summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
committerToon Claes <toon@gitlab.com>2019-02-28 19:57:34 +0100
commit62d7990b9bb30cf33ed87017c5c633d1cccc75c2 (patch)
treec3e1b69c58a412ba1c6f50a0337a23d9f9d6e1a4
parentf6453eca992a9c142268e78ac782cef98110d183 (diff)
downloadgitlab-ce-tc-standard-gem.tar.gz
Ran standardrb --fix on the whole codebasetc-standard-gem
Inspired by https://twitter.com/searls/status/1101137953743613952 I decided to try https://github.com/testdouble/standard on our codebase. It's opinionated, but at least it's a _standard_.
-rw-r--r--Dangerfile28
-rw-r--r--Gemfile475
-rw-r--r--Gemfile.lock32
-rwxr-xr-xRakefile4
-rw-r--r--app/controllers/abuse_reports_controller.rb6
-rw-r--r--app/controllers/admin/appearances_controller.rb16
-rw-r--r--app/controllers/admin/application_controller.rb2
-rw-r--r--app/controllers/admin/application_settings_controller.rb12
-rw-r--r--app/controllers/admin/applications_controller.rb4
-rw-r--r--app/controllers/admin/broadcast_messages_controller.rb12
-rw-r--r--app/controllers/admin/dashboard_controller.rb2
-rw-r--r--app/controllers/admin/deploy_keys_controller.rb6
-rw-r--r--app/controllers/admin/groups_controller.rb18
-rw-r--r--app/controllers/admin/health_check_controller.rb2
-rw-r--r--app/controllers/admin/hooks_controller.rb6
-rw-r--r--app/controllers/admin/identities_controller.rb8
-rw-r--r--app/controllers/admin/impersonation_tokens_controller.rb6
-rw-r--r--app/controllers/admin/impersonations_controller.rb2
-rw-r--r--app/controllers/admin/jobs_controller.rb8
-rw-r--r--app/controllers/admin/keys_controller.rb4
-rw-r--r--app/controllers/admin/labels_controller.rb4
-rw-r--r--app/controllers/admin/logs_controller.rb2
-rw-r--r--app/controllers/admin/projects_controller.rb17
-rw-r--r--app/controllers/admin/requests_profiles_controller.rb2
-rw-r--r--app/controllers/admin/runner_projects_controller.rb4
-rw-r--r--app/controllers/admin/runners_controller.rb12
-rw-r--r--app/controllers/admin/services_controller.rb4
-rw-r--r--app/controllers/admin/spam_logs_controller.rb8
-rw-r--r--app/controllers/admin/system_info_controller.rb68
-rw-r--r--app/controllers/admin/users_controller.rb22
-rw-r--r--app/controllers/application_controller.rb96
-rw-r--r--app/controllers/boards/application_controller.rb2
-rw-r--r--app/controllers/boards/issues_controller.rb33
-rw-r--r--app/controllers/boards/lists_controller.rb2
-rw-r--r--app/controllers/chaos_controller.rb2
-rw-r--r--app/controllers/clusters/applications_controller.rb2
-rw-r--r--app/controllers/clusters/base_controller.rb2
-rw-r--r--app/controllers/clusters/clusters_controller.rb43
-rw-r--r--app/controllers/concerns/authenticates_with_two_factor.rb20
-rw-r--r--app/controllers/concerns/creates_commit.rb11
-rw-r--r--app/controllers/concerns/cycle_analytics_params.rb6
-rw-r--r--app/controllers/concerns/diff_for_path.rb6
-rw-r--r--app/controllers/concerns/group_tree.rb12
-rw-r--r--app/controllers/concerns/internal_redirect.rb2
-rw-r--r--app/controllers/concerns/issuable_actions.rb25
-rw-r--r--app/controllers/concerns/issuable_collections.rb38
-rw-r--r--app/controllers/concerns/issuable_collections_action.rb18
-rw-r--r--app/controllers/concerns/issues_calendar.rb8
-rw-r--r--app/controllers/concerns/labels_as_hash.rb2
-rw-r--r--app/controllers/concerns/lfs_request.rb16
-rw-r--r--app/controllers/concerns/membership_actions.rb14
-rw-r--r--app/controllers/concerns/milestone_actions.rb8
-rw-r--r--app/controllers/concerns/notes_actions.rb36
-rw-r--r--app/controllers/concerns/oauth_applications.rb2
-rw-r--r--app/controllers/concerns/preview_markdown.rb14
-rw-r--r--app/controllers/concerns/renders_blob.rb8
-rw-r--r--app/controllers/concerns/renders_commits.rb2
-rw-r--r--app/controllers/concerns/renders_notes.rb2
-rw-r--r--app/controllers/concerns/requires_whitelisted_monitoring_client.rb4
-rw-r--r--app/controllers/concerns/routable_actions.rb4
-rw-r--r--app/controllers/concerns/send_file_upload.rb11
-rw-r--r--app/controllers/concerns/sends_blob.rb8
-rw-r--r--app/controllers/concerns/service_params.rb2
-rw-r--r--app/controllers/concerns/sessionless_authentication.rb2
-rw-r--r--app/controllers/concerns/snippets_actions.rb6
-rw-r--r--app/controllers/concerns/spammable_actions.rb16
-rw-r--r--app/controllers/concerns/todos_actions.rb2
-rw-r--r--app/controllers/concerns/toggle_award_emoji.rb4
-rw-r--r--app/controllers/concerns/uploads_actions.rb15
-rw-r--r--app/controllers/concerns/with_performance_bar.rb4
-rw-r--r--app/controllers/confirmations_controller.rb2
-rw-r--r--app/controllers/dashboard/application_controller.rb2
-rw-r--r--app/controllers/dashboard/labels_controller.rb2
-rw-r--r--app/controllers/dashboard/projects_controller.rb20
-rw-r--r--app/controllers/dashboard/todos_controller.rb8
-rw-r--r--app/controllers/dashboard_controller.rb2
-rw-r--r--app/controllers/explore/application_controller.rb2
-rw-r--r--app/controllers/explore/projects_controller.rb22
-rw-r--r--app/controllers/graphql_controller.rb4
-rw-r--r--app/controllers/groups/application_controller.rb6
-rw-r--r--app/controllers/groups/children_controller.rb12
-rw-r--r--app/controllers/groups/clusters_controller.rb2
-rw-r--r--app/controllers/groups/group_members_controller.rb9
-rw-r--r--app/controllers/groups/labels_controller.rb9
-rw-r--r--app/controllers/groups/milestones_controller.rb2
-rw-r--r--app/controllers/groups/runners_controller.rb16
-rw-r--r--app/controllers/groups/settings/ci_cd_controller.rb2
-rw-r--r--app/controllers/groups/shared_projects_controller.rb4
-rw-r--r--app/controllers/groups/uploads_controller.rb2
-rw-r--r--app/controllers/groups/variables_controller.rb4
-rw-r--r--app/controllers/groups_controller.rb42
-rw-r--r--app/controllers/health_controller.rb14
-rw-r--r--app/controllers/help_controller.rb24
-rw-r--r--app/controllers/ide_controller.rb2
-rw-r--r--app/controllers/import/base_controller.rb2
-rw-r--r--app/controllers/import/bitbucket_controller.rb14
-rw-r--r--app/controllers/import/bitbucket_server_controller.rb24
-rw-r--r--app/controllers/import/fogbugz_controller.rb16
-rw-r--r--app/controllers/import/gitea_controller.rb4
-rw-r--r--app/controllers/import/github_controller.rb14
-rw-r--r--app/controllers/import/gitlab_controller.rb12
-rw-r--r--app/controllers/import/gitlab_projects_controller.rb10
-rw-r--r--app/controllers/import/google_code_controller.rb12
-rw-r--r--app/controllers/import/manifest_controller.rb14
-rw-r--r--app/controllers/instance_statistics/application_controller.rb2
-rw-r--r--app/controllers/instance_statistics/cohorts_controller.rb4
-rw-r--r--app/controllers/invites_controller.rb6
-rw-r--r--app/controllers/jwt_controller.rb22
-rw-r--r--app/controllers/ldap/omniauth_callbacks_controller.rb4
-rw-r--r--app/controllers/metrics_controller.rb15
-rw-r--r--app/controllers/notification_settings_controller.rb4
-rw-r--r--app/controllers/oauth/applications_controller.rb2
-rw-r--r--app/controllers/oauth/authorizations_controller.rb2
-rw-r--r--app/controllers/oauth/authorized_applications_controller.rb6
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb40
-rw-r--r--app/controllers/passwords_controller.rb8
-rw-r--r--app/controllers/profiles/application_controller.rb2
-rw-r--r--app/controllers/profiles/keys_controller.rb2
-rw-r--r--app/controllers/profiles/passwords_controller.rb22
-rw-r--r--app/controllers/profiles/personal_access_tokens_controller.rb6
-rw-r--r--app/controllers/profiles/preferences_controller.rb6
-rw-r--r--app/controllers/profiles/two_factor_auths_controller.rb20
-rw-r--r--app/controllers/profiles_controller.rb18
-rw-r--r--app/controllers/projects/application_controller.rb6
-rw-r--r--app/controllers/projects/artifacts_controller.rb6
-rw-r--r--app/controllers/projects/avatars_controller.rb2
-rw-r--r--app/controllers/projects/badges_controller.rb14
-rw-r--r--app/controllers/projects/blame_controller.rb2
-rw-r--r--app/controllers/projects/blob_controller.rb26
-rw-r--r--app/controllers/projects/branches_controller.rb28
-rw-r--r--app/controllers/projects/build_artifacts_controller.rb2
-rw-r--r--app/controllers/projects/ci/lints_controller.rb2
-rw-r--r--app/controllers/projects/clusters_controller.rb2
-rw-r--r--app/controllers/projects/commit_controller.rb24
-rw-r--r--app/controllers/projects/commits_controller.rb13
-rw-r--r--app/controllers/projects/compare_controller.rb12
-rw-r--r--app/controllers/projects/cycle_analytics/events_controller.rb2
-rw-r--r--app/controllers/projects/cycle_analytics_controller.rb4
-rw-r--r--app/controllers/projects/deploy_keys_controller.rb24
-rw-r--r--app/controllers/projects/deploy_tokens_controller.rb2
-rw-r--r--app/controllers/projects/deployments_controller.rb6
-rw-r--r--app/controllers/projects/discussions_controller.rb6
-rw-r--r--app/controllers/projects/environments_controller.rb10
-rw-r--r--app/controllers/projects/error_tracking_controller.rb8
-rw-r--r--app/controllers/projects/forks_controller.rb4
-rw-r--r--app/controllers/projects/git_http_client_controller.rb12
-rw-r--r--app/controllers/projects/git_http_controller.rb10
-rw-r--r--app/controllers/projects/graphs_controller.rb8
-rw-r--r--app/controllers/projects/group_links_controller.rb4
-rw-r--r--app/controllers/projects/hook_logs_controller.rb2
-rw-r--r--app/controllers/projects/hooks_controller.rb6
-rw-r--r--app/controllers/projects/imports_controller.rb4
-rw-r--r--app/controllers/projects/issues_controller.rb33
-rw-r--r--app/controllers/projects/jobs_controller.rb36
-rw-r--r--app/controllers/projects/labels_controller.rb32
-rw-r--r--app/controllers/projects/lfs_api_controller.rb36
-rw-r--r--app/controllers/projects/lfs_locks_api_controller.rb8
-rw-r--r--app/controllers/projects/lfs_storage_controller.rb14
-rw-r--r--app/controllers/projects/mattermosts_controller.rb11
-rw-r--r--app/controllers/projects/merge_requests/application_controller.rb2
-rw-r--r--app/controllers/projects/merge_requests/conflicts_controller.rb18
-rw-r--r--app/controllers/projects/merge_requests/creations_controller.rb16
-rw-r--r--app/controllers/projects/merge_requests/diffs_controller.rb8
-rw-r--r--app/controllers/projects/merge_requests_controller.rb48
-rw-r--r--app/controllers/projects/milestones_controller.rb6
-rw-r--r--app/controllers/projects/mirrors_controller.rb16
-rw-r--r--app/controllers/projects/network_controller.rb4
-rw-r--r--app/controllers/projects/notes_controller.rb8
-rw-r--r--app/controllers/projects/pages_controller.rb10
-rw-r--r--app/controllers/projects/pages_domains_controller.rb16
-rw-r--r--app/controllers/projects/pipeline_schedules_controller.rb10
-rw-r--r--app/controllers/projects/pipelines_controller.rb28
-rw-r--r--app/controllers/projects/project_members_controller.rb4
-rw-r--r--app/controllers/projects/protected_branches_controller.rb4
-rw-r--r--app/controllers/projects/protected_refs_controller.rb2
-rw-r--r--app/controllers/projects/raw_controller.rb2
-rw-r--r--app/controllers/projects/registry/application_controller.rb2
-rw-r--r--app/controllers/projects/repositories_controller.rb2
-rw-r--r--app/controllers/projects/runner_projects_controller.rb4
-rw-r--r--app/controllers/projects/runners_controller.rb22
-rw-r--r--app/controllers/projects/services_controller.rb8
-rw-r--r--app/controllers/projects/settings/ci_cd_controller.rb8
-rw-r--r--app/controllers/projects/settings/operations_controller.rb6
-rw-r--r--app/controllers/projects/settings/repository_controller.rb22
-rw-r--r--app/controllers/projects/snippets_controller.rb8
-rw-r--r--app/controllers/projects/tags_controller.rb6
-rw-r--r--app/controllers/projects/templates_controller.rb2
-rw-r--r--app/controllers/projects/tree_controller.rb4
-rw-r--r--app/controllers/projects/triggers_controller.rb20
-rw-r--r--app/controllers/projects/uploads_controller.rb2
-rw-r--r--app/controllers/projects/variables_controller.rb4
-rw-r--r--app/controllers/projects/wikis_controller.rb32
-rw-r--r--app/controllers/projects_controller.rb79
-rw-r--r--app/controllers/registrations_controller.rb18
-rw-r--r--app/controllers/root_controller.rb20
-rw-r--r--app/controllers/search_controller.rb6
-rw-r--r--app/controllers/sent_notifications_controller.rb2
-rw-r--r--app/controllers/sessions_controller.rb18
-rw-r--r--app/controllers/sherlock/transactions_controller.rb2
-rw-r--r--app/controllers/snippets/notes_controller.rb6
-rw-r--r--app/controllers/snippets_controller.rb12
-rw-r--r--app/controllers/uploads_controller.rb14
-rw-r--r--app/controllers/users/terms_controller.rb10
-rw-r--r--app/controllers/users_controller.rb34
-rw-r--r--app/finders/admin/projects_finder.rb4
-rw-r--r--app/finders/admin/runners_finder.rb6
-rw-r--r--app/finders/autocomplete/users_finder.rb4
-rw-r--r--app/finders/awarded_emoji_finder.rb2
-rw-r--r--app/finders/branches_finder.rb6
-rw-r--r--app/finders/concerns/custom_attributes_filter.rb4
-rw-r--r--app/finders/concerns/finder_methods.rb2
-rw-r--r--app/finders/environments_finder.rb2
-rw-r--r--app/finders/events_finder.rb6
-rw-r--r--app/finders/group_descendants_finder.rb34
-rw-r--r--app/finders/group_finder.rb2
-rw-r--r--app/finders/group_labels_finder.rb2
-rw-r--r--app/finders/group_members_finder.rb2
-rw-r--r--app/finders/group_projects_finder.rb10
-rw-r--r--app/finders/groups_finder.rb6
-rw-r--r--app/finders/issuable_finder.rb40
-rw-r--r--app/finders/issues_finder.rb2
-rw-r--r--app/finders/labels_finder.rb14
-rw-r--r--app/finders/members_finder.rb44
-rw-r--r--app/finders/merge_requests_finder.rb10
-rw-r--r--app/finders/milestones_finder.rb4
-rw-r--r--app/finders/notes_finder.rb4
-rw-r--r--app/finders/personal_access_tokens_finder.rb4
-rw-r--r--app/finders/pipeline_schedules_finder.rb4
-rw-r--r--app/finders/pipelines_finder.rb36
-rw-r--r--app/finders/projects/serverless/functions_finder.rb3
-rw-r--r--app/finders/projects_finder.rb10
-rw-r--r--app/finders/snippets_finder.rb12
-rw-r--r--app/finders/template_finder.rb2
-rw-r--r--app/finders/todos_finder.rb6
-rw-r--r--app/finders/users_finder.rb4
-rw-r--r--app/graphql/mutations/base_mutation.rb4
-rw-r--r--app/graphql/mutations/merge_requests/base.rb14
-rw-r--r--app/graphql/mutations/merge_requests/set_wip.rb16
-rw-r--r--app/graphql/resolvers/base_resolver.rb4
-rw-r--r--app/graphql/resolvers/concerns/resolves_pipelines.rb18
-rw-r--r--app/graphql/resolvers/full_path_resolver.rb4
-rw-r--r--app/graphql/resolvers/issues_resolver.rb48
-rw-r--r--app/graphql/resolvers/merge_request_pipelines_resolver.rb2
-rw-r--r--app/graphql/resolvers/merge_requests_resolver.rb10
-rw-r--r--app/graphql/resolvers/project_pipelines_resolver.rb2
-rw-r--r--app/graphql/types/ci/pipeline_type.rb14
-rw-r--r--app/graphql/types/issuable_state_enum.rb10
-rw-r--r--app/graphql/types/issue_state_enum.rb4
-rw-r--r--app/graphql/types/issue_type.rb18
-rw-r--r--app/graphql/types/label_type.rb2
-rw-r--r--app/graphql/types/merge_request_state_enum.rb6
-rw-r--r--app/graphql/types/merge_request_type.rb4
-rw-r--r--app/graphql/types/milestone_type.rb2
-rw-r--r--app/graphql/types/permission_types/base_permission_type.rb5
-rw-r--r--app/graphql/types/permission_types/ci/pipeline.rb2
-rw-r--r--app/graphql/types/permission_types/issue.rb8
-rw-r--r--app/graphql/types/permission_types/merge_request.rb6
-rw-r--r--app/graphql/types/permission_types/project.rb24
-rw-r--r--app/graphql/types/project_type.rb44
-rw-r--r--app/graphql/types/query_type.rb10
-rw-r--r--app/graphql/types/time_type.rb4
-rw-r--r--app/graphql/types/user_type.rb2
-rw-r--r--app/helpers/active_sessions_helper.rb20
-rw-r--r--app/helpers/appearances_helper.rb10
-rw-r--r--app/helpers/application_helper.rb62
-rw-r--r--app/helpers/application_settings_helper.rb72
-rw-r--r--app/helpers/auth_helper.rb14
-rw-r--r--app/helpers/auto_devops_helper.rb2
-rw-r--r--app/helpers/avatars_helper.rb22
-rw-r--r--app/helpers/blame_helper.rb2
-rw-r--r--app/helpers/blob_helper.rb116
-rw-r--r--app/helpers/boards_helper.rb26
-rw-r--r--app/helpers/breadcrumbs_helper.rb2
-rw-r--r--app/helpers/broadcast_messages_helper.rb12
-rw-r--r--app/helpers/builds_helper.rb10
-rw-r--r--app/helpers/button_helper.rb30
-rw-r--r--app/helpers/calendar_helper.rb8
-rw-r--r--app/helpers/ci_status_helper.rb104
-rw-r--r--app/helpers/clusters_helper.rb4
-rw-r--r--app/helpers/commits_helper.rb62
-rw-r--r--app/helpers/compare_helper.rb2
-rw-r--r--app/helpers/components_helper.rb4
-rw-r--r--app/helpers/conversational_development_index_helper.rb6
-rw-r--r--app/helpers/cookies_helper.rb2
-rw-r--r--app/helpers/diff_helper.rb56
-rw-r--r--app/helpers/dropdowns_helper.rb42
-rw-r--r--app/helpers/emails_helper.rb70
-rw-r--r--app/helpers/environment_helper.rb2
-rw-r--r--app/helpers/environments_helper.rb22
-rw-r--r--app/helpers/events_helper.rb76
-rw-r--r--app/helpers/explore_helper.rb2
-rw-r--r--app/helpers/form_helper.rb30
-rw-r--r--app/helpers/gitlab_routing_helper.rb10
-rw-r--r--app/helpers/graph_helper.rb4
-rw-r--r--app/helpers/groups_helper.rb34
-rw-r--r--app/helpers/hooks_helper.rb6
-rw-r--r--app/helpers/icons_helper.rb102
-rw-r--r--app/helpers/ide_helper.rb16
-rw-r--r--app/helpers/import_helper.rb28
-rw-r--r--app/helpers/instance_configuration_helper.rb2
-rw-r--r--app/helpers/issuables_helper.rb89
-rw-r--r--app/helpers/issues_helper.rb46
-rw-r--r--app/helpers/labels_helper.rb100
-rw-r--r--app/helpers/lazy_image_tag_helper.rb2
-rw-r--r--app/helpers/markup_helper.rb50
-rw-r--r--app/helpers/mattermost_helper.rb2
-rw-r--r--app/helpers/members_helper.rb10
-rw-r--r--app/helpers/merge_requests_helper.rb26
-rw-r--r--app/helpers/milestones_helper.rb46
-rw-r--r--app/helpers/mirror_helper.rb2
-rw-r--r--app/helpers/namespaces_helper.rb18
-rw-r--r--app/helpers/nav_helper.rb32
-rw-r--r--app/helpers/notes_helper.rb41
-rw-r--r--app/helpers/notifications_helper.rb44
-rw-r--r--app/helpers/numbers_helper.rb2
-rw-r--r--app/helpers/page_layout_helper.rb6
-rw-r--r--app/helpers/pagination_helper.rb4
-rw-r--r--app/helpers/pipeline_schedules_helper.rb2
-rw-r--r--app/helpers/preferences_helper.rb22
-rw-r--r--app/helpers/profiles_helper.rb8
-rw-r--r--app/helpers/projects/error_tracking_helper.rb10
-rw-r--r--app/helpers/projects_helper.rb108
-rw-r--r--app/helpers/repository_languages_helper.rb4
-rw-r--r--app/helpers/rss_helper.rb2
-rw-r--r--app/helpers/runners_helper.rb12
-rw-r--r--app/helpers/search_helper.rb84
-rw-r--r--app/helpers/selects_helper.rb40
-rw-r--r--app/helpers/services_helper.rb6
-rw-r--r--app/helpers/sidekiq_helper.rb2
-rw-r--r--app/helpers/snippets_helper.rb40
-rw-r--r--app/helpers/sorting_helper.rb258
-rw-r--r--app/helpers/storage_helper.rb2
-rw-r--r--app/helpers/submodule_helper.rb42
-rw-r--r--app/helpers/system_note_helper.rb46
-rw-r--r--app/helpers/tab_helper.rb20
-rw-r--r--app/helpers/tags_helper.rb2
-rw-r--r--app/helpers/todos_helper.rb80
-rw-r--r--app/helpers/tree_helper.rb26
-rw-r--r--app/helpers/user_callouts_helper.rb6
-rw-r--r--app/helpers/users_helper.rb36
-rw-r--r--app/helpers/version_check_helper.rb10
-rw-r--r--app/helpers/visibility_level_helper.rb22
-rw-r--r--app/helpers/webpack_helper.rb20
-rw-r--r--app/helpers/wiki_helper.rb10
-rw-r--r--app/helpers/workhorse_helper.rb8
-rw-r--r--app/mailers/abuse_report_mailer.rb6
-rw-r--r--app/mailers/devise_mailer.rb4
-rw-r--r--app/mailers/email_rejection_mailer.rb12
-rw-r--r--app/mailers/emails/auto_devops.rb4
-rw-r--r--app/mailers/emails/issues.rb16
-rw-r--r--app/mailers/emails/members.rb4
-rw-r--r--app/mailers/emails/merge_requests.rb10
-rw-r--r--app/mailers/emails/notes.rb2
-rw-r--r--app/mailers/emails/pipelines.rb16
-rw-r--r--app/mailers/emails/projects.rb8
-rw-r--r--app/mailers/emails/remote_mirrors.rb2
-rw-r--r--app/mailers/notify.rb41
-rw-r--r--app/mailers/previews/devise_mailer_preview.rb12
-rw-r--r--app/mailers/previews/notify_preview.rb30
-rw-r--r--app/mailers/repository_check_mailer.rb2
-rw-r--r--app/models/ability.rb2
-rw-r--r--app/models/abuse_report.rb12
-rw-r--r--app/models/active_session.rb4
-rw-r--r--app/models/appearance.rb21
-rw-r--r--app/models/application_setting.rb206
-rw-r--r--app/models/audit_event.rb2
-rw-r--r--app/models/award_emoji.rb20
-rw-r--r--app/models/badge.rb10
-rw-r--r--app/models/blob.rb6
-rw-r--r--app/models/blob_viewer/auxiliary.rb2
-rw-r--r--app/models/blob_viewer/balsamiq.rb8
-rw-r--r--app/models/blob_viewer/base.rb4
-rw-r--r--app/models/blob_viewer/binary_stl.rb4
-rw-r--r--app/models/blob_viewer/cartfile.rb6
-rw-r--r--app/models/blob_viewer/changelog.rb4
-rw-r--r--app/models/blob_viewer/composer_json.rb8
-rw-r--r--app/models/blob_viewer/contributing.rb4
-rw-r--r--app/models/blob_viewer/dependency_manager.rb8
-rw-r--r--app/models/blob_viewer/download.rb2
-rw-r--r--app/models/blob_viewer/empty.rb2
-rw-r--r--app/models/blob_viewer/gemfile.rb6
-rw-r--r--app/models/blob_viewer/gemspec.rb10
-rw-r--r--app/models/blob_viewer/gitlab_ci_yml.rb6
-rw-r--r--app/models/blob_viewer/godeps_json.rb6
-rw-r--r--app/models/blob_viewer/image.rb6
-rw-r--r--app/models/blob_viewer/license.rb4
-rw-r--r--app/models/blob_viewer/markup.rb4
-rw-r--r--app/models/blob_viewer/notebook.rb8
-rw-r--r--app/models/blob_viewer/package_json.rb14
-rw-r--r--app/models/blob_viewer/pdf.rb8
-rw-r--r--app/models/blob_viewer/podfile.rb6
-rw-r--r--app/models/blob_viewer/podspec.rb10
-rw-r--r--app/models/blob_viewer/podspec_json.rb4
-rw-r--r--app/models/blob_viewer/readme.rb4
-rw-r--r--app/models/blob_viewer/requirements_txt.rb6
-rw-r--r--app/models/blob_viewer/rich.rb4
-rw-r--r--app/models/blob_viewer/route_map.rb6
-rw-r--r--app/models/blob_viewer/simple.rb4
-rw-r--r--app/models/blob_viewer/sketch.rb8
-rw-r--r--app/models/blob_viewer/svg.rb8
-rw-r--r--app/models/blob_viewer/text.rb2
-rw-r--r--app/models/blob_viewer/video.rb6
-rw-r--r--app/models/blob_viewer/yarn_lock.rb6
-rw-r--r--app/models/board_group_recent_visit.rb2
-rw-r--r--app/models/board_project_recent_visit.rb2
-rw-r--r--app/models/broadcast_message.rb14
-rw-r--r--app/models/chat_name.rb4
-rw-r--r--app/models/ci/artifact_blob.rb12
-rw-r--r--app/models/ci/bridge.rb2
-rw-r--r--app/models/ci/build.rb202
-rw-r--r--app/models/ci/build_metadata.rb12
-rw-r--r--app/models/ci/build_runner_session.rb12
-rw-r--r--app/models/ci/build_trace_chunk.rb24
-rw-r--r--app/models/ci/build_trace_section.rb4
-rw-r--r--app/models/ci/build_trace_section_name.rb4
-rw-r--r--app/models/ci/group.rb2
-rw-r--r--app/models/ci/group_variable.rb2
-rw-r--r--app/models/ci/job_artifact.rb48
-rw-r--r--app/models/ci/legacy_stage.rb2
-rw-r--r--app/models/ci/pipeline.rb148
-rw-r--r--app/models/ci/pipeline_chat_data.rb2
-rw-r--r--app/models/ci/pipeline_enums.rb6
-rw-r--r--app/models/ci/pipeline_schedule.rb19
-rw-r--r--app/models/ci/pipeline_schedule_variable.rb2
-rw-r--r--app/models/ci/pipeline_variable.rb4
-rw-r--r--app/models/ci/runner.rb62
-rw-r--r--app/models/ci/runner_namespace.rb6
-rw-r--r--app/models/ci/runner_project.rb2
-rw-r--r--app/models/ci/stage.rb28
-rw-r--r--app/models/ci/trigger.rb6
-rw-r--r--app/models/ci/trigger_request.rb2
-rw-r--r--app/models/ci/variable.rb2
-rw-r--r--app/models/clusters/applications/cert_manager.rb14
-rw-r--r--app/models/clusters/applications/helm.rb10
-rw-r--r--app/models/clusters/applications/ingress.rb13
-rw-r--r--app/models/clusters/applications/jupyter.rb30
-rw-r--r--app/models/clusters/applications/knative.rb25
-rw-r--r--app/models/clusters/applications/prometheus.rb12
-rw-r--r--app/models/clusters/applications/runner.rb16
-rw-r--r--app/models/clusters/cluster.rb70
-rw-r--r--app/models/clusters/concerns/application_core.rb6
-rw-r--r--app/models/clusters/concerns/application_data.rb4
-rw-r--r--app/models/clusters/concerns/application_status.rb4
-rw-r--r--app/models/clusters/group.rb6
-rw-r--r--app/models/clusters/kubernetes_namespace.rb27
-rw-r--r--app/models/clusters/platforms/kubernetes.rb55
-rw-r--r--app/models/clusters/project.rb10
-rw-r--r--app/models/clusters/providers/gcp.rb16
-rw-r--r--app/models/commit.rb47
-rw-r--r--app/models/commit_range.rb20
-rw-r--r--app/models/commit_status.rb14
-rw-r--r--app/models/commit_status_enums.rb2
-rw-r--r--app/models/compare.rb8
-rw-r--r--app/models/concerns/atomic_internal_id.rb2
-rw-r--r--app/models/concerns/avatarable.rb20
-rw-r--r--app/models/concerns/awardable.rb18
-rw-r--r--app/models/concerns/blob_language_from_git_attributes.rb2
-rw-r--r--app/models/concerns/blocks_json_serialization.rb2
-rw-r--r--app/models/concerns/bulk_member_access_load.rb6
-rw-r--r--app/models/concerns/cache_markdown_field.rb18
-rw-r--r--app/models/concerns/cacheable_attributes.rb2
-rw-r--r--app/models/concerns/case_sensitivity.rb8
-rw-r--r--app/models/concerns/chronic_duration_attribute.rb2
-rw-r--r--app/models/concerns/ci/metadatable.rb8
-rw-r--r--app/models/concerns/ci/processable.rb2
-rw-r--r--app/models/concerns/deployable.rb3
-rw-r--r--app/models/concerns/deployment_platform.rb6
-rw-r--r--app/models/concerns/diff_positionable_note.rb25
-rw-r--r--app/models/concerns/discussion_on_diff.rb27
-rw-r--r--app/models/concerns/each_batch.rb2
-rw-r--r--app/models/concerns/expirable.rb2
-rw-r--r--app/models/concerns/fast_destroy_all.rb2
-rw-r--r--app/models/concerns/ghost_user.rb2
-rw-r--r--app/models/concerns/group_descendant.rb18
-rw-r--r--app/models/concerns/has_status.rb68
-rw-r--r--app/models/concerns/has_variable.rb16
-rw-r--r--app/models/concerns/importable.rb4
-rw-r--r--app/models/concerns/issuable.rb100
-rw-r--r--app/models/concerns/loaded_in_group_list.rb16
-rw-r--r--app/models/concerns/maskable.rb4
-rw-r--r--app/models/concerns/mentionable.rb12
-rw-r--r--app/models/concerns/mentionable/reference_regexes.rb8
-rw-r--r--app/models/concerns/milestoneish.rb10
-rw-r--r--app/models/concerns/mirror_authentication.rb16
-rw-r--r--app/models/concerns/noteable.rb4
-rw-r--r--app/models/concerns/participable.rb4
-rw-r--r--app/models/concerns/project_features_compatibility.rb2
-rw-r--r--app/models/concerns/project_services_loggable.rb2
-rw-r--r--app/models/concerns/prometheus_adapter.rb4
-rw-r--r--app/models/concerns/protected_ref.rb12
-rw-r--r--app/models/concerns/protected_ref_access.rb16
-rw-r--r--app/models/concerns/reactive_caching.rb4
-rw-r--r--app/models/concerns/redactable.rb2
-rw-r--r--app/models/concerns/redis_cacheable.rb4
-rw-r--r--app/models/concerns/referable.rb4
-rw-r--r--app/models/concerns/relative_positioning.rb34
-rw-r--r--app/models/concerns/resolvable_discussion.rb17
-rw-r--r--app/models/concerns/resolvable_note.rb4
-rw-r--r--app/models/concerns/routable.rb16
-rw-r--r--app/models/concerns/sha_attribute.rb2
-rw-r--r--app/models/concerns/sortable.rb20
-rw-r--r--app/models/concerns/spammable.rb26
-rw-r--r--app/models/concerns/storage/legacy_namespace.rb12
-rw-r--r--app/models/concerns/storage/legacy_project_wiki.rb2
-rw-r--r--app/models/concerns/strip_attribute.rb2
-rw-r--r--app/models/concerns/subscribable.rb4
-rw-r--r--app/models/concerns/taskable.rb20
-rw-r--r--app/models/concerns/time_trackable.rb6
-rw-r--r--app/models/concerns/token_authenticatable_strategies/base.rb6
-rw-r--r--app/models/concerns/token_authenticatable_strategies/encrypted.rb6
-rw-r--r--app/models/concerns/triggerable_hooks.rb20
-rw-r--r--app/models/concerns/valid_attribute.rb2
-rw-r--r--app/models/concerns/with_uploads.rb4
-rw-r--r--app/models/container_repository.rb18
-rw-r--r--app/models/conversational_development_index/idea_to_production_step.rb4
-rw-r--r--app/models/conversational_development_index/metric.rb2
-rw-r--r--app/models/cycle_analytics.rb4
-rw-r--r--app/models/dashboard_group_milestone.rb7
-rw-r--r--app/models/deploy_key.rb8
-rw-r--r--app/models/deploy_keys_project.rb8
-rw-r--r--app/models/deploy_token.rb4
-rw-r--r--app/models/deployment.rb30
-rw-r--r--app/models/diff_discussion.rb13
-rw-r--r--app/models/diff_note.rb44
-rw-r--r--app/models/diff_viewer/added.rb2
-rw-r--r--app/models/diff_viewer/base.rb8
-rw-r--r--app/models/diff_viewer/deleted.rb2
-rw-r--r--app/models/diff_viewer/image.rb6
-rw-r--r--app/models/diff_viewer/mode_changed.rb2
-rw-r--r--app/models/diff_viewer/no_preview.rb2
-rw-r--r--app/models/diff_viewer/not_diffable.rb2
-rw-r--r--app/models/diff_viewer/renamed.rb2
-rw-r--r--app/models/diff_viewer/rich.rb4
-rw-r--r--app/models/diff_viewer/server_side.rb4
-rw-r--r--app/models/diff_viewer/simple.rb4
-rw-r--r--app/models/diff_viewer/text.rb2
-rw-r--r--app/models/discussion.rb26
-rw-r--r--app/models/discussion_note.rb4
-rw-r--r--app/models/email.rb4
-rw-r--r--app/models/environment.rb81
-rw-r--r--app/models/environment_status.rb6
-rw-r--r--app/models/epic.rb4
-rw-r--r--app/models/error_tracking/project_error_tracking_setting.rb24
-rw-r--r--app/models/event.rb68
-rw-r--r--app/models/event_collection.rb10
-rw-r--r--app/models/external_issue.rb2
-rw-r--r--app/models/fork_network.rb2
-rw-r--r--app/models/fork_network_member.rb2
-rw-r--r--app/models/generic_commit_status.rb6
-rw-r--r--app/models/global_milestone.rb31
-rw-r--r--app/models/gpg_key.rb22
-rw-r--r--app/models/gpg_signature.rb2
-rw-r--r--app/models/group.rb66
-rw-r--r--app/models/group_custom_attribute.rb2
-rw-r--r--app/models/group_label.rb2
-rw-r--r--app/models/group_milestone.rb5
-rw-r--r--app/models/hooks/project_hook.rb2
-rw-r--r--app/models/hooks/service_hook.rb2
-rw-r--r--app/models/hooks/system_hook.rb2
-rw-r--r--app/models/hooks/web_hook.rb18
-rw-r--r--app/models/hooks/web_hook_log.rb2
-rw-r--r--app/models/identity.rb6
-rw-r--r--app/models/instance_configuration.rb34
-rw-r--r--app/models/internal_id.rb6
-rw-r--r--app/models/issue.rb70
-rw-r--r--app/models/issue/metrics.rb6
-rw-r--r--app/models/issue_collection.rb2
-rw-r--r--app/models/key.rb16
-rw-r--r--app/models/label.rb64
-rw-r--r--app/models/label_note.rb16
-rw-r--r--app/models/label_priority.rb4
-rw-r--r--app/models/legacy_diff_discussion.rb2
-rw-r--r--app/models/legacy_diff_note.rb16
-rw-r--r--app/models/lfs_download_object.rb6
-rw-r--r--app/models/lfs_object.rb6
-rw-r--r--app/models/lfs_objects_project.rb2
-rw-r--r--app/models/license_template.rb2
-rw-r--r--app/models/list.rb6
-rw-r--r--app/models/member.rb66
-rw-r--r--app/models/members/group_member.rb10
-rw-r--r--app/models/members/project_member.rb22
-rw-r--r--app/models/merge_request.rb194
-rw-r--r--app/models/merge_request/metrics.rb6
-rw-r--r--app/models/merge_request_diff.rb40
-rw-r--r--app/models/merge_request_diff_commit.rb6
-rw-r--r--app/models/merge_request_diff_file.rb4
-rw-r--r--app/models/merge_requests_closing_issues.rb4
-rw-r--r--app/models/milestone.rb68
-rw-r--r--app/models/namespace.rb40
-rw-r--r--app/models/network/graph.rb20
-rw-r--r--app/models/note.rb56
-rw-r--r--app/models/note_diff_file.rb6
-rw-r--r--app/models/notification_reason.rb8
-rw-r--r--app/models/notification_recipient.rb2
-rw-r--r--app/models/notification_setting.rb22
-rw-r--r--app/models/oauth_access_grant.rb4
-rw-r--r--app/models/oauth_access_token.rb4
-rw-r--r--app/models/pages_domain.rb24
-rw-r--r--app/models/personal_access_token.rb2
-rw-r--r--app/models/pool_repository.rb6
-rw-r--r--app/models/postgresql/replication_slot.rb2
-rw-r--r--app/models/project.rb478
-rw-r--r--app/models/project_authorization.rb12
-rw-r--r--app/models/project_auto_devops.rb14
-rw-r--r--app/models/project_custom_attribute.rb2
-rw-r--r--app/models/project_daily_statistic.rb4
-rw-r--r--app/models/project_deploy_token.rb2
-rw-r--r--app/models/project_feature.rb12
-rw-r--r--app/models/project_group_link.rb12
-rw-r--r--app/models/project_import_data.rb16
-rw-r--r--app/models/project_import_state.rb4
-rw-r--r--app/models/project_label.rb6
-rw-r--r--app/models/project_services/asana_service.rb26
-rw-r--r--app/models/project_services/assembla_service.rb14
-rw-r--r--app/models/project_services/bamboo_service.rb60
-rw-r--r--app/models/project_services/bugzilla_service.rb14
-rw-r--r--app/models/project_services/buildkite_service.rb40
-rw-r--r--app/models/project_services/builds_email_service.rb2
-rw-r--r--app/models/project_services/campfire_service.rb28
-rw-r--r--app/models/project_services/chat_message/base_message.rb8
-rw-r--r--app/models/project_services/chat_message/issue_message.rb6
-rw-r--r--app/models/project_services/chat_message/merge_message.rb4
-rw-r--r--app/models/project_services/chat_message/note_message.rb10
-rw-r--r--app/models/project_services/chat_message/pipeline_message.rb20
-rw-r--r--app/models/project_services/chat_message/push_message.rb16
-rw-r--r--app/models/project_services/chat_message/wiki_page_message.rb4
-rw-r--r--app/models/project_services/chat_notification_service.rb40
-rw-r--r--app/models/project_services/ci_service.rb6
-rw-r--r--app/models/project_services/custom_issue_tracker_service.rb26
-rw-r--r--app/models/project_services/deployment_service.rb4
-rw-r--r--app/models/project_services/discord_service.rb6
-rw-r--r--app/models/project_services/drone_ci_service.rb40
-rw-r--r--app/models/project_services/emails_on_push_service.rb24
-rw-r--r--app/models/project_services/external_wiki_service.rb16
-rw-r--r--app/models/project_services/flowdock_service.rb10
-rw-r--r--app/models/project_services/gitlab_issue_tracker_service.rb2
-rw-r--r--app/models/project_services/hangouts_chat_service.rb16
-rw-r--r--app/models/project_services/irker_service.rb60
-rw-r--r--app/models/project_services/issue_tracker_service.rb35
-rw-r--r--app/models/project_services/jira_service.rb101
-rw-r--r--app/models/project_services/kubernetes_service.rb81
-rw-r--r--app/models/project_services/mattermost_service.rb8
-rw-r--r--app/models/project_services/mattermost_slash_commands_service.rb11
-rw-r--r--app/models/project_services/microsoft_teams_service.rb14
-rw-r--r--app/models/project_services/mock_ci_service.rb28
-rw-r--r--app/models/project_services/mock_deployment_service.rb6
-rw-r--r--app/models/project_services/mock_monitoring_service.rb8
-rw-r--r--app/models/project_services/monitoring_service.rb4
-rw-r--r--app/models/project_services/packagist_service.rb24
-rw-r--r--app/models/project_services/pipelines_email_service.rb30
-rw-r--r--app/models/project_services/pivotaltracker_service.rb46
-rw-r--r--app/models/project_services/prometheus_service.rb30
-rw-r--r--app/models/project_services/pushover_service.rb84
-rw-r--r--app/models/project_services/redmine_service.rb14
-rw-r--r--app/models/project_services/slack_service.rb8
-rw-r--r--app/models/project_services/slack_slash_commands_service.rb4
-rw-r--r--app/models/project_services/slash_commands_service.rb8
-rw-r--r--app/models/project_services/teamcity_service.rb58
-rw-r--r--app/models/project_services/youtrack_service.rb16
-rw-r--r--app/models/project_statistics.rb4
-rw-r--r--app/models/project_team.rb16
-rw-r--r--app/models/project_wiki.rb36
-rw-r--r--app/models/prometheus_metric.rb68
-rw-r--r--app/models/protectable_dropdown.rb2
-rw-r--r--app/models/protected_branch.rb2
-rw-r--r--app/models/protected_tag.rb4
-rw-r--r--app/models/push_event.rb18
-rw-r--r--app/models/push_event_payload.rb6
-rw-r--r--app/models/redirect_route.rb14
-rw-r--r--app/models/ref_matcher.rb6
-rw-r--r--app/models/release.rb4
-rw-r--r--app/models/releases/link.rb6
-rw-r--r--app/models/releases/source.rb8
-rw-r--r--app/models/remote_mirror.rb40
-rw-r--r--app/models/repository.rb137
-rw-r--r--app/models/repository_language.rb4
-rw-r--r--app/models/resource_label_event.rb20
-rw-r--r--app/models/route.rb10
-rw-r--r--app/models/sent_notification.rb34
-rw-r--r--app/models/service.rb20
-rw-r--r--app/models/snippet.rb28
-rw-r--r--app/models/snippet_blob.rb2
-rw-r--r--app/models/spam_log.rb2
-rw-r--r--app/models/ssh_host_key.rb22
-rw-r--r--app/models/storage/hashed_project.rb4
-rw-r--r--app/models/subscription.rb2
-rw-r--r--app/models/suggestion.rb6
-rw-r--r--app/models/system_note_metadata.rb2
-rw-r--r--app/models/term_agreement.rb2
-rw-r--r--app/models/timelog.rb4
-rw-r--r--app/models/todo.rb34
-rw-r--r--app/models/tree.rb18
-rw-r--r--app/models/u2f_registration.rb4
-rw-r--r--app/models/upload.rb10
-rw-r--r--app/models/uploads/local.rb2
-rw-r--r--app/models/user.rb220
-rw-r--r--app/models/user_callout.rb4
-rw-r--r--app/models/user_callout_enums.rb2
-rw-r--r--app/models/user_custom_attribute.rb2
-rw-r--r--app/models/user_interacted_project.rb20
-rw-r--r--app/models/user_preference.rb12
-rw-r--r--app/models/user_status.rb6
-rw-r--r--app/models/users_star_project.rb2
-rw-r--r--app/models/wiki_directory.rb2
-rw-r--r--app/models/wiki_page.rb20
-rw-r--r--app/policies/base_policy.rb2
-rw-r--r--app/policies/ci/pipeline_schedule_policy.rb2
-rw-r--r--app/policies/clusters/cluster_policy.rb2
-rw-r--r--app/policies/global_policy.rb2
-rw-r--r--app/policies/group_policy.rb2
-rw-r--r--app/policies/namespace_policy.rb2
-rw-r--r--app/policies/project_policy.rb8
-rw-r--r--app/policies/project_policy/class_methods.rb4
-rw-r--r--app/policies/project_snippet_policy.rb10
-rw-r--r--app/presenters/ci/build_metadata_presenter.rb6
-rw-r--r--app/presenters/ci/build_runner_presenter.rb20
-rw-r--r--app/presenters/ci/group_variable_presenter.rb2
-rw-r--r--app/presenters/ci/pipeline_presenter.rb2
-rw-r--r--app/presenters/ci/variable_presenter.rb2
-rw-r--r--app/presenters/clusters/cluster_presenter.rb4
-rw-r--r--app/presenters/commit_status_presenter.rb18
-rw-r--r--app/presenters/conversational_development_index/metric_presenter.rb138
-rw-r--r--app/presenters/group_clusterable_presenter.rb6
-rw-r--r--app/presenters/merge_request_presenter.rb25
-rw-r--r--app/presenters/project_clusterable_presenter.rb4
-rw-r--r--app/presenters/project_presenter.rb180
-rw-r--r--app/presenters/projects/settings/deploy_keys_presenter.rb8
-rw-r--r--app/serializers/base_serializer.rb2
-rw-r--r--app/serializers/blob_entity.rb4
-rw-r--r--app/serializers/build_action_entity.rb6
-rw-r--r--app/serializers/build_artifact_entity.rb4
-rw-r--r--app/serializers/build_details_entity.rb34
-rw-r--r--app/serializers/build_serializer.rb2
-rw-r--r--app/serializers/cluster_application_entity.rb8
-rw-r--r--app/serializers/cluster_serializer.rb2
-rw-r--r--app/serializers/cohort_entity.rb2
-rw-r--r--app/serializers/commit_entity.rb10
-rw-r--r--app/serializers/container_repository_entity.rb4
-rw-r--r--app/serializers/container_tag_entity.rb4
-rw-r--r--app/serializers/deploy_key_entity.rb4
-rw-r--r--app/serializers/deployment_entity.rb4
-rw-r--r--app/serializers/detailed_status_entity.rb18
-rw-r--r--app/serializers/diff_file_base_entity.rb8
-rw-r--r--app/serializers/diff_file_entity.rb14
-rw-r--r--app/serializers/diffs_entity.rb10
-rw-r--r--app/serializers/discussion_entity.rb18
-rw-r--r--app/serializers/entity_date_helper.rb12
-rw-r--r--app/serializers/environment_entity.rb6
-rw-r--r--app/serializers/environment_serializer.rb14
-rw-r--r--app/serializers/group_child_entity.rb6
-rw-r--r--app/serializers/issue_board_entity.rb12
-rw-r--r--app/serializers/issue_entity.rb4
-rw-r--r--app/serializers/issue_serializer.rb6
-rw-r--r--app/serializers/job_entity.rb18
-rw-r--r--app/serializers/job_group_entity.rb2
-rw-r--r--app/serializers/label_entity.rb2
-rw-r--r--app/serializers/label_serializer.rb2
-rw-r--r--app/serializers/lfs_file_lock_entity.rb2
-rw-r--r--app/serializers/merge_request_serializer.rb6
-rw-r--r--app/serializers/merge_request_user_entity.rb2
-rw-r--r--app/serializers/merge_request_widget_entity.rb6
-rw-r--r--app/serializers/note_entity.rb16
-rw-r--r--app/serializers/pipeline_entity.rb10
-rw-r--r--app/serializers/pipeline_serializer.rb12
-rw-r--r--app/serializers/project_note_entity.rb12
-rw-r--r--app/serializers/projects/serverless/service_entity.rb47
-rw-r--r--app/serializers/runner_entity.rb4
-rw-r--r--app/serializers/stage_entity.rb24
-rw-r--r--app/serializers/submodule_entity.rb2
-rw-r--r--app/services/access_token_validation_service.rb12
-rw-r--r--app/services/akismet_service.rb10
-rw-r--r--app/services/audit_event_service.rb6
-rw-r--r--app/services/auth/container_registry_authentication_service.rb50
-rw-r--r--app/services/base_count_service.rb4
-rw-r--r--app/services/base_service.rb2
-rw-r--r--app/services/boards/issues/create_service.rb2
-rw-r--r--app/services/boards/issues/list_service.rb12
-rw-r--r--app/services/boards/issues/move_service.rb4
-rw-r--r--app/services/boards/lists/create_service.rb7
-rw-r--r--app/services/boards/lists/destroy_service.rb4
-rw-r--r--app/services/boards/lists/generate_service.rb4
-rw-r--r--app/services/boards/lists/move_service.rb12
-rw-r--r--app/services/chat_names/authorize_user_service.rb2
-rw-r--r--app/services/ci/archive_trace_service.rb6
-rw-r--r--app/services/ci/compare_reports_base_service.rb6
-rw-r--r--app/services/ci/create_pipeline_service.rb7
-rw-r--r--app/services/ci/destroy_expired_job_artifacts_service.rb2
-rw-r--r--app/services/ci/extract_sections_from_build_trace_service.rb3
-rw-r--r--app/services/ci/pipeline_trigger_service.rb6
-rw-r--r--app/services/ci/process_build_service.rb10
-rw-r--r--app/services/ci/process_pipeline_service.rb22
-rw-r--r--app/services/ci/register_job_service.rb36
-rw-r--r--app/services/ci/retry_build_service.rb4
-rw-r--r--app/services/clusters/applications/base_helm_service.rb2
-rw-r--r--app/services/clusters/applications/check_installation_progress_service.rb3
-rw-r--r--app/services/clusters/applications/create_service.rb18
-rw-r--r--app/services/clusters/applications/install_service.rb5
-rw-r--r--app/services/clusters/applications/upgrade_service.rb5
-rw-r--r--app/services/clusters/build_service.rb1
-rw-r--r--app/services/clusters/create_service.rb8
-rw-r--r--app/services/clusters/gcp/fetch_operation_service.rb3
-rw-r--r--app/services/clusters/gcp/finalize_creation_service.rb25
-rw-r--r--app/services/clusters/gcp/kubernetes.rb12
-rw-r--r--app/services/clusters/gcp/kubernetes/create_or_update_service_account_service.rb6
-rw-r--r--app/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service.rb2
-rw-r--r--app/services/clusters/gcp/provision_service.rb8
-rw-r--r--app/services/clusters/gcp/verify_provision_status_service.rb6
-rw-r--r--app/services/cohorts_service.rb12
-rw-r--r--app/services/commits/change_service.rb3
-rw-r--r--app/services/commits/commit_patch_service.rb2
-rw-r--r--app/services/commits/create_service.rb2
-rw-r--r--app/services/commits/tag_service.rb2
-rw-r--r--app/services/compare_service.rb8
-rw-r--r--app/services/concerns/exclusive_lease_guard.rb2
-rw-r--r--app/services/concerns/issues/resolve_discussions.rb2
-rw-r--r--app/services/concerns/users/participable_service.rb4
-rw-r--r--app/services/create_branch_service.rb10
-rw-r--r--app/services/create_snippet_service.rb8
-rw-r--r--app/services/delete_branch_service.rb11
-rw-r--r--app/services/emails/destroy_service.rb6
-rw-r--r--app/services/error_tracking/list_issues_service.rb8
-rw-r--r--app/services/error_tracking/list_projects_service.rb4
-rw-r--r--app/services/event_create_service.rb2
-rw-r--r--app/services/events/render_service.rb2
-rw-r--r--app/services/files/base_service.rb2
-rw-r--r--app/services/files/create_dir_service.rb3
-rw-r--r--app/services/files/create_service.rb3
-rw-r--r--app/services/files/delete_service.rb3
-rw-r--r--app/services/files/multi_service.rb4
-rw-r--r--app/services/files/update_service.rb14
-rw-r--r--app/services/git_push_service.rb3
-rw-r--r--app/services/git_tag_push_service.rb6
-rw-r--r--app/services/gravatar_service.rb4
-rw-r--r--app/services/groups/create_service.rb6
-rw-r--r--app/services/groups/nested_create_service.rb8
-rw-r--r--app/services/groups/transfer_service.rb11
-rw-r--r--app/services/import/base_service.rb2
-rw-r--r--app/services/import/github_service.rb6
-rw-r--r--app/services/import_export_clean_up_service.rb4
-rw-r--r--app/services/issuable/bulk_update_service.rb8
-rw-r--r--app/services/issuable/clone/attributes_rewriter.rb16
-rw-r--r--app/services/issuable/clone/base_service.rb4
-rw-r--r--app/services/issuable/clone/content_rewriter.rb2
-rw-r--r--app/services/issuable/common_system_notes_service.rb14
-rw-r--r--app/services/issuable_base_service.rb38
-rw-r--r--app/services/issues/base_service.rb5
-rw-r--r--app/services/issues/build_service.rb10
-rw-r--r--app/services/issues/close_service.rb8
-rw-r--r--app/services/issues/create_service.rb4
-rw-r--r--app/services/issues/import_csv_service.rb2
-rw-r--r--app/services/issues/move_service.rb24
-rw-r--r--app/services/issues/referenced_merge_requests_service.rb6
-rw-r--r--app/services/issues/reopen_service.rb4
-rw-r--r--app/services/issues/update_service.rb12
-rw-r--r--app/services/labels/base_service.rb294
-rw-r--r--app/services/labels/find_or_create_service.rb4
-rw-r--r--app/services/labels/promote_service.rb8
-rw-r--r--app/services/labels/transfer_service.rb14
-rw-r--r--app/services/lfs/file_transformer.rb6
-rw-r--r--app/services/lfs/lock_file_service.rb6
-rw-r--r--app/services/lfs/unlock_file_service.rb16
-rw-r--r--app/services/members/base_service.rb2
-rw-r--r--app/services/members/create_service.rb4
-rw-r--r--app/services/members/request_access_service.rb3
-rw-r--r--app/services/merge_requests/assign_issues_service.rb2
-rw-r--r--app/services/merge_requests/base_service.rb21
-rw-r--r--app/services/merge_requests/build_service.rb32
-rw-r--r--app/services/merge_requests/close_service.rb2
-rw-r--r--app/services/merge_requests/create_from_issue_service.rb6
-rw-r--r--app/services/merge_requests/create_service.rb2
-rw-r--r--app/services/merge_requests/ff_merge_service.rb8
-rw-r--r--app/services/merge_requests/get_urls_service.rb10
-rw-r--r--app/services/merge_requests/merge_service.rb18
-rw-r--r--app/services/merge_requests/merge_to_ref_service.rb8
-rw-r--r--app/services/merge_requests/post_merge_service.rb2
-rw-r--r--app/services/merge_requests/rebase_service.rb4
-rw-r--r--app/services/merge_requests/refresh_service.rb23
-rw-r--r--app/services/merge_requests/reopen_service.rb4
-rw-r--r--app/services/merge_requests/squash_service.rb4
-rw-r--r--app/services/merge_requests/update_service.rb29
-rw-r--r--app/services/metrics_service.rb2
-rw-r--r--app/services/milestones/destroy_service.rb2
-rw-r--r--app/services/milestones/promote_service.rb6
-rw-r--r--app/services/milestones/update_service.rb4
-rw-r--r--app/services/note_summary.rb6
-rw-r--r--app/services/notes/build_service.rb2
-rw-r--r--app/services/notes/create_service.rb8
-rw-r--r--app/services/notes/quick_actions_service.rb6
-rw-r--r--app/services/notes/update_service.rb2
-rw-r--r--app/services/notification_recipient_service.rb8
-rw-r--r--app/services/notification_service.rb29
-rw-r--r--app/services/preview_markdown_service.rb4
-rw-r--r--app/services/projects/after_import_service.rb5
-rw-r--r--app/services/projects/auto_devops/disable_service.rb2
-rw-r--r--app/services/projects/autocomplete_service.rb6
-rw-r--r--app/services/projects/base_move_relations_service.rb2
-rw-r--r--app/services/projects/batch_count_service.rb4
-rw-r--r--app/services/projects/batch_forks_count_service.rb4
-rw-r--r--app/services/projects/container_repository/cleanup_tags_service.rb16
-rw-r--r--app/services/projects/count_service.rb2
-rw-r--r--app/services/projects/create_service.rb14
-rw-r--r--app/services/projects/destroy_service.rb18
-rw-r--r--app/services/projects/detect_repository_languages_service.rb4
-rw-r--r--app/services/projects/download_service.rb4
-rw-r--r--app/services/projects/fetch_statistics_increment_service.rb8
-rw-r--r--app/services/projects/fork_service.rb16
-rw-r--r--app/services/projects/forks_count_service.rb2
-rw-r--r--app/services/projects/gitlab_projects_import_service.rb4
-rw-r--r--app/services/projects/hashed_storage/migrate_repository_service.rb2
-rw-r--r--app/services/projects/import_error_filter.rb2
-rw-r--r--app/services/projects/import_export/export_service.rb4
-rw-r--r--app/services/projects/import_service.rb38
-rw-r--r--app/services/projects/lfs_pointers/lfs_download_link_list_service.rb30
-rw-r--r--app/services/projects/lfs_pointers/lfs_download_service.rb36
-rw-r--r--app/services/projects/lfs_pointers/lfs_import_service.rb12
-rw-r--r--app/services/projects/lfs_pointers/lfs_list_service.rb8
-rw-r--r--app/services/projects/move_access_service.rb2
-rw-r--r--app/services/projects/move_deploy_keys_projects_service.rb4
-rw-r--r--app/services/projects/move_project_authorizations_service.rb4
-rw-r--r--app/services/projects/move_project_group_links_service.rb2
-rw-r--r--app/services/projects/move_project_members_service.rb4
-rw-r--r--app/services/projects/open_issues_count_service.rb4
-rw-r--r--app/services/projects/open_merge_requests_count_service.rb2
-rw-r--r--app/services/projects/overwrite_project_service.rb8
-rw-r--r--app/services/projects/participants_service.rb2
-rw-r--r--app/services/projects/propagate_service_template.rb14
-rw-r--r--app/services/projects/protect_default_branch_service.rb4
-rw-r--r--app/services/projects/transfer_service.rb10
-rw-r--r--app/services/projects/unlink_fork_service.rb8
-rw-r--r--app/services/projects/update_pages_configuration_service.rb12
-rw-r--r--app/services/projects/update_pages_service.rb24
-rw-r--r--app/services/projects/update_service.rb18
-rw-r--r--app/services/prometheus/adapter_service.rb16
-rw-r--r--app/services/protected_branches/access_level_params.rb2
-rw-r--r--app/services/protected_branches/api_service.rb2
-rw-r--r--app/services/protected_branches/legacy_api_create_service.rb4
-rw-r--r--app/services/protected_branches/legacy_api_update_service.rb8
-rw-r--r--app/services/quick_actions/interpret_service.rb168
-rw-r--r--app/services/quick_actions/target_service.rb6
-rw-r--r--app/services/releases/create_service.rb8
-rw-r--r--app/services/releases/destroy_service.rb8
-rw-r--r--app/services/releases/update_service.rb10
-rw-r--r--app/services/repository_archive_clean_up_service.rb6
-rw-r--r--app/services/resource_events/change_labels_service.rb16
-rw-r--r--app/services/search/global_service.rb4
-rw-r--r--app/services/search/project_service.rb8
-rw-r--r--app/services/search/snippet_service.rb2
-rw-r--r--app/services/search_service.rb6
-rw-r--r--app/services/spam_service.rb8
-rw-r--r--app/services/submit_usage_ping_service.rb8
-rw-r--r--app/services/submodules/update_service.rb14
-rw-r--r--app/services/suggestions/apply_service.rb14
-rw-r--r--app/services/suggestions/create_service.rb8
-rw-r--r--app/services/system_hooks_service.rb48
-rw-r--r--app/services/system_note_service.rb124
-rw-r--r--app/services/tags/create_service.rb2
-rw-r--r--app/services/tags/destroy_service.rb9
-rw-r--r--app/services/task_list_toggle_service.rb8
-rw-r--r--app/services/test_hooks/base_service.rb12
-rw-r--r--app/services/test_hooks/project_service.rb20
-rw-r--r--app/services/test_hooks/system_service.rb2
-rw-r--r--app/services/todo_service.rb7
-rw-r--r--app/services/todos/destroy/base_service.rb2
-rw-r--r--app/services/todos/destroy/confidential_issue_service.rb6
-rw-r--r--app/services/todos/destroy/entity_leave_service.rb20
-rw-r--r--app/services/todos/destroy/private_features_service.rb2
-rw-r--r--app/services/update_deployment_service.rb2
-rw-r--r--app/services/user_agent_detail_service.rb2
-rw-r--r--app/services/users/activity_service.rb10
-rw-r--r--app/services/users/build_service.rb11
-rw-r--r--app/services/users/destroy_service.rb2
-rw-r--r--app/services/users/last_push_event_service.rb2
-rw-r--r--app/services/users/refresh_authorized_projects_service.rb16
-rw-r--r--app/services/users/update_service.rb2
-rw-r--r--app/services/validate_new_branch_service.rb6
-rw-r--r--app/services/verify_pages_domain_service.rb2
-rw-r--r--app/services/web_hook_service.rb32
-rw-r--r--app/services/wiki_pages/base_service.rb2
-rw-r--r--app/services/wiki_pages/create_service.rb2
-rw-r--r--app/services/wiki_pages/destroy_service.rb2
-rw-r--r--app/services/wiki_pages/update_service.rb2
-rw-r--r--app/services/wikis/create_attachment_service.rb13
-rw-r--r--app/uploaders/avatar_uploader.rb2
-rw-r--r--app/uploaders/external_diff_uploader.rb2
-rw-r--r--app/uploaders/file_mover.rb2
-rw-r--r--app/uploaders/file_uploader.rb24
-rw-r--r--app/uploaders/gitlab_uploader.rb8
-rw-r--r--app/uploaders/job_artifact_uploader.rb8
-rw-r--r--app/uploaders/legacy_artifact_uploader.rb6
-rw-r--r--app/uploaders/lfs_object_uploader.rb2
-rw-r--r--app/uploaders/namespace_file_uploader.rb6
-rw-r--r--app/uploaders/object_storage.rb52
-rw-r--r--app/uploaders/personal_file_uploader.rb6
-rw-r--r--app/uploaders/records_uploads.rb6
-rw-r--r--app/uploaders/uploader_helper.rb2
-rw-r--r--app/uploaders/workhorse.rb2
-rw-r--r--app/validators/abstract_path_validator.rb2
-rw-r--r--app/validators/branch_filter_validator.rb6
-rw-r--r--app/validators/cluster_name_validator.rb2
-rw-r--r--app/validators/color_validator.rb2
-rw-r--r--app/validators/key_restriction_validator.rb2
-rw-r--r--app/validators/line_code_validator.rb2
-rw-r--r--app/validators/namespace_name_validator.rb2
-rw-r--r--app/validators/url_validator.rb10
-rw-r--r--app/validators/variable_duplicates_validator.rb4
-rw-r--r--app/views/dashboard/issues.atom.builder2
-rw-r--r--app/views/dashboard/projects/index.atom.builder2
-rw-r--r--app/views/groups/issues.atom.builder2
-rw-r--r--app/views/issues/_issues_calendar.ics.ruby6
-rw-r--r--app/views/layouts/xml.atom.builder2
-rw-r--r--app/views/projects/commits/_commit.atom.builder2
-rw-r--r--app/views/projects/issues/index.atom.builder2
-rw-r--r--app/views/projects/tags/_tag.atom.builder4
-rw-r--r--app/views/projects/tags/index.atom.builder6
-rw-r--r--app/workers/background_migration_worker.rb2
-rw-r--r--app/workers/concerns/application_worker.rb18
-rw-r--r--app/workers/concerns/auto_devops_queue.rb2
-rw-r--r--app/workers/concerns/gitlab/github_import/notify_upon_death.rb4
-rw-r--r--app/workers/concerns/gitlab/github_import/stage_methods.rb2
-rw-r--r--app/workers/concerns/project_import_options.rb14
-rw-r--r--app/workers/concerns/project_start_import.rb2
-rw-r--r--app/workers/concerns/waitable_worker.rb8
-rw-r--r--app/workers/create_gpg_signature_worker.rb8
-rw-r--r--app/workers/delete_stored_files_worker.rb4
-rw-r--r--app/workers/emails_on_push_worker.rb40
-rw-r--r--app/workers/expire_build_artifacts_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/advance_stage_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/import_diff_note_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/import_issue_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/import_lfs_object_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/import_note_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/import_pull_request_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/stage/finish_import_worker.rb6
-rw-r--r--app/workers/gitlab/github_import/stage/import_base_data_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb6
-rw-r--r--app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/stage/import_notes_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb2
-rw-r--r--app/workers/gitlab/github_import/stage/import_repository_worker.rb2
-rw-r--r--app/workers/gitlab_usage_ping_worker.rb2
-rw-r--r--app/workers/import_issues_csv_worker.rb2
-rw-r--r--app/workers/irker_worker.rb46
-rw-r--r--app/workers/mail_scheduler/notification_service_worker.rb6
-rw-r--r--app/workers/namespaceless_project_destroy_worker.rb2
-rw-r--r--app/workers/object_storage/migrate_uploads_worker.rb8
-rw-r--r--app/workers/pipeline_schedule_worker.rb25
-rw-r--r--app/workers/post_receive.rb10
-rw-r--r--app/workers/process_commit_worker.rb2
-rw-r--r--app/workers/project_cache_worker.rb2
-rw-r--r--app/workers/project_export_worker.rb2
-rw-r--r--app/workers/project_migrate_hashed_storage_worker.rb3
-rw-r--r--app/workers/prune_old_events_worker.rb12
-rw-r--r--app/workers/prune_web_hook_logs_worker.rb4
-rw-r--r--app/workers/reactive_caching_worker.rb4
-rw-r--r--app/workers/remove_expired_members_worker.rb8
-rw-r--r--app/workers/repository_check/batch_worker.rb4
-rw-r--r--app/workers/repository_cleanup_worker.rb2
-rw-r--r--app/workers/repository_fork_worker.rb2
-rw-r--r--app/workers/repository_update_remote_mirror_worker.rb2
-rw-r--r--app/workers/run_pipeline_schedule_worker.rb4
-rw-r--r--app/workers/stuck_ci_jobs_worker.rb10
-rw-r--r--app/workers/stuck_import_jobs_worker.rb8
-rw-r--r--app/workers/stuck_merge_jobs_worker.rb4
-rw-r--r--app/workers/trending_projects_worker.rb2
-rw-r--r--app/workers/update_merge_requests_worker.rb8
-rw-r--r--config.ru16
-rw-r--r--config/application.rb67
-rw-r--r--config/boot.rb6
-rw-r--r--config/environment.rb2
-rw-r--r--config/environments/development.rb6
-rw-r--r--config/environments/production.rb4
-rw-r--r--config/environments/test.rb8
-rw-r--r--config/initializers/01_secret_token.rb22
-rw-r--r--config/initializers/0_inflections.rb4
-rw-r--r--config/initializers/1_settings.rb576
-rw-r--r--config/initializers/2_gitlab.rb2
-rw-r--r--config/initializers/6_validations.rb4
-rw-r--r--config/initializers/7_prometheus_metrics.rb12
-rw-r--r--config/initializers/8_devise.rb2
-rw-r--r--config/initializers/8_gitaly.rb2
-rw-r--r--config/initializers/9_fast_gettext.rb10
-rw-r--r--config/initializers/active_record_data_types.rb16
-rw-r--r--config/initializers/active_record_locking.rb6
-rw-r--r--config/initializers/active_record_migration.rb2
-rw-r--r--config/initializers/active_record_mysql_timestamp.rb8
-rw-r--r--config/initializers/active_record_table_definition.rb2
-rw-r--r--config/initializers/active_record_verbose_query_logs.rb8
-rw-r--r--config/initializers/ar_mysql_jsonb_support.rb8
-rw-r--r--config/initializers/ar_native_database_types.rb4
-rw-r--r--config/initializers/ar_speed_up_migration_checking.rb4
-rw-r--r--config/initializers/attr_encrypted_no_db_connection.rb6
-rw-r--r--config/initializers/bullet.rb2
-rw-r--r--config/initializers/connection_fix.rb4
-rw-r--r--config/initializers/console_message.rb2
-rw-r--r--config/initializers/date_time_formats.rb8
-rw-r--r--config/initializers/default_url_options.rb8
-rw-r--r--config/initializers/deprecations.rb6
-rw-r--r--config/initializers/direct_upload_support.rb4
-rw-r--r--config/initializers/doorkeeper.rb9
-rw-r--r--config/initializers/doorkeeper_openid_connect.rb4
-rw-r--r--config/initializers/fix_local_cache_middleware.rb4
-rw-r--r--config/initializers/forbid_sidekiq_in_transactions.rb11
-rw-r--r--config/initializers/gettext_rails_i18n_patch.rb10
-rw-r--r--config/initializers/grpc.rb8
-rw-r--r--config/initializers/hamlit.rb4
-rw-r--r--config/initializers/health_check.rb4
-rw-r--r--config/initializers/lograge.rb8
-rw-r--r--config/initializers/macos.rb6
-rw-r--r--config/initializers/mime_types.rb4
-rw-r--r--config/initializers/mysql_ignore_postgresql_options.rb6
-rw-r--r--config/initializers/omniauth.rb6
-rw-r--r--config/initializers/peek.rb6
-rw-r--r--config/initializers/postgresql_cte.rb4
-rw-r--r--config/initializers/query_limiting.rb6
-rw-r--r--config/initializers/rack_attack_git_basic_auth.rb4
-rw-r--r--config/initializers/rack_attack_global.rb14
-rw-r--r--config/initializers/rack_attack_logging.rb6
-rw-r--r--config/initializers/rack_lineprof.rb10
-rw-r--r--config/initializers/rbtrace.rb4
-rw-r--r--config/initializers/rspec_profiling.rb16
-rw-r--r--config/initializers/sentry.rb4
-rw-r--r--config/initializers/session_store.rb18
-rw-r--r--config/initializers/sidekiq.rb18
-rw-r--r--config/initializers/static_files.rb2
-rw-r--r--config/initializers/tracing.rb2
-rw-r--r--config/initializers/trusted_proxies.rb10
-rw-r--r--config/initializers/warden.rb4
-rw-r--r--config/initializers/zz_metrics.rb34
-rw-r--r--config/object_store_settings.rb12
-rw-r--r--config/puma.example.development.rb16
-rw-r--r--config/routes.rb68
-rw-r--r--config/routes/admin.rb38
-rw-r--r--config/routes/api.rb6
-rw-r--r--config/routes/ci.rb2
-rw-r--r--config/routes/dashboard.rb2
-rw-r--r--config/routes/development.rb12
-rw-r--r--config/routes/explore.rb6
-rw-r--r--config/routes/git_http.rb40
-rw-r--r--config/routes/google_api.rb2
-rw-r--r--config/routes/group.rb40
-rw-r--r--config/routes/help.rb10
-rw-r--r--config/routes/import.rb2
-rw-r--r--config/routes/instance_statistics.rb2
-rw-r--r--config/routes/legacy_builds.rb14
-rw-r--r--config/routes/profile.rb4
-rw-r--r--config/routes/project.rb140
-rw-r--r--config/routes/repository.rb62
-rw-r--r--config/routes/sidekiq.rb4
-rw-r--r--config/routes/snippets.rb6
-rw-r--r--config/routes/uploads.rb38
-rw-r--r--config/routes/user.rb44
-rw-r--r--config/routes/wiki.rb14
-rw-r--r--config/settings.rb30
-rw-r--r--config/spring.rb4
-rw-r--r--danger/changelog/Dangerfile22
-rw-r--r--danger/commit_messages/Dangerfile58
-rw-r--r--danger/database/Dangerfile68
-rw-r--r--danger/documentation/Dangerfile38
-rw-r--r--danger/duplicate_yarn_dependencies/Dangerfile10
-rw-r--r--danger/eslint/Dangerfile6
-rw-r--r--danger/frozen_string/Dangerfile4
-rw-r--r--danger/gemfile/Dangerfile22
-rw-r--r--danger/metadata/Dangerfile10
-rw-r--r--danger/plugins/helper.rb6
-rw-r--r--danger/prettier/Dangerfile10
-rw-r--r--danger/roulette/Dangerfile36
-rw-r--r--danger/specs/Dangerfile10
-rw-r--r--db/fixtures/development/01_admin.rb12
-rw-r--r--db/fixtures/development/03_settings.rb2
-rw-r--r--db/fixtures/development/04_project.rb22
-rw-r--r--db/fixtures/development/05_users.rb46
-rw-r--r--db/fixtures/development/06_teams.rb10
-rw-r--r--db/fixtures/development/07_milestones.rb7
-rw-r--r--db/fixtures/development/08_settings.rb2
-rw-r--r--db/fixtures/development/09_issues.rb8
-rw-r--r--db/fixtures/development/10_merge_requests.rb24
-rw-r--r--db/fixtures/development/11_keys.rb5
-rw-r--r--db/fixtures/development/12_snippets.rb51
-rw-r--r--db/fixtures/development/13_comments.rb10
-rw-r--r--db/fixtures/development/14_pipelines.rb138
-rw-r--r--db/fixtures/development/15_award_emoji.rb6
-rw-r--r--db/fixtures/development/16_protected_branches.rb6
-rw-r--r--db/fixtures/development/17_cycle_analytics.rb56
-rw-r--r--db/fixtures/development/18_abuse_reports.rb6
-rw-r--r--db/fixtures/development/19_environments.rb12
-rw-r--r--db/fixtures/development/20_nested_groups.rb34
-rw-r--r--db/fixtures/development/21_conversational_development_index_metrics.rb4
-rw-r--r--db/fixtures/development/22_labeled_issues_seed.rb14
-rw-r--r--db/fixtures/development/23_spam_logs.rb7
-rw-r--r--db/fixtures/development/24_forks.rb6
-rw-r--r--db/fixtures/development/99_common_metrics.rb2
-rw-r--r--db/fixtures/production/002_admin.rb12
-rw-r--r--db/fixtures/production/010_settings.rb12
-rw-r--r--db/fixtures/production/999_common_metrics.rb2
-rw-r--r--db/importers/common_metrics_importer.rb44
-rw-r--r--db/migrate/20140407135544_fix_namespaces.rb6
-rw-r--r--db/migrate/20140415124820_limits_to_mysql.rb2
-rw-r--r--db/migrate/20140729145339_migrate_project_tags.rb4
-rw-r--r--db/migrate/20150411000035_fix_identities.rb20
-rw-r--r--db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb2
-rw-r--r--db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb2
-rw-r--r--db/migrate/20150620233230_add_default_otp_required_for_login_value.rb2
-rw-r--r--db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb2
-rw-r--r--db/migrate/20151020173516_ci_limits_to_mysql.rb2
-rw-r--r--db/migrate/20151023144219_remove_satellites.rb6
-rw-r--r--db/migrate/20151209144329_migrate_ci_web_hooks.rb6
-rw-r--r--db/migrate/20151209145909_migrate_ci_emails.rb16
-rw-r--r--db/migrate/20151210125232_migrate_ci_slack_service.rb12
-rw-r--r--db/migrate/20151210125927_migrate_ci_hip_chat_service.rb10
-rw-r--r--db/migrate/20151210125930_migrate_ci_to_project.rb22
-rw-r--r--db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb4
-rw-r--r--db/migrate/20160328115649_migrate_new_notification_setting.rb2
-rw-r--r--db/migrate/20160415062917_create_personal_access_tokens.rb2
-rw-r--r--db/migrate/20160416182152_convert_award_note_to_emoji_award.rb8
-rw-r--r--db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb6
-rw-r--r--db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb2
-rw-r--r--db/migrate/20160509091049_add_locked_to_ci_runner.rb2
-rw-r--r--db/migrate/20160603180330_remove_duplicated_notification_settings.rb10
-rw-r--r--db/migrate/20160608195742_add_repository_storage_to_projects.rb2
-rw-r--r--db/migrate/20160608211215_add_user_default_external_to_application_settings.rb2
-rw-r--r--db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb2
-rw-r--r--db/migrate/20160610201627_migrate_users_notification_level.rb4
-rw-r--r--db/migrate/20160614182521_add_repository_storage_to_application_settings.rb2
-rw-r--r--db/migrate/20160616102642_remove_duplicated_keys.rb4
-rw-r--r--db/migrate/20160705054938_add_protected_branches_push_access.rb2
-rw-r--r--db/migrate/20160705054952_add_protected_branches_merge_access.rb2
-rw-r--r--db/migrate/20160712171823_remove_award_emojis_with_no_user.rb2
-rw-r--r--db/migrate/20160725104020_merge_request_diff_remove_uniq.rb2
-rw-r--r--db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb2
-rw-r--r--db/migrate/20160728103734_add_pipeline_events_to_services.rb2
-rw-r--r--db/migrate/20160729173930_remove_project_id_from_spam_logs.rb2
-rw-r--r--db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb8
-rw-r--r--db/migrate/20160810142633_remove_redundant_indexes.rb96
-rw-r--r--db/migrate/20160823081327_change_merge_error_to_text.rb2
-rw-r--r--db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb2
-rw-r--r--db/migrate/20160824124900_add_table_issue_metrics.rb10
-rw-r--r--db/migrate/20160825052008_add_table_merge_request_metrics.rb12
-rw-r--r--db/migrate/20160827011312_ensure_lock_version_has_no_default.rb4
-rw-r--r--db/migrate/20160829114652_add_markdown_cache_columns.rb4
-rw-r--r--db/migrate/20160831214543_migrate_project_features.rb4
-rw-r--r--db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb14
-rw-r--r--db/migrate/20160913162434_remove_projects_pushes_since_gc.rb2
-rw-r--r--db/migrate/20160913212128_change_artifacts_size_column.rb2
-rw-r--r--db/migrate/20160915042921_create_merge_requests_closing_issues.rb6
-rw-r--r--db/migrate/20160919144305_add_type_to_labels.rb4
-rw-r--r--db/migrate/20161007133303_precalculate_trending_projects.rb2
-rw-r--r--db/migrate/20161010142410_create_project_authorizations.rb6
-rw-r--r--db/migrate/20161014173530_create_label_priorities.rb6
-rw-r--r--db/migrate/20161017125927_add_unique_index_to_labels.rb8
-rw-r--r--db/migrate/20161018024215_migrate_labels_priority.rb2
-rw-r--r--db/migrate/20161018024550_remove_priority_from_labels.rb2
-rw-r--r--db/migrate/20161018124658_make_project_owners_masters.rb2
-rw-r--r--db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb86
-rw-r--r--db/migrate/20161019213545_generate_project_feature_for_projects.rb2
-rw-r--r--db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb2
-rw-r--r--db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb12
-rw-r--r--db/migrate/20161025231710_migrate_jira_to_gem.rb44
-rw-r--r--db/migrate/20161031174110_migrate_subscriptions_project_id.rb2
-rw-r--r--db/migrate/20161031181638_add_unique_index_to_subscriptions.rb10
-rw-r--r--db/migrate/20161103171205_rename_repository_storage_column.rb2
-rw-r--r--db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb24
-rw-r--r--db/migrate/20161128142110_remove_unnecessary_indexes.rb4
-rw-r--r--db/migrate/20161130095245_fill_routes_table.rb2
-rw-r--r--db/migrate/20161130101252_fill_projects_routes_table.rb2
-rw-r--r--db/migrate/20161201155511_create_project_statistics.rb4
-rw-r--r--db/migrate/20161201160452_migrate_project_statistics.rb2
-rw-r--r--db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb2
-rw-r--r--db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb2
-rw-r--r--db/migrate/20161207231620_fixup_environment_name_uniqueness.rb2
-rw-r--r--db/migrate/20161207231621_create_environment_name_unique_index.rb2
-rw-r--r--db/migrate/20161207231626_add_environment_slug.rb16
-rw-r--r--db/migrate/20161209153400_add_unique_index_for_environment_slug.rb2
-rw-r--r--db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb8
-rw-r--r--db/migrate/20161212142807_add_lower_path_index_to_routes.rb2
-rw-r--r--db/migrate/20161220141214_remove_dot_git_from_group_names.rb22
-rw-r--r--db/migrate/20161226122833_remove_dot_git_from_usernames.rb20
-rw-r--r--db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb16
-rw-r--r--db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb2
-rw-r--r--db/migrate/20170120131253_create_chat_teams.rb2
-rw-r--r--db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb14
-rw-r--r--db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb2
-rw-r--r--db/migrate/20170217132157_rename_merge_when_build_succeeds.rb2
-rw-r--r--db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb2
-rw-r--r--db/migrate/20170222111732_create_gpg_keys.rb2
-rw-r--r--db/migrate/20170222143500_remove_old_project_id_columns.rb2
-rw-r--r--db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb2
-rw-r--r--db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb4
-rw-r--r--db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb4
-rw-r--r--db/migrate/20170309173138_create_protected_tags.rb2
-rw-r--r--db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb2
-rw-r--r--db/migrate/20170316163845_move_uploads_to_system_dir.rb2
-rw-r--r--db/migrate/20170317203554_index_routes_path_for_like.rb2
-rw-r--r--db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb2
-rw-r--r--db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb2
-rw-r--r--db/migrate/20170503140201_reschedule_project_authorizations.rb12
-rw-r--r--db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb22
-rw-r--r--db/migrate/20170503185032_index_redirect_routes_path_for_like.rb2
-rw-r--r--db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb2
-rw-r--r--db/migrate/20170516153305_migrate_assignee_to_separate_table.rb2
-rw-r--r--db/migrate/20170516183131_add_indices_to_issue_assignees.rb4
-rw-r--r--db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb2
-rw-r--r--db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb27
-rw-r--r--db/migrate/20170606154216_add_notification_setting_columns.rb2
-rw-r--r--db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb4
-rw-r--r--db/migrate/20170608171156_create_merge_request_diff_files.rb4
-rw-r--r--db/migrate/20170613154149_create_gpg_signatures.rb4
-rw-r--r--db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb2
-rw-r--r--db/migrate/20170616133147_create_merge_request_diff_commits.rb4
-rw-r--r--db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb6
-rw-r--r--db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb4
-rw-r--r--db/migrate/20170622135451_rename_duplicated_variable_key.rb4
-rw-r--r--db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb2
-rw-r--r--db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb2
-rw-r--r--db/migrate/20170710083355_clean_stage_id_reference_migration.rb2
-rw-r--r--db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb4
-rw-r--r--db/migrate/20170717074009_move_system_upload_folder.rb12
-rw-r--r--db/migrate/20170720122741_create_user_custom_attributes.rb2
-rw-r--r--db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb2
-rw-r--r--db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb2
-rw-r--r--db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb2
-rw-r--r--db/migrate/20170816133938_add_access_level_to_ci_runners.rb2
-rw-r--r--db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb6
-rw-r--r--db/migrate/20170820120108_create_user_synced_attributes_metadata.rb2
-rw-r--r--db/migrate/20170825104051_migrate_issues_to_ghost_user.rb6
-rw-r--r--db/migrate/20170828093725_create_project_auto_dev_ops.rb2
-rw-r--r--db/migrate/20170828135939_migrate_user_external_mail_data.rb8
-rw-r--r--db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb2
-rw-r--r--db/migrate/20170830131015_swap_event_migration_tables.rb4
-rw-r--r--db/migrate/20170912113435_clean_stages_statuses_migration.rb8
-rw-r--r--db/migrate/20170918072948_create_job_artifacts.rb2
-rw-r--r--db/migrate/20170918111708_create_project_custom_attributes.rb2
-rw-r--r--db/migrate/20170919211300_remove_temporary_ci_builds_index.rb8
-rw-r--r--db/migrate/20170924094327_create_gcp_clusters.rb6
-rw-r--r--db/migrate/20170927161718_create_gpg_key_subkeys.rb4
-rw-r--r--db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb2
-rw-r--r--db/migrate/20170928124105_create_fork_networks.rb8
-rw-r--r--db/migrate/20170928133643_create_fork_network_members.rb8
-rw-r--r--db/migrate/20170929131201_populate_fork_networks.rb2
-rw-r--r--db/migrate/20171006090001_create_ci_build_trace_sections.rb2
-rw-r--r--db/migrate/20171006090100_create_ci_build_trace_section_names.rb2
-rw-r--r--db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb24
-rw-r--r--db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb2
-rw-r--r--db/migrate/20171013094327_create_new_clusters_architectures.rb10
-rw-r--r--db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb12
-rw-r--r--db/migrate/20171019141859_fix_dev_timezone_schema.rb2
-rw-r--r--db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb4
-rw-r--r--db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb2
-rw-r--r--db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb18
-rw-r--r--db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb2
-rw-r--r--db/migrate/20171106132212_issues_confidential_not_null.rb4
-rw-r--r--db/migrate/20171106135924_issues_milestone_id_foreign_key.rb6
-rw-r--r--db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb8
-rw-r--r--db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb12
-rw-r--r--db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb6
-rw-r--r--db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb6
-rw-r--r--db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb6
-rw-r--r--db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb8
-rw-r--r--db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb8
-rw-r--r--db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb6
-rw-r--r--db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb6
-rw-r--r--db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb4
-rw-r--r--db/migrate/20171116135628_add_environment_scope_to_clusters.rb2
-rw-r--r--db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb8
-rw-r--r--db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb2
-rw-r--r--db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb8
-rw-r--r--db/migrate/20171124125748_populate_missing_merge_request_statuses.rb12
-rw-r--r--db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb8
-rw-r--r--db/migrate/20171207185153_add_merge_request_state_index.rb6
-rw-r--r--db/migrate/20171212203433_create_clusters_applications_prometheus.rb2
-rw-r--r--db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb6
-rw-r--r--db/migrate/20171216111734_clean_up_for_members.rb2
-rw-r--r--db/migrate/20171216112339_add_foreign_key_for_members.rb4
-rw-r--r--db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb2
-rw-r--r--db/migrate/20180101160629_create_prometheus_metrics.rb2
-rw-r--r--db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb6
-rw-r--r--db/migrate/20180116193854_create_lfs_file_locks.rb4
-rw-r--r--db/migrate/20180125214301_create_user_callouts.rb2
-rw-r--r--db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb10
-rw-r--r--db/migrate/20180201110056_add_foreign_keys_to_todos.rb8
-rw-r--r--db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb14
-rw-r--r--db/migrate/20180206200543_reset_events_primary_key_sequence.rb4
-rw-r--r--db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb7
-rw-r--r--db/migrate/20180209115333_create_chatops_tables.rb2
-rw-r--r--db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb4
-rw-r--r--db/migrate/20180214093516_create_badges.rb2
-rw-r--r--db/migrate/20180214155405_create_clusters_applications_runners.rb2
-rw-r--r--db/migrate/20180215181245_users_name_lower_index.rb2
-rw-r--r--db/migrate/20180223120443_create_user_interacted_projects_table.rb2
-rw-r--r--db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb6
-rw-r--r--db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb8
-rw-r--r--db/migrate/20180305095250_create_internal_ids_table.rb2
-rw-r--r--db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb2
-rw-r--r--db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb8
-rw-r--r--db/migrate/20180319190020_create_deploy_tokens.rb2
-rw-r--r--db/migrate/20180403035759_create_project_ci_cd_settings.rb4
-rw-r--r--db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb2
-rw-r--r--db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb6
-rw-r--r--db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb8
-rw-r--r--db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb4
-rw-r--r--db/migrate/20180420010616_cleanup_build_stage_migration.rb12
-rw-r--r--db/migrate/20180425075446_create_term_agreements.rb8
-rw-r--r--db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb6
-rw-r--r--db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb2
-rw-r--r--db/migrate/20180426102016_add_accepted_term_to_users.rb2
-rw-r--r--db/migrate/20180502122856_create_project_mirror_data.rb2
-rw-r--r--db/migrate/20180503131624_create_remote_mirrors.rb2
-rw-r--r--db/migrate/20180504195842_project_name_lower_index.rb2
-rw-r--r--db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb2
-rw-r--r--db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb18
-rw-r--r--db/migrate/20180511131058_create_clusters_applications_jupyter.rb4
-rw-r--r--db/migrate/20180515121227_create_notes_diff_files.rb2
-rw-r--r--db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb16
-rw-r--r--db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb2
-rw-r--r--db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb2
-rw-r--r--db/migrate/20180529093006_ensure_remote_mirror_columns.rb8
-rw-r--r--db/migrate/20180531185349_add_repository_languages.rb2
-rw-r--r--db/migrate/20180608091413_add_group_to_todos.rb2
-rw-r--r--db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb1
-rw-r--r--db/migrate/20180625113853_create_import_export_uploads.rb2
-rw-r--r--db/migrate/20180629153018_create_site_statistics.rb2
-rw-r--r--db/migrate/20180702124358_remove_orphaned_routes.rb12
-rw-r--r--db/migrate/20180702134423_generate_missing_routes.rb34
-rw-r--r--db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb6
-rw-r--r--db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb6
-rw-r--r--db/migrate/20180711103851_drop_duplicate_protected_tags.rb6
-rw-r--r--db/migrate/20180713092803_create_user_statuses.rb8
-rw-r--r--db/migrate/20180717125853_remove_restricted_todos.rb8
-rw-r--r--db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb6
-rw-r--r--db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb1
-rw-r--r--db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb6
-rw-r--r--db/migrate/20180726172057_create_resource_label_events.rb8
-rw-r--r--db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb2
-rw-r--r--db/migrate/20180815175440_add_index_on_list_type.rb1
-rw-r--r--db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb2
-rw-r--r--db/migrate/20180831164910_import_common_metrics.rb2
-rw-r--r--db/migrate/20180912111628_add_knative_application.rb2
-rw-r--r--db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb8
-rw-r--r--db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb2
-rw-r--r--db/migrate/20180925200829_create_user_preferences.rb20
-rw-r--r--db/migrate/20181002172433_remove_restricted_todos_with_cte.rb9
-rw-r--r--db/migrate/20181006004100_import_common_metrics_nginx_vts.rb2
-rw-r--r--db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb8
-rw-r--r--db/migrate/20181010235606_create_board_project_recent_visits.rb8
-rw-r--r--db/migrate/20181014203236_create_cluster_groups.rb2
-rw-r--r--db/migrate/20181016152238_create_board_group_recent_visits.rb6
-rw-r--r--db/migrate/20181019032400_add_shards_table.rb2
-rw-r--r--db/migrate/20181019032408_add_repositories_table.rb6
-rw-r--r--db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb2
-rw-r--r--db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb2
-rw-r--r--db/migrate/20181031190559_drop_gcp_clusters_table.rb6
-rw-r--r--db/migrate/20181101144347_add_index_for_stuck_mr_query.rb1
-rw-r--r--db/migrate/20181101191341_create_clusters_applications_cert_manager.rb2
-rw-r--r--db/migrate/20181108091549_cleanup_environments_external_url.rb2
-rw-r--r--db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb12
-rw-r--r--db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb4
-rw-r--r--db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb6
-rw-r--r--db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb6
-rw-r--r--db/migrate/20181122160027_create_project_repositories.rb6
-rw-r--r--db/migrate/20181123144235_create_suggestions.rb4
-rw-r--r--db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb4
-rw-r--r--db/migrate/20181126153547_remove_notes_index_on_updated_at.rb4
-rw-r--r--db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb2
-rw-r--r--db/migrate/20181205171941_create_project_daily_statistics.rb2
-rw-r--r--db/migrate/20181228175414_create_releases_link_table.rb2
-rw-r--r--db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb6
-rw-r--r--db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb2
-rw-r--r--db/migrate/20190206193120_add_index_to_tags.rb4
-rw-r--r--db/migrate/limits_to_mysql.rb2
-rw-r--r--db/optional_migrations/composite_primary_keys.rb14
-rw-r--r--db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb2
-rw-r--r--db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb4
-rw-r--r--db/post_migrate/20161221153951_rename_reserved_project_names.rb12
-rw-r--r--db/post_migrate/20170104150317_requeue_pending_delete_projects.rb4
-rw-r--r--db/post_migrate/20170106142508_fill_authorized_projects.rb6
-rw-r--r--db/post_migrate/20170206040400_remove_inactive_default_email_services.rb8
-rw-r--r--db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb4
-rw-r--r--db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb8
-rw-r--r--db/post_migrate/20170313133418_rename_more_reserved_project_names.rb6
-rw-r--r--db/post_migrate/20170317162059_update_upload_paths_to_system.rb2
-rw-r--r--db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb2
-rw-r--r--db/post_migrate/20170406111121_clean_upload_symlinks.rb2
-rw-r--r--db/post_migrate/20170408033905_remove_old_cache_directories.rb2
-rw-r--r--db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb2
-rw-r--r--db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb2
-rw-r--r--db/post_migrate/20170503004427_update_retried_for_ci_build.rb4
-rw-r--r--db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb2
-rw-r--r--db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb2
-rw-r--r--db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb20
-rw-r--r--db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb10
-rw-r--r--db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb4
-rw-r--r--db/post_migrate/20170523083112_migrate_old_artifacts.rb22
-rw-r--r--db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb140
-rw-r--r--db/post_migrate/20170606202615_move_appearance_to_system_dir.rb4
-rw-r--r--db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb6
-rw-r--r--db/post_migrate/20170612071012_move_personal_snippets_files.rb22
-rw-r--r--db/post_migrate/20170613111224_clean_appearance_symlinks.rb2
-rw-r--r--db/post_migrate/20170627101016_schedule_event_migrations.rb6
-rw-r--r--db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb6
-rw-r--r--db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb8
-rw-r--r--db/post_migrate/20170711145558_migrate_stages_statuses.rb6
-rw-r--r--db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb6
-rw-r--r--db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb12
-rw-r--r--db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb8
-rw-r--r--db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb4
-rw-r--r--db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb12
-rw-r--r--db/post_migrate/20170815060945_remove_duplicate_mr_events.rb6
-rw-r--r--db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb8
-rw-r--r--db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb12
-rw-r--r--db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb8
-rw-r--r--db/post_migrate/20170830150306_drop_events_for_migration_table.rb2
-rw-r--r--db/post_migrate/20170913180600_fix_projects_without_project_feature.rb2
-rw-r--r--db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb4
-rw-r--r--db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb6
-rw-r--r--db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb4
-rw-r--r--db/post_migrate/20170927112319_update_notes_type_for_import.rb4
-rw-r--r--db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb8
-rw-r--r--db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb45
-rw-r--r--db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb6
-rw-r--r--db/post_migrate/20171103140253_track_untracked_uploads.rb2
-rw-r--r--db/post_migrate/20171114104051_remove_empty_fork_networks.rb12
-rw-r--r--db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb16
-rw-r--r--db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb16
-rw-r--r--db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb77
-rw-r--r--db/post_migrate/20171124150326_reschedule_fork_network_creation.rb2
-rw-r--r--db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb8
-rw-r--r--db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb6
-rw-r--r--db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb2
-rw-r--r--db/post_migrate/20171207150343_remove_soft_removed_objects.rb34
-rw-r--r--db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb4
-rw-r--r--db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb6
-rw-r--r--db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb4
-rw-r--r--db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb6
-rw-r--r--db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb6
-rw-r--r--db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb6
-rw-r--r--db/post_migrate/20180202111106_remove_project_labels_group_id.rb2
-rw-r--r--db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb2
-rw-r--r--db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb6
-rw-r--r--db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb6
-rw-r--r--db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb4
-rw-r--r--db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb4
-rw-r--r--db/post_migrate/20180223124427_build_user_interacted_projects_table.rb18
-rw-r--r--db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb2
-rw-r--r--db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb4
-rw-r--r--db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb2
-rw-r--r--db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb8
-rw-r--r--db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb12
-rw-r--r--db/post_migrate/20180420080616_schedule_stages_index_migration.rb10
-rw-r--r--db/post_migrate/20180424151928_fill_file_store.rb12
-rw-r--r--db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb8
-rw-r--r--db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb22
-rw-r--r--db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb2
-rw-r--r--db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb10
-rw-r--r--db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb11
-rw-r--r--db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb2
-rw-r--r--db/post_migrate/20180604123514_cleanup_stages_position_migration.rb8
-rw-r--r--db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb4
-rw-r--r--db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb8
-rw-r--r--db/post_migrate/20180704145007_update_project_indexes.rb5
-rw-r--r--db/post_migrate/20180706223200_populate_site_statistics.rb4
-rw-r--r--db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb17
-rw-r--r--db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb4
-rw-r--r--db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb10
-rw-r--r--db/post_migrate/20180816193530_rename_login_root_namespaces.rb3
-rw-r--r--db/post_migrate/20180826111825_recalculate_site_statistics.rb4
-rw-r--r--db/post_migrate/20180906051323_remove_orphaned_label_links.rb4
-rw-r--r--db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb4
-rw-r--r--db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb10
-rw-r--r--db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb4
-rw-r--r--db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb1
-rw-r--r--db/post_migrate/20180916014356_populate_external_pipeline_source.rb10
-rw-r--r--db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb1
-rw-r--r--db/post_migrate/20181008145341_steal_encrypt_columns.rb2
-rw-r--r--db/post_migrate/20181008200441_remove_circuit_breaker.rb2
-rw-r--r--db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb6
-rw-r--r--db/post_migrate/20181014121030_enqueue_redact_links.rb20
-rw-r--r--db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb2
-rw-r--r--db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb6
-rw-r--r--db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb8
-rw-r--r--db/post_migrate/20181101091005_steal_digest_column.rb2
-rw-r--r--db/post_migrate/20181105201455_steal_fill_store_upload.rb6
-rw-r--r--db/post_migrate/20181107054254_remove_restricted_todos_again.rb8
-rw-r--r--db/post_migrate/20181121111200_schedule_runners_token_encryption.rb6
-rw-r--r--db/post_migrate/20181123042307_drop_site_statistics.rb2
-rw-r--r--db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb4
-rw-r--r--db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb8
-rw-r--r--db/post_migrate/20181219130552_update_project_import_visibility_level.rb12
-rw-r--r--db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb4
-rw-r--r--db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb9
-rw-r--r--db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb4
-rw-r--r--db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb4
-rw-r--r--db/post_migrate/20190131122559_fix_null_type_labels.rb2
-rw-r--r--db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb28
-rw-r--r--lib/after_commit_queue.rb2
-rw-r--r--lib/api/access_requests.rb20
-rw-r--r--lib/api/api.rb56
-rw-r--r--lib/api/api_guard.rb21
-rw-r--r--lib/api/applications.rb16
-rw-r--r--lib/api/avatar.rb8
-rw-r--r--lib/api/award_emoji.rb34
-rw-r--r--lib/api/badges.rb36
-rw-r--r--lib/api/boards.rb56
-rw-r--r--lib/api/boards_responses.rb10
-rw-r--r--lib/api/branches.rb74
-rw-r--r--lib/api/broadcast_messages.rb54
-rw-r--r--lib/api/circuit_breakers.rb24
-rw-r--r--lib/api/commit_statuses.rb75
-rw-r--r--lib/api/commits.rb186
-rw-r--r--lib/api/container_registry.rb65
-rw-r--r--lib/api/custom_attributes_endpoints.rb12
-rw-r--r--lib/api/deploy_keys.rb44
-rw-r--r--lib/api/deployments.rb20
-rw-r--r--lib/api/discussions.rb94
-rw-r--r--lib/api/entities.rb108
-rw-r--r--lib/api/environments.rb48
-rw-r--r--lib/api/events.rb30
-rw-r--r--lib/api/features.rb22
-rw-r--r--lib/api/files.rb62
-rw-r--r--lib/api/group_boards.rb56
-rw-r--r--lib/api/group_labels.rb34
-rw-r--r--lib/api/group_milestones.rb28
-rw-r--r--lib/api/group_variables.rb44
-rw-r--r--lib/api/groups.rb103
-rw-r--r--lib/api/helpers.rb111
-rw-r--r--lib/api/helpers/badges_helpers.rb10
-rw-r--r--lib/api/helpers/custom_attributes.rb4
-rw-r--r--lib/api/helpers/custom_validators.rb2
-rw-r--r--lib/api/helpers/headers_helpers.rb2
-rw-r--r--lib/api/helpers/internal_helpers.rb8
-rw-r--r--lib/api/helpers/label_helpers.rb8
-rw-r--r--lib/api/helpers/members_helpers.rb6
-rw-r--r--lib/api/helpers/notes_helpers.rb2
-rw-r--r--lib/api/helpers/pagination.rb62
-rw-r--r--lib/api/helpers/projects_helpers.rb40
-rw-r--r--lib/api/helpers/related_resources_helpers.rb2
-rw-r--r--lib/api/helpers/runner.rb16
-rw-r--r--lib/api/helpers/version.rb4
-rw-r--r--lib/api/import_github.rb18
-rw-r--r--lib/api/internal.rb38
-rw-r--r--lib/api/issues.rb174
-rw-r--r--lib/api/job_artifacts.rb56
-rw-r--r--lib/api/jobs.rb66
-rw-r--r--lib/api/keys.rb2
-rw-r--r--lib/api/labels.rb30
-rw-r--r--lib/api/lint.rb10
-rw-r--r--lib/api/markdown.rb4
-rw-r--r--lib/api/members.rb36
-rw-r--r--lib/api/merge_request_diffs.rb16
-rw-r--r--lib/api/merge_requests.rb192
-rw-r--r--lib/api/milestone_responses.rb20
-rw-r--r--lib/api/namespaces.rb8
-rw-r--r--lib/api/notes.rb34
-rw-r--r--lib/api/notification_settings.rb20
-rw-r--r--lib/api/pages_domains.rb32
-rw-r--r--lib/api/pagination_params.rb4
-rw-r--r--lib/api/pipeline_schedules.rb90
-rw-r--r--lib/api/pipelines.rb84
-rw-r--r--lib/api/project_clusters.rb70
-rw-r--r--lib/api/project_export.rb36
-rw-r--r--lib/api/project_hooks.rb16
-rw-r--r--lib/api/project_import.rb48
-rw-r--r--lib/api/project_milestones.rb50
-rw-r--r--lib/api/project_snapshots.rb8
-rw-r--r--lib/api/project_snippets.rb60
-rw-r--r--lib/api/project_statistics.rb4
-rw-r--r--lib/api/project_templates.rb24
-rw-r--r--lib/api/projects.rb170
-rw-r--r--lib/api/protected_branches.rb26
-rw-r--r--lib/api/protected_tags.rb38
-rw-r--r--lib/api/release/links.rb44
-rw-r--r--lib/api/releases.rb50
-rw-r--r--lib/api/repositories.rb94
-rw-r--r--lib/api/resource_label_events.rb10
-rw-r--r--lib/api/runner.rb234
-rw-r--r--lib/api/runners.rb88
-rw-r--r--lib/api/scope.rb2
-rw-r--r--lib/api/search.rb38
-rw-r--r--lib/api/services.rb373
-rw-r--r--lib/api/settings.rb164
-rw-r--r--lib/api/sidekiq_metrics.rb46
-rw-r--r--lib/api/snippets.rb84
-rw-r--r--lib/api/submodules.rb14
-rw-r--r--lib/api/subscriptions.rb28
-rw-r--r--lib/api/suggestions.rb6
-rw-r--r--lib/api/system_hooks.rb20
-rw-r--r--lib/api/tags.rb80
-rw-r--r--lib/api/templates.rb32
-rw-r--r--lib/api/time_tracking_endpoints.rb18
-rw-r--r--lib/api/todos.rb22
-rw-r--r--lib/api/triggers.rb63
-rw-r--r--lib/api/users.rb392
-rw-r--r--lib/api/variables.rb44
-rw-r--r--lib/api/version.rb8
-rw-r--r--lib/api/wikis.rb50
-rw-r--r--lib/backup/artifacts.rb4
-rw-r--r--lib/backup/builds.rb4
-rw-r--r--lib/backup/database.rb86
-rw-r--r--lib/backup/files.rb32
-rw-r--r--lib/backup/helper.rb25
-rw-r--r--lib/backup/lfs.rb4
-rw-r--r--lib/backup/manager.rb60
-rw-r--r--lib/backup/pages.rb4
-rw-r--r--lib/backup/registry.rb4
-rw-r--r--lib/backup/repository.rb12
-rw-r--r--lib/backup/uploads.rb4
-rw-r--r--lib/banzai/filter/absolute_link_filter.rb8
-rw-r--r--lib/banzai/filter/abstract_reference_filter.rb30
-rw-r--r--lib/banzai/filter/ascii_doc_post_processing_filter.rb4
-rw-r--r--lib/banzai/filter/autolink_filter.rb20
-rw-r--r--lib/banzai/filter/color_filter.rb8
-rw-r--r--lib/banzai/filter/commit_range_reference_filter.rb2
-rw-r--r--lib/banzai/filter/commit_reference_filter.rb14
-rw-r--r--lib/banzai/filter/commit_trailers_filter.rb14
-rw-r--r--lib/banzai/filter/emoji_filter.rb6
-rw-r--r--lib/banzai/filter/external_issue_reference_filter.rb2
-rw-r--r--lib/banzai/filter/external_link_filter.rb24
-rw-r--r--lib/banzai/filter/footnote_filter.rb10
-rw-r--r--lib/banzai/filter/front_matter_filter.rb6
-rw-r--r--lib/banzai/filter/gollum_tags_filter.rb20
-rw-r--r--lib/banzai/filter/html_entity_filter.rb2
-rw-r--r--lib/banzai/filter/image_lazy_load_filter.rb8
-rw-r--r--lib/banzai/filter/image_link_filter.rb12
-rw-r--r--lib/banzai/filter/inline_diff_filter.rb2
-rw-r--r--lib/banzai/filter/issuable_state_filter.rb2
-rw-r--r--lib/banzai/filter/label_reference_filter.rb20
-rw-r--r--lib/banzai/filter/markdown_engines/common_mark.rb8
-rw-r--r--lib/banzai/filter/math_filter.rb18
-rw-r--r--lib/banzai/filter/merge_request_reference_filter.rb14
-rw-r--r--lib/banzai/filter/mermaid_filter.rb2
-rw-r--r--lib/banzai/filter/milestone_reference_filter.rb6
-rw-r--r--lib/banzai/filter/plantuml_filter.rb3
-rw-r--r--lib/banzai/filter/project_reference_filter.rb8
-rw-r--r--lib/banzai/filter/reference_filter.rb22
-rw-r--r--lib/banzai/filter/relative_link_filter.rb38
-rw-r--r--lib/banzai/filter/sanitization_filter.rb72
-rw-r--r--lib/banzai/filter/set_direction_filter.rb2
-rw-r--r--lib/banzai/filter/snippet_reference_filter.rb2
-rw-r--r--lib/banzai/filter/spaced_link_filter.rb16
-rw-r--r--lib/banzai/filter/suggestion_filter.rb4
-rw-r--r--lib/banzai/filter/syntax_highlight_filter.rb10
-rw-r--r--lib/banzai/filter/table_of_contents_filter.rb22
-rw-r--r--lib/banzai/filter/task_list_filter.rb2
-rw-r--r--lib/banzai/filter/user_reference_filter.rb14
-rw-r--r--lib/banzai/filter/video_link_filter.rb38
-rw-r--r--lib/banzai/filter/wiki_link_filter.rb8
-rw-r--r--lib/banzai/filter/wiki_link_filter/rewriter.rb6
-rw-r--r--lib/banzai/issuable_extractor.rb14
-rw-r--r--lib/banzai/object_renderer.rb4
-rw-r--r--lib/banzai/pipeline/base_pipeline.rb2
-rw-r--r--lib/banzai/pipeline/broadcast_message_pipeline.rb1
-rw-r--r--lib/banzai/pipeline/description_pipeline.rb2
-rw-r--r--lib/banzai/pipeline/gfm_pipeline.rb8
-rw-r--r--lib/banzai/pipeline/post_process_pipeline.rb2
-rw-r--r--lib/banzai/pipeline/single_line_pipeline.rb4
-rw-r--r--lib/banzai/pipeline/wiki_pipeline.rb2
-rw-r--r--lib/banzai/querying.rb4
-rw-r--r--lib/banzai/redactor.rb20
-rw-r--r--lib/banzai/reference_extractor.rb2
-rw-r--r--lib/banzai/reference_parser/base_parser.rb14
-rw-r--r--lib/banzai/reference_parser/directly_addressed_user_parser.rb2
-rw-r--r--lib/banzai/reference_parser/issue_parser.rb8
-rw-r--r--lib/banzai/reference_parser/merge_request_parser.rb11
-rw-r--r--lib/banzai/reference_parser/user_parser.rb18
-rw-r--r--lib/banzai/renderer.rb4
-rw-r--r--lib/banzai/renderer/common_mark/html.rb4
-rw-r--r--lib/banzai/request_store_reference_cache.rb4
-rw-r--r--lib/banzai/suggestions_parser.rb2
-rw-r--r--lib/bitbucket/client.rb2
-rw-r--r--lib/bitbucket/collection.rb4
-rw-r--r--lib/bitbucket/connection.rb6
-rw-r--r--lib/bitbucket/page.rb6
-rw-r--r--lib/bitbucket/representation/comment.rb10
-rw-r--r--lib/bitbucket/representation/issue.rb22
-rw-r--r--lib/bitbucket/representation/pull_request.rb34
-rw-r--r--lib/bitbucket/representation/pull_request_comment.rb16
-rw-r--r--lib/bitbucket/representation/repo.rb18
-rw-r--r--lib/bitbucket/representation/user.rb2
-rw-r--r--lib/bitbucket_server/client.rb4
-rw-r--r--lib/bitbucket_server/collection.rb4
-rw-r--r--lib/bitbucket_server/connection.rb32
-rw-r--r--lib/bitbucket_server/page.rb6
-rw-r--r--lib/bitbucket_server/representation/activity.rb20
-rw-r--r--lib/bitbucket_server/representation/comment.rb22
-rw-r--r--lib/bitbucket_server/representation/pull_request.rb36
-rw-r--r--lib/bitbucket_server/representation/pull_request_comment.rb32
-rw-r--r--lib/bitbucket_server/representation/repo.rb20
-rw-r--r--lib/constraints/project_url_constrainer.rb2
-rw-r--r--lib/container_registry/blob.rb8
-rw-r--r--lib/container_registry/client.rb38
-rw-r--r--lib/container_registry/path.rb10
-rw-r--r--lib/container_registry/registry.rb2
-rw-r--r--lib/container_registry/tag.rb12
-rw-r--r--lib/declarative_policy.rb26
-rw-r--r--lib/declarative_policy/base.rb6
-rw-r--r--lib/declarative_policy/cache.rb4
-rw-r--r--lib/declarative_policy/condition.rb2
-rw-r--r--lib/declarative_policy/rule.rb24
-rw-r--r--lib/declarative_policy/runner.rb6
-rw-r--r--lib/event_filter.rb14
-rw-r--r--lib/expand_variables.rb5
-rw-r--r--lib/extracts_path.rb12
-rw-r--r--lib/feature.rb16
-rw-r--r--lib/file_size_validator.rb8
-rw-r--r--lib/flowdock/git.rb10
-rw-r--r--lib/flowdock/git/builder.rb17
-rw-r--r--lib/forever.rb2
-rw-r--r--lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb4
-rw-r--r--lib/gitaly/server.rb2
-rw-r--r--lib/gitlab.rb20
-rw-r--r--lib/gitlab/access.rb18
-rw-r--r--lib/gitlab/action_rate_limiter.rb2
-rw-r--r--lib/gitlab/app_logger.rb2
-rw-r--r--lib/gitlab/asciidoc.rb18
-rw-r--r--lib/gitlab/audit_json_logger.rb2
-rw-r--r--lib/gitlab/auth.rb26
-rw-r--r--lib/gitlab/auth/activity.rb18
-rw-r--r--lib/gitlab/auth/blocked_user_tracker.rb1
-rw-r--r--lib/gitlab/auth/ip_rate_limiter.rb4
-rw-r--r--lib/gitlab/auth/ldap/access.rb12
-rw-r--r--lib/gitlab/auth/ldap/adapter.rb14
-rw-r--r--lib/gitlab/auth/ldap/auth_hash.rb2
-rw-r--r--lib/gitlab/auth/ldap/config.rb106
-rw-r--r--lib/gitlab/auth/ldap/dn.rb55
-rw-r--r--lib/gitlab/auth/ldap/person.rb12
-rw-r--r--lib/gitlab/auth/ldap/user.rb4
-rw-r--r--lib/gitlab/auth/o_auth/auth_hash.rb6
-rw-r--r--lib/gitlab/auth/o_auth/provider.rb18
-rw-r--r--lib/gitlab/auth/o_auth/user.rb19
-rw-r--r--lib/gitlab/auth/omniauth_identity_linker_base.rb10
-rw-r--r--lib/gitlab/auth/result.rb4
-rw-r--r--lib/gitlab/auth/saml/config.rb2
-rw-r--r--lib/gitlab/auth/saml/user.rb2
-rw-r--r--lib/gitlab/auth/unique_ips_limiter.rb2
-rw-r--r--lib/gitlab/auth/user_auth_finders.rb8
-rw-r--r--lib/gitlab/background_migration.rb6
-rw-r--r--lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb3
-rw-r--r--lib/gitlab/background_migration/archive_legacy_traces.rb10
-rw-r--r--lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb20
-rw-r--r--lib/gitlab/background_migration/backfill_project_repositories.rb30
-rw-r--r--lib/gitlab/background_migration/create_fork_network_memberships_range.rb3
-rw-r--r--lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb7
-rw-r--r--lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb1
-rw-r--r--lib/gitlab/background_migration/delete_diff_files.rb9
-rw-r--r--lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb39
-rw-r--r--lib/gitlab/background_migration/digest_column.rb2
-rw-r--r--lib/gitlab/background_migration/encrypt_columns.rb4
-rw-r--r--lib/gitlab/background_migration/fill_file_store_job_artifact.rb3
-rw-r--r--lib/gitlab/background_migration/fill_file_store_lfs_object.rb3
-rw-r--r--lib/gitlab/background_migration/fill_store_upload.rb3
-rw-r--r--lib/gitlab/background_migration/fix_cross_project_label_links.rb45
-rw-r--r--lib/gitlab/background_migration/migrate_build_stage.rb21
-rw-r--r--lib/gitlab/background_migration/migrate_build_stage_id_reference.rb1
-rw-r--r--lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb19
-rw-r--r--lib/gitlab/background_migration/migrate_legacy_artifacts.rb1
-rw-r--r--lib/gitlab/background_migration/migrate_stage_index.rb1
-rw-r--r--lib/gitlab/background_migration/migrate_stage_status.rb45
-rw-r--r--lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb5
-rw-r--r--lib/gitlab/background_migration/models/encrypt_columns/namespace.rb4
-rw-r--r--lib/gitlab/background_migration/models/encrypt_columns/project.rb4
-rw-r--r--lib/gitlab/background_migration/models/encrypt_columns/runner.rb4
-rw-r--r--lib/gitlab/background_migration/models/encrypt_columns/settings.rb6
-rw-r--r--lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb14
-rw-r--r--lib/gitlab/background_migration/move_personal_snippet_files.rb15
-rw-r--r--lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb69
-rw-r--r--lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb17
-rw-r--r--lib/gitlab/background_migration/populate_external_pipeline_source.rb17
-rw-r--r--lib/gitlab/background_migration/populate_fork_networks_range.rb108
-rw-r--r--lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb1
-rw-r--r--lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved.rb1
-rw-r--r--lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb3
-rw-r--r--lib/gitlab/background_migration/populate_untracked_uploads.rb46
-rw-r--r--lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb59
-rw-r--r--lib/gitlab/background_migration/prepare_untracked_uploads.rb29
-rw-r--r--lib/gitlab/background_migration/redact_links.rb11
-rw-r--r--lib/gitlab/background_migration/redact_links/redactable.rb9
-rw-r--r--lib/gitlab/background_migration/remove_restricted_todos.rb33
-rw-r--r--lib/gitlab/background_migration/schedule_diff_files_deletion.rb11
-rw-r--r--lib/gitlab/background_migration/set_confidential_note_events_on_services.rb7
-rw-r--r--lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb7
-rw-r--r--lib/gitlab/badge/coverage/metadata.rb2
-rw-r--r--lib/gitlab/badge/coverage/report.rb2
-rw-r--r--lib/gitlab/badge/coverage/template.rb12
-rw-r--r--lib/gitlab/badge/pipeline/metadata.rb2
-rw-r--r--lib/gitlab/badge/pipeline/status.rb4
-rw-r--r--lib/gitlab/badge/pipeline/template.rb16
-rw-r--r--lib/gitlab/badge/template.rb2
-rw-r--r--lib/gitlab/bare_repository_import/importer.rb20
-rw-r--r--lib/gitlab/bare_repository_import/repository.rb12
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb173
-rw-r--r--lib/gitlab/bitbucket_import/project_creator.rb4
-rw-r--r--lib/gitlab/bitbucket_server_import/importer.rb105
-rw-r--r--lib/gitlab/bitbucket_server_import/project_creator.rb4
-rw-r--r--lib/gitlab/blame.rb2
-rw-r--r--lib/gitlab/blob_helper.rb4
-rw-r--r--lib/gitlab/cache/ci/project_pipeline_status.rb10
-rw-r--r--lib/gitlab/cache/request_cache.rb4
-rw-r--r--lib/gitlab/changes_list.rb8
-rw-r--r--lib/gitlab/chat/command.rb8
-rw-r--r--lib/gitlab/chat/output.rb6
-rw-r--r--lib/gitlab/chat/responder/base.rb8
-rw-r--r--lib/gitlab/chat/responder/slack.rb10
-rw-r--r--lib/gitlab/chat_name_token.rb2
-rw-r--r--lib/gitlab/checks/base_checker.rb2
-rw-r--r--lib/gitlab/checks/branch_check.rb22
-rw-r--r--lib/gitlab/checks/diff_check.rb2
-rw-r--r--lib/gitlab/checks/lfs_check.rb4
-rw-r--r--lib/gitlab/checks/lfs_integrity.rb6
-rw-r--r--lib/gitlab/checks/post_push_message.rb2
-rw-r--r--lib/gitlab/checks/project_created.rb15
-rw-r--r--lib/gitlab/checks/project_moved.rb10
-rw-r--r--lib/gitlab/checks/tag_check.rb10
-rw-r--r--lib/gitlab/checks/timed_logger.rb2
-rw-r--r--lib/gitlab/ci/ansi2html.rb253
-rw-r--r--lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb2
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata.rb22
-rw-r--r--lib/gitlab/ci/build/artifacts/metadata/entry.rb4
-rw-r--r--lib/gitlab/ci/build/artifacts/path.rb12
-rw-r--r--lib/gitlab/ci/build/credentials/registry.rb2
-rw-r--r--lib/gitlab/ci/build/image.rb4
-rw-r--r--lib/gitlab/ci/build/policy.rb6
-rw-r--r--lib/gitlab/ci/build/policy/refs.rb6
-rw-r--r--lib/gitlab/ci/build/policy/variables.rb4
-rw-r--r--lib/gitlab/ci/build/step.rb10
-rw-r--r--lib/gitlab/ci/charts.rb6
-rw-r--r--lib/gitlab/ci/config/entry/artifacts.rb8
-rw-r--r--lib/gitlab/ci/config/entry/cache.rb10
-rw-r--r--lib/gitlab/ci/config/entry/environment.rb18
-rw-r--r--lib/gitlab/ci/config/entry/global.rb22
-rw-r--r--lib/gitlab/ci/config/entry/image.rb2
-rw-r--r--lib/gitlab/ci/config/entry/includes.rb4
-rw-r--r--lib/gitlab/ci/config/entry/job.rb92
-rw-r--r--lib/gitlab/ci/config/entry/jobs.rb4
-rw-r--r--lib/gitlab/ci/config/entry/key.rb2
-rw-r--r--lib/gitlab/ci/config/entry/policy.rb12
-rw-r--r--lib/gitlab/ci/config/entry/retry.rb34
-rw-r--r--lib/gitlab/ci/config/entry/stage.rb2
-rw-r--r--lib/gitlab/ci/config/extendable/entry.rb10
-rw-r--r--lib/gitlab/ci/config/external/file/base.rb2
-rw-r--r--lib/gitlab/ci/config/external/file/project.rb2
-rw-r--r--lib/gitlab/ci/config/external/file/template.rb2
-rw-r--r--lib/gitlab/ci/config/external/mapper.rb10
-rw-r--r--lib/gitlab/ci/cron_parser.rb6
-rw-r--r--lib/gitlab/ci/mask_secret.rb2
-rw-r--r--lib/gitlab/ci/model.rb2
-rw-r--r--lib/gitlab/ci/parsers.rb2
-rw-r--r--lib/gitlab/ci/parsers/test/junit.rb18
-rw-r--r--lib/gitlab/ci/pipeline/chain/command.rb4
-rw-r--r--lib/gitlab/ci/pipeline/chain/populate.rb4
-rw-r--r--lib/gitlab/ci/pipeline/chain/skip.rb2
-rw-r--r--lib/gitlab/ci/pipeline/chain/validate/abilities.rb4
-rw-r--r--lib/gitlab/ci/pipeline/chain/validate/repository.rb6
-rw-r--r--lib/gitlab/ci/pipeline/duration.rb8
-rw-r--r--lib/gitlab/ci/pipeline/expression/lexeme/null.rb2
-rw-r--r--lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb6
-rw-r--r--lib/gitlab/ci/pipeline/expression/lexer.rb10
-rw-r--r--lib/gitlab/ci/pipeline/expression/statement.rb4
-rw-r--r--lib/gitlab/ci/pipeline/preloader.rb2
-rw-r--r--lib/gitlab/ci/pipeline/seed/stage.rb12
-rw-r--r--lib/gitlab/ci/reports/test_case.rb10
-rw-r--r--lib/gitlab/ci/reports/test_reports_comparer.rb2
-rw-r--r--lib/gitlab/ci/reports/test_suite.rb2
-rw-r--r--lib/gitlab/ci/reports/test_suite_comparer.rb12
-rw-r--r--lib/gitlab/ci/status/build/cancelable.rb6
-rw-r--r--lib/gitlab/ci/status/build/canceled.rb6
-rw-r--r--lib/gitlab/ci/status/build/common.rb6
-rw-r--r--lib/gitlab/ci/status/build/created.rb8
-rw-r--r--lib/gitlab/ci/status/build/erased.rb6
-rw-r--r--lib/gitlab/ci/status/build/factory.rb8
-rw-r--r--lib/gitlab/ci/status/build/failed.rb22
-rw-r--r--lib/gitlab/ci/status/build/failed_allowed.rb4
-rw-r--r--lib/gitlab/ci/status/build/manual.rb8
-rw-r--r--lib/gitlab/ci/status/build/pending.rb8
-rw-r--r--lib/gitlab/ci/status/build/play.rb8
-rw-r--r--lib/gitlab/ci/status/build/retryable.rb6
-rw-r--r--lib/gitlab/ci/status/build/scheduled.rb6
-rw-r--r--lib/gitlab/ci/status/build/skipped.rb6
-rw-r--r--lib/gitlab/ci/status/build/stop.rb8
-rw-r--r--lib/gitlab/ci/status/build/unschedule.rb8
-rw-r--r--lib/gitlab/ci/status/canceled.rb8
-rw-r--r--lib/gitlab/ci/status/created.rb8
-rw-r--r--lib/gitlab/ci/status/factory.rb4
-rw-r--r--lib/gitlab/ci/status/failed.rb8
-rw-r--r--lib/gitlab/ci/status/manual.rb8
-rw-r--r--lib/gitlab/ci/status/pending.rb8
-rw-r--r--lib/gitlab/ci/status/pipeline/blocked.rb4
-rw-r--r--lib/gitlab/ci/status/pipeline/delayed.rb4
-rw-r--r--lib/gitlab/ci/status/pipeline/factory.rb2
-rw-r--r--lib/gitlab/ci/status/running.rb8
-rw-r--r--lib/gitlab/ci/status/scheduled.rb8
-rw-r--r--lib/gitlab/ci/status/skipped.rb8
-rw-r--r--lib/gitlab/ci/status/stage/common.rb4
-rw-r--r--lib/gitlab/ci/status/success.rb8
-rw-r--r--lib/gitlab/ci/status/success_warning.rb8
-rw-r--r--lib/gitlab/ci/trace.rb49
-rw-r--r--lib/gitlab/ci/trace/chunked_io.rb12
-rw-r--r--lib/gitlab/ci/trace/section_parser.rb12
-rw-r--r--lib/gitlab/ci/trace/stream.rb10
-rw-r--r--lib/gitlab/ci/variables/collection.rb10
-rw-r--r--lib/gitlab/ci/variables/collection/item.rb6
-rw-r--r--lib/gitlab/ci/yaml_processor.rb62
-rw-r--r--lib/gitlab/cleanup/project_upload_file_finder.rb12
-rw-r--r--lib/gitlab/cleanup/project_uploads.rb14
-rw-r--r--lib/gitlab/cleanup/remote_uploads.rb21
-rw-r--r--lib/gitlab/closing_issue_extractor.rb2
-rw-r--r--lib/gitlab/cluster/lifecycle_events.rb2
-rw-r--r--lib/gitlab/cluster/puma_worker_killer_initializer.rb2
-rw-r--r--lib/gitlab/color_schemes.rb14
-rw-r--r--lib/gitlab/config/entry/attributable.rb2
-rw-r--r--lib/gitlab/config/entry/configurable.rb2
-rw-r--r--lib/gitlab/config/entry/factory.rb2
-rw-r--r--lib/gitlab/config/entry/legacy_validation_helpers.rb2
-rw-r--r--lib/gitlab/config/entry/node.rb10
-rw-r--r--lib/gitlab/config/entry/simplifiable.rb8
-rw-r--r--lib/gitlab/config/entry/validator.rb2
-rw-r--r--lib/gitlab/config/entry/validators.rb34
-rw-r--r--lib/gitlab/config/loader/yaml.rb2
-rw-r--r--lib/gitlab/conflict/file.rb32
-rw-r--r--lib/gitlab/conflict/file_collection.rb22
-rw-r--r--lib/gitlab/content_disposition.rb5
-rw-r--r--lib/gitlab/contributions_calendar.rb22
-rw-r--r--lib/gitlab/correlation_id.rb2
-rw-r--r--lib/gitlab/cross_project_access.rb24
-rw-r--r--lib/gitlab/crypto_helper.rb4
-rw-r--r--lib/gitlab/current_settings.rb10
-rw-r--r--lib/gitlab/cycle_analytics/base_event_fetcher.rb16
-rw-r--r--lib/gitlab/cycle_analytics/base_stage.rb4
-rw-r--r--lib/gitlab/cycle_analytics/code_event_fetcher.rb2
-rw-r--r--lib/gitlab/cycle_analytics/code_stage.rb2
-rw-r--r--lib/gitlab/cycle_analytics/issue_event_fetcher.rb2
-rw-r--r--lib/gitlab/cycle_analytics/issue_stage.rb4
-rw-r--r--lib/gitlab/cycle_analytics/permissions.rb2
-rw-r--r--lib/gitlab/cycle_analytics/plan_event_fetcher.rb12
-rw-r--r--lib/gitlab/cycle_analytics/plan_stage.rb4
-rw-r--r--lib/gitlab/cycle_analytics/production_stage.rb2
-rw-r--r--lib/gitlab/cycle_analytics/review_event_fetcher.rb2
-rw-r--r--lib/gitlab/cycle_analytics/review_stage.rb2
-rw-r--r--lib/gitlab/cycle_analytics/stage_summary.rb2
-rw-r--r--lib/gitlab/cycle_analytics/staging_event_fetcher.rb4
-rw-r--r--lib/gitlab/cycle_analytics/staging_stage.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/base.rb4
-rw-r--r--lib/gitlab/cycle_analytics/summary/commit.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/deploy.rb2
-rw-r--r--lib/gitlab/cycle_analytics/summary/issue.rb2
-rw-r--r--lib/gitlab/cycle_analytics/test_stage.rb2
-rw-r--r--lib/gitlab/cycle_analytics/updater.rb2
-rw-r--r--lib/gitlab/cycle_analytics/usage_data.rb14
-rw-r--r--lib/gitlab/danger/helper.rb17
-rw-r--r--lib/gitlab/danger/teammate.rb10
-rw-r--r--lib/gitlab/data_builder/build.rb10
-rw-r--r--lib/gitlab/data_builder/note.rb4
-rw-r--r--lib/gitlab/data_builder/pipeline.rb12
-rw-r--r--lib/gitlab/data_builder/push.rb18
-rw-r--r--lib/gitlab/data_builder/repository.rb20
-rw-r--r--lib/gitlab/data_builder/wiki_page.rb2
-rw-r--r--lib/gitlab/database.rb60
-rw-r--r--lib/gitlab/database/count.rb4
-rw-r--r--lib/gitlab/database/count/reltuples_count_strategy.rb8
-rw-r--r--lib/gitlab/database/count/tablesample_count_strategy.rb2
-rw-r--r--lib/gitlab/database/date_time.rb8
-rw-r--r--lib/gitlab/database/grant.rb14
-rw-r--r--lib/gitlab/database/median.rb57
-rw-r--r--lib/gitlab/database/migration_helpers.rb160
-rw-r--r--lib/gitlab/database/multi_threaded_migration.rb14
-rw-r--r--lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb26
-rw-r--r--lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb32
-rw-r--r--lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb16
-rw-r--r--lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb12
-rw-r--r--lib/gitlab/database/sha_attribute.rb4
-rw-r--r--lib/gitlab/database/subquery.rb2
-rw-r--r--lib/gitlab/dependency_linker.rb2
-rw-r--r--lib/gitlab/dependency_linker/base_linker.rb2
-rw-r--r--lib/gitlab/dependency_linker/cartfile_linker.rb2
-rw-r--r--lib/gitlab/dependency_linker/gemfile_linker.rb4
-rw-r--r--lib/gitlab/dependency_linker/gemspec_linker.rb4
-rw-r--r--lib/gitlab/dependency_linker/godeps_json_linker.rb2
-rw-r--r--lib/gitlab/dependency_linker/json_linker.rb6
-rw-r--r--lib/gitlab/dependency_linker/package_json_linker.rb4
-rw-r--r--lib/gitlab/dependency_linker/podfile_linker.rb2
-rw-r--r--lib/gitlab/dependency_linker/podspec_json_linker.rb4
-rw-r--r--lib/gitlab/dependency_linker/podspec_linker.rb4
-rw-r--r--lib/gitlab/diff/diff_refs.rb8
-rw-r--r--lib/gitlab/diff/file.rb17
-rw-r--r--lib/gitlab/diff/file_collection/base.rb8
-rw-r--r--lib/gitlab/diff/file_collection/compare.rb4
-rw-r--r--lib/gitlab/diff/formatters/base_formatter.rb2
-rw-r--r--lib/gitlab/diff/formatters/text_formatter.rb4
-rw-r--r--lib/gitlab/diff/highlight.rb6
-rw-r--r--lib/gitlab/diff/highlight_cache.rb4
-rw-r--r--lib/gitlab/diff/image_point.rb2
-rw-r--r--lib/gitlab/diff/inline_diff.rb2
-rw-r--r--lib/gitlab/diff/inline_diff_markdown_marker.rb2
-rw-r--r--lib/gitlab/diff/inline_diff_marker.rb2
-rw-r--r--lib/gitlab/diff/line.rb18
-rw-r--r--lib/gitlab/diff/line_mapper.rb4
-rw-r--r--lib/gitlab/diff/lines_unfolder.rb12
-rw-r--r--lib/gitlab/diff/parallel_diff.rb6
-rw-r--r--lib/gitlab/diff/parser.rb22
-rw-r--r--lib/gitlab/diff/position.rb36
-rw-r--r--lib/gitlab/diff/position_tracer.rb22
-rw-r--r--lib/gitlab/discussions_diff/highlight_cache.rb6
-rw-r--r--lib/gitlab/downtime_check.rb4
-rw-r--r--lib/gitlab/downtime_check/message.rb4
-rw-r--r--lib/gitlab/ee_compat_check.rb81
-rw-r--r--lib/gitlab/email/attachment_uploader.rb6
-rw-r--r--lib/gitlab/email/handler.rb2
-rw-r--r--lib/gitlab/email/handler/base_handler.rb2
-rw-r--r--lib/gitlab/email/handler/create_issue_handler.rb11
-rw-r--r--lib/gitlab/email/handler/create_merge_request_handler.rb19
-rw-r--r--lib/gitlab/email/handler/create_note_handler.rb7
-rw-r--r--lib/gitlab/email/handler/reply_processing.rb8
-rw-r--r--lib/gitlab/email/handler/unsubscribe_handler.rb4
-rw-r--r--lib/gitlab/email/hook/additional_headers_interceptor.rb4
-rw-r--r--lib/gitlab/email/hook/delivery_metrics_observer.rb4
-rw-r--r--lib/gitlab/email/hook/email_template_interceptor.rb2
-rw-r--r--lib/gitlab/email/html_parser.rb6
-rw-r--r--lib/gitlab/email/message/repository_push.rb16
-rw-r--r--lib/gitlab/email/receiver.rb6
-rw-r--r--lib/gitlab/email/reply_parser.rb10
-rw-r--r--lib/gitlab/emoji.rb8
-rw-r--r--lib/gitlab/encoding_helper.rb8
-rw-r--r--lib/gitlab/environment.rb2
-rw-r--r--lib/gitlab/error_tracking/project.rb2
-rw-r--r--lib/gitlab/etag_caching/middleware.rb8
-rw-r--r--lib/gitlab/etag_caching/router.rb46
-rw-r--r--lib/gitlab/etag_caching/store.rb4
-rw-r--r--lib/gitlab/exclusive_lease.rb8
-rw-r--r--lib/gitlab/exclusive_lease_helpers.rb4
-rw-r--r--lib/gitlab/fake_application_settings.rb4
-rw-r--r--lib/gitlab/favicon.rb14
-rw-r--r--lib/gitlab/file_detector.rb30
-rw-r--r--lib/gitlab/file_finder.rb4
-rw-r--r--lib/gitlab/file_markdown_link_builder.rb2
-rw-r--r--lib/gitlab/file_type_detection.rb2
-rw-r--r--lib/gitlab/fogbugz_import/client.rb14
-rw-r--r--lib/gitlab/fogbugz_import/importer.rb140
-rw-r--r--lib/gitlab/fogbugz_import/project_creator.rb4
-rw-r--r--lib/gitlab/fogbugz_import/repository.rb8
-rw-r--r--lib/gitlab/gfm/reference_rewriter.rb2
-rw-r--r--lib/gitlab/gfm/uploads_rewriter.rb6
-rw-r--r--lib/gitlab/git.rb28
-rw-r--r--lib/gitlab/git/attributes_at_ref_parser.rb2
-rw-r--r--lib/gitlab/git/attributes_parser.rb14
-rw-r--r--lib/gitlab/git/blob.rb14
-rw-r--r--lib/gitlab/git/branch.rb2
-rw-r--r--lib/gitlab/git/bundle_file.rb4
-rw-r--r--lib/gitlab/git/commit.rb10
-rw-r--r--lib/gitlab/git/conflict/file.rb22
-rw-r--r--lib/gitlab/git/conflict/parser.rb20
-rw-r--r--lib/gitlab/git/conflict/resolver.rb4
-rw-r--r--lib/gitlab/git/diff.rb44
-rw-r--r--lib/gitlab/git/diff_collection.rb6
-rw-r--r--lib/gitlab/git/gitmodules_parser.rb4
-rw-r--r--lib/gitlab/git/lfs_pointer_file.rb4
-rw-r--r--lib/gitlab/git/merge_base.rb2
-rw-r--r--lib/gitlab/git/operation_service.rb4
-rw-r--r--lib/gitlab/git/patches/collection.rb4
-rw-r--r--lib/gitlab/git/path_helper.rb4
-rw-r--r--lib/gitlab/git/pre_receive_error.rb2
-rw-r--r--lib/gitlab/git/push.rb2
-rw-r--r--lib/gitlab/git/raw_diff_change.rb14
-rw-r--r--lib/gitlab/git/ref.rb16
-rw-r--r--lib/gitlab/git/remote_repository.rb12
-rw-r--r--lib/gitlab/git/repository.rb82
-rw-r--r--lib/gitlab/git/tag.rb2
-rw-r--r--lib/gitlab/git/tree.rb14
-rw-r--r--lib/gitlab/git/util.rb2
-rw-r--r--lib/gitlab/git/wiki.rb30
-rw-r--r--lib/gitlab/git_access.rb52
-rw-r--r--lib/gitlab/git_access_wiki.rb4
-rw-r--r--lib/gitlab/git_logger.rb2
-rw-r--r--lib/gitlab/git_post_receive.rb6
-rw-r--r--lib/gitlab/git_ref_validator.rb4
-rw-r--r--lib/gitlab/gitaly_client.rb71
-rw-r--r--lib/gitlab/gitaly_client/blobs_stitcher.rb20
-rw-r--r--lib/gitlab/gitaly_client/cleanup_service.rb4
-rw-r--r--lib/gitlab/gitaly_client/commit_service.rb44
-rw-r--r--lib/gitlab/gitaly_client/conflict_files_stitcher.rb6
-rw-r--r--lib/gitlab/gitaly_client/conflicts_service.rb4
-rw-r--r--lib/gitlab/gitaly_client/diff.rb2
-rw-r--r--lib/gitlab/gitaly_client/health_check_service.rb4
-rw-r--r--lib/gitlab/gitaly_client/object_pool_service.rb7
-rw-r--r--lib/gitlab/gitaly_client/operation_service.rb46
-rw-r--r--lib/gitlab/gitaly_client/ref_service.rb12
-rw-r--r--lib/gitlab/gitaly_client/remote_service.rb20
-rw-r--r--lib/gitlab/gitaly_client/repository_service.rb12
-rw-r--r--lib/gitlab/gitaly_client/storage_settings.rb8
-rw-r--r--lib/gitlab/gitaly_client/util.rb10
-rw-r--r--lib/gitlab/gitaly_client/wiki_file.rb2
-rw-r--r--lib/gitlab/gitaly_client/wiki_page.rb2
-rw-r--r--lib/gitlab/gitaly_client/wiki_service.rb10
-rw-r--r--lib/gitlab/github_import.rb4
-rw-r--r--lib/gitlab/github_import/caching.rb4
-rw-r--r--lib/gitlab/github_import/client.rb14
-rw-r--r--lib/gitlab/github_import/importer/diff_note_importer.rb6
-rw-r--r--lib/gitlab/github_import/importer/issue_importer.rb6
-rw-r--r--lib/gitlab/github_import/importer/issues_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/label_links_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/labels_importer.rb6
-rw-r--r--lib/gitlab/github_import/importer/lfs_objects_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/milestones_importer.rb6
-rw-r--r--lib/gitlab/github_import/importer/note_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/pull_request_importer.rb14
-rw-r--r--lib/gitlab/github_import/importer/pull_requests_importer.rb6
-rw-r--r--lib/gitlab/github_import/importer/releases_importer.rb2
-rw-r--r--lib/gitlab/github_import/importer/repository_importer.rb4
-rw-r--r--lib/gitlab/github_import/issuable_finder.rb4
-rw-r--r--lib/gitlab/github_import/label_finder.rb8
-rw-r--r--lib/gitlab/github_import/milestone_finder.rb8
-rw-r--r--lib/gitlab/github_import/page_counter.rb4
-rw-r--r--lib/gitlab/github_import/parallel_scheduling.rb4
-rw-r--r--lib/gitlab/github_import/representation/diff_note.rb14
-rw-r--r--lib/gitlab/github_import/representation/issue.rb12
-rw-r--r--lib/gitlab/github_import/representation/lfs_object.rb2
-rw-r--r--lib/gitlab/github_import/representation/note.rb12
-rw-r--r--lib/gitlab/github_import/representation/pull_request.rb14
-rw-r--r--lib/gitlab/github_import/sequential_importer.rb4
-rw-r--r--lib/gitlab/github_import/user_finder.rb6
-rw-r--r--lib/gitlab/gitlab_import/client.rb4
-rw-r--r--lib/gitlab/gitlab_import/importer.rb4
-rw-r--r--lib/gitlab/gl_id.rb2
-rw-r--r--lib/gitlab/gl_repository.rb4
-rw-r--r--lib/gitlab/gon_helper.rb12
-rw-r--r--lib/gitlab/google_code_import/importer.rb82
-rw-r--r--lib/gitlab/google_code_import/project_creator.rb2
-rw-r--r--lib/gitlab/gpg.rb14
-rw-r--r--lib/gitlab/gpg/commit.rb2
-rw-r--r--lib/gitlab/gpg/invalid_gpg_signature_updater.rb2
-rw-r--r--lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb6
-rw-r--r--lib/gitlab/grape_logging/loggers/correlation_id_logger.rb2
-rw-r--r--lib/gitlab/grape_logging/loggers/perf_logger.rb2
-rw-r--r--lib/gitlab/grape_logging/loggers/queue_duration_logger.rb4
-rw-r--r--lib/gitlab/grape_logging/loggers/route_logger.rb2
-rw-r--r--lib/gitlab/graphql/authorize/authorize_resource.rb12
-rw-r--r--lib/gitlab/graphql/authorize/instrumentation.rb2
-rw-r--r--lib/gitlab/graphql/expose_permissions.rb8
-rw-r--r--lib/gitlab/graphql/loaders/batch_model_loader.rb4
-rw-r--r--lib/gitlab/graphql/mount_mutation.rb2
-rw-r--r--lib/gitlab/graphql/present/instrumentation.rb2
-rw-r--r--lib/gitlab/graphs/commits.rb6
-rw-r--r--lib/gitlab/hashed_storage/rake_helper.rb12
-rw-r--r--lib/gitlab/health_checks/base_abstract_check.rb10
-rw-r--r--lib/gitlab/health_checks/db_check.rb8
-rw-r--r--lib/gitlab/health_checks/gitaly_check.rb6
-rw-r--r--lib/gitlab/health_checks/prometheus_text_format.rb2
-rw-r--r--lib/gitlab/health_checks/redis/cache_check.rb4
-rw-r--r--lib/gitlab/health_checks/redis/queues_check.rb4
-rw-r--r--lib/gitlab/health_checks/redis/redis_check.rb4
-rw-r--r--lib/gitlab/health_checks/redis/shared_state_check.rb4
-rw-r--r--lib/gitlab/health_checks/simple_abstract_check.rb2
-rw-r--r--lib/gitlab/highlight.rb4
-rw-r--r--lib/gitlab/hook_data/base_builder.rb6
-rw-r--r--lib/gitlab/hook_data/issuable_builder.rb7
-rw-r--r--lib/gitlab/hook_data/issue_builder.rb18
-rw-r--r--lib/gitlab/hook_data/merge_request_builder.rb6
-rw-r--r--lib/gitlab/hook_data/note_builder.rb2
-rw-r--r--lib/gitlab/hook_data/wiki_page_builder.rb4
-rw-r--r--lib/gitlab/http_io.rb14
-rw-r--r--lib/gitlab/i18n.rb44
-rw-r--r--lib/gitlab/i18n/metadata_entry.rb4
-rw-r--r--lib/gitlab/i18n/po_linter.rb47
-rw-r--r--lib/gitlab/i18n/translation_entry.rb10
-rw-r--r--lib/gitlab/identifier.rb6
-rw-r--r--lib/gitlab/import/database_helpers.rb2
-rw-r--r--lib/gitlab/import/logger.rb2
-rw-r--r--lib/gitlab/import_export.rb12
-rw-r--r--lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb2
-rw-r--r--lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb16
-rw-r--r--lib/gitlab/import_export/after_export_strategy_builder.rb6
-rw-r--r--lib/gitlab/import_export/attribute_cleaner.rb8
-rw-r--r--lib/gitlab/import_export/attributes_finder.rb8
-rw-r--r--lib/gitlab/import_export/avatar_restorer.rb2
-rw-r--r--lib/gitlab/import_export/avatar_saver.rb2
-rw-r--r--lib/gitlab/import_export/command_line_util.rb16
-rw-r--r--lib/gitlab/import_export/file_importer.rb2
-rw-r--r--lib/gitlab/import_export/group_project_object_builder.rb20
-rw-r--r--lib/gitlab/import_export/hash_util.rb4
-rw-r--r--lib/gitlab/import_export/importer.rb12
-rw-r--r--lib/gitlab/import_export/json_hash_builder.rb8
-rw-r--r--lib/gitlab/import_export/lfs_restorer.rb2
-rw-r--r--lib/gitlab/import_export/lfs_saver.rb4
-rw-r--r--lib/gitlab/import_export/members_mapper.rb16
-rw-r--r--lib/gitlab/import_export/merge_request_parser.rb4
-rw-r--r--lib/gitlab/import_export/project_tree_restorer.rb22
-rw-r--r--lib/gitlab/import_export/project_tree_saver.rb6
-rw-r--r--lib/gitlab/import_export/relation_factory.rb113
-rw-r--r--lib/gitlab/import_export/relation_rename_service.rb2
-rw-r--r--lib/gitlab/import_export/shared.rb6
-rw-r--r--lib/gitlab/import_export/uploads_manager.rb8
-rw-r--r--lib/gitlab/import_export/version_checker.rb2
-rw-r--r--lib/gitlab/import_export/version_saver.rb2
-rw-r--r--lib/gitlab/import_sources.rb20
-rw-r--r--lib/gitlab/incoming_email.rb10
-rw-r--r--lib/gitlab/insecure_key_fingerprint.rb2
-rw-r--r--lib/gitlab/issuable_metadata.rb4
-rw-r--r--lib/gitlab/issuable_sorter.rb4
-rw-r--r--lib/gitlab/issues_labels.rb24
-rw-r--r--lib/gitlab/job_waiter.rb2
-rw-r--r--lib/gitlab/json_cache.rb2
-rw-r--r--lib/gitlab/kubernetes.rb72
-rw-r--r--lib/gitlab/kubernetes/cluster_role_binding.rb8
-rw-r--r--lib/gitlab/kubernetes/config_map.rb2
-rw-r--r--lib/gitlab/kubernetes/helm.rb12
-rw-r--r--lib/gitlab/kubernetes/helm/api.rb2
-rw-r--r--lib/gitlab/kubernetes/helm/certificate.rb7
-rw-r--r--lib/gitlab/kubernetes/helm/client_command.rb4
-rw-r--r--lib/gitlab/kubernetes/helm/init_command.rb16
-rw-r--r--lib/gitlab/kubernetes/helm/install_command.rb28
-rw-r--r--lib/gitlab/kubernetes/helm/pod.rb32
-rw-r--r--lib/gitlab/kubernetes/kube_client.rb12
-rw-r--r--lib/gitlab/kubernetes/logger.rb2
-rw-r--r--lib/gitlab/kubernetes/namespace.rb2
-rw-r--r--lib/gitlab/kubernetes/pod.rb10
-rw-r--r--lib/gitlab/kubernetes/role_binding.rb14
-rw-r--r--lib/gitlab/kubernetes/service_account.rb2
-rw-r--r--lib/gitlab/kubernetes/service_account_token.rb6
-rw-r--r--lib/gitlab/language_data.rb6
-rw-r--r--lib/gitlab/language_detection.rb20
-rw-r--r--lib/gitlab/legacy_github_import/base_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/branch_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/client.rb14
-rw-r--r--lib/gitlab/legacy_github_import/comment_formatter.rb4
-rw-r--r--lib/gitlab/legacy_github_import/importer.rb82
-rw-r--r--lib/gitlab/legacy_github_import/issuable_formatter.rb4
-rw-r--r--lib/gitlab/legacy_github_import/issue_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/label_formatter.rb2
-rw-r--r--lib/gitlab/legacy_github_import/milestone_formatter.rb6
-rw-r--r--lib/gitlab/legacy_github_import/project_creator.rb6
-rw-r--r--lib/gitlab/legacy_github_import/pull_request_formatter.rb8
-rw-r--r--lib/gitlab/legacy_github_import/release_formatter.rb4
-rw-r--r--lib/gitlab/legacy_github_import/user_formatter.rb8
-rw-r--r--lib/gitlab/lfs_token.rb10
-rw-r--r--lib/gitlab/logger.rb10
-rw-r--r--lib/gitlab/mail_room.rb18
-rw-r--r--lib/gitlab/manifest_import/manifest.rb20
-rw-r--r--lib/gitlab/manifest_import/project_creator.rb8
-rw-r--r--lib/gitlab/markup_helper.rb4
-rw-r--r--lib/gitlab/metrics/background_transaction.rb2
-rw-r--r--lib/gitlab/metrics/influx_db.rb32
-rw-r--r--lib/gitlab/metrics/instrumentation.rb4
-rw-r--r--lib/gitlab/metrics/method_call.rb8
-rw-r--r--lib/gitlab/metrics/metric.rb8
-rw-r--r--lib/gitlab/metrics/prometheus.rb2
-rw-r--r--lib/gitlab/metrics/rack_middleware.rb5
-rw-r--r--lib/gitlab/metrics/requests_rack_middleware.rb12
-rw-r--r--lib/gitlab/metrics/samplers/base_sampler.rb2
-rw-r--r--lib/gitlab/metrics/samplers/influx_sampler.rb8
-rw-r--r--lib/gitlab/metrics/samplers/ruby_sampler.rb14
-rw-r--r--lib/gitlab/metrics/samplers/unicorn_sampler.rb12
-rw-r--r--lib/gitlab/metrics/sidekiq_metrics_exporter.rb12
-rw-r--r--lib/gitlab/metrics/sidekiq_middleware.rb2
-rw-r--r--lib/gitlab/metrics/subscribers/action_view.rb14
-rw-r--r--lib/gitlab/metrics/subscribers/active_record.rb6
-rw-r--r--lib/gitlab/metrics/subscribers/rails_cache.rb8
-rw-r--r--lib/gitlab/metrics/system.rb6
-rw-r--r--lib/gitlab/metrics/transaction.rb20
-rw-r--r--lib/gitlab/metrics/web_transaction.rb28
-rw-r--r--lib/gitlab/middleware/basic_health_check.rb8
-rw-r--r--lib/gitlab/middleware/go.rb28
-rw-r--r--lib/gitlab/middleware/multipart.rb8
-rw-r--r--lib/gitlab/middleware/rails_queue_duration.rb4
-rw-r--r--lib/gitlab/middleware/read_only/controller.rb44
-rw-r--r--lib/gitlab/middleware/release_env.rb4
-rw-r--r--lib/gitlab/middleware/static.rb2
-rw-r--r--lib/gitlab/multi_collection_paginator.rb26
-rw-r--r--lib/gitlab/namespace_sanitizer.rb2
-rw-r--r--lib/gitlab/object_hierarchy.rb2
-rw-r--r--lib/gitlab/omniauth_initializer.rb26
-rw-r--r--lib/gitlab/optimistic_locking.rb2
-rw-r--r--lib/gitlab/otp_key_rotator.rb4
-rw-r--r--lib/gitlab/pages_client.rb12
-rw-r--r--lib/gitlab/patch/sprockets_base_file_digest_key.rb2
-rw-r--r--lib/gitlab/path_regex.rb8
-rw-r--r--lib/gitlab/performance_bar.rb2
-rw-r--r--lib/gitlab/performance_bar/peek_query_tracker.rb6
-rw-r--r--lib/gitlab/plugin.rb6
-rw-r--r--lib/gitlab/plugin_logger.rb2
-rw-r--r--lib/gitlab/polling_interval.rb2
-rw-r--r--lib/gitlab/popen.rb12
-rw-r--r--lib/gitlab/private_commit_email.rb2
-rw-r--r--lib/gitlab/profiler.rb27
-rw-r--r--lib/gitlab/profiler/total_time_flat_printer.rb2
-rw-r--r--lib/gitlab/project_authorizations/with_nested_groups.rb24
-rw-r--r--lib/gitlab/project_authorizations/without_nested_groups.rb2
-rw-r--r--lib/gitlab/project_search_results.rb22
-rw-r--r--lib/gitlab/project_service_logger.rb2
-rw-r--r--lib/gitlab/project_template.rb32
-rw-r--r--lib/gitlab/project_transfer.rb8
-rw-r--r--lib/gitlab/prometheus/additional_metrics_parser.rb2
-rw-r--r--lib/gitlab/prometheus/metric.rb2
-rw-r--r--lib/gitlab/prometheus/metric_group.rb4
-rw-r--r--lib/gitlab/prometheus/queries/deployment_query.rb2
-rw-r--r--lib/gitlab/prometheus/queries/environment_query.rb2
-rw-r--r--lib/gitlab/prometheus/queries/matched_metric_query.rb14
-rw-r--r--lib/gitlab/prometheus/queries/query_additional_metrics.rb14
-rw-r--r--lib/gitlab/prometheus/query_variables.rb4
-rw-r--r--lib/gitlab/prometheus_client.rb40
-rw-r--r--lib/gitlab/protocol_access.rb2
-rw-r--r--lib/gitlab/query_limiting.rb4
-rw-r--r--lib/gitlab/query_limiting/active_support_subscriber.rb2
-rw-r--r--lib/gitlab/query_limiting/middleware.rb16
-rw-r--r--lib/gitlab/query_limiting/transaction.rb2
-rw-r--r--lib/gitlab/quick_actions/command_definition.rb28
-rw-r--r--lib/gitlab/quick_actions/dsl.rb10
-rw-r--r--lib/gitlab/quick_actions/extractor.rb10
-rw-r--r--lib/gitlab/quick_actions/spend_time_and_date_separator.rb8
-rw-r--r--lib/gitlab/redis/cache.rb10
-rw-r--r--lib/gitlab/redis/queues.rb12
-rw-r--r--lib/gitlab/redis/shared_state.rb14
-rw-r--r--lib/gitlab/redis/wrapper.rb16
-rw-r--r--lib/gitlab/reference_extractor.rb8
-rw-r--r--lib/gitlab/repo_path.rb6
-rw-r--r--lib/gitlab/repository_cache_adapter.rb2
-rw-r--r--lib/gitlab/repository_check_logger.rb2
-rw-r--r--lib/gitlab/request_profiler.rb6
-rw-r--r--lib/gitlab/request_profiler/middleware.rb16
-rw-r--r--lib/gitlab/request_profiler/profile.rb6
-rw-r--r--lib/gitlab/route_map.rb20
-rw-r--r--lib/gitlab/routing.rb8
-rw-r--r--lib/gitlab/sanitizers/svg.rb4
-rw-r--r--lib/gitlab/sanitizers/svg/whitelist.rb160
-rw-r--r--lib/gitlab/search/found_blob.rb10
-rw-r--r--lib/gitlab/search/query.rb16
-rw-r--r--lib/gitlab/search_results.rb18
-rw-r--r--lib/gitlab/sentry.rb2
-rw-r--r--lib/gitlab/setup_helper.rb24
-rw-r--r--lib/gitlab/shard_health_cache.rb2
-rw-r--r--lib/gitlab/shell.rb60
-rw-r--r--lib/gitlab/sherlock.rb6
-rw-r--r--lib/gitlab/sherlock/collection.rb2
-rw-r--r--lib/gitlab/sherlock/file_sample.rb2
-rw-r--r--lib/gitlab/sherlock/line_profiler.rb6
-rw-r--r--lib/gitlab/sherlock/middleware.rb6
-rw-r--r--lib/gitlab/sherlock/query.rb6
-rw-r--r--lib/gitlab/sherlock/transaction.rb8
-rw-r--r--lib/gitlab/sidekiq_config.rb22
-rw-r--r--lib/gitlab/sidekiq_logger.rb2
-rw-r--r--lib/gitlab/sidekiq_logging/json_formatter.rb2
-rw-r--r--lib/gitlab/sidekiq_logging/structured_logger.rb36
-rw-r--r--lib/gitlab/sidekiq_middleware/arguments_logger.rb2
-rw-r--r--lib/gitlab/sidekiq_middleware/shutdown.rb18
-rw-r--r--lib/gitlab/sidekiq_status.rb8
-rw-r--r--lib/gitlab/sidekiq_status/client_middleware.rb4
-rw-r--r--lib/gitlab/sidekiq_status/server_middleware.rb2
-rw-r--r--lib/gitlab/sidekiq_versioning.rb2
-rw-r--r--lib/gitlab/slash_commands/command.rb6
-rw-r--r--lib/gitlab/slash_commands/deploy.rb6
-rw-r--r--lib/gitlab/slash_commands/help.rb2
-rw-r--r--lib/gitlab/slash_commands/issue_move.rb4
-rw-r--r--lib/gitlab/slash_commands/issue_new.rb2
-rw-r--r--lib/gitlab/slash_commands/presenters/base.rb6
-rw-r--r--lib/gitlab/slash_commands/presenters/help.rb2
-rw-r--r--lib/gitlab/slash_commands/presenters/issue_base.rb14
-rw-r--r--lib/gitlab/slash_commands/presenters/issue_move.rb25
-rw-r--r--lib/gitlab/slash_commands/presenters/issue_new.rb24
-rw-r--r--lib/gitlab/slash_commands/presenters/issue_search.rb16
-rw-r--r--lib/gitlab/slash_commands/presenters/issue_show.rb26
-rw-r--r--lib/gitlab/slash_commands/presenters/run.rb6
-rw-r--r--lib/gitlab/slash_commands/run.rb2
-rw-r--r--lib/gitlab/snippet_search_results.rb10
-rw-r--r--lib/gitlab/sql/glob.rb6
-rw-r--r--lib/gitlab/sql/pattern.rb4
-rw-r--r--lib/gitlab/sql/recursive_cte.rb2
-rw-r--r--lib/gitlab/sql/union.rb8
-rw-r--r--lib/gitlab/ssh_public_key.rb4
-rw-r--r--lib/gitlab/string_range_marker.rb8
-rw-r--r--lib/gitlab/task_helpers.rb40
-rw-r--r--lib/gitlab/tcp_checker.rb2
-rw-r--r--lib/gitlab/template/base_template.rb18
-rw-r--r--lib/gitlab/template/dockerfile_template.rb8
-rw-r--r--lib/gitlab/template/finders/global_template_finder.rb2
-rw-r--r--lib/gitlab/template/finders/repo_template_finder.rb2
-rw-r--r--lib/gitlab/template/gitignore_template.rb10
-rw-r--r--lib/gitlab/template/gitlab_ci_yml_template.rb14
-rw-r--r--lib/gitlab/template/issue_template.rb6
-rw-r--r--lib/gitlab/template/merge_request_template.rb6
-rw-r--r--lib/gitlab/testing/request_blocker_middleware.rb1
-rw-r--r--lib/gitlab/testing/request_inspector_middleware.rb14
-rw-r--r--lib/gitlab/themes.rb22
-rw-r--r--lib/gitlab/time_tracking_formatter.rb12
-rw-r--r--lib/gitlab/timeless.rb1
-rw-r--r--lib/gitlab/tracing.rb4
-rw-r--r--lib/gitlab/tracing/common.rb18
-rw-r--r--lib/gitlab/tracing/factory.rb2
-rw-r--r--lib/gitlab/tracing/grpc_interceptor.rb20
-rw-r--r--lib/gitlab/tracing/jaeger_factory.rb6
-rw-r--r--lib/gitlab/tracing/rack_middleware.rb14
-rw-r--r--lib/gitlab/tracing/rails/action_view_subscriber.rb28
-rw-r--r--lib/gitlab/tracing/rails/active_record_subscriber.rb22
-rw-r--r--lib/gitlab/tracing/sidekiq/client_middleware.rb9
-rw-r--r--lib/gitlab/tracing/sidekiq/server_middleware.rb9
-rw-r--r--lib/gitlab/tracing/sidekiq/sidekiq_common.rb12
-rw-r--r--lib/gitlab/tree_summary.rb6
-rw-r--r--lib/gitlab/untrusted_regexp.rb12
-rw-r--r--lib/gitlab/url_blocker.rb20
-rw-r--r--lib/gitlab/url_builder.rb4
-rw-r--r--lib/gitlab/url_sanitizer.rb14
-rw-r--r--lib/gitlab/usage_data.rb40
-rw-r--r--lib/gitlab/user_access.rb12
-rw-r--r--lib/gitlab/user_extractor.rb2
-rw-r--r--lib/gitlab/utils.rb36
-rw-r--r--lib/gitlab/utils/merge_hash.rb2
-rw-r--r--lib/gitlab/utils/override.rb20
-rw-r--r--lib/gitlab/utils/strong_memoize.rb2
-rw-r--r--lib/gitlab/verify/batch_verifier.rb8
-rw-r--r--lib/gitlab/verify/job_artifacts.rb2
-rw-r--r--lib/gitlab/verify/lfs_objects.rb2
-rw-r--r--lib/gitlab/verify/rake_task.rb10
-rw-r--r--lib/gitlab/verify/uploads.rb2
-rw-r--r--lib/gitlab/visibility_level.rb20
-rw-r--r--lib/gitlab/web_ide_commits_counter.rb2
-rw-r--r--lib/gitlab/webpack/dev_server_middleware.rb8
-rw-r--r--lib/gitlab/webpack/manifest.rb2
-rw-r--r--lib/gitlab/wiki_file_finder.rb2
-rw-r--r--lib/gitlab/workhorse.rb106
-rw-r--r--lib/google_api/auth.rb10
-rw-r--r--lib/google_api/cloud_platform/client.rb22
-rw-r--r--lib/haml_lint/inline_javascript.rb14
-rw-r--r--lib/json_web_token/hmac_token.rb6
-rw-r--r--lib/json_web_token/rsa_token.rb6
-rw-r--r--lib/json_web_token/token.rb4
-rw-r--r--lib/mattermost/client.rb4
-rw-r--r--lib/mattermost/command.rb4
-rw-r--r--lib/mattermost/session.rb19
-rw-r--r--lib/mattermost/team.rb4
-rw-r--r--lib/microsoft_teams/activity.rb8
-rw-r--r--lib/microsoft_teams/notifier.rb16
-rw-r--r--lib/milestone_array.rb24
-rw-r--r--lib/mysql_zero_date.rb2
-rw-r--r--lib/object_storage/direct_upload.rb26
-rw-r--r--lib/omni_auth/strategies/bitbucket.rb28
-rw-r--r--lib/omni_auth/strategies/jwt.rb24
-rw-r--r--lib/peek/views/gitaly.rb4
-rw-r--r--lib/peek/views/host.rb2
-rw-r--r--lib/peek/views/tracing.rb2
-rw-r--r--lib/quality/helm_client.rb28
-rw-r--r--lib/quality/kubernetes_client.rb12
-rw-r--r--lib/rouge/formatters/html_gitlab.rb2
-rw-r--r--lib/rspec_flaky/config.rb8
-rw-r--r--lib/rspec_flaky/flaky_example.rb7
-rw-r--r--lib/rspec_flaky/flaky_examples_collection.rb10
-rw-r--r--lib/rspec_flaky/listener.rb12
-rw-r--r--lib/rspec_flaky/report.rb12
-rw-r--r--lib/safe_zip/extract.rb8
-rw-r--r--lib/safe_zip/extract_params.rb4
-rw-r--r--lib/sentry/client.rb62
-rw-r--r--lib/static_model.rb2
-rw-r--r--lib/system_check/app/active_users_check.rb2
-rw-r--r--lib/system_check/app/database_config_exists_check.rb12
-rw-r--r--lib/system_check/app/git_config_check.rb20
-rw-r--r--lib/system_check/app/git_user_default_ssh_config_check.rb12
-rw-r--r--lib/system_check/app/git_version_check.rb8
-rw-r--r--lib/system_check/app/gitlab_config_exists_check.rb10
-rw-r--r--lib/system_check/app/gitlab_config_up_to_date_check.rb14
-rw-r--r--lib/system_check/app/init_script_exists_check.rb10
-rw-r--r--lib/system_check/app/init_script_up_to_date_check.rb12
-rw-r--r--lib/system_check/app/log_writable_check.rb6
-rw-r--r--lib/system_check/app/migrations_are_up_check.rb6
-rw-r--r--lib/system_check/app/orphaned_group_members_check.rb10
-rw-r--r--lib/system_check/app/projects_have_namespace_check.rb8
-rw-r--r--lib/system_check/app/redis_version_check.rb6
-rw-r--r--lib/system_check/app/ruby_version_check.rb4
-rw-r--r--lib/system_check/app/tmp_writable_check.rb6
-rw-r--r--lib/system_check/app/uploads_directory_exists_check.rb6
-rw-r--r--lib/system_check/app/uploads_path_permission_check.rb10
-rw-r--r--lib/system_check/app/uploads_path_tmp_permission_check.rb12
-rw-r--r--lib/system_check/base_check.rb8
-rw-r--r--lib/system_check/gitaly_check.rb4
-rw-r--r--lib/system_check/gitlab_shell_check.rb14
-rw-r--r--lib/system_check/helpers.rb22
-rw-r--r--lib/system_check/incoming_email/foreman_configured_check.rb8
-rw-r--r--lib/system_check/incoming_email/imap_authentication_check.rb8
-rw-r--r--lib/system_check/incoming_email/initd_configured_check.rb10
-rw-r--r--lib/system_check/incoming_email/mail_room_running_check.rb14
-rw-r--r--lib/system_check/incoming_email_check.rb8
-rw-r--r--lib/system_check/ldap_check.rb20
-rw-r--r--lib/system_check/orphans/namespace_check.rb6
-rw-r--r--lib/system_check/orphans/repository_check.rb8
-rw-r--r--lib/system_check/rake_task/app_task.rb4
-rw-r--r--lib/system_check/rake_task/gitaly_task.rb2
-rw-r--r--lib/system_check/rake_task/gitlab_shell_task.rb2
-rw-r--r--lib/system_check/rake_task/gitlab_task.rb4
-rw-r--r--lib/system_check/rake_task/incoming_email_task.rb2
-rw-r--r--lib/system_check/rake_task/ldap_task.rb2
-rw-r--r--lib/system_check/rake_task/orphans/namespace_task.rb2
-rw-r--r--lib/system_check/rake_task/orphans/repository_task.rb2
-rw-r--r--lib/system_check/rake_task/orphans_task.rb4
-rw-r--r--lib/system_check/rake_task/rake_task_helpers.rb2
-rw-r--r--lib/system_check/rake_task/sidekiq_task.rb2
-rw-r--r--lib/system_check/sidekiq_check.rb14
-rw-r--r--lib/system_check/simple_executor.rb16
-rw-r--r--lib/tasks/brakeman.rake8
-rw-r--r--lib/tasks/cache.rake4
-rw-r--r--lib/tasks/ci/cleanup.rake2
-rw-r--r--lib/tasks/config_lint.rake12
-rw-r--r--lib/tasks/dev.rake2
-rw-r--r--lib/tasks/downtime_check.rake12
-rw-r--r--lib/tasks/ee_compat_check.rake4
-rw-r--r--lib/tasks/eslint.rake6
-rw-r--r--lib/tasks/gemojione.rake86
-rw-r--r--lib/tasks/gettext.rake44
-rw-r--r--lib/tasks/gitlab/artifacts/check.rake2
-rw-r--r--lib/tasks/gitlab/artifacts/migrate.rake19
-rw-r--r--lib/tasks/gitlab/assets.rake22
-rw-r--r--lib/tasks/gitlab/backup.rake56
-rw-r--r--lib/tasks/gitlab/check.rake14
-rw-r--r--lib/tasks/gitlab/cleanup.rake33
-rw-r--r--lib/tasks/gitlab/db.rake26
-rw-r--r--lib/tasks/gitlab/dev.rake12
-rw-r--r--lib/tasks/gitlab/exclusive_lease.rake4
-rw-r--r--lib/tasks/gitlab/git.rake3
-rw-r--r--lib/tasks/gitlab/gitaly.rake13
-rw-r--r--lib/tasks/gitlab/helpers.rake2
-rw-r--r--lib/tasks/gitlab/import.rake2
-rw-r--r--lib/tasks/gitlab/import_export.rake10
-rw-r--r--lib/tasks/gitlab/info.rake22
-rw-r--r--lib/tasks/gitlab/ldap.rake24
-rw-r--r--lib/tasks/gitlab/lfs/check.rake2
-rw-r--r--lib/tasks/gitlab/lfs/migrate.rake15
-rw-r--r--lib/tasks/gitlab/list_repos.rake10
-rw-r--r--lib/tasks/gitlab/pages.rake2
-rw-r--r--lib/tasks/gitlab/setup.rake10
-rw-r--r--lib/tasks/gitlab/shell.rake53
-rw-r--r--lib/tasks/gitlab/storage.rake42
-rw-r--r--lib/tasks/gitlab/tcp_check.rake2
-rw-r--r--lib/tasks/gitlab/test.rake10
-rw-r--r--lib/tasks/gitlab/traces.rake19
-rw-r--r--lib/tasks/gitlab/track_deployment.rake4
-rw-r--r--lib/tasks/gitlab/two_factor.rake4
-rw-r--r--lib/tasks/gitlab/update_templates.rake6
-rw-r--r--lib/tasks/gitlab/uploads/check.rake2
-rw-r--r--lib/tasks/gitlab/uploads/migrate.rake34
-rw-r--r--lib/tasks/gitlab/web_hook.rake10
-rw-r--r--lib/tasks/gitlab/workhorse.rake4
-rw-r--r--lib/tasks/grape.rake2
-rw-r--r--lib/tasks/haml-lint.rake6
-rw-r--r--lib/tasks/import.rake26
-rw-r--r--lib/tasks/karma.rake18
-rw-r--r--lib/tasks/lint.rake16
-rw-r--r--lib/tasks/migrate/add_limits_mysql.rake12
-rw-r--r--lib/tasks/migrate/composite_primary_keys.rake8
-rw-r--r--lib/tasks/migrate/migrate_iids.rake60
-rw-r--r--lib/tasks/migrate/setup_postgresql.rake34
-rw-r--r--lib/tasks/plugins.rake4
-rw-r--r--lib/tasks/rubocop.rake2
-rw-r--r--lib/tasks/scss-lint.rake4
-rw-r--r--lib/tasks/services.rake78
-rw-r--r--lib/tasks/sidekiq.rake10
-rw-r--r--lib/tasks/spec.rake44
-rw-r--r--lib/tasks/tokens.rake10
-rw-r--r--lib/tasks/yarn.rake37
-rw-r--r--lib/unfold_form.rb2
-rw-r--r--lib/uploaded_file.rb8
-rw-r--r--lib/version_check.rb4
-rw-r--r--locale/unfound_translations.rb20
-rwxr-xr-xplugins/examples/save_to_file.rb2
-rw-r--r--qa/Gemfile20
-rw-r--r--qa/Rakefile4
-rwxr-xr-xqa/bin/qa2
-rw-r--r--qa/qa.rb336
-rw-r--r--qa/qa/fixtures/auto_devops_rack/Gemfile6
-rw-r--r--qa/qa/fixtures/auto_devops_rack/Rakefile2
-rw-r--r--qa/qa/fixtures/auto_devops_rack/config.ru2
-rw-r--r--qa/qa/git/location.rb10
-rw-r--r--qa/qa/git/repository.rb66
-rw-r--r--qa/qa/page/admin/menu.rb2
-rw-r--r--qa/qa/page/admin/settings/component/account_and_limit.rb2
-rw-r--r--qa/qa/page/admin/settings/component/repository_storage.rb2
-rw-r--r--qa/qa/page/admin/settings/general.rb2
-rw-r--r--qa/qa/page/admin/settings/repository.rb2
-rw-r--r--qa/qa/page/alert/auto_devops_alert.rb2
-rw-r--r--qa/qa/page/base.rb10
-rw-r--r--qa/qa/page/component/clone_panel.rb2
-rw-r--r--qa/qa/page/component/dropdown_filter.rb4
-rw-r--r--qa/qa/page/component/dropzone.rb4
-rw-r--r--qa/qa/page/component/groups_filter.rb6
-rw-r--r--qa/qa/page/component/issuable/common.rb10
-rw-r--r--qa/qa/page/component/lazy_loader.rb2
-rw-r--r--qa/qa/page/component/legacy_clone_panel.rb14
-rw-r--r--qa/qa/page/component/note.rb8
-rw-r--r--qa/qa/page/component/select2.rb8
-rw-r--r--qa/qa/page/component/users_select.rb2
-rw-r--r--qa/qa/page/dashboard/groups.rb10
-rw-r--r--qa/qa/page/dashboard/projects.rb6
-rw-r--r--qa/qa/page/element.rb2
-rw-r--r--qa/qa/page/file/form.rb26
-rw-r--r--qa/qa/page/file/shared/commit_message.rb4
-rw-r--r--qa/qa/page/file/show.rb10
-rw-r--r--qa/qa/page/group/new.rb20
-rw-r--r--qa/qa/page/group/show.rb6
-rw-r--r--qa/qa/page/issuable/sidebar.rb10
-rw-r--r--qa/qa/page/label/index.rb6
-rw-r--r--qa/qa/page/label/new.rb2
-rw-r--r--qa/qa/page/layout/banner.rb6
-rw-r--r--qa/qa/page/main/login.rb24
-rw-r--r--qa/qa/page/main/menu.rb24
-rw-r--r--qa/qa/page/main/oauth.rb6
-rw-r--r--qa/qa/page/main/sign_up.rb6
-rw-r--r--qa/qa/page/mattermost/login.rb10
-rw-r--r--qa/qa/page/mattermost/main.rb2
-rw-r--r--qa/qa/page/merge_request/new.rb14
-rw-r--r--qa/qa/page/merge_request/show.rb40
-rw-r--r--qa/qa/page/profile/menu.rb16
-rw-r--r--qa/qa/page/profile/personal_access_tokens.rb12
-rw-r--r--qa/qa/page/profile/ssh_keys.rb4
-rw-r--r--qa/qa/page/project/activity.rb4
-rw-r--r--qa/qa/page/project/branches/show.rb10
-rw-r--r--qa/qa/page/project/commit/show.rb2
-rw-r--r--qa/qa/page/project/fork/new.rb4
-rw-r--r--qa/qa/page/project/import/github.rb12
-rw-r--r--qa/qa/page/project/issue/index.rb4
-rw-r--r--qa/qa/page/project/issue/new.rb14
-rw-r--r--qa/qa/page/project/issue/show.rb20
-rw-r--r--qa/qa/page/project/job/show.rb8
-rw-r--r--qa/qa/page/project/menu.rb2
-rw-r--r--qa/qa/page/project/milestone/index.rb2
-rw-r--r--qa/qa/page/project/milestone/new.rb2
-rw-r--r--qa/qa/page/project/new.rb26
-rw-r--r--qa/qa/page/project/operations/environments/index.rb2
-rw-r--r--qa/qa/page/project/operations/environments/show.rb2
-rw-r--r--qa/qa/page/project/operations/kubernetes/add.rb4
-rw-r--r--qa/qa/page/project/operations/kubernetes/add_existing.rb20
-rw-r--r--qa/qa/page/project/operations/kubernetes/index.rb4
-rw-r--r--qa/qa/page/project/operations/kubernetes/show.rb16
-rw-r--r--qa/qa/page/project/pipeline/index.rb8
-rw-r--r--qa/qa/page/project/pipeline/show.rb26
-rw-r--r--qa/qa/page/project/settings/advanced.rb8
-rw-r--r--qa/qa/page/project/settings/ci_cd.rb10
-rw-r--r--qa/qa/page/project/settings/ci_variables.rb22
-rw-r--r--qa/qa/page/project/settings/common.rb2
-rw-r--r--qa/qa/page/project/settings/deploy_keys.rb16
-rw-r--r--qa/qa/page/project/settings/deploy_tokens.rb4
-rw-r--r--qa/qa/page/project/settings/main.rb2
-rw-r--r--qa/qa/page/project/settings/members.rb4
-rw-r--r--qa/qa/page/project/settings/merge_request.rb4
-rw-r--r--qa/qa/page/project/settings/mirroring_repositories.rb12
-rw-r--r--qa/qa/page/project/settings/protected_branches.rb22
-rw-r--r--qa/qa/page/project/settings/repository.rb6
-rw-r--r--qa/qa/page/project/settings/runners.rb14
-rw-r--r--qa/qa/page/project/show.rb34
-rw-r--r--qa/qa/page/project/sub_menus/ci_cd.rb2
-rw-r--r--qa/qa/page/project/sub_menus/common.rb4
-rw-r--r--qa/qa/page/project/sub_menus/issues.rb4
-rw-r--r--qa/qa/page/project/sub_menus/operations.rb4
-rw-r--r--qa/qa/page/project/sub_menus/repository.rb2
-rw-r--r--qa/qa/page/project/sub_menus/settings.rb8
-rw-r--r--qa/qa/page/project/web_ide/edit.rb28
-rw-r--r--qa/qa/page/project/wiki/edit.rb14
-rw-r--r--qa/qa/page/project/wiki/new.rb6
-rw-r--r--qa/qa/page/project/wiki/show.rb6
-rw-r--r--qa/qa/page/settings/common.rb4
-rw-r--r--qa/qa/page/validator.rb14
-rw-r--r--qa/qa/page/view.rb4
-rw-r--r--qa/qa/resource/api_fabricator.rb9
-rw-r--r--qa/qa/resource/base.rb15
-rw-r--r--qa/qa/resource/branch.rb22
-rw-r--r--qa/qa/resource/ci_variable.rb4
-rw-r--r--qa/qa/resource/deploy_key.rb4
-rw-r--r--qa/qa/resource/deploy_token.rb4
-rw-r--r--qa/qa/resource/events/base.rb6
-rw-r--r--qa/qa/resource/events/project.rb8
-rw-r--r--qa/qa/resource/file.rb12
-rw-r--r--qa/qa/resource/fork.rb2
-rw-r--r--qa/qa/resource/group.rb6
-rw-r--r--qa/qa/resource/issue.rb4
-rw-r--r--qa/qa/resource/kubernetes_cluster.rb11
-rw-r--r--qa/qa/resource/label.rb8
-rw-r--r--qa/qa/resource/merge_request.rb28
-rw-r--r--qa/qa/resource/merge_request_from_fork.rb2
-rw-r--r--qa/qa/resource/personal_access_token.rb2
-rw-r--r--qa/qa/resource/project.rb10
-rw-r--r--qa/qa/resource/project_imported_from_github.rb2
-rw-r--r--qa/qa/resource/project_milestone.rb2
-rw-r--r--qa/qa/resource/repository/project_push.rb10
-rw-r--r--qa/qa/resource/repository/push.rb20
-rw-r--r--qa/qa/resource/repository/wiki_push.rb14
-rw-r--r--qa/qa/resource/runner.rb8
-rw-r--r--qa/qa/resource/sandbox.rb8
-rw-r--r--qa/qa/resource/user.rb18
-rw-r--r--qa/qa/resource/wiki.rb4
-rw-r--r--qa/qa/runtime/api/client.rb2
-rw-r--r--qa/qa/runtime/api/request.rb8
-rw-r--r--qa/qa/runtime/browser.rb32
-rw-r--r--qa/qa/runtime/env.rb76
-rw-r--r--qa/qa/runtime/key/base.rb2
-rw-r--r--qa/qa/runtime/key/ecdsa.rb2
-rw-r--r--qa/qa/runtime/key/ed25519.rb2
-rw-r--r--qa/qa/runtime/key/rsa.rb2
-rw-r--r--qa/qa/runtime/logger.rb2
-rw-r--r--qa/qa/runtime/namespace.rb4
-rw-r--r--qa/qa/runtime/path.rb2
-rw-r--r--qa/qa/runtime/release.rb2
-rw-r--r--qa/qa/runtime/user.rb6
-rw-r--r--qa/qa/scenario/bootable.rb12
-rw-r--r--qa/qa/scenario/test/instance.rb2
-rw-r--r--qa/qa/scenario/test/sanity/selectors.rb6
-rw-r--r--qa/qa/service/kubernetes_cluster.rb46
-rw-r--r--qa/qa/service/runner.rb12
-rw-r--r--qa/qa/service/shellout.rb2
-rw-r--r--qa/qa/specs/features/api/1_manage/users_spec.rb16
-rw-r--r--qa/qa/specs/features/api/3_create/repository/files_spec.rb24
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb6
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb6
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb6
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb16
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/project/add_project_member_spec.rb12
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb18
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb48
-rw-r--r--qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb18
-rw-r--r--qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb8
-rw-r--r--qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb20
-rw-r--r--qa/qa/specs/features/browser_ui/2_plan/issue/filter_issue_comments_spec.rb12
-rw-r--r--qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb16
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb54
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb14
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb18
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb22
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb58
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/add_list_delete_branches_spec.rb42
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb10
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb24
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb24
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb25
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb25
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_http_private_token_spec.rb20
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb26
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb30
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb20
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb30
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb24
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb38
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb52
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb30
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb16
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb34
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb6
-rw-r--r--qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb12
-rw-r--r--qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb48
-rw-r--r--qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb12
-rw-r--r--qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb78
-rw-r--r--qa/qa/specs/features/browser_ui/7_configure/mattermost/create_group_with_mattermost_team_spec.rb6
-rw-r--r--qa/qa/specs/features/sanity/framework_spec.rb12
-rw-r--r--qa/qa/specs/runner.rb8
-rw-r--r--qa/qa/support/api.rb12
-rw-r--r--qa/qa/support/page/logging.rb20
-rw-r--r--qa/qa/support/retrier.rb2
-rw-r--r--qa/qa/tools/delete_subgroups.rb12
-rw-r--r--qa/qa/tools/revoke_all_personal_access_tokens.rb18
-rw-r--r--qa/qa/vendor/github/page/login.rb10
-rw-r--r--qa/qa/vendor/saml_idp/page/login.rb8
-rw-r--r--qa/spec/factory/resource/user_spec.rb26
-rw-r--r--qa/spec/git/location_spec.rb54
-rw-r--r--qa/spec/git/repository_spec.rb64
-rw-r--r--qa/spec/helpers/stub_env.rb2
-rw-r--r--qa/spec/page/base_spec.rb54
-rw-r--r--qa/spec/page/element_spec.rb40
-rw-r--r--qa/spec/page/logging_spec.rb62
-rw-r--r--qa/spec/page/validator_spec.rb36
-rw-r--r--qa/spec/page/view_spec.rb48
-rw-r--r--qa/spec/resource/api_fabricator_spec.rb84
-rw-r--r--qa/spec/resource/base_spec.rb146
-rw-r--r--qa/spec/resource/events/base_spec.rb18
-rw-r--r--qa/spec/resource/events/project_spec.rb44
-rw-r--r--qa/spec/resource/repository/push_spec.rb16
-rw-r--r--qa/spec/resource/user_spec.rb76
-rw-r--r--qa/spec/runtime/api/client_spec.rb28
-rw-r--r--qa/spec/runtime/api/request_spec.rb54
-rw-r--r--qa/spec/runtime/env_spec.rb214
-rw-r--r--qa/spec/runtime/key/ecdsa_spec.rb6
-rw-r--r--qa/spec/runtime/key/ed25519_spec.rb4
-rw-r--r--qa/spec/runtime/key/rsa_spec.rb4
-rw-r--r--qa/spec/runtime/logger_spec.rb24
-rw-r--r--qa/spec/runtime/release_spec.rb32
-rw-r--r--qa/spec/runtime/scenario_spec.rb18
-rw-r--r--qa/spec/scenario/actable_spec.rb32
-rw-r--r--qa/spec/scenario/bootable_spec.rb12
-rw-r--r--qa/spec/scenario/test/instance/all_spec.rb2
-rw-r--r--qa/spec/scenario/test/instance/smoke_spec.rb2
-rw-r--r--qa/spec/scenario/test/integration/github_spec.rb12
-rw-r--r--qa/spec/scenario/test/integration/instance_saml_spec.rb4
-rw-r--r--qa/spec/scenario/test/integration/kubernetes_spec.rb4
-rw-r--r--qa/spec/scenario/test/integration/ldap_spec.rb8
-rw-r--r--qa/spec/scenario/test/integration/mattermost_spec.rb10
-rw-r--r--qa/spec/scenario/test/integration/oauth_spec.rb4
-rw-r--r--qa/spec/scenario/test/integration/object_storage_spec.rb4
-rw-r--r--qa/spec/scenario/test/sanity/framework_spec.rb2
-rw-r--r--qa/spec/scenario/test/sanity/selectors_spec.rb16
-rw-r--r--qa/spec/shared_examples/scenario_shared_examples.rb30
-rw-r--r--qa/spec/spec_helper.rb12
-rw-r--r--qa/spec/spec_helper_spec.rb134
-rw-r--r--qa/spec/specs/runner_spec.rb42
-rw-r--r--qa/spec/support/waiter_spec.rb24
-rw-r--r--rubocop/code_reuse_helpers.rb28
-rw-r--r--rubocop/cop/avoid_break_from_strong_memoize.rb2
-rw-r--r--rubocop/cop/avoid_return_from_blocks.rb2
-rw-r--r--rubocop/cop/avoid_route_redirect_leading_slash.rb4
-rw-r--r--rubocop/cop/code_reuse/active_record.rb10
-rw-r--r--rubocop/cop/code_reuse/finder.rb8
-rw-r--r--rubocop/cop/code_reuse/presenter.rb16
-rw-r--r--rubocop/cop/code_reuse/serializer.rb16
-rw-r--r--rubocop/cop/code_reuse/service_class.rb12
-rw-r--r--rubocop/cop/code_reuse/worker.rb16
-rw-r--r--rubocop/cop/destroy_all.rb6
-rw-r--r--rubocop/cop/gitlab/finder_with_find_by.rb15
-rw-r--r--rubocop/cop/gitlab/httparty.rb4
-rw-r--r--rubocop/cop/gitlab/predicate_memoization.rb2
-rw-r--r--rubocop/cop/gitlab/union.rb5
-rw-r--r--rubocop/cop/group_public_or_visible_to_user.rb8
-rw-r--r--rubocop/cop/include_sidekiq_worker.rb6
-rw-r--r--rubocop/cop/inject_enterprise_edition_module.rb4
-rw-r--r--rubocop/cop/line_break_around_conditional_block.rb4
-rw-r--r--rubocop/cop/migration/add_column.rb6
-rw-r--r--rubocop/cop/migration/add_concurrent_foreign_key.rb4
-rw-r--r--rubocop/cop/migration/add_concurrent_index.rb6
-rw-r--r--rubocop/cop/migration/add_index.rb4
-rw-r--r--rubocop/cop/migration/add_reference.rb5
-rw-r--r--rubocop/cop/migration/add_timestamps.rb4
-rw-r--r--rubocop/cop/migration/datetime.rb4
-rw-r--r--rubocop/cop/migration/hash_index.rb12
-rw-r--r--rubocop/cop/migration/remove_column.rb4
-rw-r--r--rubocop/cop/migration/remove_concurrent_index.rb6
-rw-r--r--rubocop/cop/migration/remove_index.rb4
-rw-r--r--rubocop/cop/migration/reversible_add_column_with_default.rb6
-rw-r--r--rubocop/cop/migration/safer_boolean_column.rb24
-rw-r--r--rubocop/cop/migration/timestamps.rb4
-rw-r--r--rubocop/cop/migration/update_column_in_batches.rb12
-rw-r--r--rubocop/cop/migration/update_large_table.rb10
-rw-r--r--rubocop/cop/prefer_class_methods_over_module.rb6
-rw-r--r--rubocop/cop/project_path_helper.rb10
-rw-r--r--rubocop/cop/qa/element_with_pattern.rb6
-rw-r--r--rubocop/cop/rspec/env_assignment.rb2
-rw-r--r--rubocop/cop/rspec/factories_in_migration_specs.rb4
-rw-r--r--rubocop/cop/ruby_interpolation_in_translation.rb2
-rw-r--r--rubocop/cop/safe_params.rb2
-rw-r--r--rubocop/cop/sidekiq_options_queue.rb4
-rw-r--r--rubocop/migration_helpers.rb4
-rw-r--r--rubocop/qa_helpers.rb2
-rw-r--r--rubocop/rubocop.rb86
-rw-r--r--rubocop/spec_helpers.rb10
-rwxr-xr-xscripts/detect-new-flaky-examples4
-rwxr-xr-xscripts/gitaly-test-build10
-rwxr-xr-xscripts/gitaly-test-spawn4
-rw-r--r--scripts/gitaly_test.rb54
-rwxr-xr-xscripts/lint-changelog-yaml8
-rwxr-xr-xscripts/lint-rugged10
-rwxr-xr-xscripts/merge-reports8
-rwxr-xr-xscripts/merge-simplecov12
-rwxr-xr-xscripts/no-ee-check4
-rwxr-xr-xscripts/prune-old-flaky-specs8
-rwxr-xr-xscripts/review_apps/automated_cleanup.rb42
-rwxr-xr-xscripts/security-harness10
-rwxr-xr-xscripts/static-analysis20
-rwxr-xr-xscripts/sync-reports30
-rwxr-xr-xscripts/trigger-build71
-rwxr-xr-xscripts/trigger-build-docs32
-rw-r--r--spec/bin/changelog_spec.rb66
-rw-r--r--spec/config/application_spec.rb22
-rw-r--r--spec/config/mail_room_spec.rb40
-rw-r--r--spec/config/object_store_settings_spec.rb30
-rw-r--r--spec/config/settings_spec.rb62
-rw-r--r--spec/controllers/abuse_reports_controller_spec.rb46
-rw-r--r--spec/controllers/admin/appearances_controller_spec.rb46
-rw-r--r--spec/controllers/admin/application_settings_controller_spec.rb46
-rw-r--r--spec/controllers/admin/applications_controller_spec.rb42
-rw-r--r--spec/controllers/admin/dashboard_controller_spec.rb8
-rw-r--r--spec/controllers/admin/gitaly_servers_controller_spec.rb6
-rw-r--r--spec/controllers/admin/groups_controller_spec.rb50
-rw-r--r--spec/controllers/admin/health_check_controller_spec.rb6
-rw-r--r--spec/controllers/admin/hooks_controller_spec.rb10
-rw-r--r--spec/controllers/admin/identities_controller_spec.rb18
-rw-r--r--spec/controllers/admin/impersonations_controller_spec.rb2
-rw-r--r--spec/controllers/admin/projects_controller_spec.rb22
-rw-r--r--spec/controllers/admin/requests_profiles_controller_spec.rb14
-rw-r--r--spec/controllers/admin/runners_controller_spec.rb58
-rw-r--r--spec/controllers/admin/services_controller_spec.rb24
-rw-r--r--spec/controllers/admin/spam_logs_controller_spec.rb22
-rw-r--r--spec/controllers/admin/users_controller_spec.rb164
-rw-r--r--spec/controllers/application_controller_spec.rb281
-rw-r--r--spec/controllers/autocomplete_controller_spec.rb192
-rw-r--r--spec/controllers/boards/issues_controller_spec.rb144
-rw-r--r--spec/controllers/boards/lists_controller_spec.rb148
-rw-r--r--spec/controllers/concerns/checks_collaboration_spec.rb24
-rw-r--r--spec/controllers/concerns/continue_params_spec.rb26
-rw-r--r--spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb36
-rw-r--r--spec/controllers/concerns/group_tree_spec.rb58
-rw-r--r--spec/controllers/concerns/internal_redirect_spec.rb74
-rw-r--r--spec/controllers/concerns/issuable_collections_spec.rb123
-rw-r--r--spec/controllers/concerns/lfs_request_spec.rb12
-rw-r--r--spec/controllers/concerns/send_file_upload_spec.rb70
-rw-r--r--spec/controllers/dashboard/groups_controller_spec.rb20
-rw-r--r--spec/controllers/dashboard/labels_controller_spec.rb4
-rw-r--r--spec/controllers/dashboard/milestones_controller_spec.rb28
-rw-r--r--spec/controllers/dashboard/projects_controller_spec.rb4
-rw-r--r--spec/controllers/dashboard/todos_controller_spec.rb68
-rw-r--r--spec/controllers/dashboard_controller_spec.rb20
-rw-r--r--spec/controllers/explore/groups_controller_spec.rb6
-rw-r--r--spec/controllers/explore/projects_controller_spec.rb14
-rw-r--r--spec/controllers/google_api/authorizations_controller_spec.rb24
-rw-r--r--spec/controllers/graphql_controller_spec.rb58
-rw-r--r--spec/controllers/groups/avatars_controller_spec.rb6
-rw-r--r--spec/controllers/groups/boards_controller_spec.rb86
-rw-r--r--spec/controllers/groups/children_controller_spec.rb192
-rw-r--r--spec/controllers/groups/clusters/applications_controller_spec.rb28
-rw-r--r--spec/controllers/groups/clusters_controller_spec.rb240
-rw-r--r--spec/controllers/groups/group_members_controller_spec.rb148
-rw-r--r--spec/controllers/groups/labels_controller_spec.rb30
-rw-r--r--spec/controllers/groups/milestones_controller_spec.rb200
-rw-r--r--spec/controllers/groups/runners_controller_spec.rb34
-rw-r--r--spec/controllers/groups/settings/ci_cd_controller_spec.rb30
-rw-r--r--spec/controllers/groups/shared_projects_controller_spec.rb22
-rw-r--r--spec/controllers/groups/uploads_controller_spec.rb8
-rw-r--r--spec/controllers/groups/variables_controller_spec.rb14
-rw-r--r--spec/controllers/groups_controller_spec.rb334
-rw-r--r--spec/controllers/health_check_controller_spec.rb98
-rw-r--r--spec/controllers/health_controller_spec.rb82
-rw-r--r--spec/controllers/help_controller_spec.rb116
-rw-r--r--spec/controllers/import/bitbucket_controller_spec.rb97
-rw-r--r--spec/controllers/import/bitbucket_server_controller_spec.rb86
-rw-r--r--spec/controllers/import/fogbugz_controller_spec.rb14
-rw-r--r--spec/controllers/import/gitea_controller_spec.rb20
-rw-r--r--spec/controllers/import/github_controller_spec.rb16
-rw-r--r--spec/controllers/import/gitlab_controller_spec.rb86
-rw-r--r--spec/controllers/import/gitlab_projects_controller_spec.rb28
-rw-r--r--spec/controllers/import/google_code_controller_spec.rb12
-rw-r--r--spec/controllers/instance_statistics/cohorts_controller_spec.rb6
-rw-r--r--spec/controllers/instance_statistics/conversational_development_index_controller_spec.rb4
-rw-r--r--spec/controllers/invites_controller_spec.rb22
-rw-r--r--spec/controllers/ldap/omniauth_callbacks_controller_spec.rb38
-rw-r--r--spec/controllers/metrics_controller_spec.rb34
-rw-r--r--spec/controllers/notification_settings_controller_spec.rb128
-rw-r--r--spec/controllers/oauth/applications_controller_spec.rb34
-rw-r--r--spec/controllers/oauth/authorizations_controller_spec.rb36
-rw-r--r--spec/controllers/omniauth_callbacks_controller_spec.rb150
-rw-r--r--spec/controllers/passwords_controller_spec.rb20
-rw-r--r--spec/controllers/profiles/accounts_controller_spec.rb14
-rw-r--r--spec/controllers/profiles/avatars_controller_spec.rb4
-rw-r--r--spec/controllers/profiles/emails_controller_spec.rb24
-rw-r--r--spec/controllers/profiles/keys_controller_spec.rb24
-rw-r--r--spec/controllers/profiles/notifications_controller_spec.rb30
-rw-r--r--spec/controllers/profiles/personal_access_tokens_controller_spec.rb14
-rw-r--r--spec/controllers/profiles/preferences_controller_spec.rb54
-rw-r--r--spec/controllers/profiles/two_factor_auths_controller_spec.rb58
-rw-r--r--spec/controllers/profiles_controller_spec.rb102
-rw-r--r--spec/controllers/projects/artifacts_controller_spec.rb209
-rw-r--r--spec/controllers/projects/autocomplete_sources_controller_spec.rb14
-rw-r--r--spec/controllers/projects/avatars_controller_spec.rb34
-rw-r--r--spec/controllers/projects/badges_controller_spec.rb36
-rw-r--r--spec/controllers/projects/blame_controller_spec.rb16
-rw-r--r--spec/controllers/projects/blob_controller_spec.rb230
-rw-r--r--spec/controllers/projects/boards_controller_spec.rb100
-rw-r--r--spec/controllers/projects/branches_controller_spec.rb358
-rw-r--r--spec/controllers/projects/ci/lints_controller_spec.rb75
-rw-r--r--spec/controllers/projects/clusters/applications_controller_spec.rb28
-rw-r--r--spec/controllers/projects/clusters_controller_spec.rb225
-rw-r--r--spec/controllers/projects/commit_controller_spec.rb284
-rw-r--r--spec/controllers/projects/commits_controller_spec.rb90
-rw-r--r--spec/controllers/projects/compare_controller_spec.rb152
-rw-r--r--spec/controllers/projects/cycle_analytics_controller_spec.rb28
-rw-r--r--spec/controllers/projects/deploy_keys_controller_spec.rb132
-rw-r--r--spec/controllers/projects/deployments_controller_spec.rb72
-rw-r--r--spec/controllers/projects/discussions_controller_spec.rb46
-rw-r--r--spec/controllers/projects/environments_controller_spec.rb314
-rw-r--r--spec/controllers/projects/error_tracking_controller_spec.rb96
-rw-r--r--spec/controllers/projects/find_file_controller_spec.rb38
-rw-r--r--spec/controllers/projects/forks_controller_spec.rb52
-rw-r--r--spec/controllers/projects/graphs_controller_spec.rb21
-rw-r--r--spec/controllers/projects/group_links_controller_spec.rb68
-rw-r--r--spec/controllers/projects/hooks_controller_spec.rb16
-rw-r--r--spec/controllers/projects/imports_controller_spec.rb74
-rw-r--r--spec/controllers/projects/issues_controller_spec.rb509
-rw-r--r--spec/controllers/projects/jobs_controller_spec.rb597
-rw-r--r--spec/controllers/projects/labels_controller_spec.rb138
-rw-r--r--spec/controllers/projects/mattermosts_controller_spec.rb38
-rw-r--r--spec/controllers/projects/merge_requests/conflicts_controller_spec.rb296
-rw-r--r--spec/controllers/projects/merge_requests/creations_controller_spec.rb118
-rw-r--r--spec/controllers/projects/merge_requests/diffs_controller_spec.rb64
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb510
-rw-r--r--spec/controllers/projects/milestones_controller_spec.rb74
-rw-r--r--spec/controllers/projects/mirrors_controller_spec.rb88
-rw-r--r--spec/controllers/projects/notes_controller_spec.rb202
-rw-r--r--spec/controllers/projects/pages_controller_spec.rb42
-rw-r--r--spec/controllers/projects/pages_domains_controller_spec.rb82
-rw-r--r--spec/controllers/projects/pipeline_schedules_controller_spec.rb206
-rw-r--r--spec/controllers/projects/pipelines_controller_spec.rb255
-rw-r--r--spec/controllers/projects/pipelines_settings_controller_spec.rb8
-rw-r--r--spec/controllers/projects/project_members_controller_spec.rb270
-rw-r--r--spec/controllers/projects/prometheus/metrics_controller_spec.rb38
-rw-r--r--spec/controllers/projects/protected_branches_controller_spec.rb32
-rw-r--r--spec/controllers/projects/protected_tags_controller_spec.rb6
-rw-r--r--spec/controllers/projects/raw_controller_spec.rb40
-rw-r--r--spec/controllers/projects/refs_controller_spec.rb32
-rw-r--r--spec/controllers/projects/registry/repositories_controller_spec.rb58
-rw-r--r--spec/controllers/projects/registry/tags_controller_spec.rb54
-rw-r--r--spec/controllers/projects/releases_controller_spec.rb16
-rw-r--r--spec/controllers/projects/repositories_controller_spec.rb40
-rw-r--r--spec/controllers/projects/runners_controller_spec.rb34
-rw-r--r--spec/controllers/projects/serverless/functions_controller_spec.rb38
-rw-r--r--spec/controllers/projects/services_controller_spec.rb132
-rw-r--r--spec/controllers/projects/settings/ci_cd_controller_spec.rb94
-rw-r--r--spec/controllers/projects/settings/integrations_controller_spec.rb8
-rw-r--r--spec/controllers/projects/settings/operations_controller_spec.rb54
-rw-r--r--spec/controllers/projects/settings/repository_controller_spec.rb16
-rw-r--r--spec/controllers/projects/snippets_controller_spec.rb222
-rw-r--r--spec/controllers/projects/tags/releases_controller_spec.rb24
-rw-r--r--spec/controllers/projects/tags_controller_spec.rb30
-rw-r--r--spec/controllers/projects/templates_controller_spec.rb26
-rw-r--r--spec/controllers/projects/todos_controller_spec.rb28
-rw-r--r--spec/controllers/projects/tree_controller_spec.rb90
-rw-r--r--spec/controllers/projects/uploads_controller_spec.rb16
-rw-r--r--spec/controllers/projects/variables_controller_spec.rb14
-rw-r--r--spec/controllers/projects/wikis_controller_spec.rb96
-rw-r--r--spec/controllers/projects_controller_spec.rb538
-rw-r--r--spec/controllers/registrations_controller_spec.rb76
-rw-r--r--spec/controllers/root_controller_spec.rb68
-rw-r--r--spec/controllers/search_controller_spec.rb30
-rw-r--r--spec/controllers/sent_notifications_controller_spec.rb58
-rw-r--r--spec/controllers/sessions_controller_spec.rb174
-rw-r--r--spec/controllers/snippets/notes_controller_spec.rb58
-rw-r--r--spec/controllers/snippets_controller_spec.rb342
-rw-r--r--spec/controllers/uploads_controller_spec.rb226
-rw-r--r--spec/controllers/user_callouts_controller_spec.rb22
-rw-r--r--spec/controllers/users/terms_controller_spec.rb50
-rw-r--r--spec/controllers/users_controller_spec.rb272
-rw-r--r--spec/db/development/import_common_metrics_spec.rb6
-rw-r--r--spec/db/importers/common_metrics_importer_spec.rb64
-rw-r--r--spec/db/production/import_common_metrics_spec.rb6
-rw-r--r--spec/db/production/settings_spec.rb38
-rw-r--r--spec/db/schema_spec.rb18
-rw-r--r--spec/dependencies/omniauth_saml_spec.rb16
-rw-r--r--spec/factories/abuse_reports.rb2
-rw-r--r--spec/factories/appearances.rb6
-rw-r--r--spec/factories/chat_names.rb4
-rw-r--r--spec/factories/ci/bridge.rb12
-rw-r--r--spec/factories/ci/build_trace_chunks.rb6
-rw-r--r--spec/factories/ci/builds.rb146
-rw-r--r--spec/factories/ci/group_variables.rb2
-rw-r--r--spec/factories/ci/job_artifacts.rb33
-rw-r--r--spec/factories/ci/pipeline_schedule.rb10
-rw-r--r--spec/factories/ci/pipeline_schedule_variables.rb2
-rw-r--r--spec/factories/ci/pipeline_variables.rb2
-rw-r--r--spec/factories/ci/pipelines.rb10
-rw-r--r--spec/factories/ci/runners.rb2
-rw-r--r--spec/factories/ci/stages.rb6
-rw-r--r--spec/factories/ci/variables.rb2
-rw-r--r--spec/factories/clusters/applications/helm.rb24
-rw-r--r--spec/factories/clusters/clusters.rb6
-rw-r--r--spec/factories/clusters/platforms/kubernetes.rb12
-rw-r--r--spec/factories/clusters/providers/gcp.rb12
-rw-r--r--spec/factories/commit_statuses.rb34
-rw-r--r--spec/factories/commits.rb2
-rw-r--r--spec/factories/container_repositories.rb12
-rw-r--r--spec/factories/deployments.rb8
-rw-r--r--spec/factories/environments.rb22
-rw-r--r--spec/factories/error_tracking/error.rb22
-rw-r--r--spec/factories/error_tracking/project.rb14
-rw-r--r--spec/factories/events.rb4
-rw-r--r--spec/factories/file_uploaders.rb4
-rw-r--r--spec/factories/gitaly/tag.rb4
-rw-r--r--spec/factories/gpg_keys.rb2
-rw-r--r--spec/factories/group_members.rb4
-rw-r--r--spec/factories/groups.rb6
-rw-r--r--spec/factories/identities.rb4
-rw-r--r--spec/factories/keys.rb10
-rw-r--r--spec/factories/lfs_file_locks.rb2
-rw-r--r--spec/factories/lfs_objects.rb2
-rw-r--r--spec/factories/merge_request_diff_files.rb18
-rw-r--r--spec/factories/merge_requests.rb7
-rw-r--r--spec/factories/namespaces.rb2
-rw-r--r--spec/factories/notes.rb6
-rw-r--r--spec/factories/oauth_applications.rb4
-rw-r--r--spec/factories/pages_domains.rb2
-rw-r--r--spec/factories/personal_access_tokens.rb2
-rw-r--r--spec/factories/programming_languages.rb4
-rw-r--r--spec/factories/project_error_tracking_settings.rb8
-rw-r--r--spec/factories/project_members.rb4
-rw-r--r--spec/factories/projects.rb55
-rw-r--r--spec/factories/prometheus_metrics.rb10
-rw-r--r--spec/factories/releases.rb2
-rw-r--r--spec/factories/remote_mirrors.rb2
-rw-r--r--spec/factories/services.rb40
-rw-r--r--spec/factories/spam_logs.rb2
-rw-r--r--spec/factories/system_note_metadata.rb2
-rw-r--r--spec/factories/trending_project.rb2
-rw-r--r--spec/factories/uploads.rb4
-rw-r--r--spec/factories/user_agent_details.rb4
-rw-r--r--spec/factories/user_statuses.rb4
-rw-r--r--spec/factories/users.rb8
-rw-r--r--spec/factories/web_hook_log.rb6
-rw-r--r--spec/factories/wiki_directories.rb2
-rw-r--r--spec/factories/wiki_pages.rb10
-rw-r--r--spec/factories_spec.rb10
-rw-r--r--spec/fast_spec_helper.rb18
-rw-r--r--spec/features/abuse_report_spec.rb14
-rw-r--r--spec/features/admin/admin_abuse_reports_spec.rb30
-rw-r--r--spec/features/admin/admin_appearance_spec.rb88
-rw-r--r--spec/features/admin/admin_broadcast_messages_spec.rb52
-rw-r--r--spec/features/admin/admin_browse_spam_logs_spec.rb16
-rw-r--r--spec/features/admin/admin_browses_logs_spec.rb16
-rw-r--r--spec/features/admin/admin_builds_spec.rb112
-rw-r--r--spec/features/admin/admin_deploy_keys_spec.rb50
-rw-r--r--spec/features/admin/admin_disables_git_access_protocol_spec.rb78
-rw-r--r--spec/features/admin/admin_disables_two_factor_spec.rb22
-rw-r--r--spec/features/admin/admin_groups_spec.rb132
-rw-r--r--spec/features/admin/admin_health_check_spec.rb40
-rw-r--r--spec/features/admin/admin_hook_logs_spec.rb22
-rw-r--r--spec/features/admin/admin_hooks_spec.rb94
-rw-r--r--spec/features/admin/admin_labels_spec.rb88
-rw-r--r--spec/features/admin/admin_manage_applications_spec.rb44
-rw-r--r--spec/features/admin/admin_projects_spec.rb60
-rw-r--r--spec/features/admin/admin_requests_profiles_spec.rb30
-rw-r--r--spec/features/admin/admin_runners_spec.rb308
-rw-r--r--spec/features/admin/admin_settings_spec.rb328
-rw-r--r--spec/features/admin/admin_system_info_spec.rb42
-rw-r--r--spec/features/admin/admin_users_impersonation_tokens_spec.rb16
-rw-r--r--spec/features/admin/admin_users_spec.rb346
-rw-r--r--spec/features/admin/admin_uses_repository_checks_spec.rb24
-rw-r--r--spec/features/admin/dashboard_spec.rb14
-rw-r--r--spec/features/admin/services/admin_activates_prometheus_spec.rb16
-rw-r--r--spec/features/atom/dashboard_issues_spec.rb50
-rw-r--r--spec/features/atom/dashboard_spec.rb12
-rw-r--r--spec/features/atom/issues_spec.rb84
-rw-r--r--spec/features/atom/users_spec.rb48
-rw-r--r--spec/features/boards/add_issues_modal_spec.rb228
-rw-r--r--spec/features/boards/boards_spec.rb390
-rw-r--r--spec/features/boards/issue_ordering_spec.rb98
-rw-r--r--spec/features/boards/keyboard_shortcut_spec.rb18
-rw-r--r--spec/features/boards/modal_filter_spec.rb142
-rw-r--r--spec/features/boards/new_issue_spec.rb102
-rw-r--r--spec/features/boards/reload_boards_on_browser_back_spec.rb24
-rw-r--r--spec/features/boards/sidebar_spec.rb228
-rw-r--r--spec/features/boards/sub_group_project_spec.rb26
-rw-r--r--spec/features/calendar_spec.rb106
-rw-r--r--spec/features/clusters/cluster_detail_page_spec.rb42
-rw-r--r--spec/features/commits/user_uses_quick_actions_spec.rb22
-rw-r--r--spec/features/commits_spec.rb123
-rw-r--r--spec/features/container_registry_spec.rb26
-rw-r--r--spec/features/cycle_analytics_spec.rb98
-rw-r--r--spec/features/dashboard/active_tab_spec.rb28
-rw-r--r--spec/features/dashboard/activity_spec.rb134
-rw-r--r--spec/features/dashboard/archived_projects_spec.rb24
-rw-r--r--spec/features/dashboard/datetime_on_tooltips_spec.rb28
-rw-r--r--spec/features/dashboard/group_spec.rb22
-rw-r--r--spec/features/dashboard/groups_list_spec.rb42
-rw-r--r--spec/features/dashboard/help_spec.rb16
-rw-r--r--spec/features/dashboard/instance_statistics_spec.rb30
-rw-r--r--spec/features/dashboard/issuables_counter_spec.rb20
-rw-r--r--spec/features/dashboard/issues_filter_spec.rb56
-rw-r--r--spec/features/dashboard/issues_spec.rb40
-rw-r--r--spec/features/dashboard/label_filter_spec.rb22
-rw-r--r--spec/features/dashboard/merge_requests_spec.rb64
-rw-r--r--spec/features/dashboard/milestone_tabs_spec.rb22
-rw-r--r--spec/features/dashboard/milestones_spec.rb12
-rw-r--r--spec/features/dashboard/project_member_activity_index_spec.rb24
-rw-r--r--spec/features/dashboard/projects_spec.rb116
-rw-r--r--spec/features/dashboard/root_explore_spec.rb12
-rw-r--r--spec/features/dashboard/shortcuts_spec.rb48
-rw-r--r--spec/features/dashboard/snippets_spec.rb42
-rw-r--r--spec/features/dashboard/todos/target_state_spec.rb36
-rw-r--r--spec/features/dashboard/todos/todos_filtering_spec.rb102
-rw-r--r--spec/features/dashboard/todos/todos_sorting_spec.rb88
-rw-r--r--spec/features/dashboard/todos/todos_spec.rb214
-rw-r--r--spec/features/dashboard/user_filters_projects_spec.rb28
-rw-r--r--spec/features/discussion_comments/commit_spec.rb6
-rw-r--r--spec/features/discussion_comments/issue_spec.rb6
-rw-r--r--spec/features/discussion_comments/merge_request_spec.rb6
-rw-r--r--spec/features/discussion_comments/snippets_spec.rb6
-rw-r--r--spec/features/display_system_header_and_footer_bar_spec.rb88
-rw-r--r--spec/features/error_pages_spec.rb26
-rw-r--r--spec/features/expand_collapse_diffs_spec.rb272
-rw-r--r--spec/features/explore/groups_list_spec.rb44
-rw-r--r--spec/features/explore/groups_spec.rb30
-rw-r--r--spec/features/explore/user_explores_projects_spec.rb24
-rw-r--r--spec/features/global_search_spec.rb10
-rw-r--r--spec/features/group_variables_spec.rb8
-rw-r--r--spec/features/groups/activity_spec.rb18
-rw-r--r--spec/features/groups/board_sidebar_spec.rb24
-rw-r--r--spec/features/groups/board_spec.rb24
-rw-r--r--spec/features/groups/clusters/user_spec.rb98
-rw-r--r--spec/features/groups/empty_states_spec.rb60
-rw-r--r--spec/features/groups/group_settings_spec.rb74
-rw-r--r--spec/features/groups/issues_spec.rb58
-rw-r--r--spec/features/groups/labels/create_spec.rb14
-rw-r--r--spec/features/groups/labels/edit_spec.rb12
-rw-r--r--spec/features/groups/labels/index_spec.rb14
-rw-r--r--spec/features/groups/labels/search_labels_spec.rb28
-rw-r--r--spec/features/groups/labels/sort_labels_spec.rb44
-rw-r--r--spec/features/groups/labels/subscription_spec.rb60
-rw-r--r--spec/features/groups/labels/user_sees_links_to_issuables.rb12
-rw-r--r--spec/features/groups/members/filter_members_spec.rb22
-rw-r--r--spec/features/groups/members/leave_group_spec.rb22
-rw-r--r--spec/features/groups/members/list_members_spec.rb16
-rw-r--r--spec/features/groups/members/manage_members_spec.rb64
-rw-r--r--spec/features/groups/members/master_manages_access_requests_spec.rb6
-rw-r--r--spec/features/groups/members/request_access_spec.rb46
-rw-r--r--spec/features/groups/members/search_members_spec.rb12
-rw-r--r--spec/features/groups/members/sort_members_spec.rb48
-rw-r--r--spec/features/groups/merge_requests_spec.rb48
-rw-r--r--spec/features/groups/milestone_spec.rb154
-rw-r--r--spec/features/groups/milestones_sorting_spec.rb56
-rw-r--r--spec/features/groups/settings/ci_cd_spec.rb18
-rw-r--r--spec/features/groups/settings/group_badges_spec.rb90
-rw-r--r--spec/features/groups/share_lock_spec.rb32
-rw-r--r--spec/features/groups/show_spec.rb52
-rw-r--r--spec/features/groups/user_browse_projects_group_page_spec.rb14
-rw-r--r--spec/features/groups/user_sees_users_dropdowns_in_issuables_list_spec.rb8
-rw-r--r--spec/features/groups_spec.rb168
-rw-r--r--spec/features/help_pages_spec.rb62
-rw-r--r--spec/features/ics/dashboard_issues_spec.rb100
-rw-r--r--spec/features/ics/group_issues_spec.rb58
-rw-r--r--spec/features/ics/project_issues_spec.rb68
-rw-r--r--spec/features/ide_spec.rb12
-rw-r--r--spec/features/import/manifest_import_spec.rb34
-rw-r--r--spec/features/instance_statistics/cohorts_spec.rb8
-rw-r--r--spec/features/instance_statistics/conversational_development_index_spec.rb34
-rw-r--r--spec/features/instance_statistics/instance_statistics.rb12
-rw-r--r--spec/features/invites_spec.rb92
-rw-r--r--spec/features/issuables/close_reopen_report_toggle_spec.rb118
-rw-r--r--spec/features/issuables/discussion_lock_spec.rb84
-rw-r--r--spec/features/issuables/issuable_list_spec.rb38
-rw-r--r--spec/features/issuables/markdown_references/internal_references_spec.rb4
-rw-r--r--spec/features/issuables/markdown_references/jira_spec.rb2
-rw-r--r--spec/features/issuables/shortcuts_issuable_spec.rb20
-rw-r--r--spec/features/issuables/sorting_list_spec.rb103
-rw-r--r--spec/features/issuables/user_sees_sidebar_spec.rb8
-rw-r--r--spec/features/issues/bulk_assignment_labels_spec.rb286
-rw-r--r--spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb52
-rw-r--r--spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb38
-rw-r--r--spec/features/issues/filtered_search/dropdown_assignee_spec.rb140
-rw-r--r--spec/features/issues/filtered_search/dropdown_author_spec.rb126
-rw-r--r--spec/features/issues/filtered_search/dropdown_emoji_spec.rb142
-rw-r--r--spec/features/issues/filtered_search/dropdown_hint_spec.rb196
-rw-r--r--spec/features/issues/filtered_search/dropdown_label_spec.rb198
-rw-r--r--spec/features/issues/filtered_search/dropdown_milestone_spec.rb172
-rw-r--r--spec/features/issues/filtered_search/filter_issues_spec.rb226
-rw-r--r--spec/features/issues/filtered_search/recent_searches_spec.rb84
-rw-r--r--spec/features/issues/filtered_search/search_bar_spec.rb82
-rw-r--r--spec/features/issues/filtered_search/visual_tokens_spec.rb304
-rw-r--r--spec/features/issues/form_spec.rb212
-rw-r--r--spec/features/issues/gfm_autocomplete_spec.rb292
-rw-r--r--spec/features/issues/group_label_sidebar_spec.rb10
-rw-r--r--spec/features/issues/issue_detail_spec.rb38
-rw-r--r--spec/features/issues/issue_sidebar_spec.rb148
-rw-r--r--spec/features/issues/keyboard_shortcut_spec.rb20
-rw-r--r--spec/features/issues/markdown_toolbar_spec.rb28
-rw-r--r--spec/features/issues/move_spec.rb44
-rw-r--r--spec/features/issues/note_polling_spec.rb32
-rw-r--r--spec/features/issues/notes_on_issues_spec.rb52
-rw-r--r--spec/features/issues/resource_label_events_spec.rb38
-rw-r--r--spec/features/issues/rss_spec.rb8
-rw-r--r--spec/features/issues/spam_issues_spec.rb48
-rw-r--r--spec/features/issues/todo_spec.rb32
-rw-r--r--spec/features/issues/update_issues_spec.rb88
-rw-r--r--spec/features/issues/user_comments_on_issue_spec.rb12
-rw-r--r--spec/features/issues/user_creates_branch_and_merge_request_spec.rb136
-rw-r--r--spec/features/issues/user_creates_issue_spec.rb16
-rw-r--r--spec/features/issues/user_interacts_with_awards_spec.rb220
-rw-r--r--spec/features/issues/user_sees_breadcrumb_links_spec.rb12
-rw-r--r--spec/features/issues/user_sorts_issues_spec.rb18
-rw-r--r--spec/features/issues/user_uses_quick_actions_spec.rb168
-rw-r--r--spec/features/issues/user_views_issue_spec.rb28
-rw-r--r--spec/features/issues_spec.rb525
-rw-r--r--spec/features/labels_hierarchy_spec.rb184
-rw-r--r--spec/features/markdown/copy_as_gfm_spec.rb288
-rw-r--r--spec/features/markdown/gitlab_flavored_markdown_spec.rb28
-rw-r--r--spec/features/markdown/markdown_spec.rb186
-rw-r--r--spec/features/markdown/math_spec.rb16
-rw-r--r--spec/features/markdown/mermaid_spec.rb8
-rw-r--r--spec/features/merge_request/maintainer_edits_fork_spec.rb38
-rw-r--r--spec/features/merge_request/user_accepts_merge_request_spec.rb58
-rw-r--r--spec/features/merge_request/user_allows_commits_from_memebers_who_can_merge_spec.rb47
-rw-r--r--spec/features/merge_request/user_assigns_themselves_spec.rb28
-rw-r--r--spec/features/merge_request/user_awards_emoji_spec.rb54
-rw-r--r--spec/features/merge_request/user_closes_merge_request_spec.rb10
-rw-r--r--spec/features/merge_request/user_comments_on_commit_spec.rb6
-rw-r--r--spec/features/merge_request/user_comments_on_diff_spec.rb144
-rw-r--r--spec/features/merge_request/user_comments_on_merge_request_spec.rb30
-rw-r--r--spec/features/merge_request/user_creates_image_diff_notes_spec.rb134
-rw-r--r--spec/features/merge_request/user_creates_merge_request_spec.rb4
-rw-r--r--spec/features/merge_request/user_creates_mr_spec.rb31
-rw-r--r--spec/features/merge_request/user_customizes_merge_commit_message_spec.rb20
-rw-r--r--spec/features/merge_request/user_edits_merge_request_spec.rb12
-rw-r--r--spec/features/merge_request/user_edits_mr_spec.rb10
-rw-r--r--spec/features/merge_request/user_expands_diff_spec.rb14
-rw-r--r--spec/features/merge_request/user_locks_discussion_spec.rb30
-rw-r--r--spec/features/merge_request/user_manages_subscription_spec.rb18
-rw-r--r--spec/features/merge_request/user_merges_immediately_spec.rb22
-rw-r--r--spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb82
-rw-r--r--spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb90
-rw-r--r--spec/features/merge_request/user_posts_diff_notes_spec.rb180
-rw-r--r--spec/features/merge_request/user_posts_notes_spec.rb168
-rw-r--r--spec/features/merge_request/user_reopens_merge_request_spec.rb12
-rw-r--r--spec/features/merge_request/user_resolves_conflicts_spec.rb138
-rw-r--r--spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb478
-rw-r--r--spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb42
-rw-r--r--spec/features/merge_request/user_reverts_merge_request_spec.rb44
-rw-r--r--spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb18
-rw-r--r--spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb122
-rw-r--r--spec/features/merge_request/user_sees_breadcrumb_links_spec.rb12
-rw-r--r--spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb16
-rw-r--r--spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb36
-rw-r--r--spec/features/merge_request/user_sees_closing_issues_message_spec.rb32
-rw-r--r--spec/features/merge_request/user_sees_deleted_target_branch_spec.rb14
-rw-r--r--spec/features/merge_request/user_sees_deployment_widget_spec.rb66
-rw-r--r--spec/features/merge_request/user_sees_diff_spec.rb98
-rw-r--r--spec/features/merge_request/user_sees_discussions_spec.rb42
-rw-r--r--spec/features/merge_request/user_sees_empty_state_spec.rb22
-rw-r--r--spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb34
-rw-r--r--spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb258
-rw-r--r--spec/features/merge_request/user_sees_merge_widget_spec.rb309
-rw-r--r--spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb96
-rw-r--r--spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb10
-rw-r--r--spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb26
-rw-r--r--spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb22
-rw-r--r--spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb22
-rw-r--r--spec/features/merge_request/user_sees_pipelines_spec.rb60
-rw-r--r--spec/features/merge_request/user_sees_system_notes_spec.rb18
-rw-r--r--spec/features/merge_request/user_sees_versions_spec.rb186
-rw-r--r--spec/features/merge_request/user_sees_wip_help_message_spec.rb32
-rw-r--r--spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb143
-rw-r--r--spec/features/merge_request/user_suggests_changes_on_diff_spec.rb66
-rw-r--r--spec/features/merge_request/user_toggles_whitespace_changes_spec.rb16
-rw-r--r--spec/features/merge_request/user_tries_to_access_private_repository_through_new_mr_spec.rb20
-rw-r--r--spec/features/merge_request/user_uses_quick_actions_spec.rb120
-rw-r--r--spec/features/merge_request/user_views_diffs_spec.rb54
-rw-r--r--spec/features/merge_request/user_views_open_merge_request_spec.rb54
-rw-r--r--spec/features/merge_request/user_views_user_status_on_merge_request_spec.rb18
-rw-r--r--spec/features/merge_requests/filters_generic_behavior_spec.rb68
-rw-r--r--spec/features/merge_requests/user_filters_by_assignees_spec.rb26
-rw-r--r--spec/features/merge_requests/user_filters_by_labels_spec.rb40
-rw-r--r--spec/features/merge_requests/user_filters_by_milestones_spec.rb38
-rw-r--r--spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb20
-rw-r--r--spec/features/merge_requests/user_lists_merge_requests_spec.rb94
-rw-r--r--spec/features/merge_requests/user_mass_updates_spec.rb82
-rw-r--r--spec/features/merge_requests/user_sorts_merge_requests_spec.rb56
-rw-r--r--spec/features/merge_requests/user_squashes_merge_request_spec.rb78
-rw-r--r--spec/features/merge_requests/user_views_all_merge_requests_spec.rb6
-rw-r--r--spec/features/merge_requests/user_views_closed_merge_requests_spec.rb6
-rw-r--r--spec/features/merge_requests/user_views_merged_merge_requests_spec.rb6
-rw-r--r--spec/features/merge_requests/user_views_open_merge_requests_spec.rb60
-rw-r--r--spec/features/milestone_spec.rb68
-rw-r--r--spec/features/milestones/user_promotes_milestone_spec.rb12
-rw-r--r--spec/features/milestones/user_sees_breadcrumb_links_spec.rb12
-rw-r--r--spec/features/milestones/user_views_milestone_spec.rb2
-rw-r--r--spec/features/oauth_login_spec.rb38
-rw-r--r--spec/features/participants_autocomplete_spec.rb28
-rw-r--r--spec/features/password_reset_spec.rb36
-rw-r--r--spec/features/profile_spec.rb76
-rw-r--r--spec/features/profiles/account_spec.rb34
-rw-r--r--spec/features/profiles/active_sessions_spec.rb42
-rw-r--r--spec/features/profiles/chat_names_spec.rb40
-rw-r--r--spec/features/profiles/emails_spec.rb46
-rw-r--r--spec/features/profiles/gpg_keys_spec.rb44
-rw-r--r--spec/features/profiles/keys_spec.rb60
-rw-r--r--spec/features/profiles/oauth_applications_spec.rb38
-rw-r--r--spec/features/profiles/password_spec.rb94
-rw-r--r--spec/features/profiles/personal_access_tokens_spec.rb18
-rw-r--r--spec/features/profiles/user_changes_notified_of_own_activity_spec.rb24
-rw-r--r--spec/features/profiles/user_edit_profile_spec.rb216
-rw-r--r--spec/features/profiles/user_manages_applications_spec.rb40
-rw-r--r--spec/features/profiles/user_manages_emails_spec.rb36
-rw-r--r--spec/features/profiles/user_visits_notifications_tab_spec.rb14
-rw-r--r--spec/features/profiles/user_visits_profile_account_page_spec.rb8
-rw-r--r--spec/features/profiles/user_visits_profile_authentication_log_spec.rb16
-rw-r--r--spec/features/profiles/user_visits_profile_preferences_page_spec.rb56
-rw-r--r--spec/features/profiles/user_visits_profile_spec.rb16
-rw-r--r--spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb8
-rw-r--r--spec/features/project_variables_spec.rb8
-rw-r--r--spec/features/projects/activity/rss_spec.rb8
-rw-r--r--spec/features/projects/activity/user_sees_activity_spec.rb18
-rw-r--r--spec/features/projects/activity/user_sees_private_activity_spec.rb10
-rw-r--r--spec/features/projects/actve_tabs_spec.rb82
-rw-r--r--spec/features/projects/artifacts/file_spec.rb38
-rw-r--r--spec/features/projects/artifacts/raw_spec.rb10
-rw-r--r--spec/features/projects/artifacts/user_browses_artifacts_spec.rb8
-rw-r--r--spec/features/projects/artifacts/user_downloads_artifacts_spec.rb6
-rw-r--r--spec/features/projects/badges/coverage_spec.rb44
-rw-r--r--spec/features/projects/badges/list_spec.rb52
-rw-r--r--spec/features/projects/badges/pipeline_badge_spec.rb40
-rw-r--r--spec/features/projects/blobs/blob_line_permalink_updater_spec.rb50
-rw-r--r--spec/features/projects/blobs/blob_show_spec.rb340
-rw-r--r--spec/features/projects/blobs/edit_spec.rb80
-rw-r--r--spec/features/projects/blobs/shortcuts_blob_spec.rb16
-rw-r--r--spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb32
-rw-r--r--spec/features/projects/branches/download_buttons_spec.rb30
-rw-r--r--spec/features/projects/branches/new_branch_ref_dropdown_spec.rb28
-rw-r--r--spec/features/projects/branches/user_views_branches_spec.rb2
-rw-r--r--spec/features/projects/branches_spec.rb204
-rw-r--r--spec/features/projects/ci/lint_spec.rb58
-rw-r--r--spec/features/projects/clusters/applications_spec.rb136
-rw-r--r--spec/features/projects/clusters/gcp_spec.rb152
-rw-r--r--spec/features/projects/clusters/interchangeability_spec.rb8
-rw-r--r--spec/features/projects/clusters/user_spec.rb88
-rw-r--r--spec/features/projects/clusters_spec.rb38
-rw-r--r--spec/features/projects/commit/builds_spec.rb12
-rw-r--r--spec/features/projects/commit/cherry_pick_spec.rb68
-rw-r--r--spec/features/projects/commit/comments/user_adds_comment_spec.rb14
-rw-r--r--spec/features/projects/commit/diff_notes_spec.rb18
-rw-r--r--spec/features/projects/commit/mini_pipeline_graph_spec.rb32
-rw-r--r--spec/features/projects/commit/user_reverts_commit_spec.rb48
-rw-r--r--spec/features/projects/commit/user_views_user_status_on_commit_spec.rb16
-rw-r--r--spec/features/projects/commits/rss_spec.rb8
-rw-r--r--spec/features/projects/commits/user_browses_commits_spec.rb174
-rw-r--r--spec/features/projects/compare_spec.rb50
-rw-r--r--spec/features/projects/deploy_keys_spec.rb16
-rw-r--r--spec/features/projects/diffs/diff_show_spec.rb122
-rw-r--r--spec/features/projects/environments/environment_metrics_spec.rb12
-rw-r--r--spec/features/projects/environments/environment_spec.rb180
-rw-r--r--spec/features/projects/environments/environments_spec.rb314
-rw-r--r--spec/features/projects/features_visibility_spec.rb80
-rw-r--r--spec/features/projects/files/dockerfile_dropdown_spec.rb22
-rw-r--r--spec/features/projects/files/download_buttons_spec.rb24
-rw-r--r--spec/features/projects/files/edit_file_soft_wrap_spec.rb18
-rw-r--r--spec/features/projects/files/editing_a_file_spec.rb14
-rw-r--r--spec/features/projects/files/files_sort_submodules_with_folders_spec.rb12
-rw-r--r--spec/features/projects/files/find_file_keyboard_spec.rb30
-rw-r--r--spec/features/projects/files/gitignore_dropdown_spec.rb24
-rw-r--r--spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb24
-rw-r--r--spec/features/projects/files/project_owner_creates_license_file_spec.rb63
-rw-r--r--spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb36
-rw-r--r--spec/features/projects/files/template_selector_menu_spec.rb36
-rw-r--r--spec/features/projects/files/template_type_dropdown_spec.rb78
-rw-r--r--spec/features/projects/files/undo_template_spec.rb38
-rw-r--r--spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb10
-rw-r--r--spec/features/projects/files/user_browses_files_spec.rb34
-rw-r--r--spec/features/projects/files/user_browses_lfs_files_spec.rb66
-rw-r--r--spec/features/projects/files/user_creates_directory_spec.rb80
-rw-r--r--spec/features/projects/files/user_creates_files_spec.rb160
-rw-r--r--spec/features/projects/files/user_deletes_files_spec.rb50
-rw-r--r--spec/features/projects/files/user_edits_files_spec.rb164
-rw-r--r--spec/features/projects/files/user_find_file_spec.rb62
-rw-r--r--spec/features/projects/files/user_reads_pipeline_status_spec.rb22
-rw-r--r--spec/features/projects/files/user_replaces_files_spec.rb66
-rw-r--r--spec/features/projects/files/user_searches_for_files_spec.rb32
-rw-r--r--spec/features/projects/files/user_uploads_files_spec.rb84
-rw-r--r--spec/features/projects/fork_spec.rb94
-rw-r--r--spec/features/projects/gfm_autocomplete_load_spec.rb12
-rw-r--r--spec/features/projects/graph_spec.rb72
-rw-r--r--spec/features/projects/hook_logs/user_reads_log_spec.rb14
-rw-r--r--spec/features/projects/import_export/export_file_spec.rb24
-rw-r--r--spec/features/projects/import_export/import_file_spec.rb58
-rw-r--r--spec/features/projects/issuable_templates_spec.rb107
-rw-r--r--spec/features/projects/jobs/permissions_spec.rb64
-rw-r--r--spec/features/projects/jobs/user_browses_job_spec.rb36
-rw-r--r--spec/features/projects/jobs/user_browses_jobs_spec.rb26
-rw-r--r--spec/features/projects/jobs_spec.rb583
-rw-r--r--spec/features/projects/labels/issues_sorted_by_priority_spec.rb74
-rw-r--r--spec/features/projects/labels/search_labels_spec.rb54
-rw-r--r--spec/features/projects/labels/sort_labels_spec.rb44
-rw-r--r--spec/features/projects/labels/subscription_spec.rb66
-rw-r--r--spec/features/projects/labels/update_prioritization_spec.rb138
-rw-r--r--spec/features/projects/labels/user_removes_labels_spec.rb4
-rw-r--r--spec/features/projects/labels/user_sees_breadcrumb_links_spec.rb10
-rw-r--r--spec/features/projects/labels/user_sees_links_to_issuables.rb60
-rw-r--r--spec/features/projects/labels/user_views_labels_spec.rb2
-rw-r--r--spec/features/projects/members/anonymous_user_sees_members_spec.rb7
-rw-r--r--spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb6
-rw-r--r--spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb24
-rw-r--r--spec/features/projects/members/group_members_spec.rb44
-rw-r--r--spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb12
-rw-r--r--spec/features/projects/members/groups_with_access_list_spec.rb50
-rw-r--r--spec/features/projects/members/invite_group_spec.rb90
-rw-r--r--spec/features/projects/members/list_spec.rb40
-rw-r--r--spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb26
-rw-r--r--spec/features/projects/members/master_manages_access_requests_spec.rb6
-rw-r--r--spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb8
-rw-r--r--spec/features/projects/members/member_leaves_project_spec.rb8
-rw-r--r--spec/features/projects/members/owner_cannot_leave_project_spec.rb6
-rw-r--r--spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb8
-rw-r--r--spec/features/projects/members/sorting_spec.rb48
-rw-r--r--spec/features/projects/members/user_requests_access_spec.rb50
-rw-r--r--spec/features/projects/merge_request_button_spec.rb74
-rw-r--r--spec/features/projects/milestones/milestone_spec.rb74
-rw-r--r--spec/features/projects/milestones/milestones_sorting_spec.rb46
-rw-r--r--spec/features/projects/milestones/new_spec.rb14
-rw-r--r--spec/features/projects/milestones/user_interacts_with_labels_spec.rb26
-rw-r--r--spec/features/projects/network_graph_spec.rb82
-rw-r--r--spec/features/projects/new_project_spec.rb162
-rw-r--r--spec/features/projects/pages_spec.rb230
-rw-r--r--spec/features/projects/pipeline_schedules_spec.rb222
-rw-r--r--spec/features/projects/pipelines/pipeline_spec.rb558
-rw-r--r--spec/features/projects/pipelines/pipelines_spec.rb498
-rw-r--r--spec/features/projects/releases/user_views_releases_spec.rb28
-rw-r--r--spec/features/projects/remote_mirror_spec.rb26
-rw-r--r--spec/features/projects/serverless/functions_spec.rb26
-rw-r--r--spec/features/projects/services/disable_triggers_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_asana_spec.rb18
-rw-r--r--spec/features/projects/services/user_activates_assembla_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb26
-rw-r--r--spec/features/projects/services/user_activates_emails_on_push_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_flowdock_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_irker_spec.rb18
-rw-r--r--spec/features/projects/services/user_activates_issue_tracker_spec.rb62
-rw-r--r--spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb22
-rw-r--r--spec/features/projects/services/user_activates_jira_spec.rb90
-rw-r--r--spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb136
-rw-r--r--spec/features/projects/services/user_activates_packagist_spec.rb18
-rw-r--r--spec/features/projects/services/user_activates_pivotaltracker_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_prometheus_spec.rb16
-rw-r--r--spec/features/projects/services/user_activates_pushover_spec.rb24
-rw-r--r--spec/features/projects/services/user_activates_slack_notifications_spec.rb39
-rw-r--r--spec/features/projects/services/user_activates_slack_slash_command_spec.rb36
-rw-r--r--spec/features/projects/services/user_activates_youtrack_spec.rb52
-rw-r--r--spec/features/projects/services/user_views_services_spec.rb28
-rw-r--r--spec/features/projects/settings/forked_project_settings_spec.rb22
-rw-r--r--spec/features/projects/settings/integration_settings_spec.rb104
-rw-r--r--spec/features/projects/settings/lfs_settings_spec.rb12
-rw-r--r--spec/features/projects/settings/operations_settings_spec.rb8
-rw-r--r--spec/features/projects/settings/pipelines_settings_spec.rb92
-rw-r--r--spec/features/projects/settings/project_badges_spec.rb90
-rw-r--r--spec/features/projects/settings/repository_settings_spec.rb154
-rw-r--r--spec/features/projects/settings/user_archives_project_spec.rb24
-rw-r--r--spec/features/projects/settings/user_changes_avatar_spec.rb20
-rw-r--r--spec/features/projects/settings/user_changes_default_branch_spec.rb22
-rw-r--r--spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb2
-rw-r--r--spec/features/projects/settings/user_manages_group_links_spec.rb30
-rw-r--r--spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb82
-rw-r--r--spec/features/projects/settings/user_manages_project_members_spec.rb36
-rw-r--r--spec/features/projects/settings/user_renames_a_project_spec.rb78
-rw-r--r--spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb16
-rw-r--r--spec/features/projects/settings/user_tags_project_spec.rb14
-rw-r--r--spec/features/projects/settings/user_transfers_a_project_spec.rb34
-rw-r--r--spec/features/projects/settings/visibility_settings_spec.rb58
-rw-r--r--spec/features/projects/show/developer_views_empty_project_instructions_spec.rb4
-rw-r--r--spec/features/projects/show/download_buttons_spec.rb36
-rw-r--r--spec/features/projects/show/no_password_spec.rb36
-rw-r--r--spec/features/projects/show/redirects_spec.rb38
-rw-r--r--spec/features/projects/show/rss_spec.rb8
-rw-r--r--spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb34
-rw-r--r--spec/features/projects/show/user_interacts_with_stars_spec.rb24
-rw-r--r--spec/features/projects/show/user_manages_notifications_spec.rb20
-rw-r--r--spec/features/projects/show/user_sees_collaboration_links_spec.rb60
-rw-r--r--spec/features/projects/show/user_sees_deletion_failure_message_spec.rb8
-rw-r--r--spec/features/projects/show/user_sees_git_instructions_spec.rb90
-rw-r--r--spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb12
-rw-r--r--spec/features/projects/show/user_sees_readme_spec.rb10
-rw-r--r--spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb212
-rw-r--r--spec/features/projects/snippets/create_snippet_spec.rb68
-rw-r--r--spec/features/projects/snippets/show_spec.rb70
-rw-r--r--spec/features/projects/snippets/user_comments_on_snippet_spec.rb28
-rw-r--r--spec/features/projects/snippets/user_deletes_snippet_spec.rb8
-rw-r--r--spec/features/projects/snippets/user_updates_snippet_spec.rb16
-rw-r--r--spec/features/projects/snippets/user_views_snippets_spec.rb10
-rw-r--r--spec/features/projects/sub_group_issuables_spec.rb18
-rw-r--r--spec/features/projects/tags/download_buttons_spec.rb30
-rw-r--r--spec/features/projects/tags/user_edits_tags_spec.rb58
-rw-r--r--spec/features/projects/tags/user_views_tags_spec.rb35
-rw-r--r--spec/features/projects/tree/create_directory_spec.rb40
-rw-r--r--spec/features/projects/tree/create_file_spec.rb30
-rw-r--r--spec/features/projects/tree/rss_spec.rb8
-rw-r--r--spec/features/projects/tree/tree_show_spec.rb88
-rw-r--r--spec/features/projects/tree/upload_file_spec.rb20
-rw-r--r--spec/features/projects/user_creates_project_spec.rb32
-rw-r--r--spec/features/projects/user_sees_sidebar_spec.rb76
-rw-r--r--spec/features/projects/user_uses_shortcuts_spec.rb170
-rw-r--r--spec/features/projects/user_views_empty_project_spec.rb24
-rw-r--r--spec/features/projects/view_on_env_spec.rb48
-rw-r--r--spec/features/projects/wiki/markdown_preview_spec.rb92
-rw-r--r--spec/features/projects/wiki/shortcuts_spec.rb10
-rw-r--r--spec/features/projects/wiki/user_creates_wiki_page_spec.rb56
-rw-r--r--spec/features/projects/wiki/user_deletes_wiki_page_spec.rb14
-rw-r--r--spec/features/projects/wiki/user_git_access_wiki_page_spec.rb10
-rw-r--r--spec/features/projects/wiki/user_updates_wiki_page_spec.rb162
-rw-r--r--spec/features/projects/wiki/user_views_wiki_empty_spec.rb42
-rw-r--r--spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb24
-rw-r--r--spec/features/projects/wiki/user_views_wiki_page_spec.rb118
-rw-r--r--spec/features/projects_spec.rb214
-rw-r--r--spec/features/protected_branches_spec.rb90
-rw-r--r--spec/features/protected_tags_spec.rb40
-rw-r--r--spec/features/raven_js_spec.rb14
-rw-r--r--spec/features/read_only_spec.rb12
-rw-r--r--spec/features/reportable_note/commit_spec.rb12
-rw-r--r--spec/features/reportable_note/issue_spec.rb6
-rw-r--r--spec/features/reportable_note/merge_request_spec.rb12
-rw-r--r--spec/features/reportable_note/snippets_spec.rb8
-rw-r--r--spec/features/runners_spec.rb238
-rw-r--r--spec/features/search/user_searches_for_code_spec.rb48
-rw-r--r--spec/features/search/user_searches_for_comments_spec.rb40
-rw-r--r--spec/features/search/user_searches_for_commits_spec.rb42
-rw-r--r--spec/features/search/user_searches_for_issues_spec.rb64
-rw-r--r--spec/features/search/user_searches_for_merge_requests_spec.rb44
-rw-r--r--spec/features/search/user_searches_for_milestones_spec.rb44
-rw-r--r--spec/features/search/user_searches_for_projects_spec.rb32
-rw-r--r--spec/features/search/user_searches_for_wiki_pages_spec.rb26
-rw-r--r--spec/features/search/user_uses_header_search_field_spec.rb94
-rw-r--r--spec/features/search/user_uses_search_filters_spec.rb28
-rw-r--r--spec/features/security/admin_access_spec.rb2
-rw-r--r--spec/features/security/dashboard_access_spec.rb2
-rw-r--r--spec/features/security/group/internal_access_spec.rb16
-rw-r--r--spec/features/security/group/private_access_spec.rb16
-rw-r--r--spec/features/security/group/public_access_spec.rb16
-rw-r--r--spec/features/security/profile_access_spec.rb2
-rw-r--r--spec/features/security/project/internal_access_spec.rb14
-rw-r--r--spec/features/security/project/private_access_spec.rb30
-rw-r--r--spec/features/security/project/public_access_spec.rb14
-rw-r--r--spec/features/security/project/snippet/internal_access_spec.rb2
-rw-r--r--spec/features/security/project/snippet/private_access_spec.rb2
-rw-r--r--spec/features/security/project/snippet/public_access_spec.rb2
-rw-r--r--spec/features/signed_commits_spec.rb86
-rw-r--r--spec/features/snippets/embedded_snippet_spec.rb16
-rw-r--r--spec/features/snippets/explore_spec.rb10
-rw-r--r--spec/features/snippets/internal_snippet_spec.rb10
-rw-r--r--spec/features/snippets/notes_on_personal_snippets_spec.rb92
-rw-r--r--spec/features/snippets/public_snippets_spec.rb8
-rw-r--r--spec/features/snippets/search_snippets_spec.rb54
-rw-r--r--spec/features/snippets/show_spec.rb78
-rw-r--r--spec/features/snippets/user_creates_snippet_spec.rb92
-rw-r--r--spec/features/snippets/user_deletes_snippet_spec.rb8
-rw-r--r--spec/features/snippets/user_edits_snippet_spec.rb36
-rw-r--r--spec/features/snippets/user_sees_breadcrumb_links.rb12
-rw-r--r--spec/features/snippets/user_snippets_spec.rb18
-rw-r--r--spec/features/snippets_spec.rb8
-rw-r--r--spec/features/tags/master_creates_tag_spec.rb86
-rw-r--r--spec/features/tags/master_deletes_tag_spec.rb40
-rw-r--r--spec/features/tags/master_updates_tag_spec.rb54
-rw-r--r--spec/features/tags/master_views_tags_spec.rb63
-rw-r--r--spec/features/task_lists_spec.rb144
-rw-r--r--spec/features/triggers_spec.rb112
-rw-r--r--spec/features/u2f_spec.rb108
-rw-r--r--spec/features/unsubscribe_links_spec.rb36
-rw-r--r--spec/features/uploads/user_uploads_avatar_to_group_spec.rb16
-rw-r--r--spec/features/uploads/user_uploads_avatar_to_profile_spec.rb26
-rw-r--r--spec/features/uploads/user_uploads_file_to_note_spec.rb60
-rw-r--r--spec/features/usage_stats_consent_spec.rb16
-rw-r--r--spec/features/user_can_display_performance_bar_spec.rb62
-rw-r--r--spec/features/user_sees_revert_modal_spec.rb18
-rw-r--r--spec/features/users/active_sessions_spec.rb26
-rw-r--r--spec/features/users/add_email_to_existing_account.rb10
-rw-r--r--spec/features/users/login_spec.rb341
-rw-r--r--spec/features/users/logout_spec.rb10
-rw-r--r--spec/features/users/overview_spec.rb126
-rw-r--r--spec/features/users/rss_spec.rb8
-rw-r--r--spec/features/users/show_spec.rb64
-rw-r--r--spec/features/users/signup_spec.rb144
-rw-r--r--spec/features/users/snippets_spec.rb26
-rw-r--r--spec/features/users/terms_spec.rb78
-rw-r--r--spec/features/users/user_browses_projects_on_user_page_spec.rb60
-rw-r--r--spec/finders/access_requests_finder_spec.rb42
-rw-r--r--spec/finders/admin/projects_finder_spec.rb76
-rw-r--r--spec/finders/admin/runners_finder_spec.rb66
-rw-r--r--spec/finders/applications_finder_spec.rb14
-rw-r--r--spec/finders/autocomplete/acts_as_taggable_on/tags_finder_spec.rb54
-rw-r--r--spec/finders/autocomplete/group_finder_spec.rb28
-rw-r--r--spec/finders/autocomplete/move_to_project_finder_spec.rb32
-rw-r--r--spec/finders/autocomplete/project_finder_spec.rb24
-rw-r--r--spec/finders/autocomplete/users_finder_spec.rb54
-rw-r--r--spec/finders/awarded_emoji_finder_spec.rb16
-rw-r--r--spec/finders/branches_finder_spec.rb74
-rw-r--r--spec/finders/cluster_ancestors_finder_spec.rb24
-rw-r--r--spec/finders/clusters_finder_spec.rb10
-rw-r--r--spec/finders/concerns/finder_methods_spec.rb30
-rw-r--r--spec/finders/concerns/finder_with_cross_project_access_spec.rb50
-rw-r--r--spec/finders/contributed_projects_finder_spec.rb10
-rw-r--r--spec/finders/environments_finder_spec.rb76
-rw-r--r--spec/finders/events_finder_spec.rb24
-rw-r--r--spec/finders/fork_projects_finder_spec.rb16
-rw-r--r--spec/finders/group_descendants_finder_spec.rb124
-rw-r--r--spec/finders/group_labels_finder_spec.rb26
-rw-r--r--spec/finders/group_members_finder_spec.rb10
-rw-r--r--spec/finders/group_projects_finder_spec.rb56
-rw-r--r--spec/finders/groups_finder_spec.rb88
-rw-r--r--spec/finders/issues_finder_spec.rb484
-rw-r--r--spec/finders/joined_groups_finder_spec.rb20
-rw-r--r--spec/finders/labels_finder_spec.rb112
-rw-r--r--spec/finders/license_template_finder_spec.rb24
-rw-r--r--spec/finders/members_finder_spec.rb8
-rw-r--r--spec/finders/merge_request_target_project_finder_spec.rb26
-rw-r--r--spec/finders/merge_requests_finder_spec.rb140
-rw-r--r--spec/finders/milestones_finder_spec.rb50
-rw-r--r--spec/finders/notes_finder_spec.rb120
-rw-r--r--spec/finders/pending_todos_finder_spec.rb20
-rw-r--r--spec/finders/personal_access_tokens_finder_spec.rb80
-rw-r--r--spec/finders/personal_projects_finder_spec.rb14
-rw-r--r--spec/finders/pipeline_schedules_finder_spec.rb20
-rw-r--r--spec/finders/pipelines_finder_spec.rb158
-rw-r--r--spec/finders/projects/serverless/functions_finder_spec.rb28
-rw-r--r--spec/finders/projects_finder_spec.rb100
-rw-r--r--spec/finders/releases_finder_spec.rb16
-rw-r--r--spec/finders/runner_jobs_finder_spec.rb14
-rw-r--r--spec/finders/snippets_finder_spec.rb26
-rw-r--r--spec/finders/tags_finder_spec.rb48
-rw-r--r--spec/finders/template_finder_spec.rb20
-rw-r--r--spec/finders/todos_finder_spec.rb62
-rw-r--r--spec/finders/user_finder_spec.rb94
-rw-r--r--spec/finders/user_recent_events_finder_spec.rb14
-rw-r--r--spec/finders/users_finder_spec.rb58
-rw-r--r--spec/finders/users_with_pending_todos_finder_spec.rb6
-rw-r--r--spec/graphql/features/authorization_spec.rb40
-rw-r--r--spec/graphql/gitlab_schema_spec.rb16
-rw-r--r--spec/graphql/mutations/concerns/mutations/resolves_project_spec.rb4
-rw-r--r--spec/graphql/mutations/merge_requests/set_wip_spec.rb20
-rw-r--r--spec/graphql/resolvers/base_resolver_spec.rb12
-rw-r--r--spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb24
-rw-r--r--spec/graphql/resolvers/issues_resolver_spec.rb54
-rw-r--r--spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb6
-rw-r--r--spec/graphql/resolvers/merge_requests_resolver_spec.rb26
-rw-r--r--spec/graphql/resolvers/project_pipelines_resolver_spec.rb6
-rw-r--r--spec/graphql/resolvers/project_resolver_spec.rb16
-rw-r--r--spec/graphql/types/ci/pipeline_type_spec.rb4
-rw-r--r--spec/graphql/types/issuable_state_enum_spec.rb8
-rw-r--r--spec/graphql/types/issue_state_enum_spec.rb8
-rw-r--r--spec/graphql/types/issue_type_spec.rb6
-rw-r--r--spec/graphql/types/merge_request_state_enum_spec.rb12
-rw-r--r--spec/graphql/types/merge_request_type_spec.rb12
-rw-r--r--spec/graphql/types/mutation_type_spec.rb4
-rw-r--r--spec/graphql/types/permission_types/base_permission_type_spec.rb26
-rw-r--r--spec/graphql/types/permission_types/issue_spec.rb4
-rw-r--r--spec/graphql/types/permission_types/merge_request_spec.rb4
-rw-r--r--spec/graphql/types/permission_types/merge_request_type_spec.rb2
-rw-r--r--spec/graphql/types/permission_types/project_spec.rb4
-rw-r--r--spec/graphql/types/project_type_spec.rb18
-rw-r--r--spec/graphql/types/query_type_spec.rb16
-rw-r--r--spec/graphql/types/time_type_spec.rb10
-rw-r--r--spec/helpers/appearances_helper_spec.rb40
-rw-r--r--spec/helpers/application_helper_spec.rb125
-rw-r--r--spec/helpers/application_settings_helper_spec.rb18
-rw-r--r--spec/helpers/auth_helper_spec.rb56
-rw-r--r--spec/helpers/auto_devops_helper_spec.rb28
-rw-r--r--spec/helpers/avatars_helper_spec.rb192
-rw-r--r--spec/helpers/award_emoji_helper_spec.rb24
-rw-r--r--spec/helpers/blame_helper_spec.rb36
-rw-r--r--spec/helpers/blob_helper_spec.rb114
-rw-r--r--spec/helpers/boards_helper_spec.rb26
-rw-r--r--spec/helpers/broadcast_messages_helper_spec.rb44
-rw-r--r--spec/helpers/button_helper_spec.rb134
-rw-r--r--spec/helpers/calendar_helper_spec.rb8
-rw-r--r--spec/helpers/ci_status_helper_spec.rb48
-rw-r--r--spec/helpers/commits_helper_spec.rb46
-rw-r--r--spec/helpers/components_helper_spec.rb16
-rw-r--r--spec/helpers/dashboard_helper_spec.rb8
-rw-r--r--spec/helpers/defer_script_tag_helper_spec.rb9
-rw-r--r--spec/helpers/diff_helper_spec.rb204
-rw-r--r--spec/helpers/emails_helper_spec.rb118
-rw-r--r--spec/helpers/events_helper_spec.rb60
-rw-r--r--spec/helpers/explore_helper_spec.rb6
-rw-r--r--spec/helpers/form_helper_spec.rb30
-rw-r--r--spec/helpers/git_helper_spec.rb8
-rw-r--r--spec/helpers/gitlab_routing_helper_spec.rb44
-rw-r--r--spec/helpers/graph_helper_spec.rb12
-rw-r--r--spec/helpers/groups_helper_spec.rb86
-rw-r--r--spec/helpers/hooks_helper_spec.rb10
-rw-r--r--spec/helpers/icons_helper_spec.rb182
-rw-r--r--spec/helpers/import_helper_spec.rb38
-rw-r--r--spec/helpers/instance_configuration_helper_spec.rb44
-rw-r--r--spec/helpers/issuables_helper_spec.rb80
-rw-r--r--spec/helpers/issues_helper_spec.rb46
-rw-r--r--spec/helpers/labels_helper_spec.rb172
-rw-r--r--spec/helpers/markup_helper_spec.rb240
-rw-r--r--spec/helpers/members_helper_spec.rb16
-rw-r--r--spec/helpers/merge_requests_helper_spec.rb26
-rw-r--r--spec/helpers/milestones_helper_spec.rb36
-rw-r--r--spec/helpers/milestones_routing_helper_spec.rb22
-rw-r--r--spec/helpers/namespaces_helper_spec.rb32
-rw-r--r--spec/helpers/nav_helper_spec.rb20
-rw-r--r--spec/helpers/notes_helper_spec.rb124
-rw-r--r--spec/helpers/notifications_helper_spec.rb18
-rw-r--r--spec/helpers/page_layout_helper_spec.rb74
-rw-r--r--spec/helpers/pagination_helper_spec.rb8
-rw-r--r--spec/helpers/preferences_helper_spec.rb78
-rw-r--r--spec/helpers/profiles_helper_spec.rb42
-rw-r--r--spec/helpers/projects/error_tracking_helper_spec.rb28
-rw-r--r--spec/helpers/projects_helper_spec.rb256
-rw-r--r--spec/helpers/rss_helper_spec.rb8
-rw-r--r--spec/helpers/runners_helper_spec.rb20
-rw-r--r--spec/helpers/search_helper_spec.rb70
-rw-r--r--spec/helpers/sidekiq_helper_spec.rb58
-rw-r--r--spec/helpers/snippets_helper_spec.rb22
-rw-r--r--spec/helpers/sorting_helper_spec.rb41
-rw-r--r--spec/helpers/submodule_helper_spec.rb182
-rw-r--r--spec/helpers/tab_helper_spec.rb54
-rw-r--r--spec/helpers/time_helper_spec.rb4
-rw-r--r--spec/helpers/todos_helper_spec.rb26
-rw-r--r--spec/helpers/tree_helper_spec.rb104
-rw-r--r--spec/helpers/user_callouts_helper_spec.rb18
-rw-r--r--spec/helpers/users_helper_spec.rb70
-rw-r--r--spec/helpers/version_check_helper_spec.rb20
-rw-r--r--spec/helpers/visibility_level_helper_spec.rb56
-rw-r--r--spec/helpers/wiki_helper_spec.rb20
-rw-r--r--spec/initializers/6_validations_spec.rb34
-rw-r--r--spec/initializers/active_record_locking_spec.rb22
-rw-r--r--spec/initializers/attr_encrypted_no_db_connection_spec.rb16
-rw-r--r--spec/initializers/direct_upload_support_spec.rb52
-rw-r--r--spec/initializers/doorkeeper_spec.rb38
-rw-r--r--spec/initializers/fog_google_https_private_urls_spec.rb12
-rw-r--r--spec/initializers/lograge_spec.rb14
-rw-r--r--spec/initializers/secret_token_spec.rb156
-rw-r--r--spec/initializers/settings_spec.rb70
-rw-r--r--spec/initializers/trusted_proxies_spec.rb62
-rw-r--r--spec/initializers/zz_metrics_spec.rb8
-rw-r--r--spec/javascripts/fixtures/abuse_reports.rb10
-rw-r--r--spec/javascripts/fixtures/admin_users.rb10
-rw-r--r--spec/javascripts/fixtures/application_settings.rb14
-rw-r--r--spec/javascripts/fixtures/autocomplete_sources.rb34
-rw-r--r--spec/javascripts/fixtures/balsamiq.rb16
-rw-r--r--spec/javascripts/fixtures/blob.rb16
-rw-r--r--spec/javascripts/fixtures/boards.rb14
-rw-r--r--spec/javascripts/fixtures/branches.rb14
-rw-r--r--spec/javascripts/fixtures/clusters.rb12
-rw-r--r--spec/javascripts/fixtures/commit.rb12
-rw-r--r--spec/javascripts/fixtures/deploy_keys.rb18
-rw-r--r--spec/javascripts/fixtures/groups.rb20
-rw-r--r--spec/javascripts/fixtures/issues.rb30
-rw-r--r--spec/javascripts/fixtures/jobs.rb32
-rw-r--r--spec/javascripts/fixtures/labels.rb38
-rw-r--r--spec/javascripts/fixtures/merge_requests.rb40
-rw-r--r--spec/javascripts/fixtures/merge_requests_diffs.rb25
-rw-r--r--spec/javascripts/fixtures/pdf.rb14
-rw-r--r--spec/javascripts/fixtures/pipeline_schedules.rb20
-rw-r--r--spec/javascripts/fixtures/pipelines.rb16
-rw-r--r--spec/javascripts/fixtures/projects.rb42
-rw-r--r--spec/javascripts/fixtures/prometheus_service.rb14
-rw-r--r--spec/javascripts/fixtures/raw.rb22
-rw-r--r--spec/javascripts/fixtures/search.rb8
-rw-r--r--spec/javascripts/fixtures/services.rb16
-rw-r--r--spec/javascripts/fixtures/sessions.rb10
-rw-r--r--spec/javascripts/fixtures/snippet.rb20
-rw-r--r--spec/javascripts/fixtures/static_fixtures.rb14
-rw-r--r--spec/javascripts/fixtures/todos.rb28
-rw-r--r--spec/javascripts/fixtures/u2f.rb20
-rw-r--r--spec/lib/after_commit_queue_spec.rb4
-rw-r--r--spec/lib/api/api_spec.rb16
-rw-r--r--spec/lib/api/helpers/custom_validators_spec.rb40
-rw-r--r--spec/lib/api/helpers/pagination_spec.rb252
-rw-r--r--spec/lib/api/helpers/related_resources_helpers_spec.rb38
-rw-r--r--spec/lib/api/helpers/version_spec.rb26
-rw-r--r--spec/lib/api/helpers_spec.rb102
-rw-r--r--spec/lib/backup/files_spec.rb28
-rw-r--r--spec/lib/backup/manager_spec.rb146
-rw-r--r--spec/lib/backup/repository_spec.rb48
-rw-r--r--spec/lib/banzai/color_parser_spec.rb84
-rw-r--r--spec/lib/banzai/commit_renderer_spec.rb6
-rw-r--r--spec/lib/banzai/cross_project_reference_spec.rb32
-rw-r--r--spec/lib/banzai/filter/absolute_link_filter_spec.rb50
-rw-r--r--spec/lib/banzai/filter/abstract_reference_filter_spec.rb48
-rw-r--r--spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb6
-rw-r--r--spec/lib/banzai/filter/autolink_filter_spec.rb160
-rw-r--r--spec/lib/banzai/filter/blockquote_fence_filter_spec.rb10
-rw-r--r--spec/lib/banzai/filter/color_filter_spec.rb34
-rw-r--r--spec/lib/banzai/filter/commit_range_reference_filter_spec.rb124
-rw-r--r--spec/lib/banzai/filter/commit_reference_filter_spec.rb122
-rw-r--r--spec/lib/banzai/filter/commit_trailers_filter_spec.rb48
-rw-r--r--spec/lib/banzai/filter/emoji_filter_spec.rb102
-rw-r--r--spec/lib/banzai/filter/external_issue_reference_filter_spec.rb54
-rw-r--r--spec/lib/banzai/filter/external_link_filter_spec.rb154
-rw-r--r--spec/lib/banzai/filter/footnote_filter_spec.rb10
-rw-r--r--spec/lib/banzai/filter/front_matter_filter_spec.rb30
-rw-r--r--spec/lib/banzai/filter/gollum_tags_filter_spec.rb94
-rw-r--r--spec/lib/banzai/filter/html_entity_filter_spec.rb6
-rw-r--r--spec/lib/banzai/filter/image_lazy_load_filter_spec.rb26
-rw-r--r--spec/lib/banzai/filter/image_link_filter_spec.rb22
-rw-r--r--spec/lib/banzai/filter/inline_diff_filter_spec.rb26
-rw-r--r--spec/lib/banzai/filter/issuable_state_filter_spec.rb120
-rw-r--r--spec/lib/banzai/filter/issue_reference_filter_spec.rb274
-rw-r--r--spec/lib/banzai/filter/label_reference_filter_spec.rb430
-rw-r--r--spec/lib/banzai/filter/markdown_filter_spec.rb52
-rw-r--r--spec/lib/banzai/filter/math_filter_spec.rb82
-rw-r--r--spec/lib/banzai/filter/merge_request_reference_filter_spec.rb140
-rw-r--r--spec/lib/banzai/filter/mermaid_filter_spec.rb8
-rw-r--r--spec/lib/banzai/filter/milestone_reference_filter_spec.rb276
-rw-r--r--spec/lib/banzai/filter/plantuml_filter_spec.rb8
-rw-r--r--spec/lib/banzai/filter/project_reference_filter_spec.rb44
-rw-r--r--spec/lib/banzai/filter/redactor_filter_spec.rb110
-rw-r--r--spec/lib/banzai/filter/reference_filter_spec.rb16
-rw-r--r--spec/lib/banzai/filter/relative_link_filter_spec.rb314
-rw-r--r--spec/lib/banzai/filter/sanitization_filter_spec.rb264
-rw-r--r--spec/lib/banzai/filter/snippet_reference_filter_spec.rb116
-rw-r--r--spec/lib/banzai/filter/spaced_link_filter_spec.rb82
-rw-r--r--spec/lib/banzai/filter/suggestion_filter_spec.rb14
-rw-r--r--spec/lib/banzai/filter/syntax_highlight_filter_spec.rb14
-rw-r--r--spec/lib/banzai/filter/table_of_contents_filter_spec.rb120
-rw-r--r--spec/lib/banzai/filter/user_reference_filter_spec.rb118
-rw-r--r--spec/lib/banzai/filter/video_link_filter_spec.rb32
-rw-r--r--spec/lib/banzai/filter/wiki_link_filter_spec.rb26
-rw-r--r--spec/lib/banzai/filter_array_spec.rb38
-rw-r--r--spec/lib/banzai/issuable_extractor_spec.rb12
-rw-r--r--spec/lib/banzai/object_renderer_spec.rb32
-rw-r--r--spec/lib/banzai/pipeline/description_pipeline_spec.rb16
-rw-r--r--spec/lib/banzai/pipeline/email_pipeline_spec.rb14
-rw-r--r--spec/lib/banzai/pipeline/emoji_pipeline_spec.rb14
-rw-r--r--spec/lib/banzai/pipeline/full_pipeline_spec.rb36
-rw-r--r--spec/lib/banzai/pipeline/gfm_pipeline_spec.rb66
-rw-r--r--spec/lib/banzai/pipeline/wiki_pipeline_spec.rb50
-rw-r--r--spec/lib/banzai/querying_spec.rb8
-rw-r--r--spec/lib/banzai/redactor_spec.rb88
-rw-r--r--spec/lib/banzai/reference_parser/base_parser_spec.rb150
-rw-r--r--spec/lib/banzai/reference_parser/commit_parser_spec.rb68
-rw-r--r--spec/lib/banzai/reference_parser/commit_range_parser_spec.rb80
-rw-r--r--spec/lib/banzai/reference_parser/external_issue_parser_spec.rb42
-rw-r--r--spec/lib/banzai/reference_parser/issue_parser_spec.rb78
-rw-r--r--spec/lib/banzai/reference_parser/label_parser_spec.rb24
-rw-r--r--spec/lib/banzai/reference_parser/merge_request_parser_spec.rb30
-rw-r--r--spec/lib/banzai/reference_parser/milestone_parser_spec.rb24
-rw-r--r--spec/lib/banzai/reference_parser/project_parser_spec.rb28
-rw-r--r--spec/lib/banzai/reference_parser/snippet_parser_spec.rb102
-rw-r--r--spec/lib/banzai/reference_parser/user_parser_spec.rb118
-rw-r--r--spec/lib/banzai/render_context_spec.rb22
-rw-r--r--spec/lib/banzai/renderer_spec.rb28
-rw-r--r--spec/lib/banzai/suggestions_parser_spec.rb8
-rw-r--r--spec/lib/bitbucket/collection_spec.rb4
-rw-r--r--spec/lib/bitbucket/connection_spec.rb18
-rw-r--r--spec/lib/bitbucket/page_spec.rb26
-rw-r--r--spec/lib/bitbucket/paginator_spec.rb14
-rw-r--r--spec/lib/bitbucket/representation/comment_spec.rb20
-rw-r--r--spec/lib/bitbucket/representation/issue_spec.rb48
-rw-r--r--spec/lib/bitbucket/representation/pull_request_comment_spec.rb30
-rw-r--r--spec/lib/bitbucket/representation/pull_request_spec.rb50
-rw-r--r--spec/lib/bitbucket/representation/repo_spec.rb52
-rw-r--r--spec/lib/bitbucket/representation/user_spec.rb10
-rw-r--r--spec/lib/bitbucket_server/client_spec.rb48
-rw-r--r--spec/lib/bitbucket_server/collection_spec.rb16
-rw-r--r--spec/lib/bitbucket_server/connection_spec.rb58
-rw-r--r--spec/lib/bitbucket_server/page_spec.rb26
-rw-r--r--spec/lib/bitbucket_server/paginator_spec.rb38
-rw-r--r--spec/lib/bitbucket_server/representation/activity_spec.rb16
-rw-r--r--spec/lib/bitbucket_server/representation/comment_spec.rb28
-rw-r--r--spec/lib/bitbucket_server/representation/pull_request_comment_spec.rb30
-rw-r--r--spec/lib/bitbucket_server/representation/pull_request_spec.rb68
-rw-r--r--spec/lib/bitbucket_server/representation/repo_spec.rb96
-rw-r--r--spec/lib/constraints/feature_constrainer_spec.rb8
-rw-r--r--spec/lib/constraints/group_url_constrainer_spec.rb48
-rw-r--r--spec/lib/constraints/project_url_constrainer_spec.rb28
-rw-r--r--spec/lib/constraints/user_url_constrainer_spec.rb30
-rw-r--r--spec/lib/container_registry/blob_spec.rb97
-rw-r--r--spec/lib/container_registry/client_spec.rb35
-rw-r--r--spec/lib/container_registry/path_spec.rb188
-rw-r--r--spec/lib/container_registry/registry_spec.rb14
-rw-r--r--spec/lib/container_registry/tag_spec.rb127
-rw-r--r--spec/lib/event_filter_spec.rb46
-rw-r--r--spec/lib/expand_variables_spec.rb94
-rw-r--r--spec/lib/extracts_path_spec.rb136
-rw-r--r--spec/lib/feature_spec.rb92
-rw-r--r--spec/lib/file_size_validator_spec.rb18
-rw-r--r--spec/lib/forever_spec.rb12
-rw-r--r--spec/lib/gitaly/server_spec.rb38
-rw-r--r--spec/lib/gitlab/access/branch_protection_spec.rb8
-rw-r--r--spec/lib/gitlab/action_rate_limiter_spec.rb8
-rw-r--r--spec/lib/gitlab/allowable_spec.rb12
-rw-r--r--spec/lib/gitlab/app_logger_spec.rb8
-rw-r--r--spec/lib/gitlab/asciidoc_spec.rb50
-rw-r--r--spec/lib/gitlab/auth/activity_spec.rb16
-rw-r--r--spec/lib/gitlab/auth/blocked_user_tracker_spec.rb16
-rw-r--r--spec/lib/gitlab/auth/ldap/access_spec.rb60
-rw-r--r--spec/lib/gitlab/auth/ldap/adapter_spec.rb67
-rw-r--r--spec/lib/gitlab/auth/ldap/auth_hash_spec.rb62
-rw-r--r--spec/lib/gitlab/auth/ldap/authentication_spec.rb20
-rw-r--r--spec/lib/gitlab/auth/ldap/config_spec.rb352
-rw-r--r--spec/lib/gitlab/auth/ldap/dn_spec.rb160
-rw-r--r--spec/lib/gitlab/auth/ldap/person_spec.rb130
-rw-r--r--spec/lib/gitlab/auth/ldap/user_spec.rb100
-rw-r--r--spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb48
-rw-r--r--spec/lib/gitlab/auth/o_auth/identity_linker_spec.rb24
-rw-r--r--spec/lib/gitlab/auth/o_auth/provider_spec.rb68
-rw-r--r--spec/lib/gitlab/auth/o_auth/user_spec.rb288
-rw-r--r--spec/lib/gitlab/auth/request_authenticator_spec.rb26
-rw-r--r--spec/lib/gitlab/auth/saml/auth_hash_spec.rb78
-rw-r--r--spec/lib/gitlab/auth/saml/identity_linker_spec.rb18
-rw-r--r--spec/lib/gitlab/auth/saml/user_spec.rb258
-rw-r--r--spec/lib/gitlab/auth/unique_ips_limiter_spec.rb46
-rw-r--r--spec/lib/gitlab/auth/user_access_denied_reason_spec.rb10
-rw-r--r--spec/lib/gitlab/auth/user_auth_finders_spec.rb162
-rw-r--r--spec/lib/gitlab/auth_spec.rb314
-rw-r--r--spec/lib/gitlab/background_migration/add_merge_request_diff_commits_count_spec.rb29
-rw-r--r--spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb28
-rw-r--r--spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb4
-rw-r--r--spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb4
-rw-r--r--spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb46
-rw-r--r--spec/lib/gitlab/background_migration/backfill_project_repositories_spec.rb68
-rw-r--r--spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb20
-rw-r--r--spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb16
-rw-r--r--spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb30
-rw-r--r--spec/lib/gitlab/background_migration/delete_diff_files_spec.rb26
-rw-r--r--spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb152
-rw-r--r--spec/lib/gitlab/background_migration/digest_column_spec.rb36
-rw-r--r--spec/lib/gitlab/background_migration/encrypt_columns_spec.rb54
-rw-r--r--spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb44
-rw-r--r--spec/lib/gitlab/background_migration/fix_cross_project_label_links_spec.rb58
-rw-r--r--spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb32
-rw-r--r--spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb204
-rw-r--r--spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb93
-rw-r--r--spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb14
-rw-r--r--spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb48
-rw-r--r--spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb12
-rw-r--r--spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb24
-rw-r--r--spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb10
-rw-r--r--spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb36
-rw-r--r--spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb26
-rw-r--r--spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb16
-rw-r--r--spec/lib/gitlab/background_migration/populate_import_state_spec.rb18
-rw-r--r--spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved_spec.rb20
-rw-r--r--spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb26
-rw-r--r--spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb18
-rw-r--r--spec/lib/gitlab/background_migration/populate_untracked_uploads_dependencies/untracked_file_spec.rb194
-rw-r--r--spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb176
-rw-r--r--spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb60
-rw-r--r--spec/lib/gitlab/background_migration/redact_links_spec.rb55
-rw-r--r--spec/lib/gitlab/background_migration/remove_restricted_todos_spec.rb54
-rw-r--r--spec/lib/gitlab/background_migration/rollback_import_state_data_spec.rb8
-rw-r--r--spec/lib/gitlab/background_migration/schedule_diff_files_deletion_spec.rb26
-rw-r--r--spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb10
-rw-r--r--spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb10
-rw-r--r--spec/lib/gitlab/background_migration_spec.rb122
-rw-r--r--spec/lib/gitlab/badge/coverage/metadata_spec.rb26
-rw-r--r--spec/lib/gitlab/badge/coverage/report_spec.rb66
-rw-r--r--spec/lib/gitlab/badge/coverage/template_spec.rb92
-rw-r--r--spec/lib/gitlab/badge/pipeline/metadata_spec.rb26
-rw-r--r--spec/lib/gitlab/badge/pipeline/status_spec.rb70
-rw-r--r--spec/lib/gitlab/badge/pipeline/template_spec.rb66
-rw-r--r--spec/lib/gitlab/badge/shared/metadata.rb22
-rw-r--r--spec/lib/gitlab/bare_repository_import/importer_spec.rb102
-rw-r--r--spec/lib/gitlab/bare_repository_import/repository_spec.rb88
-rw-r--r--spec/lib/gitlab/bitbucket_import/importer_spec.rb109
-rw-r--r--spec/lib/gitlab/bitbucket_import/project_creator_spec.rb18
-rw-r--r--spec/lib/gitlab/bitbucket_import/wiki_formatter_spec.rb20
-rw-r--r--spec/lib/gitlab/bitbucket_server_import/importer_spec.rb162
-rw-r--r--spec/lib/gitlab/blame_spec.rb14
-rw-r--r--spec/lib/gitlab/blob_helper_spec.rb94
-rw-r--r--spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb42
-rw-r--r--spec/lib/gitlab/build_access_spec.rb8
-rw-r--r--spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb106
-rw-r--r--spec/lib/gitlab/cache/request_cache_spec.rb48
-rw-r--r--spec/lib/gitlab/changes_list_spec.rb12
-rw-r--r--spec/lib/gitlab/chat/command_spec.rb38
-rw-r--r--spec/lib/gitlab/chat/output_spec.rb56
-rw-r--r--spec/lib/gitlab/chat/responder/base_spec.rb28
-rw-r--r--spec/lib/gitlab/chat/responder/slack_spec.rb40
-rw-r--r--spec/lib/gitlab/chat/responder_spec.rb12
-rw-r--r--spec/lib/gitlab/chat_name_token_spec.rb16
-rw-r--r--spec/lib/gitlab/chat_spec.rb8
-rw-r--r--spec/lib/gitlab/checks/branch_check_spec.rb66
-rw-r--r--spec/lib/gitlab/checks/change_access_spec.rb30
-rw-r--r--spec/lib/gitlab/checks/diff_check_spec.rb36
-rw-r--r--spec/lib/gitlab/checks/force_push_spec.rb12
-rw-r--r--spec/lib/gitlab/checks/lfs_check_spec.rb24
-rw-r--r--spec/lib/gitlab/checks/lfs_integrity_spec.rb32
-rw-r--r--spec/lib/gitlab/checks/project_created_spec.rb28
-rw-r--r--spec/lib/gitlab/checks/project_moved_spec.rb44
-rw-r--r--spec/lib/gitlab/checks/push_check_spec.rb16
-rw-r--r--spec/lib/gitlab/checks/tag_check_spec.rb50
-rw-r--r--spec/lib/gitlab/checks/timed_logger_spec.rb22
-rw-r--r--spec/lib/gitlab/ci/ansi2html_spec.rb68
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb45
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb28
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb122
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb110
-rw-r--r--spec/lib/gitlab/ci/build/artifacts/path_spec.rb48
-rw-r--r--spec/lib/gitlab/ci/build/credentials/factory_spec.rb15
-rw-r--r--spec/lib/gitlab/ci/build/credentials/registry_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/build/image_spec.rb76
-rw-r--r--spec/lib/gitlab/ci/build/policy/changes_spec.rb82
-rw-r--r--spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb30
-rw-r--r--spec/lib/gitlab/ci/build/policy/refs_spec.rb52
-rw-r--r--spec/lib/gitlab/ci/build/policy/variables_spec.rb40
-rw-r--r--spec/lib/gitlab/ci/build/policy_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/build/step_spec.rb42
-rw-r--r--spec/lib/gitlab/ci/charts_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/config/entry/artifacts_spec.rb46
-rw-r--r--spec/lib/gitlab/ci/config/entry/cache_spec.rb86
-rw-r--r--spec/lib/gitlab/ci/config/entry/commands_spec.rb36
-rw-r--r--spec/lib/gitlab/ci/config/entry/coverage_spec.rb22
-rw-r--r--spec/lib/gitlab/ci/config/entry/environment_spec.rb152
-rw-r--r--spec/lib/gitlab/ci/config/entry/global_spec.rb252
-rw-r--r--spec/lib/gitlab/ci/config/entry/hidden_spec.rb30
-rw-r--r--spec/lib/gitlab/ci/config/entry/image_spec.rb78
-rw-r--r--spec/lib/gitlab/ci/config/entry/job_spec.rb264
-rw-r--r--spec/lib/gitlab/ci/config/entry/jobs_spec.rb79
-rw-r--r--spec/lib/gitlab/ci/config/entry/key_spec.rb88
-rw-r--r--spec/lib/gitlab/ci/config/entry/paths_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/config/entry/policy_spec.rb142
-rw-r--r--spec/lib/gitlab/ci/config/entry/reports_spec.rb66
-rw-r--r--spec/lib/gitlab/ci/config/entry/retry_spec.rb154
-rw-r--r--spec/lib/gitlab/ci/config/entry/script_spec.rb34
-rw-r--r--spec/lib/gitlab/ci/config/entry/service_spec.rb80
-rw-r--r--spec/lib/gitlab/ci/config/entry/services_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/config/entry/stage_spec.rb30
-rw-r--r--spec/lib/gitlab/ci/config/entry/stages_spec.rb32
-rw-r--r--spec/lib/gitlab/ci/config/entry/variables_spec.rb40
-rw-r--r--spec/lib/gitlab/ci/config/extendable/entry_spec.rb160
-rw-r--r--spec/lib/gitlab/ci/config/extendable_spec.rb180
-rw-r--r--spec/lib/gitlab/ci/config/external/file/base_spec.rb44
-rw-r--r--spec/lib/gitlab/ci/config/external/file/local_spec.rb64
-rw-r--r--spec/lib/gitlab/ci/config/external/file/project_spec.rb82
-rw-r--r--spec/lib/gitlab/ci/config/external/file/remote_spec.rb100
-rw-r--r--spec/lib/gitlab/ci/config/external/file/template_spec.rb68
-rw-r--r--spec/lib/gitlab/ci/config/external/mapper_spec.rb99
-rw-r--r--spec/lib/gitlab/ci/config/external/processor_spec.rb72
-rw-r--r--spec/lib/gitlab/ci/config/normalizer_spec.rb46
-rw-r--r--spec/lib/gitlab/ci/config_spec.rb228
-rw-r--r--spec/lib/gitlab/ci/cron_parser_spec.rb134
-rw-r--r--spec/lib/gitlab/ci/mask_secret_spec.rb20
-rw-r--r--spec/lib/gitlab/ci/parsers/test/junit_spec.rb78
-rw-r--r--spec/lib/gitlab/ci/parsers_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/build_spec.rb45
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/command_spec.rb164
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/create_spec.rb23
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb120
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb12
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb35
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb63
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb61
-rw-r--r--spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb46
-rw-r--r--spec/lib/gitlab/ci/pipeline/duration_spec.rb50
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb22
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb44
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb60
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb60
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb42
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb32
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb20
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb84
-rw-r--r--spec/lib/gitlab/ci/pipeline/expression/token_spec.rb32
-rw-r--r--spec/lib/gitlab/ci/pipeline/preloader_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/build_spec.rb144
-rw-r--r--spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb70
-rw-r--r--spec/lib/gitlab/ci/reports/test_case_spec.rb64
-rw-r--r--spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb98
-rw-r--r--spec/lib/gitlab/ci/reports/test_reports_spec.rb74
-rw-r--r--spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb80
-rw-r--r--spec/lib/gitlab/ci/reports/test_suite_spec.rb40
-rw-r--r--spec/lib/gitlab/ci/status/build/action_spec.rb38
-rw-r--r--spec/lib/gitlab/ci/status/build/cancelable_spec.rb64
-rw-r--r--spec/lib/gitlab/ci/status/build/canceled_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/build/common_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/status/build/created_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/build/erased_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/build/factory_spec.rb256
-rw-r--r--spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb80
-rw-r--r--spec/lib/gitlab/ci/status/build/failed_spec.rb54
-rw-r--r--spec/lib/gitlab/ci/status/build/manual_spec.rb14
-rw-r--r--spec/lib/gitlab/ci/status/build/pending_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/build/play_spec.rb60
-rw-r--r--spec/lib/gitlab/ci/status/build/retried_spec.rb52
-rw-r--r--spec/lib/gitlab/ci/status/build/retryable_spec.rb64
-rw-r--r--spec/lib/gitlab/ci/status/build/scheduled_spec.rb18
-rw-r--r--spec/lib/gitlab/ci/status/build/skipped_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/build/stop_spec.rb56
-rw-r--r--spec/lib/gitlab/ci/status/build/unschedule_spec.rb52
-rw-r--r--spec/lib/gitlab/ci/status/canceled_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/created_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/extended_spec.rb4
-rw-r--r--spec/lib/gitlab/ci/status/external/common_spec.rb36
-rw-r--r--spec/lib/gitlab/ci/status/external/factory_spec.rb8
-rw-r--r--spec/lib/gitlab/ci/status/factory_spec.rb62
-rw-r--r--spec/lib/gitlab/ci/status/failed_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/group/common_spec.rb8
-rw-r--r--spec/lib/gitlab/ci/status/group/factory_spec.rb6
-rw-r--r--spec/lib/gitlab/ci/status/manual_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/pending_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb28
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/common_spec.rb14
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb28
-rw-r--r--spec/lib/gitlab/ci/status/pipeline/factory_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/running_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/scheduled_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/skipped_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/stage/common_spec.rb16
-rw-r--r--spec/lib/gitlab/ci/status/stage/factory_spec.rb25
-rw-r--r--spec/lib/gitlab/ci/status/success_spec.rb24
-rw-r--r--spec/lib/gitlab/ci/status/success_warning_spec.rb44
-rw-r--r--spec/lib/gitlab/ci/templates/templates_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/trace/chunked_io_spec.rb146
-rw-r--r--spec/lib/gitlab/ci/trace/section_parser_spec.rb32
-rw-r--r--spec/lib/gitlab/ci/trace/stream_spec.rb192
-rw-r--r--spec/lib/gitlab/ci/trace_spec.rb10
-rw-r--r--spec/lib/gitlab/ci/variables/collection/item_spec.rb94
-rw-r--r--spec/lib/gitlab/ci/variables/collection_spec.rb98
-rw-r--r--spec/lib/gitlab/ci/yaml_processor_spec.rb993
-rw-r--r--spec/lib/gitlab/ci_access_spec.rb8
-rw-r--r--spec/lib/gitlab/cleanup/project_uploads_spec.rb110
-rw-r--r--spec/lib/gitlab/cleanup/remote_uploads_spec.rb29
-rw-r--r--spec/lib/gitlab/closing_issue_extractor_spec.rb54
-rw-r--r--spec/lib/gitlab/color_schemes_spec.rb32
-rw-r--r--spec/lib/gitlab/config/entry/attributable_spec.rb30
-rw-r--r--spec/lib/gitlab/config/entry/boolean_spec.rb24
-rw-r--r--spec/lib/gitlab/config/entry/configurable_spec.rb30
-rw-r--r--spec/lib/gitlab/config/entry/factory_spec.rb60
-rw-r--r--spec/lib/gitlab/config/entry/simplifiable_spec.rb62
-rw-r--r--spec/lib/gitlab/config/entry/undefined_spec.rb26
-rw-r--r--spec/lib/gitlab/config/entry/unspecified_spec.rb20
-rw-r--r--spec/lib/gitlab/config/entry/validatable_spec.rb22
-rw-r--r--spec/lib/gitlab/config/entry/validator_spec.rb22
-rw-r--r--spec/lib/gitlab/config/loader/yaml_spec.rb48
-rw-r--r--spec/lib/gitlab/conflict/file_collection_spec.rb34
-rw-r--r--spec/lib/gitlab/conflict/file_spec.rb252
-rw-r--r--spec/lib/gitlab/contributions_calendar_spec.rb20
-rw-r--r--spec/lib/gitlab/correlation_id_spec.rb58
-rw-r--r--spec/lib/gitlab/cross_project_access/check_collection_spec.rb18
-rw-r--r--spec/lib/gitlab/cross_project_access/check_info_spec.rb56
-rw-r--r--spec/lib/gitlab/cross_project_access/class_methods_spec.rb28
-rw-r--r--spec/lib/gitlab/cross_project_access_spec.rb56
-rw-r--r--spec/lib/gitlab/crypto_helper_spec.rb26
-rw-r--r--spec/lib/gitlab/current_settings_spec.rb82
-rw-r--r--spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb12
-rw-r--r--spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb8
-rw-r--r--spec/lib/gitlab/cycle_analytics/code_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/events_spec.rb130
-rw-r--r--spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/permissions_spec.rb58
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/production_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/review_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_event_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb14
-rw-r--r--spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb10
-rw-r--r--spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb8
-rw-r--r--spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb8
-rw-r--r--spec/lib/gitlab/cycle_analytics/test_stage_spec.rb6
-rw-r--r--spec/lib/gitlab/cycle_analytics/updater_spec.rb22
-rw-r--r--spec/lib/gitlab/cycle_analytics/usage_data_spec.rb52
-rw-r--r--spec/lib/gitlab/daemon_spec.rb34
-rw-r--r--spec/lib/gitlab/danger/helper_spec.rb284
-rw-r--r--spec/lib/gitlab/data_builder/build_spec.rb18
-rw-r--r--spec/lib/gitlab/data_builder/note_spec.rb90
-rw-r--r--spec/lib/gitlab/data_builder/pipeline_spec.rb26
-rw-r--r--spec/lib/gitlab/data_builder/push_spec.rb38
-rw-r--r--spec/lib/gitlab/data_builder/wiki_page_spec.rb10
-rw-r--r--spec/lib/gitlab/database/count/exact_count_strategy_spec.rb18
-rw-r--r--spec/lib/gitlab/database/count/reltuples_count_strategy_spec.rb24
-rw-r--r--spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb26
-rw-r--r--spec/lib/gitlab/database/count_spec.rb36
-rw-r--r--spec/lib/gitlab/database/grant_spec.rb12
-rw-r--r--spec/lib/gitlab/database/median_spec.rb6
-rw-r--r--spec/lib/gitlab/database/migration_helpers_spec.rb856
-rw-r--r--spec/lib/gitlab/database/multi_threaded_migration_spec.rb16
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb184
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb210
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb130
-rw-r--r--spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb52
-rw-r--r--spec/lib/gitlab/database/sha_attribute_spec.rb14
-rw-r--r--spec/lib/gitlab/database/subquery_spec.rb12
-rw-r--r--spec/lib/gitlab/database_spec.rb268
-rw-r--r--spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb40
-rw-r--r--spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb50
-rw-r--r--spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb48
-rw-r--r--spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb40
-rw-r--r--spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb38
-rw-r--r--spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb64
-rw-r--r--spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb32
-rw-r--r--spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb44
-rw-r--r--spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb44
-rw-r--r--spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb60
-rw-r--r--spec/lib/gitlab/dependency_linker_spec.rb44
-rw-r--r--spec/lib/gitlab/diff/diff_refs_spec.rb66
-rw-r--r--spec/lib/gitlab/diff/file_collection/commit_spec.rb10
-rw-r--r--spec/lib/gitlab/diff/file_collection/compare_spec.rb12
-rw-r--r--spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb22
-rw-r--r--spec/lib/gitlab/diff/file_spec.rb384
-rw-r--r--spec/lib/gitlab/diff/formatters/image_formatter_spec.rb8
-rw-r--r--spec/lib/gitlab/diff/formatters/text_formatter_spec.rb16
-rw-r--r--spec/lib/gitlab/diff/highlight_cache_spec.rb36
-rw-r--r--spec/lib/gitlab/diff/highlight_spec.rb62
-rw-r--r--spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb6
-rw-r--r--spec/lib/gitlab/diff/inline_diff_marker_spec.rb14
-rw-r--r--spec/lib/gitlab/diff/inline_diff_spec.rb10
-rw-r--r--spec/lib/gitlab/diff/line_mapper_spec.rb14
-rw-r--r--spec/lib/gitlab/diff/line_spec.rb14
-rw-r--r--spec/lib/gitlab/diff/lines_unfolder_spec.rb122
-rw-r--r--spec/lib/gitlab/diff/parallel_diff_spec.rb60
-rw-r--r--spec/lib/gitlab/diff/parser_spec.rb120
-rw-r--r--spec/lib/gitlab/diff/position_spec.rb28
-rw-r--r--spec/lib/gitlab/diff/position_tracer_spec.rb218
-rw-r--r--spec/lib/gitlab/discussions_diff/file_collection_spec.rb20
-rw-r--r--spec/lib/gitlab/discussions_diff/highlight_cache_spec.rb64
-rw-r--r--spec/lib/gitlab/downtime_check/message_spec.rb28
-rw-r--r--spec/lib/gitlab/downtime_check_spec.rb66
-rw-r--r--spec/lib/gitlab/email/handler/create_issue_handler_spec.rb34
-rw-r--r--spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb74
-rw-r--r--spec/lib/gitlab/email/handler/create_note_handler_spec.rb54
-rw-r--r--spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb36
-rw-r--r--spec/lib/gitlab/email/handler_spec.rb44
-rw-r--r--spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb22
-rw-r--r--spec/lib/gitlab/email/hook/delivery_metrics_observer_spec.rb20
-rw-r--r--spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb4
-rw-r--r--spec/lib/gitlab/email/message/repository_push_spec.rb60
-rw-r--r--spec/lib/gitlab/email/receiver_spec.rb8
-rw-r--r--spec/lib/gitlab/email/reply_parser_spec.rb4
-rw-r--r--spec/lib/gitlab/encoding_helper_spec.rb118
-rw-r--r--spec/lib/gitlab/etag_caching/middleware_spec.rb84
-rw-r--r--spec/lib/gitlab/etag_caching/router_spec.rb60
-rw-r--r--spec/lib/gitlab/exclusive_lease_helpers_spec.rb52
-rw-r--r--spec/lib/gitlab/exclusive_lease_spec.rb44
-rw-r--r--spec/lib/gitlab/fake_application_settings_spec.rb16
-rw-r--r--spec/lib/gitlab/favicon_spec.rb52
-rw-r--r--spec/lib/gitlab/file_detector_spec.rb68
-rw-r--r--spec/lib/gitlab/file_finder_spec.rb22
-rw-r--r--spec/lib/gitlab/file_markdown_link_builder_spec.rb57
-rw-r--r--spec/lib/gitlab/file_type_detection_spec.rb49
-rw-r--r--spec/lib/gitlab/fogbugz_import/client_spec.rb12
-rw-r--r--spec/lib/gitlab/gfm/reference_rewriter_spec.rb78
-rw-r--r--spec/lib/gitlab/gfm/uploads_rewriter_spec.rb20
-rw-r--r--spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb18
-rw-r--r--spec/lib/gitlab/git/attributes_parser_spec.rb118
-rw-r--r--spec/lib/gitlab/git/blame_spec.rb15
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb226
-rw-r--r--spec/lib/gitlab/git/branch_spec.rb54
-rw-r--r--spec/lib/gitlab/git/bundle_file_spec.rb14
-rw-r--r--spec/lib/gitlab/git/commit_spec.rb216
-rw-r--r--spec/lib/gitlab/git/compare_spec.rb50
-rw-r--r--spec/lib/gitlab/git/conflict/file_spec.rb43
-rw-r--r--spec/lib/gitlab/git/conflict/parser_spec.rb240
-rw-r--r--spec/lib/gitlab/git/diff_collection_spec.rb224
-rw-r--r--spec/lib/gitlab/git/diff_spec.rb176
-rw-r--r--spec/lib/gitlab/git/diff_stats_collection_spec.rb18
-rw-r--r--spec/lib/gitlab/git/gitmodules_parser_spec.rb14
-rw-r--r--spec/lib/gitlab/git/hook_env_spec.rb74
-rw-r--r--spec/lib/gitlab/git/lfs_changes_spec.rb14
-rw-r--r--spec/lib/gitlab/git/lfs_pointer_file_spec.rb24
-rw-r--r--spec/lib/gitlab/git/merge_base_spec.rb54
-rw-r--r--spec/lib/gitlab/git/object_pool_spec.rb40
-rw-r--r--spec/lib/gitlab/git/patches/collection_spec.rb13
-rw-r--r--spec/lib/gitlab/git/patches/commit_patches_spec.rb23
-rw-r--r--spec/lib/gitlab/git/patches/patch_spec.rb9
-rw-r--r--spec/lib/gitlab/git/pre_receive_error_spec.rb6
-rw-r--r--spec/lib/gitlab/git/push_spec.rb112
-rw-r--r--spec/lib/gitlab/git/raw_diff_change_spec.rb44
-rw-r--r--spec/lib/gitlab/git/remote_mirror_spec.rb14
-rw-r--r--spec/lib/gitlab/git/remote_repository_spec.rb66
-rw-r--r--spec/lib/gitlab/git/repository_cleaner_spec.rb28
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb1049
-rw-r--r--spec/lib/gitlab/git/tag_spec.rb28
-rw-r--r--spec/lib/gitlab/git/tree_spec.rb62
-rw-r--r--spec/lib/gitlab/git/user_spec.rb40
-rw-r--r--spec/lib/gitlab/git/util_spec.rb6
-rw-r--r--spec/lib/gitlab/git/wiki_spec.rb88
-rw-r--r--spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb10
-rw-r--r--spec/lib/gitlab/git_access_spec.rb521
-rw-r--r--spec/lib/gitlab/git_access_wiki_spec.rb40
-rw-r--r--spec/lib/gitlab/git_ref_validator_spec.rb50
-rw-r--r--spec/lib/gitlab/git_spec.rb23
-rw-r--r--spec/lib/gitlab/gitaly_client/blob_service_spec.rb26
-rw-r--r--spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb34
-rw-r--r--spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb8
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_service_spec.rb104
-rw-r--r--spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb28
-rw-r--r--spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb24
-rw-r--r--spec/lib/gitlab/gitaly_client/diff_spec.rb18
-rw-r--r--spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb38
-rw-r--r--spec/lib/gitlab/gitaly_client/health_check_service_spec.rb24
-rw-r--r--spec/lib/gitlab/gitaly_client/notification_service_spec.rb8
-rw-r--r--spec/lib/gitlab/gitaly_client/object_pool_service_spec.rb20
-rw-r--r--spec/lib/gitlab/gitaly_client/operation_service_spec.rb139
-rw-r--r--spec/lib/gitlab/gitaly_client/ref_service_spec.rb80
-rw-r--r--spec/lib/gitlab/gitaly_client/remote_service_spec.rb52
-rw-r--r--spec/lib/gitlab/gitaly_client/repository_service_spec.rb98
-rw-r--r--spec/lib/gitlab/gitaly_client/storage_service_spec.rb6
-rw-r--r--spec/lib/gitlab/gitaly_client/storage_settings_spec.rb24
-rw-r--r--spec/lib/gitlab/gitaly_client/util_spec.rb22
-rw-r--r--spec/lib/gitlab/gitaly_client/wiki_service_spec.rb62
-rw-r--r--spec/lib/gitlab/gitaly_client_spec.rb165
-rw-r--r--spec/lib/gitlab/github_import/bulk_importing_spec.rb28
-rw-r--r--spec/lib/gitlab/github_import/caching_spec.rb96
-rw-r--r--spec/lib/gitlab/github_import/client_spec.rb208
-rw-r--r--spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb56
-rw-r--r--spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb46
-rw-r--r--spec/lib/gitlab/github_import/importer/issue_and_label_links_importer_spec.rb6
-rw-r--r--spec/lib/gitlab/github_import/importer/issue_importer_spec.rb60
-rw-r--r--spec/lib/gitlab/github_import/importer/issues_importer_spec.rb46
-rw-r--r--spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb24
-rw-r--r--spec/lib/gitlab/github_import/importer/labels_importer_spec.rb60
-rw-r--r--spec/lib/gitlab/github_import/importer/lfs_object_importer_spec.rb10
-rw-r--r--spec/lib/gitlab/github_import/importer/lfs_objects_importer_spec.rb36
-rw-r--r--spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb62
-rw-r--r--spec/lib/gitlab/github_import/importer/note_importer_spec.rb52
-rw-r--r--spec/lib/gitlab/github_import/importer/notes_importer_spec.rb42
-rw-r--r--spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb100
-rw-r--r--spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb100
-rw-r--r--spec/lib/gitlab/github_import/importer/releases_importer_spec.rb74
-rw-r--r--spec/lib/gitlab/github_import/importer/repository_importer_spec.rb68
-rw-r--r--spec/lib/gitlab/github_import/issuable_finder_spec.rb16
-rw-r--r--spec/lib/gitlab/github_import/label_finder_spec.rb36
-rw-r--r--spec/lib/gitlab/github_import/markdown_text_spec.rb26
-rw-r--r--spec/lib/gitlab/github_import/milestone_finder_spec.rb26
-rw-r--r--spec/lib/gitlab/github_import/page_counter_spec.rb14
-rw-r--r--spec/lib/gitlab/github_import/parallel_importer_spec.rb16
-rw-r--r--spec/lib/gitlab/github_import/parallel_scheduling_spec.rb60
-rw-r--r--spec/lib/gitlab/github_import/representation/diff_note_spec.rb136
-rw-r--r--spec/lib/gitlab/github_import/representation/expose_attribute_spec.rb10
-rw-r--r--spec/lib/gitlab/github_import/representation/issue_spec.rb130
-rw-r--r--spec/lib/gitlab/github_import/representation/note_spec.rb74
-rw-r--r--spec/lib/gitlab/github_import/representation/pull_request_spec.rb226
-rw-r--r--spec/lib/gitlab/github_import/representation/to_hash_spec.rb20
-rw-r--r--spec/lib/gitlab/github_import/representation/user_spec.rb26
-rw-r--r--spec/lib/gitlab/github_import/representation_spec.rb14
-rw-r--r--spec/lib/gitlab/github_import/sequential_importer_spec.rb8
-rw-r--r--spec/lib/gitlab/github_import/user_finder_spec.rb154
-rw-r--r--spec/lib/gitlab/github_import_spec.rb22
-rw-r--r--spec/lib/gitlab/gitlab_import/client_spec.rb56
-rw-r--r--spec/lib/gitlab/gitlab_import/importer_spec.rb46
-rw-r--r--spec/lib/gitlab/gitlab_import/project_creator_spec.rb14
-rw-r--r--spec/lib/gitlab/gl_repository_spec.rb10
-rw-r--r--spec/lib/gitlab/gon_helper_spec.rb18
-rw-r--r--spec/lib/gitlab/google_code_import/importer_spec.rb24
-rw-r--r--spec/lib/gitlab/google_code_import/project_creator_spec.rb8
-rw-r--r--spec/lib/gitlab/gpg/commit_spec.rb168
-rw-r--r--spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb60
-rw-r--r--spec/lib/gitlab/gpg_spec.rb88
-rw-r--r--spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb16
-rw-r--r--spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb54
-rw-r--r--spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb14
-rw-r--r--spec/lib/gitlab/graphql/connections/keyset_connection_spec.rb60
-rw-r--r--spec/lib/gitlab/graphql/loaders/batch_model_loader_spec.rb14
-rw-r--r--spec/lib/gitlab/graphs/commits_spec.rb18
-rw-r--r--spec/lib/gitlab/hashed_storage/migrator_spec.rb32
-rw-r--r--spec/lib/gitlab/health_checks/db_check_spec.rb6
-rw-r--r--spec/lib/gitlab/health_checks/gitaly_check_spec.rb40
-rw-r--r--spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb18
-rw-r--r--spec/lib/gitlab/health_checks/redis/cache_check_spec.rb6
-rw-r--r--spec/lib/gitlab/health_checks/redis/queues_check_spec.rb6
-rw-r--r--spec/lib/gitlab/health_checks/redis/redis_check_spec.rb6
-rw-r--r--spec/lib/gitlab/health_checks/redis/shared_state_check_spec.rb6
-rw-r--r--spec/lib/gitlab/health_checks/simple_check_shared.rb26
-rw-r--r--spec/lib/gitlab/highlight_spec.rb68
-rw-r--r--spec/lib/gitlab/hook_data/base_builder_spec.rb96
-rw-r--r--spec/lib/gitlab/hook_data/issuable_builder_spec.rb74
-rw-r--r--spec/lib/gitlab/hook_data/issue_builder_spec.rb14
-rw-r--r--spec/lib/gitlab/hook_data/merge_request_builder_spec.rb16
-rw-r--r--spec/lib/gitlab/http_io_spec.rb122
-rw-r--r--spec/lib/gitlab/http_spec.rb60
-rw-r--r--spec/lib/gitlab/i18n/metadata_entry_spec.rb16
-rw-r--r--spec/lib/gitlab/i18n/po_linter_spec.rb258
-rw-r--r--spec/lib/gitlab/i18n/translation_entry_spec.rb158
-rw-r--r--spec/lib/gitlab/i18n_spec.rb16
-rw-r--r--spec/lib/gitlab/identifier_spec.rb38
-rw-r--r--spec/lib/gitlab/import/database_helpers_spec.rb14
-rw-r--r--spec/lib/gitlab/import/merge_request_creator_spec.rb12
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb38
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb22
-rw-r--r--spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb22
-rw-r--r--spec/lib/gitlab/import_export/attribute_cleaner_spec.rb54
-rw-r--r--spec/lib/gitlab/import_export/attribute_configuration_spec.rb16
-rw-r--r--spec/lib/gitlab/import_export/avatar_restorer_spec.rb14
-rw-r--r--spec/lib/gitlab/import_export/avatar_saver_spec.rb6
-rw-r--r--spec/lib/gitlab/import_export/command_line_util_spec.rb16
-rw-r--r--spec/lib/gitlab/import_export/file_importer_spec.rb46
-rw-r--r--spec/lib/gitlab/import_export/fork_spec.rb12
-rw-r--r--spec/lib/gitlab/import_export/group_project_object_builder_spec.rb52
-rw-r--r--spec/lib/gitlab/import_export/hash_util_spec.rb20
-rw-r--r--spec/lib/gitlab/import_export/import_export_spec.rb16
-rw-r--r--spec/lib/gitlab/import_export/importer_spec.rb40
-rw-r--r--spec/lib/gitlab/import_export/lfs_restorer_spec.rb30
-rw-r--r--spec/lib/gitlab/import_export/lfs_saver_spec.rb22
-rw-r--r--spec/lib/gitlab/import_export/members_mapper_spec.rb95
-rw-r--r--spec/lib/gitlab/import_export/merge_request_parser_spec.rb16
-rw-r--r--spec/lib/gitlab/import_export/model_configuration_spec.rb18
-rw-r--r--spec/lib/gitlab/import_export/project_tree_restorer_spec.rb312
-rw-r--r--spec/lib/gitlab/import_export/project_tree_saver_spec.rb249
-rw-r--r--spec/lib/gitlab/import_export/reader_spec.rb64
-rw-r--r--spec/lib/gitlab/import_export/relation_factory_spec.rb125
-rw-r--r--spec/lib/gitlab/import_export/relation_rename_service_spec.rb28
-rw-r--r--spec/lib/gitlab/import_export/repo_restorer_spec.rb10
-rw-r--r--spec/lib/gitlab/import_export/repo_saver_spec.rb8
-rw-r--r--spec/lib/gitlab/import_export/saver_spec.rb10
-rw-r--r--spec/lib/gitlab/import_export/shared_spec.rb24
-rw-r--r--spec/lib/gitlab/import_export/uploads_manager_spec.rb30
-rw-r--r--spec/lib/gitlab/import_export/uploads_restorer_spec.rb24
-rw-r--r--spec/lib/gitlab/import_export/uploads_saver_spec.rb26
-rw-r--r--spec/lib/gitlab/import_export/version_checker_spec.rb24
-rw-r--r--spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb8
-rw-r--r--spec/lib/gitlab/import_export/wiki_restorer_spec.rb8
-rw-r--r--spec/lib/gitlab/import_sources_spec.rb92
-rw-r--r--spec/lib/gitlab/incoming_email_spec.rb46
-rw-r--r--spec/lib/gitlab/insecure_key_fingerprint_spec.rb10
-rw-r--r--spec/lib/gitlab/issuable_metadata_spec.rb22
-rw-r--r--spec/lib/gitlab/issuable_sorter_spec.rb26
-rw-r--r--spec/lib/gitlab/issuables_count_for_state_spec.rb24
-rw-r--r--spec/lib/gitlab/job_waiter_spec.rb26
-rw-r--r--spec/lib/gitlab/json_cache_spec.rb188
-rw-r--r--spec/lib/gitlab/json_logger_spec.rb35
-rw-r--r--spec/lib/gitlab/kubernetes/cluster_role_binding_spec.rb20
-rw-r--r--spec/lib/gitlab/kubernetes/config_map_spec.rb14
-rw-r--r--spec/lib/gitlab/kubernetes/helm/api_spec.rb120
-rw-r--r--spec/lib/gitlab/kubernetes/helm/base_command_spec.rb20
-rw-r--r--spec/lib/gitlab/kubernetes/helm/certificate_spec.rb15
-rw-r--r--spec/lib/gitlab/kubernetes/helm/init_command_spec.rb68
-rw-r--r--spec/lib/gitlab/kubernetes/helm/install_command_spec.rb268
-rw-r--r--spec/lib/gitlab/kubernetes/helm/pod_spec.rb54
-rw-r--r--spec/lib/gitlab/kubernetes/kube_client_spec.rb160
-rw-r--r--spec/lib/gitlab/kubernetes/namespace_spec.rb32
-rw-r--r--spec/lib/gitlab/kubernetes/role_binding_spec.rb26
-rw-r--r--spec/lib/gitlab/kubernetes/service_account_spec.rb12
-rw-r--r--spec/lib/gitlab/kubernetes/service_account_token_spec.rb18
-rw-r--r--spec/lib/gitlab/kubernetes_spec.rb82
-rw-r--r--spec/lib/gitlab/language_data_spec.rb8
-rw-r--r--spec/lib/gitlab/language_detection_spec.rb42
-rw-r--r--spec/lib/gitlab/lazy_spec.rb24
-rw-r--r--spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb34
-rw-r--r--spec/lib/gitlab/legacy_github_import/client_spec.rb68
-rw-r--r--spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb48
-rw-r--r--spec/lib/gitlab/legacy_github_import/importer_spec.rb138
-rw-r--r--spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb12
-rw-r--r--spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb110
-rw-r--r--spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb22
-rw-r--r--spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb68
-rw-r--r--spec/lib/gitlab/legacy_github_import/project_creator_spec.rb50
-rw-r--r--spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb214
-rw-r--r--spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb34
-rw-r--r--spec/lib/gitlab/legacy_github_import/user_formatter_spec.rb20
-rw-r--r--spec/lib/gitlab/legacy_github_import/wiki_formatter_spec.rb20
-rw-r--r--spec/lib/gitlab/lfs_token_spec.rb122
-rw-r--r--spec/lib/gitlab/loop_helpers_spec.rb22
-rw-r--r--spec/lib/gitlab/manifest_import/manifest_spec.rb26
-rw-r--r--spec/lib/gitlab/manifest_import/project_creator_spec.rb14
-rw-r--r--spec/lib/gitlab/markup_helper_spec.rb28
-rw-r--r--spec/lib/gitlab/metrics/background_transaction_spec.rb16
-rw-r--r--spec/lib/gitlab/metrics/delta_spec.rb8
-rw-r--r--spec/lib/gitlab/metrics/instrumentation_spec.rb141
-rw-r--r--spec/lib/gitlab/metrics/method_call_spec.rb86
-rw-r--r--spec/lib/gitlab/metrics/methods_spec.rb38
-rw-r--r--spec/lib/gitlab/metrics/metric_spec.rb42
-rw-r--r--spec/lib/gitlab/metrics/prometheus_spec.rb8
-rw-r--r--spec/lib/gitlab/metrics/rack_middleware_spec.rb38
-rw-r--r--spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb30
-rw-r--r--spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb48
-rw-r--r--spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb22
-rw-r--r--spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb66
-rw-r--r--spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb34
-rw-r--r--spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb18
-rw-r--r--spec/lib/gitlab/metrics/subscribers/action_view_spec.rb16
-rw-r--r--spec/lib/gitlab/metrics/subscribers/active_record_spec.rb42
-rw-r--r--spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb126
-rw-r--r--spec/lib/gitlab/metrics/system_spec.rb30
-rw-r--r--spec/lib/gitlab/metrics/web_transaction_spec.rb162
-rw-r--r--spec/lib/gitlab/metrics_spec.rb198
-rw-r--r--spec/lib/gitlab/middleware/basic_health_check_spec.rb32
-rw-r--r--spec/lib/gitlab/middleware/go_spec.rb130
-rw-r--r--spec/lib/gitlab/middleware/multipart_spec.rb94
-rw-r--r--spec/lib/gitlab/middleware/rails_queue_duration_spec.rb28
-rw-r--r--spec/lib/gitlab/middleware/read_only_spec.rb96
-rw-r--r--spec/lib/gitlab/middleware/release_env_spec.rb12
-rw-r--r--spec/lib/gitlab/multi_collection_paginator_spec.rb16
-rw-r--r--spec/lib/gitlab/null_request_store_spec.rb68
-rw-r--r--spec/lib/gitlab/object_hierarchy_spec.rb58
-rw-r--r--spec/lib/gitlab/omniauth_initializer_spec.rb34
-rw-r--r--spec/lib/gitlab/optimistic_locking_spec.rb20
-rw-r--r--spec/lib/gitlab/other_markup_spec.rb12
-rw-r--r--spec/lib/gitlab/otp_key_rotator_spec.rb22
-rw-r--r--spec/lib/gitlab/pages_client_spec.rb96
-rw-r--r--spec/lib/gitlab/patch/draw_route_spec.rb10
-rw-r--r--spec/lib/gitlab/patch/prependable_spec.rb82
-rw-r--r--spec/lib/gitlab/path_regex_spec.rb325
-rw-r--r--spec/lib/gitlab/performance_bar_spec.rb52
-rw-r--r--spec/lib/gitlab/plugin_spec.rb18
-rw-r--r--spec/lib/gitlab/polling_interval_spec.rb16
-rw-r--r--spec/lib/gitlab/popen/runner_spec.rb65
-rw-r--r--spec/lib/gitlab/popen_spec.rb56
-rw-r--r--spec/lib/gitlab/private_commit_email_spec.rb26
-rw-r--r--spec/lib/gitlab/profiler_spec.rb160
-rw-r--r--spec/lib/gitlab/project_authorizations_spec.rb24
-rw-r--r--spec/lib/gitlab/project_search_results_spec.rb211
-rw-r--r--spec/lib/gitlab/project_template_spec.rb56
-rw-r--r--spec/lib/gitlab/project_transfer_spec.rb24
-rw-r--r--spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb56
-rw-r--r--spec/lib/gitlab/prometheus/metric_group_spec.rb22
-rw-r--r--spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb10
-rw-r--r--spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb6
-rw-r--r--spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb20
-rw-r--r--spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb86
-rw-r--r--spec/lib/gitlab/prometheus/query_variables_spec.rb12
-rw-r--r--spec/lib/gitlab/prometheus_client_spec.rb144
-rw-r--r--spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb10
-rw-r--r--spec/lib/gitlab/query_limiting/middleware_spec.rb56
-rw-r--r--spec/lib/gitlab/query_limiting/transaction_spec.rb52
-rw-r--r--spec/lib/gitlab/query_limiting_spec.rb30
-rw-r--r--spec/lib/gitlab/quick_actions/command_definition_spec.rb44
-rw-r--r--spec/lib/gitlab/quick_actions/dsl_spec.rb72
-rw-r--r--spec/lib/gitlab/quick_actions/extractor_spec.rb156
-rw-r--r--spec/lib/gitlab/quick_actions/spend_time_and_date_separator_spec.rb60
-rw-r--r--spec/lib/gitlab/quick_actions/substitution_definition_spec.rb36
-rw-r--r--spec/lib/gitlab/redis/cache_spec.rb2
-rw-r--r--spec/lib/gitlab/redis/queues_spec.rb2
-rw-r--r--spec/lib/gitlab/redis/shared_state_spec.rb2
-rw-r--r--spec/lib/gitlab/redis/wrapper_spec.rb10
-rw-r--r--spec/lib/gitlab/reference_counter_spec.rb16
-rw-r--r--spec/lib/gitlab/reference_extractor_spec.rb148
-rw-r--r--spec/lib/gitlab/regex_spec.rb79
-rw-r--r--spec/lib/gitlab/repo_path_spec.rb58
-rw-r--r--spec/lib/gitlab/repository_cache_adapter_spec.rb105
-rw-r--r--spec/lib/gitlab/repository_cache_spec.rb76
-rw-r--r--spec/lib/gitlab/request_context_spec.rb18
-rw-r--r--spec/lib/gitlab/request_forgery_protection_spec.rb58
-rw-r--r--spec/lib/gitlab/request_profiler_spec.rb14
-rw-r--r--spec/lib/gitlab/route_map_spec.rb66
-rw-r--r--spec/lib/gitlab/routing_spec.rb10
-rw-r--r--spec/lib/gitlab/safe_request_store_spec.rb240
-rw-r--r--spec/lib/gitlab/sanitizers/svg_spec.rb62
-rw-r--r--spec/lib/gitlab/search/found_blob_spec.rb114
-rw-r--r--spec/lib/gitlab/search/query_spec.rb24
-rw-r--r--spec/lib/gitlab/search_results_spec.rb132
-rw-r--r--spec/lib/gitlab/sentry_spec.rb60
-rw-r--r--spec/lib/gitlab/serializer/ci/variables_spec.rb12
-rw-r--r--spec/lib/gitlab/serializer/pagination_spec.rb29
-rw-r--r--spec/lib/gitlab/shard_health_cache_spec.rb32
-rw-r--r--spec/lib/gitlab/shell_spec.rb288
-rw-r--r--spec/lib/gitlab/sherlock/collection_spec.rb40
-rw-r--r--spec/lib/gitlab/sherlock/file_sample_spec.rb36
-rw-r--r--spec/lib/gitlab/sherlock/line_profiler_spec.rb34
-rw-r--r--spec/lib/gitlab/sherlock/line_sample_spec.rb18
-rw-r--r--spec/lib/gitlab/sherlock/location_spec.rb22
-rw-r--r--spec/lib/gitlab/sherlock/middleware_spec.rb42
-rw-r--r--spec/lib/gitlab/sherlock/query_spec.rb74
-rw-r--r--spec/lib/gitlab/sherlock/transaction_spec.rb150
-rw-r--r--spec/lib/gitlab/sidekiq_config_spec.rb36
-rw-r--r--spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb22
-rw-r--r--spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb82
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb12
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb15
-rw-r--r--spec/lib/gitlab/sidekiq_middleware/shutdown_spec.rb30
-rw-r--r--spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb10
-rw-r--r--spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb10
-rw-r--r--spec/lib/gitlab/sidekiq_status_spec.rb94
-rw-r--r--spec/lib/gitlab/sidekiq_versioning/manager_spec.rb18
-rw-r--r--spec/lib/gitlab/sidekiq_versioning_spec.rb16
-rw-r--r--spec/lib/gitlab/slash_commands/application_help_spec.rb12
-rw-r--r--spec/lib/gitlab/slash_commands/command_spec.rb80
-rw-r--r--spec/lib/gitlab/slash_commands/deploy_spec.rb80
-rw-r--r--spec/lib/gitlab/slash_commands/issue_move_spec.rb70
-rw-r--r--spec/lib/gitlab/slash_commands/issue_new_spec.rb38
-rw-r--r--spec/lib/gitlab/slash_commands/issue_search_spec.rb24
-rw-r--r--spec/lib/gitlab/slash_commands/issue_show_spec.rb20
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/access_spec.rb22
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb12
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/error_spec.rb8
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb6
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_new_spec.rb4
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_search_spec.rb6
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb22
-rw-r--r--spec/lib/gitlab/slash_commands/presenters/run_spec.rb30
-rw-r--r--spec/lib/gitlab/slash_commands/run_spec.rb42
-rw-r--r--spec/lib/gitlab/snippet_search_results_spec.rb14
-rw-r--r--spec/lib/gitlab/sql/cte_spec.rb18
-rw-r--r--spec/lib/gitlab/sql/glob_spec.rb38
-rw-r--r--spec/lib/gitlab/sql/pattern_spec.rb146
-rw-r--r--spec/lib/gitlab/sql/recursive_cte_spec.rb22
-rw-r--r--spec/lib/gitlab/sql/union_spec.rb20
-rw-r--r--spec/lib/gitlab/ssh_public_key_spec.rb74
-rw-r--r--spec/lib/gitlab/string_placeholder_replacer_spec.rb38
-rw-r--r--spec/lib/gitlab/string_range_marker_spec.rb24
-rw-r--r--spec/lib/gitlab/string_regex_marker_spec.rb28
-rw-r--r--spec/lib/gitlab/tcp_checker_spec.rb10
-rw-r--r--spec/lib/gitlab/template/finders/global_template_finder_spec.rb22
-rw-r--r--spec/lib/gitlab/template/finders/repo_template_finders_spec.rb36
-rw-r--r--spec/lib/gitlab/template/gitignore_template_spec.rb36
-rw-r--r--spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb52
-rw-r--r--spec/lib/gitlab/template/issue_template_spec.rb56
-rw-r--r--spec/lib/gitlab/template/merge_request_template_spec.rb56
-rw-r--r--spec/lib/gitlab/themes_spec.rb30
-rw-r--r--spec/lib/gitlab/tracing/factory_spec.rb32
-rw-r--r--spec/lib/gitlab/tracing/grpc_interceptor_spec.rb30
-rw-r--r--spec/lib/gitlab/tracing/jaeger_factory_spec.rb64
-rw-r--r--spec/lib/gitlab/tracing/rack_middleware_spec.rb36
-rw-r--r--spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb61
-rw-r--r--spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb28
-rw-r--r--spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb30
-rw-r--r--spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb30
-rw-r--r--spec/lib/gitlab/tracing_spec.rb16
-rw-r--r--spec/lib/gitlab/tree_summary_spec.rb82
-rw-r--r--spec/lib/gitlab/untrusted_regexp_spec.rb126
-rw-r--r--spec/lib/gitlab/uploads_transfer_spec.rb6
-rw-r--r--spec/lib/gitlab/url_blocker_spec.rb291
-rw-r--r--spec/lib/gitlab/url_builder_spec.rb90
-rw-r--r--spec/lib/gitlab/url_sanitizer_spec.rb158
-rw-r--r--spec/lib/gitlab/usage_data_spec.rb52
-rw-r--r--spec/lib/gitlab/user_access_spec.rb144
-rw-r--r--spec/lib/gitlab/user_extractor_spec.rb40
-rw-r--r--spec/lib/gitlab/utils/merge_hash_spec.rb26
-rw-r--r--spec/lib/gitlab/utils/override_spec.rb92
-rw-r--r--spec/lib/gitlab/utils/strong_memoize_spec.rb24
-rw-r--r--spec/lib/gitlab/utils_spec.rb188
-rw-r--r--spec/lib/gitlab/verify/job_artifacts_spec.rb24
-rw-r--r--spec/lib/gitlab/verify/lfs_objects_spec.rb24
-rw-r--r--spec/lib/gitlab/verify/uploads_spec.rb36
-rw-r--r--spec/lib/gitlab/version_info_spec.rb22
-rw-r--r--spec/lib/gitlab/view/presenter/base_spec.rb28
-rw-r--r--spec/lib/gitlab/view/presenter/delegated_spec.rb24
-rw-r--r--spec/lib/gitlab/view/presenter/factory_spec.rb20
-rw-r--r--spec/lib/gitlab/view/presenter/simple_spec.rb24
-rw-r--r--spec/lib/gitlab/visibility_level_spec.rb48
-rw-r--r--spec/lib/gitlab/web_ide_commits_counter_spec.rb14
-rw-r--r--spec/lib/gitlab/wiki_file_finder_spec.rb14
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb256
-rw-r--r--spec/lib/gitlab_spec.rb64
-rw-r--r--spec/lib/google_api/auth_spec.rb26
-rw-r--r--spec/lib/google_api/cloud_platform/client_spec.rb99
-rw-r--r--spec/lib/json_web_token/hmac_token_spec.rb80
-rw-r--r--spec/lib/json_web_token/rsa_token_spec.rb17
-rw-r--r--spec/lib/json_web_token/token_spec.rb6
-rw-r--r--spec/lib/mattermost/client_spec.rb8
-rw-r--r--spec/lib/mattermost/command_spec.rb48
-rw-r--r--spec/lib/mattermost/session_spec.rb69
-rw-r--r--spec/lib/mattermost/team_spec.rb84
-rw-r--r--spec/lib/microsoft_teams/activity_spec.rb16
-rw-r--r--spec/lib/microsoft_teams/notifier_spec.rb54
-rw-r--r--spec/lib/milestone_array_spec.rb34
-rw-r--r--spec/lib/object_storage/direct_upload_spec.rb90
-rw-r--r--spec/lib/omni_auth/strategies/jwt_spec.rb38
-rw-r--r--spec/lib/quality/helm_client_spec.rb90
-rw-r--r--spec/lib/quality/kubernetes_client_spec.rb20
-rw-r--r--spec/lib/rspec_flaky/config_spec.rb76
-rw-r--r--spec/lib/rspec_flaky/example_spec.rb58
-rw-r--r--spec/lib/rspec_flaky/flaky_example_spec.rb88
-rw-r--r--spec/lib/rspec_flaky/flaky_examples_collection_spec.rb46
-rw-r--r--spec/lib/rspec_flaky/listener_spec.rb114
-rw-r--r--spec/lib/rspec_flaky/report_spec.rb50
-rw-r--r--spec/lib/safe_zip/entry_spec.rb103
-rw-r--r--spec/lib/safe_zip/extract_params_spec.rb32
-rw-r--r--spec/lib/safe_zip/extract_spec.rb56
-rw-r--r--spec/lib/sentry/client_spec.rb100
-rw-r--r--spec/lib/serializers/json_spec.rb68
-rw-r--r--spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb26
-rw-r--r--spec/lib/system_check/base_check_spec.rb8
-rw-r--r--spec/lib/system_check/orphans/namespace_check_spec.rb46
-rw-r--r--spec/lib/system_check/orphans/repository_check_spec.rb58
-rw-r--r--spec/lib/system_check/simple_executor_spec.rb116
-rw-r--r--spec/lib/system_check_spec.rb14
-rw-r--r--spec/lib/uploaded_file_spec.rb54
-rw-r--r--spec/mailers/abuse_report_mailer_spec.rb22
-rw-r--r--spec/mailers/email_rejection_mailer_spec.rb10
-rw-r--r--spec/mailers/emails/auto_devops_spec.rb14
-rw-r--r--spec/mailers/emails/issues_spec.rb18
-rw-r--r--spec/mailers/emails/merge_requests_spec.rb4
-rw-r--r--spec/mailers/emails/pages_domains_spec.rb46
-rw-r--r--spec/mailers/emails/profile_spec.rb80
-rw-r--r--spec/mailers/notify_spec.rb956
-rw-r--r--spec/mailers/repository_check_mailer_spec.rb16
-rw-r--r--spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb8
-rw-r--r--spec/migrations/active_record/schema_spec.rb14
-rw-r--r--spec/migrations/add_foreign_key_from_notification_settings_to_users_spec.rb17
-rw-r--r--spec/migrations/add_foreign_key_to_merge_requests_spec.rb16
-rw-r--r--spec/migrations/add_foreign_keys_to_todos_spec.rb32
-rw-r--r--spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb4
-rw-r--r--spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb10
-rw-r--r--spec/migrations/add_pages_access_level_to_project_feature_spec.rb16
-rw-r--r--spec/migrations/add_pipeline_build_foreign_key_spec.rb12
-rw-r--r--spec/migrations/add_unique_constraint_to_project_features_project_id_spec.rb24
-rw-r--r--spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb22
-rw-r--r--spec/migrations/backfill_releases_name_with_tag_name_spec.rb10
-rw-r--r--spec/migrations/backfill_store_project_full_path_in_repo_spec.rb56
-rw-r--r--spec/migrations/calculate_conv_dev_index_percentages_spec.rb10
-rw-r--r--spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb8
-rw-r--r--spec/migrations/clean_appearance_symlinks_spec.rb16
-rw-r--r--spec/migrations/clean_stage_id_reference_migration_spec.rb16
-rw-r--r--spec/migrations/clean_stages_statuses_migration_spec.rb28
-rw-r--r--spec/migrations/clean_up_for_members_spec.rb18
-rw-r--r--spec/migrations/clean_upload_symlinks_spec.rb16
-rw-r--r--spec/migrations/cleanup_build_stage_migration_spec.rb28
-rw-r--r--spec/migrations/cleanup_environments_external_url_spec.rb22
-rw-r--r--spec/migrations/cleanup_legacy_artifact_migration_spec.rb46
-rw-r--r--spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb20
-rw-r--r--spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb18
-rw-r--r--spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb10
-rw-r--r--spec/migrations/cleanup_stages_position_migration_spec.rb30
-rw-r--r--spec/migrations/convert_custom_notification_settings_to_columns_spec.rb28
-rw-r--r--spec/migrations/create_missing_namespace_for_internal_users_spec.rb10
-rw-r--r--spec/migrations/delete_conflicting_redirect_routes_spec.rb32
-rw-r--r--spec/migrations/delete_inconsistent_internal_id_records_spec.rb43
-rw-r--r--spec/migrations/drop_duplicate_protected_tags_spec.rb30
-rw-r--r--spec/migrations/enqueue_delete_diff_files_workers_spec.rb6
-rw-r--r--spec/migrations/enqueue_redact_links_spec.rb14
-rw-r--r--spec/migrations/enqueue_verify_pages_domain_workers_spec.rb10
-rw-r--r--spec/migrations/fill_empty_finished_at_in_deployments_spec.rb44
-rw-r--r--spec/migrations/fill_file_store_spec.rb14
-rw-r--r--spec/migrations/fix_null_type_labels_spec.rb30
-rw-r--r--spec/migrations/fix_wrongly_renamed_routes_spec.rb66
-rw-r--r--spec/migrations/generate_missing_routes_spec.rb50
-rw-r--r--spec/migrations/import_common_metrics_spec.rb6
-rw-r--r--spec/migrations/issues_moved_to_id_foreign_key_spec.rb6
-rw-r--r--spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb20
-rw-r--r--spec/migrations/migrate_build_stage_reference_again_spec.rb42
-rw-r--r--spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb56
-rw-r--r--spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb52
-rw-r--r--spec/migrations/migrate_forbidden_redirect_uris_spec.rb36
-rw-r--r--spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb46
-rw-r--r--spec/migrations/migrate_import_attributes_data_from_projects_to_project_mirror_data_spec.rb22
-rw-r--r--spec/migrations/migrate_issues_to_ghost_user_spec.rb32
-rw-r--r--spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb186
-rw-r--r--spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb48
-rw-r--r--spec/migrations/migrate_null_wiki_access_levels_spec.rb18
-rw-r--r--spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb20
-rw-r--r--spec/migrations/migrate_old_artifacts_spec.rb56
-rw-r--r--spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb44
-rw-r--r--spec/migrations/migrate_pipeline_stages_spec.rb38
-rw-r--r--spec/migrations/migrate_process_commit_worker_jobs_spec.rb110
-rw-r--r--spec/migrations/migrate_remaining_mr_metrics_populating_background_migration_spec.rb20
-rw-r--r--spec/migrations/migrate_stage_id_reference_in_background_spec.rb34
-rw-r--r--spec/migrations/migrate_stages_statuses_spec.rb44
-rw-r--r--spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb24
-rw-r--r--spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb48
-rw-r--r--spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb14
-rw-r--r--spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb14
-rw-r--r--spec/migrations/migrate_user_project_view_spec.rb14
-rw-r--r--spec/migrations/move_personal_snippets_files_spec.rb84
-rw-r--r--spec/migrations/move_system_upload_folder_spec.rb46
-rw-r--r--spec/migrations/move_uploads_to_system_dir_spec.rb30
-rw-r--r--spec/migrations/normalize_ldap_extern_uids_spec.rb26
-rw-r--r--spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb16
-rw-r--r--spec/migrations/populate_mr_metrics_with_events_data_spec.rb16
-rw-r--r--spec/migrations/remove_assignee_id_from_issue_spec.rb14
-rw-r--r--spec/migrations/remove_dot_git_from_usernames_spec.rb42
-rw-r--r--spec/migrations/remove_duplicate_mr_events_spec.rb10
-rw-r--r--spec/migrations/remove_empty_extern_uid_auth0_identities_spec.rb18
-rw-r--r--spec/migrations/remove_empty_fork_networks_spec.rb6
-rw-r--r--spec/migrations/remove_orphaned_label_links_spec.rb12
-rw-r--r--spec/migrations/remove_project_labels_group_id_spec.rb12
-rw-r--r--spec/migrations/remove_redundant_pipeline_stages_spec.rb26
-rw-r--r--spec/migrations/remove_soft_removed_objects_spec.rb24
-rw-r--r--spec/migrations/rename_duplicated_variable_key_spec.rb38
-rw-r--r--spec/migrations/rename_more_reserved_project_names_spec.rb28
-rw-r--r--spec/migrations/rename_reserved_project_names_spec.rb28
-rw-r--r--spec/migrations/rename_users_with_renamed_namespace_spec.rb22
-rw-r--r--spec/migrations/reschedule_builds_stages_migration_spec.rb14
-rw-r--r--spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb10
-rw-r--r--spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb8
-rw-r--r--spec/migrations/schedule_digest_personal_access_tokens_spec.rb32
-rw-r--r--spec/migrations/schedule_merge_request_diff_migrations_spec.rb14
-rw-r--r--spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb14
-rw-r--r--spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb20
-rw-r--r--spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb6
-rw-r--r--spec/migrations/schedule_runners_token_encryption_spec.rb34
-rw-r--r--spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb8
-rw-r--r--spec/migrations/schedule_stages_index_migration_spec.rb18
-rw-r--r--spec/migrations/schedule_to_archive_legacy_traces_spec.rb26
-rw-r--r--spec/migrations/steal_fill_store_upload_spec.rb26
-rw-r--r--spec/migrations/track_untracked_uploads_spec.rb6
-rw-r--r--spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb26
-rw-r--r--spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb16
-rw-r--r--spec/migrations/update_notes_type_for_import_spec.rb16
-rw-r--r--spec/migrations/update_project_import_visibility_level_spec.rb46
-rw-r--r--spec/migrations/update_retried_for_ci_build_spec.rb10
-rw-r--r--spec/migrations/update_upload_paths_to_system_spec.rb48
-rw-r--r--spec/models/ability_spec.rb96
-rw-r--r--spec/models/abuse_report_spec.rb22
-rw-r--r--spec/models/active_session_spec.rb122
-rw-r--r--spec/models/appearance_spec.rb50
-rw-r--r--spec/models/application_record_spec.rb16
-rw-r--r--spec/models/application_setting/term_spec.rb18
-rw-r--r--spec/models/application_setting_spec.rb314
-rw-r--r--spec/models/award_emoji_spec.rb38
-rw-r--r--spec/models/badge_spec.rb56
-rw-r--r--spec/models/badges/group_badge_spec.rb6
-rw-r--r--spec/models/badges/project_badge_spec.rb26
-rw-r--r--spec/models/blob_spec.rb271
-rw-r--r--spec/models/blob_viewer/base_spec.rb100
-rw-r--r--spec/models/blob_viewer/changelog_spec.rb14
-rw-r--r--spec/models/blob_viewer/composer_json_spec.rb10
-rw-r--r--spec/models/blob_viewer/gemspec_spec.rb10
-rw-r--r--spec/models/blob_viewer/gitlab_ci_yml_spec.rb22
-rw-r--r--spec/models/blob_viewer/license_spec.rb18
-rw-r--r--spec/models/blob_viewer/package_json_spec.rb38
-rw-r--r--spec/models/blob_viewer/podspec_json_spec.rb10
-rw-r--r--spec/models/blob_viewer/podspec_spec.rb10
-rw-r--r--spec/models/blob_viewer/readme_spec.rb26
-rw-r--r--spec/models/blob_viewer/route_map_spec.rb20
-rw-r--r--spec/models/blob_viewer/server_side_spec.rb16
-rw-r--r--spec/models/board_group_recent_visit_spec.rb26
-rw-r--r--spec/models/board_project_recent_visit_spec.rb26
-rw-r--r--spec/models/board_spec.rb6
-rw-r--r--spec/models/broadcast_message_spec.rb56
-rw-r--r--spec/models/chat_name_spec.rb8
-rw-r--r--spec/models/chat_team_spec.rb2
-rw-r--r--spec/models/ci/artifact_blob_spec.rb56
-rw-r--r--spec/models/ci/bridge_spec.rb10
-rw-r--r--spec/models/ci/build_metadata_spec.rb28
-rw-r--r--spec/models/ci/build_runner_session_spec.rb22
-rw-r--r--spec/models/ci/build_spec.rb1721
-rw-r--r--spec/models/ci/build_trace_chunk_spec.rb324
-rw-r--r--spec/models/ci/build_trace_chunks/database_spec.rb56
-rw-r--r--spec/models/ci/build_trace_chunks/fog_spec.rb72
-rw-r--r--spec/models/ci/build_trace_chunks/redis_spec.rb60
-rw-r--r--spec/models/ci/build_trace_section_name_spec.rb2
-rw-r--r--spec/models/ci/build_trace_section_spec.rb2
-rw-r--r--spec/models/ci/group_spec.rb50
-rw-r--r--spec/models/ci/group_variable_spec.rb12
-rw-r--r--spec/models/ci/job_artifact_spec.rb126
-rw-r--r--spec/models/ci/legacy_stage_spec.rb142
-rw-r--r--spec/models/ci/pipeline_schedule_spec.rb50
-rw-r--r--spec/models/ci/pipeline_schedule_variable_spec.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb1383
-rw-r--r--spec/models/ci/pipeline_variable_spec.rb8
-rw-r--r--spec/models/ci/runner_spec.rb332
-rw-r--r--spec/models/ci/stage_spec.rb140
-rw-r--r--spec/models/ci/trigger_request_spec.rb10
-rw-r--r--spec/models/ci/trigger_spec.rb38
-rw-r--r--spec/models/ci/variable_spec.rb14
-rw-r--r--spec/models/clusters/applications/cert_manager_spec.rb50
-rw-r--r--spec/models/clusters/applications/helm_spec.rb24
-rw-r--r--spec/models/clusters/applications/ingress_spec.rb68
-rw-r--r--spec/models/clusters/applications/jupyter_spec.rb62
-rw-r--r--spec/models/clusters/applications/knative_spec.rb80
-rw-r--r--spec/models/clusters/applications/prometheus_spec.rb132
-rw-r--r--spec/models/clusters/applications/runner_spec.rb76
-rw-r--r--spec/models/clusters/cluster_spec.rb262
-rw-r--r--spec/models/clusters/group_spec.rb2
-rw-r--r--spec/models/clusters/kubernetes_namespace_spec.rb66
-rw-r--r--spec/models/clusters/platforms/kubernetes_spec.rb220
-rw-r--r--spec/models/clusters/project_spec.rb2
-rw-r--r--spec/models/clusters/providers/gcp_spec.rb88
-rw-r--r--spec/models/commit_collection_spec.rb44
-rw-r--r--spec/models/commit_range_spec.rb80
-rw-r--r--spec/models/commit_spec.rb310
-rw-r--r--spec/models/commit_status_spec.rb314
-rw-r--r--spec/models/compare_spec.rb54
-rw-r--r--spec/models/concerns/access_requestable_spec.rb14
-rw-r--r--spec/models/concerns/avatarable_spec.rb36
-rw-r--r--spec/models/concerns/awardable_spec.rb12
-rw-r--r--spec/models/concerns/batch_destroy_dependent_associations_spec.rb16
-rw-r--r--spec/models/concerns/blob_language_from_git_attributes_spec.rb14
-rw-r--r--spec/models/concerns/blocks_json_serialization_spec.rb10
-rw-r--r--spec/models/concerns/cache_markdown_field_spec.rb106
-rw-r--r--spec/models/concerns/cacheable_attributes_spec.rb108
-rw-r--r--spec/models/concerns/case_sensitivity_spec.rb38
-rw-r--r--spec/models/concerns/chronic_duration_attribute_spec.rb66
-rw-r--r--spec/models/concerns/deployable_spec.rb43
-rw-r--r--spec/models/concerns/deployment_platform_spec.rb58
-rw-r--r--spec/models/concerns/discussion_on_diff_spec.rb30
-rw-r--r--spec/models/concerns/each_batch_spec.rb26
-rw-r--r--spec/models/concerns/editable_spec.rb4
-rw-r--r--spec/models/concerns/expirable_spec.rb12
-rw-r--r--spec/models/concerns/faster_cache_keys_spec.rb8
-rw-r--r--spec/models/concerns/feature_gate_spec.rb10
-rw-r--r--spec/models/concerns/from_union_spec.rb14
-rw-r--r--spec/models/concerns/group_descendant_spec.rb80
-rw-r--r--spec/models/concerns/has_ref_spec.rb26
-rw-r--r--spec/models/concerns/has_status_spec.rb184
-rw-r--r--spec/models/concerns/has_variable_spec.rb44
-rw-r--r--spec/models/concerns/ignorable_column_spec.rb22
-rw-r--r--spec/models/concerns/issuable_spec.rb254
-rw-r--r--spec/models/concerns/loaded_in_group_list_spec.rb20
-rw-r--r--spec/models/concerns/manual_inverse_association_spec.rb22
-rw-r--r--spec/models/concerns/maskable_spec.rb50
-rw-r--r--spec/models/concerns/mentionable_spec.rb80
-rw-r--r--spec/models/concerns/milestoneish_spec.rb96
-rw-r--r--spec/models/concerns/noteable_spec.rb22
-rw-r--r--spec/models/concerns/optionally_search_spec.rb30
-rw-r--r--spec/models/concerns/participable_spec.rb20
-rw-r--r--spec/models/concerns/presentable_spec.rb10
-rw-r--r--spec/models/concerns/project_features_compatibility_spec.rb4
-rw-r--r--spec/models/concerns/prometheus_adapter_spec.rb32
-rw-r--r--spec/models/concerns/protected_ref_access_spec.rb10
-rw-r--r--spec/models/concerns/reactive_caching_spec.rb52
-rw-r--r--spec/models/concerns/redactable_spec.rb40
-rw-r--r--spec/models/concerns/redis_cacheable_spec.rb38
-rw-r--r--spec/models/concerns/relative_positioning_spec.rb74
-rw-r--r--spec/models/concerns/resolvable_discussion_spec.rb2
-rw-r--r--spec/models/concerns/resolvable_note_spec.rb42
-rw-r--r--spec/models/concerns/routable_spec.rb88
-rw-r--r--spec/models/concerns/sha_attribute_spec.rb34
-rw-r--r--spec/models/concerns/sortable_spec.rb88
-rw-r--r--spec/models/concerns/spammable_spec.rb24
-rw-r--r--spec/models/concerns/strip_attribute_spec.rb6
-rw-r--r--spec/models/concerns/subscribable_spec.rb62
-rw-r--r--spec/models/concerns/token_authenticatable_spec.rb164
-rw-r--r--spec/models/concerns/token_authenticatable_strategies/base_spec.rb36
-rw-r--r--spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb132
-rw-r--r--spec/models/concerns/triggerable_hooks_spec.rb36
-rw-r--r--spec/models/concerns/uniquify_spec.rb36
-rw-r--r--spec/models/container_repository_spec.rb160
-rw-r--r--spec/models/conversational_development_index/metric_spec.rb8
-rw-r--r--spec/models/cycle_analytics/code_spec.rb38
-rw-r--r--spec/models/cycle_analytics/issue_spec.rb37
-rw-r--r--spec/models/cycle_analytics/plan_spec.rb29
-rw-r--r--spec/models/cycle_analytics/production_spec.rb22
-rw-r--r--spec/models/cycle_analytics/review_spec.rb21
-rw-r--r--spec/models/cycle_analytics/staging_spec.rb48
-rw-r--r--spec/models/cycle_analytics/test_spec.rb17
-rw-r--r--spec/models/cycle_analytics_spec.rb12
-rw-r--r--spec/models/deploy_key_spec.rb16
-rw-r--r--spec/models/deploy_keys_project_spec.rb2
-rw-r--r--spec/models/deploy_token_spec.rb84
-rw-r--r--spec/models/deployment_spec.rb136
-rw-r--r--spec/models/diff_discussion_spec.rb58
-rw-r--r--spec/models/diff_note_spec.rb48
-rw-r--r--spec/models/diff_viewer/base_spec.rb100
-rw-r--r--spec/models/diff_viewer/server_side_spec.rb28
-rw-r--r--spec/models/discussion_spec.rb12
-rw-r--r--spec/models/email_spec.rb28
-rw-r--r--spec/models/environment_spec.rb424
-rw-r--r--spec/models/environment_status_spec.rb76
-rw-r--r--spec/models/error_tracking/project_error_tracking_setting_spec.rb168
-rw-r--r--spec/models/event_collection_spec.rb14
-rw-r--r--spec/models/event_spec.rb132
-rw-r--r--spec/models/external_issue_spec.rb40
-rw-r--r--spec/models/fork_network_member_spec.rb10
-rw-r--r--spec/models/fork_network_spec.rb22
-rw-r--r--spec/models/generic_commit_status_spec.rb36
-rw-r--r--spec/models/global_milestone_spec.rb104
-rw-r--r--spec/models/gpg_key_spec.rb104
-rw-r--r--spec/models/gpg_key_subkey_spec.rb6
-rw-r--r--spec/models/gpg_signature_spec.rb46
-rw-r--r--spec/models/group_custom_attribute_spec.rb6
-rw-r--r--spec/models/group_label_spec.rb38
-rw-r--r--spec/models/group_milestone_spec.rb34
-rw-r--r--spec/models/group_spec.rb319
-rw-r--r--spec/models/guest_spec.rb26
-rw-r--r--spec/models/hooks/active_hook_filter_spec.rb56
-rw-r--r--spec/models/hooks/project_hook_spec.rb14
-rw-r--r--spec/models/hooks/service_hook_spec.rb14
-rw-r--r--spec/models/hooks/system_hook_spec.rb52
-rw-r--r--spec/models/hooks/web_hook_log_spec.rb22
-rw-r--r--spec/models/hooks/web_hook_spec.rb60
-rw-r--r--spec/models/identity_spec.rb98
-rw-r--r--spec/models/import_export_upload_spec.rb16
-rw-r--r--spec/models/instance_configuration_spec.rb60
-rw-r--r--spec/models/internal_id_spec.rb84
-rw-r--r--spec/models/issue/metrics_spec.rb2
-rw-r--r--spec/models/issue_collection_spec.rb32
-rw-r--r--spec/models/issue_spec.rb360
-rw-r--r--spec/models/key_spec.rb46
-rw-r--r--spec/models/label_link_spec.rb2
-rw-r--r--spec/models/label_note_spec.rb10
-rw-r--r--spec/models/label_priority_spec.rb8
-rw-r--r--spec/models/label_spec.rb128
-rw-r--r--spec/models/legacy_diff_discussion_spec.rb16
-rw-r--r--spec/models/lfs_download_object_spec.rb50
-rw-r--r--spec/models/lfs_file_lock_spec.rb10
-rw-r--r--spec/models/lfs_object_spec.rb44
-rw-r--r--spec/models/lfs_objects_project_spec.rb14
-rw-r--r--spec/models/license_template_spec.rb42
-rw-r--r--spec/models/list_spec.rb40
-rw-r--r--spec/models/member_spec.rb130
-rw-r--r--spec/models/members/group_member_spec.rb38
-rw-r--r--spec/models/members/project_member_spec.rb49
-rw-r--r--spec/models/merge_request/metrics_spec.rb8
-rw-r--r--spec/models/merge_request_diff_commit_spec.rb28
-rw-r--r--spec/models/merge_request_diff_file_spec.rb20
-rw-r--r--spec/models/merge_request_diff_spec.rb146
-rw-r--r--spec/models/merge_request_spec.rb1304
-rw-r--r--spec/models/milestone_spec.rb216
-rw-r--r--spec/models/namespace_spec.rb348
-rw-r--r--spec/models/network/graph_spec.rb22
-rw-r--r--spec/models/note_diff_file_spec.rb6
-rw-r--r--spec/models/note_spec.rb258
-rw-r--r--spec/models/notification_recipient_spec.rb16
-rw-r--r--spec/models/notification_setting_spec.rb38
-rw-r--r--spec/models/pages_domain_spec.rb132
-rw-r--r--spec/models/personal_access_token_spec.rb36
-rw-r--r--spec/models/pool_repository_spec.rb20
-rw-r--r--spec/models/postgresql/replication_slot_spec.rb20
-rw-r--r--spec/models/programming_language_spec.rb2
-rw-r--r--spec/models/project_authorization_spec.rb10
-rw-r--r--spec/models/project_auto_devops_spec.rb118
-rw-r--r--spec/models/project_ci_cd_setting_spec.rb8
-rw-r--r--spec/models/project_custom_attribute_spec.rb6
-rw-r--r--spec/models/project_daily_statistic_spec.rb2
-rw-r--r--spec/models/project_deploy_token_spec.rb2
-rw-r--r--spec/models/project_feature_spec.rb44
-rw-r--r--spec/models/project_group_link_spec.rb2
-rw-r--r--spec/models/project_import_data_spec.rb40
-rw-r--r--spec/models/project_import_state_spec.rb46
-rw-r--r--spec/models/project_label_spec.rb76
-rw-r--r--spec/models/project_repository_spec.rb12
-rw-r--r--spec/models/project_services/asana_service_spec.rb68
-rw-r--r--spec/models/project_services/assembla_service_spec.rb8
-rw-r--r--spec/models/project_services/bamboo_service_spec.rb172
-rw-r--r--spec/models/project_services/bugzilla_service_spec.rb16
-rw-r--r--spec/models/project_services/buildkite_service_spec.rb72
-rw-r--r--spec/models/project_services/campfire_service_spec.rb30
-rw-r--r--spec/models/project_services/chat_message/issue_message_spec.rb104
-rw-r--r--spec/models/project_services/chat_message/merge_message_spec.rb92
-rw-r--r--spec/models/project_services/chat_message/note_message_spec.rb154
-rw-r--r--spec/models/project_services/chat_message/pipeline_message_spec.rb92
-rw-r--r--spec/models/project_services/chat_message/push_message_spec.rb181
-rw-r--r--spec/models/project_services/chat_message/wiki_page_message_spec.rb120
-rw-r--r--spec/models/project_services/chat_notification_service_spec.rb42
-rw-r--r--spec/models/project_services/custom_issue_tracker_service_spec.rb28
-rw-r--r--spec/models/project_services/discord_service_spec.rb2
-rw-r--r--spec/models/project_services/drone_ci_service_spec.rb52
-rw-r--r--spec/models/project_services/emails_on_push_service_spec.rb8
-rw-r--r--spec/models/project_services/external_wiki_service_spec.rb10
-rw-r--r--spec/models/project_services/flowdock_service_spec.rb12
-rw-r--r--spec/models/project_services/gitlab_issue_tracker_service_spec.rb20
-rw-r--r--spec/models/project_services/irker_service_spec.rb35
-rw-r--r--spec/models/project_services/issue_tracker_service_spec.rb16
-rw-r--r--spec/models/project_services/jira_service_spec.rb359
-rw-r--r--spec/models/project_services/kubernetes_service_spec.rb230
-rw-r--r--spec/models/project_services/mattermost_service_spec.rb2
-rw-r--r--spec/models/project_services/mattermost_slash_commands_service_spec.rb84
-rw-r--r--spec/models/project_services/microsoft_teams_service_spec.rb88
-rw-r--r--spec/models/project_services/packagist_service_spec.rb26
-rw-r--r--spec/models/project_services/pipelines_email_service_spec.rb104
-rw-r--r--spec/models/project_services/pivotaltracker_service_spec.rb64
-rw-r--r--spec/models/project_services/prometheus_service_spec.rb100
-rw-r--r--spec/models/project_services/pushover_service_spec.rb24
-rw-r--r--spec/models/project_services/redmine_service_spec.rb24
-rw-r--r--spec/models/project_services/slack_service_spec.rb2
-rw-r--r--spec/models/project_services/slack_slash_commands_service_spec.rb26
-rw-r--r--spec/models/project_services/teamcity_service_spec.rb146
-rw-r--r--spec/models/project_services/youtrack_service_spec.rb22
-rw-r--r--spec/models/project_snippet_spec.rb2
-rw-r--r--spec/models/project_spec.rb2152
-rw-r--r--spec/models/project_statistics_spec.rb32
-rw-r--r--spec/models/project_team_spec.rb99
-rw-r--r--spec/models/project_wiki_spec.rb99
-rw-r--r--spec/models/prometheus_metric_spec.rb74
-rw-r--r--spec/models/protectable_dropdown_spec.rb20
-rw-r--r--spec/models/protected_branch/merge_access_level_spec.rb2
-rw-r--r--spec/models/protected_branch/push_access_level_spec.rb2
-rw-r--r--spec/models/protected_branch_spec.rb42
-rw-r--r--spec/models/protected_tag_spec.rb6
-rw-r--r--spec/models/push_event_payload_spec.rb10
-rw-r--r--spec/models/push_event_spec.rb180
-rw-r--r--spec/models/redirect_route_spec.rb30
-rw-r--r--spec/models/release_spec.rb22
-rw-r--r--spec/models/releases/link_spec.rb70
-rw-r--r--spec/models/releases/source_spec.rb22
-rw-r--r--spec/models/remote_mirror_spec.rb232
-rw-r--r--spec/models/repository_language_spec.rb6
-rw-r--r--spec/models/repository_spec.rb1617
-rw-r--r--spec/models/resource_label_event_spec.rb50
-rw-r--r--spec/models/route_spec.rb238
-rw-r--r--spec/models/sent_notification_spec.rb144
-rw-r--r--spec/models/service_spec.rb171
-rw-r--r--spec/models/shard_spec.rb30
-rw-r--r--spec/models/snippet_blob_spec.rb30
-rw-r--r--spec/models/snippet_spec.rb212
-rw-r--r--spec/models/spam_log_spec.rb12
-rw-r--r--spec/models/ssh_host_key_spec.rb100
-rw-r--r--spec/models/subscription_spec.rb8
-rw-r--r--spec/models/suggestion_spec.rb22
-rw-r--r--spec/models/system_note_metadata_spec.rb14
-rw-r--r--spec/models/term_agreement_spec.rb8
-rw-r--r--spec/models/timelog_spec.rb20
-rw-r--r--spec/models/todo_spec.rb136
-rw-r--r--spec/models/tree_spec.rb38
-rw-r--r--spec/models/trending_project_spec.rb14
-rw-r--r--spec/models/upload_spec.rb70
-rw-r--r--spec/models/uploads/fog_spec.rb22
-rw-r--r--spec/models/uploads/local_spec.rb12
-rw-r--r--spec/models/user_agent_detail_spec.rb14
-rw-r--r--spec/models/user_callout_spec.rb8
-rw-r--r--spec/models/user_custom_attribute_spec.rb6
-rw-r--r--spec/models/user_interacted_project_spec.rb26
-rw-r--r--spec/models/user_preference_spec.rb40
-rw-r--r--spec/models/user_spec.rb1460
-rw-r--r--spec/models/user_status_spec.rb12
-rw-r--r--spec/models/wiki_directory_spec.rb32
-rw-r--r--spec/models/wiki_page_spec.rb270
-rw-r--r--spec/policies/application_setting/term_policy_spec.rb18
-rw-r--r--spec/policies/base_policy_spec.rb10
-rw-r--r--spec/policies/board_policy_spec.rb16
-rw-r--r--spec/policies/ci/build_policy_spec.rb120
-rw-r--r--spec/policies/ci/pipeline_policy_spec.rb48
-rw-r--r--spec/policies/ci/pipeline_schedule_policy_spec.rb44
-rw-r--r--spec/policies/ci/trigger_policy_spec.rb56
-rw-r--r--spec/policies/clusters/cluster_policy_spec.rb18
-rw-r--r--spec/policies/concerns/policy_actor_spec.rb4
-rw-r--r--spec/policies/deploy_key_policy_spec.rb18
-rw-r--r--spec/policies/deploy_token_policy_spec.rb14
-rw-r--r--spec/policies/environment_policy_spec.rb28
-rw-r--r--spec/policies/global_policy_spec.rb62
-rw-r--r--spec/policies/group_policy_spec.rb96
-rw-r--r--spec/policies/issuable_policy_spec.rb28
-rw-r--r--spec/policies/issue_policy_spec.rb54
-rw-r--r--spec/policies/namespace_policy_spec.rb12
-rw-r--r--spec/policies/note_policy_spec.rb66
-rw-r--r--spec/policies/personal_snippet_policy_spec.rb36
-rw-r--r--spec/policies/project_policy_spec.rb152
-rw-r--r--spec/policies/project_snippet_policy_spec.rb36
-rw-r--r--spec/policies/protected_branch_policy_spec.rb6
-rw-r--r--spec/policies/user_policy_spec.rb10
-rw-r--r--spec/presenters/blob_presenter_spec.rb26
-rw-r--r--spec/presenters/ci/build_presenter_spec.rb154
-rw-r--r--spec/presenters/ci/build_runner_presenter_spec.rb90
-rw-r--r--spec/presenters/ci/group_variable_presenter_spec.rb22
-rw-r--r--spec/presenters/ci/pipeline_presenter_spec.rb38
-rw-r--r--spec/presenters/ci/trigger_presenter_spec.rb26
-rw-r--r--spec/presenters/ci/variable_presenter_spec.rb22
-rw-r--r--spec/presenters/clusterable_presenter_spec.rb32
-rw-r--r--spec/presenters/clusters/cluster_presenter_spec.rb108
-rw-r--r--spec/presenters/commit_presenter_spec.rb28
-rw-r--r--spec/presenters/commit_status_presenter_spec.rb10
-rw-r--r--spec/presenters/conversational_development_index/metric_presenter_spec.rb16
-rw-r--r--spec/presenters/group_clusterable_presenter_spec.rb22
-rw-r--r--spec/presenters/group_member_presenter_spec.rb46
-rw-r--r--spec/presenters/merge_request_presenter_spec.rb178
-rw-r--r--spec/presenters/project_clusterable_presenter_spec.rb22
-rw-r--r--spec/presenters/project_member_presenter_spec.rb44
-rw-r--r--spec/presenters/project_presenter_spec.rb256
-rw-r--r--spec/presenters/projects/settings/deploy_keys_presenter_spec.rb24
-rw-r--r--spec/rack_servers/configs/config.ru8
-rw-r--r--spec/rack_servers/configs/puma.rb8
-rw-r--r--spec/rack_servers/puma_spec.rb32
-rw-r--r--spec/rack_servers/unicorn_spec.rb34
-rw-r--r--spec/rake_helper.rb6
-rw-r--r--spec/requests/api/access_requests_spec.rb158
-rw-r--r--spec/requests/api/applications_spec.rb132
-rw-r--r--spec/requests/api/avatar_spec.rb79
-rw-r--r--spec/requests/api/award_emoji_spec.rb164
-rw-r--r--spec/requests/api/badges_spec.rb208
-rw-r--r--spec/requests/api/boards_spec.rb34
-rw-r--r--spec/requests/api/branches_spec.rb462
-rw-r--r--spec/requests/api/broadcast_messages_spec.rb114
-rw-r--r--spec/requests/api/circuit_breakers_spec.rb28
-rw-r--r--spec/requests/api/commit_statuses_spec.rb232
-rw-r--r--spec/requests/api/commits_spec.rb1128
-rw-r--r--spec/requests/api/container_registry_spec.rb114
-rw-r--r--spec/requests/api/deploy_keys_spec.rb168
-rw-r--r--spec/requests/api/deployments_spec.rb62
-rw-r--r--spec/requests/api/discussions_spec.rb24
-rw-r--r--spec/requests/api/doorkeeper_access_spec.rb20
-rw-r--r--spec/requests/api/environments_spec.rb114
-rw-r--r--spec/requests/api/events_spec.rb166
-rw-r--r--spec/requests/api/features_spec.rb320
-rw-r--r--spec/requests/api/files_spec.rb276
-rw-r--r--spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb34
-rw-r--r--spec/requests/api/graphql/project/issues_spec.rb54
-rw-r--r--spec/requests/api/graphql/project/merge_request_spec.rb56
-rw-r--r--spec/requests/api/graphql/project_query_spec.rb28
-rw-r--r--spec/requests/api/group_boards_spec.rb18
-rw-r--r--spec/requests/api/group_labels_spec.rb204
-rw-r--r--spec/requests/api/group_milestones_spec.rb8
-rw-r--r--spec/requests/api/group_variables_spec.rb126
-rw-r--r--spec/requests/api/groups_spec.rb376
-rw-r--r--spec/requests/api/helpers_spec.rb208
-rw-r--r--spec/requests/api/import_github_spec.rb22
-rw-r--r--spec/requests/api/internal_spec.rb466
-rw-r--r--spec/requests/api/issues_spec.rb1320
-rw-r--r--spec/requests/api/jobs_spec.rb576
-rw-r--r--spec/requests/api/keys_spec.rb26
-rw-r--r--spec/requests/api/labels_spec.rb434
-rw-r--r--spec/requests/api/lint_spec.rb40
-rw-r--r--spec/requests/api/markdown_spec.rb74
-rw-r--r--spec/requests/api/members_spec.rb250
-rw-r--r--spec/requests/api/merge_request_diffs_spec.rb34
-rw-r--r--spec/requests/api/merge_requests_spec.rb790
-rw-r--r--spec/requests/api/namespaces_spec.rb104
-rw-r--r--spec/requests/api/notes_spec.rb46
-rw-r--r--spec/requests/api/notification_settings_spec.rb32
-rw-r--r--spec/requests/api/oauth_tokens_spec.rb20
-rw-r--r--spec/requests/api/pages/internal_access_spec.rb6
-rw-r--r--spec/requests/api/pages/private_access_spec.rb6
-rw-r--r--spec/requests/api/pages/public_access_spec.rb6
-rw-r--r--spec/requests/api/pages_domains_spec.rb272
-rw-r--r--spec/requests/api/pipeline_schedules_spec.rb248
-rw-r--r--spec/requests/api/pipelines_spec.rb358
-rw-r--r--spec/requests/api/project_clusters_spec.rb306
-rw-r--r--spec/requests/api/project_export_spec.rb208
-rw-r--r--spec/requests/api/project_hooks_spec.rb146
-rw-r--r--spec/requests/api/project_import_spec.rb148
-rw-r--r--spec/requests/api/project_milestones_spec.rb44
-rw-r--r--spec/requests/api/project_snapshots_spec.rb26
-rw-r--r--spec/requests/api/project_snippets_spec.rb152
-rw-r--r--spec/requests/api/project_statistics_spec.rb34
-rw-r--r--spec/requests/api/project_templates_spec.rb110
-rw-r--r--spec/requests/api/projects_spec.rb1461
-rw-r--r--spec/requests/api/protected_branches_spec.rb168
-rw-r--r--spec/requests/api/protected_tags_spec.rb132
-rw-r--r--spec/requests/api/release/links_spec.rb216
-rw-r--r--spec/requests/api/releases_spec.rb443
-rw-r--r--spec/requests/api/repositories_spec.rb390
-rw-r--r--spec/requests/api/resource_label_events_spec.rb16
-rw-r--r--spec/requests/api/runner_spec.rb1162
-rw-r--r--spec/requests/api/runners_spec.rb552
-rw-r--r--spec/requests/api/search_spec.rb252
-rw-r--r--spec/requests/api/services_spec.rb60
-rw-r--r--spec/requests/api/settings_spec.rb114
-rw-r--r--spec/requests/api/sidekiq_metrics_spec.rb28
-rw-r--r--spec/requests/api/snippets_spec.rb196
-rw-r--r--spec/requests/api/submodules_spec.rb54
-rw-r--r--spec/requests/api/suggestions_spec.rb30
-rw-r--r--spec/requests/api/system_hooks_spec.rb64
-rw-r--r--spec/requests/api/tags_spec.rb382
-rw-r--r--spec/requests/api/templates_spec.rb172
-rw-r--r--spec/requests/api/todos_spec.rb152
-rw-r--r--spec/requests/api/triggers_spec.rb216
-rw-r--r--spec/requests/api/users_spec.rb1088
-rw-r--r--spec/requests/api/variables_spec.rb124
-rw-r--r--spec/requests/api/version_spec.rb20
-rw-r--r--spec/requests/api/wikis_spec.rb428
-rw-r--r--spec/requests/git_http_spec.rb324
-rw-r--r--spec/requests/jwt_controller_spec.rb102
-rw-r--r--spec/requests/lfs_http_spec.rb824
-rw-r--r--spec/requests/lfs_locks_api_spec.rb98
-rw-r--r--spec/requests/oauth_tokens_spec.rb44
-rw-r--r--spec/requests/openid_connect_spec.rb150
-rw-r--r--spec/requests/projects/cycle_analytics_events_spec.rb66
-rw-r--r--spec/requests/rack_attack_global_spec.rb108
-rw-r--r--spec/requests/request_profiler_spec.rb16
-rw-r--r--spec/requests/user_activity_spec.rb64
-rw-r--r--spec/routing/admin_routing_spec.rb68
-rw-r--r--spec/routing/api_routing_spec.rb24
-rw-r--r--spec/routing/environments_spec.rb38
-rw-r--r--spec/routing/group_routing_spec.rb106
-rw-r--r--spec/routing/import_routing_spec.rb90
-rw-r--r--spec/routing/instance_statistics_routing_spec.rb6
-rw-r--r--spec/routing/openid_connect_spec.rb16
-rw-r--r--spec/routing/project_routing_spec.rb585
-rw-r--r--spec/routing/routing_spec.rb148
-rw-r--r--spec/rubocop/code_reuse_helpers_spec.rb166
-rw-r--r--spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb12
-rw-r--r--spec/rubocop/cop/avoid_return_from_blocks_spec.rb20
-rw-r--r--spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb12
-rw-r--r--spec/rubocop/cop/code_reuse/active_record_spec.rb132
-rw-r--r--spec/rubocop/cop/code_reuse/finder_spec.rb16
-rw-r--r--spec/rubocop/cop/code_reuse/presenter_spec.rb22
-rw-r--r--spec/rubocop/cop/code_reuse/serializer_spec.rb22
-rw-r--r--spec/rubocop/cop/code_reuse/service_class_spec.rb18
-rw-r--r--spec/rubocop/cop/code_reuse/worker_spec.rb20
-rw-r--r--spec/rubocop/cop/destroy_all_spec.rb30
-rw-r--r--spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb28
-rw-r--r--spec/rubocop/cop/gitlab/httparty_spec.rb28
-rw-r--r--spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb48
-rw-r--r--spec/rubocop/cop/gitlab/predicate_memoization_spec.rb34
-rw-r--r--spec/rubocop/cop/gitlab/union_spec.rb18
-rw-r--r--spec/rubocop/cop/group_public_or_visible_to_user_spec.rb20
-rw-r--r--spec/rubocop/cop/include_sidekiq_worker_spec.rb20
-rw-r--r--spec/rubocop/cop/inject_enterprise_edition_module_spec.rb175
-rw-r--r--spec/rubocop/cop/line_break_around_conditional_block_spec.rb323
-rw-r--r--spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb20
-rw-r--r--spec/rubocop/cop/migration/add_concurrent_index_spec.rb24
-rw-r--r--spec/rubocop/cop/migration/add_reference_spec.rb22
-rw-r--r--spec/rubocop/cop/migration/add_timestamps_spec.rb26
-rw-r--r--spec/rubocop/cop/migration/datetime_spec.rb34
-rw-r--r--spec/rubocop/cop/migration/hash_index_spec.rb28
-rw-r--r--spec/rubocop/cop/migration/remove_column_spec.rb32
-rw-r--r--spec/rubocop/cop/migration/remove_concurrent_index_spec.rb24
-rw-r--r--spec/rubocop/cop/migration/remove_index_spec.rb20
-rw-r--r--spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb24
-rw-r--r--spec/rubocop/cop/migration/safer_boolean_column_spec.rb38
-rw-r--r--spec/rubocop/cop/migration/timestamps_spec.rb26
-rw-r--r--spec/rubocop/cop/migration/update_column_in_batches_spec.rb50
-rw-r--r--spec/rubocop/cop/migration/update_large_table_spec.rb42
-rw-r--r--spec/rubocop/cop/prefer_class_methods_over_module_spec.rb12
-rw-r--r--spec/rubocop/cop/project_path_helper_spec.rb24
-rw-r--r--spec/rubocop/cop/qa/element_with_pattern_spec.rb14
-rw-r--r--spec/rubocop/cop/rspec/env_assignment_spec.rb30
-rw-r--r--spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb22
-rw-r--r--spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb22
-rw-r--r--spec/rubocop/cop/safe_params_spec.rb16
-rw-r--r--spec/rubocop/cop/sidekiq_options_queue_spec.rb14
-rw-r--r--spec/rubocop/qa_helpers_spec.rb22
-rw-r--r--spec/serializers/analytics_build_entity_spec.rb50
-rw-r--r--spec/serializers/analytics_build_serializer_spec.rb6
-rw-r--r--spec/serializers/analytics_issue_entity_spec.rb12
-rw-r--r--spec/serializers/analytics_issue_serializer_spec.rb8
-rw-r--r--spec/serializers/analytics_merge_request_serializer_spec.rb10
-rw-r--r--spec/serializers/analytics_stage_serializer_spec.rb6
-rw-r--r--spec/serializers/analytics_summary_serializer_spec.rb6
-rw-r--r--spec/serializers/blob_entity_spec.rb10
-rw-r--r--spec/serializers/build_action_entity_spec.rb26
-rw-r--r--spec/serializers/build_artifact_entity_spec.rb14
-rw-r--r--spec/serializers/build_details_entity_spec.rb42
-rw-r--r--spec/serializers/build_serializer_spec.rb34
-rw-r--r--spec/serializers/cluster_application_entity_spec.rb34
-rw-r--r--spec/serializers/cluster_entity_spec.rb24
-rw-r--r--spec/serializers/cluster_serializer_spec.rb12
-rw-r--r--spec/serializers/commit_entity_spec.rb42
-rw-r--r--spec/serializers/container_repository_entity_spec.rb14
-rw-r--r--spec/serializers/container_tag_entity_spec.rb18
-rw-r--r--spec/serializers/deploy_key_entity_spec.rb16
-rw-r--r--spec/serializers/deployment_entity_spec.rb38
-rw-r--r--spec/serializers/deployment_serializer_spec.rb20
-rw-r--r--spec/serializers/detailed_status_entity_spec.rb12
-rw-r--r--spec/serializers/diff_file_entity_spec.rb26
-rw-r--r--spec/serializers/diff_line_entity_spec.rb20
-rw-r--r--spec/serializers/diff_line_serializer_spec.rb22
-rw-r--r--spec/serializers/diff_viewer_entity_spec.rb6
-rw-r--r--spec/serializers/diffs_entity_spec.rb6
-rw-r--r--spec/serializers/discussion_diff_file_entity_spec.rb16
-rw-r--r--spec/serializers/discussion_entity_spec.rb20
-rw-r--r--spec/serializers/entity_date_helper_spec.rb44
-rw-r--r--spec/serializers/entity_request_spec.rb14
-rw-r--r--spec/serializers/environment_entity_spec.rb38
-rw-r--r--spec/serializers/environment_serializer_spec.rb130
-rw-r--r--spec/serializers/environment_status_entity_spec.rb20
-rw-r--r--spec/serializers/group_child_entity_spec.rb46
-rw-r--r--spec/serializers/group_child_serializer_spec.rb34
-rw-r--r--spec/serializers/group_variable_entity_spec.rb6
-rw-r--r--spec/serializers/issue_board_entity_spec.rb20
-rw-r--r--spec/serializers/issue_entity_spec.rb10
-rw-r--r--spec/serializers/issue_serializer_spec.rb32
-rw-r--r--spec/serializers/job_entity_spec.rb120
-rw-r--r--spec/serializers/label_serializer_spec.rb18
-rw-r--r--spec/serializers/lfs_file_lock_entity_spec.rb8
-rw-r--r--spec/serializers/merge_request_diff_entity_spec.rb6
-rw-r--r--spec/serializers/merge_request_serializer_spec.rb40
-rw-r--r--spec/serializers/merge_request_user_entity_spec.rb6
-rw-r--r--spec/serializers/merge_request_widget_commit_entity_spec.rb6
-rw-r--r--spec/serializers/merge_request_widget_entity_spec.rb136
-rw-r--r--spec/serializers/move_to_project_entity_spec.rb8
-rw-r--r--spec/serializers/move_to_project_serializer_spec.rb6
-rw-r--r--spec/serializers/namespace_basic_entity_spec.rb6
-rw-r--r--spec/serializers/namespace_serializer_spec.rb4
-rw-r--r--spec/serializers/note_entity_spec.rb6
-rw-r--r--spec/serializers/pipeline_details_entity_spec.rb56
-rw-r--r--spec/serializers/pipeline_entity_spec.rb48
-rw-r--r--spec/serializers/pipeline_serializer_spec.rb79
-rw-r--r--spec/serializers/project_import_entity_spec.rb10
-rw-r--r--spec/serializers/project_mirror_entity_spec.rb4
-rw-r--r--spec/serializers/project_mirror_serializer_spec.rb4
-rw-r--r--spec/serializers/project_note_entity_spec.rb12
-rw-r--r--spec/serializers/project_serializer_spec.rb16
-rw-r--r--spec/serializers/provider_repo_entity_spec.rb10
-rw-r--r--spec/serializers/provider_repo_serializer_spec.rb4
-rw-r--r--spec/serializers/remote_mirror_entity_spec.rb4
-rw-r--r--spec/serializers/request_aware_entity_spec.rb12
-rw-r--r--spec/serializers/runner_entity_spec.rb8
-rw-r--r--spec/serializers/stage_entity_spec.rb38
-rw-r--r--spec/serializers/suggestion_entity_spec.rb10
-rw-r--r--spec/serializers/test_case_entity_spec.rb20
-rw-r--r--spec/serializers/test_reports_comparer_entity_spec.rb72
-rw-r--r--spec/serializers/test_reports_comparer_serializer_spec.rb48
-rw-r--r--spec/serializers/test_suite_comparer_entity_spec.rb24
-rw-r--r--spec/serializers/trigger_variable_entity_spec.rb22
-rw-r--r--spec/serializers/user_entity_spec.rb12
-rw-r--r--spec/serializers/variable_entity_spec.rb6
-rw-r--r--spec/services/access_token_validation_service_spec.rb4
-rw-r--r--spec/services/after_branch_delete_service_spec.rb8
-rw-r--r--spec/services/application_settings/update_service_spec.rb88
-rw-r--r--spec/services/audit_event_service_spec.rb8
-rw-r--r--spec/services/auth/container_registry_authentication_service_spec.rb574
-rw-r--r--spec/services/base_count_service_spec.rb42
-rw-r--r--spec/services/boards/create_service_spec.rb12
-rw-r--r--spec/services/boards/issues/create_service_spec.rb14
-rw-r--r--spec/services/boards/issues/list_service_spec.rb72
-rw-r--r--spec/services/boards/issues/move_service_spec.rb28
-rw-r--r--spec/services/boards/list_service_spec.rb12
-rw-r--r--spec/services/boards/lists/create_service_spec.rb40
-rw-r--r--spec/services/boards/lists/destroy_service_spec.rb12
-rw-r--r--spec/services/boards/lists/generate_service_spec.rb22
-rw-r--r--spec/services/boards/lists/list_service_spec.rb12
-rw-r--r--spec/services/boards/lists/move_service_spec.rb12
-rw-r--r--spec/services/boards/visits/create_service_spec.rb18
-rw-r--r--spec/services/boards/visits/latest_service_spec.rb16
-rw-r--r--spec/services/chat_names/authorize_user_service_spec.rb14
-rw-r--r--spec/services/chat_names/find_user_service_spec.rb22
-rw-r--r--spec/services/ci/archive_trace_service_spec.rb22
-rw-r--r--spec/services/ci/compare_test_reports_service_spec.rb36
-rw-r--r--spec/services/ci/create_pipeline_service_spec.rb539
-rw-r--r--spec/services/ci/destroy_expired_job_artifacts_service_spec.rb50
-rw-r--r--spec/services/ci/destroy_pipeline_service_spec.rb22
-rw-r--r--spec/services/ci/ensure_stage_service_spec.rb24
-rw-r--r--spec/services/ci/extract_sections_from_build_trace_service_spec.rb28
-rw-r--r--spec/services/ci/pipeline_trigger_service_spec.rb50
-rw-r--r--spec/services/ci/play_build_service_spec.rb42
-rw-r--r--spec/services/ci/process_build_service_spec.rb95
-rw-r--r--spec/services/ci/process_pipeline_service_spec.rb456
-rw-r--r--spec/services/ci/register_job_service_spec.rb236
-rw-r--r--spec/services/ci/retry_build_service_spec.rb64
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb234
-rw-r--r--spec/services/ci/run_scheduled_build_service_spec.rb26
-rw-r--r--spec/services/ci/stop_environments_service_spec.rb68
-rw-r--r--spec/services/ci/update_build_queue_service_spec.rb40
-rw-r--r--spec/services/ci/update_runner_service_spec.rb18
-rw-r--r--spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb18
-rw-r--r--spec/services/clusters/applications/check_installation_progress_service_spec.rb78
-rw-r--r--spec/services/clusters/applications/create_service_spec.rb132
-rw-r--r--spec/services/clusters/applications/install_service_spec.rb58
-rw-r--r--spec/services/clusters/applications/upgrade_service_spec.rb60
-rw-r--r--spec/services/clusters/build_service_spec.rb12
-rw-r--r--spec/services/clusters/create_service_spec.rb44
-rw-r--r--spec/services/clusters/gcp/fetch_operation_service_spec.rb20
-rw-r--r--spec/services/clusters/gcp/finalize_creation_service_spec.rb88
-rw-r--r--spec/services/clusters/gcp/kubernetes/create_or_update_namespace_service_spec.rb66
-rw-r--r--spec/services/clusters/gcp/kubernetes/create_or_update_service_account_service_spec.rb93
-rw-r--r--spec/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service_spec.rb24
-rw-r--r--spec/services/clusters/gcp/provision_service_spec.rb38
-rw-r--r--spec/services/clusters/gcp/verify_provision_status_service_spec.rb71
-rw-r--r--spec/services/clusters/refresh_service_spec.rb50
-rw-r--r--spec/services/clusters/update_service_spec.rb52
-rw-r--r--spec/services/cohorts_service_spec.rb56
-rw-r--r--spec/services/commits/commit_patch_service_spec.rb55
-rw-r--r--spec/services/commits/tag_service_spec.rb44
-rw-r--r--spec/services/compare_service_spec.rb14
-rw-r--r--spec/services/create_branch_service_spec.rb18
-rw-r--r--spec/services/create_snippet_service_spec.rb16
-rw-r--r--spec/services/delete_branch_service_spec.rb26
-rw-r--r--spec/services/delete_merged_branches_service_spec.rb52
-rw-r--r--spec/services/deploy_keys/create_service_spec.rb2
-rw-r--r--spec/services/deploy_tokens/create_service_spec.rb24
-rw-r--r--spec/services/discussions/resolve_service_spec.rb12
-rw-r--r--spec/services/discussions/update_diff_position_service_spec.rb23
-rw-r--r--spec/services/emails/confirm_service_spec.rb10
-rw-r--r--spec/services/emails/create_service_spec.rb16
-rw-r--r--spec/services/emails/destroy_service_spec.rb6
-rw-r--r--spec/services/error_tracking/list_issues_service_spec.rb47
-rw-r--r--spec/services/error_tracking/list_projects_service_spec.rb58
-rw-r--r--spec/services/event_create_service_spec.rb58
-rw-r--r--spec/services/events/render_service_spec.rb14
-rw-r--r--spec/services/files/create_service_spec.rb34
-rw-r--r--spec/services/files/delete_service_spec.rb18
-rw-r--r--spec/services/files/multi_service_spec.rb122
-rw-r--r--spec/services/files/update_service_spec.rb10
-rw-r--r--spec/services/git_push_service_spec.rb206
-rw-r--r--spec/services/git_tag_push_service_spec.rb50
-rw-r--r--spec/services/gpg_keys/create_service_spec.rb12
-rw-r--r--spec/services/gravatar_service_spec.rb12
-rw-r--r--spec/services/groups/create_service_spec.rb40
-rw-r--r--spec/services/groups/destroy_service_spec.rb58
-rw-r--r--spec/services/groups/nested_create_service_spec.rb50
-rw-r--r--spec/services/groups/transfer_service_spec.rb156
-rw-r--r--spec/services/groups/update_service_spec.rb30
-rw-r--r--spec/services/import_export_clean_up_service_spec.rb36
-rw-r--r--spec/services/issuable/bulk_update_service_spec.rb146
-rw-r--r--spec/services/issuable/clone/attributes_rewriter_spec.rb36
-rw-r--r--spec/services/issuable/clone/content_rewriter_spec.rb62
-rw-r--r--spec/services/issuable/common_system_notes_service_spec.rb52
-rw-r--r--spec/services/issuable/destroy_service_spec.rb24
-rw-r--r--spec/services/issues/build_service_spec.rb80
-rw-r--r--spec/services/issues/close_service_spec.rb38
-rw-r--r--spec/services/issues/create_service_spec.rb196
-rw-r--r--spec/services/issues/duplicate_service_spec.rb24
-rw-r--r--spec/services/issues/import_csv_service_spec.rb28
-rw-r--r--spec/services/issues/move_service_spec.rb84
-rw-r--r--spec/services/issues/referenced_merge_requests_service_spec.rb50
-rw-r--r--spec/services/issues/related_branches_service_spec.rb16
-rw-r--r--spec/services/issues/reopen_service_spec.rb22
-rw-r--r--spec/services/issues/resolve_discussions_spec.rb15
-rw-r--r--spec/services/issues/update_service_spec.rb271
-rw-r--r--spec/services/keys/create_service_spec.rb8
-rw-r--r--spec/services/keys/destroy_service_spec.rb4
-rw-r--r--spec/services/keys/last_used_service_spec.rb20
-rw-r--r--spec/services/labels/create_service_spec.rb98
-rw-r--r--spec/services/labels/find_or_create_service_spec.rb68
-rw-r--r--spec/services/labels/promote_service_spec.rb48
-rw-r--r--spec/services/labels/transfer_service_spec.rb26
-rw-r--r--spec/services/labels/update_service_spec.rb46
-rw-r--r--spec/services/lfs/file_transformer_spec.rb52
-rw-r--r--spec/services/lfs/lock_file_service_spec.rb26
-rw-r--r--spec/services/lfs/locks_finder_service_spec.rb50
-rw-r--r--spec/services/lfs/unlock_file_service_spec.rb36
-rw-r--r--spec/services/members/approve_access_request_service_spec.rb58
-rw-r--r--spec/services/members/create_service_spec.rb20
-rw-r--r--spec/services/members/destroy_service_spec.rb124
-rw-r--r--spec/services/members/request_access_service_spec.rb28
-rw-r--r--spec/services/members/update_service_spec.rb30
-rw-r--r--spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb56
-rw-r--r--spec/services/merge_requests/assign_issues_service_spec.rb24
-rw-r--r--spec/services/merge_requests/build_service_spec.rb228
-rw-r--r--spec/services/merge_requests/close_service_spec.rb28
-rw-r--r--spec/services/merge_requests/conflicts/list_service_spec.rb56
-rw-r--r--spec/services/merge_requests/conflicts/resolve_service_spec.rb171
-rw-r--r--spec/services/merge_requests/create_from_issue_service_spec.rb52
-rw-r--r--spec/services/merge_requests/create_service_spec.rb220
-rw-r--r--spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb12
-rw-r--r--spec/services/merge_requests/ff_merge_service_spec.rb30
-rw-r--r--spec/services/merge_requests/get_urls_service_spec.rb70
-rw-r--r--spec/services/merge_requests/merge_service_spec.rb120
-rw-r--r--spec/services/merge_requests/merge_to_ref_service_spec.rb72
-rw-r--r--spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb52
-rw-r--r--spec/services/merge_requests/post_merge_service_spec.rb20
-rw-r--r--spec/services/merge_requests/rebase_service_spec.rb65
-rw-r--r--spec/services/merge_requests/refresh_service_spec.rb426
-rw-r--r--spec/services/merge_requests/reload_diffs_service_spec.rb20
-rw-r--r--spec/services/merge_requests/reopen_service_spec.rb28
-rw-r--r--spec/services/merge_requests/resolved_discussion_notification_service_spec.rb2
-rw-r--r--spec/services/merge_requests/squash_service_spec.rb96
-rw-r--r--spec/services/merge_requests/update_service_spec.rb278
-rw-r--r--spec/services/milestones/close_service_spec.rb8
-rw-r--r--spec/services/milestones/create_service_spec.rb10
-rw-r--r--spec/services/milestones/destroy_service_spec.rb20
-rw-r--r--spec/services/milestones/promote_service_spec.rb30
-rw-r--r--spec/services/milestones/update_service_spec.rb21
-rw-r--r--spec/services/note_summary_spec.rb32
-rw-r--r--spec/services/notes/build_service_spec.rb100
-rw-r--r--spec/services/notes/create_service_spec.rb128
-rw-r--r--spec/services/notes/destroy_service_spec.rb14
-rw-r--r--spec/services/notes/post_process_service_spec.rb12
-rw-r--r--spec/services/notes/quick_actions_service_spec.rb82
-rw-r--r--spec/services/notes/render_service_spec.rb26
-rw-r--r--spec/services/notes/resolve_service_spec.rb4
-rw-r--r--spec/services/notes/update_service_spec.rb26
-rw-r--r--spec/services/notification_recipient_service_spec.rb24
-rw-r--r--spec/services/notification_service_spec.rb594
-rw-r--r--spec/services/preview_markdown_service_spec.rb58
-rw-r--r--spec/services/projects/after_import_service_spec.rb14
-rw-r--r--spec/services/projects/after_rename_service_spec.rb62
-rw-r--r--spec/services/projects/auto_devops/disable_service_spec.rb33
-rw-r--r--spec/services/projects/autocomplete_service_spec.rb56
-rw-r--r--spec/services/projects/batch_open_issues_count_service_spec.rb12
-rw-r--r--spec/services/projects/cleanup_service_spec.rb16
-rw-r--r--spec/services/projects/container_repository/cleanup_tags_service_spec.rb117
-rw-r--r--spec/services/projects/container_repository/destroy_service_spec.rb12
-rw-r--r--spec/services/projects/count_service_spec.rb42
-rw-r--r--spec/services/projects/create_from_template_service_spec.rb36
-rw-r--r--spec/services/projects/create_service_spec.rb150
-rw-r--r--spec/services/projects/destroy_service_spec.rb142
-rw-r--r--spec/services/projects/detect_repository_languages_service_spec.rb24
-rw-r--r--spec/services/projects/download_service_spec.rb32
-rw-r--r--spec/services/projects/enable_deploy_key_service_spec.rb20
-rw-r--r--spec/services/projects/fetch_statistics_increment_service_spec.rb10
-rw-r--r--spec/services/projects/fork_service_spec.rb118
-rw-r--r--spec/services/projects/forks_count_service_spec.rb6
-rw-r--r--spec/services/projects/gitlab_projects_import_service_spec.rb12
-rw-r--r--spec/services/projects/group_links/create_service_spec.rb12
-rw-r--r--spec/services/projects/group_links/destroy_service_spec.rb8
-rw-r--r--spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb32
-rw-r--r--spec/services/projects/hashed_storage/migrate_repository_service_spec.rb30
-rw-r--r--spec/services/projects/hashed_storage/migration_service_spec.rb24
-rw-r--r--spec/services/projects/housekeeping_service_spec.rb44
-rw-r--r--spec/services/projects/import_error_filter_spec.rb14
-rw-r--r--spec/services/projects/import_export/export_service_spec.rb46
-rw-r--r--spec/services/projects/import_service_spec.rb108
-rw-r--r--spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb64
-rw-r--r--spec/services/projects/lfs_pointers/lfs_download_service_spec.rb98
-rw-r--r--spec/services/projects/lfs_pointers/lfs_import_service_spec.rb56
-rw-r--r--spec/services/projects/lfs_pointers/lfs_link_service_spec.rb10
-rw-r--r--spec/services/projects/move_access_service_spec.rb30
-rw-r--r--spec/services/projects/move_deploy_keys_projects_service_spec.rb16
-rw-r--r--spec/services/projects/move_forks_service_spec.rb26
-rw-r--r--spec/services/projects/move_lfs_objects_projects_service_spec.rb16
-rw-r--r--spec/services/projects/move_notification_settings_service_spec.rb18
-rw-r--r--spec/services/projects/move_project_authorizations_service_spec.rb14
-rw-r--r--spec/services/projects/move_project_group_links_service_spec.rb16
-rw-r--r--spec/services/projects/move_project_members_service_spec.rb16
-rw-r--r--spec/services/projects/move_users_star_projects_service_spec.rb8
-rw-r--r--spec/services/projects/open_issues_count_service_spec.rb36
-rw-r--r--spec/services/projects/open_merge_requests_count_service_spec.rb12
-rw-r--r--spec/services/projects/operations/update_service_spec.rb44
-rw-r--r--spec/services/projects/overwrite_project_service_spec.rb54
-rw-r--r--spec/services/projects/participants_service_spec.rb14
-rw-r--r--spec/services/projects/propagate_service_template_spec.rb53
-rw-r--r--spec/services/projects/protect_default_branch_service_spec.rb90
-rw-r--r--spec/services/projects/transfer_service_spec.rb92
-rw-r--r--spec/services/projects/unlink_fork_service_spec.rb22
-rw-r--r--spec/services/projects/update_pages_configuration_service_spec.rb12
-rw-r--r--spec/services/projects/update_pages_service_spec.rb98
-rw-r--r--spec/services/projects/update_remote_mirror_service_spec.rb14
-rw-r--r--spec/services/projects/update_service_spec.rb201
-rw-r--r--spec/services/prometheus/adapter_service_spec.rb24
-rw-r--r--spec/services/protected_branches/create_service_spec.rb24
-rw-r--r--spec/services/protected_branches/destroy_service_spec.rb12
-rw-r--r--spec/services/protected_branches/update_service_spec.rb12
-rw-r--r--spec/services/protected_tags/create_service_spec.rb10
-rw-r--r--spec/services/protected_tags/destroy_service_spec.rb6
-rw-r--r--spec/services/protected_tags/update_service_spec.rb10
-rw-r--r--spec/services/push_event_payload_service_spec.rb148
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb938
-rw-r--r--spec/services/quick_actions/target_service_spec.rb54
-rw-r--r--spec/services/releases/create_service_spec.rb36
-rw-r--r--spec/services/releases/destroy_service_spec.rb34
-rw-r--r--spec/services/releases/update_service_spec.rb34
-rw-r--r--spec/services/repair_ldap_blocked_user_service_spec.rb12
-rw-r--r--spec/services/repository_archive_clean_up_service_spec.rb48
-rw-r--r--spec/services/reset_project_cache_service_spec.rb10
-rw-r--r--spec/services/resource_events/change_labels_service_spec.rb22
-rw-r--r--spec/services/resource_events/merge_into_notes_service_spec.rb20
-rw-r--r--spec/services/search/global_service_spec.rb32
-rw-r--r--spec/services/search/group_service_spec.rb18
-rw-r--r--spec/services/search/snippet_service_spec.rb50
-rw-r--r--spec/services/search_service_spec.rb217
-rw-r--r--spec/services/spam_service_spec.rb38
-rw-r--r--spec/services/submit_usage_ping_service_spec.rb24
-rw-r--r--spec/services/submodules/update_service_spec.rb157
-rw-r--r--spec/services/suggestions/apply_service_spec.rb102
-rw-r--r--spec/services/suggestions/create_service_spec.rb40
-rw-r--r--spec/services/system_hooks_service_spec.rb58
-rw-r--r--spec/services/system_note_service_spec.rb618
-rw-r--r--spec/services/tags/create_service_spec.rb40
-rw-r--r--spec/services/tags/destroy_service_spec.rb8
-rw-r--r--spec/services/task_list_toggle_service_spec.rb50
-rw-r--r--spec/services/test_hooks/project_service_spec.rb112
-rw-r--r--spec/services/test_hooks/system_service_spec.rb46
-rw-r--r--spec/services/todo_service_spec.rb310
-rw-r--r--spec/services/todos/destroy/confidential_issue_service_spec.rb12
-rw-r--r--spec/services/todos/destroy/entity_leave_service_spec.rb118
-rw-r--r--spec/services/todos/destroy/group_private_service_spec.rb16
-rw-r--r--spec/services/todos/destroy/private_features_service_spec.rb50
-rw-r--r--spec/services/todos/destroy/project_private_service_spec.rb12
-rw-r--r--spec/services/update_deployment_service_spec.rb100
-rw-r--r--spec/services/update_merge_request_metrics_service_spec.rb14
-rw-r--r--spec/services/update_snippet_service_spec.rb16
-rw-r--r--spec/services/upload_service_spec.rb42
-rw-r--r--spec/services/user_project_access_changed_service_spec.rb8
-rw-r--r--spec/services/users/activity_service_spec.rb42
-rw-r--r--spec/services/users/build_service_spec.rb132
-rw-r--r--spec/services/users/create_service_spec.rb68
-rw-r--r--spec/services/users/destroy_service_spec.rb54
-rw-r--r--spec/services/users/keys_count_service_spec.rb30
-rw-r--r--spec/services/users/last_push_event_service_spec.rb56
-rw-r--r--spec/services/users/migrate_to_ghost_user_service_spec.rb20
-rw-r--r--spec/services/users/refresh_authorized_projects_service_spec.rb94
-rw-r--r--spec/services/users/respond_to_terms_service_spec.rb12
-rw-r--r--spec/services/users/set_status_service_spec.rb32
-rw-r--r--spec/services/users/update_service_spec.rb68
-rw-r--r--spec/services/verify_pages_domain_service_spec.rb86
-rw-r--r--spec/services/web_hook_service_spec.rb122
-rw-r--r--spec/services/wiki_pages/create_service_spec.rb16
-rw-r--r--spec/services/wiki_pages/destroy_service_spec.rb8
-rw-r--r--spec/services/wiki_pages/update_service_spec.rb18
-rw-r--r--spec/services/wikis/create_attachment_service_spec.rb127
-rw-r--r--spec/sidekiq/cron/job_gem_dependency_spec.rb14
-rw-r--r--spec/simplecov_env.rb56
-rw-r--r--spec/spec_helper.rb51
-rw-r--r--spec/support/active_record_enum.rb2
-rw-r--r--spec/support/api/boards_shared_examples.rb50
-rw-r--r--spec/support/api/issues_resolving_discussions_shared_examples.rb10
-rw-r--r--spec/support/api/members_shared_examples.rb4
-rw-r--r--spec/support/api/milestones_shared_examples.rb194
-rw-r--r--spec/support/api/repositories_shared_context.rb2
-rw-r--r--spec/support/api/schema_matcher.rb11
-rw-r--r--spec/support/api/scopes/read_user_shared_examples.rb18
-rw-r--r--spec/support/api/time_tracking_shared_examples.rb98
-rw-r--r--spec/support/banzai/reference_filter_shared_examples.rb62
-rw-r--r--spec/support/capybara.rb29
-rw-r--r--spec/support/carrierwave.rb2
-rw-r--r--spec/support/chunked_io/chunked_io_helpers.rb6
-rw-r--r--spec/support/commit_trailers_spec_helper.rb4
-rw-r--r--spec/support/controllers/githubish_import_controller_shared_context.rb4
-rw-r--r--spec/support/controllers/githubish_import_controller_shared_examples.rb206
-rw-r--r--spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb12
-rw-r--r--spec/support/controllers/sessionless_auth_controller_shared_examples.rb32
-rw-r--r--spec/support/cycle_analytics_helpers/test_generation.rb6
-rw-r--r--spec/support/db_cleaner.rb8
-rw-r--r--spec/support/features/discussion_comments_shared_example.rb156
-rw-r--r--spec/support/features/issuable_quick_actions_shared_examples.rb118
-rw-r--r--spec/support/features/reportable_note_shared_examples.rb34
-rw-r--r--spec/support/features/resolving_discussions_in_issues_shared_examples.rb30
-rw-r--r--spec/support/features/variable_list_shared_examples.rb298
-rwxr-xr-xspec/support/generate-seed-repo-rb16
-rw-r--r--spec/support/google_api/cloud_platform_helpers.rb94
-rw-r--r--spec/support/helpers/api_helpers.rb4
-rw-r--r--spec/support/helpers/assets_helpers.rb2
-rw-r--r--spec/support/helpers/bare_repo_operations.rb32
-rw-r--r--spec/support/helpers/board_helpers.rb2
-rw-r--r--spec/support/helpers/capybara_helpers.rb4
-rw-r--r--spec/support/helpers/ci_artifact_metadata_generator.rb6
-rw-r--r--spec/support/helpers/cookie_helper.rb4
-rw-r--r--spec/support/helpers/cycle_analytics_helpers.rb46
-rw-r--r--spec/support/helpers/devise_helpers.rb2
-rw-r--r--spec/support/helpers/drag_to_helper.rb4
-rw-r--r--spec/support/helpers/dropzone_helper.rb6
-rw-r--r--spec/support/helpers/email_helpers.rb2
-rw-r--r--spec/support/helpers/exclusive_lease_helpers.rb4
-rw-r--r--spec/support/helpers/expect_offense.rb4
-rw-r--r--spec/support/helpers/fake_blob_helpers.rb6
-rw-r--r--spec/support/helpers/fake_migration_classes.rb2
-rw-r--r--spec/support/helpers/fake_u2f_device.rb8
-rw-r--r--spec/support/helpers/features/list_rows_helpers.rb5
-rw-r--r--spec/support/helpers/features/notes_helpers.rb6
-rw-r--r--spec/support/helpers/features/responsive_table_helpers.rb5
-rw-r--r--spec/support/helpers/features/sorting_helpers.rb4
-rw-r--r--spec/support/helpers/filter_spec_helper.rb6
-rw-r--r--spec/support/helpers/filtered_search_helpers.rb56
-rw-r--r--spec/support/helpers/fixture_helpers.rb8
-rw-r--r--spec/support/helpers/git_helpers.rb4
-rw-r--r--spec/support/helpers/git_http_helpers.rb12
-rw-r--r--spec/support/helpers/gpg_helpers.rb28
-rw-r--r--spec/support/helpers/graphql_helpers.rb36
-rw-r--r--spec/support/helpers/import_spec_helper.rb8
-rw-r--r--spec/support/helpers/input_helper.rb2
-rw-r--r--spec/support/helpers/inspect_requests.rb2
-rw-r--r--spec/support/helpers/issue_helpers.rb4
-rw-r--r--spec/support/helpers/javascript_fixtures_helpers.rb12
-rw-r--r--spec/support/helpers/jira_service_helper.rb6
-rw-r--r--spec/support/helpers/key_generator_helper.rb12
-rw-r--r--spec/support/helpers/kubernetes_helpers.rb174
-rw-r--r--spec/support/helpers/ldap_helpers.rb12
-rw-r--r--spec/support/helpers/live_debugger.rb2
-rw-r--r--spec/support/helpers/login_helpers.rb68
-rw-r--r--spec/support/helpers/markdown_feature.rb16
-rw-r--r--spec/support/helpers/merge_request_diff_helpers.rb12
-rw-r--r--spec/support/helpers/merge_request_helpers.rb8
-rw-r--r--spec/support/helpers/migrations_helpers.rb4
-rw-r--r--spec/support/helpers/note_interaction_helpers.rb4
-rw-r--r--spec/support/helpers/notification_helpers.rb2
-rw-r--r--spec/support/helpers/project_forks_helper.rb6
-rw-r--r--spec/support/helpers/prometheus_helpers.rb96
-rw-r--r--spec/support/helpers/query_recorder.rb4
-rw-r--r--spec/support/helpers/quick_actions_helpers.rb6
-rw-r--r--spec/support/helpers/rake_helpers.rb4
-rw-r--r--spec/support/helpers/reactive_caching_helpers.rb4
-rw-r--r--spec/support/helpers/reference_parser_helpers.rb12
-rw-r--r--spec/support/helpers/repo_helpers.rb84
-rw-r--r--spec/support/helpers/seed_helper.rb108
-rw-r--r--spec/support/helpers/seed_repo.rb60
-rw-r--r--spec/support/helpers/select2_helper.rb4
-rw-r--r--spec/support/helpers/sorting_helper.rb4
-rw-r--r--spec/support/helpers/stub_configuration.rb23
-rw-r--r--spec/support/helpers/stub_env.rb2
-rw-r--r--spec/support/helpers/stub_gitlab_calls.rb42
-rw-r--r--spec/support/helpers/stub_gitlab_data.rb2
-rw-r--r--spec/support/helpers/stub_object_storage.rb34
-rw-r--r--spec/support/helpers/terms_helper.rb6
-rw-r--r--spec/support/helpers/test_env.rb213
-rw-r--r--spec/support/helpers/test_request_helpers.rb4
-rw-r--r--spec/support/helpers/upload_helpers.rb8
-rw-r--r--spec/support/helpers/user_login_helper.rb4
-rw-r--r--spec/support/helpers/wait_for_requests.rb8
-rw-r--r--spec/support/helpers/wiki_helpers.rb6
-rw-r--r--spec/support/helpers/workhorse_helpers.rb10
-rw-r--r--spec/support/http_io/http_io_helpers.rb8
-rw-r--r--spec/support/import_export/common_util.rb2
-rw-r--r--spec/support/import_export/configuration_helper.rb8
-rw-r--r--spec/support/import_export/export_file_helper.rb26
-rw-r--r--spec/support/issuables_requiring_filter_shared_examples.rb4
-rw-r--r--spec/support/json_response.rb6
-rw-r--r--spec/support/matchers/access_matchers.rb4
-rw-r--r--spec/support/matchers/access_matchers_for_controller.rb6
-rw-r--r--spec/support/matchers/background_migrations_matchers.rb8
-rw-r--r--spec/support/matchers/be_a_binary_string.rb2
-rw-r--r--spec/support/matchers/be_url.rb4
-rw-r--r--spec/support/matchers/be_utf8.rb2
-rw-r--r--spec/support/matchers/disallow_request_matchers.rb8
-rw-r--r--spec/support/matchers/exceed_query_limit.rb12
-rw-r--r--spec/support/matchers/execute_check.rb4
-rw-r--r--spec/support/matchers/graphql_matchers.rb2
-rw-r--r--spec/support/matchers/have_issuable_counts.rb6
-rw-r--r--spec/support/matchers/markdown_matchers.rb86
-rw-r--r--spec/support/matchers/match_ids.rb2
-rw-r--r--spec/support/matchers/navigation_matcher.rb6
-rw-r--r--spec/support/matchers/pagination_matcher.rb4
-rw-r--r--spec/support/matchers/security_header_matcher.rb2
-rw-r--r--spec/support/migrations_helpers/cluster_helpers.rb14
-rw-r--r--spec/support/migrations_helpers/track_untracked_uploads_helpers.rb42
-rwxr-xr-xspec/support/prepare-gitlab-git-test-for-commit6
-rw-r--r--spec/support/prometheus/additional_metrics_shared_examples.rb109
-rw-r--r--spec/support/prometheus/metric_builders.rb18
-rw-r--r--spec/support/protected_tags/access_control_ce_shared_examples.rb12
-rw-r--r--spec/support/redis/redis_shared_examples.rb98
-rw-r--r--spec/support/services/clusters/create_service_shared.rb42
-rw-r--r--spec/support/services/issuable_create_service_slash_commands_shared_examples.rb28
-rw-r--r--spec/support/services/issuable_update_service_shared_examples.rb16
-rw-r--r--spec/support/services/migrate_to_ghost_user_service_shared_examples.rb18
-rw-r--r--spec/support/setup_builds_storage.rb4
-rw-r--r--spec/support/shared_contexts/change_access_checks_shared_context.rb12
-rw-r--r--spec/support/shared_contexts/email_shared_context.rb6
-rw-r--r--spec/support/shared_contexts/json_response_shared_context.rb2
-rw-r--r--spec/support/shared_contexts/merge_requests_allowing_collaboration.rb10
-rw-r--r--spec/support/shared_contexts/services_shared_context.rb16
-rw-r--r--spec/support/shared_contexts/url_shared_context.rb4
-rw-r--r--spec/support/shared_examples/chat_slash_commands_shared_examples.rb64
-rw-r--r--spec/support/shared_examples/ci_trace_shared_examples.rb318
-rw-r--r--spec/support/shared_examples/common_system_notes_examples.rb10
-rw-r--r--spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb20
-rw-r--r--spec/support/shared_examples/controllers/repository_lfs_file_load_examples.rb45
-rw-r--r--spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb20
-rw-r--r--spec/support/shared_examples/controllers/todos_shared_examples.rb30
-rw-r--r--spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb78
-rw-r--r--spec/support/shared_examples/controllers/variables_shared_examples.rb78
-rw-r--r--spec/support/shared_examples/diff_file_collections.rb24
-rw-r--r--spec/support/shared_examples/dirty_submit_form_shared_examples.rb10
-rw-r--r--spec/support/shared_examples/email_format_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/fast_destroy_all.rb18
-rw-r--r--spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb22
-rw-r--r--spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb57
-rw-r--r--spec/support/shared_examples/features/editable_merge_request_shared_examples.rb82
-rw-r--r--spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb4
-rw-r--r--spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb14
-rw-r--r--spec/support/shared_examples/features/project_features_apply_to_issuables_shared_examples.rb18
-rw-r--r--spec/support/shared_examples/features/protected_branches_access_control_ce.rb40
-rw-r--r--spec/support/shared_examples/features/search_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/file_finder.rb8
-rw-r--r--spec/support/shared_examples/gitlab_verify.rb10
-rw-r--r--spec/support/shared_examples/graphql/issuable_state_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/group_members_shared_example.rb14
-rw-r--r--spec/support/shared_examples/helm_generated_script.rb8
-rw-r--r--spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb12
-rw-r--r--spec/support/shared_examples/issuable_shared_examples.rb64
-rw-r--r--spec/support/shared_examples/issuables_list_metadata_shared_examples.rb16
-rw-r--r--spec/support/shared_examples/issue_tracker_service_shared_example.rb26
-rw-r--r--spec/support/shared_examples/ldap_shared_examples.rb96
-rw-r--r--spec/support/shared_examples/legacy_path_redirect_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb28
-rw-r--r--spec/support/shared_examples/malicious_regexp_shared_examples.rb10
-rw-r--r--spec/support/shared_examples/mentionable_shared_examples.rb20
-rw-r--r--spec/support/shared_examples/milestone_tabs_examples.rb62
-rw-r--r--spec/support/shared_examples/models/atomic_internal_id_spec.rb32
-rw-r--r--spec/support/shared_examples/models/chat_service_spec.rb18
-rw-r--r--spec/support/shared_examples/models/cluster_application_core_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb10
-rw-r--r--spec/support/shared_examples/models/cluster_application_initial_status.rb12
-rw-r--r--spec/support/shared_examples/models/cluster_application_status_shared_examples.rb62
-rw-r--r--spec/support/shared_examples/models/cluster_application_version_shared_examples.rb10
-rw-r--r--spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb38
-rw-r--r--spec/support/shared_examples/models/label_note_shared_examples.rb38
-rw-r--r--spec/support/shared_examples/models/member_shared_examples.rb22
-rw-r--r--spec/support/shared_examples/models/members_notifications_shared_example.rb6
-rw-r--r--spec/support/shared_examples/models/project_hook_data_shared_examples.rb12
-rw-r--r--spec/support/shared_examples/models/with_uploads_shared_examples.rb24
-rw-r--r--spec/support/shared_examples/notify_shared_examples.rb200
-rw-r--r--spec/support/shared_examples/policies/clusterable_shared_examples.rb14
-rw-r--r--spec/support/shared_examples/position_formatters.rb14
-rw-r--r--spec/support/shared_examples/project_list_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/reference_parser_shared_examples.rb2
-rw-r--r--spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb146
-rw-r--r--spec/support/shared_examples/requests/api/diff_discussions.rb34
-rw-r--r--spec/support/shared_examples/requests/api/discussions.rb64
-rw-r--r--spec/support/shared_examples/requests/api/issuable_participants_examples.rb14
-rw-r--r--spec/support/shared_examples/requests/api/merge_requests_list.rb216
-rw-r--r--spec/support/shared_examples/requests/api/notes.rb158
-rw-r--r--spec/support/shared_examples/requests/api/resolvable_discussions.rb38
-rw-r--r--spec/support/shared_examples/requests/api/status_shared_examples.rb30
-rw-r--r--spec/support/shared_examples/requests/graphql_shared_examples.rb8
-rw-r--r--spec/support/shared_examples/serializers/diff_file_entity_examples.rb38
-rw-r--r--spec/support/shared_examples/serializers/note_entity_examples.rb20
-rw-r--r--spec/support/shared_examples/services/boards/boards_create_service.rb12
-rw-r--r--spec/support/shared_examples/services/boards/boards_list_service.rb14
-rw-r--r--spec/support/shared_examples/services/boards/issues_list_service.rb38
-rw-r--r--spec/support/shared_examples/services/boards/issues_move_service.rb48
-rw-r--r--spec/support/shared_examples/services/boards/lists_destroy_service.rb10
-rw-r--r--spec/support/shared_examples/services/boards/lists_list_service.rb10
-rw-r--r--spec/support/shared_examples/services/boards/lists_move_service.rb24
-rw-r--r--spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb18
-rw-r--r--spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb30
-rw-r--r--spec/support/shared_examples/showing_user_status_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb180
-rw-r--r--spec/support/shared_examples/snippet_visibility.rb32
-rw-r--r--spec/support/shared_examples/snippets_shared_examples.rb12
-rw-r--r--spec/support/shared_examples/taskable_shared_examples.rb70
-rw-r--r--spec/support/shared_examples/throttled_touch.rb8
-rw-r--r--spec/support/shared_examples/time_tracking_shared_examples.rb88
-rw-r--r--spec/support/shared_examples/unique_ip_check_shared_examples.rb36
-rw-r--r--spec/support/shared_examples/update_invalid_issuable.rb20
-rw-r--r--spec/support/shared_examples/updating_mentions_shared_examples.rb10
-rw-r--r--spec/support/shared_examples/uploaders/gitlab_uploader_shared_examples.rb6
-rw-r--r--spec/support/shared_examples/uploaders/object_storage_shared_examples.rb38
-rw-r--r--spec/support/shared_examples/url_validator_examples.rb22
-rw-r--r--spec/support/shared_examples/wiki_file_attachments_examples.rb52
-rw-r--r--spec/support/shoulda/matchers/rails_shim.rb4
-rw-r--r--spec/support/sidekiq.rb2
-rw-r--r--spec/support/stored_repositories.rb2
-rw-r--r--spec/support/stub_version.rb2
-rw-r--r--spec/support/test_reports/test_reports_helper.rb64
-rw-r--r--spec/support/trace/trace_helpers.rb6
-rwxr-xr-xspec/support/unpack-gitlab-git-test22
-rw-r--r--spec/support/webmock.rb4
-rw-r--r--spec/tasks/cache/clear/redis_spec.rb12
-rw-r--r--spec/tasks/config_lint_spec.rb22
-rw-r--r--spec/tasks/gitlab/artifacts/check_rake_spec.rb28
-rw-r--r--spec/tasks/gitlab/artifacts/migrate_rake_spec.rb34
-rw-r--r--spec/tasks/gitlab/backup_rake_spec.rb260
-rw-r--r--spec/tasks/gitlab/check_rake_spec.rb80
-rw-r--r--spec/tasks/gitlab/cleanup_rake_spec.rb92
-rw-r--r--spec/tasks/gitlab/db_rake_spec.rb108
-rw-r--r--spec/tasks/gitlab/git_rake_spec.rb14
-rw-r--r--spec/tasks/gitlab/gitaly_rake_spec.rb60
-rw-r--r--spec/tasks/gitlab/info_rake_spec.rb26
-rw-r--r--spec/tasks/gitlab/ldap_rake_spec.rb12
-rw-r--r--spec/tasks/gitlab/lfs/check_rake_spec.rb22
-rw-r--r--spec/tasks/gitlab/lfs/migrate_rake_spec.rb16
-rw-r--r--spec/tasks/gitlab/mail_google_schema_whitelisting.rb10
-rw-r--r--spec/tasks/gitlab/shell_rake_spec.rb30
-rw-r--r--spec/tasks/gitlab/storage_rake_spec.rb108
-rw-r--r--spec/tasks/gitlab/task_helpers_spec.rb54
-rw-r--r--spec/tasks/gitlab/traces_rake_spec.rb48
-rw-r--r--spec/tasks/gitlab/uploads/check_rake_spec.rb26
-rw-r--r--spec/tasks/gitlab/uploads/migrate_rake_spec.rb36
-rw-r--r--spec/tasks/gitlab/web_hook_rake_spec.rb62
-rw-r--r--spec/tasks/gitlab/workhorse_rake_spec.rb58
-rw-r--r--spec/tasks/tokens_spec.rb18
-rw-r--r--spec/uploaders/attachment_uploader_spec.rb20
-rw-r--r--spec/uploaders/avatar_uploader_spec.rb20
-rw-r--r--spec/uploaders/external_diff_uploader_spec.rb28
-rw-r--r--spec/uploaders/file_mover_spec.rb26
-rw-r--r--spec/uploaders/file_uploader_spec.rb150
-rw-r--r--spec/uploaders/gitlab_uploader_spec.rb64
-rw-r--r--spec/uploaders/import_export_uploader_spec.rb10
-rw-r--r--spec/uploaders/job_artifact_uploader_spec.rb54
-rw-r--r--spec/uploaders/legacy_artifact_uploader_spec.rb28
-rw-r--r--spec/uploaders/lfs_object_uploader_spec.rb28
-rw-r--r--spec/uploaders/namespace_file_uploader_spec.rb64
-rw-r--r--spec/uploaders/object_storage_spec.rb268
-rw-r--r--spec/uploaders/personal_file_uploader_spec.rb40
-rw-r--r--spec/uploaders/records_uploads_spec.rb44
-rw-r--r--spec/uploaders/uploader_helper_spec.rb12
-rw-r--r--spec/uploaders/workers/object_storage/background_move_worker_spec.rb40
-rw-r--r--spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb52
-rw-r--r--spec/validators/branch_filter_validator_spec.rb20
-rw-r--r--spec/validators/js_regex_validator_spec.rb12
-rw-r--r--spec/validators/namespace_path_validator_spec.rb26
-rw-r--r--spec/validators/project_path_validator_spec.rb26
-rw-r--r--spec/validators/public_url_validator_spec.rb16
-rw-r--r--spec/validators/url_validator_spec.rb102
-rw-r--r--spec/validators/variable_duplicates_validator_spec.rb30
-rw-r--r--spec/views/admin/dashboard/index.html.haml_spec.rb10
-rw-r--r--spec/views/ci/status/_badge.html.haml_spec.rb54
-rw-r--r--spec/views/dashboard/projects/_blank_state_admin_welcome.haml.rb8
-rw-r--r--spec/views/dashboard/projects/_nav.html.haml.rb12
-rw-r--r--spec/views/devise/shared/_signin_box.html.haml_spec.rb16
-rw-r--r--spec/views/errors/access_denied.html.haml_spec.rb6
-rw-r--r--spec/views/events/event/_push.html.haml_spec.rb30
-rw-r--r--spec/views/groups/edit.html.haml_spec.rb50
-rw-r--r--spec/views/help/index.html.haml_spec.rb40
-rw-r--r--spec/views/help/instance_configuration.html.haml_spec.rb22
-rw-r--r--spec/views/layouts/_head.html.haml_spec.rb34
-rw-r--r--spec/views/layouts/header/_new_dropdown.haml_spec.rb36
-rw-r--r--spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb74
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb68
-rw-r--r--spec/views/notify/changed_milestone_email.html.haml_spec.rb24
-rw-r--r--spec/views/notify/pipeline_failed_email.html.haml_spec.rb22
-rw-r--r--spec/views/notify/pipeline_success_email.html.haml_spec.rb22
-rw-r--r--spec/views/profiles/show.html.haml_spec.rb12
-rw-r--r--spec/views/projects/_home_panel.html.haml_spec.rb56
-rw-r--r--spec/views/projects/blob/_viewer.html.haml_spec.rb50
-rw-r--r--spec/views/projects/buttons/_dropdown.html.haml_spec.rb26
-rw-r--r--spec/views/projects/ci/lints/show.html.haml_spec.rb68
-rw-r--r--spec/views/projects/commit/_commit_box.html.haml_spec.rb40
-rw-r--r--spec/views/projects/commit/branches.html.haml_spec.rb84
-rw-r--r--spec/views/projects/commit/show.html.haml_spec.rb22
-rw-r--r--spec/views/projects/commits/_commit.html.haml_spec.rb44
-rw-r--r--spec/views/projects/diffs/_stats.html.haml_spec.rb44
-rw-r--r--spec/views/projects/diffs/_viewer.html.haml_spec.rb36
-rw-r--r--spec/views/projects/edit.html.haml_spec.rb10
-rw-r--r--spec/views/projects/environments/terminal.html.haml_spec.rb18
-rw-r--r--spec/views/projects/imports/new.html.haml_spec.rb6
-rw-r--r--spec/views/projects/issues/_merge_requests_status.html.haml_spec.rb17
-rw-r--r--spec/views/projects/issues/_related_branches.html.haml_spec.rb16
-rw-r--r--spec/views/projects/issues/show.html.haml_spec.rb24
-rw-r--r--spec/views/projects/jobs/_build.html.haml_spec.rb24
-rw-r--r--spec/views/projects/jobs/_generic_commit_status.html.haml_spec.rb24
-rw-r--r--spec/views/projects/jobs/show.html.haml_spec.rb14
-rw-r--r--spec/views/projects/merge_requests/_commits.html.haml_spec.rb12
-rw-r--r--spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb20
-rw-r--r--spec/views/projects/merge_requests/diffs/_diffs.html.haml_spec.rb6
-rw-r--r--spec/views/projects/merge_requests/edit.html.haml_spec.rb28
-rw-r--r--spec/views/projects/merge_requests/show.html.haml_spec.rb42
-rw-r--r--spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb30
-rw-r--r--spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb18
-rw-r--r--spec/views/projects/pipelines/_stage.html.haml_spec.rb36
-rw-r--r--spec/views/projects/services/_form.haml_spec.rb22
-rw-r--r--spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb8
-rw-r--r--spec/views/projects/settings/operations/show.html.haml_spec.rb18
-rw-r--r--spec/views/projects/tags/index.html.haml_spec.rb10
-rw-r--r--spec/views/projects/tree/_tree_row.html.haml_spec.rb20
-rw-r--r--spec/views/projects/tree/show.html.haml_spec.rb18
-rw-r--r--spec/views/shared/milestones/_issuable.html.haml.rb10
-rw-r--r--spec/views/shared/milestones/_issuables.html.haml.rb28
-rw-r--r--spec/views/shared/milestones/_top.html.haml.rb22
-rw-r--r--spec/views/shared/notes/_form.html.haml_spec.rb8
-rw-r--r--spec/views/shared/projects/_project.html.haml_spec.rb16
-rw-r--r--spec/views/shared/runners/show.html.haml_spec.rb106
-rw-r--r--spec/workers/admin_email_worker_spec.rb14
-rw-r--r--spec/workers/archive_trace_worker_spec.rb12
-rw-r--r--spec/workers/authorized_projects_worker_spec.rb4
-rw-r--r--spec/workers/auto_devops/disable_worker_spec.rb19
-rw-r--r--spec/workers/background_migration_worker_spec.rb44
-rw-r--r--spec/workers/build_coverage_worker_spec.rb12
-rw-r--r--spec/workers/build_finished_worker_spec.rb16
-rw-r--r--spec/workers/build_hooks_worker_spec.rb12
-rw-r--r--spec/workers/build_success_worker_spec.rb26
-rw-r--r--spec/workers/build_trace_sections_worker_spec.rb12
-rw-r--r--spec/workers/chat_notification_worker_spec.rb24
-rw-r--r--spec/workers/ci/archive_traces_cron_worker_spec.rb30
-rw-r--r--spec/workers/ci/build_schedule_worker_spec.rb16
-rw-r--r--spec/workers/cleanup_container_repository_worker_spec.rb24
-rw-r--r--spec/workers/cluster_configure_worker_spec.rb30
-rw-r--r--spec/workers/cluster_provision_worker_spec.rb18
-rw-r--r--spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb10
-rw-r--r--spec/workers/concerns/application_worker_spec.rb46
-rw-r--r--spec/workers/concerns/cluster_queue_spec.rb10
-rw-r--r--spec/workers/concerns/cronjob_queue_spec.rb12
-rw-r--r--spec/workers/concerns/gitlab/github_import/notify_upon_death_spec.rb22
-rw-r--r--spec/workers/concerns/gitlab/github_import/object_importer_spec.rb22
-rw-r--r--spec/workers/concerns/gitlab/github_import/queue_spec.rb12
-rw-r--r--spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb50
-rw-r--r--spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb26
-rw-r--r--spec/workers/concerns/pipeline_background_queue_spec.rb10
-rw-r--r--spec/workers/concerns/pipeline_queue_spec.rb10
-rw-r--r--spec/workers/concerns/project_import_options_spec.rb28
-rw-r--r--spec/workers/concerns/repository_check_queue_spec.rb12
-rw-r--r--spec/workers/concerns/waitable_worker_spec.rb38
-rw-r--r--spec/workers/create_gpg_signature_worker_spec.rb26
-rw-r--r--spec/workers/create_note_diff_file_worker_spec.rb6
-rw-r--r--spec/workers/create_pipeline_worker_spec.rb18
-rw-r--r--spec/workers/delete_container_repository_worker_spec.rb18
-rw-r--r--spec/workers/delete_diff_files_worker_spec.rb14
-rw-r--r--spec/workers/delete_merged_branches_worker_spec.rb4
-rw-r--r--spec/workers/delete_user_worker_spec.rb2
-rw-r--r--spec/workers/deployments/success_worker_spec.rb14
-rw-r--r--spec/workers/detect_repository_languages_worker_spec.rb20
-rw-r--r--spec/workers/email_receiver_worker_spec.rb14
-rw-r--r--spec/workers/emails_on_push_worker_spec.rb10
-rw-r--r--spec/workers/every_sidekiq_worker_spec.rb20
-rw-r--r--spec/workers/expire_build_artifacts_worker_spec.rb22
-rw-r--r--spec/workers/expire_build_instance_artifacts_worker_spec.rb34
-rw-r--r--spec/workers/expire_job_cache_worker_spec.rb12
-rw-r--r--spec/workers/expire_pipeline_cache_worker_spec.rb14
-rw-r--r--spec/workers/git_garbage_collect_worker_spec.rb58
-rw-r--r--spec/workers/gitlab/github_import/advance_stage_worker_spec.rb62
-rw-r--r--spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb24
-rw-r--r--spec/workers/gitlab/github_import/import_issue_worker_spec.rb30
-rw-r--r--spec/workers/gitlab/github_import/import_note_worker_spec.rb20
-rw-r--r--spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb42
-rw-r--r--spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb46
-rw-r--r--spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb12
-rw-r--r--spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb6
-rw-r--r--spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb10
-rw-r--r--spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb10
-rw-r--r--spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb10
-rw-r--r--spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb10
-rw-r--r--spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb16
-rw-r--r--spec/workers/gitlab_shell_worker_spec.rb10
-rw-r--r--spec/workers/gitlab_usage_ping_worker_spec.rb4
-rw-r--r--spec/workers/group_destroy_worker_spec.rb2
-rw-r--r--spec/workers/hashed_storage/migrator_worker_spec.rb8
-rw-r--r--spec/workers/import_issues_csv_worker_spec.rb8
-rw-r--r--spec/workers/invalid_gpg_signature_update_worker_spec.rb12
-rw-r--r--spec/workers/issue_due_scheduler_worker_spec.rb6
-rw-r--r--spec/workers/mail_scheduler/issue_due_worker_spec.rb6
-rw-r--r--spec/workers/mail_scheduler/notification_service_worker_spec.rb46
-rw-r--r--spec/workers/merge_worker_spec.rb13
-rw-r--r--spec/workers/namespaceless_project_destroy_worker_spec.rb28
-rw-r--r--spec/workers/new_issue_worker_spec.rb28
-rw-r--r--spec/workers/new_merge_request_worker_spec.rb30
-rw-r--r--spec/workers/new_note_worker_spec.rb8
-rw-r--r--spec/workers/object_pool/create_worker_spec.rb28
-rw-r--r--spec/workers/object_pool/destroy_worker_spec.rb14
-rw-r--r--spec/workers/object_pool/join_worker_spec.rb16
-rw-r--r--spec/workers/pages_domain_verification_cron_worker_spec.rb6
-rw-r--r--spec/workers/pages_domain_verification_worker_spec.rb8
-rw-r--r--spec/workers/pipeline_hooks_worker_spec.rb12
-rw-r--r--spec/workers/pipeline_metrics_worker_spec.rb36
-rw-r--r--spec/workers/pipeline_notification_worker_spec.rb8
-rw-r--r--spec/workers/pipeline_process_worker_spec.rb12
-rw-r--r--spec/workers/pipeline_schedule_worker_spec.rb56
-rw-r--r--spec/workers/pipeline_success_worker_spec.rb12
-rw-r--r--spec/workers/pipeline_update_worker_spec.rb12
-rw-r--r--spec/workers/plugin_worker_spec.rb16
-rw-r--r--spec/workers/post_receive_spec.rb32
-rw-r--r--spec/workers/process_commit_worker_spec.rb86
-rw-r--r--spec/workers/project_cache_worker_spec.rb50
-rw-r--r--spec/workers/project_daily_statistics_worker_spec.rb17
-rw-r--r--spec/workers/project_destroy_worker_spec.rb18
-rw-r--r--spec/workers/project_export_worker_spec.rb16
-rw-r--r--spec/workers/project_migrate_hashed_storage_worker_spec.rb14
-rw-r--r--spec/workers/project_service_worker_spec.rb15
-rw-r--r--spec/workers/propagate_service_template_worker_spec.rb17
-rw-r--r--spec/workers/prune_old_events_worker_spec.rb12
-rw-r--r--spec/workers/prune_web_hook_logs_worker_spec.rb10
-rw-r--r--spec/workers/reactive_caching_worker_spec.rb12
-rw-r--r--spec/workers/rebase_worker_spec.rb16
-rw-r--r--spec/workers/remote_mirror_notification_worker_spec.rb12
-rw-r--r--spec/workers/remove_expired_group_links_worker_spec.rb10
-rw-r--r--spec/workers/remove_expired_members_worker_spec.rb24
-rw-r--r--spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb33
-rw-r--r--spec/workers/repository_check/batch_worker_spec.rb24
-rw-r--r--spec/workers/repository_check/clear_worker_spec.rb4
-rw-r--r--spec/workers/repository_check/dispatch_worker_spec.rb20
-rw-r--r--spec/workers/repository_check/single_repository_worker_spec.rb26
-rw-r--r--spec/workers/repository_cleanup_worker_spec.rb20
-rw-r--r--spec/workers/repository_fork_worker_spec.rb26
-rw-r--r--spec/workers/repository_import_worker_spec.rb54
-rw-r--r--spec/workers/repository_remove_remote_worker_spec.rb22
-rw-r--r--spec/workers/repository_update_remote_mirror_worker_spec.rb52
-rw-r--r--spec/workers/run_pipeline_schedule_worker_spec.rb18
-rw-r--r--spec/workers/stage_update_worker_spec.rb12
-rw-r--r--spec/workers/stuck_ci_jobs_worker_spec.rb80
-rw-r--r--spec/workers/stuck_import_jobs_worker_spec.rb34
-rw-r--r--spec/workers/stuck_merge_jobs_worker_spec.rb38
-rw-r--r--spec/workers/system_hook_push_worker_spec.rb10
-rw-r--r--spec/workers/todos_destroyer/confidential_issue_worker_spec.rb2
-rw-r--r--spec/workers/todos_destroyer/entity_leave_worker_spec.rb6
-rw-r--r--spec/workers/todos_destroyer/group_private_worker_spec.rb2
-rw-r--r--spec/workers/todos_destroyer/private_features_worker_spec.rb2
-rw-r--r--spec/workers/todos_destroyer/project_private_worker_spec.rb2
-rw-r--r--spec/workers/trending_projects_worker_spec.rb6
-rw-r--r--spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb36
-rw-r--r--spec/workers/update_merge_requests_worker_spec.rb10
-rw-r--r--spec/workers/upload_checksum_worker_spec.rb14
-rw-r--r--spec/workers/wait_for_cluster_creation_worker_spec.rb16
6256 files changed, 123257 insertions, 122889 deletions
diff --git a/Dangerfile b/Dangerfile
index 715a2bcbbae..6a5e75d83b6 100644
--- a/Dangerfile
+++ b/Dangerfile
@@ -1,14 +1,14 @@
-danger.import_plugin('danger/plugins/helper.rb')
-danger.import_dangerfile(path: 'danger/metadata')
-danger.import_dangerfile(path: 'danger/changes_size')
-danger.import_dangerfile(path: 'danger/changelog')
-danger.import_dangerfile(path: 'danger/specs')
-danger.import_dangerfile(path: 'danger/gemfile')
-danger.import_dangerfile(path: 'danger/database')
-danger.import_dangerfile(path: 'danger/documentation')
-danger.import_dangerfile(path: 'danger/frozen_string')
-danger.import_dangerfile(path: 'danger/commit_messages')
-danger.import_dangerfile(path: 'danger/duplicate_yarn_dependencies')
-danger.import_dangerfile(path: 'danger/prettier')
-danger.import_dangerfile(path: 'danger/eslint')
-danger.import_dangerfile(path: 'danger/roulette')
+danger.import_plugin("danger/plugins/helper.rb")
+danger.import_dangerfile(path: "danger/metadata")
+danger.import_dangerfile(path: "danger/changes_size")
+danger.import_dangerfile(path: "danger/changelog")
+danger.import_dangerfile(path: "danger/specs")
+danger.import_dangerfile(path: "danger/gemfile")
+danger.import_dangerfile(path: "danger/database")
+danger.import_dangerfile(path: "danger/documentation")
+danger.import_dangerfile(path: "danger/frozen_string")
+danger.import_dangerfile(path: "danger/commit_messages")
+danger.import_dangerfile(path: "danger/duplicate_yarn_dependencies")
+danger.import_dangerfile(path: "danger/prettier")
+danger.import_dangerfile(path: "danger/eslint")
+danger.import_dangerfile(path: "danger/roulette")
diff --git a/Gemfile b/Gemfile
index 28666199c0f..459106a7107 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,437 +1,438 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
-gem 'rails', '5.0.7.1'
-gem 'rails-deprecated_sanitizer', '~> 1.0.3'
+gem "rails", "5.0.7.1"
+gem "rails-deprecated_sanitizer", "~> 1.0.3"
# Improves copy-on-write performance for MRI
-gem 'nakayoshi_fork', '~> 0.0.4'
+gem "nakayoshi_fork", "~> 0.0.4"
# Responders respond_to and respond_with
-gem 'responders', '~> 2.0'
+gem "responders", "~> 2.0"
-gem 'sprockets', '~> 3.7.0'
+gem "sprockets", "~> 3.7.0"
# Default values for AR models
-gem 'gitlab-default_value_for', '~> 3.1.1', require: 'default_value_for'
+gem "gitlab-default_value_for", "~> 3.1.1", require: "default_value_for"
# Supported DBs
-gem 'mysql2', '~> 0.4.10', group: :mysql
-gem 'pg', '~> 1.1', group: :postgres
+gem "mysql2", "~> 0.4.10", group: :mysql
+gem "pg", "~> 1.1", group: :postgres
-gem 'rugged', '~> 0.27'
-gem 'grape-path-helpers', '~> 1.0'
+gem "rugged", "~> 0.27"
+gem "grape-path-helpers", "~> 1.0"
-gem 'faraday', '~> 0.12'
+gem "faraday", "~> 0.12"
# Authentication libraries
-gem 'devise', '~> 4.4'
-gem 'doorkeeper', '~> 4.3'
-gem 'doorkeeper-openid_connect', '~> 1.5'
-gem 'omniauth', '~> 1.8'
-gem 'omniauth-auth0', '~> 2.0.0'
-gem 'omniauth-azure-oauth2', '~> 0.0.9'
-gem 'omniauth-cas3', '~> 1.1.4'
-gem 'omniauth-facebook', '~> 4.0.0'
-gem 'omniauth-github', '~> 1.3'
-gem 'omniauth-gitlab', '~> 1.0.2'
-gem 'omniauth-google-oauth2', '~> 0.6.0'
-gem 'omniauth-kerberos', '~> 0.3.0', group: :kerberos
-gem 'omniauth-oauth2-generic', '~> 0.2.2'
-gem 'omniauth-saml', '~> 1.10'
-gem 'omniauth-shibboleth', '~> 1.3.0'
-gem 'omniauth-twitter', '~> 1.4'
-gem 'omniauth_crowd', '~> 2.2.0'
-gem 'omniauth-authentiq', '~> 0.3.3'
-gem 'rack-oauth2', '~> 1.2.1'
-gem 'jwt', '~> 2.1.0'
+gem "devise", "~> 4.4"
+gem "doorkeeper", "~> 4.3"
+gem "doorkeeper-openid_connect", "~> 1.5"
+gem "omniauth", "~> 1.8"
+gem "omniauth-auth0", "~> 2.0.0"
+gem "omniauth-azure-oauth2", "~> 0.0.9"
+gem "omniauth-cas3", "~> 1.1.4"
+gem "omniauth-facebook", "~> 4.0.0"
+gem "omniauth-github", "~> 1.3"
+gem "omniauth-gitlab", "~> 1.0.2"
+gem "omniauth-google-oauth2", "~> 0.6.0"
+gem "omniauth-kerberos", "~> 0.3.0", group: :kerberos
+gem "omniauth-oauth2-generic", "~> 0.2.2"
+gem "omniauth-saml", "~> 1.10"
+gem "omniauth-shibboleth", "~> 1.3.0"
+gem "omniauth-twitter", "~> 1.4"
+gem "omniauth_crowd", "~> 2.2.0"
+gem "omniauth-authentiq", "~> 0.3.3"
+gem "rack-oauth2", "~> 1.2.1"
+gem "jwt", "~> 2.1.0"
# Spam and anti-bot protection
-gem 'recaptcha', '~> 3.0', require: 'recaptcha/rails'
-gem 'akismet', '~> 2.0'
+gem "recaptcha", "~> 3.0", require: "recaptcha/rails"
+gem "akismet", "~> 2.0"
# Two-factor authentication
-gem 'devise-two-factor', '~> 3.0.0'
-gem 'rqrcode-rails3', '~> 0.1.7'
-gem 'attr_encrypted', '~> 3.1.0'
-gem 'u2f', '~> 0.2.1'
+gem "devise-two-factor", "~> 3.0.0"
+gem "rqrcode-rails3", "~> 0.1.7"
+gem "attr_encrypted", "~> 3.1.0"
+gem "u2f", "~> 0.2.1"
# GitLab Pages
-gem 'validates_hostname', '~> 1.0.6'
-gem 'rubyzip', '~> 1.2.2', require: 'zip'
+gem "validates_hostname", "~> 1.0.6"
+gem "rubyzip", "~> 1.2.2", require: "zip"
# Browser detection
-gem 'browser', '~> 2.5'
+gem "browser", "~> 2.5"
# GPG
-gem 'gpgme', '~> 2.0.18'
+gem "gpgme", "~> 2.0.18"
# LDAP Auth
# GitLab fork with several improvements to original library. For full list of changes
# see https://github.com/intridea/omniauth-ldap/compare/master...gitlabhq:master
-gem 'gitlab_omniauth-ldap', '~> 2.0.4', require: 'omniauth-ldap'
-gem 'net-ldap'
+gem "gitlab_omniauth-ldap", "~> 2.0.4", require: "omniauth-ldap"
+gem "net-ldap"
# API
-gem 'grape', '~> 1.1.0'
-gem 'grape-entity', '~> 0.7.1'
-gem 'rack-cors', '~> 1.0.0', require: 'rack/cors'
+gem "grape", "~> 1.1.0"
+gem "grape-entity", "~> 0.7.1"
+gem "rack-cors", "~> 1.0.0", require: "rack/cors"
# GraphQL API
-gem 'graphql', '~> 1.8.0'
-gem 'graphiql-rails', '~> 1.4.10'
+gem "graphql", "~> 1.8.0"
+gem "graphiql-rails", "~> 1.4.10"
# Disable strong_params so that Mash does not respond to :permitted?
-gem 'hashie-forbidden_attributes'
+gem "hashie-forbidden_attributes"
# Pagination
-gem 'kaminari', '~> 1.0'
+gem "kaminari", "~> 1.0"
# HAML
-gem 'hamlit', '~> 2.8.8'
+gem "hamlit", "~> 2.8.8"
# Files attachments
-gem 'carrierwave', '~> 1.3'
-gem 'mini_magick'
+gem "carrierwave", "~> 1.3"
+gem "mini_magick"
# for backups
-gem 'fog-aws', '~> 2.0.1'
-gem 'fog-core', '~> 1.44'
-gem 'fog-google', '~> 1.7.1'
-gem 'fog-local', '~> 0.3'
-gem 'fog-openstack', '~> 0.1'
-gem 'fog-rackspace', '~> 0.1.1'
-gem 'fog-aliyun', '~> 0.2.0'
+gem "fog-aws", "~> 2.0.1"
+gem "fog-core", "~> 1.44"
+gem "fog-google", "~> 1.7.1"
+gem "fog-local", "~> 0.3"
+gem "fog-openstack", "~> 0.1"
+gem "fog-rackspace", "~> 0.1.1"
+gem "fog-aliyun", "~> 0.2.0"
# for Google storage
-gem 'google-api-client', '~> 0.23'
+gem "google-api-client", "~> 0.23"
# for aws storage
-gem 'unf', '~> 0.1.4'
+gem "unf", "~> 0.1.4"
# Seed data
-gem 'seed-fu', '~> 2.3.7'
+gem "seed-fu", "~> 2.3.7"
# Markdown and HTML processing
-gem 'html-pipeline', '~> 2.8'
-gem 'deckar01-task_list', '2.2.0'
-gem 'gitlab-markup', '~> 1.6.5'
-gem 'github-markup', '~> 1.7.0', require: 'github/markup'
-gem 'commonmarker', '~> 0.17'
-gem 'RedCloth', '~> 4.3.2'
-gem 'rdoc', '~> 6.0'
-gem 'org-ruby', '~> 0.9.12'
-gem 'creole', '~> 0.5.0'
-gem 'wikicloth', '0.8.1'
-gem 'asciidoctor', '~> 1.5.8'
-gem 'asciidoctor-plantuml', '0.0.8'
-gem 'rouge', '~> 3.1'
-gem 'truncato', '~> 0.7.11'
-gem 'bootstrap_form', '~> 2.7.0'
-gem 'nokogiri', '~> 1.10.1'
-gem 'escape_utils', '~> 1.1'
+gem "html-pipeline", "~> 2.8"
+gem "deckar01-task_list", "2.2.0"
+gem "gitlab-markup", "~> 1.6.5"
+gem "github-markup", "~> 1.7.0", require: "github/markup"
+gem "commonmarker", "~> 0.17"
+gem "RedCloth", "~> 4.3.2"
+gem "rdoc", "~> 6.0"
+gem "org-ruby", "~> 0.9.12"
+gem "creole", "~> 0.5.0"
+gem "wikicloth", "0.8.1"
+gem "asciidoctor", "~> 1.5.8"
+gem "asciidoctor-plantuml", "0.0.8"
+gem "rouge", "~> 3.1"
+gem "truncato", "~> 0.7.11"
+gem "bootstrap_form", "~> 2.7.0"
+gem "nokogiri", "~> 1.10.1"
+gem "escape_utils", "~> 1.1"
# Calendar rendering
-gem 'icalendar'
+gem "icalendar"
# Diffs
-gem 'diffy', '~> 3.1.0'
+gem "diffy", "~> 3.1.0"
# Application server
# The 2.0.6 version of rack requires monkeypatch to be present in
# `config.ru`. This can be removed once a new update for Rack
# is available that contains https://github.com/rack/rack/pull/1201.
-gem 'rack', '2.0.6'
+gem "rack", "2.0.6"
group :unicorn do
- gem 'unicorn', '~> 5.4.1'
- gem 'unicorn-worker-killer', '~> 0.4.4'
+ gem "unicorn", "~> 5.4.1"
+ gem "unicorn-worker-killer", "~> 0.4.4"
end
group :puma do
- gem 'puma', '~> 3.12', require: false
- gem 'puma_worker_killer', require: false
+ gem "puma", "~> 3.12", require: false
+ gem "puma_worker_killer", require: false
end
# State machine
-gem 'state_machines-activerecord', '~> 0.5.1'
+gem "state_machines-activerecord", "~> 0.5.1"
# Issue tags
-gem 'acts-as-taggable-on', '~> 5.0'
+gem "acts-as-taggable-on", "~> 5.0"
# Background jobs
-gem 'sidekiq', '~> 5.2.1'
-gem 'sidekiq-cron', '~> 1.0'
-gem 'redis-namespace', '~> 1.6.0'
-gem 'gitlab-sidekiq-fetcher', '~> 0.4.0', require: 'sidekiq-reliable-fetch'
+gem "sidekiq", "~> 5.2.1"
+gem "sidekiq-cron", "~> 1.0"
+gem "redis-namespace", "~> 1.6.0"
+gem "gitlab-sidekiq-fetcher", "~> 0.4.0", require: "sidekiq-reliable-fetch"
# Cron Parser
-gem 'fugit', '~> 1.1'
+gem "fugit", "~> 1.1"
# HTTP requests
-gem 'httparty', '~> 0.13.3'
+gem "httparty", "~> 0.13.3"
# Colored output to console
-gem 'rainbow', '~> 3.0'
+gem "rainbow", "~> 3.0"
# Progress bar
-gem 'ruby-progressbar'
+gem "ruby-progressbar"
# GitLab settings
-gem 'settingslogic', '~> 2.0.9'
+gem "settingslogic", "~> 2.0.9"
# Linear-time regex library for untrusted regular expressions
-gem 're2', '~> 1.1.1'
+gem "re2", "~> 1.1.1"
# Misc
-gem 'version_sorter', '~> 2.2.4'
+gem "version_sorter", "~> 2.2.4"
# Export Ruby Regex to Javascript
-gem 'js_regex', '~> 3.1'
+gem "js_regex", "~> 3.1"
# User agent parsing
-gem 'device_detector'
+gem "device_detector"
# Cache
-gem 'redis-rails', '~> 5.0.2'
+gem "redis-rails", "~> 5.0.2"
# Redis
-gem 'redis', '~> 3.2'
-gem 'connection_pool', '~> 2.0'
+gem "redis", "~> 3.2"
+gem "connection_pool", "~> 2.0"
# Discord integration
-gem 'discordrb-webhooks-blackst0ne', '~> 3.3', require: false
+gem "discordrb-webhooks-blackst0ne", "~> 3.3", require: false
# JIRA integration
-gem 'jira-ruby', '~> 1.4'
+gem "jira-ruby", "~> 1.4"
# Flowdock integration
-gem 'flowdock', '~> 0.7'
+gem "flowdock", "~> 0.7"
# Slack integration
-gem 'slack-notifier', '~> 1.5.1'
+gem "slack-notifier", "~> 1.5.1"
# Hangouts Chat integration
-gem 'hangouts-chat', '~> 0.0.5'
+gem "hangouts-chat", "~> 0.0.5"
# Asana integration
-gem 'asana', '~> 0.8.1'
+gem "asana", "~> 0.8.1"
# FogBugz integration
-gem 'ruby-fogbugz', '~> 0.2.1'
+gem "ruby-fogbugz", "~> 0.2.1"
# Kubernetes integration
-gem 'kubeclient', '~> 4.2.2'
+gem "kubeclient", "~> 4.2.2"
# Sanitize user input
-gem 'sanitize', '~> 4.6'
-gem 'babosa', '~> 1.0.2'
+gem "sanitize", "~> 4.6"
+gem "babosa", "~> 1.0.2"
# Sanitizes SVG input
-gem 'loofah', '~> 2.2'
+gem "loofah", "~> 2.2"
# Working with license
-gem 'licensee', '~> 8.9'
+gem "licensee", "~> 8.9"
# Protect against bruteforcing
-gem 'rack-attack', '~> 4.4.1'
+gem "rack-attack", "~> 4.4.1"
# Ace editor
-gem 'ace-rails-ap', '~> 4.1.0'
+gem "ace-rails-ap", "~> 4.1.0"
# Detect and convert string character encoding
-gem 'charlock_holmes', '~> 0.7.5'
+gem "charlock_holmes", "~> 0.7.5"
# Detect mime content type from content
-gem 'mimemagic', '~> 0.3.2'
+gem "mimemagic", "~> 0.3.2"
# Faster blank
-gem 'fast_blank'
+gem "fast_blank"
# Parse time & duration
-gem 'chronic', '~> 0.10.2'
-gem 'chronic_duration', '~> 0.10.6'
-
-gem 'webpack-rails', '~> 0.9.10'
-gem 'rack-proxy', '~> 0.6.0'
-
-gem 'sass-rails', '~> 5.0.6'
-gem 'sass', '~> 3.5'
-gem 'uglifier', '~> 2.7.2'
-
-gem 'addressable', '~> 2.5.2'
-gem 'font-awesome-rails', '~> 4.7'
-gem 'gemojione', '~> 3.3'
-gem 'gon', '~> 6.2'
-gem 'jquery-atwho-rails', '~> 1.3.2'
-gem 'request_store', '~> 1.3'
-gem 'select2-rails', '~> 3.5.9'
-gem 'virtus', '~> 1.0.1'
-gem 'base32', '~> 0.3.0'
+gem "chronic", "~> 0.10.2"
+gem "chronic_duration", "~> 0.10.6"
+
+gem "webpack-rails", "~> 0.9.10"
+gem "rack-proxy", "~> 0.6.0"
+
+gem "sass-rails", "~> 5.0.6"
+gem "sass", "~> 3.5"
+gem "uglifier", "~> 2.7.2"
+
+gem "addressable", "~> 2.5.2"
+gem "font-awesome-rails", "~> 4.7"
+gem "gemojione", "~> 3.3"
+gem "gon", "~> 6.2"
+gem "jquery-atwho-rails", "~> 1.3.2"
+gem "request_store", "~> 1.3"
+gem "select2-rails", "~> 3.5.9"
+gem "virtus", "~> 1.0.1"
+gem "base32", "~> 0.3.0"
# Sentry integration
-gem 'sentry-raven', '~> 2.7'
+gem "sentry-raven", "~> 2.7"
-gem 'premailer-rails', '~> 1.9.7'
+gem "premailer-rails", "~> 1.9.7"
# I18n
-gem 'ruby_parser', '~> 3.8', require: false
-gem 'rails-i18n', '~> 5.1'
-gem 'gettext_i18n_rails', '~> 1.8.0'
-gem 'gettext_i18n_rails_js', '~> 1.3'
-gem 'gettext', '~> 3.2.2', require: false, group: :development
+gem "ruby_parser", "~> 3.8", require: false
+gem "rails-i18n", "~> 5.1"
+gem "gettext_i18n_rails", "~> 1.8.0"
+gem "gettext_i18n_rails_js", "~> 1.3"
+gem "gettext", "~> 3.2.2", require: false, group: :development
-gem 'batch-loader', '~> 1.2.2'
+gem "batch-loader", "~> 1.2.2"
# Perf bar
-gem 'peek', '~> 1.0.1'
-gem 'peek-gc', '~> 0.0.2'
-gem 'peek-mysql2', '~> 1.2.0', group: :mysql
-gem 'peek-pg', '~> 1.3.0', group: :postgres
-gem 'peek-rblineprof', '~> 0.2.0'
-gem 'peek-redis', '~> 1.2.0'
+gem "peek", "~> 1.0.1"
+gem "peek-gc", "~> 0.0.2"
+gem "peek-mysql2", "~> 1.2.0", group: :mysql
+gem "peek-pg", "~> 1.3.0", group: :postgres
+gem "peek-rblineprof", "~> 0.2.0"
+gem "peek-redis", "~> 1.2.0"
# Metrics
group :metrics do
- gem 'method_source', '~> 0.8', require: false
- gem 'influxdb', '~> 0.2', require: false
+ gem "method_source", "~> 0.8", require: false
+ gem "influxdb", "~> 0.2", require: false
# Prometheus
- gem 'prometheus-client-mmap', '~> 0.9.4'
- gem 'raindrops', '~> 0.18'
+ gem "prometheus-client-mmap", "~> 0.9.4"
+ gem "raindrops", "~> 0.18"
end
group :tracing do
# OpenTracing
- gem 'opentracing', '~> 0.4.3'
- gem 'jaeger-client', '~> 0.10.0'
+ gem "opentracing", "~> 0.4.3"
+ gem "jaeger-client", "~> 0.10.0"
end
group :development do
- gem 'foreman', '~> 0.84.0'
- gem 'brakeman', '~> 4.2', require: false
+ gem "foreman", "~> 0.84.0"
+ gem "brakeman", "~> 4.2", require: false
- gem 'letter_opener_web', '~> 1.3.0'
- gem 'rblineprof', '~> 0.3.6', platform: :mri, require: false
+ gem "letter_opener_web", "~> 1.3.0"
+ gem "rblineprof", "~> 0.3.6", platform: :mri, require: false
# Better errors handler
- gem 'better_errors', '~> 2.5.0'
- gem 'binding_of_caller', '~> 0.8.0'
+ gem "better_errors", "~> 2.5.0"
+ gem "binding_of_caller", "~> 0.8.0"
# thin instead webrick
- gem 'thin', '~> 1.7.0'
+ gem "thin", "~> 1.7.0"
end
group :development, :test do
- gem 'bootsnap', '~> 1.3'
- gem 'bullet', '~> 5.5.0', require: !!ENV['ENABLE_BULLET']
- gem 'pry-byebug', '~> 3.5.1', platform: :mri
- gem 'pry-rails', '~> 0.3.4'
-
- gem 'awesome_print', require: false
- gem 'fuubar', '~> 2.2.0'
-
- gem 'database_cleaner', '~> 1.7.0'
- gem 'factory_bot_rails', '~> 4.8.2'
- gem 'rspec-rails', '~> 3.7.0'
- gem 'rspec-retry', '~> 0.4.5'
- gem 'rspec_profiling', '~> 0.0.5'
- gem 'rspec-set', '~> 0.1.3'
- gem 'rspec-parameterized', require: false
+ gem "bootsnap", "~> 1.3"
+ gem "bullet", "~> 5.5.0", require: !!ENV["ENABLE_BULLET"]
+ gem "pry-byebug", "~> 3.5.1", platform: :mri
+ gem "pry-rails", "~> 0.3.4"
+
+ gem "awesome_print", require: false
+ gem "fuubar", "~> 2.2.0"
+
+ gem "database_cleaner", "~> 1.7.0"
+ gem "factory_bot_rails", "~> 4.8.2"
+ gem "rspec-rails", "~> 3.7.0"
+ gem "rspec-retry", "~> 0.4.5"
+ gem "rspec_profiling", "~> 0.0.5"
+ gem "rspec-set", "~> 0.1.3"
+ gem "rspec-parameterized", require: false
# Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
- gem 'minitest', '~> 5.11.0'
+ gem "minitest", "~> 5.11.0"
# Generate Fake data
- gem 'ffaker', '~> 2.10'
+ gem "ffaker", "~> 2.10"
- gem 'capybara', '~> 2.16.1'
- gem 'capybara-screenshot', '~> 1.0.18'
- gem 'selenium-webdriver', '~> 3.12'
+ gem "capybara", "~> 2.16.1"
+ gem "capybara-screenshot", "~> 1.0.18"
+ gem "selenium-webdriver", "~> 3.12"
- gem 'spring', '~> 2.0.0'
- gem 'spring-commands-rspec', '~> 1.0.4'
+ gem "spring", "~> 2.0.0"
+ gem "spring-commands-rspec", "~> 1.0.4"
- gem 'gitlab-styles', '~> 2.4', require: false
# Pin these dependencies, otherwise a new rule could break the CI pipelines
- gem 'rubocop', '~> 0.54.0'
- gem 'rubocop-rspec', '~> 1.22.1'
+ gem "rubocop"
+ gem "rubocop-rspec"
- gem 'scss_lint', '~> 0.56.0', require: false
- gem 'haml_lint', '~> 0.28.0', require: false
- gem 'simplecov', '~> 0.14.0', require: false
- gem 'bundler-audit', '~> 0.5.0', require: false
+ gem "standard"
- gem 'benchmark-ips', '~> 2.3.0', require: false
+ gem "scss_lint", "~> 0.56.0", require: false
+ gem "haml_lint", "~> 0.28.0", require: false
+ gem "simplecov", "~> 0.14.0", require: false
+ gem "bundler-audit", "~> 0.5.0", require: false
- gem 'license_finder', '~> 5.4', require: false
- gem 'knapsack', '~> 1.17'
+ gem "benchmark-ips", "~> 2.3.0", require: false
- gem 'activerecord_sane_schema_dumper', '1.0'
+ gem "license_finder", "~> 5.4", require: false
+ gem "knapsack", "~> 1.17"
- gem 'stackprof', '~> 0.2.10', require: false
+ gem "activerecord_sane_schema_dumper", "1.0"
- gem 'simple_po_parser', '~> 1.1.2', require: false
+ gem "stackprof", "~> 0.2.10", require: false
- gem 'timecop', '~> 0.8.0'
+ gem "simple_po_parser", "~> 1.1.2", require: false
+
+ gem "timecop", "~> 0.8.0"
end
group :test do
- gem 'shoulda-matchers', '~> 3.1.2', require: false
- gem 'email_spec', '~> 2.2.0'
- gem 'json-schema', '~> 2.8.0'
- gem 'webmock', '~> 3.5.1'
- gem 'rails-controller-testing'
- gem 'sham_rack', '~> 1.3.6'
- gem 'concurrent-ruby', '~> 1.1'
- gem 'test-prof', '~> 0.2.5'
- gem 'rspec_junit_formatter'
+ gem "shoulda-matchers", "~> 3.1.2", require: false
+ gem "email_spec", "~> 2.2.0"
+ gem "json-schema", "~> 2.8.0"
+ gem "webmock", "~> 3.5.1"
+ gem "rails-controller-testing"
+ gem "sham_rack", "~> 1.3.6"
+ gem "concurrent-ruby", "~> 1.1"
+ gem "test-prof", "~> 0.2.5"
+ gem "rspec_junit_formatter"
end
-gem 'octokit', '~> 4.9'
+gem "octokit", "~> 4.9"
-gem 'mail_room', '~> 0.9.1'
+gem "mail_room", "~> 0.9.1"
-gem 'email_reply_trimmer', '~> 0.1'
-gem 'html2text'
+gem "email_reply_trimmer", "~> 0.1"
+gem "html2text"
-gem 'ruby-prof', '~> 0.17.0'
-gem 'rbtrace', '~> 0.4', require: false
+gem "ruby-prof", "~> 0.17.0"
+gem "rbtrace", "~> 0.4", require: false
# OAuth
-gem 'oauth2', '~> 1.4'
+gem "oauth2", "~> 1.4"
# Health check
-gem 'health_check', '~> 2.6.0'
+gem "health_check", "~> 2.6.0"
# System information
-gem 'vmstat', '~> 2.3.0'
-gem 'sys-filesystem', '~> 1.1.6'
+gem "vmstat", "~> 2.3.0"
+gem "sys-filesystem", "~> 1.1.6"
# SSH host key support
-gem 'net-ssh', '~> 5.0'
-gem 'sshkey', '~> 2.0'
+gem "net-ssh", "~> 5.0"
+gem "sshkey", "~> 2.0"
# Required for ED25519 SSH host key support
group :ed25519 do
- gem 'ed25519', '~> 1.2'
- gem 'bcrypt_pbkdf', '~> 1.0'
+ gem "ed25519", "~> 1.2"
+ gem "bcrypt_pbkdf", "~> 1.0"
end
# Gitaly GRPC client
-gem 'gitaly-proto', '~> 1.12.0', require: 'gitaly'
+gem "gitaly-proto", "~> 1.12.0", require: "gitaly"
-gem 'grpc', '~> 1.15.0'
+gem "grpc", "~> 1.15.0"
-gem 'google-protobuf', '~> 3.6'
+gem "google-protobuf", "~> 3.6"
-gem 'toml-rb', '~> 1.0.0', require: false
+gem "toml-rb", "~> 1.0.0", require: false
# Feature toggles
-gem 'flipper', '~> 0.13.0'
-gem 'flipper-active_record', '~> 0.13.0'
-gem 'flipper-active_support_cache_store', '~> 0.13.0'
+gem "flipper", "~> 0.13.0"
+gem "flipper-active_record", "~> 0.13.0"
+gem "flipper-active_support_cache_store", "~> 0.13.0"
# Structured logging
-gem 'lograge', '~> 0.5'
-gem 'grape_logging', '~> 1.7'
+gem "lograge", "~> 0.5"
+gem "grape_logging", "~> 1.7"
diff --git a/Gemfile.lock b/Gemfile.lock
index 59e152c27fb..0dfd3dc750c 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -286,10 +286,6 @@ GEM
gitlab-markup (1.6.5)
gitlab-sidekiq-fetcher (0.4.0)
sidekiq (~> 5)
- gitlab-styles (2.5.1)
- rubocop (~> 0.54.0)
- rubocop-gitlab-security (~> 0.1.0)
- rubocop-rspec (~> 1.19)
gitlab_omniauth-ldap (2.0.4)
net-ldap (~> 0.16)
omniauth (~> 1.3)
@@ -393,6 +389,7 @@ GEM
jaeger-client (0.10.0)
opentracing (~> 0.3)
thrift
+ jaro_winkler (1.5.2)
jira-ruby (1.4.1)
activesupport
multipart-post
@@ -556,7 +553,7 @@ GEM
rubypants (~> 0.2)
orm_adapter (0.5.0)
os (1.0.0)
- parallel (1.12.1)
+ parallel (1.14.0)
parser (2.5.3.0)
ast (~> 2.4.0)
parslet (1.8.2)
@@ -586,7 +583,7 @@ GEM
pg (1.1.3)
po_to_json (1.0.1)
json (>= 1.6.0)
- powerpack (0.1.1)
+ powerpack (0.1.2)
premailer (1.10.4)
addressable
css_parser (>= 1.4.10)
@@ -608,6 +605,7 @@ GEM
pry (~> 0.10)
pry-rails (0.3.6)
pry (>= 0.10.4)
+ psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.0)
puma_worker_killer (0.1.0)
@@ -760,15 +758,15 @@ GEM
pg
rails
sqlite3
- rubocop (0.54.0)
+ rubocop (0.65.0)
+ jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
- parser (>= 2.5)
+ parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
+ psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
- unicode-display_width (~> 1.0, >= 1.0.1)
- rubocop-gitlab-security (0.1.1)
- rubocop (>= 0.51)
+ unicode-display_width (~> 1.4.0)
rubocop-rspec (1.22.2)
rubocop (>= 0.52.1)
ruby-enum (0.7.2)
@@ -776,7 +774,7 @@ GEM
ruby-fogbugz (0.2.1)
crack (~> 0.4)
ruby-prof (0.17.0)
- ruby-progressbar (1.9.0)
+ ruby-progressbar (1.10.0)
ruby-saml (1.7.2)
nokogiri (>= 1.5.10)
ruby_parser (3.11.0)
@@ -857,6 +855,8 @@ GEM
sqlite3 (1.3.13)
sshkey (2.0.0)
stackprof (0.2.10)
+ standard (0.0.32)
+ rubocop (>= 0.63)
state_machines (0.5.0)
state_machines-activemodel (0.5.1)
activemodel (>= 4.1, < 6.0)
@@ -897,7 +897,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
- unicode-display_width (1.3.2)
+ unicode-display_width (1.4.1)
unicorn (5.4.1)
kgio (~> 2.6)
raindrops (~> 0.7)
@@ -1022,7 +1022,6 @@ DEPENDENCIES
gitlab-default_value_for (~> 3.1.1)
gitlab-markup (~> 1.6.5)
gitlab-sidekiq-fetcher (~> 0.4.0)
- gitlab-styles (~> 2.4)
gitlab_omniauth-ldap (~> 2.0.4)
gon (~> 6.2)
google-api-client (~> 0.23)
@@ -1130,8 +1129,8 @@ DEPENDENCIES
rspec-set (~> 0.1.3)
rspec_junit_formatter
rspec_profiling (~> 0.0.5)
- rubocop (~> 0.54.0)
- rubocop-rspec (~> 1.22.1)
+ rubocop
+ rubocop-rspec
ruby-fogbugz (~> 0.2.1)
ruby-prof (~> 0.17.0)
ruby-progressbar
@@ -1159,6 +1158,7 @@ DEPENDENCIES
sprockets (~> 3.7.0)
sshkey (~> 2.0)
stackprof (~> 0.2.10)
+ standard
state_machines-activerecord (~> 0.5.1)
sys-filesystem (~> 1.1.6)
test-prof (~> 0.2.5)
diff --git a/Rakefile b/Rakefile
index de0d6695c7b..5c91c26db06 100755
--- a/Rakefile
+++ b/Rakefile
@@ -2,9 +2,9 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
-require File.expand_path('config/application', __dir__)
+require File.expand_path("config/application", __dir__)
-relative_url_conf = File.expand_path('config/initializers/relative_url', __dir__)
+relative_url_conf = File.expand_path("config/initializers/relative_url", __dir__)
require relative_url_conf if File.exist?("#{relative_url_conf}.rb")
Gitlab::Application.load_tasks
diff --git a/app/controllers/abuse_reports_controller.rb b/app/controllers/abuse_reports_controller.rb
index 68e14f0c2e5..10c9de2d177 100644
--- a/app/controllers/abuse_reports_controller.rb
+++ b/app/controllers/abuse_reports_controller.rb
@@ -6,7 +6,7 @@ class AbuseReportsController < ApplicationController
def new
@abuse_report = AbuseReport.new
@abuse_report.user_id = @user.id
- @ref_url = params.fetch(:ref_url, '')
+ @ref_url = params.fetch(:ref_url, "")
end
def create
@@ -26,10 +26,10 @@ class AbuseReportsController < ApplicationController
private
def report_params
- params.require(:abuse_report).permit(%i(
+ params.require(:abuse_report).permit(%i[
message
user_id
- ))
+ ])
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/controllers/admin/appearances_controller.rb b/app/controllers/admin/appearances_controller.rb
index 189fee98aa0..664bb99c95c 100644
--- a/app/controllers/admin/appearances_controller.rb
+++ b/app/controllers/admin/appearances_controller.rb
@@ -7,24 +7,24 @@ class Admin::AppearancesController < Admin::ApplicationController
end
def preview_sign_in
- render 'preview_sign_in', layout: 'devise'
+ render "preview_sign_in", layout: "devise"
end
def create
@appearance = Appearance.new(appearance_params)
if @appearance.save
- redirect_to admin_appearances_path, notice: 'Appearance was successfully created.'
+ redirect_to admin_appearances_path, notice: "Appearance was successfully created."
else
- render action: 'show'
+ render action: "show"
end
end
def update
if @appearance.update(appearance_params)
- redirect_to admin_appearances_path, notice: 'Appearance was successfully updated.'
+ redirect_to admin_appearances_path, notice: "Appearance was successfully updated."
else
- render action: 'show'
+ render action: "show"
end
end
@@ -33,21 +33,21 @@ class Admin::AppearancesController < Admin::ApplicationController
@appearance.save
- redirect_to admin_appearances_path, notice: 'Logo was successfully removed.'
+ redirect_to admin_appearances_path, notice: "Logo was successfully removed."
end
def header_logos
@appearance.remove_header_logo!
@appearance.save
- redirect_to admin_appearances_path, notice: 'Header logo was successfully removed.'
+ redirect_to admin_appearances_path, notice: "Header logo was successfully removed."
end
def favicon
@appearance.remove_favicon!
@appearance.save
- redirect_to admin_appearances_path, notice: 'Favicon was successfully removed.'
+ redirect_to admin_appearances_path, notice: "Favicon was successfully removed."
end
private
diff --git a/app/controllers/admin/application_controller.rb b/app/controllers/admin/application_controller.rb
index ef182b981f1..2466b8c68df 100644
--- a/app/controllers/admin/application_controller.rb
+++ b/app/controllers/admin/application_controller.rb
@@ -5,7 +5,7 @@
# Automatically sets the layout and ensures an administrator is logged in
class Admin::ApplicationController < ApplicationController
before_action :authenticate_admin!
- layout 'admin'
+ layout "admin"
def authenticate_admin!
render_404 unless current_user.admin?
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 8f267eccc8a..eb8fddbb626 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -48,7 +48,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
respond_to do |format|
if successful
format.json { head :ok }
- format.html { redirect_to redirect_path, notice: 'Application settings saved successfully' }
+ format.html { redirect_to redirect_path, notice: "Application settings saved successfully" }
else
format.json { head :bad_request }
format.html { render :show }
@@ -61,7 +61,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
format.html do
usage_data_json = JSON.pretty_generate(Gitlab::UsageData.data)
- render html: Gitlab::Highlight.highlight('payload.json', usage_data_json, language: 'json')
+ render html: Gitlab::Highlight.highlight("payload.json", usage_data_json, language: "json")
end
format.json { render json: Gitlab::UsageData.to_json }
end
@@ -70,13 +70,13 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
def reset_registration_token
@application_setting.reset_runners_registration_token!
- flash[:notice] = 'New runners registration token has been generated!'
+ flash[:notice] = "New runners registration token has been generated!"
redirect_to admin_runners_path
end
def reset_health_check_token
@application_setting.reset_health_check_access_token!
- flash[:notice] = 'New health check access token has been generated!'
+ flash[:notice] = "New health check access token has been generated!"
redirect_back_or_default
end
@@ -85,7 +85,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
redirect_to(
admin_application_settings_path,
- notice: 'Started asynchronous removal of all repository check states.'
+ notice: "Started asynchronous removal of all repository check states."
)
end
@@ -129,7 +129,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
disabled_oauth_sign_in_sources: [],
import_sources: [],
repository_storages: [],
- restricted_visibility_levels: []
+ restricted_visibility_levels: [],
]
end
end
diff --git a/app/controllers/admin/applications_controller.rb b/app/controllers/admin/applications_controller.rb
index 6fc336714b6..6489fa8f376 100644
--- a/app/controllers/admin/applications_controller.rb
+++ b/app/controllers/admin/applications_controller.rb
@@ -34,7 +34,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
def update
if @application.update(application_params)
- redirect_to admin_application_path(@application), notice: 'Application was successfully updated.'
+ redirect_to admin_application_path(@application), notice: "Application was successfully updated."
else
render :edit
end
@@ -42,7 +42,7 @@ class Admin::ApplicationsController < Admin::ApplicationController
def destroy
@application.destroy
- redirect_to admin_applications_url, status: 302, notice: 'Application was successfully destroyed.'
+ redirect_to admin_applications_url, status: 302, notice: "Application was successfully destroyed."
end
private
diff --git a/app/controllers/admin/broadcast_messages_controller.rb b/app/controllers/admin/broadcast_messages_controller.rb
index a91d9a534cd..dbd3469f232 100644
--- a/app/controllers/admin/broadcast_messages_controller.rb
+++ b/app/controllers/admin/broadcast_messages_controller.rb
@@ -19,7 +19,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
@broadcast_message = BroadcastMessage.new(broadcast_message_params)
if @broadcast_message.save
- redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully created.'
+ redirect_to admin_broadcast_messages_path, notice: "Broadcast Message was successfully created."
else
render :index
end
@@ -27,7 +27,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
def update
if @broadcast_message.update(broadcast_message_params)
- redirect_to admin_broadcast_messages_path, notice: 'Broadcast Message was successfully updated.'
+ redirect_to admin_broadcast_messages_path, notice: "Broadcast Message was successfully updated."
else
render :edit
end
@@ -37,14 +37,14 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
@broadcast_message.destroy
respond_to do |format|
- format.html { redirect_back_or_default(default: { action: 'index' }) }
+ format.html { redirect_back_or_default(default: {action: "index"}) }
format.js { head :ok }
end
end
def preview
broadcast_message = BroadcastMessage.new(broadcast_message_params)
- render json: { message: render_broadcast_message(broadcast_message) }
+ render json: {message: render_broadcast_message(broadcast_message)}
end
protected
@@ -54,12 +54,12 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
end
def broadcast_message_params
- params.require(:broadcast_message).permit(%i(
+ params.require(:broadcast_message).permit(%i[
color
ends_at
font
message
starts_at
- ))
+ ])
end
end
diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb
index 23cc9ee247a..b59844bff58 100644
--- a/app/controllers/admin/dashboard_controller.rb
+++ b/app/controllers/admin/dashboard_controller.rb
@@ -4,7 +4,7 @@ class Admin::DashboardController < Admin::ApplicationController
include CountHelper
COUNTED_ITEMS = [Project, User, Group, ForkNetworkMember, ForkNetwork, Issue,
- MergeRequest, Note, Snippet, Key, Milestone].freeze
+ MergeRequest, Note, Snippet, Key, Milestone,].freeze
# rubocop: disable CodeReuse/ActiveRecord
def index
diff --git a/app/controllers/admin/deploy_keys_controller.rb b/app/controllers/admin/deploy_keys_controller.rb
index 49ce275ad14..c76adcc1852 100644
--- a/app/controllers/admin/deploy_keys_controller.rb
+++ b/app/controllers/admin/deploy_keys_controller.rb
@@ -16,7 +16,7 @@ class Admin::DeployKeysController < Admin::ApplicationController
if @deploy_key.persisted?
redirect_to admin_deploy_keys_path
else
- render 'new'
+ render "new"
end
end
@@ -25,10 +25,10 @@ class Admin::DeployKeysController < Admin::ApplicationController
def update
if deploy_key.update(update_params)
- flash[:notice] = 'Deploy key was successfully updated.'
+ flash[:notice] = "Deploy key was successfully updated."
redirect_to admin_deploy_keys_path
else
- render 'edit'
+ render "edit"
end
end
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index 46e85e1424f..a2f3b2b8e52 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -14,11 +14,13 @@ class Admin::GroupsController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def show
- @group = Group.with_statistics.joins(:route).group('routes.path').find_by_full_path(params[:id])
+ @group = Group.with_statistics.joins(:route).group("routes.path").find_by_full_path(params[:id])
@members = present_members(
- @group.members.order("access_level DESC").page(params[:members_page]))
+ @group.members.order("access_level DESC").page(params[:members_page])
+ )
@requesters = present_members(
- AccessRequestsFinder.new(@group).execute(current_user))
+ AccessRequestsFinder.new(@group).execute(current_user)
+ )
@projects = @group.projects.with_statistics.page(params[:projects_page])
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -44,7 +46,7 @@ class Admin::GroupsController < Admin::ApplicationController
def update
if @group.update(group_params)
- redirect_to [:admin, @group], notice: 'Group was successfully updated.'
+ redirect_to [:admin, @group], notice: "Group was successfully updated."
else
render "edit"
end
@@ -55,7 +57,7 @@ class Admin::GroupsController < Admin::ApplicationController
result = Members::CreateService.new(current_user, member_params.merge(limit: -1)).execute(@group)
if result[:status] == :success
- redirect_to [:admin, @group], notice: 'Users were successfully added.'
+ redirect_to [:admin, @group], notice: "Users were successfully added."
else
redirect_to [:admin, @group], alert: result[:message]
end
@@ -65,8 +67,8 @@ class Admin::GroupsController < Admin::ApplicationController
Groups::DestroyService.new(@group, current_user).async_execute
redirect_to admin_groups_path,
- status: 302,
- alert: "Group '#{@group.name}' was scheduled for deletion."
+ status: 302,
+ alert: "Group '#{@group.name}' was scheduled for deletion."
end
private
@@ -89,7 +91,7 @@ class Admin::GroupsController < Admin::ApplicationController
:request_access_enabled,
:visibility_level,
:require_two_factor_authentication,
- :two_factor_grace_period
+ :two_factor_grace_period,
]
end
end
diff --git a/app/controllers/admin/health_check_controller.rb b/app/controllers/admin/health_check_controller.rb
index 7cd80e8b5e1..daf19f2aa63 100644
--- a/app/controllers/admin/health_check_controller.rb
+++ b/app/controllers/admin/health_check_controller.rb
@@ -8,6 +8,6 @@ class Admin::HealthCheckController < Admin::ApplicationController
private
def checks
- ['standard']
+ ["standard"]
end
end
diff --git a/app/controllers/admin/hooks_controller.rb b/app/controllers/admin/hooks_controller.rb
index d0abdec50ae..1100bf8c9f6 100644
--- a/app/controllers/admin/hooks_controller.rb
+++ b/app/controllers/admin/hooks_controller.rb
@@ -14,7 +14,7 @@ class Admin::HooksController < Admin::ApplicationController
@hook = SystemHook.new(hook_params.to_h)
if @hook.save
- redirect_to admin_hooks_path, notice: 'Hook was successfully created.'
+ redirect_to admin_hooks_path, notice: "Hook was successfully created."
else
@hooks = SystemHook.all
render :index
@@ -26,10 +26,10 @@ class Admin::HooksController < Admin::ApplicationController
def update
if hook.update(hook_params)
- flash[:notice] = 'System hook was successfully updated.'
+ flash[:notice] = "System hook was successfully updated."
redirect_to admin_hooks_path
else
- render 'edit'
+ render "edit"
end
end
diff --git a/app/controllers/admin/identities_controller.rb b/app/controllers/admin/identities_controller.rb
index b51c2f678ca..714f7838eca 100644
--- a/app/controllers/admin/identities_controller.rb
+++ b/app/controllers/admin/identities_controller.rb
@@ -13,7 +13,7 @@ class Admin::IdentitiesController < Admin::ApplicationController
@identity.user_id = user.id
if @identity.save
- redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully created.'
+ redirect_to admin_user_identities_path(@user), notice: "User identity was successfully created."
else
render :new
end
@@ -29,7 +29,7 @@ class Admin::IdentitiesController < Admin::ApplicationController
def update
if @identity.update(identity_params)
RepairLdapBlockedUserService.new(@user).execute
- redirect_to admin_user_identities_path(@user), notice: 'User identity was successfully updated.'
+ redirect_to admin_user_identities_path(@user), notice: "User identity was successfully updated."
else
render :edit
end
@@ -38,9 +38,9 @@ class Admin::IdentitiesController < Admin::ApplicationController
def destroy
if @identity.destroy
RepairLdapBlockedUserService.new(@user).execute
- redirect_to admin_user_identities_path(@user), status: 302, notice: 'User identity was successfully removed.'
+ redirect_to admin_user_identities_path(@user), status: 302, notice: "User identity was successfully removed."
else
- redirect_to admin_user_identities_path(@user), status: 302, alert: 'Failed to remove user identity.'
+ redirect_to admin_user_identities_path(@user), status: 302, alert: "Failed to remove user identity."
end
end
diff --git a/app/controllers/admin/impersonation_tokens_controller.rb b/app/controllers/admin/impersonation_tokens_controller.rb
index 706bcc1e549..bbb7e76d918 100644
--- a/app/controllers/admin/impersonation_tokens_controller.rb
+++ b/app/controllers/admin/impersonation_tokens_controller.rb
@@ -40,7 +40,7 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
def finder(options = {})
- PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
+ PersonalAccessTokensFinder.new({user: user, impersonation: true}.merge(options))
end
def impersonation_token_params
@@ -52,8 +52,8 @@ class Admin::ImpersonationTokensController < Admin::ApplicationController
@scopes = Gitlab::Auth.available_scopes(current_user)
@impersonation_token ||= finder.build
- @inactive_impersonation_tokens = finder(state: 'inactive').execute
- @active_impersonation_tokens = finder(state: 'active').execute.order(:expires_at)
+ @inactive_impersonation_tokens = finder(state: "inactive").execute
+ @active_impersonation_tokens = finder(state: "active").execute.order(:expires_at)
@new_impersonation_token = PersonalAccessToken.redis_getdel(current_user.id)
end
diff --git a/app/controllers/admin/impersonations_controller.rb b/app/controllers/admin/impersonations_controller.rb
index 65fe22bd8f4..f0e160258f8 100644
--- a/app/controllers/admin/impersonations_controller.rb
+++ b/app/controllers/admin/impersonations_controller.rb
@@ -12,6 +12,6 @@ class Admin::ImpersonationsController < Admin::ApplicationController
private
def authenticate_impersonator!
- render_404 unless impersonator && impersonator.admin? && !impersonator.blocked?
+ render_404 unless impersonator&.admin? && !impersonator.blocked?
end
end
diff --git a/app/controllers/admin/jobs_controller.rb b/app/controllers/admin/jobs_controller.rb
index 0c1afdc3d3b..fc8e9f5b5e3 100644
--- a/app/controllers/admin/jobs_controller.rb
+++ b/app/controllers/admin/jobs_controller.rb
@@ -5,14 +5,14 @@ class Admin::JobsController < Admin::ApplicationController
def index
@scope = params[:scope]
@all_builds = Ci::Build
- @builds = @all_builds.order('id DESC')
+ @builds = @all_builds.order("id DESC")
@builds =
case @scope
- when 'pending'
+ when "pending"
@builds.pending.reverse_order
- when 'running'
+ when "running"
@builds.running.reverse_order
- when 'finished'
+ when "finished"
@builds.finished
else
@builds
diff --git a/app/controllers/admin/keys_controller.rb b/app/controllers/admin/keys_controller.rb
index 4e9262ccc96..5dfcac07988 100644
--- a/app/controllers/admin/keys_controller.rb
+++ b/app/controllers/admin/keys_controller.rb
@@ -17,9 +17,9 @@ class Admin::KeysController < Admin::ApplicationController
respond_to do |format|
if key.destroy
- format.html { redirect_to keys_admin_user_path(user), status: 302, notice: 'User key was successfully removed.' }
+ format.html { redirect_to keys_admin_user_path(user), status: 302, notice: "User key was successfully removed." }
else
- format.html { redirect_to keys_admin_user_path(user), status: 302, alert: 'Failed to remove user key.' }
+ format.html { redirect_to keys_admin_user_path(user), status: 302, alert: "Failed to remove user key." }
end
end
end
diff --git a/app/controllers/admin/labels_controller.rb b/app/controllers/admin/labels_controller.rb
index aa5eae7a474..8a29bff9bbc 100644
--- a/app/controllers/admin/labels_controller.rb
+++ b/app/controllers/admin/labels_controller.rb
@@ -31,7 +31,7 @@ class Admin::LabelsController < Admin::ApplicationController
@label = Labels::UpdateService.new(label_params).execute(@label)
if @label.valid?
- redirect_to admin_labels_path, notice: 'Label was successfully updated.'
+ redirect_to admin_labels_path, notice: "Label was successfully updated."
else
render :edit
end
@@ -43,7 +43,7 @@ class Admin::LabelsController < Admin::ApplicationController
respond_to do |format|
format.html do
- redirect_to admin_labels_path, status: 302, notice: 'Label was removed'
+ redirect_to admin_labels_path, status: 302, notice: "Label was removed"
end
format.js
end
diff --git a/app/controllers/admin/logs_controller.rb b/app/controllers/admin/logs_controller.rb
index 06b0e6a15a3..65cfe926cb5 100644
--- a/app/controllers/admin/logs_controller.rb
+++ b/app/controllers/admin/logs_controller.rb
@@ -15,7 +15,7 @@ class Admin::LogsController < Admin::ApplicationController
Gitlab::EnvironmentLogger,
Gitlab::SidekiqLogger,
Gitlab::RepositoryCheckLogger,
- Gitlab::ProjectServiceLogger
+ Gitlab::ProjectServiceLogger,
]
end
end
diff --git a/app/controllers/admin/projects_controller.rb b/app/controllers/admin/projects_controller.rb
index 550f29a58d2..34a7de84802 100644
--- a/app/controllers/admin/projects_controller.rb
+++ b/app/controllers/admin/projects_controller.rb
@@ -7,7 +7,7 @@ class Admin::ProjectsController < Admin::ApplicationController
before_action :group, only: [:show, :transfer]
def index
- params[:sort] ||= 'latest_activity_desc'
+ params[:sort] ||= "latest_activity_desc"
@sort = params[:sort]
@projects = Admin::ProjectsFinder.new(params: params, current_user: current_user).execute
@@ -15,7 +15,7 @@ class Admin::ProjectsController < Admin::ApplicationController
format.html
format.json do
render json: {
- html: view_to_html_string("admin/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("admin/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -25,13 +25,16 @@ class Admin::ProjectsController < Admin::ApplicationController
def show
if @group
@group_members = present_members(
- @group.members.order("access_level DESC").page(params[:group_members_page]))
+ @group.members.order("access_level DESC").page(params[:group_members_page])
+ )
end
@project_members = present_members(
- @project.members.page(params[:project_members_page]))
+ @project.members.page(params[:project_members_page])
+ )
@requesters = present_members(
- AccessRequestsFinder.new(@project).execute(current_user))
+ AccessRequestsFinder.new(@project).execute(current_user)
+ )
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -50,7 +53,7 @@ class Admin::ProjectsController < Admin::ApplicationController
redirect_to(
admin_project_path(@project),
- notice: 'Repository check was triggered.'
+ notice: "Repository check was triggered."
)
end
@@ -58,7 +61,7 @@ class Admin::ProjectsController < Admin::ApplicationController
def project
@project = Project.find_by_full_path(
- [params[:namespace_id], '/', params[:id]].join('')
+ [params[:namespace_id], "/", params[:id]].join("")
)
@project || render_404
end
diff --git a/app/controllers/admin/requests_profiles_controller.rb b/app/controllers/admin/requests_profiles_controller.rb
index 89d4c4f18d9..205447f5b9e 100644
--- a/app/controllers/admin/requests_profiles_controller.rb
+++ b/app/controllers/admin/requests_profiles_controller.rb
@@ -13,7 +13,7 @@ class Admin::RequestsProfilesController < Admin::ApplicationController
if profile
render html: profile.content.html_safe
else
- redirect_to admin_requests_profiles_path, alert: 'Profile not found'
+ redirect_to admin_requests_profiles_path, alert: "Profile not found"
end
end
end
diff --git a/app/controllers/admin/runner_projects_controller.rb b/app/controllers/admin/runner_projects_controller.rb
index 774ce04d079..877ac68f8bc 100644
--- a/app/controllers/admin/runner_projects_controller.rb
+++ b/app/controllers/admin/runner_projects_controller.rb
@@ -9,7 +9,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
if @runner.assign_to(@project, current_user)
redirect_to admin_runner_path(@runner)
else
- redirect_to admin_runner_path(@runner), alert: 'Failed adding runner to project'
+ redirect_to admin_runner_path(@runner), alert: "Failed adding runner to project"
end
end
@@ -25,7 +25,7 @@ class Admin::RunnerProjectsController < Admin::ApplicationController
def project
@project = Project.find_by_full_path(
- [params[:namespace_id], '/', params[:project_id]].join('')
+ [params[:namespace_id], "/", params[:project_id]].join("")
)
@project || render_404
end
diff --git a/app/controllers/admin/runners_controller.rb b/app/controllers/admin/runners_controller.rb
index 8a00408001e..049f4246abc 100644
--- a/app/controllers/admin/runners_controller.rb
+++ b/app/controllers/admin/runners_controller.rb
@@ -22,7 +22,7 @@ class Admin::RunnersController < Admin::ApplicationController
end
else
assign_builds_and_projects
- render 'show'
+ render "show"
end
end
@@ -34,17 +34,17 @@ class Admin::RunnersController < Admin::ApplicationController
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
- redirect_to admin_runners_path, notice: 'Runner was successfully updated.'
+ redirect_to admin_runners_path, notice: "Runner was successfully updated."
else
- redirect_to admin_runners_path, alert: 'Runner was not updated.'
+ redirect_to admin_runners_path, alert: "Runner was not updated."
end
end
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
- redirect_to admin_runners_path, notice: 'Runner was successfully updated.'
+ redirect_to admin_runners_path, notice: "Runner was successfully updated."
else
- redirect_to admin_runners_path, alert: 'Runner was not updated.'
+ redirect_to admin_runners_path, alert: "Runner was not updated."
end
end
@@ -66,7 +66,7 @@ class Admin::RunnersController < Admin::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def assign_builds_and_projects
- @builds = runner.builds.order('id DESC').first(30)
+ @builds = runner.builds.order("id DESC").first(30)
@projects =
if params[:search].present?
::Project.search(params[:search])
diff --git a/app/controllers/admin/services_controller.rb b/app/controllers/admin/services_controller.rb
index c455930c044..c4581eebf44 100644
--- a/app/controllers/admin/services_controller.rb
+++ b/app/controllers/admin/services_controller.rb
@@ -22,7 +22,7 @@ class Admin::ServicesController < Admin::ApplicationController
PropagateServiceTemplateWorker.perform_async(service.id) if service.active?
redirect_to admin_application_settings_services_path,
- notice: 'Application settings saved successfully'
+ notice: "Application settings saved successfully"
else
render :edit
end
@@ -46,6 +46,6 @@ class Admin::ServicesController < Admin::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42430')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42430")
end
end
diff --git a/app/controllers/admin/spam_logs_controller.rb b/app/controllers/admin/spam_logs_controller.rb
index 18d22c95b61..60f4ca018d8 100644
--- a/app/controllers/admin/spam_logs_controller.rb
+++ b/app/controllers/admin/spam_logs_controller.rb
@@ -13,8 +13,8 @@ class Admin::SpamLogsController < Admin::ApplicationController
if params[:remove_user]
spam_log.remove_user(deleted_by: current_user)
redirect_to admin_spam_logs_path,
- status: 302,
- notice: "User #{spam_log.user.username} was successfully removed."
+ status: 302,
+ notice: "User #{spam_log.user.username} was successfully removed."
else
spam_log.destroy
head :ok
@@ -25,9 +25,9 @@ class Admin::SpamLogsController < Admin::ApplicationController
spam_log = SpamLog.find(params[:id])
if HamService.new(spam_log).mark_as_ham!
- redirect_to admin_spam_logs_path, notice: 'Spam log successfully submitted as ham.'
+ redirect_to admin_spam_logs_path, notice: "Spam log successfully submitted as ham."
else
- redirect_to admin_spam_logs_path, alert: 'Error with Akismet. Please check the logs for more info.'
+ redirect_to admin_spam_logs_path, alert: "Error with Akismet. Please check the logs for more info."
end
end
end
diff --git a/app/controllers/admin/system_info_controller.rb b/app/controllers/admin/system_info_controller.rb
index 244fc2b31bb..bc4268fb8db 100644
--- a/app/controllers/admin/system_info_controller.rb
+++ b/app/controllers/admin/system_info_controller.rb
@@ -2,43 +2,51 @@
class Admin::SystemInfoController < Admin::ApplicationController
EXCLUDED_MOUNT_OPTIONS = [
- 'nobrowse',
- 'read-only',
- 'ro'
+ "nobrowse",
+ "read-only",
+ "ro",
].freeze
EXCLUDED_MOUNT_TYPES = [
- 'autofs',
- 'binfmt_misc',
- 'cgroup',
- 'debugfs',
- 'devfs',
- 'devpts',
- 'devtmpfs',
- 'efivarfs',
- 'fuse.gvfsd-fuse',
- 'fuseblk',
- 'fusectl',
- 'hugetlbfs',
- 'mqueue',
- 'proc',
- 'pstore',
- 'rpc_pipefs',
- 'securityfs',
- 'sysfs',
- 'tmpfs',
- 'tracefs',
- 'vfat'
+ "autofs",
+ "binfmt_misc",
+ "cgroup",
+ "debugfs",
+ "devfs",
+ "devpts",
+ "devtmpfs",
+ "efivarfs",
+ "fuse.gvfsd-fuse",
+ "fuseblk",
+ "fusectl",
+ "hugetlbfs",
+ "mqueue",
+ "proc",
+ "pstore",
+ "rpc_pipefs",
+ "securityfs",
+ "sysfs",
+ "tmpfs",
+ "tracefs",
+ "vfat",
].freeze
def show
- @cpus = Vmstat.cpu rescue nil
- @memory = Vmstat.memory rescue nil
+ @cpus = begin
+ Vmstat.cpu
+ rescue
+ nil
+ end
+ @memory = begin
+ Vmstat.memory
+ rescue
+ nil
+ end
mounts = Sys::Filesystem.mounts
@disks = []
mounts.each do |mount|
- mount_options = mount.options.split(',')
+ mount_options = mount.options.split(",")
next if (EXCLUDED_MOUNT_OPTIONS & mount_options).any?
next if (EXCLUDED_MOUNT_TYPES & [mount.mount_type]).any?
@@ -47,9 +55,9 @@ class Admin::SystemInfoController < Admin::ApplicationController
disk = Sys::Filesystem.stat(mount.mount_point)
@disks.push({
bytes_total: disk.bytes_total,
- bytes_used: disk.bytes_used,
- disk_name: mount.name,
- mount_path: disk.path
+ bytes_used: disk.bytes_used,
+ disk_name: mount.name,
+ mount_path: disk.path,
})
rescue Sys::Filesystem::Error
end
diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb
index bfa7c7d0109..17a2c7924ab 100644
--- a/app/controllers/admin/users_controller.rb
+++ b/app/controllers/admin/users_controller.rb
@@ -96,20 +96,20 @@ class Admin::UsersController < Admin::ApplicationController
update_user { |user| user.disable_two_factor! }
redirect_to admin_user_path(user),
- notice: 'Two-factor Authentication has been disabled for this user'
+ notice: "Two-factor Authentication has been disabled for this user"
end
def create
opts = {
reset_password: true,
- skip_confirmation: true
+ skip_confirmation: true,
}
@user = Users::CreateService.new(current_user, user_params.merge(opts)).execute
respond_to do |format|
if @user.persisted?
- format.html { redirect_to [:admin, @user], notice: 'User was successfully created.' }
+ format.html { redirect_to [:admin, @user], notice: "User was successfully created." }
format.json { render json: @user, status: :created, location: @user }
else
format.html { render "new" }
@@ -124,7 +124,7 @@ class Admin::UsersController < Admin::ApplicationController
if params[:user][:password].present?
password_params = {
password: params[:user][:password],
- password_confirmation: params[:user][:password_confirmation]
+ password_confirmation: params[:user][:password_confirmation],
}
password_params[:password_expires_at] = Time.now unless changing_own_password?
@@ -133,12 +133,12 @@ class Admin::UsersController < Admin::ApplicationController
end
respond_to do |format|
- result = Users::UpdateService.new(current_user, user_params_with_pass.merge(user: user)).execute do |user|
+ result = Users::UpdateService.new(current_user, user_params_with_pass.merge(user: user)).execute { |user|
user.skip_reconfirmation!
- end
+ }
if result[:status] == :success
- format.html { redirect_to [:admin, user], notice: 'User was successfully updated.' }
+ format.html { redirect_to [:admin, user], notice: "User was successfully updated." }
format.json { head :ok }
else
# restore username to keep form action url.
@@ -164,11 +164,11 @@ class Admin::UsersController < Admin::ApplicationController
respond_to do |format|
if success
- format.html { redirect_back_or_admin_user(notice: 'Successfully removed email.') }
+ format.html { redirect_back_or_admin_user(notice: "Successfully removed email.") }
format.json { head :ok }
else
- format.html { redirect_back_or_admin_user(alert: 'There was an error removing the e-mail.') }
- format.json { render json: 'There was an error removing the e-mail.', status: :bad_request }
+ format.html { redirect_back_or_admin_user(alert: "There was an error removing the e-mail.") }
+ format.json { render json: "There was an error removing the e-mail.", status: :bad_request }
end
end
end
@@ -223,7 +223,7 @@ class Admin::UsersController < Admin::ApplicationController
:theme_id,
:twitter,
:username,
- :website_url
+ :website_url,
]
end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index b7eb6af6d67..9f94d5eb3af 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'gon'
-require 'fogbugz'
+require "gon"
+require "fogbugz"
class ApplicationController < ActionController::Base
include Gitlab::GonHelper
@@ -45,8 +45,8 @@ class ApplicationController < ActionController::Base
# Adds `no-store` to the DEFAULT_CACHE_CONTROL, to prevent security
# concerns due to caching private data.
- DEFAULT_GITLAB_CACHE_CONTROL = "#{ActionDispatch::Http::Cache::Response::DEFAULT_CACHE_CONTROL}, no-store".freeze
- DEFAULT_GITLAB_CONTROL_NO_CACHE = "#{DEFAULT_GITLAB_CACHE_CONTROL}, no-cache".freeze
+ DEFAULT_GITLAB_CACHE_CONTROL = "#{ActionDispatch::Http::Cache::Response::DEFAULT_CACHE_CONTROL}, no-store"
+ DEFAULT_GITLAB_CONTROL_NO_CACHE = "#{DEFAULT_GITLAB_CACHE_CONTROL}, no-cache"
rescue_from Encoding::CompatibilityError do |exception|
log_exception(exception)
@@ -73,7 +73,7 @@ class ApplicationController < ActionController::Base
rescue_from GRPC::Unavailable, Gitlab::Git::CommandError do |exception|
log_exception(exception)
- headers['Retry-After'] = exception.retry_after if exception.respond_to?(:retry_after)
+ headers["Retry-After"] = exception.retry_after if exception.respond_to?(:retry_after)
render_503
end
@@ -105,18 +105,18 @@ class ApplicationController < ActionController::Base
return if current_user
# Rack sets this header, but not all tests may have it: https://github.com/rack/rack/blob/fdcd03a3c5a1c51d1f96fc97f9dfa1a9deac0c77/lib/rack/session/abstract/id.rb#L251-L259
- return unless request.env['rack.session.options']
+ return unless request.env["rack.session.options"]
# This works because Rack uses these options every time a request is handled:
# https://github.com/rack/rack/blob/fdcd03a3c5a1c51d1f96fc97f9dfa1a9deac0c77/lib/rack/session/abstract/id.rb#L342
- request.env['rack.session.options'][:expire_after] = Settings.gitlab['unauthenticated_session_expire_delay']
+ request.env["rack.session.options"][:expire_after] = Settings.gitlab["unauthenticated_session_expire_delay"]
end
def render(*args)
super.tap do
# Set a header for custom error pages to prevent them from being intercepted by gitlab-workhorse
- if response.content_type == 'text/html' && (400..599).cover?(response.status)
- response.headers['X-GitLab-Custom-Error'] = '1'
+ if response.content_type == "text/html" && (400..599).cover?(response.status)
+ response.headers["X-GitLab-Custom-Error"] = "1"
end
end
end
@@ -137,7 +137,7 @@ class ApplicationController < ActionController::Base
payload[:username] = logged_user.try(:username)
end
- if response.status == 422 && response.body.present? && response.content_type == 'application/json'.freeze
+ if response.status == 422 && response.body.present? && response.content_type == "application/json"
payload[:response] = response.body
end
@@ -193,9 +193,9 @@ class ApplicationController < ActionController::Base
format.any { head status }
format.html do
render template,
- layout: "errors",
- status: status,
- locals: { message: message }
+ layout: "errors",
+ status: status,
+ locals: {message: message}
end
end
end
@@ -215,7 +215,7 @@ class ApplicationController < ActionController::Base
respond_to do |format|
format.html { render "errors/not_found", layout: "errors", status: 404 }
# Prevent the Rails CSRF protector from thinking a missing .js file is a JavaScript file
- format.js { render json: '', status: :not_found, content_type: 'application/json' }
+ format.js { render json: "", status: :not_found, content_type: "application/json" }
format.any { head :not_found }
end
end
@@ -238,20 +238,20 @@ class ApplicationController < ActionController::Base
end
def no_cache_headers
- headers['Cache-Control'] = DEFAULT_GITLAB_CONTROL_NO_CACHE
- headers['Pragma'] = 'no-cache' # HTTP 1.0 compatibility
- headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
+ headers["Cache-Control"] = DEFAULT_GITLAB_CONTROL_NO_CACHE
+ headers["Pragma"] = "no-cache" # HTTP 1.0 compatibility
+ headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end
def default_headers
- headers['X-Frame-Options'] = 'DENY'
- headers['X-XSS-Protection'] = '1; mode=block'
- headers['X-UA-Compatible'] = 'IE=edge'
- headers['X-Content-Type-Options'] = 'nosniff'
+ headers["X-Frame-Options"] = "DENY"
+ headers["X-XSS-Protection"] = "1; mode=block"
+ headers["X-UA-Compatible"] = "IE=edge"
+ headers["X-Content-Type-Options"] = "nosniff"
if current_user
- headers['Cache-Control'] = default_cache_control
- headers['Pragma'] = 'no-cache' # HTTP 1.0 compatibility
+ headers["Cache-Control"] = default_cache_control
+ headers["Pragma"] = "no-cache" # HTTP 1.0 compatibility
end
end
@@ -266,9 +266,9 @@ class ApplicationController < ActionController::Base
def validate_user_service_ticket!
return unless signed_in? && session[:service_tickets]
- valid = session[:service_tickets].all? do |provider, ticket|
+ valid = session[:service_tickets].all? { |provider, ticket|
Gitlab::Auth::OAuth::Session.valid?(provider, ticket)
- end
+ }
unless valid
session[:service_tickets] = nil
@@ -288,7 +288,7 @@ class ApplicationController < ActionController::Base
end
def ldap_security_check
- if current_user && current_user.requires_ldap_check?
+ if current_user&.requires_ldap_check?
return unless current_user.try_obtain_ldap_lease
unless Gitlab::Auth::LDAP::Access.allowed?(current_user)
@@ -317,7 +317,7 @@ class ApplicationController < ActionController::Base
render json: {
html: html,
- count: count
+ count: count,
}
end
@@ -339,8 +339,8 @@ class ApplicationController < ActionController::Base
end
def require_email
- if current_user && current_user.temp_oauth_email? && session[:impersonator_id].nil?
- return redirect_to profile_path, notice: 'Please complete your profile with email address'
+ if current_user&.temp_oauth_email? && session[:impersonator_id].nil?
+ redirect_to profile_path, notice: "Please complete your profile with email address"
end
end
@@ -357,10 +357,10 @@ class ApplicationController < ActionController::Base
# Redirect to the source if it was a post, so the user can re-submit after
# accepting the terms.
redirect_path = if request.get?
- request.fullpath
- else
- URI(request.referer).path if request.referer
- end
+ request.fullpath
+ else
+ URI(request.referer).path if request.referer
+ end
flash[:notice] = message
redirect_to terms_path(redirect: redirect_path), status: :found
@@ -372,15 +372,15 @@ class ApplicationController < ActionController::Base
end
def bitbucket_server_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('bitbucket_server')
+ Gitlab::CurrentSettings.import_sources.include?("bitbucket_server")
end
def github_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('github')
+ Gitlab::CurrentSettings.import_sources.include?("github")
end
def gitea_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('gitea')
+ Gitlab::CurrentSettings.import_sources.include?("gitea")
end
def github_import_configured?
@@ -388,7 +388,7 @@ class ApplicationController < ActionController::Base
end
def gitlab_import_enabled?
- request.host != 'gitlab.com' && Gitlab::CurrentSettings.import_sources.include?('gitlab')
+ request.host != "gitlab.com" && Gitlab::CurrentSettings.import_sources.include?("gitlab")
end
def gitlab_import_configured?
@@ -396,7 +396,7 @@ class ApplicationController < ActionController::Base
end
def bitbucket_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('bitbucket')
+ Gitlab::CurrentSettings.import_sources.include?("bitbucket")
end
def bitbucket_import_configured?
@@ -404,23 +404,23 @@ class ApplicationController < ActionController::Base
end
def google_code_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('google_code')
+ Gitlab::CurrentSettings.import_sources.include?("google_code")
end
def fogbugz_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('fogbugz')
+ Gitlab::CurrentSettings.import_sources.include?("fogbugz")
end
def git_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('git')
+ Gitlab::CurrentSettings.import_sources.include?("git")
end
def gitlab_project_import_enabled?
- Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
+ Gitlab::CurrentSettings.import_sources.include?("gitlab_project")
end
def manifest_import_enabled?
- Group.supports_nested_objects? && Gitlab::CurrentSettings.import_sources.include?('manifest')
+ Group.supports_nested_objects? && Gitlab::CurrentSettings.import_sources.include?("manifest")
end
# U2F (universal 2nd factor) devices need a unique identifier for the application
@@ -436,11 +436,11 @@ class ApplicationController < ActionController::Base
def set_page_title_header
# Per https://tools.ietf.org/html/rfc5987, headers need to be ISO-8859-1, not UTF-8
- response.headers['Page-Title'] = URI.escape(page_title('GitLab'))
+ response.headers["Page-Title"] = URI.escape(page_title("GitLab"))
end
def peek_request?
- request.path.start_with?('/-/peek')
+ request.path.start_with?("/-/peek")
end
def json_request?
@@ -456,7 +456,7 @@ class ApplicationController < ActionController::Base
def set_usage_stats_consent_flag
return unless current_user
return if sessionless_user?
- return if session.has_key?(:ask_for_usage_stats_consent)
+ return if session.key?(:ask_for_usage_stats_consent)
session[:ask_for_usage_stats_consent] = current_user.requires_usage_stats_consent?
@@ -469,7 +469,7 @@ class ApplicationController < ActionController::Base
application_setting_params = {
usage_ping_enabled: false,
version_check_enabled: false,
- skip_usage_stats_user: true
+ skip_usage_stats_user: true,
}
settings = Gitlab::CurrentSettings.current_application_settings
@@ -483,7 +483,7 @@ class ApplicationController < ActionController::Base
unless Gitlab.config.gitlab.impersonation_enabled
stop_impersonation
- access_denied! _('Impersonation has been disabled')
+ access_denied! _("Impersonation has been disabled")
end
end
diff --git a/app/controllers/boards/application_controller.rb b/app/controllers/boards/application_controller.rb
index eab908ba5ed..67b70d54a3d 100644
--- a/app/controllers/boards/application_controller.rb
+++ b/app/controllers/boards/application_controller.rb
@@ -17,7 +17,7 @@ module Boards
end
def record_not_found(exception)
- render json: { error: exception.message }, status: :not_found
+ render json: {error: exception.message}, status: :not_found
end
end
end
diff --git a/app/controllers/boards/issues_controller.rb b/app/controllers/boards/issues_controller.rb
index 0dd7500623d..5afa5be8957 100644
--- a/app/controllers/boards/issues_controller.rb
+++ b/app/controllers/boards/issues_controller.rb
@@ -20,16 +20,15 @@ module Boards
issues = issues.page(params[:page]).per(params[:per] || 20).without_count
Issue.move_to_end(issues) if Gitlab::Database.read_write?
issues = issues.preload(:milestone,
- :assignees,
- project: [
- :route,
- {
- namespace: [:route]
- }
- ],
- labels: [:priorities],
- notes: [:award_emoji, :author]
- )
+ :assignees,
+ project: [
+ :route,
+ {
+ namespace: [:route],
+ },
+ ],
+ labels: [:priorities],
+ notes: [:award_emoji, :author])
render_issues(issues, list_service.metadata)
end
@@ -59,7 +58,7 @@ module Boards
private
def render_issues(issues, metadata)
- data = { issues: serialize_as_json(issues) }
+ data = {issues: serialize_as_json(issues)}
data.merge!(metadata)
render json: data
@@ -84,10 +83,10 @@ module Boards
def project
@project ||= if board.group_board?
- Project.find(issue_params[:project_id])
- else
- board_parent
- end
+ Project.find(issue_params[:project_id])
+ else
+ board_parent
+ end
end
def move_params
@@ -105,12 +104,12 @@ module Boards
end
def serialize_as_json(resource)
- serializer.represent(resource, serializer: 'board', include_full_project_path: board.group_board?)
+ serializer.represent(resource, serializer: "board", include_full_project_path: board.group_board?)
end
def whitelist_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-ce/issues/42439
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42428')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42428")
end
end
end
diff --git a/app/controllers/boards/lists_controller.rb b/app/controllers/boards/lists_controller.rb
index ccd02144671..fc9b35e1380 100644
--- a/app/controllers/boards/lists_controller.rb
+++ b/app/controllers/boards/lists_controller.rb
@@ -78,7 +78,7 @@ module Boards
{
only: [:id, :list_type, :position],
methods: [:title],
- label: true
+ label: true,
}
end
end
diff --git a/app/controllers/chaos_controller.rb b/app/controllers/chaos_controller.rb
index 8d518c14b90..2be1fed43ec 100644
--- a/app/controllers/chaos_controller.rb
+++ b/app/controllers/chaos_controller.rb
@@ -41,7 +41,7 @@ class ChaosController < ActionController::Base
private
def validate_request
- secret = ENV['GITLAB_CHAOS_SECRET']
+ secret = ENV["GITLAB_CHAOS_SECRET"]
# GITLAB_CHAOS_SECRET is required unless you're running in Development mode
if !secret && !Rails.env.development?
render plain: "chaos misconfigured: please configure GITLAB_CHAOS_SECRET when using GITLAB_ENABLE_CHAOS_ENDPOINTS outside of a development environment", status: :internal_server_error
diff --git a/app/controllers/clusters/applications_controller.rb b/app/controllers/clusters/applications_controller.rb
index c4e7fc950f9..54d9a36bbd2 100644
--- a/app/controllers/clusters/applications_controller.rb
+++ b/app/controllers/clusters/applications_controller.rb
@@ -12,7 +12,7 @@ class Clusters::ApplicationsController < Clusters::BaseController
head :no_content
rescue Clusters::Applications::CreateService::InvalidApplicationError
render_404
- rescue StandardError
+ rescue
head :bad_request
end
diff --git a/app/controllers/clusters/base_controller.rb b/app/controllers/clusters/base_controller.rb
index ef42f7c4074..5a86ca39daa 100644
--- a/app/controllers/clusters/base_controller.rb
+++ b/app/controllers/clusters/base_controller.rb
@@ -12,7 +12,7 @@ class Clusters::BaseController < ApplicationController
def cluster
@cluster ||= clusterable.clusters.find(params[:id])
- .present(current_user: current_user)
+ .present(current_user: current_user)
end
def authorize_update_cluster!
diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb
index 68a2a83f0de..9e38c74cad3 100644
--- a/app/controllers/clusters/clusters_controller.rb
+++ b/app/controllers/clusters/clusters_controller.rb
@@ -64,7 +64,7 @@ class Clusters::ClustersController < Clusters::BaseController
head :no_content
end
format.html do
- flash[:notice] = _('Kubernetes cluster was successfully updated.')
+ flash[:notice] = _("Kubernetes cluster was successfully updated.")
redirect_to cluster.show_path
end
end
@@ -78,10 +78,10 @@ class Clusters::ClustersController < Clusters::BaseController
def destroy
if cluster.destroy
- flash[:notice] = _('Kubernetes cluster integration was successfully removed.')
+ flash[:notice] = _("Kubernetes cluster integration was successfully removed.")
redirect_to clusterable.index_path, status: :found
else
- flash[:notice] = _('Kubernetes cluster integration was not removed.')
+ flash[:notice] = _("Kubernetes cluster integration was not removed.")
render :show
end
end
@@ -99,7 +99,7 @@ class Clusters::ClustersController < Clusters::BaseController
validate_gcp_token
user_cluster
- render :new, locals: { active_tab: 'gcp' }
+ render :new, locals: {active_tab: "gcp"}
end
end
@@ -116,7 +116,7 @@ class Clusters::ClustersController < Clusters::BaseController
validate_gcp_token
gcp_cluster
- render :new, locals: { active_tab: 'user' }
+ render :new, locals: {active_tab: "user"}
end
end
@@ -129,7 +129,7 @@ class Clusters::ClustersController < Clusters::BaseController
:environment_scope,
:base_domain,
platform_kubernetes_attributes: [
- :namespace
+ :namespace,
]
)
else
@@ -142,7 +142,7 @@ class Clusters::ClustersController < Clusters::BaseController
:api_url,
:token,
:ca_cert,
- :namespace
+ :namespace,
]
)
end
@@ -158,12 +158,13 @@ class Clusters::ClustersController < Clusters::BaseController
:zone,
:num_nodes,
:machine_type,
- :legacy_abac
- ]).merge(
- provider_type: :gcp,
- platform_type: :kubernetes,
- clusterable: clusterable.subject
- )
+ :legacy_abac,
+ ]
+ ).merge(
+ provider_type: :gcp,
+ platform_type: :kubernetes,
+ clusterable: clusterable.subject
+ )
end
def create_user_cluster_params
@@ -176,12 +177,13 @@ class Clusters::ClustersController < Clusters::BaseController
:api_url,
:token,
:ca_cert,
- :authorization_type
- ]).merge(
- provider_type: :user,
- platform_type: :kubernetes,
- clusterable: clusterable.subject
- )
+ :authorization_type,
+ ]
+ ).merge(
+ provider_type: :user,
+ platform_type: :kubernetes,
+ clusterable: clusterable.subject
+ )
end
def generate_gcp_authorize_url
@@ -189,7 +191,8 @@ class Clusters::ClustersController < Clusters::BaseController
@authorize_url = GoogleApi::CloudPlatform::Client.new(
nil, callback_google_api_auth_url,
- state: state).authorize_url
+ state: state
+ ).authorize_url
rescue GoogleApi::Auth::ConfigMissingError
# no-op
end
diff --git a/app/controllers/concerns/authenticates_with_two_factor.rb b/app/controllers/concerns/authenticates_with_two_factor.rb
index 5507328f8ae..147267258ee 100644
--- a/app/controllers/concerns/authenticates_with_two_factor.rb
+++ b/app/controllers/concerns/authenticates_with_two_factor.rb
@@ -32,12 +32,12 @@ module AuthenticatesWithTwoFactor
session[:otp_user_id] = user.id
setup_u2f_authentication(user)
- render 'devise/sessions/two_factor'
+ render "devise/sessions/two_factor"
end
def locked_user_redirect(user)
- flash.now[:alert] = 'Invalid Login or password'
- render 'devise/sessions/new'
+ flash.now[:alert] = "Invalid Login or password"
+ render "devise/sessions/new"
end
def authenticate_with_two_factor
@@ -48,7 +48,7 @@ module AuthenticatesWithTwoFactor
authenticate_with_two_factor_via_otp(user)
elsif user_params[:device_response].present? && session[:otp_user_id]
authenticate_with_two_factor_via_u2f(user)
- elsif user && user.valid_password?(user_params[:password])
+ elsif user&.valid_password?(user_params[:password])
prompt_for_two_factor(user)
end
end
@@ -60,13 +60,13 @@ module AuthenticatesWithTwoFactor
# Remove any lingering user data from login
session.delete(:otp_user_id)
- remember_me(user) if user_params[:remember_me] == '1'
+ remember_me(user) if user_params[:remember_me] == "1"
user.save!
sign_in(user, message: :two_factor_authenticated)
else
user.increment_failed_attempts!
Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=OTP")
- flash.now[:alert] = 'Invalid two-factor code.'
+ flash.now[:alert] = "Invalid two-factor code."
prompt_for_two_factor(user)
end
end
@@ -78,12 +78,12 @@ module AuthenticatesWithTwoFactor
session.delete(:otp_user_id)
session.delete(:challenge)
- remember_me(user) if user_params[:remember_me] == '1'
+ remember_me(user) if user_params[:remember_me] == "1"
sign_in(user, message: :two_factor_authenticated)
else
user.increment_failed_attempts!
Gitlab::AppLogger.info("Failed Login: user=#{user.username} ip=#{request.remote_ip} method=U2F")
- flash.now[:alert] = 'Authentication via U2F device failed.'
+ flash.now[:alert] = "Authentication via U2F device failed."
prompt_for_two_factor(user)
end
end
@@ -98,8 +98,8 @@ module AuthenticatesWithTwoFactor
if key_handles.present?
sign_requests = u2f.authentication_requests(key_handles)
session[:challenge] ||= u2f.challenge
- gon.push(u2f: { challenge: session[:challenge], app_id: u2f_app_id,
- sign_requests: sign_requests })
+ gon.push(u2f: {challenge: session[:challenge], app_id: u2f_app_id,
+ sign_requests: sign_requests,})
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/controllers/concerns/creates_commit.rb b/app/controllers/concerns/creates_commit.rb
index b3777fd2b0f..7cdbe068f4d 100644
--- a/app/controllers/concerns/creates_commit.rb
+++ b/app/controllers/concerns/creates_commit.rb
@@ -11,7 +11,7 @@ module CreatesCommit
@branch_name ||= @ref
else
@project_to_commit_into = current_user.fork_of(@project)
- @branch_name ||= @project_to_commit_into.repository.next_branch('patch')
+ @branch_name ||= @project_to_commit_into.repository.next_branch("patch")
end
@start_branch ||= @ref || @branch_name
@@ -31,7 +31,7 @@ module CreatesCommit
respond_to do |format|
format.html { redirect_to success_path }
- format.json { render json: { message: "success", filePath: success_path } }
+ format.json { render json: {message: "success", filePath: success_path} }
end
else
flash[:alert] = result[:message]
@@ -45,7 +45,7 @@ module CreatesCommit
redirect_to failure_path
end
end
- format.json { render json: { message: "failed", filePath: failure_path } }
+ format.json { render json: {message: "failed", filePath: failure_path} }
end
end
end
@@ -90,7 +90,7 @@ module CreatesCommit
source_project_id: @project_to_commit_into.id,
target_project_id: @project.id,
source_branch: @branch_name,
- target_branch: @start_branch
+ target_branch: @start_branch,
}
)
end
@@ -110,7 +110,8 @@ module CreatesCommit
.find_by(
source_project_id: @project_to_commit_into,
source_branch: @branch_name,
- target_branch: @start_branch)
+ target_branch: @start_branch
+ )
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/controllers/concerns/cycle_analytics_params.rb b/app/controllers/concerns/cycle_analytics_params.rb
index c1ef848e1e7..6a74d660d24 100644
--- a/app/controllers/concerns/cycle_analytics_params.rb
+++ b/app/controllers/concerns/cycle_analytics_params.rb
@@ -4,14 +4,14 @@ module CycleAnalyticsParams
extend ActiveSupport::Concern
def options(params)
- @options ||= { from: start_date(params), current_user: current_user }
+ @options ||= {from: start_date(params), current_user: current_user}
end
def start_date(params)
case params[:start_date]
- when '7'
+ when "7"
7.days.ago
- when '30'
+ when "30"
30.days.ago
else
90.days.ago
diff --git a/app/controllers/concerns/diff_for_path.rb b/app/controllers/concerns/diff_for_path.rb
index 6be7a2a18a2..b83d1a948cd 100644
--- a/app/controllers/concerns/diff_for_path.rb
+++ b/app/controllers/concerns/diff_for_path.rb
@@ -4,12 +4,12 @@ module DiffForPath
extend ActiveSupport::Concern
def render_diff_for_path(diffs)
- diff_file = diffs.diff_files.find do |diff|
+ diff_file = diffs.diff_files.find { |diff|
diff.file_identifier == params[:file_identifier]
- end
+ }
return render_404 unless diff_file
- render json: { html: view_to_html_string('projects/diffs/_content', diff_file: diff_file) }
+ render json: {html: view_to_html_string("projects/diffs/_content", diff_file: diff_file)}
end
end
diff --git a/app/controllers/concerns/group_tree.rb b/app/controllers/concerns/group_tree.rb
index e9a7d6a3152..f6868e67c4f 100644
--- a/app/controllers/concerns/group_tree.rb
+++ b/app/controllers/concerns/group_tree.rb
@@ -7,11 +7,11 @@ module GroupTree
groups = groups.sort_by_attribute(@sort = params[:sort])
groups = if params[:filter].present?
- filtered_groups_with_ancestors(groups)
- else
- # If `params[:parent_id]` is `nil`, we will only show root-groups
- groups.where(parent_id: params[:parent_id]).page(params[:page])
- end
+ filtered_groups_with_ancestors(groups)
+ else
+ # If `params[:parent_id]` is `nil`, we will only show root-groups
+ groups.where(parent_id: params[:parent_id]).page(params[:page])
+ end
@groups = groups.with_selects_for_list(archived: params[:archived])
@@ -19,7 +19,7 @@ module GroupTree
format.html
format.json do
serializer = GroupChildSerializer.new(current_user: current_user)
- .with_pagination(request, response)
+ .with_pagination(request, response)
serializer.expand_hierarchy if params[:filter].present?
render json: serializer.represent(@groups)
end
diff --git a/app/controllers/concerns/internal_redirect.rb b/app/controllers/concerns/internal_redirect.rb
index 6785e6972d0..335fb3c1a14 100644
--- a/app/controllers/concerns/internal_redirect.rb
+++ b/app/controllers/concerns/internal_redirect.rb
@@ -35,7 +35,7 @@ module InternalRedirect
end
def full_path_for_uri(uri)
- path_with_query = [uri.path, uri.query].compact.join('?')
+ path_with_query = [uri.path, uri.query].compact.join("?")
[path_with_query, uri.fragment].compact.join("#")
end
diff --git a/app/controllers/concerns/issuable_actions.rb b/app/controllers/concerns/issuable_actions.rb
index cd3fa641e89..c261601c95b 100644
--- a/app/controllers/concerns/issuable_actions.rb
+++ b/app/controllers/concerns/issuable_actions.rb
@@ -21,14 +21,14 @@ module IssuableActions
:subscription_event,
label_ids: [],
add_label_ids: [],
- remove_label_ids: []
+ remove_label_ids: [],
]
end
def show
respond_to do |format|
format.html do
- @issuable_sidebar = serializer.represent(issuable, serializer: 'sidebar') # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ @issuable_sidebar = serializer.represent(issuable, serializer: "sidebar") # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
format.json do
@@ -48,7 +48,6 @@ module IssuableActions
recaptcha_check_if_spammable(false) { render_entity_json }
end
end
-
rescue ActiveRecord::StaleObjectError
render_conflict_response
end
@@ -62,7 +61,7 @@ module IssuableActions
description: view_context.markdown_field(issuable, :description),
description_text: issuable.description,
task_status: issuable.task_status,
- lock_version: issuable.lock_version
+ lock_version: issuable.lock_version,
}
if issuable.edited?
@@ -85,7 +84,7 @@ module IssuableActions
format.html { redirect_to index_path }
format.json do
render json: {
- web_url: index_path
+ web_url: index_path,
}
end
end
@@ -95,7 +94,7 @@ module IssuableActions
result = Issuable::BulkUpdateService.new(project, current_user, bulk_update_params).execute(resource_name)
quantity = result[:count]
- render json: { notice: "#{quantity} #{resource_name.pluralize(quantity)} updated" }
+ render json: {notice: "#{quantity} #{resource_name.pluralize(quantity)} updated"}
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -167,8 +166,8 @@ module IssuableActions
format.json do
render json: {
errors: [
- "Someone edited this #{issuable.human_class_name} at the same time you did. Please refresh your browser and make sure your changes will not unintentionally remove theirs."
- ]
+ "Someone edited this #{issuable.human_class_name} at the same time you did. Please refresh your browser and make sure your changes will not unintentionally remove theirs.",
+ ],
}, status: :conflict
end
end
@@ -176,13 +175,13 @@ module IssuableActions
def authorize_destroy_issuable!
unless can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable)
- return access_denied!
+ access_denied!
end
end
def authorize_admin_issuable!
unless can?(current_user, :"admin_#{resource_name}", @project) # rubocop:disable Gitlab/ModuleWithInstanceVariables
- return access_denied!
+ access_denied!
end
end
@@ -193,8 +192,8 @@ module IssuableActions
def bulk_update_params
permitted_keys_array = permitted_keys.dup
- if resource_name == 'issue'
- permitted_keys_array << { assignee_ids: [] }
+ if resource_name == "issue"
+ permitted_keys_array << {assignee_ids: []}
else
permitted_keys_array.unshift(:assignee_id)
end
@@ -211,7 +210,7 @@ module IssuableActions
if @issuable.valid?
render json: serializer.represent(@issuable)
else
- render json: { errors: @issuable.errors.full_messages }, status: :unprocessable_entity
+ render json: {errors: @issuable.errors.full_messages}, status: :unprocessable_entity
end
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
diff --git a/app/controllers/concerns/issuable_collections.rb b/app/controllers/concerns/issuable_collections.rb
index c529aabf797..a83006ee952 100644
--- a/app/controllers/concerns/issuable_collections.rb
+++ b/app/controllers/concerns/issuable_collections.rb
@@ -21,7 +21,7 @@ module IssuableCollections
return if redirect_out_of_range(@total_pages)
if params[:label_name].present? && @project
- labels_params = { project_id: @project.id, title: params[:label_name] }
+ labels_params = {project_id: @project.id, title: params[:label_name]}
@labels = LabelsFinder.new(current_user, labels_params).execute
end
@@ -92,7 +92,7 @@ module IssuableCollections
scope: params[:scope],
state: params[:state],
confidential: Gitlab::Utils.to_boolean(params[:confidential]),
- sort: set_sort_order
+ sort: set_sort_order,
}
# Used by view to highlight active option
@@ -111,7 +111,7 @@ module IssuableCollections
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def default_state
- 'opened'
+ "opened"
end
def set_sort_order
@@ -145,7 +145,7 @@ module IssuableCollections
def set_sort_order_from_cookie
sort_param = params[:sort] if params[:sort].present?
# fallback to legacy cookie value for backward compatibility
- sort_param ||= cookies['issuable_sort']
+ sort_param ||= cookies["issuable_sort"]
sort_param ||= cookies[remember_sorting_key]
sort_value = update_cookie_value(sort_param)
@@ -159,8 +159,8 @@ module IssuableCollections
def default_sort_order
case params[:state]
- when 'opened', 'all' then sort_value_created_date
- when 'merged', 'closed' then sort_value_recently_updated
+ when "opened", "all" then sort_value_created_date
+ when "merged", "closed" then sort_value_recently_updated
else sort_value_created_date
end
end
@@ -168,10 +168,10 @@ module IssuableCollections
# Update old values to the actual ones.
def update_cookie_value(value)
case value
- when 'id_asc' then sort_value_oldest_created
- when 'id_desc' then sort_value_recently_created
- when 'downvotes_asc' then sort_value_popularity
- when 'downvotes_desc' then sort_value_popularity
+ when "id_asc" then sort_value_oldest_created
+ when "id_desc" then sort_value_recently_created
+ when "downvotes_asc" then sort_value_popularity
+ when "downvotes_desc" then sort_value_popularity
else value
end
end
@@ -182,22 +182,22 @@ module IssuableCollections
def collection_type
@collection_type ||= case finder_type.name
- when 'IssuesFinder'
- 'Issue'
- when 'MergeRequestsFinder'
- 'MergeRequest'
- end
+ when "IssuesFinder"
+ "Issue"
+ when "MergeRequestsFinder"
+ "MergeRequest"
+ end
end
def preload_for_collection
@preload_for_collection ||= case collection_type
- when 'Issue'
+ when "Issue"
[:project, :author, :assignees, :labels, :milestone, project: :namespace]
- when 'MergeRequest'
+ when "MergeRequest"
[
:target_project, :author, :assignee, :labels, :milestone,
- source_project: :route, head_pipeline: :project, target_project: :namespace, latest_merge_request_diff: :merge_request_diff_commits
+ source_project: :route, head_pipeline: :project, target_project: :namespace, latest_merge_request_diff: :merge_request_diff_commits,
]
- end
+ end
end
end
diff --git a/app/controllers/concerns/issuable_collections_action.rb b/app/controllers/concerns/issuable_collections_action.rb
index 18ed4027eac..f3fb1b4cd0d 100644
--- a/app/controllers/concerns/issuable_collections_action.rb
+++ b/app/controllers/concerns/issuable_collections_action.rb
@@ -8,14 +8,14 @@ module IssuableCollectionsAction
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def issues
@issues = issuables_collection
- .non_archived
- .page(params[:page])
+ .non_archived
+ .page(params[:page])
@issuable_meta_data = issuable_meta_data(@issues, collection_type)
respond_to do |format|
format.html
- format.atom { render layout: 'xml.atom' }
+ format.atom { render layout: "xml.atom" }
end
end
@@ -34,23 +34,19 @@ module IssuableCollectionsAction
def issuable_sorting_field
case action_name
- when 'issues'
+ when "issues"
Issue::SORTING_PREFERENCE_FIELD
- when 'merge_requests'
+ when "merge_requests"
MergeRequest::SORTING_PREFERENCE_FIELD
- else
- nil
end
end
def finder_type
case action_name
- when 'issues', 'issues_calendar'
+ when "issues", "issues_calendar"
IssuesFinder
- when 'merge_requests'
+ when "merge_requests"
MergeRequestsFinder
- else
- nil
end
end
diff --git a/app/controllers/concerns/issues_calendar.rb b/app/controllers/concerns/issues_calendar.rb
index 1fdfde4c869..138de7918c1 100644
--- a/app/controllers/concerns/issues_calendar.rb
+++ b/app/controllers/concerns/issues_calendar.rb
@@ -7,9 +7,9 @@ module IssuesCalendar
# rubocop: disable CodeReuse/ActiveRecord
def render_issues_calendar(issuables)
@issues = issuables
- .non_archived
- .with_due_date
- .limit(100)
+ .non_archived
+ .with_due_date
+ .limit(100)
respond_to do |format|
format.ics do
@@ -18,7 +18,7 @@ module IssuesCalendar
# header). We want to display the content inline when accessed
# from GitLab, similarly to the RSS feed.
if request.referer&.start_with?(::Settings.gitlab.base_url)
- response.headers['Content-Type'] = 'text/plain'
+ response.headers["Content-Type"] = "text/plain"
end
end
end
diff --git a/app/controllers/concerns/labels_as_hash.rb b/app/controllers/concerns/labels_as_hash.rb
index 1171aa9cf44..56bec5ce32e 100644
--- a/app/controllers/concerns/labels_as_hash.rb
+++ b/app/controllers/concerns/labels_as_hash.rb
@@ -16,7 +16,7 @@ module LabelsAsHash
if already_set_labels.present?
titles = already_set_labels.map(&:title)
label_hashes.each do |hash|
- if titles.include?(hash['title'])
+ if titles.include?(hash["title"])
hash[:set] = true
end
end
diff --git a/app/controllers/concerns/lfs_request.rb b/app/controllers/concerns/lfs_request.rb
index 57e444319e0..06f7700f079 100644
--- a/app/controllers/concerns/lfs_request.rb
+++ b/app/controllers/concerns/lfs_request.rb
@@ -12,7 +12,7 @@
module LfsRequest
extend ActiveSupport::Concern
- CONTENT_TYPE = 'application/vnd.git-lfs+json'.freeze
+ CONTENT_TYPE = "application/vnd.git-lfs+json"
included do
before_action :require_lfs_enabled!
@@ -26,8 +26,8 @@ module LfsRequest
render(
json: {
- message: 'Git LFS is not enabled on this GitLab server, contact your admin.',
- documentation_url: help_url
+ message: "Git LFS is not enabled on this GitLab server, contact your admin.",
+ documentation_url: help_url,
},
status: :not_implemented
)
@@ -51,8 +51,8 @@ module LfsRequest
def render_lfs_forbidden
render(
json: {
- message: 'Access forbidden. Check your access level.',
- documentation_url: help_url
+ message: "Access forbidden. Check your access level.",
+ documentation_url: help_url,
},
content_type: CONTENT_TYPE,
status: 403
@@ -62,8 +62,8 @@ module LfsRequest
def render_lfs_not_found
render(
json: {
- message: 'Not found.',
- documentation_url: help_url
+ message: "Not found.",
+ documentation_url: help_url,
},
content_type: CONTENT_TYPE,
status: 404
@@ -84,7 +84,7 @@ module LfsRequest
end
def deploy_token_present?
- user && user.is_a?(DeployToken)
+ user&.is_a?(DeployToken)
end
def deploy_token
diff --git a/app/controllers/concerns/membership_actions.rb b/app/controllers/concerns/membership_actions.rb
index 6402e01ddc0..143b9dc5494 100644
--- a/app/controllers/concerns/membership_actions.rb
+++ b/app/controllers/concerns/membership_actions.rb
@@ -9,7 +9,7 @@ module MembershipActions
result = Members::CreateService.new(current_user, create_params).execute(membershipable)
if result[:status] == :success
- redirect_to members_page_url, notice: 'Users were successfully added.'
+ redirect_to members_page_url, notice: "Users were successfully added."
else
redirect_to members_page_url, alert: result[:message]
end
@@ -25,7 +25,7 @@ module MembershipActions
present_members([member])
respond_to do |format|
- format.js { render 'shared/members/update', locals: { member: member } }
+ format.js { render "shared/members/update", locals: {member: member} }
end
end
@@ -35,7 +35,7 @@ module MembershipActions
respond_to do |format|
format.html do
- source = source_type == 'group' ? 'group and any subresources' : source_type
+ source = source_type == "group" ? "group and any subresources" : source_type
message = "User was successfully removed from #{source}."
redirect_to members_page_url, notice: message
@@ -49,7 +49,7 @@ module MembershipActions
membershipable.request_access(current_user)
redirect_to polymorphic_path(membershipable),
- notice: 'Your request for access has been queued for review.'
+ notice: "Your request for access has been queued for review."
end
def approve_access_request
@@ -79,7 +79,7 @@ module MembershipActions
redirect_to redirect_path, notice: notice
end
- format.json { render json: { notice: notice } }
+ format.json { render json: {notice: notice} }
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -90,9 +90,9 @@ module MembershipActions
if member.invite?
member.resend_invite
- redirect_to members_page_url, notice: 'The invitation was successfully resent.'
+ redirect_to members_page_url, notice: "The invitation was successfully resent."
else
- redirect_to members_page_url, alert: 'The invitation has already been accepted.'
+ redirect_to members_page_url, alert: "The invitation has already been accepted."
end
end
diff --git a/app/controllers/concerns/milestone_actions.rb b/app/controllers/concerns/milestone_actions.rb
index eccbe35577b..45ad9a12aca 100644
--- a/app/controllers/concerns/milestone_actions.rb
+++ b/app/controllers/concerns/milestone_actions.rb
@@ -9,7 +9,7 @@ module MilestoneActions
format.json do
render json: tabs_json("shared/milestones/_merge_requests_tab", {
merge_requests: @milestone.sorted_merge_requests, # rubocop:disable Gitlab/ModuleWithInstanceVariables
- show_project_name: true
+ show_project_name: true,
})
end
end
@@ -20,7 +20,7 @@ module MilestoneActions
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_participants_tab", {
- users: @milestone.participants # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ users: @milestone.participants, # rubocop:disable Gitlab/ModuleWithInstanceVariables
})
end
end
@@ -31,7 +31,7 @@ module MilestoneActions
format.html { redirect_to milestone_redirect_path }
format.json do
render json: tabs_json("shared/milestones/_labels_tab", {
- labels: @milestone.labels # rubocop:disable Gitlab/ModuleWithInstanceVariables
+ labels: @milestone.labels, # rubocop:disable Gitlab/ModuleWithInstanceVariables
})
end
end
@@ -41,7 +41,7 @@ module MilestoneActions
def tabs_json(partial, data = {})
{
- html: view_to_html_string(partial, data)
+ html: view_to_html_string(partial, data),
}
end
diff --git a/app/controllers/concerns/notes_actions.rb b/app/controllers/concerns/notes_actions.rb
index b4fee93713b..337c8c809e7 100644
--- a/app/controllers/concerns/notes_actions.rb
+++ b/app/controllers/concerns/notes_actions.rb
@@ -15,11 +15,11 @@ module NotesActions
def index
current_fetched_at = Time.now.to_i
- notes_json = { notes: [], last_fetched_at: current_fetched_at }
+ notes_json = {notes: [], last_fetched_at: current_fetched_at}
notes = notes_finder
- .execute
- .inc_relations_for_view
+ .execute
+ .inc_relations_for_view
if notes_filter != UserPreference::NOTES_FILTERS[:only_comments]
notes =
@@ -48,7 +48,7 @@ module NotesActions
respond_to do |format|
format.json do
json = {
- commands_changes: @note.commands_changes
+ commands_changes: @note.commands_changes,
}
if @note.persisted? && return_discussion?
@@ -99,7 +99,7 @@ module NotesActions
"shared/notes/_note",
layout: false,
formats: [:html],
- locals: { note: note }
+ locals: {note: note}
)
end
@@ -138,10 +138,8 @@ module NotesActions
end
end
else
- attrs.merge!(
- valid: false,
- errors: note.errors
- )
+ attrs[:valid] = false
+ attrs[:errors] = note.errors
end
attrs
@@ -152,19 +150,19 @@ module NotesActions
on_image = discussion.on_image?
- if params[:view] == 'parallel' && !on_image
+ if params[:view] == "parallel" && !on_image
template = "discussions/_parallel_diff_discussion"
locals =
- if params[:line_type] == 'old'
- { discussions_left: [discussion], discussions_right: nil }
+ if params[:line_type] == "old"
+ {discussions_left: [discussion], discussions_right: nil}
else
- { discussions_left: nil, discussions_right: [discussion] }
+ {discussions_left: nil, discussions_right: [discussion]}
end
else
template = "discussions/_diff_discussion"
@fresh_discussion = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
- locals = { discussions: [discussion], on_image: on_image }
+ locals = {discussions: [discussion], on_image: on_image}
end
render_to_string(
@@ -182,7 +180,7 @@ module NotesActions
"discussions/_discussion",
layout: false,
formats: [:html],
- locals: { discussion: discussion }
+ locals: {discussion: discussion}
)
end
@@ -206,9 +204,9 @@ module NotesActions
create_params[:noteable_type] = params[:target_type].classify
case params[:target_type]
- when 'commit'
+ when "commit"
create_params[:commit_id] = params[:target_id]
- when 'merge_request'
+ when "merge_request"
create_params[:noteable_id] = params[:target_id]
# Notes on MergeRequest can have an extra `commit_id` context
create_params[:commit_id] = params.dig(:note, :commit_id)
@@ -235,7 +233,7 @@ module NotesActions
end
def last_fetched_at
- request.headers['X-Last-Fetched-At']
+ request.headers["X-Last-Fetched-At"]
end
def notes_filter
@@ -278,7 +276,7 @@ module NotesActions
end
def use_note_serializer?
- return false if params['html']
+ return false if params["html"]
noteable.discussions_rendered_on_frontend?
end
diff --git a/app/controllers/concerns/oauth_applications.rb b/app/controllers/concerns/oauth_applications.rb
index d97e22df472..055b3e938bd 100644
--- a/app/controllers/concerns/oauth_applications.rb
+++ b/app/controllers/concerns/oauth_applications.rb
@@ -11,7 +11,7 @@ module OauthApplications
scopes = params.fetch(:doorkeeper_application, {}).fetch(:scopes, nil)
if scopes
- params[:doorkeeper_application][:scopes] = scopes.join(' ')
+ params[:doorkeeper_application][:scopes] = scopes.join(" ")
end
end
diff --git a/app/controllers/concerns/preview_markdown.rb b/app/controllers/concerns/preview_markdown.rb
index f72d25fc54c..a603c5cf0f1 100644
--- a/app/controllers/concerns/preview_markdown.rb
+++ b/app/controllers/concerns/preview_markdown.rb
@@ -9,10 +9,10 @@ module PreviewMarkdown
markdown_params =
case controller_name
- when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] }
- when 'snippets' then { skip_project_check: true }
- when 'groups' then { group: group }
- when 'projects' then projects_filter_params
+ when "wikis" then {pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id]}
+ when "snippets" then {skip_project_check: true}
+ when "groups" then {group: group}
+ when "projects" then projects_filter_params
else {}
end
@@ -21,15 +21,15 @@ module PreviewMarkdown
references: {
users: result[:users],
suggestions: result[:suggestions],
- commands: view_context.markdown(result[:commands])
- }
+ commands: view_context.markdown(result[:commands]),
+ },
}
end
def projects_filter_params
{
issuable_state_filter_enabled: true,
- suggestions_filter_enabled: params[:preview_suggestions].present?
+ suggestions_filter_enabled: params[:preview_suggestions].present?,
}
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables
diff --git a/app/controllers/concerns/renders_blob.rb b/app/controllers/concerns/renders_blob.rb
index b8026c7a01d..2f1c87f0a38 100644
--- a/app/controllers/concerns/renders_blob.rb
+++ b/app/controllers/concerns/renders_blob.rb
@@ -6,9 +6,9 @@ module RendersBlob
def blob_json(blob)
viewer =
case params[:viewer]
- when 'rich'
+ when "rich"
blob.rich_viewer
- when 'auxiliary'
+ when "auxiliary"
blob.auxiliary_viewer
else
blob.simple_viewer
@@ -17,7 +17,7 @@ module RendersBlob
return unless viewer
{
- html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false)
+ html: view_to_html_string("projects/blob/_viewer", viewer: viewer, load_async: false),
}
end
@@ -29,6 +29,6 @@ module RendersBlob
end
def conditionally_expand_blob(blob)
- blob.expand! if params[:expanded] == 'true'
+ blob.expand! if params[:expanded] == "true"
end
end
diff --git a/app/controllers/concerns/renders_commits.rb b/app/controllers/concerns/renders_commits.rb
index ed9b898a2a3..cf95c4b18cd 100644
--- a/app/controllers/concerns/renders_commits.rb
+++ b/app/controllers/concerns/renders_commits.rb
@@ -5,7 +5,7 @@ module RendersCommits
if commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
[
commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE),
- commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE
+ commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE,
]
else
[commits, 0]
diff --git a/app/controllers/concerns/renders_notes.rb b/app/controllers/concerns/renders_notes.rb
index ce36da6b715..1dc66324eba 100644
--- a/app/controllers/concerns/renders_notes.rb
+++ b/app/controllers/concerns/renders_notes.rb
@@ -36,7 +36,7 @@ module RendersNotes
# rubocop: disable CodeReuse/ActiveRecord
def preload_author_status(notes)
- ActiveRecord::Associations::Preloader.new.preload(notes, { author: :status })
+ ActiveRecord::Associations::Preloader.new.preload(notes, {author: :status})
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/controllers/concerns/requires_whitelisted_monitoring_client.rb b/app/controllers/concerns/requires_whitelisted_monitoring_client.rb
index 426f224d26b..35256673aad 100644
--- a/app/controllers/concerns/requires_whitelisted_monitoring_client.rb
+++ b/app/controllers/concerns/requires_whitelisted_monitoring_client.rb
@@ -22,7 +22,7 @@ module RequiresWhitelistedMonitoringClient
end
def valid_token?
- token = params[:token].presence || request.headers['TOKEN']
+ token = params[:token].presence || request.headers["TOKEN"]
token.present? &&
ActiveSupport::SecurityUtils.variable_size_secure_compare(
token,
@@ -31,6 +31,6 @@ module RequiresWhitelistedMonitoringClient
end
def render_404
- render file: Rails.root.join('public', '404'), layout: false, status: '404'
+ render file: Rails.root.join("public", "404"), layout: false, status: "404"
end
end
diff --git a/app/controllers/concerns/routable_actions.rb b/app/controllers/concerns/routable_actions.rb
index 5624eb3aa45..237967d01e3 100644
--- a/app/controllers/concerns/routable_actions.rb
+++ b/app/controllers/concerns/routable_actions.rb
@@ -9,9 +9,7 @@ module RoutableActions
ensure_canonical_path(routable, requested_full_path)
routable
else
- if not_found_or_authorized_proc
- not_found_or_authorized_proc.call(routable)
- end
+ not_found_or_authorized_proc&.call(routable)
route_not_found unless performed?
diff --git a/app/controllers/concerns/send_file_upload.rb b/app/controllers/concerns/send_file_upload.rb
index 28e4cece548..36372cd6ac1 100644
--- a/app/controllers/concerns/send_file_upload.rb
+++ b/app/controllers/concerns/send_file_upload.rb
@@ -1,21 +1,22 @@
# frozen_string_literal: true
module SendFileUpload
- def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: 'attachment')
+ def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: "attachment")
if attachment
response_disposition = ::Gitlab::ContentDisposition.format(disposition: disposition, filename: attachment)
# Response-Content-Type will not override an existing Content-Type in
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
# this to work. However, this override works with AWS.
- redirect_params[:query] = { "response-content-disposition" => response_disposition,
- "response-content-type" => guess_content_type(attachment) }
+ redirect_params[:query] = {"response-content-disposition" => response_disposition,
+ "response-content-type" => guess_content_type(attachment),}
# By default, Rails will send uploads with an extension of .js with a
# content-type of text/javascript, which will trigger Rails'
# cross-origin JavaScript protection.
- send_params[:content_type] = 'text/plain' if File.extname(attachment) == '.js'
+ send_params[:content_type] = "text/plain" if File.extname(attachment) == ".js"
- send_params.merge!(filename: attachment, disposition: utf8_encoded_disposition(disposition, attachment))
+ send_params[:filename] = attachment
+ send_params[:disposition] = utf8_encoded_disposition(disposition, attachment)
end
if file_upload.file_storage?
diff --git a/app/controllers/concerns/sends_blob.rb b/app/controllers/concerns/sends_blob.rb
index 8ecdaced9f5..50d88504b7c 100644
--- a/app/controllers/concerns/sends_blob.rb
+++ b/app/controllers/concerns/sends_blob.rb
@@ -10,7 +10,7 @@ module SendsBlob
def send_blob(repository, blob, params = {})
if blob
- headers['X-Content-Type-Options'] = 'nosniff'
+ headers["X-Content-Type-Options"] = "nosniff"
return if cached_blob?(blob)
@@ -51,7 +51,7 @@ module SendsBlob
def send_lfs_object(blob)
lfs_object = find_lfs_object(blob)
- if lfs_object && lfs_object.project_allowed_access?(project)
+ if lfs_object&.project_allowed_access?(project)
send_upload(lfs_object.file, attachment: blob.name)
else
render_404
@@ -60,10 +60,8 @@ module SendsBlob
def find_lfs_object(blob)
lfs_object = LfsObject.find_by_oid(blob.lfs_oid)
- if lfs_object && lfs_object.file.exists?
+ if lfs_object&.file&.exists?
lfs_object
- else
- nil
end
end
end
diff --git a/app/controllers/concerns/service_params.rb b/app/controllers/concerns/service_params.rb
index 48451bedcc2..0f64cb04635 100644
--- a/app/controllers/concerns/service_params.rb
+++ b/app/controllers/concerns/service_params.rb
@@ -62,7 +62,7 @@ module ServiceParams
:url,
:user_key,
:username,
- :webhook
+ :webhook,
].freeze
# Parameters to ignore if no value is specified
diff --git a/app/controllers/concerns/sessionless_authentication.rb b/app/controllers/concerns/sessionless_authentication.rb
index 590eefc6dab..c718f4303df 100644
--- a/app/controllers/concerns/sessionless_authentication.rb
+++ b/app/controllers/concerns/sessionless_authentication.rb
@@ -13,7 +13,7 @@ module SessionlessAuthentication
end
def sessionless_user?
- current_user && !session.keys.include?('warden.user.user.key')
+ current_user && !session.key?("warden.user.user.key")
end
def sessionless_sign_in(user)
diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb
index 014232a7d05..bf2683034a8 100644
--- a/app/controllers/concerns/snippets_actions.rb
+++ b/app/controllers/concerns/snippets_actions.rb
@@ -8,13 +8,13 @@ module SnippetsActions
# rubocop:disable Gitlab/ModuleWithInstanceVariables
def raw
- disposition = params[:inline] == 'false' ? 'attachment' : 'inline'
+ disposition = params[:inline] == "false" ? "attachment" : "inline"
workhorse_set_content_type!
send_data(
convert_line_endings(@snippet.content),
- type: 'text/plain; charset=utf-8',
+ type: "text/plain; charset=utf-8",
disposition: disposition,
filename: @snippet.sanitized_file_name
)
@@ -28,6 +28,6 @@ module SnippetsActions
private
def convert_line_endings(content)
- params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n")
+ params[:line_ending] == "raw" ? content : content.gsub(/\r\n/, "\n")
end
end
diff --git a/app/controllers/concerns/spammable_actions.rb b/app/controllers/concerns/spammable_actions.rb
index c3a1b12af84..26847e03550 100644
--- a/app/controllers/concerns/spammable_actions.rb
+++ b/app/controllers/concerns/spammable_actions.rb
@@ -14,7 +14,7 @@ module SpammableActions
if SpamService.new(spammable).mark_as_spam!
redirect_to spammable_path, notice: "#{spammable.spammable_entity_type.titlecase} was submitted to Akismet successfully."
else
- redirect_to spammable_path, alert: 'Error with Akismet. Please check the logs for more info.'
+ redirect_to spammable_path, alert: "Error with Akismet. Please check the logs for more info."
end
end
@@ -33,7 +33,7 @@ module SpammableActions
ensure_spam_config_loaded!
if params[:recaptcha_verification]
- flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ flash[:alert] = "There was an error with the reCAPTCHA. Please solve the reCAPTCHA again."
end
respond_to do |format|
@@ -42,10 +42,10 @@ module SpammableActions
end
format.json do
- locals = { spammable: spammable, script: false, has_submit: false }
- recaptcha_html = render_to_string(partial: 'shared/recaptcha_form', formats: :html, locals: locals)
+ locals = {spammable: spammable, script: false, has_submit: false}
+ recaptcha_html = render_to_string(partial: "shared/recaptcha_form", formats: :html, locals: locals)
- render json: { recaptcha_html: recaptcha_html }
+ render json: {recaptcha_html: recaptcha_html}
end
end
else
@@ -54,7 +54,7 @@ module SpammableActions
end
def spammable_params
- default_params = { request: request }
+ default_params = {request: request}
recaptcha_check = params[:recaptcha_verification] &&
ensure_spam_config_loaded! &&
@@ -62,8 +62,8 @@ module SpammableActions
return default_params unless recaptcha_check
- { recaptcha_verified: true,
- spam_log_id: params[:spam_log_id] }.merge(default_params)
+ {recaptcha_verified: true,
+ spam_log_id: params[:spam_log_id],}.merge(default_params)
end
def spammable
diff --git a/app/controllers/concerns/todos_actions.rb b/app/controllers/concerns/todos_actions.rb
index 78b65f7961b..c486a65445a 100644
--- a/app/controllers/concerns/todos_actions.rb
+++ b/app/controllers/concerns/todos_actions.rb
@@ -8,7 +8,7 @@ module TodosActions
render json: {
count: TodosFinder.new(current_user, state: :pending).execute.count,
- delete_path: dashboard_todo_path(todo)
+ delete_path: dashboard_todo_path(todo),
}
end
end
diff --git a/app/controllers/concerns/toggle_award_emoji.rb b/app/controllers/concerns/toggle_award_emoji.rb
index 97b343f8b1a..e7bbf2c4baa 100644
--- a/app/controllers/concerns/toggle_award_emoji.rb
+++ b/app/controllers/concerns/toggle_award_emoji.rb
@@ -13,9 +13,9 @@ module ToggleAwardEmoji
todoable = to_todoable(awardable)
TodoService.new.new_award_emoji(todoable, current_user) if todoable
- render json: { ok: true }
+ render json: {ok: true}
else
- render json: { ok: false }
+ render json: {ok: false}
end
end
diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb
index 4ec0e94df9a..5657bdf916d 100644
--- a/app/controllers/concerns/uploads_actions.rb
+++ b/app/controllers/concerns/uploads_actions.rb
@@ -4,7 +4,7 @@ module UploadsActions
include Gitlab::Utils::StrongMemoize
include SendFileUpload
- UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze
+ UPLOAD_MOUNTS = %w[avatar attachment file logo header_logo favicon].freeze
def create
uploader = UploadService.new(model, params[:file], uploader_class).execute
@@ -12,11 +12,11 @@ module UploadsActions
respond_to do |format|
if uploader
format.json do
- render json: { link: uploader.to_h }
+ render json: {link: uploader.to_h}
end
else
format.json do
- render json: 'Invalid file.', status: :unprocessable_entity
+ render json: "Invalid file.", status: :unprocessable_entity
end
end
end
@@ -31,13 +31,13 @@ module UploadsActions
if cache_publicly?
# We need to reset caching from the applications controller to get rid of the no-store value
- headers['Cache-Control'] = ''
+ headers["Cache-Control"] = ""
expires_in 5.minutes, public: true, must_revalidate: false
else
expires_in 0.seconds, must_revalidate: true, private: true
end
- disposition = uploader.image_or_video? ? 'inline' : 'attachment'
+ disposition = uploader.image_or_video? ? "inline" : "attachment"
uploaders = [uploader, *uploader.versions.values]
uploader = uploaders.find { |version| version.filename == params[:filename] }
@@ -53,7 +53,8 @@ module UploadsActions
authorized = uploader_class.workhorse_authorize(
has_length: false,
- maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i)
+ maximum_size: Gitlab::CurrentSettings.max_attachment_size.megabytes.to_i
+ )
render json: authorized
rescue SocketError
@@ -113,7 +114,7 @@ module UploadsActions
end
def image_or_video?
- uploader && uploader.exists? && uploader.image_or_video?
+ uploader&.exists? && uploader&.image_or_video?
end
def find_model
diff --git a/app/controllers/concerns/with_performance_bar.rb b/app/controllers/concerns/with_performance_bar.rb
index 77c3d476ac6..bcce144ef49 100644
--- a/app/controllers/concerns/with_performance_bar.rb
+++ b/app/controllers/concerns/with_performance_bar.rb
@@ -17,9 +17,9 @@ module WithPerformanceBar
def cookie_or_default_value
if cookies[:perf_bar_enabled].present?
- cookies[:perf_bar_enabled] == 'true'
+ cookies[:perf_bar_enabled] == "true"
else
- cookies[:perf_bar_enabled] = 'true' if Rails.env.development?
+ cookies[:perf_bar_enabled] = "true" if Rails.env.development?
end
end
end
diff --git a/app/controllers/confirmations_controller.rb b/app/controllers/confirmations_controller.rb
index 2c4aab67448..23d020fba3a 100644
--- a/app/controllers/confirmations_controller.rb
+++ b/app/controllers/confirmations_controller.rb
@@ -23,7 +23,7 @@ class ConfirmationsController < Devise::ConfirmationsController
else
Gitlab::AppLogger.info("Email Confirmed: username=#{resource.username} email=#{resource.email} ip=#{request.remote_ip}")
flash[:notice] = flash[:notice] + " Please sign in."
- new_session_path(:user, anchor: 'login-pane')
+ new_session_path(:user, anchor: "login-pane")
end
end
diff --git a/app/controllers/dashboard/application_controller.rb b/app/controllers/dashboard/application_controller.rb
index 0e9fdc60363..63bba1a156e 100644
--- a/app/controllers/dashboard/application_controller.rb
+++ b/app/controllers/dashboard/application_controller.rb
@@ -4,7 +4,7 @@ class Dashboard::ApplicationController < ApplicationController
include ControllerWithCrossProjectAccessCheck
include RecordUserLastActivity
- layout 'dashboard'
+ layout "dashboard"
requires_cross_project_access
diff --git a/app/controllers/dashboard/labels_controller.rb b/app/controllers/dashboard/labels_controller.rb
index 89d87c2d5c8..3a266fa2a72 100644
--- a/app/controllers/dashboard/labels_controller.rb
+++ b/app/controllers/dashboard/labels_controller.rb
@@ -8,7 +8,7 @@ class Dashboard::LabelsController < Dashboard::ApplicationController
end
def labels
- finder_params = { project_ids: projects.select(:id) }
+ finder_params = {project_ids: projects.select(:id)}
labels = LabelsFinder.new(current_user, finder_params).execute
GlobalLabel.build_collection(labels)
diff --git a/app/controllers/dashboard/projects_controller.rb b/app/controllers/dashboard/projects_controller.rb
index b044affd4e8..a10f7366a97 100644
--- a/app/controllers/dashboard/projects_controller.rb
+++ b/app/controllers/dashboard/projects_controller.rb
@@ -22,11 +22,11 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
end
format.atom do
load_events
- render layout: 'xml.atom'
+ render layout: "xml.atom"
end
format.json do
render json: {
- html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("dashboard/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -43,7 +43,7 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
format.html
format.json do
render json: {
- html: view_to_html_string("dashboard/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("dashboard/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -53,20 +53,20 @@ class Dashboard::ProjectsController < Dashboard::ApplicationController
private
def default_sorting
- params[:sort] ||= 'latest_activity_desc'
+ params[:sort] ||= "latest_activity_desc"
@sort = params[:sort]
end
# rubocop: disable CodeReuse/ActiveRecord
def load_projects(finder_params)
- @total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute
- @total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
+ @total_user_projects_count = ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute
+ @total_starred_projects_count = ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute
projects = ProjectsFinder
- .new(params: finder_params, current_user: current_user)
- .execute
- .includes(:route, :creator, :group, namespace: [:route, :owner])
- .page(finder_params[:page])
+ .new(params: finder_params, current_user: current_user)
+ .execute
+ .includes(:route, :creator, :group, namespace: [:route, :owner])
+ .page(finder_params[:page])
prepare_projects_for_rendering(projects)
end
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index 3fa582cf25b..36063ef23e9 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -20,8 +20,8 @@ class Dashboard::TodosController < Dashboard::ApplicationController
respond_to do |format|
format.html do
redirect_to dashboard_todos_path,
- status: 302,
- notice: 'Todo was successfully marked as done.'
+ status: 302,
+ notice: "Todo was successfully marked as done."
end
format.js { head :ok }
format.json { render json: todos_counts }
@@ -32,7 +32,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
updated_ids = TodoService.new.mark_todos_as_done(@todos, current_user)
respond_to do |format|
- format.html { redirect_to dashboard_todos_path, status: 302, notice: 'All todos were marked as done.' }
+ format.html { redirect_to dashboard_todos_path, status: 302, notice: "All todos were marked as done." }
format.js { head :ok }
format.json { render json: todos_counts.merge(updated_ids: updated_ids) }
end
@@ -77,7 +77,7 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def todos_counts
{
count: number_with_delimiter(current_user.todos_pending_count),
- done_count: number_with_delimiter(current_user.todos_done_count)
+ done_count: number_with_delimiter(current_user.todos_done_count),
}
end
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 75329b05a6f..0f9a0a9d824 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -29,7 +29,7 @@ class DashboardController < Dashboard::ApplicationController
def load_events
projects =
if params[:filter] == "starred"
- ProjectsFinder.new(current_user: current_user, params: { starred: true }).execute
+ ProjectsFinder.new(current_user: current_user, params: {starred: true}).execute
else
current_user.authorized_projects
end
diff --git a/app/controllers/explore/application_controller.rb b/app/controllers/explore/application_controller.rb
index 8eee3742d89..effe9028d10 100644
--- a/app/controllers/explore/application_controller.rb
+++ b/app/controllers/explore/application_controller.rb
@@ -3,5 +3,5 @@
class Explore::ApplicationController < ApplicationController
skip_before_action :authenticate_user!
- layout 'explore'
+ layout "explore"
end
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb
index f3d76c5a478..d33ccca1898 100644
--- a/app/controllers/explore/projects_controller.rb
+++ b/app/controllers/explore/projects_controller.rb
@@ -7,7 +7,7 @@ class Explore::ProjectsController < Explore::ApplicationController
before_action :set_non_archived_param
def index
- params[:sort] ||= 'latest_activity_desc'
+ params[:sort] ||= "latest_activity_desc"
@sort = params[:sort]
@projects = load_projects
@@ -15,7 +15,7 @@ class Explore::ProjectsController < Explore::ApplicationController
format.html
format.json do
render json: {
- html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("explore/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -30,7 +30,7 @@ class Explore::ProjectsController < Explore::ApplicationController
format.html
format.json do
render json: {
- html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("explore/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -38,13 +38,13 @@ class Explore::ProjectsController < Explore::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def starred
- @projects = load_projects.reorder('star_count DESC')
+ @projects = load_projects.reorder("star_count DESC")
respond_to do |format|
format.html
format.json do
render json: {
- html: view_to_html_string("explore/projects/_projects", locals: { projects: @projects })
+ html: view_to_html_string("explore/projects/_projects", locals: {projects: @projects}),
}
end
end
@@ -55,14 +55,14 @@ class Explore::ProjectsController < Explore::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def load_projects
- @total_user_projects_count = ProjectsFinder.new(params: { non_public: true }, current_user: current_user).execute
- @total_starred_projects_count = ProjectsFinder.new(params: { starred: true }, current_user: current_user).execute
+ @total_user_projects_count = ProjectsFinder.new(params: {non_public: true}, current_user: current_user).execute
+ @total_starred_projects_count = ProjectsFinder.new(params: {starred: true}, current_user: current_user).execute
projects = ProjectsFinder.new(current_user: current_user, params: params)
- .execute
- .includes(:route, :creator, :group, namespace: [:route, :owner])
- .page(params[:page])
- .without_count
+ .execute
+ .includes(:route, :creator, :group, namespace: [:route, :owner])
+ .page(params[:page])
+ .without_count
prepare_projects_for_rendering(projects)
end
diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb
index 3ef03bc9622..8d8cb44e07e 100644
--- a/app/controllers/graphql_controller.rb
+++ b/app/controllers/graphql_controller.rb
@@ -12,7 +12,7 @@ class GraphqlController < ApplicationController
query = params[:query]
operation_name = params[:operationName]
context = {
- current_user: current_user
+ current_user: current_user,
}
result = GitlabSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
render json: result
@@ -37,7 +37,7 @@ class GraphqlController < ApplicationController
end
def render_error(message, status: 500)
- error = { errors: [message: message] }
+ error = {errors: [message: message]}
render json: error, status: status
end
diff --git a/app/controllers/groups/application_controller.rb b/app/controllers/groups/application_controller.rb
index 5f92333c2c3..10abdcc3365 100644
--- a/app/controllers/groups/application_controller.rb
+++ b/app/controllers/groups/application_controller.rb
@@ -4,7 +4,7 @@ class Groups::ApplicationController < ApplicationController
include RoutableActions
include ControllerWithCrossProjectAccessCheck
- layout 'group'
+ layout "group"
skip_before_action :authenticate_user!
before_action :group
@@ -22,13 +22,13 @@ class Groups::ApplicationController < ApplicationController
def authorize_admin_group!
unless can?(current_user, :admin_group, group)
- return render_404
+ render_404
end
end
def authorize_admin_group_member!
unless can?(current_user, :admin_group_member, group)
- return render_403
+ render_403
end
end
diff --git a/app/controllers/groups/children_controller.rb b/app/controllers/groups/children_controller.rb
index 236a19a8dc4..b13c543084d 100644
--- a/app/controllers/groups/children_controller.rb
+++ b/app/controllers/groups/children_controller.rb
@@ -7,10 +7,10 @@ module Groups
def index
parent = if params[:parent_id].present?
- GroupFinder.new(current_user).execute(id: params[:parent_id])
- else
- @group
- end
+ GroupFinder.new(current_user).execute(id: params[:parent_id])
+ else
+ @group
+ end
if parent.nil?
render_404
@@ -22,8 +22,8 @@ module Groups
respond_to do |format|
format.json do
serializer = GroupChildSerializer
- .new(current_user: current_user)
- .with_pagination(request, response)
+ .new(current_user: current_user)
+ .with_pagination(request, response)
serializer.expand_hierarchy(parent) if params[:filter].present?
render json: serializer.represent(@children)
end
diff --git a/app/controllers/groups/clusters_controller.rb b/app/controllers/groups/clusters_controller.rb
index b846fb21266..f659d4c3991 100644
--- a/app/controllers/groups/clusters_controller.rb
+++ b/app/controllers/groups/clusters_controller.rb
@@ -7,7 +7,7 @@ class Groups::ClustersController < Clusters::ClustersController
prepend_before_action :check_group_clusters_feature_flag!
requires_cross_project_access
- layout 'group'
+ layout "group"
private
diff --git a/app/controllers/groups/group_members_controller.rb b/app/controllers/groups/group_members_controller.rb
index 0bc082246a1..5cbebae5a44 100644
--- a/app/controllers/groups/group_members_controller.rb
+++ b/app/controllers/groups/group_members_controller.rb
@@ -13,8 +13,8 @@ class Groups::GroupMembersController < Groups::ApplicationController
before_action :authorize_admin_group_member!, except: admin_not_required_endpoints
skip_cross_project_access_check :index, :create, :update, :destroy, :request_access,
- :approve_access_request, :leave, :resend_invite,
- :override
+ :approve_access_request, :leave, :resend_invite,
+ :override
def index
can_manage_members = can?(current_user, :admin_group_member, @group)
@@ -35,11 +35,12 @@ class Groups::GroupMembersController < Groups::ApplicationController
@members = present_members(@members)
@requesters = present_members(
- AccessRequestsFinder.new(@group).execute(current_user))
+ AccessRequestsFinder.new(@group).execute(current_user)
+ )
@group_member = @group.group_members.new
end
# MembershipActions concern
- alias_method :membershipable, :group
+ alias membershipable group
end
diff --git a/app/controllers/groups/labels_controller.rb b/app/controllers/groups/labels_controller.rb
index 26768c628ca..dd80c8ebbc5 100644
--- a/app/controllers/groups/labels_controller.rb
+++ b/app/controllers/groups/labels_controller.rb
@@ -82,7 +82,7 @@ class Groups::LabelsController < Groups::ApplicationController
def label
@label ||= @group.labels.find(params[:id])
end
- alias_method :subscribable_resource, :label
+ alias subscribable_resource label
def subscribable_project
nil
@@ -105,7 +105,7 @@ class Groups::LabelsController < Groups::ApplicationController
end
def save_previous_label_path
- session[:previous_labels_path] = URI(request.referer || '').path
+ session[:previous_labels_path] = URI(request.referer || "").path
end
def available_labels
@@ -116,10 +116,11 @@ class Groups::LabelsController < Groups::ApplicationController
only_group_labels: params[:only_group_labels],
include_ancestor_groups: params[:include_ancestor_groups],
include_descendant_groups: params[:include_descendant_groups],
- search: params[:search]).execute
+ search: params[:search]
+ ).execute
end
def sort
- @sort ||= params[:sort] || 'name_asc'
+ @sort ||= params[:sort] || "name_asc"
end
end
diff --git a/app/controllers/groups/milestones_controller.rb b/app/controllers/groups/milestones_controller.rb
index 7ed4384089b..cf9510dfb50 100644
--- a/app/controllers/groups/milestones_controller.rb
+++ b/app/controllers/groups/milestones_controller.rb
@@ -95,7 +95,7 @@ class Groups::MilestonesController < Groups::ApplicationController
def milestones
milestones = MilestonesFinder.new(search_params).execute
- @sort = params[:sort] || 'due_date_asc'
+ @sort = params[:sort] || "due_date_asc"
MilestoneArray.sort(milestones + legacy_milestones, @sort)
end
diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb
index dd8fbf7a029..15349446b9a 100644
--- a/app/controllers/groups/runners_controller.rb
+++ b/app/controllers/groups/runners_controller.rb
@@ -8,7 +8,7 @@ class Groups::RunnersController < Groups::ApplicationController
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
def show
- render 'shared/runners/show'
+ render "shared/runners/show"
end
def edit
@@ -16,31 +16,31 @@ class Groups::RunnersController < Groups::ApplicationController
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
- redirect_to group_runner_path(@group, @runner), notice: 'Runner was successfully updated.'
+ redirect_to group_runner_path(@group, @runner), notice: "Runner was successfully updated."
else
- render 'edit'
+ render "edit"
end
end
def destroy
@runner.destroy
- redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found
+ redirect_to group_settings_ci_cd_path(@group, anchor: "runners-settings"), status: :found
end
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
- redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
+ redirect_to group_settings_ci_cd_path(@group, anchor: "runners-settings"), notice: "Runner was successfully updated."
else
- redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
+ redirect_to group_settings_ci_cd_path(@group, anchor: "runners-settings"), alert: "Runner was not updated."
end
end
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
- redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
+ redirect_to group_settings_ci_cd_path(@group, anchor: "runners-settings"), notice: "Runner was successfully updated."
else
- redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
+ redirect_to group_settings_ci_cd_path(@group, anchor: "runners-settings"), alert: "Runner was not updated."
end
end
diff --git a/app/controllers/groups/settings/ci_cd_controller.rb b/app/controllers/groups/settings/ci_cd_controller.rb
index f476f428fdb..d8b909f73f7 100644
--- a/app/controllers/groups/settings/ci_cd_controller.rb
+++ b/app/controllers/groups/settings/ci_cd_controller.rb
@@ -13,7 +13,7 @@ module Groups
def reset_registration_token
@group.reset_runners_token!
- flash[:notice] = 'New runners registration token has been generated!'
+ flash[:notice] = "New runners registration token has been generated!"
redirect_to group_settings_ci_cd_path
end
diff --git a/app/controllers/groups/shared_projects_controller.rb b/app/controllers/groups/shared_projects_controller.rb
index 30b7bfc70ae..1096af84cb2 100644
--- a/app/controllers/groups/shared_projects_controller.rb
+++ b/app/controllers/groups/shared_projects_controller.rb
@@ -11,10 +11,10 @@ module Groups
group: group,
current_user: current_user,
params: finder_params,
- options: { only_shared: true }
+ options: {only_shared: true}
).execute
serializer = GroupChildSerializer.new(current_user: current_user)
- .with_pagination(request, response)
+ .with_pagination(request, response)
render json: serializer.represent(shared_projects)
end
diff --git a/app/controllers/groups/uploads_controller.rb b/app/controllers/groups/uploads_controller.rb
index 7e5cdae0ce3..2af007e4f57 100644
--- a/app/controllers/groups/uploads_controller.rb
+++ b/app/controllers/groups/uploads_controller.rb
@@ -4,7 +4,7 @@ class Groups::UploadsController < Groups::ApplicationController
include UploadsActions
include WorkhorseRequest
- skip_before_action :group, if: -> { action_name == 'show' && image_or_video? }
+ skip_before_action :group, if: -> { action_name == "show" && image_or_video? }
before_action :authorize_upload_file!, only: [:create, :authorize]
before_action :verify_workhorse_api!, only: [:authorize]
diff --git a/app/controllers/groups/variables_controller.rb b/app/controllers/groups/variables_controller.rb
index 4f641de0357..35c760f10c8 100644
--- a/app/controllers/groups/variables_controller.rb
+++ b/app/controllers/groups/variables_controller.rb
@@ -9,7 +9,7 @@ module Groups
def show
respond_to do |format|
format.json do
- render status: :ok, json: { variables: GroupVariableSerializer.new.represent(@group.variables) }
+ render status: :ok, json: {variables: GroupVariableSerializer.new.represent(@group.variables)}
end
end
end
@@ -29,7 +29,7 @@ module Groups
private
def render_group_variables
- render status: :ok, json: { variables: GroupVariableSerializer.new.represent(@group.variables) }
+ render status: :ok, json: {variables: GroupVariableSerializer.new.represent(@group.variables)}
end
def render_error
diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb
index 4e50106398a..a078cb2b000 100644
--- a/app/controllers/groups_controller.rb
+++ b/app/controllers/groups_controller.rb
@@ -25,7 +25,7 @@ class GroupsController < Groups::ApplicationController
before_action :user_actions, only: [:show]
skip_cross_project_access_check :index, :new, :create, :edit, :update,
- :destroy, :projects
+ :destroy, :projects
# When loading show as an atom feed, we render events that could leak cross
# project information
skip_cross_project_access_check :show, if: -> { request.format.html? }
@@ -45,10 +45,10 @@ class GroupsController < Groups::ApplicationController
if @group.persisted?
notice = if @group.chat_team.present?
- "Group '#{@group.name}' and its Mattermost team were successfully created."
- else
- "Group '#{@group.name}' was successfully created."
- end
+ "Group '#{@group.name}' and its Mattermost team were successfully created."
+ else
+ "Group '#{@group.name}' was successfully created."
+ end
redirect_to @group, notice: notice
else
@@ -62,7 +62,7 @@ class GroupsController < Groups::ApplicationController
format.atom do
load_events
- render layout: 'xml.atom'
+ render layout: "xml.atom"
end
end
end
@@ -122,11 +122,11 @@ class GroupsController < Groups::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def authorize_create_group!
allowed = if params[:parent_id].present?
- parent = Group.find_by(id: params[:parent_id])
- can?(current_user, :create_subgroup, parent)
- else
- can?(current_user, :create_group)
- end
+ parent = Group.find_by(id: params[:parent_id])
+ can?(current_user, :create_subgroup, parent)
+ else
+ can?(current_user, :create_group)
+ end
render_404 unless allowed
end
@@ -134,11 +134,11 @@ class GroupsController < Groups::ApplicationController
def determine_layout
if [:new, :create].include?(action_name.to_sym)
- 'application'
+ "application"
elsif [:edit, :update, :projects].include?(action_name.to_sym)
- 'group_settings'
+ "group_settings"
else
- 'group'
+ "group"
end
end
@@ -161,21 +161,21 @@ class GroupsController < Groups::ApplicationController
:create_chat_team,
:chat_team_name,
:require_two_factor_authentication,
- :two_factor_grace_period
+ :two_factor_grace_period,
]
end
# rubocop: disable CodeReuse/ActiveRecord
def load_events
- params[:sort] ||= 'latest_activity_desc'
+ params[:sort] ||= "latest_activity_desc"
options = {}
- options[:only_owned] = true if params[:shared] == '0'
- options[:only_shared] = true if params[:shared] == '1'
+ options[:only_owned] = true if params[:shared] == "0"
+ options[:only_shared] = true if params[:shared] == "1"
@projects = GroupProjectsFinder.new(params: params, group: group, options: options, current_user: current_user)
- .execute
- .includes(:namespace)
+ .execute
+ .includes(:namespace)
@events = EventCollection
.new(@projects, offset: params[:offset].to_i, filter: event_filter)
@@ -194,7 +194,7 @@ class GroupsController < Groups::ApplicationController
end
def build_canonical_path(group)
- return group_path(group) if action_name == 'show' # root group path
+ return group_path(group) if action_name == "show" # root group path
params[:id] = group.to_param
diff --git a/app/controllers/health_controller.rb b/app/controllers/health_controller.rb
index dc9a52f8da5..b930e651fed 100644
--- a/app/controllers/health_controller.rb
+++ b/app/controllers/health_controller.rb
@@ -10,7 +10,7 @@ class HealthController < ActionController::Base
Gitlab::HealthChecks::Redis::CacheCheck,
Gitlab::HealthChecks::Redis::QueuesCheck,
Gitlab::HealthChecks::Redis::SharedStateCheck,
- Gitlab::HealthChecks::GitalyCheck
+ Gitlab::HealthChecks::GitalyCheck,
].freeze
def readiness
@@ -28,21 +28,21 @@ class HealthController < ActionController::Base
private
def render_check_results(results)
- flattened = results.flat_map do |name, result|
+ flattened = results.flat_map { |name, result|
if result.is_a?(Gitlab::HealthChecks::Result)
[[name, result]]
else
result.map { |r| [name, r] }
end
- end
+ }
success = flattened.all? { |name, r| r.success }
- response = flattened.map do |name, r|
- info = { status: r.success ? 'ok' : 'failed' }
- info['message'] = r.message if r.message
+ response = flattened.map { |name, r|
+ info = {status: r.success ? "ok" : "failed"}
+ info["message"] = r.message if r.message
info[:labels] = r.labels if r.labels
[name, info]
- end
+ }
render json: response.to_h, status: success ? :ok : :service_unavailable
end
end
diff --git a/app/controllers/help_controller.rb b/app/controllers/help_controller.rb
index a9d6addd4a4..ae585e795dd 100644
--- a/app/controllers/help_controller.rb
+++ b/app/controllers/help_controller.rb
@@ -3,7 +3,7 @@
class HelpController < ApplicationController
skip_before_action :authenticate_user!
- layout 'help'
+ layout "help"
# Taken from Jekyll
# https://github.com/jekyll/jekyll/blob/3.5-stable/lib/jekyll/document.rb#L13
@@ -11,7 +11,7 @@ class HelpController < ApplicationController
def index
# Remove YAML frontmatter so that it doesn't look weird
- @help_index = File.read(Rails.root.join('doc', 'README.md')).sub(YAML_FRONT_MATTER_REGEXP, '')
+ @help_index = File.read(Rails.root.join("doc", "README.md")).sub(YAML_FRONT_MATTER_REGEXP, "")
# Prefix Markdown links with `help/` unless they are external links.
# '//' not necessarily part of URL, e.g., mailto:mail@example.com
@@ -27,26 +27,26 @@ class HelpController < ApplicationController
respond_to do |format|
format.any(:markdown, :md, :html) do
# Note: We are purposefully NOT using `Rails.root.join`
- path = File.join(Rails.root, 'doc', "#{@path}.md")
+ path = File.join(Rails.root, "doc", "#{@path}.md")
if File.exist?(path)
# Remove YAML frontmatter so that it doesn't look weird
- @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, '')
+ @markdown = File.read(path).gsub(YAML_FRONT_MATTER_REGEXP, "")
- render 'show.html.haml'
+ render "show.html.haml"
else
# Force template to Haml
- render 'errors/not_found.html.haml', layout: 'errors', status: 404
+ render "errors/not_found.html.haml", layout: "errors", status: 404
end
end
# Allow access to images in the doc folder
format.any(:png, :gif, :jpeg, :mp4) do
# Note: We are purposefully NOT using `Rails.root.join`
- path = File.join(Rails.root, 'doc', "#{@path}.#{params[:format]}")
+ path = File.join(Rails.root, "doc", "#{@path}.#{params[:format]}")
if File.exist?(path)
- send_file(path, disposition: 'inline')
+ send_file(path, disposition: "inline")
else
head :not_found
end
@@ -65,7 +65,7 @@ class HelpController < ApplicationController
end
def ui
- @user = User.new(id: 0, name: 'John Doe', username: '@johndoe')
+ @user = User.new(id: 0, name: "John Doe", username: "@johndoe")
end
private
@@ -88,9 +88,9 @@ class HelpController < ApplicationController
# Walk over each part of the path
parts.each do |part|
# Turn `one//two` or `one/./two` into `one/two`.
- next if part.empty? || part == '.'
+ next if part.empty? || part == "."
- if part == '..'
+ if part == ".."
# Turn `one/two/../` into `one`
clean.pop
else
@@ -101,7 +101,7 @@ class HelpController < ApplicationController
# If the path was an absolute path (i.e. `/` or `/one/two`),
# add `/` to the front of the clean path.
- clean.unshift '/' if parts.empty? || parts.first.empty?
+ clean.unshift "/" if parts.empty? || parts.first.empty?
# Join all the clean path parts by the path separator.
::File.join(*clean)
diff --git a/app/controllers/ide_controller.rb b/app/controllers/ide_controller.rb
index eeeebe430a7..02ad604d87f 100644
--- a/app/controllers/ide_controller.rb
+++ b/app/controllers/ide_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class IdeController < ApplicationController
- layout 'fullscreen'
+ layout "fullscreen"
def index
end
diff --git a/app/controllers/import/base_controller.rb b/app/controllers/import/base_controller.rb
index 9b45be6db99..27389018507 100644
--- a/app/controllers/import/base_controller.rb
+++ b/app/controllers/import/base_controller.rb
@@ -35,6 +35,6 @@ class Import::BaseController < ApplicationController
# deprecated: being replaced by app/services/import/base_service.rb
def project_save_error(project)
- project.errors.full_messages.join(', ')
+ project.errors.full_messages.join(", ")
end
end
diff --git a/app/controllers/import/bitbucket_controller.rb b/app/controllers/import/bitbucket_controller.rb
index 2b1395f364f..70be7aa143b 100644
--- a/app/controllers/import/bitbucket_controller.rb
+++ b/app/controllers/import/bitbucket_controller.rb
@@ -25,7 +25,7 @@ class Import::BitbucketController < Import::BaseController
@repos, @incompatible_repos = repos.partition { |repo| repo.valid? }
- @already_added_projects = find_already_added_projects('bitbucket')
+ @already_added_projects = find_already_added_projects("bitbucket")
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.to_a.reject! { |repo| already_added_projects_names.include?(repo.full_name) }
@@ -33,14 +33,14 @@ class Import::BitbucketController < Import::BaseController
# rubocop: enable CodeReuse/ActiveRecord
def jobs
- render json: find_jobs('bitbucket')
+ render json: find_jobs("bitbucket")
end
def create
bitbucket_client = Bitbucket::Client.new(credentials)
repo_id = params[:repo_id].to_s
- name = repo_id.gsub('___', '/')
+ name = repo_id.gsub("___", "/")
repo = bitbucket_client.repo(name)
project_name = params[:new_name].presence || repo.name
@@ -59,10 +59,10 @@ class Import::BitbucketController < Import::BaseController
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
else
- render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
+ render json: {errors: "This namespace has already been taken! Please choose another one."}, status: :unprocessable_entity
end
end
@@ -73,7 +73,7 @@ class Import::BitbucketController < Import::BaseController
end
def provider
- Gitlab::Auth::OAuth::Provider.config_for('bitbucket')
+ Gitlab::Auth::OAuth::Provider.config_for("bitbucket")
end
def options
@@ -101,7 +101,7 @@ class Import::BitbucketController < Import::BaseController
token: session[:bitbucket_token],
expires_at: session[:bitbucket_expires_at],
expires_in: session[:bitbucket_expires_in],
- refresh_token: session[:bitbucket_refresh_token]
+ refresh_token: session[:bitbucket_refresh_token],
}
end
end
diff --git a/app/controllers/import/bitbucket_server_controller.rb b/app/controllers/import/bitbucket_server_controller.rb
index f333e43b892..c495d2945a4 100644
--- a/app/controllers/import/bitbucket_server_controller.rb
+++ b/app/controllers/import/bitbucket_server_controller.rb
@@ -25,7 +25,7 @@ class Import::BitbucketServerController < Import::BaseController
repo = bitbucket_client.repo(@project_key, @repo_slug)
unless repo
- return render json: { errors: "Project #{@project_key}/#{@repo_slug} could not be found" }, status: :unprocessable_entity
+ return render json: {errors: "Project #{@project_key}/#{@repo_slug} could not be found"}, status: :unprocessable_entity
end
project_name = params[:new_name].presence || repo.name
@@ -38,13 +38,13 @@ class Import::BitbucketServerController < Import::BaseController
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
else
- render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
+ render json: {errors: "This namespace has already been taken! Please choose another one."}, status: :unprocessable_entity
end
rescue BitbucketServer::Connection::ConnectionError => e
- render json: { errors: "Unable to connect to server: #{e}" }, status: :unprocessable_entity
+ render json: {errors: "Unable to connect to server: #{e}"}, status: :unprocessable_entity
end
def configure
@@ -61,7 +61,7 @@ class Import::BitbucketServerController < Import::BaseController
@repos, @incompatible_repos = @collection.partition { |repo| repo.valid? }
# Use the import URL to filter beyond what BaseService#find_already_added_projects
- @already_added_projects = filter_added_projects('bitbucket_server', @repos.map(&:browse_url))
+ @already_added_projects = filter_added_projects("bitbucket_server", @repos.map(&:browse_url))
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include?(repo.browse_url) }
@@ -73,7 +73,7 @@ class Import::BitbucketServerController < Import::BaseController
# rubocop: enable CodeReuse/ActiveRecord
def jobs
- render json: find_jobs('bitbucket_server')
+ render json: find_jobs("bitbucket_server")
end
private
@@ -92,14 +92,14 @@ class Import::BitbucketServerController < Import::BaseController
@project_key = params[:project]
@repo_slug = params[:repository]
- return render_validation_error('Missing project key') unless @project_key.present? && @repo_slug.present?
- return render_validation_error('Missing repository slug') unless @repo_slug.present?
- return render_validation_error('Invalid project key') unless @project_key =~ VALID_BITBUCKET_PROJECT_CHARS
- return render_validation_error('Invalid repository slug') unless @repo_slug =~ VALID_BITBUCKET_CHARS
+ return render_validation_error("Missing project key") unless @project_key.present? && @repo_slug.present?
+ return render_validation_error("Missing repository slug") unless @repo_slug.present?
+ return render_validation_error("Invalid project key") unless @project_key =~ VALID_BITBUCKET_PROJECT_CHARS
+ return render_validation_error("Invalid repository slug") unless @repo_slug =~ VALID_BITBUCKET_CHARS
end
def render_validation_error(message)
- render json: { errors: message }, status: :unprocessable_entity
+ render json: {errors: message}, status: :unprocessable_entity
end
def bitbucket_auth
@@ -136,7 +136,7 @@ class Import::BitbucketServerController < Import::BaseController
{
base_uri: session[bitbucket_server_url_key],
user: session[bitbucket_server_username_key],
- password: session[personal_access_token_key]
+ password: session[personal_access_token_key],
}
end
diff --git a/app/controllers/import/fogbugz_controller.rb b/app/controllers/import/fogbugz_controller.rb
index 5a439e6de78..a961f9c2d16 100644
--- a/app/controllers/import/fogbugz_controller.rb
+++ b/app/controllers/import/fogbugz_controller.rb
@@ -14,7 +14,7 @@ class Import::FogbugzController < Import::BaseController
res = Gitlab::FogbugzImport::Client.new(import_params.symbolize_keys)
rescue
# If the URI is invalid various errors can occur
- return redirect_to new_import_fogbugz_path, alert: 'Could not connect to FogBugz, check your URL'
+ return redirect_to new_import_fogbugz_path, alert: "Could not connect to FogBugz, check your URL"
end
session[:fogbugz_token] = res.get_token
session[:fogbugz_uri] = params[:uri]
@@ -29,14 +29,14 @@ class Import::FogbugzController < Import::BaseController
user_map = params[:users]
unless user_map.is_a?(Hash) && user_map.all? { |k, v| !v[:name].blank? }
- flash.now[:alert] = 'All users must have a name.'
+ flash.now[:alert] = "All users must have a name."
- return render 'new_user_map'
+ return render "new_user_map"
end
session[:fogbugz_user_map] = user_map
- flash[:notice] = 'The user map has been saved. Continue by selecting the projects you want to import.'
+ flash[:notice] = "The user map has been saved. Continue by selecting the projects you want to import."
redirect_to status_import_fogbugz_path
end
@@ -49,7 +49,7 @@ class Import::FogbugzController < Import::BaseController
@repos = client.repos
- @already_added_projects = find_already_added_projects('fogbugz')
+ @already_added_projects = find_already_added_projects("fogbugz")
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include? repo.name }
@@ -57,12 +57,12 @@ class Import::FogbugzController < Import::BaseController
# rubocop: enable CodeReuse/ActiveRecord
def jobs
- render json: find_jobs('fogbugz')
+ render json: find_jobs("fogbugz")
end
def create
repo = client.repo(params[:repo_id])
- fb_session = { uri: session[:fogbugz_uri], token: session[:fogbugz_token] }
+ fb_session = {uri: session[:fogbugz_uri], token: session[:fogbugz_token]}
umap = session[:fogbugz_user_map] || client.user_map
project = Gitlab::FogbugzImport::ProjectCreator.new(repo, fb_session, current_user.namespace, current_user, umap).execute
@@ -70,7 +70,7 @@ class Import::FogbugzController < Import::BaseController
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
end
diff --git a/app/controllers/import/gitea_controller.rb b/app/controllers/import/gitea_controller.rb
index 68ad8650dba..06fbd5ecae1 100644
--- a/app/controllers/import/gitea_controller.rb
+++ b/app/controllers/import/gitea_controller.rb
@@ -46,12 +46,12 @@ class Import::GiteaController < Import::GithubController
def provider_auth
if session[access_token_key].blank? || provider_url.blank?
redirect_to new_import_gitea_url,
- alert: 'You need to specify both an Access Token and a Host URL.'
+ alert: "You need to specify both an Access Token and a Host URL."
end
end
override :client_options
def client_options
- { host: provider_url, api_version: 'v1' }
+ {host: provider_url, api_version: "v1"}
end
end
diff --git a/app/controllers/import/github_controller.rb b/app/controllers/import/github_controller.rb
index aa4aa0fbdac..1bb8c035659 100644
--- a/app/controllers/import/github_controller.rb
+++ b/app/controllers/import/github_controller.rb
@@ -34,9 +34,9 @@ class Import::GithubController < Import::BaseController
respond_to do |format|
format.json do
- render json: { imported_projects: serialized_imported_projects,
- provider_repos: serialized_provider_repos,
- namespaces: serialized_namespaces }
+ render json: {imported_projects: serialized_imported_projects,
+ provider_repos: serialized_provider_repos,
+ namespaces: serialized_namespaces,}
end
format.html
end
@@ -48,7 +48,7 @@ class Import::GithubController < Import::BaseController
if result[:status] == :success
render json: serialized_imported_projects(result[:project])
else
- render json: { errors: result[:message] }, status: result[:http_status]
+ render json: {errors: result[:message]}, status: result[:http_status]
end
end
@@ -146,7 +146,7 @@ class Import::GithubController < Import::BaseController
end
def access_params
- { github_access_token: session[access_token_key] }
+ {github_access_token: session[access_token_key]}
end
# The following methods are overridden in subclasses
@@ -156,9 +156,9 @@ class Import::GithubController < Import::BaseController
def provider_url
strong_memoize(:provider_url) do
- provider = Gitlab::Auth::OAuth::Provider.config_for('github')
+ provider = Gitlab::Auth::OAuth::Provider.config_for("github")
- provider&.dig('url').presence || 'https://github.com'
+ provider&.dig("url").presence || "https://github.com"
end
end
diff --git a/app/controllers/import/gitlab_controller.rb b/app/controllers/import/gitlab_controller.rb
index 498de0b07b8..c07632f66cb 100644
--- a/app/controllers/import/gitlab_controller.rb
+++ b/app/controllers/import/gitlab_controller.rb
@@ -18,7 +18,7 @@ class Import::GitlabController < Import::BaseController
def status
@repos = client.projects(starting_page: 1, page_limit: MAX_PROJECT_PAGES, per_page: PER_PAGE_PROJECTS)
- @already_added_projects = find_already_added_projects('gitlab')
+ @already_added_projects = find_already_added_projects("gitlab")
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos = @repos.to_a.reject { |repo| already_added_projects_names.include? repo["path_with_namespace"] }
@@ -26,12 +26,12 @@ class Import::GitlabController < Import::BaseController
# rubocop: enable CodeReuse/ActiveRecord
def jobs
- render json: find_jobs('gitlab')
+ render json: find_jobs("gitlab")
end
def create
repo = client.project(params[:repo_id].to_i)
- target_namespace = find_or_create_namespace(repo['namespace']['path'], client.user['username'])
+ target_namespace = find_or_create_namespace(repo["namespace"]["path"], client.user["username"])
if current_user.can?(:create_projects, target_namespace)
project = Gitlab::GitlabImport::ProjectCreator.new(repo, target_namespace, current_user, access_params).execute
@@ -39,10 +39,10 @@ class Import::GitlabController < Import::BaseController
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
else
- render json: { errors: 'This namespace has already been taken! Please choose another one.' }, status: :unprocessable_entity
+ render json: {errors: "This namespace has already been taken! Please choose another one."}, status: :unprocessable_entity
end
end
@@ -71,6 +71,6 @@ class Import::GitlabController < Import::BaseController
end
def access_params
- { gitlab_access_token: session[:gitlab_access_token] }
+ {gitlab_access_token: session[:gitlab_access_token]}
end
end
diff --git a/app/controllers/import/gitlab_projects_controller.rb b/app/controllers/import/gitlab_projects_controller.rb
index 354fba5d204..fc63db08a97 100644
--- a/app/controllers/import/gitlab_projects_controller.rb
+++ b/app/controllers/import/gitlab_projects_controller.rb
@@ -13,7 +13,7 @@ class Import::GitlabProjectsController < Import::BaseController
def create
unless file_is_valid?
- return redirect_back_or_default(options: { alert: "You need to upload a GitLab project export archive (ending in .gz)." })
+ return redirect_back_or_default(options: {alert: "You need to upload a GitLab project export archive (ending in .gz)."})
end
@project = ::Projects::GitlabProjectsImportService.new(current_user, project_params).execute
@@ -24,18 +24,18 @@ class Import::GitlabProjectsController < Import::BaseController
notice: "Project '#{@project.name}' is being imported."
)
else
- redirect_back_or_default(options: { alert: "Project could not be imported: #{@project.errors.full_messages.join(', ')}" })
+ redirect_back_or_default(options: {alert: "Project could not be imported: #{@project.errors.full_messages.join(", ")}"})
end
end
private
def file_is_valid?
- return false unless project_params[:file] && project_params[:file].respond_to?(:read)
+ return false unless project_params[:file]&.respond_to?(:read)
filename = project_params[:file].original_filename
- ImportExportUploader::EXTENSION_WHITELIST.include?(File.extname(filename).delete('.'))
+ ImportExportUploader::EXTENSION_WHITELIST.include?(File.extname(filename).delete("."))
end
def verify_gitlab_project_import_enabled
@@ -49,6 +49,6 @@ class Import::GitlabProjectsController < Import::BaseController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42437')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42437")
end
end
diff --git a/app/controllers/import/google_code_controller.rb b/app/controllers/import/google_code_controller.rb
index 331f06c3dd6..c00ee4b9ff8 100644
--- a/app/controllers/import/google_code_controller.rb
+++ b/app/controllers/import/google_code_controller.rb
@@ -11,18 +11,18 @@ class Import::GoogleCodeController < Import::BaseController
dump_file = params[:dump_file]
unless dump_file.respond_to?(:read)
- return redirect_back_or_default(options: { alert: "You need to upload a Google Takeout archive." })
+ return redirect_back_or_default(options: {alert: "You need to upload a Google Takeout archive."})
end
begin
dump = JSON.parse(dump_file.read)
rescue
- return redirect_back_or_default(options: { alert: "The uploaded file is not a valid Google Takeout archive." })
+ return redirect_back_or_default(options: {alert: "The uploaded file is not a valid Google Takeout archive."})
end
client = Gitlab::GoogleCodeImport::Client.new(dump)
unless client.valid?
- return redirect_back_or_default(options: { alert: "The uploaded file is not a valid Google Takeout archive." })
+ return redirect_back_or_default(options: {alert: "The uploaded file is not a valid Google Takeout archive."})
end
session[:google_code_dump] = dump
@@ -76,7 +76,7 @@ class Import::GoogleCodeController < Import::BaseController
@repos = client.repos
@incompatible_repos = client.incompatible_repos
- @already_added_projects = find_already_added_projects('google_code')
+ @already_added_projects = find_already_added_projects("google_code")
already_added_projects_names = @already_added_projects.pluck(:import_source)
@repos.reject! { |repo| already_added_projects_names.include? repo.name }
@@ -84,7 +84,7 @@ class Import::GoogleCodeController < Import::BaseController
# rubocop: enable CodeReuse/ActiveRecord
def jobs
- render json: find_jobs('google_code')
+ render json: find_jobs("google_code")
end
def create
@@ -96,7 +96,7 @@ class Import::GoogleCodeController < Import::BaseController
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
end
diff --git a/app/controllers/import/manifest_controller.rb b/app/controllers/import/manifest_controller.rb
index 320cd45b925..f27f5bcee42 100644
--- a/app/controllers/import/manifest_controller.rb
+++ b/app/controllers/import/manifest_controller.rb
@@ -13,9 +13,9 @@ class Import::ManifestController < Import::BaseController
@already_added_projects = find_already_added_projects
already_added_import_urls = @already_added_projects.pluck(:import_url)
- @pending_repositories = repositories.to_a.reject do |repository|
+ @pending_repositories = repositories.to_a.reject { |repository|
already_added_import_urls.include?(repository[:url])
- end
+ }
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -47,16 +47,16 @@ class Import::ManifestController < Import::BaseController
end
def create
- repository = repositories.find do |project|
+ repository = repositories.find { |project|
project[:id] == params[:repo_id].to_i
- end
+ }
project = Gitlab::ManifestImport::ProjectCreator.new(repository, group, current_user).execute
if project.persisted?
render json: ProjectSerializer.new.represent(project)
else
- render json: { errors: project_save_error(project) }, status: :unprocessable_entity
+ render json: {errors: project_save_error(project)}, status: :unprocessable_entity
end
end
@@ -85,7 +85,7 @@ class Import::ManifestController < Import::BaseController
# rubocop: disable CodeReuse/ActiveRecord
def find_already_added_projects
group.all_projects
- .where(import_type: 'manifest')
+ .where(import_type: "manifest")
.where(creator_id: current_user)
.includes(:import_state)
end
@@ -96,6 +96,6 @@ class Import::ManifestController < Import::BaseController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/48939')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/48939")
end
end
diff --git a/app/controllers/instance_statistics/application_controller.rb b/app/controllers/instance_statistics/application_controller.rb
index a273dde105c..caeda57df26 100644
--- a/app/controllers/instance_statistics/application_controller.rb
+++ b/app/controllers/instance_statistics/application_controller.rb
@@ -2,7 +2,7 @@
class InstanceStatistics::ApplicationController < ApplicationController
before_action :authorize_read_instance_statistics!
- layout 'instance_statistics'
+ layout "instance_statistics"
def authorize_read_instance_statistics!
render_404 unless can?(current_user, :read_instance_statistics)
diff --git a/app/controllers/instance_statistics/cohorts_controller.rb b/app/controllers/instance_statistics/cohorts_controller.rb
index 4b4e39db2e1..574c4f1479b 100644
--- a/app/controllers/instance_statistics/cohorts_controller.rb
+++ b/app/controllers/instance_statistics/cohorts_controller.rb
@@ -5,9 +5,9 @@ class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationCon
def index
if Gitlab::CurrentSettings.usage_ping_enabled
- cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
+ cohorts_results = Rails.cache.fetch("cohorts", expires_in: 1.day) {
CohortsService.new.execute
- end
+ }
@cohorts = CohortsSerializer.new.represent(cohorts_results)
end
diff --git a/app/controllers/invites_controller.rb b/app/controllers/invites_controller.rb
index 315d1375e02..89e4a3486ae 100644
--- a/app/controllers/invites_controller.rb
+++ b/app/controllers/invites_controller.rb
@@ -15,7 +15,7 @@ class InvitesController < ApplicationController
redirect_to path, notice: "You have been granted #{member.human_access} access to #{label}."
else
- redirect_back_or_default(options: { alert: "The invitation could not be accepted." })
+ redirect_back_or_default(options: {alert: "The invitation could not be accepted."})
end
end
@@ -32,7 +32,7 @@ class InvitesController < ApplicationController
redirect_to path, notice: "You have declined the invitation to join #{label}."
else
- redirect_back_or_default(options: { alert: "The invitation could not be declined." })
+ redirect_back_or_default(options: {alert: "The invitation could not be declined."})
end
end
@@ -54,7 +54,7 @@ class InvitesController < ApplicationController
notice = ["To accept this invitation, sign in"]
notice << "or create an account" if Gitlab::CurrentSettings.allow_signup?
- notice = notice.join(' ') + "."
+ notice = notice.join(" ") + "."
store_location_for :user, request.fullpath
redirect_to new_user_session_path, notice: notice
diff --git a/app/controllers/jwt_controller.rb b/app/controllers/jwt_controller.rb
index f9008a5b67e..83e98d3fb18 100644
--- a/app/controllers/jwt_controller.rb
+++ b/app/controllers/jwt_controller.rb
@@ -6,7 +6,7 @@ class JwtController < ApplicationController
before_action :authenticate_project_or_user
SERVICES = {
- Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService
+ Auth::ContainerRegistryAuthenticationService::AUDIENCE => Auth::ContainerRegistryAuthenticationService,
}.freeze
def auth
@@ -38,30 +38,30 @@ class JwtController < ApplicationController
def render_missing_personal_access_token
render json: {
errors: [
- { code: 'UNAUTHORIZED',
- message: "HTTP Basic: Access denied\n" \
+ {code: "UNAUTHORIZED",
+ message: "HTTP Basic: Access denied\n" \
"You must use a personal access token with 'api' scope for Git over HTTP.\n" \
- "You can generate one at #{profile_personal_access_tokens_url}" }
- ]
+ "You can generate one at #{profile_personal_access_tokens_url}",},
+ ],
}, status: :unauthorized
end
def render_unauthorized
render json: {
errors: [
- { code: 'UNAUTHORIZED',
- message: 'HTTP Basic: Access denied' }
- ]
+ {code: "UNAUTHORIZED",
+ message: "HTTP Basic: Access denied",},
+ ],
}, status: :unauthorized
end
def auth_params
params.permit(:service, :account, :client_id)
- .merge(additional_params)
+ .merge(additional_params)
end
def additional_params
- { scopes: scopes_param }.compact
+ {scopes: scopes_param}.compact
end
# We have to parse scope here, because Docker Client does not send an array of scopes,
@@ -72,6 +72,6 @@ class JwtController < ApplicationController
def scopes_param
return unless params[:scope].present?
- Array(Rack::Utils.parse_query(request.query_string)['scope'])
+ Array(Rack::Utils.parse_query(request.query_string)["scope"])
end
end
diff --git a/app/controllers/ldap/omniauth_callbacks_controller.rb b/app/controllers/ldap/omniauth_callbacks_controller.rb
index 5e872804448..0f64c1cc242 100644
--- a/app/controllers/ldap/omniauth_callbacks_controller.rb
+++ b/app/controllers/ldap/omniauth_callbacks_controller.rb
@@ -7,7 +7,7 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
return unless Gitlab::Auth::LDAP::Config.enabled?
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
- alias_method server['provider_name'], :ldap
+ alias_method server["provider_name"], :ldap
end
end
@@ -26,7 +26,7 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController
override :fail_login
def fail_login(user)
- flash[:alert] = 'Access denied for your LDAP account.'
+ flash[:alert] = "Access denied for your LDAP account."
redirect_to new_user_session_path
end
diff --git a/app/controllers/metrics_controller.rb b/app/controllers/metrics_controller.rb
index c2089a0fca3..d39987615fd 100644
--- a/app/controllers/metrics_controller.rb
+++ b/app/controllers/metrics_controller.rb
@@ -7,15 +7,14 @@ class MetricsController < ActionController::Base
def index
response = if Gitlab::Metrics.prometheus_metrics_enabled?
- metrics_service.metrics_text
- else
- help_page = help_page_url('administration/monitoring/prometheus/gitlab_metrics',
- anchor: 'gitlab-prometheus-metrics'
- )
- "# Metrics are disabled, see: #{help_page}\n"
- end
+ metrics_service.metrics_text
+ else
+ help_page = help_page_url("administration/monitoring/prometheus/gitlab_metrics",
+ anchor: "gitlab-prometheus-metrics")
+ "# Metrics are disabled, see: #{help_page}\n"
+ end
- render plain: response, content_type: 'text/plain; version=0.0.4'
+ render plain: response, content_type: "text/plain; version=0.0.4"
end
private
diff --git a/app/controllers/notification_settings_controller.rb b/app/controllers/notification_settings_controller.rb
index 43c4f4d220e..2a2e8af35a7 100644
--- a/app/controllers/notification_settings_controller.rb
+++ b/app/controllers/notification_settings_controller.rb
@@ -17,7 +17,7 @@ class NotificationSettingsController < ApplicationController
@saved = @notification_setting.update(notification_setting_params_for(@notification_setting.source))
if params[:hide_label].present?
- btn_class = params[:project_id].present? ? 'btn-xs' : ''
+ btn_class = params[:project_id].present? ? "btn-xs" : ""
render_response("shared/notifications/_new_button", btn_class)
else
render_response
@@ -45,7 +45,7 @@ class NotificationSettingsController < ApplicationController
def render_response(response_template = "shared/notifications/_button", btn_class = nil)
render json: {
html: view_to_html_string(response_template, notification_setting: @notification_setting, btn_class: btn_class),
- saved: @saved
+ saved: @saved,
}
end
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
index ab4ca56bb49..91218dc5676 100644
--- a/app/controllers/oauth/applications_controller.rb
+++ b/app/controllers/oauth/applications_controller.rb
@@ -13,7 +13,7 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
helper_method :can?
- layout 'profile'
+ layout "profile"
def index
set_index_vars
diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb
index 705389749d8..dc0cb563458 100644
--- a/app/controllers/oauth/authorizations_controller.rb
+++ b/app/controllers/oauth/authorizations_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
- layout 'profile'
+ layout "profile"
# Overridden from Doorkeeper::AuthorizationsController to
# include the call to session.delete
diff --git a/app/controllers/oauth/authorized_applications_controller.rb b/app/controllers/oauth/authorized_applications_controller.rb
index a59ade559b3..801d3583360 100644
--- a/app/controllers/oauth/authorized_applications_controller.rb
+++ b/app/controllers/oauth/authorized_applications_controller.rb
@@ -3,7 +3,7 @@
class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicationsController
include PageLayoutHelper
- layout 'profile'
+ layout "profile"
def destroy
if params[:token_id].present?
@@ -13,7 +13,7 @@ class Oauth::AuthorizedApplicationsController < Doorkeeper::AuthorizedApplicatio
end
redirect_to applications_profile_url,
- status: 302,
- notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
+ status: 302,
+ notice: I18n.t(:notice, scope: [:doorkeeper, :flash, :authorized_applications, :destroy])
end
end
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index cc2bb99f55b..eda404acce7 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -34,7 +34,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
error ||= exception.message if exception.respond_to?(:message)
error ||= request.env["omniauth.error.type"].to_s
- error.to_s.humanize if error
+ error&.to_s&.humanize
end
def saml
@@ -44,28 +44,28 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
def omniauth_error
@provider = params[:provider]
@error = params[:error]
- render 'errors/omniauth_error', layout: "oauth_error", status: 422
+ render "errors/omniauth_error", layout: "oauth_error", status: 422
end
def cas3
- ticket = params['ticket']
+ ticket = params["ticket"]
if ticket
- handle_service_ticket oauth['provider'], ticket
+ handle_service_ticket oauth["provider"], ticket
end
handle_omniauth
end
def authentiq
- if params['sid']
- handle_service_ticket oauth['provider'], params['sid']
+ if params["sid"]
+ handle_service_ticket oauth["provider"], params["sid"]
end
handle_omniauth
end
def auth0
- if oauth['uid'].blank?
+ if oauth["uid"].blank?
fail_auth0_login
else
handle_omniauth
@@ -75,12 +75,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
def omniauth_flow(auth_module, identity_linker: nil)
- if fragment = request.env.dig('omniauth.params', 'redirect_fragment').presence
+ if fragment = request.env.dig("omniauth.params", "redirect_fragment").presence
store_redirect_fragment(fragment)
end
if current_user
- log_audit_event(current_user, with: oauth['provider'])
+ log_audit_event(current_user, with: oauth["provider"])
identity_linker ||= auth_module::IdentityLinker.new(current_user, oauth)
@@ -107,7 +107,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def redirect_identity_linked
- redirect_to profile_account_path, notice: 'Authentication method updated'
+ redirect_to profile_account_path, notice: "Authentication method updated"
end
def handle_service_ticket(provider, ticket)
@@ -125,7 +125,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
user = auth_user.find_and_update!
if auth_user.valid_sign_in?
- log_audit_event(user, with: oauth['provider'])
+ log_audit_event(user, with: oauth["provider"])
set_remember_me(user)
@@ -144,35 +144,35 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end
def handle_signup_error
- label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider'])
+ label = Gitlab::Auth::OAuth::Provider.label_for(oauth["provider"])
message = ["Signing in using your #{label} account without a pre-existing GitLab account is not allowed."]
if Gitlab::CurrentSettings.allow_signup?
message << "Create a GitLab account first, and then connect it to your #{label} account."
end
- flash[:notice] = message.join(' ')
+ flash[:notice] = message.join(" ")
redirect_to new_user_session_path
end
def oauth
- @oauth ||= request.env['omniauth.auth']
+ @oauth ||= request.env["omniauth.auth"]
end
def fail_login(user)
error_message = user.errors.full_messages.to_sentence
- return redirect_to omniauth_error_path(oauth['provider'], error: error_message)
+ redirect_to omniauth_error_path(oauth["provider"], error: error_message)
end
def fail_auth0_login
- flash[:alert] = 'Wrong extern UID provided. Make sure Auth0 is configured correctly.'
+ flash[:alert] = "Wrong extern UID provided. Make sure Auth0 is configured correctly."
redirect_to new_user_session_path
end
def handle_disabled_provider
- label = Gitlab::Auth::OAuth::Provider.label_for(oauth['provider'])
+ label = Gitlab::Auth::OAuth::Provider.label_for(oauth["provider"])
flash[:alert] = "Signing in using #{label} has been disabled"
redirect_to new_user_session_path
@@ -187,15 +187,15 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
return unless remember_me?
if user.two_factor_enabled?
- params[:remember_me] = '1'
+ params[:remember_me] = "1"
else
remember_me(user)
end
end
def remember_me?
- request_params = request.env['omniauth.params']
- (request_params['remember_me'] == '1') if request_params.present?
+ request_params = request.env["omniauth.params"]
+ (request_params["remember_me"] == "1") if request_params.present?
end
def store_redirect_fragment(redirect_fragment)
diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb
index 28f113b5cbe..924acca53ea 100644
--- a/app/controllers/passwords_controller.rb
+++ b/app/controllers/passwords_controller.rb
@@ -22,8 +22,8 @@ class PasswordsController < Devise::PasswordsController
).first_or_initialize
unless user.reset_password_period_valid?
- flash[:alert] = 'Your password reset token has expired.'
- redirect_to(new_user_password_url(user_email: user['email']))
+ flash[:alert] = "Your password reset token has expired."
+ redirect_to(new_user_password_url(user_email: user["email"]))
end
end
end
@@ -56,11 +56,11 @@ class PasswordsController < Devise::PasswordsController
end
def throttle_reset
- return unless resource && resource.recently_sent_password_reset?
+ return unless resource&.recently_sent_password_reset?
# Throttle reset attempts, but return a normal message to
# avoid user enumeration attack.
redirect_to new_user_session_path,
- notice: I18n.t('devise.passwords.send_paranoid_instructions')
+ notice: I18n.t("devise.passwords.send_paranoid_instructions")
end
end
diff --git a/app/controllers/profiles/application_controller.rb b/app/controllers/profiles/application_controller.rb
index 52b046ef64f..6d8aecd75f3 100644
--- a/app/controllers/profiles/application_controller.rb
+++ b/app/controllers/profiles/application_controller.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class Profiles::ApplicationController < ApplicationController
- layout 'profile'
+ layout "profile"
end
diff --git a/app/controllers/profiles/keys_controller.rb b/app/controllers/profiles/keys_controller.rb
index 055d900eece..927514a6727 100644
--- a/app/controllers/profiles/keys_controller.rb
+++ b/app/controllers/profiles/keys_controller.rb
@@ -48,7 +48,7 @@ class Profiles::KeysController < Profiles::ApplicationController
render html: e.message
end
else
- return render_404
+ render_404
end
end
diff --git a/app/controllers/profiles/passwords_controller.rb b/app/controllers/profiles/passwords_controller.rb
index a0391d677c4..318c1cfc66b 100644
--- a/app/controllers/profiles/passwords_controller.rb
+++ b/app/controllers/profiles/passwords_controller.rb
@@ -14,14 +14,14 @@ class Profiles::PasswordsController < Profiles::ApplicationController
def create
unless @user.password_automatically_set || @user.valid_password?(user_params[:current_password])
- redirect_to new_profile_password_path, alert: 'You must provide a valid current password'
+ redirect_to new_profile_password_path, alert: "You must provide a valid current password"
return
end
password_attributes = {
password: user_params[:password],
password_confirmation: user_params[:password_confirmation],
- password_automatically_set: false
+ password_automatically_set: false,
}
result = Users::UpdateService.new(current_user, password_attributes.merge(user: @user)).execute
@@ -29,7 +29,7 @@ class Profiles::PasswordsController < Profiles::ApplicationController
if result[:status] == :success
Users::UpdateService.new(current_user, user: @user, password_expires_at: nil).execute
- redirect_to root_path, notice: 'Password successfully changed'
+ redirect_to root_path, notice: "Password successfully changed"
else
render :new
end
@@ -39,13 +39,13 @@ class Profiles::PasswordsController < Profiles::ApplicationController
end
def update
- password_attributes = user_params.select do |key, value|
- %w(password password_confirmation).include?(key.to_s)
- end
+ password_attributes = user_params.select { |key, value|
+ %w[password password_confirmation].include?(key.to_s)
+ }
password_attributes[:password_automatically_set] = false
unless @user.password_automatically_set || @user.valid_password?(user_params[:current_password])
- redirect_to edit_profile_password_path, alert: 'You must provide a valid current password'
+ redirect_to edit_profile_password_path, alert: "You must provide a valid current password"
return
end
@@ -56,13 +56,13 @@ class Profiles::PasswordsController < Profiles::ApplicationController
redirect_to new_user_session_path
else
@user.reload
- render 'edit'
+ render "edit"
end
end
def reset
current_user.send_reset_password_instructions
- redirect_to edit_profile_password_path, notice: 'We sent you an email with reset password instructions'
+ redirect_to edit_profile_password_path, notice: "We sent you an email with reset password instructions"
end
private
@@ -73,9 +73,9 @@ class Profiles::PasswordsController < Profiles::ApplicationController
def determine_layout
if [:new, :create].include?(action_name.to_sym)
- 'application'
+ "application"
else
- 'profile'
+ "profile"
end
end
diff --git a/app/controllers/profiles/personal_access_tokens_controller.rb b/app/controllers/profiles/personal_access_tokens_controller.rb
index 4b6ec2697b7..c516a7f74b7 100644
--- a/app/controllers/profiles/personal_access_tokens_controller.rb
+++ b/app/controllers/profiles/personal_access_tokens_controller.rb
@@ -33,7 +33,7 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
private
def finder(options = {})
- PersonalAccessTokensFinder.new({ user: current_user, impersonation: false }.merge(options))
+ PersonalAccessTokensFinder.new({user: current_user, impersonation: false}.merge(options))
end
def personal_access_token_params
@@ -44,8 +44,8 @@ class Profiles::PersonalAccessTokensController < Profiles::ApplicationController
def set_index_vars
@scopes = Gitlab::Auth.available_scopes(current_user)
- @inactive_personal_access_tokens = finder(state: 'inactive').execute
- @active_personal_access_tokens = finder(state: 'active').execute.order(:expires_at)
+ @inactive_personal_access_tokens = finder(state: "inactive").execute
+ @active_personal_access_tokens = finder(state: "active").execute.order(:expires_at)
@new_personal_access_token = PersonalAccessToken.redis_getdel(current_user.id)
end
diff --git a/app/controllers/profiles/preferences_controller.rb b/app/controllers/profiles/preferences_controller.rb
index 0227af2c266..80679ac168d 100644
--- a/app/controllers/profiles/preferences_controller.rb
+++ b/app/controllers/profiles/preferences_controller.rb
@@ -11,9 +11,9 @@ class Profiles::PreferencesController < Profiles::ApplicationController
result = Users::UpdateService.new(current_user, preferences_params.merge(user: user)).execute
if result[:status] == :success
- flash[:notice] = 'Preferences saved.'
+ flash[:notice] = "Preferences saved."
else
- flash[:alert] = 'Failed to save preferences.'
+ flash[:alert] = "Failed to save preferences."
end
rescue ArgumentError => e
# Raised when `dashboard` is given an invalid value.
@@ -44,7 +44,7 @@ class Profiles::PreferencesController < Profiles::ApplicationController
:project_view,
:theme_id,
:first_day_of_week,
- :preferred_language
+ :preferred_language,
]
end
end
diff --git a/app/controllers/profiles/two_factor_auths_controller.rb b/app/controllers/profiles/two_factor_auths_controller.rb
index ba94196b2f9..49772d6c2a4 100644
--- a/app/controllers/profiles/two_factor_auths_controller.rb
+++ b/app/controllers/profiles/two_factor_auths_controller.rb
@@ -18,15 +18,15 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
two_factor_authentication_reason(
global: lambda do
flash.now[:alert] =
- 'The global settings require you to enable Two-Factor Authentication for your account.'
+ "The global settings require you to enable Two-Factor Authentication for your account."
end,
group: lambda do |groups|
group_links = groups.map { |group| view_context.link_to group.full_name, group_path(group) }.to_sentence
- flash.now[:alert] = %{
+ flash.now[:alert] = %(
The group settings for #{group_links} require you to enable
Two-Factor Authentication for your account.
- }.html_safe
+ ).html_safe
end
)
@@ -47,12 +47,12 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
@codes = user.generate_otp_backup_codes!
end
- render 'create'
+ render "create"
else
- @error = 'Invalid pin code'
+ @error = "Invalid pin code"
@qr_code = build_qr_code
setup_u2f_registration
- render 'show'
+ render "show"
end
end
@@ -85,7 +85,7 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
def skip
if two_factor_grace_period_expired?
- redirect_to new_profile_two_factor_auth_path, alert: 'Cannot skip two factor authentication setup'
+ redirect_to new_profile_two_factor_auth_path, alert: "Cannot skip two factor authentication setup"
else
session[:skip_two_factor] = current_user.otp_grace_period_started_at + two_factor_grace_period.hours
redirect_to root_path
@@ -118,9 +118,9 @@ class Profiles::TwoFactorAuthsController < Profiles::ApplicationController
sign_requests = u2f.authentication_requests(@u2f_registrations.map(&:key_handle))
session[:challenges] = registration_requests.map(&:challenge)
- gon.push(u2f: { challenges: session[:challenges], app_id: u2f_app_id,
- register_requests: registration_requests,
- sign_requests: sign_requests })
+ gon.push(u2f: {challenges: session[:challenges], app_id: u2f_app_id,
+ register_requests: registration_requests,
+ sign_requests: sign_requests,})
end
def u2f_registration_params
diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb
index b9c52618d4b..d112fe6aef0 100644
--- a/app/controllers/profiles_controller.rb
+++ b/app/controllers/profiles_controller.rb
@@ -17,10 +17,10 @@ class ProfilesController < Profiles::ApplicationController
if result[:status] == :success
message = "Profile was successfully updated"
- format.html { redirect_back_or_default(default: { action: 'show' }, options: { notice: message }) }
- format.json { render json: { message: message } }
+ format.html { redirect_back_or_default(default: {action: "show"}, options: {notice: message}) }
+ format.json { render json: {message: message} }
else
- format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: result[:message] }) }
+ format.html { redirect_back_or_default(default: {action: "show"}, options: {alert: result[:message]}) }
format.json { render json: result }
end
end
@@ -41,7 +41,7 @@ class ProfilesController < Profiles::ApplicationController
user.reset_feed_token!
end
- flash[:notice] = 'Feed token was successfully reset'
+ flash[:notice] = "Feed token was successfully reset"
redirect_to profile_personal_access_tokens_path
end
@@ -61,13 +61,13 @@ class ProfilesController < Profiles::ApplicationController
if result[:status] == :success
message = s_("Profiles|Username successfully changed")
- format.html { redirect_back_or_default(default: { action: 'show' }, options: { notice: message }) }
- format.json { render json: { message: message }, status: :ok }
+ format.html { redirect_back_or_default(default: {action: "show"}, options: {notice: message}) }
+ format.json { render json: {message: message}, status: :ok }
else
- message = s_("Profiles|Username change failed - %{message}") % { message: result[:message] }
+ message = s_("Profiles|Username change failed - %{message}") % {message: result[:message]}
- format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: message }) }
- format.json { render json: { message: message }, status: :unprocessable_entity }
+ format.html { redirect_back_or_default(default: {action: "show"}, options: {alert: message}) }
+ format.json { render json: {message: message}, status: :unprocessable_entity }
end
end
end
diff --git a/app/controllers/projects/application_controller.rb b/app/controllers/projects/application_controller.rb
index e0677ce3fbc..87484068eeb 100644
--- a/app/controllers/projects/application_controller.rb
+++ b/app/controllers/projects/application_controller.rb
@@ -9,7 +9,7 @@ class Projects::ApplicationController < ApplicationController
skip_before_action :authenticate_user!
before_action :project
before_action :repository
- layout 'project'
+ layout "project"
helper_method :repository, :can_collaborate_with_project?, :user_access
@@ -38,7 +38,7 @@ class Projects::ApplicationController < ApplicationController
def authorize_action!(action)
unless can?(current_user, action, project)
- return access_denied!
+ access_denied!
end
end
@@ -48,7 +48,7 @@ class Projects::ApplicationController < ApplicationController
def check_issuables_available!
render_404 unless project.feature_available?(:issues, current_user) ||
- project.feature_available?(:merge_requests, current_user)
+ project.feature_available?(:merge_requests, current_user)
end
def method_missing(method_sym, *arguments, &block)
diff --git a/app/controllers/projects/artifacts_controller.rb b/app/controllers/projects/artifacts_controller.rb
index 2ef18d900f2..2f7025d44fc 100644
--- a/app/controllers/projects/artifacts_controller.rb
+++ b/app/controllers/projects/artifacts_controller.rb
@@ -5,7 +5,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
include RendersBlob
include SendFileUpload
- layout 'project'
+ layout "project"
before_action :authorize_read_build!
before_action :authorize_update_build!, only: [:keep]
before_action :extract_ref_name_and_path
@@ -20,7 +20,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
def browse
@path = params[:path]
- directory = @path ? "#{@path}/" : ''
+ directory = @path ? "#{@path}/" : ""
@entry = build.artifacts_metadata_entry(directory)
render_404 unless @entry.exists?
@@ -35,7 +35,7 @@ class Projects::ArtifactsController < Projects::ApplicationController
else
respond_to do |format|
format.html do
- render 'file'
+ render "file"
end
format.json do
diff --git a/app/controllers/projects/avatars_controller.rb b/app/controllers/projects/avatars_controller.rb
index 1f4a25f82e9..e490cb64a73 100644
--- a/app/controllers/projects/avatars_controller.rb
+++ b/app/controllers/projects/avatars_controller.rb
@@ -15,6 +15,6 @@ class Projects::AvatarsController < Projects::ApplicationController
@project.remove_avatar!
@project.save
- redirect_to edit_project_path(@project, anchor: 'js-general-project-settings'), status: :found
+ redirect_to edit_project_path(@project, anchor: "js-general-project-settings"), status: :found
end
end
diff --git a/app/controllers/projects/badges_controller.rb b/app/controllers/projects/badges_controller.rb
index 09a384e89ab..d8630114070 100644
--- a/app/controllers/projects/badges_controller.rb
+++ b/app/controllers/projects/badges_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Projects::BadgesController < Projects::ApplicationController
- layout 'project_settings'
+ layout "project_settings"
before_action :authorize_admin_project!, only: [:index]
before_action :no_cache_headers, except: [:index]
@@ -23,12 +23,12 @@ class Projects::BadgesController < Projects::ApplicationController
def badge_layout
case params[:style]
- when 'flat'
- 'badge'
- when 'flat-square'
- 'badge_flat-square'
+ when "flat"
+ "badge"
+ when "flat-square"
+ "badge_flat-square"
else
- 'badge'
+ "badge"
end
end
@@ -36,7 +36,7 @@ class Projects::BadgesController < Projects::ApplicationController
respond_to do |format|
format.html { render_404 }
format.svg do
- render badge_layout, locals: { badge: badge.template }
+ render badge_layout, locals: {badge: badge.template}
end
end
end
diff --git a/app/controllers/projects/blame_controller.rb b/app/controllers/projects/blame_controller.rb
index 9076bdb9f04..c0836f8ae85 100644
--- a/app/controllers/projects/blame_controller.rb
+++ b/app/controllers/projects/blame_controller.rb
@@ -13,7 +13,7 @@ class Projects::BlameController < Projects::ApplicationController
return render_404 unless @blob
- environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
+ environment_params = @repository.branch_exists?(@ref) ? {ref: @ref} : {commit: @commit}
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@blame_groups = Gitlab::Blame.new(@blob, @commit).groups
diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb
index 77672e7d9fc..0fc343336cc 100644
--- a/app/controllers/projects/blob_controller.rb
+++ b/app/controllers/projects/blob_controller.rb
@@ -55,7 +55,7 @@ class Projects::BlobController < Projects::ApplicationController
if can_collaborate_with_project?(project, ref: @ref)
blob.load_all_data!
else
- redirect_to action: 'show'
+ redirect_to action: "show"
end
end
@@ -72,7 +72,7 @@ class Projects::BlobController < Projects::ApplicationController
def preview
@content = params[:content]
@blob.load_all_data!
- diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true)
+ diffy = Diffy::Diff.new(@blob.data, @content, diff: "-U 3", include_diff_info: true)
diff_lines = diffy.diff.scan(/.*\n/)[2..-1]
diff_lines = Gitlab::Diff::Parser.new.parse(diff_lines)
@diff_lines = Gitlab::Diff::Highlight.new(diff_lines, repository: @repository).highlight
@@ -98,10 +98,10 @@ class Projects::BlobController < Projects::ApplicationController
@lines = @lines[@form.since - 1..@form.to - 1].map(&:html_safe)
if @form.bottom?
- @match_line = ''
+ @match_line = ""
else
lines_length = @lines.length - 1
- line = [@form.since, lines_length].join(',')
+ line = [@form.since, lines_length].join(",")
@match_line = "@@ -#{line}+#{line} @@"
end
@@ -144,7 +144,7 @@ class Projects::BlobController < Projects::ApplicationController
# Match line is not needed when it reaches the top limit or bottom limit of the file.
return unless new_pos
- @match_line = Gitlab::Diff::Line.new(@match_line, 'match', nil, old_pos, new_pos)
+ @match_line = Gitlab::Diff::Line.new(@match_line, "match", nil, old_pos, new_pos)
@form.bottom? ? @lines.push(@match_line) : @lines.unshift(@match_line)
end
@@ -203,7 +203,7 @@ class Projects::BlobController < Projects::ApplicationController
@branch_name = params[:branch_name]
@file_path =
- if action_name.to_s == 'create'
+ if action_name.to_s == "create"
if params[:file].present?
params[:file_name] = params[:file].original_filename
end
@@ -217,7 +217,7 @@ class Projects::BlobController < Projects::ApplicationController
if params[:file].present?
params[:content] = Base64.encode64(params[:file].read)
- params[:encoding] = 'base64'
+ params[:encoding] = "base64"
end
@commit_params = {
@@ -226,7 +226,7 @@ class Projects::BlobController < Projects::ApplicationController
previous_path: @path,
file_content: params[:content],
file_content_encoding: params[:encoding],
- last_commit_sha: params[:last_commit_sha]
+ last_commit_sha: params[:last_commit_sha],
}
end
@@ -242,11 +242,11 @@ class Projects::BlobController < Projects::ApplicationController
end
def show_html
- environment_params = @repository.branch_exists?(@ref) ? { ref: @ref } : { commit: @commit }
+ environment_params = @repository.branch_exists?(@ref) ? {ref: @ref} : {commit: @commit}
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
@last_commit = @repository.last_commit_for_path(@commit.id, @blob.path)
- render 'show'
+ render "show"
end
def show_json
@@ -269,15 +269,15 @@ class Projects::BlobController < Projects::ApplicationController
blame_path: project_blame_path(project, @id),
commits_path: project_commits_path(project, @id),
tree_path: project_tree_path(project, File.join(@ref, tree_path)),
- permalink: project_blob_path(project, File.join(@commit.id, @path))
+ permalink: project_blob_path(project, File.join(@commit.id, @path)),
}
- json.merge!(blob_json(@blob) || {}) unless params[:viewer] == 'none'
+ json.merge!(blob_json(@blob) || {}) unless params[:viewer] == "none"
render json: json
end
def tree_path
- @path.rpartition('/').first
+ @path.rpartition("/").first
end
end
diff --git a/app/controllers/projects/branches_controller.rb b/app/controllers/projects/branches_controller.rb
index 32b7f3207ef..00c7fd9d000 100644
--- a/app/controllers/projects/branches_controller.rb
+++ b/app/controllers/projects/branches_controller.rb
@@ -16,7 +16,7 @@ class Projects::BranchesController < Projects::ApplicationController
respond_to do |format|
format.html do
@sort = params[:sort].presence || sort_value_recently_updated
- @mode = params[:state].presence || 'overview'
+ @mode = params[:state].presence || "overview"
@overview_max_branches = 5
# Fetch branches for the specified mode
@@ -27,11 +27,11 @@ class Projects::BranchesController < Projects::ApplicationController
# n+1: https://gitlab.com/gitlab-org/gitaly/issues/992
Gitlab::GitalyClient.allow_n_plus_1_calls do
- @max_commits = @branches.reduce(0) do |memo, branch|
+ @max_commits = @branches.reduce(0) { |memo, branch|
diverging_commit_counts = repository.diverging_commit_counts(branch)
[memo, diverging_commit_counts.values_at(:behind, :ahead, :distance)]
.flatten.compact.max
- end
+ }
end
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48097
@@ -59,7 +59,7 @@ class Projects::BranchesController < Projects::ApplicationController
redirect_to_autodeploy = project.empty_repo? && project.deployment_platform.present?
result = CreateBranchService.new(project, current_user)
- .execute(branch_name, ref)
+ .execute(branch_name, ref)
success = (result[:status] == :success)
@@ -79,13 +79,13 @@ class Projects::BranchesController < Projects::ApplicationController
end
else
@error = result[:message]
- render action: 'new'
+ render action: "new"
end
end
format.json do
if success
- render json: { name: branch_name, url: project_tree_url(@project, branch_name) }
+ render json: {name: branch_name, url: project_tree_url(@project, branch_name)}
else
render json: result[:messsage], status: :unprocessable_entity
end
@@ -107,7 +107,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
format.js { head result[:return_code] }
- format.json { render json: { message: result[:message] }, status: result[:return_code] }
+ format.json { render json: {message: result[:message]}, status: result[:return_code] }
end
end
@@ -115,7 +115,7 @@ class Projects::BranchesController < Projects::ApplicationController
DeleteMergedBranchesService.new(@project, current_user).async_execute
redirect_to project_branches_path(@project),
- notice: 'Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.'
+ notice: "Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes."
end
private
@@ -125,7 +125,7 @@ class Projects::BranchesController < Projects::ApplicationController
ref_escaped = sanitize(strip_tags(params[:ref]))
Addressable::URI.unescape(ref_escaped)
else
- @project.default_branch || 'master'
+ @project.default_branch || "master"
end
end
@@ -133,22 +133,22 @@ class Projects::BranchesController < Projects::ApplicationController
project_new_blob_path(
project,
branch_name,
- file_name: '.gitlab-ci.yml',
- commit_message: 'Set up auto deploy',
+ file_name: ".gitlab-ci.yml",
+ commit_message: "Set up auto deploy",
target_branch: branch_name,
- context: 'autodeploy'
+ context: "autodeploy"
)
end
def redirect_for_legacy_index_sort_or_search
# Normalize a legacy URL with redirect
if request.format != :json && !params[:state].presence && [:sort, :search, :page].any? { |key| params[key].presence }
- redirect_to project_branches_filtered_path(@project, state: 'all'), notice: 'Update your bookmarked URLs as filtered/sorted branches URL has been changed.'
+ redirect_to project_branches_filtered_path(@project, state: "all"), notice: "Update your bookmarked URLs as filtered/sorted branches URL has been changed."
end
end
def fetch_branches_by_mode
- if @mode == 'overview'
+ if @mode == "overview"
# overview mode
@active_branches, @stale_branches = BranchesFinder.new(@repository, sort: sort_value_recently_updated).execute.partition(&:active?)
# Here we get one more branch to indicate if there are more data we're not showing
diff --git a/app/controllers/projects/build_artifacts_controller.rb b/app/controllers/projects/build_artifacts_controller.rb
index 4274c356227..7c1b98930f8 100644
--- a/app/controllers/projects/build_artifacts_controller.rb
+++ b/app/controllers/projects/build_artifacts_controller.rb
@@ -31,7 +31,7 @@ class Projects::BuildArtifactsController < Projects::ApplicationController
private
def validate_artifacts!
- render_404 unless job && job.artifacts?
+ render_404 unless job&.artifacts?
end
def extract_ref_name_and_path
diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb
index d7a0b7ece14..1a5841ea13a 100644
--- a/app/controllers/projects/ci/lints_controller.rb
+++ b/app/controllers/projects/ci/lints_controller.rb
@@ -27,7 +27,7 @@ class Projects::Ci::LintsController < Projects::ApplicationController
{
project: @project,
user: current_user,
- sha: project.repository.commit.sha
+ sha: project.repository.commit.sha,
}
end
end
diff --git a/app/controllers/projects/clusters_controller.rb b/app/controllers/projects/clusters_controller.rb
index feda6deeaa6..b0d779a596c 100644
--- a/app/controllers/projects/clusters_controller.rb
+++ b/app/controllers/projects/clusters_controller.rb
@@ -6,7 +6,7 @@ class Projects::ClustersController < Clusters::ClustersController
prepend_before_action :project
before_action :repository
- layout 'project'
+ layout "project"
private
diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb
index b13c0ae3967..59a0f43622c 100644
--- a/app/controllers/projects/commit_controller.rb
+++ b/app/controllers/projects/commit_controller.rb
@@ -56,8 +56,8 @@ class Projects::CommitController < Projects::ApplicationController
.with_pagination(request, response)
.represent(@pipelines),
count: {
- all: @pipelines.count
- }
+ all: @pipelines.count,
+ },
}
end
end
@@ -65,9 +65,9 @@ class Projects::CommitController < Projects::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
def merge_requests
- @merge_requests = @commit.merge_requests.map do |mr|
- { iid: mr.iid, path: merge_request_path(mr), title: mr.title }
- end
+ @merge_requests = @commit.merge_requests.map { |mr|
+ {iid: mr.iid, path: merge_request_path(mr), title: mr.title}
+ }
respond_to do |format|
format.json do
@@ -141,7 +141,7 @@ class Projects::CommitController < Projects::ApplicationController
return git_not_found! unless commit
opts = diff_options
- opts[:ignore_whitespace_change] = true if params[:format] == 'diff'
+ opts[:ignore_whitespace_change] = true if params[:format] == "diff"
@diffs = commit.diffs(opts)
@notes_count = commit.notes.count
@@ -155,8 +155,8 @@ class Projects::CommitController < Projects::ApplicationController
@note = @project.build_commit_note(commit)
@new_diff_note_attrs = {
- noteable_type: 'Commit',
- commit_id: @commit.id
+ noteable_type: "Commit",
+ commit_id: @commit.id,
}
@grouped_diff_discussions = commit.grouped_diff_discussions
@@ -166,10 +166,8 @@ class Projects::CommitController < Projects::ApplicationController
@merge_request = MergeRequestsFinder.new(current_user, project_id: @project.id).find_by(iid: merge_request_iid)
if @merge_request
- @new_diff_note_attrs.merge!(
- noteable_type: 'MergeRequest',
- noteable_id: @merge_request.id
- )
+ @new_diff_note_attrs[:noteable_type] = "MergeRequest"
+ @new_diff_note_attrs[:noteable_id] = @merge_request.id
merge_request_commit_notes = @merge_request.notes.where(commit_id: @commit.id).inc_relations_for_view
merge_request_commit_diff_discussions = merge_request_commit_notes.grouped_diff_discussions(@commit.diff_refs)
@@ -186,6 +184,6 @@ class Projects::CommitController < Projects::ApplicationController
def assign_change_commit_vars
@start_branch = params[:start_branch]
- @commit_params = { commit: @commit }
+ @commit_params = {commit: @commit}
end
end
diff --git a/app/controllers/projects/commits_controller.rb b/app/controllers/projects/commits_controller.rb
index 2510a31c9b3..62fa9b7c31e 100644
--- a/app/controllers/projects/commits_controller.rb
+++ b/app/controllers/projects/commits_controller.rb
@@ -25,14 +25,15 @@ class Projects::CommitsController < Projects::ApplicationController
respond_to do |format|
format.html
- format.atom { render layout: 'xml.atom' }
+ format.atom { render layout: "xml.atom" }
format.json do
pager_json(
- 'projects/commits/_commits',
+ "projects/commits/_commits",
@commits.size,
project: @project,
- ref: @ref)
+ ref: @ref
+ )
end
end
end
@@ -45,9 +46,9 @@ class Projects::CommitsController < Projects::ApplicationController
signatures: @commits.select(&:has_signature?).map do |commit|
{
commit_sha: commit.sha,
- html: view_to_html_string('projects/commit/_signature', signature: commit.signature)
+ html: view_to_html_string("projects/commit/_signature", signature: commit.signature),
}
- end
+ end,
}
end
end
@@ -76,6 +77,6 @@ class Projects::CommitsController < Projects::ApplicationController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42330')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42330")
end
end
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index 5586c2fc631..92a3a276d63 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'addressable/uri'
+require "addressable/uri"
class Projects::CompareController < Projects::ApplicationController
include DiffForPath
@@ -39,12 +39,12 @@ class Projects::CompareController < Projects::ApplicationController
flash[:alert] = "You must select a Source and a Target revision"
from_to_vars = {
from: params[:from].presence,
- to: params[:to].presence
+ to: params[:to].presence,
}
redirect_to project_compare_index_path(@project, from_to_vars)
else
redirect_to project_compare_path(@project,
- params[:from], params[:to])
+ params[:from], params[:to])
end
end
@@ -55,9 +55,9 @@ class Projects::CompareController < Projects::ApplicationController
signatures: @commits.select(&:has_signature?).map do |commit|
{
commit_sha: commit.sha,
- html: view_to_html_string('projects/commit/_signature', signature: commit.signature)
+ html: view_to_html_string("projects/commit/_signature", signature: commit.signature),
}
- end
+ end,
}
end
end
@@ -100,7 +100,7 @@ class Projects::CompareController < Projects::ApplicationController
def define_environment
if compare
- environment_params = @repository.branch_exists?(head_ref) ? { ref: head_ref } : { commit: compare.commit }
+ environment_params = @repository.branch_exists?(head_ref) ? {ref: head_ref} : {commit: compare.commit}
@environment = EnvironmentsFinder.new(@project, current_user, environment_params).execute.last
end
end
diff --git a/app/controllers/projects/cycle_analytics/events_controller.rb b/app/controllers/projects/cycle_analytics/events_controller.rb
index fb43356ff10..47eebc34595 100644
--- a/app/controllers/projects/cycle_analytics/events_controller.rb
+++ b/app/controllers/projects/cycle_analytics/events_controller.rb
@@ -45,7 +45,7 @@ module Projects
def render_events(events)
respond_to do |format|
format.html
- format.json { render json: { events: events } }
+ format.json { render json: {events: events} }
end
end
diff --git a/app/controllers/projects/cycle_analytics_controller.rb b/app/controllers/projects/cycle_analytics_controller.rb
index 8c071496ba9..fc2afc74bf8 100644
--- a/app/controllers/projects/cycle_analytics_controller.rb
+++ b/app/controllers/projects/cycle_analytics_controller.rb
@@ -31,11 +31,11 @@ class Projects::CycleAnalyticsController < Projects::ApplicationController
{
summary: @cycle_analytics.summary,
stats: @cycle_analytics.stats,
- permissions: @cycle_analytics.permissions(user: current_user)
+ permissions: @cycle_analytics.permissions(user: current_user),
}
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42671')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42671")
end
end
diff --git a/app/controllers/projects/deploy_keys_controller.rb b/app/controllers/projects/deploy_keys_controller.rb
index 6824a07dc76..a087eef2617 100644
--- a/app/controllers/projects/deploy_keys_controller.rb
+++ b/app/controllers/projects/deploy_keys_controller.rb
@@ -8,11 +8,11 @@ class Projects::DeployKeysController < Projects::ApplicationController
before_action :authorize_admin_project!
before_action :authorize_update_deploy_key!, only: [:edit, :update]
- layout 'project_settings'
+ layout "project_settings"
def index
respond_to do |format|
- format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
+ format.html { redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings") }
format.json do
render json: Projects::Settings::DeployKeysPresenter.new(@project, current_user: current_user).as_json
end
@@ -20,17 +20,17 @@ class Projects::DeployKeysController < Projects::ApplicationController
end
def new
- redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
+ redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings")
end
def create
@key = DeployKeys::CreateService.new(current_user, create_params).execute(project: @project)
unless @key.valid?
- flash[:alert] = @key.errors.full_messages.join(', ').html_safe
+ flash[:alert] = @key.errors.full_messages.join(", ").html_safe
end
- redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
+ redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings")
end
def edit
@@ -38,10 +38,10 @@ class Projects::DeployKeysController < Projects::ApplicationController
def update
if deploy_key.update(update_params)
- flash[:notice] = 'Deploy key was successfully updated.'
- redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings')
+ flash[:notice] = "Deploy key was successfully updated."
+ redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings")
else
- render 'edit'
+ render "edit"
end
end
@@ -51,7 +51,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
return render_404 unless key
respond_to do |format|
- format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
+ format.html { redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings") }
format.json { head :ok }
end
end
@@ -62,7 +62,7 @@ class Projects::DeployKeysController < Projects::ApplicationController
return render_404 unless deploy_key_project
respond_to do |format|
- format.html { redirect_to_repository_settings(@project, anchor: 'js-deploy-keys-settings') }
+ format.html { redirect_to_repository_settings(@project, anchor: "js-deploy-keys-settings") }
format.json { head :ok }
end
end
@@ -75,8 +75,8 @@ class Projects::DeployKeysController < Projects::ApplicationController
def create_params
create_params = params.require(:deploy_key)
- .permit(:key, :title, deploy_keys_projects_attributes: [:can_push])
- create_params.dig(:deploy_keys_projects_attributes, '0')&.merge!(project_id: @project.id)
+ .permit(:key, :title, deploy_keys_projects_attributes: [:can_push])
+ create_params.dig(:deploy_keys_projects_attributes, "0")&.merge!(project_id: @project.id)
create_params
end
diff --git a/app/controllers/projects/deploy_tokens_controller.rb b/app/controllers/projects/deploy_tokens_controller.rb
index 830b1f4fe4a..eed3fe216a9 100644
--- a/app/controllers/projects/deploy_tokens_controller.rb
+++ b/app/controllers/projects/deploy_tokens_controller.rb
@@ -7,6 +7,6 @@ class Projects::DeployTokensController < Projects::ApplicationController
@token = @project.deploy_tokens.find(params[:id])
@token.revoke!
- redirect_to project_settings_repository_path(project, anchor: 'js-deploy-tokens')
+ redirect_to project_settings_repository_path(project, anchor: "js-deploy-tokens")
end
end
diff --git a/app/controllers/projects/deployments_controller.rb b/app/controllers/projects/deployments_controller.rb
index 0a009477d61..9854212ddf5 100644
--- a/app/controllers/projects/deployments_controller.rb
+++ b/app/controllers/projects/deployments_controller.rb
@@ -7,10 +7,10 @@ class Projects::DeploymentsController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
deployments = environment.deployments.reorder(created_at: :desc)
- deployments = deployments.where('created_at > ?', params[:after].to_time) if params[:after]&.to_time
+ deployments = deployments.where("created_at > ?", params[:after].to_time) if params[:after]&.to_time
- render json: { deployments: DeploymentSerializer.new(project: project)
- .represent_concise(deployments) }
+ render json: {deployments: DeploymentSerializer.new(project: project)
+ .represent_concise(deployments)}
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/controllers/projects/discussions_controller.rb b/app/controllers/projects/discussions_controller.rb
index 028390c7e2a..eae96f4d9d7 100644
--- a/app/controllers/projects/discussions_controller.rb
+++ b/app/controllers/projects/discussions_controller.rb
@@ -23,7 +23,7 @@ class Projects::DiscussionsController < Projects::ApplicationController
def show
render json: {
- truncated_diff_lines: discussion.try(:truncated_diff_lines)
+ truncated_diff_lines: discussion.try(:truncated_diff_lines),
}
end
@@ -41,14 +41,14 @@ class Projects::DiscussionsController < Projects::ApplicationController
def render_json_with_discussions_serializer
render json:
DiscussionSerializer.new(project: project, noteable: discussion.noteable, current_user: current_user, note_entity: ProjectNoteEntity)
- .represent(discussion, context: self, render_truncated_diff_lines: true)
+ .represent(discussion, context: self, render_truncated_diff_lines: true)
end
# Legacy method used to render discussions notes when not using Vue on views.
def render_json_with_html
render json: {
resolved_by: discussion.resolved_by.try(:name),
- discussion_headline_html: view_to_html_string('discussions/_headline', discussion: discussion)
+ discussion_headline_html: view_to_html_string("discussions/_headline", discussion: discussion),
}
end
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index e9cd475a199..9263fc6789c 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Projects::EnvironmentsController < Projects::ApplicationController
- layout 'project'
+ layout "project"
before_action :authorize_read_environment!
before_action :authorize_create_environment!, only: [:new, :create]
before_action :authorize_stop_environment!, only: [:stop]
@@ -23,7 +23,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
render json: {
environments: serialize_environments(request, response, params[:nested]),
available_count: project.environments.available.count,
- stopped_count: project.environments.stopped.count
+ stopped_count: project.environments.stopped.count,
}
end
end
@@ -43,7 +43,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
render json: {
environments: serialize_environments(request, response),
available_count: folder_environments.available.count,
- stopped_count: folder_environments.stopped.count
+ stopped_count: folder_environments.stopped.count,
}
end
end
@@ -95,7 +95,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
respond_to do |format|
format.html { redirect_to action_or_env_url }
- format.json { render json: { redirect_url: action_or_env_url } }
+ format.json { render json: {redirect_url: action_or_env_url} }
end
end
@@ -116,7 +116,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
set_workhorse_internal_api_content_type
render json: Gitlab::Workhorse.terminal_websocket(terminal)
else
- render html: 'Not found', status: :not_found
+ render html: "Not found", status: :not_found
end
end
diff --git a/app/controllers/projects/error_tracking_controller.rb b/app/controllers/projects/error_tracking_controller.rb
index 88d0755f41f..b84bf09518b 100644
--- a/app/controllers/projects/error_tracking_controller.rb
+++ b/app/controllers/projects/error_tracking_controller.rb
@@ -30,13 +30,13 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
result = service.execute
unless result[:status] == :success
- return render json: { message: result[:message] },
+ return render json: {message: result[:message]},
status: result[:http_status] || :bad_request
end
render json: {
errors: serialize_errors(result[:issues]),
- external_url: service.external_url
+ external_url: service.external_url,
}
end
@@ -50,13 +50,13 @@ class Projects::ErrorTrackingController < Projects::ApplicationController
if result[:status] == :success
render json: {
- projects: serialize_projects(result[:projects])
+ projects: serialize_projects(result[:projects]),
}
else
return render(
status: result[:http_status] || :bad_request,
json: {
- message: result[:message]
+ message: result[:message],
}
)
end
diff --git a/app/controllers/projects/forks_controller.rb b/app/controllers/projects/forks_controller.rb
index 7a1700a206a..f40baa0d7c5 100644
--- a/app/controllers/projects/forks_controller.rb
+++ b/app/controllers/projects/forks_controller.rb
@@ -25,7 +25,7 @@ class Projects::ForksController < Projects::ApplicationController
format.json do
render json: {
- html: view_to_html_string("projects/forks/_projects", projects: @forks)
+ html: view_to_html_string("projects/forks/_projects", projects: @forks),
}
end
end
@@ -63,6 +63,6 @@ class Projects::ForksController < Projects::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42335')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42335")
end
end
diff --git a/app/controllers/projects/git_http_client_controller.rb b/app/controllers/projects/git_http_client_controller.rb
index d439db97252..82de4de4db0 100644
--- a/app/controllers/projects/git_http_client_controller.rb
+++ b/app/controllers/projects/git_http_client_controller.rb
@@ -11,8 +11,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
delegate :actor, :authentication_abilities, to: :authentication_result, allow_nil: true
delegate :type, to: :authentication_result, allow_nil: true, prefix: :auth_result
- alias_method :user, :actor
- alias_method :authenticated_user, :actor
+ alias user actor
+ alias authenticated_user actor
# Git clients will not know what authenticity token to send along
skip_before_action :verify_authenticity_token
@@ -43,7 +43,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
if kerberos_user
@authentication_result = Gitlab::Auth::Result.new(
- kerberos_user, nil, :kerberos, Gitlab::Auth.full_authentication_abilities)
+ kerberos_user, nil, :kerberos, Gitlab::Auth.full_authentication_abilities
+ )
send_final_spnego_response
return # Allow access
@@ -68,7 +69,7 @@ class Projects::GitHttpClientController < Projects::ApplicationController
challenges = []
challenges << 'Basic realm="GitLab"' if allow_basic_auth?
challenges << spnego_challenge if allow_kerberos_spnego_auth?
- headers['Www-Authenticate'] = challenges.join("\n") if challenges.any?
+ headers["Www-Authenticate"] = challenges.join("\n") if challenges.any?
end
def project
@@ -100,7 +101,8 @@ class Projects::GitHttpClientController < Projects::ApplicationController
def handle_basic_authentication(login, password)
@authentication_result = Gitlab::Auth.find_for_git_client(
- login, password, project: project, ip: request.ip)
+ login, password, project: project, ip: request.ip
+ )
@authentication_result.success?
end
diff --git a/app/controllers/projects/git_http_controller.rb b/app/controllers/projects/git_http_controller.rb
index 0c5328fc941..2342d3deee4 100644
--- a/app/controllers/projects/git_http_controller.rb
+++ b/app/controllers/projects/git_http_controller.rb
@@ -37,11 +37,11 @@ class Projects::GitHttpController < Projects::GitHttpClientController
end
def upload_pack?
- git_command == 'git-upload-pack'
+ git_command == "git-upload-pack"
end
def git_command
- if action_name == 'info_refs'
+ if action_name == "info_refs"
params[:service]
else
action_name.dasherize
@@ -78,7 +78,7 @@ class Projects::GitHttpController < Projects::GitHttpClientController
def access
@access ||= access_klass.new(access_actor, project,
- 'http', authentication_abilities: authentication_abilities,
+ "http", authentication_abilities: authentication_abilities,
namespace_path: params[:namespace_id], project_path: project_path,
redirected_path: redirected_path, auth_result_type: auth_result_type)
end
@@ -98,10 +98,10 @@ class Projects::GitHttpController < Projects::GitHttpClientController
end
def project_path
- @project_path ||= params[:project_id].sub(/\.git$/, '')
+ @project_path ||= params[:project_id].sub(/\.git$/, "")
end
def log_user_activity
- Users::ActivityService.new(user, 'pull').execute
+ Users::ActivityService.new(user, "pull").execute
end
end
diff --git a/app/controllers/projects/graphs_controller.rb b/app/controllers/projects/graphs_controller.rb
index c80fce513f6..e25e1c10958 100644
--- a/app/controllers/projects/graphs_controller.rb
+++ b/app/controllers/projects/graphs_controller.rb
@@ -18,11 +18,11 @@ class Projects::GraphsController < Projects::ApplicationController
end
def commits
- redirect_to action: 'charts'
+ redirect_to action: "charts"
end
def languages
- redirect_to action: 'charts'
+ redirect_to action: "charts"
end
def charts
@@ -48,7 +48,7 @@ class Projects::GraphsController < Projects::ApplicationController
@languages =
if @project.repository_languages.present?
@project.repository_languages.map do |lang|
- { value: lang.share, label: lang.name, color: lang.color, highlight: lang.color }
+ {value: lang.share, label: lang.name, color: lang.color, highlight: lang.color}
end
else
@project.repository.languages
@@ -63,7 +63,7 @@ class Projects::GraphsController < Projects::ApplicationController
@log << {
author_name: commit.author_name,
author_email: commit.author_email,
- date: commit.committed_date.strftime("%Y-%m-%d")
+ date: commit.committed_date.strftime("%Y-%m-%d"),
}
end
diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb
index 7c713c19762..3bfb5636241 100644
--- a/app/controllers/projects/group_links_controller.rb
+++ b/app/controllers/projects/group_links_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Projects::GroupLinksController < Projects::ApplicationController
- layout 'project_settings'
+ layout "project_settings"
before_action :authorize_admin_project!
before_action :authorize_admin_project_member!, only: [:update]
@@ -17,7 +17,7 @@ class Projects::GroupLinksController < Projects::ApplicationController
Projects::GroupLinks::CreateService.new(project, current_user, group_link_create_params).execute(group)
else
- flash[:alert] = 'Please select a group.'
+ flash[:alert] = "Please select a group."
end
redirect_to project_project_members_path(project)
diff --git a/app/controllers/projects/hook_logs_controller.rb b/app/controllers/projects/hook_logs_controller.rb
index a7afc3d77a5..1b251e87d5e 100644
--- a/app/controllers/projects/hook_logs_controller.rb
+++ b/app/controllers/projects/hook_logs_controller.rb
@@ -10,7 +10,7 @@ class Projects::HookLogsController < Projects::ApplicationController
respond_to :html
- layout 'project_settings'
+ layout "project_settings"
def show
end
diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb
index bc84418b79f..4c768cb641d 100644
--- a/app/controllers/projects/hooks_controller.rb
+++ b/app/controllers/projects/hooks_controller.rb
@@ -32,10 +32,10 @@ class Projects::HooksController < Projects::ApplicationController
def update
if hook.update(hook_params)
- flash[:notice] = 'Hook was successfully updated.'
+ flash[:notice] = "Hook was successfully updated."
redirect_to project_settings_integrations_path(@project)
else
- render 'edit'
+ render "edit"
end
end
@@ -44,7 +44,7 @@ class Projects::HooksController < Projects::ApplicationController
set_hook_execution_notice(result)
- redirect_back_or_default(default: { action: 'index' })
+ redirect_back_or_default(default: {action: "index"})
end
def destroy
diff --git a/app/controllers/projects/imports_controller.rb b/app/controllers/projects/imports_controller.rb
index 8b33fa85c1e..9d689402282 100644
--- a/app/controllers/projects/imports_controller.rb
+++ b/app/controllers/projects/imports_controller.rb
@@ -42,9 +42,9 @@ class Projects::ImportsController < Projects::ApplicationController
def finished_notice
if @project.forked?
- 'The project was successfully forked.'
+ "The project was successfully forked."
else
- 'The project was successfully imported.'
+ "The project was successfully imported."
end
end
diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb
index b9d02a62fc3..6d25ec310f7 100644
--- a/app/controllers/projects/issues_controller.rb
+++ b/app/controllers/projects/issues_controller.rb
@@ -49,11 +49,11 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
format.html
- format.atom { render layout: 'xml.atom' }
+ format.atom { render layout: "xml.atom" }
format.json do
render json: {
html: view_to_html_string("projects/issues/_issues"),
- labels: @labels.as_json(methods: :text_color)
+ labels: @labels.as_json(methods: :text_color),
}
end
end
@@ -95,10 +95,10 @@ class Projects::IssuesController < Projects::ApplicationController
if service.discussions_to_resolve.count(&:resolved?) > 0
flash[:notice] = if service.discussion_to_resolve_id
- "Resolved 1 discussion."
- else
- "Resolved all discussions."
- end
+ "Resolved 1 discussion."
+ else
+ "Resolved all discussions."
+ end
end
respond_to do |format|
@@ -126,7 +126,6 @@ class Projects::IssuesController < Projects::ApplicationController
render_issue_json
end
end
-
rescue ActiveRecord::StaleObjectError
render_conflict_response
end
@@ -137,7 +136,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
format.json do
render json: {
- html: view_to_html_string('projects/issues/_merge_requests')
+ html: view_to_html_string("projects/issues/_merge_requests"),
}
end
end
@@ -149,7 +148,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
format.json do
render json: {
- html: view_to_html_string('projects/issues/_related_branches')
+ html: view_to_html_string("projects/issues/_related_branches"),
}
end
end
@@ -162,7 +161,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format|
format.json do
- render json: { can_create_branch: can_create, suggested_branch_name: @issue.suggested_branch_name }
+ render json: {can_create_branch: can_create, suggested_branch_name: @issue.suggested_branch_name}
end
end
end
@@ -209,10 +208,10 @@ class Projects::IssuesController < Projects::ApplicationController
@issue
end
# rubocop: enable CodeReuse/ActiveRecord
- alias_method :subscribable_resource, :issue
- alias_method :issuable, :issue
- alias_method :awardable, :issue
- alias_method :spammable, :issue
+ alias subscribable_resource issue
+ alias issuable issue
+ alias awardable issue
+ alias spammable issue
def spammable_path
project_issue_path(@project, @issue)
@@ -226,7 +225,7 @@ class Projects::IssuesController < Projects::ApplicationController
if @issue.valid?
render json: serializer.represent(@issue)
else
- render json: { errors: @issue.errors.full_messages }, status: :unprocessable_entity
+ render json: {errors: @issue.errors.full_messages}, status: :unprocessable_entity
end
end
@@ -247,7 +246,7 @@ class Projects::IssuesController < Projects::ApplicationController
task_num
lock_version
discussion_locked
- ] + [{ label_ids: [], assignee_ids: [], update_task: [:index, :checked, :line_number, :line_source] }]
+ ] + [{label_ids: [], assignee_ids: [], update_task: [:index, :checked, :line_number, :line_source]}]
end
def store_uri
@@ -275,7 +274,7 @@ class Projects::IssuesController < Projects::ApplicationController
# 1. https://gitlab.com/gitlab-org/gitlab-ce/issues/42423
# 2. https://gitlab.com/gitlab-org/gitlab-ce/issues/42424
# 3. https://gitlab.com/gitlab-org/gitlab-ce/issues/42426
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42422')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42422")
end
def set_suggested_issues_feature_flags
diff --git a/app/controllers/projects/jobs_controller.rb b/app/controllers/projects/jobs_controller.rb
index d5ce790e2d9..b8435620feb 100644
--- a/app/controllers/projects/jobs_controller.rb
+++ b/app/controllers/projects/jobs_controller.rb
@@ -12,28 +12,28 @@ class Projects::JobsController < Projects::ApplicationController
before_action :authorize_use_build_terminal!, only: [:terminal, :terminal_websocket_authorize]
before_action :verify_api_request!, only: :terminal_websocket_authorize
- layout 'project'
+ layout "project"
# rubocop: disable CodeReuse/ActiveRecord
def index
@scope = params[:scope]
@all_builds = project.builds.relevant
- @builds = @all_builds.order('ci_builds.id DESC')
+ @builds = @all_builds.order("ci_builds.id DESC")
@builds =
case @scope
- when 'pending'
+ when "pending"
@builds.pending.reverse_order
- when 'running'
+ when "running"
@builds.running.reverse_order
- when 'finished'
+ when "finished"
@builds.finished
else
@builds
end
@builds = @builds.includes([
- { pipeline: :project },
+ {pipeline: :project},
:project,
- :tags
+ :tags,
])
@builds = @builds.page(params[:page]).per(30).without_count
end
@@ -43,7 +43,7 @@ class Projects::JobsController < Projects::ApplicationController
def show
@pipeline = @build.pipeline
@builds = @pipeline.builds
- .order('id DESC')
+ .order("id DESC")
.present(current_user: current_user)
respond_to do |format|
@@ -64,7 +64,7 @@ class Projects::JobsController < Projects::ApplicationController
respond_to do |format|
format.json do
result = {
- id: @build.id, status: @build.status, complete: @build.complete?
+ id: @build.id, status: @build.status, complete: @build.complete?,
}
if stream.valid?
@@ -122,7 +122,7 @@ class Projects::JobsController < Projects::ApplicationController
def erase
if @build.erase(erased_by: current_user)
redirect_to project_job_path(project, @build),
- notice: "Job has been successfully erased!"
+ notice: "Job has been successfully erased!"
else
respond_422
end
@@ -132,20 +132,20 @@ class Projects::JobsController < Projects::ApplicationController
if trace_artifact_file
workhorse_set_content_type!
send_upload(trace_artifact_file,
- send_params: raw_send_params,
- redirect_params: raw_redirect_params)
+ send_params: raw_send_params,
+ redirect_params: raw_redirect_params)
else
build.trace.read do |stream|
if stream.file?
workhorse_set_content_type!
- send_file stream.path, type: 'text/plain; charset=utf-8', disposition: 'inline'
+ send_file stream.path, type: "text/plain; charset=utf-8", disposition: "inline"
else
# In this case we can't use workhorse_set_content_type! and let
# Workhorse handle the response because the data is streamed directly
# to the user but, because we have the trace content, we can calculate
# the proper content type and disposition here.
raw_data = stream.raw
- send_data raw_data, type: 'text/plain; charset=utf-8', disposition: raw_trace_content_disposition(raw_data), filename: 'job.log'
+ send_data raw_data, type: "text/plain; charset=utf-8", disposition: raw_trace_content_disposition(raw_data), filename: "job.log"
end
end
end
@@ -179,11 +179,11 @@ class Projects::JobsController < Projects::ApplicationController
end
def raw_send_params
- { type: 'text/plain; charset=utf-8', disposition: 'inline' }
+ {type: "text/plain; charset=utf-8", disposition: "inline"}
end
def raw_redirect_params
- { query: { 'response-content-type' => 'text/plain; charset=utf-8', 'response-content-disposition' => 'inline' } }
+ {query: {"response-content-type" => "text/plain; charset=utf-8", "response-content-disposition" => "inline"}}
end
def trace_artifact_file
@@ -203,8 +203,8 @@ class Projects::JobsController < Projects::ApplicationController
mime_type = MimeMagic.by_magic(raw_data)
# if mime_type is nil can also represent 'text/plain'
- return 'inline' if mime_type.nil? || mime_type.type == 'text/plain'
+ return "inline" if mime_type.nil? || mime_type.type == "text/plain"
- 'attachment'
+ "attachment"
end
end
diff --git a/app/controllers/projects/labels_controller.rb b/app/controllers/projects/labels_controller.rb
index 640038818f2..4d79f0a1f5d 100644
--- a/app/controllers/projects/labels_controller.rb
+++ b/app/controllers/projects/labels_controller.rb
@@ -9,7 +9,7 @@ class Projects::LabelsController < Projects::ApplicationController
before_action :authorize_read_label!
before_action :authorize_admin_labels!, only: [:new, :create, :edit, :update,
:generate, :destroy, :remove_priority,
- :set_priorities]
+ :set_priorities,]
before_action :authorize_admin_group_labels!, only: [:promote]
respond_to :js, :html
@@ -41,7 +41,7 @@ class Projects::LabelsController < Projects::ApplicationController
else
respond_to do |format|
format.html { render :new }
- format.json { render json: { message: @label.errors.messages }, status: :bad_request }
+ format.json { render json: {message: @label.errors.messages}, status: :bad_request }
end
end
end
@@ -62,9 +62,9 @@ class Projects::LabelsController < Projects::ApplicationController
def generate
Gitlab::IssuesLabels.generate(@project)
- if params[:redirect] == 'issues'
+ if params[:redirect] == "issues"
redirect_to project_issues_path(@project)
- elsif params[:redirect] == 'merge_requests'
+ elsif params[:redirect] == "merge_requests"
redirect_to project_merge_requests_path(@project)
else
redirect_to project_labels_path(@project)
@@ -76,8 +76,8 @@ class Projects::LabelsController < Projects::ApplicationController
@labels = find_labels
redirect_to project_labels_path(@project),
- status: 302,
- notice: 'Label was removed'
+ status: 302,
+ notice: "Label was removed"
end
def remove_priority
@@ -105,7 +105,7 @@ class Projects::LabelsController < Projects::ApplicationController
end
respond_to do |format|
- format.json { render json: { message: 'success' } }
+ format.json { render json: {message: "success"} }
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -122,7 +122,7 @@ class Projects::LabelsController < Projects::ApplicationController
redirect_to(project_labels_path(@project), status: :see_other)
end
format.json do
- render json: { url: project_labels_path(@project) }
+ render json: {url: project_labels_path(@project)}
end
end
rescue ActiveRecord::RecordInvalid => e
@@ -132,7 +132,7 @@ class Projects::LabelsController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to(project_labels_path(@project),
- notice: 'Failed to promote label due to internal error. Please contact administrators.')
+ notice: "Failed to promote label due to internal error. Please contact administrators.")
end
format.js
end
@@ -140,7 +140,7 @@ class Projects::LabelsController < Projects::ApplicationController
end
def flash_notice_for(label, group)
- ''.html_safe + "#{label.title} promoted to " + view_context.link_to('<u>group label</u>'.html_safe, group_labels_path(group)) + '.'
+ "".html_safe + "#{label.title} promoted to " + view_context.link_to("<u>group label</u>".html_safe, group_labels_path(group)) + "."
end
protected
@@ -160,15 +160,15 @@ class Projects::LabelsController < Projects::ApplicationController
def find_labels
@available_labels ||=
LabelsFinder.new(current_user,
- project_id: @project.id,
- include_ancestor_groups: params[:include_ancestor_groups],
- search: params[:search],
- subscribed: params[:subscribed],
- sort: sort).execute
+ project_id: @project.id,
+ include_ancestor_groups: params[:include_ancestor_groups],
+ search: params[:search],
+ subscribed: params[:subscribed],
+ sort: sort).execute
end
def sort
- @sort ||= params[:sort] || 'name_asc'
+ @sort ||= params[:sort] || "name_asc"
end
def authorize_admin_labels!
diff --git a/app/controllers/projects/lfs_api_controller.rb b/app/controllers/projects/lfs_api_controller.rb
index be40077d389..e4947ea9d3e 100644
--- a/app/controllers/projects/lfs_api_controller.rb
+++ b/app/controllers/projects/lfs_api_controller.rb
@@ -3,7 +3,7 @@
class Projects::LfsApiController < Projects::GitHttpClientController
include LfsRequest
- LFS_TRANSFER_CONTENT_TYPE = 'application/octet-stream'.freeze
+ LFS_TRANSFER_CONTENT_TYPE = "application/octet-stream"
skip_before_action :lfs_check_access!, only: [:deprecated]
before_action :lfs_check_batch_operation!, only: [:batch]
@@ -15,9 +15,9 @@ class Projects::LfsApiController < Projects::GitHttpClientController
end
if download_request?
- render json: { objects: download_objects! }
+ render json: {objects: download_objects!}
elsif upload_request?
- render json: { objects: upload_objects! }
+ render json: {objects: upload_objects!}
else
raise "Never reached"
end
@@ -26,8 +26,8 @@ class Projects::LfsApiController < Projects::GitHttpClientController
def deprecated
render(
json: {
- message: 'Server supports batch API only, please update your Git LFS client to version 1.0.1 and up.',
- documentation_url: "#{Gitlab.config.gitlab.url}/help"
+ message: "Server supports batch API only, please update your Git LFS client to version 1.0.1 and up.",
+ documentation_url: "#{Gitlab.config.gitlab.url}/help",
},
status: :not_implemented
)
@@ -36,17 +36,17 @@ class Projects::LfsApiController < Projects::GitHttpClientController
private
def download_request?
- params[:operation] == 'download'
+ params[:operation] == "download"
end
def upload_request?
- params[:operation] == 'upload'
+ params[:operation] == "upload"
end
# rubocop: disable CodeReuse/ActiveRecord
def existing_oids
@existing_oids ||= begin
- project.all_lfs_objects.where(oid: objects.map { |o| o['oid'].to_s }).pluck(:oid)
+ project.all_lfs_objects.where(oid: objects.map { |o| o["oid"].to_s }).pluck(:oid)
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -62,7 +62,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController
else
object[:error] = {
code: 404,
- message: "Object does not exist on the server or you don't have permissions to access it"
+ message: "Object does not exist on the server or you don't have permissions to access it",
}
end
end
@@ -81,9 +81,9 @@ class Projects::LfsApiController < Projects::GitHttpClientController
download: {
href: "#{project.http_url_to_repo}/gitlab-lfs/objects/#{object[:oid]}",
header: {
- Authorization: request.headers['Authorization']
- }.compact
- }
+ Authorization: request.headers["Authorization"],
+ }.compact,
+ },
}
end
@@ -92,12 +92,12 @@ class Projects::LfsApiController < Projects::GitHttpClientController
upload: {
href: "#{project.http_url_to_repo}/gitlab-lfs/objects/#{object[:oid]}/#{object[:size]}",
header: {
- Authorization: request.headers['Authorization'],
+ Authorization: request.headers["Authorization"],
# git-lfs v2.5.0 sets the Content-Type based on the uploaded file. This
# ensures that Workhorse can intercept the request.
- 'Content-Type': LFS_TRANSFER_CONTENT_TYPE
- }.compact
- }
+ 'Content-Type': LFS_TRANSFER_CONTENT_TYPE,
+ }.compact,
+ },
}
end
@@ -105,7 +105,7 @@ class Projects::LfsApiController < Projects::GitHttpClientController
if batch_operation_disallowed?
render(
json: {
- message: lfs_read_only_message
+ message: lfs_read_only_message,
},
content_type: LfsRequest::CONTENT_TYPE,
status: 403
@@ -120,6 +120,6 @@ class Projects::LfsApiController < Projects::GitHttpClientController
# Overridden in EE
def lfs_read_only_message
- _('You cannot write to this read-only GitLab instance.')
+ _("You cannot write to this read-only GitLab instance.")
end
end
diff --git a/app/controllers/projects/lfs_locks_api_controller.rb b/app/controllers/projects/lfs_locks_api_controller.rb
index 6aacb9d9a56..9b61be1224e 100644
--- a/app/controllers/projects/lfs_locks_api_controller.rb
+++ b/app/controllers/projects/lfs_locks_api_controller.rb
@@ -26,7 +26,7 @@ class Projects::LfsLocksApiController < Projects::GitHttpClientController
ours, theirs = split_by_owner(@result[:locks])
- render_json({ ours: ours, theirs: theirs }, false)
+ render_json({ours: ours, theirs: theirs}, false)
end
private
@@ -50,7 +50,7 @@ class Projects::LfsLocksApiController < Projects::GitHttpClientController
def error_payload(message, custom_attrs = {})
custom_attrs.merge({
message: message,
- documentation_url: help_url
+ documentation_url: help_url,
})
end
@@ -63,11 +63,11 @@ class Projects::LfsLocksApiController < Projects::GitHttpClientController
end
def download_request?
- params[:action] == 'index'
+ params[:action] == "index"
end
def upload_request?
- %w(create unlock verify).include?(params[:action])
+ %w[create unlock verify].include?(params[:action])
end
def lfs_params
diff --git a/app/controllers/projects/lfs_storage_controller.rb b/app/controllers/projects/lfs_storage_controller.rb
index 013e01b82aa..8faee9161d5 100644
--- a/app/controllers/projects/lfs_storage_controller.rb
+++ b/app/controllers/projects/lfs_storage_controller.rb
@@ -9,19 +9,20 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
def download
lfs_object = LfsObject.find_by_oid(oid)
- unless lfs_object && lfs_object.file.exists?
+ unless lfs_object&.file&.exists?
render_lfs_not_found
return
end
- send_upload(lfs_object.file, send_params: { content_type: "application/octet-stream" })
+ send_upload(lfs_object.file, send_params: {content_type: "application/octet-stream"})
end
def upload_authorize
set_workhorse_internal_api_content_type
authorized = LfsObjectUploader.workhorse_authorize(has_length: true)
- authorized.merge!(LfsOid: oid, LfsSize: size)
+ authorized[:LfsOid] = oid
+ authorized[:LfsSize] = size
render json: authorized
end
@@ -30,7 +31,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
if store_file!(oid, size)
head 200
else
- render plain: 'Unprocessable entity', status: :unprocessable_entity
+ render plain: "Unprocessable entity", status: :unprocessable_entity
end
rescue ActiveRecord::RecordInvalid
render_lfs_forbidden
@@ -43,7 +44,7 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
private
def download_request?
- action_name == 'download'
+ action_name == "download"
end
def upload_request?
@@ -73,7 +74,8 @@ class Projects::LfsStorageController < Projects::GitHttpClientController
def create_file!(oid, size)
uploaded_file = UploadedFile.from_params(
- params, :file, LfsObjectUploader.workhorse_local_upload_path)
+ params, :file, LfsObjectUploader.workhorse_local_upload_path
+ )
return unless uploaded_file
LfsObject.create!(oid: oid, size: size, file: uploaded_file)
diff --git a/app/controllers/projects/mattermosts_controller.rb b/app/controllers/projects/mattermosts_controller.rb
index 085b1bc1498..1c12982b699 100644
--- a/app/controllers/projects/mattermosts_controller.rb
+++ b/app/controllers/projects/mattermosts_controller.rb
@@ -4,7 +4,7 @@ class Projects::MattermostsController < Projects::ApplicationController
include TriggersHelper
include ActionView::Helpers::AssetUrlHelper
- layout 'project_settings'
+ layout "project_settings"
before_action :authorize_admin_project!
before_action :service
@@ -17,10 +17,10 @@ class Projects::MattermostsController < Projects::ApplicationController
result, message = @service.configure(current_user, configure_params)
if result
- flash[:notice] = 'This service is now configured'
+ flash[:notice] = "This service is now configured"
redirect_to edit_project_service_path(@project, service)
else
- flash[:alert] = message || 'Failed to configure service'
+ flash[:alert] = message || "Failed to configure service"
redirect_to new_project_mattermost_path(@project)
end
end
@@ -30,7 +30,8 @@ class Projects::MattermostsController < Projects::ApplicationController
def configure_params
params.require(:mattermost).permit(:trigger, :team_id).merge(
url: service_trigger_url(@service),
- icon_url: asset_url('slash-command-logo.png'))
+ icon_url: asset_url("slash-command-logo.png")
+ )
end
def teams
@@ -38,6 +39,6 @@ class Projects::MattermostsController < Projects::ApplicationController
end
def service
- @service ||= @project.find_or_initialize_service('mattermost_slash_commands')
+ @service ||= @project.find_or_initialize_service("mattermost_slash_commands")
end
end
diff --git a/app/controllers/projects/merge_requests/application_controller.rb b/app/controllers/projects/merge_requests/application_controller.rb
index 6045ee4e171..aa34eeb1c37 100644
--- a/app/controllers/projects/merge_requests/application_controller.rb
+++ b/app/controllers/projects/merge_requests/application_controller.rb
@@ -35,7 +35,7 @@ class Projects::MergeRequests::ApplicationController < Projects::ApplicationCont
:title,
:discussion_locked,
label_ids: [],
- update_task: [:index, :checked, :line_number, :line_source]
+ update_task: [:index, :checked, :line_number, :line_source],
]
end
diff --git a/app/controllers/projects/merge_requests/conflicts_controller.rb b/app/controllers/projects/merge_requests/conflicts_controller.rb
index 045a4e974fe..91a1232f1b5 100644
--- a/app/controllers/projects/merge_requests/conflicts_controller.rb
+++ b/app/controllers/projects/merge_requests/conflicts_controller.rb
@@ -8,7 +8,7 @@ class Projects::MergeRequests::ConflictsController < Projects::MergeRequests::Ap
def show
respond_to do |format|
format.html do
- @issuable_sidebar = serializer.represent(@merge_request, serializer: 'sidebar')
+ @issuable_sidebar = serializer.represent(@merge_request, serializer: "sidebar")
end
format.json do
@@ -16,13 +16,13 @@ class Projects::MergeRequests::ConflictsController < Projects::MergeRequests::Ap
render json: @conflicts_list
elsif @merge_request.can_be_merged?
render json: {
- message: 'The merge conflicts for this merge request have already been resolved. Please return to the merge request.',
- type: 'error'
+ message: "The merge conflicts for this merge request have already been resolved. Please return to the merge request.",
+ type: "error",
}
else
render json: {
- message: 'The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally.',
- type: 'error'
+ message: "The merge conflicts for this merge request cannot be resolved through GitLab. Please try to resolve them locally.",
+ type: "error",
}
end
end
@@ -43,7 +43,7 @@ class Projects::MergeRequests::ConflictsController < Projects::MergeRequests::Ap
return render_404 unless @conflicts_list.can_be_resolved_in_ui?
if @merge_request.can_be_merged?
- render status: :bad_request, json: { message: 'The merge conflicts for this merge request have already been resolved.' }
+ render status: :bad_request, json: {message: "The merge conflicts for this merge request have already been resolved."}
return
end
@@ -52,11 +52,11 @@ class Projects::MergeRequests::ConflictsController < Projects::MergeRequests::Ap
.new(merge_request)
.execute(current_user, params)
- flash[:notice] = 'All merge conflicts were resolved. The merge request can now be merged.'
+ flash[:notice] = "All merge conflicts were resolved. The merge request can now be merged."
- render json: { redirect_to: project_merge_request_url(@project, @merge_request, resolved_conflicts: true) }
+ render json: {redirect_to: project_merge_request_url(@project, @merge_request, resolved_conflicts: true)}
rescue Gitlab::Git::Conflict::Resolver::ResolutionError => e
- render status: :bad_request, json: { message: e.message }
+ render status: :bad_request, json: {message: e.message}
end
end
diff --git a/app/controllers/projects/merge_requests/creations_controller.rb b/app/controllers/projects/merge_requests/creations_controller.rb
index 32cefe54613..ca3bff85c56 100644
--- a/app/controllers/projects/merge_requests/creations_controller.rb
+++ b/app/controllers/projects/merge_requests/creations_controller.rb
@@ -40,8 +40,8 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
render json: {
pipelines: PipelineSerializer
- .new(project: @project, current_user: @current_user)
- .represent(@pipelines)
+ .new(project: @project, current_user: @current_user)
+ .represent(@pipelines),
}
end
@@ -52,7 +52,7 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
@environment = @merge_request.environments_for(current_user).last
- render json: { html: view_to_html_string('projects/merge_requests/creations/_diffs', diffs: @diffs, environment: @environment) }
+ render json: {html: view_to_html_string("projects/merge_requests/creations/_diffs", diffs: @diffs, environment: @environment)}
end
def diff_for_path
@@ -100,10 +100,10 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
@noteable = @merge_request
@target_branches = if @merge_request.target_project
- @merge_request.target_project.repository.branch_names
- else
- []
- end
+ @merge_request.target_project.repository.branch_names
+ else
+ []
+ end
@target_project = @merge_request.target_project
@source_project = @merge_request.source_project
@@ -133,6 +133,6 @@ class Projects::MergeRequests::CreationsController < Projects::MergeRequests::Ap
# rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42384')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42384")
end
end
diff --git a/app/controllers/projects/merge_requests/diffs_controller.rb b/app/controllers/projects/merge_requests/diffs_controller.rb
index 518d41bd3fb..7e67c79f78d 100644
--- a/app/controllers/projects/merge_requests/diffs_controller.rb
+++ b/app/controllers/projects/merge_requests/diffs_controller.rb
@@ -30,7 +30,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
request = {
current_user: current_user,
project: @merge_request.project,
- render: ->(partial, locals) { view_to_html_string(partial, locals) }
+ render: ->(partial, locals) { view_to_html_string(partial, locals) },
}
render json: DiffsSerializer.new(request).represent(@diffs, additional_attributes)
@@ -92,15 +92,15 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
start_version: @start_version,
start_sha: @start_sha,
commit: @commit,
- latest_diff: @merge_request_diff&.latest?
+ latest_diff: @merge_request_diff&.latest?,
}
end
def define_diff_comment_vars
@new_diff_note_attrs = {
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: @merge_request.id,
- commit_id: @commit&.id
+ commit_id: @commit&.id,
}
@diff_notes_disabled = false
diff --git a/app/controllers/projects/merge_requests_controller.rb b/app/controllers/projects/merge_requests_controller.rb
index 46a44841c31..fb746c0e197 100644
--- a/app/controllers/projects/merge_requests_controller.rb
+++ b/app/controllers/projects/merge_requests_controller.rb
@@ -27,7 +27,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
format.html
format.json do
render json: {
- html: view_to_html_string("projects/merge_requests/_merge_requests")
+ html: view_to_html_string("projects/merge_requests/_merge_requests"),
}
end
end
@@ -40,14 +40,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
respond_to do |format|
format.html do
# use next to appease Rubocop
- next render('invalid') if target_branch_missing?
+ next render("invalid") if target_branch_missing?
# Build a note object for comment form
@note = @project.notes.new(noteable: @merge_request)
@noteable = @merge_request
@commits_count = @merge_request.commits_count
- @issuable_sidebar = serializer.represent(@merge_request, serializer: 'sidebar')
+ @issuable_sidebar = serializer.represent(@merge_request, serializer: "sidebar")
set_pipeline_variables
@@ -80,7 +80,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
@commits =
set_commits_for_rendering(@merge_request.commits.with_pipeline_status)
- render json: { html: view_to_html_string('projects/merge_requests/_commits') }
+ render json: {html: view_to_html_string("projects/merge_requests/_commits")}
end
def pipelines
@@ -94,8 +94,8 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
.with_pagination(request, response)
.represent(@pipelines),
count: {
- all: @pipelines.count
- }
+ all: @pipelines.count,
+ },
}
end
@@ -106,13 +106,13 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
when :parsing
Gitlab::PollingInterval.set_header(response, interval: 3000)
- render json: '', status: :no_content
+ render json: "", status: :no_content
when :parsed
render json: result[:data].to_json, status: :ok
when :error
- render json: { status_reason: result[:status_reason] }, status: :bad_request
+ render json: {status_reason: result[:status_reason]}, status: :bad_request
else
- render json: { status_reason: 'Unknown error' }, status: :internal_server_error
+ render json: {status_reason: "Unknown error"}, status: :internal_server_error
end
end
@@ -138,7 +138,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
if merge_request.errors.present?
render json: @merge_request.errors, status: :bad_request
else
- render json: serializer.represent(@merge_request, serializer: 'basic')
+ render json: serializer.represent(@merge_request, serializer: "basic")
end
end
end
@@ -150,14 +150,14 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def remove_wip
@merge_request = ::MergeRequests::UpdateService
- .new(project, current_user, wip_event: 'unwip')
+ .new(project, current_user, wip_event: "unwip")
.execute(@merge_request)
render json: serialize_widget(@merge_request)
end
def commit_change_content
- render partial: 'projects/merge_requests/widget/commit_change_content', layout: false
+ render partial: "projects/merge_requests/widget/commit_change_content", layout: false
end
def cancel_merge_when_pipeline_succeeds
@@ -180,9 +180,9 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
status = merge!
if @merge_request.merge_error
- render json: { status: status, merge_error: @merge_request.merge_error }
+ render json: {status: status, merge_error: @merge_request.merge_error}
else
- render json: { status: status }
+ render json: {status: status}
end
end
@@ -209,10 +209,10 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def ci_environments_status
environments = if ci_environments_status_on_merge_result?
- EnvironmentStatus.after_merge_request(@merge_request, current_user)
- else
- EnvironmentStatus.for_merge_request(@merge_request, current_user)
- end
+ EnvironmentStatus.after_merge_request(@merge_request, current_user)
+ else
+ EnvironmentStatus.for_merge_request(@merge_request, current_user)
+ end
render json: EnvironmentStatusSerializer.new(current_user: current_user).represent(environments)
end
@@ -231,9 +231,9 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
protected
- alias_method :subscribable_resource, :merge_request
- alias_method :issuable, :merge_request
- alias_method :awardable, :merge_request
+ alias subscribable_resource merge_request
+ alias issuable merge_request
+ alias awardable merge_request
def issuable_sorting_field
MergeRequest::SORTING_PREFERENCE_FIELD
@@ -261,7 +261,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
private
def ci_environments_status_on_merge_result?
- params[:environment_target] == 'merge_commit'
+ params[:environment_target] == "merge_commit"
end
def target_branch_missing?
@@ -315,7 +315,7 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
end
def serialize_widget(merge_request)
- serializer.represent(merge_request, serializer: 'widget')
+ serializer.represent(merge_request, serializer: "widget")
end
def serializer
@@ -353,6 +353,6 @@ class Projects::MergeRequestsController < Projects::MergeRequests::ApplicationCo
def whitelist_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-ce/issues/42441
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42438')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42438")
end
end
diff --git a/app/controllers/projects/milestones_controller.rb b/app/controllers/projects/milestones_controller.rb
index f6f61b6e5fb..ef8f6bd4219 100644
--- a/app/controllers/projects/milestones_controller.rb
+++ b/app/controllers/projects/milestones_controller.rb
@@ -19,7 +19,7 @@ class Projects::MilestonesController < Projects::ApplicationController
respond_to :html
def index
- @sort = params[:sort] || 'due_date_asc'
+ @sort = params[:sort] || "due_date_asc"
@milestones = milestones.sort_by_attribute(@sort)
respond_to do |format|
@@ -88,7 +88,7 @@ class Projects::MilestonesController < Projects::ApplicationController
redirect_to project_milestones_path(project)
end
format.json do
- render json: { url: project_milestones_path(project) }
+ render json: {url: project_milestones_path(project)}
end
end
rescue Milestones::PromoteService::PromoteMilestoneError => error
@@ -96,7 +96,7 @@ class Projects::MilestonesController < Projects::ApplicationController
end
def flash_notice_for(milestone, group)
- ''.html_safe + "#{milestone.title} promoted to " + view_context.link_to('<u>group milestone</u>'.html_safe, group_milestone_path(group, milestone.iid)) + '.'
+ "".html_safe + "#{milestone.title} promoted to " + view_context.link_to("<u>group milestone</u>".html_safe, group_milestone_path(group, milestone.iid)) + "."
end
def destroy
diff --git a/app/controllers/projects/mirrors_controller.rb b/app/controllers/projects/mirrors_controller.rb
index ab7ab13657a..720e96852a5 100644
--- a/app/controllers/projects/mirrors_controller.rb
+++ b/app/controllers/projects/mirrors_controller.rb
@@ -11,20 +11,20 @@ class Projects::MirrorsController < Projects::ApplicationController
layout "project_settings"
def show
- redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
+ redirect_to_repository_settings(project, anchor: "js-push-remote-settings")
end
def update
result = ::Projects::UpdateService.new(project, current_user, mirror_params).execute
if result[:status] == :success
- flash[:notice] = 'Mirroring settings were successfully updated.'
+ flash[:notice] = "Mirroring settings were successfully updated."
else
- flash[:alert] = project.errors.full_messages.join(', ').html_safe
+ flash[:alert] = project.errors.full_messages.join(", ").html_safe
end
respond_to do |format|
- format.html { redirect_to_repository_settings(project, anchor: 'js-push-remote-settings') }
+ format.html { redirect_to_repository_settings(project, anchor: "js-push-remote-settings") }
format.json do
if project.errors.present?
render json: project.errors, status: :unprocessable_entity
@@ -41,7 +41,7 @@ class Projects::MirrorsController < Projects::ApplicationController
flash[:notice] = "The remote repository is being updated..."
end
- redirect_to_repository_settings(project, anchor: 'js-push-remote-settings')
+ redirect_to_repository_settings(project, anchor: "js-push-remote-settings")
end
def ssh_host_keys
@@ -49,7 +49,7 @@ class Projects::MirrorsController < Projects::ApplicationController
if lookup.error.present?
# Failed to read keys
- render json: { message: lookup.error }, status: :bad_request
+ render json: {message: lookup.error}, status: :bad_request
elsif lookup.known_hosts.nil?
# Still working, come back later
render body: nil, status: :no_content
@@ -57,7 +57,7 @@ class Projects::MirrorsController < Projects::ApplicationController
render json: lookup
end
rescue ArgumentError => err
- render json: { message: err.message }, status: :bad_request
+ render json: {message: err.message}, status: :bad_request
end
private
@@ -81,7 +81,7 @@ class Projects::MirrorsController < Projects::ApplicationController
password
ssh_known_hosts
regenerate_ssh_private_key
- ]
+ ],
]
end
diff --git a/app/controllers/projects/network_controller.rb b/app/controllers/projects/network_controller.rb
index 6543711ecfa..e1a819ad84c 100644
--- a/app/controllers/projects/network_controller.rb
+++ b/app/controllers/projects/network_controller.rb
@@ -13,7 +13,7 @@ class Projects::NetworkController < Projects::ApplicationController
def show
@url = project_network_path(@project, @ref, @options.merge(format: :json))
- @commit_url = project_commit_path(@project, 'ae45ca32').gsub("ae45ca32", "%s")
+ @commit_url = project_commit_path(@project, "ae45ca32").gsub("ae45ca32", "%s")
respond_to do |format|
format.html do
@@ -41,6 +41,6 @@ class Projects::NetworkController < Projects::ApplicationController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42333')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42333")
end
end
diff --git a/app/controllers/projects/notes_controller.rb b/app/controllers/projects/notes_controller.rb
index 3152a38fd8e..015de870b16 100644
--- a/app/controllers/projects/notes_controller.rb
+++ b/app/controllers/projects/notes_controller.rb
@@ -32,7 +32,7 @@ class Projects::NotesController < Projects::ApplicationController
else
render json: {
resolved_by: note.resolved_by.try(:name),
- discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion)
+ discussion_headline_html: (view_to_html_string("discussions/_headline", discussion: discussion) if discussion),
}
end
end
@@ -48,7 +48,7 @@ class Projects::NotesController < Projects::ApplicationController
render_json_with_notes_serializer
else
render json: {
- discussion_headline_html: (view_to_html_string('discussions/_headline', discussion: discussion) if discussion)
+ discussion_headline_html: (view_to_html_string("discussions/_headline", discussion: discussion) if discussion),
}
end
end
@@ -65,7 +65,7 @@ class Projects::NotesController < Projects::ApplicationController
@note ||= @project.notes.find(params[:id])
end
- alias_method :awardable, :note
+ alias awardable note
def finder_params
params.merge(last_fetched_at: last_fetched_at, notes_filter: notes_filter)
@@ -86,6 +86,6 @@ class Projects::NotesController < Projects::ApplicationController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42383')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42383")
end
end
diff --git a/app/controllers/projects/pages_controller.rb b/app/controllers/projects/pages_controller.rb
index 73e629ab7c3..3ad934cd487 100644
--- a/app/controllers/projects/pages_controller.rb
+++ b/app/controllers/projects/pages_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Projects::PagesController < Projects::ApplicationController
- layout 'project_settings'
+ layout "project_settings"
before_action :require_pages_enabled!
before_action :authorize_read_pages!, only: [:show]
@@ -21,8 +21,8 @@ class Projects::PagesController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to project_pages_path(@project),
- status: 302,
- notice: 'Pages were removed'
+ status: 302,
+ notice: "Pages were removed"
end
end
end
@@ -33,9 +33,9 @@ class Projects::PagesController < Projects::ApplicationController
respond_to do |format|
format.html do
if result[:status] == :success
- flash[:notice] = 'Your changes have been saved'
+ flash[:notice] = "Your changes have been saved"
else
- flash[:alert] = 'Something went wrong on our end'
+ flash[:alert] = "Something went wrong on our end"
end
redirect_to project_pages_path(@project)
diff --git a/app/controllers/projects/pages_domains_controller.rb b/app/controllers/projects/pages_domains_controller.rb
index 58b1bc54181..424b31aac56 100644
--- a/app/controllers/projects/pages_domains_controller.rb
+++ b/app/controllers/projects/pages_domains_controller.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class Projects::PagesDomainsController < Projects::ApplicationController
- layout 'project_settings'
+ layout "project_settings"
before_action :require_pages_enabled!
before_action :authorize_update_pages!
@@ -18,9 +18,9 @@ class Projects::PagesDomainsController < Projects::ApplicationController
result = VerifyPagesDomainService.new(@domain).execute
if result[:status] == :success
- flash[:notice] = 'Successfully verified domain ownership'
+ flash[:notice] = "Successfully verified domain ownership"
else
- flash[:alert] = 'Failed to verify domain ownership'
+ flash[:alert] = "Failed to verify domain ownership"
end
redirect_to project_pages_domain_path(@project, @domain)
@@ -35,7 +35,7 @@ class Projects::PagesDomainsController < Projects::ApplicationController
if @domain.valid?
redirect_to project_pages_domain_path(@project, @domain)
else
- render 'new'
+ render "new"
end
end
@@ -43,9 +43,9 @@ class Projects::PagesDomainsController < Projects::ApplicationController
if @domain.update(update_params)
redirect_to project_pages_path(@project),
status: 302,
- notice: 'Domain was updated'
+ notice: "Domain was updated"
else
- render 'edit'
+ render "edit"
end
end
@@ -55,8 +55,8 @@ class Projects::PagesDomainsController < Projects::ApplicationController
respond_to do |format|
format.html do
redirect_to project_pages_path(@project),
- status: 302,
- notice: 'Domain was removed'
+ status: 302,
+ notice: "Domain was removed"
end
format.js
end
diff --git a/app/controllers/projects/pipeline_schedules_controller.rb b/app/controllers/projects/pipeline_schedules_controller.rb
index acf56f0eb6a..6a627f55f96 100644
--- a/app/controllers/projects/pipeline_schedules_controller.rb
+++ b/app/controllers/projects/pipeline_schedules_controller.rb
@@ -52,7 +52,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
if job_id
flash[:notice] = "Successfully scheduled a pipeline to run. Go to the <a href=\"#{project_pipelines_path(@project)}\">Pipelines page</a> for details.".html_safe
else
- flash[:alert] = 'Unable to schedule a pipeline to run immediately'
+ flash[:alert] = "Unable to schedule a pipeline to run immediately"
end
redirect_to pipeline_schedules_path(@project)
@@ -71,8 +71,8 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
redirect_to pipeline_schedules_path(@project), status: :found
else
redirect_to pipeline_schedules_path(@project),
- status: :forbidden,
- alert: _("Failed to remove the pipeline schedule")
+ status: :forbidden,
+ alert: _("Failed to remove the pipeline schedule")
end
end
@@ -85,7 +85,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
return unless limiter.throttled?([current_user, schedule], 1)
- flash[:alert] = 'You cannot play this scheduled pipeline at the moment. Please wait a minute.'
+ flash[:alert] = "You cannot play this scheduled pipeline at the moment. Please wait a minute."
redirect_to pipeline_schedules_path(@project)
end
@@ -96,7 +96,7 @@ class Projects::PipelineSchedulesController < Projects::ApplicationController
def schedule_params
params.require(:schedule)
.permit(:description, :cron, :cron_timezone, :ref, :active,
- variables_attributes: [:id, :key, :secret_value, :_destroy] )
+ variables_attributes: [:id, :key, :secret_value, :_destroy])
end
def authorize_play_pipeline_schedule!
diff --git a/app/controllers/projects/pipelines_controller.rb b/app/controllers/projects/pipelines_controller.rb
index 6a86f8ca729..b00f1826d50 100644
--- a/app/controllers/projects/pipelines_controller.rb
+++ b/app/controllers/projects/pipelines_controller.rb
@@ -20,9 +20,9 @@ class Projects::PipelinesController < Projects::ApplicationController
.page(params[:page])
.per(30)
- @running_count = limited_pipelines_count(project, 'running')
- @pending_count = limited_pipelines_count(project, 'pending')
- @finished_count = limited_pipelines_count(project, 'finished')
+ @running_count = limited_pipelines_count(project, "running")
+ @pending_count = limited_pipelines_count(project, "pending")
+ @finished_count = limited_pipelines_count(project, "finished")
@pipelines_count = limited_pipelines_count(project)
respond_to do |format|
@@ -39,8 +39,8 @@ class Projects::PipelinesController < Projects::ApplicationController
all: @pipelines_count,
running: @running_count,
pending: @pending_count,
- finished: @finished_count
- }
+ finished: @finished_count,
+ },
}
end
end
@@ -58,7 +58,7 @@ class Projects::PipelinesController < Projects::ApplicationController
if @pipeline.persisted?
redirect_to project_pipeline_path(project, @pipeline)
else
- render 'new'
+ render "new"
end
end
@@ -108,7 +108,7 @@ class Projects::PipelinesController < Projects::ApplicationController
@stage = pipeline.legacy_stage(params[:stage])
return not_found unless @stage
- render json: { html: view_to_html_string('projects/pipelines/_stage') }
+ render json: {html: view_to_html_string("projects/pipelines/_stage")}
end
def retry
@@ -153,13 +153,13 @@ class Projects::PipelinesController < Projects::ApplicationController
def render_show
respond_to do |format|
format.html do
- render 'show'
+ render "show"
end
end
end
def show_represent_params
- { grouped: true }
+ {grouped: true}
end
def create_params
@@ -169,16 +169,16 @@ class Projects::PipelinesController < Projects::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def pipeline
@pipeline ||= project
- .all_pipelines
- .includes(user: :status)
- .find_by!(id: params[:id])
- .present(current_user: current_user)
+ .all_pipelines
+ .includes(user: :status)
+ .find_by!(id: params[:id])
+ .present(current_user: current_user)
end
# rubocop: enable CodeReuse/ActiveRecord
def whitelist_query_limiting
# Also see https://gitlab.com/gitlab-org/gitlab-ce/issues/42343
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42339')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42339")
end
def authorize_update_pipeline!
diff --git a/app/controllers/projects/project_members_controller.rb b/app/controllers/projects/project_members_controller.rb
index 8938cfbad54..84fdbee678b 100644
--- a/app/controllers/projects/project_members_controller.rb
+++ b/app/controllers/projects/project_members_controller.rb
@@ -45,9 +45,9 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
redirect_to(project_project_members_path(project),
- notice: notice)
+ notice: notice)
end
# MembershipActions concern
- alias_method :membershipable, :project
+ alias membershipable project
end
diff --git a/app/controllers/projects/protected_branches_controller.rb b/app/controllers/projects/protected_branches_controller.rb
index c5454883060..ea2c0a798e6 100644
--- a/app/controllers/projects/protected_branches_controller.rb
+++ b/app/controllers/projects/protected_branches_controller.rb
@@ -21,7 +21,7 @@ class Projects::ProtectedBranchesController < Projects::ProtectedRefsController
def protected_ref_params
params.require(:protected_branch).permit(:name,
- merge_access_levels_attributes: access_level_attributes,
- push_access_levels_attributes: access_level_attributes)
+ merge_access_levels_attributes: access_level_attributes,
+ push_access_levels_attributes: access_level_attributes)
end
end
diff --git a/app/controllers/projects/protected_refs_controller.rb b/app/controllers/projects/protected_refs_controller.rb
index 4e2a9df5576..1c7af305ba0 100644
--- a/app/controllers/projects/protected_refs_controller.rb
+++ b/app/controllers/projects/protected_refs_controller.rb
@@ -18,7 +18,7 @@ class Projects::ProtectedRefsController < Projects::ApplicationController
protected_ref = create_service_class.new(@project, current_user, protected_ref_params).execute
unless protected_ref.persisted?
- flash[:alert] = protected_ref.errors.full_messages.join(', ').html_safe
+ flash[:alert] = protected_ref.errors.full_messages.join(", ").html_safe
end
redirect_to_repository_settings(@project, anchor: params[:update_section])
diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb
index 42ae5b0ef3c..8a36757f480 100644
--- a/app/controllers/projects/raw_controller.rb
+++ b/app/controllers/projects/raw_controller.rb
@@ -12,6 +12,6 @@ class Projects::RawController < Projects::ApplicationController
def show
@blob = @repository.blob_at(@commit.id, @path)
- send_blob(@repository, @blob, inline: (params[:inline] != 'false'))
+ send_blob(@repository, @blob, inline: (params[:inline] != "false"))
end
end
diff --git a/app/controllers/projects/registry/application_controller.rb b/app/controllers/projects/registry/application_controller.rb
index 2f891d78c91..2ebfe2e6e56 100644
--- a/app/controllers/projects/registry/application_controller.rb
+++ b/app/controllers/projects/registry/application_controller.rb
@@ -3,7 +3,7 @@
module Projects
module Registry
class ApplicationController < Projects::ApplicationController
- layout 'project'
+ layout "project"
before_action :verify_registry_enabled!
before_action :authorize_read_container_image!
diff --git a/app/controllers/projects/repositories_controller.rb b/app/controllers/projects/repositories_controller.rb
index 4eeaeb860ee..66fff5ec9f8 100644
--- a/app/controllers/projects/repositories_controller.rb
+++ b/app/controllers/projects/repositories_controller.rb
@@ -19,7 +19,7 @@ class Projects::RepositoriesController < Projects::ApplicationController
append_sha = params[:append_sha]
if @ref
- shortname = "#{@project.path}-#{@ref.tr('/', '-')}"
+ shortname = "#{@project.path}-#{@ref.tr("/", "-")}"
append_sha = false if @filename == shortname
end
diff --git a/app/controllers/projects/runner_projects_controller.rb b/app/controllers/projects/runner_projects_controller.rb
index cbeb32fd610..3093cf72ef9 100644
--- a/app/controllers/projects/runner_projects_controller.rb
+++ b/app/controllers/projects/runner_projects_controller.rb
@@ -3,7 +3,7 @@
class Projects::RunnerProjectsController < Projects::ApplicationController
before_action :authorize_admin_build!
- layout 'project_settings'
+ layout "project_settings"
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
@@ -15,7 +15,7 @@ class Projects::RunnerProjectsController < Projects::ApplicationController
if @runner.assign_to(project, current_user)
redirect_to path
else
- redirect_to path, alert: 'Failed adding runner to project'
+ redirect_to path, alert: "Failed adding runner to project"
end
end
diff --git a/app/controllers/projects/runners_controller.rb b/app/controllers/projects/runners_controller.rb
index 91f40b90aa8..b4a1dd378dc 100644
--- a/app/controllers/projects/runners_controller.rb
+++ b/app/controllers/projects/runners_controller.rb
@@ -4,10 +4,10 @@ class Projects::RunnersController < Projects::ApplicationController
before_action :authorize_admin_build!
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
- layout 'project_settings'
+ layout "project_settings"
def index
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-runners-settings")
end
def edit
@@ -15,9 +15,9 @@ class Projects::RunnersController < Projects::ApplicationController
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
- redirect_to project_runner_path(@project, @runner), notice: 'Runner was successfully updated.'
+ redirect_to project_runner_path(@project, @runner), notice: "Runner was successfully updated."
else
- render 'edit'
+ render "edit"
end
end
@@ -31,34 +31,34 @@ class Projects::RunnersController < Projects::ApplicationController
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
- redirect_to project_runners_path(@project), notice: 'Runner was successfully updated.'
+ redirect_to project_runners_path(@project), notice: "Runner was successfully updated."
else
- redirect_to project_runners_path(@project), alert: 'Runner was not updated.'
+ redirect_to project_runners_path(@project), alert: "Runner was not updated."
end
end
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
- redirect_to project_runners_path(@project), notice: 'Runner was successfully updated.'
+ redirect_to project_runners_path(@project), notice: "Runner was successfully updated."
else
- redirect_to project_runners_path(@project), alert: 'Runner was not updated.'
+ redirect_to project_runners_path(@project), alert: "Runner was not updated."
end
end
def show
- render 'shared/runners/show'
+ render "shared/runners/show"
end
def toggle_shared_runners
project.toggle!(:shared_runners_enabled)
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-runners-settings")
end
def toggle_group_runners
project.toggle_ci_cd_settings!(:group_runners_enabled)
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-runners-settings')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-runners-settings")
end
protected
diff --git a/app/controllers/projects/services_controller.rb b/app/controllers/projects/services_controller.rb
index f1c9d0d0f77..9ae486fca73 100644
--- a/app/controllers/projects/services_controller.rb
+++ b/app/controllers/projects/services_controller.rb
@@ -21,7 +21,7 @@ class Projects::ServicesController < Projects::ApplicationController
if @service.save(context: :manual_change)
redirect_to(project_settings_integrations_path(@project), notice: success_message)
else
- render 'edit'
+ render "edit"
end
end
@@ -43,13 +43,13 @@ class Projects::ServicesController < Projects::ApplicationController
if outcome[:success]
{}
else
- { error: true, message: 'Test failed.', service_response: outcome[:result].to_s, test_failed: true }
+ {error: true, message: "Test failed.", service_response: outcome[:result].to_s, test_failed: true}
end
else
- { error: true, message: 'Validations failed.', service_response: @service.errors.full_messages.join(','), test_failed: false }
+ {error: true, message: "Validations failed.", service_response: @service.errors.full_messages.join(","), test_failed: false}
end
rescue Gitlab::HTTP::BlockedUrlError => e
- { error: true, message: 'Test failed.', service_response: e.message, test_failed: true }
+ {error: true, message: "Test failed.", service_response: e.message, test_failed: true}
end
def success_message
diff --git a/app/controllers/projects/settings/ci_cd_controller.rb b/app/controllers/projects/settings/ci_cd_controller.rb
index f2f63e986bb..b9a4b3fe63a 100644
--- a/app/controllers/projects/settings/ci_cd_controller.rb
+++ b/app/controllers/projects/settings/ci_cd_controller.rb
@@ -19,7 +19,7 @@ module Projects
redirect_to project_settings_ci_cd_path(@project)
else
- render 'show'
+ render "show"
end
end
end
@@ -39,7 +39,7 @@ module Projects
def reset_registration_token
@project.reset_runners_token!
- flash[:notice] = 'New runners registration token has been generated!'
+ flash[:notice] = "New runners registration token has been generated!"
redirect_to namespace_project_settings_ci_cd_path
end
@@ -105,10 +105,10 @@ module Projects
end
def define_badges_variables
- @ref = params[:ref] || @project.default_branch || 'master'
+ @ref = params[:ref] || @project.default_branch || "master"
@badges = [Gitlab::Badge::Pipeline::Status,
- Gitlab::Badge::Coverage::Report]
+ Gitlab::Badge::Coverage::Report,]
@badges.map! do |badge|
badge.new(@project, @ref).metadata
diff --git a/app/controllers/projects/settings/operations_controller.rb b/app/controllers/projects/settings/operations_controller.rb
index 521ec2acebb..840f17134f2 100644
--- a/app/controllers/projects/settings/operations_controller.rb
+++ b/app/controllers/projects/settings/operations_controller.rb
@@ -15,10 +15,10 @@ module Projects
result = ::Projects::Operations::UpdateService.new(project, current_user, update_params).execute
if result[:status] == :success
- flash[:notice] = _('Your changes have been saved')
+ flash[:notice] = _("Your changes have been saved")
redirect_to project_settings_operations_path(@project)
else
- render 'show'
+ render "show"
end
end
@@ -35,7 +35,7 @@ module Projects
# overridden in EE
def permitted_project_params
- { error_tracking_setting_attributes: [:enabled, :api_url, :token] }
+ {error_tracking_setting_attributes: [:enabled, :api_url, :token]}
end
def check_license
diff --git a/app/controllers/projects/settings/repository_controller.rb b/app/controllers/projects/settings/repository_controller.rb
index ac3004d069f..7cf504eccf3 100644
--- a/app/controllers/projects/settings/repository_controller.rb
+++ b/app/controllers/projects/settings/repository_controller.rb
@@ -14,7 +14,7 @@ module Projects
@new_deploy_token = DeployTokens::CreateService.new(@project, current_user, deploy_token_params).execute
if @new_deploy_token.persisted?
- flash.now[:notice] = s_('DeployTokens|Your new project deploy token has been created.')
+ flash.now[:notice] = s_("DeployTokens|Your new project deploy token has been created.")
end
render_show
@@ -26,9 +26,9 @@ module Projects
if result[:status] == :success
RepositoryCleanupWorker.perform_async(project.id, current_user.id)
- flash[:notice] = _('Repository cleanup has started. You will receive an email once the cleanup operation is complete.')
+ flash[:notice] = _("Repository cleanup has started. You will receive an email once the cleanup operation is complete.")
else
- flash[:alert] = _('Failed to upload object map file')
+ flash[:alert] = _("Failed to upload object map file")
end
redirect_to project_settings_repository_path(project)
@@ -44,7 +44,7 @@ module Projects
define_protected_refs
remote_mirror
- render 'show'
+ render "show"
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -69,23 +69,23 @@ module Projects
{
create_access_levels: levels_for_dropdown,
push_access_levels: levels_for_dropdown,
- merge_access_levels: levels_for_dropdown
+ merge_access_levels: levels_for_dropdown,
}
end
def levels_for_dropdown
- roles = ProtectedRefAccess::HUMAN_ACCESS_LEVELS.map do |id, text|
- { id: id, text: text, before_divider: true }
- end
- { roles: roles }
+ roles = ProtectedRefAccess::HUMAN_ACCESS_LEVELS.map { |id, text|
+ {id: id, text: text, before_divider: true}
+ }
+ {roles: roles}
end
def protectable_tags_for_dropdown
- { open_tags: ProtectableDropdown.new(@project, :tags).hash }
+ {open_tags: ProtectableDropdown.new(@project, :tags).hash}
end
def protectable_branches_for_dropdown
- { open_branches: ProtectableDropdown.new(@project, :branches).hash }
+ {open_branches: ProtectableDropdown.new(@project, :branches).hash}
end
def load_gon_index
diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb
index 255f1f3569a..89f6c3e8613 100644
--- a/app/controllers/projects/snippets_controller.rb
+++ b/app/controllers/projects/snippets_controller.rb
@@ -69,7 +69,7 @@ class Projects::SnippetsController < Projects::ApplicationController
@discussions = @snippet.discussions
@notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes), @noteable)
- render 'show'
+ render "show"
end
format.json do
@@ -78,7 +78,7 @@ class Projects::SnippetsController < Projects::ApplicationController
format.js do
if @snippet.embeddable?
- render 'shared/snippets/show'
+ render "shared/snippets/show"
else
head :not_found
end
@@ -99,8 +99,8 @@ class Projects::SnippetsController < Projects::ApplicationController
def snippet
@snippet ||= @project.snippets.inc_relations_for_view.find(params[:id])
end
- alias_method :awardable, :snippet
- alias_method :spammable, :snippet
+ alias awardable snippet
+ alias spammable snippet
def spammable_path
project_snippet_path(@project, @snippet)
diff --git a/app/controllers/projects/tags_controller.rb b/app/controllers/projects/tags_controller.rb
index a17c050b696..9d07932bf32 100644
--- a/app/controllers/projects/tags_controller.rb
+++ b/app/controllers/projects/tags_controller.rb
@@ -25,7 +25,7 @@ class Projects::TagsController < Projects::ApplicationController
respond_to do |format|
format.html
- format.atom { render layout: 'xml.atom' }
+ format.atom { render layout: "xml.atom" }
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -51,7 +51,7 @@ class Projects::TagsController < Projects::ApplicationController
release_params = {
tag: params[:tag_name],
name: params[:tag_name],
- description: params[:release_description]
+ description: params[:release_description],
}
Releases::CreateService
@@ -66,7 +66,7 @@ class Projects::TagsController < Projects::ApplicationController
@error = result[:message]
@message = params[:message]
@release_description = params[:release_description]
- render action: 'new'
+ render action: "new"
end
end
diff --git a/app/controllers/projects/templates_controller.rb b/app/controllers/projects/templates_controller.rb
index 7ceea4e5b96..5edaf4726d4 100644
--- a/app/controllers/projects/templates_controller.rb
+++ b/app/controllers/projects/templates_controller.rb
@@ -14,7 +14,7 @@ class Projects::TemplatesController < Projects::ApplicationController
private
def get_template_class
- template_types = { issue: Gitlab::Template::IssueTemplate, merge_request: Gitlab::Template::MergeRequestTemplate }.with_indifferent_access
+ template_types = {issue: Gitlab::Template::IssueTemplate, merge_request: Gitlab::Template::MergeRequestTemplate}.with_indifferent_access
@template_type = template_types[params[:template_type]]
render json: [], status: :not_found unless @template_type
end
diff --git a/app/controllers/projects/tree_controller.rb b/app/controllers/projects/tree_controller.rb
index edebfc55c17..b3723f8c6d2 100644
--- a/app/controllers/projects/tree_controller.rb
+++ b/app/controllers/projects/tree_controller.rb
@@ -19,7 +19,7 @@ class Projects::TreeController < Projects::ApplicationController
if @repository.blob_at(@commit.id, @path)
return redirect_to(
project_blob_path(@project,
- File.join(@ref, @path))
+ File.join(@ref, @path))
)
elsif @path.present?
return render_404
@@ -50,7 +50,7 @@ class Projects::TreeController < Projects::ApplicationController
@dir_name = File.join(@path, params[:dir_name])
@commit_params = {
file_path: @dir_name,
- commit_message: params[:commit_message]
+ commit_message: params[:commit_message],
}
end
end
diff --git a/app/controllers/projects/triggers_controller.rb b/app/controllers/projects/triggers_controller.rb
index c7b4ebb2b24..e57dbe9c37c 100644
--- a/app/controllers/projects/triggers_controller.rb
+++ b/app/controllers/projects/triggers_controller.rb
@@ -6,32 +6,32 @@ class Projects::TriggersController < Projects::ApplicationController
before_action :authorize_admin_trigger!, only: [:edit, :update]
before_action :trigger, only: [:take_ownership, :edit, :update, :destroy]
- layout 'project_settings'
+ layout "project_settings"
def index
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-pipeline-triggers')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-pipeline-triggers")
end
def create
@trigger = project.triggers.create(trigger_params.merge(owner: current_user))
if @trigger.valid?
- flash[:notice] = 'Trigger was created successfully.'
+ flash[:notice] = "Trigger was created successfully."
else
- flash[:alert] = 'You could not create a new trigger.'
+ flash[:alert] = "You could not create a new trigger."
end
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-pipeline-triggers')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-pipeline-triggers")
end
def take_ownership
if trigger.update(owner: current_user)
- flash[:notice] = 'Trigger was re-assigned.'
+ flash[:notice] = "Trigger was re-assigned."
else
- flash[:alert] = 'You could not take ownership of trigger.'
+ flash[:alert] = "You could not take ownership of trigger."
end
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-pipeline-triggers')
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-pipeline-triggers")
end
def edit
@@ -39,7 +39,7 @@ class Projects::TriggersController < Projects::ApplicationController
def update
if trigger.update(trigger_params)
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-pipeline-triggers'), notice: 'Trigger was successfully updated.'
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-pipeline-triggers"), notice: "Trigger was successfully updated."
else
render action: "edit"
end
@@ -52,7 +52,7 @@ class Projects::TriggersController < Projects::ApplicationController
flash[:alert] = "Could not remove the trigger."
end
- redirect_to project_settings_ci_cd_path(@project, anchor: 'js-pipeline-triggers'), status: :found
+ redirect_to project_settings_ci_cd_path(@project, anchor: "js-pipeline-triggers"), status: :found
end
private
diff --git a/app/controllers/projects/uploads_controller.rb b/app/controllers/projects/uploads_controller.rb
index 4ffcc2ac805..ee2ca2eb3fd 100644
--- a/app/controllers/projects/uploads_controller.rb
+++ b/app/controllers/projects/uploads_controller.rb
@@ -6,7 +6,7 @@ class Projects::UploadsController < Projects::ApplicationController
# These will kick you out if you don't have access.
skip_before_action :project, :repository,
- if: -> { action_name == 'show' && image_or_video? }
+ if: -> { action_name == "show" && image_or_video? }
before_action :authorize_upload_file!, only: [:create, :authorize]
before_action :verify_workhorse_api!, only: [:authorize]
diff --git a/app/controllers/projects/variables_controller.rb b/app/controllers/projects/variables_controller.rb
index bb658bfcc19..1dedae56013 100644
--- a/app/controllers/projects/variables_controller.rb
+++ b/app/controllers/projects/variables_controller.rb
@@ -6,7 +6,7 @@ class Projects::VariablesController < Projects::ApplicationController
def show
respond_to do |format|
format.json do
- render status: :ok, json: { variables: VariableSerializer.new.represent(@project.variables) }
+ render status: :ok, json: {variables: VariableSerializer.new.represent(@project.variables)}
end
end
end
@@ -26,7 +26,7 @@ class Projects::VariablesController < Projects::ApplicationController
private
def render_variables
- render status: :ok, json: { variables: VariableSerializer.new.represent(@project.variables) }
+ render status: :ok, json: {variables: VariableSerializer.new.represent(@project.variables)}
end
def render_error
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb
index 88dd111132b..e0b7ac2db23 100644
--- a/app/controllers/projects/wikis_controller.rb
+++ b/app/controllers/projects/wikis_controller.rb
@@ -21,20 +21,20 @@ class Projects::WikisController < Projects::ApplicationController
end
def show
- view_param = @project_wiki.empty? ? params[:view] : 'create'
+ view_param = @project_wiki.empty? ? params[:view] : "create"
if @page
set_encoding_error unless valid_encoding?
- render 'show'
+ render "show"
elsif file_blob
send_blob(@project_wiki.repository, file_blob)
- elsif can?(current_user, :create_wiki, @project) && view_param == 'create'
+ elsif can?(current_user, :create_wiki, @project) && view_param == "create"
@page = build_page(title: params[:id])
- render 'edit'
+ render "edit"
else
- render 'empty'
+ render "empty"
end
end
@@ -42,21 +42,21 @@ class Projects::WikisController < Projects::ApplicationController
end
def update
- return render('empty') unless can?(current_user, :create_wiki, @project)
+ return render("empty") unless can?(current_user, :create_wiki, @project)
@page = WikiPages::UpdateService.new(@project, current_user, wiki_params).execute(@page)
if @page.valid?
redirect_to(
project_wiki_path(@project, @page),
- notice: 'Wiki was successfully updated.'
+ notice: "Wiki was successfully updated."
)
else
- render 'edit'
+ render "edit"
end
rescue WikiPage::PageChangedError, WikiPage::PageRenameError, Gitlab::Git::Wiki::OperationError => e
@error = e
- render 'edit'
+ render "edit"
end
def create
@@ -65,7 +65,7 @@ class Projects::WikisController < Projects::ApplicationController
if @page.persisted?
redirect_to(
project_wiki_path(@project, @page),
- notice: 'Wiki was successfully updated.'
+ notice: "Wiki was successfully updated."
)
else
render action: "edit"
@@ -74,13 +74,13 @@ class Projects::WikisController < Projects::ApplicationController
@page = build_page(wiki_params)
@error = e
- render 'edit'
+ render "edit"
end
def history
if @page
@page_versions = Kaminari.paginate_array(@page.versions(page: params[:page].to_i),
- total_count: @page.count_versions)
+ total_count: @page.count_versions)
.page(params[:page])
else
redirect_to(
@@ -94,11 +94,11 @@ class Projects::WikisController < Projects::ApplicationController
WikiPages::DestroyService.new(@project, current_user).execute(@page)
redirect_to project_wiki_path(@project, :home),
- status: 302,
- notice: "Page was successfully deleted"
+ status: 302,
+ notice: "Page was successfully deleted"
rescue Gitlab::Git::Wiki::OperationError => e
@error = e
- render 'edit'
+ render "edit"
end
def git_access
@@ -143,7 +143,7 @@ class Projects::WikisController < Projects::ApplicationController
def page_params
keys = [:id]
- keys << :version_id if params[:action] == 'show'
+ keys << :version_id if params[:action] == "show"
params.values_at(*keys)
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 33c6608d321..0f346146e1d 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -43,21 +43,21 @@ class ProjectsController < Projects::ApplicationController
def edit
@badge_api_endpoint = expose_url(api_v4_projects_badges_path(id: @project.id))
- render 'edit'
+ render "edit"
end
def create
@project = ::Projects::CreateService.new(current_user, project_params).execute
if @project.saved?
- cookies[:issue_board_welcome_hidden] = { path: project_path(@project), value: nil, expires: Time.at(0) }
+ cookies[:issue_board_welcome_hidden] = {path: project_path(@project), value: nil, expires: Time.at(0)}
redirect_to(
project_path(@project, custom_import_params),
- notice: _("Project '%{project_name}' was successfully created.") % { project_name: @project.name }
+ notice: _("Project '%{project_name}' was successfully created.") % {project_name: @project.name}
)
else
- render 'new', locals: { active_tab: active_new_project_tab }
+ render "new", locals: {active_tab: active_new_project_tab}
end
end
@@ -69,15 +69,15 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format|
if result[:status] == :success
- flash[:notice] = _("Project '%{project_name}' was successfully updated.") % { project_name: @project.name }
+ flash[:notice] = _("Project '%{project_name}' was successfully updated.") % {project_name: @project.name}
format.html do
- redirect_to(edit_project_path(@project, anchor: 'js-general-project-settings'))
+ redirect_to(edit_project_path(@project, anchor: "js-general-project-settings"))
end
else
flash.now[:alert] = result[:message]
- format.html { render 'edit' }
+ format.html { render "edit" }
end
format.js
@@ -101,7 +101,7 @@ class ProjectsController < Projects::ApplicationController
return access_denied! unless can?(current_user, :remove_fork_project, @project)
if ::Projects::UnlinkForkService.new(@project, current_user).execute
- flash[:notice] = _('The fork relationship has been removed.')
+ flash[:notice] = _("The fork relationship has been removed.")
end
end
@@ -110,7 +110,7 @@ class ProjectsController < Projects::ApplicationController
format.html
format.json do
load_events
- pager_json('events/_events', @events.count)
+ pager_json("events/_events", @events.count)
end
end
end
@@ -122,7 +122,7 @@ class ProjectsController < Projects::ApplicationController
end
if @project.pending_delete?
- flash.now[:alert] = _("Project '%{project_name}' queued for deletion.") % { project_name: @project.name }
+ flash.now[:alert] = _("Project '%{project_name}' queued for deletion.") % {project_name: @project.name}
end
respond_to do |format|
@@ -135,7 +135,7 @@ class ProjectsController < Projects::ApplicationController
format.atom do
load_events
- render layout: 'xml.atom'
+ render layout: "xml.atom"
end
end
end
@@ -144,7 +144,7 @@ class ProjectsController < Projects::ApplicationController
return access_denied! unless can?(current_user, :remove_project, @project)
::Projects::DestroyService.new(@project, current_user, {}).async_execute
- flash[:notice] = _("Project '%{project_name}' is in the process of being deleted.") % { project_name: @project.full_name }
+ flash[:notice] = _("Project '%{project_name}' is in the process of being deleted.") % {project_name: @project.full_name}
redirect_to dashboard_projects_path, status: :found
rescue Projects::DestroyService::DestroyError => ex
@@ -155,7 +155,7 @@ class ProjectsController < Projects::ApplicationController
return render_404 unless Gitlab::IncomingEmail.supports_issue_creation?
current_user.reset_incoming_email_token!
- render json: { new_address: @project.new_issuable_address(current_user, params[:issuable_type]) }
+ render json: {new_address: @project.new_issuable_address(current_user, params[:issuable_type])}
end
def archive
@@ -187,7 +187,7 @@ class ProjectsController < Projects::ApplicationController
)
rescue ::Projects::HousekeepingService::LeaseTaken => ex
redirect_to(
- edit_project_path(@project, anchor: 'js-project-advanced-settings'),
+ edit_project_path(@project, anchor: "js-project-advanced-settings"),
alert: ex.to_s
)
end
@@ -196,7 +196,7 @@ class ProjectsController < Projects::ApplicationController
@project.add_export_job(current_user: current_user)
redirect_to(
- edit_project_path(@project, anchor: 'js-export-project'),
+ edit_project_path(@project, anchor: "js-export-project"),
notice: _("Project export started. A download link will be sent by email.")
)
end
@@ -206,7 +206,7 @@ class ProjectsController < Projects::ApplicationController
send_upload(@project.export_file, attachment: @project.export_file.filename)
else
redirect_to(
- edit_project_path(@project, anchor: 'js-export-project'),
+ edit_project_path(@project, anchor: "js-export-project"),
alert: _("Project export link has expired. Please generate a new export from your project settings.")
)
end
@@ -219,7 +219,7 @@ class ProjectsController < Projects::ApplicationController
flash[:alert] = _("Project export could not be deleted.")
end
- redirect_to(edit_project_path(@project, anchor: 'js-export-project'))
+ redirect_to(edit_project_path(@project, anchor: "js-export-project"))
end
def generate_new_export
@@ -227,7 +227,7 @@ class ProjectsController < Projects::ApplicationController
export
else
redirect_to(
- edit_project_path(@project, anchor: 'js-export-project'),
+ edit_project_path(@project, anchor: "js-export-project"),
alert: _("Project export could not be deleted.")
)
end
@@ -238,41 +238,41 @@ class ProjectsController < Projects::ApplicationController
@project.reload
render json: {
- star_count: @project.star_count
+ star_count: @project.star_count,
}
end
# rubocop: disable CodeReuse/ActiveRecord
def refs
- find_refs = params['find']
+ find_refs = params["find"]
find_branches = true
find_tags = true
find_commits = true
unless find_refs.nil?
- find_branches = find_refs.include?('branches')
- find_tags = find_refs.include?('tags')
- find_commits = find_refs.include?('commits')
+ find_branches = find_refs.include?("branches")
+ find_tags = find_refs.include?("tags")
+ find_commits = find_refs.include?("commits")
end
options = {}
if find_branches
branches = BranchesFinder.new(@repository, params).execute.take(100).map(&:name)
- options['Branches'] = branches
+ options["Branches"] = branches
end
if find_tags && @repository.tag_count.nonzero?
tags = TagsFinder.new(@repository, params).execute.take(100).map(&:name)
- options['Tags'] = tags
+ options["Tags"] = tags
end
# If reference is commit id - we should add it to branch/tag selectbox
ref = Addressable::URI.unescape(params[:ref])
if find_commits && ref && options.flatten(2).exclude?(ref) && ref =~ /\A[0-9a-zA-Z]{6,52}\z/
- options['Commits'] = [ref]
+ options["Commits"] = [ref]
end
render json: options.to_json
@@ -285,16 +285,16 @@ class ProjectsController < Projects::ApplicationController
# pages list order: repository readme, wiki home, issues list, customize workflow
def render_landing_page
if can?(current_user, :download_code, @project)
- return render 'projects/no_repo' unless @project.repository_exists?
+ return render "projects/no_repo" unless @project.repository_exists?
- render 'projects/empty' if @project.empty_repo?
+ render "projects/empty" if @project.empty_repo?
else
if can?(current_user, :read_wiki, @project)
@project_wiki = @project.wiki
- @wiki_home = @project_wiki.find_page('home', params[:version_id])
+ @wiki_home = @project_wiki.find_page("home", params[:version_id])
elsif @project.feature_available?(:issues, current_user)
@issues = issuables_collection.page(params[:page])
- @collection_type = 'Issue'
+ @collection_type = "Issue"
@issuable_meta_data = issuable_meta_data(@issues, @collection_type)
end
@@ -308,11 +308,11 @@ class ProjectsController < Projects::ApplicationController
def determine_layout
if [:new, :create].include?(action_name.to_sym)
- 'application'
+ "application"
elsif [:edit, :update].include?(action_name.to_sym)
- 'project_settings'
+ "project_settings"
else
- 'project'
+ "project"
end
end
@@ -371,7 +371,7 @@ class ProjectsController < Projects::ApplicationController
snippets_access_level
wiki_access_level
pages_access_level
- ]
+ ],
]
end
@@ -380,12 +380,11 @@ class ProjectsController < Projects::ApplicationController
end
def active_new_project_tab
- project_params[:import_url].present? ? 'import' : 'blank'
+ project_params[:import_url].present? ? "import" : "blank"
end
def repo_exists?
project.repository_exists? && !project.empty_repo?
-
rescue Gitlab::Git::Repository::NoRepository
project.repository.expire_exists_cache
@@ -394,7 +393,7 @@ class ProjectsController < Projects::ApplicationController
def project_view_files?
if current_user
- current_user.project_view == 'files'
+ current_user.project_view == "files"
else
project_view_files_allowed?
end
@@ -404,7 +403,7 @@ class ProjectsController < Projects::ApplicationController
# for the blob/tree, which in this case is just the root of the default branch.
# This way we avoid to access the repository.ref_names.
def extract_ref(_id)
- [get_id, '']
+ [get_id, ""]
end
# Override get_id from ExtractsPath in this case is just the root of the default branch.
@@ -433,11 +432,11 @@ class ProjectsController < Projects::ApplicationController
# to
# localhost/group/project
#
- redirect_to request.original_url.sub(%r{\.git/?\Z}, '') if params[:format] == 'git'
+ redirect_to request.original_url.sub(%r{\.git/?\Z}, "") if params[:format] == "git"
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42440')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42440")
end
def present_project
diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb
index 8b8d87524a8..1a034f2400c 100644
--- a/app/controllers/registrations_controller.rb
+++ b/app/controllers/registrations_controller.rb
@@ -6,8 +6,8 @@ class RegistrationsController < Devise::RegistrationsController
before_action :whitelist_query_limiting, only: [:destroy]
before_action :ensure_terms_accepted,
- if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms? },
- only: [:create]
+ if: -> { Gitlab::CurrentSettings.current_application_settings.enforce_terms? },
+ only: [:create]
def new
redirect_to(new_user_session_path)
@@ -27,9 +27,9 @@ class RegistrationsController < Devise::RegistrationsController
persist_accepted_terms_if_required(new_user)
end
else
- flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ flash[:alert] = "There was an error with the reCAPTCHA. Please solve the reCAPTCHA again."
flash.delete :recaptcha_error
- render action: 'new'
+ render action: "new"
end
rescue Gitlab::Access::AccessDeniedError
redirect_to(new_user_session_path)
@@ -39,7 +39,7 @@ class RegistrationsController < Devise::RegistrationsController
if destroy_confirmation_valid?
current_user.delete_async(deleted_by: current_user)
session.try(:destroy)
- redirect_to new_user_session_path, status: 303, notice: s_('Profiles|Account scheduled for removal.')
+ redirect_to new_user_session_path, status: 303, notice: s_("Profiles|Account scheduled for removal.")
else
redirect_to profile_account_path, status: 303, alert: destroy_confirmation_failure_message
end
@@ -67,9 +67,9 @@ class RegistrationsController < Devise::RegistrationsController
def destroy_confirmation_failure_message
if current_user.confirm_deletion_with_password?
- s_('Profiles|Invalid password')
+ s_("Profiles|Invalid password")
else
- s_('Profiles|Invalid username')
+ s_("Profiles|Invalid username")
end
end
@@ -106,13 +106,13 @@ class RegistrationsController < Devise::RegistrationsController
end
def whitelist_query_limiting
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42380')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42380")
end
def ensure_terms_accepted
return if terms_accepted?
- redirect_to new_user_session_path, alert: _('You must accept our Terms of Service and privacy policy in order to register an account')
+ redirect_to new_user_session_path, alert: _("You must accept our Terms of Service and privacy policy in order to register an account")
end
def terms_accepted?
diff --git a/app/controllers/root_controller.rb b/app/controllers/root_controller.rb
index 7b6657e1196..304dacfcc98 100644
--- a/app/controllers/root_controller.rb
+++ b/app/controllers/root_controller.rb
@@ -33,20 +33,20 @@ class RootController < Dashboard::ProjectsController
def redirect_logged_user
case current_user.dashboard
- when 'stars'
+ when "stars"
flash.keep
redirect_to(starred_dashboard_projects_path)
- when 'project_activity'
+ when "project_activity"
redirect_to(activity_dashboard_path)
- when 'starred_project_activity'
- redirect_to(activity_dashboard_path(filter: 'starred'))
- when 'groups'
+ when "starred_project_activity"
+ redirect_to(activity_dashboard_path(filter: "starred"))
+ when "groups"
redirect_to(dashboard_groups_path)
- when 'todos'
+ when "todos"
redirect_to(dashboard_todos_path)
- when 'issues'
+ when "issues"
redirect_to(issues_dashboard_path(assignee_username: current_user.username))
- when 'merge_requests'
+ when "merge_requests"
redirect_to(merge_requests_dashboard_path(assignee_username: current_user.username))
end
end
@@ -56,8 +56,8 @@ class RootController < Dashboard::ProjectsController
# Don't redirect to the default URL to prevent endless redirections
return false unless Gitlab::CurrentSettings.home_page_url.present?
- home_page_url = Gitlab::CurrentSettings.home_page_url.chomp('/')
- root_urls = [Gitlab.config.gitlab['url'].chomp('/'), root_url.chomp('/')]
+ home_page_url = Gitlab::CurrentSettings.home_page_url.chomp("/")
+ root_urls = [Gitlab.config.gitlab["url"].chomp("/"), root_url.chomp("/")]
root_urls.exclude?(home_page_url)
end
diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb
index 1b22907c10f..3e84b5b121a 100644
--- a/app/controllers/search_controller.rb
+++ b/app/controllers/search_controller.rb
@@ -11,7 +11,7 @@ class SearchController < ApplicationController
search_term_present && !params[:project_id].present?
end
- layout 'search'
+ layout "search"
def show
search_service = SearchService.new(current_user, params)
@@ -28,7 +28,7 @@ class SearchController < ApplicationController
@search_results = search_service.search_results
@search_objects = search_service.search_objects
- render_commits if @scope == 'commits'
+ render_commits if @scope == "commits"
check_single_commit_result
end
@@ -56,7 +56,7 @@ class SearchController < ApplicationController
def check_single_commit_result
if @search_results.single_commit_result?
- only_commit = @search_results.objects('commits').first
+ only_commit = @search_results.objects("commits").first
query = params[:search].strip.downcase
found_by_commit_sha = Commit.valid_hash?(query) && only_commit.sha.start_with?(query)
diff --git a/app/controllers/sent_notifications_controller.rb b/app/controllers/sent_notifications_controller.rb
index 2b76921ebd8..baaf8636f5a 100644
--- a/app/controllers/sent_notifications_controller.rb
+++ b/app/controllers/sent_notifications_controller.rb
@@ -6,7 +6,7 @@ class SentNotificationsController < ApplicationController
def unsubscribe
@sent_notification = SentNotification.for(params[:id])
- return render_404 unless @sent_notification && @sent_notification.unsubscribable?
+ return render_404 unless @sent_notification&.unsubscribable?
return unsubscribe_and_redirect if current_user || params[:force]
end
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 4bd7d71e264..fff5e72f96f 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -22,7 +22,7 @@ class SessionsController < Devise::SessionsController
helper_method :captcha_enabled?
- CAPTCHA_HEADER = 'X-GitLab-Show-Login-Captcha'.freeze
+ CAPTCHA_HEADER = "X-GitLab-Show-Login-Captcha"
def new
set_minimum_password_length
@@ -70,7 +70,7 @@ class SessionsController < Devise::SessionsController
increment_failed_login_captcha_counter
self.resource = resource_class.new
- flash[:alert] = 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ flash[:alert] = "There was an error with the reCAPTCHA. Please solve the reCAPTCHA again."
flash.delete :recaptcha_error
respond_with_navigational(resource) { render :new }
@@ -80,14 +80,14 @@ class SessionsController < Devise::SessionsController
def increment_failed_login_captcha_counter
Gitlab::Metrics.counter(
:failed_login_captcha_total,
- 'Number of failed CAPTCHA attempts for logins'.freeze
+ "Number of failed CAPTCHA attempts for logins"
).increment
end
def increment_successful_login_captcha_counter
Gitlab::Metrics.counter(
:successful_login_captcha_total,
- 'Number of successful CAPTCHA attempts for logins'.freeze
+ "Number of successful CAPTCHA attempts for logins"
).increment
end
@@ -96,7 +96,7 @@ class SessionsController < Devise::SessionsController
# leaving this method here because of backwards compatibility.
#
def login_counter
- @login_counter ||= Gitlab::Metrics.counter(:user_session_logins_total, 'User sign in count')
+ @login_counter ||= Gitlab::Metrics.counter(:user_session_logins_total, "User sign in count")
end
def log_failed_login
@@ -115,7 +115,7 @@ class SessionsController < Devise::SessionsController
user = User.admins.last
- return unless user && user.require_password_creation_for_web?
+ return unless user&.require_password_creation_for_web?
Users::UpdateService.new(current_user, user: user).execute do |user|
@token = user.generate_reset_token
@@ -144,7 +144,7 @@ class SessionsController < Devise::SessionsController
def store_redirect_uri
redirect_uri =
- if request.referer.present? && (params['redirect_to_referer'] == 'yes')
+ if request.referer.present? && (params["redirect_to_referer"] == "yes")
URI(request.referer)
else
URI(request.url)
@@ -177,7 +177,7 @@ class SessionsController < Devise::SessionsController
# Auto sign in with an Omniauth provider only if the standard "you need to sign-in" alert is
# registered or no alert at all. In case of another alert (such as a blocked user), it is safer
# to do nothing to prevent redirection loops with certain Omniauth providers.
- return unless flash[:alert].blank? || flash[:alert] == I18n.t('devise.failure.unauthenticated')
+ return unless flash[:alert].blank? || flash[:alert] == I18n.t("devise.failure.unauthenticated")
# Prevent alert from popping up on the first page shown after authentication.
flash[:alert] = nil
@@ -198,7 +198,7 @@ class SessionsController < Devise::SessionsController
def log_user_activity(user)
login_counter.increment
- Users::ActivityService.new(user, 'login').execute
+ Users::ActivityService.new(user, "login").execute
end
def load_recaptcha
diff --git a/app/controllers/sherlock/transactions_controller.rb b/app/controllers/sherlock/transactions_controller.rb
index 8d1847507cc..a6289af198b 100644
--- a/app/controllers/sherlock/transactions_controller.rb
+++ b/app/controllers/sherlock/transactions_controller.rb
@@ -15,7 +15,7 @@ module Sherlock
def destroy_all
Gitlab::Sherlock.collection.clear
- redirect_back_or_default(options: { status: :found })
+ redirect_back_or_default(options: {status: :found})
end
end
end
diff --git a/app/controllers/snippets/notes_controller.rb b/app/controllers/snippets/notes_controller.rb
index eee14b0faf4..ae1018f06c5 100644
--- a/app/controllers/snippets/notes_controller.rb
+++ b/app/controllers/snippets/notes_controller.rb
@@ -13,7 +13,7 @@ class Snippets::NotesController < ApplicationController
def note
@note ||= snippet.notes.inc_relations_for_view.find(params[:id])
end
- alias_method :awardable, :note
+ alias awardable note
def project
nil
@@ -24,10 +24,10 @@ class Snippets::NotesController < ApplicationController
PersonalSnippet.find_by(id: params[:snippet_id])
end
# rubocop: enable CodeReuse/ActiveRecord
- alias_method :noteable, :snippet
+ alias noteable snippet
def finder_params
- params.merge(last_fetched_at: last_fetched_at, target_id: snippet.id, target_type: 'personal_snippet')
+ params.merge(last_fetched_at: last_fetched_at, target_id: snippet.id, target_type: "personal_snippet")
end
def authorize_read_snippet!
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb
index 8ea5450b4e8..bc8923703d2 100644
--- a/app/controllers/snippets_controller.rb
+++ b/app/controllers/snippets_controller.rb
@@ -23,7 +23,7 @@ class SnippetsController < ApplicationController
skip_before_action :authenticate_user!, only: [:index, :show, :raw]
- layout 'snippets'
+ layout "snippets"
respond_to :html
def index
@@ -33,7 +33,7 @@ class SnippetsController < ApplicationController
@snippets = SnippetsFinder.new(current_user, author: @user, scope: params[:scope])
.execute.page(params[:page])
- render 'index'
+ render "index"
else
redirect_to(current_user ? dashboard_snippets_path : explore_snippets_path)
end
@@ -73,7 +73,7 @@ class SnippetsController < ApplicationController
respond_to do |format|
format.html do
- render 'show'
+ render "show"
end
format.json do
@@ -82,7 +82,7 @@ class SnippetsController < ApplicationController
format.js do
if @snippet.embeddable?
- render 'shared/snippets/show'
+ render "shared/snippets/show"
else
head :not_found
end
@@ -106,8 +106,8 @@ class SnippetsController < ApplicationController
end
# rubocop: enable CodeReuse/ActiveRecord
- alias_method :awardable, :snippet
- alias_method :spammable, :snippet
+ alias awardable snippet
+ alias spammable snippet
def spammable_path
snippet_path(@snippet)
diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb
index 519e7439205..bc9c229ce00 100644
--- a/app/controllers/uploads_controller.rb
+++ b/app/controllers/uploads_controller.rb
@@ -6,13 +6,13 @@ class UploadsController < ApplicationController
UnknownUploadModelError = Class.new(StandardError)
MODEL_CLASSES = {
- "user" => User,
- "project" => Project,
- "note" => Note,
- "group" => Group,
- "appearance" => Appearance,
+ "user" => User,
+ "project" => Project,
+ "note" => Note,
+ "group" => Group,
+ "appearance" => Appearance,
"personal_snippet" => PersonalSnippet,
- nil => PersonalSnippet
+ nil => PersonalSnippet,
}.freeze
rescue_from UnknownUploadModelError, with: :render_404
@@ -85,6 +85,6 @@ class UploadsController < ApplicationController
def upload_mount_satisfied?
return true unless upload_model_class_has_mounts?
- upload_model_class.uploader_options.has_key?(upload_mount)
+ upload_model_class.uploader_options.key?(upload_mount)
end
end
diff --git a/app/controllers/users/terms_controller.rb b/app/controllers/users/terms_controller.rb
index 3c16d934b4d..8ff5bcb8b8a 100644
--- a/app/controllers/users/terms_controller.rb
+++ b/app/controllers/users/terms_controller.rb
@@ -12,7 +12,7 @@ module Users
before_action :terms
- layout 'terms'
+ layout "terms"
def index
@redirect = redirect_path
@@ -24,25 +24,25 @@ module Users
def accept
agreement = Users::RespondToTermsService.new(current_user, viewed_term)
- .execute(accepted: true)
+ .execute(accepted: true)
if agreement.persisted?
redirect_to redirect_path
else
- flash[:alert] = agreement.errors.full_messages.join(', ')
+ flash[:alert] = agreement.errors.full_messages.join(", ")
redirect_to terms_path, redirect: redirect_path
end
end
def decline
agreement = Users::RespondToTermsService.new(current_user, viewed_term)
- .execute(accepted: false)
+ .execute(accepted: false)
if agreement.persisted?
sign_out(current_user)
redirect_to root_path
else
- flash[:alert] = agreement.errors.full_messages.join(', ')
+ flash[:alert] = agreement.errors.full_messages.join(", ")
redirect_to terms_path, redirect: redirect_path
end
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 072d62ddf38..2e3dcb63f46 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -17,7 +17,7 @@ class UsersController < ApplicationController
prepend_before_action(only: [:show]) { authenticate_sessionless_user!(:rss) }
before_action :user, except: [:exists]
before_action :authorize_read_user_profile!,
- only: [:calendar, :calendar_activities, :groups, :projects, :contributed_projects, :snippets]
+ only: [:calendar, :calendar_activities, :groups, :projects, :contributed_projects, :snippets]
def show
respond_to do |format|
@@ -25,7 +25,7 @@ class UsersController < ApplicationController
format.atom do
load_events
- render layout: 'xml.atom'
+ render layout: "xml.atom"
end
format.json do
@@ -37,7 +37,7 @@ class UsersController < ApplicationController
def activity
respond_to do |format|
- format.html { render 'show' }
+ format.html { render "show" }
end
end
@@ -45,10 +45,10 @@ class UsersController < ApplicationController
load_groups
respond_to do |format|
- format.html { render 'show' }
+ format.html { render "show" }
format.json do
render json: {
- html: view_to_html_string("shared/groups/_list", groups: @groups)
+ html: view_to_html_string("shared/groups/_list", groups: @groups),
}
end
end
@@ -62,7 +62,7 @@ class UsersController < ApplicationController
compact_mode = Gitlab::Utils.to_boolean(params[:compact_mode])
respond_to do |format|
- format.html { render 'show' }
+ format.html { render "show" }
format.json do
pager_json("shared/projects/_list", @projects.count, projects: @projects, skip_pagination: skip_pagination, skip_namespace: skip_namespace, compact_mode: compact_mode)
end
@@ -73,10 +73,10 @@ class UsersController < ApplicationController
load_contributed_projects
respond_to do |format|
- format.html { render 'show' }
+ format.html { render "show" }
format.json do
render json: {
- html: view_to_html_string("shared/projects/_list", projects: @contributed_projects)
+ html: view_to_html_string("shared/projects/_list", projects: @contributed_projects),
}
end
end
@@ -86,10 +86,10 @@ class UsersController < ApplicationController
load_snippets
respond_to do |format|
- format.html { render 'show' }
+ format.html { render "show" }
format.json do
render json: {
- html: view_to_html_string("snippets/_snippets", collection: @snippets)
+ html: view_to_html_string("snippets/_snippets", collection: @snippets),
}
end
end
@@ -100,14 +100,18 @@ class UsersController < ApplicationController
end
def calendar_activities
- @calendar_date = Date.parse(params[:date]) rescue Date.today
+ @calendar_date = begin
+ Date.parse(params[:date])
+ rescue
+ Date.today
+ end
@events = contributions_calendar.events_by_date(@calendar_date)
- render 'calendar_activities', layout: false
+ render "calendar_activities", layout: false
end
def exists
- render json: { exists: !!Namespace.find_by_path_or_name(params[:username]) }
+ render json: {exists: !!Namespace.find_by_path_or_name(params[:username])}
end
private
@@ -133,8 +137,8 @@ class UsersController < ApplicationController
def load_projects
@projects =
PersonalProjectsFinder.new(user).execute(current_user)
- .page(params[:page])
- .per(params[:limit])
+ .page(params[:page])
+ .per(params[:limit])
prepare_projects_for_rendering(@projects)
end
diff --git a/app/finders/admin/projects_finder.rb b/app/finders/admin/projects_finder.rb
index e2b9b0b44c1..c4764671204 100644
--- a/app/finders/admin/projects_finder.rb
+++ b/app/finders/admin/projects_finder.rb
@@ -51,7 +51,7 @@ class Admin::ProjectsFinder
# rubocop: enable CodeReuse/ActiveRecord
def by_archived(items)
- if params[:archived] == 'only'
+ if params[:archived] == "only"
items.archived
elsif params[:archived].blank?
items.non_archived
@@ -69,7 +69,7 @@ class Admin::ProjectsFinder
end
def sort(items)
- sort = params.fetch(:sort) { 'latest_activity_desc' }
+ sort = params.fetch(:sort) { "latest_activity_desc" }
items.sort_by_attribute(sort)
end
end
diff --git a/app/finders/admin/runners_finder.rb b/app/finders/admin/runners_finder.rb
index b2799565f57..b8533436dcf 100644
--- a/app/finders/admin/runners_finder.rb
+++ b/app/finders/admin/runners_finder.rb
@@ -19,10 +19,10 @@ class Admin::RunnersFinder < UnionFinder
end
def sort_key
- if @params[:sort] == 'contacted_asc'
- 'contacted_asc'
+ if @params[:sort] == "contacted_asc"
+ "contacted_asc"
else
- 'created_date'
+ "created_date"
end
end
diff --git a/app/finders/autocomplete/users_finder.rb b/app/finders/autocomplete/users_finder.rb
index 45955783be9..47af42ddc11 100644
--- a/app/finders/autocomplete/users_finder.rb
+++ b/app/finders/autocomplete/users_finder.rb
@@ -9,8 +9,8 @@ module Autocomplete
LIMIT = 20
attr_reader :current_user, :project, :group, :search, :skip_users,
- :author_id, :todo_filter, :todo_state_filter,
- :filter_by_current_user
+ :author_id, :todo_filter, :todo_state_filter,
+ :filter_by_current_user
def initialize(params:, current_user:, project:, group:)
@current_user = current_user
diff --git a/app/finders/awarded_emoji_finder.rb b/app/finders/awarded_emoji_finder.rb
index f0cc17f3b26..57e1ad0d305 100644
--- a/app/finders/awarded_emoji_finder.rb
+++ b/app/finders/awarded_emoji_finder.rb
@@ -16,6 +16,6 @@ class AwardedEmojiFinder
# in descending order, based on how often they were awarded.
AwardEmoji
.award_counts_for_user(current_user)
- .map { |name, _| { name: name } }
+ .map { |name, _| {name: name} }
end
end
diff --git a/app/finders/branches_finder.rb b/app/finders/branches_finder.rb
index 45d5591e81b..4beed0691ed 100644
--- a/app/finders/branches_finder.rb
+++ b/app/finders/branches_finder.rb
@@ -21,16 +21,16 @@ class BranchesFinder
end
def sort
- @params[:sort].presence || 'name'
+ @params[:sort].presence || "name"
end
def by_search(branches)
return branches unless search
case search
- when ->(v) { v.starts_with?('^') }
+ when ->(v) { v.starts_with?("^") }
filter_branches_with_prefix(branches, search.slice(1..-1).upcase)
- when ->(v) { v.ends_with?('$') }
+ when ->(v) { v.ends_with?("$") }
filter_branches_with_suffix(branches, search.chop.upcase)
else
matches = filter_branches_by_name(branches, search.upcase)
diff --git a/app/finders/concerns/custom_attributes_filter.rb b/app/finders/concerns/custom_attributes_filter.rb
index 825c3a6b5b7..261a8de1634 100644
--- a/app/finders/concerns/custom_attributes_filter.rb
+++ b/app/finders/concerns/custom_attributes_filter.rb
@@ -10,14 +10,14 @@ module CustomAttributesFilter
attributes_table = association.klass.arel_table
attributable_table = items.model.arel_table
- custom_attributes = association.klass.select('true').where(
+ custom_attributes = association.klass.select("true").where(
attributes_table[association.foreign_key]
.eq(attributable_table[association.association_primary_key])
)
# perform a subquery for each attribute to be filtered
params[:custom_attributes].inject(items) do |scope, (key, value)|
- scope.where('EXISTS (?)', custom_attributes.where(key: key, value: value))
+ scope.where("EXISTS (?)", custom_attributes.where(key: key, value: value))
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/finders/concerns/finder_methods.rb b/app/finders/concerns/finder_methods.rb
index 8de3276184d..78ee8fbf573 100644
--- a/app/finders/concerns/finder_methods.rb
+++ b/app/finders/concerns/finder_methods.rb
@@ -34,8 +34,6 @@ module FinderMethods
if can_read_object?(result)
result
- else
- nil
end
end
diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb
index 419be46fafe..262cfcdabcc 100644
--- a/app/finders/environments_finder.rb
+++ b/app/finders/environments_finder.rb
@@ -12,7 +12,7 @@ class EnvironmentsFinder
deployments = project.deployments
deployments =
if ref
- deployments_query = params[:with_tags] ? 'ref = :ref OR tag IS TRUE' : 'ref = :ref'
+ deployments_query = params[:with_tags] ? "ref = :ref OR tag IS TRUE" : "ref = :ref"
deployments.where(deployments_query, ref: ref.to_s)
elsif commit
deployments.where(sha: commit.sha)
diff --git a/app/finders/events_finder.rb b/app/finders/events_finder.rb
index 234b7090fd9..9be9431f9ca 100644
--- a/app/finders/events_finder.rb
+++ b/app/finders/events_finder.rb
@@ -74,7 +74,7 @@ class EventsFinder
def by_created_at_before(events)
return events unless params[:before]
- events.where('events.created_at < ?', params[:before].beginning_of_day)
+ events.where("events.created_at < ?", params[:before].beginning_of_day)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -82,14 +82,14 @@ class EventsFinder
def by_created_at_after(events)
return events unless params[:after]
- events.where('events.created_at > ?', params[:after].end_of_day)
+ events.where("events.created_at > ?", params[:after].end_of_day)
end
# rubocop: enable CodeReuse/ActiveRecord
def sort(events)
return events unless params[:sort]
- if params[:sort] == 'asc'
+ if params[:sort] == "asc"
events.order_id_asc
else
events.order_id_desc
diff --git a/app/finders/group_descendants_finder.rb b/app/finders/group_descendants_finder.rb
index ec340f38450..a82805ff0af 100644
--- a/app/finders/group_descendants_finder.rb
+++ b/app/finders/group_descendants_finder.rb
@@ -65,8 +65,8 @@ class GroupDescendantsFinder
def direct_child_groups
# rubocop: disable CodeReuse/Finder
GroupsFinder.new(current_user,
- parent: parent_group,
- all_available: true).execute
+ parent: parent_group,
+ all_available: true).execute
# rubocop: enable CodeReuse/Finder
end
@@ -75,15 +75,15 @@ class GroupDescendantsFinder
# rubocop: disable CodeReuse/Finder
groups_table = Group.arel_table
visible_to_user = groups_table[:visibility_level]
- .in(Gitlab::VisibilityLevel.levels_for_user(current_user))
+ .in(Gitlab::VisibilityLevel.levels_for_user(current_user))
if current_user
authorized_groups = GroupsFinder.new(current_user,
- all_available: false)
- .execute.as('authorized')
+ all_available: false)
+ .execute.as("authorized")
authorized_to_user = groups_table.project(1).from(authorized_groups)
- .where(authorized_groups[:id].eq(groups_table[:id]))
- .exists
+ .where(authorized_groups[:id].eq(groups_table[:id]))
+ .exists
visible_to_user = visible_to_user.or(authorized_to_user)
end
@@ -137,17 +137,17 @@ class GroupDescendantsFinder
# When filtering subgroups, we want to find all matches within the tree of
# descendants to show to the user
groups = if params[:filter]
- subgroups_matching_filter
- else
- direct_child_groups
- end
+ subgroups_matching_filter
+ else
+ direct_child_groups
+ end
groups.with_selects_for_list(archived: params[:archived]).order_by(sort)
end
# rubocop: disable CodeReuse/Finder
def direct_child_projects
- GroupProjectsFinder.new(group: parent_group, current_user: current_user, params: params, options: { only_owned: true })
+ GroupProjectsFinder.new(group: parent_group, current_user: current_user, params: params, options: {only_owned: true})
.execute
end
# rubocop: enable CodeReuse/Finder
@@ -169,16 +169,16 @@ class GroupDescendantsFinder
def projects
projects = if params[:filter]
- projects_matching_filter
- else
- direct_child_projects
- end
+ projects_matching_filter
+ else
+ direct_child_projects
+ end
projects.with_route.order_by(sort)
end
def sort
- params.fetch(:sort, 'created_desc')
+ params.fetch(:sort, "created_desc")
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/finders/group_finder.rb b/app/finders/group_finder.rb
index d2ad8a372b1..dcb2fb1e041 100644
--- a/app/finders/group_finder.rb
+++ b/app/finders/group_finder.rb
@@ -13,8 +13,6 @@ class GroupFinder
if can?(@current_user, :read_group, group)
group
- else
- nil
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/finders/group_labels_finder.rb b/app/finders/group_labels_finder.rb
index a668a0f0fae..e1a6ee0688b 100644
--- a/app/finders/group_labels_finder.rb
+++ b/app/finders/group_labels_finder.rb
@@ -24,6 +24,6 @@ class GroupLabelsFinder
end
def subscribed?
- params[:subscribed] == 'true'
+ params[:subscribed] == "true"
end
end
diff --git a/app/finders/group_members_finder.rb b/app/finders/group_members_finder.rb
index eebc67cfa9e..4557e93bc35 100644
--- a/app/finders/group_members_finder.rb
+++ b/app/finders/group_members_finder.rb
@@ -30,7 +30,7 @@ class GroupMembersFinder
wheres << "members.id IN (#{descendant_members.select(:id).to_sql})"
end
- GroupMember.where(wheres.join(' OR '))
+ GroupMember.where(wheres.join(" OR "))
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/group_projects_finder.rb b/app/finders/group_projects_finder.rb
index 4155b6af8da..f5572ab8b5f 100644
--- a/app/finders/group_projects_finder.rb
+++ b/app/finders/group_projects_finder.rb
@@ -32,10 +32,10 @@ class GroupProjectsFinder < ProjectsFinder
def init_collection
projects = if current_user
- collection_with_user
- else
- collection_without_user
- end
+ collection_with_user
+ else
+ collection_without_user
+ end
union(projects)
end
@@ -48,7 +48,7 @@ class GroupProjectsFinder < ProjectsFinder
else
[
owned_projects.public_or_visible_to_user(current_user),
- shared_projects.public_or_visible_to_user(current_user)
+ shared_projects.public_or_visible_to_user(current_user),
]
end
end
diff --git a/app/finders/groups_finder.rb b/app/finders/groups_finder.rb
index 0080123407d..9867e6bb401 100644
--- a/app/finders/groups_finder.rb
+++ b/app/finders/groups_finder.rb
@@ -26,12 +26,12 @@ class GroupsFinder < UnionFinder
end
def execute
- items = all_groups.map do |item|
+ items = all_groups.map { |item|
item = by_parent(item)
item = by_custom_attributes(item)
item
- end
+ }
find_union(items, Group).with_route.order_id_desc
end
@@ -64,7 +64,7 @@ class GroupsFinder < UnionFinder
def groups_with_min_access_level
groups = current_user
.groups
- .where('members.access_level >= ?', params[:min_access_level])
+ .where("members.access_level >= ?", params[:min_access_level])
Gitlab::ObjectHierarchy
.new(groups)
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index 5870f158690..2d194c98675 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -39,11 +39,11 @@ class IssuableFinder
requires_cross_project_access unless: -> { project? }
# This is used as a common filter for None / Any
- FILTER_NONE = 'none'.freeze
- FILTER_ANY = 'any'.freeze
+ FILTER_NONE = "none"
+ FILTER_ANY = "any"
# This is accepted as a deprecated filter and is also used in unassigning users
- NONE = '0'.freeze
+ NONE = "0"
attr_accessor :current_user, :params
@@ -62,7 +62,7 @@ class IssuableFinder
end
def self.array_params
- @array_params ||= { label_name: [], assignee_username: [] }
+ @array_params ||= {label_name: [], assignee_username: []}
end
def self.valid_params
@@ -147,8 +147,6 @@ class IssuableFinder
@group =
if params[:group_id].present?
Group.find(params[:group_id])
- else
- nil
end
end
@@ -187,7 +185,7 @@ class IssuableFinder
if current_user && params[:authorized_only].presence && !current_user_related?
current_user.authorized_projects
elsif group
- finder_options = { include_subgroups: params[:include_subgroups], only_owned: true }
+ finder_options = {include_subgroups: params[:include_subgroups], only_owned: true}
GroupProjectsFinder.new(group: group, current_user: current_user, options: finder_options).execute # rubocop: disable CodeReuse/Finder
else
ProjectsFinder.new(current_user: current_user).execute # rubocop: disable CodeReuse/Finder
@@ -218,7 +216,7 @@ class IssuableFinder
group_id = group.id if group
search_params =
- { title: params[:milestone_title], project_ids: project_id, group_ids: group_id }
+ {title: params[:milestone_title], project_ids: project_id, group_ids: group_id}
MilestonesFinder.new(search_params).execute # rubocop: disable CodeReuse/Finder
else
@@ -269,8 +267,6 @@ class IssuableFinder
User.find_by(id: params[:assignee_id])
elsif assignee_username?
User.find_by_username(params[:assignee_username])
- else
- nil
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -297,8 +293,6 @@ class IssuableFinder
User.find_by(id: params[:author_id])
elsif author_username?
User.find_by_username(params[:author_username])
- else
- nil
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -337,9 +331,9 @@ class IssuableFinder
return items.none if current_user_related? && !current_user
case params[:scope]
- when 'created_by_me', 'authored'
+ when "created_by_me", "authored"
items.where(author_id: current_user.id)
- when 'assigned_to_me'
+ when "assigned_to_me"
items.assigned_to(current_user)
else
items
@@ -364,14 +358,14 @@ class IssuableFinder
# rubocop: disable CodeReuse/ActiveRecord
def by_state(items)
case params[:state].to_s
- when 'closed'
+ when "closed"
items.closed
- when 'merged'
+ when "merged"
items.respond_to?(:merged) ? items.merged : items.closed
- when 'opened'
+ when "opened"
items.opened
- when 'locked'
- items.where(state: 'locked')
+ when "locked"
+ items.where(state: "locked")
else
items
end
@@ -441,7 +435,7 @@ class IssuableFinder
if filter_by_no_assignee?
items.where(assignee_id: nil)
elsif filter_by_any_assignee?
- items.where('assignee_id IS NOT NULL')
+ items.where("assignee_id IS NOT NULL")
elsif assignee
items.where(assignee_id: assignee.id)
elsif assignee_id? || assignee_username? # assignee not found
@@ -486,7 +480,7 @@ class IssuableFinder
upcoming_ids = Milestone.upcoming_ids(projects, related_groups)
items = items.left_joins_milestones.where(milestone_id: upcoming_ids)
elsif filter_by_started_milestone?
- items = items.left_joins_milestones.where('milestones.start_date <= NOW()')
+ items = items.left_joins_milestones.where("milestones.start_date <= NOW()")
else
items = items.with_milestone(params[:milestone_title])
end
@@ -554,7 +548,7 @@ class IssuableFinder
def label_names
if labels?
- params[:label_name].is_a?(String) ? params[:label_name].split(',') : params[:label_name]
+ params[:label_name].is_a?(String) ? params[:label_name].split(",") : params[:label_name]
else
[]
end
@@ -566,6 +560,6 @@ class IssuableFinder
def current_user_related?
scope = params[:scope]
- scope == 'created_by_me' || scope == 'authored' || scope == 'assigned_to_me'
+ scope == "created_by_me" || scope == "authored" || scope == "assigned_to_me"
end
end
diff --git a/app/finders/issues_finder.rb b/app/finders/issues_finder.rb
index cb44575d6f1..590df04afc4 100644
--- a/app/finders/issues_finder.rb
+++ b/app/finders/issues_finder.rb
@@ -41,7 +41,7 @@ class IssuesFinder < IssuableFinder
# rubocop: disable CodeReuse/ActiveRecord
def with_confidentiality_access_check
return Issue.all if user_can_see_all_confidential_issues?
- return Issue.where('issues.confidential IS NOT TRUE') if user_cannot_see_confidential_issues?
+ return Issue.where("issues.confidential IS NOT TRUE") if user_cannot_see_confidential_issues?
Issue.where('
issues.confidential IS NOT TRUE
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb
index e523942ea4c..52e2fa715b6 100644
--- a/app/finders/labels_finder.rb
+++ b/app/finders/labels_finder.rb
@@ -36,8 +36,8 @@ class LabelsFinder < UnionFinder
group_ids = group_ids_for(project.group)
label_ids << Label.where(
- labels_table[:type].eq('GroupLabel').and(labels_table[:group_id].in(group_ids)).or(
- labels_table[:type].eq('ProjectLabel').and(labels_table[:project_id].eq(project.id))
+ labels_table[:type].eq("GroupLabel").and(labels_table[:group_id].in(group_ids)).or(
+ labels_table[:type].eq("ProjectLabel").and(labels_table[:project_id].eq(project.id))
)
)
else
@@ -92,7 +92,7 @@ class LabelsFinder < UnionFinder
end
def subscribed?
- params[:subscribed] == 'true'
+ params[:subscribed] == "true"
end
# Gets redacted array of group ids
@@ -164,10 +164,10 @@ class LabelsFinder < UnionFinder
return @projects if defined?(@projects)
@projects = if skip_authorization
- Project.all
- else
- ProjectsFinder.new(params: { non_archived: true }, current_user: current_user).execute # rubocop: disable CodeReuse/Finder
- end
+ Project.all
+ else
+ ProjectsFinder.new(params: {non_archived: true}, current_user: current_user).execute # rubocop: disable CodeReuse/Finder
+ end
@projects = @projects.in_namespace(params[:group_id]) if group?
@projects = @projects.where(id: params[:project_ids]) if projects?
diff --git a/app/finders/members_finder.rb b/app/finders/members_finder.rb
index f90a7868102..665744fa117 100644
--- a/app/finders/members_finder.rb
+++ b/app/finders/members_finder.rb
@@ -40,32 +40,32 @@ class MembersFinder
# We prefer project members over group members, project members should go first.
if Gitlab::Database.postgresql?
<<~SQL
- SELECT DISTINCT ON (user_id, invite_email) member_union.*
- FROM (#{union.to_sql}) AS member_union
- ORDER BY user_id,
- invite_email,
- CASE
- WHEN type = 'ProjectMember' THEN 1
- WHEN type = 'GroupMember' THEN 2
- ELSE 3
- END
+ SELECT DISTINCT ON (user_id, invite_email) member_union.*
+ FROM (#{union.to_sql}) AS member_union
+ ORDER BY user_id,
+ invite_email,
+ CASE
+ WHEN type = 'ProjectMember' THEN 1
+ WHEN type = 'GroupMember' THEN 2
+ ELSE 3
+ END
SQL
else
# Older versions of MySQL do not support window functions (and DISTINCT ON is postgres-specific).
<<~SQL
- SELECT t1.*
- FROM (#{union.to_sql}) AS t1
- JOIN (
- SELECT
- COALESCE(user_id, -1) AS user_id,
- COALESCE(invite_email, 'NULL') AS invite_email,
- MIN(CASE WHEN type = 'ProjectMember' THEN 1 WHEN type = 'GroupMember' THEN 2 ELSE 3 END) AS type_number
- FROM
- (#{union.to_sql}) AS t3
- GROUP BY COALESCE(user_id, -1), COALESCE(invite_email, 'NULL')
- ) AS t2 ON COALESCE(t1.user_id, -1) = t2.user_id
- AND COALESCE(t1.invite_email, 'NULL') = t2.invite_email
- AND CASE WHEN t1.type = 'ProjectMember' THEN 1 WHEN t1.type = 'GroupMember' THEN 2 ELSE 3 END = t2.type_number
+ SELECT t1.*
+ FROM (#{union.to_sql}) AS t1
+ JOIN (
+ SELECT
+ COALESCE(user_id, -1) AS user_id,
+ COALESCE(invite_email, 'NULL') AS invite_email,
+ MIN(CASE WHEN type = 'ProjectMember' THEN 1 WHEN type = 'GroupMember' THEN 2 ELSE 3 END) AS type_number
+ FROM
+ (#{union.to_sql}) AS t3
+ GROUP BY COALESCE(user_id, -1), COALESCE(invite_email, 'NULL')
+ ) AS t2 ON COALESCE(t1.user_id, -1) = t2.user_id
+ AND COALESCE(t1.invite_email, 'NULL') = t2.invite_email
+ AND CASE WHEN t1.type = 'ProjectMember' THEN 1 WHEN t1.type = 'GroupMember' THEN 2 ELSE 3 END = t2.type_number
SQL
end
end
diff --git a/app/finders/merge_requests_finder.rb b/app/finders/merge_requests_finder.rb
index b645011a3c5..d20fd7c1f3a 100644
--- a/app/finders/merge_requests_finder.rb
+++ b/app/finders/merge_requests_finder.rb
@@ -68,9 +68,9 @@ class MergeRequestsFinder < IssuableFinder
end
def by_wip(items)
- if params[:wip] == 'yes'
+ if params[:wip] == "yes"
items.where(wip_match(items.arel_table))
- elsif params[:wip] == 'no'
+ elsif params[:wip] == "no"
items.where.not(wip_match(items.arel_table))
else
items
@@ -78,8 +78,8 @@ class MergeRequestsFinder < IssuableFinder
end
def wip_match(table)
- table[:title].matches('WIP:%')
- .or(table[:title].matches('WIP %'))
- .or(table[:title].matches('[WIP]%'))
+ table[:title].matches("WIP:%")
+ .or(table[:title].matches("WIP %"))
+ .or(table[:title].matches("[WIP]%"))
end
end
diff --git a/app/finders/milestones_finder.rb b/app/finders/milestones_finder.rb
index 77b55cbb838..209d68fec7c 100644
--- a/app/finders/milestones_finder.rb
+++ b/app/finders/milestones_finder.rb
@@ -58,8 +58,8 @@ class MilestonesFinder
# rubocop: disable CodeReuse/ActiveRecord
def order(items)
- order_statement = Gitlab::Database.nulls_last_order('due_date', 'ASC')
- items.reorder(order_statement).order('title ASC')
+ order_statement = Gitlab::Database.nulls_last_order("due_date", "ASC")
+ items.reorder(order_statement).order("title ASC")
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb
index 817aac8b5d5..6bb0108e24e 100644
--- a/app/finders/notes_finder.rb
+++ b/app/finders/notes_finder.rb
@@ -71,7 +71,7 @@ class NotesFinder
# rubocop: disable CodeReuse/ActiveRecord
def notes_of_any_type
- types = %w(commit issue merge_request snippet)
+ types = %w[commit issue merge_request snippet]
note_relations = types.map { |t| notes_for_type(t) }
note_relations.map! { |notes| search(notes) }
UnionFinder.new.find_union(note_relations, Note.includes(:author)) # rubocop: disable CodeReuse/Finder
@@ -97,7 +97,7 @@ class NotesFinder
def notes_for_type(noteable_type)
if noteable_type == "commit"
if Ability.allowed?(@current_user, :download_code, @project)
- @project.notes.where(noteable_type: 'Commit')
+ @project.notes.where(noteable_type: "Commit")
else
Note.none
end
diff --git a/app/finders/personal_access_tokens_finder.rb b/app/finders/personal_access_tokens_finder.rb
index bd95dcd323f..1ede7058030 100644
--- a/app/finders/personal_access_tokens_finder.rb
+++ b/app/finders/personal_access_tokens_finder.rb
@@ -39,9 +39,9 @@ class PersonalAccessTokensFinder
def by_state(tokens)
case @params[:state]
- when 'active'
+ when "active"
tokens.active
- when 'inactive'
+ when "inactive"
tokens.inactive
else
tokens
diff --git a/app/finders/pipeline_schedules_finder.rb b/app/finders/pipeline_schedules_finder.rb
index 3beee608268..b64b9013425 100644
--- a/app/finders/pipeline_schedules_finder.rb
+++ b/app/finders/pipeline_schedules_finder.rb
@@ -12,9 +12,9 @@ class PipelineSchedulesFinder
def execute(scope: nil)
scoped_schedules =
case scope
- when 'active'
+ when "active"
pipeline_schedules.active
- when 'inactive'
+ when "inactive"
pipeline_schedules.inactive
else
pipeline_schedules
diff --git a/app/finders/pipelines_finder.rb b/app/finders/pipelines_finder.rb
index f5aadc42ff0..c9fa7dc6bfc 100644
--- a/app/finders/pipelines_finder.rb
+++ b/app/finders/pipelines_finder.rb
@@ -32,7 +32,7 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def ids_for_ref(refs)
- pipelines.where(ref: refs).group(:ref).select('max(id)')
+ pipelines.where(ref: refs).group(:ref).select("max(id)")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -52,15 +52,15 @@ class PipelinesFinder
def by_scope(items)
case params[:scope]
- when 'running'
+ when "running"
items.running
- when 'pending'
+ when "pending"
items.pending
- when 'finished'
+ when "finished"
items.finished
- when 'branches'
+ when "branches"
from_ids(ids_for_ref(branches))
- when 'tags'
+ when "tags"
from_ids(ids_for_ref(tags))
else
items
@@ -98,7 +98,7 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def by_name(items)
if params[:name].present?
- items.joins(:user).where(users: { name: params[:name] })
+ items.joins(:user).where(users: {name: params[:name]})
else
items
end
@@ -108,7 +108,7 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def by_username(items)
if params[:username].present?
- items.joins(:user).where(users: { username: params[:username] })
+ items.joins(:user).where(users: {username: params[:username]})
else
items
end
@@ -131,16 +131,16 @@ class PipelinesFinder
# rubocop: disable CodeReuse/ActiveRecord
def sort_items(items)
order_by = if ALLOWED_INDEXED_COLUMNS.include?(params[:order_by])
- params[:order_by]
- else
- :id
- end
-
- sort = if params[:sort] =~ /\A(ASC|DESC)\z/i
- params[:sort]
- else
- :desc
- end
+ params[:order_by]
+ else
+ :id
+ end
+
+ sort = if /\A(ASC|DESC)\z/i.match?(params[:sort])
+ params[:sort]
+ else
+ :desc
+ end
items.order(order_by => sort)
end
diff --git a/app/finders/projects/serverless/functions_finder.rb b/app/finders/projects/serverless/functions_finder.rb
index 2f2816a4a08..e5fa402401f 100644
--- a/app/finders/projects/serverless/functions_finder.rb
+++ b/app/finders/projects/serverless/functions_finder.rb
@@ -47,7 +47,8 @@ module Projects
if services.length == 1
s["podcount"] = cluster.application_knative.service_pod_details(
cluster.platform_kubernetes&.actual_namespace,
- s["metadata"]["name"]).length
+ s["metadata"]["name"]
+ ).length
end
end
end
diff --git a/app/finders/projects_finder.rb b/app/finders/projects_finder.rb
index 93d3c991846..4654ec4ed0d 100644
--- a/app/finders/projects_finder.rb
+++ b/app/finders/projects_finder.rb
@@ -76,7 +76,7 @@ class ProjectsFinder < UnionFinder
if owned_projects?
current_user.owned_projects
elsif min_access_level?
- current_user.authorized_projects.where('project_authorizations.access_level >= ?', params[:min_access_level])
+ current_user.authorized_projects.where("project_authorizations.access_level >= ?", params[:min_access_level])
else
if private_only?
current_user.authorized_projects
@@ -119,11 +119,11 @@ class ProjectsFinder < UnionFinder
end
def by_personal(items)
- (params[:personal].present? && current_user) ? items.personal(current_user) : items
+ params[:personal].present? && current_user ? items.personal(current_user) : items
end
def by_starred(items)
- (params[:starred].present? && current_user) ? items.starred_by(current_user) : items
+ params[:starred].present? && current_user ? items.starred_by(current_user) : items
end
def by_trending(items)
@@ -157,7 +157,7 @@ class ProjectsFinder < UnionFinder
if params[:non_archived]
projects.non_archived
elsif params.key?(:archived)
- if params[:archived] == 'only'
+ if params[:archived] == "only"
projects.archived
elsif Gitlab::Utils.to_boolean(params[:archived])
projects
@@ -172,6 +172,6 @@ class ProjectsFinder < UnionFinder
def finder_params
return {} unless min_access_level?
- { min_access_level: params[:min_access_level] }
+ {min_access_level: params[:min_access_level]}
end
end
diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb
index d3774746cb8..3497a04a314 100644
--- a/app/finders/snippets_finder.rb
+++ b/app/finders/snippets_finder.rb
@@ -52,8 +52,8 @@ class SnippetsFinder < UnionFinder
if project && author
raise(
ArgumentError,
- 'Filtering by both an author and a project is not supported, ' \
- 'as this finder is not optimised for this use case'
+ "Filtering by both an author and a project is not supported, " \
+ "as this finder is not optimised for this use case"
)
end
end
@@ -144,14 +144,12 @@ class SnippetsFinder < UnionFinder
def visibility_from_scope
case scope
- when 'are_private'
+ when "are_private"
Snippet::PRIVATE
- when 'are_internal'
+ when "are_internal"
Snippet::INTERNAL
- when 'are_public'
+ when "are_public"
Snippet::PUBLIC
- else
- nil
end
end
end
diff --git a/app/finders/template_finder.rb b/app/finders/template_finder.rb
index 3e483716064..16071f5d236 100644
--- a/app/finders/template_finder.rb
+++ b/app/finders/template_finder.rb
@@ -11,7 +11,7 @@ class TemplateFinder
class << self
def build(type, project, params = {})
- if type.to_s == 'licenses'
+ if type.to_s == "licenses"
LicenseTemplateFinder.new(project, params) # rubocop: disable CodeReuse/Finder
else
new(type, project, params)
diff --git a/app/finders/todos_finder.rb b/app/finders/todos_finder.rb
index d001e18fea9..e2dcc5f88fa 100644
--- a/app/finders/todos_finder.rb
+++ b/app/finders/todos_finder.rb
@@ -21,9 +21,9 @@ class TodosFinder
requires_cross_project_access unless: -> { project? }
- NONE = '0'.freeze
+ NONE = "0"
- TODO_TYPES = Set.new(%w(Issue MergeRequest Epic)).freeze
+ TODO_TYPES = Set.new(%w[Issue MergeRequest Epic]).freeze
attr_accessor :current_user, :params
@@ -165,7 +165,7 @@ class TodosFinder
end
def by_state(items)
- if params[:state].to_s == 'done'
+ if params[:state].to_s == "done"
items.done
else
items.pending
diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb
index 81ae50c0bd1..e323419386e 100644
--- a/app/finders/users_finder.rb
+++ b/app/finders/users_finder.rb
@@ -86,9 +86,9 @@ class UsersFinder
def by_2fa(users)
case params[:two_factor]
- when 'enabled'
+ when "enabled"
users.with_two_factor
- when 'disabled'
+ when "disabled"
users.without_two_factor
else
users
diff --git a/app/graphql/mutations/base_mutation.rb b/app/graphql/mutations/base_mutation.rb
index eb03dfe1624..56c9c1abe71 100644
--- a/app/graphql/mutations/base_mutation.rb
+++ b/app/graphql/mutations/base_mutation.rb
@@ -3,8 +3,8 @@
module Mutations
class BaseMutation < GraphQL::Schema::RelayClassicMutation
field :errors, [GraphQL::STRING_TYPE],
- null: false,
- description: "Reasons why the mutation failed."
+ null: false,
+ description: "Reasons why the mutation failed."
def current_user
context[:current_user]
diff --git a/app/graphql/mutations/merge_requests/base.rb b/app/graphql/mutations/merge_requests/base.rb
index 7d0cb777ad1..b31a24d8d16 100644
--- a/app/graphql/mutations/merge_requests/base.rb
+++ b/app/graphql/mutations/merge_requests/base.rb
@@ -7,17 +7,17 @@ module Mutations
include Mutations::ResolvesProject
argument :project_path, GraphQL::ID_TYPE,
- required: true,
- description: "The project the merge request to mutate is in"
+ required: true,
+ description: "The project the merge request to mutate is in"
argument :iid, GraphQL::ID_TYPE,
- required: true,
- description: "The iid of the merge request to mutate"
+ required: true,
+ description: "The iid of the merge request to mutate"
field :merge_request,
- Types::MergeRequestType,
- null: true,
- description: "The merge request after mutation"
+ Types::MergeRequestType,
+ null: true,
+ description: "The merge request after mutation"
authorize :update_merge_request
diff --git a/app/graphql/mutations/merge_requests/set_wip.rb b/app/graphql/mutations/merge_requests/set_wip.rb
index a2aa0c84ee4..0e2c512e2f8 100644
--- a/app/graphql/mutations/merge_requests/set_wip.rb
+++ b/app/graphql/mutations/merge_requests/set_wip.rb
@@ -3,14 +3,14 @@
module Mutations
module MergeRequests
class SetWip < Base
- graphql_name 'MergeRequestSetWip'
+ graphql_name "MergeRequestSetWip"
argument :wip,
- GraphQL::BOOLEAN_TYPE,
- required: true,
- description: <<~DESC
- Whether or not to set the merge request as a WIP.
- DESC
+ GraphQL::BOOLEAN_TYPE,
+ required: true,
+ description: <<~DESC
+ Whether or not to set the merge request as a WIP.
+ DESC
def resolve(project_path:, iid:, wip: nil)
merge_request = authorized_find!(project_path: project_path, iid: iid)
@@ -21,14 +21,14 @@ module Mutations
{
merge_request: merge_request,
- errors: merge_request.errors.full_messages
+ errors: merge_request.errors.full_messages,
}
end
private
def wip_event(merge_request, wip)
- wip ? 'wip' : 'unwip'
+ wip ? "wip" : "unwip"
end
end
end
diff --git a/app/graphql/resolvers/base_resolver.rb b/app/graphql/resolvers/base_resolver.rb
index 063def75d38..09247fd8249 100644
--- a/app/graphql/resolvers/base_resolver.rb
+++ b/app/graphql/resolvers/base_resolver.rb
@@ -3,11 +3,11 @@
module Resolvers
class BaseResolver < GraphQL::Schema::Resolver
def self.single
- @single ||= Class.new(self) do
+ @single ||= Class.new(self) {
def resolve(**args)
super.first
end
- end
+ }
end
end
end
diff --git a/app/graphql/resolvers/concerns/resolves_pipelines.rb b/app/graphql/resolvers/concerns/resolves_pipelines.rb
index 8fd26d85994..122de4f831b 100644
--- a/app/graphql/resolvers/concerns/resolves_pipelines.rb
+++ b/app/graphql/resolvers/concerns/resolves_pipelines.rb
@@ -6,17 +6,17 @@ module ResolvesPipelines
included do
type [Types::Ci::PipelineType], null: false
argument :status,
- Types::Ci::PipelineStatusEnum,
- required: false,
- description: "Filter pipelines by their status"
+ Types::Ci::PipelineStatusEnum,
+ required: false,
+ description: "Filter pipelines by their status"
argument :ref,
- GraphQL::STRING_TYPE,
- required: false,
- description: "Filter pipelines by the ref they are run for"
+ GraphQL::STRING_TYPE,
+ required: false,
+ description: "Filter pipelines by the ref they are run for"
argument :sha,
- GraphQL::STRING_TYPE,
- required: false,
- description: "Filter pipelines by the sha of the commit they are run for"
+ GraphQL::STRING_TYPE,
+ required: false,
+ description: "Filter pipelines by the sha of the commit they are run for"
end
def resolve_pipelines(project, params = {})
diff --git a/app/graphql/resolvers/full_path_resolver.rb b/app/graphql/resolvers/full_path_resolver.rb
index 0f1a64b6c58..168565c513f 100644
--- a/app/graphql/resolvers/full_path_resolver.rb
+++ b/app/graphql/resolvers/full_path_resolver.rb
@@ -6,8 +6,8 @@ module Resolvers
prepended do
argument :full_path, GraphQL::ID_TYPE,
- required: true,
- description: 'The full path of the project or namespace, e.g., "gitlab-org/gitlab-ce"'
+ required: true,
+ description: 'The full path of the project or namespace, e.g., "gitlab-org/gitlab-ce"'
end
def model_by_full_path(model, full_path)
diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb
index b98d8bd1fff..6ce40d4a168 100644
--- a/app/graphql/resolvers/issues_resolver.rb
+++ b/app/graphql/resolvers/issues_resolver.rb
@@ -3,45 +3,45 @@
module Resolvers
class IssuesResolver < BaseResolver
argument :iid, GraphQL::ID_TYPE,
- required: false,
- description: 'The IID of the issue, e.g., "1"'
+ required: false,
+ description: 'The IID of the issue, e.g., "1"'
argument :iids, [GraphQL::ID_TYPE],
- required: false,
- description: 'The list of IIDs of issues, e.g., [1, 2]'
+ required: false,
+ description: "The list of IIDs of issues, e.g., [1, 2]"
argument :state, Types::IssuableStateEnum,
- required: false,
- description: "Current state of Issue"
+ required: false,
+ description: "Current state of Issue"
argument :label_name, GraphQL::STRING_TYPE.to_list_type,
- required: false,
- description: "Labels applied to the Issue"
+ required: false,
+ description: "Labels applied to the Issue"
argument :created_before, Types::TimeType,
- required: false,
- description: "Issues created before this date"
+ required: false,
+ description: "Issues created before this date"
argument :created_after, Types::TimeType,
- required: false,
- description: "Issues created after this date"
+ required: false,
+ description: "Issues created after this date"
argument :updated_before, Types::TimeType,
- required: false,
- description: "Issues updated before this date"
+ required: false,
+ description: "Issues updated before this date"
argument :updated_after, Types::TimeType,
- required: false,
- description: "Issues updated after this date"
+ required: false,
+ description: "Issues updated after this date"
argument :closed_before, Types::TimeType,
- required: false,
- description: "Issues closed before this date"
+ required: false,
+ description: "Issues closed before this date"
argument :closed_after, Types::TimeType,
- required: false,
- description: "Issues closed after this date"
+ required: false,
+ description: "Issues closed after this date"
argument :search, GraphQL::STRING_TYPE,
- required: false
+ required: false
argument :sort, Types::Sort,
- required: false,
- default_value: 'created_desc'
+ required: false,
+ default_value: "created_desc"
type Types::IssueType, null: true
- alias_method :project, :object
+ alias project object
def resolve(**args)
# Will need to be be made group & namespace aware with
diff --git a/app/graphql/resolvers/merge_request_pipelines_resolver.rb b/app/graphql/resolvers/merge_request_pipelines_resolver.rb
index b371f1335f8..79fef122141 100644
--- a/app/graphql/resolvers/merge_request_pipelines_resolver.rb
+++ b/app/graphql/resolvers/merge_request_pipelines_resolver.rb
@@ -4,7 +4,7 @@ module Resolvers
class MergeRequestPipelinesResolver < BaseResolver
include ::ResolvesPipelines
- alias_method :merge_request, :object
+ alias merge_request object
def resolve(**args)
resolve_pipelines(project, args)
diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb
index 90795c797ac..4a1c2d1740b 100644
--- a/app/graphql/resolvers/merge_requests_resolver.rb
+++ b/app/graphql/resolvers/merge_requests_resolver.rb
@@ -3,16 +3,16 @@
module Resolvers
class MergeRequestsResolver < BaseResolver
argument :iid, GraphQL::ID_TYPE,
- required: false,
- description: 'The IID of the merge request, e.g., "1"'
+ required: false,
+ description: 'The IID of the merge request, e.g., "1"'
argument :iids, [GraphQL::ID_TYPE],
- required: false,
- description: 'The list of IIDs of issues, e.g., [1, 2]'
+ required: false,
+ description: "The list of IIDs of issues, e.g., [1, 2]"
type Types::MergeRequestType, null: true
- alias_method :project, :object
+ alias project object
def resolve(**args)
return unless project.present?
diff --git a/app/graphql/resolvers/project_pipelines_resolver.rb b/app/graphql/resolvers/project_pipelines_resolver.rb
index 86094c46c2a..d0dbcf240c6 100644
--- a/app/graphql/resolvers/project_pipelines_resolver.rb
+++ b/app/graphql/resolvers/project_pipelines_resolver.rb
@@ -4,7 +4,7 @@ module Resolvers
class ProjectPipelinesResolver < BaseResolver
include ResolvesPipelines
- alias_method :project, :object
+ alias project object
def resolve(**args)
resolve_pipelines(project, args)
diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb
index 2bbffad4563..fba8fd48d72 100644
--- a/app/graphql/types/ci/pipeline_type.rb
+++ b/app/graphql/types/ci/pipeline_type.rb
@@ -5,7 +5,7 @@ module Types
class PipelineType < BaseObject
expose_permissions Types::PermissionTypes::Ci::Pipeline
- graphql_name 'Pipeline'
+ graphql_name "Pipeline"
field :id, GraphQL::ID_TYPE, null: false
field :iid, GraphQL::ID_TYPE, null: false
@@ -14,13 +14,13 @@ module Types
field :before_sha, GraphQL::STRING_TYPE, null: true
field :status, PipelineStatusEnum, null: false
field :duration,
- GraphQL::INT_TYPE,
- null: true,
- description: "Duration of the pipeline in seconds"
+ GraphQL::INT_TYPE,
+ null: true,
+ description: "Duration of the pipeline in seconds"
field :coverage,
- GraphQL::FLOAT_TYPE,
- null: true,
- description: "Coverage percentage"
+ GraphQL::FLOAT_TYPE,
+ null: true,
+ description: "Coverage percentage"
field :created_at, Types::TimeType, null: false
field :updated_at, Types::TimeType, null: false
field :started_at, Types::TimeType, null: true
diff --git a/app/graphql/types/issuable_state_enum.rb b/app/graphql/types/issuable_state_enum.rb
index f2f6d6c6cab..f460a41e83b 100644
--- a/app/graphql/types/issuable_state_enum.rb
+++ b/app/graphql/types/issuable_state_enum.rb
@@ -2,11 +2,11 @@
module Types
class IssuableStateEnum < BaseEnum
- graphql_name 'IssuableState'
- description 'State of a GitLab issue or merge request'
+ graphql_name "IssuableState"
+ description "State of a GitLab issue or merge request"
- value 'opened'
- value 'closed'
- value 'locked'
+ value "opened"
+ value "closed"
+ value "locked"
end
end
diff --git a/app/graphql/types/issue_state_enum.rb b/app/graphql/types/issue_state_enum.rb
index 6521407fc9d..116b2937df3 100644
--- a/app/graphql/types/issue_state_enum.rb
+++ b/app/graphql/types/issue_state_enum.rb
@@ -2,7 +2,7 @@
module Types
class IssueStateEnum < IssuableStateEnum
- graphql_name 'IssueState'
- description 'State of a GitLab issue'
+ graphql_name "IssueState"
+ description "State of a GitLab issue"
end
end
diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb
index 5ad3ea52930..b336b821dc5 100644
--- a/app/graphql/types/issue_type.rb
+++ b/app/graphql/types/issue_type.rb
@@ -4,7 +4,7 @@ module Types
class IssueType < BaseObject
expose_permissions Types::PermissionTypes::Issue
- graphql_name 'Issue'
+ graphql_name "Issue"
present_using IssuePresenter
@@ -14,23 +14,23 @@ module Types
field :state, IssueStateEnum, null: false
field :author, Types::UserType,
- null: false,
- resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find },
- authorize: :read_user
+ null: false,
+ resolve: ->(obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(User, obj.author_id).find },
+ authorize: :read_user
field :assignees, Types::UserType.connection_type, null: true
field :labels, Types::LabelType.connection_type, null: true
field :milestone, Types::MilestoneType,
- null: true,
- resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find },
- authorize: :read_milestone
+ null: true,
+ resolve: ->(obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Milestone, obj.milestone_id).find },
+ authorize: :read_milestone
field :due_date, Types::TimeType, null: true
field :confidential, GraphQL::BOOLEAN_TYPE, null: false
field :discussion_locked, GraphQL::BOOLEAN_TYPE,
- null: false,
- resolve: -> (obj, _args, _ctx) { !!obj.discussion_locked }
+ null: false,
+ resolve: ->(obj, _args, _ctx) { !!obj.discussion_locked }
field :upvotes, GraphQL::INT_TYPE, null: false
field :downvotes, GraphQL::INT_TYPE, null: false
diff --git a/app/graphql/types/label_type.rb b/app/graphql/types/label_type.rb
index ccd466edc1a..9b155bffcfb 100644
--- a/app/graphql/types/label_type.rb
+++ b/app/graphql/types/label_type.rb
@@ -2,7 +2,7 @@
module Types
class LabelType < BaseObject
- graphql_name 'Label'
+ graphql_name "Label"
field :description, GraphQL::STRING_TYPE, null: true
field :title, GraphQL::STRING_TYPE, null: false
diff --git a/app/graphql/types/merge_request_state_enum.rb b/app/graphql/types/merge_request_state_enum.rb
index 92f52726ab3..2dee256459e 100644
--- a/app/graphql/types/merge_request_state_enum.rb
+++ b/app/graphql/types/merge_request_state_enum.rb
@@ -2,9 +2,9 @@
module Types
class MergeRequestStateEnum < IssuableStateEnum
- graphql_name 'MergeRequestState'
- description 'State of a GitLab merge request'
+ graphql_name "MergeRequestState"
+ description "State of a GitLab merge request"
- value 'merged'
+ value "merged"
end
end
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb
index 1ed27a14e33..470e041bd62 100644
--- a/app/graphql/types/merge_request_type.rb
+++ b/app/graphql/types/merge_request_type.rb
@@ -6,7 +6,7 @@ module Types
present_using MergeRequestPresenter
- graphql_name 'MergeRequest'
+ graphql_name "MergeRequest"
field :id, GraphQL::ID_TYPE, null: false
field :iid, GraphQL::ID_TYPE, null: false
@@ -50,6 +50,6 @@ module Types
field :head_pipeline, Types::Ci::PipelineType, null: true, method: :actual_head_pipeline, authorize: :read_pipeline
field :pipelines, Types::Ci::PipelineType.connection_type,
- resolver: Resolvers::MergeRequestPipelinesResolver
+ resolver: Resolvers::MergeRequestPipelinesResolver
end
end
diff --git a/app/graphql/types/milestone_type.rb b/app/graphql/types/milestone_type.rb
index af31b572c9a..0478675013f 100644
--- a/app/graphql/types/milestone_type.rb
+++ b/app/graphql/types/milestone_type.rb
@@ -2,7 +2,7 @@
module Types
class MilestoneType < BaseObject
- graphql_name 'Milestone'
+ graphql_name "Milestone"
field :description, GraphQL::STRING_TYPE, null: true
field :title, GraphQL::STRING_TYPE, null: false
diff --git a/app/graphql/types/permission_types/base_permission_type.rb b/app/graphql/types/permission_types/base_permission_type.rb
index 26a71e2bfbb..da1afc6808e 100644
--- a/app/graphql/types/permission_types/base_permission_type.rb
+++ b/app/graphql/types/permission_types/base_permission_type.rb
@@ -13,7 +13,7 @@ module Types
def self.ability_field(ability, **kword_args)
unless resolving_keywords?(kword_args)
- kword_args[:resolve] ||= -> (object, args, context) do
+ kword_args[:resolve] ||= ->(object, args, context) do
can?(context[:current_user], ability, object, args.to_h)
end
end
@@ -26,7 +26,8 @@ module Types
name: name,
type: GraphQL::BOOLEAN_TYPE,
description: "Whether or not a user can perform `#{name}` on this resource",
- null: false)
+ null: false
+ )
field(**kword_args)
end
diff --git a/app/graphql/types/permission_types/ci/pipeline.rb b/app/graphql/types/permission_types/ci/pipeline.rb
index 73e44a33eba..67449671c6a 100644
--- a/app/graphql/types/permission_types/ci/pipeline.rb
+++ b/app/graphql/types/permission_types/ci/pipeline.rb
@@ -4,7 +4,7 @@ module Types
module PermissionTypes
module Ci
class Pipeline < BasePermissionType
- graphql_name 'PipelinePermissions'
+ graphql_name "PipelinePermissions"
abilities :update_pipeline, :admin_pipeline, :destroy_pipeline
end
diff --git a/app/graphql/types/permission_types/issue.rb b/app/graphql/types/permission_types/issue.rb
index 199540c7d6d..1e6ecc3602c 100644
--- a/app/graphql/types/permission_types/issue.rb
+++ b/app/graphql/types/permission_types/issue.rb
@@ -3,12 +3,12 @@
module Types
module PermissionTypes
class Issue < BasePermissionType
- description 'Check permissions for the current user on a issue'
- graphql_name 'IssuePermissions'
+ description "Check permissions for the current user on a issue"
+ graphql_name "IssuePermissions"
abilities :read_issue, :admin_issue,
- :update_issue, :create_note,
- :reopen_issue
+ :update_issue, :create_note,
+ :reopen_issue
end
end
end
diff --git a/app/graphql/types/permission_types/merge_request.rb b/app/graphql/types/permission_types/merge_request.rb
index 13995d3ea8f..6a120b573c3 100644
--- a/app/graphql/types/permission_types/merge_request.rb
+++ b/app/graphql/types/permission_types/merge_request.rb
@@ -4,11 +4,11 @@ module Types
module PermissionTypes
class MergeRequest < BasePermissionType
present_using MergeRequestPresenter
- description 'Check permissions for the current user on a merge request'
- graphql_name 'MergeRequestPermissions'
+ description "Check permissions for the current user on a merge request"
+ graphql_name "MergeRequestPermissions"
abilities :read_merge_request, :admin_merge_request,
- :update_merge_request, :create_note
+ :update_merge_request, :create_note
permission_field :push_to_source_branch, method: :can_push_to_source_branch?
permission_field :remove_source_branch, method: :can_remove_source_branch?
diff --git a/app/graphql/types/permission_types/project.rb b/app/graphql/types/permission_types/project.rb
index e9a4ea9157b..93f8a282655 100644
--- a/app/graphql/types/permission_types/project.rb
+++ b/app/graphql/types/permission_types/project.rb
@@ -3,20 +3,20 @@
module Types
module PermissionTypes
class Project < BasePermissionType
- graphql_name 'ProjectPermissions'
+ graphql_name "ProjectPermissions"
abilities :change_namespace, :change_visibility_level, :rename_project,
- :remove_project, :archive_project, :remove_fork_project,
- :remove_pages, :read_project, :create_merge_request_in,
- :read_wiki, :read_project_member, :create_issue, :upload_file,
- :read_cycle_analytics, :download_code, :download_wiki_code,
- :fork_project, :create_project_snippet, :read_commit_status,
- :request_access, :create_pipeline, :create_pipeline_schedule,
- :create_merge_request_from, :create_wiki, :push_code,
- :create_deployment, :push_to_delete_protected_branch,
- :admin_wiki, :admin_project, :update_pages,
- :admin_remote_mirror, :create_label, :update_wiki, :destroy_wiki,
- :create_pages, :destroy_pages, :read_pages_content
+ :remove_project, :archive_project, :remove_fork_project,
+ :remove_pages, :read_project, :create_merge_request_in,
+ :read_wiki, :read_project_member, :create_issue, :upload_file,
+ :read_cycle_analytics, :download_code, :download_wiki_code,
+ :fork_project, :create_project_snippet, :read_commit_status,
+ :request_access, :create_pipeline, :create_pipeline_schedule,
+ :create_merge_request_from, :create_wiki, :push_code,
+ :create_deployment, :push_to_delete_protected_branch,
+ :admin_wiki, :admin_project, :update_pages,
+ :admin_remote_mirror, :create_label, :update_wiki, :destroy_wiki,
+ :create_pages, :destroy_pages, :read_pages_content
end
end
end
diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb
index 3ef0cc5020c..5d493137077 100644
--- a/app/graphql/types/project_type.rb
+++ b/app/graphql/types/project_type.rb
@@ -4,7 +4,7 @@ module Types
class ProjectType < BaseObject
expose_permissions Types::PermissionTypes::Project
- graphql_name 'Project'
+ graphql_name "Project"
field :id, GraphQL::ID_TYPE, null: false
@@ -38,23 +38,23 @@ module Types
field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true
field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, null: true
- field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: -> (project, args, ctx) do
+ field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: ->(project, args, ctx) do
project.avatar_url(only_path: false)
end
%i[issues merge_requests wiki snippets].each do |feature|
- field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do
+ field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, resolve: ->(project, args, ctx) do
project.feature_available?(feature, ctx[:current_user])
end
end
- field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, resolve: -> (project, args, ctx) do
+ field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, resolve: ->(project, args, ctx) do
project.feature_available?(:builds, ctx[:current_user])
end
field :public_jobs, GraphQL::BOOLEAN_TYPE, method: :public_builds, null: true
- field :open_issues_count, GraphQL::INT_TYPE, null: true, resolve: -> (project, args, ctx) do
+ field :open_issues_count, GraphQL::INT_TYPE, null: true, resolve: ->(project, args, ctx) do
project.open_issues_count if project.feature_available?(:issues, ctx[:current_user])
end
@@ -67,30 +67,30 @@ module Types
field :printing_merge_request_link_enabled, GraphQL::BOOLEAN_TYPE, null: true
field :merge_requests,
- Types::MergeRequestType.connection_type,
- null: true,
- resolver: Resolvers::MergeRequestsResolver,
- authorize: :read_merge_request
+ Types::MergeRequestType.connection_type,
+ null: true,
+ resolver: Resolvers::MergeRequestsResolver,
+ authorize: :read_merge_request
field :merge_request,
- Types::MergeRequestType,
- null: true,
- resolver: Resolvers::MergeRequestsResolver.single,
- authorize: :read_merge_request
+ Types::MergeRequestType,
+ null: true,
+ resolver: Resolvers::MergeRequestsResolver.single,
+ authorize: :read_merge_request
field :issues,
- Types::IssueType.connection_type,
- null: true,
- resolver: Resolvers::IssuesResolver
+ Types::IssueType.connection_type,
+ null: true,
+ resolver: Resolvers::IssuesResolver
field :issue,
- Types::IssueType,
- null: true,
- resolver: Resolvers::IssuesResolver.single
+ Types::IssueType,
+ null: true,
+ resolver: Resolvers::IssuesResolver.single
field :pipelines,
- Types::Ci::PipelineType.connection_type,
- null: false,
- resolver: Resolvers::ProjectPipelinesResolver
+ Types::Ci::PipelineType.connection_type,
+ null: false,
+ resolver: Resolvers::ProjectPipelinesResolver
end
end
diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb
index 954bcc0a5a3..a8ee4069c3c 100644
--- a/app/graphql/types/query_type.rb
+++ b/app/graphql/types/query_type.rb
@@ -2,13 +2,13 @@
module Types
class QueryType < BaseObject
- graphql_name 'Query'
+ graphql_name "Query"
field :project, Types::ProjectType,
- null: true,
- resolver: Resolvers::ProjectResolver,
- description: "Find a project",
- authorize: :read_project
+ null: true,
+ resolver: Resolvers::ProjectResolver,
+ description: "Find a project",
+ authorize: :read_project
field :echo, GraphQL::STRING_TYPE, null: false, function: Functions::Echo.new
end
diff --git a/app/graphql/types/time_type.rb b/app/graphql/types/time_type.rb
index f045a50e672..cbe9c95c779 100644
--- a/app/graphql/types/time_type.rb
+++ b/app/graphql/types/time_type.rb
@@ -2,8 +2,8 @@
module Types
class TimeType < BaseScalar
- graphql_name 'Time'
- description 'Time represented in ISO 8601'
+ graphql_name "Time"
+ description "Time represented in ISO 8601"
def self.coerce_input(value, ctx)
Time.parse(value)
diff --git a/app/graphql/types/user_type.rb b/app/graphql/types/user_type.rb
index a13e65207df..c01c9ccaee9 100644
--- a/app/graphql/types/user_type.rb
+++ b/app/graphql/types/user_type.rb
@@ -2,7 +2,7 @@
module Types
class UserType < BaseObject
- graphql_name 'User'
+ graphql_name "User"
present_using UserPresenter
diff --git a/app/helpers/active_sessions_helper.rb b/app/helpers/active_sessions_helper.rb
index 84aa1160f12..35e139b7f60 100644
--- a/app/helpers/active_sessions_helper.rb
+++ b/app/helpers/active_sessions_helper.rb
@@ -8,18 +8,18 @@ module ActiveSessionsHelper
def active_session_device_type_icon(active_session)
icon_name =
case active_session.device_type
- when 'smartphone', 'feature phone', 'phablet'
- 'mobile'
- when 'tablet'
- 'tablet'
- when 'tv', 'smart display', 'camera', 'portable media player', 'console'
- 'media'
- when 'car browser'
- 'car'
+ when "smartphone", "feature phone", "phablet"
+ "mobile"
+ when "tablet"
+ "tablet"
+ when "tv", "smart display", "camera", "portable media player", "console"
+ "media"
+ when "car browser"
+ "car"
else
- 'monitor-o'
+ "monitor-o"
end
- sprite_icon(icon_name, size: 16, css_class: 'prepend-top-2')
+ sprite_icon(icon_name, size: 16, css_class: "prepend-top-2")
end
end
diff --git a/app/helpers/appearances_helper.rb b/app/helpers/appearances_helper.rb
index c0db9910143..a51551ac46d 100644
--- a/app/helpers/appearances_helper.rb
+++ b/app/helpers/appearances_helper.rb
@@ -9,7 +9,7 @@ module AppearancesHelper
def default_brand_title
# This resides in a separate method so that EE can easily redefine it.
- 'GitLab Community Edition'
+ "GitLab Community Edition"
end
def brand_image
@@ -30,16 +30,16 @@ module AppearancesHelper
def brand_header_logo
if current_appearance&.header_logo?
- image_tag current_appearance.header_logo_path, class: 'brand-header-logo'
+ image_tag current_appearance.header_logo_path, class: "brand-header-logo"
else
- render 'shared/logo.svg'
+ render "shared/logo.svg"
end
end
# Skip the 'GitLab' type logo when custom brand logo is set
def brand_header_logo_type
unless current_appearance&.header_logo?
- render 'shared/logo_type.svg'
+ render "shared/logo_type.svg"
end
end
@@ -47,7 +47,7 @@ module AppearancesHelper
return unless current_appearance&.show_header?
class_names = []
- class_names << 'with-performance-bar' if performance_bar_enabled?
+ class_names << "with-performance-bar" if performance_bar_enabled?
render_message(:header_message, class_names: class_names)
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index ffa5719fefb..a51f9f79fae 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'digest/md5'
-require 'uri'
+require "digest/md5"
+require "uri"
module ApplicationHelper
# See https://docs.gitlab.com/ee/development/ee_features.html#code-in-app-views
@@ -58,10 +58,10 @@ module ApplicationHelper
if project.repo_exists?
time_ago_with_tooltip(project.repository.commit.committed_date)
else
- 'Never'
+ "Never"
end
rescue
- 'Never'
+ "Never"
end
# Define whenever show last push event
@@ -69,7 +69,7 @@ module ApplicationHelper
# rubocop: disable CodeReuse/ActiveRecord
def show_last_push_widget?(event)
# Skip if event is not about added or modified non-master branch
- return false unless event && event.last_push_to_non_root? && !event.rm_ref?
+ return false unless event&.last_push_to_non_root? && !event.rm_ref?
project = event.project
@@ -91,11 +91,11 @@ module ApplicationHelper
end
def simple_sanitize(str)
- sanitize(str, tags: %w(a span))
+ sanitize(str, tags: %w[a span])
end
def body_data_page
- [*controller.controller_path.split('/'), controller.action_name].compact.join(':')
+ [*controller.controller_path.split("/"), controller.action_name].compact.join(":")
end
# shortcut for gitlab config
@@ -124,32 +124,32 @@ module ApplicationHelper
# `html_class` argument is provided.
#
# Returns an HTML-safe String
- def time_ago_with_tooltip(time, placement: 'top', html_class: '', short_format: false)
- css_classes = [short_format ? 'js-short-timeago' : 'js-timeago']
+ def time_ago_with_tooltip(time, placement: "top", html_class: "", short_format: false)
+ css_classes = [short_format ? "js-short-timeago" : "js-timeago"]
css_classes << html_class unless html_class.blank?
element = content_tag :time, l(time, format: "%b %d, %Y"),
- class: css_classes.join(' '),
+ class: css_classes.join(" "),
title: l(time.to_time.in_time_zone, format: :timeago_tooltip),
datetime: time.to_time.getutc.iso8601,
data: {
- toggle: 'tooltip',
+ toggle: "tooltip",
placement: placement,
- container: 'body'
+ container: "body",
}
element
end
- def edited_time_ago_with_tooltip(object, placement: 'top', html_class: 'time_ago', exclude_author: false)
+ def edited_time_ago_with_tooltip(object, placement: "top", html_class: "time_ago", exclude_author: false)
return unless object.edited?
- content_tag :small, class: 'edited-text' do
- output = content_tag(:span, 'Edited ')
+ content_tag :small, class: "edited-text" do
+ output = content_tag(:span, "Edited ")
output << time_ago_with_tooltip(object.last_edited_at, placement: placement, html_class: html_class)
if !exclude_author && object.last_edited_by
- output << content_tag(:span, ' by ')
+ output << content_tag(:span, " by ")
output << link_to_member(object.project, object.last_edited_by, avatar: false, author_class: nil)
end
@@ -158,15 +158,15 @@ module ApplicationHelper
end
def promo_host
- 'about.gitlab.com'
+ "about.gitlab.com"
end
def promo_url
- 'https://' + promo_host
+ "https://" + promo_host
end
def support_url
- Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + '/getting-help/'
+ Gitlab::CurrentSettings.current_application_settings.help_page_support_url.presence || promo_url + "/getting-help/"
end
def page_filter_path(options = {})
@@ -212,8 +212,8 @@ module ApplicationHelper
def page_class
class_names = []
- class_names << 'issue-boards-page' if current_controller?(:boards)
- class_names << 'with-performance-bar' if performance_bar_enabled?
+ class_names << "issue-boards-page" if current_controller?(:boards)
+ class_names << "with-performance-bar" if performance_bar_enabled?
class_names << system_message_class
class_names
end
@@ -223,8 +223,8 @@ module ApplicationHelper
return class_names unless appearance
- class_names << 'with-system-header' if appearance.show_header?
- class_names << 'with-system-footer' if appearance.show_footer?
+ class_names << "with-system-header" if appearance.show_header?
+ class_names << "with-system-footer" if appearance.show_footer?
class_names
end
@@ -235,16 +235,16 @@ module ApplicationHelper
# Example:
# %li{ class: active_when(params[:filter] == '1') }
def active_when(condition)
- 'active' if condition
+ "active" if condition
end
def show_callout?(name)
- cookies[name] != 'true'
+ cookies[name] != "true"
end
def linkedin_url(user)
name = user.linkedin
- if name =~ %r{\Ahttps?://(www\.)?linkedin\.com/in/}
+ if %r{\Ahttps?://(www\.)?linkedin\.com/in/}.match?(name)
name
else
"https://www.linkedin.com/in/#{name}"
@@ -253,7 +253,7 @@ module ApplicationHelper
def twitter_url(user)
name = user.twitter
- if name =~ %r{\Ahttps?://(www\.)?twitter\.com/}
+ if %r{\Ahttps?://(www\.)?twitter\.com/}.match?(name)
name
else
"https://twitter.com/#{name}"
@@ -272,7 +272,7 @@ module ApplicationHelper
def read_only_message
return unless Gitlab::Database.read_only?
- _('You are on a read-only GitLab instance.')
+ _("You are on a read-only GitLab instance.")
end
def client_class_list
@@ -281,8 +281,8 @@ module ApplicationHelper
def client_js_flags
{
- "is#{browser.id.to_s.titlecase}": true,
- "is#{browser.platform.id.to_s.titlecase}": true
+ :"is#{browser.id.to_s.titlecase}" => true,
+ :"is#{browser.platform.id.to_s.titlecase}" => true,
}
end
@@ -296,7 +296,7 @@ module ApplicationHelper
labels: labels_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]),
milestones: milestones_project_autocomplete_sources_path(object),
commands: commands_project_autocomplete_sources_path(object, type: noteable_type, type_id: params[:id]),
- snippets: snippets_project_autocomplete_sources_path(object)
+ snippets: snippets_project_autocomplete_sources_path(object),
}
end
diff --git a/app/helpers/application_settings_helper.rb b/app/helpers/application_settings_helper.rb
index e635f608237..4b2fdb69f18 100644
--- a/app/helpers/application_settings_helper.rb
+++ b/app/helpers/application_settings_helper.rb
@@ -3,11 +3,11 @@
module ApplicationSettingsHelper
extend self
- delegate :allow_signup?,
- :gravatar_enabled?,
- :password_authentication_enabled_for_web?,
- :akismet_enabled?,
- to: :'Gitlab::CurrentSettings.current_application_settings'
+ delegate :allow_signup?,
+ :gravatar_enabled?,
+ :password_authentication_enabled_for_web?,
+ :akismet_enabled?,
+ to: :'Gitlab::CurrentSettings.current_application_settings'
def user_oauth_applications?
Gitlab::CurrentSettings.user_oauth_applications
@@ -19,10 +19,10 @@ module ApplicationSettingsHelper
def enabled_protocol
case Gitlab::CurrentSettings.enabled_git_access_protocol
- when 'http'
+ when "http"
Gitlab.config.gitlab.protocol
- when 'ssh'
- 'ssh'
+ when "ssh"
+ "ssh"
end
end
@@ -31,16 +31,16 @@ module ApplicationSettingsHelper
end
def ssh_enabled?
- all_protocols_enabled? || enabled_protocol == 'ssh'
+ all_protocols_enabled? || enabled_protocol == "ssh"
end
def http_enabled?
- all_protocols_enabled? || Gitlab::CurrentSettings.enabled_git_access_protocol == 'http'
+ all_protocols_enabled? || Gitlab::CurrentSettings.enabled_git_access_protocol == "http"
end
def enabled_project_button(project, protocol)
case protocol
- when 'ssh'
+ when "ssh"
ssh_clone_button(project, append_link: false)
else
http_clone_button(project, append_link: false)
@@ -52,15 +52,15 @@ module ApplicationSettingsHelper
def restricted_level_checkboxes(help_block_id, checkbox_name, options = {})
Gitlab::VisibilityLevel.values.map do |level|
checked = restricted_visibility_levels(true).include?(level)
- css_class = checked ? 'active' : ''
+ css_class = checked ? "active" : ""
tag_name = "application_setting_visibility_level_#{level}"
label_tag(tag_name, class: css_class) do
check_box_tag(checkbox_name, level, checked,
- autocomplete: 'off',
- 'aria-describedby' => help_block_id,
- 'class' => options[:class],
- id: tag_name) + visibility_level_icon(level) + visibility_level_label(level)
+ :autocomplete => "off",
+ "aria-describedby" => help_block_id,
+ "class" => options[:class],
+ :id => tag_name) + visibility_level_icon(level) + visibility_level_label(level)
end
end
end
@@ -70,15 +70,15 @@ module ApplicationSettingsHelper
def import_sources_checkboxes(help_block_id, options = {})
Gitlab::ImportSources.options.map do |name, source|
checked = Gitlab::CurrentSettings.import_sources.include?(source)
- css_class = checked ? 'active' : ''
- checkbox_name = 'application_setting[import_sources][]'
+ css_class = checked ? "active" : ""
+ checkbox_name = "application_setting[import_sources][]"
label_tag(name, class: css_class) do
check_box_tag(checkbox_name, source, checked,
- autocomplete: 'off',
- 'aria-describedby' => help_block_id,
- 'class' => options[:class],
- id: name.tr(' ', '_')) + name
+ :autocomplete => "off",
+ "aria-describedby" => help_block_id,
+ "class" => options[:class],
+ :id => name.tr(" ", "_")) + name
end
end
end
@@ -86,35 +86,35 @@ module ApplicationSettingsHelper
def oauth_providers_checkboxes
button_based_providers.map do |source|
disabled = Gitlab::CurrentSettings.disabled_oauth_sign_in_sources.include?(source.to_s)
- css_class = ['btn']
- css_class << 'active' unless disabled
- checkbox_name = 'application_setting[enabled_oauth_sign_in_sources][]'
+ css_class = ["btn"]
+ css_class << "active" unless disabled
+ checkbox_name = "application_setting[enabled_oauth_sign_in_sources][]"
name = Gitlab::Auth::OAuth::Provider.label_for(source)
- label_tag(checkbox_name, class: css_class.join(' ')) do
+ label_tag(checkbox_name, class: css_class.join(" ")) do
check_box_tag(checkbox_name, source, !disabled,
- autocomplete: 'off',
- id: name.tr(' ', '_')) + name
+ autocomplete: "off",
+ id: name.tr(" ", "_")) + name
end
end
end
def key_restriction_options_for_select(type)
- bit_size_options = Gitlab::SSHPublicKey.supported_sizes(type).map do |bits|
+ bit_size_options = Gitlab::SSHPublicKey.supported_sizes(type).map { |bits|
["Must be at least #{bits} bits", bits]
- end
+ }
[
- ['Are allowed', 0],
+ ["Are allowed", 0],
*bit_size_options,
- ['Are forbidden', ApplicationSetting::FORBIDDEN_KEY_VALUE]
+ ["Are forbidden", ApplicationSetting::FORBIDDEN_KEY_VALUE],
]
end
def repository_storages_options_for_select(selected)
- options = Gitlab.config.repositories.storages.map do |name, storage|
- ["#{name} - #{storage['gitaly_address']}", name]
- end
+ options = Gitlab.config.repositories.storages.map { |name, storage|
+ ["#{name} - #{storage["gitaly_address"]}", name]
+ }
options_for_select(options, selected)
end
@@ -233,7 +233,7 @@ module ApplicationSettingsHelper
:diff_max_patch_bytes,
:commit_email_hostname,
:protected_ci_variables,
- :local_markdown_version
+ :local_markdown_version,
]
end
diff --git a/app/helpers/auth_helper.rb b/app/helpers/auth_helper.rb
index 2b1d6f49878..410c6041c7a 100644
--- a/app/helpers/auth_helper.rb
+++ b/app/helpers/auth_helper.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module AuthHelper
- PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq).freeze
+ PROVIDERS_WITH_ICONS = %w[twitter github gitlab bitbucket google_oauth2 facebook azure_oauth2 authentiq].freeze
LDAP_PROVIDER = /\Aldap/
def ldap_enabled?
@@ -18,8 +18,8 @@ module AuthHelper
def qa_class_for_provider(provider)
{
- saml: 'qa-saml-login-button',
- github: 'qa-github-login-button'
+ saml: "qa-saml-login-button",
+ github: "qa-github-login-button",
}[provider.to_sym]
end
@@ -32,7 +32,7 @@ module AuthHelper
end
def form_based_provider_priority
- ['crowd', /^ldap/, 'kerberos']
+ ["crowd", /^ldap/, "kerberos"]
end
def form_based_provider_with_highest_priority
@@ -49,7 +49,7 @@ module AuthHelper
end
def form_based_provider?(name)
- [LDAP_PROVIDER, 'crowd'].any? { |pattern| pattern === name.to_s }
+ [LDAP_PROVIDER, "crowd"].any? { |pattern| pattern === name.to_s }
end
def form_based_providers
@@ -86,7 +86,7 @@ module AuthHelper
label = label_for_provider(provider)
if provider_has_icon?(provider)
- file_name = "#{provider.to_s.split('_').first}_#{size}.png"
+ file_name = "#{provider.to_s.split("_").first}_#{size}.png"
image_tag("auth_buttons/#{file_name}", alt: label, title: "Sign in with #{label}")
else
@@ -101,7 +101,7 @@ module AuthHelper
# rubocop: enable CodeReuse/ActiveRecord
def unlink_allowed?(provider)
- %w(saml cas3).exclude?(provider.to_s)
+ %w[saml cas3].exclude?(provider.to_s)
end
extend self
diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb
index 67e7e475920..e792bf4bbb4 100644
--- a/app/helpers/auto_devops_helper.rb
+++ b/app/helpers/auto_devops_helper.rb
@@ -3,7 +3,7 @@
module AutoDevopsHelper
def show_auto_devops_callout?(project)
Feature.get(:auto_devops_banner_disabled).off? &&
- show_callout?('auto_devops_settings_dismissed') &&
+ show_callout?("auto_devops_settings_dismissed") &&
can?(current_user, :admin_pipeline, project) &&
project.has_auto_devops_implicitly_disabled? &&
!project.repository.gitlab_ci_yml &&
diff --git a/app/helpers/avatars_helper.rb b/app/helpers/avatars_helper.rb
index 5906ddabee4..bf099890f6e 100644
--- a/app/helpers/avatars_helper.rb
+++ b/app/helpers/avatars_helper.rb
@@ -38,13 +38,13 @@ module AvatarsHelper
end
end
- def gravatar_icon(user_email = '', size = nil, scale = 2)
+ def gravatar_icon(user_email = "", size = nil, scale = 2)
GravatarService.new.execute(user_email, size, scale) ||
default_avatar
end
def default_avatar
- ActionController::Base.helpers.image_path('no_avatar.png')
+ ActionController::Base.helpers.image_path("no_avatar.png")
end
def author_avatar(commit_or_event, options = {})
@@ -52,7 +52,7 @@ module AvatarsHelper
user: commit_or_event.author,
user_name: commit_or_event.author_name,
user_email: commit_or_event.author_email,
- css_class: 'd-none d-sm-inline'
+ css_class: "d-none d-sm-inline",
}))
end
@@ -77,22 +77,22 @@ module AvatarsHelper
css_class = %W[avatar s#{avatar_size}].push(*options[:css_class])
if has_tooltip
- css_class.push('has-tooltip')
- data_attributes[:container] = 'body'
+ css_class.push("has-tooltip")
+ data_attributes[:container] = "body"
end
if options[:lazy]
- css_class << 'lazy'
+ css_class << "lazy"
data_attributes[:src] = avatar_url
avatar_url = LazyImageTagHelper.placeholder_image
end
image_options = {
- alt: "#{user_name}'s avatar",
- src: avatar_url,
- data: data_attributes,
+ alt: "#{user_name}'s avatar",
+ src: avatar_url,
+ data: data_attributes,
class: css_class,
- title: user_name
+ title: user_name,
}
tag(:img, image_options)
@@ -124,7 +124,7 @@ module AvatarsHelper
bg_key = (source.id % 7) + 1
options[:class] =
- [*options[:class], "identicon bg#{bg_key}"].join(' ')
+ [*options[:class], "identicon bg#{bg_key}"].join(" ")
content_tag(:div, class: options[:class].strip) do
source.name[0, 1].upcase
diff --git a/app/helpers/blame_helper.rb b/app/helpers/blame_helper.rb
index 82c74e2416d..ace4bf539b1 100644
--- a/app/helpers/blame_helper.rb
+++ b/app/helpers/blame_helper.rb
@@ -8,7 +8,7 @@ module BlameHelper
{
now: now,
- started_days_ago: (now - start_date).to_i / 1.day
+ started_days_ago: (now - start_date).to_i / 1.day,
}
end
diff --git a/app/helpers/blob_helper.rb b/app/helpers/blob_helper.rb
index 3e1bb9af5cc..62da4a47afd 100644
--- a/app/helpers/blob_helper.rb
+++ b/app/helpers/blob_helper.rb
@@ -8,18 +8,18 @@ module BlobHelper
end
def no_highlight_files
- %w(credits changelog news copying copyright license authors)
+ %w[credits changelog news copying copyright license authors]
end
def edit_blob_path(project = @project, ref = @ref, path = @path, options = {})
project_edit_blob_path(project,
- tree_join(ref, path),
- options[:link_opts])
+ tree_join(ref, path),
+ options[:link_opts])
end
def ide_edit_path(project = @project, ref = @ref, path = @path, options = {})
- segments = [ide_path, 'project', project.full_path, 'edit', ref]
- segments.concat(['-', path]) if path.present?
+ segments = [ide_path, "project", project.full_path, "edit", ref]
+ segments.concat(["-", path]) if path.present?
File.join(segments)
end
@@ -29,11 +29,11 @@ module BlobHelper
common_classes = "btn js-edit-blob #{options[:extra_class]}"
edit_button_tag(blob,
- common_classes,
- _('Edit'),
- Feature.enabled?(:web_ide_default) ? ide_edit_path(project, ref, path, options) : edit_blob_path(project, ref, path, options),
- project,
- ref)
+ common_classes,
+ _("Edit"),
+ Feature.enabled?(:web_ide_default) ? ide_edit_path(project, ref, path, options) : edit_blob_path(project, ref, path, options),
+ project,
+ ref)
end
def ide_edit_button(project = @project, ref = @ref, path = @path, options = {})
@@ -41,28 +41,32 @@ module BlobHelper
return unless blob = readable_blob(options, path, project, ref)
edit_button_tag(blob,
- 'btn btn-default',
- _('Web IDE'),
- ide_edit_path(project, ref, path, options),
- project,
- ref)
+ "btn btn-default",
+ _("Web IDE"),
+ ide_edit_path(project, ref, path, options),
+ project,
+ ref)
end
def modify_file_button(project = @project, ref = @ref, path = @path, label:, action:, btn_class:, modal_type:)
return unless current_user
- blob = project.repository.blob_at(ref, path) rescue nil
+ blob = begin
+ project.repository.blob_at(ref, path)
+ rescue
+ nil
+ end
return unless blob
common_classes = "btn btn-#{btn_class}"
if !on_top_of_branch?(project, ref)
- button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: { container: 'body' }
+ button_tag label, class: "#{common_classes} disabled has-tooltip", title: "You can only #{action} files when you are on a branch", data: {container: "body"}
elsif blob.stored_externally?
- button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: { container: 'body' }
+ button_tag label, class: "#{common_classes} disabled has-tooltip", title: "It is not possible to #{action} files that are stored in LFS using the web interface", data: {container: "body"}
elsif can_modify_blob?(blob, project, ref)
- button_tag label, class: "#{common_classes}", 'data-target' => "#modal-#{modal_type}-blob", 'data-toggle' => 'modal'
+ button_tag label, :class => common_classes.to_s, "data-target" => "#modal-#{modal_type}-blob", "data-toggle" => "modal"
elsif can?(current_user, :fork_project, project) && can?(current_user, :create_merge_request_in, project)
edit_fork_button_tag(common_classes, project, label, edit_modify_file_fork_params(action), action)
end
@@ -73,9 +77,9 @@ module BlobHelper
project,
ref,
path,
- label: "Replace",
- action: "replace",
- btn_class: "default",
+ label: "Replace",
+ action: "replace",
+ btn_class: "default",
modal_type: "upload"
)
end
@@ -85,9 +89,9 @@ module BlobHelper
project,
ref,
path,
- label: "Delete",
- action: "delete",
- btn_class: "remove",
+ label: "Delete",
+ action: "delete",
+ btn_class: "remove",
modal_type: "remove"
)
end
@@ -102,9 +106,9 @@ module BlobHelper
def editing_preview_title(filename)
if Gitlab::MarkupHelper.previewable?(filename)
- 'Preview'
+ "Preview"
else
- 'Preview changes'
+ "Preview changes"
end
end
@@ -113,7 +117,7 @@ module BlobHelper
# mode - File unix mode
# mode - File name
def blob_icon(mode, name)
- icon("#{file_type_icon_class('file', mode, name)} fw")
+ icon("#{file_type_icon_class("file", mode, name)} fw")
end
def blob_raw_url(**kwargs)
@@ -150,9 +154,9 @@ module BlobHelper
categories = grouped.keys
categories.each_with_object({}) do |category, hash|
- hash[category] = grouped[category].map do |item|
- { name: item.name, id: item.key }
- end
+ hash[category] = grouped[category].map { |item|
+ {name: item.name, id: item.key}
+ }
end
end
private :template_dropdown_names
@@ -175,16 +179,16 @@ module BlobHelper
def blob_editor_paths(project)
{
- 'relative-url-root' => Rails.application.config.relative_url_root,
- 'assets-prefix' => Gitlab::Application.config.assets.prefix,
- 'blob-filename' => @blob && @blob.path,
- 'project-id' => project.id,
- 'is-markdown' => @blob && @blob.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path)
+ "relative-url-root" => Rails.application.config.relative_url_root,
+ "assets-prefix" => Gitlab::Application.config.assets.prefix,
+ "blob-filename" => @blob&.path,
+ "project-id" => project.id,
+ "is-markdown" => @blob&.path && Gitlab::MarkupHelper.gitlab_markdown?(@blob.path),
}
end
def copy_file_path_button(file_path)
- clipboard_button(text: file_path, gfm: "`#{file_path}`", class: 'btn-clipboard btn-transparent prepend-left-5', title: 'Copy file path to clipboard')
+ clipboard_button(text: file_path, gfm: "`#{file_path}`", class: "btn-clipboard btn-transparent prepend-left-5", title: "Copy file path to clipboard")
end
def copy_blob_source_button(blob)
@@ -197,15 +201,15 @@ module BlobHelper
return if blob.empty?
return if blob.binary? || blob.stored_externally?
- title = 'Open raw'
- link_to icon('file-code-o'), blob_raw_path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
+ title = "Open raw"
+ link_to icon("file-code-o"), blob_raw_path, class: "btn btn-sm has-tooltip", target: "_blank", rel: "noopener noreferrer", title: title, data: {container: "body"}
end
def download_blob_button(blob)
return if blob.empty?
- title = 'Download'
- link_to sprite_icon('download'), blob_raw_path(inline: false), download: @path, class: 'btn btn-sm has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: title, data: { container: 'body' }
+ title = "Download"
+ link_to sprite_icon("download"), blob_raw_path(inline: false), download: @path, class: "btn btn-sm has-tooltip", target: "_blank", rel: "noopener noreferrer", title: title, data: {container: "body"}
end
def blob_render_error_reason(viewer)
@@ -217,11 +221,11 @@ module BlobHelper
when :server_side_but_stored_externally
case viewer.blob.external_storage
when :lfs
- 'it is stored in LFS'
+ "it is stored in LFS"
when :build_artifact
- 'it is stored as a job artifact'
+ "it is stored as a job artifact"
else
- 'it is stored externally'
+ "it is stored externally"
end
end
end
@@ -231,16 +235,16 @@ module BlobHelper
options = []
if error == :collapsed
- options << link_to('load it anyway', url_for(safe_params.merge(viewer: viewer.type, expanded: true, format: nil)))
+ options << link_to("load it anyway", url_for(safe_params.merge(viewer: viewer.type, expanded: true, format: nil)))
end
# If the error is `:server_side_but_stored_externally`, the simple viewer will show the same error,
# so don't bother switching.
if viewer.rich? && viewer.blob.rendered_as_text? && error != :server_side_but_stored_externally
- options << link_to('view the source', '#', class: 'js-blob-viewer-switch-btn', data: { viewer: 'simple' })
+ options << link_to("view the source", "#", class: "js-blob-viewer-switch-btn", data: {viewer: "simple"})
end
- options << link_to('download it', blob_raw_path, target: '_blank', rel: 'noopener noreferrer')
+ options << link_to("download it", blob_raw_path, target: "_blank", rel: "noopener noreferrer")
options
end
@@ -262,7 +266,11 @@ module BlobHelper
def readable_blob(options, path, project, ref)
blob = options.delete(:blob)
- blob ||= project.repository.blob_at(ref, path) rescue nil
+ blob ||= begin
+ project.repository.blob_at(ref, path)
+ rescue
+ nil
+ end
blob if blob&.readable_text?
end
@@ -271,7 +279,7 @@ module BlobHelper
{
to: path,
notice: edit_in_new_fork_notice,
- notice_now: edit_in_new_fork_notice_now
+ notice_now: edit_in_new_fork_notice_now,
}
end
@@ -279,20 +287,20 @@ module BlobHelper
{
to: request.fullpath,
notice: edit_in_new_fork_notice_action(action),
- notice_now: edit_in_new_fork_notice_now
+ notice_now: edit_in_new_fork_notice_now,
}
end
- def edit_fork_button_tag(common_classes, project, label, params, action = 'edit')
+ def edit_fork_button_tag(common_classes, project, label, params, action = "edit")
fork_path = project_forks_path(project, namespace_key: current_user.namespace.id, continue: params)
button_tag label,
- class: "#{common_classes} js-edit-blob-link-fork-toggler",
- data: { action: action, fork_path: fork_path }
+ class: "#{common_classes} js-edit-blob-link-fork-toggler",
+ data: {action: action, fork_path: fork_path}
end
def edit_disabled_button_tag(button_text, common_classes)
- button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _('You can only edit files when you are on a branch'), data: { container: 'body' })
+ button_tag(button_text, class: "#{common_classes} disabled has-tooltip", title: _("You can only edit files when you are on a branch"), data: {container: "body"})
end
def edit_link_tag(link_text, edit_path, common_classes)
diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb
index be1e7016a1e..d869897db07 100644
--- a/app/helpers/boards_helper.rb
+++ b/app/helpers/boards_helper.rb
@@ -10,11 +10,11 @@ module BoardsHelper
boards_endpoint: @boards_endpoint,
lists_endpoint: board_lists_path(board),
board_id: board.id,
- disabled: "#{!can?(current_user, :admin_list, current_board_parent)}",
+ disabled: (!can?(current_user, :admin_list, current_board_parent)).to_s,
issue_link_base: build_issue_link_base,
root_path: root_path,
bulk_update_path: @bulk_issues_path,
- default_avatar: image_path(default_avatar)
+ default_avatar: image_path(default_avatar),
}
end
@@ -40,10 +40,10 @@ module BoardsHelper
def current_board_path(board)
@current_board_path ||= if board.group_board?
- group_board_path(current_board_parent, board)
- else
- project_board_path(current_board_parent, board)
- end
+ group_board_path(current_board_parent, board)
+ else
+ project_board_path(current_board_parent, board)
+ end
end
def current_board_parent
@@ -64,7 +64,7 @@ module BoardsHelper
labels_endpoint: @labels_endpoint,
namespace_path: @namespace_path,
project_path: @project&.path,
- group_path: @group&.path
+ group_path: @group&.path,
}
end
@@ -72,16 +72,16 @@ module BoardsHelper
dropdown_options = issue_assignees_dropdown_options
{
- toggle: 'dropdown',
- field_name: 'issue[assignee_ids][]',
+ toggle: "dropdown",
+ field_name: "issue[assignee_ids][]",
first_user: current_user&.username,
- current_user: 'true',
+ current_user: "true",
project_id: @project&.id,
group_id: @group&.id,
- null_user: 'true',
- multi_select: 'true',
+ null_user: "true",
+ multi_select: "true",
'dropdown-header': dropdown_options[:data][:'dropdown-header'],
- 'max-select': dropdown_options[:data][:'max-select']
+ 'max-select': dropdown_options[:data][:'max-select'],
}
end
diff --git a/app/helpers/breadcrumbs_helper.rb b/app/helpers/breadcrumbs_helper.rb
index b067376cea0..377d5099ec0 100644
--- a/app/helpers/breadcrumbs_helper.rb
+++ b/app/helpers/breadcrumbs_helper.rb
@@ -5,7 +5,7 @@ module BreadcrumbsHelper
@breadcrumbs_extra_links ||= []
@breadcrumbs_extra_links.push({
text: text,
- link: link
+ link: link,
})
end
diff --git a/app/helpers/broadcast_messages_helper.rb b/app/helpers/broadcast_messages_helper.rb
index 289cb44f1e8..394d5d54cba 100644
--- a/app/helpers/broadcast_messages_helper.rb
+++ b/app/helpers/broadcast_messages_helper.rb
@@ -4,8 +4,8 @@ module BroadcastMessagesHelper
def broadcast_message(message)
return unless message.present?
- content_tag :div, class: 'broadcast-message', style: broadcast_message_style(message) do
- icon('bullhorn') << ' ' << render_broadcast_message(message)
+ content_tag :div, class: "broadcast-message", style: broadcast_message_style(message) do
+ icon("bullhorn") << " " << render_broadcast_message(message)
end
end
@@ -20,16 +20,16 @@ module BroadcastMessagesHelper
style << "color: #{broadcast_message.font}"
end
- style.join('; ')
+ style.join("; ")
end
def broadcast_message_status(broadcast_message)
if broadcast_message.active?
- 'Active'
+ "Active"
elsif broadcast_message.ended?
- 'Expired'
+ "Expired"
else
- 'Pending'
+ "Pending"
end
end
diff --git a/app/helpers/builds_helper.rb b/app/helpers/builds_helper.rb
index 3c8caec3fe5..c1df49473b2 100644
--- a/app/helpers/builds_helper.rb
+++ b/app/helpers/builds_helper.rb
@@ -15,9 +15,9 @@ module BuildsHelper
def sidebar_build_class(build, current_build)
build_class = []
- build_class << 'active' if build.id === current_build.id
- build_class << 'retried' if build.retried?
- build_class.join(' ')
+ build_class << "active" if build.id === current_build.id
+ build_class << "retried" if build.retried?
+ build_class.join(" ")
end
def javascript_build_options
@@ -25,14 +25,14 @@ module BuildsHelper
page_path: project_job_path(@project, @build),
build_status: @build.status,
build_stage: @build.stage,
- log_state: ''
+ log_state: "",
}
end
def build_failed_issue_options
{
title: "Job Failed ##{@build.id}",
- description: project_job_url(@project, @build)
+ description: project_job_url(@project, @build),
}
end
end
diff --git a/app/helpers/button_helper.rb b/app/helpers/button_helper.rb
index 494c754e7d5..b13bbbf518b 100644
--- a/app/helpers/button_helper.rb
+++ b/app/helpers/button_helper.rb
@@ -20,9 +20,9 @@ module ButtonHelper
#
# See http://clipboardjs.com/#usage
def clipboard_button(data = {})
- css_class = data[:class] || 'btn-clipboard btn-transparent'
- title = data[:title] || 'Copy to clipboard'
- button_text = data[:button_text] || ''
+ css_class = data[:class] || "btn-clipboard btn-transparent"
+ title = data[:title] || "Copy to clipboard"
+ button_text = data[:button_text] || ""
hide_tooltip = data[:hide_tooltip] || false
hide_button_icon = data[:hide_button_icon] || false
@@ -31,7 +31,7 @@ module ButtonHelper
if text = data.delete(:text)
data[:clipboard_text] =
if gfm = data.delete(:gfm)
- { text: text, gfm: gfm }
+ {text: text, gfm: gfm}
else
text
end
@@ -41,7 +41,7 @@ module ButtonHelper
data[:clipboard_target] = target if target
unless hide_tooltip
- data = { toggle: 'tooltip', placement: 'bottom', container: 'body' }.merge(data)
+ data = {toggle: "tooltip", placement: "bottom", container: "body"}.merge(data)
end
button_attributes = {
@@ -49,11 +49,11 @@ module ButtonHelper
data: data,
type: :button,
title: title,
- aria: { label: title }
+ aria: {label: title},
}
content_tag :button, button_attributes do
- concat(sprite_icon('duplicate')) unless hide_button_icon
+ concat(sprite_icon("duplicate")) unless hide_button_icon
concat(button_text)
end
end
@@ -63,14 +63,14 @@ module ButtonHelper
dropdown_description = http_dropdown_description(protocol)
append_url = project.http_url_to_repo if append_link
- dropdown_item_with_description(protocol, dropdown_description, href: append_url, data: { clone_type: 'http' })
+ dropdown_item_with_description(protocol, dropdown_description, href: append_url, data: {clone_type: "http"})
end
def http_dropdown_description(protocol)
if current_user.try(:require_password_creation_for_git?)
- _("Set a password on your account to pull or push via %{protocol}.") % { protocol: protocol }
+ _("Set a password on your account to pull or push via %{protocol}.") % {protocol: protocol}
elsif current_user.try(:require_personal_access_token_creation_for_git_auth?)
- _("Create a personal access token on your account to pull or push via %{protocol}.") % { protocol: protocol }
+ _("Create a personal access token on your account to pull or push via %{protocol}.") % {protocol: protocol}
end
end
@@ -82,18 +82,18 @@ module ButtonHelper
append_url = project.ssh_url_to_repo if append_link
- dropdown_item_with_description('SSH', dropdown_description, href: append_url, data: { clone_type: 'ssh' })
+ dropdown_item_with_description("SSH", dropdown_description, href: append_url, data: {clone_type: "ssh"})
end
def dropdown_item_with_description(title, description, href: nil, data: nil, default: false)
active_class = "is-active" if default
- button_content = content_tag(:strong, title, class: 'dropdown-menu-inner-title')
- button_content << content_tag(:span, description, class: 'dropdown-menu-inner-content') if description
+ button_content = content_tag(:strong, title, class: "dropdown-menu-inner-title")
+ button_content << content_tag(:span, description, class: "dropdown-menu-inner-content") if description
content_tag (href ? :a : :span),
(href ? button_content : title),
class: "#{title.downcase}-selector #{active_class}",
- href: (href if href),
- data: (data if data)
+ href: href,
+ data: data
end
end
diff --git a/app/helpers/calendar_helper.rb b/app/helpers/calendar_helper.rb
index ad4116fc3da..c36d74ff80a 100644
--- a/app/helpers/calendar_helper.rb
+++ b/app/helpers/calendar_helper.rb
@@ -2,9 +2,9 @@
module CalendarHelper
def calendar_url_options
- { format: :ics,
- feed_token: current_user.try(:feed_token),
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date' }
+ {format: :ics,
+ feed_token: current_user.try(:feed_token),
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date",}
end
end
diff --git a/app/helpers/ci_status_helper.rb b/app/helpers/ci_status_helper.rb
index 923a06a0512..9accced1237 100644
--- a/app/helpers/ci_status_helper.rb
+++ b/app/helpers/ci_status_helper.rb
@@ -14,17 +14,17 @@ module CiStatusHelper
end
label = case status
- when 'success'
- 'passed'
- when 'success_with_warnings'
- 'passed with warnings'
- when 'manual'
- 'waiting for manual action'
- when 'scheduled'
- 'waiting for delayed job'
+ when "success"
+ "passed"
+ when "success_with_warnings"
+ "passed with warnings"
+ when "manual"
+ "waiting for manual action"
+ when "scheduled"
+ "waiting for delayed job"
else
status
- end
+ end
translation = "CiStatusLabel|#{label}"
s_(translation)
end
@@ -35,14 +35,14 @@ module CiStatusHelper
end
case status
- when 'success'
- s_('CiStatusText|passed')
- when 'success_with_warnings'
- s_('CiStatusText|passed')
- when 'manual'
- s_('CiStatusText|blocked')
- when 'scheduled'
- s_('CiStatusText|delayed')
+ when "success"
+ s_("CiStatusText|passed")
+ when "success_with_warnings"
+ s_("CiStatusText|passed")
+ when "manual"
+ s_("CiStatusText|blocked")
+ when "scheduled"
+ s_("CiStatusText|delayed")
else
# All states are already being translated inside the detailed statuses:
# :running => Gitlab::Ci::Status::Running
@@ -58,7 +58,7 @@ module CiStatusHelper
end
def ci_status_for_statuseable(subject)
- status = subject.try(:status) || 'not found'
+ status = subject.try(:status) || "not found"
status.humanize
end
@@ -69,28 +69,28 @@ module CiStatusHelper
icon_name =
case status
- when 'success'
- 'status_success'
- when 'success_with_warnings'
- 'status_warning'
- when 'failed'
- 'status_failed'
- when 'pending'
- 'status_pending'
- when 'running'
- 'status_running'
- when 'play'
- 'play'
- when 'created'
- 'status_created'
- when 'skipped'
- 'status_skipped'
- when 'manual'
- 'status_manual'
- when 'scheduled'
- 'status_scheduled'
+ when "success"
+ "status_success"
+ when "success_with_warnings"
+ "status_warning"
+ when "failed"
+ "status_failed"
+ when "pending"
+ "status_pending"
+ when "running"
+ "status_running"
+ when "play"
+ "play"
+ when "created"
+ "status_created"
+ when "skipped"
+ "status_skipped"
+ when "manual"
+ "status_manual"
+ when "scheduled"
+ "status_scheduled"
else
- 'status_canceled'
+ "status_canceled"
end
sprite_icon(icon_name, size: size)
@@ -100,46 +100,48 @@ module CiStatusHelper
"pipeline-status/#{pipeline_status.sha}-#{pipeline_status.status}"
end
- def render_project_pipeline_status(pipeline_status, tooltip_placement: 'left')
+ def render_project_pipeline_status(pipeline_status, tooltip_placement: "left")
project = pipeline_status.project
path = pipelines_project_commit_path(project, pipeline_status.sha, ref: pipeline_status.ref)
render_status_with_link(
- 'commit',
+ "commit",
pipeline_status.status,
path,
- tooltip_placement: tooltip_placement)
+ tooltip_placement: tooltip_placement
+ )
end
- def render_commit_status(commit, ref: nil, tooltip_placement: 'left')
+ def render_commit_status(commit, ref: nil, tooltip_placement: "left")
project = commit.project
path = pipelines_project_commit_path(project, commit, ref: ref)
render_status_with_link(
- 'commit',
+ "commit",
commit.status(ref),
path,
tooltip_placement: tooltip_placement,
- icon_size: 24)
+ icon_size: 24
+ )
end
- def render_pipeline_status(pipeline, tooltip_placement: 'left')
+ def render_pipeline_status(pipeline, tooltip_placement: "left")
project = pipeline.project
path = project_pipeline_path(project, pipeline)
- render_status_with_link('pipeline', pipeline.status, path, tooltip_placement: tooltip_placement)
+ render_status_with_link("pipeline", pipeline.status, path, tooltip_placement: tooltip_placement)
end
- def render_status_with_link(type, status, path = nil, tooltip_placement: 'left', cssclass: '', container: 'body', icon_size: 16)
+ def render_status_with_link(type, status, path = nil, tooltip_placement: "left", cssclass: "", container: "body", icon_size: 16)
klass = "ci-status-link ci-status-icon-#{status.dasherize} #{cssclass}"
title = "#{type.titleize}: #{ci_label_for_status(status)}"
- data = { toggle: 'tooltip', placement: tooltip_placement, container: container }
+ data = {toggle: "tooltip", placement: tooltip_placement, container: container}
if path
link_to ci_icon_for_status(status, size: icon_size), path,
- class: klass, title: title, data: data
+ class: klass, title: title, data: data
else
content_tag :span, ci_icon_for_status(status, size: icon_size),
- class: klass, title: title, data: data
+ class: klass, title: title, data: data
end
end
diff --git a/app/helpers/clusters_helper.rb b/app/helpers/clusters_helper.rb
index 916dcb1a308..e7e3093cee3 100644
--- a/app/helpers/clusters_helper.rb
+++ b/app/helpers/clusters_helper.rb
@@ -10,8 +10,8 @@ module ClustersHelper
return if Gitlab::CurrentSettings.current_application_settings.hide_third_party_offers?
return unless show_gcp_signup_offer?
- content_tag :section, class: 'no-animate expanded' do
- render 'clusters/clusters/gcp_signup_offer_banner'
+ content_tag :section, class: "no-animate expanded" do
+ render "clusters/clusters/gcp_signup_offer_banner"
end
end
end
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index d58f634425b..f1e4531c21d 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -18,7 +18,7 @@ module CommitsHelper
end
def commit_to_html(commit, ref, project)
- render 'projects/commits/commit',
+ render "projects/commits/commit",
commit: commit,
ref: ref,
project: project
@@ -29,27 +29,27 @@ module CommitsHelper
return unless @project && @ref
# Add the root project link and the arrow icon
- crumbs = content_tag(:li, class: 'breadcrumb-item') do
+ crumbs = content_tag(:li, class: "breadcrumb-item") {
link_to(
@project.path,
project_commits_path(@project, @ref)
)
- end
+ }
if @path
- parts = @path.split('/')
+ parts = @path.split("/")
parts.each_with_index do |part, i|
- crumbs << content_tag(:li, class: 'breadcrumb-item') do
+ crumbs << content_tag(:li, class: "breadcrumb-item") {
# The text is just the individual part, but the link needs all the parts before it
link_to(
part,
project_commits_path(
@project,
- tree_join(@ref, parts[0..i].join('/'))
+ tree_join(@ref, parts[0..i].join("/"))
)
)
- end
+ }
end
end
@@ -64,31 +64,31 @@ module CommitsHelper
# Returns a link formatted as a commit branch link
def commit_branch_link(url, text)
- link_to(url, class: 'badge badge-gray ref-name branch-link') do
- sprite_icon('branch', size: 12, css_class: 'fork-svg') + "#{text}"
+ link_to(url, class: "badge badge-gray ref-name branch-link") do
+ sprite_icon("branch", size: 12, css_class: "fork-svg") + text.to_s
end
end
# Returns the sorted alphabetically links to branches, separated by a comma
def commit_branches_links(project, branches)
- branches.sort.map do |branch|
+ branches.sort.map { |branch|
commit_branch_link(project_ref_path(project, branch), branch)
- end.join(' ').html_safe
+ }.join(" ").html_safe
end
# Returns a link formatted as a commit tag link
def commit_tag_link(url, text)
- link_to(url, class: 'badge badge-gray ref-name') do
- sprite_icon('tag', size: 12, css_class: 'append-right-5 vertical-align-middle') + "#{text}"
+ link_to(url, class: "badge badge-gray ref-name") do
+ sprite_icon("tag", size: 12, css_class: "append-right-5 vertical-align-middle") + text.to_s
end
end
# Returns the sorted links to tags, separated by a comma
def commit_tags_links(project, tags)
sorted = VersionSorter.rsort(tags)
- sorted.map do |tag|
+ sorted.map { |tag|
commit_tag_link(project_ref_path(project, tag), tag)
- end.join(' ').html_safe
+ }.join(" ").html_safe
end
def link_to_browse_code(project, commit)
@@ -105,21 +105,21 @@ module CommitsHelper
tooltip = _("Browse Directory")
end
- link_to url, class: "btn btn-default has-tooltip", title: tooltip, data: { container: "body" } do
- sprite_icon('folder-open')
+ link_to url, class: "btn btn-default has-tooltip", title: tooltip, data: {container: "body"} do
+ sprite_icon("folder-open")
end
end
def revert_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true)
- commit_action_link('revert', commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip)
+ commit_action_link("revert", commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip)
end
def cherry_pick_commit_link(commit, continue_to_path, btn_class: nil, has_tooltip: true)
- commit_action_link('cherry-pick', commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip)
+ commit_action_link("cherry-pick", commit, continue_to_path, btn_class: btn_class, has_tooltip: has_tooltip)
end
def commit_signature_badge_classes(additional_classes)
- %w(btn gpg-status-box) + Array(additional_classes)
+ %w[btn gpg-status-box] + Array(additional_classes)
end
protected
@@ -148,13 +148,13 @@ module CommitsHelper
end
link_options = {
- class: "commit-#{options[:source]}-link"
+ class: "commit-#{options[:source]}-link",
}
if user.nil?
mail_to(source_email, text, link_options)
else
- link_to(text, user_path(user), { class: "commit-#{options[:source]}-link js-user-link", data: { user_id: user.id } })
+ link_to(text, user_path(user), {class: "commit-#{options[:source]}-link js-user-link", data: {user_id: user.id}})
end
end
@@ -165,31 +165,31 @@ module CommitsHelper
btn_class = "btn btn-#{btn_class}" unless btn_class.nil?
if can_collaborate_with_project?(@project)
- link_to action.capitalize, "#modal-#{action}-commit", 'data-toggle' => 'modal', 'data-container' => 'body', title: (tooltip if has_tooltip), class: "#{btn_class} #{'has-tooltip' if has_tooltip}"
+ link_to action.capitalize, "#modal-#{action}-commit", "data-toggle" => "modal", "data-container" => "body", :title => (tooltip if has_tooltip), :class => "#{btn_class} #{"has-tooltip" if has_tooltip}"
elsif can?(current_user, :fork_project, @project)
continue_params = {
to: continue_to_path,
notice: "#{edit_in_new_fork_notice} Try to #{action} this commit again.",
- notice_now: edit_in_new_fork_notice_now
+ notice_now: edit_in_new_fork_notice_now,
}
fork_path = project_forks_path(@project,
namespace_key: current_user.namespace.id,
continue: continue_params)
- link_to action.capitalize, fork_path, class: btn_class, method: :post, 'data-toggle' => 'tooltip', 'data-container' => 'body', title: (tooltip if has_tooltip)
+ link_to action.capitalize, fork_path, :class => btn_class, :method => :post, "data-toggle" => "tooltip", "data-container" => "body", :title => (tooltip if has_tooltip)
end
end
def view_file_button(commit_sha, diff_new_path, project, replaced: false)
- title = replaced ? _('View replaced file @ ') : _('View file @ ')
+ title = replaced ? _("View replaced file @ ") : _("View file @ ")
link_to(
project_blob_path(project,
- tree_join(commit_sha, diff_new_path)),
- class: 'btn view-file js-view-file'
+ tree_join(commit_sha, diff_new_path)),
+ class: "btn view-file js-view-file"
) do
raw(title) + content_tag(:span, Commit.truncate_sha(commit_sha),
- class: 'commit-sha')
+ class: "commit-sha")
end
end
@@ -199,8 +199,8 @@ module CommitsHelper
external_url = environment.external_url_for(diff_new_path, commit_sha)
return unless external_url
- link_to(external_url, class: 'btn btn-file-option has-tooltip', target: '_blank', rel: 'noopener noreferrer', title: "View on #{environment.formatted_external_url}", data: { container: 'body' }) do
- icon('external-link')
+ link_to(external_url, class: "btn btn-file-option has-tooltip", target: "_blank", rel: "noopener noreferrer", title: "View on #{environment.formatted_external_url}", data: {container: "body"}) do
+ icon("external-link")
end
end
diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb
index 9ece8b0bc5b..f2d2e42eb96 100644
--- a/app/helpers/compare_helper.rb
+++ b/app/helpers/compare_helper.rb
@@ -15,7 +15,7 @@ module CompareHelper
project,
merge_request: {
source_branch: to,
- target_branch: from
+ target_branch: from,
}
)
end
diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb
index d0ef86851ad..ea1474fbb9d 100644
--- a/app/helpers/components_helper.rb
+++ b/app/helpers/components_helper.rb
@@ -2,8 +2,8 @@
module ComponentsHelper
def gitlab_workhorse_version
- if request.headers['Gitlab-Workhorse'].present?
- request.headers['Gitlab-Workhorse'].split('-').first
+ if request.headers["Gitlab-Workhorse"].present?
+ request.headers["Gitlab-Workhorse"].split("-").first
else
Gitlab::Workhorse.version
end
diff --git a/app/helpers/conversational_development_index_helper.rb b/app/helpers/conversational_development_index_helper.rb
index 37e5bb325fb..60c8a0457c8 100644
--- a/app/helpers/conversational_development_index_helper.rb
+++ b/app/helpers/conversational_development_index_helper.rb
@@ -3,11 +3,11 @@
module ConversationalDevelopmentIndexHelper
def score_level(score)
if score < 33.33
- 'low'
+ "low"
elsif score < 66.66
- 'average'
+ "average"
else
- 'high'
+ "high"
end
end
diff --git a/app/helpers/cookies_helper.rb b/app/helpers/cookies_helper.rb
index 3a7e9987190..1670f2b59cc 100644
--- a/app/helpers/cookies_helper.rb
+++ b/app/helpers/cookies_helper.rb
@@ -4,6 +4,6 @@ module CookiesHelper
def set_secure_cookie(key, value, httponly: false, permanent: false)
cookie_jar = permanent ? cookies.permanent : cookies
- cookie_jar[key] = { value: value, secure: Gitlab.config.gitlab.https, httponly: httponly }
+ cookie_jar[key] = {value: value, secure: Gitlab.config.gitlab.https, httponly: httponly}
end
end
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 32431959851..7b733c496eb 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -16,7 +16,7 @@ module DiffHelper
def diff_view
@diff_view ||= begin
- diff_views = %w(inline parallel)
+ diff_views = %w[inline parallel]
diff_view = params[:view] || cookies[:diff_view]
diff_view = diff_views.first unless diff_views.include?(diff_view)
diff_view.to_sym
@@ -24,9 +24,9 @@ module DiffHelper
end
def diff_options
- options = { ignore_whitespace_change: hide_whitespace?, expanded: diffs_expanded? }
+ options = {ignore_whitespace_change: hide_whitespace?, expanded: diffs_expanded?}
- if action_name == 'diff_for_path'
+ if action_name == "diff_for_path"
options[:expanded] = true
options[:paths] = params.values_at(:old_path, :new_path)
end
@@ -34,23 +34,23 @@ module DiffHelper
options
end
- def diff_match_line(old_pos, new_pos, text: '', view: :inline, bottom: false)
+ def diff_match_line(old_pos, new_pos, text: "", view: :inline, bottom: false)
content_line_class = %w[line_content match]
- content_line_class << 'parallel' if view == :parallel
+ content_line_class << "parallel" if view == :parallel
line_num_class = %w[diff-line-num unfold js-unfold]
- line_num_class << 'js-unfold-bottom' if bottom
+ line_num_class << "js-unfold-bottom" if bottom
html = []
if old_pos
- html << content_tag(:td, '...', class: [*line_num_class, 'old_line'], data: { linenumber: old_pos })
- html << content_tag(:td, text, class: [*content_line_class, 'left-side']) if view == :parallel
+ html << content_tag(:td, "...", class: [*line_num_class, "old_line"], data: {linenumber: old_pos})
+ html << content_tag(:td, text, class: [*content_line_class, "left-side"]) if view == :parallel
end
if new_pos
- html << content_tag(:td, '...', class: [*line_num_class, 'new_line'], data: { linenumber: new_pos })
- html << content_tag(:td, text, class: [*content_line_class, ('right-side' if view == :parallel)])
+ html << content_tag(:td, "...", class: [*line_num_class, "new_line"], data: {linenumber: new_pos})
+ html << content_tag(:td, text, class: [*content_line_class, ("right-side" if view == :parallel)])
end
html.join.html_safe
@@ -61,7 +61,7 @@ module DiffHelper
"&nbsp;".html_safe
else
# We can't use `sub` because the HTML-safeness of `line` will not survive.
- line[0] = '' if line.start_with?('+', '-', ' ')
+ line[0] = "" if line.start_with?("+", "-", " ")
line
end
end
@@ -71,12 +71,12 @@ module DiffHelper
discussions_left = discussions_right = nil
- if left && left.discussable? && (left.unchanged? || left.removed?)
+ if left&.discussable? && (left&.unchanged? || left&.removed?)
line_code = diff_file.line_code(left)
discussions_left = @grouped_diff_discussions[line_code]
end
- if right && right.discussable? && right.added?
+ if right&.discussable? && right&.added?
line_code = diff_file.line_code(right)
discussions_right = @grouped_diff_discussions[line_code]
end
@@ -85,26 +85,26 @@ 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)
project_url, tree_url = submodule_links(blob, ref, repository)
commit_id = if tree_url.nil?
- Commit.truncate_sha(blob.id)
- else
- link_to Commit.truncate_sha(blob.id), tree_url
- end
+ Commit.truncate_sha(blob.id)
+ else
+ link_to Commit.truncate_sha(blob.id), tree_url
+ end
[
content_tag(:span, link_to(truncate(blob.name, length: 40), project_url)),
- '@',
- content_tag(:span, commit_id, class: 'commit-sha')
- ].join(' ').html_safe
+ "@",
+ content_tag(:span, commit_id, class: "commit-sha"),
+ ].join(" ").html_safe
end
def diff_file_blob_raw_url(diff_file, only_path: false)
@@ -129,8 +129,8 @@ module DiffHelper
def diff_file_html_data(project, diff_file_path, diff_commit_id)
{
blob_diff_path: project_blob_diff_path(project,
- tree_join(diff_commit_id, diff_file_path)),
- view: diff_view
+ tree_join(diff_commit_id, diff_file_path)),
+ view: diff_view,
}
end
@@ -165,7 +165,7 @@ module DiffHelper
# Always use HTML to handle case where JSON diff rendered this button
params_copy.delete(:format)
- link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? 'btn active' : 'btn'), data: { view_type: name } do
+ link_to url_for(params_copy), id: "#{name}-diff-btn", class: (selected ? "btn active" : "btn"), data: {view_type: name} do
title
end
end
@@ -186,7 +186,7 @@ module DiffHelper
end
def hide_whitespace?
- params[:w] == '1'
+ params[:w] == "1"
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -196,8 +196,8 @@ module DiffHelper
# rubocop: enable CodeReuse/ActiveRecord
def toggle_whitespace_link(url, options)
- options[:class] = [*options[:class], 'btn btn-default'].join(' ')
- link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: options[:class]
+ options[:class] = [*options[:class], "btn btn-default"].join(" ")
+ link_to "#{hide_whitespace? ? "Show" : "Hide"} whitespace changes", url, class: options[:class]
end
def render_overflow_warning?(diff_files)
diff --git a/app/helpers/dropdowns_helper.rb b/app/helpers/dropdowns_helper.rb
index 8d8c62f1291..890d506d6c5 100644
--- a/app/helpers/dropdowns_helper.rb
+++ b/app/helpers/dropdowns_helper.rb
@@ -3,7 +3,7 @@
module DropdownsHelper
def dropdown_tag(toggle_text, options: {}, &block)
content_tag :div, class: "dropdown #{options[:wrapper_class] if options.key?(:wrapper_class)}" do
- data_attr = { toggle: "dropdown" }
+ data_attr = {toggle: "dropdown"}
if options.key?(:data)
data_attr = options[:data].merge(data_attr)
@@ -15,7 +15,7 @@ module DropdownsHelper
dropdown_output = dropdown_toggle_link(toggle_text, data_attr, options)
end
- dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") do
+ dropdown_output << content_tag(:div, class: "dropdown-menu dropdown-select #{options[:dropdown_class] if options.key?(:dropdown_class)}") {
output = []
if options.key?(:title)
@@ -26,19 +26,19 @@ module DropdownsHelper
output << dropdown_filter(options[:placeholder])
end
- output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") do
+ output << content_tag(:div, class: "dropdown-content #{options[:content_class] if options.key?(:content_class)}") {
capture(&block) if block && !options.key?(:footer_content)
- end
+ }
if block && options[:footer_content]
- output << content_tag(:div, class: "dropdown-footer") do
+ output << content_tag(:div, class: "dropdown-footer") {
capture(&block)
- end
+ }
end
output << dropdown_loading
output.join.html_safe
- end
+ }
dropdown_output.html_safe
end
@@ -47,8 +47,8 @@ module DropdownsHelper
def dropdown_toggle(toggle_text, data_attr, options = {})
default_label = data_attr[:default_label]
content_tag(:button, disabled: options[:disabled], class: "dropdown-menu-toggle #{options[:toggle_class] if options.key?(:toggle_class)}", id: (options[:id] if options.key?(:id)), type: "button", data: data_attr) do
- output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{'is-default' if toggle_text == default_label}")
- output << icon('chevron-down')
+ output = content_tag(:span, toggle_text, class: "dropdown-toggle-text #{"is-default" if toggle_text == default_label}")
+ output << icon("chevron-down")
output.html_safe
end
end
@@ -63,17 +63,17 @@ module DropdownsHelper
title_output = []
if options.fetch(:back, false)
- title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: { label: "Go back" }, type: "button") do
- icon('arrow-left')
- end
+ title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-back", aria: {label: "Go back"}, type: "button") {
+ icon("arrow-left")
+ }
end
title_output << content_tag(:span, title)
if options.fetch(:close, true)
- title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: { label: "Close" }, type: "button") do
- icon('times', class: 'dropdown-menu-close-icon')
- end
+ title_output << content_tag(:button, class: "dropdown-title-button dropdown-menu-close", aria: {label: "Close"}, type: "button") {
+ icon("times", class: "dropdown-menu-close-icon")
+ }
end
title_output.join.html_safe
@@ -82,8 +82,8 @@ module DropdownsHelper
def dropdown_input(placeholder, input_id: nil)
content_tag :div, class: "dropdown-input" do
- filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: 'off'
- filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button")
+ filter_output = text_field_tag input_id, nil, class: "dropdown-input-field dropdown-no-filter", placeholder: placeholder, autocomplete: "off"
+ filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button")
filter_output.html_safe
end
@@ -91,9 +91,9 @@ module DropdownsHelper
def dropdown_filter(placeholder, search_id: nil)
content_tag :div, class: "dropdown-input" do
- filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: 'off'
- filter_output << icon('search', class: "dropdown-input-search")
- filter_output << icon('times', class: "dropdown-input-clear js-dropdown-input-clear", role: "button")
+ filter_output = search_field_tag search_id, nil, class: "dropdown-input-field", placeholder: placeholder, autocomplete: "off"
+ filter_output << icon("search", class: "dropdown-input-search")
+ filter_output << icon("times", class: "dropdown-input-clear js-dropdown-input-clear", role: "button")
filter_output.html_safe
end
@@ -119,7 +119,7 @@ module DropdownsHelper
def dropdown_loading
content_tag :div, class: "dropdown-loading" do
- icon('spinner spin')
+ icon("spinner spin")
end
end
end
diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb
index 96471d15aac..ed5f011644e 100644
--- a/app/helpers/emails_helper.rb
+++ b/app/helpers/emails_helper.rb
@@ -14,11 +14,11 @@ module EmailsHelper
"action" => {
"@type" => "ViewAction",
"name" => name,
- "url" => url
- }
- }
+ "url" => url,
+ },
+ }
- content_tag :script, type: 'application/ld+json' do
+ content_tag :script, type: "application/ld+json" do
data.to_json.html_safe
end
end
@@ -27,7 +27,7 @@ module EmailsHelper
def action_title(url)
return unless url
- %w(merge_requests issues commit).each do |action|
+ %w[merge_requests issues commit].each do |action|
if url.split("/").include?(action)
return "View #{action.humanize.singularize}"
end
@@ -37,8 +37,8 @@ module EmailsHelper
end
def sanitize_name(name)
- if name =~ URI::DEFAULT_PARSER.regexp[:URI_REF]
- name.tr('.', '_')
+ if name&.match?(URI::DEFAULT_PARSER.regexp[:URI_REF])
+ name.tr(".", "_")
else
name
end
@@ -47,10 +47,10 @@ module EmailsHelper
def password_reset_token_valid_time
valid_hours = Devise.reset_password_within / 60 / 60
if valid_hours >= 24
- unit = 'day'
+ unit = "day"
valid_length = (valid_hours / 24).floor
else
- unit = 'hour'
+ unit = "hour"
valid_length = valid_hours.floor
end
@@ -58,7 +58,7 @@ module EmailsHelper
end
def reset_token_expire_message
- link_tag = link_to('request a new one', new_user_password_url(user_email: @user.email))
+ link_tag = link_to("request a new one", new_user_password_url(user_email: @user.email))
"This link is valid for #{password_reset_token_valid_time}. " \
"After it expires, you can #{link_tag}."
end
@@ -67,13 +67,13 @@ module EmailsHelper
if current_appearance&.header_logo?
image_tag(
current_appearance.header_logo_path,
- style: 'height: 50px'
+ style: "height: 50px"
)
else
image_tag(
- image_url('mailers/gitlab_header_logo.gif'),
- size: '55x50',
- alt: 'GitLab'
+ image_url("mailers/gitlab_header_logo.gif"),
+ size: "55x50",
+ alt: "GitLab"
)
end
end
@@ -81,38 +81,38 @@ module EmailsHelper
def email_default_heading(text)
content_tag :h1, text, style: [
"font-family:'Helvetica Neue',Helvetica,Arial,sans-serif",
- 'color:#333333',
- 'font-size:18px',
- 'font-weight:400',
- 'line-height:1.4',
- 'padding:0',
- 'margin:0',
- 'text-align:center'
- ].join(';')
+ "color:#333333",
+ "font-size:18px",
+ "font-weight:400",
+ "line-height:1.4",
+ "padding:0",
+ "margin:0",
+ "text-align:center",
+ ].join(";")
end
# "You are receiving this email because #{reason}"
def notification_reason_text(reason)
string = case reason
when NotificationReason::OWN_ACTIVITY
- 'of your activity'
+ "of your activity"
when NotificationReason::ASSIGNED
- 'you have been assigned an item'
+ "you have been assigned an item"
when NotificationReason::MENTIONED
- 'you have been mentioned'
+ "you have been mentioned"
else
- 'of your account'
- end
+ "of your account"
+ end
"#{string} on #{Gitlab.config.gitlab.host}"
end
def create_list_id_string(project, list_id_max_length = 255)
project_path_as_domain = project.full_path.downcase
- .split('/').reverse.join('/')
- .gsub(%r{[^a-z0-9\/]}, '-')
- .gsub(%r{\/+}, '.')
- .gsub(/(\A\.+|\.+\z)/, '')
+ .split("/").reverse.join("/")
+ .gsub(%r{[^a-z0-9\/]}, "-")
+ .gsub(%r{\/+}, ".")
+ .gsub(/(\A\.+|\.+\z)/, "")
max_domain_length = list_id_max_length - Gitlab.config.gitlab.host.length - project.id.to_s.length - 2
@@ -135,25 +135,25 @@ module EmailsHelper
def html_header_message
return unless show_header?
- render_message(:header_message, style: '')
+ render_message(:header_message, style: "")
end
def html_footer_message
return unless show_footer?
- render_message(:footer_message, style: '')
+ render_message(:footer_message, style: "")
end
def text_header_message
return unless show_header?
- strip_tags(render_message(:header_message, style: ''))
+ strip_tags(render_message(:header_message, style: ""))
end
def text_footer_message
return unless show_footer?
- strip_tags(render_message(:footer_message, style: ''))
+ strip_tags(render_message(:footer_message, style: ""))
end
private
diff --git a/app/helpers/environment_helper.rb b/app/helpers/environment_helper.rb
index 2b7320817ed..1b45ec53a2c 100644
--- a/app/helpers/environment_helper.rb
+++ b/app/helpers/environment_helper.rb
@@ -21,7 +21,7 @@ module EnvironmentHelper
def deployment_link(deployment, text: nil)
return unless deployment
- link_label = text ? text : "##{deployment.iid}"
+ link_label = text || "##{deployment.iid}"
link_to link_label, [deployment.project.namespace.becomes(Namespace), deployment.project, deployment.deployable]
end
diff --git a/app/helpers/environments_helper.rb b/app/helpers/environments_helper.rb
index 365b94f5a3e..39a7c473f58 100644
--- a/app/helpers/environments_helper.rb
+++ b/app/helpers/environments_helper.rb
@@ -3,7 +3,7 @@
module EnvironmentsHelper
def environments_list_data
{
- endpoint: project_environments_path(@project, format: :json)
+ endpoint: project_environments_path(@project, format: :json),
}
end
@@ -11,26 +11,26 @@ module EnvironmentsHelper
{
"endpoint" => folder_project_environments_path(@project, @folder, format: :json),
"folder-name" => @folder,
- "can-read-environment" => can?(current_user, :read_environment, @project).to_s
+ "can-read-environment" => can?(current_user, :read_environment, @project).to_s,
}
end
def metrics_data(project, environment)
{
- "settings-path" => edit_project_service_path(project, 'prometheus'),
+ "settings-path" => edit_project_service_path(project, "prometheus"),
"clusters-path" => project_clusters_path(project),
- "current-environment-name": environment.name,
- "documentation-path" => help_page_path('administration/monitoring/prometheus/index.md'),
- "empty-getting-started-svg-path" => image_path('illustrations/monitoring/getting_started.svg'),
- "empty-loading-svg-path" => image_path('illustrations/monitoring/loading.svg'),
- "empty-no-data-svg-path" => image_path('illustrations/monitoring/no_data.svg'),
- "empty-unable-to-connect-svg-path" => image_path('illustrations/monitoring/unable_to_connect.svg'),
+ :"current-environment-name" => environment.name,
+ "documentation-path" => help_page_path("administration/monitoring/prometheus/index.md"),
+ "empty-getting-started-svg-path" => image_path("illustrations/monitoring/getting_started.svg"),
+ "empty-loading-svg-path" => image_path("illustrations/monitoring/loading.svg"),
+ "empty-no-data-svg-path" => image_path("illustrations/monitoring/no_data.svg"),
+ "empty-unable-to-connect-svg-path" => image_path("illustrations/monitoring/unable_to_connect.svg"),
"metrics-endpoint" => additional_metrics_project_environment_path(project, environment, format: :json),
"deployment-endpoint" => project_environment_deployments_path(project, environment, format: :json),
- "environments-endpoint": project_environments_path(project, format: :json),
+ :"environments-endpoint" => project_environments_path(project, format: :json),
"project-path" => project_path(project),
"tags-path" => project_tags_path(project),
- "has-metrics" => "#{environment.has_metrics?}"
+ "has-metrics" => environment.has_metrics?.to_s,
}
end
end
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb
index 1371e9993b4..42739862aa1 100644
--- a/app/helpers/events_helper.rb
+++ b/app/helpers/events_helper.rb
@@ -2,23 +2,23 @@
module EventsHelper
ICON_NAMES_BY_EVENT_TYPE = {
- 'pushed to' => 'commit',
- 'pushed new' => 'commit',
- 'created' => 'status_open',
- 'opened' => 'status_open',
- 'closed' => 'status_closed',
- 'accepted' => 'fork',
- 'commented on' => 'comment',
- 'deleted' => 'remove',
- 'imported' => 'import',
- 'joined' => 'users'
+ "pushed to" => "commit",
+ "pushed new" => "commit",
+ "created" => "status_open",
+ "opened" => "status_open",
+ "closed" => "status_closed",
+ "accepted" => "fork",
+ "commented on" => "comment",
+ "deleted" => "remove",
+ "imported" => "import",
+ "joined" => "users",
}.freeze
def link_to_author(event, self_added: false)
author = event.author
if author
- name = self_added ? 'You' : author.name
+ name = self_added ? "You" : author.name
link_to name, user_path(author.username), title: name
else
escape_once(event.author_name)
@@ -26,31 +26,31 @@ module EventsHelper
end
def event_action_name(event)
- target = if event.target_type
- if event.note?
- event.note_target_type
- else
- event.target_type.titleize.downcase
- end
- else
- 'project'
- end
+ target = if event.target_type
+ if event.note?
+ event.note_target_type
+ else
+ event.target_type.titleize.downcase
+ end
+ else
+ "project"
+ end
[event.action_name, target].join(" ")
end
def event_filter_link(key, text, tooltip)
key = key.to_s
- active = 'active' if @event_filter.active?(key)
+ active = "active" if @event_filter.active?(key)
link_opts = {
class: "event-filter-link",
- id: "#{key}_event_filter",
- title: tooltip
+ id: "#{key}_event_filter",
+ title: tooltip,
}
content_tag :li, class: active do
link_to request.path, link_opts do
- content_tag(:span, ' ' + text)
+ content_tag(:span, " " + text)
end
end
end
@@ -111,12 +111,12 @@ module EventsHelper
def event_feed_url(event)
if event.issue?
project_issue_url(event.project,
- event.issue)
+ event.issue)
elsif event.merge_request?
project_merge_request_url(event.project, event.merge_request)
elsif event.commit_note?
project_commit_url(event.project,
- event.note_target)
+ event.note_target)
elsif event.note?
if event.note_target
event_note_target_url(event)
@@ -132,15 +132,15 @@ module EventsHelper
if event.push_with_commits? && event.md_ref?
if event.commits_count > 1
project_compare_url(event.project,
- from: event.commit_from, to:
- event.commit_to)
+ from: event.commit_from, to:
+ event.commit_to)
else
project_commit_url(event.project,
- id: event.commit_to)
+ id: event.commit_to)
end
else
project_commits_url(event.project,
- event.ref_name)
+ event.ref_name)
end
end
@@ -167,8 +167,8 @@ module EventsHelper
project_merge_request_url(event.project, id: event.note_target, anchor: dom_id(event.target))
else
polymorphic_url([event.project.namespace.becomes(Namespace),
- event.project, event.note_target],
- anchor: dom_id(event.target))
+ event.project, event.note_target,],
+ anchor: dom_id(event.target))
end
end
@@ -176,15 +176,15 @@ module EventsHelper
if event.note_target
capture do
concat content_tag(:span, event.note_target_type, class: "event-target-type append-right-4")
- concat link_to(event.note_target_reference, event_note_target_url(event), title: event.target_title, class: 'has-tooltip event-target-link append-right-4')
+ concat link_to(event.note_target_reference, event_note_target_url(event), title: event.target_title, class: "has-tooltip event-target-link append-right-4")
end
else
- content_tag(:strong, '(deleted)')
+ content_tag(:strong, "(deleted)")
end
end
def event_commit_title(message)
- message ||= ''
+ message ||= ""
(message.split("\n").first || "").truncate(70)
rescue
"--broken encoding"
@@ -196,19 +196,19 @@ module EventsHelper
end
def icon_for_profile_event(event)
- if current_path?('users#show')
+ if current_path?("users#show")
content_tag :div, class: "system-note-image #{event.action_name.parameterize}-icon" do
icon_for_event(event.action_name)
end
else
- content_tag :div, class: 'system-note-image user-avatar' do
+ content_tag :div, class: "system-note-image user-avatar" do
author_avatar(event, size: 40)
end
end
end
def inline_event_icon(event)
- unless current_path?('users#show')
+ unless current_path?("users#show")
content_tag :span, class: "system-note-image-inline d-none d-sm-flex append-right-4 #{event.action_name.parameterize}-icon align-self-center" do
icon_for_event(event.action_name, size: 14)
end
diff --git a/app/helpers/explore_helper.rb b/app/helpers/explore_helper.rb
index 62be591ec47..1282aa32eee 100644
--- a/app/helpers/explore_helper.rb
+++ b/app/helpers/explore_helper.rb
@@ -12,7 +12,7 @@ module ExploreHelper
personal: params[:personal],
archived: params[:archived],
shared: params[:shared],
- namespace_id: params[:namespace_id]
+ namespace_id: params[:namespace_id],
}
options = exist_opts.merge(options).delete_if { |key, value| value.blank? }
diff --git a/app/helpers/form_helper.rb b/app/helpers/form_helper.rb
index 5705ee54cee..ff4f8a91f85 100644
--- a/app/helpers/form_helper.rb
+++ b/app/helpers/form_helper.rb
@@ -1,44 +1,44 @@
# frozen_string_literal: true
module FormHelper
- def form_errors(model, type: 'form')
+ def form_errors(model, type: "form")
return unless model.errors.any?
- pluralized = 'error'.pluralize(model.errors.count)
+ pluralized = "error".pluralize(model.errors.count)
headline = "The #{type} contains the following #{pluralized}:"
- content_tag(:div, class: 'alert alert-danger', id: 'error_explanation') do
+ content_tag(:div, class: "alert alert-danger", id: "error_explanation") do
content_tag(:h4, headline) <<
- content_tag(:ul) do
+ content_tag(:ul) {
model.errors.full_messages
.map { |msg| content_tag(:li, msg) }
.join
.html_safe
- end
+ }
end
end
def issue_assignees_dropdown_options
{
- toggle_class: 'js-user-search js-assignee-search js-multiselect js-save-user-data',
- title: 'Select assignee',
+ toggle_class: "js-user-search js-assignee-search js-multiselect js-save-user-data",
+ title: "Select assignee",
filter: true,
- dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee',
- placeholder: 'Search users',
+ dropdown_class: "dropdown-menu-user dropdown-menu-selectable dropdown-menu-assignee",
+ placeholder: "Search users",
data: {
first_user: current_user&.username,
null_user: true,
current_user: true,
project_id: @project&.id,
- field_name: 'issue[assignee_ids][]',
- default_label: 'Unassigned',
+ field_name: "issue[assignee_ids][]",
+ default_label: "Unassigned",
'max-select': 1,
- 'dropdown-header': 'Assignee',
+ 'dropdown-header': "Assignee",
multi_select: true,
- 'input-meta': 'name',
+ 'input-meta': "name",
'always-show-selectbox': true,
- current_user_info: UserSerializer.new.represent(current_user)
- }
+ current_user_info: UserSerializer.new.represent(current_user),
+ },
}
end
end
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index 04cf43be452..0ac4d0b08a0 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -154,17 +154,17 @@ module GitlabRoutingHelper
# Artifacts
def artifacts_action_path(path, project, build)
- action, path_params = path.split('/', 2)
+ action, path_params = path.split("/", 2)
args = [project, build, path_params]
case action
- when 'download'
+ when "download"
download_project_job_artifacts_path(*args)
- when 'browse'
+ when "browse"
browse_project_job_artifacts_path(*args)
- when 'file'
+ when "file"
file_project_job_artifacts_path(*args)
- when 'raw'
+ when "raw"
raw_project_job_artifacts_path(*args)
end
end
diff --git a/app/helpers/graph_helper.rb b/app/helpers/graph_helper.rb
index 49b15cde009..30093bf23f2 100644
--- a/app/helpers/graph_helper.rb
+++ b/app/helpers/graph_helper.rb
@@ -2,11 +2,11 @@
module GraphHelper
def refs(repo, commit)
- refs = [commit.ref_names(repo).join(' ')]
+ refs = [commit.ref_names(repo).join(" ")]
# append note count
notes_count = @graph.notes[commit.id]
- refs << "[#{pluralize(notes_count, 'note')}]" if notes_count > 0
+ refs << "[#{pluralize(notes_count, "note")}]" if notes_count > 0
refs.join
end
diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb
index 4a9ed123161..bc16822987a 100644
--- a/app/helpers/groups_helper.rb
+++ b/app/helpers/groups_helper.rb
@@ -49,7 +49,7 @@ module GroupsHelper
group = Group.find_by_full_path(group)
end
- group.try(:avatar_url) || ActionController::Base.helpers.image_path('no_group_avatar.png')
+ group.try(:avatar_url) || ActionController::Base.helpers.image_path("no_group_avatar.png")
end
def group_title(group, name = nil, url = nil)
@@ -67,7 +67,7 @@ module GroupsHelper
full_title << render("layouts/nav/breadcrumbs/collapsed_dropdown", location: :before, title: _("Show parent subgroups"))
full_title << breadcrumb_list_item(group_title_link(group))
- full_title << ' &middot; '.html_safe + link_to(simple_sanitize(name), url, class: 'group-path breadcrumb-item-text js-breadcrumb-item-text') if name
+ full_title << " &middot; ".html_safe + link_to(simple_sanitize(name), url, class: "group-path breadcrumb-item-text js-breadcrumb-item-text") if name
full_title.join.html_safe
end
@@ -83,14 +83,14 @@ module GroupsHelper
size = group.projects.size
if lfs_status == size
- 'for all projects'
+ "for all projects"
else
- "for #{lfs_status} out of #{pluralize(size, 'project')}"
+ "for #{lfs_status} out of #{pluralize(size, "project")}"
end
end
def group_lfs_status(group)
- status = group.lfs_enabled? ? 'enabled' : 'disabled'
+ status = group.lfs_enabled? ? "enabled" : "disabled"
content_tag(:span, class: "lfs-#{status}") do
"#{status.humanize} #{projects_lfs_status(group)}"
@@ -99,7 +99,7 @@ module GroupsHelper
def remove_group_message(group)
_("You are going to remove %{group_name}. Removed groups CANNOT be restored! Are you ABSOLUTELY sure?") %
- { group_name: group.name }
+ {group_name: group.name}
end
def share_with_group_lock_help_text(group)
@@ -117,9 +117,9 @@ module GroupsHelper
end
def parent_group_options(current_group)
- groups = current_user.owned_groups.sort_by(&:human_name).map do |group|
- { id: group.id, text: group.human_name }
- end
+ groups = current_user.owned_groups.sort_by(&:human_name).map { |group|
+ {id: group.id, text: group.human_name}
+ }
groups.delete_if { |group| group[:id] == current_group.id }
groups.to_json
@@ -135,10 +135,10 @@ module GroupsHelper
links = [:overview, :group_members]
resources = [:activity, :issues, :boards, :labels, :milestones,
- :merge_requests]
- links += resources.select do |resource|
+ :merge_requests,]
+ links += resources.select { |resource|
can?(current_user, "read_group_#{resource}".to_sym, @group)
- end
+ }
if can?(current_user, :read_cluster, @group) && @group.group_clusters_enabled?
links << :kubernetes
@@ -152,7 +152,7 @@ module GroupsHelper
end
def group_title_link(group, hidable: false, show_avatar: false, for_dropdown: false)
- link_to(group_path(group), class: "group-path #{'breadcrumb-item-text' unless for_dropdown} js-breadcrumb-item-text #{'hidable' if hidable}") do
+ link_to(group_path(group), class: "group-path #{"breadcrumb-item-text" unless for_dropdown} js-breadcrumb-item-text #{"hidable" if hidable}") do
icon = group_icon(group, class: "avatar-tile", width: 15, height: 15) if (group.try(:avatar_url) || show_avatar) && !Rails.env.test?
[icon, simple_sanitize(group.name)].join.html_safe
end
@@ -169,7 +169,7 @@ module GroupsHelper
def remove_the_share_with_group_lock_from_ancestor(group)
ancestor = oldest_consecutively_locked_ancestor(group)
- text = s_("GroupSettings|remove the share with group lock from %{ancestor_group_name}") % { ancestor_group_name: ancestor.name }
+ text = s_("GroupSettings|remove the share with group lock from %{ancestor_group_name}") % {ancestor_group_name: ancestor.name}
if can?(current_user, :admin_group, ancestor)
link_to text, edit_group_path(ancestor)
else
@@ -188,14 +188,14 @@ module GroupsHelper
end
def ancestor_locked_but_you_can_override(group)
- s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) }
+ s_("GroupSettings|This setting is applied on %{ancestor_group}. You can override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % {ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group)}
end
def ancestor_locked_so_ask_the_owner(group)
- s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % { ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group) }
+ s_("GroupSettings|This setting is applied on %{ancestor_group}. To share projects in this group with another group, ask the owner to override the setting or %{remove_ancestor_share_with_group_lock}.").html_safe % {ancestor_group: ancestor_group(group), remove_ancestor_share_with_group_lock: remove_the_share_with_group_lock_from_ancestor(group)}
end
def ancestor_locked_and_has_been_overridden(group)
- s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % { ancestor_group: ancestor_group(group) }
+ s_("GroupSettings|This setting is applied on %{ancestor_group} and has been overridden on this subgroup.").html_safe % {ancestor_group: ancestor_group(group)}
end
end
diff --git a/app/helpers/hooks_helper.rb b/app/helpers/hooks_helper.rb
index c4b39939192..ca3e5097d5b 100644
--- a/app/helpers/hooks_helper.rb
+++ b/app/helpers/hooks_helper.rb
@@ -8,11 +8,11 @@ module HooksHelper
test_project_hook_path(project, hook, trigger: trigger)
when SystemHook
test_admin_hook_path(hook, trigger: trigger)
- end
+ end
- trigger_human_name = trigger.to_s.tr('_', ' ').camelize
+ trigger_human_name = trigger.to_s.tr("_", " ").camelize
- link_to path, rel: 'nofollow', method: :post do
+ link_to path, rel: "nofollow", method: :post do
content_tag(:span, trigger_human_name)
end
end
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
index 4e11772b252..2726c8a0f0f 100644
--- a/app/helpers/icons_helper.rb
+++ b/app/helpers/icons_helper.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'json'
+require "json"
module IconsHelper
extend self
@@ -14,8 +14,8 @@ module IconsHelper
def icon(names, options = {})
if (options.keys & %w[aria-hidden aria-label data-hidden]).empty?
# Add 'aria-hidden' and 'data-hidden' if they are not set in options.
- options['aria-hidden'] = true
- options['data-hidden'] = true
+ options["aria-hidden"] = true
+ options["data-hidden"] = true
end
options.include?(:base) ? fa_stacked_icon(names, options) : fa_icon(names, options)
@@ -31,14 +31,14 @@ module IconsHelper
# SVG Sprites currently don't work across domains, so in the case of a CDN
# we have to set the current path deliberately to prevent addition of asset_host
sprite_base_url = Gitlab.config.gitlab.url if ActionController::Base.asset_host
- ActionController::Base.helpers.image_path('icons.svg', host: sprite_base_url)
+ ActionController::Base.helpers.image_path("icons.svg", host: sprite_base_url)
end
def sprite_file_icons_path
# SVG Sprites currently don't work across domains, so in the case of a CDN
# we have to set the current path deliberately to prevent addition of asset_host
sprite_base_url = Gitlab.config.gitlab.url if ActionController::Base.asset_host
- ActionController::Base.helpers.image_path('file_icons.svg', host: sprite_base_url)
+ ActionController::Base.helpers.image_path("file_icons.svg", host: sprite_base_url)
end
def sprite_icon(icon_name, size: nil, css_class: nil)
@@ -51,8 +51,8 @@ module IconsHelper
css_classes = []
css_classes << "s#{size}" if size
- css_classes << "#{css_class}" unless css_class.blank?
- content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes.join(' '))
+ css_classes << css_class.to_s unless css_class.blank?
+ content_tag(:svg, content_tag(:use, "", {"xlink:href" => "#{sprite_icon_path}##{icon_name}"}), class: css_classes.empty? ? nil : css_classes.join(" "))
end
def external_snippet_icon(name)
@@ -73,19 +73,19 @@ module IconsHelper
end
def spinner(text = nil, visible = false)
- css_class = ['loading']
- css_class << 'hide' unless visible
+ css_class = ["loading"]
+ css_class << "hide" unless visible
- content_tag :div, class: css_class.join(' ') do
- icon('spinner spin') + text
+ content_tag :div, class: css_class.join(" ") do
+ icon("spinner spin") + text
end
end
def boolean_to_icon(value)
if value
- icon('circle', class: 'cgreen')
+ icon("circle", class: "cgreen")
else
- icon('power-off', class: 'clgray')
+ icon("power-off", class: "clgray")
end
end
@@ -93,59 +93,59 @@ module IconsHelper
name =
case level
when Gitlab::VisibilityLevel::PRIVATE
- 'lock'
+ "lock"
when Gitlab::VisibilityLevel::INTERNAL
- 'shield'
+ "shield"
else # Gitlab::VisibilityLevel::PUBLIC
- 'globe'
+ "globe"
end
name = [name]
name << "fw" if fw
- icon(name.join(' '), options)
+ icon(name.join(" "), options)
end
def file_type_icon_class(type, mode, name)
- if type == 'folder'
- icon_class = 'folder'
- elsif type == 'archive'
- icon_class = 'archive'
- elsif mode == '120000'
- icon_class = 'share'
+ if type == "folder"
+ icon_class = "folder"
+ elsif type == "archive"
+ icon_class = "archive"
+ elsif mode == "120000"
+ icon_class = "share"
else
# Guess which icon to choose based on file extension.
# If you think a file extension is missing, feel free to add it on PR
case File.extname(name).downcase
- when '.pdf'
- icon_class = 'file-pdf-o'
- when '.jpg', '.jpeg', '.jif', '.jfif',
- '.jp2', '.jpx', '.j2k', '.j2c',
- '.png', '.gif', '.tif', '.tiff',
- '.svg', '.ico', '.bmp'
- icon_class = 'file-image-o'
- when '.zip', '.zipx', '.tar', '.gz', '.bz', '.bzip',
- '.xz', '.rar', '.7z'
- icon_class = 'file-archive-o'
- when '.mp3', '.wma', '.ogg', '.oga', '.wav', '.flac', '.aac'
- icon_class = 'file-audio-o'
- when '.mp4', '.m4p', '.m4v',
- '.mpg', '.mp2', '.mpeg', '.mpe', '.mpv',
- '.mpg', '.mpeg', '.m2v',
- '.avi', '.mkv', '.flv', '.ogv', '.mov',
- '.3gp', '.3g2'
- icon_class = 'file-video-o'
- when '.doc', '.dot', '.docx', '.docm', '.dotx', '.dotm', '.docb'
- icon_class = 'file-word-o'
- when '.xls', '.xlt', '.xlm', '.xlsx', '.xlsm', '.xltx', '.xltm',
- '.xlsb', '.xla', '.xlam', '.xll', '.xlw'
- icon_class = 'file-excel-o'
- when '.ppt', '.pot', '.pps', '.pptx', '.pptm', '.potx', '.potm',
- '.ppam', '.ppsx', '.ppsm', '.sldx', '.sldm'
- icon_class = 'file-powerpoint-o'
+ when ".pdf"
+ icon_class = "file-pdf-o"
+ when ".jpg", ".jpeg", ".jif", ".jfif",
+ ".jp2", ".jpx", ".j2k", ".j2c",
+ ".png", ".gif", ".tif", ".tiff",
+ ".svg", ".ico", ".bmp"
+ icon_class = "file-image-o"
+ when ".zip", ".zipx", ".tar", ".gz", ".bz", ".bzip",
+ ".xz", ".rar", ".7z"
+ icon_class = "file-archive-o"
+ when ".mp3", ".wma", ".ogg", ".oga", ".wav", ".flac", ".aac"
+ icon_class = "file-audio-o"
+ when ".mp4", ".m4p", ".m4v",
+ ".mpg", ".mp2", ".mpeg", ".mpe", ".mpv",
+ ".mpg", ".mpeg", ".m2v",
+ ".avi", ".mkv", ".flv", ".ogv", ".mov",
+ ".3gp", ".3g2"
+ icon_class = "file-video-o"
+ when ".doc", ".dot", ".docx", ".docm", ".dotx", ".dotm", ".docb"
+ icon_class = "file-word-o"
+ when ".xls", ".xlt", ".xlm", ".xlsx", ".xlsm", ".xltx", ".xltm",
+ ".xlsb", ".xla", ".xlam", ".xll", ".xlw"
+ icon_class = "file-excel-o"
+ when ".ppt", ".pot", ".pps", ".pptx", ".pptm", ".potx", ".potm",
+ ".ppam", ".ppsx", ".ppsm", ".sldx", ".sldm"
+ icon_class = "file-powerpoint-o"
else
- icon_class = 'file-text-o'
+ icon_class = "file-text-o"
end
end
@@ -155,6 +155,6 @@ module IconsHelper
private
def known_sprites
- @known_sprites ||= JSON.parse(File.read(Rails.root.join('node_modules/@gitlab/svgs/dist/icons.json')))['icons']
+ @known_sprites ||= JSON.parse(File.read(Rails.root.join("node_modules/@gitlab/svgs/dist/icons.json")))["icons"]
end
end
diff --git a/app/helpers/ide_helper.rb b/app/helpers/ide_helper.rb
index 8e50bbc6c04..4c6c449c2c8 100644
--- a/app/helpers/ide_helper.rb
+++ b/app/helpers/ide_helper.rb
@@ -3,14 +3,14 @@
module IdeHelper
def ide_data
{
- "empty-state-svg-path" => image_path('illustrations/multi_file_editor_empty.svg'),
- "no-changes-state-svg-path" => image_path('illustrations/multi-editor_no_changes_empty.svg'),
- "committed-state-svg-path" => image_path('illustrations/multi-editor_all_changes_committed_empty.svg'),
- "pipelines-empty-state-svg-path": image_path('illustrations/pipelines_empty.svg'),
- "promotion-svg-path": image_path('illustrations/web-ide_promotion.svg'),
- "ci-help-page-path" => help_page_path('ci/quick_start/README'),
- "web-ide-help-page-path" => help_page_path('user/project/web_ide/index.html'),
- "clientside-preview-enabled": Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s
+ "empty-state-svg-path" => image_path("illustrations/multi_file_editor_empty.svg"),
+ "no-changes-state-svg-path" => image_path("illustrations/multi-editor_no_changes_empty.svg"),
+ "committed-state-svg-path" => image_path("illustrations/multi-editor_all_changes_committed_empty.svg"),
+ :"pipelines-empty-state-svg-path" => image_path("illustrations/pipelines_empty.svg"),
+ :"promotion-svg-path" => image_path("illustrations/web-ide_promotion.svg"),
+ "ci-help-page-path" => help_page_path("ci/quick_start/README"),
+ "web-ide-help-page-path" => help_page_path("user/project/web_ide/index.html"),
+ :"clientside-preview-enabled" => Gitlab::CurrentSettings.current_application_settings.web_ide_clientside_preview_enabled.to_s,
}
end
end
diff --git a/app/helpers/import_helper.rb b/app/helpers/import_helper.rb
index 3d494c3de6a..8469a091d31 100644
--- a/app/helpers/import_helper.rb
+++ b/app/helpers/import_helper.rb
@@ -10,7 +10,7 @@ module ImportHelper
def sanitize_project_name(name)
# For personal projects in Bitbucket in the form ~username, we can
# just drop that leading tilde.
- name.gsub(/\A~+/, '').gsub(/[^\w\-]/, '-')
+ name.gsub(/\A~+/, "").gsub(/[^\w\-]/, "-")
end
def import_project_target(owner, name)
@@ -24,47 +24,47 @@ module ImportHelper
def import_will_timeout_message(_ci_cd_only)
timeout = time_interval_in_words(Gitlab.config.gitlab_shell.git_timeout)
- _('The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination.') % { timeout: timeout }
+ _("The import will time out after %{timeout}. For repositories that take longer, use a clone/push combination.") % {timeout: timeout}
end
def import_svn_message(_ci_cd_only)
- svn_link = link_to _('this document'), help_page_path('user/project/import/svn')
- _('To import an SVN repository, check out %{svn_link}.').html_safe % { svn_link: svn_link }
+ svn_link = link_to _("this document"), help_page_path("user/project/import/svn")
+ _("To import an SVN repository, check out %{svn_link}.").html_safe % {svn_link: svn_link}
end
def import_in_progress_title
if @project.forked?
- _('Forking in progress')
+ _("Forking in progress")
else
- _('Import in progress')
+ _("Import in progress")
end
end
def import_wait_and_refresh_message
- _('Please wait while we import the repository for you. Refresh at will.')
+ _("Please wait while we import the repository for you. Refresh at will.")
end
def import_github_authorize_message
- _('To import GitHub repositories, you first need to authorize GitLab to access the list of your GitHub repositories:')
+ _("To import GitHub repositories, you first need to authorize GitLab to access the list of your GitHub repositories:")
end
def import_github_personal_access_token_message
- personal_access_token_link = link_to _('Personal Access Token'), 'https://github.com/settings/tokens'
+ personal_access_token_link = link_to _("Personal Access Token"), "https://github.com/settings/tokens"
if github_import_configured?
- _('Alternatively, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.').html_safe % { personal_access_token_link: personal_access_token_link }
+ _("Alternatively, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.").html_safe % {personal_access_token_link: personal_access_token_link}
else
- _('To import GitHub repositories, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.').html_safe % { personal_access_token_link: personal_access_token_link }
+ _("To import GitHub repositories, you can use a %{personal_access_token_link}. When you create your Personal Access Token, you will need to select the <code>repo</code> scope, so we can display a list of your public and private repositories which are available to import.").html_safe % {personal_access_token_link: personal_access_token_link}
end
end
def import_configure_github_admin_message
- github_integration_link = link_to 'GitHub integration', help_page_path('integration/github')
+ github_integration_link = link_to "GitHub integration", help_page_path("integration/github")
if current_user.admin?
- _('Note: As an administrator you may like to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.').html_safe % { github_integration_link: github_integration_link }
+ _("Note: As an administrator you may like to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.").html_safe % {github_integration_link: github_integration_link}
else
- _('Note: Consider asking your GitLab administrator to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.').html_safe % { github_integration_link: github_integration_link }
+ _("Note: Consider asking your GitLab administrator to configure %{github_integration_link}, which will allow login via GitHub and allow importing repositories without generating a Personal Access Token.").html_safe % {github_integration_link: github_integration_link}
end
end
end
diff --git a/app/helpers/instance_configuration_helper.rb b/app/helpers/instance_configuration_helper.rb
index f695be32743..6aeddb82090 100644
--- a/app/helpers/instance_configuration_helper.rb
+++ b/app/helpers/instance_configuration_helper.rb
@@ -2,7 +2,7 @@
module InstanceConfigurationHelper
def instance_configuration_cell_html(value, &block)
- return '-' unless value.to_s.presence
+ return "-" unless value.to_s.presence
block_given? ? yield(value) : value
end
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb
index af28e6fcb93..72a726001a5 100644
--- a/app/helpers/issuables_helper.rb
+++ b/app/helpers/issuables_helper.rb
@@ -4,29 +4,29 @@ module IssuablesHelper
include GitlabRoutingHelper
def sidebar_gutter_toggle_icon
- sidebar_gutter_collapsed? ? icon('angle-double-left', { 'aria-hidden': 'true' }) : icon('angle-double-right', { 'aria-hidden': 'true' })
+ sidebar_gutter_collapsed? ? icon("angle-double-left", {'aria-hidden': "true"}) : icon("angle-double-right", {'aria-hidden': "true"})
end
def sidebar_gutter_collapsed_class
- "right-sidebar-#{sidebar_gutter_collapsed? ? 'collapsed' : 'expanded'}"
+ "right-sidebar-#{sidebar_gutter_collapsed? ? "collapsed" : "expanded"}"
end
def sidebar_gutter_tooltip_text
- sidebar_gutter_collapsed? ? _('Expand sidebar') : _('Collapse sidebar')
+ sidebar_gutter_collapsed? ? _("Expand sidebar") : _("Collapse sidebar")
end
def sidebar_assignee_tooltip_label(issuable)
if issuable.assignee
issuable.assignee.name
else
- issuable.allows_multiple_assignees? ? _('Assignee(s)') : _('Assignee')
+ issuable.allows_multiple_assignees? ? _("Assignee(s)") : _("Assignee")
end
end
def sidebar_milestone_tooltip_label(milestone)
- return _('Milestone') unless milestone.present?
+ return _("Milestone") unless milestone.present?
- [milestone[:title], sidebar_milestone_remaining_days(milestone) || _('Milestone')].join('<br/>')
+ [milestone[:title], sidebar_milestone_remaining_days(milestone) || _("Milestone")].join("<br/>")
end
def sidebar_milestone_remaining_days(milestone)
@@ -34,7 +34,7 @@ module IssuablesHelper
end
def sidebar_due_date_tooltip_label(due_date)
- [_('Due date'), due_date_with_remaining_days(due_date)].compact.join('<br/>')
+ [_("Due date"), due_date_with_remaining_days(due_date)].compact.join("<br/>")
end
def due_date_with_remaining_days(due_date, start_date = nil)
@@ -44,7 +44,7 @@ module IssuablesHelper
end
def sidebar_label_filter_path(base_path, label_name)
- query_params = { label_name: [label_name] }.to_query
+ query_params = {label_name: [label_name]}.to_query
"#{base_path}?#{query_params}"
end
@@ -77,7 +77,7 @@ module IssuablesHelper
IssueSerializer
when MergeRequest
MergeRequestSerializer
- end
+ end
serializer_klass
.new(current_user: current_user, project: issuable.project)
@@ -88,18 +88,18 @@ module IssuablesHelper
def template_dropdown_tag(issuable, &block)
title = selected_template(issuable) || "Choose a template"
options = {
- toggle_class: 'js-issuable-selector',
+ toggle_class: "js-issuable-selector",
title: title,
filter: true,
- placeholder: 'Filter',
+ placeholder: "Filter",
footer_content: true,
data: {
data: issuable_templates(issuable),
- field_name: 'issuable_template',
+ field_name: "issuable_template",
selected: selected_template(issuable),
project_path: ref_project.path,
- namespace_path: ref_project.namespace.full_path
- }
+ namespace_path: ref_project.namespace.full_path,
+ },
}
dropdown_tag(title, options: options) do
@@ -189,18 +189,18 @@ module IssuablesHelper
output = []
output << "Opened #{time_ago_with_tooltip(issuable.created_at)} by ".html_safe
- output << content_tag(:strong) do
+ output << content_tag(:strong) {
author_output = link_to_member(project, issuable.author, size: 24, mobile_classes: "d-none d-sm-inline")
author_output << link_to_member(project, issuable.author, size: 24, by_username: true, avatar: false, mobile_classes: "d-block d-sm-none")
if status = user_status(issuable.author)
- author_output << "#{status}".html_safe
+ author_output << status.to_s.html_safe
end
author_output
- end
+ }
- output << content_tag(:span, (issuable_first_contribution_icon if issuable.first_contribution?), class: 'has-tooltip prepend-left-4', title: _('1st contribution!'))
+ output << content_tag(:span, (issuable_first_contribution_icon if issuable.first_contribution?), class: "has-tooltip prepend-left-4", title: _("1st contribution!"))
output << content_tag(:span, (issuable.task_status if issuable.tasks?), id: "task_status", class: "d-none d-sm-none d-md-inline-block prepend-left-8")
output << content_tag(:span, (issuable.task_status_short if issuable.tasks?), id: "task_status_short", class: "d-md-none")
@@ -211,11 +211,11 @@ module IssuablesHelper
def issuable_labels_tooltip(labels, limit: 5)
first, last = labels.partition.with_index { |_, i| i < limit }
- if labels && labels.any?
+ if labels&.any?
label_names = first.collect { |label| label.fetch(:title) }
label_names << "and #{last.size} more" unless last.empty?
- label_names.join(', ')
+ label_names.join(", ")
else
_("Labels")
end
@@ -223,7 +223,7 @@ module IssuablesHelper
def issuables_state_counter_text(issuable_type, state, display_count)
titles = {
- opened: "Open"
+ opened: "Open",
}
state_title = titles[state] || state.to_s.humanize
@@ -231,16 +231,16 @@ module IssuablesHelper
if display_count
count = issuables_count_for_state(issuable_type, state)
- html << " " << content_tag(:span, number_with_delimiter(count), class: 'badge badge-pill')
+ html << " " << content_tag(:span, number_with_delimiter(count), class: "badge badge-pill")
end
html.html_safe
end
def issuable_first_contribution_icon
- content_tag(:span, class: 'fa-stack') do
- concat(icon('certificate', class: "fa-stack-2x"))
- concat(content_tag(:strong, '1', class: 'fa-inverse fa-stack-1x'))
+ content_tag(:span, class: "fa-stack") do
+ concat(icon("certificate", class: "fa-stack-2x"))
+ concat(content_tag(:strong, "1", class: "fa-inverse fa-stack-1x"))
end
end
@@ -267,20 +267,21 @@ module IssuablesHelper
canDestroy: can?(current_user, :"destroy_#{issuable.to_ability_name}", issuable),
issuableRef: issuable.to_reference,
markdownPreviewPath: preview_markdown_path(parent),
- markdownDocsPath: help_page_path('user/markdown'),
+ markdownDocsPath: help_page_path("user/markdown"),
lockVersion: issuable.lock_version,
issuableTemplates: issuable_templates(issuable),
initialTitleHtml: markdown_field(issuable, :title),
initialTitleText: issuable.title,
initialDescriptionHtml: markdown_field(issuable, :description),
initialDescriptionText: issuable.description,
- initialTaskStatus: issuable.task_status
+ initialTaskStatus: issuable.task_status,
}
if parent.is_a?(Group)
data[:groupPath] = parent.path
else
- data.merge!(projectPath: ref_project.path, projectNamespace: ref_project.namespace.full_path)
+ data[:projectPath] = ref_project.path
+ data[:projectNamespace] = ref_project.namespace.full_path
end
data.merge!(updated_at_by(issuable))
@@ -295,8 +296,8 @@ module IssuablesHelper
updatedAt: issuable.last_edited_at.to_time.iso8601,
updatedBy: {
name: issuable.last_edited_by.name,
- path: user_path(issuable.last_edited_by)
- }
+ path: user_path(issuable.last_edited_by),
+ },
}
end
@@ -330,7 +331,7 @@ module IssuablesHelper
end
def issuable_button_visibility(issuable, closed)
- return 'hidden' if issuable_button_hidden?(issuable, closed)
+ return "hidden" if issuable_button_hidden?(issuable, closed)
end
def issuable_button_hidden?(issuable, closed)
@@ -345,9 +346,9 @@ module IssuablesHelper
def issuable_close_reopen_button_method(issuable)
case issuable
when Issue
- ''
+ ""
when MergeRequest
- 'put'
+ "put"
end
end
@@ -366,7 +367,7 @@ module IssuablesHelper
private
def sidebar_gutter_collapsed?
- cookies[:collapsed_gutter] == 'true'
+ cookies[:collapsed_gutter] == "true"
end
def issuable_templates(issuable)
@@ -385,24 +386,24 @@ module IssuablesHelper
def issuable_todo_button_data(issuable, is_collapsed)
{
- todo_text: _('Add todo'),
- mark_text: _('Mark todo as done'),
- todo_icon: sprite_icon('todo-add'),
- mark_icon: sprite_icon('todo-done', css_class: 'todo-undone'),
+ todo_text: _("Add todo"),
+ mark_text: _("Mark todo as done"),
+ todo_icon: sprite_icon("todo-add"),
+ mark_icon: sprite_icon("todo-done", css_class: "todo-undone"),
issuable_id: issuable[:id],
issuable_type: issuable[:type],
create_path: issuable[:create_todo_path],
delete_path: issuable.dig(:current_user, :todo, :delete_path),
- placement: is_collapsed ? 'left' : nil,
- container: is_collapsed ? 'body' : nil,
- boundary: 'viewport',
- is_collapsed: is_collapsed
+ placement: is_collapsed ? "left" : nil,
+ container: is_collapsed ? "body" : nil,
+ boundary: "viewport",
+ is_collapsed: is_collapsed,
}
end
def close_reopen_params(issuable, action)
{
- issuable.model_name.to_s.underscore => { state_event: action }
+ issuable.model_name.to_s.underscore => {state_event: action},
}.tap do |params|
params[:format] = :json if issuable.is_a?(Issue)
end
@@ -425,7 +426,7 @@ module IssuablesHelper
editable: issuable.dig(:current_user, :can_edit),
currentUser: issuable[:current_user],
rootPath: root_path,
- fullPath: issuable[:project_full_path]
+ fullPath: issuable[:project_full_path],
}
end
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index 957ab06b0ca..b2e90612b9a 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -5,18 +5,18 @@ module IssuesHelper
classes = ["issue"]
classes << "closed" if issue.closed?
classes << "today" if issue.today?
- classes.join(' ')
+ classes.join(" ")
end
# Returns an OpenStruct object suitable for use by <tt>options_from_collection_for_select</tt>
# to allow filtering issues by an unassigned User or Milestone
def unassigned_filter
# Milestone uses :title, Issue uses :name
- OpenStruct.new(id: 0, title: 'None (backlog)', name: 'Unassigned')
+ OpenStruct.new(id: 0, title: "None (backlog)", name: "Unassigned")
end
def url_for_issue(issue_iid, project = @project, options = {})
- return '' if project.nil?
+ return "" if project.nil?
url =
if options[:internal]
@@ -28,7 +28,7 @@ module IssuesHelper
# Ensure we return a valid URL to prevent possible XSS.
URI.parse(url).to_s
rescue URI::InvalidURIError
- ''
+ ""
end
def url_for_tracker_issue(issue_iid, project, options)
@@ -51,20 +51,20 @@ module IssuesHelper
def status_box_class(item)
if item.try(:expired?)
- 'status-box-expired'
+ "status-box-expired"
elsif item.try(:merged?)
- 'status-box-mr-merged'
+ "status-box-mr-merged"
elsif item.closed?
- 'status-box-mr-closed'
+ "status-box-mr-closed"
elsif item.try(:upcoming?)
- 'status-box-upcoming'
+ "status-box-upcoming"
else
- 'status-box-open'
+ "status-box-open"
end
end
def issue_button_visibility(issue, closed)
- return 'hidden' if issue_button_hidden?(issue, closed)
+ return "hidden" if issue_button_hidden?(issue, closed)
end
def issue_button_hidden?(issue, closed)
@@ -72,15 +72,15 @@ module IssuesHelper
end
def confidential_icon(issue)
- icon('eye-slash') if issue.confidential?
+ icon("eye-slash") if issue.confidential?
end
def award_user_list(awards, current_user, limit: 10)
- names = awards.map do |award|
- award.user == current_user ? 'You' : award.user.name
- end
+ names = awards.map { |award|
+ award.user == current_user ? "You" : award.user.name
+ }
- current_user_name = names.delete('You')
+ current_user_name = names.delete("You")
names = names.insert(0, current_user_name).compact.first(limit)
names << "#{awards.size - names.size} more." if awards.size > names.size
@@ -99,7 +99,7 @@ module IssuesHelper
end
def awards_sort(awards)
- awards.sort_by do |award, award_emojis|
+ awards.sort_by { |award, award_emojis|
if award == "thumbsup"
0
elsif award == "thumbsdown"
@@ -107,7 +107,7 @@ module IssuesHelper
else
2
end
- end.to_h
+ }.to_h
end
def link_to_discussions_to_resolve(merge_request, single_discussion = nil)
@@ -115,13 +115,13 @@ module IssuesHelper
link_text << "(discussion #{single_discussion.first_note.id})" if single_discussion
path = if single_discussion
- Gitlab::UrlBuilder.build(single_discussion.first_note)
- else
- project = merge_request.project
- project_merge_request_path(project, merge_request)
- end
+ Gitlab::UrlBuilder.build(single_discussion.first_note)
+ else
+ project = merge_request.project
+ project_merge_request_path(project, merge_request)
+ end
- link_to link_text.join(' '), path
+ link_to link_text.join(" "), path
end
def show_new_issue_link?(project)
diff --git a/app/helpers/labels_helper.rb b/app/helpers/labels_helper.rb
index bd53add80ca..1b9ff1bd095 100644
--- a/app/helpers/labels_helper.rb
+++ b/app/helpers/labels_helper.rb
@@ -54,13 +54,13 @@ module LabelsHelper
case subject
when Group
send("#{type.to_s.pluralize}_group_path", # rubocop:disable GitlabSecurity/PublicSend
- subject,
- label_name: [label.name])
+ subject,
+ label_name: [label.name])
when Project
send("namespace_project_#{type.to_s.pluralize}_path", # rubocop:disable GitlabSecurity/PublicSend
- subject.namespace,
- subject,
- label_name: [label.name])
+ subject.namespace,
+ subject,
+ label_name: [label.name])
end
end
@@ -78,7 +78,7 @@ module LabelsHelper
end
end
- def render_colored_label(label, label_suffix = '', tooltip: true)
+ def render_colored_label(label, label_suffix = "", tooltip: true)
text_color = text_color_for_bg(label.color)
# Intentionally not using content_tag here so that this method can be called
@@ -93,27 +93,27 @@ module LabelsHelper
def suggested_colors
[
- '#0033CC',
- '#428BCA',
- '#44AD8E',
- '#A8D695',
- '#5CB85C',
- '#69D100',
- '#004E00',
- '#34495E',
- '#7F8C8D',
- '#A295D6',
- '#5843AD',
- '#8E44AD',
- '#FFECDB',
- '#AD4363',
- '#D10069',
- '#CC0033',
- '#FF0000',
- '#D9534F',
- '#D1D100',
- '#F0AD4E',
- '#AD8D43'
+ "#0033CC",
+ "#428BCA",
+ "#44AD8E",
+ "#A8D695",
+ "#5CB85C",
+ "#69D100",
+ "#004E00",
+ "#34495E",
+ "#7F8C8D",
+ "#A295D6",
+ "#5843AD",
+ "#8E44AD",
+ "#FFECDB",
+ "#AD4363",
+ "#D10069",
+ "#CC0033",
+ "#FF0000",
+ "#D9534F",
+ "#D1D100",
+ "#F0AD4E",
+ "#AD8D43",
]
end
@@ -125,9 +125,9 @@ module LabelsHelper
end
if (r + g + b) > 500
- '#333333'
+ "#333333"
else
- '#FFFFFF'
+ "#FFFFFF"
end
end
@@ -159,70 +159,70 @@ module LabelsHelper
end
def label_subscription_status(label, project)
- return 'group-level' if label.subscribed?(current_user)
- return 'project-level' if label.subscribed?(current_user, project)
+ return "group-level" if label.subscribed?(current_user)
+ return "project-level" if label.subscribed?(current_user, project)
- 'unsubscribed'
+ "unsubscribed"
end
def toggle_subscription_label_path(label, project)
return toggle_subscription_group_label_path(label.group, label) unless project
case label_subscription_status(label, project)
- when 'group-level' then toggle_subscription_group_label_path(label.group, label)
- when 'project-level' then toggle_subscription_project_label_path(project, label)
- when 'unsubscribed' then toggle_subscription_project_label_path(project, label)
+ when "group-level" then toggle_subscription_group_label_path(label.group, label)
+ when "project-level" then toggle_subscription_project_label_path(project, label)
+ when "unsubscribed" then toggle_subscription_project_label_path(project, label)
end
end
def label_subscription_toggle_button_text(label, project = nil)
- label.subscribed?(current_user, project) ? 'Unsubscribe' : 'Subscribe'
+ label.subscribed?(current_user, project) ? "Unsubscribe" : "Subscribe"
end
def label_deletion_confirm_text(label)
case label
- when GroupLabel then 'Remove this label? This will affect all projects within the group. Are you sure?'
- when ProjectLabel then 'Remove this label? Are you sure?'
+ when GroupLabel then "Remove this label? This will affect all projects within the group. Are you sure?"
+ when ProjectLabel then "Remove this label? Are you sure?"
end
end
def create_label_title(subject)
case subject
when Group
- _('Create group label')
+ _("Create group label")
when Project
- _('Create project label')
+ _("Create project label")
else
- _('Create new label')
+ _("Create new label")
end
end
def manage_labels_title(subject)
case subject
when Group
- _('Manage group labels')
+ _("Manage group labels")
when Project
- _('Manage project labels')
+ _("Manage project labels")
else
- _('Manage labels')
+ _("Manage labels")
end
end
def view_labels_title(subject)
case subject
when Group
- _('View group labels')
+ _("View group labels")
when Project
- _('View project labels')
+ _("View project labels")
else
- _('View labels')
+ _("View labels")
end
end
def label_status_tooltip(label, status)
- type = label.is_a?(ProjectLabel) ? 'project' : 'group'
- level = status.unsubscribed? ? type : status.sub('-level', '')
- action = status.unsubscribed? ? 'Subscribe' : 'Unsubscribe'
+ type = label.is_a?(ProjectLabel) ? "project" : "group"
+ level = status.unsubscribed? ? type : status.sub("-level", "")
+ action = status.unsubscribed? ? "Subscribe" : "Unsubscribe"
"#{action} at #{level} level"
end
diff --git a/app/helpers/lazy_image_tag_helper.rb b/app/helpers/lazy_image_tag_helper.rb
index ac987a04895..30b9e7d7b2a 100644
--- a/app/helpers/lazy_image_tag_helper.rb
+++ b/app/helpers/lazy_image_tag_helper.rb
@@ -17,7 +17,7 @@ module LazyImageTagHelper
klass_opts = Array.wrap(options[:class])
klass_opts << "lazy"
- options[:class] = klass_opts.join(' ')
+ options[:class] = klass_opts.join(" ")
source = placeholder_image
end
diff --git a/app/helpers/markup_helper.rb b/app/helpers/markup_helper.rb
index 66f4b7b3f30..7eb193bd087 100644
--- a/app/helpers/markup_helper.rb
+++ b/app/helpers/markup_helper.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'nokogiri'
+require "nokogiri"
module MarkupHelper
include ActionView::Helpers::TagHelper
@@ -24,7 +24,7 @@ module MarkupHelper
# Use this in places where you would normally use link_to(gfm(...), ...).
def link_to_markdown(body, url, html_options = {})
- return '' if body.blank?
+ return "" if body.blank?
link_to_html(markdown(body, pipeline: :single_line), url, html_options)
end
@@ -45,7 +45,7 @@ module MarkupHelper
def link_to_html(redacted, url, html_options = {})
fragment = Nokogiri::HTML::DocumentFragment.parse(redacted)
- if fragment.children.size == 1 && fragment.children[0].name == 'a'
+ if fragment.children.size == 1 && fragment.children[0].name == "a"
# Fragment has only one node, and it's a link generated by `gfm`.
# Replace it with our requested link.
text = fragment.children[0].text
@@ -62,7 +62,7 @@ module MarkupHelper
# Add any custom CSS classes to the GFM-generated reference links
if html_options[:class]
- fragment.css('a.gfm').add_class(html_options[:class])
+ fragment.css("a.gfm").add_class(html_options[:class])
end
fragment.to_html.html_safe
@@ -76,14 +76,14 @@ module MarkupHelper
md = markdown_field(object, attribute, options)
return nil unless md.present?
- tags = %w(a gl-emoji b pre code p span)
- tags << 'img' if options[:allow_images]
+ tags = %w[a gl-emoji b pre code p span]
+ tags << "img" if options[:allow_images]
text = truncate_visible(md, max_chars || md.length)
text = sanitize(
text,
tags: tags,
- attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ['style', 'data-src', 'data-name', 'data-unicode-version']
+ attributes: Rails::Html::WhiteListSanitizer.allowed_attributes + ["style", "data-src", "data-name", "data-unicode-version"]
)
# since <img> tags are stripped, this can leave empty <a> tags hanging around
@@ -92,7 +92,7 @@ module MarkupHelper
end
def markdown(text, context = {})
- return '' unless text.present?
+ return "" unless text.present?
context[:project] ||= @project
context[:group] ||= @group
@@ -105,7 +105,7 @@ module MarkupHelper
object = object.for_display if object.respond_to?(:for_display)
redacted_field_html = object.try(:"redacted_#{field}_html")
- return '' unless object.present?
+ return "" unless object.present?
return redacted_field_html if redacted_field_html
html = Banzai.render_field(object, field, context)
@@ -122,7 +122,7 @@ module MarkupHelper
def render_wiki_content(wiki_page, context = {})
text = wiki_page.content
- return '' unless text.present?
+ return "" unless text.present?
context.merge!(
pipeline: :wiki,
@@ -146,14 +146,14 @@ module MarkupHelper
end
def markup_unsafe(file_name, text, context = {})
- return '' unless text.present?
+ return "" unless text.present?
if gitlab_markdown?(file_name)
markdown_unsafe(text, context)
elsif asciidoc?(file_name)
asciidoc_unsafe(text, context)
elsif plain?(file_name)
- content_tag :pre, class: 'plain-readme' do
+ content_tag :pre, class: "plain-readme" do
text
end
else
@@ -181,7 +181,7 @@ module MarkupHelper
if entity.respond_to?(:to_reference)
entity.to_reference(project, full: true)
else
- ''
+ ""
end
end
@@ -228,7 +228,7 @@ module MarkupHelper
def truncate_if_block(node, truncated)
return true if truncated
- if node.element? && (node.description&.block? || node.matches?('pre > code > .line'))
+ if node.element? && (node.description&.block? || node.matches?("pre > code > .line"))
node.inner_html = "#{node.inner_html}..." if node.next_sibling
true
else
@@ -237,9 +237,9 @@ module MarkupHelper
end
def strip_empty_link_tags(text)
- scrubber = Loofah::Scrubber.new do |node|
- node.remove if node.name == 'a' && node.content.blank?
- end
+ scrubber = Loofah::Scrubber.new { |node|
+ node.remove if node.name == "a" && node.content.blank?
+ }
# Use `Loofah` directly instead of `sanitize`
# as we still use the `rails-deprecated_sanitizer` gem
@@ -247,14 +247,14 @@ module MarkupHelper
end
def markdown_toolbar_button(options = {})
- data = options[:data].merge({ container: 'body' })
+ data = options[:data].merge({container: "body"})
content_tag :button,
- type: 'button',
- class: 'toolbar-btn js-md has-tooltip',
+ type: "button",
+ class: "toolbar-btn js-md has-tooltip",
tabindex: -1,
data: data,
title: options[:title],
- aria: { label: options[:title] } do
+ aria: {label: options[:title]} do
sprite_icon(options[:icon])
end
end
@@ -272,15 +272,15 @@ module MarkupHelper
end
def prepare_for_rendering(html, context = {})
- return '' unless html.present?
+ return "" unless html.present?
context.merge!(
current_user: (current_user if defined?(current_user)),
# RelativeLinkFilter
- commit: @commit,
- project_wiki: @project_wiki,
- ref: @ref,
+ commit: @commit,
+ project_wiki: @project_wiki,
+ ref: @ref,
requested_path: @path
)
diff --git a/app/helpers/mattermost_helper.rb b/app/helpers/mattermost_helper.rb
index b211fe5076a..6d400971ae1 100644
--- a/app/helpers/mattermost_helper.rb
+++ b/app/helpers/mattermost_helper.rb
@@ -3,7 +3,7 @@
module MattermostHelper
def mattermost_teams_options(teams)
teams.map do |team|
- [team['display_name'] || team['name'], team['id']]
+ [team["display_name"] || team["name"], team["id"]]
end
end
end
diff --git a/app/helpers/members_helper.rb b/app/helpers/members_helper.rb
index 11d5591d509..90ae44f4205 100644
--- a/app/helpers/members_helper.rb
+++ b/app/helpers/members_helper.rb
@@ -3,12 +3,12 @@
module MembersHelper
def remove_member_message(member, user: nil)
user = current_user if defined?(current_user)
- text = 'Are you sure you want to'
+ text = "Are you sure you want to"
action =
if member.request?
if member.user == user
- 'withdraw your access request for'
+ "withdraw your access request for"
else
"deny #{member.user.name}'s request to join"
end
@@ -22,7 +22,7 @@ module MembersHelper
end
def remove_member_title(member)
- action = member.request? ? 'Deny access request' : 'Remove user'
+ action = member.request? ? "Deny access request" : "Remove user"
"#{action} from #{source_text(member)}"
end
@@ -42,8 +42,8 @@ module MembersHelper
def source_text(member)
type = member.real_source_type.humanize(capitalize: false)
- return type if member.request? || member.invite? || type != 'group'
+ return type if member.request? || member.invite? || type != "group"
- 'group and any subresources'
+ "group and any subresources"
end
end
diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb
index 23d7aa427bb..a921ed566d5 100644
--- a/app/helpers/merge_requests_helper.rb
+++ b/app/helpers/merge_requests_helper.rb
@@ -15,8 +15,8 @@ module MergeRequestsHelper
source_project_id: event.project.id,
target_project_id: target_project.id,
source_branch: event.branch_name,
- target_branch: target_project.repository.root_ref
- }
+ target_branch: target_project.repository.root_ref,
+ },
}
end
@@ -24,7 +24,7 @@ module MergeRequestsHelper
classes = ["merge-request"]
classes << "closed" if mr.closed?
classes << "merged" if mr.merged?
- classes.join(' ')
+ classes.join(" ")
end
def ci_build_details_path(merge_request)
@@ -34,7 +34,7 @@ module MergeRequestsHelper
parsed_url = URI.parse(build_url)
unless parsed_url.userinfo.blank?
- parsed_url.userinfo = ''
+ parsed_url.userinfo = ""
end
parsed_url.to_s
@@ -55,7 +55,7 @@ module MergeRequestsHelper
source_project_id: merge_request.source_project_id,
target_project_id: merge_request.target_project_id,
source_branch: merge_request.source_branch,
- target_branch: merge_request.target_branch
+ target_branch: merge_request.target_branch,
},
change_branches: true
)
@@ -80,7 +80,7 @@ module MergeRequestsHelper
end
def merge_request_button_visibility(merge_request, closed)
- return 'hidden' if merge_request_button_hidden?(merge_request, closed)
+ return "hidden" if merge_request_button_hidden?(merge_request, closed)
end
def merge_request_button_hidden?(merge_request, closed)
@@ -106,7 +106,7 @@ module MergeRequestsHelper
merge_when_pipeline_succeeds: true,
should_remove_source_branch: true,
sha: merge_request.diff_head_sha,
- squash: merge_request.squash
+ squash: merge_request.squash,
}
end
@@ -114,12 +114,12 @@ module MergeRequestsHelper
data_attrs = {
action: tab.to_s,
target: "##{tab}",
- toggle: options.fetch(:force_link, false) ? '' : 'tabvue'
+ toggle: options.fetch(:force_link, false) ? "" : "tabvue",
}
url = case tab
when :show
- data_attrs[:target] = '#notes'
+ data_attrs[:target] = "#notes"
method(:project_merge_request_path)
when :commits
method(:commits_project_merge_request_path)
@@ -129,7 +129,7 @@ module MergeRequestsHelper
method(:diffs_project_merge_request_path)
else
raise "Cannot create tab #{tab}."
- end
+ end
link_to(url[merge_request.project, merge_request], data: data_attrs, &block)
end
@@ -138,12 +138,12 @@ module MergeRequestsHelper
return if merge_request.can_allow_collaboration?(current_user)
minimum_visibility = [merge_request.target_project.visibility_level,
- merge_request.source_project.visibility_level].min
+ merge_request.source_project.visibility_level,].min
if minimum_visibility < Gitlab::VisibilityLevel::INTERNAL
- _('Not available for private projects')
+ _("Not available for private projects")
elsif ProtectedBranch.protected?(merge_request.source_project, merge_request.source_branch)
- _('Not available for protected branches')
+ _("Not available for protected branches")
end
end
diff --git a/app/helpers/milestones_helper.rb b/app/helpers/milestones_helper.rb
index 50aec83b867..7ce0f65478a 100644
--- a/app/helpers/milestones_helper.rb
+++ b/app/helpers/milestones_helper.rb
@@ -25,7 +25,7 @@ module MilestonesHelper
end
def milestones_browse_issuables_path(milestone, state: nil, type:)
- opts = { milestone_title: milestone.title, state: state }
+ opts = {milestone_title: milestone.title, state: state}
if @project
polymorphic_path([@project.namespace.becomes(Namespace), @project, type], opts)
@@ -59,9 +59,9 @@ module MilestonesHelper
counts = milestones.reorder(nil).group(:state).count
{
- opened: counts['active'] || 0,
- closed: counts['closed'] || 0,
- all: counts.values.sum || 0
+ opened: counts["active"] || 0,
+ closed: counts["closed"] || 0,
+ all: counts.values.sum || 0,
}
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -71,9 +71,9 @@ module MilestonesHelper
# Could be refactored to be simpler but that may make it harder to read
def milestone_class_for_state(param, check, match_blank_param = false)
if match_blank_param
- 'active' if param.blank? || param == check
+ "active" if param.blank? || param == check
elsif param == check
- 'active'
+ "active"
else
check
end
@@ -84,21 +84,21 @@ module MilestonesHelper
if has_issues
[
- _('Progress'),
- _("%{percent}%% complete") % { percent: milestone.percent_complete(current_user) }
- ].join('<br />')
+ _("Progress"),
+ _("%{percent}%% complete") % {percent: milestone.percent_complete(current_user)},
+ ].join("<br />")
else
- _('Progress')
+ _("Progress")
end
end
def milestone_progress_bar(milestone)
options = {
- class: 'progress-bar bg-success',
- style: "width: #{milestone.percent_complete(current_user)}%;"
+ class: "progress-bar bg-success",
+ style: "width: #{milestone.percent_complete(current_user)}%;",
}
- content_tag :div, class: 'progress' do
+ content_tag :div, class: "progress" do
content_tag :div, nil, options
end
end
@@ -120,16 +120,16 @@ module MilestonesHelper
if date
time_ago = time_ago_in_words(date).sub("about ", "")
state = if date.past?
- "ago"
- else
- "remaining"
- end
+ "ago"
+ else
+ "remaining"
+ end
content = [
title,
"<br />",
date.to_s(:medium),
- "(#{time_ago} #{state})"
+ "(#{time_ago} #{state})",
].join(" ")
content.html_safe
@@ -148,7 +148,7 @@ module MilestonesHelper
content << n_("1 open issue", "%d open issues", issues["opened"]) % issues["opened"] if issues["opened"]
content << n_("1 closed issue", "%d closed issues", issues["closed"]) % issues["closed"] if issues["closed"]
- content.join('<br />').html_safe
+ content.join("<br />").html_safe
end
def milestone_merge_requests_tooltip_text(milestone)
@@ -162,14 +162,14 @@ module MilestonesHelper
content << n_("1 closed merge request", "%d closed merge requests", merge_requests.closed.count) % merge_requests.closed.count if merge_requests.closed.any?
content << n_("1 merged merge request", "%d merged merge requests", merge_requests.merged.count) % merge_requests.merged.count if merge_requests.merged.any?
- content.join('<br />').html_safe
+ content.join("<br />").html_safe
end
def milestone_tooltip_due_date(milestone)
if milestone.due_date
"#{milestone.due_date.to_s(:medium)} (#{remaining_days_in_words(milestone.due_date, milestone.start_date)})"
else
- _('Milestone')
+ _("Milestone")
end
end
@@ -234,9 +234,9 @@ module MilestonesHelper
def group_or_project_milestone_path(milestone)
params =
if milestone.group_milestone?
- { milestone: { title: milestone.title } }
+ {milestone: {title: milestone.title}}
else
- { title: milestone.title }
+ {title: milestone.title}
end
milestone_path(milestone.milestone, params)
diff --git a/app/helpers/mirror_helper.rb b/app/helpers/mirror_helper.rb
index 65c7cd82832..4e26b9a5e5f 100644
--- a/app/helpers/mirror_helper.rb
+++ b/app/helpers/mirror_helper.rb
@@ -4,7 +4,7 @@ module MirrorHelper
def mirrors_form_data_attributes
{
project_mirror_ssh_endpoint: ssh_host_keys_project_mirror_path(@project, :json),
- project_mirror_endpoint: project_mirror_path(@project, :json)
+ project_mirror_endpoint: project_mirror_path(@project, :json),
}
end
end
diff --git a/app/helpers/namespaces_helper.rb b/app/helpers/namespaces_helper.rb
index ea3bcfc791a..44b58b702d9 100644
--- a/app/helpers/namespaces_helper.rb
+++ b/app/helpers/namespaces_helper.rb
@@ -11,10 +11,10 @@ module NamespacesHelper
selected_id = selected
unless extra_group.nil? || extra_group.is_a?(Group)
- extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == 'group'
+ extra_group = Group.find(extra_group) if Namespace.find(extra_group).kind == "group"
end
- if extra_group && extra_group.is_a?(Group)
+ if extra_group&.is_a?(Group)
extra_group = dedup_extra_group(extra_group)
if Ability.allowed?(current_user, :read_group, extra_group)
@@ -28,10 +28,10 @@ module NamespacesHelper
end
options = []
- options << options_for_group(groups, display_path: display_path, type: 'group')
+ options << options_for_group(groups, display_path: display_path, type: "group")
unless groups_only
- options << options_for_group(users, display_path: display_path, type: 'user')
+ options << options_for_group(users, display_path: display_path, type: "user")
if selected == :current_user && current_user.namespace
selected_id = current_user.namespace.id
@@ -66,17 +66,17 @@ module NamespacesHelper
def options_for_group(namespaces, display_path:, type:)
group_label = type.pluralize
- elements = namespaces.sort_by(&:human_name).map! do |n|
+ elements = namespaces.sort_by(&:human_name).map! { |n|
[display_path ? n.full_path : n.human_name, n.id,
data: {
options_parent: group_label,
visibility_level: n.visibility_level_value,
visibility: n.visibility,
name: n.name,
- show_path: (type == 'group') ? group_path(n) : user_path(n),
- edit_path: (type == 'group') ? edit_group_path(n) : nil
- }]
- end
+ show_path: type == "group" ? group_path(n) : user_path(n),
+ edit_path: type == "group" ? edit_group_path(n) : nil,
+ },]
+ }
[group_label.camelize, elements]
end
diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb
index 05da5ebdb22..f30e8c8c2c0 100644
--- a/app/helpers/nav_helper.rb
+++ b/app/helpers/nav_helper.rb
@@ -11,9 +11,9 @@ module NavHelper
def page_with_sidebar_class
class_name = page_gutter_class
- class_name << 'page-with-contextual-sidebar' if defined?(@left_sidebar) && @left_sidebar
- class_name << 'page-with-icon-sidebar' if collapsed_sidebar? && @left_sidebar
- class_name -= ['right-sidebar-expanded'] if defined?(@right_sidebar) && !@right_sidebar
+ class_name << "page-with-contextual-sidebar" if defined?(@left_sidebar) && @left_sidebar
+ class_name << "page-with-icon-sidebar" if collapsed_sidebar? && @left_sidebar
+ class_name -= ["right-sidebar-expanded"] if defined?(@right_sidebar) && !@right_sidebar
class_name
end
@@ -21,14 +21,14 @@ module NavHelper
def page_gutter_class
if page_has_markdown?
- if cookies[:collapsed_gutter] == 'true'
+ if cookies[:collapsed_gutter] == "true"
%w[page-gutter right-sidebar-collapsed]
else
%w[page-gutter right-sidebar-expanded]
end
- elsif current_path?('jobs#show')
+ elsif current_path?("jobs#show")
%w[page-gutter build-sidebar right-sidebar-expanded]
- elsif current_controller?('wikis') && current_action?('show', 'create', 'edit', 'update', 'history', 'git_access', 'destroy')
+ elsif current_controller?("wikis") && current_action?("show", "create", "edit", "update", "history", "git_access", "destroy")
%w[page-gutter wiki-sidebar right-sidebar-expanded]
else
[]
@@ -41,8 +41,8 @@ module NavHelper
def user_dropdown_class
class_names = []
- class_names << 'header-user-dropdown-toggle'
- class_names << 'impersonated-user' if session[:impersonator_id]
+ class_names << "header-user-dropdown-toggle"
+ class_names << "impersonated-user" if session[:impersonator_id]
class_names
end
@@ -52,20 +52,20 @@ module NavHelper
end
def page_has_markdown?
- current_path?('merge_requests#show') ||
- current_path?('projects/merge_requests/conflicts#show') ||
- current_path?('issues#show') ||
- current_path?('milestones#show')
+ current_path?("merge_requests#show") ||
+ current_path?("projects/merge_requests/conflicts#show") ||
+ current_path?("issues#show") ||
+ current_path?("milestones#show")
end
private
def get_header_links
links = if current_user
- [:user_dropdown]
- else
- [:sign_in]
- end
+ [:user_dropdown]
+ else
+ [:sign_in]
+ end
if can?(current_user, :read_cross_project)
links += [:issues, :merge_requests, :todos] if current_user.present?
diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb
index aaf38cbfe70..7efeb19ddb0 100644
--- a/app/helpers/notes_helper.rb
+++ b/app/helpers/notes_helper.rb
@@ -17,7 +17,7 @@ module NotesHelper
id: noteable.id,
class: noteable.class.name,
resources: noteable.class.table_name,
- project_id: noteable.project.id
+ project_id: noteable.project.id,
}.to_json
end
@@ -32,7 +32,7 @@ module NotesHelper
data = {
line_code: line_code,
- line_type: line_type
+ line_type: line_type,
}
if @use_legacy_diff_notes
@@ -48,12 +48,12 @@ module NotesHelper
def add_diff_note_button(line_code, position, line_type)
return if @diff_notes_disabled
- button_tag '',
- class: 'add-diff-note js-add-diff-note-button',
- type: 'submit', name: 'button',
+ button_tag "",
+ class: "add-diff-note js-add-diff-note-button",
+ type: "submit", name: "button",
data: diff_view_line_data(line_code, position, line_type),
- title: 'Add a comment to this line' do
- icon('comment-o')
+ title: "Add a comment to this line" do
+ icon("comment-o")
end
end
@@ -63,11 +63,11 @@ module NotesHelper
data = {
discussion_id: discussion.reply_id,
discussion_project_id: discussion.project&.id,
- line_type: line_type
+ line_type: line_type,
}
- button_tag 'Reply...', class: 'btn btn-text-field js-discussion-reply-button',
- data: data, title: 'Add a reply'
+ button_tag "Reply...", class: "btn btn-text-field js-discussion-reply-button",
+ data: data, title: "Add a reply"
end
def note_max_access_for_user(note)
@@ -95,7 +95,8 @@ module NotesHelper
if @snippet.is_a?(PersonalSnippet)
snippet_notes_path(@snippet, params)
else
- params.merge!(target_id: @noteable.id, target_type: @noteable.class.name.underscore)
+ params[:target_id] = @noteable.id
+ params[:target_type] = @noteable.class.name.underscore
project_noteable_notes_path(@project, params)
end
@@ -152,8 +153,8 @@ module NotesHelper
mergeRequests: autocomplete,
epics: autocomplete,
milestones: autocomplete,
- labels: autocomplete
- }
+ labels: autocomplete,
+ },
}
end
@@ -168,20 +169,20 @@ module NotesHelper
def notes_data(issuable)
{
discussionsPath: discussions_path(issuable),
- registerPath: new_session_path(:user, redirect_to_referer: 'yes', anchor: 'register-pane'),
- newSessionPath: new_session_path(:user, redirect_to_referer: 'yes'),
- markdownDocsPath: help_page_path('user/markdown'),
- quickActionsDocsPath: help_page_path('user/project/quick_actions'),
+ registerPath: new_session_path(:user, redirect_to_referer: "yes", anchor: "register-pane"),
+ newSessionPath: new_session_path(:user, redirect_to_referer: "yes"),
+ markdownDocsPath: help_page_path("user/markdown"),
+ quickActionsDocsPath: help_page_path("user/project/quick_actions"),
closePath: close_issuable_path(issuable),
reopenPath: reopen_issuable_path(issuable),
notesPath: notes_url,
totalNotes: issuable.discussions.length,
- lastFetchedAt: Time.now.to_i
+ lastFetchedAt: Time.now.to_i,
}
end
def discussion_resolved_intro(discussion)
- discussion.resolved_by_push? ? 'Automatically resolved' : 'Resolved'
+ discussion.resolved_by_push? ? "Automatically resolved" : "Resolved"
end
def rendered_for_merge_request?
@@ -189,6 +190,6 @@ module NotesHelper
end
def serialize_notes?
- rendered_for_merge_request? || params['html'].nil?
+ rendered_for_merge_request? || params["html"].nil?
end
end
diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb
index 5318ab4ddef..400d83c8790 100644
--- a/app/helpers/notifications_helper.rb
+++ b/app/helpers/notifications_helper.rb
@@ -6,15 +6,15 @@ module NotificationsHelper
def notification_icon_class(level)
case level.to_sym
when :disabled
- 'microphone-slash'
+ "microphone-slash"
when :participating
- 'volume-up'
+ "volume-up"
when :watch
- 'eye'
+ "eye"
when :mention
- 'at'
+ "at"
when :global
- 'globe'
+ "globe"
end
end
@@ -26,14 +26,14 @@ module NotificationsHelper
# Can be anything in `NotificationSetting.level:
case level.to_sym
when :participating
- s_('NotificationLevel|Participate')
+ s_("NotificationLevel|Participate")
when :mention
- s_('NotificationLevel|On mention')
+ s_("NotificationLevel|On mention")
else
- N_('NotificationLevel|Global')
- N_('NotificationLevel|Watch')
- N_('NotificationLevel|Disabled')
- N_('NotificationLevel|Custom')
+ N_("NotificationLevel|Global")
+ N_("NotificationLevel|Watch")
+ N_("NotificationLevel|Disabled")
+ N_("NotificationLevel|Custom")
level = "NotificationLevel|#{level.to_s.humanize}"
s_(level)
end
@@ -42,17 +42,17 @@ module NotificationsHelper
def notification_description(level)
case level.to_sym
when :participating
- _('You will only receive notifications for threads you have participated in')
+ _("You will only receive notifications for threads you have participated in")
when :mention
- _('You will receive notifications only for comments in which you were @mentioned')
+ _("You will receive notifications only for comments in which you were @mentioned")
when :watch
- _('You will receive notifications for any activity')
+ _("You will receive notifications for any activity")
when :disabled
- _('You will not get any notifications via email')
+ _("You will not get any notifications via email")
when :global
- _('Use your global notification setting')
+ _("Use your global notification setting")
when :custom
- _('You will only receive notifications for the events you choose')
+ _("You will only receive notifications for the events you choose")
end
end
@@ -61,13 +61,13 @@ module NotificationsHelper
data = {
notification_level: level,
- notification_title: title
+ notification_title: title,
}
content_tag(:li, role: "menuitem") do
- link_to '#', class: "update-notification #{('is-active' if setting.level == level)}", data: data do
- link_output = content_tag(:strong, title, class: 'dropdown-menu-inner-title')
- link_output << content_tag(:span, notification_description(level), class: 'dropdown-menu-inner-content')
+ link_to "#", class: "update-notification #{("is-active" if setting.level == level)}", data: data do
+ link_output = content_tag(:strong, title, class: "dropdown-menu-inner-title")
+ link_output << content_tag(:span, notification_description(level), class: "dropdown-menu-inner-content")
end
end
end
@@ -88,7 +88,7 @@ module NotificationsHelper
# All values from NotificationSetting.email_events
case event
when :success_pipeline
- s_('NotificationEvent|Successful pipeline')
+ s_("NotificationEvent|Successful pipeline")
else
s_(event.to_s.humanize)
end
diff --git a/app/helpers/numbers_helper.rb b/app/helpers/numbers_helper.rb
index 3c0b11c4d32..862cc032e5a 100644
--- a/app/helpers/numbers_helper.rb
+++ b/app/helpers/numbers_helper.rb
@@ -6,7 +6,7 @@ module NumbersHelper
limit = options.fetch(:limit, 1000).to_i
count = resource.limit(limit + 1).count(:all)
if count > limit
- number_with_delimiter(count - 1, options) + '+'
+ number_with_delimiter(count - 1, options) + "+"
else
number_with_delimiter(count, options)
end
diff --git a/app/helpers/page_layout_helper.rb b/app/helpers/page_layout_helper.rb
index 5038dcf9746..bb57ad65050 100644
--- a/app/helpers/page_layout_helper.rb
+++ b/app/helpers/page_layout_helper.rb
@@ -45,7 +45,7 @@ module PageLayoutHelper
end
def page_image
- default = image_url('gitlab_logo.png')
+ default = image_url("gitlab_logo.png")
subject = @project || @user || @group
@@ -59,7 +59,7 @@ module PageLayoutHelper
#
# Raises ArgumentError if given more than two attributes
def page_card_attributes(map = {})
- raise ArgumentError, 'cannot provide more than two attributes' if map.length > 2
+ raise ArgumentError, "cannot provide more than two attributes" if map.length > 2
@page_card_attributes ||= {}
@page_card_attributes = map.reject { |_, v| v.blank? } if map.present?
@@ -127,6 +127,6 @@ module PageLayoutHelper
css_class << "container-blank"
end
- css_class.join(' ')
+ css_class.join(" ")
end
end
diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb
index d05153c9d4b..8586bfdb700 100644
--- a/app/helpers/pagination_helper.rb
+++ b/app/helpers/pagination_helper.rb
@@ -11,13 +11,13 @@ module PaginationHelper
def paginate_without_count(collection)
render(
- 'kaminari/gitlab/without_count',
+ "kaminari/gitlab/without_count",
previous_path: path_to_prev_page(collection),
next_path: path_to_next_page(collection)
)
end
def paginate_with_count(collection, remote: nil)
- paginate(collection, remote: remote, theme: 'gitlab')
+ paginate(collection, remote: remote, theme: "gitlab")
end
end
diff --git a/app/helpers/pipeline_schedules_helper.rb b/app/helpers/pipeline_schedules_helper.rb
index 0e166106b32..6d2dccfd38a 100644
--- a/app/helpers/pipeline_schedules_helper.rb
+++ b/app/helpers/pipeline_schedules_helper.rb
@@ -6,7 +6,7 @@ module PipelineSchedulesHelper
{
name: timezone.name,
offset: timezone.now.utc_offset,
- identifier: timezone.tzinfo.identifier
+ identifier: timezone.tzinfo.identifier,
}
end
end
diff --git a/app/helpers/preferences_helper.rb b/app/helpers/preferences_helper.rb
index eed529f93db..7890cd0ab64 100644
--- a/app/helpers/preferences_helper.rb
+++ b/app/helpers/preferences_helper.rb
@@ -4,22 +4,22 @@
module PreferencesHelper
def layout_choices
[
- ['Fixed', :fixed],
- ['Fluid', :fluid]
+ ["Fixed", :fixed],
+ ["Fluid", :fluid],
]
end
# Maps `dashboard` values to more user-friendly option text
DASHBOARD_CHOICES = {
projects: _("Your Projects (default)"),
- stars: _("Starred Projects"),
+ stars: _("Starred Projects"),
project_activity: _("Your Projects' Activity"),
starred_project_activity: _("Starred Projects' Activity"),
groups: _("Your Groups"),
todos: _("Your Todos"),
issues: _("Assigned Issues"),
merge_requests: _("Assigned Merge Requests"),
- operations: _("Operations Dashboard")
+ operations: _("Operations Dashboard"),
}.with_indifferent_access.freeze
# Returns an Array usable by a select field for more user-friendly option text
@@ -37,21 +37,21 @@ module PreferencesHelper
def project_view_choices
[
- ['Files and Readme (default)', :files],
- ['Activity', :activity],
- ['Readme', :readme]
+ ["Files and Readme (default)", :files],
+ ["Activity", :activity],
+ ["Readme", :readme],
]
end
def first_day_of_week_choices
[
- [_('Sunday'), 0],
- [_('Monday'), 1]
+ [_("Sunday"), 0],
+ [_("Monday"), 1],
]
end
def first_day_of_week_choices_with_default
- first_day_of_week_choices.unshift([_('System default (%{default})') % { default: default_first_day_of_week }, nil])
+ first_day_of_week_choices.unshift([_("System default (%{default})") % {default: default_first_day_of_week}, nil])
end
def user_application_theme
@@ -79,7 +79,7 @@ module PreferencesHelper
# List of dashboard choice to be excluded from CE.
# EE would override this.
def excluded_dashboard_choices
- ['operations']
+ ["operations"]
end
def default_first_day_of_week
diff --git a/app/helpers/profiles_helper.rb b/app/helpers/profiles_helper.rb
index 5a42e581867..6451c29cffc 100644
--- a/app/helpers/profiles_helper.rb
+++ b/app/helpers/profiles_helper.rb
@@ -6,8 +6,8 @@ module ProfilesHelper
verified_emails = user.verified_emails - [private_email]
[
- [s_("Profiles|Use a private email - %{email}").html_safe % { email: private_email }, Gitlab::PrivateCommitEmail::TOKEN],
- *verified_emails
+ [s_("Profiles|Use a private email - %{email}").html_safe % {email: private_email}, Gitlab::PrivateCommitEmail::TOKEN],
+ *verified_emails,
]
end
@@ -21,12 +21,12 @@ module ProfilesHelper
if user_synced_attributes_metadata.provider
Gitlab::Auth::OAuth::Provider.label_for(user_synced_attributes_metadata.provider)
else
- 'LDAP'
+ "LDAP"
end
end
end
def user_profile?
- params[:controller] == 'users'
+ params[:controller] == "users"
end
end
diff --git a/app/helpers/projects/error_tracking_helper.rb b/app/helpers/projects/error_tracking_helper.rb
index 6daf2e21ca2..20f0a3930c8 100644
--- a/app/helpers/projects/error_tracking_helper.rb
+++ b/app/helpers/projects/error_tracking_helper.rb
@@ -5,11 +5,11 @@ module Projects::ErrorTrackingHelper
error_tracking_enabled = !!project.error_tracking_setting&.enabled?
{
- 'index-path' => project_error_tracking_index_path(project,
- format: :json),
- 'enable-error-tracking-link' => project_settings_operations_path(project),
- 'error-tracking-enabled' => error_tracking_enabled.to_s,
- 'illustration-path' => image_path('illustrations/cluster_popover.svg')
+ "index-path" => project_error_tracking_index_path(project,
+ format: :json),
+ "enable-error-tracking-link" => project_settings_operations_path(project),
+ "error-tracking-enabled" => error_tracking_enabled.to_s,
+ "illustration-path" => image_path("illustrations/cluster_popover.svg"),
}
end
end
diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb
index c400302cda3..0fc31cab03a 100644
--- a/app/helpers/projects_helper.rb
+++ b/app/helpers/projects_helper.rb
@@ -3,10 +3,10 @@
module ProjectsHelper
def link_to_project(project)
link_to namespace_project_path(namespace_id: project.namespace, id: project), title: h(project.name) do
- title = content_tag(:span, project.name, class: 'project-name')
+ title = content_tag(:span, project.name, class: "project-name")
if project.namespace
- namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: 'namespace-name')
+ namespace = content_tag(:span, "#{project.namespace.human_name} / ", class: "namespace-name")
title = namespace + title
end
@@ -15,7 +15,7 @@ module ProjectsHelper
end
def link_to_member_avatar(author, opts = {})
- default_opts = { size: 16, lazy_load: false }
+ default_opts = {size: 16, lazy_load: false}
opts = default_opts.merge(opts)
classes = %W[avatar avatar-inline s#{opts[:size]}]
@@ -24,22 +24,22 @@ module ProjectsHelper
avatar = avatar_icon_for_user(author, opts[:size])
src = opts[:lazy_load] ? nil : avatar
- image_tag(src, width: opts[:size], class: classes, alt: '', "data-src" => avatar)
+ image_tag(src, :width => opts[:size], :class => classes, :alt => "", "data-src" => avatar)
end
def author_content_tag(author, opts = {})
- default_opts = { author_class: 'author', tooltip: false, by_username: false }
+ default_opts = {author_class: "author", tooltip: false, by_username: false}
opts = default_opts.merge(opts)
has_tooltip = !opts[:by_username] && opts[:tooltip]
username = opts[:by_username] ? author.to_reference : author.name
- name_tag_options = { class: [opts[:author_class]] }
+ name_tag_options = {class: [opts[:author_class]]}
if has_tooltip
name_tag_options[:title] = author.to_reference
- name_tag_options[:data] = { placement: 'top' }
- name_tag_options[:class] << 'has-tooltip'
+ name_tag_options[:data] = {placement: "top"}
+ name_tag_options[:class] << "has-tooltip"
end
# NOTE: ActionView::Helpers::TagHelper#content_tag HTML escapes username
@@ -47,13 +47,13 @@ module ProjectsHelper
end
def link_to_member(project, author, opts = {}, &block)
- default_opts = { avatar: true, name: true, title: ":name" }
+ default_opts = {avatar: true, name: true, title: ":name"}
opts = default_opts.merge(opts)
data_attrs = {
user_id: author.id,
username: author.username,
- name: author.name
+ name: author.name,
}
return "(deleted)" unless author
@@ -71,10 +71,10 @@ module ProjectsHelper
author_html = author_html.join.html_safe
if opts[:name]
- link_to(author_html, user_path(author), class: "author-link js-user-link #{"#{opts[:extra_class]}" if opts[:extra_class]} #{"#{opts[:mobile_classes]}" if opts[:mobile_classes]}", data: data_attrs).html_safe
+ link_to(author_html, user_path(author), class: "author-link js-user-link #{(opts[:extra_class]).to_s if opts[:extra_class]} #{(opts[:mobile_classes]).to_s if opts[:mobile_classes]}", data: data_attrs).html_safe
else
title = opts[:title].sub(":name", sanitize(author.name))
- link_to(author_html, user_path(author), class: "author-link has-tooltip", title: title, data: { container: 'body' }).html_safe
+ link_to(author_html, user_path(author), class: "author-link has-tooltip", title: title, data: {container: "body"}).html_safe
end
end
@@ -88,7 +88,7 @@ module ProjectsHelper
end
project_link = link_to project_path(project) do
- icon = project_icon(project, alt: project.name, class: 'avatar-tile', width: 15, height: 15) if project.avatar_url && !Rails.env.test?
+ icon = project_icon(project, alt: project.name, class: "avatar-tile", width: 15, height: 15) if project.avatar_url && !Rails.env.test?
[icon, content_tag("span", simple_sanitize(project.name), class: "breadcrumb-item-text js-breadcrumb-item-text")].join.html_safe
end
@@ -100,17 +100,17 @@ module ProjectsHelper
def remove_project_message(project)
_("You are going to remove %{project_full_name}. Removed project CANNOT be restored! Are you ABSOLUTELY sure?") %
- { project_full_name: project.full_name }
+ {project_full_name: project.full_name}
end
def transfer_project_message(project)
_("You are going to transfer %{project_full_name} to another owner. Are you ABSOLUTELY sure?") %
- { project_full_name: project.full_name }
+ {project_full_name: project.full_name}
end
def remove_fork_project_message(project)
_("You are going to remove the fork relationship to source project %{forked_from_project}. Are you ABSOLUTELY sure?") %
- { forked_from_project: fork_source_name(project) }
+ {forked_from_project: fork_source_name(project)}
end
def fork_source_name(project)
@@ -160,12 +160,12 @@ module ProjectsHelper
end
def link_to_autodeploy_doc
- link_to _('About auto deploy'), help_page_path('ci/autodeploy/index'), target: '_blank'
+ link_to _("About auto deploy"), help_page_path("ci/autodeploy/index"), target: "_blank"
end
def autodeploy_flash_notice(branch_name)
translation = _("Branch <strong>%{branch_name}</strong> was created. To set up auto deploy, choose a GitLab CI Yaml template and commit your changes. %{link_to_autodeploy_doc}") %
- { branch_name: truncate(sanitize(branch_name)), link_to_autodeploy_doc: link_to_autodeploy_doc }
+ {branch_name: truncate(sanitize(branch_name)), link_to_autodeploy_doc: link_to_autodeploy_doc}
translation.html_safe
end
@@ -179,7 +179,7 @@ module ProjectsHelper
Gitlab::CurrentSettings.cache_key,
"cross-project:#{can?(current_user, :read_cross_project)}",
max_project_member_access_cache_key(project),
- 'v2.6'
+ "v2.6",
]
key << pipeline_status_cache_key(project.pipeline_status) if project.pipeline_status.has_status?
@@ -212,9 +212,9 @@ module ProjectsHelper
def link_to_set_password
if current_user.require_password_creation_for_git?
- link_to s_('SetPasswordToCloneLink|set a password'), edit_profile_password_path
+ link_to s_("SetPasswordToCloneLink|set a password"), edit_profile_password_path
else
- link_to s_('CreateTokenToCloneLink|create a personal access token'), profile_personal_access_tokens_path
+ link_to s_("CreateTokenToCloneLink|create a personal access token"), profile_personal_access_tokens_path
end
end
@@ -244,7 +244,7 @@ module ProjectsHelper
def push_to_create_project_command(user = current_user)
repository_url =
- if Gitlab::CurrentSettings.current_application_settings.enabled_git_access_protocol == 'http'
+ if Gitlab::CurrentSettings.current_application_settings.enabled_git_access_protocol == "http"
user_url(user)
else
Gitlab.config.gitlab_shell.ssh_path_prefix + user.username
@@ -262,7 +262,7 @@ module ProjectsHelper
end
def link_to_bfg
- link_to 'BFG', 'https://rtyley.github.io/bfg-repo-cleaner/', target: '_blank', rel: 'noopener noreferrer'
+ link_to "BFG", "https://rtyley.github.io/bfg-repo-cleaner/", target: "_blank", rel: "noopener noreferrer"
end
def explore_projects_tab?
@@ -330,38 +330,38 @@ module ProjectsHelper
def tab_ability_map
{
- environments: :read_environment,
- milestones: :read_milestone,
- snippets: :read_project_snippet,
- settings: :admin_project,
- builds: :read_build,
- clusters: :read_cluster,
- serverless: :read_cluster,
- error_tracking: :read_sentry_issue,
- labels: :read_label,
- issues: :read_issue,
- project_members: :read_project_member,
- wiki: :read_wiki
+ environments: :read_environment,
+ milestones: :read_milestone,
+ snippets: :read_project_snippet,
+ settings: :admin_project,
+ builds: :read_build,
+ clusters: :read_cluster,
+ serverless: :read_cluster,
+ error_tracking: :read_sentry_issue,
+ labels: :read_label,
+ issues: :read_issue,
+ project_members: :read_project_member,
+ wiki: :read_wiki,
}
end
def search_tab_ability_map
@search_tab_ability_map ||= tab_ability_map.merge(
- blobs: :download_code,
- commits: :download_code,
+ blobs: :download_code,
+ commits: :download_code,
merge_requests: :read_merge_request,
- notes: [:read_merge_request, :download_code, :read_issue, :read_project_snippet]
+ notes: [:read_merge_request, :download_code, :read_issue, :read_project_snippet]
)
end
def project_lfs_status(project)
if project.lfs_enabled?
- content_tag(:span, class: 'lfs-enabled') do
- s_('LFSStatus|Enabled')
+ content_tag(:span, class: "lfs-enabled") do
+ s_("LFSStatus|Enabled")
end
else
- content_tag(:span, class: 'lfs-disabled') do
- s_('LFSStatus|Disabled')
+ content_tag(:span, class: "lfs-disabled") do
+ s_("LFSStatus|Disabled")
end
end
end
@@ -384,7 +384,7 @@ module ProjectsHelper
def default_url_to_repo(project = @project)
case default_clone_protocol
- when 'ssh'
+ when "ssh"
project.ssh_url_to_repo
else
project.http_url_to_repo
@@ -392,7 +392,7 @@ module ProjectsHelper
end
def default_clone_label
- _("Copy %{protocol} clone URL") % { protocol: default_clone_protocol.upcase }
+ _("Copy %{protocol} clone URL") % {protocol: default_clone_protocol.upcase}
end
def default_clone_protocol
@@ -407,7 +407,7 @@ module ProjectsHelper
if !current_user || current_user.require_ssh_key?
gitlab_config.protocol
else
- 'ssh'
+ "ssh"
end
end
@@ -417,14 +417,14 @@ module ProjectsHelper
def project_last_activity(project)
if project.last_activity_at
- time_ago_with_tooltip(project.last_activity_at, placement: 'bottom', html_class: 'last_activity_time_ago')
+ time_ago_with_tooltip(project.last_activity_at, placement: "bottom", html_class: "last_activity_time_ago")
else
s_("ProjectLastActivity|Never")
end
end
def project_wiki_path_with_version(proj, page, version, is_newest)
- url_params = is_newest ? {} : { version_id: version }
+ url_params = is_newest ? {} : {version_id: version}
project_wiki_path(proj, page, url_params)
end
@@ -440,8 +440,8 @@ module ProjectsHelper
end
def readme_cache_key
- sha = @project.commit.try(:sha) || 'nil'
- [@project.full_path, sha, "readme"].join('-')
+ sha = @project.commit.try(:sha) || "nil"
+ [@project.full_path, sha, "readme"].join("-")
end
def current_ref
@@ -475,7 +475,7 @@ module ProjectsHelper
snippetsAccessLevel: feature.snippets_access_level,
pagesAccessLevel: feature.pages_access_level,
containerRegistryEnabled: !!project.container_registry_enabled,
- lfsEnabled: !!project.lfs_enabled
+ lfsEnabled: !!project.lfs_enabled,
}
end
@@ -484,14 +484,14 @@ module ProjectsHelper
currentSettings: project_permissions_settings(project),
canChangeVisibilityLevel: can_change_visibility_level?(project, current_user),
allowedVisibilityOptions: project_allowed_visibility_levels(project),
- visibilityHelpPath: help_page_path('public_access/public_access'),
+ visibilityHelpPath: help_page_path("public_access/public_access"),
registryAvailable: Gitlab.config.registry.enabled,
- registryHelpPath: help_page_path('user/project/container_registry'),
+ registryHelpPath: help_page_path("user/project/container_registry"),
lfsAvailable: Gitlab.config.lfs.enabled,
- lfsHelpPath: help_page_path('workflow/lfs/manage_large_binaries_with_git_lfs'),
+ lfsHelpPath: help_page_path("workflow/lfs/manage_large_binaries_with_git_lfs"),
pagesAvailable: Gitlab.config.pages.enabled,
pagesAccessControlEnabled: Gitlab.config.pages.access_control,
- pagesHelpPath: help_page_path('user/project/pages/introduction', anchor: 'gitlab-pages-access-control-core-only')
+ pagesHelpPath: help_page_path("user/project/pages/introduction", anchor: "gitlab-pages-access-control-core-only"),
}
end
diff --git a/app/helpers/repository_languages_helper.rb b/app/helpers/repository_languages_helper.rb
index cf7eee7fff3..b64ce165aea 100644
--- a/app/helpers/repository_languages_helper.rb
+++ b/app/helpers/repository_languages_helper.rb
@@ -4,7 +4,7 @@ module RepositoryLanguagesHelper
def repository_languages_bar(languages)
return if languages.none?
- content_tag :div, class: 'progress repository-languages-bar' do
+ content_tag :div, class: "progress repository-languages-bar" do
safe_join(languages.map { |lang| language_progress(lang) })
end
end
@@ -13,7 +13,7 @@ module RepositoryLanguagesHelper
content_tag :div, nil,
class: "progress-bar has-tooltip",
style: "width: #{lang.share}%; background-color:#{lang.color}",
- data: { html: true },
+ data: {html: true},
title: "<span class=\"repository-language-bar-tooltip-language\">#{escape_javascript(lang.name)}</span>&nbsp;<span class=\"repository-language-bar-tooltip-share\">#{lang.share.round(1)}%</span>"
end
end
diff --git a/app/helpers/rss_helper.rb b/app/helpers/rss_helper.rb
index 67c7d244f11..e50db812e33 100644
--- a/app/helpers/rss_helper.rb
+++ b/app/helpers/rss_helper.rb
@@ -2,6 +2,6 @@
module RssHelper
def rss_url_options
- { format: :atom, feed_token: current_user.try(:feed_token) }
+ {format: :atom, feed_token: current_user.try(:feed_token)}
end
end
diff --git a/app/helpers/runners_helper.rb b/app/helpers/runners_helper.rb
index 0d880c38a7b..2ebbd9ba86c 100644
--- a/app/helpers/runners_helper.rb
+++ b/app/helpers/runners_helper.rb
@@ -6,13 +6,13 @@ module RunnersHelper
case status
when :not_connected
content_tag :i, nil,
- class: "fa fa-warning",
- title: "New runner. Has not connected yet"
+ class: "fa fa-warning",
+ title: "New runner. Has not connected yet"
when :online, :offline, :paused
content_tag :i, nil,
- class: "fa fa-circle runner-status-#{status}",
- title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
+ class: "fa fa-circle runner-status-#{status}",
+ title: "Runner is #{status}, last contact was #{time_ago_in_words(runner.contacted_at)} ago"
end
end
@@ -20,7 +20,7 @@ module RunnersHelper
display_name = truncate(runner.display_name, length: 15)
id = "\##{runner.id}"
- if current_user && current_user.admin
+ if current_user&.admin
link_to admin_runner_path(runner) do
display_name + id
end
@@ -32,7 +32,7 @@ module RunnersHelper
# Due to inability of performing sorting of runners by cached "contacted_at" values we have to show uncached values if sorting by "contacted_asc" is requested.
# Please refer to the following issue for more details: https://gitlab.com/gitlab-org/gitlab-ce/issues/55920
def runner_contacted_at(runner)
- if params[:sort] == 'contacted_asc'
+ if params[:sort] == "contacted_asc"
runner.uncached_contacted_at
else
runner.contacted_at
diff --git a/app/helpers/search_helper.rb b/app/helpers/search_helper.rb
index 0ee76a51f7d..6cd8bded0f4 100644
--- a/app/helpers/search_helper.rb
+++ b/app/helpers/search_helper.rb
@@ -6,7 +6,7 @@ module SearchHelper
resources_results = [
groups_autocomplete(term),
- projects_autocomplete(term)
+ projects_autocomplete(term),
].flatten
search_pattern = Regexp.new(Regexp.escape(term), "i")
@@ -17,7 +17,7 @@ module SearchHelper
[
resources_results,
- generic_results
+ generic_results,
].flatten.uniq do |item|
item[:label]
end
@@ -50,50 +50,50 @@ module SearchHelper
# Autocomplete results for various settings pages
def default_autocomplete
[
- { category: "Settings", label: "User settings", url: profile_path },
- { category: "Settings", label: "SSH Keys", url: profile_keys_path },
- { category: "Settings", label: "Dashboard", url: root_path }
+ {category: "Settings", label: "User settings", url: profile_path},
+ {category: "Settings", label: "SSH Keys", url: profile_keys_path},
+ {category: "Settings", label: "Dashboard", url: root_path},
]
end
# Autocomplete results for settings pages, for admins
def default_autocomplete_admin
[
- { category: "Settings", label: "Admin Section", url: admin_root_path }
+ {category: "Settings", label: "Admin Section", url: admin_root_path},
]
end
# Autocomplete results for internal help pages
def help_autocomplete
[
- { category: "Help", label: "API Help", url: help_page_path("api/README") },
- { category: "Help", label: "Markdown Help", url: help_page_path("user/markdown") },
- { category: "Help", label: "Permissions Help", url: help_page_path("user/permissions") },
- { category: "Help", label: "Public Access Help", url: help_page_path("public_access/public_access") },
- { category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks/README") },
- { category: "Help", label: "SSH Keys Help", url: help_page_path("ssh/README") },
- { category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks/system_hooks") },
- { category: "Help", label: "Webhooks Help", url: help_page_path("user/project/integrations/webhooks") },
- { category: "Help", label: "Workflow Help", url: help_page_path("workflow/README") }
+ {category: "Help", label: "API Help", url: help_page_path("api/README")},
+ {category: "Help", label: "Markdown Help", url: help_page_path("user/markdown")},
+ {category: "Help", label: "Permissions Help", url: help_page_path("user/permissions")},
+ {category: "Help", label: "Public Access Help", url: help_page_path("public_access/public_access")},
+ {category: "Help", label: "Rake Tasks Help", url: help_page_path("raketasks/README")},
+ {category: "Help", label: "SSH Keys Help", url: help_page_path("ssh/README")},
+ {category: "Help", label: "System Hooks Help", url: help_page_path("system_hooks/system_hooks")},
+ {category: "Help", label: "Webhooks Help", url: help_page_path("user/project/integrations/webhooks")},
+ {category: "Help", label: "Workflow Help", url: help_page_path("workflow/README")},
]
end
# Autocomplete results for the current project, if it's defined
def project_autocomplete
- if @project && @project.repository.exists? && @project.repository.root_ref
+ if @project&.repository&.exists? && @project.repository.root_ref
ref = @ref || @project.repository.root_ref
[
- { category: "In this project", label: "Files", url: project_tree_path(@project, ref) },
- { category: "In this project", label: "Commits", url: project_commits_path(@project, ref) },
- { category: "In this project", label: "Network", url: project_network_path(@project, ref) },
- { category: "In this project", label: "Graph", url: project_graph_path(@project, ref) },
- { category: "In this project", label: "Issues", url: project_issues_path(@project) },
- { category: "In this project", label: "Merge Requests", url: project_merge_requests_path(@project) },
- { category: "In this project", label: "Milestones", url: project_milestones_path(@project) },
- { category: "In this project", label: "Snippets", url: project_snippets_path(@project) },
- { category: "In this project", label: "Members", url: project_project_members_path(@project) },
- { category: "In this project", label: "Wiki", url: project_wikis_path(@project) }
+ {category: "In this project", label: "Files", url: project_tree_path(@project, ref)},
+ {category: "In this project", label: "Commits", url: project_commits_path(@project, ref)},
+ {category: "In this project", label: "Network", url: project_network_path(@project, ref)},
+ {category: "In this project", label: "Graph", url: project_graph_path(@project, ref)},
+ {category: "In this project", label: "Issues", url: project_issues_path(@project)},
+ {category: "In this project", label: "Merge Requests", url: project_merge_requests_path(@project)},
+ {category: "In this project", label: "Milestones", url: project_milestones_path(@project)},
+ {category: "In this project", label: "Snippets", url: project_snippets_path(@project)},
+ {category: "In this project", label: "Members", url: project_project_members_path(@project)},
+ {category: "In this project", label: "Wiki", url: project_wikis_path(@project)},
]
else
[]
@@ -107,9 +107,9 @@ module SearchHelper
{
category: "Groups",
id: group.id,
- label: "#{search_result_sanitize(group.full_name)}",
+ label: search_result_sanitize(group.full_name).to_s,
url: group_path(group),
- avatar_url: group.avatar_url || ''
+ avatar_url: group.avatar_url || "",
}
end
end
@@ -123,10 +123,10 @@ module SearchHelper
{
category: "Projects",
id: p.id,
- value: "#{search_result_sanitize(p.name)}",
- label: "#{search_result_sanitize(p.full_name)}",
+ value: search_result_sanitize(p.name).to_s,
+ label: search_result_sanitize(p.full_name).to_s,
url: project_path(p),
- avatar_url: p.avatar_url || ''
+ avatar_url: p.avatar_url || "",
}
end
end
@@ -142,7 +142,7 @@ module SearchHelper
project_id: params[:project_id],
group_id: params[:group_id],
scope: params[:scope],
- repository_ref: params[:repository_ref]
+ repository_ref: params[:repository_ref],
}
options = exist_opts.merge(options)
@@ -153,21 +153,21 @@ module SearchHelper
opts =
{
id: "filtered-search-#{type}",
- placeholder: 'Search or filter results...',
+ placeholder: "Search or filter results...",
data: {
- 'username-params' => UserSerializer.new.represent(@users)
+ "username-params" => UserSerializer.new.represent(@users),
},
- autocomplete: 'off'
+ autocomplete: "off",
}
if @project.present?
- opts[:data]['project-id'] = @project.id
- opts[:data]['base-endpoint'] = project_path(@project)
+ opts[:data]["project-id"] = @project.id
+ opts[:data]["base-endpoint"] = project_path(@project)
elsif @group.present?
- opts[:data]['group-id'] = @group.id
- opts[:data]['base-endpoint'] = group_canonical_path(@group)
+ opts[:data]["group-id"] = @group.id
+ opts[:data]["base-endpoint"] = group_canonical_path(@group)
else
- opts[:data]['base-endpoint'] = root_dashboard_path
+ opts[:data]["base-endpoint"] = root_dashboard_path
end
opts
@@ -179,7 +179,7 @@ module SearchHelper
elsif @group.present?
@group.full_path
else
- 'dashboard'
+ "dashboard"
end
end
@@ -195,7 +195,7 @@ module SearchHelper
)
# Truncato's filtered_tags and filtered_attributes are not quite the same
- sanitize(html, tags: %w(a p ol ul li pre code))
+ sanitize(html, tags: %w[a p ol ul li pre code])
end
def limited_count(count, limit = 1000)
diff --git a/app/helpers/selects_helper.rb b/app/helpers/selects_helper.rb
index 2f802e4eab8..f433ee56ab3 100644
--- a/app/helpers/selects_helper.rb
+++ b/app/helpers/selects_helper.rb
@@ -5,20 +5,20 @@ module SelectsHelper
css_class = ["ajax-users-select"]
css_class << "multiselect" if opts[:multiple]
css_class << "skip_ldap" if opts[:skip_ldap]
- css_class << (opts[:class] || '')
- value = opts[:selected] || ''
+ css_class << (opts[:class] || "")
+ value = opts[:selected] || ""
html = {
- class: css_class.join(' '),
- data: users_select_data_attributes(opts)
+ class: css_class.join(" "),
+ data: users_select_data_attributes(opts),
}
unless opts[:scope] == :all
project = opts[:project] || @project
if project
- html['data-project-id'] = project.id
+ html["data-project-id"] = project.id
elsif @group
- html['data-group-id'] = @group.id
+ html["data-group-id"] = @group.id
end
end
@@ -27,36 +27,36 @@ module SelectsHelper
def groups_select_tag(id, opts = {})
classes = Array.wrap(opts[:class])
- classes << 'ajax-groups-select'
+ classes << "ajax-groups-select"
# EE requires this line to be present, but there is no easy way of injecting
# this into EE without causing merge conflicts. Given this line is very
# simple and not really EE specific on its own, we just include it in CE.
- classes << 'multiselect' if opts[:multiple]
+ classes << "multiselect" if opts[:multiple]
- opts[:class] = classes.join(' ')
+ opts[:class] = classes.join(" ")
select2_tag(id, opts)
end
def namespace_select_tag(id, opts = {})
- opts[:class] = [*opts[:class], 'ajax-namespace-select'].join(' ')
+ opts[:class] = [*opts[:class], "ajax-namespace-select"].join(" ")
select2_tag(id, opts)
end
def project_select_tag(id, opts = {})
- opts[:class] = [*opts[:class], 'ajax-project-select'].join(' ')
+ opts[:class] = [*opts[:class], "ajax-project-select"].join(" ")
unless opts.delete(:scope) == :all
if @group
- opts['data-group-id'] = @group.id
+ opts["data-group-id"] = @group.id
end
end
with_feature_enabled_data_attribute =
case opts.delete(:with_feature_enabled)
- when 'issues' then 'data-with-issues-enabled'
- when 'merge_requests' then 'data-with-merge-requests-enabled'
+ when "issues" then "data-with-issues-enabled"
+ when "merge_requests" then "data-with-merge-requests-enabled"
end
opts[with_feature_enabled_data_attribute] = true
@@ -66,10 +66,10 @@ module SelectsHelper
def select2_tag(id, opts = {})
klass_opts = [opts[:class]]
- klass_opts << 'multiselect' if opts[:multiple]
+ klass_opts << "multiselect" if opts[:multiple]
- opts[:class] = klass_opts.join(' ')
- value = opts[:selected] || ''
+ opts[:class] = klass_opts.join(" ")
+ value = opts[:selected] || ""
hidden_field_tag(id, value, opts)
end
@@ -78,14 +78,14 @@ module SelectsHelper
def users_select_data_attributes(opts)
{
- placeholder: opts[:placeholder] || 'Search for a user',
+ placeholder: opts[:placeholder] || "Search for a user",
null_user: opts[:null_user] || false,
any_user: opts[:any_user] || false,
email_user: opts[:email_user] || false,
first_user: opts[:first_user] && current_user ? current_user.username : false,
current_user: opts[:current_user] || false,
- author_id: opts[:author_id] || '',
- skip_users: opts[:skip_users] ? opts[:skip_users].map(&:id) : nil
+ author_id: opts[:author_id] || "",
+ skip_users: opts[:skip_users] ? opts[:skip_users].map(&:id) : nil,
}
end
end
diff --git a/app/helpers/services_helper.rb b/app/helpers/services_helper.rb
index d4b50b7ecfb..4fe2b7e4c0e 100644
--- a/app/helpers/services_helper.rb
+++ b/app/helpers/services_helper.rb
@@ -32,9 +32,9 @@ module ServicesHelper
end
def service_save_button(service)
- button_tag(class: 'btn btn-success', type: 'submit', disabled: service.deprecated?) do
- icon('spinner spin', class: 'hidden js-btn-spinner') +
- content_tag(:span, 'Save changes', class: 'js-btn-label')
+ button_tag(class: "btn btn-success", type: "submit", disabled: service.deprecated?) do
+ icon("spinner spin", class: "hidden js-btn-spinner") +
+ content_tag(:span, "Save changes", class: "js-btn-label")
end
end
diff --git a/app/helpers/sidekiq_helper.rb b/app/helpers/sidekiq_helper.rb
index 32bf3526571..156d69c5420 100644
--- a/app/helpers/sidekiq_helper.rb
+++ b/app/helpers/sidekiq_helper.rb
@@ -12,6 +12,6 @@ module SidekiqHelper
def parse_sidekiq_ps(line)
match = line.strip.match(SIDEKIQ_PS_REGEXP)
- match ? match[1..6] : Array.new(6, '?')
+ match ? match[1..6] : Array.new(6, "?")
end
end
diff --git a/app/helpers/snippets_helper.rb b/app/helpers/snippets_helper.rb
index ecb2b2d707b..37870e88086 100644
--- a/app/helpers/snippets_helper.rb
+++ b/app/helpers/snippets_helper.rb
@@ -46,12 +46,14 @@ module SnippetsHelper
def matching_lines(lined_content, surrounding_lines, query)
used_lines = []
lined_content.each_with_index do |line, line_number|
- used_lines.concat bounded_line_numbers(
- line_number,
- 0,
- lined_content.size,
- surrounding_lines
- ) if line.downcase.include?(query.downcase)
+ if line.downcase.include?(query.downcase)
+ used_lines.concat bounded_line_numbers(
+ line_number,
+ 0,
+ lined_content.size,
+ surrounding_lines
+ )
+ end
end
used_lines.uniq.sort
@@ -84,7 +86,7 @@ module SnippetsHelper
# Non-consecutive line, add chunk to chunk array.
snippet_chunks << {
data: snippet_chunk.join("\n"),
- start_line: snippet_start_line + 1
+ start_line: snippet_start_line + 1,
}
# Start a new chunk.
@@ -97,11 +99,11 @@ module SnippetsHelper
# Add final chunk to chunk array
snippet_chunks << {
data: snippet_chunk.join("\n"),
- start_line: snippet_start_line + 1
+ start_line: snippet_start_line + 1,
}
# Return snippet with chunk array
- { snippet_object: snippet, snippet_chunks: snippet_chunks }
+ {snippet_object: snippet, snippet_chunks: snippet_chunks}
end
def snippet_embed
@@ -113,21 +115,21 @@ module SnippetsHelper
return if blob.empty? || blob.binary? || blob.stored_externally?
snippet_raw_url = if @snippet.is_a?(PersonalSnippet)
- raw_snippet_url(@snippet)
- else
- raw_project_snippet_url(@snippet.project, @snippet)
- end
+ raw_snippet_url(@snippet)
+ else
+ raw_project_snippet_url(@snippet.project, @snippet)
+ end
- link_to external_snippet_icon('doc-code'), snippet_raw_url, class: 'btn', target: '_blank', rel: 'noopener noreferrer', title: 'Open raw'
+ link_to external_snippet_icon("doc-code"), snippet_raw_url, class: "btn", target: "_blank", rel: "noopener noreferrer", title: "Open raw"
end
def embedded_snippet_download_button
download_url = if @snippet.is_a?(PersonalSnippet)
- raw_snippet_url(@snippet, inline: false)
- else
- raw_project_snippet_url(@snippet.project, @snippet, inline: false)
- end
+ raw_snippet_url(@snippet, inline: false)
+ else
+ raw_project_snippet_url(@snippet.project, @snippet, inline: false)
+ end
- link_to external_snippet_icon('download'), download_url, class: 'btn', target: '_blank', title: 'Download', rel: 'noopener noreferrer'
+ link_to external_snippet_icon("download"), download_url, class: "btn", target: "_blank", title: "Download", rel: "noopener noreferrer"
end
end
diff --git a/app/helpers/sorting_helper.rb b/app/helpers/sorting_helper.rb
index 07ec129dea3..3322e0e5dd8 100644
--- a/app/helpers/sorting_helper.rb
+++ b/app/helpers/sorting_helper.rb
@@ -3,43 +3,43 @@
module SortingHelper
def sort_options_hash
{
- sort_value_created_date => sort_title_created_date,
- sort_value_downvotes => sort_title_downvotes,
- sort_value_due_date => sort_title_due_date,
- sort_value_due_date_later => sort_title_due_date_later,
- sort_value_due_date_soon => sort_title_due_date_soon,
- sort_value_label_priority => sort_title_label_priority,
- sort_value_largest_group => sort_title_largest_group,
- sort_value_largest_repo => sort_title_largest_repo,
- sort_value_milestone => sort_title_milestone,
- sort_value_milestone_later => sort_title_milestone_later,
- sort_value_milestone_soon => sort_title_milestone_soon,
- sort_value_name => sort_title_name,
- sort_value_name_desc => sort_title_name_desc,
- sort_value_oldest_created => sort_title_oldest_created,
- sort_value_oldest_signin => sort_title_oldest_signin,
- sort_value_oldest_updated => sort_title_oldest_updated,
+ sort_value_created_date => sort_title_created_date,
+ sort_value_downvotes => sort_title_downvotes,
+ sort_value_due_date => sort_title_due_date,
+ sort_value_due_date_later => sort_title_due_date_later,
+ sort_value_due_date_soon => sort_title_due_date_soon,
+ sort_value_label_priority => sort_title_label_priority,
+ sort_value_largest_group => sort_title_largest_group,
+ sort_value_largest_repo => sort_title_largest_repo,
+ sort_value_milestone => sort_title_milestone,
+ sort_value_milestone_later => sort_title_milestone_later,
+ sort_value_milestone_soon => sort_title_milestone_soon,
+ sort_value_name => sort_title_name,
+ sort_value_name_desc => sort_title_name_desc,
+ sort_value_oldest_created => sort_title_oldest_created,
+ sort_value_oldest_signin => sort_title_oldest_signin,
+ sort_value_oldest_updated => sort_title_oldest_updated,
sort_value_recently_created => sort_title_recently_created,
- sort_value_recently_signin => sort_title_recently_signin,
+ sort_value_recently_signin => sort_title_recently_signin,
sort_value_recently_updated => sort_title_recently_updated,
- sort_value_popularity => sort_title_popularity,
- sort_value_priority => sort_title_priority,
- sort_value_upvotes => sort_title_upvotes,
- sort_value_contacted_date => sort_title_contacted_date
+ sort_value_popularity => sort_title_popularity,
+ sort_value_priority => sort_title_priority,
+ sort_value_upvotes => sort_title_upvotes,
+ sort_value_contacted_date => sort_title_contacted_date,
}
end
def projects_sort_options_hash
options = {
- sort_value_latest_activity => sort_title_latest_activity,
- sort_value_name => sort_title_name,
- sort_value_oldest_activity => sort_title_oldest_activity,
- sort_value_oldest_created => sort_title_oldest_created,
+ sort_value_latest_activity => sort_title_latest_activity,
+ sort_value_name => sort_title_name,
+ sort_value_oldest_activity => sort_title_oldest_activity,
+ sort_value_oldest_created => sort_title_oldest_created,
sort_value_recently_created => sort_title_recently_created,
- sort_value_most_stars => sort_title_most_stars
+ sort_value_most_stars => sort_title_most_stars,
}
- if current_controller?('admin/projects')
+ if current_controller?("admin/projects")
options[sort_value_largest_repo] = sort_title_largest_repo
end
@@ -48,12 +48,12 @@ module SortingHelper
def groups_sort_options_hash
{
- sort_value_name => sort_title_name,
- sort_value_name_desc => sort_title_name_desc,
+ sort_value_name => sort_title_name,
+ sort_value_name_desc => sort_title_name_desc,
sort_value_recently_created => sort_title_recently_created,
- sort_value_oldest_created => sort_title_oldest_created,
+ sort_value_oldest_created => sort_title_oldest_created,
sort_value_recently_updated => sort_title_recently_updated,
- sort_value_oldest_updated => sort_title_oldest_updated
+ sort_value_oldest_updated => sort_title_oldest_updated,
}
end
@@ -71,41 +71,41 @@ module SortingHelper
def member_sort_options_hash
{
- sort_value_access_level_asc => sort_title_access_level_asc,
+ sort_value_access_level_asc => sort_title_access_level_asc,
sort_value_access_level_desc => sort_title_access_level_desc,
- sort_value_last_joined => sort_title_last_joined,
- sort_value_name => sort_title_name_asc,
- sort_value_name_desc => sort_title_name_desc,
- sort_value_oldest_joined => sort_title_oldest_joined,
- sort_value_oldest_signin => sort_title_oldest_signin,
- sort_value_recently_signin => sort_title_recently_signin
+ sort_value_last_joined => sort_title_last_joined,
+ sort_value_name => sort_title_name_asc,
+ sort_value_name_desc => sort_title_name_desc,
+ sort_value_oldest_joined => sort_title_oldest_joined,
+ sort_value_oldest_signin => sort_title_oldest_signin,
+ sort_value_recently_signin => sort_title_recently_signin,
}
end
def milestone_sort_options_hash
{
- sort_value_name => sort_title_name_asc,
- sort_value_name_desc => sort_title_name_desc,
- sort_value_due_date_later => sort_title_due_date_later,
- sort_value_due_date_soon => sort_title_due_date_soon,
+ sort_value_name => sort_title_name_asc,
+ sort_value_name_desc => sort_title_name_desc,
+ sort_value_due_date_later => sort_title_due_date_later,
+ sort_value_due_date_soon => sort_title_due_date_soon,
sort_value_start_date_later => sort_title_start_date_later,
- sort_value_start_date_soon => sort_title_start_date_soon
+ sort_value_start_date_soon => sort_title_start_date_soon,
}
end
def branches_sort_options_hash
{
- sort_value_name => sort_title_name,
- sort_value_oldest_updated => sort_title_oldest_updated,
- sort_value_recently_updated => sort_title_recently_updated
+ sort_value_name => sort_title_name,
+ sort_value_oldest_updated => sort_title_oldest_updated,
+ sort_value_recently_updated => sort_title_recently_updated,
}
end
def tags_sort_options_hash
{
- sort_value_name => sort_title_name,
- sort_value_oldest_updated => sort_title_oldest_updated,
- sort_value_recently_updated => sort_title_recently_updated
+ sort_value_name => sort_title_name,
+ sort_value_oldest_updated => sort_title_oldest_updated,
+ sort_value_recently_updated => sort_title_recently_updated,
}
end
@@ -116,7 +116,7 @@ module SortingHelper
sort_value_recently_created => sort_title_recently_created,
sort_value_oldest_created => sort_title_oldest_created,
sort_value_recently_updated => sort_title_recently_updated,
- sort_value_oldest_updated => sort_title_oldest_updated
+ sort_value_oldest_updated => sort_title_oldest_updated,
}
end
@@ -130,19 +130,19 @@ module SortingHelper
sort_value_recently_updated => sort_title_recently_updated,
sort_value_oldest_updated => sort_title_oldest_updated,
sort_value_recently_last_activity => sort_title_recently_last_activity,
- sort_value_oldest_last_activity => sort_title_oldest_last_activity
+ sort_value_oldest_last_activity => sort_title_oldest_last_activity,
}
end
def sortable_item(item, path, sorted_by)
- link_to item, path, class: sorted_by == item ? 'is-active' : ''
+ link_to item, path, class: sorted_by == item ? "is-active" : ""
end
def issuable_sort_option_overrides
{
sort_value_oldest_created => sort_value_created_date,
sort_value_oldest_updated => sort_value_recently_updated,
- sort_value_milestone_later => sort_value_milestone
+ sort_value_milestone_later => sort_value_milestone,
}
end
@@ -151,7 +151,7 @@ module SortingHelper
sort_value_created_date => sort_value_oldest_created,
sort_value_recently_created => sort_value_oldest_created,
sort_value_recently_updated => sort_value_oldest_updated,
- sort_value_milestone => sort_value_milestone_later
+ sort_value_milestone => sort_value_milestone_later,
}.merge(issuable_sort_option_overrides)
end
@@ -164,303 +164,303 @@ module SortingHelper
def issuable_sort_icon_suffix(sort_value)
case sort_value
when sort_value_milestone, sort_value_due_date, /_asc\z/
- 'lowest'
+ "lowest"
else
- 'highest'
+ "highest"
end
end
def issuable_sort_direction_button(sort_value)
- link_class = 'btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort'
+ link_class = "btn btn-default has-tooltip reverse-sort-btn qa-reverse-sort"
reverse_sort = issuable_reverse_sort_order_hash[sort_value]
if reverse_sort
reverse_url = page_filter_path(sort: reverse_sort)
else
- reverse_url = '#'
- link_class += ' disabled'
+ reverse_url = "#"
+ link_class += " disabled"
end
- link_to(reverse_url, type: 'button', class: link_class, title: 'Sort direction') do
+ link_to(reverse_url, type: "button", class: link_class, title: "Sort direction") do
sprite_icon("sort-#{issuable_sort_icon_suffix(sort_value)}", size: 16)
end
end
# Titles.
def sort_title_access_level_asc
- s_('SortOptions|Access level, ascending')
+ s_("SortOptions|Access level, ascending")
end
def sort_title_access_level_desc
- s_('SortOptions|Access level, descending')
+ s_("SortOptions|Access level, descending")
end
def sort_title_created_date
- s_('SortOptions|Created date')
+ s_("SortOptions|Created date")
end
def sort_title_downvotes
- s_('SortOptions|Least popular')
+ s_("SortOptions|Least popular")
end
def sort_title_due_date
- s_('SortOptions|Due date')
+ s_("SortOptions|Due date")
end
def sort_title_due_date_later
- s_('SortOptions|Due later')
+ s_("SortOptions|Due later")
end
def sort_title_due_date_soon
- s_('SortOptions|Due soon')
+ s_("SortOptions|Due soon")
end
def sort_title_label_priority
- s_('SortOptions|Label priority')
+ s_("SortOptions|Label priority")
end
def sort_title_largest_group
- s_('SortOptions|Largest group')
+ s_("SortOptions|Largest group")
end
def sort_title_largest_repo
- s_('SortOptions|Largest repository')
+ s_("SortOptions|Largest repository")
end
def sort_title_last_joined
- s_('SortOptions|Last joined')
+ s_("SortOptions|Last joined")
end
def sort_title_latest_activity
- s_('SortOptions|Last updated')
+ s_("SortOptions|Last updated")
end
def sort_title_milestone
- s_('SortOptions|Milestone due date')
+ s_("SortOptions|Milestone due date")
end
def sort_title_milestone_later
- s_('SortOptions|Milestone due later')
+ s_("SortOptions|Milestone due later")
end
def sort_title_milestone_soon
- s_('SortOptions|Milestone due soon')
+ s_("SortOptions|Milestone due soon")
end
def sort_title_name
- s_('SortOptions|Name')
+ s_("SortOptions|Name")
end
def sort_title_name_asc
- s_('SortOptions|Name, ascending')
+ s_("SortOptions|Name, ascending")
end
def sort_title_name_desc
- s_('SortOptions|Name, descending')
+ s_("SortOptions|Name, descending")
end
def sort_title_oldest_activity
- s_('SortOptions|Oldest updated')
+ s_("SortOptions|Oldest updated")
end
def sort_title_oldest_created
- s_('SortOptions|Oldest created')
+ s_("SortOptions|Oldest created")
end
def sort_title_oldest_joined
- s_('SortOptions|Oldest joined')
+ s_("SortOptions|Oldest joined")
end
def sort_title_oldest_signin
- s_('SortOptions|Oldest sign in')
+ s_("SortOptions|Oldest sign in")
end
def sort_title_oldest_updated
- s_('SortOptions|Oldest updated')
+ s_("SortOptions|Oldest updated")
end
def sort_title_popularity
- s_('SortOptions|Popularity')
+ s_("SortOptions|Popularity")
end
def sort_title_priority
- s_('SortOptions|Priority')
+ s_("SortOptions|Priority")
end
def sort_title_recently_created
- s_('SortOptions|Last created')
+ s_("SortOptions|Last created")
end
def sort_title_recently_signin
- s_('SortOptions|Recent sign in')
+ s_("SortOptions|Recent sign in")
end
def sort_title_recently_updated
- s_('SortOptions|Last updated')
+ s_("SortOptions|Last updated")
end
def sort_title_start_date_later
- s_('SortOptions|Start later')
+ s_("SortOptions|Start later")
end
def sort_title_start_date_soon
- s_('SortOptions|Start soon')
+ s_("SortOptions|Start soon")
end
def sort_title_upvotes
- s_('SortOptions|Most popular')
+ s_("SortOptions|Most popular")
end
def sort_title_contacted_date
- s_('SortOptions|Last Contact')
+ s_("SortOptions|Last Contact")
end
def sort_title_most_stars
- s_('SortOptions|Most stars')
+ s_("SortOptions|Most stars")
end
def sort_title_oldest_last_activity
- s_('SortOptions|Oldest last activity')
+ s_("SortOptions|Oldest last activity")
end
def sort_title_recently_last_activity
- s_('SortOptions|Recent last activity')
+ s_("SortOptions|Recent last activity")
end
# Values.
def sort_value_access_level_asc
- 'access_level_asc'
+ "access_level_asc"
end
def sort_value_access_level_desc
- 'access_level_desc'
+ "access_level_desc"
end
def sort_value_created_date
- 'created_date'
+ "created_date"
end
def sort_value_downvotes
- 'downvotes_desc'
+ "downvotes_desc"
end
def sort_value_due_date
- 'due_date'
+ "due_date"
end
def sort_value_due_date_later
- 'due_date_desc'
+ "due_date_desc"
end
def sort_value_due_date_soon
- 'due_date_asc'
+ "due_date_asc"
end
def sort_value_label_priority
- 'label_priority'
+ "label_priority"
end
def sort_value_largest_group
- 'storage_size_desc'
+ "storage_size_desc"
end
def sort_value_largest_repo
- 'storage_size_desc'
+ "storage_size_desc"
end
def sort_value_last_joined
- 'last_joined'
+ "last_joined"
end
def sort_value_latest_activity
- 'latest_activity_desc'
+ "latest_activity_desc"
end
def sort_value_milestone
- 'milestone'
+ "milestone"
end
def sort_value_milestone_later
- 'milestone_due_desc'
+ "milestone_due_desc"
end
def sort_value_milestone_soon
- 'milestone_due_asc'
+ "milestone_due_asc"
end
def sort_value_name
- 'name_asc'
+ "name_asc"
end
def sort_value_name_desc
- 'name_desc'
+ "name_desc"
end
def sort_value_oldest_activity
- 'latest_activity_asc'
+ "latest_activity_asc"
end
def sort_value_oldest_created
- 'created_asc'
+ "created_asc"
end
def sort_value_oldest_signin
- 'oldest_sign_in'
+ "oldest_sign_in"
end
def sort_value_oldest_joined
- 'oldest_joined'
+ "oldest_joined"
end
def sort_value_oldest_updated
- 'updated_asc'
+ "updated_asc"
end
def sort_value_popularity
- 'popularity'
+ "popularity"
end
def sort_value_priority
- 'priority'
+ "priority"
end
def sort_value_recently_created
- 'created_desc'
+ "created_desc"
end
def sort_value_recently_signin
- 'recent_sign_in'
+ "recent_sign_in"
end
def sort_value_recently_updated
- 'updated_desc'
+ "updated_desc"
end
def sort_value_start_date_later
- 'start_date_desc'
+ "start_date_desc"
end
def sort_value_start_date_soon
- 'start_date_asc'
+ "start_date_asc"
end
def sort_value_upvotes
- 'upvotes_desc'
+ "upvotes_desc"
end
def sort_value_contacted_date
- 'contacted_asc'
+ "contacted_asc"
end
def sort_value_most_stars
- 'stars_desc'
+ "stars_desc"
end
def sort_value_oldest_last_activity
- 'last_activity_on_asc'
+ "last_activity_on_asc"
end
def sort_value_recently_last_activity
- 'last_activity_on_desc'
+ "last_activity_on_desc"
end
end
diff --git a/app/helpers/storage_helper.rb b/app/helpers/storage_helper.rb
index be8761db562..0f8df476299 100644
--- a/app/helpers/storage_helper.rb
+++ b/app/helpers/storage_helper.rb
@@ -4,6 +4,6 @@ module StorageHelper
def storage_counter(size_in_bytes)
precision = size_in_bytes < 1.megabyte ? 0 : 1
- number_to_human_size(size_in_bytes, delimiter: ',', precision: precision, significant: false)
+ number_to_human_size(size_in_bytes, delimiter: ",", precision: precision, significant: false)
end
end
diff --git a/app/helpers/submodule_helper.rb b/app/helpers/submodule_helper.rb
index 164c69ca50b..3251f4e0444 100644
--- a/app/helpers/submodule_helper.rb
+++ b/app/helpers/submodule_helper.rb
@@ -9,35 +9,35 @@ module SubmoduleHelper
def submodule_links(submodule_item, ref = nil, repository = @repository)
url = repository.submodule_url_for(ref, submodule_item.path)
- if url == '.' || url == './'
+ if url == "." || url == "./"
url = File.join(Gitlab.config.gitlab.url, repository.project.full_path)
end
if url =~ %r{([^/:]+)/([^/]+(?:\.git)?)\Z}
namespace, project = $1, $2
gitlab_hosts = [Gitlab.config.gitlab.url,
- Gitlab.config.gitlab_shell.ssh_path_prefix]
+ Gitlab.config.gitlab_shell.ssh_path_prefix,]
gitlab_hosts.each do |host|
if url.start_with?(host)
- namespace, _, project = url.sub(host, '').rpartition('/')
+ namespace, _, project = url.sub(host, "").rpartition("/")
break
end
end
- namespace.sub!(%r{\A/}, '')
+ namespace.sub!(%r{\A/}, "")
project.rstrip!
- project.sub!(/\.git\z/, '')
+ project.sub!(/\.git\z/, "")
if self_url?(url, namespace, project)
[namespace_project_path(namespace, project),
- namespace_project_tree_path(namespace, project, submodule_item.id)]
+ namespace_project_tree_path(namespace, project, submodule_item.id),]
elsif relative_self_url?(url)
relative_self_links(url, submodule_item.id, repository.project)
elsif github_dot_com_url?(url)
- standard_links('github.com', namespace, project, submodule_item.id)
+ standard_links("github.com", namespace, project, submodule_item.id)
elsif gitlab_dot_com_url?(url)
- standard_links('gitlab.com', namespace, project, submodule_item.id)
+ standard_links("gitlab.com", namespace, project, submodule_item.id)
else
[sanitize_submodule_url(url), nil]
end
@@ -57,21 +57,21 @@ module SubmoduleHelper
end
def self_url?(url, namespace, project)
- url_no_dotgit = url.chomp('.git')
- return true if url_no_dotgit == [Gitlab.config.gitlab.url, '/', namespace, '/',
- project].join('')
+ url_no_dotgit = url.chomp(".git")
+ return true if url_no_dotgit == [Gitlab.config.gitlab.url, "/", namespace, "/",
+ project,].join("")
- url_with_dotgit = url_no_dotgit + '.git'
- url_with_dotgit == Gitlab::Shell.new.url_to_repo([namespace, '/', project].join(''))
+ url_with_dotgit = url_no_dotgit + ".git"
+ url_with_dotgit == Gitlab::Shell.new.url_to_repo([namespace, "/", project].join(""))
end
def relative_self_url?(url)
- url.start_with?('../', './')
+ url.start_with?("../", "./")
end
def standard_links(host, namespace, project, commit)
- base = ['https://', host, '/', namespace, '/', project].join('')
- [base, [base, '/tree/', commit].join('')]
+ base = ["https://", host, "/", namespace, "/", project].join("")
+ [base, [base, "/tree/", commit].join("")]
end
def relative_self_links(relative_path, commit, project)
@@ -86,17 +86,17 @@ module SubmoduleHelper
submodule_project_path = File.absolute_path(relative_path, absolute_project_path)
target_namespace_path = File.dirname(submodule_project_path)
- if target_namespace_path == '/' || target_namespace_path.start_with?(absolute_project_path)
+ if target_namespace_path == "/" || target_namespace_path.start_with?(absolute_project_path)
return [nil, nil]
end
- target_namespace_path.sub!(%r{^/}, '')
- submodule_base = File.basename(submodule_project_path, '.git')
+ target_namespace_path.sub!(%r{^/}, "")
+ submodule_base = File.basename(submodule_project_path, ".git")
begin
[
namespace_project_path(target_namespace_path, submodule_base),
- namespace_project_tree_path(target_namespace_path, submodule_base, commit)
+ namespace_project_tree_path(target_namespace_path, submodule_base, commit),
]
rescue ActionController::UrlGenerationError
[nil, nil]
@@ -108,8 +108,6 @@ module SubmoduleHelper
if uri.scheme.in?(VALID_SUBMODULE_PROTOCOLS)
uri.to_s
- else
- nil
end
rescue URI::InvalidURIError
nil
diff --git a/app/helpers/system_note_helper.rb b/app/helpers/system_note_helper.rb
index ac4e8f54260..d886712b522 100644
--- a/app/helpers/system_note_helper.rb
+++ b/app/helpers/system_note_helper.rb
@@ -2,29 +2,29 @@
module SystemNoteHelper
ICON_NAMES_BY_ACTION = {
- 'commit' => 'commit',
- 'description' => 'pencil-square',
- 'merge' => 'git-merge',
- 'merged' => 'git-merge',
- 'opened' => 'issue-open',
- 'closed' => 'issue-close',
- 'time_tracking' => 'timer',
- 'assignee' => 'user',
- 'title' => 'pencil-square',
- 'task' => 'task-done',
- 'label' => 'label',
- 'cross_reference' => 'comment-dots',
- 'branch' => 'fork',
- 'confidential' => 'eye-slash',
- 'visible' => 'eye',
- 'milestone' => 'clock',
- 'discussion' => 'comment',
- 'moved' => 'arrow-right',
- 'outdated' => 'pencil-square',
- 'duplicate' => 'issue-duplicate',
- 'locked' => 'lock',
- 'unlocked' => 'lock-open',
- 'due_date' => 'calendar'
+ "commit" => "commit",
+ "description" => "pencil-square",
+ "merge" => "git-merge",
+ "merged" => "git-merge",
+ "opened" => "issue-open",
+ "closed" => "issue-close",
+ "time_tracking" => "timer",
+ "assignee" => "user",
+ "title" => "pencil-square",
+ "task" => "task-done",
+ "label" => "label",
+ "cross_reference" => "comment-dots",
+ "branch" => "fork",
+ "confidential" => "eye-slash",
+ "visible" => "eye",
+ "milestone" => "clock",
+ "discussion" => "comment",
+ "moved" => "arrow-right",
+ "outdated" => "pencil-square",
+ "duplicate" => "issue-duplicate",
+ "locked" => "lock",
+ "unlocked" => "lock-open",
+ "due_date" => "calendar",
}.freeze
def system_note_icon_name(note)
diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb
index d91f0f78db7..c1d823cb151 100644
--- a/app/helpers/tab_helper.rb
+++ b/app/helpers/tab_helper.rb
@@ -58,12 +58,12 @@ module TabHelper
#
# Returns a list item element String
def nav_link(options = {}, &block)
- klass = active_nav_link?(options) ? 'active' : ''
+ klass = active_nav_link?(options) ? "active" : ""
# Add our custom class into the html_options, which may or may not exist
# and which may or may not already have a :class key
o = options.delete(:html_options) || {}
- o[:class] = [*o[:class], klass].join(' ').strip
+ o[:class] = [*o[:class], klass].join(" ").strip
if block_given?
content_tag(:li, capture(&block), o)
@@ -104,16 +104,16 @@ module TabHelper
end
def current_path?(path)
- c, a, _ = path.split('#')
+ c, a, _ = path.split("#")
current_controller?(c) && current_action?(a)
end
def project_tab_class
- if controller.controller_path.start_with?('projects')
- return 'active'
+ if controller.controller_path.start_with?("projects")
+ return "active"
end
- if %w(services hooks deploy_keys protected_branches).include? controller.controller_name
+ if %w[services hooks deploy_keys protected_branches].include? controller.controller_name
"active"
end
end
@@ -122,15 +122,15 @@ module TabHelper
if current_controller?(:protected_branches) ||
current_controller?(:branches) ||
current_page?(project_repository_path(@project))
- 'active'
+ "active"
end
end
def profile_tab_class
- if controller.controller_path.start_with?('profiles')
- return 'active'
+ if controller.controller_path.start_with?("profiles")
+ return "active"
end
- 'active' if current_controller?('oauth/applications')
+ "active" if current_controller?("oauth/applications")
end
end
diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb
index de0b92b6fd7..e065f152a7f 100644
--- a/app/helpers/tags_helper.rb
+++ b/app/helpers/tags_helper.rb
@@ -8,7 +8,7 @@ module TagsHelper
def filter_tags_path(options = {})
exist_opts = {
search: params[:search],
- sort: params[:sort]
+ sort: params[:sort],
}
options = exist_opts.merge(options)
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index 6bd78336ed3..39178b77ac6 100644
--- a/app/helpers/todos_helper.rb
+++ b/app/helpers/todos_helper.rb
@@ -6,7 +6,7 @@ module TodosHelper
end
def todos_count_format(count)
- count > 99 ? '99+' : count.to_s
+ count > 99 ? "99+" : count.to_s
end
def todos_done_count
@@ -15,12 +15,12 @@ module TodosHelper
def todo_action_name(todo)
case todo.action
- when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you'
+ when Todo::ASSIGNED then todo.self_added? ? "assigned" : "assigned you"
when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on"
- when Todo::BUILD_FAILED then 'The build failed for'
- when Todo::MARKED then 'added a todo for'
+ when Todo::BUILD_FAILED then "The build failed for"
+ when Todo::MARKED then "added a todo for"
when Todo::APPROVAL_REQUIRED then "set #{todo_action_subject(todo)} as an approver for"
- when Todo::UNMERGEABLE then 'Could not merge'
+ when Todo::UNMERGEABLE then "Could not merge"
when Todo::DIRECTLY_ADDRESSED then "directly addressed #{todo_action_subject(todo)} on"
end
end
@@ -28,12 +28,12 @@ module TodosHelper
def todo_target_link(todo)
text = raw("#{todo.target_type.titleize.downcase} ") +
if todo.for_commit?
- content_tag(:span, todo.target_reference, class: 'commit-sha')
+ content_tag(:span, todo.target_reference, class: "commit-sha")
else
todo.target_reference
end
- link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title
+ link_to text, todo_target_path(todo), class: "has-tooltip", title: todo.target.title
end
def todo_target_path(todo)
@@ -43,7 +43,7 @@ module TodosHelper
if todo.for_commit?
project_commit_path(todo.project,
- todo.target, anchor: anchor)
+ todo.target, anchor: anchor)
else
path = [todo.parent, todo.target]
@@ -59,12 +59,12 @@ module TodosHelper
type =
case todo.target
when MergeRequest
- 'mr'
+ "mr"
when Issue
- 'issue'
+ "issue"
end
- content_tag(:span, nil, class: 'target-status') do
+ content_tag(:span, nil, class: "target-status") do
content_tag(:span, nil, class: "status-box status-box-#{type}-#{todo.target.state.dasherize}") do
todo.target.state.capitalize
end
@@ -73,11 +73,11 @@ module TodosHelper
def todos_filter_params
{
- state: params[:state],
+ state: params[:state],
project_id: params[:project_id],
- author_id: params[:author_id],
- type: params[:type],
- action_id: params[:action_id]
+ author_id: params[:author_id],
+ type: params[:type],
+ action_id: params[:action_id],
}
end
@@ -101,30 +101,30 @@ module TodosHelper
def todo_actions_options
[
- { id: '', text: 'Any Action' },
- { id: Todo::ASSIGNED, text: 'Assigned' },
- { id: Todo::MENTIONED, text: 'Mentioned' },
- { id: Todo::MARKED, text: 'Added' },
- { id: Todo::BUILD_FAILED, text: 'Pipelines' },
- { id: Todo::DIRECTLY_ADDRESSED, text: 'Directly addressed' }
+ {id: "", text: "Any Action"},
+ {id: Todo::ASSIGNED, text: "Assigned"},
+ {id: Todo::MENTIONED, text: "Mentioned"},
+ {id: Todo::MARKED, text: "Added"},
+ {id: Todo::BUILD_FAILED, text: "Pipelines"},
+ {id: Todo::DIRECTLY_ADDRESSED, text: "Directly addressed"},
]
end
def todo_projects_options
projects = current_user.authorized_projects.sorted_by_activity.non_archived.with_route
- projects = projects.map do |project|
- { id: project.id, text: project.full_name }
- end
+ projects = projects.map { |project|
+ {id: project.id, text: project.full_name}
+ }
- projects.unshift({ id: '', text: 'Any Project' }).to_json
+ projects.unshift({id: "", text: "Any Project"}).to_json
end
def todo_types_options
[
- { id: '', text: 'Any Type' },
- { id: 'Issue', text: 'Issue' },
- { id: 'MergeRequest', text: 'Merge Request' }
+ {id: "", text: "Any Type"},
+ {id: "Issue", text: "Issue"},
+ {id: "MergeRequest", text: "Merge Request"},
]
end
@@ -134,7 +134,7 @@ module TodosHelper
end
def todo_types_dropdown_label(selected_type, default_type)
- selected_type = todo_types_options.find { |type| type[:id] == selected_type && type[:id] != '' }
+ selected_type = todo_types_options.find { |type| type[:id] == selected_type && type[:id] != "" }
selected_type ? selected_type[:text] : default_type
end
@@ -145,16 +145,16 @@ module TodosHelper
is_overdue = todo.target.overdue?
css_class =
if is_due_today
- 'text-warning'
+ "text-warning"
elsif is_overdue
- 'text-danger'
+ "text-danger"
else
- ''
+ ""
end
- content = content_tag(:span, class: css_class) do
+ content = content_tag(:span, class: css_class) {
"Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}"
- end
+ }
"&middot; #{content}".html_safe
end
@@ -162,18 +162,18 @@ module TodosHelper
private
def todo_action_subject(todo)
- todo.self_added? ? 'yourself' : 'you'
+ todo.self_added? ? "yourself" : "you"
end
def show_todo_state?(todo)
- (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state)
+ (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w[closed merged].include?(todo.target.state)
end
def todo_group_options
- groups = current_user.authorized_groups.map do |group|
- { id: group.id, text: group.full_name }
- end
+ groups = current_user.authorized_groups.map { |group|
+ {id: group.id, text: group.full_name}
+ }
- groups.unshift({ id: '', text: 'Any Group' }).to_json
+ groups.unshift({id: "", text: "Any Group"}).to_json
end
end
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index e2879bfdcf1..8eed6664e38 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -15,12 +15,12 @@ module TreeHelper
items = (folders + submodules).sort_by(&:name) + files
if items.size > FILE_LIMIT
- tree << render(partial: 'projects/tree/truncated_notice_tree_row',
- locals: { limit: FILE_LIMIT, total: items.size })
+ tree << render(partial: "projects/tree/truncated_notice_tree_row",
+ locals: {limit: FILE_LIMIT, total: items.size})
items = items.take(FILE_LIMIT)
end
- tree << render(partial: 'projects/tree/tree_row', collection: items) if items.present?
+ tree << render(partial: "projects/tree/tree_row", collection: items) if items.present?
tree.join.html_safe
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -31,20 +31,20 @@ module TreeHelper
# mode - File unix mode
# name - File name
def tree_icon(type, mode, name)
- icon([file_type_icon_class(type, mode, name), 'fw'])
+ icon([file_type_icon_class(type, mode, name), "fw"])
end
# Using Rails `*_path` methods can be slow, especially when generating
# many paths, as with a repository tree that has thousands of items.
def fast_project_blob_path(project, blob_path)
ActionDispatch::Journey::Router::Utils.escape_path(
- File.join(relative_url_root, project.path_with_namespace, 'blob', blob_path)
+ File.join(relative_url_root, project.path_with_namespace, "blob", blob_path)
)
end
def fast_project_tree_path(project, tree_path)
ActionDispatch::Journey::Router::Utils.escape_path(
- File.join(relative_url_root, project.path_with_namespace, 'tree', tree_path)
+ File.join(relative_url_root, project.path_with_namespace, "tree", tree_path)
)
end
@@ -73,14 +73,14 @@ module TreeHelper
ref
else
project = tree_edit_project(project)
- project.repository.next_branch('patch')
+ project.repository.next_branch("patch")
end
end
def tree_edit_project(project = @project)
if can?(current_user, :push_code, project)
project
- elsif current_user && current_user.already_forked?(project)
+ elsif current_user&.already_forked?(project)
current_user.fork_of(project)
end
end
@@ -107,7 +107,7 @@ module TreeHelper
branch_name = ERB::Util.html_escape(selected_branch)
message = _("Your changes can be committed to %{branch_name} because a merge "\
- "request is open.") % { branch_name: "<strong>#{branch_name}</strong>" }
+ "request is open.") % {branch_name: "<strong>#{branch_name}</strong>"}
message.html_safe
end
@@ -115,9 +115,9 @@ module TreeHelper
def path_breadcrumbs(max_links = 6)
if @path.present?
part_path = ""
- parts = @path.split('/')
+ parts = @path.split("/")
- yield('..', File.join(*parts.first(parts.count - 2))) if parts.count > max_links
+ yield("..", File.join(*parts.first(parts.count - 2))) if parts.count > max_links
parts.each do |part|
part_path = File.join(part_path, part) unless part_path.empty?
@@ -138,7 +138,7 @@ module TreeHelper
# returns the relative path of the first subdir that doesn't have only one directory descendant
# rubocop: disable CodeReuse/ActiveRecord
def flatten_tree(root_path, tree)
- return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, '') if tree.flat_path.present?
+ return tree.flat_path.sub(%r{\A#{Regexp.escape(root_path)}/}, "") if tree.flat_path.present?
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
@@ -154,6 +154,6 @@ module TreeHelper
end
def relative_url_root
- Gitlab.config.gitlab.relative_url_root.presence || '/'
+ Gitlab.config.gitlab.relative_url_root.presence || "/"
end
end
diff --git a/app/helpers/user_callouts_helper.rb b/app/helpers/user_callouts_helper.rb
index 1ad7bb81784..667ad4ba825 100644
--- a/app/helpers/user_callouts_helper.rb
+++ b/app/helpers/user_callouts_helper.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module UserCalloutsHelper
- GKE_CLUSTER_INTEGRATION = 'gke_cluster_integration'.freeze
- GCP_SIGNUP_OFFER = 'gcp_signup_offer'.freeze
+ GKE_CLUSTER_INTEGRATION = "gke_cluster_integration"
+ GCP_SIGNUP_OFFER = "gcp_signup_offer"
def show_gke_cluster_integration_callout?(project)
can?(current_user, :create_cluster, project) &&
@@ -14,7 +14,7 @@ module UserCalloutsHelper
end
def render_flash_user_callout(flash_type, message, feature_name)
- render 'shared/flash_user_callout', flash_type: flash_type, message: message, feature_name: feature_name
+ render "shared/flash_user_callout", flash_type: flash_type, message: message, feature_name: feature_name
end
private
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 73ca17c6605..79ecc45bb2e 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -3,17 +3,17 @@
module UsersHelper
def user_link(user)
link_to(user.name, user_path(user),
- title: user.email,
- class: 'has-tooltip commit-committer-link')
+ title: user.email,
+ class: "has-tooltip commit-committer-link")
end
def user_email_help_text(user)
- return 'We also use email for avatar detection if no avatar is uploaded' unless user.unconfirmed_email.present?
+ return "We also use email for avatar detection if no avatar is uploaded" unless user.unconfirmed_email.present?
- confirmation_link = link_to 'Resend confirmation e-mail', user_confirmation_path(user: { email: @user.unconfirmed_email }), method: :post
+ confirmation_link = link_to "Resend confirmation e-mail", user_confirmation_path(user: {email: @user.unconfirmed_email}), method: :post
- h('Please click the link in the confirmation email before continuing. It was sent to ') +
- content_tag(:strong) { user.unconfirmed_email } + h('.') +
+ h("Please click the link in the confirmation email before continuing. It was sent to ") +
+ content_tag(:strong) { user.unconfirmed_email } + h(".") +
content_tag(:p) { confirmation_link }
end
@@ -29,11 +29,11 @@ module UsersHelper
settings = Gitlab::CurrentSettings.current_application_settings
pattern, options = if settings.user_default_internal_regex_enabled?
- regex = settings.user_default_internal_regex_instance
- JsRegex.new(regex).to_h.slice(:source, :options).values
- end
+ regex = settings.user_default_internal_regex_instance
+ JsRegex.new(regex).to_h.slice(:source, :options).values
+ end
- { user_internal_regex_pattern: pattern, user_internal_regex_options: options }
+ {user_internal_regex_pattern: pattern, user_internal_regex_options: options}
end
def current_user_menu_items
@@ -57,15 +57,15 @@ module UsersHelper
unless user.association(:status).loaded?
exception = RuntimeError.new("Status was not preloaded")
- Gitlab::Sentry.track_exception(exception, extra: { user: user.inspect })
+ Gitlab::Sentry.track_exception(exception, extra: {user: user.inspect})
end
return unless user.status
content_tag :span,
- class: 'user-status-emoji has-tooltip',
- title: user.status.message_html,
- data: { html: true, placement: 'top' } do
+ class: "user-status-emoji has-tooltip",
+ title: user.status.message_html,
+ data: {html: true, placement: "top"} do
emoji_icon user.status.emoji
end
end
@@ -76,10 +76,10 @@ module UsersHelper
def user_badges_in_admin_section(user)
[].tap do |badges|
- badges << { text: s_('AdminUsers|Blocked'), variant: 'danger' } if user.blocked?
- badges << { text: s_('AdminUsers|Admin'), variant: 'success' } if user.admin?
- badges << { text: s_('AdminUsers|External'), variant: 'secondary' } if user.external?
- badges << { text: s_("AdminUsers|It's you!"), variant: nil } if current_user == user
+ badges << {text: s_("AdminUsers|Blocked"), variant: "danger"} if user.blocked?
+ badges << {text: s_("AdminUsers|Admin"), variant: "success"} if user.admin?
+ badges << {text: s_("AdminUsers|External"), variant: "secondary"} if user.external?
+ badges << {text: s_("AdminUsers|It's you!"), variant: nil} if current_user == user
end
end
diff --git a/app/helpers/version_check_helper.rb b/app/helpers/version_check_helper.rb
index 5e519cf5c19..a947dfa2c7d 100644
--- a/app/helpers/version_check_helper.rb
+++ b/app/helpers/version_check_helper.rb
@@ -6,19 +6,19 @@ module VersionCheckHelper
return unless Gitlab::CurrentSettings.version_check_enabled
return if User.single_user&.requires_usage_stats_consent?
- image_tag VersionCheck.url, class: 'js-version-status-badge'
+ image_tag VersionCheck.url, class: "js-version-status-badge"
end
def link_to_version
if Gitlab.pre_release?
- commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path('gitlab-org', source_code_project, Gitlab.revision))
- [Gitlab::VERSION, content_tag(:small, commit_link)].join(' ').html_safe
+ commit_link = link_to(Gitlab.revision, Gitlab::COM_URL + namespace_project_commits_path("gitlab-org", source_code_project, Gitlab.revision))
+ [Gitlab::VERSION, content_tag(:small, commit_link)].join(" ").html_safe
else
- link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path('gitlab-org', source_code_project, "v#{Gitlab::VERSION}")
+ link_to Gitlab::VERSION, Gitlab::COM_URL + namespace_project_tag_path("gitlab-org", source_code_project, "v#{Gitlab::VERSION}")
end
end
def source_code_project
- 'gitlab-ce'
+ "gitlab-ce"
end
end
diff --git a/app/helpers/visibility_level_helper.rb b/app/helpers/visibility_level_helper.rb
index 712f0f808dd..0a00beca8d5 100644
--- a/app/helpers/visibility_level_helper.rb
+++ b/app/helpers/visibility_level_helper.rb
@@ -4,11 +4,11 @@ module VisibilityLevelHelper
def visibility_level_color(level)
case level
when Gitlab::VisibilityLevel::PRIVATE
- 'vs-private'
+ "vs-private"
when Gitlab::VisibilityLevel::INTERNAL
- 'vs-internal'
+ "vs-internal"
when Gitlab::VisibilityLevel::PUBLIC
- 'vs-public'
+ "vs-public"
end
end
@@ -97,7 +97,7 @@ module VisibilityLevelHelper
instructions << errors[:instruction]
end
- reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
+ reasons = reasons.any? ? " because " + reasons.to_sentence : ""
"This project cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe
end
@@ -123,7 +123,7 @@ module VisibilityLevelHelper
instructions << errors[:instruction]
end
- reasons = reasons.any? ? ' because ' + reasons.to_sentence : ''
+ reasons = reasons.any? ? " because " + reasons.to_sentence : ""
"This group cannot be #{level_name}#{reasons}.#{instructions.join}".html_safe
end
@@ -155,9 +155,9 @@ module VisibilityLevelHelper
Gitlab::CurrentSettings.restricted_visibility_levels || []
end
- delegate :default_project_visibility,
- :default_group_visibility,
- to: :'Gitlab::CurrentSettings.current_application_settings'
+ delegate :default_project_visibility,
+ :default_group_visibility,
+ to: :'Gitlab::CurrentSettings.current_application_settings'
def disallowed_visibility_level?(form_model, level)
return false unless form_model.respond_to?(:visibility_level_allowed?)
@@ -169,9 +169,9 @@ module VisibilityLevelHelper
def visibility_level_errors_for_group(group, level_name)
group_name = link_to group.name, group_path(group)
- change_visiblity = link_to 'change the visibility', edit_group_path(group)
+ change_visiblity = link_to "change the visibility", edit_group_path(group)
- { reason: "the visibility of #{group_name} is #{group.visibility}",
- instruction: " To make this group #{level_name}, you must first #{change_visiblity} of the parent group." }
+ {reason: "the visibility of #{group_name} is #{group.visibility}",
+ instruction: " To make this group #{level_name}, you must first #{change_visiblity} of the parent group.",}
end
end
diff --git a/app/helpers/webpack_helper.rb b/app/helpers/webpack_helper.rb
index 345ddcf023a..7f6a3f775cd 100644
--- a/app/helpers/webpack_helper.rb
+++ b/app/helpers/webpack_helper.rb
@@ -9,17 +9,17 @@ module WebpackHelper
chunks = []
action = case controller.action_name
- when 'create' then 'new'
- when 'update' then 'edit'
+ when "create" then "new"
+ when "update" then "edit"
else controller.action_name
- end
+ end
- route = [*controller.controller_path.split('/'), action].compact
+ route = [*controller.controller_path.split("/"), action].compact
until chunks.any? || route.empty?
- entrypoint = "pages.#{route.join('.')}"
+ entrypoint = "pages.#{route.join(".")}"
begin
- chunks = webpack_entrypoint_paths(entrypoint, extension: 'js')
+ chunks = webpack_entrypoint_paths(entrypoint, extension: "js")
rescue Gitlab::Webpack::Manifest::AssetMissingError
# no bundle exists for this path
end
@@ -27,7 +27,7 @@ module WebpackHelper
end
if chunks.empty?
- chunks = webpack_entrypoint_paths("default", extension: 'js')
+ chunks = webpack_entrypoint_paths("default", extension: "js")
end
javascript_include_tag(*chunks)
@@ -60,16 +60,16 @@ module WebpackHelper
if Rails.env.test? && Rails.configuration.webpack.dev_server.enabled
host = Rails.configuration.webpack.dev_server.host
port = Rails.configuration.webpack.dev_server.port
- protocol = Rails.configuration.webpack.dev_server.https ? 'https' : 'http'
+ protocol = Rails.configuration.webpack.dev_server.https ? "https" : "http"
"#{protocol}://#{host}:#{port}"
else
- ActionController::Base.asset_host.try(:chomp, '/')
+ ActionController::Base.asset_host.try(:chomp, "/")
end
end
def webpack_public_path
relative_path = Rails.application.config.relative_url_root
webpack_path = Rails.application.config.webpack.public_path
- File.join(webpack_public_host.to_s, relative_path.to_s, webpack_path.to_s, '')
+ File.join(webpack_public_host.to_s, relative_path.to_s, webpack_path.to_s, "")
end
end
diff --git a/app/helpers/wiki_helper.rb b/app/helpers/wiki_helper.rb
index 647f34e57ed..9f346f1c818 100644
--- a/app/helpers/wiki_helper.rb
+++ b/app/helpers/wiki_helper.rb
@@ -10,13 +10,13 @@ module WikiHelper
# Returns a String composed of the capitalized name of each directory and the
# capitalized name of the page itself.
def breadcrumb(page_slug)
- page_slug.split('/')
+ page_slug.split("/")
.map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }
- .join(' / ')
+ .join(" / ")
end
def wiki_breadcrumb_dropdown_links(page_slug)
- page_slug_split = page_slug.split('/')
+ page_slug_split = page_slug.split("/")
page_slug_split.pop(1)
current_slug = ""
page_slug_split
@@ -29,12 +29,12 @@ module WikiHelper
def wiki_page_errors(error)
return unless error
- content_tag(:div, class: 'alert alert-danger') do
+ content_tag(:div, class: "alert alert-danger") do
case error
when WikiPage::PageChangedError
page_link = link_to s_("WikiPageConflictMessage|the page"), project_wiki_path(@project, @page), target: "_blank"
concat(
- (s_("WikiPageConflictMessage|Someone edited the page the same time you did. Please check out %{page_link} and make sure your changes will not unintentionally remove theirs.") % { page_link: page_link }).html_safe
+ (s_("WikiPageConflictMessage|Someone edited the page the same time you did. Please check out %{page_link} and make sure your changes will not unintentionally remove theirs.") % {page_link: page_link}).html_safe
)
when WikiPage::PageRenameError
s_("WikiEdit|There is already a page with the same title in that path.")
diff --git a/app/helpers/workhorse_helper.rb b/app/helpers/workhorse_helper.rb
index bb5b1555dc4..6259946168f 100644
--- a/app/helpers/workhorse_helper.rb
+++ b/app/helpers/workhorse_helper.rb
@@ -7,7 +7,7 @@ module WorkhorseHelper
def send_git_blob(repository, blob, inline: true)
headers.store(*Gitlab::Workhorse.send_git_blob(repository, blob))
- headers['Content-Disposition'] = inline ? 'inline' : 'attachment'
+ headers["Content-Disposition"] = inline ? "inline" : "attachment"
# If enabled, this will override the values set above
workhorse_set_content_type!
@@ -18,14 +18,14 @@ module WorkhorseHelper
# Send a Git diff through Workhorse
def send_git_diff(repository, diff_refs)
headers.store(*Gitlab::Workhorse.send_git_diff(repository, diff_refs))
- headers['Content-Disposition'] = 'inline'
+ headers["Content-Disposition"] = "inline"
head :ok
end
# Send a Git patch through Workhorse
def send_git_patch(repository, diff_refs)
headers.store(*Gitlab::Workhorse.send_git_patch(repository, diff_refs))
- headers['Content-Disposition'] = 'inline'
+ headers["Content-Disposition"] = "inline"
head :ok
end
@@ -42,7 +42,7 @@ module WorkhorseHelper
end
def set_workhorse_internal_api_content_type
- headers['Content-Type'] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
+ headers["Content-Type"] = Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE
end
def workhorse_set_content_type!
diff --git a/app/mailers/abuse_report_mailer.rb b/app/mailers/abuse_report_mailer.rb
index e0aa66e6de3..41aa27ed8de 100644
--- a/app/mailers/abuse_report_mailer.rb
+++ b/app/mailers/abuse_report_mailer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class AbuseReportMailer < BaseMailer
- layout 'empty_mailer'
+ layout "empty_mailer"
helper EmailsHelper
@@ -11,8 +11,8 @@ class AbuseReportMailer < BaseMailer
@abuse_report = AbuseReport.find(abuse_report_id)
mail(
- to: Gitlab::CurrentSettings.admin_notification_email,
- subject: "#{@abuse_report.user.name} (#{@abuse_report.user.username}) was reported for abuse"
+ to: Gitlab::CurrentSettings.admin_notification_email,
+ subject: "#{@abuse_report.user.name} (#{@abuse_report.user.username}) was reported for abuse"
)
end
diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb
index 7aa75ee30e6..f018364a1a9 100644
--- a/app/mailers/devise_mailer.rb
+++ b/app/mailers/devise_mailer.rb
@@ -4,7 +4,7 @@ class DeviseMailer < Devise::Mailer
default from: "#{Gitlab.config.gitlab.email_display_name} <#{Gitlab.config.gitlab.email_from}>"
default reply_to: Gitlab.config.gitlab.email_reply_to
- layout 'mailer/devise'
+ layout "mailer/devise"
helper EmailsHelper
@@ -14,6 +14,6 @@ class DeviseMailer < Devise::Mailer
subject = [super]
subject << Gitlab.config.gitlab.email_subject_suffix if Gitlab.config.gitlab.email_subject_suffix.present?
- subject.join(' | ')
+ subject.join(" | ")
end
end
diff --git a/app/mailers/email_rejection_mailer.rb b/app/mailers/email_rejection_mailer.rb
index d743533b1bc..781517c360f 100644
--- a/app/mailers/email_rejection_mailer.rb
+++ b/app/mailers/email_rejection_mailer.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class EmailRejectionMailer < BaseMailer
- layout 'empty_mailer'
+ layout "empty_mailer"
helper EmailsHelper
@@ -13,14 +13,14 @@ class EmailRejectionMailer < BaseMailer
headers = {
to: @original_message.from,
- subject: "[Rejected] #{@original_message.subject}"
+ subject: "[Rejected] #{@original_message.subject}",
}
- headers['Message-ID'] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>"
- headers['In-Reply-To'] = @original_message.message_id
- headers['References'] = @original_message.message_id
+ headers["Message-ID"] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>"
+ headers["In-Reply-To"] = @original_message.message_id
+ headers["References"] = @original_message.message_id
- headers['Reply-To'] = @original_message.to.first if can_retry
+ headers["Reply-To"] = @original_message.to.first if can_retry
mail(headers)
end
diff --git a/app/mailers/emails/auto_devops.rb b/app/mailers/emails/auto_devops.rb
index 9705a3052d4..7cd33cd9dcc 100644
--- a/app/mailers/emails/auto_devops.rb
+++ b/app/mailers/emails/auto_devops.rb
@@ -10,8 +10,8 @@ module Emails
mail(to: recipient,
subject: auto_devops_disabled_subject(@project.name)) do |format|
- format.html { render layout: 'mailer' }
- format.text { render layout: 'mailer' }
+ format.html { render layout: "mailer" }
+ format.text { render layout: "mailer" }
end
end
diff --git a/app/mailers/emails/issues.rb b/app/mailers/emails/issues.rb
index 654ae211310..0f91449ba50 100644
--- a/app/mailers/emails/issues.rb
+++ b/app/mailers/emails/issues.rb
@@ -57,7 +57,7 @@ module Emails
@milestone = milestone
@milestone_url = milestone_url(@milestone)
mail_answer_thread(@issue, issue_thread_options(updated_by_user_id, recipient_id, reason).merge({
- template_name: 'changed_milestone_email'
+ template_name: "changed_milestone_email",
}))
end
@@ -82,9 +82,9 @@ module Emails
@project = Project.find(project_id)
@results = results
- mail(to: @user.notification_email, subject: subject('Imported issues')) do |format|
- format.html { render layout: 'mailer' }
- format.text { render layout: 'mailer' }
+ mail(to: @user.notification_email, subject: subject("Imported issues")) do |format|
+ format.html { render layout: "mailer" }
+ format.text { render layout: "mailer" }
end
end
@@ -100,10 +100,10 @@ module Emails
def issue_thread_options(sender_id, recipient_id, reason)
{
- from: sender(sender_id),
- to: recipient(recipient_id),
- subject: subject("#{@issue.title} (##{@issue.iid})"),
- 'X-GitLab-NotificationReason' => reason
+ :from => sender(sender_id),
+ :to => recipient(recipient_id),
+ :subject => subject("#{@issue.title} (##{@issue.iid})"),
+ "X-GitLab-NotificationReason" => reason,
}
end
end
diff --git a/app/mailers/emails/members.rb b/app/mailers/emails/members.rb
index 91dfdf58982..e77a9b01961 100644
--- a/app/mailers/emails/members.rb
+++ b/app/mailers/emails/members.rb
@@ -49,7 +49,7 @@ module Emails
return unless member.created_by
mail(to: member.created_by.notification_email,
- subject: subject('Invitation accepted'))
+ subject: subject("Invitation accepted"))
end
def member_invite_declined_email(member_source_type, source_id, invite_email, created_by_id)
@@ -61,7 +61,7 @@ module Emails
inviter = User.find(created_by_id)
mail(to: inviter.notification_email,
- subject: subject('Invitation declined'))
+ subject: subject("Invitation declined"))
end
def member
diff --git a/app/mailers/emails/merge_requests.rb b/app/mailers/emails/merge_requests.rb
index 9ba8f92fcbf..e7568c8d319 100644
--- a/app/mailers/emails/merge_requests.rb
+++ b/app/mailers/emails/merge_requests.rb
@@ -52,7 +52,7 @@ module Emails
@milestone = milestone
@milestone_url = milestone_url(@milestone)
mail_answer_thread(@merge_request, merge_request_thread_options(updated_by_user_id, recipient_id, reason).merge({
- template_name: 'changed_milestone_email'
+ template_name: "changed_milestone_email",
}))
end
@@ -107,10 +107,10 @@ module Emails
def merge_request_thread_options(sender_id, recipient_id, reason = nil)
{
- from: sender(sender_id),
- to: recipient(recipient_id),
- subject: subject("#{@merge_request.title} (#{@merge_request.to_reference})"),
- 'X-GitLab-NotificationReason' => reason
+ :from => sender(sender_id),
+ :to => recipient(recipient_id),
+ :subject => subject("#{@merge_request.title} (#{@merge_request.to_reference})"),
+ "X-GitLab-NotificationReason" => reason,
}
end
end
diff --git a/app/mailers/emails/notes.rb b/app/mailers/emails/notes.rb
index 1b3c1f9a8a9..342fa2755aa 100644
--- a/app/mailers/emails/notes.rb
+++ b/app/mailers/emails/notes.rb
@@ -52,7 +52,7 @@ module Emails
{
from: sender(@note.author_id),
to: recipient(recipient_id),
- subject: subject("#{@note.noteable.title} (#{@note.noteable.reference_link_text})")
+ subject: subject("#{@note.noteable.title} (#{@note.noteable.reference_link_text})"),
}
end
diff --git a/app/mailers/emails/pipelines.rb b/app/mailers/emails/pipelines.rb
index 31e183640ad..9f0315d9bd4 100644
--- a/app/mailers/emails/pipelines.rb
+++ b/app/mailers/emails/pipelines.rb
@@ -3,11 +3,11 @@
module Emails
module Pipelines
def pipeline_success_email(pipeline, recipients)
- pipeline_mail(pipeline, recipients, 'succeeded')
+ pipeline_mail(pipeline, recipients, "succeeded")
end
def pipeline_failed_email(pipeline, recipients)
- pipeline_mail(pipeline, recipients, 'failed')
+ pipeline_mail(pipeline, recipients, "failed")
end
private
@@ -24,8 +24,8 @@ module Emails
mail(bcc: recipients,
subject: pipeline_subject(status),
skip_premailer: true) do |format|
- format.html { render layout: 'mailer' }
- format.text { render layout: 'mailer' }
+ format.html { render layout: "mailer" }
+ format.text { render layout: "mailer" }
end
end
@@ -35,16 +35,16 @@ module Emails
end
def add_pipeline_headers
- headers['X-GitLab-Pipeline-Id'] = @pipeline.id
- headers['X-GitLab-Pipeline-Ref'] = @pipeline.ref
- headers['X-GitLab-Pipeline-Status'] = @pipeline.status
+ headers["X-GitLab-Pipeline-Id"] = @pipeline.id
+ headers["X-GitLab-Pipeline-Ref"] = @pipeline.ref
+ headers["X-GitLab-Pipeline-Status"] = @pipeline.status
end
def pipeline_subject(status)
commit = [@pipeline.short_sha]
commit << "in #{@merge_request.to_reference}" if @merge_request
- subject("Pipeline ##{@pipeline.id} has #{status} for #{@pipeline.ref}", commit.join(' '))
+ subject("Pipeline ##{@pipeline.id} has #{status} for #{@pipeline.ref}", commit.join(" "))
end
end
end
diff --git a/app/mailers/emails/projects.rb b/app/mailers/emails/projects.rb
index 2500622caa7..15f58f810c0 100644
--- a/app/mailers/emails/projects.rb
+++ b/app/mailers/emails/projects.rb
@@ -49,11 +49,11 @@ module Emails
@diff_notes_disabled = true
add_project_headers
- headers['X-GitLab-Author'] = @message.author_username
+ headers["X-GitLab-Author"] = @message.author_username
- mail(from: sender(@message.author_id, @message.send_from_committer_email?),
- reply_to: @message.reply_to,
- subject: @message.subject)
+ mail(from: sender(@message.author_id, @message.send_from_committer_email?),
+ reply_to: @message.reply_to,
+ subject: @message.subject)
end
end
end
diff --git a/app/mailers/emails/remote_mirrors.rb b/app/mailers/emails/remote_mirrors.rb
index 2018eb7260b..4396ea82c13 100644
--- a/app/mailers/emails/remote_mirrors.rb
+++ b/app/mailers/emails/remote_mirrors.rb
@@ -6,7 +6,7 @@ module Emails
@remote_mirror = RemoteMirrorFinder.new(id: remote_mirror_id).execute
@project = @remote_mirror.project
- mail(to: recipient(recipient_id), subject: subject('Remote mirror update failed'))
+ mail(to: recipient(recipient_id), subject: subject("Remote mirror update failed"))
end
end
end
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index efa1233b434..7f3098e09a6 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -29,8 +29,7 @@ class Notify < BaseMailer
mail(to: recipient_email,
subject: subject,
body: body.html_safe,
- content_type: 'text/html'
- )
+ content_type: "text/html")
end
# Splits "gitlab.corp.company.com" up into "gitlab.corp.company.com",
@@ -105,7 +104,7 @@ class Notify < BaseMailer
subject.concat(extra) if extra.present?
subject << Gitlab.config.gitlab.email_subject_suffix if Gitlab.config.gitlab.email_subject_suffix.present?
- subject.join(' | ')
+ subject.join(" | ")
end
# Return a string suitable for inclusion in the 'Message-Id' mail header.
@@ -122,18 +121,18 @@ class Notify < BaseMailer
headers["X-GitLab-#{model.class.name}-ID"] = model.id
headers["X-GitLab-#{model.class.name}-IID"] = model.iid if model.respond_to?(:iid)
- headers['X-GitLab-Reply-Key'] = reply_key
+ headers["X-GitLab-Reply-Key"] = reply_key
- @reason = headers['X-GitLab-NotificationReason']
+ @reason = headers["X-GitLab-NotificationReason"]
if Gitlab::IncomingEmail.enabled? && @sent_notification
- headers['Reply-To'] = Mail::Address.new(Gitlab::IncomingEmail.reply_address(reply_key)).tap do |address|
+ headers["Reply-To"] = Mail::Address.new(Gitlab::IncomingEmail.reply_address(reply_key)).tap do |address|
address.display_name = reply_display_name(model)
end
fallback_reply_message_id = "<reply-#{reply_key}@#{Gitlab.config.gitlab.host}>"
- headers['References'] ||= []
- headers['References'].unshift(fallback_reply_message_id)
+ headers["References"] ||= []
+ headers["References"].unshift(fallback_reply_message_id)
@reply_by_email = true
end
@@ -151,7 +150,7 @@ class Notify < BaseMailer
#
# See: mail_answer_thread
def mail_new_thread(model, headers = {})
- headers['Message-ID'] = message_id(model)
+ headers["Message-ID"] = message_id(model)
mail_thread(model, headers)
end
@@ -165,9 +164,9 @@ class Notify < BaseMailer
# * have a 'In-Reply-To' or 'References' header that references the original 'Message-ID'
#
def mail_answer_thread(model, headers = {})
- headers['Message-ID'] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>"
- headers['In-Reply-To'] = message_id(model)
- headers['References'] = [message_id(model)]
+ headers["Message-ID"] = "<#{SecureRandom.hex}@#{Gitlab.config.gitlab.host}>"
+ headers["In-Reply-To"] = message_id(model)
+ headers["References"] = [message_id(model)]
headers[:subject] = "Re: #{headers[:subject]}" if headers[:subject]
@@ -175,11 +174,11 @@ class Notify < BaseMailer
end
def mail_answer_note_thread(model, note, headers = {})
- headers['Message-ID'] = message_id(note)
- headers['In-Reply-To'] = message_id(note.references.last)
- headers['References'] = note.references.map { |ref| message_id(ref) }
+ headers["Message-ID"] = message_id(note)
+ headers["In-Reply-To"] = message_id(note.references.last)
+ headers["References"] = note.references.map { |ref| message_id(ref) }
- headers['X-GitLab-Discussion-ID'] = note.discussion.id if note.part_of_discussion?
+ headers["X-GitLab-Discussion-ID"] = note.discussion.id if note.part_of_discussion?
headers[:subject] = "Re: #{headers[:subject]}" if headers[:subject]
@@ -193,10 +192,10 @@ class Notify < BaseMailer
def add_project_headers
return unless @project
- headers['X-GitLab-Project'] = @project.name
- headers['X-GitLab-Project-Id'] = @project.id
- headers['X-GitLab-Project-Path'] = @project.full_path
- headers['List-Id'] = "#{@project.full_path} <#{create_list_id_string(@project)}>"
+ headers["X-GitLab-Project"] = @project.name
+ headers["X-GitLab-Project-Id"] = @project.id
+ headers["X-GitLab-Project-Path"] = @project.full_path
+ headers["List-Id"] = "#{@project.full_path} <#{create_list_id_string(@project)}>"
end
def add_unsubscription_headers_and_links
@@ -207,7 +206,7 @@ class Notify < BaseMailer
list_unsubscribe_methods << "mailto:#{Gitlab::IncomingEmail.unsubscribe_address(reply_key)}"
end
- headers['List-Unsubscribe'] = list_unsubscribe_methods.map { |e| "<#{e}>" }.join(',')
+ headers["List-Unsubscribe"] = list_unsubscribe_methods.map { |e| "<#{e}>" }.join(",")
@unsubscribe_url = unsubscribe_sent_notification_url(@sent_notification)
end
end
diff --git a/app/mailers/previews/devise_mailer_preview.rb b/app/mailers/previews/devise_mailer_preview.rb
index 3b9ef0d3ac0..963d13c946d 100644
--- a/app/mailers/previews/devise_mailer_preview.rb
+++ b/app/mailers/previews/devise_mailer_preview.rb
@@ -2,22 +2,22 @@
class DeviseMailerPreview < ActionMailer::Preview
def confirmation_instructions_for_signup
- DeviseMailer.confirmation_instructions(unsaved_user, 'faketoken', {})
+ DeviseMailer.confirmation_instructions(unsaved_user, "faketoken", {})
end
def confirmation_instructions_for_new_email
user = User.last
- user.unconfirmed_email = 'unconfirmed@example.com'
+ user.unconfirmed_email = "unconfirmed@example.com"
- DeviseMailer.confirmation_instructions(user, 'faketoken', {})
+ DeviseMailer.confirmation_instructions(user, "faketoken", {})
end
def reset_password_instructions
- DeviseMailer.reset_password_instructions(unsaved_user, 'faketoken', {})
+ DeviseMailer.reset_password_instructions(unsaved_user, "faketoken", {})
end
def unlock_instructions
- DeviseMailer.unlock_instructions(unsaved_user, 'faketoken', {})
+ DeviseMailer.unlock_instructions(unsaved_user, "faketoken", {})
end
def password_change
@@ -27,6 +27,6 @@ class DeviseMailerPreview < ActionMailer::Preview
private
def unsaved_user
- User.new(name: 'Jane Doe', email: 'jdoe@example.com')
+ User.new(name: "Jane Doe", email: "jdoe@example.com")
end
end
diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb
index 80e0a17c312..8d7a3bc8d81 100644
--- a/app/mailers/previews/notify_preview.rb
+++ b/app/mailers/previews/notify_preview.rb
@@ -13,7 +13,7 @@ class NotifyPreview < ActionMailer::Preview
- An explanation for why the user is receiving this notification
MD
- create_note(noteable_type: 'merge_request', noteable_id: merge_request.id, note: note)
+ create_note(noteable_type: "merge_request", noteable_id: merge_request.id, note: note)
end
end
@@ -30,7 +30,7 @@ class NotifyPreview < ActionMailer::Preview
- An explanation for why the user is receiving this notification
MD
- create_note(noteable_type: 'merge_request', noteable_id: merge_request.id, type: 'DiscussionNote', note: note)
+ create_note(noteable_type: "merge_request", noteable_id: merge_request.id, type: "DiscussionNote", note: note)
end
end
@@ -56,7 +56,7 @@ class NotifyPreview < ActionMailer::Preview
diff_refs: merge_request.diff_refs
)
- create_note(noteable_type: 'merge_request', noteable_id: merge_request.id, type: 'DiffNote', position: position, note: note)
+ create_note(noteable_type: "merge_request", noteable_id: merge_request.id, type: "DiffNote", position: position, note: note)
end
end
@@ -65,7 +65,7 @@ class NotifyPreview < ActionMailer::Preview
end
def issue_status_changed_email
- Notify.issue_status_changed_email(user.id, issue.id, 'closed', user.id).message
+ Notify.issue_status_changed_email(user.id, issue.id, "closed", user.id).message
end
def removed_milestone_issue_email
@@ -77,7 +77,7 @@ class NotifyPreview < ActionMailer::Preview
end
def import_issues_csv_email
- Notify.import_issues_csv_email(user, project, { success: 3, errors: [5, 6, 7], valid_file: true })
+ Notify.import_issues_csv_email(user, project, {success: 3, errors: [5, 6, 7], valid_file: true})
end
def closed_merge_request_email
@@ -85,7 +85,7 @@ class NotifyPreview < ActionMailer::Preview
end
def merge_request_status_email
- Notify.merge_request_status_email(user.id, merge_request.id, 'closed', user.id).message
+ Notify.merge_request_status_email(user.id, merge_request.id, "closed", user.id).message
end
def merged_merge_request_email
@@ -101,37 +101,37 @@ class NotifyPreview < ActionMailer::Preview
end
def member_access_denied_email
- Notify.member_access_denied_email('project', project.id, user.id).message
+ Notify.member_access_denied_email("project", project.id, user.id).message
end
def member_access_granted_email
- Notify.member_access_granted_email('project', user.id).message
+ Notify.member_access_granted_email("project", user.id).message
end
def member_access_requested_email
- Notify.member_access_requested_email('group', user.id, 'some@example.com').message
+ Notify.member_access_requested_email("group", user.id, "some@example.com").message
end
def member_invite_accepted_email
- Notify.member_invite_accepted_email('project', user.id).message
+ Notify.member_invite_accepted_email("project", user.id).message
end
def member_invite_declined_email
Notify.member_invite_declined_email(
- 'project',
+ "project",
project.id,
- 'invite@example.com',
+ "invite@example.com",
user.id
).message
end
def member_invited_email
- Notify.member_invited_email('project', user.id, '1234').message
+ Notify.member_invited_email("project", user.id, "1234").message
end
def pages_domain_enabled_email
cleanup do
- pages_domain = PagesDomain.new(domain: 'my.example.com', project: project, verified_at: Time.now, enabled_until: 1.week.from_now)
+ pages_domain = PagesDomain.new(domain: "my.example.com", project: project, verified_at: Time.now, enabled_until: 1.week.from_now)
Notify.pages_domain_enabled_email(pages_domain, user).message
end
@@ -156,7 +156,7 @@ class NotifyPreview < ActionMailer::Preview
private
def project
- @project ||= Project.find_by_full_path('gitlab-org/gitlab-test')
+ @project ||= Project.find_by_full_path("gitlab-org/gitlab-test")
end
def issue
diff --git a/app/mailers/repository_check_mailer.rb b/app/mailers/repository_check_mailer.rb
index a24d3476d0e..448b52af777 100644
--- a/app/mailers/repository_check_mailer.rb
+++ b/app/mailers/repository_check_mailer.rb
@@ -2,7 +2,7 @@
class RepositoryCheckMailer < BaseMailer
# rubocop: disable CodeReuse/ActiveRecord
- layout 'empty_mailer'
+ layout "empty_mailer"
helper EmailsHelper
diff --git a/app/models/ability.rb b/app/models/ability.rb
index 1466407d0d1..2d861c909ef 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'declarative_policy'
+require_dependency "declarative_policy"
class Ability
class << self
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index 1b78fd04ebb..d40e0edf194 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -5,24 +5,24 @@ class AbuseReport < ActiveRecord::Base
cache_markdown_field :message, pipeline: :single_line
- belongs_to :reporter, class_name: 'User'
+ belongs_to :reporter, class_name: "User"
belongs_to :user
validates :reporter, presence: true
validates :user, presence: true
validates :message, presence: true
- validates :user_id, uniqueness: { message: 'has already been reported' }
+ validates :user_id, uniqueness: {message: "has already been reported"}
# For CacheMarkdownField
- alias_method :author, :reporter
+ alias author reporter
def remove_user(deleted_by:)
- user.delete_async(deleted_by: deleted_by, params: { hard_delete: true })
+ user.delete_async(deleted_by: deleted_by, params: {hard_delete: true})
end
def notify
- return unless self.persisted?
+ return unless persisted?
- AbuseReportMailer.notify(self.id).deliver_later
+ AbuseReportMailer.notify(id).deliver_later
end
end
diff --git a/app/models/active_session.rb b/app/models/active_session.rb
index 0d9c6a4a1f0..b2d7735d877 100644
--- a/app/models/active_session.rb
+++ b/app/models/active_session.rb
@@ -37,7 +37,7 @@ class ActiveSession
redis.pipelined do
redis.setex(
key_name(user.id, session_id),
- Settings.gitlab['session_expire_delay'] * 60,
+ Settings.gitlab["session_expire_delay"] * 60,
Marshal.dump(active_user_session)
)
@@ -80,7 +80,7 @@ class ActiveSession
end
end
- def self.key_name(user_id, session_id = '*')
+ def self.key_name(user_id, session_id = "*")
"#{Gitlab::Redis::SharedState::USER_SESSIONS_NAMESPACE}:#{user_id}:#{session_id}"
end
diff --git a/app/models/appearance.rb b/app/models/appearance.rb
index bdee9b2b73c..1ddb021dadb 100644
--- a/app/models/appearance.rb
+++ b/app/models/appearance.rb
@@ -11,15 +11,15 @@ class Appearance < ActiveRecord::Base
cache_markdown_field :header_message, pipeline: :broadcast_message
cache_markdown_field :footer_message, pipeline: :broadcast_message
- validates :logo, file_size: { maximum: 1.megabyte }
- validates :header_logo, file_size: { maximum: 1.megabyte }
+ validates :logo, file_size: {maximum: 1.megabyte}
+ validates :header_logo, file_size: {maximum: 1.megabyte}
validates :message_background_color, allow_blank: true, color: true
validates :message_font_color, allow_blank: true, color: true
validate :single_appearance_row, on: :create
- default_value_for :message_background_color, '#E75E40'
- default_value_for :message_font_color, '#FFFFFF'
+ default_value_for :message_background_color, "#E75E40"
+ default_value_for :message_font_color, "#FFFFFF"
default_value_for :email_header_and_footer_enabled, false
mount_uploader :logo, AttachmentUploader
@@ -33,20 +33,20 @@ class Appearance < ActiveRecord::Base
def single_appearance_row
if self.class.any?
- errors.add(:single_appearance_row, 'Only 1 appearances row can exist')
+ errors.add(:single_appearance_row, "Only 1 appearances row can exist")
end
end
def logo_path
- logo_system_path(logo, 'logo')
+ logo_system_path(logo, "logo")
end
def header_logo_path
- logo_system_path(header_logo, 'header_logo')
+ logo_system_path(header_logo, "header_logo")
end
def favicon_path
- logo_system_path(favicon, 'favicon')
+ logo_system_path(favicon, "favicon")
end
def show_header?
@@ -71,8 +71,9 @@ class Appearance < ActiveRecord::Base
local_path = Gitlab::Routing.url_helpers.appearance_upload_path(
filename: logo.filename,
id: logo.upload.model_id,
- model: 'appearance',
- mounted_as: mount_type)
+ model: "appearance",
+ mounted_as: mount_type
+ )
Gitlab::Utils.append_path(asset_host, local_path)
end
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index daadf9427ba..1faa3d83f8f 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -51,154 +51,154 @@ class ApplicationSetting < ActiveRecord::Base
validates :uuid, presence: true
validates :session_expire_delay,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0}
validates :home_page_url,
- allow_blank: true,
- url: true,
- if: :home_page_url_column_exists?
+ allow_blank: true,
+ url: true,
+ if: :home_page_url_column_exists?
validates :help_page_support_url,
- allow_blank: true,
- url: true,
- if: :help_page_support_url_column_exists?
+ allow_blank: true,
+ url: true,
+ if: :help_page_support_url_column_exists?
validates :after_sign_out_path,
- allow_blank: true,
- url: true
+ allow_blank: true,
+ url: true
validates :admin_notification_email,
- email: true,
- allow_blank: true
+ email: true,
+ allow_blank: true
validates :two_factor_grace_period,
- numericality: { greater_than_or_equal_to: 0 }
+ numericality: {greater_than_or_equal_to: 0}
validates :recaptcha_site_key,
- presence: true,
- if: :recaptcha_enabled
+ presence: true,
+ if: :recaptcha_enabled
validates :recaptcha_private_key,
- presence: true,
- if: :recaptcha_enabled
+ presence: true,
+ if: :recaptcha_enabled
validates :sentry_dsn,
- presence: true,
- if: :sentry_enabled
+ presence: true,
+ if: :sentry_enabled
validates :clientside_sentry_dsn,
- presence: true,
- if: :clientside_sentry_enabled
+ presence: true,
+ if: :clientside_sentry_enabled
validates :akismet_api_key,
- presence: true,
- if: :akismet_enabled
+ presence: true,
+ if: :akismet_enabled
validates :unique_ips_limit_per_user,
- numericality: { greater_than_or_equal_to: 1 },
- presence: true,
- if: :unique_ips_limit_enabled
+ numericality: {greater_than_or_equal_to: 1},
+ presence: true,
+ if: :unique_ips_limit_enabled
validates :unique_ips_limit_time_window,
- numericality: { greater_than_or_equal_to: 0 },
- presence: true,
- if: :unique_ips_limit_enabled
+ numericality: {greater_than_or_equal_to: 0},
+ presence: true,
+ if: :unique_ips_limit_enabled
validates :plantuml_url,
- presence: true,
- if: :plantuml_enabled
+ presence: true,
+ if: :plantuml_enabled
validates :max_attachment_size,
- presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than: 0}
validates :max_artifacts_size,
- presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than: 0}
validates :default_artifacts_expire_in, presence: true, duration: true
validates :container_registry_token_expire_delay,
- presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than: 0}
validates :repository_storages, presence: true
validate :check_repository_storages
validates :auto_devops_domain,
- allow_blank: true,
- hostname: { allow_numeric_hostname: true, require_valid_tld: true },
- if: :auto_devops_enabled?
+ allow_blank: true,
+ hostname: {allow_numeric_hostname: true, require_valid_tld: true},
+ if: :auto_devops_enabled?
validates :enabled_git_access_protocol,
- inclusion: { in: %w(ssh http), allow_blank: true, allow_nil: true }
+ inclusion: {in: %w[ssh http], allow_blank: true, allow_nil: true}
validates :domain_blacklist,
- presence: { message: 'Domain blacklist cannot be empty if Blacklist is enabled.' },
- if: :domain_blacklist_enabled?
+ presence: {message: "Domain blacklist cannot be empty if Blacklist is enabled."},
+ if: :domain_blacklist_enabled?
validates :housekeeping_incremental_repack_period,
- presence: true,
- numericality: { only_integer: true, greater_than: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than: 0}
validates :housekeeping_full_repack_period,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: :housekeeping_incremental_repack_period }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: :housekeeping_incremental_repack_period}
validates :housekeeping_gc_period,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: :housekeeping_full_repack_period }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: :housekeeping_full_repack_period}
validates :terminal_max_session_time,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0}
validates :polling_interval_multiplier,
- presence: true,
- numericality: { greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {greater_than_or_equal_to: 0}
validates :gitaly_timeout_default,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0}
validates :gitaly_timeout_medium,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0}
validates :gitaly_timeout_medium,
- numericality: { less_than_or_equal_to: :gitaly_timeout_default },
- if: :gitaly_timeout_default
+ numericality: {less_than_or_equal_to: :gitaly_timeout_default},
+ if: :gitaly_timeout_default
validates :gitaly_timeout_medium,
- numericality: { greater_than_or_equal_to: :gitaly_timeout_fast },
- if: :gitaly_timeout_fast
+ numericality: {greater_than_or_equal_to: :gitaly_timeout_fast},
+ if: :gitaly_timeout_fast
validates :gitaly_timeout_fast,
- presence: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ presence: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0}
validates :gitaly_timeout_fast,
- numericality: { less_than_or_equal_to: :gitaly_timeout_default },
- if: :gitaly_timeout_default
+ numericality: {less_than_or_equal_to: :gitaly_timeout_default},
+ if: :gitaly_timeout_default
validates :diff_max_patch_bytes,
- presence: true,
- numericality: { only_integer: true,
- greater_than_or_equal_to: Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES,
- less_than_or_equal_to: Gitlab::Git::Diff::MAX_PATCH_BYTES_UPPER_BOUND }
+ presence: true,
+ numericality: {only_integer: true,
+ greater_than_or_equal_to: Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES,
+ less_than_or_equal_to: Gitlab::Git::Diff::MAX_PATCH_BYTES_UPPER_BOUND,}
validates :user_default_internal_regex, js_regex: true, allow_nil: true
- validates :commit_email_hostname, format: { with: /\A[^@]+\z/ }
+ validates :commit_email_hostname, format: {with: /\A[^@]+\z/}
validates :archive_builds_in_seconds,
- allow_nil: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 1.day.seconds }
+ allow_nil: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 1.day.seconds}
validates :local_markdown_version,
- allow_nil: true,
- numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than: 65536 }
+ allow_nil: true,
+ numericality: {only_integer: true, greater_than_or_equal_to: 0, less_than: 65536}
SUPPORTED_KEY_TYPES.each do |type|
- validates :"#{type}_key_restriction", presence: true, key_restriction: { type: type }
+ validates :"#{type}_key_restriction", presence: true, key_restriction: {type: type}
end
validates :allowed_key_types, presence: true
@@ -230,7 +230,7 @@ class ApplicationSetting < ActiveRecord::Base
after_commit do
reset_memoized_terms
end
- after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') }
+ after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?("performance_bar_allowed_group_id") }
def self.defaults
{
@@ -239,14 +239,14 @@ class ApplicationSetting < ActiveRecord::Base
allow_local_requests_from_hooks_and_services: false,
authorized_keys_enabled: true, # TODO default to false if the instance is configured to use AuthorizedKeysCommand
container_registry_token_expire_delay: 5,
- default_artifacts_expire_in: '30 days',
- default_branch_protection: Settings.gitlab['default_branch_protection'],
- default_group_visibility: Settings.gitlab.default_projects_features['visibility_level'],
- default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
- default_projects_limit: Settings.gitlab['default_projects_limit'],
- default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
+ default_artifacts_expire_in: "30 days",
+ default_branch_protection: Settings.gitlab["default_branch_protection"],
+ default_group_visibility: Settings.gitlab.default_projects_features["visibility_level"],
+ default_project_visibility: Settings.gitlab.default_projects_features["visibility_level"],
+ default_projects_limit: Settings.gitlab["default_projects_limit"],
+ default_snippet_visibility: Settings.gitlab.default_projects_features["visibility_level"],
disabled_oauth_sign_in_sources: [],
- domain_whitelist: Settings.gitlab['domain_whitelist'],
+ domain_whitelist: Settings.gitlab["domain_whitelist"],
dsa_key_restriction: 0,
ecdsa_key_restriction: 0,
ed25519_key_restriction: 0,
@@ -254,7 +254,7 @@ class ApplicationSetting < ActiveRecord::Base
gitaly_timeout_default: 55,
gitaly_timeout_fast: 10,
gitaly_timeout_medium: 30,
- gravatar_enabled: Settings.gravatar['enabled'],
+ gravatar_enabled: Settings.gravatar["enabled"],
help_page_hide_commercial_content: false,
help_page_text: nil,
hide_third_party_offers: false,
@@ -263,12 +263,12 @@ class ApplicationSetting < ActiveRecord::Base
housekeeping_full_repack_period: 50,
housekeeping_gc_period: 200,
housekeeping_incremental_repack_period: 10,
- import_sources: Settings.gitlab['import_sources'],
- max_artifacts_size: Settings.artifacts['max_size'],
- max_attachment_size: Settings.gitlab['max_attachment_size'],
+ import_sources: Settings.gitlab["import_sources"],
+ max_artifacts_size: Settings.artifacts["max_size"],
+ max_attachment_size: Settings.gitlab["max_attachment_size"],
mirror_available: true,
password_authentication_enabled_for_git: true,
- password_authentication_enabled_for_web: Settings.gitlab['signin_enabled'],
+ password_authentication_enabled_for_web: Settings.gitlab["signin_enabled"],
performance_bar_allowed_group_id: nil,
rsa_key_restriction: 0,
plantuml_enabled: false,
@@ -277,15 +277,15 @@ class ApplicationSetting < ActiveRecord::Base
project_export_enabled: true,
recaptcha_enabled: false,
repository_checks_enabled: true,
- repository_storages: ['default'],
+ repository_storages: ["default"],
require_two_factor_authentication: false,
- restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
- session_expire_delay: Settings.gitlab['session_expire_delay'],
+ restricted_visibility_levels: Settings.gitlab["restricted_visibility_levels"],
+ session_expire_delay: Settings.gitlab["session_expire_delay"],
send_user_confirmation_email: false,
- shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
+ shared_runners_enabled: Settings.gitlab_ci["shared_runners_enabled"],
shared_runners_text: nil,
sign_in_text: nil,
- signup_enabled: Settings.gitlab['signup_enabled'],
+ signup_enabled: Settings.gitlab["signup_enabled"],
terminal_max_session_time: 0,
throttle_authenticated_api_enabled: false,
throttle_authenticated_api_period_in_seconds: 3600,
@@ -300,7 +300,7 @@ class ApplicationSetting < ActiveRecord::Base
unique_ips_limit_enabled: false,
unique_ips_limit_per_user: 10,
unique_ips_limit_time_window: 3600,
- usage_ping_enabled: Settings.gitlab['usage_ping_enabled'],
+ usage_ping_enabled: Settings.gitlab["usage_ping_enabled"],
instance_statistics_visibility_private: false,
user_default_external: false,
user_default_internal_regex: nil,
@@ -309,7 +309,7 @@ class ApplicationSetting < ActiveRecord::Base
diff_max_patch_bytes: Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES,
commit_email_hostname: default_commit_email_hostname,
protected_ci_variables: false,
- local_markdown_version: 0
+ local_markdown_version: 0,
}
end
@@ -323,7 +323,7 @@ class ApplicationSetting < ActiveRecord::Base
def self.human_attribute_name(attr, _options = {})
if attr == :default_artifacts_expire_in
- 'Default artifacts expiration'
+ "Default artifacts expiration"
else
super
end
@@ -343,25 +343,25 @@ class ApplicationSetting < ActiveRecord::Base
end
def domain_whitelist_raw
- self.domain_whitelist&.join("\n")
+ domain_whitelist&.join("\n")
end
def domain_blacklist_raw
- self.domain_blacklist&.join("\n")
+ domain_blacklist&.join("\n")
end
def domain_whitelist_raw=(values)
self.domain_whitelist = []
self.domain_whitelist = values.split(DOMAIN_LIST_SEPARATOR)
- self.domain_whitelist.reject! { |d| d.empty? }
- self.domain_whitelist
+ domain_whitelist.reject! { |d| d.empty? }
+ domain_whitelist
end
def domain_blacklist_raw=(values)
self.domain_blacklist = []
self.domain_blacklist = values.split(DOMAIN_LIST_SEPARATOR)
- self.domain_blacklist.reject! { |d| d.empty? }
- self.domain_blacklist
+ domain_blacklist.reject! { |d| d.empty? }
+ domain_blacklist
end
def domain_blacklist_file=(file)
@@ -467,7 +467,7 @@ class ApplicationSetting < ActiveRecord::Base
end
def archive_builds_older_than
- archive_builds_in_seconds.seconds.ago if archive_builds_in_seconds
+ archive_builds_in_seconds&.seconds&.ago
end
private
diff --git a/app/models/audit_event.rb b/app/models/audit_event.rb
index 8508c88d406..2704acc76b4 100644
--- a/app/models/audit_event.rb
+++ b/app/models/audit_event.rb
@@ -16,6 +16,6 @@ class AuditEvent < ActiveRecord::Base
end
def author_name
- self.user.name
+ user.name
end
end
diff --git a/app/models/award_emoji.rb b/app/models/award_emoji.rb
index ddc516ccb60..008929d0478 100644
--- a/app/models/award_emoji.rb
+++ b/app/models/award_emoji.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class AwardEmoji < ActiveRecord::Base
- DOWNVOTE_NAME = "thumbsdown".freeze
- UPVOTE_NAME = "thumbsup".freeze
+ DOWNVOTE_NAME = "thumbsdown"
+ UPVOTE_NAME = "thumbsup"
include Participable
include GhostUser
@@ -11,8 +11,8 @@ class AwardEmoji < ActiveRecord::Base
belongs_to :user
validates :awardable, :user, presence: true
- validates :name, presence: true, inclusion: { in: Gitlab::Emoji.emojis_names }
- validates :name, uniqueness: { scope: [:user, :awardable_type, :awardable_id] }, unless: :ghost_user?
+ validates :name, presence: true, inclusion: {in: Gitlab::Emoji.emojis_names}
+ validates :name, uniqueness: {scope: [:user, :awardable_type, :awardable_id]}, unless: :ghost_user?
participant :user
@@ -24,9 +24,9 @@ class AwardEmoji < ActiveRecord::Base
class << self
def votes_for_collection(ids, type)
- select('name', 'awardable_id', 'COUNT(*) as count')
- .where('name IN (?) AND awardable_type = ? AND awardable_id IN (?)', [DOWNVOTE_NAME, UPVOTE_NAME], type, ids)
- .group('name', 'awardable_id')
+ select("name", "awardable_id", "COUNT(*) as count")
+ .where("name IN (?) AND awardable_type = ? AND awardable_id IN (?)", [DOWNVOTE_NAME, UPVOTE_NAME], type, ids)
+ .group("name", "awardable_id")
end
# Returns the top 100 emoji awarded by the given user.
@@ -42,17 +42,17 @@ class AwardEmoji < ActiveRecord::Base
limit(limit)
.where(user: user)
.group(:name)
- .order('count_all DESC, name ASC')
+ .order("count_all DESC, name ASC")
.count
end
end
def downvote?
- self.name == DOWNVOTE_NAME
+ name == DOWNVOTE_NAME
end
def upvote?
- self.name == UPVOTE_NAME
+ name == UPVOTE_NAME
end
def expire_etag_cache
diff --git a/app/models/badge.rb b/app/models/badge.rb
index f016654206b..469915bc460 100644
--- a/app/models/badge.rb
+++ b/app/models/badge.rb
@@ -7,10 +7,10 @@ class Badge < ActiveRecord::Base
# can have. This hash also sets which action to ask when
# the placeholder is found.
PLACEHOLDERS = {
- 'project_path' => :full_path,
- 'project_id' => :id,
- 'default_branch' => :default_branch,
- 'commit_sha' => ->(project) { project.commit&.sha }
+ "project_path" => :full_path,
+ "project_id" => :id,
+ "default_branch" => :default_branch,
+ "commit_sha" => ->(project) { project.commit&.sha },
}.freeze
# This regex is built dynamically using the keys from the PLACEHOLDER struct.
@@ -22,7 +22,7 @@ class Badge < ActiveRecord::Base
scope :order_created_at_asc, -> { reorder(created_at: :asc) }
- validates :link_url, :image_url, url: { protocols: %w(http https) }
+ validates :link_url, :image_url, url: {protocols: %w[http https]}
validates :type, presence: true
def rendered_link_url(project = nil)
diff --git a/app/models/blob.rb b/app/models/blob.rb
index c5766eb0327..eac766827b3 100644
--- a/app/models/blob.rb
+++ b/app/models/blob.rb
@@ -36,7 +36,7 @@ class Blob < SimpleDelegator
BlobViewer::PDF,
BlobViewer::BinarySTL,
- BlobViewer::TextSTL
+ BlobViewer::TextSTL,
].sort_by { |v| v.binary? ? 0 : 1 }.freeze
AUXILIARY_VIEWERS = [
@@ -58,7 +58,7 @@ class Blob < SimpleDelegator
BlobViewer::Podspec,
BlobViewer::PodspecJson,
BlobViewer::RequirementsTxt,
- BlobViewer::YarnLock
+ BlobViewer::YarnLock,
].freeze
attr_reader :project
@@ -166,7 +166,7 @@ class Blob < SimpleDelegator
end
def extension
- @extension ||= extname.downcase.delete('.')
+ @extension ||= extname.downcase.delete(".")
end
def file_type
diff --git a/app/models/blob_viewer/auxiliary.rb b/app/models/blob_viewer/auxiliary.rb
index 263d51b4e36..aa432d51026 100644
--- a/app/models/blob_viewer/auxiliary.rb
+++ b/app/models/blob_viewer/auxiliary.rb
@@ -7,7 +7,7 @@ module BlobViewer
include Gitlab::Allowable
included do
- self.loading_partial_name = 'loading_auxiliary'
+ self.loading_partial_name = "loading_auxiliary"
self.type = :auxiliary
self.collapse_limit = 100.kilobytes
self.size_limit = 100.kilobytes
diff --git a/app/models/blob_viewer/balsamiq.rb b/app/models/blob_viewer/balsamiq.rb
index 1af6c5474d7..b98b3e39026 100644
--- a/app/models/blob_viewer/balsamiq.rb
+++ b/app/models/blob_viewer/balsamiq.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'balsamiq'
- self.extensions = %w(bmpr)
+ self.partial_name = "balsamiq"
+ self.extensions = %w[bmpr]
self.binary = true
- self.switcher_icon = 'file-image-o'
- self.switcher_title = 'preview'
+ self.switcher_icon = "file-image-o"
+ self.switcher_title = "preview"
end
end
diff --git a/app/models/blob_viewer/base.rb b/app/models/blob_viewer/base.rb
index df6b9bb2f0b..d1e45d3d160 100644
--- a/app/models/blob_viewer/base.rb
+++ b/app/models/blob_viewer/base.rb
@@ -2,11 +2,11 @@
module BlobViewer
class Base
- PARTIAL_PATH_PREFIX = 'projects/blob/viewers'.freeze
+ PARTIAL_PATH_PREFIX = "projects/blob/viewers"
class_attribute :partial_name, :loading_partial_name, :type, :extensions, :file_types, :load_async, :binary, :switcher_icon, :switcher_title, :collapse_limit, :size_limit
- self.loading_partial_name = 'loading'
+ self.loading_partial_name = "loading"
delegate :partial_path, :loading_partial_path, :rich?, :simple?, :load_async?, :text?, :binary?, to: :class
diff --git a/app/models/blob_viewer/binary_stl.rb b/app/models/blob_viewer/binary_stl.rb
index 425f72decae..5d4098d7733 100644
--- a/app/models/blob_viewer/binary_stl.rb
+++ b/app/models/blob_viewer/binary_stl.rb
@@ -5,8 +5,8 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'stl'
- self.extensions = %w(stl)
+ self.partial_name = "stl"
+ self.extensions = %w[stl]
self.binary = true
end
end
diff --git a/app/models/blob_viewer/cartfile.rb b/app/models/blob_viewer/cartfile.rb
index ea0494033bf..0932075db30 100644
--- a/app/models/blob_viewer/cartfile.rb
+++ b/app/models/blob_viewer/cartfile.rb
@@ -4,14 +4,14 @@ module BlobViewer
class Cartfile < DependencyManager
include Static
- self.file_types = %i(cartfile)
+ self.file_types = %i[cartfile]
def manager_name
- 'Carthage'
+ "Carthage"
end
def manager_url
- 'https://github.com/Carthage/Carthage'
+ "https://github.com/Carthage/Carthage"
end
end
end
diff --git a/app/models/blob_viewer/changelog.rb b/app/models/blob_viewer/changelog.rb
index 8810bd25809..f552fa588ba 100644
--- a/app/models/blob_viewer/changelog.rb
+++ b/app/models/blob_viewer/changelog.rb
@@ -5,8 +5,8 @@ module BlobViewer
include Auxiliary
include Static
- self.partial_name = 'changelog'
- self.file_types = %i(changelog)
+ self.partial_name = "changelog"
+ self.file_types = %i[changelog]
self.binary = false
def render_error
diff --git a/app/models/blob_viewer/composer_json.rb b/app/models/blob_viewer/composer_json.rb
index 9d1376de0cb..b39e2e4b530 100644
--- a/app/models/blob_viewer/composer_json.rb
+++ b/app/models/blob_viewer/composer_json.rb
@@ -4,18 +4,18 @@ module BlobViewer
class ComposerJson < DependencyManager
include ServerSide
- self.file_types = %i(composer_json)
+ self.file_types = %i[composer_json]
def manager_name
- 'Composer'
+ "Composer"
end
def manager_url
- 'https://getcomposer.org/'
+ "https://getcomposer.org/"
end
def package_name
- @package_name ||= package_name_from_json('name')
+ @package_name ||= package_name_from_json("name")
end
def package_url
diff --git a/app/models/blob_viewer/contributing.rb b/app/models/blob_viewer/contributing.rb
index fa224309e31..8918026abd0 100644
--- a/app/models/blob_viewer/contributing.rb
+++ b/app/models/blob_viewer/contributing.rb
@@ -5,8 +5,8 @@ module BlobViewer
include Auxiliary
include Static
- self.partial_name = 'contributing'
- self.file_types = %i(contributing)
+ self.partial_name = "contributing"
+ self.file_types = %i[contributing]
self.binary = false
end
end
diff --git a/app/models/blob_viewer/dependency_manager.rb b/app/models/blob_viewer/dependency_manager.rb
index 711465c7c79..240416c1e6a 100644
--- a/app/models/blob_viewer/dependency_manager.rb
+++ b/app/models/blob_viewer/dependency_manager.rb
@@ -4,7 +4,7 @@ module BlobViewer
class DependencyManager < Base
include Auxiliary
- self.partial_name = 'dependency_manager'
+ self.partial_name = "dependency_manager"
self.binary = false
def manager_name
@@ -16,7 +16,7 @@ module BlobViewer
end
def package_type
- 'package'
+ "package"
end
def package_name
@@ -33,8 +33,8 @@ module BlobViewer
@json_data ||= begin
prepare!
JSON.parse(blob.data)
- rescue
- {}
+ rescue
+ {}
end
end
diff --git a/app/models/blob_viewer/download.rb b/app/models/blob_viewer/download.rb
index 8228a83c2b1..537c6728bc1 100644
--- a/app/models/blob_viewer/download.rb
+++ b/app/models/blob_viewer/download.rb
@@ -5,7 +5,7 @@ module BlobViewer
include Simple
include Static
- self.partial_name = 'download'
+ self.partial_name = "download"
self.binary = true
end
end
diff --git a/app/models/blob_viewer/empty.rb b/app/models/blob_viewer/empty.rb
index 766be349d83..045933c8f1f 100644
--- a/app/models/blob_viewer/empty.rb
+++ b/app/models/blob_viewer/empty.rb
@@ -5,6 +5,6 @@ module BlobViewer
include Simple
include ServerSide
- self.partial_name = 'empty'
+ self.partial_name = "empty"
end
end
diff --git a/app/models/blob_viewer/gemfile.rb b/app/models/blob_viewer/gemfile.rb
index 77220cdbd08..6fa39517837 100644
--- a/app/models/blob_viewer/gemfile.rb
+++ b/app/models/blob_viewer/gemfile.rb
@@ -4,14 +4,14 @@ module BlobViewer
class Gemfile < DependencyManager
include Static
- self.file_types = %i(gemfile gemfile_lock)
+ self.file_types = %i[gemfile gemfile_lock]
def manager_name
- 'Bundler'
+ "Bundler"
end
def manager_url
- 'http://bundler.io/'
+ "http://bundler.io/"
end
end
end
diff --git a/app/models/blob_viewer/gemspec.rb b/app/models/blob_viewer/gemspec.rb
index 274859a7710..2f7e17345d6 100644
--- a/app/models/blob_viewer/gemspec.rb
+++ b/app/models/blob_viewer/gemspec.rb
@@ -4,22 +4,22 @@ module BlobViewer
class Gemspec < DependencyManager
include ServerSide
- self.file_types = %i(gemspec)
+ self.file_types = %i[gemspec]
def manager_name
- 'RubyGems'
+ "RubyGems"
end
def manager_url
- 'https://rubygems.org/'
+ "https://rubygems.org/"
end
def package_type
- 'gem'
+ "gem"
end
def package_name
- @package_name ||= package_name_from_method_call('name')
+ @package_name ||= package_name_from_method_call("name")
end
def package_url
diff --git a/app/models/blob_viewer/gitlab_ci_yml.rb b/app/models/blob_viewer/gitlab_ci_yml.rb
index 11228e620c9..f20484061bd 100644
--- a/app/models/blob_viewer/gitlab_ci_yml.rb
+++ b/app/models/blob_viewer/gitlab_ci_yml.rb
@@ -5,9 +5,9 @@ module BlobViewer
include ServerSide
include Auxiliary
- self.partial_name = 'gitlab_ci_yml'
- self.loading_partial_name = 'gitlab_ci_yml_loading'
- self.file_types = %i(gitlab_ci)
+ self.partial_name = "gitlab_ci_yml"
+ self.loading_partial_name = "gitlab_ci_yml_loading"
+ self.file_types = %i[gitlab_ci]
self.binary = false
def validation_message(opts)
diff --git a/app/models/blob_viewer/godeps_json.rb b/app/models/blob_viewer/godeps_json.rb
index 743c759aea5..bcddce7280d 100644
--- a/app/models/blob_viewer/godeps_json.rb
+++ b/app/models/blob_viewer/godeps_json.rb
@@ -4,14 +4,14 @@ module BlobViewer
class GodepsJson < DependencyManager
include Static
- self.file_types = %i(godeps_json)
+ self.file_types = %i[godeps_json]
def manager_name
- 'godep'
+ "godep"
end
def manager_url
- 'https://github.com/tools/godep'
+ "https://github.com/tools/godep"
end
end
end
diff --git a/app/models/blob_viewer/image.rb b/app/models/blob_viewer/image.rb
index 56e27839fca..92d7067dcd3 100644
--- a/app/models/blob_viewer/image.rb
+++ b/app/models/blob_viewer/image.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'image'
+ self.partial_name = "image"
self.extensions = UploaderHelper::IMAGE_EXT
self.binary = true
- self.switcher_icon = 'picture-o'
- self.switcher_title = 'image'
+ self.switcher_icon = "picture-o"
+ self.switcher_title = "image"
end
end
diff --git a/app/models/blob_viewer/license.rb b/app/models/blob_viewer/license.rb
index 3427227ad26..bf2d64686ec 100644
--- a/app/models/blob_viewer/license.rb
+++ b/app/models/blob_viewer/license.rb
@@ -5,8 +5,8 @@ module BlobViewer
include Auxiliary
include Static
- self.partial_name = 'license'
- self.file_types = %i(license)
+ self.partial_name = "license"
+ self.file_types = %i[license]
self.binary = false
def license
diff --git a/app/models/blob_viewer/markup.rb b/app/models/blob_viewer/markup.rb
index f525180048e..55e0ef3f0e7 100644
--- a/app/models/blob_viewer/markup.rb
+++ b/app/models/blob_viewer/markup.rb
@@ -5,9 +5,9 @@ module BlobViewer
include Rich
include ServerSide
- self.partial_name = 'markup'
+ self.partial_name = "markup"
self.extensions = Gitlab::MarkupHelper::EXTENSIONS
- self.file_types = %i(readme)
+ self.file_types = %i[readme]
self.binary = false
end
end
diff --git a/app/models/blob_viewer/notebook.rb b/app/models/blob_viewer/notebook.rb
index 57d6d802db3..e0e74520622 100644
--- a/app/models/blob_viewer/notebook.rb
+++ b/app/models/blob_viewer/notebook.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'notebook'
- self.extensions = %w(ipynb)
+ self.partial_name = "notebook"
+ self.extensions = %w[ipynb]
self.binary = false
- self.switcher_icon = 'file-text-o'
- self.switcher_title = 'notebook'
+ self.switcher_icon = "file-text-o"
+ self.switcher_title = "notebook"
end
end
diff --git a/app/models/blob_viewer/package_json.rb b/app/models/blob_viewer/package_json.rb
index 7cae60a74d6..c0e578bd2bc 100644
--- a/app/models/blob_viewer/package_json.rb
+++ b/app/models/blob_viewer/package_json.rb
@@ -4,22 +4,22 @@ module BlobViewer
class PackageJson < DependencyManager
include ServerSide
- self.file_types = %i(package_json)
+ self.file_types = %i[package_json]
def manager_name
- 'npm'
+ "npm"
end
def manager_url
- 'https://www.npmjs.com/'
+ "https://www.npmjs.com/"
end
def package_name
- @package_name ||= package_name_from_json('name')
+ @package_name ||= package_name_from_json("name")
end
def package_type
- private? ? 'private package' : super
+ private? ? "private package" : super
end
def package_url
@@ -29,11 +29,11 @@ module BlobViewer
private
def private?
- !!json_data['private']
+ !!json_data["private"]
end
def homepage
- url = json_data['homepage']
+ url = json_data["homepage"]
url if Gitlab::UrlSanitizer.valid?(url)
end
diff --git a/app/models/blob_viewer/pdf.rb b/app/models/blob_viewer/pdf.rb
index 2cf7752585c..04fafc2d1b8 100644
--- a/app/models/blob_viewer/pdf.rb
+++ b/app/models/blob_viewer/pdf.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'pdf'
- self.extensions = %w(pdf)
+ self.partial_name = "pdf"
+ self.extensions = %w[pdf]
self.binary = true
- self.switcher_icon = 'file-pdf-o'
- self.switcher_title = 'PDF'
+ self.switcher_icon = "file-pdf-o"
+ self.switcher_title = "PDF"
end
end
diff --git a/app/models/blob_viewer/podfile.rb b/app/models/blob_viewer/podfile.rb
index 73d714f48ca..9bf40c54408 100644
--- a/app/models/blob_viewer/podfile.rb
+++ b/app/models/blob_viewer/podfile.rb
@@ -4,14 +4,14 @@ module BlobViewer
class Podfile < DependencyManager
include Static
- self.file_types = %i(podfile)
+ self.file_types = %i[podfile]
def manager_name
- 'CocoaPods'
+ "CocoaPods"
end
def manager_url
- 'https://cocoapods.org/'
+ "https://cocoapods.org/"
end
end
end
diff --git a/app/models/blob_viewer/podspec.rb b/app/models/blob_viewer/podspec.rb
index 2303471583d..66779369aad 100644
--- a/app/models/blob_viewer/podspec.rb
+++ b/app/models/blob_viewer/podspec.rb
@@ -4,22 +4,22 @@ module BlobViewer
class Podspec < DependencyManager
include ServerSide
- self.file_types = %i(podspec)
+ self.file_types = %i[podspec]
def manager_name
- 'CocoaPods'
+ "CocoaPods"
end
def manager_url
- 'https://cocoapods.org/'
+ "https://cocoapods.org/"
end
def package_type
- 'pod'
+ "pod"
end
def package_name
- @package_name ||= package_name_from_method_call('name')
+ @package_name ||= package_name_from_method_call("name")
end
def package_url
diff --git a/app/models/blob_viewer/podspec_json.rb b/app/models/blob_viewer/podspec_json.rb
index d3f6ae269da..6efe88aa506 100644
--- a/app/models/blob_viewer/podspec_json.rb
+++ b/app/models/blob_viewer/podspec_json.rb
@@ -2,10 +2,10 @@
module BlobViewer
class PodspecJson < Podspec
- self.file_types = %i(podspec_json)
+ self.file_types = %i[podspec_json]
def package_name
- @package_name ||= package_name_from_json('name')
+ @package_name ||= package_name_from_json("name")
end
end
end
diff --git a/app/models/blob_viewer/readme.rb b/app/models/blob_viewer/readme.rb
index f1a5c6a6acc..d93baa9de7b 100644
--- a/app/models/blob_viewer/readme.rb
+++ b/app/models/blob_viewer/readme.rb
@@ -5,8 +5,8 @@ module BlobViewer
include Auxiliary
include Static
- self.partial_name = 'readme'
- self.file_types = %i(readme)
+ self.partial_name = "readme"
+ self.file_types = %i[readme]
self.binary = false
def visible_to?(current_user)
diff --git a/app/models/blob_viewer/requirements_txt.rb b/app/models/blob_viewer/requirements_txt.rb
index 58161e83493..dacd2bc842c 100644
--- a/app/models/blob_viewer/requirements_txt.rb
+++ b/app/models/blob_viewer/requirements_txt.rb
@@ -4,14 +4,14 @@ module BlobViewer
class RequirementsTxt < DependencyManager
include Static
- self.file_types = %i(requirements_txt)
+ self.file_types = %i[requirements_txt]
def manager_name
- 'pip'
+ "pip"
end
def manager_url
- 'https://pip.pypa.io/'
+ "https://pip.pypa.io/"
end
end
end
diff --git a/app/models/blob_viewer/rich.rb b/app/models/blob_viewer/rich.rb
index 0f66a672102..a3b690f940e 100644
--- a/app/models/blob_viewer/rich.rb
+++ b/app/models/blob_viewer/rich.rb
@@ -6,8 +6,8 @@ module BlobViewer
included do
self.type = :rich
- self.switcher_icon = 'file-text-o'
- self.switcher_title = 'rendered file'
+ self.switcher_icon = "file-text-o"
+ self.switcher_title = "rendered file"
end
end
end
diff --git a/app/models/blob_viewer/route_map.rb b/app/models/blob_viewer/route_map.rb
index 6731536dfe1..4a6e3a2fac7 100644
--- a/app/models/blob_viewer/route_map.rb
+++ b/app/models/blob_viewer/route_map.rb
@@ -5,9 +5,9 @@ module BlobViewer
include ServerSide
include Auxiliary
- self.partial_name = 'route_map'
- self.loading_partial_name = 'route_map_loading'
- self.file_types = %i(route_map)
+ self.partial_name = "route_map"
+ self.loading_partial_name = "route_map_loading"
+ self.file_types = %i[route_map]
self.binary = false
def validation_message
diff --git a/app/models/blob_viewer/simple.rb b/app/models/blob_viewer/simple.rb
index c176784df46..47874789e5e 100644
--- a/app/models/blob_viewer/simple.rb
+++ b/app/models/blob_viewer/simple.rb
@@ -6,8 +6,8 @@ module BlobViewer
included do
self.type = :simple
- self.switcher_icon = 'code'
- self.switcher_title = 'source'
+ self.switcher_icon = "code"
+ self.switcher_title = "source"
end
end
end
diff --git a/app/models/blob_viewer/sketch.rb b/app/models/blob_viewer/sketch.rb
index 659ab11f30b..89745f1a7f1 100644
--- a/app/models/blob_viewer/sketch.rb
+++ b/app/models/blob_viewer/sketch.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'sketch'
- self.extensions = %w(sketch)
+ self.partial_name = "sketch"
+ self.extensions = %w[sketch]
self.binary = true
- self.switcher_icon = 'file-image-o'
- self.switcher_title = 'preview'
+ self.switcher_icon = "file-image-o"
+ self.switcher_title = "preview"
end
end
diff --git a/app/models/blob_viewer/svg.rb b/app/models/blob_viewer/svg.rb
index 454c6a57568..e1914c48acd 100644
--- a/app/models/blob_viewer/svg.rb
+++ b/app/models/blob_viewer/svg.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ServerSide
- self.partial_name = 'svg'
- self.extensions = %w(svg)
+ self.partial_name = "svg"
+ self.extensions = %w[svg]
self.binary = false
- self.switcher_icon = 'picture-o'
- self.switcher_title = 'image'
+ self.switcher_icon = "picture-o"
+ self.switcher_title = "image"
end
end
diff --git a/app/models/blob_viewer/text.rb b/app/models/blob_viewer/text.rb
index e0c586a6680..d24ad376694 100644
--- a/app/models/blob_viewer/text.rb
+++ b/app/models/blob_viewer/text.rb
@@ -5,7 +5,7 @@ module BlobViewer
include Simple
include ServerSide
- self.partial_name = 'text'
+ self.partial_name = "text"
self.binary = false
self.collapse_limit = 1.megabyte
self.size_limit = 10.megabytes
diff --git a/app/models/blob_viewer/video.rb b/app/models/blob_viewer/video.rb
index 48bb2a13518..09e43d16a4f 100644
--- a/app/models/blob_viewer/video.rb
+++ b/app/models/blob_viewer/video.rb
@@ -5,10 +5,10 @@ module BlobViewer
include Rich
include ClientSide
- self.partial_name = 'video'
+ self.partial_name = "video"
self.extensions = UploaderHelper::VIDEO_EXT
self.binary = true
- self.switcher_icon = 'film'
- self.switcher_title = 'video'
+ self.switcher_icon = "film"
+ self.switcher_title = "video"
end
end
diff --git a/app/models/blob_viewer/yarn_lock.rb b/app/models/blob_viewer/yarn_lock.rb
index 196d9f96f23..99eb99939b6 100644
--- a/app/models/blob_viewer/yarn_lock.rb
+++ b/app/models/blob_viewer/yarn_lock.rb
@@ -4,14 +4,14 @@ module BlobViewer
class YarnLock < DependencyManager
include Static
- self.file_types = %i(yarn_lock)
+ self.file_types = %i[yarn_lock]
def manager_name
- 'Yarn'
+ "Yarn"
end
def manager_url
- 'https://yarnpkg.com/'
+ "https://yarnpkg.com/"
end
end
end
diff --git a/app/models/board_group_recent_visit.rb b/app/models/board_group_recent_visit.rb
index 92abbb67222..d9f24a877ff 100644
--- a/app/models/board_group_recent_visit.rb
+++ b/app/models/board_group_recent_visit.rb
@@ -10,7 +10,7 @@ class BoardGroupRecentVisit < ActiveRecord::Base
validates :group, presence: true
validates :board, presence: true
- scope :by_user_group, -> (user, group) { where(user: user, group: group).order(:updated_at) }
+ scope :by_user_group, ->(user, group) { where(user: user, group: group).order(:updated_at) }
def self.visited!(user, board)
visit = find_or_create_by(user: user, group: board.group, board: board)
diff --git a/app/models/board_project_recent_visit.rb b/app/models/board_project_recent_visit.rb
index 7cffff906d8..963720f349f 100644
--- a/app/models/board_project_recent_visit.rb
+++ b/app/models/board_project_recent_visit.rb
@@ -10,7 +10,7 @@ class BoardProjectRecentVisit < ActiveRecord::Base
validates :project, presence: true
validates :board, presence: true
- scope :by_user_project, -> (user, project) { where(user: user, project: project).order(:updated_at) }
+ scope :by_user_project, ->(user, project) { where(user: user, project: project).order(:updated_at) }
def self.visited!(user, board)
visit = find_or_create_by(user: user, project: board.project, board: board)
diff --git a/app/models/broadcast_message.rb b/app/models/broadcast_message.rb
index 2d237383e60..8ee663b5e01 100644
--- a/app/models/broadcast_message.rb
+++ b/app/models/broadcast_message.rb
@@ -13,19 +13,19 @@ class BroadcastMessage < ActiveRecord::Base
validates :color, allow_blank: true, color: true
validates :font, allow_blank: true, color: true
- default_value_for :color, '#E75E40'
- default_value_for :font, '#FFFFFF'
+ default_value_for :color, "#E75E40"
+ default_value_for :font, "#FFFFFF"
- CACHE_KEY = 'broadcast_message_current_json'.freeze
- LEGACY_CACHE_KEY = 'broadcast_message_current'.freeze
+ CACHE_KEY = "broadcast_message_current_json"
+ LEGACY_CACHE_KEY = "broadcast_message_current"
after_commit :flush_redis_cache
def self.current
- messages = cache.fetch(CACHE_KEY, as: BroadcastMessage, expires_in: cache_expires_in) do
+ messages = cache.fetch(CACHE_KEY, as: BroadcastMessage, expires_in: cache_expires_in) {
remove_legacy_cache_key
current_and_future_messages
- end
+ }
return [] unless messages&.present?
@@ -39,7 +39,7 @@ class BroadcastMessage < ActiveRecord::Base
end
def self.current_and_future_messages
- where('ends_at > :now', now: Time.zone.now).order_id_asc
+ where("ends_at > :now", now: Time.zone.now).order_id_asc
end
def self.cache
diff --git a/app/models/chat_name.rb b/app/models/chat_name.rb
index 03b0af53046..8a97134c6a5 100644
--- a/app/models/chat_name.rb
+++ b/app/models/chat_name.rb
@@ -11,8 +11,8 @@ class ChatName < ActiveRecord::Base
validates :team_id, presence: true
validates :chat_id, presence: true
- validates :user_id, uniqueness: { scope: [:service_id] }
- validates :chat_id, uniqueness: { scope: [:service_id, :team_id] }
+ validates :user_id, uniqueness: {scope: [:service_id]}
+ validates :chat_id, uniqueness: {scope: [:service_id, :team_id]}
# Updates the "last_used_timestamp" but only if it wasn't already updated
# recently.
diff --git a/app/models/ci/artifact_blob.rb b/app/models/ci/artifact_blob.rb
index d87d6a5cb2f..32809bbd1a3 100644
--- a/app/models/ci/artifact_blob.rb
+++ b/app/models/ci/artifact_blob.rb
@@ -21,7 +21,7 @@ module Ci
def size
entry.metadata[:size]
end
- alias_method :external_size, :size
+ alias external_size size
def data
"Build artifact #{path}"
@@ -38,13 +38,13 @@ module Ci
def external_url(project, job)
return unless external_link?(job)
- url_project_path = project.full_path.partition('/').last
+ url_project_path = project.full_path.partition("/").last
artifact_path = [
- '-', url_project_path, '-',
- 'jobs', job.id,
- 'artifacts', path
- ].join('/')
+ "-", url_project_path, "-",
+ "jobs", job.id,
+ "artifacts", path,
+ ].join("/")
"#{project.pages_group_url}/#{artifact_path}"
end
diff --git a/app/models/ci/bridge.rb b/app/models/ci/bridge.rb
index 5450d40ea95..5659c0a2557 100644
--- a/app/models/ci/bridge.rb
+++ b/app/models/ci/bridge.rb
@@ -49,7 +49,7 @@ module Ci
end
def to_partial_path
- 'projects/generic_commit_statuses/generic_commit_status'
+ "projects/generic_commit_statuses/generic_commit_status"
end
end
end
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index c902e49ee6d..e1fe32a40a7 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -22,23 +22,23 @@ module Ci
belongs_to :project, inverse_of: :builds
belongs_to :runner
belongs_to :trigger_request
- belongs_to :erased_by, class_name: 'User'
+ belongs_to :erased_by, class_name: "User"
RUNNER_FEATURES = {
- upload_multiple_artifacts: -> (build) { build.publishes_artifacts_reports? }
+ upload_multiple_artifacts: ->(build) { build.publishes_artifacts_reports? },
}.freeze
- has_one :deployment, as: :deployable, class_name: 'Deployment'
- has_many :trace_sections, class_name: 'Ci::BuildTraceSection'
- has_many :trace_chunks, class_name: 'Ci::BuildTraceChunk', foreign_key: :build_id
+ has_one :deployment, as: :deployable, class_name: "Deployment"
+ has_many :trace_sections, class_name: "Ci::BuildTraceSection"
+ has_many :trace_chunks, class_name: "Ci::BuildTraceChunk", foreign_key: :build_id
- has_many :job_artifacts, class_name: 'Ci::JobArtifact', foreign_key: :job_id, dependent: :destroy, inverse_of: :job # rubocop:disable Cop/ActiveRecordDependent
+ has_many :job_artifacts, class_name: "Ci::JobArtifact", foreign_key: :job_id, dependent: :destroy, inverse_of: :job # rubocop:disable Cop/ActiveRecordDependent
Ci::JobArtifact.file_types.each do |key, value|
- has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: 'Ci::JobArtifact', inverse_of: :job, foreign_key: :job_id
+ has_one :"job_artifacts_#{key}", -> { where(file_type: value) }, class_name: "Ci::JobArtifact", inverse_of: :job, foreign_key: :job_id
end
- has_one :runner_session, class_name: 'Ci::BuildRunnerSession', validate: true, inverse_of: :build
+ has_one :runner_session, class_name: "Ci::BuildRunnerSession", validate: true, inverse_of: :build
accepts_nested_attributes_for :runner_session
@@ -77,26 +77,26 @@ module Ci
validates :coverage, numericality: true, allow_blank: true
validates :ref, presence: true
- scope :unstarted, ->() { where(runner_id: nil) }
- scope :ignore_failures, ->() { where(allow_failure: false) }
- scope :with_artifacts_archive, ->() do
- where('(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)',
- '', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').archive)
+ scope :unstarted, -> { where(runner_id: nil) }
+ scope :ignore_failures, -> { where(allow_failure: false) }
+ scope :with_artifacts_archive, -> do
+ where("(artifacts_file IS NOT NULL AND artifacts_file <> ?) OR EXISTS (?)",
+ "", Ci::JobArtifact.select(1).where("ci_builds.id = ci_job_artifacts.job_id").archive)
end
scope :with_existing_job_artifacts, ->(query) do
- where('EXISTS (?)', ::Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').merge(query))
+ where("EXISTS (?)", ::Ci::JobArtifact.select(1).where("ci_builds.id = ci_job_artifacts.job_id").merge(query))
end
- scope :with_archived_trace, ->() do
+ scope :with_archived_trace, -> do
with_existing_job_artifacts(Ci::JobArtifact.trace)
end
- scope :without_archived_trace, ->() do
- where('NOT EXISTS (?)', Ci::JobArtifact.select(1).where('ci_builds.id = ci_job_artifacts.job_id').trace)
+ scope :without_archived_trace, -> do
+ where("NOT EXISTS (?)", Ci::JobArtifact.select(1).where("ci_builds.id = ci_job_artifacts.job_id").trace)
end
- scope :with_test_reports, ->() do
+ scope :with_test_reports, -> do
with_existing_job_artifacts(Ci::JobArtifact.test_reports)
.eager_load_job_artifacts
end
@@ -105,20 +105,20 @@ module Ci
scope :with_artifacts_stored_locally, -> { with_artifacts_archive.where(artifacts_file_store: [nil, LegacyArtifactUploader::Store::LOCAL]) }
scope :with_archived_trace_stored_locally, -> { with_archived_trace.where(artifacts_file_store: [nil, LegacyArtifactUploader::Store::LOCAL]) }
- scope :with_artifacts_not_expired, ->() { with_artifacts_archive.where('artifacts_expire_at IS NULL OR artifacts_expire_at > ?', Time.now) }
- scope :with_expired_artifacts, ->() { with_artifacts_archive.where('artifacts_expire_at < ?', Time.now) }
- scope :last_month, ->() { where('created_at > ?', Date.today - 1.month) }
- scope :manual_actions, ->() { where(when: :manual, status: COMPLETED_STATUSES + %i[manual]) }
- scope :scheduled_actions, ->() { where(when: :delayed, status: COMPLETED_STATUSES + %i[scheduled]) }
+ scope :with_artifacts_not_expired, -> { with_artifacts_archive.where("artifacts_expire_at IS NULL OR artifacts_expire_at > ?", Time.now) }
+ scope :with_expired_artifacts, -> { with_artifacts_archive.where("artifacts_expire_at < ?", Time.now) }
+ scope :last_month, -> { where("created_at > ?", Date.today - 1.month) }
+ scope :manual_actions, -> { where(when: :manual, status: COMPLETED_STATUSES + %i[manual]) }
+ scope :scheduled_actions, -> { where(when: :delayed, status: COMPLETED_STATUSES + %i[scheduled]) }
scope :ref_protected, -> { where(protected: true) }
- scope :with_live_trace, -> { where('EXISTS (?)', Ci::BuildTraceChunk.where('ci_builds.id = ci_build_trace_chunks.build_id').select(1)) }
+ scope :with_live_trace, -> { where("EXISTS (?)", Ci::BuildTraceChunk.where("ci_builds.id = ci_build_trace_chunks.build_id").select(1)) }
- scope :matches_tag_ids, -> (tag_ids) do
+ scope :matches_tag_ids, ->(tag_ids) do
matcher = ::ActsAsTaggableOn::Tagging
.where(taggable_type: CommitStatus.name)
- .where(context: 'tags')
- .where('taggable_id = ci_builds.id')
- .where.not(tag_id: tag_ids).select('1')
+ .where(context: "tags")
+ .where("taggable_id = ci_builds.id")
+ .where.not(tag_id: tag_ids).select("1")
where("NOT EXISTS (?)", matcher)
end
@@ -126,8 +126,8 @@ module Ci
scope :with_any_tags, -> do
matcher = ::ActsAsTaggableOn::Tagging
.where(taggable_type: CommitStatus.name)
- .where(context: 'tags')
- .where('taggable_id = ci_builds.id').select('1')
+ .where(context: "tags")
+ .where("taggable_id = ci_builds.id").select("1")
where("EXISTS (?)", matcher)
end
@@ -154,11 +154,11 @@ module Ci
# This is needed for url_for to work,
# as the controller is JobsController
def model_name
- ActiveModel::Name.new(self, nil, 'job')
+ ActiveModel::Name.new(self, nil, "job")
end
def first_pending
- pending.unstarted.order('created_at ASC').first
+ pending.unstarted.order("created_at ASC").first
end
def retry(build, current_user)
@@ -239,7 +239,7 @@ module Ci
begin
build.deployment.drop!
rescue => e
- Gitlab::Sentry.track_exception(e, extra: { build_id: build.id })
+ Gitlab::Sentry.track_exception(e, extra: {build_id: build.id})
end
true
@@ -286,7 +286,7 @@ module Ci
def pages_generator?
Gitlab.config.pages.enabled &&
- self.name == 'pages'
+ name == "pages"
end
def archived?
@@ -301,7 +301,7 @@ module Ci
end
def schedulable?
- self.when == 'delayed' && options[:start_in].present?
+ self.when == "delayed" && options[:start_in].present?
end
def options_scheduled_at
@@ -329,7 +329,7 @@ module Ci
end
def retries_count
- pipeline.builds.retried.where(name: self.name).count
+ pipeline.builds.retried.where(name: name).count
end
def retries_max
@@ -337,13 +337,13 @@ module Ci
end
def retry_when
- normalized_retry.fetch(:when, ['always'])
+ normalized_retry.fetch(:when, ["always"])
end
def retry_failure?
return false if retries_max.zero? || retries_count >= retries_max
- retry_when.include?('always') || retry_when.include?(failure_reason.to_s)
+ retry_when.include?("always") || retry_when.include?(failure_reason.to_s)
end
def latest?
@@ -363,19 +363,19 @@ module Ci
end
def starts_environment?
- has_environment? && self.environment_action == 'start'
+ has_environment? && environment_action == "start"
end
def stops_environment?
- has_environment? && self.environment_action == 'stop'
+ has_environment? && environment_action == "stop"
end
def environment_action
- self.options.fetch(:environment, {}).fetch(:action, 'start') if self.options
+ options&.fetch(:environment, {})&.fetch(:action, "start")
end
def has_deployment?
- !!self.deployment
+ !!deployment
end
def outdated_deployment?
@@ -384,10 +384,10 @@ module Ci
def depends_on_builds
# Get builds of the same type
- latest_builds = self.pipeline.builds.latest
+ latest_builds = pipeline.builds.latest
# Return builds from previous stages
- latest_builds.where('stage_idx < ?', stage_idx)
+ latest_builds.where("stage_idx < ?", stage_idx)
end
def triggered_by?(current_user)
@@ -460,7 +460,7 @@ module Ci
end
def features
- { trace_sections: true }
+ {trace_sections: true}
end
def merge_request
@@ -570,7 +570,8 @@ module Ci
metadata = Gitlab::Ci::Build::Artifacts::Metadata.new(
metadata_stream,
path,
- **options)
+ **options
+ )
metadata.to_entry
end
@@ -596,7 +597,7 @@ module Ci
end
def erased?
- !self.erased_at.nil?
+ !erased_at.nil?
end
def artifacts_expired?
@@ -619,8 +620,8 @@ module Ci
end
def keep_artifacts!
- self.update(artifacts_expire_at: nil)
- self.job_artifacts.update_all(expire_at: nil)
+ update(artifacts_expire_at: nil)
+ job_artifacts.update_all(expire_at: nil)
end
def artifacts_file_for_type(type)
@@ -638,10 +639,10 @@ module Ci
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables if user.blank?
- variables.append(key: 'GITLAB_USER_ID', value: user.id.to_s)
- variables.append(key: 'GITLAB_USER_EMAIL', value: user.email)
- variables.append(key: 'GITLAB_USER_LOGIN', value: user.username)
- variables.append(key: 'GITLAB_USER_NAME', value: user.name)
+ variables.append(key: "GITLAB_USER_ID", value: user.id.to_s)
+ variables.append(key: "GITLAB_USER_EMAIL", value: user.email)
+ variables.append(key: "GITLAB_USER_LOGIN", value: user.username)
+ variables.append(key: "GITLAB_USER_NAME", value: user.name)
end
end
@@ -657,7 +658,7 @@ module Ci
def steps
[Gitlab::Ci::Build::Step.from_commands(self),
- Gitlab::Ci::Build::Step.from_after_script(self)].compact
+ Gitlab::Ci::Build::Step.from_after_script(self),].compact
end
def image
@@ -673,7 +674,8 @@ module Ci
if cache && project.jobs_cache_index
cache = cache.merge(
- key: "#{cache[:key]}-#{project.jobs_cache_index}")
+ key: "#{cache[:key]}-#{project.jobs_cache_index}"
+ )
end
[cache]
@@ -700,7 +702,7 @@ module Ci
end
def has_valid_build_dependencies?
- return true if Feature.enabled?('ci_disable_validates_dependencies')
+ return true if Feature.enabled?("ci_disable_validates_dependencies")
dependencies.all?(&:valid_dependency?)
end
@@ -714,9 +716,9 @@ module Ci
def runner_required_feature_names
strong_memoize(:runner_required_feature_names) do
- RUNNER_FEATURES.select do |feature, method|
+ RUNNER_FEATURES.select { |feature, method|
method.call(self)
- end.keys
+ }.keys
end
end
@@ -807,14 +809,14 @@ module Ci
end
def update_erased!(user = nil)
- self.update(erased_by: user, erased_at: Time.now, artifacts_expire_at: nil)
+ update(erased_by: user, erased_at: Time.now, artifacts_expire_at: nil)
end
def unscoped_project
@unscoped_project ||= Project.unscoped.find_by(id: project_id)
end
- CI_REGISTRY_USER = 'gitlab-ci-token'.freeze
+ CI_REGISTRY_USER = "gitlab-ci-token"
def persisted_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
@@ -822,56 +824,56 @@ module Ci
variables
.concat(pipeline.persisted_variables)
- .append(key: 'CI_JOB_ID', value: id.to_s)
- .append(key: 'CI_JOB_URL', value: Gitlab::Routing.url_helpers.project_job_url(project, self))
- .append(key: 'CI_JOB_TOKEN', value: token.to_s, public: false)
- .append(key: 'CI_BUILD_ID', value: id.to_s)
- .append(key: 'CI_BUILD_TOKEN', value: token.to_s, public: false)
- .append(key: 'CI_REGISTRY_USER', value: CI_REGISTRY_USER)
- .append(key: 'CI_REGISTRY_PASSWORD', value: token.to_s, public: false)
- .append(key: 'CI_REPOSITORY_URL', value: repo_url.to_s, public: false)
+ .append(key: "CI_JOB_ID", value: id.to_s)
+ .append(key: "CI_JOB_URL", value: Gitlab::Routing.url_helpers.project_job_url(project, self))
+ .append(key: "CI_JOB_TOKEN", value: token.to_s, public: false)
+ .append(key: "CI_BUILD_ID", value: id.to_s)
+ .append(key: "CI_BUILD_TOKEN", value: token.to_s, public: false)
+ .append(key: "CI_REGISTRY_USER", value: CI_REGISTRY_USER)
+ .append(key: "CI_REGISTRY_PASSWORD", value: token.to_s, public: false)
+ .append(key: "CI_REPOSITORY_URL", value: repo_url.to_s, public: false)
.concat(deploy_token_variables)
end
end
def predefined_variables # rubocop:disable Metrics/AbcSize
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI', value: 'true')
- variables.append(key: 'GITLAB_CI', value: 'true')
- variables.append(key: 'GITLAB_FEATURES', value: project.licensed_features.join(','))
- variables.append(key: 'CI_SERVER_NAME', value: 'GitLab')
- variables.append(key: 'CI_SERVER_VERSION', value: Gitlab::VERSION)
- variables.append(key: 'CI_SERVER_VERSION_MAJOR', value: Gitlab.version_info.major.to_s)
- variables.append(key: 'CI_SERVER_VERSION_MINOR', value: Gitlab.version_info.minor.to_s)
- variables.append(key: 'CI_SERVER_VERSION_PATCH', value: Gitlab.version_info.patch.to_s)
- variables.append(key: 'CI_SERVER_REVISION', value: Gitlab.revision)
- variables.append(key: 'CI_JOB_NAME', value: name)
- variables.append(key: 'CI_JOB_STAGE', value: stage)
- variables.append(key: 'CI_COMMIT_SHA', value: sha)
- variables.append(key: 'CI_COMMIT_SHORT_SHA', value: short_sha)
- variables.append(key: 'CI_COMMIT_BEFORE_SHA', value: before_sha)
- variables.append(key: 'CI_COMMIT_REF_NAME', value: ref)
- variables.append(key: 'CI_COMMIT_REF_SLUG', value: ref_slug)
+ variables.append(key: "CI", value: "true")
+ variables.append(key: "GITLAB_CI", value: "true")
+ variables.append(key: "GITLAB_FEATURES", value: project.licensed_features.join(","))
+ variables.append(key: "CI_SERVER_NAME", value: "GitLab")
+ variables.append(key: "CI_SERVER_VERSION", value: Gitlab::VERSION)
+ variables.append(key: "CI_SERVER_VERSION_MAJOR", value: Gitlab.version_info.major.to_s)
+ variables.append(key: "CI_SERVER_VERSION_MINOR", value: Gitlab.version_info.minor.to_s)
+ variables.append(key: "CI_SERVER_VERSION_PATCH", value: Gitlab.version_info.patch.to_s)
+ variables.append(key: "CI_SERVER_REVISION", value: Gitlab.revision)
+ variables.append(key: "CI_JOB_NAME", value: name)
+ variables.append(key: "CI_JOB_STAGE", value: stage)
+ variables.append(key: "CI_COMMIT_SHA", value: sha)
+ variables.append(key: "CI_COMMIT_SHORT_SHA", value: short_sha)
+ variables.append(key: "CI_COMMIT_BEFORE_SHA", value: before_sha)
+ variables.append(key: "CI_COMMIT_REF_NAME", value: ref)
+ variables.append(key: "CI_COMMIT_REF_SLUG", value: ref_slug)
variables.append(key: "CI_COMMIT_TAG", value: ref) if tag?
- variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request
- variables.append(key: "CI_JOB_MANUAL", value: 'true') if action?
- variables.append(key: "CI_NODE_INDEX", value: self.options[:instance].to_s) if self.options&.include?(:instance)
- variables.append(key: "CI_NODE_TOTAL", value: (self.options&.dig(:parallel) || 1).to_s)
+ variables.append(key: "CI_PIPELINE_TRIGGERED", value: "true") if trigger_request
+ variables.append(key: "CI_JOB_MANUAL", value: "true") if action?
+ variables.append(key: "CI_NODE_INDEX", value: options[:instance].to_s) if options&.include?(:instance)
+ variables.append(key: "CI_NODE_TOTAL", value: (options&.dig(:parallel) || 1).to_s)
variables.concat(legacy_variables)
end
end
def legacy_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_BUILD_REF', value: sha)
- variables.append(key: 'CI_BUILD_BEFORE_SHA', value: before_sha)
- variables.append(key: 'CI_BUILD_REF_NAME', value: ref)
- variables.append(key: 'CI_BUILD_REF_SLUG', value: ref_slug)
- variables.append(key: 'CI_BUILD_NAME', value: name)
- variables.append(key: 'CI_BUILD_STAGE', value: stage)
+ variables.append(key: "CI_BUILD_REF", value: sha)
+ variables.append(key: "CI_BUILD_BEFORE_SHA", value: before_sha)
+ variables.append(key: "CI_BUILD_REF_NAME", value: ref)
+ variables.append(key: "CI_BUILD_REF_SLUG", value: ref_slug)
+ variables.append(key: "CI_BUILD_NAME", value: name)
+ variables.append(key: "CI_BUILD_STAGE", value: stage)
variables.append(key: "CI_BUILD_TAG", value: ref) if tag?
- variables.append(key: "CI_BUILD_TRIGGERED", value: 'true') if trigger_request
- variables.append(key: "CI_BUILD_MANUAL", value: 'true') if action?
+ variables.append(key: "CI_BUILD_TRIGGERED", value: "true") if trigger_request
+ variables.append(key: "CI_BUILD_MANUAL", value: "true") if action?
end
end
@@ -884,7 +886,7 @@ module Ci
# Here we're passing unexpanded environment_url for runner to expand,
# and we need to make sure that CI_ENVIRONMENT_NAME and
# CI_ENVIRONMENT_SLUG so on are available for the URL be expanded.
- variables.append(key: 'CI_ENVIRONMENT_URL', value: environment_url) if environment_url
+ variables.append(key: "CI_ENVIRONMENT_URL", value: environment_url) if environment_url
end
end
@@ -892,8 +894,8 @@ module Ci
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless gitlab_deploy_token
- variables.append(key: 'CI_DEPLOY_USER', value: gitlab_deploy_token.username)
- variables.append(key: 'CI_DEPLOY_PASSWORD', value: gitlab_deploy_token.token, public: false)
+ variables.append(key: "CI_DEPLOY_USER", value: gitlab_deploy_token.username)
+ variables.append(key: "CI_DEPLOY_PASSWORD", value: gitlab_deploy_token.token, public: false)
end
end
@@ -909,7 +911,7 @@ module Ci
def normalized_retry
strong_memoize(:normalized_retry) do
value = options&.dig(:retry)
- value = value.is_a?(Integer) ? { max: value } : value.to_h
+ value = value.is_a?(Integer) ? {max: value} : value.to_h
value.with_indifferent_access
end
end
diff --git a/app/models/ci/build_metadata.rb b/app/models/ci/build_metadata.rb
index cd8eb774cf5..ff4a5bfaa7c 100644
--- a/app/models/ci/build_metadata.rb
+++ b/app/models/ci/build_metadata.rb
@@ -8,9 +8,9 @@ module Ci
include Presentable
include ChronicDurationAttribute
- self.table_name = 'ci_builds_metadata'
+ self.table_name = "ci_builds_metadata"
- belongs_to :build, class_name: 'CommitStatus'
+ belongs_to :build, class_name: "CommitStatus"
belongs_to :project
before_create :set_build_project
@@ -23,9 +23,9 @@ module Ci
chronic_duration_attr_reader :timeout_human_readable, :timeout
enum timeout_source: {
- unknown_timeout_source: 1,
- project_timeout_source: 2,
- runner_timeout_source: 3
+ unknown_timeout_source: 1,
+ project_timeout_source: 2,
+ runner_timeout_source: 3,
}
def update_timeout_state
@@ -41,7 +41,7 @@ module Ci
private
def set_build_project
- self.project_id ||= self.build.project_id
+ self.project_id ||= build.project_id
end
end
end
diff --git a/app/models/ci/build_runner_session.rb b/app/models/ci/build_runner_session.rb
index 457d7eeab6a..bda127b930e 100644
--- a/app/models/ci/build_runner_session.rb
+++ b/app/models/ci/build_runner_session.rb
@@ -6,21 +6,21 @@ module Ci
class BuildRunnerSession < ActiveRecord::Base
extend Gitlab::Ci::Model
- self.table_name = 'ci_builds_runner_session'
+ self.table_name = "ci_builds_runner_session"
- belongs_to :build, class_name: 'Ci::Build', inverse_of: :runner_session
+ belongs_to :build, class_name: "Ci::Build", inverse_of: :runner_session
validates :build, presence: true
- validates :url, url: { protocols: %w(https) }
+ validates :url, url: {protocols: %w[https]}
def terminal_specification
return {} unless url.present?
{
- subprotocols: ['terminal.gitlab.com'].freeze,
+ subprotocols: ["terminal.gitlab.com"].freeze,
url: "#{url}/exec".sub("https://", "wss://"),
- headers: { Authorization: [authorization.presence] }.compact,
- ca_pem: certificate.presence
+ headers: {Authorization: [authorization.presence]}.compact,
+ ca_pem: certificate.presence,
}
end
end
diff --git a/app/models/ci/build_trace_chunk.rb b/app/models/ci/build_trace_chunk.rb
index 75017f224a0..dd02e884af8 100644
--- a/app/models/ci/build_trace_chunk.rb
+++ b/app/models/ci/build_trace_chunk.rb
@@ -22,12 +22,12 @@ module Ci
enum data_store: {
redis: 1,
database: 2,
- fog: 3
+ fog: 3,
}
class << self
def all_stores
- @all_stores ||= self.data_stores.keys
+ @all_stores ||= data_stores.keys
end
def persistable_store
@@ -67,16 +67,16 @@ module Ci
end
def truncate(offset = 0)
- raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0
+ raise ArgumentError, "Offset is out of range" if offset > size || offset < 0
return if offset == size # Skip the following process as it doesn't affect anything
- self.append("", offset)
+ append("", offset)
end
def append(new_data, offset)
- raise ArgumentError, 'New data is missing' unless new_data
- raise ArgumentError, 'Offset is out of range' if offset > size || offset < 0
- raise ArgumentError, 'Chunk size overflow' if CHUNK_SIZE < (offset + new_data.bytesize)
+ raise ArgumentError, "New data is missing" unless new_data
+ raise ArgumentError, "Offset is out of range" if offset > size || offset < 0
+ raise ArgumentError, "Chunk size overflow" if CHUNK_SIZE < (offset + new_data.bytesize)
in_lock(*lock_params) do # Write operation is atomic
unsafe_set_data!(data.byteslice(0, offset) + new_data)
@@ -115,7 +115,7 @@ module Ci
current_data = get_data
unless current_data&.bytesize.to_i == CHUNK_SIZE
- raise FailedToPersistDataError, 'Data is not fulfilled in a bucket'
+ raise FailedToPersistDataError, "Data is not fulfilled in a bucket"
end
old_store_class = self.class.get_store_class(data_store)
@@ -134,7 +134,7 @@ module Ci
end
def unsafe_set_data!(value)
- raise ArgumentError, 'New data size exceeds chunk size' if value.bytesize > CHUNK_SIZE
+ raise ArgumentError, "New data size exceeds chunk size" if value.bytesize > CHUNK_SIZE
self.class.get_store_class(data_store).set_data(self, value)
@data = value
@@ -158,9 +158,9 @@ module Ci
def lock_params
["trace_write:#{build_id}:chunks:#{chunk_index}",
- { ttl: WRITE_LOCK_TTL,
- retries: WRITE_LOCK_RETRY,
- sleep_sec: WRITE_LOCK_SLEEP }]
+ {ttl: WRITE_LOCK_TTL,
+ retries: WRITE_LOCK_RETRY,
+ sleep_sec: WRITE_LOCK_SLEEP,},]
end
end
end
diff --git a/app/models/ci/build_trace_section.rb b/app/models/ci/build_trace_section.rb
index a4bee59c83b..f19cd721f99 100644
--- a/app/models/ci/build_trace_section.rb
+++ b/app/models/ci/build_trace_section.rb
@@ -4,9 +4,9 @@ module Ci
class BuildTraceSection < ActiveRecord::Base
extend Gitlab::Ci::Model
- belongs_to :build, class_name: 'Ci::Build'
+ belongs_to :build, class_name: "Ci::Build"
belongs_to :project
- belongs_to :section_name, class_name: 'Ci::BuildTraceSectionName'
+ belongs_to :section_name, class_name: "Ci::BuildTraceSectionName"
validates :section_name, :build, :project, presence: true, allow_blank: false
end
diff --git a/app/models/ci/build_trace_section_name.rb b/app/models/ci/build_trace_section_name.rb
index cbdf3c4b673..8c6834f6514 100644
--- a/app/models/ci/build_trace_section_name.rb
+++ b/app/models/ci/build_trace_section_name.rb
@@ -5,9 +5,9 @@ module Ci
extend Gitlab::Ci::Model
belongs_to :project
- has_many :trace_sections, class_name: 'Ci::BuildTraceSection', foreign_key: :section_name_id
+ has_many :trace_sections, class_name: "Ci::BuildTraceSection", foreign_key: :section_name_id
validates :name, :project, presence: true, allow_blank: false
- validates :name, uniqueness: { scope: :project_id }
+ validates :name, uniqueness: {scope: :project_id}
end
end
diff --git a/app/models/ci/group.rb b/app/models/ci/group.rb
index 9b2c3c807ac..d601ea120d9 100644
--- a/app/models/ci/group.rb
+++ b/app/models/ci/group.rb
@@ -37,7 +37,7 @@ module Ci
stage.statuses.ordered.latest
.sort_by(&:sortable_name).group_by(&:group_name)
.map do |group_name, grouped_statuses|
- self.new(stage, name: group_name, jobs: grouped_statuses)
+ new(stage, name: group_name, jobs: grouped_statuses)
end
end
diff --git a/app/models/ci/group_variable.rb b/app/models/ci/group_variable.rb
index 323ff560564..98326d3af8b 100644
--- a/app/models/ci/group_variable.rb
+++ b/app/models/ci/group_variable.rb
@@ -13,7 +13,7 @@ module Ci
validates :key, uniqueness: {
scope: :group_id,
- message: "(%{value}) has already been taken"
+ message: "(%{value}) has already been taken",
}
scope :unprotected, -> { where(protected: false) }
diff --git a/app/models/ci/job_artifact.rb b/app/models/ci/job_artifact.rb
index 789bb293811..da262666637 100644
--- a/app/models/ci/job_artifact.rb
+++ b/app/models/ci/job_artifact.rb
@@ -14,14 +14,14 @@ module Ci
archive: nil,
metadata: nil,
trace: nil,
- junit: 'junit.xml',
- codequality: 'gl-code-quality-report.json',
- sast: 'gl-sast-report.json',
- dependency_scanning: 'gl-dependency-scanning-report.json',
- container_scanning: 'gl-container-scanning-report.json',
- dast: 'gl-dast-report.json',
- license_management: 'gl-license-management-report.json',
- performance: 'performance.json'
+ junit: "junit.xml",
+ codequality: "gl-code-quality-report.json",
+ sast: "gl-sast-report.json",
+ dependency_scanning: "gl-dependency-scanning-report.json",
+ container_scanning: "gl-container-scanning-report.json",
+ dast: "gl-dast-report.json",
+ license_management: "gl-license-management-report.json",
+ performance: "performance.json",
}.freeze
TYPE_AND_FORMAT_PAIRS = {
@@ -39,7 +39,7 @@ module Ci
container_scanning: :raw,
dast: :raw,
license_management: :raw,
- performance: :raw
+ performance: :raw,
}.freeze
belongs_to :project
@@ -57,7 +57,7 @@ module Ci
scope :with_files_stored_locally, -> { where(file_store: [nil, ::JobArtifactUploader::Store::LOCAL]) }
- scope :with_file_types, -> (file_types) do
+ scope :with_file_types, ->(file_types) do
types = self.file_types.select { |file_type| file_types.include?(file_type) }.values
where(file_type: types)
@@ -68,12 +68,12 @@ module Ci
end
scope :erasable, -> do
- types = self.file_types.reject { |file_type| NON_ERASABLE_FILE_TYPES.include?(file_type) }.values
+ types = file_types.reject { |file_type| NON_ERASABLE_FILE_TYPES.include?(file_type) }.values
where(file_type: types)
end
- scope :expired, -> (limit) { where('expire_at < ?', Time.now).limit(limit) }
+ scope :expired, ->(limit) { where("expire_at < ?", Time.now).limit(limit) }
delegate :filename, :exists?, :open, to: :file
@@ -88,13 +88,13 @@ module Ci
dast: 8, ## EE-specific
codequality: 9, ## EE-specific
license_management: 10, ## EE-specific
- performance: 11 ## EE-specific
+ performance: 11, ## EE-specific
}
enum file_format: {
raw: 1,
zip: 2,
- gzip: 3
+ gzip: 3,
}
# `file_location` indicates where actual files are stored.
@@ -108,38 +108,38 @@ module Ci
# This is the default value.
enum file_location: {
legacy_path: 1,
- hashed_path: 2
+ hashed_path: 2,
}
FILE_FORMAT_ADAPTERS = {
gzip: Gitlab::Ci::Build::Artifacts::Adapters::GzipStream,
- raw: Gitlab::Ci::Build::Artifacts::Adapters::RawStream
+ raw: Gitlab::Ci::Build::Artifacts::Adapters::RawStream,
}.freeze
def valid_file_format?
- unless TYPE_AND_FORMAT_PAIRS[self.file_type&.to_sym] == self.file_format&.to_sym
- errors.add(:file_format, 'Invalid file format with specified file type')
+ unless TYPE_AND_FORMAT_PAIRS[file_type&.to_sym] == file_format&.to_sym
+ errors.add(:file_format, "Invalid file format with specified file type")
end
end
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
- self.update_column(:file_store, file.object_store)
+ update_column(:file_store, file.object_store)
end
def self.artifacts_size_for(project)
- self.where(project: project).sum(:size)
+ where(project: project).sum(:size)
end
def local_store?
- [nil, ::JobArtifactUploader::Store::LOCAL].include?(self.file_store)
+ [nil, ::JobArtifactUploader::Store::LOCAL].include?(file_store)
end
def hashed_path?
return true if trace? # ArchiveLegacyTraces background migration might not have `file_location` column
- super || self.file_location.nil?
+ super || file_location.nil?
end
def expire_in
@@ -155,7 +155,7 @@ module Ci
def each_blob(&blk)
unless file_format_adapter_class
- raise NotSupportedAdapterError, 'This file format requires a dedicated adapter'
+ raise NotSupportedAdapterError, "This file format requires a dedicated adapter"
end
file.open do |stream|
@@ -178,7 +178,7 @@ module Ci
end
def update_project_statistics_after_destroy
- update_project_statistics(-self.size.to_i)
+ update_project_statistics(-size.to_i)
end
def update_project_statistics(difference)
diff --git a/app/models/ci/legacy_stage.rb b/app/models/ci/legacy_stage.rb
index 96dbc7b6895..d81c473e7be 100644
--- a/app/models/ci/legacy_stage.rb
+++ b/app/models/ci/legacy_stage.rb
@@ -48,7 +48,7 @@ module Ci
end
def success?
- status.to_s == 'success'
+ status.to_s == "success"
end
def has_warnings?
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index d4586219333..56c425867b9 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -19,21 +19,21 @@ module Ci
belongs_to :project, inverse_of: :all_pipelines
belongs_to :user
- belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
- belongs_to :pipeline_schedule, class_name: 'Ci::PipelineSchedule'
- belongs_to :merge_request, class_name: 'MergeRequest'
+ belongs_to :auto_canceled_by, class_name: "Ci::Pipeline"
+ belongs_to :pipeline_schedule, class_name: "Ci::PipelineSchedule"
+ belongs_to :merge_request, class_name: "MergeRequest"
has_internal_id :iid, scope: :project, presence: false, init: ->(s) do
s&.project&.all_pipelines&.maximum(:iid) || s&.project&.all_pipelines&.count
end
has_many :stages, -> { order(position: :asc) }, inverse_of: :pipeline
- has_many :statuses, class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
+ has_many :statuses, class_name: "CommitStatus", foreign_key: :commit_id, inverse_of: :pipeline
has_many :processables, -> { processables },
- class_name: 'CommitStatus', foreign_key: :commit_id, inverse_of: :pipeline
+ class_name: "CommitStatus", foreign_key: :commit_id, inverse_of: :pipeline
has_many :builds, foreign_key: :commit_id, inverse_of: :pipeline
has_many :trigger_requests, dependent: :destroy, foreign_key: :commit_id # rubocop:disable Cop/ActiveRecordDependent
- has_many :variables, class_name: 'Ci::PipelineVariable'
+ has_many :variables, class_name: "Ci::PipelineVariable"
has_many :deployments, through: :builds
has_many :environments, -> { distinct }, through: :deployments
@@ -41,31 +41,31 @@ module Ci
# the merge request's latest commit.
has_many :merge_requests, foreign_key: "head_pipeline_id"
- has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: 'Ci::Build'
- has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
- has_many :cancelable_statuses, -> { cancelable }, foreign_key: :commit_id, class_name: 'CommitStatus'
- has_many :manual_actions, -> { latest.manual_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
- has_many :scheduled_actions, -> { latest.scheduled_actions.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
- has_many :artifacts, -> { latest.with_artifacts_not_expired.includes(:project) }, foreign_key: :commit_id, class_name: 'Ci::Build'
+ has_many :pending_builds, -> { pending }, foreign_key: :commit_id, class_name: "Ci::Build"
+ has_many :retryable_builds, -> { latest.failed_or_canceled.includes(:project) }, foreign_key: :commit_id, class_name: "Ci::Build"
+ has_many :cancelable_statuses, -> { cancelable }, foreign_key: :commit_id, class_name: "CommitStatus"
+ has_many :manual_actions, -> { latest.manual_actions.includes(:project) }, foreign_key: :commit_id, class_name: "Ci::Build"
+ has_many :scheduled_actions, -> { latest.scheduled_actions.includes(:project) }, foreign_key: :commit_id, class_name: "Ci::Build"
+ has_many :artifacts, -> { latest.with_artifacts_not_expired.includes(:project) }, foreign_key: :commit_id, class_name: "Ci::Build"
- has_many :auto_canceled_pipelines, class_name: 'Ci::Pipeline', foreign_key: 'auto_canceled_by_id'
- has_many :auto_canceled_jobs, class_name: 'CommitStatus', foreign_key: 'auto_canceled_by_id'
+ has_many :auto_canceled_pipelines, class_name: "Ci::Pipeline", foreign_key: "auto_canceled_by_id"
+ has_many :auto_canceled_jobs, class_name: "CommitStatus", foreign_key: "auto_canceled_by_id"
- has_one :chat_data, class_name: 'Ci::PipelineChatData'
+ has_one :chat_data, class_name: "Ci::PipelineChatData"
accepts_nested_attributes_for :variables, reject_if: :persisted?
delegate :id, to: :project, prefix: true
delegate :full_path, to: :project, prefix: true
- validates :sha, presence: { unless: :importing? }
- validates :ref, presence: { unless: :importing? }
- validates :merge_request, presence: { if: :merge_request? }
- validates :merge_request, absence: { unless: :merge_request? }
- validates :tag, inclusion: { in: [false], if: :merge_request? }
- validates :status, presence: { unless: :importing? }
+ validates :sha, presence: {unless: :importing?}
+ validates :ref, presence: {unless: :importing?}
+ validates :merge_request, presence: {if: :merge_request?}
+ validates :merge_request, absence: {unless: :merge_request?}
+ validates :tag, inclusion: {in: [false], if: :merge_request?}
+ validates :status, presence: {unless: :importing?}
validate :valid_commit_sha, unless: :importing?
- validates :source, exclusion: { in: %w(unknown), unless: :importing? }, on: :create
+ validates :source, exclusion: {in: %w[unknown], unless: :importing?}, on: :create
after_create :keep_around_commits, unless: :importing?
@@ -178,15 +178,15 @@ module Ci
scope :ci_sources, -> { where(config_source: ci_sources_values) }
scope :sort_by_merge_request_pipelines, -> do
- sql = 'CASE ci_pipelines.source WHEN (?) THEN 0 ELSE 1 END, ci_pipelines.id DESC'
+ sql = "CASE ci_pipelines.source WHEN (?) THEN 0 ELSE 1 END, ci_pipelines.id DESC"
query = ActiveRecord::Base.send(:sanitize_sql_array, [sql, sources[:merge_request]]) # rubocop:disable GitlabSecurity/PublicSend
order(query)
end
- scope :for_user, -> (user) { where(user: user) }
+ scope :for_user, ->(user) { where(user: user) }
- scope :for_merge_request, -> (merge_request, ref, sha) do
+ scope :for_merge_request, ->(merge_request, ref, sha) do
##
# We have to filter out unrelated MR pipelines.
# When merge request is empty, it selects general pipelines, such as push sourced pipelines.
@@ -195,19 +195,19 @@ module Ci
.sort_by_merge_request_pipelines
end
- scope :triggered_by_merge_request, -> (merge_request) do
+ scope :triggered_by_merge_request, ->(merge_request) do
where(source: :merge_request, merge_request: merge_request)
end
- scope :detached_merge_request_pipelines, -> (merge_request) do
+ scope :detached_merge_request_pipelines, ->(merge_request) do
triggered_by_merge_request(merge_request).where(target_sha: nil)
end
- scope :merge_request_pipelines, -> (merge_request) do
+ scope :merge_request_pipelines, ->(merge_request) do
triggered_by_merge_request(merge_request).where.not(target_sha: nil)
end
- scope :mergeable_merge_request_pipelines, -> (merge_request) do
+ scope :mergeable_merge_request_pipelines, ->(merge_request) do
triggered_by_merge_request(merge_request).where(target_sha: merge_request.target_branch_sha)
end
@@ -283,7 +283,7 @@ module Ci
end
def self.latest_successful_ids_per_project
- success.group(:project_id).select('max(id) as id')
+ success.group(:project_id).select("max(id) as id")
end
def self.truncate_sha(sha)
@@ -337,7 +337,7 @@ module Ci
def ordered_stages
return legacy_stages unless complete?
- if Feature.enabled?('ci_pipeline_persisted_stages', default_enabled: true)
+ if Feature.enabled?("ci_pipeline_persisted_stages", default_enabled: true)
stages
else
legacy_stages
@@ -348,15 +348,15 @@ module Ci
# TODO, this needs refactoring, see gitlab-ce#26481.
stages_query = statuses
- .group('stage').select(:stage).order('max(stage_idx)')
+ .group("stage").select(:stage).order("max(stage_idx)")
- status_sql = statuses.latest.where('stage=sg.stage').status_sql
+ status_sql = statuses.latest.where("stage=sg.stage").status_sql
- warnings_sql = statuses.latest.select('COUNT(*)')
- .where('stage=sg.stage').failed_but_allowed.to_sql
+ warnings_sql = statuses.latest.select("COUNT(*)")
+ .where("stage=sg.stage").failed_but_allowed.to_sql
stages_with_statuses = CommitStatus.from(stages_query, :sg)
- .pluck('sg.stage', status_sql, "(#{warnings_sql})")
+ .pluck("sg.stage", status_sql, "(#{warnings_sql})")
stages_with_statuses.map do |stage|
Ci::LegacyStage.new(self, Hash[%i[name status warnings].zip(stage)])
@@ -364,8 +364,8 @@ module Ci
end
def valid_commit_sha
- if self.sha == Gitlab::Git::BLANK_SHA
- self.errors.add(:sha, " cant be 00000000 (branch removal)")
+ if sha == Gitlab::Git::BLANK_SHA
+ errors.add(:sha, " cant be 00000000 (branch removal)")
end
end
@@ -478,7 +478,7 @@ module Ci
def coverage
coverage_array = statuses.latest.map(&:coverage).compact
if coverage_array.size >= 1
- '%.2f' % (coverage_array.reduce(:+) / coverage_array.size)
+ "%.2f" % (coverage_array.reduce(:+) / coverage_array.size)
end
end
@@ -486,9 +486,9 @@ module Ci
return [] unless config_processor
strong_memoize(:stage_seeds) do
- seeds = config_processor.stages_attributes.map do |attributes|
+ seeds = config_processor.stages_attributes.map { |attributes|
Gitlab::Ci::Pipeline::Seed::Stage.new(self, attributes)
- end
+ }
seeds.select(&:included?)
end
@@ -533,13 +533,13 @@ module Ci
return @config_processor if defined?(@config_processor)
@config_processor ||= begin
- ::Gitlab::Ci::YamlProcessor.new(ci_yaml_file, { project: project, sha: sha, user: user })
- rescue Gitlab::Ci::YamlProcessor::ValidationError => e
- self.yaml_errors = e.message
- nil
- rescue
- self.yaml_errors = 'Undefined error'
- nil
+ ::Gitlab::Ci::YamlProcessor.new(ci_yaml_file, {project: project, sha: sha, user: user})
+ rescue Gitlab::Ci::YamlProcessor::ValidationError => e
+ self.yaml_errors = e.message
+ nil
+ rescue
+ self.yaml_errors = "Undefined error"
+ nil
end
end
@@ -547,7 +547,7 @@ module Ci
return unless repository_source? || unknown_source?
if project.ci_config_path.blank?
- '.gitlab-ci.yml'
+ ".gitlab-ci.yml"
else
project.ci_config_path
end
@@ -583,7 +583,7 @@ module Ci
notes.each do |note|
note[:id] = nil
note[:commit_id] = sha
- note[:noteable_id] = self['id']
+ note[:noteable_id] = self["id"]
note.save!
end
end
@@ -601,18 +601,18 @@ module Ci
def update_status
retry_optimistic_lock(self) do
case latest_builds_status.to_s
- when 'created' then nil
- when 'pending' then enqueue
- when 'running' then run
- when 'success' then succeed
- when 'failed' then drop
- when 'canceled' then cancel
- when 'skipped' then skip
- when 'manual' then block
- when 'scheduled' then delay
+ when "created" then nil
+ when "pending" then enqueue
+ when "running" then run
+ when "success" then succeed
+ when "failed" then drop
+ when "canceled" then cancel
+ when "skipped" then skip
+ when "manual" then block
+ when "scheduled" then delay
else
raise HasStatus::UnknownStatusError,
- "Unknown status `#{latest_builds_status}`"
+ "Unknown status `#{latest_builds_status}`"
end
end
end
@@ -629,23 +629,23 @@ module Ci
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless persisted?
- variables.append(key: 'CI_PIPELINE_ID', value: id.to_s)
- variables.append(key: 'CI_PIPELINE_URL', value: Gitlab::Routing.url_helpers.project_pipeline_url(project, self))
+ variables.append(key: "CI_PIPELINE_ID", value: id.to_s)
+ variables.append(key: "CI_PIPELINE_URL", value: Gitlab::Routing.url_helpers.project_pipeline_url(project, self))
end
end
def predefined_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_PIPELINE_IID', value: iid.to_s)
- variables.append(key: 'CI_CONFIG_PATH', value: ci_yaml_file_path)
- variables.append(key: 'CI_PIPELINE_SOURCE', value: source.to_s)
- variables.append(key: 'CI_COMMIT_MESSAGE', value: git_commit_message.to_s)
- variables.append(key: 'CI_COMMIT_TITLE', value: git_commit_full_title.to_s)
- variables.append(key: 'CI_COMMIT_DESCRIPTION', value: git_commit_description.to_s)
+ variables.append(key: "CI_PIPELINE_IID", value: iid.to_s)
+ variables.append(key: "CI_CONFIG_PATH", value: ci_yaml_file_path)
+ variables.append(key: "CI_PIPELINE_SOURCE", value: source.to_s)
+ variables.append(key: "CI_COMMIT_MESSAGE", value: git_commit_message.to_s)
+ variables.append(key: "CI_COMMIT_TITLE", value: git_commit_full_title.to_s)
+ variables.append(key: "CI_COMMIT_DESCRIPTION", value: git_commit_description.to_s)
if merge_request? && merge_request
- variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA', value: source_sha.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA', value: target_sha.to_s)
+ variables.append(key: "CI_MERGE_REQUEST_SOURCE_BRANCH_SHA", value: source_sha.to_s)
+ variables.append(key: "CI_MERGE_REQUEST_TARGET_BRANCH_SHA", value: target_sha.to_s)
variables.concat(merge_request.predefined_variables)
end
end
@@ -762,7 +762,7 @@ module Ci
return unless project
if project.auto_devops_enabled?
- Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content
+ Gitlab::Template::GitlabCiYmlTemplate.find("Auto-DevOps").content
end
end
@@ -791,15 +791,15 @@ module Ci
end
def latest_builds_status
- return 'failed' unless yaml_errors.blank?
+ return "failed" unless yaml_errors.blank?
- statuses.latest.status || 'skipped'
+ statuses.latest.status || "skipped"
end
def keep_around_commits
return unless project
- project.repository.keep_around(self.sha, self.before_sha)
+ project.repository.keep_around(sha, before_sha)
end
end
end
diff --git a/app/models/ci/pipeline_chat_data.rb b/app/models/ci/pipeline_chat_data.rb
index 8d37500fec5..0a8c2a75980 100644
--- a/app/models/ci/pipeline_chat_data.rb
+++ b/app/models/ci/pipeline_chat_data.rb
@@ -2,7 +2,7 @@
module Ci
class PipelineChatData < ActiveRecord::Base
- self.table_name = 'ci_pipeline_chat_data'
+ self.table_name = "ci_pipeline_chat_data"
belongs_to :chat_name
diff --git a/app/models/ci/pipeline_enums.rb b/app/models/ci/pipeline_enums.rb
index 4be4fdb1ff2..da28b8d3613 100644
--- a/app/models/ci/pipeline_enums.rb
+++ b/app/models/ci/pipeline_enums.rb
@@ -7,7 +7,7 @@ module Ci
def self.failure_reasons
{
unknown_failure: 0,
- config_error: 1
+ config_error: 1,
}
end
@@ -23,7 +23,7 @@ module Ci
api: 5,
external: 6,
chat: 8,
- merge_request: 10
+ merge_request: 10,
}
end
@@ -33,7 +33,7 @@ module Ci
{
unknown_source: nil,
repository_source: 1,
- auto_devops_source: 2
+ auto_devops_source: 2,
}
end
end
diff --git a/app/models/ci/pipeline_schedule.rb b/app/models/ci/pipeline_schedule.rb
index 1c1f203bdb2..7c4f6e83bb0 100644
--- a/app/models/ci/pipeline_schedule.rb
+++ b/app/models/ci/pipeline_schedule.rb
@@ -9,14 +9,14 @@ module Ci
ignore_column :deleted_at
belongs_to :project
- belongs_to :owner, class_name: 'User'
- has_one :last_pipeline, -> { order(id: :desc) }, class_name: 'Ci::Pipeline'
+ belongs_to :owner, class_name: "User"
+ has_one :last_pipeline, -> { order(id: :desc) }, class_name: "Ci::Pipeline"
has_many :pipelines
- has_many :variables, class_name: 'Ci::PipelineScheduleVariable', validate: false
+ has_many :variables, class_name: "Ci::PipelineScheduleVariable", validate: false
- validates :cron, unless: :importing?, cron: true, presence: { unless: :importing? }
- validates :cron_timezone, cron_timezone: true, presence: { unless: :importing? }
- validates :ref, presence: { unless: :importing? }
+ validates :cron, unless: :importing?, cron: true, presence: {unless: :importing?}
+ validates :cron_timezone, cron_timezone: true, presence: {unless: :importing?}
+ validates :ref, presence: {unless: :importing?}
validates :description, presence: true
validates :variables, variable_duplicates: true
@@ -54,10 +54,11 @@ module Ci
end
def real_next_run(
- worker_cron: Settings.cron_jobs['pipeline_schedule_worker']['cron'],
- worker_time_zone: Time.zone.name)
+ worker_cron: Settings.cron_jobs["pipeline_schedule_worker"]["cron"],
+ worker_time_zone: Time.zone.name
+ )
Gitlab::Ci::CronParser.new(worker_cron, worker_time_zone)
- .next_time_from(next_run_at)
+ .next_time_from(next_run_at)
end
def job_variables
diff --git a/app/models/ci/pipeline_schedule_variable.rb b/app/models/ci/pipeline_schedule_variable.rb
index fbb9987cab2..6886876341d 100644
--- a/app/models/ci/pipeline_schedule_variable.rb
+++ b/app/models/ci/pipeline_schedule_variable.rb
@@ -9,6 +9,6 @@ module Ci
alias_attribute :secret_value, :value
- validates :key, uniqueness: { scope: :pipeline_schedule_id }
+ validates :key, uniqueness: {scope: :pipeline_schedule_id}
end
end
diff --git a/app/models/ci/pipeline_variable.rb b/app/models/ci/pipeline_variable.rb
index 08514d6af4e..0f5b6c17739 100644
--- a/app/models/ci/pipeline_variable.rb
+++ b/app/models/ci/pipeline_variable.rb
@@ -9,10 +9,10 @@ module Ci
alias_attribute :secret_value, :value
- validates :key, uniqueness: { scope: :pipeline_id }
+ validates :key, uniqueness: {scope: :pipeline_id}
def hook_attrs
- { key: key, value: value }
+ {key: key, value: value}
end
end
end
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb
index d82e11bbb89..efcc6e8a938 100644
--- a/app/models/ci/runner.rb
+++ b/app/models/ci/runner.rb
@@ -14,13 +14,13 @@ module Ci
enum access_level: {
not_protected: 0,
- ref_protected: 1
+ ref_protected: 1,
}
enum runner_type: {
instance_type: 1,
group_type: 2,
- project_type: 3
+ project_type: 3,
}
RUNNER_QUEUE_EXPIRY_TIME = 60.minutes
@@ -40,13 +40,13 @@ module Ci
has_many :runner_namespaces, inverse_of: :runner
has_many :groups, through: :runner_namespaces
- has_one :last_build, ->() { order('id DESC') }, class_name: 'Ci::Build'
+ has_one :last_build, -> { order("id DESC") }, class_name: "Ci::Build"
before_save :ensure_token
scope :active, -> { where(active: true) }
scope :paused, -> { where(active: false) }
- scope :online, -> { where('contacted_at > ?', contact_time_deadline) }
+ scope :online, -> { where("contacted_at > ?", contact_time_deadline) }
# The following query using negation is cheaper than using `contacted_at <= ?`
# because there are less runners online than have been created. The
# resulting query is quickly finding online ones and then uses the regular
@@ -60,23 +60,23 @@ module Ci
scope :deprecated_shared, -> { instance_type }
scope :deprecated_specific, -> { project_type.or(group_type) }
- scope :belonging_to_project, -> (project_id) {
- joins(:runner_projects).where(ci_runner_projects: { project_id: project_id })
+ scope :belonging_to_project, ->(project_id) {
+ joins(:runner_projects).where(ci_runner_projects: {project_id: project_id})
}
- scope :belonging_to_parent_group_of_project, -> (project_id) {
- project_groups = ::Group.joins(:projects).where(projects: { id: project_id })
+ scope :belonging_to_parent_group_of_project, ->(project_id) {
+ project_groups = ::Group.joins(:projects).where(projects: {id: project_id})
hierarchy_groups = Gitlab::ObjectHierarchy.new(project_groups).base_and_ancestors
- joins(:groups).where(namespaces: { id: hierarchy_groups })
+ joins(:groups).where(namespaces: {id: hierarchy_groups})
}
- scope :owned_or_instance_wide, -> (project_id) do
+ scope :owned_or_instance_wide, ->(project_id) do
from_union(
[
belonging_to_project(project_id),
belonging_to_parent_group_of_project(project_id),
- instance_type
+ instance_type,
],
remove_duplicates: false
)
@@ -115,11 +115,11 @@ module Ci
cached_attr_reader :version, :revision, :platform, :architecture, :ip_address, :contacted_at
chronic_duration_attr :maximum_timeout_human_readable, :maximum_timeout,
- error_message: 'Maximum job timeout has a value which could not be accepted'
+ error_message: "Maximum job timeout has a value which could not be accepted"
validates :maximum_timeout, allow_nil: true,
- numericality: { greater_than_or_equal_to: 600,
- message: 'needs to be at least 10 minutes' }
+ numericality: {greater_than_or_equal_to: 600,
+ message: "needs to be at least 10 minutes",}
# Searches for runners matching the given query.
#
@@ -142,7 +142,7 @@ module Ci
end
def self.order_by(order)
- if order == 'contacted_asc'
+ if order == "contacted_asc"
order_contacted_at_asc
else
order_created_at_desc
@@ -153,16 +153,16 @@ module Ci
if instance_type?
self.runner_type = :project_type
elsif group_type?
- raise ArgumentError, 'Transitioning a group runner to a project runner is not supported'
+ raise ArgumentError, "Transitioning a group runner to a project runner is not supported"
end
begin
transaction do
- self.projects << project
- self.save!
+ projects << project
+ save!
end
rescue ActiveRecord::RecordInvalid => e
- self.errors.add(:assign_to, e.message)
+ errors.add(:assign_to, e.message)
false
end
end
@@ -200,7 +200,7 @@ module Ci
end
def can_pick?(build)
- return false if self.ref_protected? && !build.protected?
+ return false if ref_protected? && !build.protected?
assignable_for?(build.project_id) && accepting_tags?(build)
end
@@ -219,9 +219,9 @@ module Ci
def predefined_variables
Gitlab::Ci::Variables::Collection.new
- .append(key: 'CI_RUNNER_ID', value: id.to_s)
- .append(key: 'CI_RUNNER_DESCRIPTION', value: description)
- .append(key: 'CI_RUNNER_TAGS', value: tag_list.to_s)
+ .append(key: "CI_RUNNER_ID", value: id.to_s)
+ .append(key: "CI_RUNNER_DESCRIPTION", value: description)
+ .append(key: "CI_RUNNER_TAGS", value: tag_list.to_s)
end
def tick_runner_queue
@@ -248,7 +248,7 @@ module Ci
cache_attributes(values)
# We save data without validation, it will always change due to `contacted_at`
- self.update_columns(values) if persist_cached_data?
+ update_columns(values) if persist_cached_data?
end
def pick_build!(build)
@@ -270,7 +270,7 @@ module Ci
end
def runner_queue_key
- "runner:build_queue:#{self.token}"
+ "runner:build_queue:#{token}"
end
def persist_cached_data?
@@ -287,35 +287,35 @@ module Ci
def tag_constraints
unless has_tags? || run_untagged?
errors.add(:tags_list,
- 'can not be empty when runner is not allowed to pick untagged jobs')
+ "can not be empty when runner is not allowed to pick untagged jobs")
end
end
def assignable_for?(project_id)
- self.class.owned_or_instance_wide(project_id).where(id: self.id).any?
+ self.class.owned_or_instance_wide(project_id).where(id: id).any?
end
def no_projects
if projects.any?
- errors.add(:runner, 'cannot have projects assigned')
+ errors.add(:runner, "cannot have projects assigned")
end
end
def no_groups
if groups.any?
- errors.add(:runner, 'cannot have groups assigned')
+ errors.add(:runner, "cannot have groups assigned")
end
end
def any_project
unless projects.any?
- errors.add(:runner, 'needs to be assigned to at least one project')
+ errors.add(:runner, "needs to be assigned to at least one project")
end
end
def exactly_one_group
unless groups.one?
- errors.add(:runner, 'needs to be assigned to exactly one group')
+ errors.add(:runner, "needs to be assigned to exactly one group")
end
end
diff --git a/app/models/ci/runner_namespace.rb b/app/models/ci/runner_namespace.rb
index 22b80b98551..ca638f0b502 100644
--- a/app/models/ci/runner_namespace.rb
+++ b/app/models/ci/runner_namespace.rb
@@ -5,9 +5,9 @@ module Ci
extend Gitlab::Ci::Model
belongs_to :runner, inverse_of: :runner_namespaces, validate: true
- belongs_to :namespace, inverse_of: :runner_namespaces, class_name: '::Namespace'
- belongs_to :group, class_name: '::Group', foreign_key: :namespace_id
+ belongs_to :namespace, inverse_of: :runner_namespaces, class_name: "::Namespace"
+ belongs_to :group, class_name: "::Group", foreign_key: :namespace_id
- validates :runner_id, uniqueness: { scope: :namespace_id }
+ validates :runner_id, uniqueness: {scope: :namespace_id}
end
end
diff --git a/app/models/ci/runner_project.rb b/app/models/ci/runner_project.rb
index 1a718d24141..8359e9af20f 100644
--- a/app/models/ci/runner_project.rb
+++ b/app/models/ci/runner_project.rb
@@ -7,6 +7,6 @@ module Ci
belongs_to :runner, inverse_of: :runner_projects
belongs_to :project, inverse_of: :runner_projects
- validates :runner_id, uniqueness: { scope: :project_id }
+ validates :runner_id, uniqueness: {scope: :project_id}
end
end
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb
index 0389945191e..2505aa79f2d 100644
--- a/app/models/ci/stage.rb
+++ b/app/models/ci/stage.rb
@@ -12,7 +12,7 @@ module Ci
belongs_to :project
belongs_to :pipeline
- has_many :statuses, class_name: 'CommitStatus', foreign_key: :stage_id
+ has_many :statuses, class_name: "CommitStatus", foreign_key: :stage_id
has_many :builds, foreign_key: :stage_id
has_many :bridges, foreign_key: :stage_id
@@ -24,16 +24,16 @@ module Ci
end
after_initialize do
- self.status = DEFAULT_STATUS if self.status.nil?
+ self.status = DEFAULT_STATUS if status.nil?
end
before_validation unless: :importing? do
next if position.present?
self.position = statuses.select(:stage_idx)
- .where('stage_idx IS NOT NULL')
+ .where("stage_idx IS NOT NULL")
.group(:stage_idx)
- .order('COUNT(*) DESC')
+ .order("COUNT(*) DESC")
.first&.stage_idx.to_i
end
@@ -75,18 +75,18 @@ module Ci
def update_status
retry_optimistic_lock(self) do
case statuses.latest.status
- when 'created' then nil
- when 'pending' then enqueue
- when 'running' then run
- when 'success' then succeed
- when 'failed' then drop
- when 'canceled' then cancel
- when 'manual' then block
- when 'scheduled' then delay
- when 'skipped', nil then skip
+ when "created" then nil
+ when "pending" then enqueue
+ when "running" then run
+ when "success" then succeed
+ when "failed" then drop
+ when "canceled" then cancel
+ when "manual" then block
+ when "scheduled" then delay
+ when "skipped", nil then skip
else
raise HasStatus::UnknownStatusError,
- "Unknown status `#{statuses.latest.status}`"
+ "Unknown status `#{statuses.latest.status}`"
end
end
end
diff --git a/app/models/ci/trigger.rb b/app/models/ci/trigger.rb
index 637148c4ce4..a83826fbc43 100644
--- a/app/models/ci/trigger.rb
+++ b/app/models/ci/trigger.rb
@@ -18,7 +18,7 @@ module Ci
before_validation :set_default_values
def set_default_values
- self.token = SecureRandom.hex(15) if self.token.blank?
+ self.token = SecureRandom.hex(15) if token.blank?
end
def last_trigger_request
@@ -34,11 +34,11 @@ module Ci
end
def legacy?
- self.owner_id.blank?
+ owner_id.blank?
end
def can_access_project?
- self.owner_id.blank? || Ability.allowed?(self.owner, :create_build, project)
+ owner_id.blank? || Ability.allowed?(owner, :create_build, project)
end
end
end
diff --git a/app/models/ci/trigger_request.rb b/app/models/ci/trigger_request.rb
index 0b52c690e93..d6eb4723b13 100644
--- a/app/models/ci/trigger_request.rb
+++ b/app/models/ci/trigger_request.rb
@@ -20,7 +20,7 @@ module Ci
return [] unless variables
variables.map do |key, value|
- { key: key, value: value, public: false }
+ {key: key, value: value, public: false}
end
end
end
diff --git a/app/models/ci/variable.rb b/app/models/ci/variable.rb
index 64836ea4fa4..ccc7ce6d268 100644
--- a/app/models/ci/variable.rb
+++ b/app/models/ci/variable.rb
@@ -13,7 +13,7 @@ module Ci
validates :key, uniqueness: {
scope: [:project_id, :environment_scope],
- message: "(%{value}) has already been taken"
+ message: "(%{value}) has already been taken",
}
scope :unprotected, -> { where(protected: false) }
diff --git a/app/models/clusters/applications/cert_manager.rb b/app/models/clusters/applications/cert_manager.rb
index c758577815a..edc90b372ff 100644
--- a/app/models/clusters/applications/cert_manager.rb
+++ b/app/models/clusters/applications/cert_manager.rb
@@ -3,9 +3,9 @@
module Clusters
module Applications
class CertManager < ActiveRecord::Base
- VERSION = 'v0.5.2'.freeze
+ VERSION = "v0.5.2"
- self.table_name = 'clusters_applications_cert_managers'
+ self.table_name = "clusters_applications_cert_managers"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
@@ -21,12 +21,12 @@ module Clusters
validates :email, presence: true
def chart
- 'stable/cert-manager'
+ "stable/cert-manager"
end
def install_command
Gitlab::Kubernetes::Helm::InstallCommand.new(
- name: 'certmanager',
+ name: "certmanager",
version: VERSION,
rbac: cluster.platform_kubernetes_rbac?,
chart: chart,
@@ -43,7 +43,7 @@ module Clusters
def cluster_issuer_file
{
- 'cluster_issuer.yaml': cluster_issuer_yaml_content
+ 'cluster_issuer.yaml': cluster_issuer_yaml_content,
}
end
@@ -56,11 +56,11 @@ module Clusters
end
def cluster_issue_overlay
- { "spec" => { "acme" => { "email" => self.email } } }
+ {"spec" => {"acme" => {"email" => email}}}
end
def cluster_issuer_file_path
- Rails.root.join('vendor', 'cert_manager', 'cluster_issuer.yaml')
+ Rails.root.join("vendor", "cert_manager", "cluster_issuer.yaml")
end
end
end
diff --git a/app/models/clusters/applications/helm.rb b/app/models/clusters/applications/helm.rb
index 423071ec024..321802c98fe 100644
--- a/app/models/clusters/applications/helm.rb
+++ b/app/models/clusters/applications/helm.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'openssl'
+require "openssl"
module Clusters
module Applications
class Helm < ActiveRecord::Base
- self.table_name = 'clusters_applications_helm'
+ self.table_name = "clusters_applications_helm"
attr_encrypted :ca_key,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
@@ -26,7 +26,7 @@ module Clusters
def set_initial_status
return unless not_installable?
- self.status = 'installable' if cluster&.platform_kubernetes_active?
+ self.status = "installable" if cluster&.platform_kubernetes_active?
end
def install_command
@@ -47,7 +47,7 @@ module Clusters
{
'ca.pem': ca_cert,
'cert.pem': tiller_cert.cert_string,
- 'key.pem': tiller_cert.key_string
+ 'key.pem': tiller_cert.key_string,
}
end
diff --git a/app/models/clusters/applications/ingress.rb b/app/models/clusters/applications/ingress.rb
index 7c15aaa4825..5c3aa094c17 100644
--- a/app/models/clusters/applications/ingress.rb
+++ b/app/models/clusters/applications/ingress.rb
@@ -3,9 +3,9 @@
module Clusters
module Applications
class Ingress < ActiveRecord::Base
- VERSION = '1.1.2'.freeze
+ VERSION = "1.1.2"
- self.table_name = 'clusters_applications_ingress'
+ self.table_name = "clusters_applications_ingress"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
@@ -17,7 +17,7 @@ module Clusters
default_value_for :version, VERSION
enum ingress_type: {
- nginx: 1
+ nginx: 1,
}
FETCH_IP_ADDRESS_DELAY = 30.seconds
@@ -26,13 +26,14 @@ module Clusters
after_transition any => [:installed] do |application|
application.run_after_commit do
ClusterWaitForIngressIpAddressWorker.perform_in(
- FETCH_IP_ADDRESS_DELAY, application.name, application.id)
+ FETCH_IP_ADDRESS_DELAY, application.name, application.id
+ )
end
end
end
def chart
- 'stable/nginx-ingress'
+ "stable/nginx-ingress"
end
def install_command
@@ -53,7 +54,7 @@ module Clusters
end
def ingress_service
- cluster.kubeclient.get_service('ingress-nginx-ingress-controller', Gitlab::Kubernetes::Helm::NAMESPACE)
+ cluster.kubeclient.get_service("ingress-nginx-ingress-controller", Gitlab::Kubernetes::Helm::NAMESPACE)
end
end
end
diff --git a/app/models/clusters/applications/jupyter.rb b/app/models/clusters/applications/jupyter.rb
index 421a923d386..82d0b35759a 100644
--- a/app/models/clusters/applications/jupyter.rb
+++ b/app/models/clusters/applications/jupyter.rb
@@ -3,16 +3,16 @@
module Clusters
module Applications
class Jupyter < ActiveRecord::Base
- VERSION = 'v0.6'.freeze
+ VERSION = "v0.6"
- self.table_name = 'clusters_applications_jupyter'
+ self.table_name = "clusters_applications_jupyter"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
include ::Clusters::Concerns::ApplicationVersion
include ::Clusters::Concerns::ApplicationData
- belongs_to :oauth_application, class_name: 'Doorkeeper::Application'
+ belongs_to :oauth_application, class_name: "Doorkeeper::Application"
default_value_for :version, VERSION
@@ -20,7 +20,7 @@ module Clusters
return unless not_installable?
if cluster&.application_ingress_available? && cluster.application_ingress.external_ip
- self.status = 'installable'
+ self.status = "installable"
end
end
@@ -29,7 +29,7 @@ module Clusters
end
def repository
- 'https://jupyterhub.github.io/helm-chart/'
+ "https://jupyterhub.github.io/helm-chart/"
end
def values
@@ -59,30 +59,30 @@ module Clusters
"hosts" => [hostname],
"tls" => [{
"hosts" => [hostname],
- "secretName" => "jupyter-cert"
- }]
+ "secretName" => "jupyter-cert",
+ }],
},
"hub" => {
"extraEnv" => {
- "GITLAB_HOST" => gitlab_url
+ "GITLAB_HOST" => gitlab_url,
},
- "cookieSecret" => cookie_secret
+ "cookieSecret" => cookie_secret,
},
"proxy" => {
- "secretToken" => secret_token
+ "secretToken" => secret_token,
},
"auth" => {
"gitlab" => {
"clientId" => oauth_application.uid,
"clientSecret" => oauth_application.secret,
- "callbackUrl" => callback_url
- }
+ "callbackUrl" => callback_url,
+ },
},
"singleuser" => {
"extraEnv" => {
- "GITLAB_CLUSTER_ID" => cluster.id
- }
- }
+ "GITLAB_CLUSTER_ID" => cluster.id,
+ },
+ },
}
end
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb
index 8d79b041b64..4ef709f3119 100644
--- a/app/models/clusters/applications/knative.rb
+++ b/app/models/clusters/applications/knative.rb
@@ -3,12 +3,12 @@
module Clusters
module Applications
class Knative < ActiveRecord::Base
- VERSION = '0.2.2'.freeze
- REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze
- METRICS_CONFIG = 'https://storage.googleapis.com/triggermesh-charts/istio-metrics.yaml'.freeze
+ VERSION = "0.2.2"
+ REPOSITORY = "https://storage.googleapis.com/triggermesh-charts"
+ METRICS_CONFIG = "https://storage.googleapis.com/triggermesh-charts/istio-metrics.yaml"
FETCH_IP_ADDRESS_DELAY = 30.seconds
- self.table_name = 'clusters_applications_knative'
+ self.table_name = "clusters_applications_knative"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
@@ -23,14 +23,15 @@ module Clusters
return unless not_installable?
return unless verify_cluster?
- self.status = 'installable'
+ self.status = "installable"
end
state_machine :status do
after_transition any => [:installed] do |application|
application.run_after_commit do
ClusterWaitForIngressIpAddressWorker.perform_in(
- FETCH_IP_ADDRESS_DELAY, application.name, application.id)
+ FETCH_IP_ADDRESS_DELAY, application.name, application.id
+ )
end
end
end
@@ -39,16 +40,16 @@ module Clusters
validates :hostname, presence: true, hostname: true
- scope :for_cluster, -> (cluster) { where(cluster: cluster) }
+ scope :for_cluster, ->(cluster) { where(cluster: cluster) }
after_save :clear_reactive_cache!
def chart
- 'knative/knative'
+ "knative/knative"
end
def values
- { "domain" => hostname }.to_yaml
+ {"domain" => hostname}.to_yaml
end
def install_command
@@ -81,11 +82,11 @@ module Clusters
end
def calculate_reactive_cache
- { services: read_services, pods: read_pods }
+ {services: read_services, pods: read_pods}
end
def ingress_service
- cluster.kubeclient.get_service('knative-ingressgateway', 'istio-system')
+ cluster.kubeclient.get_service("knative-ingressgateway", "istio-system")
end
def services_for(ns: namespace)
@@ -93,7 +94,7 @@ module Clusters
return [] unless ns
services.select do |service|
- service.dig('metadata', 'namespace') == ns
+ service.dig("metadata", "namespace") == ns
end
end
diff --git a/app/models/clusters/applications/prometheus.rb b/app/models/clusters/applications/prometheus.rb
index fa7ce363531..51c5c3d5c06 100644
--- a/app/models/clusters/applications/prometheus.rb
+++ b/app/models/clusters/applications/prometheus.rb
@@ -5,9 +5,9 @@ module Clusters
class Prometheus < ActiveRecord::Base
include PrometheusAdapter
- VERSION = '6.7.3'
+ VERSION = "6.7.3"
- self.table_name = 'clusters_applications_prometheus'
+ self.table_name = "clusters_applications_prometheus"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
@@ -19,17 +19,17 @@ module Clusters
state_machine :status do
after_transition any => [:installed] do |application|
application.cluster.projects.each do |project|
- project.find_or_initialize_service('prometheus').update(active: true)
+ project.find_or_initialize_service("prometheus").update(active: true)
end
end
end
def chart
- 'stable/prometheus'
+ "stable/prometheus"
end
def service_name
- 'prometheus-prometheus-server'
+ "prometheus-prometheus-server"
end
def service_port
@@ -68,7 +68,7 @@ module Clusters
def prometheus_client
return unless kube_client
- proxy_url = kube_client.proxy_url('service', service_name, service_port, Gitlab::Kubernetes::Helm::NAMESPACE)
+ proxy_url = kube_client.proxy_url("service", service_name, service_port, Gitlab::Kubernetes::Helm::NAMESPACE)
# ensures headers containing auth data are appended to original k8s client options
options = kube_client.rest_client.options.merge(headers: kube_client.headers)
diff --git a/app/models/clusters/applications/runner.rb b/app/models/clusters/applications/runner.rb
index 941551dadaa..a0271b5de6a 100644
--- a/app/models/clusters/applications/runner.rb
+++ b/app/models/clusters/applications/runner.rb
@@ -3,16 +3,16 @@
module Clusters
module Applications
class Runner < ActiveRecord::Base
- VERSION = '0.2.0'.freeze
+ VERSION = "0.2.0"
- self.table_name = 'clusters_applications_runners'
+ self.table_name = "clusters_applications_runners"
include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus
include ::Clusters::Concerns::ApplicationVersion
include ::Clusters::Concerns::ApplicationData
- belongs_to :runner, class_name: 'Ci::Runner', foreign_key: :runner_id
+ belongs_to :runner, class_name: "Ci::Runner", foreign_key: :runner_id
delegate :project, to: :cluster
default_value_for :version, VERSION
@@ -22,7 +22,7 @@ module Clusters
end
def repository
- 'https://charts.gitlab.io'
+ "https://charts.gitlab.io"
end
def values
@@ -56,10 +56,10 @@ module Clusters
def runner_create_params
{
- name: 'kubernetes-cluster',
+ name: "kubernetes-cluster",
runner_type: :project_type,
- tag_list: %w(kubernetes cluster),
- projects: [project]
+ tag_list: %w[kubernetes cluster],
+ projects: [project],
}
end
@@ -71,7 +71,7 @@ module Clusters
{
"gitlabUrl" => gitlab_url,
"runnerToken" => ensure_runner.token,
- "runners" => { "privileged" => privileged }
+ "runners" => {"privileged" => privileged},
}
end
diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb
index be3e6a05e1e..685575dd7b7 100644
--- a/app/models/clusters/cluster.rb
+++ b/app/models/clusters/cluster.rb
@@ -6,7 +6,7 @@ module Clusters
include Gitlab::Utils::StrongMemoize
include FromUnion
- self.table_name = 'clusters'
+ self.table_name = "clusters"
APPLICATIONS = {
Applications::Helm.application_name => Applications::Helm,
@@ -15,42 +15,42 @@ module Clusters
Applications::Prometheus.application_name => Applications::Prometheus,
Applications::Runner.application_name => Applications::Runner,
Applications::Jupyter.application_name => Applications::Jupyter,
- Applications::Knative.application_name => Applications::Knative
+ Applications::Knative.application_name => Applications::Knative,
}.freeze
- DEFAULT_ENVIRONMENT = '*'.freeze
- KUBE_INGRESS_BASE_DOMAIN = 'KUBE_INGRESS_BASE_DOMAIN'.freeze
+ DEFAULT_ENVIRONMENT = "*"
+ KUBE_INGRESS_BASE_DOMAIN = "KUBE_INGRESS_BASE_DOMAIN"
belongs_to :user
- has_many :cluster_projects, class_name: 'Clusters::Project'
- has_many :projects, through: :cluster_projects, class_name: '::Project'
- has_one :cluster_project, -> { order(id: :desc) }, class_name: 'Clusters::Project'
+ has_many :cluster_projects, class_name: "Clusters::Project"
+ has_many :projects, through: :cluster_projects, class_name: "::Project"
+ has_one :cluster_project, -> { order(id: :desc) }, class_name: "Clusters::Project"
- has_many :cluster_groups, class_name: 'Clusters::Group'
- has_many :groups, through: :cluster_groups, class_name: '::Group'
+ has_many :cluster_groups, class_name: "Clusters::Group"
+ has_many :groups, through: :cluster_groups, class_name: "::Group"
# we force autosave to happen when we save `Cluster` model
- has_one :provider_gcp, class_name: 'Clusters::Providers::Gcp', autosave: true
+ has_one :provider_gcp, class_name: "Clusters::Providers::Gcp", autosave: true
- has_one :platform_kubernetes, class_name: 'Clusters::Platforms::Kubernetes', inverse_of: :cluster, autosave: true
+ has_one :platform_kubernetes, class_name: "Clusters::Platforms::Kubernetes", inverse_of: :cluster, autosave: true
- has_one :application_helm, class_name: 'Clusters::Applications::Helm'
- has_one :application_ingress, class_name: 'Clusters::Applications::Ingress'
- has_one :application_cert_manager, class_name: 'Clusters::Applications::CertManager'
- has_one :application_prometheus, class_name: 'Clusters::Applications::Prometheus'
- has_one :application_runner, class_name: 'Clusters::Applications::Runner'
- has_one :application_jupyter, class_name: 'Clusters::Applications::Jupyter'
- has_one :application_knative, class_name: 'Clusters::Applications::Knative'
+ has_one :application_helm, class_name: "Clusters::Applications::Helm"
+ has_one :application_ingress, class_name: "Clusters::Applications::Ingress"
+ has_one :application_cert_manager, class_name: "Clusters::Applications::CertManager"
+ has_one :application_prometheus, class_name: "Clusters::Applications::Prometheus"
+ has_one :application_runner, class_name: "Clusters::Applications::Runner"
+ has_one :application_jupyter, class_name: "Clusters::Applications::Jupyter"
+ has_one :application_knative, class_name: "Clusters::Applications::Knative"
has_many :kubernetes_namespaces
- has_one :kubernetes_namespace, -> { order(id: :desc) }, class_name: 'Clusters::KubernetesNamespace'
+ has_one :kubernetes_namespace, -> { order(id: :desc) }, class_name: "Clusters::KubernetesNamespace"
accepts_nested_attributes_for :provider_gcp, update_only: true
accepts_nested_attributes_for :platform_kubernetes, update_only: true
validates :name, cluster_name: true
validates :cluster_type, presence: true
- validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true }
+ validates :domain, allow_blank: true, hostname: {allow_numeric_hostname: true}
validate :restrict_modification, on: :update
validate :no_groups, unless: :group_type?
@@ -73,30 +73,30 @@ module Clusters
enum cluster_type: {
instance_type: 1,
group_type: 2,
- project_type: 3
+ project_type: 3,
}
enum platform_type: {
- kubernetes: 1
+ kubernetes: 1,
}
enum provider_type: {
user: 0,
- gcp: 1
+ gcp: 1,
}
scope :enabled, -> { where(enabled: true) }
scope :disabled, -> { where(enabled: false) }
scope :user_provided, -> { where(provider_type: ::Clusters::Cluster.provider_types[:user]) }
scope :gcp_provided, -> { where(provider_type: ::Clusters::Cluster.provider_types[:gcp]) }
- scope :gcp_installed, -> { gcp_provided.includes(:provider_gcp).where(cluster_providers_gcp: { status: ::Clusters::Providers::Gcp.state_machines[:status].states[:created].value }) }
+ scope :gcp_installed, -> { gcp_provided.includes(:provider_gcp).where(cluster_providers_gcp: {status: ::Clusters::Providers::Gcp.state_machines[:status].states[:created].value}) }
scope :default_environment, -> { where(environment_scope: DEFAULT_ENVIRONMENT) }
- scope :missing_kubernetes_namespace, -> (kubernetes_namespaces) do
- subquery = kubernetes_namespaces.select('1').where('clusters_kubernetes_namespaces.cluster_id = clusters.id')
+ scope :missing_kubernetes_namespace, ->(kubernetes_namespaces) do
+ subquery = kubernetes_namespaces.select("1").where("clusters_kubernetes_namespaces.cluster_id = clusters.id")
- where('NOT EXISTS (?)', subquery)
+ where("NOT EXISTS (?)", subquery)
end
scope :with_knative_installed, -> { joins(:application_knative).merge(Clusters::Applications::Knative.available) }
@@ -136,7 +136,7 @@ module Clusters
application_prometheus || build_application_prometheus,
application_runner || build_application_runner,
application_jupyter || build_application_jupyter,
- application_knative || build_application_knative
+ application_knative || build_application_knative,
]
end
@@ -167,14 +167,14 @@ module Clusters
projects.first
end
end
- alias_method :project, :first_project
+ alias project first_project
def first_group
strong_memoize(:first_group) do
groups.first
end
end
- alias_method :group, :first_group
+ alias group first_group
def kubeclient
platform_kubernetes.kubeclient if kubernetes?
@@ -226,10 +226,10 @@ module Clusters
def legacy_auto_devops_domain
if project_type?
project&.auto_devops&.domain.presence ||
- project.variables.find_by(key: 'AUTO_DEVOPS_DOMAIN')&.value.presence ||
- project.group&.variables&.find_by(key: 'AUTO_DEVOPS_DOMAIN')&.value.presence
+ project.variables.find_by(key: "AUTO_DEVOPS_DOMAIN")&.value.presence ||
+ project.group&.variables&.find_by(key: "AUTO_DEVOPS_DOMAIN")&.value.presence
elsif group_type?
- group.variables.find_by(key: 'AUTO_DEVOPS_DOMAIN')&.value.presence
+ group.variables.find_by(key: "AUTO_DEVOPS_DOMAIN")&.value.presence
end
end
@@ -244,13 +244,13 @@ module Clusters
def no_groups
if groups.any?
- errors.add(:cluster, 'cannot have groups assigned')
+ errors.add(:cluster, "cannot have groups assigned")
end
end
def no_projects
if projects.any?
- errors.add(:cluster, 'cannot have projects assigned')
+ errors.add(:cluster, "cannot have projects assigned")
end
end
end
diff --git a/app/models/clusters/concerns/application_core.rb b/app/models/clusters/concerns/application_core.rb
index 683b45331f6..8f69779f1e7 100644
--- a/app/models/clusters/concerns/application_core.rb
+++ b/app/models/clusters/concerns/application_core.rb
@@ -6,7 +6,7 @@ module Clusters
extend ActiveSupport::Concern
included do
- belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
+ belongs_to :cluster, class_name: "Clusters::Cluster", foreign_key: :cluster_id
validates :cluster, presence: true
@@ -15,11 +15,11 @@ module Clusters
def set_initial_status
return unless not_installable?
- self.status = 'installable' if cluster&.application_helm_available?
+ self.status = "installable" if cluster&.application_helm_available?
end
def self.application_name
- self.to_s.demodulize.underscore
+ to_s.demodulize.underscore
end
def name
diff --git a/app/models/clusters/concerns/application_data.rb b/app/models/clusters/concerns/application_data.rb
index 52498f123ff..b6bf71ed972 100644
--- a/app/models/clusters/concerns/application_data.rb
+++ b/app/models/clusters/concerns/application_data.rb
@@ -16,7 +16,7 @@ module Clusters
def files
@files ||= begin
- files = { 'values.yaml': values }
+ files = {'values.yaml': values}
files.merge!(certificate_files) if cluster.application_helm.has_ssl?
@@ -30,7 +30,7 @@ module Clusters
{
'ca.pem': ca_cert,
'cert.pem': helm_cert.cert_string,
- 'key.pem': helm_cert.key_string
+ 'key.pem': helm_cert.key_string,
}
end
diff --git a/app/models/clusters/concerns/application_status.rb b/app/models/clusters/concerns/application_status.rb
index 1273ed83abe..7c068460aa2 100644
--- a/app/models/clusters/concerns/application_status.rb
+++ b/app/models/clusters/concerns/application_status.rb
@@ -9,8 +9,8 @@ module Clusters
scope :available, -> do
where(
status: [
- self.state_machines[:status].states[:installed].value,
- self.state_machines[:status].states[:updated].value
+ state_machines[:status].states[:installed].value,
+ state_machines[:status].states[:updated].value,
]
)
end
diff --git a/app/models/clusters/group.rb b/app/models/clusters/group.rb
index 2b08a9e47f0..8c1d46d935c 100644
--- a/app/models/clusters/group.rb
+++ b/app/models/clusters/group.rb
@@ -2,9 +2,9 @@
module Clusters
class Group < ActiveRecord::Base
- self.table_name = 'cluster_groups'
+ self.table_name = "cluster_groups"
- belongs_to :cluster, class_name: 'Clusters::Cluster'
- belongs_to :group, class_name: '::Group'
+ belongs_to :cluster, class_name: "Clusters::Cluster"
+ belongs_to :group, class_name: "::Group"
end
end
diff --git a/app/models/clusters/kubernetes_namespace.rb b/app/models/clusters/kubernetes_namespace.rb
index 73da6cb37d7..f5629a7b53d 100644
--- a/app/models/clusters/kubernetes_namespace.rb
+++ b/app/models/clusters/kubernetes_namespace.rb
@@ -4,17 +4,17 @@ module Clusters
class KubernetesNamespace < ActiveRecord::Base
include Gitlab::Kubernetes
- self.table_name = 'clusters_kubernetes_namespaces'
+ self.table_name = "clusters_kubernetes_namespaces"
- belongs_to :cluster_project, class_name: 'Clusters::Project'
- belongs_to :cluster, class_name: 'Clusters::Cluster'
- belongs_to :project, class_name: '::Project'
+ belongs_to :cluster_project, class_name: "Clusters::Project"
+ belongs_to :cluster, class_name: "Clusters::Cluster"
+ belongs_to :project, class_name: "::Project"
has_one :platform_kubernetes, through: :cluster
before_validation :set_defaults
validates :namespace, presence: true
- validates :namespace, uniqueness: { scope: :cluster_id }
+ validates :namespace, uniqueness: {scope: :cluster_id}
validates :service_account_name, presence: true
@@ -22,9 +22,9 @@ module Clusters
delegate :api_url, to: :platform_kubernetes, allow_nil: true
attr_encrypted :service_account_token,
- mode: :per_attribute_iv,
- key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ mode: :per_attribute_iv,
+ key: Settings.attr_encrypted_db_key_base_truncated,
+ algorithm: "aes-256-cbc"
scope :has_service_account_token, -> { where.not(encrypted_service_account_token: nil) }
@@ -35,10 +35,10 @@ module Clusters
def predefined_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables
- .append(key: 'KUBE_SERVICE_ACCOUNT', value: service_account_name.to_s)
- .append(key: 'KUBE_NAMESPACE', value: namespace.to_s)
- .append(key: 'KUBE_TOKEN', value: service_account_token.to_s, public: false)
- .append(key: 'KUBECONFIG', value: kubeconfig, public: false, file: true)
+ .append(key: "KUBE_SERVICE_ACCOUNT", value: service_account_name.to_s)
+ .append(key: "KUBE_NAMESPACE", value: namespace.to_s)
+ .append(key: "KUBE_TOKEN", value: service_account_token.to_s, public: false)
+ .append(key: "KUBECONFIG", value: kubeconfig, public: false, file: true)
end
end
@@ -75,7 +75,8 @@ module Clusters
url: api_url,
namespace: namespace,
token: service_account_token,
- ca_pem: ca_pem)
+ ca_pem: ca_pem
+ )
end
end
end
diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb
index 46d0898014e..c99aa82a559 100644
--- a/app/models/clusters/platforms/kubernetes.rb
+++ b/app/models/clusters/platforms/kubernetes.rb
@@ -8,22 +8,22 @@ module Clusters
include EnumWithNil
include AfterCommitQueue
- RESERVED_NAMESPACES = %w(gitlab-managed-apps).freeze
+ RESERVED_NAMESPACES = %w[gitlab-managed-apps].freeze
- self.table_name = 'cluster_platforms_kubernetes'
+ self.table_name = "cluster_platforms_kubernetes"
self.reactive_cache_key = ->(kubernetes) { [kubernetes.class.model_name.singular, kubernetes.id] }
- belongs_to :cluster, inverse_of: :platform_kubernetes, class_name: 'Clusters::Cluster'
+ belongs_to :cluster, inverse_of: :platform_kubernetes, class_name: "Clusters::Cluster"
attr_encrypted :password,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
attr_encrypted :token,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
before_validation :enforce_namespace_to_lower_case
before_validation :enforce_ca_whitespace_trimming
@@ -33,10 +33,10 @@ module Clusters
length: 1..63,
format: {
with: Gitlab::Regex.kubernetes_namespace_regex,
- message: Gitlab::Regex.kubernetes_namespace_regex_message
+ message: Gitlab::Regex.kubernetes_namespace_regex_message,
}
- validates :namespace, exclusion: { in: RESERVED_NAMESPACES }
+ validates :namespace, exclusion: {in: RESERVED_NAMESPACES}
validate :no_namespace, unless: :allow_user_defined_namespace?
@@ -58,12 +58,12 @@ module Clusters
delegate :allow_user_defined_namespace?, to: :cluster, allow_nil: true
delegate :kubernetes_namespace, to: :cluster
- alias_method :active?, :enabled?
+ alias active? enabled?
enum_with_nil authorization_type: {
unknown_authorization: nil,
rbac: 1,
- abac: 2
+ abac: 2,
}
default_value_for :authorization_type, :rbac
@@ -78,12 +78,12 @@ module Clusters
def predefined_variables(project:)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'KUBE_URL', value: api_url)
+ variables.append(key: "KUBE_URL", value: api_url)
if ca_pem.present?
variables
- .append(key: 'KUBE_CA_PEM', value: ca_pem)
- .append(key: 'KUBE_CA_PEM_FILE', value: ca_pem, file: true)
+ .append(key: "KUBE_CA_PEM", value: ca_pem)
+ .append(key: "KUBE_CA_PEM_FILE", value: ca_pem, file: true)
end
if kubernetes_namespace = cluster.kubernetes_namespaces.has_service_account_token.find_by(project: project)
@@ -94,10 +94,10 @@ module Clusters
# this 'else' branch will be removed. For more information, please see
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22433
variables
- .append(key: 'KUBE_URL', value: api_url)
- .append(key: 'KUBE_TOKEN', value: token, public: false)
- .append(key: 'KUBE_NAMESPACE', value: actual_namespace)
- .append(key: 'KUBECONFIG', value: kubeconfig, public: false, file: true)
+ .append(key: "KUBE_URL", value: api_url)
+ .append(key: "KUBE_TOKEN", value: token, public: false)
+ .append(key: "KUBE_NAMESPACE", value: actual_namespace)
+ .append(key: "KUBECONFIG", value: kubeconfig, public: false, file: true)
end
variables.concat(cluster.predefined_variables)
@@ -122,7 +122,7 @@ module Clusters
return unless enabled? && project && !project.pending_delete?
# We may want to cache extra things in the future
- { pods: read_pods }
+ {pods: read_pods}
end
def kubeclient
@@ -136,7 +136,8 @@ module Clusters
url: api_url,
namespace: actual_namespace,
token: token,
- ca_pem: ca_pem)
+ ca_pem: ca_pem
+ )
end
def default_namespace
@@ -167,7 +168,7 @@ module Clusters
api_url,
auth_options: kubeclient_auth_options,
ssl_options: kubeclient_ssl_options,
- http_proxy_uri: ENV['http_proxy']
+ http_proxy_uri: ENV["http_proxy"]
)
end
@@ -181,7 +182,7 @@ module Clusters
end
def kubeclient_ssl_options
- opts = { verify_ssl: OpenSSL::SSL::VERIFY_PEER }
+ opts = {verify_ssl: OpenSSL::SSL::VERIFY_PEER}
if ca_pem.present?
opts[:cert_store] = OpenSSL::X509::Store.new
@@ -192,29 +193,29 @@ module Clusters
end
def kubeclient_auth_options
- { bearer_token: token }
+ {bearer_token: token}
end
def terminal_auth
{
token: token,
ca_pem: ca_pem,
- max_session_time: Gitlab::CurrentSettings.terminal_max_session_time
+ max_session_time: Gitlab::CurrentSettings.terminal_max_session_time,
}
end
def enforce_namespace_to_lower_case
- self.namespace = self.namespace&.downcase
+ self.namespace = namespace&.downcase
end
def enforce_ca_whitespace_trimming
- self.ca_pem = self.ca_pem&.strip
- self.token = self.token&.strip
+ self.ca_pem = ca_pem&.strip
+ self.token = token&.strip
end
def no_namespace
if namespace
- errors.add(:namespace, 'only allowed for project cluster')
+ errors.add(:namespace, "only allowed for project cluster")
end
end
@@ -222,7 +223,7 @@ module Clusters
return unless managed?
if api_url_changed? || token_changed? || ca_pem_changed?
- errors.add(:base, _('Cannot modify managed Kubernetes cluster'))
+ errors.add(:base, _("Cannot modify managed Kubernetes cluster"))
return false
end
diff --git a/app/models/clusters/project.rb b/app/models/clusters/project.rb
index 15092b1c9d2..8cf7d2dea82 100644
--- a/app/models/clusters/project.rb
+++ b/app/models/clusters/project.rb
@@ -2,12 +2,12 @@
module Clusters
class Project < ActiveRecord::Base
- self.table_name = 'cluster_projects'
+ self.table_name = "cluster_projects"
- belongs_to :cluster, class_name: 'Clusters::Cluster'
- belongs_to :project, class_name: '::Project'
+ belongs_to :cluster, class_name: "Clusters::Cluster"
+ belongs_to :project, class_name: "::Project"
- has_many :kubernetes_namespaces, class_name: 'Clusters::KubernetesNamespace', foreign_key: :cluster_project_id
- has_one :kubernetes_namespace, -> { order(id: :desc) }, class_name: 'Clusters::KubernetesNamespace', foreign_key: :cluster_project_id
+ has_many :kubernetes_namespaces, class_name: "Clusters::KubernetesNamespace", foreign_key: :cluster_project_id
+ has_one :kubernetes_namespace, -> { order(id: :desc) }, class_name: "Clusters::KubernetesNamespace", foreign_key: :cluster_project_id
end
end
diff --git a/app/models/clusters/providers/gcp.rb b/app/models/clusters/providers/gcp.rb
index 16b59cd9d14..500f62f874f 100644
--- a/app/models/clusters/providers/gcp.rb
+++ b/app/models/clusters/providers/gcp.rb
@@ -3,24 +3,24 @@
module Clusters
module Providers
class Gcp < ActiveRecord::Base
- self.table_name = 'cluster_providers_gcp'
+ self.table_name = "cluster_providers_gcp"
- belongs_to :cluster, inverse_of: :provider_gcp, class_name: 'Clusters::Cluster'
+ belongs_to :cluster, inverse_of: :provider_gcp, class_name: "Clusters::Cluster"
- default_value_for :zone, 'us-central1-a'
+ default_value_for :zone, "us-central1-a"
default_value_for :num_nodes, 3
- default_value_for :machine_type, 'n1-standard-2'
+ default_value_for :machine_type, "n1-standard-2"
attr_encrypted :access_token,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
validates :gcp_project_id,
length: 1..63,
format: {
with: Gitlab::Regex.kubernetes_namespace_regex,
- message: Gitlab::Regex.kubernetes_namespace_regex_message
+ message: Gitlab::Regex.kubernetes_namespace_regex_message,
}
validates :zone, presence: true
@@ -29,7 +29,7 @@ module Clusters
presence: true,
numericality: {
only_integer: true,
- greater_than: 0
+ greater_than: 0,
}
state_machine :status, initial: :scheduled do
@@ -57,7 +57,7 @@ module Clusters
before_transition any => [:creating] do |provider, transition|
operation_id = transition.args.first
- raise ArgumentError.new('operation_id is required') unless operation_id.present?
+ raise ArgumentError.new("operation_id is required") unless operation_id.present?
provider.operation_id = operation_id
end
diff --git a/app/models/commit.rb b/app/models/commit.rb
index f412d252e5c..38ed1d8d85e 100644
--- a/app/models/commit.rb
+++ b/app/models/commit.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
class Commit
@@ -39,8 +38,8 @@ class Commit
def banzai_render_context(field)
pipeline = field == :description ? :commit_description : :single_line
- context = { pipeline: pipeline, project: self.project }
- context[:author] = self.author if self.author
+ context = {pipeline: pipeline, project: project}
+ context[:author] = author if author
context
end
@@ -51,7 +50,7 @@ class Commit
if commit.is_a?(Commit)
commit
else
- self.new(commit, project)
+ new(commit, project)
end
end
end
@@ -66,7 +65,7 @@ class Commit
return collection unless %w[asc desc].include?(sort)
collection.sort do |a, b|
- operands = [a, b].tap { |o| o.reverse! if sort == 'desc' }
+ operands = [a, b].tap { |o| o.reverse! if sort == "desc" }
attr1, attr2 = operands.first.public_send(order_by), operands.second.public_send(order_by) # rubocop:disable PublicSend
@@ -83,7 +82,7 @@ class Commit
def max_diff_options
{
max_files: DIFF_HARD_LIMIT_FILES,
- max_lines: DIFF_HARD_LIMIT_LINES
+ max_lines: DIFF_HARD_LIMIT_LINES,
}
end
@@ -97,14 +96,14 @@ class Commit
end
def lazy(project, oid)
- BatchLoader.for({ project: project, oid: oid }).batch do |items, loader|
+ BatchLoader.for({project: project, oid: oid}).batch do |items, loader|
items_by_project = items.group_by { |i| i[:project] }
items_by_project.each do |project, commit_ids|
oids = commit_ids.map { |i| i[:oid] }
project.repository.commits_by(oids: oids).each do |commit|
- loader.call({ project: commit.project, oid: commit.id }, commit) if commit
+ loader.call({project: commit.project, oid: commit.id}, commit) if commit
end
end
end
@@ -139,7 +138,7 @@ class Commit
end
def self.reference_prefix
- '@'
+ "@"
end
# Pattern used to extract commit references from text
@@ -180,7 +179,7 @@ class Commit
# Use three dots instead of the ellipsis Unicode character because
# some clients show the raw Unicode value in the merge commit.
- full_title.truncate(81, separator: ' ', omission: '...')
+ full_title.truncate(81, separator: " ", omission: "...")
end
# Returns the full commits title
@@ -214,8 +213,8 @@ class Commit
url: Gitlab::UrlBuilder.build(self),
author: {
name: author_name,
- email: author_email
- }
+ email: author_email,
+ },
}
if with_changed_files
@@ -227,7 +226,7 @@ class Commit
# Discover issues should be closed when this commit is pushed to a project's
# default branch.
- def closes_issues(current_user = self.committer)
+ def closes_issues(current_user = committer)
Gitlab::ClosingIssueExtractor.new(project, current_user).closed_by_message(safe_message)
end
@@ -261,12 +260,12 @@ class Commit
def parent
strong_memoize(:parent) do
- project.commit_by(oid: self.parent_id) if self.parent_id
+ project.commit_by(oid: parent_id) if parent_id
end
end
def notes
- project.notes.for_commit_id(self.id)
+ project.notes.for_commit_id(id)
end
def discussion_notes
@@ -295,8 +294,8 @@ class Commit
def diff_refs
Gitlab::Diff::DiffRefs.new(
- base_sha: self.parent_id || Gitlab::Git::BLANK_SHA,
- head_sha: self.sha
+ base_sha: parent_id || Gitlab::Git::BLANK_SHA,
+ head_sha: sha
)
end
@@ -349,7 +348,7 @@ class Commit
if commits_in_merge_request.present?
message_body << ""
- commits_in_merge_request.reverse.each do |commit_in_merge|
+ commits_in_merge_request.reverse_each do |commit_in_merge|
message_body << "#{commit_in_merge.short_id} #{commit_in_merge.title}"
end
end
@@ -359,7 +358,7 @@ class Commit
end
def cherry_pick_message(user)
- %Q{#{message}\n\n#{cherry_pick_description(user)}}
+ %(#{message}\n\n#{cherry_pick_description(user)})
end
def revert_description(user)
@@ -371,7 +370,7 @@ class Commit
end
def revert_message(user)
- %Q{Revert "#{title.strip}"\n\n#{revert_description(user)}}
+ %(Revert "#{title.strip}"\n\n#{revert_description(user)})
end
def reverts_commit?(commit, user)
@@ -384,9 +383,9 @@ class Commit
def merged_merge_request(current_user)
# Memoize with per-user access check
- @merged_merge_request_hash ||= Hash.new do |hash, user|
+ @merged_merge_request_hash ||= Hash.new { |hash, user|
hash[user] = merged_merge_request_no_cache(user)
- end
+ }
@merged_merge_request_hash[current_user]
end
@@ -403,7 +402,7 @@ class Commit
end
def change_type_title(user)
- merged_merge_request?(user) ? 'merge request' : 'commit'
+ merged_merge_request?(user) ? "merge request" : "commit"
end
# Get the URI type of the given path
@@ -489,7 +488,7 @@ class Commit
end
def repo_changes
- changes = { added: [], modified: [], removed: [] }
+ changes = {added: [], modified: [], removed: []}
raw_deltas.each do |diff|
if diff.deleted_file
diff --git a/app/models/commit_range.rb b/app/models/commit_range.rb
index 094747ee48d..1489a330be3 100644
--- a/app/models/commit_range.rb
+++ b/app/models/commit_range.rb
@@ -36,7 +36,7 @@ class CommitRange
STRICT_PATTERN = /\h{7,40}\.{2,3}\h{7,40}/
def self.reference_prefix
- '@'
+ "@"
end
# Pattern used to extract commit range references from text
@@ -64,7 +64,7 @@ class CommitRange
range_string = range_string.strip
- unless range_string =~ /\A#{PATTERN}\z/
+ unless /\A#{PATTERN}\z/.match?(range_string)
raise ArgumentError, "invalid CommitRange string format: #{range_string}"
end
@@ -89,15 +89,15 @@ class CommitRange
sha_from + notation + sha_to
end
- alias_method :id, :to_s
+ alias id to_s
def to_reference(from = nil, full: false)
project_reference = project.to_reference(from, full: full)
if project_reference.present?
- project_reference + self.class.reference_prefix + self.id
+ project_reference + self.class.reference_prefix + id
else
- self.id
+ id
end
end
@@ -116,11 +116,11 @@ class CommitRange
#
# See `namespace_project_compare_url`
def to_param
- { from: sha_start, to: sha_to }
+ {from: sha_start, to: sha_to}
end
def exclude_start?
- @notation == '..'
+ @notation == ".."
end
# Check if both the starting and ending commit IDs exist in a project's
@@ -148,7 +148,7 @@ class CommitRange
def sha_start
return nil unless sha_from
- exclude_start? ? sha_from + '^' : sha_from
+ exclude_start? ? sha_from + "^" : sha_from
end
def commit_start
@@ -161,6 +161,6 @@ class CommitRange
end
end
- alias_method :sha_end, :sha_to
- alias_method :commit_end, :commit_to
+ alias sha_end sha_to
+ alias commit_end commit_to
end
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index 7f6562b63e5..012085bebd8 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -7,12 +7,12 @@ class CommitStatus < ActiveRecord::Base
include Presentable
include EnumWithNil
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
belongs_to :user
belongs_to :project
- belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :commit_id
- belongs_to :auto_canceled_by, class_name: 'Ci::Pipeline'
+ belongs_to :pipeline, class_name: "Ci::Pipeline", foreign_key: :commit_id
+ belongs_to :auto_canceled_by, class_name: "Ci::Pipeline"
delegate :commit, to: :pipeline
delegate :sha, :short_sha, to: :pipeline
@@ -40,7 +40,7 @@ class CommitStatus < ActiveRecord::Base
scope :ordered, -> { order(:name) }
scope :latest_ordered, -> { latest.ordered.includes(project: :namespace) }
scope :retried_ordered, -> { retried.ordered.includes(project: :namespace) }
- scope :after_stage, -> (index) { where('stage_idx > ?', index) }
+ scope :after_stage, ->(index) { where("stage_idx > ?", index) }
scope :processables, -> { where(type: %w[Ci::Build Ci::Bridge]) }
# We use `CommitStatusEnums.failure_reasons` here so that EE can more easily
@@ -55,7 +55,7 @@ class CommitStatus < ActiveRecord::Base
before_create unless: :importing? do
# rubocop: disable CodeReuse/ServiceClass
Ci::EnsureStageService.new(project, user).execute(self) do |stage|
- self.run_after_commit { StageUpdateWorker.perform_async(stage.id) }
+ run_after_commit { StageUpdateWorker.perform_async(stage.id) }
end
# rubocop: enable CodeReuse/ServiceClass
end
@@ -145,7 +145,7 @@ class CommitStatus < ActiveRecord::Base
end
def group_name
- name.to_s.gsub(%r{\d+[\s:/\\]+\d+\s*}, '').strip
+ name.to_s.gsub(%r{\d+[\s:/\\]+\d+\s*}, "").strip
end
def failed_but_allowed?
@@ -192,7 +192,7 @@ class CommitStatus < ActiveRecord::Base
def sortable_name
name.to_s.split(/(\d+)/).map do |v|
- v =~ /\d+/ ? v.to_i : v
+ /\d+/.match?(v) ? v.to_i : v
end
end
end
diff --git a/app/models/commit_status_enums.rb b/app/models/commit_status_enums.rb
index 152105d9429..2d2ace1521c 100644
--- a/app/models/commit_status_enums.rb
+++ b/app/models/commit_status_enums.rb
@@ -14,7 +14,7 @@ module CommitStatusEnums
runner_unsupported: 6,
stale_schedule: 7,
job_execution_timeout: 8,
- archived_failure: 9
+ archived_failure: 9,
}
end
end
diff --git a/app/models/compare.rb b/app/models/compare.rb
index f1ed84ab5a5..a448867c238 100644
--- a/app/models/compare.rb
+++ b/app/models/compare.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'set'
+require "set"
class Compare
include Gitlab::Utils::StrongMemoize
@@ -13,7 +13,7 @@ class Compare
if compare.is_a?(Compare)
compare
else
- self.new(compare, project)
+ new(compare, project)
end
end
@@ -43,7 +43,7 @@ class Compare
::Commit.new(commit, project) if commit
end
end
- alias_method :commit, :head_commit
+ alias commit head_commit
def start_commit_sha
start_commit&.sha
@@ -74,7 +74,7 @@ class Compare
def diff_refs
Gitlab::Diff::DiffRefs.new(
- base_sha: @straight ? start_commit_sha : base_commit_sha,
+ base_sha: @straight ? start_commit_sha : base_commit_sha,
start_sha: start_commit_sha,
head_sha: head_commit_sha
)
diff --git a/app/models/concerns/atomic_internal_id.rb b/app/models/concerns/atomic_internal_id.rb
index 4e15b60ccd1..1e26abd947a 100644
--- a/app/models/concerns/atomic_internal_id.rb
+++ b/app/models/concerns/atomic_internal_id.rb
@@ -41,7 +41,7 @@ module AtomicInternalId
return value unless scope_value
- scope_attrs = { scope_value.class.table_name.singularize.to_sym => scope_value }
+ scope_attrs = {scope_value.class.table_name.singularize.to_sym => scope_value}
usage = self.class.table_name.to_sym
if value.present?
diff --git a/app/models/concerns/avatarable.rb b/app/models/concerns/avatarable.rb
index 4687ec7d166..0be3fa992fd 100644
--- a/app/models/concerns/avatarable.rb
+++ b/app/models/concerns/avatarable.rb
@@ -9,7 +9,7 @@ module Avatarable
include Gitlab::Utils::StrongMemoize
validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? }
- validates :avatar, file_size: { maximum: 200.kilobytes.to_i }, if: :avatar_changed?
+ validates :avatar, file_size: {maximum: 200.kilobytes.to_i}, if: :avatar_changed?
mount_uploader :avatar, AvatarUploader
@@ -37,24 +37,24 @@ module Avatarable
end
def avatar_type
- unless self.avatar.image?
- errors.add :avatar, "file format is not supported. Please try one of the following supported formats: #{AvatarUploader::IMAGE_EXT.join(', ')}"
+ unless avatar.image?
+ errors.add :avatar, "file format is not supported. Please try one of the following supported formats: #{AvatarUploader::IMAGE_EXT.join(", ")}"
end
end
def avatar_path(only_path: true, size: nil)
- unless self.try(:id)
+ unless try(:id)
return uncached_avatar_path(only_path: only_path, size: size)
end
# Cache this avatar path only within the request because avatars in
# object storage may be generated with time-limited, signed URLs.
- key = "#{self.class.name}:#{self.id}:#{only_path}:#{size}"
+ key = "#{self.class.name}:#{id}:#{only_path}:#{size}"
Gitlab::SafeRequestStore[key] ||= uncached_avatar_path(only_path: only_path, size: size)
end
def uncached_avatar_path(only_path: true, size: nil)
- return unless self.try(:avatar).present?
+ return unless try(:avatar).present?
asset_host = ActionController::Base.asset_host
use_asset_host = asset_host.present?
@@ -93,14 +93,14 @@ module Avatarable
def retrieve_upload_from_batch(identifier)
BatchLoader.for(identifier: identifier, model: self).batch(key: self.class) do |upload_params, loader, args|
model_class = args[:key]
- paths = upload_params.flat_map do |params|
+ paths = upload_params.flat_map { |params|
params[:model].upload_paths(params[:identifier])
- end
+ }
Upload.where(uploader: AvatarUploader.name, path: paths).find_each do |upload|
- model = model_class.instantiate('id' => upload.model_id)
+ model = model_class.instantiate("id" => upload.model_id)
- loader.call({ model: model, identifier: File.basename(upload.path) }, upload)
+ loader.call({model: model, identifier: File.basename(upload.path)}, upload)
end
end
end
diff --git a/app/models/concerns/awardable.rb b/app/models/concerns/awardable.rb
index 14bc56f0eee..96092fcfbd1 100644
--- a/app/models/concerns/awardable.rb
+++ b/app/models/concerns/awardable.rb
@@ -21,7 +21,7 @@ module Awardable
WHERE user_id = :user_id AND
#{"name = :name AND" if name.present?}
awardable_type = :awardable_type AND
- awardable_id = #{self.arel_table.name}.id
+ awardable_id = #{arel_table.name}.id
)
EOL
@@ -35,33 +35,33 @@ module Awardable
FROM award_emoji
WHERE user_id = :user_id AND
awardable_type = :awardable_type AND
- awardable_id = #{self.arel_table.name}.id
+ awardable_id = #{arel_table.name}.id
)
EOL
- where(sql, user_id: user.id, awardable_type: self.name)
+ where(sql, user_id: user.id, awardable_type: name)
end
def order_upvotes_desc
- order_votes(AwardEmoji::UPVOTE_NAME, 'DESC')
+ order_votes(AwardEmoji::UPVOTE_NAME, "DESC")
end
def order_upvotes_asc
- order_votes(AwardEmoji::UPVOTE_NAME, 'ASC')
+ order_votes(AwardEmoji::UPVOTE_NAME, "ASC")
end
def order_downvotes_desc
- order_votes(AwardEmoji::DOWNVOTE_NAME, 'DESC')
+ order_votes(AwardEmoji::DOWNVOTE_NAME, "DESC")
end
# Order votes by emoji, optional sort order param `descending` defaults to true
def order_votes(emoji_name, direction)
- awardable_table = self.arel_table
+ awardable_table = arel_table
awards_table = AwardEmoji.arel_table
join_clause = awardable_table.join(awards_table, Arel::Nodes::OuterJoin).on(
awards_table[:awardable_id].eq(awardable_table[:id]).and(
- awards_table[:awardable_type].eq(self.name).and(
+ awards_table[:awardable_type].eq(name).and(
awards_table[:name].eq(emoji_name)
)
)
@@ -100,7 +100,7 @@ module Awardable
end
def user_authored?(current_user)
- author = self.respond_to?(:author) ? self.author : self.user
+ author = respond_to?(:author) ? self.author : user
author == current_user
end
diff --git a/app/models/concerns/blob_language_from_git_attributes.rb b/app/models/concerns/blob_language_from_git_attributes.rb
index 70213d22147..45ff64d83de 100644
--- a/app/models/concerns/blob_language_from_git_attributes.rb
+++ b/app/models/concerns/blob_language_from_git_attributes.rb
@@ -8,6 +8,6 @@ module BlobLanguageFromGitAttributes
return nil unless project
repository = project.repository
- repository.gitattribute(path, 'gitlab-language')
+ repository.gitattribute(path, "gitlab-language")
end
end
diff --git a/app/models/concerns/blocks_json_serialization.rb b/app/models/concerns/blocks_json_serialization.rb
index 18c00532d78..5cbfd5e11d7 100644
--- a/app/models/concerns/blocks_json_serialization.rb
+++ b/app/models/concerns/blocks_json_serialization.rb
@@ -14,5 +14,5 @@ module BlocksJsonSerialization
"JSON serialization has been disabled on #{self.class.name}"
end
- alias_method :as_json, :to_json
+ alias as_json to_json
end
diff --git a/app/models/concerns/bulk_member_access_load.rb b/app/models/concerns/bulk_member_access_load.rb
index 041ed3755e0..384adefa838 100644
--- a/app/models/concerns/bulk_member_access_load.rb
+++ b/app/models/concerns/bulk_member_access_load.rb
@@ -9,8 +9,8 @@ module BulkMemberAccessLoad
# Determine the maximum access level for a group of resources in bulk.
#
# Returns a Hash mapping resource ID -> maximum access level.
- def max_member_access_for_resource_ids(resource_klass, resource_ids, memoization_index = self.id, &block)
- raise 'Block is mandatory' unless block_given?
+ def max_member_access_for_resource_ids(resource_klass, resource_ids, memoization_index = id, &block)
+ raise "Block is mandatory" unless block_given?
resource_ids = resource_ids.uniq
key = max_member_access_for_resource_key(resource_klass, memoization_index)
@@ -22,7 +22,7 @@ module BulkMemberAccessLoad
end
# Look up only the IDs we need
- resource_ids = resource_ids - access.keys
+ resource_ids -= access.keys
return access if resource_ids.empty?
diff --git a/app/models/concerns/cache_markdown_field.rb b/app/models/concerns/cache_markdown_field.rb
index 1a8570b80c3..191bd418c2e 100644
--- a/app/models/concerns/cache_markdown_field.rb
+++ b/app/models/concerns/cache_markdown_field.rb
@@ -51,12 +51,12 @@ module CacheMarkdownField
cached_markdown_fields.markdown_fields.include?(field)
# Always include a project key, or Banzai complains
- project = self.project if self.respond_to?(:project)
- group = self.group if self.respond_to?(:group)
+ project = self.project if respond_to?(:project)
+ group = self.group if respond_to?(:group)
context = cached_markdown_fields[field].merge(project: project, group: group)
# Banzai is less strict about authors, so don't always have an author key
- context[:author] = self.author if self.respond_to?(:author)
+ context[:author] = author if respond_to?(:author)
context[:markdown_engine] = :common_mark
@@ -66,15 +66,15 @@ module CacheMarkdownField
# Update every column in a row if any one is invalidated, as we only store
# one version per row
def refresh_markdown_cache
- options = { skip_project_check: skip_project_check? }
+ options = {skip_project_check: skip_project_check?}
- updates = cached_markdown_fields.markdown_fields.map do |markdown_field|
+ updates = cached_markdown_fields.markdown_fields.map { |markdown_field|
[
cached_markdown_fields.html_field(markdown_field),
- Banzai::Renderer.cacheless_render_field(self, markdown_field, options)
+ Banzai::Renderer.cacheless_render_field(self, markdown_field, options),
]
- end.to_h
- updates['cached_markdown_version'] = latest_cached_markdown_version
+ }.to_h
+ updates["cached_markdown_version"] = latest_cached_markdown_version
updates.each {|html_field, data| write_attribute(html_field, data) }
end
@@ -150,7 +150,7 @@ module CacheMarkdownField
def attributes
attrs = attributes_before_markdown_cache
- attrs.delete('cached_markdown_version')
+ attrs.delete("cached_markdown_version")
cached_markdown_fields.html_fields.each do |field|
attrs.delete(field)
diff --git a/app/models/concerns/cacheable_attributes.rb b/app/models/concerns/cacheable_attributes.rb
index 3d60f6924c1..ffba6e8fb92 100644
--- a/app/models/concerns/cacheable_attributes.rb
+++ b/app/models/concerns/cacheable_attributes.rb
@@ -9,7 +9,7 @@ module CacheableAttributes
class_methods do
def cache_key
- "#{name}:#{Gitlab::VERSION}:#{Rails.version}".freeze
+ "#{name}:#{Gitlab::VERSION}:#{Rails.version}"
end
# Can be overridden
diff --git a/app/models/concerns/case_sensitivity.rb b/app/models/concerns/case_sensitivity.rb
index c93b6589ee7..325ddc58bf0 100644
--- a/app/models/concerns/case_sensitivity.rb
+++ b/app/models/concerns/case_sensitivity.rb
@@ -17,7 +17,7 @@ module CaseSensitivity
criteria.where(value_in(key, value))
else
criteria.where(value_equal(key, value))
- end
+ end
end
criteria
@@ -32,9 +32,9 @@ module CaseSensitivity
end
def value_in(column, values)
- lower_values = values.map do |value|
+ lower_values = values.map { |value|
lower_value(value)
- end
+ }
lower_column(arel_table[column]).in(lower_values).to_sql
end
@@ -42,7 +42,7 @@ module CaseSensitivity
def lower_value(value)
return value if Gitlab::Database.mysql?
- Arel::Nodes::NamedFunction.new('LOWER', [Arel::Nodes.build_quoted(value)])
+ Arel::Nodes::NamedFunction.new("LOWER", [Arel::Nodes.build_quoted(value)])
end
def lower_column(column)
diff --git a/app/models/concerns/chronic_duration_attribute.rb b/app/models/concerns/chronic_duration_attribute.rb
index af4905115b1..e4fd20bc654 100644
--- a/app/models/concerns/chronic_duration_attribute.rb
+++ b/app/models/concerns/chronic_duration_attribute.rb
@@ -24,7 +24,7 @@ module ChronicDurationAttribute
end
end
- validates virtual_attribute, allow_nil: true, duration: { message: parameters[:error_message] }
+ validates virtual_attribute, allow_nil: true, duration: {message: parameters[:error_message]}
end
alias_method :chronic_duration_attr, :chronic_duration_attr_writer
diff --git a/app/models/concerns/ci/metadatable.rb b/app/models/concerns/ci/metadatable.rb
index 9eed9492b37..cb1a8ce423d 100644
--- a/app/models/concerns/ci/metadatable.rb
+++ b/app/models/concerns/ci/metadatable.rb
@@ -9,7 +9,7 @@ module Ci
extend ActiveSupport::Concern
included do
- has_one :metadata, class_name: 'Ci::BuildMetadata',
+ has_one :metadata, class_name: "Ci::BuildMetadata",
foreign_key: :build_id,
inverse_of: :build,
autosave: true
@@ -23,13 +23,13 @@ module Ci
end
def degenerated?
- self.options.blank?
+ options.blank?
end
def degenerate!
self.class.transaction do
- self.update!(options: nil, yaml_variables: nil)
- self.metadata&.destroy
+ update!(options: nil, yaml_variables: nil)
+ metadata&.destroy
end
end
diff --git a/app/models/concerns/ci/processable.rb b/app/models/concerns/ci/processable.rb
index 1c78b1413a8..f84f9f12dfe 100644
--- a/app/models/concerns/ci/processable.rb
+++ b/app/models/concerns/ci/processable.rb
@@ -17,7 +17,7 @@ module Ci
end
def when
- read_attribute(:when) || 'on_success'
+ read_attribute(:when) || "on_success"
end
def expanded_environment_name
diff --git a/app/models/concerns/deployable.rb b/app/models/concerns/deployable.rb
index bc12b06b5af..6330de41e5b 100644
--- a/app/models/concerns/deployable.rb
+++ b/app/models/concerns/deployable.rb
@@ -24,7 +24,8 @@ module Deployable
tag: tag,
sha: sha,
user: user,
- on_stop: on_stop)
+ on_stop: on_stop
+ )
end
end
end
diff --git a/app/models/concerns/deployment_platform.rb b/app/models/concerns/deployment_platform.rb
index 0107af5f8ec..5d86a7fbb27 100644
--- a/app/models/concerns/deployment_platform.rb
+++ b/app/models/concerns/deployment_platform.rb
@@ -53,12 +53,12 @@ module DeploymentPlatform
def cluster_attributes_from_service_template
{
- name: 'kubernetes-template',
+ name: "kubernetes-template",
projects: [self],
cluster_type: :project_type,
provider_type: :user,
platform_type: :kubernetes,
- platform_kubernetes_attributes: platform_kubernetes_attributes_from_service_template
+ platform_kubernetes_attributes: platform_kubernetes_attributes_from_service_template,
}
end
@@ -67,7 +67,7 @@ module DeploymentPlatform
api_url: kubernetes_service_template.api_url,
ca_pem: kubernetes_service_template.ca_pem,
token: kubernetes_service_template.token,
- namespace: kubernetes_service_template.namespace
+ namespace: kubernetes_service_template.namespace,
}
end
end
diff --git a/app/models/concerns/diff_positionable_note.rb b/app/models/concerns/diff_positionable_note.rb
index b61bf29e6ad..1cae121b024 100644
--- a/app/models/concerns/diff_positionable_note.rb
+++ b/app/models/concerns/diff_positionable_note.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module DiffPositionableNote
extend ActiveSupport::Concern
@@ -11,10 +12,14 @@ module DiffPositionableNote
serialize :change_position, Gitlab::Diff::Position # rubocop:disable Cop/ActiveRecordSerialize
end
- %i(original_position position change_position).each do |meth|
+ %i[original_position position change_position].each do |meth|
define_method "#{meth}=" do |new_position|
if new_position.is_a?(String)
- new_position = JSON.parse(new_position) rescue nil
+ new_position = begin
+ JSON.parse(new_position)
+ rescue
+ nil
+ end
end
if new_position.is_a?(Hash)
@@ -37,7 +42,7 @@ module DiffPositionableNote
end
def supported?
- for_commit? || self.noteable.has_complete_diff_refs?
+ for_commit? || noteable.has_complete_diff_refs?
end
def active?(diff_refs = nil)
@@ -46,13 +51,13 @@ module DiffPositionableNote
diff_refs ||= noteable.diff_refs
- self.position.diff_refs == diff_refs
+ position.diff_refs == diff_refs
end
def set_original_position
return unless position
- self.original_position = self.position.dup unless self.original_position&.complete?
+ self.original_position = position.dup unless original_position&.complete?
end
def update_position
@@ -63,13 +68,13 @@ module DiffPositionableNote
return unless position
tracer = Gitlab::Diff::PositionTracer.new(
- project: self.project,
- old_diff_refs: self.position.diff_refs,
- new_diff_refs: self.noteable.diff_refs,
- paths: self.position.paths
+ project: project,
+ old_diff_refs: position.diff_refs,
+ new_diff_refs: noteable.diff_refs,
+ paths: position.paths
)
- result = tracer.trace(self.position)
+ result = tracer.trace(position)
return unless result
if result[:outdated]
diff --git a/app/models/concerns/discussion_on_diff.rb b/app/models/concerns/discussion_on_diff.rb
index e4e5928f5cf..74488919b62 100644
--- a/app/models/concerns/discussion_on_diff.rb
+++ b/app/models/concerns/discussion_on_diff.rb
@@ -8,21 +8,19 @@ module DiscussionOnDiff
included do
delegate :line_code,
- :original_line_code,
- :note_diff_file,
- :diff_line,
- :active?,
- :created_at_diff?,
-
- to: :first_note
+ :original_line_code,
+ :note_diff_file,
+ :diff_line,
+ :active?,
+ :created_at_diff?,
+ to: :first_note
delegate :file_path,
- :blob,
- :highlighted_diff_lines,
- :diff_lines,
-
- to: :diff_file,
- allow_nil: true
+ :blob,
+ :highlighted_diff_lines,
+ :diff_lines,
+ to: :diff_file,
+ allow_nil: true
end
def diff_discussion?
@@ -79,8 +77,7 @@ module DiscussionOnDiff
def fetch_preloaded_diff_file
fetch_preloaded_diff =
- context_noteable &&
- context_noteable.preloads_discussion_diff_highlighting? &&
+ context_noteable&.preloads_discussion_diff_highlighting? &&
note_diff_file
context_noteable.discussions_diffs.find_by_id(note_diff_file.id) if fetch_preloaded_diff
diff --git a/app/models/concerns/each_batch.rb b/app/models/concerns/each_batch.rb
index 6314b46a7e3..3472c9dea9b 100644
--- a/app/models/concerns/each_batch.rb
+++ b/app/models/concerns/each_batch.rb
@@ -50,7 +50,7 @@ module EachBatch
def each_batch(of: 1000, column: primary_key, order_hint: nil)
unless column
raise ArgumentError,
- 'the column: argument must be set to a column name to use for ordering rows'
+ "the column: argument must be set to a column name to use for ordering rows"
end
start = except(:select)
diff --git a/app/models/concerns/expirable.rb b/app/models/concerns/expirable.rb
index 1f274487935..592f9d8fabf 100644
--- a/app/models/concerns/expirable.rb
+++ b/app/models/concerns/expirable.rb
@@ -4,7 +4,7 @@ module Expirable
extend ActiveSupport::Concern
included do
- scope :expired, -> { where('expires_at <= ?', Time.current) }
+ scope :expired, -> { where("expires_at <= ?", Time.current) }
end
def expired?
diff --git a/app/models/concerns/fast_destroy_all.rb b/app/models/concerns/fast_destroy_all.rb
index f862031bce0..e641c1237aa 100644
--- a/app/models/concerns/fast_destroy_all.rb
+++ b/app/models/concerns/fast_destroy_all.rb
@@ -34,7 +34,7 @@ module FastDestroyAll
included do
before_destroy do
- raise ForbiddenActionError, '`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`'
+ raise ForbiddenActionError, "`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`"
end
end
diff --git a/app/models/concerns/ghost_user.rb b/app/models/concerns/ghost_user.rb
index 15278c431fb..e7255ae710a 100644
--- a/app/models/concerns/ghost_user.rb
+++ b/app/models/concerns/ghost_user.rb
@@ -4,6 +4,6 @@ module GhostUser
extend ActiveSupport::Concern
def ghost_user?
- user && user.ghost?
+ user&.ghost?
end
end
diff --git a/app/models/concerns/group_descendant.rb b/app/models/concerns/group_descendant.rb
index 05cd4265133..68ab20f1371 100644
--- a/app/models/concerns/group_descendant.rb
+++ b/app/models/concerns/group_descendant.rb
@@ -22,12 +22,12 @@ module GroupDescendant
return [] if descendants.empty?
unless descendants.all? { |hierarchy| hierarchy.is_a?(GroupDescendant) }
- raise ArgumentError.new('element is not a hierarchy')
+ raise ArgumentError.new("element is not a hierarchy")
end
- all_hierarchies = descendants.map do |descendant|
+ all_hierarchies = descendants.map { |descendant|
descendant.hierarchy(hierarchy_top, descendants)
- end
+ }
Gitlab::Utils::MergeHash.merge(all_hierarchies)
end
@@ -48,22 +48,22 @@ module GroupDescendant
extras = {
parent: parent.inspect,
child: child.inspect,
- preloaded: preloaded.map(&:full_path)
+ preloaded: preloaded.map(&:full_path),
}
- issue_url = 'https://gitlab.com/gitlab-org/gitlab-ce/issues/40785'
+ issue_url = "https://gitlab.com/gitlab-org/gitlab-ce/issues/40785"
Gitlab::Sentry.track_exception(exception, issue_url: issue_url, extra: extras)
end
if parent.nil? && hierarchy_top.present?
- raise ArgumentError.new('specified top is not part of the tree')
+ raise ArgumentError.new("specified top is not part of the tree")
end
if parent && parent != hierarchy_top
expand_hierarchy_for_child(parent,
- { parent => hierarchy },
- hierarchy_top,
- preloaded)
+ {parent => hierarchy},
+ hierarchy_top,
+ preloaded)
else
hierarchy
end
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index 0d2be4c61ab..c8436fe74f7 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -3,16 +3,16 @@
module HasStatus
extend ActiveSupport::Concern
- DEFAULT_STATUS = 'created'.freeze
+ DEFAULT_STATUS = "created"
BLOCKED_STATUS = %w[manual scheduled].freeze
AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped manual scheduled].freeze
STARTED_STATUSES = %w[running success failed skipped manual scheduled].freeze
ACTIVE_STATUSES = %w[pending running].freeze
COMPLETED_STATUSES = %w[success failed canceled skipped].freeze
ORDERED_STATUSES = %w[failed pending running manual scheduled canceled success skipped created].freeze
- STATUSES_ENUM = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7,
- scheduled: 8 }.freeze
+ STATUSES_ENUM = {created: 0, pending: 1, running: 2, success: 3,
+ failed: 4, canceled: 5, skipped: 6, manual: 7,
+ scheduled: 8,}.freeze
UnknownStatusError = Class.new(StandardError)
@@ -21,16 +21,16 @@ module HasStatus
scope_relevant = respond_to?(:exclude_ignored) ? exclude_ignored : all
scope_warnings = respond_to?(:failed_but_allowed) ? failed_but_allowed : none
- builds = scope_relevant.select('count(*)').to_sql
- created = scope_relevant.created.select('count(*)').to_sql
- success = scope_relevant.success.select('count(*)').to_sql
- manual = scope_relevant.manual.select('count(*)').to_sql
- scheduled = scope_relevant.scheduled.select('count(*)').to_sql
- pending = scope_relevant.pending.select('count(*)').to_sql
- running = scope_relevant.running.select('count(*)').to_sql
- skipped = scope_relevant.skipped.select('count(*)').to_sql
- canceled = scope_relevant.canceled.select('count(*)').to_sql
- warnings = scope_warnings.select('count(*) > 0').to_sql.presence || 'false'
+ builds = scope_relevant.select("count(*)").to_sql
+ created = scope_relevant.created.select("count(*)").to_sql
+ success = scope_relevant.success.select("count(*)").to_sql
+ manual = scope_relevant.manual.select("count(*)").to_sql
+ scheduled = scope_relevant.scheduled.select("count(*)").to_sql
+ pending = scope_relevant.pending.select("count(*)").to_sql
+ running = scope_relevant.running.select("count(*)").to_sql
+ skipped = scope_relevant.skipped.select("count(*)").to_sql
+ canceled = scope_relevant.canceled.select("count(*)").to_sql
+ warnings = scope_warnings.select("count(*) > 0").to_sql.presence || "false"
"(CASE
WHEN (#{builds})=(#{skipped}) AND (#{warnings}) THEN 'success'
@@ -66,30 +66,30 @@ module HasStatus
end
included do
- validates :status, inclusion: { in: AVAILABLE_STATUSES }
+ validates :status, inclusion: {in: AVAILABLE_STATUSES}
state_machine :status, initial: :created do
- state :created, value: 'created'
- state :pending, value: 'pending'
- state :running, value: 'running'
- state :failed, value: 'failed'
- state :success, value: 'success'
- state :canceled, value: 'canceled'
- state :skipped, value: 'skipped'
- state :manual, value: 'manual'
- state :scheduled, value: 'scheduled'
+ state :created, value: "created"
+ state :pending, value: "pending"
+ state :running, value: "running"
+ state :failed, value: "failed"
+ state :success, value: "success"
+ state :canceled, value: "canceled"
+ state :skipped, value: "skipped"
+ state :manual, value: "manual"
+ state :scheduled, value: "scheduled"
end
- scope :created, -> { where(status: 'created') }
- scope :relevant, -> { where(status: AVAILABLE_STATUSES - ['created']) }
- scope :running, -> { where(status: 'running') }
- scope :pending, -> { where(status: 'pending') }
- scope :success, -> { where(status: 'success') }
- scope :failed, -> { where(status: 'failed') }
- scope :canceled, -> { where(status: 'canceled') }
- scope :skipped, -> { where(status: 'skipped') }
- scope :manual, -> { where(status: 'manual') }
- scope :scheduled, -> { where(status: 'scheduled') }
+ scope :created, -> { where(status: "created") }
+ scope :relevant, -> { where(status: AVAILABLE_STATUSES - ["created"]) }
+ scope :running, -> { where(status: "running") }
+ scope :pending, -> { where(status: "pending") }
+ scope :success, -> { where(status: "success") }
+ scope :failed, -> { where(status: "failed") }
+ scope :canceled, -> { where(status: "canceled") }
+ scope :skipped, -> { where(status: "skipped") }
+ scope :manual, -> { where(status: "manual") }
+ scope :scheduled, -> { where(status: "scheduled") }
scope :alive, -> { where(status: [:created, :pending, :running]) }
scope :created_or_pending, -> { where(status: [:created, :pending]) }
scope :running_or_pending, -> { where(status: [:running, :pending]) }
diff --git a/app/models/concerns/has_variable.rb b/app/models/concerns/has_variable.rb
index 2ec42a1029b..342b255347e 100644
--- a/app/models/concerns/has_variable.rb
+++ b/app/models/concerns/has_variable.rb
@@ -6,17 +6,17 @@ module HasVariable
included do
validates :key,
presence: true,
- length: { maximum: 255 },
- format: { with: /\A[a-zA-Z0-9_]+\z/,
- message: "can contain only letters, digits and '_'." }
+ length: {maximum: 255},
+ format: {with: /\A[a-zA-Z0-9_]+\z/,
+ message: "can contain only letters, digits and '_'.",}
scope :order_key_asc, -> { reorder(key: :asc) }
attr_encrypted :value,
- mode: :per_attribute_iv_and_salt,
- insecure_mode: true,
- key: Settings.attr_encrypted_db_key_base,
- algorithm: 'aes-256-cbc'
+ mode: :per_attribute_iv_and_salt,
+ insecure_mode: true,
+ key: Settings.attr_encrypted_db_key_base,
+ algorithm: "aes-256-cbc"
def key=(new_key)
super(new_key.to_s.strip)
@@ -24,6 +24,6 @@ module HasVariable
end
def to_runner_variable
- { key: key, value: value, public: false }
+ {key: key, value: value, public: false}
end
end
diff --git a/app/models/concerns/importable.rb b/app/models/concerns/importable.rb
index 4d2707b08ab..451bae34575 100644
--- a/app/models/concerns/importable.rb
+++ b/app/models/concerns/importable.rb
@@ -4,8 +4,8 @@ module Importable
extend ActiveSupport::Concern
attr_accessor :importing
- alias_method :importing?, :importing
+ alias importing? importing
attr_accessor :imported
- alias_method :imported?, :imported
+ alias imported? imported
end
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 670103bc3f3..82264983cef 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -36,9 +36,9 @@ module Issuable
redact_field :description
- belongs_to :author, class_name: 'User'
- belongs_to :updated_by, class_name: 'User'
- belongs_to :last_edited_by, class_name: 'User'
+ belongs_to :author, class_name: "User"
+ belongs_to :updated_by, class_name: "User"
+ belongs_to :last_edited_by, class_name: "User"
belongs_to :milestone
has_many :notes, as: :noteable, inverse_of: :noteable, dependent: :destroy do # rubocop:disable Cop/ActiveRecordDependent
@@ -60,42 +60,42 @@ module Issuable
has_one :metrics
delegate :name,
- :email,
- :public_email,
- to: :author,
- allow_nil: true,
- prefix: true
+ :email,
+ :public_email,
+ to: :author,
+ allow_nil: true,
+ prefix: true
delegate :name,
- :email,
- :public_email,
- to: :assignee,
- allow_nil: true,
- prefix: true
+ :email,
+ :public_email,
+ to: :assignee,
+ allow_nil: true,
+ prefix: true
validates :author, presence: true
- validates :title, presence: true, length: { maximum: 255 }
+ validates :title, presence: true, length: {maximum: 255}
scope :authored, ->(user) { where(author_id: user) }
scope :recent, -> { reorder(id: :desc) }
scope :of_projects, ->(ids) { where(project_id: ids) }
scope :of_milestones, ->(ids) { where(milestone_id: ids) }
- scope :any_milestone, -> { where('milestone_id IS NOT NULL') }
- scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) }
+ scope :any_milestone, -> { where("milestone_id IS NOT NULL") }
+ scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: {title: title}) }
scope :opened, -> { with_state(:opened) }
scope :only_opened, -> { with_state(:opened) }
scope :closed, -> { with_state(:closed) }
scope :left_joins_milestones, -> { joins("LEFT OUTER JOIN milestones ON #{table_name}.milestone_id = milestones.id") }
- scope :order_milestone_due_desc, -> { left_joins_milestones.reorder('milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date DESC') }
- scope :order_milestone_due_asc, -> { left_joins_milestones.reorder('milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date ASC') }
+ scope :order_milestone_due_desc, -> { left_joins_milestones.reorder("milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date DESC") }
+ scope :order_milestone_due_asc, -> { left_joins_milestones.reorder("milestones.due_date IS NULL, milestones.id IS NULL, milestones.due_date ASC") }
- scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) }
+ scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: {id: nil}) }
scope :any_label, -> { joins(:label_links).group(:id) }
scope :join_project, -> { joins(:project) }
scope :inc_notes_with_associations, -> { includes(notes: [:project, :author, :award_emoji]) }
scope :references_project, -> { references(:project) }
- scope :non_archived, -> { join_project.where(projects: { archived: false }) }
+ scope :non_archived, -> { join_project.where(projects: {archived: false}) }
attr_mentionable :title, pipeline: :single_line
attr_mentionable :description
@@ -140,9 +140,9 @@ module Issuable
# matched_columns - Modify the scope of the query. 'title', 'description' or joining them with a comma.
#
# Returns an ActiveRecord::Relation.
- def full_search(query, matched_columns: 'title,description')
+ def full_search(query, matched_columns: "title,description")
allowed_columns = [:title, :description]
- matched_columns = matched_columns.to_s.split(',').map(&:to_sym)
+ matched_columns = matched_columns.to_s.split(",").map(&:to_sym)
matched_columns &= allowed_columns
# Matching title or description if the matched_columns did not contain any allowed columns.
@@ -154,16 +154,16 @@ module Issuable
def sort_by_attribute(method, excluded_labels: [])
sorted =
case method.to_s
- when 'downvotes_desc' then order_downvotes_desc
- when 'label_priority' then order_labels_priority(excluded_labels: excluded_labels)
- when 'label_priority_desc' then order_labels_priority('DESC', excluded_labels: excluded_labels)
- when 'milestone', 'milestone_due_asc' then order_milestone_due_asc
- when 'milestone_due_desc' then order_milestone_due_desc
- when 'popularity', 'popularity_desc' then order_upvotes_desc
- when 'popularity_asc' then order_upvotes_asc
- when 'priority', 'priority_asc' then order_due_date_and_labels_priority(excluded_labels: excluded_labels)
- when 'priority_desc' then order_due_date_and_labels_priority('DESC', excluded_labels: excluded_labels)
- when 'upvotes_desc' then order_upvotes_desc
+ when "downvotes_desc" then order_downvotes_desc
+ when "label_priority" then order_labels_priority(excluded_labels: excluded_labels)
+ when "label_priority_desc" then order_labels_priority("DESC", excluded_labels: excluded_labels)
+ when "milestone", "milestone_due_asc" then order_milestone_due_asc
+ when "milestone_due_desc" then order_milestone_due_desc
+ when "popularity", "popularity_desc" then order_upvotes_desc
+ when "popularity_asc" then order_upvotes_asc
+ when "priority", "priority_asc" then order_due_date_and_labels_priority(excluded_labels: excluded_labels)
+ when "priority_desc" then order_due_date_and_labels_priority("DESC", excluded_labels: excluded_labels)
+ when "upvotes_desc" then order_upvotes_desc
else order_by(method)
end
@@ -171,7 +171,7 @@ module Issuable
sorted.with_order_id_desc
end
- def order_due_date_and_labels_priority(direction = 'ASC', excluded_labels: [])
+ def order_due_date_and_labels_priority(direction = "ASC", excluded_labels: [])
# The order_ methods also modify the query in other ways:
#
# - For milestones, we add a JOIN.
@@ -184,39 +184,39 @@ module Issuable
# 2. We can't ORDER BY a column that isn't in the GROUP BY and doesn't
# have an aggregate function applied, so we do a useless MIN() instead.
#
- milestones_due_date = 'MIN(milestones.due_date)'
+ milestones_due_date = "MIN(milestones.due_date)"
order_milestone_due_asc
.order_labels_priority(excluded_labels: excluded_labels, extra_select_columns: [milestones_due_date])
.reorder(Gitlab::Database.nulls_last_order(milestones_due_date, direction),
- Gitlab::Database.nulls_last_order('highest_priority', direction))
+ Gitlab::Database.nulls_last_order("highest_priority", direction))
end
- def order_labels_priority(direction = 'ASC', excluded_labels: [], extra_select_columns: [])
+ def order_labels_priority(direction = "ASC", excluded_labels: [], extra_select_columns: [])
params = {
target_type: name,
target_column: "#{table_name}.id",
project_column: "#{table_name}.#{project_foreign_key}",
- excluded_labels: excluded_labels
+ excluded_labels: excluded_labels,
}
highest_priority = highest_label_priority(params).to_sql
select_columns = [
"#{table_name}.*",
- "(#{highest_priority}) AS highest_priority"
+ "(#{highest_priority}) AS highest_priority",
] + extra_select_columns
- select(select_columns.join(', '))
+ select(select_columns.join(", "))
.group(arel_table[:id])
- .reorder(Gitlab::Database.nulls_last_order('highest_priority', direction))
+ .reorder(Gitlab::Database.nulls_last_order("highest_priority", direction))
end
def with_label(title, sort = nil)
if title.is_a?(Array) && title.size > 1
- joins(:labels).where(labels: { title: title }).group(*grouping_columns(sort)).having("COUNT(DISTINCT labels.title) = #{title.size}")
+ joins(:labels).where(labels: {title: title}).group(*grouping_columns(sort)).having("COUNT(DISTINCT labels.title) = #{title.size}")
else
- joins(:labels).where(labels: { title: title })
+ joins(:labels).where(labels: {title: title})
end
end
@@ -227,7 +227,7 @@ module Issuable
def grouping_columns(sort)
grouping_columns = [arel_table[:id]]
- if %w(milestone_due_desc milestone_due_asc milestone).include?(sort)
+ if %w[milestone_due_desc milestone_due_asc milestone].include?(sort)
milestone_table = Milestone.arel_table
grouping_columns << milestone_table[:id]
grouping_columns << milestone_table[:due_date]
@@ -289,14 +289,14 @@ module Issuable
end
if old_assignees != assignees
- if self.is_a?(Issue)
+ if is_a?(Issue)
changes[:assignees] = [old_assignees.map(&:hook_attrs), assignees.map(&:hook_attrs)]
else
changes[:assignee] = [old_assignees&.first&.hook_attrs, assignee&.hook_attrs]
end
end
- if self.respond_to?(:total_time_spent)
+ if respond_to?(:total_time_spent)
old_total_time_spent = old_associations.fetch(:total_time_spent, nil)
if old_total_time_spent != total_time_spent
@@ -313,7 +313,7 @@ module Issuable
end
def label_names
- labels.order('title ASC').pluck(:title)
+ labels.order("title ASC").pluck(:title)
end
# Convert this Issuable class name to a format usable by Ability definitions
@@ -329,8 +329,8 @@ module Issuable
# Returns a Hash of attributes to be used for Twitter card metadata
def card_attributes
{
- 'Author' => author.try(:name),
- 'Assignee' => assignee.try(:name)
+ "Author" => author.try(:name),
+ "Assignee" => assignee.try(:name),
}
end
@@ -353,7 +353,7 @@ module Issuable
end
def updated_tasks
- Taskable.get_updated_tasks(old_content: previous_changes['description'].first,
+ Taskable.get_updated_tasks(old_content: previous_changes["description"].first,
new_content: description)
end
@@ -374,7 +374,7 @@ module Issuable
end
def ensure_metrics
- self.metrics || create_metrics
+ metrics || create_metrics
end
##
diff --git a/app/models/concerns/loaded_in_group_list.rb b/app/models/concerns/loaded_in_group_list.rb
index fc15c6d55ed..143ff09b88d 100644
--- a/app/models/concerns/loaded_in_group_list.rb
+++ b/app/models/concerns/loaded_in_group_list.rb
@@ -6,10 +6,10 @@ module LoadedInGroupList
class_methods do
def with_counts(archived:)
selects_including_counts = [
- 'namespaces.*',
+ "namespaces.*",
"(#{project_count_sql(archived).to_sql}) AS preloaded_project_count",
"(#{member_count_sql.to_sql}) AS preloaded_member_count",
- "(#{subgroup_count_sql.to_sql}) AS preloaded_subgroup_count"
+ "(#{subgroup_count_sql.to_sql}) AS preloaded_subgroup_count",
]
select(selects_including_counts)
@@ -25,10 +25,10 @@ module LoadedInGroupList
projects = Project.arel_table
namespaces = Namespace.arel_table
- base_count = projects.project(Arel.star.count.as('preloaded_project_count'))
- .where(projects[:namespace_id].eq(namespaces[:id]))
+ base_count = projects.project(Arel.star.count.as("preloaded_project_count"))
+ .where(projects[:namespace_id].eq(namespaces[:id]))
- if archived == 'only'
+ if archived == "only"
base_count.where(projects[:archived].eq(true))
elsif Gitlab::Utils.to_boolean(archived)
base_count
@@ -39,9 +39,9 @@ module LoadedInGroupList
def subgroup_count_sql
namespaces = Namespace.arel_table
- children = namespaces.alias('children')
+ children = namespaces.alias("children")
- namespaces.project(Arel.star.count.as('preloaded_subgroup_count'))
+ namespaces.project(Arel.star.count.as("preloaded_subgroup_count"))
.from(children)
.where(children[:parent_id].eq(namespaces[:id]))
end
@@ -50,7 +50,7 @@ module LoadedInGroupList
members = Member.arel_table
namespaces = Namespace.arel_table
- members.project(Arel.star.count.as('preloaded_member_count'))
+ members.project(Arel.star.count.as("preloaded_member_count"))
.where(members[:source_type].eq(Namespace.name))
.where(members[:source_id].eq(namespaces[:id]))
.where(members[:requested_at].eq(nil))
diff --git a/app/models/concerns/maskable.rb b/app/models/concerns/maskable.rb
index 8793f0ec965..311847411a9 100644
--- a/app/models/concerns/maskable.rb
+++ b/app/models/concerns/maskable.rb
@@ -12,8 +12,8 @@ module Maskable
REGEX = /\A\w{8,}\z/
included do
- validates :masked, inclusion: { in: [true, false] }
- validates :value, format: { with: REGEX }, if: :masked?
+ validates :masked, inclusion: {in: [true, false]}
+ validates :value, format: {with: REGEX}, if: :masked?
end
def to_runner_variable
diff --git a/app/models/concerns/mentionable.rb b/app/models/concerns/mentionable.rb
index 0d88b34fb48..cc6891d74d9 100644
--- a/app/models/concerns/mentionable.rb
+++ b/app/models/concerns/mentionable.rb
@@ -25,7 +25,7 @@ module Mentionable
end
if self < Participable
- participant -> (user, ext) { all_references(user, extractor: ext) }
+ participant ->(user, ext) { all_references(user, extractor: ext) }
end
end
@@ -82,7 +82,7 @@ module Mentionable
end
# Extract GFM references to other Mentionables from this Mentionable. Always excludes its #local_reference.
- def referenced_mentionables(current_user = self.author)
+ def referenced_mentionables(current_user = author)
return [] unless matches_cross_reference_regex?
refs = all_references(current_user)
@@ -97,10 +97,10 @@ module Mentionable
# Allows heavy processing to be skipped
def matches_cross_reference_regex?
reference_pattern = if !project || project.default_issues_tracker?
- ReferenceRegexes.default_pattern
- else
- ReferenceRegexes.external_pattern
- end
+ ReferenceRegexes.default_pattern
+ else
+ ReferenceRegexes.external_pattern
+ end
self.class.mentionable_attrs.any? do |attr, _|
__send__(attr) =~ reference_pattern # rubocop:disable GitlabSecurity/PublicSend
diff --git a/app/models/concerns/mentionable/reference_regexes.rb b/app/models/concerns/mentionable/reference_regexes.rb
index b8fb3f71925..ffb4f8233c8 100644
--- a/app/models/concerns/mentionable/reference_regexes.rb
+++ b/app/models/concerns/mentionable/reference_regexes.rb
@@ -6,14 +6,14 @@ module Mentionable
def self.reference_pattern(link_patterns, issue_pattern)
Regexp.union(link_patterns,
- issue_pattern,
- *other_patterns)
+ issue_pattern,
+ *other_patterns)
end
def self.other_patterns
[
Commit.reference_pattern,
- MergeRequest.reference_pattern
+ MergeRequest.reference_pattern,
]
end
@@ -28,7 +28,7 @@ module Mentionable
def self.external_pattern
strong_memoize(:external_pattern) do
issue_pattern = IssueTrackerService.reference_pattern
- link_patterns = URI.regexp(%w(http https))
+ link_patterns = URI.regexp(%w[http https])
reference_pattern(link_patterns, issue_pattern)
end
end
diff --git a/app/models/concerns/milestoneish.rb b/app/models/concerns/milestoneish.rb
index 055ffe04646..05aa8ba098e 100644
--- a/app/models/concerns/milestoneish.rb
+++ b/app/models/concerns/milestoneish.rb
@@ -3,7 +3,7 @@
module Milestoneish
def closed_items_count(user)
memoize_per_user(user, :closed_items_count) do
- (count_issues_by_state(user)['closed'] || 0) + merge_requests.closed_and_merged.size
+ (count_issues_by_state(user)["closed"] || 0) + merge_requests.closed_and_merged.size
end
end
@@ -47,15 +47,15 @@ module Milestoneish
end
def sorted_issues(user)
- issues_visible_to_user(user).preload_associations.sort_by_attribute('label_priority')
+ issues_visible_to_user(user).preload_associations.sort_by_attribute("label_priority")
end
def sorted_merge_requests
- merge_requests.sort_by_attribute('label_priority')
+ merge_requests.sort_by_attribute("label_priority")
end
def upcoming?
- start_date && start_date.future?
+ start_date&.future?
end
def expires_at
@@ -69,7 +69,7 @@ module Milestoneish
end
def expired?
- due_date && due_date.past?
+ due_date&.past?
end
def group_milestone?
diff --git a/app/models/concerns/mirror_authentication.rb b/app/models/concerns/mirror_authentication.rb
index e3e1a0441f8..a2a7e1bf862 100644
--- a/app/models/concerns/mirror_authentication.rb
+++ b/app/models/concerns/mirror_authentication.rb
@@ -5,18 +5,18 @@
# serialized attribute. It also needs an `url` method to be defined
module MirrorAuthentication
SSH_PRIVATE_KEY_OPTS = {
- type: 'RSA',
- bits: 4096
+ type: "RSA",
+ bits: 4096,
}.freeze
extend ActiveSupport::Concern
included do
- validates :auth_method, inclusion: { in: %w[password ssh_public_key] }, allow_blank: true
+ validates :auth_method, inclusion: {in: %w[password ssh_public_key]}, allow_blank: true
# We should generate a key even if there's no SSH URL present
before_validation :generate_ssh_private_key!, if: -> {
- regenerate_ssh_private_key || ( auth_method == 'ssh_public_key' && ssh_private_key.blank? )
+ regenerate_ssh_private_key || (auth_method == "ssh_public_key" && ssh_private_key.blank?)
}
credentials_field :auth_method, reader: false
@@ -53,15 +53,15 @@ module MirrorAuthentication
attr_accessor :regenerate_ssh_private_key
def ssh_key_auth?
- ssh_mirror_url? && auth_method == 'ssh_public_key'
+ ssh_mirror_url? && auth_method == "ssh_public_key"
end
def password_auth?
- auth_method == 'password'
+ auth_method == "password"
end
def ssh_mirror_url?
- url&.start_with?('ssh://')
+ url&.start_with?("ssh://")
end
def ssh_known_hosts_verified_by
@@ -75,7 +75,7 @@ module MirrorAuthentication
def auth_method
auth_method = credentials.fetch(:auth_method, nil) if credentials.present?
- auth_method.presence || 'password'
+ auth_method.presence || "password"
end
def ssh_public_key
diff --git a/app/models/concerns/noteable.rb b/app/models/concerns/noteable.rb
index 3c74034b527..0d8b6d15980 100644
--- a/app/models/concerns/noteable.rb
+++ b/app/models/concerns/noteable.rb
@@ -4,12 +4,12 @@ module Noteable
extend ActiveSupport::Concern
# `Noteable` class names that support resolvable notes.
- RESOLVABLE_TYPES = %w(MergeRequest).freeze
+ RESOLVABLE_TYPES = %w[MergeRequest].freeze
class_methods do
# `Noteable` class names that support replying to individual notes.
def replyable_types
- %w(Issue MergeRequest)
+ %w[Issue MergeRequest]
end
end
diff --git a/app/models/concerns/participable.rb b/app/models/concerns/participable.rb
index 614c3242874..b78b3329673 100644
--- a/app/models/concerns/participable.rb
+++ b/app/models/concerns/participable.rb
@@ -64,9 +64,9 @@ module Participable
private
def all_participants
- @all_participants ||= Hash.new do |hash, user|
+ @all_participants ||= Hash.new { |hash, user|
hash[user] = raw_participants(user)
- end
+ }
end
def raw_participants(current_user = nil)
diff --git a/app/models/concerns/project_features_compatibility.rb b/app/models/concerns/project_features_compatibility.rb
index f268a842db4..19c830fe569 100644
--- a/app/models/concerns/project_features_compatibility.rb
+++ b/app/models/concerns/project_features_compatibility.rb
@@ -4,7 +4,7 @@
#
# After migrating issues_enabled merge_requests_enabled builds_enabled snippets_enabled and wiki_enabled
# fields to a new table "project_features", support for the old fields is still needed in the API.
-require 'gitlab/utils'
+require "gitlab/utils"
module ProjectFeaturesCompatibility
extend ActiveSupport::Concern
diff --git a/app/models/concerns/project_services_loggable.rb b/app/models/concerns/project_services_loggable.rb
index fecd77cdc98..af1a2d4a99e 100644
--- a/app/models/concerns/project_services_loggable.rb
+++ b/app/models/concerns/project_services_loggable.rb
@@ -18,7 +18,7 @@ module ProjectServicesLoggable
service_class: self.class.name,
project_id: project.id,
project_path: project.full_path,
- message: message
+ message: message,
}.merge(params)
end
diff --git a/app/models/concerns/prometheus_adapter.rb b/app/models/concerns/prometheus_adapter.rb
index a29e80fe0c1..86bc522c418 100644
--- a/app/models/concerns/prometheus_adapter.rb
+++ b/app/models/concerns/prometheus_adapter.rb
@@ -40,10 +40,10 @@ module PrometheusAdapter
{
success: true,
data: data,
- last_update: Time.now.utc
+ last_update: Time.now.utc,
}
rescue Gitlab::PrometheusClient::Error => err
- { success: false, result: err.message }
+ {success: false, result: err.message}
end
def query_klass_for(query_name)
diff --git a/app/models/concerns/protected_ref.rb b/app/models/concerns/protected_ref.rb
index af387c99f3d..26adb6cfc44 100644
--- a/app/models/concerns/protected_ref.rb
+++ b/app/models/concerns/protected_ref.rb
@@ -13,7 +13,7 @@ module ProtectedRef
end
def commit
- project.commit(self.name)
+ project.commit(name)
end
class_methods do
@@ -25,9 +25,9 @@ module ProtectedRef
# If we don't `protected_branch` or `protected_tag` would be empty and
# `project` cannot be delegated to it, which in turn would cause validations
# to fail.
- has_many :"#{type}_access_levels", inverse_of: self.model_name.singular
+ has_many :"#{type}_access_levels", inverse_of: model_name.singular
- validates :"#{type}_access_levels", length: { is: 1, message: "are restricted to a single instance per #{self.model_name.human}." }
+ validates :"#{type}_access_levels", length: {is: 1, message: "are restricted to a single instance per #{model_name.human}."}
accepts_nested_attributes_for :"#{type}_access_levels", allow_destroy: true
end
@@ -46,7 +46,7 @@ module ProtectedRef
end
def access_levels_for_ref(ref, action:, protected_refs: nil)
- self.matching(ref, protected_refs: protected_refs)
+ matching(ref, protected_refs: protected_refs)
.map(&:"#{action}_access_levels").flatten
end
@@ -57,13 +57,13 @@ module ProtectedRef
# This method optionally takes in a list of `protected_refs` to search
# through, to avoid calling out to the database.
def matching(ref_name, protected_refs: nil)
- (protected_refs || self.all).select { |protected_ref| protected_ref.matches?(ref_name) }
+ (protected_refs || all).select { |protected_ref| protected_ref.matches?(ref_name) }
end
end
private
def ref_matcher
- @ref_matcher ||= RefMatcher.new(self.name)
+ @ref_matcher ||= RefMatcher.new(name)
end
end
diff --git a/app/models/concerns/protected_ref_access.rb b/app/models/concerns/protected_ref_access.rb
index 583751ea6ac..60e0ab45f11 100644
--- a/app/models/concerns/protected_ref_access.rb
+++ b/app/models/concerns/protected_ref_access.rb
@@ -4,9 +4,9 @@ module ProtectedRefAccess
extend ActiveSupport::Concern
HUMAN_ACCESS_LEVELS = {
- Gitlab::Access::MAINTAINER => "Maintainers".freeze,
- Gitlab::Access::DEVELOPER => "Developers + Maintainers".freeze,
- Gitlab::Access::NO_ACCESS => "No one".freeze
+ Gitlab::Access::MAINTAINER => "Maintainers",
+ Gitlab::Access::DEVELOPER => "Developers + Maintainers",
+ Gitlab::Access::NO_ACCESS => "No one",
}.freeze
class_methods do
@@ -14,7 +14,7 @@ module ProtectedRefAccess
[
Gitlab::Access::MAINTAINER,
Gitlab::Access::DEVELOPER,
- Gitlab::Access::NO_ACCESS
+ Gitlab::Access::NO_ACCESS,
]
end
end
@@ -23,19 +23,19 @@ module ProtectedRefAccess
scope :master, -> { maintainer } # @deprecated
scope :maintainer, -> { where(access_level: Gitlab::Access::MAINTAINER) }
scope :developer, -> { where(access_level: Gitlab::Access::DEVELOPER) }
- scope :by_user, -> (user) { where(user_id: user ) }
- scope :by_group, -> (group) { where(group_id: group ) }
+ scope :by_user, ->(user) { where(user_id: user) }
+ scope :by_group, ->(group) { where(group_id: group) }
scope :for_role, -> { where(user_id: nil, group_id: nil) }
scope :for_user, -> { where.not(user_id: nil) }
scope :for_group, -> { where.not(group_id: nil) }
validates :access_level, presence: true, if: :role?, inclusion: {
- in: self.allowed_access_levels
+ in: allowed_access_levels,
}
end
def humanize
- HUMAN_ACCESS_LEVELS[self.access_level]
+ HUMAN_ACCESS_LEVELS[access_level]
end
# CE access levels are always role-based,
diff --git a/app/models/concerns/reactive_caching.rb b/app/models/concerns/reactive_caching.rb
index de77ca3e963..bc686828aa2 100644
--- a/app/models/concerns/reactive_caching.rb
+++ b/app/models/concerns/reactive_caching.rb
@@ -118,11 +118,11 @@ module ReactiveCaching
prefix = self.class.reactive_cache_key
prefix = prefix.call(self) if prefix.respond_to?(:call)
- ([prefix].flatten + qualifiers).join(':')
+ ([prefix].flatten + qualifiers).join(":")
end
def alive_reactive_cache_key(*qualifiers)
- full_reactive_cache_key(*(qualifiers + ['alive']))
+ full_reactive_cache_key(*(qualifiers + ["alive"]))
end
def locking_reactive_cache(*args)
diff --git a/app/models/concerns/redactable.rb b/app/models/concerns/redactable.rb
index 5ad96d6cc46..fbbb88f5935 100644
--- a/app/models/concerns/redactable.rb
+++ b/app/models/concerns/redactable.rb
@@ -26,7 +26,7 @@ module Redactable
text = public_send(field) # rubocop:disable GitlabSecurity/PublicSend
return unless text.present?
- redacted = text.gsub(UNSUBSCRIBE_PATTERN, '/sent_notifications/REDACTED/unsubscribe')
+ redacted = text.gsub(UNSUBSCRIBE_PATTERN, "/sent_notifications/REDACTED/unsubscribe")
public_send("#{field}=", redacted) # rubocop:disable GitlabSecurity/PublicSend
end
diff --git a/app/models/concerns/redis_cacheable.rb b/app/models/concerns/redis_cacheable.rb
index 4bb4ffe2a8e..0e7d8a1af09 100644
--- a/app/models/concerns/redis_cacheable.rb
+++ b/app/models/concerns/redis_cacheable.rb
@@ -10,7 +10,7 @@ module RedisCacheable
def cached_attr_reader(*attributes)
attributes.each do |attribute|
define_method(attribute) do
- unless self.has_attribute?(attribute)
+ unless has_attribute?(attribute)
raise ArgumentError, "`cached_attr_reader` requires the #{self.class.name}\##{attribute} attribute to have a database column"
end
@@ -36,7 +36,7 @@ module RedisCacheable
private
def cache_attribute_key
- "cache:#{self.class.name}:#{self.id}:attributes"
+ "cache:#{self.class.name}:#{id}:attributes"
end
def cached_attributes
diff --git a/app/models/concerns/referable.rb b/app/models/concerns/referable.rb
index 58143a32fdc..5d21719fdff 100644
--- a/app/models/concerns/referable.rb
+++ b/app/models/concerns/referable.rb
@@ -20,7 +20,7 @@ module Referable
#
# Returns a String
def to_reference(_from = nil, full:)
- ''
+ ""
end
def reference_link_text(from = nil)
@@ -52,7 +52,7 @@ module Referable
#
# Returns a String
def reference_prefix
- ''
+ ""
end
# Regexp pattern used to match references to this object
diff --git a/app/models/concerns/relative_positioning.rb b/app/models/concerns/relative_positioning.rb
index 46d2c345758..3cd21888a92 100644
--- a/app/models/concerns/relative_positioning.rb
+++ b/app/models/concerns/relative_positioning.rb
@@ -20,7 +20,7 @@ module RelativePositioning
max_relative_position = objects.first.max_relative_position
- self.transaction do
+ transaction do
objects.each do |object|
relative_position = position_between(max_relative_position, MAX_POSITION)
object.relative_position = relative_position
@@ -58,20 +58,20 @@ module RelativePositioning
end
def min_relative_position(&block)
- calculate_relative_position('MIN', &block)
+ calculate_relative_position("MIN", &block)
end
def max_relative_position(&block)
- calculate_relative_position('MAX', &block)
+ calculate_relative_position("MAX", &block)
end
def prev_relative_position
prev_pos = nil
- if self.relative_position
- prev_pos = max_relative_position do |relation|
- relation.where('relative_position < ?', self.relative_position)
- end
+ if relative_position
+ prev_pos = max_relative_position { |relation|
+ relation.where("relative_position < ?", relative_position)
+ }
end
prev_pos
@@ -80,10 +80,10 @@ module RelativePositioning
def next_relative_position
next_pos = nil
- if self.relative_position
- next_pos = min_relative_position do |relation|
- relation.where('relative_position > ?', self.relative_position)
- end
+ if relative_position
+ next_pos = min_relative_position { |relation|
+ relation.where("relative_position > ?", relative_position)
+ }
end
next_pos
@@ -171,16 +171,16 @@ module RelativePositioning
# MAX(relative_position) without the GROUP BY, due to index usage:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/54276#note_119340977
relation = self.class
- .in_parents(parent_ids)
- .order(Gitlab::Database.nulls_last_order('position', 'DESC'))
- .limit(1)
- .group(self.class.parent_column)
+ .in_parents(parent_ids)
+ .order(Gitlab::Database.nulls_last_order("position", "DESC"))
+ .limit(1)
+ .group(self.class.parent_column)
relation = yield relation if block_given?
relation
.pluck(self.class.parent_column, "#{calculation}(relative_position) AS position")
- .first&.
- last
+ .first
+ &.last
end
end
diff --git a/app/models/concerns/resolvable_discussion.rb b/app/models/concerns/resolvable_discussion.rb
index c0490af2453..f017ffa585c 100644
--- a/app/models/concerns/resolvable_discussion.rb
+++ b/app/models/concerns/resolvable_discussion.rb
@@ -25,12 +25,11 @@ module ResolvableDiscussion
delegate :potentially_resolvable?, to: :first_note
- delegate :resolved_at,
- :resolved_by,
- :resolved_by_push?,
-
- to: :last_resolved_note,
- allow_nil: true
+ delegate :resolved_at,
+ :resolved_by,
+ :resolved_by_push?,
+ to: :last_resolved_note,
+ allow_nil: true
end
def resolvable?
@@ -63,7 +62,7 @@ module ResolvableDiscussion
return unless resolved?
strong_memoize(:last_resolved_note) do
- resolved_notes.sort_by(&:resolved_at).last
+ resolved_notes.max_by(&:resolved_at)
end
end
@@ -79,8 +78,8 @@ module ResolvableDiscussion
return false unless current_user
return false unless resolvable?
- current_user == self.noteable.author ||
- current_user.can?(:resolve_note, self.project)
+ current_user == noteable.author ||
+ current_user.can?(:resolve_note, project)
end
def resolve!(current_user)
diff --git a/app/models/concerns/resolvable_note.rb b/app/models/concerns/resolvable_note.rb
index 16ea330701d..878f6cc18c4 100644
--- a/app/models/concerns/resolvable_note.rb
+++ b/app/models/concerns/resolvable_note.rb
@@ -4,7 +4,7 @@ module ResolvableNote
extend ActiveSupport::Concern
# Names of all subclasses of `Note` that can be resolvable.
- RESOLVABLE_TYPES = %w(DiffNote DiscussionNote).freeze
+ RESOLVABLE_TYPES = %w[DiffNote DiscussionNote].freeze
included do
belongs_to :resolved_by, class_name: "User"
@@ -45,7 +45,7 @@ module ResolvableNote
def resolved?
return false unless resolvable?
- self.resolved_at.present?
+ resolved_at.present?
end
def to_be_resolved?
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index b9ffc64e4a9..cbe4b3e239b 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -45,7 +45,7 @@ module Routable
# clients' DBs) that have the same path with different cases.
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/18603. Also note that
# our unique index is case-sensitive in Postgres.
- binary = Gitlab::Database.mysql? ? 'BINARY' : ''
+ binary = Gitlab::Database.mysql? ? "BINARY" : ""
order_sql = "(CASE WHEN #{binary} routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)"
found = where_full_path_in([path]).reorder(order_sql).take
return found if found
@@ -54,7 +54,7 @@ module Routable
if Gitlab::Database.postgresql?
joins(:redirect_routes).find_by("LOWER(redirect_routes.path) = LOWER(?)", path)
else
- joins(:redirect_routes).find_by(redirect_routes: { path: path })
+ joins(:redirect_routes).find_by(redirect_routes: {path: path})
end
end
end
@@ -86,7 +86,7 @@ module Routable
if wheres.empty?
none
else
- joins(:route).where(wheres.join(' OR '))
+ joins(:route).where(wheres.join(" OR "))
end
end
end
@@ -100,12 +100,12 @@ module Routable
end
def full_path_components
- full_path.split('/')
+ full_path.split("/")
end
def build_full_path
if parent && path
- parent.full_path + '/' + path
+ parent.full_path + "/" + path
else
path
end
@@ -119,8 +119,8 @@ module Routable
private
def set_path_errors
- route_path_errors = self.errors.delete(:"route.path")
- self.errors[:path].concat(route_path_errors) if route_path_errors
+ route_path_errors = errors.delete(:"route.path")
+ errors[:path].concat(route_path_errors) if route_path_errors
end
def full_name_changed?
@@ -133,7 +133,7 @@ module Routable
def build_full_name
if parent && name
- parent.human_name + ' / ' + name
+ parent.human_name + " / " + name
else
name
end
diff --git a/app/models/concerns/sha_attribute.rb b/app/models/concerns/sha_attribute.rb
index a479bef993c..7ec07d2fc4e 100644
--- a/app/models/concerns/sha_attribute.rb
+++ b/app/models/concerns/sha_attribute.rb
@@ -5,7 +5,7 @@ module ShaAttribute
class_methods do
def sha_attribute(name)
- return if ENV['STATIC_VERIFICATION']
+ return if ENV["STATIC_VERIFICATION"]
validate_binary_column_exists!(name) unless Rails.env.production?
diff --git a/app/models/concerns/sortable.rb b/app/models/concerns/sortable.rb
index 29e48f0c5f7..c1c8210f759 100644
--- a/app/models/concerns/sortable.rb
+++ b/app/models/concerns/sortable.rb
@@ -22,15 +22,15 @@ module Sortable
class_methods do
def order_by(method)
case method.to_s
- when 'created_asc' then order_created_asc
- when 'created_date' then order_created_desc
- when 'created_desc' then order_created_desc
- when 'id_asc' then order_id_asc
- when 'id_desc' then order_id_desc
- when 'name_asc' then order_name_asc
- when 'name_desc' then order_name_desc
- when 'updated_asc' then order_updated_asc
- when 'updated_desc' then order_updated_desc
+ when "created_asc" then order_created_asc
+ when "created_date" then order_created_desc
+ when "created_desc" then order_created_desc
+ when "id_asc" then order_id_asc
+ when "id_desc" then order_id_desc
+ when "name_asc" then order_name_asc
+ when "name_desc" then order_name_desc
+ when "updated_asc" then order_updated_asc
+ when "updated_desc" then order_updated_desc
else
all
end
@@ -50,7 +50,7 @@ module Sortable
if target_type_column
query.where("label_links.target_type = #{target_type_column}")
else
- query.where(label_links: { target_type: target_type })
+ query.where(label_links: {target_type: target_type})
end
query = query.where.not(title: excluded_labels) if excluded_labels.present?
diff --git a/app/models/concerns/spammable.rb b/app/models/concerns/spammable.rb
index 3ff4b4046d3..079ab6d693d 100644
--- a/app/models/concerns/spammable.rb
+++ b/app/models/concerns/spammable.rb
@@ -26,7 +26,7 @@ module Spammable
end
def submittable_as_spam_by?(current_user)
- current_user && current_user.admin? && submittable_as_spam?
+ current_user&.admin? && submittable_as_spam?
end
def submittable_as_spam?
@@ -39,13 +39,13 @@ module Spammable
def check_for_spam
error_msg = if Gitlab::Recaptcha.enabled?
- "Your #{spammable_entity_type} has been recognized as spam. "\
- "Please, change the content or solve the reCAPTCHA to proceed."
- else
- "Your #{spammable_entity_type} has been recognized as spam and has been discarded."
- end
+ "Your #{spammable_entity_type} has been recognized as spam. "\
+ "Please, change the content or solve the reCAPTCHA to proceed."
+ else
+ "Your #{spammable_entity_type} has been recognized as spam and has been discarded."
+ end
- self.errors.add(:base, error_msg) if spam?
+ errors.add(:base, error_msg) if spam?
end
def spammable_entity_type
@@ -53,25 +53,25 @@ module Spammable
end
def spam_title
- attr = self.class.spammable_attrs.find do |_, options|
+ attr = self.class.spammable_attrs.find { |_, options|
options.fetch(:spam_title, false)
- end
+ }
public_send(attr.first) if attr && respond_to?(attr.first.to_sym) # rubocop:disable GitlabSecurity/PublicSend
end
def spam_description
- attr = self.class.spammable_attrs.find do |_, options|
+ attr = self.class.spammable_attrs.find { |_, options|
options.fetch(:spam_description, false)
- end
+ }
public_send(attr.first) if attr && respond_to?(attr.first.to_sym) # rubocop:disable GitlabSecurity/PublicSend
end
def spammable_text
- result = self.class.spammable_attrs.map do |attr|
+ result = self.class.spammable_attrs.map { |attr|
public_send(attr.first) # rubocop:disable GitlabSecurity/PublicSend
- end
+ }
result.reject(&:blank?).join("\n")
end
diff --git a/app/models/concerns/storage/legacy_namespace.rb b/app/models/concerns/storage/legacy_namespace.rb
index 498996f4f80..fefc3b4a1c6 100644
--- a/app/models/concerns/storage/legacy_namespace.rb
+++ b/app/models/concerns/storage/legacy_namespace.rb
@@ -14,8 +14,8 @@ module Storage
end
parent_was = if parent_changed? && parent_id_was.present?
- Namespace.find(parent_id_was) # raise NotFound early if needed
- end
+ Namespace.find(parent_id_was) # raise NotFound early if needed
+ end
move_repositories
@@ -38,7 +38,7 @@ module Storage
write_projects_repository_config
rescue => e
# Raise if development/test environment, else just notify Sentry
- Gitlab::Sentry.track_exception(e, extra: { full_path_was: full_path_was, full_path: full_path, action: 'move_dir' })
+ Gitlab::Sentry.track_exception(e, extra: {full_path_was: full_path_was, full_path: full_path, action: "move_dir"})
end
true # false would cancel later callbacks but not rollback
@@ -68,7 +68,7 @@ module Storage
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
- raise Gitlab::UpdatePathError.new('namespace directory cannot be moved')
+ raise Gitlab::UpdatePathError.new("namespace directory cannot be moved")
end
end
end
@@ -82,7 +82,7 @@ module Storage
# pending delete. Unscoping also get rids of the default order, which causes
# problems with SELECT DISTINCT.
Project.unscoped do
- all_projects.select('distinct(repository_storage)').to_a.map(&:repository_storage)
+ all_projects.select("distinct(repository_storage)").to_a.map(&:repository_storage)
end
end
@@ -94,7 +94,7 @@ module Storage
new_path = "#{full_path}+#{id}+deleted"
if gitlab_shell.mv_namespace(repository_storage, full_path, new_path)
- Gitlab::AppLogger.info %Q(Namespace directory "#{full_path}" moved to "#{new_path}")
+ Gitlab::AppLogger.info %(Namespace directory "#{full_path}" moved to "#{new_path}")
# Remove namespace directory async with delay so
# GitLab has time to remove all projects first
diff --git a/app/models/concerns/storage/legacy_project_wiki.rb b/app/models/concerns/storage/legacy_project_wiki.rb
index a377fa1e5de..7c308ac9efa 100644
--- a/app/models/concerns/storage/legacy_project_wiki.rb
+++ b/app/models/concerns/storage/legacy_project_wiki.rb
@@ -5,7 +5,7 @@ module Storage
extend ActiveSupport::Concern
def disk_path
- project.disk_path + '.wiki'
+ project.disk_path + ".wiki"
end
end
end
diff --git a/app/models/concerns/strip_attribute.rb b/app/models/concerns/strip_attribute.rb
index c9f5ba7793d..af05b3c71d3 100644
--- a/app/models/concerns/strip_attribute.rb
+++ b/app/models/concerns/strip_attribute.rb
@@ -30,7 +30,7 @@ module StripAttribute
def strip_attributes
self.class.strip_attrs.each do |attr|
- self[attr].strip! if self[attr] && self[attr].respond_to?(:strip!)
+ self[attr].strip! if self[attr]&.respond_to?(:strip!)
end
end
end
diff --git a/app/models/concerns/subscribable.rb b/app/models/concerns/subscribable.rb
index 92a5c1112af..1f74f54e1db 100644
--- a/app/models/concerns/subscribable.rb
+++ b/app/models/concerns/subscribable.rb
@@ -32,8 +32,8 @@ module Subscribable
def subscribers(project)
relation = subscriptions_available(project)
- .where(subscribed: true)
- .select(:user_id)
+ .where(subscribed: true)
+ .select(:user_id)
User.where(id: relation)
end
diff --git a/app/models/concerns/taskable.rb b/app/models/concerns/taskable.rb
index f147ce8ad6b..c27792486dd 100644
--- a/app/models/concerns/taskable.rb
+++ b/app/models/concerns/taskable.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'task_list'
-require 'task_list/filter'
+require "task_list"
+require "task_list/filter"
# Contains functionality for objects that can have task lists in their
# descriptions. Task list items can be added with Markdown like "* [x] Fix
@@ -9,8 +9,8 @@ require 'task_list/filter'
#
# Used by MergeRequest and Issue
module Taskable
- COMPLETED = 'completed'.freeze
- INCOMPLETE = 'incomplete'.freeze
+ COMPLETED = "completed"
+ INCOMPLETE = "incomplete"
COMPLETE_PATTERN = /(\[[xX]\])/.freeze
INCOMPLETE_PATTERN = /(\[[\s]\])/.freeze
ITEM_PATTERN = %r{
@@ -58,16 +58,16 @@ module Taskable
# Return a string that describes the current state of this Taskable's task
# list items, e.g. "12 of 20 tasks completed"
def task_status(short: false)
- return '' if description.blank?
+ return "" if description.blank?
prep, completed = if short
- ['/', '']
- else
- [' of ', ' completed']
- end
+ ["/", ""]
+ else
+ [" of ", " completed"]
+ end
sum = tasks.summary
- "#{sum.complete_count}#{prep}#{sum.item_count} #{'task'.pluralize(sum.item_count)}#{completed}"
+ "#{sum.complete_count}#{prep}#{sum.item_count} #{"task".pluralize(sum.item_count)}#{completed}"
end
# Return a short string that describes the current state of this Taskable's
diff --git a/app/models/concerns/time_trackable.rb b/app/models/concerns/time_trackable.rb
index f61a0bbc65b..364bb6b7745 100644
--- a/app/models/concerns/time_trackable.rb
+++ b/app/models/concerns/time_trackable.rb
@@ -17,7 +17,7 @@ module TimeTrackable
default_value_for :time_estimate, value: 0, allows_nil: false
- validates :time_estimate, numericality: { message: 'has an invalid format' }, allow_nil: false
+ validates :time_estimate, numericality: {message: "has an invalid format"}, allow_nil: false
validate :check_negative_time_spent
has_many :timelogs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -38,7 +38,7 @@ module TimeTrackable
add_or_subtract_spent_time
end
end
- alias_method :spend_time=, :spend_time
+ alias spend_time= spend_time
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def total_time_spent
@@ -77,7 +77,7 @@ module TimeTrackable
return if time_spent.nil? || time_spent == :reset
if time_spent < 0 && (time_spent.abs > original_total_time_spent)
- errors.add(:time_spent, 'Time to subtract exceeds the total time spent')
+ errors.add(:time_spent, "Time to subtract exceeds the total time spent")
end
end
diff --git a/app/models/concerns/token_authenticatable_strategies/base.rb b/app/models/concerns/token_authenticatable_strategies/base.rb
index 01fb194281a..690bb5975a7 100644
--- a/app/models/concerns/token_authenticatable_strategies/base.rb
+++ b/app/models/concerns/token_authenticatable_strategies/base.rb
@@ -41,7 +41,7 @@ module TokenAuthenticatableStrategies
def fallback?
unless options[:fallback].in?([true, false, nil])
- raise ArgumentError, 'fallback: needs to be a boolean value!'
+ raise ArgumentError, "fallback: needs to be a boolean value!"
end
options[:fallback] == true
@@ -49,7 +49,7 @@ module TokenAuthenticatableStrategies
def migrating?
unless options[:migrating].in?([true, false, nil])
- raise ArgumentError, 'migrating: needs to be a boolean value!'
+ raise ArgumentError, "migrating: needs to be a boolean value!"
end
options[:migrating] == true
@@ -57,7 +57,7 @@ module TokenAuthenticatableStrategies
def self.fabricate(model, field, options)
if options[:digest] && options[:encrypted]
- raise ArgumentError, 'Incompatible options set!'
+ raise ArgumentError, "Incompatible options set!"
end
if options[:digest]
diff --git a/app/models/concerns/token_authenticatable_strategies/encrypted.rb b/app/models/concerns/token_authenticatable_strategies/encrypted.rb
index 152491aa6e9..92a7da92c39 100644
--- a/app/models/concerns/token_authenticatable_strategies/encrypted.rb
+++ b/app/models/concerns/token_authenticatable_strategies/encrypted.rb
@@ -6,7 +6,7 @@ module TokenAuthenticatableStrategies
super
if migrating? && fallback?
- raise ArgumentError, '`fallback` and `migrating` options are not compatible!'
+ raise ArgumentError, "`fallback` and `migrating` options are not compatible!"
end
end
@@ -23,7 +23,7 @@ module TokenAuthenticatableStrategies
elsif migrating?
find_by_plaintext_token(token, unscoped)
else
- raise ArgumentError, 'Unknown encryption phase!'
+ raise ArgumentError, "Unknown encryption phase!"
end
end
@@ -42,7 +42,7 @@ module TokenAuthenticatableStrategies
return super if instance.has_attribute?(encrypted_field)
if fully_encrypted?
- raise ArgumentError, 'Using encrypted strategy when encrypted field is missing!'
+ raise ArgumentError, "Using encrypted strategy when encrypted field is missing!"
else
insecure_strategy.ensure_token(instance)
end
diff --git a/app/models/concerns/triggerable_hooks.rb b/app/models/concerns/triggerable_hooks.rb
index c52baa0524c..c1bd157b4db 100644
--- a/app/models/concerns/triggerable_hooks.rb
+++ b/app/models/concerns/triggerable_hooks.rb
@@ -2,17 +2,17 @@
module TriggerableHooks
AVAILABLE_TRIGGERS = {
- repository_update_hooks: :repository_update_events,
- push_hooks: :push_events,
- tag_push_hooks: :tag_push_events,
- issue_hooks: :issues_events,
- confidential_note_hooks: :confidential_note_events,
+ repository_update_hooks: :repository_update_events,
+ push_hooks: :push_events,
+ tag_push_hooks: :tag_push_events,
+ issue_hooks: :issues_events,
+ confidential_note_hooks: :confidential_note_events,
confidential_issue_hooks: :confidential_issues_events,
- note_hooks: :note_events,
- merge_request_hooks: :merge_requests_events,
- job_hooks: :job_events,
- pipeline_hooks: :pipeline_events,
- wiki_page_hooks: :wiki_page_events
+ note_hooks: :note_events,
+ merge_request_hooks: :merge_requests_events,
+ job_hooks: :job_events,
+ pipeline_hooks: :pipeline_events,
+ wiki_page_hooks: :wiki_page_events,
}.freeze
extend ActiveSupport::Concern
diff --git a/app/models/concerns/valid_attribute.rb b/app/models/concerns/valid_attribute.rb
index 251db9ce30b..07e9a284d8b 100644
--- a/app/models/concerns/valid_attribute.rb
+++ b/app/models/concerns/valid_attribute.rb
@@ -7,6 +7,6 @@ module ValidAttribute
#
# +attribute+ The symbolised name of the attribute i.e :name
def valid_attribute?(attribute)
- self.errors.empty? || self.errors.messages[attribute].nil?
+ errors.empty? || errors.messages[attribute].nil?
end
end
diff --git a/app/models/concerns/with_uploads.rb b/app/models/concerns/with_uploads.rb
index 6c6febd186c..87ab13b80bd 100644
--- a/app/models/concerns/with_uploads.rb
+++ b/app/models/concerns/with_uploads.rb
@@ -23,12 +23,12 @@ module WithUploads
# Currently there is no simple way how to select only not-mounted
# uploads, it should be all FileUploaders so we select them by
# `uploader` class
- FILE_UPLOADERS = %w(PersonalFileUploader NamespaceFileUploader FileUploader).freeze
+ FILE_UPLOADERS = %w[PersonalFileUploader NamespaceFileUploader FileUploader].freeze
included do
has_many :uploads, as: :model
has_many :file_uploads, -> { where(uploader: FILE_UPLOADERS) },
- class_name: 'Upload', as: :model,
+ class_name: "Upload", as: :model,
dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
use_fast_destroy :file_uploads
diff --git a/app/models/container_repository.rb b/app/models/container_repository.rb
index cf057d774cf..56a971d6d78 100644
--- a/app/models/container_repository.rb
+++ b/app/models/container_repository.rb
@@ -5,8 +5,8 @@ class ContainerRepository < ActiveRecord::Base
belongs_to :project
- validates :name, length: { minimum: 0, allow_nil: false }
- validates :name, uniqueness: { scope: :project_id }
+ validates :name, length: {minimum: 0, allow_nil: false}
+ validates :name, uniqueness: {scope: :project_id}
delegate :client, to: :registry
@@ -27,7 +27,7 @@ class ContainerRepository < ActiveRecord::Base
def path
@path ||= [project.full_path, name]
- .select(&:present?).join('/').downcase
+ .select(&:present?).join("/").downcase
end
def location
@@ -43,10 +43,10 @@ class ContainerRepository < ActiveRecord::Base
end
def tags
- return [] unless manifest && manifest['tags']
+ return [] unless manifest && manifest["tags"]
strong_memoize(:tags) do
- manifest['tags'].sort.map do |tag|
+ manifest["tags"].sort.map do |tag|
ContainerRegistry::Tag.new(self, tag)
end
end
@@ -70,13 +70,13 @@ class ContainerRepository < ActiveRecord::Base
digests = tags.map { |tag| tag.digest }.to_set
digests.all? do |digest|
- client.delete_repository_tag(self.path, digest)
+ client.delete_repository_tag(path, digest)
end
end
def self.build_from_path(path)
- self.new(project: path.repository_project,
- name: path.repository_name)
+ new(project: path.repository_project,
+ name: path.repository_name)
end
def self.create_from_path!(path)
@@ -84,6 +84,6 @@ class ContainerRepository < ActiveRecord::Base
end
def self.build_root_repository(project)
- self.new(project: project, name: '')
+ new(project: project, name: "")
end
end
diff --git a/app/models/conversational_development_index/idea_to_production_step.rb b/app/models/conversational_development_index/idea_to_production_step.rb
index e78a734693c..536c3fb1f33 100644
--- a/app/models/conversational_development_index/idea_to_production_step.rb
+++ b/app/models/conversational_development_index/idea_to_production_step.rb
@@ -11,9 +11,9 @@ module ConversationalDevelopmentIndex
end
def percentage_score
- sum = features.sum do |feature|
+ sum = features.sum { |feature|
metric.percentage_score(feature)
- end
+ }
sum / features.size.to_f
end
diff --git a/app/models/conversational_development_index/metric.rb b/app/models/conversational_development_index/metric.rb
index c54537572d6..cad73ad1659 100644
--- a/app/models/conversational_development_index/metric.rb
+++ b/app/models/conversational_development_index/metric.rb
@@ -4,7 +4,7 @@ module ConversationalDevelopmentIndex
class Metric < ActiveRecord::Base
include Presentable
- self.table_name = 'conversational_development_index_metrics'
+ self.table_name = "conversational_development_index_metrics"
def instance_score(feature)
self["instance_#{feature}"]
diff --git a/app/models/cycle_analytics.rb b/app/models/cycle_analytics.rb
index d0f5b6970b1..c678d1a1fcd 100644
--- a/app/models/cycle_analytics.rb
+++ b/app/models/cycle_analytics.rb
@@ -16,8 +16,8 @@ class CycleAnalytics
def summary
@summary ||= ::Gitlab::CycleAnalytics::StageSummary.new(@project,
- from: @options[:from],
- current_user: @options[:current_user]).data
+ from: @options[:from],
+ current_user: @options[:current_user]).data
end
def stats
diff --git a/app/models/dashboard_group_milestone.rb b/app/models/dashboard_group_milestone.rb
index 74aa04ab7d0..70aa21614e0 100644
--- a/app/models/dashboard_group_milestone.rb
+++ b/app/models/dashboard_group_milestone.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# Dashboard Group Milestones are milestones that allow us to pull more info out for the UI that the Milestone object doesn't allow for
class DashboardGroupMilestone < GlobalMilestone
extend ::Gitlab::Utils::Override
@@ -13,9 +14,9 @@ class DashboardGroupMilestone < GlobalMilestone
def self.build_collection(groups, params)
milestones = Milestone.of_groups(groups.select(:id))
- .reorder_by_due_date_asc
- .order_by_name_asc
- .active
+ .reorder_by_due_date_asc
+ .order_by_name_asc
+ .active
milestones = milestones.search_title(params[:search_title]) if params[:search_title].present?
milestones.map { |m| new(m) }
end
diff --git a/app/models/deploy_key.rb b/app/models/deploy_key.rb
index db501b4b506..aab4535db1e 100644
--- a/app/models/deploy_key.rb
+++ b/app/models/deploy_key.rb
@@ -6,7 +6,7 @@ class DeployKey < Key
has_many :deploy_keys_projects, inverse_of: :deploy_key, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :projects, through: :deploy_keys_projects
- scope :in_projects, ->(projects) { joins(:deploy_keys_projects).where('deploy_keys_projects.project_id in (?)', projects) }
+ scope :in_projects, ->(projects) { joins(:deploy_keys_projects).where("deploy_keys_projects.project_id in (?)", projects) }
scope :are_public, -> { where(public: true) }
ignore_column :can_push
@@ -18,15 +18,15 @@ class DeployKey < Key
end
def orphaned?
- self.deploy_keys_projects.empty?
+ deploy_keys_projects.empty?
end
def almost_orphaned?
- self.deploy_keys_projects.length == 1
+ deploy_keys_projects.length == 1
end
def destroyed_when_orphaned?
- self.private?
+ private?
end
def user
diff --git a/app/models/deploy_keys_project.rb b/app/models/deploy_keys_project.rb
index 71fd02fac86..06ae342c381 100644
--- a/app/models/deploy_keys_project.rb
+++ b/app/models/deploy_keys_project.rb
@@ -4,14 +4,14 @@ class DeployKeysProject < ActiveRecord::Base
belongs_to :project
belongs_to :deploy_key, inverse_of: :deploy_keys_projects
- scope :without_project_deleted, -> { joins(:project).where(projects: { pending_delete: false }) }
+ scope :without_project_deleted, -> { joins(:project).where(projects: {pending_delete: false}) }
scope :in_project, ->(project) { where(project: project) }
scope :with_write_access, -> { where(can_push: true) }
accepts_nested_attributes_for :deploy_key
validates :deploy_key, presence: true
- validates :deploy_key_id, uniqueness: { scope: [:project_id], message: "already exists in project" }
+ validates :deploy_key_id, uniqueness: {scope: [:project_id], message: "already exists in project"}
validates :project_id, presence: true
after_destroy :destroy_orphaned_deploy_key
@@ -19,8 +19,8 @@ class DeployKeysProject < ActiveRecord::Base
private
def destroy_orphaned_deploy_key
- return unless self.deploy_key.destroyed_when_orphaned? && self.deploy_key.orphaned?
+ return unless deploy_key.destroyed_when_orphaned? && deploy_key.orphaned?
- self.deploy_key.destroy
+ deploy_key.destroy
end
end
diff --git a/app/models/deploy_token.rb b/app/models/deploy_token.rb
index e3524305346..3b0a4f5c203 100644
--- a/app/models/deploy_token.rb
+++ b/app/models/deploy_token.rb
@@ -7,8 +7,8 @@ class DeployToken < ActiveRecord::Base
include Gitlab::Utils::StrongMemoize
add_authentication_token_field :token
- AVAILABLE_SCOPES = %i(read_repository read_registry).freeze
- GITLAB_DEPLOY_TOKEN_NAME = 'gitlab-deploy-token'.freeze
+ AVAILABLE_SCOPES = %i[read_repository read_registry].freeze
+ GITLAB_DEPLOY_TOKEN_NAME = "gitlab-deploy-token"
default_value_for(:expires_at) { Forever.date }
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 811e623b7f7..41f3bb84da1 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -19,7 +19,7 @@ class Deployment < ActiveRecord::Base
delegate :name, to: :environment, prefix: true
- scope :for_environment, -> (environment) { where(environment_id: environment) }
+ scope :for_environment, ->(environment) { where(environment_id: environment) }
state_machine :status, initial: :created do
event :run do
@@ -54,15 +54,15 @@ class Deployment < ActiveRecord::Base
running: 1,
success: 2,
failed: 3,
- canceled: 4
+ canceled: 4,
}
def self.last_for_environment(environment)
- ids = self
- .for_environment(environment)
- .select('MAX(id) AS id')
- .group(:environment_id)
- .map(&:id)
+ ids =
+ for_environment(environment)
+ .select("MAX(id) AS id")
+ .group(:environment_id)
+ .map(&:id)
find(ids)
end
@@ -108,9 +108,9 @@ class Deployment < ActiveRecord::Base
return unless environment.update_merge_request_metrics? && success?
merge_requests = project.merge_requests
- .joins(:metrics)
- .where(target_branch: self.ref, merge_request_metrics: { first_deployed_to_production_at: nil })
- .where("merge_request_metrics.merged_at <= ?", finished_at)
+ .joins(:metrics)
+ .where(target_branch: ref, merge_request_metrics: {first_deployed_to_production_at: nil})
+ .where("merge_request_metrics.merged_at <= ?", finished_at)
if previous_deployment
merge_requests = merge_requests.where("merge_request_metrics.merged_at >= ?", previous_deployment.finished_at)
@@ -133,9 +133,9 @@ class Deployment < ActiveRecord::Base
def previous_deployment
@previous_deployment ||=
project.deployments.joins(:environment)
- .where(environments: { name: self.environment.name }, ref: self.ref)
- .where.not(id: self.id)
- .take
+ .where(environments: {name: environment.name}, ref: ref)
+ .where.not(id: id)
+ .take
end
def stop_action
@@ -184,10 +184,10 @@ class Deployment < ActiveRecord::Base
end
def ref_path
- File.join(environment.ref_path, 'deployments', iid.to_s)
+ File.join(environment.ref_path, "deployments", iid.to_s)
end
def legacy_finished_at
- self.created_at if success? && !read_attribute(:finished_at)
+ created_at if success? && !read_attribute(:finished_at)
end
end
diff --git a/app/models/diff_discussion.rb b/app/models/diff_discussion.rb
index 93e3ebf7896..d6803f10902 100644
--- a/app/models/diff_discussion.rb
+++ b/app/models/diff_discussion.rb
@@ -10,13 +10,12 @@ class DiffDiscussion < Discussion
DiffNote
end
- delegate :position,
- :original_position,
- :change_position,
- :on_text?,
- :on_image?,
-
- to: :first_note
+ delegate :position,
+ :original_position,
+ :change_position,
+ :on_text?,
+ :on_image?,
+ to: :first_note
def legacy_diff_discussion?
false
diff --git a/app/models/diff_note.rb b/app/models/diff_note.rb
index 805092e527a..ef6e6cfe120 100644
--- a/app/models/diff_note.rb
+++ b/app/models/diff_note.rb
@@ -9,13 +9,13 @@ class DiffNote < Note
include Gitlab::Utils::StrongMemoize
def self.noteable_types
- %w(MergeRequest Commit)
+ %w[MergeRequest Commit]
end
validates :original_position, presence: true
validates :position, presence: true
validates :line_code, presence: true, line_code: true, if: :on_text?
- validates :noteable_type, inclusion: { in: noteable_types }
+ validates :noteable_type, inclusion: {in: noteable_types}
validate :positions_complete
validate :verify_supported
validate :diff_refs_match_commit, if: :for_commit?
@@ -32,7 +32,7 @@ class DiffNote < Note
return unless should_create_diff_file?
diff_file = fetch_diff_file
- diff_line = diff_file.line_for_position(self.original_position)
+ diff_line = diff_file.line_for_position(original_position)
creation_params = diff_file.diff.to_hash
.except(:too_large)
@@ -58,27 +58,27 @@ class DiffNote < Note
end
def diff_line
- @diff_line ||= diff_file&.line_for_position(self.original_position)
+ @diff_line ||= diff_file&.line_for_position(original_position)
end
def original_line_code
return unless on_text?
- self.diff_file.line_code(self.diff_line)
+ diff_file.line_code(diff_line)
end
def created_at_diff?(diff_refs)
return false unless supported?
return true if for_commit?
- self.original_position.diff_refs == diff_refs
+ original_position.diff_refs == diff_refs
end
def supports_suggestion?
return false unless noteable.supports_suggestion? && on_text?
# We don't want to trigger side-effects of `diff_file` call.
return false unless file = fetch_diff_file
- return false unless line = file.line_for_position(self.original_position)
+ return false unless line = file.line_for_position(original_position)
line&.suggestible?
end
@@ -111,8 +111,8 @@ class DiffNote < Note
if note_diff_file
diff = Gitlab::Git::Diff.new(note_diff_file.to_hash)
Gitlab::Diff::File.new(diff,
- repository: project.repository,
- diff_refs: original_position.diff_refs)
+ repository: project.repository,
+ diff_refs: original_position.diff_refs)
elsif created_at_diff?(noteable.diff_refs)
# We're able to use the already persisted diffs (Postgres) if we're
# presenting a "current version" of the MR discussion diff.
@@ -122,7 +122,7 @@ class DiffNote < Note
# `Diff::FileCollection::MergeRequestDiff`.
noteable.diffs(original_position.diff_options).diff_files.first
else
- original_position.diff_file(self.project.repository)
+ original_position.diff_file(project.repository)
end
# Since persisted diff files already have its content "unfolded"
@@ -133,11 +133,11 @@ class DiffNote < Note
end
def supported?
- for_commit? || self.noteable.has_complete_diff_refs?
+ for_commit? || noteable.has_complete_diff_refs?
end
def set_line_code
- self.line_code = self.position.line_code(self.project.repository)
+ self.line_code = position.line_code(project.repository)
end
def verify_supported
@@ -147,28 +147,28 @@ class DiffNote < Note
end
def positions_complete
- return if self.original_position.complete? && self.position.complete?
+ return if original_position.complete? && position.complete?
errors.add(:position, "is invalid")
end
def diff_refs_match_commit
- return if self.original_position.diff_refs == self.commit.diff_refs
+ return if original_position.diff_refs == commit.diff_refs
- errors.add(:commit_id, 'does not match the diff refs')
+ errors.add(:commit_id, "does not match the diff refs")
end
def keep_around_commits
shas = [
- self.original_position.base_sha,
- self.original_position.start_sha,
- self.original_position.head_sha
+ original_position.base_sha,
+ original_position.start_sha,
+ original_position.head_sha,
]
- if self.position != self.original_position
- shas << self.position.base_sha
- shas << self.position.start_sha
- shas << self.position.head_sha
+ if position != original_position
+ shas << position.base_sha
+ shas << position.start_sha
+ shas << position.head_sha
end
project.repository.keep_around(*shas)
diff --git a/app/models/diff_viewer/added.rb b/app/models/diff_viewer/added.rb
index 70d13e3478c..1a24cad299e 100644
--- a/app/models/diff_viewer/added.rb
+++ b/app/models/diff_viewer/added.rb
@@ -5,6 +5,6 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'added'
+ self.partial_name = "added"
end
end
diff --git a/app/models/diff_viewer/base.rb b/app/models/diff_viewer/base.rb
index 527ee33b83b..40e27aa0c22 100644
--- a/app/models/diff_viewer/base.rb
+++ b/app/models/diff_viewer/base.rb
@@ -2,7 +2,7 @@
module DiffViewer
class Base
- PARTIAL_PATH_PREFIX = 'projects/diffs/viewers'.freeze
+ PARTIAL_PATH_PREFIX = "projects/diffs/viewers"
class_attribute :partial_name, :type, :extensions, :file_types, :binary, :switcher_icon, :switcher_title
@@ -89,7 +89,7 @@ module DiffViewer
{
viewer: switcher_title,
reason: render_error_reason,
- options: render_error_options.to_sentence(two_words_connector: _(' or '), last_word_connector: _(', or '))
+ options: render_error_options.to_sentence(two_words_connector: _(" or "), last_word_connector: _(", or ")),
}
end
@@ -103,8 +103,8 @@ module DiffViewer
options = []
blob_url = Gitlab::Routing.url_helpers.project_blob_path(diff_file.repository.project,
- File.join(diff_file.content_sha, diff_file.file_path))
- options << ActionController::Base.helpers.link_to(_('view the blob'), blob_url)
+ File.join(diff_file.content_sha, diff_file.file_path))
+ options << ActionController::Base.helpers.link_to(_("view the blob"), blob_url)
options
end
diff --git a/app/models/diff_viewer/deleted.rb b/app/models/diff_viewer/deleted.rb
index 78671084eeb..bdd36f98625 100644
--- a/app/models/diff_viewer/deleted.rb
+++ b/app/models/diff_viewer/deleted.rb
@@ -5,6 +5,6 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'deleted'
+ self.partial_name = "deleted"
end
end
diff --git a/app/models/diff_viewer/image.rb b/app/models/diff_viewer/image.rb
index 350bef1d42a..9ee75a7bc0c 100644
--- a/app/models/diff_viewer/image.rb
+++ b/app/models/diff_viewer/image.rb
@@ -5,10 +5,10 @@ module DiffViewer
include Rich
include ClientSide
- self.partial_name = 'image'
+ self.partial_name = "image"
self.extensions = UploaderHelper::IMAGE_EXT
self.binary = true
- self.switcher_icon = 'picture-o'
- self.switcher_title = _('image diff')
+ self.switcher_icon = "picture-o"
+ self.switcher_title = _("image diff")
end
end
diff --git a/app/models/diff_viewer/mode_changed.rb b/app/models/diff_viewer/mode_changed.rb
index bd07d1e21b9..aa9691476b6 100644
--- a/app/models/diff_viewer/mode_changed.rb
+++ b/app/models/diff_viewer/mode_changed.rb
@@ -5,6 +5,6 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'mode_changed'
+ self.partial_name = "mode_changed"
end
end
diff --git a/app/models/diff_viewer/no_preview.rb b/app/models/diff_viewer/no_preview.rb
index b0dd5fd151d..62d02cb76dc 100644
--- a/app/models/diff_viewer/no_preview.rb
+++ b/app/models/diff_viewer/no_preview.rb
@@ -5,7 +5,7 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'no_preview'
+ self.partial_name = "no_preview"
self.binary = true
end
end
diff --git a/app/models/diff_viewer/not_diffable.rb b/app/models/diff_viewer/not_diffable.rb
index dc86599e722..9a2fc459a88 100644
--- a/app/models/diff_viewer/not_diffable.rb
+++ b/app/models/diff_viewer/not_diffable.rb
@@ -5,7 +5,7 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'not_diffable'
+ self.partial_name = "not_diffable"
self.binary = true
end
end
diff --git a/app/models/diff_viewer/renamed.rb b/app/models/diff_viewer/renamed.rb
index 70ab9d4ca2c..0b39afedfc8 100644
--- a/app/models/diff_viewer/renamed.rb
+++ b/app/models/diff_viewer/renamed.rb
@@ -5,6 +5,6 @@ module DiffViewer
include Simple
include Static
- self.partial_name = 'renamed'
+ self.partial_name = "renamed"
end
end
diff --git a/app/models/diff_viewer/rich.rb b/app/models/diff_viewer/rich.rb
index 5caefa2031c..49c4aff8368 100644
--- a/app/models/diff_viewer/rich.rb
+++ b/app/models/diff_viewer/rich.rb
@@ -6,8 +6,8 @@ module DiffViewer
included do
self.type = :rich
- self.switcher_icon = 'file-text-o'
- self.switcher_title = _('rendered diff')
+ self.switcher_icon = "file-text-o"
+ self.switcher_title = _("rendered diff")
end
end
end
diff --git a/app/models/diff_viewer/server_side.rb b/app/models/diff_viewer/server_side.rb
index 0877c9dddec..4294d4c6a67 100644
--- a/app/models/diff_viewer/server_side.rb
+++ b/app/models/diff_viewer/server_side.rb
@@ -31,9 +31,9 @@ module DiffViewer
return super unless render_error == :server_side_but_stored_externally
if diff_file.external_storage == :lfs
- _('it is stored in LFS')
+ _("it is stored in LFS")
else
- _('it is stored externally')
+ _("it is stored externally")
end
end
end
diff --git a/app/models/diff_viewer/simple.rb b/app/models/diff_viewer/simple.rb
index 929d8ad5a7e..949e9ef32c9 100644
--- a/app/models/diff_viewer/simple.rb
+++ b/app/models/diff_viewer/simple.rb
@@ -6,8 +6,8 @@ module DiffViewer
included do
self.type = :simple
- self.switcher_icon = 'code'
- self.switcher_title = _('source diff')
+ self.switcher_icon = "code"
+ self.switcher_title = _("source diff")
end
end
end
diff --git a/app/models/diff_viewer/text.rb b/app/models/diff_viewer/text.rb
index d3d5055c402..8197204b65a 100644
--- a/app/models/diff_viewer/text.rb
+++ b/app/models/diff_viewer/text.rb
@@ -5,7 +5,7 @@ module DiffViewer
include Simple
include ServerSide
- self.partial_name = 'text'
+ self.partial_name = "text"
self.binary = false
# Since the text diff viewer doesn't render the old and new blobs in full,
diff --git a/app/models/discussion.rb b/app/models/discussion.rb
index 32529ebf71d..f5f96b3d52e 100644
--- a/app/models/discussion.rb
+++ b/app/models/discussion.rb
@@ -8,16 +8,14 @@ class Discussion
attr_reader :notes, :context_noteable
- delegate :created_at,
- :project,
- :author,
-
- :noteable,
- :commit_id,
- :for_commit?,
- :for_merge_request?,
-
- to: :first_note
+ delegate :created_at,
+ :project,
+ :author,
+ :noteable,
+ :commit_id,
+ :for_commit?,
+ :for_merge_request?,
+ to: :first_note
def project_id
project&.id
@@ -79,9 +77,9 @@ class Discussion
def ==(other)
other.class == self.class &&
- other.context_noteable == self.context_noteable &&
- other.id == self.id &&
- other.notes == self.notes
+ other.context_noteable == context_noteable &&
+ other.id == id &&
+ other.notes == notes
end
def last_updated_at
@@ -106,7 +104,7 @@ class Discussion
first_note.discussion_id
end
- alias_method :to_param, :id
+ alias to_param id
def diff_discussion?
false
diff --git a/app/models/discussion_note.rb b/app/models/discussion_note.rb
index 142cbdcdfa6..d4b38d58941 100644
--- a/app/models/discussion_note.rb
+++ b/app/models/discussion_note.rb
@@ -6,10 +6,10 @@
class DiscussionNote < Note
# Names of all implementers of `Noteable` that support discussions.
def self.noteable_types
- %w(MergeRequest Issue Commit Snippet)
+ %w[MergeRequest Issue Commit Snippet]
end
- validates :noteable_type, inclusion: { in: noteable_types }
+ validates :noteable_type, inclusion: {in: noteable_types}
def discussion_class(*)
Discussion
diff --git a/app/models/email.rb b/app/models/email.rb
index 3ce6e792fa8..bfbdccef9a3 100644
--- a/app/models/email.rb
+++ b/app/models/email.rb
@@ -12,7 +12,7 @@ class Email < ActiveRecord::Base
scope :confirmed, -> { where.not(confirmed_at: nil) }
- after_commit :update_invalid_gpg_signatures, if: -> { previous_changes.key?('confirmed_at') }
+ after_commit :update_invalid_gpg_signatures, if: -> { previous_changes.key?("confirmed_at") }
devise :confirmable
self.reconfirmable = false # currently email can't be changed, no need to reconfirm
@@ -24,7 +24,7 @@ class Email < ActiveRecord::Base
end
def unique_email
- self.errors.add(:email, 'has already been taken') if User.exists?(email: self.email)
+ errors.add(:email, "has already been taken") if User.exists?(email: email)
end
def accept_pending_invitations!
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 87bdb52b58b..8671285be1a 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -3,15 +3,15 @@
class Environment < ActiveRecord::Base
include Gitlab::Utils::StrongMemoize
# Used to generate random suffixes for the slug
- LETTERS = 'a'..'z'
- NUMBERS = '0'..'9'
+ LETTERS = "a".."z"
+ NUMBERS = "0".."9"
SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a
belongs_to :project, required: true
has_many :deployments, -> { success }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment'
+ has_one :last_deployment, -> { success.order("deployments.id DESC") }, class_name: "Deployment"
before_validation :nullify_external_url
before_validation :generate_slug, if: ->(env) { env.slug.blank? }
@@ -19,23 +19,23 @@ class Environment < ActiveRecord::Base
before_save :set_environment_type
validates :name,
- presence: true,
- uniqueness: { scope: :project_id },
- length: { maximum: 255 },
- format: { with: Gitlab::Regex.environment_name_regex,
- message: Gitlab::Regex.environment_name_regex_message }
+ presence: true,
+ uniqueness: {scope: :project_id},
+ length: {maximum: 255},
+ format: {with: Gitlab::Regex.environment_name_regex,
+ message: Gitlab::Regex.environment_name_regex_message,}
validates :slug,
- presence: true,
- uniqueness: { scope: :project_id },
- length: { maximum: 24 },
- format: { with: Gitlab::Regex.environment_slug_regex,
- message: Gitlab::Regex.environment_slug_regex_message }
+ presence: true,
+ uniqueness: {scope: :project_id},
+ length: {maximum: 24},
+ format: {with: Gitlab::Regex.environment_slug_regex,
+ message: Gitlab::Regex.environment_slug_regex_message,}
validates :external_url,
- length: { maximum: 255 },
- allow_nil: true,
- url: true
+ length: {maximum: 255},
+ allow_nil: true,
+ url: true
delegate :stop_action, :manual_actions, to: :last_deployment, allow_nil: true
@@ -44,22 +44,22 @@ class Environment < ActiveRecord::Base
scope :order_by_last_deployed_at, -> do
max_deployment_id_sql =
Deployment.select(Deployment.arel_table[:id].maximum)
- .where(Deployment.arel_table[:environment_id].eq(arel_table[:id]))
- .to_sql
- order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", 'ASC'))
+ .where(Deployment.arel_table[:environment_id].eq(arel_table[:id]))
+ .to_sql
+ order(Gitlab::Database.nulls_first_order("(#{max_deployment_id_sql})", "ASC"))
end
scope :in_review_folder, -> { where(environment_type: "review") }
- scope :for_name, -> (name) { where(name: name) }
+ scope :for_name, ->(name) { where(name: name) }
##
# Search environments which have names like the given query.
# Do not set a large limit unless you've confirmed that it works on gitlab.com scale.
- scope :for_name_like, -> (query, limit: 5) do
- where('name LIKE ?', "#{sanitize_sql_like(query)}%").limit(limit)
+ scope :for_name_like, ->(query, limit: 5) do
+ where("name LIKE ?", "#{sanitize_sql_like(query)}%").limit(limit)
end
- scope :for_project, -> (project) { where(project_id: project) }
- scope :with_deployment, -> (sha) { where('EXISTS (?)', Deployment.select(1).where('deployments.environment_id = environments.id').where(sha: sha)) }
+ scope :for_project, ->(project) { where(project_id: project) }
+ scope :with_deployment, ->(sha) { where("EXISTS (?)", Deployment.select(1).where("deployments.environment_id = environments.id").where(sha: sha)) }
state_machine :state, initial: :available do
event :start do
@@ -84,8 +84,8 @@ class Environment < ActiveRecord::Base
def predefined_variables
Gitlab::Ci::Variables::Collection.new
- .append(key: 'CI_ENVIRONMENT_NAME', value: name)
- .append(key: 'CI_ENVIRONMENT_SLUG', value: slug)
+ .append(key: "CI_ENVIRONMENT_NAME", value: name)
+ .append(key: "CI_ENVIRONMENT_SLUG", value: slug)
end
def recently_updated_on_branch?(ref)
@@ -93,11 +93,11 @@ class Environment < ActiveRecord::Base
end
def nullify_external_url
- self.external_url = nil if self.external_url.blank?
+ self.external_url = nil if external_url.blank?
end
def set_environment_type
- names = name.split('/')
+ names = name.split("/")
self.environment_type = names.many? ? names.first : nil
end
@@ -121,7 +121,7 @@ class Environment < ActiveRecord::Base
return nil unless ref
- deployment_iid = ref.split('/').last
+ deployment_iid = ref.split("/").last
deployments.find_by(iid: deployment_iid)
end
@@ -132,7 +132,7 @@ class Environment < ActiveRecord::Base
def formatted_external_url
return nil unless external_url
- external_url.gsub(%r{\A.*?://}, '')
+ external_url.gsub(%r{\A.*?://}, "")
end
def stop_action_available?
@@ -193,25 +193,25 @@ class Environment < ActiveRecord::Base
# * cannot end with `-`
def generate_slug
# Lowercase letters and numbers only
- slugified = +name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
+ slugified = +name.to_s.downcase.gsub(/[^a-z0-9]/, "-")
# Must start with a letter
- slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0])
+ slugified = "env-" + slugified unless LETTERS.cover?(slugified[0])
# Repeated dashes are invalid (OpenShift limitation)
- slugified.gsub!(/\-+/, '-')
+ slugified.gsub!(/\-+/, "-")
# Maximum length: 24 characters (OpenShift limitation)
slugified = slugified[0..23]
# Cannot end with a dash (Kubernetes label limitation)
- slugified.chop! if slugified.end_with?('-')
+ slugified.chop! if slugified.end_with?("-")
# Add a random suffix, shortening the current string if necessary, if it
# has been slugified. This ensures uniqueness.
if slugified != name
slugified = slugified[0..16]
- slugified << '-' unless slugified.end_with?('-')
+ slugified << "-" unless slugified.end_with?("-")
slugified << random_suffix
end
@@ -219,12 +219,12 @@ class Environment < ActiveRecord::Base
end
def external_url_for(path, commit_sha)
- return unless self.external_url
+ return unless external_url
public_path = project.public_path_for_source_path(path, commit_sha)
return unless public_path
- [external_url, public_path].join('/')
+ [external_url, public_path].join("/")
end
def expire_etag_cache
@@ -236,11 +236,12 @@ class Environment < ActiveRecord::Base
def etag_cache_key
Gitlab::Routing.url_helpers.project_environments_path(
project,
- format: :json)
+ format: :json
+ )
end
def folder_name
- self.environment_type || self.name
+ environment_type || name
end
def name_without_type
@@ -249,7 +250,7 @@ class Environment < ActiveRecord::Base
def deployment_platform
strong_memoize(:deployment_platform) do
- project.deployment_platform(environment: self.name)
+ project.deployment_platform(environment: name)
end
end
diff --git a/app/models/environment_status.rb b/app/models/environment_status.rb
index 2fb6cadc8cd..a508bcc3230 100644
--- a/app/models/environment_status.rb
+++ b/app/models/environment_status.rb
@@ -57,18 +57,18 @@ class EnvironmentStatus
{
path: public_path,
- external_url: environment.external_url_for(file.new_path, sha)
+ external_url: environment.external_url_for(file.new_path, sha),
}
end
def self.build_environments_status(mr, user, pipeline)
return [] unless pipeline
- pipeline.environments.available.map do |environment|
+ pipeline.environments.available.map { |environment|
next unless Ability.allowed?(user, :read_environment, environment)
EnvironmentStatus.new(environment, mr, pipeline.sha)
- end.compact
+ }.compact
end
private_class_method :build_environments_status
end
diff --git a/app/models/epic.rb b/app/models/epic.rb
index ccd10593434..e711f610586 100644
--- a/app/models/epic.rb
+++ b/app/models/epic.rb
@@ -8,10 +8,10 @@ class Epic < ActiveRecord::Base
end
def self.reference_prefix
- '&'
+ "&"
end
def self.reference_prefix_escaped
- '&amp;'
+ "&amp;"
end
end
diff --git a/app/models/error_tracking/project_error_tracking_setting.rb b/app/models/error_tracking/project_error_tracking_setting.rb
index 57283a78ea9..867fff2de6d 100644
--- a/app/models/error_tracking/project_error_tracking_setting.rb
+++ b/app/models/error_tracking/project_error_tracking_setting.rb
@@ -8,7 +8,7 @@ module ErrorTracking
belongs_to :project
- validates :api_url, length: { maximum: 255 }, public_url: true, url: { enforce_sanitization: true, ascii_only: true }, allow_nil: true
+ validates :api_url, length: {maximum: 255}, public_url: true, url: {enforce_sanitization: true, ascii_only: true}, allow_nil: true
validates :api_url, presence: true, if: :enabled
@@ -19,7 +19,7 @@ module ErrorTracking
attr_encrypted :token,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-gcm'
+ algorithm: "aes-256-gcm"
after_save :clear_reactive_cache!
@@ -41,7 +41,7 @@ module ErrorTracking
def self.build_api_url_from(api_host:, project_slug:, organization_slug:)
uri = Addressable::URI.parse("#{api_host}/api/0/projects/#{organization_slug}/#{project_slug}/")
- uri.path = uri.path.squeeze('/')
+ uri.path = uri.path.squeeze("/")
uri.to_s
rescue Addressable::URI::InvalidURIError
@@ -57,36 +57,36 @@ module ErrorTracking
end
def list_sentry_issues(opts = {})
- with_reactive_cache('list_issues', opts.stringify_keys) do |result|
+ with_reactive_cache("list_issues", opts.stringify_keys) do |result|
result
end
end
def list_sentry_projects
- { projects: sentry_client.list_projects }
+ {projects: sentry_client.list_projects}
end
def calculate_reactive_cache(request, opts)
case request
- when 'list_issues'
- { issues: sentry_client.list_issues(**opts.symbolize_keys) }
+ when "list_issues"
+ {issues: sentry_client.list_issues(**opts.symbolize_keys)}
end
rescue Sentry::Client::Error => e
- { error: e.message }
+ {error: e.message}
end
# http://HOST/api/0/projects/ORG/PROJECT
# ->
# http://HOST/ORG/PROJECT
def self.extract_sentry_external_url(url)
- url.sub('api/0/projects/', '')
+ url.sub("api/0/projects/", "")
end
def api_host
return if api_url.blank?
# This returns http://example.com/
- Addressable::URI.join(api_url, '/').to_s
+ Addressable::URI.join(api_url, "/").to_s
end
private
@@ -124,8 +124,8 @@ module ErrorTracking
return if api_url.blank?
begin
- unless Addressable::URI.parse(api_url).path.starts_with?('/api/0/projects')
- errors.add(:api_url, 'path needs to start with /api/0/projects')
+ unless Addressable::URI.parse(api_url).path.starts_with?("/api/0/projects")
+ errors.add(:api_url, "path needs to start with /api/0/projects")
end
rescue Addressable::URI::InvalidURIError
end
diff --git a/app/models/event.rb b/app/models/event.rb
index 6a35bca72c5..a0d86c9ebe7 100644
--- a/app/models/event.rb
+++ b/app/models/event.rb
@@ -19,27 +19,27 @@ class Event < ActiveRecord::Base
EXPIRED = 11 # User left project due to expiry
ACTIONS = HashWithIndifferentAccess.new(
- created: CREATED,
- updated: UPDATED,
- closed: CLOSED,
- reopened: REOPENED,
- pushed: PUSHED,
- commented: COMMENTED,
- merged: MERGED,
- joined: JOINED,
- left: LEFT,
- destroyed: DESTROYED,
- expired: EXPIRED
+ created: CREATED,
+ updated: UPDATED,
+ closed: CLOSED,
+ reopened: REOPENED,
+ pushed: PUSHED,
+ commented: COMMENTED,
+ merged: MERGED,
+ joined: JOINED,
+ left: LEFT,
+ destroyed: DESTROYED,
+ expired: EXPIRED
).freeze
TARGET_TYPES = HashWithIndifferentAccess.new(
- issue: Issue,
- milestone: Milestone,
- merge_request: MergeRequest,
- note: Note,
- project: Project,
- snippet: Snippet,
- user: User
+ issue: Issue,
+ milestone: Milestone,
+ merge_request: MergeRequest,
+ note: Note,
+ project: Project,
+ snippet: Snippet,
+ user: User
).freeze
RESET_PROJECT_ACTIVITY_INTERVAL = 1.hour
@@ -57,9 +57,9 @@ class Event < ActiveRecord::Base
# If the association for "target" defines an "author" association we want to
# eager-load this so Banzai & friends don't end up performing N+1 queries to
# get the authors of notes, issues, etc. (likewise for "noteable").
- incs = %i(author noteable).select do |a|
- reflections['events'].active_record.reflect_on_association(a)
- end
+ incs = %i[author noteable].select { |a|
+ reflections["events"].active_record.reflect_on_association(a)
+ }
incs.reduce(self) { |obj, a| obj.includes(a) }
}, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
@@ -75,13 +75,13 @@ class Event < ActiveRecord::Base
scope :recent, -> { reorder(id: :desc) }
scope :code_push, -> { where(action: PUSHED) }
- scope :in_projects, -> (projects) do
+ scope :in_projects, ->(projects) do
sub_query = projects
.except(:order)
.select(1)
- .where('projects.id = events.project_id')
+ .where("projects.id = events.project_id")
- where('EXISTS (?)', sub_query).recent
+ where("EXISTS (?)", sub_query).recent
end
scope :with_associations, -> do
@@ -99,11 +99,11 @@ class Event < ActiveRecord::Base
# should ensure the ID points to a valid user.
validates :author_id, presence: true
- self.inheritance_column = 'action'
+ self.inheritance_column = "action"
class << self
def model_name
- ActiveModel::Name.new(self, nil, 'event')
+ ActiveModel::Name.new(self, nil, "event")
end
def find_sti_class(action)
@@ -117,9 +117,9 @@ class Event < ActiveRecord::Base
# Update Gitlab::ContributionsCalendar#activity_dates if this changes
def contributions
where("action = ? OR (target_type IN (?) AND action IN (?)) OR (target_type = ? AND action = ?)",
- Event::PUSHED,
- %w(MergeRequest Issue), [Event::CREATED, Event::CLOSED, Event::MERGED],
- "Note", Event::COMMENTED)
+ Event::PUSHED,
+ %w[MergeRequest Issue], [Event::CREATED, Event::CLOSED, Event::MERGED],
+ "Note", Event::COMMENTED)
end
def limit_recent(limit = 20, offset = nil)
@@ -265,13 +265,13 @@ class Event < ActiveRecord::Base
elsif merged?
"accepted"
elsif joined?
- 'joined'
+ "joined"
elsif left?
- 'left'
+ "left"
elsif expired?
- 'removed due to membership expiration from'
+ "removed due to membership expiration from"
elsif destroyed?
- 'destroyed'
+ "destroyed"
elsif commented?
"commented on"
elsif created_project?
@@ -356,7 +356,7 @@ class Event < ActiveRecord::Base
# update the project. Only one query should actually perform the update,
# hence we add the extra WHERE clause for last_activity_at.
Project.unscoped.where(id: project_id)
- .where('last_activity_at <= ?', RESET_PROJECT_ACTIVITY_INTERVAL.ago)
+ .where("last_activity_at <= ?", RESET_PROJECT_ACTIVITY_INTERVAL.ago)
.update_all(last_activity_at: created_at)
end
diff --git a/app/models/event_collection.rb b/app/models/event_collection.rb
index a4c69b11781..8a3cfb12c3c 100644
--- a/app/models/event_collection.rb
+++ b/app/models/event_collection.rb
@@ -25,10 +25,10 @@ class EventCollection
return [] if current_page > MAX_PAGE
relation = if Gitlab::Database.join_lateral_supported?
- relation_with_join_lateral
- else
- relation_without_join_lateral
- end
+ relation_with_join_lateral
+ else
+ relation_without_join_lateral
+ end
relation.with_associations.to_a
end
@@ -54,7 +54,7 @@ class EventCollection
lateral = filtered_events
.limit(limit_for_join_lateral)
- .where('events.project_id = projects_for_lateral.id')
+ .where("events.project_id = projects_for_lateral.id")
.to_sql
# The outer query does not need to re-apply the filters since the JOIN
diff --git a/app/models/external_issue.rb b/app/models/external_issue.rb
index 68b2353556e..3f03b1b5afa 100644
--- a/app/models/external_issue.rb
+++ b/app/models/external_issue.rb
@@ -28,7 +28,7 @@ class ExternalIssue
def ==(other)
other.is_a?(self.class) && (to_s == other.to_s)
end
- alias_method :eql?, :==
+ alias eql? ==
def hash
[self.class, to_s].hash
diff --git a/app/models/fork_network.rb b/app/models/fork_network.rb
index 1b9bf93cbbc..4d8ca3e7291 100644
--- a/app/models/fork_network.rb
+++ b/app/models/fork_network.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class ForkNetwork < ActiveRecord::Base
- belongs_to :root_project, class_name: 'Project'
+ belongs_to :root_project, class_name: "Project"
has_many :fork_network_members
has_many :projects, through: :fork_network_members
diff --git a/app/models/fork_network_member.rb b/app/models/fork_network_member.rb
index 36c66f21b0b..32c6e3d08a2 100644
--- a/app/models/fork_network_member.rb
+++ b/app/models/fork_network_member.rb
@@ -3,7 +3,7 @@
class ForkNetworkMember < ActiveRecord::Base
belongs_to :fork_network
belongs_to :project
- belongs_to :forked_from_project, class_name: 'Project'
+ belongs_to :forked_from_project, class_name: "Project"
validates :fork_network, :project, presence: true
diff --git a/app/models/generic_commit_status.rb b/app/models/generic_commit_status.rb
index 3028bf21301..93c16bc7d47 100644
--- a/app/models/generic_commit_status.rb
+++ b/app/models/generic_commit_status.rb
@@ -4,15 +4,15 @@ class GenericCommitStatus < CommitStatus
before_validation :set_default_values
validates :target_url, url: true,
- length: { maximum: 255 },
+ length: {maximum: 255},
allow_nil: true
# GitHub compatible API
alias_attribute :context, :name
def set_default_values
- self.context ||= 'default'
- self.stage ||= 'external'
+ self.context ||= "default"
+ self.stage ||= "external"
self.stage_idx ||= 1000000
end
diff --git a/app/models/global_milestone.rb b/app/models/global_milestone.rb
index fd17745b035..794a8cd51ba 100644
--- a/app/models/global_milestone.rb
+++ b/app/models/global_milestone.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
+
# Global Milestones are milestones that can be shared across multiple projects
class GlobalMilestone
include Milestoneish
- STATE_COUNT_HASH = { opened: 0, closed: 0, all: 0 }.freeze
+ STATE_COUNT_HASH = {opened: 0, closed: 0, all: 0}.freeze
attr_reader :milestone
alias_attribute :name, :title
@@ -12,10 +13,10 @@ class GlobalMilestone
def to_hash
{
- name: title,
- title: title,
- group_name: group&.full_name,
- project_name: project&.full_name
+ name: title,
+ title: title,
+ group_name: group&.full_name,
+ project_name: project&.full_name,
}
end
@@ -25,8 +26,8 @@ class GlobalMilestone
def self.build_collection(projects, params)
items = Milestone.of_projects(projects)
- .reorder_by_due_date_asc
- .order_by_name_asc
+ .reorder_by_due_date_asc
+ .order_by_name_asc
items = items.search_title(params[:search_title]) if params[:search_title].present?
Milestone.filter_by_state(items, params[:state]).map { |m| new(m) }
@@ -55,9 +56,9 @@ class GlobalMilestone
counts_by_state = Milestone.of_groups(group).count_by_state
{
- opened: counts_by_state['active'] || 0,
- closed: counts_by_state['closed'] || 0,
- all: counts_by_state.values.sum
+ opened: counts_by_state["active"] || 0,
+ closed: counts_by_state["closed"] || 0,
+ all: counts_by_state.values.sum,
}
end
@@ -68,9 +69,9 @@ class GlobalMilestone
relation = Milestone.of_projects(projects.reorder(nil)).count_by_state
{
- opened: relation['active'] || 0,
- closed: relation['closed'] || 0,
- all: relation.values.sum
+ opened: relation["active"] || 0,
+ closed: relation["closed"] || 0,
+ all: relation.values.sum,
}
end
@@ -79,11 +80,11 @@ class GlobalMilestone
end
def active?
- state == 'active'
+ state == "active"
end
def closed?
- state == 'closed'
+ state == "closed"
end
def issues
diff --git a/app/models/gpg_key.rb b/app/models/gpg_key.rb
index 077afffd358..b14053b4c03 100644
--- a/app/models/gpg_key.rb
+++ b/app/models/gpg_key.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class GpgKey < ActiveRecord::Base
- KEY_PREFIX = '-----BEGIN PGP PUBLIC KEY BLOCK-----'.freeze
- KEY_SUFFIX = '-----END PGP PUBLIC KEY BLOCK-----'.freeze
+ KEY_PREFIX = "-----BEGIN PGP PUBLIC KEY BLOCK-----"
+ KEY_SUFFIX = "-----END PGP PUBLIC KEY BLOCK-----"
include ShaAttribute
@@ -11,7 +11,7 @@ class GpgKey < ActiveRecord::Base
belongs_to :user
has_many :gpg_signatures
- has_many :subkeys, class_name: 'GpgKeySubkey'
+ has_many :subkeys, class_name: "GpgKeySubkey"
scope :with_subkeys, -> { includes(:subkeys) }
@@ -22,7 +22,7 @@ class GpgKey < ActiveRecord::Base
uniqueness: true,
format: {
with: /\A#{KEY_PREFIX}((?!#{KEY_PREFIX})(?!#{KEY_SUFFIX}).)+#{KEY_SUFFIX}\Z/m,
- message: "is invalid. A valid public GPG key begins with '#{KEY_PREFIX}' and ends with '#{KEY_SUFFIX}'"
+ message: "is invalid. A valid public GPG key begins with '#{KEY_PREFIX}' and ends with '#{KEY_SUFFIX}'",
}
validates :fingerprint,
@@ -30,14 +30,14 @@ class GpgKey < ActiveRecord::Base
uniqueness: true,
# only validate when the `key` is valid, as we don't want the user to show
# the error about the fingerprint
- unless: -> { errors.has_key?(:key) }
+ unless: -> { errors.key?(:key) }
validates :primary_keyid,
presence: true,
uniqueness: true,
# only validate when the `key` is valid, as we don't want the user to show
# the error about the fingerprint
- unless: -> { errors.has_key?(:key) }
+ unless: -> { errors.key?(:key) }
before_validation :extract_fingerprint, :extract_primary_keyid
after_commit :update_invalid_gpg_signatures, on: :create
@@ -46,7 +46,7 @@ class GpgKey < ActiveRecord::Base
def primary_keyid
super&.upcase
end
- alias_method :keyid, :primary_keyid
+ alias keyid primary_keyid
def fingerprint
super&.upcase
@@ -71,12 +71,12 @@ class GpgKey < ActiveRecord::Base
end
def emails_with_verified_status
- user_infos.map do |user_info|
+ user_infos.map { |user_info|
[
user_info[:email],
- user.verified_email?(user_info[:email])
+ user.verified_email?(user_info[:email]),
]
- end.to_h
+ }.to_h
end
def verified?
@@ -88,7 +88,7 @@ class GpgKey < ActiveRecord::Base
end
def update_invalid_gpg_signatures
- InvalidGpgSignatureUpdateWorker.perform_async(self.id)
+ InvalidGpgSignatureUpdateWorker.perform_async(id)
end
def revoke
diff --git a/app/models/gpg_signature.rb b/app/models/gpg_signature.rb
index 7f9ff7bbda6..dfe93e3d8ab 100644
--- a/app/models/gpg_signature.rb
+++ b/app/models/gpg_signature.rb
@@ -12,7 +12,7 @@ class GpgSignature < ApplicationRecord
same_user_different_email: 2,
other_user: 3,
unverified_key: 4,
- unknown_key: 5
+ unknown_key: 5,
}
belongs_to :project
diff --git a/app/models/group.rb b/app/models/group.rb
index 52f503404af..5ef7a211318 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'carrierwave/orm/activerecord'
+require "carrierwave/orm/activerecord"
class Group < Namespace
include Gitlab::ConfigHelper
@@ -17,15 +17,15 @@ class Group < Namespace
include Gitlab::Utils::StrongMemoize
has_many :group_members, -> { where(requested_at: nil) }, dependent: :destroy, as: :source # rubocop:disable Cop/ActiveRecordDependent
- alias_method :members, :group_members
+ alias members group_members
has_many :users, through: :group_members
has_many :owners,
- -> { where(members: { access_level: Gitlab::Access::OWNER }) },
+ -> { where(members: {access_level: Gitlab::Access::OWNER}) },
through: :group_members,
source: :user
- has_many :requesters, -> { where.not(requested_at: nil) }, dependent: :destroy, as: :source, class_name: 'GroupMember' # rubocop:disable Cop/ActiveRecordDependent
- has_many :members_and_requesters, as: :source, class_name: 'GroupMember'
+ has_many :requesters, -> { where.not(requested_at: nil) }, dependent: :destroy, as: :source, class_name: "GroupMember" # rubocop:disable Cop/ActiveRecordDependent
+ has_many :members_and_requesters, as: :source, class_name: "GroupMember"
has_many :milestones
has_many :project_group_links, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -35,15 +35,15 @@ class Group < Namespace
# Left here just to be dependent: :destroy
has_many :notification_settings, dependent: :destroy, as: :source # rubocop:disable Cop/ActiveRecordDependent
- has_many :labels, class_name: 'GroupLabel'
- has_many :variables, class_name: 'Ci::GroupVariable'
- has_many :custom_attributes, class_name: 'GroupCustomAttribute'
+ has_many :labels, class_name: "GroupLabel"
+ has_many :variables, class_name: "Ci::GroupVariable"
+ has_many :custom_attributes, class_name: "GroupCustomAttribute"
has_many :boards
- has_many :badges, class_name: 'GroupBadge'
+ has_many :badges, class_name: "GroupBadge"
- has_many :cluster_groups, class_name: 'Clusters::Group'
- has_many :clusters, through: :cluster_groups, class_name: 'Clusters::Cluster'
+ has_many :cluster_groups, class_name: "Clusters::Group"
+ has_many :clusters, through: :cluster_groups, class_name: "Clusters::Cluster"
has_many :todos
@@ -54,7 +54,7 @@ class Group < Namespace
validate :visibility_level_allowed_by_parent
validates :variables, variable_duplicates: true
- validates :two_factor_grace_period, presence: true, numericality: { greater_than_or_equal_to: 0 }
+ validates :two_factor_grace_period, presence: true, numericality: {greater_than_or_equal_to: 0}
add_authentication_token_field :runners_token, encrypted: true, migrating: true
@@ -65,10 +65,10 @@ class Group < Namespace
class << self
def sort_by_attribute(method)
- if method == 'storage_size_desc'
+ if method == "storage_size_desc"
# storage_size is a virtual column so we need to
# pass a string to avoid AR adding the table name
- reorder('storage_size DESC, namespaces.id DESC')
+ reorder("storage_size DESC, namespaces.id DESC")
else
order_by(method)
end
@@ -97,8 +97,8 @@ class Group < Namespace
def select_for_project_authorization
if current_scope.joins_values.include?(:shared_projects)
- joins('INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id')
- .where('project_namespace.share_with_group_lock = ?', false)
+ joins("INNER JOIN namespaces project_namespace ON project_namespace.id = projects.namespace_id")
+ .where("project_namespace.share_with_group_lock = ?", false)
.select("projects.id AS project_id, LEAST(project_group_links.group_access, members.access_level) AS access_level")
else
super
@@ -108,13 +108,13 @@ class Group < Namespace
private
def public_to_user_arel(user)
- self.arel_table[:visibility_level]
+ arel_table[:visibility_level]
.in(Gitlab::VisibilityLevel.levels_for_user(user))
end
def visible_to_user_arel(user)
- groups_table = self.arel_table
- authorized_groups = user.authorized_groups.as('authorized')
+ groups_table = arel_table
+ authorized_groups = user.authorized_groups.as("authorized")
groups_table.project(1)
.from(authorized_groups)
@@ -144,21 +144,21 @@ class Group < Namespace
full_name
end
- def visibility_level_allowed_by_parent?(level = self.visibility_level)
- return true unless parent_id && parent_id.nonzero?
+ def visibility_level_allowed_by_parent?(level = visibility_level)
+ return true unless parent_id&.nonzero?
level <= parent.visibility_level
end
- def visibility_level_allowed_by_projects?(level = self.visibility_level)
- !projects.where('visibility_level > ?', level).exists?
+ def visibility_level_allowed_by_projects?(level = visibility_level)
+ !projects.where("visibility_level > ?", level).exists?
end
- def visibility_level_allowed_by_sub_groups?(level = self.visibility_level)
- !children.where('visibility_level > ?', level).exists?
+ def visibility_level_allowed_by_sub_groups?(level = visibility_level)
+ !children.where("visibility_level > ?", level).exists?
end
- def visibility_level_allowed?(level = self.visibility_level)
+ def visibility_level_allowed?(level = visibility_level)
visibility_level_allowed_by_parent?(level) &&
visibility_level_allowed_by_projects?(level) &&
visibility_level_allowed_by_sub_groups?(level)
@@ -213,7 +213,7 @@ class Group < Namespace
end
# @deprecated
- alias_method :add_master, :add_maintainer
+ alias add_master add_maintainer
def add_owner(user, current_user = nil)
add_user(user, :owner, current_user: current_user)
@@ -238,7 +238,7 @@ class Group < Namespace
end
# @deprecated
- alias_method :has_master?, :has_maintainer?
+ alias has_master? has_maintainer?
# Check if user is a last owner of the group.
# Parent owners are ignored for nested groups.
@@ -334,7 +334,7 @@ class Group < Namespace
User
.where(id: direct_and_indirect_members.select(:user_id))
.reorder(nil),
- project_users_with_descendants
+ project_users_with_descendants,
])
end
@@ -343,7 +343,7 @@ class Group < Namespace
def project_users_with_descendants
User
.joins(projects: :group)
- .where(namespaces: { id: self_and_descendants.select(:id) })
+ .where(namespaces: {id: self_and_descendants.select(:id)})
end
def max_member_access_for_user(user)
@@ -352,8 +352,8 @@ class Group < Namespace
members_with_parents
.where(user_id: user)
.reorder(access_level: :desc)
- .first&.
- access_level || GroupMember::NO_ACCESS
+ .first
+ &.access_level || GroupMember::NO_ACCESS
end
def mattermost_team_params
@@ -362,7 +362,7 @@ class Group < Namespace
{
name: path[0..max_length],
display_name: name[0..max_length],
- type: public? ? 'O' : 'I' # Open vs Invite-only
+ type: public? ? "O" : "I", # Open vs Invite-only
}
end
diff --git a/app/models/group_custom_attribute.rb b/app/models/group_custom_attribute.rb
index 22f14885657..1915f6914e8 100644
--- a/app/models/group_custom_attribute.rb
+++ b/app/models/group_custom_attribute.rb
@@ -4,5 +4,5 @@ class GroupCustomAttribute < ActiveRecord::Base
belongs_to :group
validates :group, :key, :value, presence: true
- validates :key, uniqueness: { scope: [:group_id] }
+ validates :key, uniqueness: {scope: [:group_id]}
end
diff --git a/app/models/group_label.rb b/app/models/group_label.rb
index ff14529c6e6..26b69277118 100644
--- a/app/models/group_label.rb
+++ b/app/models/group_label.rb
@@ -8,6 +8,6 @@ class GroupLabel < Label
alias_attribute :subject, :group
def subject_foreign_key
- 'group_id'
+ "group_id"
end
end
diff --git a/app/models/group_milestone.rb b/app/models/group_milestone.rb
index 97cb26c6ea9..8b8f09bee9e 100644
--- a/app/models/group_milestone.rb
+++ b/app/models/group_milestone.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# Group Milestones are milestones that can be shared among many projects within the same group
class GroupMilestone < GlobalMilestone
attr_reader :group, :milestones
def self.build_collection(group, projects, params)
params =
- { state: params[:state], search_title: params[:search_title] }
+ {state: params[:state], search_title: params[:search_title]}
project_milestones = Milestone.of_projects(projects)
project_milestones = project_milestones.search_title(params[:search_title]) if params[:search_title].present?
@@ -34,7 +35,7 @@ class GroupMilestone < GlobalMilestone
end
def issues_finder_params
- { group_id: group.id }
+ {group_id: group.id}
end
def legacy_group_milestone?
diff --git a/app/models/hooks/project_hook.rb b/app/models/hooks/project_hook.rb
index 18c387f0d34..42e1fb18347 100644
--- a/app/models/hooks/project_hook.rb
+++ b/app/models/hooks/project_hook.rb
@@ -13,7 +13,7 @@ class ProjectHook < WebHook
:merge_request_hooks,
:job_hooks,
:pipeline_hooks,
- :wiki_page_hooks
+ :wiki_page_hooks,
]
belongs_to :project
diff --git a/app/models/hooks/service_hook.rb b/app/models/hooks/service_hook.rb
index 8f305dd7c22..78a53658b9a 100644
--- a/app/models/hooks/service_hook.rb
+++ b/app/models/hooks/service_hook.rb
@@ -5,7 +5,7 @@ class ServiceHook < WebHook
validates :service, presence: true
# rubocop: disable CodeReuse/ServiceClass
- def execute(data, hook_name = 'service_hook')
+ def execute(data, hook_name = "service_hook")
WebHookService.new(self, data, hook_name).execute
end
# rubocop: enable CodeReuse/ServiceClass
diff --git a/app/models/hooks/system_hook.rb b/app/models/hooks/system_hook.rb
index 90b4588a325..c67bcb223e8 100644
--- a/app/models/hooks/system_hook.rb
+++ b/app/models/hooks/system_hook.rb
@@ -7,7 +7,7 @@ class SystemHook < WebHook
:repository_update_hooks,
:push_hooks,
:tag_push_hooks,
- :merge_request_hooks
+ :merge_request_hooks,
]
default_value_for :push_events, false
diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb
index 1a8662db9fb..4c5bdd1a148 100644
--- a/app/models/hooks/web_hook.rb
+++ b/app/models/hooks/web_hook.rb
@@ -4,21 +4,21 @@ class WebHook < ActiveRecord::Base
include Sortable
attr_encrypted :token,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm',
- key: Settings.attr_encrypted_db_key_base_32
+ mode: :per_attribute_iv,
+ algorithm: "aes-256-gcm",
+ key: Settings.attr_encrypted_db_key_base_32
attr_encrypted :url,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm',
- key: Settings.attr_encrypted_db_key_base_32
+ mode: :per_attribute_iv,
+ algorithm: "aes-256-gcm",
+ key: Settings.attr_encrypted_db_key_base_32
has_many :web_hook_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- validates :url, presence: true, public_url: { allow_localhost: lambda(&:allow_local_requests?),
- allow_local_network: lambda(&:allow_local_requests?) }
+ validates :url, presence: true, public_url: {allow_localhost: lambda(&:allow_local_requests?),
+ allow_local_network: lambda(&:allow_local_requests?),}
- validates :token, format: { without: /\n/ }
+ validates :token, format: {without: /\n/}
validates :push_events_branch_filter, branch_filter: true
# rubocop: disable CodeReuse/ServiceClass
diff --git a/app/models/hooks/web_hook_log.rb b/app/models/hooks/web_hook_log.rb
index 2d9f7594e8c..e9671efcd6a 100644
--- a/app/models/hooks/web_hook_log.rb
+++ b/app/models/hooks/web_hook_log.rb
@@ -10,7 +10,7 @@ class WebHookLog < ActiveRecord::Base
validates :web_hook, presence: true
def self.recent
- where('created_at >= ?', 2.days.ago.beginning_of_day)
+ where("created_at >= ?", 2.days.ago.beginning_of_day)
.order(created_at: :desc)
end
diff --git a/app/models/identity.rb b/app/models/identity.rb
index acdde4f296b..c8833db9d64 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -7,8 +7,8 @@ class Identity < ActiveRecord::Base
belongs_to :user
validates :provider, presence: true
- validates :extern_uid, allow_blank: true, uniqueness: { scope: UniquenessScopes.scopes, case_sensitive: false }
- validates :user, uniqueness: { scope: UniquenessScopes.scopes }
+ validates :extern_uid, allow_blank: true, uniqueness: {scope: UniquenessScopes.scopes, case_sensitive: false}
+ validates :user, uniqueness: {scope: UniquenessScopes.scopes}
before_save :ensure_normalized_extern_uid, if: :extern_uid_changed?
after_destroy :clear_user_synced_attributes, if: :user_synced_attributes_metadata_from_provider?
@@ -35,7 +35,7 @@ class Identity < ActiveRecord::Base
def ensure_normalized_extern_uid
return if extern_uid.nil?
- self.extern_uid = Identity.normalize_uid(self.provider, self.extern_uid)
+ self.extern_uid = Identity.normalize_uid(provider, extern_uid)
end
def user_synced_attributes_metadata_from_provider?
diff --git a/app/models/instance_configuration.rb b/app/models/instance_configuration.rb
index 11289887e00..aa4d8d1737d 100644
--- a/app/models/instance_configuration.rb
+++ b/app/models/instance_configuration.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'resolv'
+require "resolv"
class InstanceConfiguration
- SSH_ALGORITHMS = %w(DSA ECDSA ED25519 RSA).freeze
- SSH_ALGORITHMS_PATH = '/etc/ssh/'.freeze
- CACHE_KEY = 'instance_configuration'.freeze
+ SSH_ALGORITHMS = %w[DSA ECDSA ED25519 RSA].freeze
+ SSH_ALGORITHMS_PATH = "/etc/ssh/"
+ CACHE_KEY = "instance_configuration"
EXPIRATION_TIME = 24.hours
def settings
- @configuration ||= Rails.cache.fetch(CACHE_KEY, expires_in: EXPIRATION_TIME) do
- { ssh_algorithms_hashes: ssh_algorithms_hashes,
- host: host,
- gitlab_pages: gitlab_pages,
- gitlab_ci: gitlab_ci }.deep_symbolize_keys
- end
+ @configuration ||= Rails.cache.fetch(CACHE_KEY, expires_in: EXPIRATION_TIME) {
+ {ssh_algorithms_hashes: ssh_algorithms_hashes,
+ host: host,
+ gitlab_pages: gitlab_pages,
+ gitlab_ci: gitlab_ci,}.deep_symbolize_keys
+ }
end
private
@@ -38,9 +38,9 @@ class InstanceConfiguration
def gitlab_ci
Settings.gitlab_ci
- .to_h
- .merge(artifacts_max_size: { value: Settings.artifacts.max_size&.megabytes,
- default: 100.megabytes })
+ .to_h
+ .merge(artifacts_max_size: {value: Settings.artifacts.max_size&.megabytes,
+ default: 100.megabytes,})
end
def ssh_algorithm_file(algorithm)
@@ -51,9 +51,9 @@ class InstanceConfiguration
content = ssh_algorithm_file_content(algorithm)
return unless content.present?
- { name: algorithm,
- md5: ssh_algorithm_md5(content),
- sha256: ssh_algorithm_sha256(content) }
+ {name: algorithm,
+ md5: ssh_algorithm_md5(content),
+ sha256: ssh_algorithm_sha256(content),}
end
def ssh_algorithm_file_content(algorithm)
@@ -68,6 +68,6 @@ class InstanceConfiguration
end
def ssh_algorithm_sha256(ssh_file_content)
- Gitlab::SSHPublicKey.new(ssh_file_content).fingerprint('SHA256')
+ Gitlab::SSHPublicKey.new(ssh_file_content).fingerprint("SHA256")
end
end
diff --git a/app/models/internal_id.rb b/app/models/internal_id.rb
index e75c6eb2331..6171767fd43 100644
--- a/app/models/internal_id.rb
+++ b/app/models/internal_id.rb
@@ -19,7 +19,7 @@ class InternalId < ActiveRecord::Base
belongs_to :project
belongs_to :namespace
- enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 }
+ enum usage: {issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5}
validates :usage, presence: true
@@ -113,9 +113,9 @@ class InternalId < ActiveRecord::Base
@init = init
@usage = usage
- raise ArgumentError, 'Scope is not well-defined, need at least one column for scope (given: 0)' if scope.empty?
+ raise ArgumentError, "Scope is not well-defined, need at least one column for scope (given: 0)" if scope.empty?
- unless InternalId.usages.has_key?(usage.to_s)
+ unless InternalId.usages.key?(usage.to_s)
raise ArgumentError, "Usage '#{usage}' is unknown. Supported values are #{InternalId.usages.keys} from InternalId.usages"
end
end
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 071ad50fddc..d2b4fbba526 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'carrierwave/orm/activerecord'
+require "carrierwave/orm/activerecord"
class Issue < ActiveRecord::Base
include AtomicInternalId
@@ -19,25 +19,25 @@ class Issue < ActiveRecord::Base
ignore_column :assignee_id, :branch_name, :deleted_at
DueDateStruct = Struct.new(:title, :name).freeze
- NoDueDate = DueDateStruct.new('No Due Date', '0').freeze
- AnyDueDate = DueDateStruct.new('Any Due Date', '').freeze
- Overdue = DueDateStruct.new('Overdue', 'overdue').freeze
- DueThisWeek = DueDateStruct.new('Due This Week', 'week').freeze
- DueThisMonth = DueDateStruct.new('Due This Month', 'month').freeze
- DueNextMonthAndPreviousTwoWeeks = DueDateStruct.new('Due Next Month And Previous Two Weeks', 'next_month_and_previous_two_weeks').freeze
+ NoDueDate = DueDateStruct.new("No Due Date", "0").freeze
+ AnyDueDate = DueDateStruct.new("Any Due Date", "").freeze
+ Overdue = DueDateStruct.new("Overdue", "overdue").freeze
+ DueThisWeek = DueDateStruct.new("Due This Week", "week").freeze
+ DueThisMonth = DueDateStruct.new("Due This Month", "month").freeze
+ DueNextMonthAndPreviousTwoWeeks = DueDateStruct.new("Due Next Month And Previous Two Weeks", "next_month_and_previous_two_weeks").freeze
SORTING_PREFERENCE_FIELD = :issues_sort
belongs_to :project
- belongs_to :moved_to, class_name: 'Issue'
- belongs_to :closed_by, class_name: 'User'
+ belongs_to :moved_to, class_name: "Issue"
+ belongs_to :closed_by, class_name: "User"
has_internal_id :iid, scope: :project, init: ->(s) { s&.project&.issues&.maximum(:iid) }
has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :merge_requests_closing_issues,
- class_name: 'MergeRequestsClosingIssues',
+ class_name: "MergeRequestsClosingIssues",
dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :issue_assignees
@@ -49,19 +49,19 @@ class Issue < ActiveRecord::Base
scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
- scope :assigned, -> { where('EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)') }
- scope :unassigned, -> { where('NOT EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)') }
- scope :assigned_to, ->(u) { where('EXISTS (SELECT TRUE FROM issue_assignees WHERE user_id = ? AND issue_id = issues.id)', u.id)}
+ scope :assigned, -> { where("EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)") }
+ scope :unassigned, -> { where("NOT EXISTS (SELECT TRUE FROM issue_assignees WHERE issue_id = issues.id)") }
+ scope :assigned_to, ->(u) { where("EXISTS (SELECT TRUE FROM issue_assignees WHERE user_id = ? AND issue_id = issues.id)", u.id)}
scope :with_due_date, -> { where.not(due_date: nil) }
scope :without_due_date, -> { where(due_date: nil) }
- scope :due_before, ->(date) { where('issues.due_date < ?', date) }
- scope :due_between, ->(from_date, to_date) { where('issues.due_date >= ?', from_date).where('issues.due_date <= ?', to_date) }
+ scope :due_before, ->(date) { where("issues.due_date < ?", date) }
+ scope :due_between, ->(from_date, to_date) { where("issues.due_date >= ?", from_date).where("issues.due_date <= ?", to_date) }
scope :due_tomorrow, -> { where(due_date: Date.tomorrow) }
- scope :order_due_date_asc, -> { reorder('issues.due_date IS NULL, issues.due_date ASC') }
- scope :order_due_date_desc, -> { reorder('issues.due_date IS NULL, issues.due_date DESC') }
- scope :order_closest_future_date, -> { reorder('CASE WHEN issues.due_date >= CURRENT_DATE THEN 0 ELSE 1 END ASC, ABS(CURRENT_DATE - issues.due_date) ASC') }
+ scope :order_due_date_asc, -> { reorder("issues.due_date IS NULL, issues.due_date ASC") }
+ scope :order_due_date_desc, -> { reorder("issues.due_date IS NULL, issues.due_date DESC") }
+ scope :order_closest_future_date, -> { reorder("CASE WHEN issues.due_date >= CURRENT_DATE THEN 0 ELSE 1 END ASC, ABS(CURRENT_DATE - issues.due_date) ASC") }
scope :preload_associations, -> { preload(:labels, project: :namespace) }
@@ -99,7 +99,7 @@ class Issue < ActiveRecord::Base
end
class << self
- alias_method :in_parents, :in_projects
+ alias in_parents in_projects
end
def self.parent_column
@@ -107,7 +107,7 @@ class Issue < ActiveRecord::Base
end
def self.reference_prefix
- '#'
+ "#"
end
# Pattern used to extract `#123` issue references from text
@@ -129,15 +129,15 @@ class Issue < ActiveRecord::Base
end
def self.project_foreign_key
- 'project_id'
+ "project_id"
end
def self.sort_by_attribute(method, excluded_labels: [])
case method.to_s
- when 'closest_future_date' then order_closest_future_date
- when 'due_date' then order_due_date_asc
- when 'due_date_asc' then order_due_date_asc
- when 'due_date_desc' then order_due_date_desc
+ when "closest_future_date" then order_closest_future_date
+ when "due_date" then order_due_date_asc
+ when "due_date_asc" then order_due_date_asc
+ when "due_date_desc" then order_due_date_desc
else
super
end
@@ -145,9 +145,9 @@ class Issue < ActiveRecord::Base
def self.order_by_position_and_priority
order_labels_priority
- .reorder(Gitlab::Database.nulls_last_order('relative_position', 'ASC'),
- Gitlab::Database.nulls_last_order('highest_priority', 'ASC'),
- "id DESC")
+ .reorder(Gitlab::Database.nulls_last_order("relative_position", "ASC"),
+ Gitlab::Database.nulls_last_order("highest_priority", "ASC"),
+ "id DESC")
end
def hook_attrs
@@ -157,8 +157,8 @@ class Issue < ActiveRecord::Base
# Returns a Hash of attributes to be used for Twitter card metadata
def card_attributes
{
- 'Author' => author.try(:name),
- 'Assignee' => assignee_list
+ "Author" => author.try(:name),
+ "Assignee" => assignee_list,
}
end
@@ -181,7 +181,7 @@ class Issue < ActiveRecord::Base
return to_branch_name unless project.repository.branch_exists?(to_branch_name)
start_counting_from = 2
- Uniquify.new(start_counting_from).string(-> (counter) { "#{to_branch_name}-#{counter}" }) do |suggested_branch_name|
+ Uniquify.new(start_counting_from).string(->(counter) { "#{to_branch_name}-#{counter}" }) do |suggested_branch_name|
project.repository.branch_exists?(suggested_branch_name)
end
end
@@ -209,11 +209,11 @@ class Issue < ActiveRecord::Base
end
!moved? && persisted? &&
- user.can?(:admin_issue, self.project)
+ user.can?(:admin_issue, project)
end
def to_branch_name
- if self.confidential?
+ if confidential?
"#{iid}-confidential-issue"
else
"#{iid}-#{title.parameterize}"
@@ -221,13 +221,13 @@ class Issue < ActiveRecord::Base
end
def can_be_worked_on?
- !self.closed? && !self.project.forked?
+ !closed? && !project.forked?
end
# Returns `true` if the current issue can be viewed by either a logged in User
# or an anonymous user.
def visible_to_user?(user = nil)
- return false unless project && project.feature_available?(:issues, user)
+ return false unless project&.feature_available?(:issues, user)
user ? readable_by?(user) : publicly_visible?
end
diff --git a/app/models/issue/metrics.rb b/app/models/issue/metrics.rb
index 0f5ee957ec9..0b3d507dc00 100644
--- a/app/models/issue/metrics.rb
+++ b/app/models/issue/metrics.rb
@@ -4,15 +4,15 @@ class Issue::Metrics < ActiveRecord::Base
belongs_to :issue
def record!
- if issue.milestone_id.present? && self.first_associated_with_milestone_at.blank?
+ if issue.milestone_id.present? && first_associated_with_milestone_at.blank?
self.first_associated_with_milestone_at = Time.now
end
- if issue_assigned_to_list_label? && self.first_added_to_board_at.blank?
+ if issue_assigned_to_list_label? && first_added_to_board_at.blank?
self.first_added_to_board_at = Time.now
end
- self.save
+ save
end
private
diff --git a/app/models/issue_collection.rb b/app/models/issue_collection.rb
index 05607fc3a08..c3be71bbffc 100644
--- a/app/models/issue_collection.rb
+++ b/app/models/issue_collection.rb
@@ -34,7 +34,7 @@ class IssueCollection
end
end
- alias_method :visible_to, :updatable_by_user
+ alias visible_to updatable_by_user
private
diff --git a/app/models/key.rb b/app/models/key.rb
index 8f93418b88b..e6174182198 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'digest/md5'
+require "digest/md5"
class Key < ActiveRecord::Base
include AfterCommitQueue
@@ -12,16 +12,16 @@ class Key < ActiveRecord::Base
validates :title,
presence: true,
- length: { maximum: 255 }
+ length: {maximum: 255}
validates :key,
presence: true,
- length: { maximum: 5000 },
- format: { with: /\A(ssh|ecdsa)-.*\Z/ }
+ length: {maximum: 5000},
+ format: {with: /\A(ssh|ecdsa)-.*\Z/}
validates :fingerprint,
uniqueness: true,
- presence: { message: 'cannot be generated' }
+ presence: {message: "cannot be generated"}
validate :key_meets_restrictions
@@ -35,7 +35,7 @@ class Key < ActiveRecord::Base
after_destroy :refresh_user_cache
def self.regular_keys
- where(type: ['Key', nil])
+ where(type: ["Key", nil])
end
def key=(value)
@@ -47,7 +47,7 @@ class Key < ActiveRecord::Base
def publishable_key
# Strip out the keys comment so we don't leak email addresses
# Replace with simple ident of user_name (hostname)
- self.key.split[0..1].push("#{self.user_name} (#{Gitlab.config.gitlab.host})").join(' ')
+ key.split[0..1].push("#{user_name} (#{Gitlab.config.gitlab.host})").join(" ")
end
# projects that has this key
@@ -130,7 +130,7 @@ class Key < ActiveRecord::Base
Gitlab::CurrentSettings
.allowed_key_types
.map(&:upcase)
- .to_sentence(last_word_connector: ', or ', two_words_connector: ' or ')
+ .to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
"type is forbidden. Must be #{allowed_types}"
end
diff --git a/app/models/label.rb b/app/models/label.rb
index 1c3db3eb35d..3237350ff04 100644
--- a/app/models/label.rb
+++ b/app/models/label.rb
@@ -11,41 +11,41 @@ class Label < ActiveRecord::Base
cache_markdown_field :description, pipeline: :single_line
- DEFAULT_COLOR = '#428BCA'
- NONE = 'no label'
+ DEFAULT_COLOR = "#428BCA"
+ NONE = "no label"
default_value_for :color, DEFAULT_COLOR
has_many :lists, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :priorities, class_name: 'LabelPriority'
+ has_many :priorities, class_name: "LabelPriority"
has_many :label_links, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :issues, through: :label_links, source: :target, source_type: 'Issue'
- has_many :merge_requests, through: :label_links, source: :target, source_type: 'MergeRequest'
+ has_many :issues, through: :label_links, source: :target, source_type: "Issue"
+ has_many :merge_requests, through: :label_links, source: :target, source_type: "MergeRequest"
before_validation :strip_whitespace_from_title_and_color
validates :color, color: true, allow_blank: false
# Don't allow ',' for label titles
- validates :title, presence: true, format: { with: /\A[^,]+\z/ }
- validates :title, uniqueness: { scope: [:group_id, :project_id] }
- validates :title, length: { maximum: 255 }
+ validates :title, presence: true, format: {with: /\A[^,]+\z/}
+ validates :title, uniqueness: {scope: [:group_id, :project_id]}
+ validates :title, length: {maximum: 255}
default_scope { order(title: :asc) }
scope :templates, -> { where(template: true) }
scope :with_title, ->(title) { where(title: title) }
scope :with_lists_and_board, -> { joins(lists: :board).merge(List.movable) }
- scope :on_project_boards, ->(project_id) { with_lists_and_board.where(boards: { project_id: project_id }) }
- scope :on_board, ->(board_id) { with_lists_and_board.where(boards: { id: board_id }) }
+ scope :on_project_boards, ->(project_id) { with_lists_and_board.where(boards: {project_id: project_id}) }
+ scope :on_board, ->(board_id) { with_lists_and_board.where(boards: {id: board_id}) }
scope :order_name_asc, -> { reorder(title: :asc) }
scope :order_name_desc, -> { reorder(title: :desc) }
- scope :subscribed_by, ->(user_id) { joins(:subscriptions).where(subscriptions: { user_id: user_id, subscribed: true }) }
+ scope :subscribed_by, ->(user_id) { joins(:subscriptions).where(subscriptions: {user_id: user_id, subscribed: true}) }
def self.prioritized(project)
joins(:priorities)
- .where(label_priorities: { project_id: project })
- .reorder('label_priorities.priority ASC, labels.title ASC')
+ .where(label_priorities: {project_id: project})
+ .reorder("label_priorities.priority ASC, labels.title ASC")
end
def self.unprioritized(project)
@@ -53,8 +53,8 @@ class Label < ActiveRecord::Base
priorities = LabelPriority.arel_table
label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin)
- .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id)))
- .join_sources
+ .on(labels[:id].eq(priorities[:label_id]).and(priorities[:project_id].eq(project.id)))
+ .join_sources
joins(label_priorities).where(priorities[:priority].eq(nil))
end
@@ -64,8 +64,8 @@ class Label < ActiveRecord::Base
priorities = LabelPriority.arel_table
label_priorities = labels.join(priorities, Arel::Nodes::OuterJoin)
- .on(labels[:id].eq(priorities[:label_id]))
- .join_sources
+ .on(labels[:id].eq(priorities[:label_id]))
+ .join_sources
joins(label_priorities)
end
@@ -81,7 +81,7 @@ class Label < ActiveRecord::Base
alias_attribute :name, :title
def self.reference_prefix
- '~'
+ "~"
end
##
@@ -127,19 +127,19 @@ class Label < ActiveRecord::Base
end
def open_issues_count(user = nil)
- issues_count(user, state: 'opened')
+ issues_count(user, state: "opened")
end
def closed_issues_count(user = nil)
- issues_count(user, state: 'closed')
+ issues_count(user, state: "closed")
end
def open_merge_requests_count(user = nil)
params = {
subject_foreign_key => subject.id,
- label_name: title,
- scope: 'all',
- state: 'opened'
+ :label_name => title,
+ :scope => "all",
+ :state => "opened",
}
MergeRequestsFinder.new(user, params.with_indifferent_access).execute.count
@@ -157,10 +157,10 @@ class Label < ActiveRecord::Base
def priority(project)
priority = if priorities.loaded?
- priorities.first { |p| p.project == project }
- else
- priorities.find_by(project: project)
- end
+ priorities.first { |p| p.project == project }
+ else
+ priorities.find_by(project: project)
+ end
priority.try(:priority)
end
@@ -178,7 +178,7 @@ class Label < ActiveRecord::Base
end
def text_color
- LabelsHelper.text_color_for_bg(self.color)
+ LabelsHelper.text_color_for_bg(color)
end
def title=(value)
@@ -212,7 +212,7 @@ class Label < ActiveRecord::Base
def as_json(options = {})
super(options).tap do |json|
- json[:type] = self.try(:type)
+ json[:type] = try(:type)
json[:priority] = priority(options[:project]) if options.key?(:project)
json[:textColor] = text_color
end
@@ -225,12 +225,12 @@ class Label < ActiveRecord::Base
private
def issues_count(user, params = {})
- params.merge!(subject_foreign_key => subject.id, label_name: title, scope: 'all')
+ params.merge!(subject_foreign_key => subject.id, :label_name => title, :scope => "all")
IssuesFinder.new(user, params.with_indifferent_access).execute.count
end
def label_format_reference(format = :id)
- raise StandardError, 'Unknown format' unless [:id, :name].include?(format)
+ raise StandardError, "Unknown format" unless [:id, :name].include?(format)
if format == :name && !name.include?('"')
%("#{name}")
@@ -244,6 +244,6 @@ class Label < ActiveRecord::Base
end
def strip_whitespace_from_title_and_color
- %w(color title).each { |attr| self[attr] = self[attr]&.strip }
+ %w[color title].each { |attr| self[attr] = self[attr]&.strip }
end
end
diff --git a/app/models/label_note.rb b/app/models/label_note.rb
index 680952cf421..e9fd31c3572 100644
--- a/app/models/label_note.rb
+++ b/app/models/label_note.rb
@@ -13,9 +13,9 @@ class LabelNote < Note
created_at: events.first.created_at,
discussion_id: events.first.discussion_id,
noteable: resource,
- system_note_metadata: SystemNoteMetadata.new(action: 'label'),
+ system_note_metadata: SystemNoteMetadata.new(action: "label"),
events: events,
- resource_parent: resource_parent
+ resource_parent: resource_parent,
}
if resource_parent.is_a?(Project)
@@ -62,10 +62,10 @@ class LabelNote < Note
end
def note_text(html: false)
- added = labels_str('added', label_refs_by_action('add', html))
- removed = labels_str('removed', label_refs_by_action('remove', html))
+ added = labels_str("added", label_refs_by_action("add", html))
+ removed = labels_str("removed", label_refs_by_action("remove", html))
- [added, removed].compact.join(' and ')
+ [added, removed].compact.join(" and ")
end
# returns string containing added/removed labels including
@@ -76,15 +76,15 @@ class LabelNote < Note
# added ~1 ~2 labels
def labels_str(prefix, label_refs)
existing_refs = label_refs.select { |ref| ref.present? }.sort
- refs_str = existing_refs.empty? ? nil : existing_refs.join(' ')
+ refs_str = existing_refs.empty? ? nil : existing_refs.join(" ")
deleted = label_refs.count - existing_refs.count
deleted_str = deleted == 0 ? nil : "#{deleted} deleted"
return nil unless refs_str || deleted_str
- label_list_str = [refs_str, deleted_str].compact.join(' + ')
- suffix = 'label'.pluralize(deleted > 0 ? deleted : existing_refs.count)
+ label_list_str = [refs_str, deleted_str].compact.join(" + ")
+ suffix = "label".pluralize(deleted > 0 ? deleted : existing_refs.count)
"#{prefix} #{label_list_str} #{suffix}"
end
diff --git a/app/models/label_priority.rb b/app/models/label_priority.rb
index 8ed8bb7577f..4d91b4edd21 100644
--- a/app/models/label_priority.rb
+++ b/app/models/label_priority.rb
@@ -5,6 +5,6 @@ class LabelPriority < ActiveRecord::Base
belongs_to :label
validates :project, :label, :priority, presence: true
- validates :label_id, uniqueness: { scope: :project_id }
- validates :priority, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+ validates :label_id, uniqueness: {scope: :project_id}
+ validates :priority, numericality: {only_integer: true, greater_than_or_equal_to: 0}
end
diff --git a/app/models/legacy_diff_discussion.rb b/app/models/legacy_diff_discussion.rb
index 7d78c580fa2..50fd7ce1f68 100644
--- a/app/models/legacy_diff_discussion.rb
+++ b/app/models/legacy_diff_discussion.rb
@@ -42,8 +42,6 @@ class LegacyDiffDiscussion < Discussion
if active?
{}
- else
- nil
end
end
diff --git a/app/models/legacy_diff_note.rb b/app/models/legacy_diff_note.rb
index 00dec6bb92b..92b9b38e507 100644
--- a/app/models/legacy_diff_note.rb
+++ b/app/models/legacy_diff_note.rb
@@ -20,11 +20,11 @@ class LegacyDiffNote < Note
end
def project_repository
- Gitlab::SafeRequestStore.fetch("project:#{project_id}:repository") { self.project.repository }
+ Gitlab::SafeRequestStore.fetch("project:#{project_id}:repository") { project.repository }
end
def diff_file_hash
- line_code.split('_')[0] if line_code
+ line_code.split("_")[0] if line_code
end
def diff
@@ -36,11 +36,11 @@ class LegacyDiffNote < Note
end
def diff_line
- @diff_line ||= diff_file&.line_for_line_code(self.line_code)
+ @diff_line ||= diff_file&.line_for_line_code(line_code)
end
def original_line_code
- self.line_code
+ line_code
end
# Check if this note is part of an "active" discussion
@@ -76,9 +76,9 @@ class LegacyDiffNote < Note
return nil unless noteable
return @diff if defined?(@diff)
- @diff = noteable.raw_diffs(Commit.max_diff_options).find do |d|
+ @diff = noteable.raw_diffs(Commit.max_diff_options).find { |d|
d.new_path && Digest::SHA1.hexdigest(d.new_path) == diff_file_hash
- end
+ }
end
def set_diff
@@ -93,7 +93,7 @@ class LegacyDiffNote < Note
def diff_for_line_code
attributes = {
noteable_type: noteable_type,
- line_code: line_code
+ line_code: line_code,
}
if for_commit?
@@ -108,6 +108,6 @@ class LegacyDiffNote < Note
# Find the diff on noteable that matches our own
def find_noteable_diff
diffs = noteable.raw_diffs(Commit.max_diff_options)
- diffs.find { |d| d.new_path == self.diff.new_path }
+ diffs.find { |d| d.new_path == diff.new_path }
end
end
diff --git a/app/models/lfs_download_object.rb b/app/models/lfs_download_object.rb
index 6383f95d546..e59a2d40280 100644
--- a/app/models/lfs_download_object.rb
+++ b/app/models/lfs_download_object.rb
@@ -6,9 +6,9 @@ class LfsDownloadObject
attr_accessor :oid, :size, :link
delegate :sanitized_url, :credentials, to: :sanitized_uri
- validates :oid, format: { with: /\A\h{64}\z/ }
- validates :size, numericality: { greater_than_or_equal_to: 0 }
- validates :link, public_url: { protocols: %w(http https) }
+ validates :oid, format: {with: /\A\h{64}\z/}
+ validates :size, numericality: {greater_than_or_equal_to: 0}
+ validates :link, public_url: {protocols: %w[http https]}
def initialize(oid:, size:, link:)
@oid = oid
diff --git a/app/models/lfs_object.rb b/app/models/lfs_object.rb
index 69c563545bb..3e08a616bd2 100644
--- a/app/models/lfs_object.rb
+++ b/app/models/lfs_object.rb
@@ -18,7 +18,7 @@ class LfsObject < ActiveRecord::Base
def update_file_store
# The file.object_store is set during `uploader.store!`
# which happens after object is inserted/updated
- self.update_column(:file_store, file.object_store)
+ update_column(:file_store, file.object_store)
end
def project_allowed_access?(project)
@@ -32,8 +32,8 @@ class LfsObject < ActiveRecord::Base
# rubocop: disable DestroyAll
def self.destroy_unreferenced
joins("LEFT JOIN lfs_objects_projects ON lfs_objects_projects.lfs_object_id = #{table_name}.id")
- .where(lfs_objects_projects: { id: nil })
- .destroy_all
+ .where(lfs_objects_projects: {id: nil})
+ .destroy_all
end
# rubocop: enable DestroyAll
diff --git a/app/models/lfs_objects_project.rb b/app/models/lfs_objects_project.rb
index 353602800d7..6140126aca6 100644
--- a/app/models/lfs_objects_project.rb
+++ b/app/models/lfs_objects_project.rb
@@ -5,7 +5,7 @@ class LfsObjectsProject < ActiveRecord::Base
belongs_to :lfs_object
validates :lfs_object_id, presence: true
- validates :lfs_object_id, uniqueness: { scope: [:project_id], message: "already exists in project" }
+ validates :lfs_object_id, uniqueness: {scope: [:project_id], message: "already exists in project"}
validates :project_id, presence: true
after_commit :update_project_statistics, on: [:create, :destroy]
diff --git a/app/models/license_template.rb b/app/models/license_template.rb
index 73e403f98b4..ad00d45560e 100644
--- a/app/models/license_template.rb
+++ b/app/models/license_template.rb
@@ -27,7 +27,7 @@ class LicenseTemplate
def popular?
category == :Popular
end
- alias_method :featured?, :popular?
+ alias featured? popular?
# Returns the text of the license
def content
diff --git a/app/models/list.rb b/app/models/list.rb
index 682af761ba0..c9dfc6a2afd 100644
--- a/app/models/list.rb
+++ b/app/models/list.rb
@@ -4,12 +4,12 @@ class List < ActiveRecord::Base
belongs_to :board
belongs_to :label
- enum list_type: { backlog: 0, label: 1, closed: 2, assignee: 3, milestone: 4 }
+ enum list_type: {backlog: 0, label: 1, closed: 2, assignee: 3, milestone: 4}
validates :board, :list_type, presence: true
validates :label, :position, presence: true, if: :label?
- validates :label_id, uniqueness: { scope: :board_id }, if: :label?
- validates :position, numericality: { only_integer: true, greater_than_or_equal_to: 0 }, if: :movable?
+ validates :label_id, uniqueness: {scope: :board_id}, if: :label?
+ validates :position, numericality: {only_integer: true, greater_than_or_equal_to: 0}, if: :movable?
before_destroy :can_be_destroyed
diff --git a/app/models/member.rb b/app/models/member.rb
index 8e071a8ff21..4e4842e2e46 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -19,21 +19,21 @@ class Member < ActiveRecord::Base
validates :user, presence: true, unless: :invite?
validates :source, presence: true
- validates :user_id, uniqueness: { scope: [:source_type, :source_id],
- message: "already exists in source",
- allow_nil: true }
- validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
+ validates :user_id, uniqueness: {scope: [:source_type, :source_id],
+ message: "already exists in source",
+ allow_nil: true,}
+ validates :access_level, inclusion: {in: Gitlab::Access.all_values}, presence: true
validate :higher_access_level_than_group, unless: :importing?
validates :invite_email,
presence: {
- if: :invite?
+ if: :invite?,
},
email: {
- allow_nil: true
+ allow_nil: true,
},
uniqueness: {
scope: [:source_type, :source_id],
- allow_nil: true
+ allow_nil: true,
}
# This scope encapsulates (most of) the conditions a row in the member table
@@ -58,7 +58,7 @@ class Member < ActiveRecord::Base
# Like active, but without invites. For when a User is required.
scope :active_without_invites_and_requests, -> do
left_join_users
- .where(users: { state: 'active' })
+ .where(users: {state: "active"})
.non_request
.reorder(nil)
end
@@ -68,7 +68,7 @@ class Member < ActiveRecord::Base
scope :request, -> { where.not(requested_at: nil) }
scope :non_request, -> { where(requested_at: nil) }
- scope :has_access, -> { active.where('access_level > 0') }
+ scope :has_access, -> { active.where("access_level > 0") }
scope :guests, -> { active.where(access_level: GUEST) }
scope :reporters, -> { active.where(access_level: REPORTER) }
@@ -77,17 +77,17 @@ class Member < ActiveRecord::Base
scope :masters, -> { maintainers } # @deprecated
scope :owners, -> { active.where(access_level: OWNER) }
scope :owners_and_maintainers, -> { active.where(access_level: [OWNER, MAINTAINER]) }
- scope :owners_and_masters, -> { owners_and_maintainers } # @deprecated
- scope :with_user, -> (user) { where(user: user) }
+ scope :owners_and_masters, -> { owners_and_maintainers } # @deprecated
+ scope :with_user, ->(user) { where(user: user) }
- scope :order_name_asc, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.name', 'ASC')) }
- scope :order_name_desc, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.name', 'DESC')) }
- scope :order_recent_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.last_sign_in_at', 'DESC')) }
- scope :order_oldest_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order('users.last_sign_in_at', 'ASC')) }
+ scope :order_name_asc, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order("users.name", "ASC")) }
+ scope :order_name_desc, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order("users.name", "DESC")) }
+ scope :order_recent_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order("users.last_sign_in_at", "DESC")) }
+ scope :order_oldest_sign_in, -> { left_join_users.reorder(Gitlab::Database.nulls_last_order("users.last_sign_in_at", "ASC")) }
scope :on_project_and_ancestors, ->(project) { where(source: [project] + project.ancestors) }
- before_validation :generate_invite_token, on: :create, if: -> (member) { member.invite_email.present? }
+ before_validation :generate_invite_token, on: :create, if: ->(member) { member.invite_email.present? }
after_create :send_invite, if: :invite?, unless: :importing?
after_create :send_request, if: :request?, unless: :importing?
@@ -107,9 +107,9 @@ class Member < ActiveRecord::Base
def filter_by_2fa(value)
case value
- when 'enabled'
+ when "enabled"
left_join_users.merge(User.with_two_factor)
- when 'disabled'
+ when "disabled"
left_join_users.merge(User.without_two_factor)
else
all
@@ -118,12 +118,12 @@ class Member < ActiveRecord::Base
def sort_by_attribute(method)
case method.to_s
- when 'access_level_asc' then reorder(access_level: :asc)
- when 'access_level_desc' then reorder(access_level: :desc)
- when 'recent_sign_in' then order_recent_sign_in
- when 'oldest_sign_in' then order_oldest_sign_in
- when 'last_joined' then order_created_desc
- when 'oldest_joined' then order_created_asc
+ when "access_level_asc" then reorder(access_level: :asc)
+ when "access_level_desc" then reorder(access_level: :desc)
+ when "recent_sign_in" then order_recent_sign_in
+ when "oldest_sign_in" then order_oldest_sign_in
+ when "last_joined" then order_created_desc
+ when "oldest_joined" then order_created_asc
else
order_by(method)
end
@@ -134,8 +134,8 @@ class Member < ActiveRecord::Base
members = Member.arel_table
member_users = members.join(users, Arel::Nodes::OuterJoin)
- .on(members[:user_id].eq(users[:id]))
- .join_sources
+ .on(members[:user_id].eq(users[:id]))
+ .join_sources
joins(member_users)
end
@@ -190,7 +190,7 @@ class Member < ActiveRecord::Base
member.attributes = {
created_by: member.created_by || current_user,
access_level: access_level,
- expires_at: expires_at
+ expires_at: expires_at,
}
end
@@ -199,7 +199,7 @@ class Member < ActiveRecord::Base
emails, users, existing_members = parse_users_list(source, users)
- self.transaction do
+ transaction do
(emails + users).map! do |user|
add_user(
source,
@@ -285,7 +285,7 @@ class Member < ActiveRecord::Base
end
def invite?
- self.invite_token.present?
+ invite_token.present?
end
def request?
@@ -299,7 +299,7 @@ class Member < ActiveRecord::Base
def accept_request
return false unless request?
- updated = self.update(requested_at: nil)
+ updated = update(requested_at: nil)
after_accept_request if updated
updated
@@ -313,7 +313,7 @@ class Member < ActiveRecord::Base
self.user = new_user
- saved = self.save
+ saved = save
after_accept_invite if saved
@@ -323,7 +323,7 @@ class Member < ActiveRecord::Base
def decline_invite!
return false unless invite?
- destroyed = self.destroy
+ destroyed = destroy
after_decline_invite if destroyed
@@ -447,7 +447,7 @@ class Member < ActiveRecord::Base
def higher_access_level_than_group
if highest_group_member && highest_group_member.access_level >= access_level
- error_parameters = { access: highest_group_member.human_access, group_name: highest_group_member.group.name }
+ error_parameters = {access: highest_group_member.human_access, group_name: highest_group_member.group.name}
errors.add(:access_level, s_("should be higher than %{access} inherited membership from group %{group_name}") % error_parameters)
end
diff --git a/app/models/members/group_member.rb b/app/models/members/group_member.rb
index 2c9e1ba1d80..1bd91baa75f 100644
--- a/app/models/members/group_member.rb
+++ b/app/models/members/group_member.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
class GroupMember < Member
- SOURCE_TYPE = 'Namespace'.freeze
+ SOURCE_TYPE = "Namespace"
- belongs_to :group, foreign_key: 'source_id'
+ belongs_to :group, foreign_key: "source_id"
delegate :update_two_factor_requirement, to: :user
# Make sure group member points only to group as it source
default_value_for :source_type, SOURCE_TYPE
- validates :source_type, format: { with: /\ANamespace\z/ }
+ validates :source_type, format: {with: /\ANamespace\z/}
default_scope { where(source_type: SOURCE_TYPE) }
scope :in_groups, ->(groups) { where(source_id: groups.select(:id)) }
@@ -31,11 +31,11 @@ class GroupMember < Member
# Because source_type is `Namespace`...
def real_source_type
- 'Group'
+ "Group"
end
def notifiable_options
- { group: group }
+ {group: group}
end
private
diff --git a/app/models/members/project_member.rb b/app/models/members/project_member.rb
index 5372c6084f4..cdb7eb8bb53 100644
--- a/app/models/members/project_member.rb
+++ b/app/models/members/project_member.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
class ProjectMember < Member
- SOURCE_TYPE = 'Project'.freeze
+ SOURCE_TYPE = "Project"
- belongs_to :project, foreign_key: 'source_id'
+ belongs_to :project, foreign_key: "source_id"
# Make sure project member points only to project as it source
default_value_for :source_type, SOURCE_TYPE
- validates :source_type, format: { with: /\AProject\z/ }
- validates :access_level, inclusion: { in: Gitlab::Access.values }
+ validates :source_type, format: {with: /\AProject\z/}
+ validates :access_level, inclusion: {in: Gitlab::Access.values}
default_scope { where(source_type: SOURCE_TYPE) }
scope :in_project, ->(project) { where(source_id: project.id) }
scope :in_namespaces, ->(groups) do
- joins('INNER JOIN projects ON projects.id = members.source_id')
- .where('projects.namespace_id in (?)', groups.select(:id))
+ joins("INNER JOIN projects ON projects.id = members.source_id")
+ .where("projects.namespace_id in (?)", groups.select(:id))
end
class << self
@@ -37,7 +37,7 @@ class ProjectMember < Member
# )
#
def add_users_to_projects(project_ids, users, access_level, current_user: nil, expires_at: nil)
- self.transaction do
+ transaction do
project_ids.each do |project_id|
project = Project.find(project_id)
@@ -90,7 +90,7 @@ class ProjectMember < Member
end
def notifiable_options
- { project: project }
+ {project: project}
end
private
@@ -103,7 +103,7 @@ class ProjectMember < Member
def post_create_hook
unless owner?
- event_service.join_project(self.project, self.user)
+ event_service.join_project(project, user)
run_after_commit_or_now { notification_service.new_project_member(self) }
end
@@ -120,9 +120,9 @@ class ProjectMember < Member
def post_destroy_hook
if expired?
- event_service.expired_leave_project(self.project, self.user)
+ event_service.expired_leave_project(project, user)
else
- event_service.leave_project(self.project, self.user)
+ event_service.leave_project(project, user)
end
super
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index 1468ae1c34a..7bdd3c64d29 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -24,8 +24,8 @@ class MergeRequest < ActiveRecord::Base
SORTING_PREFERENCE_FIELD = :merge_requests_sort
ignore_column :locked_at,
- :ref_fetched,
- :deleted_at
+ :ref_fetched,
+ :deleted_at
belongs_to :target_project, class_name: "Project"
belongs_to :source_project, class_name: "Project"
@@ -36,9 +36,9 @@ class MergeRequest < ActiveRecord::Base
has_many :merge_request_diffs
has_one :merge_request_diff,
- -> { order('merge_request_diffs.id DESC') }, inverse_of: :merge_request
+ -> { order("merge_request_diffs.id DESC") }, inverse_of: :merge_request
- belongs_to :latest_merge_request_diff, class_name: 'MergeRequestDiff'
+ belongs_to :latest_merge_request_diff, class_name: "MergeRequestDiff"
manual_inverse_association :latest_merge_request_diff, :merge_request
# This is the same as latest_merge_request_diff unless:
@@ -61,11 +61,11 @@ class MergeRequest < ActiveRecord::Base
has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :merge_requests_closing_issues,
- class_name: 'MergeRequestsClosingIssues',
+ class_name: "MergeRequestsClosingIssues",
dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :cached_closes_issues, through: :merge_requests_closing_issues, source: :issue
- has_many :merge_request_pipelines, foreign_key: 'merge_request_id', class_name: 'Ci::Pipeline'
+ has_many :merge_request_pipelines, foreign_key: "merge_request_id", class_name: "Ci::Pipeline"
belongs_to :assignee, class_name: "User"
@@ -177,7 +177,7 @@ class MergeRequest < ActiveRecord::Base
scope :closed_and_merged, -> { with_states(:closed, :merged) }
scope :from_source_branches, ->(branches) { where(source_branch: branches) }
scope :by_commit_sha, ->(sha) do
- where('EXISTS (?)', MergeRequestDiff.select(1).where('merge_requests.latest_merge_request_diff_id = merge_request_diffs.id').by_commit_sha(sha)).reorder(nil)
+ where("EXISTS (?)", MergeRequestDiff.select(1).where("merge_requests.latest_merge_request_diff_id = merge_request_diffs.id").by_commit_sha(sha)).reorder(nil)
end
scope :join_project, -> { joins(:target_project) }
scope :references_project, -> { references(:target_project) }
@@ -190,7 +190,7 @@ class MergeRequest < ActiveRecord::Base
after_save :keep_around_commit
def self.reference_prefix
- '!'
+ "!"
end
def rebase_in_progress?
@@ -234,7 +234,7 @@ class MergeRequest < ActiveRecord::Base
end
def self.project_foreign_key
- 'target_project_id'
+ "target_project_id"
end
# Returns all the merge requests from an ActiveRecord:Relation.
@@ -267,7 +267,7 @@ class MergeRequest < ActiveRecord::Base
WHERE merge_requests.id = merge_request_diffs.merge_request_id
)'.squish
- self.each_batch do |batch|
+ each_batch do |batch|
batch.update_all(update)
end
end
@@ -291,13 +291,13 @@ class MergeRequest < ActiveRecord::Base
end
def authors
- User.from_union([commit_authors, User.where(id: self.author_id)])
+ User.from_union([commit_authors, User.where(id: author_id)])
end
# Verifies if title has changed not taking into account WIP prefix
# for merge requests.
def wipless_title_changed(old_title)
- self.class.wipless_title(old_title) != self.wipless_title
+ self.class.wipless_title(old_title) != wipless_title
end
def hook_attrs
@@ -307,8 +307,8 @@ class MergeRequest < ActiveRecord::Base
# Returns a Hash of attributes to be used for Twitter card metadata
def card_attributes
{
- 'Author' => author.try(:name),
- 'Assignee' => assignee.try(:name)
+ "Author" => author.try(:name),
+ "Assignee" => assignee.try(:name),
}
end
@@ -340,10 +340,10 @@ class MergeRequest < ActiveRecord::Base
return merge_request_diff.commits if persisted?
commits_arr = if compare_commits
- compare_commits.reverse
- else
- []
- end
+ compare_commits.reverse
+ else
+ []
+ end
CommitCollection.new(source_project, commits_arr, source_branch)
end
@@ -452,12 +452,12 @@ class MergeRequest < ActiveRecord::Base
def modified_paths(past_merge_request_diff: nil)
diffs = if past_merge_request_diff
- past_merge_request_diff
- elsif compare
- compare
- else
- self.merge_request_diff
- end
+ past_merge_request_diff
+ elsif compare
+ compare
+ else
+ merge_request_diff
+ end
diffs.modified_paths
end
@@ -571,9 +571,9 @@ class MergeRequest < ActiveRecord::Base
# most recent data possible.
def repository_diff_refs
Gitlab::Diff::DiffRefs.new(
- base_sha: branch_merge_base_sha,
+ base_sha: branch_merge_base_sha,
start_sha: target_branch_sha,
- head_sha: source_branch_sha
+ head_sha: source_branch_sha
)
end
@@ -610,7 +610,7 @@ class MergeRequest < ActiveRecord::Base
def validate_target_project
return true if target_project.merge_requests_enabled?
- errors.add :base, 'Target project has disabled merge requests'
+ errors.add :base, "Target project has disabled merge requests"
end
def validate_fork
@@ -619,7 +619,7 @@ class MergeRequest < ActiveRecord::Base
return true unless source_project_missing?
errors.add :validate_fork,
- 'Source project is not a fork of the target project'
+ "Source project is not a fork of the target project"
end
def merge_ongoing?
@@ -667,12 +667,12 @@ class MergeRequest < ActiveRecord::Base
matcher =
if diff_refs_or_sha.is_a?(Gitlab::Diff::DiffRefs)
{
- 'start_commit_sha' => diff_refs_or_sha.start_sha,
- 'head_commit_sha' => diff_refs_or_sha.head_sha,
- 'base_commit_sha' => diff_refs_or_sha.base_sha
+ "start_commit_sha" => diff_refs_or_sha.start_sha,
+ "head_commit_sha" => diff_refs_or_sha.head_sha,
+ "base_commit_sha" => diff_refs_or_sha.base_sha,
}
else
- { 'head_commit_sha' => diff_refs_or_sha }
+ {"head_commit_sha" => diff_refs_or_sha}
end
viewable_diffs.find do |diff|
@@ -682,11 +682,11 @@ class MergeRequest < ActiveRecord::Base
def version_params_for(diff_refs)
if diff = merge_request_diff_for(diff_refs)
- { diff_id: diff.id }
+ {diff_id: diff.id}
elsif diff = merge_request_diff_for(diff_refs.head_sha)
{
diff_id: diff.id,
- start_sha: diff_refs.start_sha
+ start_sha: diff_refs.start_sha,
}
end
end
@@ -727,11 +727,11 @@ class MergeRequest < ActiveRecord::Base
end
def merge_event
- @merge_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last
+ @merge_event ||= target_project.events.where(target_id: id, target_type: "MergeRequest", action: Event::MERGED).last
end
def closed_event
- @closed_event ||= target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last
+ @closed_event ||= target_project.events.where(target_id: id, target_type: "MergeRequest", action: Event::CLOSED).last
end
def work_in_progress?
@@ -739,11 +739,11 @@ class MergeRequest < ActiveRecord::Base
end
def wipless_title
- self.class.wipless_title(self.title)
+ self.class.wipless_title(title)
end
def wip_title
- self.class.wip_title(self.title)
+ self.class.wip_title(title)
end
def mergeable?(skip_ci_check: false)
@@ -783,7 +783,7 @@ class MergeRequest < ActiveRecord::Base
end
def can_cancel_merge_when_pipeline_succeeds?(current_user)
- can_be_merged_by?(current_user) || self.author == current_user
+ can_be_merged_by?(current_user) || author == current_user
end
def can_remove_source_branch?(current_user)
@@ -794,11 +794,11 @@ class MergeRequest < ActiveRecord::Base
end
def should_remove_source_branch?
- Gitlab::Utils.to_boolean(merge_params['should_remove_source_branch'])
+ Gitlab::Utils.to_boolean(merge_params["should_remove_source_branch"])
end
def force_remove_source_branch?
- Gitlab::Utils.to_boolean(merge_params['force_remove_source_branch'])
+ Gitlab::Utils.to_boolean(merge_params["force_remove_source_branch"])
end
def remove_source_branch?
@@ -835,7 +835,7 @@ class MergeRequest < ActiveRecord::Base
.includes(:noteable)
end
- alias_method :discussion_notes, :related_notes
+ alias discussion_notes related_notes
def mergeable_discussions_state?
return true unless project.only_allow_merge_if_all_discussions_are_resolved?
@@ -856,24 +856,24 @@ class MergeRequest < ActiveRecord::Base
# Calculating this information for a number of merge requests requires
# running `ReferenceExtractor` on each of them separately.
# This optimization does not apply to issues from external sources.
- def cache_merge_request_closes_issues!(current_user = self.author)
+ def cache_merge_request_closes_issues!(current_user = author)
return unless project.issues_enabled?
return if closed? || merged?
transaction do
- self.merge_requests_closing_issues.delete_all
+ merge_requests_closing_issues.delete_all
closes_issues(current_user).each do |issue|
next if issue.is_a?(ExternalIssue)
- self.merge_requests_closing_issues.create!(issue: issue)
+ merge_requests_closing_issues.create!(issue: issue)
end
end
end
- def visible_closing_issues_for(current_user = self.author)
+ def visible_closing_issues_for(current_user = author)
strong_memoize(:visible_closing_issues_for) do
- if self.target_project.has_external_issue_tracker?
+ if target_project.has_external_issue_tracker?
closes_issues(current_user)
else
cached_closes_issues.select do |issue|
@@ -884,7 +884,7 @@ class MergeRequest < ActiveRecord::Base
end
# Return the set of issues that will be closed if this merge request is accepted.
- def closes_issues(current_user = self.author)
+ def closes_issues(current_user = author)
if target_branch == project.default_branch
messages = [title, description]
messages.concat(commits.map(&:safe_message)) if merge_request_diff
@@ -922,7 +922,7 @@ class MergeRequest < ActiveRecord::Base
end
def source_project_namespace
- if source_project && source_project.namespace
+ if source_project&.namespace
source_project.namespace.full_path
else
"(removed)"
@@ -930,7 +930,7 @@ class MergeRequest < ActiveRecord::Base
end
def target_project_namespace
- if target_project && target_project.namespace
+ if target_project&.namespace
target_project.namespace.full_path
else
"(removed)"
@@ -938,32 +938,32 @@ class MergeRequest < ActiveRecord::Base
end
def source_branch_exists?
- return false unless self.source_project
+ return false unless source_project
- self.source_project.repository.branch_exists?(self.source_branch)
+ source_project.repository.branch_exists?(source_branch)
end
def target_branch_exists?
- return false unless self.target_project
+ return false unless target_project
- self.target_project.repository.branch_exists?(self.target_branch)
+ target_project.repository.branch_exists?(target_branch)
end
def default_merge_commit_message(include_description: false)
- closes_issues_references = visible_closing_issues_for.map do |issue|
+ closes_issues_references = visible_closing_issues_for.map { |issue|
issue.to_reference(target_project)
- end
+ }
message = [
"Merge branch '#{source_branch}' into '#{target_branch}'",
- title
+ title,
]
if !include_description && closes_issues_references.present?
message << "Closes #{closes_issues_references.to_sentence}"
end
- message << "#{description}" if include_description && description.present?
+ message << description.to_s if include_description && description.present?
message << "See merge request #{to_reference(full: true)}"
message.join("\n\n")
@@ -982,12 +982,12 @@ class MergeRequest < ActiveRecord::Base
self.merge_when_pipeline_succeeds = false
self.merge_user = nil
if merge_params
- merge_params.delete('should_remove_source_branch')
- merge_params.delete('commit_message')
- merge_params.delete('squash_commit_message')
+ merge_params.delete("should_remove_source_branch")
+ merge_params.delete("commit_message")
+ merge_params.delete("squash_commit_message")
end
- self.save
+ save
end
# Return array of possible target branches
@@ -1044,7 +1044,7 @@ class MergeRequest < ActiveRecord::Base
def environments_for(current_user)
return [] unless diff_head_commit
- @environments ||= Hash.new do |h, current_user|
+ @environments ||= Hash.new { |h, current_user|
envs = EnvironmentsFinder.new(target_project, current_user,
ref: target_branch, commit: diff_head_commit, with_tags: true).execute
@@ -1054,7 +1054,7 @@ class MergeRequest < ActiveRecord::Base
end
h[current_user] = envs.uniq
- end
+ }
@environments[current_user]
end
@@ -1092,12 +1092,10 @@ class MergeRequest < ActiveRecord::Base
end
def in_locked_state
- begin
- lock_mr
- yield
- ensure
- unlock_mr
- end
+ lock_mr
+ yield
+ ensure
+ unlock_mr
end
def diverged_commits_count
@@ -1107,7 +1105,7 @@ class MergeRequest < ActiveRecord::Base
cache = {
source_sha: source_branch_sha,
target_sha: target_branch_sha,
- diverged_commits_count: compute_diverged_commits_count
+ diverged_commits_count: compute_diverged_commits_count,
}
Rails.cache.write(:"merge_request_#{id}_diverged_commits", cache)
end
@@ -1132,7 +1130,7 @@ class MergeRequest < ActiveRecord::Base
@all_pipelines ||=
source_project.ci_pipelines
- .for_merge_request(self, source_branch, all_commit_shas)
+ .for_merge_request(self, source_branch, all_commit_shas)
end
def update_head_pipeline
@@ -1152,35 +1150,35 @@ class MergeRequest < ActiveRecord::Base
def predefined_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_MERGE_REQUEST_ID', value: id.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_IID', value: iid.to_s)
+ variables.append(key: "CI_MERGE_REQUEST_ID", value: id.to_s)
+ variables.append(key: "CI_MERGE_REQUEST_IID", value: iid.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_REF_PATH',
+ variables.append(key: "CI_MERGE_REQUEST_REF_PATH",
value: ref_path.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_PROJECT_ID',
+ variables.append(key: "CI_MERGE_REQUEST_PROJECT_ID",
value: project.id.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_PROJECT_PATH',
+ variables.append(key: "CI_MERGE_REQUEST_PROJECT_PATH",
value: project.full_path)
- variables.append(key: 'CI_MERGE_REQUEST_PROJECT_URL',
+ variables.append(key: "CI_MERGE_REQUEST_PROJECT_URL",
value: project.web_url)
- variables.append(key: 'CI_MERGE_REQUEST_TARGET_BRANCH_NAME',
+ variables.append(key: "CI_MERGE_REQUEST_TARGET_BRANCH_NAME",
value: target_branch.to_s)
if source_project
- variables.append(key: 'CI_MERGE_REQUEST_SOURCE_PROJECT_ID',
+ variables.append(key: "CI_MERGE_REQUEST_SOURCE_PROJECT_ID",
value: source_project.id.to_s)
- variables.append(key: 'CI_MERGE_REQUEST_SOURCE_PROJECT_PATH',
+ variables.append(key: "CI_MERGE_REQUEST_SOURCE_PROJECT_PATH",
value: source_project.full_path)
- variables.append(key: 'CI_MERGE_REQUEST_SOURCE_PROJECT_URL',
+ variables.append(key: "CI_MERGE_REQUEST_SOURCE_PROJECT_URL",
value: source_project.web_url)
- variables.append(key: 'CI_MERGE_REQUEST_SOURCE_BRANCH_NAME',
+ variables.append(key: "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME",
value: source_branch.to_s)
end
end
@@ -1188,7 +1186,7 @@ class MergeRequest < ActiveRecord::Base
def compare_test_reports
unless has_test_reports?
- return { status: :error, status_reason: 'This merge request does not have test reports' }
+ return {status: :error, status_reason: "This merge request does not have test reports"}
end
compare_reports(Ci::CompareTestReportsService)
@@ -1197,12 +1195,12 @@ class MergeRequest < ActiveRecord::Base
def compare_reports(service_class)
with_reactive_cache(service_class.name) do |data|
unless service_class.new(project)
- .latest?(base_pipeline, actual_head_pipeline, data)
+ .latest?(base_pipeline, actual_head_pipeline, data)
raise InvalidateReactiveCache
end
data
- end || { status: :parsing }
+ end || {status: :parsing}
end
def calculate_reactive_cache(identifier, *args)
@@ -1216,10 +1214,10 @@ class MergeRequest < ActiveRecord::Base
def all_commits
# MySQL doesn't support LIMIT in a subquery.
diffs_relation = if Gitlab::Database.postgresql?
- merge_request_diffs.recent
- else
- merge_request_diffs
- end
+ merge_request_diffs.recent
+ else
+ merge_request_diffs
+ end
MergeRequestDiffCommit
.where(merge_request_diff: diffs_relation)
@@ -1254,7 +1252,7 @@ class MergeRequest < ActiveRecord::Base
# synchronized. Add a minute's leeway to compensate for both possibilities
cutoff = merged_at - 1.minute
- notes_association = notes_with_associations.where('created_at >= ?', cutoff)
+ notes_association = notes_with_associations.where("created_at >= ?", cutoff)
!merge_commit.has_been_reverted?(current_user, notes_association)
end
@@ -1265,7 +1263,7 @@ class MergeRequest < ActiveRecord::Base
metrics&.merged_at ||
merge_event&.created_at ||
- notes.system.reorder(nil).find_by(note: 'merged')&.created_at
+ notes.system.reorder(nil).find_by(note: "merged")&.created_at
end
end
@@ -1274,7 +1272,7 @@ class MergeRequest < ActiveRecord::Base
end
def has_complete_diff_refs?
- diff_refs && diff_refs.complete?
+ diff_refs&.complete?
end
# rubocop: disable CodeReuse/ServiceClass
@@ -1282,15 +1280,15 @@ class MergeRequest < ActiveRecord::Base
return unless has_complete_diff_refs?
return if new_diff_refs == old_diff_refs
- active_diff_discussions = self.notes.new_diff_notes.discussions.select do |discussion|
+ active_diff_discussions = notes.new_diff_notes.discussions.select { |discussion|
discussion.active?(old_diff_refs)
- end
+ }
return if active_diff_discussions.empty?
paths = active_diff_discussions.flat_map { |n| n.diff_file.paths }.uniq
service = Discussions::UpdateDiffPositionService.new(
- self.project,
+ project,
current_user,
old_diff_refs: old_diff_refs,
new_diff_refs: new_diff_refs,
@@ -1310,7 +1308,7 @@ class MergeRequest < ActiveRecord::Base
# rubocop: enable CodeReuse/ServiceClass
def keep_around_commit
- project.repository.keep_around(self.merge_commit_sha)
+ project.repository.keep_around(merge_commit_sha)
end
def has_commits?
@@ -1362,7 +1360,7 @@ class MergeRequest < ActiveRecord::Base
collaborative_push_possible? && allow_maintainer_to_push
end
- alias_method :allow_collaboration?, :allow_collaboration
+ alias allow_collaboration? allow_collaboration
def collaborative_push_possible?
source_project.present? && for_fork? &&
diff --git a/app/models/merge_request/metrics.rb b/app/models/merge_request/metrics.rb
index 65e94a97b0a..14d57a1389b 100644
--- a/app/models/merge_request/metrics.rb
+++ b/app/models/merge_request/metrics.rb
@@ -2,7 +2,7 @@
class MergeRequest::Metrics < ActiveRecord::Base
belongs_to :merge_request
- belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :pipeline_id
- belongs_to :latest_closed_by, class_name: 'User'
- belongs_to :merged_by, class_name: 'User'
+ belongs_to :pipeline, class_name: "Ci::Pipeline", foreign_key: :pipeline_id
+ belongs_to :latest_closed_by, class_name: "User"
+ belongs_to :merged_by, class_name: "User"
end
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index e286a4e57f2..0d0a388bc02 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -42,7 +42,7 @@ class MergeRequestDiff < ActiveRecord::Base
scope :with_files, -> { without_states(:without_files, :empty) }
scope :viewable, -> { without_state(:empty) }
scope :by_commit_sha, ->(sha) do
- joins(:merge_request_diff_commits).where(merge_request_diff_commits: { sha: sha }).reorder(nil)
+ joins(:merge_request_diff_commits).where(merge_request_diff_commits: {sha: sha}).reorder(nil)
end
scope :recent, -> { order(id: :desc).limit(100) }
@@ -67,8 +67,8 @@ class MergeRequestDiff < ActiveRecord::Base
# and save it to the database as serialized data
def save_git_content
MergeRequest
- .where('id = ? AND COALESCE(latest_merge_request_diff_id, 0) < ?', self.merge_request_id, self.id)
- .update_all(latest_merge_request_diff_id: self.id)
+ .where("id = ? AND COALESCE(latest_merge_request_diff_id, 0) < ?", merge_request_id, id)
+ .update_all(latest_merge_request_diff_id: id)
ensure_commit_shas
save_commits
@@ -163,9 +163,9 @@ class MergeRequestDiff < ActiveRecord::Base
return unless start_commit_sha || base_commit_sha
Gitlab::Diff::DiffRefs.new(
- base_sha: base_commit_sha,
+ base_sha: base_commit_sha,
start_sha: start_commit_sha,
- head_sha: head_commit_sha
+ head_sha: head_commit_sha
)
end
@@ -186,9 +186,9 @@ class MergeRequestDiff < ActiveRecord::Base
likely_base_commit_sha = (first_commit&.parent || first_commit)&.sha
Gitlab::Diff::DiffRefs.new(
- base_sha: likely_base_commit_sha,
+ base_sha: likely_base_commit_sha,
start_sha: safe_start_commit_sha,
- head_sha: head_commit_sha
+ head_sha: head_commit_sha
)
end
@@ -229,7 +229,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
def latest?
- self.id == merge_request.latest_merge_request_diff_id
+ id == merge_request.latest_merge_request_diff_id
end
# rubocop: disable CodeReuse/ServiceClass
@@ -249,7 +249,7 @@ class MergeRequestDiff < ActiveRecord::Base
# Carrierwave defines `write_uploader` dynamically on this class, so `super`
# does not work. Alias the carrierwave method so we can call it when needed
- alias_method :carrierwave_write_uploader, :write_uploader
+ alias carrierwave_write_uploader write_uploader
# The `external_diff`, `external_diff_store`, and `stored_externally`
# columns were introduced in GitLab 11.8, but some background migration specs
@@ -274,7 +274,7 @@ class MergeRequestDiff < ActiveRecord::Base
def stored_externally
super if has_attribute?(:stored_externally)
end
- alias_method :stored_externally?, :stored_externally
+ alias stored_externally? stored_externally
# If enabled, yields the external file containing the diff. Otherwise, yields
# nil. This method is not thread-safe, but it *is* re-entrant, which allows
@@ -284,13 +284,11 @@ class MergeRequestDiff < ActiveRecord::Base
return yield(@external_diff_file) if @external_diff_file
external_diff.open do |file|
- begin
- @external_diff_file = file
+ @external_diff_file = file
- yield(@external_diff_file)
- ensure
- @external_diff_file = nil
- end
+ yield(@external_diff_file)
+ ensure
+ @external_diff_file = nil
end
end
@@ -305,7 +303,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
# Faster inserts
- Gitlab::Database.bulk_insert('merge_request_diff_files', rows)
+ Gitlab::Database.bulk_insert("merge_request_diff_files", rows)
end
def build_external_merge_request_diff_files(diffs)
@@ -340,7 +338,7 @@ class MergeRequestDiff < ActiveRecord::Base
diffs.map.with_index do |diff, index|
diff_hash = diff.to_hash.merge(
binary: false,
- merge_request_diff_id: self.id,
+ merge_request_diff_id: id,
relative_order: index
)
@@ -350,7 +348,7 @@ class MergeRequestDiff < ActiveRecord::Base
if diff_text.encoding == Encoding::BINARY && !diff_text.ascii_only?
hash[:binary] = true
- hash[:diff] = [diff_text].pack('m0')
+ hash[:diff] = [diff_text].pack("m0")
end
end
end
@@ -363,7 +361,7 @@ class MergeRequestDiff < ActiveRecord::Base
collection = merge_request_diff_files
if paths = options[:paths]
- collection = collection.where('old_path IN (?) OR new_path IN (?)', paths, paths)
+ collection = collection.where("old_path IN (?) OR new_path IN (?)", paths, paths)
end
Gitlab::Git::DiffCollection.new(collection.map(&:to_hash), options)
@@ -404,7 +402,7 @@ class MergeRequestDiff < ActiveRecord::Base
end
def save_commits
- MergeRequestDiffCommit.create_bulk(self.id, compare.commits.reverse)
+ MergeRequestDiffCommit.create_bulk(id, compare.commits.reverse)
# merge_request_diff_commits.reload is preferred way to reload associated
# objects but it returns cached result for some reason in this case
diff --git a/app/models/merge_request_diff_commit.rb b/app/models/merge_request_diff_commit.rb
index 4ad3690512d..e9e01a20aa8 100644
--- a/app/models/merge_request_diff_commit.rb
+++ b/app/models/merge_request_diff_commit.rb
@@ -11,7 +11,7 @@ class MergeRequestDiffCommit < ActiveRecord::Base
def self.create_bulk(merge_request_diff_id, commits)
sha_attribute = Gitlab::Database::ShaAttribute.new
- rows = commits.map.with_index do |commit, index|
+ rows = commits.map.with_index { |commit, index|
# See #parent_ids.
commit_hash = commit.to_hash.except(:parent_ids)
sha = commit_hash.delete(:id)
@@ -23,9 +23,9 @@ class MergeRequestDiffCommit < ActiveRecord::Base
authored_date: Gitlab::Database.sanitize_timestamp(commit_hash[:authored_date]),
committed_date: Gitlab::Database.sanitize_timestamp(commit_hash[:committed_date])
)
- end
+ }
- Gitlab::Database.bulk_insert(self.table_name, rows)
+ Gitlab::Database.bulk_insert(table_name, rows)
end
def to_hash
diff --git a/app/models/merge_request_diff_file.rb b/app/models/merge_request_diff_file.rb
index e8d936e265c..0ee789e609a 100644
--- a/app/models/merge_request_diff_file.rb
+++ b/app/models/merge_request_diff_file.rb
@@ -7,7 +7,7 @@ class MergeRequestDiffFile < ActiveRecord::Base
belongs_to :merge_request_diff, inverse_of: :merge_request_diff_files
def utf8_diff
- return '' if diff.blank?
+ return "" if diff.blank?
encode_utf8(diff) if diff.respond_to?(:encoding)
end
@@ -23,6 +23,6 @@ class MergeRequestDiffFile < ActiveRecord::Base
super
end
- binary? ? content.unpack('m0').first : content
+ binary? ? content.unpack1("m0") : content
end
end
diff --git a/app/models/merge_requests_closing_issues.rb b/app/models/merge_requests_closing_issues.rb
index 242b65bedc0..80e0af9cd11 100644
--- a/app/models/merge_requests_closing_issues.rb
+++ b/app/models/merge_requests_closing_issues.rb
@@ -4,14 +4,14 @@ class MergeRequestsClosingIssues < ActiveRecord::Base
belongs_to :merge_request
belongs_to :issue
- validates :merge_request_id, uniqueness: { scope: :issue_id }, presence: true
+ validates :merge_request_id, uniqueness: {scope: :issue_id}, presence: true
validates :issue_id, presence: true
class << self
def count_for_collection(ids)
group(:issue_id)
.where(issue_id: ids)
- .pluck('issue_id', 'COUNT(*) as count')
+ .pluck("issue_id", "COUNT(*) as count")
end
end
end
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index 26cfdc5ef30..c72c6d58135 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -4,10 +4,10 @@ class Milestone < ActiveRecord::Base
# Represents a "No Milestone" state used for filtering Issues and Merge
# Requests that have no milestone assigned.
MilestoneStruct = Struct.new(:title, :name, :id)
- None = MilestoneStruct.new('No Milestone', 'No Milestone', 0)
- Any = MilestoneStruct.new('Any Milestone', '', -1)
- Upcoming = MilestoneStruct.new('Upcoming', '#upcoming', -2)
- Started = MilestoneStruct.new('Started', '#started', -3)
+ None = MilestoneStruct.new("No Milestone", "No Milestone", 0)
+ Any = MilestoneStruct.new("Any Milestone", "", -1)
+ Upcoming = MilestoneStruct.new("Upcoming", "#upcoming", -2)
+ Started = MilestoneStruct.new("Started", "#started", -3)
include CacheMarkdownField
include AtomicInternalId
@@ -28,7 +28,7 @@ class Milestone < ActiveRecord::Base
has_internal_id :iid, scope: :group, init: ->(s) { s&.group&.milestones&.maximum(:iid) }
has_many :issues
- has_many :labels, -> { distinct.reorder('labels.title') }, through: :issues
+ has_many :labels, -> { distinct.reorder("labels.title") }, through: :issues
has_many :merge_requests
has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -38,7 +38,7 @@ class Milestone < ActiveRecord::Base
scope :closed, -> { with_state(:closed) }
scope :for_projects, -> { where(group: nil).includes(:project) }
- scope :for_projects_and_groups, -> (projects, groups) do
+ scope :for_projects_and_groups, ->(projects, groups) do
projects = projects.compact if projects.is_a? Array
projects = [] if projects.nil?
@@ -49,7 +49,7 @@ class Milestone < ActiveRecord::Base
end
scope :order_by_name_asc, -> { order(Arel::Nodes::Ascending.new(arel_table[:title].lower)) }
- scope :reorder_by_due_date_asc, -> { reorder(Gitlab::Database.nulls_last_order('due_date', 'ASC')) }
+ scope :reorder_by_due_date_asc, -> { reorder(Gitlab::Database.nulls_last_order("due_date", "ASC")) }
validates :group, presence: true, unless: :project
validates :project, presence: true, unless: :group
@@ -101,8 +101,8 @@ class Milestone < ActiveRecord::Base
def filter_by_state(milestones, state)
case state
- when 'closed' then milestones.closed
- when 'all' then milestones
+ when "closed" then milestones.closed
+ when "all" then milestones
else milestones.active
end
end
@@ -120,7 +120,7 @@ class Milestone < ActiveRecord::Base
end
def self.reference_prefix
- '%'
+ "%"
end
def self.reference_pattern
@@ -148,11 +148,11 @@ class Milestone < ActiveRecord::Base
def self.upcoming_ids(projects, groups)
rel = unscoped
- .for_projects_and_groups(projects, groups)
- .active.where('milestones.due_date > NOW()')
+ .for_projects_and_groups(projects, groups)
+ .active.where("milestones.due_date > NOW()")
if Gitlab::Database.postgresql?
- rel.order(:project_id, :group_id, :due_date).select('DISTINCT ON (project_id, group_id) id')
+ rel.order(:project_id, :group_id, :due_date).select("DISTINCT ON (project_id, group_id) id")
else
# We need to use MySQL's NULL-safe comparison operator `<=>` here
# because one of `project_id` or `group_id` is always NULL
@@ -167,7 +167,7 @@ class Milestone < ActiveRecord::Base
rel
.joins(join_clause)
- .where('earlier_milestones.id IS NULL')
+ .where("earlier_milestones.id IS NULL")
.select(:id)
end
end
@@ -179,18 +179,18 @@ class Milestone < ActiveRecord::Base
def self.sort_by_attribute(method)
sorted =
case method.to_s
- when 'due_date_asc'
+ when "due_date_asc"
reorder_by_due_date_asc
- when 'due_date_desc'
- reorder(Gitlab::Database.nulls_last_order('due_date', 'DESC'))
- when 'name_asc'
+ when "due_date_desc"
+ reorder(Gitlab::Database.nulls_last_order("due_date", "DESC"))
+ when "name_asc"
reorder(Arel::Nodes::Ascending.new(arel_table[:title].lower))
- when 'name_desc'
+ when "name_desc"
reorder(Arel::Nodes::Descending.new(arel_table[:title].lower))
- when 'start_date_asc'
- reorder(Gitlab::Database.nulls_last_order('start_date', 'ASC'))
- when 'start_date_desc'
- reorder(Gitlab::Database.nulls_last_order('start_date', 'DESC'))
+ when "start_date_asc"
+ reorder(Gitlab::Database.nulls_last_order("start_date", "ASC"))
+ when "start_date_desc"
+ reorder(Gitlab::Database.nulls_last_order("start_date", "DESC"))
else
order_by(method)
end
@@ -202,15 +202,15 @@ class Milestone < ActiveRecord::Base
return STATE_COUNT_HASH unless projects || groups
counts = Milestone
- .for_projects_and_groups(projects, groups)
- .reorder(nil)
- .group(:state)
- .count
+ .for_projects_and_groups(projects, groups)
+ .reorder(nil)
+ .group(:state)
+ .count
{
- opened: counts['active'] || 0,
- closed: counts['closed'] || 0,
- all: counts.values.sum
+ opened: counts["active"] || 0,
+ closed: counts["closed"] || 0,
+ all: counts.values.sum,
}
end
@@ -240,7 +240,7 @@ class Milestone < ActiveRecord::Base
end
def reference_link_text(from = nil)
- self.class.reference_prefix + self.title
+ self.class.reference_prefix + title
end
def milestoneish_id
@@ -302,10 +302,10 @@ class Milestone < ActiveRecord::Base
end
def milestone_format_reference(format = :iid)
- raise ArgumentError, 'Unknown format' unless [:iid, :name].include?(format)
+ raise ArgumentError, "Unknown format" unless [:iid, :name].include?(format)
if group_milestone? && format == :iid
- raise ArgumentError, 'Cannot refer to a group milestone by an internal id!'
+ raise ArgumentError, "Cannot refer to a group milestone by an internal id!"
end
if format == :name && !name.include?('"')
@@ -326,6 +326,6 @@ class Milestone < ActiveRecord::Base
end
def issues_finder_params
- { project_id: project_id }
+ {project_id: project_id}
end
end
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index f7592532c5b..6e173e2549b 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -24,8 +24,8 @@ class Namespace < ApplicationRecord
has_many :projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :project_statistics
- has_many :runner_namespaces, inverse_of: :namespace, class_name: 'Ci::RunnerNamespace'
- has_many :runners, through: :runner_namespaces, source: :runner, class_name: 'Ci::Runner'
+ has_many :runner_namespaces, inverse_of: :namespace, class_name: "Ci::RunnerNamespace"
+ has_many :runners, through: :runner_namespaces, source: :runner, class_name: "Ci::Runner"
# This should _not_ be `inverse_of: :namespace`, because that would also set
# `user.namespace` when this user creates a group with themselves as `owner`.
@@ -38,20 +38,20 @@ class Namespace < ApplicationRecord
validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :name,
presence: true,
- length: { maximum: 255 },
+ length: {maximum: 255},
namespace_name: true
- validates :description, length: { maximum: 255 }
+ validates :description, length: {maximum: 255}
validates :path,
presence: true,
- length: { maximum: 255 },
+ length: {maximum: 255},
namespace_path: true
validate :nesting_level_allowed
delegate :name, to: :owner, allow_nil: true, prefix: true
- after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?('share_with_group_lock') }
+ after_commit :refresh_access_of_projects_invited_groups, on: :update, if: -> { previous_changes.key?("share_with_group_lock") }
before_create :sync_share_with_group_lock_with_parent
before_update :sync_share_with_group_lock_with_parent, if: :parent_changed?
@@ -63,23 +63,23 @@ class Namespace < ApplicationRecord
before_destroy(prepend: true) { prepare_for_destroy }
after_destroy :rm_dir
- scope :for_user, -> { where('type IS NULL') }
+ scope :for_user, -> { where("type IS NULL") }
scope :with_statistics, -> do
- joins('LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id')
- .group('namespaces.id')
+ joins("LEFT JOIN project_statistics ps ON ps.namespace_id = namespaces.id")
+ .group("namespaces.id")
.select(
- 'namespaces.*',
- 'COALESCE(SUM(ps.storage_size), 0) AS storage_size',
- 'COALESCE(SUM(ps.repository_size), 0) AS repository_size',
- 'COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size',
- 'COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size'
+ "namespaces.*",
+ "COALESCE(SUM(ps.storage_size), 0) AS storage_size",
+ "COALESCE(SUM(ps.repository_size), 0) AS repository_size",
+ "COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size",
+ "COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size"
)
end
class << self
def by_path(path)
- find_by('lower(path) = :value', value: path.downcase)
+ find_by("lower(path) = :value", value: path.downcase)
end
# Case insensitive search for namespace by path or name
@@ -145,18 +145,18 @@ class Namespace < ApplicationRecord
end
def kind
- type == 'Group' ? 'group' : 'user'
+ type == "Group" ? "group" : "user"
end
def find_fork_of(project)
return nil unless project.fork_network
if Gitlab::SafeRequestStore.active?
- forks_in_namespace = Gitlab::SafeRequestStore.fetch("namespaces:#{id}:forked_projects") do
+ forks_in_namespace = Gitlab::SafeRequestStore.fetch("namespaces:#{id}:forked_projects") {
Hash.new do |found_forks, project|
found_forks[project] = project.fork_network.find_forks_in(projects).first
end
- end
+ }
forks_in_namespace[project]
else
@@ -259,7 +259,7 @@ class Namespace < ApplicationRecord
path_was
else
previous_parent = Group.find_by(id: parent_id_was)
- previous_parent.full_path + '/' + path_was
+ previous_parent.full_path + "/" + path_was
end
end
@@ -276,7 +276,7 @@ class Namespace < ApplicationRecord
def refresh_access_of_projects_invited_groups
Group
.joins(project_group_links: :project)
- .where(projects: { namespace_id: id })
+ .where(projects: {namespace_id: id})
.find_each(&:refresh_members_authorized_projects)
end
diff --git a/app/models/network/graph.rb b/app/models/network/graph.rb
index ecbeb24ee0a..d696eef1244 100644
--- a/app/models/network/graph.rb
+++ b/app/models/network/graph.rb
@@ -27,9 +27,9 @@ module Network
@project
.notes
- .where('noteable_type = ?', 'Commit')
- .group('notes.commit_id')
- .select('notes.commit_id, count(notes.id) as note_count')
+ .where("noteable_type = ?", "Commit")
+ .group("notes.commit_id")
+ .select("notes.commit_id, count(notes.id) as note_count")
.each do |item|
h[item.commit_id] = item.note_count.to_i
end
@@ -85,9 +85,9 @@ module Network
while offset == -1
tmp_commits = find_commits(skip)
if tmp_commits.present?
- index = tmp_commits.index do |c|
+ index = tmp_commits.index { |c|
c.id == @commit.id
- end
+ }
if index
# Find the target commit
@@ -113,7 +113,7 @@ module Network
opts = {
max_count: self.class.max_count,
skip: skip,
- order: :date
+ order: :date,
}
opts[:ref] = @commit.id if @filter_ref
@@ -144,10 +144,10 @@ module Network
range = commit.time..parent.time
space = if commit.space >= parent.space
- find_free_parent_space(range, parent.space, -1, commit.space)
- else
- find_free_parent_space(range, commit.space, -1, parent.space)
- end
+ find_free_parent_space(range, parent.space, -1, commit.space)
+ else
+ find_free_parent_space(range, commit.space, -1, parent.space)
+ end
mark_reserved(range, space)
spaces << space
diff --git a/app/models/note.rb b/app/models/note.rb
index 1578ae9c4cc..e8e3a106f1d 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -25,7 +25,7 @@ class Note < ActiveRecord::Base
class << self
def values
- constants.map {|const| self.const_get(const)}
+ constants.map {|const| const_get(const)}
end
end
end
@@ -66,7 +66,7 @@ class Note < ActiveRecord::Base
belongs_to :noteable, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :author, class_name: "User"
belongs_to :updated_by, class_name: "User"
- belongs_to :last_edited_by, class_name: 'User'
+ belongs_to :last_edited_by, class_name: "User"
has_many :todos
@@ -88,17 +88,17 @@ class Note < ActiveRecord::Base
validates :project, presence: true, if: :for_project_noteable?
# Attachments are deprecated and are handled by Markdown uploader
- validates :attachment, file_size: { maximum: :max_attachment_size }
+ validates :attachment, file_size: {maximum: :max_attachment_size}
validates :noteable_type, presence: true
validates :noteable_id, presence: true, unless: [:for_commit?, :importing?]
validates :commit_id, presence: true, if: :for_commit?
validates :author, presence: true
- validates :discussion_id, presence: true, format: { with: /\A\h{40}\z/ }
+ validates :discussion_id, presence: true, format: {with: /\A\h{40}\z/}
validate unless: [:for_commit?, :importing?, :skip_project_check?] do |note|
unless note.noteable.try(:project) == note.project
- errors.add(:project, 'does not match noteable project')
+ errors.add(:project, "does not match noteable project")
end
end
@@ -111,15 +111,15 @@ class Note < ActiveRecord::Base
scope :user, -> { where(system: false) }
scope :common, -> { where(noteable_type: ["", nil]) }
scope :fresh, -> { order(created_at: :asc, id: :asc) }
- scope :updated_after, ->(time) { where('updated_at > ?', time) }
+ scope :updated_after, ->(time) { where("updated_at > ?", time) }
scope :inc_author_project, -> { includes(:project, :author) }
scope :inc_author, -> { includes(:author) }
scope :inc_relations_for_view, -> do
- includes(:project, { author: :status }, :updated_by, :resolved_by, :award_emoji,
- :system_note_metadata, :note_diff_file, :suggestions)
+ includes(:project, {author: :status}, :updated_by, :resolved_by, :award_emoji,
+ :system_note_metadata, :note_diff_file, :suggestions)
end
- scope :with_notes_filter, -> (notes_filter) do
+ scope :with_notes_filter, ->(notes_filter) do
case notes_filter
when UserPreference::NOTES_FILTERS[:only_comments]
user
@@ -130,14 +130,14 @@ class Note < ActiveRecord::Base
end
end
- scope :diff_notes, -> { where(type: %w(LegacyDiffNote DiffNote)) }
- scope :new_diff_notes, -> { where(type: 'DiffNote') }
- scope :non_diff_notes, -> { where(type: ['Note', 'DiscussionNote', nil]) }
+ scope :diff_notes, -> { where(type: %w[LegacyDiffNote DiffNote]) }
+ scope :new_diff_notes, -> { where(type: "DiffNote") }
+ scope :non_diff_notes, -> { where(type: ["Note", "DiscussionNote", nil]) }
scope :with_associations, -> do
# FYI noteable cannot be loaded for LegacyDiffNote for commits
includes(:author, :noteable, :updated_by,
- project: [:project_members, :namespace, { group: [:group_members] }])
+ project: [:project_members, :namespace, {group: [:group_members]}])
end
scope :with_metadata, -> { includes(:system_note_metadata) }
@@ -151,7 +151,7 @@ class Note < ActiveRecord::Base
class << self
def model_name
- ActiveModel::Name.new(self, nil, 'note')
+ ActiveModel::Name.new(self, nil, "note")
end
def discussions(context_noteable = nil)
@@ -190,7 +190,7 @@ class Note < ActiveRecord::Base
end
def count_for_collection(ids, type)
- user.select('noteable_id', 'COUNT(*) as count')
+ user.select("noteable_id", "COUNT(*) as count")
.group(:noteable_id)
.where(noteable_type: type, noteable_id: ids)
end
@@ -290,7 +290,7 @@ class Note < ActiveRecord::Base
end
def special_role=(role)
- raise "Role is undefined, #{role} not found in #{SpecialRole.values}" unless SpecialRole.values.include?(role)
+ raise "Role is undefined, #{role} not found in #{SpecialRole.values}" unless SpecialRole.value?(role)
@special_role = role
end
@@ -300,7 +300,7 @@ class Note < ActiveRecord::Base
end
def specialize_for_first_contribution!(noteable)
- return unless noteable.author_id == self.author_id
+ return unless noteable.author_id == author_id
self.special_role = Note::SpecialRole::FIRST_TIME_CONTRIBUTOR
end
@@ -338,7 +338,7 @@ class Note < ActiveRecord::Base
end
def can_be_discussion_note?
- self.noteable.supports_discussions? && !part_of_discussion?
+ noteable.supports_discussions? && !part_of_discussion?
end
def can_create_todo?
@@ -374,7 +374,7 @@ class Note < ActiveRecord::Base
# Consider using `#to_discussion` if we do not need to render the discussion
# and all its notes and if we don't care about the discussion's resolvability status.
def discussion
- full_discussion = self.noteable.notes.find_discussion(self.discussion_id) if part_of_discussion?
+ full_discussion = noteable.notes.find_discussion(discussion_id) if part_of_discussion?
full_discussion || to_discussion
end
@@ -391,9 +391,9 @@ class Note < ActiveRecord::Base
in_reply_to?(other.noteable)
end
when Discussion
- self.discussion_id == other.id
+ discussion_id == other.id
when Noteable
- self.noteable == other
+ noteable == other
else
false
end
@@ -463,25 +463,25 @@ class Note < ActiveRecord::Base
private
def keep_around_commit
- project.repository.keep_around(self.commit_id)
+ project.repository.keep_around(commit_id)
end
def nullify_blank_type
- self.type = nil if self.type.blank?
+ self.type = nil if type.blank?
end
def nullify_blank_line_code
- self.line_code = nil if self.line_code.blank?
+ self.line_code = nil if line_code.blank?
end
def ensure_discussion_id
- return unless self.persisted?
+ return unless persisted?
# Needed in case the SELECT statement doesn't ask for `discussion_id`
- return unless self.has_attribute?(:discussion_id)
- return if self.discussion_id
+ return unless has_attribute?(:discussion_id)
+ return if discussion_id
set_discussion_id
- update_column(:discussion_id, self.discussion_id)
+ update_column(:discussion_id, discussion_id)
end
def set_discussion_id
diff --git a/app/models/note_diff_file.rb b/app/models/note_diff_file.rb
index e369122003e..22a70154c97 100644
--- a/app/models/note_diff_file.rb
+++ b/app/models/note_diff_file.rb
@@ -17,8 +17,8 @@ class NoteDiffFile < ActiveRecord::Base
raw_diff = Gitlab::Git::Diff.new(to_hash)
Gitlab::Diff::File.new(raw_diff,
- repository: project.repository,
- diff_refs: original_position.diff_refs,
- unique_identifier: id)
+ repository: project.repository,
+ diff_refs: original_position.diff_refs,
+ unique_identifier: id)
end
end
diff --git a/app/models/notification_reason.rb b/app/models/notification_reason.rb
index 0a13487574f..88cd0134e57 100644
--- a/app/models/notification_reason.rb
+++ b/app/models/notification_reason.rb
@@ -3,15 +3,15 @@
# Holds reasons for a notification to have been sent as well as a priority list to select which reason to use
# above the rest
class NotificationReason
- OWN_ACTIVITY = 'own_activity'.freeze
- ASSIGNED = 'assigned'.freeze
- MENTIONED = 'mentioned'.freeze
+ OWN_ACTIVITY = "own_activity"
+ ASSIGNED = "assigned"
+ MENTIONED = "mentioned"
# Priority list for selecting which reason to return in the notification
REASON_PRIORITY = [
OWN_ACTIVITY,
ASSIGNED,
- MENTIONED
+ MENTIONED,
].freeze
# returns the priority of a reason as an integer
diff --git a/app/models/notification_recipient.rb b/app/models/notification_recipient.rb
index 481c1d963c6..d9657e24a57 100644
--- a/app/models/notification_recipient.rb
+++ b/app/models/notification_recipient.rb
@@ -130,8 +130,6 @@ class NotificationRecipient
:read_build # We have build trace in pipeline emails
when ActiveRecord::Base
:"read_#{@target.class.model_name.name.underscore}"
- else
- nil
end
end
diff --git a/app/models/notification_setting.rb b/app/models/notification_setting.rb
index e82eaf4e069..8db7519f342 100644
--- a/app/models/notification_setting.rb
+++ b/app/models/notification_setting.rb
@@ -5,27 +5,27 @@ class NotificationSetting < ActiveRecord::Base
ignore_column :events
- enum level: { global: 3, watch: 2, participating: 1, mention: 4, disabled: 0, custom: 5 }
+ enum level: {global: 3, watch: 2, participating: 1, mention: 4, disabled: 0, custom: 5}
default_value_for :level, NotificationSetting.levels[:global]
belongs_to :user
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
- belongs_to :project, foreign_key: 'source_id'
+ belongs_to :project, foreign_key: "source_id"
validates :user, presence: true
validates :level, presence: true
- validates :user_id, uniqueness: { scope: [:source_type, :source_id],
- message: "already exists in source",
- allow_nil: true }
+ validates :user_id, uniqueness: {scope: [:source_type, :source_id],
+ message: "already exists in source",
+ allow_nil: true,}
- scope :for_groups, -> { where(source_type: 'Namespace') }
+ scope :for_groups, -> { where(source_type: "Namespace") }
# Exclude projects not included by the Project model's default scope (those that are
# pending delete).
#
scope :for_projects, -> do
- includes(:project).references(:projects).where(source_type: 'Project').where.not(projects: { id: nil, pending_delete: true })
+ includes(:project).references(:projects).where(source_type: "Project").where.not(projects: {id: nil, pending_delete: true})
end
EMAIL_EVENTS = [
@@ -42,7 +42,7 @@ class NotificationSetting < ActiveRecord::Base
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
- :success_pipeline
+ :success_pipeline,
].freeze
# Update unfound_translations.rb when events are changed
@@ -55,12 +55,12 @@ class NotificationSetting < ActiveRecord::Base
end
EXCLUDED_PARTICIPATING_EVENTS = [
- :success_pipeline
+ :success_pipeline,
].freeze
EXCLUDED_WATCHER_EVENTS = [
:push_to_merge_request,
- :issue_due
+ :issue_due,
].push(*EXCLUDED_PARTICIPATING_EVENTS).freeze
def self.find_or_create_for(source)
@@ -81,7 +81,7 @@ class NotificationSetting < ActiveRecord::Base
bool.nil? || bool
end
- alias_method :failed_pipeline?, :failed_pipeline
+ alias failed_pipeline? failed_pipeline
def event_enabled?(event)
respond_to?(event) && !!public_send(event) # rubocop:disable GitlabSecurity/PublicSend
diff --git a/app/models/oauth_access_grant.rb b/app/models/oauth_access_grant.rb
index d5a8a1a25b6..cb43a41e7dc 100644
--- a/app/models/oauth_access_grant.rb
+++ b/app/models/oauth_access_grant.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class OauthAccessGrant < Doorkeeper::AccessGrant
- belongs_to :resource_owner, class_name: 'User'
- belongs_to :application, class_name: 'Doorkeeper::Application'
+ belongs_to :resource_owner, class_name: "User"
+ belongs_to :application, class_name: "Doorkeeper::Application"
end
diff --git a/app/models/oauth_access_token.rb b/app/models/oauth_access_token.rb
index 0aa920fa828..7ce5ddac096 100644
--- a/app/models/oauth_access_token.rb
+++ b/app/models/oauth_access_token.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
class OauthAccessToken < Doorkeeper::AccessToken
- belongs_to :resource_owner, class_name: 'User'
- belongs_to :application, class_name: 'Doorkeeper::Application'
+ belongs_to :resource_owner, class_name: "User"
+ belongs_to :application, class_name: "Doorkeeper::Application"
alias_attribute :user, :resource_owner
diff --git a/app/models/pages_domain.rb b/app/models/pages_domain.rb
index 7a33ade826b..0f24e0a9fda 100644
--- a/app/models/pages_domain.rb
+++ b/app/models/pages_domain.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
class PagesDomain < ActiveRecord::Base
- VERIFICATION_KEY = 'gitlab-pages-verification-code'.freeze
+ VERIFICATION_KEY = "gitlab-pages-verification-code"
VERIFICATION_THRESHOLD = 3.days.freeze
belongs_to :project
- validates :domain, hostname: { allow_numeric_hostname: true }
- validates :domain, uniqueness: { case_sensitive: false }
- validates :certificate, presence: { message: 'must be present if HTTPS-only is enabled' }, if: ->(domain) { domain.project&.pages_https_only? }
+ validates :domain, hostname: {allow_numeric_hostname: true}
+ validates :domain, uniqueness: {case_sensitive: false}
+ validates :certificate, presence: {message: "must be present if HTTPS-only is enabled"}, if: ->(domain) { domain.project&.pages_https_only? }
validates :certificate, certificate: true, if: ->(domain) { domain.certificate.present? }
- validates :key, presence: { message: 'must be present if HTTPS-only is enabled' }, if: ->(domain) { domain.project&.pages_https_only? }
+ validates :key, presence: {message: "must be present if HTTPS-only is enabled"}, if: ->(domain) { domain.project&.pages_https_only? }
validates :key, certificate_key: true, if: ->(domain) { domain.key.present? }
validates :verification_code, presence: true, allow_blank: false
@@ -22,14 +22,14 @@ class PagesDomain < ActiveRecord::Base
mode: :per_attribute_iv_and_salt,
insecure_mode: true,
key: Settings.attr_encrypted_db_key_base,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
after_initialize :set_verification_code
after_create :update_daemon
after_update :update_daemon, if: :pages_config_changed?
after_destroy :update_daemon
- scope :enabled, -> { where('enabled_until >= ?', Time.now ) }
+ scope :enabled, -> { where("enabled_until >= ?", Time.now) }
scope :needs_verification, -> do
verified_at = arel_table[:verified_at]
enabled_until = arel_table[:enabled_until]
@@ -86,7 +86,7 @@ class PagesDomain < ActiveRecord::Base
store.set_default_paths
# This forces to load all intermediate certificates stored in `certificate`
- Tempfile.open('certificate_chain') do |f|
+ Tempfile.open("certificate_chain") do |f|
f.write(certificate)
f.flush
store.add_file(f.path)
@@ -135,7 +135,7 @@ class PagesDomain < ActiveRecord::Base
private
def set_verification_code
- return if self.verification_code.present?
+ return if verification_code.present?
self.verification_code = SecureRandom.hex(16)
end
@@ -165,13 +165,13 @@ class PagesDomain < ActiveRecord::Base
def validate_matching_key
unless has_matching_key?
- self.errors.add(:key, "doesn't match the certificate")
+ errors.add(:key, "doesn't match the certificate")
end
end
def validate_intermediates
unless has_intermediates?
- self.errors.add(:certificate, 'misses intermediates')
+ errors.add(:certificate, "misses intermediates")
end
end
@@ -179,7 +179,7 @@ class PagesDomain < ActiveRecord::Base
return unless domain
if domain.downcase.ends_with?(Settings.pages.host.downcase)
- self.errors.add(:domain, "*.#{Settings.pages.host} is restricted")
+ errors.add(:domain, "*.#{Settings.pages.host} is restricted")
end
end
diff --git a/app/models/personal_access_token.rb b/app/models/personal_access_token.rb
index ed78a46eaf3..552e741639c 100644
--- a/app/models/personal_access_token.rb
+++ b/app/models/personal_access_token.rb
@@ -64,7 +64,7 @@ class PersonalAccessToken < ActiveRecord::Base
end
def set_default_scopes
- self.scopes = Gitlab::Auth::DEFAULT_SCOPES if self.scopes.empty?
+ self.scopes = Gitlab::Auth::DEFAULT_SCOPES if scopes.empty?
end
def self.redis_shared_state_key(user_id)
diff --git a/app/models/pool_repository.rb b/app/models/pool_repository.rb
index 4635fc72dc7..5d52d4b60bc 100644
--- a/app/models/pool_repository.rb
+++ b/app/models/pool_repository.rb
@@ -7,10 +7,10 @@ class PoolRepository < ActiveRecord::Base
include Shardable
include AfterCommitQueue
- has_one :source_project, class_name: 'Project'
+ has_one :source_project, class_name: "Project"
validates :source_project, presence: true
- has_many :member_projects, class_name: 'Project'
+ has_many :member_projects, class_name: "Project"
after_create :correct_disk_path
@@ -95,7 +95,7 @@ class PoolRepository < ActiveRecord::Base
def object_pool
@object_pool ||= Gitlab::Git::ObjectPool.new(
shard.name,
- disk_path + '.git',
+ disk_path + ".git",
source_project.repository.raw,
source_project.full_path
)
diff --git a/app/models/postgresql/replication_slot.rb b/app/models/postgresql/replication_slot.rb
index e264fe88e47..6a7503ce798 100644
--- a/app/models/postgresql/replication_slot.rb
+++ b/app/models/postgresql/replication_slot.rb
@@ -2,7 +2,7 @@
module Postgresql
class ReplicationSlot < ActiveRecord::Base
- self.table_name = 'pg_replication_slots'
+ self.table_name = "pg_replication_slots"
# Returns true if there are any replication slots in use.
# PostgreSQL-compatible databases such as Aurora don't support
diff --git a/app/models/project.rb b/app/models/project.rb
index 47baf899222..49118e877e1 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'carrierwave/orm/activerecord'
+require "carrierwave/orm/activerecord"
class Project < ActiveRecord::Base
include Gitlab::ConfigHelper
@@ -37,9 +37,9 @@ class Project < ActiveRecord::Base
BoardLimitExceeded = Class.new(StandardError)
- STATISTICS_ATTRIBUTE = 'repositories_count'.freeze
+ STATISTICS_ATTRIBUTE = "repositories_count"
NUMBER_OF_PERMITTED_BOARDS = 1
- UNKNOWN_IMPORT_URL = 'http://unknown.git'.freeze
+ UNKNOWN_IMPORT_URL = "http://unknown.git"
# Hashed Storage versions handle rolling out new storage to project and dependents models:
# nil: legacy
# 1: repository
@@ -47,22 +47,22 @@ class Project < ActiveRecord::Base
LATEST_STORAGE_VERSION = 2
HASHED_STORAGE_FEATURES = {
repository: 1,
- attachments: 2
+ attachments: 2,
}.freeze
VALID_IMPORT_PORTS = [80, 443].freeze
- VALID_IMPORT_PROTOCOLS = %w(http https git).freeze
+ VALID_IMPORT_PROTOCOLS = %w[http https git].freeze
VALID_MIRROR_PORTS = [22, 80, 443].freeze
- VALID_MIRROR_PROTOCOLS = %w(http https ssh git).freeze
+ VALID_MIRROR_PROTOCOLS = %w[http https ssh git].freeze
ignore_column :import_status, :import_jid, :import_error
cache_markdown_field :description, pipeline: :description
delegate :feature_available?, :builds_enabled?, :wiki_enabled?,
- :merge_requests_enabled?, :issues_enabled?, :pages_enabled?, :public_pages?,
- to: :project_feature, allow_nil: true
+ :merge_requests_enabled?, :issues_enabled?, :pages_enabled?, :public_pages?,
+ to: :project_feature, allow_nil: true
delegate :base_dir, :disk_path, :ensure_storage_path_exists, to: :storage
@@ -130,13 +130,13 @@ class Project < ActiveRecord::Base
# Relations
belongs_to :pool_repository
- belongs_to :creator, class_name: 'User'
- belongs_to :group, -> { where(type: 'Group') }, foreign_key: 'namespace_id'
+ belongs_to :creator, class_name: "User"
+ belongs_to :group, -> { where(type: "Group") }, foreign_key: "namespace_id"
belongs_to :namespace
- alias_method :parent, :namespace
+ alias parent namespace
alias_attribute :parent_id, :namespace_id
- has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event'
+ has_one :last_event, -> {order "events.created_at DESC"}, class_name: "Event"
has_many :boards, before_add: :validate_board_limit
# Project services
@@ -175,46 +175,46 @@ class Project < ActiveRecord::Base
has_one :hangouts_chat_service
has_one :root_of_fork_network,
- foreign_key: 'root_project_id',
- inverse_of: :root_project,
- class_name: 'ForkNetwork'
+ foreign_key: "root_project_id",
+ inverse_of: :root_project,
+ class_name: "ForkNetwork"
has_one :fork_network_member
has_one :fork_network, through: :fork_network_member
has_one :forked_from_project, through: :fork_network_member
- has_many :forked_to_members, class_name: 'ForkNetworkMember', foreign_key: 'forked_from_project_id'
+ has_many :forked_to_members, class_name: "ForkNetworkMember", foreign_key: "forked_from_project_id"
has_many :forks, through: :forked_to_members, source: :project, inverse_of: :forked_from_project
- has_one :import_state, autosave: true, class_name: 'ProjectImportState', inverse_of: :project
+ has_one :import_state, autosave: true, class_name: "ProjectImportState", inverse_of: :project
has_one :import_export_upload, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_one :project_repository, inverse_of: :project
- has_one :error_tracking_setting, inverse_of: :project, class_name: 'ErrorTracking::ProjectErrorTrackingSetting'
+ has_one :error_tracking_setting, inverse_of: :project, class_name: "ErrorTracking::ProjectErrorTrackingSetting"
# Merge Requests for target project should be removed with it
- has_many :merge_requests, foreign_key: 'target_project_id', inverse_of: :target_project
- has_many :source_of_merge_requests, foreign_key: 'source_project_id', class_name: 'MergeRequest'
+ has_many :merge_requests, foreign_key: "target_project_id", inverse_of: :target_project
+ has_many :source_of_merge_requests, foreign_key: "source_project_id", class_name: "MergeRequest"
has_many :issues
- has_many :labels, class_name: 'ProjectLabel'
+ has_many :labels, class_name: "ProjectLabel"
has_many :services
has_many :events
has_many :milestones
has_many :notes
- has_many :snippets, class_name: 'ProjectSnippet'
- has_many :hooks, class_name: 'ProjectHook'
+ has_many :snippets, class_name: "ProjectSnippet"
+ has_many :hooks, class_name: "ProjectHook"
has_many :protected_branches
has_many :protected_tags
has_many :repository_languages, -> { order "share DESC" }
has_many :project_authorizations
- has_many :authorized_users, through: :project_authorizations, source: :user, class_name: 'User'
+ has_many :authorized_users, through: :project_authorizations, source: :user, class_name: "User"
has_many :project_members, -> { where(requested_at: nil) },
as: :source, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
- alias_method :members, :project_members
+ alias members project_members
has_many :users, through: :project_members
has_many :requesters, -> { where.not(requested_at: nil) },
- as: :source, class_name: 'ProjectMember', dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
- has_many :members_and_requesters, as: :source, class_name: 'ProjectMember'
+ as: :source, class_name: "ProjectMember", dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
+ has_many :members_and_requesters, as: :source, class_name: "ProjectMember"
has_many :deploy_keys_projects
has_many :deploy_keys, through: :deploy_keys_projects
@@ -232,14 +232,14 @@ class Project < ActiveRecord::Base
has_many :internal_ids
- has_one :import_data, class_name: 'ProjectImportData', inverse_of: :project, autosave: true
+ has_one :import_data, class_name: "ProjectImportData", inverse_of: :project, autosave: true
has_one :project_feature, inverse_of: :project
- has_one :statistics, class_name: 'ProjectStatistics'
+ has_one :statistics, class_name: "ProjectStatistics"
- has_one :cluster_project, class_name: 'Clusters::Project'
- has_many :clusters, through: :cluster_project, class_name: 'Clusters::Cluster'
- has_many :cluster_ingresses, through: :clusters, source: :application_ingress, class_name: 'Clusters::Applications::Ingress'
- has_many :kubernetes_namespaces, class_name: 'Clusters::KubernetesNamespace'
+ has_one :cluster_project, class_name: "Clusters::Project"
+ has_many :clusters, through: :cluster_project, class_name: "Clusters::Cluster"
+ has_many :cluster_ingresses, through: :clusters, source: :application_ingress, class_name: "Clusters::Applications::Ingress"
+ has_many :kubernetes_namespaces, class_name: "Clusters::KubernetesNamespace"
has_many :prometheus_metrics
@@ -251,39 +251,39 @@ class Project < ActiveRecord::Base
has_many :commit_statuses
# The relation :all_pipelines is intended to be used when we want to get the
# whole list of pipelines associated to the project
- has_many :all_pipelines, class_name: 'Ci::Pipeline', inverse_of: :project
+ has_many :all_pipelines, class_name: "Ci::Pipeline", inverse_of: :project
# The relation :ci_pipelines is intended to be used when we want to get only
# those pipeline which are directly related to CI. There are
# other pipelines, like webide ones, that we won't retrieve
# if we use this relation.
has_many :ci_pipelines,
- -> { ci_sources },
- class_name: 'Ci::Pipeline',
- inverse_of: :project
- has_many :stages, class_name: 'Ci::Stage', inverse_of: :project
+ -> { ci_sources },
+ class_name: "Ci::Pipeline",
+ inverse_of: :project
+ has_many :stages, class_name: "Ci::Stage", inverse_of: :project
# Ci::Build objects store data on the file system such as artifact files and
# build traces. Currently there's no efficient way of removing this data in
# bulk that doesn't involve loading the rows into memory. As a result we're
# still using `dependent: :destroy` here.
- has_many :builds, class_name: 'Ci::Build', inverse_of: :project, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :build_trace_section_names, class_name: 'Ci::BuildTraceSectionName'
- has_many :build_trace_chunks, class_name: 'Ci::BuildTraceChunk', through: :builds, source: :trace_chunks
- has_many :runner_projects, class_name: 'Ci::RunnerProject', inverse_of: :project
- has_many :runners, through: :runner_projects, source: :runner, class_name: 'Ci::Runner'
- has_many :variables, class_name: 'Ci::Variable'
- has_many :triggers, class_name: 'Ci::Trigger'
+ has_many :builds, class_name: "Ci::Build", inverse_of: :project, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_many :build_trace_section_names, class_name: "Ci::BuildTraceSectionName"
+ has_many :build_trace_chunks, class_name: "Ci::BuildTraceChunk", through: :builds, source: :trace_chunks
+ has_many :runner_projects, class_name: "Ci::RunnerProject", inverse_of: :project
+ has_many :runners, through: :runner_projects, source: :runner, class_name: "Ci::Runner"
+ has_many :variables, class_name: "Ci::Variable"
+ has_many :triggers, class_name: "Ci::Trigger"
has_many :environments
has_many :deployments, -> { success }
- has_many :pipeline_schedules, class_name: 'Ci::PipelineSchedule'
+ has_many :pipeline_schedules, class_name: "Ci::PipelineSchedule"
has_many :project_deploy_tokens
has_many :deploy_tokens, through: :project_deploy_tokens
- has_one :auto_devops, class_name: 'ProjectAutoDevops'
- has_many :custom_attributes, class_name: 'ProjectCustomAttribute'
+ has_one :auto_devops, class_name: "ProjectAutoDevops"
+ has_many :custom_attributes, class_name: "ProjectCustomAttribute"
- has_many :project_badges, class_name: 'ProjectBadge'
- has_one :ci_cd_settings, class_name: 'ProjectCiCdSetting', inverse_of: :project, autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_many :project_badges, class_name: "ProjectBadge"
+ has_one :ci_cd_settings, class_name: "ProjectCiCdSetting", inverse_of: :project, autosave: true, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :remote_mirrors, inverse_of: :project
@@ -293,8 +293,8 @@ class Project < ActiveRecord::Base
accepts_nested_attributes_for :auto_devops, update_only: true
accepts_nested_attributes_for :remote_mirrors,
- allow_destroy: true,
- reject_if: ->(attrs) { attrs[:id].blank? && attrs[:url].blank? }
+ allow_destroy: true,
+ reject_if: ->(attrs) { attrs[:id].blank? && attrs[:url].blank? }
accepts_nested_attributes_for :error_tracking_setting, update_only: true
@@ -310,47 +310,47 @@ class Project < ActiveRecord::Base
# Validations
validates :creator, presence: true, on: :create
- validates :description, length: { maximum: 2000 }, allow_blank: true
+ validates :description, length: {maximum: 2000}, allow_blank: true
validates :ci_config_path,
- format: { without: %r{(\.{2}|\A/)},
- message: 'cannot include leading slash or directory traversal.' },
- length: { maximum: 255 },
+ format: {without: %r{(\.{2}|\A/)},
+ message: "cannot include leading slash or directory traversal.",},
+ length: {maximum: 255},
allow_blank: true
validates :name,
presence: true,
- length: { maximum: 255 },
- format: { with: Gitlab::Regex.project_name_regex,
- message: Gitlab::Regex.project_name_regex_message }
+ length: {maximum: 255},
+ format: {with: Gitlab::Regex.project_name_regex,
+ message: Gitlab::Regex.project_name_regex_message,}
validates :path,
presence: true,
project_path: true,
- length: { maximum: 255 }
+ length: {maximum: 255}
validates :namespace, presence: true
- validates :name, uniqueness: { scope: :namespace_id }
- validates :import_url, public_url: { protocols: ->(project) { project.persisted? ? VALID_MIRROR_PROTOCOLS : VALID_IMPORT_PROTOCOLS },
- ports: ->(project) { project.persisted? ? VALID_MIRROR_PORTS : VALID_IMPORT_PORTS },
- enforce_user: true }, if: [:external_import?, :import_url_changed?]
- validates :star_count, numericality: { greater_than_or_equal_to: 0 }
+ validates :name, uniqueness: {scope: :namespace_id}
+ validates :import_url, public_url: {protocols: ->(project) { project.persisted? ? VALID_MIRROR_PROTOCOLS : VALID_IMPORT_PROTOCOLS },
+ ports: ->(project) { project.persisted? ? VALID_MIRROR_PORTS : VALID_IMPORT_PORTS },
+ enforce_user: true,}, if: [:external_import?, :import_url_changed?]
+ validates :star_count, numericality: {greater_than_or_equal_to: 0}
validate :check_personal_projects_limit, on: :create
validate :check_repository_path_availability, on: :update, if: ->(project) { project.renamed? }
- validate :visibility_level_allowed_by_group, if: -> { changes.has_key?(:visibility_level) }
- validate :visibility_level_allowed_as_fork, if: -> { changes.has_key?(:visibility_level) }
+ validate :visibility_level_allowed_by_group, if: -> { changes.key?(:visibility_level) }
+ validate :visibility_level_allowed_as_fork, if: -> { changes.key?(:visibility_level) }
validate :check_wiki_path_conflict
- validate :validate_pages_https_only, if: -> { changes.has_key?(:pages_https_only) }
+ validate :validate_pages_https_only, if: -> { changes.key?(:pages_https_only) }
validates :repository_storage,
presence: true,
- inclusion: { in: ->(_object) { Gitlab.config.repositories.storages.keys } }
- validates :variables, variable_duplicates: { scope: :environment_scope }
- validates :bfg_object_map, file_size: { maximum: :max_attachment_size }
+ inclusion: {in: ->(_object) { Gitlab.config.repositories.storages.keys }}
+ validates :variables, variable_duplicates: {scope: :environment_scope}
+ validates :bfg_object_map, file_size: {maximum: :max_attachment_size}
# Scopes
scope :pending_delete, -> { where(pending_delete: true) }
scope :without_deleted, -> { where(pending_delete: false) }
- scope :with_storage_feature, ->(feature) { where('storage_version >= :version', version: HASHED_STORAGE_FEATURES[feature]) }
- scope :without_storage_feature, ->(feature) { where('storage_version < :version OR storage_version IS NULL', version: HASHED_STORAGE_FEATURES[feature]) }
- scope :with_unmigrated_storage, -> { where('storage_version < :version OR storage_version IS NULL', version: LATEST_STORAGE_VERSION) }
+ scope :with_storage_feature, ->(feature) { where("storage_version >= :version", version: HASHED_STORAGE_FEATURES[feature]) }
+ scope :without_storage_feature, ->(feature) { where("storage_version < :version OR storage_version IS NULL", version: HASHED_STORAGE_FEATURES[feature]) }
+ scope :with_unmigrated_storage, -> { where("storage_version < :version OR storage_version IS NULL", version: LATEST_STORAGE_VERSION) }
# last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push
scope :sorted_by_activity, -> { reorder("GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC") }
@@ -358,22 +358,22 @@ class Project < ActiveRecord::Base
scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
- scope :joined, ->(user) { where('namespace_id != ?', user.namespace_id) }
+ scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :starred_by, ->(user) { joins(:users_star_projects).where('users_star_projects.user_id': user.id) }
scope :visible_to_user, ->(user) { where(id: user.authorized_projects.select(:id).reorder(nil)) }
- scope :visible_to_user_and_access_level, ->(user, access_level) { where(id: user.authorized_projects.where('project_authorizations.access_level >= ?', access_level).select(:id).reorder(nil)) }
+ scope :visible_to_user_and_access_level, ->(user, access_level) { where(id: user.authorized_projects.where("project_authorizations.access_level >= ?", access_level).select(:id).reorder(nil)) }
scope :archived, -> { where(archived: true) }
scope :non_archived, -> { where(archived: false) }
- scope :for_milestones, ->(ids) { joins(:milestones).where('milestones.id' => ids).distinct }
- scope :with_push, -> { joins(:events).where('events.action = ?', Event::PUSHED) }
- scope :with_project_feature, -> { joins('LEFT JOIN project_features ON projects.id = project_features.project_id') }
+ scope :for_milestones, ->(ids) { joins(:milestones).where("milestones.id" => ids).distinct }
+ scope :with_push, -> { joins(:events).where("events.action = ?", Event::PUSHED) }
+ scope :with_project_feature, -> { joins("LEFT JOIN project_features ON projects.id = project_features.project_id") }
scope :with_statistics, -> { includes(:statistics) }
scope :with_shared_runners, -> { where(shared_runners_enabled: true) }
scope :inside_path, ->(path) do
# We need routes alias rs for JOIN so it does not conflict with
# includes(:route) which we use in ProjectsFinder.
joins("INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'")
- .where('rs.path LIKE ?', "#{sanitize_sql_like(path)}/%")
+ .where("rs.path LIKE ?", "#{sanitize_sql_like(path)}/%")
end
# "enabled" here means "not disabled". It includes private features!
@@ -387,46 +387,46 @@ class Project < ActiveRecord::Base
# Picks a feature where the level is exactly that given.
scope :with_feature_access_level, ->(feature, level) {
access_level_attribute = ProjectFeature.access_level_attribute(feature)
- with_project_feature.where(project_features: { access_level_attribute => level })
+ with_project_feature.where(project_features: {access_level_attribute => level})
}
# Picks projects which use the given programming language
scope :with_programming_language, ->(language_name) do
lang_id_query = ProgrammingLanguage
- .with_name_case_insensitive(language_name)
- .select(:id)
+ .with_name_case_insensitive(language_name)
+ .select(:id)
joins(:repository_languages)
- .where(repository_languages: { programming_language_id: lang_id_query })
+ .where(repository_languages: {programming_language_id: lang_id_query})
end
scope :with_builds_enabled, -> { with_feature_enabled(:builds) }
scope :with_issues_enabled, -> { with_feature_enabled(:issues) }
scope :with_issues_available_for_user, ->(current_user) { with_feature_available_for_user(:issues, current_user) }
scope :with_merge_requests_enabled, -> { with_feature_enabled(:merge_requests) }
- scope :with_remote_mirrors, -> { joins(:remote_mirrors).where(remote_mirrors: { enabled: true }).distinct }
+ scope :with_remote_mirrors, -> { joins(:remote_mirrors).where(remote_mirrors: {enabled: true}).distinct }
scope :with_group_runners_enabled, -> do
joins(:ci_cd_settings)
- .where(project_ci_cd_settings: { group_runners_enabled: true })
+ .where(project_ci_cd_settings: {group_runners_enabled: true})
end
- scope :missing_kubernetes_namespace, -> (kubernetes_namespaces) do
- subquery = kubernetes_namespaces.select('1').where('clusters_kubernetes_namespaces.project_id = projects.id')
+ scope :missing_kubernetes_namespace, ->(kubernetes_namespaces) do
+ subquery = kubernetes_namespaces.select("1").where("clusters_kubernetes_namespaces.project_id = projects.id")
- where('NOT EXISTS (?)', subquery)
+ where("NOT EXISTS (?)", subquery)
end
- enum auto_cancel_pending_pipelines: { disabled: 0, enabled: 1 }
+ enum auto_cancel_pending_pipelines: {disabled: 0, enabled: 1}
chronic_duration_attr :build_timeout_human_readable, :build_timeout,
- default: 3600, error_message: 'Maximum job timeout has a value which could not be accepted'
+ default: 3600, error_message: "Maximum job timeout has a value which could not be accepted"
validates :build_timeout, allow_nil: true,
- numericality: { greater_than_or_equal_to: 10.minutes,
- less_than: 1.month,
- only_integer: true,
- message: 'needs to be beetween 10 minutes and 1 month' }
+ numericality: {greater_than_or_equal_to: 10.minutes,
+ less_than: 1.month,
+ only_integer: true,
+ message: "needs to be beetween 10 minutes and 1 month",}
# Used by Projects::CleanupService to hold a map of rewritten object IDs
mount_uploader :bfg_object_map, AttachmentUploader
@@ -449,7 +449,7 @@ class Project < ActiveRecord::Base
limit: Kaminari.config.default_per_page
)
relation = order_id_desc.limit(limit)
- relation = relation.where('projects.id < ?', before) if before
+ relation = relation.where("projects.id < ?", before) if before
relation
end
@@ -462,9 +462,9 @@ class Project < ActiveRecord::Base
# logged in user.
def self.public_or_visible_to_user(user = nil)
if user
- where('EXISTS (?) OR projects.visibility_level IN (?)',
- user.authorizations_for_projects,
- Gitlab::VisibilityLevel.levels_for_user(user))
+ where("EXISTS (?) OR projects.visibility_level IN (?)",
+ user.authorizations_for_projects,
+ Gitlab::VisibilityLevel.levels_for_user(user))
else
public_to_user
end
@@ -494,21 +494,22 @@ class Project < ActiveRecord::Base
private: Gitlab::VisibilityLevel::PRIVATE,
public_visible: ProjectFeature::ENABLED,
private_visible: ProjectFeature::PRIVATE,
- authorizations: user.authorizations_for_projects(min_access_level: min_access_level)
- })
+ authorizations: user.authorizations_for_projects(min_access_level: min_access_level),
+ }
+ )
else
with_feature_access_level(feature, visible)
end
end
- scope :active, -> { joins(:issues, :notes, :merge_requests).order('issues.created_at, notes.created_at, merge_requests.created_at DESC') }
- scope :abandoned, -> { where('projects.last_activity_at < ?', 6.months.ago) }
+ scope :active, -> { joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC") }
+ scope :abandoned, -> { where("projects.last_activity_at < ?", 6.months.ago) }
scope :excluding_project, ->(project) { where.not(id: project) }
# We require an alias to the project_mirror_data_table in order to use import_state in our queries
scope :joins_import_state, -> { joins("INNER JOIN project_mirror_data import_state ON import_state.project_id = projects.id") }
- scope :for_group, -> (group) { where(group: group) }
+ scope :for_group, ->(group) { where(group: group) }
class << self
# Searches for a list of projects based on the query given in `query`.
@@ -532,15 +533,15 @@ class Project < ActiveRecord::Base
def sort_by_attribute(method)
case method.to_s
- when 'storage_size_desc'
+ when "storage_size_desc"
# storage_size is a joined column so we need to
# pass a string to avoid AR adding the table name
- reorder('project_statistics.storage_size DESC, projects.id DESC')
- when 'latest_activity_desc'
+ reorder("project_statistics.storage_size DESC, projects.id DESC")
+ when "latest_activity_desc"
reorder(last_activity_at: :desc)
- when 'latest_activity_asc'
+ when "latest_activity_asc"
reorder(last_activity_at: :asc)
- when 'stars_desc'
+ when "stars_desc"
sorted_by_stars
else
order_by(method)
@@ -556,11 +557,11 @@ class Project < ActiveRecord::Base
end
def reference_postfix
- '>'
+ ">"
end
def reference_postfix_escaped
- '&gt;'
+ "&gt;"
end
# Pattern used to extract `namespace/project>` project references from text.
@@ -574,18 +575,18 @@ class Project < ActiveRecord::Base
end
def trending
- joins('INNER JOIN trending_projects ON projects.id = trending_projects.project_id')
- .reorder('trending_projects.id ASC')
+ joins("INNER JOIN trending_projects ON projects.id = trending_projects.project_id")
+ .reorder("trending_projects.id ASC")
end
def cached_count
- Rails.cache.fetch('total_project_count', expires_in: 5.minutes) do
+ Rails.cache.fetch("total_project_count", expires_in: 5.minutes) do
Project.count
end
end
def group_ids
- joins(:namespace).where(namespaces: { type: 'Group' }).select(:namespace_id)
+ joins(:namespace).where(namespaces: {type: "Group"}).select(:namespace_id)
end
end
@@ -612,7 +613,7 @@ class Project < ActiveRecord::Base
.base_and_ancestors(upto: top, hierarchy_order: hierarchy_order)
end
- alias_method :ancestors, :ancestors_upto
+ alias ancestors ancestors_upto
def lfs_enabled?
return namespace.lfs_enabled? if self[:lfs_enabled].nil?
@@ -620,7 +621,7 @@ class Project < ActiveRecord::Base
self[:lfs_enabled] && Gitlab.config.lfs.enabled
end
- alias_method :lfs_enabled, :lfs_enabled?
+ alias lfs_enabled lfs_enabled?
def auto_devops_enabled?
if auto_devops&.enabled.nil?
@@ -659,7 +660,7 @@ class Project < ActiveRecord::Base
@repository = nil
end
- alias_method :reload_repository!, :cleanup
+ alias reload_repository! cleanup
def container_registry_url
if Gitlab.config.registry.enabled
@@ -674,7 +675,7 @@ class Project < ActiveRecord::Base
has_root_container_repository_tags?
end
- def commit(ref = 'HEAD')
+ def commit(ref = "HEAD")
repository.commit(ref)
end
@@ -708,11 +709,11 @@ class Project < ActiveRecord::Base
end
def import_status
- import_state&.status || 'none'
+ import_state&.status || "none"
end
def human_import_status_name
- import_state&.human_status_name || 'none'
+ import_state&.human_status_name || "none"
end
def add_import_job
@@ -721,9 +722,9 @@ class Project < ActiveRecord::Base
RepositoryForkWorker.perform_async(id)
elsif gitlab_project_import?
# Do not retry on Import/Export until https://gitlab.com/gitlab-org/gitlab-ce/issues/26189 is solved.
- RepositoryImportWorker.set(retry: false).perform_async(self.id)
+ RepositoryImportWorker.set(retry: false).perform_async(id)
else
- RepositoryImportWorker.perform_async(self.id)
+ RepositoryImportWorker.perform_async(id)
end
log_import_activity(job_id)
@@ -743,7 +744,7 @@ class Project < ActiveRecord::Base
def reset_cache_and_import_attrs
run_after_commit do
- ProjectCacheWorker.perform_async(self.id)
+ ProjectCacheWorker.perform_async(id)
end
import_state.update(last_error: nil)
@@ -809,15 +810,15 @@ class Project < ActiveRecord::Base
end
def bare_repository_import?
- import_type == 'bare_repository'
+ import_type == "bare_repository"
end
def gitlab_project_import?
- import_type == 'gitlab_project'
+ import_type == "gitlab_project"
end
def gitea_import?
- import_type == 'gitea'
+ import_type == "gitea"
end
def has_remote_mirror?
@@ -837,7 +838,7 @@ class Project < ActiveRecord::Base
def mark_stuck_remote_mirrors_as_failed!
remote_mirrors.stuck.update_all(
update_status: :failed,
- last_error: 'The remote mirror took to long to complete.',
+ last_error: "The remote mirror took to long to complete.",
last_update_at: Time.now
)
end
@@ -856,41 +857,41 @@ class Project < ActiveRecord::Base
# present. Since the validation for that will fail, we can just return
# early.
return if !creator || creator.can_create_project? ||
- namespace.kind == 'group'
+ namespace.kind == "group"
limit = creator.projects_limit
error =
if limit.zero?
- _('Personal project creation is not allowed. Please contact your administrator with questions')
+ _("Personal project creation is not allowed. Please contact your administrator with questions")
else
- _('Your project limit is %{limit} projects! Please contact your administrator to increase it')
+ _("Your project limit is %{limit} projects! Please contact your administrator to increase it")
end
- self.errors.add(:limit_reached, error % { limit: limit })
+ errors.add(:limit_reached, error % {limit: limit})
end
def visibility_level_allowed_by_group
return if visibility_level_allowed_by_group?
- level_name = Gitlab::VisibilityLevel.level_name(self.visibility_level).downcase
- group_level_name = Gitlab::VisibilityLevel.level_name(self.group.visibility_level).downcase
- self.errors.add(:visibility_level, "#{level_name} is not allowed in a #{group_level_name} group.")
+ level_name = Gitlab::VisibilityLevel.level_name(visibility_level).downcase
+ group_level_name = Gitlab::VisibilityLevel.level_name(group.visibility_level).downcase
+ errors.add(:visibility_level, "#{level_name} is not allowed in a #{group_level_name} group.")
end
def visibility_level_allowed_as_fork
return if visibility_level_allowed_as_fork?
- level_name = Gitlab::VisibilityLevel.level_name(self.visibility_level).downcase
- self.errors.add(:visibility_level, "#{level_name} is not allowed since the fork source project has lower visibility.")
+ level_name = Gitlab::VisibilityLevel.level_name(visibility_level).downcase
+ errors.add(:visibility_level, "#{level_name} is not allowed since the fork source project has lower visibility.")
end
def check_wiki_path_conflict
return if path.blank?
- path_to_check = path.ends_with?('.wiki') ? path.chomp('.wiki') : "#{path}.wiki"
+ path_to_check = path.ends_with?(".wiki") ? path.chomp(".wiki") : "#{path}.wiki"
if Project.where(namespace_id: namespace_id, path: path_to_check).exists?
- errors.add(:name, 'has already been taken')
+ errors.add(:name, "has already been taken")
end
end
@@ -958,7 +959,7 @@ class Project < ActiveRecord::Base
return unless Gitlab::IncomingEmail.supports_issue_creation? && author
# check since this can come from a request parameter
- return unless %w(issue merge_request).include?(address_type)
+ return unless %w[issue merge_request].include?(address_type)
author.ensure_incoming_email_token!
@@ -970,7 +971,7 @@ class Project < ActiveRecord::Base
end
def build_commit_note(commit)
- notes.new(commit_id: commit.id, noteable_type: 'Commit')
+ notes.new(commit_id: commit.id, noteable_type: "Commit")
end
def last_activity
@@ -982,7 +983,7 @@ class Project < ActiveRecord::Base
end
def project_id
- self.id
+ id
end
def get_issue(issue_id, current_user)
@@ -1004,11 +1005,7 @@ class Project < ActiveRecord::Base
end
def issues_tracker
- if external_issue_tracker
- external_issue_tracker
- else
- default_issue_tracker
- end
+ external_issue_tracker || default_issue_tracker
end
def external_issue_reference_pattern
@@ -1028,8 +1025,6 @@ class Project < ActiveRecord::Base
return @external_issue_tracker if defined?(@external_issue_tracker)
@external_issue_tracker = services.external_issue_trackers.first
- else
- nil
end
end
@@ -1048,8 +1043,6 @@ class Project < ActiveRecord::Base
if has_external_wiki
@external_wiki ||= services.external_wikis.first
- else
- nil
end
end
@@ -1060,9 +1053,9 @@ class Project < ActiveRecord::Base
def find_or_initialize_services(exceptions: [])
available_services_names = Service.available_services_names - exceptions
- available_services = available_services_names.map do |service_name|
+ available_services = available_services_names.map { |service_name|
find_or_initialize_service(service_name)
- end
+ }
available_services.compact
end
@@ -1091,7 +1084,7 @@ class Project < ActiveRecord::Base
# rubocop: disable CodeReuse/ServiceClass
def create_labels
Label.templates.each do |label|
- params = label.attributes.except('id', 'template', 'created_at', 'updated_at', 'type')
+ params = label.attributes.except("id", "template", "created_at", "updated_at", "type")
Labels::FindOrCreateService.new(nil, self, params).execute(skip_authorization: true)
end
end
@@ -1118,7 +1111,7 @@ class Project < ActiveRecord::Base
end
def jira_tracker?
- issues_tracker.to_param == 'jira'
+ issues_tracker.to_param == "jira"
end
def avatar_in_git
@@ -1135,16 +1128,16 @@ class Project < ActiveRecord::Base
end
def all_clusters
- group_clusters = Clusters::Cluster.joins(:groups).where(cluster_groups: { group_id: ancestors_upto } )
+ group_clusters = Clusters::Cluster.joins(:groups).where(cluster_groups: {group_id: ancestors_upto})
Clusters::Cluster.from_union([clusters, group_clusters])
end
def items_for(entity)
case entity
- when 'issue' then
+ when "issue" then
issues
- when 'merge_request' then
+ when "merge_request" then
merge_requests
end
end
@@ -1160,11 +1153,7 @@ class Project < ActiveRecord::Base
# rubocop: enable CodeReuse/ServiceClass
def owner
- if group
- group
- else
- namespace.try(:owner)
- end
+ group || namespace.try(:owner)
end
# rubocop: disable CodeReuse/ServiceClass
@@ -1190,7 +1179,7 @@ class Project < ActiveRecord::Base
def valid_repo?
repository.exists?
rescue
- errors.add(:path, 'Invalid repository path')
+ errors.add(:path, "Invalid repository path")
false
end
@@ -1200,11 +1189,9 @@ class Project < ActiveRecord::Base
def repo_exists?
strong_memoize(:repo_exists) do
- begin
- repository.exists?
- rescue
- false
- end
+ repository.exists?
+ rescue
+ false
end
end
@@ -1283,7 +1270,7 @@ class Project < ActiveRecord::Base
# Check if repository with same path already exists on disk we can
# skip this for the hashed storage because the path does not change
if legacy_storage? && repository_with_same_path_already_exists?
- errors.add(:base, 'There is already a repository with that name on disk')
+ errors.add(:base, "There is already a repository with that name on disk")
return false
end
@@ -1305,7 +1292,7 @@ class Project < ActiveRecord::Base
repository.after_create
true
else
- errors.add(:base, 'Failed to create repository via gitlab-shell')
+ errors.add(:base, "Failed to create repository via gitlab-shell")
false
end
end
@@ -1323,17 +1310,17 @@ class Project < ActiveRecord::Base
visibility_level: visibility_level,
path_with_namespace: full_path,
default_branch: default_branch,
- ci_config_path: ci_config_path
+ ci_config_path: ci_config_path,
}
# Backward compatibility
if backward
attrs.merge!({
- homepage: web_url,
- url: url_to_repo,
- ssh_url: ssh_url_to_repo,
- http_url: http_url_to_repo
- })
+ homepage: web_url,
+ url: url_to_repo,
+ ssh_url: ssh_url_to_repo,
+ http_url: http_url_to_repo,
+ })
end
attrs
@@ -1354,7 +1341,7 @@ class Project < ActiveRecord::Base
else
return [] if users.empty?
- user_ids = authorized_users.where(users: { id: users.map(&:id) }).pluck(:id)
+ user_ids = authorized_users.where(users: {id: users.map(&:id)}).pluck(:id)
users.select { |user| user_ids.include?(user.id) }
end
end
@@ -1375,7 +1362,7 @@ class Project < ActiveRecord::Base
def change_head(branch)
if repository.branch_exists?(branch)
repository.before_change_head
- repository.raw_repository.write_ref('HEAD', "refs/heads/#{branch}")
+ repository.raw_repository.write_ref("HEAD", "refs/heads/#{branch}")
repository.copy_gitattributes(branch)
repository.after_change_head
reload_default_branch
@@ -1401,7 +1388,7 @@ class Project < ActiveRecord::Base
end
def origin_merge_requests
- merge_requests.where(source_project_id: self.id)
+ merge_requests.where(source_project_id: id)
end
def ensure_repository
@@ -1429,15 +1416,15 @@ class Project < ActiveRecord::Base
end
def create_wiki
- ProjectWiki.new(self, self.owner).wiki
+ ProjectWiki.new(self, owner).wiki
true
rescue ProjectWiki::CouldNotCreateWikiError
- errors.add(:base, 'Failed create wiki')
+ errors.add(:base, "Failed create wiki")
false
end
def wiki
- @wiki ||= ProjectWiki.new(self, self.owner)
+ @wiki ||= ProjectWiki.new(self, owner)
end
def jira_tracker_active?
@@ -1486,7 +1473,7 @@ class Project < ActiveRecord::Base
end
def group_runners
- @group_runners ||= group_runners_enabled? ? Ci::Runner.belonging_to_parent_group_of_project(self.id) : Ci::Runner.none
+ @group_runners ||= group_runners_enabled? ? Ci::Runner.belonging_to_parent_group_of_project(id) : Ci::Runner.none
end
def all_runners
@@ -1504,7 +1491,7 @@ class Project < ActiveRecord::Base
end
def valid_runners_token?(token)
- self.runners_token && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.runners_token)
+ runners_token && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, runners_token)
end
# rubocop: disable CodeReuse/ServiceClass
@@ -1519,7 +1506,7 @@ class Project < ActiveRecord::Base
end
# rubocop: enable CodeReuse/ServiceClass
- def visibility_level_allowed_as_fork?(level = self.visibility_level)
+ def visibility_level_allowed_as_fork?(level = visibility_level)
return true unless forked?
original_project = fork_source
@@ -1528,13 +1515,13 @@ class Project < ActiveRecord::Base
level <= original_project.visibility_level
end
- def visibility_level_allowed_by_group?(level = self.visibility_level)
+ def visibility_level_allowed_by_group?(level = visibility_level)
return true unless group
level <= group.visibility_level
end
- def visibility_level_allowed?(level = self.visibility_level)
+ def visibility_level_allowed?(level = visibility_level)
visibility_level_allowed_as_fork?(level) && visibility_level_allowed_by_group?(level)
end
@@ -1548,14 +1535,14 @@ class Project < ActiveRecord::Base
def pages_group_url
# The host in URL always needs to be downcased
- Gitlab.config.pages.url.sub(%r{^https?://}) do |prefix|
+ Gitlab.config.pages.url.sub(%r{^https?://}) { |prefix|
"#{prefix}#{pages_subdomain}."
- end.downcase
+ }.downcase
end
def pages_url
url = pages_group_url
- url_path = full_path.partition('/').last
+ url_path = full_path.partition("/").last
# If the project path is the same as host, we serve it as group page
return url if url == "#{Settings.pages.protocol}://#{url_path}"
@@ -1564,7 +1551,7 @@ class Project < ActiveRecord::Base
end
def pages_subdomain
- full_path.partition('/').first
+ full_path.partition("/").first
end
def pages_path
@@ -1573,7 +1560,7 @@ class Project < ActiveRecord::Base
end
def public_pages_path
- File.join(pages_path, 'public')
+ File.join(pages_path, "public")
end
def pages_available?
@@ -1591,8 +1578,8 @@ class Project < ActiveRecord::Base
SQL
deploy_keys.where(public: false)
- .where(exclude_keys_linked_to_other_projects)
- .delete_all
+ .where(exclude_keys_linked_to_other_projects)
+ .delete_all
end
# TODO: what to do here when not using Legacy Storage? Do we still need to rename and delay removal?
@@ -1645,7 +1632,7 @@ class Project < ActiveRecord::Base
def update_project_counter_caches
classes = [
Projects::OpenIssuesCountService,
- Projects::OpenMergeRequestsCountService
+ Projects::OpenMergeRequestsCountService,
]
classes.each do |klass|
@@ -1665,12 +1652,12 @@ class Project < ActiveRecord::Base
end
def add_export_job(current_user:, after_export_strategy: nil, params: {})
- job_id = ProjectExportWorker.perform_async(current_user.id, self.id, after_export_strategy, params)
+ job_id = ProjectExportWorker.perform_async(current_user.id, id, after_export_strategy, params)
if job_id
- Rails.logger.info "Export job started for project ID #{self.id} with job ID #{job_id}"
+ Rails.logger.info "Export job started for project ID #{id} with job ID #{job_id}"
else
- Rails.logger.error "Export job failed to start for project ID #{self.id}"
+ Rails.logger.error "Export job failed to start for project ID #{id}"
end
end
@@ -1731,13 +1718,13 @@ class Project < ActiveRecord::Base
visibility = Gitlab::VisibilityLevel.string_level(visibility_level)
Gitlab::Ci::Variables::Collection.new
- .append(key: 'CI_PROJECT_ID', value: id.to_s)
- .append(key: 'CI_PROJECT_NAME', value: path)
- .append(key: 'CI_PROJECT_PATH', value: full_path)
- .append(key: 'CI_PROJECT_PATH_SLUG', value: full_path_slug)
- .append(key: 'CI_PROJECT_NAMESPACE', value: namespace.full_path)
- .append(key: 'CI_PROJECT_URL', value: web_url)
- .append(key: 'CI_PROJECT_VISIBILITY', value: visibility)
+ .append(key: "CI_PROJECT_ID", value: id.to_s)
+ .append(key: "CI_PROJECT_NAME", value: path)
+ .append(key: "CI_PROJECT_PATH", value: full_path)
+ .append(key: "CI_PROJECT_PATH_SLUG", value: full_path_slug)
+ .append(key: "CI_PROJECT_NAMESPACE", value: namespace.full_path)
+ .append(key: "CI_PROJECT_URL", value: web_url)
+ .append(key: "CI_PROJECT_VISIBILITY", value: visibility)
.concat(pages_variables)
.concat(container_registry_variables)
.concat(auto_devops_variables)
@@ -1746,14 +1733,14 @@ class Project < ActiveRecord::Base
def pages_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host)
- variables.append(key: 'CI_PAGES_URL', value: pages_url)
+ variables.append(key: "CI_PAGES_DOMAIN", value: Gitlab.config.pages.host)
+ variables.append(key: "CI_PAGES_URL", value: pages_url)
end
end
def api_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
- variables.append(key: 'CI_API_V4_URL', value: API::Helpers::Version.new('v4').root_url)
+ variables.append(key: "CI_API_V4_URL", value: API::Helpers::Version.new("v4").root_url)
end
end
@@ -1761,10 +1748,10 @@ class Project < ActiveRecord::Base
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless Gitlab.config.registry.enabled
- variables.append(key: 'CI_REGISTRY', value: Gitlab.config.registry.host_port)
+ variables.append(key: "CI_REGISTRY", value: Gitlab.config.registry.host_port)
if container_registry_enabled?
- variables.append(key: 'CI_REGISTRY_IMAGE', value: container_registry_url)
+ variables.append(key: "CI_REGISTRY_IMAGE", value: container_registry_url)
end
end
end
@@ -1794,10 +1781,10 @@ class Project < ActiveRecord::Base
return false unless Gitlab::Git.tag_ref?(resolved_ref) || Gitlab::Git.branch_ref?(resolved_ref)
ref_name = if resolved_ref == ref
- Gitlab::Git.ref_name(resolved_ref)
- else
- ref
- end
+ Gitlab::Git.ref_name(resolved_ref)
+ else
+ ref
+ end
if Gitlab::Git.branch_ref?(resolved_ref)
ProtectedBranch.protected?(self, ref_name)
@@ -1824,7 +1811,6 @@ class Project < ActiveRecord::Base
else
update_attribute(name, value)
end
-
rescue ActiveRecord::RecordNotSaved => e
handle_update_attribute_error(e, value)
end
@@ -1860,16 +1846,16 @@ class Project < ActiveRecord::Base
end
def route_map_for(commit_sha)
- @route_maps_by_commit ||= Hash.new do |h, sha|
+ @route_maps_by_commit ||= Hash.new { |h, sha|
h[sha] = begin
data = repository.route_map_for(sha)
next unless data
Gitlab::RouteMap.new(data)
- rescue Gitlab::RouteMap::FormatError
- nil
+ rescue Gitlab::RouteMap::FormatError
+ nil
end
- end
+ }
@route_maps_by_commit[commit_sha]
end
@@ -1899,13 +1885,13 @@ class Project < ActiveRecord::Base
end
def full_path_was
- File.join(namespace.full_path, previous_changes['path'].first)
+ File.join(namespace.full_path, previous_changes["path"].first)
end
- alias_method :name_with_namespace, :full_name
- alias_method :human_name, :full_name
+ alias name_with_namespace full_name
+ alias human_name full_name
# @deprecated cannot remove yet because it has an index with its name in elasticsearch
- alias_method :path_with_namespace, :full_path
+ alias path_with_namespace full_path
# rubocop: disable CodeReuse/ServiceClass
def forks_count
@@ -1914,7 +1900,7 @@ class Project < ActiveRecord::Base
# rubocop: enable CodeReuse/ServiceClass
def legacy_storage?
- [nil, 0].include?(self.storage_version)
+ [nil, 0].include?(storage_version)
end
# Check if Hashed Storage is enabled for the project with at least informed feature rolled out
@@ -1923,7 +1909,7 @@ class Project < ActiveRecord::Base
def hashed_storage?(feature)
raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
- self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
+ storage_version && storage_version >= HASHED_STORAGE_FEATURES[feature]
end
def renamed?
@@ -1932,16 +1918,16 @@ class Project < ActiveRecord::Base
def human_merge_method
if merge_method == :ff
- 'Fast-forward'
+ "Fast-forward"
else
merge_method.to_s.humanize
end
end
def merge_method
- if self.merge_requests_ff_only_enabled
+ if merge_requests_ff_only_enabled
:ff
- elsif self.merge_requests_rebase_enabled
+ elsif merge_requests_rebase_enabled
:rebase_merge
else
:merge
@@ -1963,7 +1949,7 @@ class Project < ActiveRecord::Base
end
def ff_merge_must_be_possible?
- self.merge_requests_ff_only_enabled || self.merge_requests_rebase_enabled
+ merge_requests_ff_only_enabled || merge_requests_rebase_enabled
end
def migrate_to_hashed_storage!
@@ -1999,7 +1985,7 @@ class Project < ActiveRecord::Base
Badge.from_union([
project_badges,
- GroupBadge.where(group: group.self_and_ancestors)
+ GroupBadge.where(group: group.self_and_ancestors),
])
end
@@ -2007,11 +1993,11 @@ class Project < ActiveRecord::Base
return MergeRequest.none unless user
developer_access_exists = user.project_authorizations
- .where('access_level >= ? ', Gitlab::Access::DEVELOPER)
- .where('project_authorizations.project_id = merge_requests.target_project_id')
- .limit(1)
- .select(1)
- merge_requests_allowing_collaboration.where('EXISTS (?)', developer_access_exists)
+ .where("access_level >= ? ", Gitlab::Access::DEVELOPER)
+ .where("project_authorizations.project_id = merge_requests.target_project_id")
+ .limit(1)
+ .select(1)
+ merge_requests_allowing_collaboration.where("EXISTS (?)", developer_access_exists)
end
def any_branch_allows_collaboration?(user)
@@ -2037,10 +2023,10 @@ class Project < ActiveRecord::Base
def any_lfs_file_locks?
lfs_file_locks.any?
end
- request_cache(:any_lfs_file_locks?) { self.id }
+ request_cache(:any_lfs_file_locks?) { id }
def auto_cancel_pending_pipelines?
- auto_cancel_pending_pipelines == 'enabled'
+ auto_cancel_pending_pipelines == "enabled"
end
def storage
@@ -2069,7 +2055,7 @@ class Project < ActiveRecord::Base
{
repository_storage: repository_storage,
- pool_repository: pool_repository || create_new_pool_repository
+ pool_repository: pool_repository || create_new_pool_repository,
}
end
@@ -2121,11 +2107,11 @@ class Project < ActiveRecord::Base
def join_pool_repository
return unless pool_repository
- ObjectPool::JoinWorker.perform_async(pool_repository.id, self.id)
+ ObjectPool::JoinWorker.perform_async(pool_repository.id, id)
end
def use_hashed_storage
- if self.new_record? && Gitlab::CurrentSettings.hashed_storage_enabled
+ if new_record? && Gitlab::CurrentSettings.hashed_storage_enabled
self.storage_version = LATEST_STORAGE_VERSION
end
end
@@ -2142,7 +2128,7 @@ class Project < ActiveRecord::Base
return if skip_disk_validation
if repository_storage.blank? || repository_with_same_path_already_exists?
- errors.add(:base, 'There is already a repository with that name on disk')
+ errors.add(:base, "There is already a repository with that name on disk")
throw :abort
end
end
@@ -2152,7 +2138,7 @@ class Project < ActiveRecord::Base
end
def set_timestamps_for_create
- update_columns(last_activity_at: self.created_at, last_repository_updated_at: self.created_at)
+ update_columns(last_activity_at: created_at, last_repository_updated_at: created_at)
end
def cross_namespace_reference?(from)
@@ -2183,7 +2169,7 @@ class Project < ActiveRecord::Base
# already have 1, 2, or n it will fail, but it if you have 0 that is lower
# than the number of permitted boards per project it won't fail.
def validate_board_limit(board)
- raise BoardLimitExceeded, 'Number of permitted boards exceeded' if boards.size >= NUMBER_OF_PERMITTED_BOARDS
+ raise BoardLimitExceeded, "Number of permitted boards exceeded" if boards.size >= NUMBER_OF_PERMITTED_BOARDS
end
def update_project_statistics
@@ -2220,11 +2206,11 @@ class Project < ActiveRecord::Base
end
def handle_update_attribute_error(ex, value)
- if ex.message.start_with?('Failed to replace')
+ if ex.message.start_with?("Failed to replace")
if value.respond_to?(:each)
invalid = value.detect(&:invalid?)
- raise ex, ([ex.message] + invalid.errors.full_messages).join(' ') if invalid
+ raise ex, ([ex.message] + invalid.errors.full_messages).join(" ") if invalid
end
end
diff --git a/app/models/project_authorization.rb b/app/models/project_authorization.rb
index 2c590008db2..b0961f9529d 100644
--- a/app/models/project_authorization.rb
+++ b/app/models/project_authorization.rb
@@ -7,24 +7,24 @@ class ProjectAuthorization < ActiveRecord::Base
belongs_to :project
validates :project, presence: true
- validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
- validates :user, uniqueness: { scope: [:project, :access_level] }, presence: true
+ validates :access_level, inclusion: {in: Gitlab::Access.all_values}, presence: true
+ validates :user, uniqueness: {scope: [:project, :access_level]}, presence: true
def self.select_from_union(relations)
from_union(relations)
- .select(['project_id', 'MAX(access_level) AS access_level'])
+ .select(["project_id", "MAX(access_level) AS access_level"])
.group(:project_id)
end
def self.insert_authorizations(rows, per_batch = 1000)
rows.each_slice(per_batch) do |slice|
- tuples = slice.map do |tuple|
+ tuples = slice.map { |tuple|
tuple.map { |value| connection.quote(value) }
- end
+ }
connection.execute <<-EOF.strip_heredoc
INSERT INTO project_authorizations (user_id, project_id, access_level)
- VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
+ VALUES #{tuples.map { |tuple| "(#{tuple.join(", ")})" }.join(", ")}
EOF
end
end
diff --git a/app/models/project_auto_devops.rb b/app/models/project_auto_devops.rb
index e353a6443c4..d865c8832ed 100644
--- a/app/models/project_auto_devops.rb
+++ b/app/models/project_auto_devops.rb
@@ -6,13 +6,13 @@ class ProjectAutoDevops < ActiveRecord::Base
enum deploy_strategy: {
continuous: 0,
manual: 1,
- timed_incremental: 2
+ timed_incremental: 2,
}
scope :enabled, -> { where(enabled: true) }
scope :disabled, -> { where(enabled: false) }
- validates :domain, allow_blank: true, hostname: { allow_numeric_hostname: true }
+ validates :domain, allow_blank: true, hostname: {allow_numeric_hostname: true}
after_save :create_gitlab_deploy_token, if: :needs_to_create_deploy_token?
@@ -33,7 +33,7 @@ class ProjectAutoDevops < ActiveRecord::Base
def predefined_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
if has_domain?
- variables.append(key: 'AUTO_DEVOPS_DOMAIN',
+ variables.append(key: "AUTO_DEVOPS_DOMAIN",
value: domain.presence || instance_domain)
end
@@ -59,11 +59,11 @@ class ProjectAutoDevops < ActiveRecord::Base
def deployment_strategy_default_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
if manual?
- variables.append(key: 'STAGING_ENABLED', value: '1')
- variables.append(key: 'INCREMENTAL_ROLLOUT_ENABLED', value: '1') # deprecated
- variables.append(key: 'INCREMENTAL_ROLLOUT_MODE', value: 'manual')
+ variables.append(key: "STAGING_ENABLED", value: "1")
+ variables.append(key: "INCREMENTAL_ROLLOUT_ENABLED", value: "1") # deprecated
+ variables.append(key: "INCREMENTAL_ROLLOUT_MODE", value: "manual")
elsif timed_incremental?
- variables.append(key: 'INCREMENTAL_ROLLOUT_MODE', value: 'timed')
+ variables.append(key: "INCREMENTAL_ROLLOUT_MODE", value: "timed")
end
end
end
diff --git a/app/models/project_custom_attribute.rb b/app/models/project_custom_attribute.rb
index 4e767cb3b26..2c6690c6c78 100644
--- a/app/models/project_custom_attribute.rb
+++ b/app/models/project_custom_attribute.rb
@@ -4,5 +4,5 @@ class ProjectCustomAttribute < ActiveRecord::Base
belongs_to :project
validates :project, :key, :value, presence: true
- validates :key, uniqueness: { scope: [:project_id] }
+ validates :key, uniqueness: {scope: [:project_id]}
end
diff --git a/app/models/project_daily_statistic.rb b/app/models/project_daily_statistic.rb
index ff115dd010f..8e14ad35dac 100644
--- a/app/models/project_daily_statistic.rb
+++ b/app/models/project_daily_statistic.rb
@@ -3,8 +3,8 @@
class ProjectDailyStatistic < ActiveRecord::Base
belongs_to :project
- scope :of_project, -> (project) { where(project: project) }
- scope :of_last_30_days, -> { where('date >= ?', 29.days.ago.utc.to_date) }
+ scope :of_project, ->(project) { where(project: project) }
+ scope :of_last_30_days, -> { where("date >= ?", 29.days.ago.utc.to_date) }
scope :sorted_by_date_desc, -> { order(project_id: :desc, date: :desc) }
scope :sum_fetch_count, -> { sum(:fetch_count) }
end
diff --git a/app/models/project_deploy_token.rb b/app/models/project_deploy_token.rb
index 719c492a1ff..eeb71065323 100644
--- a/app/models/project_deploy_token.rb
+++ b/app/models/project_deploy_token.rb
@@ -6,5 +6,5 @@ class ProjectDeployToken < ActiveRecord::Base
validates :deploy_token, presence: true
validates :project, presence: true
- validates :deploy_token_id, uniqueness: { scope: [:project_id] }
+ validates :deploy_token_id, uniqueness: {scope: [:project_id]}
end
diff --git a/app/models/project_feature.rb b/app/models/project_feature.rb
index f700090a493..41de4b6d131 100644
--- a/app/models/project_feature.rb
+++ b/app/models/project_feature.rb
@@ -22,8 +22,8 @@ class ProjectFeature < ActiveRecord::Base
ENABLED = 20
PUBLIC = 30
- FEATURES = %i(issues merge_requests wiki snippets builds repository pages).freeze
- PRIVATE_FEATURES_MIN_ACCESS_LEVEL = { merge_requests: Gitlab::Access::REPORTER }.freeze
+ FEATURES = %i[issues merge_requests wiki snippets builds repository pages].freeze
+ PRIVATE_FEATURES_MIN_ACCESS_LEVEL = {merge_requests: Gitlab::Access::REPORTER}.freeze
class << self
def access_level_attribute(feature)
@@ -117,10 +117,10 @@ class ProjectFeature < ActiveRecord::Base
validator = lambda do |field|
level = public_send(field) || ProjectFeature::ENABLED # rubocop:disable GitlabSecurity/PublicSend
not_allowed = level > repository_access_level
- self.errors.add(field, "cannot have higher visibility level than repository access level") if not_allowed
+ errors.add(field, "cannot have higher visibility level than repository access level") if not_allowed
end
- %i(merge_requests_access_level builds_access_level).each(&validator)
+ %i[merge_requests_access_level builds_access_level].each(&validator)
end
# Validates access level for other than pages cannot be PUBLIC
@@ -128,10 +128,10 @@ class ProjectFeature < ActiveRecord::Base
validator = lambda do |field|
level = public_send(field) || ProjectFeature::ENABLED # rubocop:disable GitlabSecurity/PublicSend
not_allowed = level > ProjectFeature::ENABLED
- self.errors.add(field, "cannot have public visibility level") if not_allowed
+ errors.add(field, "cannot have public visibility level") if not_allowed
end
- (FEATURES - %i(pages)).each {|f| validator.call("#{f}_access_level")}
+ (FEATURES - %i[pages]).each {|f| validator.call("#{f}_access_level")}
end
def get_permission(user, level)
diff --git a/app/models/project_group_link.rb b/app/models/project_group_link.rb
index bc3759142ae..9021a2b8f66 100644
--- a/app/models/project_group_link.rb
+++ b/app/models/project_group_link.rb
@@ -14,9 +14,9 @@ class ProjectGroupLink < ActiveRecord::Base
validates :project_id, presence: true
validates :group, presence: true
- validates :group_id, uniqueness: { scope: [:project_id], message: "already shared with this group" }
+ validates :group_id, uniqueness: {scope: [:project_id], message: "already shared with this group"}
validates :group_access, presence: true
- validates :group_access, inclusion: { in: Gitlab::Access.values }, presence: true
+ validates :group_access, inclusion: {in: Gitlab::Access.values}, presence: true
validate :different_group
after_commit :refresh_group_members_authorized_projects
@@ -30,20 +30,20 @@ class ProjectGroupLink < ActiveRecord::Base
end
def human_access
- self.class.access_options.key(self.group_access)
+ self.class.access_options.key(group_access)
end
private
def different_group
- return unless self.group && self.project
+ return unless group && project
- project_group = self.project.group
+ project_group = project.group
return unless project_group
group_ids = project_group.ancestors.map(&:id).push(project_group.id)
- if group_ids.include?(self.group.id)
+ if group_ids.include?(group.id)
errors.add(:base, "Project cannot be shared with the group it is in or one of its ancestors.")
end
end
diff --git a/app/models/project_import_data.rb b/app/models/project_import_data.rb
index aa0c121fe99..9ec8422523e 100644
--- a/app/models/project_import_data.rb
+++ b/app/models/project_import_data.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'carrierwave/orm/activerecord'
+require "carrierwave/orm/activerecord"
class ProjectImportData < ActiveRecord::Base
belongs_to :project, inverse_of: :import_data
attr_encrypted :credentials,
- key: Settings.attr_encrypted_db_key_base,
- marshal: true,
- encode: true,
- mode: :per_attribute_iv_and_salt,
- insecure_mode: true,
- algorithm: 'aes-256-cbc'
+ key: Settings.attr_encrypted_db_key_base,
+ marshal: true,
+ encode: true,
+ mode: :per_attribute_iv_and_salt,
+ insecure_mode: true,
+ algorithm: "aes-256-cbc"
serialize :data, JSON # rubocop:disable Cop/ActiveRecordSerialize
@@ -20,7 +20,7 @@ class ProjectImportData < ActiveRecord::Base
def symbolize_credentials
# bang doesn't work here - attr_encrypted makes it not to work
- self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
+ self.credentials = credentials.deep_symbolize_keys unless credentials.blank?
end
def merge_data(hash)
diff --git a/app/models/project_import_state.rb b/app/models/project_import_state.rb
index 488f0cb5971..4f2d499c77c 100644
--- a/app/models/project_import_state.rb
+++ b/app/models/project_import_state.rb
@@ -70,7 +70,7 @@ class ProjectImportState < ActiveRecord::Base
@errors = original_errors
end
- alias_method :no_import?, :none?
+ alias no_import? none?
def in_progress?
scheduled? || started?
@@ -78,7 +78,7 @@ class ProjectImportState < ActiveRecord::Base
def started?
# import? does SQL work so only run it if it looks like there's an import running
- status == 'started' && project.import?
+ status == "started" && project.import?
end
def remove_jid
diff --git a/app/models/project_label.rb b/app/models/project_label.rb
index d0b16cc98b4..0b5c6ce7916 100644
--- a/app/models/project_label.rb
+++ b/app/models/project_label.rb
@@ -15,7 +15,7 @@ class ProjectLabel < Label
alias_attribute :subject, :project
def subject_foreign_key
- 'project_id'
+ "project_id"
end
def to_reference(target_project = nil, format: :id, full: false)
@@ -27,14 +27,14 @@ class ProjectLabel < Label
def title_must_not_exist_at_group_level
return unless group.present? && title_changed?
- if group.labels.with_title(self.title).exists?
+ if group.labels.with_title(title).exists?
errors.add(:title, :label_already_exists_at_group_level, group: group.name)
end
end
def permitted_numbers_of_priorities
if priorities && priorities.size > MAX_NUMBER_OF_PRIORITIES
- errors.add(:priorities, 'Number of permitted priorities exceeded')
+ errors.add(:priorities, "Number of permitted priorities exceeded")
end
end
end
diff --git a/app/models/project_services/asana_service.rb b/app/models/project_services/asana_service.rb
index cc5f1207653..b02fac2994a 100644
--- a/app/models/project_services/asana_service.rb
+++ b/app/models/project_services/asana_service.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'asana'
+require "asana"
class AsanaService < Service
prop_accessor :api_key, :restrict_to_branch
validates :api_key, presence: true, if: :activated?
def title
- 'Asana'
+ "Asana"
end
def description
- 'Asana - Teamwork without email'
+ "Asana - Teamwork without email"
end
def help
@@ -28,27 +28,27 @@ http://app.asana.com/-/account_api'
end
def self.to_param
- 'asana'
+ "asana"
end
def fields
[
{
- type: 'text',
- name: 'api_key',
- placeholder: 'User Personal Access Token. User must have access to task, all comments will be attributed to this user.',
- required: true
+ type: "text",
+ name: "api_key",
+ placeholder: "User Personal Access Token. User must have access to task, all comments will be attributed to this user.",
+ required: true,
},
{
- type: 'text',
- name: 'restrict_to_branch',
- placeholder: 'Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches.'
- }
+ type: "text",
+ name: "restrict_to_branch",
+ placeholder: "Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches.",
+ },
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def client
diff --git a/app/models/project_services/assembla_service.rb b/app/models/project_services/assembla_service.rb
index 60575e45a90..a627c31363a 100644
--- a/app/models/project_services/assembla_service.rb
+++ b/app/models/project_services/assembla_service.rb
@@ -5,32 +5,32 @@ class AssemblaService < Service
validates :token, presence: true, if: :activated?
def title
- 'Assembla'
+ "Assembla"
end
def description
- 'Project Management Software (Source Commits Endpoint)'
+ "Project Management Software (Source Commits Endpoint)"
end
def self.to_param
- 'assembla'
+ "assembla"
end
def fields
[
- { type: 'text', name: 'token', placeholder: '', required: true },
- { type: 'text', name: 'subdomain', placeholder: '' }
+ {type: "text", name: "token", placeholder: "", required: true},
+ {type: "text", name: "subdomain", placeholder: ""},
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}"
- Gitlab::HTTP.post(url, body: { payload: data }.to_json, headers: { 'Content-Type' => 'application/json' })
+ Gitlab::HTTP.post(url, body: {payload: data}.to_json, headers: {"Content-Type" => "application/json"})
end
end
diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb
index 71f5607dbdb..1fce9af9deb 100644
--- a/app/models/project_services/bamboo_service.rb
+++ b/app/models/project_services/bamboo_service.rb
@@ -31,30 +31,30 @@ class BambooService < CiService
end
def title
- 'Atlassian Bamboo CI'
+ "Atlassian Bamboo CI"
end
def description
- 'A continuous integration and build server'
+ "A continuous integration and build server"
end
def help
- 'You must set up automatic revision labeling and a repository trigger in Bamboo.'
+ "You must set up automatic revision labeling and a repository trigger in Bamboo."
end
def self.to_param
- 'bamboo'
+ "bamboo"
end
def fields
[
- { type: 'text', name: 'bamboo_url',
- placeholder: 'Bamboo root URL like https://bamboo.example.com', required: true },
- { type: 'text', name: 'build_key',
- placeholder: 'Bamboo build plan key like KEY', required: true },
- { type: 'text', name: 'username',
- placeholder: 'A user with API access, if applicable' },
- { type: 'password', name: 'password' }
+ {type: "text", name: "bamboo_url",
+ placeholder: "Bamboo root URL like https://bamboo.example.com", required: true,},
+ {type: "text", name: "build_key",
+ placeholder: "Bamboo build plan key like KEY", required: true,},
+ {type: "text", name: "username",
+ placeholder: "A user with API access, if applicable",},
+ {type: "password", name: "password"},
]
end
@@ -69,13 +69,13 @@ class BambooService < CiService
def execute(data)
return unless supported_events.include?(data[:object_kind])
- get_path("updateAndBuild.action", { buildKey: build_key })
+ get_path("updateAndBuild.action", {buildKey: build_key})
end
def calculate_reactive_cache(sha, ref)
response = get_path("rest/api/latest/result/byChangeset/#{sha}")
- { build_page: read_build_page(response), commit_status: read_commit_status(response) }
+ {build_page: read_build_page(response), commit_status: read_commit_status(response)}
end
private
@@ -84,7 +84,7 @@ class BambooService < CiService
return if response.code != 200
# May be nil if no result, a single result hash, or an array if multiple results for a given changeset.
- result = response.dig('results', 'results', 'result')
+ result = response.dig("results", "results", "result")
# In case of multiple results, arbitrarily assume the last one is the most relevant.
return result.last if result.is_a?(Array)
@@ -100,7 +100,7 @@ class BambooService < CiService
build_key
else
# If actual build link is available, go to build result page.
- result.dig('planResultKey', 'key')
+ result.dig("planResultKey", "key")
end
build_url("browse/#{key}")
@@ -112,19 +112,19 @@ class BambooService < CiService
result = get_build_result(response)
status =
if result.blank?
- 'Pending'
+ "Pending"
else
- result.dig('buildState')
+ result.dig("buildState")
end
return :error unless status.present?
- if status.include?('Success')
- 'success'
- elsif status.include?('Failed')
- 'failed'
- elsif status.include?('Pending')
- 'pending'
+ if status.include?("Success")
+ "success"
+ elsif status.include?("Failed")
+ "failed"
+ elsif status.include?("Pending")
+ "pending"
else
:error
end
@@ -140,14 +140,14 @@ class BambooService < CiService
if username.blank? && password.blank?
Gitlab::HTTP.get(url, verify: false, query: query_params)
else
- query_params[:os_authType] = 'basic'
+ query_params[:os_authType] = "basic"
Gitlab::HTTP.get(url,
- verify: false,
- query: query_params,
- basic_auth: {
- username: username,
- password: password
- })
+ verify: false,
+ query: query_params,
+ basic_auth: {
+ username: username,
+ password: password,
+ })
end
end
end
diff --git a/app/models/project_services/bugzilla_service.rb b/app/models/project_services/bugzilla_service.rb
index 1a2bb6a171b..e5828db3af6 100644
--- a/app/models/project_services/bugzilla_service.rb
+++ b/app/models/project_services/bugzilla_service.rb
@@ -6,22 +6,22 @@ class BugzillaService < IssueTrackerService
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
def title
- if self.properties && self.properties['title'].present?
- self.properties['title']
+ if properties && properties["title"].present?
+ properties["title"]
else
- 'Bugzilla'
+ "Bugzilla"
end
end
def description
- if self.properties && self.properties['description'].present?
- self.properties['description']
+ if properties && properties["description"].present?
+ properties["description"]
else
- 'Bugzilla issue tracker'
+ "Bugzilla issue tracker"
end
end
def self.to_param
- 'bugzilla'
+ "bugzilla"
end
end
diff --git a/app/models/project_services/buildkite_service.rb b/app/models/project_services/buildkite_service.rb
index 43edfde851c..c34da0d155d 100644
--- a/app/models/project_services/buildkite_service.rb
+++ b/app/models/project_services/buildkite_service.rb
@@ -5,7 +5,7 @@ require "addressable/uri"
class BuildkiteService < CiService
include ReactiveService
- ENDPOINT = "https://buildkite.com".freeze
+ ENDPOINT = "https://buildkite.com"
prop_accessor :project_url, :token
boolean_accessor :enable_ssl_verification
@@ -16,7 +16,7 @@ class BuildkiteService < CiService
after_save :compose_service_hook, if: :activated?
def webhook_url
- "#{buildkite_endpoint('webhook')}/deliver/#{webhook_token}"
+ "#{buildkite_endpoint("webhook")}/deliver/#{webhook_token}"
end
def compose_service_hook
@@ -37,7 +37,7 @@ class BuildkiteService < CiService
end
def commit_status_path(sha)
- "#{buildkite_endpoint('gitlab')}/status/#{status_token}.json?commit=#{sha}"
+ "#{buildkite_endpoint("gitlab")}/status/#{status_token}.json?commit=#{sha}"
end
def build_page(sha, ref)
@@ -45,30 +45,30 @@ class BuildkiteService < CiService
end
def title
- 'Buildkite'
+ "Buildkite"
end
def description
- 'Continuous integration and deployments'
+ "Continuous integration and deployments"
end
def self.to_param
- 'buildkite'
+ "buildkite"
end
def fields
[
- { type: 'text',
- name: 'token',
- placeholder: 'Buildkite project GitLab token', required: true },
+ {type: "text",
+ name: "token",
+ placeholder: "Buildkite project GitLab token", required: true,},
- { type: 'text',
- name: 'project_url',
- placeholder: "#{ENDPOINT}/example/project", required: true },
+ {type: "text",
+ name: "project_url",
+ placeholder: "#{ENDPOINT}/example/project", required: true,},
- { type: 'checkbox',
- name: 'enable_ssl_verification',
- title: "Enable SSL verification" }
+ {type: "checkbox",
+ name: "enable_ssl_verification",
+ title: "Enable SSL verification",},
]
end
@@ -76,13 +76,13 @@ class BuildkiteService < CiService
response = Gitlab::HTTP.get(commit_status_path(sha), verify: false)
status =
- if response.code == 200 && response['status']
- response['status']
+ if response.code == 200 && response["status"]
+ response["status"]
else
:error
end
- { commit_status: status }
+ {commit_status: status}
end
private
@@ -97,7 +97,7 @@ class BuildkiteService < CiService
def token_parts
if token.present?
- token.split(':')
+ token.split(":")
else
[]
end
@@ -106,7 +106,7 @@ class BuildkiteService < CiService
def buildkite_endpoint(subdomain = nil)
if subdomain.present?
uri = Addressable::URI.parse(ENDPOINT)
- new_endpoint = "#{uri.scheme || 'http'}://#{subdomain}.#{uri.host}"
+ new_endpoint = "#{uri.scheme || "http"}://#{subdomain}.#{uri.host}"
if uri.port.present?
"#{new_endpoint}:#{uri.port}"
diff --git a/app/models/project_services/builds_email_service.rb b/app/models/project_services/builds_email_service.rb
index f2295a95b60..8adf3cd5fcf 100644
--- a/app/models/project_services/builds_email_service.rb
+++ b/app/models/project_services/builds_email_service.rb
@@ -4,7 +4,7 @@
# We should also by then remove BuildsEmailService from database
class BuildsEmailService < Service
def self.to_param
- 'builds_email'
+ "builds_email"
end
def self.supported_events
diff --git a/app/models/project_services/campfire_service.rb b/app/models/project_services/campfire_service.rb
index 1d7877a1fb5..fdd38ef8a73 100644
--- a/app/models/project_services/campfire_service.rb
+++ b/app/models/project_services/campfire_service.rb
@@ -5,34 +5,34 @@ class CampfireService < Service
validates :token, presence: true, if: :activated?
def title
- 'Campfire'
+ "Campfire"
end
def description
- 'Simple web-based real-time group chat'
+ "Simple web-based real-time group chat"
end
def self.to_param
- 'campfire'
+ "campfire"
end
def fields
[
- { type: 'text', name: 'token', placeholder: '', required: true },
- { type: 'text', name: 'subdomain', placeholder: '' },
- { type: 'text', name: 'room', placeholder: '' }
+ {type: "text", name: "token", placeholder: "", required: true},
+ {type: "text", name: "subdomain", placeholder: ""},
+ {type: "text", name: "room", placeholder: ""},
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
message = build_message(data)
- speak(self.room, message, auth)
+ speak(room, message, auth)
end
private
@@ -47,8 +47,8 @@ class CampfireService < Service
@auth ||= {
basic_auth: {
username: token,
- password: 'X'
- }
+ password: "X",
+ },
}
end
@@ -63,10 +63,10 @@ class CampfireService < Service
body = {
body: {
message: {
- type: 'TextMessage',
- body: message
- }
- }
+ type: "TextMessage",
+ body: message,
+ },
+ },
}
res = Gitlab::HTTP.post(path, base_uri: base_uri, **auth.merge(body))
res.code == 201 ? res : nil
diff --git a/app/models/project_services/chat_message/base_message.rb b/app/models/project_services/chat_message/base_message.rb
index 8c68ddc40f2..4b75b95f82e 100644
--- a/app/models/project_services/chat_message/base_message.rb
+++ b/app/models/project_services/chat_message/base_message.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'slack-notifier'
+require "slack-notifier"
module ChatMessage
class BaseMessage
@@ -61,7 +61,7 @@ module ChatMessage
end
def attachment_color
- '#345'
+ "#345"
end
def link(text, url)
@@ -71,9 +71,9 @@ module ChatMessage
def pretty_duration(seconds)
parse_string =
if duration < 1.hour
- '%M:%S'
+ "%M:%S"
else
- '%H:%M:%S'
+ "%H:%M:%S"
end
Time.at(seconds).utc.strftime(parse_string)
diff --git a/app/models/project_services/chat_message/issue_message.rb b/app/models/project_services/chat_message/issue_message.rb
index 0cdcfcf0237..f97b41f01b7 100644
--- a/app/models/project_services/chat_message/issue_message.rb
+++ b/app/models/project_services/chat_message/issue_message.rb
@@ -19,7 +19,7 @@ module ChatMessage
@issue_url = obj_attr[:url]
@action = obj_attr[:action]
@state = obj_attr[:state]
- @description = obj_attr[:description] || ''
+ @description = obj_attr[:description] || ""
end
def attachments
@@ -34,7 +34,7 @@ module ChatMessage
title: "Issue #{state} by #{user_combined_name}",
subtitle: "in #{project_link}",
text: issue_link,
- image: user_avatar
+ image: user_avatar,
}
end
@@ -57,7 +57,7 @@ module ChatMessage
title: issue_title,
title_link: issue_url,
text: format(description),
- color: "#C95823"
+ color: "#C95823",
}]
end
diff --git a/app/models/project_services/chat_message/merge_message.rb b/app/models/project_services/chat_message/merge_message.rb
index 6b7a35aaa75..18f1e6e3058 100644
--- a/app/models/project_services/chat_message/merge_message.rb
+++ b/app/models/project_services/chat_message/merge_message.rb
@@ -29,14 +29,14 @@ module ChatMessage
title: "Merge Request #{state_or_action_text} by #{user_combined_name}",
subtitle: "in #{project_link}",
text: merge_request_link,
- image: user_avatar
+ image: user_avatar,
}
end
private
def format_title(title)
- '*' + title.lines.first.chomp + '*'
+ "*" + title.lines.first.chomp + "*"
end
def message
diff --git a/app/models/project_services/chat_message/note_message.rb b/app/models/project_services/chat_message/note_message.rb
index 741474fb27b..f83a4d58ae1 100644
--- a/app/models/project_services/chat_message/note_message.rb
+++ b/app/models/project_services/chat_message/note_message.rb
@@ -23,7 +23,7 @@ module ChatMessage
create_merge_note(params[:merge_request])
when "Snippet"
create_snippet_note(params[:snippet])
- end
+ end
end
def attachments
@@ -34,17 +34,17 @@ module ChatMessage
def activity
{
- title: "#{user_combined_name} #{link('commented on ' + target, note_url)}",
+ title: "#{user_combined_name} #{link("commented on " + target, note_url)}",
subtitle: "in #{project_link}",
text: formatted_title,
- image: user_avatar
+ image: user_avatar,
}
end
private
def message
- "#{user_combined_name} #{link('commented on ' + target, note_url)} in #{project_link}: *#{formatted_title}*"
+ "#{user_combined_name} #{link("commented on " + target, note_url)} in #{project_link}: *#{formatted_title}*"
end
def format_title(title)
@@ -74,7 +74,7 @@ module ChatMessage
end
def description_message
- [{ text: format(note), color: attachment_color }]
+ [{text: format(note), color: attachment_color}]
end
def project_link
diff --git a/app/models/project_services/chat_message/pipeline_message.rb b/app/models/project_services/chat_message/pipeline_message.rb
index 62aec4351db..325d036dc3a 100644
--- a/app/models/project_services/chat_message/pipeline_message.rb
+++ b/app/models/project_services/chat_message/pipeline_message.rb
@@ -11,10 +11,10 @@ module ChatMessage
def initialize(data)
super
- @user_name = data.dig(:user, :username) || 'API'
+ @user_name = data.dig(:user, :username) || "API"
pipeline_attributes = data[:object_attributes]
- @ref_type = pipeline_attributes[:tag] ? 'tag' : 'branch'
+ @ref_type = pipeline_attributes[:tag] ? "tag" : "branch"
@ref = pipeline_attributes[:ref]
@status = pipeline_attributes[:status]
@duration = pipeline_attributes[:duration].to_i
@@ -22,13 +22,13 @@ module ChatMessage
end
def pretext
- ''
+ ""
end
def attachments
return message if markdown
- [{ text: format(message), color: attachment_color }]
+ [{text: format(message), color: attachment_color}]
end
def activity
@@ -36,7 +36,7 @@ module ChatMessage
title: "Pipeline #{pipeline_link} of #{ref_type} #{branch_link} by #{user_combined_name} #{humanized_status}",
subtitle: "in #{project_link}",
text: "in #{pretty_duration(duration)}",
- image: user_avatar || ''
+ image: user_avatar || "",
}
end
@@ -48,18 +48,18 @@ module ChatMessage
def humanized_status
case status
- when 'success'
- 'passed'
+ when "success"
+ "passed"
else
status
end
end
def attachment_color
- if status == 'success'
- 'good'
+ if status == "success"
+ "good"
else
- 'danger'
+ "danger"
end
end
diff --git a/app/models/project_services/chat_message/push_message.rb b/app/models/project_services/chat_message/push_message.rb
index 5dd0414b7e6..413fb907796 100644
--- a/app/models/project_services/chat_message/push_message.rb
+++ b/app/models/project_services/chat_message/push_message.rb
@@ -14,7 +14,7 @@ module ChatMessage
@after = params[:after]
@before = params[:before]
@commits = params.fetch(:commits, [])
- @ref_type = Gitlab::Git.tag_ref?(params[:ref]) ? 'tag' : 'branch'
+ @ref_type = Gitlab::Git.tag_ref?(params[:ref]) ? "tag" : "branch"
@ref = Gitlab::Git.ref_name(params[:ref])
end
@@ -30,7 +30,7 @@ module ChatMessage
title: humanized_action(short: true),
subtitle: "in #{project_link}",
text: compare_link,
- image: user_avatar
+ image: user_avatar,
}
end
@@ -40,7 +40,7 @@ module ChatMessage
action, ref_link, target_link = compose_action_details
text = [user_combined_name, action, ref_type, ref_link]
text << target_link unless short
- text.join(' ')
+ text.join(" ")
end
def message
@@ -56,7 +56,7 @@ module ChatMessage
end
def commit_message_attachments
- [{ text: format(commit_messages), color: attachment_color }]
+ [{text: format(commit_messages), color: attachment_color}]
end
def compose_commit_message(commit)
@@ -98,16 +98,16 @@ module ChatMessage
def compose_action_details
if new_branch?
- ['pushed new', branch_link, "to #{project_link}"]
+ ["pushed new", branch_link, "to #{project_link}"]
elsif removed_branch?
- ['removed', ref, "from #{project_link}"]
+ ["removed", ref, "from #{project_link}"]
else
- ['pushed to', branch_link, "of #{project_link} (#{compare_link})"]
+ ["pushed to", branch_link, "of #{project_link} (#{compare_link})"]
end
end
def attachment_color
- '#345'
+ "#345"
end
end
end
diff --git a/app/models/project_services/chat_message/wiki_page_message.rb b/app/models/project_services/chat_message/wiki_page_message.rb
index b605d289278..fe60d40bc2b 100644
--- a/app/models/project_services/chat_message/wiki_page_message.rb
+++ b/app/models/project_services/chat_message/wiki_page_message.rb
@@ -36,7 +36,7 @@ module ChatMessage
title: "#{user_combined_name} #{action} #{wiki_page_link}",
subtitle: "in #{project_link}",
text: title,
- image: user_avatar
+ image: user_avatar,
}
end
@@ -47,7 +47,7 @@ module ChatMessage
end
def description_message
- [{ text: format(@description), color: attachment_color }]
+ [{text: format(@description), color: attachment_color}]
end
def project_link
diff --git a/app/models/project_services/chat_notification_service.rb b/app/models/project_services/chat_notification_service.rb
index c10ee07ccf4..b1b8fbea763 100644
--- a/app/models/project_services/chat_notification_service.rb
+++ b/app/models/project_services/chat_notification_service.rb
@@ -5,7 +5,7 @@
class ChatNotificationService < Service
include ChatMessage
- default_value_for :category, 'chat'
+ default_value_for :category, "chat"
prop_accessor :webhook, :username, :channel
boolean_accessor :notify_only_broken_pipelines, :notify_only_default_branch
@@ -14,7 +14,7 @@ class ChatNotificationService < Service
def initialize_properties
# Custom serialized properties initialization
- self.supported_events.each { |event| self.class.prop_accessor(event_channel_name(event)) }
+ supported_events.each { |event| self.class.prop_accessor(event_channel_name(event)) }
if properties.nil?
self.properties = {}
@@ -24,11 +24,11 @@ class ChatNotificationService < Service
end
def confidential_issue_channel
- properties['confidential_issue_channel'].presence || properties['issue_channel']
+ properties["confidential_issue_channel"].presence || properties["issue_channel"]
end
def confidential_note_channel
- properties['confidential_note_channel'].presence || properties['note_channel']
+ properties["confidential_note_channel"].presence || properties["note_channel"]
end
def self.supported_events
@@ -42,10 +42,10 @@ class ChatNotificationService < Service
def default_fields
[
- { type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}", required: true },
- { type: 'text', name: 'username', placeholder: 'e.g. GitLab' },
- { type: 'checkbox', name: 'notify_only_broken_pipelines' },
- { type: 'checkbox', name: 'notify_only_default_branch' }
+ {type: "text", name: "webhook", placeholder: "e.g. #{webhook_placeholder}", required: true},
+ {type: "text", name: "username", placeholder: "e.g. GitLab"},
+ {type: "checkbox", name: "notify_only_broken_pipelines"},
+ {type: "checkbox", name: "notify_only_default_branch"},
]
end
@@ -87,7 +87,7 @@ class ChatNotificationService < Service
end
def global_fields
- fields.reject { |field| field[:name].end_with?('channel') }
+ fields.reject { |field| field[:name].end_with?("channel") }
end
def default_channel_placeholder
@@ -127,12 +127,12 @@ class ChatNotificationService < Service
def get_channel_field(event)
field_name = event_channel_name(event)
- self.public_send(field_name) # rubocop:disable GitlabSecurity/PublicSend
+ public_send(field_name) # rubocop:disable GitlabSecurity/PublicSend
end
def build_event_channels
supported_events.reduce([]) do |channels, event|
- channels << { type: 'text', name: event_channel_name(event), placeholder: default_channel_placeholder }
+ channels << {type: "text", name: event_channel_name(event), placeholder: default_channel_placeholder}
end
end
@@ -141,7 +141,7 @@ class ChatNotificationService < Service
end
def project_name
- project.full_name.gsub(/\s/, '')
+ project.full_name.gsub(/\s/, "")
end
def project_url
@@ -149,7 +149,7 @@ class ChatNotificationService < Service
end
def update?(data)
- data[:object_attributes][:action] == 'update'
+ data[:object_attributes][:action] == "update"
end
def should_pipeline_be_notified?(data)
@@ -157,24 +157,24 @@ class ChatNotificationService < Service
end
def notify_for_ref?(data)
- return true if data[:object_kind] == 'tag_push'
+ return true if data[:object_kind] == "tag_push"
return true if data.dig(:object_attributes, :tag)
return true unless notify_only_default_branch?
ref = if data[:ref]
- Gitlab::Git.ref_name(data[:ref])
- else
- data.dig(:object_attributes, :ref)
- end
+ Gitlab::Git.ref_name(data[:ref])
+ else
+ data.dig(:object_attributes, :ref)
+ end
ref == project.default_branch
end
def notify_for_pipeline?(data)
case data[:object_attributes][:status]
- when 'success'
+ when "success"
!notify_only_broken_pipelines?
- when 'failed'
+ when "failed"
true
else
false
diff --git a/app/models/project_services/ci_service.rb b/app/models/project_services/ci_service.rb
index f0ef2d925ab..c59f8d46504 100644
--- a/app/models/project_services/ci_service.rb
+++ b/app/models/project_services/ci_service.rb
@@ -4,14 +4,14 @@
# List methods you need to implement to get your CI service
# working with GitLab Merge Requests
class CiService < Service
- default_value_for :category, 'ci'
+ default_value_for :category, "ci"
def valid_token?(token)
- self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
+ respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
end
def self.supported_events
- %w(push)
+ %w[push]
end
# Return complete url to build page
diff --git a/app/models/project_services/custom_issue_tracker_service.rb b/app/models/project_services/custom_issue_tracker_service.rb
index b8f8072869c..f09a82d25c9 100644
--- a/app/models/project_services/custom_issue_tracker_service.rb
+++ b/app/models/project_services/custom_issue_tracker_service.rb
@@ -6,36 +6,36 @@ class CustomIssueTrackerService < IssueTrackerService
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
def title
- if self.properties && self.properties['title'].present?
- self.properties['title']
+ if properties && properties["title"].present?
+ properties["title"]
else
- 'Custom Issue Tracker'
+ "Custom Issue Tracker"
end
end
def title=(value)
- self.properties['title'] = value if self.properties
+ properties["title"] = value if properties
end
def description
- if self.properties && self.properties['description'].present?
- self.properties['description']
+ if properties && properties["description"].present?
+ properties["description"]
else
- 'Custom issue tracker'
+ "Custom issue tracker"
end
end
def self.to_param
- 'custom_issue_tracker'
+ "custom_issue_tracker"
end
def fields
[
- { type: 'text', name: 'title', placeholder: title },
- { type: 'text', name: 'description', placeholder: description },
- { type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
- { type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true },
- { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url', required: true }
+ {type: "text", name: "title", placeholder: title},
+ {type: "text", name: "description", placeholder: description},
+ {type: "text", name: "project_url", placeholder: "Project url", required: true},
+ {type: "text", name: "issues_url", placeholder: "Issue url", required: true},
+ {type: "text", name: "new_issue_url", placeholder: "New Issue url", required: true},
]
end
end
diff --git a/app/models/project_services/deployment_service.rb b/app/models/project_services/deployment_service.rb
index 80aa2101509..f1bc78a3736 100644
--- a/app/models/project_services/deployment_service.rb
+++ b/app/models/project_services/deployment_service.rb
@@ -5,10 +5,10 @@
# These services integrate with a deployment solution like Kubernetes/OpenShift,
# Mesosphere, etc, to provide additional features to environments.
class DeploymentService < Service
- default_value_for :category, 'deployment'
+ default_value_for :category, "deployment"
def self.supported_events
- %w()
+ %w[]
end
def predefined_variables(project:)
diff --git a/app/models/project_services/discord_service.rb b/app/models/project_services/discord_service.rb
index 21afd14dbff..fcecdafe3e8 100644
--- a/app/models/project_services/discord_service.rb
+++ b/app/models/project_services/discord_service.rb
@@ -35,9 +35,9 @@ class DiscordService < ChatNotificationService
def default_fields
[
- { type: "text", name: "webhook", placeholder: "e.g. https://discordapp.com/api/webhooks/…" },
- { type: "checkbox", name: "notify_only_broken_pipelines" },
- { type: "checkbox", name: "notify_only_default_branch" }
+ {type: "text", name: "webhook", placeholder: "e.g. https://discordapp.com/api/webhooks/…"},
+ {type: "checkbox", name: "notify_only_broken_pipelines"},
+ {type: "checkbox", name: "notify_only_default_branch"},
]
end
diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb
index 5ccc2f019cb..6fc476b34cf 100644
--- a/app/models/project_services/drone_ci_service.rb
+++ b/app/models/project_services/drone_ci_service.rb
@@ -21,11 +21,11 @@ class DroneCiService < CiService
def execute(data)
case data[:object_kind]
- when 'push'
+ when "push"
service_hook.execute(data) if push_valid?(data)
- when 'merge_request'
+ when "merge_request"
service_hook.execute(data) if merge_request_valid?(data)
- when 'tag_push'
+ when "tag_push"
service_hook.execute(data) if tag_push_valid?(data)
end
end
@@ -35,13 +35,14 @@ class DroneCiService < CiService
end
def self.supported_events
- %w(push merge_request tag_push)
+ %w[push merge_request tag_push]
end
def commit_status_path(sha, ref)
Gitlab::Utils.append_path(
drone_url,
- "gitlab/#{project.full_path}/commits/#{sha}?branch=#{URI.encode(ref.to_s)}&access_token=#{token}")
+ "gitlab/#{project.full_path}/commits/#{sha}?branch=#{URI.encode(ref.to_s)}&access_token=#{token}"
+ )
end
def commit_status(sha, ref)
@@ -52,11 +53,11 @@ class DroneCiService < CiService
response = Gitlab::HTTP.get(commit_status_path(sha, ref), verify: enable_ssl_verification)
status =
- if response.code == 200 && response['status']
- case response['status']
- when 'killed'
+ if response.code == 200 && response["status"]
+ case response["status"]
+ when "killed"
:canceled
- when 'failure', 'error'
+ when "failure", "error"
# Because drone return error if some test env failed
:failed
else
@@ -66,34 +67,35 @@ class DroneCiService < CiService
:error
end
- { commit_status: status }
+ {commit_status: status}
rescue Errno::ECONNREFUSED
- { commit_status: :error }
+ {commit_status: :error}
end
def build_page(sha, ref)
Gitlab::Utils.append_path(
drone_url,
- "gitlab/#{project.full_path}/redirect/commits/#{sha}?branch=#{URI.encode(ref.to_s)}")
+ "gitlab/#{project.full_path}/redirect/commits/#{sha}?branch=#{URI.encode(ref.to_s)}"
+ )
end
def title
- 'Drone CI'
+ "Drone CI"
end
def description
- 'Drone is a Continuous Integration platform built on Docker, written in Go'
+ "Drone is a Continuous Integration platform built on Docker, written in Go"
end
def self.to_param
- 'drone_ci'
+ "drone_ci"
end
def fields
[
- { type: 'text', name: 'token', placeholder: 'Drone CI project specific token', required: true },
- { type: 'text', name: 'drone_url', placeholder: 'http://drone.example.com', required: true },
- { type: 'checkbox', name: 'enable_ssl_verification', title: "Enable SSL verification" }
+ {type: "text", name: "token", placeholder: "Drone CI project specific token", required: true},
+ {type: "text", name: "drone_url", placeholder: "http://drone.example.com", required: true},
+ {type: "checkbox", name: "enable_ssl_verification", title: "Enable SSL verification"},
]
end
@@ -112,7 +114,7 @@ class DroneCiService < CiService
end
def merge_request_valid?(data)
- data[:object_attributes][:state] == 'opened' &&
+ data[:object_attributes][:state] == "opened" &&
MergeRequest.state_machines[:merge_status].check_state?(data[:object_attributes][:merge_status])
end
end
diff --git a/app/models/project_services/emails_on_push_service.rb b/app/models/project_services/emails_on_push_service.rb
index fb73d430fb1..cd1ff179243 100644
--- a/app/models/project_services/emails_on_push_service.rb
+++ b/app/models/project_services/emails_on_push_service.rb
@@ -7,19 +7,19 @@ class EmailsOnPushService < Service
validates :recipients, presence: true, if: :valid_recipients?
def title
- 'Emails on push'
+ "Emails on push"
end
def description
- 'Email the commits and diff of each push to a list of recipients.'
+ "Email the commits and diff of each push to a list of recipients."
end
def self.to_param
- 'emails_on_push'
+ "emails_on_push"
end
def self.supported_events
- %w(push tag_push)
+ %w[push tag_push]
end
def execute(push_data)
@@ -30,26 +30,26 @@ class EmailsOnPushService < Service
recipients,
push_data,
send_from_committer_email: send_from_committer_email?,
- disable_diffs: disable_diffs?
+ disable_diffs: disable_diffs?
)
end
def send_from_committer_email?
- Gitlab::Utils.to_boolean(self.send_from_committer_email)
+ Gitlab::Utils.to_boolean(send_from_committer_email)
end
def disable_diffs?
- Gitlab::Utils.to_boolean(self.disable_diffs)
+ Gitlab::Utils.to_boolean(disable_diffs)
end
def fields
domains = Notify.allowed_email_domains.map { |domain| "user@#{domain}" }.join(", ")
[
- { type: 'checkbox', name: 'send_from_committer_email', title: "Send from committer",
- help: "Send notifications from the committer's email address if the domain is part of the domain GitLab is running on (e.g. #{domains})." },
- { type: 'checkbox', name: 'disable_diffs', title: "Disable code diffs",
- help: "Don't include possibly sensitive code diffs in notification body." },
- { type: 'textarea', name: 'recipients', placeholder: 'Emails separated by whitespace' }
+ {type: "checkbox", name: "send_from_committer_email", title: "Send from committer",
+ help: "Send notifications from the committer's email address if the domain is part of the domain GitLab is running on (e.g. #{domains}).",},
+ {type: "checkbox", name: "disable_diffs", title: "Disable code diffs",
+ help: "Don't include possibly sensitive code diffs in notification body.",},
+ {type: "textarea", name: "recipients", placeholder: "Emails separated by whitespace"},
]
end
end
diff --git a/app/models/project_services/external_wiki_service.rb b/app/models/project_services/external_wiki_service.rb
index d2835c6ac82..b073af4a73c 100644
--- a/app/models/project_services/external_wiki_service.rb
+++ b/app/models/project_services/external_wiki_service.rb
@@ -6,31 +6,35 @@ class ExternalWikiService < Service
validates :external_wiki_url, presence: true, public_url: true, if: :activated?
def title
- 'External Wiki'
+ "External Wiki"
end
def description
- 'Replaces the link to the internal wiki with a link to an external wiki.'
+ "Replaces the link to the internal wiki with a link to an external wiki."
end
def self.to_param
- 'external_wiki'
+ "external_wiki"
end
def fields
[
- { type: 'text', name: 'external_wiki_url', placeholder: 'The URL of the external Wiki', required: true }
+ {type: "text", name: "external_wiki_url", placeholder: "The URL of the external Wiki", required: true},
]
end
def execute(_data)
- @response = Gitlab::HTTP.get(properties['external_wiki_url'], verify: true) rescue nil
+ @response = begin
+ Gitlab::HTTP.get(properties["external_wiki_url"], verify: true)
+ rescue
+ nil
+ end
if @response != 200
nil
end
end
def self.supported_events
- %w()
+ %w[]
end
end
diff --git a/app/models/project_services/flowdock_service.rb b/app/models/project_services/flowdock_service.rb
index 76624263aab..055941d1a62 100644
--- a/app/models/project_services/flowdock_service.rb
+++ b/app/models/project_services/flowdock_service.rb
@@ -5,25 +5,25 @@ class FlowdockService < Service
validates :token, presence: true, if: :activated?
def title
- 'Flowdock'
+ "Flowdock"
end
def description
- 'Flowdock is a collaboration web app for technical teams.'
+ "Flowdock is a collaboration web app for technical teams."
end
def self.to_param
- 'flowdock'
+ "flowdock"
end
def fields
[
- { type: 'text', name: 'token', placeholder: 'Flowdock Git source token', required: true }
+ {type: "text", name: "token", placeholder: "Flowdock Git source token", required: true},
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb
index fa9abf58e62..5af972c20b8 100644
--- a/app/models/project_services/gitlab_issue_tracker_service.rb
+++ b/app/models/project_services/gitlab_issue_tracker_service.rb
@@ -10,7 +10,7 @@ class GitlabIssueTrackerService < IssueTrackerService
default_value_for :default, true
def self.to_param
- 'gitlab'
+ "gitlab"
end
def project_url
diff --git a/app/models/project_services/hangouts_chat_service.rb b/app/models/project_services/hangouts_chat_service.rb
index 272cd0f4e47..ea42d64ede9 100644
--- a/app/models/project_services/hangouts_chat_service.rb
+++ b/app/models/project_services/hangouts_chat_service.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'hangouts_chat'
+require "hangouts_chat"
class HangoutsChatService < ChatNotificationService
def title
- 'Hangouts Chat'
+ "Hangouts Chat"
end
def description
- 'Receive event notifications in Google Hangouts Chat'
+ "Receive event notifications in Google Hangouts Chat"
end
def self.to_param
- 'hangouts_chat'
+ "hangouts_chat"
end
def help
@@ -32,14 +32,14 @@ class HangoutsChatService < ChatNotificationService
end
def webhook_placeholder
- 'https://chat.googleapis.com/v1/spaces…'
+ "https://chat.googleapis.com/v1/spaces…"
end
def default_fields
[
- { type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}" },
- { type: 'checkbox', name: 'notify_only_broken_pipelines' },
- { type: 'checkbox', name: 'notify_only_default_branch' }
+ {type: "text", name: "webhook", placeholder: "e.g. #{webhook_placeholder}"},
+ {type: "checkbox", name: "notify_only_broken_pipelines"},
+ {type: "checkbox", name: "notify_only_default_branch"},
]
end
diff --git a/app/models/project_services/irker_service.rb b/app/models/project_services/irker_service.rb
index 83fd9a34438..47be8dbe029 100644
--- a/app/models/project_services/irker_service.rb
+++ b/app/models/project_services/irker_service.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
class IrkerService < Service
prop_accessor :server_host, :server_port, :default_irc_uri
@@ -11,64 +11,64 @@ class IrkerService < Service
before_validation :get_channels
def title
- 'Irker (IRC gateway)'
+ "Irker (IRC gateway)"
end
def description
- 'Send IRC messages, on update, to a list of recipients through an Irker '\
- 'gateway.'
+ "Send IRC messages, on update, to a list of recipients through an Irker "\
+ "gateway."
end
def self.to_param
- 'irker'
+ "irker"
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
IrkerWorker.perform_async(project_id, channels,
- colorize_messages, data, settings)
+ colorize_messages, data, settings)
end
def settings
{
- server_host: server_host.present? ? server_host : 'localhost',
- server_port: server_port.present? ? server_port : 6659
+ server_host: server_host.present? ? server_host : "localhost",
+ server_port: server_port.present? ? server_port : 6659,
}
end
def fields
[
- { type: 'text', name: 'server_host', placeholder: 'localhost',
- help: 'Irker daemon hostname (defaults to localhost)' },
- { type: 'text', name: 'server_port', placeholder: 6659,
- help: 'Irker daemon port (defaults to 6659)' },
- { type: 'text', name: 'default_irc_uri', title: 'Default IRC URI',
- help: 'A default IRC URI to prepend before each recipient (optional)',
- placeholder: 'irc://irc.network.net:6697/' },
- { type: 'textarea', name: 'recipients',
- placeholder: 'Recipients/channels separated by whitespaces', required: true,
- help: 'Recipients have to be specified with a full URI: '\
- 'irc[s]://irc.network.net[:port]/#channel. Special cases: if '\
+ {type: "text", name: "server_host", placeholder: "localhost",
+ help: "Irker daemon hostname (defaults to localhost)",},
+ {type: "text", name: "server_port", placeholder: 6659,
+ help: "Irker daemon port (defaults to 6659)",},
+ {type: "text", name: "default_irc_uri", title: "Default IRC URI",
+ help: "A default IRC URI to prepend before each recipient (optional)",
+ placeholder: "irc://irc.network.net:6697/",},
+ {type: "textarea", name: "recipients",
+ placeholder: "Recipients/channels separated by whitespaces", required: true,
+ help: "Recipients have to be specified with a full URI: "\
+ "irc[s]://irc.network.net[:port]/#channel. Special cases: if "\
'you want the channel to be a nickname instead, append ",isnick" to ' \
- 'the channel name; if the channel is protected by a secret password, ' \
+ "the channel name; if the channel is protected by a secret password, " \
' append "?key=secretpassword" to the URI (Note that due to a bug, if you ' \
' want to use a password, you have to omit the "#" on the channel). If you ' \
- ' specify a default IRC URI to prepend before each recipient, you can just ' \
- ' give a channel name.' },
- { type: 'checkbox', name: 'colorize_messages' }
+ " specify a default IRC URI to prepend before each recipient, you can just " \
+ " give a channel name.",},
+ {type: "checkbox", name: "colorize_messages"},
]
end
def help
- ' NOTE: Irker does NOT have built-in authentication, which makes it' \
- ' vulnerable to spamming IRC channels if it is hosted outside of a ' \
- ' firewall. Please make sure you run the daemon within a secured network ' \
- ' to prevent abuse. For more details, read: http://www.catb.org/~esr/irker/security.html.'
+ " NOTE: Irker does NOT have built-in authentication, which makes it" \
+ " vulnerable to spamming IRC channels if it is hosted outside of a " \
+ " firewall. Please make sure you run the daemon within a secured network " \
+ " to prevent abuse. For more details, read: http://www.catb.org/~esr/irker/security.html."
end
private
@@ -79,7 +79,7 @@ class IrkerService < Service
map_recipients
- errors.add(:recipients, 'are all invalid') if channels.empty?
+ errors.add(:recipients, "are all invalid") if channels.empty?
true
end
@@ -101,7 +101,7 @@ class IrkerService < Service
unless uri.present? && default_irc_uri.nil?
begin
- new_recipient = URI.join(default_irc_uri, '/', recipient).to_s
+ new_recipient = URI.join(default_irc_uri, "/", recipient).to_s
uri = consider_uri(URI.parse(new_recipient))
rescue
log_error("Unable to create a valid URL", default_irc_uri: default_irc_uri, recipient: recipient)
diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb
index f54497fc6d8..d3d1d676d53 100644
--- a/app/models/project_services/issue_tracker_service.rb
+++ b/app/models/project_services/issue_tracker_service.rb
@@ -3,7 +3,7 @@
class IssueTrackerService < Service
validate :one_issue_tracker, if: :activated?, on: :manual_change
- default_value_for :category, 'issue_tracker'
+ default_value_for :category, "issue_tracker"
# Pattern used to extract links from comments
# Override this method on services that uses different patterns
@@ -23,7 +23,7 @@ class IssueTrackerService < Service
end
def issue_url(iid)
- self.issues_url.gsub(':id', iid.to_s)
+ issues_url.gsub(":id", iid.to_s)
end
def issue_tracker_path
@@ -40,10 +40,10 @@ class IssueTrackerService < Service
def fields
[
- { type: 'text', name: 'description', placeholder: description },
- { type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
- { type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true },
- { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url', required: true }
+ {type: "text", name: "description", placeholder: description},
+ {type: "text", name: "project_url", placeholder: "Project url", required: true},
+ {type: "text", name: "issues_url", placeholder: "Issue url", required: true},
+ {type: "text", name: "new_issue_url", placeholder: "New Issue url", required: true},
]
end
@@ -57,10 +57,10 @@ class IssueTrackerService < Service
yield
else
self.properties = {
- title: issues_tracker['title'],
- project_url: issues_tracker['project_url'],
- issues_url: issues_tracker['issues_url'],
- new_issue_url: issues_tracker['new_issue_url']
+ title: issues_tracker["title"],
+ project_url: issues_tracker["project_url"],
+ issues_url: issues_tracker["issues_url"],
+ new_issue_url: issues_tracker["new_issue_url"],
}
end
else
@@ -69,24 +69,24 @@ class IssueTrackerService < Service
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
- message = "#{self.type} was unable to reach #{self.project_url}. Check the url and try again."
+ message = "#{type} was unable to reach #{project_url}. Check the url and try again."
result = false
begin
- response = Gitlab::HTTP.head(self.project_url, verify: true)
+ response = Gitlab::HTTP.head(project_url, verify: true)
if response
- message = "#{self.type} received response #{response.code} when attempting to connect to #{self.project_url}"
+ message = "#{type} received response #{response.code} when attempting to connect to #{project_url}"
result = true
end
rescue Gitlab::HTTP::Error, Timeout::Error, SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED, OpenSSL::SSL::SSLError => error
- message = "#{self.type} had an error when trying to connect to #{self.project_url}: #{error.message}"
+ message = "#{type} had an error when trying to connect to #{project_url}: #{error.message}"
end
log_info(message)
result
@@ -95,8 +95,7 @@ class IssueTrackerService < Service
private
def enabled_in_gitlab_config
- Gitlab.config.issues_tracker &&
- Gitlab.config.issues_tracker.values.any? &&
+ Gitlab.config.issues_tracker&.values&.any? &&
issues_tracker
end
@@ -109,7 +108,7 @@ class IssueTrackerService < Service
return if project.blank?
if project.services.external_issue_trackers.where.not(id: id).any?
- errors.add(:base, 'Another issue tracker is already in use. Only one issue tracker service can be active at a time')
+ errors.add(:base, "Another issue tracker is already in use. Only one issue tracker service can be active at a time")
end
end
end
diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb
index f7064d5aaea..de04d3ec2b8 100644
--- a/app/models/project_services/jira_service.rb
+++ b/app/models/project_services/jira_service.rb
@@ -11,8 +11,8 @@ class JiraService < IssueTrackerService
validates :password, presence: true, if: :activated?
validates :jira_issue_transition_id,
- format: { with: Gitlab::Regex.jira_transition_id_regex, message: "transition ids can have only numbers which can be split with , or ;" },
- allow_blank: true
+ format: {with: Gitlab::Regex.jira_transition_id_regex, message: "transition ids can have only numbers which can be split with , or ;"},
+ allow_blank: true
# JIRA cloud version is deprecating authentication via username and password.
# We should use username/password for JIRA server and email/api_token for JIRA cloud,
@@ -21,12 +21,12 @@ class JiraService < IssueTrackerService
before_update :reset_password
- alias_method :project_url, :url
+ alias project_url url
# When these are false GitLab does not create cross reference
# comments on JIRA except when an issue gets transitioned.
def self.supported_events
- %w(commit merge_request)
+ %w[commit merge_request]
end
# {PROJECT-KEY}-{NUMBER} Examples: JIRA-1, PROJECT-1
@@ -37,9 +37,9 @@ class JiraService < IssueTrackerService
def initialize_properties
super do
self.properties = {
- title: issues_tracker['title'],
- url: issues_tracker['url'],
- api_url: issues_tracker['api_url']
+ title: issues_tracker["title"],
+ url: issues_tracker["url"],
+ api_url: issues_tracker["api_url"],
}
end
end
@@ -52,15 +52,15 @@ class JiraService < IssueTrackerService
url = URI.parse(client_url)
{
- username: self.username,
- password: self.password,
- site: URI.join(url, '/').to_s, # Intended to find the root
- context_path: url.path.chomp('/'),
+ username: username,
+ password: password,
+ site: URI.join(url, "/").to_s, # Intended to find the root
+ context_path: url.path.chomp("/"),
auth_type: :basic,
read_timeout: 120,
use_cookies: true,
- additional_cookies: ['OBBasicAuth=fromDialog'],
- use_ssl: url.scheme == 'https'
+ additional_cookies: ["OBBasicAuth=fromDialog"],
+ use_ssl: url.scheme == "https",
}
end
@@ -71,36 +71,36 @@ class JiraService < IssueTrackerService
def help
"You need to configure JIRA before enabling this service. For more details
read the
- [JIRA service documentation](#{help_page_url('user/project/integrations/jira')})."
+ [JIRA service documentation](#{help_page_url("user/project/integrations/jira")})."
end
def title
- if self.properties && self.properties['title'].present?
- self.properties['title']
+ if properties && properties["title"].present?
+ properties["title"]
else
- 'JIRA'
+ "JIRA"
end
end
def description
- if self.properties && self.properties['description'].present?
- self.properties['description']
+ if properties && properties["description"].present?
+ properties["description"]
else
- 'Jira issue tracker'
+ "Jira issue tracker"
end
end
def self.to_param
- 'jira'
+ "jira"
end
def fields
[
- { type: 'text', name: 'url', title: 'Web URL', placeholder: 'https://jira.example.com', required: true },
- { type: 'text', name: 'api_url', title: 'JIRA API URL', placeholder: 'If different from Web URL' },
- { type: 'text', name: 'username', title: 'Username or Email', placeholder: 'Use a username for server version and an email for cloud version', required: true },
- { type: 'password', name: 'password', title: 'Password or API token', placeholder: 'Use a password for server version and an API token for cloud version', required: true },
- { type: 'text', name: 'jira_issue_transition_id', title: 'Transition ID(s)', placeholder: 'Use , or ; to separate multiple transition IDs' }
+ {type: "text", name: "url", title: "Web URL", placeholder: "https://jira.example.com", required: true},
+ {type: "text", name: "api_url", title: "JIRA API URL", placeholder: "If different from Web URL"},
+ {type: "text", name: "username", title: "Username or Email", placeholder: "Use a username for server version and an email for cloud version", required: true},
+ {type: "password", name: "password", title: "Password or API token", placeholder: "Use a password for server version and an API token for cloud version", required: true},
+ {type: "text", name: "jira_issue_transition_id", title: "Transition ID(s)", placeholder: "Use , or ; to separate multiple transition IDs"},
]
end
@@ -123,10 +123,10 @@ class JiraService < IssueTrackerService
return if issue.nil? || has_resolution?(issue) || !jira_issue_transition_id.present?
commit_id = if entity.is_a?(Commit)
- entity.id
- elsif entity.is_a?(MergeRequest)
- entity.diff_head_sha
- end
+ entity.id
+ elsif entity.is_a?(MergeRequest)
+ entity.diff_head_sha
+ end
commit_url = build_entity_url(:commit, commit_id)
@@ -153,17 +153,17 @@ class JiraService < IssueTrackerService
data = {
user: {
name: author.name,
- url: resource_url(user_path(author))
+ url: resource_url(user_path(author)),
},
project: {
name: project.full_path,
- url: resource_url(namespace_project_path(project.namespace, project)) # rubocop:disable Cop/ProjectPathHelper
+ url: resource_url(namespace_project_path(project.namespace, project)), # rubocop:disable Cop/ProjectPathHelper
},
entity: {
name: noteable_type.humanize.downcase,
url: entity_url,
- title: noteable.title
- }
+ title: noteable.title,
+ },
}
add_comment(data, jira_issue)
@@ -174,7 +174,7 @@ class JiraService < IssueTrackerService
success = result.present?
result = @error if @error && !success
- { success: success, result: result }
+ {success: success, result: result}
end
# JIRA does not need test data.
@@ -205,12 +205,10 @@ class JiraService < IssueTrackerService
# if any transition fails it will log the error message and stop the transition sequence
def transition_issue(issue)
jira_issue_transition_id.scan(Gitlab::Regex.jira_transition_id_regex).each do |transition_id|
- begin
- issue.transitions.build.save!(transition: { id: transition_id })
- rescue => error
- log_error("Issue transition failed", error: error.message, client_url: client_url)
- return false
- end
+ issue.transitions.build.save!(transition: {id: transition_id})
+ rescue => error
+ log_error("Issue transition failed", error: error.message, client_url: client_url)
+ return false
end
end
@@ -273,20 +271,20 @@ class JiraService < IssueTrackerService
def build_remote_link_props(url:, title:, resolved: false)
status = {
- resolved: resolved
+ resolved: resolved,
}
{
- GlobalID: 'GitLab',
- relationship: 'mentioned on',
+ GlobalID: "GitLab",
+ relationship: "mentioned on",
object: {
url: url,
title: title,
status: status,
icon: {
- title: 'GitLab', url16x16: asset_url(Gitlab::Favicon.main, host: gitlab_config.url)
- }
- }
+ title: "GitLab", url16x16: asset_url(Gitlab::Favicon.main, host: gitlab_config.url),
+ },
+ },
}
end
@@ -297,11 +295,11 @@ class JiraService < IssueTrackerService
def build_entity_url(noteable_type, entity_id)
polymorphic_url(
[
- self.project.namespace.becomes(Namespace),
- self.project,
- noteable_type.to_sym
+ project.namespace.becomes(Namespace),
+ project,
+ noteable_type.to_sym,
],
- id: entity_id,
+ id: entity_id,
host: Settings.gitlab.base_url
)
end
@@ -317,7 +315,6 @@ class JiraService < IssueTrackerService
# Handle errors when doing JIRA API calls
def jira_request
yield
-
rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, URI::InvalidURIError, JIRA::HTTPError, OpenSSL::SSL::SSLError => e
@error = e.message
log_error("Error sending message", client_url: client_url, error: @error)
diff --git a/app/models/project_services/kubernetes_service.rb b/app/models/project_services/kubernetes_service.rb
index f69edd60003..1d19880beab 100644
--- a/app/models/project_services/kubernetes_service.rb
+++ b/app/models/project_services/kubernetes_service.rb
@@ -39,7 +39,7 @@ class KubernetesService < DeploymentService
if: :activated?,
format: {
with: Gitlab::Regex.kubernetes_namespace_regex,
- message: Gitlab::Regex.kubernetes_namespace_regex_message
+ message: Gitlab::Regex.kubernetes_namespace_regex_message,
}
after_save :clear_reactive_cache!
@@ -49,40 +49,40 @@ class KubernetesService < DeploymentService
end
def title
- 'Kubernetes'
+ "Kubernetes"
end
def description
- 'Kubernetes / OpenShift integration'
+ "Kubernetes / OpenShift integration"
end
def help
- 'To enable terminal access to Kubernetes environments, label your ' \
- 'deployments with `app=$CI_ENVIRONMENT_SLUG`'
+ "To enable terminal access to Kubernetes environments, label your " \
+ "deployments with `app=$CI_ENVIRONMENT_SLUG`"
end
def self.to_param
- 'kubernetes'
+ "kubernetes"
end
def fields
[
- { type: 'text',
- name: 'api_url',
- title: 'API URL',
- placeholder: 'Kubernetes API URL, like https://kube.example.com/' },
- { type: 'textarea',
- name: 'ca_pem',
- title: 'CA Certificate',
- placeholder: 'Certificate Authority bundle (PEM format)' },
- { type: 'text',
- name: 'namespace',
- title: 'Project namespace (optional/unique)',
- placeholder: namespace_placeholder },
- { type: 'text',
- name: 'token',
- title: 'Token',
- placeholder: 'Service token' }
+ {type: "text",
+ name: "api_url",
+ title: "API URL",
+ placeholder: "Kubernetes API URL, like https://kube.example.com/",},
+ {type: "textarea",
+ name: "ca_pem",
+ title: "CA Certificate",
+ placeholder: "Certificate Authority bundle (PEM format)",},
+ {type: "text",
+ name: "namespace",
+ title: "Project namespace (optional/unique)",
+ placeholder: namespace_placeholder,},
+ {type: "text",
+ name: "token",
+ title: "Token",
+ placeholder: "Service token",},
]
end
@@ -99,9 +99,9 @@ class KubernetesService < DeploymentService
kubeclient = build_kube_client!
kubeclient.core_client.discover
- { success: kubeclient.core_client.discovered, result: "Checked API discovery endpoint" }
+ {success: kubeclient.core_client.discovered, result: "Checked API discovery endpoint"}
rescue => err
- { success: false, result: err }
+ {success: false, result: err}
end
# Project param was added on
@@ -112,15 +112,15 @@ class KubernetesService < DeploymentService
def predefined_variables(project:)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables
- .append(key: 'KUBE_URL', value: api_url)
- .append(key: 'KUBE_TOKEN', value: token, public: false)
- .append(key: 'KUBE_NAMESPACE', value: actual_namespace)
- .append(key: 'KUBECONFIG', value: kubeconfig, public: false, file: true)
+ .append(key: "KUBE_URL", value: api_url)
+ .append(key: "KUBE_TOKEN", value: token, public: false)
+ .append(key: "KUBE_NAMESPACE", value: actual_namespace)
+ .append(key: "KUBECONFIG", value: kubeconfig, public: false, file: true)
if ca_pem.present?
variables
- .append(key: 'KUBE_CA_PEM', value: ca_pem)
- .append(key: 'KUBE_CA_PEM_FILE', value: ca_pem, file: true)
+ .append(key: "KUBE_CA_PEM", value: ca_pem)
+ .append(key: "KUBE_CA_PEM_FILE", value: ca_pem, file: true)
end
end
end
@@ -143,7 +143,7 @@ class KubernetesService < DeploymentService
return unless active? && project && !project.pending_delete?
# We may want to cache extra things in the future
- { pods: read_pods }
+ {pods: read_pods}
end
def kubeclient
@@ -157,12 +157,12 @@ class KubernetesService < DeploymentService
def deprecation_message
content = _("Kubernetes service integration has been deprecated. %{deprecated_message_content} your Kubernetes clusters using the new <a href=\"%{url}\"/>Kubernetes Clusters</a> page") % {
deprecated_message_content: deprecated_message_content,
- url: Gitlab::Routing.url_helpers.project_clusters_path(project)
+ url: Gitlab::Routing.url_helpers.project_clusters_path(project),
}
content.html_safe
end
- TEMPLATE_PLACEHOLDER = 'Kubernetes namespace'.freeze
+ TEMPLATE_PLACEHOLDER = "Kubernetes namespace"
private
@@ -171,7 +171,8 @@ class KubernetesService < DeploymentService
url: api_url,
namespace: actual_namespace,
token: token,
- ca_pem: ca_pem)
+ ca_pem: ca_pem
+ )
end
def namespace_placeholder
@@ -182,7 +183,7 @@ class KubernetesService < DeploymentService
return unless project
slug = "#{project.path}-#{project.id}".downcase
- slug.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '')
+ slug.gsub(/[^-a-z0-9]/, "-").gsub(/^-+/, "")
end
def build_kube_client!
@@ -192,7 +193,7 @@ class KubernetesService < DeploymentService
api_url,
auth_options: kubeclient_auth_options,
ssl_options: kubeclient_ssl_options,
- http_proxy_uri: ENV['http_proxy']
+ http_proxy_uri: ENV["http_proxy"]
)
end
@@ -206,7 +207,7 @@ class KubernetesService < DeploymentService
end
def kubeclient_ssl_options
- opts = { verify_ssl: OpenSSL::SSL::VERIFY_PEER }
+ opts = {verify_ssl: OpenSSL::SSL::VERIFY_PEER}
if ca_pem.present?
opts[:cert_store] = OpenSSL::X509::Store.new
@@ -217,19 +218,19 @@ class KubernetesService < DeploymentService
end
def kubeclient_auth_options
- { bearer_token: token }
+ {bearer_token: token}
end
def terminal_auth
{
token: token,
ca_pem: ca_pem,
- max_session_time: Gitlab::CurrentSettings.terminal_max_session_time
+ max_session_time: Gitlab::CurrentSettings.terminal_max_session_time,
}
end
def enforce_namespace_to_lower_case
- self.namespace = self.namespace&.downcase
+ self.namespace = namespace&.downcase
end
def deprecation_validation
diff --git a/app/models/project_services/mattermost_service.rb b/app/models/project_services/mattermost_service.rb
index b8bc83b870e..5c245c56d5a 100644
--- a/app/models/project_services/mattermost_service.rb
+++ b/app/models/project_services/mattermost_service.rb
@@ -2,15 +2,15 @@
class MattermostService < ChatNotificationService
def title
- 'Mattermost notifications'
+ "Mattermost notifications"
end
def description
- 'Receive event notifications in Mattermost'
+ "Receive event notifications in Mattermost"
end
def self.to_param
- 'mattermost'
+ "mattermost"
end
def help
@@ -29,6 +29,6 @@ class MattermostService < ChatNotificationService
end
def webhook_placeholder
- 'http://mattermost.example.com/hooks/…'
+ "http://mattermost.example.com/hooks/…"
end
end
diff --git a/app/models/project_services/mattermost_slash_commands_service.rb b/app/models/project_services/mattermost_slash_commands_service.rb
index ca324f68d2d..14e5cc3171d 100644
--- a/app/models/project_services/mattermost_slash_commands_service.rb
+++ b/app/models/project_services/mattermost_slash_commands_service.rb
@@ -10,7 +10,7 @@ class MattermostSlashCommandsService < SlashCommandsService
end
def title
- 'Mattermost slash commands'
+ "Mattermost slash commands"
end
def description
@@ -18,7 +18,7 @@ class MattermostSlashCommandsService < SlashCommandsService
end
def self.to_param
- 'mattermost_slash_commands'
+ "mattermost_slash_commands"
end
def configure(user, params)
@@ -44,10 +44,11 @@ class MattermostSlashCommandsService < SlashCommandsService
params.merge(
auto_complete: true,
auto_complete_desc: "Perform common operations on: #{pretty_project_name}",
- auto_complete_hint: '[help]',
+ auto_complete_hint: "[help]",
description: "Perform common operations on: #{pretty_project_name}",
display_name: "GitLab / #{pretty_project_name}",
- method: 'P',
- username: 'GitLab')
+ method: "P",
+ username: "GitLab"
+ )
end
end
diff --git a/app/models/project_services/microsoft_teams_service.rb b/app/models/project_services/microsoft_teams_service.rb
index c34078f13c1..46e0bdd078e 100644
--- a/app/models/project_services/microsoft_teams_service.rb
+++ b/app/models/project_services/microsoft_teams_service.rb
@@ -2,15 +2,15 @@
class MicrosoftTeamsService < ChatNotificationService
def title
- 'Microsoft Teams Notification'
+ "Microsoft Teams Notification"
end
def description
- 'Receive event notifications in Microsoft Teams'
+ "Receive event notifications in Microsoft Teams"
end
def self.to_param
- 'microsoft_teams'
+ "microsoft_teams"
end
def help
@@ -24,7 +24,7 @@ class MicrosoftTeamsService < ChatNotificationService
end
def webhook_placeholder
- 'https://outlook.office.com/webhook/…'
+ "https://outlook.office.com/webhook/…"
end
def event_field(event)
@@ -35,9 +35,9 @@ class MicrosoftTeamsService < ChatNotificationService
def default_fields
[
- { type: 'text', name: 'webhook', placeholder: "e.g. #{webhook_placeholder}" },
- { type: 'checkbox', name: 'notify_only_broken_pipelines' },
- { type: 'checkbox', name: 'notify_only_default_branch' }
+ {type: "text", name: "webhook", placeholder: "e.g. #{webhook_placeholder}"},
+ {type: "checkbox", name: "notify_only_broken_pipelines"},
+ {type: "checkbox", name: "notify_only_default_branch"},
]
end
diff --git a/app/models/project_services/mock_ci_service.rb b/app/models/project_services/mock_ci_service.rb
index d8bba58dcbf..5d99553f2ed 100644
--- a/app/models/project_services/mock_ci_service.rb
+++ b/app/models/project_services/mock_ci_service.rb
@@ -8,23 +8,23 @@ class MockCiService < CiService
validates :mock_service_url, presence: true, public_url: true, if: :activated?
def title
- 'MockCI'
+ "MockCI"
end
def description
- 'Mock an external CI'
+ "Mock an external CI"
end
def self.to_param
- 'mock_ci'
+ "mock_ci"
end
def fields
[
- { type: 'text',
- name: 'mock_service_url',
- placeholder: 'http://localhost:4004',
- required: true }
+ {type: "text",
+ name: "mock_service_url",
+ placeholder: "http://localhost:4004",
+ required: true,},
]
end
@@ -36,7 +36,8 @@ class MockCiService < CiService
def build_page(sha, ref)
Gitlab::Utils.append_path(
mock_service_url,
- "#{project.namespace.path}/#{project.path}/status/#{sha}")
+ "#{project.namespace.path}/#{project.path}/status/#{sha}"
+ )
end
# Return string with build status or :error symbol
@@ -62,17 +63,18 @@ class MockCiService < CiService
def commit_status_path(sha)
Gitlab::Utils.append_path(
mock_service_url,
- "#{project.namespace.path}/#{project.path}/status/#{sha}.json")
+ "#{project.namespace.path}/#{project.path}/status/#{sha}.json"
+ )
end
def read_commit_status(response)
return :error unless response.code == 200 || response.code == 404
status = if response.code == 404
- 'pending'
- else
- response['status']
- end
+ "pending"
+ else
+ response["status"]
+ end
if status.present? && ALLOWED_STATES.include?(status)
status
diff --git a/app/models/project_services/mock_deployment_service.rb b/app/models/project_services/mock_deployment_service.rb
index 7ab1687f8ba..4b5736c4f96 100644
--- a/app/models/project_services/mock_deployment_service.rb
+++ b/app/models/project_services/mock_deployment_service.rb
@@ -2,15 +2,15 @@
class MockDeploymentService < DeploymentService
def title
- 'Mock deployment'
+ "Mock deployment"
end
def description
- 'Mock deployment service'
+ "Mock deployment service"
end
def self.to_param
- 'mock_deployment'
+ "mock_deployment"
end
# No terminals support
diff --git a/app/models/project_services/mock_monitoring_service.rb b/app/models/project_services/mock_monitoring_service.rb
index bcf8f1df5da..0b799627316 100644
--- a/app/models/project_services/mock_monitoring_service.rb
+++ b/app/models/project_services/mock_monitoring_service.rb
@@ -2,19 +2,19 @@
class MockMonitoringService < MonitoringService
def title
- 'Mock monitoring'
+ "Mock monitoring"
end
def description
- 'Mock monitoring service'
+ "Mock monitoring service"
end
def self.to_param
- 'mock_monitoring'
+ "mock_monitoring"
end
def metrics(environment)
- JSON.parse(File.read(Rails.root + 'spec/fixtures/metrics.json'))
+ JSON.parse(File.read(Rails.root + "spec/fixtures/metrics.json"))
end
def can_test?
diff --git a/app/models/project_services/monitoring_service.rb b/app/models/project_services/monitoring_service.rb
index 1b530a8247b..725c27c6190 100644
--- a/app/models/project_services/monitoring_service.rb
+++ b/app/models/project_services/monitoring_service.rb
@@ -5,10 +5,10 @@
# These services integrate with a deployment solution like Prometheus
# to provide additional features for environments.
class MonitoringService < Service
- default_value_for :category, 'monitoring'
+ default_value_for :category, "monitoring"
def self.supported_events
- %w()
+ %w[]
end
def can_query?
diff --git a/app/models/project_services/packagist_service.rb b/app/models/project_services/packagist_service.rb
index 003884bb7ac..4cff62d6429 100644
--- a/app/models/project_services/packagist_service.rb
+++ b/app/models/project_services/packagist_service.rb
@@ -12,27 +12,27 @@ class PackagistService < Service
after_save :compose_service_hook, if: :activated?
def title
- 'Packagist'
+ "Packagist"
end
def description
- 'Update your project on Packagist, the main Composer repository'
+ "Update your project on Packagist, the main Composer repository"
end
def self.to_param
- 'packagist'
+ "packagist"
end
def fields
[
- { type: 'text', name: 'username', placeholder: '', required: true },
- { type: 'text', name: 'token', placeholder: '', required: true },
- { type: 'text', name: 'server', placeholder: 'https://packagist.org', required: false }
+ {type: "text", name: "username", placeholder: "", required: true},
+ {type: "text", name: "token", placeholder: "", required: true},
+ {type: "text", name: "server", placeholder: "https://packagist.org", required: false},
]
end
def self.supported_events
- %w(push merge_request tag_push)
+ %w[push merge_request tag_push]
end
def execute(data)
@@ -44,12 +44,12 @@ class PackagistService < Service
def test(data)
begin
result = execute(data)
- return { success: false, result: result[:message] } if result[:http_status] != 202
- rescue StandardError => error
- return { success: false, result: error }
+ return {success: false, result: result[:message]} if result[:http_status] != 202
+ rescue => error
+ return {success: false, result: error}
end
- { success: true, result: result[:message] }
+ {success: true, result: result[:message]}
end
def compose_service_hook
@@ -59,7 +59,7 @@ class PackagistService < Service
end
def hook_url
- base_url = server.present? ? server : 'https://packagist.org'
+ base_url = server.present? ? server : "https://packagist.org"
"#{base_url}/api/update-package?username=#{username}&apiToken=#{token}"
end
end
diff --git a/app/models/project_services/pipelines_email_service.rb b/app/models/project_services/pipelines_email_service.rb
index d60a6a7efa3..e17b51c1d31 100644
--- a/app/models/project_services/pipelines_email_service.rb
+++ b/app/models/project_services/pipelines_email_service.rb
@@ -6,19 +6,19 @@ class PipelinesEmailService < Service
validates :recipients, presence: true, if: :valid_recipients?
def initialize_properties
- self.properties ||= { notify_only_broken_pipelines: true }
+ self.properties ||= {notify_only_broken_pipelines: true}
end
def title
- 'Pipelines emails'
+ "Pipelines emails"
end
def description
- 'Email the pipelines status to a list of recipients.'
+ "Email the pipelines status to a list of recipients."
end
def self.to_param
- 'pipelines_email'
+ "pipelines_email"
end
def self.supported_events
@@ -49,28 +49,28 @@ class PipelinesEmailService < Service
def fields
[
- { type: 'textarea',
- name: 'recipients',
- placeholder: 'Emails separated by comma',
- required: true },
- { type: 'checkbox',
- name: 'notify_only_broken_pipelines' }
+ {type: "textarea",
+ name: "recipients",
+ placeholder: "Emails separated by comma",
+ required: true,},
+ {type: "checkbox",
+ name: "notify_only_broken_pipelines",},
]
end
def test(data)
result = execute(data, force: true)
- { success: true, result: result }
- rescue StandardError => error
- { success: false, result: error }
+ {success: true, result: result}
+ rescue => error
+ {success: false, result: error}
end
def should_pipeline_be_notified?(data)
case data[:object_attributes][:status]
- when 'success'
+ when "success"
!notify_only_broken_pipelines?
- when 'failed'
+ when "failed"
true
else
false
diff --git a/app/models/project_services/pivotaltracker_service.rb b/app/models/project_services/pivotaltracker_service.rb
index 617e502b639..e53fe85b1e8 100644
--- a/app/models/project_services/pivotaltracker_service.rb
+++ b/app/models/project_services/pivotaltracker_service.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
class PivotaltrackerService < Service
- API_ENDPOINT = 'https://www.pivotaltracker.com/services/v5/source_commits'.freeze
+ API_ENDPOINT = "https://www.pivotaltracker.com/services/v5/source_commits"
prop_accessor :token, :restrict_to_branch
validates :token, presence: true, if: :activated?
def title
- 'PivotalTracker'
+ "PivotalTracker"
end
def description
- 'Project Management Software (Source Commits Endpoint)'
+ "Project Management Software (Source Commits Endpoint)"
end
def self.to_param
- 'pivotaltracker'
+ "pivotaltracker"
end
def fields
[
{
- type: 'text',
- name: 'token',
- placeholder: 'Pivotal Tracker API token.',
- required: true
+ type: "text",
+ name: "token",
+ placeholder: "Pivotal Tracker API token.",
+ required: true,
},
{
- type: 'text',
- name: 'restrict_to_branch',
- placeholder: 'Comma-separated list of branches which will be ' \
- 'automatically inspected. Leave blank to include all branches.'
- }
+ type: "text",
+ name: "restrict_to_branch",
+ placeholder: "Comma-separated list of branches which will be " \
+ "automatically inspected. Leave blank to include all branches.",
+ },
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
@@ -45,19 +45,19 @@ class PivotaltrackerService < Service
data[:commits].each do |commit|
message = {
- 'source_commit' => {
- 'commit_id' => commit[:id],
- 'author' => commit[:author][:name],
- 'url' => commit[:url],
- 'message' => commit[:message]
- }
+ "source_commit" => {
+ "commit_id" => commit[:id],
+ "author" => commit[:author][:name],
+ "url" => commit[:url],
+ "message" => commit[:message],
+ },
}
Gitlab::HTTP.post(
API_ENDPOINT,
body: message.to_json,
headers: {
- 'Content-Type' => 'application/json',
- 'X-TrackerToken' => token
+ "Content-Type" => "application/json",
+ "X-TrackerToken" => token,
}
)
end
@@ -69,7 +69,7 @@ class PivotaltrackerService < Service
return true unless ref.present? && restrict_to_branch.present?
branch = Gitlab::Git.ref_name(ref)
- allowed_branches = restrict_to_branch.split(',').map(&:strip)
+ allowed_branches = restrict_to_branch.split(",").map(&:strip)
branch.present? && allowed_branches.include?(branch)
end
diff --git a/app/models/project_services/prometheus_service.rb b/app/models/project_services/prometheus_service.rb
index 60cb2d380d5..1cc52e26243 100644
--- a/app/models/project_services/prometheus_service.rb
+++ b/app/models/project_services/prometheus_service.rb
@@ -30,15 +30,15 @@ class PrometheusService < MonitoringService
end
def title
- 'Prometheus'
+ "Prometheus"
end
def description
- s_('PrometheusService|Time-series monitoring service')
+ s_("PrometheusService|Time-series monitoring service")
end
def self.to_param
- 'prometheus'
+ "prometheus"
end
def fields
@@ -46,18 +46,18 @@ class PrometheusService < MonitoringService
[
{
- type: 'checkbox',
- name: 'manual_configuration',
- title: s_('PrometheusService|Active'),
- required: true
+ type: "checkbox",
+ name: "manual_configuration",
+ title: s_("PrometheusService|Active"),
+ required: true,
},
{
- type: 'text',
- name: 'api_url',
- title: 'API URL',
- placeholder: s_('PrometheusService|Prometheus API Base URL, like http://prometheus.example.com/'),
- required: true
- }
+ type: "text",
+ name: "api_url",
+ title: "API URL",
+ placeholder: s_("PrometheusService|Prometheus API Base URL, like http://prometheus.example.com/"),
+ required: true,
+ },
]
end
@@ -65,9 +65,9 @@ class PrometheusService < MonitoringService
def test(*args)
Gitlab::PrometheusClient.new(prometheus_client).ping
- { success: true, result: 'Checked API endpoint' }
+ {success: true, result: "Checked API endpoint"}
rescue Gitlab::PrometheusClient::Error => err
- { success: false, result: err }
+ {success: false, result: err}
end
def prometheus_client
diff --git a/app/models/project_services/pushover_service.rb b/app/models/project_services/pushover_service.rb
index 4e48c348b45..08a6ac3e296 100644
--- a/app/models/project_services/pushover_service.rb
+++ b/app/models/project_services/pushover_service.rb
@@ -1,67 +1,67 @@
# frozen_string_literal: true
class PushoverService < Service
- BASE_URI = 'https://api.pushover.net/1'.freeze
+ BASE_URI = "https://api.pushover.net/1"
prop_accessor :api_key, :user_key, :device, :priority, :sound
validates :api_key, :user_key, :priority, presence: true, if: :activated?
def title
- 'Pushover'
+ "Pushover"
end
def description
- 'Pushover makes it easy to get real-time notifications on your Android device, iPhone, iPad, and Desktop.'
+ "Pushover makes it easy to get real-time notifications on your Android device, iPhone, iPad, and Desktop."
end
def self.to_param
- 'pushover'
+ "pushover"
end
def fields
[
- { type: 'text', name: 'api_key', placeholder: 'Your application key', required: true },
- { type: 'text', name: 'user_key', placeholder: 'Your user key', required: true },
- { type: 'text', name: 'device', placeholder: 'Leave blank for all active devices' },
- { type: 'select', name: 'priority', required: true, choices:
+ {type: "text", name: "api_key", placeholder: "Your application key", required: true},
+ {type: "text", name: "user_key", placeholder: "Your user key", required: true},
+ {type: "text", name: "device", placeholder: "Leave blank for all active devices"},
+ {type: "select", name: "priority", required: true, choices:
[
- ['Lowest Priority', -2],
- ['Low Priority', -1],
- ['Normal Priority', 0],
- ['High Priority', 1]
+ ["Lowest Priority", -2],
+ ["Low Priority", -1],
+ ["Normal Priority", 0],
+ ["High Priority", 1],
],
- default_choice: 0 },
- { type: 'select', name: 'sound', choices:
+ default_choice: 0,},
+ {type: "select", name: "sound", choices:
[
- ['Device default sound', nil],
- ['Pushover (default)', 'pushover'],
- %w(Bike bike),
- %w(Bugle bugle),
- ['Cash Register', 'cashregister'],
- %w(Classical classical),
- %w(Cosmic cosmic),
- %w(Falling falling),
- %w(Gamelan gamelan),
- %w(Incoming incoming),
- %w(Intermission intermission),
- %w(Magic magic),
- %w(Mechanical mechanical),
- ['Piano Bar', 'pianobar'],
- %w(Siren siren),
- ['Space Alarm', 'spacealarm'],
- ['Tug Boat', 'tugboat'],
- ['Alien Alarm (long)', 'alien'],
- ['Climb (long)', 'climb'],
- ['Persistent (long)', 'persistent'],
- ['Pushover Echo (long)', 'echo'],
- ['Up Down (long)', 'updown'],
- ['None (silent)', 'none']
- ] }
+ ["Device default sound", nil],
+ ["Pushover (default)", "pushover"],
+ %w[Bike bike],
+ %w[Bugle bugle],
+ ["Cash Register", "cashregister"],
+ %w[Classical classical],
+ %w[Cosmic cosmic],
+ %w[Falling falling],
+ %w[Gamelan gamelan],
+ %w[Incoming incoming],
+ %w[Intermission intermission],
+ %w[Magic magic],
+ %w[Mechanical mechanical],
+ ["Piano Bar", "pianobar"],
+ %w[Siren siren],
+ ["Space Alarm", "spacealarm"],
+ ["Tug Boat", "tugboat"],
+ ["Alien Alarm (long)", "alien"],
+ ["Climb (long)", "climb"],
+ ["Persistent (long)", "persistent"],
+ ["Pushover Echo (long)", "echo"],
+ ["Up Down (long)", "updown"],
+ ["None (silent)", "none"],
+ ],},
]
end
def self.supported_events
- %w(push)
+ %w[push]
end
def execute(data)
@@ -89,10 +89,10 @@ class PushoverService < Service
user: user_key,
device: device,
priority: priority,
- title: "#{project.full_name}",
+ title: project.full_name.to_s,
message: message,
url: data[:project][:web_url],
- url_title: "See project #{project.full_name}"
+ url_title: "See project #{project.full_name}",
}
# Sound parameter MUST NOT be sent to API if not selected
@@ -100,6 +100,6 @@ class PushoverService < Service
pushover_data[:sound] = sound
end
- Gitlab::HTTP.post('/messages.json', base_uri: BASE_URI, body: pushover_data)
+ Gitlab::HTTP.post("/messages.json", base_uri: BASE_URI, body: pushover_data)
end
end
diff --git a/app/models/project_services/redmine_service.rb b/app/models/project_services/redmine_service.rb
index a80be4b06da..96de7243701 100644
--- a/app/models/project_services/redmine_service.rb
+++ b/app/models/project_services/redmine_service.rb
@@ -6,22 +6,22 @@ class RedmineService < IssueTrackerService
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
def title
- if self.properties && self.properties['title'].present?
- self.properties['title']
+ if properties && properties["title"].present?
+ properties["title"]
else
- 'Redmine'
+ "Redmine"
end
end
def description
- if self.properties && self.properties['description'].present?
- self.properties['description']
+ if properties && properties["description"].present?
+ properties["description"]
else
- 'Redmine issue tracker'
+ "Redmine issue tracker"
end
end
def self.to_param
- 'redmine'
+ "redmine"
end
end
diff --git a/app/models/project_services/slack_service.rb b/app/models/project_services/slack_service.rb
index 482808255f9..e2f847817db 100644
--- a/app/models/project_services/slack_service.rb
+++ b/app/models/project_services/slack_service.rb
@@ -2,15 +2,15 @@
class SlackService < ChatNotificationService
def title
- 'Slack notifications'
+ "Slack notifications"
end
def description
- 'Receive event notifications in Slack'
+ "Receive event notifications in Slack"
end
def self.to_param
- 'slack'
+ "slack"
end
def help
@@ -28,6 +28,6 @@ class SlackService < ChatNotificationService
end
def webhook_placeholder
- 'https://hooks.slack.com/services/…'
+ "https://hooks.slack.com/services/…"
end
end
diff --git a/app/models/project_services/slack_slash_commands_service.rb b/app/models/project_services/slack_slash_commands_service.rb
index 6a454070fe2..194d5d53bf1 100644
--- a/app/models/project_services/slack_slash_commands_service.rb
+++ b/app/models/project_services/slack_slash_commands_service.rb
@@ -4,7 +4,7 @@ class SlackSlashCommandsService < SlashCommandsService
include TriggersHelper
def title
- 'Slack slash commands'
+ "Slack slash commands"
end
def description
@@ -12,7 +12,7 @@ class SlackSlashCommandsService < SlashCommandsService
end
def self.to_param
- 'slack_slash_commands'
+ "slack_slash_commands"
end
def trigger(params)
diff --git a/app/models/project_services/slash_commands_service.rb b/app/models/project_services/slash_commands_service.rb
index bfabc6d262c..091e3389ac5 100644
--- a/app/models/project_services/slash_commands_service.rb
+++ b/app/models/project_services/slash_commands_service.rb
@@ -3,20 +3,20 @@
# Base class for Chat services
# This class is not meant to be used directly, but only to inherrit from.
class SlashCommandsService < Service
- default_value_for :category, 'chat'
+ default_value_for :category, "chat"
prop_accessor :token
has_many :chat_names, foreign_key: :service_id, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
def valid_token?(token)
- self.respond_to?(:token) &&
+ respond_to?(:token) &&
self.token.present? &&
ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
end
def self.supported_events
- %w()
+ %w[]
end
def can_test?
@@ -25,7 +25,7 @@ class SlashCommandsService < Service
def fields
[
- { type: 'text', name: 'token', placeholder: 'XXxxXXxxXXxxXXxxXXxxXXxx' }
+ {type: "text", name: "token", placeholder: "XXxxXXxxXXxxXXxxXXxxXXxx"},
]
end
diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb
index 3245cd22e73..7f60d83de98 100644
--- a/app/models/project_services/teamcity_service.rb
+++ b/app/models/project_services/teamcity_service.rb
@@ -31,31 +31,31 @@ class TeamcityService < CiService
end
def title
- 'JetBrains TeamCity CI'
+ "JetBrains TeamCity CI"
end
def description
- 'A continuous integration and build server'
+ "A continuous integration and build server"
end
def help
- 'You will want to configure monitoring of all branches so merge '\
- 'requests build, that setting is in the vsc root advanced settings.'
+ "You will want to configure monitoring of all branches so merge "\
+ "requests build, that setting is in the vsc root advanced settings."
end
def self.to_param
- 'teamcity'
+ "teamcity"
end
def fields
[
- { type: 'text', name: 'teamcity_url',
- placeholder: 'TeamCity root URL like https://teamcity.example.com', required: true },
- { type: 'text', name: 'build_type',
- placeholder: 'Build configuration ID', required: true },
- { type: 'text', name: 'username',
- placeholder: 'A user with permissions to trigger a manual build' },
- { type: 'password', name: 'password' }
+ {type: "text", name: "teamcity_url",
+ placeholder: "TeamCity root URL like https://teamcity.example.com", required: true,},
+ {type: "text", name: "build_type",
+ placeholder: "Build configuration ID", required: true,},
+ {type: "text", name: "username",
+ placeholder: "A user with permissions to trigger a manual build",},
+ {type: "password", name: "password"},
]
end
@@ -70,7 +70,7 @@ class TeamcityService < CiService
def calculate_reactive_cache(sha, ref)
response = get_path("httpAuth/app/rest/builds/branch:unspecified:any,revision:#{sha}")
- { build_page: read_build_page(response), commit_status: read_commit_status(response) }
+ {build_page: read_build_page(response), commit_status: read_commit_status(response)}
end
def execute(data)
@@ -78,17 +78,17 @@ class TeamcityService < CiService
auth = {
username: username,
- password: password
+ password: password,
}
branch = Gitlab::Git.ref_name(data[:ref])
Gitlab::HTTP.post(
- build_url('httpAuth/app/rest/buildQueue'),
+ build_url("httpAuth/app/rest/buildQueue"),
body: "<build branchName=\"#{branch}\">"\
"<buildType id=\"#{build_type}\"/>"\
- '</build>',
- headers: { 'Content-type' => 'application/xml' },
+ "</build>",
+ headers: {"Content-type" => "application/xml"},
basic_auth: auth
)
end
@@ -102,7 +102,7 @@ class TeamcityService < CiService
build_url("viewLog.html?buildTypeId=#{build_type}")
else
# If actual build link is available, go to build result page.
- built_id = response['build']['id']
+ built_id = response["build"]["id"]
build_url("viewLog.html?buildId=#{built_id}&buildTypeId=#{build_type}")
end
end
@@ -111,19 +111,19 @@ class TeamcityService < CiService
return :error unless response.code == 200 || response.code == 404
status = if response.code == 404
- 'Pending'
- else
- response['build']['status']
- end
+ "Pending"
+ else
+ response["build"]["status"]
+ end
return :error unless status.present?
- if status.include?('SUCCESS')
- 'success'
- elsif status.include?('FAILURE')
- 'failed'
- elsif status.include?('Pending')
- 'pending'
+ if status.include?("SUCCESS")
+ "success"
+ elsif status.include?("FAILURE")
+ "failed"
+ elsif status.include?("Pending")
+ "pending"
else
:error
end
@@ -137,7 +137,7 @@ class TeamcityService < CiService
Gitlab::HTTP.get(build_url(path), verify: false,
basic_auth: {
username: username,
- password: password
+ password: password,
})
end
end
diff --git a/app/models/project_services/youtrack_service.rb b/app/models/project_services/youtrack_service.rb
index 957be685aea..56f21a4e40e 100644
--- a/app/models/project_services/youtrack_service.rb
+++ b/app/models/project_services/youtrack_service.rb
@@ -15,26 +15,26 @@ class YoutrackService < IssueTrackerService
end
def title
- 'YouTrack'
+ "YouTrack"
end
def description
- if self.properties && self.properties['description'].present?
- self.properties['description']
+ if properties && properties["description"].present?
+ properties["description"]
else
- 'YouTrack issue tracker'
+ "YouTrack issue tracker"
end
end
def self.to_param
- 'youtrack'
+ "youtrack"
end
def fields
[
- { type: 'text', name: 'description', placeholder: description },
- { type: 'text', name: 'project_url', placeholder: 'Project url', required: true },
- { type: 'text', name: 'issues_url', placeholder: 'Issue url', required: true }
+ {type: "text", name: "description", placeholder: description},
+ {type: "text", name: "project_url", placeholder: "Project url", required: true},
+ {type: "text", name: "issues_url", placeholder: "Issue url", required: true},
]
end
end
diff --git a/app/models/project_statistics.rb b/app/models/project_statistics.rb
index 781a197d56f..026ed278ec9 100644
--- a/app/models/project_statistics.rb
+++ b/app/models/project_statistics.rb
@@ -7,7 +7,7 @@ class ProjectStatistics < ActiveRecord::Base
before_save :update_storage_size
COLUMNS_TO_REFRESH = [:repository_size, :lfs_objects_size, :commit_count].freeze
- INCREMENTABLE_COLUMNS = { build_artifacts_size: %i[storage_size] }.freeze
+ INCREMENTABLE_COLUMNS = {build_artifacts_size: %i[storage_size]}.freeze
def total_repository_size
repository_size + lfs_objects_size
@@ -62,6 +62,6 @@ class ProjectStatistics < ActiveRecord::Base
end
end
- update_all(updates.join(', '))
+ update_all(updates.join(", "))
end
end
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index aeba2843e5d..f09bcbe9062 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -26,7 +26,7 @@ class ProjectTeam
end
# @deprecated
- alias_method :add_master, :add_maintainer
+ alias add_master add_maintainer
def add_role(user, role, current_user: nil)
public_send(:"add_#{role}", user, current_user: current_user) # rubocop:disable GitlabSecurity/PublicSend
@@ -72,7 +72,7 @@ class ProjectTeam
def members
@members ||= fetch_members
end
- alias_method :users, :members
+ alias users members
# `members` method uses project_authorizations table which
# is updated asynchronously, on project move it still contains
@@ -99,7 +99,7 @@ class ProjectTeam
end
# @deprecated
- alias_method :masters, :maintainers
+ alias masters maintainers
def owners
@owners ||=
@@ -157,7 +157,7 @@ class ProjectTeam
end
# @deprecated
- alias_method :master?, :maintainer?
+ alias master? maintainer?
# Checks if `user` is authorized for this project, with at least the
# `min_access_level` (if given).
@@ -177,9 +177,9 @@ class ProjectTeam
def max_member_access_for_user_ids(user_ids)
max_member_access_for_resource_ids(User, user_ids, project.id) do |user_ids|
project.project_authorizations
- .where(user: user_ids)
- .group(:user_id)
- .maximum(:access_level)
+ .where(user: user_ids)
+ .group(:user_id)
+ .maximum(:access_level)
end
end
@@ -191,7 +191,7 @@ class ProjectTeam
def fetch_members(level = nil)
members = project.authorized_users
- members = members.where(project_authorizations: { access_level: level }) if level
+ members = members.where(project_authorizations: {access_level: level}) if level
members
end
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index c43bd45a62f..dcecb14f707 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -4,14 +4,16 @@ class ProjectWiki
include Gitlab::ShellAdapter
include Storage::LegacyProjectWiki
- MARKUPS = {
- 'Markdown' => :markdown,
- 'RDoc' => :rdoc,
- 'AsciiDoc' => :asciidoc
- }.freeze unless defined?(MARKUPS)
+ unless defined?(MARKUPS)
+ MARKUPS = {
+ "Markdown" => :markdown,
+ "RDoc" => :rdoc,
+ "AsciiDoc" => :asciidoc,
+ }.freeze
+ end
CouldNotCreateWikiError = Class.new(StandardError)
- SIDEBAR = '_sidebar'
+ SIDEBAR = "_sidebar"
# Returns a string describing what went wrong after
# an operation fails.
@@ -26,15 +28,15 @@ class ProjectWiki
delegate :repository_storage, :hashed_storage?, to: :project
def path
- @project.path + '.wiki'
+ @project.path + ".wiki"
end
def full_path
- @project.full_path + '.wiki'
+ @project.full_path + ".wiki"
end
# @deprecated use full_path when you need it for an URL route or disk_path when you want to point to the filesystem
- alias_method :path_with_namespace, :full_path
+ alias path_with_namespace full_path
def web_url
Gitlab::Routing.url_helpers.project_wiki_url(@project, :home)
@@ -53,14 +55,14 @@ class ProjectWiki
end
def wiki_base_path
- [Gitlab.config.gitlab.relative_url_root, '/', @project.full_path, '/wikis'].join('')
+ [Gitlab.config.gitlab.relative_url_root, "/", @project.full_path, "/wikis"].join("")
end
# Returns the Gitlab::Git::Wiki object.
def wiki
@wiki ||= begin
gl_repository = Gitlab::GlRepository.gl_repository(project, true)
- raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + '.git', gl_repository, full_path)
+ raw_repository = Gitlab::Git::Repository.new(project.repository_storage, disk_path + ".git", gl_repository, full_path)
create_repo!(raw_repository) unless raw_repository.exists?
@@ -73,7 +75,7 @@ class ProjectWiki
end
def has_home_page?
- !!find_page('home')
+ !!find_page("home")
end
def empty?
@@ -168,7 +170,7 @@ class ProjectWiki
git_ssh_url: ssh_url_to_repo,
git_http_url: http_url_to_repo,
path_with_namespace: full_path,
- default_branch: default_branch
+ default_branch: default_branch,
}
end
@@ -187,10 +189,10 @@ class ProjectWiki
git_user = Gitlab::Git::User.from_gitlab(@user)
Gitlab::Git::Wiki::CommitDetails.new(@user.id,
- git_user.username,
- git_user.name,
- git_user.email,
- commit_message)
+ git_user.username,
+ git_user.name,
+ git_user.email,
+ commit_message)
end
def default_message(action, title)
diff --git a/app/models/prometheus_metric.rb b/app/models/prometheus_metric.rb
index 5594594a48d..e49b28c61eb 100644
--- a/app/models/prometheus_metric.rb
+++ b/app/models/prometheus_metric.rb
@@ -15,55 +15,55 @@ class PrometheusMetric < ActiveRecord::Base
# custom/user groups
business: 0,
response: 1,
- system: 2
+ system: 2,
}
GROUP_DETAILS = {
# built-in groups
nginx_ingress_vts: {
- group_title: _('Response metrics (NGINX Ingress VTS)'),
- required_metrics: %w(nginx_upstream_responses_total nginx_upstream_response_msecs_avg),
- priority: 10
+ group_title: _("Response metrics (NGINX Ingress VTS)"),
+ required_metrics: %w[nginx_upstream_responses_total nginx_upstream_response_msecs_avg],
+ priority: 10,
}.freeze,
nginx_ingress: {
- group_title: _('Response metrics (NGINX Ingress)'),
- required_metrics: %w(nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum),
- priority: 10
+ group_title: _("Response metrics (NGINX Ingress)"),
+ required_metrics: %w[nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum],
+ priority: 10,
}.freeze,
ha_proxy: {
- group_title: _('Response metrics (HA Proxy)'),
- required_metrics: %w(haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total),
- priority: 10
+ group_title: _("Response metrics (HA Proxy)"),
+ required_metrics: %w[haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total],
+ priority: 10,
}.freeze,
aws_elb: {
- group_title: _('Response metrics (AWS ELB)'),
- required_metrics: %w(aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum),
- priority: 10
+ group_title: _("Response metrics (AWS ELB)"),
+ required_metrics: %w[aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum],
+ priority: 10,
}.freeze,
nginx: {
- group_title: _('Response metrics (NGINX)'),
- required_metrics: %w(nginx_server_requests nginx_server_requestMsec),
- priority: 10
+ group_title: _("Response metrics (NGINX)"),
+ required_metrics: %w[nginx_server_requests nginx_server_requestMsec],
+ priority: 10,
}.freeze,
kubernetes: {
- group_title: _('System metrics (Kubernetes)'),
- required_metrics: %w(container_memory_usage_bytes container_cpu_usage_seconds_total),
- priority: 5
+ group_title: _("System metrics (Kubernetes)"),
+ required_metrics: %w[container_memory_usage_bytes container_cpu_usage_seconds_total],
+ priority: 5,
}.freeze,
# custom/user groups
business: {
- group_title: _('Business metrics (Custom)'),
- priority: 0
+ group_title: _("Business metrics (Custom)"),
+ priority: 0,
}.freeze,
response: {
- group_title: _('Response metrics (Custom)'),
- priority: -5
+ group_title: _("Response metrics (Custom)"),
+ priority: -5,
}.freeze,
system: {
- group_title: _('System metrics (Custom)'),
- priority: -10
- }.freeze
+ group_title: _("System metrics (Custom)"),
+ priority: -10,
+ }.freeze,
}.freeze
validates :title, presence: true
@@ -99,21 +99,21 @@ class PrometheusMetric < ActiveRecord::Base
query_range: query,
unit: unit,
label: legend,
- series: query_series
- }.compact
+ series: query_series,
+ }.compact,
]
end
def query_series
case legend
- when 'Status Code'
+ when "Status Code"
[{
- label: 'status_code',
+ label: "status_code",
when: [
- { value: '2xx', color: 'green' },
- { value: '4xx', color: 'orange' },
- { value: '5xx', color: 'red' }
- ]
+ {value: "2xx", color: "green"},
+ {value: "4xx", color: "orange"},
+ {value: "5xx", color: "red"},
+ ],
}]
end
end
diff --git a/app/models/protectable_dropdown.rb b/app/models/protectable_dropdown.rb
index 25e70ab406c..78348dccb30 100644
--- a/app/models/protectable_dropdown.rb
+++ b/app/models/protectable_dropdown.rb
@@ -16,7 +16,7 @@ class ProtectableDropdown
end
def hash
- protectable_ref_names.map { |ref_name| { text: ref_name, id: ref_name, title: ref_name } }
+ protectable_ref_names.map { |ref_name| {text: ref_name, id: ref_name, title: ref_name} }
end
private
diff --git a/app/models/protected_branch.rb b/app/models/protected_branch.rb
index d075440b147..559c90eba86 100644
--- a/app/models/protected_branch.rb
+++ b/app/models/protected_branch.rb
@@ -20,7 +20,7 @@ class ProtectedBranch < ActiveRecord::Base
refs = project.protected_branches.select(:name)
- self.matching(ref_name, protected_refs: refs).present?
+ matching(ref_name, protected_refs: refs).present?
end
def self.default_branch_protected?
diff --git a/app/models/protected_tag.rb b/app/models/protected_tag.rb
index d28ebabfe49..901dacee18c 100644
--- a/app/models/protected_tag.rb
+++ b/app/models/protected_tag.rb
@@ -3,13 +3,13 @@
class ProtectedTag < ActiveRecord::Base
include ProtectedRef
- validates :name, uniqueness: { scope: :project_id }
+ validates :name, uniqueness: {scope: :project_id}
protected_ref_access_levels :create
def self.protected?(project, ref_name)
refs = project.protected_tags.select(:name)
- self.matching(ref_name, protected_refs: refs).present?
+ matching(ref_name, protected_refs: refs).present?
end
end
diff --git a/app/models/push_event.rb b/app/models/push_event.rb
index 9c0267c3140..dc9410930f8 100644
--- a/app/models/push_event.rb
+++ b/app/models/push_event.rb
@@ -24,18 +24,18 @@ class PushEvent < Event
delegate :commit_title, to: :push_event_payload
delegate :commit_count, to: :push_event_payload
- alias_method :commits_count, :commit_count
+ alias commits_count commit_count
# Returns events of pushes that either pushed to an existing ref or created a
# new one.
def self.created_or_pushed
actions = [
PushEventPayload.actions[:pushed],
- PushEventPayload.actions[:created]
+ PushEventPayload.actions[:created],
]
joins(:push_event_payload)
- .where(push_event_payloads: { action: actions })
+ .where(push_event_payloads: {action: actions})
end
# Returns events of pushes to a branch.
@@ -43,15 +43,15 @@ class PushEvent < Event
ref_type = PushEventPayload.ref_types[:branch]
joins(:push_event_payload)
- .where(push_event_payloads: { ref_type: ref_type })
+ .where(push_event_payloads: {ref_type: ref_type})
end
# Returns PushEvent instances for which no merge requests have been created.
def self.without_existing_merge_requests
existing_mrs = MergeRequest.except(:order, :where)
.select(1)
- .where('merge_requests.source_project_id = events.project_id')
- .where('merge_requests.source_branch = push_event_payloads.ref')
+ .where("merge_requests.source_project_id = events.project_id")
+ .where("merge_requests.source_branch = push_event_payloads.ref")
.where(state: :opened)
# For reasons unknown the use of #eager_load will result in the
@@ -60,7 +60,7 @@ class PushEvent < Event
# executed in order to retrieve the "push_event_association" when the
# returned PushEvent is used.
joins(:push_event_payload)
- .where('NOT EXISTS (?)', existing_mrs)
+ .where("NOT EXISTS (?)", existing_mrs)
.created_or_pushed
.branch_events
end
@@ -97,8 +97,8 @@ class PushEvent < Event
push_event_payload.ref
end
- alias_method :branch_name, :ref_name
- alias_method :tag_name, :ref_name
+ alias branch_name ref_name
+ alias tag_name ref_name
def commit_id
commit_to || commit_from
diff --git a/app/models/push_event_payload.rb b/app/models/push_event_payload.rb
index c7769edf055..449a7fef123 100644
--- a/app/models/push_event_payload.rb
+++ b/app/models/push_event_payload.rb
@@ -6,7 +6,7 @@ class PushEventPayload < ActiveRecord::Base
belongs_to :event, inverse_of: :push_event_payload
validates :event_id, :commit_count, :action, :ref_type, presence: true
- validates :commit_title, length: { maximum: 70 }
+ validates :commit_title, length: {maximum: 70}
sha_attribute :commit_from
sha_attribute :commit_to
@@ -14,11 +14,11 @@ class PushEventPayload < ActiveRecord::Base
enum action: {
created: 0,
removed: 1,
- pushed: 2
+ pushed: 2,
}
enum ref_type: {
branch: 0,
- tag: 1
+ tag: 1,
}
end
diff --git a/app/models/redirect_route.rb b/app/models/redirect_route.rb
index c6bd4bb6dfa..055ba2f4dc3 100644
--- a/app/models/redirect_route.rb
+++ b/app/models/redirect_route.rb
@@ -6,16 +6,16 @@ class RedirectRoute < ActiveRecord::Base
validates :source, presence: true
validates :path,
- length: { within: 1..255 },
+ length: {within: 1..255},
presence: true,
- uniqueness: { case_sensitive: false }
+ uniqueness: {case_sensitive: false}
- scope :matching_path_and_descendants, -> (path) do
+ scope :matching_path_and_descendants, ->(path) do
wheres = if Gitlab::Database.postgresql?
- 'LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)'
- else
- 'redirect_routes.path = ? OR redirect_routes.path LIKE ?'
- end
+ "LOWER(redirect_routes.path) = LOWER(?) OR LOWER(redirect_routes.path) LIKE LOWER(?)"
+ else
+ "redirect_routes.path = ? OR redirect_routes.path LIKE ?"
+ end
where(wheres, path, "#{sanitize_sql_like(path)}/%")
end
diff --git a/app/models/ref_matcher.rb b/app/models/ref_matcher.rb
index fa7d2c0f06c..fdd33ca3567 100644
--- a/app/models/ref_matcher.rb
+++ b/app/models/ref_matcher.rb
@@ -20,7 +20,7 @@ class RefMatcher
# Checks if this protected ref contains a wildcard
def wildcard?
- @ref_name_or_pattern && @ref_name_or_pattern.include?('*')
+ @ref_name_or_pattern&.include?("*")
end
protected
@@ -37,9 +37,9 @@ class RefMatcher
def wildcard_regex
@wildcard_regex ||= begin
- name = @ref_name_or_pattern.gsub('*', 'STAR_DONT_ESCAPE')
+ name = @ref_name_or_pattern.gsub("*", "STAR_DONT_ESCAPE")
quoted_name = Regexp.quote(name)
- regex_string = quoted_name.gsub('STAR_DONT_ESCAPE', '.*?')
+ regex_string = quoted_name.gsub("STAR_DONT_ESCAPE", ".*?")
/\A#{regex_string}\z/
end
end
diff --git a/app/models/release.rb b/app/models/release.rb
index 0dae5c90394..cc53f13a780 100644
--- a/app/models/release.rb
+++ b/app/models/release.rb
@@ -8,9 +8,9 @@ class Release < ActiveRecord::Base
belongs_to :project
# releases prior to 11.7 have no author
- belongs_to :author, class_name: 'User'
+ belongs_to :author, class_name: "User"
- has_many :links, class_name: 'Releases::Link'
+ has_many :links, class_name: "Releases::Link"
accepts_nested_attributes_for :links, allow_destroy: true
diff --git a/app/models/releases/link.rb b/app/models/releases/link.rb
index 6c507c47752..38ba8a2c90d 100644
--- a/app/models/releases/link.rb
+++ b/app/models/releases/link.rb
@@ -2,12 +2,12 @@
module Releases
class Link < ActiveRecord::Base
- self.table_name = 'release_links'
+ self.table_name = "release_links"
belongs_to :release
- validates :url, presence: true, url: { protocols: %w(http https ftp) }, uniqueness: { scope: :release }
- validates :name, presence: true, uniqueness: { scope: :release }
+ validates :url, presence: true, url: {protocols: %w[http https ftp]}, uniqueness: {scope: :release}
+ validates :name, presence: true, uniqueness: {scope: :release}
scope :sorted, -> { order(created_at: :desc) }
diff --git a/app/models/releases/source.rb b/app/models/releases/source.rb
index 4d3d54457af..4ed08315b54 100644
--- a/app/models/releases/source.rb
+++ b/app/models/releases/source.rb
@@ -6,7 +6,7 @@ module Releases
attr_accessor :project, :tag_name, :format
- FORMATS = %w(zip tar.gz tar.bz2 tar).freeze
+ FORMATS = %w[zip tar.gz tar.bz2 tar].freeze
class << self
def all(project, tag_name)
@@ -22,14 +22,14 @@ module Releases
Gitlab::Routing
.url_helpers
.project_archive_url(project,
- id: File.join(tag_name, archive_prefix),
- format: format)
+ id: File.join(tag_name, archive_prefix),
+ format: format)
end
private
def archive_prefix
- "#{project.path}-#{tag_name.tr('/', '-')}"
+ "#{project.path}-#{tag_name.tr("/", "-")}"
end
end
end
diff --git a/app/models/remote_mirror.rb b/app/models/remote_mirror.rb
index 5eba7ddd75c..78b4689338a 100644
--- a/app/models/remote_mirror.rb
+++ b/app/models/remote_mirror.rb
@@ -8,16 +8,16 @@ class RemoteMirror < ActiveRecord::Base
UNPROTECTED_BACKOFF_DELAY = 5.minutes
attr_encrypted :credentials,
- key: Settings.attr_encrypted_db_key_base,
- marshal: true,
- encode: true,
- mode: :per_attribute_iv_and_salt,
- insecure_mode: true,
- algorithm: 'aes-256-cbc'
+ key: Settings.attr_encrypted_db_key_base,
+ marshal: true,
+ encode: true,
+ mode: :per_attribute_iv_and_salt,
+ insecure_mode: true,
+ algorithm: "aes-256-cbc"
belongs_to :project, inverse_of: :remote_mirrors
- validates :url, presence: true, public_url: { protocols: %w(ssh git http https), allow_blank: true, enforce_user: true }
+ validates :url, presence: true, public_url: {protocols: %w[ssh git http https], allow_blank: true, enforce_user: true}
before_save :set_new_remote_name, if: :mirror_url_changed?
@@ -31,7 +31,7 @@ class RemoteMirror < ActiveRecord::Base
scope :enabled, -> { where(enabled: true) }
scope :started, -> { with_update_status(:started) }
- scope :stuck, -> { started.where('last_update_at < ? OR (last_update_at IS NULL AND updated_at < ?)', 1.day.ago, 1.day.ago) }
+ scope :stuck, -> { started.where("last_update_at < ? OR (last_update_at IS NULL AND updated_at < ?)", 1.day.ago, 1.day.ago) }
state_machine :update_status, initial: :none do
event :update_start do
@@ -84,11 +84,11 @@ class RemoteMirror < ActiveRecord::Base
end
def update_failed?
- update_status == 'failed'
+ update_status == "failed"
end
def update_in_progress?
- update_status == 'started'
+ update_status == "started"
end
def update_repository(options)
@@ -117,9 +117,9 @@ class RemoteMirror < ActiveRecord::Base
return unless sync?
if recently_scheduled?
- RepositoryUpdateRemoteMirrorWorker.perform_in(backoff_delay, self.id, Time.now)
+ RepositoryUpdateRemoteMirrorWorker.perform_in(backoff_delay, id, Time.now)
else
- RepositoryUpdateRemoteMirrorWorker.perform_async(self.id, Time.now)
+ RepositoryUpdateRemoteMirrorWorker.perform_async(id, Time.now)
end
end
@@ -131,7 +131,7 @@ class RemoteMirror < ActiveRecord::Base
true
end
- alias_method :enabled?, :enabled
+ alias enabled? enabled
def updated_since?(timestamp)
last_update_started_at && last_update_started_at > timestamp && !update_failed?
@@ -168,8 +168,8 @@ class RemoteMirror < ActiveRecord::Base
return if url.nil?
result = URI.parse(url)
- result.password = '*****' if result.password
- result.user = '*****' if result.user && result.user != "git" # tokens or other data may be saved as user
+ result.password = "*****" if result.password
+ result.user = "*****" if result.user && result.user != "git" # tokens or other data may be saved as user
result.to_s
end
@@ -198,7 +198,7 @@ class RemoteMirror < ActiveRecord::Base
def remote_url
return url unless ssh_key_auth? && password.present?
- Gitlab::UrlSanitizer.new(read_attribute(:url), credentials: { user: user }).full_url
+ Gitlab::UrlSanitizer.new(read_attribute(:url), credentials: {user: user}).full_url
rescue
super
end
@@ -210,13 +210,13 @@ class RemoteMirror < ActiveRecord::Base
end
def recently_scheduled?
- return false unless self.last_update_started_at
+ return false unless last_update_started_at
- self.last_update_started_at >= Time.now - backoff_delay
+ last_update_started_at >= Time.now - backoff_delay
end
def backoff_delay
- if self.only_protected_branches
+ if only_protected_branches
PROTECTED_BACKOFF_DELAY
else
UNPROTECTED_BACKOFF_DELAY
@@ -228,7 +228,7 @@ class RemoteMirror < ActiveRecord::Base
last_error: nil,
last_update_at: nil,
last_successful_update_at: nil,
- update_status: 'finished',
+ update_status: "finished",
error_notification_sent: false
)
end
diff --git a/app/models/repository.rb b/app/models/repository.rb
index cd761a29618..2e42709452b 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
class Repository
- REF_MERGE_REQUEST = 'merge-requests'.freeze
- REF_KEEP_AROUND = 'keep-around'.freeze
- REF_ENVIRONMENTS = 'environments'.freeze
+ REF_MERGE_REQUEST = "merge-requests"
+ REF_KEEP_AROUND = "keep-around"
+ REF_ENVIRONMENTS = "environments"
MAX_DIVERGING_COUNT = 1000
RESERVED_REFS_NAMES = %W[
@@ -35,29 +35,29 @@ class Repository
#
# For example, for entry `:commit_count` there's a method called `commit_count` which
# stores its data in the `commit_count` cache key.
- CACHED_METHODS = %i(size commit_count rendered_readme readme_path contribution_guide
+ CACHED_METHODS = %i[size commit_count rendered_readme readme_path contribution_guide
changelog license_blob license_key gitignore
gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref has_visible_content?
- issue_template_names merge_request_template_names xcode_project?).freeze
+ issue_template_names merge_request_template_names xcode_project?].freeze
# Methods that use cache_method but only memoize the value
- MEMOIZED_CACHED_METHODS = %i(license).freeze
+ MEMOIZED_CACHED_METHODS = %i[license].freeze
# Certain method caches should be refreshed when certain types of files are
# changed. This Hash maps file types (as returned by Gitlab::FileDetector) to
# the corresponding methods to call for refreshing caches.
METHOD_CACHES_FOR_FILE_TYPES = {
- readme: %i(rendered_readme readme_path),
+ readme: %i[rendered_readme readme_path],
changelog: :changelog,
- license: %i(license_blob license_key license),
+ license: %i[license_blob license_key license],
contributing: :contribution_guide,
gitignore: :gitignore,
gitlab_ci: :gitlab_ci_yml,
avatar: :avatar,
issue_template: :issue_template_names,
merge_request_template: :merge_request_template_names,
- xcode_config: :xcode_project?
+ xcode_config: :xcode_project?,
}.freeze
def initialize(full_path, project, disk_path: nil, is_wiki: false)
@@ -72,7 +72,7 @@ class Repository
other.is_a?(self.class) && @disk_path == other.disk_path
end
- alias_method :eql?, :==
+ alias eql? ==
def hash
[self.class, @disk_path].hash
@@ -84,7 +84,7 @@ class Repository
@raw_repository ||= initialize_raw_repository
end
- alias_method :raw, :raw_repository
+ alias raw raw_repository
# Don't use this! It's going away. Use Gitaly to read or write from repos.
def path_to_repo
@@ -93,7 +93,7 @@ class Repository
storage = Gitlab.config.repositories.storages[@project.repository_storage]
File.expand_path(
- File.join(storage.legacy_disk_path, disk_path + '.git')
+ File.join(storage.legacy_disk_path, disk_path + ".git")
)
end
end
@@ -140,7 +140,7 @@ class Repository
before: before,
follow: Array(path).length == 1,
skip_merges: skip_merges,
- all: all
+ all: all,
}
commits = Gitlab::Git::Commit.where(options)
@@ -168,9 +168,9 @@ class Repository
return []
end
- commits = raw_repository.find_commits_by_message(query, ref, path, limit, offset).map do |c|
+ commits = raw_repository.find_commits_by_message(query, ref, path, limit, offset).map { |c|
commit(c)
- end
+ }
CommitCollection.new(project, commits, ref)
end
@@ -265,16 +265,14 @@ class Repository
# to avoid unnecessary syncing.
def keep_around(*shas)
shas.each do |sha|
- begin
- next unless sha.present? && commit_by(oid: sha)
+ next unless sha.present? && commit_by(oid: sha)
- next if kept_around?(sha)
+ next if kept_around?(sha)
- # This will still fail if the file is corrupted (e.g. 0 bytes)
- raw_repository.write_ref(keep_around_ref_name(sha), sha)
- rescue Gitlab::Git::CommandError => ex
- Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}"
- end
+ # This will still fail if the file is corrupted (e.g. 0 bytes)
+ raw_repository.write_ref(keep_around_ref_name(sha), sha)
+ rescue Gitlab::Git::CommandError => ex
+ Rails.logger.error "Unable to create keep-around reference for repository #{disk_path}: #{ex}"
end
end
@@ -291,12 +289,13 @@ class Repository
raw_repository.diverging_commit_count(
@root_ref_hash,
branch.dereferenced_target.sha,
- max_count: MAX_DIVERGING_COUNT)
+ max_count: MAX_DIVERGING_COUNT
+ )
if number_commits_behind + number_commits_ahead >= MAX_DIVERGING_COUNT
- { distance: MAX_DIVERGING_COUNT }
+ {distance: MAX_DIVERGING_COUNT}
else
- { behind: number_commits_behind, ahead: number_commits_ahead }
+ {behind: number_commits_behind, ahead: number_commits_ahead}
end
end
end
@@ -316,18 +315,18 @@ class Repository
end
def expire_tags_cache
- expire_method_caches(%i(tag_names tag_count))
+ expire_method_caches(%i[tag_names tag_count])
@tags = nil
end
def expire_branches_cache
- expire_method_caches(%i(branch_names branch_count has_visible_content?))
+ expire_method_caches(%i[branch_names branch_count has_visible_content?])
@local_branches = nil
@branch_exists_memo = nil
end
def expire_statistics_caches
- expire_method_caches(%i(size commit_count))
+ expire_method_caches(%i[size commit_count])
end
def expire_all_method_caches
@@ -335,7 +334,7 @@ class Repository
end
def expire_avatar_cache
- expire_method_caches(%i(avatar))
+ expire_method_caches(%i[avatar])
end
# Refreshes the method caches of this repository.
@@ -376,14 +375,14 @@ class Repository
end
def expire_root_ref_cache
- expire_method_caches(%i(root_ref))
+ expire_method_caches(%i[root_ref])
end
# Expires the cache(s) used to determine if a repository is empty or not.
def expire_emptiness_caches
return unless empty?
- expire_method_caches(%i(has_visible_content?))
+ expire_method_caches(%i[has_visible_content?])
raw_repository.expire_has_local_branches_cache
end
@@ -392,7 +391,7 @@ class Repository
end
def expire_exists_cache
- expire_method_caches(%i(exists?))
+ expire_method_caches(%i[exists?])
end
# expire cache that doesn't depend on repository data (when expiring)
@@ -616,7 +615,7 @@ class Repository
def rendered_readme
return unless readme
- context = { project: project }
+ context = {project: project}
MarkupHelper.markup_unsafe(readme.name, readme.data, context)
end
@@ -667,7 +666,7 @@ class Repository
cache_method :xcode_project?
def head_commit
- @head_commit ||= commit(self.root_ref)
+ @head_commit ||= commit(root_ref)
end
def head_tree
@@ -695,8 +694,6 @@ class Repository
if last_commit
blob_at(last_commit.sha, path)
- else
- nil
end
end
@@ -722,16 +719,16 @@ class Repository
end
def next_branch(name, opts = {})
- branch_ids = self.branch_names.map do |n|
+ branch_ids = branch_names.map { |n|
next 1 if n == name
result = n.match(/\A#{name}-([0-9]+)\z/)
result[1].to_i if result
- end.compact
+ }.compact
highest_branch_id = branch_ids.max || 0
- return name if opts[:mild] && 0 == highest_branch_id
+ return name if opts[:mild] && highest_branch_id == 0
"#{name}-#{highest_branch_id + 1}"
end
@@ -742,13 +739,13 @@ class Repository
def tags_sorted_by(value)
case value
- when 'name_asc'
+ when "name_asc"
VersionSorter.sort(tags) { |tag| tag.name }
- when 'name_desc'
+ when "name_desc"
VersionSorter.rsort(tags) { |tag| tag.name }
- when 'updated_desc'
+ when "updated_desc"
tags_sorted_by_committed_date.reverse
- when 'updated_asc'
+ when "updated_asc"
tags_sorted_by_committed_date
else
tags
@@ -759,10 +756,10 @@ class Repository
#
# order_by: name|email|commits
# sort: asc|desc default: 'asc'
- def contributors(order_by: nil, sort: 'asc')
+ def contributors(order_by: nil, sort: "asc")
commits = self.commits(nil, limit: 2000, offset: 0, skip_merges: true)
- commits = commits.group_by(&:author_email).map do |email, commits|
+ commits = commits.group_by(&:author_email).map { |email, commits|
contributor = Gitlab::Contributor.new
contributor.email = email
@@ -775,7 +772,7 @@ class Repository
end
contributor
- end
+ }
Commit.order_by(collection: commits, order_by: order_by, sort: sort)
end
@@ -791,20 +788,20 @@ class Repository
@local_branches ||= raw_repository.local_branches
end
- alias_method :branches, :local_branches
+ alias branches local_branches
def tags
@tags ||= raw_repository.tags
end
def create_dir(user, path, **options)
- options[:actions] = [{ action: :create_dir, file_path: path }]
+ options[:actions] = [{action: :create_dir, file_path: path}]
multi_action(user, **options)
end
def create_file(user, path, content, **options)
- options[:actions] = [{ action: :create, file_path: path, content: content }]
+ options[:actions] = [{action: :create, file_path: path, content: content}]
multi_action(user, **options)
end
@@ -813,13 +810,13 @@ class Repository
previous_path = options.delete(:previous_path)
action = previous_path && previous_path != path ? :move : :update
- options[:actions] = [{ action: action, file_path: path, previous_path: previous_path, content: content }]
+ options[:actions] = [{action: action, file_path: path, previous_path: previous_path, content: content}]
multi_action(user, **options)
end
def delete_file(user, path, **options)
- options[:actions] = [{ action: :delete, file_path: path }]
+ options[:actions] = [{action: :delete, file_path: path}]
multi_action(user, **options)
end
@@ -862,7 +859,7 @@ class Repository
def ff_merge(user, source, target_branch, merge_request: nil)
their_commit_id = commit(source)&.id
- raise 'Invalid merge source' if their_commit_id.nil?
+ raise "Invalid merge source" if their_commit_id.nil?
merge_request&.update(in_progress_merge_commit_sha: their_commit_id)
@@ -871,7 +868,8 @@ class Repository
def revert(
user, commit, branch_name, message,
- start_branch_name: nil, start_project: project)
+ start_branch_name: nil, start_project: project
+ )
with_cache_hooks do
raw_repository.revert(
@@ -887,7 +885,8 @@ class Repository
def cherry_pick(
user, commit, branch_name, message,
- start_branch_name: nil, start_project: project)
+ start_branch_name: nil, start_project: project
+ )
with_cache_hooks do
raw_repository.cherry_pick(
@@ -908,8 +907,6 @@ class Repository
same_head = branch.target == root_ref_sha
merged = ancestor?(branch.target, root_ref_sha)
!same_head && merged
- else
- nil
end
end
@@ -920,9 +917,9 @@ class Repository
delegate :merged_branch_names, to: :raw_repository
def merge_base(*commits_or_ids)
- commit_ids = commits_or_ids.map do |commit_or_id|
+ commit_ids = commits_or_ids.map { |commit_or_id|
commit_or_id.is_a?(::Commit) ? commit_or_id.id : commit_or_id
- end
+ }
raw_repository.merge_base(*commit_ids)
end
@@ -1017,15 +1014,15 @@ class Repository
end
def route_map_for(sha)
- blob_data_at(sha, '.gitlab/route-map.yml')
+ blob_data_at(sha, ".gitlab/route-map.yml")
end
- def gitlab_ci_yml_for(sha, path = '.gitlab-ci.yml')
+ def gitlab_ci_yml_for(sha, path = ".gitlab-ci.yml")
blob_data_at(sha, path)
end
def lfsconfig_for(sha)
- blob_data_at(sha, '.lfsconfig')
+ blob_data_at(sha, ".lfsconfig")
end
def fetch_ref(source_repository, source_ref:, target_ref:)
@@ -1073,10 +1070,10 @@ class Repository
# gitlab-org/gitlab-ce#39239
def find_commit(oid_or_ref)
commit = if oid_or_ref.is_a?(Gitlab::Git::Commit)
- oid_or_ref
- else
- Gitlab::Git::Commit.find(raw_repository, oid_or_ref)
- end
+ oid_or_ref
+ else
+ Gitlab::Git::Commit.find(raw_repository, oid_or_ref)
+ end
::Commit.new(commit, @project) if commit
end
@@ -1114,8 +1111,8 @@ class Repository
def initialize_raw_repository
Gitlab::Git::Repository.new(project.repository_storage,
- disk_path + '.git',
- Gitlab::GlRepository.gl_repository(project, is_wiki),
- project.full_path)
+ disk_path + ".git",
+ Gitlab::GlRepository.gl_repository(project, is_wiki),
+ project.full_path)
end
end
diff --git a/app/models/repository_language.rb b/app/models/repository_language.rb
index b18142a2ac4..72a900cbf86 100644
--- a/app/models/repository_language.rb
+++ b/app/models/repository_language.rb
@@ -7,8 +7,8 @@ class RepositoryLanguage < ActiveRecord::Base
default_scope { includes(:programming_language) }
validates :project, presence: true
- validates :share, inclusion: { in: 0..100, message: "The share of a lanuage is between 0 and 100" }
- validates :programming_language, uniqueness: { scope: :project_id }
+ validates :share, inclusion: {in: 0..100, message: "The share of a lanuage is between 0 and 100"}
+ validates :programming_language, uniqueness: {scope: :project_id}
delegate :name, :color, to: :programming_language
end
diff --git a/app/models/resource_label_event.rb b/app/models/resource_label_event.rb
index 3fd96b9dc18..3ae550035d8 100644
--- a/app/models/resource_label_event.rb
+++ b/app/models/resource_label_event.rb
@@ -14,10 +14,10 @@ class ResourceLabelEvent < ActiveRecord::Base
belongs_to :merge_request
belongs_to :label
- scope :created_after, ->(time) { where('created_at > ?', time) }
+ scope :created_after, ->(time) { where("created_at > ?", time) }
- validates :user, presence: { unless: :importing? }, on: :create
- validates :label, presence: { unless: :importing? }, on: :create
+ validates :user, presence: {unless: :importing?}, on: :create
+ validates :label, presence: {unless: :importing?}, on: :create
validate :exactly_one_issuable
after_save :expire_etag_cache
@@ -25,11 +25,11 @@ class ResourceLabelEvent < ActiveRecord::Base
enum action: {
add: 1,
- remove: 2
+ remove: 2,
}
def self.issuable_attrs
- %i(issue merge_request).freeze
+ %i[issue merge_request].freeze
end
def issuable
@@ -58,12 +58,12 @@ class ResourceLabelEvent < ActiveRecord::Base
end
def banzai_render_context(field)
- super.merge(pipeline: 'label', only_path: true)
+ super.merge(pipeline: "label", only_path: true)
end
def refresh_invalid_reference
# label_id could be nullified on label delete
- self.reference = '' if label_id.nil?
+ self.reference = "" if label_id.nil?
# reference is not set for events which were not rendered yet
self.reference ||= label_reference
@@ -95,12 +95,12 @@ class ResourceLabelEvent < ActiveRecord::Base
# if none of issuable IDs is set, check explicitly if nested issuable
# object is set, this is used during project import
if issuable_count == 0 && importing?
- issuable_count = self.class.issuable_attrs.count { |attr| self.public_send(attr) } # rubocop:disable GitlabSecurity/PublicSend
+ issuable_count = self.class.issuable_attrs.count { |attr| public_send(attr) } # rubocop:disable GitlabSecurity/PublicSend
return true if issuable_count == 1
end
- errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(', ')} is required")
+ errors.add(:base, "Exactly one of #{self.class.issuable_attrs.join(", ")} is required")
end
def expire_etag_cache
@@ -108,7 +108,7 @@ class ResourceLabelEvent < ActiveRecord::Base
end
def local_label?
- params = { include_ancestor_groups: true }
+ params = {include_ancestor_groups: true}
if resource_parent.is_a?(Project)
params[:project_id] = resource_parent.id
else
diff --git a/app/models/route.rb b/app/models/route.rb
index 4b23dfa5778..a68949f9a9f 100644
--- a/app/models/route.rb
+++ b/app/models/route.rb
@@ -8,9 +8,9 @@ class Route < ActiveRecord::Base
validates :source, presence: true
validates :path,
- length: { within: 1..255 },
+ length: {within: 1..255},
presence: true,
- uniqueness: { case_sensitive: false }
+ uniqueness: {case_sensitive: false}
before_validation :delete_conflicting_orphaned_routes
after_create :delete_conflicting_redirects
@@ -18,7 +18,7 @@ class Route < ActiveRecord::Base
after_update :create_redirect_for_old_path
after_update :rename_descendants
- scope :inside_path, -> (path) { where('routes.path LIKE ?', "#{sanitize_sql_like(path)}/%") }
+ scope :inside_path, ->(path) { where("routes.path LIKE ?", "#{sanitize_sql_like(path)}/%") }
def rename_descendants
return unless path_changed? || name_changed?
@@ -70,9 +70,9 @@ class Route < ActiveRecord::Base
def delete_conflicting_orphaned_routes
conflicting = self.class.iwhere(path: path)
- conflicting_orphaned_routes = conflicting.select do |route|
+ conflicting_orphaned_routes = conflicting.select { |route|
route.source.nil?
- end
+ }
conflicting_orphaned_routes.each(&:destroy)
end
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 6caab24143b..31a6ba2191f 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -11,7 +11,7 @@ class SentNotification < ActiveRecord::Base
validates :reply_key, presence: true, uniqueness: true
validates :noteable_id, presence: true, unless: :for_commit?
validates :commit_id, presence: true, if: :for_commit?
- validates :in_reply_to_discussion_id, format: { with: /\A\h{40}\z/, allow_nil: true }
+ validates :in_reply_to_discussion_id, format: {with: /\A\h{40}\z/, allow_nil: true}
validate :note_valid
after_save :keep_around_commit, if: :for_commit?
@@ -63,12 +63,16 @@ class SentNotification < ActiveRecord::Base
end
def for_snippet?
- noteable_type.end_with?('Snippet')
+ noteable_type.end_with?("Snippet")
end
def noteable
if for_commit?
- project.commit(commit_id) rescue nil
+ begin
+ project.commit(commit_id)
+ rescue
+ nil
+ end
else
super
end
@@ -76,7 +80,11 @@ class SentNotification < ActiveRecord::Base
def position=(new_position)
if new_position.is_a?(String)
- new_position = JSON.parse(new_position) rescue nil
+ new_position = begin
+ JSON.parse(new_position)
+ rescue
+ nil
+ end
end
if new_position.is_a?(Hash)
@@ -88,34 +96,34 @@ class SentNotification < ActiveRecord::Base
end
def to_param
- self.reply_key
+ reply_key
end
def create_reply(message, dryrun: false)
klass = dryrun ? Notes::BuildService : Notes::CreateService
- klass.new(self.project, self.recipient, reply_params.merge(note: message)).execute
+ klass.new(project, recipient, reply_params.merge(note: message)).execute
end
private
def reply_params
{
- noteable_type: self.noteable_type,
- noteable_id: self.noteable_id,
- commit_id: self.commit_id,
- in_reply_to_discussion_id: self.in_reply_to_discussion_id
+ noteable_type: noteable_type,
+ noteable_id: noteable_id,
+ commit_id: commit_id,
+ in_reply_to_discussion_id: in_reply_to_discussion_id,
}
end
def note_valid
- note = create_reply('Test', dryrun: true)
+ note = create_reply("Test", dryrun: true)
unless note.valid?
- self.errors.add(:base, "Note parameters are invalid: #{note.errors.full_messages.to_sentence}")
+ errors.add(:base, "Note parameters are invalid: #{note.errors.full_messages.to_sentence}")
end
end
def keep_around_commit
- project.repository.keep_around(self.commit_id)
+ project.repository.keep_around(commit_id)
end
end
diff --git a/app/models/service.rb b/app/models/service.rb
index da523bfa426..3185be9129e 100644
--- a/app/models/service.rb
+++ b/app/models/service.rb
@@ -34,9 +34,9 @@ class Service < ActiveRecord::Base
validates :project_id, presence: true, unless: proc { |service| service.template? }
validates :type, presence: true
- scope :visible, -> { where.not(type: 'GitlabIssueTrackerService') }
- scope :issue_trackers, -> { where(category: 'issue_tracker') }
- scope :external_wikis, -> { where(type: 'ExternalWikiService').active }
+ scope :visible, -> { where.not(type: "GitlabIssueTrackerService") }
+ scope :issue_trackers, -> { where(category: "issue_tracker") }
+ scope :external_wikis, -> { where(type: "ExternalWikiService").active }
scope :active, -> { where(active: true) }
scope :without_defaults, -> { where(default: false) }
@@ -51,9 +51,9 @@ class Service < ActiveRecord::Base
scope :pipeline_hooks, -> { where(pipeline_events: true, active: true) }
scope :wiki_page_hooks, -> { where(wiki_page_events: true, active: true) }
scope :external_issue_trackers, -> { issue_trackers.active.without_defaults }
- scope :deployment, -> { where(category: 'deployment') }
+ scope :deployment, -> { where(category: "deployment") }
- default_value_for :category, 'common'
+ default_value_for :category, "common"
def activated?
active
@@ -118,7 +118,7 @@ class Service < ActiveRecord::Base
end
def self.event_names
- self.supported_events.map { |event| "#{event}_events" }
+ supported_events.map { |event| "#{event}_events" }
end
def event_field(event)
@@ -150,7 +150,7 @@ class Service < ActiveRecord::Base
end
def self.supported_events
- %w(push tag_push issue confidential_issue merge_request wiki_page)
+ %w[push tag_push issue confidential_issue merge_request wiki_page]
end
def execute(data)
@@ -160,7 +160,7 @@ class Service < ActiveRecord::Base
def test(data)
# default implementation
result = execute(data)
- { success: result.present?, result: result }
+ {success: result.present?, result: result}
end
def can_test?
@@ -204,7 +204,7 @@ class Service < ActiveRecord::Base
# for each serialized property.
# Also keep track of updated properties in a similar way as ActiveModel::Dirty
def self.boolean_accessor(*args)
- self.prop_accessor(*args)
+ prop_accessor(*args)
args.each do |arg|
class_eval %{
@@ -237,7 +237,7 @@ class Service < ActiveRecord::Base
end
def issue_tracker?
- self.category == :issue_tracker
+ category == :issue_tracker
end
def self.available_services_names
diff --git a/app/models/snippet.rb b/app/models/snippet.rb
index f23ddd64fe3..9337b822936 100644
--- a/app/models/snippet.rb
+++ b/app/models/snippet.rb
@@ -27,14 +27,14 @@ class Snippet < ActiveRecord::Base
alias_attribute :last_edited_by, :updated_by
# If file_name changes, it invalidates content
- alias_method :default_content_html_invalidator, :content_html_invalidated?
+ alias default_content_html_invalidator content_html_invalidated?
def content_html_invalidated?
default_content_html_invalidator || file_name_changed?
end
default_value_for(:visibility_level) { Gitlab::CurrentSettings.default_snippet_visibility }
- belongs_to :author, class_name: 'User'
+ belongs_to :author, class_name: "User"
belongs_to :project
has_many :notes, as: :noteable, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -42,12 +42,12 @@ class Snippet < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true, allow_nil: true
validates :author, presence: true
- validates :title, presence: true, length: { maximum: 255 }
+ validates :title, presence: true, length: {maximum: 255}
validates :file_name,
- length: { maximum: 255 }
+ length: {maximum: 255}
validates :content, presence: true
- validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values }
+ validates :visibility_level, inclusion: {in: Gitlab::VisibilityLevel.values}
# Scopes
scope :are_internal, -> { where(visibility_level: Snippet::INTERNAL) }
@@ -78,7 +78,7 @@ class Snippet < ActiveRecord::Base
def self.only_include_projects_visible_to(current_user = nil)
levels = Gitlab::VisibilityLevel.levels_for_user(current_user)
- joins(:project).where('projects.visibility_level IN (?)', levels)
+ joins(:project).where("projects.visibility_level IN (?)", levels)
end
def self.only_include_projects_with_snippets_enabled(include_private: false)
@@ -88,15 +88,15 @@ class Snippet < ActiveRecord::Base
levels << ProjectFeature::PRIVATE if include_private
joins(project: :project_feature)
- .where(project_features: { column => levels })
+ .where(project_features: {column => levels})
end
def self.only_include_authorized_projects(current_user)
where(
- 'EXISTS (?)',
+ "EXISTS (?)",
ProjectAuthorization
.select(1)
- .where('project_id = snippets.project_id')
+ .where("project_id = snippets.project_id")
.where(user_id: current_user.id)
)
end
@@ -113,14 +113,14 @@ class Snippet < ActiveRecord::Base
def self.visible_to_or_authored_by(user)
where(
- 'snippets.visibility_level IN (?) OR snippets.author_id = ?',
+ "snippets.visibility_level IN (?) OR snippets.author_id = ?",
Gitlab::VisibilityLevel.levels_for_user(user),
user.id
)
end
def self.reference_prefix
- '$'
+ "$"
end
# Pattern used to extract `$123` snippet references from text
@@ -151,7 +151,7 @@ class Snippet < ActiveRecord::Base
[
".rb", ".py", ".pl", ".scala", ".c", ".cpp", ".java",
".haml", ".html", ".sass", ".scss", ".xml", ".php", ".erb",
- ".js", ".sh", ".coffee", ".yml", ".md"
+ ".js", ".sh", ".coffee", ".yml", ".md",
]
end
@@ -168,7 +168,7 @@ class Snippet < ActiveRecord::Base
end
def sanitized_file_name
- file_name.gsub(/[^a-zA-Z0-9_\-\.]+/, '')
+ file_name.gsub(/[^a-zA-Z0-9_\-\.]+/, "")
end
def visibility_level_field
@@ -191,7 +191,7 @@ class Snippet < ActiveRecord::Base
end
def spammable_entity_type
- 'snippet'
+ "snippet"
end
class << self
diff --git a/app/models/snippet_blob.rb b/app/models/snippet_blob.rb
index cf1ab089829..b90ae096473 100644
--- a/app/models/snippet_blob.rb
+++ b/app/models/snippet_blob.rb
@@ -15,7 +15,7 @@ class SnippetBlob
snippet.file_name
end
- alias_method :path, :name
+ alias path name
def size
data.bytesize
diff --git a/app/models/spam_log.rb b/app/models/spam_log.rb
index ef3f974b959..63329c1a28a 100644
--- a/app/models/spam_log.rb
+++ b/app/models/spam_log.rb
@@ -6,7 +6,7 @@ class SpamLog < ActiveRecord::Base
validates :user, presence: true
def remove_user(deleted_by:)
- user.delete_async(deleted_by: deleted_by, params: { hard_delete: true })
+ user.delete_async(deleted_by: deleted_by, params: {hard_delete: true})
end
def text
diff --git a/app/models/ssh_host_key.rb b/app/models/ssh_host_key.rb
index fd23cc9ac87..f4dfaf93c2f 100644
--- a/app/models/ssh_host_key.rb
+++ b/app/models/ssh_host_key.rb
@@ -12,7 +12,7 @@ class SshHostKey
end
def as_json(*)
- { bits: bits, fingerprint: fingerprint, type: type, index: index }
+ {bits: bits, fingerprint: fingerprint, type: type, index: index}
end
end
@@ -29,7 +29,7 @@ class SshHostKey
opts = HashWithIndifferentAccess.new(opts)
return nil unless opts.key?(:id)
- project_id, url = opts[:id].split(':', 2)
+ project_id, url = opts[:id].split(":", 2)
project = Project.find_by(id: project_id)
project.presence && new(project: project, url: url)
@@ -59,14 +59,14 @@ class SshHostKey
end
def id
- [project.id, url].join(':')
+ [project.id, url].join(":")
end
def as_json(*)
{
host_keys_changed: host_keys_changed?,
fingerprints: fingerprints,
- known_hosts: known_hosts
+ known_hosts: known_hosts,
}
end
@@ -90,25 +90,25 @@ class SshHostKey
def calculate_reactive_cache
known_hosts, errors, status =
- Open3.popen3({}, *%W[ssh-keyscan -T 5 -p #{url.port} -f-]) do |stdin, stdout, stderr, wait_thr|
+ Open3.popen3({}, "ssh-keyscan", "-T", "5", "-p", url.port.to_s, "-f-") { |stdin, stdout, stderr, wait_thr|
stdin.puts(url.host)
stdin.close
[
cleanup(stdout.read),
cleanup(stderr.read),
- wait_thr.value
+ wait_thr.value,
]
- end
+ }
# ssh-keyscan returns an exit code 0 in several error conditions, such as an
# unknown hostname, so check both STDERR and the exit code
if status.success? && !errors.present?
- { known_hosts: known_hosts }
+ {known_hosts: known_hosts}
else
Rails.logger.debug("Failed to detect SSH host keys for #{id}: #{errors}")
- { error: 'Failed to detect SSH host keys' }
+ {error: "Failed to detect SSH host keys"}
end
end
@@ -119,7 +119,7 @@ class SshHostKey
data
.to_s
.each_line
- .reject { |line| line.start_with?('#') || line.chomp.empty? }
+ .reject { |line| line.start_with?("#") || line.chomp.empty? }
.uniq
.sort
.join
@@ -127,7 +127,7 @@ class SshHostKey
def normalize_url(url)
full_url = ::Addressable::URI.parse(url)
- raise ArgumentError.new("Invalid URL") unless full_url&.scheme == 'ssh'
+ raise ArgumentError.new("Invalid URL") unless full_url&.scheme == "ssh"
Addressable::URI.parse("ssh://#{full_url.host}:#{full_url.inferred_port}")
rescue Addressable::URI::InvalidURIError
diff --git a/app/models/storage/hashed_project.rb b/app/models/storage/hashed_project.rb
index f5d0d6fab3b..39a9b009611 100644
--- a/app/models/storage/hashed_project.rb
+++ b/app/models/storage/hashed_project.rb
@@ -5,8 +5,8 @@ module Storage
attr_accessor :project
delegate :gitlab_shell, :repository_storage, to: :project
- REPOSITORY_PATH_PREFIX = '@hashed'
- POOL_PATH_PREFIX = '@pools'
+ REPOSITORY_PATH_PREFIX = "@hashed"
+ POOL_PATH_PREFIX = "@pools"
def initialize(project, prefix: REPOSITORY_PATH_PREFIX)
@project = project
diff --git a/app/models/subscription.rb b/app/models/subscription.rb
index 0f6ee0ddf7e..52d8a1d898b 100644
--- a/app/models/subscription.rb
+++ b/app/models/subscription.rb
@@ -7,5 +7,5 @@ class Subscription < ActiveRecord::Base
validates :user, :subscribable, presence: true
- validates :project_id, uniqueness: { scope: [:subscribable_id, :subscribable_type, :user_id] }
+ validates :project_id, uniqueness: {scope: [:subscribable_id, :subscribable_type, :user_id]}
end
diff --git a/app/models/suggestion.rb b/app/models/suggestion.rb
index 09034646bff..9ac7fdde7a2 100644
--- a/app/models/suggestion.rb
+++ b/app/models/suggestion.rb
@@ -27,19 +27,19 @@ class Suggestion < ApplicationRecord
def from_line
position.new_line
end
- alias_method :to_line, :from_line
+ alias to_line from_line
def from_original_line
original_position.new_line
end
- alias_method :to_original_line, :from_original_line
+ alias to_original_line from_original_line
# `from_line_index` and `to_line_index` represents diff/blob line numbers in
# index-like way (N-1).
def from_line_index
from_line - 1
end
- alias_method :to_line_index, :from_line_index
+ alias to_line_index from_line_index
def appliable?
return false unless note.supports_suggestion?
diff --git a/app/models/system_note_metadata.rb b/app/models/system_note_metadata.rb
index d555ebe5322..0c2a59d1aa6 100644
--- a/app/models/system_note_metadata.rb
+++ b/app/models/system_note_metadata.rb
@@ -20,7 +20,7 @@ class SystemNoteMetadata < ActiveRecord::Base
].freeze
validates :note, presence: true
- validates :action, inclusion: { in: :icon_types }, allow_nil: true
+ validates :action, inclusion: {in: :icon_types}, allow_nil: true
belongs_to :note
diff --git a/app/models/term_agreement.rb b/app/models/term_agreement.rb
index 9b3c8ac68bd..679fc28f46e 100644
--- a/app/models/term_agreement.rb
+++ b/app/models/term_agreement.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class TermAgreement < ActiveRecord::Base
- belongs_to :term, class_name: 'ApplicationSetting::Term'
+ belongs_to :term, class_name: "ApplicationSetting::Term"
belongs_to :user
scope :accepted, -> { where(accepted: true) }
diff --git a/app/models/timelog.rb b/app/models/timelog.rb
index e04c644a53a..8b8a0eb40ab 100644
--- a/app/models/timelog.rb
+++ b/app/models/timelog.rb
@@ -16,9 +16,9 @@ class Timelog < ActiveRecord::Base
def issuable_id_is_present
if issue_id && merge_request_id
- errors.add(:base, 'Only Issue ID or Merge Request ID is required')
+ errors.add(:base, "Only Issue ID or Merge Request ID is required")
elsif issuable.nil?
- errors.add(:base, 'Issue or Merge Request ID is required')
+ errors.add(:base, "Issue or Merge Request ID is required")
end
end
diff --git a/app/models/todo.rb b/app/models/todo.rb
index d9b86d941b6..534db99b9a0 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -24,7 +24,7 @@ class Todo < ActiveRecord::Base
MARKED => :marked,
APPROVAL_REQUIRED => :approval_required,
UNMERGEABLE => :unmergeable,
- DIRECTLY_ADDRESSED => :directly_addressed
+ DIRECTLY_ADDRESSED => :directly_addressed,
}.freeze
belongs_to :author, class_name: "User"
@@ -45,13 +45,13 @@ class Todo < ActiveRecord::Base
scope :pending, -> { with_state(:pending) }
scope :done, -> { with_state(:done) }
- scope :for_action, -> (action) { where(action: action) }
- scope :for_author, -> (author) { where(author: author) }
- scope :for_project, -> (project) { where(project: project) }
- scope :for_group, -> (group) { where(group: group) }
- scope :for_type, -> (type) { where(target_type: type) }
- scope :for_target, -> (id) { where(target_id: id) }
- scope :for_commit, -> (id) { where(commit_id: id) }
+ scope :for_action, ->(action) { where(action: action) }
+ scope :for_author, ->(author) { where(author: author) }
+ scope :for_project, ->(project) { where(project: project) }
+ scope :for_group, ->(group) { where(group: group) }
+ scope :for_type, ->(type) { where(target_type: type) }
+ scope :for_target, ->(id) { where(target_id: id) }
+ scope :for_commit, ->(id) { where(commit_id: id) }
state_machine :state, initial: :pending do
event :done do
@@ -75,7 +75,7 @@ class Todo < ActiveRecord::Base
from_union([
for_project(Project.for_group(groups)),
- for_group(groups)
+ for_group(groups),
])
end
@@ -107,7 +107,7 @@ class Todo < ActiveRecord::Base
def sort_by_attribute(method)
sorted =
case method.to_s
- when 'priority', 'label_priority' then order_by_labels_priority
+ when "priority", "label_priority" then order_by_labels_priority
else order_by(method)
end
@@ -122,14 +122,14 @@ class Todo < ActiveRecord::Base
params = {
target_type_column: "todos.target_type",
target_column: "todos.target_id",
- project_column: "todos.project_id"
+ project_column: "todos.project_id",
}
highest_priority = highest_label_priority(params).to_sql
select("#{table_name}.*, (#{highest_priority}) AS highest_priority")
- .order(Gitlab::Database.nulls_last_order('highest_priority', 'ASC'))
- .order('todos.created_at')
+ .order(Gitlab::Database.nulls_last_order("highest_priority", "ASC"))
+ .order("todos.created_at")
end
end
@@ -168,7 +168,11 @@ class Todo < ActiveRecord::Base
# override to return commits, which are not active record
def target
if for_commit?
- project.commit(commit_id) rescue nil
+ begin
+ project.commit(commit_id)
+ rescue
+ nil
+ end
else
super
end
@@ -193,6 +197,6 @@ class Todo < ActiveRecord::Base
private
def keep_around_commit
- project.repository.keep_around(self.commit_id)
+ project.repository.keep_around(commit_id)
end
end
diff --git a/app/models/tree.rb b/app/models/tree.rb
index cd385872171..e078eed5122 100644
--- a/app/models/tree.rb
+++ b/app/models/tree.rb
@@ -6,8 +6,8 @@ class Tree
attr_accessor :repository, :sha, :path, :entries
- def initialize(repository, sha, path = '/', recursive: false)
- path = '/' if path.blank?
+ def initialize(repository, sha, path = "/", recursive: false)
+ path = "/" if path.blank?
@repository = repository
@sha = sha
@@ -19,23 +19,23 @@ class Tree
def readme_path
strong_memoize(:readme_path) do
- available_readmes = blobs.select do |blob|
+ available_readmes = blobs.select { |blob|
Gitlab::FileDetector.type_of(blob.name) == :readme
- end
+ }
- previewable_readmes = available_readmes.select do |blob|
+ previewable_readmes = available_readmes.select { |blob|
previewable?(blob.name)
- end
+ }
- plain_readmes = available_readmes.select do |blob|
+ plain_readmes = available_readmes.select { |blob|
plain?(blob.name)
- end
+ }
# Prioritize previewable over plain readmes
entry = previewable_readmes.first || plain_readmes.first
next nil unless entry
- if path == '/'
+ if path == "/"
entry.name
else
File.join(path, entry.name)
diff --git a/app/models/u2f_registration.rb b/app/models/u2f_registration.rb
index 37598173fd1..351fc0a7454 100644
--- a/app/models/u2f_registration.rb
+++ b/app/models/u2f_registration.rb
@@ -7,7 +7,7 @@ class U2fRegistration < ActiveRecord::Base
def self.register(user, app_id, params, challenges)
u2f = U2F::U2F.new(app_id)
- registration = self.new
+ registration = new
begin
response = U2F::RegisterResponse.load_from_json(params[:device_response])
@@ -19,7 +19,7 @@ class U2fRegistration < ActiveRecord::Base
user: user,
name: params[:name])
rescue JSON::ParserError, NoMethodError, ArgumentError
- registration.errors.add(:base, 'Your U2F device did not send a valid JSON response.')
+ registration.errors.add(:base, "Your U2F device did not send a valid JSON response.")
rescue U2F::Error => e
registration.errors.add(:base, e.message)
end
diff --git a/app/models/upload.rb b/app/models/upload.rb
index 20860f14b83..d83a5b31659 100644
--- a/app/models/upload.rb
+++ b/app/models/upload.rb
@@ -31,7 +31,7 @@ class Upload < ActiveRecord::Base
def begin_fast_destroy
{
Uploads::Local => Uploads::Local.new.keys(with_files_stored_locally),
- Uploads::Fog => Uploads::Fog.new.keys(with_files_stored_remotely)
+ Uploads::Fog => Uploads::Fog.new.keys(with_files_stored_remotely),
}
end
@@ -71,10 +71,10 @@ class Upload < ActiveRecord::Base
# Help sysadmins find missing upload files
if persisted? && !exist
if Gitlab::Sentry.enabled?
- Raven.capture_message("Upload file does not exist", extra: self.attributes)
+ Raven.capture_message("Upload file does not exist", extra: attributes)
end
- Gitlab::Metrics.counter(:upload_file_does_not_exist_total, 'The number of times an upload record could not find its file').increment
+ Gitlab::Metrics.counter(:upload_file_does_not_exist_total, "The number of times an upload record could not find its file").increment
end
exist
@@ -83,7 +83,7 @@ class Upload < ActiveRecord::Base
def uploader_context
{
identifier: identifier,
- secret: secret
+ secret: secret,
}.compact
end
@@ -110,7 +110,7 @@ class Upload < ActiveRecord::Base
end
def relative_path?
- !path.start_with?('/')
+ !path.start_with?("/")
end
def uploader_class
diff --git a/app/models/uploads/local.rb b/app/models/uploads/local.rb
index 2901c33c359..30cb69b721e 100644
--- a/app/models/uploads/local.rb
+++ b/app/models/uploads/local.rb
@@ -23,7 +23,7 @@ module Uploads
unless in_uploads?(path)
message = "Path '#{path}' is not in uploads dir, skipping"
logger.warn(message)
- Gitlab::Sentry.track_exception(RuntimeError.new(message), extra: { uploads_dir: storage_dir })
+ Gitlab::Sentry.track_exception(RuntimeError.new(message), extra: {uploads_dir: storage_dir})
return
end
diff --git a/app/models/user.rb b/app/models/user.rb
index ee51c35d576..b9b6084b56d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'carrierwave/orm/activerecord'
+require "carrierwave/orm/activerecord"
class User < ApplicationRecord
extend Gitlab::ConfigHelper
@@ -43,22 +43,22 @@ class User < ApplicationRecord
default_value_for :theme_id, gitlab_config.default_theme
attr_encrypted :otp_secret,
- key: Gitlab::Application.secrets.otp_key_base,
- mode: :per_attribute_iv_and_salt,
+ key: Gitlab::Application.secrets.otp_key_base,
+ mode: :per_attribute_iv_and_salt,
insecure_mode: true,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
devise :two_factor_authenticatable,
- otp_secret_encryption_key: Gitlab::Application.secrets.otp_key_base
+ otp_secret_encryption_key: Gitlab::Application.secrets.otp_key_base
devise :two_factor_backupable, otp_number_of_backup_codes: 10
serialize :otp_backup_codes, JSON # rubocop:disable Cop/ActiveRecordSerialize
devise :lockable, :recoverable, :rememberable, :trackable,
- :validatable, :omniauthable, :confirmable, :registerable
+ :validatable, :omniauthable, :confirmable, :registerable
BLOCKED_MESSAGE = "Your account has been blocked. Please contact your GitLab " \
- "administrator if you think this is an error.".freeze
+ "administrator if you think this is an error."
# Override Devise::Models::Trackable#update_tracked_fields!
# to limit database writes to at most once every hour
@@ -89,7 +89,7 @@ class User < ApplicationRecord
# Profile
has_many :keys, -> { regular_keys }, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :deploy_keys, -> { where(type: 'DeployKey') }, dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent
+ has_many :deploy_keys, -> { where(type: "DeployKey") }, dependent: :nullify # rubocop:disable Cop/ActiveRecordDependent
has_many :gpg_keys
has_many :emails, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
@@ -101,14 +101,14 @@ class User < ApplicationRecord
# Groups
has_many :members
- has_many :group_members, -> { where(requested_at: nil) }, source: 'GroupMember'
+ has_many :group_members, -> { where(requested_at: nil) }, source: "GroupMember"
has_many :groups, through: :group_members
- has_many :owned_groups, -> { where(members: { access_level: Gitlab::Access::OWNER }) }, through: :group_members, source: :group
- has_many :maintainers_groups, -> { where(members: { access_level: Gitlab::Access::MAINTAINER }) }, through: :group_members, source: :group
+ has_many :owned_groups, -> { where(members: {access_level: Gitlab::Access::OWNER}) }, through: :group_members, source: :group
+ has_many :maintainers_groups, -> { where(members: {access_level: Gitlab::Access::MAINTAINER}) }, through: :group_members, source: :group
has_many :owned_or_maintainers_groups,
- -> { where(members: { access_level: [Gitlab::Access::MAINTAINER, Gitlab::Access::OWNER] }) },
- through: :group_members,
- source: :group
+ -> { where(members: {access_level: [Gitlab::Access::MAINTAINER, Gitlab::Access::OWNER]}) },
+ through: :group_members,
+ source: :group
alias_attribute :masters_groups, :maintainers_groups
# Projects
@@ -116,14 +116,14 @@ class User < ApplicationRecord
has_many :personal_projects, through: :namespace, source: :projects
has_many :project_members, -> { where(requested_at: nil) }
has_many :projects, through: :project_members
- has_many :created_projects, foreign_key: :creator_id, class_name: 'Project'
+ has_many :created_projects, foreign_key: :creator_id, class_name: "Project"
has_many :users_star_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :starred_projects, through: :users_star_projects, source: :project
has_many :project_authorizations, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent
has_many :authorized_projects, through: :project_authorizations, source: :project
has_many :user_interacted_projects
- has_many :project_interactions, through: :user_interacted_projects, source: :project, class_name: 'Project'
+ has_many :project_interactions, through: :user_interacted_projects, source: :project, class_name: "Project"
has_many :snippets, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent
has_many :notes, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent
@@ -132,27 +132,27 @@ class User < ApplicationRecord
has_many :events, dependent: :destroy, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent
has_many :releases, dependent: :nullify, foreign_key: :author_id # rubocop:disable Cop/ActiveRecordDependent
has_many :subscriptions, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_many :oauth_applications, class_name: "Doorkeeper::Application", as: :owner, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_one :abuse_report, dependent: :destroy, foreign_key: :user_id # rubocop:disable Cop/ActiveRecordDependent
has_many :reported_abuse_reports, dependent: :destroy, foreign_key: :reporter_id, class_name: "AbuseReport" # rubocop:disable Cop/ActiveRecordDependent
has_many :spam_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :builds, dependent: :nullify, class_name: 'Ci::Build' # rubocop:disable Cop/ActiveRecordDependent
- has_many :pipelines, dependent: :nullify, class_name: 'Ci::Pipeline' # rubocop:disable Cop/ActiveRecordDependent
+ has_many :builds, dependent: :nullify, class_name: "Ci::Build" # rubocop:disable Cop/ActiveRecordDependent
+ has_many :pipelines, dependent: :nullify, class_name: "Ci::Pipeline" # rubocop:disable Cop/ActiveRecordDependent
has_many :todos
has_many :notification_settings
has_many :award_emoji, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
- has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :owner_id # rubocop:disable Cop/ActiveRecordDependent
+ has_many :triggers, dependent: :destroy, class_name: "Ci::Trigger", foreign_key: :owner_id # rubocop:disable Cop/ActiveRecordDependent
has_many :issue_assignees
has_many :assigned_issues, class_name: "Issue", through: :issue_assignees, source: :issue
has_many :assigned_merge_requests, dependent: :nullify, foreign_key: :assignee_id, class_name: "MergeRequest" # rubocop:disable Cop/ActiveRecordDependent
- has_many :custom_attributes, class_name: 'UserCustomAttribute'
- has_many :callouts, class_name: 'UserCallout'
+ has_many :custom_attributes, class_name: "UserCustomAttribute"
+ has_many :callouts, class_name: "UserCallout"
has_many :term_agreements
- belongs_to :accepted_term, class_name: 'ApplicationSetting::Term'
+ belongs_to :accepted_term, class_name: "ApplicationSetting::Term"
- has_one :status, class_name: 'UserStatus'
+ has_one :status, class_name: "UserStatus"
has_one :user_preference
#
@@ -165,10 +165,10 @@ class User < ApplicationRecord
validates :notification_email, email: true, if: ->(user) { user.notification_email != user.email }
validates :public_email, presence: true, uniqueness: true, email: true, allow_blank: true
validates :commit_email, email: true, allow_nil: true, if: ->(user) { user.commit_email != user.email }
- validates :bio, length: { maximum: 255 }, allow_blank: true
+ validates :bio, length: {maximum: 255}, allow_blank: true
validates :projects_limit,
presence: true,
- numericality: { greater_than_or_equal_to: 0, less_than_or_equal_to: Gitlab::Database::MAX_INT_VALUE }
+ numericality: {greater_than_or_equal_to: 0, less_than_or_equal_to: Gitlab::Database::MAX_INT_VALUE}
validates :username, presence: true
validates :namespace, presence: true
@@ -197,7 +197,7 @@ class User < ApplicationRecord
after_destroy :post_destroy_hook
after_destroy :remove_key_cache
after_commit(on: :update) do
- if previous_changes.key?('email')
+ if previous_changes.key?("email")
# Grab previous_email here since previous_changes changes after
# #update_emails_with_primary_email and #update_notification_email are called
previous_email = previous_changes[:email][0]
@@ -267,14 +267,14 @@ class User < ApplicationRecord
scope :blocked, -> { with_states(:blocked, :ldap_blocked) }
scope :external, -> { where(external: true) }
scope :active, -> { with_state(:active).non_internal }
- scope :without_projects, -> { joins('LEFT JOIN project_authorizations ON users.id = project_authorizations.user_id').where(project_authorizations: { user_id: nil }) }
- scope :order_recent_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('current_sign_in_at', 'DESC')) }
- scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order('current_sign_in_at', 'ASC')) }
- scope :order_recent_last_activity, -> { reorder(Gitlab::Database.nulls_last_order('last_activity_on', 'DESC')) }
- scope :order_oldest_last_activity, -> { reorder(Gitlab::Database.nulls_first_order('last_activity_on', 'ASC')) }
+ scope :without_projects, -> { joins("LEFT JOIN project_authorizations ON users.id = project_authorizations.user_id").where(project_authorizations: {user_id: nil}) }
+ scope :order_recent_sign_in, -> { reorder(Gitlab::Database.nulls_last_order("current_sign_in_at", "DESC")) }
+ scope :order_oldest_sign_in, -> { reorder(Gitlab::Database.nulls_last_order("current_sign_in_at", "ASC")) }
+ scope :order_recent_last_activity, -> { reorder(Gitlab::Database.nulls_last_order("last_activity_on", "DESC")) }
+ scope :order_oldest_last_activity, -> { reorder(Gitlab::Database.nulls_first_order("last_activity_on", "ASC")) }
scope :confirmed, -> { where.not(confirmed_at: nil) }
- scope :by_username, -> (usernames) { iwhere(username: Array(usernames).map(&:to_s)) }
- scope :for_todos, -> (todos) { where(id: todos.select(:user_id)) }
+ scope :by_username, ->(usernames) { iwhere(username: Array(usernames).map(&:to_s)) }
+ scope :for_todos, ->(todos) { where(id: todos.select(:user_id)) }
scope :with_emails, -> { preload(:emails) }
# Limits the users to those that have TODOs, optionally in the given state.
@@ -338,13 +338,13 @@ class User < ApplicationRecord
end
def sort_by_attribute(method)
- order_method = method || 'id_desc'
+ order_method = method || "id_desc"
case order_method.to_s
- when 'recent_sign_in' then order_recent_sign_in
- when 'oldest_sign_in' then order_oldest_sign_in
- when 'last_activity_on_desc' then order_recent_last_activity
- when 'last_activity_on_asc' then order_oldest_last_activity
+ when "recent_sign_in" then order_recent_sign_in
+ when "oldest_sign_in" then order_oldest_sign_in
+ when "last_activity_on_desc" then order_recent_last_activity
+ when "last_activity_on_asc" then order_oldest_last_activity
else
order_by(order_method)
end
@@ -371,7 +371,7 @@ class User < ApplicationRecord
from_users = where(email: emails)
from_users = from_users.confirmed if confirmed
- from_emails = joins(:emails).where(emails: { email: emails })
+ from_emails = joins(:emails).where(emails: {email: emails})
from_emails = from_emails.confirmed.merge(Email.confirmed) if confirmed
items = [from_users, from_emails]
@@ -390,17 +390,17 @@ class User < ApplicationRecord
def filter_items(filter_name)
case filter_name
- when 'admins'
+ when "admins"
admins
- when 'blocked'
+ when "blocked"
blocked
- when 'two_factor_disabled'
+ when "two_factor_disabled"
without_two_factor
- when 'two_factor_enabled'
+ when "two_factor_enabled"
with_two_factor
- when 'wop'
+ when "wop"
without_projects
- when 'external'
+ when "external"
external
else
active
@@ -432,7 +432,7 @@ class User < ApplicationRecord
fuzzy_arel_match(:name, query, lower_exact_match: true)
.or(fuzzy_arel_match(:username, query, lower_exact_match: true))
.or(arel_table[:email].eq(query))
- ).reorder(order % { query: ActiveRecord::Base.connection.quote(query) }, :name)
+ ).reorder(order % {query: ActiveRecord::Base.connection.quote(query)}, :name)
end
# Limits the result set to users _not_ in the given query/list of IDs.
@@ -472,7 +472,7 @@ class User < ApplicationRecord
def by_login(login)
return nil unless login
- if login.include?('@'.freeze)
+ if login.include?("@")
unscoped.iwhere(email: login).take
else
unscoped.iwhere(username: login).take
@@ -498,7 +498,7 @@ class User < ApplicationRecord
end
def reference_prefix
- '@'
+ "@"
end
# Pattern used to extract `@user` user references from text
@@ -513,10 +513,10 @@ class User < ApplicationRecord
# Return (create if necessary) the ghost user. The ghost user
# owns records previously belonging to deleted users.
def ghost
- email = 'ghost%s@example.com'
- unique_internal(where(ghost: true), 'ghost', email) do |u|
+ email = "ghost%s@example.com"
+ unique_internal(where(ghost: true), "ghost", email) do |u|
u.bio = 'This is a "Ghost User", created to hold all issues authored by users that have since been deleted. This user cannot be removed.'
- u.name = 'Ghost User'
+ u.name = "Ghost User"
end
end
@@ -595,14 +595,14 @@ class User < ApplicationRecord
def disable_two_factor!
transaction do
update(
- otp_required_for_login: false,
- encrypted_otp_secret: nil,
- encrypted_otp_secret_iv: nil,
- encrypted_otp_secret_salt: nil,
+ otp_required_for_login: false,
+ encrypted_otp_secret: nil,
+ encrypted_otp_secret_iv: nil,
+ encrypted_otp_secret_salt: nil,
otp_grace_period_started_at: nil,
- otp_backup_codes: nil
+ otp_backup_codes: nil
)
- self.u2f_registrations.destroy_all # rubocop: disable DestroyAll
+ u2f_registrations.destroy_all # rubocop: disable DestroyAll
end
end
@@ -624,13 +624,13 @@ class User < ApplicationRecord
def namespace_move_dir_allowed
if namespace&.any_project_has_container_registry_tags?
- errors.add(:username, 'cannot be changed if a personal project has container registry tags.')
+ errors.add(:username, "cannot be changed if a personal project has container registry tags.")
end
end
def unique_email
if !emails.exists?(email: email) && Email.exists?(email: email)
- errors.add(:email, 'has already been taken')
+ errors.add(:email, "has already been taken")
end
end
@@ -658,14 +658,14 @@ class User < ApplicationRecord
# possibility of the commit_email column not existing.
def commit_email
- return self.email unless has_attribute?(:commit_email)
+ return email unless has_attribute?(:commit_email)
if super == Gitlab::PrivateCommitEmail::TOKEN
return private_commit_email
end
# The commit email is the same as the primary email if undefined
- super.presence || self.email
+ super.presence || email
end
def commit_email=(email)
@@ -682,7 +682,7 @@ class User < ApplicationRecord
# see if the new email is already a verified secondary email
def check_for_verified_email
- skip_reconfirmation! if emails.confirmed.where(email: self.email).any?
+ skip_reconfirmation! if emails.confirmed.where(email: email).any?
end
# Note: the use of the Emails services will cause `saves` on the user object, running
@@ -710,7 +710,7 @@ class User < ApplicationRecord
Group.unscoped do
Group.from_union([
groups,
- authorized_projects.joins(:namespace).select('namespaces.*')
+ authorized_projects.joins(:namespace).select("namespaces.*"),
])
end
end
@@ -747,14 +747,14 @@ class User < ApplicationRecord
if min_access_level
projects = projects
- .where('project_authorizations.access_level >= ?', min_access_level)
+ .where("project_authorizations.access_level >= ?", min_access_level)
end
projects
end
def authorized_project?(project, min_access_level = nil)
- authorized_projects(min_access_level).exists?({ id: project.id })
+ authorized_projects(min_access_level).exists?({id: project.id})
end
# Typically used in conjunction with projects table to get projects
@@ -763,11 +763,11 @@ class User < ApplicationRecord
# Example use:
# `Project.where('EXISTS(?)', user.authorizations_for_projects)`
def authorizations_for_projects(min_access_level: nil)
- authorizations = project_authorizations.select(1).where('project_authorizations.project_id = projects.id')
+ authorizations = project_authorizations.select(1).where("project_authorizations.project_id = projects.id")
return authorizations unless min_access_level.present?
- authorizations.where('project_authorizations.access_level >= ?', min_access_level)
+ authorizations.where("project_authorizations.access_level >= ?", min_access_level)
end
# Returns the projects this user has reporter (or greater) access to, limited
@@ -786,7 +786,7 @@ class User < ApplicationRecord
Project.where(namespace: namespace),
Project.joins(:project_authorizations)
.where("projects.namespace_id <> ?", namespace.id)
- .where(project_authorizations: { user_id: id, access_level: Gitlab::Access::OWNER })
+ .where(project_authorizations: {user_id: id, access_level: Gitlab::Access::OWNER}),
],
remove_duplicates: false
)
@@ -803,7 +803,7 @@ class User < ApplicationRecord
def require_ssh_key?
count = Users::KeysCountService.new(self).count
- count.zero? && Gitlab::ProtocolAccess.allowed?('ssh')
+ count.zero? && Gitlab::ProtocolAccess.allowed?("ssh")
end
# rubocop: enable CodeReuse/ServiceClass
@@ -818,7 +818,7 @@ class User < ApplicationRecord
def require_personal_access_token_creation_for_git_auth?
return false if allow_password_authentication_for_git? || ldap_user?
- PersonalAccessTokensFinder.new(user: self, impersonation: false, state: 'active').execute.none?
+ PersonalAccessTokensFinder.new(user: self, impersonation: false, state: "active").execute.none?
end
def require_extra_setup_for_git_auth?
@@ -944,7 +944,7 @@ class User < ApplicationRecord
def set_public_email
if public_email.blank? || all_emails.exclude?(public_email)
- self.public_email = ''
+ self.public_email = ""
end
end
@@ -993,9 +993,9 @@ class User < ApplicationRecord
end
def solo_owned_groups
- @solo_owned_groups ||= owned_groups.select do |group|
+ @solo_owned_groups ||= owned_groups.select { |group|
group.owners == [self]
- end
+ }
end
def with_defaults
@@ -1018,7 +1018,7 @@ class User < ApplicationRecord
end
def short_website_url
- website_url.sub(%r{\Ahttps?://}, '')
+ website_url.sub(%r{\Ahttps?://}, "")
end
def all_ssh_keys
@@ -1026,7 +1026,7 @@ class User < ApplicationRecord
end
def temp_oauth_email?
- email.start_with?('temp-email-for-oauth')
+ email.start_with?("temp-email-for-oauth")
end
# rubocop: disable CodeReuse/ServiceClass
@@ -1070,7 +1070,7 @@ class User < ApplicationRecord
# handle the outdated private commit email case
return true if persisted? &&
- id == Gitlab::PrivateCommitEmail.user_id_for_email(downcased)
+ id == Gitlab::PrivateCommitEmail.user_id_for_email(downcased)
all_emails.include?(check_email.downcase)
end
@@ -1080,7 +1080,7 @@ class User < ApplicationRecord
# handle the outdated private commit email case
return true if persisted? &&
- id == Gitlab::PrivateCommitEmail.user_id_for_email(downcased)
+ id == Gitlab::PrivateCommitEmail.user_id_for_email(downcased)
verified_emails.include?(check_email.downcase)
end
@@ -1089,7 +1089,7 @@ class User < ApplicationRecord
{
name: name,
username: username,
- avatar_url: avatar_url(only_path: false)
+ avatar_url: avatar_url(only_path: false),
}
end
@@ -1102,8 +1102,8 @@ class User < ApplicationRecord
end
def set_username_errors
- namespace_path_errors = self.errors.delete(:"namespace.path")
- self.errors[:username].concat(namespace_path_errors) if namespace_path_errors
+ namespace_path_errors = errors.delete(:"namespace.path")
+ errors[:username].concat(namespace_path_errors) if namespace_path_errors
end
def username_changed_hook
@@ -1150,7 +1150,7 @@ class User < ApplicationRecord
def toggle_star(project)
UsersStarProject.transaction do
user_star_project = users_star_projects
- .where(project: project, user: self).lock(true).first
+ .where(project: project, user: self).lock(true).first
if user_star_project
user_star_project.destroy
@@ -1169,7 +1169,7 @@ class User < ApplicationRecord
end
def manageable_groups_with_routes
- manageable_groups.eager_load(:route).order('routes.path')
+ manageable_groups.eager_load(:route).order("routes.path")
end
def namespaces
@@ -1212,12 +1212,12 @@ class User < ApplicationRecord
project_runners = Ci::RunnerProject
.where(project: authorized_projects(Gitlab::Access::MAINTAINER))
.joins(:runner)
- .select('ci_runners.*')
+ .select("ci_runners.*")
group_runners = Ci::RunnerNamespace
.where(namespace_id: owned_or_maintainers_groups.select(:id))
.joins(:runner)
- .select('ci_runners.*')
+ .select("ci_runners.*")
Ci::Runner.from_union([project_runners, group_runners])
end
@@ -1246,33 +1246,33 @@ class User < ApplicationRecord
end
def assigned_open_merge_requests_count(force: false)
- Rails.cache.fetch(['users', id, 'assigned_open_merge_requests_count'], force: force, expires_in: 20.minutes) do
- MergeRequestsFinder.new(self, assignee_id: self.id, state: 'opened', non_archived: true).execute.count
+ Rails.cache.fetch(["users", id, "assigned_open_merge_requests_count"], force: force, expires_in: 20.minutes) do
+ MergeRequestsFinder.new(self, assignee_id: id, state: "opened", non_archived: true).execute.count
end
end
def assigned_open_issues_count(force: false)
- Rails.cache.fetch(['users', id, 'assigned_open_issues_count'], force: force, expires_in: 20.minutes) do
- IssuesFinder.new(self, assignee_id: self.id, state: 'opened', non_archived: true).execute.count
+ Rails.cache.fetch(["users", id, "assigned_open_issues_count"], force: force, expires_in: 20.minutes) do
+ IssuesFinder.new(self, assignee_id: id, state: "opened", non_archived: true).execute.count
end
end
def todos_done_count(force: false)
- Rails.cache.fetch(['users', id, 'todos_done_count'], force: force, expires_in: 20.minutes) do
+ Rails.cache.fetch(["users", id, "todos_done_count"], force: force, expires_in: 20.minutes) do
TodosFinder.new(self, state: :done).execute.count
end
end
def todos_pending_count(force: false)
- Rails.cache.fetch(['users', id, 'todos_pending_count'], force: force, expires_in: 20.minutes) do
+ Rails.cache.fetch(["users", id, "todos_pending_count"], force: force, expires_in: 20.minutes) do
TodosFinder.new(self, state: :pending).execute.count
end
end
def personal_projects_count(force: false)
- Rails.cache.fetch(['users', id, 'personal_projects_count'], force: force, expires_in: 24.hours, raw: true) do
+ Rails.cache.fetch(["users", id, "personal_projects_count"], force: force, expires_in: 24.hours, raw: true) {
personal_projects.count
- end.to_i
+ }.to_i
end
def update_todos_count_cache
@@ -1289,23 +1289,23 @@ class User < ApplicationRecord
end
def invalidate_issue_cache_counts
- Rails.cache.delete(['users', id, 'assigned_open_issues_count'])
+ Rails.cache.delete(["users", id, "assigned_open_issues_count"])
end
def invalidate_merge_request_cache_counts
- Rails.cache.delete(['users', id, 'assigned_open_merge_requests_count'])
+ Rails.cache.delete(["users", id, "assigned_open_merge_requests_count"])
end
def invalidate_todos_done_count
- Rails.cache.delete(['users', id, 'todos_done_count'])
+ Rails.cache.delete(["users", id, "todos_done_count"])
end
def invalidate_todos_pending_count
- Rails.cache.delete(['users', id, 'todos_pending_count'])
+ Rails.cache.delete(["users", id, "todos_pending_count"])
end
def invalidate_personal_projects_count
- Rails.cache.delete(['users', id, 'personal_projects_count'])
+ Rails.cache.delete(["users", id, "personal_projects_count"])
end
# This is copied from Devise::Models::Lockable#valid_for_authentication?, as our auth
@@ -1339,9 +1339,9 @@ class User < ApplicationRecord
def access_level=(new_level)
new_level = new_level.to_s
- return unless %w(admin regular).include?(new_level)
+ return unless %w[admin regular].include?(new_level)
- self.admin = (new_level == 'admin')
+ self.admin = (new_level == "admin")
end
# Does the user have access to all private groups & projects?
@@ -1354,7 +1354,7 @@ class User < ApplicationRecord
periods = expanded_groups_requiring_two_factor_authentication.pluck(:two_factor_grace_period)
self.require_two_factor_authentication_from_group = periods.any?
- self.two_factor_grace_period = periods.min || User.column_defaults['two_factor_grace_period']
+ self.two_factor_grace_period = periods.min || User.column_defaults["two_factor_grace_period"]
save
end
@@ -1394,8 +1394,8 @@ class User < ApplicationRecord
def max_member_access_for_project_ids(project_ids)
max_member_access_for_resource_ids(Project, project_ids) do |project_ids|
project_authorizations.where(project: project_ids)
- .group(:project_id)
- .maximum(:access_level)
+ .group(:project_id)
+ .maximum(:access_level)
end
end
@@ -1426,7 +1426,7 @@ class User < ApplicationRecord
end
def requires_usage_stats_consent?
- !consented_usage_stats? && 7.days.ago > self.created_at && !has_current_license? && User.single_user?
+ !consented_usage_stats? && 7.days.ago > created_at && !has_current_license? && User.single_user?
end
# Avoid migrations only building user preference object when needed.
@@ -1443,7 +1443,7 @@ class User < ApplicationRecord
end
# @deprecated
- alias_method :owned_or_masters_groups, :owned_or_maintainers_groups
+ alias owned_or_masters_groups owned_or_maintainers_groups
protected
@@ -1461,7 +1461,7 @@ class User < ApplicationRecord
end
def consented_usage_stats?
- Gitlab::CurrentSettings.usage_stats_set_by_user_id == self.id
+ Gitlab::CurrentSettings.usage_stats_set_by_user_id == id
end
# Added according to https://github.com/plataformatec/devise/blob/7df57d5081f9884849ca15e4fde179ef164a575f/README.md#activejob-integration
@@ -1498,7 +1498,7 @@ class User < ApplicationRecord
if Gitlab::CurrentSettings.domain_blacklist_enabled?
blocked_domains = Gitlab::CurrentSettings.domain_blacklist
if domain_matches?(blocked_domains, email)
- error = 'is not from an allowed domain.'
+ error = "is not from an allowed domain."
valid = false
end
end
@@ -1521,7 +1521,7 @@ class User < ApplicationRecord
def domain_matches?(email_domains, email)
signup_domain = Mail::Address.new(email).domain
email_domains.any? do |domain|
- escaped = Regexp.escape(domain).gsub('\*', '.*?')
+ escaped = Regexp.escape(domain).gsub('\*', ".*?")
regexp = Regexp.new "^#{escaped}$", Regexp::IGNORECASE
signup_domain =~ regexp
end
@@ -1553,9 +1553,9 @@ class User < ApplicationRecord
username = uniquify.string(username) { |s| User.find_by_username(s) }
- email = uniquify.string(-> (n) { Kernel.sprintf(email_pattern, n) }) do |s|
+ email = uniquify.string(->(n) { Kernel.sprintf(email_pattern, n) }) { |s|
User.find_by_email(s)
- end
+ }
user = scope.build(
username: username,
diff --git a/app/models/user_callout.rb b/app/models/user_callout.rb
index 76e7bc06b4e..f0270dfbde4 100644
--- a/app/models/user_callout.rb
+++ b/app/models/user_callout.rb
@@ -10,6 +10,6 @@ class UserCallout < ActiveRecord::Base
validates :user, presence: true
validates :feature_name,
presence: true,
- uniqueness: { scope: :user_id },
- inclusion: { in: UserCallout.feature_names.keys }
+ uniqueness: {scope: :user_id},
+ inclusion: {in: UserCallout.feature_names.keys}
end
diff --git a/app/models/user_callout_enums.rb b/app/models/user_callout_enums.rb
index b9373ae6166..68199909b92 100644
--- a/app/models/user_callout_enums.rb
+++ b/app/models/user_callout_enums.rb
@@ -10,7 +10,7 @@ module UserCalloutEnums
{
gke_cluster_integration: 1,
gcp_signup_offer: 2,
- cluster_security_warning: 3
+ cluster_security_warning: 3,
}
end
end
diff --git a/app/models/user_custom_attribute.rb b/app/models/user_custom_attribute.rb
index e0ffe8ebbfd..c4d6fea9a4e 100644
--- a/app/models/user_custom_attribute.rb
+++ b/app/models/user_custom_attribute.rb
@@ -4,5 +4,5 @@ class UserCustomAttribute < ActiveRecord::Base
belongs_to :user
validates :user_id, :key, :value, presence: true
- validates :key, uniqueness: { scope: [:user_id] }
+ validates :key, uniqueness: {scope: [:user_id]}
end
diff --git a/app/models/user_interacted_project.rb b/app/models/user_interacted_project.rb
index ae6778e49be..308211c0b96 100644
--- a/app/models/user_interacted_project.rb
+++ b/app/models/user_interacted_project.rb
@@ -21,21 +21,19 @@ class UserInteractedProject < ActiveRecord::Base
attributes = {
project_id: event.project_id,
- user_id: event.author_id
+ user_id: event.author_id,
}
cached_exists?(attributes) do
transaction(requires_new: true) do
- begin
- where(attributes).select(1).first || create!(attributes)
- true # not caching the whole record here for now
- rescue ActiveRecord::RecordNotUnique
- # Note, above queries are not atomic and prone
- # to race conditions (similar like #find_or_create!).
- # In the case where we hit this, the record we want
- # already exists - shortcut and return.
- true
- end
+ where(attributes).select(1).first || create!(attributes)
+ true # not caching the whole record here for now
+ rescue ActiveRecord::RecordNotUnique
+ # Note, above queries are not atomic and prone
+ # to race conditions (similar like #find_or_create!).
+ # In the case where we hit this, the record we want
+ # already exists - shortcut and return.
+ true
end
end
end
diff --git a/app/models/user_preference.rb b/app/models/user_preference.rb
index 32d0407800f..c3ec04ea12e 100644
--- a/app/models/user_preference.rb
+++ b/app/models/user_preference.rb
@@ -4,25 +4,25 @@ class UserPreference < ActiveRecord::Base
# We could use enums, but Rails 4 doesn't support multiple
# enum options with same name for multiple fields, also it creates
# extra methods that aren't really needed here.
- NOTES_FILTERS = { all_notes: 0, only_comments: 1, only_activity: 2 }.freeze
+ NOTES_FILTERS = {all_notes: 0, only_comments: 1, only_activity: 2}.freeze
belongs_to :user
- validates :issue_notes_filter, :merge_request_notes_filter, inclusion: { in: NOTES_FILTERS.values }, presence: true
+ validates :issue_notes_filter, :merge_request_notes_filter, inclusion: {in: NOTES_FILTERS.values}, presence: true
class << self
def notes_filters
{
- s_('Notes|Show all activity') => NOTES_FILTERS[:all_notes],
- s_('Notes|Show comments only') => NOTES_FILTERS[:only_comments],
- s_('Notes|Show history only') => NOTES_FILTERS[:only_activity]
+ s_("Notes|Show all activity") => NOTES_FILTERS[:all_notes],
+ s_("Notes|Show comments only") => NOTES_FILTERS[:only_comments],
+ s_("Notes|Show history only") => NOTES_FILTERS[:only_activity],
}
end
end
def set_notes_filter(filter_id, issuable)
# No need to update the column if the value is already set.
- if filter_id && NOTES_FILTERS.values.include?(filter_id)
+ if filter_id && NOTES_FILTERS.value?(filter_id)
field = notes_filter_field_for(issuable)
self[field] = filter_id
diff --git a/app/models/user_status.rb b/app/models/user_status.rb
index 2bbb0c59ac1..3f19dec1cf4 100644
--- a/app/models/user_status.rb
+++ b/app/models/user_status.rb
@@ -5,13 +5,13 @@ class UserStatus < ActiveRecord::Base
self.primary_key = :user_id
- DEFAULT_EMOJI = 'speech_balloon'.freeze
+ DEFAULT_EMOJI = "speech_balloon"
belongs_to :user
validates :user, presence: true
- validates :emoji, inclusion: { in: Gitlab::Emoji.emojis_names }
- validates :message, length: { maximum: 100 }, allow_blank: true
+ validates :emoji, inclusion: {in: Gitlab::Emoji.emojis_names}
+ validates :message, length: {maximum: 100}, allow_blank: true
cache_markdown_field :message, pipeline: :emoji
end
diff --git a/app/models/users_star_project.rb b/app/models/users_star_project.rb
index bdaf58ae1c1..cd8a2cb57ed 100644
--- a/app/models/users_star_project.rb
+++ b/app/models/users_star_project.rb
@@ -5,6 +5,6 @@ class UsersStarProject < ActiveRecord::Base
belongs_to :user
validates :user, presence: true
- validates :user_id, uniqueness: { scope: [:project_id] }
+ validates :user_id, uniqueness: {scope: [:project_id]}
validates :project, presence: true
end
diff --git a/app/models/wiki_directory.rb b/app/models/wiki_directory.rb
index 712ba79bbd2..3bb18c764c9 100644
--- a/app/models/wiki_directory.rb
+++ b/app/models/wiki_directory.rb
@@ -15,6 +15,6 @@ class WikiDirectory
# Relative path to the partial to be used when rendering collections
# of this object.
def to_partial_path
- 'projects/wikis/wiki_directory'
+ "projects/wikis/wiki_directory"
end
end
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb
index b1d6d461928..1405c097828 100644
--- a/app/models/wiki_page.rb
+++ b/app/models/wiki_page.rb
@@ -11,11 +11,11 @@ class WikiPage
extend ActiveModel::Naming
def self.primary_key
- 'slug'
+ "slug"
end
def self.model_name
- ActiveModel::Name.new(self, nil, 'wiki')
+ ActiveModel::Name.new(self, nil, "wiki")
end
# Sorts and groups pages by directory.
@@ -30,18 +30,18 @@ class WikiPage
pages.sort_by { |page| [page.directory, page.slug] }
.group_by(&:directory)
- .map do |dir, pages|
+ .map { |dir, pages|
if dir.present?
WikiDirectory.new(dir, pages)
else
pages
end
- end
+ }
.flatten
end
def self.unhyphenize(name)
- name.gsub(/-+/, ' ')
+ name.gsub(/-+/, " ")
end
def to_key
@@ -83,10 +83,10 @@ class WikiPage
end
end
- alias_method :to_param, :slug
+ alias to_param slug
def human_title
- return 'Home' if title == 'home'
+ return "Home" if title == "home"
title
end
@@ -256,7 +256,7 @@ class WikiPage
# Relative path to the partial to be used when rendering collections
# of this object.
def to_partial_path
- 'projects/wikis/wiki_page'
+ "projects/wikis/wiki_page"
end
def id
@@ -286,8 +286,8 @@ class WikiPage
current_dirname = File.dirname(title)
if @page.present?
- return title[1..-1] if current_dirname == '/'
- return File.join([directory.presence, title].compact) if current_dirname == '.'
+ return title[1..-1] if current_dirname == "/"
+ return File.join([directory.presence, title].compact) if current_dirname == "."
end
title
diff --git a/app/policies/base_policy.rb b/app/policies/base_policy.rb
index 72de04203a6..269d92e2259 100644
--- a/app/policies/base_policy.rb
+++ b/app/policies/base_policy.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'declarative_policy'
+require_dependency "declarative_policy"
class BasePolicy < DeclarativePolicy::Base
desc "User is an instance admin"
diff --git a/app/policies/ci/pipeline_schedule_policy.rb b/app/policies/ci/pipeline_schedule_policy.rb
index cf3f784f851..60911c29920 100644
--- a/app/policies/ci/pipeline_schedule_policy.rb
+++ b/app/policies/ci/pipeline_schedule_policy.rb
@@ -2,7 +2,7 @@
module Ci
class PipelineSchedulePolicy < PipelinePolicy
- alias_method :pipeline_schedule, :subject
+ alias pipeline_schedule subject
condition(:protected_ref) do
ref_protected?(@user, @subject.project, @subject.project.repository.tag_exists?(@subject.ref), @subject.ref)
diff --git a/app/policies/clusters/cluster_policy.rb b/app/policies/clusters/cluster_policy.rb
index d6d590687e2..b2490153a8b 100644
--- a/app/policies/clusters/cluster_policy.rb
+++ b/app/policies/clusters/cluster_policy.rb
@@ -2,7 +2,7 @@
module Clusters
class ClusterPolicy < BasePolicy
- alias_method :cluster, :subject
+ alias cluster subject
delegate { cluster.group }
delegate { cluster.project }
diff --git a/app/policies/global_policy.rb b/app/policies/global_policy.rb
index 16c58730878..069b8de8401 100644
--- a/app/policies/global_policy.rb
+++ b/app/policies/global_policy.rb
@@ -13,7 +13,7 @@ class GlobalPolicy < BasePolicy
with_options scope: :user, score: 0
condition(:access_locked) { @user&.access_locked? }
- condition(:can_create_fork, scope: :user) { @user && @user.manageable_namespaces.any? { |namespace| @user.can?(:create_projects, namespace) } }
+ condition(:can_create_fork, scope: :user) { @user&.manageable_namespaces&.any? { |namespace| @user.can?(:create_projects, namespace) } }
condition(:required_terms_not_accepted, scope: :user, score: 0) do
@user&.required_terms_not_accepted?
diff --git a/app/policies/group_policy.rb b/app/policies/group_policy.rb
index 298769c0eb8..1ea85d09124 100644
--- a/app/policies/group_policy.rb
+++ b/app/policies/group_policy.rb
@@ -26,7 +26,7 @@ class GroupPolicy < BasePolicy
condition(:can_change_parent_share_with_group_lock) { can?(:change_share_with_group_lock, @subject.parent) }
condition(:has_projects) do
- GroupProjectsFinder.new(group: @subject, current_user: @user, options: { include_subgroups: true }).execute.any?
+ GroupProjectsFinder.new(group: @subject, current_user: @user, options: {include_subgroups: true}).execute.any?
end
condition(:has_clusters, scope: :subject) { clusterable_has_clusters? }
diff --git a/app/policies/namespace_policy.rb b/app/policies/namespace_policy.rb
index 2babcb0a2d9..9df10bc229f 100644
--- a/app/policies/namespace_policy.rb
+++ b/app/policies/namespace_policy.rb
@@ -3,7 +3,7 @@
class NamespacePolicy < BasePolicy
rule { anonymous }.prevent_all
- condition(:personal_project, scope: :subject) { @subject.kind == 'user' }
+ condition(:personal_project, scope: :subject) { @subject.kind == "user" }
condition(:can_create_personal_project, scope: :user) { @user.can_create_project? }
condition(:owner) { @subject.owner == @user }
diff --git a/app/policies/project_policy.rb b/app/policies/project_policy.rb
index 533782104ac..1f28761eb36 100644
--- a/app/policies/project_policy.rb
+++ b/app/policies/project_policy.rb
@@ -401,13 +401,13 @@ class ProjectPolicy < BasePolicy
enable :create_pipeline
end
- rule do
+ rule {
(can?(:read_project_for_iids) & issues_visible_to_user) | can?(:read_issue)
- end.enable :read_issue_iid
+ }.enable :read_issue_iid
- rule do
+ rule {
(~guest & can?(:read_project_for_iids) & merge_requests_visible_to_user) | can?(:read_merge_request)
- end.enable :read_merge_request_iid
+ }.enable :read_merge_request_iid
rule { ~can_have_multiple_clusters & has_clusters }.prevent :add_cluster
diff --git a/app/policies/project_policy/class_methods.rb b/app/policies/project_policy/class_methods.rb
index 42d993406a9..0c8fac7c71f 100644
--- a/app/policies/project_policy/class_methods.rb
+++ b/app/policies/project_policy/class_methods.rb
@@ -5,7 +5,7 @@ class ProjectPolicy
def create_read_update_admin_destroy(name)
[
:"read_#{name}",
- *create_update_admin_destroy(name)
+ *create_update_admin_destroy(name),
]
end
@@ -14,7 +14,7 @@ class ProjectPolicy
:"create_#{name}",
:"update_#{name}",
:"admin_#{name}",
- :"destroy_#{name}"
+ :"destroy_#{name}",
]
end
end
diff --git a/app/policies/project_snippet_policy.rb b/app/policies/project_snippet_policy.rb
index e5e005cee6d..e2b101238dd 100644
--- a/app/policies/project_snippet_policy.rb
+++ b/app/policies/project_snippet_policy.rb
@@ -24,12 +24,12 @@ class ProjectSnippetPolicy < BasePolicy
# information about the snippet. However, :read_project_snippet on the *project*
# is used to hide/show various snippet-related controls, so we can't just move
# all of the handling here.
- rule do
+ rule {
all?(private_snippet | (internal_snippet & external_user),
- ~project.guest,
- ~is_author,
- ~full_private_access)
- end.prevent :read_project_snippet
+ ~project.guest,
+ ~is_author,
+ ~full_private_access)
+ }.prevent :read_project_snippet
rule { internal_snippet & ~is_author & ~admin }.policy do
prevent :update_project_snippet
diff --git a/app/presenters/ci/build_metadata_presenter.rb b/app/presenters/ci/build_metadata_presenter.rb
index 015b1f67db7..96469043093 100644
--- a/app/presenters/ci/build_metadata_presenter.rb
+++ b/app/presenters/ci/build_metadata_presenter.rb
@@ -3,9 +3,9 @@
module Ci
class BuildMetadataPresenter < Gitlab::View::Presenter::Delegated
TIMEOUT_SOURCES = {
- unknown_timeout_source: nil,
- project_timeout_source: 'project',
- runner_timeout_source: 'runner'
+ unknown_timeout_source: nil,
+ project_timeout_source: "project",
+ runner_timeout_source: "runner",
}.freeze
presents :metadata
diff --git a/app/presenters/ci/build_runner_presenter.rb b/app/presenters/ci/build_runner_presenter.rb
index d60281c8a0b..22341eed948 100644
--- a/app/presenters/ci/build_runner_presenter.rb
+++ b/app/presenters/ci/build_runner_presenter.rb
@@ -4,8 +4,8 @@ module Ci
class BuildRunnerPresenter < SimpleDelegator
include Gitlab::Utils::StrongMemoize
- RUNNER_REMOTE_TAG_PREFIX = 'refs/tags/'.freeze
- RUNNER_REMOTE_BRANCH_PREFIX = 'refs/remotes/origin/'.freeze
+ RUNNER_REMOTE_TAG_PREFIX = "refs/tags/"
+ RUNNER_REMOTE_BRANCH_PREFIX = "refs/remotes/origin/"
def artifacts
return unless options[:artifacts]
@@ -18,15 +18,15 @@ module Ci
def ref_type
if tag
- 'tag'
+ "tag"
else
- 'branch'
+ "branch"
end
end
def git_depth
strong_memoize(:git_depth) do
- git_depth = variables&.find { |variable| variable[:key] == 'GIT_DEPTH' }&.dig(:value)
+ git_depth = variables&.find { |variable| variable[:key] == "GIT_DEPTH" }&.dig(:value)
git_depth.to_i
end
end
@@ -57,7 +57,7 @@ module Ci
untracked: artifacts[:untracked],
paths: artifacts[:paths],
when: artifacts[:when],
- expire_in: artifacts[:expire_in]
+ expire_in: artifacts[:expire_in],
}
end
@@ -70,17 +70,17 @@ module Ci
artifact_format: ::Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(report_type.to_sym),
name: ::Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(report_type.to_sym),
paths: report_paths,
- when: 'always',
- expire_in: expire_in
+ when: "always",
+ expire_in: expire_in,
}
end
end
- def refspec_for_branch(ref = '*')
+ def refspec_for_branch(ref = "*")
"+#{Gitlab::Git::BRANCH_REF_PREFIX}#{ref}:#{RUNNER_REMOTE_BRANCH_PREFIX}#{ref}"
end
- def refspec_for_tag(ref = '*')
+ def refspec_for_tag(ref = "*")
"+#{Gitlab::Git::TAG_REF_PREFIX}#{ref}:#{RUNNER_REMOTE_TAG_PREFIX}#{ref}"
end
end
diff --git a/app/presenters/ci/group_variable_presenter.rb b/app/presenters/ci/group_variable_presenter.rb
index 99011150c84..8c2a7cae028 100644
--- a/app/presenters/ci/group_variable_presenter.rb
+++ b/app/presenters/ci/group_variable_presenter.rb
@@ -5,7 +5,7 @@ module Ci
presents :variable
def placeholder
- 'GROUP_VARIABLE'
+ "GROUP_VARIABLE"
end
def form_path
diff --git a/app/presenters/ci/pipeline_presenter.rb b/app/presenters/ci/pipeline_presenter.rb
index 57daf04efc6..829a8ac0b9d 100644
--- a/app/presenters/ci/pipeline_presenter.rb
+++ b/app/presenters/ci/pipeline_presenter.rb
@@ -7,7 +7,7 @@ module Ci
# We use a class method here instead of a constant, allowing EE to redefine
# the returned `Hash` more easily.
def self.failure_reasons
- { config_error: 'CI/CD YAML configuration error!' }
+ {config_error: "CI/CD YAML configuration error!"}
end
presents :pipeline
diff --git a/app/presenters/ci/variable_presenter.rb b/app/presenters/ci/variable_presenter.rb
index f027f3aa560..c0214c6fafa 100644
--- a/app/presenters/ci/variable_presenter.rb
+++ b/app/presenters/ci/variable_presenter.rb
@@ -5,7 +5,7 @@ module Ci
presents :variable
def placeholder
- 'PROJECT_VARIABLE'
+ "PROJECT_VARIABLE"
end
def form_path
diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb
index 7a5b68f9a4b..760c44dfd66 100644
--- a/app/presenters/clusters/cluster_presenter.rb
+++ b/app/presenters/clusters/cluster_presenter.rb
@@ -12,7 +12,7 @@ module Clusters
# clusterable, only for the ancestor clusters.
def item_link(clusterable_presenter)
if cluster.group_type? && clusterable != clusterable_presenter.subject
- contracted_group_name(cluster.group) + ' / ' + link_to_cluster
+ contracted_group_name(cluster.group) + " / " + link_to_cluster
else
link_to_cluster
end
@@ -65,7 +65,7 @@ module Clusters
end
def contracted_icon
- sprite_icon('ellipsis_h', size: 12, css_class: 'vertical-align-middle')
+ sprite_icon("ellipsis_h", size: 12, css_class: "vertical-align-middle")
end
def link_to_cluster
diff --git a/app/presenters/commit_status_presenter.rb b/app/presenters/commit_status_presenter.rb
index 0cd77da6303..c7e8f75f298 100644
--- a/app/presenters/commit_status_presenter.rb
+++ b/app/presenters/commit_status_presenter.rb
@@ -2,16 +2,16 @@
class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
CALLOUT_FAILURE_MESSAGES = {
- unknown_failure: 'There is an unknown failure, please try again',
+ unknown_failure: "There is an unknown failure, please try again",
script_failure: nil,
- api_failure: 'There has been an API failure, please try again',
- stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again',
- runner_system_failure: 'There has been a runner system failure, please try again',
- missing_dependency_failure: 'There has been a missing dependency failure',
- runner_unsupported: 'Your runner is outdated, please upgrade your runner',
- stale_schedule: 'Delayed job could not be executed by some reason, please try again',
- job_execution_timeout: 'The script exceeded the maximum execution time set for the job',
- archived_failure: 'The job is archived and cannot be run'
+ api_failure: "There has been an API failure, please try again",
+ stuck_or_timeout_failure: "There has been a timeout failure or the job got stuck. Check your timeout limits or try again",
+ runner_system_failure: "There has been a runner system failure, please try again",
+ missing_dependency_failure: "There has been a missing dependency failure",
+ runner_unsupported: "Your runner is outdated, please upgrade your runner",
+ stale_schedule: "Delayed job could not be executed by some reason, please try again",
+ job_execution_timeout: "The script exceeded the maximum execution time set for the job",
+ archived_failure: "The job is archived and cannot be run",
}.freeze
private_constant :CALLOUT_FAILURE_MESSAGES
diff --git a/app/presenters/conversational_development_index/metric_presenter.rb b/app/presenters/conversational_development_index/metric_presenter.rb
index 9639b84cf56..5f6b0f1ce6c 100644
--- a/app/presenters/conversational_development_index/metric_presenter.rb
+++ b/app/presenters/conversational_development_index/metric_presenter.rb
@@ -6,81 +6,81 @@ module ConversationalDevelopmentIndex
[
Card.new(
metric: subject,
- title: 'Issues',
- description: 'created per active user',
- feature: 'issues',
- blog: 'https://www2.deloitte.com/content/dam/Deloitte/se/Documents/technology-media-telecommunications/deloitte-digital-collaboration.pdf'
+ title: "Issues",
+ description: "created per active user",
+ feature: "issues",
+ blog: "https://www2.deloitte.com/content/dam/Deloitte/se/Documents/technology-media-telecommunications/deloitte-digital-collaboration.pdf"
),
Card.new(
metric: subject,
- title: 'Comments',
- description: 'created per active user',
- feature: 'notes',
- blog: 'http://conversationaldevelopment.com/why/'
+ title: "Comments",
+ description: "created per active user",
+ feature: "notes",
+ blog: "http://conversationaldevelopment.com/why/"
),
Card.new(
metric: subject,
- title: 'Milestones',
- description: 'created per active user',
- feature: 'milestones',
- blog: 'http://conversationaldevelopment.com/shorten-cycle/',
- docs: help_page_path('user/project/milestones/index')
+ title: "Milestones",
+ description: "created per active user",
+ feature: "milestones",
+ blog: "http://conversationaldevelopment.com/shorten-cycle/",
+ docs: help_page_path("user/project/milestones/index")
),
Card.new(
metric: subject,
- title: 'Boards',
- description: 'created per active user',
- feature: 'boards',
- blog: 'http://jpattonassociates.com/user-story-mapping/',
- docs: help_page_path('user/project/issue_board')
+ title: "Boards",
+ description: "created per active user",
+ feature: "boards",
+ blog: "http://jpattonassociates.com/user-story-mapping/",
+ docs: help_page_path("user/project/issue_board")
),
Card.new(
metric: subject,
- title: 'Merge Requests',
- description: 'per active user',
- feature: 'merge_requests',
- blog: 'https://8thlight.com/blog/uncle-bob/2013/02/01/The-Humble-Craftsman.html',
- docs: help_page_path('user/project/merge_requests/index')
+ title: "Merge Requests",
+ description: "per active user",
+ feature: "merge_requests",
+ blog: "https://8thlight.com/blog/uncle-bob/2013/02/01/The-Humble-Craftsman.html",
+ docs: help_page_path("user/project/merge_requests/index")
),
Card.new(
metric: subject,
- title: 'Pipelines',
- description: 'created per active user',
- feature: 'ci_pipelines',
- blog: 'https://martinfowler.com/bliki/ContinuousDelivery.html',
- docs: help_page_path('ci/README')
+ title: "Pipelines",
+ description: "created per active user",
+ feature: "ci_pipelines",
+ blog: "https://martinfowler.com/bliki/ContinuousDelivery.html",
+ docs: help_page_path("ci/README")
),
Card.new(
metric: subject,
- title: 'Environments',
- description: 'created per active user',
- feature: 'environments',
- blog: 'https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/',
- docs: help_page_path('ci/environments')
+ title: "Environments",
+ description: "created per active user",
+ feature: "environments",
+ blog: "https://about.gitlab.com/2016/08/26/ci-deployment-and-environments/",
+ docs: help_page_path("ci/environments")
),
Card.new(
metric: subject,
- title: 'Deployments',
- description: 'created per active user',
- feature: 'deployments',
- blog: 'https://puppet.com/blog/continuous-delivery-vs-continuous-deployment-what-s-diff'
+ title: "Deployments",
+ description: "created per active user",
+ feature: "deployments",
+ blog: "https://puppet.com/blog/continuous-delivery-vs-continuous-deployment-what-s-diff"
),
Card.new(
metric: subject,
- title: 'Monitoring',
- description: 'fraction of all projects',
- feature: 'projects_prometheus_active',
- blog: 'https://prometheus.io/docs/introduction/overview/',
- docs: help_page_path('user/project/integrations/prometheus')
+ title: "Monitoring",
+ description: "fraction of all projects",
+ feature: "projects_prometheus_active",
+ blog: "https://prometheus.io/docs/introduction/overview/",
+ docs: help_page_path("user/project/integrations/prometheus")
),
Card.new(
metric: subject,
- title: 'Service Desk',
- description: 'issues created per active user',
- feature: 'service_desk_issues',
- blog: 'http://blogs.forrester.com/kate_leggett/17-01-30-top_trends_for_customer_service_in_2017_operations_become_smarter_and_more_strategic',
- docs: 'https://docs.gitlab.com/ee/user/project/service_desk.html'
- )
+ title: "Service Desk",
+ description: "issues created per active user",
+ feature: "service_desk_issues",
+ blog: "http://blogs.forrester.com/kate_leggett/17-01-30-top_trends_for_customer_service_in_2017_operations_become_smarter_and_more_strategic",
+ docs: "https://docs.gitlab.com/ee/user/project/service_desk.html"
+ ),
]
end
@@ -88,54 +88,54 @@ module ConversationalDevelopmentIndex
[
IdeaToProductionStep.new(
metric: subject,
- title: 'Idea',
- features: %w(issues)
+ title: "Idea",
+ features: %w[issues]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Issue',
- features: %w(issues notes)
+ title: "Issue",
+ features: %w[issues notes]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Plan',
- features: %w(milestones boards)
+ title: "Plan",
+ features: %w[milestones boards]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Code',
- features: %w(merge_requests)
+ title: "Code",
+ features: %w[merge_requests]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Commit',
- features: %w(merge_requests)
+ title: "Commit",
+ features: %w[merge_requests]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Test',
- features: %w(ci_pipelines)
+ title: "Test",
+ features: %w[ci_pipelines]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Review',
- features: %w(ci_pipelines environments)
+ title: "Review",
+ features: %w[ci_pipelines environments]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Staging',
- features: %w(environments deployments)
+ title: "Staging",
+ features: %w[environments deployments]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Production',
- features: %w(deployments)
+ title: "Production",
+ features: %w[deployments]
),
IdeaToProductionStep.new(
metric: subject,
- title: 'Feedback',
- features: %w(projects_prometheus_active service_desk_issues)
- )
+ title: "Feedback",
+ features: %w[projects_prometheus_active service_desk_issues]
+ ),
]
end
diff --git a/app/presenters/group_clusterable_presenter.rb b/app/presenters/group_clusterable_presenter.rb
index ef6bbc0d109..73bfe9a58b8 100644
--- a/app/presenters/group_clusterable_presenter.rb
+++ b/app/presenters/group_clusterable_presenter.rb
@@ -21,16 +21,16 @@ class GroupClusterablePresenter < ClusterablePresenter
override :empty_state_help_text
def empty_state_help_text
- s_('ClusterIntegration|Adding an integration to your group will share the cluster across all your projects.')
+ s_("ClusterIntegration|Adding an integration to your group will share the cluster across all your projects.")
end
override :sidebar_text
def sidebar_text
- s_('ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects. Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster.')
+ s_("ClusterIntegration|Adding a Kubernetes cluster to your group will automatically share the cluster across all your projects. Use review apps, deploy your applications, and easily run your pipelines for all projects using the same cluster.")
end
override :learn_more_link
def learn_more_link
- link_to(s_('ClusterIntegration|Learn more about group Kubernetes clusters'), help_page_path('user/group/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
+ link_to(s_("ClusterIntegration|Learn more about group Kubernetes clusters"), help_page_path("user/group/clusters/index"), target: "_blank", rel: "noopener noreferrer")
end
end
diff --git a/app/presenters/merge_request_presenter.rb b/app/presenters/merge_request_presenter.rb
index c59e73f824c..a708ae33969 100644
--- a/app/presenters/merge_request_presenter.rb
+++ b/app/presenters/merge_request_presenter.rb
@@ -51,12 +51,12 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
continue_params = {
to: merge_request_path(merge_request),
notice: "#{edit_in_new_fork_notice} Try to cherry-pick this commit again.",
- notice_now: edit_in_new_fork_notice_now
+ notice_now: edit_in_new_fork_notice_now,
}
project_forks_path(merge_request.project,
- namespace_key: current_user.namespace.id,
- continue: continue_params)
+ namespace_key: current_user.namespace.id,
+ continue: continue_params)
end
end
@@ -65,12 +65,12 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
continue_params = {
to: merge_request_path(merge_request),
notice: "#{edit_in_new_fork_notice} Try to revert this commit again.",
- notice_now: edit_in_new_fork_notice_now
+ notice_now: edit_in_new_fork_notice_now,
}
project_forks_path(project,
- namespace_key: current_user.namespace.id,
- continue: continue_params)
+ namespace_key: current_user.namespace.id,
+ continue: continue_params)
end
end
@@ -138,10 +138,9 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
def assign_to_closing_issues_link
# rubocop: disable CodeReuse/ServiceClass
issues = MergeRequests::AssignIssuesService.new(project,
- current_user,
- merge_request: merge_request,
- closes_issues: closing_issues
- ).assignable_issues
+ current_user,
+ merge_request: merge_request,
+ closes_issues: closing_issues).assignable_issues
path = assign_related_issues_project_merge_request_path(project, merge_request)
if issues.present?
pluralize_this_issue = issues.count > 1 ? "these issues" : "this issue"
@@ -194,7 +193,7 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
end
def conflicts_docs_path
- help_page_path('user/project/merge_requests/resolve_conflicts.md')
+ help_page_path("user/project/merge_requests/resolve_conflicts.md")
end
private
@@ -222,9 +221,9 @@ class MergeRequestPresenter < Gitlab::View::Presenter::Delegated
def issues_sentence(project, issues)
# Sorting based on the `#123` or `group/project#123` reference will sort
# local issues first.
- issues.map do |issue|
+ issues.map { |issue|
issue.to_reference(project)
- end.sort.to_sentence
+ }.sort.to_sentence
end
def user_can_fork_project?
diff --git a/app/presenters/project_clusterable_presenter.rb b/app/presenters/project_clusterable_presenter.rb
index 63e69b91b11..7912af95d80 100644
--- a/app/presenters/project_clusterable_presenter.rb
+++ b/app/presenters/project_clusterable_presenter.rb
@@ -21,11 +21,11 @@ class ProjectClusterablePresenter < ClusterablePresenter
override :sidebar_text
def sidebar_text
- s_('ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.')
+ s_("ClusterIntegration|With a Kubernetes cluster associated to this project, you can use review apps, deploy your applications, run your pipelines, and much more in an easy way.")
end
override :learn_more_link
def learn_more_link
- link_to(s_('ClusterIntegration|Learn more about Kubernetes'), help_page_path('user/project/clusters/index'), target: '_blank', rel: 'noopener noreferrer')
+ link_to(s_("ClusterIntegration|Learn more about Kubernetes"), help_page_path("user/project/clusters/index"), target: "_blank", rel: "noopener noreferrer")
end
end
diff --git a/app/presenters/project_presenter.rb b/app/presenters/project_presenter.rb
index 000b7c433a2..3f52bacb86a 100644
--- a/app/presenters/project_presenter.rb
+++ b/app/presenters/project_presenter.rb
@@ -15,8 +15,8 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
AnchorData = Struct.new(:is_link, :label, :link, :class_modifier, :icon)
MAX_TOPICS_TO_SHOW = 3
- def statistic_icon(icon_name = 'plus-square-o')
- sprite_icon(icon_name, size: 16, css_class: 'icon append-right-4')
+ def statistic_icon(icon_name = "plus-square-o")
+ sprite_icon(icon_name, size: 16, css_class: "icon append-right-4")
end
def statistics_anchors(show_auto_devops_callout:)
@@ -25,7 +25,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
commits_anchor_data,
branches_anchor_data,
tags_anchor_data,
- files_anchor_data
+ files_anchor_data,
].compact.select(&:is_link)
end
@@ -36,7 +36,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
contribution_guide_anchor_data,
autodevops_anchor_data(show_auto_devops_callout: show_auto_devops_callout),
kubernetes_cluster_anchor_data,
- gitlab_ci_anchor_data
+ gitlab_ci_anchor_data,
].compact.reject(&:is_link)
end
@@ -46,7 +46,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
commits_anchor_data,
branches_anchor_data,
tags_anchor_data,
- files_anchor_data
+ files_anchor_data,
].compact.select { |item| item.is_link }
end
@@ -57,7 +57,7 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
changelog_anchor_data,
contribution_guide_anchor_data,
autodevops_anchor_data,
- kubernetes_cluster_anchor_data
+ kubernetes_cluster_anchor_data,
].compact.reject { |item| item.is_link }
end
@@ -100,34 +100,34 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
project_blob_path(
project,
tree_join(project.default_branch,
- contribution_guide.name)
+ contribution_guide.name)
)
end
end
def add_license_path
- add_special_file_path(file_name: 'LICENSE')
+ add_special_file_path(file_name: "LICENSE")
end
def add_changelog_path
- add_special_file_path(file_name: 'CHANGELOG')
+ add_special_file_path(file_name: "CHANGELOG")
end
def add_contribution_guide_path
- add_special_file_path(file_name: 'CONTRIBUTING.md', commit_message: 'Add CONTRIBUTING')
+ add_special_file_path(file_name: "CONTRIBUTING.md", commit_message: "Add CONTRIBUTING")
end
def add_ci_yml_path
- add_special_file_path(file_name: '.gitlab-ci.yml')
+ add_special_file_path(file_name: ".gitlab-ci.yml")
end
def add_readme_path
- add_special_file_path(file_name: 'README.md')
+ add_special_file_path(file_name: "README.md")
end
def license_short_name
license = repository.license
- license&.nickname || license&.name || 'LICENSE'
+ license&.nickname || license&.name || "LICENSE"
end
def can_current_user_push_code?
@@ -150,100 +150,100 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def files_anchor_data
AnchorData.new(true,
- statistic_icon('doc-code') +
- _('%{strong_start}%{human_size}%{strong_end} Files').html_safe % {
- human_size: storage_counter(statistics.total_repository_size),
- strong_start: '<strong class="project-stat-value">'.html_safe,
- strong_end: '</strong>'.html_safe
- },
- empty_repo? ? nil : project_tree_path(project))
+ statistic_icon("doc-code") +
+ _("%{strong_start}%{human_size}%{strong_end} Files").html_safe % {
+ human_size: storage_counter(statistics.total_repository_size),
+ strong_start: '<strong class="project-stat-value">'.html_safe,
+ strong_end: "</strong>".html_safe,
+ },
+ empty_repo? ? nil : project_tree_path(project))
end
def commits_anchor_data
AnchorData.new(true,
- statistic_icon('commit') +
- n_('%{strong_start}%{commit_count}%{strong_end} Commit', '%{strong_start}%{commit_count}%{strong_end} Commits', statistics.commit_count).html_safe % {
- commit_count: number_with_delimiter(statistics.commit_count),
- strong_start: '<strong class="project-stat-value">'.html_safe,
- strong_end: '</strong>'.html_safe
- },
- empty_repo? ? nil : project_commits_path(project, repository.root_ref))
+ statistic_icon("commit") +
+ n_("%{strong_start}%{commit_count}%{strong_end} Commit", "%{strong_start}%{commit_count}%{strong_end} Commits", statistics.commit_count).html_safe % {
+ commit_count: number_with_delimiter(statistics.commit_count),
+ strong_start: '<strong class="project-stat-value">'.html_safe,
+ strong_end: "</strong>".html_safe,
+ },
+ empty_repo? ? nil : project_commits_path(project, repository.root_ref))
end
def branches_anchor_data
AnchorData.new(true,
- statistic_icon('branch') +
- n_('%{strong_start}%{branch_count}%{strong_end} Branch', '%{strong_start}%{branch_count}%{strong_end} Branches', repository.branch_count).html_safe % {
- branch_count: number_with_delimiter(repository.branch_count),
- strong_start: '<strong class="project-stat-value">'.html_safe,
- strong_end: '</strong>'.html_safe
- },
- empty_repo? ? nil : project_branches_path(project))
+ statistic_icon("branch") +
+ n_("%{strong_start}%{branch_count}%{strong_end} Branch", "%{strong_start}%{branch_count}%{strong_end} Branches", repository.branch_count).html_safe % {
+ branch_count: number_with_delimiter(repository.branch_count),
+ strong_start: '<strong class="project-stat-value">'.html_safe,
+ strong_end: "</strong>".html_safe,
+ },
+ empty_repo? ? nil : project_branches_path(project))
end
def tags_anchor_data
AnchorData.new(true,
- statistic_icon('label') +
- n_('%{strong_start}%{tag_count}%{strong_end} Tag', '%{strong_start}%{tag_count}%{strong_end} Tags', repository.tag_count).html_safe % {
- tag_count: number_with_delimiter(repository.tag_count),
- strong_start: '<strong class="project-stat-value">'.html_safe,
- strong_end: '</strong>'.html_safe
- },
- empty_repo? ? nil : project_tags_path(project))
+ statistic_icon("label") +
+ n_("%{strong_start}%{tag_count}%{strong_end} Tag", "%{strong_start}%{tag_count}%{strong_end} Tags", repository.tag_count).html_safe % {
+ tag_count: number_with_delimiter(repository.tag_count),
+ strong_start: '<strong class="project-stat-value">'.html_safe,
+ strong_end: "</strong>".html_safe,
+ },
+ empty_repo? ? nil : project_tags_path(project))
end
def new_file_anchor_data
if current_user && can_current_user_push_to_default_branch?
AnchorData.new(false,
- statistic_icon + _('New file'),
- project_new_blob_path(project, default_branch || 'master'),
- 'success')
+ statistic_icon + _("New file"),
+ project_new_blob_path(project, default_branch || "master"),
+ "success")
end
end
def readme_anchor_data
if current_user && can_current_user_push_to_default_branch? && repository.readme.nil?
AnchorData.new(false,
- statistic_icon + _('Add README'),
- add_readme_path)
+ statistic_icon + _("Add README"),
+ add_readme_path)
elsif repository.readme
AnchorData.new(false,
- statistic_icon('doc-text') + _('README'),
- default_view != 'readme' ? readme_path : '#readme',
- 'default',
- 'doc-text')
+ statistic_icon("doc-text") + _("README"),
+ default_view != "readme" ? readme_path : "#readme",
+ "default",
+ "doc-text")
end
end
def changelog_anchor_data
if current_user && can_current_user_push_to_default_branch? && repository.changelog.blank?
AnchorData.new(false,
- statistic_icon + _('Add CHANGELOG'),
- add_changelog_path)
+ statistic_icon + _("Add CHANGELOG"),
+ add_changelog_path)
elsif repository.changelog.present?
AnchorData.new(false,
- statistic_icon('doc-text') + _('CHANGELOG'),
- changelog_path,
- 'default')
+ statistic_icon("doc-text") + _("CHANGELOG"),
+ changelog_path,
+ "default")
end
end
def license_anchor_data
- icon = statistic_icon('scale')
+ icon = statistic_icon("scale")
if repository.license_blob.present?
AnchorData.new(true,
- icon + content_tag(:strong, license_short_name, class: 'project-stat-value'),
- license_path)
+ icon + content_tag(:strong, license_short_name, class: "project-stat-value"),
+ license_path)
else
if current_user && can_current_user_push_to_default_branch?
AnchorData.new(true,
- content_tag(:span, icon + _('Add license'), class: 'add-license-link d-flex'),
- add_license_path)
+ content_tag(:span, icon + _("Add license"), class: "add-license-link d-flex"),
+ add_license_path)
else
AnchorData.new(true,
- icon + content_tag(:strong, _('No license. All rights reserved'), class: 'project-stat-value'),
- nil)
+ icon + content_tag(:strong, _("No license. All rights reserved"), class: "project-stat-value"),
+ nil)
end
end
end
@@ -251,13 +251,13 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def contribution_guide_anchor_data
if current_user && can_current_user_push_to_default_branch? && repository.contribution_guide.blank?
AnchorData.new(false,
- statistic_icon + _('Add CONTRIBUTING'),
- add_contribution_guide_path)
+ statistic_icon + _("Add CONTRIBUTING"),
+ add_contribution_guide_path)
elsif repository.contribution_guide.present?
AnchorData.new(false,
- statistic_icon('doc-text') + _('CONTRIBUTING'),
- contribution_guide_path,
- 'default')
+ statistic_icon("doc-text") + _("CONTRIBUTING"),
+ contribution_guide_path,
+ "default")
end
end
@@ -265,18 +265,18 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
if current_user && can?(current_user, :admin_pipeline, project) && repository.gitlab_ci_yml.blank? && !show_auto_devops_callout
if auto_devops_enabled?
AnchorData.new(false,
- statistic_icon('doc-text') + _('Auto DevOps enabled'),
- project_settings_ci_cd_path(project, anchor: 'autodevops-settings'),
- 'default')
+ statistic_icon("doc-text") + _("Auto DevOps enabled"),
+ project_settings_ci_cd_path(project, anchor: "autodevops-settings"),
+ "default")
else
AnchorData.new(false,
- statistic_icon + _('Enable Auto DevOps'),
- project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ statistic_icon + _("Enable Auto DevOps"),
+ project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
elsif auto_devops_enabled?
AnchorData.new(false,
- _('Auto DevOps enabled'),
- nil)
+ _("Auto DevOps enabled"),
+ nil)
end
end
@@ -285,15 +285,15 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
if clusters.empty?
AnchorData.new(false,
- statistic_icon + _('Add Kubernetes cluster'),
- new_project_cluster_path(project))
+ statistic_icon + _("Add Kubernetes cluster"),
+ new_project_cluster_path(project))
else
cluster_link = clusters.count == 1 ? project_cluster_path(project, clusters.first) : project_clusters_path(project)
AnchorData.new(false,
- _('Kubernetes configured'),
- cluster_link,
- 'default')
+ _("Kubernetes configured"),
+ cluster_link,
+ "default")
end
end
end
@@ -301,13 +301,13 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def gitlab_ci_anchor_data
if current_user && can_current_user_push_code? && repository.gitlab_ci_yml.blank? && !auto_devops_enabled?
AnchorData.new(false,
- statistic_icon + _('Set up CI/CD'),
- add_ci_yml_path)
+ statistic_icon + _("Set up CI/CD"),
+ add_ci_yml_path)
elsif repository.gitlab_ci_yml.present?
AnchorData.new(false,
- statistic_icon('doc-text') + _('CI/CD configuration'),
- ci_configuration_path,
- 'default')
+ statistic_icon("doc-text") + _("CI/CD configuration"),
+ ci_configuration_path,
+ "default")
end
end
@@ -344,20 +344,20 @@ class ProjectPresenter < Gitlab::View::Presenter::Delegated
def anonymous_project_view
if !project.empty_repo? && can?(current_user, :download_code, project)
- 'files'
+ "files"
else
- 'activity'
+ "activity"
end
end
def add_special_file_path(file_name:, commit_message: nil, branch_name: nil)
- commit_message ||= s_("CommitMessage|Add %{file_name}") % { file_name: file_name }
+ commit_message ||= s_("CommitMessage|Add %{file_name}") % {file_name: file_name}
project_new_blob_path(
project,
- project.default_branch || 'master',
- file_name: file_name,
+ project.default_branch || "master",
+ file_name: file_name,
commit_message: commit_message,
- branch_name: branch_name
+ branch_name: branch_name
)
end
end
diff --git a/app/presenters/projects/settings/deploy_keys_presenter.rb b/app/presenters/projects/settings/deploy_keys_presenter.rb
index 85518c9a3a4..ed125cc752d 100644
--- a/app/presenters/projects/settings/deploy_keys_presenter.rb
+++ b/app/presenters/projects/settings/deploy_keys_presenter.rb
@@ -50,21 +50,21 @@ module Projects
def as_json
serializer = DeployKeySerializer.new # rubocop: disable CodeReuse/Serializer
- opts = { user: current_user }
+ opts = {user: current_user}
{
enabled_keys: serializer.represent(enabled_keys, opts),
available_project_keys: serializer.represent(available_project_keys, opts),
- public_keys: serializer.represent(available_public_keys, opts)
+ public_keys: serializer.represent(available_public_keys, opts),
}
end
def to_partial_path
- 'projects/deploy_keys/index'
+ "projects/deploy_keys/index"
end
def form_partial_path
- 'projects/deploy_keys/form'
+ "projects/deploy_keys/form"
end
end
end
diff --git a/app/serializers/base_serializer.rb b/app/serializers/base_serializer.rb
index 4744a7c1cc8..90bd4730f1e 100644
--- a/app/serializers/base_serializer.rb
+++ b/app/serializers/base_serializer.rb
@@ -9,7 +9,7 @@ class BaseSerializer
end
def represent(resource, opts = {}, entity_class = nil)
- entity_class = entity_class || self.class.entity_class
+ entity_class ||= self.class.entity_class
entity_class
.represent(resource, opts.merge(request: @request))
diff --git a/app/serializers/blob_entity.rb b/app/serializers/blob_entity.rb
index 3ac61481dea..0f7d1810ee0 100644
--- a/app/serializers/blob_entity.rb
+++ b/app/serializers/blob_entity.rb
@@ -8,10 +8,10 @@ class BlobEntity < Grape::Entity
expose :readable_text?, as: :readable_text
expose :icon do |blob|
- IconsHelper.file_type_icon_class('file', blob.mode, blob.name)
+ IconsHelper.file_type_icon_class("file", blob.mode, blob.name)
end
- expose :url, if: -> (*) { request.respond_to?(:ref) } do |blob|
+ expose :url, if: ->(*) { request.respond_to?(:ref) } do |blob|
project_blob_path(request.project, File.join(request.ref, blob.path))
end
end
diff --git a/app/serializers/build_action_entity.rb b/app/serializers/build_action_entity.rb
index 95833c3528f..a40cb02634f 100644
--- a/app/serializers/build_action_entity.rb
+++ b/app/serializers/build_action_entity.rb
@@ -13,15 +13,15 @@ class BuildActionEntity < Grape::Entity
expose :playable?, as: :playable
expose :scheduled?, as: :scheduled
- expose :scheduled_at, if: -> (*) { scheduled? }
+ expose :scheduled_at, if: ->(*) { scheduled? }
- expose :unschedule_path, if: -> (build) { build.scheduled? } do |build|
+ expose :unschedule_path, if: ->(build) { build.scheduled? } do |build|
unschedule_project_job_path(build.project, build)
end
private
- alias_method :build, :object
+ alias build object
def playable?
build.playable? && can?(request.current_user, :update_build, build)
diff --git a/app/serializers/build_artifact_entity.rb b/app/serializers/build_artifact_entity.rb
index 414f436e76e..af638f05e63 100644
--- a/app/serializers/build_artifact_entity.rb
+++ b/app/serializers/build_artifact_entity.rb
@@ -14,7 +14,7 @@ class BuildArtifactEntity < Grape::Entity
download_project_job_artifacts_path(project, job)
end
- expose :keep_path, if: -> (*) { job.has_expiring_artifacts? } do |job|
+ expose :keep_path, if: ->(*) { job.has_expiring_artifacts? } do |job|
keep_project_job_artifacts_path(project, job)
end
@@ -24,7 +24,7 @@ class BuildArtifactEntity < Grape::Entity
private
- alias_method :job, :object
+ alias job object
def project
job.project
diff --git a/app/serializers/build_details_entity.rb b/app/serializers/build_details_entity.rb
index 9ddce0d2c80..770e7f6975c 100644
--- a/app/serializers/build_details_entity.rb
+++ b/app/serializers/build_details_entity.rb
@@ -10,7 +10,7 @@ class BuildDetailsEntity < JobEntity
expose :runner, using: RunnerEntity
expose :pipeline, using: PipelineEntity
- expose :deployment_status, if: -> (*) { build.starts_environment? } do
+ expose :deployment_status, if: ->(*) { build.starts_environment? } do
expose :deployment_status, as: :status
expose :persisted_environment, as: :environment, with: EnvironmentEntity
@@ -18,49 +18,49 @@ class BuildDetailsEntity < JobEntity
expose :metadata, using: BuildMetadataEntity
- expose :artifact, if: -> (*) { can?(current_user, :read_build, build) } do
- expose :download_path, if: -> (*) { build.artifacts? } do |build|
+ expose :artifact, if: ->(*) { can?(current_user, :read_build, build) } do
+ expose :download_path, if: ->(*) { build.artifacts? } do |build|
download_project_job_artifacts_path(project, build)
end
- expose :browse_path, if: -> (*) { build.browsable_artifacts? } do |build|
+ expose :browse_path, if: ->(*) { build.browsable_artifacts? } do |build|
browse_project_job_artifacts_path(project, build)
end
- expose :keep_path, if: -> (*) { build.has_expiring_artifacts? && can?(current_user, :update_build, build) } do |build|
+ expose :keep_path, if: ->(*) { build.has_expiring_artifacts? && can?(current_user, :update_build, build) } do |build|
keep_project_job_artifacts_path(project, build)
end
- expose :expire_at, if: -> (*) { build.artifacts_expire_at.present? } do |build|
+ expose :expire_at, if: ->(*) { build.artifacts_expire_at.present? } do |build|
build.artifacts_expire_at
end
- expose :expired, if: -> (*) { build.artifacts_expire_at.present? } do |build|
+ expose :expired, if: ->(*) { build.artifacts_expire_at.present? } do |build|
build.artifacts_expired?
end
end
- expose :erased_by, if: -> (*) { build.erased? }, using: UserEntity
- expose :erase_path, if: -> (*) { build.erasable? && can?(current_user, :erase_build, build) } do |build|
+ expose :erased_by, if: ->(*) { build.erased? }, using: UserEntity
+ expose :erase_path, if: ->(*) { build.erasable? && can?(current_user, :erase_build, build) } do |build|
erase_project_job_path(project, build)
end
- expose :terminal_path, if: -> (*) { can_create_build_terminal? } do |build|
+ expose :terminal_path, if: ->(*) { can_create_build_terminal? } do |build|
terminal_project_job_path(project, build)
end
- expose :merge_request, if: -> (*) { can?(current_user, :read_merge_request, build.merge_request) } do
+ expose :merge_request, if: ->(*) { can?(current_user, :read_merge_request, build.merge_request) } do
expose :iid do |build|
build.merge_request.iid
end
expose :path do |build|
project_merge_request_path(build.merge_request.project,
- build.merge_request)
+ build.merge_request)
end
end
- expose :new_issue_path, if: -> (*) { can?(request.current_user, :create_issue, project) && build.failed? } do |build|
+ expose :new_issue_path, if: ->(*) { can?(request.current_user, :create_issue, project) && build.failed? } do |build|
new_project_issue_path(project, issue: build_failed_issue_options)
end
@@ -68,7 +68,7 @@ class BuildDetailsEntity < JobEntity
raw_project_job_path(project, build)
end
- expose :trigger, if: -> (*) { build.trigger_request } do
+ expose :trigger, if: ->(*) { build.trigger_request } do
expose :trigger_short_token, as: :short_token
expose :trigger_variables, as: :variables, using: TriggerVariableEntity
@@ -83,7 +83,7 @@ class BuildDetailsEntity < JobEntity
project.any_runners?
end
- expose :settings_path, if: -> (*) { can_admin_build? } do |build|
+ expose :settings_path, if: ->(*) { can_admin_build? } do |build|
project_runners_path(project)
end
end
@@ -91,8 +91,8 @@ class BuildDetailsEntity < JobEntity
private
def build_failed_issue_options
- { title: "Job Failed ##{build.id}",
- description: "Job [##{build.id}](#{project_job_url(project, build)}) failed for #{build.sha}:\n" }
+ {title: "Job Failed ##{build.id}",
+ description: "Job [##{build.id}](#{project_job_url(project, build)}) failed for #{build.sha}:\n",}
end
def current_user
diff --git a/app/serializers/build_serializer.rb b/app/serializers/build_serializer.rb
index 0649fdad6a8..8a403fc5901 100644
--- a/app/serializers/build_serializer.rb
+++ b/app/serializers/build_serializer.rb
@@ -4,7 +4,7 @@ class BuildSerializer < BaseSerializer
entity JobEntity
def represent_status(resource)
- data = represent(resource, { only: [:status] })
+ data = represent(resource, {only: [:status]})
data.fetch(:status, {})
end
end
diff --git a/app/serializers/cluster_application_entity.rb b/app/serializers/cluster_application_entity.rb
index 02df1480828..d79a607a98a 100644
--- a/app/serializers/cluster_application_entity.rb
+++ b/app/serializers/cluster_application_entity.rb
@@ -5,8 +5,8 @@ class ClusterApplicationEntity < Grape::Entity
expose :status_name, as: :status
expose :status_reason
expose :version
- expose :external_ip, if: -> (e, _) { e.respond_to?(:external_ip) }
- expose :hostname, if: -> (e, _) { e.respond_to?(:hostname) }
- expose :email, if: -> (e, _) { e.respond_to?(:email) }
- expose :update_available?, as: :update_available, if: -> (e, _) { e.respond_to?(:update_available?) }
+ expose :external_ip, if: ->(e, _) { e.respond_to?(:external_ip) }
+ expose :hostname, if: ->(e, _) { e.respond_to?(:hostname) }
+ expose :email, if: ->(e, _) { e.respond_to?(:email) }
+ expose :update_available?, as: :update_available, if: ->(e, _) { e.respond_to?(:update_available?) }
end
diff --git a/app/serializers/cluster_serializer.rb b/app/serializers/cluster_serializer.rb
index 4bb4d4880d4..8d7de5869f4 100644
--- a/app/serializers/cluster_serializer.rb
+++ b/app/serializers/cluster_serializer.rb
@@ -4,6 +4,6 @@ class ClusterSerializer < BaseSerializer
entity ClusterEntity
def represent_status(resource)
- represent(resource, { only: [:status, :status_reason, :applications] })
+ represent(resource, {only: [:status, :status_reason, :applications]})
end
end
diff --git a/app/serializers/cohort_entity.rb b/app/serializers/cohort_entity.rb
index 3d0213e1038..f3bc4b0f9b7 100644
--- a/app/serializers/cohort_entity.rb
+++ b/app/serializers/cohort_entity.rb
@@ -4,7 +4,7 @@ class CohortEntity < Grape::Entity
include ActionView::Helpers::NumberHelper
expose :registration_month do |cohort|
- cohort[:registration_month].strftime('%b %Y')
+ cohort[:registration_month].strftime("%b %Y")
end
expose :total do |cohort|
diff --git a/app/serializers/commit_entity.rb b/app/serializers/commit_entity.rb
index a94e32478ce..37da95ac8d5 100644
--- a/app/serializers/commit_entity.rb
+++ b/app/serializers/commit_entity.rb
@@ -18,19 +18,19 @@ class CommitEntity < API::Entities::Commit
project_commit_path(request.project, commit, params: options.fetch(:commit_url_params, {}))
end
- expose :description_html, if: { type: :full } do |commit|
+ expose :description_html, if: {type: :full} do |commit|
markdown_field(commit, :description)
end
- expose :title_html, if: { type: :full } do |commit|
+ expose :title_html, if: {type: :full} do |commit|
markdown_field(commit, :title)
end
- expose :signature_html, if: { type: :full } do |commit|
- render('projects/commit/_signature', signature: commit.signature) if commit.has_signature?
+ expose :signature_html, if: {type: :full} do |commit|
+ render("projects/commit/_signature", signature: commit.signature) if commit.has_signature?
end
- expose :pipeline_status_path, if: { type: :full } do |commit, options|
+ expose :pipeline_status_path, if: {type: :full} do |commit, options|
pipeline_ref = options[:pipeline_ref]
pipeline_project = options[:pipeline_project] || commit.project
next unless pipeline_ref && pipeline_project
diff --git a/app/serializers/container_repository_entity.rb b/app/serializers/container_repository_entity.rb
index cc746698a05..460e77f48f1 100644
--- a/app/serializers/container_repository_entity.rb
+++ b/app/serializers/container_repository_entity.rb
@@ -9,13 +9,13 @@ class ContainerRepositoryEntity < Grape::Entity
project_registry_repository_tags_path(project, repository, format: :json)
end
- expose :destroy_path, if: -> (*) { can_destroy? } do |repository|
+ expose :destroy_path, if: ->(*) { can_destroy? } do |repository|
project_container_registry_path(project, repository, format: :json)
end
private
- alias_method :repository, :object
+ alias repository object
def project
request.project
diff --git a/app/serializers/container_tag_entity.rb b/app/serializers/container_tag_entity.rb
index 361c073e22e..ac2a0eb7067 100644
--- a/app/serializers/container_tag_entity.rb
+++ b/app/serializers/container_tag_entity.rb
@@ -5,13 +5,13 @@ class ContainerTagEntity < Grape::Entity
expose :name, :path, :location, :digest, :revision, :short_revision, :total_size, :created_at
- expose :destroy_path, if: -> (*) { can_destroy? } do |tag|
+ expose :destroy_path, if: ->(*) { can_destroy? } do |tag|
project_registry_repository_tag_path(project, tag.repository, tag.name)
end
private
- alias_method :tag, :object
+ alias tag object
def project
request.project
diff --git a/app/serializers/deploy_key_entity.rb b/app/serializers/deploy_key_entity.rb
index 54bf030aba1..e26ed8002c6 100644
--- a/app/serializers/deploy_key_entity.rb
+++ b/app/serializers/deploy_key_entity.rb
@@ -11,8 +11,8 @@ class DeployKeyEntity < Grape::Entity
expose :updated_at
expose :deploy_keys_projects, using: DeployKeysProjectEntity do |deploy_key|
deploy_key.deploy_keys_projects
- .without_project_deleted
- .select { |deploy_key_project| Ability.allowed?(options[:user], :read_project, deploy_key_project.project) }
+ .without_project_deleted
+ .select { |deploy_key_project| Ability.allowed?(options[:user], :read_project, deploy_key_project.project) }
end
expose :can_edit
diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb
index 34ae06278c8..206e70e241d 100644
--- a/app/serializers/deployment_entity.rb
+++ b/app/serializers/deployment_entity.rb
@@ -24,8 +24,8 @@ class DeploymentEntity < Grape::Entity
expose :user, using: UserEntity
expose :commit, using: CommitEntity
expose :deployable, using: JobEntity
- expose :manual_actions, using: JobEntity, if: -> (*) { can_create_deployment? }
- expose :scheduled_actions, using: JobEntity, if: -> (*) { can_create_deployment? }
+ expose :manual_actions, using: JobEntity, if: ->(*) { can_create_deployment? }
+ expose :scheduled_actions, using: JobEntity, if: ->(*) { can_create_deployment? }
private
diff --git a/app/serializers/detailed_status_entity.rb b/app/serializers/detailed_status_entity.rb
index da994d78286..5fc46623d2c 100644
--- a/app/serializers/detailed_status_entity.rb
+++ b/app/serializers/detailed_status_entity.rb
@@ -9,23 +9,21 @@ class DetailedStatusEntity < Grape::Entity
expose :details_path
expose :illustration do |status|
- begin
- illustration = {
- image: ActionController::Base.helpers.image_path(status.illustration[:image])
- }
- illustration = status.illustration.merge(illustration)
+ illustration = {
+ image: ActionController::Base.helpers.image_path(status.illustration[:image]),
+ }
+ illustration = status.illustration.merge(illustration)
- illustration
- rescue NotImplementedError
- # ignored
- end
+ illustration
+ rescue NotImplementedError
+ # ignored
end
expose :favicon do |status|
Gitlab::Favicon.status_overlay(status.favicon)
end
- expose :action, if: -> (status, _) { status.has_action? } do
+ expose :action, if: ->(status, _) { status.has_action? } do
expose :action_icon, as: :icon
expose :action_title, as: :title
expose :action_path, as: :path
diff --git a/app/serializers/diff_file_base_entity.rb b/app/serializers/diff_file_base_entity.rb
index d8630165e49..a5147c1a860 100644
--- a/app/serializers/diff_file_base_entity.rb
+++ b/app/serializers/diff_file_base_entity.rb
@@ -20,10 +20,10 @@ class DiffFileBaseEntity < Grape::Entity
memoized_submodule_links(diff_file).last
end
- expose :edit_path, if: -> (_, options) { options[:merge_request] } do |diff_file|
+ expose :edit_path, if: ->(_, options) { options[:merge_request] } do |diff_file|
merge_request = options[:merge_request]
- options = merge_request.persisted? ? { from_merge_request_iid: merge_request.iid } : {}
+ options = merge_request.persisted? ? {from_merge_request_iid: merge_request.iid} : {}
next unless merge_request.source_project
@@ -46,11 +46,11 @@ class DiffFileBaseEntity < Grape::Entity
new_path
end
- expose :formatted_external_url, if: -> (_, options) { options[:environment] } do |diff_file|
+ expose :formatted_external_url, if: ->(_, options) { options[:environment] } do |diff_file|
options[:environment].formatted_external_url
end
- expose :external_url, if: -> (_, options) { options[:environment] } do |diff_file|
+ expose :external_url, if: ->(_, options) { options[:environment] } do |diff_file|
options[:environment].external_url_for(diff_file.new_path, diff_file.content_sha)
end
diff --git a/app/serializers/diff_file_entity.rb b/app/serializers/diff_file_entity.rb
index 01ee7af37ed..6db66fef022 100644
--- a/app/serializers/diff_file_entity.rb
+++ b/app/serializers/diff_file_entity.rb
@@ -7,7 +7,7 @@ class DiffFileEntity < DiffFileBaseEntity
expose :added_lines
expose :removed_lines
- expose :load_collapsed_diff_url, if: -> (diff_file, options) { diff_file.viewer.collapsed? && options[:merge_request] } do |diff_file|
+ expose :load_collapsed_diff_url, if: ->(diff_file, options) { diff_file.viewer.collapsed? && options[:merge_request] } do |diff_file|
merge_request = options[:merge_request]
project = merge_request.target_project
@@ -23,7 +23,7 @@ class DiffFileEntity < DiffFileBaseEntity
)
end
- expose :view_path, if: -> (_, options) { options[:merge_request] } do |diff_file|
+ expose :view_path, if: ->(_, options) { options[:merge_request] } do |diff_file|
merge_request = options[:merge_request]
project = merge_request.target_project
@@ -34,8 +34,8 @@ class DiffFileEntity < DiffFileBaseEntity
project_blob_path(project, tree_join(diff_file.content_sha, diff_file.new_path))
end
- expose :replaced_view_path, if: -> (_, options) { options[:merge_request] } do |diff_file|
- image_diff = diff_file.rich_viewer && diff_file.rich_viewer.partial_name == 'image'
+ expose :replaced_view_path, if: ->(_, options) { options[:merge_request] } do |diff_file|
+ image_diff = diff_file.rich_viewer && diff_file.rich_viewer.partial_name == "image"
image_replaced = diff_file.old_content_sha && diff_file.old_content_sha != diff_file.content_sha
merge_request = options[:merge_request]
@@ -46,17 +46,17 @@ class DiffFileEntity < DiffFileBaseEntity
project_blob_path(project, tree_join(diff_file.old_content_sha, diff_file.old_path)) if image_diff && image_replaced
end
- expose :context_lines_path, if: -> (diff_file, _) { diff_file.text? } do |diff_file|
+ expose :context_lines_path, if: ->(diff_file, _) { diff_file.text? } do |diff_file|
next unless diff_file.content_sha
project_blob_diff_path(diff_file.repository.project, tree_join(diff_file.content_sha, diff_file.file_path))
end
# Used for inline diffs
- expose :highlighted_diff_lines, using: DiffLineEntity, if: -> (diff_file, _) { diff_file.text? } do |diff_file|
+ expose :highlighted_diff_lines, using: DiffLineEntity, if: ->(diff_file, _) { diff_file.text? } do |diff_file|
diff_file.diff_lines_for_serializer
end
# Used for parallel diffs
- expose :parallel_diff_lines, using: DiffLineParallelEntity, if: -> (diff_file, _) { diff_file.text? }
+ expose :parallel_diff_lines, using: DiffLineParallelEntity, if: ->(diff_file, _) { diff_file.text? }
end
diff --git a/app/serializers/diffs_entity.rb b/app/serializers/diffs_entity.rb
index b51e4a7e6d0..8249615c633 100644
--- a/app/serializers/diffs_entity.rb
+++ b/app/serializers/diffs_entity.rb
@@ -18,7 +18,7 @@ class DiffsEntity < Grape::Entity
expose :commit do |diffs, options|
CommitEntity.represent options[:commit], options.merge(
type: :full,
- commit_url_params: { merge_request_iid: merge_request&.iid },
+ commit_url_params: {merge_request_iid: merge_request&.iid},
pipeline_ref: merge_request&.source_branch,
pipeline_project: merge_request&.source_project
)
@@ -36,7 +36,7 @@ class DiffsEntity < Grape::Entity
options[:latest_diff]
end
- expose :latest_version_path, if: -> (*) { merge_request } do |diffs|
+ expose :latest_version_path, if: ->(*) { merge_request } do |diffs|
diffs_project_merge_request_path(merge_request&.project, merge_request)
end
@@ -56,17 +56,17 @@ class DiffsEntity < Grape::Entity
render_overflow_warning?(diffs.diff_files)
end
- expose :email_patch_path, if: -> (*) { merge_request } do |diffs|
+ expose :email_patch_path, if: ->(*) { merge_request } do |diffs|
merge_request_path(merge_request, format: :patch)
end
- expose :plain_diff_path, if: -> (*) { merge_request } do |diffs|
+ expose :plain_diff_path, if: ->(*) { merge_request } do |diffs|
merge_request_path(merge_request, format: :diff)
end
expose :diff_files, using: DiffFileEntity
- expose :merge_request_diffs, using: MergeRequestDiffEntity, if: -> (_, options) { options[:merge_request_diffs]&.any? } do |diffs|
+ expose :merge_request_diffs, using: MergeRequestDiffEntity, if: ->(_, options) { options[:merge_request_diffs]&.any? } do |diffs|
options[:merge_request_diffs]
end
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb
index b2d9d52bd22..384dab7f080 100644
--- a/app/serializers/discussion_entity.rb
+++ b/app/serializers/discussion_entity.rb
@@ -5,11 +5,11 @@ class DiscussionEntity < Grape::Entity
include NotesHelper
expose :id, :reply_id
- expose :position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
- expose :original_position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
- expose :line_code, if: -> (d, _) { d.diff_discussion? }
+ expose :position, if: ->(d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
+ expose :original_position, if: ->(d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
+ expose :line_code, if: ->(d, _) { d.diff_discussion? }
expose :expanded?, as: :expanded
- expose :active?, as: :active, if: -> (d, _) { d.diff_discussion? }
+ expose :active?, as: :active, if: ->(d, _) { d.diff_discussion? }
expose :project_id
expose :notes do |discussion, opts|
@@ -29,22 +29,22 @@ class DiscussionEntity < Grape::Entity
expose :resolved_by_push?, as: :resolved_by_push
expose :resolved_by, using: NoteUserEntity
expose :resolved_at
- expose :resolve_path, if: -> (d, _) { d.resolvable? } do |discussion|
+ expose :resolve_path, if: ->(d, _) { d.resolvable? } do |discussion|
resolve_project_merge_request_discussion_path(discussion.project, discussion.noteable, discussion.id)
end
- expose :resolve_with_issue_path, if: -> (d, _) { d.resolvable? } do |discussion|
+ expose :resolve_with_issue_path, if: ->(d, _) { d.resolvable? } do |discussion|
new_project_issue_path(discussion.project, merge_request_to_resolve_discussions_of: discussion.noteable.iid, discussion_to_resolve: discussion.id)
end
- expose :diff_file, using: DiscussionDiffFileEntity, if: -> (d, _) { d.diff_discussion? }
+ expose :diff_file, using: DiscussionDiffFileEntity, if: ->(d, _) { d.diff_discussion? }
expose :diff_discussion?, as: :diff_discussion
- expose :truncated_diff_lines_path, if: -> (d, _) { !d.expanded? && !render_truncated_diff_lines? } do |discussion|
+ expose :truncated_diff_lines_path, if: ->(d, _) { !d.expanded? && !render_truncated_diff_lines? } do |discussion|
project_merge_request_discussion_path(discussion.project, discussion.noteable, discussion)
end
- expose :truncated_diff_lines, using: DiffLineEntity, if: -> (d, _) { d.diff_discussion? && d.on_text? && (d.expanded? || render_truncated_diff_lines?) }
+ expose :truncated_diff_lines, using: DiffLineEntity, if: ->(d, _) { d.diff_discussion? && d.on_text? && (d.expanded? || render_truncated_diff_lines?) }
expose :for_commit?, as: :for_commit
expose :commit_id
diff --git a/app/serializers/entity_date_helper.rb b/app/serializers/entity_date_helper.rb
index f515abe5917..547df5e00d9 100644
--- a/app/serializers/entity_date_helper.rb
+++ b/app/serializers/entity_date_helper.rb
@@ -5,9 +5,9 @@ module EntityDateHelper
include ActionView::Helpers::TagHelper
def interval_in_words(diff)
- return 'Not started' unless diff
+ return "Not started" unless diff
- distance_of_time_in_words(Time.now, diff, scope: 'datetime.time_ago_in_words')
+ distance_of_time_in_words(Time.now, diff, scope: "datetime.time_ago_in_words")
end
# Converts seconds into a hash such as:
@@ -19,7 +19,7 @@ module EntityDateHelper
def distance_of_time_as_hash(diff)
diff = diff.abs.floor
- return { seconds: 0 } if diff == 0
+ return {seconds: 0} if diff == 0
mins = (diff / 60).floor
seconds = diff % 60
@@ -46,9 +46,9 @@ module EntityDateHelper
# If start date is provided and elapsed, with no due date, it returns "# days elapsed"
def remaining_days_in_words(due_date, start_date = nil)
if due_date&.past?
- content_tag(:strong, 'Past due')
+ content_tag(:strong, "Past due")
elsif start_date&.future?
- content_tag(:strong, 'Upcoming')
+ content_tag(:strong, "Upcoming")
elsif due_date
is_upcoming = (due_date - Date.today).to_i > 0
time_ago = time_ago_in_words(due_date)
@@ -65,7 +65,7 @@ module EntityDateHelper
"#{content} #{remaining_or_ago}".html_safe
elsif start_date&.past?
days = (Date.today - start_date).to_i
- "#{content_tag(:strong, days)} #{'day'.pluralize(days)} elapsed".html_safe
+ "#{content_tag(:strong, days)} #{"day".pluralize(days)} elapsed".html_safe
end
end
end
diff --git a/app/serializers/environment_entity.rb b/app/serializers/environment_entity.rb
index 76248e6470e..469e2c9fe82 100644
--- a/app/serializers/environment_entity.rb
+++ b/app/serializers/environment_entity.rb
@@ -12,7 +12,7 @@ class EnvironmentEntity < Grape::Entity
expose :last_deployment, using: DeploymentEntity
expose :stop_action_available?, as: :has_stop_action
- expose :metrics_path, if: -> (environment, _) { environment.has_metrics? } do |environment|
+ expose :metrics_path, if: ->(environment, _) { environment.has_metrics? } do |environment|
metrics_project_environment_path(environment.project, environment)
end
@@ -44,7 +44,7 @@ class EnvironmentEntity < Grape::Entity
private
- alias_method :environment, :object
+ alias environment object
def current_user
request.current_user
@@ -55,7 +55,7 @@ class EnvironmentEntity < Grape::Entity
end
def cluster_platform_kubernetes?
- deployment_platform && deployment_platform.is_a?(Clusters::Platforms::Kubernetes)
+ deployment_platform&.is_a?(Clusters::Platforms::Kubernetes)
end
def deployment_platform
diff --git a/app/serializers/environment_serializer.rb b/app/serializers/environment_serializer.rb
index 598ce5f9e4f..216baed6737 100644
--- a/app/serializers/environment_serializer.rb
+++ b/app/serializers/environment_serializer.rb
@@ -18,9 +18,9 @@ class EnvironmentSerializer < BaseSerializer
def represent(resource, opts = {})
if itemized?
itemize(resource).map do |item|
- { name: item.name,
- size: item.size,
- latest: super(item.latest, opts) }
+ {name: item.name,
+ size: item.size,
+ latest: super(item.latest, opts),}
end
else
super(resource, opts)
@@ -31,10 +31,10 @@ class EnvironmentSerializer < BaseSerializer
# rubocop: disable CodeReuse/ActiveRecord
def itemize(resource)
- items = resource.order('folder ASC')
- .group('COALESCE(environment_type, name)')
- .select('COALESCE(environment_type, name) AS folder',
- 'COUNT(*) AS size', 'MAX(id) AS last_id')
+ items = resource.order("folder ASC")
+ .group("COALESCE(environment_type, name)")
+ .select("COALESCE(environment_type, name) AS folder",
+ "COUNT(*) AS size", "MAX(id) AS last_id")
# It makes a difference when you call `paginate` method, because
# although `page` is effective at the end, it calls counting methods
diff --git a/app/serializers/group_child_entity.rb b/app/serializers/group_child_entity.rb
index 20d7032c970..ae44a8a77a8 100644
--- a/app/serializers/group_child_entity.rb
+++ b/app/serializers/group_child_entity.rb
@@ -6,7 +6,7 @@ class GroupChildEntity < Grape::Entity
include MarkupHelper
expose :id, :name, :description, :visibility, :full_name,
- :created_at, :updated_at, :avatar_url
+ :created_at, :updated_at, :avatar_url
expose :type do |instance|
type
@@ -34,11 +34,11 @@ class GroupChildEntity < Grape::Entity
# Project only attributes
expose :star_count, :archived,
- if: lambda { |_instance, _options| project? }
+ if: lambda { |_instance, _options| project? }
# Group only attributes
expose :children_count, :parent_id, :project_count, :subgroup_count,
- unless: lambda { |_instance, _options| project? }
+ unless: lambda { |_instance, _options| project? }
expose :leave_path, unless: lambda { |_instance, _options| project? } do |instance|
leave_group_members_path(instance)
diff --git a/app/serializers/issue_board_entity.rb b/app/serializers/issue_board_entity.rb
index f7719447b92..d00d71a6e98 100644
--- a/app/serializers/issue_board_entity.rb
+++ b/app/serializers/issue_board_entity.rb
@@ -28,23 +28,23 @@ class IssueBoardEntity < Grape::Entity
LabelEntity.represent issue.labels, project: issue.project, only: [:id, :title, :description, :color, :priority, :text_color]
end
- expose :reference_path, if: -> (issue) { issue.project } do |issue, options|
+ expose :reference_path, if: ->(issue) { issue.project } do |issue, options|
options[:include_full_project_path] ? issue.to_reference(full: true) : issue.to_reference
end
- expose :real_path, if: -> (issue) { issue.project } do |issue|
+ expose :real_path, if: ->(issue) { issue.project } do |issue|
project_issue_path(issue.project, issue)
end
- expose :issue_sidebar_endpoint, if: -> (issue) { issue.project } do |issue|
- project_issue_path(issue.project, issue, format: :json, serializer: 'sidebar_extras')
+ expose :issue_sidebar_endpoint, if: ->(issue) { issue.project } do |issue|
+ project_issue_path(issue.project, issue, format: :json, serializer: "sidebar_extras")
end
- expose :toggle_subscription_endpoint, if: -> (issue) { issue.project } do |issue|
+ expose :toggle_subscription_endpoint, if: ->(issue) { issue.project } do |issue|
toggle_subscription_project_issue_path(issue.project, issue)
end
- expose :assignable_labels_endpoint, if: -> (issue) { issue.project } do |issue|
+ expose :assignable_labels_endpoint, if: ->(issue) { issue.project } do |issue|
project_labels_path(issue.project, format: :json, include_ancestor_groups: true)
end
end
diff --git a/app/serializers/issue_entity.rb b/app/serializers/issue_entity.rb
index c3f7d4651fb..7825398b575 100644
--- a/app/serializers/issue_entity.rb
+++ b/app/serializers/issue_entity.rb
@@ -38,10 +38,10 @@ class IssueEntity < IssuableEntity
end
expose :create_note_path do |issue|
- project_notes_path(issue.project, target_type: 'issue', target_id: issue.id)
+ project_notes_path(issue.project, target_type: "issue", target_id: issue.id)
end
expose :preview_note_path do |issue|
- preview_markdown_path(issue.project, quick_actions_target_type: 'Issue', quick_actions_target_id: issue.iid)
+ preview_markdown_path(issue.project, quick_actions_target_type: "Issue", quick_actions_target_id: issue.iid)
end
end
diff --git a/app/serializers/issue_serializer.rb b/app/serializers/issue_serializer.rb
index 0fa76f098cd..a57599f895d 100644
--- a/app/serializers/issue_serializer.rb
+++ b/app/serializers/issue_serializer.rb
@@ -7,11 +7,11 @@ class IssueSerializer < BaseSerializer
def represent(issue, opts = {})
entity =
case opts[:serializer]
- when 'sidebar'
+ when "sidebar"
IssueSidebarBasicEntity
- when 'sidebar_extras'
+ when "sidebar_extras"
IssueSidebarExtrasEntity
- when 'board'
+ when "board"
IssueBoardEntity
else
IssueEntity
diff --git a/app/serializers/job_entity.rb b/app/serializers/job_entity.rb
index d0099ae77f2..7ea04167a4c 100644
--- a/app/serializers/job_entity.rb
+++ b/app/serializers/job_entity.rb
@@ -13,38 +13,38 @@ class JobEntity < Grape::Entity
build_path(build)
end
- expose :retry_path, if: -> (*) { retryable? } do |build|
+ expose :retry_path, if: ->(*) { retryable? } do |build|
path_to(:retry_namespace_project_job, build)
end
- expose :cancel_path, if: -> (*) { cancelable? } do |build|
+ expose :cancel_path, if: ->(*) { cancelable? } do |build|
path_to(
:cancel_namespace_project_job,
build,
- { continue: { to: build_path(build) } }
+ {continue: {to: build_path(build)}}
)
end
- expose :play_path, if: -> (*) { playable? } do |build|
+ expose :play_path, if: ->(*) { playable? } do |build|
path_to(:play_namespace_project_job, build)
end
- expose :unschedule_path, if: -> (*) { scheduled? } do |build|
+ expose :unschedule_path, if: ->(*) { scheduled? } do |build|
path_to(:unschedule_namespace_project_job, build)
end
expose :playable?, as: :playable
expose :scheduled?, as: :scheduled
- expose :scheduled_at, if: -> (*) { scheduled? }
+ expose :scheduled_at, if: ->(*) { scheduled? }
expose :created_at
expose :updated_at
expose :detailed_status, as: :status, with: DetailedStatusEntity
- expose :callout_message, if: -> (*) { failed? && !build.script_failure? }
- expose :recoverable, if: -> (*) { failed? }
+ expose :callout_message, if: ->(*) { failed? && !build.script_failure? }
+ expose :recoverable, if: ->(*) { failed? }
private
- alias_method :build, :object
+ alias build object
def cancelable?
build.cancelable? && can?(request.current_user, :update_build, build)
diff --git a/app/serializers/job_group_entity.rb b/app/serializers/job_group_entity.rb
index 0db7624b3f7..90a488b5d5d 100644
--- a/app/serializers/job_group_entity.rb
+++ b/app/serializers/job_group_entity.rb
@@ -10,7 +10,7 @@ class JobGroupEntity < Grape::Entity
private
- alias_method :group, :object
+ alias group object
def detailed_status
group.detailed_status(request.current_user)
diff --git a/app/serializers/label_entity.rb b/app/serializers/label_entity.rb
index 5082245dda9..5905a785e57 100644
--- a/app/serializers/label_entity.rb
+++ b/app/serializers/label_entity.rb
@@ -13,7 +13,7 @@ class LabelEntity < Grape::Entity
expose :created_at
expose :updated_at
- expose :priority, if: -> (*) { options.key?(:project) } do |label|
+ expose :priority, if: ->(*) { options.key?(:project) } do |label|
label.priority(options[:project])
end
end
diff --git a/app/serializers/label_serializer.rb b/app/serializers/label_serializer.rb
index 25b9f7de243..ac2b52433e8 100644
--- a/app/serializers/label_serializer.rb
+++ b/app/serializers/label_serializer.rb
@@ -4,6 +4,6 @@ class LabelSerializer < BaseSerializer
entity LabelEntity
def represent_appearance(resource)
- represent(resource, { only: [:id, :title, :color, :text_color] })
+ represent(resource, {only: [:id, :title, :color, :text_color]})
end
end
diff --git a/app/serializers/lfs_file_lock_entity.rb b/app/serializers/lfs_file_lock_entity.rb
index 7961c4e666b..3aa6c120b86 100644
--- a/app/serializers/lfs_file_lock_entity.rb
+++ b/app/serializers/lfs_file_lock_entity.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class LfsFileLockEntity < Grape::Entity
- root 'locks', 'lock'
+ root "locks", "lock"
expose :path
expose(:id) { |entity| entity.id.to_s }
diff --git a/app/serializers/merge_request_serializer.rb b/app/serializers/merge_request_serializer.rb
index 4cf84336aa4..a8dbf69ceb4 100644
--- a/app/serializers/merge_request_serializer.rb
+++ b/app/serializers/merge_request_serializer.rb
@@ -7,11 +7,11 @@ class MergeRequestSerializer < BaseSerializer
def represent(merge_request, opts = {})
entity =
case opts[:serializer]
- when 'sidebar'
+ when "sidebar"
MergeRequestSidebarBasicEntity
- when 'sidebar_extras'
+ when "sidebar_extras"
IssuableSidebarExtrasEntity
- when 'basic'
+ when "basic"
MergeRequestBasicEntity
else
# fallback to widget for old poll requests without `serializer` set
diff --git a/app/serializers/merge_request_user_entity.rb b/app/serializers/merge_request_user_entity.rb
index 53257b0602c..95168f53998 100644
--- a/app/serializers/merge_request_user_entity.rb
+++ b/app/serializers/merge_request_user_entity.rb
@@ -13,7 +13,7 @@ class MergeRequestUserEntity < CurrentUserEntity
project && can?(user, :create_merge_request_in, project)
end
- expose :fork_path, if: -> (*) { project } do |user|
+ expose :fork_path, if: ->(*) { project } do |user|
params = edit_blob_fork_params("Edit")
project_forks_path(project, namespace_key: user.namespace.id, continue: params)
end
diff --git a/app/serializers/merge_request_widget_entity.rb b/app/serializers/merge_request_widget_entity.rb
index 2142ceb6122..7f7365dc1a9 100644
--- a/app/serializers/merge_request_widget_entity.rb
+++ b/app/serializers/merge_request_widget_entity.rb
@@ -56,7 +56,7 @@ class MergeRequestWidgetEntity < IssuableEntity
merge_request.diff_head_sha.presence
end
- expose :actual_head_pipeline, with: PipelineDetailsEntity, as: :pipeline, if: -> (mr, _) { presenter(mr).can_read_pipeline? }
+ expose :actual_head_pipeline, with: PipelineDetailsEntity, as: :pipeline, if: ->(mr, _) { presenter(mr).can_read_pipeline? }
expose :merge_pipeline, with: PipelineDetailsEntity, if: ->(mr, _) { mr.merged? && can?(request.current_user, :read_pipeline, mr.target_project)}
@@ -226,7 +226,7 @@ class MergeRequestWidgetEntity < IssuableEntity
end
expose :create_note_path do |merge_request|
- project_notes_path(merge_request.project, target_type: 'merge_request', target_id: merge_request.id)
+ project_notes_path(merge_request.project, target_type: "merge_request", target_id: merge_request.id)
end
expose :commit_change_content_path do |merge_request|
@@ -234,7 +234,7 @@ class MergeRequestWidgetEntity < IssuableEntity
end
expose :preview_note_path do |merge_request|
- preview_markdown_path(merge_request.project, quick_actions_target_type: 'MergeRequest', quick_actions_target_id: merge_request.iid)
+ preview_markdown_path(merge_request.project, quick_actions_target_type: "MergeRequest", quick_actions_target_id: merge_request.iid)
end
expose :merge_commit_path do |merge_request|
diff --git a/app/serializers/note_entity.rb b/app/serializers/note_entity.rb
index 1d3b59eb1b7..b8ea9b86f4a 100644
--- a/app/serializers/note_entity.rb
+++ b/app/serializers/note_entity.rb
@@ -19,8 +19,8 @@ class NoteEntity < API::Entities::Note
expose :redacted_note_html, as: :note_html
- expose :last_edited_at, if: -> (note, _) { note.edited? }
- expose :last_edited_by, using: NoteUserEntity, if: -> (note, _) { note.edited? }
+ expose :last_edited_at, if: ->(note, _) { note.edited? }
+ expose :last_edited_by, using: NoteUserEntity, if: ->(note, _) { note.edited? }
expose :current_user do
expose :can_edit do |note|
@@ -42,7 +42,7 @@ class NoteEntity < API::Entities::Note
expose :resolved_by, using: NoteUserEntity
- expose :system_note_icon_name, if: -> (note, _) { note.system? } do |note|
+ expose :system_note_icon_name, if: ->(note, _) { note.system? } do |note|
SystemNoteHelper.system_note_icon_name(note)
end
@@ -51,9 +51,9 @@ class NoteEntity < API::Entities::Note
end
expose :emoji_awardable?, as: :emoji_awardable
- expose :award_emoji, if: -> (note, _) { note.emoji_awardable? }, using: AwardEmojiEntity
+ expose :award_emoji, if: ->(note, _) { note.emoji_awardable? }, using: AwardEmojiEntity
- expose :report_abuse_path, if: -> (note, _) { note.author_id } do |note|
+ expose :report_abuse_path, if: ->(note, _) { note.author_id } do |note|
new_abuse_report_path(user_id: note.author_id, ref_url: Gitlab::UrlBuilder.build(note))
end
@@ -61,15 +61,15 @@ class NoteEntity < API::Entities::Note
noteable_note_url(note)
end
- expose :resolve_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
+ expose :resolve_path, if: ->(note, _) { note.part_of_discussion? && note.resolvable? } do |note|
resolve_project_merge_request_discussion_path(note.project, note.noteable, note.discussion_id)
end
- expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
+ expose :resolve_with_issue_path, if: ->(note, _) { note.part_of_discussion? && note.resolvable? } do |note|
new_project_issue_path(note.project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id)
end
- expose :attachment, using: NoteAttachmentEntity, if: -> (note, _) { note.attachment? }
+ expose :attachment, using: NoteAttachmentEntity, if: ->(note, _) { note.attachment? }
expose :cached_markdown_version
diff --git a/app/serializers/pipeline_entity.rb b/app/serializers/pipeline_entity.rb
index 29b1a6c244b..366bf2abeb5 100644
--- a/app/serializers/pipeline_entity.rb
+++ b/app/serializers/pipeline_entity.rb
@@ -53,23 +53,23 @@ class PipelineEntity < Grape::Entity
end
expose :commit, using: CommitEntity
- expose :yaml_errors, if: -> (pipeline, _) { pipeline.has_yaml_errors? }
+ expose :yaml_errors, if: ->(pipeline, _) { pipeline.has_yaml_errors? }
- expose :failure_reason, if: -> (pipeline, _) { pipeline.failure_reason? } do |pipeline|
+ expose :failure_reason, if: ->(pipeline, _) { pipeline.failure_reason? } do |pipeline|
pipeline.present.failure_reason
end
- expose :retry_path, if: -> (*) { can_retry? } do |pipeline|
+ expose :retry_path, if: ->(*) { can_retry? } do |pipeline|
retry_project_pipeline_path(pipeline.project, pipeline)
end
- expose :cancel_path, if: -> (*) { can_cancel? } do |pipeline|
+ expose :cancel_path, if: ->(*) { can_cancel? } do |pipeline|
cancel_project_pipeline_path(pipeline.project, pipeline)
end
private
- alias_method :pipeline, :object
+ alias pipeline object
def can_retry?
can?(request.current_user, :update_pipeline, pipeline) &&
diff --git a/app/serializers/pipeline_serializer.rb b/app/serializers/pipeline_serializer.rb
index 7451433a841..95c6216f278 100644
--- a/app/serializers/pipeline_serializer.rb
+++ b/app/serializers/pipeline_serializer.rb
@@ -17,11 +17,11 @@ class PipelineSerializer < BaseSerializer
:artifacts,
{
pending_builds: :project,
- project: [:route, { namespace: :route }],
+ project: [:route, {namespace: :route}],
artifacts: {
- project: [:route, { namespace: :route }]
- }
- }
+ project: [:route, {namespace: :route}],
+ },
+ },
])
end
@@ -40,14 +40,14 @@ class PipelineSerializer < BaseSerializer
def represent_status(resource)
return {} unless resource.present?
- data = represent(resource, { only: [{ details: [:status] }] })
+ data = represent(resource, {only: [{details: [:status]}]})
data.dig(:details, :status) || {}
end
def represent_stages(resource)
return {} unless resource.present?
- data = represent(resource, { only: [{ details: [:stages] }], preload: true })
+ data = represent(resource, {only: [{details: [:stages]}], preload: true})
data.dig(:details, :stages) || []
end
end
diff --git a/app/serializers/project_note_entity.rb b/app/serializers/project_note_entity.rb
index f6cdea1d8b5..e40ee02b550 100644
--- a/app/serializers/project_note_entity.rb
+++ b/app/serializers/project_note_entity.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
class ProjectNoteEntity < NoteEntity
- expose :human_access, if: -> (note, _) { note.project.present? } do |note|
+ expose :human_access, if: ->(note, _) { note.project.present? } do |note|
note.project.team.human_max_access(note.author_id)
end
- expose :toggle_award_path, if: -> (note, _) { note.emoji_awardable? } do |note|
+ expose :toggle_award_path, if: ->(note, _) { note.emoji_awardable? } do |note|
toggle_award_emoji_project_note_path(note.project, note.id)
end
- expose :path, if: -> (note, _) { note.id } do |note|
+ expose :path, if: ->(note, _) { note.id } do |note|
project_note_path(note.project, note)
end
- expose :resolve_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
+ expose :resolve_path, if: ->(note, _) { note.part_of_discussion? && note.resolvable? } do |note|
resolve_project_merge_request_discussion_path(note.project, note.noteable, note.discussion_id)
end
- expose :resolve_with_issue_path, if: -> (note, _) { note.part_of_discussion? && note.resolvable? } do |note|
+ expose :resolve_with_issue_path, if: ->(note, _) { note.part_of_discussion? && note.resolvable? } do |note|
new_project_issue_path(note.project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id)
end
- expose :delete_attachment_path, if: -> (note, _) { note.attachment? } do |note|
+ expose :delete_attachment_path, if: ->(note, _) { note.attachment? } do |note|
delete_attachment_project_note_path(note.project, note)
end
end
diff --git a/app/serializers/projects/serverless/service_entity.rb b/app/serializers/projects/serverless/service_entity.rb
index c98dc1a1c4a..6ec03e5a22b 100644
--- a/app/serializers/projects/serverless/service_entity.rb
+++ b/app/serializers/projects/serverless/service_entity.rb
@@ -6,59 +6,62 @@ module Projects
include RequestAwareEntity
expose :name do |service|
- service.dig('metadata', 'name')
+ service.dig("metadata", "name")
end
expose :namespace do |service|
- service.dig('metadata', 'namespace')
+ service.dig("metadata", "namespace")
end
expose :environment_scope do |service|
- service.dig('environment_scope')
+ service.dig("environment_scope")
end
expose :cluster_id do |service|
- service.dig('cluster_id')
+ service.dig("cluster_id")
end
expose :detail_url do |service|
project_serverless_path(
request.project,
- service.dig('environment_scope'),
- service.dig('metadata', 'name'))
+ service.dig("environment_scope"),
+ service.dig("metadata", "name")
+ )
end
expose :podcount do |service|
- service.dig('podcount')
+ service.dig("podcount")
end
expose :created_at do |service|
- service.dig('metadata', 'creationTimestamp')
+ service.dig("metadata", "creationTimestamp")
end
expose :url do |service|
- "http://#{service.dig('status', 'domain')}"
+ "http://#{service.dig("status", "domain")}"
end
expose :description do |service|
service.dig(
- 'spec',
- 'runLatest',
- 'configuration',
- 'revisionTemplate',
- 'metadata',
- 'annotations',
- 'Description')
+ "spec",
+ "runLatest",
+ "configuration",
+ "revisionTemplate",
+ "metadata",
+ "annotations",
+ "Description"
+ )
end
expose :image do |service|
service.dig(
- 'spec',
- 'runLatest',
- 'configuration',
- 'build',
- 'template',
- 'name')
+ "spec",
+ "runLatest",
+ "configuration",
+ "build",
+ "template",
+ "name"
+ )
end
end
end
diff --git a/app/serializers/runner_entity.rb b/app/serializers/runner_entity.rb
index 97e5b336a35..71f520c5494 100644
--- a/app/serializers/runner_entity.rb
+++ b/app/serializers/runner_entity.rb
@@ -5,13 +5,13 @@ class RunnerEntity < Grape::Entity
expose :id, :description
- expose :edit_path, if: -> (*) { can_edit_runner? } do |runner|
+ expose :edit_path, if: ->(*) { can_edit_runner? } do |runner|
edit_project_runner_path(project, runner)
end
private
- alias_method :runner, :object
+ alias runner object
def project
request.project
diff --git a/app/serializers/stage_entity.rb b/app/serializers/stage_entity.rb
index 029dd3d0684..116a179578c 100644
--- a/app/serializers/stage_entity.rb
+++ b/app/serializers/stage_entity.rb
@@ -10,18 +10,18 @@ class StageEntity < Grape::Entity
end
expose :groups,
- if: -> (_, opts) { opts[:grouped] },
+ if: ->(_, opts) { opts[:grouped] },
with: JobGroupEntity
expose :latest_statuses,
- if: -> (_, opts) { opts[:details] },
+ if: ->(_, opts) { opts[:details] },
with: JobEntity do |stage|
latest_statuses
end
expose :retried,
- if: -> (_, opts) { opts[:retried] },
- with: JobEntity do |stage|
+ if: ->(_, opts) { opts[:retried] },
+ with: JobEntity do |stage|
retried_statuses
end
@@ -31,7 +31,8 @@ class StageEntity < Grape::Entity
project_pipeline_path(
stage.pipeline.project,
stage.pipeline,
- anchor: stage.name)
+ anchor: stage.name
+ )
end
expose :dropdown_path do |stage|
@@ -39,12 +40,13 @@ class StageEntity < Grape::Entity
stage.pipeline.project,
stage.pipeline,
stage: stage.name,
- format: :json)
+ format: :json
+ )
end
private
- alias_method :stage, :object
+ alias stage object
def detailed_status
stage.detailed_status(request.current_user)
@@ -59,14 +61,14 @@ class StageEntity < Grape::Entity
end
def latest_statuses
- HasStatus::ORDERED_STATUSES.map do |ordered_status|
+ HasStatus::ORDERED_STATUSES.map { |ordered_status|
grouped_statuses.fetch(ordered_status, [])
- end.flatten
+ }.flatten
end
def retried_statuses
- HasStatus::ORDERED_STATUSES.map do |ordered_status|
+ HasStatus::ORDERED_STATUSES.map { |ordered_status|
grouped_retried_statuses.fetch(ordered_status, [])
- end.flatten
+ }.flatten
end
end
diff --git a/app/serializers/submodule_entity.rb b/app/serializers/submodule_entity.rb
index e475a4f301f..6d0ca697772 100644
--- a/app/serializers/submodule_entity.rb
+++ b/app/serializers/submodule_entity.rb
@@ -6,7 +6,7 @@ class SubmoduleEntity < Grape::Entity
expose :id, :path, :name, :mode
expose :icon do |blob|
- 'archive'
+ "archive"
end
expose :url do |blob|
diff --git a/app/services/access_token_validation_service.rb b/app/services/access_token_validation_service.rb
index 40aa9250885..c16b82ef444 100644
--- a/app/services/access_token_validation_service.rb
+++ b/app/services/access_token_validation_service.rb
@@ -17,21 +17,21 @@ class AccessTokenValidationService
def validate(scopes: [])
if token.expired?
- return EXPIRED
+ EXPIRED
elsif token.revoked?
- return REVOKED
+ REVOKED
- elsif !self.include_any_scope?(scopes)
- return INSUFFICIENT_SCOPE
+ elsif !include_any_scope?(scopes)
+ INSUFFICIENT_SCOPE
elsif token.respond_to?(:impersonation) &&
token.impersonation &&
!Gitlab.config.gitlab.impersonation_enabled
- return IMPERSONATION_DISABLED
+ IMPERSONATION_DISABLED
else
- return VALID
+ VALID
end
end
diff --git a/app/services/akismet_service.rb b/app/services/akismet_service.rb
index 82ae66ab0f5..1672be9a3b2 100644
--- a/app/services/akismet_service.rb
+++ b/app/services/akismet_service.rb
@@ -13,12 +13,12 @@ class AkismetService
return false unless akismet_enabled?
params = {
- type: 'comment',
+ type: "comment",
text: text,
created_at: DateTime.now,
author: owner.name,
author_email: owner.email,
- referrer: options[:referrer]
+ referrer: options[:referrer],
}
begin
@@ -42,7 +42,7 @@ class AkismetService
def akismet_client
@akismet_client ||= ::Akismet::Client.new(Gitlab::CurrentSettings.akismet_api_key,
- Gitlab.config.gitlab.url)
+ Gitlab.config.gitlab.url)
end
def akismet_enabled?
@@ -53,10 +53,10 @@ class AkismetService
return false unless akismet_enabled?
params = {
- type: 'comment',
+ type: "comment",
text: text,
author: owner.name,
- author_email: owner.email
+ author_email: owner.email,
}
begin
diff --git a/app/services/audit_event_service.rb b/app/services/audit_event_service.rb
index 201048aaba5..72529cd2ba1 100644
--- a/app/services/audit_event_service.rb
+++ b/app/services/audit_event_service.rb
@@ -9,8 +9,8 @@ class AuditEventService
@details = {
with: @details[:with],
target_id: @author.id,
- target_type: 'User',
- target_details: @author.name
+ target_type: "User",
+ target_details: @author.name,
}
self
@@ -27,7 +27,7 @@ class AuditEventService
{
author_id: @author.id,
entity_id: @entity.id,
- entity_type: @entity.class.name
+ entity_type: @entity.class.name,
}
end
diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb
index e95ba09c006..4a6da870958 100644
--- a/app/services/auth/container_registry_authentication_service.rb
+++ b/app/services/auth/container_registry_authentication_service.rb
@@ -2,18 +2,18 @@
module Auth
class ContainerRegistryAuthenticationService < BaseService
- AUDIENCE = 'container_registry'.freeze
+ AUDIENCE = "container_registry"
def execute(authentication_abilities:)
@authentication_abilities = authentication_abilities
- return error('UNAVAILABLE', status: 404, message: 'registry not enabled') unless registry.enabled
+ return error("UNAVAILABLE", status: 404, message: "registry not enabled") unless registry.enabled
unless scopes.any? || current_user || project
- return error('DENIED', status: 403, message: 'access forbidden')
+ return error("DENIED", status: 403, message: "access forbidden")
end
- { token: authorized_token(*scopes).encoded }
+ {token: authorized_token(*scopes).encoded}
end
def self.full_access_token(*names)
@@ -24,9 +24,9 @@ module Auth
token.audience = AUDIENCE
token.expire_time = token_expire_at
- token[:access] = names.map do |name|
- { type: 'repository', name: name, actions: %w(*) }
- end
+ token[:access] = names.map { |name|
+ {type: "repository", name: name, actions: %w[*]}
+ }
token.encoded
end
@@ -50,19 +50,19 @@ module Auth
def scopes
return [] unless params[:scopes]
- @scopes ||= params[:scopes].map do |scope|
+ @scopes ||= params[:scopes].map { |scope|
process_scope(scope)
- end.compact
+ }.compact
end
def process_scope(scope)
- type, name, actions = scope.split(':', 3)
- actions = actions.split(',')
+ type, name, actions = scope.split(":", 3)
+ actions = actions.split(",")
case type
- when 'registry'
+ when "registry"
process_registry_access(type, name, actions)
- when 'repository'
+ when "repository"
path = ContainerRegistry::Path.new(name)
process_repository_access(type, path, actions)
end
@@ -70,10 +70,10 @@ module Auth
def process_registry_access(type, name, actions)
return unless current_user&.admin?
- return unless name == 'catalog'
- return unless actions == ['*']
+ return unless name == "catalog"
+ return unless actions == ["*"]
- { type: type, name: name, actions: ['*'] }
+ {type: type, name: name, actions: ["*"]}
end
def process_repository_access(type, path, actions)
@@ -83,9 +83,9 @@ module Auth
return unless requested_project
- actions = actions.select do |action|
+ actions = actions.select { |action|
can_access?(requested_project, action)
- end
+ }
return unless actions.present?
@@ -93,7 +93,7 @@ module Auth
#
ensure_container_repository!(path, actions)
- { type: type, name: path.to_s, actions: actions }
+ {type: type, name: path.to_s, actions: actions}
end
##
@@ -103,7 +103,7 @@ module Auth
#
def ensure_container_repository!(path, actions)
return if path.has_repository?
- return unless actions.include?('push')
+ return unless actions.include?("push")
ContainerRepository.create_from_path!(path)
end
@@ -112,11 +112,11 @@ module Auth
return false unless requested_project.container_registry_enabled?
case requested_action
- when 'pull'
+ when "pull"
build_can_pull?(requested_project) || user_can_pull?(requested_project) || deploy_token_can_pull?(requested_project)
- when 'push'
+ when "push"
build_can_push?(requested_project) || user_can_push?(requested_project)
- when '*'
+ when "*"
user_can_admin?(requested_project)
else
false
@@ -174,8 +174,8 @@ module Auth
can_user?(:create_container_image, requested_project)
end
- def error(code, status:, message: '')
- { errors: [{ code: code, message: message }], http_status: status }
+ def error(code, status:, message: "")
+ {errors: [{code: code, message: message}], http_status: status}
end
def has_authentication_ability?(capability)
diff --git a/app/services/base_count_service.rb b/app/services/base_count_service.rb
index ad1647842b8..d3ba3686df1 100644
--- a/app/services/base_count_service.rb
+++ b/app/services/base_count_service.rb
@@ -35,13 +35,13 @@ class BaseCountService
end
def cache_key
- raise NotImplementedError, 'cache_key must be implemented and return a String'
+ raise NotImplementedError, "cache_key must be implemented and return a String"
end
# subclasses can override to add any specific options, such as
# super.merge({ expires_in: 5.minutes })
def cache_options
- { raw: raw? }
+ {raw: raw?}
end
def update_cache_for_key(key, &block)
diff --git a/app/services/base_service.rb b/app/services/base_service.rb
index 3e968c8f707..5fdee88136f 100644
--- a/app/services/base_service.rb
+++ b/app/services/base_service.rb
@@ -49,7 +49,7 @@ class BaseService
def error(message, http_status = nil)
result = {
message: message,
- status: :error
+ status: :error,
}
result[:http_status] = http_status if http_status
diff --git a/app/services/boards/issues/create_service.rb b/app/services/boards/issues/create_service.rb
index bd045e18b8d..c8b3908decc 100644
--- a/app/services/boards/issues/create_service.rb
+++ b/app/services/boards/issues/create_service.rb
@@ -18,7 +18,7 @@ module Boards
private
def issue_params
- { label_ids: [list.label_id] }
+ {label_ids: [list.label_id]}
end
def board
diff --git a/app/services/boards/issues/list_service.rb b/app/services/boards/issues/list_service.rb
index 0b69661bbd0..87bf3f2f5a8 100644
--- a/app/services/boards/issues/list_service.rb
+++ b/app/services/boards/issues/list_service.rb
@@ -12,8 +12,8 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord
def metadata
keys = metadata_fields.keys
- columns = metadata_fields.values_at(*keys).join(', ')
- results = Issue.where(id: fetch_issues.select('issues.id')).pluck(columns)
+ columns = metadata_fields.values_at(*keys).join(", ")
+ results = Issue.where(id: fetch_issues.select("issues.id")).pluck(columns)
Hash[keys.zip(results.flatten)]
end
@@ -22,7 +22,7 @@ module Boards
private
def metadata_fields
- { size: 'COUNT(*)' }
+ {size: "COUNT(*)"}
end
# We memoize the query here since the finder methods we use are quite complex. This does not memoize the result of the query.
@@ -70,7 +70,7 @@ module Boards
end
def set_state
- params[:state] = list && list.closed? ? 'closed' : 'opened'
+ params[:state] = list && list.closed? ? "closed" : "opened"
end
def set_scope
@@ -91,7 +91,7 @@ module Boards
def without_board_labels(issues)
return issues unless board_label_ids.any?
- issues.where.not('EXISTS (?)', issues_label_links.limit(1))
+ issues.where.not("EXISTS (?)", issues_label_links.limit(1))
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -103,7 +103,7 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord
def with_list_label(issues)
- issues.where('EXISTS (?)', LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
+ issues.where("EXISTS (?)", LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1))
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/boards/issues/move_service.rb b/app/services/boards/issues/move_service.rb
index 834baeb9643..9e8413c1ae0 100644
--- a/app/services/boards/issues/move_service.rb
+++ b/app/services/boards/issues/move_service.rb
@@ -57,8 +57,8 @@ module Boards
end
def issue_state
- return 'reopen' if moving_from_list.closed?
- return 'close' if moving_to_list.closed?
+ return "reopen" if moving_from_list.closed?
+ return "close" if moving_to_list.closed?
end
def add_label_ids
diff --git a/app/services/boards/lists/create_service.rb b/app/services/boards/lists/create_service.rb
index 48d2d5abaec..154807a64a8 100644
--- a/app/services/boards/lists/create_service.rb
+++ b/app/services/boards/lists/create_service.rb
@@ -26,10 +26,11 @@ module Boards
end
def available_labels_for(board)
- options = { include_ancestor_groups: true }
+ options = {include_ancestor_groups: true}
if board.group_board?
- options.merge!(group_id: parent.id, only_group_labels: true)
+ options[:group_id] = parent.id
+ options[:only_group_labels] = true
else
options[:project_id] = parent.id
end
@@ -43,7 +44,7 @@ module Boards
end
def create_list(board, type, target, position)
- board.lists.create(type => target, list_type: type, position: position)
+ board.lists.create(type => target, :list_type => type, :position => position)
end
end
end
diff --git a/app/services/boards/lists/destroy_service.rb b/app/services/boards/lists/destroy_service.rb
index e20805d0405..89e02eee2f9 100644
--- a/app/services/boards/lists/destroy_service.rb
+++ b/app/services/boards/lists/destroy_service.rb
@@ -20,8 +20,8 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord
def decrement_higher_lists(list)
- board.lists.movable.where('position > ?', list.position)
- .update_all('position = position - 1')
+ board.lists.movable.where("position > ?", list.position)
+ .update_all("position = position - 1")
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/boards/lists/generate_service.rb b/app/services/boards/lists/generate_service.rb
index 4fbf1026019..8f7cdb384dc 100644
--- a/app/services/boards/lists/generate_service.rb
+++ b/app/services/boards/lists/generate_service.rb
@@ -26,8 +26,8 @@ module Boards
def label_params
[
- { name: 'To Do', color: '#F0AD4E' },
- { name: 'Doing', color: '#5CB85C' }
+ {name: "To Do", color: "#F0AD4E"},
+ {name: "Doing", color: "#5CB85C"},
]
end
end
diff --git a/app/services/boards/lists/move_service.rb b/app/services/boards/lists/move_service.rb
index 93f81837d1a..da3a46d658d 100644
--- a/app/services/boards/lists/move_service.rb
+++ b/app/services/boards/lists/move_service.rb
@@ -36,17 +36,17 @@ module Boards
# rubocop: disable CodeReuse/ActiveRecord
def decrement_intermediate_lists
- board.lists.movable.where('position > ?', old_position)
- .where('position <= ?', new_position)
- .update_all('position = position - 1')
+ board.lists.movable.where("position > ?", old_position)
+ .where("position <= ?", new_position)
+ .update_all("position = position - 1")
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def increment_intermediate_lists
- board.lists.movable.where('position >= ?', new_position)
- .where('position < ?', old_position)
- .update_all('position = position + 1')
+ board.lists.movable.where("position >= ?", new_position)
+ .where("position < ?", old_position)
+ .update_all("position = position + 1")
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/chat_names/authorize_user_service.rb b/app/services/chat_names/authorize_user_service.rb
index 78b53cb3637..c30d3b07630 100644
--- a/app/services/chat_names/authorize_user_service.rb
+++ b/app/services/chat_names/authorize_user_service.rb
@@ -33,7 +33,7 @@ module ChatNames
team_id: @params[:team_id],
team_domain: @params[:team_domain],
chat_id: @params[:user_id],
- chat_name: @params[:user_name]
+ chat_name: @params[:user_name],
}
end
end
diff --git a/app/services/ci/archive_trace_service.rb b/app/services/ci/archive_trace_service.rb
index a1dd00721b5..5bb68ae55b2 100644
--- a/app/services/ci/archive_trace_service.rb
+++ b/app/services/ci/archive_trace_service.rb
@@ -19,7 +19,7 @@ module Ci
def failed_archive_counter
@failed_archive_counter ||=
Gitlab::Metrics.counter(:job_trace_archive_failed_total,
- "Counter of failed attempts of trace archiving")
+ "Counter of failed attempts of trace archiving")
end
def archive_error(error, job)
@@ -28,8 +28,8 @@ module Ci
Gitlab::Sentry
.track_exception(error,
- issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502',
- extra: { job_id: job.id })
+ issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/51502",
+ extra: {job_id: job.id})
end
end
end
diff --git a/app/services/ci/compare_reports_base_service.rb b/app/services/ci/compare_reports_base_service.rb
index d5625857599..7d42f1c0d5a 100644
--- a/app/services/ci/compare_reports_base_service.rb
+++ b/app/services/ci/compare_reports_base_service.rb
@@ -9,13 +9,13 @@ module Ci
key: key(base_pipeline, head_pipeline),
data: serializer_class
.new(project: project)
- .represent(comparer).as_json
+ .represent(comparer).as_json,
}
rescue Gitlab::Ci::Parsers::ParserError => e
{
status: :error,
key: key(base_pipeline, head_pipeline),
- status_reason: e.message
+ status_reason: e.message,
}
end
@@ -28,7 +28,7 @@ module Ci
def key(base_pipeline, head_pipeline)
[
base_pipeline&.id, base_pipeline&.updated_at,
- head_pipeline&.id, head_pipeline&.updated_at
+ head_pipeline&.id, head_pipeline&.updated_at,
]
end
diff --git a/app/services/ci/create_pipeline_service.rb b/app/services/ci/create_pipeline_service.rb
index 8973c5ffc9e..d3d48c45987 100644
--- a/app/services/ci/create_pipeline_service.rb
+++ b/app/services/ci/create_pipeline_service.rb
@@ -15,7 +15,7 @@ module Ci
Gitlab::Ci::Pipeline::Chain::Limit::Size,
Gitlab::Ci::Pipeline::Chain::Populate,
Gitlab::Ci::Pipeline::Chain::Create,
- Gitlab::Ci::Pipeline::Chain::Limit::Activity].freeze
+ Gitlab::Ci::Pipeline::Chain::Limit::Activity,].freeze
def execute(source, ignore_skip_ci: false, save_on_errors: true, trigger_request: nil, schedule: nil, merge_request: nil, **options, &block)
@pipeline = Ci::Pipeline.new
@@ -39,7 +39,8 @@ module Ci
current_user: current_user,
push_options: params[:push_options],
chat_data: params[:chat_data],
- **extra_options(options))
+ **extra_options(options)
+ )
sequence = Gitlab::Ci::Pipeline::Chain::Sequence
.new(pipeline, command, SEQUENCE)
@@ -61,7 +62,7 @@ module Ci
def execute!(*args, &block)
execute(*args, &block).tap do |pipeline|
unless pipeline.persisted?
- raise CreateError, pipeline.errors.full_messages.join(',')
+ raise CreateError, pipeline.errors.full_messages.join(",")
end
end
end
diff --git a/app/services/ci/destroy_expired_job_artifacts_service.rb b/app/services/ci/destroy_expired_job_artifacts_service.rb
index 7d2f5d33fed..1050a4a89dd 100644
--- a/app/services/ci/destroy_expired_job_artifacts_service.rb
+++ b/app/services/ci/destroy_expired_job_artifacts_service.rb
@@ -8,7 +8,7 @@ module Ci
BATCH_SIZE = 100
LOOP_TIMEOUT = 45.minutes
LOOP_LIMIT = 1000
- EXCLUSIVE_LOCK_KEY = 'expired_job_artifacts:destroy:lock'
+ EXCLUSIVE_LOCK_KEY = "expired_job_artifacts:destroy:lock"
LOCK_TIMEOUT = 50.minutes
##
diff --git a/app/services/ci/extract_sections_from_build_trace_service.rb b/app/services/ci/extract_sections_from_build_trace_service.rb
index 97f9918fdb7..b8cefe1df04 100644
--- a/app/services/ci/extract_sections_from_build_trace_service.rb
+++ b/app/services/ci/extract_sections_from_build_trace_service.rb
@@ -27,7 +27,8 @@ module Ci
attr.merge(
build_id: build.id,
project_id: project.id,
- section_name_id: name_record.id)
+ section_name_id: name_record.id
+ )
end
end
end
diff --git a/app/services/ci/pipeline_trigger_service.rb b/app/services/ci/pipeline_trigger_service.rb
index 2dbb7c3917d..114fa3f84b2 100644
--- a/app/services/ci/pipeline_trigger_service.rb
+++ b/app/services/ci/pipeline_trigger_service.rb
@@ -19,10 +19,10 @@ module Ci
return unless trigger.project == project
pipeline = Ci::CreatePipelineService.new(project, trigger.owner, ref: params[:ref])
- .execute(:trigger, ignore_skip_ci: true) do |pipeline|
+ .execute(:trigger, ignore_skip_ci: true) { |pipeline|
pipeline.trigger_requests.build(trigger: trigger)
pipeline.variables.build(variables)
- end
+ }
if pipeline.persisted?
success(pipeline: pipeline)
@@ -47,7 +47,7 @@ module Ci
def variables
params[:variables].to_h.map do |key, value|
- { key: key, value: value }
+ {key: key, value: value}
end
end
end
diff --git a/app/services/ci/process_build_service.rb b/app/services/ci/process_build_service.rb
index d9f8e7cb452..6a437c3a6c2 100644
--- a/app/services/ci/process_build_service.rb
+++ b/app/services/ci/process_build_service.rb
@@ -27,15 +27,15 @@ module Ci
def valid_statuses_for_when(value)
case value
- when 'on_success'
+ when "on_success"
%w[success skipped]
- when 'on_failure'
+ when "on_failure"
%w[failed]
- when 'always'
+ when "always"
%w[success failed skipped]
- when 'manual'
+ when "manual"
%w[success skipped]
- when 'delayed'
+ when "delayed"
%w[success skipped]
else
[]
diff --git a/app/services/ci/process_pipeline_service.rb b/app/services/ci/process_pipeline_service.rb
index 4a7ce00b8e2..f17a8fa974c 100644
--- a/app/services/ci/process_pipeline_service.rb
+++ b/app/services/ci/process_pipeline_service.rb
@@ -10,9 +10,9 @@ module Ci
update_retried
new_builds =
- stage_indexes_of_created_processables.map do |index|
+ stage_indexes_of_created_processables.map { |index|
process_stage(index)
- end
+ }
@pipeline.update_status
@@ -38,13 +38,13 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
def status_for_prior_stages(index)
- pipeline.builds.where('stage_idx < ?', index).latest.status || 'success'
+ pipeline.builds.where("stage_idx < ?", index).latest.status || "success"
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def stage_indexes_of_created_processables
- created_processables.order(:stage_idx).pluck('distinct stage_idx')
+ created_processables.order(:stage_idx).pluck("distinct stage_idx")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -67,14 +67,16 @@ module Ci
# find the latest builds for each name
latest_statuses = pipeline.statuses.latest
.group(:name)
- .having('count(*) > 1')
- .pluck('max(id)', 'name')
+ .having("count(*) > 1")
+ .pluck("max(id)", "name")
# mark builds that are retried
- pipeline.statuses.latest
- .where(name: latest_statuses.map(&:second))
- .where.not(id: latest_statuses.map(&:first))
- .update_all(retried: true) if latest_statuses.any?
+ if latest_statuses.any?
+ pipeline.statuses.latest
+ .where(name: latest_statuses.map(&:second))
+ .where.not(id: latest_statuses.map(&:first))
+ .update_all(retried: true)
+ end
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb
index 6707a1363d0..09a6e9cf7ee 100644
--- a/app/services/ci/register_job_service.rb
+++ b/app/services/ci/register_job_service.rb
@@ -7,7 +7,7 @@ module Ci
attr_reader :runner
JOB_QUEUE_DURATION_SECONDS_BUCKETS = [1, 3, 10, 30].freeze
- JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET = 5.freeze
+ JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET = 5
Result = Struct.new(:build, :valid?)
@@ -95,21 +95,21 @@ module Ci
def builds_for_shared_runner
new_builds.
# don't run projects which have not enabled shared runners and builds
- joins(:project).where(projects: { shared_runners_enabled: true, pending_delete: false })
- .joins('LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id')
- .where('project_features.builds_access_level IS NULL or project_features.builds_access_level > 0').
-
- # Implement fair scheduling
- # this returns builds that are ordered by number of running builds
- # we prefer projects that don't use shared runners at all
- joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.project_id=project_builds.project_id")
- .order('COALESCE(project_builds.running_builds, 0) ASC', 'ci_builds.id ASC')
+ joins(:project).where(projects: {shared_runners_enabled: true, pending_delete: false})
+ .joins("LEFT JOIN project_features ON ci_builds.project_id = project_features.project_id")
+ .where("project_features.builds_access_level IS NULL or project_features.builds_access_level > 0").
+
+ # Implement fair scheduling
+ # this returns builds that are ordered by number of running builds
+ # we prefer projects that don't use shared runners at all
+ joins("LEFT JOIN (#{running_builds_for_shared_runners.to_sql}) AS project_builds ON ci_builds.project_id=project_builds.project_id")
+ .order("COALESCE(project_builds.running_builds, 0) ASC", "ci_builds.id ASC")
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def builds_for_project_runner
- new_builds.where(project: runner.projects.without_deleted.with_builds_enabled).order('id ASC')
+ new_builds.where(project: runner.projects.without_deleted.with_builds_enabled).order("id ASC")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -123,14 +123,14 @@ module Ci
.with_group_runners_enabled
.with_builds_enabled
.without_deleted
- new_builds.where(project: projects).order('id ASC')
+ new_builds.where(project: projects).order("id ASC")
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def running_builds_for_shared_runners
Ci::Build.running.where(runner: Ci::Runner.instance_type)
- .group(:project_id).select(:project_id, 'count(*) AS running_builds')
+ .group(:project_id).select(:project_id, "count(*) AS running_builds")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -146,8 +146,8 @@ module Ci
end
def register_success(job)
- labels = { shared_runner: runner.instance_type?,
- jobs_running_for_project: jobs_running_for_project(job) }
+ labels = {shared_runner: runner.instance_type?,
+ jobs_running_for_project: jobs_running_for_project(job),}
job_queue_duration_seconds.observe(labels, Time.now - job.queued_at) unless job.queued_at.nil?
attempt_counter.increment
@@ -155,11 +155,11 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord
def jobs_running_for_project(job)
- return '+Inf' unless runner.instance_type?
+ return "+Inf" unless runner.instance_type?
# excluding currently started job
running_jobs_count = job.project.builds.running.where(runner: Ci::Runner.instance_type)
- .limit(JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET + 1).count - 1
+ .limit(JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET + 1).count - 1
running_jobs_count < JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET ? running_jobs_count : "#{JOBS_RUNNING_FOR_PROJECT_MAX_BUCKET}+"
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -173,7 +173,7 @@ module Ci
end
def job_queue_duration_seconds
- @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, 'Request handling execution time', {}, JOB_QUEUE_DURATION_SECONDS_BUCKETS)
+ @job_queue_duration_seconds ||= Gitlab::Metrics.histogram(:job_queue_duration_seconds, "Request handling execution time", {}, JOB_QUEUE_DURATION_SECONDS_BUCKETS)
end
end
end
diff --git a/app/services/ci/retry_build_service.rb b/app/services/ci/retry_build_service.rb
index fab8a179843..cfb9def4b22 100644
--- a/app/services/ci/retry_build_service.rb
+++ b/app/services/ci/retry_build_service.rb
@@ -25,9 +25,9 @@ module Ci
raise Gitlab::Access::AccessDeniedError
end
- attributes = CLONE_ACCESSORS.map do |attribute|
+ attributes = CLONE_ACCESSORS.map { |attribute|
[attribute, build.public_send(attribute)] # rubocop:disable GitlabSecurity/PublicSend
- end
+ }
attributes.push([:user, current_user])
diff --git a/app/services/clusters/applications/base_helm_service.rb b/app/services/clusters/applications/base_helm_service.rb
index 8a71730d5ec..f80d95567e2 100644
--- a/app/services/clusters/applications/base_helm_service.rb
+++ b/app/services/clusters/applications/base_helm_service.rb
@@ -19,7 +19,7 @@ module Clusters
app_id: app.id,
project_ids: app.cluster.project_ids,
group_ids: app.cluster.group_ids,
- message: error.message
+ message: error.message,
}
logger.error(meta)
diff --git a/app/services/clusters/applications/check_installation_progress_service.rb b/app/services/clusters/applications/check_installation_progress_service.rb
index c592d608b89..e2d0d28b145 100644
--- a/app/services/clusters/applications/check_installation_progress_service.rb
+++ b/app/services/clusters/applications/check_installation_progress_service.rb
@@ -43,7 +43,8 @@ module Clusters
end
else
ClusterWaitForAppInstallationWorker.perform_in(
- ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
+ ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id
+ )
end
end
diff --git a/app/services/clusters/applications/create_service.rb b/app/services/clusters/applications/create_service.rb
index 12f8c849d41..1a08942288b 100644
--- a/app/services/clusters/applications/create_service.rb
+++ b/app/services/clusters/applications/create_service.rb
@@ -47,9 +47,9 @@ module Clusters
def builders
{
- "helm" => -> (cluster) { cluster.application_helm || cluster.build_application_helm },
- "ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress },
- "cert_manager" => -> (cluster) { cluster.application_cert_manager || cluster.build_application_cert_manager }
+ "helm" => ->(cluster) { cluster.application_helm || cluster.build_application_helm },
+ "ingress" => ->(cluster) { cluster.application_ingress || cluster.build_application_ingress },
+ "cert_manager" => ->(cluster) { cluster.application_cert_manager || cluster.build_application_cert_manager },
}.tap do |hash|
hash.merge!(project_builders) if cluster.project_type?
end
@@ -59,10 +59,10 @@ module Clusters
# with groups of projects
def project_builders
{
- "prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus },
- "runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner },
- "jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter },
- "knative" => -> (cluster) { cluster.application_knative || cluster.build_application_knative }
+ "prometheus" => ->(cluster) { cluster.application_prometheus || cluster.build_application_prometheus },
+ "runner" => ->(cluster) { cluster.application_runner || cluster.build_application_runner },
+ "jupyter" => ->(cluster) { cluster.application_jupyter || cluster.build_application_jupyter },
+ "knative" => ->(cluster) { cluster.application_knative || cluster.build_application_knative },
}
end
@@ -74,8 +74,8 @@ module Clusters
oauth_application_params = {
name: params[:application],
redirect_uri: application.callback_url,
- scopes: 'api read_user openid',
- owner: current_user
+ scopes: "api read_user openid",
+ owner: current_user,
}
::Applications::CreateService.new(current_user, oauth_application_params).execute(request)
diff --git a/app/services/clusters/applications/install_service.rb b/app/services/clusters/applications/install_service.rb
index 5a65dc4ef59..4d555a2e785 100644
--- a/app/services/clusters/applications/install_service.rb
+++ b/app/services/clusters/applications/install_service.rb
@@ -11,11 +11,12 @@ module Clusters
helm_api.install(install_command)
ClusterWaitForAppInstallationWorker.perform_in(
- ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
+ ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id
+ )
rescue Kubeclient::HttpError => e
log_error(e)
app.make_errored!("Kubernetes error: #{e.error_code}")
- rescue StandardError => e
+ rescue => e
log_error(e)
app.make_errored!("Can't start installation process.")
end
diff --git a/app/services/clusters/applications/upgrade_service.rb b/app/services/clusters/applications/upgrade_service.rb
index a0ece1d2635..bdfe86f1451 100644
--- a/app/services/clusters/applications/upgrade_service.rb
+++ b/app/services/clusters/applications/upgrade_service.rb
@@ -14,11 +14,12 @@ module Clusters
helm_api.update(install_command)
ClusterWaitForAppInstallationWorker.perform_in(
- ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
+ ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id
+ )
rescue Kubeclient::HttpError => e
log_error(e)
app.make_update_errored!("Kubernetes error: #{e.error_code}")
- rescue StandardError => e
+ rescue => e
log_error(e)
app.make_update_errored!("Can't start upgrade process.")
end
diff --git a/app/services/clusters/build_service.rb b/app/services/clusters/build_service.rb
index 8de73831164..94a5a368202 100644
--- a/app/services/clusters/build_service.rb
+++ b/app/services/clusters/build_service.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Clusters
class BuildService
def initialize(subject)
diff --git a/app/services/clusters/create_service.rb b/app/services/clusters/create_service.rb
index 5a9da053780..c1142517a9c 100644
--- a/app/services/clusters/create_service.rb
+++ b/app/services/clusters/create_service.rb
@@ -9,8 +9,8 @@ module Clusters
end
def execute(access_token: nil)
- raise ArgumentError, 'Unknown clusterable provided' unless clusterable
- raise ArgumentError, _('Instance does not support multiple Kubernetes clusters') unless can_create_cluster?
+ raise ArgumentError, "Unknown clusterable provided" unless clusterable
+ raise ArgumentError, _("Instance does not support multiple Kubernetes clusters") unless can_create_cluster?
cluster_params = params.merge(user: current_user).merge(clusterable_params)
cluster_params[:provider_gcp_attributes].try do |provider|
@@ -35,9 +35,9 @@ module Clusters
def clusterable_params
case clusterable
when ::Project
- { cluster_type: :project_type, projects: [clusterable] }
+ {cluster_type: :project_type, projects: [clusterable]}
when ::Group
- { cluster_type: :group_type, groups: [clusterable] }
+ {cluster_type: :group_type, groups: [clusterable]}
else
raise NotImplementedError
end
diff --git a/app/services/clusters/gcp/fetch_operation_service.rb b/app/services/clusters/gcp/fetch_operation_service.rb
index 6c648b443a0..29f4d03dd5d 100644
--- a/app/services/clusters/gcp/fetch_operation_service.rb
+++ b/app/services/clusters/gcp/fetch_operation_service.rb
@@ -7,7 +7,8 @@ module Clusters
operation = provider.api_client.projects_zones_operations(
provider.gcp_project_id,
provider.zone,
- provider.operation_id)
+ provider.operation_id
+ )
yield(operation) if block_given?
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
diff --git a/app/services/clusters/gcp/finalize_creation_service.rb b/app/services/clusters/gcp/finalize_creation_service.rb
index 5525c1b9b7f..f977b543218 100644
--- a/app/services/clusters/gcp/finalize_creation_service.rb
+++ b/app/services/clusters/gcp/finalize_creation_service.rb
@@ -14,16 +14,15 @@ module Clusters
cluster.save!
ClusterConfigureWorker.perform_async(cluster.id)
-
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
log_service_error(e.class.name, provider.id, e.message)
- provider.make_errored!(s_('ClusterIntegration|Failed to request to Google Cloud Platform: %{message}') % { message: e.message })
+ provider.make_errored!(s_("ClusterIntegration|Failed to request to Google Cloud Platform: %{message}") % {message: e.message})
rescue Kubeclient::HttpError => e
log_service_error(e.class.name, provider.id, e.message)
- provider.make_errored!(s_('ClusterIntegration|Failed to run Kubeclient: %{message}') % { message: e.message })
+ provider.make_errored!(s_("ClusterIntegration|Failed to run Kubeclient: %{message}") % {message: e.message})
rescue ActiveRecord::RecordInvalid => e
log_service_error(e.class.name, provider.id, e.message)
- provider.make_errored!(s_('ClusterIntegration|Failed to configure Google Kubernetes Engine Cluster: %{message}') % { message: e.message })
+ provider.make_errored!(s_("ClusterIntegration|Failed to configure Google Kubernetes Engine Cluster: %{message}") % {message: e.message})
end
private
@@ -43,12 +42,13 @@ module Clusters
def configure_kubernetes
cluster.platform_type = :kubernetes
cluster.build_platform_kubernetes(
- api_url: 'https://' + gke_cluster.endpoint,
+ api_url: "https://" + gke_cluster.endpoint,
ca_cert: Base64.decode64(gke_cluster.master_auth.cluster_ca_certificate),
username: gke_cluster.master_auth.username,
password: gke_cluster.master_auth.password,
authorization_type: authorization_type,
- token: request_kubernetes_token)
+ token: request_kubernetes_token
+ )
end
def request_kubernetes_token
@@ -60,7 +60,7 @@ module Clusters
end
def authorization_type
- create_rbac_cluster? ? 'rbac' : 'abac'
+ create_rbac_cluster? ? "rbac" : "abac"
end
def create_rbac_cluster?
@@ -69,7 +69,7 @@ module Clusters
def kube_client
@kube_client ||= build_kube_client!(
- 'https://' + gke_cluster.endpoint,
+ "https://" + gke_cluster.endpoint,
Base64.decode64(gke_cluster.master_auth.cluster_ca_certificate),
gke_cluster.master_auth.username,
gke_cluster.master_auth.password
@@ -81,14 +81,14 @@ module Clusters
Gitlab::Kubernetes::KubeClient.new(
api_url,
- auth_options: { username: username, password: password },
+ auth_options: {username: username, password: password},
ssl_options: kubeclient_ssl_options(ca_pem),
- http_proxy_uri: ENV['http_proxy']
+ http_proxy_uri: ENV["http_proxy"]
)
end
def kubeclient_ssl_options(ca_pem)
- opts = { verify_ssl: OpenSSL::SSL::VERIFY_PEER }
+ opts = {verify_ssl: OpenSSL::SSL::VERIFY_PEER}
if ca_pem.present?
opts[:cert_store] = OpenSSL::X509::Store.new
@@ -102,7 +102,8 @@ module Clusters
@gke_cluster ||= provider.api_client.projects_zones_clusters_get(
provider.gcp_project_id,
provider.zone,
- cluster.name)
+ cluster.name
+ )
end
def cluster
diff --git a/app/services/clusters/gcp/kubernetes.rb b/app/services/clusters/gcp/kubernetes.rb
index 90ed529670c..40840c95788 100644
--- a/app/services/clusters/gcp/kubernetes.rb
+++ b/app/services/clusters/gcp/kubernetes.rb
@@ -3,12 +3,12 @@
module Clusters
module Gcp
module Kubernetes
- GITLAB_SERVICE_ACCOUNT_NAME = 'gitlab'
- GITLAB_SERVICE_ACCOUNT_NAMESPACE = 'default'
- GITLAB_ADMIN_TOKEN_NAME = 'gitlab-token'
- GITLAB_CLUSTER_ROLE_BINDING_NAME = 'gitlab-admin'
- GITLAB_CLUSTER_ROLE_NAME = 'cluster-admin'
- PROJECT_CLUSTER_ROLE_NAME = 'edit'
+ GITLAB_SERVICE_ACCOUNT_NAME = "gitlab"
+ GITLAB_SERVICE_ACCOUNT_NAMESPACE = "default"
+ GITLAB_ADMIN_TOKEN_NAME = "gitlab-token"
+ GITLAB_CLUSTER_ROLE_BINDING_NAME = "gitlab-admin"
+ GITLAB_CLUSTER_ROLE_NAME = "cluster-admin"
+ PROJECT_CLUSTER_ROLE_NAME = "edit"
end
end
end
diff --git a/app/services/clusters/gcp/kubernetes/create_or_update_service_account_service.rb b/app/services/clusters/gcp/kubernetes/create_or_update_service_account_service.rb
index 49e766cbf13..1031c338b74 100644
--- a/app/services/clusters/gcp/kubernetes/create_or_update_service_account_service.rb
+++ b/app/services/clusters/gcp/kubernetes/create_or_update_service_account_service.rb
@@ -15,7 +15,7 @@ module Clusters
end
def self.gitlab_creator(kubeclient, rbac:)
- self.new(
+ new(
kubeclient,
service_account_name: Clusters::Gcp::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAME,
service_account_namespace: Clusters::Gcp::Kubernetes::GITLAB_SERVICE_ACCOUNT_NAMESPACE,
@@ -25,7 +25,7 @@ module Clusters
end
def self.namespace_creator(kubeclient, service_account_name:, service_account_namespace:, rbac:)
- self.new(
+ new(
kubeclient,
service_account_name: service_account_name,
service_account_namespace: service_account_namespace,
@@ -79,7 +79,7 @@ module Clusters
end
def cluster_role_binding_resource
- subjects = [{ kind: 'ServiceAccount', name: service_account_name, namespace: service_account_namespace }]
+ subjects = [{kind: "ServiceAccount", name: service_account_name, namespace: service_account_namespace}]
Gitlab::Kubernetes::ClusterRoleBinding.new(
Clusters::Gcp::Kubernetes::GITLAB_CLUSTER_ROLE_BINDING_NAME,
diff --git a/app/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service.rb b/app/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service.rb
index 4ad04ab801e..767e6abc594 100644
--- a/app/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service.rb
+++ b/app/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service.rb
@@ -13,7 +13,7 @@ module Clusters
end
def execute
- token_base64 = get_secret&.dig('data', 'token')
+ token_base64 = get_secret&.dig("data", "token")
Base64.decode64(token_base64) if token_base64
end
diff --git a/app/services/clusters/gcp/provision_service.rb b/app/services/clusters/gcp/provision_service.rb
index 80040511ec2..e907fa2f036 100644
--- a/app/services/clusters/gcp/provision_service.rb
+++ b/app/services/clusters/gcp/provision_service.rb
@@ -12,7 +12,8 @@ module Clusters
if provider.make_creating(operation_id)
WaitForClusterCreationWorker.perform_in(
Clusters::Gcp::VerifyProvisionStatusService::INITIAL_INTERVAL,
- provider.cluster_id)
+ provider.cluster_id
+ )
else
provider.make_errored!("Failed to update provider record; #{provider.errors}")
end
@@ -31,18 +32,17 @@ module Clusters
legacy_abac: provider.legacy_abac
)
- unless operation.status == 'PENDING' || operation.status == 'RUNNING'
+ unless operation.status == "PENDING" || operation.status == "RUNNING"
return provider.make_errored!("Operation status is unexpected; #{operation.status_message}")
end
operation_id = provider.api_client.parse_operation_id(operation.self_link)
unless operation_id
- return provider.make_errored!('Can not find operation_id from self_link')
+ return provider.make_errored!("Can not find operation_id from self_link")
end
yield(operation_id)
-
rescue Google::Apis::ServerError, Google::Apis::ClientError, Google::Apis::AuthorizationError => e
provider.make_errored!("Failed to request to CloudPlatform; #{e.message}")
end
diff --git a/app/services/clusters/gcp/verify_provision_status_service.rb b/app/services/clusters/gcp/verify_provision_status_service.rb
index b24246f5c4b..edb478e3de2 100644
--- a/app/services/clusters/gcp/verify_provision_status_service.rb
+++ b/app/services/clusters/gcp/verify_provision_status_service.rb
@@ -14,9 +14,9 @@ module Clusters
request_operation do |operation|
case operation.status
- when 'PENDING', 'RUNNING'
+ when "PENDING", "RUNNING"
continue_creation(operation)
- when 'DONE'
+ when "DONE"
finalize_creation
else
provider.make_errored!("Unexpected operation status; #{operation.status} #{operation.status_message}")
@@ -30,7 +30,7 @@ module Clusters
if elapsed_time_from_creation(operation) < TIMEOUT
WaitForClusterCreationWorker.perform_in(EAGER_INTERVAL, provider.cluster_id)
else
- provider.make_errored!(_('Kubernetes cluster creation time exceeds timeout; %{timeout}') % { timeout: TIMEOUT })
+ provider.make_errored!(_("Kubernetes cluster creation time exceeds timeout; %{timeout}") % {timeout: TIMEOUT})
end
end
diff --git a/app/services/cohorts_service.rb b/app/services/cohorts_service.rb
index 6d466c2fc9c..08970fc9fe9 100644
--- a/app/services/cohorts_service.rb
+++ b/app/services/cohorts_service.rb
@@ -6,7 +6,7 @@ class CohortsService
def execute
{
months_included: MONTHS_INCLUDED,
- cohorts: cohorts
+ cohorts: cohorts,
}
end
@@ -40,7 +40,7 @@ class CohortsService
registration_month: registration_month,
activity_months: activity_months,
total: activity_months.first[:total],
- inactive: inactive
+ inactive: inactive,
}
end
end
@@ -63,7 +63,7 @@ class CohortsService
overall_total = month_totals.first
month_totals.map do |total|
- { total: total, percentage: total.zero? ? 0 : 100 * total / overall_total }
+ {total: total, percentage: total.zero? ? 0 : 100 * total / overall_total}
end
end
@@ -82,11 +82,11 @@ class CohortsService
def counts_by_month
@counts_by_month ||=
begin
- created_at_month = column_to_date('created_at')
- last_activity_on_month = column_to_date('last_activity_on')
+ created_at_month = column_to_date("created_at")
+ last_activity_on_month = column_to_date("last_activity_on")
User
- .where('created_at > ?', MONTHS_INCLUDED.months.ago.end_of_month)
+ .where("created_at > ?", MONTHS_INCLUDED.months.ago.end_of_month)
.group(created_at_month, last_activity_on_month)
.reorder("#{created_at_month} ASC", "#{last_activity_on_month} ASC")
.count
diff --git a/app/services/commits/change_service.rb b/app/services/commits/change_service.rb
index fbf71f02837..92b36ff871b 100644
--- a/app/services/commits/change_service.rb
+++ b/app/services/commits/change_service.rb
@@ -22,7 +22,8 @@ module Commits
@branch_name,
message,
start_project: @start_project,
- start_branch_name: @start_branch)
+ start_branch_name: @start_branch
+ )
rescue Gitlab::Git::Repository::CreateTreeError
act = action.to_s.dasherize
type = @commit.change_type_title(current_user)
diff --git a/app/services/commits/commit_patch_service.rb b/app/services/commits/commit_patch_service.rb
index 49113c3c691..f3348068131 100644
--- a/app/services/commits/commit_patch_service.rb
+++ b/app/services/commits/commit_patch_service.rb
@@ -33,7 +33,7 @@ module Commits
def prepare_branch!
branch_result = CreateBranchService.new(project, current_user)
- .execute(@branch_name, @start_branch)
+ .execute(@branch_name, @start_branch)
if branch_result[:status] != :success
raise ChangeError, branch_result[:message]
diff --git a/app/services/commits/create_service.rb b/app/services/commits/create_service.rb
index a3b87c20761..bc9ca8b38f8 100644
--- a/app/services/commits/create_service.rb
+++ b/app/services/commits/create_service.rb
@@ -60,7 +60,7 @@ module Commits
def validate_on_branch!
if !@start_project.empty_repo? && !@start_project.repository.branch_exists?(@start_branch)
- raise_error('You can only create or edit files when you are on a branch')
+ raise_error("You can only create or edit files when you are on a branch")
end
end
diff --git a/app/services/commits/tag_service.rb b/app/services/commits/tag_service.rb
index bb8cfb63f98..99eda486d53 100644
--- a/app/services/commits/tag_service.rb
+++ b/app/services/commits/tag_service.rb
@@ -4,7 +4,7 @@ module Commits
class TagService < BaseService
def execute(commit)
unless params[:tag_name]
- return error('Missing parameter tag_name')
+ return error("Missing parameter tag_name")
end
tag_name = params[:tag_name]
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 3adf8a0c1a1..ef782e248c4 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
# Compare 2 refs for one repo or between repositories
# and return Gitlab::Git::Compare object that responds to commits and diffs
@@ -18,8 +18,8 @@ class CompareService
return unless raw_compare
Compare.new(raw_compare,
- target_project,
- base_sha: base_sha,
- straight: straight)
+ target_project,
+ base_sha: base_sha,
+ straight: straight)
end
end
diff --git a/app/services/concerns/exclusive_lease_guard.rb b/app/services/concerns/exclusive_lease_guard.rb
index 2cb73555d85..03a5186741d 100644
--- a/app/services/concerns/exclusive_lease_guard.rb
+++ b/app/services/concerns/exclusive_lease_guard.rb
@@ -21,7 +21,7 @@ module ExclusiveLeaseGuard
lease = exclusive_lease.try_obtain
unless lease
- log_error('Cannot obtain an exclusive lease. There must be another instance already in execution.')
+ log_error("Cannot obtain an exclusive lease. There must be another instance already in execution.")
return
end
diff --git a/app/services/concerns/issues/resolve_discussions.rb b/app/services/concerns/issues/resolve_discussions.rb
index f0e9862ca30..2aaf52a8a0d 100644
--- a/app/services/concerns/issues/resolve_discussions.rb
+++ b/app/services/concerns/issues/resolve_discussions.rb
@@ -28,7 +28,7 @@ module Issues
@discussions_to_resolve ||= # rubocop:disable Gitlab/ModuleWithInstanceVariables
if discussion_to_resolve_id
discussion_or_nil = merge_request_to_resolve_discussions_of
- .find_discussion(discussion_to_resolve_id)
+ .find_discussion(discussion_to_resolve_id)
Array(discussion_or_nil)
else
merge_request_to_resolve_discussions_of
diff --git a/app/services/concerns/users/participable_service.rb b/app/services/concerns/users/participable_service.rb
index 6713b6617ae..2565bdc8097 100644
--- a/app/services/concerns/users/participable_service.rb
+++ b/app/services/concerns/users/participable_service.rb
@@ -36,11 +36,11 @@ module Users
private
def user_as_hash(user)
- { type: user.class.name, username: user.username, name: user.name, avatar_url: user.avatar_url }
+ {type: user.class.name, username: user.username, name: user.name, avatar_url: user.avatar_url}
end
def group_as_hash(group)
- { type: group.class.name, username: group.full_path, name: group.full_name, avatar_url: group.avatar_url, count: group.users.count }
+ {type: group.class.name, username: group.full_path, name: group.full_name, avatar_url: group.avatar_url, count: group.users.count}
end
end
end
diff --git a/app/services/create_branch_service.rb b/app/services/create_branch_service.rb
index 110e589e30d..196c38ad9b6 100644
--- a/app/services/create_branch_service.rb
+++ b/app/services/create_branch_service.rb
@@ -14,7 +14,7 @@ class CreateBranchService < BaseService
if new_branch
success(new_branch)
else
- error('Invalid reference name')
+ error("Invalid reference name")
end
rescue Gitlab::Git::PreReceiveError => ex
error(ex.message)
@@ -29,10 +29,10 @@ class CreateBranchService < BaseService
def create_master_branch
project.repository.create_file(
current_user,
- '/README.md',
- '',
- message: 'Add README.md',
- branch_name: 'master'
+ "/README.md",
+ "",
+ message: "Add README.md",
+ branch_name: "master"
)
end
end
diff --git a/app/services/create_snippet_service.rb b/app/services/create_snippet_service.rb
index 6f1fce4989e..bc1164de096 100644
--- a/app/services/create_snippet_service.rb
+++ b/app/services/create_snippet_service.rb
@@ -7,10 +7,10 @@ class CreateSnippetService < BaseService
filter_spam_check_params
snippet = if project
- project.snippets.build(params)
- else
- PersonalSnippet.new(params)
- end
+ project.snippets.build(params)
+ else
+ PersonalSnippet.new(params)
+ end
unless Gitlab::VisibilityLevel.allowed_for?(current_user, params[:visibility_level])
deny_visibility_level(snippet)
diff --git a/app/services/delete_branch_service.rb b/app/services/delete_branch_service.rb
index 8322a3d74f4..427cc6be72e 100644
--- a/app/services/delete_branch_service.rb
+++ b/app/services/delete_branch_service.rb
@@ -6,17 +6,17 @@ class DeleteBranchService < BaseService
branch = repository.find_branch(branch_name)
unless current_user.can?(:push_code, project)
- return error('You dont have push access to repo', 405)
+ return error("You dont have push access to repo", 405)
end
unless branch
- return error('No such branch', 404)
+ return error("No such branch", 404)
end
if repository.rm_branch(current_user, branch_name)
- success('Branch was deleted')
+ success("Branch was deleted")
else
- error('Failed to remove branch')
+ error("Failed to remove branch")
end
rescue Gitlab::Git::PreReceiveError => ex
error(ex.message)
@@ -37,6 +37,7 @@ class DeleteBranchService < BaseService
branch.dereferenced_target.sha,
Gitlab::Git::BLANK_SHA,
"#{Gitlab::Git::BRANCH_REF_PREFIX}#{branch.name}",
- [])
+ []
+ )
end
end
diff --git a/app/services/emails/destroy_service.rb b/app/services/emails/destroy_service.rb
index 9ca1a03e172..a7828a94fd8 100644
--- a/app/services/emails/destroy_service.rb
+++ b/app/services/emails/destroy_service.rb
@@ -9,11 +9,11 @@ module Emails
private
def update_secondary_emails!
- result = ::Users::UpdateService.new(@current_user, user: @user).execute do |user|
+ result = ::Users::UpdateService.new(@current_user, user: @user).execute { |user|
user.update_secondary_emails!
- end
+ }
- result[:status] == 'success'
+ result[:status] == "success"
end
end
end
diff --git a/app/services/error_tracking/list_issues_service.rb b/app/services/error_tracking/list_issues_service.rb
index a6c6bec9598..2f8e456b546 100644
--- a/app/services/error_tracking/list_issues_service.rb
+++ b/app/services/error_tracking/list_issues_service.rb
@@ -2,19 +2,19 @@
module ErrorTracking
class ListIssuesService < ::BaseService
- DEFAULT_ISSUE_STATUS = 'unresolved'
+ DEFAULT_ISSUE_STATUS = "unresolved"
DEFAULT_LIMIT = 20
def execute
- return error('Error Tracking is not enabled') unless enabled?
- return error('Access denied', :unauthorized) unless can_read?
+ return error("Error Tracking is not enabled") unless enabled?
+ return error("Access denied", :unauthorized) unless can_read?
result = project_error_tracking_setting
.list_sentry_issues(issue_status: issue_status, limit: limit)
# our results are not yet ready
unless result
- return error('Not ready. Try again later', :no_content)
+ return error("Not ready. Try again later", :no_content)
end
if result[:error].present?
diff --git a/app/services/error_tracking/list_projects_service.rb b/app/services/error_tracking/list_projects_service.rb
index c6e8be0f2be..2cdc74bf8f2 100644
--- a/app/services/error_tracking/list_projects_service.rb
+++ b/app/services/error_tracking/list_projects_service.rb
@@ -3,12 +3,12 @@
module ErrorTracking
class ListProjectsService < ::BaseService
def execute
- return error('access denied') unless can_read?
+ return error("access denied") unless can_read?
setting = project_error_tracking_setting
unless setting.valid?
- return error(setting.errors.full_messages.join(', '), :bad_request)
+ return error(setting.errors.full_messages.join(", "), :bad_request)
end
begin
diff --git a/app/services/event_create_service.rb b/app/services/event_create_service.rb
index e7464fd9d5f..4815887b55c 100644
--- a/app/services/event_create_service.rb
+++ b/app/services/event_create_service.rb
@@ -89,7 +89,7 @@ class EventCreateService
Users::LastPushEventService.new(current_user)
.cache_last_push_event(event)
- Users::ActivityService.new(current_user, 'push').execute
+ Users::ActivityService.new(current_user, "push").execute
end
private
diff --git a/app/services/events/render_service.rb b/app/services/events/render_service.rb
index 50429683902..8adbdc7913c 100644
--- a/app/services/events/render_service.rb
+++ b/app/services/events/render_service.rb
@@ -19,7 +19,7 @@ module Events
def render_options(atom_request)
return {} unless atom_request
- { only_path: false, xhtml: true }
+ {only_path: false, xhtml: true}
end
end
end
diff --git a/app/services/files/base_service.rb b/app/services/files/base_service.rb
index 39e614d6569..a129617cc68 100644
--- a/app/services/files/base_service.rb
+++ b/app/services/files/base_service.rb
@@ -18,7 +18,7 @@ module Files
@previous_path = params[:previous_path]
@file_content = params[:file_content]
- @file_content = Base64.decode64(@file_content) if params[:file_content_encoding] == 'base64'
+ @file_content = Base64.decode64(@file_content) if params[:file_content_encoding] == "base64"
end
def file_has_changed?(path, commit_id)
diff --git a/app/services/files/create_dir_service.rb b/app/services/files/create_dir_service.rb
index 362b80071ba..a32d9af3a2d 100644
--- a/app/services/files/create_dir_service.rb
+++ b/app/services/files/create_dir_service.rb
@@ -11,7 +11,8 @@ module Files
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
- start_branch_name: @start_branch)
+ start_branch_name: @start_branch
+ )
end
end
end
diff --git a/app/services/files/create_service.rb b/app/services/files/create_service.rb
index fd5442a6c28..a5d61c94731 100644
--- a/app/services/files/create_service.rb
+++ b/app/services/files/create_service.rb
@@ -22,7 +22,8 @@ module Files
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
- start_branch_name: @start_branch)
+ start_branch_name: @start_branch
+ )
end
end
end
diff --git a/app/services/files/delete_service.rb b/app/services/files/delete_service.rb
index 0ec1f79d396..416e206bab8 100644
--- a/app/services/files/delete_service.rb
+++ b/app/services/files/delete_service.rb
@@ -11,7 +11,8 @@ module Files
author_email: @author_email,
author_name: @author_name,
start_project: @start_project,
- start_branch_name: @start_branch)
+ start_branch_name: @start_branch
+ )
end
private
diff --git a/app/services/files/multi_service.rb b/app/services/files/multi_service.rb
index 927634c2159..6fcf0fe2d4a 100644
--- a/app/services/files/multi_service.rb
+++ b/app/services/files/multi_service.rb
@@ -2,7 +2,7 @@
module Files
class MultiService < Files::BaseService
- UPDATE_FILE_ACTIONS = %w(update move delete chmod).freeze
+ UPDATE_FILE_ACTIONS = %w[update move delete chmod].freeze
def create_commit!
transformer = Lfs::FileTransformer.new(project, @branch_name)
@@ -17,7 +17,7 @@ module Files
def actions_after_lfs_transformation(transformer, actions)
actions.map do |action|
- if action[:action] == 'create'
+ if action[:action] == "create"
result = transformer.new_file(action[:file_path], action[:content], encoding: action[:encoding])
action[:content] = result.content
action[:encoding] = result.encoding
diff --git a/app/services/files/update_service.rb b/app/services/files/update_service.rb
index 2b3e96e6c53..a4bec851b0a 100644
--- a/app/services/files/update_service.rb
+++ b/app/services/files/update_service.rb
@@ -4,13 +4,13 @@ module Files
class UpdateService < Files::BaseService
def create_commit!
repository.update_file(current_user, @file_path, @file_content,
- message: @commit_message,
- branch_name: @branch_name,
- previous_path: @previous_path,
- author_email: @author_email,
- author_name: @author_name,
- start_project: @start_project,
- start_branch_name: @start_branch)
+ message: @commit_message,
+ branch_name: @branch_name,
+ previous_path: @previous_path,
+ author_email: @author_email,
+ author_name: @author_name,
+ start_project: @start_project,
+ start_branch_name: @start_branch)
end
private
diff --git a/app/services/git_push_service.rb b/app/services/git_push_service.rb
index f387c749a21..ca5ff51debc 100644
--- a/app/services/git_push_service.rb
+++ b/app/services/git_push_service.rb
@@ -175,7 +175,8 @@ class GitPushService < BaseService
params[:ref],
@push_commits,
commits_count: commits_count,
- push_options: params[:push_options] || [])
+ push_options: params[:push_options] || []
+ )
end
def push_to_existing_branch?
diff --git a/app/services/git_tag_push_service.rb b/app/services/git_tag_push_service.rb
index e39b3603c6c..8816f6a2e7c 100644
--- a/app/services/git_tag_push_service.rb
+++ b/app/services/git_tag_push_service.rb
@@ -46,7 +46,8 @@ class GitTagPushService < BaseService
params[:ref],
commits,
message,
- push_options: params[:push_options] || [])
+ push_options: params[:push_options] || []
+ )
end
def build_system_push_data
@@ -57,7 +58,8 @@ class GitTagPushService < BaseService
params[:newrev],
params[:ref],
[],
- '')
+ ""
+ )
end
def pipeline_options
diff --git a/app/services/gravatar_service.rb b/app/services/gravatar_service.rb
index 2a7a5dae291..69aec82e202 100644
--- a/app/services/gravatar_service.rb
+++ b/app/services/gravatar_service.rb
@@ -13,8 +13,8 @@ class GravatarService
sprintf gravatar_url,
hash: hash,
size: size * scale,
- email: ERB::Util.url_encode(email&.strip || ''),
- username: ERB::Util.url_encode(username&.strip || '')
+ email: ERB::Util.url_encode(email&.strip || ""),
+ username: ERB::Util.url_encode(username&.strip || "")
end
def gitlab_config
diff --git a/app/services/groups/create_service.rb b/app/services/groups/create_service.rb
index 99ead467f74..a3106979586 100644
--- a/app/services/groups/create_service.rb
+++ b/app/services/groups/create_service.rb
@@ -22,7 +22,7 @@ module Groups
response = Mattermost::CreateTeamService.new(@group, current_user).execute
return @group if @group.errors.any?
- @group.build_chat_team(name: response['name'], team_id: response['id'])
+ @group.build_chat_team(name: response["name"], team_id: response["id"])
end
@group.save
@@ -44,13 +44,13 @@ module Groups
if @group.subgroup?
unless can?(current_user, :create_subgroup, @group.parent)
@group.parent = nil
- @group.errors.add(:parent_id, 'You don’t have permission to create a subgroup in this group.')
+ @group.errors.add(:parent_id, "You don’t have permission to create a subgroup in this group.")
return false
end
else
unless can?(current_user, :create_group)
- @group.errors.add(:base, 'You don’t have permission to create groups.')
+ @group.errors.add(:base, "You don’t have permission to create groups.")
return false
end
diff --git a/app/services/groups/nested_create_service.rb b/app/services/groups/nested_create_service.rb
index f01f5656296..8432029c6ce 100644
--- a/app/services/groups/nested_create_service.rb
+++ b/app/services/groups/nested_create_service.rb
@@ -18,8 +18,8 @@ module Groups
return namespace
end
- if group_path.include?('/') && !Group.supports_nested_objects?
- raise 'Nested groups are not supported on MySQL'
+ if group_path.include?("/") && !Group.supports_nested_objects?
+ raise "Nested groups are not supported on MySQL"
end
create_group_path
@@ -28,13 +28,13 @@ module Groups
private
def create_group_path
- group_path_segments = group_path.split('/')
+ group_path_segments = group_path.split("/")
last_group = nil
partial_path_segments = []
while subgroup_name = group_path_segments.shift
partial_path_segments << subgroup_name
- partial_path = partial_path_segments.join('/')
+ partial_path = partial_path_segments.join("/")
new_params = params.reverse_merge(
path: subgroup_name,
diff --git a/app/services/groups/transfer_service.rb b/app/services/groups/transfer_service.rb
index f64e327416a..520cacb44be 100644
--- a/app/services/groups/transfer_service.rb
+++ b/app/services/groups/transfer_service.rb
@@ -3,11 +3,11 @@
module Groups
class TransferService < Groups::BaseService
ERROR_MESSAGES = {
- database_not_supported: 'Database is not supported.',
- namespace_with_same_path: 'The parent group already has a subgroup with the same path.',
- group_is_already_root: 'Group is already a root group.',
- same_parent_as_current: 'Group is already associated to the parent group.',
- invalid_policies: "You don't have enough permissions."
+ database_not_supported: "Database is not supported.",
+ namespace_with_same_path: "The parent group already has a subgroup with the same path.",
+ group_is_already_root: "Group is already a root group.",
+ same_parent_as_current: "Group is already associated to the parent group.",
+ invalid_policies: "You don't have enough permissions.",
}.freeze
TransferError = Class.new(StandardError)
@@ -23,7 +23,6 @@ module Groups
@new_parent_group = new_parent_group
ensure_allowed_transfer
proceed_to_transfer
-
rescue TransferError, ActiveRecord::RecordInvalid, Gitlab::UpdatePathError => e
@group.errors.clear
@error = "Transfer failed: " + e.message
diff --git a/app/services/import/base_service.rb b/app/services/import/base_service.rb
index 2683c75e41f..1052f005c6a 100644
--- a/app/services/import/base_service.rb
+++ b/app/services/import/base_service.rb
@@ -25,7 +25,7 @@ module Import
end
def project_save_error(project)
- project.errors.full_messages.join(', ')
+ project.errors.full_messages.join(", ")
end
def success(project)
diff --git a/app/services/import/github_service.rb b/app/services/import/github_service.rb
index a2533683da9..6ac490b4390 100644
--- a/app/services/import/github_service.rb
+++ b/app/services/import/github_service.rb
@@ -7,12 +7,12 @@ module Import
def execute(access_params, provider)
unless authorized?
- return error('This namespace has already been taken! Please choose another one.', :unprocessable_entity)
+ return error("This namespace has already been taken! Please choose another one.", :unprocessable_entity)
end
project = Gitlab::LegacyGithubImport::ProjectCreator
- .new(repo, project_name, target_namespace, current_user, access_params, type: provider)
- .execute(extra_project_attrs)
+ .new(repo, project_name, target_namespace, current_user, access_params, type: provider)
+ .execute(extra_project_attrs)
if project.persisted?
success(project)
diff --git a/app/services/import_export_clean_up_service.rb b/app/services/import_export_clean_up_service.rb
index 3ecb51b60d0..3b33bf4ad47 100644
--- a/app/services/import_export_clean_up_service.rb
+++ b/app/services/import_export_clean_up_service.rb
@@ -23,12 +23,12 @@ class ImportExportCleanUpService
private
def clean_up_export_files
- Gitlab::Popen.popen(%W(find #{path} -not -path #{path} -mmin +#{mmin} -delete))
+ Gitlab::Popen.popen(%W[find #{path} -not -path #{path} -mmin +#{mmin} -delete])
end
# rubocop: disable CodeReuse/ActiveRecord
def clean_up_export_object_files
- ImportExportUpload.where('updated_at < ?', mmin.minutes.ago).each do |upload|
+ ImportExportUpload.where("updated_at < ?", mmin.minutes.ago).each do |upload|
upload.remove_export_file!
upload.save!
end
diff --git a/app/services/issuable/bulk_update_service.rb b/app/services/issuable/bulk_update_service.rb
index c4beddf2294..618aa12c688 100644
--- a/app/services/issuable/bulk_update_service.rb
+++ b/app/services/issuable/bulk_update_service.rb
@@ -25,8 +25,8 @@ module Issuable
end
{
- count: items.count,
- success: !items.count.zero?
+ count: items.count,
+ success: !items.count.zero?,
}
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -34,9 +34,9 @@ module Issuable
private
def permitted_attrs(type)
- attrs = %i(state_event milestone_id assignee_id assignee_ids add_label_ids remove_label_ids subscription_event)
+ attrs = %i[state_event milestone_id assignee_id assignee_ids add_label_ids remove_label_ids subscription_event]
- if type == 'issue'
+ if type == "issue"
attrs.push(:assignee_ids)
else
attrs.push(:assignee_id)
diff --git a/app/services/issuable/clone/attributes_rewriter.rb b/app/services/issuable/clone/attributes_rewriter.rb
index 0300cc0d8d3..4dfd118b843 100644
--- a/app/services/issuable/clone/attributes_rewriter.rb
+++ b/app/services/issuable/clone/attributes_rewriter.rb
@@ -20,7 +20,7 @@ module Issuable
title = original_entity.milestone&.title
return unless title
- params = { title: title, project_ids: new_entity.project&.id, group_ids: group&.id }
+ params = {title: title, project_ids: new_entity.project&.id, group_ids: group&.id}
milestones = MilestonesFinder.new(params).execute
milestones.first
@@ -31,7 +31,7 @@ module Issuable
project_id: new_entity.project&.id,
group_id: group&.id,
title: original_entity.labels.select(:title),
- include_ancestor_groups: true
+ include_ancestor_groups: true,
}
params[:only_group_labels] = true if new_parent.is_a?(Group)
@@ -41,21 +41,21 @@ module Issuable
def copy_resource_label_events
original_entity.resource_label_events.find_in_batches do |batch|
- events = batch.map do |event|
- entity_key = new_entity.is_a?(Issue) ? 'issue_id' : 'epic_id'
+ events = batch.map { |event|
+ entity_key = new_entity.is_a?(Issue) ? "issue_id" : "epic_id"
# rubocop: disable CodeReuse/ActiveRecord
event.attributes
- .except('id', 'reference', 'reference_html')
- .merge(entity_key => new_entity.id, 'action' => ResourceLabelEvent.actions[event.action])
+ .except("id", "reference", "reference_html")
+ .merge(entity_key => new_entity.id, "action" => ResourceLabelEvent.actions[event.action])
# rubocop: enable CodeReuse/ActiveRecord
- end
+ }
Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, events)
end
end
def entity_key
- new_entity.class.name.parameterize('_').foreign_key
+ new_entity.class.name.parameterize("_").foreign_key
end
end
end
diff --git a/app/services/issuable/clone/base_service.rb b/app/services/issuable/clone/base_service.rb
index 42dd9c666f5..76550e014cc 100644
--- a/app/services/issuable/clone/base_service.rb
+++ b/app/services/issuable/clone/base_service.rb
@@ -5,7 +5,7 @@ module Issuable
class BaseService < IssuableBaseService
attr_reader :original_entity, :new_entity
- alias_method :old_project, :project
+ alias old_project project
def execute(original_entity, new_project = nil)
@original_entity = original_entity
@@ -47,7 +47,7 @@ module Issuable
end
def new_parent
- new_entity.project ? new_entity.project : new_entity.group
+ new_entity.project || new_entity.group
end
def group
diff --git a/app/services/issuable/clone/content_rewriter.rb b/app/services/issuable/clone/content_rewriter.rb
index e1e0b75085d..46fdd3ba680 100644
--- a/app/services/issuable/clone/content_rewriter.rb
+++ b/app/services/issuable/clone/content_rewriter.rb
@@ -29,7 +29,7 @@ module Issuable
project: new_entity.project, noteable: new_entity,
note: rewrite_content(new_note.note),
created_at: note.created_at,
- updated_at: note.updated_at
+ updated_at: note.updated_at,
}
if note.system_note_metadata
diff --git a/app/services/issuable/common_system_notes_service.rb b/app/services/issuable/common_system_notes_service.rb
index 77f38f8882e..5feed68b3dd 100644
--- a/app/services/issuable/common_system_notes_service.rb
+++ b/app/services/issuable/common_system_notes_service.rb
@@ -8,25 +8,25 @@ module Issuable
@issuable = issuable
if is_update
- if issuable.previous_changes.include?('title')
- create_title_change_note(issuable.previous_changes['title'].first)
+ if issuable.previous_changes.include?("title")
+ create_title_change_note(issuable.previous_changes["title"].first)
end
handle_description_change_note
handle_time_tracking_note if issuable.is_a?(TimeTrackable)
- create_discussion_lock_note if issuable.previous_changes.include?('discussion_locked')
+ create_discussion_lock_note if issuable.previous_changes.include?("discussion_locked")
end
- create_due_date_note if issuable.previous_changes.include?('due_date')
- create_milestone_note if issuable.previous_changes.include?('milestone_id')
+ create_due_date_note if issuable.previous_changes.include?("due_date")
+ create_milestone_note if issuable.previous_changes.include?("milestone_id")
create_labels_note(old_labels) if old_labels && issuable.labels != old_labels
end
private
def handle_time_tracking_note
- if issuable.previous_changes.include?('time_estimate')
+ if issuable.previous_changes.include?("time_estimate")
create_time_estimate_note
end
@@ -36,7 +36,7 @@ module Issuable
end
def handle_description_change_note
- if issuable.previous_changes.include?('description')
+ if issuable.previous_changes.include?("description")
if issuable.tasks? && issuable.updated_tasks.any?
create_task_status_note
else
diff --git a/app/services/issuable_base_service.rb b/app/services/issuable_base_service.rb
index ef991eaf234..2e29f449553 100644
--- a/app/services/issuable_base_service.rb
+++ b/app/services/issuable_base_service.rb
@@ -60,13 +60,13 @@ class IssuableBaseService < BaseService
milestone_id = params[:milestone_id]
return unless milestone_id
- params[:milestone_id] = '' if milestone_id == IssuableFinder::NONE
+ params[:milestone_id] = "" if milestone_id == IssuableFinder::NONE
groups = project.group&.self_and_ancestors&.select(:id)
milestone =
Milestone.for_projects_and_groups([project.id], groups).find_by_id(milestone_id)
- params[:milestone_id] = '' unless milestone
+ params[:milestone_id] = "" unless milestone
end
def filter_labels
@@ -89,7 +89,7 @@ class IssuableBaseService < BaseService
return unless labels
- params[:label_ids] = labels.split(",").map do |label_name|
+ params[:label_ids] = labels.split(",").map { |label_name|
label = Labels::FindOrCreateService.new(
current_user,
parent,
@@ -98,7 +98,7 @@ class IssuableBaseService < BaseService
).execute
label.try(:id)
- end.compact
+ }.compact
end
def process_label_ids(attributes, existing_label_ids: nil)
@@ -224,7 +224,7 @@ class IssuableBaseService < BaseService
issuable.create_new_cross_references!(current_user)
execute_hooks(
issuable,
- 'update',
+ "update",
old_associations: old_associations
)
@@ -254,7 +254,7 @@ class IssuableBaseService < BaseService
handle_task_changes(issuable)
invalidate_cache_counts(issuable, users: issuable.assignees.to_a)
after_update(issuable)
- execute_hooks(issuable, 'update', old_associations: nil)
+ execute_hooks(issuable, "update", old_associations: nil)
end
end
@@ -268,9 +268,9 @@ class IssuableBaseService < BaseService
return unless update_task_params
tasklist_toggler = TaskListToggleService.new(issuable.description, issuable.description_html,
- line_source: update_task_params[:line_source],
- line_number: update_task_params[:line_number].to_i,
- toggle_as_checked: update_task_params[:checked])
+ line_source: update_task_params[:line_source],
+ line_number: update_task_params[:line_number].to_i,
+ toggle_as_checked: update_task_params[:checked])
unless tasklist_toggler.execute
# if we make it here, the data is much newer than we thought it was - fail fast
@@ -300,18 +300,18 @@ class IssuableBaseService < BaseService
def change_state(issuable)
case params.delete(:state_event)
- when 'reopen'
+ when "reopen"
reopen_service.new(project, current_user, {}).execute(issuable)
- when 'close'
+ when "close"
close_service.new(project, current_user, {}).execute(issuable)
end
end
def change_subscription(issuable)
case params.delete(:subscription_event)
- when 'subscribe'
+ when "subscribe"
issuable.subscribe(current_user, project)
- when 'unsubscribe'
+ when "unsubscribe"
issuable.unsubscribe(current_user, project)
end
end
@@ -319,9 +319,9 @@ class IssuableBaseService < BaseService
# rubocop: disable CodeReuse/ActiveRecord
def change_todo(issuable)
case params.delete(:todo_event)
- when 'add'
+ when "add"
todo_service.mark_todo(issuable, current_user)
- when 'done'
+ when "done"
todo = TodosFinder.new(current_user).find_by(target: issuable)
todo_service.mark_todos_as_done_by_ids(todo, current_user) if todo
end
@@ -341,7 +341,7 @@ class IssuableBaseService < BaseService
{
labels: issuable.labels.to_a,
mentioned_users: issuable.mentioned_users.to_a,
- assignees: issuable.assignees.to_a
+ assignees: issuable.assignees.to_a,
}
associations[:total_time_spent] = issuable.total_time_spent if issuable.respond_to?(:total_time_spent)
@@ -351,9 +351,9 @@ class IssuableBaseService < BaseService
def has_changes?(issuable, old_labels: [], old_assignees: [])
valid_attrs = [:title, :description, :assignee_id, :milestone_id, :target_branch]
- attrs_changed = valid_attrs.any? do |attr|
+ attrs_changed = valid_attrs.any? { |attr|
issuable.previous_changes.include?(attr.to_s)
- end
+ }
labels_changed = issuable.labels != old_labels
@@ -377,7 +377,7 @@ class IssuableBaseService < BaseService
end
# override if needed
- def execute_hooks(issuable, action = 'open', params = {})
+ def execute_hooks(issuable, action = "open", params = {})
end
def update_project_counter_caches?(issuable)
diff --git a/app/services/issues/base_service.rb b/app/services/issues/base_service.rb
index ef08adf4f92..54db0d08b74 100644
--- a/app/services/issues/base_service.rb
+++ b/app/services/issues/base_service.rb
@@ -21,10 +21,11 @@ module Issues
def create_assignee_note(issue, old_assignees)
SystemNoteService.change_issue_assignees(
- issue, issue.project, current_user, old_assignees)
+ issue, issue.project, current_user, old_assignees
+ )
end
- def execute_hooks(issue, action = 'open', old_associations: {})
+ def execute_hooks(issue, action = "open", old_associations: {})
issue_data = hook_data(issue, action, old_associations: old_associations)
hooks_scope = issue.confidential? ? :confidential_issue_hooks : :issue_hooks
issue.project.execute_hooks(issue_data, hooks_scope)
diff --git a/app/services/issues/build_service.rb b/app/services/issues/build_service.rb
index 3fb2c2b3007..9deeee23b92 100644
--- a/app/services/issues/build_service.rb
+++ b/app/services/issues/build_service.rb
@@ -12,7 +12,7 @@ module Issues
def issue_params_with_info_from_discussions
return {} unless merge_request_to_resolve_discussions_of
- { title: title_from_merge_request, description: description_for_discussions }
+ {title: title_from_merge_request, description: description_for_discussions}
end
def title_from_merge_request
@@ -25,7 +25,7 @@ module Issues
"Review the conversation in #{merge_request_to_resolve_discussions_of.to_reference}"
end
- description = "The following #{'discussion'.pluralize(discussions_to_resolve.size)} "\
+ description = "The following #{"discussion".pluralize(discussions_to_resolve.size)} "\
"from #{merge_request_to_resolve_discussions_of.to_reference} "\
"should be addressed:"
@@ -47,13 +47,13 @@ module Issues
other_note_count = discussion.notes.size - 1
discussion_info = ["- [ ] #{first_note_to_resolve.author.to_reference} #{action} a [discussion](#{note_url}): "]
- discussion_info << "(+#{other_note_count} #{'comment'.pluralize(other_note_count)})" if other_note_count > 0
+ discussion_info << "(+#{other_note_count} #{"comment".pluralize(other_note_count)})" if other_note_count > 0
note_without_block_quotes = Banzai::Filter::BlockquoteFenceFilter.new(first_note_to_resolve.note).call
- spaces = ' ' * 4
+ spaces = " " * 4
quote = note_without_block_quotes.lines.map { |line| "#{spaces}> #{line}" }.join
- [discussion_info.join(' '), quote].join("\n\n")
+ [discussion_info.join(" "), quote].join("\n\n")
end
def issue_params
diff --git a/app/services/issues/close_service.rb b/app/services/issues/close_service.rb
index e5cc12e6082..c674669c8fc 100644
--- a/app/services/issues/close_service.rb
+++ b/app/services/issues/close_service.rb
@@ -7,9 +7,9 @@ module Issues
return issue unless can?(current_user, :update_issue, issue)
close_issue(issue,
- commit: commit,
- notifications: notifications,
- system_note: system_note)
+ commit: commit,
+ notifications: notifications,
+ system_note: system_note)
end
# Closes the supplied issue without checking if the user is authorized to
@@ -30,7 +30,7 @@ module Issues
create_note(issue, commit) if system_note
notification_service.async.close_issue(issue, current_user) if notifications
todo_service.close_issue(issue, current_user)
- execute_hooks(issue, 'close')
+ execute_hooks(issue, "close")
invalidate_cache_counts(issue, users: issue.assignees)
issue.update_project_counter_caches
end
diff --git a/app/services/issues/create_service.rb b/app/services/issues/create_service.rb
index 5793a15e1bc..6366614d036 100644
--- a/app/services/issues/create_service.rb
+++ b/app/services/issues/create_service.rb
@@ -37,8 +37,8 @@ module Issues
return if discussions_to_resolve.empty?
Discussions::ResolveService.new(project, current_user,
- merge_request: merge_request_to_resolve_discussions_of,
- follow_up_issue: issue)
+ merge_request: merge_request_to_resolve_discussions_of,
+ follow_up_issue: issue)
.execute(discussions_to_resolve)
end
diff --git a/app/services/issues/import_csv_service.rb b/app/services/issues/import_csv_service.rb
index ef08fafa7cc..a48c6cc91a1 100644
--- a/app/services/issues/import_csv_service.rb
+++ b/app/services/issues/import_csv_service.rb
@@ -6,7 +6,7 @@ module Issues
@user = user
@project = project
@csv_io = csv_io
- @results = { success: 0, error_lines: [], parse_error: false }
+ @results = {success: 0, error_lines: [], parse_error: false}
end
def execute
diff --git a/app/services/issues/move_service.rb b/app/services/issues/move_service.rb
index 41b6a96b005..30478f1b366 100644
--- a/app/services/issues/move_service.rb
+++ b/app/services/issues/move_service.rb
@@ -8,11 +8,11 @@ module Issues
@target_project = target_project
unless issue.can_move?(current_user, @target_project)
- raise MoveError, 'Cannot move issue due to insufficient permissions!'
+ raise MoveError, "Cannot move issue due to insufficient permissions!"
end
if @project == @target_project
- raise MoveError, 'Cannot move issue to project it originates from!'
+ raise MoveError, "Cannot move issue to project it originates from!"
end
super
@@ -32,12 +32,12 @@ module Issues
def create_new_entity
new_params = {
- id: nil,
- iid: nil,
- project: @target_project,
- author: original_entity.author,
- assignee_ids: original_entity.assignee_ids
- }
+ id: nil,
+ iid: nil,
+ project: @target_project,
+ author: original_entity.author,
+ assignee_ids: original_entity.assignee_ids,
+ }
new_params = original_entity.serializable_hash.symbolize_keys.merge(new_params)
CreateService.new(@target_project, @current_user, new_params).execute
@@ -53,14 +53,14 @@ module Issues
def add_note_from
SystemNoteService.noteable_moved(new_entity, @target_project,
- original_entity, current_user,
- direction: :from)
+ original_entity, current_user,
+ direction: :from)
end
def add_note_to
SystemNoteService.noteable_moved(original_entity, old_project,
- new_entity, current_user,
- direction: :to)
+ new_entity, current_user,
+ direction: :to)
end
end
end
diff --git a/app/services/issues/referenced_merge_requests_service.rb b/app/services/issues/referenced_merge_requests_service.rb
index a69cd324b1e..0a5cf2dff5e 100644
--- a/app/services/issues/referenced_merge_requests_service.rb
+++ b/app/services/issues/referenced_merge_requests_service.rb
@@ -9,7 +9,7 @@ module Issues
preloader = ActiveRecord::Associations::Preloader.new
preloader.preload(referenced + closed_by,
- head_pipeline: { project: [:route, { namespace: :route }] })
+ head_pipeline: {project: [:route, {namespace: :route}]})
[sort_by_iid(referenced), sort_by_iid(closed_by)]
end
@@ -18,7 +18,7 @@ module Issues
def referenced_merge_requests(issue)
merge_requests = extract_merge_requests(issue)
- cross_project_filter = -> (merge_requests) do
+ cross_project_filter = ->(merge_requests) do
merge_requests.select { |mr| mr.target_project == project }
end
@@ -26,7 +26,7 @@ module Issues
merge_requests,
current_user,
filters: {
- read_cross_project: cross_project_filter
+ read_cross_project: cross_project_filter,
}
)
end
diff --git a/app/services/issues/reopen_service.rb b/app/services/issues/reopen_service.rb
index 56d59b235a7..cb68b3bfb82 100644
--- a/app/services/issues/reopen_service.rb
+++ b/app/services/issues/reopen_service.rb
@@ -7,9 +7,9 @@ module Issues
if issue.reopen
event_service.reopen_issue(issue, current_user)
- create_note(issue, 'reopened')
+ create_note(issue, "reopened")
notification_service.async.reopen_issue(issue, current_user)
- execute_hooks(issue, 'reopen')
+ execute_hooks(issue, "reopen")
invalidate_cache_counts(issue, users: issue.assignees)
issue.update_project_counter_caches
end
diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb
index cec5b5734c0..d23abcf99f4 100644
--- a/app/services/issues/update_service.rb
+++ b/app/services/issues/update_service.rb
@@ -31,8 +31,8 @@ module Issues
todo_service.mark_pending_todos_as_done(issue, current_user)
end
- if issue.previous_changes.include?('title') ||
- issue.previous_changes.include?('description')
+ if issue.previous_changes.include?("title") ||
+ issue.previous_changes.include?("description")
todo_service.update_issue(issue, current_user, old_mentioned_users)
end
@@ -42,7 +42,7 @@ module Issues
todo_service.reassigned_issue(issue, current_user, old_assignees)
end
- if issue.previous_changes.include?('confidential')
+ if issue.previous_changes.include?("confidential")
# don't enqueue immediately to prevent todos removal in case of a mistake
TodosDestroyer::ConfidentialIssueWorker.perform_in(Todo::WAIT_FOR_DELETE, issue.id) if issue.confidential?
create_confidentiality_note(issue)
@@ -97,8 +97,8 @@ module Issues
target_project = params.delete(:target_project)
return unless target_project &&
- issue.can_move?(current_user, target_project) &&
- target_project != issue.project
+ issue.can_move?(current_user, target_project) &&
+ target_project != issue.project
update(issue)
Issues::MoveService.new(project, current_user).execute(issue, target_project)
@@ -116,7 +116,7 @@ module Issues
def handle_milestone_change(issue)
return if skip_milestone_email
- return unless issue.previous_changes.include?('milestone_id')
+ return unless issue.previous_changes.include?("milestone_id")
if issue.milestone.nil?
notification_service.async.removed_milestone_issue(issue, current_user)
diff --git a/app/services/labels/base_service.rb b/app/services/labels/base_service.rb
index ead7f2ea607..b63fc16fc4c 100644
--- a/app/services/labels/base_service.rb
+++ b/app/services/labels/base_service.rb
@@ -3,159 +3,159 @@
module Labels
class BaseService < ::BaseService
COLOR_NAME_TO_HEX = {
- black: '#000000',
- silver: '#C0C0C0',
- gray: '#808080',
- white: '#FFFFFF',
- maroon: '#800000',
- red: '#FF0000',
- purple: '#800080',
- fuchsia: '#FF00FF',
- green: '#008000',
- lime: '#00FF00',
- olive: '#808000',
- yellow: '#FFFF00',
- navy: '#000080',
- blue: '#0000FF',
- teal: '#008080',
- aqua: '#00FFFF',
- orange: '#FFA500',
- aliceblue: '#F0F8FF',
- antiquewhite: '#FAEBD7',
- aquamarine: '#7FFFD4',
- azure: '#F0FFFF',
- beige: '#F5F5DC',
- bisque: '#FFE4C4',
- blanchedalmond: '#FFEBCD',
- blueviolet: '#8A2BE2',
- brown: '#A52A2A',
- burlywood: '#DEB887',
- cadetblue: '#5F9EA0',
- chartreuse: '#7FFF00',
- chocolate: '#D2691E',
- coral: '#FF7F50',
- cornflowerblue: '#6495ED',
- cornsilk: '#FFF8DC',
- crimson: '#DC143C',
- darkblue: '#00008B',
- darkcyan: '#008B8B',
- darkgoldenrod: '#B8860B',
- darkgray: '#A9A9A9',
- darkgreen: '#006400',
- darkgrey: '#A9A9A9',
- darkkhaki: '#BDB76B',
- darkmagenta: '#8B008B',
- darkolivegreen: '#556B2F',
- darkorange: '#FF8C00',
- darkorchid: '#9932CC',
- darkred: '#8B0000',
- darksalmon: '#E9967A',
- darkseagreen: '#8FBC8F',
- darkslateblue: '#483D8B',
- darkslategray: '#2F4F4F',
- darkslategrey: '#2F4F4F',
- darkturquoise: '#00CED1',
- darkviolet: '#9400D3',
- deeppink: '#FF1493',
- deepskyblue: '#00BFFF',
- dimgray: '#696969',
- dimgrey: '#696969',
- dodgerblue: '#1E90FF',
- firebrick: '#B22222',
- floralwhite: '#FFFAF0',
- forestgreen: '#228B22',
- gainsboro: '#DCDCDC',
- ghostwhite: '#F8F8FF',
- gold: '#FFD700',
- goldenrod: '#DAA520',
- greenyellow: '#ADFF2F',
- grey: '#808080',
- honeydew: '#F0FFF0',
- hotpink: '#FF69B4',
- indianred: '#CD5C5C',
- indigo: '#4B0082',
- ivory: '#FFFFF0',
- khaki: '#F0E68C',
- lavender: '#E6E6FA',
- lavenderblush: '#FFF0F5',
- lawngreen: '#7CFC00',
- lemonchiffon: '#FFFACD',
- lightblue: '#ADD8E6',
- lightcoral: '#F08080',
- lightcyan: '#E0FFFF',
- lightgoldenrodyellow: '#FAFAD2',
- lightgray: '#D3D3D3',
- lightgreen: '#90EE90',
- lightgrey: '#D3D3D3',
- lightpink: '#FFB6C1',
- lightsalmon: '#FFA07A',
- lightseagreen: '#20B2AA',
- lightskyblue: '#87CEFA',
- lightslategray: '#778899',
- lightslategrey: '#778899',
- lightsteelblue: '#B0C4DE',
- lightyellow: '#FFFFE0',
- limegreen: '#32CD32',
- linen: '#FAF0E6',
- mediumaquamarine: '#66CDAA',
- mediumblue: '#0000CD',
- mediumorchid: '#BA55D3',
- mediumpurple: '#9370DB',
- mediumseagreen: '#3CB371',
- mediumslateblue: '#7B68EE',
- mediumspringgreen: '#00FA9A',
- mediumturquoise: '#48D1CC',
- mediumvioletred: '#C71585',
- midnightblue: '#191970',
- mintcream: '#F5FFFA',
- mistyrose: '#FFE4E1',
- moccasin: '#FFE4B5',
- navajowhite: '#FFDEAD',
- oldlace: '#FDF5E6',
- olivedrab: '#6B8E23',
- orangered: '#FF4500',
- orchid: '#DA70D6',
- palegoldenrod: '#EEE8AA',
- palegreen: '#98FB98',
- paleturquoise: '#AFEEEE',
- palevioletred: '#DB7093',
- papayawhip: '#FFEFD5',
- peachpuff: '#FFDAB9',
- peru: '#CD853F',
- pink: '#FFC0CB',
- plum: '#DDA0DD',
- powderblue: '#B0E0E6',
- rosybrown: '#BC8F8F',
- royalblue: '#4169E1',
- saddlebrown: '#8B4513',
- salmon: '#FA8072',
- sandybrown: '#F4A460',
- seagreen: '#2E8B57',
- seashell: '#FFF5EE',
- sienna: '#A0522D',
- skyblue: '#87CEEB',
- slateblue: '#6A5ACD',
- slategray: '#708090',
- slategrey: '#708090',
- snow: '#FFFAFA',
- springgreen: '#00FF7F',
- steelblue: '#4682B4',
- tan: '#D2B48C',
- thistle: '#D8BFD8',
- tomato: '#FF6347',
- turquoise: '#40E0D0',
- violet: '#EE82EE',
- wheat: '#F5DEB3',
- whitesmoke: '#F5F5F5',
- yellowgreen: '#9ACD32',
- rebeccapurple: '#663399'
+ black: "#000000",
+ silver: "#C0C0C0",
+ gray: "#808080",
+ white: "#FFFFFF",
+ maroon: "#800000",
+ red: "#FF0000",
+ purple: "#800080",
+ fuchsia: "#FF00FF",
+ green: "#008000",
+ lime: "#00FF00",
+ olive: "#808000",
+ yellow: "#FFFF00",
+ navy: "#000080",
+ blue: "#0000FF",
+ teal: "#008080",
+ aqua: "#00FFFF",
+ orange: "#FFA500",
+ aliceblue: "#F0F8FF",
+ antiquewhite: "#FAEBD7",
+ aquamarine: "#7FFFD4",
+ azure: "#F0FFFF",
+ beige: "#F5F5DC",
+ bisque: "#FFE4C4",
+ blanchedalmond: "#FFEBCD",
+ blueviolet: "#8A2BE2",
+ brown: "#A52A2A",
+ burlywood: "#DEB887",
+ cadetblue: "#5F9EA0",
+ chartreuse: "#7FFF00",
+ chocolate: "#D2691E",
+ coral: "#FF7F50",
+ cornflowerblue: "#6495ED",
+ cornsilk: "#FFF8DC",
+ crimson: "#DC143C",
+ darkblue: "#00008B",
+ darkcyan: "#008B8B",
+ darkgoldenrod: "#B8860B",
+ darkgray: "#A9A9A9",
+ darkgreen: "#006400",
+ darkgrey: "#A9A9A9",
+ darkkhaki: "#BDB76B",
+ darkmagenta: "#8B008B",
+ darkolivegreen: "#556B2F",
+ darkorange: "#FF8C00",
+ darkorchid: "#9932CC",
+ darkred: "#8B0000",
+ darksalmon: "#E9967A",
+ darkseagreen: "#8FBC8F",
+ darkslateblue: "#483D8B",
+ darkslategray: "#2F4F4F",
+ darkslategrey: "#2F4F4F",
+ darkturquoise: "#00CED1",
+ darkviolet: "#9400D3",
+ deeppink: "#FF1493",
+ deepskyblue: "#00BFFF",
+ dimgray: "#696969",
+ dimgrey: "#696969",
+ dodgerblue: "#1E90FF",
+ firebrick: "#B22222",
+ floralwhite: "#FFFAF0",
+ forestgreen: "#228B22",
+ gainsboro: "#DCDCDC",
+ ghostwhite: "#F8F8FF",
+ gold: "#FFD700",
+ goldenrod: "#DAA520",
+ greenyellow: "#ADFF2F",
+ grey: "#808080",
+ honeydew: "#F0FFF0",
+ hotpink: "#FF69B4",
+ indianred: "#CD5C5C",
+ indigo: "#4B0082",
+ ivory: "#FFFFF0",
+ khaki: "#F0E68C",
+ lavender: "#E6E6FA",
+ lavenderblush: "#FFF0F5",
+ lawngreen: "#7CFC00",
+ lemonchiffon: "#FFFACD",
+ lightblue: "#ADD8E6",
+ lightcoral: "#F08080",
+ lightcyan: "#E0FFFF",
+ lightgoldenrodyellow: "#FAFAD2",
+ lightgray: "#D3D3D3",
+ lightgreen: "#90EE90",
+ lightgrey: "#D3D3D3",
+ lightpink: "#FFB6C1",
+ lightsalmon: "#FFA07A",
+ lightseagreen: "#20B2AA",
+ lightskyblue: "#87CEFA",
+ lightslategray: "#778899",
+ lightslategrey: "#778899",
+ lightsteelblue: "#B0C4DE",
+ lightyellow: "#FFFFE0",
+ limegreen: "#32CD32",
+ linen: "#FAF0E6",
+ mediumaquamarine: "#66CDAA",
+ mediumblue: "#0000CD",
+ mediumorchid: "#BA55D3",
+ mediumpurple: "#9370DB",
+ mediumseagreen: "#3CB371",
+ mediumslateblue: "#7B68EE",
+ mediumspringgreen: "#00FA9A",
+ mediumturquoise: "#48D1CC",
+ mediumvioletred: "#C71585",
+ midnightblue: "#191970",
+ mintcream: "#F5FFFA",
+ mistyrose: "#FFE4E1",
+ moccasin: "#FFE4B5",
+ navajowhite: "#FFDEAD",
+ oldlace: "#FDF5E6",
+ olivedrab: "#6B8E23",
+ orangered: "#FF4500",
+ orchid: "#DA70D6",
+ palegoldenrod: "#EEE8AA",
+ palegreen: "#98FB98",
+ paleturquoise: "#AFEEEE",
+ palevioletred: "#DB7093",
+ papayawhip: "#FFEFD5",
+ peachpuff: "#FFDAB9",
+ peru: "#CD853F",
+ pink: "#FFC0CB",
+ plum: "#DDA0DD",
+ powderblue: "#B0E0E6",
+ rosybrown: "#BC8F8F",
+ royalblue: "#4169E1",
+ saddlebrown: "#8B4513",
+ salmon: "#FA8072",
+ sandybrown: "#F4A460",
+ seagreen: "#2E8B57",
+ seashell: "#FFF5EE",
+ sienna: "#A0522D",
+ skyblue: "#87CEEB",
+ slateblue: "#6A5ACD",
+ slategray: "#708090",
+ slategrey: "#708090",
+ snow: "#FFFAFA",
+ springgreen: "#00FF7F",
+ steelblue: "#4682B4",
+ tan: "#D2B48C",
+ thistle: "#D8BFD8",
+ tomato: "#FF6347",
+ turquoise: "#40E0D0",
+ violet: "#EE82EE",
+ wheat: "#F5DEB3",
+ whitesmoke: "#F5F5F5",
+ yellowgreen: "#9ACD32",
+ rebeccapurple: "#663399",
}.freeze
def convert_color_name_to_hex
color = params[:color]
color_name = color.strip.downcase
- return color if color_name.start_with?('#')
+ return color if color_name.start_with?("#")
COLOR_NAME_TO_HEX[color_name.to_sym] || color
end
diff --git a/app/services/labels/find_or_create_service.rb b/app/services/labels/find_or_create_service.rb
index 628873519d7..4bd3969d48e 100644
--- a/app/services/labels/find_or_create_service.rb
+++ b/app/services/labels/find_or_create_service.rb
@@ -22,8 +22,8 @@ module Labels
@available_labels ||= LabelsFinder.new(
current_user,
"#{parent_type}_id".to_sym => parent.id,
- include_ancestor_groups: include_ancestor_groups?,
- only_group_labels: parent_is_group?
+ :include_ancestor_groups => include_ancestor_groups?,
+ :only_group_labels => parent_is_group?
).execute(skip_authorization: skip_authorization)
end
diff --git a/app/services/labels/promote_service.rb b/app/services/labels/promote_service.rb
index e73e6476c12..a04676312c0 100644
--- a/app/services/labels/promote_service.rb
+++ b/app/services/labels/promote_service.rb
@@ -7,7 +7,7 @@ module Labels
# rubocop: disable CodeReuse/ActiveRecord
def execute(label)
return unless project.group &&
- label.is_a?(ProjectLabel)
+ label.is_a?(ProjectLabel)
Label.transaction do
new_label = clone_label_to_group_label(label)
@@ -36,9 +36,9 @@ module Labels
def subscribe_users(new_label, label_ids)
# users can be subscribed to multiple labels that will be merged into the group one
# we want to keep only one subscription / user
- ids_to_update = Subscription.where(subscribable_id: label_ids, subscribable_type: 'Label')
+ ids_to_update = Subscription.where(subscribable_id: label_ids, subscribable_type: "Label")
.group(:user_id)
- .pluck('MAX(id)')
+ .pluck("MAX(id)")
Subscription.where(id: ids_to_update).update_all(subscribable_id: new_label.id)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -92,7 +92,7 @@ module Labels
# rubocop: enable CodeReuse/ActiveRecord
def clone_label_to_group_label(label)
- params = label.attributes.slice('title', 'description', 'color')
+ params = label.attributes.slice("title", "description", "color")
# Since the title of the new label has to be the same as the previous labels
# and we're merging old labels in batches we'll skip validation to omit 2-step
# merge process and do it in one batch
diff --git a/app/services/labels/transfer_service.rb b/app/services/labels/transfer_service.rb
index 9cbc9fef529..a340e15e2ac 100644
--- a/app/services/labels/transfer_service.rb
+++ b/app/services/labels/transfer_service.rb
@@ -37,7 +37,7 @@ module Labels
Label
.from_union([
group_labels_applied_to_issues,
- group_labels_applied_to_merge_requests
+ group_labels_applied_to_merge_requests,
])
.reorder(nil)
.distinct
@@ -48,8 +48,8 @@ module Labels
def group_labels_applied_to_issues
Label.joins(:issues)
.where(
- issues: { project_id: project.id },
- labels: { type: 'GroupLabel', group_id: old_group.id }
+ issues: {project_id: project.id},
+ labels: {type: "GroupLabel", group_id: old_group.id}
)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -58,14 +58,14 @@ module Labels
def group_labels_applied_to_merge_requests
Label.joins(:merge_requests)
.where(
- merge_requests: { target_project_id: project.id },
- labels: { type: 'GroupLabel', group_id: old_group.id }
+ merge_requests: {target_project_id: project.id},
+ labels: {type: "GroupLabel", group_id: old_group.id}
)
end
# rubocop: enable CodeReuse/ActiveRecord
def find_or_create_label!(label)
- params = label.attributes.slice('title', 'description', 'color')
+ params = label.attributes.slice("title", "description", "color")
new_label = FindOrCreateService.new(current_user, project, params).execute
new_label.id
@@ -78,7 +78,7 @@ module Labels
# IDs are fetched in a separate query because MySQL doesn't
# allow referring of 'label_links' table in UPDATE query:
# https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/62435068
- link_ids = labels.pluck('label_links.id')
+ link_ids = labels.pluck("label_links.id")
LabelLink.where(id: link_ids, label_id: old_label_id)
.update_all(label_id: new_label_id)
diff --git a/app/services/lfs/file_transformer.rb b/app/services/lfs/file_transformer.rb
index 6ecf583cb6a..279f0b3010c 100644
--- a/app/services/lfs/file_transformer.rb
+++ b/app/services/lfs/file_transformer.rb
@@ -24,13 +24,13 @@ module Lfs
def new_file(file_path, file_content, encoding: nil)
if project.lfs_enabled? && lfs_file?(file_path)
- file_content = Base64.decode64(file_content) if encoding == 'base64'
+ file_content = Base64.decode64(file_content) if encoding == "base64"
lfs_pointer_file = Gitlab::Git::LfsPointerFile.new(file_content)
lfs_object = create_lfs_object!(lfs_pointer_file, file_content)
link_lfs_object!(lfs_object)
- Result.new(content: lfs_pointer_file.pointer, encoding: 'text')
+ Result.new(content: lfs_pointer_file.pointer, encoding: "text")
else
Result.new(content: file_content, encoding: encoding)
end
@@ -48,7 +48,7 @@ module Lfs
private
def lfs_file?(file_path)
- cached_attributes.attributes(file_path)['filter'] == 'lfs'
+ cached_attributes.attributes(file_path)["filter"] == "lfs"
end
def cached_attributes
diff --git a/app/services/lfs/lock_file_service.rb b/app/services/lfs/lock_file_service.rb
index c7730d24bdc..124e99eae29 100644
--- a/app/services/lfs/lock_file_service.rb
+++ b/app/services/lfs/lock_file_service.rb
@@ -4,12 +4,12 @@ module Lfs
class LockFileService < BaseService
def execute
unless can?(current_user, :push_code, project)
- raise Gitlab::GitAccess::UnauthorizedError, 'You have no permissions'
+ raise Gitlab::GitAccess::UnauthorizedError, "You have no permissions"
end
create_lock!
rescue ActiveRecord::RecordNotUnique
- error('already locked', 409, current_lock)
+ error("already locked", 409, current_lock)
rescue Gitlab::GitAccess::UnauthorizedError => ex
error(ex.message, 403)
rescue => ex
@@ -36,7 +36,7 @@ module Lfs
status: :error,
message: message,
http_status: http_status,
- lock: lock
+ lock: lock,
}
end
end
diff --git a/app/services/lfs/unlock_file_service.rb b/app/services/lfs/unlock_file_service.rb
index a42916d86bb..9306d53d14f 100644
--- a/app/services/lfs/unlock_file_service.rb
+++ b/app/services/lfs/unlock_file_service.rb
@@ -4,14 +4,14 @@ module Lfs
class UnlockFileService < BaseService
def execute
unless can?(current_user, :push_code, project)
- raise Gitlab::GitAccess::UnauthorizedError, _('You have no permissions')
+ raise Gitlab::GitAccess::UnauthorizedError, _("You have no permissions")
end
unlock_file
rescue Gitlab::GitAccess::UnauthorizedError => ex
error(ex.message, 403)
rescue ActiveRecord::RecordNotFound
- error(_('Lock not found'), 404)
+ error(_("Lock not found"), 404)
rescue => ex
error(ex.message, 500)
end
@@ -26,9 +26,9 @@ module Lfs
success(lock: lock, http_status: :ok)
elsif forced
- error(_('You must have maintainer access to force delete a lock'), 403)
+ error(_("You must have maintainer access to force delete a lock"), 403)
else
- error(_("%{lock_path} is locked by GitLab User %{lock_user_id}") % { lock_path: lock.path, lock_user_id: lock.user_id }, 403)
+ error(_("%{lock_path} is locked by GitLab User %{lock_user_id}") % {lock_path: lock.path, lock_user_id: lock.user_id}, 403)
end
end
@@ -37,10 +37,10 @@ module Lfs
return @lock if defined?(@lock)
@lock = if params[:id].present?
- project.lfs_file_locks.find(params[:id])
- elsif params[:path].present?
- project.lfs_file_locks.find_by!(path: params[:path])
- end
+ project.lfs_file_locks.find(params[:id])
+ elsif params[:path].present?
+ project.lfs_file_locks.find_by!(path: params[:path])
+ end
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/members/base_service.rb b/app/services/members/base_service.rb
index e78affff797..1f26378862f 100644
--- a/app/services/members/base_service.rb
+++ b/app/services/members/base_service.rb
@@ -49,7 +49,7 @@ module Members
end
def enqueue_delete_todos(member)
- type = member.is_a?(GroupMember) ? 'Group' : 'Project'
+ type = member.is_a?(GroupMember) ? "Group" : "Project"
# don't enqueue immediately to prevent todos removal in case of a mistake
TodosDestroyer::EntityLeaveWorker.perform_in(Todo::WAIT_FOR_DELETE, member.user_id, member.source_id, type)
end
diff --git a/app/services/members/create_service.rb b/app/services/members/create_service.rb
index cf710fef52b..f6a857af7ec 100644
--- a/app/services/members/create_service.rb
+++ b/app/services/members/create_service.rb
@@ -5,9 +5,9 @@ module Members
DEFAULT_LIMIT = 100
def execute(source)
- return error('No users specified.') if params[:user_ids].blank?
+ return error("No users specified.") if params[:user_ids].blank?
- user_ids = params[:user_ids].split(',').uniq
+ user_ids = params[:user_ids].split(",").uniq
return error("Too many users specified (limit is #{user_limit})") if
user_limit && user_ids.size > user_limit
diff --git a/app/services/members/request_access_service.rb b/app/services/members/request_access_service.rb
index b9b0550e290..280561e159d 100644
--- a/app/services/members/request_access_service.rb
+++ b/app/services/members/request_access_service.rb
@@ -8,7 +8,8 @@ module Members
source.members.create(
access_level: Gitlab::Access::DEVELOPER,
user: current_user,
- requested_at: Time.now.utc)
+ requested_at: Time.now.utc
+ )
end
private
diff --git a/app/services/merge_requests/assign_issues_service.rb b/app/services/merge_requests/assign_issues_service.rb
index e9107b9998e..0622094474d 100644
--- a/app/services/merge_requests/assign_issues_service.rb
+++ b/app/services/merge_requests/assign_issues_service.rb
@@ -20,7 +20,7 @@ module MergeRequests
end
{
- count: assignable_issues.count
+ count: assignable_issues.count,
}
end
diff --git a/app/services/merge_requests/base_service.rb b/app/services/merge_requests/base_service.rb
index ac51fee0b3f..72a2d352248 100644
--- a/app/services/merge_requests/base_service.rb
+++ b/app/services/merge_requests/base_service.rb
@@ -16,7 +16,7 @@ module MergeRequests
hook_data
end
- def execute_hooks(merge_request, action = 'open', old_rev: nil, old_associations: {})
+ def execute_hooks(merge_request, action = "open", old_rev: nil, old_associations: {})
if merge_request.project
merge_data = hook_data(merge_request, action, old_rev: old_rev, old_associations: old_associations)
merge_request.project.execute_hooks(merge_data, :merge_request_hooks)
@@ -31,9 +31,9 @@ module MergeRequests
# We update the title that is provided in the params or we use the mr title
title = params[:title] || merge_request.title
params[:title] = case wip_event
- when 'wip' then MergeRequest.wip_title(title)
- when 'unwip' then MergeRequest.wipless_title(title)
- end
+ when "wip" then MergeRequest.wip_title(title)
+ when "unwip" then MergeRequest.wipless_title(title)
+ end
end
end
@@ -51,13 +51,14 @@ module MergeRequests
def create_assignee_note(merge_request)
SystemNoteService.change_assignee(
- merge_request, merge_request.project, current_user, merge_request.assignee)
+ merge_request, merge_request.project, current_user, merge_request.assignee
+ )
end
def create_merge_request_pipeline(merge_request, user)
return unless Feature.enabled?(:ci_merge_request_pipeline,
- merge_request.source_project,
- default_enabled: true)
+ merge_request.source_project,
+ default_enabled: true)
##
# UpdateMergeRequestsWorker could be retried by an exception.
@@ -68,9 +69,9 @@ module MergeRequests
Ci::CreatePipelineService
.new(merge_request.source_project, user, ref: merge_request.source_branch)
.execute(:merge_request,
- ignore_skip_ci: true,
- save_on_errors: false,
- merge_request: merge_request)
+ ignore_skip_ci: true,
+ save_on_errors: false,
+ merge_request: merge_request)
end
# Returns all origin and fork merge requests from `@project` satisfying passed arguments.
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb
index 48419da98ad..8a63c7e66c5 100644
--- a/app/services/merge_requests/build_service.rb
+++ b/app/services/merge_requests/build_service.rb
@@ -10,7 +10,7 @@ module MergeRequests
# TODO: this should handle all quick actions that don't have side effects
# https://gitlab.com/gitlab-org/gitlab-ce/issues/53658
merge_quick_actions_into_params!(merge_request, only: [:target_branch])
- merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch) if params.has_key?(:force_remove_source_branch)
+ merge_request.merge_params["force_remove_source_branch"] = params.delete(:force_remove_source_branch) if params.key?(:force_remove_source_branch)
merge_request.assign_attributes(params)
merge_request.author = current_user
@@ -37,16 +37,16 @@ module MergeRequests
attr_accessor :merge_request
delegate :target_branch,
- :target_branch_ref,
- :target_project,
- :source_branch,
- :source_branch_ref,
- :source_project,
- :compare_commits,
- :wip_title,
- :description,
- :errors,
- to: :merge_request
+ :target_branch_ref,
+ :target_project,
+ :source_branch,
+ :source_branch_ref,
+ :source_project,
+ :compare_commits,
+ :wip_title,
+ :description,
+ :errors,
+ to: :merge_request
def find_source_project
return source_project if source_project.present? && can?(current_user, :create_merge_request_from, source_project)
@@ -105,8 +105,8 @@ module MergeRequests
return if errors.any?
- add_error('You must select source and target branch') unless branches_present?
- add_error('You must select different branches') if same_source_and_target?
+ add_error("You must select source and target branch") unless branches_present?
+ add_error("You must select different branches") if same_source_and_target?
add_error("Source branch \"#{source_branch}\" does not exist") unless source_branch_exists?
add_error("Target branch \"#{target_branch}\" does not exist") unless target_branch_exists?
end
@@ -200,15 +200,15 @@ module MergeRequests
branch_title = source_branch.downcase.remove(issue_iid.downcase).titleize.humanize
title_parts << "\"#{branch_title}\"" if branch_title.present?
- title_parts.join(' ')
+ title_parts.join(" ")
end
def issue_iid
strong_memoize(:issue_iid) do
@params_issue_iid || begin
id = if target_project.external_issue_tracker
- source_branch.match(target_project.external_issue_reference_pattern).try(:[], 0)
- end
+ source_branch.match(target_project.external_issue_reference_pattern).try(:[], 0)
+ end
id || source_branch.match(/\A(\d+)-/).try(:[], 1)
end
diff --git a/app/services/merge_requests/close_service.rb b/app/services/merge_requests/close_service.rb
index 04527bb9713..e5449f015ce 100644
--- a/app/services/merge_requests/close_service.rb
+++ b/app/services/merge_requests/close_service.rb
@@ -14,7 +14,7 @@ module MergeRequests
create_note(merge_request)
notification_service.async.close_mr(merge_request, current_user)
todo_service.close_merge_request(merge_request, current_user)
- execute_hooks(merge_request, 'close')
+ execute_hooks(merge_request, "close")
invalidate_cache_counts(merge_request, users: merge_request.assignees)
merge_request.update_project_counter_caches
end
diff --git a/app/services/merge_requests/create_from_issue_service.rb b/app/services/merge_requests/create_from_issue_service.rb
index e69791872cc..cef57be8082 100644
--- a/app/services/merge_requests/create_from_issue_service.rb
+++ b/app/services/merge_requests/create_from_issue_service.rb
@@ -14,7 +14,7 @@ module MergeRequests
end
def execute
- return error('Invalid issue iid') unless @issue_iid.present? && issue.present?
+ return error("Invalid issue iid") unless @issue_iid.present? && issue.present?
result = CreateBranchService.new(project, current_user).execute(branch_name, ref)
return result if result[:status] == :error
@@ -47,7 +47,7 @@ module MergeRequests
def ref
return @ref if project.repository.branch_exists?(@ref)
- project.default_branch || 'master'
+ project.default_branch || "master"
end
def merge_request
@@ -60,7 +60,7 @@ module MergeRequests
source_project_id: project.id,
source_branch: branch_name,
target_project_id: project.id,
- target_branch: ref
+ target_branch: ref,
}
end
diff --git a/app/services/merge_requests/create_service.rb b/app/services/merge_requests/create_service.rb
index 02c2388c05c..c5a9aae7af3 100644
--- a/app/services/merge_requests/create_service.rb
+++ b/app/services/merge_requests/create_service.rb
@@ -9,7 +9,7 @@ module MergeRequests
merge_request.target_project = @project
merge_request.source_project = @source_project
merge_request.source_branch = params[:source_branch]
- merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch)
+ merge_request.merge_params["force_remove_source_branch"] = params.delete(:force_remove_source_branch)
create(merge_request)
end
diff --git a/app/services/merge_requests/ff_merge_service.rb b/app/services/merge_requests/ff_merge_service.rb
index 479e0fe6699..b04a7fcacb8 100644
--- a/app/services/merge_requests/ff_merge_service.rb
+++ b/app/services/merge_requests/ff_merge_service.rb
@@ -12,12 +12,12 @@ module MergeRequests
def commit
repository.ff_merge(current_user,
- source,
- merge_request.target_branch,
- merge_request: merge_request)
+ source,
+ merge_request.target_branch,
+ merge_request: merge_request)
rescue Gitlab::Git::PreReceiveError => e
raise MergeError, e.message
- rescue StandardError => e
+ rescue => e
raise MergeError, "Something went wrong during merge: #{e.message}"
ensure
merge_request.update(in_progress_merge_commit_sha: nil)
diff --git a/app/services/merge_requests/get_urls_service.rb b/app/services/merge_requests/get_urls_service.rb
index 7c88c9abb41..1cb4b991968 100644
--- a/app/services/merge_requests/get_urls_service.rb
+++ b/app/services/merge_requests/get_urls_service.rb
@@ -35,7 +35,7 @@ module MergeRequests
return [] unless project.merge_requests_enabled?
changes_list = Gitlab::ChangesList.new(changes)
- changes_list.map do |change|
+ changes_list.map { |change|
next unless Gitlab::Git.branch_ref?(change[:ref])
# Deleted branch
@@ -46,19 +46,19 @@ module MergeRequests
next if branch_name == project.default_branch
branch_name
- end.compact
+ }.compact
end
def url_for_new_merge_request(branch_name)
- merge_request_params = { source_branch: branch_name }
+ merge_request_params = {source_branch: branch_name}
url = Gitlab::Routing.url_helpers.project_new_merge_request_url(project, merge_request: merge_request_params)
- { branch_name: branch_name, url: url, new_merge_request: true }
+ {branch_name: branch_name, url: url, new_merge_request: true}
end
def url_for_existing_merge_request(merge_request)
target_project = merge_request.target_project
url = Gitlab::Routing.url_helpers.project_merge_request_url(target_project, merge_request)
- { branch_name: merge_request.source_branch, url: url, new_merge_request: false }
+ {branch_name: merge_request.source_branch, url: url, new_merge_request: false}
end
end
end
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb
index 8241e408ce5..4b1dc239488 100644
--- a/app/services/merge_requests/merge_service.rb
+++ b/app/services/merge_requests/merge_service.rb
@@ -11,7 +11,7 @@ module MergeRequests
delegate :merge_jid, :state, to: :@merge_request
def execute(merge_request)
- if project.merge_requests_ff_only_enabled && !self.is_a?(FfMergeService)
+ if project.merge_requests_ff_only_enabled && !is_a?(FfMergeService)
FfMergeService.new(project, current_user, params).execute(merge_request)
return
end
@@ -41,7 +41,7 @@ module MergeRequests
def authorization_check!
unless @merge_request.can_be_merged_by?(current_user)
- raise_error('You are not allowed to merge this merge request')
+ raise_error("You are not allowed to merge this merge request")
end
end
@@ -50,11 +50,11 @@ module MergeRequests
error =
if @merge_request.should_be_rebased?
- 'Only fast-forward merge is allowed for your project. Please update your source branch'
+ "Only fast-forward merge is allowed for your project. Please update your source branch"
elsif !@merge_request.mergeable?
- 'Merge request is not mergeable'
+ "Merge request is not mergeable"
elsif !source
- 'No source for merge'
+ "No source for merge"
end
raise_error(error) if error
@@ -67,7 +67,7 @@ module MergeRequests
if commit_id
log_info("Git merge finished on JID #{merge_jid} commit #{commit_id}")
else
- raise_error('Conflicts detected during merge')
+ raise_error("Conflicts detected during merge")
end
merge_request.update!(merge_commit_sha: commit_id)
@@ -77,10 +77,10 @@ module MergeRequests
repository.merge(current_user, source, merge_request, commit_message)
rescue Gitlab::Git::PreReceiveError => e
handle_merge_error(log_message: e.message)
- raise_error('Something went wrong during merge pre-receive hook')
+ raise_error("Something went wrong during merge pre-receive hook")
rescue => e
handle_merge_error(log_message: e.message)
- raise_error('Something went wrong during merge')
+ raise_error("Something went wrong during merge")
ensure
merge_request.update!(in_progress_merge_commit_sha: nil)
end
@@ -108,7 +108,7 @@ module MergeRequests
# or the source branch may have been updated, or the user may not have permission
#
def delete_source_branch?
- params.fetch('should_remove_source_branch', @merge_request.force_remove_source_branch?) &&
+ params.fetch("should_remove_source_branch", @merge_request.force_remove_source_branch?) &&
@merge_request.can_remove_source_branch?(branch_deletion_user)
end
diff --git a/app/services/merge_requests/merge_to_ref_service.rb b/app/services/merge_requests/merge_to_ref_service.rb
index 586652ae44e..9770af0dffe 100644
--- a/app/services/merge_requests/merge_to_ref_service.rb
+++ b/app/services/merge_requests/merge_to_ref_service.rb
@@ -18,7 +18,7 @@ module MergeRequests
commit_id = commit
- raise_error('Conflicts detected during merge') unless commit_id
+ raise_error("Conflicts detected during merge") unless commit_id
success(commit_id: commit_id)
rescue MergeError => error
@@ -37,17 +37,17 @@ module MergeRequests
error =
if Feature.disabled?(:merge_to_tmp_merge_ref_path, project)
- 'Feature is not enabled'
+ "Feature is not enabled"
elsif !merge_method_supported?
"#{project.human_merge_method} to #{target_ref} is currently not supported."
elsif !hooks_validation_pass?(merge_request)
hooks_validation_error(merge_request)
elsif @merge_request.should_be_rebased?
- 'Fast-forward merge is not possible. Please update your source branch.'
+ "Fast-forward merge is not possible. Please update your source branch."
elsif !@merge_request.mergeable_to_ref?
"Merge request is not mergeable to #{target_ref}"
elsif !source
- 'No source for merge'
+ "No source for merge"
end
raise_error(error) if error
diff --git a/app/services/merge_requests/post_merge_service.rb b/app/services/merge_requests/post_merge_service.rb
index f26e3bee06f..467fc4b05ca 100644
--- a/app/services/merge_requests/post_merge_service.rb
+++ b/app/services/merge_requests/post_merge_service.rb
@@ -14,7 +14,7 @@ module MergeRequests
create_event(merge_request)
create_note(merge_request)
notification_service.merge_mr(merge_request, current_user)
- execute_hooks(merge_request, 'merge')
+ execute_hooks(merge_request, "merge")
invalidate_cache_counts(merge_request, users: merge_request.assignees)
merge_request.update_project_counter_caches
delete_non_latest_diffs(merge_request)
diff --git a/app/services/merge_requests/rebase_service.rb b/app/services/merge_requests/rebase_service.rb
index 31b3ebf311e..9e5842906a3 100644
--- a/app/services/merge_requests/rebase_service.rb
+++ b/app/services/merge_requests/rebase_service.rb
@@ -2,7 +2,7 @@
module MergeRequests
class RebaseService < MergeRequests::WorkingCopyBaseService
- REBASE_ERROR = 'Rebase failed. Please rebase locally'.freeze
+ REBASE_ERROR = "Rebase failed. Please rebase locally"
def execute(merge_request)
@merge_request = merge_request
@@ -16,7 +16,7 @@ module MergeRequests
def rebase
if merge_request.rebase_in_progress?
- log_error('Rebase task canceled: Another rebase is already in progress', save_message_on_model: true)
+ log_error("Rebase task canceled: Another rebase is already in progress", save_message_on_model: true)
return false
end
diff --git a/app/services/merge_requests/refresh_service.rb b/app/services/merge_requests/refresh_service.rb
index f712b8863cd..f131bf76fab 100644
--- a/app/services/merge_requests/refresh_service.rb
+++ b/app/services/merge_requests/refresh_service.rb
@@ -58,10 +58,10 @@ module MergeRequests
.preload(:latest_merge_request_diff)
.where(target_branch: @push.branch_name).to_a
.select(&:diff_head_commit)
- .select do |merge_request|
+ .select { |merge_request|
commit_ids.include?(merge_request.diff_head_sha) &&
- merge_request.merge_request_diff.state != 'empty'
- end
+ merge_request.merge_request_diff.state != "empty"
+ }
merge_requests = filter_merge_requests(merge_requests)
return if merge_requests.empty?
@@ -166,7 +166,8 @@ module MergeRequests
merge_requests_for_source_branch.each do |merge_request|
SystemNoteService.change_branch_presence(
merge_request, merge_request.project, @current_user,
- :source, @push.branch_name, presence)
+ :source, @push.branch_name, presence
+ )
end
end
@@ -177,13 +178,13 @@ module MergeRequests
merge_requests_for_source_branch.each do |merge_request|
mr_commit_ids = Set.new(merge_request.commit_shas)
- new_commits, existing_commits = @commits.partition do |commit|
+ new_commits, existing_commits = @commits.partition { |commit|
mr_commit_ids.include?(commit.id)
- end
+ }
SystemNoteService.add_commits(merge_request, merge_request.project,
- @current_user, new_commits,
- existing_commits, @push.oldrev)
+ @current_user, new_commits,
+ existing_commits, @push.oldrev)
notification_service.push_to_merge_request(merge_request, @current_user, new_commits: new_commits, existing_commits: existing_commits)
end
@@ -195,9 +196,9 @@ module MergeRequests
merge_requests_for_source_branch.each do |merge_request|
commit_shas = merge_request.commit_shas
- wip_commit = @commits.detect do |commit|
+ wip_commit = @commits.detect { |commit|
commit.work_in_progress? && commit_shas.include?(commit.sha)
- end
+ }
if wip_commit && !merge_request.work_in_progress?
merge_request.update(title: merge_request.wip_title)
@@ -214,7 +215,7 @@ module MergeRequests
# Call merge request webhook with update branches
def execute_mr_web_hooks
merge_requests_for_source_branch.each do |merge_request|
- execute_hooks(merge_request, 'update', old_rev: @push.oldrev)
+ execute_hooks(merge_request, "update", old_rev: @push.oldrev)
end
end
diff --git a/app/services/merge_requests/reopen_service.rb b/app/services/merge_requests/reopen_service.rb
index f6cbe769ef4..2df19aba42b 100644
--- a/app/services/merge_requests/reopen_service.rb
+++ b/app/services/merge_requests/reopen_service.rb
@@ -7,9 +7,9 @@ module MergeRequests
if merge_request.reopen
create_event(merge_request)
- create_note(merge_request, 'reopened')
+ create_note(merge_request, "reopened")
notification_service.async.reopen_mr(merge_request, current_user)
- execute_hooks(merge_request, 'reopen')
+ execute_hooks(merge_request, "reopen")
merge_request.reload_diff(current_user)
merge_request.mark_as_unchecked
invalidate_cache_counts(merge_request, users: merge_request.assignees)
diff --git a/app/services/merge_requests/squash_service.rb b/app/services/merge_requests/squash_service.rb
index 9d1a5d5e6d4..423de0baf38 100644
--- a/app/services/merge_requests/squash_service.rb
+++ b/app/services/merge_requests/squash_service.rb
@@ -10,10 +10,10 @@ module MergeRequests
end
if merge_request.squash_in_progress?
- return error('Squash task canceled: another squash is already in progress.')
+ return error("Squash task canceled: another squash is already in progress.")
end
- squash! || error('Failed to squash. Should be done manually.')
+ squash! || error("Failed to squash. Should be done manually.")
end
private
diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb
index 8112c2a4299..7ea2f2de9c7 100644
--- a/app/services/merge_requests/update_service.rb
+++ b/app/services/merge_requests/update_service.rb
@@ -17,7 +17,7 @@ module MergeRequests
end
if params[:force_remove_source_branch].present?
- merge_request.merge_params['force_remove_source_branch'] = params.delete(:force_remove_source_branch)
+ merge_request.merge_params["force_remove_source_branch"] = params.delete(:force_remove_source_branch)
end
handle_wip_event(merge_request)
@@ -34,21 +34,21 @@ module MergeRequests
todo_service.mark_pending_todos_as_done(merge_request, current_user)
end
- if merge_request.previous_changes.include?('title') ||
- merge_request.previous_changes.include?('description')
+ if merge_request.previous_changes.include?("title") ||
+ merge_request.previous_changes.include?("description")
todo_service.update_merge_request(merge_request, current_user, old_mentioned_users)
end
- if merge_request.previous_changes.include?('target_branch')
- create_branch_change_note(merge_request, 'target',
- merge_request.previous_changes['target_branch'].first,
- merge_request.target_branch)
+ if merge_request.previous_changes.include?("target_branch")
+ create_branch_change_note(merge_request, "target",
+ merge_request.previous_changes["target_branch"].first,
+ merge_request.target_branch)
end
- if merge_request.previous_changes.include?('assignee_id')
+ if merge_request.previous_changes.include?("assignee_id")
reassigned_merge_request_args = [merge_request, current_user]
- old_assignee_id = merge_request.previous_changes['assignee_id'].first
+ old_assignee_id = merge_request.previous_changes["assignee_id"].first
reassigned_merge_request_args << User.find(old_assignee_id) if old_assignee_id
create_assignee_note(merge_request)
@@ -56,8 +56,8 @@ module MergeRequests
todo_service.reassigned_merge_request(merge_request, current_user)
end
- if merge_request.previous_changes.include?('target_branch') ||
- merge_request.previous_changes.include?('source_branch')
+ if merge_request.previous_changes.include?("target_branch") ||
+ merge_request.previous_changes.include?("source_branch")
merge_request.mark_as_unchecked
end
@@ -94,7 +94,7 @@ module MergeRequests
merge_request.update(merge_error: nil)
- if merge_request.head_pipeline && merge_request.head_pipeline.active?
+ if merge_request.head_pipeline&.active?
MergeRequests::MergeWhenPipelineSucceedsService.new(project, current_user).execute(merge_request)
else
merge_request.merge_async(current_user.id, {})
@@ -118,7 +118,7 @@ module MergeRequests
def handle_milestone_change(merge_request)
return if skip_milestone_email
- return unless merge_request.previous_changes.include?('milestone_id')
+ return unless merge_request.previous_changes.include?("milestone_id")
if merge_request.milestone.nil?
notification_service.async.removed_milestone_merge_request(merge_request, current_user)
@@ -130,7 +130,8 @@ module MergeRequests
def create_branch_change_note(issuable, branch_type, old_branch, new_branch)
SystemNoteService.change_branch(
issuable, issuable.project, current_user, branch_type,
- old_branch, new_branch)
+ old_branch, new_branch
+ )
end
end
end
diff --git a/app/services/metrics_service.rb b/app/services/metrics_service.rb
index 222a5c8c79c..d076f8032b2 100644
--- a/app/services/metrics_service.rb
+++ b/app/services/metrics_service.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'prometheus/client/formats/text'
+require "prometheus/client/formats/text"
class MetricsService
def prometheus_metrics_text
diff --git a/app/services/milestones/destroy_service.rb b/app/services/milestones/destroy_service.rb
index 87c7a282081..20a3d526a1d 100644
--- a/app/services/milestones/destroy_service.rb
+++ b/app/services/milestones/destroy_service.rb
@@ -4,7 +4,7 @@ module Milestones
class DestroyService < Milestones::BaseService
def execute(milestone)
Milestone.transaction do
- update_params = { milestone: nil, skip_milestone_email: true }
+ update_params = {milestone: nil, skip_milestone_email: true}
milestone.issues.each do |issue|
Issues::UpdateService.new(parent, current_user, update_params).execute(issue)
diff --git a/app/services/milestones/promote_service.rb b/app/services/milestones/promote_service.rb
index cbe5996e8ca..c249d25679e 100644
--- a/app/services/milestones/promote_service.rb
+++ b/app/services/milestones/promote_service.rb
@@ -31,7 +31,7 @@ module Milestones
# Pluck need to be used here instead of select so the array of ids
# is persistent after old milestones gets deleted.
@milestone_ids_for_merge ||= begin
- search_params = { title: group_milestone.title, project_ids: group_project_ids, state: 'all' }
+ search_params = {title: group_milestone.title, project_ids: group_project_ids, state: "all"}
milestones = MilestonesFinder.new(search_params).execute
milestones.pluck(:id)
end
@@ -45,7 +45,7 @@ module Milestones
end
def check_project_milestone!(milestone)
- raise_error('Only project milestones can be promoted.') unless milestone.project_milestone?
+ raise_error("Only project milestones can be promoted.") unless milestone.project_milestone?
end
def clone_project_milestone(milestone)
@@ -73,7 +73,7 @@ module Milestones
# rubocop: enable CodeReuse/ActiveRecord
def group
- @group ||= parent.group || raise_error('Project does not belong to a group.')
+ @group ||= parent.group || raise_error("Project does not belong to a group.")
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/services/milestones/update_service.rb b/app/services/milestones/update_service.rb
index 01ab8b37bac..2e40326b324 100644
--- a/app/services/milestones/update_service.rb
+++ b/app/services/milestones/update_service.rb
@@ -7,9 +7,9 @@ module Milestones
state = params[:state_event]
case state
- when 'activate'
+ when "activate"
Milestones::ReopenService.new(parent, current_user, {}).execute(milestone)
- when 'close'
+ when "close"
Milestones::CloseService.new(parent, current_user, {}).execute(milestone)
end
diff --git a/app/services/note_summary.rb b/app/services/note_summary.rb
index 81f6f92f75c..fbcdd6190e0 100644
--- a/app/services/note_summary.rb
+++ b/app/services/note_summary.rb
@@ -5,8 +5,8 @@ class NoteSummary
attr_reader :metadata
def initialize(noteable, project, author, body, action: nil, commit_count: nil)
- @note = { noteable: noteable, project: project, author: author, note: body }
- @metadata = { action: action, commit_count: commit_count }.compact
+ @note = {noteable: noteable, project: project, author: author, note: body}
+ @metadata = {action: action, commit_count: commit_count}.compact
set_commit_params if note[:noteable].is_a?(Commit)
end
@@ -16,7 +16,7 @@ class NoteSummary
end
def set_commit_params
- note.merge!(noteable_type: 'Commit', commit_id: note[:noteable].id)
+ note.merge!(noteable_type: "Commit", commit_id: note[:noteable].id)
note[:noteable] = nil
end
end
diff --git a/app/services/notes/build_service.rb b/app/services/notes/build_service.rb
index 541f3e0d23c..f527419cd6b 100644
--- a/app/services/notes/build_service.rb
+++ b/app/services/notes/build_service.rb
@@ -11,7 +11,7 @@ module Notes
unless discussion && can?(current_user, :create_note, discussion.noteable)
note = Note.new
- note.errors.add(:base, 'Discussion to reply to cannot be found')
+ note.errors.add(:base, "Discussion to reply to cannot be found")
return note
end
diff --git a/app/services/notes/create_service.rb b/app/services/notes/create_service.rb
index 5a6e7338b42..a1aa1f694bf 100644
--- a/app/services/notes/create_service.rb
+++ b/app/services/notes/create_service.rb
@@ -8,9 +8,9 @@ module Notes
note = Notes::BuildService.new(project, current_user, params).execute
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/37440
- note_valid = Gitlab::GitalyClient.allow_n_plus_1_calls do
+ note_valid = Gitlab::GitalyClient.allow_n_plus_1_calls {
note.valid?
- end
+ }
return note unless note_valid
@@ -20,7 +20,7 @@ module Notes
quick_actions_service = QuickActionsService.new(project, current_user)
if quick_actions_service.supported?(note)
- options = { merge_request_diff_head_sha: merge_request_diff_head_sha }
+ options = {merge_request_diff_head_sha: merge_request_diff_head_sha}
content, command_params = quick_actions_service.extract_commands(note, options)
only_commands = content.empty?
@@ -49,7 +49,7 @@ module Notes
# We must add the error after we call #save because errors are reset
# when #save is called
if only_commands
- note.errors.add(:commands_only, 'Commands applied')
+ note.errors.add(:commands_only, "Commands applied")
end
note.commands_changes = command_params
diff --git a/app/services/notes/quick_actions_service.rb b/app/services/notes/quick_actions_service.rb
index 985a03060bd..e9a2e1b34e0 100644
--- a/app/services/notes/quick_actions_service.rb
+++ b/app/services/notes/quick_actions_service.rb
@@ -3,9 +3,9 @@
module Notes
class QuickActionsService < BaseService
UPDATE_SERVICES = {
- 'Issue' => Issues::UpdateService,
- 'MergeRequest' => MergeRequests::UpdateService,
- 'Commit' => Commits::TagService
+ "Issue" => Issues::UpdateService,
+ "MergeRequest" => MergeRequests::UpdateService,
+ "Commit" => Commits::TagService,
}.freeze
private_constant :UPDATE_SERVICES
diff --git a/app/services/notes/update_service.rb b/app/services/notes/update_service.rb
index d2052bed646..1090794aeb8 100644
--- a/app/services/notes/update_service.rb
+++ b/app/services/notes/update_service.rb
@@ -10,7 +10,7 @@ module Notes
note.update(params.merge(updated_by: current_user))
note.create_new_cross_references!(current_user)
- if note.previous_changes.include?('note')
+ if note.previous_changes.include?("note")
TodoService.new.update_note(note, current_user, old_mentioned_users)
end
diff --git a/app/services/notification_recipient_service.rb b/app/services/notification_recipient_service.rb
index 56f11b31110..940feded269 100644
--- a/app/services/notification_recipient_service.rb
+++ b/app/services/notification_recipient_service.rb
@@ -31,11 +31,11 @@ module NotificationRecipientService
module Builder
class Base
def initialize(*)
- raise 'abstract'
+ raise "abstract"
end
def build!
- raise 'abstract'
+ raise "abstract"
end
def filter!
@@ -47,7 +47,7 @@ module NotificationRecipientService
end
def target
- raise 'abstract'
+ raise "abstract"
end
def project
@@ -293,7 +293,7 @@ module NotificationRecipientService
target.assignees
else
target.assignee
- end
+ end
# We use the `:participating` notification level in order to match existing legacy behavior as captured
# in existing specs (notification_service_spec.rb ~ line 507)
diff --git a/app/services/notification_service.rb b/app/services/notification_service.rb
index 1a65561dd70..1fa1d66c51b 100644
--- a/app/services/notification_service.rb
+++ b/app/services/notification_service.rb
@@ -151,8 +151,8 @@ class NotificationService
end
def push_to_merge_request(merge_request, current_user, new_commits: [], existing_commits: [])
- new_commits = new_commits.map { |c| { short_id: c.short_id, title: c.title } }
- existing_commits = existing_commits.map { |c| { short_id: c.short_id, title: c.title } }
+ new_commits = new_commits.map { |c| {short_id: c.short_id, title: c.title} }
+ existing_commits = existing_commits.map { |c| {short_id: c.short_id, title: c.title} }
recipients = NotificationRecipientService.build_recipients(merge_request, current_user, action: "push_to")
recipients.each do |recipient|
@@ -228,7 +228,7 @@ class NotificationService
end
def reopen_issue(issue, current_user)
- reopen_resource_email(issue, current_user, :issue_status_changed_email, 'reopened')
+ reopen_resource_email(issue, current_user, :issue_status_changed_email, "reopened")
end
def merge_mr(merge_request, current_user)
@@ -245,7 +245,7 @@ class NotificationService
merge_request,
current_user,
:merge_request_status_email,
- 'reopened'
+ "reopened"
)
end
@@ -253,7 +253,8 @@ class NotificationService
recipients = NotificationRecipientService.build_recipients(
merge_request,
current_user,
- action: "resolve_all_discussions")
+ action: "resolve_all_discussions"
+ )
recipients.each do |recipient|
mailer.resolved_all_discussions_email(recipient.user.id, merge_request.id, current_user.id, recipient.reason).deliver_later
@@ -386,7 +387,7 @@ class NotificationService
end
def issue_moved(issue, new_issue, current_user)
- recipients = NotificationRecipientService.build_recipients(issue, current_user, action: 'moved')
+ recipients = NotificationRecipientService.build_recipients(issue, current_user, action: "moved")
recipients.map do |recipient|
email = mailer.issue_moved_email(recipient.user, issue, new_issue, current_user, recipient.reason)
@@ -430,25 +431,25 @@ class NotificationService
end
def pages_domain_verification_succeeded(domain)
- project_maintainers_recipients(domain, action: 'succeeded').each do |recipient|
+ project_maintainers_recipients(domain, action: "succeeded").each do |recipient|
mailer.pages_domain_verification_succeeded_email(domain, recipient.user).deliver_later
end
end
def pages_domain_verification_failed(domain)
- project_maintainers_recipients(domain, action: 'failed').each do |recipient|
+ project_maintainers_recipients(domain, action: "failed").each do |recipient|
mailer.pages_domain_verification_failed_email(domain, recipient.user).deliver_later
end
end
def pages_domain_enabled(domain)
- project_maintainers_recipients(domain, action: 'enabled').each do |recipient|
+ project_maintainers_recipients(domain, action: "enabled").each do |recipient|
mailer.pages_domain_enabled_email(domain, recipient.user).deliver_later
end
end
def pages_domain_disabled(domain)
- project_maintainers_recipients(domain, action: 'disabled').each do |recipient|
+ project_maintainers_recipients(domain, action: "disabled").each do |recipient|
mailer.pages_domain_disabled_email(domain, recipient.user).deliver_later
end
end
@@ -457,7 +458,7 @@ class NotificationService
recipients = NotificationRecipientService.build_recipients(
issue,
issue.author,
- action: 'due',
+ action: "due",
custom_action: :issue_due,
skip_current_user: false
)
@@ -476,7 +477,7 @@ class NotificationService
end
def remote_mirror_update_failed(remote_mirror)
- recipients = project_maintainers_recipients(remote_mirror, action: 'update_failed')
+ recipients = project_maintainers_recipients(remote_mirror, action: "update_failed")
recipients.each do |recipient|
mailer.remote_mirror_update_failed_email(remote_mirror.id, recipient.user.id).deliver_later
@@ -536,7 +537,7 @@ class NotificationService
recipients = NotificationRecipientService.build_recipients(
target,
current_user,
- action: 'removed_milestone'
+ action: "removed_milestone"
)
recipients.each do |recipient|
@@ -548,7 +549,7 @@ class NotificationService
recipients = NotificationRecipientService.build_recipients(
target,
current_user,
- action: 'changed_milestone'
+ action: "changed_milestone"
)
recipients.each do |recipient|
diff --git a/app/services/preview_markdown_service.rb b/app/services/preview_markdown_service.rb
index c1655c38095..1e4e2a2c002 100644
--- a/app/services/preview_markdown_service.rb
+++ b/app/services/preview_markdown_service.rb
@@ -10,14 +10,14 @@ class PreviewMarkdownService < BaseService
text: text,
users: users,
suggestions: suggestions,
- commands: commands.join(' ')
+ commands: commands.join(" ")
)
end
private
def explain_quick_actions(text)
- return text, [] unless %w(Issue MergeRequest Commit).include?(commands_target_type)
+ return text, [] unless %w[Issue MergeRequest Commit].include?(commands_target_type)
quick_actions_service = QuickActions::InterpretService.new(project, current_user)
quick_actions_service.explain(text, find_commands_target)
diff --git a/app/services/projects/after_import_service.rb b/app/services/projects/after_import_service.rb
index bbdde4408d2..3d4849bebff 100644
--- a/app/services/projects/after_import_service.rb
+++ b/app/services/projects/after_import_service.rb
@@ -2,7 +2,7 @@
module Projects
class AfterImportService
- RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join('refs', n, '/') }
+ RESERVED_REF_PREFIXES = Repository::RESERVED_REFS_NAMES.map { |n| File.join("refs", n, "/") }
def initialize(project)
@project = project
@@ -14,7 +14,8 @@ module Projects
end
rescue Projects::HousekeepingService::LeaseTaken => e
Rails.logger.info(
- "Could not perform housekeeping for project #{@project.full_path} (#{@project.id}): #{e}")
+ "Could not perform housekeeping for project #{@project.full_path} (#{@project.id}): #{e}"
+ )
end
private
diff --git a/app/services/projects/auto_devops/disable_service.rb b/app/services/projects/auto_devops/disable_service.rb
index 6608b3da1a8..a2090023892 100644
--- a/app/services/projects/auto_devops/disable_service.rb
+++ b/app/services/projects/auto_devops/disable_service.rb
@@ -29,7 +29,7 @@ module Projects
# rubocop: enable CodeReuse/ActiveRecord
def disable_auto_devops
- project.auto_devops_attributes = { enabled: false }
+ project.auto_devops_attributes = {enabled: false}
project.save!
end
diff --git a/app/services/projects/autocomplete_service.rb b/app/services/projects/autocomplete_service.rb
index 3dad90188cf..0dce88302d1 100644
--- a/app/services/projects/autocomplete_service.rb
+++ b/app/services/projects/autocomplete_service.rb
@@ -4,14 +4,14 @@ module Projects
class AutocompleteService < BaseService
include LabelsAsHash
def issues
- IssuesFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
+ IssuesFinder.new(current_user, project_id: project.id, state: "opened").execute.select([:iid, :title])
end
def milestones
finder_params = {
project_ids: [@project.id],
state: :active,
- order: { due_date: :asc, title: :asc }
+ order: {due_date: :asc, title: :asc},
}
finder_params[:group_ids] = @project.group.self_and_ancestors.select(:id) if @project.group
@@ -20,7 +20,7 @@ module Projects
end
def merge_requests
- MergeRequestsFinder.new(current_user, project_id: project.id, state: 'opened').execute.select([:iid, :title])
+ MergeRequestsFinder.new(current_user, project_id: project.id, state: "opened").execute.select([:iid, :title])
end
def commands(noteable, type)
diff --git a/app/services/projects/base_move_relations_service.rb b/app/services/projects/base_move_relations_service.rb
index 24dec1f3a45..27913105e8d 100644
--- a/app/services/projects/base_move_relations_service.rb
+++ b/app/services/projects/base_move_relations_service.rb
@@ -18,7 +18,7 @@ module Projects
if Gitlab::Database.postgresql?
relation
else
- relation.model.where("#{id_param}": relation.pluck(id_param))
+ relation.model.where(:"#{id_param}" => relation.pluck(id_param))
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/projects/batch_count_service.rb b/app/services/projects/batch_count_service.rb
index aec3b32da89..228d2208a82 100644
--- a/app/services/projects/batch_count_service.rb
+++ b/app/services/projects/batch_count_service.rb
@@ -23,11 +23,11 @@ module Projects
end
def global_count(project)
- raise NotImplementedError, 'global_count must be implemented and return an hash indexed by the project id'
+ raise NotImplementedError, "global_count must be implemented and return an hash indexed by the project id"
end
def count_service
- raise NotImplementedError, 'count_service must be implemented and return a Projects::CountService object'
+ raise NotImplementedError, "count_service must be implemented and return a Projects::CountService object"
end
end
end
diff --git a/app/services/projects/batch_forks_count_service.rb b/app/services/projects/batch_forks_count_service.rb
index 6467744a435..33f6fb67059 100644
--- a/app/services/projects/batch_forks_count_service.rb
+++ b/app/services/projects/batch_forks_count_service.rb
@@ -9,8 +9,8 @@ module Projects
def global_count
@global_count ||= begin
count_service.query(project_ids)
- .group(:forked_from_project_id)
- .count
+ .group(:forked_from_project_id)
+ .count
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/projects/container_repository/cleanup_tags_service.rb b/app/services/projects/container_repository/cleanup_tags_service.rb
index 488290db824..638d9ebde57 100644
--- a/app/services/projects/container_repository/cleanup_tags_service.rb
+++ b/app/services/projects/container_repository/cleanup_tags_service.rb
@@ -4,8 +4,8 @@ module Projects
module ContainerRepository
class CleanupTagsService < BaseService
def execute(container_repository)
- return error('feature disabled') unless can_use?
- return error('access denied') unless can_admin?
+ return error("feature disabled") unless can_use?
+ return error("access denied") unless can_admin?
tags = container_repository.tags
tags_by_digest = group_by_digest(tags)
@@ -25,9 +25,9 @@ module Projects
private
def delete_tags(tags_to_delete, tags_by_digest)
- deleted_digests = group_by_digest(tags_to_delete).select do |digest, tags|
+ deleted_digests = group_by_digest(tags_to_delete).select { |digest, tags|
delete_tag_digest(digest, tags, tags_by_digest[digest])
- end
+ }
deleted_digests.values.flatten
end
@@ -61,7 +61,7 @@ module Projects
end
def filter_by_name(tags)
- regex = Gitlab::UntrustedRegexp.new("\\A#{params['name_regex']}\\z")
+ regex = Gitlab::UntrustedRegexp.new("\\A#{params["name_regex"]}\\z")
tags.select do |tag|
regex.scan(tag.name).any?
@@ -69,13 +69,13 @@ module Projects
end
def filter_keep_n(tags)
- tags.drop(params['keep_n'].to_i)
+ tags.drop(params["keep_n"].to_i)
end
def filter_by_older_than(tags)
- return tags unless params['older_than']
+ return tags unless params["older_than"]
- older_than = ChronicDuration.parse(params['older_than']).seconds.ago
+ older_than = ChronicDuration.parse(params["older_than"]).seconds.ago
tags.select do |tag|
tag.created_at && tag.created_at < older_than
diff --git a/app/services/projects/count_service.rb b/app/services/projects/count_service.rb
index 3cee80c7bbc..28072bc9ce0 100644
--- a/app/services/projects/count_service.rb
+++ b/app/services/projects/count_service.rb
@@ -27,7 +27,7 @@ module Projects
def cache_key(key = nil)
cache_key = key || cache_key_name
- ['projects', 'count_service', VERSION, @project.id, cache_key]
+ ["projects", "count_service", VERSION, @project.id, cache_key]
end
def self.query(project_ids)
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index d03137b63b2..8ea65d00a06 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -61,7 +61,7 @@ module Projects
message = "Unable to save #{e.record.type}: #{e.record.errors.full_messages.join(", ")} "
fail(error: message)
rescue => e
- @project.errors.add(:base, e.message) if @project
+ @project&.errors&.add(:base, e.message)
fail(error: e.message)
end
@@ -114,10 +114,10 @@ module Projects
def create_readme
commit_attrs = {
- branch_name: 'master',
- commit_message: 'Initial commit',
- file_path: 'README.md',
- file_content: "# #{@project.name}\n\n#{@project.description}"
+ branch_name: "master",
+ commit_message: "Initial commit",
+ file_path: "README.md",
+ file_content: "# #{@project.name}\n\n#{@project.description}",
}
Files::CreateService.new(@project, current_user, commit_attrs).execute
@@ -142,7 +142,7 @@ module Projects
end
unless @project.import?
- raise 'Failed to create repository' unless @project.create_repository
+ raise "Failed to create repository" unless @project.create_repository
end
end
end
@@ -191,7 +191,7 @@ module Projects
if @project.errors.empty?
@project.import_state.schedule if @project.import? && !@project.bare_repository_import?
else
- fail(error: @project.errors.full_messages.join(', '))
+ fail(error: @project.errors.full_messages.join(", "))
end
end
end
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb
index b14b31302f5..fd787993fc9 100644
--- a/app/services/projects/destroy_service.rb
+++ b/app/services/projects/destroy_service.rb
@@ -6,7 +6,7 @@ module Projects
DestroyError = Class.new(StandardError)
- DELETED_FLAG = '+deleted'.freeze
+ DELETED_FLAG = "+deleted"
REPO_REMOVAL_DELAY = 5.minutes.to_i
def async_execute
@@ -61,11 +61,11 @@ module Projects
flush_caches(@project)
unless rollback_repository(removal_path(repo_path), repo_path)
- raise_error('Failed to restore project repository. Please contact the administrator.')
+ raise_error("Failed to restore project repository. Please contact the administrator.")
end
unless rollback_repository(removal_path(wiki_path), wiki_path)
- raise_error('Failed to restore wiki repository. Please contact the administrator.')
+ raise_error("Failed to restore wiki repository. Please contact the administrator.")
end
end
@@ -81,11 +81,11 @@ module Projects
def trash_repositories!
unless remove_repository(repo_path)
- raise_error('Failed to remove project repository. Please try again or contact administrator.')
+ raise_error("Failed to remove project repository. Please try again or contact administrator.")
end
unless remove_repository(wiki_path)
- raise_error('Failed to remove wiki repository. Please try again or contact administrator.')
+ raise_error("Failed to remove wiki repository. Please try again or contact administrator.")
end
end
@@ -96,10 +96,10 @@ module Projects
new_path = removal_path(path)
if mv_repository(path, new_path)
- log_info(%Q{Repository "#{path}" moved to "#{new_path}" for project "#{project.full_path}"})
+ log_info(%(Repository "#{path}" moved to "#{new_path}" for project "#{project.full_path}"))
project.run_after_commit do
- GitlabShellWorker.perform_in(REPO_REMOVAL_DELAY, :remove_repository, self.repository_storage, new_path)
+ GitlabShellWorker.perform_in(REPO_REMOVAL_DELAY, :remove_repository, repository_storage, new_path)
end
else
false
@@ -125,7 +125,7 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def repo_exists?(path)
- gitlab_shell.exists?(project.repository_storage, path + '.git')
+ gitlab_shell.exists?(project.repository_storage, path + ".git")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -148,7 +148,7 @@ module Projects
def attempt_destroy_transaction(project)
unless remove_registry_tags
- raise_error('Failed to remove some tags in project container registry. Please try again or contact administrator.')
+ raise_error("Failed to remove some tags in project container registry. Please try again or contact administrator.")
end
project.leave_pool_repository
diff --git a/app/services/projects/detect_repository_languages_service.rb b/app/services/projects/detect_repository_languages_service.rb
index 4a837a4fb6a..ff469f001e4 100644
--- a/app/services/projects/detect_repository_languages_service.rb
+++ b/app/services/projects/detect_repository_languages_service.rb
@@ -39,9 +39,9 @@ module Projects
return existing_languages if detection.languages.size == existing_languages.size
missing_languages = detection.languages - existing_languages.map(&:name)
- created_languages = missing_languages.map do |name|
+ created_languages = missing_languages.map { |name|
create_language(name, detection.language_color(name))
- end
+ }
existing_languages + created_languages
end
diff --git a/app/services/projects/download_service.rb b/app/services/projects/download_service.rb
index dd297c9ba43..060007b4bf2 100644
--- a/app/services/projects/download_service.rb
+++ b/app/services/projects/download_service.rb
@@ -3,7 +3,7 @@
module Projects
class DownloadService < BaseService
WHITELIST = [
- /^[^.]+\.fogbugz.com$/
+ /^[^.]+\.fogbugz.com$/,
].freeze
def initialize(project, url)
@@ -27,7 +27,7 @@ module Projects
end
def http?(url)
- url =~ /\A#{URI.regexp(%w(http https))}\z/
+ url =~ /\A#{URI.regexp(%w[http https])}\z/
end
def valid_domain?(url)
diff --git a/app/services/projects/fetch_statistics_increment_service.rb b/app/services/projects/fetch_statistics_increment_service.rb
index 8644e6bf313..e2525d55361 100644
--- a/app/services/projects/fetch_statistics_increment_service.rb
+++ b/app/services/projects/fetch_statistics_increment_service.rb
@@ -15,10 +15,10 @@ module Projects
SQL
increment_fetch_count_sql += if Gitlab::Database.postgresql?
- "ON CONFLICT (project_id, date) DO UPDATE SET fetch_count = #{table_name}.fetch_count + 1"
- else
- "ON DUPLICATE KEY UPDATE fetch_count = #{table_name}.fetch_count + 1"
- end
+ "ON CONFLICT (project_id, date) DO UPDATE SET fetch_count = #{table_name}.fetch_count + 1"
+ else
+ "ON DUPLICATE KEY UPDATE fetch_count = #{table_name}.fetch_count + 1"
+ end
ActiveRecord::Base.connection.execute(increment_fetch_count_sql)
end
diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb
index fc234bafc57..16982cafa8a 100644
--- a/app/services/projects/fork_service.rb
+++ b/app/services/projects/fork_service.rb
@@ -36,18 +36,18 @@ module Projects
def fork_new_project
new_params = {
- visibility_level: allowed_visibility_level,
- description: @project.description,
- name: target_name,
- path: target_path,
+ visibility_level: allowed_visibility_level,
+ description: @project.description,
+ name: target_name,
+ path: target_path,
shared_runners_enabled: @project.shared_runners_enabled,
- namespace_id: target_namespace.id,
- fork_network: fork_network,
+ namespace_id: target_namespace.id,
+ fork_network: fork_network,
# We need to assign the fork network membership after the project has
# been instantiated to avoid ActiveRecord trying to create it when
# initializing the project, as that would cause a foreign key constraint
# exception.
- relations_block: -> (project) { build_fork_network_member(project) }
+ relations_block: ->(project) { build_fork_network_member(project) },
}
if @project.avatar.present? && @project.avatar.image?
@@ -79,7 +79,7 @@ module Projects
fork_to_project.build_fork_network_member(forked_from_project: @project,
fork_network: fork_network)
else
- fork_to_project.errors.add(:forked_from_project_id, 'is forbidden')
+ fork_to_project.errors.add(:forked_from_project_id, "is forbidden")
end
end
diff --git a/app/services/projects/forks_count_service.rb b/app/services/projects/forks_count_service.rb
index ca85e2dc281..2807ee1555e 100644
--- a/app/services/projects/forks_count_service.rb
+++ b/app/services/projects/forks_count_service.rb
@@ -4,7 +4,7 @@ module Projects
# Service class for getting and caching the number of forks of a project.
class ForksCountService < Projects::CountService
def cache_key_name
- 'forks_count'
+ "forks_count"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/app/services/projects/gitlab_projects_import_service.rb b/app/services/projects/gitlab_projects_import_service.rb
index a315adf42f0..5141e298e06 100644
--- a/app/services/projects/gitlab_projects_import_service.rb
+++ b/app/services/projects/gitlab_projects_import_service.rb
@@ -62,10 +62,10 @@ module Projects
end
if template_file
- params[:import_type] = 'gitlab_project'
+ params[:import_type] = "gitlab_project"
end
- params[:import_data] = { data: data } if data.present?
+ params[:import_data] = {data: data} if data.present?
end
end
end
diff --git a/app/services/projects/hashed_storage/migrate_repository_service.rb b/app/services/projects/hashed_storage/migrate_repository_service.rb
index 9c672283c7e..f1d48d140dc 100644
--- a/app/services/projects/hashed_storage/migrate_repository_service.rb
+++ b/app/services/projects/hashed_storage/migrate_repository_service.rb
@@ -15,7 +15,7 @@ module Projects
result = move_repository(old_disk_path, new_disk_path)
if move_wiki
- result &&= move_repository("#{old_wiki_disk_path}", "#{new_disk_path}.wiki")
+ result &&= move_repository(old_wiki_disk_path.to_s, "#{new_disk_path}.wiki")
end
if result
diff --git a/app/services/projects/import_error_filter.rb b/app/services/projects/import_error_filter.rb
index a0fc5149bb4..1b04468777e 100644
--- a/app/services/projects/import_error_filter.rb
+++ b/app/services/projects/import_error_filter.rb
@@ -5,7 +5,7 @@ module Projects
# included in an error message that could be stored in the DB
class ImportErrorFilter
ERROR_MESSAGE_FILTER = /[^\s]*#{File::SEPARATOR}[^\s]*(?=(\s|\z))/
- FILTER_MESSAGE = '[FILTERED]'
+ FILTER_MESSAGE = "[FILTERED]"
def self.filter_message(message)
message.gsub(ERROR_MESSAGE_FILTER, FILTER_MESSAGE)
diff --git a/app/services/projects/import_export/export_service.rb b/app/services/projects/import_export/export_service.rb
index e3491282a8a..b471fd9ed6b 100644
--- a/app/services/projects/import_export/export_service.rb
+++ b/app/services/projects/import_export/export_service.rb
@@ -62,7 +62,7 @@ module Projects
end
def cleanup_and_notify_error
- Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{@shared.errors.join(', ')}")
+ Rails.logger.error("Import/Export - Project #{project.name} with ID: #{project.id} export error - #{@shared.errors.join(", ")}")
FileUtils.rm_rf(@shared.export_path)
@@ -72,7 +72,7 @@ module Projects
def cleanup_and_notify_error!
cleanup_and_notify_error
- raise Gitlab::ImportExport::Error.new(@shared.errors.join(', '))
+ raise Gitlab::ImportExport::Error.new(@shared.errors.join(", "))
end
def notify_success
diff --git a/app/services/projects/import_service.rb b/app/services/projects/import_service.rb
index 7214e9efaf6..d720e80f1ad 100644
--- a/app/services/projects/import_service.rb
+++ b/app/services/projects/import_service.rb
@@ -25,13 +25,13 @@ module Projects
success
rescue Gitlab::UrlBlocker::BlockedUrlError => e
- Gitlab::Sentry.track_acceptable_exception(e, extra: { project_path: project.full_path, importer: project.import_type })
+ Gitlab::Sentry.track_acceptable_exception(e, extra: {project_path: project.full_path, importer: project.import_type})
error("Error importing repository #{project.safe_import_url} into #{project.full_path} - #{e.message}")
rescue => e
message = Projects::ImportErrorFilter.filter_message(e.message)
- Gitlab::Sentry.track_acceptable_exception(e, extra: { project_path: project.full_path, importer: project.import_type })
+ Gitlab::Sentry.track_acceptable_exception(e, extra: {project_path: project.full_path, importer: project.import_type})
error("Error importing repository #{project.safe_import_url} into #{project.full_path} - #{message}")
end
@@ -61,28 +61,26 @@ module Projects
def create_repository
unless project.create_repository
- raise Error, 'The repository could not be created.'
+ raise Error, "The repository could not be created."
end
end
def import_repository
- begin
- refmap = importer_class.try(:refmap) if has_importer?
-
- if refmap
- project.ensure_repository
- project.repository.fetch_as_mirror(project.import_url, refmap: refmap)
- else
- gitlab_shell.import_project_repository(project)
- end
- rescue Gitlab::Shell::Error => e
- # Expire cache to prevent scenarios such as:
- # 1. First import failed, but the repo was imported successfully, so +exists?+ returns true
- # 2. Retried import, repo is broken or not imported but +exists?+ still returns true
- project.repository.expire_content_cache if project.repository_exists?
+ refmap = importer_class.try(:refmap) if has_importer?
- raise Error, e.message
+ if refmap
+ project.ensure_repository
+ project.repository.fetch_as_mirror(project.import_url, refmap: refmap)
+ else
+ gitlab_shell.import_project_repository(project)
end
+ rescue Gitlab::Shell::Error => e
+ # Expire cache to prevent scenarios such as:
+ # 1. First import failed, but the repo was imported successfully, so +exists?+ returns true
+ # 2. Retried import, repo is broken or not imported but +exists?+ still returns true
+ project.repository.expire_content_cache if project.repository_exists?
+
+ raise Error, e.message
end
def download_lfs_objects
@@ -98,7 +96,7 @@ module Projects
lfs_objects_to_download.each do |lfs_download_object|
Projects::LfsPointers::LfsDownloadService.new(project, lfs_download_object)
- .execute
+ .execute
end
rescue => e
# Right now, to avoid aborting the importing process, we silently fail
@@ -112,7 +110,7 @@ module Projects
project.repository.expire_content_cache unless project.gitlab_project_import?
unless importer.execute
- raise Error, 'The remote data could not be imported.'
+ raise Error, "The remote data could not be imported."
end
end
diff --git a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
index 7998976b00a..2ec7385f190 100644
--- a/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_download_link_list_service.rb
@@ -5,7 +5,7 @@
module Projects
module LfsPointers
class LfsDownloadLinkListService < BaseService
- DOWNLOAD_ACTION = 'download'.freeze
+ DOWNLOAD_ACTION = "download"
DownloadLinksError = Class.new(StandardError)
DownloadLinkNotFound = Class.new(StandardError)
@@ -32,41 +32,39 @@ module Projects
def get_download_links(oids)
response = Gitlab::HTTP.post(remote_uri,
- body: request_body(oids),
- headers: headers)
+ body: request_body(oids),
+ headers: headers)
raise DownloadLinksError, response.message unless response.success?
- parse_response_links(response['objects'])
+ parse_response_links(response["objects"])
end
def parse_response_links(objects_response)
objects_response.each_with_object([]) do |entry, link_list|
- begin
- link = entry.dig('actions', DOWNLOAD_ACTION, 'href')
+ link = entry.dig("actions", DOWNLOAD_ACTION, "href")
- raise DownloadLinkNotFound unless link
+ raise DownloadLinkNotFound unless link
- link_list << LfsDownloadObject.new(oid: entry['oid'],
- size: entry['size'],
- link: add_credentials(link))
- rescue DownloadLinkNotFound, Addressable::URI::InvalidURIError
- log_error("Link for Lfs Object with oid #{entry['oid']} not found or invalid.")
- end
+ link_list << LfsDownloadObject.new(oid: entry["oid"],
+ size: entry["size"],
+ link: add_credentials(link))
+ rescue DownloadLinkNotFound, Addressable::URI::InvalidURIError
+ log_error("Link for Lfs Object with oid #{entry["oid"]} not found or invalid.")
end
end
def request_body(oids)
{
operation: DOWNLOAD_ACTION,
- objects: oids.map { |oid, size| { oid: oid, size: size } }
+ objects: oids.map { |oid, size| {oid: oid, size: size} },
}.to_json
end
def headers
{
- 'Accept' => LfsRequest::CONTENT_TYPE,
- 'Content-Type' => LfsRequest::CONTENT_TYPE
+ "Accept" => LfsRequest::CONTENT_TYPE,
+ "Content-Type" => LfsRequest::CONTENT_TYPE,
}.freeze
end
diff --git a/app/services/projects/lfs_pointers/lfs_download_service.rb b/app/services/projects/lfs_pointers/lfs_download_service.rb
index 398f00a598d..997ecc7f7ef 100644
--- a/app/services/projects/lfs_pointers/lfs_download_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_download_service.rb
@@ -49,12 +49,12 @@ module Projects
def download_and_save_file!(file)
digester = Digest::SHA256.new
- response = Gitlab::HTTP.get(lfs_sanitized_url, download_headers) do |fragment|
+ response = Gitlab::HTTP.get(lfs_sanitized_url, download_headers) { |fragment|
digester << fragment
file.write(fragment)
raise_size_error! if file.size > lfs_size
- end
+ }
raise StandardError, "Received error code #{response.code}" unless response.success?
@@ -63,10 +63,10 @@ module Projects
end
def download_headers
- { stream_body: true }.tap do |headers|
+ {stream_body: true}.tap do |headers|
if lfs_credentials[:user].present? || lfs_credentials[:password].present?
# Using authentication headers in the request
- headers[:basic_auth] = { username: lfs_credentials[:user], password: lfs_credentials[:password] }
+ headers[:basic_auth] = {username: lfs_credentials[:user], password: lfs_credentials[:password]}
end
end
end
@@ -74,18 +74,16 @@ module Projects
def with_tmp_file
create_tmp_storage_dir
- File.open(tmp_filename, 'wb') do |file|
- begin
- yield file
- rescue StandardError => e
- # If the lfs file is successfully downloaded it will be removed
- # when it is added to the project's lfs files.
- # Nevertheless if any excetion raises the file would remain
- # in the file system. Here we ensure to remove it
- File.unlink(file) if File.exist?(file)
-
- raise e
- end
+ File.open(tmp_filename, "wb") do |file|
+ yield file
+ rescue => e
+ # If the lfs file is successfully downloaded it will be removed
+ # when it is added to the project's lfs files.
+ # Nevertheless if any excetion raises the file would remain
+ # in the file system. Here we ensure to remove it
+ File.unlink(file) if File.exist?(file)
+
+ raise e
end
end
@@ -98,7 +96,7 @@ module Projects
end
def tmp_storage_dir
- @tmp_storage_dir ||= File.join(storage_dir, 'tmp', 'download')
+ @tmp_storage_dir ||= File.join(storage_dir, "tmp", "download")
end
def storage_dir
@@ -106,11 +104,11 @@ module Projects
end
def raise_size_error!
- raise SizeError, 'Size mistmatch'
+ raise SizeError, "Size mistmatch"
end
def raise_oid_error!
- raise OidError, 'Oid mismatch'
+ raise OidError, "Oid mismatch"
end
def error(message, http_status = nil)
diff --git a/app/services/projects/lfs_pointers/lfs_import_service.rb b/app/services/projects/lfs_pointers/lfs_import_service.rb
index 9215fa0a7bf..1e5bda516ea 100644
--- a/app/services/projects/lfs_pointers/lfs_import_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_import_service.rb
@@ -8,9 +8,9 @@ module Projects
class LfsImportService < BaseService
include Gitlab::Utils::StrongMemoize
- HEAD_REV = 'HEAD'.freeze
+ HEAD_REV = "HEAD"
LFS_ENDPOINT_PATTERN = /^\t?url\s*=\s*(.+)$/.freeze
- LFS_BATCH_API_ENDPOINT = '/info/lfs/objects/batch'.freeze
+ LFS_BATCH_API_ENDPOINT = "/info/lfs/objects/batch"
LfsImportError = Class.new(StandardError)
@@ -68,13 +68,13 @@ module Projects
end
end
rescue URI::InvalidURIError
- raise LfsImportError, 'Invalid URL in .lfsconfig file'
+ raise LfsImportError, "Invalid URL in .lfsconfig file"
end
def import_uri
@import_uri ||= URI.parse(project.import_url)
rescue URI::InvalidURIError
- raise LfsImportError, 'Invalid project import URL'
+ raise LfsImportError, "Invalid project import URL"
end
def current_endpoint_uri
@@ -85,8 +85,8 @@ module Projects
def default_endpoint_uri
@default_endpoint_uri ||= begin
import_uri.dup.tap do |uri|
- path = uri.path.gsub(%r(/$), '')
- path += '.git' unless path.ends_with?('.git')
+ path = uri.path.gsub(%r{/$}, "")
+ path += ".git" unless path.ends_with?(".git")
uri.path = path + LFS_BATCH_API_ENDPOINT
end
end
diff --git a/app/services/projects/lfs_pointers/lfs_list_service.rb b/app/services/projects/lfs_pointers/lfs_list_service.rb
index 22160017f4f..cbf7d8377ac 100644
--- a/app/services/projects/lfs_pointers/lfs_list_service.rb
+++ b/app/services/projects/lfs_pointers/lfs_list_service.rb
@@ -4,7 +4,7 @@
module Projects
module LfsPointers
class LfsListService < BaseService
- REV = 'HEAD'.freeze
+ REV = "HEAD"
# Retrieve all lfs blob pointers and returns a hash
# with the structure { lfs_file_oid => lfs_file_size }
@@ -12,9 +12,9 @@ module Projects
return {} unless project&.lfs_enabled?
Gitlab::Git::LfsChanges.new(project.repository, REV)
- .all_pointers
- .map! { |blob| [blob.lfs_oid, blob.lfs_size] }
- .to_h
+ .all_pointers
+ .map! { |blob| [blob.lfs_oid, blob.lfs_size] }
+ .to_h
end
end
end
diff --git a/app/services/projects/move_access_service.rb b/app/services/projects/move_access_service.rb
index 8e2c3ad2f69..78538fb11cc 100644
--- a/app/services/projects/move_access_service.rb
+++ b/app/services/projects/move_access_service.rb
@@ -9,7 +9,7 @@ module Projects
if @project.namespace != source_project.namespace
@project.run_after_commit do
source_project.namespace.refresh_project_authorizations
- self.namespace.refresh_project_authorizations
+ namespace.refresh_project_authorizations
end
end
diff --git a/app/services/projects/move_deploy_keys_projects_service.rb b/app/services/projects/move_deploy_keys_projects_service.rb
index b6a3af8c7b8..7a56e191fb4 100644
--- a/app/services/projects/move_deploy_keys_projects_service.rb
+++ b/app/services/projects/move_deploy_keys_projects_service.rb
@@ -23,8 +23,8 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def non_existent_deploy_keys_projects
source_project.deploy_keys_projects
- .joins(:deploy_key)
- .where.not(keys: { fingerprint: @project.deploy_keys.select(:fingerprint) })
+ .joins(:deploy_key)
+ .where.not(keys: {fingerprint: @project.deploy_keys.select(:fingerprint)})
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/projects/move_project_authorizations_service.rb b/app/services/projects/move_project_authorizations_service.rb
index 2985ba89014..c02576fa2b6 100644
--- a/app/services/projects/move_project_authorizations_service.rb
+++ b/app/services/projects/move_project_authorizations_service.rb
@@ -36,8 +36,8 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def non_existent_authorization
source_project.project_authorizations
- .select(:user_id)
- .where.not(user: @project.authorized_users)
+ .select(:user_id)
+ .where.not(user: @project.authorized_users)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/projects/move_project_group_links_service.rb b/app/services/projects/move_project_group_links_service.rb
index 36afcd0c503..707c1171e16 100644
--- a/app/services/projects/move_project_group_links_service.rb
+++ b/app/services/projects/move_project_group_links_service.rb
@@ -37,7 +37,7 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def non_existent_group_links
source_project.project_group_links
- .where.not(group_id: group_links_in_target_project)
+ .where.not(group_id: group_links_in_target_project)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/projects/move_project_members_service.rb b/app/services/projects/move_project_members_service.rb
index faf389241d2..10991e2f42e 100644
--- a/app/services/projects/move_project_members_service.rb
+++ b/app/services/projects/move_project_members_service.rb
@@ -36,8 +36,8 @@ module Projects
# rubocop: disable CodeReuse/ActiveRecord
def non_existent_members
source_project.members
- .select(:id)
- .where.not(user_id: @project.project_members.select(:user_id))
+ .select(:id)
+ .where.not(user_id: @project.project_members.select(:user_id))
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/projects/open_issues_count_service.rb b/app/services/projects/open_issues_count_service.rb
index ee9884e9042..a9629fac6eb 100644
--- a/app/services/projects/open_issues_count_service.rb
+++ b/app/services/projects/open_issues_count_service.rb
@@ -7,8 +7,8 @@ module Projects
include Gitlab::Utils::StrongMemoize
# Cache keys used to store issues count
- PUBLIC_COUNT_KEY = 'public_open_issues_count'.freeze
- TOTAL_COUNT_KEY = 'total_open_issues_count'.freeze
+ PUBLIC_COUNT_KEY = "public_open_issues_count"
+ TOTAL_COUNT_KEY = "total_open_issues_count"
def initialize(project, user = nil)
@user = user
diff --git a/app/services/projects/open_merge_requests_count_service.rb b/app/services/projects/open_merge_requests_count_service.rb
index 76ec13952ab..875c5529aa8 100644
--- a/app/services/projects/open_merge_requests_count_service.rb
+++ b/app/services/projects/open_merge_requests_count_service.rb
@@ -9,7 +9,7 @@ module Projects
end
def cache_key_name
- 'open_merge_requests_count'
+ "open_merge_requests_count"
end
end
end
diff --git a/app/services/projects/overwrite_project_service.rb b/app/services/projects/overwrite_project_service.rb
index 696e1b665b2..53f82a8c632 100644
--- a/app/services/projects/overwrite_project_service.rb
+++ b/app/services/projects/overwrite_project_service.rb
@@ -28,7 +28,7 @@ module Projects
private
def move_before_destroy_relationships(source_project)
- options = { remove_remaining_elements: false }
+ options = {remove_remaining_elements: false}
::Projects::MoveUsersStarProjectsService.new(@project, @current_user).execute(source_project, options)
::Projects::MoveAccessService.new(@project, @current_user).execute(source_project, options)
@@ -47,9 +47,9 @@ module Projects
def rename_project(name, path)
# Update de project's name and path to the original name/path
::Projects::UpdateService.new(@project,
- @current_user,
- { name: name, path: path })
- .execute
+ @current_user,
+ {name: name, path: path})
+ .execute
end
def attempt_restore_repositories(project)
diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb
index 7080f388e53..3e0201ae555 100644
--- a/app/services/projects/participants_service.rb
+++ b/app/services/projects/participants_service.rb
@@ -16,7 +16,7 @@ module Projects
end
def all_members
- [{ username: "all", name: "All Project and Group Members", count: project_members.count }]
+ [{username: "all", name: "All Project and Group Members", count: project_members.count}]
end
end
end
diff --git a/app/services/projects/propagate_service_template.rb b/app/services/projects/propagate_service_template.rb
index 633a263af7b..93c696e3923 100644
--- a/app/services/projects/propagate_service_template.rb
+++ b/app/services/projects/propagate_service_template.rb
@@ -33,12 +33,12 @@ module Projects
end
def bulk_create_from_template(batch)
- service_list = batch.map do |project_id|
+ service_list = batch.map { |project_id|
service_hash.values << project_id
- end
+ }
Project.transaction do
- bulk_insert_services(service_hash.keys << 'project_id', service_list)
+ bulk_insert_services(service_hash.keys << "project_id", service_list)
run_callbacks(batch)
end
end
@@ -64,8 +64,8 @@ module Projects
def bulk_insert_services(columns, values_array)
ActiveRecord::Base.connection.execute(
<<-SQL.strip_heredoc
- INSERT INTO services (#{columns.join(', ')})
- VALUES #{values_array.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
+ INSERT INTO services (#{columns.join(", ")})
+ VALUES #{values_array.map { |tuple| "(#{tuple.join(", ")})" }.join(", ")}
SQL
)
end
@@ -74,7 +74,7 @@ module Projects
def service_hash
@service_hash ||=
begin
- template_hash = @template.as_json(methods: :type).except('id', 'template', 'project_id')
+ template_hash = @template.as_json(methods: :type).except("id", "template", "project_id")
template_hash.each_with_object({}) do |(key, value), service_hash|
value = value.is_a?(Hash) ? value.to_json : value
@@ -103,7 +103,7 @@ module Projects
end
def active_external_wiki?
- @template.type == 'ExternalWikiService'
+ @template.type == "ExternalWikiService"
end
end
end
diff --git a/app/services/projects/protect_default_branch_service.rb b/app/services/projects/protect_default_branch_service.rb
index 245490791bf..2f5795b9289 100644
--- a/app/services/projects/protect_default_branch_service.rb
+++ b/app/services/projects/protect_default_branch_service.rb
@@ -28,8 +28,8 @@ module Projects
def create_protected_branch
params = {
name: default_branch,
- push_access_levels_attributes: [{ access_level: push_access_level }],
- merge_access_levels_attributes: [{ access_level: merge_access_level }]
+ push_access_levels_attributes: [{access_level: push_access_level}],
+ merge_access_levels_attributes: [{access_level: merge_access_level}],
}
# The creator of the project is always allowed to create protected
diff --git a/app/services/projects/transfer_service.rb b/app/services/projects/transfer_service.rb
index 5da1e39a1fb..e108b846010 100644
--- a/app/services/projects/transfer_service.rb
+++ b/app/services/projects/transfer_service.rb
@@ -17,11 +17,11 @@ module Projects
@new_namespace = new_namespace
if @new_namespace.blank?
- raise TransferError, 'Please select a new namespace for your project.'
+ raise TransferError, "Please select a new namespace for your project."
end
unless allowed_transfer?(current_user, project)
- raise TransferError, 'Transfer failed, please contact an admin.'
+ raise TransferError, "Transfer failed, please contact an admin."
end
transfer(project)
@@ -41,16 +41,16 @@ module Projects
def transfer(project)
@old_path = project.full_path
@old_group = project.group
- @new_path = File.join(@new_namespace.try(:full_path) || '', project.path)
+ @new_path = File.join(@new_namespace.try(:full_path) || "", project.path)
@old_namespace = project.namespace
- if Project.where(namespace_id: @new_namespace.try(:id)).where('path = ? or name = ?', project.path, project.name).exists?
+ if Project.where(namespace_id: @new_namespace.try(:id)).where("path = ? or name = ?", project.path, project.name).exists?
raise TransferError.new("Project with same name or path in target namespace already exists")
end
if project.has_container_registry_tags?
# We currently don't support renaming repository if it contains tags in container registry
- raise TransferError.new('Project cannot be transferred, because tags are present in its container registry')
+ raise TransferError.new("Project cannot be transferred, because tags are present in its container registry")
end
attempt_transfer_transaction
diff --git a/app/services/projects/unlink_fork_service.rb b/app/services/projects/unlink_fork_service.rb
index 1b8a920268f..a41aabcf99d 100644
--- a/app/services/projects/unlink_fork_service.rb
+++ b/app/services/projects/unlink_fork_service.rb
@@ -15,10 +15,10 @@ module Projects
end
merge_requests = @project.fork_network
- .merge_requests
- .opened
- .where.not(target_project: @project)
- .from_project(@project)
+ .merge_requests
+ .opened
+ .where.not(target_project: @project)
+ .from_project(@project)
merge_requests.each do |mr|
::MergeRequests::CloseService.new(@project, @current_user).execute(mr)
diff --git a/app/services/projects/update_pages_configuration_service.rb b/app/services/projects/update_pages_configuration_service.rb
index 674071ad92a..66969701c06 100644
--- a/app/services/projects/update_pages_configuration_service.rb
+++ b/app/services/projects/update_pages_configuration_service.rb
@@ -35,7 +35,7 @@ module Projects
domains: pages_domains_config,
https_only: project.pages_https_only?,
id: project.project_id,
- access_control: !project.public_pages?
+ access_control: !project.public_pages?,
}
end
@@ -47,7 +47,7 @@ module Projects
key: domain.key,
https_only: project.pages_https_only? && domain.https?,
id: project.project_id,
- access_control: !project.public_pages?
+ access_control: !project.public_pages?,
}
end
end
@@ -71,16 +71,16 @@ module Projects
end
def pages_config_file
- File.join(pages_path, 'config.json')
+ File.join(pages_path, "config.json")
end
def pages_update_file
- File.join(::Settings.pages.path, '.update')
+ File.join(::Settings.pages.path, ".update")
end
def update_file(file, data)
temp_file = "#{file}.#{SecureRandom.hex(16)}"
- File.open(temp_file, 'w') do |f|
+ File.open(temp_file, "w") do |f|
f.write(data)
end
FileUtils.move(temp_file, file, force: true)
@@ -95,7 +95,7 @@ module Projects
end
def read_file(file)
- File.open(file, 'r') do |f|
+ File.open(file, "r") do |f|
f.read
end
rescue
diff --git a/app/services/projects/update_pages_service.rb b/app/services/projects/update_pages_service.rb
index 5caeb4cfa5f..01f0dd48762 100644
--- a/app/services/projects/update_pages_service.rb
+++ b/app/services/projects/update_pages_service.rb
@@ -7,11 +7,11 @@ module Projects
BLOCK_SIZE = 32.kilobytes
MAX_SIZE = 1.terabyte
- PUBLIC_DIR = 'public'.freeze
+ PUBLIC_DIR = "public"
# this has to be invalid group name,
# as it shares the namespace with groups
- TMP_EXTRACT_PATH = '@pages.tmp'.freeze
+ TMP_EXTRACT_PATH = "@pages.tmp"
attr_reader :build
@@ -27,8 +27,8 @@ module Projects
@status.enqueue!
@status.run!
- raise InvalidStateError, 'missing pages artifacts' unless build.artifacts?
- raise InvalidStateError, 'pages are outdated' unless latest?
+ raise InvalidStateError, "missing pages artifacts" unless build.artifacts?
+ raise InvalidStateError, "pages are outdated" unless latest?
# Create temporary directory in which we will extract the artifacts
make_secure_tmp_dir(tmp_path) do |archive_path|
@@ -36,8 +36,8 @@ module Projects
# Check if we did extract public directory
archive_public_path = File.join(archive_path, PUBLIC_DIR)
- raise InvalidStateError, 'pages miss the public folder' unless Dir.exist?(archive_public_path)
- raise InvalidStateError, 'pages are outdated' unless latest?
+ raise InvalidStateError, "pages miss the public folder" unless Dir.exist?(archive_public_path)
+ raise InvalidStateError, "pages are outdated" unless latest?
deploy_page!(archive_public_path)
success
@@ -71,24 +71,24 @@ module Projects
pipeline: build.pipeline,
user: build.user,
ref: build.ref,
- stage: 'deploy',
- name: 'pages:deploy'
+ stage: "deploy",
+ name: "pages:deploy"
)
end
def extract_archive!(temp_path)
- if artifacts.ends_with?('.zip')
+ if artifacts.ends_with?(".zip")
extract_zip_archive!(temp_path)
else
- raise InvalidStateError, 'unsupported artifacts format'
+ raise InvalidStateError, "unsupported artifacts format"
end
end
def extract_zip_archive!(temp_path)
- raise InvalidStateError, 'missing artifacts metadata' unless build.artifacts_metadata?
+ raise InvalidStateError, "missing artifacts metadata" unless build.artifacts_metadata?
# Calculate page size after extract
- public_entry = build.artifacts_metadata_entry(PUBLIC_DIR + '/', recursive: true)
+ public_entry = build.artifacts_metadata_entry(PUBLIC_DIR + "/", recursive: true)
if public_entry.total_size > max_size
raise InvalidStateError, "artifacts for pages are too large: #{public_entry.total_size}"
diff --git a/app/services/projects/update_service.rb b/app/services/projects/update_service.rb
index 6856009b395..17858dbd1dc 100644
--- a/app/services/projects/update_service.rb
+++ b/app/services/projects/update_service.rb
@@ -30,7 +30,7 @@ module Projects
# rubocop: enable CodeReuse/ActiveRecord
def run_auto_devops_pipeline?
- return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?('enabled')
+ return false if project.repository.gitlab_ci_yml || !project.auto_devops&.previous_changes&.include?("enabled")
project.auto_devops_enabled?
end
@@ -39,11 +39,11 @@ module Projects
def validate!
unless valid_visibility_level_change?(project, params[:visibility_level])
- raise ValidationError.new('New visibility level not allowed!')
+ raise ValidationError.new("New visibility level not allowed!")
end
if renaming_project_with_container_registry_tags?
- raise ValidationError.new('Cannot rename project because it contains container registry tags!')
+ raise ValidationError.new("Cannot rename project because it contains container registry tags!")
end
if changing_default_branch?
@@ -52,11 +52,11 @@ module Projects
end
def after_update
- todos_features_changes = %w(
+ todos_features_changes = %w[
issues_access_level
merge_requests_access_level
repository_access_level
- )
+ ]
project_changed_feature_keys = project.project_feature.previous_changes.keys
if project.previous_changes.include?(:visibility_level) && project.private?
@@ -66,7 +66,7 @@ module Projects
TodosDestroyer::PrivateFeaturesWorker.perform_in(Todo::WAIT_FOR_DELETE, project.id)
end
- if project.previous_changes.include?('path')
+ if project.previous_changes.include?("path")
after_rename_service(project).execute
else
system_hook_service.execute_hooks_for(project, :update)
@@ -77,7 +77,7 @@ module Projects
def after_rename_service(project)
# The path slug the project was using, before the rename took place.
- path_before = project.previous_changes['path'].first
+ path_before = project.previous_changes["path"].first
AfterRenameService.new(project, path_before: path_before, full_path_before: project.full_path_was)
end
@@ -88,7 +88,7 @@ module Projects
def update_failed!
model_errors = project.errors.full_messages.to_sentence
- error_message = model_errors.presence || 'Project could not be updated!'
+ error_message = model_errors.presence || "Project could not be updated!"
error(error_message)
end
@@ -121,7 +121,7 @@ module Projects
ProjectWiki.new(project, project.owner).wiki
rescue ProjectWiki::CouldNotCreateWikiError
log_error("Could not create wiki for #{project.full_name}")
- Gitlab::Metrics.counter(:wiki_can_not_be_created_total, 'Counts the times we failed to create a wiki')
+ Gitlab::Metrics.counter(:wiki_can_not_be_created_total, "Counts the times we failed to create a wiki")
end
def update_pages_config
diff --git a/app/services/prometheus/adapter_service.rb b/app/services/prometheus/adapter_service.rb
index 3be958e1613..673799e5f38 100644
--- a/app/services/prometheus/adapter_service.rb
+++ b/app/services/prometheus/adapter_service.rb
@@ -5,25 +5,21 @@ module Prometheus
def initialize(project, deployment_platform = nil)
@project = project
- @deployment_platform = if deployment_platform
- deployment_platform
- else
- project.deployment_platform
- end
+ @deployment_platform = deployment_platform || project.deployment_platform
end
attr_reader :deployment_platform, :project
def prometheus_adapter
@prometheus_adapter ||= if service_prometheus_adapter.can_query?
- service_prometheus_adapter
- else
- cluster_prometheus_adapter
- end
+ service_prometheus_adapter
+ else
+ cluster_prometheus_adapter
+ end
end
def service_prometheus_adapter
- project.find_or_initialize_service('prometheus')
+ project.find_or_initialize_service("prometheus")
end
def cluster_prometheus_adapter
diff --git a/app/services/protected_branches/access_level_params.rb b/app/services/protected_branches/access_level_params.rb
index a7ef573ff0b..06b10fd98c1 100644
--- a/app/services/protected_branches/access_level_params.rb
+++ b/app/services/protected_branches/access_level_params.rb
@@ -29,7 +29,7 @@ module ProtectedBranches
return [] unless access_level
- [{ access_level: access_level }]
+ [{access_level: access_level}]
end
end
end
diff --git a/app/services/protected_branches/api_service.rb b/app/services/protected_branches/api_service.rb
index 1b13dace5f2..b432728dc75 100644
--- a/app/services/protected_branches/api_service.rb
+++ b/app/services/protected_branches/api_service.rb
@@ -10,7 +10,7 @@ module ProtectedBranches
{
name: params[:name],
push_access_levels_attributes: AccessLevelParams.new(:push, params).access_levels,
- merge_access_levels_attributes: AccessLevelParams.new(:merge, params).access_levels
+ merge_access_levels_attributes: AccessLevelParams.new(:merge, params).access_levels,
}
end
end
diff --git a/app/services/protected_branches/legacy_api_create_service.rb b/app/services/protected_branches/legacy_api_create_service.rb
index aef99a860a0..493fd127320 100644
--- a/app/services/protected_branches/legacy_api_create_service.rb
+++ b/app/services/protected_branches/legacy_api_create_service.rb
@@ -21,8 +21,8 @@ module ProtectedBranches
Gitlab::Access::MAINTAINER
end
- @params.merge!(push_access_levels_attributes: [{ access_level: push_access_level }],
- merge_access_levels_attributes: [{ access_level: merge_access_level }])
+ @params[:push_access_levels_attributes] = [{access_level: push_access_level}]
+ @params[:merge_access_levels_attributes] = [{access_level: merge_access_level}]
service = ProtectedBranches::CreateService.new(@project, @current_user, @params)
service.execute
diff --git a/app/services/protected_branches/legacy_api_update_service.rb b/app/services/protected_branches/legacy_api_update_service.rb
index 7cb8d41818f..c8f0138f490 100644
--- a/app/services/protected_branches/legacy_api_update_service.rb
+++ b/app/services/protected_branches/legacy_api_update_service.rb
@@ -18,16 +18,16 @@ module ProtectedBranches
case developers_can_push
when true
- params[:push_access_levels_attributes] = [{ access_level: Gitlab::Access::DEVELOPER }]
+ params[:push_access_levels_attributes] = [{access_level: Gitlab::Access::DEVELOPER}]
when false
- params[:push_access_levels_attributes] = [{ access_level: Gitlab::Access::MAINTAINER }]
+ params[:push_access_levels_attributes] = [{access_level: Gitlab::Access::MAINTAINER}]
end
case developers_can_merge
when true
- params[:merge_access_levels_attributes] = [{ access_level: Gitlab::Access::DEVELOPER }]
+ params[:merge_access_levels_attributes] = [{access_level: Gitlab::Access::DEVELOPER}]
when false
- params[:merge_access_levels_attributes] = [{ access_level: Gitlab::Access::MAINTAINER }]
+ params[:merge_access_levels_attributes] = [{access_level: Gitlab::Access::MAINTAINER}]
end
service = ProtectedBranches::UpdateService.new(project, current_user, params)
diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb
index 5c58caee8cd..9b1e8bd921a 100644
--- a/app/services/quick_actions/interpret_service.rb
+++ b/app/services/quick_actions/interpret_service.rb
@@ -7,19 +7,19 @@ module QuickActions
attr_reader :issuable
- SHRUG = '¯\\_(ツ)_/¯'.freeze
- TABLEFLIP = '(╯°□°)╯︵ ┻━┻'.freeze
+ SHRUG = '¯\\_(ツ)_/¯'
+ TABLEFLIP = "(╯°□°)╯︵ ┻━┻"
# Takes an issuable and returns an array of all the available commands
# represented with .to_h
def available_commands(issuable)
@issuable = issuable
- self.class.command_definitions.map do |definition|
+ self.class.command_definitions.map { |definition|
next unless definition.available?(self)
definition.to_h(self)
- end.compact
+ }.compact
end
# Takes a text and interprets the commands that are extracted from it.
@@ -67,7 +67,7 @@ module QuickActions
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
command :close do
- @updates[:state_event] = 'close'
+ @updates[:state_event] = "close"
end
desc do
@@ -83,11 +83,11 @@ module QuickActions
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
command :reopen do
- @updates[:state_event] = 'reopen'
+ @updates[:state_event] = "reopen"
end
- desc 'Merge (when the pipeline succeeds)'
- explanation 'Merges this merge request when the pipeline succeeds.'
+ desc "Merge (when the pipeline succeeds)"
+ explanation "Merges this merge request when the pipeline succeeds."
condition do
last_diff_sha = params && params[:merge_request_diff_head_sha]
issuable.is_a?(MergeRequest) &&
@@ -98,11 +98,11 @@ module QuickActions
@updates[:merge] = params[:merge_request_diff_head_sha]
end
- desc 'Change title'
+ desc "Change title"
explanation do |title_param|
"Changes the title to \"#{title_param}\"."
end
- params '<New title>'
+ params "<New title>"
condition do
issuable.persisted? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
@@ -111,7 +111,7 @@ module QuickActions
@updates[:title] = title_param
end
- desc 'Assign'
+ desc "Assign"
# rubocop: disable CodeReuse/ActiveRecord
explanation do |users|
users = issuable.allows_multiple_assignees? ? users : users.take(1)
@@ -119,7 +119,7 @@ module QuickActions
end
# rubocop: enable CodeReuse/ActiveRecord
params do
- issuable.allows_multiple_assignees? ? '@user1 @user2' : '@user'
+ issuable.allows_multiple_assignees? ? "@user1 @user2" : "@user"
end
condition do
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
@@ -140,18 +140,18 @@ module QuickActions
desc do
if issuable.allows_multiple_assignees?
- 'Remove all or specific assignee(s)'
+ "Remove all or specific assignee(s)"
else
- 'Remove assignee'
+ "Remove assignee"
end
end
explanation do |users = nil|
assignees = issuable.assignees
assignees &= users if users.present? && issuable.allows_multiple_assignees?
- "Removes #{'assignee'.pluralize(assignees.size)} #{assignees.map(&:to_reference).to_sentence}."
+ "Removes #{"assignee".pluralize(assignees.size)} #{assignees.map(&:to_reference).to_sentence}."
end
params do
- issuable.allows_multiple_assignees? ? '@user1 @user2' : ''
+ issuable.allows_multiple_assignees? ? "@user1 @user2" : ""
end
condition do
issuable.is_a?(Issuable) &&
@@ -172,14 +172,14 @@ module QuickActions
end
end
- desc 'Set milestone'
+ desc "Set milestone"
explanation do |milestone|
"Sets the milestone to #{milestone.to_reference}." if milestone
end
params '%"milestone"'
condition do
current_user.can?(:"admin_#{issuable.to_ability_name}", project) &&
- find_milestones(project, state: 'active').any?
+ find_milestones(project, state: "active").any?
end
parse_params do |milestone_param|
extract_references(milestone_param, :milestone).first ||
@@ -189,7 +189,7 @@ module QuickActions
@updates[:milestone_id] = milestone.id if milestone
end
- desc 'Remove milestone'
+ desc "Remove milestone"
explanation do
"Removes #{issuable.milestone.to_reference(format: :name)} milestone."
end
@@ -203,11 +203,11 @@ module QuickActions
@updates[:milestone_id] = nil
end
- desc 'Add label(s)'
+ desc "Add label(s)"
explanation do |labels_param|
labels = find_label_references(labels_param)
- "Adds #{labels.join(' ')} #{'label'.pluralize(labels.count)}." if labels.any?
+ "Adds #{labels.join(" ")} #{"label".pluralize(labels.count)}." if labels.any?
end
params '~label1 ~"label 2"'
condition do
@@ -226,13 +226,13 @@ module QuickActions
end
end
- desc 'Remove all or specific label(s)'
+ desc "Remove all or specific label(s)"
explanation do |labels_param = nil|
if labels_param.present?
labels = find_label_references(labels_param)
- "Removes #{labels.join(' ')} #{'label'.pluralize(labels.count)}." if labels.any?
+ "Removes #{labels.join(" ")} #{"label".pluralize(labels.count)}." if labels.any?
else
- 'Removes all labels.'
+ "Removes all labels."
end
end
params '~label1 ~"label 2"'
@@ -257,10 +257,10 @@ module QuickActions
end
end
- desc 'Replace all label(s)'
+ desc "Replace all label(s)"
explanation do |labels_param|
labels = find_label_references(labels_param)
- "Replaces all labels with #{labels.join(' ')} #{'label'.pluralize(labels.count)}." if labels.any?
+ "Replaces all labels with #{labels.join(" ")} #{"label".pluralize(labels.count)}." if labels.any?
end
params '~label1 ~"label 2"'
condition do
@@ -280,11 +280,11 @@ module QuickActions
end
end
- desc 'Copy labels and milestone from other issue or merge request'
+ desc "Copy labels and milestone from other issue or merge request"
explanation do |source_issuable|
"Copy labels and milestone from #{source_issuable.to_reference}."
end
- params '#issue | !merge_request'
+ params "#issue | !merge_request"
condition do
[MergeRequest, Issue].include?(issuable.class) &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
@@ -300,28 +300,28 @@ module QuickActions
end
end
- desc 'Add a todo'
- explanation 'Adds a todo.'
+ desc "Add a todo"
+ explanation "Adds a todo."
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
!TodoService.new.todo_exist?(issuable, current_user)
end
command :todo do
- @updates[:todo_event] = 'add'
+ @updates[:todo_event] = "add"
end
- desc 'Mark todo as done'
- explanation 'Marks todo as done.'
+ desc "Mark todo as done"
+ explanation "Marks todo as done."
condition do
issuable.persisted? &&
TodoService.new.todo_exist?(issuable, current_user)
end
command :done do
- @updates[:todo_event] = 'done'
+ @updates[:todo_event] = "done"
end
- desc 'Subscribe'
+ desc "Subscribe"
explanation do
"Subscribes to this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
@@ -331,10 +331,10 @@ module QuickActions
!issuable.subscribed?(current_user, project)
end
command :subscribe do
- @updates[:subscription_event] = 'subscribe'
+ @updates[:subscription_event] = "subscribe"
end
- desc 'Unsubscribe'
+ desc "Unsubscribe"
explanation do
"Unsubscribes from this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
@@ -344,14 +344,14 @@ module QuickActions
issuable.subscribed?(current_user, project)
end
command :unsubscribe do
- @updates[:subscription_event] = 'unsubscribe'
+ @updates[:subscription_event] = "unsubscribe"
end
- desc 'Set due date'
+ desc "Set due date"
explanation do |due_date|
"Sets the due date to #{due_date.to_s(:medium)}." if due_date
end
- params '<in 2 days | this Friday | December 31st>'
+ params "<in 2 days | this Friday | December 31st>"
condition do
issuable.respond_to?(:due_date) &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
@@ -363,8 +363,8 @@ module QuickActions
@updates[:due_date] = due_date if due_date
end
- desc 'Remove due date'
- explanation 'Removes the due date.'
+ desc "Remove due date"
+ explanation "Removes the due date."
condition do
issuable.persisted? &&
issuable.respond_to?(:due_date) &&
@@ -375,9 +375,9 @@ module QuickActions
@updates[:due_date] = nil
end
- desc 'Toggle the Work In Progress status'
+ desc "Toggle the Work In Progress status"
explanation do
- verb = issuable.work_in_progress? ? 'Unmarks' : 'Marks'
+ verb = issuable.work_in_progress? ? "Unmarks" : "Marks"
noun = issuable.to_ability_name.humanize(capitalize: false)
"#{verb} this #{noun} as Work In Progress."
end
@@ -387,14 +387,14 @@ module QuickActions
(issuable.new_record? || current_user.can?(:"update_#{issuable.to_ability_name}", issuable))
end
command :wip do
- @updates[:wip_event] = issuable.work_in_progress? ? 'unwip' : 'wip'
+ @updates[:wip_event] = issuable.work_in_progress? ? "unwip" : "wip"
end
- desc 'Toggle emoji award'
+ desc "Toggle emoji award"
explanation do |name|
"Toggles :#{name}: emoji award." if name
end
- params ':emoji:'
+ params ":emoji:"
condition do
issuable.is_a?(Issuable) &&
issuable.persisted?
@@ -409,13 +409,13 @@ module QuickActions
end
end
- desc 'Set time estimate'
+ desc "Set time estimate"
explanation do |time_estimate|
time_estimate = Gitlab::TimeTrackingFormatter.output(time_estimate)
"Sets time estimate to #{time_estimate}." if time_estimate
end
- params '<1w 3d 2h 14m>'
+ params "<1w 3d 2h 14m>"
condition do
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
@@ -428,21 +428,21 @@ module QuickActions
end
end
- desc 'Add or subtract spent time'
+ desc "Add or subtract spent time"
explanation do |time_spent, time_spent_date|
if time_spent
if time_spent > 0
- verb = 'Adds'
+ verb = "Adds"
value = time_spent
else
- verb = 'Subtracts'
+ verb = "Subtracts"
value = -time_spent
end
"#{verb} #{Gitlab::TimeTrackingFormatter.output(value)} spent time."
end
end
- params '<time(1h30m | -1h30m)> <date(YYYY-MM-DD)>'
+ params "<time(1h30m | -1h30m)> <date(YYYY-MM-DD)>"
condition do
issuable.is_a?(TimeTrackable) &&
current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
@@ -455,13 +455,13 @@ module QuickActions
@updates[:spend_time] = {
duration: time_spent,
user_id: current_user.id,
- spent_at: time_spent_date
+ spent_at: time_spent_date,
}
end
end
- desc 'Remove time estimate'
- explanation 'Removes time estimate.'
+ desc "Remove time estimate"
+ explanation "Removes time estimate."
condition do
issuable.persisted? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
@@ -470,24 +470,24 @@ module QuickActions
@updates[:time_estimate] = 0
end
- desc 'Remove spent time'
- explanation 'Removes spent time.'
+ desc "Remove spent time"
+ explanation "Removes spent time."
condition do
issuable.persisted? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
command :remove_time_spent do
- @updates[:spend_time] = { duration: :reset, user_id: current_user.id }
+ @updates[:spend_time] = {duration: :reset, user_id: current_user.id}
end
desc "Append the comment with #{SHRUG}"
- params '<Comment>'
+ params "<Comment>"
substitution :shrug do |comment|
"#{comment} #{SHRUG}"
end
desc "Append the comment with #{TABLEFLIP}"
- params '<Comment>'
+ params "<Comment>"
substitution :tableflip do |comment|
"#{comment} #{TABLEFLIP}"
end
@@ -517,15 +517,15 @@ module QuickActions
end
# This is a dummy command, so that it appears in the autocomplete commands
- desc 'CC'
- params '@user'
+ desc "CC"
+ params "@user"
command :cc
- desc 'Set target branch'
+ desc "Set target branch"
explanation do |branch_name|
"Sets target branch to #{branch_name}."
end
- params '<Local branch name>'
+ params "<Local branch name>"
condition do
issuable.respond_to?(:target_branch) &&
(current_user.can?(:"update_#{issuable.to_ability_name}", issuable) ||
@@ -538,7 +538,7 @@ module QuickActions
@updates[:target_branch] = branch_name if project.repository.branch_exists?(branch_name)
end
- desc 'Move issue from one column of the board to another'
+ desc "Move issue from one column of the board to another"
explanation do |target_list_name|
label = find_label_references(target_list_name).first
"Moves issue to #{label} column in the board." if label
@@ -566,11 +566,11 @@ module QuickActions
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Mark this issue as a duplicate of another issue'
+ desc "Mark this issue as a duplicate of another issue"
explanation do |duplicate_reference|
"Marks this issue as a duplicate of #{duplicate_reference}."
end
- params '#issue'
+ params "#issue"
condition do
issuable.is_a?(Issue) &&
issuable.persisted? &&
@@ -584,11 +584,11 @@ module QuickActions
end
end
- desc 'Move this issue to another project.'
+ desc "Move this issue to another project."
explanation do |path_to_project|
"Moves this issue to #{path_to_project}."
end
- params 'path/to/project'
+ params "path/to/project"
condition do
issuable.is_a?(Issue) &&
issuable.persisted? &&
@@ -602,9 +602,9 @@ module QuickActions
end
end
- desc 'Make issue confidential.'
+ desc "Make issue confidential."
explanation do
- 'Makes this issue confidential'
+ "Makes this issue confidential"
end
condition do
issuable.is_a?(Issue) && current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
@@ -613,14 +613,14 @@ module QuickActions
@updates[:confidential] = true
end
- desc 'Tag this commit.'
+ desc "Tag this commit."
explanation do |tag_name, message|
- with_message = %{ with "#{message}"} if message.present?
+ with_message = %( with "#{message}") if message.present?
"Tags this commit to #{tag_name}#{with_message}."
end
- params 'v1.2.3 <message>'
+ params "v1.2.3 <message>"
parse_params do |tag_name_and_message|
- tag_name_and_message.split(' ', 2)
+ tag_name_and_message.split(" ", 2)
end
condition do
issuable.is_a?(Commit) && current_user.can?(:push_code, project)
@@ -630,9 +630,9 @@ module QuickActions
@updates[:tag_message] = message
end
- desc 'Create a merge request.'
+ desc "Create a merge request."
explanation do |branch_name = nil|
- branch_text = branch_name ? "branch '#{branch_name}'" : 'a branch'
+ branch_text = branch_name ? "branch '#{branch_name}'" : "a branch"
"Creates #{branch_text} and a merge request to resolve this issue"
end
params "<branch name>"
@@ -642,7 +642,7 @@ module QuickActions
command :create_merge_request do |branch_name = nil|
@updates[:create_merge_request] = {
branch_name: branch_name,
- issue_iid: issuable.iid
+ issue_iid: issuable.iid,
}
end
@@ -654,10 +654,10 @@ module QuickActions
if users.empty?
users =
- if params.strip == 'me'
+ if params.strip == "me"
[current_user]
else
- User.where(username: params.split(' ').map(&:strip))
+ User.where(username: params.split(" ").map(&:strip))
end
end
@@ -680,7 +680,7 @@ module QuickActions
end
def find_labels(labels_params = nil)
- finder_params = { include_ancestor_groups: true }
+ finder_params = {include_ancestor_groups: true}
finder_params[:project_id] = project.id if project
finder_params[:group_id] = group.id if group
finder_params[:name] = labels_params.split if labels_params
@@ -699,12 +699,12 @@ module QuickActions
end
def explain_commands(commands)
- commands.map do |name, arg|
+ commands.map { |name, arg|
definition = self.class.definition_by_name(name)
next unless definition
definition.explain(self, arg)
- end.compact
+ }.compact
end
def extract_updates(commands)
diff --git a/app/services/quick_actions/target_service.rb b/app/services/quick_actions/target_service.rb
index 69464c3c1ae..798ce95df92 100644
--- a/app/services/quick_actions/target_service.rb
+++ b/app/services/quick_actions/target_service.rb
@@ -4,11 +4,11 @@ module QuickActions
class TargetService < BaseService
def execute(type, type_id)
case type&.downcase
- when 'issue'
+ when "issue"
issue(type_id)
- when 'mergerequest'
+ when "mergerequest"
merge_request(type_id)
- when 'commit'
+ when "commit"
commit(type_id)
end
end
diff --git a/app/services/releases/create_service.rb b/app/services/releases/create_service.rb
index c6e143d440d..0e042ae2756 100644
--- a/app/services/releases/create_service.rb
+++ b/app/services/releases/create_service.rb
@@ -5,8 +5,8 @@ module Releases
include Releases::Concerns
def execute
- return error('Access Denied', 403) unless allowed?
- return error('Release already exists', 409) if release
+ return error("Access Denied", 403) unless allowed?
+ return error("Release already exists", 409) if release
tag = ensure_tag
@@ -22,7 +22,7 @@ module Releases
end
def create_tag
- return error('Ref is not specified', 422) unless ref
+ return error("Ref is not specified", 422) unless ref
result = Tags::CreateService
.new(project, current_user)
@@ -44,7 +44,7 @@ module Releases
author: current_user,
tag: tag.name,
sha: tag.dereferenced_target.sha,
- links_attributes: params.dig(:assets, 'links') || []
+ links_attributes: params.dig(:assets, "links") || []
)
success(tag: tag, release: release)
diff --git a/app/services/releases/destroy_service.rb b/app/services/releases/destroy_service.rb
index 8c2bc3b4e6e..85b0c4801a2 100644
--- a/app/services/releases/destroy_service.rb
+++ b/app/services/releases/destroy_service.rb
@@ -5,14 +5,14 @@ module Releases
include Releases::Concerns
def execute
- return error('Tag does not exist', 404) unless existing_tag
- return error('Release does not exist', 404) unless release
- return error('Access Denied', 403) unless allowed?
+ return error("Tag does not exist", 404) unless existing_tag
+ return error("Release does not exist", 404) unless release
+ return error("Access Denied", 403) unless allowed?
if release.destroy
success(tag: existing_tag, release: release)
else
- error(release.errors.messages || '400 Bad request', 400)
+ error(release.errors.messages || "400 Bad request", 400)
end
end
diff --git a/app/services/releases/update_service.rb b/app/services/releases/update_service.rb
index fabfa398c59..f90e94667c4 100644
--- a/app/services/releases/update_service.rb
+++ b/app/services/releases/update_service.rb
@@ -5,15 +5,15 @@ module Releases
include Releases::Concerns
def execute
- return error('Tag does not exist', 404) unless existing_tag
- return error('Release does not exist', 404) unless release
- return error('Access Denied', 403) unless allowed?
- return error('params is empty', 400) if empty_params?
+ return error("Tag does not exist", 404) unless existing_tag
+ return error("Release does not exist", 404) unless release
+ return error("Access Denied", 403) unless allowed?
+ return error("params is empty", 400) if empty_params?
if release.update(params)
success(tag: existing_tag, release: release)
else
- error(release.errors.messages || '400 Bad request', 400)
+ error(release.errors.messages || "400 Bad request", 400)
end
end
diff --git a/app/services/repository_archive_clean_up_service.rb b/app/services/repository_archive_clean_up_service.rb
index 99a9c834352..b099bb1237e 100644
--- a/app/services/repository_archive_clean_up_service.rb
+++ b/app/services/repository_archive_clean_up_service.rb
@@ -22,12 +22,12 @@ class RepositoryArchiveCleanUpService
private
def clean_up_old_archives
- run(%W(find #{path} -mindepth 1 -maxdepth 3 -type f \( -name \*.tar -o -name \*.bz2 -o -name \*.tar.gz -o -name \*.zip \) -mmin +#{mmin} -delete))
+ run(%W[find #{path} -mindepth 1 -maxdepth 3 -type f \( -name \*.tar -o -name \*.bz2 -o -name \*.tar.gz -o -name \*.zip \) -mmin +#{mmin} -delete])
end
def clean_up_empty_directories
- run(%W(find #{path} -mindepth 2 -maxdepth 2 -type d -empty -delete))
- run(%W(find #{path} -mindepth 1 -maxdepth 1 -type d -empty -delete))
+ run(%W[find #{path} -mindepth 2 -maxdepth 2 -type d -empty -delete])
+ run(%W[find #{path} -mindepth 1 -maxdepth 1 -type d -empty -delete])
end
def run(cmd)
diff --git a/app/services/resource_events/change_labels_service.rb b/app/services/resource_events/change_labels_service.rb
index 039d6e2ebad..ccef073f84f 100644
--- a/app/services/resource_events/change_labels_service.rb
+++ b/app/services/resource_events/change_labels_service.rb
@@ -11,16 +11,16 @@ module ResourceEvents
def execute(added_labels: [], removed_labels: [])
label_hash = {
resource_column(resource) => resource.id,
- user_id: user.id,
- created_at: Time.now
+ :user_id => user.id,
+ :created_at => Time.now,
}
- labels = added_labels.map do |label|
- label_hash.merge(label_id: label.id, action: ResourceLabelEvent.actions['add'])
- end
- labels += removed_labels.map do |label|
- label_hash.merge(label_id: label.id, action: ResourceLabelEvent.actions['remove'])
- end
+ labels = added_labels.map { |label|
+ label_hash.merge(label_id: label.id, action: ResourceLabelEvent.actions["add"])
+ }
+ labels += removed_labels.map { |label|
+ label_hash.merge(label_id: label.id, action: ResourceLabelEvent.actions["remove"])
+ }
Gitlab::Database.bulk_insert(ResourceLabelEvent.table_name, labels)
resource.expire_note_etag_cache
diff --git a/app/services/search/global_service.rb b/app/services/search/global_service.rb
index d6af26d949d..fe8d6e57f6d 100644
--- a/app/services/search/global_service.rb
+++ b/app/services/search/global_service.rb
@@ -14,7 +14,7 @@ module Search
def execute
Gitlab::SearchResults.new(current_user, projects, params[:search],
- default_project_filter: default_project_filter)
+ default_project_filter: default_project_filter)
end
def projects
@@ -29,7 +29,7 @@ module Search
def scope
strong_memoize(:scope) do
- allowed_scopes.include?(params[:scope]) ? params[:scope] : 'projects'
+ allowed_scopes.include?(params[:scope]) ? params[:scope] : "projects"
end
end
end
diff --git a/app/services/search/project_service.rb b/app/services/search/project_service.rb
index f223c8be103..2ec99c290ef 100644
--- a/app/services/search/project_service.rb
+++ b/app/services/search/project_service.rb
@@ -10,13 +10,13 @@ module Search
def execute
Gitlab::ProjectSearchResults.new(current_user,
- project,
- params[:search],
- params[:repository_ref])
+ project,
+ params[:search],
+ params[:repository_ref])
end
def scope
- @scope ||= %w[notes issues merge_requests milestones wiki_blobs commits].delete(params[:scope]) { 'blobs' }
+ @scope ||= %w[notes issues merge_requests milestones wiki_blobs commits].delete(params[:scope]) { "blobs" }
end
end
end
diff --git a/app/services/search/snippet_service.rb b/app/services/search/snippet_service.rb
index e899a36f468..3e9b54b595f 100644
--- a/app/services/search/snippet_service.rb
+++ b/app/services/search/snippet_service.rb
@@ -15,7 +15,7 @@ module Search
end
def scope
- @scope ||= %w[snippet_titles].delete(params[:scope]) { 'snippet_blobs' }
+ @scope ||= %w[snippet_titles].delete(params[:scope]) { "snippet_blobs" }
end
end
end
diff --git a/app/services/search_service.rb b/app/services/search_service.rb
index e0cbfac2420..f5852628d8f 100644
--- a/app/services/search_service.rb
+++ b/app/services/search_service.rb
@@ -16,8 +16,6 @@ class SearchService
if params[:project_id].present?
the_project = Project.find_by(id: params[:project_id])
can?(current_user, :read_project, the_project) ? the_project : nil
- else
- nil
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -30,8 +28,6 @@ class SearchService
if params[:group_id].present?
the_group = Group.find_by(id: params[:group_id])
can?(current_user, :read_group, the_group) ? the_group : nil
- else
- nil
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -39,7 +35,7 @@ class SearchService
def show_snippets?
return @show_snippets if defined?(@show_snippets)
- @show_snippets = params[:snippets] == 'true'
+ @show_snippets = params[:snippets] == "true"
end
delegate :scope, to: :search_service
diff --git a/app/services/spam_service.rb b/app/services/spam_service.rb
index f2f133dae28..41d82dc116c 100644
--- a/app/services/spam_service.rb
+++ b/app/services/spam_service.rb
@@ -10,9 +10,9 @@ class SpamService
@options = {}
if @request
- @options[:ip_address] = @request.env['action_dispatch.remote_ip'].to_s
- @options[:user_agent] = @request.env['HTTP_USER_AGENT']
- @options[:referrer] = @request.env['HTTP_REFERRER']
+ @options[:ip_address] = @request.env["action_dispatch.remote_ip"].to_s
+ @options[:user_agent] = @request.env["HTTP_USER_AGENT"]
+ @options[:referrer] = @request.env["HTTP_REFERRER"]
else
@options[:ip_address] = @spammable.ip_address
@options[:user_agent] = @spammable.user_agent
@@ -87,7 +87,7 @@ class SpamService
source_ip: options[:ip_address],
user_agent: options[:user_agent],
noteable_type: spammable.class.to_s,
- via_api: api
+ via_api: api,
}
)
end
diff --git a/app/services/submit_usage_ping_service.rb b/app/services/submit_usage_ping_service.rb
index 62222d3fd2a..c98ee9c0989 100644
--- a/app/services/submit_usage_ping_service.rb
+++ b/app/services/submit_usage_ping_service.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class SubmitUsagePingService
- URL = 'https://version.gitlab.com/usage_data'.freeze
+ URL = "https://version.gitlab.com/usage_data"
METRICS = %w[leader_issues instance_issues percentage_issues leader_notes instance_notes
percentage_notes leader_milestones instance_milestones percentage_milestones
@@ -21,7 +21,7 @@ class SubmitUsagePingService
URL,
body: Gitlab::UsageData.to_json(force_refresh: true),
allow_local_requests: true,
- headers: { 'Content-type' => 'application/json' }
+ headers: {"Content-type" => "application/json"}
)
store_metrics(response)
@@ -36,10 +36,10 @@ class SubmitUsagePingService
private
def store_metrics(response)
- return unless response['conv_index'].present?
+ return unless response["conv_index"].present?
ConversationalDevelopmentIndex::Metric.create!(
- response['conv_index'].slice(*METRICS)
+ response["conv_index"].slice(*METRICS)
)
end
end
diff --git a/app/services/submodules/update_service.rb b/app/services/submodules/update_service.rb
index a6011a920bd..803cc5f4744 100644
--- a/app/services/submodules/update_service.rb
+++ b/app/services/submodules/update_service.rb
@@ -16,23 +16,23 @@ module Submodules
def validate!
super
- raise ValidationError, 'The repository is empty' if repository.empty?
+ raise ValidationError, "The repository is empty" if repository.empty?
end
def execute
super
- rescue StandardError => e
+ rescue => e
error(e.message)
end
def create_commit!
repository.update_submodule(current_user,
- @submodule,
- @commit_sha,
- message: @commit_message,
- branch: @branch_name)
+ @submodule,
+ @commit_sha,
+ message: @commit_message,
+ branch: @branch_name)
rescue ArgumentError, TypeError
- raise ValidationError, 'Invalid parameters'
+ raise ValidationError, "Invalid parameters"
end
end
end
diff --git a/app/services/suggestions/apply_service.rb b/app/services/suggestions/apply_service.rb
index f778c5aa5f5..3b7ea5bc87d 100644
--- a/app/services/suggestions/apply_service.rb
+++ b/app/services/suggestions/apply_service.rb
@@ -8,17 +8,17 @@ module Suggestions
def execute(suggestion)
unless suggestion.appliable?
- return error('Suggestion is not appliable')
+ return error("Suggestion is not appliable")
end
unless latest_source_head?(suggestion)
- return error('The file has been changed')
+ return error("The file has been changed")
end
diff_file = suggestion.note.latest_diff_file
unless diff_file
- return error('The file was not found')
+ return error("The file was not found")
end
params = file_update_params(suggestion, diff_file)
@@ -30,7 +30,7 @@ module Suggestions
result
rescue Files::UpdateService::FileChangedError
- error('The file has been changed')
+ error("The file has been changed")
end
private
@@ -53,8 +53,8 @@ module Suggestions
file_last_commit =
Gitlab::Git::Commit.last_for_path(suggestion.project.repository,
- blob.commit_id,
- blob.path)
+ blob.commit_id,
+ blob.path)
{
file_path: file_path,
@@ -62,7 +62,7 @@ module Suggestions
start_branch: branch_name,
commit_message: commit_message,
file_content: file_content,
- last_commit_sha: file_last_commit&.id
+ last_commit_sha: file_last_commit&.id,
}
end
diff --git a/app/services/suggestions/create_service.rb b/app/services/suggestions/create_service.rb
index c7ac2452c53..5ba6b83164f 100644
--- a/app/services/suggestions/create_service.rb
+++ b/app/services/suggestions/create_service.rb
@@ -23,7 +23,7 @@ module Suggestions
comment_line = @note.position.new_line
rows =
- suggestions.map.with_index do |suggestion, index|
+ suggestions.map.with_index { |suggestion, index|
from_content = changing_lines(diff_file, comment_line, comment_line)
# The parsed suggestion doesn't have information about the correct
@@ -37,12 +37,12 @@ module Suggestions
note_id: @note.id,
from_content: from_content,
to_content: to_content,
- relative_order: index
+ relative_order: index,
}
- end
+ }
rows.in_groups_of(100, false) do |rows|
- Gitlab::Database.bulk_insert('suggestions', rows)
+ Gitlab::Database.bulk_insert("suggestions", rows)
end
end
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb
index bd3907cdf8e..5e24ee7541a 100644
--- a/app/services/system_hooks_service.rb
+++ b/app/services/system_hooks_service.rb
@@ -11,7 +11,7 @@ class SystemHooksService
def execute_hooks(data, hooks_scope = :all)
SystemHook.hooks_for(hooks_scope).find_each do |hook|
- hook.async_execute(data, 'system_hooks')
+ hook.async_execute(data, "system_hooks")
end
Gitlab::Plugin.execute_all_async(data)
@@ -23,15 +23,13 @@ class SystemHooksService
data = {
event_name: build_event_name(model, event),
created_at: model.created_at&.xmlschema,
- updated_at: model.updated_at&.xmlschema
+ updated_at: model.updated_at&.xmlschema,
}
case model
when Key
- data.merge!(
- key: model.key,
- id: model.id
- )
+ data[:key] = model.key
+ data[:id] = model.id
if model.user
data[:username] = model.user.username
@@ -57,10 +55,8 @@ class SystemHooksService
data.merge!(group_data(model))
if event == :rename
- data.merge!(
- old_path: model.path_was,
- old_full_path: model.full_path_was
- )
+ data[:old_path] = model.path_was
+ data[:old_full_path] = model.full_path_was
end
when GroupMember
data.merge!(group_member_data(model))
@@ -75,8 +71,8 @@ class SystemHooksService
return "user_add_to_team" if event == :create
return "user_remove_from_team" if event == :destroy
when GroupMember
- return 'user_add_to_group' if event == :create
- return 'user_remove_from_group' if event == :destroy
+ return "user_add_to_group" if event == :create
+ return "user_remove_from_group" if event == :destroy
else
"#{model.class.name.downcase}_#{event}"
end
@@ -92,7 +88,7 @@ class SystemHooksService
project_id: model.id,
owner_name: owner.name,
owner_email: owner.respond_to?(:email) ? owner.email : "",
- project_visibility: model.visibility.downcase
+ project_visibility: model.visibility.downcase,
}
end
@@ -100,16 +96,16 @@ class SystemHooksService
project = model.project || Project.unscoped.find(model.source_id)
{
- project_name: project.name,
- project_path: project.path,
- project_path_with_namespace: project.full_path,
- project_id: project.id,
- user_username: model.user.username,
- user_name: model.user.name,
- user_email: model.user.email,
- user_id: model.user.id,
- access_level: model.human_access,
- project_visibility: Project.visibility_levels.key(project.visibility_level_value).downcase
+ project_name: project.name,
+ project_path: project.path,
+ project_path_with_namespace: project.full_path,
+ project_id: project.id,
+ user_username: model.user.username,
+ user_name: model.user.name,
+ user_email: model.user.email,
+ user_id: model.user.id,
+ access_level: model.human_access,
+ project_visibility: Project.visibility_levels.key(project.visibility_level_value).downcase,
}
end
@@ -122,7 +118,7 @@ class SystemHooksService
full_path: model.full_path,
group_id: model.id,
owner_name: owner.try(:name),
- owner_email: owner.try(:email)
+ owner_email: owner.try(:email),
}
end
@@ -135,7 +131,7 @@ class SystemHooksService
user_name: model.user.name,
user_email: model.user.email,
user_id: model.user.id,
- group_access: model.human_access
+ group_access: model.human_access,
}
end
@@ -144,7 +140,7 @@ class SystemHooksService
name: model.name,
email: model.email,
user_id: model.id,
- username: model.username
+ username: model.username,
}
end
end
diff --git a/app/services/system_note_service.rb b/app/services/system_note_service.rb
index ea8ac7e4656..c77bce01f09 100644
--- a/app/services/system_note_service.rb
+++ b/app/services/system_note_service.rb
@@ -29,7 +29,7 @@ module SystemNoteService
body = text_parts.join("\n\n")
- create_note(NoteSummary.new(noteable, project, author, body, action: 'commit', commit_count: total_count))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "commit", commit_count: total_count))
end
# Called when a commit was tagged
@@ -44,7 +44,7 @@ module SystemNoteService
link = url_helpers.project_tag_url(project, id: tag_name)
body = "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'tag'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "tag"))
end
# Called when the assignee of a Noteable is changed or removed
@@ -62,9 +62,9 @@ module SystemNoteService
#
# Returns the created Note object
def change_assignee(noteable, project, author, assignee)
- body = assignee.nil? ? 'removed assignee' : "assigned to #{assignee.to_reference}"
+ body = assignee.nil? ? "removed assignee" : "assigned to #{assignee.to_reference}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'assignee'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "assignee"))
end
# Called when the assignees of an Issue is changed or removed
@@ -93,9 +93,9 @@ module SystemNoteService
text_parts << "assigned to #{added_users.map(&:to_reference).to_sentence}" if added_users.any?
text_parts << "unassigned #{unassigned_users.map(&:to_reference).to_sentence}" if unassigned_users.any?
- body = text_parts.join(' and ')
+ body = text_parts.join(" and ")
- create_note(NoteSummary.new(issue, project, author, body, action: 'assignee'))
+ create_note(NoteSummary.new(issue, project, author, body, action: "assignee"))
end
# Called when the milestone of a Noteable is changed
@@ -114,9 +114,9 @@ module SystemNoteService
# Returns the created Note object
def change_milestone(noteable, project, author, milestone)
format = milestone&.group_milestone? ? :name : :iid
- body = milestone.nil? ? 'removed milestone' : "changed milestone to #{milestone.to_reference(project, format: format)}"
+ body = milestone.nil? ? "removed milestone" : "changed milestone to #{milestone.to_reference(project, format: format)}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'milestone'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "milestone"))
end
# Called when the due_date of a Noteable is changed
@@ -134,9 +134,9 @@ module SystemNoteService
#
# Returns the created Note object
def change_due_date(noteable, project, author, due_date)
- body = due_date ? "changed due date to #{due_date.to_s(:long)}" : 'removed due date'
+ body = due_date ? "changed due date to #{due_date.to_s(:long)}" : "removed due date"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'due_date'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "due_date"))
end
# Called when the estimated time of a Noteable is changed
@@ -156,12 +156,12 @@ module SystemNoteService
def change_time_estimate(noteable, project, author)
parsed_time = Gitlab::TimeTrackingFormatter.output(noteable.time_estimate)
body = if noteable.time_estimate == 0
- "removed time estimate"
- else
- "changed time estimate to #{parsed_time}"
- end
+ "removed time estimate"
+ else
+ "changed time estimate to #{parsed_time}"
+ end
- create_note(NoteSummary.new(noteable, project, author, body, action: 'time_tracking'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "time_tracking"))
end
# Called when the spent time of a Noteable is changed
@@ -186,14 +186,14 @@ module SystemNoteService
else
spent_at = noteable.spent_at
parsed_time = Gitlab::TimeTrackingFormatter.output(time_spent.abs)
- action = time_spent > 0 ? 'added' : 'subtracted'
+ action = time_spent > 0 ? "added" : "subtracted"
text_parts = ["#{action} #{parsed_time} of time spent"]
text_parts << "at #{spent_at}" if spent_at
- body = text_parts.join(' ')
+ body = text_parts.join(" ")
end
- create_note(NoteSummary.new(noteable, project, author, body, action: 'time_tracking'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "time_tracking"))
end
# Called when the status of a Noteable is changed
@@ -215,7 +215,7 @@ module SystemNoteService
body = status.dup
body << " via #{source.gfm_reference(project)}" if source
- action = status == 'reopened' ? 'opened' : status
+ action = status == "reopened" ? "opened" : status
create_note(NoteSummary.new(noteable, project, author, body, action: action))
end
@@ -224,14 +224,14 @@ module SystemNoteService
def merge_when_pipeline_succeeds(noteable, project, author, last_commit)
body = "enabled an automatic merge when the pipeline for #{last_commit.to_reference(project)} succeeds"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'merge'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "merge"))
end
# Called when 'merge when pipeline succeeds' is canceled
def cancel_merge_when_pipeline_succeeds(noteable, project, author)
- body = 'canceled the automatic merge'
+ body = "canceled the automatic merge"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'merge'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "merge"))
end
def handle_merge_request_wip(noteable, project, author)
@@ -239,19 +239,19 @@ module SystemNoteService
body = "#{prefix} as a **Work In Progress**"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'title'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "title"))
end
def add_merge_request_wip_from_commit(noteable, project, author, commit)
body = "marked as a **Work In Progress** from #{commit.to_reference(project)}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'title'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "title"))
end
def resolve_all_discussions(merge_request, project, author)
body = "resolved all discussions"
- create_note(NoteSummary.new(merge_request, project, author, body, action: 'discussion'))
+ create_note(NoteSummary.new(merge_request, project, author, body, action: "discussion"))
end
def discussion_continued_in_issue(discussion, project, author, issue)
@@ -259,7 +259,7 @@ module SystemNoteService
note_attributes = discussion.reply_attributes.merge(project: project, author: author, note: body)
note = Note.create(note_attributes.merge(system: true))
- note.system_note_metadata = SystemNoteMetadata.new(action: 'discussion')
+ note.system_note_metadata = SystemNoteMetadata.new(action: "discussion")
note
end
@@ -279,11 +279,11 @@ module SystemNoteService
text_parts << "version #{version_index} of the diff"
end
- body = text_parts.join(' ')
+ body = text_parts.join(" ")
note_attributes = discussion.reply_attributes.merge(project: project, author: author, note: body)
note = Note.create(note_attributes.merge(system: true))
- note.system_note_metadata = SystemNoteMetadata.new(action: 'outdated')
+ note.system_note_metadata = SystemNoteMetadata.new(action: "outdated")
note
end
@@ -310,7 +310,7 @@ module SystemNoteService
body = "changed title from **#{marked_old_title}** to **#{marked_new_title}**"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'title'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "title"))
end
# Called when the description of a Noteable is changed
@@ -325,9 +325,9 @@ module SystemNoteService
#
# Returns the created Note object
def change_description(noteable, project, author)
- body = 'changed the description'
+ body = "changed the description"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'description'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "description"))
end
# Called when the confidentiality changes
@@ -343,11 +343,11 @@ module SystemNoteService
# Returns the created Note object
def change_issue_confidentiality(issue, project, author)
if issue.confidential
- body = 'made the issue confidential'
- action = 'confidential'
+ body = "made the issue confidential"
+ action = "confidential"
else
- body = 'made the issue visible to everyone'
- action = 'visible'
+ body = "made the issue visible to everyone"
+ action = "visible"
end
create_note(NoteSummary.new(issue, project, author, body, action: action))
@@ -370,7 +370,7 @@ module SystemNoteService
def change_branch(noteable, project, author, branch_type, old_branch, new_branch)
body = "changed #{branch_type} branch from `#{old_branch}` to `#{new_branch}`"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'branch'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "branch"))
end
# Called when a branch in Noteable is added or deleted
@@ -390,14 +390,14 @@ module SystemNoteService
def change_branch_presence(noteable, project, author, branch_type, branch, presence)
verb =
if presence == :add
- 'restored'
+ "restored"
else
- 'deleted'
+ "deleted"
end
body = "#{verb} #{branch_type} branch `#{branch}`"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'branch'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "branch"))
end
# Called when a branch is created from the 'new branch' button on a issue
@@ -409,13 +409,13 @@ module SystemNoteService
body = "created branch [`#{branch}`](#{link}) to address this issue"
- create_note(NoteSummary.new(issue, project, author, body, action: 'branch'))
+ create_note(NoteSummary.new(issue, project, author, body, action: "branch"))
end
def new_merge_request(issue, project, author, merge_request)
body = "created merge request #{merge_request.to_reference} to address this issue"
- create_note(NoteSummary.new(issue, project, author, body, action: 'merge'))
+ create_note(NoteSummary.new(issue, project, author, body, action: "merge"))
end
# Called when a Mentionable references a Noteable
@@ -444,7 +444,7 @@ module SystemNoteService
if noteable.is_a?(ExternalIssue)
noteable.project.issues_tracker.create_cross_reference_note(noteable, mentioner, author)
else
- create_note(NoteSummary.new(noteable, noteable.project, author, body, action: 'cross_reference'))
+ create_note(NoteSummary.new(noteable, noteable.project, author, body, action: "cross_reference"))
end
end
@@ -489,7 +489,7 @@ module SystemNoteService
# Returns an Array of Strings
def new_commit_summary(new_commits)
new_commits.collect do |commit|
- content_tag('li', "#{commit.short_id} - #{commit.title}")
+ content_tag("li", "#{commit.short_id} - #{commit.title}")
end
end
@@ -509,7 +509,7 @@ module SystemNoteService
status_label = new_task.complete? ? Taskable::COMPLETED : Taskable::INCOMPLETE
body = "marked the task **#{new_task.source}** as #{status_label}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'task'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "task"))
end
# Called when noteable has been moved to another project
@@ -532,7 +532,7 @@ module SystemNoteService
cross_reference = noteable_ref.to_reference(project)
body = "moved #{direction} #{cross_reference}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'moved'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "moved"))
end
# Called when a Noteable has been marked as a duplicate of another Issue
@@ -551,7 +551,7 @@ module SystemNoteService
# Returns the created Note object
def mark_duplicate_issue(noteable, project, author, canonical_issue)
body = "marked this issue as a duplicate of #{canonical_issue.to_reference(project)}"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'duplicate'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "duplicate"))
end
# Called when a Noteable has been marked as the canonical Issue of a duplicate
@@ -570,11 +570,11 @@ module SystemNoteService
# Returns the created Note object
def mark_canonical_issue_of_duplicate(noteable, project, author, duplicate_issue)
body = "marked #{duplicate_issue.to_reference(project)} as a duplicate of this issue"
- create_note(NoteSummary.new(noteable, project, author, body, action: 'duplicate'))
+ create_note(NoteSummary.new(noteable, project, author, body, action: "duplicate"))
end
def discussion_lock(issuable, author)
- action = issuable.discussion_locked? ? 'locked' : 'unlocked'
+ action = issuable.discussion_locked? ? "locked" : "unlocked"
body = "#{action} this #{issuable.class.to_s.titleize.downcase}"
create_note(NoteSummary.new(issuable, issuable.project, author, body, action: action))
@@ -590,7 +590,7 @@ module SystemNoteService
def notes_for_mentioner(mentioner, noteable, notes)
if mentioner.is_a?(Commit)
text = "#{cross_reference_note_prefix}%#{mentioner.to_reference(nil)}"
- notes.where('(note LIKE ? OR note LIKE ?)', text, text.capitalize)
+ notes.where("(note LIKE ? OR note LIKE ?)", text, text.capitalize)
else
gfm_reference = mentioner.gfm_reference(noteable.project || noteable.group)
text = cross_reference_note_content(gfm_reference)
@@ -607,7 +607,7 @@ module SystemNoteService
end
def cross_reference_note_prefix
- 'mentioned in '
+ "mentioned in "
end
def cross_reference_note_content(gfm_reference)
@@ -621,7 +621,7 @@ module SystemNoteService
existing_commit_summary = existing_commit_summary(noteable, existing_commits, oldrev)
new_commit_summary = new_commit_summary(new_commits).join
- content_tag('ul', "#{existing_commit_summary}#{new_commit_summary}".html_safe)
+ content_tag("ul", "#{existing_commit_summary}#{new_commit_summary}".html_safe)
end
# Build a single line summarizing existing commits being added in a merge
@@ -641,27 +641,27 @@ module SystemNoteService
#
# Returns a newline-terminated String
def existing_commit_summary(noteable, existing_commits, oldrev = nil)
- return '' if existing_commits.empty?
+ return "" if existing_commits.empty?
count = existing_commits.size
commit_ids = if count == 1
- existing_commits.first.short_id
- else
- if oldrev && !Gitlab::Git.blank_ref?(oldrev)
- "#{Commit.truncate_sha(oldrev)}...#{existing_commits.last.short_id}"
- else
- "#{existing_commits.first.short_id}..#{existing_commits.last.short_id}"
- end
- end
+ existing_commits.first.short_id
+ else
+ if oldrev && !Gitlab::Git.blank_ref?(oldrev)
+ "#{Commit.truncate_sha(oldrev)}...#{existing_commits.last.short_id}"
+ else
+ "#{existing_commits.first.short_id}..#{existing_commits.last.short_id}"
+ end
+ end
commits_text = "#{count} commit".pluralize(count)
branch = noteable.target_branch
branch = "#{noteable.target_project_namespace}:#{branch}" if noteable.for_fork?
- branch_name = content_tag('code', branch)
- content_tag('li', "#{commit_ids} - #{commits_text} from branch #{branch_name}".html_safe)
+ branch_name = content_tag("code", branch)
+ content_tag("li", "#{commit_ids} - #{commits_text} from branch #{branch_name}".html_safe)
end
def url_helpers
diff --git a/app/services/tags/create_service.rb b/app/services/tags/create_service.rb
index 4de6b2d2774..4d836ba763e 100644
--- a/app/services/tags/create_service.rb
+++ b/app/services/tags/create_service.rb
@@ -4,7 +4,7 @@ module Tags
class CreateService < BaseService
def execute(tag_name, target, message)
valid_tag = Gitlab::GitRefValidator.validate(tag_name)
- return error('Tag name invalid') unless valid_tag
+ return error("Tag name invalid") unless valid_tag
repository = project.repository
message = message&.strip
diff --git a/app/services/tags/destroy_service.rb b/app/services/tags/destroy_service.rb
index cab507946b4..48d419c2cf7 100644
--- a/app/services/tags/destroy_service.rb
+++ b/app/services/tags/destroy_service.rb
@@ -7,7 +7,7 @@ module Tags
tag = repository.find_tag(tag_name)
unless tag
- return error('No such tag', 404)
+ return error("No such tag", 404)
end
if repository.rm_tag(current_user, tag_name)
@@ -23,9 +23,9 @@ module Tags
project.execute_hooks(push_data.dup, :tag_push_hooks)
project.execute_services(push_data.dup, :tag_push_hooks)
- success('Tag was removed')
+ success("Tag was removed")
else
- error('Failed to remove tag')
+ error("Failed to remove tag")
end
rescue Gitlab::Git::PreReceiveError => ex
error(ex.message)
@@ -46,7 +46,8 @@ module Tags
tag.dereferenced_target.sha,
Gitlab::Git::BLANK_SHA,
"#{Gitlab::Git::TAG_REF_PREFIX}#{tag.name}",
- [])
+ []
+ )
end
end
end
diff --git a/app/services/task_list_toggle_service.rb b/app/services/task_list_toggle_service.rb
index f6602a35033..47eb805d461 100644
--- a/app/services/task_list_toggle_service.rb
+++ b/app/services/task_list_toggle_service.rb
@@ -41,9 +41,9 @@ class TaskListToggleService
# Check `toggle_as_checked` to make sure we don't accidentally replace
# any `[ ]` or `[x]` in the middle of the text
if currently_checked
- markdown_task.sub!(Taskable::COMPLETE_PATTERN, '[ ]') unless toggle_as_checked
+ markdown_task.sub!(Taskable::COMPLETE_PATTERN, "[ ]") unless toggle_as_checked
else
- markdown_task.sub!(Taskable::INCOMPLETE_PATTERN, '[x]') if toggle_as_checked
+ markdown_task.sub!(Taskable::INCOMPLETE_PATTERN, "[x]") if toggle_as_checked
end
source_lines[source_line_index] = markdown_task
@@ -56,9 +56,9 @@ class TaskListToggleService
return unless html_checkbox
if toggle_as_checked
- html_checkbox[:checked] = 'checked'
+ html_checkbox[:checked] = "checked"
else
- html_checkbox.remove_attribute('checked')
+ html_checkbox.remove_attribute("checked")
end
@updated_markdown_html = html.to_html
diff --git a/app/services/test_hooks/base_service.rb b/app/services/test_hooks/base_service.rb
index 8b5439c00bf..422dfc096ef 100644
--- a/app/services/test_hooks/base_service.rb
+++ b/app/services/test_hooks/base_service.rb
@@ -14,15 +14,15 @@ module TestHooks
trigger_key = hook.class.triggers.key(trigger.to_sym)
trigger_data_method = "#{trigger}_data"
- if trigger_key.nil? || !self.respond_to?(trigger_data_method, true)
- return error('Testing not available for this hook')
+ if trigger_key.nil? || !respond_to?(trigger_data_method, true)
+ return error("Testing not available for this hook")
end
- error_message = catch(:validation_error) do
- sample_data = self.__send__(trigger_data_method) # rubocop:disable GitlabSecurity/PublicSend
+ error_message = catch(:validation_error) {
+ sample_data = __send__(trigger_data_method) # rubocop:disable GitlabSecurity/PublicSend
return hook.execute(sample_data, trigger_key) # rubocop:disable Cop/AvoidReturnFromBlocks
- end
+ }
error(error_message)
end
@@ -32,7 +32,7 @@ module TestHooks
def error(message, http_status = nil)
result = {
message: message,
- status: :error
+ status: :error,
}
result[:http_status] = http_status if http_status
diff --git a/app/services/test_hooks/project_service.rb b/app/services/test_hooks/project_service.rb
index 7e14ddcd017..99c3d541490 100644
--- a/app/services/test_hooks/project_service.rb
+++ b/app/services/test_hooks/project_service.rb
@@ -11,46 +11,46 @@ module TestHooks
private
def push_events_data
- throw(:validation_error, 'Ensure the project has at least one commit.') if project.empty_repo?
+ throw(:validation_error, "Ensure the project has at least one commit.") if project.empty_repo?
Gitlab::DataBuilder::Push.build_sample(project, current_user)
end
- alias_method :tag_push_events_data, :push_events_data
+ alias tag_push_events_data push_events_data
def note_events_data
note = project.notes.first
- throw(:validation_error, 'Ensure the project has notes.') unless note.present?
+ throw(:validation_error, "Ensure the project has notes.") unless note.present?
Gitlab::DataBuilder::Note.build(note, current_user)
end
def issues_events_data
issue = project.issues.first
- throw(:validation_error, 'Ensure the project has issues.') unless issue.present?
+ throw(:validation_error, "Ensure the project has issues.") unless issue.present?
issue.to_hook_data(current_user)
end
- alias_method :confidential_issues_events_data, :issues_events_data
+ alias confidential_issues_events_data issues_events_data
def merge_requests_events_data
merge_request = project.merge_requests.first
- throw(:validation_error, 'Ensure the project has merge requests.') unless merge_request.present?
+ throw(:validation_error, "Ensure the project has merge requests.") unless merge_request.present?
merge_request.to_hook_data(current_user)
end
def job_events_data
build = project.builds.first
- throw(:validation_error, 'Ensure the project has CI jobs.') unless build.present?
+ throw(:validation_error, "Ensure the project has CI jobs.") unless build.present?
Gitlab::DataBuilder::Build.build(build)
end
def pipeline_events_data
pipeline = project.ci_pipelines.first
- throw(:validation_error, 'Ensure the project has CI pipelines.') unless pipeline.present?
+ throw(:validation_error, "Ensure the project has CI pipelines.") unless pipeline.present?
Gitlab::DataBuilder::Pipeline.build(pipeline)
end
@@ -58,10 +58,10 @@ module TestHooks
def wiki_page_events_data
page = project.wiki.pages.first
if !project.wiki_enabled? || page.blank?
- throw(:validation_error, 'Ensure the wiki is enabled and has pages.')
+ throw(:validation_error, "Ensure the wiki is enabled and has pages.")
end
- Gitlab::DataBuilder::WikiPage.build(page, current_user, 'create')
+ Gitlab::DataBuilder::WikiPage.build(page, current_user, "create")
end
end
end
diff --git a/app/services/test_hooks/system_service.rb b/app/services/test_hooks/system_service.rb
index 082830c5538..55a9c794d1a 100644
--- a/app/services/test_hooks/system_service.rb
+++ b/app/services/test_hooks/system_service.rb
@@ -18,7 +18,7 @@ module TestHooks
def merge_requests_events_data
merge_request = MergeRequest.of_projects(current_user.projects.select(:id)).first
- throw(:validation_error, 'Ensure one of your projects has merge requests.') unless merge_request.present?
+ throw(:validation_error, "Ensure one of your projects has merge requests.") unless merge_request.present?
merge_request.to_hook_data(current_user)
end
diff --git a/app/services/todo_service.rb b/app/services/todo_service.rb
index f357dc37fe7..65ca9e0b4f4 100644
--- a/app/services/todo_service.rb
+++ b/app/services/todo_service.rb
@@ -239,7 +239,7 @@ class TodoService
end
def toggling_tasks?(issuable)
- issuable.previous_changes.include?('description') &&
+ issuable.previous_changes.include?("description") &&
issuable.tasks? && issuable.updated_tasks.any?
end
@@ -288,11 +288,12 @@ class TodoService
project_id: target&.project&.id,
target_id: target.id,
target_type: target.class.name,
- commit_id: nil
+ commit_id: nil,
}
if target.is_a?(Commit)
- attributes.merge!(target_id: nil, commit_id: target.id)
+ attributes[:target_id] = nil
+ attributes[:commit_id] = target.id
end
attributes
diff --git a/app/services/todos/destroy/base_service.rb b/app/services/todos/destroy/base_service.rb
index f3f1dbb5698..f718fcfbf46 100644
--- a/app/services/todos/destroy/base_service.rb
+++ b/app/services/todos/destroy/base_service.rb
@@ -13,7 +13,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
def without_authorized(items)
- items.where('user_id NOT IN (?)', authorized_users)
+ items.where("user_id NOT IN (?)", authorized_users)
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/services/todos/destroy/confidential_issue_service.rb b/app/services/todos/destroy/confidential_issue_service.rb
index 6276e332448..a231f19b04b 100644
--- a/app/services/todos/destroy/confidential_issue_service.rb
+++ b/app/services/todos/destroy/confidential_issue_service.rb
@@ -19,8 +19,8 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
def todos
Todo.where(target: issue)
- .where('user_id != ?', issue.author_id)
- .where('user_id NOT IN (?)', issue.assignees.select(:id))
+ .where("user_id != ?", issue.author_id)
+ .where("user_id NOT IN (?)", issue.assignees.select(:id))
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -39,7 +39,7 @@ module Todos
def authorized_users
ProjectAuthorization.select(:user_id)
.where(project_id: project_ids)
- .where('access_level >= ?', Gitlab::Access::REPORTER)
+ .where("access_level >= ?", Gitlab::Access::REPORTER)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/todos/destroy/entity_leave_service.rb b/app/services/todos/destroy/entity_leave_service.rb
index ebfb20132d0..86f1f368b11 100644
--- a/app/services/todos/destroy/entity_leave_service.rb
+++ b/app/services/todos/destroy/entity_leave_service.rb
@@ -9,7 +9,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
def initialize(user_id, entity_id, entity_type)
- unless %w(Group Project).include?(entity_type)
+ unless %w[Group Project].include?(entity_type)
raise ArgumentError.new("#{entity_type} is not an entity user can leave")
end
@@ -67,10 +67,10 @@ module Todos
def project_ids
condition = case entity
when Project
- { id: entity.id }
+ {id: entity.id}
when Namespace
- { namespace_id: non_member_groups }
- end
+ {namespace_id: non_member_groups}
+ end
Project.where(condition).select(:id)
end
@@ -78,7 +78,7 @@ module Todos
# rubocop: disable CodeReuse/ActiveRecord
def non_authorized_projects
- project_ids.where('id NOT IN (?)', user.authorized_projects.select(:id))
+ project_ids.where("id NOT IN (?)", user.authorized_projects.select(:id))
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -87,14 +87,14 @@ module Todos
return [] unless entity.is_a?(Namespace)
entity.self_and_descendants.select(:id)
- .where('id NOT IN (?)', GroupsFinder.new(user).execute.select(:id))
+ .where("id NOT IN (?)", GroupsFinder.new(user).execute.select(:id))
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def non_member_groups
entity.self_and_descendants.select(:id)
- .where('id NOT IN (?)', user.membership_groups.select(:id))
+ .where("id NOT IN (?)", user.membership_groups.select(:id))
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -111,9 +111,9 @@ module Todos
.authorized_projects(Gitlab::Access::REPORTER).select(:id)
Issue.where(project_id: project_ids, confidential: true)
- .where('project_id NOT IN(?)', authorized_reporter_projects)
- .where('author_id != ?', user.id)
- .where('id NOT IN (?)', assigned_ids)
+ .where("project_id NOT IN(?)", authorized_reporter_projects)
+ .where("author_id != ?", user.id)
+ .where("id NOT IN (?)", assigned_ids)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/services/todos/destroy/private_features_service.rb b/app/services/todos/destroy/private_features_service.rb
index bd49519d694..cfb7cc5dec9 100644
--- a/app/services/todos/destroy/private_features_service.rb
+++ b/app/services/todos/destroy/private_features_service.rb
@@ -36,7 +36,7 @@ module Todos
items = Todo.where(project_id: project_id)
items = items.where(user_id: user_id) if user_id
- items.where('user_id NOT IN (?)', authorized_users)
+ items.where("user_id NOT IN (?)", authorized_users)
.where(target_type: target_types)
.delete_all
end
diff --git a/app/services/update_deployment_service.rb b/app/services/update_deployment_service.rb
index aa7fcca1e2a..6d08d1521c6 100644
--- a/app/services/update_deployment_service.rb
+++ b/app/services/update_deployment_service.rb
@@ -48,6 +48,6 @@ class UpdateDeploymentService
end
def action
- environment_options[:action] || 'start'
+ environment_options[:action] || "start"
end
end
diff --git a/app/services/user_agent_detail_service.rb b/app/services/user_agent_detail_service.rb
index 5cb42e879a0..0419b039b84 100644
--- a/app/services/user_agent_detail_service.rb
+++ b/app/services/user_agent_detail_service.rb
@@ -10,6 +10,6 @@ class UserAgentDetailService
def create
return unless request
- spammable.create_user_agent_detail(user_agent: request.env['HTTP_USER_AGENT'], ip_address: request.env['action_dispatch.remote_ip'].to_s)
+ spammable.create_user_agent_detail(user_agent: request.env["HTTP_USER_AGENT"], ip_address: request.env["action_dispatch.remote_ip"].to_s)
end
end
diff --git a/app/services/users/activity_service.rb b/app/services/users/activity_service.rb
index e50840a9158..a51bb5e015d 100644
--- a/app/services/users/activity_service.rb
+++ b/app/services/users/activity_service.rb
@@ -6,10 +6,10 @@ module Users
def initialize(author, activity)
@user = if author.respond_to?(:username)
- author
- elsif author.respond_to?(:user)
- author.user
- end
+ author
+ elsif author.respond_to?(:user)
+ author.user
+ end
@user = nil unless @user.is_a?(User)
@activity = activity
@@ -31,7 +31,7 @@ module Users
return if @user.last_activity_on == today
lease = Gitlab::ExclusiveLease.new("acitvity_service:#{@user.id}",
- timeout: LEASE_TIMEOUT)
+ timeout: LEASE_TIMEOUT)
return unless lease.try_obtain
@user.update_attribute(:last_activity_on, today)
diff --git a/app/services/users/build_service.rb b/app/services/users/build_service.rb
index 3f503f3da28..382be61185a 100644
--- a/app/services/users/build_service.rb
+++ b/app/services/users/build_service.rb
@@ -3,8 +3,8 @@
module Users
class BuildService < BaseService
delegate :user_default_internal_regex_enabled?,
- :user_default_internal_regex_instance,
- to: :'Gitlab::CurrentSettings.current_application_settings'
+ :user_default_internal_regex_instance,
+ to: :'Gitlab::CurrentSettings.current_application_settings'
def initialize(current_user, params = {})
@current_user = current_user
@@ -71,7 +71,7 @@ module Users
:private_profile,
:organization,
:location,
- :public_email
+ :public_email,
]
end
@@ -83,7 +83,7 @@ module Users
:password_automatically_set,
:name,
:password,
- :username
+ :username,
]
end
@@ -93,7 +93,8 @@ module Users
user_params[:created_by_id] = current_user&.id
if params[:reset_password]
- user_params.merge!(force_random_password: true, password_expires_at: nil)
+ user_params[:force_random_password] = true
+ user_params[:password_expires_at] = nil
end
else
allowed_signup_params = signup_params
diff --git a/app/services/users/destroy_service.rb b/app/services/users/destroy_service.rb
index 73fa6089945..141dee49b45 100644
--- a/app/services/users/destroy_service.rb
+++ b/app/services/users/destroy_service.rb
@@ -31,7 +31,7 @@ module Users
end
if !delete_solo_owned_groups && user.solo_owned_groups.present?
- user.errors[:base] << 'You must transfer ownership or delete groups before you can remove user'
+ user.errors[:base] << "You must transfer ownership or delete groups before you can remove user"
return user
end
diff --git a/app/services/users/last_push_event_service.rb b/app/services/users/last_push_event_service.rb
index b3980b8e32c..6e9c3b7c658 100644
--- a/app/services/users/last_push_event_service.rb
+++ b/app/services/users/last_push_event_service.rb
@@ -15,7 +15,7 @@ module Users
def cache_last_push_event(event)
keys = [
project_cache_key(event.project),
- user_cache_key
+ user_cache_key,
]
if forked_from = event.project.forked_from_project
diff --git a/app/services/users/refresh_authorized_projects_service.rb b/app/services/users/refresh_authorized_projects_service.rb
index fe5a82e23fa..e26df34a6e1 100644
--- a/app/services/users/refresh_authorized_projects_service.rb
+++ b/app/services/users/refresh_authorized_projects_service.rb
@@ -51,21 +51,21 @@ module Users
current = current_authorizations_per_project
fresh = fresh_access_levels_per_project
- remove = current.each_with_object([]) do |(project_id, row), array|
+ remove = current.each_with_object([]) { |(project_id, row), array|
# rows not in the new list or with a different access level should be
# removed.
if !fresh[project_id] || fresh[project_id] != row.access_level
array << row.project_id
end
- end
+ }
- add = fresh.each_with_object([]) do |(project_id, level), array|
+ add = fresh.each_with_object([]) { |(project_id, level), array|
# rows not in the old list or with a different access level should be
# added.
if !current[project_id] || current[project_id].access_level != level
array << [user.id, project_id, level]
end
- end
+ }
update_authorizations(remove, add)
end
@@ -103,10 +103,10 @@ module Users
def fresh_authorizations
klass = if Group.supports_nested_objects?
- Gitlab::ProjectAuthorizations::WithNestedGroups
- else
- Gitlab::ProjectAuthorizations::WithoutNestedGroups
- end
+ Gitlab::ProjectAuthorizations::WithNestedGroups
+ else
+ Gitlab::ProjectAuthorizations::WithoutNestedGroups
+ end
klass.new(user).calculate
end
diff --git a/app/services/users/update_service.rb b/app/services/users/update_service.rb
index 0b00bd135eb..ac2d7643e25 100644
--- a/app/services/users/update_service.rb
+++ b/app/services/users/update_service.rb
@@ -22,7 +22,7 @@ module Users
notify_success(user_exists)
else
messages = @user.errors.full_messages + Array(@user.status&.errors&.full_messages)
- error(messages.uniq.join('. '))
+ error(messages.uniq.join(". "))
end
end
diff --git a/app/services/validate_new_branch_service.rb b/app/services/validate_new_branch_service.rb
index c19e2ec2043..8f6973a2d4d 100644
--- a/app/services/validate_new_branch_service.rb
+++ b/app/services/validate_new_branch_service.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require_relative 'base_service'
+require_relative "base_service"
class ValidateNewBranchService < BaseService
def execute(branch_name)
valid_branch = Gitlab::GitRefValidator.validate(branch_name)
unless valid_branch
- return error('Branch name is invalid')
+ return error("Branch name is invalid")
end
if project.repository.branch_exists?(branch_name)
- return error('Branch already exists')
+ return error("Branch already exists")
end
success
diff --git a/app/services/verify_pages_domain_service.rb b/app/services/verify_pages_domain_service.rb
index 07f7391f877..4524facbceb 100644
--- a/app/services/verify_pages_domain_service.rb
+++ b/app/services/verify_pages_domain_service.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'resolv'
+require "resolv"
class VerifyPagesDomainService < BaseService
# The maximum number of seconds to be spent on each DNS lookup
diff --git a/app/services/web_hook_service.rb b/app/services/web_hook_service.rb
index 1fee8bfcd31..ef85272829e 100644
--- a/app/services/web_hook_service.rb
+++ b/app/services/web_hook_service.rb
@@ -6,8 +6,8 @@ class WebHookService
def initialize
@headers = Gitlab::HTTP::Response::Headers.new({})
- @body = ''
- @code = 'internal error'
+ @body = ""
+ @code = "internal error"
end
end
@@ -17,7 +17,7 @@ class WebHookService
@hook = hook
@data = data
@hook_name = hook_name.to_s
- @request_options = { timeout: Gitlab.config.gitlab.webhook_timeout }
+ @request_options = {timeout: Gitlab.config.gitlab.webhook_timeout}
@request_options.merge!(allow_local_requests: true) if @hook.is_a?(SystemHook)
end
@@ -25,10 +25,10 @@ class WebHookService
start_time = Gitlab::Metrics::System.monotonic_time
response = if parsed_url.userinfo.blank?
- make_request(hook.url)
- else
- make_request_with_auth
- end
+ make_request(hook.url)
+ else
+ make_request_with_auth
+ end
log_execution(
trigger: hook_name,
@@ -41,7 +41,7 @@ class WebHookService
{
status: :success,
http_status: response.code,
- message: response.to_s
+ message: response.to_s,
}
rescue SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep => e
log_execution(
@@ -57,7 +57,7 @@ class WebHookService
{
status: :error,
- message: e.to_s
+ message: e.to_s,
}
end
@@ -81,10 +81,10 @@ class WebHookService
end
def make_request_with_auth
- post_url = hook.url.gsub("#{parsed_url.userinfo}@", '')
+ post_url = hook.url.gsub("#{parsed_url.userinfo}@", "")
basic_auth = {
username: CGI.unescape(parsed_url.user),
- password: CGI.unescape(parsed_url.password.presence || '')
+ password: CGI.unescape(parsed_url.password.presence || ""),
}
make_request(post_url, basic_auth)
end
@@ -110,10 +110,10 @@ class WebHookService
def build_headers(hook_name)
@headers ||= begin
{
- 'Content-Type' => 'application/json',
- 'X-Gitlab-Event' => hook_name.singularize.titleize
+ "Content-Type" => "application/json",
+ "X-Gitlab-Event" => hook_name.singularize.titleize,
}.tap do |hash|
- hash['X-Gitlab-Token'] = Gitlab::Utils.remove_line_breaks(hook.token) if hook.token.present?
+ hash["X-Gitlab-Token"] = Gitlab::Utils.remove_line_breaks(hook.token) if hook.token.present?
end
end
end
@@ -126,8 +126,8 @@ class WebHookService
end
def safe_response_body(response)
- return '' unless response.body
+ return "" unless response.body
- response.body.encode('UTF-8', invalid: :replace, undef: :replace, replace: '')
+ response.body.encode("UTF-8", invalid: :replace, undef: :replace, replace: "")
end
end
diff --git a/app/services/wiki_pages/base_service.rb b/app/services/wiki_pages/base_service.rb
index e259f5bd1bc..ed2e2a917f2 100644
--- a/app/services/wiki_pages/base_service.rb
+++ b/app/services/wiki_pages/base_service.rb
@@ -4,7 +4,7 @@ module WikiPages
class BaseService < ::BaseService
private
- def execute_hooks(page, action = 'create')
+ def execute_hooks(page, action = "create")
page_data = Gitlab::DataBuilder::WikiPage.build(page, current_user, action)
@project.execute_hooks(page_data, :wiki_page_hooks)
@project.execute_services(page_data, :wiki_page_hooks)
diff --git a/app/services/wiki_pages/create_service.rb b/app/services/wiki_pages/create_service.rb
index 2e2e0fd9033..85ddf35bffa 100644
--- a/app/services/wiki_pages/create_service.rb
+++ b/app/services/wiki_pages/create_service.rb
@@ -7,7 +7,7 @@ module WikiPages
page = WikiPage.new(project_wiki)
if page.create(@params)
- execute_hooks(page, 'create')
+ execute_hooks(page, "create")
end
page
diff --git a/app/services/wiki_pages/destroy_service.rb b/app/services/wiki_pages/destroy_service.rb
index 3f9343339cd..8860544a8cd 100644
--- a/app/services/wiki_pages/destroy_service.rb
+++ b/app/services/wiki_pages/destroy_service.rb
@@ -4,7 +4,7 @@ module WikiPages
class DestroyService < WikiPages::BaseService
def execute(page)
if page&.delete
- execute_hooks(page, 'delete')
+ execute_hooks(page, "delete")
end
page
diff --git a/app/services/wiki_pages/update_service.rb b/app/services/wiki_pages/update_service.rb
index 2159dd91e9c..b283ccb74a7 100644
--- a/app/services/wiki_pages/update_service.rb
+++ b/app/services/wiki_pages/update_service.rb
@@ -4,7 +4,7 @@ module WikiPages
class UpdateService < WikiPages::BaseService
def execute(page)
if page.update(@params)
- execute_hooks(page, 'update')
+ execute_hooks(page, "update")
end
page
diff --git a/app/services/wikis/create_attachment_service.rb b/app/services/wikis/create_attachment_service.rb
index df31ad7c8ea..00276e40eb2 100644
--- a/app/services/wikis/create_attachment_service.rb
+++ b/app/services/wikis/create_attachment_service.rb
@@ -2,7 +2,7 @@
module Wikis
class CreateAttachmentService < Files::CreateService
- ATTACHMENT_PATH = 'uploads'.freeze
+ ATTACHMENT_PATH = "uploads"
MAX_FILENAME_LENGTH = 255
delegate :wiki, to: :project
@@ -29,7 +29,7 @@ module Wikis
file_name = truncate_file_name(file_name)
# CommonMark does not allow Urls with whitespaces, so we have to replace them
# Using the same regex Carrierwave use to replace invalid characters
- file_name.gsub(CarrierWave::SanitizedFile.sanitize_regexp, '_')
+ file_name.gsub(CarrierWave::SanitizedFile.sanitize_regexp, "_")
end
def truncate_file_name(file_name)
@@ -47,12 +47,12 @@ module Wikis
end
def validate_file_name!
- raise_error('The file name cannot be empty') unless @file_name
+ raise_error("The file name cannot be empty") unless @file_name
end
def validate_permissions!
unless can?(current_user, :create_wiki, project)
- raise_error('You are not allowed to push to the wiki')
+ raise_error("You are not allowed to push to the wiki")
end
end
@@ -64,7 +64,8 @@ module Wikis
message: @commit_message,
branch_name: @branch_name,
author_email: @author_email,
- author_name: @author_name)
+ author_name: @author_name
+ )
end
def commit_result(commit_id)
@@ -72,7 +73,7 @@ module Wikis
file_name: @file_name,
file_path: @file_path,
branch: @branch_name,
- commit: commit_id
+ commit: commit_id,
}
end
end
diff --git a/app/uploaders/avatar_uploader.rb b/app/uploaders/avatar_uploader.rb
index c0165759203..6c1b715ed01 100644
--- a/app/uploaders/avatar_uploader.rb
+++ b/app/uploaders/avatar_uploader.rb
@@ -7,7 +7,7 @@ class AvatarUploader < GitlabUploader
prepend ObjectStorage::Extension::RecordsUploads
def exists?
- model.avatar.file && model.avatar.file.present?
+ model.avatar.file&.present?
end
def move_to_store
diff --git a/app/uploaders/external_diff_uploader.rb b/app/uploaders/external_diff_uploader.rb
index d2707cd0777..af114c10372 100644
--- a/app/uploaders/external_diff_uploader.rb
+++ b/app/uploaders/external_diff_uploader.rb
@@ -5,7 +5,7 @@ class ExternalDiffUploader < GitlabUploader
storage_options Gitlab.config.external_diffs
- alias_method :upload, :model
+ alias upload model
def filename
"diff-#{model.id}"
diff --git a/app/uploaders/file_mover.rb b/app/uploaders/file_mover.rb
index a7f8615e9ba..7b3b50b662b 100644
--- a/app/uploaders/file_mover.rb
+++ b/app/uploaders/file_mover.rb
@@ -28,7 +28,7 @@ class FileMover
def update_markdown
updated_text = model.read_attribute(update_field)
- .gsub(temp_file_uploader.markdown_link, uploader.markdown_link)
+ .gsub(temp_file_uploader.markdown_link, uploader.markdown_link)
model.update_attribute(update_field, updated_text)
rescue
revert
diff --git a/app/uploaders/file_uploader.rb b/app/uploaders/file_uploader.rb
index e90599f2505..f78b85fae4b 100644
--- a/app/uploaders/file_uploader.rb
+++ b/app/uploaders/file_uploader.rb
@@ -24,7 +24,7 @@ class FileUploader < GitlabUploader
after :store, :schedule_background_upload
def self.root
- File.join(options.storage_path, 'uploads')
+ File.join(options.storage_path, "uploads")
end
def self.absolute_path(upload)
@@ -74,7 +74,7 @@ class FileUploader < GitlabUploader
def upload_paths(identifier)
[
File.join(secret, identifier),
- File.join(base_dir(Store::REMOTE), secret, identifier)
+ File.join(base_dir(Store::REMOTE), secret, identifier),
]
end
@@ -118,15 +118,15 @@ class FileUploader < GitlabUploader
def store_dirs
{
Store::LOCAL => File.join(base_dir, dynamic_segment),
- Store::REMOTE => File.join(base_dir(ObjectStorage::Store::REMOTE), dynamic_segment)
+ Store::REMOTE => File.join(base_dir(ObjectStorage::Store::REMOTE), dynamic_segment),
}
end
def to_h
{
- alt: markdown_name,
- url: secure_url,
- markdown: markdown_link
+ alt: markdown_name,
+ url: secure_url,
+ markdown: markdown_link,
}
end
@@ -149,7 +149,7 @@ class FileUploader < GitlabUploader
# return a new uploader with a file copy on another project
def self.copy_to(uploader, to_project)
- moved = self.new(to_project)
+ moved = new(to_project)
moved.object_store = uploader.object_store
moved.filename = uploader.filename
@@ -159,10 +159,10 @@ class FileUploader < GitlabUploader
def copy_file(file)
to_path = if file_storage?
- File.join(self.class.root, store_path)
- else
- store_path
- end
+ File.join(self.class.root, store_path)
+ else
+ store_path
+ end
self.file = file.copy_to(to_path)
record_upload # after_store is not triggered
@@ -195,6 +195,6 @@ class FileUploader < GitlabUploader
end
def secure_url
- File.join('/uploads', @secret, file.filename)
+ File.join("/uploads", @secret, file.filename)
end
end
diff --git a/app/uploaders/gitlab_uploader.rb b/app/uploaders/gitlab_uploader.rb
index cefcd3d3f5a..fe41054072f 100644
--- a/app/uploaders/gitlab_uploader.rb
+++ b/app/uploaders/gitlab_uploader.rb
@@ -15,7 +15,7 @@ class GitlabUploader < CarrierWave::Uploader::Base
# represent the directory namespacing at the class level
def base_dir
- options.fetch('base_dir', '')
+ options.fetch("base_dir", "")
end
def file_storage?
@@ -52,11 +52,11 @@ class GitlabUploader < CarrierWave::Uploader::Base
end
def cache_dir
- File.join(root, base_dir, 'tmp/cache')
+ File.join(root, base_dir, "tmp/cache")
end
def work_dir
- File.join(root, base_dir, 'tmp/work')
+ File.join(root, base_dir, "tmp/work")
end
def filename
@@ -74,7 +74,7 @@ class GitlabUploader < CarrierWave::Uploader::Base
end
def local_url
- File.join('/', self.class.base_dir, dynamic_segment, filename)
+ File.join("/", self.class.base_dir, dynamic_segment, filename)
end
def cached_size
diff --git a/app/uploaders/job_artifact_uploader.rb b/app/uploaders/job_artifact_uploader.rb
index 400f0b3dcc6..b7849b1b0bc 100644
--- a/app/uploaders/job_artifact_uploader.rb
+++ b/app/uploaders/job_artifact_uploader.rb
@@ -9,7 +9,7 @@ class JobArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts
- alias_method :upload, :model
+ alias upload model
def cached_size
return model.size if model.size.present? && !model.file_changed?
@@ -24,7 +24,7 @@ class JobArtifactUploader < GitlabUploader
private
def dynamic_segment
- raise ObjectNotReadyError, 'JobArtifact is not ready' unless model.id
+ raise ObjectNotReadyError, "JobArtifact is not ready" unless model.id
if model.hashed_path?
hashed_path
@@ -37,11 +37,11 @@ class JobArtifactUploader < GitlabUploader
def hashed_path
File.join(disk_hash[0..1], disk_hash[2..3], disk_hash,
- model.created_at.utc.strftime('%Y_%m_%d'), model.job_id.to_s, model.id.to_s)
+ model.created_at.utc.strftime("%Y_%m_%d"), model.job_id.to_s, model.id.to_s)
end
def legacy_path
- File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.job_id.to_s)
+ File.join(model.created_at.utc.strftime("%Y_%m"), model.project_id.to_s, model.job_id.to_s)
end
def disk_hash
diff --git a/app/uploaders/legacy_artifact_uploader.rb b/app/uploaders/legacy_artifact_uploader.rb
index a9afc104ed1..9caa787d789 100644
--- a/app/uploaders/legacy_artifact_uploader.rb
+++ b/app/uploaders/legacy_artifact_uploader.rb
@@ -8,7 +8,7 @@ class LegacyArtifactUploader < GitlabUploader
storage_options Gitlab.config.artifacts
- alias_method :upload, :model
+ alias upload model
def store_dir
dynamic_segment
@@ -17,8 +17,8 @@ class LegacyArtifactUploader < GitlabUploader
private
def dynamic_segment
- raise ObjectNotReadyError, 'Build is not ready' unless model.id
+ raise ObjectNotReadyError, "Build is not ready" unless model.id
- File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.id.to_s)
+ File.join(model.created_at.utc.strftime("%Y_%m"), model.project_id.to_s, model.id.to_s)
end
end
diff --git a/app/uploaders/lfs_object_uploader.rb b/app/uploaders/lfs_object_uploader.rb
index 0a966f3d44f..eed47cd3b53 100644
--- a/app/uploaders/lfs_object_uploader.rb
+++ b/app/uploaders/lfs_object_uploader.rb
@@ -6,7 +6,7 @@ class LfsObjectUploader < GitlabUploader
storage_options Gitlab.config.lfs
- alias_method :upload, :model
+ alias upload model
def filename
model.oid[4..-1]
diff --git a/app/uploaders/namespace_file_uploader.rb b/app/uploaders/namespace_file_uploader.rb
index 4965bd7f057..c41e12dc3ac 100644
--- a/app/uploaders/namespace_file_uploader.rb
+++ b/app/uploaders/namespace_file_uploader.rb
@@ -12,8 +12,8 @@ class NamespaceFileUploader < FileUploader
def self.base_dirs(model)
{
- Store::LOCAL => File.join(options.base_dir, 'namespace', model_path_segment(model)),
- Store::REMOTE => File.join('namespace', model_path_segment(model))
+ Store::LOCAL => File.join(options.base_dir, "namespace", model_path_segment(model)),
+ Store::REMOTE => File.join("namespace", model_path_segment(model)),
}
end
@@ -22,7 +22,7 @@ class NamespaceFileUploader < FileUploader
end
def self.workhorse_local_upload_path
- File.join(options.storage_path, 'uploads', TMP_UPLOAD_PATH)
+ File.join(options.storage_path, "uploads", TMP_UPLOAD_PATH)
end
# Re-Override
diff --git a/app/uploaders/object_storage.rb b/app/uploaders/object_storage.rb
index dad6e85fb56..8a450b73cb0 100644
--- a/app/uploaders/object_storage.rb
+++ b/app/uploaders/object_storage.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'fog/aws'
-require 'carrierwave/storage/fog'
+require "fog/aws"
+require "carrierwave/storage/fog"
#
# This concern should add object storage support
@@ -19,11 +19,11 @@ module ObjectStorage
def message
*lease_key_group, _ = *@lease_key.split(":")
- "Exclusive lease for #{lease_key_group.join(':')} is already taken."
+ "Exclusive lease for #{lease_key_group.join(":")} is already taken."
end
end
- TMP_UPLOAD_PATH = 'tmp/uploads'.freeze
+ TMP_UPLOAD_PATH = "tmp/uploads"
module Store
LOCAL = 1
@@ -70,9 +70,9 @@ module ObjectStorage
return unless upload
ObjectStorage::BackgroundMoveWorker.perform_async(self.class.name,
- upload.class.to_s,
- mounted_as,
- upload.id)
+ upload.class.to_s,
+ mounted_as,
+ upload.id)
end
def exclusive_lease_key
@@ -111,7 +111,7 @@ module ObjectStorage
end
def changed_mounts
- self.class.uploaders.select do |mount, uploader_class|
+ self.class.uploaders.select { |mount, uploader_class|
mounted_as = uploader_class.serialization_column(self.class, mount)
uploader = send(:"#{mounted_as}") # rubocop:disable GitlabSecurity/PublicSend
@@ -120,7 +120,7 @@ module ObjectStorage
next unless send(:"#{mounted_as}_changed?") # rubocop:disable GitlabSecurity/PublicSend
mount
- end.keys
+ }.keys
end
included do
@@ -180,21 +180,21 @@ module ObjectStorage
def workhorse_authorize(has_length:, maximum_size: nil)
{
RemoteObject: workhorse_remote_upload_options(has_length: has_length, maximum_size: maximum_size),
- TempPath: workhorse_local_upload_path
+ TempPath: workhorse_local_upload_path,
}.compact
end
def workhorse_local_upload_path
- File.join(self.root, TMP_UPLOAD_PATH)
+ File.join(root, TMP_UPLOAD_PATH)
end
def workhorse_remote_upload_options(has_length:, maximum_size: nil)
- return unless self.object_store_enabled?
- return unless self.direct_upload_enabled?
+ return unless object_store_enabled?
+ return unless direct_upload_enabled?
- id = [CarrierWave.generate_cache_id, SecureRandom.hex].join('-')
+ id = [CarrierWave.generate_cache_id, SecureRandom.hex].join("-")
upload_path = File.join(TMP_UPLOAD_PATH, id)
- direct_upload = ObjectStorage::DirectUpload.new(self.object_store_credentials, remote_store_path, upload_path,
+ direct_upload = ObjectStorage::DirectUpload.new(object_store_credentials, remote_store_path, upload_path,
has_length: has_length, maximum_size: maximum_size)
direct_upload.to_hash.merge(ID: id)
@@ -241,7 +241,7 @@ module ObjectStorage
return unless persist_object_store?
updated = model.update_column(store_serialization_column, object_store)
- raise 'Failed to update object store' unless updated
+ raise "Failed to update object store" unless updated
end
def use_file(&blk)
@@ -265,9 +265,9 @@ module ObjectStorage
return unless schedule_background_upload?
ObjectStorage::BackgroundMoveWorker.perform_async(self.class.name,
- model.class.name,
- mounted_as,
- model.id)
+ model.class.name,
+ mounted_as,
+ model.id)
end
def fog_directory
@@ -297,7 +297,7 @@ module ObjectStorage
def store_dirs
{
Store::LOCAL => File.join(base_dir, dynamic_segment),
- Store::REMOTE => File.join(dynamic_segment)
+ Store::REMOTE => File.join(dynamic_segment),
}
end
@@ -336,20 +336,20 @@ module ObjectStorage
def schedule_background_upload?
self.class.object_store_enabled? &&
self.class.background_upload_enabled? &&
- self.file_storage?
+ file_storage?
end
def cache_remote_file!(remote_object_id, original_filename)
file_path = File.join(TMP_UPLOAD_PATH, remote_object_id)
file_path = Pathname.new(file_path).cleanpath.to_s
- raise RemoteStoreError, 'Bad file path' unless file_path.start_with?(TMP_UPLOAD_PATH + '/')
+ raise RemoteStoreError, "Bad file path" unless file_path.start_with?(TMP_UPLOAD_PATH + "/")
# TODO:
# This should be changed to make use of `tmp/cache` mechanism
# instead of using custom upload directory,
# using tmp/cache makes this implementation way easier than it is today
CarrierWave::Storage::Fog::File.new(self, storage_for(Store::REMOTE), file_path).tap do |file|
- raise RemoteStoreError, 'Missing file' unless file.exists?
+ raise RemoteStoreError, "Missing file" unless file.exists?
# Remote stored file, we force to store on remote storage
self.object_store = Store::REMOTE
@@ -377,7 +377,7 @@ module ObjectStorage
# Returns the column where the 'store' is saved
# defaults to 'store'
def store_serialization_column
- [serialization_column, 'store'].compact.join('_').to_sym
+ [serialization_column, "store"].compact.join("_").to_sym
end
def storage
@@ -387,7 +387,7 @@ module ObjectStorage
def storage_for(store)
case store
when Store::REMOTE
- raise 'Object Storage is not enabled' unless self.class.object_store_enabled?
+ raise "Object Storage is not enabled" unless self.class.object_store_enabled?
CarrierWave::Storage::Fog.new(self)
when Store::LOCAL
@@ -434,7 +434,7 @@ module ObjectStorage
file
rescue => e
# in case of failure delete new file
- new_file.delete unless new_file.nil?
+ new_file&.delete
# revert back to the old file
self.object_store = from_object_store
self.file = file_to_delete
diff --git a/app/uploaders/personal_file_uploader.rb b/app/uploaders/personal_file_uploader.rb
index 272837aa6ce..5a16794bce6 100644
--- a/app/uploaders/personal_file_uploader.rb
+++ b/app/uploaders/personal_file_uploader.rb
@@ -13,12 +13,12 @@ class PersonalFileUploader < FileUploader
def self.base_dirs(model)
{
Store::LOCAL => File.join(options.base_dir, model_path_segment(model)),
- Store::REMOTE => model_path_segment(model)
+ Store::REMOTE => model_path_segment(model),
}
end
def self.model_path_segment(model)
- return 'temp/' unless model
+ return "temp/" unless model
File.join(model.class.to_s.underscore, model.id.to_s)
end
@@ -43,6 +43,6 @@ class PersonalFileUploader < FileUploader
private
def secure_url
- File.join('/', base_dir, secret, file.filename)
+ File.join("/", base_dir, secret, file.filename)
end
end
diff --git a/app/uploaders/records_uploads.rb b/app/uploaders/records_uploads.rb
index 9a243e07936..90a51436c1a 100644
--- a/app/uploaders/records_uploads.rb
+++ b/app/uploaders/records_uploads.rb
@@ -21,7 +21,7 @@ module RecordsUploads
# rubocop: disable CodeReuse/ActiveRecord
def record_upload(_tempfile = nil)
return unless model
- return unless file && file.exists?
+ return unless file&.exists?
# MySQL InnoDB may encounter a deadlock if a deletion and an
# insert is in the same transaction due to its next-key locking
@@ -36,7 +36,7 @@ module RecordsUploads
def readd_upload
uploads.where(path: upload_path).delete_all
- upload.delete if upload
+ upload&.delete
self.upload = build_upload.tap(&:save!)
end
@@ -69,7 +69,7 @@ module RecordsUploads
# Called `before :remove`
# rubocop: disable CodeReuse/ActiveRecord
def destroy_upload(*args)
- return unless file && file.exists?
+ return unless file&.exists?
self.upload = nil
uploads.where(path: upload_path).delete_all
diff --git a/app/uploaders/uploader_helper.rb b/app/uploaders/uploader_helper.rb
index e8a2dce7755..c4f4e29da4e 100644
--- a/app/uploaders/uploader_helper.rb
+++ b/app/uploaders/uploader_helper.rb
@@ -9,7 +9,7 @@ module UploaderHelper
def extension_match?(extensions)
return false unless file
- extension = file.try(:extension) || File.extname(file.path).delete('.')
+ extension = file.try(:extension) || File.extname(file.path).delete(".")
extensions.include?(extension.downcase)
end
end
diff --git a/app/uploaders/workhorse.rb b/app/uploaders/workhorse.rb
index 84dc2791b9c..db821f811a6 100644
--- a/app/uploaders/workhorse.rb
+++ b/app/uploaders/workhorse.rb
@@ -3,7 +3,7 @@
module Workhorse
module UploadPath
def workhorse_upload_path
- File.join(root, base_dir, 'tmp/uploads')
+ File.join(root, base_dir, "tmp/uploads")
end
end
end
diff --git a/app/validators/abstract_path_validator.rb b/app/validators/abstract_path_validator.rb
index 45ac695c5ec..b96ea5b7766 100644
--- a/app/validators/abstract_path_validator.rb
+++ b/app/validators/abstract_path_validator.rb
@@ -21,7 +21,7 @@ class AbstractPathValidator < ActiveModel::EachValidator
end
def validate_each(record, attribute, value)
- unless value =~ self.class.format_regex
+ unless value&.match?(self.class.format_regex)
record.errors.add(attribute, self.class.format_error_message)
return
end
diff --git a/app/validators/branch_filter_validator.rb b/app/validators/branch_filter_validator.rb
index 6a0899be850..db44d75c503 100644
--- a/app/validators/branch_filter_validator.rb
+++ b/app/validators/branch_filter_validator.rb
@@ -14,10 +14,10 @@
#
class BranchFilterValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- value.squish! unless value.nil?
+ value&.squish!
if value.present?
- value_without_wildcards = value.tr('*', 'x')
+ value_without_wildcards = value.tr("*", "x")
unless Gitlab::GitRefValidator.validate(value_without_wildcards)
record.errors[attribute] << "is not a valid branch name"
@@ -32,6 +32,6 @@ class BranchFilterValidator < ActiveModel::EachValidator
private
def contains_wildcard?(value)
- value.include?('*')
+ value.include?("*")
end
end
diff --git a/app/validators/cluster_name_validator.rb b/app/validators/cluster_name_validator.rb
index 85fd63f08e5..db45ebd21ea 100644
--- a/app/validators/cluster_name_validator.rb
+++ b/app/validators/cluster_name_validator.rb
@@ -14,7 +14,7 @@ class ClusterNameValidator < ActiveModel::EachValidator
record.errors.add(attribute, " is invalid syntax")
end
- unless value =~ Gitlab::Regex.kubernetes_namespace_regex
+ unless value&.match?(Gitlab::Regex.kubernetes_namespace_regex)
record.errors.add(attribute, Gitlab::Regex.kubernetes_namespace_regex_message)
end
else
diff --git a/app/validators/color_validator.rb b/app/validators/color_validator.rb
index 1932d042e83..3e1231f5a89 100644
--- a/app/validators/color_validator.rb
+++ b/app/validators/color_validator.rb
@@ -15,7 +15,7 @@ class ColorValidator < ActiveModel::EachValidator
PATTERN = /\A\#[0-9A-Fa-f]{3}{1,2}+\Z/.freeze
def validate_each(record, attribute, value)
- unless value =~ PATTERN
+ unless PATTERN.match?(value)
record.errors.add(attribute, "must be a valid color code")
end
end
diff --git a/app/validators/key_restriction_validator.rb b/app/validators/key_restriction_validator.rb
index 891d13b1596..580987e7ad3 100644
--- a/app/validators/key_restriction_validator.rb
+++ b/app/validators/key_restriction_validator.rb
@@ -21,7 +21,7 @@ class KeyRestrictionValidator < ActiveModel::EachValidator
def supported_sizes_message
sizes = self.class.supported_sizes(options[:type])
- sizes.to_sentence(last_word_connector: ', or ', two_words_connector: ' or ')
+ sizes.to_sentence(last_word_connector: ", or ", two_words_connector: " or ")
end
def valid_restriction?(value)
diff --git a/app/validators/line_code_validator.rb b/app/validators/line_code_validator.rb
index a351180790e..e1abccc1dff 100644
--- a/app/validators/line_code_validator.rb
+++ b/app/validators/line_code_validator.rb
@@ -7,7 +7,7 @@ class LineCodeValidator < ActiveModel::EachValidator
PATTERN = /\A[a-z0-9]+_\d+_\d+\z/.freeze
def validate_each(record, attribute, value)
- unless value =~ PATTERN
+ unless PATTERN.match?(value)
record.errors.add(attribute, "must be a valid line code")
end
end
diff --git a/app/validators/namespace_name_validator.rb b/app/validators/namespace_name_validator.rb
index fb1c241037c..b3a486013f0 100644
--- a/app/validators/namespace_name_validator.rb
+++ b/app/validators/namespace_name_validator.rb
@@ -5,7 +5,7 @@
# Custom validator for GitLab namespace name strings.
class NamespaceNameValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
- unless value =~ Gitlab::Regex.namespace_name_regex
+ unless value&.match?(Gitlab::Regex.namespace_name_regex)
record.errors.add(attribute, Gitlab::Regex.namespace_name_regex_message)
end
end
diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb
index 3fd015c3cf5..a35e857db9a 100644
--- a/app/validators/url_validator.rb
+++ b/app/validators/url_validator.rb
@@ -35,7 +35,7 @@
# validates :web_url, url: { ports: [80, 443] }
# end
class UrlValidator < ActiveModel::EachValidator
- DEFAULT_PROTOCOLS = %w(http https).freeze
+ DEFAULT_PROTOCOLS = %w[http https].freeze
attr_reader :record
@@ -43,7 +43,7 @@ class UrlValidator < ActiveModel::EachValidator
@record = record
unless value.present?
- record.errors.add(attribute, 'must be a valid URL')
+ record.errors.add(attribute, "must be a valid URL")
return
end
@@ -72,14 +72,14 @@ class UrlValidator < ActiveModel::EachValidator
allow_local_network: true,
ascii_only: false,
enforce_user: false,
- enforce_sanitization: false
+ enforce_sanitization: false,
}
end
def current_options
- options = self.options.map do |option, value|
+ options = self.options.map { |option, value|
[option, value.is_a?(Proc) ? value.call(record) : value]
- end.to_h
+ }.to_h
default_options.merge(options)
end
diff --git a/app/validators/variable_duplicates_validator.rb b/app/validators/variable_duplicates_validator.rb
index d36a56e81b9..8b13b8e7bf0 100644
--- a/app/validators/variable_duplicates_validator.rb
+++ b/app/validators/variable_duplicates_validator.rb
@@ -10,9 +10,9 @@ class VariableDuplicatesValidator < ActiveModel::EachValidator
return if record.errors.include?(:"#{attribute}.key")
if options[:scope]
- scoped = value.group_by do |variable|
+ scoped = value.group_by { |variable|
Array(options[:scope]).map { |attr| variable.send(attr) } # rubocop:disable GitlabSecurity/PublicSend
- end
+ }
scoped.each_value { |scope| validate_duplicates(record, attribute, scope) }
else
validate_duplicates(record, attribute, value)
diff --git a/app/views/dashboard/issues.atom.builder b/app/views/dashboard/issues.atom.builder
index 6034389b897..0a2c02e7158 100644
--- a/app/views/dashboard/issues.atom.builder
+++ b/app/views/dashboard/issues.atom.builder
@@ -5,5 +5,5 @@ xml.link href: issues_dashboard_url, rel: "alternate", type: "text/html"
xml.id issues_dashboard_url
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
-xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+xml << render(partial: "issues/issue", collection: @issues) if @issues.reorder(nil).any?
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/dashboard/projects/index.atom.builder b/app/views/dashboard/projects/index.atom.builder
index 747c53b440e..4d13cebab26 100644
--- a/app/views/dashboard/projects/index.atom.builder
+++ b/app/views/dashboard/projects/index.atom.builder
@@ -4,4 +4,4 @@ xml.link href: dashboard_projects_url, rel: "alternate", type: "text/html"
xml.id dashboard_projects_url
xml.updated @events[0].updated_at.xmlschema if @events[0]
-xml << render(partial: 'events/event', collection: @events) if @events.any?
+xml << render(partial: "events/event", collection: @events) if @events.any?
diff --git a/app/views/groups/issues.atom.builder b/app/views/groups/issues.atom.builder
index 2fd96c9d158..8ac77d66ecc 100644
--- a/app/views/groups/issues.atom.builder
+++ b/app/views/groups/issues.atom.builder
@@ -5,5 +5,5 @@ xml.link href: issues_group_url, rel: "alternate", type: "text/html"
xml.id issues_group_url
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
-xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+xml << render(partial: "issues/issue", collection: @issues) if @issues.reorder(nil).any?
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/issues/_issues_calendar.ics.ruby b/app/views/issues/_issues_calendar.ics.ruby
index 94c3099ace2..965ca78e77f 100644
--- a/app/views/issues/_issues_calendar.ics.ruby
+++ b/app/views/issues/_issues_calendar.ics.ruby
@@ -1,6 +1,6 @@
cal = Icalendar::Calendar.new
-cal.prodid = '-//GitLab//NONSGML GitLab//EN'
-cal.x_wr_calname = 'GitLab Issues'
+cal.prodid = "-//GitLab//NONSGML GitLab//EN"
+cal.x_wr_calname = "GitLab Issues"
# rubocop: disable CodeReuse/ActiveRecord
@issues.preload(project: :namespace).each do |issue|
@@ -9,7 +9,7 @@ cal.x_wr_calname = 'GitLab Issues'
event.summary = "#{issue.title} (in #{issue.project.full_path})"
event.description = "Find out more at #{issue_url(issue)}"
event.url = issue_url(issue)
- event.transp = 'TRANSPARENT'
+ event.transp = "TRANSPARENT"
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/layouts/xml.atom.builder b/app/views/layouts/xml.atom.builder
index 4ee09cb87a1..ae506b7c3bf 100644
--- a/app/views/layouts/xml.atom.builder
+++ b/app/views/layouts/xml.atom.builder
@@ -1,4 +1,4 @@
xml.instruct!
-xml.feed 'xmlns' => 'http://www.w3.org/2005/Atom', 'xmlns:media' => 'http://search.yahoo.com/mrss/' do
+xml.feed "xmlns" => "http://www.w3.org/2005/Atom", "xmlns:media" => "http://search.yahoo.com/mrss/" do
xml << yield
end
diff --git a/app/views/projects/commits/_commit.atom.builder b/app/views/projects/commits/_commit.atom.builder
index 640b5ecf99e..98ff8ac914d 100644
--- a/app/views/projects/commits/_commit.atom.builder
+++ b/app/views/projects/commits/_commit.atom.builder
@@ -10,5 +10,5 @@ xml.entry do
xml.email commit.author_email
end
- xml.summary markdown_field(commit, :description), type: 'html'
+ xml.summary markdown_field(commit, :description), type: "html"
end
diff --git a/app/views/projects/issues/index.atom.builder b/app/views/projects/issues/index.atom.builder
index 6566866be82..54b46de4a8a 100644
--- a/app/views/projects/issues/index.atom.builder
+++ b/app/views/projects/issues/index.atom.builder
@@ -5,5 +5,5 @@ xml.link href: project_issues_url(@project), rel: "alternate", type: "text/ht
xml.id project_issues_url(@project)
xml.updated @issues.first.updated_at.xmlschema if @issues.reorder(nil).any?
-xml << render(partial: 'issues/issue', collection: @issues) if @issues.reorder(nil).any?
+xml << render(partial: "issues/issue", collection: @issues) if @issues.reorder(nil).any?
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/views/projects/tags/_tag.atom.builder b/app/views/projects/tags/_tag.atom.builder
index 60d4b21b9d1..08c17cd6b1a 100644
--- a/app/views/projects/tags/_tag.atom.builder
+++ b/app/views/projects/tags/_tag.atom.builder
@@ -8,9 +8,9 @@ if commit
xml.link href: tag_url
xml.title truncate(tag.name, length: 80)
xml.summary strip_gpg_signature(tag.message)
- xml.content markdown_field(release, :description), type: 'html'
+ xml.content markdown_field(release, :description), type: "html"
xml.updated release.updated_at.xmlschema if release
- xml.media :thumbnail, width: '40', height: '40', url: image_url(avatar_icon_for_email(commit.author_email))
+ xml.media :thumbnail, width: "40", height: "40", url: image_url(avatar_icon_for_email(commit.author_email))
xml.author do |author|
xml.name commit.author_name
xml.email commit.author_email
diff --git a/app/views/projects/tags/index.atom.builder b/app/views/projects/tags/index.atom.builder
index b9b58b7beaa..268405821e2 100644
--- a/app/views/projects/tags/index.atom.builder
+++ b/app/views/projects/tags/index.atom.builder
@@ -1,7 +1,7 @@
xml.title "#{@project.name} tags"
-xml.link href: project_tags_url(@project, @ref, rss_url_options), rel: 'self', type: 'application/atom+xml'
-xml.link href: project_tags_url(@project, @ref), rel: 'alternate', type: 'text/html'
+xml.link href: project_tags_url(@project, @ref, rss_url_options), rel: "self", type: "application/atom+xml"
+xml.link href: project_tags_url(@project, @ref), rel: "alternate", type: "text/html"
xml.id project_tags_url(@project, @ref)
xml.updated @releases.first.updated_at.xmlschema if @releases.any?
-xml << render(partial: 'tag', collection: @tags) if @tags.any?
+xml << render(partial: "tag", collection: @tags) if @tags.any?
diff --git a/app/workers/background_migration_worker.rb b/app/workers/background_migration_worker.rb
index 688b600649a..da796b5fce5 100644
--- a/app/workers/background_migration_worker.rb
+++ b/app/workers/background_migration_worker.rb
@@ -84,7 +84,7 @@ class BackgroundMigrationWorker
def database_unhealthy_counter
Gitlab::Metrics.counter(
:background_migration_database_health_reschedules,
- 'The number of times a background migration is rescheduled because the database is unhealthy.'
+ "The number of times a background migration is rescheduled because the database is unhealthy."
)
end
end
diff --git a/app/workers/concerns/application_worker.rb b/app/workers/concerns/application_worker.rb
index d64c2f82a09..e6f5db7cf80 100644
--- a/app/workers/concerns/application_worker.rb
+++ b/app/workers/concerns/application_worker.rb
@@ -17,17 +17,17 @@ module ApplicationWorker
end
def set_queue
- queue_name = [queue_namespace, base_queue_name].compact.join(':')
+ queue_name = [queue_namespace, base_queue_name].compact.join(":")
sidekiq_options queue: queue_name # rubocop:disable Cop/SidekiqOptionsQueue
end
def base_queue_name
name
- .sub(/\AGitlab::/, '')
- .sub(/Worker\z/, '')
+ .sub(/\AGitlab::/, "")
+ .sub(/Worker\z/, "")
.underscore
- .tr('/', '_')
+ .tr("/", "_")
end
def queue_namespace(new_namespace = nil)
@@ -36,16 +36,16 @@ module ApplicationWorker
set_queue
else
- get_sidekiq_options['queue_namespace']&.to_s
+ get_sidekiq_options["queue_namespace"]&.to_s
end
end
def queue
- get_sidekiq_options['queue'].to_s
+ get_sidekiq_options["queue"].to_s
end
def bulk_perform_async(args_list)
- Sidekiq::Client.push_bulk('class' => self, 'args' => args_list)
+ Sidekiq::Client.push_bulk("class" => self, "args" => args_list)
end
def bulk_perform_in(delay, args_list)
@@ -53,10 +53,10 @@ module ApplicationWorker
schedule = now + delay.to_i
if schedule <= now
- raise ArgumentError, 'The schedule time must be in the future!'
+ raise ArgumentError, "The schedule time must be in the future!"
end
- Sidekiq::Client.push_bulk('class' => self, 'args' => args_list, 'at' => schedule)
+ Sidekiq::Client.push_bulk("class" => self, "args" => args_list, "at" => schedule)
end
end
end
diff --git a/app/workers/concerns/auto_devops_queue.rb b/app/workers/concerns/auto_devops_queue.rb
index aba928ccaab..77f45ff7e43 100644
--- a/app/workers/concerns/auto_devops_queue.rb
+++ b/app/workers/concerns/auto_devops_queue.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-#
+
module AutoDevopsQueue
extend ActiveSupport::Concern
diff --git a/app/workers/concerns/gitlab/github_import/notify_upon_death.rb b/app/workers/concerns/gitlab/github_import/notify_upon_death.rb
index 3d7120665b6..d5b2da22c8c 100644
--- a/app/workers/concerns/gitlab/github_import/notify_upon_death.rb
+++ b/app/workers/concerns/gitlab/github_import/notify_upon_death.rb
@@ -18,8 +18,8 @@ module Gitlab
# AdvanceStageWorker. This prevents the entire import from getting stuck
# just because 1 job threw too many errors.
sidekiq_retries_exhausted do |job|
- args = job['args']
- jid = job['jid']
+ args = job["args"]
+ jid = job["jid"]
if args.length == 3 && (key = args.last) && key.is_a?(String)
JobWaiter.notify(key, jid)
diff --git a/app/workers/concerns/gitlab/github_import/stage_methods.rb b/app/workers/concerns/gitlab/github_import/stage_methods.rb
index e2dee315cde..07bcdc121f8 100644
--- a/app/workers/concerns/gitlab/github_import/stage_methods.rb
+++ b/app/workers/concerns/gitlab/github_import/stage_methods.rb
@@ -24,7 +24,7 @@ module Gitlab
def find_project(id)
# If the project has been marked as failed we want to bail out
# automatically.
- Project.joins_import_state.where(import_state: { status: :started }).find_by(id: id)
+ Project.joins_import_state.where(import_state: {status: :started}).find_by(id: id)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/concerns/project_import_options.rb b/app/workers/concerns/project_import_options.rb
index 2baf768bfd1..7b1c5277355 100644
--- a/app/workers/concerns/project_import_options.rb
+++ b/app/workers/concerns/project_import_options.rb
@@ -10,16 +10,16 @@ module ProjectImportOptions
# We only want to mark the project as failed once we exhausted all retries
sidekiq_retries_exhausted do |job|
- project = Project.find(job['args'].first)
+ project = Project.find(job["args"].first)
action = if project.forked?
- "fork"
- else
- "import"
- end
+ "fork"
+ else
+ "import"
+ end
- project.import_state.mark_as_failed(_("Every %{action} attempt has failed: %{job_error_message}. Please try again.") % { action: action, job_error_message: job['error_message'] })
- Sidekiq.logger.warn "Failed #{job['class']} with #{job['args']}: #{job['error_message']}"
+ project.import_state.mark_as_failed(_("Every %{action} attempt has failed: %{job_error_message}. Please try again.") % {action: action, job_error_message: job["error_message"]})
+ Sidekiq.logger.warn "Failed #{job["class"]} with #{job["args"]}: #{job["error_message"]}"
end
end
end
diff --git a/app/workers/concerns/project_start_import.rb b/app/workers/concerns/project_start_import.rb
index 4462bc51a24..7679c467443 100644
--- a/app/workers/concerns/project_start_import.rb
+++ b/app/workers/concerns/project_start_import.rb
@@ -3,7 +3,7 @@
# Used in EE by mirroring
module ProjectStartImport
def start(import_state)
- if import_state.started? && import_state.jid == self.jid
+ if import_state.started? && import_state.jid == jid
return true
end
diff --git a/app/workers/concerns/waitable_worker.rb b/app/workers/concerns/waitable_worker.rb
index 27b94a82444..17946bbc5ca 100644
--- a/app/workers/concerns/waitable_worker.rb
+++ b/app/workers/concerns/waitable_worker.rb
@@ -25,11 +25,9 @@ module WaitableWorker
failed = []
args_list.each do |args|
- begin
- new.perform(*args)
- rescue
- failed << args
- end
+ new.perform(*args)
+ rescue
+ failed << args
end
bulk_perform_async(failed) if failed.present?
diff --git a/app/workers/create_gpg_signature_worker.rb b/app/workers/create_gpg_signature_worker.rb
index 49c7a403838..2827529cc1c 100644
--- a/app/workers/create_gpg_signature_worker.rb
+++ b/app/workers/create_gpg_signature_worker.rb
@@ -20,11 +20,9 @@ class CreateGpgSignatureWorker
# This calculates and caches the signature in the database
commits.each do |commit|
- begin
- Gitlab::Gpg::Commit.new(commit).signature
- rescue => e
- Rails.logger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}")
- end
+ Gitlab::Gpg::Commit.new(commit).signature
+ rescue => e
+ Rails.logger.error("Failed to create signature for commit #{commit.id}. Error: #{e.message}")
end
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/app/workers/delete_stored_files_worker.rb b/app/workers/delete_stored_files_worker.rb
index ff7931849d8..6341d70386e 100644
--- a/app/workers/delete_stored_files_worker.rb
+++ b/app/workers/delete_stored_files_worker.rb
@@ -6,8 +6,8 @@ class DeleteStoredFilesWorker
def perform(class_name, keys)
klass = begin
class_name.constantize
- rescue NameError
- nil
+ rescue NameError
+ nil
end
unless klass
diff --git a/app/workers/emails_on_push_worker.rb b/app/workers/emails_on_push_worker.rb
index 17ad1d5ab88..ab254d8968e 100644
--- a/app/workers/emails_on_push_worker.rb
+++ b/app/workers/emails_on_push_worker.rb
@@ -8,8 +8,8 @@ class EmailsOnPushWorker
def perform(project_id, recipients, push_data, options = {})
options.symbolize_keys!
options.reverse_merge!(
- send_from_committer_email: false,
- disable_diffs: false
+ send_from_committer_email: false,
+ disable_diffs: false
)
send_from_committer_email = options[:send_from_committer_email]
disable_diffs = options[:disable_diffs]
@@ -52,24 +52,22 @@ class EmailsOnPushWorker
end
valid_recipients(recipients).each do |recipient|
- begin
- send_email(
- recipient,
- project_id,
- author_id: author_id,
- ref: ref,
- action: action,
- compare: compare,
- reverse_compare: reverse_compare,
- diff_refs: diff_refs,
- send_from_committer_email: send_from_committer_email,
- disable_diffs: disable_diffs
- )
-
- # These are input errors and won't be corrected even if Sidekiq retries
- rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e
- logger.info("Failed to send e-mail for project '#{project.full_name}' to #{recipient}: #{e}")
- end
+ send_email(
+ recipient,
+ project_id,
+ author_id: author_id,
+ ref: ref,
+ action: action,
+ compare: compare,
+ reverse_compare: reverse_compare,
+ diff_refs: diff_refs,
+ send_from_committer_email: send_from_committer_email,
+ disable_diffs: disable_diffs
+ )
+
+ # These are input errors and won't be corrected even if Sidekiq retries
+ rescue Net::SMTPFatalError, Net::SMTPSyntaxError => e
+ logger.info("Failed to send e-mail for project '#{project.full_name}' to #{recipient}: #{e}")
end
ensure
@email = nil
@@ -92,7 +90,7 @@ class EmailsOnPushWorker
def valid_recipients(recipients)
recipients.split.select do |recipient|
- recipient.include?('@')
+ recipient.include?("@")
end
end
end
diff --git a/app/workers/expire_build_artifacts_worker.rb b/app/workers/expire_build_artifacts_worker.rb
index 251e95c68d5..5b38dd23eea 100644
--- a/app/workers/expire_build_artifacts_worker.rb
+++ b/app/workers/expire_build_artifacts_worker.rb
@@ -18,7 +18,7 @@ class ExpireBuildArtifactsWorker
# rubocop: disable CodeReuse/ActiveRecord
def perform_legacy_artifacts_removal
- Rails.logger.info 'Scheduling removal of build artifacts'
+ Rails.logger.info "Scheduling removal of build artifacts"
build_ids = Ci::Build.with_expired_artifacts.pluck(:id)
build_ids = build_ids.map { |build_id| [build_id] }
diff --git a/app/workers/gitlab/github_import/advance_stage_worker.rb b/app/workers/gitlab/github_import/advance_stage_worker.rb
index 0b3437a8a33..97d1cbab541 100644
--- a/app/workers/gitlab/github_import/advance_stage_worker.rb
+++ b/app/workers/gitlab/github_import/advance_stage_worker.rb
@@ -22,7 +22,7 @@ module Gitlab
issues_and_diff_notes: Stage::ImportIssuesAndDiffNotesWorker,
notes: Stage::ImportNotesWorker,
lfs_objects: Stage::ImportLfsObjectsWorker,
- finish: Stage::FinishImportWorker
+ finish: Stage::FinishImportWorker,
}.freeze
# project_id - The ID of the project being imported.
diff --git a/app/workers/gitlab/github_import/import_diff_note_worker.rb b/app/workers/gitlab/github_import/import_diff_note_worker.rb
index ef2a74c51c5..3e076812ab3 100644
--- a/app/workers/gitlab/github_import/import_diff_note_worker.rb
+++ b/app/workers/gitlab/github_import/import_diff_note_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def counter_description
- 'The number of imported GitHub pull request review comments'
+ "The number of imported GitHub pull request review comments"
end
end
end
diff --git a/app/workers/gitlab/github_import/import_issue_worker.rb b/app/workers/gitlab/github_import/import_issue_worker.rb
index 1b081ae5966..aa8a7649a5f 100644
--- a/app/workers/gitlab/github_import/import_issue_worker.rb
+++ b/app/workers/gitlab/github_import/import_issue_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def counter_description
- 'The number of imported GitHub issues'
+ "The number of imported GitHub issues"
end
end
end
diff --git a/app/workers/gitlab/github_import/import_lfs_object_worker.rb b/app/workers/gitlab/github_import/import_lfs_object_worker.rb
index 520c5cb091a..264e939f183 100644
--- a/app/workers/gitlab/github_import/import_lfs_object_worker.rb
+++ b/app/workers/gitlab/github_import/import_lfs_object_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def counter_description
- 'The number of imported GitHub Lfs Objects'
+ "The number of imported GitHub Lfs Objects"
end
end
end
diff --git a/app/workers/gitlab/github_import/import_note_worker.rb b/app/workers/gitlab/github_import/import_note_worker.rb
index d2b4c36a5b9..a7a839168ab 100644
--- a/app/workers/gitlab/github_import/import_note_worker.rb
+++ b/app/workers/gitlab/github_import/import_note_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def counter_description
- 'The number of imported GitHub comments'
+ "The number of imported GitHub comments"
end
end
end
diff --git a/app/workers/gitlab/github_import/import_pull_request_worker.rb b/app/workers/gitlab/github_import/import_pull_request_worker.rb
index 62a6da152a3..ca78c6e0e12 100644
--- a/app/workers/gitlab/github_import/import_pull_request_worker.rb
+++ b/app/workers/gitlab/github_import/import_pull_request_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def counter_description
- 'The number of imported GitHub pull requests'
+ "The number of imported GitHub pull requests"
end
end
end
diff --git a/app/workers/gitlab/github_import/stage/finish_import_worker.rb b/app/workers/gitlab/github_import/stage/finish_import_worker.rb
index a779e631516..d8699b9b7f5 100644
--- a/app/workers/gitlab/github_import/stage/finish_import_worker.rb
+++ b/app/workers/gitlab/github_import/stage/finish_import_worker.rb
@@ -18,7 +18,7 @@ module Gitlab
duration = Time.zone.now - project.created_at
path = project.full_path
- histogram.observe({ project: path }, duration)
+ histogram.observe({project: path}, duration)
counter.increment
logger.info("GitHub importer finished for #{path} in #{duration.round(2)} seconds")
@@ -27,14 +27,14 @@ module Gitlab
def histogram
@histogram ||= Gitlab::Metrics.histogram(
:github_importer_total_duration_seconds,
- 'Total time spent importing GitHub projects, in seconds'
+ "Total time spent importing GitHub projects, in seconds"
)
end
def counter
@counter ||= Gitlab::Metrics.counter(
:github_importer_imported_projects,
- 'The number of imported GitHub projects'
+ "The number of imported GitHub projects"
)
end
end
diff --git a/app/workers/gitlab/github_import/stage/import_base_data_worker.rb b/app/workers/gitlab/github_import/stage/import_base_data_worker.rb
index ccfed2ae187..fb81071ccaf 100644
--- a/app/workers/gitlab/github_import/stage/import_base_data_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_base_data_worker.rb
@@ -13,7 +13,7 @@ module Gitlab
IMPORTERS = [
Importer::LabelsImporter,
Importer::MilestonesImporter,
- Importer::ReleasesImporter
+ Importer::ReleasesImporter,
].freeze
# client - An instance of Gitlab::GithubImport::Client.
diff --git a/app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb b/app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb
index 7007754ff2e..5c114aa8cd5 100644
--- a/app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker.rb
@@ -12,16 +12,16 @@ module Gitlab
# on as we also use these to enrich pull requests with assigned labels.
IMPORTERS = [
Importer::IssuesImporter,
- Importer::DiffNotesImporter
+ Importer::DiffNotesImporter,
].freeze
# client - An instance of Gitlab::GithubImport::Client.
# project - An instance of Project.
def import(client, project)
- waiters = IMPORTERS.each_with_object({}) do |klass, hash|
+ waiters = IMPORTERS.each_with_object({}) { |klass, hash|
waiter = klass.new(project, client).execute
hash[waiter.key] = waiter.jobs_remaining
- end
+ }
AdvanceStageWorker.perform_async(project.id, waiters, :notes)
end
diff --git a/app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb b/app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb
index 29257603a9d..016eda1bb3f 100644
--- a/app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_lfs_objects_worker.rb
@@ -22,7 +22,7 @@ module Gitlab
AdvanceStageWorker.perform_async(
project.id,
- { waiter.key => waiter.jobs_remaining },
+ {waiter.key => waiter.jobs_remaining},
:finish
)
end
diff --git a/app/workers/gitlab/github_import/stage/import_notes_worker.rb b/app/workers/gitlab/github_import/stage/import_notes_worker.rb
index ccf0013180d..1dd08acaff0 100644
--- a/app/workers/gitlab/github_import/stage/import_notes_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_notes_worker.rb
@@ -17,7 +17,7 @@ module Gitlab
AdvanceStageWorker.perform_async(
project.id,
- { waiter.key => waiter.jobs_remaining },
+ {waiter.key => waiter.jobs_remaining},
:lfs_objects
)
end
diff --git a/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb b/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb
index 37a7a7f4ba0..f4c4d955f1b 100644
--- a/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_pull_requests_worker.rb
@@ -19,7 +19,7 @@ module Gitlab
AdvanceStageWorker.perform_async(
project.id,
- { waiter.key => waiter.jobs_remaining },
+ {waiter.key => waiter.jobs_remaining},
:issues_and_diff_notes
)
end
diff --git a/app/workers/gitlab/github_import/stage/import_repository_worker.rb b/app/workers/gitlab/github_import/stage/import_repository_worker.rb
index 4d16cef1130..d2bd7de1cab 100644
--- a/app/workers/gitlab/github_import/stage/import_repository_worker.rb
+++ b/app/workers/gitlab/github_import/stage/import_repository_worker.rb
@@ -29,7 +29,7 @@ module Gitlab
def counter
Gitlab::Metrics.counter(
:github_importer_imported_repositories,
- 'The number of imported GitHub repositories'
+ "The number of imported GitHub repositories"
)
end
end
diff --git a/app/workers/gitlab_usage_ping_worker.rb b/app/workers/gitlab_usage_ping_worker.rb
index b75e724ca98..eb1c7d1991e 100644
--- a/app/workers/gitlab_usage_ping_worker.rb
+++ b/app/workers/gitlab_usage_ping_worker.rb
@@ -16,6 +16,6 @@ class GitlabUsagePingWorker
private
def try_obtain_lease
- Gitlab::ExclusiveLease.new('gitlab_usage_ping_worker:ping', timeout: LEASE_TIMEOUT).try_obtain
+ Gitlab::ExclusiveLease.new("gitlab_usage_ping_worker:ping", timeout: LEASE_TIMEOUT).try_obtain
end
end
diff --git a/app/workers/import_issues_csv_worker.rb b/app/workers/import_issues_csv_worker.rb
index d44fdfec8ae..42b70cb60e5 100644
--- a/app/workers/import_issues_csv_worker.rb
+++ b/app/workers/import_issues_csv_worker.rb
@@ -4,7 +4,7 @@ class ImportIssuesCsvWorker
include ApplicationWorker
sidekiq_retries_exhausted do |job|
- Upload.find(job['args'][2]).destroy
+ Upload.find(job["args"][2]).destroy
end
def perform(current_user_id, project_id, upload_id)
diff --git a/app/workers/irker_worker.rb b/app/workers/irker_worker.rb
index 29631c6b7ac..c44c263706e 100644
--- a/app/workers/irker_worker.rb
+++ b/app/workers/irker_worker.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'json'
-require 'socket'
+require "json"
+require "socket"
class IrkerWorker
include ApplicationWorker
@@ -12,9 +12,9 @@ class IrkerWorker
# Get config parameters
return false unless init_perform settings, chans, colors
- repo_name = push_data['repository']['name']
- committer = push_data['user_name']
- branch = push_data['ref'].gsub(%r'refs/[^/]*/', '')
+ repo_name = push_data["repository"]["name"]
+ committer = push_data["user_name"]
+ branch = push_data["ref"].gsub(%r{refs/[^/]*/}, "")
if @colors
repo_name = "\x0304#{repo_name}\x0f"
@@ -36,7 +36,7 @@ class IrkerWorker
def init_perform(set, chans, colors)
@colors = colors
@channels = chans
- start_connection set['server_host'], set['server_port']
+ start_connection set["server_host"], set["server_port"]
end
def start_connection(irker_server, irker_port)
@@ -50,7 +50,7 @@ class IrkerWorker
end
def sendtoirker(privmsg)
- to_send = { to: @channels, privmsg: privmsg }
+ to_send = {to: @channels, privmsg: privmsg}
@socket.puts JSON.dump(to_send)
end
@@ -59,9 +59,9 @@ class IrkerWorker
end
def send_branch_updates(push_data, project, repo_name, committer, branch)
- if Gitlab::Git.blank_ref?(push_data['before'])
+ if Gitlab::Git.blank_ref?(push_data["before"])
send_new_branch project, repo_name, committer, branch
- elsif Gitlab::Git.blank_ref?(push_data['after'])
+ elsif Gitlab::Git.blank_ref?(push_data["after"])
send_del_branch repo_name, committer, branch
end
end
@@ -82,29 +82,29 @@ class IrkerWorker
end
def send_commits(push_data, project, repo_name, committer, branch)
- return if push_data['total_commits_count'] == 0
+ return if push_data["total_commits_count"] == 0
# Next message is for number of commit pushed, if any
- if Gitlab::Git.blank_ref?(push_data['before'])
+ if Gitlab::Git.blank_ref?(push_data["before"])
# Tweak on push_data["before"] in order to have a nice compare URL
- push_data['before'] = before_on_new_branch push_data, project
+ push_data["before"] = before_on_new_branch push_data, project
end
send_commits_count(push_data, project, repo_name, committer, branch)
# One message per commit, limited by 3 messages (same limit as the
# github irc hook)
- commits = push_data['commits'].first(3)
+ commits = push_data["commits"].first(3)
commits.each do |hook_attrs|
send_one_commit project, hook_attrs, repo_name, branch
end
end
def before_on_new_branch(push_data, project)
- commit = commit_from_id project, push_data['commits'][0]['id']
+ commit = commit_from_id project, push_data["commits"][0]["id"]
parents = commit.parents
# Return old value if there's no new one
- return push_data['before'] if parents.empty?
+ return push_data["before"] if parents.empty?
# Or return the first parent-commit
parents[0].id
@@ -112,26 +112,26 @@ class IrkerWorker
def send_commits_count(data, project, repo, committer, branch)
url = compare_url data, project.full_path
- commits = colorize_commits data['total_commits_count']
+ commits = colorize_commits data["total_commits_count"]
- new_commits = 'new commit'.pluralize(data['total_commits_count'])
+ new_commits = "new commit".pluralize(data["total_commits_count"])
sendtoirker "[#{repo}] #{committer} pushed #{commits} #{new_commits} " \
"to #{branch}: #{url}"
end
def compare_url(data, repo_path)
- sha1 = Commit.truncate_sha(data['before'])
- sha2 = Commit.truncate_sha(data['after'])
+ sha1 = Commit.truncate_sha(data["before"])
+ sha2 = Commit.truncate_sha(data["after"])
compare_url = "#{Gitlab.config.gitlab.url}/#{repo_path}/compare" \
"/#{sha1}...#{sha2}"
colorize_url compare_url
end
def send_one_commit(project, hook_attrs, repo_name, branch)
- commit = commit_from_id project, hook_attrs['id']
- sha = colorize_sha Commit.truncate_sha(hook_attrs['id'])
- author = hook_attrs['author']['name']
- files = colorize_nb_files(files_count commit)
+ commit = commit_from_id project, hook_attrs["id"]
+ sha = colorize_sha Commit.truncate_sha(hook_attrs["id"])
+ author = hook_attrs["author"]["name"]
+ files = colorize_nb_files(files_count(commit))
title = commit.title
sendtoirker "#{repo_name}/#{branch} #{sha} #{author} (#{files}): #{title}"
diff --git a/app/workers/mail_scheduler/notification_service_worker.rb b/app/workers/mail_scheduler/notification_service_worker.rb
index 421fbf04e28..7b455e0439f 100644
--- a/app/workers/mail_scheduler/notification_service_worker.rb
+++ b/app/workers/mail_scheduler/notification_service_worker.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'active_job/arguments'
+require "active_job/arguments"
module MailScheduler
class NotificationServiceWorker
@@ -51,7 +51,7 @@ module MailScheduler
def serialize_argument(argument)
case argument
- when -> (arg) { arg.respond_to?(:permitted?) }
+ when ->(arg) { arg.respond_to?(:permitted?) }
serialize_hash(argument.to_h).tap do |result|
result[WITH_INDIFFERENT_ACCESS_KEY] = serialize_argument(true)
end
@@ -62,7 +62,7 @@ module MailScheduler
end
# Make sure we remove this patch starting with Rails 6.0.
- if Rails.version.start_with?('6.0')
+ if Rails.version.start_with?("6.0")
raise <<~MSG
Please remove the patch `Arguments` module and use `ActiveJob::Arguments` again.
MSG
diff --git a/app/workers/namespaceless_project_destroy_worker.rb b/app/workers/namespaceless_project_destroy_worker.rb
index f6e98746055..1f694308830 100644
--- a/app/workers/namespaceless_project_destroy_worker.rb
+++ b/app/workers/namespaceless_project_destroy_worker.rb
@@ -31,6 +31,6 @@ class NamespacelessProjectDestroyWorker
def unlink_fork(project)
merge_requests = project.forked_from_project.merge_requests.opened.from_project(project)
- merge_requests.update_all(state: 'closed')
+ merge_requests.update_all(state: "closed")
end
end
diff --git a/app/workers/object_storage/migrate_uploads_worker.rb b/app/workers/object_storage/migrate_uploads_worker.rb
index fe5d27b087d..206eb71b898 100644
--- a/app/workers/object_storage/migrate_uploads_worker.rb
+++ b/app/workers/object_storage/migrate_uploads_worker.rb
@@ -126,11 +126,9 @@ module ObjectStorage
def process_uploader(uploader)
MigrationResult.new(uploader.upload).tap do |result|
- begin
- uploader.migrate!(@to_store)
- rescue => e
- result.error = e
- end
+ uploader.migrate!(@to_store)
+ rescue => e
+ result.error = e
end
end
end
diff --git a/app/workers/pipeline_schedule_worker.rb b/app/workers/pipeline_schedule_worker.rb
index ac4e9710f33..15703f059a0 100644
--- a/app/workers/pipeline_schedule_worker.rb
+++ b/app/workers/pipeline_schedule_worker.rb
@@ -8,16 +8,15 @@ class PipelineScheduleWorker
def perform
Ci::PipelineSchedule.active.where("next_run_at < ?", Time.now)
.preload(:owner, :project).find_each do |schedule|
- begin
- Ci::CreatePipelineService.new(schedule.project,
- schedule.owner,
- ref: schedule.ref)
- .execute!(:schedule, ignore_skip_ci: true, save_on_errors: true, schedule: schedule)
- rescue => e
- error(schedule, e)
- ensure
- schedule.schedule_next_run!
- end
+
+ Ci::CreatePipelineService.new(schedule.project,
+ schedule.owner,
+ ref: schedule.ref)
+ .execute!(:schedule, ignore_skip_ci: true, save_on_errors: true, schedule: schedule)
+ rescue => e
+ error(schedule, e)
+ ensure
+ schedule.schedule_next_run!
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -32,13 +31,13 @@ class PipelineScheduleWorker
Gitlab::Sentry
.track_exception(error,
- issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/41231',
- extra: { schedule_id: schedule.id })
+ issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/41231",
+ extra: {schedule_id: schedule.id})
end
def failed_creation_counter
@failed_creation_counter ||=
Gitlab::Metrics.counter(:pipeline_schedule_creation_failed_total,
- "Counter of failed attempts of pipeline schedule creation")
+ "Counter of failed attempts of pipeline schedule creation")
end
end
diff --git a/app/workers/post_receive.rb b/app/workers/post_receive.rb
index bbd4ab159e4..dc8b73d8b41 100644
--- a/app/workers/post_receive.rb
+++ b/app/workers/post_receive.rb
@@ -11,10 +11,10 @@ class PostReceive
return false
end
- changes = Base64.decode64(changes) unless changes.include?(' ')
+ 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']
+ Sidekiq.logger.info "changes: #{changes.inspect}" if ENV["SIDEKIQ_LOG_ARGUMENTS"]
post_received = Gitlab::GitPostReceive.new(project, identifier, changes, push_options)
if is_wiki
@@ -44,7 +44,8 @@ class PostReceive
oldrev: oldrev,
newrev: newrev,
ref: ref,
- push_options: post_received.push_options).execute
+ push_options: post_received.push_options
+ ).execute
elsif Gitlab::Git.branch_ref?(ref)
GitPushService.new(
post_received.project,
@@ -52,7 +53,8 @@ class PostReceive
oldrev: oldrev,
newrev: newrev,
ref: ref,
- push_options: post_received.push_options).execute
+ push_options: post_received.push_options
+ ).execute
end
changes << Gitlab::DataBuilder::Repository.single_change(oldrev, newrev, ref)
diff --git a/app/workers/process_commit_worker.rb b/app/workers/process_commit_worker.rb
index 29a7f8e691a..13837c4025a 100644
--- a/app/workers/process_commit_worker.rb
+++ b/app/workers/process_commit_worker.rb
@@ -64,7 +64,7 @@ class ProcessCommitWorker
# rubocop: enable CodeReuse/ActiveRecord
def build_commit(project, hash)
- date_suffix = '_date'
+ date_suffix = "_date"
# When processing Sidekiq payloads various timestamps are stored as Strings.
# Commit in turn expects Time-like instances upon input, so we have to
diff --git a/app/workers/project_cache_worker.rb b/app/workers/project_cache_worker.rb
index d27b5e62574..e1489f2fd41 100644
--- a/app/workers/project_cache_worker.rb
+++ b/app/workers/project_cache_worker.rb
@@ -16,7 +16,7 @@ class ProjectCacheWorker
def perform(project_id, files = [], statistics = [])
project = Project.find_by(id: project_id)
- return unless project && project.repository.exists?
+ return unless project&.repository&.exists?
update_statistics(project, statistics.map(&:to_sym))
diff --git a/app/workers/project_export_worker.rb b/app/workers/project_export_worker.rb
index ed9da39c7c3..bc9d4c17c49 100644
--- a/app/workers/project_export_worker.rb
+++ b/app/workers/project_export_worker.rb
@@ -17,7 +17,7 @@ class ProjectExportWorker
private
def build!(after_export_strategy)
- strategy_klass = after_export_strategy&.delete('klass')
+ strategy_klass = after_export_strategy&.delete("klass")
Gitlab::ImportExport::AfterExportStrategyBuilder.build!(strategy_klass, after_export_strategy)
end
diff --git a/app/workers/project_migrate_hashed_storage_worker.rb b/app/workers/project_migrate_hashed_storage_worker.rb
index 1c8f313e6e9..267be29eb8e 100644
--- a/app/workers/project_migrate_hashed_storage_worker.rb
+++ b/app/workers/project_migrate_hashed_storage_worker.rb
@@ -4,7 +4,7 @@ class ProjectMigrateHashedStorageWorker
include ApplicationWorker
LEASE_TIMEOUT = 30.seconds.to_i
- LEASE_KEY_SEGMENT = 'project_migrate_hashed_storage_worker'.freeze
+ LEASE_KEY_SEGMENT = "project_migrate_hashed_storage_worker"
# rubocop: disable CodeReuse/ActiveRecord
def perform(project_id, old_disk_path = nil)
@@ -20,7 +20,6 @@ class ProjectMigrateHashedStorageWorker
else
return false
end
-
ensure
cancel_lease_for(project_id, uuid) if uuid
end
diff --git a/app/workers/prune_old_events_worker.rb b/app/workers/prune_old_events_worker.rb
index dc4b7670131..694e8997c72 100644
--- a/app/workers/prune_old_events_worker.rb
+++ b/app/workers/prune_old_events_worker.rb
@@ -9,13 +9,15 @@ class PruneOldEventsWorker
# Contribution calendar shows maximum 12 months of events, we retain 2 years for data integrity.
# Double nested query is used because MySQL doesn't allow DELETE subqueries on the same table.
Event.unscoped.where(
- '(id IN (SELECT id FROM (?) ids_to_remove))',
+ "(id IN (SELECT id FROM (?) ids_to_remove))",
Event.unscoped.where(
- 'created_at < ?',
- (2.years + 1.day).ago)
+ "created_at < ?",
+ (2.years + 1.day).ago
+ )
.select(:id)
- .limit(10_000))
- .delete_all
+ .limit(10_000)
+ )
+ .delete_all
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/prune_web_hook_logs_worker.rb b/app/workers/prune_web_hook_logs_worker.rb
index 38054069f4e..f5b38b9520e 100644
--- a/app/workers/prune_web_hook_logs_worker.rb
+++ b/app/workers/prune_web_hook_logs_worker.rb
@@ -16,10 +16,10 @@ class PruneWebHookLogsWorker
# another sub query.
WebHookLog
.where(
- 'id IN (SELECT id FROM (?) ids_to_remove)',
+ "id IN (SELECT id FROM (?) ids_to_remove)",
WebHookLog
.select(:id)
- .where('created_at < ?', 90.days.ago.beginning_of_day)
+ .where("created_at < ?", 90.days.ago.beginning_of_day)
.limit(DELETE_LIMIT)
)
.delete_all
diff --git a/app/workers/reactive_caching_worker.rb b/app/workers/reactive_caching_worker.rb
index 9ec8bcca4f3..a357443bcbf 100644
--- a/app/workers/reactive_caching_worker.rb
+++ b/app/workers/reactive_caching_worker.rb
@@ -7,8 +7,8 @@ class ReactiveCachingWorker
def perform(class_name, id, *args)
klass = begin
class_name.constantize
- rescue NameError
- nil
+ rescue NameError
+ nil
end
return unless klass
diff --git a/app/workers/remove_expired_members_worker.rb b/app/workers/remove_expired_members_worker.rb
index 41913900571..3497a1f9280 100644
--- a/app/workers/remove_expired_members_worker.rb
+++ b/app/workers/remove_expired_members_worker.rb
@@ -6,11 +6,9 @@ class RemoveExpiredMembersWorker
def perform
Member.expired.find_each do |member|
- begin
- Members::DestroyService.new.execute(member, skip_authorization: true)
- rescue => ex
- logger.error("Expired Member ID=#{member.id} cannot be removed - #{ex}")
- end
+ Members::DestroyService.new.execute(member, skip_authorization: true)
+ rescue => ex
+ logger.error("Expired Member ID=#{member.id} cannot be removed - #{ex}")
end
end
end
diff --git a/app/workers/repository_check/batch_worker.rb b/app/workers/repository_check/batch_worker.rb
index c1bb1adc9cc..2fbe0be6e0e 100644
--- a/app/workers/repository_check/batch_worker.rb
+++ b/app/workers/repository_check/batch_worker.rb
@@ -62,7 +62,7 @@ module RepositoryCheck
# rubocop: disable CodeReuse/ActiveRecord
def never_checked_project_ids(batch_size)
projects_on_shard.where(last_repository_check_at: nil)
- .where('created_at < ?', 24.hours.ago)
+ .where("created_at < ?", 24.hours.ago)
.limit(batch_size).pluck(:id)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -70,7 +70,7 @@ module RepositoryCheck
# rubocop: disable CodeReuse/ActiveRecord
def old_checked_project_ids(batch_size)
projects_on_shard.where.not(last_repository_check_at: nil)
- .where('last_repository_check_at < ?', 1.month.ago)
+ .where("last_repository_check_at < ?", 1.month.ago)
.reorder(last_repository_check_at: :asc)
.limit(batch_size).pluck(:id)
end
diff --git a/app/workers/repository_cleanup_worker.rb b/app/workers/repository_cleanup_worker.rb
index aa26c173a72..bf9f85d4009 100644
--- a/app/workers/repository_cleanup_worker.rb
+++ b/app/workers/repository_cleanup_worker.rb
@@ -8,7 +8,7 @@ class RepositoryCleanupWorker
sidekiq_retries_exhausted do |msg, err|
next if err.is_a?(ActiveRecord::RecordNotFound)
- args = msg['args'] + [msg['error_message']]
+ args = msg["args"] + [msg["error_message"]]
new.perform_failure(*args)
end
diff --git a/app/workers/repository_fork_worker.rb b/app/workers/repository_fork_worker.rb
index a9b88a133be..bbdac6620d0 100644
--- a/app/workers/repository_fork_worker.rb
+++ b/app/workers/repository_fork_worker.rb
@@ -12,7 +12,7 @@ class RepositoryForkWorker
source_project = target_project.forked_from_project
unless source_project
- return target_project.import_state.mark_as_failed(_('Source project cannot be found.'))
+ return target_project.import_state.mark_as_failed(_("Source project cannot be found."))
end
fork_repository(target_project, source_project)
diff --git a/app/workers/repository_update_remote_mirror_worker.rb b/app/workers/repository_update_remote_mirror_worker.rb
index c0bae08ba85..c18ae6bec37 100644
--- a/app/workers/repository_update_remote_mirror_worker.rb
+++ b/app/workers/repository_update_remote_mirror_worker.rb
@@ -11,7 +11,7 @@ class RepositoryUpdateRemoteMirrorWorker
sidekiq_retry_in { |count| 30 * count }
sidekiq_retries_exhausted do |msg, _|
- Sidekiq.logger.warn "Failed #{msg['class']} with #{msg['args']}: #{msg['error_message']}"
+ Sidekiq.logger.warn "Failed #{msg["class"]} with #{msg["args"]}: #{msg["error_message"]}"
end
def perform(remote_mirror_id, scheduled_time)
diff --git a/app/workers/run_pipeline_schedule_worker.rb b/app/workers/run_pipeline_schedule_worker.rb
index f72331c003a..8651acaed47 100644
--- a/app/workers/run_pipeline_schedule_worker.rb
+++ b/app/workers/run_pipeline_schedule_worker.rb
@@ -19,8 +19,8 @@ class RunPipelineScheduleWorker
def run_pipeline_schedule(schedule, user)
Ci::CreatePipelineService.new(schedule.project,
- user,
- ref: schedule.ref)
+ user,
+ ref: schedule.ref)
.execute(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: schedule)
end
end
diff --git a/app/workers/stuck_ci_jobs_worker.rb b/app/workers/stuck_ci_jobs_worker.rb
index 25809f68080..f2b00f0f5ed 100644
--- a/app/workers/stuck_ci_jobs_worker.rb
+++ b/app/workers/stuck_ci_jobs_worker.rb
@@ -4,7 +4,7 @@ class StuckCiJobsWorker
include ApplicationWorker
include CronjobQueue
- EXCLUSIVE_LEASE_KEY = 'stuck_ci_builds_worker_lease'.freeze
+ EXCLUSIVE_LEASE_KEY = "stuck_ci_builds_worker_lease"
BUILD_RUNNING_OUTDATED_TIMEOUT = 1.hour
BUILD_PENDING_OUTDATED_TIMEOUT = 1.day
@@ -16,10 +16,10 @@ class StuckCiJobsWorker
Rails.logger.info "#{self.class}: Cleaning stuck builds"
- drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
- drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
- drop :scheduled, BUILD_SCHEDULED_OUTDATED_TIMEOUT, 'scheduled_at IS NOT NULL AND scheduled_at < ?', :stale_schedule
- drop_stuck :pending, BUILD_PENDING_STUCK_TIMEOUT, 'ci_builds.updated_at < ?', :stuck_or_timeout_failure
+ drop :running, BUILD_RUNNING_OUTDATED_TIMEOUT, "ci_builds.updated_at < ?", :stuck_or_timeout_failure
+ drop :pending, BUILD_PENDING_OUTDATED_TIMEOUT, "ci_builds.updated_at < ?", :stuck_or_timeout_failure
+ drop :scheduled, BUILD_SCHEDULED_OUTDATED_TIMEOUT, "scheduled_at IS NOT NULL AND scheduled_at < ?", :stale_schedule
+ drop_stuck :pending, BUILD_PENDING_STUCK_TIMEOUT, "ci_builds.updated_at < ?", :stuck_or_timeout_failure
remove_lease
end
diff --git a/app/workers/stuck_import_jobs_worker.rb b/app/workers/stuck_import_jobs_worker.rb
index c8a186ba4ce..626fc30a3df 100644
--- a/app/workers/stuck_import_jobs_worker.rb
+++ b/app/workers/stuck_import_jobs_worker.rb
@@ -11,8 +11,8 @@ class StuckImportJobsWorker
import_state_with_jid_count = mark_import_states_with_jid_as_failed!
Gitlab::Metrics.add_event(:stuck_import_jobs,
- projects_without_jid_count: import_state_without_jid_count,
- projects_with_jid_count: import_state_with_jid_count)
+ projects_without_jid_count: import_state_without_jid_count,
+ projects_with_jid_count: import_state_with_jid_count)
end
private
@@ -37,7 +37,7 @@ class StuckImportJobsWorker
# scheduled/started to finished/failed while we were looking up their Sidekiq status.
completed_import_states = enqueued_import_states_with_jid.where(id: completed_import_state_ids)
- completed_import_state_jids = completed_import_states.map { |import_state| import_state.jid }.join(', ')
+ completed_import_state_jids = completed_import_states.map { |import_state| import_state.jid }.join(", ")
Rails.logger.info("Marked stuck import jobs as failed. JIDs: #{completed_import_state_jids}")
completed_import_states.each do |import_state|
@@ -63,6 +63,6 @@ class StuckImportJobsWorker
# rubocop: enable CodeReuse/ActiveRecord
def error_message
- _("Import timed out. Import took longer than %{import_jobs_expiration} seconds") % { import_jobs_expiration: IMPORT_JOBS_EXPIRATION }
+ _("Import timed out. Import took longer than %{import_jobs_expiration} seconds") % {import_jobs_expiration: IMPORT_JOBS_EXPIRATION}
end
end
diff --git a/app/workers/stuck_merge_jobs_worker.rb b/app/workers/stuck_merge_jobs_worker.rb
index f34ed6c4844..73144947475 100644
--- a/app/workers/stuck_merge_jobs_worker.rb
+++ b/app/workers/stuck_merge_jobs_worker.rb
@@ -39,13 +39,13 @@ class StuckMergeJobsWorker
# We rely on state machine callbacks to update head_pipeline_id
merge_requests_to_reopen.each(&:unlock_mr)
- self.class.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(', ')}")
+ self.class.logger.info("Updated state of locked merge jobs. JIDs: #{completed_jids.join(", ")}")
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def stuck_merge_requests
- MergeRequest.select('id, merge_jid').with_state(:locked).where.not(merge_jid: nil).reorder(nil)
+ MergeRequest.select("id, merge_jid").with_state(:locked).where.not(merge_jid: nil).reorder(nil)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/app/workers/trending_projects_worker.rb b/app/workers/trending_projects_worker.rb
index 3297a1fe3d0..def43b860a7 100644
--- a/app/workers/trending_projects_worker.rb
+++ b/app/workers/trending_projects_worker.rb
@@ -5,7 +5,7 @@ class TrendingProjectsWorker
include CronjobQueue
def perform
- Rails.logger.info('Refreshing trending projects')
+ Rails.logger.info("Refreshing trending projects")
TrendingProject.refresh!
end
diff --git a/app/workers/update_merge_requests_worker.rb b/app/workers/update_merge_requests_worker.rb
index c7213df652a..ebba1610986 100644
--- a/app/workers/update_merge_requests_worker.rb
+++ b/app/workers/update_merge_requests_worker.rb
@@ -14,9 +14,9 @@ class UpdateMergeRequestsWorker
return unless user
# TODO: remove this benchmarking when we have rich logging
- time = Benchmark.measure do
+ time = Benchmark.measure {
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
- end
+ }
args_log = [
"elapsed=#{time.real}",
@@ -24,8 +24,8 @@ class UpdateMergeRequestsWorker
"user_id=#{user_id}",
"oldrev=#{oldrev}",
"newrev=#{newrev}",
- "ref=#{ref}"
- ].join(',')
+ "ref=#{ref}",
+ ].join(",")
Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD
end
diff --git a/config.ru b/config.ru
index 5cd79870d54..68b8c5b63f9 100644
--- a/config.ru
+++ b/config.ru
@@ -1,14 +1,14 @@
# This file is used by Rack-based servers to start the application.
if defined?(Unicorn)
- require 'unicorn'
+ require "unicorn"
- if ENV['RAILS_ENV'] == 'production' || ENV['RAILS_ENV'] == 'staging'
+ if ENV["RAILS_ENV"] == "production" || ENV["RAILS_ENV"] == "staging"
# Unicorn self-process killer
- require 'unicorn/worker_killer'
+ require "unicorn/worker_killer"
- min = (ENV['GITLAB_UNICORN_MEMORY_MIN'] || 400 * 1 << 20).to_i
- max = (ENV['GITLAB_UNICORN_MEMORY_MAX'] || 650 * 1 << 20).to_i
+ min = (ENV["GITLAB_UNICORN_MEMORY_MIN"] || 400 * 1 << 20).to_i
+ max = (ENV["GITLAB_UNICORN_MEMORY_MAX"] || 650 * 1 << 20).to_i
# Max memory size (RSS) per worker
use Unicorn::WorkerKiller::Oom, min, max
@@ -19,14 +19,14 @@ if defined?(Unicorn)
Unicorn::StreamInput.send(:public, :eof?) # rubocop:disable GitlabSecurity/PublicSend
end
-require ::File.expand_path('../config/environment', __FILE__)
+require ::File.expand_path("../config/environment", __FILE__)
warmup do |app|
client = Rack::MockRequest.new(app)
- client.get('/')
+ client.get("/")
end
-map ENV['RAILS_RELATIVE_URL_ROOT'] || "/" do
+map ENV["RAILS_RELATIVE_URL_ROOT"] || "/" do
use Gitlab::Middleware::ReleaseEnv
run Gitlab::Application
end
diff --git a/config/application.rb b/config/application.rb
index 1c11e347281..6d39e26b9ab 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -1,24 +1,24 @@
-require File.expand_path('boot', __dir__)
+require File.expand_path("boot", __dir__)
-require 'rails/all'
+require "rails/all"
Bundler.require(:default, Rails.env)
module Gitlab
class Application < Rails::Application
- require_dependency Rails.root.join('lib/gitlab/redis/wrapper')
- require_dependency Rails.root.join('lib/gitlab/redis/cache')
- require_dependency Rails.root.join('lib/gitlab/redis/queues')
- require_dependency Rails.root.join('lib/gitlab/redis/shared_state')
- require_dependency Rails.root.join('lib/gitlab/request_context')
- require_dependency Rails.root.join('lib/gitlab/current_settings')
- require_dependency Rails.root.join('lib/gitlab/middleware/read_only')
- require_dependency Rails.root.join('lib/gitlab/middleware/basic_health_check')
+ require_dependency Rails.root.join("lib/gitlab/redis/wrapper")
+ require_dependency Rails.root.join("lib/gitlab/redis/cache")
+ require_dependency Rails.root.join("lib/gitlab/redis/queues")
+ require_dependency Rails.root.join("lib/gitlab/redis/shared_state")
+ require_dependency Rails.root.join("lib/gitlab/request_context")
+ require_dependency Rails.root.join("lib/gitlab/current_settings")
+ require_dependency Rails.root.join("lib/gitlab/middleware/read_only")
+ require_dependency Rails.root.join("lib/gitlab/middleware/basic_health_check")
# This needs to be loaded before DB connection is made
# to make sure that all connections have NO_ZERO_DATE
# setting disabled
- require_dependency Rails.root.join('lib/mysql_zero_date')
+ require_dependency Rails.root.join("lib/mysql_zero_date")
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
@@ -32,18 +32,7 @@ module Gitlab
# https://github.com/rails/rails/blob/v4.2.6/railties/lib/rails/engine.rb#L687
# This is a nice reference article on autoloading/eager loading:
# http://blog.arkency.com/2014/11/dont-forget-about-eager-load-when-extending-autoload
- config.eager_load_paths.push(*%W[#{config.root}/lib
- #{config.root}/app/models/badges
- #{config.root}/app/models/hooks
- #{config.root}/app/models/members
- #{config.root}/app/models/project_services
- #{config.root}/app/workers/concerns
- #{config.root}/app/policies/concerns
- #{config.root}/app/services/concerns
- #{config.root}/app/serializers/concerns
- #{config.root}/app/finders/concerns
- #{config.root}/app/graphql/resolvers/concerns
- #{config.root}/app/graphql/mutations/concerns])
+ config.eager_load_paths.push("#{config.root}/lib", "#{config.root}/app/models/badges", "#{config.root}/app/models/hooks", "#{config.root}/app/models/members", "#{config.root}/app/models/project_services", "#{config.root}/app/workers/concerns", "#{config.root}/app/policies/concerns", "#{config.root}/app/services/concerns", "#{config.root}/app/serializers/concerns", "#{config.root}/app/finders/concerns", "#{config.root}/app/graphql/resolvers/concerns", "#{config.root}/app/graphql/mutations/concerns")
config.generators.templates.push("#{config.root}/generator_templates")
@@ -98,7 +87,7 @@ module Gitlab
# NOTE: It is **IMPORTANT** to also update gitlab-workhorse's filter when adding parameters here to not
# introduce another security vulnerability: https://gitlab.com/gitlab-org/gitlab-workhorse/issues/182
config.filter_parameters += [/token$/, /password/, /secret/, /key$/, /^note$/, /^text$/]
- config.filter_parameters += %i(
+ config.filter_parameters += %i[
certificate
encrypted_key
hook
@@ -108,7 +97,7 @@ module Gitlab
trace
variables
content
- )
+ ]
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
@@ -160,15 +149,15 @@ module Gitlab
config.assets.precompile << "xterm.css"
# Version of your assets, change this if you want to expire all your assets
- config.assets.version = '1.0'
+ config.assets.version = "1.0"
- config.action_view.sanitized_allowed_protocols = %w(smb)
+ config.action_view.sanitized_allowed_protocols = %w[smb]
# Can be removed once upgraded to Rails 5.1 or higher
config.action_controller.raise_on_unfiltered_parameters = true
# Nokogiri is significantly faster and uses less memory than REXML
- ActiveSupport::XmlMini.backend = 'Nokogiri'
+ ActiveSupport::XmlMini.backend = "Nokogiri"
# This middleware needs to precede ActiveRecord::QueryCache and other middlewares that
# connect to the database.
@@ -180,21 +169,21 @@ module Gitlab
config.middleware.insert_before Warden::Manager, Rack::Cors do
allow do
origins Gitlab.config.gitlab.url
- resource '/api/*',
+ resource "/api/*",
credentials: true,
headers: :any,
methods: :any,
- expose: ['Link', 'X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page']
+ expose: ["Link", "X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page"]
end
# Cross-origin requests must not have the session cookie available
allow do
- origins '*'
- resource '/api/*',
+ origins "*"
+ resource "/api/*",
credentials: false,
headers: :any,
methods: :any,
- expose: ['Link', 'X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page']
+ expose: ["Link", "X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page"]
end
end
@@ -212,8 +201,8 @@ module Gitlab
config.active_job.queue_adapter = :sidekiq
# This is needed for gitlab-shell
- ENV['GITLAB_PATH_OUTSIDE_HOOK'] = ENV['PATH']
- ENV['GIT_TERMINAL_PROMPT'] = '0'
+ ENV["GITLAB_PATH_OUTSIDE_HOOK"] = ENV["PATH"]
+ ENV["GIT_TERMINAL_PROMPT"] = "0"
# GitLab Read-only middleware support
config.middleware.insert_after ActionDispatch::Flash, ::Gitlab::Middleware::ReadOnly
@@ -225,17 +214,17 @@ module Gitlab
config.after_initialize do
Rails.application.reload_routes!
- project_url_helpers = Module.new do
+ project_url_helpers = Module.new {
extend ActiveSupport::Concern
Gitlab::Application.routes.named_routes.helper_names.each do |name|
- next unless name.include?('namespace_project')
+ next unless name.include?("namespace_project")
- define_method(name.sub('namespace_project', 'project')) do |project, *args|
+ define_method(name.sub("namespace_project", "project")) do |project, *args|
send(name, project&.namespace, project, *args)
end
end
- end
+ }
# We add the MilestonesRoutingHelper because we know that this does not
# conflict with the methods defined in `project_url_helpers`, and we want
diff --git a/config/boot.rb b/config/boot.rb
index 2811f0e6188..5901d8198f6 100644
--- a/config/boot.rb
+++ b/config/boot.rb
@@ -1,9 +1,9 @@
-ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
+ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
# Set up gems listed in the Gemfile.
-require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
+require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
begin
- require 'bootsnap/setup'
+ require "bootsnap/setup"
rescue LoadError
# bootsnap is an optional dependency, so if we don't have it, it's fine
end
diff --git a/config/environment.rb b/config/environment.rb
index 7e55c7803d3..f6cc40a42d5 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -1,6 +1,6 @@
# Load the rails application
-require_relative 'application'
+require_relative "application"
# Initialize the rails application
Rails.application.initialize!
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 494ddd72556..bd18efc561d 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -34,12 +34,12 @@ Rails.application.configure do
config.assets.raise_runtime_errors = true
# For having correct urls in mails
- config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
+ config.action_mailer.default_url_options = {host: "localhost", port: 3000}
# Open sent mails in browser
config.action_mailer.delivery_method = :letter_opener_web
# Don't make a mess when bootstrapping a development environment
- config.action_mailer.perform_deliveries = (ENV['BOOTSTRAP'] != '1')
- config.action_mailer.preview_path = 'app/mailers/previews'
+ config.action_mailer.perform_deliveries = (ENV["BOOTSTRAP"] != "1")
+ config.action_mailer.preview_path = "app/mailers/previews"
config.eager_load = false
diff --git a/config/environments/production.rb b/config/environments/production.rb
index 09bcf49a9a5..49a8dd6d218 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -39,7 +39,7 @@ Rails.application.configure do
# Suppress 'Rendered template ...' messages in the log
# source: http://stackoverflow.com/a/16369363
- %w{render_template render_partial render_collection}.each do |event|
+ %w[render_template render_partial render_collection].each do |event|
ActiveSupport::Notifications.unsubscribe "#{event}.action_view"
end
@@ -50,7 +50,7 @@ Rails.application.configure do
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Enable serving of images, stylesheets, and JavaScripts from an asset server
- config.action_controller.asset_host = ENV['GITLAB_CDN_HOST'] if ENV['GITLAB_CDN_HOST'].present?
+ config.action_controller.asset_host = ENV["GITLAB_CDN_HOST"] if ENV["GITLAB_CDN_HOST"].present?
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
# config.assets.precompile += %w( search.js )
diff --git a/config/environments/test.rb b/config/environments/test.rb
index 3461099253a..fd7e41c86a6 100644
--- a/config/environments/test.rb
+++ b/config/environments/test.rb
@@ -14,13 +14,13 @@ Rails.application.configure do
# are loaded at initalization, but it reduces memory and load because files
# are not reloaded with every request. For example, caching is not necessary
# for loading database migrations but useful for handling Knapsack specs.
- config.cache_classes = ENV['CACHE_CLASSES'] == 'true'
+ config.cache_classes = ENV["CACHE_CLASSES"] == "true"
# Configure static asset server for tests with Cache-Control for performance
- config.assets.compile = false if ENV['CI']
+ config.assets.compile = false if ENV["CI"]
config.public_file_server.enabled = true
- config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
+ config.public_file_server.headers = {"Cache-Control" => "public, max-age=3600"}
# Show full error reports and disable caching
config.consider_all_requests_local = true
@@ -46,7 +46,7 @@ Rails.application.configure do
config.active_job.queue_adapter = :test
- if ENV['CI'] && !ENV['RAILS_ENABLE_TEST_LOG']
+ if ENV["CI"] && !ENV["RAILS_ENABLE_TEST_LOG"]
config.logger = ActiveSupport::TaggedLogging.new(Logger.new(nil))
config.log_level = :fatal
end
diff --git a/config/initializers/01_secret_token.rb b/config/initializers/01_secret_token.rb
index 02bded43083..2d34ded5f92 100644
--- a/config/initializers/01_secret_token.rb
+++ b/config/initializers/01_secret_token.rb
@@ -3,7 +3,7 @@
#
# Be sure to restart your server when you modify this file.
-require 'securerandom'
+require "securerandom"
# Transition material in .secret to the secret_key_base key in config/secrets.yml.
# Historically, ENV['SECRET_KEY_BASE'] takes precedence over .secret, so we maintain that
@@ -17,9 +17,9 @@ require 'securerandom'
# .secret file to avoid confusion.
#
def create_tokens
- secret_file = Rails.root.join('.secret')
+ secret_file = Rails.root.join(".secret")
file_secret_key = File.read(secret_file).chomp if File.exist?(secret_file)
- env_secret_key = ENV['SECRET_KEY_BASE']
+ env_secret_key = ENV["SECRET_KEY_BASE"]
# Ensure environment variable always overrides secrets.yml.
Rails.application.secrets.secret_key_base = env_secret_key if env_secret_key.present?
@@ -28,7 +28,7 @@ def create_tokens
secret_key_base: file_secret_key || generate_new_secure_token,
otp_key_base: env_secret_key || file_secret_key || generate_new_secure_token,
db_key_base: generate_new_secure_token,
- openid_connect_signing_key: generate_new_rsa_private_key
+ openid_connect_signing_key: generate_new_rsa_private_key,
}
missing_secrets = set_missing_keys(defaults)
@@ -64,7 +64,7 @@ def set_missing_keys(defaults)
end
def write_secrets_yml(missing_secrets)
- secrets_yml = Rails.root.join('config/secrets.yml')
+ secrets_yml = Rails.root.join("config/secrets.yml")
rails_env = Rails.env.to_s
secrets = YAML.load_file(secrets_yml) if File.exist?(secrets_yml)
secrets ||= {}
@@ -76,12 +76,12 @@ def write_secrets_yml(missing_secrets)
# specifically, just ensure we don't break things further.
#
if old.present?
- warn <<EOM
-Rails.application.secrets.#{key} was blank, but the literal value in config/secrets.yml was:
- #{old}
+ warn <<~EOM
+ Rails.application.secrets.#{key} was blank, but the literal value in config/secrets.yml was:
+ #{old}
-This probably isn't the expected value for this secret. To keep using a literal Erb string in config/secrets.yml, replace `<%` with `<%%`.
-EOM
+ This probably isn't the expected value for this secret. To keep using a literal Erb string in config/secrets.yml, replace `<%` with `<%%`.
+ EOM
exit 1 # rubocop:disable Rails/Exit
end
@@ -89,7 +89,7 @@ EOM
new
end
- File.write(secrets_yml, YAML.dump(secrets), mode: 'w', perm: 0600)
+ File.write(secrets_yml, YAML.dump(secrets), mode: "w", perm: 0o600)
end
create_tokens
diff --git a/config/initializers/0_inflections.rb b/config/initializers/0_inflections.rb
index 1ad9ddca877..0f84c6bdd58 100644
--- a/config/initializers/0_inflections.rb
+++ b/config/initializers/0_inflections.rb
@@ -10,10 +10,10 @@
# end
#
ActiveSupport::Inflector.inflections do |inflect|
- inflect.uncountable %w(
+ inflect.uncountable %w[
award_emoji
project_statistics
system_note_metadata
project_auto_devops
- )
+ ]
end
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 1344b3cb1f6..701dde69619 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -1,88 +1,88 @@
-require_relative '../settings'
-require_relative '../object_store_settings'
+require_relative "../settings"
+require_relative "../object_store_settings"
# Default settings
-Settings['ldap'] ||= Settingslogic.new({})
-Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
+Settings["ldap"] ||= Settingslogic.new({})
+Settings.ldap["enabled"] = false if Settings.ldap["enabled"].nil?
# backwards compatibility, we only have one host
-if Settings.ldap['enabled'] || Rails.env.test?
- if Settings.ldap['host'].present?
+if Settings.ldap["enabled"] || Rails.env.test?
+ if Settings.ldap["host"].present?
# We detected old LDAP configuration syntax. Update the config to make it
# look like it was entered with the new syntax.
- server = Settings.ldap.except('sync_time')
- Settings.ldap['servers'] = {
- 'main' => server
+ server = Settings.ldap.except("sync_time")
+ Settings.ldap["servers"] = {
+ "main" => server,
}
end
- Settings.ldap['servers'].each do |key, server|
+ Settings.ldap["servers"].each do |key, server|
server = Settingslogic.new(server)
- server['label'] ||= 'LDAP'
- server['timeout'] ||= 10.seconds
- server['block_auto_created_users'] = false if server['block_auto_created_users'].nil?
- server['allow_username_or_email_login'] = false if server['allow_username_or_email_login'].nil?
- server['active_directory'] = true if server['active_directory'].nil?
- server['attributes'] = {} if server['attributes'].nil?
- server['lowercase_usernames'] = false if server['lowercase_usernames'].nil?
- server['provider_name'] ||= "ldap#{key}".downcase
- server['provider_class'] = OmniAuth::Utils.camelize(server['provider_name'])
+ server["label"] ||= "LDAP"
+ server["timeout"] ||= 10.seconds
+ server["block_auto_created_users"] = false if server["block_auto_created_users"].nil?
+ server["allow_username_or_email_login"] = false if server["allow_username_or_email_login"].nil?
+ server["active_directory"] = true if server["active_directory"].nil?
+ server["attributes"] = {} if server["attributes"].nil?
+ server["lowercase_usernames"] = false if server["lowercase_usernames"].nil?
+ server["provider_name"] ||= "ldap#{key}".downcase
+ server["provider_class"] = OmniAuth::Utils.camelize(server["provider_name"])
# For backwards compatibility
- server['encryption'] ||= server['method']
- server['encryption'] = 'simple_tls' if server['encryption'] == 'ssl'
- server['encryption'] = 'start_tls' if server['encryption'] == 'tls'
+ server["encryption"] ||= server["method"]
+ server["encryption"] = "simple_tls" if server["encryption"] == "ssl"
+ server["encryption"] = "start_tls" if server["encryption"] == "tls"
# Certificate verification was added in 9.4.2, and defaulted to false for
# backwards-compatibility.
#
# Since GitLab 10.0, verify_certificates defaults to true for security.
- server['verify_certificates'] = true if server['verify_certificates'].nil?
+ server["verify_certificates"] = true if server["verify_certificates"].nil?
- Settings.ldap['servers'][key] = server
+ Settings.ldap["servers"][key] = server
end
end
-Settings['omniauth'] ||= Settingslogic.new({})
-Settings.omniauth['enabled'] = true if Settings.omniauth['enabled'].nil?
-Settings.omniauth['auto_sign_in_with_provider'] = false if Settings.omniauth['auto_sign_in_with_provider'].nil?
-Settings.omniauth['allow_single_sign_on'] = false if Settings.omniauth['allow_single_sign_on'].nil?
-Settings.omniauth['external_providers'] = [] if Settings.omniauth['external_providers'].nil?
-Settings.omniauth['block_auto_created_users'] = true if Settings.omniauth['block_auto_created_users'].nil?
-Settings.omniauth['auto_link_ldap_user'] = false if Settings.omniauth['auto_link_ldap_user'].nil?
-Settings.omniauth['auto_link_saml_user'] = false if Settings.omniauth['auto_link_saml_user'].nil?
+Settings["omniauth"] ||= Settingslogic.new({})
+Settings.omniauth["enabled"] = true if Settings.omniauth["enabled"].nil?
+Settings.omniauth["auto_sign_in_with_provider"] = false if Settings.omniauth["auto_sign_in_with_provider"].nil?
+Settings.omniauth["allow_single_sign_on"] = false if Settings.omniauth["allow_single_sign_on"].nil?
+Settings.omniauth["external_providers"] = [] if Settings.omniauth["external_providers"].nil?
+Settings.omniauth["block_auto_created_users"] = true if Settings.omniauth["block_auto_created_users"].nil?
+Settings.omniauth["auto_link_ldap_user"] = false if Settings.omniauth["auto_link_ldap_user"].nil?
+Settings.omniauth["auto_link_saml_user"] = false if Settings.omniauth["auto_link_saml_user"].nil?
-Settings.omniauth['sync_profile_from_provider'] = false if Settings.omniauth['sync_profile_from_provider'].nil?
-Settings.omniauth['sync_profile_attributes'] = ['email'] if Settings.omniauth['sync_profile_attributes'].nil?
+Settings.omniauth["sync_profile_from_provider"] = false if Settings.omniauth["sync_profile_from_provider"].nil?
+Settings.omniauth["sync_profile_attributes"] = ["email"] if Settings.omniauth["sync_profile_attributes"].nil?
# Handle backwards compatibility with merge request 11268
-if Settings.omniauth['sync_email_from_provider']
- if Settings.omniauth['sync_profile_from_provider'].is_a?(Array)
- Settings.omniauth['sync_profile_from_provider'] |= [Settings.omniauth['sync_email_from_provider']]
- elsif !Settings.omniauth['sync_profile_from_provider']
- Settings.omniauth['sync_profile_from_provider'] = [Settings.omniauth['sync_email_from_provider']]
+if Settings.omniauth["sync_email_from_provider"]
+ if Settings.omniauth["sync_profile_from_provider"].is_a?(Array)
+ Settings.omniauth["sync_profile_from_provider"] |= [Settings.omniauth["sync_email_from_provider"]]
+ elsif !Settings.omniauth["sync_profile_from_provider"]
+ Settings.omniauth["sync_profile_from_provider"] = [Settings.omniauth["sync_email_from_provider"]]
end
- Settings.omniauth['sync_profile_attributes'] |= ['email'] unless Settings.omniauth['sync_profile_attributes'] == true
+ Settings.omniauth["sync_profile_attributes"] |= ["email"] unless Settings.omniauth["sync_profile_attributes"] == true
end
-Settings.omniauth['providers'] ||= []
-Settings.omniauth['cas3'] ||= Settingslogic.new({})
-Settings.omniauth.cas3['session_duration'] ||= 8.hours
-Settings.omniauth['session_tickets'] ||= Settingslogic.new({})
-Settings.omniauth.session_tickets['cas3'] = 'ticket'
+Settings.omniauth["providers"] ||= []
+Settings.omniauth["cas3"] ||= Settingslogic.new({})
+Settings.omniauth.cas3["session_duration"] ||= 8.hours
+Settings.omniauth["session_tickets"] ||= Settingslogic.new({})
+Settings.omniauth.session_tickets["cas3"] = "ticket"
# Fill out omniauth-gitlab settings. It is needed for easy set up GHE or GH by just specifying url.
github_default_url = "https://github.com"
-github_settings = Settings.omniauth['providers'].find { |provider| provider["name"] == "github" }
+github_settings = Settings.omniauth["providers"].find { |provider| provider["name"] == "github" }
if github_settings
# For compatibility with old config files (before 7.8)
# where people dont have url in github settings
- if github_settings['url'].blank?
- github_settings['url'] = github_default_url
+ if github_settings["url"].blank?
+ github_settings["url"] = github_default_url
end
github_settings["args"] ||= Settingslogic.new({})
@@ -92,279 +92,279 @@ if github_settings
OmniAuth::Strategies::GitHub.default_options[:client_options]
else
{
- "site" => File.join(github_settings["url"], "api/v3"),
+ "site" => File.join(github_settings["url"], "api/v3"),
"authorize_url" => File.join(github_settings["url"], "login/oauth/authorize"),
- "token_url" => File.join(github_settings["url"], "login/oauth/access_token")
+ "token_url" => File.join(github_settings["url"], "login/oauth/access_token"),
}
end
end
-Settings['shared'] ||= Settingslogic.new({})
-Settings.shared['path'] = Settings.absolute(Settings.shared['path'] || "shared")
+Settings["shared"] ||= Settingslogic.new({})
+Settings.shared["path"] = Settings.absolute(Settings.shared["path"] || "shared")
-Settings['issues_tracker'] ||= {}
+Settings["issues_tracker"] ||= {}
#
# GitLab
#
-Settings['gitlab'] ||= Settingslogic.new({})
-Settings.gitlab['default_projects_limit'] ||= 100000
-Settings.gitlab['default_branch_protection'] ||= 2
-Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil?
-Settings.gitlab['default_theme'] = Gitlab::Themes::APPLICATION_DEFAULT if Settings.gitlab['default_theme'].nil?
-Settings.gitlab['host'] ||= ENV['GITLAB_HOST'] || 'localhost'
-Settings.gitlab['ssh_host'] ||= Settings.gitlab.host
-Settings.gitlab['https'] = false if Settings.gitlab['https'].nil?
-Settings.gitlab['port'] ||= ENV['GITLAB_PORT'] || (Settings.gitlab.https ? 443 : 80)
-Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''
-Settings.gitlab['protocol'] ||= Settings.gitlab.https ? "https" : "http"
-Settings.gitlab['email_enabled'] ||= true if Settings.gitlab['email_enabled'].nil?
-Settings.gitlab['email_from'] ||= ENV['GITLAB_EMAIL_FROM'] || "gitlab@#{Settings.gitlab.host}"
-Settings.gitlab['email_display_name'] ||= ENV['GITLAB_EMAIL_DISPLAY_NAME'] || 'GitLab'
-Settings.gitlab['email_reply_to'] ||= ENV['GITLAB_EMAIL_REPLY_TO'] || "noreply@#{Settings.gitlab.host}"
-Settings.gitlab['email_subject_suffix'] ||= ENV['GITLAB_EMAIL_SUBJECT_SUFFIX'] || ""
-Settings.gitlab['base_url'] ||= Settings.__send__(:build_base_gitlab_url)
-Settings.gitlab['url'] ||= Settings.__send__(:build_gitlab_url)
-Settings.gitlab['user'] ||= 'git'
-Settings.gitlab['user_home'] ||= begin
- Etc.getpwnam(Settings.gitlab['user']).dir
-rescue ArgumentError # no user configured
- '/home/' + Settings.gitlab['user']
+Settings["gitlab"] ||= Settingslogic.new({})
+Settings.gitlab["default_projects_limit"] ||= 100000
+Settings.gitlab["default_branch_protection"] ||= 2
+Settings.gitlab["default_can_create_group"] = true if Settings.gitlab["default_can_create_group"].nil?
+Settings.gitlab["default_theme"] = Gitlab::Themes::APPLICATION_DEFAULT if Settings.gitlab["default_theme"].nil?
+Settings.gitlab["host"] ||= ENV["GITLAB_HOST"] || "localhost"
+Settings.gitlab["ssh_host"] ||= Settings.gitlab.host
+Settings.gitlab["https"] = false if Settings.gitlab["https"].nil?
+Settings.gitlab["port"] ||= ENV["GITLAB_PORT"] || (Settings.gitlab.https ? 443 : 80)
+Settings.gitlab["relative_url_root"] ||= ENV["RAILS_RELATIVE_URL_ROOT"] || ""
+Settings.gitlab["protocol"] ||= Settings.gitlab.https ? "https" : "http"
+Settings.gitlab["email_enabled"] ||= true if Settings.gitlab["email_enabled"].nil?
+Settings.gitlab["email_from"] ||= ENV["GITLAB_EMAIL_FROM"] || "gitlab@#{Settings.gitlab.host}"
+Settings.gitlab["email_display_name"] ||= ENV["GITLAB_EMAIL_DISPLAY_NAME"] || "GitLab"
+Settings.gitlab["email_reply_to"] ||= ENV["GITLAB_EMAIL_REPLY_TO"] || "noreply@#{Settings.gitlab.host}"
+Settings.gitlab["email_subject_suffix"] ||= ENV["GITLAB_EMAIL_SUBJECT_SUFFIX"] || ""
+Settings.gitlab["base_url"] ||= Settings.__send__(:build_base_gitlab_url)
+Settings.gitlab["url"] ||= Settings.__send__(:build_gitlab_url)
+Settings.gitlab["user"] ||= "git"
+Settings.gitlab["user_home"] ||= begin
+ Etc.getpwnam(Settings.gitlab["user"]).dir
+ rescue ArgumentError # no user configured
+ "/home/" + Settings.gitlab["user"]
end
-Settings.gitlab['time_zone'] ||= nil
-Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].nil?
-Settings.gitlab['signin_enabled'] ||= true if Settings.gitlab['signin_enabled'].nil?
-Settings.gitlab['restricted_visibility_levels'] = Settings.__send__(:verify_constant_array, Gitlab::VisibilityLevel, Settings.gitlab['restricted_visibility_levels'], [])
-Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil?
-Settings.gitlab['issue_closing_pattern'] = '\b((?:[Cc]los(?:e[sd]?|ing)|\b[Ff]ix(?:e[sd]|ing)?|\b[Rr]esolv(?:e[sd]?|ing)|\b[Ii]mplement(?:s|ed|ing)?)(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?: *,? +and +| *,? *)?)|([A-Z][A-Z0-9_]+-\d+))+)' if Settings.gitlab['issue_closing_pattern'].nil?
-Settings.gitlab['default_projects_features'] ||= {}
-Settings.gitlab['webhook_timeout'] ||= 10
-Settings.gitlab['max_attachment_size'] ||= 10
-Settings.gitlab['session_expire_delay'] ||= 10080
-Settings.gitlab['unauthenticated_session_expire_delay'] ||= 2.hours.to_i
-Settings.gitlab.default_projects_features['issues'] = true if Settings.gitlab.default_projects_features['issues'].nil?
-Settings.gitlab.default_projects_features['merge_requests'] = true if Settings.gitlab.default_projects_features['merge_requests'].nil?
-Settings.gitlab.default_projects_features['wiki'] = true if Settings.gitlab.default_projects_features['wiki'].nil?
-Settings.gitlab.default_projects_features['snippets'] = true if Settings.gitlab.default_projects_features['snippets'].nil?
-Settings.gitlab.default_projects_features['builds'] = true if Settings.gitlab.default_projects_features['builds'].nil?
-Settings.gitlab.default_projects_features['container_registry'] = true if Settings.gitlab.default_projects_features['container_registry'].nil?
-Settings.gitlab.default_projects_features['visibility_level'] = Settings.__send__(:verify_constant, Gitlab::VisibilityLevel, Settings.gitlab.default_projects_features['visibility_level'], Gitlab::VisibilityLevel::PRIVATE)
-Settings.gitlab['domain_whitelist'] ||= []
-Settings.gitlab['import_sources'] ||= Gitlab::ImportSources.values
-Settings.gitlab['trusted_proxies'] ||= []
-Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml'))
-Settings.gitlab['impersonation_enabled'] ||= true if Settings.gitlab['impersonation_enabled'].nil?
-Settings.gitlab['usage_ping_enabled'] = true if Settings.gitlab['usage_ping_enabled'].nil?
+Settings.gitlab["time_zone"] ||= nil
+Settings.gitlab["signup_enabled"] ||= true if Settings.gitlab["signup_enabled"].nil?
+Settings.gitlab["signin_enabled"] ||= true if Settings.gitlab["signin_enabled"].nil?
+Settings.gitlab["restricted_visibility_levels"] = Settings.__send__(:verify_constant_array, Gitlab::VisibilityLevel, Settings.gitlab["restricted_visibility_levels"], [])
+Settings.gitlab["username_changing_enabled"] = true if Settings.gitlab["username_changing_enabled"].nil?
+Settings.gitlab["issue_closing_pattern"] = '\b((?:[Cc]los(?:e[sd]?|ing)|\b[Ff]ix(?:e[sd]|ing)?|\b[Rr]esolv(?:e[sd]?|ing)|\b[Ii]mplement(?:s|ed|ing)?)(:?) +(?:(?:issues? +)?%{issue_ref}(?:(?: *,? +and +| *,? *)?)|([A-Z][A-Z0-9_]+-\d+))+)' if Settings.gitlab["issue_closing_pattern"].nil?
+Settings.gitlab["default_projects_features"] ||= {}
+Settings.gitlab["webhook_timeout"] ||= 10
+Settings.gitlab["max_attachment_size"] ||= 10
+Settings.gitlab["session_expire_delay"] ||= 10080
+Settings.gitlab["unauthenticated_session_expire_delay"] ||= 2.hours.to_i
+Settings.gitlab.default_projects_features["issues"] = true if Settings.gitlab.default_projects_features["issues"].nil?
+Settings.gitlab.default_projects_features["merge_requests"] = true if Settings.gitlab.default_projects_features["merge_requests"].nil?
+Settings.gitlab.default_projects_features["wiki"] = true if Settings.gitlab.default_projects_features["wiki"].nil?
+Settings.gitlab.default_projects_features["snippets"] = true if Settings.gitlab.default_projects_features["snippets"].nil?
+Settings.gitlab.default_projects_features["builds"] = true if Settings.gitlab.default_projects_features["builds"].nil?
+Settings.gitlab.default_projects_features["container_registry"] = true if Settings.gitlab.default_projects_features["container_registry"].nil?
+Settings.gitlab.default_projects_features["visibility_level"] = Settings.__send__(:verify_constant, Gitlab::VisibilityLevel, Settings.gitlab.default_projects_features["visibility_level"], Gitlab::VisibilityLevel::PRIVATE)
+Settings.gitlab["domain_whitelist"] ||= []
+Settings.gitlab["import_sources"] ||= Gitlab::ImportSources.values
+Settings.gitlab["trusted_proxies"] ||= []
+Settings.gitlab["no_todos_messages"] ||= YAML.load_file(Rails.root.join("config", "no_todos_messages.yml"))
+Settings.gitlab["impersonation_enabled"] ||= true if Settings.gitlab["impersonation_enabled"].nil?
+Settings.gitlab["usage_ping_enabled"] = true if Settings.gitlab["usage_ping_enabled"].nil?
#
# CI
#
-Settings['gitlab_ci'] ||= Settingslogic.new({})
-Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil?
-Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
-Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
-Settings.gitlab_ci['builds_path'] = Settings.absolute(Settings.gitlab_ci['builds_path'] || "builds/")
-Settings.gitlab_ci['url'] ||= Settings.__send__(:build_gitlab_ci_url)
+Settings["gitlab_ci"] ||= Settingslogic.new({})
+Settings.gitlab_ci["shared_runners_enabled"] = true if Settings.gitlab_ci["shared_runners_enabled"].nil?
+Settings.gitlab_ci["all_broken_builds"] = true if Settings.gitlab_ci["all_broken_builds"].nil?
+Settings.gitlab_ci["add_pusher"] = false if Settings.gitlab_ci["add_pusher"].nil?
+Settings.gitlab_ci["builds_path"] = Settings.absolute(Settings.gitlab_ci["builds_path"] || "builds/")
+Settings.gitlab_ci["url"] ||= Settings.__send__(:build_gitlab_ci_url)
#
# Reply by email
#
-Settings['incoming_email'] ||= Settingslogic.new({})
-Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'].nil?
+Settings["incoming_email"] ||= Settingslogic.new({})
+Settings.incoming_email["enabled"] = false if Settings.incoming_email["enabled"].nil?
#
# Build Artifacts
#
-Settings['artifacts'] ||= Settingslogic.new({})
-Settings.artifacts['enabled'] = true if Settings.artifacts['enabled'].nil?
-Settings.artifacts['storage_path'] = Settings.absolute(Settings.artifacts.values_at('path', 'storage_path').compact.first || File.join(Settings.shared['path'], "artifacts"))
+Settings["artifacts"] ||= Settingslogic.new({})
+Settings.artifacts["enabled"] = true if Settings.artifacts["enabled"].nil?
+Settings.artifacts["storage_path"] = Settings.absolute(Settings.artifacts.values_at("path", "storage_path").compact.first || File.join(Settings.shared["path"], "artifacts"))
# Settings.artifact['path'] is deprecated, use `storage_path` instead
-Settings.artifacts['path'] = Settings.artifacts['storage_path']
-Settings.artifacts['max_size'] ||= 100 # in megabytes
-Settings.artifacts['object_store'] = ObjectStoreSettings.parse(Settings.artifacts['object_store'])
+Settings.artifacts["path"] = Settings.artifacts["storage_path"]
+Settings.artifacts["max_size"] ||= 100 # in megabytes
+Settings.artifacts["object_store"] = ObjectStoreSettings.parse(Settings.artifacts["object_store"])
#
# Registry
#
-Settings['registry'] ||= Settingslogic.new({})
-Settings.registry['enabled'] ||= false
-Settings.registry['host'] ||= "example.com"
-Settings.registry['port'] ||= nil
-Settings.registry['api_url'] ||= "http://localhost:5000/"
-Settings.registry['key'] ||= nil
-Settings.registry['issuer'] ||= nil
-Settings.registry['host_port'] ||= [Settings.registry['host'], Settings.registry['port']].compact.join(':')
-Settings.registry['path'] = Settings.absolute(Settings.registry['path'] || File.join(Settings.shared['path'], 'registry'))
+Settings["registry"] ||= Settingslogic.new({})
+Settings.registry["enabled"] ||= false
+Settings.registry["host"] ||= "example.com"
+Settings.registry["port"] ||= nil
+Settings.registry["api_url"] ||= "http://localhost:5000/"
+Settings.registry["key"] ||= nil
+Settings.registry["issuer"] ||= nil
+Settings.registry["host_port"] ||= [Settings.registry["host"], Settings.registry["port"]].compact.join(":")
+Settings.registry["path"] = Settings.absolute(Settings.registry["path"] || File.join(Settings.shared["path"], "registry"))
#
# Pages
#
-Settings['pages'] ||= Settingslogic.new({})
-Settings.pages['enabled'] = false if Settings.pages['enabled'].nil?
-Settings.pages['access_control'] = false if Settings.pages['access_control'].nil?
-Settings.pages['path'] = Settings.absolute(Settings.pages['path'] || File.join(Settings.shared['path'], "pages"))
-Settings.pages['https'] = false if Settings.pages['https'].nil?
-Settings.pages['host'] ||= "example.com"
-Settings.pages['port'] ||= Settings.pages.https ? 443 : 80
-Settings.pages['protocol'] ||= Settings.pages.https ? "https" : "http"
-Settings.pages['url'] ||= Settings.__send__(:build_pages_url)
-Settings.pages['external_http'] ||= false unless Settings.pages['external_http'].present?
-Settings.pages['external_https'] ||= false unless Settings.pages['external_https'].present?
-Settings.pages['artifacts_server'] ||= Settings.pages['enabled'] if Settings.pages['artifacts_server'].nil?
+Settings["pages"] ||= Settingslogic.new({})
+Settings.pages["enabled"] = false if Settings.pages["enabled"].nil?
+Settings.pages["access_control"] = false if Settings.pages["access_control"].nil?
+Settings.pages["path"] = Settings.absolute(Settings.pages["path"] || File.join(Settings.shared["path"], "pages"))
+Settings.pages["https"] = false if Settings.pages["https"].nil?
+Settings.pages["host"] ||= "example.com"
+Settings.pages["port"] ||= Settings.pages.https ? 443 : 80
+Settings.pages["protocol"] ||= Settings.pages.https ? "https" : "http"
+Settings.pages["url"] ||= Settings.__send__(:build_pages_url)
+Settings.pages["external_http"] ||= false unless Settings.pages["external_http"].present?
+Settings.pages["external_https"] ||= false unless Settings.pages["external_https"].present?
+Settings.pages["artifacts_server"] ||= Settings.pages["enabled"] if Settings.pages["artifacts_server"].nil?
-Settings.pages['admin'] ||= Settingslogic.new({})
-Settings.pages.admin['certificate'] ||= ''
+Settings.pages["admin"] ||= Settingslogic.new({})
+Settings.pages.admin["certificate"] ||= ""
#
# External merge request diffs
#
-Settings['external_diffs'] ||= Settingslogic.new({})
-Settings.external_diffs['enabled'] = false if Settings.external_diffs['enabled'].nil?
-Settings.external_diffs['storage_path'] = Settings.absolute(Settings.external_diffs['storage_path'] || File.join(Settings.shared['path'], 'external-diffs'))
-Settings.external_diffs['object_store'] = ObjectStoreSettings.parse(Settings.external_diffs['object_store'])
+Settings["external_diffs"] ||= Settingslogic.new({})
+Settings.external_diffs["enabled"] = false if Settings.external_diffs["enabled"].nil?
+Settings.external_diffs["storage_path"] = Settings.absolute(Settings.external_diffs["storage_path"] || File.join(Settings.shared["path"], "external-diffs"))
+Settings.external_diffs["object_store"] = ObjectStoreSettings.parse(Settings.external_diffs["object_store"])
#
# Git LFS
#
-Settings['lfs'] ||= Settingslogic.new({})
-Settings.lfs['enabled'] = true if Settings.lfs['enabled'].nil?
-Settings.lfs['storage_path'] = Settings.absolute(Settings.lfs['storage_path'] || File.join(Settings.shared['path'], "lfs-objects"))
-Settings.lfs['object_store'] = ObjectStoreSettings.parse(Settings.lfs['object_store'])
+Settings["lfs"] ||= Settingslogic.new({})
+Settings.lfs["enabled"] = true if Settings.lfs["enabled"].nil?
+Settings.lfs["storage_path"] = Settings.absolute(Settings.lfs["storage_path"] || File.join(Settings.shared["path"], "lfs-objects"))
+Settings.lfs["object_store"] = ObjectStoreSettings.parse(Settings.lfs["object_store"])
#
# Uploads
#
-Settings['uploads'] ||= Settingslogic.new({})
-Settings.uploads['storage_path'] = Settings.absolute(Settings.uploads['storage_path'] || 'public')
-Settings.uploads['base_dir'] = Settings.uploads['base_dir'] || 'uploads/-/system'
-Settings.uploads['object_store'] = ObjectStoreSettings.parse(Settings.uploads['object_store'])
-Settings.uploads['object_store']['remote_directory'] ||= 'uploads'
+Settings["uploads"] ||= Settingslogic.new({})
+Settings.uploads["storage_path"] = Settings.absolute(Settings.uploads["storage_path"] || "public")
+Settings.uploads["base_dir"] = Settings.uploads["base_dir"] || "uploads/-/system"
+Settings.uploads["object_store"] = ObjectStoreSettings.parse(Settings.uploads["object_store"])
+Settings.uploads["object_store"]["remote_directory"] ||= "uploads"
#
# Mattermost
#
-Settings['mattermost'] ||= Settingslogic.new({})
-Settings.mattermost['enabled'] = false if Settings.mattermost['enabled'].nil?
-Settings.mattermost['host'] = nil unless Settings.mattermost.enabled
+Settings["mattermost"] ||= Settingslogic.new({})
+Settings.mattermost["enabled"] = false if Settings.mattermost["enabled"].nil?
+Settings.mattermost["host"] = nil unless Settings.mattermost.enabled
#
# Gravatar
#
-Settings['gravatar'] ||= Settingslogic.new({})
-Settings.gravatar['enabled'] = true if Settings.gravatar['enabled'].nil?
-Settings.gravatar['plain_url'] ||= 'https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
-Settings.gravatar['ssl_url'] ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon'
-Settings.gravatar['host'] = Settings.host_without_www(Settings.gravatar['plain_url'])
+Settings["gravatar"] ||= Settingslogic.new({})
+Settings.gravatar["enabled"] = true if Settings.gravatar["enabled"].nil?
+Settings.gravatar["plain_url"] ||= "https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon"
+Settings.gravatar["ssl_url"] ||= "https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon"
+Settings.gravatar["host"] = Settings.host_without_www(Settings.gravatar["plain_url"])
#
# Cron Jobs
#
-Settings['cron_jobs'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_ci_jobs_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_ci_jobs_worker']['cron'] ||= '0 * * * *'
-Settings.cron_jobs['stuck_ci_jobs_worker']['job_class'] = 'StuckCiJobsWorker'
-Settings.cron_jobs['pipeline_schedule_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['pipeline_schedule_worker']['cron'] ||= '19 * * * *'
-Settings.cron_jobs['pipeline_schedule_worker']['job_class'] = 'PipelineScheduleWorker'
-Settings.cron_jobs['expire_build_artifacts_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['expire_build_artifacts_worker']['cron'] ||= '50 * * * *'
-Settings.cron_jobs['expire_build_artifacts_worker']['job_class'] = 'ExpireBuildArtifactsWorker'
-Settings.cron_jobs['repository_check_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['repository_check_worker']['cron'] ||= '20 * * * *'
-Settings.cron_jobs['repository_check_worker']['job_class'] = 'RepositoryCheck::DispatchWorker'
-Settings.cron_jobs['admin_email_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['admin_email_worker']['cron'] ||= '0 0 * * 0'
-Settings.cron_jobs['admin_email_worker']['job_class'] = 'AdminEmailWorker'
-Settings.cron_jobs['repository_archive_cache_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['repository_archive_cache_worker']['cron'] ||= '0 * * * *'
-Settings.cron_jobs['repository_archive_cache_worker']['job_class'] = 'RepositoryArchiveCacheWorker'
-Settings.cron_jobs['import_export_project_cleanup_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['import_export_project_cleanup_worker']['cron'] ||= '0 * * * *'
-Settings.cron_jobs['import_export_project_cleanup_worker']['job_class'] = 'ImportExportProjectCleanupWorker'
-Settings.cron_jobs['ci_archive_traces_cron_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['ci_archive_traces_cron_worker']['cron'] ||= '17 * * * *'
-Settings.cron_jobs['ci_archive_traces_cron_worker']['job_class'] = 'Ci::ArchiveTracesCronWorker'
-Settings.cron_jobs['requests_profiles_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['requests_profiles_worker']['cron'] ||= '0 0 * * *'
-Settings.cron_jobs['requests_profiles_worker']['job_class'] = 'RequestsProfilesWorker'
-Settings.cron_jobs['remove_expired_members_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['remove_expired_members_worker']['cron'] ||= '10 0 * * *'
-Settings.cron_jobs['remove_expired_members_worker']['job_class'] = 'RemoveExpiredMembersWorker'
-Settings.cron_jobs['remove_expired_group_links_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['remove_expired_group_links_worker']['cron'] ||= '10 0 * * *'
-Settings.cron_jobs['remove_expired_group_links_worker']['job_class'] = 'RemoveExpiredGroupLinksWorker'
-Settings.cron_jobs['prune_old_events_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['prune_old_events_worker']['cron'] ||= '0 */6 * * *'
-Settings.cron_jobs['prune_old_events_worker']['job_class'] = 'PruneOldEventsWorker'
-
-Settings.cron_jobs['trending_projects_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['trending_projects_worker']['cron'] = '0 1 * * *'
-Settings.cron_jobs['trending_projects_worker']['job_class'] = 'TrendingProjectsWorker'
-Settings.cron_jobs['remove_unreferenced_lfs_objects_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['remove_unreferenced_lfs_objects_worker']['cron'] ||= '20 0 * * *'
-Settings.cron_jobs['remove_unreferenced_lfs_objects_worker']['job_class'] = 'RemoveUnreferencedLfsObjectsWorker'
-Settings.cron_jobs['stuck_import_jobs_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_import_jobs_worker']['cron'] ||= '15 * * * *'
-Settings.cron_jobs['stuck_import_jobs_worker']['job_class'] = 'StuckImportJobsWorker'
-Settings.cron_jobs['gitlab_usage_ping_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['gitlab_usage_ping_worker']['cron'] ||= Settings.__send__(:cron_for_usage_ping)
-Settings.cron_jobs['gitlab_usage_ping_worker']['job_class'] = 'GitlabUsagePingWorker'
-
-Settings.cron_jobs['stuck_merge_jobs_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['stuck_merge_jobs_worker']['cron'] ||= '0 */2 * * *'
-Settings.cron_jobs['stuck_merge_jobs_worker']['job_class'] = 'StuckMergeJobsWorker'
-
-Settings.cron_jobs['pages_domain_verification_cron_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['pages_domain_verification_cron_worker']['cron'] ||= '*/15 * * * *'
-Settings.cron_jobs['pages_domain_verification_cron_worker']['job_class'] = 'PagesDomainVerificationCronWorker'
-
-Settings.cron_jobs['issue_due_scheduler_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['issue_due_scheduler_worker']['cron'] ||= '50 00 * * *'
-Settings.cron_jobs['issue_due_scheduler_worker']['job_class'] = 'IssueDueSchedulerWorker'
-
-Settings.cron_jobs['prune_web_hook_logs_worker'] ||= Settingslogic.new({})
-Settings.cron_jobs['prune_web_hook_logs_worker']['cron'] ||= '0 */1 * * *'
-Settings.cron_jobs['prune_web_hook_logs_worker']['job_class'] = 'PruneWebHookLogsWorker'
+Settings["cron_jobs"] ||= Settingslogic.new({})
+Settings.cron_jobs["stuck_ci_jobs_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["stuck_ci_jobs_worker"]["cron"] ||= "0 * * * *"
+Settings.cron_jobs["stuck_ci_jobs_worker"]["job_class"] = "StuckCiJobsWorker"
+Settings.cron_jobs["pipeline_schedule_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["pipeline_schedule_worker"]["cron"] ||= "19 * * * *"
+Settings.cron_jobs["pipeline_schedule_worker"]["job_class"] = "PipelineScheduleWorker"
+Settings.cron_jobs["expire_build_artifacts_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["expire_build_artifacts_worker"]["cron"] ||= "50 * * * *"
+Settings.cron_jobs["expire_build_artifacts_worker"]["job_class"] = "ExpireBuildArtifactsWorker"
+Settings.cron_jobs["repository_check_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["repository_check_worker"]["cron"] ||= "20 * * * *"
+Settings.cron_jobs["repository_check_worker"]["job_class"] = "RepositoryCheck::DispatchWorker"
+Settings.cron_jobs["admin_email_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["admin_email_worker"]["cron"] ||= "0 0 * * 0"
+Settings.cron_jobs["admin_email_worker"]["job_class"] = "AdminEmailWorker"
+Settings.cron_jobs["repository_archive_cache_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["repository_archive_cache_worker"]["cron"] ||= "0 * * * *"
+Settings.cron_jobs["repository_archive_cache_worker"]["job_class"] = "RepositoryArchiveCacheWorker"
+Settings.cron_jobs["import_export_project_cleanup_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["import_export_project_cleanup_worker"]["cron"] ||= "0 * * * *"
+Settings.cron_jobs["import_export_project_cleanup_worker"]["job_class"] = "ImportExportProjectCleanupWorker"
+Settings.cron_jobs["ci_archive_traces_cron_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["ci_archive_traces_cron_worker"]["cron"] ||= "17 * * * *"
+Settings.cron_jobs["ci_archive_traces_cron_worker"]["job_class"] = "Ci::ArchiveTracesCronWorker"
+Settings.cron_jobs["requests_profiles_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["requests_profiles_worker"]["cron"] ||= "0 0 * * *"
+Settings.cron_jobs["requests_profiles_worker"]["job_class"] = "RequestsProfilesWorker"
+Settings.cron_jobs["remove_expired_members_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["remove_expired_members_worker"]["cron"] ||= "10 0 * * *"
+Settings.cron_jobs["remove_expired_members_worker"]["job_class"] = "RemoveExpiredMembersWorker"
+Settings.cron_jobs["remove_expired_group_links_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["remove_expired_group_links_worker"]["cron"] ||= "10 0 * * *"
+Settings.cron_jobs["remove_expired_group_links_worker"]["job_class"] = "RemoveExpiredGroupLinksWorker"
+Settings.cron_jobs["prune_old_events_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["prune_old_events_worker"]["cron"] ||= "0 */6 * * *"
+Settings.cron_jobs["prune_old_events_worker"]["job_class"] = "PruneOldEventsWorker"
+
+Settings.cron_jobs["trending_projects_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["trending_projects_worker"]["cron"] = "0 1 * * *"
+Settings.cron_jobs["trending_projects_worker"]["job_class"] = "TrendingProjectsWorker"
+Settings.cron_jobs["remove_unreferenced_lfs_objects_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["remove_unreferenced_lfs_objects_worker"]["cron"] ||= "20 0 * * *"
+Settings.cron_jobs["remove_unreferenced_lfs_objects_worker"]["job_class"] = "RemoveUnreferencedLfsObjectsWorker"
+Settings.cron_jobs["stuck_import_jobs_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["stuck_import_jobs_worker"]["cron"] ||= "15 * * * *"
+Settings.cron_jobs["stuck_import_jobs_worker"]["job_class"] = "StuckImportJobsWorker"
+Settings.cron_jobs["gitlab_usage_ping_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["gitlab_usage_ping_worker"]["cron"] ||= Settings.__send__(:cron_for_usage_ping)
+Settings.cron_jobs["gitlab_usage_ping_worker"]["job_class"] = "GitlabUsagePingWorker"
+
+Settings.cron_jobs["stuck_merge_jobs_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["stuck_merge_jobs_worker"]["cron"] ||= "0 */2 * * *"
+Settings.cron_jobs["stuck_merge_jobs_worker"]["job_class"] = "StuckMergeJobsWorker"
+
+Settings.cron_jobs["pages_domain_verification_cron_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["pages_domain_verification_cron_worker"]["cron"] ||= "*/15 * * * *"
+Settings.cron_jobs["pages_domain_verification_cron_worker"]["job_class"] = "PagesDomainVerificationCronWorker"
+
+Settings.cron_jobs["issue_due_scheduler_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["issue_due_scheduler_worker"]["cron"] ||= "50 00 * * *"
+Settings.cron_jobs["issue_due_scheduler_worker"]["job_class"] = "IssueDueSchedulerWorker"
+
+Settings.cron_jobs["prune_web_hook_logs_worker"] ||= Settingslogic.new({})
+Settings.cron_jobs["prune_web_hook_logs_worker"]["cron"] ||= "0 */1 * * *"
+Settings.cron_jobs["prune_web_hook_logs_worker"]["job_class"] = "PruneWebHookLogsWorker"
#
# Sidekiq
#
-Settings['sidekiq'] ||= Settingslogic.new({})
-Settings['sidekiq']['log_format'] ||= 'default'
+Settings["sidekiq"] ||= Settingslogic.new({})
+Settings["sidekiq"]["log_format"] ||= "default"
#
# GitLab Shell
#
-Settings['gitlab_shell'] ||= Settingslogic.new({})
-Settings.gitlab_shell['path'] = Settings.absolute(Settings.gitlab_shell['path'] || Settings.gitlab['user_home'] + '/gitlab-shell/')
-Settings.gitlab_shell['hooks_path'] = :deprecated_use_gitlab_shell_path_instead
-Settings.gitlab_shell['secret_file'] ||= Rails.root.join('.gitlab_shell_secret')
-Settings.gitlab_shell['receive_pack'] = true if Settings.gitlab_shell['receive_pack'].nil?
-Settings.gitlab_shell['upload_pack'] = true if Settings.gitlab_shell['upload_pack'].nil?
-Settings.gitlab_shell['ssh_host'] ||= Settings.gitlab.ssh_host
-Settings.gitlab_shell['ssh_port'] ||= 22
-Settings.gitlab_shell['ssh_user'] ||= Settings.gitlab.user
-Settings.gitlab_shell['owner_group'] ||= Settings.gitlab.user
-Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.__send__(:build_gitlab_shell_ssh_path_prefix)
-Settings.gitlab_shell['git_timeout'] ||= 10800
+Settings["gitlab_shell"] ||= Settingslogic.new({})
+Settings.gitlab_shell["path"] = Settings.absolute(Settings.gitlab_shell["path"] || Settings.gitlab["user_home"] + "/gitlab-shell/")
+Settings.gitlab_shell["hooks_path"] = :deprecated_use_gitlab_shell_path_instead
+Settings.gitlab_shell["secret_file"] ||= Rails.root.join(".gitlab_shell_secret")
+Settings.gitlab_shell["receive_pack"] = true if Settings.gitlab_shell["receive_pack"].nil?
+Settings.gitlab_shell["upload_pack"] = true if Settings.gitlab_shell["upload_pack"].nil?
+Settings.gitlab_shell["ssh_host"] ||= Settings.gitlab.ssh_host
+Settings.gitlab_shell["ssh_port"] ||= 22
+Settings.gitlab_shell["ssh_user"] ||= Settings.gitlab.user
+Settings.gitlab_shell["owner_group"] ||= Settings.gitlab.user
+Settings.gitlab_shell["ssh_path_prefix"] ||= Settings.__send__(:build_gitlab_shell_ssh_path_prefix)
+Settings.gitlab_shell["git_timeout"] ||= 10800
#
# Workhorse
#
-Settings['workhorse'] ||= Settingslogic.new({})
-Settings.workhorse['secret_file'] ||= Rails.root.join('.gitlab_workhorse_secret')
+Settings["workhorse"] ||= Settingslogic.new({})
+Settings.workhorse["secret_file"] ||= Rails.root.join(".gitlab_workhorse_secret")
#
# Repositories
#
-Settings['repositories'] ||= Settingslogic.new({})
-Settings.repositories['storages'] ||= {}
-unless Settings.repositories.storages['default']
- Settings.repositories.storages['default'] ||= {}
+Settings["repositories"] ||= Settingslogic.new({})
+Settings.repositories["storages"] ||= {}
+unless Settings.repositories.storages["default"]
+ Settings.repositories.storages["default"] ||= {}
# We set the path only if the default storage doesn't exist, in case it exists
# but follows the pre-9.0 configuration structure. `6_validations.rb` initializer
# will validate all storages and throw a relevant error to the user if necessary.
- Settings.repositories.storages['default']['path'] ||= Settings.gitlab['user_home'] + '/repositories/'
+ Settings.repositories.storages["default"]["path"] ||= Settings.gitlab["user_home"] + "/repositories/"
end
Settings.repositories.storages.each do |key, storage|
@@ -379,89 +379,89 @@ end
# repository_downloads_path value.
#
repositories_storages = Settings.repositories.storages.values
-repository_downloads_path = Settings.gitlab['repository_downloads_path'].to_s.gsub(%r{/$}, '')
-repository_downloads_full_path = File.expand_path(repository_downloads_path, Settings.gitlab['user_home'])
+repository_downloads_path = Settings.gitlab["repository_downloads_path"].to_s.gsub(%r{/$}, "")
+repository_downloads_full_path = File.expand_path(repository_downloads_path, Settings.gitlab["user_home"])
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1255
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- if repository_downloads_path.blank? || repositories_storages.any? { |rs| [repository_downloads_path, repository_downloads_full_path].include?(rs.legacy_disk_path.gsub(%r{/$}, '')) }
- Settings.gitlab['repository_downloads_path'] = File.join(Settings.shared['path'], 'cache/archive')
+ if repository_downloads_path.blank? || repositories_storages.any? { |rs| [repository_downloads_path, repository_downloads_full_path].include?(rs.legacy_disk_path.gsub(%r{/$}, "")) }
+ Settings.gitlab["repository_downloads_path"] = File.join(Settings.shared["path"], "cache/archive")
end
end
#
# Backup
#
-Settings['backup'] ||= Settingslogic.new({})
-Settings.backup['keep_time'] ||= 0
-Settings.backup['pg_schema'] = nil
-Settings.backup['path'] = Settings.absolute(Settings.backup['path'] || "tmp/backups/")
-Settings.backup['archive_permissions'] ||= 0600
-Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil })
-Settings.backup['upload']['multipart_chunk_size'] ||= 104857600
-Settings.backup['upload']['encryption'] ||= nil
-Settings.backup['upload']['encryption_key'] ||= ENV['GITLAB_BACKUP_ENCRYPTION_KEY']
-Settings.backup['upload']['storage_class'] ||= nil
+Settings["backup"] ||= Settingslogic.new({})
+Settings.backup["keep_time"] ||= 0
+Settings.backup["pg_schema"] = nil
+Settings.backup["path"] = Settings.absolute(Settings.backup["path"] || "tmp/backups/")
+Settings.backup["archive_permissions"] ||= 0o600
+Settings.backup["upload"] ||= Settingslogic.new({"remote_directory" => nil, "connection" => nil})
+Settings.backup["upload"]["multipart_chunk_size"] ||= 104857600
+Settings.backup["upload"]["encryption"] ||= nil
+Settings.backup["upload"]["encryption_key"] ||= ENV["GITLAB_BACKUP_ENCRYPTION_KEY"]
+Settings.backup["upload"]["storage_class"] ||= nil
#
# Git
#
-Settings['git'] ||= Settingslogic.new({})
-Settings.git['bin_path'] ||= '/usr/bin/git'
+Settings["git"] ||= Settingslogic.new({})
+Settings.git["bin_path"] ||= "/usr/bin/git"
# Important: keep the satellites.path setting until GitLab 9.0 at
# least. This setting is fed to 'rm -rf' in
# db/migrate/20151023144219_remove_satellites.rb
-Settings['satellites'] ||= Settingslogic.new({})
-Settings.satellites['path'] = Settings.absolute(Settings.satellites['path'] || "tmp/repo_satellites/")
+Settings["satellites"] ||= Settingslogic.new({})
+Settings.satellites["path"] = Settings.absolute(Settings.satellites["path"] || "tmp/repo_satellites/")
#
# Extra customization
#
-Settings['extra'] ||= Settingslogic.new({})
+Settings["extra"] ||= Settingslogic.new({})
#
# Rack::Attack settings
#
-Settings['rack_attack'] ||= Settingslogic.new({})
-Settings.rack_attack['git_basic_auth'] ||= Settingslogic.new({})
-Settings.rack_attack.git_basic_auth['enabled'] = false if Settings.rack_attack.git_basic_auth['enabled'].nil?
-Settings.rack_attack.git_basic_auth['ip_whitelist'] ||= %w{127.0.0.1}
-Settings.rack_attack.git_basic_auth['maxretry'] ||= 10
-Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute
-Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
+Settings["rack_attack"] ||= Settingslogic.new({})
+Settings.rack_attack["git_basic_auth"] ||= Settingslogic.new({})
+Settings.rack_attack.git_basic_auth["enabled"] = false if Settings.rack_attack.git_basic_auth["enabled"].nil?
+Settings.rack_attack.git_basic_auth["ip_whitelist"] ||= %w[127.0.0.1]
+Settings.rack_attack.git_basic_auth["maxretry"] ||= 10
+Settings.rack_attack.git_basic_auth["findtime"] ||= 1.minute
+Settings.rack_attack.git_basic_auth["bantime"] ||= 1.hour
#
# Gitaly
#
-Settings['gitaly'] ||= Settingslogic.new({})
+Settings["gitaly"] ||= Settingslogic.new({})
#
# Webpack settings
#
-Settings['webpack'] ||= Settingslogic.new({})
-Settings.webpack['dev_server'] ||= Settingslogic.new({})
-Settings.webpack.dev_server['enabled'] ||= false
-Settings.webpack.dev_server['host'] ||= 'localhost'
-Settings.webpack.dev_server['port'] ||= 3808
+Settings["webpack"] ||= Settingslogic.new({})
+Settings.webpack["dev_server"] ||= Settingslogic.new({})
+Settings.webpack.dev_server["enabled"] ||= false
+Settings.webpack.dev_server["host"] ||= "localhost"
+Settings.webpack.dev_server["port"] ||= 3808
#
# Monitoring settings
#
-Settings['monitoring'] ||= Settingslogic.new({})
-Settings.monitoring['ip_whitelist'] ||= ['127.0.0.1/8']
-Settings.monitoring['unicorn_sampler_interval'] ||= 10
-Settings.monitoring['ruby_sampler_interval'] ||= 60
-Settings.monitoring['sidekiq_exporter'] ||= Settingslogic.new({})
-Settings.monitoring.sidekiq_exporter['enabled'] ||= false
-Settings.monitoring.sidekiq_exporter['address'] ||= 'localhost'
-Settings.monitoring.sidekiq_exporter['port'] ||= 3807
+Settings["monitoring"] ||= Settingslogic.new({})
+Settings.monitoring["ip_whitelist"] ||= ["127.0.0.1/8"]
+Settings.monitoring["unicorn_sampler_interval"] ||= 10
+Settings.monitoring["ruby_sampler_interval"] ||= 60
+Settings.monitoring["sidekiq_exporter"] ||= Settingslogic.new({})
+Settings.monitoring.sidekiq_exporter["enabled"] ||= false
+Settings.monitoring.sidekiq_exporter["address"] ||= "localhost"
+Settings.monitoring.sidekiq_exporter["port"] ||= 3807
#
# Testing settings
#
if Rails.env.test?
- Settings.gitlab['default_projects_limit'] = 42
- Settings.gitlab['default_can_create_group'] = true
- Settings.gitlab['default_can_create_team'] = false
+ Settings.gitlab["default_projects_limit"] = 42
+ Settings.gitlab["default_can_create_group"] = true
+ Settings.gitlab["default_can_create_team"] = false
end
diff --git a/config/initializers/2_gitlab.rb b/config/initializers/2_gitlab.rb
index 8b7f245b7b0..b224047f982 100644
--- a/config/initializers/2_gitlab.rb
+++ b/config/initializers/2_gitlab.rb
@@ -1 +1 @@
-require_dependency 'gitlab'
+require_dependency "gitlab"
diff --git a/config/initializers/6_validations.rb b/config/initializers/6_validations.rb
index bf9e5a50382..f1950011bbe 100644
--- a/config/initializers/6_validations.rb
+++ b/config/initializers/6_validations.rb
@@ -7,12 +7,12 @@ def storage_validation_error(message)
end
def validate_storages_config
- storage_validation_error('No repository storage path defined') if Gitlab.config.repositories.storages.empty?
+ storage_validation_error("No repository storage path defined") if Gitlab.config.repositories.storages.empty?
Gitlab.config.repositories.storages.each do |name, repository_storage|
storage_validation_error("\"#{name}\" is not a valid storage name") unless storage_name_valid?(name)
- %w(failure_count_threshold failure_reset_time storage_timeout).each do |setting|
+ %w[failure_count_threshold failure_reset_time storage_timeout].each do |setting|
# Falling back to the defaults is fine!
next if repository_storage[setting].nil?
diff --git a/config/initializers/7_prometheus_metrics.rb b/config/initializers/7_prometheus_metrics.rb
index 8052880cc3d..eea69399da2 100644
--- a/config/initializers/7_prometheus_metrics.rb
+++ b/config/initializers/7_prometheus_metrics.rb
@@ -1,14 +1,14 @@
-require 'prometheus/client'
-require 'prometheus/client/support/unicorn'
+require "prometheus/client"
+require "prometheus/client/support/unicorn"
Prometheus::Client.configure do |config|
config.logger = Rails.logger
config.initial_mmap_file_size = 4 * 1024
- config.multiprocess_files_dir = ENV['prometheus_multiproc_dir']
+ config.multiprocess_files_dir = ENV["prometheus_multiproc_dir"]
if Rails.env.development? || Rails.env.test?
- config.multiprocess_files_dir ||= Rails.root.join('tmp/prometheus_multiproc_dir')
+ config.multiprocess_files_dir ||= Rails.root.join("tmp/prometheus_multiproc_dir")
end
config.pid_provider = Prometheus::Client::Support::Unicorn.method(:worker_pid_provider)
@@ -42,9 +42,9 @@ Gitlab::Cluster::LifecycleEvents.on_master_restart do
# accumulate over time. It needs to be done in this hook as opposed to
# inside an init script to ensure metrics files aren't deleted after new
# unicorn workers start after a SIGUSR2 is received.
- prometheus_multiproc_dir = ENV['prometheus_multiproc_dir']
+ prometheus_multiproc_dir = ENV["prometheus_multiproc_dir"]
if prometheus_multiproc_dir
- old_metrics = Dir[File.join(prometheus_multiproc_dir, '*.db')]
+ old_metrics = Dir[File.join(prometheus_multiproc_dir, "*.db")]
FileUtils.rm_rf(old_metrics)
end
end
diff --git a/config/initializers/8_devise.rb b/config/initializers/8_devise.rb
index 4683b02f300..5f4abe149a1 100644
--- a/config/initializers/8_devise.rb
+++ b/config/initializers/8_devise.rb
@@ -14,7 +14,7 @@ Devise.setup do |config|
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
- require 'devise/orm/active_record'
+ require "devise/orm/active_record"
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating a user. The default is
diff --git a/config/initializers/8_gitaly.rb b/config/initializers/8_gitaly.rb
index f4f116e67f7..cfe7b4cc1dd 100644
--- a/config/initializers/8_gitaly.rb
+++ b/config/initializers/8_gitaly.rb
@@ -1,4 +1,4 @@
-require 'uri'
+require "uri"
Gitlab.config.repositories.storages.keys.each do |storage|
# Force validation of each address
diff --git a/config/initializers/9_fast_gettext.rb b/config/initializers/9_fast_gettext.rb
index fd0167aa476..a80048c35a7 100644
--- a/config/initializers/9_fast_gettext.rb
+++ b/config/initializers/9_fast_gettext.rb
@@ -1,8 +1,8 @@
-FastGettext.add_text_domain 'gitlab',
- path: File.join(Rails.root, 'locale'),
- type: :po,
- ignore_fuzzy: true
-FastGettext.default_text_domain = 'gitlab'
+FastGettext.add_text_domain "gitlab",
+ path: File.join(Rails.root, "locale"),
+ type: :po,
+ ignore_fuzzy: true
+FastGettext.default_text_domain = "gitlab"
FastGettext.default_available_locales = Gitlab::I18n.available_locales
FastGettext.default_locale = :en
diff --git a/config/initializers/active_record_data_types.rb b/config/initializers/active_record_data_types.rb
index e95157bfde5..0f763924bc0 100644
--- a/config/initializers/active_record_data_types.rb
+++ b/config/initializers/active_record_data_types.rb
@@ -2,7 +2,7 @@
# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11229
if Gitlab::Database.postgresql?
- require 'active_record/connection_adapters/postgresql_adapter'
+ require "active_record/connection_adapters/postgresql_adapter"
module ActiveRecord::ConnectionAdapters::PostgreSQL::OID
# Add the class `DateTimeWithTimeZone` so we can map `timestamptz` to it.
@@ -25,7 +25,7 @@ if Gitlab::Database.postgresql?
def initialize_type_map(mapping)
super mapping
- mapping.register_type 'timestamptz' do |_, _, sql_type|
+ mapping.register_type "timestamptz" do |_, _, sql_type|
precision = extract_precision(sql_type)
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::OID::DateTimeWithTimeZone.new(precision: precision)
end
@@ -40,10 +40,10 @@ if Gitlab::Database.postgresql?
#
# add_column(:users, :datetime_with_timezone)
#
- NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamptz' }
+ NATIVE_DATABASE_TYPES[:datetime_with_timezone] = {name: "timestamptz"}
end
elsif Gitlab::Database.mysql?
- require 'active_record/connection_adapters/mysql2_adapter'
+ require "active_record/connection_adapters/mysql2_adapter"
module RegisterDateTimeWithTimeZone
# Run original `initialize_type_map` and then register `timestamp` as a
@@ -76,11 +76,15 @@ elsif Gitlab::Database.mysql?
#
# add_column(:users, :datetime_with_timezone)
#
- NATIVE_DATABASE_TYPES[:datetime_with_timezone] = { name: 'timestamp' }
+ NATIVE_DATABASE_TYPES[:datetime_with_timezone] = {name: "timestamp"}
end
end
# Ensure `datetime_with_timezone` columns are correctly written to schema.rb
-if (ActiveRecord::Base.connection.active? rescue false)
+if begin
+ ActiveRecord::Base.connection.active?
+ rescue
+ false
+ end
ActiveRecord::Base.connection.send :reload_type_map
end
diff --git a/config/initializers/active_record_locking.rb b/config/initializers/active_record_locking.rb
index 1bd1a12e4b7..fcc8d8a0537 100644
--- a/config/initializers/active_record_locking.rb
+++ b/config/initializers/active_record_locking.rb
@@ -33,9 +33,9 @@ module ActiveRecord
# Patched because when `lock_version` is read as `0`, it may actually be `NULL` in the DB.
lock_col => previous_lock_value == 0 ? [nil, 0] : previous_lock_value
).update_all(
- attributes_for_update(attribute_names).map do |name|
+ attributes_for_update(attribute_names).map { |name|
[name, _read_attribute(name)]
- end.to_h
+ }.to_h
)
unless affected_rows == 1
@@ -46,7 +46,7 @@ module ActiveRecord
# If something went wrong, revert the version.
rescue Exception
- send(lock_col + '=', previous_lock_value)
+ send(lock_col + "=", previous_lock_value)
raise
end
end
diff --git a/config/initializers/active_record_migration.rb b/config/initializers/active_record_migration.rb
index 04c06be7834..1cdd31a9c75 100644
--- a/config/initializers/active_record_migration.rb
+++ b/config/initializers/active_record_migration.rb
@@ -1,4 +1,4 @@
-require 'active_record/migration'
+require "active_record/migration"
module ActiveRecord
class Migration
diff --git a/config/initializers/active_record_mysql_timestamp.rb b/config/initializers/active_record_mysql_timestamp.rb
index af74c4ff6fb..01fa389a115 100644
--- a/config/initializers/active_record_mysql_timestamp.rb
+++ b/config/initializers/active_record_mysql_timestamp.rb
@@ -5,7 +5,7 @@
# https://github.com/rails/rails/blob/15ef55efb591e5379486ccf53dd3e13f416564f6/activerecord/lib/active_record/connection_adapters/mysql/schema_creation.rb#L34-L36
if Gitlab::Database.mysql?
- require 'active_record/connection_adapters/abstract/schema_creation'
+ require "active_record/connection_adapters/abstract/schema_creation"
module MySQLTimestampFix
def add_column_options!(sql, options)
@@ -13,11 +13,11 @@ if Gitlab::Database.mysql?
# and assigning NULL assigns the current timestamp. To permit a TIMESTAMP
# column to contain NULL, explicitly declare it with the NULL attribute.
# See http://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
- if sql.end_with?('timestamp') && !options[:primary_key]
+ if sql.end_with?("timestamp") && !options[:primary_key]
if options[:null] != false
- sql << ' NULL'
+ sql << " NULL"
elsif options[:column].default.nil?
- sql << ' DEFAULT 0'
+ sql << " DEFAULT 0"
end
end
diff --git a/config/initializers/active_record_table_definition.rb b/config/initializers/active_record_table_definition.rb
index a71069f27a3..666dedad087 100644
--- a/config/initializers/active_record_table_definition.rb
+++ b/config/initializers/active_record_table_definition.rb
@@ -1,7 +1,7 @@
# ActiveRecord custom method definitions with timezone information.
# See https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/11229
-require 'active_record/connection_adapters/abstract/schema_definitions'
+require "active_record/connection_adapters/abstract/schema_definitions"
module ActiveRecord
module ConnectionAdapters
diff --git a/config/initializers/active_record_verbose_query_logs.rb b/config/initializers/active_record_verbose_query_logs.rb
index 1c5fbc8e830..18eb753d2fe 100644
--- a/config/initializers/active_record_verbose_query_logs.rb
+++ b/config/initializers/active_record_verbose_query_logs.rb
@@ -17,7 +17,7 @@ module ActiveRecord
if source_line
if defined?(::Rails.root)
- app_root = "#{::Rails.root}/".freeze
+ app_root = "#{::Rails.root}/"
source_line = source_line.sub(app_root, "")
end
@@ -26,15 +26,15 @@ module ActiveRecord
end
def extract_callstack(callstack)
- line = callstack.find do |frame|
+ line = callstack.find { |frame|
frame.absolute_path && !ignored_callstack(frame.absolute_path)
- end
+ }
offending_line = line || callstack.first
[
offending_line.path,
offending_line.lineno,
- offending_line.label
+ offending_line.label,
]
end
diff --git a/config/initializers/ar_mysql_jsonb_support.rb b/config/initializers/ar_mysql_jsonb_support.rb
index 63a0b05119a..4fdd18b303e 100644
--- a/config/initializers/ar_mysql_jsonb_support.rb
+++ b/config/initializers/ar_mysql_jsonb_support.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'active_record/connection_adapters/abstract_mysql_adapter'
-require 'active_record/connection_adapters/mysql/schema_definitions'
+require "active_record/connection_adapters/abstract_mysql_adapter"
+require "active_record/connection_adapters/mysql/schema_definitions"
# MySQL (5.6) and MariaDB (10.1) are currently supported versions within GitLab,
# Since they do not support native `json` datatype we force to emulate it as `text`
@@ -13,8 +13,8 @@ if Gitlab::Database.mysql?
JSON_DATASIZE = 1.megabyte
NATIVE_DATABASE_TYPES.merge!(
- json: { name: "text", limit: JSON_DATASIZE },
- jsonb: { name: "text", limit: JSON_DATASIZE }
+ json: {name: "text", limit: JSON_DATASIZE},
+ jsonb: {name: "text", limit: JSON_DATASIZE}
)
end
diff --git a/config/initializers/ar_native_database_types.rb b/config/initializers/ar_native_database_types.rb
index 3522b1db536..06f6c87762a 100644
--- a/config/initializers/ar_native_database_types.rb
+++ b/config/initializers/ar_native_database_types.rb
@@ -1,10 +1,10 @@
-require 'active_record/connection_adapters/abstract_mysql_adapter'
+require "active_record/connection_adapters/abstract_mysql_adapter"
module ActiveRecord
module ConnectionAdapters
class AbstractMysqlAdapter
NATIVE_DATABASE_TYPES.merge!(
- bigserial: { name: 'bigint(20) auto_increment PRIMARY KEY' }
+ bigserial: {name: "bigint(20) auto_increment PRIMARY KEY"}
)
end
end
diff --git a/config/initializers/ar_speed_up_migration_checking.rb b/config/initializers/ar_speed_up_migration_checking.rb
index aae774daa35..fa55268873b 100644
--- a/config/initializers/ar_speed_up_migration_checking.rb
+++ b/config/initializers/ar_speed_up_migration_checking.rb
@@ -1,10 +1,10 @@
if Rails.env.test?
- require 'active_record/migration'
+ require "active_record/migration"
module ActiveRecord
class Migrator
class << self
- alias_method :migrations_unmemoized, :migrations
+ alias migrations_unmemoized migrations
# This method is called a large number of times per rspec example, and
# it reads + parses `db/migrate/*` each time. Memoizing it can save 0.5
diff --git a/config/initializers/attr_encrypted_no_db_connection.rb b/config/initializers/attr_encrypted_no_db_connection.rb
index 7ad458929db..482ed04415c 100644
--- a/config/initializers/attr_encrypted_no_db_connection.rb
+++ b/config/initializers/attr_encrypted_no_db_connection.rb
@@ -15,7 +15,11 @@ module AttrEncrypted
# ensuring the connection is released
def attribute_instance_methods_as_symbols
# Use with_connection so the connection doesn't stay pinned to the thread.
- connected = ::ActiveRecord::Base.connection_pool.with_connection(&:active?) rescue false
+ connected = begin
+ ::ActiveRecord::Base.connection_pool.with_connection(&:active?)
+ rescue
+ false
+ end
if connected
# Call version from AttrEncrypted::Adapters::ActiveRecord
diff --git a/config/initializers/bullet.rb b/config/initializers/bullet.rb
index 0ade7109420..caa73976eab 100644
--- a/config/initializers/bullet.rb
+++ b/config/initializers/bullet.rb
@@ -1,4 +1,4 @@
-if defined?(Bullet) && ENV['ENABLE_BULLET']
+if defined?(Bullet) && ENV["ENABLE_BULLET"]
Rails.application.configure do
config.after_initialize do
Bullet.enable = true
diff --git a/config/initializers/connection_fix.rb b/config/initializers/connection_fix.rb
index d0b1444f607..2e17ed8d0a8 100644
--- a/config/initializers/connection_fix.rb
+++ b/config/initializers/connection_fix.rb
@@ -14,12 +14,12 @@
if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
module ActiveRecord::ConnectionAdapters
class Mysql2Adapter
- alias_method :execute_without_retry, :execute
+ alias execute_without_retry execute
def execute(*args)
execute_without_retry(*args)
rescue ActiveRecord::StatementInvalid => e
- if e.message =~ /server has gone away/i
+ if /server has gone away/i.match?(e.message)
warn "Lost connection to MySQL server during query"
reconnect!
retry
diff --git a/config/initializers/console_message.rb b/config/initializers/console_message.rb
index f7c26732e6d..8eb250df923 100644
--- a/config/initializers/console_message.rb
+++ b/config/initializers/console_message.rb
@@ -4,7 +4,7 @@ if defined?(Rails::Console)
justify = 15
puts "-------------------------------------------------------------------------------------"
puts " GitLab:".ljust(justify) + "#{Gitlab::VERSION} (#{Gitlab.revision})"
- puts " GitLab Shell:".ljust(justify) + "#{Gitlab::VersionInfo.parse(Gitlab::Shell.new.version)}"
+ puts " GitLab Shell:".ljust(justify) + Gitlab::VersionInfo.parse(Gitlab::Shell.new.version).to_s
puts " #{Gitlab::Database.adapter_name}:".ljust(justify) + Gitlab::Database.version
puts "-------------------------------------------------------------------------------------"
end
diff --git a/config/initializers/date_time_formats.rb b/config/initializers/date_time_formats.rb
index 1939ced512d..db5fc2cd675 100644
--- a/config/initializers/date_time_formats.rb
+++ b/config/initializers/date_time_formats.rb
@@ -1,11 +1,11 @@
# :short - 10 Nov
# :medium - Nov 10, 2007
# :long - November 10, 2007
-Date::DATE_FORMATS[:medium] = '%b %-d, %Y'
-Date::DATE_FORMATS[:csv] = '%Y-%m-%d'
+Date::DATE_FORMATS[:medium] = "%b %-d, %Y"
+Date::DATE_FORMATS[:csv] = "%Y-%m-%d"
# :short - 18 Jan 06:10
# :medium - Jan 18, 2007 6:10am
# :long - January 18, 2007 06:10
-Time::DATE_FORMATS[:medium] = '%b %-d, %Y %-I:%M%P'
-Time::DATE_FORMATS[:csv] = '%Y-%m-%d %H:%M:%S'
+Time::DATE_FORMATS[:medium] = "%b %-d, %Y %-I:%M%P"
+Time::DATE_FORMATS[:csv] = "%Y-%m-%d %H:%M:%S"
diff --git a/config/initializers/default_url_options.rb b/config/initializers/default_url_options.rb
index de2cdc6ecae..04d7781c77f 100644
--- a/config/initializers/default_url_options.rb
+++ b/config/initializers/default_url_options.rb
@@ -1,7 +1,7 @@
default_url_options = {
- host: Gitlab.config.gitlab.host,
- protocol: Gitlab.config.gitlab.protocol,
- script_name: Gitlab.config.gitlab.relative_url_root
+ host: Gitlab.config.gitlab.host,
+ protocol: Gitlab.config.gitlab.protocol,
+ script_name: Gitlab.config.gitlab.relative_url_root,
}
unless Gitlab.config.gitlab_on_standard_port?
@@ -9,4 +9,4 @@ unless Gitlab.config.gitlab_on_standard_port?
end
Rails.application.routes.default_url_options = default_url_options
-ActionMailer::Base.asset_host = Settings.gitlab['base_url']
+ActionMailer::Base.asset_host = Settings.gitlab["base_url"]
diff --git a/config/initializers/deprecations.rb b/config/initializers/deprecations.rb
index 14616e726d9..937f7d57eca 100644
--- a/config/initializers/deprecations.rb
+++ b/config/initializers/deprecations.rb
@@ -1,7 +1,7 @@
-if Rails.env.development? || ENV['GITLAB_LEGACY_PATH_LOG_MESSAGE']
- deprecator = ActiveSupport::Deprecation.new('11.0', 'GitLab')
+if Rails.env.development? || ENV["GITLAB_LEGACY_PATH_LOG_MESSAGE"]
+ deprecator = ActiveSupport::Deprecation.new("11.0", "GitLab")
- deprecator.behavior = -> (message, callstack) {
+ deprecator.behavior = ->(message, callstack) {
Rails.logger.warn("#{message}: #{callstack[1..20].join}")
}
diff --git a/config/initializers/direct_upload_support.rb b/config/initializers/direct_upload_support.rb
index 32fc8c8bc69..ae9b1bdacb9 100644
--- a/config/initializers/direct_upload_support.rb
+++ b/config/initializers/direct_upload_support.rb
@@ -1,5 +1,5 @@
class DirectUploadsValidator
- SUPPORTED_DIRECT_UPLOAD_PROVIDERS = %w(Google AWS).freeze
+ SUPPORTED_DIRECT_UPLOAD_PROVIDERS = %w[Google AWS].freeze
ValidationError = Class.new(StandardError)
@@ -8,7 +8,7 @@ class DirectUploadsValidator
return unless object_store.direct_upload
return if SUPPORTED_DIRECT_UPLOAD_PROVIDERS.include?(object_store.connection&.provider.to_s)
- raise ValidationError, "Only #{SUPPORTED_DIRECT_UPLOAD_PROVIDERS.join(',')} are supported as a object storage provider when 'direct_upload' is used"
+ raise ValidationError, "Only #{SUPPORTED_DIRECT_UPLOAD_PROVIDERS.join(",")} are supported as a object storage provider when 'direct_upload' is used"
end
end
diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb
index 6be5c00daaa..fcb23881f07 100644
--- a/config/initializers/doorkeeper.rb
+++ b/config/initializers/doorkeeper.rb
@@ -94,7 +94,7 @@ Doorkeeper.configure do
# "password" => Resource Owner Password Credentials Grant Flow
# "client_credentials" => Client Credentials Grant Flow
#
- grant_flows %w(authorization_code implicit password client_credentials)
+ grant_flows %w[authorization_code implicit password client_credentials]
# Under some circumstances you might want to have applications auto-approved,
# so that the user skips the authorization step.
@@ -111,7 +111,7 @@ Doorkeeper.configure do
# set to true if you want this to be allowed
# wildcard_redirect_uri false
- base_controller '::Gitlab::BaseDoorkeeperController'
+ base_controller "::Gitlab::BaseDoorkeeperController"
end
# Monkey patch to avoid creating new applications if the scope of the
@@ -119,7 +119,7 @@ end
# It also prevents the OAuth authorize application window to appear every time.
# Remove after we upgrade the doorkeeper gem from version 4.3.2
-if Doorkeeper.gem_version > Gem::Version.new('4.3.2')
+if Doorkeeper.gem_version > Gem::Version.new("4.3.2")
raise "Doorkeeper was upgraded, please remove the monkey patch in #{__FILE__}"
end
@@ -147,7 +147,8 @@ module Doorkeeper
Doorkeeper::OAuth::Helpers::ScopeChecker.valid?(
param_scopes.to_s,
Doorkeeper.configuration.scopes,
- app_scopes)
+ app_scopes
+ )
end
def authorized_tokens_for(application_id, resource_owner_id)
diff --git a/config/initializers/doorkeeper_openid_connect.rb b/config/initializers/doorkeeper_openid_connect.rb
index fd5a62c39c6..d9e780680af 100644
--- a/config/initializers/doorkeeper_openid_connect.rb
+++ b/config/initializers/doorkeeper_openid_connect.rb
@@ -45,10 +45,6 @@ Doorkeeper::OpenidConnect.configure do
user.primary_email_verified?
elsif user.public_email?
user.verified_email?(user.public_email)
- else
- # If there is no public email set, tell doorkicker-openid-connect to
- # exclude the email_verified claim by returning nil.
- nil
end
end
diff --git a/config/initializers/fix_local_cache_middleware.rb b/config/initializers/fix_local_cache_middleware.rb
index 2644ee6a7d3..08f7d59c26d 100644
--- a/config/initializers/fix_local_cache_middleware.rb
+++ b/config/initializers/fix_local_cache_middleware.rb
@@ -7,9 +7,9 @@ module LocalCacheRegistryCleanupWithEnsure
def call(env)
LocalCacheRegistry.set_cache_for(local_cache_key, LocalStore.new)
response = @app.call(env) # rubocop:disable Gitlab/ModuleWithInstanceVariables
- response[2] = ::Rack::BodyProxy.new(response[2]) do
+ response[2] = ::Rack::BodyProxy.new(response[2]) {
LocalCacheRegistry.set_cache_for(local_cache_key, nil)
- end
+ }
cleanup_after_response = true # ADDED THIS LINE
response
rescue Rack::Utils::InvalidParameterError
diff --git a/config/initializers/forbid_sidekiq_in_transactions.rb b/config/initializers/forbid_sidekiq_in_transactions.rb
index deb94d7dbce..1ea36a072f7 100644
--- a/config/initializers/forbid_sidekiq_in_transactions.rb
+++ b/config/initializers/forbid_sidekiq_in_transactions.rb
@@ -15,16 +15,15 @@ module Sidekiq
module ClassMethods
module NoEnqueueingFromTransactions
- %i(perform_async perform_at perform_in).each do |name|
+ %i[perform_async perform_at perform_in].each do |name|
define_method(name) do |*args|
if !Sidekiq::Worker.skip_transaction_check && AfterCommitQueue.inside_transaction?
begin
raise Sidekiq::Worker::EnqueueFromTransactionError, <<~MSG
- `#{self}.#{name}` cannot be called inside a transaction as this can lead to
- race conditions when the worker runs before the transaction is committed and
- tries to access a model that has not been saved yet.
-
- Use an `after_commit` hook, or include `AfterCommitQueue` and use a `run_after_commit` block instead.
+ `#{self}.#{name}` cannot be called inside a transaction as this can lead to
+ race conditions when the worker runs before the transaction is committed and
+ tries to access a model that has not been saved yet.
+ Use an `after_commit` hook, or include `AfterCommitQueue` and use a `run_after_commit` block instead.
MSG
rescue Sidekiq::Worker::EnqueueFromTransactionError => e
::Rails.logger.error(e.message) if ::Rails.env.production?
diff --git a/config/initializers/gettext_rails_i18n_patch.rb b/config/initializers/gettext_rails_i18n_patch.rb
index c1342f48ebd..e6e75d627d5 100644
--- a/config/initializers/gettext_rails_i18n_patch.rb
+++ b/config/initializers/gettext_rails_i18n_patch.rb
@@ -1,6 +1,6 @@
-require 'gettext_i18n_rails/haml_parser'
-require 'gettext_i18n_rails_js/parser/javascript'
-require 'json'
+require "gettext_i18n_rails/haml_parser"
+require "gettext_i18n_rails_js/parser/javascript"
+require "json"
VUE_TRANSLATE_REGEX = /((%[\w.-]+)(?:\s))?{{ (N|n|s)?__\((.*)\) }}/
@@ -34,7 +34,7 @@ module GettextI18nRailsJs
[
".js",
".jsx",
- ".vue"
+ ".vue",
].include? ::File.extname(file)
end
@@ -64,7 +64,7 @@ class PoToJson
generated = build_json_for(build_jed_for(@parsed))
[
- "window.translations = #{generated};"
+ "window.translations = #{generated};",
].join(" ")
end
end
diff --git a/config/initializers/grpc.rb b/config/initializers/grpc.rb
index b96962fe7db..012bb33780f 100644
--- a/config/initializers/grpc.rb
+++ b/config/initializers/grpc.rb
@@ -1,8 +1,8 @@
-require 'logger'
+require "logger"
-GRPC_LOGGER = Logger.new(Rails.root.join('log/grpc.log'))
-GRPC_LOGGER.level = ENV['GRPC_LOG_LEVEL'].presence || 'WARN'
-GRPC_LOGGER.progname = 'GRPC'
+GRPC_LOGGER = Logger.new(Rails.root.join("log/grpc.log"))
+GRPC_LOGGER.level = ENV["GRPC_LOG_LEVEL"].presence || "WARN"
+GRPC_LOGGER.progname = "GRPC"
module GRPC
def self.logger
diff --git a/config/initializers/hamlit.rb b/config/initializers/hamlit.rb
index 51dbffeda05..d909050bff0 100644
--- a/config/initializers/hamlit.rb
+++ b/config/initializers/hamlit.rb
@@ -14,5 +14,5 @@ ActionView::Template.register_template_handler(
Hamlit::TemplateHandler.new
)
-Hamlit::Filters.remove_filter('coffee')
-Hamlit::Filters.remove_filter('coffeescript')
+Hamlit::Filters.remove_filter("coffee")
+Hamlit::Filters.remove_filter("coffeescript")
diff --git a/config/initializers/health_check.rb b/config/initializers/health_check.rb
index 959daa93f78..209bd186b8b 100644
--- a/config/initializers/health_check.rb
+++ b/config/initializers/health_check.rb
@@ -1,4 +1,4 @@
HealthCheck.setup do |config|
- config.standard_checks = %w(database migrations cache)
- config.full_checks = %w(database migrations cache)
+ config.standard_checks = %w[database migrations cache]
+ config.full_checks = %w[database migrations cache]
end
diff --git a/config/initializers/lograge.rb b/config/initializers/lograge.rb
index 164954d1293..79b3d219abf 100644
--- a/config/initializers/lograge.rb
+++ b/config/initializers/lograge.rb
@@ -1,6 +1,6 @@
# Only use Lograge for Rails
unless Sidekiq.server?
- filename = File.join(Rails.root, 'log', "#{Rails.env}_json.log")
+ filename = File.join(Rails.root, "log", "#{Rails.env}_json.log")
Rails.application.configure do
config.lograge.enabled = true
@@ -13,9 +13,9 @@ unless Sidekiq.server?
# Add request parameters to log output
config.lograge.custom_options = lambda do |event|
params = event.payload[:params]
- .except(*%w(controller action format))
+ .except("controller", "action", "format")
.each_pair
- .map { |k, v| { key: k, value: v } }
+ .map { |k, v| {key: k, value: v} }
payload = {
time: event.time.utc.iso8601(3),
@@ -24,7 +24,7 @@ unless Sidekiq.server?
user_id: event.payload[:user_id],
username: event.payload[:username],
ua: event.payload[:ua],
- queue_duration: event.payload[:queue_duration]
+ queue_duration: event.payload[:queue_duration],
}
gitaly_calls = Gitlab::GitalyClient.get_request_count
diff --git a/config/initializers/macos.rb b/config/initializers/macos.rb
index f410af6ed47..eb0521ac7a8 100644
--- a/config/initializers/macos.rb
+++ b/config/initializers/macos.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-if /darwin/ =~ RUBY_PLATFORM
+if /darwin/.match?(RUBY_PLATFORM)
Gitlab::Cluster::LifecycleEvents.on_before_fork do
- require 'fiddle'
+ require "fiddle"
# Dynamically load Foundation.framework, ~implicitly~ initialising
# the Objective-C runtime before any forking happens in Unicorn
#
# From https://bugs.ruby-lang.org/issues/14009
- Fiddle.dlopen '/System/Library/Frameworks/Foundation.framework/Foundation'
+ Fiddle.dlopen "/System/Library/Frameworks/Foundation.framework/Foundation"
end
end
diff --git a/config/initializers/mime_types.rb b/config/initializers/mime_types.rb
index acbdf8de5a6..75cb7e8d632 100644
--- a/config/initializers/mime_types.rb
+++ b/config/initializers/mime_types.rb
@@ -14,6 +14,6 @@ Mime::Type.register "video/webm", :webm
Mime::Type.register "video/ogg", :ogv
Mime::Type.unregister :json
-Mime::Type.register 'application/json', :json, [LfsRequest::CONTENT_TYPE, 'application/json']
+Mime::Type.register "application/json", :json, [LfsRequest::CONTENT_TYPE, "application/json"]
-Mime::Type.register 'image/x-icon', :ico
+Mime::Type.register "image/x-icon", :ico
diff --git a/config/initializers/mysql_ignore_postgresql_options.rb b/config/initializers/mysql_ignore_postgresql_options.rb
index 9a569be7674..5e222afcd1d 100644
--- a/config/initializers/mysql_ignore_postgresql_options.rb
+++ b/config/initializers/mysql_ignore_postgresql_options.rb
@@ -14,9 +14,9 @@ if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
module ActiveRecord
module ConnectionAdapters
class Mysql2Adapter < AbstractMysqlAdapter
- alias_method :__gitlab_add_index, :add_index
- alias_method :__gitlab_add_index_sql, :add_index_sql
- alias_method :__gitlab_add_index_options, :add_index_options
+ alias __gitlab_add_index add_index
+ alias __gitlab_add_index_sql add_index_sql
+ alias __gitlab_add_index_options add_index_options
def add_index(table_name, column_name, options = {})
unless options[:opclasses]
diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb
index ef23ca065c6..9b58f54aecd 100644
--- a/config/initializers/omniauth.rb
+++ b/config/initializers/omniauth.rb
@@ -2,14 +2,14 @@ if Gitlab::Auth::LDAP::Config.enabled?
module OmniAuth::Strategies
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
# do not redeclare LDAP
- next if server['provider_name'] == 'ldap'
+ next if server["provider_name"] == "ldap"
- const_set(server['provider_class'], Class.new(LDAP))
+ const_set(server["provider_class"], Class.new(LDAP))
end
end
end
-OmniAuth.config.full_host = Settings.gitlab['base_url']
+OmniAuth.config.full_host = Settings.gitlab["base_url"]
OmniAuth.config.allowed_request_methods = [:post]
# In case of auto sign-in, the GET method is used (users don't get to click on a button)
OmniAuth.config.allowed_request_methods << :get if Gitlab.config.omniauth.auto_sign_in_with_provider.present?
diff --git a/config/initializers/peek.rb b/config/initializers/peek.rb
index e051e5c68c4..04e11204c4f 100644
--- a/config/initializers/peek.rb
+++ b/config/initializers/peek.rb
@@ -1,13 +1,13 @@
-Rails.application.config.peek.adapter = :redis, { client: ::Redis.new(Gitlab::Redis::Cache.params) }
+Rails.application.config.peek.adapter = :redis, {client: ::Redis.new(Gitlab::Redis::Cache.params)}
Peek.into Peek::Views::Host
if Gitlab::Database.mysql?
- require 'peek-mysql2'
+ require "peek-mysql2"
PEEK_DB_CLIENT = ::Mysql2::Client
PEEK_DB_VIEW = Peek::Views::Mysql2
elsif Gitlab::Database.postgresql?
- require 'peek-pg'
+ require "peek-pg"
PEEK_DB_CLIENT = ::PG::Connection
PEEK_DB_VIEW = Peek::Views::PG
else
diff --git a/config/initializers/postgresql_cte.rb b/config/initializers/postgresql_cte.rb
index 56689bc8e74..9726f912179 100644
--- a/config/initializers/postgresql_cte.rb
+++ b/config/initializers/postgresql_cte.rb
@@ -103,7 +103,7 @@ module ActiveRecord
end
def build_with(arel)
- with_statements = with_values.flat_map do |with_value|
+ with_statements = with_values.flat_map { |with_value|
case with_value
when String
with_value
@@ -120,7 +120,7 @@ module ActiveRecord
when Arel::Nodes::As
with_value
end
- end
+ }
unless with_statements.empty?
if recursive_value
diff --git a/config/initializers/query_limiting.rb b/config/initializers/query_limiting.rb
index 66864d1898e..1a693607e83 100644
--- a/config/initializers/query_limiting.rb
+++ b/config/initializers/query_limiting.rb
@@ -1,7 +1,7 @@
if Gitlab::QueryLimiting.enable?
- require_dependency 'gitlab/query_limiting/active_support_subscriber'
- require_dependency 'gitlab/query_limiting/transaction'
- require_dependency 'gitlab/query_limiting/middleware'
+ require_dependency "gitlab/query_limiting/active_support_subscriber"
+ require_dependency "gitlab/query_limiting/transaction"
+ require_dependency "gitlab/query_limiting/middleware"
Gitlab::Application.configure do |config|
config.middleware.use(Gitlab::QueryLimiting::Middleware)
diff --git a/config/initializers/rack_attack_git_basic_auth.rb b/config/initializers/rack_attack_git_basic_auth.rb
index 6a721826170..a7d44a5f978 100644
--- a/config/initializers/rack_attack_git_basic_auth.rb
+++ b/config/initializers/rack_attack_git_basic_auth.rb
@@ -1,9 +1,9 @@
-rack_attack_enabled = Gitlab.config.rack_attack.git_basic_auth['enabled']
+rack_attack_enabled = Gitlab.config.rack_attack.git_basic_auth["enabled"]
unless Rails.env.test? || !rack_attack_enabled
# Tell the Rack::Attack Rack middleware to maintain an IP blacklist. We will
# update the blacklist from Grack::Auth#authenticate_user.
- Rack::Attack.blacklist('Git HTTP Basic Auth') do |req|
+ Rack::Attack.blacklist("Git HTTP Basic Auth") do |req|
Rack::Attack::Allow2Ban.filter(req.ip, Gitlab.config.rack_attack.git_basic_auth) do
# This block only gets run if the IP was not already banned.
# Return false, meaning that we do not see anything wrong with the
diff --git a/config/initializers/rack_attack_global.rb b/config/initializers/rack_attack_global.rb
index 86cb930eca9..0edc33cc1b6 100644
--- a/config/initializers/rack_attack_global.rb
+++ b/config/initializers/rack_attack_global.rb
@@ -6,37 +6,37 @@ module Gitlab::Throttle
def self.unauthenticated_options
limit_proc = proc { |req| settings.throttle_unauthenticated_requests_per_period }
period_proc = proc { |req| settings.throttle_unauthenticated_period_in_seconds.seconds }
- { limit: limit_proc, period: period_proc }
+ {limit: limit_proc, period: period_proc}
end
def self.authenticated_api_options
limit_proc = proc { |req| settings.throttle_authenticated_api_requests_per_period }
period_proc = proc { |req| settings.throttle_authenticated_api_period_in_seconds.seconds }
- { limit: limit_proc, period: period_proc }
+ {limit: limit_proc, period: period_proc}
end
def self.authenticated_web_options
limit_proc = proc { |req| settings.throttle_authenticated_web_requests_per_period }
period_proc = proc { |req| settings.throttle_authenticated_web_period_in_seconds.seconds }
- { limit: limit_proc, period: period_proc }
+ {limit: limit_proc, period: period_proc}
end
end
class Rack::Attack
- throttle('throttle_unauthenticated', Gitlab::Throttle.unauthenticated_options) do |req|
+ throttle("throttle_unauthenticated", Gitlab::Throttle.unauthenticated_options) do |req|
Gitlab::Throttle.settings.throttle_unauthenticated_enabled &&
req.unauthenticated? &&
!req.should_be_skipped? &&
req.ip
end
- throttle('throttle_authenticated_api', Gitlab::Throttle.authenticated_api_options) do |req|
+ throttle("throttle_authenticated_api", Gitlab::Throttle.authenticated_api_options) do |req|
Gitlab::Throttle.settings.throttle_authenticated_api_enabled &&
req.api_request? &&
req.authenticated_user_id([:api])
end
- throttle('throttle_authenticated_web', Gitlab::Throttle.authenticated_web_options) do |req|
+ throttle("throttle_authenticated_web", Gitlab::Throttle.authenticated_web_options) do |req|
Gitlab::Throttle.settings.throttle_authenticated_web_enabled &&
req.web_request? &&
req.authenticated_user_id([:api, :rss, :ics])
@@ -52,7 +52,7 @@ class Rack::Attack
end
def api_request?
- path.start_with?('/api')
+ path.start_with?("/api")
end
def api_internal_request?
diff --git a/config/initializers/rack_attack_logging.rb b/config/initializers/rack_attack_logging.rb
index 8bb9ea29c33..9367c8b50b8 100644
--- a/config/initializers/rack_attack_logging.rb
+++ b/config/initializers/rack_attack_logging.rb
@@ -1,7 +1,7 @@
# Adds logging for all Rack Attack blocks and throttling events.
-ActiveSupport::Notifications.subscribe('rack.attack') do |name, start, finish, request_id, req|
- if [:throttle, :blacklist].include? req.env['rack.attack.match_type']
- Rails.logger.info("Rack_Attack: #{req.env['rack.attack.match_type']} #{req.ip} #{req.request_method} #{req.fullpath}")
+ActiveSupport::Notifications.subscribe("rack.attack") do |name, start, finish, request_id, req|
+ if [:throttle, :blacklist].include? req.env["rack.attack.match_type"]
+ Rails.logger.info("Rack_Attack: #{req.env["rack.attack.match_type"]} #{req.ip} #{req.request_method} #{req.fullpath}")
end
end
diff --git a/config/initializers/rack_lineprof.rb b/config/initializers/rack_lineprof.rb
index f7172fce9bc..f2fdccd71a9 100644
--- a/config/initializers/rack_lineprof.rb
+++ b/config/initializers/rack_lineprof.rb
@@ -1,7 +1,7 @@
# The default colors of rack-lineprof can be very hard to look at in terminals
# with darker backgrounds. This patch tweaks the colors a bit so the output is
# actually readable.
-if Rails.env.development? && RUBY_ENGINE == 'ruby' && ENV['ENABLE_LINEPROF']
+if Rails.env.development? && RUBY_ENGINE == "ruby" && ENV["ENABLE_LINEPROF"]
Rails.application.config.middleware.use(Rack::Lineprof)
module Rack
@@ -9,10 +9,10 @@ if Rails.env.development? && RUBY_ENGINE == 'ruby' && ENV['ENABLE_LINEPROF']
class Sample < Rack::Lineprof::Sample.superclass
def format(*)
formatted = if level == CONTEXT
- sprintf " | % 3i %s", line, code
- else
- sprintf "% 8.1fms %5i | % 3i %s", ms, calls, line, code
- end
+ sprintf " | % 3i %s", line, code
+ else
+ sprintf "% 8.1fms %5i | % 3i %s", ms, calls, line, code
+ end
case level
when CRITICAL
diff --git a/config/initializers/rbtrace.rb b/config/initializers/rbtrace.rb
index 6a1b71bf4bd..af4bca9cdcf 100644
--- a/config/initializers/rbtrace.rb
+++ b/config/initializers/rbtrace.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-if ENV['ENABLE_RBTRACE']
+if ENV["ENABLE_RBTRACE"]
Gitlab::Cluster::LifecycleEvents.on_worker_start do
# Unicorn clears out signals before it forks, so rbtrace won't work
# unless it is enabled after the fork.
- require 'rbtrace'
+ require "rbtrace"
end
end
diff --git a/config/initializers/rspec_profiling.rb b/config/initializers/rspec_profiling.rb
index 2de310753a9..2be1116ec06 100644
--- a/config/initializers/rspec_profiling.rb
+++ b/config/initializers/rspec_profiling.rb
@@ -1,14 +1,14 @@
module RspecProfilingExt
module PSQL
def establish_connection
- ::RspecProfiling::Collectors::PSQL::Result.establish_connection(ENV['RSPEC_PROFILING_POSTGRES_URL'])
+ ::RspecProfiling::Collectors::PSQL::Result.establish_connection(ENV["RSPEC_PROFILING_POSTGRES_URL"])
end
end
module Git
def branch
- if ENV['CI_COMMIT_REF_NAME']
- "#{defined?(Gitlab::License) ? 'ee' : 'ce'}:#{ENV['CI_COMMIT_REF_NAME']}"
+ if ENV["CI_COMMIT_REF_NAME"]
+ "#{defined?(Gitlab::License) ? "ee" : "ce"}:#{ENV["CI_COMMIT_REF_NAME"]}"
else
super
end
@@ -21,23 +21,23 @@ module RspecProfilingExt
rescue => err
return if @already_logged_example_finished_error # rubocop:disable Gitlab/ModuleWithInstanceVariables
- $stderr.puts "rspec_profiling couldn't collect an example: #{err}. Further warnings suppressed."
+ warn "rspec_profiling couldn't collect an example: #{err}. Further warnings suppressed."
@already_logged_example_finished_error = true # rubocop:disable Gitlab/ModuleWithInstanceVariables
end
- alias_method :example_passed, :example_finished
- alias_method :example_failed, :example_finished
+ alias example_passed example_finished
+ alias example_failed example_finished
end
end
if Rails.env.test?
RspecProfiling.configure do |config|
- if ENV['RSPEC_PROFILING_POSTGRES_URL'].present?
+ if ENV["RSPEC_PROFILING_POSTGRES_URL"].present?
RspecProfiling::Collectors::PSQL.prepend(RspecProfilingExt::PSQL)
config.collector = RspecProfiling::Collectors::PSQL
end
- if ENV.key?('CI')
+ if ENV.key?("CI")
RspecProfiling::VCS::Git.prepend(RspecProfilingExt::Git)
RspecProfiling::Run.prepend(RspecProfilingExt::Run)
end
diff --git a/config/initializers/sentry.rb b/config/initializers/sentry.rb
index abc91c3ae51..d35157f4b6f 100644
--- a/config/initializers/sentry.rb
+++ b/config/initializers/sentry.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
-require 'gitlab/current_settings'
+require "gitlab/current_settings"
def configure_sentry
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
@@ -19,7 +19,7 @@ def configure_sentry
config.sanitize_fields = Rails.application.config.filter_parameters.map(&:to_s)
# Sanitize authentication headers
config.sanitize_http_headers = %w[Authorization Private-Token]
- config.tags = { program: Gitlab.process_name }
+ config.tags = {program: Gitlab.process_name}
end
end
end
diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb
index da24881885e..4e494e23e72 100644
--- a/config/initializers/session_store.rb
+++ b/config/initializers/session_store.rb
@@ -1,19 +1,19 @@
# Be sure to restart your server when you modify this file.
-require 'gitlab/current_settings'
+require "gitlab/current_settings"
# allow it to fail: it may do so when create_from_defaults is executed before migrations are actually done
begin
- Settings.gitlab['session_expire_delay'] = Gitlab::CurrentSettings.current_application_settings.session_expire_delay || 10080
+ Settings.gitlab["session_expire_delay"] = Gitlab::CurrentSettings.current_application_settings.session_expire_delay || 10080
rescue
- Settings.gitlab['session_expire_delay'] ||= 10080
+ Settings.gitlab["session_expire_delay"] ||= 10080
end
cookie_key = if Rails.env.development?
- "_gitlab_session_#{Digest::SHA256.hexdigest(Rails.root.to_s)}"
- else
- "_gitlab_session"
- end
+ "_gitlab_session_#{Digest::SHA256.hexdigest(Rails.root.to_s)}"
+else
+ "_gitlab_session"
+end
sessions_config = Gitlab::Redis::SharedState.params
sessions_config[:namespace] = Gitlab::Redis::SharedState::SESSION_NAMESPACE
@@ -24,6 +24,6 @@ Gitlab::Application.config.session_store(
key: cookie_key,
secure: Gitlab.config.gitlab.https,
httponly: true,
- expires_in: Settings.gitlab['session_expire_delay'] * 60,
- path: Rails.application.config.relative_url_root.nil? ? '/' : Gitlab::Application.config.relative_url_root
+ expires_in: Settings.gitlab["session_expire_delay"] * 60,
+ path: Rails.application.config.relative_url_root.nil? ? "/" : Gitlab::Application.config.relative_url_root
)
diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb
index 69a60a65e77..9cd27a2a16f 100644
--- a/config/initializers/sidekiq.rb
+++ b/config/initializers/sidekiq.rb
@@ -1,4 +1,4 @@
-require 'sidekiq/web'
+require "sidekiq/web"
# Disable the Sidekiq Rack session since GitLab already has its own session store.
# CSRF protection still works (https://github.com/mperham/sidekiq/commit/315504e766c4fd88a29b7772169060afc4c40329).
@@ -9,21 +9,21 @@ queues_config_hash = Gitlab::Redis::Queues.params
queues_config_hash[:namespace] = Gitlab::Redis::Queues::SIDEKIQ_NAMESPACE
# Default is to retry 25 times with exponential backoff. That's too much.
-Sidekiq.default_worker_options = { retry: 3 }
+Sidekiq.default_worker_options = {retry: 3}
if Rails.env.development?
Sidekiq.default_worker_options[:backtrace] = true
end
-enable_json_logs = Gitlab.config.sidekiq.log_format == 'json'
+enable_json_logs = Gitlab.config.sidekiq.log_format == "json"
Sidekiq.configure_server do |config|
config.redis = queues_config_hash
config.server_middleware do |chain|
- chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV['SIDEKIQ_LOG_ARGUMENTS'] && !enable_json_logs
+ chain.add Gitlab::SidekiqMiddleware::ArgumentsLogger if ENV["SIDEKIQ_LOG_ARGUMENTS"] && !enable_json_logs
chain.add Gitlab::SidekiqMiddleware::Shutdown
- chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV['SIDEKIQ_REQUEST_STORE'] == '0'
+ chain.add Gitlab::SidekiqMiddleware::RequestStoreMiddleware unless ENV["SIDEKIQ_REQUEST_STORE"] == "0"
chain.add Gitlab::SidekiqMiddleware::BatchLoader
chain.add Gitlab::SidekiqMiddleware::CorrelationLogger
chain.add Gitlab::SidekiqStatus::ServerMiddleware
@@ -55,10 +55,10 @@ Sidekiq.configure_server do |config|
# UGLY Hack to get nested hash from settingslogic
cron_jobs = JSON.parse(Gitlab.config.cron_jobs.to_json)
# UGLY hack: Settingslogic doesn't allow 'class' key
- cron_jobs_required_keys = %w(job_class cron)
+ cron_jobs_required_keys = %w[job_class cron]
cron_jobs.each do |k, v|
if cron_jobs[k] && cron_jobs_required_keys.all? { |s| cron_jobs[k].key?(s) }
- cron_jobs[k]['class'] = cron_jobs[k].delete('job_class')
+ cron_jobs[k]["class"] = cron_jobs[k].delete("job_class")
else
cron_jobs.delete(k)
Rails.logger.error("Invalid cron_jobs config key: '#{k}'. Check your gitlab config file.")
@@ -70,9 +70,9 @@ Sidekiq.configure_server do |config|
db_config = Gitlab::Database.config ||
Rails.application.config.database_configuration[Rails.env]
- db_config['pool'] = Sidekiq.options[:concurrency]
+ db_config["pool"] = Sidekiq.options[:concurrency]
ActiveRecord::Base.establish_connection(db_config)
- Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get('@size')}")
+ Rails.logger.debug("Connection Pool size for Sidekiq Server is now: #{ActiveRecord::Base.connection.pool.instance_variable_get("@size")}")
# Avoid autoload issue such as 'Mail::Parsers::AddressStruct'
# https://github.com/mikel/mail/issues/912#issuecomment-214850355
diff --git a/config/initializers/static_files.rb b/config/initializers/static_files.rb
index e02f0868e9f..d9c3d473b25 100644
--- a/config/initializers/static_files.rb
+++ b/config/initializers/static_files.rb
@@ -23,7 +23,7 @@ if app.config.public_file_server.enabled
host: dev_server.host,
port: dev_server.port,
manifest_host: dev_server.host,
- manifest_port: dev_server.port
+ manifest_port: dev_server.port,
}
if Rails.env.development?
diff --git a/config/initializers/tracing.rb b/config/initializers/tracing.rb
index ddd91150c90..ff6764230b8 100644
--- a/config/initializers/tracing.rb
+++ b/config/initializers/tracing.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
if Gitlab::Tracing.enabled?
- require 'opentracing'
+ require "opentracing"
Rails.application.configure do |config|
config.middleware.insert_after Gitlab::Middleware::CorrelationId, ::Gitlab::Tracing::RackMiddleware
diff --git a/config/initializers/trusted_proxies.rb b/config/initializers/trusted_proxies.rb
index 7af465d8443..bed5b944000 100644
--- a/config/initializers/trusted_proxies.rb
+++ b/config/initializers/trusted_proxies.rb
@@ -13,15 +13,15 @@ module Rack
end
end
-gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map do |proxy|
- begin
+gitlab_trusted_proxies = Array(Gitlab.config.gitlab.trusted_proxies).map { |proxy|
+
IPAddr.new(proxy)
rescue IPAddr::InvalidAddressError
- end
-end.compact
+
+}.compact
Rails.application.config.action_dispatch.trusted_proxies = (
- ['127.0.0.1', '::1'] + gitlab_trusted_proxies)
+ ["127.0.0.1", "::1"] + gitlab_trusted_proxies)
# A monkey patch to make trusted proxies work with Rails 5.0.
# Inspired by https://github.com/rails/rails/issues/5223#issuecomment-263778719
diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb
index 1d2bb2bce0a..7be1921fd24 100644
--- a/config/initializers/warden.rb
+++ b/config/initializers/warden.rb
@@ -50,13 +50,13 @@ Rails.application.configure do |config|
# 'warden.auth.*' is our custom hash key that follows usual convention
# of naming keys in the Rack env hash.
#
- next if auth.env['warden.auth.user.blocked']
+ next if auth.env["warden.auth.user.blocked"]
if user.blocked?
activity.user_blocked!
tracker.log_activity!
end
- auth.env['warden.auth.user.blocked'] = true
+ auth.env["warden.auth.user.blocked"] = true
end
end
diff --git a/config/initializers/zz_metrics.rb b/config/initializers/zz_metrics.rb
index 151cad3ef9a..bed3403795c 100644
--- a/config/initializers/zz_metrics.rb
+++ b/config/initializers/zz_metrics.rb
@@ -22,25 +22,25 @@ def instrument_classes(instrumentation)
# Path to search => prefix to strip from constant
paths_to_instrument = {
- %w(app finders) => %w(app finders),
- %w(app mailers emails) => %w(app mailers),
+ %w[app finders] => %w[app finders],
+ %w[app mailers emails] => %w[app mailers],
# Don't instrument `app/services/concerns`
# It contains modules that are included in the services.
# The services themselves are instrumented so the methods from the modules
# are included.
- %w(app services [^concerns]**) => %w(app services),
- %w(lib gitlab conflicts) => ['lib'],
- %w(lib gitlab diff) => ['lib'],
- %w(lib gitlab email message) => ['lib'],
- %w(lib gitlab checks) => ['lib']
+ %w(app services [^concerns]**) => %w[app services],
+ %w[lib gitlab conflicts] => ["lib"],
+ %w[lib gitlab diff] => ["lib"],
+ %w[lib gitlab email message] => ["lib"],
+ %w[lib gitlab checks] => ["lib"],
}
paths_to_instrument.each do |(path, prefix)|
prefix = Rails.root.join(*prefix)
- Dir[Rails.root.join(*path + ['*.rb'])].each do |file_path|
+ Dir[Rails.root.join(*path + ["*.rb"])].each do |file_path|
path = Pathname.new(file_path).relative_path_from(prefix)
- const = path.to_s.sub('.rb', '').camelize.constantize
+ const = path.to_s.sub(".rb", "").camelize.constantize
instrumentation.instrument_methods(const)
instrumentation.instrument_instance_methods(const)
@@ -106,16 +106,16 @@ end
# `rails generate migration` because eager loading short-circuits the
# loading of our custom migration templates.
if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && defined?(Rails::Generators))
- require 'pathname'
- require 'influxdb'
- require 'connection_pool'
- require 'method_source'
+ require "pathname"
+ require "influxdb"
+ require "connection_pool"
+ require "method_source"
# These are manually require'd so the classes are registered properly with
# ActiveSupport.
- require_dependency 'gitlab/metrics/subscribers/action_view'
- require_dependency 'gitlab/metrics/subscribers/active_record'
- require_dependency 'gitlab/metrics/subscribers/rails_cache'
+ require_dependency "gitlab/metrics/subscribers/action_view"
+ require_dependency "gitlab/metrics/subscribers/active_record"
+ require_dependency "gitlab/metrics/subscribers/rails_cache"
Gitlab::Application.configure do |config|
config.middleware.use(Gitlab::Metrics::RackMiddleware)
@@ -134,7 +134,7 @@ if Gitlab::Metrics.enabled? && !Rails.env.test? && !(Rails.env.development? && d
Gitlab::Application.config.after_initialize do
Rails.application.eager_load!
- models = Rails.root.join('app', 'models').to_s
+ models = Rails.root.join("app", "models").to_s
regex = Regexp.union(
ActiveRecord::Querying.public_instance_methods(false).map(&:to_s)
diff --git a/config/object_store_settings.rb b/config/object_store_settings.rb
index d85ff394dcc..9c54ba73cb3 100644
--- a/config/object_store_settings.rb
+++ b/config/object_store_settings.rb
@@ -2,14 +2,14 @@
class ObjectStoreSettings
def self.parse(object_store)
object_store ||= Settingslogic.new({})
- object_store['enabled'] = false if object_store['enabled'].nil?
- object_store['remote_directory'] ||= nil
- object_store['direct_upload'] = false if object_store['direct_upload'].nil?
- object_store['background_upload'] = true if object_store['background_upload'].nil?
- object_store['proxy_download'] = false if object_store['proxy_download'].nil?
+ object_store["enabled"] = false if object_store["enabled"].nil?
+ object_store["remote_directory"] ||= nil
+ object_store["direct_upload"] = false if object_store["direct_upload"].nil?
+ object_store["background_upload"] = true if object_store["background_upload"].nil?
+ object_store["proxy_download"] = false if object_store["proxy_download"].nil?
# Convert upload connection settings to use string keys, to make Fog happy
- object_store['connection']&.deep_stringify_keys!
+ object_store["connection"]&.deep_stringify_keys!
object_store
end
end
diff --git a/config/puma.example.development.rb b/config/puma.example.development.rb
index 490c940077a..aa217167860 100644
--- a/config/puma.example.development.rb
+++ b/config/puma.example.development.rb
@@ -10,12 +10,12 @@
#
# The default is "config.ru".
#
-rackup 'config.ru'
-pidfile '/home/git/gitlab/tmp/pids/puma.pid'
-state_path '/home/git/gitlab/tmp/pids/puma.state'
+rackup "config.ru"
+pidfile "/home/git/gitlab/tmp/pids/puma.pid"
+state_path "/home/git/gitlab/tmp/pids/puma.state"
-stdout_redirect '/home/git/gitlab/log/puma.stdout.log',
- '/home/git/gitlab/log/puma.stderr.log',
+stdout_redirect "/home/git/gitlab/log/puma.stdout.log",
+ "/home/git/gitlab/log/puma.stderr.log",
true
# Configure "min" to be the minimum number of threads to use to answer
@@ -37,7 +37,7 @@ queue_requests false
# Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only
# accepted protocols.
-bind 'unix:///home/git/gitlab.socket'
+bind "unix:///home/git/gitlab.socket"
workers 2
@@ -51,7 +51,7 @@ end
before_fork do
# Signal to the puma killer
- Gitlab::Cluster::PumaWorkerKillerInitializer.start @config.options unless ENV['DISABLE_PUMA_WORKER_KILLER']
+ Gitlab::Cluster::PumaWorkerKillerInitializer.start @config.options unless ENV["DISABLE_PUMA_WORKER_KILLER"]
# Signal application hooks that we're about to fork
Gitlab::Cluster::LifecycleEvents.do_before_fork
@@ -68,7 +68,7 @@ end
preload_app!
-tag 'gitlab-puma-worker'
+tag "gitlab-puma-worker"
# Verifies that all workers have checked in to the master process within
# the given timeout. If not the worker process will be restarted. Default
diff --git a/config/routes.rb b/config/routes.rb
index 484e05114be..70ad4d836b7 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1,5 +1,5 @@
-require 'sidekiq/web'
-require 'sidekiq/cron/web'
+require "sidekiq/web"
+require "sidekiq/cron/web"
Rails.application.routes.draw do
concern :access_requestable do
@@ -11,27 +11,27 @@ Rails.application.routes.draw do
post :toggle_award_emoji, on: :member
end
- favicon_redirect = redirect do |_params, _request|
+ favicon_redirect = redirect { |_params, _request|
ActionController::Base.helpers.asset_url(Gitlab::Favicon.main)
- end
- get 'favicon.png', to: favicon_redirect
- get 'favicon.ico', to: favicon_redirect
+ }
+ get "favicon.png", to: favicon_redirect
+ get "favicon.ico", to: favicon_redirect
draw :sherlock
draw :development
draw :ci
use_doorkeeper do
- controllers applications: 'oauth/applications',
- authorized_applications: 'oauth/authorized_applications',
- authorizations: 'oauth/authorizations'
+ controllers applications: "oauth/applications",
+ authorized_applications: "oauth/authorized_applications",
+ authorizations: "oauth/authorizations"
end
# This is here so we can "reserve" the path for the Jira integration in GitLab EE
# Having a non-existent controller here does not affect the scope in any way since all possible routes
# get a 404 proc returned. It is written in this way to minimize merge conflicts with EE
- scope path: '/login/oauth', controller: 'oauth/jira/authorizations', as: :oauth_jira do
- match '*all', via: [:get, :post], to: proc { [404, {}, ['']] }
+ scope path: "/login/oauth", controller: "oauth/jira/authorizations", as: :oauth_jira do
+ match "*all", via: [:get, :post], to: proc { [404, {}, [""]] }
end
draw :oauth
@@ -39,27 +39,27 @@ Rails.application.routes.draw do
use_doorkeeper_openid_connect
# Autocomplete
- get '/autocomplete/users' => 'autocomplete#users'
- get '/autocomplete/users/:id' => 'autocomplete#user'
- get '/autocomplete/projects' => 'autocomplete#projects'
- get '/autocomplete/award_emojis' => 'autocomplete#award_emojis'
+ get "/autocomplete/users" => "autocomplete#users"
+ get "/autocomplete/users/:id" => "autocomplete#user"
+ get "/autocomplete/projects" => "autocomplete#projects"
+ get "/autocomplete/award_emojis" => "autocomplete#award_emojis"
# Search
- get 'search' => 'search#show'
- get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
+ get "search" => "search#show"
+ get "search/autocomplete" => "search#autocomplete", :as => :search_autocomplete
# JSON Web Token
- get 'jwt/auth' => 'jwt#auth'
+ get "jwt/auth" => "jwt#auth"
# Health check
- get 'health_check(/:checks)' => 'health_check#index', as: :health_check
+ get "health_check(/:checks)" => "health_check#index", :as => :health_check
- scope path: '-' do
+ scope path: "-" do
# '/-/health' implemented by BasicHealthMiddleware
- get 'liveness' => 'health#liveness'
- get 'readiness' => 'health#readiness'
+ get "liveness" => "health#liveness"
+ get "readiness" => "health#readiness"
resources :metrics, only: [:index]
- mount Peek::Railtie => '/peek', as: 'peek_routes'
+ mount Peek::Railtie => "/peek", :as => "peek_routes"
# Boards resources shared between group and projects
resources :boards, only: [] do
@@ -77,17 +77,17 @@ Rails.application.routes.draw do
# UserCallouts
resources :user_callouts, only: [:create]
- get 'ide' => 'ide#index'
- get 'ide/*vueroute' => 'ide#index', format: false
+ get "ide" => "ide#index"
+ get "ide/*vueroute" => "ide#index", :format => false
draw :operations
draw :instance_statistics
- if ENV['GITLAB_ENABLE_CHAOS_ENDPOINTS']
- get '/chaos/leakmem' => 'chaos#leakmem'
- get '/chaos/cpuspin' => 'chaos#cpuspin'
- get '/chaos/sleep' => 'chaos#sleep'
- get '/chaos/kill' => 'chaos#kill'
+ if ENV["GITLAB_ENABLE_CHAOS_ENDPOINTS"]
+ get "/chaos/leakmem" => "chaos#leakmem"
+ get "/chaos/cpuspin" => "chaos#cpuspin"
+ get "/chaos/sleep" => "chaos#sleep"
+ get "/chaos/kill" => "chaos#kill"
end
end
@@ -100,7 +100,7 @@ Rails.application.routes.draw do
member do
scope :applications do
- post '/:application', to: 'clusters/applications#create', as: :install_applications
+ post "/:application", to: "clusters/applications#create", as: :install_applications
end
get :cluster_status, format: :json
@@ -114,14 +114,14 @@ Rails.application.routes.draw do
draw :snippets
# Invites
- resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
+ resources :invites, only: [:show], constraints: {id: /[A-Za-z0-9_-]+/} do
member do
post :accept
match :decline, via: [:get, :post]
end
end
- resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
+ resources :sent_notifications, only: [], constraints: {id: /\h{32}/} do
member do
get :unsubscribe
end
@@ -146,5 +146,5 @@ Rails.application.routes.draw do
root to: "root#index"
- get '*unmatched_route', to: 'application#route_not_found'
+ get "*unmatched_route", to: "application#route_not_found"
end
diff --git a/config/routes/admin.rb b/config/routes/admin.rb
index a01003b6039..bbafcbb3d5e 100644
--- a/config/routes/admin.rb
+++ b/config/routes/admin.rb
@@ -1,5 +1,5 @@
namespace :admin do
- resources :users, constraints: { id: %r{[a-zA-Z./0-9_\-]+} } do
+ resources :users, constraints: {id: %r{[a-zA-Z./0-9_\-]+}} do
resources :keys, only: [:show, :destroy]
resources :identities, except: [:show]
resources :impersonation_tokens, only: [:index, :create] do
@@ -17,7 +17,7 @@ namespace :admin do
put :confirm
post :impersonate
patch :disable_two_factor
- delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
+ delete "remove/:email_id", action: "remove_email", as: "remove_email"
end
end
@@ -36,17 +36,17 @@ namespace :admin do
resources :groups, only: [:index, :new, :create]
- scope(path: 'groups/*id',
+ scope(path: "groups/*id",
controller: :groups,
- constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ }) do
+ constraints: {id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/}) do
scope(as: :group) do
put :members_update
get :edit, action: :edit
- get '/', action: :show
- patch '/', action: :update
- put '/', action: :update
- delete '/', action: :destroy
+ get "/", action: :show
+ patch "/", action: :update
+ put "/", action: :update
+ delete "/", action: :destroy
end
end
@@ -69,21 +69,21 @@ namespace :admin do
end
resource :logs, only: [:show]
- resource :health_check, controller: 'health_check', only: [:show]
- resource :background_jobs, controller: 'background_jobs', only: [:show]
+ resource :health_check, controller: "health_check", only: [:show]
+ resource :background_jobs, controller: "background_jobs", only: [:show]
- resource :system_info, controller: 'system_info', only: [:show]
- resources :requests_profiles, only: [:index, :show], param: :name, constraints: { name: /.+\.html/ }
+ resource :system_info, controller: "system_info", only: [:show]
+ resources :requests_profiles, only: [:index, :show], param: :name, constraints: {name: /.+\.html/}
resources :projects, only: [:index]
- scope(path: 'projects/*namespace_id',
+ scope(path: "projects/*namespace_id",
as: :namespace,
- constraints: { namespace_id: Gitlab::PathRegex.full_namespace_route_regex }) do
+ constraints: {namespace_id: Gitlab::PathRegex.full_namespace_route_regex}) do
resources(:projects,
- path: '/',
- constraints: { id: Gitlab::PathRegex.project_route_regex },
- only: [:show]) do
+ path: "/",
+ constraints: {id: Gitlab::PathRegex.project_route_regex},
+ only: [:show]) do
member do
put :transfer
@@ -94,7 +94,7 @@ namespace :admin do
end
end
- resource :appearances, only: [:show, :create, :update], path: 'appearance' do
+ resource :appearances, only: [:show, :create, :update], path: "appearance" do
member do
get :preview_sign_in
delete :logo
@@ -132,5 +132,5 @@ namespace :admin do
end
end
- root to: 'dashboard#index'
+ root to: "dashboard#index"
end
diff --git a/config/routes/api.rb b/config/routes/api.rb
index 3719b7d3a1e..88841210fbe 100644
--- a/config/routes/api.rb
+++ b/config/routes/api.rb
@@ -1,7 +1,7 @@
constraints(::Constraints::FeatureConstrainer.new(:graphql, default_enabled: true)) do
- post '/api/graphql', to: 'graphql#execute'
- mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql'
+ post "/api/graphql", to: "graphql#execute"
+ mount GraphiQL::Rails::Engine, at: "/-/graphql-explorer", graphql_path: "/api/graphql"
end
API::API.logger Rails.logger
-mount API::API => '/'
+mount API::API => "/"
diff --git a/config/routes/ci.rb b/config/routes/ci.rb
index ebd321ed097..876750a92ed 100644
--- a/config/routes/ci.rb
+++ b/config/routes/ci.rb
@@ -1,5 +1,5 @@
namespace :ci do
resource :lint, only: :show
- root to: redirect('')
+ root to: redirect("")
end
diff --git a/config/routes/dashboard.rb b/config/routes/dashboard.rb
index f1e8c2b9d82..51589697390 100644
--- a/config/routes/dashboard.rb
+++ b/config/routes/dashboard.rb
@@ -1,4 +1,4 @@
-resource :dashboard, controller: 'dashboard', only: [] do
+resource :dashboard, controller: "dashboard", only: [] do
get :issues, action: :issues_calendar, constraints: lambda { |req| req.format == :ics }
get :issues
get :merge_requests
diff --git a/config/routes/development.rb b/config/routes/development.rb
index 9b2b47c6a21..40add12b5e5 100644
--- a/config/routes/development.rb
+++ b/config/routes/development.rb
@@ -3,11 +3,11 @@ if Rails.env.development?
# get swallowed by the `namespace/project` route matcher below.
#
# See https://git.io/va79N
- get '/rails/mailers' => 'rails/mailers#index'
- get '/rails/mailers/:path' => 'rails/mailers#preview'
- get '/rails/info/properties' => 'rails/info#properties'
- get '/rails/info/routes' => 'rails/info#routes'
- get '/rails/info' => 'rails/info#index'
+ get "/rails/mailers" => "rails/mailers#index"
+ get "/rails/mailers/:path" => "rails/mailers#preview"
+ get "/rails/info/properties" => "rails/info#properties"
+ get "/rails/info/routes" => "rails/info#routes"
+ get "/rails/info" => "rails/info#index"
- mount LetterOpenerWeb::Engine, at: '/rails/letter_opener'
+ mount LetterOpenerWeb::Engine, at: "/rails/letter_opener"
end
diff --git a/config/routes/explore.rb b/config/routes/explore.rb
index 42ec5e8abec..bdf75bb1ace 100644
--- a/config/routes/explore.rb
+++ b/config/routes/explore.rb
@@ -8,9 +8,9 @@ namespace :explore do
resources :groups, only: [:index]
resources :snippets, only: [:index]
- root to: 'projects#trending'
+ root to: "projects#trending"
end
# Compatibility with old routing
-get 'public' => 'explore/projects#index'
-get 'public/projects' => 'explore/projects#index'
+get "public" => "explore/projects#index"
+get "public/projects" => "explore/projects#index"
diff --git a/config/routes/git_http.rb b/config/routes/git_http.rb
index ec5c68f81df..710a1b2a4cc 100644
--- a/config/routes/git_http.rb
+++ b/config/routes/git_http.rb
@@ -1,41 +1,41 @@
-scope(path: '*namespace_id/:project_id',
+scope(path: "*namespace_id/:project_id",
format: nil,
- constraints: { namespace_id: Gitlab::PathRegex.full_namespace_route_regex }) do
- scope(constraints: { project_id: Gitlab::PathRegex.project_git_route_regex }, module: :projects) do
+ constraints: {namespace_id: Gitlab::PathRegex.full_namespace_route_regex}) do
+ scope(constraints: {project_id: Gitlab::PathRegex.project_git_route_regex}, module: :projects) do
# Git HTTP clients ('git clone' etc.)
scope(controller: :git_http) do
- get '/info/refs', action: :info_refs
- post '/git-upload-pack', action: :git_upload_pack
- post '/git-receive-pack', action: :git_receive_pack
+ get "/info/refs", action: :info_refs
+ post "/git-upload-pack", action: :git_upload_pack
+ post "/git-receive-pack", action: :git_receive_pack
end
# Git LFS API (metadata)
- scope(path: 'info/lfs/objects', controller: :lfs_api) do
+ scope(path: "info/lfs/objects", controller: :lfs_api) do
post :batch
- post '/', action: :deprecated
- get '/*oid', action: :deprecated
+ post "/", action: :deprecated
+ get "/*oid", action: :deprecated
end
- scope(path: 'info/lfs') do
- resources :lfs_locks, controller: :lfs_locks_api, path: 'locks' do
+ scope(path: "info/lfs") do
+ resources :lfs_locks, controller: :lfs_locks_api, path: "locks" do
post :unlock, on: :member
post :verify, on: :collection
end
end
# GitLab LFS object storage
- scope(path: 'gitlab-lfs/objects/*oid', controller: :lfs_storage, constraints: { oid: /[a-f0-9]{64}/ }) do
- get '/', action: :download
+ scope(path: "gitlab-lfs/objects/*oid", controller: :lfs_storage, constraints: {oid: /[a-f0-9]{64}/}) do
+ get "/", action: :download
- scope constraints: { size: /[0-9]+/ } do
- put '/*size/authorize', action: :upload_authorize
- put '/*size', action: :upload_finalize
+ scope constraints: {size: /[0-9]+/} do
+ put "/*size/authorize", action: :upload_authorize
+ put "/*size", action: :upload_finalize
end
end
end
# Redirect /group/project/info/refs to /group/project.git/info/refs
- scope(constraints: { project_id: Gitlab::PathRegex.project_route_regex }) do
+ scope(constraints: {project_id: Gitlab::PathRegex.project_route_regex}) do
# Allow /info/refs, /info/refs?service=git-upload-pack, and
# /info/refs?service=git-receive-pack, but nothing else.
#
@@ -45,12 +45,12 @@ scope(path: '*namespace_id/:project_id',
request.query_string.match(/\Aservice=git-(upload|receive)-pack\z/))
end
- ref_redirect = redirect do |params, request|
+ ref_redirect = redirect { |params, request|
path = "#{params[:namespace_id]}/#{params[:project_id]}.git/info/refs"
path << "?#{request.query_string}" unless request.query_string.blank?
path
- end
+ }
- get '/info/refs', constraints: git_http_handshake, to: ref_redirect
+ get "/info/refs", constraints: git_http_handshake, to: ref_redirect
end
end
diff --git a/config/routes/google_api.rb b/config/routes/google_api.rb
index a119b47c176..f19eebeaa8f 100644
--- a/config/routes/google_api.rb
+++ b/config/routes/google_api.rb
@@ -1,4 +1,4 @@
-scope '-' do
+scope "-" do
namespace :google_api do
resource :auth, only: [], controller: :authorizations do
match :callback, via: [:get, :post]
diff --git a/config/routes/group.rb b/config/routes/group.rb
index a0aeebe4b91..f2a1f296bc6 100644
--- a/config/routes/group.rb
+++ b/config/routes/group.rb
@@ -5,10 +5,10 @@ resources :groups, only: [:index, :new, :create] do
end
constraints(::Constraints::GroupUrlConstrainer.new) do
- scope(path: 'groups/*id',
+ scope(path: "groups/*id",
controller: :groups,
- constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom|ics)/ }) do
- scope(path: '-') do
+ constraints: {id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom|ics)/}) do
+ scope(path: "-") do
get :edit, as: :edit_group
get :issues, as: :issues_group_calendar, action: :issues_calendar, constraints: lambda { |req| req.format == :ics }
get :issues, as: :issues_group
@@ -17,19 +17,19 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
get :activity, as: :activity_group
put :transfer, as: :transfer_group
# TODO: Remove as part of refactor in https://gitlab.com/gitlab-org/gitlab-ce/issues/49693
- get 'shared', action: :show, as: :group_shared
- get 'archived', action: :show, as: :group_archived
+ get "shared", action: :show, as: :group_shared
+ get "archived", action: :show, as: :group_archived
end
- get '/', action: :show, as: :group_canonical
+ get "/", action: :show, as: :group_canonical
end
- scope(path: 'groups/*group_id/-',
+ scope(path: "groups/*group_id/-",
module: :groups,
as: :group,
- constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do
+ constraints: {group_id: Gitlab::PathRegex.full_namespace_route_regex}) do
namespace :settings do
- resource :ci_cd, only: [:show], controller: 'ci_cd' do
+ resource :ci_cd, only: [:show], controller: "ci_cd" do
put :reset_registration_token
end
end
@@ -43,7 +43,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
post :toggle_subscription, on: :member
end
- resources :milestones, constraints: { id: %r{[^/]+} } do
+ resources :milestones, constraints: {id: %r{[^/]+}} do
member do
get :merge_requests
get :participants
@@ -62,7 +62,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resources :uploads, only: [:create] do
collection do
- get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} }
+ get ":secret/:filename", action: :show, as: :show, constraints: {filename: %r{[^/]+}}
post :authorize
end
end
@@ -77,21 +77,21 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end
end
- scope(path: '*id',
+ scope(path: "*id",
as: :group,
- constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/ },
+ constraints: {id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom)/},
controller: :groups) do
- get '/', action: :show
- patch '/', action: :update
- put '/', action: :update
- delete '/', action: :destroy
+ get "/", action: :show
+ patch "/", action: :update
+ put "/", action: :update
+ delete "/", action: :destroy
end
# Legacy paths should be defined last, so they would be ignored if routes with
# one of the previously reserved words exist.
- scope(path: 'groups/*group_id') do
+ scope(path: "groups/*group_id") do
Gitlab::Routing.redirect_legacy_paths(self, :labels, :milestones, :group_members,
- :edit, :issues, :merge_requests, :projects,
- :activity)
+ :edit, :issues, :merge_requests, :projects,
+ :activity)
end
end
diff --git a/config/routes/help.rb b/config/routes/help.rb
index 2ea8bfd7aed..228ca3b9f61 100644
--- a/config/routes/help.rb
+++ b/config/routes/help.rb
@@ -1,5 +1,5 @@
-get 'help' => 'help#index'
-get 'help/shortcuts' => 'help#shortcuts'
-get 'help/ui' => 'help#ui'
-get 'help/instance_configuration' => 'help#instance_configuration'
-get 'help/*path' => 'help#show', as: :help_page
+get "help" => "help#index"
+get "help/shortcuts" => "help#shortcuts"
+get "help/ui" => "help#ui"
+get "help/instance_configuration" => "help#instance_configuration"
+get "help/*path" => "help#show", :as => :help_page
diff --git a/config/routes/import.rb b/config/routes/import.rb
index 24013eb2c88..a30e8cb61ea 100644
--- a/config/routes/import.rb
+++ b/config/routes/import.rb
@@ -2,7 +2,7 @@
# the OAuth2 callback URL can be restricted under http://example.com/users/auth
# instead of http://example.com.
Devise.omniauth_providers.map(&:downcase).each do |provider|
- next if provider == 'ldapmain'
+ next if provider == "ldapmain"
get "/users/auth/-/import/#{provider}/callback", to: "import/#{provider}#callback", as: "users_import_#{provider}_callback"
end
diff --git a/config/routes/instance_statistics.rb b/config/routes/instance_statistics.rb
index 1102ef6b017..8a6354d921d 100644
--- a/config/routes/instance_statistics.rb
+++ b/config/routes/instance_statistics.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
namespace :instance_statistics do
- root to: redirect('-/instance_statistics/conversational_development_index')
+ root to: redirect("-/instance_statistics/conversational_development_index")
resources :cohorts, only: :index
resources :conversational_development_index, only: :index
diff --git a/config/routes/legacy_builds.rb b/config/routes/legacy_builds.rb
index 5ab2b953ce1..59475743da9 100644
--- a/config/routes/legacy_builds.rb
+++ b/config/routes/legacy_builds.rb
@@ -1,9 +1,9 @@
-resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
+resources :builds, only: [:index, :show], constraints: {id: /\d+/} do
collection do
- resources :artifacts, only: [], controller: 'build_artifacts' do
+ resources :artifacts, only: [], controller: "build_artifacts" do
collection do
get :latest_succeeded,
- path: '*ref_name_and_path',
+ path: "*ref_name_and_path",
format: false
end
end
@@ -13,10 +13,10 @@ resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
get :raw
end
- resource :artifacts, only: [], controller: 'build_artifacts' do
+ resource :artifacts, only: [], controller: "build_artifacts" do
get :download
- get :browse, path: 'browse(/*path)', format: false
- get :file, path: 'file/*path', format: false
- get :raw, path: 'raw/*path', format: false
+ get :browse, path: "browse(/*path)", format: false
+ get :file, path: "file/*path", format: false
+ get :raw, path: "raw/*path", format: false
end
end
diff --git a/config/routes/profile.rb b/config/routes/profile.rb
index c1cac3905f1..565e318c4e7 100644
--- a/config/routes/profile.rb
+++ b/config/routes/profile.rb
@@ -1,10 +1,10 @@
# for secondary email confirmations - uses the same confirmation controller as :users
-devise_for :emails, path: 'profile/emails', controllers: { confirmations: :confirmations }
+devise_for :emails, path: "profile/emails", controllers: {confirmations: :confirmations}
resource :profile, only: [:show, :update] do
member do
get :audit_log
- get :applications, to: 'oauth/applications#index'
+ get :applications, to: "oauth/applications#index"
put :reset_incoming_email_token
put :reset_feed_token
diff --git a/config/routes/project.rb b/config/routes/project.rb
index b4ebc7df4fe..63f9c99b10e 100644
--- a/config/routes/project.rb
+++ b/config/routes/project.rb
@@ -2,7 +2,7 @@ resources :projects, only: [:index, :new, :create]
draw :git_http
-get '/projects/:id' => 'projects#resolve'
+get "/projects/:id" => "projects#resolve"
constraints(::Constraints::ProjectUrlConstrainer.new) do
# If the route has a wildcard segment, the segment has a regex constraint,
@@ -18,33 +18,33 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# `:project_id`, or `*id`.
#
# See https://github.com/rails/rails/blob/v4.2.8/actionpack/lib/action_dispatch/routing/mapper.rb#L155
- scope(path: '*namespace_id',
+ scope(path: "*namespace_id",
as: :namespace,
namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do
- scope(path: ':project_id',
- constraints: { project_id: Gitlab::PathRegex.project_route_regex },
+ scope(path: ":project_id",
+ constraints: {project_id: Gitlab::PathRegex.project_route_regex},
module: :projects,
as: :project) do
resources :autocomplete_sources, only: [] do
collection do
- get 'members'
- get 'issues'
- get 'merge_requests'
- get 'labels'
- get 'milestones'
- get 'commands'
- get 'snippets'
+ get "members"
+ get "issues"
+ get "merge_requests"
+ get "labels"
+ get "milestones"
+ get "commands"
+ get "snippets"
end
end
#
# Templates
#
- get '/templates/:template_type/:key' => 'templates#show', as: :template, constraints: { key: %r{[^/]+} }
+ get "/templates/:template_type/:key" => "templates#show", :as => :template, :constraints => {key: %r{[^/]+}}
resource :avatar, only: [:show, :destroy]
- resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
+ resources :commit, only: [:show], constraints: {id: /\h{7,40}/} do
member do
get :branches
get :pipelines
@@ -56,21 +56,21 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
resource :pages, only: [:show, :update, :destroy] do
- resources :domains, except: :index, controller: 'pages_domains', constraints: { id: %r{[^/]+} } do
+ resources :domains, except: :index, controller: "pages_domains", constraints: {id: %r{[^/]+}} do
member do
post :verify
end
end
end
- resources :snippets, concerns: :awardable, constraints: { id: /\d+/ } do
+ resources :snippets, concerns: :awardable, constraints: {id: /\d+/} do
member do
get :raw
post :mark_as_spam
end
end
- resources :services, constraints: { id: %r{[^/]+} }, only: [:edit, :update] do
+ resources :services, constraints: {id: %r{[^/]+}}, only: [:edit, :update] do
member do
put :test
end
@@ -79,19 +79,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :mattermost, only: [:new, :create]
namespace :prometheus do
- resources :metrics, constraints: { id: %r{[^\/]+} }, only: [] do
+ resources :metrics, constraints: {id: %r{[^\/]+}}, only: [] do
get :active_common, on: :collection
end
end
- resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create, :edit, :update] do
+ resources :deploy_keys, constraints: {id: /\d+/}, only: [:index, :new, :create, :edit, :update] do
member do
put :enable
put :disable
end
end
- resources :deploy_tokens, constraints: { id: /\d+/ }, only: [] do
+ resources :deploy_tokens, constraints: {id: /\d+/}, only: [] do
member do
put :revoke
end
@@ -101,7 +101,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :forks, only: [:index, :new, :create]
resource :import, only: [:new, :create, :show]
- resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: { id: /\d+/ } do
+ resources :merge_requests, concerns: :awardable, except: [:new, :create], constraints: {id: /\d+/} do
member do
get :commit_change_content
post :merge
@@ -115,21 +115,21 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :rebase
get :test_reports
- scope constraints: { format: nil }, action: :show do
- get :commits, defaults: { tab: 'commits' }
- get :pipelines, defaults: { tab: 'pipelines' }
- get :diffs, defaults: { tab: 'diffs' }
+ scope constraints: {format: nil}, action: :show do
+ get :commits, defaults: {tab: "commits"}
+ get :pipelines, defaults: {tab: "pipelines"}
+ get :diffs, defaults: {tab: "diffs"}
end
- scope constraints: { format: 'json' }, as: :json do
+ scope constraints: {format: "json"}, as: :json do
get :commits
get :pipelines
- get :diffs, to: 'merge_requests/diffs#show'
+ get :diffs, to: "merge_requests/diffs#show"
end
- get :diff_for_path, controller: 'merge_requests/diffs'
+ get :diff_for_path, controller: "merge_requests/diffs"
- scope controller: 'merge_requests/conflicts' do
+ scope controller: "merge_requests/conflicts" do
get :conflicts, action: :show
get :conflict_for_path
post :resolve_conflicts
@@ -141,7 +141,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :bulk_update
end
- resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do
+ resources :discussions, only: [:show], constraints: {id: /\h{40}/} do
member do
post :resolve
delete :resolve, action: :unresolve
@@ -149,18 +149,18 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- scope path: 'merge_requests', controller: 'merge_requests/creations' do
- post '', action: :create, as: nil
+ scope path: "merge_requests", controller: "merge_requests/creations" do
+ post "", action: :create, as: nil
- scope path: 'new', as: :new_merge_request do
- get '', action: :new
+ scope path: "new", as: :new_merge_request do
+ get "", action: :new
- scope constraints: { format: nil }, action: :new do
- get :diffs, defaults: { tab: 'diffs' }
- get :pipelines, defaults: { tab: 'pipelines' }
+ scope constraints: {format: nil}, action: :new do
+ get :diffs, defaults: {tab: "diffs"}
+ get :pipelines, defaults: {tab: "pipelines"}
end
- scope constraints: { format: 'json' }, as: :json do
+ scope constraints: {format: "json"}, as: :json do
get :diffs
get :pipelines
end
@@ -181,14 +181,14 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :mirror, only: [:show, :update] do
member do
- get :ssh_host_keys, constraints: { format: :json }
+ get :ssh_host_keys, constraints: {format: :json}
post :update_now
end
end
resources :pipelines, only: [:index, :new, :create, :show] do
collection do
- resource :pipelines_settings, path: 'settings', only: [:show, :update]
+ resource :pipelines_settings, path: "settings", only: [:show, :update]
get :charts
end
@@ -218,12 +218,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :terminal
get :metrics
get :additional_metrics
- get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil }
+ get "/terminal.ws/authorize", to: "environments#terminal_websocket_authorize", constraints: {format: nil}
end
collection do
get :metrics, action: :metrics_redirect
- get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
+ get :folder, path: "folders/*id", constraints: {format: /(html|json)/}
get :search
end
@@ -238,7 +238,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :cycle_analytics, only: [:show]
namespace :cycle_analytics do
- scope :events, controller: 'events' do
+ scope :events, controller: "events" do
get :issue
get :plan
get :code
@@ -250,19 +250,19 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
namespace :serverless do
- get '/functions/:environment_id/:id', to: 'functions#show'
+ get "/functions/:environment_id/:id", to: "functions#show"
resources :functions, only: [:index]
end
- scope '-' do
- get 'archive/*id', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/ }, to: 'repositories#archive', as: 'archive'
+ scope "-" do
+ get "archive/*id", constraints: {format: Gitlab::PathRegex.archive_formats_regex, id: /.+?/}, to: "repositories#archive", as: "archive"
- resources :jobs, only: [:index, :show], constraints: { id: /\d+/ } do
+ resources :jobs, only: [:index, :show], constraints: {id: /\d+/} do
collection do
resources :artifacts, only: [] do
collection do
get :latest_succeeded,
- path: '*ref_name_and_path',
+ path: "*ref_name_and_path",
format: false
end
end
@@ -275,17 +275,17 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :retry
post :play
post :erase
- get :trace, defaults: { format: 'json' }
+ get :trace, defaults: {format: "json"}
get :raw
get :terminal
- get '/terminal.ws/authorize', to: 'jobs#terminal_websocket_authorize', constraints: { format: nil }
+ get "/terminal.ws/authorize", to: "jobs#terminal_websocket_authorize", constraints: {format: nil}
end
resource :artifacts, only: [] do
get :download
- get :browse, path: 'browse(/*path)', format: false
- get :file, path: 'file/*path', format: false
- get :raw, path: 'raw/*path', format: false
+ get :browse, path: "browse(/*path)", format: false
+ get :file, path: "file/*path", format: false
+ get :raw, path: "raw/*path", format: false
post :keep
end
end
@@ -297,7 +297,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
draw :legacy_builds
- resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
+ resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: {id: /\d+/} do
member do
post :test
end
@@ -310,7 +310,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
resources :container_registry, only: [:index, :destroy],
- controller: 'registry/repositories'
+ controller: "registry/repositories"
namespace :registry do
resources :repository, only: [] do
@@ -319,12 +319,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
# in JSON format, or a request for tag named `latest.json`.
scope format: false do
resources :tags, only: [:index, :destroy],
- constraints: { id: Gitlab::Regex.container_registry_tag_regex }
+ constraints: {id: Gitlab::Regex.container_registry_tag_regex}
end
end
end
- resources :milestones, constraints: { id: /\d+/ } do
+ resources :milestones, constraints: {id: /\d+/} do
member do
post :promote
put :sort_issues
@@ -335,7 +335,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- resources :labels, except: [:show], constraints: { id: /\d+/ } do
+ resources :labels, except: [:show], constraints: {id: /\d+/} do
collection do
post :generate
post :set_priorities
@@ -348,8 +348,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- get :issues, to: 'issues#calendar', constraints: lambda { |req| req.format == :ics }
- resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do
+ get :issues, to: "issues#calendar", constraints: lambda { |req| req.format == :ics }
+ resources :issues, concerns: :awardable, constraints: {id: /\d+/} do
member do
post :toggle_subscription
post :mark_as_spam
@@ -367,7 +367,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- resources :project_members, except: [:show, :new, :edit], constraints: { id: %r{[a-zA-Z./0-9_\-#%+]+} }, concerns: :access_requestable do
+ resources :project_members, except: [:show, :new, :edit], constraints: {id: %r{[a-zA-Z./0-9_\-#%+]+}}, concerns: :access_requestable do
collection do
delete :leave
@@ -382,9 +382,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- resources :group_links, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ }
+ resources :group_links, only: [:index, :create, :update, :destroy], constraints: {id: /\d+/}
- resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do
+ resources :notes, only: [:create, :destroy, :update], concerns: :awardable, constraints: {id: /\d+/} do
member do
delete :delete_attachment
post :resolve
@@ -392,7 +392,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
- get 'noteable/:target_type/:target_id/notes' => 'notes#index', as: 'noteable_notes'
+ get "noteable/:target_type/:target_id/notes" => "notes#index", :as => "noteable_notes"
# On CE only index and show are needed
resources :boards, only: [:index, :show]
@@ -401,7 +401,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :uploads, only: [:create] do
collection do
- get ":secret/:filename", action: :show, as: :show, constraints: { filename: %r{[^/]+} }
+ get ":secret/:filename", action: :show, as: :show, constraints: {filename: %r{[^/]+}}
post :authorize
end
end
@@ -421,7 +421,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :runner_projects, only: [:create, :destroy]
resources :badges, only: [:index] do
collection do
- scope '*ref', constraints: { ref: Gitlab::PathRegex.git_reference_regex } do
+ scope "*ref", constraints: {ref: Gitlab::PathRegex.git_reference_regex} do
constraints format: /svg/ do
# Keep around until 10.0, see gitlab-org/gitlab-ce#35307
get :build, to: "badges#pipeline"
@@ -433,13 +433,13 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
namespace :settings do
get :members, to: redirect("%{namespace_id}/%{project_id}/project_members")
- resource :ci_cd, only: [:show, :update], controller: 'ci_cd' do
+ resource :ci_cd, only: [:show, :update], controller: "ci_cd" do
post :reset_cache
put :reset_registration_token
end
resource :integrations, only: [:show]
resource :repository, only: [:show], controller: :repository do
- post :create_deploy_token, path: 'deploy_token/create'
+ post :create_deploy_token, path: "deploy_token/create"
post :cleanup
end
end
@@ -461,9 +461,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
resources(:projects,
- path: '/',
- constraints: { id: Gitlab::PathRegex.project_route_regex },
- only: [:edit, :show, :update, :destroy]) do
+ path: "/",
+ constraints: {id: Gitlab::PathRegex.project_route_regex},
+ only: [:edit, :show, :update, :destroy]) do
member do
put :transfer
delete :remove_fork
diff --git a/config/routes/repository.rb b/config/routes/repository.rb
index f5201b9ddbb..54df1810dd6 100644
--- a/config/routes/repository.rb
+++ b/config/routes/repository.rb
@@ -3,17 +3,17 @@
resource :repository, only: [:create] do
member do
# deprecated since GitLab 9.5
- get 'archive', constraints: { format: Gitlab::PathRegex.archive_formats_regex }, as: 'archive_alternative', defaults: { append_sha: true }
+ get "archive", constraints: {format: Gitlab::PathRegex.archive_formats_regex}, as: "archive_alternative", defaults: {append_sha: true}
# deprecated since GitLab 10.7
- get ':id/archive', constraints: { format: Gitlab::PathRegex.archive_formats_regex, id: /.+/ }, action: 'archive', as: 'archive_deprecated', defaults: { append_sha: true }
+ get ":id/archive", constraints: {format: Gitlab::PathRegex.archive_formats_regex, id: /.+/}, action: "archive", as: "archive_deprecated", defaults: {append_sha: true}
end
end
# Don't use format parameter as file extension (old 3.0.x behavior)
# See http://guides.rubyonrails.org/routing.html#route-globbing-and-wildcard-segments
scope format: false do
- get '/compare/:from...:to', to: 'compare#show', as: 'compare', constraints: { from: /.+/, to: /.+/ }
+ get "/compare/:from...:to", to: "compare#show", as: "compare", constraints: {from: /.+/, to: /.+/}
resources :compare, only: [:index, :create] do
collection do
@@ -24,22 +24,22 @@ scope format: false do
resources :refs, only: [] do
collection do
- get 'switch'
+ get "switch"
end
member do
# tree viewer logs
- get 'logs_tree', constraints: { id: Gitlab::PathRegex.git_reference_regex }
+ get "logs_tree", constraints: {id: Gitlab::PathRegex.git_reference_regex}
# Directories with leading dots erroneously get rejected if git
# ref regex used in constraints. Regex verification now done in controller.
- get 'logs_tree/*path', action: :logs_tree, as: :logs_file, format: false, constraints: {
+ get "logs_tree/*path", action: :logs_tree, as: :logs_file, format: false, constraints: {
id: /.*/,
- path: /.*/
+ path: /.*/,
}
end
end
- scope constraints: { id: Gitlab::PathRegex.git_reference_regex } do
+ scope constraints: {id: Gitlab::PathRegex.git_reference_regex} do
resources :network, only: [:show]
resources :graphs, only: [:show] do
@@ -51,48 +51,48 @@ scope format: false do
end
end
- get '/branches/:state', to: 'branches#index', as: :branches_filtered, constraints: { state: /active|stale|all/ }
+ get "/branches/:state", to: "branches#index", as: :branches_filtered, constraints: {state: /active|stale|all/}
resources :branches, only: [:index, :new, :create, :destroy]
- delete :merged_branches, controller: 'branches', action: :destroy_all_merged
+ delete :merged_branches, controller: "branches", action: :destroy_all_merged
resources :tags, only: [:index, :show, :new, :create, :destroy] do
- resource :release, controller: 'tags/releases', only: [:edit, :update]
+ resource :release, controller: "tags/releases", only: [:edit, :update]
end
resources :protected_branches, only: [:index, :show, :create, :update, :destroy]
resources :protected_tags, only: [:index, :show, :create, :update, :destroy]
end
- scope constraints: { id: /.+/ } do
+ scope constraints: {id: /.+/} do
scope controller: :blob do
- get '/new/*id', action: :new, as: :new_blob
- post '/create/*id', action: :create, as: :create_blob
- get '/edit/*id', action: :edit, as: :edit_blob
- put '/update/*id', action: :update, as: :update_blob
- post '/preview/*id', action: :preview, as: :preview_blob
+ get "/new/*id", action: :new, as: :new_blob
+ post "/create/*id", action: :create, as: :create_blob
+ get "/edit/*id", action: :edit, as: :edit_blob
+ put "/update/*id", action: :update, as: :update_blob
+ post "/preview/*id", action: :preview, as: :preview_blob
- scope path: '/blob/*id', as: :blob do
+ scope path: "/blob/*id", as: :blob do
get :diff
- get '/', action: :show
- delete '/', action: :destroy
- post '/', action: :create
- put '/', action: :update
+ get "/", action: :show
+ delete "/", action: :destroy
+ post "/", action: :create
+ put "/", action: :update
end
end
- get '/tree/*id', to: 'tree#show', as: :tree
- get '/raw/*id', to: 'raw#show', as: :raw
- get '/blame/*id', to: 'blame#show', as: :blame
+ get "/tree/*id", to: "tree#show", as: :tree
+ get "/raw/*id", to: "raw#show", as: :raw
+ get "/blame/*id", to: "blame#show", as: :blame
- get '/commits', to: 'commits#commits_root', as: :commits_root
- get '/commits/*id/signatures', to: 'commits#signatures', as: :signatures
- get '/commits/*id', to: 'commits#show', as: :commits
+ get "/commits", to: "commits#commits_root", as: :commits_root
+ get "/commits/*id/signatures", to: "commits#signatures", as: :signatures
+ get "/commits/*id", to: "commits#show", as: :commits
- post '/create_dir/*id', to: 'tree#create_dir', as: :create_dir
+ post "/create_dir/*id", to: "tree#create_dir", as: :create_dir
scope controller: :find_file do
- get '/find_file/*id', action: :show, as: :find_file
+ get "/find_file/*id", action: :show, as: :find_file
- get '/files/*id', action: :list, as: :files
+ get "/files/*id", action: :list, as: :files
end
end
end
diff --git a/config/routes/sidekiq.rb b/config/routes/sidekiq.rb
index 0fa23f2b3d0..76b77c2d0df 100644
--- a/config/routes/sidekiq.rb
+++ b/config/routes/sidekiq.rb
@@ -1,4 +1,4 @@
-constraint = lambda { |request| request.env['warden'].authenticate? && request.env['warden'].user.admin? }
+constraint = lambda { |request| request.env["warden"].authenticate? && request.env["warden"].user.admin? }
constraints constraint do
- mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
+ mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
end
diff --git a/config/routes/snippets.rb b/config/routes/snippets.rb
index 81bc890d86b..3139924f9b7 100644
--- a/config/routes/snippets.rb
+++ b/config/routes/snippets.rb
@@ -9,7 +9,7 @@ resources :snippets, concerns: :awardable do
end
scope module: :snippets do
- resources :notes, only: [:index, :create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ } do
+ resources :notes, only: [:index, :create, :destroy, :update], concerns: :awardable, constraints: {id: /\d+/} do
member do
delete :delete_attachment
end
@@ -17,5 +17,5 @@ resources :snippets, concerns: :awardable do
end
end
-get '/s/:username', to: redirect('u/%{username}/snippets'),
- constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
+get "/s/:username", to: redirect("u/%{username}/snippets"),
+ constraints: {username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/}
diff --git a/config/routes/uploads.rb b/config/routes/uploads.rb
index b594f55f8a0..cdbe462d47e 100644
--- a/config/routes/uploads.rb
+++ b/config/routes/uploads.rb
@@ -1,38 +1,38 @@
scope path: :uploads do
# Note attachments and User/Group/Project avatars
get "-/system/:model/:mounted_as/:id/:filename",
- to: "uploads#show",
- constraints: { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: %r{[^/]+} }
+ to: "uploads#show",
+ constraints: {model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: %r{[^/]+}}
# show uploads for models, snippets (notes) available for now
- get '-/system/:model/:id/:secret/:filename',
- to: 'uploads#show',
- constraints: { model: /personal_snippet/, id: /\d+/, filename: %r{[^/]+} }
+ get "-/system/:model/:id/:secret/:filename",
+ to: "uploads#show",
+ constraints: {model: /personal_snippet/, id: /\d+/, filename: %r{[^/]+}}
# show temporary uploads
- get '-/system/temp/:secret/:filename',
- to: 'uploads#show',
- constraints: { filename: %r{[^/]+} }
+ get "-/system/temp/:secret/:filename",
+ to: "uploads#show",
+ constraints: {filename: %r{[^/]+}}
# Appearance
get "-/system/:model/:mounted_as/:id/:filename",
- to: "uploads#show",
- constraints: { model: /appearance/, mounted_as: /logo|header_logo|favicon/, filename: /.+/ },
- as: 'appearance_upload'
+ to: "uploads#show",
+ constraints: {model: /appearance/, mounted_as: /logo|header_logo|favicon/, filename: /.+/},
+ as: "appearance_upload"
# Project markdown uploads
get ":namespace_id/:project_id/:secret/:filename",
- to: "projects/uploads#show",
- constraints: { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: %r{[^/]+} }
+ to: "projects/uploads#show",
+ constraints: {namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: %r{[^/]+}}
# create uploads for models, snippets (notes) available for now
- post ':model',
- to: 'uploads#create',
- constraints: { model: /personal_snippet/, id: /\d+/ },
- as: 'upload'
+ post ":model",
+ to: "uploads#create",
+ constraints: {model: /personal_snippet/, id: /\d+/},
+ as: "upload"
end
# Redirect old note attachments path to new uploads path.
get "files/note/:id/:filename",
- to: redirect("uploads/note/attachment/%{id}/%{filename}"),
- constraints: { filename: %r{[^/]+} }
+ to: redirect("uploads/note/attachment/%{id}/%{filename}"),
+ constraints: {filename: %r{[^/]+}}
diff --git a/config/routes/user.rb b/config/routes/user.rb
index e0ae264e2c0..e1eeec6f766 100644
--- a/config/routes/user.rb
+++ b/config/routes/user.rb
@@ -1,6 +1,6 @@
# Allows individual providers to be directed to a chosen controller
# Call from inside devise_scope
-def override_omniauth(provider, controller, path_prefix = '/users/auth')
+def override_omniauth(provider, controller, path_prefix = "/users/auth")
match "#{path_prefix}/#{provider}/callback",
to: "#{controller}##{provider}",
as: "#{provider}_omniauth_callback",
@@ -11,31 +11,31 @@ end
if Gitlab::Auth::LDAP::Config.enabled?
devise_scope :user do
Gitlab::Auth::LDAP::Config.available_servers.each do |server|
- override_omniauth(server['provider_name'], 'ldap/omniauth_callbacks')
+ override_omniauth(server["provider_name"], "ldap/omniauth_callbacks")
end
end
end
-devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
- registrations: :registrations,
- passwords: :passwords,
- sessions: :sessions,
- confirmations: :confirmations }
+devise_for :users, controllers: {omniauth_callbacks: :omniauth_callbacks,
+ registrations: :registrations,
+ passwords: :passwords,
+ sessions: :sessions,
+ confirmations: :confirmations,}
devise_scope :user do
- get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
- get '/users/almost_there' => 'confirmations#almost_there'
+ get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", :as => :omniauth_error
+ get "/users/almost_there" => "confirmations#almost_there"
end
-scope '-/users', module: :users do
+scope "-/users", module: :users do
resources :terms, only: [:index] do
post :accept, on: :member
post :decline, on: :member
end
end
-scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
- scope(path: 'users/:username',
+scope(constraints: {username: Gitlab::PathRegex.root_namespace_route_regex}) do
+ scope(path: "users/:username",
as: :user,
controller: :users) do
get :calendar
@@ -46,27 +46,27 @@ scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) d
get :snippets
get :exists
get :activity
- get '/', to: redirect('%{username}'), as: nil
+ get "/", to: redirect("%{username}"), as: nil
end
# Compatibility with old routing
# TODO (dzaporozhets): remove in 10.0
- get '/u/:username', to: redirect('%{username}')
+ get "/u/:username", to: redirect("%{username}")
# TODO (dzaporozhets): remove in 9.0
- get '/u/:username/groups', to: redirect('users/%{username}/groups')
- get '/u/:username/projects', to: redirect('users/%{username}/projects')
- get '/u/:username/snippets', to: redirect('users/%{username}/snippets')
- get '/u/:username/contributed', to: redirect('users/%{username}/contributed')
+ get "/u/:username/groups", to: redirect("users/%{username}/groups")
+ get "/u/:username/projects", to: redirect("users/%{username}/projects")
+ get "/u/:username/snippets", to: redirect("users/%{username}/snippets")
+ get "/u/:username/contributed", to: redirect("users/%{username}/contributed")
end
constraints(::Constraints::UserUrlConstrainer.new) do
# Get all keys of user
- get ':username.keys' => 'profiles/keys#get_keys', constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }
+ get ":username.keys" => "profiles/keys#get_keys", :constraints => {username: Gitlab::PathRegex.root_namespace_route_regex}
- scope(path: ':username',
+ scope(path: ":username",
as: :user,
- constraints: { username: Gitlab::PathRegex.root_namespace_route_regex },
+ constraints: {username: Gitlab::PathRegex.root_namespace_route_regex},
controller: :users) do
- get '/', action: :show
+ get "/", action: :show
end
end
diff --git a/config/routes/wiki.rb b/config/routes/wiki.rb
index 2ca52e55fca..888dd67e017 100644
--- a/config/routes/wiki.rb
+++ b/config/routes/wiki.rb
@@ -1,17 +1,17 @@
scope(controller: :wikis) do
- scope(path: 'wikis', as: :wikis) do
+ scope(path: "wikis", as: :wikis) do
get :git_access
get :pages
- get '/', to: redirect('%{namespace_id}/%{project_id}/wikis/home')
- post '/', to: 'wikis#create'
+ get "/", to: redirect("%{namespace_id}/%{project_id}/wikis/home")
+ post "/", to: "wikis#create"
end
- scope(path: 'wikis/*id', as: :wiki, format: false) do
+ scope(path: "wikis/*id", as: :wiki, format: false) do
get :edit
get :history
post :preview_markdown
- get '/', action: :show
- put '/', action: :update
- delete '/', action: :destroy
+ get "/", action: :show
+ put "/", action: :update
+ delete "/", action: :destroy
end
end
diff --git a/config/settings.rb b/config/settings.rb
index 1b94df785a7..591857daac7 100644
--- a/config/settings.rb
+++ b/config/settings.rb
@@ -1,8 +1,8 @@
-require 'settingslogic'
+require "settingslogic"
class Settings < Settingslogic
- source ENV.fetch('GITLAB_CONFIG') { Pathname.new(File.expand_path('..', __dir__)).join('config/gitlab.yml') }
- namespace ENV.fetch('GITLAB_ENV') { Rails.env }
+ source ENV.fetch("GITLAB_CONFIG") { Pathname.new(File.expand_path("..", __dir__)).join("config/gitlab.yml") }
+ namespace ENV.fetch("GITLAB_ENV") { Rails.env }
class << self
def gitlab_on_standard_port?
@@ -10,7 +10,7 @@ class Settings < Settingslogic
end
def host_without_www(url)
- host(url).sub('www.', '')
+ host(url).sub("www.", "")
end
def build_gitlab_ci_url
@@ -26,12 +26,12 @@ class Settings < Settingslogic
"://",
gitlab.host,
custom_port,
- gitlab.relative_url_root
- ].join('')
+ gitlab.relative_url_root,
+ ].join("")
end
def build_pages_url
- base_url(pages).join('')
+ base_url(pages).join("")
end
def build_gitlab_shell_ssh_path_prefix
@@ -40,7 +40,7 @@ class Settings < Settingslogic
if gitlab_shell.ssh_port != 22
"ssh://#{user_host}:#{gitlab_shell.ssh_port}/"
else
- if gitlab_shell.ssh_host.include? ':'
+ if gitlab_shell.ssh_host.include? ":"
"[#{user_host}]:"
else
"#{user_host}:"
@@ -49,11 +49,11 @@ class Settings < Settingslogic
end
def build_base_gitlab_url
- base_url(gitlab).join('')
+ base_url(gitlab).join("")
end
def build_gitlab_url
- (base_url(gitlab) + [gitlab.relative_url_root]).join('')
+ (base_url(gitlab) + [gitlab.relative_url_root]).join("")
end
# check that values in `current` (string or integer) is a contant in `modul`.
@@ -75,7 +75,11 @@ class Settings < Settingslogic
constant = modul.constants.find { |name| modul.const_get(name) == current }
value = constant.nil? ? default : modul.const_get(constant)
if current.is_a? String
- value = modul.const_get(current.upcase) rescue default
+ value = begin
+ modul.const_get(current.upcase)
+ rescue
+ default
+ end
end
value
@@ -120,7 +124,7 @@ class Settings < Settingslogic
config.protocol,
"://",
config.host,
- custom_port
+ custom_port,
]
end
@@ -131,7 +135,7 @@ class Settings < Settingslogic
# Extract the host part of the given +url+.
def host(url)
url = url.downcase
- url = "http://#{url}" unless url.start_with?('http')
+ url = "http://#{url}" unless url.start_with?("http")
# Get rid of the path so that we don't even have to encode it
url_without_path = url.sub(%r{(https?://[^/]+)/?.*}, '\1')
diff --git a/config/spring.rb b/config/spring.rb
index c9119b40c08..9fa7863f99d 100644
--- a/config/spring.rb
+++ b/config/spring.rb
@@ -1,6 +1,6 @@
-%w(
+%w[
.ruby-version
.rbenv-vars
tmp/restart.txt
tmp/caching-dev.txt
-).each { |path| Spring.watch(path) }
+].each { |path| Spring.watch(path) }
diff --git a/danger/changelog/Dangerfile b/danger/changelog/Dangerfile
index 63b2f6f5c5c..2cedca46769 100644
--- a/danger/changelog/Dangerfile
+++ b/danger/changelog/Dangerfile
@@ -1,19 +1,19 @@
# rubocop:disable Style/SignalException
-require 'yaml'
+require "yaml"
NO_CHANGELOG_LABELS = %w[backstage ci-build Documentation meta QA test].freeze
SEE_DOC = "See [the documentation](https://docs.gitlab.com/ce/development/changelog.html).".freeze
CREATE_CHANGELOG_MESSAGE = <<~MSG.freeze
-You can create one with:
+ You can create one with:
-```
-bin/changelog -m %<mr_iid>s "%<mr_title>s"
-```
+ ```
+ bin/changelog -m %<mr_iid>s "%<mr_title>s"
+ ```
-If your merge request doesn't warrant a CHANGELOG entry,
-consider adding any of the %<labels>s labels.
-#{SEE_DOC}
+ If your merge request doesn't warrant a CHANGELOG entry,
+ consider adding any of the %<labels>s labels.
+ #{SEE_DOC}
MSG
def ee_changelog?(changelog_path)
@@ -38,18 +38,18 @@ def check_changelog(path)
rescue Psych::SyntaxError, Psych::DisallowedClass, Psych::BadAlias
# YAML could not be parsed, fail the build.
fail "#{gitlab.html_link(path)} isn't valid YAML! #{SEE_DOC}"
-rescue StandardError => e
+rescue => e
warn "There was a problem trying to check the Changelog. Exception: #{e.name} - #{e.message}"
end
def presented_no_changelog_labels
- NO_CHANGELOG_LABELS.map { |label| "~#{label}" }.join(', ')
+ NO_CHANGELOG_LABELS.map { |label| "~#{label}" }.join(", ")
end
changelog_needed = (gitlab.mr_labels & NO_CHANGELOG_LABELS).empty?
changelog_found = git.added_files.find { |path| path =~ %r{\A(ee/)?(changelogs/unreleased)(-ee)?/} }
-mr_title = gitlab.mr_json["title"].gsub(/^WIP: */, '')
+mr_title = gitlab.mr_json["title"].gsub(/^WIP: */, "")
if git.modified_files.include?("CHANGELOG.md")
fail "**CHANGELOG.md was edited.** Please remove the additions and create a CHANGELOG entry.\n\n" +
diff --git a/danger/commit_messages/Dangerfile b/danger/commit_messages/Dangerfile
index 9be1ce2ff86..16cafd59645 100644
--- a/danger/commit_messages/Dangerfile
+++ b/danger/commit_messages/Dangerfile
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'json'
+require "json"
URL_LIMIT_SUBJECT = "https://chris.beams.io/posts/git-commit/#limit-50"
URL_GIT_COMMIT = "https://chris.beams.io/posts/git-commit/"
@@ -14,8 +14,8 @@ URL_GIT_COMMIT = "https://chris.beams.io/posts/git-commit/"
# very helpful, and it doesn't offer the means of ignoring merge commits.
class EmojiChecker
- DIGESTS = File.expand_path('../../fixtures/emojis/digests.json', __dir__)
- ALIASES = File.expand_path('../../fixtures/emojis/aliases.json', __dir__)
+ DIGESTS = File.expand_path("../../fixtures/emojis/digests.json", __dir__)
+ ALIASES = File.expand_path("../../fixtures/emojis/aliases.json", __dir__)
# A regex that indicates a piece of text _might_ include an Emoji. The regex
# alone is not enough, as we'd match `:foo:bar:baz`. Instead, we use this
@@ -56,7 +56,7 @@ def subject_starts_with_capital?(subject)
end
def ce_upstream?
- gitlab.mr_labels.any? { |label| label == 'CE upstream' }
+ gitlab.mr_labels.any? { |label| label == "CE upstream" }
end
def too_many_changed_lines?(commit)
@@ -83,7 +83,7 @@ end
def lint_commit(commit)
# For now we'll ignore merge commits, as getting rid of those is a problem
# separate from enforcing good commit messages.
- return false if commit.message.start_with?('Merge branch')
+ return false if commit.message.start_with?("Merge branch")
# We ignore revert commits as they are well structured by Git already
return false if commit.message.start_with?('Revert "')
@@ -94,7 +94,7 @@ def lint_commit(commit)
if subject.split.length < 3
fail_commit(
commit,
- 'The commit subject must contain at least three words'
+ "The commit subject must contain at least three words"
)
failures = true
@@ -103,7 +103,7 @@ def lint_commit(commit)
if subject.length > 72
fail_commit(
commit,
- 'The commit subject may not be longer than 72 characters'
+ "The commit subject may not be longer than 72 characters"
)
failures = true
@@ -115,19 +115,19 @@ def lint_commit(commit)
end
unless subject_starts_with_capital?(subject)
- fail_commit(commit, 'The commit subject must start with a capital letter')
+ fail_commit(commit, "The commit subject must start with a capital letter")
failures = true
end
- if subject.end_with?('.')
- fail_commit(commit, 'The commit subject must not end with a period')
+ if subject.end_with?(".")
+ fail_commit(commit, "The commit subject must not end with a period")
failures = true
end
if separator && !separator.empty?
fail_commit(
commit,
- 'The commit subject and body must be separated by a blank line'
+ "The commit subject and body must be separated by a blank line"
)
failures = true
@@ -138,7 +138,7 @@ def lint_commit(commit)
next if line.length <= 72
- url_size = line.scan(%r((https?://\S+))).sum { |(url)| url.length }
+ url_size = line.scan(%r{(https?://\S+)}).sum { |(url)| url.length }
# If the line includes a URL, we'll allow it to exceed 72 characters, but
# only if the line _without_ the URL does not exceed this limit.
@@ -146,7 +146,7 @@ def lint_commit(commit)
fail_commit(
commit,
- 'The commit body should not contain more than 72 characters per line'
+ "The commit body should not contain more than 72 characters per line"
)
failures = true
@@ -155,8 +155,8 @@ def lint_commit(commit)
if !details && too_many_changed_lines?(commit)
fail_commit(
commit,
- 'Commits that change 30 or more lines across at least three files ' \
- 'must describe these changes in the commit body'
+ "Commits that change 30 or more lines across at least three files " \
+ "must describe these changes in the commit body"
)
failures = true
@@ -165,9 +165,9 @@ def lint_commit(commit)
if emoji_checker.includes_emoji?(commit.message)
fail_commit(
commit,
- 'Avoid the use of Markdown Emoji such as `:+1:`. ' \
- 'These add no value to the commit message, ' \
- 'and are displayed as plain text outside of GitLab'
+ "Avoid the use of Markdown Emoji such as `:+1:`. " \
+ "These add no value to the commit message, " \
+ "and are displayed as plain text outside of GitLab"
)
failures = true
@@ -176,20 +176,20 @@ def lint_commit(commit)
if commit.message.match?(unicode_emoji_regex)
fail_commit(
commit,
- 'Avoid the use of Unicode Emoji. ' \
- 'These add no value to the commit message, ' \
- 'and may not be displayed properly everywhere'
+ "Avoid the use of Unicode Emoji. " \
+ "These add no value to the commit message, " \
+ "and may not be displayed properly everywhere"
)
failures = true
end
- if commit.message.match?(%r(([\w\-\/]+)?(#|!|&|%)\d+\b))
+ if commit.message.match?(%r{([\w\-\/]+)?(#|!|&|%)\d+\b})
fail_commit(
commit,
- 'Use full URLs instead of short references ' \
- '(`gitlab-org/gitlab-ce#123` or `!123`), as short references are ' \
- 'displayed as plain text outside of GitLab'
+ "Use full URLs instead of short references " \
+ "(`gitlab-org/gitlab-ce#123` or `!123`), as short references are " \
+ "displayed as plain text outside of GitLab"
)
failures = true
@@ -199,9 +199,9 @@ def lint_commit(commit)
end
def lint_commits(commits)
- failed = commits.select do |commit|
+ failed = commits.select { |commit|
lint_commit(commit)
- end
+ }
if failed.any?
markdown(<<~MARKDOWN)
@@ -241,8 +241,8 @@ end
if git.commits.length > 10 && !ce_upstream?
warn(
- 'This merge request includes more than 10 commits. ' \
- 'Please rebase these commits into a smaller number of commits.'
+ "This merge request includes more than 10 commits. " \
+ "Please rebase these commits into a smaller number of commits."
)
else
lint_commits(git.commits)
diff --git a/danger/database/Dangerfile b/danger/database/Dangerfile
index 38ccbd94edb..1b0305146fe 100644
--- a/danger/database/Dangerfile
+++ b/danger/database/Dangerfile
@@ -2,36 +2,36 @@
# All the files/directories that should be reviewed by the DB team.
DB_FILES = [
- 'db/',
- 'app/models/project_authorization.rb',
- 'app/services/users/refresh_authorized_projects_service.rb',
- 'lib/gitlab/background_migration.rb',
- 'lib/gitlab/background_migration/',
- 'lib/gitlab/database.rb',
- 'lib/gitlab/database/',
- 'lib/gitlab/github_import.rb',
- 'lib/gitlab/github_import/',
- 'lib/gitlab/sql/',
- 'rubocop/cop/migration',
- 'ee/db/',
- 'ee/lib/gitlab/database/'
+ "db/",
+ "app/models/project_authorization.rb",
+ "app/services/users/refresh_authorized_projects_service.rb",
+ "lib/gitlab/background_migration.rb",
+ "lib/gitlab/background_migration/",
+ "lib/gitlab/database.rb",
+ "lib/gitlab/database/",
+ "lib/gitlab/github_import.rb",
+ "lib/gitlab/github_import/",
+ "lib/gitlab/sql/",
+ "rubocop/cop/migration",
+ "ee/db/",
+ "ee/lib/gitlab/database/",
].freeze
SCHEMA_NOT_UPDATED_MESSAGE = <<~MSG
-**New %<migrations>s added but %<schema>s wasn't updated.**
+ **New %<migrations>s added but %<schema>s wasn't updated.**
-Usually, when adding new %<migrations>s, %<schema>s should be
-updated too (unless the migration isn't changing the DB schema
-and isn't the most recent one).
+ Usually, when adding new %<migrations>s, %<schema>s should be
+ updated too (unless the migration isn't changing the DB schema
+ and isn't the most recent one).
MSG
def database_paths_requiring_review(files)
to_review = []
files.each do |file|
- review = DB_FILES.any? do |pattern|
+ review = DB_FILES.any? { |pattern|
file.start_with?(pattern)
- end
+ }
to_review << file if review
end
@@ -46,36 +46,36 @@ non_geo_migration_created = !git.added_files.grep(%r{\A(db/(post_)?migrate)/}).e
geo_migration_created = !git.added_files.grep(%r{\Aee/db/geo/(post_)?migrate/}).empty?
if non_geo_migration_created && !non_geo_db_schema_updated
- warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: 'migrations', schema: gitlab.html_link("db/schema.rb"))
+ warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: "migrations", schema: gitlab.html_link("db/schema.rb"))
end
if geo_migration_created && !geo_db_schema_updated
- warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: 'Geo migrations', schema: gitlab.html_link("ee/db/geo/schema.rb"))
+ warn format(SCHEMA_NOT_UPDATED_MESSAGE, migrations: "Geo migrations", schema: gitlab.html_link("ee/db/geo/schema.rb"))
end
db_paths_to_review = database_paths_requiring_review(helper.all_changed_files)
unless db_paths_to_review.empty?
- message 'This merge request adds or changes files that require a ' \
- 'review from the Database team.'
+ message "This merge request adds or changes files that require a " \
+ "review from the Database team."
markdown(<<~MARKDOWN.strip)
-## Database Review
+ ## Database Review
-The following files require a review from the Database team:
+ The following files require a review from the Database team:
-* #{db_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
+ * #{db_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
-To make sure these changes are reviewed, take the following steps:
+ To make sure these changes are reviewed, take the following steps:
-1. Edit your merge request, and add `gl-database` to the list of Group
- approvers.
-1. Mention `@gl-database` in a separate comment, and explain what needs to be
- reviewed by the team. Please don't mention the team until your changes are
- ready for review.
+ 1. Edit your merge request, and add `gl-database` to the list of Group
+ approvers.
+ 1. Mention `@gl-database` in a separate comment, and explain what needs to be
+ reviewed by the team. Please don't mention the team until your changes are
+ ready for review.
MARKDOWN
- unless gitlab.mr_labels.include?('database')
- warn 'This merge request is missing the ~database label.'
+ unless gitlab.mr_labels.include?("database")
+ warn "This merge request is missing the ~database label."
end
end
diff --git a/danger/documentation/Dangerfile b/danger/documentation/Dangerfile
index 0cf478b4f89..7c62ce09972 100644
--- a/danger/documentation/Dangerfile
+++ b/danger/documentation/Dangerfile
@@ -3,37 +3,37 @@
docs_paths_to_review = helper.changes_by_category[:docs]
unless docs_paths_to_review.empty?
- message 'This merge request adds or changes files that require a review ' \
- 'from the Technical Writing team whether before or after merging.'
+ message "This merge request adds or changes files that require a review " \
+ "from the Technical Writing team whether before or after merging."
markdown(<<~MARKDOWN)
-## Documentation review
+ ## Documentation review
-The following files will require a review from the [Technical Writing](https://about.gitlab.com/handbook/product/technical-writing/) team:
+ The following files will require a review from the [Technical Writing](https://about.gitlab.com/handbook/product/technical-writing/) team:
-* #{docs_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
+ * #{docs_paths_to_review.map { |path| "`#{path}`" }.join("\n* ")}
-Per the [documentation workflows](https://docs.gitlab.com/ee/development/documentation/workflow.html), the review may occur prior to merging this MR **or** after a maintainer has agreed to review and merge this MR without a tech writer review. (Meanwhile, you are welcome to involve a technical writer at any time if you have questions about writing or updating the documentation. GitLabbers are also welcome to use the [#docs](https://gitlab.slack.com/archives/C16HYA2P5) channel on Slack.)
+ Per the [documentation workflows](https://docs.gitlab.com/ee/development/documentation/workflow.html), the review may occur prior to merging this MR **or** after a maintainer has agreed to review and merge this MR without a tech writer review. (Meanwhile, you are welcome to involve a technical writer at any time if you have questions about writing or updating the documentation. GitLabbers are also welcome to use the [#docs](https://gitlab.slack.com/archives/C16HYA2P5) channel on Slack.)
-The technical writer who, by default, will review this content or collaborate as needed is dependent on the [DevOps stage](https://about.gitlab.com/handbook/product/categories/#devops-stages) to which the content applies:
+ The technical writer who, by default, will review this content or collaborate as needed is dependent on the [DevOps stage](https://about.gitlab.com/handbook/product/categories/#devops-stages) to which the content applies:
-| Tech writer | Stage(s) |
-| ------------ | ------------------------------------------------------------ |
-| `@marcia` | ~Create ~Release + ~"development guidelines" |
-| `@axil` | ~Distribution ~Gitaly ~Gitter ~Monitor ~Package ~Secure |
-| `@eread` | ~Manage ~Configure ~Geo ~Verify |
-| `@mikelewis` | ~Plan |
+ | Tech writer | Stage(s) |
+ | ------------ | ------------------------------------------------------------ |
+ | `@marcia` | ~Create ~Release + ~"development guidelines" |
+ | `@axil` | ~Distribution ~Gitaly ~Gitter ~Monitor ~Package ~Secure |
+ | `@eread` | ~Manage ~Configure ~Geo ~Verify |
+ | `@mikelewis` | ~Plan |
-**To request a review prior to merging**
+ **To request a review prior to merging**
-- Assign the MR to the applicable technical writer, above. If you are not sure which category the change falls within, or the change is not part of one of these categories, mention one of the usernames above.
+ - Assign the MR to the applicable technical writer, above. If you are not sure which category the change falls within, or the change is not part of one of these categories, mention one of the usernames above.
-**To request a review to commence after merging**
+ **To request a review to commence after merging**
-- Create an issue for a doc review [using the Doc Review template](https://gitlab.com/gitlab-org/gitlab-ce/issues/new?issuable_template=Doc%20Review) and assign it to the applicable technicial writer from the table.
+ - Create an issue for a doc review [using the Doc Review template](https://gitlab.com/gitlab-org/gitlab-ce/issues/new?issuable_template=Doc%20Review) and assign it to the applicable technicial writer from the table.
MARKDOWN
- unless gitlab.mr_labels.include?('Documentation')
- warn 'This merge request is missing the ~Documentation label.'
+ unless gitlab.mr_labels.include?("Documentation")
+ warn "This merge request is missing the ~Documentation label."
end
end
diff --git a/danger/duplicate_yarn_dependencies/Dangerfile b/danger/duplicate_yarn_dependencies/Dangerfile
index 25f81ec86a4..ccd3148cc0a 100644
--- a/danger/duplicate_yarn_dependencies/Dangerfile
+++ b/danger/duplicate_yarn_dependencies/Dangerfile
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-return unless helper.all_changed_files.include? 'yarn.lock'
+return unless helper.all_changed_files.include? "yarn.lock"
duplicate = `node_modules/.bin/yarn-deduplicate --list --strategy fewer yarn.lock`
- .split(/$/)
- .map(&:strip)
- .reject(&:empty?)
+ .split(/$/)
+ .map(&:strip)
+ .reject(&:empty?)
return if duplicate.empty?
-warn 'This merge request has introduced duplicated yarn dependencies.'
+warn "This merge request has introduced duplicated yarn dependencies."
markdown(<<~MARKDOWN)
## Duplicate yarn dependencies
diff --git a/danger/eslint/Dangerfile b/danger/eslint/Dangerfile
index 4916cacfd7e..9fca240d180 100644
--- a/danger/eslint/Dangerfile
+++ b/danger/eslint/Dangerfile
@@ -2,8 +2,8 @@
def get_eslint_files(files)
files.select do |file|
- file.end_with?('.js', '.vue') &&
- File.read(file).include?('/* eslint-disable')
+ file.end_with?(".js", ".vue") &&
+ File.read(file).include?("/* eslint-disable")
end
end
@@ -11,7 +11,7 @@ eslint_candidates = get_eslint_files(helper.all_changed_files)
return if eslint_candidates.empty?
-warn 'This merge request changed files with disabled eslint rules. Please consider fixing them.'
+warn "This merge request changed files with disabled eslint rules. Please consider fixing them."
markdown(<<~MARKDOWN)
## Disabled eslint rules
diff --git a/danger/frozen_string/Dangerfile b/danger/frozen_string/Dangerfile
index b9687ef6b83..517bd6d5e85 100644
--- a/danger/frozen_string/Dangerfile
+++ b/danger/frozen_string/Dangerfile
@@ -13,8 +13,8 @@ end
files_to_fix = get_files_with_no_magic_comment(git.added_files)
if files_to_fix.any?
- warn 'This merge request adds files that do not enforce frozen string literal. ' \
- 'See https://gitlab.com/gitlab-org/gitlab-ce/issues/47424 for more information.'
+ warn "This merge request adds files that do not enforce frozen string literal. " \
+ "See https://gitlab.com/gitlab-org/gitlab-ce/issues/47424 for more information."
markdown(<<~MARKDOWN)
## Enable Frozen String Literal
diff --git a/danger/gemfile/Dangerfile b/danger/gemfile/Dangerfile
index 4e91abc371a..580bbc679e8 100644
--- a/danger/gemfile/Dangerfile
+++ b/danger/gemfile/Dangerfile
@@ -1,19 +1,19 @@
GEMFILE_LOCK_NOT_UPDATED_MESSAGE = <<~MSG.freeze
-**%<gemfile>s was updated but %<gemfile_lock>s wasn't updated.**
+ **%<gemfile>s was updated but %<gemfile_lock>s wasn't updated.**
-Usually, when %<gemfile>s is updated, you should run
-```
-bundle install && \
- bundle install
-```
+ Usually, when %<gemfile>s is updated, you should run
+ ```
+ bundle install && \
+ bundle install
+ ```
-or
+ or
-```
-bundle update <the-added-or-updated-gem>
-```
+ ```
+ bundle update <the-added-or-updated-gem>
+ ```
-and commit the %<gemfile_lock>s changes.
+ and commit the %<gemfile_lock>s changes.
MSG
gemfile_modified = git.modified_files.include?("Gemfile")
diff --git a/danger/metadata/Dangerfile b/danger/metadata/Dangerfile
index 1adca152736..840e6e97118 100644
--- a/danger/metadata/Dangerfile
+++ b/danger/metadata/Dangerfile
@@ -18,15 +18,15 @@ unless has_milestone
warn "This merge request does not refer to an existing milestone.", sticky: false
end
-has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?('Pick into') }
+has_pick_into_stable_label = gitlab.mr_labels.find { |label| label.start_with?("Pick into") }
if gitlab.branch_for_base != "master" && !has_pick_into_stable_label
warn "Most of the time, merge requests should target `master`. Otherwise, please set the relevant `Pick into X.Y` label."
end
-if gitlab.mr_json['title'].length > 72
- warn 'The title of this merge request is longer than 72 characters and ' \
- 'would violate our commit message rules when using the Squash on Merge ' \
- 'feature. Please consider adjusting the title, or rebase the ' \
+if gitlab.mr_json["title"].length > 72
+ warn "The title of this merge request is longer than 72 characters and " \
+ "would violate our commit message rules when using the Squash on Merge " \
+ "feature. Please consider adjusting the title, or rebase the " \
"commits manually and don't use Squash on Merge."
end
diff --git a/danger/plugins/helper.rb b/danger/plugins/helper.rb
index 581c0720083..5a82e304b28 100644
--- a/danger/plugins/helper.rb
+++ b/danger/plugins/helper.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'net/http'
-require 'yaml'
+require "net/http"
+require "yaml"
-require_relative '../../lib/gitlab/danger/helper'
+require_relative "../../lib/gitlab/danger/helper"
module Danger
# Common helper functions for our danger scripts. See Gitlab::Danger::Helper
diff --git a/danger/prettier/Dangerfile b/danger/prettier/Dangerfile
index 37c4b78a213..e411e558328 100644
--- a/danger/prettier/Dangerfile
+++ b/danger/prettier/Dangerfile
@@ -2,7 +2,7 @@
def get_prettier_files(files)
files.select do |file|
- file.end_with?('.js', '.scss', '.vue')
+ file.end_with?(".js", ".scss", ".vue")
end
end
@@ -11,13 +11,13 @@ prettier_candidates = get_prettier_files(helper.all_changed_files)
return if prettier_candidates.empty?
unpretty = `node_modules/prettier/bin-prettier.js --list-different #{prettier_candidates.join(" ")}`
- .split(/$/)
- .map(&:strip)
- .reject(&:empty?)
+ .split(/$/)
+ .map(&:strip)
+ .reject(&:empty?)
return if unpretty.empty?
-warn 'This merge request changed frontend files without pretty printing them.'
+warn "This merge request changed frontend files without pretty printing them."
markdown(<<~MARKDOWN)
## Pretty print Frontend files
diff --git a/danger/roulette/Dangerfile b/danger/roulette/Dangerfile
index 6cf54d0f854..79bc40c0fd6 100644
--- a/danger/roulette/Dangerfile
+++ b/danger/roulette/Dangerfile
@@ -1,32 +1,32 @@
# frozen_string_literal: true
-MESSAGE = <<MARKDOWN
-## Reviewer roulette
+MESSAGE = <<~MARKDOWN
+ ## Reviewer roulette
-Changes that require review have been detected! A merge request is normally
-reviewed by both a reviewer and a maintainer in its primary category (e.g.
-~frontend or ~backend), and by a maintainer in all other categories.
+ Changes that require review have been detected! A merge request is normally
+ reviewed by both a reviewer and a maintainer in its primary category (e.g.
+ ~frontend or ~backend), and by a maintainer in all other categories.
MARKDOWN
-CATEGORY_TABLE_HEADER = <<MARKDOWN
+CATEGORY_TABLE_HEADER = <<~MARKDOWN
-To spread load more evenly across eligible reviewers, Danger has randomly picked
-a candidate for each review slot. Feel free to override this selection if you
-think someone else would be better-suited, or the chosen person is unavailable.
+ To spread load more evenly across eligible reviewers, Danger has randomly picked
+ a candidate for each review slot. Feel free to override this selection if you
+ think someone else would be better-suited, or the chosen person is unavailable.
-Once you've decided who will review this merge request, mention them as you
-normally would! Danger does not (yet?) automatically notify them for you.
+ Once you've decided who will review this merge request, mention them as you
+ normally would! Danger does not (yet?) automatically notify them for you.
-| Category | Reviewer | Maintainer |
-| -------- | -------- | ---------- |
+ | Category | Reviewer | Maintainer |
+ | -------- | -------- | ---------- |
MARKDOWN
-UNKNOWN_FILES_MESSAGE = <<MARKDOWN
+UNKNOWN_FILES_MESSAGE = <<~MARKDOWN
-These files couldn't be categorised, so Danger was unable to suggest a reviewer.
-Please consider creating a merge request to
-[add support](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/danger/helper.rb)
-for them.
+ These files couldn't be categorised, so Danger was unable to suggest a reviewer.
+ Please consider creating a merge request to
+ [add support](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/lib/gitlab/danger/helper.rb)
+ for them.
MARKDOWN
def spin(team, project, category)
diff --git a/danger/specs/Dangerfile b/danger/specs/Dangerfile
index a526bb8adaa..a45aaf19f80 100644
--- a/danger/specs/Dangerfile
+++ b/danger/specs/Dangerfile
@@ -1,14 +1,14 @@
# frozen_string_literal: true
NO_SPECS_LABELS = %w[backstage Documentation QA].freeze
-NO_NEW_SPEC_MESSAGE = <<~MSG.freeze
-You've made some app changes, but didn't add any tests.
-That's OK as long as you're refactoring existing code,
-but please consider adding any of the %<labels>s labels.
+NO_NEW_SPEC_MESSAGE = <<~MSG
+ You've made some app changes, but didn't add any tests.
+ That's OK as long as you're refactoring existing code,
+ but please consider adding any of the %<labels>s labels.
MSG
def presented_no_changelog_labels
- NO_SPECS_LABELS.map { |label| "~#{label}" }.join(', ')
+ NO_SPECS_LABELS.map { |label| "~#{label}" }.join(", ")
end
has_app_changes = !helper.all_changed_files.grep(%r{\A(ee/)?(app|lib|db/(geo/)?(post_)?migrate)/}).empty?
diff --git a/db/fixtures/development/01_admin.rb b/db/fixtures/development/01_admin.rb
index 1e260236dc5..89c3623bee0 100644
--- a/db/fixtures/development/01_admin.rb
+++ b/db/fixtures/development/01_admin.rb
@@ -1,14 +1,14 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
User.create!(
- name: 'Administrator',
- email: 'admin@example.com',
- username: 'root',
- password: '5iveL!fe',
+ name: "Administrator",
+ email: "admin@example.com",
+ username: "root",
+ password: "5iveL!fe",
admin: true,
confirmed_at: DateTime.now
)
- print '.'
+ print "."
end
diff --git a/db/fixtures/development/03_settings.rb b/db/fixtures/development/03_settings.rb
index 3a4a5d436bf..4c0fa0573bd 100644
--- a/db/fixtures/development/03_settings.rb
+++ b/db/fixtures/development/03_settings.rb
@@ -4,5 +4,5 @@
Gitlab::Seeder.quiet do
ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache
ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true)
- print '.'
+ print "."
end
diff --git a/db/fixtures/development/04_project.rb b/db/fixtures/development/04_project.rb
index 9a5f7cf8175..3efcc7881be 100644
--- a/db/fixtures/development/04_project.rb
+++ b/db/fixtures/development/04_project.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
# rubocop:disable Rails/Output
@@ -50,7 +50,7 @@ Sidekiq::Testing.inline! do
]
def create_project(url, force_latest_storage: false)
- group_path, project_path = url.split('/')[-2..-1]
+ group_path, project_path = url.split("/")[-2..-1]
group = Group.find_by(path: group_path)
@@ -73,7 +73,7 @@ Sidekiq::Testing.inline! do
name: project_path.titleize,
description: FFaker::Lorem.sentence,
visibility_level: Gitlab::VisibilityLevel.values.sample,
- skip_disk_validation: true
+ skip_disk_validation: true,
}
if force_latest_storage
@@ -94,27 +94,27 @@ Sidekiq::Testing.inline! do
end
if project.valid? && project.valid_repo?
- print '.'
+ print "."
else
puts project.errors.full_messages
- print 'F'
+ print "F"
end
end
# You can specify how many projects you need during seed execution
- size = ENV['SIZE'].present? ? ENV['SIZE'].to_i : 8
+ size = ENV["SIZE"].present? ? ENV["SIZE"].to_i : 8
project_urls.first(size).each_with_index do |url, i|
create_project(url, force_latest_storage: i.even?)
end
- if ENV['LARGE_PROJECTS'].present?
+ if ENV["LARGE_PROJECTS"].present?
large_project_urls.each(&method(:create_project))
- if ENV['FORK'].present?
+ if ENV["FORK"].present?
puts "\nGenerating forks"
- project_name = ENV['FORK'] == 'true' ? 'torvalds/linux' : ENV['FORK']
+ project_name = ENV["FORK"] == "true" ? "torvalds/linux" : ENV["FORK"]
project = Project.find_by_full_path(project_name)
@@ -122,12 +122,12 @@ Sidekiq::Testing.inline! do
new_project = Projects::ForkService.new(project, user).execute
if new_project.valid? && (new_project.valid_repo? || new_project.import_state.scheduled?)
- print '.'
+ print "."
else
new_project.errors.full_messages.each do |error|
puts "#{new_project.full_path}: #{error}"
end
- print 'F'
+ print "F"
end
end
end
diff --git a/db/fixtures/development/05_users.rb b/db/fixtures/development/05_users.rb
index 101ff3a1209..b1623f3e3da 100644
--- a/db/fixtures/development/05_users.rb
+++ b/db/fixtures/development/05_users.rb
@@ -1,34 +1,30 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
20.times do |i|
- begin
- User.create!(
- username: FFaker::Internet.user_name,
- name: FFaker::Name.name,
- email: FFaker::Internet.email,
- confirmed_at: DateTime.now,
- password: '12345678'
- )
+ User.create!(
+ username: FFaker::Internet.user_name,
+ name: FFaker::Name.name,
+ email: FFaker::Internet.email,
+ confirmed_at: DateTime.now,
+ password: "12345678"
+ )
- print '.'
- rescue ActiveRecord::RecordInvalid
- print 'F'
- end
+ print "."
+ rescue ActiveRecord::RecordInvalid
+ print "F"
end
5.times do |i|
- begin
- User.create!(
- username: "user#{i}",
- name: "User #{i}",
- email: "user#{i}@example.com",
- confirmed_at: DateTime.now,
- password: '12345678'
- )
- print '.'
- rescue ActiveRecord::RecordInvalid
- print 'F'
- end
+ User.create!(
+ username: "user#{i}",
+ name: "User #{i}",
+ email: "user#{i}@example.com",
+ confirmed_at: DateTime.now,
+ password: "12345678"
+ )
+ print "."
+ rescue ActiveRecord::RecordInvalid
+ print "F"
end
end
diff --git a/db/fixtures/development/06_teams.rb b/db/fixtures/development/06_teams.rb
index b218f4e71fd..e1867918dff 100644
--- a/db/fixtures/development/06_teams.rb
+++ b/db/fixtures/development/06_teams.rb
@@ -1,13 +1,13 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
Group.all.each do |group|
User.all.sample(4).each do |user|
if group.add_user(user, Gitlab::Access.values.sample).persisted?
- print '.'
+ print "."
else
- print 'F'
+ print "F"
end
end
end
@@ -15,9 +15,9 @@ Sidekiq::Testing.inline! do
Project.all.each do |project|
User.all.sample(4).each do |user|
if project.add_role(user, Gitlab::Access.sym_options.keys.sample)
- print '.'
+ print "."
else
- print 'F'
+ print "F"
end
end
end
diff --git a/db/fixtures/development/07_milestones.rb b/db/fixtures/development/07_milestones.rb
index 271bfbc97e0..cc5385843fe 100644
--- a/db/fixtures/development/07_milestones.rb
+++ b/db/fixtures/development/07_milestones.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
Project.all.each do |project|
@@ -10,9 +10,10 @@ Gitlab::Seeder.quiet do
}
milestone = Milestones::CreateService.new(
- project, project.team.users.sample, milestone_params).execute
+ project, project.team.users.sample, milestone_params
+ ).execute
- print '.'
+ print "."
end
end
end
diff --git a/db/fixtures/development/08_settings.rb b/db/fixtures/development/08_settings.rb
index 141465c06cf..5cd0df7da5c 100644
--- a/db/fixtures/development/08_settings.rb
+++ b/db/fixtures/development/08_settings.rb
@@ -3,5 +3,5 @@
Gitlab::Seeder.quiet do
ApplicationSetting.create_from_defaults unless ApplicationSetting.current_without_cache
ApplicationSetting.current_without_cache.update!(hashed_storage_enabled: true)
- print '.'
+ print "."
end
diff --git a/db/fixtures/development/09_issues.rb b/db/fixtures/development/09_issues.rb
index 16243b72f9a..13bac578c67 100644
--- a/db/fixtures/development/09_issues.rb
+++ b/db/fixtures/development/09_issues.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
Project.all.each do |project|
@@ -6,14 +6,14 @@ Gitlab::Seeder.quiet do
issue_params = {
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentence,
- state: ['opened', 'closed'].sample,
+ state: ["opened", "closed"].sample,
milestone: project.milestones.sample,
assignees: [project.team.users.sample],
- created_at: rand(12).months.ago
+ created_at: rand(12).months.ago,
}
Issues::CreateService.new(project, project.team.users.sample, issue_params).execute
- print '.'
+ print "."
end
end
end
diff --git a/db/fixtures/development/10_merge_requests.rb b/db/fixtures/development/10_merge_requests.rb
index 2051bcff8f0..9411e8a7670 100644
--- a/db/fixtures/development/10_merge_requests.rb
+++ b/db/fixtures/development/10_merge_requests.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
# Limit the number of merge requests per project to avoid long seeds
@@ -18,7 +18,7 @@ Gitlab::Seeder.quiet do
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentences(3).join(" "),
milestone: project.milestones.sample,
- assignee: project.team.users.sample
+ assignee: project.team.users.sample,
}
# Only create MRs with users that are allowed to create MRs
@@ -31,31 +31,31 @@ Gitlab::Seeder.quiet do
# Ignore pipelines creation errors for now, we can doing that after
# https://gitlab.com/gitlab-org/gitlab-ce/issues/55966. will be resolved.
end
- print '.'
+ print "."
end
end
- project = Project.find_by_full_path('gitlab-org/gitlab-test')
+ project = Project.find_by_full_path("gitlab-org/gitlab-test")
next if project.empty_repo? # We don't have repository on CI
params = {
- source_branch: 'feature',
- target_branch: 'master',
- title: 'Can be automatically merged'
+ source_branch: "feature",
+ target_branch: "master",
+ title: "Can be automatically merged",
}
Sidekiq::Worker.skipping_transaction_check do
MergeRequests::CreateService.new(project, User.admins.first, params).execute
end
- print '.'
+ print "."
params = {
- source_branch: 'feature_conflict',
- target_branch: 'feature',
- title: 'Cannot be automatically merged'
+ source_branch: "feature_conflict",
+ target_branch: "feature",
+ title: "Cannot be automatically merged",
}
Sidekiq::Worker.skipping_transaction_check do
MergeRequests::CreateService.new(project, User.admins.first, params).execute
end
- print '.'
+ print "."
end
diff --git a/db/fixtures/development/11_keys.rb b/db/fixtures/development/11_keys.rb
index c405ecfdaf3..2a984147793 100644
--- a/db/fixtures/development/11_keys.rb
+++ b/db/fixtures/development/11_keys.rb
@@ -1,5 +1,4 @@
-require './spec/support/sidekiq'
-
+require "./spec/support/sidekiq"
# Creating keys runs a gitlab-shell worker. Since we may not have the right
# gitlab-shell path set (yet) we need to disable this for these fixtures.
@@ -21,7 +20,7 @@ Sidekiq::Testing.disable! do
key.add_to_shell
end
- print '.'
+ print "."
end
end
end
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb
index a9f4069a0f8..861024c4632 100644
--- a/db/fixtures/development/12_snippets.rb
+++ b/db/fixtures/development/12_snippets.rb
@@ -1,28 +1,28 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
- content =<<eos
-class Member < ActiveRecord::Base
- include Notifiable
- include Gitlab::Access
-
- belongs_to :user
- belongs_to :source, polymorphic: true
-
- validates :user, presence: true
- validates :source, presence: true
- validates :user_id, uniqueness: { scope: [:source_type, :source_id], message: "already exists in source" }
- validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
-
- scope :guests, -> { where(access_level: GUEST) }
- scope :reporters, -> { where(access_level: REPORTER) }
- scope :developers, -> { where(access_level: DEVELOPER) }
- scope :maintainers, -> { where(access_level: MAINTAINER) }
- scope :owners, -> { where(access_level: OWNER) }
-
- delegate :name, :username, :email, to: :user, prefix: true
-end
-eos
+ content = <<~eos
+ class Member < ActiveRecord::Base
+ include Notifiable
+ include Gitlab::Access
+
+ belongs_to :user
+ belongs_to :source, polymorphic: true
+
+ validates :user, presence: true
+ validates :source, presence: true
+ validates :user_id, uniqueness: { scope: [:source_type, :source_id], message: "already exists in source" }
+ validates :access_level, inclusion: { in: Gitlab::Access.all_values }, presence: true
+
+ scope :guests, -> { where(access_level: GUEST) }
+ scope :reporters, -> { where(access_level: REPORTER) }
+ scope :developers, -> { where(access_level: DEVELOPER) }
+ scope :maintainers, -> { where(access_level: MAINTAINER) }
+ scope :owners, -> { where(access_level: OWNER) }
+
+ delegate :name, :username, :email, to: :user, prefix: true
+ end
+ eos
50.times do |i|
user = User.all.sample
@@ -31,12 +31,11 @@ eos
id: i,
author_id: user.id,
title: FFaker::Lorem.sentence(3),
- file_name: FFaker::Internet.domain_word + '.rb',
+ file_name: FFaker::Internet.domain_word + ".rb",
visibility_level: Gitlab::VisibilityLevel.values.sample,
content: content,
}])
- print('.')
+ print(".")
end
end
-
diff --git a/db/fixtures/development/13_comments.rb b/db/fixtures/development/13_comments.rb
index bc2d74c8034..cd698ff87ed 100644
--- a/db/fixtures/development/13_comments.rb
+++ b/db/fixtures/development/13_comments.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
Issue.find_each do |issue|
@@ -6,13 +6,13 @@ Gitlab::Seeder.quiet do
project.team.users.each do |user|
note_params = {
- noteable_type: 'Issue',
+ noteable_type: "Issue",
noteable_id: issue.id,
note: FFaker::Lorem.sentence,
}
Notes::CreateService.new(project, user, note_params).execute
- print '.'
+ print "."
end
end
@@ -21,13 +21,13 @@ Gitlab::Seeder.quiet do
project.team.users.each do |user|
note_params = {
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: mr.id,
note: FFaker::Lorem.sentence,
}
Notes::CreateService.new(project, user, note_params).execute
- print '.'
+ print "."
end
end
end
diff --git a/db/fixtures/development/14_pipelines.rb b/db/fixtures/development/14_pipelines.rb
index db043e39d2c..9a380af8f85 100644
--- a/db/fixtures/development/14_pipelines.rb
+++ b/db/fixtures/development/14_pipelines.rb
@@ -1,61 +1,61 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
class Gitlab::Seeder::Pipelines
STAGES = %w[build test security deploy notify]
BUILDS = [
# build stage
- { name: 'build:linux', stage: 'build', status: :success,
- queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago },
- { name: 'build:osx', stage: 'build', status: :success,
- queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago },
+ {name: "build:linux", stage: "build", status: :success,
+ queued_at: 10.hour.ago, started_at: 9.hour.ago, finished_at: 8.hour.ago,},
+ {name: "build:osx", stage: "build", status: :success,
+ queued_at: 10.hour.ago, started_at: 10.hour.ago, finished_at: 9.hour.ago,},
# test stage
- { name: 'rspec:linux 0 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:linux 1 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:linux 2 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:windows 0 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:windows 1 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:windows 2 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:windows 2 3', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'rspec:osx', stage: 'test', status_event: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'spinach:linux', stage: 'test', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'spinach:osx', stage: 'test', status: :failed, allow_failure: true,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
+ {name: "rspec:linux 0 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:linux 1 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:linux 2 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:windows 0 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:windows 1 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:windows 2 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:windows 2 3", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "rspec:osx", stage: "test", status_event: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "spinach:linux", stage: "test", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "spinach:osx", stage: "test", status: :failed, allow_failure: true,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
# security stage
- { name: 'dast', stage: 'security', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'sast', stage: 'security', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'dependency_scanning', stage: 'security', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
- { name: 'container_scanning', stage: 'security', status: :success,
- queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago },
+ {name: "dast", stage: "security", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "sast", stage: "security", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "dependency_scanning", stage: "security", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
+ {name: "container_scanning", stage: "security", status: :success,
+ queued_at: 8.hour.ago, started_at: 8.hour.ago, finished_at: 7.hour.ago,},
# deploy stage
- { name: 'staging', stage: 'deploy', environment: 'staging', status_event: :success,
- options: { environment: { action: 'start', on_stop: 'stop staging' } },
- queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago },
- { name: 'stop staging', stage: 'deploy', environment: 'staging',
- when: 'manual', status: :skipped },
- { name: 'production', stage: 'deploy', environment: 'production',
- when: 'manual', status: :skipped },
+ {name: "staging", stage: "deploy", environment: "staging", status_event: :success,
+ options: {environment: {action: "start", on_stop: "stop staging"}},
+ queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,},
+ {name: "stop staging", stage: "deploy", environment: "staging",
+ when: "manual", status: :skipped,},
+ {name: "production", stage: "deploy", environment: "production",
+ when: "manual", status: :skipped,},
# notify stage
- { name: 'slack', stage: 'notify', when: 'manual', status: :success },
+ {name: "slack", stage: "notify", when: "manual", status: :success},
]
EXTERNAL_JOBS = [
- { name: 'jenkins', stage: 'test', status: :success,
- queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago },
+ {name: "jenkins", stage: "test", status: :success,
+ queued_at: 7.hour.ago, started_at: 6.hour.ago, finished_at: 4.hour.ago,},
]
def initialize(project)
@@ -78,15 +78,15 @@ class Gitlab::Seeder::Pipelines
end
def create_master_pipelines
- @project.repository.commits('master', limit: 4).map do |commit|
- create_pipeline!(@project, 'master', commit)
+ @project.repository.commits("master", limit: 4).map do |commit|
+ create_pipeline!(@project, "master", commit)
end
rescue
[]
end
def create_merge_request_pipelines
- pipelines = @project.merge_requests.first(3).map do |merge_request|
+ pipelines = @project.merge_requests.first(3).map { |merge_request|
project = merge_request.source_project
branch = merge_request.source_branch
@@ -95,7 +95,7 @@ class Gitlab::Seeder::Pipelines
merge_request.update!(head_pipeline_id: pipeline.id)
end
end
- end
+ }
pipelines.flatten
rescue
@@ -110,7 +110,7 @@ class Gitlab::Seeder::Pipelines
attributes = job_attributes(pipeline, opts)
attributes[:options] ||= {}
- attributes[:options][:script] = 'build command'
+ attributes[:options][:script] = "build command"
Ci::Build.create!(attributes).tap do |build|
# We need to set build trace and artifacts after saving a build
@@ -126,8 +126,8 @@ class Gitlab::Seeder::Pipelines
end
setup_build_log(build)
- build.project.environments.
- find_or_create_by(name: build.expanded_environment_name)
+ build.project.environments
+ .find_or_create_by(name: build.expanded_environment_name)
build.save!
end
@@ -164,14 +164,15 @@ class Gitlab::Seeder::Pipelines
# we have two sources: master and feature-branch
branch_name = build.ref == build.project.default_branch ?
- 'master' : 'feature-branch'
+ "master" : "feature-branch"
artifacts_cache_file(security_reports_path(branch_name, build.name)) do |file|
build.job_artifacts.build(
project: build.project,
file_type: build.name,
file_format: :raw,
- file: file)
+ file: file
+)
end
end
@@ -180,14 +181,15 @@ class Gitlab::Seeder::Pipelines
# we have two sources: master and feature-branch
branch_name = build.ref == build.project.default_branch ?
- 'master' : 'feature-branch'
+ "master" : "feature-branch"
artifacts_cache_file(security_reports_archive_path(branch_name)) do |file|
build.job_artifacts.build(
project: build.project,
file_type: :archive,
file_format: :zip,
- file: file)
+ file: file
+)
end
# assign dummy metadata
@@ -196,20 +198,21 @@ class Gitlab::Seeder::Pipelines
project: build.project,
file_type: :metadata,
file_format: :gzip,
- file: file)
+ file: file
+)
end
build.options = {
artifacts: {
paths: [
- Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym)
- ]
- }
+ Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(build.name.to_sym),
+ ],
+ },
}
end
def setup_build_log(build)
- if %w(running success failed).include?(build.status)
+ if %w[running success failed].include?(build.status)
build.trace.set(FFaker::Lorem.paragraphs(6).join("\n\n"))
end
end
@@ -221,10 +224,9 @@ class Gitlab::Seeder::Pipelines
end
def job_attributes(pipeline, opts)
- { name: 'test build', stage: 'test', stage_idx: stage_index(opts[:stage]),
+ {name: "test build", stage: "test", stage_idx: stage_index(opts[:stage]),
ref: pipeline.ref, tag: false, user: build_user, project: @project, pipeline: pipeline,
- created_at: Time.now, updated_at: Time.now
- }.merge(opts)
+ created_at: Time.now, updated_at: Time.now},.merge(opts)
end
def build_user
@@ -240,28 +242,28 @@ class Gitlab::Seeder::Pipelines
end
def artifacts_archive_path
- Rails.root + 'spec/fixtures/ci_build_artifacts.zip'
+ Rails.root + "spec/fixtures/ci_build_artifacts.zip"
end
def artifacts_metadata_path
- Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz'
+ Rails.root + "spec/fixtures/ci_build_artifacts_metadata.gz"
end
def test_reports_pass_path
- Rails.root + 'spec/fixtures/junit/junit_ant.xml.gz'
+ Rails.root + "spec/fixtures/junit/junit_ant.xml.gz"
end
def test_reports_failed_path
- Rails.root + 'spec/fixtures/junit/junit.xml.gz'
+ Rails.root + "spec/fixtures/junit/junit.xml.gz"
end
def security_reports_archive_path(branch)
- Rails.root.join('spec', 'fixtures', 'security-reports', branch + '.zip')
+ Rails.root.join("spec", "fixtures", "security-reports", branch + ".zip")
end
def security_reports_path(branch, name)
file_name = Ci::JobArtifact::DEFAULT_FILE_NAMES.fetch(name.to_sym)
- Rails.root.join('spec', 'fixtures', 'security-reports', branch, file_name)
+ Rails.root.join("spec", "fixtures", "security-reports", branch, file_name)
end
def artifacts_cache_file(file_path)
diff --git a/db/fixtures/development/15_award_emoji.rb b/db/fixtures/development/15_award_emoji.rb
index 137a036edaf..a9257979c7d 100644
--- a/db/fixtures/development/15_award_emoji.rb
+++ b/db/fixtures/development/15_award_emoji.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
emoji = Gitlab::Emoji.emojis.keys
@@ -14,7 +14,7 @@ Gitlab::Seeder.quiet do
note.create_award_emoji(emoji.sample, user)
end
- print '.'
+ print "."
end
end
@@ -29,7 +29,7 @@ Gitlab::Seeder.quiet do
note.create_award_emoji(emoji.sample, user)
end
- print '.'
+ print "."
end
end
end
diff --git a/db/fixtures/development/16_protected_branches.rb b/db/fixtures/development/16_protected_branches.rb
index 39d466fb43f..2bf25d12ded 100644
--- a/db/fixtures/development/16_protected_branches.rb
+++ b/db/fixtures/development/16_protected_branches.rb
@@ -1,14 +1,14 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Gitlab::Seeder.quiet do
admin_user = User.find(1)
Project.all.each do |project|
params = {
- name: 'master'
+ name: "master",
}
ProtectedBranches::CreateService.new(project, admin_user, params).execute
- print '.'
+ print "."
end
end
diff --git a/db/fixtures/development/17_cycle_analytics.rb b/db/fixtures/development/17_cycle_analytics.rb
index 7a86fe2eb7c..b874cc60963 100644
--- a/db/fixtures/development/17_cycle_analytics.rb
+++ b/db/fixtures/development/17_cycle_analytics.rb
@@ -1,5 +1,5 @@
-require './spec/support/sidekiq'
-require './spec/support/helpers/test_env'
+require "./spec/support/sidekiq"
+require "./spec/support/helpers/test_env"
class Gitlab::Seeder::CycleAnalytics
def initialize(project, perf: false)
@@ -31,8 +31,8 @@ class Gitlab::Seeder::CycleAnalytics
# MR
Timecop.travel 5.days.from_now
branch_name = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
- @project.repository.add_branch(@user, branch_name, 'master')
- merge_request = MergeRequest.create(target_project: @project, source_project: @project, source_branch: branch_name, target_branch: 'master', title: branch_name, author: @user)
+ @project.repository.add_branch(@user, branch_name, "master")
+ merge_request = MergeRequest.create(target_project: @project, source_project: @project, source_branch: branch_name, target_branch: "master", title: branch_name, author: @user)
merge_request_metrics = merge_request.metrics
# MR closing issues
@@ -58,7 +58,7 @@ class Gitlab::Seeder::CycleAnalytics
issue_metrics.save!
merge_request_metrics.save!
- print '.'
+ print "."
end
end
@@ -66,41 +66,41 @@ class Gitlab::Seeder::CycleAnalytics
Sidekiq::Worker.skipping_transaction_check do
Sidekiq::Testing.inline! do
issues = create_issues
- puts '.'
+ puts "."
# Stage 1
Timecop.travel 5.days.from_now
add_milestones_and_list_labels(issues)
- print '.'
+ print "."
# Stage 2
Timecop.travel 5.days.from_now
branches = mention_in_commits(issues)
- print '.'
+ print "."
# Stage 3
Timecop.travel 5.days.from_now
merge_requests = create_merge_requests_closing_issues(issues, branches)
- print '.'
+ print "."
# Stage 4
Timecop.travel 5.days.from_now
run_builds(merge_requests)
- print '.'
+ print "."
# Stage 5
Timecop.travel 5.days.from_now
merge_merge_requests(merge_requests)
- print '.'
+ print "."
# Stage 6 / 7
Timecop.travel 5.days.from_now
deploy_to_production(merge_requests)
- print '.'
+ print "."
end
end
- print '.'
+ print "."
end
private
@@ -110,8 +110,8 @@ class Gitlab::Seeder::CycleAnalytics
issue_params = {
title: "Cycle Analytics: #{FFaker::Lorem.sentence(6)}",
description: FFaker::Lorem.sentence,
- state: 'opened',
- assignees: [@project.team.users.sample]
+ state: "opened",
+ assignees: [@project.team.users.sample],
}
Issues::CreateService.new(@project, @project.team.users.sample, issue_params).execute
@@ -141,16 +141,16 @@ class Gitlab::Seeder::CycleAnalytics
branch_name = filename = "#{FFaker::Product.brand}-#{FFaker::Product.brand}-#{rand(1000)}"
- issue.project.repository.add_branch(@user, branch_name, 'master')
+ issue.project.repository.add_branch(@user, branch_name, "master")
commit_sha = issue.project.repository.create_file(@user, filename, "content", message: "Commit for #{issue.to_reference}", branch_name: branch_name)
issue.project.repository.commit(commit_sha)
GitPushService.new(issue.project,
- @user,
- oldrev: issue.project.repository.commit("master").sha,
- newrev: commit_sha,
- ref: 'refs/heads/master').execute
+ @user,
+ oldrev: issue.project.repository.commit("master").sha,
+ newrev: commit_sha,
+ ref: "refs/heads/master").execute
branch_name
end
@@ -161,10 +161,10 @@ class Gitlab::Seeder::CycleAnalytics
Timecop.travel 12.hours.from_now
opts = {
- title: 'Cycle Analytics merge_request',
+ title: "Cycle Analytics merge_request",
description: "Fixes #{issue.to_reference}",
source_branch: branch,
- target_branch: 'master'
+ target_branch: "master",
}
MergeRequests::CreateService.new(issue.project, @user, opts).execute
@@ -176,8 +176,8 @@ class Gitlab::Seeder::CycleAnalytics
Timecop.travel 12.hours.from_now
service = Ci::CreatePipelineService.new(merge_request.project,
- @user,
- ref: "refs/heads/#{merge_request.source_branch}")
+ @user,
+ ref: "refs/heads/#{merge_request.source_branch}")
pipeline = service.execute(:push, ignore_skip_ci: true, save_on_errors: false)
pipeline.builds.map(&:run!)
@@ -208,7 +208,7 @@ class Gitlab::Seeder::CycleAnalytics
end
Gitlab::Seeder.quiet do
- flag = 'SEED_CYCLE_ANALYTICS'
+ flag = "SEED_CYCLE_ANALYTICS"
if ENV[flag]
Project.find_each do |project|
@@ -217,15 +217,15 @@ Gitlab::Seeder.quiet do
# GDK seed, but is almost never true for a GDK that's actually had
# development performed on it.
next unless project.repository_exists?
- next unless project.repository.commit('master')
+ next unless project.repository.commit("master")
seeder = Gitlab::Seeder::CycleAnalytics.new(project)
seeder.seed!
end
- elsif ENV['CYCLE_ANALYTICS_PERF_TEST']
+ elsif ENV["CYCLE_ANALYTICS_PERF_TEST"]
seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true)
seeder.seed!
- elsif ENV['CYCLE_ANALYTICS_POPULATE_METRICS_DIRECTLY']
+ elsif ENV["CYCLE_ANALYTICS_POPULATE_METRICS_DIRECTLY"]
seeder = Gitlab::Seeder::CycleAnalytics.new(Project.order(:id).first, perf: true)
seeder.seed_metrics!
else
diff --git a/db/fixtures/development/18_abuse_reports.rb b/db/fixtures/development/18_abuse_reports.rb
index 88d2f784852..759f9abad8a 100644
--- a/db/fixtures/development/18_abuse_reports.rb
+++ b/db/fixtures/development/18_abuse_reports.rb
@@ -11,11 +11,11 @@ module Db
name: FFaker::Name.name,
email: FFaker::Internet.email,
confirmed_at: DateTime.now,
- password: '12345678'
+ password: "12345678"
)
- ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: 'User sends spam')
- print '.'
+ ::AbuseReport.create(reporter: ::User.take, user: reported_user, message: "User sends spam")
+ print "."
end
end
end
diff --git a/db/fixtures/development/19_environments.rb b/db/fixtures/development/19_environments.rb
index 3e227928a29..2966dd3ee5b 100644
--- a/db/fixtures/development/19_environments.rb
+++ b/db/fixtures/development/19_environments.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
class Gitlab::Seeder::Environments
def initialize(project)
@@ -9,19 +9,19 @@ class Gitlab::Seeder::Environments
@project.create_mock_deployment_service!(active: true)
@project.create_mock_monitoring_service!(active: true)
- create_master_deployments!('production')
- create_master_deployments!('staging')
+ create_master_deployments!("production")
+ create_master_deployments!("staging")
create_merge_request_review_deployments!
end
private
def create_master_deployments!(name)
- @project.repository.commits('master', limit: 4).map do |commit|
+ @project.repository.commits("master", limit: 4).map do |commit|
create_deployment!(
@project,
name,
- 'master',
+ "master",
commit.id
)
end
@@ -37,7 +37,7 @@ class Gitlab::Seeder::Environments
create_deployment!(
merge_request.source_project,
- "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]+/, '')}",
+ "review/#{merge_request.source_branch.gsub(/[^a-zA-Z0-9]+/, "")}",
merge_request.source_branch,
merge_request.diff_head_sha
)
diff --git a/db/fixtures/development/20_nested_groups.rb b/db/fixtures/development/20_nested_groups.rb
index 3d95e243f8a..da606c21fa9 100644
--- a/db/fixtures/development/20_nested_groups.rb
+++ b/db/fixtures/development/20_nested_groups.rb
@@ -1,28 +1,28 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
- flag = 'SEED_NESTED_GROUPS'
+ flag = "SEED_NESTED_GROUPS"
if ENV[flag]
project_urls = [
- 'https://android.googlesource.com/platform/hardware/broadcom/libbt.git',
- 'https://android.googlesource.com/platform/hardware/broadcom/wlan.git',
- 'https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git',
- 'https://android.googlesource.com/platform/hardware/bsp/broadcom.git',
- 'https://android.googlesource.com/platform/hardware/bsp/freescale.git',
- 'https://android.googlesource.com/platform/hardware/bsp/imagination.git',
- 'https://android.googlesource.com/platform/hardware/bsp/intel.git',
- 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git',
- 'https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git'
+ "https://android.googlesource.com/platform/hardware/broadcom/libbt.git",
+ "https://android.googlesource.com/platform/hardware/broadcom/wlan.git",
+ "https://android.googlesource.com/platform/hardware/bsp/bootloader/intel/edison-u-boot.git",
+ "https://android.googlesource.com/platform/hardware/bsp/broadcom.git",
+ "https://android.googlesource.com/platform/hardware/bsp/freescale.git",
+ "https://android.googlesource.com/platform/hardware/bsp/imagination.git",
+ "https://android.googlesource.com/platform/hardware/bsp/intel.git",
+ "https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.1.git",
+ "https://android.googlesource.com/platform/hardware/bsp/kernel/common/v4.4.git",
]
user = User.admins.first
project_urls.each_with_index do |url, i|
- full_path = url.sub('https://android.googlesource.com/', '')
- full_path = full_path.sub(/\.git\z/, '')
- full_path, _, project_path = full_path.rpartition('/')
+ full_path = url.sub("https://android.googlesource.com/", "")
+ full_path = full_path.sub(/\.git\z/, "")
+ full_path, _, project_path = full_path.rpartition("/")
group = Group.find_by_full_path(full_path) ||
Groups::NestedCreateService.new(user, group_path: full_path).execute
@@ -32,16 +32,16 @@ Sidekiq::Testing.inline! do
path: project_path,
name: project_path,
description: FFaker::Lorem.sentence,
- visibility_level: Gitlab::VisibilityLevel.values.sample
+ visibility_level: Gitlab::VisibilityLevel.values.sample,
}
project = Projects::CreateService.new(user, params).execute
project.send(:_run_after_commit_queue)
if project.valid?
- print '.'
+ print "."
else
- print 'F'
+ print "F"
end
end
else
diff --git a/db/fixtures/development/21_conversational_development_index_metrics.rb b/db/fixtures/development/21_conversational_development_index_metrics.rb
index 4cd0a82ed1a..c2197969b79 100644
--- a/db/fixtures/development/21_conversational_development_index_metrics.rb
+++ b/db/fixtures/development/21_conversational_development_index_metrics.rb
@@ -32,9 +32,9 @@ Gitlab::Seeder.quiet do
)
if conversational_development_index_metric.save
- print '.'
+ print "."
else
puts conversational_development_index_metric.errors.full_messages
- print 'F'
+ print "F"
end
end
diff --git a/db/fixtures/development/22_labeled_issues_seed.rb b/db/fixtures/development/22_labeled_issues_seed.rb
index 3730e9c7958..f7b5244a97f 100644
--- a/db/fixtures/development/22_labeled_issues_seed.rb
+++ b/db/fixtures/development/22_labeled_issues_seed.rb
@@ -1,7 +1,7 @@
# Creates a project with labeled issues for an user.
# Run this single seed file using: rake db:seed_fu FILTER=labeled USER_ID=74.
# If an USER_ID is not provided it will use the last created user.
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
class Gitlab::Seeder::LabeledIssues
include ::Gitlab::Utils
@@ -19,7 +19,7 @@ class Gitlab::Seeder::LabeledIssues
create_issues(group)
end
- print '.'
+ print "."
end
private
@@ -30,7 +30,7 @@ class Gitlab::Seeder::LabeledIssues
group_params = {
name: group_name,
path: group_name,
- description: FFaker::Lorem.sentence
+ description: FFaker::Lorem.sentence,
}
Groups::CreateService.new(@user, group_params).execute
@@ -44,7 +44,7 @@ class Gitlab::Seeder::LabeledIssues
namespace_id: group.id,
name: project_name,
description: FFaker::Lorem.sentence,
- visibility_level: Gitlab::VisibilityLevel.values.sample
+ visibility_level: Gitlab::VisibilityLevel.values.sample,
}
Projects::CreateService.new(@user, params).execute
@@ -78,8 +78,8 @@ class Gitlab::Seeder::LabeledIssues
issue_params = {
title: FFaker::Lorem.sentence(6),
description: FFaker::Lorem.sentence,
- state: 'opened',
- label_ids: label_ids
+ state: "opened",
+ label_ids: label_ids,
}
@@ -90,7 +90,7 @@ class Gitlab::Seeder::LabeledIssues
end
Gitlab::Seeder.quiet do
- user_id = ENV['USER_ID']
+ user_id = ENV["USER_ID"]
user =
if user_id.present?
diff --git a/db/fixtures/development/23_spam_logs.rb b/db/fixtures/development/23_spam_logs.rb
index 81cc13e6b2d..ba18ba5e9e1 100644
--- a/db/fixtures/development/23_spam_logs.rb
+++ b/db/fixtures/development/23_spam_logs.rb
@@ -8,15 +8,16 @@ module Db
Gitlab::Seeder.quiet do
(::SpamLog.default_per_page + 3).times do |i|
::SpamLog.create(
- user: self.random_user,
+ user: random_user,
user_agent: FFaker::Lorem.sentence,
source_ip: FFaker::Internet.ip_v4_address,
title: FFaker::Lorem.sentence,
description: FFaker::Lorem.paragraph,
via_api: FFaker::Boolean.random,
submitted_as_ham: FFaker::Boolean.random,
- recaptcha_verified: FFaker::Boolean.random)
- print '.'
+ recaptcha_verified: FFaker::Boolean.random
+ )
+ print "."
end
end
end
diff --git a/db/fixtures/development/24_forks.rb b/db/fixtures/development/24_forks.rb
index 5eb5956ec74..40d6c16673a 100644
--- a/db/fixtures/development/24_forks.rb
+++ b/db/fixtures/development/24_forks.rb
@@ -1,4 +1,4 @@
-require './spec/support/sidekiq'
+require "./spec/support/sidekiq"
Sidekiq::Testing.inline! do
Gitlab::Seeder.quiet do
@@ -13,9 +13,9 @@ Sidekiq::Testing.inline! do
fork_project = Projects::ForkService.new(source_project, user, namespace: user.namespace).execute
if fork_project.valid?
- puts '.'
+ puts "."
else
- puts 'F'
+ puts "F"
end
end
end
diff --git a/db/fixtures/development/99_common_metrics.rb b/db/fixtures/development/99_common_metrics.rb
index 1f39c0ce5a0..461444592ec 100644
--- a/db/fixtures/development/99_common_metrics.rb
+++ b/db/fixtures/development/99_common_metrics.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require Rails.root.join('db/importers/common_metrics_importer.rb')
+require Rails.root.join("db/importers/common_metrics_importer.rb")
::Importers::CommonMetricsImporter.new.execute
diff --git a/db/fixtures/production/002_admin.rb b/db/fixtures/production/002_admin.rb
index 1c7c89f7bbd..35b92e176ff 100644
--- a/db/fixtures/production/002_admin.rb
+++ b/db/fixtures/production/002_admin.rb
@@ -1,15 +1,15 @@
user_args = {
- email: ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com',
- name: 'Administrator',
- username: 'root',
- admin: true
+ email: ENV["GITLAB_ROOT_EMAIL"].presence || "admin@example.com",
+ name: "Administrator",
+ username: "root",
+ admin: true,
}
-if ENV['GITLAB_ROOT_PASSWORD'].blank?
+if ENV["GITLAB_ROOT_PASSWORD"].blank?
user_args[:password_automatically_set] = true
user_args[:force_random_password] = true
else
- user_args[:password] = ENV['GITLAB_ROOT_PASSWORD']
+ user_args[:password] = ENV["GITLAB_ROOT_PASSWORD"]
end
# Only admins can create other admin users in Users::CreateService so to solve
diff --git a/db/fixtures/production/010_settings.rb b/db/fixtures/production/010_settings.rb
index 7626cdb0b9c..da91af57ead 100644
--- a/db/fixtures/production/010_settings.rb
+++ b/db/fixtures/production/010_settings.rb
@@ -12,15 +12,15 @@ def save(settings, topic)
end
end
-if ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'].present?
+if ENV["GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN"].present?
settings = Gitlab::CurrentSettings.current_application_settings
- settings.set_runners_registration_token(ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'])
- save(settings, 'Runner Registration Token')
+ settings.set_runners_registration_token(ENV["GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN"])
+ save(settings, "Runner Registration Token")
end
-if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present?
+if ENV["GITLAB_PROMETHEUS_METRICS_ENABLED"].present?
settings = Gitlab::CurrentSettings.current_application_settings
- value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) || false
+ value = Gitlab::Utils.to_boolean(ENV["GITLAB_PROMETHEUS_METRICS_ENABLED"]) || false
settings.prometheus_metrics_enabled = value
- save(settings, 'Prometheus metrics enabled flag')
+ save(settings, "Prometheus metrics enabled flag")
end
diff --git a/db/fixtures/production/999_common_metrics.rb b/db/fixtures/production/999_common_metrics.rb
index 1f39c0ce5a0..461444592ec 100644
--- a/db/fixtures/production/999_common_metrics.rb
+++ b/db/fixtures/production/999_common_metrics.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-require Rails.root.join('db/importers/common_metrics_importer.rb')
+require Rails.root.join("db/importers/common_metrics_importer.rb")
::Importers::CommonMetricsImporter.new.execute
diff --git a/db/importers/common_metrics_importer.rb b/db/importers/common_metrics_importer.rb
index deadd653ae9..28edcc5c3a4 100644
--- a/db/importers/common_metrics_importer.rb
+++ b/db/importers/common_metrics_importer.rb
@@ -14,21 +14,21 @@ module Importers
# custom groups
business: 0,
response: 1,
- system: 2
+ system: 2,
}
scope :common, -> { where(common: true) }
GROUP_TITLES = {
- business: _('Business metrics (Custom)'),
- response: _('Response metrics (Custom)'),
- system: _('System metrics (Custom)'),
- nginx_ingress_vts: _('Response metrics (NGINX Ingress VTS)'),
- nginx_ingress: _('Response metrics (NGINX Ingress)'),
- ha_proxy: _('Response metrics (HA Proxy)'),
- aws_elb: _('Response metrics (AWS ELB)'),
- nginx: _('Response metrics (NGINX)'),
- kubernetes: _('System metrics (Kubernetes)')
+ business: _("Business metrics (Custom)"),
+ response: _("Response metrics (Custom)"),
+ system: _("System metrics (Custom)"),
+ nginx_ingress_vts: _("Response metrics (NGINX Ingress VTS)"),
+ nginx_ingress: _("Response metrics (NGINX Ingress)"),
+ ha_proxy: _("Response metrics (HA Proxy)"),
+ aws_elb: _("Response metrics (AWS ELB)"),
+ nginx: _("Response metrics (NGINX)"),
+ kubernetes: _("System metrics (Kubernetes)"),
}.freeze
end
@@ -37,8 +37,8 @@ module Importers
attr_reader :content
- def initialize(filename = 'common_metrics.yml')
- @content = YAML.load_file(Rails.root.join('config', 'prometheus', filename))
+ def initialize(filename = "common_metrics.yml")
+ @content = YAML.load_file(Rails.root.join("config", "prometheus", filename))
end
def execute
@@ -60,31 +60,33 @@ module Importers
def process_group(group, &blk)
attributes = {
- group: find_group_title_key(group['group'])
+ group: find_group_title_key(group["group"]),
}
- group['metrics'].map do |metric|
+ group["metrics"].map do |metric|
process_metric(metric, attributes, &blk)
end
end
def process_metric(metric, attributes, &blk)
attributes = attributes.merge(
- title: metric['title'],
- y_label: metric['y_label'])
+ title: metric["title"],
+ y_label: metric["y_label"]
+ )
- metric['queries'].map do |query|
+ metric["queries"].map do |query|
process_metric_query(query, attributes, &blk)
end
end
def process_metric_query(query, attributes, &blk)
attributes = attributes.merge(
- legend: query['label'],
- query: query['query_range'],
- unit: query['unit'])
+ legend: query["label"],
+ query: query["query_range"],
+ unit: query["unit"]
+ )
- yield(query['id'], attributes)
+ yield(query["id"], attributes)
end
def find_or_build_metric!(id)
diff --git a/db/migrate/20140407135544_fix_namespaces.rb b/db/migrate/20140407135544_fix_namespaces.rb
index b16d65c4b51..1258dc914f7 100644
--- a/db/migrate/20140407135544_fix_namespaces.rb
+++ b/db/migrate/20140407135544_fix_namespaces.rb
@@ -2,11 +2,11 @@ class FixNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- namespaces = exec_query('SELECT id, path FROM namespaces WHERE name <> path and type is null')
+ namespaces = exec_query("SELECT id, path FROM namespaces WHERE name <> path and type is null")
namespaces.each do |row|
- id = row['id']
- path = row['path']
+ id = row["id"]
+ path = row["path"]
exec_query("UPDATE namespaces SET name = '#{path}' WHERE id = #{id}")
end
end
diff --git a/db/migrate/20140415124820_limits_to_mysql.rb b/db/migrate/20140415124820_limits_to_mysql.rb
index 3f6e62617c5..fa584f50d0b 100644
--- a/db/migrate/20140415124820_limits_to_mysql.rb
+++ b/db/migrate/20140415124820_limits_to_mysql.rb
@@ -1 +1 @@
-require_relative 'limits_to_mysql'
+require_relative "limits_to_mysql"
diff --git a/db/migrate/20140729145339_migrate_project_tags.rb b/db/migrate/20140729145339_migrate_project_tags.rb
index 711a2d262aa..6c4303cf8f3 100644
--- a/db/migrate/20140729145339_migrate_project_tags.rb
+++ b/db/migrate/20140729145339_migrate_project_tags.rb
@@ -1,9 +1,9 @@
class MigrateProjectTags < ActiveRecord::Migration[4.2]
def up
- ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'labels').update_all(context: 'tags')
+ ActsAsTaggableOn::Tagging.where(taggable_type: "Project", context: "labels").update_all(context: "tags")
end
def down
- ActsAsTaggableOn::Tagging.where(taggable_type: 'Project', context: 'tags').update_all(context: 'labels')
+ ActsAsTaggableOn::Tagging.where(taggable_type: "Project", context: "tags").update_all(context: "labels")
end
end
diff --git a/db/migrate/20150411000035_fix_identities.rb b/db/migrate/20150411000035_fix_identities.rb
index a449fc51ecc..21fd3df7a6d 100644
--- a/db/migrate/20150411000035_fix_identities.rb
+++ b/db/migrate/20150411000035_fix_identities.rb
@@ -10,22 +10,22 @@ class FixIdentities < ActiveRecord::Migration[4.2]
# whatever the code would have interpreted it as, i.e. as a reference to
# the first LDAP server specified in gitlab.yml / gitlab.rb.
new_provider = if Gitlab.config.ldap.enabled
- first_ldap_server = Gitlab.config.ldap.servers.values.first
- first_ldap_server['provider_name']
- else
- 'ldapmain'
- end
+ first_ldap_server = Gitlab.config.ldap.servers.values.first
+ first_ldap_server["provider_name"]
+ else
+ "ldapmain"
+ end
# Delete duplicate identities
# We use a sort of self-join to find rows in identities which match on
# user_id but where one has provider 'ldap'. We delete the duplicate row
# with provider 'ldap'.
- delete_statement = ''
+ delete_statement = ""
case adapter_name.downcase
when /^mysql/
- delete_statement << 'DELETE FROM id1 USING identities AS id1, identities AS id2'
- when 'postgresql'
- delete_statement << 'DELETE FROM identities AS id1 USING identities AS id2'
+ delete_statement << "DELETE FROM id1 USING identities AS id1, identities AS id2"
+ when "postgresql"
+ delete_statement << "DELETE FROM identities AS id1 USING identities AS id2"
else
raise "Unknown DB adapter: #{adapter_name}"
end
@@ -35,7 +35,7 @@ class FixIdentities < ActiveRecord::Migration[4.2]
# Update legacy identities
execute "UPDATE identities SET provider = '#{new_provider}' WHERE provider = 'ldap'"
- if table_exists?('ldap_group_links')
+ if table_exists?("ldap_group_links")
execute "UPDATE ldap_group_links SET provider = '#{new_provider}' WHERE provider IS NULL OR provider = 'ldap'"
end
end
diff --git a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb b/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb
index e0f35da422a..61cbb07c226 100644
--- a/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb
+++ b/db/migrate/20150423033240_add_default_project_visibililty_to_application_settings.rb
@@ -1,7 +1,7 @@
class AddDefaultProjectVisibililtyToApplicationSettings < ActiveRecord::Migration[4.2]
def up
add_column :application_settings, :default_project_visibility, :integer
- visibility = Settings.gitlab.default_projects_features['visibility_level']
+ visibility = Settings.gitlab.default_projects_features["visibility_level"]
execute("update application_settings set default_project_visibility = #{visibility}")
end
diff --git a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb b/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb
index a3a86d26767..1927a4fb1e8 100644
--- a/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb
+++ b/db/migrate/20150425173433_add_default_snippet_visibility_to_app_settings.rb
@@ -1,7 +1,7 @@
class AddDefaultSnippetVisibilityToAppSettings < ActiveRecord::Migration[4.2]
def up
add_column :application_settings, :default_snippet_visibility, :integer
- visibility = Settings.gitlab.default_projects_features['visibility_level']
+ visibility = Settings.gitlab.default_projects_features["visibility_level"]
execute("update application_settings set default_snippet_visibility = #{visibility}")
end
diff --git a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb
index 4a085ff06f3..0d14eb42c4b 100644
--- a/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb
+++ b/db/migrate/20150620233230_add_default_otp_required_for_login_value.rb
@@ -1,6 +1,6 @@
class AddDefaultOtpRequiredForLoginValue < ActiveRecord::Migration[4.2]
def up
- execute %q{UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL}
+ execute "UPDATE users SET otp_required_for_login = FALSE WHERE otp_required_for_login IS NULL"
change_column :users, :otp_required_for_login, :boolean, default: false, null: false
end
diff --git a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb b/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb
index ff31e70874f..93a6ab0b97f 100644
--- a/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb
+++ b/db/migrate/20150924125436_migrate_project_id_for_ci_commits.rb
@@ -1,6 +1,6 @@
class MigrateProjectIdForCiCommits < ActiveRecord::Migration[4.2]
def up
- subquery = 'SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = ci_commits.project_id'
+ subquery = "SELECT gitlab_id FROM ci_projects WHERE ci_projects.id = ci_commits.project_id"
execute("UPDATE ci_commits SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL")
end
end
diff --git a/db/migrate/20151020173516_ci_limits_to_mysql.rb b/db/migrate/20151020173516_ci_limits_to_mysql.rb
index 573922b851b..eab2201c2fb 100644
--- a/db/migrate/20151020173516_ci_limits_to_mysql.rb
+++ b/db/migrate/20151020173516_ci_limits_to_mysql.rb
@@ -1,6 +1,6 @@
class CiLimitsToMysql < ActiveRecord::Migration[4.2]
def change
- return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
+ return unless ActiveRecord::Base.configurations[Rails.env]["adapter"] =~ /^mysql/
# CI
change_column :ci_builds, :trace, :text, limit: 1073741823
diff --git a/db/migrate/20151023144219_remove_satellites.rb b/db/migrate/20151023144219_remove_satellites.rb
index 2d1310b0208..4701817cd97 100644
--- a/db/migrate/20151023144219_remove_satellites.rb
+++ b/db/migrate/20151023144219_remove_satellites.rb
@@ -1,11 +1,11 @@
-require 'fileutils'
+require "fileutils"
class RemoveSatellites < ActiveRecord::Migration[4.2]
def up
- satellites = Gitlab.config['satellites']
+ satellites = Gitlab.config["satellites"]
return if satellites.nil?
- satellites_path = satellites['path']
+ satellites_path = satellites["path"]
return if satellites_path.nil?
FileUtils.rm_rf(satellites_path)
diff --git a/db/migrate/20151209144329_migrate_ci_web_hooks.rb b/db/migrate/20151209144329_migrate_ci_web_hooks.rb
index 7562735cb1e..7ab26abdbca 100644
--- a/db/migrate/20151209144329_migrate_ci_web_hooks.rb
+++ b/db/migrate/20151209144329_migrate_ci_web_hooks.rb
@@ -3,11 +3,11 @@ class MigrateCiWebHooks < ActiveRecord::Migration[4.2]
def up
execute(
- 'INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events) ' \
+ "INSERT INTO web_hooks (url, project_id, type, created_at, updated_at, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events) " \
"SELECT ci_web_hooks.url, projects.id, 'ProjectHook', ci_web_hooks.created_at, ci_web_hooks.updated_at, " \
"#{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value} FROM ci_web_hooks " \
- 'JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id ' \
- 'JOIN projects ON ci_projects.gitlab_id = projects.id'
+ "JOIN ci_projects ON ci_web_hooks.project_id = ci_projects.id " \
+ "JOIN projects ON ci_projects.gitlab_id = projects.id"
)
end
diff --git a/db/migrate/20151209145909_migrate_ci_emails.rb b/db/migrate/20151209145909_migrate_ci_emails.rb
index a1f51c55a55..333f68b4398 100644
--- a/db/migrate/20151209145909_migrate_ci_emails.rb
+++ b/db/migrate/20151209145909_migrate_ci_emails.rb
@@ -6,16 +6,16 @@ class MigrateCiEmails < ActiveRecord::Migration[4.2]
# It "manually" constructs the properties (JSON-encoded)
# Migrating all ci_projects e-mail related columns
execute(
- 'INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) ' \
+ "INSERT INTO services (project_id, type, created_at, updated_at, active, push_events, issues_events, merge_requests_events, tag_push_events, note_events, build_events, properties) " \
"SELECT projects.id, 'BuildsEmailService', ci_services.created_at, ci_services.updated_at, " \
"#{true_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{false_value}, #{true_value}, " \
- "CONCAT('{\"notify_only_broken_builds\":\"', #{convert_bool('ci_projects.email_only_broken_builds')}, " \
- "'\",\"add_pusher\":\"', #{convert_bool('ci_projects.email_add_pusher')}, " \
- "'\",\"recipients\":\"', #{escape_text('ci_projects.email_recipients')}, " \
+ "CONCAT('{\"notify_only_broken_builds\":\"', #{convert_bool("ci_projects.email_only_broken_builds")}, " \
+ "'\",\"add_pusher\":\"', #{convert_bool("ci_projects.email_add_pusher")}, " \
+ "'\",\"recipients\":\"', #{escape_text("ci_projects.email_recipients")}, " \
"'\"}') " \
- 'FROM ci_services ' \
- 'JOIN ci_projects ON ci_services.project_id = ci_projects.id ' \
- 'JOIN projects ON ci_projects.gitlab_id = projects.id ' \
+ "FROM ci_services " \
+ "JOIN ci_projects ON ci_services.project_id = ci_projects.id " \
+ "JOIN projects ON ci_projects.gitlab_id = projects.id " \
"WHERE ci_services.type = 'Ci::MailService' AND ci_services.active"
)
end
@@ -39,7 +39,7 @@ class MigrateCiEmails < ActiveRecord::Migration[4.2]
"CASE WHEN #{name} IS TRUE THEN '1' ELSE '0' END"
else
# MySQL uses TINYINT
- "#{name}"
+ name.to_s
end
end
end
diff --git a/db/migrate/20151210125232_migrate_ci_slack_service.rb b/db/migrate/20151210125232_migrate_ci_slack_service.rb
index 72c90f92377..83bcb02e275 100644
--- a/db/migrate/20151210125232_migrate_ci_slack_service.rb
+++ b/db/migrate/20151210125232_migrate_ci_slack_service.rb
@@ -2,15 +2,15 @@ class MigrateCiSlackService < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
def up
- properties_query = 'SELECT properties FROM ci_services ' \
- 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \
+ properties_query = "SELECT properties FROM ci_services " \
+ "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \
- 'LIMIT 1'
+ "LIMIT 1"
- active_query = 'SELECT 1 FROM ci_services ' \
- 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \
+ active_query = "SELECT 1 FROM ci_services " \
+ "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::SlackService' AND ci_services.active " \
- 'LIMIT 1'
+ "LIMIT 1"
# We update the service since services are always generated for project, even if they are inactive
# Activate service and migrate properties if currently the service is not active
diff --git a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
index 5ec0798c38f..f273dbf5fd9 100644
--- a/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
+++ b/db/migrate/20151210125927_migrate_ci_hip_chat_service.rb
@@ -4,14 +4,14 @@ class MigrateCiHipChatService < ActiveRecord::Migration[4.2]
def up
# From properties strip `hipchat_` key
properties_query = "SELECT REPLACE(properties, '\"hipchat_', '\"') FROM ci_services " \
- 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \
+ "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \
- 'LIMIT 1'
+ "LIMIT 1"
- active_query = 'SELECT 1 FROM ci_services ' \
- 'JOIN ci_projects ON ci_services.project_id=ci_projects.id ' \
+ active_query = "SELECT 1 FROM ci_services " \
+ "JOIN ci_projects ON ci_services.project_id=ci_projects.id " \
"WHERE ci_projects.gitlab_id=services.project_id AND ci_services.type='Ci::HipChatService' AND ci_services.active " \
- 'LIMIT 1'
+ "LIMIT 1"
# We update the service since services are always generated for project, even if they are inactive
# Activate service and migrate properties if currently the service is not active
diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb
index f7573ad1a8d..b6db8f81d15 100644
--- a/db/migrate/20151210125930_migrate_ci_to_project.rb
+++ b/db/migrate/20151210125930_migrate_ci_to_project.rb
@@ -1,16 +1,16 @@
class MigrateCiToProject < ActiveRecord::Migration[4.2]
def up
- migrate_project_id_for_table('ci_runner_projects')
- migrate_project_id_for_table('ci_triggers')
- migrate_project_id_for_table('ci_variables')
+ migrate_project_id_for_table("ci_runner_projects")
+ migrate_project_id_for_table("ci_triggers")
+ migrate_project_id_for_table("ci_variables")
migrate_project_id_for_builds
- migrate_project_column('id', 'ci_id')
- migrate_project_column('shared_runners_enabled', 'shared_runners_enabled')
- migrate_project_column('token', 'runners_token')
- migrate_project_column('coverage_regex', 'build_coverage_regex')
- migrate_project_column('allow_git_fetch', 'build_allow_git_fetch')
- migrate_project_column('timeout', 'build_timeout')
+ migrate_project_column("id", "ci_id")
+ migrate_project_column("shared_runners_enabled", "shared_runners_enabled")
+ migrate_project_column("token", "runners_token")
+ migrate_project_column("coverage_regex", "build_coverage_regex")
+ migrate_project_column("allow_git_fetch", "build_allow_git_fetch")
+ migrate_project_column("timeout", "build_timeout")
migrate_ci_service
end
@@ -24,14 +24,14 @@ class MigrateCiToProject < ActiveRecord::Migration[4.2]
end
def migrate_project_id_for_builds
- subquery = 'SELECT gl_project_id FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id'
+ subquery = "SELECT gl_project_id FROM ci_commits WHERE ci_commits.id = ci_builds.commit_id"
execute("UPDATE ci_builds SET gl_project_id=(#{subquery}) WHERE gl_project_id IS NULL")
end
def migrate_project_column(column, new_column = nil)
new_column ||= column
subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id " \
- 'ORDER BY ci_projects.updated_at DESC LIMIT 1'
+ "ORDER BY ci_projects.updated_at DESC LIMIT 1"
execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL")
end
diff --git a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb
index 6254017615b..e0d0b45bdd3 100644
--- a/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb
+++ b/db/migrate/20160129135155_remove_dot_atom_path_ending_of_projects.rb
@@ -39,7 +39,7 @@ class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration[4.2]
private
def cleaned_path
- @_cleaned_path ||= @path.gsub(/\.atom\z/, '-atom')
+ @_cleaned_path ||= @path.gsub(/\.atom\z/, "-atom")
end
def path_exists?(path)
@@ -53,7 +53,7 @@ class RemoveDotAtomPathEndingOfProjects < ActiveRecord::Migration[4.2]
def up
projects_with_dot_atom.each do |project|
- project_path = ProjectPath.new(project['path'], project['id'], project['namespace_path'], project['namespace_id'])
+ project_path = ProjectPath.new(project["path"], project["id"], project["namespace_path"], project["namespace_id"])
clean_path(project_path) if rename_project_repo(project_path)
end
end
diff --git a/db/migrate/20160328115649_migrate_new_notification_setting.rb b/db/migrate/20160328115649_migrate_new_notification_setting.rb
index 5ba09e75145..5223c68b9e1 100644
--- a/db/migrate/20160328115649_migrate_new_notification_setting.rb
+++ b/db/migrate/20160328115649_migrate_new_notification_setting.rb
@@ -7,7 +7,7 @@
#
class MigrateNewNotificationSetting < ActiveRecord::Migration[4.2]
def up
- timestamp = Time.now.strftime('%F %T')
+ timestamp = Time.now.strftime("%F %T")
execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members WHERE user_id IS NOT NULL"
end
diff --git a/db/migrate/20160415062917_create_personal_access_tokens.rb b/db/migrate/20160415062917_create_personal_access_tokens.rb
index 43599db799e..b0fb68b002d 100644
--- a/db/migrate/20160415062917_create_personal_access_tokens.rb
+++ b/db/migrate/20160415062917_create_personal_access_tokens.rb
@@ -3,7 +3,7 @@ class CreatePersonalAccessTokens < ActiveRecord::Migration[4.2]
def change
create_table :personal_access_tokens do |t|
t.references :user, index: true, foreign_key: true, null: false
- t.string :token, index: { unique: true }, null: false
+ t.string :token, index: {unique: true}, null: false
t.string :name, null: false
t.boolean :revoked, default: false
t.datetime :expires_at
diff --git a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
index af2820986f0..1c4282a4cae 100644
--- a/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
+++ b/db/migrate/20160416182152_convert_award_note_to_emoji_award.rb
@@ -18,7 +18,7 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration[4.2]
def migrate_postgresql
connection.transaction do
- execute 'LOCK notes IN EXCLUSIVE MODE'
+ execute "LOCK notes IN EXCLUSIVE MODE"
execute "INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true)"
execute "DELETE FROM notes WHERE is_award = true"
remove_column :notes, :is_award, :boolean
@@ -26,11 +26,11 @@ class ConvertAwardNoteToEmojiAward < ActiveRecord::Migration[4.2]
end
def migrate_mysql
- execute 'LOCK TABLES notes WRITE, award_emoji WRITE;'
- execute 'INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);'
+ execute "LOCK TABLES notes WRITE, award_emoji WRITE;"
+ execute "INSERT INTO award_emoji (awardable_type, awardable_id, user_id, name, created_at, updated_at) (SELECT noteable_type, noteable_id, author_id, note, created_at, updated_at FROM notes WHERE is_award = true);"
execute "DELETE FROM notes WHERE is_award = true"
remove_column :notes, :is_award, :boolean
ensure
- execute 'UNLOCK TABLES'
+ execute "UNLOCK TABLES"
end
end
diff --git a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb b/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb
index cf842a684a6..f8e8397a0be 100644
--- a/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb
+++ b/db/migrate/20160419122101_add_only_allow_merge_if_build_succeeds_to_projects.rb
@@ -5,9 +5,9 @@ class AddOnlyAllowMergeIfBuildSucceedsToProjects < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:projects,
- :only_allow_merge_if_build_succeeds,
- :boolean,
- default: false)
+ :only_allow_merge_if_build_succeeds,
+ :boolean,
+ default: false)
end
def down
diff --git a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb b/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb
index 03ec29b9951..f04e98407ee 100644
--- a/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb
+++ b/db/migrate/20160504112519_add_run_untagged_to_ci_runner.rb
@@ -4,7 +4,7 @@ class AddRunUntaggedToCiRunner < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:ci_runners, :run_untagged, :boolean,
- default: true, allow_null: false)
+ default: true, allow_null: false)
end
def down
diff --git a/db/migrate/20160509091049_add_locked_to_ci_runner.rb b/db/migrate/20160509091049_add_locked_to_ci_runner.rb
index e19db5a4504..10c5de74b70 100644
--- a/db/migrate/20160509091049_add_locked_to_ci_runner.rb
+++ b/db/migrate/20160509091049_add_locked_to_ci_runner.rb
@@ -4,7 +4,7 @@ class AddLockedToCiRunner < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:ci_runners, :locked, :boolean,
- default: false, allow_null: false)
+ default: false, allow_null: false)
end
def down
diff --git a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb
index 0d8c4bf011c..b9c35307c39 100644
--- a/db/migrate/20160603180330_remove_duplicated_notification_settings.rb
+++ b/db/migrate/20160603180330_remove_duplicated_notification_settings.rb
@@ -1,6 +1,6 @@
class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration[4.2]
def up
- duplicates = exec_query(%Q{
+ duplicates = exec_query(%{
SELECT user_id, source_type, source_id
FROM notification_settings
GROUP BY user_id, source_type, source_id
@@ -8,11 +8,11 @@ class RemoveDuplicatedNotificationSettings < ActiveRecord::Migration[4.2]
})
duplicates.each do |row|
- uid = row['user_id']
- stype = connection.quote(row['source_type'])
- sid = row['source_id']
+ uid = row["user_id"]
+ stype = connection.quote(row["source_type"])
+ sid = row["source_id"]
- execute(%Q{
+ execute(%{
DELETE FROM notification_settings
WHERE user_id = #{uid}
AND source_type = #{stype}
diff --git a/db/migrate/20160608195742_add_repository_storage_to_projects.rb b/db/migrate/20160608195742_add_repository_storage_to_projects.rb
index 2b20c9fbd5f..4586b2c7141 100644
--- a/db/migrate/20160608195742_add_repository_storage_to_projects.rb
+++ b/db/migrate/20160608195742_add_repository_storage_to_projects.rb
@@ -4,7 +4,7 @@ class AddRepositoryStorageToProjects < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_column_with_default(:projects, :repository_storage, :string, default: 'default')
+ add_column_with_default(:projects, :repository_storage, :string, default: "default")
end
def down
diff --git a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb b/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb
index 9b5cfc67d5a..614f773da20 100644
--- a/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb
+++ b/db/migrate/20160608211215_add_user_default_external_to_application_settings.rb
@@ -4,7 +4,7 @@ class AddUserDefaultExternalToApplicationSettings < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:application_settings, :user_default_external, :boolean,
- default: false, allow_null: false)
+ default: false, allow_null: false)
end
def down
diff --git a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb
index 1ac65997403..22c624c4a86 100644
--- a/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb
+++ b/db/migrate/20160610194713_remove_deprecated_issues_tracker_columns_from_projects.rb
@@ -1,7 +1,7 @@
# rubocop:disable Migration/RemoveColumn
class RemoveDeprecatedIssuesTrackerColumnsFromProjects < ActiveRecord::Migration[4.2]
def change
- remove_column :projects, :issues_tracker, :string, default: 'gitlab', null: false
+ remove_column :projects, :issues_tracker, :string, default: "gitlab", null: false
remove_column :projects, :issues_tracker_id, :string
end
end
diff --git a/db/migrate/20160610201627_migrate_users_notification_level.rb b/db/migrate/20160610201627_migrate_users_notification_level.rb
index 553b7f074f2..589fc7f9ce9 100644
--- a/db/migrate/20160610201627_migrate_users_notification_level.rb
+++ b/db/migrate/20160610201627_migrate_users_notification_level.rb
@@ -7,7 +7,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- execute(%Q{
+ execute(%{
INSERT INTO notification_settings
(user_id, level, created_at, updated_at)
(SELECT id, notification_level, created_at, updated_at FROM users WHERE notification_level != 1)
@@ -17,7 +17,7 @@ class MigrateUsersNotificationLevel < ActiveRecord::Migration[4.2]
# Migrates from notification settings back to user notification_level
# If no value is found the default level of 1 will be used
def down
- execute(%Q{
+ execute(%{
UPDATE users u SET
notification_level = COALESCE((SELECT level FROM notification_settings WHERE user_id = u.id AND source_type IS NULL), 1)
})
diff --git a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb b/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb
index a1bc0e5cd86..3b83e3630eb 100644
--- a/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb
+++ b/db/migrate/20160614182521_add_repository_storage_to_application_settings.rb
@@ -1,5 +1,5 @@
class AddRepositoryStorageToApplicationSettings < ActiveRecord::Migration[4.2]
def change
- add_column :application_settings, :repository_storage, :string, default: 'default'
+ add_column :application_settings, :repository_storage, :string, default: "default"
end
end
diff --git a/db/migrate/20160616102642_remove_duplicated_keys.rb b/db/migrate/20160616102642_remove_duplicated_keys.rb
index 0b896108292..8b1e78f2463 100644
--- a/db/migrate/20160616102642_remove_duplicated_keys.rb
+++ b/db/migrate/20160616102642_remove_duplicated_keys.rb
@@ -1,8 +1,8 @@
class RemoveDuplicatedKeys < ActiveRecord::Migration[4.2]
def up
select_all("SELECT fingerprint FROM #{quote_table_name(:keys)} GROUP BY fingerprint HAVING COUNT(*) > 1").each do |row|
- fingerprint = connection.quote(row['fingerprint'])
- execute(%Q{
+ fingerprint = connection.quote(row["fingerprint"])
+ execute(%{
DELETE FROM #{quote_table_name(:keys)}
WHERE fingerprint = #{fingerprint}
AND id != (
diff --git a/db/migrate/20160705054938_add_protected_branches_push_access.rb b/db/migrate/20160705054938_add_protected_branches_push_access.rb
index 314d90efa90..8834143c74f 100644
--- a/db/migrate/20160705054938_add_protected_branches_push_access.rb
+++ b/db/migrate/20160705054938_add_protected_branches_push_access.rb
@@ -7,7 +7,7 @@ class AddProtectedBranchesPushAccess < ActiveRecord::Migration[4.2]
def change
create_table :protected_branch_push_access_levels do |t|
- t.references :protected_branch, index: { name: "index_protected_branch_push_access" }, foreign_key: true, null: false
+ t.references :protected_branch, index: {name: "index_protected_branch_push_access"}, foreign_key: true, null: false
# Gitlab::Access::MAINTAINER == 40
t.integer :access_level, default: 40, null: false
diff --git a/db/migrate/20160705054952_add_protected_branches_merge_access.rb b/db/migrate/20160705054952_add_protected_branches_merge_access.rb
index 672e0e291db..d71bed22e95 100644
--- a/db/migrate/20160705054952_add_protected_branches_merge_access.rb
+++ b/db/migrate/20160705054952_add_protected_branches_merge_access.rb
@@ -7,7 +7,7 @@ class AddProtectedBranchesMergeAccess < ActiveRecord::Migration[4.2]
def change
create_table :protected_branch_merge_access_levels do |t|
- t.references :protected_branch, index: { name: "index_protected_branch_merge_access" }, foreign_key: true, null: false
+ t.references :protected_branch, index: {name: "index_protected_branch_merge_access"}, foreign_key: true, null: false
# Gitlab::Access::MAINTAINER == 40
t.integer :access_level, default: 40, null: false
diff --git a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb
index 0b553182a81..2ae64d64fd9 100644
--- a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb
+++ b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb
@@ -16,6 +16,6 @@ class RemoveAwardEmojisWithNoUser < ActiveRecord::Migration[4.2]
# disable_ddl_transaction!
def up
- AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all # rubocop: disable DestroyAll
+ AwardEmoji.joins("LEFT JOIN users ON users.id = user_id").where("users.id IS NULL").destroy_all # rubocop: disable DestroyAll
end
end
diff --git a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb
index d8b4696a246..40772b9056c 100644
--- a/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb
+++ b/db/migrate/20160725104020_merge_request_diff_remove_uniq.rb
@@ -9,7 +9,7 @@ class MergeRequestDiffRemoveUniq < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- constraint_name = 'merge_request_diffs_merge_request_id_key'
+ constraint_name = "merge_request_diffs_merge_request_id_key"
transaction do
if index_exists?(:merge_request_diffs, :merge_request_id)
diff --git a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb b/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb
index fc3e9f03c74..ef90af06adf 100644
--- a/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb
+++ b/db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb
@@ -7,7 +7,7 @@ class AddPipelineEventsToWebHooks < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:web_hooks, :pipeline_events, :boolean,
- default: false, allow_null: false)
+ default: false, allow_null: false)
end
def down
diff --git a/db/migrate/20160728103734_add_pipeline_events_to_services.rb b/db/migrate/20160728103734_add_pipeline_events_to_services.rb
index 421859ff5fd..10ccf20ad5a 100644
--- a/db/migrate/20160728103734_add_pipeline_events_to_services.rb
+++ b/db/migrate/20160728103734_add_pipeline_events_to_services.rb
@@ -7,7 +7,7 @@ class AddPipelineEventsToServices < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:services, :pipeline_events, :boolean,
- default: false, allow_null: false)
+ default: false, allow_null: false)
end
def down
diff --git a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb
index 02e417e376f..29a687117d5 100644
--- a/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb
+++ b/db/migrate/20160729173930_remove_project_id_from_spam_logs.rb
@@ -11,7 +11,7 @@ class RemoveProjectIdFromSpamLogs < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Removing a column that contains data that is not used anywhere.'
+ DOWNTIME_REASON = "Removing a column that contains data that is not used anywhere."
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
diff --git a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb b/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb
index 738b93912b6..11a496bb8cd 100644
--- a/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb
+++ b/db/migrate/20160810102349_remove_ci_runner_trigram_indexes.rb
@@ -13,15 +13,15 @@ class RemoveCiRunnerTrigramIndexes < ActiveRecord::Migration[4.2]
return unless Gitlab::Database.postgresql?
transaction do
- execute 'DROP INDEX IF EXISTS index_ci_runners_on_token_trigram;'
- execute 'DROP INDEX IF EXISTS index_ci_runners_on_description_trigram;'
+ execute "DROP INDEX IF EXISTS index_ci_runners_on_token_trigram;"
+ execute "DROP INDEX IF EXISTS index_ci_runners_on_description_trigram;"
end
end
def down
return unless Gitlab::Database.postgresql?
- execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_token_trigram ON ci_runners USING gin(token gin_trgm_ops);'
- execute 'CREATE INDEX CONCURRENTLY index_ci_runners_on_description_trigram ON ci_runners USING gin(description gin_trgm_ops);'
+ execute "CREATE INDEX CONCURRENTLY index_ci_runners_on_token_trigram ON ci_runners USING gin(token gin_trgm_ops);"
+ execute "CREATE INDEX CONCURRENTLY index_ci_runners_on_description_trigram ON ci_runners USING gin(description gin_trgm_ops);"
end
end
diff --git a/db/migrate/20160810142633_remove_redundant_indexes.rb b/db/migrate/20160810142633_remove_redundant_indexes.rb
index 91f82cf9afa..5ad3f584cf7 100644
--- a/db/migrate/20160810142633_remove_redundant_indexes.rb
+++ b/db/migrate/20160810142633_remove_redundant_indexes.rb
@@ -11,51 +11,51 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2]
def up
indexes = [
- [:ci_taggings, 'ci_taggings_idx'],
- [:audit_events, 'index_audit_events_on_author_id'],
- [:audit_events, 'index_audit_events_on_type'],
- [:ci_builds, 'index_ci_builds_on_erased_by_id'],
- [:ci_builds, 'index_ci_builds_on_project_id_and_commit_id'],
- [:ci_builds, 'index_ci_builds_on_type'],
- [:ci_commits, 'index_ci_commits_on_project_id'],
- [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at'],
- [:ci_commits, 'index_ci_commits_on_project_id_and_committed_at_and_id'],
- [:ci_commits, 'index_ci_commits_on_project_id_and_sha'],
- [:ci_commits, 'index_ci_commits_on_sha'],
- [:ci_events, 'index_ci_events_on_created_at'],
- [:ci_events, 'index_ci_events_on_is_admin'],
- [:ci_events, 'index_ci_events_on_project_id'],
- [:ci_jobs, 'index_ci_jobs_on_deleted_at'],
- [:ci_jobs, 'index_ci_jobs_on_project_id'],
- [:ci_projects, 'index_ci_projects_on_gitlab_id'],
- [:ci_projects, 'index_ci_projects_on_shared_runners_enabled'],
- [:ci_services, 'index_ci_services_on_project_id'],
- [:ci_sessions, 'index_ci_sessions_on_session_id'],
- [:ci_sessions, 'index_ci_sessions_on_updated_at'],
- [:ci_tags, 'index_ci_tags_on_name'],
- [:ci_triggers, 'index_ci_triggers_on_deleted_at'],
- [:identities, 'index_identities_on_created_at_and_id'],
- [:issues, 'index_issues_on_title'],
- [:keys, 'index_keys_on_created_at_and_id'],
- [:members, 'index_members_on_created_at_and_id'],
- [:members, 'index_members_on_type'],
- [:milestones, 'index_milestones_on_created_at_and_id'],
- [:namespaces, 'index_namespaces_on_visibility_level'],
- [:projects, 'index_projects_on_builds_enabled_and_shared_runners_enabled'],
- [:services, 'index_services_on_category'],
- [:services, 'index_services_on_created_at_and_id'],
- [:services, 'index_services_on_default'],
- [:snippets, 'index_snippets_on_created_at'],
- [:snippets, 'index_snippets_on_created_at_and_id'],
- [:todos, 'index_todos_on_state'],
- [:web_hooks, 'index_web_hooks_on_created_at_and_id'],
+ [:ci_taggings, "ci_taggings_idx"],
+ [:audit_events, "index_audit_events_on_author_id"],
+ [:audit_events, "index_audit_events_on_type"],
+ [:ci_builds, "index_ci_builds_on_erased_by_id"],
+ [:ci_builds, "index_ci_builds_on_project_id_and_commit_id"],
+ [:ci_builds, "index_ci_builds_on_type"],
+ [:ci_commits, "index_ci_commits_on_project_id"],
+ [:ci_commits, "index_ci_commits_on_project_id_and_committed_at"],
+ [:ci_commits, "index_ci_commits_on_project_id_and_committed_at_and_id"],
+ [:ci_commits, "index_ci_commits_on_project_id_and_sha"],
+ [:ci_commits, "index_ci_commits_on_sha"],
+ [:ci_events, "index_ci_events_on_created_at"],
+ [:ci_events, "index_ci_events_on_is_admin"],
+ [:ci_events, "index_ci_events_on_project_id"],
+ [:ci_jobs, "index_ci_jobs_on_deleted_at"],
+ [:ci_jobs, "index_ci_jobs_on_project_id"],
+ [:ci_projects, "index_ci_projects_on_gitlab_id"],
+ [:ci_projects, "index_ci_projects_on_shared_runners_enabled"],
+ [:ci_services, "index_ci_services_on_project_id"],
+ [:ci_sessions, "index_ci_sessions_on_session_id"],
+ [:ci_sessions, "index_ci_sessions_on_updated_at"],
+ [:ci_tags, "index_ci_tags_on_name"],
+ [:ci_triggers, "index_ci_triggers_on_deleted_at"],
+ [:identities, "index_identities_on_created_at_and_id"],
+ [:issues, "index_issues_on_title"],
+ [:keys, "index_keys_on_created_at_and_id"],
+ [:members, "index_members_on_created_at_and_id"],
+ [:members, "index_members_on_type"],
+ [:milestones, "index_milestones_on_created_at_and_id"],
+ [:namespaces, "index_namespaces_on_visibility_level"],
+ [:projects, "index_projects_on_builds_enabled_and_shared_runners_enabled"],
+ [:services, "index_services_on_category"],
+ [:services, "index_services_on_created_at_and_id"],
+ [:services, "index_services_on_default"],
+ [:snippets, "index_snippets_on_created_at"],
+ [:snippets, "index_snippets_on_created_at_and_id"],
+ [:todos, "index_todos_on_state"],
+ [:web_hooks, "index_web_hooks_on_created_at_and_id"],
# These indexes _may_ be used but they can be replaced by other existing
# indexes.
# There's already a composite index on (project_id, iid) which means that
# a separate index for _just_ project_id is not needed.
- [:issues, 'index_issues_on_project_id'],
+ [:issues, "index_issues_on_project_id"],
# These are all composite indexes for the columns (created_at, id). In all
# these cases there's already a standalone index for "created_at" which
@@ -64,12 +64,12 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2]
# Because the "id" column of these composite indexes is never needed (due
# to "id" already being indexed as its a primary key) these composite
# indexes are useless.
- [:issues, 'index_issues_on_created_at_and_id'],
- [:merge_requests, 'index_merge_requests_on_created_at_and_id'],
- [:namespaces, 'index_namespaces_on_created_at_and_id'],
- [:notes, 'index_notes_on_created_at_and_id'],
- [:projects, 'index_projects_on_created_at_and_id'],
- [:users, 'index_users_on_created_at_and_id']
+ [:issues, "index_issues_on_created_at_and_id"],
+ [:merge_requests, "index_merge_requests_on_created_at_and_id"],
+ [:namespaces, "index_namespaces_on_created_at_and_id"],
+ [:notes, "index_notes_on_created_at_and_id"],
+ [:projects, "index_projects_on_created_at_and_id"],
+ [:users, "index_users_on_created_at_and_id"],
]
transaction do
@@ -94,7 +94,7 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2]
[:issues, :merge_requests, :namespaces, :notes, :projects, :users].each do |table|
add_concurrent_index(table, [:created_at, :id],
- name: "index_#{table}_on_created_at_and_id")
+ name: "index_#{table}_on_created_at_and_id")
end
end
@@ -106,8 +106,8 @@ class RemoveRedundantIndexes < ActiveRecord::Migration[4.2]
end
def indexes_for_table
- @indexes_for_table ||= Hash.new do |hash, table_name|
+ @indexes_for_table ||= Hash.new { |hash, table_name|
hash[table_name] = indexes(table_name).map(&:name)
- end
+ }
end
end
diff --git a/db/migrate/20160823081327_change_merge_error_to_text.rb b/db/migrate/20160823081327_change_merge_error_to_text.rb
index 23b4f35a776..158205d9d06 100644
--- a/db/migrate/20160823081327_change_merge_error_to_text.rb
+++ b/db/migrate/20160823081327_change_merge_error_to_text.rb
@@ -2,7 +2,7 @@ class ChangeMergeErrorToText < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration requires downtime because it alters a column from varchar(255) to text.'
+ DOWNTIME_REASON = "This migration requires downtime because it alters a column from varchar(255) to text."
def change
change_column :merge_requests, :merge_error, :text, limit: 65535
diff --git a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb b/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb
index 4c320123088..6fb6abfa395 100644
--- a/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb
+++ b/db/migrate/20160823083941_add_column_scopes_to_personal_access_tokens.rb
@@ -10,7 +10,7 @@ class AddColumnScopesToPersonalAccessTokens < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_column_with_default :personal_access_tokens, :scopes, :string, default: ['api'].to_yaml
+ add_column_with_default :personal_access_tokens, :scopes, :string, default: ["api"].to_yaml
end
def down
diff --git a/db/migrate/20160824124900_add_table_issue_metrics.rb b/db/migrate/20160824124900_add_table_issue_metrics.rb
index 4f34f377e22..86e0334ddba 100644
--- a/db/migrate/20160824124900_add_table_issue_metrics.rb
+++ b/db/migrate/20160824124900_add_table_issue_metrics.rb
@@ -10,7 +10,7 @@ class AddTableIssueMetrics < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Adding foreign key'
+ DOWNTIME_REASON = "Adding foreign key"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
@@ -25,11 +25,11 @@ class AddTableIssueMetrics < ActiveRecord::Migration[4.2]
def change
create_table :issue_metrics do |t|
- t.references :issue, index: { name: "index_issue_metrics" }, foreign_key: { on_delete: :cascade }, null: false
+ t.references :issue, index: {name: "index_issue_metrics"}, foreign_key: {on_delete: :cascade}, null: false
- t.datetime 'first_mentioned_in_commit_at'
- t.datetime 'first_associated_with_milestone_at'
- t.datetime 'first_added_to_board_at'
+ t.datetime "first_mentioned_in_commit_at"
+ t.datetime "first_associated_with_milestone_at"
+ t.datetime "first_added_to_board_at"
t.timestamps null: false
end
diff --git a/db/migrate/20160825052008_add_table_merge_request_metrics.rb b/db/migrate/20160825052008_add_table_merge_request_metrics.rb
index 150f698869d..06e56a7fbb3 100644
--- a/db/migrate/20160825052008_add_table_merge_request_metrics.rb
+++ b/db/migrate/20160825052008_add_table_merge_request_metrics.rb
@@ -10,7 +10,7 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Adding foreign key'
+ DOWNTIME_REASON = "Adding foreign key"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
@@ -25,12 +25,12 @@ class AddTableMergeRequestMetrics < ActiveRecord::Migration[4.2]
def change
create_table :merge_request_metrics do |t|
- t.references :merge_request, index: { name: "index_merge_request_metrics" }, foreign_key: { on_delete: :cascade }, null: false
+ t.references :merge_request, index: {name: "index_merge_request_metrics"}, foreign_key: {on_delete: :cascade}, null: false
- t.datetime 'latest_build_started_at'
- t.datetime 'latest_build_finished_at'
- t.datetime 'first_deployed_to_production_at', index: true
- t.datetime 'merged_at'
+ t.datetime "latest_build_started_at"
+ t.datetime "latest_build_finished_at"
+ t.datetime "first_deployed_to_production_at", index: true
+ t.datetime "merged_at"
t.timestamps null: false
end
diff --git a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb
index 18c0f0be3eb..01f2c3dc7f2 100644
--- a/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb
+++ b/db/migrate/20160827011312_ensure_lock_version_has_no_default.rb
@@ -7,8 +7,8 @@ class EnsureLockVersionHasNoDefault < ActiveRecord::Migration[4.2]
change_column_default :issues, :lock_version, nil
change_column_default :merge_requests, :lock_version, nil
- execute('UPDATE issues SET lock_version = 1 WHERE lock_version = 0')
- execute('UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0')
+ execute("UPDATE issues SET lock_version = 1 WHERE lock_version = 0")
+ execute("UPDATE merge_requests SET lock_version = 1 WHERE lock_version = 0")
end
def down
diff --git a/db/migrate/20160829114652_add_markdown_cache_columns.rb b/db/migrate/20160829114652_add_markdown_cache_columns.rb
index b1c5e38c3c4..a4ac9eca16f 100644
--- a/db/migrate/20160829114652_add_markdown_cache_columns.rb
+++ b/db/migrate/20160829114652_add_markdown_cache_columns.rb
@@ -14,7 +14,7 @@ class AddMarkdownCacheColumns < ActiveRecord::Migration[4.2]
:sign_in_text,
:help_page_text,
:shared_runners_text,
- :after_sign_up_text
+ :after_sign_up_text,
],
broadcast_messages: [:message],
issues: [:title, :description],
@@ -25,7 +25,7 @@ class AddMarkdownCacheColumns < ActiveRecord::Migration[4.2]
notes: [:note],
projects: [:description],
releases: [:description],
- snippets: [:title, :content]
+ snippets: [:title, :content],
}.freeze
def change
diff --git a/db/migrate/20160831214543_migrate_project_features.rb b/db/migrate/20160831214543_migrate_project_features.rb
index ba7ffd7c9f2..a5f686d8c26 100644
--- a/db/migrate/20160831214543_migrate_project_features.rb
+++ b/db/migrate/20160831214543_migrate_project_features.rb
@@ -10,7 +10,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration[4.2]
def up
sql =
- %Q{
+ %{
INSERT INTO project_features(project_id, issues_access_level, merge_requests_access_level, wiki_access_level,
builds_access_level, snippets_access_level, created_at, updated_at)
SELECT
@@ -29,7 +29,7 @@ class MigrateProjectFeatures < ActiveRecord::Migration[4.2]
end
def down
- sql = %Q{
+ sql = %{
UPDATE projects
SET
issues_enabled = COALESCE((SELECT CASE WHEN issues_access_level = 20 THEN true ELSE false END AS issues_enabled FROM project_features WHERE project_features.project_id = projects.id), true),
diff --git a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
index 6c2dc58876e..754207f388f 100644
--- a/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
+++ b/db/migrate/20160902122721_drop_gitorious_field_from_application_settings.rb
@@ -5,19 +5,19 @@ class DropGitoriousFieldFromApplicationSettings < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- require 'yaml'
+ require "yaml"
- import_sources = connection.execute('SELECT import_sources FROM application_settings;')
+ import_sources = connection.execute("SELECT import_sources FROM application_settings;")
return unless import_sources.first # support empty databases
yaml = if Gitlab::Database.postgresql?
- import_sources.values[0][0]
- else
- import_sources.first[0]
- end
+ import_sources.values[0][0]
+ else
+ import_sources.first[0]
+ end
yaml = YAML.safe_load(yaml)
- yaml.delete 'gitorious'
+ yaml.delete "gitorious"
# No need for a WHERE clause as there is only one
connection.execute("UPDATE application_settings SET import_sources = #{update_yaml(yaml)}")
diff --git a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb
index 51650c68170..bfab62f83c9 100644
--- a/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb
+++ b/db/migrate/20160913162434_remove_projects_pushes_since_gc.rb
@@ -7,7 +7,7 @@ class RemoveProjectsPushesSinceGc < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration removes an existing column'
+ DOWNTIME_REASON = "This migration removes an existing column"
disable_ddl_transaction!
diff --git a/db/migrate/20160913212128_change_artifacts_size_column.rb b/db/migrate/20160913212128_change_artifacts_size_column.rb
index f2c2aaff9a8..f2017fc07da 100644
--- a/db/migrate/20160913212128_change_artifacts_size_column.rb
+++ b/db/migrate/20160913212128_change_artifacts_size_column.rb
@@ -3,7 +3,7 @@ class ChangeArtifactsSizeColumn < ActiveRecord::Migration[4.2]
DOWNTIME = true
- DOWNTIME_REASON = 'Changing an integer column size requires a full table rewrite.'
+ DOWNTIME_REASON = "Changing an integer column size requires a full table rewrite."
def up
change_column :ci_builds, :artifacts_size, :integer, limit: 8
diff --git a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb
index 3efe8c8901b..dc405b25054 100644
--- a/db/migrate/20160915042921_create_merge_requests_closing_issues.rb
+++ b/db/migrate/20160915042921_create_merge_requests_closing_issues.rb
@@ -11,7 +11,7 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Adding foreign keys'
+ DOWNTIME_REASON = "Adding foreign keys"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
@@ -26,8 +26,8 @@ class CreateMergeRequestsClosingIssues < ActiveRecord::Migration[4.2]
def change
create_table :merge_requests_closing_issues do |t|
- t.references :merge_request, foreign_key: { on_delete: :cascade }, index: true, null: false
- t.references :issue, foreign_key: { on_delete: :cascade }, index: true, null: false
+ t.references :merge_request, foreign_key: {on_delete: :cascade}, index: true, null: false
+ t.references :issue, foreign_key: {on_delete: :cascade}, index: true, null: false
t.timestamps null: false
end
diff --git a/db/migrate/20160919144305_add_type_to_labels.rb b/db/migrate/20160919144305_add_type_to_labels.rb
index f897646d264..ab959032a41 100644
--- a/db/migrate/20160919144305_add_type_to_labels.rb
+++ b/db/migrate/20160919144305_add_type_to_labels.rb
@@ -3,14 +3,14 @@ class AddTypeToLabels < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Labels will not work as expected until this migration is complete.'
+ DOWNTIME_REASON = "Labels will not work as expected until this migration is complete."
disable_ddl_transaction!
def change
add_column :labels, :type, :string
- update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query|
+ update_column_in_batches(:labels, :type, "ProjectLabel") do |table, query|
query.where(table[:project_id].not_eq(nil))
end
end
diff --git a/db/migrate/20161007133303_precalculate_trending_projects.rb b/db/migrate/20161007133303_precalculate_trending_projects.rb
index c7a678c9d8f..0131d1be403 100644
--- a/db/migrate/20161007133303_precalculate_trending_projects.rb
+++ b/db/migrate/20161007133303_precalculate_trending_projects.rb
@@ -8,7 +8,7 @@ class PrecalculateTrendingProjects < ActiveRecord::Migration[4.2]
def up
create_table :trending_projects do |t|
- t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: false
end
timestamp = connection.quote(1.month.ago)
diff --git a/db/migrate/20161010142410_create_project_authorizations.rb b/db/migrate/20161010142410_create_project_authorizations.rb
index b340a4ece19..7f3b42a9e41 100644
--- a/db/migrate/20161010142410_create_project_authorizations.rb
+++ b/db/migrate/20161010142410_create_project_authorizations.rb
@@ -5,11 +5,11 @@ class CreateProjectAuthorizations < ActiveRecord::Migration[4.2]
def change
create_table :project_authorizations do |t|
- t.references :user, foreign_key: { on_delete: :cascade }
- t.references :project, foreign_key: { on_delete: :cascade }
+ t.references :user, foreign_key: {on_delete: :cascade}
+ t.references :project, foreign_key: {on_delete: :cascade}
t.integer :access_level
- t.index [:user_id, :project_id, :access_level], unique: true, name: 'index_project_authorizations_on_user_id_project_id_access_level'
+ t.index [:user_id, :project_id, :access_level], unique: true, name: "index_project_authorizations_on_user_id_project_id_access_level"
end
end
end
diff --git a/db/migrate/20161014173530_create_label_priorities.rb b/db/migrate/20161014173530_create_label_priorities.rb
index c7d60caa7d1..e37785e583c 100644
--- a/db/migrate/20161014173530_create_label_priorities.rb
+++ b/db/migrate/20161014173530_create_label_priorities.rb
@@ -3,14 +3,14 @@ class CreateLabelPriorities < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration adds foreign keys'
+ DOWNTIME_REASON = "This migration adds foreign keys"
disable_ddl_transaction!
def up
create_table :label_priorities do |t|
- t.references :project, foreign_key: { on_delete: :cascade }, null: false
- t.references :label, foreign_key: { on_delete: :cascade }, null: false
+ t.references :project, foreign_key: {on_delete: :cascade}, null: false
+ t.references :label, foreign_key: {on_delete: :cascade}, null: false
t.integer :priority, null: false
t.timestamps null: false
diff --git a/db/migrate/20161017125927_add_unique_index_to_labels.rb b/db/migrate/20161017125927_add_unique_index_to_labels.rb
index b5326789f52..c1e612058f7 100644
--- a/db/migrate/20161017125927_add_unique_index_to_labels.rb
+++ b/db/migrate/20161017125927_add_unique_index_to_labels.rb
@@ -3,14 +3,14 @@ class AddUniqueIndexToLabels < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration removes duplicated labels.'
+ DOWNTIME_REASON = "This migration removes duplicated labels."
disable_ddl_transaction!
def up
- select_all('SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1').each do |label|
- label_title = quote_string(label['title'])
- duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label['project_id']} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label['id'] }
+ select_all("SELECT title, project_id, COUNT(id) as cnt FROM labels GROUP BY project_id, title HAVING COUNT(id) > 1").each do |label|
+ label_title = quote_string(label["title"])
+ duplicated_ids = select_all("SELECT id FROM labels WHERE project_id = #{label["project_id"]} AND title = '#{label_title}' ORDER BY id ASC").map { |label| label["id"] }
label_id = duplicated_ids.first
duplicated_ids.delete(label_id)
diff --git a/db/migrate/20161018024215_migrate_labels_priority.rb b/db/migrate/20161018024215_migrate_labels_priority.rb
index 3e2540c134c..25baadcaa0c 100644
--- a/db/migrate/20161018024215_migrate_labels_priority.rb
+++ b/db/migrate/20161018024215_migrate_labels_priority.rb
@@ -2,7 +2,7 @@ class MigrateLabelsPriority < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Prioritized labels will not work as expected until this migration is complete.'
+ DOWNTIME_REASON = "Prioritized labels will not work as expected until this migration is complete."
disable_ddl_transaction!
diff --git a/db/migrate/20161018024550_remove_priority_from_labels.rb b/db/migrate/20161018024550_remove_priority_from_labels.rb
index e164d959bdf..e760abee85d 100644
--- a/db/migrate/20161018024550_remove_priority_from_labels.rb
+++ b/db/migrate/20161018024550_remove_priority_from_labels.rb
@@ -3,7 +3,7 @@ class RemovePriorityFromLabels < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration removes an existing column'
+ DOWNTIME_REASON = "This migration removes an existing column"
disable_ddl_transaction!
diff --git a/db/migrate/20161018124658_make_project_owners_masters.rb b/db/migrate/20161018124658_make_project_owners_masters.rb
index 132c17388dc..b33aeaed498 100644
--- a/db/migrate/20161018124658_make_project_owners_masters.rb
+++ b/db/migrate/20161018124658_make_project_owners_masters.rb
@@ -8,7 +8,7 @@ class MakeProjectOwnersMasters < ActiveRecord::Migration[4.2]
def up
update_column_in_batches(:members, :access_level, 40) do |table, query|
- query.where(table[:access_level].eq(50).and(table[:source_type].eq('Project')))
+ query.where(table[:access_level].eq(50).and(table[:source_type].eq("Project")))
end
end
diff --git a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb
index fc6d9784638..089ad660b0f 100644
--- a/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb
+++ b/db/migrate/20161019190736_migrate_sidekiq_queues_from_default.rb
@@ -1,4 +1,4 @@
-require 'json'
+require "json"
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
@@ -23,54 +23,54 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration[4.2]
# queue names.
RENAMED_QUEUES = {
gitlab_shell: {
- 'GitGarbageCollectorWorker' => :git_garbage_collector,
- 'ProjectExportWorker' => :project_export,
- 'RepositoryForkWorker' => :repository_fork,
- 'RepositoryImportWorker' => :repository_import
+ "GitGarbageCollectorWorker" => :git_garbage_collector,
+ "ProjectExportWorker" => :project_export,
+ "RepositoryForkWorker" => :repository_fork,
+ "RepositoryImportWorker" => :repository_import,
},
project_web_hook: {
- 'ProjectServiceWorker' => :project_service
+ "ProjectServiceWorker" => :project_service,
},
incoming_email: {
- 'EmailReceiverWorker' => :email_receiver
+ "EmailReceiverWorker" => :email_receiver,
},
mailers: {
- 'EmailsOnPushWorker' => :emails_on_push
+ "EmailsOnPushWorker" => :emails_on_push,
},
default: {
- 'AdminEmailWorker' => :cronjob,
- 'BuildCoverageWorker' => :build,
- 'BuildEmailWorker' => :build,
- 'BuildFinishedWorker' => :build,
- 'BuildHooksWorker' => :build,
- 'BuildSuccessWorker' => :build,
- 'ClearDatabaseCacheWorker' => :clear_database_cache,
- 'DeleteUserWorker' => :delete_user,
- 'ExpireBuildArtifactsWorker' => :cronjob,
- 'ExpireBuildInstanceArtifactsWorker' => :expire_build_instance_artifacts,
- 'GroupDestroyWorker' => :group_destroy,
- 'ImportExportProjectCleanupWorker' => :cronjob,
- 'IrkerWorker' => :irker,
- 'MergeWorker' => :merge,
- 'NewNoteWorker' => :new_note,
- 'PipelineHooksWorker' => :pipeline,
- 'PipelineMetricsWorker' => :pipeline,
- 'PipelineProcessWorker' => :pipeline,
- 'PipelineSuccessWorker' => :pipeline,
- 'PipelineUpdateWorker' => :pipeline,
- 'ProjectCacheWorker' => :project_cache,
- 'ProjectDestroyWorker' => :project_destroy,
- 'PruneOldEventsWorker' => :cronjob,
- 'RemoveExpiredGroupLinksWorker' => :cronjob,
- 'RemoveExpiredMembersWorker' => :cronjob,
- 'RepositoryArchiveCacheWorker' => :cronjob,
- 'RepositoryCheck::BatchWorker' => :cronjob,
- 'RepositoryCheck::ClearWorker' => :repository_check,
- 'RepositoryCheck::SingleRepositoryWorker' => :repository_check,
- 'RequestsProfilesWorker' => :cronjob,
- 'StuckCiBuildsWorker' => :cronjob,
- 'UpdateMergeRequestsWorker' => :update_merge_requests
- }
+ "AdminEmailWorker" => :cronjob,
+ "BuildCoverageWorker" => :build,
+ "BuildEmailWorker" => :build,
+ "BuildFinishedWorker" => :build,
+ "BuildHooksWorker" => :build,
+ "BuildSuccessWorker" => :build,
+ "ClearDatabaseCacheWorker" => :clear_database_cache,
+ "DeleteUserWorker" => :delete_user,
+ "ExpireBuildArtifactsWorker" => :cronjob,
+ "ExpireBuildInstanceArtifactsWorker" => :expire_build_instance_artifacts,
+ "GroupDestroyWorker" => :group_destroy,
+ "ImportExportProjectCleanupWorker" => :cronjob,
+ "IrkerWorker" => :irker,
+ "MergeWorker" => :merge,
+ "NewNoteWorker" => :new_note,
+ "PipelineHooksWorker" => :pipeline,
+ "PipelineMetricsWorker" => :pipeline,
+ "PipelineProcessWorker" => :pipeline,
+ "PipelineSuccessWorker" => :pipeline,
+ "PipelineUpdateWorker" => :pipeline,
+ "ProjectCacheWorker" => :project_cache,
+ "ProjectDestroyWorker" => :project_destroy,
+ "PruneOldEventsWorker" => :cronjob,
+ "RemoveExpiredGroupLinksWorker" => :cronjob,
+ "RemoveExpiredMembersWorker" => :cronjob,
+ "RepositoryArchiveCacheWorker" => :cronjob,
+ "RepositoryCheck::BatchWorker" => :cronjob,
+ "RepositoryCheck::ClearWorker" => :repository_check,
+ "RepositoryCheck::SingleRepositoryWorker" => :repository_check,
+ "RequestsProfilesWorker" => :cronjob,
+ "StuckCiBuildsWorker" => :cronjob,
+ "UpdateMergeRequestsWorker" => :update_merge_requests,
+ },
}.freeze
def up
@@ -94,14 +94,14 @@ class MigrateSidekiqQueuesFromDefault < ActiveRecord::Migration[4.2]
def migrate_from_queue(redis, queue, job_mapping)
while job = redis.lpop("queue:#{queue}")
payload = JSON.parse(job)
- new_queue = job_mapping[payload['class']]
+ new_queue = job_mapping[payload["class"]]
# If we have no target queue to migrate to we're probably dealing with
# some ancient job for which the worker no longer exists. In that case
# there's no sane option we can take, other than just dropping the job.
next unless new_queue
- payload['queue'] = new_queue
+ payload["queue"] = new_queue
redis.lpush("queue:#{new_queue}", JSON.dump(payload))
end
diff --git a/db/migrate/20161019213545_generate_project_feature_for_projects.rb b/db/migrate/20161019213545_generate_project_feature_for_projects.rb
index 587bdf60f70..d30efec30f6 100644
--- a/db/migrate/20161019213545_generate_project_feature_for_projects.rb
+++ b/db/migrate/20161019213545_generate_project_feature_for_projects.rb
@@ -16,7 +16,7 @@ class GenerateProjectFeatureForProjects < ActiveRecord::Migration[4.2]
INSERT INTO project_features
(project_id, merge_requests_access_level, builds_access_level,
issues_access_level, snippets_access_level, wiki_access_level)
- (SELECT projects.id, #{enabled_values.join(',')} FROM projects LEFT OUTER JOIN project_features
+ (SELECT projects.id, #{enabled_values.join(",")} FROM projects LEFT OUTER JOIN project_features
ON project_features.project_id = projects.id
WHERE project_features.id IS NULL)
EOF
diff --git a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
index 60352363e42..34eb7d0747b 100644
--- a/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
+++ b/db/migrate/20161020083353_add_pipeline_id_to_merge_request_metrics.rb
@@ -13,7 +13,7 @@ class AddPipelineIdToMergeRequestMetrics < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Adding a foreign key'
+ DOWNTIME_REASON = "Adding a foreign key"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
diff --git a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb
index d27f8fc38c8..b1b4df2b628 100644
--- a/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb
+++ b/db/migrate/20161024042317_migrate_mailroom_queue_from_default.rb
@@ -1,4 +1,4 @@
-require 'json'
+require "json"
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
@@ -22,9 +22,9 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration[4.2]
# The keys are the old queue names, the values the jobs to move and their new
# queue names.
RENAMED_QUEUES = {
- incoming_email: {
- 'EmailReceiverWorker' => :email_receiver
- }
+ incoming_email: {
+ "EmailReceiverWorker" => :email_receiver,
+ },
}.freeze
def up
@@ -48,14 +48,14 @@ class MigrateMailroomQueueFromDefault < ActiveRecord::Migration[4.2]
def migrate_from_queue(redis, queue, job_mapping)
while job = redis.lpop("queue:#{queue}")
payload = JSON.parse(job)
- new_queue = job_mapping[payload['class']]
+ new_queue = job_mapping[payload["class"]]
# If we have no target queue to migrate to we're probably dealing with
# some ancient job for which the worker no longer exists. In that case
# there's no sane option we can take, other than just dropping the job.
next unless new_queue
- payload['queue'] = new_queue
+ payload["queue"] = new_queue
redis.lpush("queue:#{new_queue}", JSON.dump(payload))
end
diff --git a/db/migrate/20161025231710_migrate_jira_to_gem.rb b/db/migrate/20161025231710_migrate_jira_to_gem.rb
index aa1c59ec9e6..b9e6e2ef4a4 100644
--- a/db/migrate/20161025231710_migrate_jira_to_gem.rb
+++ b/db/migrate/20161025231710_migrate_jira_to_gem.rb
@@ -13,28 +13,28 @@ class MigrateJiraToGem < ActiveRecord::Migration[4.2]
active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true"
select_all(active_services_query).each do |service|
- id = service['id']
- properties = JSON.parse(service['properties'])
+ id = service["id"]
+ properties = JSON.parse(service["properties"])
properties_was = properties.clone
# Migrate `project_url` to `project_key`
# Ignore if `project_url` doesn't have jql project query with project key
- if properties['project_url'].present?
- jql = properties['project_url'].match('project=([A-Za-z]*)')
- properties['project_key'] = jql.captures.first if jql
+ if properties["project_url"].present?
+ jql = properties["project_url"].match("project=([A-Za-z]*)")
+ properties["project_key"] = jql.captures.first if jql
end
# Migrate `api_url` to `url`
- if properties['api_url'].present?
- url = properties['api_url'].match('(.*)\/rest\/api')
- properties['url'] = url.captures.first if url
+ if properties["api_url"].present?
+ url = properties["api_url"].match('(.*)\/rest\/api')
+ properties["url"] = url.captures.first if url
end
# Delete now unnecessary properties
- properties.delete('api_url')
- properties.delete('project_url')
- properties.delete('new_issue_url')
- properties.delete('issues_url')
+ properties.delete("api_url")
+ properties.delete("project_url")
+ properties.delete("new_issue_url")
+ properties.delete("issues_url")
# Update changes properties
if properties != properties_was
@@ -47,22 +47,22 @@ class MigrateJiraToGem < ActiveRecord::Migration[4.2]
active_services_query = "SELECT id, properties FROM services WHERE services.type IN ('JiraService') AND services.active = true"
select_all(active_services_query).each do |service|
- id = service['id']
- properties = JSON.parse(service['properties'])
+ id = service["id"]
+ properties = JSON.parse(service["properties"])
properties_was = properties.clone
# Rebuild old properties based on sane defaults
- if properties['url'].present?
- properties['api_url'] = "#{properties['url']}/rest/api/2"
- properties['project_url'] =
- "#{properties['url']}/issues/?jql=project=#{properties['project_key']}"
- properties['issues_url'] = "#{properties['url']}/browse/:id"
- properties['new_issue_url'] = "#{properties['url']}/secure/CreateIssue.jspa"
+ if properties["url"].present?
+ properties["api_url"] = "#{properties["url"]}/rest/api/2"
+ properties["project_url"] =
+ "#{properties["url"]}/issues/?jql=project=#{properties["project_key"]}"
+ properties["issues_url"] = "#{properties["url"]}/browse/:id"
+ properties["new_issue_url"] = "#{properties["url"]}/secure/CreateIssue.jspa"
end
# Delete the new properties
- properties.delete('url')
- properties.delete('project_key')
+ properties.delete("url")
+ properties.delete("project_key")
# Update changes properties
if properties != properties_was
diff --git a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb
index 7f4087fdcd3..47826b0ab6b 100644
--- a/db/migrate/20161031174110_migrate_subscriptions_project_id.rb
+++ b/db/migrate/20161031174110_migrate_subscriptions_project_id.rb
@@ -2,7 +2,7 @@ class MigrateSubscriptionsProjectId < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Subscriptions will not work as expected until this migration is complete.'
+ DOWNTIME_REASON = "Subscriptions will not work as expected until this migration is complete."
def up
execute <<-EOF.strip_heredoc
diff --git a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb
index 23a775d6282..e6dab8e8691 100644
--- a/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb
+++ b/db/migrate/20161031181638_add_unique_index_to_subscriptions.rb
@@ -3,17 +3,17 @@ class AddUniqueIndexToSubscriptions < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'This migration requires downtime because it changes a column to not accept null values.'
+ DOWNTIME_REASON = "This migration requires downtime because it changes a column to not accept null values."
disable_ddl_transaction!
def up
- add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id, :project_id], { unique: true, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' }
- remove_index :subscriptions, name: 'subscriptions_user_id_and_ref_fields' if index_name_exists?(:subscriptions, 'subscriptions_user_id_and_ref_fields', false)
+ add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id, :project_id], {unique: true, name: "index_subscriptions_on_subscribable_and_user_id_and_project_id"}
+ remove_index :subscriptions, name: "subscriptions_user_id_and_ref_fields" if index_name_exists?(:subscriptions, "subscriptions_user_id_and_ref_fields", false)
end
def down
- add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], { unique: true, name: 'subscriptions_user_id_and_ref_fields' }
- remove_index :subscriptions, name: 'index_subscriptions_on_subscribable_and_user_id_and_project_id' if index_name_exists?(:subscriptions, 'index_subscriptions_on_subscribable_and_user_id_and_project_id', false)
+ add_concurrent_index :subscriptions, [:subscribable_id, :subscribable_type, :user_id], {unique: true, name: "subscriptions_user_id_and_ref_fields"}
+ remove_index :subscriptions, name: "index_subscriptions_on_subscribable_and_user_id_and_project_id" if index_name_exists?(:subscriptions, "index_subscriptions_on_subscribable_and_user_id_and_project_id", false)
end
end
diff --git a/db/migrate/20161103171205_rename_repository_storage_column.rb b/db/migrate/20161103171205_rename_repository_storage_column.rb
index d6050500e47..58cb954325e 100644
--- a/db/migrate/20161103171205_rename_repository_storage_column.rb
+++ b/db/migrate/20161103171205_rename_repository_storage_column.rb
@@ -10,7 +10,7 @@ class RenameRepositoryStorageColumn < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Renaming the application_settings.repository_storage column'
+ DOWNTIME_REASON = "Renaming the application_settings.repository_storage column"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
diff --git a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
index 0772821210c..c5620a57508 100644
--- a/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
+++ b/db/migrate/20161124141322_migrate_process_commit_worker_jobs.rb
@@ -17,7 +17,7 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2]
class Project < ActiveRecord::Base
def self.find_including_path(id)
select("projects.*, CONCAT(namespaces.path, '/', projects.path) AS path_with_namespace")
- .joins('INNER JOIN namespaces ON namespaces.id = projects.namespace_id')
+ .joins("INNER JOIN namespaces ON namespaces.id = projects.namespace_id")
.find_by(id: id)
end
@@ -26,12 +26,12 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2]
end
def repository
- @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + '.git')
+ @repository ||= Repository.new(repository_storage, read_attribute(:path_with_namespace) + ".git")
end
end
DOWNTIME = true
- DOWNTIME_REASON = 'Existing workers will error until they are using a newer version of the code'
+ DOWNTIME_REASON = "Existing workers will error until they are using a newer version of the code"
disable_ddl_transaction!
@@ -39,13 +39,13 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2]
Sidekiq.redis do |redis|
new_jobs = []
- while job = redis.lpop('queue:process_commit')
+ while job = redis.lpop("queue:process_commit")
payload = JSON.parse(job)
- project = Project.find_including_path(payload['args'][0])
+ project = Project.find_including_path(payload["args"][0])
next unless project
- commit = project.commit(payload['args'][2])
+ commit = project.commit(payload["args"][2])
next unless commit
hash = {
@@ -57,17 +57,17 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2]
author_email: encode(commit.author.email),
committed_date: Time.at(commit.committer.date.seconds).utc,
committer_email: encode(commit.committer.email),
- committer_name: encode(commit.committer.name)
+ committer_name: encode(commit.committer.name),
}
- payload['args'][2] = hash
+ payload["args"][2] = hash
new_jobs << JSON.dump(payload)
end
redis.multi do |multi|
new_jobs.each do |j|
- multi.lpush('queue:process_commit', j)
+ multi.lpush("queue:process_commit", j)
end
end
end
@@ -77,17 +77,17 @@ class MigrateProcessCommitWorkerJobs < ActiveRecord::Migration[4.2]
Sidekiq.redis do |redis|
new_jobs = []
- while job = redis.lpop('queue:process_commit')
+ while job = redis.lpop("queue:process_commit")
payload = JSON.parse(job)
- payload['args'][2] = payload['args'][2]['id']
+ payload["args"][2] = payload["args"][2]["id"]
new_jobs << JSON.dump(payload)
end
redis.multi do |multi|
new_jobs.each do |j|
- multi.lpush('queue:process_commit', j)
+ multi.lpush("queue:process_commit", j)
end
end
end
diff --git a/db/migrate/20161128142110_remove_unnecessary_indexes.rb b/db/migrate/20161128142110_remove_unnecessary_indexes.rb
index b6c6e303ec7..50124dac5c0 100644
--- a/db/migrate/20161128142110_remove_unnecessary_indexes.rb
+++ b/db/migrate/20161128142110_remove_unnecessary_indexes.rb
@@ -13,7 +13,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration[4.2]
remove_index :award_emoji, column: :user_id if index_exists?(:award_emoji, :user_id)
remove_index :ci_builds, column: :commit_id if index_exists?(:ci_builds, :commit_id)
remove_index :deployments, column: :project_id if index_exists?(:deployments, :project_id)
- remove_index :deployments, column: %w(project_id environment_id) if index_exists?(:deployments, %w(project_id environment_id))
+ remove_index :deployments, column: %w[project_id environment_id] if index_exists?(:deployments, %w[project_id environment_id])
remove_index :lists, column: :board_id if index_exists?(:lists, :board_id)
remove_index :milestones, column: :project_id if index_exists?(:milestones, :project_id)
remove_index :notes, column: :project_id if index_exists?(:notes, :project_id)
@@ -25,7 +25,7 @@ class RemoveUnnecessaryIndexes < ActiveRecord::Migration[4.2]
add_concurrent_index :award_emoji, :user_id
add_concurrent_index :ci_builds, :commit_id
add_concurrent_index :deployments, :project_id
- add_concurrent_index :deployments, %w(project_id environment_id)
+ add_concurrent_index :deployments, %w[project_id environment_id]
add_concurrent_index :lists, :board_id
add_concurrent_index :milestones, :project_id
add_concurrent_index :notes, :project_id
diff --git a/db/migrate/20161130095245_fill_routes_table.rb b/db/migrate/20161130095245_fill_routes_table.rb
index 712be187c7c..6bbb2b44ea9 100644
--- a/db/migrate/20161130095245_fill_routes_table.rb
+++ b/db/migrate/20161130095245_fill_routes_table.rb
@@ -5,7 +5,7 @@ class FillRoutesTable < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'No new namespaces should be created during data copy'
+ DOWNTIME_REASON = "No new namespaces should be created during data copy"
def up
execute <<-EOF
diff --git a/db/migrate/20161130101252_fill_projects_routes_table.rb b/db/migrate/20161130101252_fill_projects_routes_table.rb
index 1900d6c8013..9a8399f5936 100644
--- a/db/migrate/20161130101252_fill_projects_routes_table.rb
+++ b/db/migrate/20161130101252_fill_projects_routes_table.rb
@@ -5,7 +5,7 @@ class FillProjectsRoutesTable < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'No new projects should be created during data copy'
+ DOWNTIME_REASON = "No new projects should be created during data copy"
def up
if Gitlab::Database.postgresql?
diff --git a/db/migrate/20161201155511_create_project_statistics.rb b/db/migrate/20161201155511_create_project_statistics.rb
index 6dcb5adb82b..175bf0b2a15 100644
--- a/db/migrate/20161201155511_create_project_statistics.rb
+++ b/db/migrate/20161201155511_create_project_statistics.rb
@@ -5,10 +5,10 @@ class CreateProjectStatistics < ActiveRecord::Migration[4.2]
def change
# use bigint columns to support values >2GB
- counter_column = { limit: 8, null: false, default: 0 }
+ counter_column = {limit: 8, null: false, default: 0}
create_table :project_statistics do |t|
- t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.references :namespace, null: false, index: true
t.integer :commit_count, counter_column
t.integer :storage_size, counter_column
diff --git a/db/migrate/20161201160452_migrate_project_statistics.rb b/db/migrate/20161201160452_migrate_project_statistics.rb
index 42c5be07e83..306bb4e18f7 100644
--- a/db/migrate/20161201160452_migrate_project_statistics.rb
+++ b/db/migrate/20161201160452_migrate_project_statistics.rb
@@ -3,7 +3,7 @@ class MigrateProjectStatistics < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Removes two columns from the projects table'
+ DOWNTIME_REASON = "Removes two columns from the projects table"
def up
# convert repository_size in float (megabytes) to integer (bytes),
diff --git a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb
index c301d76646e..a884cce52dd 100644
--- a/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb
+++ b/db/migrate/20161206153749_remove_uniq_path_index_from_namespace.rb
@@ -10,7 +10,7 @@ class RemoveUniqPathIndexFromNamespace < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- constraint_name = 'namespaces_path_key'
+ constraint_name = "namespaces_path_key"
transaction do
if index_exists?(:namespaces, :path)
diff --git a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb
index 13660cec7aa..29bfe643700 100644
--- a/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb
+++ b/db/migrate/20161206153753_remove_uniq_name_index_from_namespace.rb
@@ -10,7 +10,7 @@ class RemoveUniqNameIndexFromNamespace < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- constraint_name = 'namespaces_name_key'
+ constraint_name = "namespaces_name_key"
transaction do
if index_exists?(:namespaces, :name)
diff --git a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
index 420f0ccb45c..61b28c3d6f6 100644
--- a/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
+++ b/db/migrate/20161207231620_fixup_environment_name_uniqueness.rb
@@ -2,7 +2,7 @@ class FixupEnvironmentNameUniqueness < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Renaming non-unique environments'
+ DOWNTIME_REASON = "Renaming non-unique environments"
def up
environments = Arel::Table.new(:environments)
diff --git a/db/migrate/20161207231621_create_environment_name_unique_index.rb b/db/migrate/20161207231621_create_environment_name_unique_index.rb
index 28d22664405..7b6c9f5b91c 100644
--- a/db/migrate/20161207231621_create_environment_name_unique_index.rb
+++ b/db/migrate/20161207231621_create_environment_name_unique_index.rb
@@ -5,7 +5,7 @@ class CreateEnvironmentNameUniqueIndex < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = true
- DOWNTIME_REASON = 'Making a non-unique index into a unique index'
+ DOWNTIME_REASON = "Making a non-unique index into a unique index"
def up
remove_index :environments, [:project_id, :name]
diff --git a/db/migrate/20161207231626_add_environment_slug.rb b/db/migrate/20161207231626_add_environment_slug.rb
index 993b9bd3330..302dfc1a065 100644
--- a/db/migrate/20161207231626_add_environment_slug.rb
+++ b/db/migrate/20161207231626_add_environment_slug.rb
@@ -5,11 +5,11 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Adding NOT NULL column environments.slug with dependent data'
+ DOWNTIME_REASON = "Adding NOT NULL column environments.slug with dependent data"
# Used to generate random suffixes for the slug
- LETTERS = 'a'..'z'
- NUMBERS = '0'..'9'
+ LETTERS = "a".."z"
+ NUMBERS = "0".."9"
SUFFIX_CHARS = LETTERS.to_a + NUMBERS.to_a
def up
@@ -37,25 +37,25 @@ class AddEnvironmentSlug < ActiveRecord::Migration[4.2]
# Copy of the Environment#generate_slug implementation
def generate_slug(name)
# Lowercase letters and numbers only
- slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, '-')
+ slugified = name.to_s.downcase.gsub(/[^a-z0-9]/, "-")
# Must start with a letter
- slugified = 'env-' + slugified unless LETTERS.cover?(slugified[0])
+ slugified = "env-" + slugified unless LETTERS.cover?(slugified[0])
# Repeated dashes are invalid (OpenShift limitation)
- slugified.gsub!(/\-+/, '-')
+ slugified.gsub!(/\-+/, "-")
# Maximum length: 24 characters (OpenShift limitation)
slugified = slugified[0..23]
# Cannot end with a dash (Kubernetes label limitation)
- slugified.chop! if slugified.end_with?('-')
+ slugified.chop! if slugified.end_with?("-")
# Add a random suffix, shortening the current string if necessary, if it
# has been slugified. This ensures uniqueness.
if slugified != name
slugified = slugified[0..16]
- slugified << '-' unless slugified.end_with?('-')
+ slugified << "-" unless slugified.end_with?("-")
slugified << random_suffix
end
diff --git a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb
index 57606a33cb9..caf96f6d6c8 100644
--- a/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb
+++ b/db/migrate/20161209153400_add_unique_index_for_environment_slug.rb
@@ -6,7 +6,7 @@ class AddUniqueIndexForEnvironmentSlug < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Adding a *unique* index to environments.slug'
+ DOWNTIME_REASON = "Adding a *unique* index to environments.slug"
disable_ddl_transaction!
diff --git a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb
index e8ea9cf8fda..0d3ade1980a 100644
--- a/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb
+++ b/db/migrate/20161209165216_create_doorkeeper_openid_connect_tables.rb
@@ -14,20 +14,20 @@ class CreateDoorkeeperOpenidConnectTables < ActiveRecord::Migration[4.2]
if Gitlab::Database.postgresql?
# add foreign key without validation to avoid downtime on PostgreSQL,
# also see db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb
- execute %q{
+ execute '
ALTER TABLE "oauth_openid_requests"
ADD CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id"
FOREIGN KEY ("access_grant_id")
REFERENCES "oauth_access_grants" ("id")
NOT VALID;
- }
+ '
else
- execute %q{
+ execute '
ALTER TABLE oauth_openid_requests
ADD CONSTRAINT fk_oauth_openid_requests_oauth_access_grants_access_grant_id
FOREIGN KEY (access_grant_id)
REFERENCES oauth_access_grants (id);
- }
+ '
end
end
diff --git a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb
index 92a12dbc699..d571985f612 100644
--- a/db/migrate/20161212142807_add_lower_path_index_to_routes.rb
+++ b/db/migrate/20161212142807_add_lower_path_index_to_routes.rb
@@ -12,7 +12,7 @@ class AddLowerPathIndexToRoutes < ActiveRecord::Migration[4.2]
def up
return unless Gitlab::Database.postgresql?
- execute 'CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));'
+ execute "CREATE INDEX CONCURRENTLY index_on_routes_lower_path ON routes (LOWER(path));"
end
def down
diff --git a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb
index 5c0b083325e..44e486353e4 100644
--- a/db/migrate/20161220141214_remove_dot_git_from_group_names.rb
+++ b/db/migrate/20161220141214_remove_dot_git_from_group_names.rb
@@ -10,18 +10,18 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2]
def up
invalid_groups.each do |group|
- path_was = group['path']
+ path_was = group["path"]
path_was_wildcard = quote_string("#{path_was}/%")
path = quote_string(rename_path(path_was))
- move_namespace(group['id'], path_was, path)
+ move_namespace(group["id"], path_was, path)
- execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{group['id']}"
- execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group['id']}"
+ execute "UPDATE routes SET path = '#{path}' WHERE source_type = 'Namespace' AND source_id = #{group["id"]}"
+ execute "UPDATE namespaces SET path = '#{path}' WHERE id = #{group["id"]}"
select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route|
- new_path = "#{path}/#{route['path'].split('/').last}"
- execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}"
+ new_path = "#{path}/#{route["path"].split("/").last}"
+ execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route["id"]}"
end
end
end
@@ -45,7 +45,7 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2]
def rename_path(path)
# To stay closer with original name and reduce risk of duplicates
# we rename suffix instead of removing it
- path = path.sub(/\.git\z/, '_git')
+ path = path.sub(/\.git\z/, "_git")
counter = 0
base = path
@@ -59,9 +59,9 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2]
end
def move_namespace(group_id, path_was, path)
- repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map do |row|
- row['repository_storage']
- end.compact
+ repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{group_id}").map { |row|
+ row["repository_storage"]
+ }.compact
# Move the namespace directory in all storages paths used by member projects
repository_storages.each do |repository_storage|
@@ -73,7 +73,7 @@ class RemoveDotGitFromGroupNames < ActiveRecord::Migration[4.2]
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
- raise Exception.new('namespace directory cannot be moved')
+ raise Exception.new("namespace directory cannot be moved")
end
end
diff --git a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb
index e3318780151..fb1b67efea4 100644
--- a/db/migrate/20161226122833_remove_dot_git_from_usernames.rb
+++ b/db/migrate/20161226122833_remove_dot_git_from_usernames.rb
@@ -6,9 +6,9 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2]
def up
invalid_users.each do |user|
- id = user['id']
- namespace_id = user['namespace_id']
- path_was = user['username']
+ id = user["id"]
+ namespace_id = user["namespace_id"]
+ path_was = user["username"]
path_was_wildcard = quote_string("#{path_was}/%")
path = quote_string(new_path(path_was))
@@ -20,8 +20,8 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2]
execute "UPDATE users SET username = '#{path}' WHERE id = #{id}"
select_all("SELECT id, path FROM routes WHERE path LIKE '#{path_was_wildcard}'").each do |route|
- new_path = "#{path}/#{route['path'].split('/').last}"
- execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route['id']}"
+ new_path = "#{path}/#{route["path"].split("/").last}"
+ execute "UPDATE routes SET path = '#{new_path}' WHERE id = #{route["id"]}"
end
rescue => e
say("Couldn't update routes for path #{path_was} to #{path}")
@@ -58,7 +58,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2]
def new_path(path)
# To stay closer with original name and reduce risk of duplicates
# we rename suffix instead of removing it
- path = path.sub(/\.git\z/, '_git')
+ path = path.sub(/\.git\z/, "_git")
check_routes(path.dup, 0, path)
end
@@ -79,9 +79,9 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2]
end
def move_namespace(namespace_id, path_was, path)
- repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map do |row|
- row['repository_storage']
- end.compact
+ repository_storages = select_all("SELECT distinct(repository_storage) FROM projects WHERE namespace_id = #{namespace_id}").map { |row|
+ row["repository_storage"]
+ }.compact
# Move the namespace directory in all storages used by member projects
repository_storages.each do |repository_storage|
@@ -93,7 +93,7 @@ class RemoveDotGitFromUsernames < ActiveRecord::Migration[4.2]
# if we cannot move namespace directory we should rollback
# db changes in order to prevent out of sync between db and fs
- raise Exception.new('namespace directory cannot be moved')
+ raise Exception.new("namespace directory cannot be moved")
end
end
diff --git a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb
index df5714278f2..3fe32a0a79d 100644
--- a/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb
+++ b/db/migrate/20161227192806_rename_slack_and_mattermost_notification_services.rb
@@ -7,22 +7,22 @@ class RenameSlackAndMattermostNotificationServices < ActiveRecord::Migration[4.2
disable_ddl_transaction!
def up
- update_column_in_batches(:services, :type, 'SlackService') do |table, query|
- query.where(table[:type].eq('SlackNotificationService'))
+ update_column_in_batches(:services, :type, "SlackService") do |table, query|
+ query.where(table[:type].eq("SlackNotificationService"))
end
- update_column_in_batches(:services, :type, 'MattermostService') do |table, query|
- query.where(table[:type].eq('MattermostNotificationService'))
+ update_column_in_batches(:services, :type, "MattermostService") do |table, query|
+ query.where(table[:type].eq("MattermostNotificationService"))
end
end
def down
- update_column_in_batches(:services, :type, 'SlackNotificationService') do |table, query|
- query.where(table[:type].eq('SlackService'))
+ update_column_in_batches(:services, :type, "SlackNotificationService") do |table, query|
+ query.where(table[:type].eq("SlackService"))
end
- update_column_in_batches(:services, :type, 'MattermostNotificationService') do |table, query|
- query.where(table[:type].eq('MattermostService'))
+ update_column_in_batches(:services, :type, "MattermostNotificationService") do |table, query|
+ query.where(table[:type].eq("MattermostService"))
end
end
end
diff --git a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb
index f9f8f11316d..61dedb2b007 100644
--- a/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb
+++ b/db/migrate/20161228124936_change_expires_at_to_date_in_personal_access_tokens.rb
@@ -7,7 +7,7 @@ class ChangeExpiresAtToDateInPersonalAccessTokens < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = true
- DOWNTIME_REASON = 'This migration requires downtime because it alters expires_at column from datetime to date'
+ DOWNTIME_REASON = "This migration requires downtime because it alters expires_at column from datetime to date"
def up
change_column :personal_access_tokens, :expires_at, :date
diff --git a/db/migrate/20170120131253_create_chat_teams.rb b/db/migrate/20170120131253_create_chat_teams.rb
index e9b9bd7bd2f..d05af314cfc 100644
--- a/db/migrate/20170120131253_create_chat_teams.rb
+++ b/db/migrate/20170120131253_create_chat_teams.rb
@@ -9,7 +9,7 @@ class CreateChatTeams < ActiveRecord::Migration[4.2]
def change
create_table :chat_teams do |t|
- t.references :namespace, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :namespace, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.string :team_id
t.string :name
diff --git a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
index ffd966be086..bb857c4ed9f 100644
--- a/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
+++ b/db/migrate/20170124174637_add_foreign_keys_to_timelogs.rb
@@ -9,7 +9,7 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = ''
+ DOWNTIME_REASON = ""
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
@@ -41,16 +41,16 @@ class AddForeignKeysToTimelogs < ActiveRecord::Migration[4.2]
execute "ALTER TABLE timelogs ADD CONSTRAINT fk_timelogs_merge_requests_merge_request_id FOREIGN KEY (merge_request_id) REFERENCES merge_requests(id) ON DELETE CASCADE;"
end
- Timelog.where(trackable_type: 'Issue').update_all("issue_id = trackable_id")
- Timelog.where(trackable_type: 'MergeRequest').update_all("merge_request_id = trackable_id")
+ Timelog.where(trackable_type: "Issue").update_all("issue_id = trackable_id")
+ Timelog.where(trackable_type: "MergeRequest").update_all("merge_request_id = trackable_id")
end
def down
- Timelog.where('issue_id IS NOT NULL').update_all("trackable_id = issue_id, trackable_type = 'Issue'")
- Timelog.where('merge_request_id IS NOT NULL').update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'")
+ Timelog.where("issue_id IS NOT NULL").update_all("trackable_id = issue_id, trackable_type = 'Issue'")
+ Timelog.where("merge_request_id IS NOT NULL").update_all("trackable_id = merge_request_id, trackable_type = 'MergeRequest'")
- remove_foreign_key :timelogs, name: 'fk_timelogs_issues_issue_id'
- remove_foreign_key :timelogs, name: 'fk_timelogs_merge_requests_merge_request_id'
+ remove_foreign_key :timelogs, name: "fk_timelogs_issues_issue_id"
+ remove_foreign_key :timelogs, name: "fk_timelogs_merge_requests_merge_request_id"
remove_columns :timelogs, :issue_id, :merge_request_id
end
diff --git a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
index 84814c2f8f2..2f3ac5717e9 100644
--- a/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
+++ b/db/migrate/20170214084746_add_default_artifacts_expiration_to_application_settings.rb
@@ -6,6 +6,6 @@ class AddDefaultArtifactsExpirationToApplicationSettings < ActiveRecord::Migrati
def change
add_column :application_settings,
:default_artifacts_expire_in, :string,
- null: false, default: '0'
+ null: false, default: "0"
end
end
diff --git a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb
index ee8838eff56..d492ed74589 100644
--- a/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb
+++ b/db/migrate/20170217132157_rename_merge_when_build_succeeds.rb
@@ -10,7 +10,7 @@ class RenameMergeWhenBuildSucceeds < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Renaming the column merge_when_build_succeeds'
+ DOWNTIME_REASON = "Renaming the column merge_when_build_succeeds"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
diff --git a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb
index 5d35216f3af..80b8e79dd74 100644
--- a/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb
+++ b/db/migrate/20170217151947_rename_only_allow_merge_if_build_succeeds.rb
@@ -10,7 +10,7 @@ class RenameOnlyAllowMergeIfBuildSucceeds < ActiveRecord::Migration[4.2]
# When a migration requires downtime you **must** uncomment the following
# constant and define a short and easy to understand explanation as to why the
# migration requires downtime.
- DOWNTIME_REASON = 'Renaming the column only_allow_merge_if_build_succeeds'
+ DOWNTIME_REASON = "Renaming the column only_allow_merge_if_build_succeeds"
# When using the methods "add_concurrent_index" or "add_column_with_default"
# you must disable the use of transactions as these methods can not run in an
diff --git a/db/migrate/20170222111732_create_gpg_keys.rb b/db/migrate/20170222111732_create_gpg_keys.rb
index 012e8ef5854..c0c5e689f43 100644
--- a/db/migrate/20170222111732_create_gpg_keys.rb
+++ b/db/migrate/20170222111732_create_gpg_keys.rb
@@ -7,7 +7,7 @@ class CreateGpgKeys < ActiveRecord::Migration[4.2]
create_table :gpg_keys do |t|
t.timestamps_with_timezone null: false
- t.references :user, index: true, foreign_key: { on_delete: :cascade }
+ t.references :user, index: true, foreign_key: {on_delete: :cascade}
t.binary :primary_keyid
t.binary :fingerprint
diff --git a/db/migrate/20170222143500_remove_old_project_id_columns.rb b/db/migrate/20170222143500_remove_old_project_id_columns.rb
index 356dee4a060..e5b640085af 100644
--- a/db/migrate/20170222143500_remove_old_project_id_columns.rb
+++ b/db/migrate/20170222143500_remove_old_project_id_columns.rb
@@ -5,7 +5,7 @@ class RemoveOldProjectIdColumns < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = true
- DOWNTIME_REASON = 'Unused columns are being removed.'
+ DOWNTIME_REASON = "Unused columns are being removed."
def up
remove_index :ci_builds, :project_id if
diff --git a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb
index 390b2c33d91..42a4a8dfae9 100644
--- a/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb
+++ b/db/migrate/20170222143603_rename_gl_project_id_to_project_id.rb
@@ -2,7 +2,7 @@ class RenameGlProjectIdToProjectId < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Renaming an actively used column.'
+ DOWNTIME_REASON = "Renaming an actively used column."
def change
rename_column :ci_builds, :gl_project_id, :project_id
diff --git a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb
index 791e9c845a6..00c617624a3 100644
--- a/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb
+++ b/db/migrate/20170301195939_rename_ci_commits_to_ci_pipelines.rb
@@ -2,9 +2,9 @@ class RenameCiCommitsToCiPipelines < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = true
- DOWNTIME_REASON = 'Rename table ci_commits to ci_pipelines'
+ DOWNTIME_REASON = "Rename table ci_commits to ci_pipelines"
def change
- rename_table 'ci_commits', 'ci_pipelines'
+ rename_table "ci_commits", "ci_pipelines"
end
end
diff --git a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb
index 08a11aee992..51f24ed7bca 100644
--- a/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb
+++ b/db/migrate/20170301205639_remove_unused_ci_tables_and_columns.rb
@@ -4,8 +4,8 @@ class RemoveUnusedCiTablesAndColumns < ActiveRecord::Migration[4.2]
DOWNTIME = true
DOWNTIME_REASON =
- 'Remove unused columns in used tables.' \
- ' Downtime required in case Rails caches them'
+ "Remove unused columns in used tables." \
+ " Downtime required in case Rails caches them"
def up
%w[ci_application_settings
diff --git a/db/migrate/20170309173138_create_protected_tags.rb b/db/migrate/20170309173138_create_protected_tags.rb
index f518b500bd4..de203448a8a 100644
--- a/db/migrate/20170309173138_create_protected_tags.rb
+++ b/db/migrate/20170309173138_create_protected_tags.rb
@@ -16,7 +16,7 @@ class CreateProtectedTags < ActiveRecord::Migration[4.2]
add_index :protected_tags, :project_id
create_table :protected_tag_create_access_levels do |t|
- t.references :protected_tag, index: { name: "index_protected_tag_create_access" }, foreign_key: true, null: false
+ t.references :protected_tag, index: {name: "index_protected_tag_create_access"}, foreign_key: true, null: false
t.integer :access_level, default: GITLAB_ACCESS_MASTER, null: true
t.references :user, foreign_key: true, index: true
t.integer :group_id
diff --git a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb
index a2b5c1c4533..101dd9acc7b 100644
--- a/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb
+++ b/db/migrate/20170312114529_add_auto_canceled_by_id_foreign_key_to_pipeline.rb
@@ -10,7 +10,7 @@ class AddAutoCanceledByIdForeignKeyToPipeline < ActiveRecord::Migration[4.2]
if Gitlab::Database.mysql?
:nullify
else
- 'SET NULL'
+ "SET NULL"
end
add_concurrent_foreign_key :ci_pipelines, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete
diff --git a/db/migrate/20170316163845_move_uploads_to_system_dir.rb b/db/migrate/20170316163845_move_uploads_to_system_dir.rb
index d24527b55cd..b37190c916e 100644
--- a/db/migrate/20170316163845_move_uploads_to_system_dir.rb
+++ b/db/migrate/20170316163845_move_uploads_to_system_dir.rb
@@ -6,7 +6,7 @@ class MoveUploadsToSystemDir < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- DIRECTORIES_TO_MOVE = %w(user project note group appearance).freeze
+ DIRECTORIES_TO_MOVE = %w[user project note group appearance].freeze
def up
return unless file_storage?
diff --git a/db/migrate/20170317203554_index_routes_path_for_like.rb b/db/migrate/20170317203554_index_routes_path_for_like.rb
index a1bee3c8783..a3d5a102aaa 100644
--- a/db/migrate/20170317203554_index_routes_path_for_like.rb
+++ b/db/migrate/20170317203554_index_routes_path_for_like.rb
@@ -7,7 +7,7 @@ class IndexRoutesPathForLike < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_routes_on_path_text_pattern_ops'
+ INDEX_NAME = "index_routes_on_path_text_pattern_ops"
disable_ddl_transaction!
diff --git a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb
index 2ec281e20c1..1f96c3c8e90 100644
--- a/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb
+++ b/db/migrate/20170406115029_add_auto_canceled_by_id_foreign_key_to_ci_builds.rb
@@ -10,7 +10,7 @@ class AddAutoCanceledByIdForeignKeyToCiBuilds < ActiveRecord::Migration[4.2]
if Gitlab::Database.mysql?
:nullify
else
- 'SET NULL'
+ "SET NULL"
end
add_concurrent_foreign_key :ci_builds, :ci_pipelines, column: :auto_canceled_by_id, on_delete: on_delete
diff --git a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb
index 1c5d4997d40..3a9d32d4f66 100644
--- a/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb
+++ b/db/migrate/20170502091007_markdown_cache_limits_to_mysql.rb
@@ -1 +1 @@
-require_relative 'markdown_cache_limits_to_mysql'
+require_relative "markdown_cache_limits_to_mysql"
diff --git a/db/migrate/20170503140201_reschedule_project_authorizations.rb b/db/migrate/20170503140201_reschedule_project_authorizations.rb
index aa940bed2d3..2168510047e 100644
--- a/db/migrate/20170503140201_reschedule_project_authorizations.rb
+++ b/db/migrate/20170503140201_reschedule_project_authorizations.rb
@@ -9,7 +9,7 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
def up
@@ -18,7 +18,7 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2]
start = Time.now
loop do
- relation = User.where('id > ?', offset)
+ relation = User.where("id > ?", offset)
user_ids = relation.limit(batch).reorder(id: :asc).pluck(:id)
break if user_ids.empty?
@@ -29,10 +29,10 @@ class RescheduleProjectAuthorizations < ActiveRecord::Migration[4.2]
# scheduled. This smears out the load over time, instead of immediately
# scheduling a million jobs.
Sidekiq::Client.push_bulk(
- 'queue' => 'authorized_projects',
- 'args' => user_ids.zip,
- 'class' => 'AuthorizedProjectsWorker',
- 'at' => start.to_i
+ "queue" => "authorized_projects",
+ "args" => user_ids.zip,
+ "class" => "AuthorizedProjectsWorker",
+ "at" => start.to_i
)
start += 5.minutes
diff --git a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb
index cfa63b65df4..9705fce9721 100644
--- a/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb
+++ b/db/migrate/20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb
@@ -25,7 +25,7 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2]
# 2. Get all the members of these namespaces, along with their higher access
# level
# 3. Give these members access to the current namespace
- Namespace.unscoped.where('parent_id IS NOT NULL').find_each do |namespace|
+ Namespace.unscoped.where("parent_id IS NOT NULL").find_each do |namespace|
rows = []
existing = namespace.members.pluck(:user_id)
@@ -35,12 +35,12 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2]
rows << {
access_level: member[:access_level],
source_id: namespace.id,
- source_type: 'Namespace',
+ source_type: "Namespace",
user_id: member[:user_id],
notification_level: 3, # global
- type: 'GroupMember',
+ type: "GroupMember",
created_at: Time.current,
- updated_at: Time.current
+ updated_at: Time.current,
}
end
@@ -64,7 +64,7 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2]
# Generates a new (unique) path for a namespace.
def new_path_for(namespace)
counter = 1
- base = namespace.full_path.tr('/', '-')
+ base = namespace.full_path.tr("/", "-")
new_path = base
while Namespace.unscoped.where(path: new_path).exists?
@@ -101,8 +101,8 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2]
def all_members_for(namespace)
Member
.unscoped
- .select(['user_id', 'MAX(access_level) AS access_level'])
- .where(source_type: 'Namespace', source_id: ancestors_for(namespace))
+ .select(["user_id", "MAX(access_level) AS access_level"])
+ .where(source_type: "Namespace", source_id: ancestors_for(namespace))
.group(:user_id)
end
@@ -111,13 +111,13 @@ class TurnNestedGroupsIntoRegularGroupsForMysql < ActiveRecord::Migration[4.2]
keys = rows.first.keys
- tuples = rows.map do |row|
+ tuples = rows.map { |row|
row.map { |(_, value)| connection.quote(value) }
- end
+ }
execute <<-EOF.strip_heredoc
- INSERT INTO members (#{keys.join(', ')})
- VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
+ INSERT INTO members (#{keys.join(", ")})
+ VALUES #{tuples.map { |tuple| "(#{tuple.join(", ")})" }.join(", ")}
EOF
end
end
diff --git a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
index 5d06fd0511c..0ec437076fb 100644
--- a/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
+++ b/db/migrate/20170503185032_index_redirect_routes_path_for_like.rb
@@ -7,7 +7,7 @@ class IndexRedirectRoutesPathForLike < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_redirect_routes_on_path_text_pattern_ops'
+ INDEX_NAME = "index_redirect_routes_on_path_text_pattern_ops"
disable_ddl_transaction!
diff --git a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb
index 50364cac259..1601c793ad8 100644
--- a/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb
+++ b/db/migrate/20170506185517_add_foreign_key_pipeline_schedules_and_pipelines.rb
@@ -10,7 +10,7 @@ class AddForeignKeyPipelineSchedulesAndPipelines < ActiveRecord::Migration[4.2]
if Gitlab::Database.mysql?
:nullify
else
- 'SET NULL'
+ "SET NULL"
end
add_concurrent_foreign_key :ci_pipelines, :ci_pipeline_schedules,
diff --git a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb
index 0ed45775421..edd717df468 100644
--- a/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb
+++ b/db/migrate/20170516153305_migrate_assignee_to_separate_table.rb
@@ -35,7 +35,7 @@ class MigrateAssigneeToSeparateTable < ActiveRecord::Migration[4.2]
EOF
else
ActiveRecord::Base.transaction do
- execute('LOCK TABLE issues IN EXCLUSIVE MODE')
+ execute("LOCK TABLE issues IN EXCLUSIVE MODE")
execute <<-EOF
CREATE TABLE issue_assignees AS
diff --git a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb b/db/migrate/20170516183131_add_indices_to_issue_assignees.rb
index 6877fe9ff98..b5c171fc88a 100644
--- a/db/migrate/20170516183131_add_indices_to_issue_assignees.rb
+++ b/db/migrate/20170516183131_add_indices_to_issue_assignees.rb
@@ -26,8 +26,8 @@ class AddIndicesToIssueAssignees < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_concurrent_index :issue_assignees, [:issue_id, :user_id], unique: true, name: 'index_issue_assignees_on_issue_id_and_user_id'
- add_concurrent_index :issue_assignees, :user_id, name: 'index_issue_assignees_on_user_id'
+ add_concurrent_index :issue_assignees, [:issue_id, :user_id], unique: true, name: "index_issue_assignees_on_issue_id_and_user_id"
+ add_concurrent_index :issue_assignees, :user_id, name: "index_issue_assignees_on_user_id"
add_concurrent_foreign_key :issue_assignees, :users, column: :user_id, on_delete: :cascade
add_concurrent_foreign_key :issue_assignees, :issues, column: :issue_id, on_delete: :cascade
end
diff --git a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb b/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb
index 9c8f58104bd..1b9c8159c3b 100644
--- a/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb
+++ b/db/migrate/20170519102115_add_prometheus_settings_to_metrics_settings.rb
@@ -7,7 +7,7 @@ class AddPrometheusSettingsToMetricsSettings < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:application_settings, :prometheus_metrics_enabled, :boolean,
- default: false, allow_null: false)
+ default: false, allow_null: false)
end
def down
diff --git a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb
index d40c61f24b1..b276774e380 100644
--- a/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb
+++ b/db/migrate/20170530130129_project_foreign_keys_with_cascading_deletes.rb
@@ -43,7 +43,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
[:ci_runner_projects, :projects, :project_id],
[:ci_triggers, :projects, :project_id],
[:environments, :projects, :project_id],
- [:deployments, :projects, :project_id]
+ [:deployments, :projects, :project_id],
]
def up
@@ -52,10 +52,10 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
remove_foreign_key_without_error(:lists, :label_id)
remove_foreign_key_without_error(:lists, :board_id)
remove_foreign_key_without_error(:protected_branch_merge_access_levels,
- :protected_branch_id)
+ :protected_branch_id)
remove_foreign_key_without_error(:protected_branch_push_access_levels,
- :protected_branch_id)
+ :protected_branch_id)
remove_orphaned_rows
add_foreign_keys
@@ -76,12 +76,12 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
add_foreign_key_if_not_exists(:lists, :boards, column: :board_id)
add_foreign_key_if_not_exists(:protected_branch_merge_access_levels,
- :protected_branches,
- column: :protected_branch_id)
+ :protected_branches,
+ column: :protected_branch_id)
add_foreign_key_if_not_exists(:protected_branch_push_access_levels,
- :protected_branches,
- column: :protected_branch_id)
+ :protected_branches,
+ column: :protected_branch_id)
remove_index_without_error(:project_group_links, :project_id)
remove_index_without_error(:pages_domains, :project_id)
@@ -98,7 +98,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
Gitlab::Database.with_connection_pool(CONCURRENCY) do |pool|
queues = queues_for_rows(TABLES)
- threads = queues.map do |queue|
+ threads = queues.map { |queue|
Thread.new do
pool.with_connection do |connection|
Thread.current[:foreign_key_connection] = connection
@@ -113,7 +113,7 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
end
end
end
- end
+ }
threads.each(&:join)
end
@@ -126,11 +126,10 @@ class ProjectForeignKeysWithCascadingDeletes < ActiveRecord::Migration[4.2]
queues.each do |queue|
# Stealing is racy so it's possible a pop might be called on an
# already-empty queue.
- begin
- remove_orphans(*queue.pop(true))
- stolen = true
- rescue ThreadError
- end
+
+ remove_orphans(*queue.pop(true))
+ stolen = true
+ rescue ThreadError
end
break unless stolen
diff --git a/db/migrate/20170606154216_add_notification_setting_columns.rb b/db/migrate/20170606154216_add_notification_setting_columns.rb
index 3b9493e6b49..cfee4e93b12 100644
--- a/db/migrate/20170606154216_add_notification_setting_columns.rb
+++ b/db/migrate/20170606154216_add_notification_setting_columns.rb
@@ -15,7 +15,7 @@ class AddNotificationSettingColumns < ActiveRecord::Migration[4.2]
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
- :success_pipeline
+ :success_pipeline,
]
def change
diff --git a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb b/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb
index 851af7f7bf6..b1a23800261 100644
--- a/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb
+++ b/db/migrate/20170608152747_prepare_events_table_for_push_events_migration.rb
@@ -26,8 +26,8 @@ class PrepareEventsTableForPushEventsMigration < ActiveRecord::Migration[4.2]
# does not support this properly.
create_table :events_for_migration do |t|
t.references :project,
- index: true,
- foreign_key: { on_delete: :cascade }
+ index: true,
+ foreign_key: {on_delete: :cascade}
t.integer :author_id, index: true, null: false
t.integer :target_id
diff --git a/db/migrate/20170608171156_create_merge_request_diff_files.rb b/db/migrate/20170608171156_create_merge_request_diff_files.rb
index 94b518455ee..c8efb2e6295 100644
--- a/db/migrate/20170608171156_create_merge_request_diff_files.rb
+++ b/db/migrate/20170608171156_create_merge_request_diff_files.rb
@@ -5,7 +5,7 @@ class CreateMergeRequestDiffFiles < ActiveRecord::Migration[4.2]
def change
create_table :merge_request_diff_files, id: false do |t|
- t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade }
+ t.belongs_to :merge_request_diff, null: false, foreign_key: {on_delete: :cascade}
t.integer :relative_order, null: false
t.boolean :new_file, null: false
t.boolean :renamed_file, null: false
@@ -16,7 +16,7 @@ class CreateMergeRequestDiffFiles < ActiveRecord::Migration[4.2]
t.text :new_path, null: false
t.text :old_path, null: false
t.text :diff, null: false
- t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_files_on_mr_diff_id_and_order', unique: true
+ t.index [:merge_request_diff_id, :relative_order], name: "index_merge_request_diff_files_on_mr_diff_id_and_order", unique: true
end
end
end
diff --git a/db/migrate/20170613154149_create_gpg_signatures.rb b/db/migrate/20170613154149_create_gpg_signatures.rb
index 181d35fe7af..9923ba00c2f 100644
--- a/db/migrate/20170613154149_create_gpg_signatures.rb
+++ b/db/migrate/20170613154149_create_gpg_signatures.rb
@@ -7,8 +7,8 @@ class CreateGpgSignatures < ActiveRecord::Migration[4.2]
create_table :gpg_signatures do |t|
t.timestamps_with_timezone null: false
- t.references :project, index: true, foreign_key: { on_delete: :cascade }
- t.references :gpg_key, index: true, foreign_key: { on_delete: :nullify }
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}
+ t.references :gpg_key, index: true, foreign_key: {on_delete: :nullify}
t.boolean :valid_signature
diff --git a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb b/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb
index 4c1cf08aa06..1428b4efe3e 100644
--- a/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb
+++ b/db/migrate/20170614115405_merge_request_diff_file_limits_to_mysql.rb
@@ -1 +1 @@
-require_relative 'merge_request_diff_file_limits_to_mysql'
+require_relative "merge_request_diff_file_limits_to_mysql"
diff --git a/db/migrate/20170616133147_create_merge_request_diff_commits.rb b/db/migrate/20170616133147_create_merge_request_diff_commits.rb
index 5e148affba2..6b4951f5e82 100644
--- a/db/migrate/20170616133147_create_merge_request_diff_commits.rb
+++ b/db/migrate/20170616133147_create_merge_request_diff_commits.rb
@@ -5,7 +5,7 @@ class CreateMergeRequestDiffCommits < ActiveRecord::Migration[4.2]
create_table :merge_request_diff_commits, id: false do |t|
t.datetime_with_timezone :authored_date
t.datetime_with_timezone :committed_date
- t.belongs_to :merge_request_diff, null: false, foreign_key: { on_delete: :cascade }
+ t.belongs_to :merge_request_diff, null: false, foreign_key: {on_delete: :cascade}
t.integer :relative_order, null: false
t.binary :sha, null: false, limit: 20
t.text :author_name
@@ -14,7 +14,7 @@ class CreateMergeRequestDiffCommits < ActiveRecord::Migration[4.2]
t.text :committer_email
t.text :message
- t.index [:merge_request_diff_id, :relative_order], name: 'index_merge_request_diff_commits_on_mr_diff_id_and_order', unique: true
+ t.index [:merge_request_diff_id, :relative_order], name: "index_merge_request_diff_commits_on_mr_diff_id_and_order", unique: true
end
end
end
diff --git a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb b/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb
index c4ba3ec2cc0..b471cd468ce 100644
--- a/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb
+++ b/db/migrate/20170622130029_correct_protected_branches_foreign_keys.rb
@@ -11,7 +11,7 @@ class CorrectProtectedBranchesForeignKeys < ActiveRecord::Migration[4.2]
def up
remove_foreign_key_without_error(:protected_branch_push_access_levels,
- column: :protected_branch_id)
+ column: :protected_branch_id)
execute <<-EOF
DELETE FROM protected_branch_push_access_levels
@@ -24,8 +24,8 @@ class CorrectProtectedBranchesForeignKeys < ActiveRecord::Migration[4.2]
EOF
add_concurrent_foreign_key(:protected_branch_push_access_levels,
- :protected_branches,
- column: :protected_branch_id)
+ :protected_branches,
+ column: :protected_branch_id)
end
def down
diff --git a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb b/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb
index b826f67ff39..262da61c4bf 100644
--- a/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb
+++ b/db/migrate/20170622132212_add_foreign_key_for_merge_request_diffs.rb
@@ -20,8 +20,8 @@ class AddForeignKeyForMergeRequestDiffs < ActiveRecord::Migration[4.2]
EOF
add_concurrent_foreign_key(:merge_request_diffs,
- :merge_requests,
- column: :merge_request_id)
+ :merge_requests,
+ column: :merge_request_id)
end
def down
diff --git a/db/migrate/20170622135451_rename_duplicated_variable_key.rb b/db/migrate/20170622135451_rename_duplicated_variable_key.rb
index 06a9529ae79..681c40b70a2 100644
--- a/db/migrate/20170622135451_rename_duplicated_variable_key.rb
+++ b/db/migrate/20170622135451_rename_duplicated_variable_key.rb
@@ -29,10 +29,10 @@ class RenameDuplicatedVariableKey < ActiveRecord::Migration[4.2]
def key
# key needs to be quoted in MySQL
- quote_column_name('key')
+ quote_column_name("key")
end
def underscore
- quote('_')
+ quote("_")
end
end
diff --git a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb b/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb
index 8fbb2ab57d5..8858000439f 100644
--- a/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb
+++ b/db/migrate/20170622135628_add_environment_scope_to_ci_variables.rb
@@ -6,7 +6,7 @@ class AddEnvironmentScopeToCiVariables < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_column_with_default(:ci_variables, :environment_scope, :string, default: '*')
+ add_column_with_default(:ci_variables, :environment_scope, :string, default: "*")
end
def down
diff --git a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
index 240f55766d3..2fcac79df3b 100644
--- a/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
+++ b/db/migrate/20170622135728_add_unique_constraint_to_ci_variables.rb
@@ -2,7 +2,7 @@ class AddUniqueConstraintToCiVariables < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'index_ci_variables_on_project_id_and_key_and_environment_scope'
+ INDEX_NAME = "index_ci_variables_on_project_id_and_key_and_environment_scope"
disable_ddl_transaction!
diff --git a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb b/db/migrate/20170710083355_clean_stage_id_reference_migration.rb
index d33c6f53b15..11f40fee6b2 100644
--- a/db/migrate/20170710083355_clean_stage_id_reference_migration.rb
+++ b/db/migrate/20170710083355_clean_stage_id_reference_migration.rb
@@ -9,7 +9,7 @@ class CleanStageIdReferenceMigration < ActiveRecord::Migration[4.2]
# `MigrateStageIdReferenceInBackground` background migration cleanup.
#
def up
- Gitlab::BackgroundMigration.steal('MigrateBuildStageIdReference')
+ Gitlab::BackgroundMigration.steal("MigrateBuildStageIdReference")
end
def down
diff --git a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb
index 908b122c659..69bbce20eaf 100644
--- a/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb
+++ b/db/migrate/20170713104829_add_foreign_key_to_merge_requests.rb
@@ -6,7 +6,7 @@ class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
@@ -25,7 +25,7 @@ class AddForeignKeyToMergeRequests < ActiveRecord::Migration[4.2]
unless foreign_key_exists?(:merge_requests, column: :head_pipeline_id)
add_concurrent_foreign_key(:merge_requests, :ci_pipelines,
- column: :head_pipeline_id, on_delete: :nullify)
+ column: :head_pipeline_id, on_delete: :nullify)
end
end
diff --git a/db/migrate/20170717074009_move_system_upload_folder.rb b/db/migrate/20170717074009_move_system_upload_folder.rb
index 6c57a751c8d..1f8d67be7f9 100644
--- a/db/migrate/20170717074009_move_system_upload_folder.rb
+++ b/db/migrate/20170717074009_move_system_upload_folder.rb
@@ -6,7 +6,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2]
def up
unless file_storage?
- say 'Using object storage, no need to move.'
+ say "Using object storage, no need to move."
return
end
@@ -20,7 +20,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2]
return
end
- FileUtils.mkdir_p(File.join(base_directory, '-'))
+ FileUtils.mkdir_p(File.join(base_directory, "-"))
say "Moving #{old_directory} -> #{new_directory}"
FileUtils.mv(old_directory, new_directory)
@@ -29,7 +29,7 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2]
def down
unless file_storage?
- say 'Using object storage, no need to move.'
+ say "Using object storage, no need to move."
return
end
@@ -53,15 +53,15 @@ class MoveSystemUploadFolder < ActiveRecord::Migration[4.2]
end
def new_directory
- File.join(base_directory, '-', 'system')
+ File.join(base_directory, "-", "system")
end
def old_directory
- File.join(base_directory, 'system')
+ File.join(base_directory, "system")
end
def base_directory
- File.join(Rails.root, 'public', 'uploads')
+ File.join(Rails.root, "public", "uploads")
end
def file_storage?
diff --git a/db/migrate/20170720122741_create_user_custom_attributes.rb b/db/migrate/20170720122741_create_user_custom_attributes.rb
index 0e6f37d7317..86ade08b83b 100644
--- a/db/migrate/20170720122741_create_user_custom_attributes.rb
+++ b/db/migrate/20170720122741_create_user_custom_attributes.rb
@@ -6,7 +6,7 @@ class CreateUserCustomAttributes < ActiveRecord::Migration[4.2]
def change
create_table :user_custom_attributes do |t|
t.timestamps_with_timezone null: false
- t.references :user, null: false, foreign_key: { on_delete: :cascade }
+ t.references :user, null: false, foreign_key: {on_delete: :cascade}
t.string :key, null: false
t.string :value, null: false
diff --git a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb
index 1a6516f8777..86b8e41ad98 100644
--- a/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb
+++ b/db/migrate/20170724214302_add_lower_path_index_to_redirect_routes.rb
@@ -5,7 +5,7 @@ class AddLowerPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'index_on_redirect_routes_lower_path'
+ INDEX_NAME = "index_on_redirect_routes_lower_path"
disable_ddl_transaction!
diff --git a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb b/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb
index e92b5f28685..4963c11f2d8 100644
--- a/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb
+++ b/db/migrate/20170803130232_reorganise_issues_indexes_for_faster_sorting.rb
@@ -14,7 +14,7 @@ class ReorganiseIssuesIndexesForFasterSorting < ActiveRecord::Migration[4.2]
ADD_INDEX_COLUMNS = [
%i[project_id created_at id state],
%i[project_id due_date id state],
- %i[project_id updated_at id state]
+ %i[project_id updated_at id state],
].freeze
TABLE = :issues
diff --git a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb
index fd8cdbb95aa..5c86b188d73 100644
--- a/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb
+++ b/db/migrate/20170809134534_add_broadcast_message_not_null_constraints.rb
@@ -10,7 +10,7 @@ class AddBroadcastMessageNotNullConstraints < ActiveRecord::Migration[4.2]
COLUMNS = %i[starts_at ends_at created_at updated_at message_html]
class BroadcastMessage < ActiveRecord::Base
- self.table_name = 'broadcast_messages'
+ self.table_name = "broadcast_messages"
end
def up
diff --git a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb
index 5a1ea9514d1..67ee7205d46 100644
--- a/db/migrate/20170816133938_add_access_level_to_ci_runners.rb
+++ b/db/migrate/20170816133938_add_access_level_to_ci_runners.rb
@@ -7,7 +7,7 @@ class AddAccessLevelToCiRunners < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:ci_runners, :access_level, :integer,
- default: Ci::Runner.access_levels['not_protected'])
+ default: Ci::Runner.access_levels["not_protected"])
end
def down
diff --git a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb b/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb
index 82e05885b0e..974aa1f489d 100644
--- a/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb
+++ b/db/migrate/20170820100558_correct_protected_tags_foreign_keys.rb
@@ -11,7 +11,7 @@ class CorrectProtectedTagsForeignKeys < ActiveRecord::Migration[4.2]
def up
remove_foreign_key_without_error(:protected_tag_create_access_levels,
- column: :protected_tag_id)
+ column: :protected_tag_id)
execute <<-EOF
DELETE FROM protected_tag_create_access_levels
@@ -24,8 +24,8 @@ class CorrectProtectedTagsForeignKeys < ActiveRecord::Migration[4.2]
EOF
add_concurrent_foreign_key(:protected_tag_create_access_levels,
- :protected_tags,
- column: :protected_tag_id)
+ :protected_tags,
+ column: :protected_tag_id)
end
def down
diff --git a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb b/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb
index 131dcf7ac25..0aecfef851d 100644
--- a/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb
+++ b/db/migrate/20170820120108_create_user_synced_attributes_metadata.rb
@@ -8,7 +8,7 @@ class CreateUserSyncedAttributesMetadata < ActiveRecord::Migration[4.2]
t.boolean :name_synced, default: false
t.boolean :email_synced, default: false
t.boolean :location_synced, default: false
- t.references :user, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :user, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.string :provider
end
end
diff --git a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb
index b1adccc9c5c..39d018202f4 100644
--- a/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb
+++ b/db/migrate/20170825104051_migrate_issues_to_ghost_user.rb
@@ -5,11 +5,11 @@ class MigrateIssuesToGhostUser < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include ::EachBatch
end
@@ -27,7 +27,7 @@ class MigrateIssuesToGhostUser < ActiveRecord::Migration[4.2]
# we use the model method because rewriting it is too complicated and would require copying multiple methods
ghost_id = ::User.ghost.id
- Issue.where('NOT EXISTS (?)', User.unscoped.select(1).where('issues.author_id = users.id')).each_batch do |relation|
+ Issue.where("NOT EXISTS (?)", User.unscoped.select(1).where("issues.author_id = users.id")).each_batch do |relation|
relation.update_all(author_id: ghost_id)
end
end
diff --git a/db/migrate/20170828093725_create_project_auto_dev_ops.rb b/db/migrate/20170828093725_create_project_auto_dev_ops.rb
index ea895dc14c1..a9066028881 100644
--- a/db/migrate/20170828093725_create_project_auto_dev_ops.rb
+++ b/db/migrate/20170828093725_create_project_auto_dev_ops.rb
@@ -5,7 +5,7 @@ class CreateProjectAutoDevOps < ActiveRecord::Migration[4.2]
def up
create_table :project_auto_devops do |t|
- t.belongs_to :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.belongs_to :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
t.boolean :enabled, default: nil, null: true
diff --git a/db/migrate/20170828135939_migrate_user_external_mail_data.rb b/db/migrate/20170828135939_migrate_user_external_mail_data.rb
index 9ee4a4598bf..245705174b6 100644
--- a/db/migrate/20170828135939_migrate_user_external_mail_data.rb
+++ b/db/migrate/20170828135939_migrate_user_external_mail_data.rb
@@ -9,20 +9,20 @@ class MigrateUserExternalMailData < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
include EachBatch
end
class UserSyncedAttributesMetadata < ActiveRecord::Base
- self.table_name = 'user_synced_attributes_metadata'
+ self.table_name = "user_synced_attributes_metadata"
include EachBatch
end
def up
User.each_batch do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
execute <<-EOF
INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced)
@@ -42,7 +42,7 @@ class MigrateUserExternalMailData < ActiveRecord::Migration[4.2]
def down
UserSyncedAttributesMetadata.each_batch do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
execute <<-EOF
UPDATE users
diff --git a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb b/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb
index bcc34d56d2d..b28dcb29ea4 100644
--- a/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb
+++ b/db/migrate/20170830130119_steal_remaining_event_migration_jobs.rb
@@ -10,7 +10,7 @@ class StealRemainingEventMigrationJobs < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- Gitlab::BackgroundMigration.steal('MigrateEventsToPushEventPayloads')
+ Gitlab::BackgroundMigration.steal("MigrateEventsToPushEventPayloads")
end
def down
diff --git a/db/migrate/20170830131015_swap_event_migration_tables.rb b/db/migrate/20170830131015_swap_event_migration_tables.rb
index fb3b2472ffe..ca544ff6d97 100644
--- a/db/migrate/20170830131015_swap_event_migration_tables.rb
+++ b/db/migrate/20170830131015_swap_event_migration_tables.rb
@@ -8,7 +8,7 @@ class SwapEventMigrationTables < ActiveRecord::Migration[4.2]
DOWNTIME = false
class Event < ActiveRecord::Base
- self.table_name = 'events'
+ self.table_name = "events"
end
def up
@@ -40,7 +40,7 @@ class SwapEventMigrationTables < ActiveRecord::Migration[4.2]
end
def reset_primary_key_for_mysql
- amount = Event.pluck('COALESCE(MAX(id), 1)').first
+ amount = Event.pluck("COALESCE(MAX(id), 1)").first
execute "ALTER TABLE #{Event.table_name} AUTO_INCREMENT = #{amount}"
end
diff --git a/db/migrate/20170912113435_clean_stages_statuses_migration.rb b/db/migrate/20170912113435_clean_stages_statuses_migration.rb
index f2040f819cd..7544b409008 100644
--- a/db/migrate/20170912113435_clean_stages_statuses_migration.rb
+++ b/db/migrate/20170912113435_clean_stages_statuses_migration.rb
@@ -7,14 +7,14 @@ class CleanStagesStatusesMigration < ActiveRecord::Migration[4.2]
class Stage < ActiveRecord::Base
include ::EachBatch
- self.table_name = 'ci_stages'
+ self.table_name = "ci_stages"
end
def up
- Gitlab::BackgroundMigration.steal('MigrateStageStatus')
+ Gitlab::BackgroundMigration.steal("MigrateStageStatus")
- Stage.where('status IS NULL').each_batch(of: 50) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ Stage.where("status IS NULL").each_batch(of: 50) do |batch|
+ range = batch.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::MigrateStageStatus.new.perform(*range)
end
diff --git a/db/migrate/20170918072948_create_job_artifacts.rb b/db/migrate/20170918072948_create_job_artifacts.rb
index 4dd24aaff99..8d11db72279 100644
--- a/db/migrate/20170918072948_create_job_artifacts.rb
+++ b/db/migrate/20170918072948_create_job_artifacts.rb
@@ -5,7 +5,7 @@ class CreateJobArtifacts < ActiveRecord::Migration[4.2]
def change
create_table :ci_job_artifacts do |t|
- t.belongs_to :project, null: false, index: true, foreign_key: { on_delete: :cascade }
+ t.belongs_to :project, null: false, index: true, foreign_key: {on_delete: :cascade}
t.integer :job_id, null: false
t.integer :file_type, null: false
t.integer :size, limit: 8
diff --git a/db/migrate/20170918111708_create_project_custom_attributes.rb b/db/migrate/20170918111708_create_project_custom_attributes.rb
index bd6064689ff..ccc5a9f2d5f 100644
--- a/db/migrate/20170918111708_create_project_custom_attributes.rb
+++ b/db/migrate/20170918111708_create_project_custom_attributes.rb
@@ -4,7 +4,7 @@ class CreateProjectCustomAttributes < ActiveRecord::Migration[4.2]
def change
create_table :project_custom_attributes do |t|
t.timestamps_with_timezone null: false
- t.references :project, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, foreign_key: {on_delete: :cascade}
t.string :key, null: false
t.string :value, null: false
diff --git a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb b/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb
index 23c94a809d4..52bf67dc5d1 100644
--- a/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb
+++ b/db/migrate/20170919211300_remove_temporary_ci_builds_index.rb
@@ -11,7 +11,7 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- return unless index_exists?(:ci_builds, :id, name: 'index_for_ci_builds_retried_migration')
+ return unless index_exists?(:ci_builds, :id, name: "index_for_ci_builds_retried_migration")
remove_concurrent_index(:ci_builds, :id, name: "index_for_ci_builds_retried_migration")
end
@@ -21,8 +21,8 @@ class RemoveTemporaryCiBuildsIndex < ActiveRecord::Migration[4.2]
# present previously so this probably shouldn't be here but it's
# easier to test the drop if we have a way to create it.
add_concurrent_index("ci_builds", ["id"],
- name: "index_for_ci_builds_retried_migration",
- where: "(retried IS NULL)",
- using: :btree)
+ name: "index_for_ci_builds_retried_migration",
+ where: "(retried IS NULL)",
+ using: :btree)
end
end
diff --git a/db/migrate/20170924094327_create_gcp_clusters.rb b/db/migrate/20170924094327_create_gcp_clusters.rb
index 43201f75ad7..f5e6febf947 100644
--- a/db/migrate/20170924094327_create_gcp_clusters.rb
+++ b/db/migrate/20170924094327_create_gcp_clusters.rb
@@ -4,9 +4,9 @@ class CreateGcpClusters < ActiveRecord::Migration[4.2]
def change
create_table :gcp_clusters do |t|
# Order columns by best align scheme
- t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
- t.references :user, foreign_key: { on_delete: :nullify }
- t.references :service, foreign_key: { on_delete: :nullify }
+ t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
+ t.references :user, foreign_key: {on_delete: :nullify}
+ t.references :service, foreign_key: {on_delete: :nullify}
t.integer :status
t.integer :gcp_cluster_size, null: false
diff --git a/db/migrate/20170927161718_create_gpg_key_subkeys.rb b/db/migrate/20170927161718_create_gpg_key_subkeys.rb
index 3b5d452ee12..df167c40897 100644
--- a/db/migrate/20170927161718_create_gpg_key_subkeys.rb
+++ b/db/migrate/20170927161718_create_gpg_key_subkeys.rb
@@ -5,7 +5,7 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2]
def up
create_table :gpg_key_subkeys do |t|
- t.references :gpg_key, null: false, index: true, foreign_key: { on_delete: :cascade }
+ t.references :gpg_key, null: false, index: true, foreign_key: {on_delete: :cascade}
t.binary :keyid
t.binary :fingerprint
@@ -14,7 +14,7 @@ class CreateGpgKeySubkeys < ActiveRecord::Migration[4.2]
t.index :fingerprint, unique: true, length: mysql_compatible_index_length
end
- add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: { on_delete: :nullify }
+ add_reference :gpg_signatures, :gpg_key_subkey, index: true, foreign_key: {on_delete: :nullify}
end
def down
diff --git a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb
index cb16589e8db..d9c95999976 100644
--- a/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb
+++ b/db/migrate/20170928100231_add_composite_index_on_merge_requests_merge_commit_sha.rb
@@ -9,7 +9,7 @@ class AddCompositeIndexOnMergeRequestsMergeCommitSha < ActiveRecord::Migration[4
# The default index name is too long for PostgreSQL and would thus be
# truncated.
- INDEX_NAME = 'index_merge_requests_on_tp_id_and_merge_commit_sha_and_id'
+ INDEX_NAME = "index_merge_requests_on_tp_id_and_merge_commit_sha_and_id"
COLUMNS = [:target_project_id, :merge_commit_sha, :id]
diff --git a/db/migrate/20170928124105_create_fork_networks.rb b/db/migrate/20170928124105_create_fork_networks.rb
index 01f623117f5..7f149b05b26 100644
--- a/db/migrate/20170928124105_create_fork_networks.rb
+++ b/db/migrate/20170928124105_create_fork_networks.rb
@@ -8,15 +8,15 @@ class CreateForkNetworks < ActiveRecord::Migration[4.2]
def up
create_table :fork_networks do |t|
t.references :root_project,
- references: :projects,
- index: { unique: true }
+ references: :projects,
+ index: {unique: true}
t.string :deleted_root_project_name
end
add_concurrent_foreign_key :fork_networks, :projects,
- column: :root_project_id,
- on_delete: :nullify
+ column: :root_project_id,
+ on_delete: :nullify
end
def down
diff --git a/db/migrate/20170928133643_create_fork_network_members.rb b/db/migrate/20170928133643_create_fork_network_members.rb
index e2a6d7b0e8a..3855bcfc4ea 100644
--- a/db/migrate/20170928133643_create_fork_network_members.rb
+++ b/db/migrate/20170928133643_create_fork_network_members.rb
@@ -7,14 +7,14 @@ class CreateForkNetworkMembers < ActiveRecord::Migration[4.2]
def up
create_table :fork_network_members do |t|
- t.references :fork_network, null: false, index: true, foreign_key: { on_delete: :cascade }
- t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :fork_network, null: false, index: true, foreign_key: {on_delete: :cascade}
+ t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.references :forked_from_project, references: :projects
end
add_concurrent_foreign_key :fork_network_members, :projects,
- column: :forked_from_project_id,
- on_delete: :nullify
+ column: :forked_from_project_id,
+ on_delete: :nullify
end
def down
diff --git a/db/migrate/20170929131201_populate_fork_networks.rb b/db/migrate/20170929131201_populate_fork_networks.rb
index ba4f8ef2531..fc9e469222c 100644
--- a/db/migrate/20170929131201_populate_fork_networks.rb
+++ b/db/migrate/20170929131201_populate_fork_networks.rb
@@ -7,7 +7,7 @@ class PopulateForkNetworks < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller'
+ say "Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller"
end
def down
diff --git a/db/migrate/20171006090001_create_ci_build_trace_sections.rb b/db/migrate/20171006090001_create_ci_build_trace_sections.rb
index a2eca0832f2..0d963b9e849 100644
--- a/db/migrate/20171006090001_create_ci_build_trace_sections.rb
+++ b/db/migrate/20171006090001_create_ci_build_trace_sections.rb
@@ -5,7 +5,7 @@ class CreateCiBuildTraceSections < ActiveRecord::Migration[4.2]
def change
create_table :ci_build_trace_sections do |t|
- t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, index: true, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :date_start, null: false
t.datetime_with_timezone :date_end, null: false
t.integer :byte_start, limit: 8, null: false
diff --git a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb b/db/migrate/20171006090100_create_ci_build_trace_section_names.rb
index 00a38fa59c2..c1818c6d7c3 100644
--- a/db/migrate/20171006090100_create_ci_build_trace_section_names.rb
+++ b/db/migrate/20171006090100_create_ci_build_trace_section_names.rb
@@ -5,7 +5,7 @@ class CreateCiBuildTraceSectionNames < ActiveRecord::Migration[4.2]
def up
create_table :ci_build_trace_section_names do |t|
- t.references :project, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, foreign_key: {on_delete: :cascade}
t.string :name, null: false
end
diff --git a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb b/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb
index 91bba07b4d7..71b33b416b6 100644
--- a/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb
+++ b/db/migrate/20171012101043_add_circuit_breaker_properties_to_application_settings.rb
@@ -8,20 +8,20 @@ class AddCircuitBreakerPropertiesToApplicationSettings < ActiveRecord::Migration
def change
add_column :application_settings,
- :circuitbreaker_failure_count_threshold,
- :integer,
- default: 160
+ :circuitbreaker_failure_count_threshold,
+ :integer,
+ default: 160
add_column :application_settings,
- :circuitbreaker_failure_wait_time,
- :integer,
- default: 30
+ :circuitbreaker_failure_wait_time,
+ :integer,
+ default: 30
add_column :application_settings,
- :circuitbreaker_failure_reset_time,
- :integer,
- default: 1800
+ :circuitbreaker_failure_reset_time,
+ :integer,
+ default: 1800
add_column :application_settings,
- :circuitbreaker_storage_timeout,
- :integer,
- default: 30
+ :circuitbreaker_storage_timeout,
+ :integer,
+ default: 30
end
end
diff --git a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb b/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb
index 305c12e31f8..50e2e13b198 100644
--- a/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb
+++ b/db/migrate/20171012125712_migrate_user_authentication_token_to_personal_access_token.rb
@@ -9,7 +9,7 @@ class MigrateUserAuthenticationTokenToPersonalAccessToken < ActiveRecord::Migrat
# disable_ddl_transaction!
- TOKEN_NAME = 'Private Token'.freeze
+ TOKEN_NAME = "Private Token".freeze
def up
execute <<~SQL
diff --git a/db/migrate/20171013094327_create_new_clusters_architectures.rb b/db/migrate/20171013094327_create_new_clusters_architectures.rb
index 98f91e6130f..cd2b5a09c9e 100644
--- a/db/migrate/20171013094327_create_new_clusters_architectures.rb
+++ b/db/migrate/20171013094327_create_new_clusters_architectures.rb
@@ -3,7 +3,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2]
def change
create_table :clusters do |t|
- t.references :user, index: true, foreign_key: { on_delete: :nullify }
+ t.references :user, index: true, foreign_key: {on_delete: :nullify}
t.integer :provider_type
t.integer :platform_type
@@ -17,15 +17,15 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2]
end
create_table :cluster_projects do |t|
- t.references :project, null: false, index: true, foreign_key: { on_delete: :cascade }
- t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, index: true, foreign_key: {on_delete: :cascade}
+ t.references :cluster, null: false, index: true, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
end
create_table :cluster_platforms_kubernetes do |t|
- t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
@@ -44,7 +44,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration[4.2]
end
create_table :cluster_providers_gcp do |t|
- t.references :cluster, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
t.integer :status
t.integer :num_nodes, null: false
diff --git a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb
index 4a0cadea364..cec8a10d0c1 100644
--- a/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb
+++ b/db/migrate/20171017145932_add_new_circuitbreaker_settings_to_application_settings.rb
@@ -5,12 +5,12 @@ class AddNewCircuitbreakerSettingsToApplicationSettings < ActiveRecord::Migratio
def change
add_column :application_settings,
- :circuitbreaker_access_retries,
- :integer,
- default: 3
+ :circuitbreaker_access_retries,
+ :integer,
+ default: 3
add_column :application_settings,
- :circuitbreaker_backoff_threshold,
- :integer,
- default: 80
+ :circuitbreaker_backoff_threshold,
+ :integer,
+ default: 80
end
end
diff --git a/db/migrate/20171019141859_fix_dev_timezone_schema.rb b/db/migrate/20171019141859_fix_dev_timezone_schema.rb
index 68c8b528e17..330cd7e54d9 100644
--- a/db/migrate/20171019141859_fix_dev_timezone_schema.rb
+++ b/db/migrate/20171019141859_fix_dev_timezone_schema.rb
@@ -9,7 +9,7 @@ class FixDevTimezoneSchema < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- TIMEZONE_TABLES = %i(appearances ci_group_variables ci_pipeline_schedule_variables events gpg_keys gpg_signatures project_auto_devops)
+ TIMEZONE_TABLES = %i[appearances ci_group_variables ci_pipeline_schedule_variables events gpg_keys gpg_signatures project_auto_devops]
def up
return unless Rails.env.development? || Rails.env.test?
diff --git a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb b/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb
index 1af0cf70958..060efd0e146 100644
--- a/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb
+++ b/db/migrate/20171025110159_add_latest_merge_request_diff_id_to_merge_requests.rb
@@ -10,8 +10,8 @@ class AddLatestMergeRequestDiffIdToMergeRequests < ActiveRecord::Migration[4.2]
add_concurrent_index :merge_requests, :latest_merge_request_diff_id
add_concurrent_foreign_key :merge_requests, :merge_request_diffs,
- column: :latest_merge_request_diff_id,
- on_delete: :nullify
+ column: :latest_merge_request_diff_id,
+ on_delete: :nullify
end
def down
diff --git a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb b/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
index 0af05f5c94a..174a6fa4396 100644
--- a/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
+++ b/db/migrate/20171031100710_create_clusters_kubernetes_helm_apps.rb
@@ -5,7 +5,7 @@ class CreateClustersKubernetesHelmApps < ActiveRecord::Migration[4.2]
def change
create_table :clusters_applications_helm do |t|
- t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
diff --git a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb b/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb
index 6d60fdc6132..589ced6864a 100644
--- a/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb
+++ b/db/migrate/20171101130535_add_gitaly_timeout_properties_to_application_settings.rb
@@ -10,17 +10,17 @@ class AddGitalyTimeoutPropertiesToApplicationSettings < ActiveRecord::Migration[
def up
add_column_with_default :application_settings,
- :gitaly_timeout_default,
- :integer,
- default: 55
+ :gitaly_timeout_default,
+ :integer,
+ default: 55
add_column_with_default :application_settings,
- :gitaly_timeout_medium,
- :integer,
- default: 30
+ :gitaly_timeout_medium,
+ :integer,
+ default: 30
add_column_with_default :application_settings,
- :gitaly_timeout_fast,
- :integer,
- default: 10
+ :gitaly_timeout_fast,
+ :integer,
+ default: 10
end
def down
diff --git a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb b/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb
index 770cb94ee18..0972bdf7fb2 100644
--- a/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb
+++ b/db/migrate/20171106101200_create_clusters_kubernetes_ingress_apps.rb
@@ -5,7 +5,7 @@ class CreateClustersKubernetesIngressApps < ActiveRecord::Migration[4.2]
def change
create_table :clusters_applications_ingress do |t|
- t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone :created_at, null: false
t.datetime_with_timezone :updated_at, null: false
diff --git a/db/migrate/20171106132212_issues_confidential_not_null.rb b/db/migrate/20171106132212_issues_confidential_not_null.rb
index 444a38c2dc5..66c749eaeb0 100644
--- a/db/migrate/20171106132212_issues_confidential_not_null.rb
+++ b/db/migrate/20171106132212_issues_confidential_not_null.rb
@@ -8,11 +8,11 @@ class IssuesConfidentialNotNull < ActiveRecord::Migration[4.2]
DOWNTIME = false
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
end
def up
- Issue.where('confidential IS NULL').update_all(confidential: false)
+ Issue.where("confidential IS NULL").update_all(confidential: false)
change_column_null :issues, :confidential, false
end
diff --git a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb
index 1de7d5e768e..d4d6616c3e4 100644
--- a/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb
+++ b/db/migrate/20171106135924_issues_milestone_id_foreign_key.rb
@@ -12,11 +12,11 @@ class IssuesMilestoneIdForeignKey < ActiveRecord::Migration[4.2]
class Issue < ActiveRecord::Base
include EachBatch
- self.table_name = 'issues'
+ self.table_name = "issues"
def self.with_orphaned_milestones
- where('NOT EXISTS (SELECT true FROM milestones WHERE milestones.id = issues.milestone_id)')
- .where('milestone_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM milestones WHERE milestones.id = issues.milestone_id)")
+ .where("milestone_id IS NOT NULL")
end
end
diff --git a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb
index b2992b1ff5d..5ddd47bf991 100644
--- a/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb
+++ b/db/migrate/20171106150657_issues_updated_by_id_foreign_key.rb
@@ -12,11 +12,11 @@ class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration[4.2]
class Issue < ActiveRecord::Base
include EachBatch
- self.table_name = 'issues'
+ self.table_name = "issues"
def self.with_orphaned_updaters
- where('NOT EXISTS (SELECT true FROM users WHERE users.id = issues.updated_by_id)')
- .where('updated_by_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM users WHERE users.id = issues.updated_by_id)")
+ .where("updated_by_id IS NOT NULL")
end
end
@@ -28,7 +28,7 @@ class IssuesUpdatedByIdForeignKey < ActiveRecord::Migration[4.2]
# This index is only used for foreign keys, and those in turn will always
# specify a value. As such we can add a WHERE condition to make the index
# smaller.
- add_concurrent_index(:issues, :updated_by_id, where: 'updated_by_id IS NOT NULL')
+ add_concurrent_index(:issues, :updated_by_id, where: "updated_by_id IS NOT NULL")
add_concurrent_foreign_key(
:issues,
diff --git a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb
index 66bfb5718dc..17ea299cefa 100644
--- a/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb
+++ b/db/migrate/20171106151218_issues_moved_to_id_foreign_key.rb
@@ -12,22 +12,22 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration[4.2]
class Issue < ActiveRecord::Base
include EachBatch
- self.table_name = 'issues'
+ self.table_name = "issues"
def self.with_orphaned_moved_to_issues
if Gitlab::Database.postgresql?
# Be careful to use a second table here for comparison otherwise we'll null
# out all rows that don't have id == moved.to_id!
- where('NOT EXISTS (SELECT true FROM issues B WHERE issues.moved_to_id = B.id)')
- .where('moved_to_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM issues B WHERE issues.moved_to_id = B.id)")
+ .where("moved_to_id IS NOT NULL")
else
# MySQL doesn't allow modification of the same table in a subquery,
# and using a temporary table isn't automatically guaranteed to work
# due to the MySQL query optimizer. See
# https://dev.mysql.com/doc/refman/5.7/en/update.html for more
# details.
- joins('LEFT JOIN issues AS b ON issues.moved_to_id = b.id')
- .where('issues.moved_to_id IS NOT NULL AND b.id IS NULL')
+ joins("LEFT JOIN issues AS b ON issues.moved_to_id = b.id")
+ .where("issues.moved_to_id IS NOT NULL AND b.id IS NULL")
end
end
end
@@ -46,7 +46,7 @@ class IssuesMovedToIdForeignKey < ActiveRecord::Migration[4.2]
# We're using a partial index here so we only index the data we actually
# care about.
- add_concurrent_index(:issues, :moved_to_id, where: 'moved_to_id IS NOT NULL')
+ add_concurrent_index(:issues, :moved_to_id, where: "moved_to_id IS NOT NULL")
end
def down
diff --git a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
index 58392de5e6b..ba0dab3d488 100644
--- a/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
+++ b/db/migrate/20171106155656_turn_issues_due_date_index_to_partial_index.rb
@@ -7,8 +7,8 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- NEW_INDEX_NAME = 'idx_issues_on_project_id_and_due_date_and_id_and_state_partial'
- OLD_INDEX_NAME = 'index_issues_on_project_id_and_due_date_and_id_and_state'
+ NEW_INDEX_NAME = "idx_issues_on_project_id_and_due_date_and_id_and_state_partial"
+ OLD_INDEX_NAME = "index_issues_on_project_id_and_due_date_and_id_and_state"
disable_ddl_transaction!
@@ -16,7 +16,7 @@ class TurnIssuesDueDateIndexToPartialIndex < ActiveRecord::Migration[4.2]
add_concurrent_index(
:issues,
[:project_id, :due_date, :id, :state],
- where: 'due_date IS NOT NULL',
+ where: "due_date IS NOT NULL",
name: NEW_INDEX_NAME
)
diff --git a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb
index 4ebb6fad059..6d426fe5dee 100644
--- a/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb
+++ b/db/migrate/20171114150259_merge_requests_author_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsAuthorIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_authors
- where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.author_id = users.id)')
- .where('author_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.author_id = users.id)")
+ .where("author_id IS NOT NULL")
end
end
diff --git a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb
index 73c177c44f9..97136bf6c4c 100644
--- a/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb
+++ b/db/migrate/20171114160005_merge_requests_assignee_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsAssigneeIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_assignees
- where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.assignee_id = users.id)')
- .where('assignee_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.assignee_id = users.id)")
+ .where("assignee_id IS NOT NULL")
end
end
diff --git a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb
index 69f9c181c10..417294ff036 100644
--- a/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb
+++ b/db/migrate/20171114160904_merge_requests_updated_by_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_updaters
- where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.updated_by_id = users.id)')
- .where('updated_by_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.updated_by_id = users.id)")
+ .where("updated_by_id IS NOT NULL")
end
end
@@ -28,7 +28,7 @@ class MergeRequestsUpdatedByIdForeignKey < ActiveRecord::Migration[4.2]
add_concurrent_index(
:merge_requests,
:updated_by_id,
- where: 'updated_by_id IS NOT NULL'
+ where: "updated_by_id IS NOT NULL"
)
add_concurrent_foreign_key(
diff --git a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb
index ccd275d5bb4..5e5cb748e71 100644
--- a/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb
+++ b/db/migrate/20171114161720_merge_requests_merge_user_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_mergers
- where('NOT EXISTS (SELECT true FROM users WHERE merge_requests.merge_user_id = users.id)')
- .where('merge_user_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM users WHERE merge_requests.merge_user_id = users.id)")
+ .where("merge_user_id IS NOT NULL")
end
end
@@ -28,7 +28,7 @@ class MergeRequestsMergeUserIdForeignKey < ActiveRecord::Migration[4.2]
add_concurrent_index(
:merge_requests,
:merge_user_id,
- where: 'merge_user_id IS NOT NULL'
+ where: "merge_user_id IS NOT NULL"
)
add_concurrent_foreign_key(
diff --git a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
index 250928a6551..33c4630cdef 100644
--- a/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
+++ b/db/migrate/20171114161914_merge_requests_source_project_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsSourceProjectIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_source_projects
- where('NOT EXISTS (SELECT true FROM projects WHERE merge_requests.source_project_id = projects.id)')
- .where('source_project_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM projects WHERE merge_requests.source_project_id = projects.id)")
+ .where("source_project_id IS NOT NULL")
end
end
diff --git a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb
index cafe0ce0853..b7ce5ae458d 100644
--- a/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb
+++ b/db/migrate/20171114162227_merge_requests_milestone_id_foreign_key.rb
@@ -12,11 +12,11 @@ class MergeRequestsMilestoneIdForeignKey < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
def self.with_orphaned_milestones
- where('NOT EXISTS (SELECT true FROM milestones WHERE merge_requests.milestone_id = milestones.id)')
- .where('milestone_id IS NOT NULL')
+ where("NOT EXISTS (SELECT true FROM milestones WHERE merge_requests.milestone_id = milestones.id)")
+ .where("milestone_id IS NOT NULL")
end
end
diff --git a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb
index 935092ce46a..39e87a77e67 100644
--- a/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb
+++ b/db/migrate/20171115164540_populate_merge_requests_latest_merge_request_diff_id_take_two.rb
@@ -6,7 +6,7 @@ class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migra
BATCH_SIZE = 1_000
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
@@ -14,7 +14,7 @@ class PopulateMergeRequestsLatestMergeRequestDiffIdTakeTwo < ActiveRecord::Migra
disable_ddl_transaction!
def up
- Gitlab::BackgroundMigration.steal('PopulateMergeRequestsLatestMergeRequestDiffId')
+ Gitlab::BackgroundMigration.steal("PopulateMergeRequestsLatestMergeRequestDiffId")
update = '
latest_merge_request_diff_id = (
diff --git a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb b/db/migrate/20171116135628_add_environment_scope_to_clusters.rb
index 39bb8759cc0..9a6b8db3b83 100644
--- a/db/migrate/20171116135628_add_environment_scope_to_clusters.rb
+++ b/db/migrate/20171116135628_add_environment_scope_to_clusters.rb
@@ -6,7 +6,7 @@ class AddEnvironmentScopeToClusters < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_column_with_default(:clusters, :environment_scope, :string, default: '*')
+ add_column_with_default(:clusters, :environment_scope, :string, default: "*")
end
def down
diff --git a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb
index 6be7b75492d..42ac8f6433e 100644
--- a/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb
+++ b/db/migrate/20171121135738_clean_up_from_merge_request_diffs_and_commits.rb
@@ -4,7 +4,7 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2]
DOWNTIME = false
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
end
@@ -12,12 +12,12 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- Gitlab::BackgroundMigration.steal('DeserializeMergeRequestDiffsAndCommits')
+ Gitlab::BackgroundMigration.steal("DeserializeMergeRequestDiffsAndCommits")
# The literal '--- []\n' value is created by the import process and treated
# as null by the application, so we can ignore those - even if we were
# migrating, it wouldn't create any rows.
- literal_prefix = Gitlab::Database.postgresql? ? 'E' : ''
+ literal_prefix = Gitlab::Database.postgresql? ? "E" : ""
non_empty = "
(st_commits IS NOT NULL AND st_commits != #{literal_prefix}'--- []\n')
OR
@@ -25,7 +25,7 @@ class CleanUpFromMergeRequestDiffsAndCommits < ActiveRecord::Migration[4.2]
".squish
MergeRequestDiff.where(non_empty).each_batch(of: 500) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits.new.perform(*range)
end
diff --git a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb b/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb
index cbcbb5d988a..e54b37edab9 100644
--- a/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb
+++ b/db/migrate/20171122131600_add_new_project_guidelines_to_appearances.rb
@@ -8,7 +8,7 @@ class AddNewProjectGuidelinesToAppearances < ActiveRecord::Migration[4.2]
# new_project_guidelines_html would be missing. See
# https://gitlab.com/gitlab-org/gitlab-ce/issues/41041
# We're not using Appearance#flush_redis_cache on purpose here.
- Rails.cache.delete('current_appearance')
+ Rails.cache.delete("current_appearance")
change_table :appearances do |t|
t.text :new_project_guidelines
diff --git a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb b/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb
index 94360c64926..35dc9edbf79 100644
--- a/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb
+++ b/db/migrate/20171123094802_add_circuitbreaker_check_interval_to_application_settings.rb
@@ -8,13 +8,13 @@ class AddCircuitbreakerCheckIntervalToApplicationSettings < ActiveRecord::Migrat
def up
add_column_with_default :application_settings,
- :circuitbreaker_check_interval,
- :integer,
- default: 1
+ :circuitbreaker_check_interval,
+ :integer,
+ default: 1
end
def down
remove_column :application_settings,
- :circuitbreaker_check_interval
+ :circuitbreaker_check_interval
end
end
diff --git a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb
index 67444f36e24..01797f30ac8 100644
--- a/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb
+++ b/db/migrate/20171124125748_populate_missing_merge_request_statuses.rb
@@ -12,25 +12,25 @@ class PopulateMissingMergeRequestStatuses < ActiveRecord::Migration[4.2]
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
end
def up
- say 'Populating missing merge_requests.state values'
+ say "Populating missing merge_requests.state values"
# GitLab.com has no rows where "state" is NULL, and technically this should
# never happen. However it doesn't hurt to be 100% certain.
MergeRequest.where(state: nil).each_batch do |batch|
- batch.update_all(state: 'opened')
+ batch.update_all(state: "opened")
end
- say 'Populating missing merge_requests.merge_status values. ' \
- 'This will take a few minutes...'
+ say "Populating missing merge_requests.merge_status values. " \
+ "This will take a few minutes..."
# GitLab.com has 66 880 rows where "merge_status" is NULL, dating back all
# the way to 2011.
MergeRequest.where(merge_status: nil).each_batch(of: 10_000) do |batch|
- batch.update_all(merge_status: 'unchecked')
+ batch.update_all(merge_status: "unchecked")
# We want to give PostgreSQL some time to vacuum any dead tuples. In
# production we see it takes roughly 1 minute for a vacuuming run to clear
diff --git a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb b/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb
index 385de9dd73d..d6c00d526a9 100644
--- a/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb
+++ b/db/migrate/20171127151038_add_events_related_columns_to_merge_request_metrics.rb
@@ -14,12 +14,12 @@ class AddEventsRelatedColumnsToMergeRequestMetrics < ActiveRecord::Migration[4.2
add_column :merge_request_metrics, :latest_closed_at, :datetime_with_timezone
add_concurrent_foreign_key :merge_request_metrics, :users,
- column: :merged_by_id,
- on_delete: :nullify
+ column: :merged_by_id,
+ on_delete: :nullify
add_concurrent_foreign_key :merge_request_metrics, :users,
- column: :latest_closed_by_id,
- on_delete: :nullify
+ column: :latest_closed_by_id,
+ on_delete: :nullify
end
def down
diff --git a/db/migrate/20171207185153_add_merge_request_state_index.rb b/db/migrate/20171207185153_add_merge_request_state_index.rb
index 167470cf7fe..fda01a0718a 100644
--- a/db/migrate/20171207185153_add_merge_request_state_index.rb
+++ b/db/migrate/20171207185153_add_merge_request_state_index.rb
@@ -7,12 +7,12 @@ class AddMergeRequestStateIndex < ActiveRecord::Migration[4.2]
def up
add_concurrent_index :merge_requests, [:source_project_id, :source_branch],
- where: "state = 'opened'",
- name: 'index_merge_requests_on_source_project_and_branch_state_opened'
+ where: "state = 'opened'",
+ name: "index_merge_requests_on_source_project_and_branch_state_opened"
end
def down
remove_concurrent_index_by_name :merge_requests,
- 'index_merge_requests_on_source_project_and_branch_state_opened'
+ "index_merge_requests_on_source_project_and_branch_state_opened"
end
end
diff --git a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb b/db/migrate/20171212203433_create_clusters_applications_prometheus.rb
index 6eb9fec609e..f0b0bee2354 100644
--- a/db/migrate/20171212203433_create_clusters_applications_prometheus.rb
+++ b/db/migrate/20171212203433_create_clusters_applications_prometheus.rb
@@ -5,7 +5,7 @@ class CreateClustersApplicationsPrometheus < ActiveRecord::Migration[4.2]
def change
create_table :clusters_applications_prometheus do |t|
- t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade}
t.integer :status, null: false
t.string :version, null: false
diff --git a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb
index e2d7879b140..c233ec870e7 100644
--- a/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb
+++ b/db/migrate/20171215113714_populate_can_push_from_deploy_keys_projects.rb
@@ -13,12 +13,12 @@ class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2]
class DeploysKeyProject < ActiveRecord::Base
include EachBatch
- self.table_name = 'deploy_keys_projects'
+ self.table_name = "deploy_keys_projects"
end
def up
DeploysKeyProject.each_batch(of: 10_000) do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
if Gitlab::Database.mysql?
execute <<-EOF.strip_heredoc
@@ -41,7 +41,7 @@ class PopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2]
def down
DeploysKeyProject.each_batch(of: 10_000) do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
if Gitlab::Database.mysql?
execute <<-EOF.strip_heredoc
diff --git a/db/migrate/20171216111734_clean_up_for_members.rb b/db/migrate/20171216111734_clean_up_for_members.rb
index 2fefc6c7fd1..9e33a2c186e 100644
--- a/db/migrate/20171216111734_clean_up_for_members.rb
+++ b/db/migrate/20171216111734_clean_up_for_members.rb
@@ -12,7 +12,7 @@ class CleanUpForMembers < ActiveRecord::Migration[4.2]
class Member < ActiveRecord::Base
include EachBatch
- self.table_name = 'members'
+ self.table_name = "members"
end
def up
diff --git a/db/migrate/20171216112339_add_foreign_key_for_members.rb b/db/migrate/20171216112339_add_foreign_key_for_members.rb
index 06c2c5068da..81aa305d7fb 100644
--- a/db/migrate/20171216112339_add_foreign_key_for_members.rb
+++ b/db/migrate/20171216112339_add_foreign_key_for_members.rb
@@ -11,8 +11,8 @@ class AddForeignKeyForMembers < ActiveRecord::Migration[4.2]
def up
add_concurrent_foreign_key(:members,
- :users,
- column: :user_id)
+ :users,
+ column: :user_id)
end
def down
diff --git a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
index 7543e435941..a65c842eaaf 100644
--- a/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
+++ b/db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb
@@ -1,7 +1,7 @@
class AddIndexOnNamespacesLowerName < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'index_on_namespaces_lower_name'
+ INDEX_NAME = "index_on_namespaces_lower_name"
disable_ddl_transaction!
diff --git a/db/migrate/20180101160629_create_prometheus_metrics.rb b/db/migrate/20180101160629_create_prometheus_metrics.rb
index e3b1ed710d6..5edd93d569c 100644
--- a/db/migrate/20180101160629_create_prometheus_metrics.rb
+++ b/db/migrate/20180101160629_create_prometheus_metrics.rb
@@ -5,7 +5,7 @@ class CreatePrometheusMetrics < ActiveRecord::Migration[4.2]
def change
create_table :prometheus_metrics do |t|
- t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: false
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: false
t.string :title, null: false
t.string :query, null: false
t.string :y_label
diff --git a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb
index e27eecde906..14a67fe47e0 100644
--- a/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb
+++ b/db/migrate/20180105212544_add_commits_count_to_merge_request_diff.rb
@@ -3,12 +3,12 @@ class AddCommitsCountToMergeRequestDiff < ActiveRecord::Migration[4.2]
DOWNTIME = false
- MIGRATION = 'AddMergeRequestDiffCommitsCount'.freeze
+ MIGRATION = "AddMergeRequestDiffCommitsCount".freeze
BATCH_SIZE = 5000
DELAY_INTERVAL = 5.minutes.to_i
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
end
@@ -18,7 +18,7 @@ class AddCommitsCountToMergeRequestDiff < ActiveRecord::Migration[4.2]
def up
add_column :merge_request_diffs, :commits_count, :integer
- say 'Populating the MergeRequestDiff `commits_count`'
+ say "Populating the MergeRequestDiff `commits_count`"
queue_background_migration_jobs_by_range_at_intervals(MergeRequestDiff, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
end
diff --git a/db/migrate/20180116193854_create_lfs_file_locks.rb b/db/migrate/20180116193854_create_lfs_file_locks.rb
index 2dd0e71916b..c57ff168a8f 100644
--- a/db/migrate/20180116193854_create_lfs_file_locks.rb
+++ b/db/migrate/20180116193854_create_lfs_file_locks.rb
@@ -7,8 +7,8 @@ class CreateLfsFileLocks < ActiveRecord::Migration[4.2]
def up
create_table :lfs_file_locks do |t|
- t.references :project, null: false, foreign_key: { on_delete: :cascade }
- t.references :user, null: false, index: true, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, foreign_key: {on_delete: :cascade}
+ t.references :user, null: false, index: true, foreign_key: {on_delete: :cascade}
t.datetime :created_at, null: false
t.string :path, limit: 511
end
diff --git a/db/migrate/20180125214301_create_user_callouts.rb b/db/migrate/20180125214301_create_user_callouts.rb
index 6eb2f932ccc..c0dbb5bbd72 100644
--- a/db/migrate/20180125214301_create_user_callouts.rb
+++ b/db/migrate/20180125214301_create_user_callouts.rb
@@ -8,7 +8,7 @@ class CreateUserCallouts < ActiveRecord::Migration[4.2]
def change
create_table :user_callouts do |t|
t.integer :feature_name, null: false
- t.references :user, index: true, foreign_key: { on_delete: :cascade }, null: false
+ t.references :user, index: true, foreign_key: {on_delete: :cascade}, null: false
end
add_index :user_callouts, [:user_id, :feature_name], unique: true
diff --git a/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb b/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb
index 1f2a79d36a5..3122c26db81 100644
--- a/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb
+++ b/db/migrate/20180201102129_add_unique_constraint_to_trending_projects_project_id.rb
@@ -6,14 +6,14 @@ class AddUniqueConstraintToTrendingProjectsProjectId < ActiveRecord::Migration[4
disable_ddl_transaction!
def up
- add_concurrent_index :trending_projects, :project_id, unique: true, name: 'index_trending_projects_on_project_id_unique'
- remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id'
- rename_index :trending_projects, 'index_trending_projects_on_project_id_unique', 'index_trending_projects_on_project_id'
+ add_concurrent_index :trending_projects, :project_id, unique: true, name: "index_trending_projects_on_project_id_unique"
+ remove_concurrent_index_by_name :trending_projects, "index_trending_projects_on_project_id"
+ rename_index :trending_projects, "index_trending_projects_on_project_id_unique", "index_trending_projects_on_project_id"
end
def down
- rename_index :trending_projects, 'index_trending_projects_on_project_id', 'index_trending_projects_on_project_id_old'
+ rename_index :trending_projects, "index_trending_projects_on_project_id", "index_trending_projects_on_project_id_old"
add_concurrent_index :trending_projects, :project_id
- remove_concurrent_index_by_name :trending_projects, 'index_trending_projects_on_project_id_old'
+ remove_concurrent_index_by_name :trending_projects, "index_trending_projects_on_project_id_old"
end
end
diff --git a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
index 6b217632a52..86e3445885f 100644
--- a/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
+++ b/db/migrate/20180201110056_add_foreign_keys_to_todos.rb
@@ -2,7 +2,7 @@ class AddForeignKeysToTodos < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
class Todo < ActiveRecord::Base
- self.table_name = 'todos'
+ self.table_name = "todos"
include EachBatch
end
@@ -13,15 +13,15 @@ class AddForeignKeysToTodos < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- Todo.where('NOT EXISTS ( SELECT true FROM users WHERE id=todos.user_id )').each_batch(of: BATCH_SIZE) do |batch|
+ Todo.where("NOT EXISTS ( SELECT true FROM users WHERE id=todos.user_id )").each_batch(of: BATCH_SIZE) do |batch|
batch.delete_all
end
- Todo.where('NOT EXISTS ( SELECT true FROM users WHERE id=todos.author_id )').each_batch(of: BATCH_SIZE) do |batch|
+ Todo.where("NOT EXISTS ( SELECT true FROM users WHERE id=todos.author_id )").each_batch(of: BATCH_SIZE) do |batch|
batch.delete_all
end
- Todo.where('note_id IS NOT NULL AND NOT EXISTS ( SELECT true FROM notes WHERE id=todos.note_id )').each_batch(of: BATCH_SIZE) do |batch|
+ Todo.where("note_id IS NOT NULL AND NOT EXISTS ( SELECT true FROM notes WHERE id=todos.note_id )").each_batch(of: BATCH_SIZE) do |batch|
batch.delete_all
end
diff --git a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb
index d398909f25b..5f1db2138e5 100644
--- a/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb
+++ b/db/migrate/20180201145907_migrate_remaining_issues_closed_at.rb
@@ -10,13 +10,13 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include EachBatch
end
def up
- Gitlab::BackgroundMigration.steal('CopyColumn')
- Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange')
+ Gitlab::BackgroundMigration.steal("CopyColumn")
+ Gitlab::BackgroundMigration.steal("CleanupConcurrentTypeChange")
if migrate_column_type?
if closed_at_for_type_change_exists?
@@ -37,8 +37,8 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2]
end
def migrate_remaining_rows
- Issue.where('closed_at_for_type_change IS NULL AND closed_at IS NOT NULL').each_batch do |batch|
- batch.update_all('closed_at_for_type_change = closed_at')
+ Issue.where("closed_at_for_type_change IS NULL AND closed_at IS NOT NULL").each_batch do |batch|
+ batch.update_all("closed_at_for_type_change = closed_at")
end
cleanup_concurrent_column_type_change(:issues, :closed_at)
@@ -47,10 +47,10 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration[4.2]
def migrate_column_type?
# Some environments may have already executed the previous version of this
# migration, thus we don't need to migrate those environments again.
- column_for('issues', 'closed_at').type == :datetime # rubocop:disable Migration/Datetime
+ column_for("issues", "closed_at").type == :datetime # rubocop:disable Migration/Datetime
end
def closed_at_for_type_change_exists?
- columns('issues').any? { |col| col.name == 'closed_at_for_type_change' }
+ columns("issues").any? { |col| col.name == "closed_at_for_type_change" }
end
end
diff --git a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb
index d395c5725e4..e52fad7e250 100644
--- a/db/migrate/20180206200543_reset_events_primary_key_sequence.rb
+++ b/db/migrate/20180206200543_reset_events_primary_key_sequence.rb
@@ -8,7 +8,7 @@ class ResetEventsPrimaryKeySequence < ActiveRecord::Migration[4.2]
DOWNTIME = false
class Event < ActiveRecord::Base
- self.table_name = 'events'
+ self.table_name = "events"
end
def up
@@ -28,7 +28,7 @@ class ResetEventsPrimaryKeySequence < ActiveRecord::Migration[4.2]
end
def reset_primary_key_for_mysql
- amount = Event.pluck('COALESCE(MAX(id), 1)').first
+ amount = Event.pluck("COALESCE(MAX(id), 1)").first
execute "ALTER TABLE #{Event.table_name} AUTO_INCREMENT = #{amount}"
end
diff --git a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb
index b69ac8f94c1..0f90e95d2c7 100644
--- a/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb
+++ b/db/migrate/20180208183958_schedule_populate_untracked_uploads_if_needed.rb
@@ -6,12 +6,12 @@ class SchedulePopulateUntrackedUploadsIfNeeded < ActiveRecord::Migration[4.2]
DOWNTIME = false
- FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze
+ FOLLOW_UP_MIGRATION = "PopulateUntrackedUploads".freeze
class UntrackedFile < ActiveRecord::Base
include EachBatch
- self.table_name = 'untracked_files_for_uploads'
+ self.table_name = "untracked_files_for_uploads"
end
def up
@@ -42,6 +42,7 @@ class SchedulePopulateUntrackedUploadsIfNeeded < ActiveRecord::Migration[4.2]
say "Scheduling #{FOLLOW_UP_MIGRATION} background migration jobs since there are rows in untracked_files_for_uploads."
bulk_queue_background_migration_jobs_by_range(
- UntrackedFile, FOLLOW_UP_MIGRATION)
+ UntrackedFile, FOLLOW_UP_MIGRATION
+ )
end
end
diff --git a/db/migrate/20180209115333_create_chatops_tables.rb b/db/migrate/20180209115333_create_chatops_tables.rb
index 2cfb71e1007..f5af604ac1f 100644
--- a/db/migrate/20180209115333_create_chatops_tables.rb
+++ b/db/migrate/20180209115333_create_chatops_tables.rb
@@ -8,7 +8,7 @@ class CreateChatopsTables < ActiveRecord::Migration[4.2]
def change
create_table :ci_pipeline_chat_data, id: :bigserial do |t|
t.integer :pipeline_id, null: false
- t.references :chat_name, foreign_key: { on_delete: :cascade }, null: false
+ t.references :chat_name, foreign_key: {on_delete: :cascade}, null: false
t.text :response_url, null: false
# A pipeline can only contain one row in this table, hence this index is
diff --git a/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb b/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb
index 905915d9239..126122e2e5c 100644
--- a/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb
+++ b/db/migrate/20180213131630_add_partial_index_to_projects_for_index_only_scans.rb
@@ -2,14 +2,14 @@ class AddPartialIndexToProjectsForIndexOnlyScans < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'index_projects_on_id_partial_for_visibility'
+ INDEX_NAME = "index_projects_on_id_partial_for_visibility"
disable_ddl_transaction!
# Adds a partial index to leverage index-only scans when looking up project ids
def up
unless index_exists?(:projects, :id, name: INDEX_NAME)
- add_concurrent_index :projects, :id, name: INDEX_NAME, unique: true, where: 'visibility_level IN (10,20)'
+ add_concurrent_index :projects, :id, name: INDEX_NAME, unique: true, where: "visibility_level IN (10,20)"
end
end
diff --git a/db/migrate/20180214093516_create_badges.rb b/db/migrate/20180214093516_create_badges.rb
index 66e017b115a..95795b9ef12 100644
--- a/db/migrate/20180214093516_create_badges.rb
+++ b/db/migrate/20180214093516_create_badges.rb
@@ -5,7 +5,7 @@ class CreateBadges < ActiveRecord::Migration[4.2]
create_table :badges do |t|
t.string :link_url, null: false
t.string :image_url, null: false
- t.references :project, index: true, foreign_key: { on_delete: :cascade }, null: true
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}, null: true
t.integer :group_id, index: true, null: true
t.string :type, null: false
diff --git a/db/migrate/20180214155405_create_clusters_applications_runners.rb b/db/migrate/20180214155405_create_clusters_applications_runners.rb
index ce594c91890..c63efa6eb64 100644
--- a/db/migrate/20180214155405_create_clusters_applications_runners.rb
+++ b/db/migrate/20180214155405_create_clusters_applications_runners.rb
@@ -7,7 +7,7 @@ class CreateClustersApplicationsRunners < ActiveRecord::Migration[4.2]
def up
create_table :clusters_applications_runners do |t|
- t.references :cluster, null: false, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, foreign_key: {on_delete: :cascade}
t.references :runner, references: :ci_runners
t.index :runner_id
t.index :cluster_id, unique: true
diff --git a/db/migrate/20180215181245_users_name_lower_index.rb b/db/migrate/20180215181245_users_name_lower_index.rb
index 3b80601a727..f483e4c0acb 100644
--- a/db/migrate/20180215181245_users_name_lower_index.rb
+++ b/db/migrate/20180215181245_users_name_lower_index.rb
@@ -6,7 +6,7 @@ class UsersNameLowerIndex < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_on_users_name_lower'
+ INDEX_NAME = "index_on_users_name_lower"
disable_ddl_transaction!
diff --git a/db/migrate/20180223120443_create_user_interacted_projects_table.rb b/db/migrate/20180223120443_create_user_interacted_projects_table.rb
index 185a690ad3d..cd8c386e87a 100644
--- a/db/migrate/20180223120443_create_user_interacted_projects_table.rb
+++ b/db/migrate/20180223120443_create_user_interacted_projects_table.rb
@@ -3,7 +3,7 @@ class CreateUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
DOWNTIME = false
- INDEX_NAME = 'user_interacted_projects_non_unique_index'
+ INDEX_NAME = "user_interacted_projects_non_unique_index"
def up
create_table :user_interacted_projects, id: false do |t|
diff --git a/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb b/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb
index 3bd7d6fd827..64061c01b5e 100644
--- a/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb
+++ b/db/migrate/20180223144945_add_allow_local_requests_from_hooks_and_services_to_application_settings.rb
@@ -7,9 +7,9 @@ class AddAllowLocalRequestsFromHooksAndServicesToApplicationSettings < ActiveRec
def up
add_column_with_default(:application_settings, :allow_local_requests_from_hooks_and_services,
- :boolean,
- default: false,
- allow_null: false)
+ :boolean,
+ default: false,
+ allow_null: false)
end
def down
diff --git a/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb b/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb
index d660c7cfd2d..766b1191bc8 100644
--- a/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb
+++ b/db/migrate/20180302152117_ensure_foreign_keys_on_clusters_applications.rb
@@ -12,9 +12,9 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration[4.2]
def up
existing = Clusters::Cluster
.joins(:application_ingress)
- .where('clusters.id = clusters_applications_ingress.cluster_id')
+ .where("clusters.id = clusters_applications_ingress.cluster_id")
- Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch|
+ Clusters::Applications::Ingress.where("NOT EXISTS (?)", existing).in_batches do |batch|
batch.delete_all
end
@@ -26,9 +26,9 @@ class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration[4.2]
existing = Clusters::Cluster
.joins(:application_prometheus)
- .where('clusters.id = clusters_applications_prometheus.cluster_id')
+ .where("clusters.id = clusters_applications_prometheus.cluster_id")
- Clusters::Applications::Ingress.where('NOT EXISTS (?)', existing).in_batches do |batch|
+ Clusters::Applications::Ingress.where("NOT EXISTS (?)", existing).in_batches do |batch|
batch.delete_all
end
diff --git a/db/migrate/20180305095250_create_internal_ids_table.rb b/db/migrate/20180305095250_create_internal_ids_table.rb
index 8565f5d848b..ca4f2ae8dee 100644
--- a/db/migrate/20180305095250_create_internal_ids_table.rb
+++ b/db/migrate/20180305095250_create_internal_ids_table.rb
@@ -5,7 +5,7 @@ class CreateInternalIdsTable < ActiveRecord::Migration[4.2]
def change
create_table :internal_ids, id: :bigserial do |t|
- t.references :project, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, foreign_key: {on_delete: :cascade}
t.integer :usage, null: false
t.integer :last_value, null: false
diff --git a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
index 4d2ab7d757f..1f139eb0464 100644
--- a/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
+++ b/db/migrate/20180308052825_add_section_name_id_index_on_ci_build_trace_sections.rb
@@ -3,7 +3,7 @@ class AddSectionNameIdIndexOnCiBuildTraceSections < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_ci_build_trace_sections_on_section_name_id'
+ INDEX_NAME = "index_ci_build_trace_sections_on_section_name_id"
disable_ddl_transaction!
diff --git a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
index ecb06dd4312..c027a4b91f3 100644
--- a/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
+++ b/db/migrate/20180309121820_reschedule_commits_count_for_merge_request_diff.rb
@@ -3,12 +3,12 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2]
DOWNTIME = false
- MIGRATION = 'AddMergeRequestDiffCommitsCount'.freeze
+ MIGRATION = "AddMergeRequestDiffCommitsCount".freeze
BATCH_SIZE = 5000
DELAY_INTERVAL = 5.minutes.to_i
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
end
@@ -16,12 +16,12 @@ class RescheduleCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- say 'Populating the MergeRequestDiff `commits_count` (reschedule)'
+ say "Populating the MergeRequestDiff `commits_count` (reschedule)"
execute("SET statement_timeout TO '60s'") if Gitlab::Database.postgresql?
MergeRequestDiff.where(commits_count: nil).each_batch(of: BATCH_SIZE) do |relation, index|
- start_id, end_id = relation.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = relation.pluck("MIN(id), MAX(id)").first
delay = index * DELAY_INTERVAL
BackgroundMigrationWorker.perform_in(delay, MIGRATION, [start_id, end_id])
diff --git a/db/migrate/20180319190020_create_deploy_tokens.rb b/db/migrate/20180319190020_create_deploy_tokens.rb
index a4d797679c5..edc1cd3db3a 100644
--- a/db/migrate/20180319190020_create_deploy_tokens.rb
+++ b/db/migrate/20180319190020_create_deploy_tokens.rb
@@ -11,7 +11,7 @@ class CreateDeployTokens < ActiveRecord::Migration[4.2]
t.datetime_with_timezone :created_at, null: false
t.string :name, null: false
- t.string :token, index: { unique: true }, null: false
+ t.string :token, index: {unique: true}, null: false
t.index [:token, :expires_at, :id], where: "(revoked IS FALSE)"
end
diff --git a/db/migrate/20180403035759_create_project_ci_cd_settings.rb b/db/migrate/20180403035759_create_project_ci_cd_settings.rb
index 00028689779..4d5a63dc8c4 100644
--- a/db/migrate/20180403035759_create_project_ci_cd_settings.rb
+++ b/db/migrate/20180403035759_create_project_ci_cd_settings.rb
@@ -15,7 +15,7 @@ class CreateProjectCiCdSettings < ActiveRecord::Migration[4.2]
disable_statement_timeout do
# This particular INSERT will take between 10 and 20 seconds.
- execute 'INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects'
+ execute "INSERT INTO project_ci_cd_settings (project_id) SELECT id FROM projects"
# We add the index and foreign key separately so the above INSERT statement
# takes as little time as possible.
@@ -46,7 +46,7 @@ class CreateProjectCiCdSettings < ActiveRecord::Migration[4.2]
add_project_id_foreign_key
break
rescue ActiveRecord::InvalidForeignKey
- say 'project_ci_cd_settings contains some orphaned rows, retrying...'
+ say "project_ci_cd_settings contains some orphaned rows, retrying..."
end
end
end
diff --git a/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb b/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb
index 0b541e94353..ad4062fbd51 100644
--- a/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb
+++ b/db/migrate/20180406204716_add_limits_ci_build_trace_chunks_raw_data_for_mysql.rb
@@ -1,6 +1,6 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
-require Rails.root.join('db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql')
+require Rails.root.join("db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql")
class AddLimitsCiBuildTraceChunksRawDataForMysql < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
diff --git a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
index 8de8b3bcc2e..0aa1d5715b4 100644
--- a/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
+++ b/db/migrate/20180413022611_create_missing_namespace_for_internal_users.rb
@@ -40,10 +40,10 @@ class CreateMissingNamespaceForInternalUsers < ActiveRecord::Migration[4.2]
end
def create_namespace(user_id, username)
- path = Uniquify.new.string(username) do |str|
+ path = Uniquify.new.string(username) { |str|
query = "SELECT id FROM namespaces WHERE parent_id IS NULL AND path='#{str}' LIMIT 1"
connection.exec_query(query).present?
- end
+ }
insert_query = "INSERT INTO namespaces(owner_id, path, name, created_at, updated_at) VALUES(#{user_id}, '#{path}', '#{path}', NOW(), NOW())"
namespace_id = connection.insert(insert_query)
@@ -55,7 +55,7 @@ class CreateMissingNamespaceForInternalUsers < ActiveRecord::Migration[4.2]
return unless namespace_id
row = connection.exec_query("SELECT id, path FROM namespaces WHERE id=#{namespace_id}").first
- id, path = row.values_at('id', 'path')
+ id, path = row.values_at("id", "path")
execute("INSERT INTO routes(source_id, source_type, path, name, created_at, updated_at) VALUES(#{id}, 'Namespace', '#{path}', '#{path}', NOW(), NOW())")
end
diff --git a/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb b/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb
index ac6bb1a8cab..0b1b8966e0c 100644
--- a/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb
+++ b/db/migrate/20180417090132_add_index_constraints_to_internal_id_table.rb
@@ -6,10 +6,10 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_concurrent_index :internal_ids, [:usage, :namespace_id], unique: true, where: 'namespace_id IS NOT NULL'
+ add_concurrent_index :internal_ids, [:usage, :namespace_id], unique: true, where: "namespace_id IS NOT NULL"
- replace_index(:internal_ids, [:usage, :project_id], name: 'index_internal_ids_on_usage_and_project_id') do
- add_concurrent_index :internal_ids, [:usage, :project_id], unique: true, where: 'project_id IS NOT NULL'
+ replace_index(:internal_ids, [:usage, :project_id], name: "index_internal_ids_on_usage_and_project_id") do
+ add_concurrent_index :internal_ids, [:usage, :project_id], unique: true, where: "project_id IS NOT NULL"
end
add_concurrent_foreign_key :internal_ids, :namespaces, column: :namespace_id, on_delete: :cascade
@@ -18,7 +18,7 @@ class AddIndexConstraintsToInternalIdTable < ActiveRecord::Migration[4.2]
def down
remove_concurrent_index :internal_ids, [:usage, :namespace_id]
- replace_index(:internal_ids, [:usage, :project_id], name: 'index_internal_ids_on_usage_and_project_id') do
+ replace_index(:internal_ids, [:usage, :project_id], name: "index_internal_ids_on_usage_and_project_id") do
add_concurrent_index :internal_ids, [:usage, :project_id], unique: true
end
diff --git a/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb b/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb
index ce470884999..176bfdd744a 100644
--- a/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb
+++ b/db/migrate/20180417101040_add_tmp_stage_priority_index_to_ci_builds.rb
@@ -7,10 +7,10 @@ class AddTmpStagePriorityIndexToCiBuilds < ActiveRecord::Migration[4.2]
def up
add_concurrent_index(:ci_builds, [:stage_id, :stage_idx],
- where: 'stage_idx IS NOT NULL', name: 'tmp_build_stage_position_index')
+ where: "stage_idx IS NOT NULL", name: "tmp_build_stage_position_index")
end
def down
- remove_concurrent_index_by_name(:ci_builds, 'tmp_build_stage_position_index')
+ remove_concurrent_index_by_name(:ci_builds, "tmp_build_stage_position_index")
end
end
diff --git a/db/migrate/20180420010616_cleanup_build_stage_migration.rb b/db/migrate/20180420010616_cleanup_build_stage_migration.rb
index 30c0d97781d..ab31f365a55 100644
--- a/db/migrate/20180420010616_cleanup_build_stage_migration.rb
+++ b/db/migrate/20180420010616_cleanup_build_stage_migration.rb
@@ -2,14 +2,14 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- TMP_INDEX = 'tmp_id_stage_partial_null_index'.freeze
+ TMP_INDEX = "tmp_id_stage_partial_null_index".freeze
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled
end
@@ -19,7 +19,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2]
# We steal from the background migrations queue to catch up with the
# scheduled migrations set.
#
- Gitlab::BackgroundMigration.steal('MigrateBuildStage')
+ Gitlab::BackgroundMigration.steal("MigrateBuildStage")
##
# We add temporary index, to make iteration over batches more performant.
@@ -27,7 +27,7 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2]
# migration file to make this operation idempotent.
#
unless index_exists_by_name?(:ci_builds, TMP_INDEX)
- add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL', name: TMP_INDEX)
+ add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL", name: TMP_INDEX)
end
##
@@ -39,8 +39,8 @@ class CleanupBuildStageMigration < ActiveRecord::Migration[4.2]
# that when this migration is done we are confident that all rows are
# already migrated.
#
- Build.where('stage_id IS NULL').each_batch(of: 50) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ Build.where("stage_id IS NULL").each_batch(of: 50) do |batch|
+ range = batch.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::MigrateBuildStage.new.perform(*range)
end
diff --git a/db/migrate/20180425075446_create_term_agreements.rb b/db/migrate/20180425075446_create_term_agreements.rb
index 25182215841..123f94e66a1 100644
--- a/db/migrate/20180425075446_create_term_agreements.rb
+++ b/db/migrate/20180425075446_create_term_agreements.rb
@@ -9,20 +9,20 @@ class CreateTermAgreements < ActiveRecord::Migration[4.2]
create_table :term_agreements do |t|
t.references :term, index: true, null: false
t.foreign_key :application_setting_terms, column: :term_id
- t.references :user, index: true, null: false, foreign_key: { on_delete: :cascade }
+ t.references :user, index: true, null: false, foreign_key: {on_delete: :cascade}
t.boolean :accepted, default: false, null: false
t.timestamps_with_timezone null: false
end
add_index :term_agreements, [:user_id, :term_id],
- unique: true,
- name: 'term_agreements_unique_index'
+ unique: true,
+ name: "term_agreements_unique_index"
end
def down
# rubocop:disable Migration/RemoveIndex
- remove_index :term_agreements, name: 'term_agreements_unique_index'
+ remove_index :term_agreements, name: "term_agreements_unique_index"
drop_table :term_agreements
end
diff --git a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
index 7d38a15b850..0435565dae0 100644
--- a/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
+++ b/db/migrate/20180425131009_assure_commits_count_for_merge_request_diff.rb
@@ -6,16 +6,16 @@ class AssureCommitsCountForMergeRequestDiff < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
end
def up
- Gitlab::BackgroundMigration.steal('AddMergeRequestDiffCommitsCount')
+ Gitlab::BackgroundMigration.steal("AddMergeRequestDiffCommitsCount")
MergeRequestDiff.where(commits_count: nil).each_batch(of: 50) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount.new.perform(*range)
end
diff --git a/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb
index 8a0cb7ae4e4..2276ea0bd13 100644
--- a/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb
+++ b/db/migrate/20180425205249_add_index_constraints_to_pipeline_iid.rb
@@ -6,7 +6,7 @@ class AddIndexConstraintsToPipelineIid < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_concurrent_index :ci_pipelines, [:project_id, :iid], unique: true, where: 'iid IS NOT NULL'
+ add_concurrent_index :ci_pipelines, [:project_id, :iid], unique: true, where: "iid IS NOT NULL"
end
def down
diff --git a/db/migrate/20180426102016_add_accepted_term_to_users.rb b/db/migrate/20180426102016_add_accepted_term_to_users.rb
index 3c6665b4264..ce4b4f090da 100644
--- a/db/migrate/20180426102016_add_accepted_term_to_users.rb
+++ b/db/migrate/20180426102016_add_accepted_term_to_users.rb
@@ -11,7 +11,7 @@ class AddAcceptedTermToUsers < ActiveRecord::Migration[4.2]
def up
change_table :users do |t|
t.references :accepted_term,
- null: true
+ null: true
end
add_concurrent_foreign_key :users, :application_setting_terms, column: :accepted_term_id
end
diff --git a/db/migrate/20180502122856_create_project_mirror_data.rb b/db/migrate/20180502122856_create_project_mirror_data.rb
index 8bc114afc0c..29b0ebdec23 100644
--- a/db/migrate/20180502122856_create_project_mirror_data.rb
+++ b/db/migrate/20180502122856_create_project_mirror_data.rb
@@ -7,7 +7,7 @@ class CreateProjectMirrorData < ActiveRecord::Migration[4.2]
return if table_exists?(:project_mirror_data)
create_table :project_mirror_data do |t|
- t.references :project, index: true, foreign_key: { on_delete: :cascade }
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}
t.string :status
t.string :jid
t.text :last_error
diff --git a/db/migrate/20180503131624_create_remote_mirrors.rb b/db/migrate/20180503131624_create_remote_mirrors.rb
index 9f4bd463e66..49164827931 100644
--- a/db/migrate/20180503131624_create_remote_mirrors.rb
+++ b/db/migrate/20180503131624_create_remote_mirrors.rb
@@ -9,7 +9,7 @@ class CreateRemoteMirrors < ActiveRecord::Migration[4.2]
return if table_exists?(:remote_mirrors)
create_table :remote_mirrors do |t|
- t.references :project, index: true, foreign_key: { on_delete: :cascade }
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}
t.string :url
t.boolean :enabled, default: true
t.string :update_status
diff --git a/db/migrate/20180504195842_project_name_lower_index.rb b/db/migrate/20180504195842_project_name_lower_index.rb
index 3fe90c3fbb1..c5b44e0bd7b 100644
--- a/db/migrate/20180504195842_project_name_lower_index.rb
+++ b/db/migrate/20180504195842_project_name_lower_index.rb
@@ -6,7 +6,7 @@ class ProjectNameLowerIndex < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_projects_on_lower_name'
+ INDEX_NAME = "index_projects_on_lower_name"
disable_ddl_transaction!
diff --git a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb
index dba5d20f276..7881dd448a0 100644
--- a/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb
+++ b/db/migrate/20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb
@@ -6,7 +6,7 @@ class AddNotNullConstraintToProjectMirrorDataForeignKey < ActiveRecord::Migratio
class ProjectImportState < ActiveRecord::Base
include EachBatch
- self.table_name = 'project_mirror_data'
+ self.table_name = "project_mirror_data"
end
def up
diff --git a/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
index b225354ca43..9f124d2009f 100644
--- a/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
+++ b/db/migrate/20180508102840_add_unique_constraint_to_project_mirror_data_project_id_index.rb
@@ -7,25 +7,25 @@ class AddUniqueConstraintToProjectMirrorDataProjectIdIndex < ActiveRecord::Migra
def up
add_concurrent_index(:project_mirror_data,
- :project_id,
- unique: true,
- name: 'index_project_mirror_data_on_project_id_unique')
+ :project_id,
+ unique: true,
+ name: "index_project_mirror_data_on_project_id_unique")
- remove_concurrent_index_by_name(:project_mirror_data, 'index_project_mirror_data_on_project_id')
+ remove_concurrent_index_by_name(:project_mirror_data, "index_project_mirror_data_on_project_id")
rename_index(:project_mirror_data,
- 'index_project_mirror_data_on_project_id_unique',
- 'index_project_mirror_data_on_project_id')
+ "index_project_mirror_data_on_project_id_unique",
+ "index_project_mirror_data_on_project_id")
end
def down
rename_index(:project_mirror_data,
- 'index_project_mirror_data_on_project_id',
- 'index_project_mirror_data_on_project_id_old')
+ "index_project_mirror_data_on_project_id",
+ "index_project_mirror_data_on_project_id_old")
add_concurrent_index(:project_mirror_data, :project_id)
remove_concurrent_index_by_name(:project_mirror_data,
- 'index_project_mirror_data_on_project_id_old')
+ "index_project_mirror_data_on_project_id_old")
end
end
diff --git a/db/migrate/20180511131058_create_clusters_applications_jupyter.rb b/db/migrate/20180511131058_create_clusters_applications_jupyter.rb
index 749aeeb4792..8d75318f264 100644
--- a/db/migrate/20180511131058_create_clusters_applications_jupyter.rb
+++ b/db/migrate/20180511131058_create_clusters_applications_jupyter.rb
@@ -8,8 +8,8 @@ class CreateClustersApplicationsJupyter < ActiveRecord::Migration[4.2]
def change
create_table :clusters_applications_jupyter do |t|
- t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
- t.references :oauth_application, foreign_key: { on_delete: :nullify }
+ t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade}
+ t.references :oauth_application, foreign_key: {on_delete: :nullify}
t.integer :status, null: false
t.string :version, null: false
diff --git a/db/migrate/20180515121227_create_notes_diff_files.rb b/db/migrate/20180515121227_create_notes_diff_files.rb
index e50324d8599..39b2bf9113e 100644
--- a/db/migrate/20180515121227_create_notes_diff_files.rb
+++ b/db/migrate/20180515121227_create_notes_diff_files.rb
@@ -5,7 +5,7 @@ class CreateNotesDiffFiles < ActiveRecord::Migration[4.2]
def change
create_table :note_diff_files do |t|
- t.references :diff_note, references: :notes, null: false, index: { unique: true }
+ t.references :diff_note, references: :notes, null: false, index: {unique: true}
t.text :diff, null: false
t.boolean :new_file, null: false
t.boolean :renamed_file, null: false
diff --git a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
index 36f4770ff32..fc6926388bb 100644
--- a/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
+++ b/db/migrate/20180517082340_add_not_null_constraints_to_project_authorizations.rb
@@ -8,10 +8,10 @@ class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2
if Gitlab::Database.postgresql?
# One-pass version for PostgreSQL
execute <<~SQL
- ALTER TABLE project_authorizations
- ALTER COLUMN user_id SET NOT NULL,
- ALTER COLUMN project_id SET NOT NULL,
- ALTER COLUMN access_level SET NOT NULL
+ ALTER TABLE project_authorizations
+ ALTER COLUMN user_id SET NOT NULL,
+ ALTER COLUMN project_id SET NOT NULL,
+ ALTER COLUMN access_level SET NOT NULL
SQL
else
change_column_null :project_authorizations, :user_id, false
@@ -24,10 +24,10 @@ class AddNotNullConstraintsToProjectAuthorizations < ActiveRecord::Migration[4.2
if Gitlab::Database.postgresql?
# One-pass version for PostgreSQL
execute <<~SQL
- ALTER TABLE project_authorizations
- ALTER COLUMN user_id DROP NOT NULL,
- ALTER COLUMN project_id DROP NOT NULL,
- ALTER COLUMN access_level DROP NOT NULL
+ ALTER TABLE project_authorizations
+ ALTER COLUMN user_id DROP NOT NULL,
+ ALTER COLUMN project_id DROP NOT NULL,
+ ALTER COLUMN access_level DROP NOT NULL
SQL
else
change_column_null :project_authorizations, :user_id, true
diff --git a/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb b/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb
index 08ce8cc3094..ea657b978fe 100644
--- a/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb
+++ b/db/migrate/20180521171529_increase_mysql_text_limit_for_gpg_keys.rb
@@ -1 +1 @@
-require_relative 'gpg_keys_limits_to_mysql'
+require_relative "gpg_keys_limits_to_mysql"
diff --git a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb
index bff4690427e..c62c3fe6c4e 100644
--- a/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb
+++ b/db/migrate/20180524132016_merge_requests_target_id_iid_state_partial_index.rb
@@ -7,7 +7,7 @@ class MergeRequestsTargetIdIidStatePartialIndex < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- INDEX_NAME = 'index_merge_requests_on_target_project_id_and_iid_opened'
+ INDEX_NAME = "index_merge_requests_on_target_project_id_and_iid_opened"
disable_ddl_transaction!
diff --git a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
index 207e1f089fb..bfd9dcc2764 100644
--- a/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
+++ b/db/migrate/20180529093006_ensure_remote_mirror_columns.rb
@@ -12,10 +12,10 @@ class EnsureRemoteMirrorColumns < ActiveRecord::Migration[4.2]
unless column_exists?(:remote_mirrors, :only_protected_branches)
add_column_with_default(:remote_mirrors,
- :only_protected_branches,
- :boolean,
- default: false,
- allow_null: false)
+ :only_protected_branches,
+ :boolean,
+ default: false,
+ allow_null: false)
end
end
diff --git a/db/migrate/20180531185349_add_repository_languages.rb b/db/migrate/20180531185349_add_repository_languages.rb
index 26a01c3bb26..0d59447a8d8 100644
--- a/db/migrate/20180531185349_add_repository_languages.rb
+++ b/db/migrate/20180531185349_add_repository_languages.rb
@@ -11,7 +11,7 @@ class AddRepositoryLanguages < ActiveRecord::Migration[4.2]
end
create_table(:repository_languages, id: false) do |t|
- t.references :project, null: false, foreign_key: { on_delete: :cascade }
+ t.references :project, null: false, foreign_key: {on_delete: :cascade}
t.references :programming_language, null: false
t.float :share, null: false
end
diff --git a/db/migrate/20180608091413_add_group_to_todos.rb b/db/migrate/20180608091413_add_group_to_todos.rb
index 7f8efd78c59..c05e2c82c64 100644
--- a/db/migrate/20180608091413_add_group_to_todos.rb
+++ b/db/migrate/20180608091413_add_group_to_todos.rb
@@ -6,7 +6,7 @@ class AddGroupToTodos < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Todo < ActiveRecord::Base
- self.table_name = 'todos'
+ self.table_name = "todos"
include ::EachBatch
end
diff --git a/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb b/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb
index d7273dff48e..3ca66d681eb 100644
--- a/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb
+++ b/db/migrate/20180612103626_add_columns_for_helm_tiller_certificates.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class AddColumnsForHelmTillerCertificates < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
diff --git a/db/migrate/20180625113853_create_import_export_uploads.rb b/db/migrate/20180625113853_create_import_export_uploads.rb
index d76b3e8cc15..f80ab0cee95 100644
--- a/db/migrate/20180625113853_create_import_export_uploads.rb
+++ b/db/migrate/20180625113853_create_import_export_uploads.rb
@@ -5,7 +5,7 @@ class CreateImportExportUploads < ActiveRecord::Migration[4.2]
create_table :import_export_uploads do |t|
t.datetime_with_timezone :updated_at, null: false
- t.references :project, index: true, foreign_key: { on_delete: :cascade }, unique: true
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}, unique: true
t.text :import_file
t.text :export_file
diff --git a/db/migrate/20180629153018_create_site_statistics.rb b/db/migrate/20180629153018_create_site_statistics.rb
index 60a32b3b2a7..c8c129346e6 100644
--- a/db/migrate/20180629153018_create_site_statistics.rb
+++ b/db/migrate/20180629153018_create_site_statistics.rb
@@ -9,7 +9,7 @@ class CreateSiteStatistics < ActiveRecord::Migration[4.2]
t.integer :wikis_count, default: 0, null: false
end
- execute('INSERT INTO site_statistics (id) VALUES(1)')
+ execute("INSERT INTO site_statistics (id) VALUES(1)")
end
def down
diff --git a/db/migrate/20180702124358_remove_orphaned_routes.rb b/db/migrate/20180702124358_remove_orphaned_routes.rb
index 62c15f9cd00..faa9e9da443 100644
--- a/db/migrate/20180702124358_remove_orphaned_routes.rb
+++ b/db/migrate/20180702124358_remove_orphaned_routes.rb
@@ -9,17 +9,17 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Route < ActiveRecord::Base
- self.table_name = 'routes'
+ self.table_name = "routes"
include EachBatch
def self.orphaned_namespace_routes
- where(source_type: 'Namespace')
- .where('NOT EXISTS ( SELECT 1 FROM namespaces WHERE namespaces.id = routes.source_id )')
+ where(source_type: "Namespace")
+ .where("NOT EXISTS ( SELECT 1 FROM namespaces WHERE namespaces.id = routes.source_id )")
end
def self.orphaned_project_routes
- where(source_type: 'Project')
- .where('NOT EXISTS ( SELECT 1 FROM projects WHERE projects.id = routes.source_id )')
+ where(source_type: "Project")
+ .where("NOT EXISTS ( SELECT 1 FROM projects WHERE projects.id = routes.source_id )")
end
end
@@ -33,7 +33,7 @@ class RemoveOrphanedRoutes < ActiveRecord::Migration[4.2]
# 150 orphaned namespace routes.
[
Route.orphaned_project_routes,
- Route.orphaned_namespace_routes
+ Route.orphaned_namespace_routes,
].each do |relation|
relation.each_batch(of: 1_000) do |batch|
batch.delete_all
diff --git a/db/migrate/20180702134423_generate_missing_routes.rb b/db/migrate/20180702134423_generate_missing_routes.rb
index a440bc3179c..6e4b19c8b29 100644
--- a/db/migrate/20180702134423_generate_missing_routes.rb
+++ b/db/migrate/20180702134423_generate_missing_routes.rb
@@ -15,17 +15,17 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
class Route < ActiveRecord::Base
- self.table_name = 'routes'
+ self.table_name = "routes"
end
module Routable
def build_full_path
if parent && path
- parent.build_full_path + '/' + path
+ parent.build_full_path + "/" + path
else
path
end
@@ -33,7 +33,7 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
def build_full_name
if parent && name
- parent.human_name + ' / ' + name
+ parent.human_name + " / " + name
else
name
end
@@ -58,25 +58,25 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
# The route path might already be taken. Instead of trying to generate a
# new unique name on every conflict, we just append the row ID to the
# route path.
- path: "#{build_full_path}-#{id}"
+ path: "#{build_full_path}-#{id}",
}
end
end
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include EachBatch
include GenerateMissingRoutes::Routable
- belongs_to :namespace, class_name: 'GenerateMissingRoutes::Namespace'
+ belongs_to :namespace, class_name: "GenerateMissingRoutes::Namespace"
has_one :route,
as: :source,
inverse_of: :source,
- class_name: 'GenerateMissingRoutes::Route'
+ class_name: "GenerateMissingRoutes::Route"
- alias_method :parent, :namespace
+ alias parent namespace
alias_attribute :parent_id, :namespace_id
def self.without_routes
@@ -87,28 +87,28 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
WHERE source_type = ?
AND source_id = projects.id
)',
- 'Project'
+ "Project"
)
end
def source_type_for_route
- 'Project'
+ "Project"
end
end
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
include EachBatch
include GenerateMissingRoutes::Routable
- belongs_to :parent, class_name: 'GenerateMissingRoutes::Namespace'
- belongs_to :owner, class_name: 'GenerateMissingRoutes::User'
+ belongs_to :parent, class_name: "GenerateMissingRoutes::Namespace"
+ belongs_to :owner, class_name: "GenerateMissingRoutes::User"
has_one :route,
as: :source,
inverse_of: :source,
- class_name: 'GenerateMissingRoutes::Route'
+ class_name: "GenerateMissingRoutes::Route"
def self.without_routes
where(
@@ -118,12 +118,12 @@ class GenerateMissingRoutes < ActiveRecord::Migration[4.2]
WHERE source_type = ?
AND source_id = namespaces.id
)',
- 'Namespace'
+ "Namespace"
)
end
def source_type_for_route
- 'Namespace'
+ "Namespace"
end
end
diff --git a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb
index 03afbe217b5..05b7d6df2e9 100644
--- a/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb
+++ b/db/migrate/20180704204006_add_hide_third_party_offers_to_application_settings.rb
@@ -7,9 +7,9 @@ class AddHideThirdPartyOffersToApplicationSettings < ActiveRecord::Migration[4.2
def up
add_column_with_default(:application_settings, :hide_third_party_offers,
- :boolean,
- default: false,
- allow_null: false)
+ :boolean,
+ default: false,
+ allow_null: false)
end
def down
diff --git a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb
index 79691f2b24c..4db69503c66 100644
--- a/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb
+++ b/db/migrate/20180710162338_add_foreign_key_from_notification_settings_to_users.rb
@@ -2,13 +2,13 @@ class AddForeignKeyFromNotificationSettingsToUsers < ActiveRecord::Migration[4.2
include Gitlab::Database::MigrationHelpers
class NotificationSetting < ActiveRecord::Base
- self.table_name = 'notification_settings'
+ self.table_name = "notification_settings"
include EachBatch
end
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
DOWNTIME = false
@@ -17,7 +17,7 @@ class AddForeignKeyFromNotificationSettingsToUsers < ActiveRecord::Migration[4.2
def up
NotificationSetting.each_batch(of: 1000) do |batch|
- batch.where('NOT EXISTS (?)', User.select(1).where('users.id = notification_settings.user_id'))
+ batch.where("NOT EXISTS (?)", User.select(1).where("users.id = notification_settings.user_id"))
.delete_all
end
diff --git a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
index 6166aa65f1f..259e01f8e19 100644
--- a/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
+++ b/db/migrate/20180711103851_drop_duplicate_protected_tags.rb
@@ -9,13 +9,13 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration[4.2]
BATCH_SIZE = 1000
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include ::EachBatch
end
class ProtectedTag < ActiveRecord::Base
- self.table_name = 'protected_tags'
+ self.table_name = "protected_tags"
end
def up
@@ -23,7 +23,7 @@ class DropDuplicateProtectedTags < ActiveRecord::Migration[4.2]
ids = ProtectedTag
.where(project_id: projects)
.group(:name, :project_id)
- .select('max(id)')
+ .select("max(id)")
tags = ProtectedTag
.where(project_id: projects)
diff --git a/db/migrate/20180713092803_create_user_statuses.rb b/db/migrate/20180713092803_create_user_statuses.rb
index 43b96805c1e..f8260f57bc5 100644
--- a/db/migrate/20180713092803_create_user_statuses.rb
+++ b/db/migrate/20180713092803_create_user_statuses.rb
@@ -8,11 +8,11 @@ class CreateUserStatuses < ActiveRecord::Migration[4.2]
def change
create_table :user_statuses, id: false, primary_key: :user_id do |t|
t.references :user,
- foreign_key: { on_delete: :cascade },
- null: false,
- primary_key: true
+ foreign_key: {on_delete: :cascade},
+ null: false,
+ primary_key: true
t.integer :cached_markdown_version, limit: 4
- t.string :emoji, null: false, default: 'speech_balloon'
+ t.string :emoji, null: false, default: "speech_balloon"
t.string :message, limit: 100
t.string :message_html
end
diff --git a/db/migrate/20180717125853_remove_restricted_todos.rb b/db/migrate/20180717125853_remove_restricted_todos.rb
index 1d4bbf6571e..358ee31c918 100644
--- a/db/migrate/20180717125853_remove_restricted_todos.rb
+++ b/db/migrate/20180717125853_remove_restricted_todos.rb
@@ -6,20 +6,20 @@ class RemoveRestrictedTodos < ActiveRecord::Migration[4.2]
DOWNTIME = false
disable_ddl_transaction!
- MIGRATION = 'RemoveRestrictedTodos'.freeze
+ MIGRATION = "RemoveRestrictedTodos"
BATCH_SIZE = 1000
DELAY_INTERVAL = 5.minutes.to_i
class Project < ActiveRecord::Base
include EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
end
def up
- Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)')
+ Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)")
.each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range)
end
diff --git a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb
index ed5fa58b481..0c1a8cfbfd7 100644
--- a/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb
+++ b/db/migrate/20180718005113_add_instance_statistics_visibility_to_application_setting.rb
@@ -9,9 +9,9 @@ class AddInstanceStatisticsVisibilityToApplicationSetting < ActiveRecord::Migrat
def up
add_column_with_default(:application_settings, :instance_statistics_visibility_private,
- :boolean,
- default: false,
- allow_null: false)
+ :boolean,
+ default: false,
+ allow_null: false)
end
def down
diff --git a/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb b/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb
index 0cf3c78507e..2188d9bdb68 100644
--- a/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb
+++ b/db/migrate/20180720023512_add_receive_max_input_size_to_application_settings.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
diff --git a/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb b/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb
index 23b8e04674a..38ba44ffe2d 100644
--- a/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb
+++ b/db/migrate/20180723135214_add_web_ide_client_side_preview_enabled_to_application_settings.rb
@@ -9,9 +9,9 @@ class AddWebIdeClientSidePreviewEnabledToApplicationSettings < ActiveRecord::Mig
def up
add_column_with_default(:application_settings, :web_ide_clientside_preview_enabled,
- :boolean,
- default: false,
- allow_null: false)
+ :boolean,
+ default: false,
+ allow_null: false)
end
def down
diff --git a/db/migrate/20180726172057_create_resource_label_events.rb b/db/migrate/20180726172057_create_resource_label_events.rb
index 550e35d6f90..954d840f411 100644
--- a/db/migrate/20180726172057_create_resource_label_events.rb
+++ b/db/migrate/20180726172057_create_resource_label_events.rb
@@ -8,10 +8,10 @@ class CreateResourceLabelEvents < ActiveRecord::Migration[4.2]
def change
create_table :resource_label_events, id: :bigserial do |t|
t.integer :action, null: false
- t.references :issue, null: true, index: true, foreign_key: { on_delete: :cascade }
- t.references :merge_request, null: true, index: true, foreign_key: { on_delete: :cascade }
- t.references :label, index: true, foreign_key: { on_delete: :nullify }
- t.references :user, index: true, foreign_key: { on_delete: :nullify }
+ t.references :issue, null: true, index: true, foreign_key: {on_delete: :cascade}
+ t.references :merge_request, null: true, index: true, foreign_key: {on_delete: :cascade}
+ t.references :label, index: true, foreign_key: {on_delete: :nullify}
+ t.references :user, index: true, foreign_key: {on_delete: :nullify}
t.datetime_with_timezone :created_at, null: false
end
end
diff --git a/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb b/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb
index 237e6ba4559..35719eb9847 100644
--- a/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb
+++ b/db/migrate/20180815170510_add_partial_index_to_ci_builds_artifacts_file.rb
@@ -2,7 +2,7 @@ class AddPartialIndexToCiBuildsArtifactsFile < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'.freeze
+ INDEX_NAME = "partial_index_ci_builds_on_id_with_legacy_artifacts".freeze
disable_ddl_transaction!
diff --git a/db/migrate/20180815175440_add_index_on_list_type.rb b/db/migrate/20180815175440_add_index_on_list_type.rb
index 3fe0f6b8de5..4f13675d0f4 100644
--- a/db/migrate/20180815175440_add_index_on_list_type.rb
+++ b/db/migrate/20180815175440_add_index_on_list_type.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class AddIndexOnListType < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
diff --git a/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb b/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb
index 80c4d11a38e..0346b03788c 100644
--- a/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb
+++ b/db/migrate/20180831164904_fix_prometheus_metric_query_limits.rb
@@ -2,7 +2,7 @@
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
-require Rails.root.join('db/migrate/prometheus_metrics_limits_to_mysql')
+require Rails.root.join("db/migrate/prometheus_metrics_limits_to_mysql")
class FixPrometheusMetricQueryLimits < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
diff --git a/db/migrate/20180831164910_import_common_metrics.rb b/db/migrate/20180831164910_import_common_metrics.rb
index f67d5f40aad..1cbf1c18317 100644
--- a/db/migrate/20180831164910_import_common_metrics.rb
+++ b/db/migrate/20180831164910_import_common_metrics.rb
@@ -3,7 +3,7 @@
class ImportCommonMetrics < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
- require Rails.root.join('db/importers/common_metrics_importer.rb')
+ require Rails.root.join("db/importers/common_metrics_importer.rb")
DOWNTIME = false
diff --git a/db/migrate/20180912111628_add_knative_application.rb b/db/migrate/20180912111628_add_knative_application.rb
index 86d9100d2e7..e5dcc25457a 100644
--- a/db/migrate/20180912111628_add_knative_application.rb
+++ b/db/migrate/20180912111628_add_knative_application.rb
@@ -7,7 +7,7 @@ class AddKnativeApplication < ActiveRecord::Migration[4.2]
def change
create_table "clusters_applications_knative" do |t|
- t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, unique: true, foreign_key: {on_delete: :cascade}
t.datetime_with_timezone "created_at", null: false
t.datetime_with_timezone "updated_at", null: false
diff --git a/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb
index 5dac5f0d100..f48d8aee134 100644
--- a/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb
+++ b/db/migrate/20180924141949_add_diff_max_patch_bytes_to_application_settings.rb
@@ -13,10 +13,10 @@ class AddDiffMaxPatchBytesToApplicationSettings < ActiveRecord::Migration[4.2]
def up
add_column_with_default(:application_settings,
- :diff_max_patch_bytes,
- :integer,
- default: 100.kilobytes,
- allow_null: false)
+ :diff_max_patch_bytes,
+ :integer,
+ default: 100.kilobytes,
+ allow_null: false)
end
def down
diff --git a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb
index 378fc4e5fea..3606a3af9bd 100644
--- a/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb
+++ b/db/migrate/20180924201039_add_partial_index_to_scheduled_at.rb
@@ -4,7 +4,7 @@ class AddPartialIndexToScheduledAt < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs'.freeze
+ INDEX_NAME = "partial_index_ci_builds_on_scheduled_at_with_scheduled_jobs"
disable_ddl_transaction!
diff --git a/db/migrate/20180925200829_create_user_preferences.rb b/db/migrate/20180925200829_create_user_preferences.rb
index b46df8157a6..f370650ed0b 100644
--- a/db/migrate/20180925200829_create_user_preferences.rb
+++ b/db/migrate/20180925200829_create_user_preferences.rb
@@ -4,26 +4,26 @@ class CreateUserPreferences < ActiveRecord::Migration[4.2]
DOWNTIME = false
class UserPreference < ActiveRecord::Base
- self.table_name = 'user_preferences'
+ self.table_name = "user_preferences"
- NOTES_FILTERS = { all_notes: 0, comments: 1 }.freeze
+ NOTES_FILTERS = {all_notes: 0, comments: 1}.freeze
end
def change
create_table :user_preferences do |t|
t.references :user,
- null: false,
- index: { unique: true },
- foreign_key: { on_delete: :cascade }
+ null: false,
+ index: {unique: true},
+ foreign_key: {on_delete: :cascade}
t.integer :issue_notes_filter,
- default: UserPreference::NOTES_FILTERS[:all_notes],
- null: false, limit: 2
+ default: UserPreference::NOTES_FILTERS[:all_notes],
+ null: false, limit: 2
t.integer :merge_request_notes_filter,
- default: UserPreference::NOTES_FILTERS[:all_notes],
- null: false,
- limit: 2
+ default: UserPreference::NOTES_FILTERS[:all_notes],
+ null: false,
+ limit: 2
t.timestamps_with_timezone null: false
end
diff --git a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb
index 7826c8d802e..b72756e4871 100644
--- a/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb
+++ b/db/migrate/20181002172433_remove_restricted_todos_with_cte.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
@@ -7,20 +8,20 @@ class RemoveRestrictedTodosWithCte < ActiveRecord::Migration[4.2]
DOWNTIME = false
disable_ddl_transaction!
- MIGRATION = 'RemoveRestrictedTodos'.freeze
+ MIGRATION = "RemoveRestrictedTodos"
BATCH_SIZE = 1000
DELAY_INTERVAL = 5.minutes.to_i
class Project < ActiveRecord::Base
include EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
end
def up
- Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)')
+ Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)")
.each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range)
end
diff --git a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb
index 5cd312837df..9de36880222 100644
--- a/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb
+++ b/db/migrate/20181006004100_import_common_metrics_nginx_vts.rb
@@ -1,7 +1,7 @@
class ImportCommonMetricsNginxVts < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
- require Rails.root.join('db/importers/common_metrics_importer.rb')
+ require Rails.root.join("db/importers/common_metrics_importer.rb")
DOWNTIME = false
diff --git a/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb b/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb
index 62ad6c63d0a..45955580690 100644
--- a/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb
+++ b/db/migrate/20181009190428_create_clusters_kubernetes_namespaces.rb
@@ -2,13 +2,13 @@
class CreateClustersKubernetesNamespaces < ActiveRecord::Migration[4.2]
DOWNTIME = false
- INDEX_NAME = 'kubernetes_namespaces_cluster_and_namespace'
+ INDEX_NAME = "kubernetes_namespaces_cluster_and_namespace"
def change
create_table :clusters_kubernetes_namespaces, id: :bigserial do |t|
- t.references :cluster, null: false, index: true, foreign_key: { on_delete: :cascade }
- t.references :project, index: true, foreign_key: { on_delete: :nullify }
- t.references :cluster_project, index: true, foreign_key: { on_delete: :nullify }
+ t.references :cluster, null: false, index: true, foreign_key: {on_delete: :cascade}
+ t.references :project, index: true, foreign_key: {on_delete: :nullify}
+ t.references :cluster_project, index: true, foreign_key: {on_delete: :nullify}
t.timestamps_with_timezone null: false
diff --git a/db/migrate/20181010235606_create_board_project_recent_visits.rb b/db/migrate/20181010235606_create_board_project_recent_visits.rb
index 07bfbdda26b..5ea6bdd72c2 100644
--- a/db/migrate/20181010235606_create_board_project_recent_visits.rb
+++ b/db/migrate/20181010235606_create_board_project_recent_visits.rb
@@ -9,11 +9,11 @@ class CreateBoardProjectRecentVisits < ActiveRecord::Migration[4.2]
create_table :board_project_recent_visits, id: :bigserial do |t|
t.timestamps_with_timezone null: false
- t.references :user, index: true, foreign_key: { on_delete: :cascade }
- t.references :project, index: true, foreign_key: { on_delete: :cascade }
- t.references :board, index: true, foreign_key: { on_delete: :cascade }
+ t.references :user, index: true, foreign_key: {on_delete: :cascade}
+ t.references :project, index: true, foreign_key: {on_delete: :cascade}
+ t.references :board, index: true, foreign_key: {on_delete: :cascade}
end
- add_index :board_project_recent_visits, [:user_id, :project_id, :board_id], unique: true, name: 'index_board_project_recent_visits_on_user_project_and_board'
+ add_index :board_project_recent_visits, [:user_id, :project_id, :board_id], unique: true, name: "index_board_project_recent_visits_on_user_project_and_board"
end
end
diff --git a/db/migrate/20181014203236_create_cluster_groups.rb b/db/migrate/20181014203236_create_cluster_groups.rb
index 33ae9a4a478..0e9e59d5713 100644
--- a/db/migrate/20181014203236_create_cluster_groups.rb
+++ b/db/migrate/20181014203236_create_cluster_groups.rb
@@ -7,7 +7,7 @@ class CreateClusterGroups < ActiveRecord::Migration[4.2]
def change
create_table :cluster_groups do |t|
- t.references :cluster, null: false, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, foreign_key: {on_delete: :cascade}
t.references :group, null: false, index: true
t.index [:cluster_id, :group_id], unique: true
diff --git a/db/migrate/20181016152238_create_board_group_recent_visits.rb b/db/migrate/20181016152238_create_board_group_recent_visits.rb
index 9e240a5f97f..9c302fe4123 100644
--- a/db/migrate/20181016152238_create_board_group_recent_visits.rb
+++ b/db/migrate/20181016152238_create_board_group_recent_visits.rb
@@ -9,12 +9,12 @@ class CreateBoardGroupRecentVisits < ActiveRecord::Migration[4.2]
create_table :board_group_recent_visits, id: :bigserial do |t|
t.timestamps_with_timezone null: false
- t.references :user, index: true, foreign_key: { on_delete: :cascade }
- t.references :board, index: true, foreign_key: { on_delete: :cascade }
+ t.references :user, index: true, foreign_key: {on_delete: :cascade}
+ t.references :board, index: true, foreign_key: {on_delete: :cascade}
t.references :group, references: :namespace, column: :group_id, index: true
t.foreign_key :namespaces, column: :group_id, on_delete: :cascade
end
- add_index :board_group_recent_visits, [:user_id, :group_id, :board_id], unique: true, name: 'index_board_group_recent_visits_on_user_group_and_board'
+ add_index :board_group_recent_visits, [:user_id, :group_id, :board_id], unique: true, name: "index_board_group_recent_visits_on_user_group_and_board"
end
end
diff --git a/db/migrate/20181019032400_add_shards_table.rb b/db/migrate/20181019032400_add_shards_table.rb
index e31af97cc94..96e9417f550 100644
--- a/db/migrate/20181019032400_add_shards_table.rb
+++ b/db/migrate/20181019032400_add_shards_table.rb
@@ -5,7 +5,7 @@ class AddShardsTable < ActiveRecord::Migration[4.2]
def change
create_table :shards do |t|
- t.string :name, null: false, index: { unique: true }
+ t.string :name, null: false, index: {unique: true}
end
end
end
diff --git a/db/migrate/20181019032408_add_repositories_table.rb b/db/migrate/20181019032408_add_repositories_table.rb
index 2153c1c9fc6..5f8745c7e47 100644
--- a/db/migrate/20181019032408_add_repositories_table.rb
+++ b/db/migrate/20181019032408_add_repositories_table.rb
@@ -5,11 +5,11 @@ class AddRepositoriesTable < ActiveRecord::Migration[4.2]
def change
create_table :repositories, id: :bigserial do |t|
- t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
- t.string :disk_path, null: false, index: { unique: true }
+ t.references :shard, null: false, index: true, foreign_key: {on_delete: :restrict}
+ t.string :disk_path, null: false, index: {unique: true}
end
add_column :projects, :pool_repository_id, :bigint
- add_index :projects, :pool_repository_id, where: 'pool_repository_id IS NOT NULL'
+ add_index :projects, :pool_repository_id, where: "pool_repository_id IS NOT NULL"
end
end
diff --git a/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb b/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb
index e90e59b57a9..1191c46d6a4 100644
--- a/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb
+++ b/db/migrate/20181023144439_add_partial_index_for_legacy_successful_deployments.rb
@@ -4,7 +4,7 @@ class AddPartialIndexForLegacySuccessfulDeployments < ActiveRecord::Migration[4.
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'partial_index_deployments_for_legacy_successful_deployments'.freeze
+ INDEX_NAME = "partial_index_deployments_for_legacy_successful_deployments"
disable_ddl_transaction!
diff --git a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb
index 2f4ef33b253..ef5b24f9411 100644
--- a/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb
+++ b/db/migrate/20181026143227_migrate_snippets_access_level_default_value.rb
@@ -14,7 +14,7 @@ class MigrateSnippetsAccessLevelDefaultValue < ActiveRecord::Migration[4.2]
class ProjectFeature < ActiveRecord::Base
include EachBatch
- self.table_name = 'project_features'
+ self.table_name = "project_features"
end
def up
diff --git a/db/migrate/20181031190559_drop_gcp_clusters_table.rb b/db/migrate/20181031190559_drop_gcp_clusters_table.rb
index 597fe49f4c8..7417c7dd5e0 100644
--- a/db/migrate/20181031190559_drop_gcp_clusters_table.rb
+++ b/db/migrate/20181031190559_drop_gcp_clusters_table.rb
@@ -12,9 +12,9 @@ class DropGcpClustersTable < ActiveRecord::Migration[4.2]
def down
create_table :gcp_clusters do |t|
# Order columns by best align scheme
- t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
- t.references :user, foreign_key: { on_delete: :nullify }
- t.references :service, foreign_key: { on_delete: :nullify }
+ t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
+ t.references :user, foreign_key: {on_delete: :nullify}
+ t.references :service, foreign_key: {on_delete: :nullify}
t.integer :status
t.integer :gcp_cluster_size, null: false
diff --git a/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb b/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb
index 569eaa8b22c..9d280ce50e6 100644
--- a/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb
+++ b/db/migrate/20181101144347_add_index_for_stuck_mr_query.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class AddIndexForStuckMrQuery < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
diff --git a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb
index 0b6155356d9..6e596d7fd52 100644
--- a/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb
+++ b/db/migrate/20181101191341_create_clusters_applications_cert_manager.rb
@@ -7,7 +7,7 @@ class CreateClustersApplicationsCertManager < ActiveRecord::Migration[4.2]
def change
create_table :clusters_applications_cert_managers do |t|
- t.references :cluster, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.references :cluster, null: false, index: false, foreign_key: {on_delete: :cascade}
t.integer :status, null: false
t.string :version, null: false
t.string :email, null: false
diff --git a/db/migrate/20181108091549_cleanup_environments_external_url.rb b/db/migrate/20181108091549_cleanup_environments_external_url.rb
index 8439f6e55e6..7e7b2104f93 100644
--- a/db/migrate/20181108091549_cleanup_environments_external_url.rb
+++ b/db/migrate/20181108091549_cleanup_environments_external_url.rb
@@ -9,7 +9,7 @@ class CleanupEnvironmentsExternalUrl < ActiveRecord::Migration[4.2]
def up
update_column_in_batches(:environments, :external_url, nil) do |table, query|
- query.where(table[:external_url].matches('javascript://%'))
+ query.where(table[:external_url].matches("javascript://%"))
end
end
diff --git a/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb
index cb01fa113eb..f4b76c48998 100644
--- a/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb
+++ b/db/migrate/20181119132520_add_indexes_to_ci_builds_and_pipelines.rb
@@ -27,18 +27,18 @@ class AddIndexesToCiBuildsAndPipelines < ActiveRecord::Migration[5.0]
:ci_pipelines,
[:project_id, :ref, :id],
{
- order: { id: :desc },
- name: 'index_ci_pipelines_on_project_idandrefandiddesc'
- }
+ order: {id: :desc},
+ name: "index_ci_pipelines_on_project_idandrefandiddesc",
+ },
],
[
:ci_builds,
[:commit_id, :artifacts_expire_at, :id],
{
where: "type::text = 'Ci::Build'::text AND (retried = false OR retried IS NULL) AND (name::text = ANY (ARRAY['sast'::character varying, 'dependency_scanning'::character varying, 'sast:container'::character varying, 'container_scanning'::character varying, 'dast'::character varying]::text[]))",
- name: 'index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial'
- }
- ]
+ name: "index_ci_builds_on_commit_id_and_artifacts_expireatandidpartial",
+ },
+ ],
]
end
end
diff --git a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb
index f8b46395941..51f3b663c18 100644
--- a/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb
+++ b/db/migrate/20181120091639_add_foreign_key_to_ci_pipelines_merge_requests.rb
@@ -8,7 +8,7 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL'
+ add_concurrent_index :ci_pipelines, :merge_request_id, where: "merge_request_id IS NOT NULL"
add_concurrent_foreign_key :ci_pipelines, :merge_requests, column: :merge_request_id, on_delete: :cascade
end
@@ -17,6 +17,6 @@ class AddForeignKeyToCiPipelinesMergeRequests < ActiveRecord::Migration[4.2]
remove_foreign_key :ci_pipelines, :merge_requests
end
- remove_concurrent_index :ci_pipelines, :merge_request_id, where: 'merge_request_id IS NOT NULL'
+ remove_concurrent_index :ci_pipelines, :merge_request_id, where: "merge_request_id IS NOT NULL"
end
end
diff --git a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb
index a524709faf8..0d6973a9568 100644
--- a/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb
+++ b/db/migrate/20181121101842_add_ci_builds_partial_index_on_project_id_and_status.rb
@@ -25,9 +25,9 @@ class AddCiBuildsPartialIndexOnProjectIdAndStatus < ActiveRecord::Migration[4.2]
:ci_builds,
[:project_id, :status],
{
- name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial2',
- where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))"
- }
+ name: "index_ci_builds_project_id_and_status_for_live_jobs_partial2",
+ where: "(((type)::text = 'Ci::Build'::text) AND ((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text])))",
+ },
]
end
end
diff --git a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb
index e4fb703e887..89b4f50398c 100644
--- a/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb
+++ b/db/migrate/20181121101843_remove_redundant_ci_builds_partial_index.rb
@@ -25,9 +25,9 @@ class RemoveRedundantCiBuildsPartialIndex < ActiveRecord::Migration[4.2]
:ci_builds,
[:project_id, :status],
{
- name: 'index_ci_builds_project_id_and_status_for_live_jobs_partial',
- where: "((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text]))"
- }
+ name: "index_ci_builds_project_id_and_status_for_live_jobs_partial",
+ where: "((status)::text = ANY (ARRAY[('running'::character varying)::text, ('pending'::character varying)::text, ('created'::character varying)::text]))",
+ },
]
end
end
diff --git a/db/migrate/20181122160027_create_project_repositories.rb b/db/migrate/20181122160027_create_project_repositories.rb
index e42cef9b1c6..20e0064ea30 100644
--- a/db/migrate/20181122160027_create_project_repositories.rb
+++ b/db/migrate/20181122160027_create_project_repositories.rb
@@ -10,9 +10,9 @@ class CreateProjectRepositories < ActiveRecord::Migration[5.0]
def change
create_table :project_repositories, id: :bigserial do |t|
- t.references :shard, null: false, index: true, foreign_key: { on_delete: :restrict }
- t.string :disk_path, null: false, index: { unique: true }
- t.references :project, null: false, index: { unique: true }, foreign_key: { on_delete: :cascade }
+ t.references :shard, null: false, index: true, foreign_key: {on_delete: :restrict}
+ t.string :disk_path, null: false, index: {unique: true}
+ t.references :project, null: false, index: {unique: true}, foreign_key: {on_delete: :cascade}
end
end
end
diff --git a/db/migrate/20181123144235_create_suggestions.rb b/db/migrate/20181123144235_create_suggestions.rb
index 1723f6de7eb..369d7d226a8 100644
--- a/db/migrate/20181123144235_create_suggestions.rb
+++ b/db/migrate/20181123144235_create_suggestions.rb
@@ -5,7 +5,7 @@ class CreateSuggestions < ActiveRecord::Migration[5.0]
def change
create_table :suggestions, id: :bigserial do |t|
- t.references :note, foreign_key: { on_delete: :cascade }, null: false
+ t.references :note, foreign_key: {on_delete: :cascade}, null: false
t.integer :relative_order, null: false, limit: 2
t.boolean :applied, null: false, default: false
t.string :commit_id
@@ -13,7 +13,7 @@ class CreateSuggestions < ActiveRecord::Migration[5.0]
t.text :to_content, null: false
t.index [:note_id, :relative_order],
- name: 'index_suggestions_on_note_id_and_relative_order',
+ name: "index_suggestions_on_note_id_and_relative_order",
unique: true
end
end
diff --git a/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb
index 7e9c56957d5..54e154da4ac 100644
--- a/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb
+++ b/db/migrate/20181126150622_add_events_index_on_project_id_and_created_at.rb
@@ -25,8 +25,8 @@ class AddEventsIndexOnProjectIdAndCreatedAt < ActiveRecord::Migration[5.0]
:events,
[:project_id, :created_at],
{
- name: 'index_events_on_project_id_and_created_at'
- }
+ name: "index_events_on_project_id_and_created_at",
+ },
]
end
end
diff --git a/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb b/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb
index d7ca46b50e4..18f17f636c1 100644
--- a/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb
+++ b/db/migrate/20181126153547_remove_notes_index_on_updated_at.rb
@@ -25,8 +25,8 @@ class RemoveNotesIndexOnUpdatedAt < ActiveRecord::Migration[5.0]
:notes,
[:updated_at],
{
- name: 'index_notes_on_updated_at'
- }
+ name: "index_notes_on_updated_at",
+ },
]
end
end
diff --git a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb
index f90aca008e5..139a4748706 100644
--- a/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb
+++ b/db/migrate/20181129104944_add_index_to_ci_builds_token_encrypted.rb
@@ -8,7 +8,7 @@ class AddIndexToCiBuildsTokenEncrypted < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
def up
- add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: 'token_encrypted IS NOT NULL'
+ add_concurrent_index :ci_builds, :token_encrypted, unique: true, where: "token_encrypted IS NOT NULL"
end
def down
diff --git a/db/migrate/20181205171941_create_project_daily_statistics.rb b/db/migrate/20181205171941_create_project_daily_statistics.rb
index c9e2a1e1aa7..5f23d34b3eb 100644
--- a/db/migrate/20181205171941_create_project_daily_statistics.rb
+++ b/db/migrate/20181205171941_create_project_daily_statistics.rb
@@ -11,7 +11,7 @@ class CreateProjectDailyStatistics < ActiveRecord::Migration[5.0]
t.integer :fetch_count, null: false
t.date :date
- t.index [:project_id, :date], unique: true, order: { date: :desc }
+ t.index [:project_id, :date], unique: true, order: {date: :desc}
t.foreign_key :projects, on_delete: :cascade
end
end
diff --git a/db/migrate/20181228175414_create_releases_link_table.rb b/db/migrate/20181228175414_create_releases_link_table.rb
index 03558202137..1c4d723fdcb 100644
--- a/db/migrate/20181228175414_create_releases_link_table.rb
+++ b/db/migrate/20181228175414_create_releases_link_table.rb
@@ -7,7 +7,7 @@ class CreateReleasesLinkTable < ActiveRecord::Migration[5.0]
def change
create_table :release_links, id: :bigserial do |t|
- t.references :release, null: false, index: false, foreign_key: { on_delete: :cascade }
+ t.references :release, null: false, index: false, foreign_key: {on_delete: :cascade}
t.string :url, null: false
t.string :name, null: false
t.timestamps_with_timezone null: false
diff --git a/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb b/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb
index 11659846a06..02f6a9fe44f 100644
--- a/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb
+++ b/db/migrate/20190104182041_cleanup_legacy_artifact_migration.rb
@@ -10,19 +10,19 @@ class CleanupLegacyArtifactMigration < ActiveRecord::Migration[5.0]
class Build < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled
scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") }
end
def up
- Gitlab::BackgroundMigration.steal('MigrateLegacyArtifacts')
+ Gitlab::BackgroundMigration.steal("MigrateLegacyArtifacts")
CleanupLegacyArtifactMigration::Build
.with_legacy_artifacts
.each_batch(of: 100) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::MigrateLegacyArtifacts.new.perform(*range)
end
diff --git a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb
index 073faf721ae..14366b0743c 100644
--- a/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb
+++ b/db/migrate/20190108192941_remove_partial_index_from_ci_builds_artifacts_file.rb
@@ -4,7 +4,7 @@ class RemovePartialIndexFromCiBuildsArtifactsFile < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'partial_index_ci_builds_on_id_with_legacy_artifacts'.freeze
+ INDEX_NAME = "partial_index_ci_builds_on_id_with_legacy_artifacts"
disable_ddl_transaction!
diff --git a/db/migrate/20190206193120_add_index_to_tags.rb b/db/migrate/20190206193120_add_index_to_tags.rb
index 5257ebba003..044e50d2d61 100644
--- a/db/migrate/20190206193120_add_index_to_tags.rb
+++ b/db/migrate/20190206193120_add_index_to_tags.rb
@@ -4,12 +4,12 @@ class AddIndexToTags < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- INDEX_NAME = 'index_tags_on_name_trigram'
+ INDEX_NAME = "index_tags_on_name_trigram"
disable_ddl_transaction!
def up
- add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: { name: :gin_trgm_ops }
+ add_concurrent_index :tags, :name, name: INDEX_NAME, using: :gin, opclasses: {name: :gin_trgm_ops}
end
def down
diff --git a/db/migrate/limits_to_mysql.rb b/db/migrate/limits_to_mysql.rb
index 33cb19aff9e..67c93fa6a18 100644
--- a/db/migrate/limits_to_mysql.rb
+++ b/db/migrate/limits_to_mysql.rb
@@ -1,6 +1,6 @@
class LimitsToMysql < ActiveRecord::Migration[4.2]
def up
- return unless ActiveRecord::Base.configurations[Rails.env]['adapter'] =~ /^mysql/
+ return unless ActiveRecord::Base.configurations[Rails.env]["adapter"] =~ /^mysql/
change_column :snippets, :content, :text, limit: 2147483647
change_column :notes, :st_diff, :text, limit: 2147483647
diff --git a/db/optional_migrations/composite_primary_keys.rb b/db/optional_migrations/composite_primary_keys.rb
index e0bb0312a35..e3dc0799a96 100644
--- a/db/optional_migrations/composite_primary_keys.rb
+++ b/db/optional_migrations/composite_primary_keys.rb
@@ -15,13 +15,13 @@ class CompositePrimaryKeysMigration < ActiveRecord::Migration[4.2]
Index = Struct.new(:table, :name, :columns)
TABLES = [
- Index.new(:issue_assignees, 'index_issue_assignees_on_issue_id_and_user_id', %i(issue_id user_id)),
- Index.new(:user_interacted_projects, 'index_user_interacted_projects_on_project_id_and_user_id', %i(project_id user_id)),
- Index.new(:merge_request_diff_files, 'index_merge_request_diff_files_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)),
- Index.new(:merge_request_diff_commits, 'index_merge_request_diff_commits_on_mr_diff_id_and_order', %i(merge_request_diff_id relative_order)),
- Index.new(:project_authorizations, 'index_project_authorizations_on_user_id_project_id_access_level', %i(user_id project_id access_level)),
- Index.new(:push_event_payloads, 'index_push_event_payloads_on_event_id', %i(event_id)),
- Index.new(:schema_migrations, 'unique_schema_migrations', %(version))
+ Index.new(:issue_assignees, "index_issue_assignees_on_issue_id_and_user_id", %i[issue_id user_id]),
+ Index.new(:user_interacted_projects, "index_user_interacted_projects_on_project_id_and_user_id", %i[project_id user_id]),
+ Index.new(:merge_request_diff_files, "index_merge_request_diff_files_on_mr_diff_id_and_order", %i[merge_request_diff_id relative_order]),
+ Index.new(:merge_request_diff_commits, "index_merge_request_diff_commits_on_mr_diff_id_and_order", %i[merge_request_diff_id relative_order]),
+ Index.new(:project_authorizations, "index_project_authorizations_on_user_id_project_id_access_level", %i[user_id project_id access_level]),
+ Index.new(:push_event_payloads, "index_push_event_payloads_on_event_id", %i[event_id]),
+ Index.new(:schema_migrations, "unique_schema_migrations", %(version)),
].freeze
disable_ddl_transaction!
diff --git a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb b/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
index 099814d7556..89c7fa660da 100644
--- a/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
+++ b/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
@@ -14,6 +14,6 @@ class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migratio
end
def down
- change_column_default :personal_access_tokens, :scopes, ['api'].to_yaml
+ change_column_default :personal_access_tokens, :scopes, ["api"].to_yaml
end
end
diff --git a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
index 6d9c7e4ed72..c6262088c98 100644
--- a/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
+++ b/db/post_migrate/20161109150329_fix_project_records_with_invalid_visibility.rb
@@ -28,9 +28,9 @@ class FixProjectRecordsWithInvalidVisibility < ActiveRecord::Migration[4.2]
break if to_update.rows.count == 0
# row[0] is projects.id, row[1] is namespaces.visibility_level
- updates = to_update.rows.each_with_object(Hash.new {|h, k| h[k] = [] }) do |row, obj|
+ updates = to_update.rows.each_with_object(Hash.new {|h, k| h[k] = [] }) { |row, obj|
obj[row[1]] << row[0]
- end
+ }
updates.each do |visibility_level, project_ids|
updater = Arel::UpdateManager.new
diff --git a/db/post_migrate/20161221153951_rename_reserved_project_names.rb b/db/post_migrate/20161221153951_rename_reserved_project_names.rb
index 32579256299..fd1e3b4fe3b 100644
--- a/db/post_migrate/20161221153951_rename_reserved_project_names.rb
+++ b/db/post_migrate/20161221153951_rename_reserved_project_names.rb
@@ -5,7 +5,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2]
THREAD_COUNT = 8
- KNOWN_PATHS = %w(.well-known
+ KNOWN_PATHS = %w[.well-known
all
blame
blob
@@ -34,13 +34,13 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2]
unsubscribes
update
users
- wikis).freeze
+ wikis].freeze
def up
queues = Array.new(THREAD_COUNT) { Queue.new }
start = false
- threads = Array.new(THREAD_COUNT) do |index|
+ threads = Array.new(THREAD_COUNT) { |index|
Thread.new do
queue = queues[index]
@@ -49,7 +49,7 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2]
rename_projects(queue.pop) until queue.empty?
end
- end
+ }
enum = queues.each
@@ -78,8 +78,8 @@ class RenameReservedProjectNames < ActiveRecord::Migration[4.2]
def reserved_projects
Project.unscoped
.includes(:namespace)
- .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)')
- .where('projects.path' => KNOWN_PATHS)
+ .where("EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)")
+ .where("projects.path" => KNOWN_PATHS)
end
def route_exists?(full_path)
diff --git a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
index f567accb051..f0ce174cb42 100644
--- a/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
+++ b/db/post_migrate/20170104150317_requeue_pending_delete_projects.rb
@@ -17,9 +17,9 @@ class RequeuePendingDeleteProjects < ActiveRecord::Migration[4.2]
break if ids.rows.count.zero?
- args = ids.map { |id| [id['id'], admin.id, {}] }
+ args = ids.map { |id| [id["id"], admin.id, {}] }
- Sidekiq::Client.push_bulk('class' => "ProjectDestroyWorker", 'args' => args)
+ Sidekiq::Client.push_bulk("class" => "ProjectDestroyWorker", "args" => args)
@offset += 1
end
diff --git a/db/post_migrate/20170106142508_fill_authorized_projects.rb b/db/post_migrate/20170106142508_fill_authorized_projects.rb
index 1f1dd0f47f0..5c750ed5e1f 100644
--- a/db/post_migrate/20170106142508_fill_authorized_projects.rb
+++ b/db/post_migrate/20170106142508_fill_authorized_projects.rb
@@ -5,7 +5,7 @@ class FillAuthorizedProjects < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
# Set this constant to true if this migration requires downtime.
@@ -16,12 +16,12 @@ class FillAuthorizedProjects < ActiveRecord::Migration[4.2]
def up
relation = User.select(:id)
- .where('authorized_projects_populated IS NOT TRUE')
+ .where("authorized_projects_populated IS NOT TRUE")
relation.find_in_batches(batch_size: 1_000) do |rows|
args = rows.map { |row| [row.id] }
- Sidekiq::Client.push_bulk('class' => 'AuthorizedProjectsWorker', 'args' => args)
+ Sidekiq::Client.push_bulk("class" => "AuthorizedProjectsWorker", "args" => args)
end
end
diff --git a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
index f221dac8e20..8383ed66b51 100644
--- a/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
+++ b/db/post_migrate/20170206040400_remove_inactive_default_email_services.rb
@@ -9,7 +9,7 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2]
Gitlab::Database.with_connection_pool(2) do |pool|
threads = []
- threads << Thread.new do
+ threads << Thread.new {
pool.with_connection do |connection|
connection.execute <<-SQL.strip_heredoc
DELETE FROM services
@@ -18,9 +18,9 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2]
AND properties = '{"notify_only_broken_builds":true}';
SQL
end
- end
+ }
- threads << Thread.new do
+ threads << Thread.new {
pool.with_connection do |connection|
connection.execute <<-SQL.strip_heredoc
DELETE FROM services
@@ -29,7 +29,7 @@ class RemoveInactiveDefaultEmailServices < ActiveRecord::Migration[4.2]
AND properties = '{"notify_only_broken_pipelines":true}';
SQL
end
- end
+ }
threads.each(&:join)
end
diff --git a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb
index 81ac4cf1373..fdd14195104 100644
--- a/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb
+++ b/db/post_migrate/20170209140523_validate_foreign_keys_on_oauth_openid_requests.rb
@@ -7,10 +7,10 @@ class ValidateForeignKeysOnOauthOpenidRequests < ActiveRecord::Migration[4.2]
def up
if Gitlab::Database.postgresql?
- execute %q{
+ execute '
ALTER TABLE "oauth_openid_requests"
VALIDATE CONSTRAINT "fk_oauth_openid_requests_oauth_access_grants_access_grant_id";
- }
+ '
end
end
diff --git a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb
index c2d28d79491..df29b7764b4 100644
--- a/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb
+++ b/db/post_migrate/20170301205640_migrate_build_events_to_pipeline_events.rb
@@ -7,7 +7,7 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration[4.2]
Gitlab::Database.with_connection_pool(2) do |pool|
threads = []
- threads << Thread.new do
+ threads << Thread.new {
pool.with_connection do |connection|
Thread.current[:foreign_key_connection] = connection
@@ -23,15 +23,15 @@ class MigrateBuildEventsToPipelineEvents < ActiveRecord::Migration[4.2]
AND build_events = #{true_value};
SQL
end
- end
+ }
- threads << Thread.new do
+ threads << Thread.new {
pool.with_connection do |connection|
Thread.current[:foreign_key_connection] = connection
execute(update_pipeline_services_sql)
end
- end
+ }
threads.each(&:join)
end
diff --git a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb
index 85c97e3687e..9e6c79c8389 100644
--- a/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb
+++ b/db/post_migrate/20170313133418_rename_more_reserved_project_names.rb
@@ -3,7 +3,7 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration[4.2]
DOWNTIME = false
- KNOWN_PATHS = %w(artifacts graphs refs badges).freeze
+ KNOWN_PATHS = %w[artifacts graphs refs badges].freeze
def up
reserved_projects.each_slice(100) do |slice|
@@ -20,8 +20,8 @@ class RenameMoreReservedProjectNames < ActiveRecord::Migration[4.2]
def reserved_projects
Project.unscoped
.includes(:namespace)
- .where('EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)')
- .where('projects.path' => KNOWN_PATHS)
+ .where("EXISTS (SELECT 1 FROM namespaces WHERE projects.namespace_id = namespaces.id)")
+ .where("projects.path" => KNOWN_PATHS)
end
def route_exists?(full_path)
diff --git a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb
index 99cdca465e2..912b3278a97 100644
--- a/db/post_migrate/20170317162059_update_upload_paths_to_system.rb
+++ b/db/post_migrate/20170317162059_update_upload_paths_to_system.rb
@@ -5,7 +5,7 @@ class UpdateUploadPathsToSystem < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- AFFECTED_MODELS = %w(User Project Note Namespace Appearance)
+ AFFECTED_MODELS = %w[User Project Note Namespace Appearance]
disable_ddl_transaction!
diff --git a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb
index 61a5c364b2f..72349132e4c 100644
--- a/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb
+++ b/db/post_migrate/20170324160416_migrate_user_activities_to_users_last_activity_on.rb
@@ -5,7 +5,7 @@ class MigrateUserActivitiesToUsersLastActivityOn < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- USER_ACTIVITY_SET_KEY = 'user/activities'.freeze
+ USER_ACTIVITY_SET_KEY = "user/activities".freeze
ACTIVITIES_PER_PAGE = 100
TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED = Time.utc(2016, 12, 1)
diff --git a/db/post_migrate/20170406111121_clean_upload_symlinks.rb b/db/post_migrate/20170406111121_clean_upload_symlinks.rb
index 5fec00aa198..1915d823b38 100644
--- a/db/post_migrate/20170406111121_clean_upload_symlinks.rb
+++ b/db/post_migrate/20170406111121_clean_upload_symlinks.rb
@@ -6,7 +6,7 @@ class CleanUploadSymlinks < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- DIRECTORIES_TO_MOVE = %w(user project note group appearance)
+ DIRECTORIES_TO_MOVE = %w[user project note group appearance]
def up
return unless file_storage?
diff --git a/db/post_migrate/20170408033905_remove_old_cache_directories.rb b/db/post_migrate/20170408033905_remove_old_cache_directories.rb
index 22bc5b9db7b..d96910dca89 100644
--- a/db/post_migrate/20170408033905_remove_old_cache_directories.rb
+++ b/db/post_migrate/20170408033905_remove_old_cache_directories.rb
@@ -13,7 +13,7 @@ class RemoveOldCacheDirectories < ActiveRecord::Migration[4.2]
def up
# FileUploader cache.
- FileUtils.rm_rf(Dir[Rails.root.join('public', 'uploads', 'tmp', '*')])
+ FileUtils.rm_rf(Dir[Rails.root.join("public", "uploads", "tmp", "*")])
end
def down
diff --git a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb
index 9d515aca8b4..6023dac9050 100644
--- a/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb
+++ b/db/post_migrate/20170425130047_drop_ci_trigger_schedules_table.rb
@@ -23,7 +23,7 @@ class DropCiTriggerSchedulesTable < ActiveRecord::Migration[4.2]
t.boolean "active"
end
- add_index "ci_trigger_schedules", %w(active next_run_at), name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree
+ add_index "ci_trigger_schedules", %w[active next_run_at], name: "index_ci_trigger_schedules_on_active_and_next_run_at", using: :btree
add_index "ci_trigger_schedules", ["project_id"], name: "index_ci_trigger_schedules_on_project_id", using: :btree
add_index "ci_trigger_schedules", ["next_run_at"], name: "index_ci_trigger_schedules_on_next_run_at"
diff --git a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb
index c018d30c175..3ecfd552039 100644
--- a/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb
+++ b/db/post_migrate/20170502101023_cleanup_namespaceless_pending_delete_projects.rb
@@ -30,7 +30,7 @@ class CleanupNamespacelessPendingDeleteProjects < ActiveRecord::Migration[4.2]
private
def pending_delete_batch
- connection.exec_query(find_batch).map { |row| row['id'].to_i }
+ connection.exec_query(find_batch).map { |row| row["id"].to_i }
end
BATCH_SIZE = 5000
diff --git a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb
index 596f8593308..a296d951575 100644
--- a/db/post_migrate/20170503004427_update_retried_for_ci_build.rb
+++ b/db/post_migrate/20170503004427_update_retried_for_ci_build.rb
@@ -56,14 +56,14 @@ class UpdateRetriedForCiBuild < ActiveRecord::Migration[4.2]
def with_temporary_partial_index
if Gitlab::Database.postgresql?
unless index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration)
- execute 'CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;'
+ execute "CREATE INDEX CONCURRENTLY index_for_ci_builds_retried_migration ON ci_builds (id) WHERE retried IS NULL;"
end
end
yield
if Gitlab::Database.postgresql? && index_exists?(:ci_builds, :id, name: :index_for_ci_builds_retried_migration)
- execute 'DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration'
+ execute "DROP INDEX CONCURRENTLY index_for_ci_builds_retried_migration"
end
end
end
diff --git a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb
index 6e7365f4c56..47e5ae893bb 100644
--- a/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb
+++ b/db/post_migrate/20170508170547_add_head_pipeline_for_each_merge_request.rb
@@ -12,7 +12,7 @@ class AddHeadPipelineForEachMergeRequest < ActiveRecord::Migration[4.2]
disable_statement_timeout do
head_id = pipelines
- .project(Arel::Nodes::NamedFunction.new('max', [pipelines[:id]]))
+ .project(Arel::Nodes::NamedFunction.new("max", [pipelines[:id]]))
.from(pipelines)
.where(pipelines[:ref].eq(merge_requests[:source_branch]))
.where(pipelines[:project_id].eq(merge_requests[:source_project_id]))
diff --git a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb b/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb
index 85586aecd54..3dd87df9d63 100644
--- a/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb
+++ b/db/post_migrate/20170510101043_add_foreign_key_on_pipeline_schedule_owner.rb
@@ -29,7 +29,7 @@ class AddForeignKeyOnPipelineScheduleOwner < ActiveRecord::Migration[4.2]
if Gitlab::Database.mysql?
:nullify
else
- 'SET NULL'
+ "SET NULL"
end
end
end
diff --git a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb b/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb
index 4ba78727cc3..411a2598dcc 100644
--- a/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb
+++ b/db/post_migrate/20170518200835_rename_users_with_renamed_namespace.rb
@@ -29,18 +29,18 @@ class RenameUsersWithRenamedNamespace < ActiveRecord::Migration[4.2]
users = Arel::Table.new(:users)
namespaces = Arel::Table.new(:namespaces)
predicate = namespaces[:owner_id].eq(users[:id])
- .and(namespaces[:type].eq(nil))
- .and(users[:username].matches(path))
+ .and(namespaces[:type].eq(nil))
+ .and(users[:username].matches(path))
update_sql = if Gitlab::Database.postgresql?
- "UPDATE users SET username = namespaces.path "\
- "FROM namespaces WHERE #{predicate.to_sql}"
- else
- "UPDATE users INNER JOIN namespaces "\
- "ON namespaces.owner_id = users.id "\
- "SET username = namespaces.path "\
- "WHERE #{predicate.to_sql}"
- end
+ "UPDATE users SET username = namespaces.path "\
+ "FROM namespaces WHERE #{predicate.to_sql}"
+ else
+ "UPDATE users INNER JOIN namespaces "\
+ "ON namespaces.owner_id = users.id "\
+ "SET username = namespaces.path "\
+ "WHERE #{predicate.to_sql}"
+ end
connection.execute(update_sql)
end
diff --git a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb b/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb
index 28a2a2e01bf..fe657ed4463 100644
--- a/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb
+++ b/db/post_migrate/20170518231126_fix_wrongly_renamed_routes.rb
@@ -32,7 +32,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2]
FIXED_PATHS = DISALLOWED_ROOT_PATHS.map { |p| "#{p}0" }
class Route < Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Route
- self.table_name = 'routes'
+ self.table_name = "routes"
end
def routes
@@ -61,7 +61,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2]
def wrongly_renamed
Route.joins("INNER JOIN namespaces ON routes.source_id = namespaces.id")
.where(
- routes[:source_type].eq('Namespace')
+ routes[:source_type].eq("Namespace")
.and(namespaces[:parent_id].eq(nil))
)
.where(namespaces[:path].matches_any(wildcard_collection(DISALLOWED_ROOT_PATHS)))
@@ -77,7 +77,7 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2]
#
def paths_and_corrections
connection.select_all(
- wrongly_renamed.select(routes[:path], namespaces[:path].as('namespace_path')).to_sql
+ wrongly_renamed.select(routes[:path], namespaces[:path].as("namespace_path")).to_sql
)
end
@@ -90,8 +90,8 @@ class FixWronglyRenamedRoutes < ActiveRecord::Migration[4.2]
def up
paths_and_corrections.each do |root_namespace|
- wrong_path = root_namespace['path']
- correct_path = root_namespace['namespace_path']
+ wrong_path = root_namespace["path"]
+ correct_path = root_namespace["namespace_path"]
replace_statement = replace_sql(Route.arel_table[:path], wrong_path, correct_path)
update_column_in_batches(:routes, :path, replace_statement) do |table, query|
diff --git a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb
index d75bbb2f612..8c0bf16b43c 100644
--- a/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb
+++ b/db/post_migrate/20170523073948_remove_assignee_id_from_issue.rb
@@ -26,7 +26,7 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include ::EachBatch
end
@@ -39,7 +39,7 @@ class RemoveAssigneeIdFromIssue < ActiveRecord::Migration[4.2]
add_column :issues, :assignee_id, :integer
add_concurrent_index :issues, :assignee_id
- update_value = Arel.sql('(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)')
+ update_value = Arel.sql("(SELECT user_id FROM issue_assignees WHERE issue_assignees.issue_id = issues.id LIMIT 1)")
# This is only used in the down step, so we can ignore the RuboCop warning
# about large tables, as this is very unlikely to be run on GitLab.com
diff --git a/db/post_migrate/20170523083112_migrate_old_artifacts.rb b/db/post_migrate/20170523083112_migrate_old_artifacts.rb
index 55e155c7619..79feda2a82e 100644
--- a/db/post_migrate/20170523083112_migrate_old_artifacts.rb
+++ b/db/post_migrate/20170523083112_migrate_old_artifacts.rb
@@ -21,23 +21,23 @@ class MigrateOldArtifacts < ActiveRecord::Migration[4.2]
def builds_with_artifacts
Build.with_artifacts
- .joins('JOIN projects ON projects.id = ci_builds.project_id')
- .where('ci_builds.id < ?', min_id)
- .where('projects.ci_id IS NOT NULL')
- .select('id', 'created_at', 'project_id', 'projects.ci_id AS ci_id')
+ .joins("JOIN projects ON projects.id = ci_builds.project_id")
+ .where("ci_builds.id < ?", min_id)
+ .where("projects.ci_id IS NOT NULL")
+ .select("id", "created_at", "project_id", "projects.ci_id AS ci_id")
end
def min_id
- Build.joins('JOIN projects ON projects.id = ci_builds.project_id')
- .where('projects.ci_id IS NULL')
- .pluck('coalesce(min(ci_builds.id), 0)')
+ Build.joins("JOIN projects ON projects.id = ci_builds.project_id")
+ .where("projects.ci_id IS NULL")
+ .pluck("coalesce(min(ci_builds.id), 0)")
.first
end
class Build < ActiveRecord::Base
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
- scope :with_artifacts, -> { where.not(artifacts_file: [nil, '']) }
+ scope :with_artifacts, -> { where.not(artifacts_file: [nil, ""]) }
def migrate_artifacts!
return unless File.exist?(source_artifacts_path)
@@ -53,14 +53,14 @@ class MigrateOldArtifacts < ActiveRecord::Migration[4.2]
def source_artifacts_path
@source_artifacts_path ||=
File.join(Gitlab.config.artifacts.path,
- created_at.utc.strftime('%Y_%m'),
+ created_at.utc.strftime("%Y_%m"),
ci_id.to_s, id.to_s)
end
def target_artifacts_path
@target_artifacts_path ||=
File.join(Gitlab.config.artifacts.path,
- created_at.utc.strftime('%Y_%m'),
+ created_at.utc.strftime("%Y_%m"),
project_id.to_s, id.to_s)
end
diff --git a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb
index 59b8daaffdf..bbb0dea9376 100644
--- a/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb
+++ b/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb
@@ -9,81 +9,81 @@ class RenameAllReservedPathsAgain < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
TOP_LEVEL_ROUTES = %w[
- -
- .well-known
- abuse_reports
- admin
- api
- assets
- autocomplete
- ci
- dashboard
- explore
- files
- groups
- health_check
- help
- import
- invites
- jwt
- koding
- notification_settings
- oauth
- profile
- projects
- public
- robots.txt
- s
- search
- sent_notifications
- snippets
- u
- unicorn_test
- unsubscribes
- uploads
- users
+ -
+ .well-known
+ abuse_reports
+ admin
+ api
+ assets
+ autocomplete
+ ci
+ dashboard
+ explore
+ files
+ groups
+ health_check
+ help
+ import
+ invites
+ jwt
+ koding
+ notification_settings
+ oauth
+ profile
+ projects
+ public
+ robots.txt
+ s
+ search
+ sent_notifications
+ snippets
+ u
+ unicorn_test
+ unsubscribes
+ uploads
+ users
].freeze
PROJECT_WILDCARD_ROUTES = %w[
- badges
- blame
- blob
- builds
- commits
- create
- create_dir
- edit
- environments/folders
- files
- find_file
- gitlab-lfs/objects
- info/lfs/objects
- new
- preview
- raw
- refs
- tree
- update
- wikis
- ].freeze
+ badges
+ blame
+ blob
+ builds
+ commits
+ create
+ create_dir
+ edit
+ environments/folders
+ files
+ find_file
+ gitlab-lfs/objects
+ info/lfs/objects
+ new
+ preview
+ raw
+ refs
+ tree
+ update
+ wikis
+ ].freeze
GROUP_ROUTES = %w[
- activity
- analytics
- audit_events
- avatar
- edit
- group_members
- hooks
- issues
- labels
- ldap
- ldap_group_links
- merge_requests
- milestones
- notification_setting
- pipeline_quota
- projects
+ activity
+ analytics
+ audit_events
+ avatar
+ edit
+ group_members
+ hooks
+ issues
+ labels
+ ldap
+ ldap_group_links
+ merge_requests
+ milestones
+ notification_setting
+ pipeline_quota
+ projects
].freeze
def up
diff --git a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb b/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb
index fb9ac8d6daf..e6f72767dfe 100644
--- a/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb
+++ b/db/post_migrate/20170606202615_move_appearance_to_system_dir.rb
@@ -3,7 +3,7 @@ class MoveAppearanceToSystemDir < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- DIRECTORY_TO_MOVE = 'appearance'.freeze
+ DIRECTORY_TO_MOVE = "appearance".freeze
def up
source = File.join(old_upload_dir, DIRECTORY_TO_MOVE)
@@ -21,7 +21,7 @@ class MoveAppearanceToSystemDir < ActiveRecord::Migration[4.2]
def move_directory(source, destination)
unless file_storage?
- say 'Not using file storage, skipping'
+ say "Not using file storage, skipping"
return
end
diff --git a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
index 8ff26130cba..8c37891559d 100644
--- a/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
+++ b/db/post_migrate/20170607121233_convert_custom_notification_settings_to_columns.rb
@@ -6,7 +6,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class NotificationSetting < ActiveRecord::Base
- self.table_name = 'notification_settings'
+ self.table_name = "notification_settings"
store :events, coder: JSON
end
@@ -23,7 +23,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2]
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
- :success_pipeline
+ :success_pipeline,
]
# We only need to migrate (up or down) rows where at least one of these
@@ -40,7 +40,7 @@ class ConvertCustomNotificationSettingsToColumns < ActiveRecord::Migration[4.2]
end
def down
- NotificationSetting.where(EMAIL_EVENTS.join(' OR ')).find_each do |notification_setting|
+ NotificationSetting.where(EMAIL_EVENTS.join(" OR ")).find_each do |notification_setting|
events = {}
EMAIL_EVENTS.each do |event|
diff --git a/db/post_migrate/20170612071012_move_personal_snippets_files.rb b/db/post_migrate/20170612071012_move_personal_snippets_files.rb
index d32d92637fa..f0063f0bd01 100644
--- a/db/post_migrate/20170612071012_move_personal_snippets_files.rb
+++ b/db/post_migrate/20170612071012_move_personal_snippets_files.rb
@@ -9,8 +9,8 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2]
def up
return unless file_storage?
- @source_relative_location = File.join('/uploads', 'personal_snippet')
- @destination_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet')
+ @source_relative_location = File.join("/uploads", "personal_snippet")
+ @destination_relative_location = File.join("/uploads", "-", "system", "personal_snippet")
move_personal_snippet_files
end
@@ -18,8 +18,8 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2]
def down
return unless file_storage?
- @source_relative_location = File.join('/uploads', '-', 'system', 'personal_snippet')
- @destination_relative_location = File.join('/uploads', 'personal_snippet')
+ @source_relative_location = File.join("/uploads", "-", "system", "personal_snippet")
+ @destination_relative_location = File.join("/uploads", "personal_snippet")
move_personal_snippet_files
end
@@ -28,12 +28,12 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2]
query = "SELECT uploads.path, uploads.model_id, snippets.description FROM uploads "\
"INNER JOIN snippets ON snippets.id = uploads.model_id WHERE uploader = 'PersonalFileUploader'"
select_all(query).each do |upload|
- secret = upload['path'].split('/')[0]
- file_name = upload['path'].split('/')[1]
+ secret = upload["path"].split("/")[0]
+ file_name = upload["path"].split("/")[1]
- next unless move_file(upload['model_id'], secret, file_name)
+ next unless move_file(upload["model_id"], secret, file_name)
- update_markdown(upload['model_id'], secret, file_name, upload['description'])
+ update_markdown(upload["model_id"], secret, file_name, upload["description"])
end
end
@@ -75,15 +75,15 @@ class MovePersonalSnippetsFiles < ActiveRecord::Migration[4.2]
query = "SELECT id, note FROM notes WHERE noteable_id = #{snippet_id} "\
"AND noteable_type = 'Snippet' AND note IS NOT NULL"
select_all(query).each do |note|
- text = note['note'].gsub(source_markdown, destination_markdown)
+ text = note["note"].gsub(source_markdown, destination_markdown)
quoted_text = quote_string(text)
- execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note['id']}")
+ execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note["id"]}")
end
end
def base_directory
- File.join(Rails.root, 'public')
+ File.join(Rails.root, "public")
end
def file_storage?
diff --git a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb
index 14511bff3db..0be51d1c1f6 100644
--- a/db/post_migrate/20170613111224_clean_appearance_symlinks.rb
+++ b/db/post_migrate/20170613111224_clean_appearance_symlinks.rb
@@ -36,7 +36,7 @@ class CleanAppearanceSymlinks < ActiveRecord::Migration[4.2]
end
def dir
- 'appearance'
+ "appearance"
end
def base_directory
diff --git a/db/post_migrate/20170627101016_schedule_event_migrations.rb b/db/post_migrate/20170627101016_schedule_event_migrations.rb
index f026a86bc0f..c87e8d0c8f2 100644
--- a/db/post_migrate/20170627101016_schedule_event_migrations.rb
+++ b/db/post_migrate/20170627101016_schedule_event_migrations.rb
@@ -12,14 +12,14 @@ class ScheduleEventMigrations < ActiveRecord::Migration[4.2]
class Event < ActiveRecord::Base
include EachBatch
- self.table_name = 'events'
+ self.table_name = "events"
end
def up
jobs = []
Event.each_batch(of: 1000) do |relation|
- min, max = relation.pluck('MIN(id), MAX(id)').first
+ min, max = relation.pluck("MIN(id), MAX(id)").first
if jobs.length == BUFFER_SIZE
# We push multiple jobs at a time to reduce the time spent in
@@ -29,7 +29,7 @@ class ScheduleEventMigrations < ActiveRecord::Migration[4.2]
jobs.clear
end
- jobs << ['MigrateEventsToPushEventPayloads', [min, max]]
+ jobs << ["MigrateEventsToPushEventPayloads", [min, max]]
end
BackgroundMigrationWorker.bulk_perform_async(jobs) unless jobs.empty?
diff --git a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
index 36aac3df071..81222ef0f8f 100644
--- a/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
+++ b/db/post_migrate/20170628080858_migrate_stage_id_reference_in_background.rb
@@ -4,12 +4,12 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 10000
RANGE_SIZE = 1000
- MIGRATION = 'MigrateBuildStageIdReference'.freeze
+ MIGRATION = "MigrateBuildStageIdReference".freeze
disable_ddl_transaction!
class Build < ActiveRecord::Base
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
include ::EachBatch
end
@@ -19,7 +19,7 @@ class MigrateStageIdReferenceInBackground < ActiveRecord::Migration[4.2]
def up
Build.where(stage_id: nil).each_batch(of: BATCH_SIZE) do |relation, index|
relation.each_batch(of: RANGE_SIZE) do |relation|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker
.perform_in(index * 2.minutes, MIGRATION, range)
diff --git a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb
index fd4b2859f7f..aee88e7a466 100644
--- a/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb
+++ b/db/post_migrate/20170703130158_schedule_merge_request_diff_migrations.rb
@@ -3,12 +3,12 @@ class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 2500
- MIGRATION = 'DeserializeMergeRequestDiffsAndCommits'
+ MIGRATION = "DeserializeMergeRequestDiffsAndCommits"
disable_ddl_transaction!
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
end
@@ -19,10 +19,10 @@ class ScheduleMergeRequestDiffMigrations < ActiveRecord::Migration[4.2]
#
# On staging, plucking the IDs themselves takes 5 seconds.
def up
- non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL'
+ non_empty = "st_commits IS NOT NULL OR st_diffs IS NOT NULL"
MergeRequestDiff.where(non_empty).each_batch(of: BATCH_SIZE) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range)
end
diff --git a/db/post_migrate/20170711145558_migrate_stages_statuses.rb b/db/post_migrate/20170711145558_migrate_stages_statuses.rb
index 8ba69ea4dce..56d99111032 100644
--- a/db/post_migrate/20170711145558_migrate_stages_statuses.rb
+++ b/db/post_migrate/20170711145558_migrate_stages_statuses.rb
@@ -7,17 +7,17 @@ class MigrateStagesStatuses < ActiveRecord::Migration[4.2]
BATCH_SIZE = 10000
RANGE_SIZE = 100
- MIGRATION = 'MigrateStageStatus'.freeze
+ MIGRATION = "MigrateStageStatus".freeze
class Stage < ActiveRecord::Base
- self.table_name = 'ci_stages'
+ self.table_name = "ci_stages"
include ::EachBatch
end
def up
Stage.where(status: nil).each_batch(of: BATCH_SIZE) do |relation, index|
relation.each_batch(of: RANGE_SIZE) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
delay = index * 5.minutes
BackgroundMigrationWorker.perform_in(delay, MIGRATION, range)
diff --git a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb b/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb
index 392c4f71532..7a74f43e9a6 100644
--- a/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb
+++ b/db/post_migrate/20170717111152_cleanup_move_system_upload_folder_symlink.rb
@@ -27,14 +27,14 @@ class CleanupMoveSystemUploadFolderSymlink < ActiveRecord::Migration[4.2]
end
def new_directory
- File.join(base_directory, '-', 'system')
+ File.join(base_directory, "-", "system")
end
def old_directory
- File.join(base_directory, 'system')
+ File.join(base_directory, "system")
end
def base_directory
- File.join(Rails.root, 'public', 'uploads')
+ File.join(Rails.root, "public", "uploads")
end
end
diff --git a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb b/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb
index fdd990ae2e5..fc70be48b96 100644
--- a/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb
+++ b/db/post_migrate/20170717150329_enqueue_migrate_system_uploads_to_new_folder.rb
@@ -3,18 +3,18 @@ class EnqueueMigrateSystemUploadsToNewFolder < ActiveRecord::Migration[4.2]
DOWNTIME = false
- OLD_FOLDER = 'uploads/system/'
- NEW_FOLDER = 'uploads/-/system/'
+ OLD_FOLDER = "uploads/system/"
+ NEW_FOLDER = "uploads/-/system/"
disable_ddl_transaction!
def up
- BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder',
- [OLD_FOLDER, NEW_FOLDER])
+ BackgroundMigrationWorker.perform_async("MigrateSystemUploadsToNewFolder",
+ [OLD_FOLDER, NEW_FOLDER])
end
def down
- BackgroundMigrationWorker.perform_async('MigrateSystemUploadsToNewFolder',
- [NEW_FOLDER, OLD_FOLDER])
+ BackgroundMigrationWorker.perform_async("MigrateSystemUploadsToNewFolder",
+ [NEW_FOLDER, OLD_FOLDER])
end
end
diff --git a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb
index 7af1d04f0cc..94486bdd194 100644
--- a/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb
+++ b/db/post_migrate/20170719150301_merge_issuable_reopened_into_opened_state.rb
@@ -9,13 +9,13 @@ class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include EachBatch
end
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include EachBatch
end
@@ -24,8 +24,8 @@ class MergeIssuableReopenedIntoOpenedState < ActiveRecord::Migration[4.2]
[Issue, MergeRequest].each do |model|
say "Changing #{model.table_name}.state from 'reopened' to 'opened'"
- model.where(state: 'reopened').each_batch do |batch|
- batch.update_all(state: 'opened')
+ model.where(state: "reopened").each_batch do |batch|
+ batch.update_all(state: "opened")
end
end
end
diff --git a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
index a148586ca89..900bc558a84 100644
--- a/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
+++ b/db/post_migrate/20170803090603_calculate_conv_dev_index_percentages.rb
@@ -3,7 +3,7 @@ class CalculateConvDevIndexPercentages < ActiveRecord::Migration[4.2]
DOWNTIME = false
class ConversationalDevelopmentIndexMetric < ActiveRecord::Base
- self.table_name = 'conversational_development_index_metrics'
+ self.table_name = "conversational_development_index_metrics"
METRICS = %w[boards ci_pipelines deployments environments issues merge_requests milestones notes
projects_prometheus_active service_desk_issues]
@@ -21,7 +21,7 @@ class CalculateConvDevIndexPercentages < ActiveRecord::Migration[4.2]
update << "percentage_#{metric} = '#{percentage}'"
end
- execute("UPDATE conversational_development_index_metrics SET #{update.join(',')} WHERE id = #{conv_dev_index.id}")
+ execute("UPDATE conversational_development_index_metrics SET #{update.join(",")} WHERE id = #{conv_dev_index.id}")
end
end
diff --git a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb b/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb
index 8341ac39c25..7938316a62d 100644
--- a/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb
+++ b/db/post_migrate/20170807190736_move_personal_snippet_files_into_correct_folder.rb
@@ -6,21 +6,21 @@ class MovePersonalSnippetFilesIntoCorrectFolder < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- NEW_DIRECTORY = File.join('/uploads', '-', 'system', 'personal_snippet')
- OLD_DIRECTORY = File.join('/uploads', 'system', 'personal_snippet')
+ NEW_DIRECTORY = File.join("/uploads", "-", "system", "personal_snippet")
+ OLD_DIRECTORY = File.join("/uploads", "system", "personal_snippet")
def up
return unless file_storage?
- BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles',
- [OLD_DIRECTORY, NEW_DIRECTORY])
+ BackgroundMigrationWorker.perform_async("MovePersonalSnippetFiles",
+ [OLD_DIRECTORY, NEW_DIRECTORY])
end
def down
return unless file_storage?
- BackgroundMigrationWorker.perform_async('MovePersonalSnippetFiles',
- [NEW_DIRECTORY, OLD_DIRECTORY])
+ BackgroundMigrationWorker.perform_async("MovePersonalSnippetFiles",
+ [NEW_DIRECTORY, OLD_DIRECTORY])
end
def file_storage?
diff --git a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
index fdc126b8fd6..c82b1f4043e 100644
--- a/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
+++ b/db/post_migrate/20170815060945_remove_duplicate_mr_events.rb
@@ -6,14 +6,14 @@ class RemoveDuplicateMrEvents < ActiveRecord::Migration[4.2]
DOWNTIME = false
class Event < ActiveRecord::Base
- self.table_name = 'events'
+ self.table_name = "events"
end
def up
base_condition = "action = 1 AND target_type = 'MergeRequest' AND created_at > '2017-08-13'"
- Event.select('target_id, count(*)')
+ Event.select("target_id, count(*)")
.where(base_condition)
- .group('target_id').having('count(*) > 1').each do |event|
+ .group("target_id").having("count(*) > 1").each do |event|
duplicates = Event.where("#{base_condition} AND target_id = #{event.target_id}").pluck(:id)
duplicates.shift
diff --git a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb
index 27656fd926d..d0cb1893f5c 100644
--- a/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb
+++ b/db/post_migrate/20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb
@@ -9,13 +9,13 @@ class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration
disable_ddl_transaction!
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include ::EachBatch
end
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
end
def up
@@ -37,8 +37,8 @@ class CleanupNonexistingNamespacePendingDeleteProjects < ActiveRecord::Migration
namespaces = Namespace.arel_table
namespace_query = namespaces.project(1)
- .where(namespaces[:id].eq(projects[:namespace_id]))
- .exists.not
+ .where(namespaces[:id].eq(projects[:namespace_id]))
+ .exists.not
# SELECT "projects"."id"
# FROM "projects"
diff --git a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb
index 825bc9250bd..ae2cd6d9718 100644
--- a/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb
+++ b/db/post_migrate/20170822101017_migrate_pipeline_sidekiq_queues.rb
@@ -4,14 +4,14 @@ class MigratePipelineSidekiqQueues < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- sidekiq_queue_migrate 'build', to: 'pipeline_default'
- sidekiq_queue_migrate 'pipeline', to: 'pipeline_default'
+ sidekiq_queue_migrate "build", to: "pipeline_default"
+ sidekiq_queue_migrate "pipeline", to: "pipeline_default"
end
def down
- sidekiq_queue_migrate 'pipeline_default', to: 'pipeline'
- sidekiq_queue_migrate 'pipeline_processing', to: 'pipeline'
- sidekiq_queue_migrate 'pipeline_hooks', to: 'pipeline'
- sidekiq_queue_migrate 'pipeline_cache', to: 'pipeline'
+ sidekiq_queue_migrate "pipeline_default", to: "pipeline"
+ sidekiq_queue_migrate "pipeline_processing", to: "pipeline"
+ sidekiq_queue_migrate "pipeline_hooks", to: "pipeline"
+ sidekiq_queue_migrate "pipeline_cache", to: "pipeline"
end
end
diff --git a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
index 533155aeb7a..4f9fcd01384 100644
--- a/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
+++ b/db/post_migrate/20170828170502_post_deploy_migrate_user_external_mail_data.rb
@@ -9,20 +9,20 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
include EachBatch
end
class UserSyncedAttributesMetadata < ActiveRecord::Base
- self.table_name = 'user_synced_attributes_metadata'
+ self.table_name = "user_synced_attributes_metadata"
include EachBatch
end
def up
User.each_batch do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
execute <<-EOF
INSERT INTO user_synced_attributes_metadata (user_id, provider, email_synced)
@@ -42,7 +42,7 @@ class PostDeployMigrateUserExternalMailData < ActiveRecord::Migration[4.2]
def down
UserSyncedAttributesMetadata.each_batch do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
execute <<-EOF
UPDATE users
diff --git a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb
index 3538b52b004..d8f26f2d55c 100644
--- a/db/post_migrate/20170830150306_drop_events_for_migration_table.rb
+++ b/db/post_migrate/20170830150306_drop_events_for_migration_table.rb
@@ -34,7 +34,7 @@ class DropEventsForMigrationTable < ActiveRecord::Migration[4.2]
end
Event.all.each_batch do |relation|
- start_id, stop_id = relation.pluck('MIN(id), MAX(id)').first
+ start_id, stop_id = relation.pluck("MIN(id), MAX(id)").first
execute <<-EOF.strip_heredoc
INSERT INTO events_for_migration (target_type, target_id, project_id, created_at, updated_at, action, author_id)
diff --git a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb
index bbc624ac7c0..060244b5859 100644
--- a/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb
+++ b/db/post_migrate/20170913180600_fix_projects_without_project_feature.rb
@@ -8,7 +8,7 @@ class FixProjectsWithoutProjectFeature < ActiveRecord::Migration[4.2]
# Creates missing project features with private visibility
sql =
- %Q{
+ %{
INSERT INTO project_features(project_id, repository_access_level, issues_access_level, merge_requests_access_level, wiki_access_level,
builds_access_level, snippets_access_level, created_at, updated_at)
SELECT projects.id as project_id,
diff --git a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb
index 9080acee1d6..26d7fee93b8 100644
--- a/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb
+++ b/db/post_migrate/20170921101004_normalize_ldap_extern_uids.rb
@@ -5,7 +5,7 @@ class NormalizeLdapExternUids < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- MIGRATION = 'NormalizeLdapExternUidsRange'.freeze
+ MIGRATION = "NormalizeLdapExternUidsRange".freeze
DELAY_INTERVAL = 10.seconds
disable_ddl_transaction!
@@ -13,7 +13,7 @@ class NormalizeLdapExternUids < ActiveRecord::Migration[4.2]
class Identity < ActiveRecord::Base
include EachBatch
- self.table_name = 'identities'
+ self.table_name = "identities"
end
def up
diff --git a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb
index 9b675a51725..cc8468c9bbb 100644
--- a/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb
+++ b/db/post_migrate/20170926150348_schedule_merge_request_diff_migrations_take_two.rb
@@ -3,17 +3,17 @@ class ScheduleMergeRequestDiffMigrationsTakeTwo < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 500
- MIGRATION = 'DeserializeMergeRequestDiffsAndCommits'
+ MIGRATION = "DeserializeMergeRequestDiffsAndCommits"
DELAY_INTERVAL = 10.minutes
disable_ddl_transaction!
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
include ::EachBatch
- default_scope { where('st_commits IS NOT NULL OR st_diffs IS NOT NULL') }
+ default_scope { where("st_commits IS NOT NULL OR st_diffs IS NOT NULL") }
end
# By this point, we assume ScheduleMergeRequestDiffMigrations - the first
diff --git a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb b/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb
index 83c21c203e0..3df2551bd77 100644
--- a/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb
+++ b/db/post_migrate/20170927112318_update_legacy_diff_notes_type_for_import.rb
@@ -7,8 +7,8 @@ class UpdateLegacyDiffNotesTypeForImport < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- update_column_in_batches(:notes, :type, 'LegacyDiffNote') do |table, query|
- query.where(table[:type].eq('Github::Import::LegacyDiffNote'))
+ update_column_in_batches(:notes, :type, "LegacyDiffNote") do |table, query|
+ query.where(table[:type].eq("Github::Import::LegacyDiffNote"))
end
end
diff --git a/db/post_migrate/20170927112319_update_notes_type_for_import.rb b/db/post_migrate/20170927112319_update_notes_type_for_import.rb
index 8c691de3192..efd022a2143 100644
--- a/db/post_migrate/20170927112319_update_notes_type_for_import.rb
+++ b/db/post_migrate/20170927112319_update_notes_type_for_import.rb
@@ -7,8 +7,8 @@ class UpdateNotesTypeForImport < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- update_column_in_batches(:notes, :type, 'Note') do |table, query|
- query.where(table[:type].eq('Github::Import::Note'))
+ update_column_in_batches(:notes, :type, "Note") do |table, query|
+ query.where(table[:type].eq("Github::Import::Note"))
end
end
diff --git a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb
index e49a70f902c..a490f1c5c39 100644
--- a/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb
+++ b/db/post_migrate/20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys.rb
@@ -5,19 +5,19 @@ class ScheduleCreateGpgKeySubkeysFromGpgKeys < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- MIGRATION = 'CreateGpgKeySubkeysFromGpgKeys'
+ MIGRATION = "CreateGpgKeySubkeysFromGpgKeys"
class GpgKey < ActiveRecord::Base
- self.table_name = 'gpg_keys'
+ self.table_name = "gpg_keys"
include EachBatch
end
def up
GpgKey.select(:id).each_batch do |gpg_keys|
- jobs = gpg_keys.pluck(:id).map do |id|
+ jobs = gpg_keys.pluck(:id).map { |id|
[MIGRATION, [id]]
- end
+ }
BackgroundMigrationWorker.bulk_perform_async(jobs)
end
diff --git a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb
index 9c90aa611a4..ae9d342ea5f 100644
--- a/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb
+++ b/db/post_migrate/20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb
@@ -2,54 +2,54 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2
DOWNTIME = false
class GcpCluster < ActiveRecord::Base
- self.table_name = 'gcp_clusters'
+ self.table_name = "gcp_clusters"
- belongs_to :project, class_name: 'Project'
+ belongs_to :project, class_name: "Project"
include EachBatch
end
class Cluster < ActiveRecord::Base
- self.table_name = 'clusters'
+ self.table_name = "clusters"
- has_many :cluster_projects, class_name: 'ClustersProject'
- has_many :projects, through: :cluster_projects, class_name: 'Project'
- has_one :provider_gcp, class_name: 'ProvidersGcp'
- has_one :platform_kubernetes, class_name: 'PlatformsKubernetes'
+ has_many :cluster_projects, class_name: "ClustersProject"
+ has_many :projects, through: :cluster_projects, class_name: "Project"
+ has_one :provider_gcp, class_name: "ProvidersGcp"
+ has_one :platform_kubernetes, class_name: "PlatformsKubernetes"
accepts_nested_attributes_for :provider_gcp
accepts_nested_attributes_for :platform_kubernetes
enum platform_type: {
- kubernetes: 1
+ kubernetes: 1,
}
enum provider_type: {
user: 0,
- gcp: 1
+ gcp: 1,
}
end
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
- has_one :cluster_project, class_name: 'ClustersProject'
- has_one :cluster, through: :cluster_project, class_name: 'Cluster'
+ has_one :cluster_project, class_name: "ClustersProject"
+ has_one :cluster, through: :cluster_project, class_name: "Cluster"
end
class ClustersProject < ActiveRecord::Base
- self.table_name = 'cluster_projects'
+ self.table_name = "cluster_projects"
- belongs_to :cluster, class_name: 'Cluster'
- belongs_to :project, class_name: 'Project'
+ belongs_to :cluster, class_name: "Cluster"
+ belongs_to :project, class_name: "Project"
end
class ProvidersGcp < ActiveRecord::Base
- self.table_name = 'cluster_providers_gcp'
+ self.table_name = "cluster_providers_gcp"
end
class PlatformsKubernetes < ActiveRecord::Base
- self.table_name = 'cluster_platforms_kubernetes'
+ self.table_name = "cluster_platforms_kubernetes"
end
def up
@@ -71,7 +71,7 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2
operation_id: gcp_cluster.gcp_operation_id,
endpoint: gcp_cluster.endpoint,
encrypted_access_token: gcp_cluster.encrypted_gcp_token,
- encrypted_access_token_iv: gcp_cluster.encrypted_gcp_token_iv
+ encrypted_access_token_iv: gcp_cluster.encrypted_gcp_token_iv,
},
platform_kubernetes_attributes: {
api_url: api_url(gcp_cluster.endpoint),
@@ -81,18 +81,19 @@ class MigrateGcpClustersToNewClustersArchitectures < ActiveRecord::Migration[4.2
encrypted_password: gcp_cluster.encrypted_password,
encrypted_password_iv: gcp_cluster.encrypted_password_iv,
encrypted_token: gcp_cluster.encrypted_kubernetes_token,
- encrypted_token_iv: gcp_cluster.encrypted_kubernetes_token_iv
- } )
+ encrypted_token_iv: gcp_cluster.encrypted_kubernetes_token_iv,
+ }
+ )
end
end
def down
- execute('DELETE FROM clusters')
+ execute("DELETE FROM clusters")
end
private
def api_url(endpoint)
- endpoint ? 'https://' + endpoint : nil
+ endpoint ? "https://" + endpoint : nil
end
end
diff --git a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb
index 764561de997..74b26c54d97 100644
--- a/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb
+++ b/db/post_migrate/20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations.rb
@@ -3,12 +3,12 @@ class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Mig
DOWNTIME = false
BATCH_SIZE = 50_000
- MIGRATION = 'PopulateMergeRequestsLatestMergeRequestDiffId'
+ MIGRATION = "PopulateMergeRequestsLatestMergeRequestDiffId"
disable_ddl_transaction!
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
@@ -21,7 +21,7 @@ class ScheduleMergeRequestLatestMergeRequestDiffIdMigrations < ActiveRecord::Mig
# we can migrate all the rows in 8.5 hours.
def up
MergeRequest.where(latest_merge_request_diff_id: nil).each_batch(of: BATCH_SIZE) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * 5.minutes, MIGRATION, range)
end
diff --git a/db/post_migrate/20171103140253_track_untracked_uploads.rb b/db/post_migrate/20171103140253_track_untracked_uploads.rb
index 6891ef5ba12..e291ac8b499 100644
--- a/db/post_migrate/20171103140253_track_untracked_uploads.rb
+++ b/db/post_migrate/20171103140253_track_untracked_uploads.rb
@@ -7,7 +7,7 @@ class TrackUntrackedUploads < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
DOWNTIME = false
- MIGRATION = 'PrepareUntrackedUploads'
+ MIGRATION = "PrepareUntrackedUploads"
def up
BackgroundMigrationWorker.perform_async(MIGRATION)
diff --git a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb
index 76862cccf60..8ff8a44b4ba 100644
--- a/db/post_migrate/20171114104051_remove_empty_fork_networks.rb
+++ b/db/post_migrate/20171114104051_remove_empty_fork_networks.rb
@@ -7,22 +7,22 @@ class RemoveEmptyForkNetworks < ActiveRecord::Migration[4.2]
class MigrationForkNetwork < ActiveRecord::Base
include EachBatch
- self.table_name = 'fork_networks'
+ self.table_name = "fork_networks"
end
class MigrationForkNetworkMembers < ActiveRecord::Base
- self.table_name = 'fork_network_members'
+ self.table_name = "fork_network_members"
end
disable_ddl_transaction!
def up
- say 'Deleting empty ForkNetworks in batches'
+ say "Deleting empty ForkNetworks in batches"
has_members = MigrationForkNetworkMembers
- .where('fork_network_members.fork_network_id = fork_networks.id')
- .select(1)
- MigrationForkNetwork.where('NOT EXISTS (?)', has_members)
+ .where("fork_network_members.fork_network_id = fork_networks.id")
+ .select(1)
+ MigrationForkNetwork.where("NOT EXISTS (?)", has_members)
.each_batch(of: BATCH_SIZE) do |networks|
deleted = networks.delete_all
diff --git a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb
index ae954289291..eda40a749c3 100644
--- a/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb
+++ b/db/post_migrate/20171123101020_update_circuitbreaker_defaults.rb
@@ -10,11 +10,11 @@ class UpdateCircuitbreakerDefaults < ActiveRecord::Migration[4.2]
def up
change_column_default :application_settings,
- :circuitbreaker_failure_count_threshold,
- 3
+ :circuitbreaker_failure_count_threshold,
+ 3
change_column_default :application_settings,
- :circuitbreaker_storage_timeout,
- 15
+ :circuitbreaker_storage_timeout,
+ 15
ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 3,
circuitbreaker_storage_timeout: 15)
@@ -22,11 +22,11 @@ class UpdateCircuitbreakerDefaults < ActiveRecord::Migration[4.2]
def down
change_column_default :application_settings,
- :circuitbreaker_failure_count_threshold,
- 160
+ :circuitbreaker_failure_count_threshold,
+ 160
change_column_default :application_settings,
- :circuitbreaker_storage_timeout,
- 30
+ :circuitbreaker_storage_timeout,
+ 30
ApplicationSetting.update_all(circuitbreaker_failure_count_threshold: 160,
circuitbreaker_storage_timeout: 30)
diff --git a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb b/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb
index 3f2c1b2170a..322e8308702 100644
--- a/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb
+++ b/db/post_migrate/20171123101046_remove_old_circuitbreaker_config.rb
@@ -8,19 +8,19 @@ class RemoveOldCircuitbreakerConfig < ActiveRecord::Migration[4.2]
def up
remove_column :application_settings,
- :circuitbreaker_backoff_threshold
+ :circuitbreaker_backoff_threshold
remove_column :application_settings,
- :circuitbreaker_failure_wait_time
+ :circuitbreaker_failure_wait_time
end
def down
add_column :application_settings,
- :circuitbreaker_backoff_threshold,
- :integer,
- default: 80
+ :circuitbreaker_backoff_threshold,
+ :integer,
+ default: 80
add_column :application_settings,
- :circuitbreaker_failure_wait_time,
- :integer,
- default: 30
+ :circuitbreaker_failure_wait_time,
+ :integer,
+ default: 30
end
end
diff --git a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
index 58ceefe3c97..6de6d1c02d2 100644
--- a/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
+++ b/db/post_migrate/20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb
@@ -2,107 +2,107 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = 'KubernetesService'.freeze
+ DEFAULT_KUBERNETES_SERVICE_CLUSTER_NAME = "KubernetesService".freeze
disable_ddl_transaction!
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
- has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject'
- has_many :clusters, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
- has_many :services, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service'
- has_one :kubernetes_service, -> { where(category: 'deployment', type: 'KubernetesService') }, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Service', inverse_of: :project, foreign_key: :project_id
+ has_many :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject"
+ has_many :clusters, through: :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster"
+ has_many :services, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Service"
+ has_one :kubernetes_service, -> { where(category: "deployment", type: "KubernetesService") }, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Service", inverse_of: :project, foreign_key: :project_id
end
class Cluster < ActiveRecord::Base
- self.table_name = 'clusters'
+ self.table_name = "clusters"
- has_many :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject'
- has_many :projects, through: :cluster_projects, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project'
- has_one :platform_kubernetes, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes'
+ has_many :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::ClustersProject"
+ has_many :projects, through: :cluster_projects, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project"
+ has_one :platform_kubernetes, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::PlatformsKubernetes"
accepts_nested_attributes_for :platform_kubernetes
enum platform_type: {
- kubernetes: 1
+ kubernetes: 1,
}
enum provider_type: {
user: 0,
- gcp: 1
+ gcp: 1,
}
end
class ClustersProject < ActiveRecord::Base
- self.table_name = 'cluster_projects'
+ self.table_name = "cluster_projects"
- belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
- belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project'
+ belongs_to :cluster, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster"
+ belongs_to :project, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project"
end
class PlatformsKubernetes < ActiveRecord::Base
- self.table_name = 'cluster_platforms_kubernetes'
+ self.table_name = "cluster_platforms_kubernetes"
- belongs_to :cluster, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Cluster'
+ belongs_to :cluster, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Cluster"
attr_encrypted :token,
mode: :per_attribute_iv,
key: Settings.attr_encrypted_db_key_base_truncated,
- algorithm: 'aes-256-cbc'
+ algorithm: "aes-256-cbc"
end
class Service < ActiveRecord::Base
include EachBatch
- self.table_name = 'services'
+ self.table_name = "services"
self.inheritance_column = :_type_disabled # Disable STI, otherwise KubernetesModel will be looked up
- belongs_to :project, class_name: 'MigrateKubernetesServiceToNewClustersArchitectures::Project', foreign_key: :project_id
+ belongs_to :project, class_name: "MigrateKubernetesServiceToNewClustersArchitectures::Project", foreign_key: :project_id
scope :unmanaged_kubernetes_service, -> do
- joins('LEFT JOIN projects ON projects.id = services.project_id')
- .joins('LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id')
- .joins('LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id')
- .where(category: 'deployment', type: 'KubernetesService', template: false)
- .where("services.properties LIKE '%api_url%'")
- .where("(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL")
- .group(:id)
- .order(id: :asc)
+ joins("LEFT JOIN projects ON projects.id = services.project_id")
+ .joins("LEFT JOIN cluster_projects ON cluster_projects.project_id = projects.id")
+ .joins("LEFT JOIN cluster_platforms_kubernetes ON cluster_platforms_kubernetes.cluster_id = cluster_projects.cluster_id")
+ .where(category: "deployment", type: "KubernetesService", template: false)
+ .where("services.properties LIKE '%api_url%'")
+ .where("(services.properties NOT LIKE CONCAT('%', cluster_platforms_kubernetes.api_url, '%')) OR cluster_platforms_kubernetes.api_url IS NULL")
+ .group(:id)
+ .order(id: :asc)
end
scope :kubernetes_service_without_template, -> do
- where(category: 'deployment', type: 'KubernetesService', template: false)
+ where(category: "deployment", type: "KubernetesService", template: false)
end
def api_url
- parsed_properties['api_url']
+ parsed_properties["api_url"]
end
def ca_pem
- parsed_properties['ca_pem']
+ parsed_properties["ca_pem"]
end
def namespace
- parsed_properties['namespace']
+ parsed_properties["namespace"]
end
def token
- parsed_properties['token']
+ parsed_properties["token"]
end
private
def parsed_properties
- @parsed_properties ||= JSON.parse(self.properties)
+ @parsed_properties ||= JSON.parse(properties)
end
end
def find_dedicated_environement_scope(project)
environment_scopes = project.clusters.map(&:environment_scope)
- return '*' if environment_scopes.exclude?('*') # KubernetesService should be added as a default cluster (environment_scope: '*') at first place
- return 'migrated/*' if environment_scopes.exclude?('migrated/*') # If it's conflicted, the KubernetesService added as a migrated cluster
+ return "*" if environment_scopes.exclude?("*") # KubernetesService should be added as a default cluster (environment_scope: '*') at first place
+ return "migrated/*" if environment_scopes.exclude?("migrated/*") # If it's conflicted, the KubernetesService added as a migrated cluster
unique_iid = 0
@@ -134,8 +134,9 @@ class MigrateKubernetesServiceToNewClustersArchitectures < ActiveRecord::Migrati
username: nil, # KubernetesService doesn't have
encrypted_password: nil, # KubernetesService doesn't have
encrypted_password_iv: nil, # KubernetesService doesn't have
- token: kubernetes_service.token # encrypted_token and encrypted_token_iv
- } )
+ token: kubernetes_service.token, # encrypted_token and encrypted_token_iv
+ }
+ )
end
end
diff --git a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
index 8e320ea9e8d..0789081c175 100644
--- a/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
+++ b/db/post_migrate/20171124150326_reschedule_fork_network_creation.rb
@@ -4,7 +4,7 @@ class RescheduleForkNetworkCreation < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- say 'Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller'
+ say "Fork networks will be populated in 20171205190711 - RescheduleForkNetworkCreationCaller"
end
def down
diff --git a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
index 51441a36e4b..d11b72652f7 100644
--- a/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
+++ b/db/post_migrate/20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb
@@ -3,18 +3,18 @@
class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 10_000
- MIGRATION = 'PopulateMergeRequestMetricsWithEventsData'
+ MIGRATION = "PopulateMergeRequestMetricsWithEventsData"
disable_ddl_transaction!
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
def up
- say 'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs'
+ say "Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs"
# It will update around 4_000_000 records in batches of 10_000 merge
# requests (running between 10 minutes) and should take around 66 hours to complete.
# Apparently, production PostgreSQL is able to vacuum 10k-20k dead_tuples by
@@ -23,7 +23,7 @@ class SchedulePopulateMergeRequestMetricsWithEventsData < ActiveRecord::Migratio
# More information about the updates in `PopulateMergeRequestMetricsWithEventsData` class.
#
MergeRequest.all.each_batch(of: BATCH_SIZE) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * 10.minutes, MIGRATION, range)
end
diff --git a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb
index 058f3a40817..0494d5c9f46 100644
--- a/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb
+++ b/db/post_migrate/20171205190711_reschedule_fork_network_creation_caller.rb
@@ -3,7 +3,7 @@ class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration[4.2]
DOWNTIME = false
- MIGRATION = 'PopulateForkNetworksRange'.freeze
+ MIGRATION = "PopulateForkNetworksRange".freeze
BATCH_SIZE = 100
DELAY_INTERVAL = 15.seconds
@@ -12,11 +12,11 @@ class RescheduleForkNetworkCreationCaller < ActiveRecord::Migration[4.2]
class ForkedProjectLink < ActiveRecord::Base
include EachBatch
- self.table_name = 'forked_project_links'
+ self.table_name = "forked_project_links"
end
def up
- say 'Populating the `fork_networks` based on existing `forked_project_links`'
+ say "Populating the `fork_networks` based on existing `forked_project_links`"
queue_background_migration_jobs_by_range_at_intervals(ForkedProjectLink, MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE)
end
diff --git a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb b/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb
index 44273cebc9d..09ea611df4f 100644
--- a/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb
+++ b/db/post_migrate/20171207150300_remove_project_labels_group_id_copy.rb
@@ -11,7 +11,7 @@ class RemoveProjectLabelsGroupIdCopy < ActiveRecord::Migration[4.2]
def up
# rubocop:disable Migration/UpdateColumnInBatches
update_column_in_batches(:labels, :group_id, nil) do |table, query|
- query.where(table[:type].eq('ProjectLabel').and(table[:group_id].not_eq(nil)))
+ query.where(table[:type].eq("ProjectLabel").and(table[:group_id].not_eq(nil)))
end
# rubocop:enable Migration/UpdateColumnInBatches
end
diff --git a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb
index 53707c67d36..81d6bb39dee 100644
--- a/db/post_migrate/20171207150343_remove_soft_removed_objects.rb
+++ b/db/post_migrate/20171207150343_remove_soft_removed_objects.rb
@@ -13,63 +13,63 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2]
extend ActiveSupport::Concern
included do
- scope :soft_removed, -> { where('deleted_at IS NOT NULL') }
+ scope :soft_removed, -> { where("deleted_at IS NOT NULL") }
end
end
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
include EachBatch
end
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include EachBatch
include SoftRemoved
end
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include EachBatch
include SoftRemoved
end
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
include EachBatch
include SoftRemoved
scope :soft_removed_personal, -> { soft_removed.where(type: nil) }
- scope :soft_removed_group, -> { soft_removed.where(type: 'Group') }
+ scope :soft_removed_group, -> { soft_removed.where(type: "Group") }
end
class Route < ActiveRecord::Base
- self.table_name = 'routes'
+ self.table_name = "routes"
include EachBatch
include SoftRemoved
end
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include EachBatch
include SoftRemoved
end
class CiPipelineSchedule < ActiveRecord::Base
- self.table_name = 'ci_pipeline_schedules'
+ self.table_name = "ci_pipeline_schedules"
include EachBatch
include SoftRemoved
end
class CiTrigger < ActiveRecord::Base
- self.table_name = 'ci_triggers'
+ self.table_name = "ci_triggers"
include EachBatch
include SoftRemoved
@@ -118,7 +118,7 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2]
model.table_name,
[:deleted_at, :id],
name: index_name,
- where: 'deleted_at IS NOT NULL'
+ where: "deleted_at IS NOT NULL"
)
end
end
@@ -159,8 +159,8 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2]
admin_id = id_for_admin_user
unless admin_id
- say 'Not scheduling soft removed groups for removal as no admin user ' \
- 'could be found. You will need to remove any such groups manually.'
+ say "Not scheduling soft removed groups for removal as no admin user " \
+ "could be found. You will need to remove any such groups manually."
return
end
@@ -189,11 +189,11 @@ class RemoveSoftRemovedObjects < ActiveRecord::Migration[4.2]
def remove_personal_routes
namespaces = Namespace.select(1)
.soft_removed
- .where('namespaces.type IS NULL')
- .where('routes.source_type = ?', 'Namespace')
- .where('routes.source_id = namespaces.id')
+ .where("namespaces.type IS NULL")
+ .where("routes.source_type = ?", "Namespace")
+ .where("routes.source_id = namespaces.id")
- Route.where('EXISTS (?)', namespaces).each_batch do |batch|
+ Route.where("EXISTS (?)", namespaces).each_batch do |batch|
batch.delete_all
end
end
diff --git a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb b/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb
index 088c4b5d46b..99908709007 100644
--- a/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb
+++ b/db/post_migrate/20171213160445_migrate_github_importer_advance_stage_sidekiq_queue.rb
@@ -7,10 +7,10 @@ class MigrateGithubImporterAdvanceStageSidekiqQueue < ActiveRecord::Migration[4.
DOWNTIME = false
def up
- sidekiq_queue_migrate 'github_importer_advance_stage', to: 'github_import_advance_stage'
+ sidekiq_queue_migrate "github_importer_advance_stage", to: "github_import_advance_stage"
end
def down
- sidekiq_queue_migrate 'github_import_advance_stage', to: 'github_importer_advance_stage'
+ sidekiq_queue_migrate "github_import_advance_stage", to: "github_importer_advance_stage"
end
end
diff --git a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb
index 1c81e56db55..901ef394963 100644
--- a/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb
+++ b/db/post_migrate/20171215121205_post_populate_can_push_from_deploy_keys_projects.rb
@@ -12,12 +12,12 @@ class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2]
class DeploysKeyProject < ActiveRecord::Base
include EachBatch
- self.table_name = 'deploy_keys_projects'
+ self.table_name = "deploy_keys_projects"
end
def up
DeploysKeyProject.each_batch(of: 10_000) do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
if Gitlab::Database.mysql?
execute <<-EOF.strip_heredoc
@@ -40,7 +40,7 @@ class PostPopulateCanPushFromDeployKeysProjects < ActiveRecord::Migration[4.2]
def down
DeploysKeyProject.each_batch(of: 10_000) do |batch|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
if Gitlab::Database.mysql?
execute <<-EOF.strip_heredoc
diff --git a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb
index 45ef75fdb98..6515574d10d 100644
--- a/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb
+++ b/db/post_migrate/20171219121201_normalize_extern_uid_from_identities.rb
@@ -5,7 +5,7 @@ class NormalizeExternUidFromIdentities < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- MIGRATION = 'NormalizeLdapExternUidsRange'.freeze
+ MIGRATION = "NormalizeLdapExternUidsRange".freeze
DELAY_INTERVAL = 10.seconds
disable_ddl_transaction!
@@ -13,7 +13,7 @@ class NormalizeExternUidFromIdentities < ActiveRecord::Migration[4.2]
class Identity < ActiveRecord::Base
include EachBatch
- self.table_name = 'identities'
+ self.table_name = "identities"
end
def up
diff --git a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb
index 6b5e6202688..4b5de82325d 100644
--- a/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb
+++ b/db/post_migrate/20171221140220_schedule_issues_closed_at_type_change.rb
@@ -9,11 +9,11 @@ class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
include EachBatch
def self.to_migrate
- where('closed_at IS NOT NULL')
+ where("closed_at IS NOT NULL")
end
end
@@ -40,6 +40,6 @@ class ScheduleIssuesClosedAtTypeChange < ActiveRecord::Migration[4.2]
def migrate_column_type?
# Some environments may have already executed the previous version of this
# migration, thus we don't need to migrate those environments again.
- column_for('issues', 'closed_at').type == :datetime
+ column_for("issues", "closed_at").type == :datetime
end
end
diff --git a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb
index 0822aebc2c6..7247e17c49c 100644
--- a/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb
+++ b/db/post_migrate/20180104131052_schedule_set_confidential_note_events_on_webhooks.rb
@@ -13,9 +13,9 @@ class ScheduleSetConfidentialNoteEventsOnWebhooks < ActiveRecord::Migration[4.2]
relation = migration::WebHook.hooks_to_update
queue_background_migration_jobs_by_range_at_intervals(relation,
- migration_name,
- INTERVAL,
- batch_size: BATCH_SIZE)
+ migration_name,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
end
def down
diff --git a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb
index 98bbb34dda1..81c52538eca 100644
--- a/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb
+++ b/db/post_migrate/20180122154930_schedule_set_confidential_note_events_on_services.rb
@@ -13,9 +13,9 @@ class ScheduleSetConfidentialNoteEventsOnServices < ActiveRecord::Migration[4.2]
relation = migration::Service.services_to_update
queue_background_migration_jobs_by_range_at_intervals(relation,
- migration_name,
- INTERVAL,
- batch_size: BATCH_SIZE)
+ migration_name,
+ INTERVAL,
+ batch_size: BATCH_SIZE)
end
def down
diff --git a/db/post_migrate/20180202111106_remove_project_labels_group_id.rb b/db/post_migrate/20180202111106_remove_project_labels_group_id.rb
index 31ec84f0d6a..0d19ac0f9e5 100644
--- a/db/post_migrate/20180202111106_remove_project_labels_group_id.rb
+++ b/db/post_migrate/20180202111106_remove_project_labels_group_id.rb
@@ -10,7 +10,7 @@ class RemoveProjectLabelsGroupId < ActiveRecord::Migration[4.2]
def up
update_column_in_batches(:labels, :group_id, nil) do |table, query|
- query.where(table[:type].eq('ProjectLabel').and(table[:group_id].not_eq(nil)))
+ query.where(table[:type].eq("ProjectLabel").and(table[:group_id].not_eq(nil)))
end
end
diff --git a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb
index 54b8a91fa47..96d34a11d9d 100644
--- a/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb
+++ b/db/post_migrate/20180204200836_change_author_id_to_not_null_in_todos.rb
@@ -2,7 +2,7 @@ class ChangeAuthorIdToNotNullInTodos < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
class Todo < ActiveRecord::Base
- self.table_name = 'todos'
+ self.table_name = "todos"
include EachBatch
end
diff --git a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb
index f8badcac990..067a5a9fc64 100644
--- a/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb
+++ b/db/post_migrate/20180212101828_add_tmp_partial_null_index_to_builds.rb
@@ -4,11 +4,11 @@ class AddTmpPartialNullIndexToBuilds < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL',
- name: 'tmp_id_partial_null_index')
+ add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL",
+ name: "tmp_id_partial_null_index")
end
def down
- remove_concurrent_index_by_name(:ci_builds, 'tmp_id_partial_null_index')
+ remove_concurrent_index_by_name(:ci_builds, "tmp_id_partial_null_index")
end
end
diff --git a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb
index 2444df881b8..cd1c2c100f1 100644
--- a/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb
+++ b/db/post_migrate/20180212102028_remove_tmp_partial_null_index_from_builds.rb
@@ -4,11 +4,11 @@ class RemoveTmpPartialNullIndexFromBuilds < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- remove_concurrent_index_by_name(:ci_builds, 'tmp_id_partial_null_index')
+ remove_concurrent_index_by_name(:ci_builds, "tmp_id_partial_null_index")
end
def down
- add_concurrent_index(:ci_builds, :id, where: 'stage_id IS NULL',
- name: 'tmp_id_partial_null_index')
+ add_concurrent_index(:ci_builds, :id, where: "stage_id IS NULL",
+ name: "tmp_id_partial_null_index")
end
end
diff --git a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb
index dae43ee14df..534e89b4d0e 100644
--- a/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb
+++ b/db/post_migrate/20180216121020_fill_pages_domain_verification_code.rb
@@ -9,7 +9,7 @@ class FillPagesDomainVerificationCode < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- PagesDomain.where(verification_code: [nil, '']).each_batch do |relation|
+ PagesDomain.where(verification_code: [nil, ""]).each_batch do |relation|
connection.execute(set_codes_sql(relation))
# Sleep 2 minutes between batches to not overload the DB with dead tuples
@@ -35,7 +35,7 @@ class FillPagesDomainVerificationCode < ActiveRecord::Migration[4.2]
CASE id
#{whens.join("\n")}
END
- WHERE id IN(#{ids.join(',')})
+ WHERE id IN(#{ids.join(",")})
SQL
end
end
diff --git a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb
index 86ef333685e..941069657ff 100644
--- a/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb
+++ b/db/post_migrate/20180220150310_remove_empty_extern_uid_auth0_identities.rb
@@ -6,7 +6,7 @@ class RemoveEmptyExternUidAuth0Identities < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class Identity < ActiveRecord::Base
- self.table_name = 'identities'
+ self.table_name = "identities"
include EachBatch
end
@@ -17,7 +17,7 @@ class RemoveEmptyExternUidAuth0Identities < ActiveRecord::Migration[4.2]
end
def broken_auth0_identities
- Identity.where(provider: 'auth0', extern_uid: [nil, ''])
+ Identity.where(provider: "auth0", extern_uid: [nil, ""])
end
def down
diff --git a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
index fa332fd5c70..9dac79b88c5 100644
--- a/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
+++ b/db/post_migrate/20180223124427_build_user_interacted_projects_table.rb
@@ -1,4 +1,4 @@
-require_relative '../migrate/20180223120443_create_user_interacted_projects_table.rb'
+require_relative "../migrate/20180223120443_create_user_interacted_projects_table.rb"
# rubocop:disable AddIndex
# rubocop:disable AddConcurrentForeignKey
class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
@@ -7,7 +7,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- UNIQUE_INDEX_NAME = 'index_user_interacted_projects_on_project_id_and_user_id'
+ UNIQUE_INDEX_NAME = "index_user_interacted_projects_on_project_id_and_user_id"
disable_ddl_transaction!
@@ -50,7 +50,7 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
SLEEP_TIME = 5
def up
- with_index(:events, [:author_id, :project_id], name: 'events_user_interactions_temp', where: 'project_id IS NOT NULL') do
+ with_index(:events, [:author_id, :project_id], name: "events_user_interactions_temp", where: "project_id IS NOT NULL") do
insert_missing_records
# Do this once without lock to speed up the second invocation
@@ -84,12 +84,12 @@ class BuildUserInteractedProjectsTable < ActiveRecord::Migration[4.2]
begin
Rails.logger.info "Building user_interacted_projects table, batch ##{iteration}"
result = execute <<~SQL
- INSERT INTO user_interacted_projects (user_id, project_id)
- SELECT e.user_id, e.project_id
- FROM (SELECT DISTINCT author_id AS user_id, project_id FROM events WHERE project_id IS NOT NULL) AS e
- LEFT JOIN user_interacted_projects ucp USING (user_id, project_id)
- WHERE ucp.user_id IS NULL
- LIMIT #{BATCH_SIZE}
+ INSERT INTO user_interacted_projects (user_id, project_id)
+ SELECT e.user_id, e.project_id
+ FROM (SELECT DISTINCT author_id AS user_id, project_id FROM events WHERE project_id IS NOT NULL) AS e
+ LEFT JOIN user_interacted_projects ucp USING (user_id, project_id)
+ WHERE ucp.user_id IS NULL
+ LIMIT #{BATCH_SIZE}
SQL
iteration += 1
records += result.cmd_tuples
diff --git a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb
index 62a239b0e7c..d149076f382 100644
--- a/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb
+++ b/db/post_migrate/20180301084653_change_project_namespace_id_not_null.rb
@@ -5,7 +5,7 @@ class ChangeProjectNamespaceIdNotNull < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include EachBatch
end
diff --git a/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb b/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb
index fc74f6f1712..56a749f1db5 100644
--- a/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb
+++ b/db/post_migrate/20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb
@@ -4,10 +4,10 @@ class MigrateCreateTraceArtifactSidekiqQueue < ActiveRecord::Migration[4.2]
DOWNTIME = false
def up
- sidekiq_queue_migrate 'pipeline_default:create_trace_artifact', to: 'pipeline_background:archive_trace'
+ sidekiq_queue_migrate "pipeline_default:create_trace_artifact", to: "pipeline_background:archive_trace"
end
def down
- sidekiq_queue_migrate 'pipeline_background:archive_trace', to: 'pipeline_default:create_trace_artifact'
+ sidekiq_queue_migrate "pipeline_background:archive_trace", to: "pipeline_default:create_trace_artifact"
end
end
diff --git a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
index 53918250b4c..0552ab44ae1 100644
--- a/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
+++ b/db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb
@@ -8,7 +8,7 @@ class AddPathIndexToRedirectRoutes < ActiveRecord::Migration[4.2]
DOWNTIME = false
disable_ddl_transaction!
- INDEX_NAME = 'index_redirect_routes_on_path_unique_text_pattern_ops'
+ INDEX_NAME = "index_redirect_routes_on_path_unique_text_pattern_ops"
# Indexing on LOWER(path) varchar_pattern_ops speeds up the LIKE query in
# RedirectRoute.matching_path_and_descendants
diff --git a/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb b/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb
index 372c04429c7..7cec496f8c8 100644
--- a/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb
+++ b/db/post_migrate/20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb
@@ -4,12 +4,12 @@ class MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue < ActiveRecord::Migra
DOWNTIME = false
def up
- sidekiq_queue_migrate 'pipeline_default:update_head_pipeline_for_merge_request',
- to: 'pipeline_processing:update_head_pipeline_for_merge_request'
+ sidekiq_queue_migrate "pipeline_default:update_head_pipeline_for_merge_request",
+ to: "pipeline_processing:update_head_pipeline_for_merge_request"
end
def down
- sidekiq_queue_migrate 'pipeline_processing:update_head_pipeline_for_merge_request',
- to: 'pipeline_default:update_head_pipeline_for_merge_request'
+ sidekiq_queue_migrate "pipeline_processing:update_head_pipeline_for_merge_request",
+ to: "pipeline_default:update_head_pipeline_for_merge_request"
end
end
diff --git a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb
index 213d97b71f7..a5c64d7bdd5 100644
--- a/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb
+++ b/db/post_migrate/20180405101928_reschedule_builds_stages_migration.rb
@@ -6,23 +6,23 @@ class RescheduleBuildsStagesMigration < ActiveRecord::Migration[4.2]
#
DOWNTIME = false
- MIGRATION = 'MigrateBuildStage'.freeze
+ MIGRATION = "MigrateBuildStage".freeze
BATCH_SIZE = 500
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
end
def up
disable_statement_timeout do
- Build.where('stage_id IS NULL').tap do |relation|
+ Build.where("stage_id IS NULL").tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
- MIGRATION,
- 5.minutes,
- batch_size: BATCH_SIZE)
+ MIGRATION,
+ 5.minutes,
+ batch_size: BATCH_SIZE)
end
end
end
diff --git a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb
index 2d72e75393f..4995fe1624b 100644
--- a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb
+++ b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb
@@ -2,23 +2,23 @@ class ScheduleStagesIndexMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- MIGRATION = 'MigrateStageIndex'.freeze
+ MIGRATION = "MigrateStageIndex".freeze
BATCH_SIZE = 10000
disable_ddl_transaction!
class Stage < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_stages'
+ self.table_name = "ci_stages"
end
def up
disable_statement_timeout do
Stage.all.tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
- MIGRATION,
- 5.minutes,
- batch_size: BATCH_SIZE)
+ MIGRATION,
+ 5.minutes,
+ batch_size: BATCH_SIZE)
end
end
end
diff --git a/db/post_migrate/20180424151928_fill_file_store.rb b/db/post_migrate/20180424151928_fill_file_store.rb
index 45fa10c9550..a92baf50e19 100644
--- a/db/post_migrate/20180424151928_fill_file_store.rb
+++ b/db/post_migrate/20180424151928_fill_file_store.rb
@@ -7,32 +7,32 @@ class FillFileStore < ActiveRecord::Migration[4.2]
class JobArtifact < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_job_artifacts'
+ self.table_name = "ci_job_artifacts"
BATCH_SIZE = 10_000
def self.params_for_background_migration
- yield self.where(file_store: nil), 'FillFileStoreJobArtifact', 5.minutes, BATCH_SIZE
+ yield where(file_store: nil), "FillFileStoreJobArtifact", 5.minutes, BATCH_SIZE
end
end
class LfsObject < ActiveRecord::Base
include EachBatch
- self.table_name = 'lfs_objects'
+ self.table_name = "lfs_objects"
BATCH_SIZE = 10_000
def self.params_for_background_migration
- yield self.where(file_store: nil), 'FillFileStoreLfsObject', 5.minutes, BATCH_SIZE
+ yield where(file_store: nil), "FillFileStoreLfsObject", 5.minutes, BATCH_SIZE
end
end
class Upload < ActiveRecord::Base
include EachBatch
- self.table_name = 'uploads'
+ self.table_name = "uploads"
self.inheritance_column = :_type_disabled # Disable STI
BATCH_SIZE = 10_000
def self.params_for_background_migration
- yield self.where(store: nil), 'FillStoreUpload', 5.minutes, BATCH_SIZE
+ yield where(store: nil), "FillStoreUpload", 5.minutes, BATCH_SIZE
end
end
diff --git a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb
index b82ee3569c9..2d53e193226 100644
--- a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb
+++ b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb
@@ -3,8 +3,8 @@ class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord:
DOWNTIME = false
- UP_MIGRATION = 'PopulateImportState'.freeze
- DOWN_MIGRATION = 'RollbackImportStateData'.freeze
+ UP_MIGRATION = "PopulateImportState".freeze
+ DOWN_MIGRATION = "RollbackImportStateData".freeze
BATCH_SIZE = 1000
DELAY_INTERVAL = 5.minutes
@@ -14,13 +14,13 @@ class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord:
class Project < ActiveRecord::Base
include EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
end
class ProjectImportState < ActiveRecord::Base
include EachBatch
- self.table_name = 'project_mirror_data'
+ self.table_name = "project_mirror_data"
end
def up
diff --git a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb
index a526001a91e..5384b865a35 100644
--- a/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb
+++ b/db/post_migrate/20180511174224_add_unique_constraint_to_project_features_project_id.rb
@@ -6,7 +6,7 @@ class AddUniqueConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4.
disable_ddl_transaction!
class ProjectFeature < ActiveRecord::Base
- self.table_name = 'project_features'
+ self.table_name = "project_features"
include EachBatch
end
@@ -14,29 +14,29 @@ class AddUniqueConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4.
def up
remove_duplicates
- add_concurrent_index :project_features, :project_id, unique: true, name: 'index_project_features_on_project_id_unique'
- remove_concurrent_index_by_name :project_features, 'index_project_features_on_project_id'
- rename_index :project_features, 'index_project_features_on_project_id_unique', 'index_project_features_on_project_id'
+ add_concurrent_index :project_features, :project_id, unique: true, name: "index_project_features_on_project_id_unique"
+ remove_concurrent_index_by_name :project_features, "index_project_features_on_project_id"
+ rename_index :project_features, "index_project_features_on_project_id_unique", "index_project_features_on_project_id"
end
def down
- rename_index :project_features, 'index_project_features_on_project_id', 'index_project_features_on_project_id_old'
+ rename_index :project_features, "index_project_features_on_project_id", "index_project_features_on_project_id_old"
add_concurrent_index :project_features, :project_id
- remove_concurrent_index_by_name :project_features, 'index_project_features_on_project_id_old'
+ remove_concurrent_index_by_name :project_features, "index_project_features_on_project_id_old"
end
private
def remove_duplicates
features = ProjectFeature
- .select('MAX(id) AS max, COUNT(id), project_id')
- .group(:project_id)
- .having('COUNT(id) > 1')
+ .select("MAX(id) AS max, COUNT(id), project_id")
+ .group(:project_id)
+ .having("COUNT(id) > 1")
features.each do |feature|
ProjectFeature
- .where(project_id: feature['project_id'])
- .where('id <> ?', feature['max'])
+ .where(project_id: feature["project_id"])
+ .where("id <> ?", feature["max"])
.each_batch { |batch| batch.delete_all }
end
end
diff --git a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb
index e3abbc039e8..c0e31711359 100644
--- a/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb
+++ b/db/post_migrate/20180512061621_add_not_null_constraint_to_project_features_project_id.rb
@@ -6,7 +6,7 @@ class AddNotNullConstraintToProjectFeaturesProjectId < ActiveRecord::Migration[4
class ProjectFeature < ActiveRecord::Base
include EachBatch
- self.table_name = 'project_features'
+ self.table_name = "project_features"
end
def up
diff --git a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb
index 39666a0cd2a..d472f48e9dd 100644
--- a/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb
+++ b/db/post_migrate/20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb
@@ -3,13 +3,13 @@ class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Mig
DOWNTIME = false
BATCH_SIZE = 5_000
- MIGRATION = 'PopulateMergeRequestMetricsWithEventsData'
+ MIGRATION = "PopulateMergeRequestMetricsWithEventsData"
DELAY_INTERVAL = 10.minutes
disable_ddl_transaction!
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
@@ -34,9 +34,9 @@ class MigrateRemainingMrMetricsPopulatingBackgroundMigration < ActiveRecord::Mig
# so this should take ~14 hours for all background migrations to complete.
#
queue_background_migration_jobs_by_range_at_intervals(relation,
- MIGRATION,
- DELAY_INTERVAL,
- batch_size: BATCH_SIZE)
+ MIGRATION,
+ DELAY_INTERVAL,
+ batch_size: BATCH_SIZE)
end
def down
diff --git a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb
index 6246f6afab0..84f6d0ccfd9 100644
--- a/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb
+++ b/db/post_migrate/20180529152628_schedule_to_archive_legacy_traces.rb
@@ -3,21 +3,21 @@ class ScheduleToArchiveLegacyTraces < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 5000
- BACKGROUND_MIGRATION_CLASS = 'ArchiveLegacyTraces'
+ BACKGROUND_MIGRATION_CLASS = "ArchiveLegacyTraces"
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled # Disable STI
- scope :type_build, -> { where(type: 'Ci::Build') }
+ scope :type_build, -> { where(type: "Ci::Build") }
scope :finished, -> { where(status: [:success, :failed, :canceled]) }
scope :without_archived_trace, -> do
- where('NOT EXISTS (SELECT 1 FROM ci_job_artifacts WHERE ci_builds.id = ci_job_artifacts.job_id AND ci_job_artifacts.file_type = 3)')
+ where("NOT EXISTS (SELECT 1 FROM ci_job_artifacts WHERE ci_builds.id = ci_job_artifacts.job_id AND ci_job_artifacts.file_type = 3)")
end
end
@@ -26,7 +26,8 @@ class ScheduleToArchiveLegacyTraces < ActiveRecord::Migration[4.2]
::ScheduleToArchiveLegacyTraces::Build.type_build.finished.without_archived_trace,
BACKGROUND_MIGRATION_CLASS,
5.minutes,
- batch_size: BATCH_SIZE)
+ batch_size: BATCH_SIZE
+ )
end
def down
diff --git a/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb b/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb
index bc7c3eb5385..bf2429f7d8e 100644
--- a/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb
+++ b/db/post_migrate/20180603190921_migrate_object_storage_upload_sidekiq_queue.rb
@@ -6,7 +6,7 @@ class MigrateObjectStorageUploadSidekiqQueue < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- sidekiq_queue_migrate 'object_storage_upload', to: 'object_storage:object_storage_background_move'
+ sidekiq_queue_migrate "object_storage_upload", to: "object_storage:object_storage_background_move"
end
def down
diff --git a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb
index 326cdfa27c3..1d2bdd7666c 100644
--- a/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb
+++ b/db/post_migrate/20180604123514_cleanup_stages_position_migration.rb
@@ -2,21 +2,21 @@ class CleanupStagesPositionMigration < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- TMP_INDEX_NAME = 'tmp_id_stage_position_partial_null_index'.freeze
+ TMP_INDEX_NAME = "tmp_id_stage_position_partial_null_index".freeze
disable_ddl_transaction!
class Stages < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_stages'
+ self.table_name = "ci_stages"
end
def up
disable_statement_timeout do
- Gitlab::BackgroundMigration.steal('MigrateStageIndex')
+ Gitlab::BackgroundMigration.steal("MigrateStageIndex")
unless index_exists_by_name?(:ci_stages, TMP_INDEX_NAME)
- add_concurrent_index(:ci_stages, :id, where: 'position IS NULL', name: TMP_INDEX_NAME)
+ add_concurrent_index(:ci_stages, :id, where: "position IS NULL", name: TMP_INDEX_NAME)
end
migratable = <<~SQL
diff --git a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb
index 73f6a3a2a43..90995afde1b 100644
--- a/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb
+++ b/db/post_migrate/20180619121030_enqueue_delete_diff_files_workers.rb
@@ -2,8 +2,8 @@ class EnqueueDeleteDiffFilesWorkers < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- SCHEDULER = 'ScheduleDiffFilesDeletion'.freeze
- TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze
+ SCHEDULER = "ScheduleDiffFilesDeletion".freeze
+ TMP_INDEX = "tmp_partial_diff_id_with_files_index".freeze
disable_ddl_transaction!
diff --git a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb
index 3d3d49e7564..7f0e16ea658 100644
--- a/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb
+++ b/db/post_migrate/20180702120647_enqueue_fix_cross_project_label_links.rb
@@ -3,21 +3,21 @@ class EnqueueFixCrossProjectLabelLinks < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 100
- MIGRATION = 'FixCrossProjectLabelLinks'
+ MIGRATION = "FixCrossProjectLabelLinks"
DELAY_INTERVAL = 5.minutes
disable_ddl_transaction!
class Label < ActiveRecord::Base
- self.table_name = 'labels'
+ self.table_name = "labels"
end
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
include ::EachBatch
- default_scope { where(type: 'Group', id: Label.where(type: 'GroupLabel').select('distinct group_id')) }
+ default_scope { where(type: "Group", id: Label.where(type: "GroupLabel").select("distinct group_id")) }
end
def up
diff --git a/db/post_migrate/20180704145007_update_project_indexes.rb b/db/post_migrate/20180704145007_update_project_indexes.rb
index 0a82f4535a0..323714c96f5 100644
--- a/db/post_migrate/20180704145007_update_project_indexes.rb
+++ b/db/post_migrate/20180704145007_update_project_indexes.rb
@@ -5,7 +5,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- NEW_INDEX_NAME = 'idx_project_repository_check_partial'
+ NEW_INDEX_NAME = "idx_project_repository_check_partial"
disable_ddl_transaction!
@@ -13,8 +13,7 @@ class UpdateProjectIndexes < ActiveRecord::Migration[4.2]
add_concurrent_index(:projects,
[:repository_storage, :created_at],
name: NEW_INDEX_NAME,
- where: 'last_repository_check_at IS NULL'
- )
+ where: "last_repository_check_at IS NULL")
end
def down
diff --git a/db/post_migrate/20180706223200_populate_site_statistics.rb b/db/post_migrate/20180706223200_populate_site_statistics.rb
index 896965b708f..4bbecf36140 100644
--- a/db/post_migrate/20180706223200_populate_site_statistics.rb
+++ b/db/post_migrate/20180706223200_populate_site_statistics.rb
@@ -7,13 +7,13 @@ class PopulateSiteStatistics < ActiveRecord::Migration[4.2]
def up
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
+ execute("SET LOCAL statement_timeout TO 0") if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
execute("UPDATE site_statistics SET repositories_count = (SELECT COUNT(*) FROM projects)")
end
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
+ execute("SET LOCAL statement_timeout TO 0") if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb
index 440868005bb..20d012c5fac 100644
--- a/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb
+++ b/db/post_migrate/20180723130817_delete_inconsistent_internal_id_records.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
@@ -14,18 +15,18 @@ class DeleteInconsistentInternalIdRecords < ActiveRecord::Migration[4.2]
def up
disable_statement_timeout do
- delete_internal_id_records('issues', 'project_id')
- delete_internal_id_records('merge_requests', 'project_id', 'target_project_id')
- delete_internal_id_records('deployments', 'project_id')
- delete_internal_id_records('milestones', 'project_id')
- delete_internal_id_records('milestones', 'namespace_id', 'group_id')
- delete_internal_id_records('ci_pipelines', 'project_id')
+ delete_internal_id_records("issues", "project_id")
+ delete_internal_id_records("merge_requests", "project_id", "target_project_id")
+ delete_internal_id_records("deployments", "project_id")
+ delete_internal_id_records("milestones", "project_id")
+ delete_internal_id_records("milestones", "namespace_id", "group_id")
+ delete_internal_id_records("ci_pipelines", "project_id")
end
end
class InternalId < ActiveRecord::Base
- self.table_name = 'internal_ids'
- enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 }
+ self.table_name = "internal_ids"
+ enum usage: {issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5}
end
private
diff --git a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
index 363219da539..64491a063c9 100644
--- a/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
+++ b/db/post_migrate/20180809195358_migrate_null_wiki_access_levels.rb
@@ -10,7 +10,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration[4.2]
class ProjectFeature < ActiveRecord::Base
include EachBatch
- self.table_name = 'project_features'
+ self.table_name = "project_features"
end
def up
@@ -20,7 +20,7 @@ class MigrateNullWikiAccessLevels < ActiveRecord::Migration[4.2]
# We need to re-count wikis as previous attempt was not considering the NULLs.
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
+ execute("SET LOCAL statement_timeout TO 0") if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb
index 6b0d1ef0d0c..0e0a26fed17 100644
--- a/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb
+++ b/db/post_migrate/20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb
@@ -2,7 +2,7 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- MIGRATION = 'MigrateLegacyArtifacts'.freeze
+ MIGRATION = "MigrateLegacyArtifacts".freeze
BATCH_SIZE = 100
disable_ddl_transaction!
@@ -10,7 +10,7 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2]
class Build < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled
scope :with_legacy_artifacts, -> { where("artifacts_file <> ''") }
@@ -20,9 +20,9 @@ class MigrateLegacyArtifactsToJobArtifacts < ActiveRecord::Migration[4.2]
MigrateLegacyArtifactsToJobArtifacts::Build
.with_legacy_artifacts.tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
- MIGRATION,
- 5.minutes,
- batch_size: BATCH_SIZE)
+ MIGRATION,
+ 5.minutes,
+ batch_size: BATCH_SIZE)
end
end
diff --git a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb
index 70db8f46d05..dc3c89a36d6 100644
--- a/db/post_migrate/20180816193530_rename_login_root_namespaces.rb
+++ b/db/post_migrate/20180816193530_rename_login_root_namespaces.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class RenameLoginRootNamespaces < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
include Gitlab::Database::RenameReservedPathsMigration::V1
@@ -10,7 +11,7 @@ class RenameLoginRootNamespaces < ActiveRecord::Migration[4.2]
# We're taking over the /login namespace as part of a fix for the Jira integration
def up
disable_statement_timeout do
- rename_root_paths 'login'
+ rename_root_paths "login"
end
end
diff --git a/db/post_migrate/20180826111825_recalculate_site_statistics.rb b/db/post_migrate/20180826111825_recalculate_site_statistics.rb
index 6d27eca38e3..9b2e14edfd5 100644
--- a/db/post_migrate/20180826111825_recalculate_site_statistics.rb
+++ b/db/post_migrate/20180826111825_recalculate_site_statistics.rb
@@ -9,13 +9,13 @@ class RecalculateSiteStatistics < ActiveRecord::Migration[4.2]
def up
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
+ execute("SET LOCAL statement_timeout TO 0") if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
execute("UPDATE site_statistics SET repositories_count = (SELECT COUNT(*) FROM projects)")
end
transaction do
- execute('SET LOCAL statement_timeout TO 0') if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
+ execute("SET LOCAL statement_timeout TO 0") if Gitlab::Database.postgresql? # see https://gitlab.com/gitlab-org/gitlab-ce/issues/48967
execute("UPDATE site_statistics SET wikis_count = (SELECT COUNT(*) FROM project_features WHERE wiki_access_level != 0)")
end
diff --git a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb
index a474aaf534c..a741dcb053a 100644
--- a/db/post_migrate/20180906051323_remove_orphaned_label_links.rb
+++ b/db/post_migrate/20180906051323_remove_orphaned_label_links.rb
@@ -8,11 +8,11 @@ class RemoveOrphanedLabelLinks < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
class LabelLinks < ActiveRecord::Base
- self.table_name = 'label_links'
+ self.table_name = "label_links"
include EachBatch
def self.orphaned
- where('NOT EXISTS ( SELECT 1 FROM labels WHERE labels.id = label_links.label_id )')
+ where("NOT EXISTS ( SELECT 1 FROM labels WHERE labels.id = label_links.label_id )")
end
end
diff --git a/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb b/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb
index 2c266a4695b..b5944f48727 100644
--- a/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb
+++ b/db/post_migrate/20180913051323_consume_remaining_diff_files_deletion_jobs.rb
@@ -7,8 +7,8 @@ class ConsumeRemainingDiffFilesDeletionJobs < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
- MIGRATION = 'ScheduleDiffFilesDeletion'.freeze
- TMP_INDEX = 'tmp_partial_diff_id_with_files_index'.freeze
+ MIGRATION = "ScheduleDiffFilesDeletion"
+ TMP_INDEX = "tmp_partial_diff_id_with_files_index"
def up
# Perform any ongoing background migration that might still be scheduled.
diff --git a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb
index 951cb3b088c..bdab6e6cf06 100644
--- a/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb
+++ b/db/post_migrate/20180913142237_schedule_digest_personal_access_tokens.rb
@@ -4,7 +4,7 @@ class ScheduleDigestPersonalAccessTokens < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 10_000
- MIGRATION = 'DigestColumn'
+ MIGRATION = "DigestColumn"
DELAY_INTERVAL = 5.minutes.to_i
disable_ddl_transaction!
@@ -12,13 +12,13 @@ class ScheduleDigestPersonalAccessTokens < ActiveRecord::Migration[4.2]
class PersonalAccessToken < ActiveRecord::Base
include EachBatch
- self.table_name = 'personal_access_tokens'
+ self.table_name = "personal_access_tokens"
end
def up
- PersonalAccessToken.where('token is NOT NULL').each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
- BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, ['PersonalAccessToken', :token, :token_digest, *range])
+ PersonalAccessToken.where("token is NOT NULL").each_batch(of: BATCH_SIZE) do |batch, index|
+ range = batch.pluck("MIN(id)", "MAX(id)").first
+ BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, ["PersonalAccessToken", :token, :token_digest, *range])
end
end
diff --git a/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb
index ef864f490bb..2752c7286bf 100644
--- a/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb
+++ b/db/post_migrate/20180914162043_encrypt_web_hooks_columns.rb
@@ -7,7 +7,7 @@ class EncryptWebHooksColumns < ActiveRecord::Migration[4.2]
BATCH_SIZE = 10000
RANGE_SIZE = 100
- MIGRATION = 'EncryptColumns'
+ MIGRATION = "EncryptColumns"
COLUMNS = [:token, :url]
WebHook = ::Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook
@@ -19,7 +19,7 @@ class EncryptWebHooksColumns < ActiveRecord::Migration[4.2]
delay = index * 2.minutes
relation.each_batch(of: RANGE_SIZE) do |relation|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
args = [WebHook, COLUMNS, *range]
BackgroundMigrationWorker.perform_in(delay, MIGRATION, args)
diff --git a/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb b/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb
index 2c007ec395d..0532a6742b9 100644
--- a/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb
+++ b/db/post_migrate/20180914201132_remove_sidekiq_throttling_from_application_settings.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.
diff --git a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb
index a3d2df1f2bd..b70da3d4c7b 100644
--- a/db/post_migrate/20180916014356_populate_external_pipeline_source.rb
+++ b/db/post_migrate/20180916014356_populate_external_pipeline_source.rb
@@ -8,22 +8,22 @@ class PopulateExternalPipelineSource < ActiveRecord::Migration[4.2]
# Set this constant to true if this migration requires downtime.
DOWNTIME = false
- MIGRATION = 'PopulateExternalPipelineSource'.freeze
+ MIGRATION = "PopulateExternalPipelineSource"
BATCH_SIZE = 500
disable_ddl_transaction!
class Pipeline < ActiveRecord::Base
include EachBatch
- self.table_name = 'ci_pipelines'
+ self.table_name = "ci_pipelines"
end
def up
Pipeline.where(source: nil).tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
- MIGRATION,
- 5.minutes,
- batch_size: BATCH_SIZE)
+ MIGRATION,
+ 5.minutes,
+ batch_size: BATCH_SIZE)
end
end
diff --git a/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb b/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb
index 3b8300dabeb..61d82fb7798 100644
--- a/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb
+++ b/db/post_migrate/20180917172041_remove_wikis_count_from_site_statistics.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class RemoveWikisCountFromSiteStatistics < ActiveRecord::Migration[4.2]
def change
remove_column :site_statistics, :wikis_count, :integer
diff --git a/db/post_migrate/20181008145341_steal_encrypt_columns.rb b/db/post_migrate/20181008145341_steal_encrypt_columns.rb
index 4102643ba13..5beef84d829 100644
--- a/db/post_migrate/20181008145341_steal_encrypt_columns.rb
+++ b/db/post_migrate/20181008145341_steal_encrypt_columns.rb
@@ -6,7 +6,7 @@ class StealEncryptColumns < ActiveRecord::Migration[4.2]
disable_ddl_transaction!
def up
- Gitlab::BackgroundMigration.steal('EncryptColumns')
+ Gitlab::BackgroundMigration.steal("EncryptColumns")
end
def down
diff --git a/db/post_migrate/20181008200441_remove_circuit_breaker.rb b/db/post_migrate/20181008200441_remove_circuit_breaker.rb
index 378692e8886..88ebf11fac8 100644
--- a/db/post_migrate/20181008200441_remove_circuit_breaker.rb
+++ b/db/post_migrate/20181008200441_remove_circuit_breaker.rb
@@ -13,7 +13,7 @@ class RemoveCircuitBreaker < ActiveRecord::Migration[4.2]
circuitbreaker_failure_reset_time: 1800,
circuitbreaker_storage_timeout: 15,
circuitbreaker_access_retries: 3,
- circuitbreaker_check_interval: 1
+ circuitbreaker_check_interval: 1,
}.freeze
def up
diff --git a/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb b/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb
index 247f5980f7e..c0d609d2cd4 100644
--- a/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb
+++ b/db/post_migrate/20181010133639_backfill_store_project_full_path_in_repo.rb
@@ -6,13 +6,13 @@ class BackfillStoreProjectFullPathInRepo < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 1_000
DELAY_INTERVAL = 5.minutes
- UP_MIGRATION = 'BackfillProjectFullpathInRepoConfig::Up'
- DOWN_MIGRATION = 'BackfillProjectFullpathInRepoConfig::Down'
+ UP_MIGRATION = "BackfillProjectFullpathInRepoConfig::Up"
+ DOWN_MIGRATION = "BackfillProjectFullpathInRepoConfig::Down"
disable_ddl_transaction!
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include EachBatch
end
diff --git a/db/post_migrate/20181014121030_enqueue_redact_links.rb b/db/post_migrate/20181014121030_enqueue_redact_links.rb
index 8d1a840d594..d87229083fd 100644
--- a/db/post_migrate/20181014121030_enqueue_redact_links.rb
+++ b/db/post_migrate/20181014121030_enqueue_redact_links.rb
@@ -6,44 +6,44 @@ class EnqueueRedactLinks < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 1000
DELAY_INTERVAL = 5.minutes.to_i
- MIGRATION = 'RedactLinks'
+ MIGRATION = "RedactLinks"
disable_ddl_transaction!
class Note < ActiveRecord::Base
include EachBatch
- self.table_name = 'notes'
+ self.table_name = "notes"
self.inheritance_column = :_type_disabled
end
class Issue < ActiveRecord::Base
include EachBatch
- self.table_name = 'issues'
+ self.table_name = "issues"
self.inheritance_column = :_type_disabled
end
class MergeRequest < ActiveRecord::Base
include EachBatch
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
self.inheritance_column = :_type_disabled
end
class Snippet < ActiveRecord::Base
include EachBatch
- self.table_name = 'snippets'
+ self.table_name = "snippets"
self.inheritance_column = :_type_disabled
end
def up
disable_statement_timeout do
- schedule_migration(Note, 'note')
- schedule_migration(Issue, 'description')
- schedule_migration(MergeRequest, 'description')
- schedule_migration(Snippet, 'description')
+ schedule_migration(Note, "note")
+ schedule_migration(Issue, "description")
+ schedule_migration(MergeRequest, "description")
+ schedule_migration(Snippet, "description")
end
end
@@ -57,7 +57,7 @@ class EnqueueRedactLinks < ActiveRecord::Migration[4.2]
link_pattern = "%/sent_notifications/" + ("_" * 32) + "/unsubscribe%"
model.where("#{field} like ?", link_pattern).each_batch(of: BATCH_SIZE) do |batch, index|
- start_id, stop_id = batch.pluck('MIN(id)', 'MAX(id)').first
+ start_id, stop_id = batch.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, [model.name.demodulize, field, start_id, stop_id])
end
diff --git a/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb b/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb
index 94a4574abff..e1bb3e47efa 100644
--- a/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb
+++ b/db/post_migrate/20181022173835_enqueue_populate_cluster_kubernetes_namespace.rb
@@ -4,7 +4,7 @@ class EnqueuePopulateClusterKubernetesNamespace < ActiveRecord::Migration[4.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
- MIGRATION = 'PopulateClusterKubernetesNamespaceTable'.freeze
+ MIGRATION = "PopulateClusterKubernetesNamespaceTable"
disable_ddl_transaction!
diff --git a/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb b/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb
index 7c2df832882..1f11dd42407 100644
--- a/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb
+++ b/db/post_migrate/20181026091631_migrate_forbidden_redirect_uris.rb
@@ -5,7 +5,7 @@ class MigrateForbiddenRedirectUris < ActiveRecord::Migration[4.2]
DOWNTIME = false
FORBIDDEN_SCHEMES = %w[data:// vbscript:// javascript://]
- NEW_URI = 'http://forbidden-scheme-has-been-overwritten'
+ NEW_URI = "http://forbidden-scheme-has-been-overwritten"
disable_ddl_transaction!
@@ -22,9 +22,9 @@ class MigrateForbiddenRedirectUris < ActiveRecord::Migration[4.2]
def update_forbidden_uris(table_name)
update_column_in_batches(table_name, :redirect_uri, NEW_URI) do |table, query|
- where_clause = FORBIDDEN_SCHEMES.map do |scheme|
+ where_clause = FORBIDDEN_SCHEMES.map { |scheme|
table[:redirect_uri].matches("#{scheme}%")
- end.inject(&:or)
+ }.inject(&:or)
query.where(where_clause)
end
diff --git a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb
index 228841a14a0..c5a176033de 100644
--- a/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb
+++ b/db/post_migrate/20181030135124_fill_empty_finished_at_in_deployments.rb
@@ -7,17 +7,17 @@ class FillEmptyFinishedAtInDeployments < ActiveRecord::Migration[4.2]
DEPLOYMENT_STATUS_SUCCESS = 2 # Equivalent to Deployment.statuses[:success]
class Deployments < ActiveRecord::Base
- self.table_name = 'deployments'
+ self.table_name = "deployments"
include EachBatch
end
def up
FillEmptyFinishedAtInDeployments::Deployments
- .where('finished_at IS NULL')
- .where('status = ?', DEPLOYMENT_STATUS_SUCCESS)
+ .where("finished_at IS NULL")
+ .where("status = ?", DEPLOYMENT_STATUS_SUCCESS)
.each_batch(of: 10_000) do |relation|
- relation.update_all('finished_at=created_at')
+ relation.update_all("finished_at=created_at")
end
end
diff --git a/db/post_migrate/20181101091005_steal_digest_column.rb b/db/post_migrate/20181101091005_steal_digest_column.rb
index 58ea710c18a..acfadedffc7 100644
--- a/db/post_migrate/20181101091005_steal_digest_column.rb
+++ b/db/post_migrate/20181101091005_steal_digest_column.rb
@@ -8,7 +8,7 @@ class StealDigestColumn < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
def up
- Gitlab::BackgroundMigration.steal('DigestColumn')
+ Gitlab::BackgroundMigration.steal("DigestColumn")
end
def down
diff --git a/db/post_migrate/20181105201455_steal_fill_store_upload.rb b/db/post_migrate/20181105201455_steal_fill_store_upload.rb
index a31a4eab472..b823e8d047d 100644
--- a/db/post_migrate/20181105201455_steal_fill_store_upload.rb
+++ b/db/post_migrate/20181105201455_steal_fill_store_upload.rb
@@ -11,15 +11,15 @@ class StealFillStoreUpload < ActiveRecord::Migration[4.2]
class Upload < ActiveRecord::Base
include EachBatch
- self.table_name = 'uploads'
+ self.table_name = "uploads"
self.inheritance_column = :_type_disabled # Disable STI
end
def up
- Gitlab::BackgroundMigration.steal('FillStoreUpload')
+ Gitlab::BackgroundMigration.steal("FillStoreUpload")
Upload.where(store: nil).each_batch(of: BATCH_SIZE) do |batch|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
Gitlab::BackgroundMigration::FillStoreUpload.new.perform(*range)
end
diff --git a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb
index bbeb4e8a1de..58bba0a8bca 100644
--- a/db/post_migrate/20181107054254_remove_restricted_todos_again.rb
+++ b/db/post_migrate/20181107054254_remove_restricted_todos_again.rb
@@ -7,20 +7,20 @@ class RemoveRestrictedTodosAgain < ActiveRecord::Migration[4.2]
DOWNTIME = false
disable_ddl_transaction!
- MIGRATION = 'RemoveRestrictedTodos'.freeze
+ MIGRATION = "RemoveRestrictedTodos"
BATCH_SIZE = 1000
DELAY_INTERVAL = 5.minutes.to_i
class Project < ActiveRecord::Base
include EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
end
def up
- Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)')
+ Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)")
.each_batch(of: BATCH_SIZE) do |batch, index|
- range = batch.pluck('MIN(id)', 'MAX(id)').first
+ range = batch.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * DELAY_INTERVAL, MIGRATION, range)
end
diff --git a/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb b/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
index ba82072fc98..30f2a7b526c 100644
--- a/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
+++ b/db/post_migrate/20181121111200_schedule_runners_token_encryption.rb
@@ -6,13 +6,13 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 10000
RANGE_SIZE = 2000
- MIGRATION = 'EncryptRunnersTokens'
+ MIGRATION = "EncryptRunnersTokens"
MODELS = [
::Gitlab::BackgroundMigration::Models::EncryptColumns::Settings,
::Gitlab::BackgroundMigration::Models::EncryptColumns::Namespace,
::Gitlab::BackgroundMigration::Models::EncryptColumns::Project,
- ::Gitlab::BackgroundMigration::Models::EncryptColumns::Runner
+ ::Gitlab::BackgroundMigration::Models::EncryptColumns::Runner,
].freeze
disable_ddl_transaction!
@@ -23,7 +23,7 @@ class ScheduleRunnersTokenEncryption < ActiveRecord::Migration[4.2]
delay = index * 4.minutes
relation.each_batch(of: RANGE_SIZE) do |relation|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
args = [model.name.demodulize.downcase, *range]
BackgroundMigrationWorker.perform_in(delay, MIGRATION, args)
diff --git a/db/post_migrate/20181123042307_drop_site_statistics.rb b/db/post_migrate/20181123042307_drop_site_statistics.rb
index 8986374ef65..e200b5a509d 100644
--- a/db/post_migrate/20181123042307_drop_site_statistics.rb
+++ b/db/post_migrate/20181123042307_drop_site_statistics.rb
@@ -17,6 +17,6 @@ class DropSiteStatistics < ActiveRecord::Migration[5.0]
t.integer :repositories_count, default: 0, null: false
end
- execute('INSERT INTO site_statistics (id) VALUES(1)')
+ execute("INSERT INTO site_statistics (id) VALUES(1)")
end
end
diff --git a/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb
index 7814cdba58a..df8a3bb10c7 100644
--- a/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb
+++ b/db/post_migrate/20181130102132_backfill_hashed_project_repositories.rb
@@ -6,14 +6,14 @@ class BackfillHashedProjectRepositories < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 1_000
DELAY_INTERVAL = 5.minutes
- MIGRATION = 'BackfillHashedProjectRepositories'
+ MIGRATION = "BackfillHashedProjectRepositories"
disable_ddl_transaction!
class Project < ActiveRecord::Base
include EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
end
def up
diff --git a/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb b/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb
index 1e43e3dd790..ccffe5d2463 100644
--- a/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb
+++ b/db/post_migrate/20181204154019_populate_mr_metrics_with_events_data.rb
@@ -8,8 +8,8 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2]
DOWNTIME = false
BATCH_SIZE = 10_000
- MIGRATION = 'PopulateMergeRequestMetricsWithEventsDataImproved'
- PREVIOUS_MIGRATION = 'PopulateMergeRequestMetricsWithEventsData'
+ MIGRATION = "PopulateMergeRequestMetricsWithEventsDataImproved"
+ PREVIOUS_MIGRATION = "PopulateMergeRequestMetricsWithEventsData"
disable_ddl_transaction!
@@ -18,7 +18,7 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2]
# previous try (see https://gitlab.com/gitlab-org/gitlab-ce/issues/47676).
Gitlab::BackgroundMigration.steal(PREVIOUS_MIGRATION)
- say 'Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs'
+ say "Scheduling `PopulateMergeRequestMetricsWithEventsData` jobs"
# It will update around 4_000_000 records in batches of 10_000 merge
# requests (running between 5 minutes) and should take around 53 hours to complete.
# Apparently, production PostgreSQL is able to vacuum 10k-20k dead_tuples
@@ -27,7 +27,7 @@ class PopulateMrMetricsWithEventsData < ActiveRecord::Migration[4.2]
# More information about the updates in `PopulateMergeRequestMetricsWithEventsDataImproved` class.
#
MergeRequest.all.each_batch(of: BATCH_SIZE) do |relation, index|
- range = relation.pluck('MIN(id)', 'MAX(id)').first
+ range = relation.pluck("MIN(id)", "MAX(id)").first
BackgroundMigrationWorker.perform_in(index * 8.minutes, MIGRATION, range)
end
diff --git a/db/post_migrate/20181219130552_update_project_import_visibility_level.rb b/db/post_migrate/20181219130552_update_project_import_visibility_level.rb
index 6209de88b31..697df94d413 100644
--- a/db/post_migrate/20181219130552_update_project_import_visibility_level.rb
+++ b/db/post_migrate/20181219130552_update_project_import_visibility_level.rb
@@ -13,7 +13,7 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
end
class Project < ActiveRecord::Base
@@ -21,16 +21,16 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0]
belongs_to :namespace
- IMPORT_TYPE = 'gitlab_project'
+ IMPORT_TYPE = "gitlab_project"
scope :with_group_visibility, ->(visibility) do
joins(:namespace)
- .where(namespaces: { type: 'Group', visibility_level: visibility })
+ .where(namespaces: {type: "Group", visibility_level: visibility})
.where(import_type: IMPORT_TYPE)
- .where('projects.visibility_level > namespaces.visibility_level')
+ .where("projects.visibility_level > namespaces.visibility_level")
end
- self.table_name = 'projects'
+ self.table_name = "projects"
end
def up
@@ -49,7 +49,7 @@ class UpdateProjectImportVisibilityLevel < ActiveRecord::Migration[5.0]
def update_projects_visibility(visibility)
say_with_time("Updating project visibility to #{visibility} on #{Project::IMPORT_TYPE} imports.") do
Project.with_group_visibility(visibility).select(:id).each_batch(of: BATCH_SIZE) do |batch, _index|
- batch_sql = Gitlab::Database.mysql? ? batch.pluck(:id).join(', ') : batch.select(:id).to_sql
+ batch_sql = Gitlab::Database.mysql? ? batch.pluck(:id).join(", ") : batch.select(:id).to_sql
say("Updating #{batch.size} items.", true)
diff --git a/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb b/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb
index c37f8c039c0..fcaa60180e4 100644
--- a/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb
+++ b/db/post_migrate/20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb
@@ -6,10 +6,10 @@ class MigrateClusterConfigureWorkerSidekiqQueue < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
- sidekiq_queue_migrate 'gcp_cluster:cluster_platform_configure', to: 'gcp_cluster:cluster_configure'
+ sidekiq_queue_migrate "gcp_cluster:cluster_platform_configure", to: "gcp_cluster:cluster_configure"
end
def down
- sidekiq_queue_migrate 'gcp_cluster:cluster_configure', to: 'gcp_cluster:cluster_platform_configure'
+ sidekiq_queue_migrate "gcp_cluster:cluster_configure", to: "gcp_cluster:cluster_platform_configure"
end
end
diff --git a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
index ddcddcf72a3..9de64674794 100644
--- a/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
+++ b/db/post_migrate/20190102152410_delete_inconsistent_internal_id_records2.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class DeleteInconsistentInternalIdRecords2 < ActiveRecord::Migration[5.0]
include Gitlab::Database::MigrationHelpers
@@ -14,14 +15,14 @@ class DeleteInconsistentInternalIdRecords2 < ActiveRecord::Migration[5.0]
def up
disable_statement_timeout do
- delete_internal_id_records('milestones', 'project_id')
- delete_internal_id_records('milestones', 'namespace_id', 'group_id')
+ delete_internal_id_records("milestones", "project_id")
+ delete_internal_id_records("milestones", "namespace_id", "group_id")
end
end
class InternalId < ActiveRecord::Base
- self.table_name = 'internal_ids'
- enum usage: { issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5 }
+ self.table_name = "internal_ids"
+ enum usage: {issues: 0, merge_requests: 1, deployments: 2, milestones: 3, epics: 4, ci_pipelines: 5}
end
private
diff --git a/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb b/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb
index 4fcee326b7e..487b91992f7 100644
--- a/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb
+++ b/db/post_migrate/20190115054215_migrate_delete_container_repository_worker.rb
@@ -6,10 +6,10 @@ class MigrateDeleteContainerRepositoryWorker < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
- sidekiq_queue_migrate('delete_container_repository', to: 'container_repository:delete_container_repository')
+ sidekiq_queue_migrate("delete_container_repository", to: "container_repository:delete_container_repository")
end
def down
- sidekiq_queue_migrate('container_repository:delete_container_repository', to: 'delete_container_repository')
+ sidekiq_queue_migrate("container_repository:delete_container_repository", to: "delete_container_repository")
end
end
diff --git a/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb b/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb
index 193bd571831..72c7f06236c 100644
--- a/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb
+++ b/db/post_migrate/20190124200344_migrate_storage_migrator_sidekiq_queue.rb
@@ -9,10 +9,10 @@ class MigrateStorageMigratorSidekiqQueue < ActiveRecord::Migration[5.0]
DOWNTIME = false
def up
- sidekiq_queue_migrate 'storage_migrator', to: 'hashed_storage:hashed_storage_migrator'
+ sidekiq_queue_migrate "storage_migrator", to: "hashed_storage:hashed_storage_migrator"
end
def down
- sidekiq_queue_migrate 'hashed_storage:hashed_storage_migrator', to: 'storage_migrator'
+ sidekiq_queue_migrate "hashed_storage:hashed_storage_migrator", to: "storage_migrator"
end
end
diff --git a/db/post_migrate/20190131122559_fix_null_type_labels.rb b/db/post_migrate/20190131122559_fix_null_type_labels.rb
index 83bb613990c..c23b5e8b41b 100644
--- a/db/post_migrate/20190131122559_fix_null_type_labels.rb
+++ b/db/post_migrate/20190131122559_fix_null_type_labels.rb
@@ -8,7 +8,7 @@ class FixNullTypeLabels < ActiveRecord::Migration[5.0]
disable_ddl_transaction!
def up
- update_column_in_batches(:labels, :type, 'ProjectLabel') do |table, query|
+ update_column_in_batches(:labels, :type, "ProjectLabel") do |table, query|
query.where(
table[:project_id].not_eq(nil)
.and(table[:template].eq(false))
diff --git a/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb b/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb
index 392e64eeade..78f8d3ea2b5 100644
--- a/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb
+++ b/db/post_migrate/20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb
@@ -25,25 +25,25 @@ class MigrateAutoDevOpsDomainToClusterDomain < ActiveRecord::Migration[5.0]
def mysql_query
<<~HEREDOC
- UPDATE clusters, project_auto_devops, cluster_projects
- SET
- clusters.domain = project_auto_devops.domain
- WHERE
- cluster_projects.cluster_id = clusters.id
- AND project_auto_devops.project_id = cluster_projects.project_id
- AND project_auto_devops.domain != ''
+ UPDATE clusters, project_auto_devops, cluster_projects
+ SET
+ clusters.domain = project_auto_devops.domain
+ WHERE
+ cluster_projects.cluster_id = clusters.id
+ AND project_auto_devops.project_id = cluster_projects.project_id
+ AND project_auto_devops.domain != ''
HEREDOC
end
def postgresql_query
<<~HEREDOC
- UPDATE clusters
- SET domain = project_auto_devops.domain
- FROM cluster_projects, project_auto_devops
- WHERE
- cluster_projects.cluster_id = clusters.id
- AND project_auto_devops.project_id = cluster_projects.project_id
- AND project_auto_devops.domain != ''
+ UPDATE clusters
+ SET domain = project_auto_devops.domain
+ FROM cluster_projects, project_auto_devops
+ WHERE
+ cluster_projects.cluster_id = clusters.id
+ AND project_auto_devops.project_id = cluster_projects.project_id
+ AND project_auto_devops.domain != ''
HEREDOC
end
end
diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb
index 6fb7985f955..169adfd47ea 100644
--- a/lib/after_commit_queue.rb
+++ b/lib/after_commit_queue.rb
@@ -48,7 +48,7 @@ module AfterCommitQueue
def _run_after_commit_queue
while action = _after_commit_queue.pop
- self.instance_eval(&action)
+ instance_eval(&action)
end
end
diff --git a/lib/api/access_requests.rb b/lib/api/access_requests.rb
index ee8dc822098..b0c12ad7d56 100644
--- a/lib/api/access_requests.rb
+++ b/lib/api/access_requests.rb
@@ -14,7 +14,7 @@ module API
end
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Gets a list of access requests for a #{source_type}." do
- detail 'This feature was introduced in GitLab 8.11.'
+ detail "This feature was introduced in GitLab 8.11."
success Entities::AccessRequester
end
params do
@@ -32,7 +32,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
desc "Requests access for the authenticated user to a #{source_type}." do
- detail 'This feature was introduced in GitLab 8.11.'
+ detail "This feature was introduced in GitLab 8.11."
success Entities::AccessRequester
end
post ":id/access_requests" do
@@ -46,16 +46,16 @@ module API
end
end
- desc 'Approves an access request for the given user.' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Approves an access request for the given user." do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Member
end
params do
- requires :user_id, type: Integer, desc: 'The user ID of the access requester'
- optional :access_level, type: Integer, desc: 'A valid access level (defaults: `30`, developer access level)'
+ requires :user_id, type: Integer, desc: "The user ID of the access requester"
+ optional :access_level, type: Integer, desc: "A valid access level (defaults: `30`, developer access level)"
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/access_requests/:user_id/approve' do
+ put ":id/access_requests/:user_id/approve" do
source = find_source(source_type, params[:id])
access_requester = source.requesters.find_by!(user_id: params[:user_id])
@@ -68,11 +68,11 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Denies an access request for the given user.' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Denies an access request for the given user." do
+ detail "This feature was introduced in GitLab 8.11."
end
params do
- requires :user_id, type: Integer, desc: 'The user ID of the access requester'
+ requires :user_id, type: Integer, desc: "The user ID of the access requester"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/access_requests/:user_id" do
diff --git a/lib/api/api.rb b/lib/api/api.rb
index bf8ddba6f0d..3b89a541ca5 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -7,61 +7,61 @@ module API
LOG_FILENAME = Rails.root.join("log", "api_json.log")
NO_SLASH_URL_PART_REGEX = %r{[^/]+}
- NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
+ NAMESPACE_OR_PROJECT_REQUIREMENTS = {id: NO_SLASH_URL_PART_REGEX}.freeze
COMMIT_ENDPOINT_REQUIREMENTS = NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(sha: NO_SLASH_URL_PART_REGEX).freeze
- USER_REQUIREMENTS = { user_id: NO_SLASH_URL_PART_REGEX }.freeze
+ USER_REQUIREMENTS = {user_id: NO_SLASH_URL_PART_REGEX}.freeze
insert_before Grape::Middleware::Error,
- GrapeLogging::Middleware::RequestLogger,
- logger: Logger.new(LOG_FILENAME),
- formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new,
- include: [
- GrapeLogging::Loggers::FilterParameters.new,
- GrapeLogging::Loggers::ClientEnv.new,
- Gitlab::GrapeLogging::Loggers::RouteLogger.new,
- Gitlab::GrapeLogging::Loggers::UserLogger.new,
- Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new,
- Gitlab::GrapeLogging::Loggers::PerfLogger.new,
- Gitlab::GrapeLogging::Loggers::CorrelationIdLogger.new
- ]
+ GrapeLogging::Middleware::RequestLogger,
+ logger: Logger.new(LOG_FILENAME),
+ formatter: Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp.new,
+ include: [
+ GrapeLogging::Loggers::FilterParameters.new,
+ GrapeLogging::Loggers::ClientEnv.new,
+ Gitlab::GrapeLogging::Loggers::RouteLogger.new,
+ Gitlab::GrapeLogging::Loggers::UserLogger.new,
+ Gitlab::GrapeLogging::Loggers::QueueDurationLogger.new,
+ Gitlab::GrapeLogging::Loggers::PerfLogger.new,
+ Gitlab::GrapeLogging::Loggers::CorrelationIdLogger.new,
+ ]
allow_access_with_scope :api
prefix :api
- version 'v3', using: :path do
- route :any, '*path' do
- error!('API V3 is no longer supported. Use API V4 instead.', 410)
+ version "v3", using: :path do
+ route :any, "*path" do
+ error!("API V3 is no longer supported. Use API V4 instead.", 410)
end
end
- version 'v4', using: :path
+ version "v4", using: :path
before do
- header['X-Frame-Options'] = 'SAMEORIGIN'
- header['X-Content-Type-Options'] = 'nosniff'
+ header["X-Frame-Options"] = "SAMEORIGIN"
+ header["X-Content-Type-Options"] = "nosniff"
end
# The locale is set to the current user's locale when `current_user` is loaded
after { Gitlab::I18n.use_default_locale }
rescue_from Gitlab::Access::AccessDeniedError do
- rack_response({ 'message' => '403 Forbidden' }.to_json, 403)
+ rack_response({"message" => "403 Forbidden"}.to_json, 403)
end
rescue_from ActiveRecord::RecordNotFound do
- rack_response({ 'message' => '404 Not found' }.to_json, 404)
+ rack_response({"message" => "404 Not found"}.to_json, 404)
end
rescue_from ::Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError do
- rack_response({ 'message' => '409 Conflict: Resource lock' }.to_json, 409)
+ rack_response({"message" => "409 Conflict: Resource lock"}.to_json, 409)
end
rescue_from UploadedFile::InvalidPathError do |e|
- rack_response({ 'message' => e.message }.to_json, 400)
+ rack_response({"message" => e.message}.to_json, 400)
end
rescue_from ObjectStorage::RemoteStoreError do |e|
- rack_response({ 'message' => e.message }.to_json, 500)
+ rack_response({"message" => e.message}.to_json, 500)
end
# Retain 405 error rather than a 500 error for Grape 0.15.0+.
@@ -75,7 +75,7 @@ module API
end
rescue_from Gitlab::Auth::TooManyIps do |e|
- rack_response({ 'message' => '403 Forbidden' }.to_json, 403)
+ rack_response({"message" => "403 Forbidden"}.to_json, 403)
end
rescue_from :all do |exception|
@@ -168,8 +168,8 @@ module API
mount ::API::Version
mount ::API::Wikis
- route :any, '*path' do
- error!('404 Not Found', 404)
+ route :any, "*path" do
+ error!("404 Not Found", 404)
end
end
end
diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb
index af9b519ed9e..2deb50e287b 100644
--- a/lib/api/api_guard.rb
+++ b/lib/api/api_guard.rb
@@ -2,7 +2,7 @@
# Guard API with OAuth 2.0 Access Token
-require 'rack/oauth2'
+require "rack/oauth2"
module API
module APIGuard
@@ -10,7 +10,7 @@ module API
included do |base|
# OAuth2 Resource Server Authentication
- use Rack::OAuth2::Server::Resource::Bearer, 'The API' do |request|
+ use Rack::OAuth2::Server::Resource::Bearer, "The API" do |request|
# The authenticator only fetches the raw token string
# Must yield access token to store it in the env
@@ -95,7 +95,7 @@ module API
Gitlab::Auth::ExpiredError,
Gitlab::Auth::RevokedError,
Gitlab::Auth::ImpersonationDisabled,
- Gitlab::Auth::InsufficientScopeError]
+ Gitlab::Auth::InsufficientScopeError,]
base.__send__(:rescue_from, *error_classes, oauth2_bearer_token_error_handler) # rubocop:disable GitlabSecurity/PublicSend
end
@@ -110,22 +110,26 @@ module API
when Gitlab::Auth::TokenNotFoundError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Bad Access Token.")
+ "Bad Access Token."
+ )
when Gitlab::Auth::ExpiredError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token is expired. You can either do re-authorization or token refresh.")
+ "Token is expired. You can either do re-authorization or token refresh."
+ )
when Gitlab::Auth::RevokedError
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token was revoked. You have to re-authorize from the user.")
+ "Token was revoked. You have to re-authorize from the user."
+ )
when Gitlab::Auth::ImpersonationDisabled
Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new(
:invalid_token,
- "Token is an impersonation token but impersonation was disabled.")
+ "Token is an impersonation token but impersonation was disabled."
+ )
when Gitlab::Auth::InsufficientScopeError
# FIXME: ForbiddenError (inherited from Bearer::Forbidden of Rack::Oauth2)
@@ -133,7 +137,8 @@ module API
Rack::OAuth2::Server::Resource::Bearer::Forbidden.new(
:insufficient_scope,
Rack::OAuth2::Server::Resource::ErrorMethods::DEFAULT_DESCRIPTION[:insufficient_scope],
- { scope: e.scopes })
+ {scope: e.scopes}
+ )
end
response.finish
diff --git a/lib/api/applications.rb b/lib/api/applications.rb
index 92717e04543..7d150196a6c 100644
--- a/lib/api/applications.rb
+++ b/lib/api/applications.rb
@@ -6,14 +6,14 @@ module API
before { authenticated_as_admin! }
resource :applications do
- desc 'Create a new application' do
- detail 'This feature was introduced in GitLab 10.5'
+ desc "Create a new application" do
+ detail "This feature was introduced in GitLab 10.5"
success Entities::ApplicationWithSecret
end
params do
- requires :name, type: String, desc: 'Application name'
- requires :redirect_uri, type: String, desc: 'Application redirect URI'
- requires :scopes, type: String, desc: 'Application scopes'
+ requires :name, type: String, desc: "Application name"
+ requires :redirect_uri, type: String, desc: "Application redirect URI"
+ requires :scopes, type: String, desc: "Application scopes"
end
post do
application = Doorkeeper::Application.new(declared_params)
@@ -25,7 +25,7 @@ module API
end
end
- desc 'Get applications' do
+ desc "Get applications" do
success Entities::Application
end
get do
@@ -33,8 +33,8 @@ module API
present applications, with: Entities::Application
end
- desc 'Delete an application'
- delete ':id' do
+ desc "Delete an application"
+ delete ":id" do
application = ApplicationsFinder.new(params).execute
application.destroy
diff --git a/lib/api/avatar.rb b/lib/api/avatar.rb
index 0f14d003065..d05481c7a4f 100644
--- a/lib/api/avatar.rb
+++ b/lib/api/avatar.rb
@@ -3,15 +3,15 @@
module API
class Avatar < Grape::API
resource :avatar do
- desc 'Return avatar url for a user' do
+ desc "Return avatar url for a user" do
success Entities::Avatar
end
params do
- requires :email, type: String, desc: 'Public email address of the user'
- optional :size, type: Integer, desc: 'Single pixel dimension for Gravatar images'
+ requires :email, type: String, desc: "Public email address of the user"
+ optional :size, type: Integer, desc: "Single pixel dimension for Gravatar images"
end
get do
- forbidden!('Unauthorized access') unless can?(current_user, :read_users_list)
+ forbidden!("Unauthorized access") unless can?(current_user, :read_users_list)
user = User.find_by_public_email(params[:email])
user ||= User.new(email: params[:email])
diff --git a/lib/api/award_emoji.rb b/lib/api/award_emoji.rb
index a1851ba3627..a47948b1a29 100644
--- a/lib/api/award_emoji.rb
+++ b/lib/api/award_emoji.rb
@@ -6,13 +6,13 @@ module API
before { authenticate! }
AWARDABLES = [
- { type: 'issue', find_by: :iid },
- { type: 'merge_request', find_by: :iid },
- { type: 'snippet', find_by: :id }
+ {type: "issue", find_by: :iid},
+ {type: "merge_request", find_by: :iid},
+ {type: "snippet", find_by: :id},
].freeze
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
AWARDABLES.each do |awardable_params|
@@ -25,11 +25,11 @@ module API
[
":id/#{awardable_string}/:#{awardable_id_string}/award_emoji",
- ":id/#{awardable_string}/:#{awardable_id_string}/notes/:note_id/award_emoji"
+ ":id/#{awardable_string}/:#{awardable_id_string}/notes/:note_id/award_emoji",
].each do |endpoint|
- desc 'Get a list of project +awardable+ award emoji' do
- detail 'This feature was introduced in 8.9'
+ desc "Get a list of project +awardable+ award emoji" do
+ detail "This feature was introduced in 8.9"
success Entities::AwardEmoji
end
params do
@@ -44,12 +44,12 @@ module API
end
end
- desc 'Get a specific award emoji' do
- detail 'This feature was introduced in 8.9'
+ desc "Get a specific award emoji" do
+ detail "This feature was introduced in 8.9"
success Entities::AwardEmoji
end
params do
- requires :award_id, type: Integer, desc: 'The ID of the award'
+ requires :award_id, type: Integer, desc: "The ID of the award"
end
get "#{endpoint}/:award_id" do
if can_read_awardable?
@@ -59,15 +59,15 @@ module API
end
end
- desc 'Award a new Emoji' do
- detail 'This feature was introduced in 8.9'
+ desc "Award a new Emoji" do
+ detail "This feature was introduced in 8.9"
success Entities::AwardEmoji
end
params do
- requires :name, type: String, desc: 'The name of a award_emoji (without colons)'
+ requires :name, type: String, desc: "The name of a award_emoji (without colons)"
end
post endpoint do
- not_found!('Award Emoji') unless can_read_awardable? && can_award_awardable?
+ not_found!("Award Emoji") unless can_read_awardable? && can_award_awardable?
award = awardable.create_award_emoji(params[:name], current_user)
@@ -78,12 +78,12 @@ module API
end
end
- desc 'Delete a +awardables+ award emoji' do
- detail 'This feature was introduced in 8.9'
+ desc "Delete a +awardables+ award emoji" do
+ detail "This feature was introduced in 8.9"
success Entities::AwardEmoji
end
params do
- requires :award_id, type: Integer, desc: 'The ID of an award emoji'
+ requires :award_id, type: Integer, desc: "The ID of an award emoji"
end
delete "#{endpoint}/:award_id" do
award = awardable.award_emoji.find(params[:award_id])
diff --git a/lib/api/badges.rb b/lib/api/badges.rb
index ba554e00a16..b512e2fa1da 100644
--- a/lib/api/badges.rb
+++ b/lib/api/badges.rb
@@ -24,7 +24,7 @@ module API
end
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Gets a list of #{source_type} badges viewable by the authenticated user." do
- detail 'This feature was introduced in GitLab 10.6.'
+ detail "This feature was introduced in GitLab 10.6."
success Entities::Badge
end
params do
@@ -37,12 +37,12 @@ module API
end
desc "Preview a badge from a #{source_type}." do
- detail 'This feature was introduced in GitLab 10.6.'
+ detail "This feature was introduced in GitLab 10.6."
success Entities::BasicBadgeDetails
end
params do
- requires :link_url, type: String, desc: 'URL of the badge link'
- requires :image_url, type: String, desc: 'URL of the badge image'
+ requires :link_url, type: String, desc: "URL of the badge link"
+ requires :image_url, type: String, desc: "URL of the badge image"
end
get ":id/badges/render" do
authenticate!
@@ -50,7 +50,7 @@ module API
source = find_source_if_admin(source_type)
badge = ::Badges::BuildService.new(declared_params(include_missing: false))
- .execute(source)
+ .execute(source)
if badge.valid?
present_badges(source, badge, with: Entities::BasicBadgeDetails)
@@ -60,11 +60,11 @@ module API
end
desc "Gets a badge of a #{source_type}." do
- detail 'This feature was introduced in GitLab 10.6.'
+ detail "This feature was introduced in GitLab 10.6."
success Entities::Badge
end
params do
- requires :badge_id, type: Integer, desc: 'The badge ID'
+ requires :badge_id, type: Integer, desc: "The badge ID"
end
get ":id/badges/:badge_id" do
source = find_source(source_type, params[:id])
@@ -74,12 +74,12 @@ module API
end
desc "Adds a badge to a #{source_type}." do
- detail 'This feature was introduced in GitLab 10.6.'
+ detail "This feature was introduced in GitLab 10.6."
success Entities::Badge
end
params do
- requires :link_url, type: String, desc: 'URL of the badge link'
- requires :image_url, type: String, desc: 'URL of the badge image'
+ requires :link_url, type: String, desc: "URL of the badge link"
+ requires :image_url, type: String, desc: "URL of the badge image"
end
post ":id/badges" do
source = find_source_if_admin(source_type)
@@ -94,18 +94,18 @@ module API
end
desc "Updates a badge of a #{source_type}." do
- detail 'This feature was introduced in GitLab 10.6.'
+ detail "This feature was introduced in GitLab 10.6."
success Entities::Badge
end
params do
- optional :link_url, type: String, desc: 'URL of the badge link'
- optional :image_url, type: String, desc: 'URL of the badge image'
+ optional :link_url, type: String, desc: "URL of the badge link"
+ optional :image_url, type: String, desc: "URL of the badge image"
end
put ":id/badges/:badge_id" do
source = find_source_if_admin(source_type)
badge = ::Badges::UpdateService.new(declared_params(include_missing: false))
- .execute(find_badge(source))
+ .execute(find_badge(source))
if badge.valid?
present_badges(source, badge)
@@ -114,18 +114,18 @@ module API
end
end
- desc 'Removes a badge from a project or group.' do
- detail 'This feature was introduced in GitLab 10.6.'
+ desc "Removes a badge from a project or group." do
+ detail "This feature was introduced in GitLab 10.6."
end
params do
- requires :badge_id, type: Integer, desc: 'The badge ID'
+ requires :badge_id, type: Integer, desc: "The badge ID"
end
delete ":id/badges/:badge_id" do
source = find_source_if_admin(source_type)
badge = find_badge(source)
if badge.is_a?(GroupBadge) && source.is_a?(Project)
- error!('To delete a Group badge please use the Group endpoint', 403)
+ error!("To delete a Group badge please use the Group endpoint", 403)
end
destroy_conditionally!(badge)
diff --git a/lib/api/boards.rb b/lib/api/boards.rb
index b7c77730afb..ee7c2123e13 100644
--- a/lib/api/boards.rb
+++ b/lib/api/boards.rb
@@ -14,68 +14,68 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- segment ':id/boards' do
- desc 'Get all project boards' do
- detail 'This feature was introduced in 8.13'
+ segment ":id/boards" do
+ desc "Get all project boards" do
+ detail "This feature was introduced in 8.13"
success Entities::Board
end
params do
use :pagination
end
- get '/' do
+ get "/" do
authorize!(:read_board, user_project)
present paginate(board_parent.boards), with: Entities::Board
end
- desc 'Find a project board' do
- detail 'This feature was introduced in 10.4'
+ desc "Find a project board" do
+ detail "This feature was introduced in 10.4"
success Entities::Board
end
- get '/:board_id' do
+ get "/:board_id" do
authorize!(:read_board, user_project)
present board, with: Entities::Board
end
end
params do
- requires :board_id, type: Integer, desc: 'The ID of a board'
+ requires :board_id, type: Integer, desc: "The ID of a board"
end
- segment ':id/boards/:board_id' do
- desc 'Get the lists of a project board' do
- detail 'Does not include `done` list. This feature was introduced in 8.13'
+ segment ":id/boards/:board_id" do
+ desc "Get the lists of a project board" do
+ detail "Does not include `done` list. This feature was introduced in 8.13"
success Entities::List
end
params do
use :pagination
end
- get '/lists' do
+ get "/lists" do
authorize!(:read_board, user_project)
present paginate(board_lists), with: Entities::List
end
- desc 'Get a list of a project board' do
- detail 'This feature was introduced in 8.13'
+ desc "Get a list of a project board" do
+ detail "This feature was introduced in 8.13"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a list'
+ requires :list_id, type: Integer, desc: "The ID of a list"
end
- get '/lists/:list_id' do
+ get "/lists/:list_id" do
authorize!(:read_board, user_project)
present board_lists.find(params[:list_id]), with: Entities::List
end
- desc 'Create a new board list' do
- detail 'This feature was introduced in 8.13'
+ desc "Create a new board list" do
+ detail "This feature was introduced in 8.13"
success Entities::List
end
params do
use :list_creation_params
end
- post '/lists' do
+ post "/lists" do
authorize_list_type_resource!
authorize!(:admin_list, user_project)
@@ -83,15 +83,15 @@ module API
create_list
end
- desc 'Moves a board list to a new position' do
- detail 'This feature was introduced in 8.13'
+ desc "Moves a board list to a new position" do
+ detail "This feature was introduced in 8.13"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a list'
- requires :position, type: Integer, desc: 'The position of the list'
+ requires :list_id, type: Integer, desc: "The ID of a list"
+ requires :position, type: Integer, desc: "The position of the list"
end
- put '/lists/:list_id' do
+ put "/lists/:list_id" do
list = board_lists.find(params[:list_id])
authorize!(:admin_list, user_project)
@@ -99,12 +99,12 @@ module API
move_list(list)
end
- desc 'Delete a board list' do
- detail 'This feature was introduced in 8.13'
+ desc "Delete a board list" do
+ detail "This feature was introduced in 8.13"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a board list'
+ requires :list_id, type: Integer, desc: "The ID of a board list"
end
delete "/lists/:list_id" do
authorize!(:admin_list, user_project)
diff --git a/lib/api/boards_responses.rb b/lib/api/boards_responses.rb
index 86d9b24802f..0c0643ad9e1 100644
--- a/lib/api/boards_responses.rb
+++ b/lib/api/boards_responses.rb
@@ -33,12 +33,12 @@ module API
def move_list(list)
move_list_service =
- ::Boards::Lists::MoveService.new(board_parent, current_user, { position: params[:position].to_i })
+ ::Boards::Lists::MoveService.new(board_parent, current_user, {position: params[:position].to_i})
if move_list_service.execute(list)
present list, with: Entities::List
else
- render_api_error!({ error: "List could not be moved!" }, 400)
+ render_api_error!({error: "List could not be moved!"}, 400)
end
end
@@ -46,7 +46,7 @@ module API
destroy_conditionally!(list) do |list|
service = ::Boards::Lists::DestroyService.new(board_parent, current_user)
unless service.execute(list)
- render_api_error!({ error: 'List could not be deleted!' }, 400)
+ render_api_error!({error: "List could not be deleted!"}, 400)
end
end
end
@@ -54,13 +54,13 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def authorize_list_type_resource!
unless available_labels_for(board_parent).exists?(params[:label_id])
- render_api_error!({ error: 'Label not found!' }, 400)
+ render_api_error!({error: "Label not found!"}, 400)
end
end
# rubocop: enable CodeReuse/ActiveRecord
params :list_creation_params do
- requires :label_id, type: Integer, desc: 'The ID of an existing label'
+ requires :label_id, type: Integer, desc: "The ID of an existing label"
end
end
end
diff --git a/lib/api/branches.rb b/lib/api/branches.rb
index 07f529b01bb..f0be2a78ab6 100644
--- a/lib/api/branches.rb
+++ b/lib/api/branches.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'mime/types'
+require "mime/types"
module API
class Branches < Grape::API
@@ -12,24 +12,24 @@ module API
helpers do
params :filter_params do
- optional :search, type: String, desc: 'Return list of branches matching the search criteria'
- optional :sort, type: String, desc: 'Return list of branches sorted by the given field'
+ optional :search, type: String, desc: "Return list of branches matching the search criteria"
+ optional :sort, type: String, desc: "Return list of branches sorted by the given field"
end
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a project repository branches' do
+ desc "Get a project repository branches" do
success Entities::Branch
end
params do
use :pagination
use :filter_params
end
- get ':id/repository/branches' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42329')
+ get ":id/repository/branches" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42329")
repository = user_project.repository
@@ -46,12 +46,12 @@ module API
)
end
- resource ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
- desc 'Get a single branch' do
+ resource ":id/repository/branches/:branch", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ desc "Get a single branch" do
success Entities::Branch
end
params do
- requires :branch, type: String, desc: 'The name of the branch'
+ requires :branch, type: String, desc: "The name of the branch"
end
head do
user_project.repository.branch_exists?(params[:branch]) ? status(204) : status(404)
@@ -67,16 +67,16 @@ module API
# Note: The internal data model moved from `developers_can_{merge,push}` to `allowed_to_{merge,push}`
# in `gitlab-org/gitlab-ce!5081`. The API interface has not been changed (to maintain compatibility),
# but it works with the changed data model to infer `developers_can_merge` and `developers_can_push`.
- desc 'Protect a single branch' do
+ desc "Protect a single branch" do
success Entities::Branch
end
params do
- requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
- optional :developers_can_push, type: Boolean, desc: 'Flag if developers can push to that branch'
- optional :developers_can_merge, type: Boolean, desc: 'Flag if developers can merge to that branch'
+ requires :branch, type: String, desc: "The name of the branch", allow_blank: false
+ optional :developers_can_push, type: Boolean, desc: "Flag if developers can push to that branch"
+ optional :developers_can_merge, type: Boolean, desc: "Flag if developers can merge to that branch"
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/repository/branches/:branch/protect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ put ":id/repository/branches/:branch/protect", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_admin_project
branch = find_branch!(params[:branch])
@@ -86,16 +86,16 @@ module API
protected_branch_params = {
name: branch.name,
developers_can_push: params[:developers_can_push],
- developers_can_merge: params[:developers_can_merge]
+ developers_can_merge: params[:developers_can_merge],
}
service_args = [user_project, current_user, protected_branch_params]
protected_branch = if protected_branch
- ::ProtectedBranches::LegacyApiUpdateService.new(*service_args).execute(protected_branch)
- else
- ::ProtectedBranches::LegacyApiCreateService.new(*service_args).execute
- end
+ ::ProtectedBranches::LegacyApiUpdateService.new(*service_args).execute(protected_branch)
+ else
+ ::ProtectedBranches::LegacyApiCreateService.new(*service_args).execute
+ end
if protected_branch.valid?
present branch, with: Entities::Branch, current_user: current_user, project: user_project
@@ -106,14 +106,14 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
# Note: This API will be deprecated in favor of the protected branches API.
- desc 'Unprotect a single branch' do
+ desc "Unprotect a single branch" do
success Entities::Branch
end
params do
- requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
+ requires :branch, type: String, desc: "The name of the branch", allow_blank: false
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/repository/branches/:branch/unprotect', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ put ":id/repository/branches/:branch/unprotect", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_admin_project
branch = find_branch!(params[:branch])
@@ -124,34 +124,34 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Create branch' do
+ desc "Create branch" do
success Entities::Branch
end
params do
- requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
- requires :ref, type: String, desc: 'Create branch from commit sha or existing branch', allow_blank: false
+ requires :branch, type: String, desc: "The name of the branch", allow_blank: false
+ requires :ref, type: String, desc: "Create branch from commit sha or existing branch", allow_blank: false
end
- post ':id/repository/branches' do
+ post ":id/repository/branches" do
authorize_push_project
result = CreateBranchService.new(user_project, current_user)
- .execute(params[:branch], params[:ref])
+ .execute(params[:branch], params[:ref])
if result[:status] == :success
present result[:branch],
- with: Entities::Branch,
- current_user: current_user,
- project: user_project
+ with: Entities::Branch,
+ current_user: current_user,
+ project: user_project
else
render_api_error!(result[:message], 400)
end
end
- desc 'Delete a branch'
+ desc "Delete a branch"
params do
- requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
+ requires :branch, type: String, desc: "The name of the branch", allow_blank: false
end
- delete ':id/repository/branches/:branch', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ delete ":id/repository/branches/:branch", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
authorize_push_project
branch = find_branch!(params[:branch])
@@ -160,7 +160,7 @@ module API
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = DeleteBranchService.new(user_project, current_user)
- .execute(params[:branch])
+ .execute(params[:branch])
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
@@ -168,8 +168,8 @@ module API
end
end
- desc 'Delete all merged branches'
- delete ':id/repository/merged_branches' do
+ desc "Delete all merged branches"
+ delete ":id/repository/merged_branches" do
DeleteMergedBranchesService.new(user_project, current_user).async_execute
accepted!
diff --git a/lib/api/broadcast_messages.rb b/lib/api/broadcast_messages.rb
index 19148758fc5..2855e2e5fac 100644
--- a/lib/api/broadcast_messages.rb
+++ b/lib/api/broadcast_messages.rb
@@ -14,8 +14,8 @@ module API
end
end
- desc 'Get all broadcast messages' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Get all broadcast messages" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::BroadcastMessage
end
params do
@@ -27,16 +27,16 @@ module API
present paginate(messages), with: Entities::BroadcastMessage
end
- desc 'Create a broadcast message' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Create a broadcast message" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::BroadcastMessage
end
params do
- requires :message, type: String, desc: 'Message to display'
- optional :starts_at, type: DateTime, desc: 'Starting time', default: -> { Time.zone.now }
- optional :ends_at, type: DateTime, desc: 'Ending time', default: -> { 1.hour.from_now }
- optional :color, type: String, desc: 'Background color'
- optional :font, type: String, desc: 'Foreground color'
+ requires :message, type: String, desc: "Message to display"
+ optional :starts_at, type: DateTime, desc: "Starting time", default: -> { Time.zone.now }
+ optional :ends_at, type: DateTime, desc: "Ending time", default: -> { 1.hour.from_now }
+ optional :color, type: String, desc: "Background color"
+ optional :font, type: String, desc: "Foreground color"
end
post do
message = BroadcastMessage.create(declared_params(include_missing: false))
@@ -48,32 +48,32 @@ module API
end
end
- desc 'Get a specific broadcast message' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Get a specific broadcast message" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::BroadcastMessage
end
params do
- requires :id, type: Integer, desc: 'Broadcast message ID'
+ requires :id, type: Integer, desc: "Broadcast message ID"
end
- get ':id' do
+ get ":id" do
message = find_message
present message, with: Entities::BroadcastMessage
end
- desc 'Update a broadcast message' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Update a broadcast message" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::BroadcastMessage
end
params do
- requires :id, type: Integer, desc: 'Broadcast message ID'
- optional :message, type: String, desc: 'Message to display'
- optional :starts_at, type: DateTime, desc: 'Starting time'
- optional :ends_at, type: DateTime, desc: 'Ending time'
- optional :color, type: String, desc: 'Background color'
- optional :font, type: String, desc: 'Foreground color'
- end
- put ':id' do
+ requires :id, type: Integer, desc: "Broadcast message ID"
+ optional :message, type: String, desc: "Message to display"
+ optional :starts_at, type: DateTime, desc: "Starting time"
+ optional :ends_at, type: DateTime, desc: "Ending time"
+ optional :color, type: String, desc: "Background color"
+ optional :font, type: String, desc: "Foreground color"
+ end
+ put ":id" do
message = find_message
if message.update(declared_params(include_missing: false))
@@ -83,14 +83,14 @@ module API
end
end
- desc 'Delete a broadcast message' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Delete a broadcast message" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::BroadcastMessage
end
params do
- requires :id, type: Integer, desc: 'Broadcast message ID'
+ requires :id, type: Integer, desc: "Broadcast message ID"
end
- delete ':id' do
+ delete ":id" do
message = find_message
destroy_conditionally!(message)
diff --git a/lib/api/circuit_breakers.rb b/lib/api/circuit_breakers.rb
index da756daadcc..202fe410918 100644
--- a/lib/api/circuit_breakers.rb
+++ b/lib/api/circuit_breakers.rb
@@ -7,28 +7,28 @@ module API
resource :circuit_breakers do
params do
requires :type,
- type: String,
- desc: "The type of circuitbreaker",
- values: ['repository_storage']
+ type: String,
+ desc: "The type of circuitbreaker",
+ values: ["repository_storage"]
end
- resource ':type' do
- namespace '', requirements: { type: 'repository_storage' } do
- desc 'Get all git storages' do
- detail 'This feature was introduced in GitLab 9.5'
+ resource ":type" do
+ namespace "", requirements: {type: "repository_storage"} do
+ desc "Get all git storages" do
+ detail "This feature was introduced in GitLab 9.5"
end
get do
present []
end
- desc 'Get all failing git storages' do
- detail 'This feature was introduced in GitLab 9.5'
+ desc "Get all failing git storages" do
+ detail "This feature was introduced in GitLab 9.5"
end
- get 'failing' do
+ get "failing" do
present []
end
- desc 'Reset all storage failures and open circuitbreaker' do
- detail 'This feature was introduced in GitLab 9.5'
+ desc "Reset all storage failures and open circuitbreaker" do
+ detail "This feature was introduced in GitLab 9.5"
end
delete do
end
diff --git a/lib/api/commit_statuses.rb b/lib/api/commit_statuses.rb
index 08b4f8db8b0..205c8e0ff6a 100644
--- a/lib/api/commit_statuses.rb
+++ b/lib/api/commit_statuses.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'mime/types'
+require "mime/types"
module API
class CommitStatuses < Grape::API
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include PaginationParams
@@ -16,18 +16,18 @@ module API
success Entities::CommitStatus
end
params do
- requires :sha, type: String, desc: 'The commit hash'
- optional :ref, type: String, desc: 'The ref'
- optional :stage, type: String, desc: 'The stage'
- optional :name, type: String, desc: 'The name'
- optional :all, type: String, desc: 'Show all statuses, default: false'
+ requires :sha, type: String, desc: "The commit hash"
+ optional :ref, type: String, desc: "The ref"
+ optional :stage, type: String, desc: "The stage"
+ optional :name, type: String, desc: "The name"
+ optional :all, type: String, desc: "Show all statuses, default: false"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/repository/commits/:sha/statuses' do
+ get ":id/repository/commits/:sha/statuses" do
authorize!(:read_commit_status, user_project)
- not_found!('Commit') unless user_project.commit(params[:sha])
+ not_found!("Commit") unless user_project.commit(params[:sha])
pipelines = user_project.ci_pipelines.where(sha: params[:sha])
statuses = ::CommitStatus.where(pipeline: pipelines)
@@ -39,26 +39,26 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Post status to a commit' do
+ desc "Post status to a commit" do
success Entities::CommitStatus
end
params do
- requires :sha, type: String, desc: 'The commit hash'
- requires :state, type: String, desc: 'The state of the status',
- values: %w(pending running success failed canceled)
- optional :ref, type: String, desc: 'The ref'
- optional :target_url, type: String, desc: 'The target URL to associate with this status'
- optional :description, type: String, desc: 'A short description of the status'
+ requires :sha, type: String, desc: "The commit hash"
+ requires :state, type: String, desc: "The state of the status",
+ values: %w[pending running success failed canceled]
+ optional :ref, type: String, desc: "The ref"
+ optional :target_url, type: String, desc: "The target URL to associate with this status"
+ optional :description, type: String, desc: "A short description of the status"
optional :name, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
optional :context, type: String, desc: 'A string label to differentiate this status from the status of other systems. Default: "default"'
- optional :coverage, type: Float, desc: 'The total code coverage'
+ optional :coverage, type: Float, desc: "The total code coverage"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/statuses/:sha' do
+ post ":id/statuses/:sha" do
authorize! :create_commit_status, user_project
commit = @project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
# Since the CommitStatus is attached to Ci::Pipeline (in the future Pipeline)
# We need to always have the pipeline object
@@ -69,19 +69,18 @@ module API
ref = params[:ref]
ref ||= @project.repository.branch_names_contains(commit.sha).first
- not_found! 'References for commit' unless ref
+ not_found! "References for commit" unless ref
- name = params[:name] || params[:context] || 'default'
+ name = params[:name] || params[:context] || "default"
pipeline = @project.pipeline_for(ref, commit.sha)
- unless pipeline
- pipeline = @project.ci_pipelines.create!(
- source: :external,
- sha: commit.sha,
- ref: ref,
- user: current_user,
- protected: @project.protected_for?(ref))
- end
+ pipeline ||= @project.ci_pipelines.create!(
+ source: :external,
+ sha: commit.sha,
+ ref: ref,
+ user: current_user,
+ protected: @project.protected_for?(ref)
+ )
status = GenericCommitStatus.running_or_pending.find_or_initialize_by(
project: @project,
@@ -100,23 +99,25 @@ module API
begin
case params[:state]
- when 'pending'
+ when "pending"
status.enqueue!
- when 'running'
+ when "running"
status.enqueue
status.run!
- when 'success'
+ when "success"
status.success!
- when 'failed'
+ when "failed"
status.drop!(:api_failure)
- when 'canceled'
+ when "canceled"
status.cancel!
else
- render_api_error!('invalid state', 400)
+ render_api_error!("invalid state", 400)
end
- MergeRequest.where(source_project: @project, source_branch: ref)
- .update_all(head_pipeline_id: pipeline.id) if pipeline.latest?
+ if pipeline.latest?
+ MergeRequest.where(source_project: @project, source_branch: ref)
+ .update_all(head_pipeline_id: pipeline.id)
+ end
present status, with: Entities::CommitStatus
rescue StateMachines::InvalidTransition => e
diff --git a/lib/api/commits.rb b/lib/api/commits.rb
index 8defc59224d..a38d476b122 100644
--- a/lib/api/commits.rb
+++ b/lib/api/commits.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'mime/types'
+require "mime/types"
module API
class Commits < Grape::API
@@ -21,37 +21,37 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a project repository commits' do
+ desc "Get a project repository commits" do
success Entities::Commit
end
params do
- optional :ref_name, type: String, desc: 'The name of a repository branch or tag, if not given the default branch is used'
- optional :since, type: DateTime, desc: 'Only commits after or on this date will be returned'
- optional :until, type: DateTime, desc: 'Only commits before or on this date will be returned'
- optional :path, type: String, desc: 'The file path'
- optional :all, type: Boolean, desc: 'Every commit will be returned'
- optional :with_stats, type: Boolean, desc: 'Stats about each commit will be added to the response'
+ optional :ref_name, type: String, desc: "The name of a repository branch or tag, if not given the default branch is used"
+ optional :since, type: DateTime, desc: "Only commits after or on this date will be returned"
+ optional :until, type: DateTime, desc: "Only commits before or on this date will be returned"
+ optional :path, type: String, desc: "The file path"
+ optional :all, type: Boolean, desc: "Every commit will be returned"
+ optional :with_stats, type: Boolean, desc: "Stats about each commit will be added to the response"
use :pagination
end
- get ':id/repository/commits' do
+ get ":id/repository/commits" do
path = params[:path]
before = params[:until]
after = params[:since]
- ref = params[:ref_name] || user_project.try(:default_branch) || 'master' unless params[:all]
+ ref = params[:ref_name] || user_project.try(:default_branch) || "master" unless params[:all]
offset = (params[:page] - 1) * params[:per_page]
all = params[:all]
with_stats = params[:with_stats]
commits = user_project.repository.commits(ref,
- path: path,
- limit: params[:per_page],
- offset: offset,
- before: before,
- after: after,
- all: all)
+ path: path,
+ limit: params[:per_page],
+ offset: offset,
+ before: before,
+ after: after,
+ all: all)
commit_count =
if all || path || before || after
@@ -68,39 +68,39 @@ module API
present paginate(paginated_commits), with: serializer
end
- desc 'Commit multiple file changes as one commit' do
+ desc "Commit multiple file changes as one commit" do
success Entities::CommitDetail
- detail 'This feature was introduced in GitLab 8.13'
+ detail "This feature was introduced in GitLab 8.13"
end
params do
- requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.', allow_blank: false
- requires :commit_message, type: String, desc: 'Commit message'
- requires :actions, type: Array, desc: 'Actions to perform in commit' do
- requires :action, type: String, desc: 'The action to perform, `create`, `delete`, `move`, `update`, `chmod`', values: %w[create update move delete chmod].freeze
- requires :file_path, type: String, desc: 'Full path to the file. Ex. `lib/class.rb`'
- given action: ->(action) { action == 'move' } do
- requires :previous_path, type: String, desc: 'Original full path to the file being moved. Ex. `lib/class1.rb`'
+ requires :branch, type: String, desc: "Name of the branch to commit into. To create a new branch, also provide `start_branch`.", allow_blank: false
+ requires :commit_message, type: String, desc: "Commit message"
+ requires :actions, type: Array, desc: "Actions to perform in commit" do
+ requires :action, type: String, desc: "The action to perform, `create`, `delete`, `move`, `update`, `chmod`", values: %w[create update move delete chmod].freeze
+ requires :file_path, type: String, desc: "Full path to the file. Ex. `lib/class.rb`"
+ given action: ->(action) { action == "move" } do
+ requires :previous_path, type: String, desc: "Original full path to the file being moved. Ex. `lib/class1.rb`"
end
given action: ->(action) { %w[create move].include? action } do
- optional :content, type: String, desc: 'File content'
+ optional :content, type: String, desc: "File content"
end
- given action: ->(action) { action == 'update' } do
- requires :content, type: String, desc: 'File content'
+ given action: ->(action) { action == "update" } do
+ requires :content, type: String, desc: "File content"
end
- optional :encoding, type: String, desc: '`text` or `base64`', default: 'text', values: %w[text base64]
+ optional :encoding, type: String, desc: "`text` or `base64`", default: "text", values: %w[text base64]
given action: ->(action) { %w[update move delete].include? action } do
- optional :last_commit_id, type: String, desc: 'Last known file commit id'
+ optional :last_commit_id, type: String, desc: "Last known file commit id"
end
- given action: ->(action) { action == 'chmod' } do
- requires :execute_filemode, type: Boolean, desc: 'When `true/false` enables/disables the execute flag on the file.'
+ given action: ->(action) { action == "chmod" } do
+ requires :execute_filemode, type: Boolean, desc: "When `true/false` enables/disables the execute flag on the file."
end
end
- optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
- optional :author_email, type: String, desc: 'Author email for commit'
- optional :author_name, type: String, desc: 'Author name for commit'
- optional :stats, type: Boolean, default: true, desc: 'Include commit stats'
+ optional :start_branch, type: String, desc: "Name of the branch to start the new commit from"
+ optional :author_email, type: String, desc: "Author email for commit"
+ optional :author_name, type: String, desc: "Author name for commit"
+ optional :stats, type: Boolean, default: true, desc: "Include commit stats"
end
- post ':id/repository/commits' do
+ post ":id/repository/commits" do
authorize_push_to_branch!(params[:branch])
attrs = declared_params
@@ -120,33 +120,33 @@ module API
end
end
- desc 'Get a specific commit of a project' do
+ desc "Get a specific commit of a project" do
success Entities::CommitDetail
- failure [[404, 'Commit Not Found']]
+ failure [[404, "Commit Not Found"]]
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
- optional :stats, type: Boolean, default: true, desc: 'Include commit stats'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag"
+ optional :stats, type: Boolean, default: true, desc: "Include commit stats"
end
- get ':id/repository/commits/:sha', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
present commit, with: Entities::CommitDetail, stats: params[:stats]
end
- desc 'Get the diff for a specific commit of a project' do
- failure [[404, 'Commit Not Found']]
+ desc "Get the diff for a specific commit of a project" do
+ failure [[404, "Commit Not Found"]]
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag"
use :pagination
end
- get ':id/repository/commits/:sha/diff', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha/diff", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
raw_diffs = ::Kaminari.paginate_array(commit.raw_diffs.to_a)
@@ -155,43 +155,43 @@ module API
desc "Get a commit's comments" do
success Entities::CommitNote
- failure [[404, 'Commit Not Found']]
+ failure [[404, "Commit Not Found"]]
end
params do
use :pagination
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/repository/commits/:sha/comments', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha/comments", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
notes = commit.notes.order(:created_at)
present paginate(notes), with: Entities::CommitNote
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Cherry pick commit into a branch' do
- detail 'This feature was introduced in GitLab 8.15'
+ desc "Cherry pick commit into a branch" do
+ detail "This feature was introduced in GitLab 8.15"
success Entities::Commit
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag to be cherry picked'
- requires :branch, type: String, desc: 'The name of the branch', allow_blank: false
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag to be cherry picked"
+ requires :branch, type: String, desc: "The name of the branch", allow_blank: false
end
- post ':id/repository/commits/:sha/cherry_pick', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ post ":id/repository/commits/:sha/cherry_pick", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
authorize_push_to_branch!(params[:branch])
commit = user_project.commit(params[:sha])
- not_found!('Commit') unless commit
+ not_found!("Commit") unless commit
find_branch!(params[:branch])
commit_params = {
commit: commit,
start_branch: params[:branch],
- branch_name: params[:branch]
+ branch_name: params[:branch],
}
result = ::Commits::CherryPickService
@@ -206,26 +206,26 @@ module API
end
end
- desc 'Revert a commit in a branch' do
- detail 'This feature was introduced in GitLab 11.5'
+ desc "Revert a commit in a branch" do
+ detail "This feature was introduced in GitLab 11.5"
success Entities::Commit
end
params do
- requires :sha, type: String, desc: 'Commit SHA to revert'
- requires :branch, type: String, desc: 'Target branch name', allow_blank: false
+ requires :sha, type: String, desc: "Commit SHA to revert"
+ requires :branch, type: String, desc: "Target branch name", allow_blank: false
end
- post ':id/repository/commits/:sha/revert', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ post ":id/repository/commits/:sha/revert", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
authorize_push_to_branch!(params[:branch])
commit = user_project.commit(params[:sha])
- not_found!('Commit') unless commit
+ not_found!("Commit") unless commit
find_branch!(params[:branch])
commit_params = {
commit: commit,
start_branch: params[:branch],
- branch_name: params[:branch]
+ branch_name: params[:branch],
}
result = ::Commits::RevertService
@@ -240,47 +240,47 @@ module API
end
end
- desc 'Get all references a commit is pushed to' do
- detail 'This feature was introduced in GitLab 10.6'
+ desc "Get all references a commit is pushed to" do
+ detail "This feature was introduced in GitLab 10.6"
success Entities::BasicRef
end
params do
- requires :sha, type: String, desc: 'A commit sha'
- optional :type, type: String, values: %w[branch tag all], default: 'all', desc: 'Scope'
+ requires :sha, type: String, desc: "A commit sha"
+ optional :type, type: String, values: %w[branch tag all], default: "all", desc: "Scope"
use :pagination
end
- get ':id/repository/commits/:sha/refs', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha/refs", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found!('Commit') unless commit
+ not_found!("Commit") unless commit
refs = []
- refs.concat(user_project.repository.branch_names_contains(commit.id).map {|name| { type: 'branch', name: name }}) unless params[:type] == 'tag'
- refs.concat(user_project.repository.tag_names_contains(commit.id).map {|name| { type: 'tag', name: name }}) unless params[:type] == 'branch'
+ refs.concat(user_project.repository.branch_names_contains(commit.id).map {|name| {type: "branch", name: name}}) unless params[:type] == "tag"
+ refs.concat(user_project.repository.tag_names_contains(commit.id).map {|name| {type: "tag", name: name}}) unless params[:type] == "branch"
refs = Kaminari.paginate_array(refs)
present paginate(refs), with: Entities::BasicRef
end
- desc 'Post comment to commit' do
+ desc "Post comment to commit" do
success Entities::CommitNote
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag on which to post a comment'
- requires :note, type: String, desc: 'The text of the comment'
- optional :path, type: String, desc: 'The file path'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag on which to post a comment"
+ requires :note, type: String, desc: "The text of the comment"
+ optional :path, type: String, desc: "The file path"
given :path do
- requires :line, type: Integer, desc: 'The line number'
- requires :line_type, type: String, values: %w[new old], default: 'new', desc: 'The type of the line'
+ requires :line, type: Integer, desc: "The line number"
+ requires :line_type, type: String, values: %w[new old], default: "new", desc: "The type of the line"
end
end
- post ':id/repository/commits/:sha/comments', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ post ":id/repository/commits/:sha/comments", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
opts = {
note: params[:note],
- noteable_type: 'Commit',
- commit_id: commit.id
+ noteable_type: "Commit",
+ commit_id: commit.id,
}
if params[:path]
@@ -310,16 +310,16 @@ module API
end
end
- desc 'Get Merge Requests associated with a commit' do
+ desc "Get Merge Requests associated with a commit" do
success Entities::MergeRequestBasic
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag on which to find Merge Requests'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag on which to find Merge Requests"
use :pagination
end
- get ':id/repository/commits/:sha/merge_requests', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha/merge_requests", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
present paginate(commit.merge_requests), with: Entities::MergeRequestBasic
end
@@ -328,14 +328,14 @@ module API
success Entities::CommitSignature
end
params do
- requires :sha, type: String, desc: 'A commit sha, or the name of a branch or tag'
+ requires :sha, type: String, desc: "A commit sha, or the name of a branch or tag"
end
- get ':id/repository/commits/:sha/signature', requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/commits/:sha/signature", requirements: API::COMMIT_ENDPOINT_REQUIREMENTS do
commit = user_project.commit(params[:sha])
- not_found! 'Commit' unless commit
+ not_found! "Commit" unless commit
signature = commit.signature
- not_found! 'GPG Signature' unless signature
+ not_found! "GPG Signature" unless signature
present signature, with: Entities::CommitSignature
end
diff --git a/lib/api/container_registry.rb b/lib/api/container_registry.rb
index e4493910196..3e387d05e47 100644
--- a/lib/api/container_registry.rb
+++ b/lib/api/container_registry.rb
@@ -5,35 +5,36 @@ module API
include PaginationParams
REGISTRY_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(
- tag_name: API::NO_SLASH_URL_PART_REGEX)
+ tag_name: API::NO_SLASH_URL_PART_REGEX
+ )
- before { error!('404 Not Found', 404) unless Feature.enabled?(:container_registry_api, user_project, default_enabled: true) }
+ before { error!("404 Not Found", 404) unless Feature.enabled?(:container_registry_api, user_project, default_enabled: true) }
before { authorize_read_container_images! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a project container repositories' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Get a project container repositories" do
+ detail "This feature was introduced in GitLab 11.8."
success Entities::ContainerRegistry::Repository
end
params do
use :pagination
end
- get ':id/registry/repositories' do
+ get ":id/registry/repositories" do
repositories = user_project.container_repositories.ordered
present paginate(repositories), with: Entities::ContainerRegistry::Repository
end
- desc 'Delete repository' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Delete repository" do
+ detail "This feature was introduced in GitLab 11.8."
end
params do
- requires :repository_id, type: Integer, desc: 'The ID of the repository'
+ requires :repository_id, type: Integer, desc: "The ID of the repository"
end
- delete ':id/registry/repositories/:repository_id', requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
+ delete ":id/registry/repositories/:repository_id", requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
authorize_admin_container_image!
DeleteContainerRepositoryWorker.perform_async(current_user.id, repository.id)
@@ -41,31 +42,31 @@ module API
status :accepted
end
- desc 'Get a list of repositories tags' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Get a list of repositories tags" do
+ detail "This feature was introduced in GitLab 11.8."
success Entities::ContainerRegistry::Tag
end
params do
- requires :repository_id, type: Integer, desc: 'The ID of the repository'
+ requires :repository_id, type: Integer, desc: "The ID of the repository"
use :pagination
end
- get ':id/registry/repositories/:repository_id/tags', requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
+ get ":id/registry/repositories/:repository_id/tags", requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
authorize_read_container_image!
tags = Kaminari.paginate_array(repository.tags)
present paginate(tags), with: Entities::ContainerRegistry::Tag
end
- desc 'Delete repository tags (in bulk)' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Delete repository tags (in bulk)" do
+ detail "This feature was introduced in GitLab 11.8."
end
params do
- requires :repository_id, type: Integer, desc: 'The ID of the repository'
- requires :name_regex, type: String, desc: 'The tag name regexp to delete, specify .* to delete all'
- optional :keep_n, type: Integer, desc: 'Keep n of latest tags with matching name'
- optional :older_than, type: String, desc: 'Delete older than: 1h, 1d, 1month'
+ requires :repository_id, type: Integer, desc: "The ID of the repository"
+ requires :name_regex, type: String, desc: "The tag name regexp to delete, specify .* to delete all"
+ optional :keep_n, type: Integer, desc: "Keep n of latest tags with matching name"
+ optional :older_than, type: String, desc: "Delete older than: 1h, 1d, 1month"
end
- delete ':id/registry/repositories/:repository_id/tags', requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
+ delete ":id/registry/repositories/:repository_id/tags", requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
authorize_admin_container_image!
CleanupContainerRepositoryWorker.perform_async(current_user.id, repository.id,
@@ -74,29 +75,29 @@ module API
status :accepted
end
- desc 'Get a details about repository tag' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Get a details about repository tag" do
+ detail "This feature was introduced in GitLab 11.8."
success Entities::ContainerRegistry::TagDetails
end
params do
- requires :repository_id, type: Integer, desc: 'The ID of the repository'
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :repository_id, type: Integer, desc: "The ID of the repository"
+ requires :tag_name, type: String, desc: "The name of the tag"
end
- get ':id/registry/repositories/:repository_id/tags/:tag_name', requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
+ get ":id/registry/repositories/:repository_id/tags/:tag_name", requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
authorize_read_container_image!
validate_tag!
present tag, with: Entities::ContainerRegistry::TagDetails
end
- desc 'Delete repository tag' do
- detail 'This feature was introduced in GitLab 11.8.'
+ desc "Delete repository tag" do
+ detail "This feature was introduced in GitLab 11.8."
end
params do
- requires :repository_id, type: Integer, desc: 'The ID of the repository'
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :repository_id, type: Integer, desc: "The ID of the repository"
+ requires :tag_name, type: String, desc: "The name of the tag"
end
- delete ':id/registry/repositories/:repository_id/tags/:tag_name', requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
+ delete ":id/registry/repositories/:repository_id/tags/:tag_name", requirements: REGISTRY_ENDPOINT_REQUIREMENTS do
authorize_destroy_container_image!
validate_tag!
@@ -136,7 +137,7 @@ module API
end
def validate_tag!
- not_found!('Tag') unless tag.valid?
+ not_found!("Tag") unless tag.valid?
end
end
end
diff --git a/lib/api/custom_attributes_endpoints.rb b/lib/api/custom_attributes_endpoints.rb
index 2149e04451e..d697d8b9f88 100644
--- a/lib/api/custom_attributes_endpoints.rb
+++ b/lib/api/custom_attributes_endpoints.rb
@@ -12,14 +12,14 @@ module API
helpers do
params :custom_attributes_key do
- requires :key, type: String, desc: 'The key of the custom attribute'
+ requires :key, type: String, desc: "The key of the custom attribute"
end
end
desc "Get all custom attributes on a #{attributable_name}" do
success Entities::CustomAttribute
end
- get ':id/custom_attributes' do
+ get ":id/custom_attributes" do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :read_custom_attribute
@@ -33,7 +33,7 @@ module API
use :custom_attributes_key
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/custom_attributes/:key' do
+ get ":id/custom_attributes/:key" do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :read_custom_attribute
@@ -46,10 +46,10 @@ module API
desc "Set a custom attribute on a #{attributable_name}"
params do
use :custom_attributes_key
- requires :value, type: String, desc: 'The value of the custom attribute'
+ requires :value, type: String, desc: "The value of the custom attribute"
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/custom_attributes/:key' do
+ put ":id/custom_attributes/:key" do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :update_custom_attribute
@@ -71,7 +71,7 @@ module API
use :custom_attributes_key
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/custom_attributes/:key' do
+ delete ":id/custom_attributes/:key" do
resource = public_send(attributable_finder, params[:id]) # rubocop:disable GitlabSecurity/PublicSend
authorize! :update_custom_attribute
diff --git a/lib/api/deploy_keys.rb b/lib/api/deploy_keys.rb
index df6d2721977..32256c726ec 100644
--- a/lib/api/deploy_keys.rb
+++ b/lib/api/deploy_keys.rb
@@ -18,7 +18,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
end
- desc 'Return all deploy keys'
+ desc "Return all deploy keys"
params do
use :pagination
end
@@ -29,7 +29,7 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of the project'
+ requires :id, type: String, desc: "The ID of the project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before { authorize_admin_project }
@@ -48,11 +48,11 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get single deploy key' do
+ desc "Get single deploy key" do
success Entities::DeployKeysProject
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ requires :key_id, type: Integer, desc: "The ID of the deploy key"
end
get ":id/deploy_keys/:key_id" do
key = find_by_deploy_key(user_project, params[:key_id])
@@ -60,12 +60,12 @@ module API
present key, with: Entities::DeployKeysProject
end
- desc 'Add new deploy key to a project' do
+ desc "Add new deploy key to a project" do
success Entities::DeployKeysProject
end
params do
- requires :key, type: String, desc: 'The new deploy key'
- requires :title, type: String, desc: 'The name of the deploy key'
+ requires :key, type: String, desc: "The new deploy key"
+ requires :title, type: String, desc: "The name of the deploy key"
optional :can_push, type: Boolean, desc: "Can deploy key push to the project's repository"
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -74,8 +74,8 @@ module API
# Check for an existing key joined to this project
deploy_key_project = user_project.deploy_keys_projects
- .joins(:deploy_key)
- .find_by(keys: { key: params[:key] })
+ .joins(:deploy_key)
+ .find_by(keys: {key: params[:key]})
if deploy_key_project
present deploy_key_project, with: Entities::DeployKeysProject
@@ -103,12 +103,12 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Update an existing deploy key for a project' do
+ desc "Update an existing deploy key for a project" do
success Entities::SSHKey
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the deploy key'
- optional :title, type: String, desc: 'The name of the deploy key'
+ requires :key_id, type: Integer, desc: "The ID of the deploy key"
+ optional :title, type: String, desc: "The name of the deploy key"
optional :can_push, type: Boolean, desc: "Can deploy key push to the project's repository"
at_least_one_of :title, :can_push
end
@@ -121,8 +121,8 @@ module API
title = params[:title] || deploy_keys_project.deploy_key.title
result = deploy_keys_project.update(can_push: can_push,
- deploy_key_attributes: { id: params[:key_id],
- title: title })
+ deploy_key_attributes: {id: params[:key_id],
+ title: title,})
if result
present deploy_keys_project, with: Entities::DeployKeysProject
@@ -131,34 +131,34 @@ module API
end
end
- desc 'Enable a deploy key for a project' do
- detail 'This feature was added in GitLab 8.11'
+ 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'
+ requires :key_id, type: Integer, desc: "The ID of the deploy key"
end
post ":id/deploy_keys/:key_id/enable" do
key = ::Projects::EnableDeployKeyService.new(user_project,
- current_user, declared_params).execute
+ current_user, declared_params).execute
if key
present key, with: Entities::SSHKey
else
- not_found!('Deploy Key')
+ not_found!("Deploy Key")
end
end
- desc 'Delete deploy key for a project' do
+ desc "Delete deploy key for a project" do
success Key
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the deploy key'
+ requires :key_id, type: Integer, desc: "The ID of the deploy key"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/deploy_keys/:key_id" do
deploy_key_project = user_project.deploy_keys_projects.find_by(deploy_key_id: params[:key_id])
- not_found!('Deploy Key') unless deploy_key_project
+ not_found!("Deploy Key") unless deploy_key_project
destroy_conditionally!(deploy_key_project)
end
diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb
index eb45df31ff9..6deb89a6809 100644
--- a/lib/api/deployments.rb
+++ b/lib/api/deployments.rb
@@ -8,34 +8,34 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The project ID'
+ requires :id, type: String, desc: "The project ID"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all deployments of the project' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Get all deployments of the project" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Deployment
end
params do
use :pagination
- optional :order_by, type: String, values: %w[id iid created_at ref], default: 'id', desc: 'Return deployments ordered by `id` or `iid` or `created_at` or `ref`'
- optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)'
+ optional :order_by, type: String, values: %w[id iid created_at ref], default: "id", desc: "Return deployments ordered by `id` or `iid` or `created_at` or `ref`"
+ optional :sort, type: String, values: %w[asc desc], default: "asc", desc: "Sort by asc (ascending) or desc (descending)"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/deployments' do
+ get ":id/deployments" do
authorize! :read_deployment, user_project
present paginate(user_project.deployments.order(params[:order_by] => params[:sort])), with: Entities::Deployment
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Gets a specific deployment' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Gets a specific deployment" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Deployment
end
params do
- requires :deployment_id, type: Integer, desc: 'The deployment ID'
+ requires :deployment_id, type: Integer, desc: "The deployment ID"
end
- get ':id/deployments/:deployment_id' do
+ get ":id/deployments/:deployment_id" do
authorize! :read_deployment, user_project
deployment = user_project.deployments.find(params[:deployment_id])
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb
index 91eb6a23701..06d9c53c2ab 100644
--- a/lib/api/discussions.rb
+++ b/lib/api/discussions.rb
@@ -22,7 +22,7 @@ module API
success Entities::Discussion
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -45,8 +45,8 @@ module API
success Entities::Discussion
end
params do
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
end
get ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -65,36 +65,36 @@ module API
success Entities::Discussion
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :body, type: String, desc: 'The content of a note'
- optional :created_at, type: String, desc: 'The creation date of the note'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :body, type: String, desc: "The content of a note"
+ optional :created_at, type: String, desc: "The creation date of the note"
optional :position, type: Hash do
- requires :base_sha, type: String, desc: 'Base commit SHA in the source branch'
- requires :start_sha, type: String, desc: 'SHA referencing commit in target branch'
- requires :head_sha, type: String, desc: 'SHA referencing HEAD of this merge request'
- requires :position_type, type: String, desc: 'Type of the position reference', values: %w(text image)
- optional :new_path, type: String, desc: 'File path after change'
- optional :new_line, type: Integer, desc: 'Line number after change'
- optional :old_path, type: String, desc: 'File path before change'
- optional :old_line, type: Integer, desc: 'Line number before change'
- optional :width, type: Integer, desc: 'Width of the image'
- optional :height, type: Integer, desc: 'Height of the image'
- optional :x, type: Integer, desc: 'X coordinate in the image'
- optional :y, type: Integer, desc: 'Y coordinate in the image'
+ requires :base_sha, type: String, desc: "Base commit SHA in the source branch"
+ requires :start_sha, type: String, desc: "SHA referencing commit in target branch"
+ requires :head_sha, type: String, desc: "SHA referencing HEAD of this merge request"
+ requires :position_type, type: String, desc: "Type of the position reference", values: %w[text image]
+ optional :new_path, type: String, desc: "File path after change"
+ optional :new_line, type: Integer, desc: "Line number after change"
+ optional :old_path, type: String, desc: "File path before change"
+ optional :old_line, type: Integer, desc: "Line number before change"
+ optional :width, type: Integer, desc: "Width of the image"
+ optional :height, type: Integer, desc: "Height of the image"
+ optional :x, type: Integer, desc: "X coordinate in the image"
+ optional :y, type: Integer, desc: "Y coordinate in the image"
end
end
post ":id/#{noteables_path}/:noteable_id/discussions" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
- type = params[:position] ? 'DiffNote' : 'DiscussionNote'
+ type = params[:position] ? "DiffNote" : "DiscussionNote"
id_key = noteable.is_a?(Commit) ? :commit_id : :noteable_id
opts = {
- note: params[:body],
- created_at: params[:created_at],
- type: type,
- noteable_type: noteables_str.classify,
- position: params[:position],
- id_key => noteable.id
+ :note => params[:body],
+ :created_at => params[:created_at],
+ :type => type,
+ :noteable_type => noteables_str.classify,
+ :position => params[:position],
+ id_key => noteable.id,
}
note = create_note(noteable, opts)
@@ -110,8 +110,8 @@ module API
success Entities::Discussion
end
params do
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
end
get ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -128,10 +128,10 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :body, type: String, desc: 'The content of a note'
- optional :created_at, type: String, desc: 'The creation date of the note'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :body, type: String, desc: "The content of a note"
+ optional :created_at, type: String, desc: "The creation date of the note"
end
post ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -142,9 +142,9 @@ module API
opts = {
note: params[:body],
- type: 'DiscussionNote',
+ type: "DiscussionNote",
in_reply_to_discussion_id: params[:discussion_id],
- created_at: params[:created_at]
+ created_at: params[:created_at],
}
note = create_note(noteable, opts)
@@ -159,9 +159,9 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :note_id, type: Integer, desc: 'The ID of a note'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :note_id, type: Integer, desc: "The ID of a note"
end
get ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -173,11 +173,11 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :note_id, type: Integer, desc: 'The ID of a note'
- optional :body, type: String, desc: 'The content of a note'
- optional :resolved, type: Boolean, desc: 'Mark note resolved/unresolved'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :note_id, type: Integer, desc: "The ID of a note"
+ optional :body, type: String, desc: "The content of a note"
+ optional :resolved, type: Boolean, desc: "Mark note resolved/unresolved"
exactly_one_of :body, :resolved
end
put ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
@@ -194,9 +194,9 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :note_id, type: Integer, desc: 'The ID of a note'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :note_id, type: Integer, desc: "The ID of a note"
end
delete ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -209,9 +209,9 @@ module API
success Entities::Discussion
end
params do
- requires :noteable_id, types: [Integer, String], desc: 'The ID of the noteable'
- requires :discussion_id, type: String, desc: 'The ID of a discussion'
- requires :resolved, type: Boolean, desc: 'Mark discussion resolved/unresolved'
+ requires :noteable_id, types: [Integer, String], desc: "The ID of the noteable"
+ requires :discussion_id, type: String, desc: "The ID of a discussion"
+ requires :resolved, type: Boolean, desc: "Mark discussion resolved/unresolved"
end
put ":id/#{noteables_path}/:noteable_id/discussions/:discussion_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 18f15632f2b..b01f65709bb 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -21,7 +21,7 @@ module API
expose :link do
expose :file_path, as: :url
expose :markdown do |_entity|
- self.markdown_link
+ markdown_link
end
end
@@ -46,7 +46,7 @@ module API
end
expose :avatar_path, if: ->(user, options) { options.fetch(:only_path, false) && user.avatar_path }
- expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
+ expose :custom_attributes, using: "API::Entities::CustomAttribute", if: :with_custom_attributes
expose :web_url do |user, options|
Gitlab::Routing.url_helpers.user_url(user)
@@ -176,7 +176,7 @@ module API
end
end
- expose :license, with: 'API::Entities::LicenseBasic', if: :license do |project|
+ expose :license, with: "API::Entities::LicenseBasic", if: :license do |project|
project.repository.license
end
@@ -186,8 +186,8 @@ module API
expose :star_count, :forks_count
expose :last_activity_at
- expose :namespace, using: 'API::Entities::NamespaceBasic'
- expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
+ expose :namespace, using: "API::Entities::NamespaceBasic"
+ expose :custom_attributes, using: "API::Entities::CustomAttribute", if: :with_custom_attributes
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
@@ -196,8 +196,8 @@ module API
# N+1 is solved then by using `subject.tags.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555
projects_relation.preload(:project_feature, :route)
- .preload(:import_state, :tags)
- .preload(namespace: [:route, :owner])
+ .preload(:import_state, :tags)
+ .preload(namespace: [:route, :owner])
end
# rubocop: enable CodeReuse/ActiveRecord
end
@@ -210,11 +210,11 @@ module API
expose_url(api_v4_projects_path(id: project.id))
end
- expose :issues, if: -> (project, options) { issues_available?(project, options) } do |project|
+ expose :issues, if: ->(project, options) { issues_available?(project, options) } do |project|
expose_url(api_v4_projects_issues_path(id: project.id))
end
- expose :merge_requests, if: -> (project, options) { mrs_available?(project, options) } do |project|
+ expose :merge_requests, if: ->(project, options) { mrs_available?(project, options) } do |project|
expose_url(api_v4_projects_merge_requests_path(id: project.id))
end
@@ -271,7 +271,7 @@ module API
expose :printing_merge_request_link_enabled
expose :merge_method
- expose :statistics, using: 'API::Entities::ProjectStatistics', if: :statistics
+ expose :statistics, using: "API::Entities::ProjectStatistics", if: :statistics
# rubocop: disable CodeReuse/ActiveRecord
def self.preload_relation(projects_relation, options = {})
@@ -280,10 +280,10 @@ module API
# N+1 is solved then by using `subject.tags.map(&:name)`
# MR describing the solution: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/20555
super(projects_relation).preload(:group)
- .preload(project_group_links: { group: :route },
- fork_network: :root_project,
- fork_network_member: :forked_from_project,
- forked_from_project: [:route, :forks, :tags, namespace: :route])
+ .preload(project_group_links: {group: :route},
+ fork_network: :root_project,
+ fork_network_member: :forked_from_project,
+ forked_from_project: [:route, :forks, :tags, namespace: :route])
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -342,10 +342,10 @@ module API
expose :parent_id
end
- expose :custom_attributes, using: 'API::Entities::CustomAttribute', if: :with_custom_attributes
+ expose :custom_attributes, using: "API::Entities::CustomAttribute", if: :with_custom_attributes
expose :statistics, if: :statistics do
- with_options format_with: -> (value) { value.to_i } do
+ with_options format_with: ->(value) { value.to_i } do
expose :storage_size
expose :repository_size
expose :lfs_objects_size
@@ -359,7 +359,7 @@ module API
projects = GroupProjectsFinder.new(
group: group,
current_user: options[:current_user],
- options: { only_owned: true }
+ options: {only_owned: true}
).execute
Entities::Project.prepare_relation(projects)
@@ -369,7 +369,7 @@ module API
projects = GroupProjectsFinder.new(
group: group,
current_user: options[:current_user],
- options: { only_shared: true }
+ options: {only_shared: true}
).execute
Entities::Project.prepare_relation(projects)
@@ -400,7 +400,7 @@ module API
class CommitDetail < Commit
expose :stats, using: Entities::CommitStats, if: :stats
expose :status
- expose :last_pipeline, using: 'API::Entities::PipelineBasic'
+ expose :last_pipeline, using: "API::Entities::PipelineBasic"
expose :project_id
end
@@ -521,8 +521,8 @@ module API
class Milestone < Grape::Entity
expose :id, :iid
- expose :project_id, if: -> (entity, options) { entity&.project_id }
- expose :group_id, if: -> (entity, options) { entity&.group_id }
+ expose :project_id, if: ->(entity, options) { entity&.project_id }
+ expose :group_id, if: ->(entity, options) { entity&.group_id }
expose :title, :description
expose :state, :created_at, :updated_at
expose :due_date
@@ -559,7 +559,7 @@ module API
Gitlab::UrlBuilder.build(issue)
end
- expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
+ expose :time_stats, using: "API::Entities::IssuableTimeStats" do |issue|
issue
end
end
@@ -648,10 +648,10 @@ module API
merge_request.metrics&.latest_closed_at
end
- expose :title_html, if: -> (_, options) { options[:render_html] } do |entity|
+ expose :title_html, if: ->(_, options) { options[:render_html] } do |entity|
MarkupHelper.markdown_field(entity, :title)
end
- expose :description_html, if: -> (_, options) { options[:render_html] } do |entity|
+ expose :description_html, if: ->(_, options) { options[:render_html] } do |entity|
MarkupHelper.markdown_field(entity, :description)
end
expose :target_branch, :source_branch
@@ -681,15 +681,15 @@ module API
expose :discussion_locked
expose :should_remove_source_branch?, as: :should_remove_source_branch
expose :force_remove_source_branch?, as: :force_remove_source_branch
- expose :allow_collaboration, if: -> (merge_request, _) { merge_request.for_fork? }
+ expose :allow_collaboration, if: ->(merge_request, _) { merge_request.for_fork? }
# Deprecated
- expose :allow_collaboration, as: :allow_maintainer_to_push, if: -> (merge_request, _) { merge_request.for_fork? }
+ expose :allow_collaboration, as: :allow_maintainer_to_push, if: ->(merge_request, _) { merge_request.for_fork? }
expose :web_url do |merge_request|
Gitlab::UrlBuilder.build(merge_request)
end
- expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |merge_request|
+ expose :time_stats, using: "API::Entities::IssuableTimeStats" do |merge_request|
merge_request
end
@@ -705,19 +705,19 @@ module API
merge_request.merge_request_diff.real_size
end
- expose :latest_build_started_at, if: -> (_, options) { build_available?(options) } do |merge_request, _options|
+ expose :latest_build_started_at, if: ->(_, options) { build_available?(options) } do |merge_request, _options|
merge_request.metrics&.latest_build_started_at
end
- expose :latest_build_finished_at, if: -> (_, options) { build_available?(options) } do |merge_request, _options|
+ expose :latest_build_finished_at, if: ->(_, options) { build_available?(options) } do |merge_request, _options|
merge_request.metrics&.latest_build_finished_at
end
- expose :first_deployed_to_production_at, if: -> (_, options) { build_available?(options) } do |merge_request, _options|
+ expose :first_deployed_to_production_at, if: ->(_, options) { build_available?(options) } do |merge_request, _options|
merge_request.metrics&.first_deployed_to_production_at
end
- expose :pipeline, using: Entities::PipelineBasic, if: -> (_, options) { build_available?(options) } do |merge_request, _options|
+ expose :pipeline, using: Entities::PipelineBasic, if: ->(_, options) { build_available?(options) } do |merge_request, _options|
merge_request.metrics&.pipeline
end
@@ -725,9 +725,9 @@ module API
# Allow the status of a rebase to be determined
expose :merge_error
- expose :rebase_in_progress?, as: :rebase_in_progress, if: -> (_, options) { options[:include_rebase_in_progress] }
+ expose :rebase_in_progress?, as: :rebase_in_progress, if: ->(_, options) { options[:include_rebase_in_progress] }
- expose :diverged_commits_count, as: :diverged_commits_count, if: -> (_, options) { options[:include_diverged_commits_count] }
+ expose :diverged_commits_count, as: :diverged_commits_count, if: ->(_, options) { options[:include_diverged_commits_count] }
def build_available?(options)
options[:project]&.feature_available?(:builds, options[:current_user])
@@ -783,7 +783,7 @@ module API
class Note < Grape::Entity
# Only Issue and MergeRequest have iid
- NOTEABLE_TYPES_WITH_IID = %w(Issue MergeRequest).freeze
+ NOTEABLE_TYPES_WITH_IID = %w[Issue MergeRequest].freeze
expose :id
expose :type
@@ -842,7 +842,7 @@ module API
class CommitStatus < Grape::Entity
expose :id, :sha, :ref, :status, :name, :target_url, :description,
- :created_at, :started_at, :finished_at, :allow_failure, :coverage
+ :created_at, :started_at, :finished_at, :allow_failure, :coverage
expose :author, using: Entities::UserBasic
end
@@ -862,7 +862,7 @@ module API
expose :push_event_payload,
as: :push_data,
using: PushEventPayload,
- if: -> (event, _) { event.push? }
+ if: ->(event, _) { event.push? }
expose :author_username do |event, options|
event.author&.username
@@ -875,8 +875,8 @@ module API
class Todo < Grape::Entity
expose :id
- expose :project, using: Entities::ProjectIdentity, if: -> (todo, _) { todo.project_id }
- expose :group, using: 'API::Entities::NamespaceBasic', if: -> (todo, _) { todo.group_id }
+ expose :project, using: Entities::ProjectIdentity, if: ->(todo, _) { todo.project_id }
+ expose :group, using: "API::Entities::NamespaceBasic", if: ->(todo, _) { todo.group_id }
expose :author, using: Entities::UserBasic
expose :action_name
expose :target_type
@@ -909,12 +909,12 @@ module API
end
class Namespace < NamespaceBasic
- expose :members_count_with_descendants, if: -> (namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _|
+ expose :members_count_with_descendants, if: ->(namespace, opts) { expose_members_count_with_descendants?(namespace, opts) } do |namespace, _|
namespace.users_with_descendants.count
end
def expose_members_count_with_descendants?(namespace, opts)
- namespace.kind == 'group' && Ability.allowed?(opts[:current_user], :admin_group, namespace)
+ namespace.kind == "group" && Ability.allowed?(opts[:current_user], :admin_group, namespace)
end
end
@@ -987,10 +987,10 @@ module API
# MySQL doesn't support LIMIT inside an IN subquery
if Gitlab::Database.mysql?
- project_ids = relation.pluck('projects.id')
+ project_ids = relation.pluck("projects.id")
namespace_ids = relation.pluck(:namespace_id)
else
- project_ids = relation.select('projects.id')
+ project_ids = relation.select("projects.id")
namespace_ids = relation.select(:namespace_id)
end
@@ -1135,7 +1135,7 @@ module API
MarkupHelper.markdown_field(entity, :description)
end
expose :created_at
- expose :author, using: Entities::UserBasic, if: -> (release, _) { release.author.present? }
+ expose :author, using: Entities::UserBasic, if: ->(release, _) { release.author.present? }
expose :commit, using: Entities::Commit
expose :assets do
@@ -1229,7 +1229,7 @@ module API
class Job < JobBasic
# artifacts_file is included in job_artifacts, but kept for backward compatibility (remove in api/v5)
- expose :artifacts_file, using: JobArtifactFile, if: -> (job, opts) { job.artifacts? }
+ expose :artifacts_file, using: JobArtifactFile, if: ->(job, opts) { job.artifacts? }
expose :job_artifacts, as: :artifacts, using: JobArtifact
expose :runner, with: Runner
expose :artifacts_expire_at
@@ -1251,7 +1251,7 @@ module API
class Variable < Grape::Entity
expose :key, :value
- expose :protected?, as: :protected, if: -> (entity, _) { entity.respond_to?(:protected?) }
+ expose :protected?, as: :protected, if: ->(entity, _) { entity.respond_to?(:protected?) }
end
class Pipeline < PipelineBasic
@@ -1293,15 +1293,15 @@ module API
class LicenseBasic < Grape::Entity
expose :key, :name, :nickname
expose :url, as: :html_url
- expose(:source_url) { |license| license.meta['source'] }
+ expose(:source_url) { |license| license.meta["source"] }
end
class License < LicenseBasic
expose :popular?, as: :popular
- expose(:description) { |license| license.meta['description'] }
- expose(:conditions) { |license| license.meta['conditions'] }
- expose(:permissions) { |license| license.meta['permissions'] }
- expose(:limitations) { |license| license.meta['limitations'] }
+ expose(:description) { |license| license.meta["description"] }
+ expose(:conditions) { |license| license.meta["conditions"] }
+ expose(:permissions) { |license| license.meta["permissions"] }
+ expose(:limitations) { |license| license.meta["limitations"] }
expose :content
end
@@ -1348,7 +1348,7 @@ module API
expose :name
expose :state
expose :gates, using: FeatureGate do |model|
- model.gates.map do |gate|
+ model.gates.map { |gate|
value = model.gate_values[gate.key]
# By default all gate values are populated. Only show relevant ones.
@@ -1356,8 +1356,8 @@ module API
next
end
- { key: gate.key, value: value }
- end.compact
+ {key: gate.key, value: value}
+ }.compact
end
end
@@ -1532,7 +1532,7 @@ module API
class Badge < BasicBadgeDetails
expose :id
expose :kind do |badge|
- badge.type == 'ProjectBadge' ? 'project' : 'group'
+ badge.type == "ProjectBadge" ? "project" : "group"
end
end
diff --git a/lib/api/environments.rb b/lib/api/environments.rb
index 0278c6c54a5..b5dd47def3f 100644
--- a/lib/api/environments.rb
+++ b/lib/api/environments.rb
@@ -9,32 +9,32 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The project ID'
+ requires :id, type: String, desc: "The project ID"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all environments of the project' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Get all environments of the project" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Environment
end
params do
use :pagination
end
- get ':id/environments' do
+ get ":id/environments" do
authorize! :read_environment, user_project
present paginate(user_project.environments), with: Entities::Environment
end
- desc 'Creates a new environment' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Creates a new environment" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Environment
end
params do
- requires :name, type: String, desc: 'The name of the environment to be created'
- optional :external_url, type: String, desc: 'URL on which this deployment is viewable'
- optional :slug, absence: { message: "is automatically generated and cannot be changed" }
+ requires :name, type: String, desc: "The name of the environment to be created"
+ optional :external_url, type: String, desc: "URL on which this deployment is viewable"
+ optional :slug, absence: {message: "is automatically generated and cannot be changed"}
end
- post ':id/environments' do
+ post ":id/environments" do
authorize! :create_environment, user_project
environment = user_project.environments.create(declared_params)
@@ -46,17 +46,17 @@ module API
end
end
- desc 'Updates an existing environment' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Updates an existing environment" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Environment
end
params do
- requires :environment_id, type: Integer, desc: 'The environment ID'
- optional :name, type: String, desc: 'The new environment name'
- optional :external_url, type: String, desc: 'The new URL on which this deployment is viewable'
- optional :slug, absence: { message: "is automatically generated and cannot be changed" }
+ requires :environment_id, type: Integer, desc: "The environment ID"
+ optional :name, type: String, desc: "The new environment name"
+ optional :external_url, type: String, desc: "The new URL on which this deployment is viewable"
+ optional :slug, absence: {message: "is automatically generated and cannot be changed"}
end
- put ':id/environments/:environment_id' do
+ put ":id/environments/:environment_id" do
authorize! :update_environment, user_project
environment = user_project.environments.find(params[:environment_id])
@@ -69,14 +69,14 @@ module API
end
end
- desc 'Deletes an existing environment' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Deletes an existing environment" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Environment
end
params do
- requires :environment_id, type: Integer, desc: 'The environment ID'
+ requires :environment_id, type: Integer, desc: "The environment ID"
end
- delete ':id/environments/:environment_id' do
+ delete ":id/environments/:environment_id" do
authorize! :update_environment, user_project
environment = user_project.environments.find(params[:environment_id])
@@ -84,13 +84,13 @@ module API
destroy_conditionally!(environment)
end
- desc 'Stops an existing environment' do
+ desc "Stops an existing environment" do
success Entities::Environment
end
params do
- requires :environment_id, type: Integer, desc: 'The environment ID'
+ requires :environment_id, type: Integer, desc: "The environment ID"
end
- post ':id/environments/:environment_id/stop' do
+ post ":id/environments/:environment_id/stop" do
authorize! :read_environment, user_project
environment = user_project.environments.find(params[:environment_id])
diff --git a/lib/api/events.rb b/lib/api/events.rb
index b98aa9f31e1..0dcd2d0396b 100644
--- a/lib/api/events.rb
+++ b/lib/api/events.rb
@@ -7,15 +7,15 @@ module API
helpers do
params :event_filter_params do
- optional :action, type: String, values: Event.actions, desc: 'Event action to filter on'
- optional :target_type, type: String, values: Event.target_types, desc: 'Event target type to filter on'
- optional :before, type: Date, desc: 'Include only events created before this date'
- optional :after, type: Date, desc: 'Include only events created after this date'
+ optional :action, type: String, values: Event.actions, desc: "Event action to filter on"
+ optional :target_type, type: String, values: Event.target_types, desc: "Event target type to filter on"
+ optional :before, type: Date, desc: "Include only events created before this date"
+ optional :after, type: Date, desc: "Include only events created after this date"
end
params :sort_params do
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return events sorted in ascending and descending order'
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return events sorted in ascending and descending order"
end
def present_events(events)
@@ -30,10 +30,10 @@ module API
end
resource :events do
- allow_access_with_scope :read_user, if: -> (request) { request.get? }
+ allow_access_with_scope :read_user, if: ->(request) { request.get? }
desc "List currently authenticated user's events" do
- detail 'This feature was introduced in GitLab 9.3.'
+ detail "This feature was introduced in GitLab 9.3."
success Entities::Event
end
params do
@@ -52,13 +52,13 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID or Username of the user'
+ requires :id, type: String, desc: "The ID or Username of the user"
end
resource :users do
- allow_access_with_scope :read_user, if: -> (request) { request.get? }
+ allow_access_with_scope :read_user, if: ->(request) { request.get? }
- desc 'Get the contribution events of a specified user' do
- detail 'This feature was introduced in GitLab 8.13.'
+ desc "Get the contribution events of a specified user" do
+ detail "This feature was introduced in GitLab 8.13."
success Entities::Event
end
params do
@@ -67,9 +67,9 @@ module API
use :sort_params
end
- get ':id/events' do
+ get ":id/events" do
user = find_user(params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
events = find_events(user)
@@ -78,7 +78,7 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "List a Project's visible events" do
diff --git a/lib/api/features.rb b/lib/api/features.rb
index 4dc1834c644..3beccec88bf 100644
--- a/lib/api/features.rb
+++ b/lib/api/features.rb
@@ -7,9 +7,9 @@ module API
helpers do
def gate_value(params)
case params[:value]
- when 'true'
+ when "true"
true
- when '0', 'false'
+ when "0", "false"
false
else
params[:value].to_i
@@ -26,7 +26,7 @@ module API
end
resource :features do
- desc 'Get a list of all features' do
+ desc "Get a list of all features" do
success Entities::Feature
end
get do
@@ -35,17 +35,17 @@ module API
present features, with: Entities::Feature, current_user: current_user
end
- desc 'Set the gate value for the given feature' do
+ desc "Set the gate value for the given feature" do
success Entities::Feature
end
params do
- requires :value, type: String, desc: '`true` or `false` to enable/disable, an integer for percentage of time'
- optional :feature_group, type: String, desc: 'A Feature group name'
- optional :user, type: String, desc: 'A GitLab username'
+ requires :value, type: String, desc: "`true` or `false` to enable/disable, an integer for percentage of time"
+ optional :feature_group, type: String, desc: "A Feature group name"
+ optional :user, type: String, desc: "A GitLab username"
optional :group, type: String, desc: "A GitLab group's path, such as 'gitlab-org'"
- optional :project, type: String, desc: 'A projects path, like gitlab-org/gitlab-ce'
+ optional :project, type: String, desc: "A projects path, like gitlab-org/gitlab-ce"
end
- post ':name' do
+ post ":name" do
feature = Feature.get(params[:name])
targets = gate_targets(params)
value = gate_value(params)
@@ -70,8 +70,8 @@ module API
present feature, with: Entities::Feature, current_user: current_user
end
- desc 'Remove the gate value for the given feature'
- delete ':name' do
+ desc "Remove the gate value for the given feature"
+ delete ":name" do
Feature.get(params[:name]).remove
status 204
diff --git a/lib/api/files.rb b/lib/api/files.rb
index ca59d330e1c..c40fd29490e 100644
--- a/lib/api/files.rb
+++ b/lib/api/files.rb
@@ -22,7 +22,7 @@ module API
file_content_encoding: attrs[:encoding],
author_email: attrs[:author_email],
author_name: attrs[:author_name],
- last_commit_sha: attrs[:last_commit_id]
+ last_commit_sha: attrs[:last_commit_id],
}
end
@@ -30,19 +30,19 @@ module API
authorize! :download_code, user_project
@commit = user_project.commit(params[:ref])
- not_found!('Commit') unless @commit
+ not_found!("Commit") unless @commit
@repo = user_project.repository
@blob = @repo.blob_at(@commit.sha, params[:file_path])
- not_found!('File') unless @blob
+ not_found!("File") unless @blob
@blob.load_all_data!
end
def commit_response(attrs)
{
file_path: attrs[:file_path],
- branch: attrs[:branch]
+ branch: attrs[:branch],
}
end
@@ -56,37 +56,37 @@ module API
ref: params[:ref],
blob_id: @blob.id,
commit_id: @commit.id,
- last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path])
+ last_commit_id: @repo.last_commit_id_for_path(@commit.sha, params[:file_path]),
}
end
params :simple_file_params do
- requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :branch, type: String, desc: 'Name of the branch to commit into. To create a new branch, also provide `start_branch`.', allow_blank: false
- requires :commit_message, type: String, allow_blank: false, desc: 'Commit message'
- optional :start_branch, type: String, desc: 'Name of the branch to start the new commit from'
- optional :author_email, type: String, desc: 'The email of the author'
- optional :author_name, type: String, desc: 'The name of the author'
+ requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb"
+ requires :branch, type: String, desc: "Name of the branch to commit into. To create a new branch, also provide `start_branch`.", allow_blank: false
+ requires :commit_message, type: String, allow_blank: false, desc: "Commit message"
+ optional :start_branch, type: String, desc: "Name of the branch to start the new commit from"
+ optional :author_email, type: String, desc: "The email of the author"
+ optional :author_name, type: String, desc: "The name of the author"
end
params :extended_file_params do
use :simple_file_params
- requires :content, type: String, desc: 'File content'
- optional :encoding, type: String, values: %w[base64], desc: 'File encoding'
- optional :last_commit_id, type: String, desc: 'Last known commit id for this file'
+ requires :content, type: String, desc: "File content"
+ optional :encoding, type: String, values: %w[base64], desc: "File encoding"
+ optional :last_commit_id, type: String, desc: "Last known commit id for this file"
end
end
params do
- requires :id, type: String, desc: 'The project ID'
+ requires :id, type: String, desc: "The project ID"
end
resource :projects, requirements: FILE_ENDPOINT_REQUIREMENTS do
- allow_access_with_scope :read_repository, if: -> (request) { request.get? || request.head? }
+ allow_access_with_scope :read_repository, if: ->(request) { request.get? || request.head? }
- desc 'Get raw file metadata from repository'
+ desc "Get raw file metadata from repository"
params do
- requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
+ requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb"
+ requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false
end
head ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
assign_file_vars!
@@ -94,10 +94,10 @@ module API
set_http_headers(blob_data)
end
- desc 'Get raw file contents from the repository'
+ desc "Get raw file contents from the repository"
params do
- requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :ref, type: String, desc: 'The name of branch, tag commit', allow_blank: false
+ requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb"
+ requires :ref, type: String, desc: "The name of branch, tag commit", allow_blank: false
end
get ":id/repository/files/:file_path/raw", requirements: FILE_ENDPOINT_REQUIREMENTS do
assign_file_vars!
@@ -107,10 +107,10 @@ module API
send_git_blob @repo, @blob
end
- desc 'Get file metadata from repository'
+ desc "Get file metadata from repository"
params do
- requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
+ requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb"
+ requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false
end
head ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
assign_file_vars!
@@ -118,10 +118,10 @@ module API
set_http_headers(blob_data)
end
- desc 'Get a file from the repository'
+ desc "Get a file from the repository"
params do
- requires :file_path, type: String, desc: 'The url encoded path to the file. Ex. lib%2Fclass%2Erb'
- requires :ref, type: String, desc: 'The name of branch, tag or commit', allow_blank: false
+ requires :file_path, type: String, desc: "The url encoded path to the file. Ex. lib%2Fclass%2Erb"
+ requires :ref, type: String, desc: "The name of branch, tag or commit", allow_blank: false
end
get ":id/repository/files/:file_path", requirements: FILE_ENDPOINT_REQUIREMENTS do
assign_file_vars!
@@ -133,7 +133,7 @@ module API
data.merge(content: Base64.strict_encode64(@blob.data))
end
- desc 'Create new file in repository'
+ desc "Create new file in repository"
params do
use :extended_file_params
end
@@ -151,7 +151,7 @@ module API
end
end
- desc 'Update existing file in repository'
+ desc "Update existing file in repository"
params do
use :extended_file_params
end
@@ -175,7 +175,7 @@ module API
end
end
- desc 'Delete an existing file in repository'
+ desc "Delete an existing file in repository"
params do
use :simple_file_params
end
diff --git a/lib/api/group_boards.rb b/lib/api/group_boards.rb
index 9a20ee8c8b9..0479b877e35 100644
--- a/lib/api/group_boards.rb
+++ b/lib/api/group_boards.rb
@@ -16,65 +16,65 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- segment ':id/boards' do
- desc 'Find a group board' do
- detail 'This feature was introduced in 10.6'
+ segment ":id/boards" do
+ desc "Find a group board" do
+ detail "This feature was introduced in 10.6"
success ::API::Entities::Board
end
- get '/:board_id' do
+ get "/:board_id" do
present board, with: ::API::Entities::Board
end
- desc 'Get all group boards' do
- detail 'This feature was introduced in 10.6'
+ desc "Get all group boards" do
+ detail "This feature was introduced in 10.6"
success Entities::Board
end
params do
use :pagination
end
- get '/' do
+ get "/" do
present paginate(board_parent.boards), with: Entities::Board
end
end
params do
- requires :board_id, type: Integer, desc: 'The ID of a board'
+ requires :board_id, type: Integer, desc: "The ID of a board"
end
- segment ':id/boards/:board_id' do
- desc 'Get the lists of a group board' do
- detail 'Does not include backlog and closed lists. This feature was introduced in 10.6'
+ segment ":id/boards/:board_id" do
+ desc "Get the lists of a group board" do
+ detail "Does not include backlog and closed lists. This feature was introduced in 10.6"
success Entities::List
end
params do
use :pagination
end
- get '/lists' do
+ get "/lists" do
present paginate(board_lists), with: Entities::List
end
- desc 'Get a list of a group board' do
- detail 'This feature was introduced in 10.6'
+ desc "Get a list of a group board" do
+ detail "This feature was introduced in 10.6"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a list'
+ requires :list_id, type: Integer, desc: "The ID of a list"
end
- get '/lists/:list_id' do
+ get "/lists/:list_id" do
present board_lists.find(params[:list_id]), with: Entities::List
end
- desc 'Create a new board list' do
- detail 'This feature was introduced in 10.6'
+ desc "Create a new board list" do
+ detail "This feature was introduced in 10.6"
success Entities::List
end
params do
use :list_creation_params
end
- post '/lists' do
+ post "/lists" do
authorize_list_type_resource!
authorize!(:admin_list, user_group)
@@ -82,15 +82,15 @@ module API
create_list
end
- desc 'Moves a board list to a new position' do
- detail 'This feature was introduced in 10.6'
+ desc "Moves a board list to a new position" do
+ detail "This feature was introduced in 10.6"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a list'
- requires :position, type: Integer, desc: 'The position of the list'
+ requires :list_id, type: Integer, desc: "The ID of a list"
+ requires :position, type: Integer, desc: "The position of the list"
end
- put '/lists/:list_id' do
+ put "/lists/:list_id" do
list = board_lists.find(params[:list_id])
authorize!(:admin_list, user_group)
@@ -98,12 +98,12 @@ module API
move_list(list)
end
- desc 'Delete a board list' do
- detail 'This feature was introduced in 10.6'
+ desc "Delete a board list" do
+ detail "This feature was introduced in 10.6"
success Entities::List
end
params do
- requires :list_id, type: Integer, desc: 'The ID of a board list'
+ requires :list_id, type: Integer, desc: "The ID of a board list"
end
delete "/lists/:list_id" do
authorize!(:admin_list, user_group)
diff --git a/lib/api/group_labels.rb b/lib/api/group_labels.rb
index 0dbc5f45a68..a78db7efe59 100644
--- a/lib/api/group_labels.rb
+++ b/lib/api/group_labels.rb
@@ -8,54 +8,54 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all labels of the group' do
- detail 'This feature was added in GitLab 11.8'
+ desc "Get all labels of the group" do
+ detail "This feature was added in GitLab 11.8"
success Entities::GroupLabel
end
params do
use :pagination
end
- get ':id/labels' do
+ get ":id/labels" do
get_labels(user_group, Entities::GroupLabel)
end
- desc 'Create a new label' do
- detail 'This feature was added in GitLab 11.8'
+ desc "Create a new label" do
+ detail "This feature was added in GitLab 11.8"
success Entities::GroupLabel
end
params do
use :label_create_params
end
- post ':id/labels' do
+ post ":id/labels" do
create_label(user_group, Entities::GroupLabel)
end
- desc 'Update an existing label. At least one optional parameter is required.' do
- detail 'This feature was added in GitLab 11.8'
+ desc "Update an existing label. At least one optional parameter is required." do
+ detail "This feature was added in GitLab 11.8"
success Entities::GroupLabel
end
params do
- requires :name, type: String, desc: 'The name of the label to be updated'
- optional :new_name, type: String, desc: 'The new name of the label'
+ requires :name, type: String, desc: "The name of the label to be updated"
+ optional :new_name, type: String, desc: "The new name of the label"
optional :color, type: String, desc: "The new color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names"
- optional :description, type: String, desc: 'The new description of label'
+ optional :description, type: String, desc: "The new description of label"
at_least_one_of :new_name, :color, :description
end
- put ':id/labels' do
+ put ":id/labels" do
update_label(user_group, Entities::GroupLabel)
end
- desc 'Delete an existing label' do
- detail 'This feature was added in GitLab 11.8'
+ desc "Delete an existing label" do
+ detail "This feature was added in GitLab 11.8"
success Entities::GroupLabel
end
params do
- requires :name, type: String, desc: 'The name of the label to be deleted'
+ requires :name, type: String, desc: "The name of the label to be deleted"
end
- delete ':id/labels' do
+ delete ":id/labels" do
delete_label(user_group)
end
end
diff --git a/lib/api/group_milestones.rb b/lib/api/group_milestones.rb
index d4287e4a7c4..1fa7889840f 100644
--- a/lib/api/group_milestones.rb
+++ b/lib/api/group_milestones.rb
@@ -10,10 +10,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a list of group milestones' do
+ desc "Get a list of group milestones" do
success Entities::Milestone
end
params do
@@ -23,11 +23,11 @@ module API
list_milestones_for(user_group)
end
- desc 'Get a single group milestone' do
+ desc "Get a single group milestone" do
success Entities::Milestone
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a group milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a group milestone"
end
get ":id/milestones/:milestone_id" do
authorize! :read_group, user_group
@@ -35,11 +35,11 @@ module API
get_milestone_for(user_group)
end
- desc 'Create a new group milestone' do
+ desc "Create a new group milestone" do
success Entities::Milestone
end
params do
- requires :title, type: String, desc: 'The title of the milestone'
+ requires :title, type: String, desc: "The title of the milestone"
use :optional_params
end
post ":id/milestones" do
@@ -48,7 +48,7 @@ module API
create_milestone_for(user_group)
end
- desc 'Update an existing group milestone' do
+ desc "Update an existing group milestone" do
success Entities::Milestone
end
params do
@@ -60,7 +60,7 @@ module API
update_milestone_for(user_group)
end
- desc 'Remove a project milestone'
+ desc "Remove a project milestone"
delete ":id/milestones/:milestone_id" do
authorize! :admin_milestone, user_group
@@ -70,26 +70,26 @@ module API
status(204)
end
- desc 'Get all issues for a single group milestone' do
+ desc "Get all issues for a single group milestone" do
success Entities::IssueBasic
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a group milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a group milestone"
use :pagination
end
get ":id/milestones/:milestone_id/issues" do
milestone_issuables_for(user_group, :issue)
end
- desc 'Get all merge requests for a single group milestone' do
- detail 'This feature was introduced in GitLab 9.'
+ desc "Get all merge requests for a single group milestone" do
+ detail "This feature was introduced in GitLab 9."
success Entities::MergeRequestBasic
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a group milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a group milestone"
use :pagination
end
- get ':id/milestones/:milestone_id/merge_requests' do
+ get ":id/milestones/:milestone_id/merge_requests" do
milestone_issuables_for(user_group, :merge_request)
end
end
diff --git a/lib/api/group_variables.rb b/lib/api/group_variables.rb
index 3f048e0dc56..a45353a907b 100644
--- a/lib/api/group_variables.rb
+++ b/lib/api/group_variables.rb
@@ -8,47 +8,47 @@ module API
before { authorize! :admin_build, user_group }
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get group-level variables' do
+ desc "Get group-level variables" do
success Entities::Variable
end
params do
use :pagination
end
- get ':id/variables' do
+ get ":id/variables" do
variables = user_group.variables
present paginate(variables), with: Entities::Variable
end
- desc 'Get a specific variable from a group' do
+ desc "Get a specific variable from a group" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
+ requires :key, type: String, desc: "The key of the variable"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/variables/:key' do
+ get ":id/variables/:key" do
key = params[:key]
variable = user_group.variables.find_by(key: key)
- break not_found!('GroupVariable') unless variable
+ break not_found!("GroupVariable") unless variable
present variable, with: Entities::Variable
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Create a new variable in a group' do
+ desc "Create a new variable in a group" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
- requires :value, type: String, desc: 'The value of the variable'
- optional :protected, type: String, desc: 'Whether the variable is protected'
+ requires :key, type: String, desc: "The key of the variable"
+ requires :value, type: String, desc: "The value of the variable"
+ optional :protected, type: String, desc: "Whether the variable is protected"
end
- post ':id/variables' do
+ post ":id/variables" do
variable_params = declared_params(include_missing: false)
variable = user_group.variables.create(variable_params)
@@ -60,19 +60,19 @@ module API
end
end
- desc 'Update an existing variable from a group' do
+ desc "Update an existing variable from a group" do
success Entities::Variable
end
params do
- optional :key, type: String, desc: 'The key of the variable'
- optional :value, type: String, desc: 'The value of the variable'
- optional :protected, type: String, desc: 'Whether the variable is protected'
+ optional :key, type: String, desc: "The key of the variable"
+ optional :value, type: String, desc: "The value of the variable"
+ optional :protected, type: String, desc: "Whether the variable is protected"
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/variables/:key' do
+ put ":id/variables/:key" do
variable = user_group.variables.find_by(key: params[:key])
- break not_found!('GroupVariable') unless variable
+ break not_found!("GroupVariable") unless variable
variable_params = declared_params(include_missing: false).except(:key)
@@ -84,16 +84,16 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete an existing variable from a group' do
+ desc "Delete an existing variable from a group" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
+ requires :key, type: String, desc: "The key of the variable"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/variables/:key' do
+ delete ":id/variables/:key" do
variable = user_group.variables.find_by(key: params[:key])
- not_found!('GroupVariable') unless variable
+ not_found!("GroupVariable") unless variable
destroy_conditionally!(variable)
end
diff --git a/lib/api/groups.rb b/lib/api/groups.rb
index 64958ff982a..c8042326cab 100644
--- a/lib/api/groups.rb
+++ b/lib/api/groups.rb
@@ -9,15 +9,16 @@ module API
helpers do
params :optional_params_ce do
- optional :description, type: String, desc: 'The description of the group'
+ optional :description, type: String, desc: "The description of the group"
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
default: Gitlab::VisibilityLevel.string_level(
- Gitlab::CurrentSettings.current_application_settings.default_group_visibility),
- desc: 'The visibility of the group'
- optional :lfs_enabled, type: Boolean, desc: 'Enable/disable LFS for the projects in this group'
- optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
- optional :share_with_group_lock, type: Boolean, desc: 'Prevent sharing a project with another group within this group'
+ Gitlab::CurrentSettings.current_application_settings.default_group_visibility
+ ),
+ desc: "The visibility of the group"
+ optional :lfs_enabled, type: Boolean, desc: "Enable/disable LFS for the projects in this group"
+ optional :request_access_enabled, type: Boolean, desc: "Allow users to request member access"
+ optional :share_with_group_lock, type: Boolean, desc: "Prevent sharing a project with another group within this group"
end
params :optional_params do
@@ -25,18 +26,18 @@ module API
end
params :statistics_params do
- optional :statistics, type: Boolean, default: false, desc: 'Include project statistics'
+ optional :statistics, type: Boolean, default: false, desc: "Include project statistics"
end
params :group_list_params do
use :statistics_params
- optional :skip_groups, type: Array[Integer], desc: 'Array of group ids to exclude from list'
- optional :all_available, type: Boolean, desc: 'Show all group that you have access to'
- optional :search, type: String, desc: 'Search for a specific group'
- optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user'
- optional :order_by, type: String, values: %w[name path id], default: 'name', desc: 'Order by name, path or id'
- optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)'
- optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'Minimum access level of authenticated user'
+ optional :skip_groups, type: Array[Integer], desc: "Array of group ids to exclude from list"
+ optional :all_available, type: Boolean, desc: "Show all group that you have access to"
+ optional :search, type: String, desc: "Search for a specific group"
+ optional :owned, type: Boolean, default: false, desc: "Limit by owned by authenticated user"
+ optional :order_by, type: String, values: %w[name path id], default: "name", desc: "Order by name, path or id"
+ optional :sort, type: String, values: %w[asc desc], default: "asc", desc: "Sort by asc (ascending) or desc (descending)"
+ optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: "Minimum access level of authenticated user"
use :pagination
end
@@ -50,7 +51,7 @@ module API
groups = GroupsFinder.new(current_user, find_params).execute
groups = groups.search(params[:search]) if params[:search].present?
groups = groups.where.not(id: params[:skip_groups]) if params[:skip_groups].present?
- order_options = { params[:order_by] => params[:sort] }
+ order_options = {params[:order_by] => params[:sort]}
order_options["id"] ||= "asc"
groups = groups.reorder(order_options)
@@ -62,7 +63,7 @@ module API
group = find_group!(params[:id])
options = {
only_owned: !params[:with_shared],
- include_subgroups: params[:include_subgroups]
+ include_subgroups: params[:include_subgroups],
}
projects = GroupProjectsFinder.new(
@@ -81,7 +82,7 @@ module API
options = {
with: Entities::Group,
current_user: current_user,
- statistics: params[:statistics] && current_user.admin?
+ statistics: params[:statistics] && current_user.admin?,
}
groups = groups.with_statistics if options[:statistics]
@@ -94,7 +95,7 @@ module API
resource :groups do
include CustomAttributesEndpoints
- desc 'Get a groups list' do
+ desc "Get a groups list" do
success Entities::Group
end
params do
@@ -106,15 +107,15 @@ module API
present_groups params, groups
end
- desc 'Create a group. Available only for users who can create groups.' do
+ desc "Create a group. Available only for users who can create groups." do
success Entities::Group
end
params do
- requires :name, type: String, desc: 'The name of the group'
- requires :path, type: String, desc: 'The path of the group'
+ requires :name, type: String, desc: "The name of the group"
+ requires :path, type: String, desc: "The path of the group"
if ::Group.supports_nested_objects?
- optional :parent_id, type: Integer, desc: 'The parent group id for creating nested group'
+ optional :parent_id, type: Integer, desc: "The parent group id for creating nested group"
end
use :optional_params
@@ -138,18 +139,18 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Update a group. Available only for users who can administrate groups.' do
+ desc "Update a group. Available only for users who can administrate groups." do
success Entities::Group
end
params do
- optional :name, type: String, desc: 'The name of the group'
- optional :path, type: String, desc: 'The path of the group'
+ optional :name, type: String, desc: "The name of the group"
+ optional :path, type: String, desc: "The path of the group"
use :optional_params
end
- put ':id' do
+ put ":id" do
group = find_group!(params[:id])
authorize! :admin_group, group
@@ -160,19 +161,19 @@ module API
end
end
- desc 'Get a single group, with containing projects.' do
+ desc "Get a single group, with containing projects." do
success Entities::GroupDetail
end
params do
use :with_custom_attributes
- optional :with_projects, type: Boolean, default: true, desc: 'Omit project details'
+ optional :with_projects, type: Boolean, default: true, desc: "Omit project details"
end
get ":id" do
group = find_group!(params[:id])
options = {
with: params[:with_projects] ? Entities::GroupDetail : Entities::Group,
- current_user: current_user
+ current_user: current_user,
}
group, options = with_custom_attributes(group, options)
@@ -180,12 +181,12 @@ module API
present group, options
end
- desc 'Remove a group.'
+ desc "Remove a group."
delete ":id" do
group = find_group!(params[:id])
authorize! :admin_group, group
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/46285')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/46285")
destroy_conditionally!(group) do |group|
::Groups::DestroyService.new(group, current_user).async_execute
end
@@ -193,26 +194,26 @@ module API
accepted!
end
- desc 'Get a list of projects in this group.' do
+ desc "Get a list of projects in this group." do
success Entities::Project
end
params do
- optional :archived, type: Boolean, default: false, desc: 'Limit by archived status'
+ optional :archived, type: Boolean, default: false, desc: "Limit by archived status"
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values,
- desc: 'Limit by visibility'
- optional :search, type: String, desc: 'Return list of authorized projects matching the search criteria'
+ desc: "Limit by visibility"
+ optional :search, type: String, desc: "Return list of authorized projects matching the search criteria"
optional :order_by, type: String, values: %w[id name path created_at updated_at last_activity_at],
- default: 'created_at', desc: 'Return projects ordered by field'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return projects sorted in ascending and descending order'
+ default: "created_at", desc: "Return projects ordered by field"
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return projects sorted in ascending and descending order"
optional :simple, type: Boolean, default: false,
- desc: 'Return only the ID, URL, name, and path of each project'
- optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user'
- optional :starred, type: Boolean, default: false, desc: 'Limit by starred status'
- optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature'
- optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature'
- optional :with_shared, type: Boolean, default: true, desc: 'Include projects shared to this group'
- optional :include_subgroups, type: Boolean, default: false, desc: 'Includes projects in subgroups of this group'
+ desc: "Return only the ID, URL, name, and path of each project"
+ optional :owned, type: Boolean, default: false, desc: "Limit by owned by authenticated user"
+ optional :starred, type: Boolean, default: false, desc: "Limit by starred status"
+ optional :with_issues_enabled, type: Boolean, default: false, desc: "Limit by enabled issues feature"
+ optional :with_merge_requests_enabled, type: Boolean, default: false, desc: "Limit by enabled merge requests feature"
+ optional :with_shared, type: Boolean, default: true, desc: "Include projects shared to this group"
+ optional :include_subgroups, type: Boolean, default: false, desc: "Includes projects in subgroups of this group"
use :pagination
use :with_custom_attributes
@@ -222,7 +223,7 @@ module API
options = {
with: params[:simple] ? Entities::BasicProjectDetails : Entities::Project,
- current_user: current_user
+ current_user: current_user,
}
projects, options = with_custom_attributes(projects, options)
@@ -230,7 +231,7 @@ module API
present options[:with].prepare_relation(projects), options
end
- desc 'Get a list of subgroups in this group.' do
+ desc "Get a list of subgroups in this group." do
success Entities::Group
end
params do
@@ -242,13 +243,13 @@ module API
present_groups params, groups
end
- desc 'Transfer a project to the group namespace. Available only for admin.' do
+ desc "Transfer a project to the group namespace. Available only for admin." do
success Entities::GroupDetail
end
params do
- requires :project_id, type: String, desc: 'The ID or path of the project'
+ requires :project_id, type: String, desc: "The ID or path of the project"
end
- post ":id/projects/:project_id", requirements: { project_id: /.+/ } do
+ post ":id/projects/:project_id", requirements: {project_id: /.+/} do
authenticated_as_admin!
group = find_group!(params[:id])
project = find_project!(params[:project_id])
diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb
index 54cd4cd9cdb..596c7e8b534 100644
--- a/lib/api/helpers.rb
+++ b/lib/api/helpers.rb
@@ -5,20 +5,24 @@ module API
include Gitlab::Utils
include Helpers::Pagination
- SUDO_HEADER = "HTTP_SUDO".freeze
+ SUDO_HEADER = "HTTP_SUDO"
SUDO_PARAM = :sudo
- API_USER_ENV = 'gitlab.api.user'.freeze
+ API_USER_ENV = "gitlab.api.user"
def declared_params(options = {})
- options = { include_parent_namespaces: false }.merge(options)
+ options = {include_parent_namespaces: false}.merge(options)
declared(params, options).to_h.symbolize_keys
end
def check_unmodified_since!(last_modified)
- if_unmodified_since = Time.parse(headers['If-Unmodified-Since']) rescue nil
+ if_unmodified_since = begin
+ Time.parse(headers["If-Unmodified-Since"])
+ rescue
+ nil
+ end
if if_unmodified_since && last_modified && last_modified > if_unmodified_since
- render_api_error!('412 Precondition Failed', 412)
+ render_api_error!("412 Precondition Failed", 412)
end
end
@@ -59,7 +63,7 @@ module API
# rubocop:enable Gitlab/ModuleWithInstanceVariables
def save_current_user_in_env(user)
- env[API_USER_ENV] = { user_id: user.id, username: user.username }
+ env[API_USER_ENV] = {user_id: user.id, username: user.username}
end
def sudo?
@@ -81,16 +85,17 @@ module API
def wiki_page
page = ProjectWiki.new(user_project, current_user).find_page(params[:slug])
- page || not_found!('Wiki Page')
+ page || not_found!("Wiki Page")
end
def available_labels_for(label_parent, include_ancestor_groups: true)
- search_params = { include_ancestor_groups: include_ancestor_groups }
+ search_params = {include_ancestor_groups: include_ancestor_groups}
if label_parent.is_a?(Project)
search_params[:project_id] = label_parent.id
else
- search_params.merge!(group_id: label_parent.id, only_group_labels: true)
+ search_params[:group_id] = label_parent.id
+ search_params[:only_group_labels] = true
end
LabelsFinder.new(current_user, search_params).execute
@@ -118,13 +123,13 @@ module API
if can?(current_user, :read_project, project)
project
else
- not_found!('Project')
+ not_found!("Project")
end
end
# rubocop: disable CodeReuse/ActiveRecord
def find_group(id)
- if id.to_s =~ /^\d+$/
+ if /^\d+$/.match?(id.to_s)
Group.find_by(id: id)
else
Group.find_by_full_path(id)
@@ -138,13 +143,13 @@ module API
if can?(current_user, :read_group, group)
group
else
- not_found!('Group')
+ not_found!("Group")
end
end
# rubocop: disable CodeReuse/ActiveRecord
def find_namespace(id)
- if id.to_s =~ /^\d+$/
+ if /^\d+$/.match?(id.to_s)
Namespace.find_by(id: id)
else
Namespace.find_by_full_path(id)
@@ -158,15 +163,15 @@ module API
if can?(current_user, :read_namespace, namespace)
namespace
else
- not_found!('Namespace')
+ not_found!("Namespace")
end
end
def find_branch!(branch_name)
if Gitlab::GitRefValidator.validate(branch_name)
- user_project.repository.find_branch(branch_name) || not_found!('Branch')
+ user_project.repository.find_branch(branch_name) || not_found!("Branch")
else
- render_api_error!('The branch refname is invalid', 400)
+ render_api_error!("The branch refname is invalid", 400)
end
end
@@ -187,7 +192,7 @@ module API
end
def find_project_snippet(id)
- finder_params = { project: user_project }
+ finder_params = {project: user_project}
SnippetsFinder.new(current_user, finder_params).find(id)
end
@@ -212,7 +217,7 @@ module API
end
def authenticate_by_gitlab_shell_token!
- input = params['secret_token'].try(:chomp)
+ input = params["secret_token"].try(:chomp)
unless Devise.secure_compare(secret_token, input)
unauthorized!
end
@@ -249,8 +254,8 @@ module API
end
def require_gitlab_workhorse!
- unless env['HTTP_GITLAB_WORKHORSE'].present?
- forbidden!('Request should be executed via GitLab Workhorse')
+ unless env["HTTP_GITLAB_WORKHORSE"].present?
+ forbidden!("Request should be executed via GitLab Workhorse")
end
end
@@ -300,72 +305,72 @@ module API
end
def order_options_with_tie_breaker
- order_options = { params[:order_by] => params[:sort] }
- order_options['id'] ||= 'desc'
+ order_options = {params[:order_by] => params[:sort]}
+ order_options["id"] ||= "desc"
order_options
end
# error helpers
def forbidden!(reason = nil)
- message = ['403 Forbidden']
+ message = ["403 Forbidden"]
message << " - #{reason}" if reason
- render_api_error!(message.join(' '), 403)
+ render_api_error!(message.join(" "), 403)
end
def bad_request!(attribute)
message = ["400 (Bad request)"]
message << "\"" + attribute.to_s + "\" not given" if attribute
- render_api_error!(message.join(' '), 400)
+ render_api_error!(message.join(" "), 400)
end
def not_found!(resource = nil)
message = ["404"]
message << resource if resource
message << "Not Found"
- render_api_error!(message.join(' '), 404)
+ render_api_error!(message.join(" "), 404)
end
def unauthorized!
- render_api_error!('401 Unauthorized', 401)
+ render_api_error!("401 Unauthorized", 401)
end
def not_allowed!
- render_api_error!('405 Method Not Allowed', 405)
+ render_api_error!("405 Method Not Allowed", 405)
end
def conflict!(message = nil)
- render_api_error!(message || '409 Conflict', 409)
+ render_api_error!(message || "409 Conflict", 409)
end
def file_to_large!
- render_api_error!('413 Request Entity Too Large', 413)
+ render_api_error!("413 Request Entity Too Large", 413)
end
def not_modified!
- render_api_error!('304 Not Modified', 304)
+ render_api_error!("304 Not Modified", 304)
end
def no_content!
- render_api_error!('204 No Content', 204)
+ render_api_error!("204 No Content", 204)
end
def accepted!
- render_api_error!('202 Accepted', 202)
+ render_api_error!("202 Accepted", 202)
end
def render_validation_error!(model)
if model.errors.any?
- render_api_error!(model.errors.messages || '400 Bad Request', 400)
+ render_api_error!(model.errors.messages || "400 Bad Request", 400)
end
end
def render_spam_error!
- render_api_error!({ error: 'Spam detected' }, 400)
+ render_api_error!({error: "Spam detected"}, 400)
end
def render_api_error!(message, status)
- error!({ 'message' => message }, status, header)
+ error!({"message" => message}, status, header)
end
def handle_api_exception(exception)
@@ -389,10 +394,10 @@ module API
if Rails.env.test?
message
else
- '500 Internal Server Error'
+ "500 Internal Server Error"
end
- rack_response({ 'message' => response_message }.to_json, 500)
+ rack_response({"message" => response_message}.to_json, 500)
end
# project helpers
@@ -404,7 +409,7 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
def project_finder_params
- finder_params = { without_deleted: true }
+ finder_params = {without_deleted: true}
finder_params[:owned] = true if params[:owned].present?
finder_params[:non_public] = true if params[:membership].present?
finder_params[:starred] = true if params[:starred].present?
@@ -419,16 +424,16 @@ module API
# file helpers
- def present_disk_file!(path, filename, content_type = 'application/octet-stream')
+ def present_disk_file!(path, filename, content_type = "application/octet-stream")
filename ||= File.basename(path)
- header['Content-Disposition'] = ::Gitlab::ContentDisposition.format(disposition: 'attachment', filename: filename)
- header['Content-Transfer-Encoding'] = 'binary'
+ header["Content-Disposition"] = ::Gitlab::ContentDisposition.format(disposition: "attachment", filename: filename)
+ header["Content-Transfer-Encoding"] = "binary"
content_type content_type
# Support download acceleration
- case headers['X-Sendfile-Type']
- when 'X-Sendfile'
- header['X-Sendfile'] = path
+ case headers["X-Sendfile-Type"]
+ when "X-Sendfile"
+ header["X-Sendfile"] = path
body
else
file path
@@ -469,11 +474,11 @@ module API
unauthorized! unless initial_current_user
unless initial_current_user.admin?
- forbidden!('Must be admin to use sudo')
+ forbidden!("Must be admin to use sudo")
end
unless access_token
- forbidden!('Must be authenticated using an OAuth or Personal Access Token to use sudo')
+ forbidden!("Must be authenticated using an OAuth or Personal Access Token to use sudo")
end
validate_access_token!(scopes: [:sudo])
@@ -493,9 +498,9 @@ module API
end
def send_git_blob(repository, blob)
- env['api.format'] = :txt
- content_type 'text/plain'
- header['Content-Disposition'] = ::Gitlab::ContentDisposition.format(disposition: 'inline', filename: blob.name)
+ env["api.format"] = :txt
+ content_type "text/plain"
+ header["Content-Disposition"] = ::Gitlab::ContentDisposition.format(disposition: "inline", filename: blob.name)
# Let Workhorse examine the content and determine the better content disposition
header[Gitlab::Workhorse::DETECT_HEADER] = "true"
@@ -515,8 +520,8 @@ module API
# `request`. We workaround this by defining methods that returns the right
# values.
def define_params_for_grape_middleware
- self.define_singleton_method(:request) { ActionDispatch::Request.new(env) }
- self.define_singleton_method(:params) { request.params.symbolize_keys }
+ define_singleton_method(:request) { ActionDispatch::Request.new(env) }
+ define_singleton_method(:params) { request.params.symbolize_keys }
end
# We could get a Grape or a standard Ruby exception. We should only report anything that
@@ -528,7 +533,7 @@ module API
end
def archived_param
- return 'only' if params[:archived]
+ return "only" if params[:archived]
params[:archived]
end
diff --git a/lib/api/helpers/badges_helpers.rb b/lib/api/helpers/badges_helpers.rb
index 46ce5b4e7b5..2f63a6ac37e 100644
--- a/lib/api/helpers/badges_helpers.rb
+++ b/lib/api/helpers/badges_helpers.rb
@@ -18,12 +18,12 @@ module API
def badge_source_params(source)
project = if source.is_a?(Project)
- source
- else
- GroupProjectsFinder.new(group: source, current_user: current_user).execute.first
- end
+ source
+ else
+ GroupProjectsFinder.new(group: source, current_user: current_user).execute.first
+ end
- { project: project }
+ {project: project}
end
end
end
diff --git a/lib/api/helpers/custom_attributes.rb b/lib/api/helpers/custom_attributes.rb
index 88208226c40..7e5775f115c 100644
--- a/lib/api/helpers/custom_attributes.rb
+++ b/lib/api/helpers/custom_attributes.rb
@@ -8,10 +8,10 @@ module API
included do
helpers do
params :with_custom_attributes do
- optional :with_custom_attributes, type: Boolean, default: false, desc: 'Include custom attributes in the response'
+ optional :with_custom_attributes, type: Boolean, default: false, desc: "Include custom attributes in the response"
optional :custom_attributes, type: Hash,
- desc: 'Filter with custom attributes'
+ desc: "Filter with custom attributes"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/api/helpers/custom_validators.rb b/lib/api/helpers/custom_validators.rb
index 1058f4e8a5e..6c62501cbc9 100644
--- a/lib/api/helpers/custom_validators.rb
+++ b/lib/api/helpers/custom_validators.rb
@@ -16,7 +16,7 @@ module API
value = params[attr_name]
return if value.is_a?(Integer) ||
- [IssuableFinder::FILTER_NONE, IssuableFinder::FILTER_ANY].include?(value.to_s.downcase)
+ [IssuableFinder::FILTER_NONE, IssuableFinder::FILTER_ANY].include?(value.to_s.downcase)
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)],
message: "should be an integer, 'None' or 'Any'"
diff --git a/lib/api/helpers/headers_helpers.rb b/lib/api/helpers/headers_helpers.rb
index 7553af9d156..3af44a230b3 100644
--- a/lib/api/helpers/headers_helpers.rb
+++ b/lib/api/helpers/headers_helpers.rb
@@ -9,7 +9,7 @@ module API
raise ArgumentError.new("Header value should be a string")
end
- header "X-Gitlab-#{key.to_s.split('_').collect(&:capitalize).join('-')}", value.to_s
+ header "X-Gitlab-#{key.to_s.split("_").collect(&:capitalize).join("-")}", value.to_s
end
end
end
diff --git a/lib/api/helpers/internal_helpers.rb b/lib/api/helpers/internal_helpers.rb
index fe78049af87..1e5e22417c9 100644
--- a/lib/api/helpers/internal_helpers.rb
+++ b/lib/api/helpers/internal_helpers.rb
@@ -19,7 +19,7 @@ module API
[
:read_project,
:download_code,
- :push_code
+ :push_code,
]
end
@@ -34,7 +34,7 @@ module API
def log_user_activity(actor)
commands = Gitlab::GitAccess::DOWNLOAD_COMMANDS
- ::Users::ActivityService.new(actor, 'Git SSH').execute if commands.include?(params[:action])
+ ::Users::ActivityService.new(actor, "Git SSH").execute if commands.include?(params[:action])
end
def merge_request_urls
@@ -44,7 +44,7 @@ module API
def redis_ping
result = Gitlab::Redis::SharedState.with { |redis| redis.ping }
- result == 'PONG'
+ result == "PONG"
rescue => e
Rails.logger.warn("GitLab: An unexpected error occurred in pinging to Redis: #{e}")
false
@@ -106,7 +106,7 @@ module API
{
repository: repository.gitaly_repository,
address: Gitlab::GitalyClient.address(project.repository_storage),
- token: Gitlab::GitalyClient.token(project.repository_storage)
+ token: Gitlab::GitalyClient.token(project.repository_storage),
}
end
end
diff --git a/lib/api/helpers/label_helpers.rb b/lib/api/helpers/label_helpers.rb
index c11e7d614ab..69cdc25aa00 100644
--- a/lib/api/helpers/label_helpers.rb
+++ b/lib/api/helpers/label_helpers.rb
@@ -6,16 +6,16 @@ module API
extend Grape::API::Helpers
params :label_create_params do
- requires :name, type: String, desc: 'The name of the label to be created'
+ requires :name, type: String, desc: "The name of the label to be created"
requires :color, type: String, desc: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names"
- optional :description, type: String, desc: 'The description of label to be created'
+ optional :description, type: String, desc: "The description of label to be created"
end
def find_label(parent, id, include_ancestor_groups: true)
labels = available_labels_for(parent, include_ancestor_groups: include_ancestor_groups)
label = labels.find_by_id(id) || labels.find_by_title(id)
- label || not_found!('Label')
+ label || not_found!("Label")
end
def get_labels(parent, entity)
@@ -26,7 +26,7 @@ module API
authorize! :admin_label, parent
label = available_labels_for(parent).find_by_title(params[:name])
- conflict!('Label already exists') if label
+ conflict!("Label already exists") if label
priority = params.delete(:priority)
label_params = declared_params(include_missing: false)
diff --git a/lib/api/helpers/members_helpers.rb b/lib/api/helpers/members_helpers.rb
index 73d58ee7f37..93b14278fb4 100644
--- a/lib/api/helpers/members_helpers.rb
+++ b/lib/api/helpers/members_helpers.rb
@@ -14,7 +14,7 @@ module API
end
def find_all_members(source_type, source)
- members = source_type == 'project' ? find_all_members_for_project(source) : find_all_members_for_group(source)
+ members = source_type == "project" ? find_all_members_for_project(source) : find_all_members_for_group(source)
members.non_invite
.non_request
end
@@ -28,7 +28,7 @@ module API
.compact
Member.includes(:user)
.joins(user: :project_authorizations)
- .where(project_authorizations: { project_id: project.id })
+ .where(project_authorizations: {project_id: project.id})
.where(source_id: source_ids)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -38,7 +38,7 @@ module API
source_ids = group.self_and_ancestors.pluck(:id)
Member.includes(:user)
.where(source_id: source_ids)
- .where(source_type: 'Namespace')
+ .where(source_type: "Namespace")
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/lib/api/helpers/notes_helpers.rb b/lib/api/helpers/notes_helpers.rb
index 216b2c45741..0d8aeb30d6a 100644
--- a/lib/api/helpers/notes_helpers.rb
+++ b/lib/api/helpers/notes_helpers.rb
@@ -9,7 +9,7 @@ module API
authorize! :admin_note, note
opts = {
- note: params[:body]
+ note: params[:body],
}
parent = noteable_parent(noteable)
project = parent if parent.is_a?(Project)
diff --git a/lib/api/helpers/pagination.rb b/lib/api/helpers/pagination.rb
index d00e61678b5..a125020d6eb 100644
--- a/lib/api/helpers/pagination.rb
+++ b/lib/api/helpers/pagination.rb
@@ -4,11 +4,11 @@ module API
module Helpers
module Pagination
def paginate(relation)
- strategy = if params[:pagination] == 'keyset' && Feature.enabled?('api_keyset_pagination')
- KeysetPaginationStrategy
- else
- DefaultPaginationStrategy
- end
+ strategy = if params[:pagination] == "keyset" && Feature.enabled?("api_keyset_pagination")
+ KeysetPaginationStrategy
+ else
+ DefaultPaginationStrategy
+ end
strategy.new(self).paginate(relation)
end
@@ -66,12 +66,12 @@ module API
# Sort direction (`:asc` or `:desc`)
def sort
@sort ||= if order_by_primary_key?
- # Default order is by id DESC
- :desc
- else
- # API defaults to DESC order if param `sort` not present
- request_context.params[:sort]&.to_sym || :desc
- end
+ # Default order is by id DESC
+ :desc
+ else
+ # API defaults to DESC order if param `sort` not present
+ request_context.params[:sort]&.to_sym || :desc
+ end
end
# Do we only sort by primary key?
@@ -100,9 +100,9 @@ module API
# All values present in request parameters that correspond to #keys.
def values
- @values ||= keys.map do |key|
+ @values ||= keys.map { |key|
request_context.params["ks_prev_#{key}".to_sym]
- end
+ }
end
# All keys relevant to pagination.
@@ -151,30 +151,30 @@ module API
return nil if fields.empty?
- placeholder = fields.map { '?' }
+ placeholder = fields.map { "?" }
comp = if pagination.sort_ascending?
- '>'
- else
- '<'
- end
+ ">"
+ else
+ "<"
+ end
[
# Row value comparison:
# (A, B) < (a, b) <=> (A < a) OR (A = a AND B < b)
# <=> A <= a AND ((A < a) OR (A = a AND B < b))
- "(#{fields.keys.join(',')}) #{comp} (#{placeholder.join(',')})",
- *fields.values
+ "(#{fields.keys.join(",")}) #{comp} (#{placeholder.join(",")})",
+ *fields.values,
]
end
def add_default_pagination_headers
- header 'X-Per-Page', per_page.to_s
+ header "X-Per-Page", per_page.to_s
end
def add_navigation_links(next_page_params)
- header 'X-Next-Page', page_href(next_page_params)
- header 'Link', link_for('next', next_page_params)
+ header "X-Next-Page", page_href(next_page_params)
+ header "Link", link_for("next", next_page_params)
end
def link_for(rel, next_page_params)
@@ -220,16 +220,16 @@ module API
end
def add_pagination_headers(paginated_data)
- header 'X-Per-Page', paginated_data.limit_value.to_s
- header 'X-Page', paginated_data.current_page.to_s
- header 'X-Next-Page', paginated_data.next_page.to_s
- header 'X-Prev-Page', paginated_data.prev_page.to_s
- header 'Link', pagination_links(paginated_data)
+ header "X-Per-Page", paginated_data.limit_value.to_s
+ header "X-Page", paginated_data.current_page.to_s
+ header "X-Next-Page", paginated_data.next_page.to_s
+ header "X-Prev-Page", paginated_data.prev_page.to_s
+ header "Link", pagination_links(paginated_data)
return if data_without_counts?(paginated_data)
- header 'X-Total', paginated_data.total_count.to_s
- header 'X-Total-Pages', total_pages(paginated_data).to_s
+ header "X-Total", paginated_data.total_count.to_s
+ header "X-Total-Pages", total_pages(paginated_data).to_s
end
def pagination_links(paginated_data)
@@ -239,7 +239,7 @@ module API
links << %(<#{page_href(page: 1)}>; rel="first")
links << %(<#{page_href(page: total_pages(paginated_data))}>; rel="last") unless data_without_counts?(paginated_data)
- end.join(', ')
+ end.join(", ")
end
def total_pages(paginated_data)
diff --git a/lib/api/helpers/projects_helpers.rb b/lib/api/helpers/projects_helpers.rb
index e6a72b949f9..07eb7f4a5d7 100644
--- a/lib/api/helpers/projects_helpers.rb
+++ b/lib/api/helpers/projects_helpers.rb
@@ -8,26 +8,26 @@ module API
included do
helpers do
params :optional_project_params_ce do
- optional :description, type: String, desc: 'The description of the project'
- optional :ci_config_path, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`'
- optional :issues_enabled, type: Boolean, desc: 'Flag indication if the issue tracker is enabled'
- optional :merge_requests_enabled, type: Boolean, desc: 'Flag indication if merge requests are enabled'
- optional :wiki_enabled, type: Boolean, desc: 'Flag indication if the wiki is enabled'
- optional :jobs_enabled, type: Boolean, desc: 'Flag indication if jobs are enabled'
- optional :snippets_enabled, type: Boolean, desc: 'Flag indication if snippets are enabled'
- optional :shared_runners_enabled, type: Boolean, desc: 'Flag indication if shared runners are enabled for that project'
- optional :resolve_outdated_diff_discussions, type: Boolean, desc: 'Automatically resolve merge request diffs discussions on lines changed with a push'
- optional :container_registry_enabled, type: Boolean, desc: 'Flag indication if the container registry is enabled for that project'
- optional :lfs_enabled, type: Boolean, desc: 'Flag indication if Git LFS is enabled for that project'
- optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The visibility of the project.'
- optional :public_builds, type: Boolean, desc: 'Perform public builds'
- optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
- optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
- optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: 'Only allow to merge if all discussions are resolved'
- optional :tag_list, type: Array[String], desc: 'The list of tags for a project'
- optional :avatar, type: File, desc: 'Avatar image for project'
- optional :printing_merge_request_link_enabled, type: Boolean, desc: 'Show link to create/view merge request when pushing from the command line'
- optional :merge_method, type: String, values: %w(ff rebase_merge merge), desc: 'The merge method used when merging merge requests'
+ optional :description, type: String, desc: "The description of the project"
+ optional :ci_config_path, type: String, desc: "The path to CI config file. Defaults to `.gitlab-ci.yml`"
+ optional :issues_enabled, type: Boolean, desc: "Flag indication if the issue tracker is enabled"
+ optional :merge_requests_enabled, type: Boolean, desc: "Flag indication if merge requests are enabled"
+ optional :wiki_enabled, type: Boolean, desc: "Flag indication if the wiki is enabled"
+ optional :jobs_enabled, type: Boolean, desc: "Flag indication if jobs are enabled"
+ optional :snippets_enabled, type: Boolean, desc: "Flag indication if snippets are enabled"
+ optional :shared_runners_enabled, type: Boolean, desc: "Flag indication if shared runners are enabled for that project"
+ optional :resolve_outdated_diff_discussions, type: Boolean, desc: "Automatically resolve merge request diffs discussions on lines changed with a push"
+ optional :container_registry_enabled, type: Boolean, desc: "Flag indication if the container registry is enabled for that project"
+ optional :lfs_enabled, type: Boolean, desc: "Flag indication if Git LFS is enabled for that project"
+ optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: "The visibility of the project."
+ optional :public_builds, type: Boolean, desc: "Perform public builds"
+ optional :request_access_enabled, type: Boolean, desc: "Allow users to request member access"
+ optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: "Only allow to merge if builds succeed"
+ optional :only_allow_merge_if_all_discussions_are_resolved, type: Boolean, desc: "Only allow to merge if all discussions are resolved"
+ optional :tag_list, type: Array[String], desc: "The list of tags for a project"
+ optional :avatar, type: File, desc: "Avatar image for project"
+ optional :printing_merge_request_link_enabled, type: Boolean, desc: "Show link to create/view merge request when pushing from the command line"
+ optional :merge_method, type: String, values: %w[ff rebase_merge merge], desc: "The merge method used when merging merge requests"
optional :initialize_with_readme, type: Boolean, desc: "Initialize a project with a README.md"
end
diff --git a/lib/api/helpers/related_resources_helpers.rb b/lib/api/helpers/related_resources_helpers.rb
index 793ae11b41d..7c4934da73b 100644
--- a/lib/api/helpers/related_resources_helpers.rb
+++ b/lib/api/helpers/related_resources_helpers.rb
@@ -20,7 +20,7 @@ module API
# Using a blank component at the beginning of the join we ensure
# that the resulted path will start with '/'. If the resulted path
# does not start with '/', URI::Generic#build will fail
- path_with_script_name = File.join('', [script_name, path].select(&:present?))
+ path_with_script_name = File.join("", [script_name, path].select(&:present?))
URI::Generic.build(scheme: protocol, host: host, port: port, path: path_with_script_name).to_s
end
diff --git a/lib/api/helpers/runner.rb b/lib/api/helpers/runner.rb
index ff73a49d5e8..4afa8183d89 100644
--- a/lib/api/helpers/runner.rb
+++ b/lib/api/helpers/runner.rb
@@ -3,12 +3,12 @@
module API
module Helpers
module Runner
- JOB_TOKEN_HEADER = 'HTTP_JOB_TOKEN'.freeze
+ JOB_TOKEN_HEADER = "HTTP_JOB_TOKEN"
JOB_TOKEN_PARAM = :token
def runner_registration_token_valid?
ActiveSupport::SecurityUtils.variable_size_secure_compare(params[:token],
- Gitlab::CurrentSettings.runners_registration_token)
+ Gitlab::CurrentSettings.runners_registration_token)
end
def authenticate_runner!
@@ -19,14 +19,14 @@ module API
end
def get_runner_details_from_request
- return get_runner_ip unless params['info'].present?
+ return get_runner_ip unless params["info"].present?
- attributes_for_keys(%w(name version revision platform architecture), params['info'])
+ attributes_for_keys(%w[name version revision platform architecture], params["info"])
.merge(get_runner_ip)
end
def get_runner_ip
- { ip_address: env["action_dispatch.remote_ip"].to_s || request.ip }
+ {ip_address: env["action_dispatch.remote_ip"].to_s || request.ip}
end
def current_runner
@@ -39,8 +39,8 @@ module API
yield if block_given?
project = job.project
- forbidden!('Project has been deleted!') if project.nil? || project.pending_delete?
- forbidden!('Job has been erased!') if job.erased?
+ forbidden!("Project has been deleted!") if project.nil? || project.pending_delete?
+ forbidden!("Job has been erased!") if job.erased?
end
def authenticate_job!
@@ -63,7 +63,7 @@ module API
end
def job_forbidden!(job, reason)
- header 'Job-Status', job.status
+ header "Job-Status", job.status
forbidden!(reason)
end
end
diff --git a/lib/api/helpers/version.rb b/lib/api/helpers/version.rb
index 7f53094e90c..2a80d5e71f5 100644
--- a/lib/api/helpers/version.rb
+++ b/lib/api/helpers/version.rb
@@ -9,12 +9,12 @@ module API
@version = version.to_s
unless API.versions.include?(version)
- raise ArgumentError, 'Unknown API version!'
+ raise ArgumentError, "Unknown API version!"
end
end
def root_path
- File.join('/', API.prefix.to_s, @version)
+ File.join("/", API.prefix.to_s, @version)
end
def root_url
diff --git a/lib/api/import_github.rb b/lib/api/import_github.rb
index bb4e536cf57..1638a9914b3 100644
--- a/lib/api/import_github.rb
+++ b/lib/api/import_github.rb
@@ -10,7 +10,7 @@ module API
end
def access_params
- { github_access_token: params[:personal_access_token] }
+ {github_access_token: params[:personal_access_token]}
end
def client_options
@@ -22,24 +22,24 @@ module API
end
end
- desc 'Import a GitHub project' do
- detail 'This feature was introduced in GitLab 11.3.4.'
+ desc "Import a GitHub project" do
+ detail "This feature was introduced in GitLab 11.3.4."
success Entities::ProjectEntity
end
params do
- requires :personal_access_token, type: String, desc: 'GitHub personal access token'
- requires :repo_id, type: Integer, desc: 'GitHub repository ID'
- optional :new_name, type: String, desc: 'New repo name'
- requires :target_namespace, type: String, desc: 'Namespace to import repo into'
+ requires :personal_access_token, type: String, desc: "GitHub personal access token"
+ requires :repo_id, type: Integer, desc: "GitHub repository ID"
+ optional :new_name, type: String, desc: "New repo name"
+ requires :target_namespace, type: String, desc: "Namespace to import repo into"
end
- post 'import/github' do
+ post "import/github" do
result = Import::GithubService.new(client, current_user, params).execute(access_params, provider)
if result[:status] == :success
present ProjectSerializer.new.represent(result[:project])
else
status result[:http_status]
- { errors: result[:message] }
+ {errors: result[:message]}
end
end
end
diff --git a/lib/api/internal.rb b/lib/api/internal.rb
index 70b32f7d758..88183d7f10a 100644
--- a/lib/api/internal.rb
+++ b/lib/api/internal.rb
@@ -8,16 +8,16 @@ module API
helpers ::API::Helpers::InternalHelpers
helpers ::Gitlab::Identifier
- UNKNOWN_CHECK_RESULT_ERROR = 'Unknown check result'.freeze
+ UNKNOWN_CHECK_RESULT_ERROR = "Unknown check result"
helpers do
def response_with_status(code: 200, success: true, message: nil, **extra_options)
status code
- { status: success, message: message }.merge(extra_options).compact
+ {status: success, message: message}.merge(extra_options).compact
end
end
- namespace 'internal' do
+ namespace "internal" do
# Check if git command is allowed for project
#
# Params:
@@ -84,9 +84,9 @@ module API
# This repository_path is a bogus value but gitlab-shell still requires
# its presence. https://gitlab.com/gitlab-org/gitlab-shell/issues/135
- repository_path: '/',
+ repository_path: "/",
- gitaly: gitaly_payload(params[:action])
+ gitaly: gitaly_payload(params[:action]),
}
# Custom option for git-receive-pack command
@@ -131,9 +131,9 @@ module API
#
# rubocop: disable CodeReuse/ActiveRecord
get "/authorized_keys" do
- fingerprint = params.fetch(:fingerprint) do
+ fingerprint = params.fetch(:fingerprint) {
Gitlab::InsecureKeyFingerprint.new(params.fetch(:key)).fingerprint
- end
+ }
key = Key.find_by(fingerprint: fingerprint)
not_found!("Key") if key.nil?
present key, with: Entities::SSHKey
@@ -163,7 +163,7 @@ module API
api_version: API.version,
gitlab_version: Gitlab::VERSION,
gitlab_rev: Gitlab.revision,
- redis: redis_ping
+ redis: redis_ping,
}
end
@@ -184,7 +184,7 @@ module API
end
# rubocop: disable CodeReuse/ActiveRecord
- post '/two_factor_recovery_codes' do
+ post "/two_factor_recovery_codes" do
status 200
if params[:key_id]
@@ -193,28 +193,28 @@ module API
if key
key.update_last_used_at
else
- break { 'success' => false, 'message' => 'Could not find the given key' }
+ break {"success" => false, "message" => "Could not find the given key"}
end
if key.is_a?(DeployKey)
- break { success: false, message: 'Deploy keys cannot be used to retrieve recovery codes' }
+ break {success: false, message: "Deploy keys cannot be used to retrieve recovery codes"}
end
user = key.user
unless user
- break { success: false, message: 'Could not find a user for the given key' }
+ break {success: false, message: "Could not find a user for the given key"}
end
elsif params[:user_id]
user = User.find_by(id: params[:user_id])
unless user
- break { success: false, message: 'Could not find the given user' }
+ break {success: false, message: "Could not find the given user"}
end
end
unless user.two_factor_enabled?
- break { success: false, message: 'Two-factor authentication is not enabled for this user' }
+ break {success: false, message: "Two-factor authentication is not enabled for this user"}
end
codes = nil
@@ -223,16 +223,16 @@ module API
codes = user.generate_otp_backup_codes!
end
- { success: true, recovery_codes: codes }
+ {success: true, recovery_codes: codes}
end
# rubocop: enable CodeReuse/ActiveRecord
- post '/pre_receive' do
+ post "/pre_receive" do
status 200
reference_counter_increased = Gitlab::ReferenceCounter.new(params[:gl_repository]).increase
- { reference_counter_increased: reference_counter_increased }
+ {reference_counter_increased: reference_counter_increased}
end
post "/notify_post_receive" do
@@ -249,7 +249,7 @@ module API
# end
end
- post '/post_receive' do
+ post "/post_receive" do
status 200
PostReceive.perform_async(params[:gl_repository], params[:identifier],
@@ -260,7 +260,7 @@ module API
output = {
merge_request_urls: merge_request_urls,
broadcast_message: broadcast_message,
- reference_counter_decreased: reference_counter_decreased
+ reference_counter_decreased: reference_counter_decreased,
}
project = Gitlab::GlRepository.parse(params[:gl_repository]).first
diff --git a/lib/api/issues.rb b/lib/api/issues.rb
index f43f4d961d6..a942c510c33 100644
--- a/lib/api/issues.rb
+++ b/lib/api/issues.rb
@@ -34,40 +34,40 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
params :issues_params do
- optional :labels, type: String, desc: 'Comma-separated list of label names'
- optional :milestone, type: String, desc: 'Milestone title'
- optional :order_by, type: String, values: %w[created_at updated_at], default: 'created_at',
- desc: 'Return issues ordered by `created_at` or `updated_at` fields.'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return issues sorted in `asc` or `desc` order.'
- optional :milestone, type: String, desc: 'Return issues for a specific milestone'
- optional :iids, type: Array[Integer], desc: 'The IID array of issues'
- optional :search, type: String, desc: 'Search issues for text present in the title, description, or any combination of these'
- optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
- optional :created_after, type: DateTime, desc: 'Return issues created after the specified time'
- optional :created_before, type: DateTime, desc: 'Return issues created before the specified time'
- optional :updated_after, type: DateTime, desc: 'Return issues updated after the specified time'
- optional :updated_before, type: DateTime, desc: 'Return issues updated before the specified time'
- optional :author_id, type: Integer, desc: 'Return issues which are authored by the user with the given ID'
+ optional :labels, type: String, desc: "Comma-separated list of label names"
+ optional :milestone, type: String, desc: "Milestone title"
+ optional :order_by, type: String, values: %w[created_at updated_at], default: "created_at",
+ desc: "Return issues ordered by `created_at` or `updated_at` fields."
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return issues sorted in `asc` or `desc` order."
+ optional :milestone, type: String, desc: "Return issues for a specific milestone"
+ optional :iids, type: Array[Integer], desc: "The IID array of issues"
+ optional :search, type: String, desc: "Search issues for text present in the title, description, or any combination of these"
+ optional :in, type: String, desc: "`title`, `description`, or a string joining them with comma"
+ optional :created_after, type: DateTime, desc: "Return issues created after the specified time"
+ optional :created_before, type: DateTime, desc: "Return issues created before the specified time"
+ optional :updated_after, type: DateTime, desc: "Return issues updated after the specified time"
+ optional :updated_before, type: DateTime, desc: "Return issues updated before the specified time"
+ optional :author_id, type: Integer, desc: "Return issues which are authored by the user with the given ID"
optional :assignee_id, types: [Integer, String], integer_none_any: true,
- desc: 'Return issues which are assigned to the user with the given ID'
+ desc: "Return issues which are assigned to the user with the given ID"
optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all],
- desc: 'Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`'
- optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji'
- optional :confidential, type: Boolean, desc: 'Filter confidential or public issues'
+ desc: "Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`"
+ optional :my_reaction_emoji, type: String, desc: "Return issues reacted by the authenticated user by the given emoji"
+ optional :confidential, type: Boolean, desc: "Filter confidential or public issues"
use :pagination
use :issues_params_ee
end
params :issue_params do
- optional :description, type: String, desc: 'The description of an issue'
- optional :assignee_ids, type: Array[Integer], desc: 'The array of user IDs to assign issue'
- optional :assignee_id, type: Integer, desc: '[Deprecated] The ID of a user to assign issue'
- optional :milestone_id, type: Integer, desc: 'The ID of a milestone to assign issue'
- optional :labels, type: String, desc: 'Comma-separated list of label names'
- optional :due_date, type: String, desc: 'Date string in the format YEAR-MONTH-DAY'
- optional :confidential, type: Boolean, desc: 'Boolean parameter if the issue should be confidential'
+ optional :description, type: String, desc: "The description of an issue"
+ optional :assignee_ids, type: Array[Integer], desc: "The array of user IDs to assign issue"
+ optional :assignee_id, type: Integer, desc: "[Deprecated] The ID of a user to assign issue"
+ optional :milestone_id, type: Integer, desc: "The ID of a milestone to assign issue"
+ optional :labels, type: String, desc: "Comma-separated list of label names"
+ optional :due_date, type: String, desc: "Date string in the format YEAR-MONTH-DAY"
+ optional :confidential, type: Boolean, desc: "Boolean parameter if the issue should be confidential"
optional :discussion_locked, type: Boolean, desc: " Boolean parameter indicating if the issue's discussion is locked"
use :issue_params_ee
@@ -79,20 +79,20 @@ module API
success Entities::IssueBasic
end
params do
- optional :state, type: String, values: %w[opened closed all], default: 'all',
- desc: 'Return opened, closed, or all issues'
+ optional :state, type: String, values: %w[opened closed all], default: "all",
+ desc: "Return opened, closed, or all issues"
use :issues_params
- optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all], default: 'created_by_me',
- desc: 'Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`'
+ optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all], default: "created_by_me",
+ desc: "Return issues for the given scope: `created_by_me`, `assigned_to_me` or `all`"
end
get do
- authenticate! unless params[:scope] == 'all'
+ authenticate! unless params[:scope] == "all"
issues = paginate(find_issues)
options = {
with: Entities::IssueBasic,
current_user: current_user,
- issuable_metadata: issuable_meta_data(issues, 'Issue')
+ issuable_metadata: issuable_meta_data(issues, "Issue"),
}
present issues, options
@@ -100,15 +100,15 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a list of group issues' do
+ desc "Get a list of group issues" do
success Entities::IssueBasic
end
params do
- optional :state, type: String, values: %w[opened closed all], default: 'all',
- desc: 'Return opened, closed, or all issues'
+ optional :state, type: String, values: %w[opened closed all], default: "all",
+ desc: "Return opened, closed, or all issues"
use :issues_params
end
get ":id/issues" do
@@ -119,7 +119,7 @@ module API
options = {
with: Entities::IssueBasic,
current_user: current_user,
- issuable_metadata: issuable_meta_data(issues, 'Issue')
+ issuable_metadata: issuable_meta_data(issues, "Issue"),
}
present issues, options
@@ -127,17 +127,17 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include TimeTrackingEndpoints
- desc 'Get a list of project issues' do
+ desc "Get a list of project issues" do
success Entities::IssueBasic
end
params do
- optional :state, type: String, values: %w[opened closed all], default: 'all',
- desc: 'Return opened, closed, or all issues'
+ optional :state, type: String, values: %w[opened closed all], default: "all",
+ desc: "Return opened, closed, or all issues"
use :issues_params
end
get ":id/issues" do
@@ -149,41 +149,41 @@ module API
with: Entities::IssueBasic,
current_user: current_user,
project: user_project,
- issuable_metadata: issuable_meta_data(issues, 'Issue')
+ issuable_metadata: issuable_meta_data(issues, "Issue"),
}
present issues, options
end
- desc 'Get a single project issue' do
+ desc "Get a single project issue" do
success Entities::Issue
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
get ":id/issues/:issue_iid", as: :api_v4_project_issue do
issue = find_project_issue(params[:issue_iid])
present issue, with: Entities::Issue, current_user: current_user, project: user_project
end
- desc 'Create a new project issue' do
+ desc "Create a new project issue" do
success Entities::Issue
end
params do
- requires :title, type: String, desc: 'The title of an issue'
+ requires :title, type: String, desc: "The title of an issue"
optional :created_at, type: DateTime,
- desc: 'Date time when the issue was created. Available only for admins and project owners.'
+ desc: "Date time when the issue was created. Available only for admins and project owners."
optional :merge_request_to_resolve_discussions_of, type: Integer,
- desc: 'The IID of a merge request for which to resolve discussions'
+ desc: "The IID of a merge request for which to resolve discussions"
optional :discussion_to_resolve, type: String,
- desc: 'The ID of a discussion to resolve, also pass `merge_request_to_resolve_discussions_of`'
+ desc: "The ID of a discussion to resolve, also pass `merge_request_to_resolve_discussions_of`"
optional :iid, type: Integer,
- desc: 'The internal ID of a project issue. Available only for admins and project owners.'
+ desc: "The internal ID of a project issue. Available only for admins and project owners."
use :issue_params
end
- post ':id/issues' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42320')
+ post ":id/issues" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42320")
authorize! :create_issue, user_project
@@ -195,11 +195,11 @@ module API
issue_params = convert_parameters_from_legacy_format(issue_params)
issue = ::Issues::CreateService.new(user_project,
- current_user,
- issue_params.merge(request: request, api: true)).execute
+ current_user,
+ issue_params.merge(request: request, api: true)).execute
if issue.spam?
- render_api_error!({ error: 'Spam detected' }, 400)
+ render_api_error!({error: "Spam detected"}, 400)
end
if issue.valid?
@@ -209,22 +209,22 @@ module API
end
end
- desc 'Update an existing issue' do
+ desc "Update an existing issue" do
success Entities::Issue
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
- optional :title, type: String, desc: 'The title of an issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
+ optional :title, type: String, desc: "The title of an issue"
optional :updated_at, type: DateTime,
- desc: 'Date time when the issue was updated. Available only for admins and project owners.'
- optional :state_event, type: String, values: %w[reopen close], desc: 'State of the issue'
+ desc: "Date time when the issue was updated. Available only for admins and project owners."
+ optional :state_event, type: String, values: %w[reopen close], desc: "State of the issue"
use :issue_params
at_least_one_of :title, :description, :assignee_ids, :assignee_id, :milestone_id, :discussion_locked,
- :labels, :created_at, :due_date, :confidential, :state_event
+ :labels, :created_at, :due_date, :confidential, :state_event
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/issues/:issue_iid' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42322')
+ put ":id/issues/:issue_iid" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42322")
issue = user_project.issues.find_by!(iid: params.delete(:issue_iid))
authorize! :update_issue, issue
@@ -239,8 +239,8 @@ module API
update_params = convert_parameters_from_legacy_format(update_params)
issue = ::Issues::UpdateService.new(user_project,
- current_user,
- update_params).execute(issue)
+ current_user,
+ update_params).execute(issue)
render_spam_error! if issue.spam?
@@ -252,22 +252,22 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Move an existing issue' do
+ desc "Move an existing issue" do
success Entities::Issue
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
- requires :to_project_id, type: Integer, desc: 'The ID of the new project'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
+ requires :to_project_id, type: Integer, desc: "The ID of the new project"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/issues/:issue_iid/move' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42323')
+ post ":id/issues/:issue_iid/move" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42323")
issue = user_project.issues.find_by(iid: params[:issue_iid])
- not_found!('Issue') unless issue
+ not_found!("Issue") unless issue
new_project = Project.find_by(id: params[:to_project_id])
- not_found!('Project') unless new_project
+ not_found!("Project") unless new_project
begin
issue = ::Issues::MoveService.new(user_project, current_user).execute(issue, new_project)
@@ -278,14 +278,14 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete a project issue'
+ desc "Delete a project issue"
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/issues/:issue_iid" do
issue = user_project.issues.find_by(iid: params[:issue_iid])
- not_found!('Issue') unless issue
+ not_found!("Issue") unless issue
authorize!(:destroy_issue, issue)
@@ -295,13 +295,13 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'List merge requests that are related to the issue' do
+ desc "List merge requests that are related to the issue" do
success Entities::MergeRequestBasic
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
- get ':id/issues/:issue_iid/related_merge_requests' do
+ get ":id/issues/:issue_iid/related_merge_requests" do
issue = find_project_issue(params[:issue_iid])
merge_requests = ::Issues::ReferencedMergeRequestsService.new(user_project, current_user)
@@ -314,14 +314,14 @@ module API
project: user_project
end
- desc 'List merge requests closing issue' do
+ desc "List merge requests closing issue" do
success Entities::MergeRequestBasic
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/issues/:issue_iid/closed_by' do
+ get ":id/issues/:issue_iid/closed_by" do
issue = find_project_issue(params[:issue_iid])
merge_request_ids = MergeRequestsClosingIssues.where(issue_id: issue).select(:merge_request_id)
@@ -331,31 +331,31 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'List participants for an issue' do
+ desc "List participants for an issue" do
success Entities::UserBasic
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
- get ':id/issues/:issue_iid/participants' do
+ get ":id/issues/:issue_iid/participants" do
issue = find_project_issue(params[:issue_iid])
participants = ::Kaminari.paginate_array(issue.participants)
present paginate(participants), with: Entities::UserBasic, current_user: current_user, project: user_project
end
- desc 'Get the user agent details for an issue' do
+ desc "Get the user agent details for an issue" do
success Entities::UserAgentDetail
end
params do
- requires :issue_iid, type: Integer, desc: 'The internal ID of a project issue'
+ requires :issue_iid, type: Integer, desc: "The internal ID of a project issue"
end
get ":id/issues/:issue_iid/user_agent_detail" do
authenticated_as_admin!
issue = find_project_issue(params[:issue_iid])
- break not_found!('UserAgentDetail') unless issue.user_agent_detail
+ break not_found!("UserAgentDetail") unless issue.user_agent_detail
present issue.user_agent_detail, with: Entities::UserAgentDetail
end
diff --git a/lib/api/job_artifacts.rb b/lib/api/job_artifacts.rb
index 933bd067e26..d100f2c431a 100644
--- a/lib/api/job_artifacts.rb
+++ b/lib/api/job_artifacts.rb
@@ -12,19 +12,19 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Download the artifacts archive from a job' do
- detail 'This feature was introduced in GitLab 8.10'
+ desc "Download the artifacts archive from a job" do
+ detail "This feature was introduced in GitLab 8.10"
end
params do
- requires :ref_name, type: String, desc: 'The ref from repository'
- requires :job, type: String, desc: 'The name for the job'
+ requires :ref_name, type: String, desc: "The ref from repository"
+ requires :job, type: String, desc: "The name for the job"
end
route_setting :authentication, job_token_allowed: true
- get ':id/jobs/artifacts/:ref_name/download',
- requirements: { ref_name: /.+/ } do
+ get ":id/jobs/artifacts/:ref_name/download",
+ requirements: {ref_name: /.+/} do
authorize_download_artifacts!
latest_build = user_project.latest_successful_build_for!(params[:job], params[:ref_name])
@@ -32,37 +32,37 @@ module API
present_carrierwave_file!(latest_build.artifacts_file)
end
- desc 'Download a specific file from artifacts archive from a ref' do
- detail 'This feature was introduced in GitLab 11.5'
+ desc "Download a specific file from artifacts archive from a ref" do
+ detail "This feature was introduced in GitLab 11.5"
end
params do
- requires :ref_name, type: String, desc: 'The ref from repository'
- requires :job, type: String, desc: 'The name for the job'
- requires :artifact_path, type: String, desc: 'Artifact path'
+ requires :ref_name, type: String, desc: "The ref from repository"
+ requires :job, type: String, desc: "The name for the job"
+ requires :artifact_path, type: String, desc: "Artifact path"
end
- get ':id/jobs/artifacts/:ref_name/raw/*artifact_path',
- format: false,
- requirements: { ref_name: /.+/ } do
+ get ":id/jobs/artifacts/:ref_name/raw/*artifact_path",
+ format: false,
+ requirements: {ref_name: /.+/} do
authorize_download_artifacts!
build = user_project.latest_successful_build_for!(params[:job], params[:ref_name])
path = Gitlab::Ci::Build::Artifacts::Path
- .new(params[:artifact_path])
+ .new(params[:artifact_path])
bad_request! unless path.valid?
send_artifacts_entry(build, path)
end
- desc 'Download the artifacts archive from a job' do
- detail 'This feature was introduced in GitLab 8.5'
+ desc "Download the artifacts archive from a job" do
+ detail "This feature was introduced in GitLab 8.5"
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
+ requires :job_id, type: Integer, desc: "The ID of a job"
end
route_setting :authentication, job_token_allowed: true
- get ':id/jobs/:job_id/artifacts' do
+ get ":id/jobs/:job_id/artifacts" do
authorize_download_artifacts!
build = find_build!(params[:job_id])
@@ -70,14 +70,14 @@ module API
present_carrierwave_file!(build.artifacts_file)
end
- desc 'Download a specific file from artifacts archive' do
- detail 'This feature was introduced in GitLab 10.0'
+ desc "Download a specific file from artifacts archive" do
+ detail "This feature was introduced in GitLab 10.0"
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
- requires :artifact_path, type: String, desc: 'Artifact path'
+ requires :job_id, type: Integer, desc: "The ID of a job"
+ requires :artifact_path, type: String, desc: "Artifact path"
end
- get ':id/jobs/:job_id/artifacts/*artifact_path', format: false do
+ get ":id/jobs/:job_id/artifacts/*artifact_path", format: false do
authorize_read_builds!
build = find_build!(params[:job_id])
@@ -91,13 +91,13 @@ module API
send_artifacts_entry(build, path)
end
- desc 'Keep the artifacts to prevent them from being deleted' do
+ desc "Keep the artifacts to prevent them from being deleted" do
success Entities::Job
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
+ requires :job_id, type: Integer, desc: "The ID of a job"
end
- post ':id/jobs/:job_id/artifacts/keep' do
+ post ":id/jobs/:job_id/artifacts/keep" do
authorize_update_builds!
build = find_build!(params[:job_id])
diff --git a/lib/api/jobs.rb b/lib/api/jobs.rb
index 59f0dbe8a9b..b30242bda9b 100644
--- a/lib/api/jobs.rb
+++ b/lib/api/jobs.rb
@@ -7,12 +7,12 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do
params :optional_scope do
- optional :scope, types: [String, Array[String]], desc: 'The scope of builds to show',
+ optional :scope, types: [String, Array[String]], desc: "The scope of builds to show",
values: ::CommitStatus::AVAILABLE_STATUSES,
coerce_with: ->(scope) {
case scope
@@ -23,13 +23,13 @@ module API
when ::Array
scope
else
- ['unknown']
+ ["unknown"]
end
}
end
end
- desc 'Get a projects jobs' do
+ desc "Get a projects jobs" do
success Entities::Job
end
params do
@@ -37,10 +37,10 @@ module API
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/jobs' do
+ get ":id/jobs" do
authorize_read_builds!
- builds = user_project.builds.order('id DESC')
+ builds = user_project.builds.order("id DESC")
builds = filter_builds(builds, params[:scope])
builds = builds.preload(:user, :job_artifacts_archive, :job_artifacts, :runner, pipeline: :project)
@@ -48,16 +48,16 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get pipeline jobs' do
+ desc "Get pipeline jobs" do
success Entities::Job
end
params do
- requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ requires :pipeline_id, type: Integer, desc: "The pipeline ID"
use :optional_scope
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/pipelines/:pipeline_id/jobs' do
+ get ":id/pipelines/:pipeline_id/jobs" do
authorize!(:read_pipeline, user_project)
pipeline = user_project.ci_pipelines.find(params[:pipeline_id])
authorize!(:read_build, pipeline)
@@ -70,13 +70,13 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a specific job of a project' do
+ desc "Get a specific job of a project" do
success Entities::Job
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
+ requires :job_id, type: Integer, desc: "The ID of a job"
end
- get ':id/jobs/:job_id' do
+ get ":id/jobs/:job_id" do
authorize_read_builds!
build = find_build!(params[:job_id])
@@ -87,30 +87,30 @@ module API
# TODO: We should use `present_disk_file!` and leave this implementation for backward compatibility (when build trace
# is saved in the DB instead of file). But before that, we need to consider how to replace the value of
# `runners_token` with some mask (like `xxxxxx`) when sending trace file directly by workhorse.
- desc 'Get a trace of a specific job of a project'
+ desc "Get a trace of a specific job of a project"
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
+ requires :job_id, type: Integer, desc: "The ID of a job"
end
- get ':id/jobs/:job_id/trace' do
+ get ":id/jobs/:job_id/trace" do
authorize_read_builds!
build = find_build!(params[:job_id])
- header 'Content-Disposition', "infile; filename=\"#{build.id}.log\""
- content_type 'text/plain'
- env['api.format'] = :binary
+ header "Content-Disposition", "infile; filename=\"#{build.id}.log\""
+ content_type "text/plain"
+ env["api.format"] = :binary
trace = build.trace.raw
body trace
end
- desc 'Cancel a specific job of a project' do
+ desc "Cancel a specific job of a project" do
success Entities::Job
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a job'
+ requires :job_id, type: Integer, desc: "The ID of a job"
end
- post ':id/jobs/:job_id/cancel' do
+ post ":id/jobs/:job_id/cancel" do
authorize_update_builds!
build = find_build!(params[:job_id])
@@ -121,47 +121,47 @@ module API
present build, with: Entities::Job
end
- desc 'Retry a specific build of a project' do
+ desc "Retry a specific build of a project" do
success Entities::Job
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a build'
+ requires :job_id, type: Integer, desc: "The ID of a build"
end
- post ':id/jobs/:job_id/retry' do
+ post ":id/jobs/:job_id/retry" do
authorize_update_builds!
build = find_build!(params[:job_id])
authorize!(:update_build, build)
- break forbidden!('Job is not retryable') unless build.retryable?
+ break forbidden!("Job is not retryable") unless build.retryable?
build = Ci::Build.retry(build, current_user)
present build, with: Entities::Job
end
- desc 'Erase job (remove artifacts and the trace)' do
+ desc "Erase job (remove artifacts and the trace)" do
success Entities::Job
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a build'
+ requires :job_id, type: Integer, desc: "The ID of a build"
end
- post ':id/jobs/:job_id/erase' do
+ post ":id/jobs/:job_id/erase" do
authorize_update_builds!
build = find_build!(params[:job_id])
authorize!(:erase_build, build)
- break forbidden!('Job is not erasable!') unless build.erasable?
+ break forbidden!("Job is not erasable!") unless build.erasable?
build.erase(erased_by: current_user)
present build, with: Entities::Job
end
- desc 'Trigger a actionable job (manual, delayed, etc)' do
+ desc "Trigger a actionable job (manual, delayed, etc)" do
success Entities::Job
- detail 'This feature was added in GitLab 8.11'
+ detail "This feature was added in GitLab 8.11"
end
params do
- requires :job_id, type: Integer, desc: 'The ID of a Job'
+ requires :job_id, type: Integer, desc: "The ID of a Job"
end
post ":id/jobs/:job_id/play" do
authorize_read_builds!
@@ -186,7 +186,7 @@ module API
available_statuses = ::CommitStatus::AVAILABLE_STATUSES
unknown = scope - available_statuses
- render_api_error!('Scope contains invalid value(s)', 400) unless unknown.empty?
+ render_api_error!("Scope contains invalid value(s)", 400) unless unknown.empty?
builds.where(status: available_statuses && scope)
end
diff --git a/lib/api/keys.rb b/lib/api/keys.rb
index d5280a0035d..404417bbdca 100644
--- a/lib/api/keys.rb
+++ b/lib/api/keys.rb
@@ -6,7 +6,7 @@ module API
before { authenticate! }
resource :keys do
- desc 'Get single ssh key by id. Only available to admin users' do
+ desc "Get single ssh key by id. Only available to admin users" do
success Entities::SSHKeyWithUser
end
get ":id" do
diff --git a/lib/api/labels.rb b/lib/api/labels.rb
index d729d3ee625..84d48d74263 100644
--- a/lib/api/labels.rb
+++ b/lib/api/labels.rb
@@ -8,52 +8,52 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all labels of the project' do
+ desc "Get all labels of the project" do
success Entities::ProjectLabel
end
params do
use :pagination
end
- get ':id/labels' do
+ get ":id/labels" do
get_labels(user_project, Entities::ProjectLabel)
end
- desc 'Create a new label' do
+ desc "Create a new label" do
success Entities::ProjectLabel
end
params do
use :label_create_params
- optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
+ optional :priority, type: Integer, desc: "The priority of the label", allow_blank: true
end
- post ':id/labels' do
+ post ":id/labels" do
create_label(user_project, Entities::ProjectLabel)
end
- desc 'Update an existing label. At least one optional parameter is required.' do
+ desc "Update an existing label. At least one optional parameter is required." do
success Entities::ProjectLabel
end
params do
- requires :name, type: String, desc: 'The name of the label to be updated'
- optional :new_name, type: String, desc: 'The new name of the label'
+ requires :name, type: String, desc: "The name of the label to be updated"
+ optional :new_name, type: String, desc: "The new name of the label"
optional :color, type: String, desc: "The new color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the allowed CSS color names"
- optional :description, type: String, desc: 'The new description of label'
- optional :priority, type: Integer, desc: 'The priority of the label', allow_blank: true
+ optional :description, type: String, desc: "The new description of label"
+ optional :priority, type: Integer, desc: "The priority of the label", allow_blank: true
at_least_one_of :new_name, :color, :description, :priority
end
- put ':id/labels' do
+ put ":id/labels" do
update_label(user_project, Entities::ProjectLabel)
end
- desc 'Delete an existing label' do
+ desc "Delete an existing label" do
success Entities::ProjectLabel
end
params do
- requires :name, type: String, desc: 'The name of the label to be deleted'
+ requires :name, type: String, desc: "The name of the label to be deleted"
end
- delete ':id/labels' do
+ delete ":id/labels" do
delete_label(user_project)
end
end
diff --git a/lib/api/lint.rb b/lib/api/lint.rb
index a7672021db0..a5995d6dcb3 100644
--- a/lib/api/lint.rb
+++ b/lib/api/lint.rb
@@ -3,20 +3,20 @@
module API
class Lint < Grape::API
namespace :ci do
- desc 'Validation of .gitlab-ci.yml content'
+ desc "Validation of .gitlab-ci.yml content"
params do
- requires :content, type: String, desc: 'Content of .gitlab-ci.yml'
+ requires :content, type: String, desc: "Content of .gitlab-ci.yml"
end
- post '/lint' do
+ post "/lint" do
error = Gitlab::Ci::YamlProcessor.validation_message(params[:content],
user: current_user)
status 200
if error.blank?
- { status: 'valid', errors: [] }
+ {status: "valid", errors: []}
else
- { status: 'invalid', errors: [error] }
+ {status: "invalid", errors: [error]}
end
end
end
diff --git a/lib/api/markdown.rb b/lib/api/markdown.rb
index de77bef43ce..41bddc820fb 100644
--- a/lib/api/markdown.rb
+++ b/lib/api/markdown.rb
@@ -12,7 +12,7 @@ module API
detail "This feature was introduced in GitLab 11.0."
end
post do
- context = { only_path: false, current_user: current_user }
+ context = {only_path: false, current_user: current_user}
context[:pipeline] = params[:gfm] ? :full : :plain_markdown
if params[:project]
@@ -25,7 +25,7 @@ module API
context[:skip_project_check] = true
end
- { html: Banzai.render_and_post_process(params[:text], context) }
+ {html: Banzai.render_and_post_process(params[:text], context)}
end
end
end
diff --git a/lib/api/members.rb b/lib/api/members.rb
index 461ffe71a62..e12be5cd0bc 100644
--- a/lib/api/members.rb
+++ b/lib/api/members.rb
@@ -13,11 +13,11 @@ module API
requires :id, type: String, desc: "The #{source_type} ID"
end
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Gets a list of group or project members viewable by the authenticated user.' do
+ desc "Gets a list of group or project members viewable by the authenticated user." do
success Entities::Member
end
params do
- optional :query, type: String, desc: 'A query string to search for members'
+ optional :query, type: String, desc: "A query string to search for members"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -32,11 +32,11 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Gets a list of group or project members viewable by the authenticated user, including those who gained membership through ancestor group.' do
+ desc "Gets a list of group or project members viewable by the authenticated user, including those who gained membership through ancestor group." do
success Entities::Member
end
params do
- optional :query, type: String, desc: 'A query string to search for members'
+ optional :query, type: String, desc: "A query string to search for members"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -51,11 +51,11 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Gets a member of a group or project.' do
+ desc "Gets a member of a group or project." do
success Entities::Member
end
params do
- requires :user_id, type: Integer, desc: 'The user ID of the member'
+ requires :user_id, type: Integer, desc: "The user ID of the member"
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id/members/:user_id" do
@@ -68,13 +68,13 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Adds a member to a group or project.' do
+ desc "Adds a member to a group or project." do
success Entities::Member
end
params do
- requires :user_id, type: Integer, desc: 'The user ID of the new member'
- requires :access_level, type: Integer, desc: 'A valid access level (defaults: `30`, developer access level)'
- optional :expires_at, type: DateTime, desc: 'Date string in the format YEAR-MONTH-DAY'
+ requires :user_id, type: Integer, desc: "The user ID of the new member"
+ requires :access_level, type: Integer, desc: "A valid access level (defaults: `30`, developer access level)"
+ optional :expires_at, type: DateTime, desc: "Date string in the format YEAR-MONTH-DAY"
end
# rubocop: disable CodeReuse/ActiveRecord
post ":id/members" do
@@ -82,10 +82,10 @@ module API
authorize_admin_source!(source_type, source)
member = source.members.find_by(user_id: params[:user_id])
- conflict!('Member already exists') if member
+ conflict!("Member already exists") if member
user = User.find_by_id(params[:user_id])
- not_found!('User') unless user
+ not_found!("User") unless user
member = source.add_user(user, params[:access_level], current_user: current_user, expires_at: params[:expires_at])
@@ -99,13 +99,13 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Updates a member of a group or project.' do
+ desc "Updates a member of a group or project." do
success Entities::Member
end
params do
- requires :user_id, type: Integer, desc: 'The user ID of the new member'
- requires :access_level, type: Integer, desc: 'A valid access level'
- optional :expires_at, type: DateTime, desc: 'Date string in the format YEAR-MONTH-DAY'
+ requires :user_id, type: Integer, desc: "The user ID of the new member"
+ requires :access_level, type: Integer, desc: "A valid access level"
+ optional :expires_at, type: DateTime, desc: "Date string in the format YEAR-MONTH-DAY"
end
# rubocop: disable CodeReuse/ActiveRecord
put ":id/members/:user_id" do
@@ -126,9 +126,9 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Removes a user from a group or project.'
+ desc "Removes a user from a group or project."
params do
- requires :user_id, type: Integer, desc: 'The user ID of the member'
+ requires :user_id, type: Integer, desc: "The user ID of the member"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/members/:user_id" do
diff --git a/lib/api/merge_request_diffs.rb b/lib/api/merge_request_diffs.rb
index 6ad30aa56e0..ba7e442a4a3 100644
--- a/lib/api/merge_request_diffs.rb
+++ b/lib/api/merge_request_diffs.rb
@@ -8,16 +8,16 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a list of merge request diff versions' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Get a list of merge request diff versions" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::MergeRequestDiff
end
params do
- requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
+ requires :merge_request_iid, type: Integer, desc: "The IID of a merge request"
use :pagination
end
get ":id/merge_requests/:merge_request_iid/versions" do
@@ -26,14 +26,14 @@ module API
present paginate(merge_request.merge_request_diffs.order_id_desc), with: Entities::MergeRequestDiff
end
- desc 'Get a single merge request diff version' do
- detail 'This feature was introduced in GitLab 8.12.'
+ desc "Get a single merge request diff version" do
+ detail "This feature was introduced in GitLab 8.12."
success Entities::MergeRequestDiffFull
end
params do
- requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
- requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
+ requires :merge_request_iid, type: Integer, desc: "The IID of a merge request"
+ requires :version_id, type: Integer, desc: "The ID of a merge request diff version"
end
get ":id/merge_requests/:merge_request_iid/versions/:version_id" do
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb
index 44f1e81caf2..71a61f38864 100644
--- a/lib/api/merge_requests.rb
+++ b/lib/api/merge_requests.rb
@@ -38,11 +38,11 @@ module API
args[:scope] = args[:scope].underscore if args[:scope]
merge_requests = MergeRequestsFinder.new(current_user, args).execute
- .reorder(order_options_with_tie_breaker)
+ .reorder(order_options_with_tie_breaker)
merge_requests = paginate(merge_requests)
- .preload(:source_project, :target_project)
+ .preload(:source_project, :target_project)
- return merge_requests if args[:view] == 'simple'
+ return merge_requests if args[:view] == "simple"
merge_requests
.preload(:notes, :author, :assignee, :milestone, :latest_merge_request_diff, :labels, :timelogs, metrics: [:latest_closed_by, :merged_by])
@@ -63,19 +63,19 @@ module API
end
def serializer_options_for(merge_requests)
- options = { with: Entities::MergeRequestBasic, current_user: current_user }
+ options = {with: Entities::MergeRequestBasic, current_user: current_user}
- if params[:view] == 'simple'
+ if params[:view] == "simple"
options[:with] = Entities::MergeRequestSimple
else
- options[:issuable_metadata] = issuable_meta_data(merge_requests, 'MergeRequest')
+ options[:issuable_metadata] = issuable_meta_data(merge_requests, "MergeRequest")
end
options
end
def authorize_push_to_merge_request!(merge_request)
- forbidden!('Source branch does not exist') unless
+ forbidden!("Source branch does not exist") unless
merge_request.source_branch_exists?
user_access = Gitlab::UserAccess.new(
@@ -83,50 +83,50 @@ module API
project: merge_request.source_project
)
- forbidden!('Cannot push to source branch') unless
+ forbidden!("Cannot push to source branch") unless
user_access.can_push_to_branch?(merge_request.source_branch)
end
params :merge_requests_params do
- optional :state, type: String, values: %w[opened closed locked merged all], default: 'all',
- desc: 'Return opened, closed, locked, merged, or all merge requests'
- optional :order_by, type: String, values: %w[created_at updated_at], default: 'created_at',
- desc: 'Return merge requests ordered by `created_at` or `updated_at` fields.'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return merge requests sorted in `asc` or `desc` order.'
- optional :milestone, type: String, desc: 'Return merge requests for a specific milestone'
- optional :labels, type: String, desc: 'Comma-separated list of label names'
- optional :created_after, type: DateTime, desc: 'Return merge requests created after the specified time'
- optional :created_before, type: DateTime, desc: 'Return merge requests created before the specified time'
- optional :updated_after, type: DateTime, desc: 'Return merge requests updated after the specified time'
- optional :updated_before, type: DateTime, desc: 'Return merge requests updated before the specified time'
- optional :view, type: String, values: %w[simple], desc: 'If simple, returns the `iid`, URL, title, description, and basic state of merge request'
- optional :author_id, type: Integer, desc: 'Return merge requests which are authored by the user with the given ID'
+ optional :state, type: String, values: %w[opened closed locked merged all], default: "all",
+ desc: "Return opened, closed, locked, merged, or all merge requests"
+ optional :order_by, type: String, values: %w[created_at updated_at], default: "created_at",
+ desc: "Return merge requests ordered by `created_at` or `updated_at` fields."
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return merge requests sorted in `asc` or `desc` order."
+ optional :milestone, type: String, desc: "Return merge requests for a specific milestone"
+ optional :labels, type: String, desc: "Comma-separated list of label names"
+ optional :created_after, type: DateTime, desc: "Return merge requests created after the specified time"
+ optional :created_before, type: DateTime, desc: "Return merge requests created before the specified time"
+ optional :updated_after, type: DateTime, desc: "Return merge requests updated after the specified time"
+ optional :updated_before, type: DateTime, desc: "Return merge requests updated before the specified time"
+ optional :view, type: String, values: %w[simple], desc: "If simple, returns the `iid`, URL, title, description, and basic state of merge request"
+ optional :author_id, type: Integer, desc: "Return merge requests which are authored by the user with the given ID"
optional :assignee_id, types: [Integer, String], integer_none_any: true,
- desc: 'Return merge requests which are assigned to the user with the given ID'
+ desc: "Return merge requests which are assigned to the user with the given ID"
optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all],
- desc: 'Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`'
- optional :my_reaction_emoji, type: String, desc: 'Return issues reacted by the authenticated user by the given emoji'
- optional :source_branch, type: String, desc: 'Return merge requests with the given source branch'
- optional :target_branch, type: String, desc: 'Return merge requests with the given target branch'
- optional :search, type: String, desc: 'Search merge requests for text present in the title, description, or any combination of these'
- optional :in, type: String, desc: '`title`, `description`, or a string joining them with comma'
- optional :wip, type: String, values: %w[yes no], desc: 'Search merge requests for WIP in the title'
+ desc: "Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`"
+ optional :my_reaction_emoji, type: String, desc: "Return issues reacted by the authenticated user by the given emoji"
+ optional :source_branch, type: String, desc: "Return merge requests with the given source branch"
+ optional :target_branch, type: String, desc: "Return merge requests with the given target branch"
+ optional :search, type: String, desc: "Search merge requests for text present in the title, description, or any combination of these"
+ optional :in, type: String, desc: "`title`, `description`, or a string joining them with comma"
+ optional :wip, type: String, values: %w[yes no], desc: "Search merge requests for WIP in the title"
use :pagination
end
end
resource :merge_requests do
- desc 'List merge requests' do
+ desc "List merge requests" do
success Entities::MergeRequestBasic
end
params do
use :merge_requests_params
- optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all], default: 'created_by_me',
- desc: 'Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`'
+ optional :scope, type: String, values: %w[created-by-me assigned-to-me created_by_me assigned_to_me all], default: "created_by_me",
+ desc: "Return merge requests for the given scope: `created_by_me`, `assigned_to_me` or `all`"
end
get do
- authenticate! unless params[:scope] == 'all'
+ authenticate! unless params[:scope] == "all"
merge_requests = find_merge_requests
present merge_requests, serializer_options_for(merge_requests)
@@ -134,10 +134,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a group'
+ requires :id, type: String, desc: "The ID of a group"
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a list of group merge requests' do
+ desc "Get a list of group merge requests" do
success Entities::MergeRequestBasic
end
params do
@@ -153,7 +153,7 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
include TimeTrackingEndpoints
@@ -176,25 +176,25 @@ module API
end
params :optional_params do
- optional :description, type: String, desc: 'The description of the merge request'
- optional :assignee_id, type: Integer, desc: 'The ID of a user to assign the merge request'
- optional :milestone_id, type: Integer, desc: 'The ID of a milestone to assign the merge request'
- optional :labels, type: String, desc: 'Comma-separated list of label names'
- optional :remove_source_branch, type: Boolean, desc: 'Delete source branch when merging'
- optional :allow_collaboration, type: Boolean, desc: 'Allow commits from members who can merge to the target branch'
- optional :allow_maintainer_to_push, type: Boolean, as: :allow_collaboration, desc: '[deprecated] See allow_collaboration'
- optional :squash, type: Grape::API::Boolean, desc: 'When true, the commits will be squashed into a single commit on merge'
+ optional :description, type: String, desc: "The description of the merge request"
+ optional :assignee_id, type: Integer, desc: "The ID of a user to assign the merge request"
+ optional :milestone_id, type: Integer, desc: "The ID of a milestone to assign the merge request"
+ optional :labels, type: String, desc: "Comma-separated list of label names"
+ optional :remove_source_branch, type: Boolean, desc: "Delete source branch when merging"
+ optional :allow_collaboration, type: Boolean, desc: "Allow commits from members who can merge to the target branch"
+ optional :allow_maintainer_to_push, type: Boolean, as: :allow_collaboration, desc: "[deprecated] See allow_collaboration"
+ optional :squash, type: Grape::API::Boolean, desc: "When true, the commits will be squashed into a single commit on merge"
use :optional_params_ee
end
end
- desc 'List merge requests' do
+ desc "List merge requests" do
success Entities::MergeRequestBasic
end
params do
use :merge_requests_params
- optional :iids, type: Array[Integer], desc: 'The IID array of merge requests'
+ optional :iids, type: Array[Integer], desc: "The IID array of merge requests"
end
get ":id/merge_requests" do
authorize! :read_merge_request, user_project
@@ -207,19 +207,19 @@ module API
present merge_requests, options
end
- desc 'Create a merge request' do
+ desc "Create a merge request" do
success Entities::MergeRequest
end
params do
- requires :title, type: String, desc: 'The title of the merge request'
- requires :source_branch, type: String, desc: 'The source branch'
- requires :target_branch, type: String, desc: 'The target branch'
+ requires :title, type: String, desc: "The title of the merge request"
+ requires :source_branch, type: String, desc: "The source branch"
+ requires :target_branch, type: String, desc: "The target branch"
optional :target_project_id, type: Integer,
- desc: 'The target project of the merge request defaults to the :id of the project'
+ desc: "The target project of the merge request defaults to the :id of the project"
use :optional_params
end
post ":id/merge_requests" do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42316')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42316")
authorize! :create_merge_request_from, user_project
@@ -235,9 +235,9 @@ module API
end
end
- desc 'Delete a merge request'
+ desc "Delete a merge request"
params do
- requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
+ requires :merge_request_iid, type: Integer, desc: "The IID of a merge request"
end
delete ":id/merge_requests/:merge_request_iid" do
merge_request = find_project_merge_request(params[:merge_request_iid])
@@ -250,15 +250,15 @@ module API
end
params do
- requires :merge_request_iid, type: Integer, desc: 'The IID of a merge request'
- optional :render_html, type: Boolean, desc: 'Returns the description and title rendered HTML'
- optional :include_diverged_commits_count, type: Boolean, desc: 'Returns the commits count behind the target branch'
- optional :include_rebase_in_progress, type: Boolean, desc: 'Returns whether a rebase operation is ongoing '
+ requires :merge_request_iid, type: Integer, desc: "The IID of a merge request"
+ optional :render_html, type: Boolean, desc: "Returns the description and title rendered HTML"
+ optional :include_diverged_commits_count, type: Boolean, desc: "Returns the commits count behind the target branch"
+ optional :include_rebase_in_progress, type: Boolean, desc: "Returns whether a rebase operation is ongoing "
end
- desc 'Get a single merge request' do
+ desc "Get a single merge request" do
success Entities::MergeRequest
end
- get ':id/merge_requests/:merge_request_iid' do
+ get ":id/merge_requests/:merge_request_iid" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
present merge_request,
@@ -270,59 +270,59 @@ module API
include_rebase_in_progress: params[:include_rebase_in_progress]
end
- desc 'Get the participants of a merge request' do
+ desc "Get the participants of a merge request" do
success Entities::UserBasic
end
- get ':id/merge_requests/:merge_request_iid/participants' do
+ get ":id/merge_requests/:merge_request_iid/participants" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
participants = ::Kaminari.paginate_array(merge_request.participants)
present paginate(participants), with: Entities::UserBasic
end
- desc 'Get the commits of a merge request' do
+ desc "Get the commits of a merge request" do
success Entities::Commit
end
- get ':id/merge_requests/:merge_request_iid/commits' do
+ get ":id/merge_requests/:merge_request_iid/commits" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
commits = ::Kaminari.paginate_array(merge_request.commits)
present paginate(commits), with: Entities::Commit
end
- desc 'Show the merge request changes' do
+ desc "Show the merge request changes" do
success Entities::MergeRequestChanges
end
- get ':id/merge_requests/:merge_request_iid/changes' do
+ get ":id/merge_requests/:merge_request_iid/changes" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
present merge_request, with: Entities::MergeRequestChanges, current_user: current_user, project: user_project
end
- desc 'Get the merge request pipelines' do
+ desc "Get the merge request pipelines" do
success Entities::PipelineBasic
end
- get ':id/merge_requests/:merge_request_iid/pipelines' do
+ get ":id/merge_requests/:merge_request_iid/pipelines" do
pipelines = merge_request_pipelines_with_access
present paginate(pipelines), with: Entities::PipelineBasic
end
- desc 'Update a merge request' do
+ desc "Update a merge request" do
success Entities::MergeRequest
end
params do
- optional :title, type: String, allow_blank: false, desc: 'The title of the merge request'
- optional :target_branch, type: String, allow_blank: false, desc: 'The target branch'
+ optional :title, type: String, allow_blank: false, desc: "The title of the merge request"
+ optional :target_branch, type: String, allow_blank: false, desc: "The target branch"
optional :state_event, type: String, values: %w[close reopen],
- desc: 'Status of the merge request'
- optional :discussion_locked, type: Boolean, desc: 'Whether the MR discussion is locked'
+ desc: "Status of the merge request"
+ optional :discussion_locked, type: Boolean, desc: "Whether the MR discussion is locked"
use :optional_params
at_least_one_of(*::API::MergeRequests.update_params_at_least_one_of)
end
- put ':id/merge_requests/:merge_request_iid' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42318')
+ put ":id/merge_requests/:merge_request_iid" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42318")
merge_request = find_merge_request_with_access(params.delete(:merge_request_iid), :update_merge_request)
@@ -338,21 +338,21 @@ module API
end
end
- desc 'Merge a merge request' do
+ desc "Merge a merge request" do
success Entities::MergeRequest
end
params do
- optional :merge_commit_message, type: String, desc: 'Custom merge commit message'
- optional :squash_commit_message, type: String, desc: 'Custom squash commit message'
+ optional :merge_commit_message, type: String, desc: "Custom merge commit message"
+ optional :squash_commit_message, type: String, desc: "Custom squash commit message"
optional :should_remove_source_branch, type: Boolean,
- desc: 'When true, the source branch will be deleted if possible'
+ desc: "When true, the source branch will be deleted if possible"
optional :merge_when_pipeline_succeeds, type: Boolean,
- desc: 'When true, this merge request will be merged when the pipeline succeeds'
- optional :sha, type: String, desc: 'When present, must have the HEAD SHA of the source branch'
- optional :squash, type: Grape::API::Boolean, desc: 'When true, the commits will be squashed into a single commit on merge'
+ desc: "When true, this merge request will be merged when the pipeline succeeds"
+ optional :sha, type: String, desc: "When present, must have the HEAD SHA of the source branch"
+ optional :squash, type: Grape::API::Boolean, desc: "When true, the commits will be squashed into a single commit on merge"
end
- put ':id/merge_requests/:merge_request_iid/merge' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42317')
+ put ":id/merge_requests/:merge_request_iid/merge" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42317")
merge_request = find_project_merge_request(params[:merge_request_iid])
merge_when_pipeline_succeeds = to_boolean(params[:merge_when_pipeline_succeeds])
@@ -363,7 +363,7 @@ module API
not_allowed! unless merge_request.mergeable_state?(skip_ci_check: merge_when_pipeline_succeeds)
- render_api_error!('Branch cannot be merged', 406) unless merge_request.mergeable?(skip_ci_check: merge_when_pipeline_succeeds)
+ render_api_error!("Branch cannot be merged", 406) unless merge_request.mergeable?(skip_ci_check: merge_when_pipeline_succeeds)
check_sha_param!(params, merge_request)
@@ -388,17 +388,17 @@ module API
present merge_request, with: Entities::MergeRequest, current_user: current_user, project: user_project
end
- desc 'Merge a merge request to its default temporary merge ref path'
+ desc "Merge a merge request to its default temporary merge ref path"
params do
- optional :merge_commit_message, type: String, desc: 'Custom merge commit message'
+ optional :merge_commit_message, type: String, desc: "Custom merge commit message"
end
- put ':id/merge_requests/:merge_request_iid/merge_to_ref' do
+ put ":id/merge_requests/:merge_request_iid/merge_to_ref" do
merge_request = find_project_merge_request(params[:merge_request_iid])
authorize! :admin_merge_request, user_project
merge_params = {
- commit_message: params[:merge_commit_message]
+ commit_message: params[:merge_commit_message],
}
result = ::MergeRequests::MergeToRefService
@@ -416,7 +416,7 @@ module API
desc 'Cancel merge if "Merge When Pipeline Succeeds" is enabled' do
success Entities::MergeRequest
end
- post ':id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds' do
+ post ":id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds" do
merge_request = find_project_merge_request(params[:merge_request_iid])
unauthorized! unless merge_request.can_cancel_merge_when_pipeline_succeeds?(current_user)
@@ -426,10 +426,10 @@ module API
.cancel(merge_request)
end
- desc 'Rebase the merge request against its target branch' do
- detail 'This feature was added in GitLab 11.6'
+ desc "Rebase the merge request against its target branch" do
+ detail "This feature was added in GitLab 11.6"
end
- put ':id/merge_requests/:merge_request_iid/rebase' do
+ put ":id/merge_requests/:merge_request_iid/rebase" do
merge_request = find_project_merge_request(params[:merge_request_iid])
authorize_push_to_merge_request!(merge_request)
@@ -439,13 +439,13 @@ module API
status :accepted
end
- desc 'List issues that will be closed on merge' do
+ desc "List issues that will be closed on merge" do
success Entities::MRNote
end
params do
use :pagination
end
- get ':id/merge_requests/:merge_request_iid/closes_issues' do
+ get ":id/merge_requests/:merge_request_iid/closes_issues" do
merge_request = find_merge_request_with_access(params[:merge_request_iid])
issues = ::Kaminari.paginate_array(merge_request.visible_closing_issues_for(current_user))
issues = paginate(issues)
diff --git a/lib/api/milestone_responses.rb b/lib/api/milestone_responses.rb
index a0ca39b69d4..d2e31a1b57c 100644
--- a/lib/api/milestone_responses.rb
+++ b/lib/api/milestone_responses.rb
@@ -7,24 +7,24 @@ module API
included do
helpers do
params :optional_params do
- optional :description, type: String, desc: 'The description of the milestone'
- optional :due_date, type: String, desc: 'The due date of the milestone. The ISO 8601 date format (%Y-%m-%d)'
- optional :start_date, type: String, desc: 'The start date of the milestone. The ISO 8601 date format (%Y-%m-%d)'
+ optional :description, type: String, desc: "The description of the milestone"
+ optional :due_date, type: String, desc: "The due date of the milestone. The ISO 8601 date format (%Y-%m-%d)"
+ optional :start_date, type: String, desc: "The start date of the milestone. The ISO 8601 date format (%Y-%m-%d)"
end
params :list_params do
- optional :state, type: String, values: %w[active closed all], default: 'all',
+ optional :state, type: String, values: %w[active closed all], default: "all",
desc: 'Return "active", "closed", or "all" milestones'
- optional :iids, type: Array[Integer], desc: 'The IIDs of the milestones'
- optional :search, type: String, desc: 'The search criteria for the title or description of the milestone'
+ optional :iids, type: Array[Integer], desc: "The IIDs of the milestones"
+ optional :search, type: String, desc: "The search criteria for the title or description of the milestone"
use :pagination
end
params :update_params do
- requires :milestone_id, type: Integer, desc: 'The milestone ID number'
- optional :title, type: String, desc: 'The title of the milestone'
+ requires :milestone_id, type: Integer, desc: "The milestone ID number"
+ optional :title, type: String, desc: "The title of the milestone"
optional :state_event, type: String, values: %w[close activate],
- desc: 'The state event of the milestone '
+ desc: "The state event of the milestone "
use :optional_params
at_least_one_of :title, :description, :start_date, :due_date, :state_event
end
@@ -78,7 +78,7 @@ module API
end
def build_finder_params(milestone, parent)
- finder_params = { milestone_title: milestone.title, sort: 'label_priority' }
+ finder_params = {milestone_title: milestone.title, sort: "label_priority"}
if parent.is_a?(Group)
finder_params.merge(group_id: parent.id)
diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb
index 3cc09f6ac3f..4e743b74468 100644
--- a/lib/api/namespaces.rb
+++ b/lib/api/namespaces.rb
@@ -18,7 +18,7 @@ module API
end
resource :namespaces do
- desc 'Get a namespaces list' do
+ desc "Get a namespaces list" do
success Entities::Namespace
end
params do
@@ -32,18 +32,18 @@ module API
namespaces = namespaces.search(params[:search]) if params[:search].present?
- options = { with: Entities::Namespace, current_user: current_user }
+ options = {with: Entities::Namespace, current_user: current_user}
present paginate(namespaces), options.reverse_merge(custom_namespace_present_options)
end
- desc 'Get a namespace by ID' do
+ desc "Get a namespace by ID" do
success Entities::Namespace
end
params do
requires :id, type: String, desc: "Namespace's ID or path"
end
- get ':id', requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ get ":id", requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
present user_namespace, with: Entities::Namespace, current_user: current_user
end
end
diff --git a/lib/api/notes.rb b/lib/api/notes.rb
index f7bd092ce50..2b4bcbc9aa2 100644
--- a/lib/api/notes.rb
+++ b/lib/api/notes.rb
@@ -23,11 +23,11 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
- optional :order_by, type: String, values: %w[created_at updated_at], default: 'created_at',
- desc: 'Return notes ordered by `created_at` or `updated_at` fields.'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return notes sorted in `asc` or `desc` order.'
+ requires :noteable_id, type: Integer, desc: "The ID of the noteable"
+ optional :order_by, type: String, values: %w[created_at updated_at], default: "created_at",
+ desc: "Return notes ordered by `created_at` or `updated_at` fields."
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return notes sorted in `asc` or `desc` order."
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -45,7 +45,7 @@ module API
# mismatch between the pagination headers info and the actual notes
# array returned, but this is really a edge-case.
paginate(raw_notes)
- .reject { |n| n.cross_reference_not_visible_for?(current_user) }
+ .reject { |n| n.cross_reference_not_visible_for?(current_user) }
present notes, with: Entities::Note
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -54,8 +54,8 @@ module API
success Entities::Note
end
params do
- requires :note_id, type: Integer, desc: 'The ID of a note'
- requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
+ requires :note_id, type: Integer, desc: "The ID of a note"
+ requires :noteable_id, type: Integer, desc: "The ID of the noteable"
end
get ":id/#{noteables_str}/:noteable_id/notes/:note_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -66,9 +66,9 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
- requires :body, type: String, desc: 'The content of a note'
- optional :created_at, type: String, desc: 'The creation date of the note'
+ requires :noteable_id, type: Integer, desc: "The ID of the noteable"
+ requires :body, type: String, desc: "The content of a note"
+ optional :created_at, type: String, desc: "The creation date of the note"
end
post ":id/#{noteables_str}/:noteable_id/notes" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -77,7 +77,7 @@ module API
note: params[:body],
noteable_type: noteables_str.classify,
noteable_id: noteable.id,
- created_at: params[:created_at]
+ created_at: params[:created_at],
}
note = create_note(noteable, opts)
@@ -93,9 +93,9 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
- requires :note_id, type: Integer, desc: 'The ID of a note'
- requires :body, type: String, desc: 'The content of a note'
+ requires :noteable_id, type: Integer, desc: "The ID of the noteable"
+ requires :note_id, type: Integer, desc: "The ID of a note"
+ requires :body, type: String, desc: "The content of a note"
end
put ":id/#{noteables_str}/:noteable_id/notes/:note_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
@@ -107,8 +107,8 @@ module API
success Entities::Note
end
params do
- requires :noteable_id, type: Integer, desc: 'The ID of the noteable'
- requires :note_id, type: Integer, desc: 'The ID of a note'
+ requires :noteable_id, type: Integer, desc: "The ID of the noteable"
+ requires :note_id, type: Integer, desc: "The ID of a note"
end
delete ":id/#{noteables_str}/:noteable_id/notes/:note_id" do
noteable = find_noteable(parent_type, noteables_str, params[:noteable_id])
diff --git a/lib/api/notification_settings.rb b/lib/api/notification_settings.rb
index 8cb46bd3ad6..9ebe5e912cb 100644
--- a/lib/api/notification_settings.rb
+++ b/lib/api/notification_settings.rb
@@ -8,8 +8,8 @@ module API
helpers ::API::Helpers::MembersHelpers
resource :notification_settings do
- desc 'Get global notification level settings and email, defaults to Participate' do
- detail 'This feature was introduced in GitLab 8.12'
+ desc "Get global notification level settings and email, defaults to Participate" do
+ detail "This feature was introduced in GitLab 8.12"
success Entities::GlobalNotificationSetting
end
get do
@@ -18,15 +18,15 @@ module API
present notification_setting, with: Entities::GlobalNotificationSetting
end
- desc 'Update global notification level settings and email, defaults to Participate' do
- detail 'This feature was introduced in GitLab 8.12'
+ desc "Update global notification level settings and email, defaults to Participate" do
+ detail "This feature was introduced in GitLab 8.12"
success Entities::GlobalNotificationSetting
end
params do
- optional :level, type: String, desc: 'The global notification level'
- optional :notification_email, type: String, desc: 'The email address to send notifications'
+ optional :level, type: String, desc: "The global notification level"
+ optional :notification_email, type: String, desc: "The email address to send notifications"
NotificationSetting.email_events.each do |event|
- optional event, type: Boolean, desc: 'Enable/disable this notification'
+ optional event, type: Boolean, desc: "Enable/disable this notification"
end
end
put do
@@ -60,7 +60,7 @@ module API
end
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get #{source_type} level notification level settings, defaults to Global" do
- detail 'This feature was introduced in GitLab 8.12'
+ detail "This feature was introduced in GitLab 8.12"
success Entities::NotificationSetting
end
get ":id/notification_settings" do
@@ -72,13 +72,13 @@ module API
end
desc "Update #{source_type} level notification level settings, defaults to Global" do
- detail 'This feature was introduced in GitLab 8.12'
+ detail "This feature was introduced in GitLab 8.12"
success Entities::NotificationSetting
end
params do
optional :level, type: String, desc: "The #{source_type} notification level"
NotificationSetting.email_events(source_class).each do |event|
- optional event, type: Boolean, desc: 'Enable/disable this notification'
+ optional event, type: Boolean, desc: "Enable/disable this notification"
end
end
put ":id/notification_settings" do
diff --git a/lib/api/pages_domains.rb b/lib/api/pages_domains.rb
index 78442f465bd..05e1363ab16 100644
--- a/lib/api/pages_domains.rb
+++ b/lib/api/pages_domains.rb
@@ -17,7 +17,7 @@ module API
helpers do
# rubocop: disable CodeReuse/ActiveRecord
def find_pages_domain!
- user_project.pages_domains.find_by(domain: params[:domain]) || not_found!('PagesDomain')
+ user_project.pages_domains.find_by(domain: params[:domain]) || not_found!("PagesDomain")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -28,7 +28,7 @@ module API
def normalize_params_file_to_string
params.each do |k, v|
if v.is_a?(Hash) && v.key?(:tempfile)
- params[k] = v[:tempfile].to_a.join('')
+ params[k] = v[:tempfile].to_a.join("")
end
end
end
@@ -52,14 +52,14 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before do
require_pages_enabled!
end
- desc 'Get all pages domains' do
+ desc "Get all pages domains" do
success Entities::PagesDomain
end
params do
@@ -73,11 +73,11 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a single pages domain' do
+ desc "Get a single pages domain" do
success Entities::PagesDomain
end
params do
- requires :domain, type: String, desc: 'The domain'
+ requires :domain, type: String, desc: "The domain"
end
get ":id/pages/domains/:domain", requirements: PAGES_DOMAINS_ENDPOINT_REQUIREMENTS do
authorize! :read_pages, user_project
@@ -85,13 +85,13 @@ module API
present pages_domain, with: Entities::PagesDomain
end
- desc 'Create a new pages domain' do
+ desc "Create a new pages domain" do
success Entities::PagesDomain
end
params do
- requires :domain, type: String, desc: 'The domain'
- optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate'
- optional :key, allow_blank: false, types: [File, String], desc: 'The key'
+ requires :domain, type: String, desc: "The domain"
+ optional :certificate, allow_blank: false, types: [File, String], desc: "The certificate"
+ optional :key, allow_blank: false, types: [File, String], desc: "The key"
all_or_none_of :certificate, :key
end
post ":id/pages/domains" do
@@ -107,11 +107,11 @@ module API
end
end
- desc 'Updates a pages domain'
+ desc "Updates a pages domain"
params do
- requires :domain, type: String, desc: 'The domain'
- optional :certificate, allow_blank: false, types: [File, String], desc: 'The certificate'
- optional :key, allow_blank: false, types: [File, String], desc: 'The key'
+ requires :domain, type: String, desc: "The domain"
+ optional :certificate, allow_blank: false, types: [File, String], desc: "The certificate"
+ optional :key, allow_blank: false, types: [File, String], desc: "The key"
end
put ":id/pages/domains/:domain", requirements: PAGES_DOMAINS_ENDPOINT_REQUIREMENTS do
authorize! :update_pages, user_project
@@ -130,9 +130,9 @@ module API
end
end
- desc 'Delete a pages domain'
+ desc "Delete a pages domain"
params do
- requires :domain, type: String, desc: 'The domain'
+ requires :domain, type: String, desc: "The domain"
end
delete ":id/pages/domains/:domain", requirements: PAGES_DOMAINS_ENDPOINT_REQUIREMENTS do
authorize! :update_pages, user_project
diff --git a/lib/api/pagination_params.rb b/lib/api/pagination_params.rb
index ae03595eb25..1fe0d7fb3f0 100644
--- a/lib/api/pagination_params.rb
+++ b/lib/api/pagination_params.rb
@@ -17,8 +17,8 @@ module API
included do
helpers do
params :pagination do
- optional :page, type: Integer, default: 1, desc: 'Current page number'
- optional :per_page, type: Integer, default: 20, desc: 'Number of items per page'
+ optional :page, type: Integer, default: 1, desc: "Current page number"
+ optional :per_page, type: Integer, default: 20, desc: "Number of items per page"
end
end
end
diff --git a/lib/api/pipeline_schedules.rb b/lib/api/pipeline_schedules.rb
index c86b50d3736..687b1bd5af5 100644
--- a/lib/api/pipeline_schedules.rb
+++ b/lib/api/pipeline_schedules.rb
@@ -7,19 +7,19 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all pipeline schedules' do
+ desc "Get all pipeline schedules" do
success Entities::PipelineSchedule
end
params do
use :pagination
optional :scope, type: String, values: %w[active inactive],
- desc: 'The scope of pipeline schedules'
+ desc: "The scope of pipeline schedules"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/pipeline_schedules' do
+ get ":id/pipeline_schedules" do
authorize! :read_pipeline_schedule, user_project
schedules = PipelineSchedulesFinder.new(user_project).execute(scope: params[:scope])
@@ -28,27 +28,27 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a single pipeline schedule' do
+ desc "Get a single pipeline schedule" do
success Entities::PipelineScheduleDetails
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
end
- get ':id/pipeline_schedules/:pipeline_schedule_id' do
+ get ":id/pipeline_schedules/:pipeline_schedule_id" do
present pipeline_schedule, with: Entities::PipelineScheduleDetails
end
- desc 'Create a new pipeline schedule' do
+ desc "Create a new pipeline schedule" do
success Entities::PipelineScheduleDetails
end
params do
- requires :description, type: String, desc: 'The description of pipeline schedule'
- requires :ref, type: String, desc: 'The branch/tag name will be triggered', allow_blank: false
- requires :cron, type: String, desc: 'The cron'
- optional :cron_timezone, type: String, default: 'UTC', desc: 'The timezone'
- optional :active, type: Boolean, default: true, desc: 'The activation of pipeline schedule'
+ requires :description, type: String, desc: "The description of pipeline schedule"
+ requires :ref, type: String, desc: "The branch/tag name will be triggered", allow_blank: false
+ requires :cron, type: String, desc: "The cron"
+ optional :cron_timezone, type: String, default: "UTC", desc: "The timezone"
+ optional :active, type: Boolean, default: true, desc: "The activation of pipeline schedule"
end
- post ':id/pipeline_schedules' do
+ post ":id/pipeline_schedules" do
authorize! :create_pipeline_schedule, user_project
pipeline_schedule = Ci::CreatePipelineScheduleService
@@ -62,18 +62,18 @@ module API
end
end
- desc 'Edit a pipeline schedule' do
+ desc "Edit a pipeline schedule" do
success Entities::PipelineScheduleDetails
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
- optional :description, type: String, desc: 'The description of pipeline schedule'
- optional :ref, type: String, desc: 'The branch/tag name will be triggered'
- optional :cron, type: String, desc: 'The cron'
- optional :cron_timezone, type: String, desc: 'The timezone'
- optional :active, type: Boolean, desc: 'The activation of pipeline schedule'
- end
- put ':id/pipeline_schedules/:pipeline_schedule_id' do
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
+ optional :description, type: String, desc: "The description of pipeline schedule"
+ optional :ref, type: String, desc: "The branch/tag name will be triggered"
+ optional :cron, type: String, desc: "The cron"
+ optional :cron_timezone, type: String, desc: "The timezone"
+ optional :active, type: Boolean, desc: "The activation of pipeline schedule"
+ end
+ put ":id/pipeline_schedules/:pipeline_schedule_id" do
authorize! :update_pipeline_schedule, pipeline_schedule
if pipeline_schedule.update(declared_params(include_missing: false))
@@ -83,13 +83,13 @@ module API
end
end
- desc 'Take ownership of a pipeline schedule' do
+ desc "Take ownership of a pipeline schedule" do
success Entities::PipelineScheduleDetails
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
end
- post ':id/pipeline_schedules/:pipeline_schedule_id/take_ownership' do
+ post ":id/pipeline_schedules/:pipeline_schedule_id/take_ownership" do
authorize! :update_pipeline_schedule, pipeline_schedule
if pipeline_schedule.own!(current_user)
@@ -99,27 +99,27 @@ module API
end
end
- desc 'Delete a pipeline schedule' do
+ desc "Delete a pipeline schedule" do
success Entities::PipelineScheduleDetails
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
end
- delete ':id/pipeline_schedules/:pipeline_schedule_id' do
+ delete ":id/pipeline_schedules/:pipeline_schedule_id" do
authorize! :admin_pipeline_schedule, pipeline_schedule
destroy_conditionally!(pipeline_schedule)
end
- desc 'Create a new pipeline schedule variable' do
+ desc "Create a new pipeline schedule variable" do
success Entities::Variable
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
- requires :key, type: String, desc: 'The key of the variable'
- requires :value, type: String, desc: 'The value of the variable'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
+ requires :key, type: String, desc: "The key of the variable"
+ requires :value, type: String, desc: "The value of the variable"
end
- post ':id/pipeline_schedules/:pipeline_schedule_id/variables' do
+ post ":id/pipeline_schedules/:pipeline_schedule_id/variables" do
authorize! :update_pipeline_schedule, pipeline_schedule
variable_params = declared_params(include_missing: false)
@@ -131,15 +131,15 @@ module API
end
end
- desc 'Edit a pipeline schedule variable' do
+ desc "Edit a pipeline schedule variable" do
success Entities::Variable
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
- requires :key, type: String, desc: 'The key of the variable'
- optional :value, type: String, desc: 'The value of the variable'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
+ requires :key, type: String, desc: "The key of the variable"
+ optional :value, type: String, desc: "The value of the variable"
end
- put ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ put ":id/pipeline_schedules/:pipeline_schedule_id/variables/:key" do
authorize! :update_pipeline_schedule, pipeline_schedule
if pipeline_schedule_variable.update(declared_params(include_missing: false))
@@ -149,14 +149,14 @@ module API
end
end
- desc 'Delete a pipeline schedule variable' do
+ desc "Delete a pipeline schedule variable" do
success Entities::Variable
end
params do
- requires :pipeline_schedule_id, type: Integer, desc: 'The pipeline schedule id'
- requires :key, type: String, desc: 'The key of the variable'
+ requires :pipeline_schedule_id, type: Integer, desc: "The pipeline schedule id"
+ requires :key, type: String, desc: "The key of the variable"
end
- delete ':id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ delete ":id/pipeline_schedules/:pipeline_schedule_id/variables/:key" do
authorize! :admin_pipeline_schedule, pipeline_schedule
status :accepted
@@ -173,7 +173,7 @@ module API
.preload(:owner, :last_pipeline)
.find_by(id: params.delete(:pipeline_schedule_id)).tap do |pipeline_schedule|
unless can?(current_user, :read_pipeline_schedule, pipeline_schedule)
- not_found!('Pipeline Schedule')
+ not_found!("Pipeline Schedule")
end
end
end
@@ -184,7 +184,7 @@ module API
@pipeline_schedule_variable ||=
pipeline_schedule.variables.find_by(key: params[:key]).tap do |pipeline_schedule_variable|
unless pipeline_schedule_variable
- not_found!('Pipeline Schedule Variable')
+ not_found!("Pipeline Schedule Variable")
end
end
end
diff --git a/lib/api/pipelines.rb b/lib/api/pipelines.rb
index ac8fe98e55e..4c79cd6feaa 100644
--- a/lib/api/pipelines.rb
+++ b/lib/api/pipelines.rb
@@ -7,47 +7,47 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The project ID'
+ requires :id, type: String, desc: "The project ID"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all Pipelines of the project' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Get all Pipelines of the project" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::PipelineBasic
end
params do
use :pagination
optional :scope, type: String, values: %w[running pending finished branches tags],
- desc: 'The scope of pipelines'
+ desc: "The scope of pipelines"
optional :status, type: String, values: HasStatus::AVAILABLE_STATUSES,
- desc: 'The status of pipelines'
- optional :ref, type: String, desc: 'The ref of pipelines'
- optional :sha, type: String, desc: 'The sha of pipelines'
- optional :yaml_errors, type: Boolean, desc: 'Returns pipelines with invalid configurations'
- optional :name, type: String, desc: 'The name of the user who triggered pipelines'
- optional :username, type: String, desc: 'The username of the user who triggered pipelines'
- optional :order_by, type: String, values: PipelinesFinder::ALLOWED_INDEXED_COLUMNS, default: 'id',
- desc: 'Order pipelines'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Sort pipelines'
- end
- get ':id/pipelines' do
+ desc: "The status of pipelines"
+ optional :ref, type: String, desc: "The ref of pipelines"
+ optional :sha, type: String, desc: "The sha of pipelines"
+ optional :yaml_errors, type: Boolean, desc: "Returns pipelines with invalid configurations"
+ optional :name, type: String, desc: "The name of the user who triggered pipelines"
+ optional :username, type: String, desc: "The username of the user who triggered pipelines"
+ optional :order_by, type: String, values: PipelinesFinder::ALLOWED_INDEXED_COLUMNS, default: "id",
+ desc: "Order pipelines"
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Sort pipelines"
+ end
+ get ":id/pipelines" do
authorize! :read_pipeline, user_project
pipelines = PipelinesFinder.new(user_project, current_user, params).execute
present paginate(pipelines), with: Entities::PipelineBasic
end
- desc 'Create a new pipeline' do
- detail 'This feature was introduced in GitLab 8.14'
+ desc "Create a new pipeline" do
+ detail "This feature was introduced in GitLab 8.14"
success Entities::Pipeline
end
params do
- requires :ref, type: String, desc: 'Reference'
- optional :variables, Array, desc: 'Array of variables available in the pipeline'
+ requires :ref, type: String, desc: "Reference"
+ optional :variables, Array, desc: "Array of variables available in the pipeline"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/pipeline' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42124')
+ post ":id/pipeline" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42124")
authorize! :create_pipeline, user_project
@@ -56,9 +56,9 @@ module API
.except(:variables)
new_pipeline = Ci::CreatePipelineService.new(user_project,
- current_user,
- pipeline_params)
- .execute(:api, ignore_skip_ci: true, save_on_errors: false)
+ current_user,
+ pipeline_params)
+ .execute(:api, ignore_skip_ci: true, save_on_errors: false)
if new_pipeline.persisted?
present new_pipeline, with: Entities::Pipeline
@@ -68,27 +68,27 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Gets a specific pipeline for the project' do
- detail 'This feature was introduced in GitLab 8.11'
+ desc "Gets a specific pipeline for the project" do
+ detail "This feature was introduced in GitLab 8.11"
success Entities::Pipeline
end
params do
- requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ requires :pipeline_id, type: Integer, desc: "The pipeline ID"
end
- get ':id/pipelines/:pipeline_id' do
+ get ":id/pipelines/:pipeline_id" do
authorize! :read_pipeline, pipeline
present pipeline, with: Entities::Pipeline
end
- desc 'Deletes a pipeline' do
- detail 'This feature was introduced in GitLab 11.6'
- http_codes [[204, 'Pipeline was deleted'], [403, 'Forbidden']]
+ desc "Deletes a pipeline" do
+ detail "This feature was introduced in GitLab 11.6"
+ http_codes [[204, "Pipeline was deleted"], [403, "Forbidden"]]
end
params do
- requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ requires :pipeline_id, type: Integer, desc: "The pipeline ID"
end
- delete ':id/pipelines/:pipeline_id' do
+ delete ":id/pipelines/:pipeline_id" do
authorize! :destroy_pipeline, pipeline
destroy_conditionally!(pipeline) do
@@ -96,14 +96,14 @@ module API
end
end
- desc 'Retry builds in the pipeline' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Retry builds in the pipeline" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Pipeline
end
params do
- requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ requires :pipeline_id, type: Integer, desc: "The pipeline ID"
end
- post ':id/pipelines/:pipeline_id/retry' do
+ post ":id/pipelines/:pipeline_id/retry" do
authorize! :update_pipeline, pipeline
pipeline.retry_failed(current_user)
@@ -111,14 +111,14 @@ module API
present pipeline, with: Entities::Pipeline
end
- desc 'Cancel all builds in the pipeline' do
- detail 'This feature was introduced in GitLab 8.11.'
+ desc "Cancel all builds in the pipeline" do
+ detail "This feature was introduced in GitLab 8.11."
success Entities::Pipeline
end
params do
- requires :pipeline_id, type: Integer, desc: 'The pipeline ID'
+ requires :pipeline_id, type: Integer, desc: "The pipeline ID"
end
- post ':id/pipelines/:pipeline_id/cancel' do
+ post ":id/pipelines/:pipeline_id/cancel" do
authorize! :update_pipeline, pipeline
pipeline.cancel_running
diff --git a/lib/api/project_clusters.rb b/lib/api/project_clusters.rb
index c96261a7b57..5bcbb095584 100644
--- a/lib/api/project_clusters.rb
+++ b/lib/api/project_clusters.rb
@@ -17,53 +17,53 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of the project'
+ requires :id, type: String, desc: "The ID of the project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get all clusters from the project' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Get all clusters from the project" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Cluster
end
params do
use :pagination
end
- get ':id/clusters' do
+ get ":id/clusters" do
authorize! :read_cluster, user_project
present paginate(clusters_for_current_user), with: Entities::Cluster
end
- desc 'Get specific cluster for the project' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Get specific cluster for the project" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::ClusterProject
end
params do
- requires :cluster_id, type: Integer, desc: 'The cluster ID'
+ requires :cluster_id, type: Integer, desc: "The cluster ID"
end
- get ':id/clusters/:cluster_id' do
+ get ":id/clusters/:cluster_id" do
authorize! :read_cluster, cluster
present cluster, with: Entities::ClusterProject
end
- desc 'Adds an existing cluster' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Adds an existing cluster" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::ClusterProject
end
params do
- requires :name, type: String, desc: 'Cluster name'
- optional :enabled, type: Boolean, default: true, desc: 'Determines if cluster is active or not, defaults to true'
- requires :platform_kubernetes_attributes, type: Hash, desc: %q(Platform Kubernetes data) do
- requires :api_url, type: String, allow_blank: false, desc: 'URL to access the Kubernetes API'
- requires :token, type: String, desc: 'Token to authenticate against Kubernetes'
- optional :ca_cert, type: String, desc: 'TLS certificate (needed if API is using a self-signed TLS certificate)'
- optional :namespace, type: String, desc: 'Unique namespace related to Project'
- optional :authorization_type, type: String, values: Clusters::Platforms::Kubernetes.authorization_types.keys, default: 'rbac', desc: 'Cluster authorization type, defaults to RBAC'
+ requires :name, type: String, desc: "Cluster name"
+ optional :enabled, type: Boolean, default: true, desc: "Determines if cluster is active or not, defaults to true"
+ requires :platform_kubernetes_attributes, type: Hash, desc: "Platform Kubernetes data" do
+ requires :api_url, type: String, allow_blank: false, desc: "URL to access the Kubernetes API"
+ requires :token, type: String, desc: "Token to authenticate against Kubernetes"
+ optional :ca_cert, type: String, desc: "TLS certificate (needed if API is using a self-signed TLS certificate)"
+ optional :namespace, type: String, desc: "Unique namespace related to Project"
+ optional :authorization_type, type: String, values: Clusters::Platforms::Kubernetes.authorization_types.keys, default: "rbac", desc: "Cluster authorization type, defaults to RBAC"
end
use :create_params_ee
end
- post ':id/clusters/user' do
- authorize! :add_cluster, user_project, 'Instance does not support multiple Kubernetes clusters'
+ post ":id/clusters/user" do
+ authorize! :add_cluster, user_project, "Instance does not support multiple Kubernetes clusters"
user_cluster = ::Clusters::CreateService
.new(current_user, create_cluster_user_params)
@@ -76,22 +76,22 @@ module API
end
end
- desc 'Update an existing cluster' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Update an existing cluster" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::ClusterProject
end
params do
- requires :cluster_id, type: Integer, desc: 'The cluster ID'
- optional :name, type: String, desc: 'Cluster name'
- optional :platform_kubernetes_attributes, type: Hash, desc: %q(Platform Kubernetes data) do
- optional :api_url, type: String, desc: 'URL to access the Kubernetes API'
- optional :token, type: String, desc: 'Token to authenticate against Kubernetes'
- optional :ca_cert, type: String, desc: 'TLS certificate (needed if API is using a self-signed TLS certificate)'
- optional :namespace, type: String, desc: 'Unique namespace related to Project'
+ requires :cluster_id, type: Integer, desc: "The cluster ID"
+ optional :name, type: String, desc: "Cluster name"
+ optional :platform_kubernetes_attributes, type: Hash, desc: "Platform Kubernetes data" do
+ optional :api_url, type: String, desc: "URL to access the Kubernetes API"
+ optional :token, type: String, desc: "Token to authenticate against Kubernetes"
+ optional :ca_cert, type: String, desc: "TLS certificate (needed if API is using a self-signed TLS certificate)"
+ optional :namespace, type: String, desc: "Unique namespace related to Project"
end
use :update_params_ee
end
- put ':id/clusters/:cluster_id' do
+ put ":id/clusters/:cluster_id" do
authorize! :update_cluster, cluster
update_service = Clusters::UpdateService.new(current_user, update_cluster_params)
@@ -103,14 +103,14 @@ module API
end
end
- desc 'Remove a cluster' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Remove a cluster" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::ClusterProject
end
params do
- requires :cluster_id, type: Integer, desc: 'The Cluster ID'
+ requires :cluster_id, type: Integer, desc: "The Cluster ID"
end
- delete ':id/clusters/:cluster_id' do
+ delete ":id/clusters/:cluster_id" do
authorize! :admin_cluster, cluster
destroy_conditionally!(cluster)
@@ -130,7 +130,7 @@ module API
declared_params.merge({
provider_type: :user,
platform_type: :kubernetes,
- clusterable: user_project
+ clusterable: user_project,
})
end
diff --git a/lib/api/project_export.rb b/lib/api/project_export.rb
index e34ed0bdb44..8bd5813416e 100644
--- a/lib/api/project_export.rb
+++ b/lib/api/project_export.rb
@@ -8,47 +8,47 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
- resource :projects, requirements: { id: %r{[^/]+} } do
- desc 'Get export status' do
- detail 'This feature was introduced in GitLab 10.6.'
+ resource :projects, requirements: {id: %r{[^/]+}} do
+ desc "Get export status" do
+ detail "This feature was introduced in GitLab 10.6."
success Entities::ProjectExportStatus
end
- get ':id/export' do
+ get ":id/export" do
present user_project, with: Entities::ProjectExportStatus
end
- desc 'Download export' do
- detail 'This feature was introduced in GitLab 10.6.'
+ desc "Download export" do
+ detail "This feature was introduced in GitLab 10.6."
end
- get ':id/export/download' do
+ get ":id/export/download" do
if user_project.export_file_exists?
present_carrierwave_file!(user_project.export_file)
else
- render_api_error!('404 Not found or has expired', 404)
+ render_api_error!("404 Not found or has expired", 404)
end
end
- desc 'Start export' do
- detail 'This feature was introduced in GitLab 10.6.'
+ desc "Start export" do
+ detail "This feature was introduced in GitLab 10.6."
end
params do
- optional :description, type: String, desc: 'Override the project description'
+ optional :description, type: String, desc: "Override the project description"
optional :upload, type: Hash do
- optional :url, type: String, desc: 'The URL to upload the project'
- optional :http_method, type: String, default: 'PUT', desc: 'HTTP method to upload the exported project'
+ optional :url, type: String, desc: "The URL to upload the project"
+ optional :http_method, type: String, default: "PUT", desc: "HTTP method to upload the exported project"
end
end
- post ':id/export' do
+ post ":id/export" do
project_export_params = declared_params(include_missing: false)
after_export_params = project_export_params.delete(:upload) || {}
export_strategy = if after_export_params[:url].present?
- params = after_export_params.slice(:url, :http_method).symbolize_keys
+ params = after_export_params.slice(:url, :http_method).symbolize_keys
- Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy.new(params)
- end
+ Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy.new(params)
+ end
if export_strategy&.invalid?
render_validation_error!(export_strategy)
diff --git a/lib/api/project_hooks.rb b/lib/api/project_hooks.rb
index 0e7576c9243..e4a0a8b90bd 100644
--- a/lib/api/project_hooks.rb
+++ b/lib/api/project_hooks.rb
@@ -27,10 +27,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get project hooks' do
+ desc "Get project hooks" do
success Entities::ProjectHook
end
params do
@@ -40,18 +40,18 @@ module API
present paginate(user_project.hooks), with: Entities::ProjectHook
end
- desc 'Get a project hook' do
+ desc "Get a project hook" do
success Entities::ProjectHook
end
params do
- requires :hook_id, type: Integer, desc: 'The ID of a project hook'
+ requires :hook_id, type: Integer, desc: "The ID of a project hook"
end
get ":id/hooks/:hook_id" do
hook = user_project.hooks.find(params[:hook_id])
present hook, with: Entities::ProjectHook
end
- desc 'Add hook to project' do
+ desc "Add hook to project" do
success Entities::ProjectHook
end
params do
@@ -72,7 +72,7 @@ module API
end
end
- desc 'Update an existing project hook' do
+ desc "Update an existing project hook" do
success Entities::ProjectHook
end
params do
@@ -94,11 +94,11 @@ module API
end
end
- desc 'Deletes project hook' do
+ desc "Deletes project hook" do
success Entities::ProjectHook
end
params do
- requires :hook_id, type: Integer, desc: 'The ID of the hook to delete'
+ requires :hook_id, type: Integer, desc: "The ID of the hook to delete"
end
delete ":id/hooks/:hook_id" do
hook = user_project.hooks.find(params.delete(:hook_id))
diff --git a/lib/api/project_import.rb b/lib/api/project_import.rb
index c64ec2fcc95..8aeec7299b6 100644
--- a/lib/api/project_import.rb
+++ b/lib/api/project_import.rb
@@ -11,50 +11,50 @@ module API
end
def file_is_valid?
- import_params[:file] && import_params[:file]['tempfile'].respond_to?(:read)
+ import_params[:file] && import_params[:file]["tempfile"].respond_to?(:read)
end
def validate_file!
- render_api_error!('The file is invalid', 400) unless file_is_valid?
+ render_api_error!("The file is invalid", 400) unless file_is_valid?
end
end
before do
- forbidden! unless Gitlab::CurrentSettings.import_sources.include?('gitlab_project')
+ forbidden! unless Gitlab::CurrentSettings.import_sources.include?("gitlab_project")
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
params do
- requires :path, type: String, desc: 'The new project path and name'
- requires :file, type: File, desc: 'The project export file to be imported'
+ requires :path, type: String, desc: "The new project path and name"
+ requires :file, type: File, desc: "The project export file to be imported"
optional :namespace, type: String, desc: "The ID or name of the namespace that the project will be imported into. Defaults to the current user's namespace."
- optional :overwrite, type: Boolean, default: false, desc: 'If there is a project in the same namespace and with the same name overwrite it'
+ optional :overwrite, type: Boolean, default: false, desc: "If there is a project in the same namespace and with the same name overwrite it"
optional :override_params,
- type: Hash,
- desc: 'New project params to override values in the export' do
+ type: Hash,
+ desc: "New project params to override values in the export" do
use :optional_project_params
end
end
- desc 'Create a new project import' do
- detail 'This feature was introduced in GitLab 10.6.'
+ desc "Create a new project import" do
+ detail "This feature was introduced in GitLab 10.6."
success Entities::ProjectImportStatus
end
- post 'import' do
+ post "import" do
validate_file!
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42437')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42437")
namespace = if import_params[:namespace]
- find_namespace!(import_params[:namespace])
- else
- current_user.namespace
- end
+ find_namespace!(import_params[:namespace])
+ else
+ current_user.namespace
+ end
project_params = {
- path: import_params[:path],
- namespace_id: namespace.id,
- file: import_params[:file]['tempfile'],
- overwrite: import_params[:overwrite]
+ path: import_params[:path],
+ namespace_id: namespace.id,
+ file: import_params[:file]["tempfile"],
+ overwrite: import_params[:overwrite],
}
override_params = import_params.delete(:override_params)
@@ -69,13 +69,13 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
- desc 'Get a project export status' do
- detail 'This feature was introduced in GitLab 10.6.'
+ desc "Get a project export status" do
+ detail "This feature was introduced in GitLab 10.6."
success Entities::ProjectImportStatus
end
- get ':id/import' do
+ get ":id/import" do
present user_project, with: Entities::ProjectImportStatus
end
end
diff --git a/lib/api/project_milestones.rb b/lib/api/project_milestones.rb
index ca24742b7a3..8a31cf1d6f5 100644
--- a/lib/api/project_milestones.rb
+++ b/lib/api/project_milestones.rb
@@ -10,10 +10,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a list of project milestones' do
+ desc "Get a list of project milestones" do
success Entities::Milestone
end
params do
@@ -25,11 +25,11 @@ module API
list_milestones_for(user_project)
end
- desc 'Get a single project milestone' do
+ desc "Get a single project milestone" do
success Entities::Milestone
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a project milestone"
end
get ":id/milestones/:milestone_id" do
authorize! :read_milestone, user_project
@@ -37,11 +37,11 @@ module API
get_milestone_for(user_project)
end
- desc 'Create a new project milestone' do
+ desc "Create a new project milestone" do
success Entities::Milestone
end
params do
- requires :title, type: String, desc: 'The title of the milestone'
+ requires :title, type: String, desc: "The title of the milestone"
use :optional_params
end
post ":id/milestones" do
@@ -50,7 +50,7 @@ module API
create_milestone_for(user_project)
end
- desc 'Update an existing project milestone' do
+ desc "Update an existing project milestone" do
success Entities::Milestone
end
params do
@@ -62,7 +62,7 @@ module API
update_milestone_for(user_project)
end
- desc 'Remove a project milestone'
+ desc "Remove a project milestone"
delete ":id/milestones/:milestone_id" do
authorize! :admin_milestone, user_project
@@ -72,11 +72,11 @@ module API
status(204)
end
- desc 'Get all issues for a single project milestone' do
+ desc "Get all issues for a single project milestone" do
success Entities::IssueBasic
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a project milestone"
use :pagination
end
get ":id/milestones/:milestone_id/issues" do
@@ -85,35 +85,33 @@ module API
milestone_issuables_for(user_project, :issue)
end
- desc 'Get all merge requests for a single project milestone' do
- detail 'This feature was introduced in GitLab 9.'
+ desc "Get all merge requests for a single project milestone" do
+ detail "This feature was introduced in GitLab 9."
success Entities::MergeRequestBasic
end
params do
- requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
+ requires :milestone_id, type: Integer, desc: "The ID of a project milestone"
use :pagination
end
- get ':id/milestones/:milestone_id/merge_requests' do
+ get ":id/milestones/:milestone_id/merge_requests" do
authorize! :read_milestone, user_project
milestone_issuables_for(user_project, :merge_request)
end
- desc 'Promote a milestone to group milestone' do
- detail 'This feature was introduced in GitLab 11.9'
+ desc "Promote a milestone to group milestone" do
+ detail "This feature was introduced in GitLab 11.9"
end
- post ':id/milestones/:milestone_id/promote' do
- begin
- authorize! :admin_milestone, user_project
- authorize! :admin_milestone, user_project.group
+ post ":id/milestones/:milestone_id/promote" do
+ authorize! :admin_milestone, user_project
+ authorize! :admin_milestone, user_project.group
- milestone = user_project.milestones.find(params[:milestone_id])
- Milestones::PromoteService.new(user_project, current_user).execute(milestone)
+ milestone = user_project.milestones.find(params[:milestone_id])
+ Milestones::PromoteService.new(user_project, current_user).execute(milestone)
- status(200)
- rescue Milestones::PromoteService::PromoteMilestoneError => error
- render_api_error!(error.message, 400)
- end
+ status(200)
+ rescue Milestones::PromoteService::PromoteMilestoneError => error
+ render_api_error!(error.message, 400)
end
end
end
diff --git a/lib/api/project_snapshots.rb b/lib/api/project_snapshots.rb
index 175fbb2ce92..92835cb65ae 100644
--- a/lib/api/project_snapshots.rb
+++ b/lib/api/project_snapshots.rb
@@ -7,13 +7,13 @@ module API
before { authorize_read_git_snapshot! }
resource :projects do
- desc 'Download a (possibly inconsistent) snapshot of a repository' do
- detail 'This feature was introduced in GitLab 10.7'
+ desc "Download a (possibly inconsistent) snapshot of a repository" do
+ detail "This feature was introduced in GitLab 10.7"
end
params do
- optional :wiki, type: Boolean, desc: 'Set to true to receive the wiki repository'
+ optional :wiki, type: Boolean, desc: "Set to true to receive the wiki repository"
end
- get ':id/snapshot' do
+ get ":id/snapshot" do
send_git_snapshot(snapshot_repository)
end
end
diff --git a/lib/api/project_snippets.rb b/lib/api/project_snippets.rb
index a607df411a6..416cc7bc084 100644
--- a/lib/api/project_snippets.rb
+++ b/lib/api/project_snippets.rb
@@ -7,7 +7,7 @@ module API
before { authenticate! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do
@@ -24,7 +24,7 @@ module API
end
end
- desc 'Get all project snippets' do
+ desc "Get all project snippets" do
success Entities::ProjectSnippet
end
params do
@@ -34,28 +34,28 @@ module API
present paginate(snippets_for_current_user), with: Entities::ProjectSnippet
end
- desc 'Get a single project snippet' do
+ desc "Get a single project snippet" do
success Entities::ProjectSnippet
end
params do
- requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
+ requires :snippet_id, type: Integer, desc: "The ID of a project snippet"
end
get ":id/snippets/:snippet_id" do
snippet = snippets_for_current_user.find(params[:snippet_id])
present snippet, with: Entities::ProjectSnippet
end
- desc 'Create a new project snippet' do
+ desc "Create a new project snippet" do
success Entities::ProjectSnippet
end
params do
- requires :title, type: String, desc: 'The title of the snippet'
- requires :file_name, type: String, desc: 'The file name of the snippet'
- requires :code, type: String, allow_blank: false, desc: 'The content of the snippet'
- optional :description, type: String, desc: 'The description of a snippet'
+ requires :title, type: String, desc: "The title of the snippet"
+ requires :file_name, type: String, desc: "The file name of the snippet"
+ requires :code, type: String, allow_blank: false, desc: "The content of the snippet"
+ optional :description, type: String, desc: "The description of a snippet"
requires :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
- desc: 'The visibility of the snippet'
+ desc: "The visibility of the snippet"
end
post ":id/snippets" do
authorize! :create_project_snippet, user_project
@@ -73,24 +73,24 @@ module API
end
end
- desc 'Update an existing project snippet' do
+ desc "Update an existing project snippet" do
success Entities::ProjectSnippet
end
params do
- requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
- optional :title, type: String, desc: 'The title of the snippet'
- optional :file_name, type: String, desc: 'The file name of the snippet'
- optional :code, type: String, allow_blank: false, desc: 'The content of the snippet'
- optional :description, type: String, desc: 'The description of a snippet'
+ requires :snippet_id, type: Integer, desc: "The ID of a project snippet"
+ optional :title, type: String, desc: "The title of the snippet"
+ optional :file_name, type: String, desc: "The file name of the snippet"
+ optional :code, type: String, allow_blank: false, desc: "The content of the snippet"
+ optional :description, type: String, desc: "The description of a snippet"
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
- desc: 'The visibility of the snippet'
+ desc: "The visibility of the snippet"
at_least_one_of :title, :file_name, :code, :visibility_level
end
# rubocop: disable CodeReuse/ActiveRecord
put ":id/snippets/:snippet_id" do
snippet = snippets_for_current_user.find_by(id: params.delete(:snippet_id))
- not_found!('Snippet') unless snippet
+ not_found!("Snippet") unless snippet
authorize! :update_project_snippet, snippet
@@ -100,7 +100,7 @@ module API
snippet_params[:content] = snippet_params.delete(:code) if snippet_params[:code].present?
UpdateSnippetService.new(user_project, current_user, snippet,
- snippet_params).execute
+ snippet_params).execute
render_spam_error! if snippet.spam?
@@ -112,14 +112,14 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete a project snippet'
+ desc "Delete a project snippet"
params do
- requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
+ requires :snippet_id, type: Integer, desc: "The ID of a project snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/snippets/:snippet_id" do
snippet = snippets_for_current_user.find_by(id: params[:snippet_id])
- not_found!('Snippet') unless snippet
+ not_found!("Snippet") unless snippet
authorize! :admin_project_snippet, snippet
@@ -127,26 +127,26 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a raw project snippet'
+ desc "Get a raw project snippet"
params do
- requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
+ requires :snippet_id, type: Integer, desc: "The ID of a project snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id/snippets/:snippet_id/raw" do
snippet = snippets_for_current_user.find_by(id: params[:snippet_id])
- not_found!('Snippet') unless snippet
+ not_found!("Snippet") unless snippet
- env['api.format'] = :txt
- content_type 'text/plain'
+ env["api.format"] = :txt
+ content_type "text/plain"
present snippet.content
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the user agent details for a project snippet' do
+ desc "Get the user agent details for a project snippet" do
success Entities::UserAgentDetail
end
params do
- requires :snippet_id, type: Integer, desc: 'The ID of a project snippet'
+ requires :snippet_id, type: Integer, desc: "The ID of a project snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id/snippets/:snippet_id/user_agent_detail" do
@@ -154,7 +154,7 @@ module API
snippet = Snippet.find_by!(id: params[:snippet_id], project_id: params[:id])
- break not_found!('UserAgentDetail') unless snippet.user_agent_detail
+ break not_found!("UserAgentDetail") unless snippet.user_agent_detail
present snippet.user_agent_detail, with: Entities::UserAgentDetail
end
diff --git a/lib/api/project_statistics.rb b/lib/api/project_statistics.rb
index 2f73785f72d..6cf765ea7b8 100644
--- a/lib/api/project_statistics.rb
+++ b/lib/api/project_statistics.rb
@@ -9,10 +9,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get the list of project fetch statistics for the last 30 days'
+ desc "Get the list of project fetch statistics for the last 30 days"
get ":id/statistics" do
statistic_finder = ::Projects::DailyStatisticsFinder.new(user_project)
diff --git a/lib/api/project_templates.rb b/lib/api/project_templates.rb
index 119902a189c..ed2cb991eab 100644
--- a/lib/api/project_templates.rb
+++ b/lib/api/project_templates.rb
@@ -9,17 +9,17 @@ module API
before { authenticate_non_get! }
params do
- requires :id, type: String, desc: 'The ID of a project'
- requires :type, type: String, values: TEMPLATE_TYPES, desc: 'The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template'
+ requires :id, type: String, desc: "The ID of a project"
+ requires :type, type: String, values: TEMPLATE_TYPES, desc: "The type (dockerfiles|gitignores|gitlab_ci_ymls|licenses) of the template"
end
resource :projects do
- desc 'Get a list of templates available to this project' do
- detail 'This endpoint was introduced in GitLab 11.4'
+ desc "Get a list of templates available to this project" do
+ detail "This endpoint was introduced in GitLab 11.4"
end
params do
use :pagination
end
- get ':id/templates/:type' do
+ get ":id/templates/:type" do
templates = TemplateFinder
.build(params[:type], user_project)
.execute
@@ -27,24 +27,24 @@ module API
present paginate(::Kaminari.paginate_array(templates)), with: Entities::TemplatesList
end
- desc 'Download a template available to this project' do
- detail 'This endpoint was introduced in GitLab 11.4'
+ desc "Download a template available to this project" do
+ detail "This endpoint was introduced in GitLab 11.4"
end
params do
- requires :name, type: String, desc: 'The name of the template'
+ requires :name, type: String, desc: "The name of the template"
- optional :project, type: String, desc: 'The project name to use when expanding placeholders in the template. Only affects licenses'
- optional :fullname, type: String, desc: 'The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses'
+ optional :project, type: String, desc: "The project name to use when expanding placeholders in the template. Only affects licenses"
+ optional :fullname, type: String, desc: "The full name of the copyright holder to use when expanding placeholders in the template. Only affects licenses"
end
# The regex is needed to ensure a period (e.g. agpl-3.0)
# isn't confused with a format type. We also need to allow encoded
# values (e.g. C%2B%2B for C++), so allow % and + as well.
- get ':id/templates/:type/:name', requirements: { name: /[\w%.+-]+/ } do
+ get ":id/templates/:type/:name", requirements: {name: /[\w%.+-]+/} do
template = TemplateFinder
.build(params[:type], user_project, name: params[:name])
.execute
- not_found!('Template') unless template.present?
+ not_found!("Template") unless template.present?
template.resolve!(
project_name: params[:project].presence,
diff --git a/lib/api/projects.rb b/lib/api/projects.rb
index b23fe6cd4e7..3be654dcdc7 100644
--- a/lib/api/projects.rb
+++ b/lib/api/projects.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'declarative_policy'
+require_dependency "declarative_policy"
module API
class Projects < Grape::API
@@ -59,13 +59,13 @@ module API
:tag_list,
:visibility,
:wiki_enabled,
- :avatar
+ :avatar,
]
end
helpers do
params :statistics_params do
- optional :statistics, type: Boolean, default: false, desc: 'Include project statistics'
+ optional :statistics, type: Boolean, default: false, desc: "Include project statistics"
end
params :collection_params do
@@ -74,35 +74,35 @@ module API
use :pagination
optional :simple, type: Boolean, default: false,
- desc: 'Return only the ID, URL, name, and path of each project'
+ desc: "Return only the ID, URL, name, and path of each project"
end
params :sort_params do
optional :order_by, type: String, values: %w[id name path created_at updated_at last_activity_at],
- default: 'created_at', desc: 'Return projects ordered by field'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return projects sorted in ascending and descending order'
+ default: "created_at", desc: "Return projects ordered by field"
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return projects sorted in ascending and descending order"
end
params :filter_params do
- optional :archived, type: Boolean, desc: 'Limit by archived status'
+ optional :archived, type: Boolean, desc: "Limit by archived status"
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values,
- desc: 'Limit by visibility'
- optional :search, type: String, desc: 'Return list of projects matching the search criteria'
- optional :owned, type: Boolean, default: false, desc: 'Limit by owned by authenticated user'
- optional :starred, type: Boolean, default: false, desc: 'Limit by starred status'
- optional :membership, type: Boolean, default: false, desc: 'Limit by projects that the current user is a member of'
- optional :with_issues_enabled, type: Boolean, default: false, desc: 'Limit by enabled issues feature'
- optional :with_merge_requests_enabled, type: Boolean, default: false, desc: 'Limit by enabled merge requests feature'
- optional :with_programming_language, type: String, desc: 'Limit to repositories which use the given programming language'
- optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: 'Limit by minimum access level of authenticated user'
+ desc: "Limit by visibility"
+ optional :search, type: String, desc: "Return list of projects matching the search criteria"
+ optional :owned, type: Boolean, default: false, desc: "Limit by owned by authenticated user"
+ optional :starred, type: Boolean, default: false, desc: "Limit by starred status"
+ optional :membership, type: Boolean, default: false, desc: "Limit by projects that the current user is a member of"
+ optional :with_issues_enabled, type: Boolean, default: false, desc: "Limit by enabled issues feature"
+ optional :with_merge_requests_enabled, type: Boolean, default: false, desc: "Limit by enabled merge requests feature"
+ optional :with_programming_language, type: String, desc: "Limit to repositories which use the given programming language"
+ optional :min_access_level, type: Integer, values: Gitlab::Access.all_values, desc: "Limit by minimum access level of authenticated user"
use :optional_filter_params_ee
end
params :create_params do
- optional :namespace_id, type: Integer, desc: 'Namespace ID for the new project. Default to the user namespace.'
- optional :import_url, type: String, desc: 'URL from which the project is imported'
+ optional :namespace_id, type: Integer, desc: "Namespace ID for the new project. Default to the user namespace."
+ optional :import_url, type: String, desc: "URL from which the project is imported"
end
def load_projects
@@ -133,18 +133,18 @@ module API
end
resource :users, requirements: API::USER_REQUIREMENTS do
- desc 'Get a user projects' do
+ desc "Get a user projects" do
success Entities::BasicProjectDetails
end
params do
- requires :user_id, type: String, desc: 'The ID or username of the user'
+ requires :user_id, type: String, desc: "The ID or username of the user"
use :collection_params
use :statistics_params
use :with_custom_attributes
end
get ":user_id/projects" do
user = find_user(params[:user_id])
- not_found!('User') unless user
+ not_found!("User") unless user
params[:user] = user
@@ -155,7 +155,7 @@ module API
resource :projects do
include CustomAttributesEndpoints
- desc 'Get a list of visible projects for authenticated user' do
+ desc "Get a list of visible projects for authenticated user" do
success Entities::BasicProjectDetails
end
params do
@@ -167,12 +167,12 @@ module API
present_projects load_projects
end
- desc 'Create new project' do
+ desc "Create new project" do
success Entities::Project
end
params do
- optional :name, type: String, desc: 'The name of the project'
- optional :path, type: String, desc: 'The path of the repository'
+ optional :name, type: String, desc: "The name of the project"
+ optional :path, type: String, desc: "The path of the repository"
at_least_one_of :name, :path
use :optional_project_params
use :create_params
@@ -194,14 +194,14 @@ module API
end
end
- desc 'Create new project for a specified user. Only available to admin users.' do
+ desc "Create new project for a specified user. Only available to admin users." do
success Entities::Project
end
params do
- requires :name, type: String, desc: 'The name of the project'
- requires :user_id, type: Integer, desc: 'The ID of a user'
- optional :path, type: String, desc: 'The path of the repository'
- optional :default_branch, type: String, desc: 'The default branch of the project'
+ requires :name, type: String, desc: "The name of the project"
+ requires :user_id, type: Integer, desc: "The ID of a user"
+ optional :path, type: String, desc: "The path of the repository"
+ optional :default_branch, type: String, desc: "The default branch of the project"
use :optional_project_params
use :create_params
end
@@ -209,7 +209,7 @@ module API
post "user/:user_id" do
authenticated_as_admin!
user = User.find_by(id: params.delete(:user_id))
- not_found!('User') unless user
+ not_found!("User") unless user
attrs = declared_params(include_missing: false)
attrs = translate_params_for_compatibility(attrs)
@@ -226,10 +226,10 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a single project' do
+ desc "Get a single project" do
success Entities::ProjectWithAccess
end
params do
@@ -237,7 +237,7 @@ module API
use :with_custom_attributes
optional :license, type: Boolean, default: false,
- desc: 'Include project license data'
+ desc: "Include project license data"
end
get ":id" do
options = {
@@ -245,7 +245,7 @@ module API
current_user: current_user,
user_can_admin_project: can?(current_user, :admin_project, user_project),
statistics: params[:statistics],
- license: params[:license]
+ license: params[:license],
}
project, options = with_custom_attributes(user_project, options)
@@ -253,16 +253,16 @@ module API
present project, options
end
- desc 'Fork new project for the current user or provided namespace.' do
+ desc "Fork new project for the current user or provided namespace." do
success Entities::Project
end
params do
- optional :namespace, type: String, desc: 'The ID or name of the namespace that the project will be forked into'
- optional :path, type: String, desc: 'The path that will be assigned to the fork'
- optional :name, type: String, desc: 'The name that will be assigned to the fork'
+ optional :namespace, type: String, desc: "The ID or name of the namespace that the project will be forked into"
+ optional :path, type: String, desc: "The path that will be assigned to the fork"
+ optional :name, type: String, desc: "The name that will be assigned to the fork"
end
- post ':id/fork' do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42284')
+ post ":id/fork" do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42284")
fork_params = declared_params(include_missing: false)
namespace_id = fork_params[:namespace]
@@ -271,7 +271,7 @@ module API
fork_params[:namespace] = find_namespace(namespace_id)
unless fork_params[:namespace] && can?(current_user, :create_projects, fork_params[:namespace])
- not_found!('Target Namespace')
+ not_found!("Target Namespace")
end
end
@@ -285,38 +285,38 @@ module API
end
end
- desc 'List forks of this project' do
+ desc "List forks of this project" do
success Entities::Project
end
params do
use :collection_params
use :with_custom_attributes
end
- get ':id/forks' do
+ get ":id/forks" do
forks = ForkProjectsFinder.new(user_project, params: project_finder_params, current_user: current_user).execute
present_projects forks
end
- desc 'Check pages access of this project'
- get ':id/pages_access' do
+ desc "Check pages access of this project"
+ get ":id/pages_access" do
authorize! :read_pages_content, user_project unless user_project.public_pages?
status 200
end
- desc 'Update an existing project' do
+ desc "Update an existing project" do
success Entities::Project
end
params do
- optional :name, type: String, desc: 'The name of the project'
- optional :default_branch, type: String, desc: 'The default branch of the project'
- optional :path, type: String, desc: 'The path of the repository'
+ optional :name, type: String, desc: "The name of the project"
+ optional :default_branch, type: String, desc: "The default branch of the project"
+ optional :path, type: String, desc: "The path of the repository"
use :optional_project_params
at_least_one_of(*::API::Projects.update_params_at_least_one_of)
end
- put ':id' do
+ put ":id" do
authorize_admin_project
attrs = declared_params(include_missing: false)
authorize! :rename_project, user_project if attrs[:name].present?
@@ -336,10 +336,10 @@ module API
end
end
- desc 'Archive a project' do
+ desc "Archive a project" do
success Entities::Project
end
- post ':id/archive' do
+ post ":id/archive" do
authorize!(:archive_project, user_project)
::Projects::UpdateService.new(user_project, current_user, archived: true).execute
@@ -347,10 +347,10 @@ module API
present user_project, with: Entities::Project
end
- desc 'Unarchive a project' do
+ desc "Unarchive a project" do
success Entities::Project
end
- post ':id/unarchive' do
+ post ":id/unarchive" do
authorize!(:archive_project, user_project)
::Projects::UpdateService.new(@project, current_user, archived: false).execute
@@ -358,10 +358,10 @@ module API
present user_project, with: Entities::Project
end
- desc 'Star a project' do
+ desc "Star a project" do
success Entities::Project
end
- post ':id/star' do
+ post ":id/star" do
if current_user.starred?(user_project)
not_modified!
else
@@ -372,10 +372,10 @@ module API
end
end
- desc 'Unstar a project' do
+ desc "Unstar a project" do
success Entities::Project
end
- post ':id/unstar' do
+ post ":id/unstar" do
if current_user.starred?(user_project)
current_user.toggle_star(user_project)
user_project.reload
@@ -386,8 +386,8 @@ module API
end
end
- desc 'Get languages in project repository'
- get ':id/languages' do
+ desc "Get languages in project repository"
+ get ":id/languages" do
if user_project.repository_languages.present?
user_project.repository_languages.map { |l| [l.name, l.share] }.to_h
else
@@ -395,7 +395,7 @@ module API
end
end
- desc 'Remove a project'
+ desc "Remove a project"
delete ":id" do
authorize! :remove_project, user_project
@@ -406,9 +406,9 @@ module API
accepted!
end
- desc 'Mark this project as forked from another'
+ desc "Mark this project as forked from another"
params do
- requires :forked_from_id, type: String, desc: 'The ID of the project it was forked from'
+ requires :forked_from_id, type: String, desc: "The ID of the project it was forked from"
end
post ":id/fork/:forked_from_id" do
authorize! :admin_project, user_project
@@ -426,31 +426,31 @@ module API
end
end
- desc 'Remove a forked_from relationship'
+ desc "Remove a forked_from relationship"
delete ":id/fork" do
authorize! :remove_fork_project, user_project
- result = destroy_conditionally!(user_project) do
+ result = destroy_conditionally!(user_project) {
::Projects::UnlinkForkService.new(user_project, current_user).execute
- end
+ }
result ? status(204) : not_modified!
end
- desc 'Share the project with a group' do
+ desc "Share the project with a group" do
success Entities::ProjectGroupLink
end
params do
- requires :group_id, type: Integer, desc: 'The ID of a group'
- requires :group_access, type: Integer, values: Gitlab::Access.values, desc: 'The group access level'
- optional :expires_at, type: Date, desc: 'Share expiration date'
+ requires :group_id, type: Integer, desc: "The ID of a group"
+ requires :group_access, type: Integer, values: Gitlab::Access.values, desc: "The group access level"
+ optional :expires_at, type: Date, desc: "Share expiration date"
end
post ":id/share" do
authorize! :admin_project, user_project
group = Group.find_by_id(params[:group_id])
unless group && can?(current_user, :read_group, group)
- not_found!('Group')
+ not_found!("Group")
end
unless user_project.allowed_to_share_with_group?
@@ -467,45 +467,45 @@ module API
end
params do
- requires :group_id, type: Integer, desc: 'The ID of the group'
+ requires :group_id, type: Integer, desc: "The ID of the group"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id/share/:group_id" do
authorize! :admin_project, user_project
link = user_project.project_group_links.find_by(group_id: params[:group_id])
- not_found!('Group Link') unless link
+ not_found!("Group Link") unless link
destroy_conditionally!(link)
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Upload a file'
+ desc "Upload a file"
params do
- requires :file, type: File, desc: 'The file to be uploaded'
+ requires :file, type: File, desc: "The file to be uploaded"
end
post ":id/uploads" do
UploadService.new(user_project, params[:file]).execute.to_h
end
- desc 'Get the users list of a project' do
+ desc "Get the users list of a project" do
success Entities::UserBasic
end
params do
- optional :search, type: String, desc: 'Return list of users matching the search criteria'
+ optional :search, type: String, desc: "Return list of users matching the search criteria"
use :pagination
end
- get ':id/users' do
+ get ":id/users" do
users = DeclarativePolicy.subject_scope { user_project.team.users }
users = users.search(params[:search]) if params[:search].present?
present paginate(users), with: Entities::UserBasic
end
- desc 'Start the housekeeping task for a project' do
- detail 'This feature was introduced in GitLab 9.0.'
+ desc "Start the housekeeping task for a project" do
+ detail "This feature was introduced in GitLab 9.0."
end
- post ':id/housekeeping' do
+ post ":id/housekeeping" do
authorize_admin_project
begin
@@ -515,9 +515,9 @@ module API
end
end
- desc 'Transfer a project to a new namespace'
+ desc "Transfer a project to a new namespace"
params do
- requires :namespace, type: String, desc: 'The ID or path of the new namespace'
+ requires :namespace, type: String, desc: "The ID or path of the new namespace"
end
put ":id/transfer" do
authorize! :change_namespace, user_project
diff --git a/lib/api/protected_branches.rb b/lib/api/protected_branches.rb
index 5af43448727..b562ea7d529 100644
--- a/lib/api/protected_branches.rb
+++ b/lib/api/protected_branches.rb
@@ -9,7 +9,7 @@ module API
before { authorize_admin_project }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get a project's protected branches" do
@@ -19,41 +19,41 @@ module API
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/protected_branches' do
+ get ":id/protected_branches" do
protected_branches = user_project.protected_branches.preload(:push_access_levels, :merge_access_levels)
present paginate(protected_branches), with: Entities::ProtectedBranch, project: user_project
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a single protected branch' do
+ desc "Get a single protected branch" do
success Entities::ProtectedBranch
end
params do
- requires :name, type: String, desc: 'The name of the branch or wildcard'
+ requires :name, type: String, desc: "The name of the branch or wildcard"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ get ":id/protected_branches/:name", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
protected_branch = user_project.protected_branches.find_by!(name: params[:name])
present protected_branch, with: Entities::ProtectedBranch, project: user_project
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Protect a single branch or wildcard' do
+ desc "Protect a single branch or wildcard" do
success Entities::ProtectedBranch
end
params do
- requires :name, type: String, desc: 'The name of the protected branch'
+ requires :name, type: String, desc: "The name of the protected branch"
optional :push_access_level, type: Integer,
values: ProtectedBranch::PushAccessLevel.allowed_access_levels,
- desc: 'Access levels allowed to push (defaults: `40`, maintainer access level)'
+ desc: "Access levels allowed to push (defaults: `40`, maintainer access level)"
optional :merge_access_level, type: Integer,
values: ProtectedBranch::MergeAccessLevel.allowed_access_levels,
- desc: 'Access levels allowed to merge (defaults: `40`, maintainer access level)'
+ desc: "Access levels allowed to merge (defaults: `40`, maintainer access level)"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/protected_branches' do
+ post ":id/protected_branches" do
protected_branch = user_project.protected_branches.find_by(name: params[:name])
if protected_branch
conflict!("Protected branch '#{params[:name]}' already exists")
@@ -71,12 +71,12 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Unprotect a single branch'
+ desc "Unprotect a single branch"
params do
- requires :name, type: String, desc: 'The name of the protected branch'
+ requires :name, type: String, desc: "The name of the protected branch"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/protected_branches/:name', requirements: BRANCH_ENDPOINT_REQUIREMENTS do
+ delete ":id/protected_branches/:name", requirements: BRANCH_ENDPOINT_REQUIREMENTS do
protected_branch = user_project.protected_branches.find_by!(name: params[:name])
destroy_conditionally!(protected_branch) do
diff --git a/lib/api/protected_tags.rb b/lib/api/protected_tags.rb
index ee13473c848..8ef1beab610 100644
--- a/lib/api/protected_tags.rb
+++ b/lib/api/protected_tags.rb
@@ -9,58 +9,58 @@ module API
before { authorize_admin_project }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get a project's protected tags" do
- detail 'This feature was introduced in GitLab 11.3.'
+ detail "This feature was introduced in GitLab 11.3."
success Entities::ProtectedTag
end
params do
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/protected_tags' do
+ get ":id/protected_tags" do
protected_tags = user_project.protected_tags.preload(:create_access_levels)
present paginate(protected_tags), with: Entities::ProtectedTag, project: user_project
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a single protected tag' do
- detail 'This feature was introduced in GitLab 11.3.'
+ desc "Get a single protected tag" do
+ detail "This feature was introduced in GitLab 11.3."
success Entities::ProtectedTag
end
params do
- requires :name, type: String, desc: 'The name of the tag or wildcard'
+ requires :name, type: String, desc: "The name of the tag or wildcard"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ get ":id/protected_tags/:name", requirements: TAG_ENDPOINT_REQUIREMENTS do
protected_tag = user_project.protected_tags.find_by!(name: params[:name])
present protected_tag, with: Entities::ProtectedTag, project: user_project
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Protect a single tag or wildcard' do
- detail 'This feature was introduced in GitLab 11.3.'
+ desc "Protect a single tag or wildcard" do
+ detail "This feature was introduced in GitLab 11.3."
success Entities::ProtectedTag
end
params do
- requires :name, type: String, desc: 'The name of the protected tag'
+ requires :name, type: String, desc: "The name of the protected tag"
optional :create_access_level, type: Integer, default: Gitlab::Access::MAINTAINER,
values: ProtectedTag::CreateAccessLevel.allowed_access_levels,
- desc: 'Access levels allowed to create (defaults: `40`, maintainer access level)'
+ desc: "Access levels allowed to create (defaults: `40`, maintainer access level)"
end
- post ':id/protected_tags' do
+ post ":id/protected_tags" do
protected_tags_params = {
name: params[:name],
- create_access_levels_attributes: [{ access_level: params[:create_access_level] }]
+ create_access_levels_attributes: [{access_level: params[:create_access_level]}],
}
protected_tag = ::ProtectedTags::CreateService.new(user_project,
- current_user,
- protected_tags_params).execute
+ current_user,
+ protected_tags_params).execute
if protected_tag.persisted?
present protected_tag, with: Entities::ProtectedTag, project: user_project
@@ -69,14 +69,14 @@ module API
end
end
- desc 'Unprotect a single tag' do
- detail 'This feature was introduced in GitLab 11.3.'
+ desc "Unprotect a single tag" do
+ detail "This feature was introduced in GitLab 11.3."
end
params do
- requires :name, type: String, desc: 'The name of the protected tag'
+ requires :name, type: String, desc: "The name of the protected tag"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/protected_tags/:name', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ delete ":id/protected_tags/:name", requirements: TAG_ENDPOINT_REQUIREMENTS do
protected_tag = user_project.protected_tags.find_by!(name: params[:name])
destroy_conditionally!(protected_tag)
diff --git a/lib/api/release/links.rb b/lib/api/release/links.rb
index e3072684ef7..f1a70f2a4bc 100644
--- a/lib/api/release/links.rb
+++ b/lib/api/release/links.rb
@@ -9,36 +9,36 @@ module API
.merge(tag_name: API::NO_SLASH_URL_PART_REGEX)
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
- resource 'projects/:id', requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ resource "projects/:id", requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
end
- resource 'releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMETS do
+ resource "releases/:tag_name", requirements: RELEASE_ENDPOINT_REQUIREMETS do
resource :assets do
- desc 'Get a list of links of a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Get a list of links of a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Releases::Link
end
params do
use :pagination
end
- get 'links' do
+ get "links" do
authorize! :read_release, release
present paginate(release.links.sorted), with: Entities::Releases::Link
end
- desc 'Create a link of a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Create a link of a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Releases::Link
end
params do
- requires :name, type: String, desc: 'The name of the link'
- requires :url, type: String, desc: 'The URL of the link'
+ requires :name, type: String, desc: "The name of the link"
+ requires :url, type: String, desc: "The URL of the link"
end
- post 'links' do
+ post "links" do
authorize! :create_release, release
new_link = release.links.create(declared_params(include_missing: false))
@@ -51,11 +51,11 @@ module API
end
params do
- requires :link_id, type: String, desc: 'The id of the link'
+ requires :link_id, type: String, desc: "The id of the link"
end
- resource 'links/:link_id' do
- desc 'Get a link detail of a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ resource "links/:link_id" do
+ desc "Get a link detail of a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Releases::Link
end
get do
@@ -64,13 +64,13 @@ module API
present link, with: Entities::Releases::Link
end
- desc 'Update a link of a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Update a link of a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Releases::Link
end
params do
- optional :name, type: String, desc: 'The name of the link'
- optional :url, type: String, desc: 'The URL of the link'
+ optional :name, type: String, desc: "The name of the link"
+ optional :url, type: String, desc: "The URL of the link"
at_least_one_of :name, :url
end
put do
@@ -83,8 +83,8 @@ module API
end
end
- desc 'Delete a link of a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Delete a link of a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Releases::Link
end
delete do
diff --git a/lib/api/releases.rb b/lib/api/releases.rb
index cb85028f22c..b608c237cff 100644
--- a/lib/api/releases.rb
+++ b/lib/api/releases.rb
@@ -10,44 +10,44 @@ module API
before { authorize_read_releases! }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a project releases' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Get a project releases" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Release
end
params do
use :pagination
end
- get ':id/releases' do
+ get ":id/releases" do
releases = ::ReleasesFinder.new(user_project, current_user).execute
present paginate(releases), with: Entities::Release
end
- desc 'Get a single project release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Get a single project release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Release
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
end
- get ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMETS do
+ get ":id/releases/:tag_name", requirements: RELEASE_ENDPOINT_REQUIREMETS do
authorize_read_release!
present release, with: Entities::Release
end
- desc 'Create a new release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Create a new release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Release
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
- requires :name, type: String, desc: 'The name of the release'
- requires :description, type: String, desc: 'The release notes'
- optional :ref, type: String, desc: 'The commit sha or branch name'
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
+ requires :name, type: String, desc: "The name of the release"
+ requires :description, type: String, desc: "The release notes"
+ optional :ref, type: String, desc: "The commit sha or branch name"
optional :assets, type: Hash do
optional :links, type: Array do
requires :name, type: String
@@ -55,7 +55,7 @@ module API
end
end
end
- post ':id/releases' do
+ post ":id/releases" do
authorize_create_release!
result = ::Releases::CreateService
@@ -69,16 +69,16 @@ module API
end
end
- desc 'Update a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Update a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Release
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
- optional :name, type: String, desc: 'The name of the release'
- optional :description, type: String, desc: 'Release notes with markdown support'
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
+ optional :name, type: String, desc: "The name of the release"
+ optional :description, type: String, desc: "Release notes with markdown support"
end
- put ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMETS do
+ put ":id/releases/:tag_name", requirements: RELEASE_ENDPOINT_REQUIREMETS do
authorize_update_release!
result = ::Releases::UpdateService
@@ -92,14 +92,14 @@ module API
end
end
- desc 'Delete a release' do
- detail 'This feature was introduced in GitLab 11.7.'
+ desc "Delete a release" do
+ detail "This feature was introduced in GitLab 11.7."
success Entities::Release
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
end
- delete ':id/releases/:tag_name', requirements: RELEASE_ENDPOINT_REQUIREMETS do
+ delete ":id/releases/:tag_name", requirements: RELEASE_ENDPOINT_REQUIREMETS do
authorize_destroy_release!
result = ::Releases::DestroyService
diff --git a/lib/api/repositories.rb b/lib/api/repositories.rb
index 32e05d84491..2545236b3fa 100644
--- a/lib/api/repositories.rb
+++ b/lib/api/repositories.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'mime/types'
+require "mime/types"
module API
class Repositories < Grape::API
@@ -9,7 +9,7 @@ module API
before { authorize! :download_code, user_project }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
helpers do
@@ -30,120 +30,116 @@ module API
@blob = Gitlab::Git::Blob.raw(@repo, params[:sha])
@blob.load_all_data!(@repo)
rescue
- not_found! 'Blob'
+ not_found! "Blob"
end
- not_found! 'Blob' unless @blob
+ not_found! "Blob" unless @blob
end
end
- desc 'Get a project repository tree' do
+ desc "Get a project repository tree" do
success Entities::TreeObject
end
params do
- optional :ref, type: String, desc: 'The name of a repository branch or tag, if not given the default branch is used'
- optional :path, type: String, desc: 'The path of the tree'
- optional :recursive, type: Boolean, default: false, desc: 'Used to get a recursive tree'
+ optional :ref, type: String, desc: "The name of a repository branch or tag, if not given the default branch is used"
+ optional :path, type: String, desc: "The path of the tree"
+ optional :recursive, type: Boolean, default: false, desc: "Used to get a recursive tree"
use :pagination
end
- get ':id/repository/tree' do
- ref = params[:ref] || user_project.try(:default_branch) || 'master'
+ get ":id/repository/tree" do
+ ref = params[:ref] || user_project.try(:default_branch) || "master"
path = params[:path] || nil
commit = user_project.commit(ref)
- not_found!('Tree') unless commit
+ not_found!("Tree") unless commit
tree = user_project.repository.tree(commit.id, path, recursive: params[:recursive])
entries = ::Kaminari.paginate_array(tree.sorted_entries)
present paginate(entries), with: Entities::TreeObject
end
- desc 'Get raw blob contents from the repository'
+ desc "Get raw blob contents from the repository"
params do
- requires :sha, type: String, desc: 'The commit hash'
+ requires :sha, type: String, desc: "The commit hash"
end
- get ':id/repository/blobs/:sha/raw' do
+ get ":id/repository/blobs/:sha/raw" do
assign_blob_vars!
send_git_blob @repo, @blob
end
- desc 'Get a blob from the repository'
+ desc "Get a blob from the repository"
params do
- requires :sha, type: String, desc: 'The commit hash'
+ requires :sha, type: String, desc: "The commit hash"
end
- get ':id/repository/blobs/:sha' do
+ get ":id/repository/blobs/:sha" do
assign_blob_vars!
{
size: @blob.size,
encoding: "base64",
content: Base64.strict_encode64(@blob.data),
- sha: @blob.id
+ sha: @blob.id,
}
end
- desc 'Get an archive of the repository'
+ desc "Get an archive of the repository"
params do
- optional :sha, type: String, desc: 'The commit sha of the archive to be downloaded'
- optional :format, type: String, desc: 'The archive format'
- end
- get ':id/repository/archive', requirements: { format: Gitlab::PathRegex.archive_formats_regex } do
- begin
- send_git_archive user_project.repository, ref: params[:sha], format: params[:format], append_sha: true
- rescue
- not_found!('File')
- end
+ optional :sha, type: String, desc: "The commit sha of the archive to be downloaded"
+ optional :format, type: String, desc: "The archive format"
+ end
+ get ":id/repository/archive", requirements: {format: Gitlab::PathRegex.archive_formats_regex} do
+ send_git_archive user_project.repository, ref: params[:sha], format: params[:format], append_sha: true
+ rescue
+ not_found!("File")
end
- desc 'Compare two branches, tags, or commits' do
+ desc "Compare two branches, tags, or commits" do
success Entities::Compare
end
params do
- requires :from, type: String, desc: 'The commit, branch name, or tag name to start comparison'
- requires :to, type: String, desc: 'The commit, branch name, or tag name to stop comparison'
- optional :straight, type: Boolean, desc: 'Comparison method, `true` for direct comparison between `from` and `to` (`from`..`to`), `false` to compare using merge base (`from`...`to`)', default: false
+ requires :from, type: String, desc: "The commit, branch name, or tag name to start comparison"
+ requires :to, type: String, desc: "The commit, branch name, or tag name to stop comparison"
+ optional :straight, type: Boolean, desc: "Comparison method, `true` for direct comparison between `from` and `to` (`from`..`to`), `false` to compare using merge base (`from`...`to`)", default: false
end
- get ':id/repository/compare' do
+ get ":id/repository/compare" do
compare = Gitlab::Git::Compare.new(user_project.repository.raw_repository, params[:from], params[:to], straight: params[:straight])
present compare, with: Entities::Compare
end
- desc 'Get repository contributors' do
+ desc "Get repository contributors" do
success Entities::Contributor
end
params do
use :pagination
- optional :order_by, type: String, values: %w[email name commits], default: 'commits', desc: 'Return contributors ordered by `name` or `email` or `commits`'
- optional :sort, type: String, values: %w[asc desc], default: 'asc', desc: 'Sort by asc (ascending) or desc (descending)'
- end
- get ':id/repository/contributors' do
- begin
- contributors = ::Kaminari.paginate_array(user_project.repository.contributors(order_by: params[:order_by], sort: params[:sort]))
- present paginate(contributors), with: Entities::Contributor
- rescue
- not_found!
- end
+ optional :order_by, type: String, values: %w[email name commits], default: "commits", desc: "Return contributors ordered by `name` or `email` or `commits`"
+ optional :sort, type: String, values: %w[asc desc], default: "asc", desc: "Sort by asc (ascending) or desc (descending)"
+ end
+ get ":id/repository/contributors" do
+ contributors = ::Kaminari.paginate_array(user_project.repository.contributors(order_by: params[:order_by], sort: params[:sort]))
+ present paginate(contributors), with: Entities::Contributor
+ rescue
+ not_found!
end
- desc 'Get the common ancestor between commits' do
+ desc "Get the common ancestor between commits" do
success Entities::Commit
end
params do
requires :refs, type: Array[String]
end
- get ':id/repository/merge_base' do
+ get ":id/repository/merge_base" do
refs = params[:refs]
if refs.size < 2
- render_api_error!('Provide at least 2 refs', 400)
+ render_api_error!("Provide at least 2 refs", 400)
end
merge_base = Gitlab::Git::MergeBase.new(user_project.repository, refs)
if merge_base.unknown_refs.any?
- ref_noun = 'ref'.pluralize(merge_base.unknown_refs.size)
- message = "Could not find #{ref_noun}: #{merge_base.unknown_refs.join(', ')}"
+ ref_noun = "ref".pluralize(merge_base.unknown_refs.size)
+ message = "Could not find #{ref_noun}: #{merge_base.unknown_refs.join(", ")}"
render_api_error!(message, 400)
end
diff --git a/lib/api/resource_label_events.rb b/lib/api/resource_label_events.rb
index 0c328f7268e..b2934eb29e1 100644
--- a/lib/api/resource_label_events.rb
+++ b/lib/api/resource_label_events.rb
@@ -19,10 +19,10 @@ module API
resource parent_type.pluralize.to_sym, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Get a list of #{eventable_type.to_s.downcase} resource label events" do
success Entities::ResourceLabelEvent
- detail 'This feature was introduced in 11.3'
+ detail "This feature was introduced in 11.3"
end
params do
- requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
+ requires :eventable_id, types: [Integer, String], desc: "The ID of the eventable"
use :pagination
end
@@ -37,11 +37,11 @@ module API
desc "Get a single #{eventable_type.to_s.downcase} resource label event" do
success Entities::ResourceLabelEvent
- detail 'This feature was introduced in 11.3'
+ detail "This feature was introduced in 11.3"
end
params do
- requires :event_id, type: String, desc: 'The ID of a resource label event'
- requires :eventable_id, types: [Integer, String], desc: 'The ID of the eventable'
+ requires :event_id, type: String, desc: "The ID of a resource label event"
+ requires :eventable_id, types: [Integer, String], desc: "The ID of the eventable"
end
get ":id/#{eventables_str}/:eventable_id/resource_label_events/:event_id" do
eventable = find_noteable(parent_type, eventables_str, params[:eventable_id])
diff --git a/lib/api/runner.rb b/lib/api/runner.rb
index c60d25b88cb..b97db592fad 100644
--- a/lib/api/runner.rb
+++ b/lib/api/runner.rb
@@ -5,21 +5,21 @@ module API
helpers ::API::Helpers::Runner
resource :runners do
- desc 'Registers a new Runner' do
+ desc "Registers a new Runner" do
success Entities::RunnerRegistrationDetails
- http_codes [[201, 'Runner was created'], [403, 'Forbidden']]
+ http_codes [[201, "Runner was created"], [403, "Forbidden"]]
end
params do
- requires :token, type: String, desc: 'Registration token'
- optional :description, type: String, desc: %q(Runner's description)
- optional :info, type: Hash, desc: %q(Runner's metadata)
- optional :active, type: Boolean, desc: 'Should Runner be active'
- optional :locked, type: Boolean, desc: 'Should Runner be locked for current project'
- optional :run_untagged, type: Boolean, desc: 'Should Runner handle untagged jobs'
- optional :tag_list, type: Array[String], desc: %q(List of Runner's tags)
- optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
+ requires :token, type: String, desc: "Registration token"
+ optional :description, type: String, desc: "Runner's description"
+ optional :info, type: Hash, desc: "Runner's metadata"
+ optional :active, type: Boolean, desc: "Should Runner be active"
+ optional :locked, type: Boolean, desc: "Should Runner be locked for current project"
+ optional :run_untagged, type: Boolean, desc: "Should Runner handle untagged jobs"
+ optional :tag_list, type: Array[String], desc: "List of Runner's tags"
+ optional :maximum_timeout, type: Integer, desc: "Maximum timeout set when this Runner will handle the job"
end
- post '/' do
+ post "/" do
attributes = attributes_for_keys([:description, :active, :locked, :run_untagged, :tag_list, :maximum_timeout])
.merge(get_runner_details_from_request)
@@ -46,13 +46,13 @@ module API
end
end
- desc 'Deletes a registered Runner' do
- http_codes [[204, 'Runner was deleted'], [403, 'Forbidden']]
+ desc "Deletes a registered Runner" do
+ http_codes [[204, "Runner was deleted"], [403, "Forbidden"]]
end
params do
- requires :token, type: String, desc: %q(Runner's authentication token)
+ requires :token, type: String, desc: "Runner's authentication token"
end
- delete '/' do
+ delete "/" do
authenticate_runner!
runner = Ci::Runner.find_by_token(params[:token])
@@ -60,55 +60,55 @@ module API
destroy_conditionally!(runner)
end
- desc 'Validates authentication credentials' do
- http_codes [[200, 'Credentials are valid'], [403, 'Forbidden']]
+ desc "Validates authentication credentials" do
+ http_codes [[200, "Credentials are valid"], [403, "Forbidden"]]
end
params do
- requires :token, type: String, desc: %q(Runner's authentication token)
+ requires :token, type: String, desc: "Runner's authentication token"
end
- post '/verify' do
+ post "/verify" do
authenticate_runner!
status 200
end
end
resource :jobs do
- desc 'Request a job' do
+ desc "Request a job" do
success Entities::JobRequest::Response
- http_codes [[201, 'Job was scheduled'],
- [204, 'No job for Runner'],
- [403, 'Forbidden']]
+ http_codes [[201, "Job was scheduled"],
+ [204, "No job for Runner"],
+ [403, "Forbidden"],]
end
params do
- requires :token, type: String, desc: %q(Runner's authentication token)
- optional :last_update, type: String, desc: %q(Runner's queue last_update token)
- optional :info, type: Hash, desc: %q(Runner's metadata) do
- optional :name, type: String, desc: %q(Runner's name)
- optional :version, type: String, desc: %q(Runner's version)
- optional :revision, type: String, desc: %q(Runner's revision)
- optional :platform, type: String, desc: %q(Runner's platform)
- optional :architecture, type: String, desc: %q(Runner's architecture)
- optional :executor, type: String, desc: %q(Runner's executor)
- optional :features, type: Hash, desc: %q(Runner's features)
+ requires :token, type: String, desc: "Runner's authentication token"
+ optional :last_update, type: String, desc: "Runner's queue last_update token"
+ optional :info, type: Hash, desc: "Runner's metadata" do
+ optional :name, type: String, desc: "Runner's name"
+ optional :version, type: String, desc: "Runner's version"
+ optional :revision, type: String, desc: "Runner's revision"
+ optional :platform, type: String, desc: "Runner's platform"
+ optional :architecture, type: String, desc: "Runner's architecture"
+ optional :executor, type: String, desc: "Runner's executor"
+ optional :features, type: Hash, desc: "Runner's features"
end
- optional :session, type: Hash, desc: %q(Runner's session data) do
- optional :url, type: String, desc: %q(Session's url)
- optional :certificate, type: String, desc: %q(Session's certificate)
- optional :authorization, type: String, desc: %q(Session's authorization)
+ optional :session, type: Hash, desc: "Runner's session data" do
+ optional :url, type: String, desc: "Session's url"
+ optional :certificate, type: String, desc: "Session's certificate"
+ optional :authorization, type: String, desc: "Session's authorization"
end
end
- post '/request' do
+ post "/request" do
authenticate_runner!
unless current_runner.active?
- header 'X-GitLab-Last-Update', current_runner.ensure_runner_queue_value
+ header "X-GitLab-Last-Update", current_runner.ensure_runner_queue_value
break no_content!
end
runner_params = declared_params(include_missing: false)
if current_runner.runner_queue_value_latest?(runner_params[:last_update])
- header 'X-GitLab-Last-Update', runner_params[:last_update]
+ header "X-GitLab-Last-Update", runner_params[:last_update]
Gitlab::Metrics.add_event(:build_not_found_cached)
break no_content!
end
@@ -122,7 +122,7 @@ module API
present Ci::BuildRunnerPresenter.new(result.build), with: Entities::JobRequest::Response
else
Gitlab::Metrics.add_event(:build_not_found)
- header 'X-GitLab-Last-Update', new_update
+ header "X-GitLab-Last-Update", new_update
no_content!
end
else
@@ -132,51 +132,51 @@ module API
end
end
- desc 'Updates a job' do
- http_codes [[200, 'Job was updated'], [403, 'Forbidden']]
+ desc "Updates a job" do
+ http_codes [[200, "Job was updated"], [403, "Forbidden"]]
end
params do
- requires :token, type: String, desc: %q(Runners's authentication token)
- requires :id, type: Integer, desc: %q(Job's ID)
- optional :trace, type: String, desc: %q(Job's full trace)
- optional :state, type: String, desc: %q(Job's status: success, failed)
- optional :failure_reason, type: String, desc: %q(Job's failure_reason)
+ requires :token, type: String, desc: "Runners's authentication token"
+ requires :id, type: Integer, desc: "Job's ID"
+ optional :trace, type: String, desc: "Job's full trace"
+ optional :state, type: String, desc: "Job's status: success, failed"
+ optional :failure_reason, type: String, desc: "Job's failure_reason"
end
- put '/:id' do
+ put "/:id" do
job = authenticate_job!
- job_forbidden!(job, 'Job is not running') unless job.running?
+ job_forbidden!(job, "Job is not running") unless job.running?
job.trace.set(params[:trace]) if params[:trace]
Gitlab::Metrics.add_event(:update_build)
case params[:state].to_s
- when 'running'
+ when "running"
job.touch if job.needs_touch?
- when 'success'
+ when "success"
job.success!
- when 'failed'
+ when "failed"
job.drop!(params[:failure_reason] || :unknown_failure)
end
end
- desc 'Appends a patch to the job trace' do
- http_codes [[202, 'Trace was patched'],
- [400, 'Missing Content-Range header'],
- [403, 'Forbidden'],
- [416, 'Range not satisfiable']]
+ desc "Appends a patch to the job trace" do
+ http_codes [[202, "Trace was patched"],
+ [400, "Missing Content-Range header"],
+ [403, "Forbidden"],
+ [416, "Range not satisfiable"],]
end
params do
- requires :id, type: Integer, desc: %q(Job's ID)
- optional :token, type: String, desc: %q(Job's authentication token)
+ requires :id, type: Integer, desc: "Job's ID"
+ optional :token, type: String, desc: "Job's authentication token"
end
- patch '/:id/trace' do
+ patch "/:id/trace" do
job = authenticate_job!
- job_forbidden!(job, 'Job is not running') unless job.running?
+ job_forbidden!(job, "Job is not running") unless job.running?
- error!('400 Missing header Content-Range', 400) unless request.headers.key?('Content-Range')
- content_range = request.headers['Content-Range']
- content_range = content_range.split('-')
+ error!("400 Missing header Content-Range", 400) unless request.headers.key?("Content-Range")
+ content_range = request.headers["Content-Range"]
+ content_range = content_range.split("-")
# TODO:
# it seems that `Content-Range` as formatted by runner is wrong,
@@ -191,32 +191,32 @@ module API
stream_size = job.trace.append(body_data, body_start)
unless stream_size == body_end
- break error!('416 Range Not Satisfiable', 416, { 'Range' => "0-#{stream_size}" })
+ break error!("416 Range Not Satisfiable", 416, {"Range" => "0-#{stream_size}"})
end
status 202
- header 'Job-Status', job.status
- header 'Range', "0-#{stream_size}"
+ header "Job-Status", job.status
+ header "Range", "0-#{stream_size}"
end
- desc 'Authorize artifacts uploading for job' do
- http_codes [[200, 'Upload allowed'],
- [403, 'Forbidden'],
- [405, 'Artifacts support not enabled'],
- [413, 'File too large']]
+ desc "Authorize artifacts uploading for job" do
+ http_codes [[200, "Upload allowed"],
+ [403, "Forbidden"],
+ [405, "Artifacts support not enabled"],
+ [413, "File too large"],]
end
params do
- requires :id, type: Integer, desc: %q(Job's ID)
- optional :token, type: String, desc: %q(Job's authentication token)
- optional :filesize, type: Integer, desc: %q(Artifacts filesize)
+ requires :id, type: Integer, desc: "Job's ID"
+ optional :token, type: String, desc: "Job's authentication token"
+ optional :filesize, type: Integer, desc: "Artifacts filesize"
end
- post '/:id/artifacts/authorize' do
+ post "/:id/artifacts/authorize" do
not_allowed! unless Gitlab.config.artifacts.enabled
require_gitlab_workhorse!
Gitlab::Workhorse.verify_api_request!(headers)
job = authenticate_job!
- forbidden!('Job is not running') unless job.running?
+ forbidden!("Job is not running") unless job.running?
if params[:filesize]
file_size = params[:filesize].to_i
@@ -228,55 +228,56 @@ module API
JobArtifactUploader.workhorse_authorize(has_length: false, maximum_size: max_artifacts_size)
end
- desc 'Upload artifacts for job' do
+ desc "Upload artifacts for job" do
success Entities::JobRequest::Response
- http_codes [[201, 'Artifact uploaded'],
- [400, 'Bad request'],
- [403, 'Forbidden'],
- [405, 'Artifacts support not enabled'],
- [413, 'File too large']]
+ http_codes [[201, "Artifact uploaded"],
+ [400, "Bad request"],
+ [403, "Forbidden"],
+ [405, "Artifacts support not enabled"],
+ [413, "File too large"],]
end
params do
- requires :id, type: Integer, desc: %q(Job's ID)
- optional :token, type: String, desc: %q(Job's authentication token)
- optional :expire_in, type: String, desc: %q(Specify when artifacts should expire)
- optional :artifact_type, type: String, desc: %q(The type of artifact),
- default: 'archive', values: Ci::JobArtifact.file_types.keys
- optional :artifact_format, type: String, desc: %q(The format of artifact),
- default: 'zip', values: Ci::JobArtifact.file_formats.keys
- optional 'file.path', type: String, desc: %q(path to locally stored body (generated by Workhorse))
- optional 'file.name', type: String, desc: %q(real filename as send in Content-Disposition (generated by Workhorse))
- optional 'file.type', type: String, desc: %q(real content type as send in Content-Type (generated by Workhorse))
- optional 'file.size', type: Integer, desc: %q(real size of file (generated by Workhorse))
- optional 'file.sha256', type: String, desc: %q(sha256 checksum of the file (generated by Workhorse))
- optional 'metadata.path', type: String, desc: %q(path to locally stored body (generated by Workhorse))
- optional 'metadata.name', type: String, desc: %q(filename (generated by Workhorse))
- optional 'metadata.size', type: Integer, desc: %q(real size of metadata (generated by Workhorse))
- optional 'metadata.sha256', type: String, desc: %q(sha256 checksum of metadata (generated by Workhorse))
+ requires :id, type: Integer, desc: "Job's ID"
+ optional :token, type: String, desc: "Job's authentication token"
+ optional :expire_in, type: String, desc: "Specify when artifacts should expire"
+ optional :artifact_type, type: String, desc: "The type of artifact",
+ default: "archive", values: Ci::JobArtifact.file_types.keys
+ optional :artifact_format, type: String, desc: "The format of artifact",
+ default: "zip", values: Ci::JobArtifact.file_formats.keys
+ optional "file.path", type: String, desc: "path to locally stored body (generated by Workhorse)"
+ optional "file.name", type: String, desc: "real filename as send in Content-Disposition (generated by Workhorse)"
+ optional "file.type", type: String, desc: "real content type as send in Content-Type (generated by Workhorse)"
+ optional "file.size", type: Integer, desc: "real size of file (generated by Workhorse)"
+ optional "file.sha256", type: String, desc: "sha256 checksum of the file (generated by Workhorse)"
+ optional "metadata.path", type: String, desc: "path to locally stored body (generated by Workhorse)"
+ optional "metadata.name", type: String, desc: "filename (generated by Workhorse)"
+ optional "metadata.size", type: Integer, desc: "real size of metadata (generated by Workhorse)"
+ optional "metadata.sha256", type: String, desc: "sha256 checksum of metadata (generated by Workhorse)"
end
- post '/:id/artifacts' do
+ post "/:id/artifacts" do
not_allowed! unless Gitlab.config.artifacts.enabled
require_gitlab_workhorse!
job = authenticate_job!
- forbidden!('Job is not running!') unless job.running?
+ forbidden!("Job is not running!") unless job.running?
artifacts = UploadedFile.from_params(params, :file, JobArtifactUploader.workhorse_local_upload_path)
metadata = UploadedFile.from_params(params, :metadata, JobArtifactUploader.workhorse_local_upload_path)
- bad_request!('Missing artifacts file!') unless artifacts
+ bad_request!("Missing artifacts file!") unless artifacts
file_to_large! unless artifacts.size < max_artifacts_size
- expire_in = params['expire_in'] ||
+ expire_in = params["expire_in"] ||
Gitlab::CurrentSettings.current_application_settings.default_artifacts_expire_in
job.job_artifacts.build(
project: job.project,
file: artifacts,
- file_type: params['artifact_type'],
- file_format: params['artifact_format'],
+ file_type: params["artifact_type"],
+ file_format: params["artifact_format"],
file_sha256: artifacts.sha256,
- expire_in: expire_in)
+ expire_in: expire_in
+ )
if metadata
job.job_artifacts.build(
@@ -285,7 +286,8 @@ module API
file_type: :metadata,
file_format: :gzip,
file_sha256: metadata.sha256,
- expire_in: expire_in)
+ expire_in: expire_in
+ )
end
if job.update(artifacts_expire_in: expire_in)
@@ -295,17 +297,17 @@ module API
end
end
- desc 'Download the artifacts file for job' do
- http_codes [[200, 'Upload allowed'],
- [403, 'Forbidden'],
- [404, 'Artifact not found']]
+ desc "Download the artifacts file for job" do
+ http_codes [[200, "Upload allowed"],
+ [403, "Forbidden"],
+ [404, "Artifact not found"],]
end
params do
- requires :id, type: Integer, desc: %q(Job's ID)
- optional :token, type: String, desc: %q(Job's authentication token)
- optional :direct_download, default: false, type: Boolean, desc: %q(Perform direct download from remote storage instead of proxying artifacts)
+ requires :id, type: Integer, desc: "Job's ID"
+ optional :token, type: String, desc: "Job's authentication token"
+ optional :direct_download, default: false, type: Boolean, desc: "Perform direct download from remote storage instead of proxying artifacts"
end
- get '/:id/artifacts' do
+ get "/:id/artifacts" do
job = authenticate_job!
present_carrierwave_file!(job.artifacts_file, supports_direct_download: params[:direct_download])
diff --git a/lib/api/runners.rb b/lib/api/runners.rb
index f3fea463e7f..1e99fbabcc8 100644
--- a/lib/api/runners.rb
+++ b/lib/api/runners.rb
@@ -7,17 +7,17 @@ module API
before { authenticate! }
resource :runners do
- desc 'Get runners available for user' do
+ desc "Get runners available for user" do
success Entities::Runner
end
params do
optional :scope, type: String, values: Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The scope of specific runners to show'
+ desc: "The scope of specific runners to show"
optional :type, type: String, values: Ci::Runner::AVAILABLE_TYPES,
- desc: 'The type of the runners to show'
+ desc: "The type of the runners to show"
optional :status, type: String, values: Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The status of the runners to show'
- optional :tag_list, type: Array[String], desc: 'The tags of the runners to show'
+ desc: "The status of the runners to show"
+ optional :tag_list, type: Array[String], desc: "The tags of the runners to show"
use :pagination
end
get do
@@ -30,20 +30,20 @@ module API
present paginate(runners), with: Entities::Runner
end
- desc 'Get all runners - shared and specific' do
+ desc "Get all runners - shared and specific" do
success Entities::Runner
end
params do
optional :scope, type: String, values: Ci::Runner::AVAILABLE_SCOPES,
- desc: 'The scope of specific runners to show'
+ desc: "The scope of specific runners to show"
optional :type, type: String, values: Ci::Runner::AVAILABLE_TYPES,
- desc: 'The type of the runners to show'
+ desc: "The type of the runners to show"
optional :status, type: String, values: Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The status of the runners to show'
- optional :tag_list, type: Array[String], desc: 'The tags of the runners to show'
+ desc: "The status of the runners to show"
+ optional :tag_list, type: Array[String], desc: "The tags of the runners to show"
use :pagination
end
- get 'all' do
+ get "all" do
authenticated_as_admin!
runners = Ci::Runner.all
@@ -59,9 +59,9 @@ module API
success Entities::RunnerDetails
end
params do
- requires :id, type: Integer, desc: 'The ID of the runner'
+ requires :id, type: Integer, desc: "The ID of the runner"
end
- get ':id' do
+ get ":id" do
runner = get_runner(params[:id])
authenticate_show_runner!(runner)
@@ -72,18 +72,18 @@ module API
success Entities::RunnerDetails
end
params do
- requires :id, type: Integer, desc: 'The ID of the runner'
- optional :description, type: String, desc: 'The description of the runner'
- optional :active, type: Boolean, desc: 'The state of a runner'
- optional :tag_list, type: Array[String], desc: 'The list of tags for a runner'
- optional :run_untagged, type: Boolean, desc: 'Flag indicating the runner can execute untagged jobs'
- optional :locked, type: Boolean, desc: 'Flag indicating the runner is locked'
+ requires :id, type: Integer, desc: "The ID of the runner"
+ optional :description, type: String, desc: "The description of the runner"
+ optional :active, type: Boolean, desc: "The state of a runner"
+ optional :tag_list, type: Array[String], desc: "The list of tags for a runner"
+ optional :run_untagged, type: Boolean, desc: "Flag indicating the runner can execute untagged jobs"
+ optional :locked, type: Boolean, desc: "Flag indicating the runner is locked"
optional :access_level, type: String, values: Ci::Runner.access_levels.keys,
- desc: 'The access_level of the runner'
- optional :maximum_timeout, type: Integer, desc: 'Maximum timeout set when this Runner will handle the job'
+ desc: "The access_level of the runner"
+ optional :maximum_timeout, type: Integer, desc: "Maximum timeout set when this Runner will handle the job"
at_least_one_of :description, :active, :tag_list, :run_untagged, :locked, :access_level, :maximum_timeout
end
- put ':id' do
+ put ":id" do
runner = get_runner(params.delete(:id))
authenticate_update_runner!(runner)
update_service = Ci::UpdateRunnerService.new(runner)
@@ -95,13 +95,13 @@ module API
end
end
- desc 'Remove a runner' do
+ desc "Remove a runner" do
success Entities::Runner
end
params do
- requires :id, type: Integer, desc: 'The ID of the runner'
+ requires :id, type: Integer, desc: "The ID of the runner"
end
- delete ':id' do
+ delete ":id" do
runner = get_runner(params[:id])
authenticate_delete_runner!(runner)
@@ -109,15 +109,15 @@ module API
destroy_conditionally!(runner)
end
- desc 'List jobs running on a runner' do
+ desc "List jobs running on a runner" do
success Entities::JobBasicWithProject
end
params do
- requires :id, type: Integer, desc: 'The ID of the runner'
- optional :status, type: String, desc: 'Status of the job', values: Ci::Build::AVAILABLE_STATUSES
+ requires :id, type: Integer, desc: "The ID of the runner"
+ optional :status, type: String, desc: "Status of the job", values: Ci::Build::AVAILABLE_STATUSES
use :pagination
end
- get ':id/jobs' do
+ get ":id/jobs" do
runner = get_runner(params[:id])
authenticate_list_runners_jobs!(runner)
@@ -128,25 +128,25 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before { authorize_admin_project }
- desc 'Get runners available for project' do
+ desc "Get runners available for project" do
success Entities::Runner
end
params do
optional :scope, type: String, values: Ci::Runner::AVAILABLE_SCOPES,
- desc: 'The scope of specific runners to show'
+ desc: "The scope of specific runners to show"
optional :type, type: String, values: Ci::Runner::AVAILABLE_TYPES,
- desc: 'The type of the runners to show'
+ desc: "The type of the runners to show"
optional :status, type: String, values: Ci::Runner::AVAILABLE_STATUSES,
- desc: 'The status of the runners to show'
- optional :tag_list, type: Array[String], desc: 'The tags of the runners to show'
+ desc: "The status of the runners to show"
+ optional :tag_list, type: Array[String], desc: "The tags of the runners to show"
use :pagination
end
- get ':id/runners' do
+ get ":id/runners" do
runners = Ci::Runner.owned_or_instance_wide(user_project.id)
runners = filter_runners(runners, params[:scope])
runners = filter_runners(runners, params[:type], allowed_scopes: Ci::Runner::AVAILABLE_TYPES)
@@ -156,13 +156,13 @@ module API
present paginate(runners), with: Entities::Runner
end
- desc 'Enable a runner for a project' do
+ desc "Enable a runner for a project" do
success Entities::Runner
end
params do
- requires :runner_id, type: Integer, desc: 'The ID of the runner'
+ requires :runner_id, type: Integer, desc: "The ID of the runner"
end
- post ':id/runners' do
+ post ":id/runners" do
runner = get_runner(params[:runner_id])
authenticate_enable_runner!(runner)
@@ -177,12 +177,12 @@ module API
success Entities::Runner
end
params do
- requires :runner_id, type: Integer, desc: 'The ID of the runner'
+ requires :runner_id, type: Integer, desc: "The ID of the runner"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/runners/:runner_id' do
+ delete ":id/runners/:runner_id" do
runner_project = user_project.runner_projects.find_by(runner_id: params[:runner_id])
- not_found!('Runner') unless runner_project
+ not_found!("Runner") unless runner_project
runner = runner_project.runner
forbidden!("Only one project associated with the runner. Please remove the runner instead") if runner.projects.count == 1
@@ -197,7 +197,7 @@ module API
return runners unless scope.present?
unless allowed_scopes.include?(scope)
- render_api_error!('Scope contains invalid value', 400)
+ render_api_error!("Scope contains invalid value", 400)
end
# Support deprecated scopes
@@ -210,7 +210,7 @@ module API
def get_runner(id)
runner = Ci::Runner.find(id)
- not_found!('Runner') unless runner
+ not_found!("Runner") unless runner
runner
end
diff --git a/lib/api/scope.rb b/lib/api/scope.rb
index 707775e5d15..1f290185480 100644
--- a/lib/api/scope.rb
+++ b/lib/api/scope.rb
@@ -13,7 +13,7 @@ module API
# Are the `scopes` passed in sufficient to adequately authorize the passed
# request for the scope represented by the current instance of this class?
def sufficient?(scopes, request)
- scopes.include?(self.name) && verify_if_condition(request)
+ scopes.include?(name) && verify_if_condition(request)
end
private
diff --git a/lib/api/search.rb b/lib/api/search.rb
index f5db692afe5..cb03f880d81 100644
--- a/lib/api/search.rb
+++ b/lib/api/search.rb
@@ -17,7 +17,7 @@ module API
blobs: Entities::Blob,
wiki_blobs: Entities::Blob,
snippet_titles: Entities::Snippet,
- snippet_blobs: Entities::Snippet
+ snippet_blobs: Entities::Snippet,
}.freeze
def search(additional_params = {})
@@ -26,7 +26,7 @@ module API
search: params[:search],
snippets: snippets?,
page: params[:page],
- per_page: params[:per_page]
+ per_page: params[:per_page],
}.merge(additional_params)
results = SearchService.new(current_user, search_params).search_objects
@@ -39,7 +39,7 @@ module API
end
def snippets?
- %w(snippet_blobs snippet_titles).include?(params[:scope]).to_s
+ %w[snippet_blobs snippet_titles].include?(params[:scope]).to_s
end
def entity
@@ -48,16 +48,16 @@ module API
end
resource :search do
- desc 'Search on GitLab' do
- detail 'This feature was introduced in GitLab 10.5.'
+ desc "Search on GitLab" do
+ detail "This feature was introduced in GitLab 10.5."
end
params do
- requires :search, type: String, desc: 'The expression it should be searched for'
+ requires :search, type: String, desc: "The expression it should be searched for"
requires :scope,
type: String,
desc: 'The scope of search, available scopes:
projects, issues, merge_requests, milestones, snippet_titles, snippet_blobs',
- values: %w(projects issues merge_requests milestones snippet_titles snippet_blobs)
+ values: %w[projects issues merge_requests milestones snippet_titles snippet_blobs]
use :pagination
end
get do
@@ -66,39 +66,39 @@ module API
end
resource :groups, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Search on GitLab' do
- detail 'This feature was introduced in GitLab 10.5.'
+ desc "Search on GitLab" do
+ detail "This feature was introduced in GitLab 10.5."
end
params do
- requires :id, type: String, desc: 'The ID of a group'
- requires :search, type: String, desc: 'The expression it should be searched for'
+ requires :id, type: String, desc: "The ID of a group"
+ requires :search, type: String, desc: "The expression it should be searched for"
requires :scope,
type: String,
desc: 'The scope of search, available scopes:
projects, issues, merge_requests, milestones',
- values: %w(projects issues merge_requests milestones)
+ values: %w[projects issues merge_requests milestones]
use :pagination
end
- get ':id/(-/)search' do
+ get ":id/(-/)search" do
present search(group_id: user_group.id), with: entity
end
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Search on GitLab' do
- detail 'This feature was introduced in GitLab 10.5.'
+ desc "Search on GitLab" do
+ detail "This feature was introduced in GitLab 10.5."
end
params do
- requires :id, type: String, desc: 'The ID of a project'
- requires :search, type: String, desc: 'The expression it should be searched for'
+ requires :id, type: String, desc: "The ID of a project"
+ requires :search, type: String, desc: "The expression it should be searched for"
requires :scope,
type: String,
desc: 'The scope of search, available scopes:
issues, merge_requests, milestones, notes, wiki_blobs, commits, blobs',
- values: %w(issues merge_requests milestones notes wiki_blobs commits blobs)
+ values: %w[issues merge_requests milestones notes wiki_blobs commits blobs]
use :pagination
end
- get ':id/(-/)search' do
+ get ":id/(-/)search" do
present search(project_id: user_project.id), with: entity
end
end
diff --git a/lib/api/services.rb b/lib/api/services.rb
index bda6be51553..60a37802ca5 100644
--- a/lib/api/services.rb
+++ b/lib/api/services.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module API
class Services < Grape::API
CHAT_NOTIFICATION_SETTINGS = [
@@ -6,20 +7,20 @@ module API
required: true,
name: :webhook,
type: String,
- desc: 'The chat webhook'
+ desc: "The chat webhook",
},
{
required: false,
name: :username,
type: String,
- desc: 'The chat username'
+ desc: "The chat username",
},
{
required: false,
name: :channel,
type: String,
- desc: 'The default chat channel'
- }
+ desc: "The default chat channel",
+ },
].freeze
CHAT_NOTIFICATION_FLAGS = [
@@ -27,14 +28,14 @@ module API
required: false,
name: :notify_only_broken_pipelines,
type: Boolean,
- desc: 'Send notifications for broken pipelines'
+ desc: "Send notifications for broken pipelines",
},
{
required: false,
name: :notify_only_default_branch,
type: Boolean,
- desc: 'Send notifications only for the default branch'
- }
+ desc: "Send notifications only for the default branch",
+ },
].freeze
CHAT_NOTIFICATION_CHANNELS = [
@@ -42,50 +43,50 @@ module API
required: false,
name: :push_channel,
type: String,
- desc: 'The name of the channel to receive push_events notifications'
+ desc: "The name of the channel to receive push_events notifications",
},
{
required: false,
name: :issue_channel,
type: String,
- desc: 'The name of the channel to receive issues_events notifications'
+ desc: "The name of the channel to receive issues_events notifications",
},
{
required: false,
name: :confidential_issue_channel,
type: String,
- desc: 'The name of the channel to receive confidential_issues_events notifications'
+ desc: "The name of the channel to receive confidential_issues_events notifications",
},
{
required: false,
name: :merge_request_channel,
type: String,
- desc: 'The name of the channel to receive merge_requests_events notifications'
+ desc: "The name of the channel to receive merge_requests_events notifications",
},
{
required: false,
name: :note_channel,
type: String,
- desc: 'The name of the channel to receive note_events notifications'
+ desc: "The name of the channel to receive note_events notifications",
},
{
required: false,
name: :tag_push_channel,
type: String,
- desc: 'The name of the channel to receive tag_push_events notifications'
+ desc: "The name of the channel to receive tag_push_events notifications",
},
{
required: false,
name: :pipeline_channel,
type: String,
- desc: 'The name of the channel to receive pipeline_events notifications'
+ desc: "The name of the channel to receive pipeline_events notifications",
},
{
required: false,
name: :wiki_page_channel,
type: String,
- desc: 'The name of the channel to receive wiki_page_events notifications'
- }
+ desc: "The name of the channel to receive wiki_page_events notifications",
+ },
].freeze
CHAT_NOTIFICATION_EVENTS = [
@@ -93,571 +94,571 @@ module API
required: false,
name: :push_events,
type: Boolean,
- desc: 'Enable notifications for push_events'
+ desc: "Enable notifications for push_events",
},
{
required: false,
name: :issues_events,
type: Boolean,
- desc: 'Enable notifications for issues_events'
+ desc: "Enable notifications for issues_events",
},
{
required: false,
name: :confidential_issues_events,
type: Boolean,
- desc: 'Enable notifications for confidential_issues_events'
+ desc: "Enable notifications for confidential_issues_events",
},
{
required: false,
name: :merge_requests_events,
type: Boolean,
- desc: 'Enable notifications for merge_requests_events'
+ desc: "Enable notifications for merge_requests_events",
},
{
required: false,
name: :note_events,
type: Boolean,
- desc: 'Enable notifications for note_events'
+ desc: "Enable notifications for note_events",
},
{
required: false,
name: :tag_push_events,
type: Boolean,
- desc: 'Enable notifications for tag_push_events'
+ desc: "Enable notifications for tag_push_events",
},
{
required: false,
name: :pipeline_events,
type: Boolean,
- desc: 'Enable notifications for pipeline_events'
+ desc: "Enable notifications for pipeline_events",
},
{
required: false,
name: :wiki_page_events,
type: Boolean,
- desc: 'Enable notifications for wiki_page_events'
- }
+ desc: "Enable notifications for wiki_page_events",
+ },
].freeze
services = {
- 'asana' => [
+ "asana" => [
{
required: true,
name: :api_key,
type: String,
- desc: 'User API token'
+ desc: "User API token",
},
{
required: false,
name: :restrict_to_branch,
type: String,
- desc: 'Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches'
- }
+ desc: "Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches",
+ },
],
- 'assembla' => [
+ "assembla" => [
{
required: true,
name: :token,
type: String,
- desc: 'The authentication token'
+ desc: "The authentication token",
},
{
required: false,
name: :subdomain,
type: String,
- desc: 'Subdomain setting'
- }
+ desc: "Subdomain setting",
+ },
],
- 'bamboo' => [
+ "bamboo" => [
{
required: true,
name: :bamboo_url,
type: String,
- desc: 'Bamboo root URL like https://bamboo.example.com'
+ desc: "Bamboo root URL like https://bamboo.example.com",
},
{
required: true,
name: :build_key,
type: String,
- desc: 'Bamboo build plan key like'
+ desc: "Bamboo build plan key like",
},
{
required: true,
name: :username,
type: String,
- desc: 'A user with API access, if applicable'
+ desc: "A user with API access, if applicable",
},
{
required: true,
name: :password,
type: String,
- desc: 'Passord of the user'
- }
+ desc: "Passord of the user",
+ },
],
- 'bugzilla' => [
+ "bugzilla" => [
{
required: true,
name: :new_issue_url,
type: String,
- desc: 'New issue URL'
+ desc: "New issue URL",
},
{
required: true,
name: :issues_url,
type: String,
- desc: 'Issues URL'
+ desc: "Issues URL",
},
{
required: true,
name: :project_url,
type: String,
- desc: 'Project URL'
+ desc: "Project URL",
},
{
required: false,
name: :description,
type: String,
- desc: 'Description'
+ desc: "Description",
},
{
required: false,
name: :title,
type: String,
- desc: 'Title'
- }
+ desc: "Title",
+ },
],
- 'buildkite' => [
+ "buildkite" => [
{
required: true,
name: :token,
type: String,
- desc: 'Buildkite project GitLab token'
+ desc: "Buildkite project GitLab token",
},
{
required: true,
name: :project_url,
type: String,
- desc: 'The buildkite project URL'
+ desc: "The buildkite project URL",
},
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
- desc: 'Enable SSL verification for communication'
- }
+ desc: "Enable SSL verification for communication",
+ },
],
- 'campfire' => [
+ "campfire" => [
{
required: true,
name: :token,
type: String,
- desc: 'Campfire token'
+ desc: "Campfire token",
},
{
required: false,
name: :subdomain,
type: String,
- desc: 'Campfire subdomain'
+ desc: "Campfire subdomain",
},
{
required: false,
name: :room,
type: String,
- desc: 'Campfire room'
- }
+ desc: "Campfire room",
+ },
],
- 'custom-issue-tracker' => [
+ "custom-issue-tracker" => [
{
required: true,
name: :new_issue_url,
type: String,
- desc: 'New issue URL'
+ desc: "New issue URL",
},
{
required: true,
name: :issues_url,
type: String,
- desc: 'Issues URL'
+ desc: "Issues URL",
},
{
required: true,
name: :project_url,
type: String,
- desc: 'Project URL'
+ desc: "Project URL",
},
{
required: false,
name: :description,
type: String,
- desc: 'Description'
+ desc: "Description",
},
{
required: false,
name: :title,
type: String,
- desc: 'Title'
- }
+ desc: "Title",
+ },
],
- 'discord' => [
+ "discord" => [
{
required: true,
name: :webhook,
type: String,
- desc: 'Discord webhook. e.g. https://discordapp.com/api/webhooks/…'
- }
+ desc: "Discord webhook. e.g. https://discordapp.com/api/webhooks/…",
+ },
],
- 'drone-ci' => [
+ "drone-ci" => [
{
required: true,
name: :token,
type: String,
- desc: 'Drone CI token'
+ desc: "Drone CI token",
},
{
required: true,
name: :drone_url,
type: String,
- desc: 'Drone CI URL'
+ desc: "Drone CI URL",
},
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
- desc: 'Enable SSL verification for communication'
- }
+ desc: "Enable SSL verification for communication",
+ },
],
- 'emails-on-push' => [
+ "emails-on-push" => [
{
required: true,
name: :recipients,
type: String,
- desc: 'Comma-separated list of recipient email addresses'
+ desc: "Comma-separated list of recipient email addresses",
},
{
required: false,
name: :disable_diffs,
type: Boolean,
- desc: 'Disable code diffs'
+ desc: "Disable code diffs",
},
{
required: false,
name: :send_from_committer_email,
type: Boolean,
- desc: 'Send from committer'
- }
+ desc: "Send from committer",
+ },
],
- 'external-wiki' => [
+ "external-wiki" => [
{
required: true,
name: :external_wiki_url,
type: String,
- desc: 'The URL of the external Wiki'
- }
+ desc: "The URL of the external Wiki",
+ },
],
- 'flowdock' => [
+ "flowdock" => [
{
required: true,
name: :token,
type: String,
- desc: 'Flowdock token'
- }
+ desc: "Flowdock token",
+ },
],
- 'hangouts-chat' => [
+ "hangouts-chat" => [
{
required: true,
name: :webhook,
type: String,
- desc: 'The Hangouts Chat webhook. e.g. https://chat.googleapis.com/v1/spaces…'
+ desc: "The Hangouts Chat webhook. e.g. https://chat.googleapis.com/v1/spaces…",
},
- CHAT_NOTIFICATION_EVENTS
+ CHAT_NOTIFICATION_EVENTS,
].flatten,
- 'irker' => [
+ "irker" => [
{
required: true,
name: :recipients,
type: String,
- desc: 'Recipients/channels separated by whitespaces'
+ desc: "Recipients/channels separated by whitespaces",
},
{
required: false,
name: :default_irc_uri,
type: String,
- desc: 'Default: irc://irc.network.net:6697'
+ desc: "Default: irc://irc.network.net:6697",
},
{
required: false,
name: :server_host,
type: String,
- desc: 'Server host. Default localhost'
+ desc: "Server host. Default localhost",
},
{
required: false,
name: :server_port,
type: Integer,
- desc: 'Server port. Default 6659'
+ desc: "Server port. Default 6659",
},
{
required: false,
name: :colorize_messages,
type: Boolean,
- desc: 'Colorize messages'
- }
+ desc: "Colorize messages",
+ },
],
- 'jira' => [
+ "jira" => [
{
required: true,
name: :url,
type: String,
- desc: 'The base URL to the JIRA instance web interface which is being linked to this GitLab project. E.g., https://jira.example.com'
+ desc: "The base URL to the JIRA instance web interface which is being linked to this GitLab project. E.g., https://jira.example.com",
},
{
required: false,
name: :api_url,
type: String,
- desc: 'The base URL to the JIRA instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com'
+ desc: "The base URL to the JIRA instance API. Web URL value will be used if not set. E.g., https://jira-api.example.com",
},
{
required: true,
name: :username,
type: String,
- desc: 'The username of the user created to be used with GitLab/JIRA'
+ desc: "The username of the user created to be used with GitLab/JIRA",
},
{
required: true,
name: :password,
type: String,
- desc: 'The password of the user created to be used with GitLab/JIRA'
+ desc: "The password of the user created to be used with GitLab/JIRA",
},
{
required: false,
name: :jira_issue_transition_id,
type: String,
- desc: 'The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`'
- }
+ desc: "The ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`",
+ },
],
- 'kubernetes' => [
+ "kubernetes" => [
{
required: true,
name: :namespace,
type: String,
- desc: 'The Kubernetes namespace to use'
+ desc: "The Kubernetes namespace to use",
},
{
required: true,
name: :api_url,
type: String,
- desc: 'The URL to the Kubernetes cluster API, e.g., https://kubernetes.example.com'
+ desc: "The URL to the Kubernetes cluster API, e.g., https://kubernetes.example.com",
},
{
required: true,
name: :token,
type: String,
- desc: 'The service token to authenticate against the Kubernetes cluster with'
+ desc: "The service token to authenticate against the Kubernetes cluster with",
},
{
required: false,
name: :ca_pem,
type: String,
- desc: 'A custom certificate authority bundle to verify the Kubernetes cluster with (PEM format)'
- }
+ desc: "A custom certificate authority bundle to verify the Kubernetes cluster with (PEM format)",
+ },
],
- 'mattermost-slash-commands' => [
+ "mattermost-slash-commands" => [
{
required: true,
name: :token,
type: String,
- desc: 'The Mattermost token'
- }
+ desc: "The Mattermost token",
+ },
],
- 'slack-slash-commands' => [
+ "slack-slash-commands" => [
{
required: true,
name: :token,
type: String,
- desc: 'The Slack token'
- }
+ desc: "The Slack token",
+ },
],
- 'packagist' => [
+ "packagist" => [
{
required: true,
name: :username,
type: String,
- desc: 'The username'
+ desc: "The username",
},
{
required: true,
name: :token,
type: String,
- desc: 'The Packagist API token'
+ desc: "The Packagist API token",
},
{
required: false,
name: :server,
type: String,
- desc: 'The server'
- }
+ desc: "The server",
+ },
],
- 'pipelines-email' => [
+ "pipelines-email" => [
{
required: true,
name: :recipients,
type: String,
- desc: 'Comma-separated list of recipient email addresses'
+ desc: "Comma-separated list of recipient email addresses",
},
{
required: false,
name: :notify_only_broken_pipelines,
type: Boolean,
- desc: 'Notify only broken pipelines'
- }
+ desc: "Notify only broken pipelines",
+ },
],
- 'pivotaltracker' => [
+ "pivotaltracker" => [
{
required: true,
name: :token,
type: String,
- desc: 'The Pivotaltracker token'
+ desc: "The Pivotaltracker token",
},
{
required: false,
name: :restrict_to_branch,
type: String,
- desc: 'Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches.'
- }
+ desc: "Comma-separated list of branches which will be automatically inspected. Leave blank to include all branches.",
+ },
],
- 'prometheus' => [
+ "prometheus" => [
{
required: true,
name: :api_url,
type: String,
- desc: 'Prometheus API Base URL, like http://prometheus.example.com/'
- }
+ desc: "Prometheus API Base URL, like http://prometheus.example.com/",
+ },
],
- 'pushover' => [
+ "pushover" => [
{
required: true,
name: :api_key,
type: String,
- desc: 'The application key'
+ desc: "The application key",
},
{
required: true,
name: :user_key,
type: String,
- desc: 'The user key'
+ desc: "The user key",
},
{
required: true,
name: :priority,
type: String,
- desc: 'The priority'
+ desc: "The priority",
},
{
required: true,
name: :device,
type: String,
- desc: 'Leave blank for all active devices'
+ desc: "Leave blank for all active devices",
},
{
required: true,
name: :sound,
type: String,
- desc: 'The sound of the notification'
- }
+ desc: "The sound of the notification",
+ },
],
- 'redmine' => [
+ "redmine" => [
{
required: true,
name: :new_issue_url,
type: String,
- desc: 'The new issue URL'
+ desc: "The new issue URL",
},
{
required: true,
name: :project_url,
type: String,
- desc: 'The project URL'
+ desc: "The project URL",
},
{
required: true,
name: :issues_url,
type: String,
- desc: 'The issues URL'
+ desc: "The issues URL",
},
{
required: false,
name: :description,
type: String,
- desc: 'The description of the tracker'
- }
+ desc: "The description of the tracker",
+ },
],
- 'youtrack' => [
+ "youtrack" => [
{
required: true,
name: :project_url,
type: String,
- desc: 'The project URL'
+ desc: "The project URL",
},
{
required: true,
name: :issues_url,
type: String,
- desc: 'The issues URL'
+ desc: "The issues URL",
},
{
required: false,
name: :description,
type: String,
- desc: 'The description of the tracker'
- }
+ desc: "The description of the tracker",
+ },
],
- 'slack' => [
+ "slack" => [
CHAT_NOTIFICATION_SETTINGS,
CHAT_NOTIFICATION_FLAGS,
CHAT_NOTIFICATION_CHANNELS,
- CHAT_NOTIFICATION_EVENTS
+ CHAT_NOTIFICATION_EVENTS,
].flatten,
- 'microsoft-teams' => [
+ "microsoft-teams" => [
{
required: true,
name: :webhook,
type: String,
- desc: 'The Microsoft Teams webhook. e.g. https://outlook.office.com/webhook/…'
- }
+ desc: "The Microsoft Teams webhook. e.g. https://outlook.office.com/webhook/…",
+ },
],
- 'mattermost' => [
+ "mattermost" => [
CHAT_NOTIFICATION_SETTINGS,
CHAT_NOTIFICATION_FLAGS,
CHAT_NOTIFICATION_CHANNELS,
- CHAT_NOTIFICATION_EVENTS
+ CHAT_NOTIFICATION_EVENTS,
].flatten,
- 'teamcity' => [
+ "teamcity" => [
{
required: true,
name: :teamcity_url,
type: String,
- desc: 'TeamCity root URL like https://teamcity.example.com'
+ desc: "TeamCity root URL like https://teamcity.example.com",
},
{
required: true,
name: :build_type,
type: String,
- desc: 'Build configuration ID'
+ desc: "Build configuration ID",
},
{
required: true,
name: :username,
type: String,
- desc: 'A user with permissions to trigger a manual build'
+ desc: "A user with permissions to trigger a manual build",
},
{
required: true,
name: :password,
type: String,
- desc: 'The password of the user'
- }
- ]
+ desc: "The password of the user",
+ },
+ ],
}
service_classes = [
@@ -689,25 +690,25 @@ module API
SlackService,
MattermostService,
MicrosoftTeamsService,
- TeamcityService
+ TeamcityService,
]
if Rails.env.development?
- services['mock-ci'] = [
+ services["mock-ci"] = [
{
required: true,
name: :mock_service_url,
type: String,
- desc: 'URL to the mock service'
- }
+ desc: "URL to the mock service",
+ },
]
- services['mock-deployment'] = []
- services['mock-monitoring'] = []
+ services["mock-deployment"] = []
+ services["mock-monitoring"] = []
service_classes += [
MockCiService,
MockDeploymentService,
- MockMonitoringService
+ MockMonitoringService,
]
end
@@ -721,30 +722,30 @@ module API
required: false,
name: event_name.to_sym,
type: String,
- desc: service.event_description(event_name)
+ desc: service.event_description(event_name),
}
end
end
TRIGGER_SERVICES = {
- 'mattermost-slash-commands' => [
+ "mattermost-slash-commands" => [
{
name: :token,
type: String,
- desc: 'The Mattermost token'
- }
+ desc: "The Mattermost token",
+ },
],
- 'slack-slash-commands' => [
+ "slack-slash-commands" => [
{
name: :token,
type: String,
- desc: 'The Slack token'
- }
- ]
+ desc: "The Slack token",
+ },
+ ],
}.freeze
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
before { authenticate! }
@@ -776,34 +777,34 @@ module API
if service.update(service_params)
present service, with: Entities::ProjectService
else
- render_api_error!('400 Bad Request', 400)
+ render_api_error!("400 Bad Request", 400)
end
end
end
desc "Delete a service for project"
params do
- requires :service_slug, type: String, values: SERVICES.keys, desc: 'The name of the service'
+ requires :service_slug, type: String, values: SERVICES.keys, desc: "The name of the service"
end
delete ":id/services/:service_slug" do
service = user_project.find_or_initialize_service(params[:service_slug].underscore)
destroy_conditionally!(service) do
- attrs = service_attributes(service).inject({}) do |hash, key|
+ attrs = service_attributes(service).inject({}) { |hash, key|
hash.merge!(key => nil)
- end
+ }
unless service.update(attrs.merge(active: false))
- render_api_error!('400 Bad Request', 400)
+ render_api_error!("400 Bad Request", 400)
end
end
end
- desc 'Get the service settings for project' do
+ desc "Get the service settings for project" do
success Entities::ProjectService
end
params do
- requires :service_slug, type: String, values: SERVICES.keys, desc: 'The name of the service'
+ requires :service_slug, type: String, values: SERVICES.keys, desc: "The name of the service"
end
get ":id/services/:service_slug" do
service = user_project.find_or_initialize_service(params[:service_slug].underscore)
@@ -823,11 +824,11 @@ module API
end
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
desc "Trigger a slash command for #{service_slug}" do
- detail 'Added in GitLab 8.13'
+ detail "Added in GitLab 8.13"
end
params do
settings.each do |setting|
@@ -838,7 +839,7 @@ module API
project = find_project(params[:id])
# This is not accurate, but done to prevent leakage of the project names
- not_found!('Service') unless project
+ not_found!("Service") unless project
service = slash_command_service(project, service_slug, params)
result = service.try(:trigger, params)
@@ -847,7 +848,7 @@ module API
status result[:status] || 200
present result
else
- not_found!('Service')
+ not_found!("Service")
end
end
end
diff --git a/lib/api/settings.rb b/lib/api/settings.rb
index b16faffe335..08dee0a1047 100644
--- a/lib/api/settings.rb
+++ b/lib/api/settings.rb
@@ -11,123 +11,123 @@ module API
end
end
- desc 'Get the current application settings' do
+ desc "Get the current application settings" do
success Entities::ApplicationSetting
end
get "application/settings" do
present current_settings, with: Entities::ApplicationSetting
end
- desc 'Modify application settings' do
+ desc "Modify application settings" do
success Entities::ApplicationSetting
end
params do
- optional :admin_notification_email, type: String, desc: 'Abuse reports will be sent to this address if it is set. Abuse reports are always available in the admin area.'
- optional :after_sign_up_text, type: String, desc: 'Text shown after sign up'
- optional :after_sign_out_path, type: String, desc: 'We will redirect users to this page after they sign out'
- optional :akismet_enabled, type: Boolean, desc: 'Helps prevent bots from creating issues'
+ optional :admin_notification_email, type: String, desc: "Abuse reports will be sent to this address if it is set. Abuse reports are always available in the admin area."
+ optional :after_sign_up_text, type: String, desc: "Text shown after sign up"
+ optional :after_sign_out_path, type: String, desc: "We will redirect users to this page after they sign out"
+ optional :akismet_enabled, type: Boolean, desc: "Helps prevent bots from creating issues"
given akismet_enabled: ->(val) { val } do
- requires :akismet_api_key, type: String, desc: 'Generate API key at http://www.akismet.com'
+ requires :akismet_api_key, type: String, desc: "Generate API key at http://www.akismet.com"
end
- optional :clientside_sentry_enabled, type: Boolean, desc: 'Sentry can also be used for reporting and logging clientside exceptions. https://sentry.io/for/javascript/'
+ optional :clientside_sentry_enabled, type: Boolean, desc: "Sentry can also be used for reporting and logging clientside exceptions. https://sentry.io/for/javascript/"
given clientside_sentry_enabled: ->(val) { val } do
- requires :clientside_sentry_dsn, type: String, desc: 'Clientside Sentry Data Source Name'
+ requires :clientside_sentry_dsn, type: String, desc: "Clientside Sentry Data Source Name"
end
- optional :container_registry_token_expire_delay, type: Integer, desc: 'Authorization token duration (minutes)'
+ optional :container_registry_token_expire_delay, type: Integer, desc: "Authorization token duration (minutes)"
optional :default_artifacts_expire_in, type: String, desc: "Set the default expiration time for each job's artifacts"
- optional :default_branch_protection, type: Integer, values: Gitlab::Access.protection_values, desc: 'Determine if developers can push to master'
- optional :default_group_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The default group visibility'
- optional :default_project_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The default project visibility'
- optional :default_projects_limit, type: Integer, desc: 'The maximum number of personal projects'
- optional :default_snippet_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The default snippet visibility'
- optional :disabled_oauth_sign_in_sources, type: Array[String], desc: 'Disable certain OAuth sign-in sources'
- optional :domain_blacklist_enabled, type: Boolean, desc: 'Enable domain blacklist for sign ups'
+ optional :default_branch_protection, type: Integer, values: Gitlab::Access.protection_values, desc: "Determine if developers can push to master"
+ optional :default_group_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: "The default group visibility"
+ optional :default_project_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: "The default project visibility"
+ optional :default_projects_limit, type: Integer, desc: "The maximum number of personal projects"
+ optional :default_snippet_visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: "The default snippet visibility"
+ optional :disabled_oauth_sign_in_sources, type: Array[String], desc: "Disable certain OAuth sign-in sources"
+ optional :domain_blacklist_enabled, type: Boolean, desc: "Enable domain blacklist for sign ups"
given domain_blacklist_enabled: ->(val) { val } do
- requires :domain_blacklist, type: String, desc: 'Users with e-mail addresses that match these domain(s) will NOT be able to sign-up. Wildcards allowed. Use separate lines for multiple entries. Ex: domain.com, *.domain.com'
- end
- optional :domain_whitelist, type: String, desc: 'ONLY users with e-mail addresses that match these domain(s) will be able to sign-up. Wildcards allowed. Use separate lines for multiple entries. Ex: domain.com, *.domain.com'
- optional :email_author_in_body, type: Boolean, desc: 'Some email servers do not support overriding the email sender name. Enable this option to include the name of the author of the issue, merge request or comment in the email body instead.'
- optional :enabled_git_access_protocol, type: String, values: %w[ssh http nil], desc: 'Allow only the selected protocols to be used for Git access.'
- optional :gitaly_timeout_default, type: Integer, desc: 'Default Gitaly timeout, in seconds. Set to 0 to disable timeouts.'
- optional :gitaly_timeout_fast, type: Integer, desc: 'Gitaly fast operation timeout, in seconds. Set to 0 to disable timeouts.'
- optional :gitaly_timeout_medium, type: Integer, desc: 'Medium Gitaly timeout, in seconds. Set to 0 to disable timeouts.'
- optional :gravatar_enabled, type: Boolean, desc: 'Flag indicating if the Gravatar service is enabled'
- optional :help_page_hide_commercial_content, type: Boolean, desc: 'Hide marketing-related entries from help'
- optional :help_page_support_url, type: String, desc: 'Alternate support URL for help page'
- optional :help_page_text, type: String, desc: 'Custom text displayed on the help page'
- optional :home_page_url, type: String, desc: 'We will redirect non-logged in users to this page'
- optional :housekeeping_enabled, type: Boolean, desc: 'Enable automatic repository housekeeping (git repack, git gc)'
+ requires :domain_blacklist, type: String, desc: "Users with e-mail addresses that match these domain(s) will NOT be able to sign-up. Wildcards allowed. Use separate lines for multiple entries. Ex: domain.com, *.domain.com"
+ end
+ optional :domain_whitelist, type: String, desc: "ONLY users with e-mail addresses that match these domain(s) will be able to sign-up. Wildcards allowed. Use separate lines for multiple entries. Ex: domain.com, *.domain.com"
+ optional :email_author_in_body, type: Boolean, desc: "Some email servers do not support overriding the email sender name. Enable this option to include the name of the author of the issue, merge request or comment in the email body instead."
+ optional :enabled_git_access_protocol, type: String, values: %w[ssh http nil], desc: "Allow only the selected protocols to be used for Git access."
+ optional :gitaly_timeout_default, type: Integer, desc: "Default Gitaly timeout, in seconds. Set to 0 to disable timeouts."
+ optional :gitaly_timeout_fast, type: Integer, desc: "Gitaly fast operation timeout, in seconds. Set to 0 to disable timeouts."
+ optional :gitaly_timeout_medium, type: Integer, desc: "Medium Gitaly timeout, in seconds. Set to 0 to disable timeouts."
+ optional :gravatar_enabled, type: Boolean, desc: "Flag indicating if the Gravatar service is enabled"
+ optional :help_page_hide_commercial_content, type: Boolean, desc: "Hide marketing-related entries from help"
+ optional :help_page_support_url, type: String, desc: "Alternate support URL for help page"
+ optional :help_page_text, type: String, desc: "Custom text displayed on the help page"
+ optional :home_page_url, type: String, desc: "We will redirect non-logged in users to this page"
+ optional :housekeeping_enabled, type: Boolean, desc: "Enable automatic repository housekeeping (git repack, git gc)"
given housekeeping_enabled: ->(val) { val } do
requires :housekeeping_bitmaps_enabled, type: Boolean, desc: "Creating pack file bitmaps makes housekeeping take a little longer but bitmaps should accelerate 'git clone' performance."
requires :housekeeping_full_repack_period, type: Integer, desc: "Number of Git pushes after which a full 'git repack' is run."
requires :housekeeping_gc_period, type: Integer, desc: "Number of Git pushes after which 'git gc' is run."
requires :housekeeping_incremental_repack_period, type: Integer, desc: "Number of Git pushes after which an incremental 'git repack' is run."
end
- optional :html_emails_enabled, type: Boolean, desc: 'By default GitLab sends emails in HTML and plain text formats so mail clients can choose what format to use. Disable this option if you only want to send emails in plain text format.'
+ optional :html_emails_enabled, type: Boolean, desc: "By default GitLab sends emails in HTML and plain text formats so mail clients can choose what format to use. Disable this option if you only want to send emails in plain text format."
optional :import_sources, type: Array[String], values: %w[github bitbucket gitlab google_code fogbugz git gitlab_project manifest],
- desc: 'Enabled sources for code import during project creation. OmniAuth must be configured for GitHub, Bitbucket, and GitLab.com'
+ desc: "Enabled sources for code import during project creation. OmniAuth must be configured for GitHub, Bitbucket, and GitLab.com"
optional :max_artifacts_size, type: Integer, desc: "Set the maximum file size for each job's artifacts"
- optional :max_attachment_size, type: Integer, desc: 'Maximum attachment size in MB'
- optional :max_pages_size, type: Integer, desc: 'Maximum size of pages in MB'
- optional :metrics_enabled, type: Boolean, desc: 'Enable the InfluxDB metrics'
+ optional :max_attachment_size, type: Integer, desc: "Maximum attachment size in MB"
+ optional :max_pages_size, type: Integer, desc: "Maximum size of pages in MB"
+ optional :metrics_enabled, type: Boolean, desc: "Enable the InfluxDB metrics"
given metrics_enabled: ->(val) { val } do
- requires :metrics_host, type: String, desc: 'The InfluxDB host'
- requires :metrics_method_call_threshold, type: Integer, desc: 'A method call is only tracked when it takes longer to complete than the given amount of milliseconds.'
- requires :metrics_packet_size, type: Integer, desc: 'The amount of points to store in a single UDP packet'
- requires :metrics_pool_size, type: Integer, desc: 'The amount of InfluxDB connections to open'
- requires :metrics_port, type: Integer, desc: 'The UDP port to use for connecting to InfluxDB'
- requires :metrics_sample_interval, type: Integer, desc: 'The sampling interval in seconds'
- requires :metrics_timeout, type: Integer, desc: 'The amount of seconds after which an InfluxDB connection will time out'
- end
- optional :password_authentication_enabled, type: Boolean, desc: 'Flag indicating if password authentication is enabled for the web interface' # support legacy names, can be removed in v5
- optional :password_authentication_enabled_for_web, type: Boolean, desc: 'Flag indicating if password authentication is enabled for the web interface'
+ requires :metrics_host, type: String, desc: "The InfluxDB host"
+ requires :metrics_method_call_threshold, type: Integer, desc: "A method call is only tracked when it takes longer to complete than the given amount of milliseconds."
+ requires :metrics_packet_size, type: Integer, desc: "The amount of points to store in a single UDP packet"
+ requires :metrics_pool_size, type: Integer, desc: "The amount of InfluxDB connections to open"
+ requires :metrics_port, type: Integer, desc: "The UDP port to use for connecting to InfluxDB"
+ requires :metrics_sample_interval, type: Integer, desc: "The sampling interval in seconds"
+ requires :metrics_timeout, type: Integer, desc: "The amount of seconds after which an InfluxDB connection will time out"
+ end
+ optional :password_authentication_enabled, type: Boolean, desc: "Flag indicating if password authentication is enabled for the web interface" # support legacy names, can be removed in v5
+ optional :password_authentication_enabled_for_web, type: Boolean, desc: "Flag indicating if password authentication is enabled for the web interface"
mutually_exclusive :password_authentication_enabled_for_web, :password_authentication_enabled, :signin_enabled
- optional :password_authentication_enabled_for_git, type: Boolean, desc: 'Flag indicating if password authentication is enabled for Git over HTTP(S)'
- optional :performance_bar_allowed_group_id, type: String, desc: 'Deprecated: Use :performance_bar_allowed_group_path instead. Path of the group that is allowed to toggle the performance bar.' # support legacy names, can be removed in v6
- optional :performance_bar_allowed_group_path, type: String, desc: 'Path of the group that is allowed to toggle the performance bar.'
- optional :performance_bar_enabled, type: String, desc: 'Deprecated: Pass `performance_bar_allowed_group_path: nil` instead. Allow enabling the performance.' # support legacy names, can be removed in v6
- optional :plantuml_enabled, type: Boolean, desc: 'Enable PlantUML'
+ optional :password_authentication_enabled_for_git, type: Boolean, desc: "Flag indicating if password authentication is enabled for Git over HTTP(S)"
+ optional :performance_bar_allowed_group_id, type: String, desc: "Deprecated: Use :performance_bar_allowed_group_path instead. Path of the group that is allowed to toggle the performance bar." # support legacy names, can be removed in v6
+ optional :performance_bar_allowed_group_path, type: String, desc: "Path of the group that is allowed to toggle the performance bar."
+ optional :performance_bar_enabled, type: String, desc: "Deprecated: Pass `performance_bar_allowed_group_path: nil` instead. Allow enabling the performance." # support legacy names, can be removed in v6
+ optional :plantuml_enabled, type: Boolean, desc: "Enable PlantUML"
given plantuml_enabled: ->(val) { val } do
- requires :plantuml_url, type: String, desc: 'The PlantUML server URL'
+ requires :plantuml_url, type: String, desc: "The PlantUML server URL"
end
- optional :polling_interval_multiplier, type: BigDecimal, desc: 'Interval multiplier used by endpoints that perform polling. Set to 0 to disable polling.'
- optional :project_export_enabled, type: Boolean, desc: 'Enable project export'
- optional :prometheus_metrics_enabled, type: Boolean, desc: 'Enable Prometheus metrics'
- optional :recaptcha_enabled, type: Boolean, desc: 'Helps prevent bots from creating accounts'
+ optional :polling_interval_multiplier, type: BigDecimal, desc: "Interval multiplier used by endpoints that perform polling. Set to 0 to disable polling."
+ optional :project_export_enabled, type: Boolean, desc: "Enable project export"
+ optional :prometheus_metrics_enabled, type: Boolean, desc: "Enable Prometheus metrics"
+ optional :recaptcha_enabled, type: Boolean, desc: "Helps prevent bots from creating accounts"
given recaptcha_enabled: ->(val) { val } do
- requires :recaptcha_site_key, type: String, desc: 'Generate site key at http://www.google.com/recaptcha'
- requires :recaptcha_private_key, type: String, desc: 'Generate private key at http://www.google.com/recaptcha'
+ requires :recaptcha_site_key, type: String, desc: "Generate site key at http://www.google.com/recaptcha"
+ requires :recaptcha_private_key, type: String, desc: "Generate private key at http://www.google.com/recaptcha"
end
optional :repository_checks_enabled, type: Boolean, desc: "GitLab will periodically run 'git fsck' in all project and wiki repositories to look for silent disk corruption issues."
- optional :repository_storages, type: Array[String], desc: 'Storage paths for new projects'
- optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users to set up Two-factor authentication'
+ optional :repository_storages, type: Array[String], desc: "Storage paths for new projects"
+ optional :require_two_factor_authentication, type: Boolean, desc: "Require all users to set up Two-factor authentication"
given require_two_factor_authentication: ->(val) { val } do
- requires :two_factor_grace_period, type: Integer, desc: 'Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication'
+ requires :two_factor_grace_period, type: Integer, desc: "Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication"
end
- optional :restricted_visibility_levels, type: Array[String], desc: 'Selected levels cannot be used by non-admin users for groups, projects or snippets. If the public level is restricted, user profiles are only visible to logged in users.'
- optional :send_user_confirmation_email, type: Boolean, desc: 'Send confirmation email on sign-up'
- optional :sentry_enabled, type: Boolean, desc: 'Sentry is an error reporting and logging tool which is currently not shipped with GitLab, get it here: https://getsentry.com'
+ optional :restricted_visibility_levels, type: Array[String], desc: "Selected levels cannot be used by non-admin users for groups, projects or snippets. If the public level is restricted, user profiles are only visible to logged in users."
+ optional :send_user_confirmation_email, type: Boolean, desc: "Send confirmation email on sign-up"
+ optional :sentry_enabled, type: Boolean, desc: "Sentry is an error reporting and logging tool which is currently not shipped with GitLab, get it here: https://getsentry.com"
given sentry_enabled: ->(val) { val } do
- requires :sentry_dsn, type: String, desc: 'Sentry Data Source Name'
+ requires :sentry_dsn, type: String, desc: "Sentry Data Source Name"
end
- optional :session_expire_delay, type: Integer, desc: 'Session duration in minutes. GitLab restart is required to apply changes.'
- optional :shared_runners_enabled, type: Boolean, desc: 'Enable shared runners for new projects'
+ optional :session_expire_delay, type: Integer, desc: "Session duration in minutes. GitLab restart is required to apply changes."
+ optional :shared_runners_enabled, type: Boolean, desc: "Enable shared runners for new projects"
given shared_runners_enabled: ->(val) { val } do
- requires :shared_runners_text, type: String, desc: 'Shared runners text '
- end
- optional :sign_in_text, type: String, desc: 'The sign in text of the GitLab application'
- optional :signin_enabled, type: Boolean, desc: 'Flag indicating if password authentication is enabled for the web interface' # support legacy names, can be removed in v5
- optional :signup_enabled, type: Boolean, desc: 'Flag indicating if sign up is enabled'
- optional :terminal_max_session_time, type: Integer, desc: 'Maximum time for web terminal websocket connection (in seconds). Set to 0 for unlimited time.'
- optional :usage_ping_enabled, type: Boolean, desc: 'Every week GitLab will report license usage back to GitLab, Inc.'
- optional :instance_statistics_visibility_private, type: Boolean, desc: 'When set to `true` Instance statistics will only be available to admins'
+ requires :shared_runners_text, type: String, desc: "Shared runners text "
+ end
+ optional :sign_in_text, type: String, desc: "The sign in text of the GitLab application"
+ optional :signin_enabled, type: Boolean, desc: "Flag indicating if password authentication is enabled for the web interface" # support legacy names, can be removed in v5
+ optional :signup_enabled, type: Boolean, desc: "Flag indicating if sign up is enabled"
+ optional :terminal_max_session_time, type: Integer, desc: "Maximum time for web terminal websocket connection (in seconds). Set to 0 for unlimited time."
+ optional :usage_ping_enabled, type: Boolean, desc: "Every week GitLab will report license usage back to GitLab, Inc."
+ optional :instance_statistics_visibility_private, type: Boolean, desc: "When set to `true` Instance statistics will only be available to admins"
optional :local_markdown_version, type: Integer, desc: "Local markdown version, increase this value when any cached markdown should be invalidated"
ApplicationSetting::SUPPORTED_KEY_TYPES.each do |type|
optional :"#{type}_key_restriction",
- type: Integer,
- values: KeyRestrictionValidator.supported_key_restrictions(type),
- desc: "Restrictions on the complexity of uploaded #{type.upcase} keys. A value of #{ApplicationSetting::FORBIDDEN_KEY_VALUE} disables all #{type.upcase} keys."
+ type: Integer,
+ values: KeyRestrictionValidator.supported_key_restrictions(type),
+ desc: "Restrictions on the complexity of uploaded #{type.upcase} keys. A value of #{ApplicationSetting::FORBIDDEN_KEY_VALUE} disables all #{type.upcase} keys."
end
optional_attributes = ::ApplicationSettingsHelper.visible_attributes << :performance_bar_allowed_group_id
@@ -139,20 +139,20 @@ module API
attrs = declared_params(include_missing: false)
# support legacy names, can be removed in v6
- if attrs.has_key?(:performance_bar_allowed_group_id)
+ if attrs.key?(:performance_bar_allowed_group_id)
attrs[:performance_bar_allowed_group_path] = attrs.delete(:performance_bar_allowed_group_id)
end
# support legacy names, can be removed in v6
- if attrs.has_key?(:performance_bar_enabled)
+ if attrs.key?(:performance_bar_enabled)
performance_bar_enabled = attrs.delete(:performance_bar_allowed_group_id)
attrs[:performance_bar_allowed_group_path] = nil unless performance_bar_enabled
end
# support legacy names, can be removed in v5
- if attrs.has_key?(:signin_enabled)
+ if attrs.key?(:signin_enabled)
attrs[:password_authentication_enabled_for_web] = attrs.delete(:signin_enabled)
- elsif attrs.has_key?(:password_authentication_enabled)
+ elsif attrs.key?(:password_authentication_enabled)
attrs[:password_authentication_enabled_for_web] = attrs.delete(:password_authentication_enabled)
end
diff --git a/lib/api/sidekiq_metrics.rb b/lib/api/sidekiq_metrics.rb
index daa9598a204..a8fd2a01b13 100644
--- a/lib/api/sidekiq_metrics.rb
+++ b/lib/api/sidekiq_metrics.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'sidekiq/api'
+require "sidekiq/api"
module API
class SidekiqMetrics < Grape::API
@@ -11,7 +11,7 @@ module API
Sidekiq::Queue.all.each_with_object({}) do |queue, hash|
hash[queue.name] = {
backlog: queue.size,
- latency: queue.latency.to_i
+ latency: queue.latency.to_i,
}
end
end
@@ -19,14 +19,14 @@ module API
def process_metrics
Sidekiq::ProcessSet.new.map do |process|
{
- hostname: process['hostname'],
- pid: process['pid'],
- tag: process['tag'],
- started_at: Time.at(process['started_at']),
- queues: process['queues'],
- labels: process['labels'],
- concurrency: process['concurrency'],
- busy: process['busy']
+ hostname: process["hostname"],
+ pid: process["pid"],
+ tag: process["tag"],
+ started_at: Time.at(process["started_at"]),
+ queues: process["queues"],
+ labels: process["labels"],
+ concurrency: process["concurrency"],
+ busy: process["busy"],
}
end
end
@@ -36,29 +36,29 @@ module API
{
processed: stats.processed,
failed: stats.failed,
- enqueued: stats.enqueued
+ enqueued: stats.enqueued,
}
end
end
- desc 'Get the Sidekiq queue metrics'
- get 'sidekiq/queue_metrics' do
- { queues: queue_metrics }
+ desc "Get the Sidekiq queue metrics"
+ get "sidekiq/queue_metrics" do
+ {queues: queue_metrics}
end
- desc 'Get the Sidekiq process metrics'
- get 'sidekiq/process_metrics' do
- { processes: process_metrics }
+ desc "Get the Sidekiq process metrics"
+ get "sidekiq/process_metrics" do
+ {processes: process_metrics}
end
- desc 'Get the Sidekiq job statistics'
- get 'sidekiq/job_stats' do
- { jobs: job_stats }
+ desc "Get the Sidekiq job statistics"
+ get "sidekiq/job_stats" do
+ {jobs: job_stats}
end
- desc 'Get the Sidekiq Compound metrics. Includes queue, process, and job statistics'
- get 'sidekiq/compound_metrics' do
- { queues: queue_metrics, processes: process_metrics, jobs: job_stats }
+ desc "Get the Sidekiq Compound metrics. Includes queue, process, and job statistics"
+ get "sidekiq/compound_metrics" do
+ {queues: queue_metrics, processes: process_metrics, jobs: job_stats}
end
end
end
diff --git a/lib/api/snippets.rb b/lib/api/snippets.rb
index 326d55afd0e..62e1e9aef2d 100644
--- a/lib/api/snippets.rb
+++ b/lib/api/snippets.rb
@@ -18,8 +18,8 @@ module API
end
end
- desc 'Get a snippets list for authenticated user' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Get a snippets list for authenticated user" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
@@ -29,42 +29,42 @@ module API
present paginate(snippets_for_current_user), with: Entities::PersonalSnippet
end
- desc 'List all public snippets current_user has access to' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "List all public snippets current_user has access to" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
use :pagination
end
- get 'public' do
+ get "public" do
present paginate(public_snippets), with: Entities::PersonalSnippet
end
- desc 'Get a single snippet' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Get a single snippet" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
- requires :id, type: Integer, desc: 'The ID of a snippet'
+ requires :id, type: Integer, desc: "The ID of a snippet"
end
- get ':id' do
+ get ":id" do
snippet = snippets_for_current_user.find(params[:id])
present snippet, with: Entities::PersonalSnippet
end
- desc 'Create new snippet' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Create new snippet" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
- requires :title, type: String, desc: 'The title of a snippet'
- requires :file_name, type: String, desc: 'The name of a snippet file'
- requires :content, type: String, desc: 'The content of a snippet'
- optional :description, type: String, desc: 'The description of a snippet'
+ requires :title, type: String, desc: "The title of a snippet"
+ requires :file_name, type: String, desc: "The name of a snippet file"
+ requires :content, type: String, desc: "The content of a snippet"
+ optional :description, type: String, desc: "The description of a snippet"
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
- default: 'internal',
- desc: 'The visibility of the snippet'
+ default: "internal",
+ desc: "The visibility of the snippet"
end
post do
attrs = declared_params(include_missing: false).merge(request: request, api: true)
@@ -79,25 +79,25 @@ module API
end
end
- desc 'Update an existing snippet' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Update an existing snippet" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
- requires :id, type: Integer, desc: 'The ID of a snippet'
- optional :title, type: String, desc: 'The title of a snippet'
- optional :file_name, type: String, desc: 'The name of a snippet file'
- optional :content, type: String, desc: 'The content of a snippet'
- optional :description, type: String, desc: 'The description of a snippet'
+ requires :id, type: Integer, desc: "The ID of a snippet"
+ optional :title, type: String, desc: "The title of a snippet"
+ optional :file_name, type: String, desc: "The name of a snippet file"
+ optional :content, type: String, desc: "The content of a snippet"
+ optional :description, type: String, desc: "The description of a snippet"
optional :visibility, type: String,
values: Gitlab::VisibilityLevel.string_values,
- desc: 'The visibility of the snippet'
+ desc: "The visibility of the snippet"
at_least_one_of :title, :file_name, :content, :visibility
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id' do
+ put ":id" do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
- break not_found!('Snippet') unless snippet
+ break not_found!("Snippet") unless snippet
authorize! :update_personal_snippet, snippet
@@ -115,17 +115,17 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Remove snippet' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Remove snippet" do
+ detail "This feature was introduced in GitLab 8.15."
success Entities::PersonalSnippet
end
params do
- requires :id, type: Integer, desc: 'The ID of a snippet'
+ requires :id, type: Integer, desc: "The ID of a snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id' do
+ delete ":id" do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
- break not_found!('Snippet') unless snippet
+ break not_found!("Snippet") unless snippet
authorize! :destroy_personal_snippet, snippet
@@ -133,29 +133,29 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a raw snippet' do
- detail 'This feature was introduced in GitLab 8.15.'
+ desc "Get a raw snippet" do
+ detail "This feature was introduced in GitLab 8.15."
end
params do
- requires :id, type: Integer, desc: 'The ID of a snippet'
+ requires :id, type: Integer, desc: "The ID of a snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id/raw" do
snippet = snippets_for_current_user.find_by(id: params.delete(:id))
- break not_found!('Snippet') unless snippet
+ break not_found!("Snippet") unless snippet
- env['api.format'] = :txt
- content_type 'text/plain'
- header['Content-Disposition'] = 'attachment'
+ env["api.format"] = :txt
+ content_type "text/plain"
+ header["Content-Disposition"] = "attachment"
present snippet.content
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the user agent details for a snippet' do
+ desc "Get the user agent details for a snippet" do
success Entities::UserAgentDetail
end
params do
- requires :id, type: Integer, desc: 'The ID of a snippet'
+ requires :id, type: Integer, desc: "The ID of a snippet"
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id/user_agent_detail" do
@@ -163,7 +163,7 @@ module API
snippet = Snippet.find_by!(id: params[:id])
- break not_found!('UserAgentDetail') unless snippet.user_agent_detail
+ break not_found!("UserAgentDetail") unless snippet.user_agent_detail
present snippet.user_agent_detail, with: Entities::UserAgentDetail
end
diff --git a/lib/api/submodules.rb b/lib/api/submodules.rb
index 72d7d994102..a76c6a832db 100644
--- a/lib/api/submodules.rb
+++ b/lib/api/submodules.rb
@@ -10,23 +10,23 @@ module API
submodule: attrs[:submodule],
commit_sha: attrs[:commit_sha],
branch_name: attrs[:branch],
- commit_message: attrs[:commit_message]
+ commit_message: attrs[:commit_message],
}
end
end
params do
- requires :id, type: String, desc: 'The project ID'
+ requires :id, type: String, desc: "The project ID"
end
resource :projects, requirements: Files::FILE_ENDPOINT_REQUIREMENTS do
- desc 'Update existing submodule reference in repository' do
+ desc "Update existing submodule reference in repository" do
success Entities::Commit
end
params do
- requires :submodule, type: String, desc: 'Url encoded full path to submodule.'
- requires :commit_sha, type: String, desc: 'Commit sha to update the submodule to.'
- requires :branch, type: String, desc: 'Name of the branch to commit into.'
- optional :commit_message, type: String, desc: 'Commit message. If no message is provided a default one will be set.'
+ requires :submodule, type: String, desc: "Url encoded full path to submodule."
+ requires :commit_sha, type: String, desc: "Commit sha to update the submodule to."
+ requires :branch, type: String, desc: "Name of the branch to commit into."
+ optional :commit_message, type: String, desc: "Commit message. If no message is provided a default one will be set."
end
put ":id/repository/submodules/:submodule", requirements: Files::FILE_ENDPOINT_REQUIREMENTS do
authorize! :push_code, user_project
diff --git a/lib/api/subscriptions.rb b/lib/api/subscriptions.rb
index dfb54446ddf..c36e52cfd79 100644
--- a/lib/api/subscriptions.rb
+++ b/lib/api/subscriptions.rb
@@ -8,29 +8,29 @@ module API
subscribables = [
{
- type: 'merge_requests',
+ type: "merge_requests",
entity: Entities::MergeRequest,
source: Project,
- finder: ->(id) { find_merge_request_with_access(id, :update_merge_request) }
+ finder: ->(id) { find_merge_request_with_access(id, :update_merge_request) },
},
{
- type: 'issues',
+ type: "issues",
entity: Entities::Issue,
source: Project,
- finder: ->(id) { find_project_issue(id) }
+ finder: ->(id) { find_project_issue(id) },
},
{
- type: 'labels',
+ type: "labels",
entity: Entities::ProjectLabel,
source: Project,
- finder: ->(id) { find_label(user_project, id) }
+ finder: ->(id) { find_label(user_project, id) },
},
{
- type: 'labels',
+ type: "labels",
entity: Entities::GroupLabel,
source: Group,
- finder: ->(id) { find_label(user_group, id) }
- }
+ finder: ->(id) { find_label(user_group, id) },
+ },
]
subscribables.each do |subscribable|
@@ -38,10 +38,10 @@ module API
params do
requires :id, type: String, desc: "The #{source_type} ID"
- requires :subscribable_id, type: String, desc: 'The ID of a resource'
+ requires :subscribable_id, type: String, desc: "The ID of a resource"
end
resource source_type.pluralize, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Subscribe to a resource' do
+ desc "Subscribe to a resource" do
success subscribable[:entity]
end
post ":id/#{subscribable[:type]}/:subscribable_id/subscribe" do
@@ -56,7 +56,7 @@ module API
end
end
- desc 'Unsubscribe from a resource' do
+ desc "Unsubscribe from a resource" do
success subscribable[:entity]
end
post ":id/#{subscribable[:type]}/:subscribable_id/unsubscribe" do
@@ -78,10 +78,8 @@ module API
helpers do
def parent_resource(source_type)
case source_type
- when 'project'
+ when "project"
user_project
- else
- nil
end
end
end
diff --git a/lib/api/suggestions.rb b/lib/api/suggestions.rb
index d008d1b9e97..92713b54230 100644
--- a/lib/api/suggestions.rb
+++ b/lib/api/suggestions.rb
@@ -5,13 +5,13 @@ module API
before { authenticate! }
resource :suggestions do
- desc 'Apply suggestion patch in the Merge Request it was created' do
+ desc "Apply suggestion patch in the Merge Request it was created" do
success Entities::Suggestion
end
params do
- requires :id, type: String, desc: 'The suggestion ID'
+ requires :id, type: String, desc: "The suggestion ID"
end
- put ':id/apply' do
+ put ":id/apply" do
suggestion = Suggestion.find_by_id(params[:id])
not_found! unless suggestion
diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb
index 51fae0e54aa..ff4e903ed3c 100644
--- a/lib/api/system_hooks.rb
+++ b/lib/api/system_hooks.rb
@@ -10,7 +10,7 @@ module API
end
resource :hooks do
- desc 'Get the list of system hooks' do
+ desc "Get the list of system hooks" do
success Entities::Hook
end
params do
@@ -20,12 +20,12 @@ module API
present paginate(SystemHook.all), with: Entities::Hook
end
- desc 'Create a new system hook' do
+ desc "Create a new system hook" do
success Entities::Hook
end
params do
requires :url, type: String, desc: "The URL to send the request to"
- optional :token, type: String, desc: 'The token used to validate payloads'
+ optional :token, type: String, desc: "The token used to validate payloads"
optional :push_events, type: Boolean, desc: "Trigger hook on push events"
optional :tag_push_events, type: Boolean, desc: "Trigger hook on tag push events"
optional :merge_requests_events, type: Boolean, desc: "Trigger hook on tag push events"
@@ -41,9 +41,9 @@ module API
end
end
- desc 'Test a hook'
+ desc "Test a hook"
params do
- requires :id, type: Integer, desc: 'The ID of the system hook'
+ requires :id, type: Integer, desc: "The ID of the system hook"
end
get ":id" do
hook = SystemHook.find(params[:id])
@@ -53,22 +53,22 @@ module API
path: "ruby",
project_id: 1,
owner_name: "Someone",
- owner_email: "example@gitlabhq.com"
+ owner_email: "example@gitlabhq.com",
}
- hook.execute(data, 'system_hooks')
+ hook.execute(data, "system_hooks")
data
end
- desc 'Delete a hook' do
+ desc "Delete a hook" do
success Entities::Hook
end
params do
- requires :id, type: Integer, desc: 'The ID of the system hook'
+ requires :id, type: Integer, desc: "The ID of the system hook"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id" do
hook = SystemHook.find_by(id: params[:id])
- not_found!('System hook') unless hook
+ not_found!("System hook") unless hook
destroy_conditionally!(hook)
end
diff --git a/lib/api/tags.rb b/lib/api/tags.rb
index f5359fd316c..6644f70056d 100644
--- a/lib/api/tags.rb
+++ b/lib/api/tags.rb
@@ -9,52 +9,52 @@ module API
before { authorize! :download_code, user_project }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get a project repository tags' do
+ desc "Get a project repository tags" do
success Entities::Tag
end
params do
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return tags sorted in updated by `asc` or `desc` order.'
- optional :order_by, type: String, values: %w[name updated], default: 'updated',
- desc: 'Return tags ordered by `name` or `updated` fields.'
- optional :search, type: String, desc: 'Return list of tags matching the search criteria'
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return tags sorted in updated by `asc` or `desc` order."
+ optional :order_by, type: String, values: %w[name updated], default: "updated",
+ desc: "Return tags ordered by `name` or `updated` fields."
+ optional :search, type: String, desc: "Return list of tags matching the search criteria"
use :pagination
end
- get ':id/repository/tags' do
+ get ":id/repository/tags" do
tags = ::TagsFinder.new(user_project.repository,
- sort: "#{params[:order_by]}_#{params[:sort]}",
- search: params[:search]).execute
+ sort: "#{params[:order_by]}_#{params[:sort]}",
+ search: params[:search]).execute
present paginate(::Kaminari.paginate_array(tags)), with: Entities::Tag, project: user_project
end
- desc 'Get a single repository tag' do
+ desc "Get a single repository tag" do
success Entities::Tag
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :tag_name, type: String, desc: "The name of the tag"
end
- get ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ get ":id/repository/tags/:tag_name", requirements: TAG_ENDPOINT_REQUIREMENTS do
tag = user_project.repository.find_tag(params[:tag_name])
- not_found!('Tag') unless tag
+ not_found!("Tag") unless tag
present tag, with: Entities::Tag, project: user_project
end
- desc 'Create a new repository tag' do
- detail 'This optional release_description parameter was deprecated in GitLab 11.7.'
+ desc "Create a new repository tag" do
+ detail "This optional release_description parameter was deprecated in GitLab 11.7."
success Entities::Tag
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag'
- requires :ref, type: String, desc: 'The commit sha or branch name'
- optional :message, type: String, desc: 'Specifying a message creates an annotated tag'
- optional :release_description, type: String, desc: 'Specifying release notes stored in the GitLab database (deprecated in GitLab 11.7)'
+ requires :tag_name, type: String, desc: "The name of the tag"
+ requires :ref, type: String, desc: "The commit sha or branch name"
+ optional :message, type: String, desc: "Specifying a message creates an annotated tag"
+ optional :release_description, type: String, desc: "Specifying release notes stored in the GitLab database (deprecated in GitLab 11.7)"
end
- post ':id/repository/tags' do
+ post ":id/repository/tags" do
authorize_push_project
result = ::Tags::CreateService.new(user_project, current_user)
@@ -66,7 +66,7 @@ module API
release_create_params = {
tag: params[:tag_name],
name: params[:tag_name], # Name can be specified in new API
- description: params[:release_description]
+ description: params[:release_description],
}
::Releases::CreateService
@@ -75,28 +75,28 @@ module API
end
present result[:tag],
- with: Entities::Tag,
- project: user_project
+ with: Entities::Tag,
+ project: user_project
else
render_api_error!(result[:message], 400)
end
end
- desc 'Delete a repository tag'
+ desc "Delete a repository tag"
params do
- requires :tag_name, type: String, desc: 'The name of the tag'
+ requires :tag_name, type: String, desc: "The name of the tag"
end
- delete ':id/repository/tags/:tag_name', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ delete ":id/repository/tags/:tag_name", requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_push_project
tag = user_project.repository.find_tag(params[:tag_name])
- not_found!('Tag') unless tag
+ not_found!("Tag") unless tag
commit = user_project.repository.commit(tag.dereferenced_target)
destroy_conditionally!(commit, last_updated: commit.authored_date) do
result = ::Tags::DestroyService.new(user_project, current_user)
- .execute(params[:tag_name])
+ .execute(params[:tag_name])
if result[:status] != :success
render_api_error!(result[:message], result[:return_code])
@@ -104,25 +104,25 @@ module API
end
end
- desc 'Add a release note to a tag' do
- detail 'This feature was deprecated in GitLab 11.7.'
+ desc "Add a release note to a tag" do
+ detail "This feature was deprecated in GitLab 11.7."
success Entities::TagRelease
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
- requires :description, type: String, desc: 'Release notes with markdown support'
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
+ requires :description, type: String, desc: "Release notes with markdown support"
end
- post ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ post ":id/repository/tags/:tag_name/release", requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_create_release!
##
# Legacy API does not support tag auto creation.
- not_found!('Tag') unless user_project.repository.find_tag(params[:tag])
+ not_found!("Tag") unless user_project.repository.find_tag(params[:tag])
release_create_params = {
tag: params[:tag],
name: params[:tag], # Name can be specified in new API
- description: params[:description]
+ description: params[:description],
}
result = ::Releases::CreateService
@@ -137,14 +137,14 @@ module API
end
desc "Update a tag's release note" do
- detail 'This feature was deprecated in GitLab 11.7.'
+ detail "This feature was deprecated in GitLab 11.7."
success Entities::TagRelease
end
params do
- requires :tag_name, type: String, desc: 'The name of the tag', as: :tag
- requires :description, type: String, desc: 'Release notes with markdown support'
+ requires :tag_name, type: String, desc: "The name of the tag", as: :tag
+ requires :description, type: String, desc: "Release notes with markdown support"
end
- put ':id/repository/tags/:tag_name/release', requirements: TAG_ENDPOINT_REQUIREMENTS do
+ put ":id/repository/tags/:tag_name/release", requirements: TAG_ENDPOINT_REQUIREMENTS do
authorize_update_release!
result = ::Releases::UpdateService
diff --git a/lib/api/templates.rb b/lib/api/templates.rb
index 51f357d9477..c4b1c4f2d52 100644
--- a/lib/api/templates.rb
+++ b/lib/api/templates.rb
@@ -6,14 +6,14 @@ module API
GLOBAL_TEMPLATE_TYPES = {
gitignores: {
- gitlab_version: 8.8
+ gitlab_version: 8.8,
},
gitlab_ci_ymls: {
- gitlab_version: 8.9
+ gitlab_version: 8.9,
},
dockerfiles: {
- gitlab_version: 8.15
- }
+ gitlab_version: 8.15,
+ },
}.freeze
helpers do
@@ -23,12 +23,12 @@ module API
end
end
- desc 'Get the list of the available license template' do
- detail 'This feature was introduced in GitLab 8.7.'
+ desc "Get the list of the available license template" do
+ detail "This feature was introduced in GitLab 8.7."
success ::API::Entities::License
end
params do
- optional :popular, type: Boolean, desc: 'If passed, returns only popular licenses'
+ optional :popular, type: Boolean, desc: "If passed, returns only popular licenses"
use :pagination
end
get "templates/licenses" do
@@ -40,17 +40,17 @@ module API
present paginate(::Kaminari.paginate_array(templates)), with: ::API::Entities::License
end
- desc 'Get the text for a specific license' do
- detail 'This feature was introduced in GitLab 8.7.'
+ desc "Get the text for a specific license" do
+ detail "This feature was introduced in GitLab 8.7."
success ::API::Entities::License
end
params do
- requires :name, type: String, desc: 'The name of the template'
+ requires :name, type: String, desc: "The name of the template"
end
- get "templates/licenses/:name", requirements: { name: /[\w\.-]+/ } do
+ get "templates/licenses/:name", requirements: {name: /[\w\.-]+/} do
template = TemplateFinder.build(:licenses, nil, name: params[:name]).execute
- not_found!('License') unless template.present?
+ not_found!("License") unless template.present?
template.resolve!(
project_name: params[:project].presence,
@@ -63,7 +63,7 @@ module API
GLOBAL_TEMPLATE_TYPES.each do |template_type, properties|
gitlab_version = properties[:gitlab_version]
- desc 'Get the list of the available template' do
+ desc "Get the list of the available template" do
detail "This feature was introduced in GitLab #{gitlab_version}."
success Entities::TemplatesList
end
@@ -75,14 +75,14 @@ module API
present paginate(templates), with: Entities::TemplatesList
end
- desc 'Get the text for a specific template present in local filesystem' do
+ desc "Get the text for a specific template present in local filesystem" do
detail "This feature was introduced in GitLab #{gitlab_version}."
success Entities::Template
end
params do
- requires :name, type: String, desc: 'The name of the template'
+ requires :name, type: String, desc: "The name of the template"
end
- get "templates/#{template_type}/:name", requirements: { name: /[\w\.-]+/ } do
+ get "templates/#{template_type}/:name", requirements: {name: /[\w\.-]+/} do
finder = TemplateFinder.build(template_type, nil, name: declared(params)[:name])
new_template = finder.execute
diff --git a/lib/api/time_tracking_endpoints.rb b/lib/api/time_tracking_endpoints.rb
index 93fe06bec27..9a65801855d 100644
--- a/lib/api/time_tracking_endpoints.rb
+++ b/lib/api/time_tracking_endpoints.rb
@@ -7,7 +7,7 @@ module API
included do
helpers do
def issuable_name
- declared_params.key?(:issue_iid) ? 'issue' : 'merge_request'
+ declared_params.key?(:issue_iid) ? "issue" : "merge_request"
end
def issuable_key
@@ -25,9 +25,9 @@ module API
def load_issuable
@issuable ||= begin
case issuable_name
- when 'issue'
+ when "issue"
find_project_issue(params.delete(issuable_key))
- when 'merge_request'
+ when "merge_request"
find_project_merge_request(params.delete(issuable_key))
end
end
@@ -46,18 +46,18 @@ module API
end
def update_service
- issuable_name == 'issue' ? ::Issues::UpdateService : ::MergeRequests::UpdateService
+ issuable_name == "issue" ? ::Issues::UpdateService : ::MergeRequests::UpdateService
end
end
- issuable_name = name.end_with?('Issues') ? 'issue' : 'merge_request'
+ issuable_name = name.end_with?("Issues") ? "issue" : "merge_request"
issuable_collection_name = issuable_name.pluralize
issuable_key = "#{issuable_name}_iid".to_sym
desc "Set a time estimate for a project #{issuable_name}"
params do
requires issuable_key, type: Integer, desc: "The ID of a project #{issuable_name}"
- requires :duration, type: String, desc: 'The duration to be parsed'
+ requires :duration, type: String, desc: "The duration to be parsed"
end
post ":id/#{issuable_collection_name}/:#{issuable_key}/time_estimate" do
authorize! update_issuable_key, load_issuable
@@ -80,14 +80,14 @@ module API
desc "Add spent time for a project #{issuable_name}"
params do
requires issuable_key, type: Integer, desc: "The ID of a project #{issuable_name}"
- requires :duration, type: String, desc: 'The duration to be parsed'
+ requires :duration, type: String, desc: "The duration to be parsed"
end
post ":id/#{issuable_collection_name}/:#{issuable_key}/add_spent_time" do
authorize! update_issuable_key, load_issuable
update_issuable(spend_time: {
duration: Gitlab::TimeTrackingFormatter.parse(params.delete(:duration)),
- user_id: current_user.id
+ user_id: current_user.id,
})
end
@@ -99,7 +99,7 @@ module API
authorize! update_issuable_key, load_issuable
status :ok
- update_issuable(spend_time: { duration: :reset, user_id: current_user.id })
+ update_issuable(spend_time: {duration: :reset, user_id: current_user.id})
end
desc "Show time stats for a project #{issuable_name}"
diff --git a/lib/api/todos.rb b/lib/api/todos.rb
index 64ac8ece56c..99aad6eb964 100644
--- a/lib/api/todos.rb
+++ b/lib/api/todos.rb
@@ -7,22 +7,22 @@ module API
before { authenticate! }
ISSUABLE_TYPES = {
- 'merge_requests' => ->(iid) { find_merge_request_with_access(iid) },
- 'issues' => ->(iid) { find_project_issue(iid) }
+ "merge_requests" => ->(iid) { find_merge_request_with_access(iid) },
+ "issues" => ->(iid) { find_project_issue(iid) },
}.freeze
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
ISSUABLE_TYPES.each do |type, finder|
type_id_str = "#{type.singularize}_iid".to_sym
- desc 'Create a todo on an issuable' do
+ desc "Create a todo on an issuable" do
success Entities::Todo
end
params do
- requires type_id_str, type: Integer, desc: 'The IID of an issuable'
+ requires type_id_str, type: Integer, desc: "The IID of an issuable"
end
post ":id/#{type}/:#{type_id_str}/todo" do
issuable = instance_exec(params[type_id_str], &finder)
@@ -44,7 +44,7 @@ module API
end
end
- desc 'Get a todo list' do
+ desc "Get a todo list" do
success Entities::Todo
end
params do
@@ -54,21 +54,21 @@ module API
present paginate(find_todos), with: Entities::Todo, current_user: current_user
end
- desc 'Mark a todo as done' do
+ desc "Mark a todo as done" do
success Entities::Todo
end
params do
- requires :id, type: Integer, desc: 'The ID of the todo being marked as done'
+ requires :id, type: Integer, desc: "The ID of the todo being marked as done"
end
- post ':id/mark_as_done' do
+ post ":id/mark_as_done" do
TodoService.new.mark_todos_as_done_by_ids(params[:id], current_user)
todo = current_user.todos.find(params[:id])
present todo, with: Entities::Todo, current_user: current_user
end
- desc 'Mark all todos as done'
- post '/mark_as_done' do
+ desc "Mark all todos as done"
+ post "/mark_as_done" do
todos = find_todos
TodoService.new.mark_todos_as_done(todos, current_user)
diff --git a/lib/api/triggers.rb b/lib/api/triggers.rb
index 8fc7c7361e1..6754fc13ec1 100644
--- a/lib/api/triggers.rb
+++ b/lib/api/triggers.rb
@@ -5,24 +5,24 @@ module API
include PaginationParams
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Trigger a GitLab project pipeline' do
+ desc "Trigger a GitLab project pipeline" do
success Entities::Pipeline
end
params do
- requires :ref, type: String, desc: 'The commit sha or name of a branch or tag', allow_blank: false
- requires :token, type: String, desc: 'The unique token of trigger'
- optional :variables, type: Hash, desc: 'The list of variables to be injected into build'
+ requires :ref, type: String, desc: "The commit sha or name of a branch or tag", allow_blank: false
+ requires :token, type: String, desc: "The unique token of trigger"
+ optional :variables, type: Hash, desc: "The list of variables to be injected into build"
end
- post ":id/(ref/:ref/)trigger/pipeline", requirements: { ref: /.+/ } do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42283')
+ post ":id/(ref/:ref/)trigger/pipeline", requirements: {ref: /.+/} do
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42283")
# validate variables
params[:variables] = params[:variables].to_h
unless params[:variables].all? { |key, value| key.is_a?(String) && value.is_a?(String) }
- render_api_error!('variables needs to be a map of key-valued strings', 400)
+ render_api_error!("variables needs to be a map of key-valued strings", 400)
end
project = find_project(params[:id])
@@ -38,14 +38,14 @@ module API
end
end
- desc 'Get triggers list' do
+ desc "Get triggers list" do
success Entities::Trigger
end
params do
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/triggers' do
+ get ":id/triggers" do
authenticate!
authorize! :admin_build, user_project
@@ -55,34 +55,35 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get specific trigger of a project' do
+ desc "Get specific trigger of a project" do
success Entities::Trigger
end
params do
- requires :trigger_id, type: Integer, desc: 'The trigger ID'
+ requires :trigger_id, type: Integer, desc: "The trigger ID"
end
- get ':id/triggers/:trigger_id' do
+ get ":id/triggers/:trigger_id" do
authenticate!
authorize! :admin_build, user_project
trigger = user_project.triggers.find(params.delete(:trigger_id))
- break not_found!('Trigger') unless trigger
+ break not_found!("Trigger") unless trigger
present trigger, with: Entities::Trigger, current_user: current_user
end
- desc 'Create a trigger' do
+ desc "Create a trigger" do
success Entities::Trigger
end
params do
- requires :description, type: String, desc: 'The trigger description'
+ requires :description, type: String, desc: "The trigger description"
end
- post ':id/triggers' do
+ post ":id/triggers" do
authenticate!
authorize! :admin_build, user_project
trigger = user_project.triggers.create(
- declared_params(include_missing: false).merge(owner: current_user))
+ declared_params(include_missing: false).merge(owner: current_user)
+ )
if trigger.valid?
present trigger, with: Entities::Trigger, current_user: current_user
@@ -91,19 +92,19 @@ module API
end
end
- desc 'Update a trigger' do
+ desc "Update a trigger" do
success Entities::Trigger
end
params do
- requires :trigger_id, type: Integer, desc: 'The trigger ID'
- optional :description, type: String, desc: 'The trigger description'
+ requires :trigger_id, type: Integer, desc: "The trigger ID"
+ optional :description, type: String, desc: "The trigger description"
end
- put ':id/triggers/:trigger_id' do
+ put ":id/triggers/:trigger_id" do
authenticate!
authorize! :admin_build, user_project
trigger = user_project.triggers.find(params.delete(:trigger_id))
- break not_found!('Trigger') unless trigger
+ break not_found!("Trigger") unless trigger
if trigger.update(declared_params(include_missing: false))
present trigger, with: Entities::Trigger, current_user: current_user
@@ -112,18 +113,18 @@ module API
end
end
- desc 'Take ownership of trigger' do
+ desc "Take ownership of trigger" do
success Entities::Trigger
end
params do
- requires :trigger_id, type: Integer, desc: 'The trigger ID'
+ requires :trigger_id, type: Integer, desc: "The trigger ID"
end
- post ':id/triggers/:trigger_id/take_ownership' do
+ post ":id/triggers/:trigger_id/take_ownership" do
authenticate!
authorize! :admin_build, user_project
trigger = user_project.triggers.find(params.delete(:trigger_id))
- break not_found!('Trigger') unless trigger
+ break not_found!("Trigger") unless trigger
if trigger.update(owner: current_user)
status :ok
@@ -133,18 +134,18 @@ module API
end
end
- desc 'Delete a trigger' do
+ desc "Delete a trigger" do
success Entities::Trigger
end
params do
- requires :trigger_id, type: Integer, desc: 'The trigger ID'
+ requires :trigger_id, type: Integer, desc: "The trigger ID"
end
- delete ':id/triggers/:trigger_id' do
+ delete ":id/triggers/:trigger_id" do
authenticate!
authorize! :admin_build, user_project
trigger = user_project.triggers.find(params.delete(:trigger_id))
- break not_found!('Trigger') unless trigger
+ break not_found!("Trigger") unless trigger
destroy_conditionally!(trigger)
end
diff --git a/lib/api/users.rb b/lib/api/users.rb
index 7d88880d412..4c0da1ca72f 100644
--- a/lib/api/users.rb
+++ b/lib/api/users.rb
@@ -6,9 +6,9 @@ module API
include APIGuard
include Helpers::CustomAttributes
- allow_access_with_scope :read_user, if: -> (request) { request.get? }
+ allow_access_with_scope :read_user, if: ->(request) { request.get? }
- resource :users, requirements: { uid: /[0-9]*/, id: /[0-9]*/ } do
+ resource :users, requirements: {uid: /[0-9]*/, id: /[0-9]*/} do
include CustomAttributesEndpoints
before do
@@ -19,7 +19,7 @@ module API
# rubocop: disable CodeReuse/ActiveRecord
def find_user_by_id(params)
id = params[:user_id] || params[:id]
- User.find_by(id: id) || not_found!('User')
+ User.find_by(id: id) || not_found!("User")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -34,47 +34,47 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
params :optional_attributes do
- optional :skype, type: String, desc: 'The Skype username'
- optional :linkedin, type: String, desc: 'The LinkedIn username'
- optional :twitter, type: String, desc: 'The Twitter username'
- optional :website_url, type: String, desc: 'The website of the user'
- optional :organization, type: String, desc: 'The organization of the user'
- optional :projects_limit, type: Integer, desc: 'The number of projects a user can create'
- optional :extern_uid, type: String, desc: 'The external authentication provider UID'
- optional :provider, type: String, desc: 'The external provider'
- optional :bio, type: String, desc: 'The biography of the user'
- optional :location, type: String, desc: 'The location of the user'
- optional :public_email, type: String, desc: 'The public email of the user'
- optional :admin, type: Boolean, desc: 'Flag indicating the user is an administrator'
- optional :can_create_group, type: Boolean, desc: 'Flag indicating the user can create groups'
- optional :external, type: Boolean, desc: 'Flag indicating the user is an external user'
- optional :avatar, type: File, desc: 'Avatar image for user'
- optional :private_profile, type: Boolean, desc: 'Flag indicating the user has a private profile'
+ optional :skype, type: String, desc: "The Skype username"
+ optional :linkedin, type: String, desc: "The LinkedIn username"
+ optional :twitter, type: String, desc: "The Twitter username"
+ optional :website_url, type: String, desc: "The website of the user"
+ optional :organization, type: String, desc: "The organization of the user"
+ optional :projects_limit, type: Integer, desc: "The number of projects a user can create"
+ optional :extern_uid, type: String, desc: "The external authentication provider UID"
+ optional :provider, type: String, desc: "The external provider"
+ optional :bio, type: String, desc: "The biography of the user"
+ optional :location, type: String, desc: "The location of the user"
+ optional :public_email, type: String, desc: "The public email of the user"
+ optional :admin, type: Boolean, desc: "Flag indicating the user is an administrator"
+ optional :can_create_group, type: Boolean, desc: "Flag indicating the user can create groups"
+ optional :external, type: Boolean, desc: "Flag indicating the user is an external user"
+ optional :avatar, type: File, desc: "Avatar image for user"
+ optional :private_profile, type: Boolean, desc: "Flag indicating the user has a private profile"
all_or_none_of :extern_uid, :provider
end
params :sort_params do
optional :order_by, type: String, values: %w[id name username created_at updated_at],
- default: 'id', desc: 'Return users ordered by a field'
- optional :sort, type: String, values: %w[asc desc], default: 'desc',
- desc: 'Return users sorted in ascending and descending order'
+ default: "id", desc: "Return users ordered by a field"
+ optional :sort, type: String, values: %w[asc desc], default: "desc",
+ desc: "Return users sorted in ascending and descending order"
end
end
- desc 'Get the list of users' do
+ desc "Get the list of users" do
success Entities::UserBasic
end
params do
# CE
- optional :username, type: String, desc: 'Get a single user with a specific username'
- optional :extern_uid, type: String, desc: 'Get a single user with a specific external authentication provider UID'
- optional :provider, type: String, desc: 'The external provider'
- optional :search, type: String, desc: 'Search for a username'
- optional :active, type: Boolean, default: false, desc: 'Filters only active users'
- optional :external, type: Boolean, default: false, desc: 'Filters only external users'
- optional :blocked, type: Boolean, default: false, desc: 'Filters only blocked users'
- optional :created_after, type: DateTime, desc: 'Return users created after the specified time'
- optional :created_before, type: DateTime, desc: 'Return users created before the specified time'
+ optional :username, type: String, desc: "Get a single user with a specific username"
+ optional :extern_uid, type: String, desc: "Get a single user with a specific external authentication provider UID"
+ optional :provider, type: String, desc: "The external provider"
+ optional :search, type: String, desc: "Search for a username"
+ optional :active, type: Boolean, default: false, desc: "Filters only active users"
+ optional :external, type: Boolean, default: false, desc: "Filters only external users"
+ optional :blocked, type: Boolean, default: false, desc: "Filters only blocked users"
+ optional :created_after, type: DateTime, desc: "Return users created after the specified time"
+ optional :created_before, type: DateTime, desc: "Return users created before the specified time"
all_or_none_of :extern_uid, :provider
use :sort_params
@@ -105,26 +105,26 @@ module API
entity = current_user&.admin? ? Entities::UserWithAdmin : Entities::UserBasic
users = users.preload(:identities, :u2f_registrations) if entity == Entities::UserWithAdmin
- users, options = with_custom_attributes(users, { with: entity, current_user: current_user })
+ users, options = with_custom_attributes(users, {with: entity, current_user: current_user})
present paginate(users), options
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a single user' do
+ desc "Get a single user" do
success Entities::User
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
use :with_custom_attributes
end
# rubocop: disable CodeReuse/ActiveRecord
get ":id" do
user = User.find_by(id: params[:id])
- not_found!('User') unless user && can?(current_user, :read_user, user)
+ not_found!("User") unless user && can?(current_user, :read_user, user)
- opts = { with: current_user&.admin? ? Entities::UserWithAdmin : Entities::User, current_user: current_user }
+ opts = {with: current_user&.admin? ? Entities::UserWithAdmin : Entities::User, current_user: current_user}
user, opts = with_custom_attributes(user, opts)
present user, opts
@@ -133,26 +133,26 @@ module API
desc "Get the status of a user"
params do
- requires :user_id, type: String, desc: 'The ID or username of the user'
+ requires :user_id, type: String, desc: "The ID or username of the user"
end
get ":user_id/status", requirements: API::USER_REQUIREMENTS do
user = find_user(params[:user_id])
- not_found!('User') unless user && can?(current_user, :read_user, user)
+ not_found!("User") unless user && can?(current_user, :read_user, user)
present user.status || {}, with: Entities::UserStatus
end
- desc 'Create a user. Available only for admins.' do
+ desc "Create a user. Available only for admins." do
success Entities::UserPublic
end
params do
- requires :email, type: String, desc: 'The email of the user'
- optional :password, type: String, desc: 'The password of the new user'
- optional :reset_password, type: Boolean, desc: 'Flag indicating the user will be sent a password reset token'
- optional :skip_confirmation, type: Boolean, desc: 'Flag indicating the account is confirmed'
+ requires :email, type: String, desc: "The email of the user"
+ optional :password, type: String, desc: "The password of the new user"
+ optional :reset_password, type: Boolean, desc: "Flag indicating the user will be sent a password reset token"
+ optional :skip_confirmation, type: Boolean, desc: "Flag indicating the account is confirmed"
at_least_one_of :password, :reset_password
- requires :name, type: String, desc: 'The name of the user'
- requires :username, type: String, desc: 'The username of the user'
+ requires :name, type: String, desc: "The name of the user"
+ requires :username, type: String, desc: "The username of the user"
use :optional_attributes
end
post do
@@ -164,11 +164,11 @@ module API
if user.persisted?
present user, with: Entities::UserPublic, current_user: current_user
else
- conflict!('Email has already been taken') if User
+ conflict!("Email has already been taken") if User
.by_any_email(user.email.downcase)
.any?
- conflict!('Username has already been taken') if User
+ conflict!("Username has already been taken") if User
.by_username(user.username)
.any?
@@ -176,16 +176,16 @@ module API
end
end
- desc 'Update a user. Available only for admins.' do
+ desc "Update a user. Available only for admins." do
success Entities::UserPublic
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- optional :email, type: String, desc: 'The email of the user'
- optional :password, type: String, desc: 'The password of the new user'
- optional :skip_reconfirmation, type: Boolean, desc: 'Flag indicating the account skips the confirmation by email'
- optional :name, type: String, desc: 'The name of the user'
- optional :username, type: String, desc: 'The username of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
+ optional :email, type: String, desc: "The email of the user"
+ optional :password, type: String, desc: "The password of the new user"
+ optional :skip_reconfirmation, type: Boolean, desc: "Flag indicating the account skips the confirmation by email"
+ optional :name, type: String, desc: "The name of the user"
+ optional :username, type: String, desc: "The username of the user"
use :optional_attributes
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -193,15 +193,15 @@ module API
authenticated_as_admin!
user = User.find_by(id: params.delete(:id))
- not_found!('User') unless user
+ not_found!("User") unless user
- conflict!('Email has already been taken') if params[:email] &&
- User.by_any_email(params[:email].downcase)
- .where.not(id: user.id).count > 0
+ conflict!("Email has already been taken") if params[:email] &&
+ User.by_any_email(params[:email].downcase)
+ .where.not(id: user.id).count > 0
- conflict!('Username has already been taken') if params[:username] &&
- User.by_username(params[:username])
- .where.not(id: user.id).count > 0
+ conflict!("Username has already been taken") if params[:username] &&
+ User.by_username(params[:username])
+ .where.not(id: user.id).count > 0
user_params = declared_params(include_missing: false)
identity_attrs = user_params.slice(:provider, :extern_uid)
@@ -229,20 +229,20 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add an SSH key to a specified user. Available only for admins.' do
+ desc "Add an SSH key to a specified user. Available only for admins." do
success Entities::SSHKey
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :key, type: String, desc: 'The new SSH key'
- requires :title, type: String, desc: 'The title of the new SSH key'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :key, type: String, desc: "The new SSH key"
+ requires :title, type: String, desc: "The title of the new SSH key"
end
# rubocop: disable CodeReuse/ActiveRecord
post ":id/keys" do
authenticated_as_admin!
user = User.find_by(id: params.delete(:id))
- not_found!('User') unless user
+ not_found!("User") unless user
key = user.keys.new(declared_params(include_missing: false))
@@ -254,57 +254,57 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the SSH keys of a specified user.' do
+ desc "Get the SSH keys of a specified user." do
success Entities::SSHKey
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/keys' do
+ get ":id/keys" do
user = User.find_by(id: params[:id])
- not_found!('User') unless user && can?(current_user, :read_user, user)
+ not_found!("User") unless user && can?(current_user, :read_user, user)
present paginate(user.keys), with: Entities::SSHKey
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete an existing SSH key from a specified user. Available only for admins.' do
+ desc "Delete an existing SSH key from a specified user. Available only for admins." do
success Entities::SSHKey
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :key_id, type: Integer, desc: 'The ID of the SSH key'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :key_id, type: Integer, desc: "The ID of the SSH key"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/keys/:key_id' do
+ delete ":id/keys/:key_id" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
key = user.keys.find_by(id: params[:key_id])
- not_found!('Key') unless key
+ not_found!("Key") unless key
destroy_conditionally!(key)
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add a GPG key to a specified user. Available only for admins.' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Add a GPG key to a specified user. Available only for admins." do
+ detail "This feature was added in GitLab 10.0"
success Entities::GPGKey
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :key, type: String, desc: 'The new GPG key'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :key, type: String, desc: "The new GPG key"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/gpg_keys' do
+ post ":id/gpg_keys" do
authenticated_as_admin!
user = User.find_by(id: params.delete(:id))
- not_found!('User') unless user
+ not_found!("User") unless user
key = user.gpg_keys.new(declared_params(include_missing: false))
@@ -316,83 +316,83 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the GPG keys of a specified user. Available only for admins.' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Get the GPG keys of a specified user. Available only for admins." do
+ detail "This feature was added in GitLab 10.0"
success Entities::GPGKey
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/gpg_keys' do
+ get ":id/gpg_keys" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
present paginate(user.gpg_keys), with: Entities::GPGKey
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete an existing GPG key from a specified user. Available only for admins.' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Delete an existing GPG key from a specified user. Available only for admins." do
+ detail "This feature was added in GitLab 10.0"
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :key_id, type: Integer, desc: 'The ID of the GPG key'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :key_id, type: Integer, desc: "The ID of the GPG key"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/gpg_keys/:key_id' do
+ delete ":id/gpg_keys/:key_id" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
key = user.gpg_keys.find_by(id: params[:key_id])
- not_found!('GPG Key') unless key
+ not_found!("GPG Key") unless key
status 204
key.destroy
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Revokes an existing GPG key from a specified user. Available only for admins.' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Revokes an existing GPG key from a specified user. Available only for admins." do
+ detail "This feature was added in GitLab 10.0"
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :key_id, type: Integer, desc: 'The ID of the GPG key'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :key_id, type: Integer, desc: "The ID of the GPG key"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/gpg_keys/:key_id/revoke' do
+ post ":id/gpg_keys/:key_id/revoke" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
key = user.gpg_keys.find_by(id: params[:key_id])
- not_found!('GPG Key') unless key
+ not_found!("GPG Key") unless key
key.revoke
status :accepted
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add an email address to a specified user. Available only for admins.' do
+ desc "Add an email address to a specified user. Available only for admins." do
success Entities::Email
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :email, type: String, desc: 'The email of the user'
- optional :skip_confirmation, type: Boolean, desc: 'Skip confirmation of email and assume it is verified'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :email, type: String, desc: "The email of the user"
+ optional :skip_confirmation, type: Boolean, desc: "Skip confirmation of email and assume it is verified"
end
# rubocop: disable CodeReuse/ActiveRecord
post ":id/emails" do
authenticated_as_admin!
user = User.find_by(id: params.delete(:id))
- not_found!('User') unless user
+ not_found!("User") unless user
email = Emails::CreateService.new(current_user, declared_params(include_missing: false).merge(user: user)).execute
@@ -404,38 +404,38 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get the emails addresses of a specified user. Available only for admins.' do
+ desc "Get the emails addresses of a specified user. Available only for admins." do
success Entities::Email
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/emails' do
+ get ":id/emails" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
present paginate(user.emails), with: Entities::Email
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete an email address of a specified user. Available only for admins.' do
+ desc "Delete an email address of a specified user. Available only for admins." do
success Entities::Email
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
- requires :email_id, type: Integer, desc: 'The ID of the email'
+ requires :id, type: Integer, desc: "The ID of the user"
+ requires :email_id, type: Integer, desc: "The ID of the email"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/emails/:email_id' do
+ delete ":id/emails/:email_id" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
email = user.emails.find_by(id: params[:email_id])
- not_found!('Email') unless email
+ not_found!("Email") unless email
destroy_conditionally!(email) do |email|
Emails::DestroyService.new(current_user, user: user).execute(email)
@@ -443,21 +443,21 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete a user. Available only for admins.' do
+ desc "Delete a user. Available only for admins." do
success Entities::Email
end
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
optional :hard_delete, type: Boolean, desc: "Whether to remove a user's contributions"
end
# rubocop: disable CodeReuse/ActiveRecord
delete ":id" do
- Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42279')
+ Gitlab::QueryLimiting.whitelist("https://gitlab.com/gitlab-org/gitlab-ce/issues/42279")
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
destroy_conditionally!(user) do
user.delete_async(deleted_by: current_user, params: params)
@@ -465,36 +465,36 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Block a user. Available only for admins.'
+ desc "Block a user. Available only for admins."
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/block' do
+ post ":id/block" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
if !user.ldap_blocked?
user.block
else
- forbidden!('LDAP blocked users cannot be modified by the API')
+ forbidden!("LDAP blocked users cannot be modified by the API")
end
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Unblock a user. Available only for admins.'
+ desc "Unblock a user. Available only for admins."
params do
- requires :id, type: Integer, desc: 'The ID of the user'
+ requires :id, type: Integer, desc: "The ID of the user"
end
# rubocop: disable CodeReuse/ActiveRecord
- post ':id/unblock' do
+ post ":id/unblock" do
authenticated_as_admin!
user = User.find_by(id: params[:id])
- not_found!('User') unless user
+ not_found!("User") unless user
if user.ldap_blocked?
- forbidden!('LDAP blocked users cannot be unblocked by the API')
+ forbidden!("LDAP blocked users cannot be unblocked by the API")
else
user.activate
end
@@ -502,41 +502,41 @@ module API
# rubocop: enable CodeReuse/ActiveRecord
params do
- requires :user_id, type: Integer, desc: 'The ID of the user'
+ requires :user_id, type: Integer, desc: "The ID of the user"
end
- segment ':user_id' do
+ segment ":user_id" do
resource :impersonation_tokens do
helpers do
def finder(options = {})
user = find_user_by_id(params)
- PersonalAccessTokensFinder.new({ user: user, impersonation: true }.merge(options))
+ PersonalAccessTokensFinder.new({user: user, impersonation: true}.merge(options))
end
def find_impersonation_token
- finder.find_by_id(declared_params[:impersonation_token_id]) || not_found!('Impersonation Token')
+ finder.find_by_id(declared_params[:impersonation_token_id]) || not_found!("Impersonation Token")
end
end
before { authenticated_as_admin! }
- desc 'Retrieve impersonation tokens. Available only for admins.' do
- detail 'This feature was introduced in GitLab 9.0'
+ desc "Retrieve impersonation tokens. Available only for admins." do
+ detail "This feature was introduced in GitLab 9.0"
success Entities::ImpersonationToken
end
params do
use :pagination
- optional :state, type: String, default: 'all', values: %w[all active inactive], desc: 'Filters (all|active|inactive) impersonation_tokens'
+ optional :state, type: String, default: "all", values: %w[all active inactive], desc: "Filters (all|active|inactive) impersonation_tokens"
end
get { present paginate(finder(declared_params(include_missing: false)).execute), with: Entities::ImpersonationToken }
- desc 'Create a impersonation token. Available only for admins.' do
- detail 'This feature was introduced in GitLab 9.0'
+ desc "Create a impersonation token. Available only for admins." do
+ detail "This feature was introduced in GitLab 9.0"
success Entities::ImpersonationTokenWithToken
end
params do
- requires :name, type: String, desc: 'The name of the impersonation token'
- optional :expires_at, type: Date, desc: 'The expiration date in the format YEAR-MONTH-DAY of the impersonation token'
- optional :scopes, type: Array, desc: 'The array of scopes of the impersonation token'
+ requires :name, type: String, desc: "The name of the impersonation token"
+ optional :expires_at, type: Date, desc: "The expiration date in the format YEAR-MONTH-DAY of the impersonation token"
+ optional :scopes, type: Array, desc: "The array of scopes of the impersonation token"
end
post do
impersonation_token = finder.build(declared_params(include_missing: false))
@@ -548,24 +548,24 @@ module API
end
end
- desc 'Retrieve impersonation token. Available only for admins.' do
- detail 'This feature was introduced in GitLab 9.0'
+ desc "Retrieve impersonation token. Available only for admins." do
+ detail "This feature was introduced in GitLab 9.0"
success Entities::ImpersonationToken
end
params do
- requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token'
+ requires :impersonation_token_id, type: Integer, desc: "The ID of the impersonation token"
end
- get ':impersonation_token_id' do
+ get ":impersonation_token_id" do
present find_impersonation_token, with: Entities::ImpersonationToken
end
- desc 'Revoke a impersonation token. Available only for admins.' do
- detail 'This feature was introduced in GitLab 9.0'
+ desc "Revoke a impersonation token. Available only for admins." do
+ detail "This feature was introduced in GitLab 9.0"
end
params do
- requires :impersonation_token_id, type: Integer, desc: 'The ID of the impersonation token'
+ requires :impersonation_token_id, type: Integer, desc: "The ID of the impersonation token"
end
- delete ':impersonation_token_id' do
+ delete ":impersonation_token_id" do
token = find_impersonation_token
destroy_conditionally!(token) do
@@ -583,8 +583,8 @@ module API
# Enabling /user endpoint for the v3 version to allow oauth
# authentication through this endpoint.
- version %w(v3 v4), using: :path do
- desc 'Get the currently authenticated user' do
+ version %w[v3 v4], using: :path do
+ desc "Get the currently authenticated user" do
success Entities::UserPublic
end
get do
@@ -609,27 +609,27 @@ module API
present paginate(current_user.keys), with: Entities::SSHKey
end
- desc 'Get a single key owned by currently authenticated user' do
+ desc "Get a single key owned by currently authenticated user" do
success Entities::SSHKey
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the SSH key'
+ requires :key_id, type: Integer, desc: "The ID of the SSH key"
end
# rubocop: disable CodeReuse/ActiveRecord
get "keys/:key_id" do
key = current_user.keys.find_by(id: params[:key_id])
- not_found!('Key') unless key
+ not_found!("Key") unless key
present key, with: Entities::SSHKey
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add a new SSH key to the currently authenticated user' do
+ desc "Add a new SSH key to the currently authenticated user" do
success Entities::SSHKey
end
params do
- requires :key, type: String, desc: 'The new SSH key'
- requires :title, type: String, desc: 'The title of the new SSH key'
+ requires :key, type: String, desc: "The new SSH key"
+ requires :title, type: String, desc: "The title of the new SSH key"
end
post "keys" do
key = current_user.keys.new(declared_params)
@@ -641,56 +641,56 @@ module API
end
end
- desc 'Delete an SSH key from the currently authenticated user' do
+ desc "Delete an SSH key from the currently authenticated user" do
success Entities::SSHKey
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the SSH key'
+ requires :key_id, type: Integer, desc: "The ID of the SSH key"
end
# rubocop: disable CodeReuse/ActiveRecord
delete "keys/:key_id" do
key = current_user.keys.find_by(id: params[:key_id])
- not_found!('Key') unless key
+ not_found!("Key") unless key
destroy_conditionally!(key)
end
# rubocop: enable CodeReuse/ActiveRecord
desc "Get the currently authenticated user's GPG keys" do
- detail 'This feature was added in GitLab 10.0'
+ detail "This feature was added in GitLab 10.0"
success Entities::GPGKey
end
params do
use :pagination
end
- get 'gpg_keys' do
+ get "gpg_keys" do
present paginate(current_user.gpg_keys), with: Entities::GPGKey
end
- desc 'Get a single GPG key owned by currently authenticated user' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Get a single GPG key owned by currently authenticated user" do
+ detail "This feature was added in GitLab 10.0"
success Entities::GPGKey
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the GPG key'
+ requires :key_id, type: Integer, desc: "The ID of the GPG key"
end
# rubocop: disable CodeReuse/ActiveRecord
- get 'gpg_keys/:key_id' do
+ get "gpg_keys/:key_id" do
key = current_user.gpg_keys.find_by(id: params[:key_id])
- not_found!('GPG Key') unless key
+ not_found!("GPG Key") unless key
present key, with: Entities::GPGKey
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add a new GPG key to the currently authenticated user' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Add a new GPG key to the currently authenticated user" do
+ detail "This feature was added in GitLab 10.0"
success Entities::GPGKey
end
params do
- requires :key, type: String, desc: 'The new GPG key'
+ requires :key, type: String, desc: "The new GPG key"
end
- post 'gpg_keys' do
+ post "gpg_keys" do
key = current_user.gpg_keys.new(declared_params)
if key.save
@@ -700,32 +700,32 @@ module API
end
end
- desc 'Revoke a GPG key owned by currently authenticated user' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Revoke a GPG key owned by currently authenticated user" do
+ detail "This feature was added in GitLab 10.0"
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the GPG key'
+ requires :key_id, type: Integer, desc: "The ID of the GPG key"
end
# rubocop: disable CodeReuse/ActiveRecord
- post 'gpg_keys/:key_id/revoke' do
+ post "gpg_keys/:key_id/revoke" do
key = current_user.gpg_keys.find_by(id: params[:key_id])
- not_found!('GPG Key') unless key
+ not_found!("GPG Key") unless key
key.revoke
status :accepted
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete a GPG key from the currently authenticated user' do
- detail 'This feature was added in GitLab 10.0'
+ desc "Delete a GPG key from the currently authenticated user" do
+ detail "This feature was added in GitLab 10.0"
end
params do
- requires :key_id, type: Integer, desc: 'The ID of the SSH key'
+ requires :key_id, type: Integer, desc: "The ID of the SSH key"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete 'gpg_keys/:key_id' do
+ delete "gpg_keys/:key_id" do
key = current_user.gpg_keys.find_by(id: params[:key_id])
- not_found!('GPG Key') unless key
+ not_found!("GPG Key") unless key
status 204
key.destroy
@@ -742,26 +742,26 @@ module API
present paginate(current_user.emails), with: Entities::Email
end
- desc 'Get a single email address owned by the currently authenticated user' do
+ desc "Get a single email address owned by the currently authenticated user" do
success Entities::Email
end
params do
- requires :email_id, type: Integer, desc: 'The ID of the email'
+ requires :email_id, type: Integer, desc: "The ID of the email"
end
# rubocop: disable CodeReuse/ActiveRecord
get "emails/:email_id" do
email = current_user.emails.find_by(id: params[:email_id])
- not_found!('Email') unless email
+ not_found!("Email") unless email
present email, with: Entities::Email
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Add new email address to the currently authenticated user' do
+ desc "Add new email address to the currently authenticated user" do
success Entities::Email
end
params do
- requires :email, type: String, desc: 'The new email'
+ requires :email, type: String, desc: "The new email"
end
post "emails" do
email = Emails::CreateService.new(current_user, declared_params.merge(user: current_user)).execute
@@ -773,14 +773,14 @@ module API
end
end
- desc 'Delete an email address from the currently authenticated user'
+ desc "Delete an email address from the currently authenticated user"
params do
- requires :email_id, type: Integer, desc: 'The ID of the email'
+ requires :email_id, type: Integer, desc: "The ID of the email"
end
# rubocop: disable CodeReuse/ActiveRecord
delete "emails/:email_id" do
email = current_user.emails.find_by(id: params[:email_id])
- not_found!('Email') unless email
+ not_found!("Email") unless email
destroy_conditionally!(email) do |email|
Emails::DestroyService.new(current_user, user: current_user).execute(email)
@@ -788,9 +788,9 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Get a list of user activities'
+ desc "Get a list of user activities"
params do
- optional :from, type: DateTime, default: 6.months.ago, desc: 'Date string in the format YEAR-MONTH-DAY'
+ optional :from, type: DateTime, default: 6.months.ago, desc: "Date string in the format YEAR-MONTH-DAY"
use :pagination
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -805,7 +805,7 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Set the status of the current user' do
+ desc "Set the status of the current user" do
success Entities::UserStatus
end
params do
@@ -822,10 +822,10 @@ module API
end
end
- desc 'get the status of the current user' do
+ desc "get the status of the current user" do
success Entities::UserStatus
end
- get 'status' do
+ get "status" do
present current_user.status || {}, with: Entities::UserStatus
end
end
diff --git a/lib/api/variables.rb b/lib/api/variables.rb
index 148deb86c4c..2972125085a 100644
--- a/lib/api/variables.rb
+++ b/lib/api/variables.rb
@@ -8,47 +8,47 @@ module API
before { authorize! :admin_build, user_project }
params do
- requires :id, type: String, desc: 'The ID of a project'
+ requires :id, type: String, desc: "The ID of a project"
end
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
- desc 'Get project variables' do
+ desc "Get project variables" do
success Entities::Variable
end
params do
use :pagination
end
- get ':id/variables' do
+ get ":id/variables" do
variables = user_project.variables
present paginate(variables), with: Entities::Variable
end
- desc 'Get a specific variable from a project' do
+ desc "Get a specific variable from a project" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
+ requires :key, type: String, desc: "The key of the variable"
end
# rubocop: disable CodeReuse/ActiveRecord
- get ':id/variables/:key' do
+ get ":id/variables/:key" do
key = params[:key]
variable = user_project.variables.find_by(key: key)
- break not_found!('Variable') unless variable
+ break not_found!("Variable") unless variable
present variable, with: Entities::Variable
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Create a new variable in a project' do
+ desc "Create a new variable in a project" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
- requires :value, type: String, desc: 'The value of the variable'
- optional :protected, type: String, desc: 'Whether the variable is protected'
+ requires :key, type: String, desc: "The key of the variable"
+ requires :value, type: String, desc: "The value of the variable"
+ optional :protected, type: String, desc: "Whether the variable is protected"
end
- post ':id/variables' do
+ post ":id/variables" do
variable_params = declared_params(include_missing: false)
variable = user_project.variables.create(variable_params)
@@ -60,19 +60,19 @@ module API
end
end
- desc 'Update an existing variable from a project' do
+ desc "Update an existing variable from a project" do
success Entities::Variable
end
params do
- optional :key, type: String, desc: 'The key of the variable'
- optional :value, type: String, desc: 'The value of the variable'
- optional :protected, type: String, desc: 'Whether the variable is protected'
+ optional :key, type: String, desc: "The key of the variable"
+ optional :value, type: String, desc: "The value of the variable"
+ optional :protected, type: String, desc: "Whether the variable is protected"
end
# rubocop: disable CodeReuse/ActiveRecord
- put ':id/variables/:key' do
+ put ":id/variables/:key" do
variable = user_project.variables.find_by(key: params[:key])
- break not_found!('Variable') unless variable
+ break not_found!("Variable") unless variable
variable_params = declared_params(include_missing: false).except(:key)
@@ -84,16 +84,16 @@ module API
end
# rubocop: enable CodeReuse/ActiveRecord
- desc 'Delete an existing variable from a project' do
+ desc "Delete an existing variable from a project" do
success Entities::Variable
end
params do
- requires :key, type: String, desc: 'The key of the variable'
+ requires :key, type: String, desc: "The key of the variable"
end
# rubocop: disable CodeReuse/ActiveRecord
- delete ':id/variables/:key' do
+ delete ":id/variables/:key" do
variable = user_project.variables.find_by(key: params[:key])
- not_found!('Variable') unless variable
+ not_found!("Variable") unless variable
# Variables don't have any timestamp. Therfore, destroy unconditionally.
status 204
diff --git a/lib/api/version.rb b/lib/api/version.rb
index 74cd857f447..e770153caf7 100644
--- a/lib/api/version.rb
+++ b/lib/api/version.rb
@@ -4,11 +4,11 @@ module API
class Version < Grape::API
before { authenticate! }
- desc 'Get the version information of the GitLab instance.' do
- detail 'This feature was introduced in GitLab 8.13.'
+ desc "Get the version information of the GitLab instance." do
+ detail "This feature was introduced in GitLab 8.13."
end
- get '/version' do
- { version: Gitlab::VERSION, revision: Gitlab.revision }
+ get "/version" do
+ {version: Gitlab::VERSION, revision: Gitlab.revision}
end
end
end
diff --git a/lib/api/wikis.rb b/lib/api/wikis.rb
index 994074ddc67..9dd7916c480 100644
--- a/lib/api/wikis.rb
+++ b/lib/api/wikis.rb
@@ -7,7 +7,7 @@ module API
{
file_name: attrs[:file][:filename],
file_content: attrs[:file][:tempfile].read,
- branch_name: attrs[:branch]
+ branch_name: attrs[:branch],
}
end
@@ -15,48 +15,48 @@ module API
optional :format,
type: String,
values: ProjectWiki::MARKUPS.values.map(&:to_s),
- default: 'markdown',
- desc: 'Format of a wiki page. Available formats are markdown, rdoc, and asciidoc'
+ default: "markdown",
+ desc: "Format of a wiki page. Available formats are markdown, rdoc, and asciidoc"
end
end
WIKI_ENDPOINT_REQUIREMENTS = API::NAMESPACE_OR_PROJECT_REQUIREMENTS.merge(slug: API::NO_SLASH_URL_PART_REGEX)
resource :projects, requirements: WIKI_ENDPOINT_REQUIREMENTS do
- desc 'Get a list of wiki pages' do
+ desc "Get a list of wiki pages" do
success Entities::WikiPageBasic
end
params do
optional :with_content, type: Boolean, default: false, desc: "Include pages' content"
end
- get ':id/wikis' do
+ get ":id/wikis" do
authorize! :read_wiki, user_project
entity = params[:with_content] ? Entities::WikiPage : Entities::WikiPageBasic
present user_project.wiki.pages, with: entity
end
- desc 'Get a wiki page' do
+ desc "Get a wiki page" do
success Entities::WikiPage
end
params do
- requires :slug, type: String, desc: 'The slug of a wiki page'
+ requires :slug, type: String, desc: "The slug of a wiki page"
end
- get ':id/wikis/:slug' do
+ get ":id/wikis/:slug" do
authorize! :read_wiki, user_project
present wiki_page, with: Entities::WikiPage
end
- desc 'Create a wiki page' do
+ desc "Create a wiki page" do
success Entities::WikiPage
end
params do
- requires :title, type: String, desc: 'Title of a wiki page'
- requires :content, type: String, desc: 'Content of a wiki page'
+ requires :title, type: String, desc: "Title of a wiki page"
+ requires :content, type: String, desc: "Content of a wiki page"
use :common_wiki_page_params
end
- post ':id/wikis' do
+ post ":id/wikis" do
authorize! :create_wiki, user_project
page = WikiPages::CreateService.new(user_project, current_user, params).execute
@@ -68,16 +68,16 @@ module API
end
end
- desc 'Update a wiki page' do
+ desc "Update a wiki page" do
success Entities::WikiPage
end
params do
- optional :title, type: String, desc: 'Title of a wiki page'
- optional :content, type: String, desc: 'Content of a wiki page'
+ optional :title, type: String, desc: "Title of a wiki page"
+ optional :content, type: String, desc: "Content of a wiki page"
use :common_wiki_page_params
at_least_one_of :content, :title, :format
end
- put ':id/wikis/:slug' do
+ put ":id/wikis/:slug" do
authorize! :create_wiki, user_project
page = WikiPages::UpdateService.new(user_project, current_user, params).execute(wiki_page)
@@ -89,31 +89,31 @@ module API
end
end
- desc 'Delete a wiki page'
+ desc "Delete a wiki page"
params do
- requires :slug, type: String, desc: 'The slug of a wiki page'
+ requires :slug, type: String, desc: "The slug of a wiki page"
end
- delete ':id/wikis/:slug' do
+ delete ":id/wikis/:slug" do
authorize! :admin_wiki, user_project
status 204
WikiPages::DestroyService.new(user_project, current_user).execute(wiki_page)
end
- desc 'Upload an attachment to the wiki repository' do
- detail 'This feature was introduced in GitLab 11.3.'
+ desc "Upload an attachment to the wiki repository" do
+ detail "This feature was introduced in GitLab 11.3."
success Entities::WikiAttachment
end
params do
- requires :file, type: ::API::Validations::Types::SafeFile, desc: 'The attachment file to be uploaded'
- optional :branch, type: String, desc: 'The name of the branch'
+ requires :file, type: ::API::Validations::Types::SafeFile, desc: "The attachment file to be uploaded"
+ optional :branch, type: String, desc: "The name of the branch"
end
post ":id/wikis/attachments" do
authorize! :create_wiki, user_project
result = ::Wikis::CreateAttachmentService.new(user_project,
- current_user,
- commit_params(declared_params(include_missing: false))).execute
+ current_user,
+ commit_params(declared_params(include_missing: false))).execute
if result[:status] == :success
status(201)
diff --git a/lib/backup/artifacts.rb b/lib/backup/artifacts.rb
index 33658ae225f..fbc058b54bc 100644
--- a/lib/backup/artifacts.rb
+++ b/lib/backup/artifacts.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Artifacts < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('artifacts', JobArtifactUploader.root)
+ super("artifacts", JobArtifactUploader.root)
end
end
end
diff --git a/lib/backup/builds.rb b/lib/backup/builds.rb
index 5e795a449de..766a35972f5 100644
--- a/lib/backup/builds.rb
+++ b/lib/backup/builds.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Builds < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('builds', Settings.gitlab_ci.builds_path)
+ super("builds", Settings.gitlab_ci.builds_path)
end
end
end
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index e6bf3d1856f..b35fe4142eb 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'yaml'
+require "yaml"
module Backup
class Database
@@ -9,26 +9,26 @@ module Backup
def initialize(progress)
@progress = progress
- @config = YAML.load_file(File.join(Rails.root, 'config', 'database.yml'))[Rails.env]
- @db_file_name = File.join(Gitlab.config.backup.path, 'db', 'database.sql.gz')
+ @config = YAML.load_file(File.join(Rails.root, "config", "database.yml"))[Rails.env]
+ @db_file_name = File.join(Gitlab.config.backup.path, "db", "database.sql.gz")
end
def dump
FileUtils.mkdir_p(File.dirname(db_file_name))
FileUtils.rm_f(db_file_name)
compress_rd, compress_wr = IO.pipe
- compress_pid = spawn(*%w(gzip -1 -c), in: compress_rd, out: [db_file_name, 'w', 0600])
+ compress_pid = spawn("gzip", "-1", "-c", in: compress_rd, out: [db_file_name, "w", 0o600])
compress_rd.close
dump_pid =
case config["adapter"]
when /^mysql/ then
- progress.print "Dumping MySQL database #{config['database']} ... "
+ progress.print "Dumping MySQL database #{config["database"]} ... "
# Workaround warnings from MySQL 5.6 about passwords on cmd line
- ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
- spawn('mysqldump', *mysql_args, config['database'], out: compress_wr)
+ ENV["MYSQL_PWD"] = config["password"].to_s if config["password"]
+ spawn("mysqldump", *mysql_args, config["database"], out: compress_wr)
when "postgresql" then
- progress.print "Dumping PostgreSQL database #{config['database']} ... "
+ progress.print "Dumping PostgreSQL database #{config["database"]} ... "
pg_env
pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
if Gitlab.config.backup.pg_schema
@@ -36,88 +36,88 @@ module Backup
pgsql_args << Gitlab.config.backup.pg_schema
end
- spawn('pg_dump', *pgsql_args, config['database'], out: compress_wr)
+ spawn("pg_dump", *pgsql_args, config["database"], out: compress_wr)
end
compress_wr.close
- success = [compress_pid, dump_pid].all? do |pid|
+ success = [compress_pid, dump_pid].all? { |pid|
Process.waitpid(pid)
$?.success?
- end
+ }
report_success(success)
- raise Backup::Error, 'Backup failed' unless success
+ raise Backup::Error, "Backup failed" unless success
end
def restore
decompress_rd, decompress_wr = IO.pipe
- decompress_pid = spawn(*%w(gzip -cd), out: decompress_wr, in: db_file_name)
+ decompress_pid = spawn("gzip", "-cd", out: decompress_wr, in: db_file_name)
decompress_wr.close
restore_pid =
case config["adapter"]
when /^mysql/ then
- progress.print "Restoring MySQL database #{config['database']} ... "
+ progress.print "Restoring MySQL database #{config["database"]} ... "
# Workaround warnings from MySQL 5.6 about passwords on cmd line
- ENV['MYSQL_PWD'] = config["password"].to_s if config["password"]
- spawn('mysql', *mysql_args, config['database'], in: decompress_rd)
+ ENV["MYSQL_PWD"] = config["password"].to_s if config["password"]
+ spawn("mysql", *mysql_args, config["database"], in: decompress_rd)
when "postgresql" then
- progress.print "Restoring PostgreSQL database #{config['database']} ... "
+ progress.print "Restoring PostgreSQL database #{config["database"]} ... "
pg_env
- spawn('psql', config['database'], in: decompress_rd)
+ spawn("psql", config["database"], in: decompress_rd)
end
decompress_rd.close
- success = [decompress_pid, restore_pid].all? do |pid|
+ success = [decompress_pid, restore_pid].all? { |pid|
Process.waitpid(pid)
$?.success?
- end
+ }
report_success(success)
- abort Backup::Error, 'Restore failed' unless success
+ abort Backup::Error, "Restore failed" unless success
end
protected
def mysql_args
args = {
- 'host' => '--host',
- 'port' => '--port',
- 'socket' => '--socket',
- 'username' => '--user',
- 'encoding' => '--default-character-set',
+ "host" => "--host",
+ "port" => "--port",
+ "socket" => "--socket",
+ "username" => "--user",
+ "encoding" => "--default-character-set",
# SSL
- 'sslkey' => '--ssl-key',
- 'sslcert' => '--ssl-cert',
- 'sslca' => '--ssl-ca',
- 'sslcapath' => '--ssl-capath',
- 'sslcipher' => '--ssl-cipher'
+ "sslkey" => "--ssl-key",
+ "sslcert" => "--ssl-cert",
+ "sslca" => "--ssl-ca",
+ "sslcapath" => "--ssl-capath",
+ "sslcipher" => "--ssl-cipher",
}
args.map { |opt, arg| "#{arg}=#{config[opt]}" if config[opt] }.compact
end
def pg_env
args = {
- 'username' => 'PGUSER',
- 'host' => 'PGHOST',
- 'port' => 'PGPORT',
- 'password' => 'PGPASSWORD',
+ "username" => "PGUSER",
+ "host" => "PGHOST",
+ "port" => "PGPORT",
+ "password" => "PGPASSWORD",
# SSL
- 'sslmode' => 'PGSSLMODE',
- 'sslkey' => 'PGSSLKEY',
- 'sslcert' => 'PGSSLCERT',
- 'sslrootcert' => 'PGSSLROOTCERT',
- 'sslcrl' => 'PGSSLCRL',
- 'sslcompression' => 'PGSSLCOMPRESSION'
+ "sslmode" => "PGSSLMODE",
+ "sslkey" => "PGSSLKEY",
+ "sslcert" => "PGSSLCERT",
+ "sslrootcert" => "PGSSLROOTCERT",
+ "sslcrl" => "PGSSLCRL",
+ "sslcompression" => "PGSSLCOMPRESSION",
}
args.each { |opt, arg| ENV[arg] = config[opt].to_s if config[opt] }
end
def report_success(success)
if success
- progress.puts '[DONE]'.color(:green)
+ progress.puts "[DONE]".color(:green)
else
- progress.puts '[FAILED]'.color(:red)
+ progress.puts "[FAILED]".color(:red)
end
end
end
diff --git a/lib/backup/files.rb b/lib/backup/files.rb
index 2bac84846c5..03b41c17d78 100644
--- a/lib/backup/files.rb
+++ b/lib/backup/files.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'open3'
-require_relative 'helper'
+require "open3"
+require_relative "helper"
module Backup
class Files
@@ -12,9 +12,9 @@ module Backup
def initialize(name, app_files_dir)
@name = name
@app_files_dir = File.realpath(app_files_dir)
- @files_parent_dir = File.realpath(File.join(@app_files_dir, '..'))
- @backup_files_dir = File.join(Gitlab.config.backup.path, File.basename(@app_files_dir) )
- @backup_tarball = File.join(Gitlab.config.backup.path, name + '.tar.gz')
+ @files_parent_dir = File.realpath(File.join(@app_files_dir, ".."))
+ @backup_files_dir = File.join(Gitlab.config.backup.path, File.basename(@app_files_dir))
+ @backup_tarball = File.join(Gitlab.config.backup.path, name + ".tar.gz")
end
# Copy files from public/files to backup/files
@@ -22,34 +22,34 @@ module Backup
FileUtils.mkdir_p(Gitlab.config.backup.path)
FileUtils.rm_f(backup_tarball)
- if ENV['STRATEGY'] == 'copy'
- cmd = %W(rsync -a --exclude=lost+found #{app_files_dir} #{Gitlab.config.backup.path})
+ if ENV["STRATEGY"] == "copy"
+ cmd = %W[rsync -a --exclude=lost+found #{app_files_dir} #{Gitlab.config.backup.path}]
output, status = Gitlab::Popen.popen(cmd)
unless status.zero?
puts output
- raise Backup::Error, 'Backup failed'
+ raise Backup::Error, "Backup failed"
end
- run_pipeline!([%W(#{tar} --exclude=lost+found -C #{@backup_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
+ run_pipeline!([%W[#{tar} --exclude=lost+found -C #{@backup_files_dir} -cf - .], %w[gzip -c -1]], out: [backup_tarball, "w", 0o600])
FileUtils.rm_rf(@backup_files_dir)
else
- run_pipeline!([%W(#{tar} --exclude=lost+found -C #{app_files_dir} -cf - .), %w(gzip -c -1)], out: [backup_tarball, 'w', 0600])
+ run_pipeline!([%W[#{tar} --exclude=lost+found -C #{app_files_dir} -cf - .], %w[gzip -c -1]], out: [backup_tarball, "w", 0o600])
end
end
def restore
backup_existing_files_dir
- run_pipeline!([%w(gzip -cd), %W(#{tar} --unlink-first --recursive-unlink -C #{app_files_dir} -xf -)], in: backup_tarball)
+ run_pipeline!([%w[gzip -cd], %W[#{tar} --unlink-first --recursive-unlink -C #{app_files_dir} -xf -]], in: backup_tarball)
end
def tar
- if system(*%w[gtar --version], out: '/dev/null')
+ if system("gtar", "--version", out: "/dev/null")
# It looks like we can get GNU tar by running 'gtar'
- 'gtar'
+ "gtar"
else
- 'tar'
+ "tar"
end
end
@@ -58,7 +58,7 @@ module Backup
if File.exist?(app_files_dir)
# Move all files in the existing repos directory except . and .. to
# repositories.old.<timestamp> directory
- FileUtils.mkdir_p(timestamped_files_path, mode: 0700)
+ FileUtils.mkdir_p(timestamped_files_path, mode: 0o700)
files = Dir.glob(File.join(app_files_dir, "*"), File::FNM_DOTMATCH) - [File.join(app_files_dir, "."), File.join(app_files_dir, "..")]
begin
FileUtils.mv(files, timestamped_files_path)
@@ -78,7 +78,7 @@ module Backup
return if status.compact.all?(&:success?)
regex = /^g?tar: \.: Cannot mkdir: No such file or directory$/
- raise Backup::Error, 'Backup failed' unless err_r.read =~ regex
+ raise Backup::Error, "Backup failed" unless err_r.read =~ regex
end
end
end
diff --git a/lib/backup/helper.rb b/lib/backup/helper.rb
index 22f00aef569..fd3fe1b47f9 100644
--- a/lib/backup/helper.rb
+++ b/lib/backup/helper.rb
@@ -4,13 +4,12 @@ module Backup
module Helper
def access_denied_error(path)
message = <<~EOS
-
- ### NOTICE ###
- As part of restore, the task tried to move existing content from #{path}.
- However, it seems that directory contains files/folders that are not owned
- by the user #{Gitlab.config.gitlab.user}. To proceed, please move the files
- or folders inside #{path} to a secure location so that #{path} is empty and
- run restore task again.
+ ### NOTICE ###
+ As part of restore, the task tried to move existing content from #{path}.
+ However, it seems that directory contains files/folders that are not owned
+ by the user #{Gitlab.config.gitlab.user}. To proceed, please move the files
+ or folders inside #{path} to a secure location so that #{path} is empty and
+ run restore task again.
EOS
raise message
@@ -18,13 +17,11 @@ module Backup
def resource_busy_error(path)
message = <<~EOS
-
- ### NOTICE ###
- As part of restore, the task tried to rename `#{path}` before restoring.
- This could not be completed, perhaps `#{path}` is a mountpoint?
-
- To complete the restore, please move the contents of `#{path}` to a
- different location and run the restore task again.
+ ### NOTICE ###
+ As part of restore, the task tried to rename `#{path}` before restoring.
+ This could not be completed, perhaps `#{path}` is a mountpoint?
+ To complete the restore, please move the contents of `#{path}` to a
+ different location and run the restore task again.
EOS
raise message
diff --git a/lib/backup/lfs.rb b/lib/backup/lfs.rb
index 0dfe56e214f..689e8093b58 100644
--- a/lib/backup/lfs.rb
+++ b/lib/backup/lfs.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Lfs < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('lfs', Settings.lfs.storage_path)
+ super("lfs", Settings.lfs.storage_path)
end
end
end
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index 06b0338b1ed..52fbbbda382 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -4,7 +4,7 @@ module Backup
class Manager
ARCHIVES_TO_BACKUP = %w[uploads builds artifacts pages lfs registry].freeze
FOLDERS_TO_BACKUP = %w[repositories db].freeze
- FILE_NAME_SUFFIX = '_gitlab_backup.tar'.freeze
+ FILE_NAME_SUFFIX = "_gitlab_backup.tar"
attr_reader :progress
@@ -18,18 +18,18 @@ module Backup
Dir.chdir(backup_path) do
File.open("#{backup_path}/backup_information.yml", "w+") do |file|
- file << backup_information.to_yaml.gsub(/^---\n/, '')
+ file << backup_information.to_yaml.gsub(/^---\n/, "")
end
# create archive
progress.print "Creating backup archive: #{tar_file} ... "
# Set file permissions on open to prevent chmod races.
- tar_system_options = { out: [tar_file, 'w', Gitlab.config.backup.archive_permissions] }
- if Kernel.system('tar', '-cf', '-', *backup_contents, tar_system_options)
+ tar_system_options = {out: [tar_file, "w", Gitlab.config.backup.archive_permissions]}
+ if Kernel.system("tar", "-cf", "-", *backup_contents, tar_system_options)
progress.puts "done".color(:green)
else
puts "creating archive #{tar_file} failed".color(:red)
- raise Backup::Error, 'Backup failed'
+ raise Backup::Error, "Backup failed"
end
upload
@@ -55,7 +55,7 @@ module Backup
progress.puts "done".color(:green)
else
puts "uploading backup to #{remote_directory} failed".color(:red)
- raise Backup::Error, 'Backup failed'
+ raise Backup::Error, "Backup failed"
end
end
@@ -69,7 +69,7 @@ module Backup
progress.puts "done".color(:green)
else
puts "deleting tmp directory '#{dir}' failed".color(:red)
- raise Backup::Error, 'Backup failed'
+ raise Backup::Error, "Backup failed"
end
end
end
@@ -118,35 +118,35 @@ module Backup
progress.puts "Please make sure that file name ends with #{FILE_NAME_SUFFIX}"
exit 1
elsif backup_file_list.many? && ENV["BACKUP"].nil?
- progress.puts 'Found more than one backup:'
+ progress.puts "Found more than one backup:"
# print list of available backups
progress.puts " " + available_timestamps.join("\n ")
- progress.puts 'Please specify which one you want to restore:'
- progress.puts 'rake gitlab:backup:restore BACKUP=timestamp_of_backup'
+ progress.puts "Please specify which one you want to restore:"
+ progress.puts "rake gitlab:backup:restore BACKUP=timestamp_of_backup"
exit 1
end
- tar_file = if ENV['BACKUP'].present?
- "#{ENV['BACKUP']}#{FILE_NAME_SUFFIX}"
- else
- backup_file_list.first
- end
+ tar_file = if ENV["BACKUP"].present?
+ "#{ENV["BACKUP"]}#{FILE_NAME_SUFFIX}"
+ else
+ backup_file_list.first
+ end
unless File.exist?(tar_file)
progress.puts "The backup file #{tar_file} does not exist!"
exit 1
end
- progress.print 'Unpacking backup ... '
+ progress.print "Unpacking backup ... "
- unless Kernel.system(*%W(tar -xf #{tar_file}))
- progress.puts 'unpacking backup failed'.color(:red)
- exit 1
+ if Kernel.system("tar", "-xf", tar_file.to_s)
+ progress.puts "done".color(:green)
else
- progress.puts 'done'.color(:green)
+ progress.puts "unpacking backup failed".color(:red)
+ exit 1
end
- ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
+ ENV["VERSION"] = settings[:db_version].to_s if settings[:db_version].to_i > 0
# restoring mismatching backups can lead to unexpected problems
if settings[:gitlab_version] != Gitlab::VERSION
@@ -164,12 +164,12 @@ module Backup
end
def tar_version
- tar_version, _ = Gitlab::Popen.popen(%w(tar --version))
- tar_version.dup.force_encoding('locale').split("\n").first
+ tar_version, _ = Gitlab::Popen.popen(%w[tar --version])
+ tar_version.dup.force_encoding("locale").split("\n").first
end
def skipped?(item)
- settings[:skipped] && settings[:skipped].include?(item) || disabled_features.include?(item)
+ settings[:skipped]&.include?(item) || disabled_features.include?(item)
end
private
@@ -183,7 +183,7 @@ module Backup
end
def available_timestamps
- @backup_file_list.map {|item| item.gsub("#{FILE_NAME_SUFFIX}", "")}
+ @backup_file_list.map {|item| item.gsub(FILE_NAME_SUFFIX.to_s, "")}
end
def connect_to_remote_directory(connection_settings)
@@ -205,8 +205,8 @@ module Backup
end
def remote_target
- if ENV['DIRECTORY']
- File.join(ENV['DIRECTORY'], tar_file)
+ if ENV["DIRECTORY"]
+ File.join(ENV["DIRECTORY"], tar_file)
else
tar_file
end
@@ -226,7 +226,7 @@ module Backup
def disabled_features
features = []
- features << 'registry' unless Gitlab.config.registry.enabled
+ features << "registry" unless Gitlab.config.registry.enabled
features
end
@@ -235,7 +235,7 @@ module Backup
end
def tar_file
- @tar_file ||= "#{backup_information[:backup_created_at].strftime('%s_%Y_%m_%d_')}#{backup_information[:gitlab_version]}#{FILE_NAME_SUFFIX}"
+ @tar_file ||= "#{backup_information[:backup_created_at].strftime("%s_%Y_%m_%d_")}#{backup_information[:gitlab_version]}#{FILE_NAME_SUFFIX}"
end
def backup_information
@@ -245,7 +245,7 @@ module Backup
gitlab_version: Gitlab::VERSION,
tar_version: tar_version,
installation_type: Gitlab::INSTALLATION_TYPE,
- skipped: ENV["SKIP"]
+ skipped: ENV["SKIP"],
}
end
end
diff --git a/lib/backup/pages.rb b/lib/backup/pages.rb
index a4be728df08..10a915cfd41 100644
--- a/lib/backup/pages.rb
+++ b/lib/backup/pages.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Pages < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('pages', Gitlab.config.pages.path)
+ super("pages", Gitlab.config.pages.path)
end
end
end
diff --git a/lib/backup/registry.rb b/lib/backup/registry.rb
index d16ed2facf1..1fdacccea26 100644
--- a/lib/backup/registry.rb
+++ b/lib/backup/registry.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Registry < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('registry', Settings.registry.path)
+ super("registry", Settings.registry.path)
end
end
end
diff --git a/lib/backup/repository.rb b/lib/backup/repository.rb
index 22ed1d8e7b4..76763b4a0f3 100644
--- a/lib/backup/repository.rb
+++ b/lib/backup/repository.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'yaml'
+require "yaml"
module Backup
class Repository
@@ -54,7 +54,7 @@ module Backup
backup_custom_hooks(project)
rescue => e
- progress_warn(project, e, 'Failed to backup repo')
+ progress_warn(project, e, "Failed to backup repo")
end
def backup_custom_hooks(project)
@@ -125,7 +125,7 @@ module Backup
protected
def path_to_bundle(project)
- File.join(backup_repos_path, project.disk_path + '.bundle')
+ File.join(backup_repos_path, project.disk_path + ".bundle")
end
def project_backup_path(project)
@@ -137,13 +137,13 @@ module Backup
end
def backup_repos_path
- File.join(Gitlab.config.backup.path, 'repositories')
+ File.join(Gitlab.config.backup.path, "repositories")
end
def prepare
FileUtils.rm_rf(backup_repos_path)
FileUtils.mkdir_p(Gitlab.config.backup.path)
- FileUtils.mkdir(backup_repos_path, mode: 0700)
+ FileUtils.mkdir(backup_repos_path, mode: 0o700)
end
private
@@ -167,7 +167,7 @@ module Backup
progress.puts " - Object pool #{pool.disk_path}..."
pool.source_project ||= pool.member_projects.first.root_of_fork_network
- pool.state = 'none'
+ pool.state = "none"
pool.save
pool.schedule
diff --git a/lib/backup/uploads.rb b/lib/backup/uploads.rb
index 9577df2634a..72c6e823026 100644
--- a/lib/backup/uploads.rb
+++ b/lib/backup/uploads.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'backup/files'
+require "backup/files"
module Backup
class Uploads < Files
@@ -9,7 +9,7 @@ module Backup
def initialize(progress)
@progress = progress
- super('uploads', Rails.root.join('public/uploads'))
+ super("uploads", Rails.root.join("public/uploads"))
end
end
end
diff --git a/lib/banzai/filter/absolute_link_filter.rb b/lib/banzai/filter/absolute_link_filter.rb
index a9bdb004c4b..84eeb1d43e0 100644
--- a/lib/banzai/filter/absolute_link_filter.rb
+++ b/lib/banzai/filter/absolute_link_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
module Banzai
module Filter
@@ -9,8 +9,8 @@ module Banzai
def call
return doc unless context[:only_path] == false
- doc.search('a.gfm').each do |el|
- process_link_attr el.attribute('href')
+ doc.search("a.gfm").each do |el|
+ process_link_attr el.attribute("href")
end
doc
@@ -20,7 +20,7 @@ module Banzai
def process_link_attr(html_attr)
return if html_attr.blank?
- return if html_attr.value.start_with?('//')
+ return if html_attr.value.start_with?("//")
uri = URI(html_attr.value)
html_attr.value = absolute_link_attr(uri) if uri.relative?
diff --git a/lib/banzai/filter/abstract_reference_filter.rb b/lib/banzai/filter/abstract_reference_filter.rb
index 4764f8e1e19..c727d0fd97d 100644
--- a/lib/banzai/filter/abstract_reference_filter.rb
+++ b/lib/banzai/filter/abstract_reference_filter.rb
@@ -133,7 +133,7 @@ module Banzai
next
end
- if link =~ link_pattern_anchor
+ if link&.match?(link_pattern_anchor)
replace_link_node_with_href(node, link) do
object_link_filter(link, link_pattern, link_content: inner_html, link_reference: true)
end
@@ -161,10 +161,10 @@ module Banzai
def object_link_filter(text, pattern, link_content: nil, link_reference: false)
references_in(text, pattern) do |match, id, project_ref, namespace_ref, matches|
parent_path = if parent_type == :group
- full_group_path(namespace_ref)
- else
- full_project_path(namespace_ref, project_ref)
- end
+ full_group_path(namespace_ref)
+ else
+ full_project_path(namespace_ref, project_ref)
+ end
parent = from_ref_cached(parent_path)
@@ -182,8 +182,8 @@ module Banzai
klass = reference_class(object_sym)
data = data_attributes_for(link_content || match, parent, object,
- link_content: !!link_content,
- link_reference: link_reference)
+ link_content: !!link_content,
+ link_reference: link_reference)
url =
if matches.names.include?("url") && matches[:url]
@@ -207,11 +207,11 @@ module Banzai
object_parent_type = parent.is_a?(Group) ? :group : :project
data_attribute(
- original: text,
- link: link_content,
- link_reference: link_reference,
+ :original => text,
+ :link => link_content,
+ :link_reference => link_reference,
object_parent_type => parent.id,
- object_sym => object.id
+ object_sym => object.id
)
end
@@ -256,10 +256,10 @@ module Banzai
nodes.each do |node|
node.to_html.scan(regex) do
path = if parent_type == :project
- full_project_path($~[:namespace], $~[:project])
- else
- full_group_path($~[:group])
- end
+ full_project_path($~[:namespace], $~[:project])
+ else
+ full_group_path($~[:group])
+ end
symbol = $~[object_sym]
refs[path] << symbol if object_class.reference_valid?(symbol)
diff --git a/lib/banzai/filter/ascii_doc_post_processing_filter.rb b/lib/banzai/filter/ascii_doc_post_processing_filter.rb
index 88439f06b5f..1df44ff21da 100644
--- a/lib/banzai/filter/ascii_doc_post_processing_filter.rb
+++ b/lib/banzai/filter/ascii_doc_post_processing_filter.rb
@@ -4,8 +4,8 @@ module Banzai
module Filter
class AsciiDocPostProcessingFilter < HTML::Pipeline::Filter
def call
- doc.search('[data-math-style]').each do |node|
- node.set_attribute('class', 'code math js-render-math')
+ doc.search("[data-math-style]").each do |node|
+ node.set_attribute("class", "code math js-render-math")
end
doc
diff --git a/lib/banzai/filter/autolink_filter.rb b/lib/banzai/filter/autolink_filter.rb
index 086adf59d2b..cad13eabdfb 100644
--- a/lib/banzai/filter/autolink_filter.rb
+++ b/lib/banzai/filter/autolink_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
module Banzai
module Filter
@@ -36,20 +36,20 @@ module Banzai
LINK_PATTERN = %r{([a-z][a-z0-9\+\.-]+://[^\s>]+)(?<!\?|!|\.|,|:)}
# Text matching LINK_PATTERN inside these elements will not be linked
- IGNORE_PARENTS = %w(a code kbd pre script style).to_set
+ IGNORE_PARENTS = %w[a code kbd pre script style].to_set
# The XPath query to use for finding text nodes to parse.
- TEXT_QUERY = %Q(descendant-or-self::text()[
- not(#{IGNORE_PARENTS.map { |p| "ancestor::#{p}" }.join(' or ')})
+ TEXT_QUERY = %(descendant-or-self::text()[
+ not(#{IGNORE_PARENTS.map { |p| "ancestor::#{p}" }.join(" or ")})
and contains(., '://')
- ]).freeze
+ ])
PUNCTUATION_PAIRS = {
"'" => "'",
'"' => '"',
- ')' => '(',
- ']' => '[',
- '}' => '{'
+ ")" => "(",
+ "]" => "[",
+ "}" => "{",
}.freeze
def call
@@ -92,8 +92,8 @@ module Banzai
# Remove any trailing HTML entities and store them for appending
# outside the link element. The entity must be marked HTML safe in
# order to be output literally rather than escaped.
- match.gsub!(/((?:&[\w#]+;)+)\z/, '')
- dropped = ($1 || '').html_safe
+ match.gsub!(/((?:&[\w#]+;)+)\z/, "")
+ dropped = ($1 || "").html_safe
# To match the behaviour of Rinku, if the matched link ends with a
# closing part of a matched pair of punctuation, we remove that trailing
diff --git a/lib/banzai/filter/color_filter.rb b/lib/banzai/filter/color_filter.rb
index 6d9bdb9cbd3..0204bd87773 100644
--- a/lib/banzai/filter/color_filter.rb
+++ b/lib/banzai/filter/color_filter.rb
@@ -5,10 +5,10 @@ module Banzai
# HTML filter that renders `color` followed by a color "chip".
#
class ColorFilter < HTML::Pipeline::Filter
- COLOR_CHIP_CLASS = 'gfm-color_chip'.freeze
+ COLOR_CHIP_CLASS = "gfm-color_chip"
def call
- doc.css('code').each do |node|
+ doc.css("code").each do |node|
color = ColorParser.parse(node.content)
node << color_chip(color) if color
end
@@ -19,8 +19,8 @@ module Banzai
private
def color_chip(color)
- checkerboard = doc.document.create_element('span', class: COLOR_CHIP_CLASS)
- chip = doc.document.create_element('span', style: inline_styles(color: color))
+ checkerboard = doc.document.create_element("span", class: COLOR_CHIP_CLASS)
+ chip = doc.document.create_element("span", style: inline_styles(color: color))
checkerboard << chip
end
diff --git a/lib/banzai/filter/commit_range_reference_filter.rb b/lib/banzai/filter/commit_range_reference_filter.rb
index d6b46236a49..926860a9bc4 100644
--- a/lib/banzai/filter/commit_range_reference_filter.rb
+++ b/lib/banzai/filter/commit_range_reference_filter.rb
@@ -35,7 +35,7 @@ module Banzai
def url_for_object(range, project)
h = Gitlab::Routing.url_helpers
h.project_compare_url(project,
- range.to_param.merge(only_path: context[:only_path]))
+ range.to_param.merge(only_path: context[:only_path]))
end
def object_link_title(range, matches)
diff --git a/lib/banzai/filter/commit_reference_filter.rb b/lib/banzai/filter/commit_reference_filter.rb
index c3e5ac41cb8..39b18873d5b 100644
--- a/lib/banzai/filter/commit_reference_filter.rb
+++ b/lib/banzai/filter/commit_reference_filter.rb
@@ -21,7 +21,7 @@ module Banzai
def find_object(project, id)
return unless project.is_a?(Project)
- if project && project.valid_repo?
+ if project&.valid_repo?
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/43894
Gitlab::GitalyClient.allow_n_plus_1_calls { project.commit(id) }
end
@@ -43,13 +43,13 @@ module Banzai
if referenced_merge_request_commit_shas.include?(commit.id)
h.diffs_project_merge_request_url(project,
- noteable,
- commit_id: commit.id,
- only_path: only_path?)
+ noteable,
+ commit_id: commit.id,
+ only_path: only_path?)
else
h.project_commit_url(project,
- commit,
- only_path: only_path?)
+ commit,
+ only_path: only_path?)
end
end
@@ -57,7 +57,7 @@ module Banzai
extras = super
path = matches[:path] if matches.names.include?("path")
- if path == '/builds'
+ if path == "/builds"
extras.unshift "builds"
end
diff --git a/lib/banzai/filter/commit_trailers_filter.rb b/lib/banzai/filter/commit_trailers_filter.rb
index f49c4b403db..d675d29730a 100644
--- a/lib/banzai/filter/commit_trailers_filter.rb
+++ b/lib/banzai/filter/commit_trailers_filter.rb
@@ -27,7 +27,7 @@ module Banzai
FILTER_REGEXP = /(?<trailer>^\s*#{TRAILER_REGEXP}\s*#{AUTHOR_REGEXP}\s+#{MAIL_REGEXP}$)/mi.freeze
def call
- doc.xpath('descendant-or-self::text()').each do |node|
+ doc.xpath("descendant-or-self::text()").each do |node|
content = node.to_html
next unless content.match(FILTER_REGEXP)
@@ -81,13 +81,13 @@ module Banzai
def link_to_user(user, name:, email:, trailer:)
wrapper = link_wrapper(data: {
trailer: trailer,
- user: user.try(:id)
+ user: user.try(:id),
})
avatar = user_avatar_without_link(
user: user,
user_email: email,
- css_class: 'avatar-inline',
+ css_class: "avatar-inline",
has_tooltip: false
)
@@ -118,7 +118,7 @@ module Banzai
data_attributes = data_attributes_from_hash(data)
doc.document.create_element(
- 'span',
+ "span",
data_attributes
)
end
@@ -131,7 +131,7 @@ module Banzai
title: title
)
- link = doc.document.create_element('a', attributes)
+ link = doc.document.create_element("a", attributes)
if content.html_safe?
link << content
@@ -144,9 +144,9 @@ module Banzai
def data_attributes_from_hash(data = {})
data.reject! {|_, value| value.nil?}
- data.map do |key, value|
+ data.map { |key, value|
[%(data-#{key.to_s.dasherize}), value]
- end.to_h
+ }.to_h
end
end
end
diff --git a/lib/banzai/filter/emoji_filter.rb b/lib/banzai/filter/emoji_filter.rb
index fa1690f73ad..cfa90295dca 100644
--- a/lib/banzai/filter/emoji_filter.rb
+++ b/lib/banzai/filter/emoji_filter.rb
@@ -7,14 +7,14 @@ module Banzai
#
# Based on HTML::Pipeline::EmojiFilter
class EmojiFilter < HTML::Pipeline::Filter
- IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
+ IGNORED_ANCESTOR_TAGS = %w[pre code tt].to_set
def call
doc.search(".//text()").each do |node|
content = node.to_html
next if has_ancestor?(node, IGNORED_ANCESTOR_TAGS)
- next unless content.include?(':') || node.text.match(emoji_unicode_pattern)
+ next unless content.include?(":") || node.text.match(emoji_unicode_pattern)
html = emoji_unicode_element_unicode_filter(content)
html = emoji_name_element_unicode_filter(html)
@@ -46,7 +46,7 @@ module Banzai
def emoji_unicode_element_unicode_filter(text)
text.gsub(emoji_unicode_pattern) do |moji|
emoji_info = Gitlab::Emoji.emojis_by_moji[moji]
- Gitlab::Emoji.gl_emoji_tag(emoji_info['name'])
+ Gitlab::Emoji.gl_emoji_tag(emoji_info["name"])
end
end
diff --git a/lib/banzai/filter/external_issue_reference_filter.rb b/lib/banzai/filter/external_issue_reference_filter.rb
index 8159dcfed72..ac8449cb4df 100644
--- a/lib/banzai/filter/external_issue_reference_filter.rb
+++ b/lib/banzai/filter/external_issue_reference_filter.rb
@@ -42,7 +42,7 @@ module Banzai
elsif element_node?(node)
yield_valid_link(node) do |link, inner_html|
- if link =~ ref_start_pattern
+ if link&.match?(ref_start_pattern)
replace_link_node_with_href(node, link) do
issue_link_filter(link, link_content: inner_html)
end
diff --git a/lib/banzai/filter/external_link_filter.rb b/lib/banzai/filter/external_link_filter.rb
index 61ee3eac216..4357826b633 100644
--- a/lib/banzai/filter/external_link_filter.rb
+++ b/lib/banzai/filter/external_link_filter.rb
@@ -4,9 +4,9 @@ module Banzai
module Filter
# HTML Filter to modify the attributes of external links
class ExternalLinkFilter < HTML::Pipeline::Filter
- SCHEMES = ['http', 'https', nil].freeze
- RTLO = "\u202E".freeze
- ENCODED_RTLO = '%E2%80%AE'.freeze
+ SCHEMES = ["http", "https", nil].freeze
+ RTLO = "\u202E"
+ ENCODED_RTLO = "%E2%80%AE"
def call
links.each do |node|
@@ -14,10 +14,10 @@ module Banzai
# such as on `mailto:` links. Since we've been using it, do an
# initial parse for validity and then use Addressable
# for IDN support, etc
- uri = uri_strict(node['href'].to_s)
+ uri = uri_strict(node["href"].to_s)
if uri
- node.set_attribute('href', uri.to_s)
- addressable_uri = addressable_uri(node['href'])
+ node.set_attribute("href", uri.to_s)
+ addressable_uri = addressable_uri(node["href"])
else
addressable_uri = nil
end
@@ -72,7 +72,7 @@ module Banzai
return unless uri
return unless context[:emailable_links]
- unencoded_uri_str = Addressable::URI.unencode(node['href'])
+ unencoded_uri_str = Addressable::URI.unencode(node["href"])
if unencoded_uri_str == node.content && idn?(uri)
node.content = uri.normalize
@@ -95,20 +95,20 @@ module Banzai
# as this is an indicator of a malicious link
def add_malicious_tooltip!(uri, node)
if idn?(uri) || has_encoded_rtlo?(uri)
- node.add_class('has-tooltip')
- node.set_attribute('title', uri.normalize)
+ node.add_class("has-tooltip")
+ node.set_attribute("title", uri.normalize)
end
end
def add_nofollow!(uri, node)
if SCHEMES.include?(uri&.scheme)
- node.set_attribute('rel', 'nofollow noreferrer noopener')
- node.set_attribute('target', '_blank')
+ node.set_attribute("rel", "nofollow noreferrer noopener")
+ node.set_attribute("target", "_blank")
end
end
def idn?(uri)
- uri&.normalized_host&.start_with?('xn--')
+ uri&.normalized_host&.start_with?("xn--")
end
def has_encoded_rtlo?(uri)
diff --git a/lib/banzai/filter/footnote_filter.rb b/lib/banzai/filter/footnote_filter.rb
index de133774dfa..0f69ecee7f8 100644
--- a/lib/banzai/filter/footnote_filter.rb
+++ b/lib/banzai/filter/footnote_filter.rb
@@ -17,8 +17,8 @@ module Banzai
#
class FootnoteFilter < HTML::Pipeline::Filter
INTEGER_PATTERN = /\A\d+\z/.freeze
- FOOTNOTE_ID_PREFIX = 'fn'.freeze
- FOOTNOTE_LINK_ID_PREFIX = 'fnref'.freeze
+ FOOTNOTE_ID_PREFIX = "fn"
+ FOOTNOTE_LINK_ID_PREFIX = "fnref"
FOOTNOTE_LI_REFERENCE_PATTERN = /\A#{FOOTNOTE_ID_PREFIX}\d+\z/.freeze
FOOTNOTE_LINK_REFERENCE_PATTERN = /\A#{FOOTNOTE_LINK_ID_PREFIX}\d+\z/.freeze
FOOTNOTE_START_NUMBER = 1
@@ -31,7 +31,7 @@ module Banzai
rand_suffix = "-#{random_number}"
modified_footnotes = {}
- doc.css('sup > a[id]').each do |link_node|
+ doc.css("sup > a[id]").each do |link_node|
ref_num = link_node[:id].delete_prefix(FOOTNOTE_LINK_ID_PREFIX)
footnote_node = doc.at_css("li[id=#{fn_id(ref_num)}]")
@@ -40,7 +40,7 @@ module Banzai
link_node[:id] += rand_suffix
# Sanitization stripped off class - add it back in
- link_node.parent.append_class('footnote-ref')
+ link_node.parent.append_class("footnote-ref")
unless modified_footnotes[ref_num]
footnote_node[:id] += rand_suffix
@@ -48,7 +48,7 @@ module Banzai
if backref_node
backref_node[:href] += rand_suffix
- backref_node.append_class('footnote-backref')
+ backref_node.append_class("footnote-backref")
end
modified_footnotes[ref_num] = true
diff --git a/lib/banzai/filter/front_matter_filter.rb b/lib/banzai/filter/front_matter_filter.rb
index a27d18facd1..67d684e4fd1 100644
--- a/lib/banzai/filter/front_matter_filter.rb
+++ b/lib/banzai/filter/front_matter_filter.rb
@@ -4,9 +4,9 @@ module Banzai
module Filter
class FrontMatterFilter < HTML::Pipeline::Filter
DELIM_LANG = {
- '---' => 'yaml',
- '+++' => 'toml',
- ';;;' => 'json'
+ "---" => "yaml",
+ "+++" => "toml",
+ ";;;" => "json",
}.freeze
DELIM = Regexp.union(DELIM_LANG.keys)
diff --git a/lib/banzai/filter/gollum_tags_filter.rb b/lib/banzai/filter/gollum_tags_filter.rb
index 0c1bbd2d250..65255ea3b6b 100644
--- a/lib/banzai/filter/gollum_tags_filter.rb
+++ b/lib/banzai/filter/gollum_tags_filter.rb
@@ -59,7 +59,7 @@ module Banzai
ALLOWED_IMAGE_EXTENSIONS = /.+(jpg|png|gif|svg|bmp)\z/i.freeze
# Do not perform linking inside these tags.
- IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
+ IGNORED_ANCESTOR_TAGS = %w[pre code tt].to_set
def call
doc.search(".//text()").each do |node|
@@ -91,7 +91,7 @@ module Banzai
# Replace an entire `[[<em>TOC</em>]]` node with the result generated by
# TableOfContentsFilter
def process_toc_tag(node)
- node.parent.parent.replace(result[:toc].presence || '')
+ node.parent.parent.replace(result[:toc].presence || "")
end
# Process a single tag into its final HTML form.
@@ -100,7 +100,7 @@ module Banzai
#
# Returns the String HTML version of the tag.
def process_tag(tag)
- parts = tag.split('|')
+ parts = tag.split("|")
return if parts.size.zero?
@@ -125,14 +125,14 @@ module Banzai
end
if path
- content_tag(:img, nil, data: { src: path }, class: 'gfm')
+ content_tag(:img, nil, data: {src: path}, class: "gfm")
end
end
def toc_tag?(node)
- node.content == 'TOC' &&
- node.parent.name == 'em' &&
- node.parent.parent.text == '[[TOC]]'
+ node.content == "TOC" &&
+ node.parent.name == "em" &&
+ node.parent.parent.text == "[[TOC]]"
end
def image?(path)
@@ -140,7 +140,7 @@ module Banzai
end
def url?(path)
- path.start_with?(*%w(http https))
+ path.start_with?("http", "https")
end
# Attempt to process the tag as a page link tag.
@@ -163,7 +163,7 @@ module Banzai
::File.join(project_wiki_base_path, reference)
end
- content_tag(:a, name || reference, href: href, class: 'gfm')
+ content_tag(:a, name || reference, href: href, class: "gfm")
end
def project_wiki
@@ -171,7 +171,7 @@ module Banzai
end
def project_wiki_base_path
- project_wiki && project_wiki.wiki_base_path
+ project_wiki&.wiki_base_path
end
# Ensure that a :project_wiki key exists in context
diff --git a/lib/banzai/filter/html_entity_filter.rb b/lib/banzai/filter/html_entity_filter.rb
index 406c2d3c96b..8ef93478bc4 100644
--- a/lib/banzai/filter/html_entity_filter.rb
+++ b/lib/banzai/filter/html_entity_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'erb'
+require "erb"
module Banzai
module Filter
diff --git a/lib/banzai/filter/image_lazy_load_filter.rb b/lib/banzai/filter/image_lazy_load_filter.rb
index d8b9eb29cf5..6e542d13ac8 100644
--- a/lib/banzai/filter/image_lazy_load_filter.rb
+++ b/lib/banzai/filter/image_lazy_load_filter.rb
@@ -7,10 +7,10 @@ module Banzai
# so they can be lazy loaded.
class ImageLazyLoadFilter < HTML::Pipeline::Filter
def call
- doc.xpath('descendant-or-self::img').each do |img|
- img.add_class('lazy')
- img['data-src'] = img['src']
- img['src'] = LazyImageTagHelper.placeholder_image
+ doc.xpath("descendant-or-self::img").each do |img|
+ img.add_class("lazy")
+ img["data-src"] = img["src"]
+ img["src"] = LazyImageTagHelper.placeholder_image
end
doc
diff --git a/lib/banzai/filter/image_link_filter.rb b/lib/banzai/filter/image_link_filter.rb
index 01237303c27..f1059da3ec4 100644
--- a/lib/banzai/filter/image_link_filter.rb
+++ b/lib/banzai/filter/image_link_filter.rb
@@ -9,13 +9,13 @@ module Banzai
# a new node (a link to the image source), copy the image as a child
# of the anchor, and then replace the img with the link-wrapped version.
def call
- doc.xpath('descendant-or-self::img[not(ancestor::a)]').each do |img|
+ doc.xpath("descendant-or-self::img[not(ancestor::a)]").each do |img|
link = doc.document.create_element(
- 'a',
- class: 'no-attachment-icon',
- href: img['data-src'] || img['src'],
- target: '_blank',
- rel: 'noopener noreferrer'
+ "a",
+ class: "no-attachment-icon",
+ href: img["data-src"] || img["src"],
+ target: "_blank",
+ rel: "noopener noreferrer"
)
link.children = img.clone
diff --git a/lib/banzai/filter/inline_diff_filter.rb b/lib/banzai/filter/inline_diff_filter.rb
index 5a1c0bee32d..23481911b19 100644
--- a/lib/banzai/filter/inline_diff_filter.rb
+++ b/lib/banzai/filter/inline_diff_filter.rb
@@ -4,7 +4,7 @@
module Banzai
module Filter
class InlineDiffFilter < HTML::Pipeline::Filter
- IGNORED_ANCESTOR_TAGS = %w(pre code tt).to_set
+ IGNORED_ANCESTOR_TAGS = %w[pre code tt].to_set
def call
doc.search(".//text()").each do |node|
diff --git a/lib/banzai/filter/issuable_state_filter.rb b/lib/banzai/filter/issuable_state_filter.rb
index 8e2358694d4..db1a9634d14 100644
--- a/lib/banzai/filter/issuable_state_filter.rb
+++ b/lib/banzai/filter/issuable_state_filter.rb
@@ -8,7 +8,7 @@ module Banzai
#
# This filter supports cross-project references.
class IssuableStateFilter < HTML::Pipeline::Filter
- VISIBLE_STATES = %w(closed merged).freeze
+ VISIBLE_STATES = %w[closed merged].freeze
def call
return doc unless context[:issuable_state_filter_enabled]
diff --git a/lib/banzai/filter/label_reference_filter.rb b/lib/banzai/filter/label_reference_filter.rb
index f90a35952e5..9061bce1937 100644
--- a/lib/banzai/filter/label_reference_filter.rb
+++ b/lib/banzai/filter/label_reference_filter.rb
@@ -44,13 +44,13 @@ module Banzai
def find_labels(parent)
params = if parent.is_a?(Group)
- { group_id: parent.id,
- include_ancestor_groups: true,
- only_group_labels: true }
- else
- { project: parent,
- include_ancestor_groups: true }
- end
+ {group_id: parent.id,
+ include_ancestor_groups: true,
+ only_group_labels: true,}
+ else
+ {project: parent,
+ include_ancestor_groups: true,}
+ end
LabelsFinder.new(nil, params).execute(skip_authorization: true)
end
@@ -64,9 +64,9 @@ module Banzai
# Returns a Hash.
def label_params(id, name)
if name
- { name: name.tr('"', '') }
+ {name: name.tr('"', "")}
else
- { id: id.to_i }
+ {id: id.to_i}
end
end
@@ -81,7 +81,7 @@ module Banzai
end
def object_link_text(object, matches)
- label_suffix = ''
+ label_suffix = ""
if project || full_path_ref?(matches)
project_path = full_project_path(matches[:namespace], matches[:project])
diff --git a/lib/banzai/filter/markdown_engines/common_mark.rb b/lib/banzai/filter/markdown_engines/common_mark.rb
index d3af776db05..a74bfe85e90 100644
--- a/lib/banzai/filter/markdown_engines/common_mark.rb
+++ b/lib/banzai/filter/markdown_engines/common_mark.rb
@@ -14,13 +14,13 @@ module Banzai
:autolink, # provides support for automatically converting URLs to anchor tags.
:strikethrough, # provides support for strikethroughs.
:table, # provides support for tables.
- :tagfilter # strips out several "unsafe" HTML tags from being used: https://github.github.com/gfm/#disallowed-raw-html-extension-
+ :tagfilter, # strips out several "unsafe" HTML tags from being used: https://github.github.com/gfm/#disallowed-raw-html-extension-
].freeze
PARSE_OPTIONS = [
:FOOTNOTES, # parse footnotes.
:STRIKETHROUGH_DOUBLE_TILDE, # parse strikethroughs by double tildes (as redcarpet does).
- :VALIDATE_UTF8 # replace illegal sequences with the replacement character U+FFFD.
+ :VALIDATE_UTF8, # replace illegal sequences with the replacement character U+FFFD.
].freeze
# The `:GITHUB_PRE_LANG` option is not used intentionally because
@@ -29,11 +29,11 @@ module Banzai
# If in the future the syntax is about to be made GitHub-compatible, please, add `:GITHUB_PRE_LANG` render option below
# and remove `code_block` method from `lib/banzai/renderer/common_mark/html.rb`.
RENDER_OPTIONS = [
- :DEFAULT # default rendering system. Nothing special.
+ :DEFAULT, # default rendering system. Nothing special.
].freeze
RENDER_OPTIONS_SOURCEPOS = RENDER_OPTIONS + [
- :SOURCEPOS # enable embedding of source position information
+ :SOURCEPOS, # enable embedding of source position information
].freeze
def initialize(context)
diff --git a/lib/banzai/filter/math_filter.rb b/lib/banzai/filter/math_filter.rb
index 8dd5a8979c8..7199f2fb7da 100644
--- a/lib/banzai/filter/math_filter.rb
+++ b/lib/banzai/filter/math_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
# Generated HTML is transformed back to GFM by:
# - app/assets/javascripts/behaviors/markdown/marks/math.js
@@ -11,17 +11,17 @@ module Banzai
#
class MathFilter < HTML::Pipeline::Filter
# Attribute indicating inline or display math.
- STYLE_ATTRIBUTE = 'data-math-style'.freeze
+ STYLE_ATTRIBUTE = "data-math-style"
# Class used for tagging elements that should be rendered
- TAG_CLASS = 'js-render-math'.freeze
+ TAG_CLASS = "js-render-math"
- INLINE_CLASSES = "code math #{TAG_CLASS}".freeze
+ INLINE_CLASSES = "code math #{TAG_CLASS}"
- DOLLAR_SIGN = '$'.freeze
+ DOLLAR_SIGN = "$"
def call
- doc.css('code').each do |code|
+ doc.css("code").each do |code|
closing = code.next
opening = code.previous
@@ -33,14 +33,14 @@ module Banzai
opening.content.last == DOLLAR_SIGN
code[:class] = INLINE_CLASSES
- code[STYLE_ATTRIBUTE] = 'inline'
+ code[STYLE_ATTRIBUTE] = "inline"
closing.content = closing.content[1..-1]
opening.content = opening.content[0..-2]
end
end
- doc.css('pre.code.math').each do |el|
- el[STYLE_ATTRIBUTE] = 'display'
+ doc.css("pre.code.math").each do |el|
+ el[STYLE_ATTRIBUTE] = "display"
el[:class] += " #{TAG_CLASS}"
end
diff --git a/lib/banzai/filter/merge_request_reference_filter.rb b/lib/banzai/filter/merge_request_reference_filter.rb
index 7098767b583..87388f5bfd7 100644
--- a/lib/banzai/filter/merge_request_reference_filter.rb
+++ b/lib/banzai/filter/merge_request_reference_filter.rb
@@ -16,7 +16,7 @@ module Banzai
def url_for_object(mr, project)
h = Gitlab::Routing.url_helpers
h.project_merge_request_url(project, mr,
- only_path: context[:only_path])
+ only_path: context[:only_path])
end
def object_link_title(object, matches)
@@ -36,11 +36,11 @@ module Banzai
path = matches[:path] if matches.names.include?("path")
case path
- when '/diffs'
+ when "/diffs"
extras.unshift "diffs"
- when '/commits'
+ when "/commits"
extras.unshift "commits"
- when '/builds'
+ when "/builds"
extras.unshift "builds"
end
@@ -64,12 +64,12 @@ module Banzai
end
def object_link_commit(object, matches)
- return unless matches.names.include?('query') && query = matches[:query]
+ return unless matches.names.include?("query") && query = matches[:query]
# Removes leading "?". CGI.parse expects "arg1&arg2&arg3"
- params = CGI.parse(query.sub(/^\?/, ''))
+ params = CGI.parse(query.sub(/^\?/, ""))
- return unless commit_sha = params['commit_id']&.first
+ return unless commit_sha = params["commit_id"]&.first
if commit = find_commit_by_sha(object, commit_sha)
Commit.from_hash(commit.to_hash, object.project)
diff --git a/lib/banzai/filter/mermaid_filter.rb b/lib/banzai/filter/mermaid_filter.rb
index f0adb83af8a..1bffa87b302 100644
--- a/lib/banzai/filter/mermaid_filter.rb
+++ b/lib/banzai/filter/mermaid_filter.rb
@@ -5,7 +5,7 @@ module Banzai
module Filter
class MermaidFilter < HTML::Pipeline::Filter
def call
- doc.css('pre[lang="mermaid"] > code').add_class('js-render-mermaid')
+ doc.css('pre[lang="mermaid"] > code').add_class("js-render-mermaid")
doc
end
diff --git a/lib/banzai/filter/milestone_reference_filter.rb b/lib/banzai/filter/milestone_reference_filter.rb
index fce042e8946..8cb2712527c 100644
--- a/lib/banzai/filter/milestone_reference_filter.rb
+++ b/lib/banzai/filter/milestone_reference_filter.rb
@@ -77,9 +77,9 @@ module Banzai
def milestone_params(iid, name)
if name
- { name: name.tr('"', '') }
+ {name: name.tr('"', "")}
else
- { iid: iid.to_i }
+ {iid: iid.to_i}
end
end
@@ -90,7 +90,7 @@ module Banzai
end
def milestone_finder_params(parent, find_by_iid)
- { order: nil, state: 'all' }.tap do |params|
+ {order: nil, state: "all"}.tap do |params|
params[:project_ids] = parent.id if project_context?(parent)
# We don't support IID lookups because IIDs can clash between
diff --git a/lib/banzai/filter/plantuml_filter.rb b/lib/banzai/filter/plantuml_filter.rb
index caba8955bac..c0efa11d420 100644
--- a/lib/banzai/filter/plantuml_filter.rb
+++ b/lib/banzai/filter/plantuml_filter.rb
@@ -15,7 +15,8 @@ module Banzai
doc.css('pre > code[lang="plantuml"]').each do |node|
img_tag = Nokogiri::HTML::DocumentFragment.parse(
- Asciidoctor::PlantUml::Processor.plantuml_content(node.content, {}))
+ Asciidoctor::PlantUml::Processor.plantuml_content(node.content, {})
+ )
node.parent.replace(img_tag)
end
diff --git a/lib/banzai/filter/project_reference_filter.rb b/lib/banzai/filter/project_reference_filter.rb
index 83cf45097ed..5f8e9ad729d 100644
--- a/lib/banzai/filter/project_reference_filter.rb
+++ b/lib/banzai/filter/project_reference_filter.rb
@@ -34,7 +34,7 @@ module Banzai
end
elsif element_node?(node)
yield_valid_link(node) do |link, inner_html|
- if link =~ ref_pattern_start
+ if link&.match?(ref_pattern_start)
replace_link_node_with_href(node, link) do
project_link_filter(link, link_content: inner_html)
end
@@ -73,9 +73,9 @@ module Banzai
# corresponding Project objects.
def projects_hash
@projects ||= Project.eager_load(:route, namespace: [:route])
- .where_full_path_in(projects)
- .index_by(&:full_path)
- .transform_keys(&:downcase)
+ .where_full_path_in(projects)
+ .index_by(&:full_path)
+ .transform_keys(&:downcase)
end
# Returns all projects referenced in the current document.
diff --git a/lib/banzai/filter/reference_filter.rb b/lib/banzai/filter/reference_filter.rb
index 42f9b3a689c..f9670ae442a 100644
--- a/lib/banzai/filter/reference_filter.rb
+++ b/lib/banzai/filter/reference_filter.rb
@@ -35,12 +35,12 @@ module Banzai
attributes = attributes.reject { |_, v| v.nil? }
attributes[:reference_type] ||= self.class.reference_type
- attributes[:container] ||= 'body'
- attributes[:placement] ||= 'bottom'
+ attributes[:container] ||= "body"
+ attributes[:placement] ||= "bottom"
attributes.delete(:original) if context[:no_original_data]
- attributes.map do |key, value|
- %Q(data-#{key.to_s.dasherize}="#{escape_once(value)}")
- end.join(' ')
+ attributes.map { |key, value|
+ %(data-#{key.to_s.dasherize}="#{escape_once(value)}")
+ }.join(" ")
end
def escape_once(html)
@@ -49,10 +49,10 @@ module Banzai
def ignore_ancestor_query
@ignore_ancestor_query ||= begin
- parents = %w(pre code a style)
- parents << 'blockquote' if context[:ignore_blockquotes]
+ parents = %w[pre code a style]
+ parents << "blockquote" if context[:ignore_blockquotes]
- parents.map { |n| "ancestor::#{n}" }.join(' or ')
+ parents.map { |n| "ancestor::#{n}" }.join(" or ")
end
end
@@ -91,7 +91,7 @@ module Banzai
def each_node
return to_enum(__method__) unless block_given?
- query = %Q{descendant-or-self::text()[not(#{ignore_ancestor_query})]
+ query = %{descendant-or-self::text()[not(#{ignore_ancestor_query})]
| descendant-or-self::a[
not(contains(concat(" ", @class, " "), " gfm ")) and not(@href = "")
]}
@@ -108,10 +108,10 @@ module Banzai
# Yields the link's URL and inner HTML whenever the node is a valid <a> tag.
def yield_valid_link(node)
- link = CGI.unescape(node.attr('href').to_s)
+ link = CGI.unescape(node.attr("href").to_s)
inner_html = node.inner_html
- return unless link.force_encoding('UTF-8').valid_encoding?
+ return unless link.force_encoding("UTF-8").valid_encoding?
yield link, inner_html
end
diff --git a/lib/banzai/filter/relative_link_filter.rb b/lib/banzai/filter/relative_link_filter.rb
index 2745905c5ff..740babe76be 100644
--- a/lib/banzai/filter/relative_link_filter.rb
+++ b/lib/banzai/filter/relative_link_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
module Banzai
module Filter
@@ -20,13 +20,13 @@ module Banzai
@uri_types = {}
clear_memoization(:linkable_files)
- doc.search('a:not(.gfm)').each do |el|
- process_link_attr el.attribute('href')
+ doc.search("a:not(.gfm)").each do |el|
+ process_link_attr el.attribute("href")
end
- doc.css('img, video').each do |el|
- process_link_attr el.attribute('src')
- process_link_attr el.attribute('data-src')
+ doc.css("img, video").each do |el|
+ process_link_attr el.attribute("src")
+ process_link_attr el.attribute("data-src")
end
doc
@@ -42,9 +42,9 @@ module Banzai
def process_link_attr(html_attr)
return if html_attr.blank?
- return if html_attr.value.start_with?('//')
+ return if html_attr.value.start_with?("//")
- if html_attr.value.start_with?('/uploads/')
+ if html_attr.value.start_with?("/uploads/")
process_link_to_upload_attr(html_attr)
elsif linkable_files?
process_link_to_repository_attr(html_attr)
@@ -55,7 +55,7 @@ module Banzai
path_parts = [Addressable::URI.unescape(html_attr.value)]
if group
- path_parts.unshift(relative_url_root, 'groups', group.full_path, '-')
+ path_parts.unshift(relative_url_root, "groups", group.full_path, "-")
elsif project
path_parts.unshift(relative_url_root, project.full_path)
else
@@ -92,9 +92,9 @@ module Banzai
relative_url_root,
project.full_path,
uri_type(file_path),
- Addressable::URI.escape(ref).gsub('#', '%23'),
- Addressable::URI.escape(file_path)
- ].compact.join('/').squeeze('/').chomp('/')
+ Addressable::URI.escape(ref).gsub("#", "%23"),
+ Addressable::URI.escape(file_path),
+ ].compact.join("/").squeeze("/").chomp("/")
uri
end
@@ -130,19 +130,19 @@ module Banzai
def build_relative_path(path, request_path)
return request_path if path.empty?
return path unless request_path
- return path[1..-1] if path.start_with?('/')
+ return path[1..-1] if path.start_with?("/")
- parts = request_path.split('/')
+ parts = request_path.split("/")
parts.pop if uri_type(request_path) != :tree
- path.sub!(%r{\A\./}, '')
+ path.sub!(%r{\A\./}, "")
- while path.start_with?('../')
+ while path.start_with?("../")
parts.pop
- path.sub!('../', '')
+ path.sub!("../", "")
end
- parts.push(path).join('/')
+ parts.push(path).join("/")
end
def file_exists?(path)
@@ -161,7 +161,7 @@ module Banzai
end
def relative_url_root
- Gitlab.config.gitlab.relative_url_root.presence || '/'
+ Gitlab.config.gitlab.relative_url_root.presence || "/"
end
def ref
diff --git a/lib/banzai/filter/sanitization_filter.rb b/lib/banzai/filter/sanitization_filter.rb
index a4a06eae7b7..652290c9f68 100644
--- a/lib/banzai/filter/sanitization_filter.rb
+++ b/lib/banzai/filter/sanitization_filter.rb
@@ -8,7 +8,7 @@ module Banzai
class SanitizationFilter < HTML::Pipeline::SanitizationFilter
include Gitlab::Utils::StrongMemoize
- UNSAFE_PROTOCOLS = %w(data javascript vbscript).freeze
+ UNSAFE_PROTOCOLS = %w[data javascript vbscript].freeze
TABLE_ALIGNMENT_PATTERN = /text-align: (?<alignment>center|left|right)/.freeze
def whitelist
@@ -22,35 +22,35 @@ module Banzai
def customize_whitelist(whitelist)
# Allow table alignment; we whitelist specific text-align values in a
# transformer below
- whitelist[:attributes]['th'] = %w(style)
- whitelist[:attributes]['td'] = %w(style)
- whitelist[:css] = { properties: ['text-align'] }
+ whitelist[:attributes]["th"] = %w[style]
+ whitelist[:attributes]["td"] = %w[style]
+ whitelist[:css] = {properties: ["text-align"]}
# Allow span elements
- whitelist[:elements].push('span')
+ whitelist[:elements].push("span")
# Allow data-math-style attribute in order to support LaTeX formatting
- whitelist[:attributes]['code'] = %w(data-math-style)
- whitelist[:attributes]['pre'] = %w(data-math-style)
+ whitelist[:attributes]["code"] = %w[data-math-style]
+ whitelist[:attributes]["pre"] = %w[data-math-style]
# Allow html5 details/summary elements
- whitelist[:elements].push('details')
- whitelist[:elements].push('summary')
+ whitelist[:elements].push("details")
+ whitelist[:elements].push("summary")
# Allow abbr elements with title attribute
- whitelist[:elements].push('abbr')
- whitelist[:attributes]['abbr'] = %w(title)
+ whitelist[:elements].push("abbr")
+ whitelist[:attributes]["abbr"] = %w[title]
# Allow the 'data-sourcepos' from CommonMark on all elements
- whitelist[:attributes][:all].push('data-sourcepos')
+ whitelist[:attributes][:all].push("data-sourcepos")
# Disallow `name` attribute globally, allow on `a`
- whitelist[:attributes][:all].delete('name')
- whitelist[:attributes]['a'].push('name')
+ whitelist[:attributes][:all].delete("name")
+ whitelist[:attributes]["a"].push("name")
# Allow any protocol in `a` elements
# and then remove links with unsafe protocols
- whitelist[:protocols].delete('a')
+ whitelist[:protocols].delete("a")
whitelist[:transformers].push(self.class.remove_unsafe_links)
# Remove `rel` attribute from `a` elements
@@ -61,8 +61,8 @@ module Banzai
# Allow `id` in a and li elements for footnotes
# and remove any `id` properties not matching for footnotes
- whitelist[:attributes]['a'].push('id')
- whitelist[:attributes]['li'] = %w(id)
+ whitelist[:attributes]["a"].push("id")
+ whitelist[:attributes]["li"] = %w[id]
whitelist[:transformers].push(self.class.remove_non_footnote_ids)
whitelist
@@ -73,12 +73,12 @@ module Banzai
lambda do |env|
node = env[:node]
- return unless node.name == 'a'
- return unless node.has_attribute?('href')
+ return unless node.name == "a"
+ return unless node.has_attribute?("href")
begin
- node['href'] = node['href'].strip
- uri = Addressable::URI.parse(node['href'])
+ node["href"] = node["href"].strip
+ uri = Addressable::URI.parse(node["href"])
return unless uri.scheme
@@ -89,19 +89,19 @@ module Banzai
scheme = uri.scheme
.strip
.downcase
- .gsub(/[^A-Za-z0-9\+\.\-]+/, '')
+ .gsub(/[^A-Za-z0-9\+\.\-]+/, "")
- node.remove_attribute('href') if UNSAFE_PROTOCOLS.include?(scheme)
+ node.remove_attribute("href") if UNSAFE_PROTOCOLS.include?(scheme)
rescue Addressable::URI::InvalidURIError
- node.remove_attribute('href')
+ node.remove_attribute("href")
end
end
end
def remove_rel
lambda do |env|
- if env[:node_name] == 'a'
- env[:node].remove_attribute('rel')
+ if env[:node_name] == "a"
+ env[:node].remove_attribute("rel")
end
end
end
@@ -110,13 +110,13 @@ module Banzai
lambda do |env|
node = env[:node]
- return unless node.name == 'th' || node.name == 'td'
- return unless node.has_attribute?('style')
+ return unless node.name == "th" || node.name == "td"
+ return unless node.has_attribute?("style")
- if node['style'] =~ TABLE_ALIGNMENT_PATTERN
- node['style'] = "text-align: #{$~[:alignment]}"
+ if node["style"] =~ TABLE_ALIGNMENT_PATTERN
+ node["style"] = "text-align: #{$~[:alignment]}"
else
- node.remove_attribute('style')
+ node.remove_attribute("style")
end
end
end
@@ -125,13 +125,13 @@ module Banzai
lambda do |env|
node = env[:node]
- return unless node.name == 'a' || node.name == 'li'
- return unless node.has_attribute?('id')
+ return unless node.name == "a" || node.name == "li"
+ return unless node.has_attribute?("id")
- return if node.name == 'a' && node['id'] =~ Banzai::Filter::FootnoteFilter::FOOTNOTE_LINK_REFERENCE_PATTERN
- return if node.name == 'li' && node['id'] =~ Banzai::Filter::FootnoteFilter::FOOTNOTE_LI_REFERENCE_PATTERN
+ return if node.name == "a" && node["id"] =~ Banzai::Filter::FootnoteFilter::FOOTNOTE_LINK_REFERENCE_PATTERN
+ return if node.name == "li" && node["id"] =~ Banzai::Filter::FootnoteFilter::FOOTNOTE_LI_REFERENCE_PATTERN
- node.remove_attribute('id')
+ node.remove_attribute("id")
end
end
end
diff --git a/lib/banzai/filter/set_direction_filter.rb b/lib/banzai/filter/set_direction_filter.rb
index 45b259a2faf..79c15a0ebef 100644
--- a/lib/banzai/filter/set_direction_filter.rb
+++ b/lib/banzai/filter/set_direction_filter.rb
@@ -7,7 +7,7 @@ module Banzai
def call
# select these elements just on top level of the document
doc.xpath('p|h1|h2|h3|h4|h5|h6|ol|ul[not(@class="section-nav")]|blockquote|table').each do |el|
- el['dir'] = 'auto'
+ el["dir"] = "auto"
end
doc
diff --git a/lib/banzai/filter/snippet_reference_filter.rb b/lib/banzai/filter/snippet_reference_filter.rb
index f4b6edb6174..7465c447c8d 100644
--- a/lib/banzai/filter/snippet_reference_filter.rb
+++ b/lib/banzai/filter/snippet_reference_filter.rb
@@ -22,7 +22,7 @@ module Banzai
def url_for_object(snippet, project)
h = Gitlab::Routing.url_helpers
h.project_snippet_url(project, snippet,
- only_path: context[:only_path])
+ only_path: context[:only_path])
end
end
end
diff --git a/lib/banzai/filter/spaced_link_filter.rb b/lib/banzai/filter/spaced_link_filter.rb
index 50bf823929c..dcf83f77641 100644
--- a/lib/banzai/filter/spaced_link_filter.rb
+++ b/lib/banzai/filter/spaced_link_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
module Banzai
module Filter
@@ -36,13 +36,13 @@ module Banzai
}x
# Text matching LINK_OR_IMAGE_PATTERN inside these elements will not be linked
- IGNORE_PARENTS = %w(a code kbd pre script style).to_set
+ IGNORE_PARENTS = %w[a code kbd pre script style].to_set
# The XPath query to use for finding text nodes to parse.
- TEXT_QUERY = %Q(descendant-or-self::text()[
- not(#{IGNORE_PARENTS.map { |p| "ancestor::#{p}" }.join(' or ')})
+ TEXT_QUERY = %(descendant-or-self::text()[
+ not(#{IGNORE_PARENTS.map { |p| "ancestor::#{p}" }.join(" or ")})
and contains(., ']\(')
- ]).freeze
+ ])
def call
doc.xpath(TEXT_QUERY).each do |node|
@@ -71,7 +71,7 @@ module Banzai
html = Banzai::Filter::MarkdownFilter.call(transform_markdown(match), context)
# link is wrapped in a <p>, so strip that off
- p_node = Nokogiri::HTML.fragment(html).at_css('p')
+ p_node = Nokogiri::HTML.fragment(html).at_css("p")
p_node ? p_node.children.to_html : html
end
@@ -91,8 +91,8 @@ module Banzai
[
match[:preview_operator],
match[:text],
- match[:new_link].gsub(' ', '%20'),
- match[:title]
+ match[:new_link].gsub(" ", "%20"),
+ match[:title],
]
end
end
diff --git a/lib/banzai/filter/suggestion_filter.rb b/lib/banzai/filter/suggestion_filter.rb
index 9950db373d8..4c9b0ab4f56 100644
--- a/lib/banzai/filter/suggestion_filter.rb
+++ b/lib/banzai/filter/suggestion_filter.rb
@@ -5,12 +5,12 @@ module Banzai
module Filter
class SuggestionFilter < HTML::Pipeline::Filter
# Class used for tagging elements that should be rendered
- TAG_CLASS = 'js-render-suggestion'.freeze
+ TAG_CLASS = "js-render-suggestion"
def call
return doc unless suggestions_filter_enabled?
- doc.search('pre.suggestion > code').each do |node|
+ doc.search("pre.suggestion > code").each do |node|
node.add_class(TAG_CLASS)
end
diff --git a/lib/banzai/filter/syntax_highlight_filter.rb b/lib/banzai/filter/syntax_highlight_filter.rb
index 9ffde52b5f2..9faea6fa59c 100644
--- a/lib/banzai/filter/syntax_highlight_filter.rb
+++ b/lib/banzai/filter/syntax_highlight_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'rouge/plugins/common_mark'
+require "rouge/plugins/common_mark"
# Generated HTML is transformed back to GFM by app/assets/javascripts/behaviors/markdown/nodes/code_block.js
module Banzai
@@ -9,7 +9,7 @@ module Banzai
#
class SyntaxHighlightFilter < HTML::Pipeline::Filter
def call
- doc.search('pre > code').each do |node|
+ doc.search("pre > code").each do |node|
highlight_node(node)
end
@@ -17,8 +17,8 @@ module Banzai
end
def highlight_node(node)
- css_classes = +'code highlight js-syntax-highlight'
- lang = node.attr('lang')
+ css_classes = +"code highlight js-syntax-highlight"
+ lang = node.attr("lang")
retried = false
if use_rouge?(lang)
@@ -69,7 +69,7 @@ module Banzai
end
def use_rouge?(language)
- %w(math mermaid plantuml suggestion).exclude?(language)
+ %w[math mermaid plantuml suggestion].exclude?(language)
end
end
end
diff --git a/lib/banzai/filter/table_of_contents_filter.rb b/lib/banzai/filter/table_of_contents_filter.rb
index f2ae17b44fa..9fca8afd0b4 100644
--- a/lib/banzai/filter/table_of_contents_filter.rb
+++ b/lib/banzai/filter/table_of_contents_filter.rb
@@ -27,17 +27,17 @@ module Banzai
headers = Hash.new(0)
header_root = current_header = HeaderNode.new
- doc.css('h1, h2, h3, h4, h5, h6').each do |node|
+ doc.css("h1, h2, h3, h4, h5, h6").each do |node|
if header_content = node.children.first
id = node
.text
.downcase
- .gsub(PUNCTUATION_REGEXP, '') # remove punctuation
- .tr(' ', '-') # replace spaces with dash
- .squeeze('-') # replace multiple dashes with one
+ .gsub(PUNCTUATION_REGEXP, "") # remove punctuation
+ .tr(" ", "-") # replace spaces with dash
+ .squeeze("-") # replace multiple dashes with one
.gsub(/\A(\d+)\z/, 'anchor-\1') # digits-only hrefs conflict with issue refs
- uniq = headers[id] > 0 ? "-#{headers[id]}" : ''
+ uniq = headers[id] > 0 ? "-#{headers[id]}" : ""
headers[id] += 1
href = "#{id}#{uniq}"
@@ -55,7 +55,7 @@ module Banzai
private
def anchor_tag(href)
- %Q{<a id="user-content-#{href}" class="anchor" href="##{href}" aria-hidden="true"></a>}
+ %(<a id="user-content-#{href}" class="anchor" href="##{href}" aria-hidden="true"></a>)
end
def push_toc(children, root: false)
@@ -65,13 +65,13 @@ module Banzai
result[:toc] << "<ul#{klass}>"
children.each { |child| push_anchor(child) }
- result[:toc] << '</ul>'
+ result[:toc] << "</ul>"
end
def push_anchor(header_node)
- result[:toc] << %Q{<li><a href="##{header_node.href}">#{header_node.text}</a>}
+ result[:toc] << %(<li><a href="##{header_node.href}">#{header_node.text}</a>)
push_toc(header_node.children)
- result[:toc] << '</li>'
+ result[:toc] << "</li>"
end
class HeaderNode
@@ -83,7 +83,7 @@ module Banzai
@children = []
@parent = find_parent(previous_header)
- @parent.children.push(self) if @parent
+ @parent&.children&.push(self)
end
def level
@@ -93,7 +93,7 @@ module Banzai
end
def text
- return '' unless node
+ return "" unless node
@text ||= EscapeUtils.escape_html(node.text)
end
diff --git a/lib/banzai/filter/task_list_filter.rb b/lib/banzai/filter/task_list_filter.rb
index c6b402575cb..ce1561de1f4 100644
--- a/lib/banzai/filter/task_list_filter.rb
+++ b/lib/banzai/filter/task_list_filter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'task_list/filter'
+require "task_list/filter"
# Generated HTML is transformed back to GFM by:
# - app/assets/javascripts/behaviors/markdown/nodes/ordered_task_list.js
diff --git a/lib/banzai/filter/user_reference_filter.rb b/lib/banzai/filter/user_reference_filter.rb
index 8cda67867a8..576bbdbd2cc 100644
--- a/lib/banzai/filter/user_reference_filter.rb
+++ b/lib/banzai/filter/user_reference_filter.rb
@@ -38,7 +38,7 @@ module Banzai
end
elsif element_node?(node)
yield_valid_link(node) do |link, inner_html|
- if link =~ ref_pattern_start
+ if link&.match?(ref_pattern_start)
replace_link_node_with_href(node, link) do
user_link_filter(link, link_content: inner_html)
end
@@ -60,7 +60,7 @@ module Banzai
# have `gfm` and `gfm-project_member` class names attached for styling.
def user_link_filter(text, link_content: nil)
self.class.references_in(text) do |match, username|
- if username == 'all' && !skip_project_check?
+ if username == "all" && !skip_project_check?
link_to_all(link_content: link_content)
else
cached_call(:banzai_url_for_object, match, path: [User, username.downcase]) do
@@ -81,9 +81,9 @@ module Banzai
# corresponding Namespace objects.
def namespaces
@namespaces ||= Namespace.eager_load(:owner, :route)
- .where_full_path_in(usernames)
- .index_by(&:full_path)
- .transform_keys(&:downcase)
+ .where_full_path_in(usernames)
+ .index_by(&:full_path)
+ .transform_keys(&:downcase)
end
# Returns all usernames referenced in the current document.
@@ -172,8 +172,8 @@ module Banzai
data = data_attribute(project: project.id, author: author.try(:id))
end
- content = link_content || User.reference_prefix + 'all'
- link_tag(url, data, content, 'All Project and Group Members')
+ content = link_content || User.reference_prefix + "all"
+ link_tag(url, data, content, "All Project and Group Members")
end
end
end
diff --git a/lib/banzai/filter/video_link_filter.rb b/lib/banzai/filter/video_link_filter.rb
index 0fff104cf91..b7c32ea741e 100644
--- a/lib/banzai/filter/video_link_filter.rb
+++ b/lib/banzai/filter/video_link_filter.rb
@@ -19,36 +19,38 @@ module Banzai
def query
@query ||= begin
- src_query = UploaderHelper::VIDEO_EXT.map do |ext|
+ src_query = UploaderHelper::VIDEO_EXT.map { |ext|
"'.#{ext}' = substring(@src, string-length(@src) - #{ext.size})"
- end
+ }
- "descendant-or-self::img[not(ancestor::a) and (#{src_query.join(' or ')})]"
+ "descendant-or-self::img[not(ancestor::a) and (#{src_query.join(" or ")})]"
end
end
def video_node(doc, element)
container = doc.document.create_element(
- 'div',
- class: 'video-container'
+ "div",
+ class: "video-container"
)
video = doc.document.create_element(
- 'video',
- src: element['src'],
- width: '400',
- controls: true,
- 'data-setup' => '{}',
- 'data-title' => element['title'] || element['alt'])
+ "video",
+ :src => element["src"],
+ :width => "400",
+ :controls => true,
+ "data-setup" => "{}",
+ "data-title" => element["title"] || element["alt"]
+ )
link = doc.document.create_element(
- 'a',
- element['title'] || element['alt'],
- href: element['src'],
- target: '_blank',
- rel: 'noopener noreferrer',
- title: "Download '#{element['title'] || element['alt']}'")
- download_paragraph = doc.document.create_element('p')
+ "a",
+ element["title"] || element["alt"],
+ href: element["src"],
+ target: "_blank",
+ rel: "noopener noreferrer",
+ title: "Download '#{element["title"] || element["alt"]}'"
+ )
+ download_paragraph = doc.document.create_element("p")
download_paragraph.children = link
container.add_child(video)
diff --git a/lib/banzai/filter/wiki_link_filter.rb b/lib/banzai/filter/wiki_link_filter.rb
index 1728a442533..b3004476a8f 100644
--- a/lib/banzai/filter/wiki_link_filter.rb
+++ b/lib/banzai/filter/wiki_link_filter.rb
@@ -11,10 +11,10 @@ module Banzai
def call
return doc unless project_wiki?
- doc.search('a:not(.gfm)').each { |el| process_link_attr(el.attribute('href')) }
- doc.search('video').each { |el| process_link_attr(el.attribute('src')) }
- doc.search('img').each do |el|
- attr = el.attribute('data-src') || el.attribute('src')
+ doc.search("a:not(.gfm)").each { |el| process_link_attr(el.attribute("href")) }
+ doc.search("video").each { |el| process_link_attr(el.attribute("src")) }
+ doc.search("img").each do |el|
+ attr = el.attribute("data-src") || el.attribute("src")
process_link_attr(attr)
end
diff --git a/lib/banzai/filter/wiki_link_filter/rewriter.rb b/lib/banzai/filter/wiki_link_filter/rewriter.rb
index f4cc8beeb52..cd6376f14a9 100644
--- a/lib/banzai/filter/wiki_link_filter/rewriter.rb
+++ b/lib/banzai/filter/wiki_link_filter/rewriter.rb
@@ -6,7 +6,7 @@ module Banzai
class Rewriter
def initialize(link_string, wiki:, slug:)
@uri = Addressable::URI.parse(link_string)
- @wiki_base_path = wiki && wiki.wiki_base_path
+ @wiki_base_path = wiki&.wiki_base_path
@slug = slug
end
@@ -35,7 +35,7 @@ module Banzai
# Of the form `./link`, `../link`, or similar
def apply_hierarchical_link_rules!
- @uri = Addressable::URI.join(@slug, @uri) if @uri.to_s[0] == '.'
+ @uri = Addressable::URI.join(@slug, @uri) if @uri.to_s[0] == "."
end
# Any link _not_ of the form `http://example.com/`
@@ -48,7 +48,7 @@ module Banzai
end
def public_upload?
- @uri.relative? && @uri.path.starts_with?('/uploads/')
+ @uri.relative? && @uri.path.starts_with?("/uploads/")
end
def repository_upload?
diff --git a/lib/banzai/issuable_extractor.rb b/lib/banzai/issuable_extractor.rb
index 341dbb74fe0..c0c9d51668b 100644
--- a/lib/banzai/issuable_extractor.rb
+++ b/lib/banzai/issuable_extractor.rb
@@ -11,8 +11,8 @@ module Banzai
class IssuableExtractor
attr_reader :context
- ISSUE_REFERENCE_TYPE = '@data-reference-type="issue"'.freeze
- MERGE_REQUEST_REFERENCE_TYPE = '@data-reference-type="merge_request"'.freeze
+ ISSUE_REFERENCE_TYPE = '@data-reference-type="issue"'
+ MERGE_REQUEST_REFERENCE_TYPE = '@data-reference-type="merge_request"'
# context - An instance of Banzai::RenderContext.
def initialize(context)
@@ -21,9 +21,9 @@ module Banzai
# Returns Hash in the form { node => issuable_instance }
def extract(documents)
- nodes = documents.flat_map do |document|
+ nodes = documents.flat_map { |document|
document.xpath(query)
- end
+ }
# The project or group for the issuable might be pending for deletion!
# Filter them out because we don't care about them.
@@ -41,14 +41,14 @@ module Banzai
def parsers
[
Banzai::ReferenceParser::IssueParser.new(context),
- Banzai::ReferenceParser::MergeRequestParser.new(context)
+ Banzai::ReferenceParser::MergeRequestParser.new(context),
]
end
def query
- %Q(
+ %(
descendant-or-self::a[contains(concat(" ", @class, " "), " gfm ")]
- [#{reference_types.join(' or ')}]
+ [#{reference_types.join(" or ")}]
)
end
diff --git a/lib/banzai/object_renderer.rb b/lib/banzai/object_renderer.rb
index 75661ffa233..4a520567ac5 100644
--- a/lib/banzai/object_renderer.rb
+++ b/lib/banzai/object_renderer.rb
@@ -87,14 +87,14 @@ module Banzai
def base_context
{
current_user: context.current_user,
- skip_redaction: true
+ skip_redaction: true,
}
end
def save_options
return {} unless @redaction_context[:xhtml]
- { save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML }
+ {save_with: Nokogiri::XML::Node::SaveOptions::AS_XHTML}
end
end
end
diff --git a/lib/banzai/pipeline/base_pipeline.rb b/lib/banzai/pipeline/base_pipeline.rb
index 87d1cf9912f..249b332be78 100644
--- a/lib/banzai/pipeline/base_pipeline.rb
+++ b/lib/banzai/pipeline/base_pipeline.rb
@@ -16,7 +16,7 @@ module Banzai
end
class << self
- %i(call to_document to_html).each do |meth|
+ %i[call to_document to_html].each do |meth|
define_method(meth) do |text, context|
context = transform_context(context)
diff --git a/lib/banzai/pipeline/broadcast_message_pipeline.rb b/lib/banzai/pipeline/broadcast_message_pipeline.rb
index 580b5b72474..b293ad8c4c6 100644
--- a/lib/banzai/pipeline/broadcast_message_pipeline.rb
+++ b/lib/banzai/pipeline/broadcast_message_pipeline.rb
@@ -7,7 +7,6 @@ module Banzai
@filters ||= FilterArray[
Filter::MarkdownFilter,
Filter::SanitizationFilter,
-
Filter::EmojiFilter,
Filter::ColorFilter,
Filter::AutolinkFilter,
diff --git a/lib/banzai/pipeline/description_pipeline.rb b/lib/banzai/pipeline/description_pipeline.rb
index d5ff9b025cc..8d5fe7fd6c2 100644
--- a/lib/banzai/pipeline/description_pipeline.rb
+++ b/lib/banzai/pipeline/description_pipeline.rb
@@ -4,7 +4,7 @@ module Banzai
module Pipeline
class DescriptionPipeline < FullPipeline
WHITELIST = Banzai::Filter::SanitizationFilter::LIMITED.deep_dup.merge(
- elements: Banzai::Filter::SanitizationFilter::LIMITED[:elements] - %w(pre code img ol ul li)
+ elements: Banzai::Filter::SanitizationFilter::LIMITED[:elements] - %w[pre code img ol ul li]
)
def self.transform_context(context)
diff --git a/lib/banzai/pipeline/gfm_pipeline.rb b/lib/banzai/pipeline/gfm_pipeline.rb
index 30cafd11834..8ba0011eea4 100644
--- a/lib/banzai/pipeline/gfm_pipeline.rb
+++ b/lib/banzai/pipeline/gfm_pipeline.rb
@@ -12,13 +12,10 @@ module Banzai
def self.filters
@filters ||= FilterArray[
Filter::PlantumlFilter,
-
# Must always be before the SanitizationFilter to prevent XSS attacks
Filter::SpacedLinkFilter,
-
Filter::SanitizationFilter,
Filter::SyntaxHighlightFilter,
-
Filter::MathFilter,
Filter::ColorFilter,
Filter::MermaidFilter,
@@ -31,12 +28,9 @@ module Banzai
Filter::ExternalLinkFilter,
Filter::SuggestionFilter,
Filter::FootnoteFilter,
-
*reference_filters,
-
Filter::TaskListFilter,
Filter::InlineDiffFilter,
-
Filter::SetDirectionFilter
]
end
@@ -52,7 +46,7 @@ module Banzai
Filter::CommitRangeReferenceFilter,
Filter::CommitReferenceFilter,
Filter::LabelReferenceFilter,
- Filter::MilestoneReferenceFilter
+ Filter::MilestoneReferenceFilter,
]
end
diff --git a/lib/banzai/pipeline/post_process_pipeline.rb b/lib/banzai/pipeline/post_process_pipeline.rb
index 7eaad6d7560..471c4dac270 100644
--- a/lib/banzai/pipeline/post_process_pipeline.rb
+++ b/lib/banzai/pipeline/post_process_pipeline.rb
@@ -15,7 +15,7 @@ module Banzai
Filter::RedactorFilter,
Filter::RelativeLinkFilter,
Filter::IssuableStateFilter,
- Filter::SuggestionFilter
+ Filter::SuggestionFilter,
]
end
diff --git a/lib/banzai/pipeline/single_line_pipeline.rb b/lib/banzai/pipeline/single_line_pipeline.rb
index 72374207a8f..104a3b1b7ed 100644
--- a/lib/banzai/pipeline/single_line_pipeline.rb
+++ b/lib/banzai/pipeline/single_line_pipeline.rb
@@ -7,11 +7,9 @@ module Banzai
@filters ||= FilterArray[
Filter::HtmlEntityFilter,
Filter::SanitizationFilter,
-
Filter::EmojiFilter,
Filter::AutolinkFilter,
Filter::ExternalLinkFilter,
-
*reference_filters
]
end
@@ -24,7 +22,7 @@ module Banzai
Filter::MergeRequestReferenceFilter,
Filter::SnippetReferenceFilter,
Filter::CommitRangeReferenceFilter,
- Filter::CommitReferenceFilter
+ Filter::CommitReferenceFilter,
]
end
diff --git a/lib/banzai/pipeline/wiki_pipeline.rb b/lib/banzai/pipeline/wiki_pipeline.rb
index 97a03895ff3..22eaf854cf7 100644
--- a/lib/banzai/pipeline/wiki_pipeline.rb
+++ b/lib/banzai/pipeline/wiki_pipeline.rb
@@ -6,7 +6,7 @@ module Banzai
def self.filters
@filters ||= begin
super.insert_after(Filter::TableOfContentsFilter, Filter::GollumTagsFilter)
- .insert_before(Filter::TaskListFilter, Filter::WikiLinkFilter)
+ .insert_before(Filter::TaskListFilter, Filter::WikiLinkFilter)
end
end
end
diff --git a/lib/banzai/querying.rb b/lib/banzai/querying.rb
index 55aa5fa66c3..20136b86884 100644
--- a/lib/banzai/querying.rb
+++ b/lib/banzai/querying.rb
@@ -16,7 +16,7 @@ module Banzai
def css(document, query, reference_options = {})
# When using "a.foo" Nokogiri compiles this to "//a[...]" but
# "descendant::a[...]" is quite a bit faster and achieves the same result.
- xpath = Nokogiri::CSS.xpath_for(query)[0].gsub(%r{^//}, 'descendant::')
+ xpath = Nokogiri::CSS.xpath_for(query)[0].gsub(%r{^//}, "descendant::")
xpath = restrict_to_p_nodes_at_root(xpath) if filter_nodes_at_beginning?(reference_options)
nodes = document.xpath(xpath)
@@ -24,7 +24,7 @@ module Banzai
end
def restrict_to_p_nodes_at_root(xpath)
- xpath.gsub('descendant::', './p/')
+ xpath.gsub("descendant::", "./p/")
end
def filter_nodes(nodes, reference_options)
diff --git a/lib/banzai/redactor.rb b/lib/banzai/redactor.rb
index 7db5f5e1f7d..223d2c52596 100644
--- a/lib/banzai/redactor.rb
+++ b/lib/banzai/redactor.rb
@@ -41,9 +41,9 @@ module Banzai
nodes_for_document = entry[:nodes]
doc_data = {
- document: entry[:document],
- total_reference_count: nodes_for_document.count,
- visible_reference_count: nodes_for_document.count
+ document: entry[:document],
+ total_reference_count: nodes_for_document.count,
+ visible_reference_count: nodes_for_document.count,
}
metadata << doc_data
@@ -64,13 +64,13 @@ module Banzai
# the original content (text), or the inner HTML of the node.
#
def redacted_node_content(node)
- original_content = node.attr('data-original')
- link_reference = node.attr('data-link-reference')
+ original_content = node.attr("data-original")
+ link_reference = node.attr("data-link-reference")
# Build the raw <a> tag just with a link as href and content if
# it's originally a link pattern. We shouldn't return a plain text href.
original_link =
- if link_reference == 'true' && href = original_content
+ if link_reference == "true" && href = original_content
%(<a href="#{href}">#{href}</a>)
end
@@ -86,8 +86,8 @@ module Banzai
issuables.each do |node, issuable|
next if issuable.project == context.project_for_node(node)
- node['class'] = node['class'].gsub('has-tooltip', '')
- node['title'] = nil
+ node["class"] = node["class"].gsub("has-tooltip", "")
+ node["title"] = nil
end
end
@@ -101,7 +101,7 @@ module Banzai
visible = Set.new
nodes.each do |node|
- per_type[node.attr('data-reference-type')] << node
+ per_type[node.attr("data-reference-type")] << node
end
per_type.each do |type, nodes|
@@ -115,7 +115,7 @@ module Banzai
def document_nodes(documents)
documents.map do |document|
- { document: document, nodes: Querying.css(document, 'a.gfm[data-reference-type]') }
+ {document: document, nodes: Querying.css(document, "a.gfm[data-reference-type]")}
end
end
diff --git a/lib/banzai/reference_extractor.rb b/lib/banzai/reference_extractor.rb
index 3fc3ae02088..66a4375746d 100644
--- a/lib/banzai/reference_extractor.rb
+++ b/lib/banzai/reference_extractor.rb
@@ -8,7 +8,7 @@ module Banzai
end
def analyze(text, context = {})
- @texts_and_contexts << { text: text, context: context }
+ @texts_and_contexts << {text: text, context: context}
end
def references(type, project, current_user = nil)
diff --git a/lib/banzai/reference_parser/base_parser.rb b/lib/banzai/reference_parser/base_parser.rb
index 8419769085a..8523d08f434 100644
--- a/lib/banzai/reference_parser/base_parser.rb
+++ b/lib/banzai/reference_parser/base_parser.rb
@@ -64,7 +64,7 @@ module Banzai
# Returns all the nodes that are visible to the given user.
def nodes_visible_to_user(user, nodes)
projects = lazy { projects_for_nodes(nodes) }
- project_attr = 'data-project'
+ project_attr = "data-project"
nodes.select do |node|
if node.has_attribute?(project_attr)
@@ -108,7 +108,7 @@ module Banzai
per_project = Hash.new { |hash, key| hash[key] = Set.new }
nodes.each do |node|
- project_id = node.attr('data-project').to_i
+ project_id = node.attr("data-project").to_i
id = node.attr(attribute)
per_project[project_id] << id if id
@@ -194,9 +194,9 @@ module Banzai
type = self.class.reference_type
reference_options = self.class.reference_options
- nodes = documents.flat_map do |document|
+ nodes = documents.flat_map { |document|
Querying.css(document, "a[data-reference-type='#{type}'].gfm", reference_options).to_a
- end
+ }
gather_references(nodes)
end
@@ -217,7 +217,7 @@ module Banzai
#
def projects_for_nodes(nodes)
@projects_for_nodes ||=
- grouped_objects_for_nodes(nodes, Project.includes(:project_feature), 'data-project')
+ grouped_objects_for_nodes(nodes, Project.includes(:project_feature), "data-project")
end
def can?(user, permission, subject = :global)
@@ -250,9 +250,9 @@ module Banzai
end
def collection_cache
- Gitlab::SafeRequestStore[:banzai_collection_cache] ||= Hash.new do |hash, key|
+ Gitlab::SafeRequestStore[:banzai_collection_cache] ||= Hash.new { |hash, key|
hash[key] = {}
- end
+ }
end
end
end
diff --git a/lib/banzai/reference_parser/directly_addressed_user_parser.rb b/lib/banzai/reference_parser/directly_addressed_user_parser.rb
index 1f18f82b916..08faa0ac526 100644
--- a/lib/banzai/reference_parser/directly_addressed_user_parser.rb
+++ b/lib/banzai/reference_parser/directly_addressed_user_parser.rb
@@ -4,7 +4,7 @@ module Banzai
module ReferenceParser
class DirectlyAddressedUserParser < UserParser
self.reference_type = :user
- self.reference_options = { location: :beginning }
+ self.reference_options = {location: :beginning}
end
end
end
diff --git a/lib/banzai/reference_parser/issue_parser.rb b/lib/banzai/reference_parser/issue_parser.rb
index 97c7173ac0f..de6d319160f 100644
--- a/lib/banzai/reference_parser/issue_parser.rb
+++ b/lib/banzai/reference_parser/issue_parser.rb
@@ -67,13 +67,13 @@ module Banzai
# Eager loading these ensures we don't end up running dozens of
# queries in this process.
project: [
- { namespace: :owner },
- { group: [:owners, :group_members] },
+ {namespace: :owner},
+ {group: [:owners, :group_members]},
:invited_groups,
:project_members,
:project_feature,
- :route
- ]
+ :route,
+ ],
}
),
self.class.data_attribute
diff --git a/lib/banzai/reference_parser/merge_request_parser.rb b/lib/banzai/reference_parser/merge_request_parser.rb
index e8147ac591a..fea56520866 100644
--- a/lib/banzai/reference_parser/merge_request_parser.rb
+++ b/lib/banzai/reference_parser/merge_request_parser.rb
@@ -16,14 +16,15 @@ module Banzai
# Eager loading these ensures we don't end up running dozens of
# queries in this process.
target_project: [
- { namespace: [:owner, :route] },
- { group: [:owners, :group_members] },
+ {namespace: [:owner, :route]},
+ {group: [:owners, :group_members]},
:invited_groups,
:project_members,
:project_feature,
- :route
- ]
- }),
+ :route,
+ ],
+ }
+ ),
self.class.data_attribute
)
end
diff --git a/lib/banzai/reference_parser/user_parser.rb b/lib/banzai/reference_parser/user_parser.rb
index 067b06b7590..dcb9d95c029 100644
--- a/lib/banzai/reference_parser/user_parser.rb
+++ b/lib/banzai/reference_parser/user_parser.rb
@@ -11,12 +11,12 @@ module Banzai
project_ids = []
nodes.each do |node|
- if node.has_attribute?('data-group')
- group_ids << node.attr('data-group').to_i
+ if node.has_attribute?("data-group")
+ group_ids << node.attr("data-group").to_i
elsif node.has_attribute?(self.class.data_attribute)
user_ids << node.attr(self.class.data_attribute).to_i
- elsif node.has_attribute?('data-project')
- project_ids << node.attr('data-project').to_i
+ elsif node.has_attribute?("data-project")
+ project_ids << node.attr("data-project").to_i
end
end
@@ -25,7 +25,7 @@ module Banzai
end
def nodes_visible_to_user(user, nodes)
- group_attr = 'data-group'
+ group_attr = "data-group"
groups = lazy { grouped_objects_for_nodes(nodes, Group, group_attr) }
visible = []
remaining = []
@@ -58,14 +58,14 @@ module Banzai
end
def can_read_project_reference?(node)
- node_id = node.attr('data-project').to_i
+ node_id = node.attr("data-project").to_i
project_for_node(node)&.id == node_id
end
def nodes_user_can_reference(current_user, nodes)
- project_attr = 'data-project'
- author_attr = 'data-author'
+ project_attr = "data-project"
+ author_attr = "data-author"
projects = lazy { projects_for_nodes(nodes) }
users = lazy { grouped_objects_for_nodes(nodes, User, author_attr) }
@@ -97,7 +97,7 @@ module Banzai
def find_users_for_groups(ids)
return [] if ids.empty?
- User.joins(:group_members).where(members: { source_id: ids }).to_a
+ User.joins(:group_members).where(members: {source_id: ids}).to_a
end
def find_users_for_projects(ids)
diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb
index c7239a5eaa6..7179d273e76 100644
--- a/lib/banzai/renderer.rb
+++ b/lib/banzai/renderer.rb
@@ -90,10 +90,10 @@ module Banzai
unless cacheable_items.empty?
items_in_cache = Rails.cache.read_multi(*cacheable_items.map { |item| item[:cache_key] })
- items_not_in_cache = cacheable_items.reject do |item|
+ items_not_in_cache = cacheable_items.reject { |item|
item[:rendered] = items_in_cache[item[:cache_key]]
items_in_cache.key?(item[:cache_key])
- end
+ }
end
(items_not_in_cache + non_cacheable_items).each do |item|
diff --git a/lib/banzai/renderer/common_mark/html.rb b/lib/banzai/renderer/common_mark/html.rb
index 837665451a1..b0352d9b0e5 100644
--- a/lib/banzai/renderer/common_mark/html.rb
+++ b/lib/banzai/renderer/common_mark/html.rb
@@ -8,9 +8,9 @@ module Banzai
block do
out("<pre#{sourcepos(node)}><code")
out(' lang="', node.fence_info, '"') if node.fence_info.present?
- out('>')
+ out(">")
out(escape_html(node.string_content))
- out('</code></pre>')
+ out("</code></pre>")
end
end
end
diff --git a/lib/banzai/request_store_reference_cache.rb b/lib/banzai/request_store_reference_cache.rb
index 91fb489b72d..e0d90a731fe 100644
--- a/lib/banzai/request_store_reference_cache.rb
+++ b/lib/banzai/request_store_reference_cache.rb
@@ -4,9 +4,9 @@ module Banzai
module RequestStoreReferenceCache
def cached_call(request_store_key, cache_key, path: [])
if Gitlab::SafeRequestStore.active?
- cache = Gitlab::SafeRequestStore[request_store_key] ||= Hash.new do |hash, key|
+ cache = Gitlab::SafeRequestStore[request_store_key] ||= Hash.new { |hash, key|
hash[key] = Hash.new { |h, k| h[k] = {} }
- end
+ }
cache = cache.dig(*path) if path.any?
diff --git a/lib/banzai/suggestions_parser.rb b/lib/banzai/suggestions_parser.rb
index 09f36635020..82afc1c9c64 100644
--- a/lib/banzai/suggestions_parser.rb
+++ b/lib/banzai/suggestions_parser.rb
@@ -8,7 +8,7 @@ module Banzai
html = Banzai.render(text, project: nil, no_original_data: true)
doc = Nokogiri::HTML(html)
- doc.search('pre.suggestion').map { |node| node.text }
+ doc.search("pre.suggestion").map { |node| node.text }
end
end
end
diff --git a/lib/bitbucket/client.rb b/lib/bitbucket/client.rb
index 1343f424c51..4b928a7d32d 100644
--- a/lib/bitbucket/client.rb
+++ b/lib/bitbucket/client.rb
@@ -45,7 +45,7 @@ module Bitbucket
def user
@user ||= begin
- parsed_response = connection.get('/user')
+ parsed_response = connection.get("/user")
Representation::User.new(parsed_response)
end
end
diff --git a/lib/bitbucket/collection.rb b/lib/bitbucket/collection.rb
index 9c496daccaa..4e64a3f4616 100644
--- a/lib/bitbucket/collection.rb
+++ b/lib/bitbucket/collection.rb
@@ -13,9 +13,9 @@ module Bitbucket
end
def method_missing(method, *args)
- return super unless self.respond_to?(method)
+ return super unless respond_to?(method)
- self.__send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend
+ __send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend
block_given? ? yield(item) : item
end
end
diff --git a/lib/bitbucket/connection.rb b/lib/bitbucket/connection.rb
index 0041634f9e3..dd7f4e579f6 100644
--- a/lib/bitbucket/connection.rb
+++ b/lib/bitbucket/connection.rb
@@ -2,8 +2,8 @@
module Bitbucket
class Connection
- DEFAULT_API_VERSION = '2.0'.freeze
- DEFAULT_BASE_URI = 'https://api.bitbucket.org/'.freeze
+ DEFAULT_API_VERSION = "2.0"
+ DEFAULT_BASE_URI = "https://api.bitbucket.org/"
DEFAULT_QUERY = {}.freeze
attr_reader :expires_at, :expires_in, :refresh_token, :token
@@ -59,7 +59,7 @@ module Bitbucket
end
def provider
- Gitlab::Auth::OAuth::Provider.config_for('bitbucket')
+ Gitlab::Auth::OAuth::Provider.config_for("bitbucket")
end
def options
diff --git a/lib/bitbucket/page.rb b/lib/bitbucket/page.rb
index 7cc1342ad65..42bc81fc8d2 100644
--- a/lib/bitbucket/page.rb
+++ b/lib/bitbucket/page.rb
@@ -20,13 +20,13 @@ module Bitbucket
private
def parse_attrs(raw)
- raw.slice(*%w(size page pagelen next previous)).symbolize_keys
+ raw.slice("size", "page", "pagelen", "next", "previous").symbolize_keys
end
def parse_values(raw, bitbucket_rep_class)
- return [] unless raw['values'] && raw['values'].is_a?(Array)
+ return [] unless raw["values"]&.is_a?(Array)
- bitbucket_rep_class.decorate(raw['values'])
+ bitbucket_rep_class.decorate(raw["values"])
end
def representation_class(type)
diff --git a/lib/bitbucket/representation/comment.rb b/lib/bitbucket/representation/comment.rb
index 1b8dc27793a..9c1848738ba 100644
--- a/lib/bitbucket/representation/comment.rb
+++ b/lib/bitbucket/representation/comment.rb
@@ -4,25 +4,25 @@ module Bitbucket
module Representation
class Comment < Representation::Base
def author
- user['username']
+ user["username"]
end
def note
- raw.fetch('content', {}).fetch('raw', nil)
+ raw.fetch("content", {}).fetch("raw", nil)
end
def created_at
- raw['created_on']
+ raw["created_on"]
end
def updated_at
- raw['updated_on'] || raw['created_on']
+ raw["updated_on"] || raw["created_on"]
end
private
def user
- raw.fetch('user', {})
+ raw.fetch("user", {})
end
end
end
diff --git a/lib/bitbucket/representation/issue.rb b/lib/bitbucket/representation/issue.rb
index a88797cdab9..7c7a586f3bf 100644
--- a/lib/bitbucket/representation/issue.rb
+++ b/lib/bitbucket/representation/issue.rb
@@ -3,42 +3,42 @@
module Bitbucket
module Representation
class Issue < Representation::Base
- CLOSED_STATUS = %w(resolved invalid duplicate wontfix closed).freeze
+ CLOSED_STATUS = %w[resolved invalid duplicate wontfix closed].freeze
def iid
- raw['id']
+ raw["id"]
end
def kind
- raw['kind']
+ raw["kind"]
end
def author
- raw.dig('reporter', 'username')
+ raw.dig("reporter", "username")
end
def description
- raw.fetch('content', {}).fetch('raw', nil)
+ raw.fetch("content", {}).fetch("raw", nil)
end
def state
- closed? ? 'closed' : 'opened'
+ closed? ? "closed" : "opened"
end
def title
- raw['title']
+ raw["title"]
end
def milestone
- raw['milestone']['name'] if raw['milestone'].present?
+ raw["milestone"]["name"] if raw["milestone"].present?
end
def created_at
- raw['created_on']
+ raw["created_on"]
end
def updated_at
- raw['edited_on']
+ raw["edited_on"]
end
def to_s
@@ -48,7 +48,7 @@ module Bitbucket
private
def closed?
- CLOSED_STATUS.include?(raw['state'])
+ CLOSED_STATUS.include?(raw["state"])
end
end
end
diff --git a/lib/bitbucket/representation/pull_request.rb b/lib/bitbucket/representation/pull_request.rb
index 6a0e8b354bf..ecb8746da8d 100644
--- a/lib/bitbucket/representation/pull_request.rb
+++ b/lib/bitbucket/representation/pull_request.rb
@@ -4,63 +4,63 @@ module Bitbucket
module Representation
class PullRequest < Representation::Base
def author
- raw.fetch('author', {}).fetch('username', nil)
+ raw.fetch("author", {}).fetch("username", nil)
end
def description
- raw['description']
+ raw["description"]
end
def iid
- raw['id']
+ raw["id"]
end
def state
- if raw['state'] == 'MERGED'
- 'merged'
- elsif raw['state'] == 'DECLINED'
- 'closed'
+ if raw["state"] == "MERGED"
+ "merged"
+ elsif raw["state"] == "DECLINED"
+ "closed"
else
- 'opened'
+ "opened"
end
end
def created_at
- raw['created_on']
+ raw["created_on"]
end
def updated_at
- raw['updated_on']
+ raw["updated_on"]
end
def title
- raw['title']
+ raw["title"]
end
def source_branch_name
- source_branch.fetch('branch', {}).fetch('name', nil)
+ source_branch.fetch("branch", {}).fetch("name", nil)
end
def source_branch_sha
- source_branch.fetch('commit', {}).fetch('hash', nil)
+ source_branch.fetch("commit", {}).fetch("hash", nil)
end
def target_branch_name
- target_branch.fetch('branch', {}).fetch('name', nil)
+ target_branch.fetch("branch", {}).fetch("name", nil)
end
def target_branch_sha
- target_branch.fetch('commit', {}).fetch('hash', nil)
+ target_branch.fetch("commit", {}).fetch("hash", nil)
end
private
def source_branch
- raw['source']
+ raw["source"]
end
def target_branch
- raw['destination']
+ raw["destination"]
end
end
end
diff --git a/lib/bitbucket/representation/pull_request_comment.rb b/lib/bitbucket/representation/pull_request_comment.rb
index 34dbf9ad22d..7eb8ef6803f 100644
--- a/lib/bitbucket/representation/pull_request_comment.rb
+++ b/lib/bitbucket/representation/pull_request_comment.rb
@@ -4,37 +4,37 @@ module Bitbucket
module Representation
class PullRequestComment < Comment
def iid
- raw['id']
+ raw["id"]
end
def file_path
- inline.fetch('path')
+ inline.fetch("path")
end
def old_pos
- inline.fetch('from')
+ inline.fetch("from")
end
def new_pos
- inline.fetch('to')
+ inline.fetch("to")
end
def parent_id
- raw.fetch('parent', {}).fetch('id', nil)
+ raw.fetch("parent", {}).fetch("id", nil)
end
def inline?
- raw.key?('inline')
+ raw.key?("inline")
end
def has_parent?
- raw.key?('parent')
+ raw.key?("parent")
end
private
def inline
- raw.fetch('inline', {})
+ raw.fetch("inline", {})
end
end
end
diff --git a/lib/bitbucket/representation/repo.rb b/lib/bitbucket/representation/repo.rb
index c5bfc91e43d..78dcca4883d 100644
--- a/lib/bitbucket/representation/repo.rb
+++ b/lib/bitbucket/representation/repo.rb
@@ -10,7 +10,7 @@ module Bitbucket
end
def owner_and_slug
- @owner_and_slug ||= full_name.split('/', 2)
+ @owner_and_slug ||= full_name.split("/", 2)
end
def owner
@@ -22,7 +22,7 @@ module Bitbucket
end
def clone_url(token = nil)
- url = raw['links']['clone'].find { |link| link['name'] == 'https' }.fetch('href')
+ url = raw["links"]["clone"].find { |link| link["name"] == "https" }.fetch("href")
if token.present?
clone_url = URI.parse(url)
@@ -34,31 +34,31 @@ module Bitbucket
end
def description
- raw['description']
+ raw["description"]
end
def full_name
- raw['full_name']
+ raw["full_name"]
end
def issues_enabled?
- raw['has_issues']
+ raw["has_issues"]
end
def name
- raw['name']
+ raw["name"]
end
def valid?
- raw['scm'] == 'git'
+ raw["scm"] == "git"
end
def has_wiki?
- raw['has_wiki']
+ raw["has_wiki"]
end
def visibility_level
- if raw['is_private']
+ if raw["is_private"]
Gitlab::VisibilityLevel::PRIVATE
else
Gitlab::VisibilityLevel::PUBLIC
diff --git a/lib/bitbucket/representation/user.rb b/lib/bitbucket/representation/user.rb
index 2b45d751e70..23d7008de92 100644
--- a/lib/bitbucket/representation/user.rb
+++ b/lib/bitbucket/representation/user.rb
@@ -4,7 +4,7 @@ module Bitbucket
module Representation
class User < Representation::Base
def username
- raw['username']
+ raw["username"]
end
end
end
diff --git a/lib/bitbucket_server/client.rb b/lib/bitbucket_server/client.rb
index 6a608058813..dfe70fe4910 100644
--- a/lib/bitbucket_server/client.rb
+++ b/lib/bitbucket_server/client.rb
@@ -32,7 +32,7 @@ module BitbucketServer
payload = {
name: branch_name,
startPoint: sha,
- message: 'GitLab temporary branch for import'
+ message: "GitLab temporary branch for import",
}
connection.post("/projects/#{project_key}/repos/#{repo}/branches", payload.to_json)
@@ -41,7 +41,7 @@ module BitbucketServer
def delete_branch(project_key, repo, branch_name, sha)
payload = {
name: Gitlab::Git::BRANCH_REF_PREFIX + branch_name,
- dryRun: false
+ dryRun: false,
}
connection.delete(:branches, "/projects/#{project_key}/repos/#{repo}/branches", payload.to_json)
diff --git a/lib/bitbucket_server/collection.rb b/lib/bitbucket_server/collection.rb
index 7e4b2277bbe..2ef5d71ddaf 100644
--- a/lib/bitbucket_server/collection.rb
+++ b/lib/bitbucket_server/collection.rb
@@ -37,9 +37,9 @@ module BitbucketServer
end
def method_missing(method, *args)
- return super unless self.respond_to?(method)
+ return super unless respond_to?(method)
- self.__send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend
+ __send__(method, *args) do |item| # rubocop:disable GitlabSecurity/PublicSend
block_given? ? yield(item) : item
end
end
diff --git a/lib/bitbucket_server/connection.rb b/lib/bitbucket_server/connection.rb
index fbd451efb23..272c8f9968d 100644
--- a/lib/bitbucket_server/connection.rb
+++ b/lib/bitbucket_server/connection.rb
@@ -4,8 +4,8 @@ module BitbucketServer
class Connection
include ActionView::Helpers::SanitizeHelper
- DEFAULT_API_VERSION = '1.0'
- SEPARATOR = '/'
+ DEFAULT_API_VERSION = "1.0"
+ SEPARATOR = "/"
NETWORK_ERRORS = [
SocketError,
@@ -15,7 +15,7 @@ module BitbucketServer
Errno::EHOSTUNREACH,
Net::OpenTimeout,
Net::ReadTimeout,
- Gitlab::HTTP::BlockedUrlError
+ Gitlab::HTTP::BlockedUrlError,
].freeze
attr_reader :api_version, :base_uri, :username, :token
@@ -31,9 +31,9 @@ module BitbucketServer
def get(path, extra_query = {})
response = Gitlab::HTTP.get(build_url(path),
- basic_auth: auth,
- headers: accept_headers,
- query: extra_query)
+ basic_auth: auth,
+ headers: accept_headers,
+ query: extra_query)
check_errors!(response)
@@ -44,9 +44,9 @@ module BitbucketServer
def post(path, body)
response = Gitlab::HTTP.post(build_url(path),
- basic_auth: auth,
- headers: post_headers,
- body: body)
+ basic_auth: auth,
+ headers: post_headers,
+ body: body)
check_errors!(response)
@@ -63,9 +63,9 @@ module BitbucketServer
url = delete_url(resource, path)
response = Gitlab::HTTP.delete(url,
- basic_auth: auth,
- headers: post_headers,
- body: body)
+ basic_auth: auth,
+ headers: post_headers,
+ body: body)
check_errors!(response)
@@ -82,7 +82,7 @@ module BitbucketServer
return if response.code >= 200 && response.code < 300
- details = sanitize(response.parsed_response.dig('errors', 0, 'message'))
+ details = sanitize(response.parsed_response.dig("errors", 0, "message"))
message = "Error #{response.code}"
message += ": #{details}" if details
@@ -92,15 +92,15 @@ module BitbucketServer
end
def auth
- @auth ||= { username: username, password: token }
+ @auth ||= {username: username, password: token}
end
def accept_headers
- @accept_headers ||= { 'Accept' => 'application/json' }
+ @accept_headers ||= {"Accept" => "application/json"}
end
def post_headers
- @post_headers ||= accept_headers.merge({ 'Content-Type' => 'application/json' })
+ @post_headers ||= accept_headers.merge({"Content-Type" => "application/json"})
end
def build_url(path)
diff --git a/lib/bitbucket_server/page.rb b/lib/bitbucket_server/page.rb
index 5d9a3168876..a15fe9d88ee 100644
--- a/lib/bitbucket_server/page.rb
+++ b/lib/bitbucket_server/page.rb
@@ -20,13 +20,13 @@ module BitbucketServer
private
def parse_attrs(raw)
- raw.slice('size', 'nextPageStart', 'isLastPage').symbolize_keys
+ raw.slice("size", "nextPageStart", "isLastPage").symbolize_keys
end
def parse_values(raw, bitbucket_rep_class)
- return [] unless raw['values'] && raw['values'].is_a?(Array)
+ return [] unless raw["values"]&.is_a?(Array)
- bitbucket_rep_class.decorate(raw['values'])
+ bitbucket_rep_class.decorate(raw["values"])
end
def representation_class(type)
diff --git a/lib/bitbucket_server/representation/activity.rb b/lib/bitbucket_server/representation/activity.rb
index 08bf30a5d1e..ec1e3d148f3 100644
--- a/lib/bitbucket_server/representation/activity.rb
+++ b/lib/bitbucket_server/representation/activity.rb
@@ -4,7 +4,7 @@ module BitbucketServer
module Representation
class Activity < Representation::Base
def comment?
- action == 'COMMENTED'
+ action == "COMMENTED"
end
def inline_comment?
@@ -24,25 +24,25 @@ module BitbucketServer
# TODO Move this into MergeEvent
def merge_event?
- action == 'MERGED'
+ action == "MERGED"
end
def committer_user
- commit.dig('committer', 'displayName')
+ commit.dig("committer", "displayName")
end
def committer_email
- commit.dig('committer', 'emailAddress')
+ commit.dig("committer", "emailAddress")
end
def merge_timestamp
- timestamp = commit['committerTimestamp']
+ timestamp = commit["committerTimestamp"]
self.class.convert_timestamp(timestamp)
end
def merge_commit
- commit['id']
+ commit["id"]
end
def created_at
@@ -52,19 +52,19 @@ module BitbucketServer
private
def commit
- raw.fetch('commit', {})
+ raw.fetch("commit", {})
end
def action
- raw['action']
+ raw["action"]
end
def comment_anchor
- raw['commentAnchor']
+ raw["commentAnchor"]
end
def created_date
- raw['createdDate']
+ raw["createdDate"]
end
end
end
diff --git a/lib/bitbucket_server/representation/comment.rb b/lib/bitbucket_server/representation/comment.rb
index 99b97a3b181..fdd8316cc6b 100644
--- a/lib/bitbucket_server/representation/comment.rb
+++ b/lib/bitbucket_server/representation/comment.rb
@@ -34,19 +34,19 @@ module BitbucketServer
end
def id
- raw_comment['id']
+ raw_comment["id"]
end
def author_username
- author['displayName']
+ author["displayName"]
end
def author_email
- author['emailAddress']
+ author["emailAddress"]
end
def note
- raw_comment['text']
+ raw_comment["text"]
end
def created_at
@@ -85,7 +85,7 @@ module BitbucketServer
# insert that node into the workset.
# b. Parse that note into a Comment structure and add it to a flat list.
def flatten_comments
- comments = raw_comment['comments']
+ comments = raw_comment["comments"]
workset =
if comments
[CommentNode.new(comments, self)]
@@ -100,8 +100,8 @@ module BitbucketServer
parent = node.parent
node.raw_comments.each do |comment|
- new_comments = comment.delete('comments')
- current_comment = Comment.new({ 'comment' => comment }, parent_comment: parent)
+ new_comments = comment.delete("comments")
+ current_comment = Comment.new({"comment" => comment}, parent_comment: parent)
all_comments << current_comment
workset << CommentNode.new(new_comments, current_comment) if new_comments
end
@@ -111,19 +111,19 @@ module BitbucketServer
end
def raw_comment
- raw.fetch('comment', {})
+ raw.fetch("comment", {})
end
def author
- raw_comment['author']
+ raw_comment["author"]
end
def created_date
- raw_comment['createdDate']
+ raw_comment["createdDate"]
end
def updated_date
- raw_comment['updatedDate']
+ raw_comment["updatedDate"]
end
end
end
diff --git a/lib/bitbucket_server/representation/pull_request.rb b/lib/bitbucket_server/representation/pull_request.rb
index c3e927d8de7..9475b2dff7e 100644
--- a/lib/bitbucket_server/representation/pull_request.rb
+++ b/lib/bitbucket_server/representation/pull_request.rb
@@ -4,34 +4,34 @@ module BitbucketServer
module Representation
class PullRequest < Representation::Base
def author
- raw.dig('author', 'user', 'name')
+ raw.dig("author", "user", "name")
end
def author_email
- raw.dig('author', 'user', 'emailAddress')
+ raw.dig("author", "user", "emailAddress")
end
def description
- raw['description']
+ raw["description"]
end
def iid
- raw['id']
+ raw["id"]
end
def state
- case raw['state']
- when 'MERGED'
- 'merged'
- when 'DECLINED'
- 'closed'
+ case raw["state"]
+ when "MERGED"
+ "merged"
+ when "DECLINED"
+ "closed"
else
- 'opened'
+ "opened"
end
end
def merged?
- state == 'merged'
+ state == "merged"
end
def created_at
@@ -43,33 +43,33 @@ module BitbucketServer
end
def title
- raw['title']
+ raw["title"]
end
def source_branch_name
- raw.dig('fromRef', 'id')
+ raw.dig("fromRef", "id")
end
def source_branch_sha
- raw.dig('fromRef', 'latestCommit')
+ raw.dig("fromRef", "latestCommit")
end
def target_branch_name
- raw.dig('toRef', 'id')
+ raw.dig("toRef", "id")
end
def target_branch_sha
- raw.dig('toRef', 'latestCommit')
+ raw.dig("toRef", "latestCommit")
end
private
def created_date
- raw['createdDate']
+ raw["createdDate"]
end
def updated_date
- raw['updatedDate']
+ raw["updatedDate"]
end
end
end
diff --git a/lib/bitbucket_server/representation/pull_request_comment.rb b/lib/bitbucket_server/representation/pull_request_comment.rb
index a2b3873a397..66dca57a0f8 100644
--- a/lib/bitbucket_server/representation/pull_request_comment.rb
+++ b/lib/bitbucket_server/representation/pull_request_comment.rb
@@ -19,27 +19,27 @@ module BitbucketServer
# More details in https://docs.atlassian.com/bitbucket-server/rest/5.12.0/bitbucket-rest.html.
class PullRequestComment < Comment
def from_sha
- comment_anchor['fromHash']
+ comment_anchor["fromHash"]
end
def to_sha
- comment_anchor['toHash']
+ comment_anchor["toHash"]
end
def to?
- file_type == 'TO'
+ file_type == "TO"
end
def from?
- file_type == 'FROM'
+ file_type == "FROM"
end
def added?
- line_type == 'ADDED'
+ line_type == "ADDED"
end
def removed?
- line_type == 'REMOVED'
+ line_type == "REMOVED"
end
# There are three line comment types: added, removed, or context.
@@ -63,17 +63,17 @@ module BitbucketServer
end
def file_path
- comment_anchor.fetch('path')
+ comment_anchor.fetch("path")
end
private
def file_type
- comment_anchor['fileType']
+ comment_anchor["fileType"]
end
def line_type
- comment_anchor['lineType']
+ comment_anchor["lineType"]
end
# Each comment contains the following information about the diff:
@@ -94,12 +94,12 @@ module BitbucketServer
# entries until we find this comment ID.
def line_position
@line_position ||= diff_hunks.each do |hunk|
- segments = hunk.fetch('segments', [])
+ segments = hunk.fetch("segments", [])
segments.each do |segment|
- lines = segment.fetch('lines', [])
+ lines = segment.fetch("lines", [])
lines.each do |line|
- if line['commentIds']&.include?(id)
- return [line['source'], line['destination']]
+ if line["commentIds"]&.include?(id)
+ return [line["source"], line["destination"]]
end
end
end
@@ -107,15 +107,15 @@ module BitbucketServer
end
def comment_anchor
- raw.fetch('commentAnchor', {})
+ raw.fetch("commentAnchor", {})
end
def diff
- raw.fetch('diff', {})
+ raw.fetch("diff", {})
end
def diff_hunks
- diff.fetch('hunks', [])
+ diff.fetch("hunks", [])
end
end
end
diff --git a/lib/bitbucket_server/representation/repo.rb b/lib/bitbucket_server/representation/repo.rb
index 6c494b79166..d67b11fd50b 100644
--- a/lib/bitbucket_server/representation/repo.rb
+++ b/lib/bitbucket_server/representation/repo.rb
@@ -8,29 +8,29 @@ module BitbucketServer
end
def project_key
- raw.dig('project', 'key')
+ raw.dig("project", "key")
end
def project_name
- raw.dig('project', 'name')
+ raw.dig("project", "name")
end
def slug
- raw['slug']
+ raw["slug"]
end
def browse_url
# The JSON reponse contains an array of 1 element. Not sure if there
# are cases where multiple links would be provided.
- raw.dig('links', 'self').first.fetch('href')
+ raw.dig("links", "self").first.fetch("href")
end
def clone_url
- raw['links']['clone'].find { |link| link['name'].starts_with?('http') }.fetch('href')
+ raw["links"]["clone"].find { |link| link["name"].starts_with?("http") }.fetch("href")
end
def description
- project['description']
+ project["description"]
end
def full_name
@@ -42,15 +42,15 @@ module BitbucketServer
end
def name
- raw['name']
+ raw["name"]
end
def valid?
- raw['scmId'] == 'git'
+ raw["scmId"] == "git"
end
def visibility_level
- if project['public']
+ if project["public"]
Gitlab::VisibilityLevel::PUBLIC
else
Gitlab::VisibilityLevel::PRIVATE
@@ -58,7 +58,7 @@ module BitbucketServer
end
def project
- raw['project']
+ raw["project"]
end
def to_s
diff --git a/lib/constraints/project_url_constrainer.rb b/lib/constraints/project_url_constrainer.rb
index eadfbf7bc01..a9a96ef3a00 100644
--- a/lib/constraints/project_url_constrainer.rb
+++ b/lib/constraints/project_url_constrainer.rb
@@ -5,7 +5,7 @@ module Constraints
def matches?(request)
namespace_path = request.params[:namespace_id]
project_path = request.params[:project_id] || request.params[:id]
- full_path = [namespace_path, project_path].join('/')
+ full_path = [namespace_path, project_path].join("/")
return false unless ProjectPathValidator.valid_path?(full_path)
diff --git a/lib/container_registry/blob.rb b/lib/container_registry/blob.rb
index 837b22c3082..54134fe0e68 100644
--- a/lib/container_registry/blob.rb
+++ b/lib/container_registry/blob.rb
@@ -20,19 +20,19 @@ module ContainerRegistry
end
def digest
- config['digest'] || config['blobSum']
+ config["digest"] || config["blobSum"]
end
def type
- config['mediaType']
+ config["mediaType"]
end
def size
- config['size']
+ config["size"]
end
def revision
- digest.split(':')[1]
+ digest.split(":")[1]
end
def short_revision
diff --git a/lib/container_registry/client.rb b/lib/container_registry/client.rb
index c80f49f5ae0..52c92bc694b 100644
--- a/lib/container_registry/client.rb
+++ b/lib/container_registry/client.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'faraday'
-require 'faraday_middleware'
+require "faraday"
+require "faraday_middleware"
module ContainerRegistry
class Client
attr_accessor :uri
- MANIFEST_VERSION = 'application/vnd.docker.distribution.manifest.v2+json'.freeze
+ MANIFEST_VERSION = "application/vnd.docker.distribution.manifest.v2+json"
# Taken from: FaradayMiddleware::FollowRedirects
REDIRECT_CODES = Set.new [301, 302, 303, 307]
@@ -27,7 +27,7 @@ module ContainerRegistry
def repository_tag_digest(name, reference)
response = faraday.head("/v2/#{name}/manifests/#{reference}")
- response.headers['docker-content-digest'] if response.success?
+ response.headers["docker-content-digest"] if response.success?
end
def delete_repository_tag(name, reference)
@@ -35,8 +35,8 @@ module ContainerRegistry
end
def blob(name, digest, type = nil)
- type ||= 'application/octet-stream'
- response_body faraday_blob.get("/v2/#{name}/blobs/#{digest}", nil, 'Accept' => type), allow_redirect: true
+ type ||= "application/octet-stream"
+ response_body faraday_blob.get("/v2/#{name}/blobs/#{digest}", nil, "Accept" => type), allow_redirect: true
end
def delete_blob(name, digest)
@@ -60,20 +60,20 @@ module ContainerRegistry
end
def accept_manifest(conn)
- conn.headers['Accept'] = MANIFEST_VERSION
+ conn.headers["Accept"] = MANIFEST_VERSION
- conn.response :json, content_type: 'application/json'
- conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v1+prettyjws'
- conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v1+json'
- conn.response :json, content_type: 'application/vnd.docker.distribution.manifest.v2+json'
+ conn.response :json, content_type: "application/json"
+ conn.response :json, content_type: "application/vnd.docker.distribution.manifest.v1+prettyjws"
+ conn.response :json, content_type: "application/vnd.docker.distribution.manifest.v1+json"
+ conn.response :json, content_type: "application/vnd.docker.distribution.manifest.v2+json"
end
def response_body(response, allow_redirect: false)
if allow_redirect && REDIRECT_CODES.include?(response.status)
- response = redirect_response(response.headers['location'])
+ response = redirect_response(response.headers["location"])
end
- response.body if response && response.success?
+ response.body if response&.success?
end
def redirect_response(location)
@@ -83,24 +83,24 @@ module ContainerRegistry
end
def faraday
- @faraday ||= Faraday.new(@base_uri) do |conn|
+ @faraday ||= Faraday.new(@base_uri) { |conn|
initialize_connection(conn, @options, &method(:accept_manifest))
- end
+ }
end
def faraday_blob
- @faraday_blob ||= Faraday.new(@base_uri) do |conn|
+ @faraday_blob ||= Faraday.new(@base_uri) { |conn|
initialize_connection(conn, @options)
- end
+ }
end
# Create a new request to make sure the Authorization header is not inserted
# via the Faraday middleware
def faraday_redirect
- @faraday_redirect ||= Faraday.new(@base_uri) do |conn|
+ @faraday_redirect ||= Faraday.new(@base_uri) { |conn|
conn.request :json
conn.adapter :net_http
- end
+ }
end
end
end
diff --git a/lib/container_registry/path.rb b/lib/container_registry/path.rb
index 9b2a61cdedc..b9cc49cb379 100644
--- a/lib/container_registry/path.rb
+++ b/lib/container_registry/path.rb
@@ -27,16 +27,16 @@ module ContainerRegistry
end
def components
- @components ||= @path.split('/')
+ @components ||= @path.split("/")
end
# rubocop: disable CodeReuse/ActiveRecord
def nodes
raise InvalidRegistryPathError unless valid?
- @nodes ||= components.size.downto(2).map do |length|
- components.take(length).join('/')
- end
+ @nodes ||= components.size.downto(2).map { |length|
+ components.take(length).join("/")
+ }
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -66,7 +66,7 @@ module ContainerRegistry
def repository_name
return unless has_project?
- @path.remove(%r(^#{Regexp.escape(project_path)}/?))
+ @path.remove(%r{^#{Regexp.escape(project_path)}/?})
end
def project_path
diff --git a/lib/container_registry/registry.rb b/lib/container_registry/registry.rb
index 523364ac7c7..c69dc0c5842 100644
--- a/lib/container_registry/registry.rb
+++ b/lib/container_registry/registry.rb
@@ -13,7 +13,7 @@ module ContainerRegistry
private
def default_path
- @uri.sub(%r{^https?://}, '')
+ @uri.sub(%r{^https?://}, "")
end
end
end
diff --git a/lib/container_registry/tag.rb b/lib/container_registry/tag.rb
index ef41dc560c9..0da4072367b 100644
--- a/lib/container_registry/tag.rb
+++ b/lib/container_registry/tag.rb
@@ -22,11 +22,11 @@ module ContainerRegistry
end
def v1?
- manifest && manifest['schemaVersion'] == 1
+ manifest && manifest["schemaVersion"] == 1
end
def v2?
- manifest && manifest['schemaVersion'] == 2
+ manifest && manifest["schemaVersion"] == 2
end
def manifest
@@ -56,10 +56,10 @@ module ContainerRegistry
end
def config_blob
- return unless manifest && manifest['config']
+ return unless manifest && manifest["config"]
strong_memoize(:config_blob) do
- repository.blob(manifest['config'])
+ repository.blob(manifest["config"])
end
end
@@ -75,7 +75,7 @@ module ContainerRegistry
return unless config
strong_memoize(:created_at) do
- DateTime.rfc3339(config['created'])
+ DateTime.rfc3339(config["created"])
end
end
@@ -83,7 +83,7 @@ module ContainerRegistry
return unless manifest
strong_memoize(:layers) do
- layers = manifest['layers'] || manifest['fsLayers']
+ layers = manifest["layers"] || manifest["fsLayers"]
layers.map do |layer|
repository.blob(layer)
diff --git a/lib/declarative_policy.rb b/lib/declarative_policy.rb
index 7ba48ae9c79..354db90ba3d 100644
--- a/lib/declarative_policy.rb
+++ b/lib/declarative_policy.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require_dependency 'declarative_policy/cache'
-require_dependency 'declarative_policy/condition'
-require_dependency 'declarative_policy/delegate_dsl'
-require_dependency 'declarative_policy/policy_dsl'
-require_dependency 'declarative_policy/rule_dsl'
-require_dependency 'declarative_policy/preferred_scope'
-require_dependency 'declarative_policy/rule'
-require_dependency 'declarative_policy/runner'
-require_dependency 'declarative_policy/step'
-
-require_dependency 'declarative_policy/base'
+require_dependency "declarative_policy/cache"
+require_dependency "declarative_policy/condition"
+require_dependency "declarative_policy/delegate_dsl"
+require_dependency "declarative_policy/policy_dsl"
+require_dependency "declarative_policy/rule_dsl"
+require_dependency "declarative_policy/preferred_scope"
+require_dependency "declarative_policy/rule"
+require_dependency "declarative_policy/runner"
+require_dependency "declarative_policy/step"
+
+require_dependency "declarative_policy/base"
module DeclarativePolicy
CLASS_CACHE_MUTEX = Mutex.new
@@ -25,9 +25,9 @@ module DeclarativePolicy
# to avoid deadlocks in multi-threaded environment when
# autoloading is enabled, we allow concurrent loads,
# https://gitlab.com/gitlab-org/gitlab-ce/issues/48263
- ActiveSupport::Dependencies.interlock.permit_concurrent_loads do
+ ActiveSupport::Dependencies.interlock.permit_concurrent_loads {
class_for(subject).new(user, subject, opts)
- end
+ }
end
def class_for(subject)
diff --git a/lib/declarative_policy/base.rb b/lib/declarative_policy/base.rb
index cd6e1606f22..3386f2935c2 100644
--- a/lib/declarative_policy/base.rb
+++ b/lib/declarative_policy/base.rb
@@ -165,7 +165,7 @@ module DeclarativePolicy
condition = Condition.new(name, opts, &value)
- self.own_conditions[name] = condition
+ own_conditions[name] = condition
define_method(:"#{name}?") { condition(name).pass? }
end
@@ -308,14 +308,14 @@ module DeclarativePolicy
# A list of other policies that we've delegated to (see `Base.delegate`)
def delegated_policies
- @delegated_policies ||= self.class.delegations.transform_values do |block|
+ @delegated_policies ||= self.class.delegations.transform_values { |block|
new_subject = instance_eval(&block)
# never delegate to nil, as that would immediately prevent_all
next if new_subject.nil?
policy_for(new_subject)
- end
+ }
end
def policy_for(other_subject)
diff --git a/lib/declarative_policy/cache.rb b/lib/declarative_policy/cache.rb
index 13006e56454..e51d6aa8851 100644
--- a/lib/declarative_policy/cache.rb
+++ b/lib/declarative_policy/cache.rb
@@ -4,7 +4,7 @@ module DeclarativePolicy
module Cache
class << self
def user_key(user)
- return '<anonymous>' if user.nil?
+ return "<anonymous>" if user.nil?
id_for(user)
end
@@ -16,7 +16,7 @@ module DeclarativePolicy
end
def subject_key(subject)
- return '<nil>' if subject.nil?
+ return "<nil>" if subject.nil?
return subject.inspect if subject.is_a?(Symbol)
"#{subject.class.name}:#{id_for(subject)}"
diff --git a/lib/declarative_policy/condition.rb b/lib/declarative_policy/condition.rb
index b77f40b1093..a0e4aa6facf 100644
--- a/lib/declarative_policy/condition.rb
+++ b/lib/declarative_policy/condition.rb
@@ -90,7 +90,7 @@ module DeclarativePolicy
when :user then "/dp/condition/#{@condition.key}/#{user_key}"
when :subject then "/dp/condition/#{@condition.key}/#{subject_key}"
when :global then "/dp/condition/#{@condition.key}"
- else raise 'invalid scope'
+ else raise "invalid scope"
end
end
diff --git a/lib/declarative_policy/rule.rb b/lib/declarative_policy/rule.rb
index f38f4f0a50f..dd3d13bc5a0 100644
--- a/lib/declarative_policy/rule.rb
+++ b/lib/declarative_policy/rule.rb
@@ -18,20 +18,20 @@ module DeclarativePolicy
# `context` is a policy - an instance of
# DeclarativePolicy::Base.
def pass?(context)
- raise 'abstract'
+ raise "abstract"
end
# same as #pass? except refuses to do any I/O,
# returning nil if the result is not yet cached.
# used for accurately scoring And/Or
def cached_pass?(context)
- raise 'abstract'
+ raise "abstract"
end
# abstractly, how long would it take to compute
# this rule? lower-scored rules are tried first.
def score(context)
- raise 'abstract'
+ raise "abstract"
end
# unwrap double negatives and nested and/or
@@ -52,9 +52,9 @@ module DeclarativePolicy
Not.make(self)
end
- alias_method :|, :or
- alias_method :&, :and
- alias_method :~@, :negate
+ alias | or
+ alias & and
+ alias ~ negate
def inspect
"#<Rule #{repr}>"
@@ -184,13 +184,13 @@ module DeclarativePolicy
end
def simplify
- simplified_rules = @rules.flat_map do |rule|
+ simplified_rules = @rules.flat_map { |rule|
simplified = rule.simplify
case simplified
when And then simplified.rules
else [simplified]
end
- end
+ }
And.new(simplified_rules)
end
@@ -222,7 +222,7 @@ module DeclarativePolicy
end
def repr
- "all?(#{rules.map(&:repr).join(', ')})"
+ "all?(#{rules.map(&:repr).join(", ")})"
end
end
@@ -241,13 +241,13 @@ module DeclarativePolicy
end
def simplify
- simplified_rules = @rules.flat_map do |rule|
+ simplified_rules = @rules.flat_map { |rule|
simplified = rule.simplify
case simplified
when Or then simplified.rules
else [simplified]
end
- end
+ }
Or.new(simplified_rules)
end
@@ -269,7 +269,7 @@ module DeclarativePolicy
end
def repr
- "any?(#{@rules.map(&:repr).join(', ')})"
+ "any?(#{@rules.map(&:repr).join(", ")})"
end
end
diff --git a/lib/declarative_policy/runner.rb b/lib/declarative_policy/runner.rb
index f739fe5e16e..fd17b1a2b5f 100644
--- a/lib/declarative_policy/runner.rb
+++ b/lib/declarative_policy/runner.rb
@@ -184,9 +184,9 @@ module DeclarativePolicy
def inspect_step(step, original_score, passed)
symbol =
case passed
- when true then '+'
- when false then '-'
- when nil then ' '
+ when true then "+"
+ when false then "-"
+ when nil then " "
end
"#{symbol} [#{original_score.to_i}] #{step.repr}\n"
diff --git a/lib/event_filter.rb b/lib/event_filter.rb
index 24fdcd6fbb1..015b27a5a4c 100644
--- a/lib/event_filter.rb
+++ b/lib/event_filter.rb
@@ -3,17 +3,17 @@
class EventFilter
attr_accessor :filter
- ALL = 'all'
- PUSH = 'push'
- MERGED = 'merged'
- ISSUE = 'issue'
- COMMENTS = 'comments'
- TEAM = 'team'
+ ALL = "all"
+ PUSH = "push"
+ MERGED = "merged"
+ ISSUE = "issue"
+ COMMENTS = "comments"
+ TEAM = "team"
FILTERS = [ALL, PUSH, MERGED, ISSUE, COMMENTS, TEAM].freeze
def initialize(filter)
# Split using comma to maintain backward compatibility Ex/ "filter1,filter2"
- filter = filter.to_s.split(',')[0].to_s
+ filter = filter.to_s.split(",")[0].to_s
@filter = FILTERS.include?(filter) ? filter : ALL
end
diff --git a/lib/expand_variables.rb b/lib/expand_variables.rb
index c83cec9dc4a..ff97a02ebde 100644
--- a/lib/expand_variables.rb
+++ b/lib/expand_variables.rb
@@ -5,10 +5,9 @@ module ExpandVariables
def expand(value, variables)
# Convert hash array to variables
if variables.is_a?(Array)
- variables = variables.reduce({}) do |hash, variable|
+ variables = variables.each_with_object({}) { |variable, hash|
hash[variable[:key]] = variable[:value]
- hash
- end
+ }
end
value.gsub(/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/) do
diff --git a/lib/extracts_path.rb b/lib/extracts_path.rb
index b2c8d46ede1..3432c0a7850 100644
--- a/lib/extracts_path.rb
+++ b/lib/extracts_path.rb
@@ -40,7 +40,7 @@ module ExtractsPath
# Returns an Array where the first value is the tree-ish and the second is the
# path
def extract_ref(id)
- pair = ['', '']
+ pair = ["", ""]
return pair unless @project # rubocop:disable Gitlab/ModuleWithInstanceVariables
@@ -52,8 +52,8 @@ module ExtractsPath
# branches and tags
# Append a trailing slash if we only get a ref and no file path
- unless id.ends_with?('/')
- id = [id, '/'].join
+ unless id.ends_with?("/")
+ id = [id, "/"].join
end
valid_refs = ref_names.select { |v| id.start_with?("#{v}/") }
@@ -72,7 +72,7 @@ module ExtractsPath
end
# Remove ending slashes from path
- pair[1].gsub!(%r{^/|/$}, '')
+ pair[1].gsub!(%r{^/|/$}, "")
pair
end
@@ -84,7 +84,7 @@ module ExtractsPath
# match, so it is possible to create a branch which has an unroutable Atom
# feed.
def extract_ref_without_atom(id)
- id_without_atom = id.sub(/\.atom$/, '')
+ id_without_atom = id.sub(/\.atom$/, "")
valid_refs = ref_names.select { |v| "#{id_without_atom}/".start_with?("#{v}/") }
valid_refs.max_by(&:length)
@@ -116,7 +116,7 @@ module ExtractsPath
@commit = @repo.commit(@ref)
- if @path.empty? && !@commit && @id.ends_with?('.atom')
+ if @path.empty? && !@commit && @id.ends_with?(".atom")
@id = @ref = extract_ref_without_atom(@id)
@commit = @repo.commit(@ref)
diff --git a/lib/feature.rb b/lib/feature.rb
index 749c861d740..8623bf35f31 100644
--- a/lib/feature.rb
+++ b/lib/feature.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'flipper/adapters/active_record'
-require 'flipper/adapters/active_support_cache_store'
+require "flipper/adapters/active_record"
+require "flipper/adapters/active_support_cache_store"
class Feature
# Classes to override flipper table names
class FlipperFeature < Flipper::Adapters::ActiveRecord::Feature
# Using `self.table_name` won't work. ActiveRecord bug?
- superclass.table_name = 'features'
+ superclass.table_name = "features"
def self.feature_names
pluck(:key)
@@ -15,7 +15,7 @@ class Feature
end
class FlipperGate < Flipper::Adapters::ActiveRecord::Gate
- superclass.table_name = 'feature_gates'
+ superclass.table_name = "feature_gates"
end
class << self
@@ -94,12 +94,14 @@ class Feature
def flipper_adapter
active_record_adapter = Flipper::Adapters::ActiveRecord.new(
feature_class: FlipperFeature,
- gate_class: FlipperGate)
+ gate_class: FlipperGate
+ )
Flipper::Adapters::ActiveSupportCacheStore.new(
active_record_adapter,
Rails.cache,
- expires_in: 1.hour)
+ expires_in: 1.hour
+ )
end
end
@@ -111,7 +113,7 @@ class Feature
end
def gate_specified?
- %i(user project group feature_group).any? { |key| params.key?(key) }
+ %i[user project group feature_group].any? { |key| params.key?(key) }
end
def targets
diff --git a/lib/file_size_validator.rb b/lib/file_size_validator.rb
index 70a145cd5bd..fcf648796e9 100644
--- a/lib/file_size_validator.rb
+++ b/lib/file_size_validator.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
class FileSizeValidator < ActiveModel::EachValidator
- MESSAGES = { is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big }.freeze
- CHECKS = { is: :==, minimum: :>=, maximum: :<= }.freeze
+ MESSAGES = {is: :wrong_size, minimum: :size_too_small, maximum: :size_too_big}.freeze
+ CHECKS = {is: :==, minimum: :>=, maximum: :<=}.freeze
- DEFAULT_TOKENIZER = -> (value) { value.split(//) }.freeze
+ DEFAULT_TOKENIZER = ->(value) { value.split(//) }.freeze
RESERVED_OPTIONS = [:minimum, :maximum, :within, :is, :tokenizer, :too_short, :too_long].freeze
def initialize(options)
@@ -22,7 +22,7 @@ class FileSizeValidator < ActiveModel::EachValidator
keys = CHECKS.keys & options.keys
if keys.empty?
- raise ArgumentError, 'Range unspecified. Specify the :within, :maximum, :minimum, or :is option.'
+ raise ArgumentError, "Range unspecified. Specify the :within, :maximum, :minimum, or :is option."
end
keys.each do |key|
diff --git a/lib/flowdock/git.rb b/lib/flowdock/git.rb
index f165ecfc1fa..be36f4c662f 100644
--- a/lib/flowdock/git.rb
+++ b/lib/flowdock/git.rb
@@ -1,13 +1,14 @@
# frozen_string_literal: true
-require 'flowdock'
-require 'flowdock/git/builder'
+
+require "flowdock"
+require "flowdock/git/builder"
module Flowdock
class Git
TokenError = Class.new(StandardError)
DEFAULT_PERMANENT_REFS = [
- Regexp.new('refs/heads/master')
+ Regexp.new("refs/heads/master"),
].freeze
class << self
@@ -55,8 +56,7 @@ module Flowdock
repo_url: @repo_url,
repo_name: @repo_name,
permanent_refs: @permanent_refs,
- tags: tags
- ).to_hashes
+ tags: tags).to_hashes
end
# Flowdock tags attached to the push notification
diff --git a/lib/flowdock/git/builder.rb b/lib/flowdock/git/builder.rb
index 6f4428d1f42..46513e19fd4 100644
--- a/lib/flowdock/git/builder.rb
+++ b/lib/flowdock/git/builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Flowdock
class Git
class Commit
@@ -15,11 +16,11 @@ module Flowdock
event: "activity",
author: {
name: @commit[:author][:name],
- email: @commit[:author][:email]
+ email: @commit[:author][:email],
},
title: title,
thread: @thread,
- body: body
+ body: body,
}
hash[:tags] = @tags if @tags
encode(hash)
@@ -52,7 +53,7 @@ module Flowdock
def body
content = @commit[:message][first_line.size..-1]
- content.strip! if content
+ content&.strip!
"<pre>#{content}</pre>" unless content.empty?
end
@@ -94,14 +95,14 @@ module Flowdock
message: commit.message,
author: {
name: commit.author_name,
- email: commit.author_email
- }
+ email: commit.author_email,
+ },
}
end
end
def ref_name
- @ref.to_s.sub(%r{\Arefs/(heads|tags)/}, '')
+ @ref.to_s.sub(%r{\Arefs/(heads|tags)/}, "")
end
def to_hashes
@@ -115,7 +116,7 @@ module Flowdock
def thread
@thread ||= {
title: thread_title,
- external_url: @opts[:repo_url]
+ external_url: @opts[:repo_url],
}
end
@@ -127,7 +128,7 @@ module Flowdock
def thread_title
action = "updated" if permanent?
- type = @ref =~ %r(^refs/heads/) ? "branch" : "tag"
+ type = %r{^refs/heads/}.match?(@ref) ? "branch" : "tag"
[@opts[:repo_name], type, ref_name, action].compact.join(" ")
end
diff --git a/lib/forever.rb b/lib/forever.rb
index 0a37118fe68..5a4ff22fb62 100644
--- a/lib/forever.rb
+++ b/lib/forever.rb
@@ -2,7 +2,7 @@
class Forever
POSTGRESQL_DATE = DateTime.new(3000, 1, 1)
- MYSQL_DATE = DateTime.new(2038, 01, 19)
+ MYSQL_DATE = DateTime.new(2038, 0o1, 19)
# MySQL timestamp has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
def self.date
diff --git a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb
index 15cdd25e711..a68bde5f50c 100644
--- a/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb
+++ b/lib/generators/rails/post_deployment_migration/post_deployment_migration_generator.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'rails/generators'
+require "rails/generators"
module Rails
class PostDeploymentMigrationGenerator < Rails::Generators::NamedBase
def create_migration_file
- timestamp = Time.now.strftime('%Y%m%d%H%M%S')
+ timestamp = Time.now.strftime("%Y%m%d%H%M%S")
template "migration.rb", "db/post_migrate/#{timestamp}_#{file_name}.rb"
end
diff --git a/lib/gitaly/server.rb b/lib/gitaly/server.rb
index 7b238623418..6ebe36c8189 100644
--- a/lib/gitaly/server.rb
+++ b/lib/gitaly/server.rb
@@ -54,7 +54,7 @@ module Gitaly
Gitlab::GitalyClient::ServerService.new(@storage).info
rescue GRPC::Unavailable, GRPC::DeadlineExceeded
# This will show the server as being out of date
- Gitaly::ServerInfoResponse.new(git_version: '', server_version: '', storage_statuses: [])
+ Gitaly::ServerInfoResponse.new(git_version: "", server_version: "", storage_statuses: [])
end
end
end
diff --git a/lib/gitlab.rb b/lib/gitlab.rb
index e073450283b..b90121c0254 100644
--- a/lib/gitlab.rb
+++ b/lib/gitlab.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require_dependency 'gitlab/popen'
+require_dependency "gitlab/popen"
module Gitlab
def self.root
- Pathname.new(File.expand_path('..', __dir__))
+ Pathname.new(File.expand_path("..", __dir__))
end
def self.version_info
@@ -12,7 +12,7 @@ module Gitlab
end
def self.pre_release?
- VERSION.include?('pre')
+ VERSION.include?("pre")
end
def self.config
@@ -29,13 +29,13 @@ module Gitlab
if result.status.success?
result.stdout.chomp.freeze
else
- "Unknown".freeze
+ "Unknown"
end
end
end
end
- COM_URL = 'https://gitlab.com'.freeze
+ COM_URL = "https://gitlab.com"
APP_DIRS_PATTERN = %r{^/?(app|config|ee|lib|spec|\(\w*\))}
SUBDOMAIN_REGEX = %r{\Ahttps://[a-z0-9]+\.gitlab\.com\z}
VERSION = File.read(root.join("VERSION")).strip.freeze
@@ -47,7 +47,7 @@ module Gitlab
end
def self.org?
- Gitlab.config.gitlab.url == 'https://dev.gitlab.org'
+ Gitlab.config.gitlab.url == "https://dev.gitlab.org"
end
def self.gl_subdomain?
@@ -59,10 +59,10 @@ module Gitlab
end
def self.process_name
- return 'sidekiq' if Sidekiq.server?
- return 'console' if defined?(Rails::Console)
- return 'test' if Rails.env.test?
+ return "sidekiq" if Sidekiq.server?
+ return "console" if defined?(Rails::Console)
+ return "test" if Rails.env.test?
- 'web'
+ "web"
end
end
diff --git a/lib/gitlab/access.rb b/lib/gitlab/access.rb
index ec090aea784..391ac9ab2cf 100644
--- a/lib/gitlab/access.rb
+++ b/lib/gitlab/access.rb
@@ -33,10 +33,10 @@ module Gitlab
def options
{
- "Guest" => GUEST,
- "Reporter" => REPORTER,
- "Developer" => DEVELOPER,
- "Maintainer" => MAINTAINER
+ "Guest" => GUEST,
+ "Reporter" => REPORTER,
+ "Developer" => DEVELOPER,
+ "Maintainer" => MAINTAINER,
}
end
@@ -48,10 +48,10 @@ module Gitlab
def sym_options
{
- guest: GUEST,
- reporter: REPORTER,
- developer: DEVELOPER,
- maintainer: MAINTAINER
+ guest: GUEST,
+ reporter: REPORTER,
+ developer: DEVELOPER,
+ maintainer: MAINTAINER,
}
end
@@ -64,7 +64,7 @@ module Gitlab
"Not protected: Both developers and maintainers can push new commits, force push, or delete the branch." => PROTECTION_NONE,
"Protected against pushes: Developers cannot push new commits, but are allowed to accept merge requests to the branch. Maintainers can push to the branch." => PROTECTION_DEV_CAN_MERGE,
"Partially protected: Both developers and maintainers can push new commits, but cannot force push or delete the branch." => PROTECTION_DEV_CAN_PUSH,
- "Fully protected: Developers cannot push new commits, but maintainers can. No-one can force push or delete the branch." => PROTECTION_FULL
+ "Fully protected: Developers cannot push new commits, but maintainers can. No-one can force push or delete the branch." => PROTECTION_FULL,
}
end
diff --git a/lib/gitlab/action_rate_limiter.rb b/lib/gitlab/action_rate_limiter.rb
index c442211e073..f16d14b96c9 100644
--- a/lib/gitlab/action_rate_limiter.rb
+++ b/lib/gitlab/action_rate_limiter.rb
@@ -36,7 +36,7 @@ module Gitlab
# key - An array of ActiveRecord instances
# threshold_value - The maximum number of times this action should occur in the given time interval
def throttled?(key, threshold_value)
- self.increment(key) > threshold_value
+ increment(key) > threshold_value
end
private
diff --git a/lib/gitlab/app_logger.rb b/lib/gitlab/app_logger.rb
index 5edec8b3efe..62296f075be 100644
--- a/lib/gitlab/app_logger.rb
+++ b/lib/gitlab/app_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class AppLogger < Gitlab::Logger
def self.file_name_noext
- 'application'
+ "application"
end
def format_message(severity, timestamp, progname, msg)
diff --git a/lib/gitlab/asciidoc.rb b/lib/gitlab/asciidoc.rb
index df8f0470063..cfa3053886d 100644
--- a/lib/gitlab/asciidoc.rb
+++ b/lib/gitlab/asciidoc.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'asciidoctor'
-require 'asciidoctor/converter/html5'
+require "asciidoctor"
+require "asciidoctor/converter/html5"
require "asciidoctor-plantuml"
module Gitlab
@@ -9,9 +9,9 @@ module Gitlab
# the resulting HTML through HTML pipeline filters.
module Asciidoc
DEFAULT_ADOC_ATTRS = [
- 'showtitle', 'idprefix=user-content-', 'idseparator=-', 'env=gitlab',
- 'env-gitlab', 'source-highlighter=html-pipeline', 'icons=font',
- 'outfilesuffix=.adoc'
+ "showtitle", "idprefix=user-content-", "idseparator=-", "env=gitlab",
+ "env-gitlab", "source-highlighter=html-pipeline", "icons=font",
+ "outfilesuffix=.adoc",
].freeze
# Public: Converts the provided Asciidoc markup into HTML.
@@ -19,9 +19,9 @@ module Gitlab
# input - the source text in Asciidoc format
#
def self.render(input, context)
- asciidoc_opts = { safe: :secure,
- backend: :gitlab_html5,
- attributes: DEFAULT_ADOC_ATTRS }
+ asciidoc_opts = {safe: :secure,
+ backend: :gitlab_html5,
+ attributes: DEFAULT_ADOC_ATTRS,}
context[:pipeline] = :ascii_doc
@@ -44,7 +44,7 @@ module Gitlab
class Html5Converter < Asciidoctor::Converter::Html5Converter
extend Asciidoctor::Converter::Config
- register_for 'gitlab_html5'
+ register_for "gitlab_html5"
def stem(node)
return super unless node.style.to_sym == :latexmath
diff --git a/lib/gitlab/audit_json_logger.rb b/lib/gitlab/audit_json_logger.rb
index 12e0645f3e4..e9a41c0c746 100644
--- a/lib/gitlab/audit_json_logger.rb
+++ b/lib/gitlab/audit_json_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class AuditJsonLogger < Gitlab::JsonLogger
def self.file_name_noext
- 'audit_json'
+ "audit_json"
end
end
end
diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb
index b2ef04d23d7..fedbbaf6bb1 100644
--- a/lib/gitlab/auth.rb
+++ b/lib/gitlab/auth.rb
@@ -65,7 +65,7 @@ module Gitlab
authenticators = []
if user
- authenticators << Gitlab::Auth::OAuth::Provider.authentication(user, 'database')
+ authenticators << Gitlab::Auth::OAuth::Provider.authentication(user, "database")
# Add authenticators for all identities if user is not nil
user&.identities&.each do |identity|
@@ -119,14 +119,14 @@ module Gitlab
return unless project && matched_login.present?
- underscored_service = matched_login['service'].underscore
+ underscored_service = matched_login["service"].underscore
if Service.available_services_names.include?(underscored_service)
# We treat underscored_service as a trusted input because it is included
# in the Service.available_services_names whitelist.
service = project.public_send("#{underscored_service}_service") # rubocop:disable GitlabSecurity/PublicSend
- if service && service.activated? && service.valid_token?(password)
+ if service&.activated? && service&.valid_token?(password)
Gitlab::Auth::Result.new(nil, project, :ci, build_authentication_abilities)
end
end
@@ -157,7 +157,7 @@ module Gitlab
def personal_access_token_check(password)
return unless password.present?
- token = PersonalAccessTokensFinder.new(state: 'active').find_by_token(password)
+ token = PersonalAccessTokensFinder.new(state: "active").find_by_token(password)
if token && valid_scoped_token?(token, available_scopes)
Gitlab::Auth::Result.new(token.user, nil, :personal_access_token, abilities_for_scopes(token.scopes))
@@ -165,7 +165,7 @@ module Gitlab
end
def valid_oauth_token?(token)
- token && token.accessible? && valid_scoped_token?(token, [:api])
+ token&.accessible? && valid_scoped_token?(token, [:api])
end
def valid_scoped_token?(token, scopes)
@@ -176,12 +176,12 @@ module Gitlab
abilities_by_scope = {
api: full_authentication_abilities,
read_registry: [:read_container_image],
- read_repository: [:download_code]
+ read_repository: [:download_code],
}
- scopes.flat_map do |scope|
+ scopes.flat_map { |scope|
abilities_by_scope.fetch(scope.to_sym, [])
- end.uniq
+ }.uniq
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -231,7 +231,7 @@ module Gitlab
end
def build_access_token_check(login, password)
- return unless login == 'gitlab-ci-token'
+ return unless login == "gitlab-ci-token"
return unless password
build = find_build_by_token(password)
@@ -254,7 +254,7 @@ module Gitlab
:read_project,
:build_download_code,
:build_read_container_image,
- :build_create_container_image
+ :build_create_container_image,
]
end
@@ -262,20 +262,20 @@ module Gitlab
[
:read_project,
:download_code,
- :read_container_image
+ :read_container_image,
]
end
def read_write_authentication_abilities
read_authentication_abilities + [
:push_code,
- :create_container_image
+ :create_container_image,
]
end
def full_authentication_abilities
read_write_authentication_abilities + [
- :admin_container_image
+ :admin_container_image,
]
end
diff --git a/lib/gitlab/auth/activity.rb b/lib/gitlab/auth/activity.rb
index 558628b5422..d48b3d61501 100644
--- a/lib/gitlab/auth/activity.rb
+++ b/lib/gitlab/auth/activity.rb
@@ -9,15 +9,15 @@ module Gitlab
extend Gitlab::Utils::StrongMemoize
COUNTERS = {
- user_authenticated: 'Counter of successful authentication events',
- user_unauthenticated: 'Counter of authentication failures',
- user_not_found: 'Counter of failed log-ins when user is unknown',
- user_password_invalid: 'Counter of failed log-ins with invalid password',
- user_session_override: 'Counter of manual log-ins and sessions overrides',
- user_session_destroyed: 'Counter of user sessions being destroyed',
- user_two_factor_authenticated: 'Counter of two factor authentications',
- user_sessionless_authentication: 'Counter of sessionless authentications',
- user_blocked: 'Counter of sign in attempts when user is blocked'
+ user_authenticated: "Counter of successful authentication events",
+ user_unauthenticated: "Counter of authentication failures",
+ user_not_found: "Counter of failed log-ins when user is unknown",
+ user_password_invalid: "Counter of failed log-ins with invalid password",
+ user_session_override: "Counter of manual log-ins and sessions overrides",
+ user_session_destroyed: "Counter of user sessions being destroyed",
+ user_two_factor_authenticated: "Counter of two factor authentications",
+ user_sessionless_authentication: "Counter of sessionless authentications",
+ user_blocked: "Counter of sign in attempts when user is blocked",
}.freeze
def initialize(opts)
diff --git a/lib/gitlab/auth/blocked_user_tracker.rb b/lib/gitlab/auth/blocked_user_tracker.rb
index 50712d7eac2..fbed4af0525 100644
--- a/lib/gitlab/auth/blocked_user_tracker.rb
+++ b/lib/gitlab/auth/blocked_user_tracker.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Gitlab
module Auth
class BlockedUserTracker
diff --git a/lib/gitlab/auth/ip_rate_limiter.rb b/lib/gitlab/auth/ip_rate_limiter.rb
index 81e616fa20a..8bc2141e804 100644
--- a/lib/gitlab/auth/ip_rate_limiter.rb
+++ b/lib/gitlab/auth/ip_rate_limiter.rb
@@ -20,10 +20,10 @@ module Gitlab
def register_fail!
# Allow2Ban.filter will return false if this IP has not failed too often yet
- @banned = Rack::Attack::Allow2Ban.filter(ip, config) do
+ @banned = Rack::Attack::Allow2Ban.filter(ip, config) {
# If we return false here, the failure for this IP is ignored by Allow2Ban
ip_can_be_banned?
- end
+ }
end
def banned?
diff --git a/lib/gitlab/auth/ldap/access.rb b/lib/gitlab/auth/ldap/access.rb
index c875bba4bcb..bb3be78d527 100644
--- a/lib/gitlab/auth/ldap/access.rb
+++ b/lib/gitlab/auth/ldap/access.rb
@@ -12,12 +12,12 @@ module Gitlab
def self.open(user, &block)
Gitlab::Auth::LDAP::Adapter.open(user.ldap_identity.provider) do |adapter|
- block.call(self.new(user, adapter))
+ block.call(new(user, adapter))
end
end
def self.allowed?(user, options = {})
- self.open(user) do |access|
+ open(user) do |access|
# Whether user is allowed, or not, we should update
# permissions to keep things clean
if access.allowed?
@@ -43,21 +43,21 @@ module Gitlab
def allowed?
if ldap_user
unless ldap_config.active_directory
- unblock_user(user, 'is available again') if user.ldap_blocked?
+ unblock_user(user, "is available again") if user.ldap_blocked?
return true
end
# Block user in GitLab if he/she was blocked in AD
if Gitlab::Auth::LDAP::Person.disabled_via_active_directory?(ldap_identity.extern_uid, adapter)
- block_user(user, 'is disabled in Active Directory')
+ block_user(user, "is disabled in Active Directory")
false
else
- unblock_user(user, 'is not disabled anymore') if user.ldap_blocked?
+ unblock_user(user, "is not disabled anymore") if user.ldap_blocked?
true
end
else
# Block the user if they no longer exist in LDAP/AD
- block_user(user, 'does not exist anymore')
+ block_user(user, "does not exist anymore")
false
end
rescue LDAPConnectionError
diff --git a/lib/gitlab/auth/ldap/adapter.rb b/lib/gitlab/auth/ldap/adapter.rb
index 15b9d5ad6e9..23b880b6a0b 100644
--- a/lib/gitlab/auth/ldap/adapter.rb
+++ b/lib/gitlab/auth/ldap/adapter.rb
@@ -11,7 +11,7 @@ module Gitlab
def self.open(provider, &block)
Net::LDAP.open(config(provider).adapter_options) do |ldap|
- block.call(self.new(provider, ldap))
+ block.call(new(provider, ldap))
end
end
@@ -41,7 +41,7 @@ module Gitlab
ldap_search(base: dn,
filter: filter,
scope: Net::LDAP::SearchScope_BaseObject,
- attributes: %w{dn}).any?
+ attributes: %w[dn]).any?
end
def ldap_search(*args)
@@ -84,9 +84,9 @@ module Gitlab
end
def users_search(options)
- entries = ldap_search(options).select do |entry|
+ entries = ldap_search(options).select { |entry|
entry.respond_to? config.uid
- end
+ }
entries.map do |entry|
Gitlab::Auth::LDAP::Person.new(entry, provider)
@@ -96,13 +96,13 @@ module Gitlab
def user_options(fields, value, limit)
options = {
attributes: Gitlab::Auth::LDAP::Person.ldap_attributes(config),
- base: config.base
+ base: config.base,
}
options[:size] = limit if limit
- if fields.include?('dn')
- raise ArgumentError, 'It is not currently possible to search the DN and other fields at the same time.' if fields.size > 1
+ if fields.include?("dn")
+ raise ArgumentError, "It is not currently possible to search the DN and other fields at the same time." if fields.size > 1
options[:base] = value
options[:scope] = Net::LDAP::SearchScope_BaseObject
diff --git a/lib/gitlab/auth/ldap/auth_hash.rb b/lib/gitlab/auth/ldap/auth_hash.rb
index 83fdc8a8c76..8b592a7fd0e 100644
--- a/lib/gitlab/auth/ldap/auth_hash.rb
+++ b/lib/gitlab/auth/ldap/auth_hash.rb
@@ -42,7 +42,7 @@ module Gitlab
end
def ldap_config
- @ldap_config ||= Gitlab::Auth::LDAP::Config.new(self.provider)
+ @ldap_config ||= Gitlab::Auth::LDAP::Config.new(provider)
end
end
end
diff --git a/lib/gitlab/auth/ldap/config.rb b/lib/gitlab/auth/ldap/config.rb
index 7ceb96f502b..c7e464b139c 100644
--- a/lib/gitlab/auth/ldap/config.rb
+++ b/lib/gitlab/auth/ldap/config.rb
@@ -7,8 +7,8 @@ module Gitlab
class Config
NET_LDAP_ENCRYPTION_METHOD = {
simple_tls: :simple_tls,
- start_tls: :start_tls,
- plain: nil
+ start_tls: :start_tls,
+ plain: nil,
}.freeze
attr_accessor :provider, :options
@@ -20,7 +20,7 @@ module Gitlab
end
def self.servers
- Gitlab.config.ldap['servers']&.values || []
+ Gitlab.config.ldap["servers"]&.values || []
end
def self.available_servers
@@ -34,7 +34,7 @@ module Gitlab
end
def self.providers
- servers.map { |server| server['provider_name'] }
+ servers.map { |server| server["provider_name"] }
end
def self.valid_provider?(provider)
@@ -72,35 +72,33 @@ module Gitlab
def omniauth_options
opts = base_options.merge(
base: base,
- encryption: options['encryption'],
+ encryption: options["encryption"],
filter: omniauth_user_filter,
name_proc: name_proc,
- disable_verify_certificates: !options['verify_certificates']
+ disable_verify_certificates: !options["verify_certificates"]
)
if has_auth?
- opts.merge!(
- bind_dn: options['bind_dn'],
- password: options['password']
- )
+ opts[:bind_dn] = options["bind_dn"]
+ opts[:password] = options["password"]
end
- opts[:ca_file] = options['ca_file'] if options['ca_file'].present?
- opts[:ssl_version] = options['ssl_version'] if options['ssl_version'].present?
+ opts[:ca_file] = options["ca_file"] if options["ca_file"].present?
+ opts[:ssl_version] = options["ssl_version"] if options["ssl_version"].present?
opts
end
def base
- @base ||= Person.normalize_dn(options['base'])
+ @base ||= Person.normalize_dn(options["base"])
end
def uid
- options['uid']
+ options["uid"]
end
def label
- options['label']
+ options["label"]
end
def sync_ssh_keys?
@@ -109,11 +107,11 @@ module Gitlab
# The LDAP attribute in which the ssh keys are stored
def sync_ssh_keys
- options['sync_ssh_keys']
+ options["sync_ssh_keys"]
end
def user_filter
- options['user_filter']
+ options["user_filter"]
end
def constructed_user_filter
@@ -121,48 +119,48 @@ module Gitlab
end
def group_base
- options['group_base']
+ options["group_base"]
end
def admin_group
- options['admin_group']
+ options["admin_group"]
end
def active_directory
- options['active_directory']
+ options["active_directory"]
end
def block_auto_created_users
- options['block_auto_created_users']
+ options["block_auto_created_users"]
end
def attributes
- default_attributes.merge(options['attributes'])
+ default_attributes.merge(options["attributes"])
end
def timeout
- options['timeout'].to_i
+ options["timeout"].to_i
end
def external_groups
- options['external_groups'] || []
+ options["external_groups"] || []
end
def has_auth?
- options['password'] || options['bind_dn']
+ options["password"] || options["bind_dn"]
end
def allow_username_or_email_login
- options['allow_username_or_email_login']
+ options["allow_username_or_email_login"]
end
def lowercase_usernames
- options['lowercase_usernames']
+ options["lowercase_usernames"]
end
def name_proc
if allow_username_or_email_login
- proc { |name| name.gsub(/@.*\z/, '') }
+ proc { |name| name.gsub(/@.*\z/, "") }
else
proc { |name| name }
end
@@ -170,11 +168,11 @@ module Gitlab
def default_attributes
{
- 'username' => %w(uid sAMAccountName userid),
- 'email' => %w(mail email userPrincipalName),
- 'name' => 'cn',
- 'first_name' => 'givenName',
- 'last_name' => 'sn'
+ "username" => %w[uid sAMAccountName userid],
+ "email" => %w[mail email userPrincipalName],
+ "name" => "cn",
+ "first_name" => "givenName",
+ "last_name" => "sn",
}
end
@@ -182,8 +180,8 @@ module Gitlab
def base_options
{
- host: options['host'],
- port: options['port']
+ host: options["host"],
+ port: options["port"],
}
end
@@ -192,16 +190,16 @@ module Gitlab
end
def config_for(provider)
- base_config.servers.values.find { |server| server['provider_name'] == provider }
+ base_config.servers.values.find { |server| server["provider_name"] == provider }
end
def encryption_options
- method = translate_method(options['encryption'])
+ method = translate_method(options["encryption"])
return nil unless method
{
method: method,
- tls_options: tls_options(method)
+ tls_options: tls_options(method),
}
end
@@ -210,20 +208,20 @@ module Gitlab
end
def tls_options(method)
- return { verify_mode: OpenSSL::SSL::VERIFY_NONE } unless method
+ return {verify_mode: OpenSSL::SSL::VERIFY_NONE} unless method
- opts = if options['verify_certificates']
- OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
- else
- # It is important to explicitly set verify_mode for two reasons:
- # 1. The behavior of OpenSSL is undefined when verify_mode is not set.
- # 2. The net-ldap gem implementation verifies the certificate hostname
- # unless verify_mode is set to VERIFY_NONE.
- { verify_mode: OpenSSL::SSL::VERIFY_NONE }
- end
+ opts = if options["verify_certificates"]
+ OpenSSL::SSL::SSLContext::DEFAULT_PARAMS
+ else
+ # It is important to explicitly set verify_mode for two reasons:
+ # 1. The behavior of OpenSSL is undefined when verify_mode is not set.
+ # 2. The net-ldap gem implementation verifies the certificate hostname
+ # unless verify_mode is set to VERIFY_NONE.
+ {verify_mode: OpenSSL::SSL::VERIFY_NONE}
+ end
- opts[:ca_file] = options['ca_file'] if options['ca_file'].present?
- opts[:ssl_version] = options['ssl_version'] if options['ssl_version'].present?
+ opts[:ca_file] = options["ca_file"] if options["ca_file"].present?
+ opts[:ssl_version] = options["ssl_version"] if options["ssl_version"].present?
opts
end
@@ -232,14 +230,14 @@ module Gitlab
{
auth: {
method: :simple,
- username: options['bind_dn'],
- password: options['password']
- }
+ username: options["bind_dn"],
+ password: options["password"],
+ },
}
end
def omniauth_user_filter
- uid_filter = Net::LDAP::Filter.eq(uid, '%{username}')
+ uid_filter = Net::LDAP::Filter.eq(uid, "%{username}")
if user_filter.present?
Net::LDAP::Filter.join(uid_filter, constructed_user_filter).to_s
diff --git a/lib/gitlab/auth/ldap/dn.rb b/lib/gitlab/auth/ldap/dn.rb
index 5df914aa367..669493e1f89 100644
--- a/lib/gitlab/auth/ldap/dn.rb
+++ b/lib/gitlab/auth/ldap/dn.rb
@@ -1,4 +1,3 @@
-# -*- ruby encoding: utf-8 -*-
# frozen_string_literal: true
# Based on the `ruby-net-ldap` gem's `Net::LDAP::DN`
@@ -31,7 +30,7 @@ module Gitlab
def self.normalize_value(given_value)
dummy_dn = "placeholder=#{given_value}"
normalized_dn = new(*dummy_dn).to_normalized_s
- normalized_dn.sub(/\Aplaceholder=/, '')
+ normalized_dn.sub(/\Aplaceholder=/, "")
end
##
@@ -66,36 +65,36 @@ module Gitlab
case state
when :key then
case char
- when 'a'..'z', 'A'..'Z' then
+ when "a".."z", "A".."Z" then
state = :key_normal
key << char
- when '0'..'9' then
+ when "0".."9" then
state = :key_oid
key << char
- when ' ' then state = :key
+ when " " then state = :key
else raise(MalformedError, "Unrecognized first character of an RDN attribute type name \"#{char}\"")
end
when :key_normal then
case char
- when '=' then state = :value
- when 'a'..'z', 'A'..'Z', '0'..'9', '-', ' ' then key << char
+ when "=" then state = :value
+ when "a".."z", "A".."Z", "0".."9", "-", " " then key << char
else raise(MalformedError, "Unrecognized RDN attribute type name character \"#{char}\"")
end
when :key_oid then
case char
- when '=' then state = :value
- when '0'..'9', '.', ' ' then key << char
+ when "=" then state = :value
+ when "0".."9", ".", " " then key << char
else raise(MalformedError, "Unrecognized RDN OID attribute type name character \"#{char}\"")
end
when :value then
case char
when '\\' then state = :value_normal_escape
when '"' then state = :value_quoted
- when ' ' then state = :value
- when '#' then
+ when " " then state = :value
+ when "#" then
state = :value_hexstring
value << char
- when ',' then
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -107,17 +106,17 @@ module Gitlab
when :value_normal then
case char
when '\\' then state = :value_normal_escape
- when ',' then
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
value = StringIO.new
- when '+' then raise(UnsupportedError, "Multivalued RDNs are not supported")
+ when "+" then raise(UnsupportedError, "Multivalued RDNs are not supported")
else value << char
end
when :value_normal_escape then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_normal_escape_hex
hex_buffer = char
else
@@ -126,7 +125,7 @@ module Gitlab
end
when :value_normal_escape_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_normal
value << "#{hex_buffer}#{char}".to_i(16).chr
else raise(MalformedError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"")
@@ -139,7 +138,7 @@ module Gitlab
end
when :value_quoted_escape then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_quoted_escape_hex
hex_buffer = char
else
@@ -148,18 +147,18 @@ module Gitlab
end
when :value_quoted_escape_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_quoted
value << "#{hex_buffer}#{char}".to_i(16).chr
else raise(MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"#{char}\"")
end
when :value_hexstring then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_hexstring_hex
value << char
- when ' ' then state = :value_end
- when ',' then
+ when " " then state = :value_end
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -168,15 +167,15 @@ module Gitlab
end
when :value_hexstring_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_hexstring
value << char
else raise(MalformedError, "Expected the second character of a hex pair, but got \"#{char}\"")
end
when :value_end then
case char
- when ' ' then state = :value_end
- when ',' then
+ when " " then state = :value_end
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -188,7 +187,7 @@ module Gitlab
end
# Last pair
- raise(MalformedError, 'DN string ended unexpectedly') unless
+ raise(MalformedError, "DN string ended unexpectedly") unless
[:value, :value_normal, :value_hexstring, :value_end].include? state
yield key.string.strip, rstrip_except_escaped(value.string, @dn.length)
@@ -216,7 +215,7 @@ module Gitlab
# Returns the DN as an array in the form expected by the constructor.
def to_a
a = []
- self.each_pair { |key, value| a << key << value } unless @dn.empty?
+ each_pair { |key, value| a << key << value } unless @dn.empty?
a
end
@@ -237,12 +236,12 @@ module Gitlab
# using a single backslash ('\') as escape. The space character is left
# out here because in a "normalized" string, spaces should only be escaped
# if necessary (i.e. leading or trailing space).
- NORMAL_ESCAPES = [',', '+', '"', '\\', '<', '>', ';', '='].freeze
+ NORMAL_ESCAPES = [",", "+", '"', '\\', "<", ">", ";", "="].freeze
# The following must be represented as escaped hex
HEX_ESCAPES = {
"\n" => '\0a',
- "\r" => '\0d'
+ "\r" => '\0d',
}.freeze
# Compiled character class regexp using the keys from the above hash, and
diff --git a/lib/gitlab/auth/ldap/person.rb b/lib/gitlab/auth/ldap/person.rb
index 48d134f91b0..03357581869 100644
--- a/lib/gitlab/auth/ldap/person.rb
+++ b/lib/gitlab/auth/ldap/person.rb
@@ -19,11 +19,11 @@ module Gitlab
end
def self.find_by_dn(dn, adapter)
- adapter.user('dn', dn)
+ adapter.user("dn", dn)
end
def self.find_by_email(email, adapter)
- email_fields = adapter.config.attributes['email']
+ email_fields = adapter.config.attributes["email"]
adapter.user(email_fields, email)
end
@@ -34,11 +34,11 @@ module Gitlab
def self.ldap_attributes(config)
[
- 'dn',
+ "dn",
config.uid,
- *config.attributes['name'],
- *config.attributes['email'],
- *config.attributes['username']
+ *config.attributes["name"],
+ *config.attributes["email"],
+ *config.attributes["username"],
].compact.uniq
end
diff --git a/lib/gitlab/auth/ldap/user.rb b/lib/gitlab/auth/ldap/user.rb
index 9c71671f409..44d508f17dc 100644
--- a/lib/gitlab/auth/ldap/user.rb
+++ b/lib/gitlab/auth/ldap/user.rb
@@ -17,13 +17,13 @@ module Gitlab
def find_by_uid_and_provider(uid, provider)
identity = ::Identity.with_extern_uid(provider, uid).take
- identity && identity.user
+ identity&.user
end
# rubocop: enable CodeReuse/ActiveRecord
end
def save
- super('LDAP')
+ super("LDAP")
end
# instance methods
diff --git a/lib/gitlab/auth/o_auth/auth_hash.rb b/lib/gitlab/auth/o_auth/auth_hash.rb
index 36fc8061d92..2898c949438 100644
--- a/lib/gitlab/auth/o_auth/auth_hash.rb
+++ b/lib/gitlab/auth/o_auth/auth_hash.rb
@@ -38,7 +38,7 @@ module Gitlab
def location
location = get_info(:address)
if location.is_a?(Hash)
- [location.locality.presence, location.country.presence].compact.join(', ')
+ [location.locality.presence, location.country.presence].compact.join(", ")
else
location
end
@@ -74,7 +74,7 @@ module Gitlab
{
username: username,
- email: email
+ email: email,
}
end
end
@@ -82,7 +82,7 @@ module Gitlab
# Get the first part of the email address (before @)
# In addition in removes illegal characters
def generate_username(email)
- email.match(/^[^@]*/)[0].mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/, '').to_s
+ email.match(/^[^@]*/)[0].mb_chars.normalize(:kd).gsub(/[^\x00-\x7F]/, "").to_s
end
def generate_temporarily_email(username)
diff --git a/lib/gitlab/auth/o_auth/provider.rb b/lib/gitlab/auth/o_auth/provider.rb
index 9fdf3324db3..497746fbaa2 100644
--- a/lib/gitlab/auth/o_auth/provider.rb
+++ b/lib/gitlab/auth/o_auth/provider.rb
@@ -5,9 +5,9 @@ module Gitlab
module OAuth
class Provider
LABELS = {
- "github" => "GitHub",
- "gitlab" => "GitLab.com",
- "google_oauth2" => "Google"
+ "github" => "GitHub",
+ "gitlab" => "GitLab.com",
+ "google_oauth2" => "Google",
}.freeze
def self.authentication(user, provider)
@@ -18,7 +18,7 @@ module Gitlab
case provider
when /^ldap/
Gitlab::Auth::LDAP::Authentication
- when 'database'
+ when "database"
Gitlab::Auth::Database::Authentication
end
@@ -30,14 +30,14 @@ module Gitlab
end
def self.enabled?(name)
- return true if name == 'database'
- return true if self.ldap_provider?(name) && providers.include?(name.to_sym)
+ return true if name == "database"
+ return true if ldap_provider?(name) && providers.include?(name.to_sym)
Gitlab::Auth.omniauth_enabled? && providers.include?(name.to_sym)
end
def self.ldap_provider?(name)
- name.to_s.start_with?('ldap')
+ name.to_s.start_with?("ldap")
end
def self.sync_profile_from_provider?(provider)
@@ -57,8 +57,6 @@ module Gitlab
if ldap_provider?(name)
if Gitlab::Auth::LDAP::Config.valid_provider?(name)
Gitlab::Auth::LDAP::Config.new(name).options
- else
- nil
end
else
Gitlab.config.omniauth.providers.find { |provider| provider.name == name }
@@ -68,7 +66,7 @@ module Gitlab
def self.label_for(name)
name = name.to_s
config = config_for(name)
- (config && config['label']) || LABELS[name] || name.titleize
+ (config && config["label"]) || LABELS[name] || name.titleize
end
end
end
diff --git a/lib/gitlab/auth/o_auth/user.rb b/lib/gitlab/auth/o_auth/user.rb
index f38c5d57c44..222700d4615 100644
--- a/lib/gitlab/auth/o_auth/user.rb
+++ b/lib/gitlab/auth/o_auth/user.rb
@@ -36,7 +36,7 @@ module Gitlab
valid? && persisted?
end
- def save(provider = 'OAuth')
+ def save(provider = "OAuth")
raise SigninDisabledForProviderError if oauth_provider_disabled?
raise SignupDisabledError unless gl_user
@@ -146,7 +146,6 @@ module Gitlab
Gitlab::Auth::LDAP::Person.find_by_uid(auth_hash.uid, adapter) ||
Gitlab::Auth::LDAP::Person.find_by_email(auth_hash.uid, adapter) ||
Gitlab::Auth::LDAP::Person.find_by_dn(auth_hash.uid, adapter)
-
rescue Gitlab::Auth::LDAP::LDAPConnectionError
nil
end
@@ -215,12 +214,12 @@ module Gitlab
name = valid_username if name.strip.empty?
{
- name: name,
- username: valid_username,
- email: email,
- password: auth_hash.password,
- password_confirmation: auth_hash.password,
- password_automatically_set: true
+ name: name,
+ username: valid_username,
+ email: email,
+ password: auth_hash.password,
+ password_confirmation: auth_hash.password,
+ password_automatically_set: true,
}
end
@@ -264,8 +263,8 @@ module Gitlab
def oauth_provider_disabled?
Gitlab::CurrentSettings.current_application_settings
- .disabled_oauth_sign_in_sources
- .include?(auth_hash.provider)
+ .disabled_oauth_sign_in_sources
+ .include?(auth_hash.provider)
end
end
end
diff --git a/lib/gitlab/auth/omniauth_identity_linker_base.rb b/lib/gitlab/auth/omniauth_identity_linker_base.rb
index 253445570f2..c9c2d83716a 100644
--- a/lib/gitlab/auth/omniauth_identity_linker_base.rb
+++ b/lib/gitlab/auth/omniauth_identity_linker_base.rb
@@ -26,7 +26,7 @@ module Gitlab
def error_message
identity.validate
- identity.errors.full_messages.join(', ')
+ identity.errors.full_messages.join(", ")
end
private
@@ -38,17 +38,17 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def identity
@identity ||= current_user.identities
- .with_extern_uid(provider, uid)
- .first_or_initialize(extern_uid: uid)
+ .with_extern_uid(provider, uid)
+ .first_or_initialize(extern_uid: uid)
end
# rubocop: enable CodeReuse/ActiveRecord
def provider
- oauth['provider']
+ oauth["provider"]
end
def uid
- oauth['uid']
+ oauth["uid"]
end
end
end
diff --git a/lib/gitlab/auth/result.rb b/lib/gitlab/auth/result.rb
index 78fa25c5516..93bc3adc0ae 100644
--- a/lib/gitlab/auth/result.rb
+++ b/lib/gitlab/auth/result.rb
@@ -3,7 +3,7 @@
module Gitlab
module Auth
- Result = Struct.new(:actor, :project, :type, :authentication_abilities) do
+ Result = Struct.new(:actor, :project, :type, :authentication_abilities) {
def ci?(for_project)
type == :ci &&
project &&
@@ -22,6 +22,6 @@ module Gitlab
def failed?
!success?
end
- end
+ }
end
end
diff --git a/lib/gitlab/auth/saml/config.rb b/lib/gitlab/auth/saml/config.rb
index 8cb999f50d4..6717375775f 100644
--- a/lib/gitlab/auth/saml/config.rb
+++ b/lib/gitlab/auth/saml/config.rb
@@ -6,7 +6,7 @@ module Gitlab
class Config
class << self
def options
- Gitlab::Auth::OAuth::Provider.config_for('saml')
+ Gitlab::Auth::OAuth::Provider.config_for("saml")
end
def upstream_two_factor_authn_contexts
diff --git a/lib/gitlab/auth/saml/user.rb b/lib/gitlab/auth/saml/user.rb
index ec95bc46791..e664ee57153 100644
--- a/lib/gitlab/auth/saml/user.rb
+++ b/lib/gitlab/auth/saml/user.rb
@@ -12,7 +12,7 @@ module Gitlab
extend ::Gitlab::Utils::Override
def save
- super('SAML')
+ super("SAML")
end
def find_user
diff --git a/lib/gitlab/auth/unique_ips_limiter.rb b/lib/gitlab/auth/unique_ips_limiter.rb
index 31dd61ae6cf..717c3e0266f 100644
--- a/lib/gitlab/auth/unique_ips_limiter.rb
+++ b/lib/gitlab/auth/unique_ips_limiter.rb
@@ -3,7 +3,7 @@
module Gitlab
module Auth
class UniqueIpsLimiter
- USER_UNIQUE_IPS_PREFIX = 'user_unique_ips'.freeze
+ USER_UNIQUE_IPS_PREFIX = "user_unique_ips"
class << self
def limit_user_id!(user_id)
diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb
index a5efe33bdc6..d0eb2854b78 100644
--- a/lib/gitlab/auth/user_auth_finders.rb
+++ b/lib/gitlab/auth/user_auth_finders.rb
@@ -20,12 +20,12 @@ module Gitlab
module UserAuthFinders
include Gitlab::Utils::StrongMemoize
- PRIVATE_TOKEN_HEADER = 'HTTP_PRIVATE_TOKEN'.freeze
+ PRIVATE_TOKEN_HEADER = "HTTP_PRIVATE_TOKEN"
PRIVATE_TOKEN_PARAM = :private_token
# Check the Rails session for valid authentication details
def find_user_from_warden
- current_request.env['warden']&.authenticate if verified_request?
+ current_request.env["warden"]&.authenticate if verified_request?
end
def find_user_from_feed_token(request_format)
@@ -144,11 +144,11 @@ module Gitlab
end
def rss_request?
- current_request.path.ends_with?('.atom') || current_request.format.atom?
+ current_request.path.ends_with?(".atom") || current_request.format.atom?
end
def ics_request?
- current_request.path.ends_with?('.ics') || current_request.format.ics?
+ current_request.path.ends_with?(".ics") || current_request.format.ics?
end
def api_request?
diff --git a/lib/gitlab/background_migration.rb b/lib/gitlab/background_migration.rb
index 5251e0fadf9..402d3e8f3f7 100644
--- a/lib/gitlab/background_migration.rb
+++ b/lib/gitlab/background_migration.rb
@@ -3,7 +3,7 @@
module Gitlab
module BackgroundMigration
def self.queue
- @queue ||= BackgroundMigrationWorker.sidekiq_options['queue']
+ @queue ||= BackgroundMigrationWorker.sidekiq_options["queue"]
end
# Begins stealing jobs from the background migrations queue, blocking the
@@ -19,7 +19,7 @@ module Gitlab
def self.steal(steal_class, retry_dead_jobs: false)
queues = [
Sidekiq::ScheduledSet.new,
- Sidekiq::Queue.new(self.queue)
+ Sidekiq::Queue.new(queue),
]
if retry_dead_jobs
@@ -59,7 +59,7 @@ module Gitlab
end
def self.exists?(migration_class)
- enqueued = Sidekiq::Queue.new(self.queue)
+ enqueued = Sidekiq::Queue.new(queue)
scheduled = Sidekiq::ScheduledSet.new
[enqueued, scheduled].each do |queue|
diff --git a/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb b/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb
index cb2bdea755c..460c48a8fba 100644
--- a/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb
+++ b/lib/gitlab/background_migration/add_merge_request_diff_commits_count.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class AddMergeRequestDiffCommitsCount
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
end
def perform(start_id, stop_id)
diff --git a/lib/gitlab/background_migration/archive_legacy_traces.rb b/lib/gitlab/background_migration/archive_legacy_traces.rb
index 92096e29ef1..270631d8998 100644
--- a/lib/gitlab/background_migration/archive_legacy_traces.rb
+++ b/lib/gitlab/background_migration/archive_legacy_traces.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -11,11 +12,10 @@ module Gitlab
# So we chose a way to use ::Ci::Build directly and we don't change the `archive!` method until 11.1
::Ci::Build.finished.without_archived_trace
.where(id: start_id..stop_id).find_each do |build|
- begin
- build.trace.archive!
- rescue => e
- Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}"
- end
+
+ build.trace.archive!
+ rescue => e
+ Rails.logger.error "Failed to archive live trace. id: #{build.id} message: #{e.message}"
end
end
end
diff --git a/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb b/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb
index 29fa0f18448..f7ec7b62363 100644
--- a/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb
+++ b/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config.rb
@@ -14,7 +14,7 @@ module Gitlab
class HashedProject
attr_accessor :project
- ROOT_PATH_PREFIX = '@hashed'
+ ROOT_PATH_PREFIX = "@hashed"
def initialize(project)
@project = project
@@ -57,7 +57,7 @@ module Gitlab
raise OrphanedNamespaceError if parent.nil?
- parent.full_path + '/' + path
+ parent.full_path + "/" + path
end
def has_parent?
@@ -82,30 +82,30 @@ module Gitlab
# Namespace can be a user or group. It can be the root or a
# child of another namespace.
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
self.inheritance_column = nil
include Routable
- belongs_to :parent, class_name: 'Namespace', inverse_of: 'namespaces'
+ belongs_to :parent, class_name: "Namespace", inverse_of: "namespaces"
has_many :projects, inverse_of: :parent
has_many :namespaces, inverse_of: :parent
end
# Project is where the repository (etc.) is stored
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include Routable
include EachBatch
- FULLPATH_CONFIG_KEY = 'gitlab.fullpath'
+ FULLPATH_CONFIG_KEY = "gitlab.fullpath"
- belongs_to :parent, class_name: 'Namespace', foreign_key: :namespace_id, inverse_of: 'projects'
+ belongs_to :parent, class_name: "Namespace", foreign_key: :namespace_id, inverse_of: "projects"
delegate :disk_path, to: :storage
def add_fullpath_config
- entries = { FULLPATH_CONFIG_KEY => full_path }
+ entries = {FULLPATH_CONFIG_KEY => full_path}
repository_service.set_config(entries)
end
@@ -128,11 +128,11 @@ module Gitlab
end
def hashed_storage?
- self.storage_version && self.storage_version >= 1
+ storage_version && storage_version >= 1
end
def repository
- @repository ||= Repository.new(repository_storage, disk_path + '.git')
+ @repository ||= Repository.new(repository_storage, disk_path + ".git")
end
def repository_service
diff --git a/lib/gitlab/background_migration/backfill_project_repositories.rb b/lib/gitlab/background_migration/backfill_project_repositories.rb
index c8d83cc1803..6f2e71c8c7f 100644
--- a/lib/gitlab/background_migration/backfill_project_repositories.rb
+++ b/lib/gitlab/background_migration/backfill_project_repositories.rb
@@ -9,7 +9,7 @@ module Gitlab
# Shard model
class Shard < ActiveRecord::Base
- self.table_name = 'shards'
+ self.table_name = "shards"
end
# Class that will find or create the shard by name.
@@ -49,7 +49,7 @@ module Gitlab
class HashedProject
attr_accessor :project
- ROOT_PATH_PREFIX = '@hashed'
+ ROOT_PATH_PREFIX = "@hashed"
def initialize(project)
@project = project
@@ -91,7 +91,7 @@ module Gitlab
raise OrphanedNamespaceError if parent.nil?
- parent.full_path + '/' + path
+ parent.full_path + "/" + path
end
def has_parent?
@@ -106,14 +106,14 @@ module Gitlab
# Namespace model
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
self.inheritance_column = nil
include Routable
- belongs_to :parent, class_name: 'Namespace', inverse_of: 'namespaces'
+ belongs_to :parent, class_name: "Namespace", inverse_of: "namespaces"
- has_one :route, -> { where(source_type: 'Namespace') }, inverse_of: :source, foreign_key: :source_id
+ has_one :route, -> { where(source_type: "Namespace") }, inverse_of: :source, foreign_key: :source_id
has_many :projects, inverse_of: :parent
has_many :namespaces, inverse_of: :parent
@@ -121,27 +121,27 @@ module Gitlab
# ProjectRegistry model
class ProjectRepository < ActiveRecord::Base
- self.table_name = 'project_repositories'
+ self.table_name = "project_repositories"
belongs_to :project, inverse_of: :project_repository
end
# Project model
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
include Routable
HASHED_STORAGE_FEATURES = {
repository: 1,
- attachments: 2
+ attachments: 2,
}.freeze
scope :with_parent, -> { includes(:parent) }
- belongs_to :parent, class_name: 'Namespace', foreign_key: :namespace_id, inverse_of: 'projects'
+ belongs_to :parent, class_name: "Namespace", foreign_key: :namespace_id, inverse_of: "projects"
- has_one :route, -> { where(source_type: 'Project') }, inverse_of: :source, foreign_key: :source_id
+ has_one :route, -> { where(source_type: "Project") }, inverse_of: :source, foreign_key: :source_id
has_one :project_repository, inverse_of: :project
delegate :disk_path, to: :storage
@@ -183,8 +183,8 @@ module Gitlab
end
def hashed_storage?
- self.storage_version &&
- self.storage_version >= HASHED_STORAGE_FEATURES[:repository]
+ storage_version &&
+ storage_version >= HASHED_STORAGE_FEATURES[:repository]
end
end
@@ -212,8 +212,8 @@ module Gitlab
def build_attributes_for_project(project)
{
project_id: project.id,
- shard_id: find_shard_id(project.repository_storage),
- disk_path: project.disk_path
+ shard_id: find_shard_id(project.repository_storage),
+ disk_path: project.disk_path,
}
end
diff --git a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb b/lib/gitlab/background_migration/create_fork_network_memberships_range.rb
index ccd1f9b4dba..4387307d416 100644
--- a/lib/gitlab/background_migration/create_fork_network_memberships_range.rb
+++ b/lib/gitlab/background_migration/create_fork_network_memberships_range.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -7,7 +8,7 @@ module Gitlab
RESCHEDULE_DELAY = 15
class ForkedProjectLink < ActiveRecord::Base
- self.table_name = 'forked_project_links'
+ self.table_name = "forked_project_links"
end
def perform(start_id, end_id)
diff --git a/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb b/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb
index da8265a3a5f..4602b12dfbd 100644
--- a/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb
+++ b/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
class Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys
class GpgKey < ActiveRecord::Base
- self.table_name = 'gpg_keys'
+ self.table_name = "gpg_keys"
include EachBatch
include ShaAttribute
@@ -11,11 +12,11 @@ class Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys
sha_attribute :primary_keyid
sha_attribute :fingerprint
- has_many :subkeys, class_name: 'GpgKeySubkey'
+ has_many :subkeys, class_name: "GpgKeySubkey"
end
class GpgKeySubkey < ActiveRecord::Base
- self.table_name = 'gpg_key_subkeys'
+ self.table_name = "gpg_key_subkeys"
include ShaAttribute
diff --git a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb
index 21b626dde56..a1bc7fc3ec1 100644
--- a/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb
+++ b/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
diff --git a/lib/gitlab/background_migration/delete_diff_files.rb b/lib/gitlab/background_migration/delete_diff_files.rb
index 664ead1af44..879e77a5bcc 100644
--- a/lib/gitlab/background_migration/delete_diff_files.rb
+++ b/lib/gitlab/background_migration/delete_diff_files.rb
@@ -1,18 +1,19 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class DeleteDiffFiles
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
belongs_to :merge_request
has_many :merge_request_diff_files
end
class MergeRequestDiffFile < ActiveRecord::Base
- self.table_name = 'merge_request_diff_files'
+ self.table_name = "merge_request_diff_files"
end
DEAD_TUPLES_THRESHOLD = 50_000
@@ -53,7 +54,7 @@ module Gitlab
execute_statement("SELECT n_dead_tup FROM pg_stat_all_tables "\
"WHERE relname = 'merge_request_diff_files'")[0]
- dead_tuple&.fetch('n_dead_tup', 0).to_i
+ dead_tuple&.fetch("n_dead_tup", 0).to_i
end
def prune_diff_files
@@ -61,7 +62,7 @@ module Gitlab
updated = 0
MergeRequestDiff.transaction do
- updated = diffs_collection.update_all(state: 'without_files')
+ updated = diffs_collection.update_all(state: "without_files")
removed = MergeRequestDiffFile.where(merge_request_diff_id: @ids).delete_all
end
diff --git a/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb b/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb
index 58df74cfa9b..9c50fa1fe37 100644
--- a/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb
+++ b/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
# rubocop:disable Style/Documentation
@@ -15,7 +16,7 @@ module Gitlab
end
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
end
BUFFER_ROWS = 1000
@@ -23,9 +24,9 @@ module Gitlab
def perform(start_id, stop_id)
merge_request_diffs = MergeRequestDiff
- .select(:id, :st_commits, :st_diffs)
- .where('st_commits IS NOT NULL OR st_diffs IS NOT NULL')
- .where(id: start_id..stop_id)
+ .select(:id, :st_commits, :st_diffs)
+ .where("st_commits IS NOT NULL OR st_diffs IS NOT NULL")
+ .where(id: start_id..stop_id)
reset_buffers!
@@ -62,11 +63,11 @@ module Gitlab
def flush_buffers!
if diff_ids.any?
commit_rows.each_slice(BUFFER_ROWS).each do |commit_rows_slice|
- bulk_insert('merge_request_diff_commits', commit_rows_slice)
+ bulk_insert("merge_request_diff_commits", commit_rows_slice)
end
file_rows.each_slice(DIFF_FILE_BUFFER_ROWS).each do |file_rows_slice|
- bulk_insert('merge_request_diff_files', file_rows_slice)
+ bulk_insert("merge_request_diff_files", file_rows_slice)
end
MergeRequestDiff.where(id: diff_ids).update_all(st_commits: nil, st_diffs: nil)
@@ -85,10 +86,14 @@ module Gitlab
def single_diff_rows(merge_request_diff)
sha_attribute = Gitlab::Database::ShaAttribute.new
- commits = YAML.load(merge_request_diff.st_commits) rescue []
+ commits = begin
+ YAML.load(merge_request_diff.st_commits)
+ rescue
+ []
+ end
commits ||= []
- commit_rows = commits.map.with_index do |commit, index|
+ commit_rows = commits.map.with_index { |commit, index|
commit_hash = commit.to_hash.with_indifferent_access.except(:parent_ids)
sha = commit_hash.delete(:id)
@@ -97,12 +102,16 @@ module Gitlab
relative_order: index,
sha: sha_attribute.serialize(sha)
)
- end
+ }
- diffs = YAML.load(merge_request_diff.st_diffs) rescue []
+ diffs = begin
+ YAML.load(merge_request_diff.st_diffs)
+ rescue
+ []
+ end
diffs = [] unless valid_raw_diffs?(diffs)
- file_rows = diffs.map.with_index do |diff, index|
+ file_rows = diffs.map.with_index { |diff, index|
diff_hash = diff.to_hash.with_indifferent_access.merge(
binary: false,
merge_request_diff_id: merge_request_diff.id,
@@ -120,10 +129,10 @@ module Gitlab
# Compatibility with old diffs created with Psych.
if diff_text.encoding == Encoding::BINARY && !diff_text.ascii_only?
hash[:binary] = true
- hash[:diff] = [diff_text].pack('m0')
+ hash[:diff] = [diff_text].pack("m0")
end
end
- end
+ }
[commit_rows, file_rows]
end
@@ -132,9 +141,9 @@ module Gitlab
# display - it won't change file modes in the repository. Submodules are
# created as 600, regular files as 644.
def guess_mode(file_missing, diff)
- return '0' if file_missing
+ return "0" if file_missing
- diff.include?('Subproject commit') ? '160000' : '100644'
+ diff.include?("Subproject commit") ? "160000" : "100644"
end
# Unlike MergeRequestDiff#valid_raw_diff?, don't count Rugged objects as
diff --git a/lib/gitlab/background_migration/digest_column.rb b/lib/gitlab/background_migration/digest_column.rb
index 22a3bb8f8f3..2ad64f63e98 100644
--- a/lib/gitlab/background_migration/digest_column.rb
+++ b/lib/gitlab/background_migration/digest_column.rb
@@ -5,7 +5,7 @@ module Gitlab
module BackgroundMigration
class DigestColumn
class PersonalAccessToken < ActiveRecord::Base
- self.table_name = 'personal_access_tokens'
+ self.table_name = "personal_access_tokens"
end
def perform(model, attribute_from, attribute_to, start_id, stop_id)
diff --git a/lib/gitlab/background_migration/encrypt_columns.rb b/lib/gitlab/background_migration/encrypt_columns.rb
index b9ad8267e37..0362e11705b 100644
--- a/lib/gitlab/background_migration/encrypt_columns.rb
+++ b/lib/gitlab/background_migration/encrypt_columns.rb
@@ -46,7 +46,7 @@ module Gitlab
# Build a hash of { attribute => encrypted column name }
def expand_attributes(klass, attributes)
- expanded = attributes.flat_map do |attribute|
+ expanded = attributes.flat_map { |attribute|
attr_config = klass.encrypted_attributes[attribute]
crypt_column_name = attr_config&.fetch(:attribute)
@@ -62,7 +62,7 @@ module Gitlab
klass.column_names.include?(crypt_column_name.to_s)
[attribute, crypt_column_name]
- end
+ }
Hash[*expanded]
end
diff --git a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
index 103bd98af14..4e98b4eb4a0 100644
--- a/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
+++ b/lib/gitlab/background_migration/fill_file_store_job_artifact.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class FillFileStoreJobArtifact
class JobArtifact < ActiveRecord::Base
- self.table_name = 'ci_job_artifacts'
+ self.table_name = "ci_job_artifacts"
end
def perform(start_id, stop_id)
diff --git a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
index 77c1f1ffaf0..9ccdf04bbe2 100644
--- a/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
+++ b/lib/gitlab/background_migration/fill_file_store_lfs_object.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class FillFileStoreLfsObject
class LfsObject < ActiveRecord::Base
- self.table_name = 'lfs_objects'
+ self.table_name = "lfs_objects"
end
def perform(start_id, stop_id)
diff --git a/lib/gitlab/background_migration/fill_store_upload.rb b/lib/gitlab/background_migration/fill_store_upload.rb
index cba3e21cea6..f3ee5eee60e 100644
--- a/lib/gitlab/background_migration/fill_store_upload.rb
+++ b/lib/gitlab/background_migration/fill_store_upload.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class FillStoreUpload
class Upload < ActiveRecord::Base
- self.table_name = 'uploads'
+ self.table_name = "uploads"
self.inheritance_column = :_type_disabled
end
diff --git a/lib/gitlab/background_migration/fix_cross_project_label_links.rb b/lib/gitlab/background_migration/fix_cross_project_label_links.rb
index 0a12401c35f..5ac3d0fc647 100644
--- a/lib/gitlab/background_migration/fix_cross_project_label_links.rb
+++ b/lib/gitlab/background_migration/fix_cross_project_label_links.rb
@@ -1,45 +1,46 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class FixCrossProjectLabelLinks
- GROUP_NESTED_LEVEL = 10.freeze
+ GROUP_NESTED_LEVEL = 10
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
end
class Label < ActiveRecord::Base
self.inheritance_column = :_type_disabled
- self.table_name = 'labels'
+ self.table_name = "labels"
end
class LabelLink < ActiveRecord::Base
- self.table_name = 'label_links'
+ self.table_name = "label_links"
end
class Issue < ActiveRecord::Base
- self.table_name = 'issues'
+ self.table_name = "issues"
end
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
end
class Namespace < ActiveRecord::Base
self.inheritance_column = :_type_disabled
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
def self.groups_with_descendants_ids(start_id, stop_id)
# To isolate migration code, we avoid usage of
# Gitlab::GroupHierarchy#base_and_descendants which already
# does this job better
- ids = Namespace.where(type: 'Group', id: Label.where(type: 'GroupLabel').select('distinct group_id')).where(id: start_id..stop_id).pluck(:id)
+ ids = Namespace.where(type: "Group", id: Label.where(type: "GroupLabel").select("distinct group_id")).where(id: start_id..stop_id).pluck(:id)
group_ids = ids
GROUP_NESTED_LEVEL.times do
- ids = Namespace.where(type: 'Group', parent_id: ids).pluck(:id)
+ ids = Namespace.where(type: "Group", parent_id: ids).pluck(:id)
break if ids.empty?
group_ids += ids
@@ -67,10 +68,10 @@ module Gitlab
.joins('INNER JOIN label_links ON label_links.label_id = labels.id AND label_links.target_type = \'Issue\'
INNER JOIN issues ON issues.id = label_links.target_id
INNER JOIN projects ON projects.id = issues.project_id')
- .where('issues.project_id in (?)', project_ids)
- .where('(labels.project_id is not null and labels.project_id != issues.project_id) '\
- 'or (labels.group_id is not null and labels.group_id != projects.namespace_id)')
- .select('distinct issues.id')
+ .where("issues.project_id in (?)", project_ids)
+ .where("(labels.project_id is not null and labels.project_id != issues.project_id) "\
+ "or (labels.group_id is not null and labels.group_id != projects.namespace_id)")
+ .select("distinct issues.id")
Issue.where(id: issue_ids).find_each { |issue| check_resource_labels(issue, issue.project_id) }
end
@@ -83,10 +84,10 @@ module Gitlab
.joins('INNER JOIN label_links ON label_links.label_id = labels.id AND label_links.target_type = \'MergeRequest\'
INNER JOIN merge_requests ON merge_requests.id = label_links.target_id
INNER JOIN projects ON projects.id = merge_requests.target_project_id')
- .where('merge_requests.target_project_id in (?)', project_ids)
- .where('(labels.project_id is not null and labels.project_id != merge_requests.target_project_id) '\
- 'or (labels.group_id is not null and labels.group_id != projects.namespace_id)')
- .select('distinct merge_requests.id')
+ .where("merge_requests.target_project_id in (?)", project_ids)
+ .where("(labels.project_id is not null and labels.project_id != merge_requests.target_project_id) "\
+ "or (labels.group_id is not null and labels.group_id != projects.namespace_id)")
+ .select("distinct merge_requests.id")
MergeRequest.where(id: mr_ids).find_each { |merge_request| check_resource_labels(merge_request, merge_request.target_project_id) }
end
@@ -98,10 +99,10 @@ module Gitlab
# which reference a label not included in avaiable_labels
# (other than its project labels and labels of ancestor groups)
cross_labels = LabelLink
- .select('label_id, labels.title as title, labels.color as color, label_links.id as label_link_id')
- .joins('INNER JOIN labels ON labels.id = label_links.label_id')
+ .select("label_id, labels.title as title, labels.color as color, label_links.id as label_link_id")
+ .joins("INNER JOIN labels ON labels.id = label_links.label_id")
.where(target_type: resource.class.name.demodulize, target_id: resource.id)
- .where('labels.id not in (?)', local_labels.select(:id))
+ .where("labels.id not in (?)", local_labels.select(:id))
cross_labels.each do |label|
matching_label = local_labels.find {|l| l.title == label.title && l.color == label.color}
@@ -119,8 +120,8 @@ module Gitlab
@labels ||= {}
@labels[project_id] ||= Label
.where("(type = 'GroupLabel' and group_id in (?)) or (type = 'ProjectLabel' and id = ?)",
- project_group_ids(project_id),
- project_id)
+ project_group_ids(project_id),
+ project_id)
end
def project_group_ids(project_id)
diff --git a/lib/gitlab/background_migration/migrate_build_stage.rb b/lib/gitlab/background_migration/migrate_build_stage.rb
index 268c6083d3c..b80cd9e2b4f 100644
--- a/lib/gitlab/background_migration/migrate_build_stage.rb
+++ b/lib/gitlab/background_migration/migrate_build_stage.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -6,11 +7,11 @@ module Gitlab
class MigrateBuildStage
module Migratable
class Stage < ActiveRecord::Base
- self.table_name = 'ci_stages'
+ self.table_name = "ci_stages"
end
class Build < ActiveRecord::Base
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled
def ensure_stage!(attempts: 2)
@@ -21,22 +22,22 @@ module Gitlab
end
def find_stage
- Stage.find_by(name: self.stage || 'test',
- pipeline_id: self.commit_id,
- project_id: self.project_id)
+ Stage.find_by(name: stage || "test",
+ pipeline_id: commit_id,
+ project_id: project_id)
end
def create_stage!
- Stage.create!(name: self.stage || 'test',
- pipeline_id: self.commit_id,
- project_id: self.project_id)
+ Stage.create!(name: stage || "test",
+ pipeline_id: commit_id,
+ project_id: project_id)
end
end
end
def perform(start_id, stop_id)
- stages = Migratable::Build.where('stage_id IS NULL')
- .where('id BETWEEN ? AND ?', start_id, stop_id)
+ stages = Migratable::Build.where("stage_id IS NULL")
+ .where("id BETWEEN ? AND ?", start_id, stop_id)
.map { |build| build.ensure_stage! }
.compact.map(&:id)
diff --git a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
index 0a8a4313cd5..14be937db7f 100644
--- a/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
+++ b/lib/gitlab/background_migration/migrate_build_stage_id_reference.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
diff --git a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb
index 38fecac1bfe..79831238896 100644
--- a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb
+++ b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -8,12 +9,12 @@ module Gitlab
# created in the push_event_payloads table.
class MigrateEventsToPushEventPayloads
class Event < ActiveRecord::Base
- self.table_name = 'events'
+ self.table_name = "events"
serialize :data
- BLANK_REF = ('0' * 40).freeze
- TAG_REF_PREFIX = 'refs/tags/'.freeze
+ BLANK_REF = ("0" * 40).freeze
+ TAG_REF_PREFIX = "refs/tags/"
MAX_INDEX = 69
PUSHED = 5
@@ -100,21 +101,21 @@ module Gitlab
end
class EventForMigration < ActiveRecord::Base
- self.table_name = 'events_for_migration'
+ self.table_name = "events_for_migration"
end
class PushEventPayload < ActiveRecord::Base
- self.table_name = 'push_event_payloads'
+ self.table_name = "push_event_payloads"
enum action: {
created: 0,
removed: 1,
- pushed: 2
+ pushed: 2,
}
enum ref_type: {
branch: 0,
- tag: 1
+ tag: 1,
}
end
@@ -162,7 +163,7 @@ module Gitlab
def find_events(start_id, end_id)
Event
- .where('NOT EXISTS (SELECT true FROM events_for_migration WHERE events_for_migration.id = events.id)')
+ .where("NOT EXISTS (SELECT true FROM events_for_migration WHERE events_for_migration.id = events.id)")
.where(id: start_id..end_id)
end
@@ -172,7 +173,7 @@ module Gitlab
end
def pack(value)
- value ? [value].pack('H*') : nil
+ value ? [value].pack("H*") : nil
end
end
end
diff --git a/lib/gitlab/background_migration/migrate_legacy_artifacts.rb b/lib/gitlab/background_migration/migrate_legacy_artifacts.rb
index 5cd638083b0..07b18c759a5 100644
--- a/lib/gitlab/background_migration/migrate_legacy_artifacts.rb
+++ b/lib/gitlab/background_migration/migrate_legacy_artifacts.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/ClassLength
module Gitlab
diff --git a/lib/gitlab/background_migration/migrate_stage_index.rb b/lib/gitlab/background_migration/migrate_stage_index.rb
index f90f35a913d..238bdad0f66 100644
--- a/lib/gitlab/background_migration/migrate_stage_index.rb
+++ b/lib/gitlab/background_migration/migrate_stage_index.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
diff --git a/lib/gitlab/background_migration/migrate_stage_status.rb b/lib/gitlab/background_migration/migrate_stage_status.rb
index 6a29a632577..f9f3d54dbac 100644
--- a/lib/gitlab/background_migration/migrate_stage_status.rb
+++ b/lib/gitlab/background_migration/migrate_stage_status.rb
@@ -1,25 +1,26 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/AbcSize
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class MigrateStageStatus
- STATUSES = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze
+ STATUSES = {created: 0, pending: 1, running: 2, success: 3,
+ failed: 4, canceled: 5, skipped: 6, manual: 7,}.freeze
class Build < ActiveRecord::Base
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
scope :latest, -> { where(retried: [false, nil]) }
- scope :created, -> { where(status: 'created') }
- scope :running, -> { where(status: 'running') }
- scope :pending, -> { where(status: 'pending') }
- scope :success, -> { where(status: 'success') }
- scope :failed, -> { where(status: 'failed') }
- scope :canceled, -> { where(status: 'canceled') }
- scope :skipped, -> { where(status: 'skipped') }
- scope :manual, -> { where(status: 'manual') }
+ scope :created, -> { where(status: "created") }
+ scope :running, -> { where(status: "running") }
+ scope :pending, -> { where(status: "pending") }
+ scope :success, -> { where(status: "success") }
+ scope :failed, -> { where(status: "failed") }
+ scope :canceled, -> { where(status: "canceled") }
+ scope :skipped, -> { where(status: "skipped") }
+ scope :manual, -> { where(status: "manual") }
scope :failed_but_allowed, -> do
where(allow_failure: true, status: [:failed, :canceled])
@@ -34,15 +35,15 @@ module Gitlab
scope_relevant = latest.exclude_ignored
scope_warnings = latest.failed_but_allowed
- builds = scope_relevant.select('count(*)').to_sql
- created = scope_relevant.created.select('count(*)').to_sql
- success = scope_relevant.success.select('count(*)').to_sql
- manual = scope_relevant.manual.select('count(*)').to_sql
- pending = scope_relevant.pending.select('count(*)').to_sql
- running = scope_relevant.running.select('count(*)').to_sql
- skipped = scope_relevant.skipped.select('count(*)').to_sql
- canceled = scope_relevant.canceled.select('count(*)').to_sql
- warnings = scope_warnings.select('count(*) > 0').to_sql
+ builds = scope_relevant.select("count(*)").to_sql
+ created = scope_relevant.created.select("count(*)").to_sql
+ success = scope_relevant.success.select("count(*)").to_sql
+ manual = scope_relevant.manual.select("count(*)").to_sql
+ pending = scope_relevant.pending.select("count(*)").to_sql
+ running = scope_relevant.running.select("count(*)").to_sql
+ skipped = scope_relevant.skipped.select("count(*)").to_sql
+ canceled = scope_relevant.canceled.select("count(*)").to_sql
+ warnings = scope_warnings.select("count(*) > 0").to_sql
<<-SQL.strip_heredoc
(CASE
@@ -64,8 +65,8 @@ module Gitlab
def perform(start_id, stop_id)
status_sql = Build
- .where('ci_builds.commit_id = ci_stages.pipeline_id')
- .where('ci_builds.stage = ci_stages.name')
+ .where("ci_builds.commit_id = ci_stages.pipeline_id")
+ .where("ci_builds.stage = ci_stages.name")
.status_sql
sql = <<-SQL
diff --git a/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
index ef50fe4adb1..651fd496eb0 100644
--- a/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
+++ b/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -8,7 +9,7 @@ module Gitlab
attr_reader :old_folder, :new_folder
class Upload < ActiveRecord::Base
- self.table_name = 'uploads'
+ self.table_name = "uploads"
include EachBatch
end
@@ -22,7 +23,7 @@ module Gitlab
end
def uploads
- Arel::Table.new('uploads')
+ Arel::Table.new("uploads")
end
end
end
diff --git a/lib/gitlab/background_migration/models/encrypt_columns/namespace.rb b/lib/gitlab/background_migration/models/encrypt_columns/namespace.rb
index 41f18979d76..45bbb19ceb7 100644
--- a/lib/gitlab/background_migration/models/encrypt_columns/namespace.rb
+++ b/lib/gitlab/background_migration/models/encrypt_columns/namespace.rb
@@ -10,7 +10,7 @@ module Gitlab
class Namespace < ActiveRecord::Base
include ::EachBatch
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
self.inheritance_column = :_type_disabled
def runners_token=(value)
@@ -19,7 +19,7 @@ module Gitlab
end
def self.encrypted_attributes
- { runners_token: { attribute: :runners_token_encrypted } }
+ {runners_token: {attribute: :runners_token_encrypted}}
end
end
end
diff --git a/lib/gitlab/background_migration/models/encrypt_columns/project.rb b/lib/gitlab/background_migration/models/encrypt_columns/project.rb
index bfeae14584d..90a8ed2512b 100644
--- a/lib/gitlab/background_migration/models/encrypt_columns/project.rb
+++ b/lib/gitlab/background_migration/models/encrypt_columns/project.rb
@@ -10,7 +10,7 @@ module Gitlab
class Project < ActiveRecord::Base
include ::EachBatch
- self.table_name = 'projects'
+ self.table_name = "projects"
self.inheritance_column = :_type_disabled
def runners_token=(value)
@@ -19,7 +19,7 @@ module Gitlab
end
def self.encrypted_attributes
- { runners_token: { attribute: :runners_token_encrypted } }
+ {runners_token: {attribute: :runners_token_encrypted}}
end
end
end
diff --git a/lib/gitlab/background_migration/models/encrypt_columns/runner.rb b/lib/gitlab/background_migration/models/encrypt_columns/runner.rb
index 14ddce4b147..70015ad0989 100644
--- a/lib/gitlab/background_migration/models/encrypt_columns/runner.rb
+++ b/lib/gitlab/background_migration/models/encrypt_columns/runner.rb
@@ -10,7 +10,7 @@ module Gitlab
class Runner < ActiveRecord::Base
include ::EachBatch
- self.table_name = 'ci_runners'
+ self.table_name = "ci_runners"
self.inheritance_column = :_type_disabled
def token=(value)
@@ -19,7 +19,7 @@ module Gitlab
end
def self.encrypted_attributes
- { token: { attribute: :token_encrypted } }
+ {token: {attribute: :token_encrypted}}
end
end
end
diff --git a/lib/gitlab/background_migration/models/encrypt_columns/settings.rb b/lib/gitlab/background_migration/models/encrypt_columns/settings.rb
index 08ae35c0671..5ddfbbbe6f3 100644
--- a/lib/gitlab/background_migration/models/encrypt_columns/settings.rb
+++ b/lib/gitlab/background_migration/models/encrypt_columns/settings.rb
@@ -11,7 +11,7 @@ module Gitlab
include ::EachBatch
include ::CacheableAttributes
- self.table_name = 'application_settings'
+ self.table_name = "application_settings"
self.inheritance_column = :_type_disabled
after_commit do
@@ -26,8 +26,8 @@ module Gitlab
def self.encrypted_attributes
{
runners_registration_token: {
- attribute: :runners_registration_token_encrypted
- }
+ attribute: :runners_registration_token_encrypted,
+ },
}
end
end
diff --git a/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb b/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb
index 34e72fd9f34..ae1367b4817 100644
--- a/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb
+++ b/lib/gitlab/background_migration/models/encrypt_columns/web_hook.rb
@@ -9,18 +9,18 @@ module Gitlab
class WebHook < ActiveRecord::Base
include ::EachBatch
- self.table_name = 'web_hooks'
+ self.table_name = "web_hooks"
self.inheritance_column = :_type_disabled
attr_encrypted :token,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm',
- key: ::Settings.attr_encrypted_db_key_base_32
+ mode: :per_attribute_iv,
+ algorithm: "aes-256-gcm",
+ key: ::Settings.attr_encrypted_db_key_base_32
attr_encrypted :url,
- mode: :per_attribute_iv,
- algorithm: 'aes-256-gcm',
- key: ::Settings.attr_encrypted_db_key_base_32
+ mode: :per_attribute_iv,
+ algorithm: "aes-256-gcm",
+ key: ::Settings.attr_encrypted_db_key_base_32
end
end
end
diff --git a/lib/gitlab/background_migration/move_personal_snippet_files.rb b/lib/gitlab/background_migration/move_personal_snippet_files.rb
index 5b2b2af718a..8a8103d2ace 100644
--- a/lib/gitlab/background_migration/move_personal_snippet_files.rb
+++ b/lib/gitlab/background_migration/move_personal_snippet_files.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -17,11 +18,11 @@ module Gitlab
query = "SELECT uploads.path, uploads.model_id FROM uploads "\
"INNER JOIN snippets ON snippets.id = uploads.model_id WHERE uploader = 'PersonalFileUploader'"
select_all(query).each do |upload|
- secret = upload['path'].split('/')[0]
- file_name = upload['path'].split('/')[1]
+ secret = upload["path"].split("/")[0]
+ file_name = upload["path"].split("/")[1]
- move_file(upload['model_id'], secret, file_name)
- update_markdown(upload['model_id'], secret, file_name)
+ move_file(upload["model_id"], secret, file_name)
+ update_markdown(upload["model_id"], secret, file_name)
end
end
@@ -59,15 +60,15 @@ module Gitlab
query = "SELECT id, note FROM notes WHERE noteable_id = #{snippet_id} "\
"AND noteable_type = 'Snippet' AND note IS NOT NULL"
select_all(query).each do |note|
- text = note['note'].gsub(source_markdown, destination_markdown)
+ text = note["note"].gsub(source_markdown, destination_markdown)
quoted_text = quote_string(text)
- execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note['id']}")
+ execute("UPDATE notes SET note = '#{quoted_text}', note_html = NULL WHERE id = #{note["id"]}")
end
end
def base_directory
- File.join(Rails.root, 'public')
+ File.join(Rails.root, "public")
end
def connection
diff --git a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb b/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb
index 698f5e46c0c..2a921c0e36e 100644
--- a/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb
+++ b/lib/gitlab/background_migration/normalize_ldap_extern_uids_range.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/ClassLength
# rubocop:disable Metrics/BlockLength
@@ -8,7 +9,7 @@ module Gitlab
module BackgroundMigration
class NormalizeLdapExternUidsRange
class Identity < ActiveRecord::Base
- self.table_name = 'identities'
+ self.table_name = "identities"
end
# Copied this class to make this migration resilient to future code changes.
@@ -25,7 +26,7 @@ module Gitlab
def self.normalize_value(given_value)
dummy_dn = "placeholder=#{given_value}"
normalized_dn = new(*dummy_dn).to_normalized_s
- normalized_dn.sub(/\Aplaceholder=/, '')
+ normalized_dn.sub(/\Aplaceholder=/, "")
end
##
@@ -60,36 +61,36 @@ module Gitlab
case state
when :key then
case char
- when 'a'..'z', 'A'..'Z' then
+ when "a".."z", "A".."Z" then
state = :key_normal
key << char
- when '0'..'9' then
+ when "0".."9" then
state = :key_oid
key << char
- when ' ' then state = :key
+ when " " then state = :key
else raise(MalformedError, "Unrecognized first character of an RDN attribute type name \"#{char}\"")
end
when :key_normal then
case char
- when '=' then state = :value
- when 'a'..'z', 'A'..'Z', '0'..'9', '-', ' ' then key << char
+ when "=" then state = :value
+ when "a".."z", "A".."Z", "0".."9", "-", " " then key << char
else raise(MalformedError, "Unrecognized RDN attribute type name character \"#{char}\"")
end
when :key_oid then
case char
- when '=' then state = :value
- when '0'..'9', '.', ' ' then key << char
+ when "=" then state = :value
+ when "0".."9", ".", " " then key << char
else raise(MalformedError, "Unrecognized RDN OID attribute type name character \"#{char}\"")
end
when :value then
case char
when '\\' then state = :value_normal_escape
when '"' then state = :value_quoted
- when ' ' then state = :value
- when '#' then
+ when " " then state = :value
+ when "#" then
state = :value_hexstring
value << char
- when ',' then
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -101,17 +102,17 @@ module Gitlab
when :value_normal then
case char
when '\\' then state = :value_normal_escape
- when ',' then
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
value = StringIO.new
- when '+' then raise(UnsupportedError, "Multivalued RDNs are not supported")
+ when "+" then raise(UnsupportedError, "Multivalued RDNs are not supported")
else value << char
end
when :value_normal_escape then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_normal_escape_hex
hex_buffer = char
else
@@ -120,7 +121,7 @@ module Gitlab
end
when :value_normal_escape_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_normal
value << "#{hex_buffer}#{char}".to_i(16).chr
else raise(MalformedError, "Invalid escaped hex code \"\\#{hex_buffer}#{char}\"")
@@ -133,7 +134,7 @@ module Gitlab
end
when :value_quoted_escape then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_quoted_escape_hex
hex_buffer = char
else
@@ -142,18 +143,18 @@ module Gitlab
end
when :value_quoted_escape_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_quoted
value << "#{hex_buffer}#{char}".to_i(16).chr
else raise(MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"#{char}\"")
end
when :value_hexstring then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_hexstring_hex
value << char
- when ' ' then state = :value_end
- when ',' then
+ when " " then state = :value_end
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -162,15 +163,15 @@ module Gitlab
end
when :value_hexstring_hex then
case char
- when '0'..'9', 'a'..'f', 'A'..'F' then
+ when "0".."9", "a".."f", "A".."F" then
state = :value_hexstring
value << char
else raise(MalformedError, "Expected the second character of a hex pair, but got \"#{char}\"")
end
when :value_end then
case char
- when ' ' then state = :value_end
- when ',' then
+ when " " then state = :value_end
+ when "," then
state = :key
yield key.string.strip, rstrip_except_escaped(value.string, dn_index)
key = StringIO.new
@@ -182,7 +183,7 @@ module Gitlab
end
# Last pair
- raise(MalformedError, 'DN string ended unexpectedly') unless
+ raise(MalformedError, "DN string ended unexpectedly") unless
[:value, :value_normal, :value_hexstring, :value_end].include? state
yield key.string.strip, rstrip_except_escaped(value.string, @dn.length)
@@ -210,7 +211,7 @@ module Gitlab
# Returns the DN as an array in the form expected by the constructor.
def to_a
a = []
- self.each_pair { |key, value| a << key << value } unless @dn.empty?
+ each_pair { |key, value| a << key << value } unless @dn.empty?
a
end
@@ -231,12 +232,12 @@ module Gitlab
# using a single backslash ('\') as escape. The space character is left
# out here because in a "normalized" string, spaces should only be escaped
# if necessary (i.e. leading or trailing space).
- NORMAL_ESCAPES = [',', '+', '"', '\\', '<', '>', ';', '='].freeze
+ NORMAL_ESCAPES = [",", "+", '"', '\\', "<", ">", ";", "="].freeze
# The following must be represented as escaped hex
HEX_ESCAPES = {
"\n" => '\0a',
- "\r" => '\0d'
+ "\r" => '\0d',
}.freeze
# Compiled character class regexp using the keys from the above hash, and
@@ -302,14 +303,12 @@ module Gitlab
ldap_identities = Identity.where("provider like 'ldap%'").where(id: start_id..end_id)
ldap_identities.each do |identity|
- begin
- identity.extern_uid = Gitlab::Auth::LDAP::DN.new(identity.extern_uid).to_normalized_s
- unless identity.save
- Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\". Skipping."
- end
- rescue Gitlab::Auth::LDAP::DN::FormatError => e
- Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\" due to \"#{e.message}\". Skipping."
+ identity.extern_uid = Gitlab::Auth::LDAP::DN.new(identity.extern_uid).to_normalized_s
+ unless identity.save
+ Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\". Skipping."
end
+ rescue Gitlab::Auth::LDAP::DN::FormatError => e
+ Rails.logger.info "Unable to normalize \"#{identity.extern_uid}\" due to \"#{e.message}\". Skipping."
end
end
diff --git a/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb b/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb
index 35bfc381180..9eb3509be6d 100644
--- a/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb
+++ b/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
#
# rubocop:disable Style/Documentation
@@ -11,13 +12,13 @@ module Gitlab
module Migratable
class KubernetesNamespace < ActiveRecord::Base
- self.table_name = 'clusters_kubernetes_namespaces'
+ self.table_name = "clusters_kubernetes_namespaces"
end
class ClusterProject < ActiveRecord::Base
include EachBatch
- self.table_name = 'cluster_projects'
+ self.table_name = "cluster_projects"
belongs_to :project
@@ -27,7 +28,7 @@ module Gitlab
def namespace
slug = "#{project.path}-#{project.id}".downcase
- slug.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '')
+ slug.gsub(/[^-a-z0-9]/, "-").gsub(/^-+/, "")
end
def service_account
@@ -36,7 +37,7 @@ module Gitlab
end
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
end
end
@@ -67,15 +68,15 @@ module Gitlab
project_id: cluster_project.project_id,
namespace: cluster_project.namespace,
service_account_name: cluster_project.service_account,
- created_at: 'NOW()',
- updated_at: 'NOW()'
+ created_at: "NOW()",
+ updated_at: "NOW()",
}
end
def insert_into_cluster_kubernetes_namespace(rows)
Gitlab::Database.bulk_insert(Migratable::KubernetesNamespace.table_name,
- rows,
- disable_quote: [:created_at, :updated_at])
+ rows,
+ disable_quote: [:created_at, :updated_at])
end
end
end
diff --git a/lib/gitlab/background_migration/populate_external_pipeline_source.rb b/lib/gitlab/background_migration/populate_external_pipeline_source.rb
index 036fe641757..9f0795ff2b3 100644
--- a/lib/gitlab/background_migration/populate_external_pipeline_source.rb
+++ b/lib/gitlab/background_migration/populate_external_pipeline_source.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -6,7 +7,7 @@ module Gitlab
class PopulateExternalPipelineSource
module Migratable
class Pipeline < ActiveRecord::Base
- self.table_name = 'ci_pipelines'
+ self.table_name = "ci_pipelines"
def self.sources
{
@@ -16,17 +17,17 @@ module Gitlab
trigger: 3,
schedule: 4,
api: 5,
- external: 6
+ external: 6,
}
end
end
class CommitStatus < ActiveRecord::Base
- self.table_name = 'ci_builds'
+ self.table_name = "ci_builds"
self.inheritance_column = :_type_disabled
- scope :has_pipeline, -> { where('ci_builds.commit_id=ci_pipelines.id') }
- scope :of_type, -> (type) { where('type=?', type) }
+ scope :has_pipeline, -> { where("ci_builds.commit_id=ci_pipelines.id") }
+ scope :of_type, ->(type) { where("type=?", type) }
end
end
@@ -40,9 +41,9 @@ module Gitlab
def external_pipelines(start_id, stop_id)
Migratable::Pipeline.where(id: (start_id..stop_id))
.where(
- 'EXISTS (?) AND NOT EXISTS (?)',
- Migratable::CommitStatus.of_type('GenericCommitStatus').has_pipeline.select(1),
- Migratable::CommitStatus.of_type('Ci::Build').has_pipeline.select(1)
+ "EXISTS (?) AND NOT EXISTS (?)",
+ Migratable::CommitStatus.of_type("GenericCommitStatus").has_pipeline.select(1),
+ Migratable::CommitStatus.of_type("Ci::Build").has_pipeline.select(1)
)
end
end
diff --git a/lib/gitlab/background_migration/populate_fork_networks_range.rb b/lib/gitlab/background_migration/populate_fork_networks_range.rb
index aa4f130538c..f607186974e 100644
--- a/lib/gitlab/background_migration/populate_fork_networks_range.rb
+++ b/lib/gitlab/background_migration/populate_fork_networks_range.rb
@@ -28,70 +28,62 @@ module Gitlab
def create_fork_networks_for_existing_projects(start_id, end_id)
log("Creating fork networks: #{start_id} - #{end_id}")
ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS
- INSERT INTO fork_networks (root_project_id)
- SELECT DISTINCT forked_project_links.forked_from_project_id
-
- FROM forked_project_links
-
- -- Exclude the forks that are not the first level fork of a project
- WHERE NOT EXISTS (
- SELECT true
- FROM forked_project_links inner_links
- WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
- )
-
- /* Exclude the ones that are already created, in case the fork network
- was already created for another fork of the project.
- */
- AND NOT EXISTS (
- SELECT true
- FROM fork_networks
- WHERE forked_project_links.forked_from_project_id = fork_networks.root_project_id
- )
-
- -- Only create a fork network for a root project that still exists
- AND EXISTS (
- SELECT true
- FROM projects
- WHERE projects.id = forked_project_links.forked_from_project_id
- )
- AND forked_project_links.id BETWEEN #{start_id} AND #{end_id}
+ INSERT INTO fork_networks (root_project_id)
+ SELECT DISTINCT forked_project_links.forked_from_project_id
+ FROM forked_project_links
+ -- Exclude the forks that are not the first level fork of a project
+ WHERE NOT EXISTS (
+ SELECT true
+ FROM forked_project_links inner_links
+ WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
+ )
+ /* Exclude the ones that are already created, in case the fork network
+ was already created for another fork of the project.
+ */
+ AND NOT EXISTS (
+ SELECT true
+ FROM fork_networks
+ WHERE forked_project_links.forked_from_project_id = fork_networks.root_project_id
+ )
+ -- Only create a fork network for a root project that still exists
+ AND EXISTS (
+ SELECT true
+ FROM projects
+ WHERE projects.id = forked_project_links.forked_from_project_id
+ )
+ AND forked_project_links.id BETWEEN #{start_id} AND #{end_id}
INSERT_NETWORKS
end
def create_fork_networks_for_missing_projects(start_id, end_id)
log("Creating fork networks with missing root: #{start_id} - #{end_id}")
ActiveRecord::Base.connection.execute <<~INSERT_NETWORKS
- INSERT INTO fork_networks (root_project_id)
- SELECT DISTINCT forked_project_links.forked_to_project_id
-
- FROM forked_project_links
-
- -- Exclude forks that are not the root forks
- WHERE NOT EXISTS (
- SELECT true
- FROM forked_project_links inner_links
- WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
- )
-
- /* Exclude the ones that are already created, in case this migration is
- re-run
- */
- AND NOT EXISTS (
- SELECT true
- FROM fork_networks
- WHERE forked_project_links.forked_to_project_id = fork_networks.root_project_id
- )
-
- /* Exclude projects for which the project still exists, those are
- Processed in the previous step of this migration
- */
- AND NOT EXISTS (
- SELECT true
- FROM projects
- WHERE projects.id = forked_project_links.forked_from_project_id
- )
- AND forked_project_links.id BETWEEN #{start_id} AND #{end_id}
+ INSERT INTO fork_networks (root_project_id)
+ SELECT DISTINCT forked_project_links.forked_to_project_id
+ FROM forked_project_links
+ -- Exclude forks that are not the root forks
+ WHERE NOT EXISTS (
+ SELECT true
+ FROM forked_project_links inner_links
+ WHERE inner_links.forked_to_project_id = forked_project_links.forked_from_project_id
+ )
+ /* Exclude the ones that are already created, in case this migration is
+ re-run
+ */
+ AND NOT EXISTS (
+ SELECT true
+ FROM fork_networks
+ WHERE forked_project_links.forked_to_project_id = fork_networks.root_project_id
+ )
+ /* Exclude projects for which the project still exists, those are
+ Processed in the previous step of this migration
+ */
+ AND NOT EXISTS (
+ SELECT true
+ FROM projects
+ WHERE projects.id = forked_project_links.forked_from_project_id
+ )
+ AND forked_project_links.id BETWEEN #{start_id} AND #{end_id}
INSERT_NETWORKS
end
diff --git a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb
index d89ce358bb9..302157798aa 100644
--- a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb
+++ b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
diff --git a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved.rb b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved.rb
index 37592d67dd9..5de0c3894f1 100644
--- a/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved.rb
+++ b/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
diff --git a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb b/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb
index dcac355e1b0..0116b07ea79 100644
--- a/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb
+++ b/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -7,7 +8,7 @@ module Gitlab
BATCH_SIZE = 1_000
class MergeRequest < ActiveRecord::Base
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
include ::EachBatch
end
diff --git a/lib/gitlab/background_migration/populate_untracked_uploads.rb b/lib/gitlab/background_migration/populate_untracked_uploads.rb
index a19dc9747fb..21b13a1bab7 100644
--- a/lib/gitlab/background_migration/populate_untracked_uploads.rb
+++ b/lib/gitlab/background_migration/populate_untracked_uploads.rb
@@ -34,18 +34,16 @@ module Gitlab
def filter_error_files(files)
files.partition do |file|
- begin
- file.to_h
- true
- rescue => e
- msg = <<~MSG
- Error parsing path "#{file.path}":
- #{e.message}
- #{e.backtrace.join("\n ")}
- MSG
- Rails.logger.error(msg)
- false
- end
+ file.to_h
+ true
+ rescue => e
+ msg = <<~MSG
+ Error parsing path "#{file.path}":
+ #{e.message}
+ #{e.backtrace.join("\n ")}
+ MSG
+ Rails.logger.error(msg)
+ false
end
end
@@ -70,11 +68,11 @@ module Gitlab
def deleted_model_ids(files)
ids = {
- 'Appearance' => [],
- 'Namespace' => [],
- 'Note' => [],
- 'Project' => [],
- 'User' => []
+ "Appearance" => [],
+ "Namespace" => [],
+ "Note" => [],
+ "Project" => [],
+ "User" => [],
}
# group model IDs by model type
@@ -93,19 +91,19 @@ module Gitlab
end
def insert(files)
- rows = files.map do |file|
- file.to_h.merge(created_at: 'NOW()')
- end
+ rows = files.map { |file|
+ file.to_h.merge(created_at: "NOW()")
+ }
- Gitlab::Database.bulk_insert('uploads',
- rows,
- disable_quote: :created_at)
+ Gitlab::Database.bulk_insert("uploads",
+ rows,
+ disable_quote: :created_at)
end
def drop_temp_table_if_finished
if Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::UntrackedFile.all.empty? && !Rails.env.test? # Dropping a table intermittently breaks test cleanup
Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::UntrackedFile.connection.drop_table(:untracked_files_for_uploads,
- if_exists: true)
+ if_exists: true)
end
end
end
diff --git a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb
index 4a9a62aaeb5..bf7d3d6a9ca 100644
--- a/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb
+++ b/lib/gitlab/background_migration/populate_untracked_uploads_dependencies.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
module Gitlab
module BackgroundMigration
module PopulateUntrackedUploadsDependencies
# This class is responsible for producing the attributes necessary to
# track an uploaded file in the `uploads` table.
class UntrackedFile < ActiveRecord::Base # rubocop:disable Metrics/ClassLength
- self.table_name = 'untracked_files_for_uploads'
+ self.table_name = "untracked_files_for_uploads"
# Ends with /:random_hex/:filename
FILE_UPLOADER_PATH = %r{/\h+/[^/]+\z}
@@ -18,39 +19,39 @@ module Gitlab
PATH_PATTERNS = [
{
pattern: %r{\A-/system/appearance/logo/(\d+)/},
- uploader: 'AttachmentUploader',
- model_type: 'Appearance'
+ uploader: "AttachmentUploader",
+ model_type: "Appearance",
},
{
pattern: %r{\A-/system/appearance/header_logo/(\d+)/},
- uploader: 'AttachmentUploader',
- model_type: 'Appearance'
+ uploader: "AttachmentUploader",
+ model_type: "Appearance",
},
{
pattern: %r{\A-/system/note/attachment/(\d+)/},
- uploader: 'AttachmentUploader',
- model_type: 'Note'
+ uploader: "AttachmentUploader",
+ model_type: "Note",
},
{
pattern: %r{\A-/system/user/avatar/(\d+)/},
- uploader: 'AvatarUploader',
- model_type: 'User'
+ uploader: "AvatarUploader",
+ model_type: "User",
},
{
pattern: %r{\A-/system/group/avatar/(\d+)/},
- uploader: 'AvatarUploader',
- model_type: 'Namespace'
+ uploader: "AvatarUploader",
+ model_type: "Namespace",
},
{
pattern: %r{\A-/system/project/avatar/(\d+)/},
- uploader: 'AvatarUploader',
- model_type: 'Project'
+ uploader: "AvatarUploader",
+ model_type: "Project",
},
{
pattern: FILE_UPLOADER_PATH,
- uploader: 'FileUploader',
- model_type: 'Project'
- }
+ uploader: "FileUploader",
+ model_type: "Project",
+ },
].freeze
def to_h
@@ -60,17 +61,17 @@ module Gitlab
model_type: model_type,
model_id: model_id,
size: file_size,
- checksum: checksum
+ checksum: checksum,
}
end
def upload_path
# UntrackedFile#path is absolute, but Upload#path depends on uploader
@upload_path ||=
- if uploader == 'FileUploader'
+ if uploader == "FileUploader"
# Path relative to project directory in uploads
matchd = path_relative_to_upload_dir.match(FILE_UPLOADER_PATH)
- matchd[0].sub(%r{\A/}, '') # remove leading slash
+ matchd[0].sub(%r{\A/}, "") # remove leading slash
else
path
end
@@ -106,9 +107,9 @@ module Gitlab
private
def matching_pattern_map
- @matching_pattern_map ||= PATH_PATTERNS.find do |path_pattern_map|
+ @matching_pattern_map ||= PATH_PATTERNS.find { |path_pattern_map|
path_relative_to_upload_dir.match(path_pattern_map[:pattern])
- end
+ }
unless @matching_pattern_map
raise "Unknown upload path pattern \"#{path}\""
@@ -136,7 +137,7 @@ module Gitlab
def path_relative_to_upload_dir
upload_dir = Gitlab::BackgroundMigration::PrepareUntrackedUploads::RELATIVE_UPLOAD_DIR
base = %r{\A#{Regexp.escape(upload_dir)}/}
- @path_relative_to_upload_dir ||= path.sub(base, '')
+ @path_relative_to_upload_dir ||= path.sub(base, "")
end
def absolute_path
@@ -146,37 +147,37 @@ module Gitlab
# Avoid using application code
class Upload < ActiveRecord::Base
- self.table_name = 'uploads'
+ self.table_name = "uploads"
end
# Avoid using application code
class Appearance < ActiveRecord::Base
- self.table_name = 'appearances'
+ self.table_name = "appearances"
end
# Avoid using application code
class Namespace < ActiveRecord::Base
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
end
# Avoid using application code
class Note < ActiveRecord::Base
- self.table_name = 'notes'
+ self.table_name = "notes"
end
# Avoid using application code
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
# Since project Markdown upload paths don't contain the project ID, we have to find the
# project by its full_path. Due to MySQL/PostgreSQL differences, and historical reasons,
# the logic is somewhat complex, so I've mostly copied it in here.
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
def self.find_by_full_path(path)
- binary = Gitlab::Database.mysql? ? 'BINARY' : ''
+ binary = Gitlab::Database.mysql? ? "BINARY" : ""
order_sql = "(CASE WHEN #{binary} routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)"
where_full_path_in(path).reorder(order_sql).take
end
diff --git a/lib/gitlab/background_migration/prepare_untracked_uploads.rb b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
index 81ca2b0a9b7..3e54de86157 100644
--- a/lib/gitlab/background_migration/prepare_untracked_uploads.rb
+++ b/lib/gitlab/background_migration/prepare_untracked_uploads.rb
@@ -10,22 +10,22 @@ module Gitlab
include ::Gitlab::Utils::StrongMemoize
FIND_BATCH_SIZE = 500
- RELATIVE_UPLOAD_DIR = "uploads".freeze
+ RELATIVE_UPLOAD_DIR = "uploads"
ABSOLUTE_UPLOAD_DIR = File.join(
Gitlab.config.uploads.storage_path,
RELATIVE_UPLOAD_DIR
)
- FOLLOW_UP_MIGRATION = 'PopulateUntrackedUploads'.freeze
+ FOLLOW_UP_MIGRATION = "PopulateUntrackedUploads"
START_WITH_ROOT_REGEX = %r{\A#{Gitlab.config.uploads.storage_path}/}
- EXCLUDED_HASHED_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/@hashed/*".freeze
- EXCLUDED_TMP_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/tmp/*".freeze
+ EXCLUDED_HASHED_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/@hashed/*"
+ EXCLUDED_TMP_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/tmp/*"
# This class is used to iterate over batches of
# `untracked_files_for_uploads` rows.
class UntrackedFile < ActiveRecord::Base
include EachBatch
- self.table_name = 'untracked_files_for_uploads'
+ self.table_name = "untracked_files_for_uploads"
end
def perform
@@ -89,7 +89,7 @@ module Gitlab
paths = []
stdout.each_line("\0") do |line|
- paths << line.chomp("\0").sub(START_WITH_ROOT_REGEX, '')
+ paths << line.chomp("\0").sub(START_WITH_ROOT_REGEX, "")
if paths.size >= batch_size
yield(paths)
@@ -110,15 +110,15 @@ module Gitlab
ionice = which_ionice
cmd = %W[#{ionice} -c Idle] + cmd if ionice
- log_msg = "PrepareUntrackedUploads find command: \"#{cmd.join(' ')}\""
+ log_msg = "PrepareUntrackedUploads find command: \"#{cmd.join(" ")}\""
Rails.logger.info log_msg
cmd
end
def which_ionice
- Gitlab::Utils.which('ionice')
- rescue StandardError
+ Gitlab::Utils.which("ionice")
+ rescue
# In this case, returning false is relatively safe,
# even though it isn't very nice
false
@@ -143,9 +143,9 @@ module Gitlab
end
def table_columns_and_values_for_insert(file_paths)
- values = file_paths.map do |file_path|
- ActiveRecord::Base.send(:sanitize_sql_array, ['(?)', file_path]) # rubocop:disable GitlabSecurity/PublicSend
- end.join(', ')
+ values = file_paths.map { |file_path|
+ ActiveRecord::Base.send(:sanitize_sql_array, ["(?)", file_path]) # rubocop:disable GitlabSecurity/PublicSend
+ }.join(", ")
"#{UntrackedFile.table_name} (path) VALUES #{values}"
end
@@ -168,13 +168,14 @@ module Gitlab
def schedule_populate_untracked_uploads_jobs
bulk_queue_background_migration_jobs_by_range(
- UntrackedFile, FOLLOW_UP_MIGRATION)
+ UntrackedFile, FOLLOW_UP_MIGRATION
+ )
end
def drop_temp_table
unless Rails.env.test? # Dropping a table intermittently breaks test cleanup
UntrackedFile.connection.drop_table(:untracked_files_for_uploads,
- if_exists: true)
+ if_exists: true)
end
end
end
diff --git a/lib/gitlab/background_migration/redact_links.rb b/lib/gitlab/background_migration/redact_links.rb
index 92256e59a6c..587c0ad76fc 100644
--- a/lib/gitlab/background_migration/redact_links.rb
+++ b/lib/gitlab/background_migration/redact_links.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
-require_relative 'redact_links/redactable'
+require_relative "redact_links/redactable"
module Gitlab
module BackgroundMigration
@@ -10,7 +11,7 @@ module Gitlab
include EachBatch
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
- self.table_name = 'notes'
+ self.table_name = "notes"
self.inheritance_column = :_type_disabled
end
@@ -18,7 +19,7 @@ module Gitlab
include EachBatch
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
- self.table_name = 'issues'
+ self.table_name = "issues"
self.inheritance_column = :_type_disabled
end
@@ -26,7 +27,7 @@ module Gitlab
include EachBatch
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
- self.table_name = 'merge_requests'
+ self.table_name = "merge_requests"
self.inheritance_column = :_type_disabled
end
@@ -34,7 +35,7 @@ module Gitlab
include EachBatch
include ::Gitlab::BackgroundMigration::RedactLinks::Redactable
- self.table_name = 'snippets'
+ self.table_name = "snippets"
self.inheritance_column = :_type_disabled
end
diff --git a/lib/gitlab/background_migration/redact_links/redactable.rb b/lib/gitlab/background_migration/redact_links/redactable.rb
index baab34221f1..e582dced24d 100644
--- a/lib/gitlab/background_migration/redact_links/redactable.rb
+++ b/lib/gitlab/background_migration/redact_links/redactable.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -8,11 +9,11 @@ module Gitlab
extend ActiveSupport::Concern
def redact_field!(field)
- self[field].gsub!(%r{/sent_notifications/\h{32}/unsubscribe}, '/sent_notifications/REDACTED/unsubscribe')
+ self[field].gsub!(%r{/sent_notifications/\h{32}/unsubscribe}, "/sent_notifications/REDACTED/unsubscribe")
- if self.changed?
- self.update_columns(field => self[field],
- "#{field}_html" => nil)
+ if changed?
+ update_columns(field => self[field],
+ "#{field}_html" => nil)
end
end
end
diff --git a/lib/gitlab/background_migration/remove_restricted_todos.rb b/lib/gitlab/background_migration/remove_restricted_todos.rb
index 47579d46c1b..fc0d4abdf10 100644
--- a/lib/gitlab/background_migration/remove_restricted_todos.rb
+++ b/lib/gitlab/background_migration/remove_restricted_todos.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
# rubocop:disable Metrics/ClassLength
@@ -9,31 +10,31 @@ module Gitlab
PRIVATE_PROJECT = 0
class Project < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
end
class ProjectAuthorization < ActiveRecord::Base
- self.table_name = 'project_authorizations'
+ self.table_name = "project_authorizations"
end
class ProjectFeature < ActiveRecord::Base
- self.table_name = 'project_features'
+ self.table_name = "project_features"
end
class Todo < ActiveRecord::Base
include EachBatch
- self.table_name = 'todos'
+ self.table_name = "todos"
end
class Issue < ActiveRecord::Base
include EachBatch
- self.table_name = 'issues'
+ self.table_name = "issues"
end
def perform(start_id, stop_id)
- projects = Project.where('EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)')
+ projects = Project.where("EXISTS (SELECT 1 FROM todos WHERE todos.project_id = projects.id)")
.where(id: start_id..stop_id)
projects.each do |project|
@@ -64,17 +65,17 @@ module Gitlab
# min access level to access a confidential issue is reporter
min_reporters = authorized_users(project_id)
.select(:user_id)
- .where('access_level >= ?', 20)
+ .where("access_level >= ?", 20)
confidential_issues = Issue.select(:id, :author_id).where(confidential: true, project_id: project_id)
confidential_issues.each_batch(of: 100, order_hint: :confidential) do |batch|
batch.each do |issue|
assigned_users = IssueAssignee.select(:user_id).where(issue_id: issue.id)
- todos = Todo.where(target_type: 'Issue', target_id: issue.id)
- .where('user_id NOT IN (?)', min_reporters)
- .where('user_id NOT IN (?)', assigned_users)
- todos = todos.where('user_id != ?', issue.author_id) if issue.author_id
+ todos = Todo.where(target_type: "Issue", target_id: issue.id)
+ .where("user_id NOT IN (?)", min_reporters)
+ .where("user_id NOT IN (?)", assigned_users)
+ todos = todos.where("user_id != ?", issue.author_id) if issue.author_id
todos.delete_all
end
@@ -84,9 +85,9 @@ module Gitlab
def remove_restricted_features_todos(project_id)
ProjectFeature.where(project_id: project_id).each do |project_features|
target_types = []
- target_types << 'Issue' if private?(project_features.issues_access_level)
- target_types << 'MergeRequest' if private?(project_features.merge_requests_access_level)
- target_types << 'Commit' if private?(project_features.repository_access_level)
+ target_types << "Issue" if private?(project_features.issues_access_level)
+ target_types << "MergeRequest" if private?(project_features.merge_requests_access_level)
+ target_types << "Commit" if private?(project_features.repository_access_level)
next if target_types.empty?
@@ -110,7 +111,7 @@ module Gitlab
def unauthorized_project_todos(project_id)
Todo.where(project_id: project_id)
- .where('user_id NOT IN (?)', authorized_users(project_id))
+ .where("user_id NOT IN (?)", authorized_users(project_id))
end
def batch_remove_todos_cte(project_id, target_types = nil)
@@ -127,7 +128,7 @@ module Gitlab
sql << as_deleted_sql
sql << "SELECT count(*) FROM deleted"
- result = Todo.connection.exec_query(sql.join(' '))
+ result = Todo.connection.exec_query(sql.join(" "))
result.rows[0][0].to_i
end
diff --git a/lib/gitlab/background_migration/schedule_diff_files_deletion.rb b/lib/gitlab/background_migration/schedule_diff_files_deletion.rb
index 609cf19187c..4edf5109ad4 100644
--- a/lib/gitlab/background_migration/schedule_diff_files_deletion.rb
+++ b/lib/gitlab/background_migration/schedule_diff_files_deletion.rb
@@ -1,11 +1,12 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
module BackgroundMigration
class ScheduleDiffFilesDeletion
class MergeRequestDiff < ActiveRecord::Base
- self.table_name = 'merge_request_diffs'
+ self.table_name = "merge_request_diffs"
belongs_to :merge_request
@@ -14,12 +15,12 @@ module Gitlab
DIFF_BATCH_SIZE = 5_000
INTERVAL = 5.minutes
- MIGRATION = 'DeleteDiffFiles'
+ MIGRATION = "DeleteDiffFiles"
def perform
diffs = MergeRequestDiff
.from("(#{diffs_collection.to_sql}) merge_request_diffs")
- .where('merge_request_diffs.id != merge_request_diffs.latest_merge_request_diff_id')
+ .where("merge_request_diffs.id != merge_request_diffs.latest_merge_request_diff_id")
.select(:id)
diffs.each_batch(of: DIFF_BATCH_SIZE) do |relation, index|
@@ -35,9 +36,9 @@ module Gitlab
MergeRequestDiff
.joins(:merge_request)
.where("merge_requests.state = 'merged'")
- .where('merge_requests.latest_merge_request_diff_id IS NOT NULL')
+ .where("merge_requests.latest_merge_request_diff_id IS NOT NULL")
.where("merge_request_diffs.state NOT IN ('without_files', 'empty')")
- .select('merge_requests.latest_merge_request_diff_id, merge_request_diffs.id')
+ .select("merge_requests.latest_merge_request_diff_id, merge_request_diffs.id")
end
end
end
diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb
index bc434b0cb64..31f8cf27719 100644
--- a/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb
+++ b/lib/gitlab/background_migration/set_confidential_note_events_on_services.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -7,7 +8,7 @@ module Gitlab
# to receive confidential ones.
class SetConfidentialNoteEventsOnServices
class Service < ActiveRecord::Base
- self.table_name = 'services'
+ self.table_name = "services"
include ::EachBatch
@@ -18,8 +19,8 @@ module Gitlab
def perform(start_id, stop_id)
Service.services_to_update
- .where(id: start_id..stop_id)
- .update_all(confidential_note_events: true)
+ .where(id: start_id..stop_id)
+ .update_all(confidential_note_events: true)
end
end
end
diff --git a/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb
index 28d8d2c640b..4514ba94ec8 100644
--- a/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb
+++ b/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# rubocop:disable Style/Documentation
module Gitlab
@@ -7,7 +8,7 @@ module Gitlab
# to receive confidential ones.
class SetConfidentialNoteEventsOnWebhooks
class WebHook < ActiveRecord::Base
- self.table_name = 'web_hooks'
+ self.table_name = "web_hooks"
include ::EachBatch
@@ -18,8 +19,8 @@ module Gitlab
def perform(start_id, stop_id)
WebHook.hooks_to_update
- .where(id: start_id..stop_id)
- .update_all(confidential_note_events: true)
+ .where(id: start_id..stop_id)
+ .update_all(confidential_note_events: true)
end
end
end
diff --git a/lib/gitlab/badge/coverage/metadata.rb b/lib/gitlab/badge/coverage/metadata.rb
index 9181ba2d4b0..3387ead969c 100644
--- a/lib/gitlab/badge/coverage/metadata.rb
+++ b/lib/gitlab/badge/coverage/metadata.rb
@@ -14,7 +14,7 @@ module Gitlab
end
def title
- 'coverage report'
+ "coverage report"
end
def image_url
diff --git a/lib/gitlab/badge/coverage/report.rb b/lib/gitlab/badge/coverage/report.rb
index 7f7cc62c8ef..18593e9e1ac 100644
--- a/lib/gitlab/badge/coverage/report.rb
+++ b/lib/gitlab/badge/coverage/report.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def entity
- 'coverage'
+ "coverage"
end
def status
diff --git a/lib/gitlab/badge/coverage/template.rb b/lib/gitlab/badge/coverage/template.rb
index 817dc28f84a..a172c0d155a 100644
--- a/lib/gitlab/badge/coverage/template.rb
+++ b/lib/gitlab/badge/coverage/template.rb
@@ -10,11 +10,11 @@ module Gitlab
#
class Template < Badge::Template
STATUS_COLOR = {
- good: '#4c1',
- acceptable: '#a3c51c',
- medium: '#dfb317',
- low: '#e05d44',
- unknown: '#9f9f9f'
+ good: "#4c1",
+ acceptable: "#a3c51c",
+ medium: "#dfb317",
+ low: "#e05d44",
+ unknown: "#9f9f9f",
}.freeze
def initialize(badge)
@@ -27,7 +27,7 @@ module Gitlab
end
def value_text
- @status ? ("%.2f%%" % @status) : 'unknown'
+ @status ? ("%.2f%%" % @status) : "unknown"
end
def key_width
diff --git a/lib/gitlab/badge/pipeline/metadata.rb b/lib/gitlab/badge/pipeline/metadata.rb
index d4d789558c9..0557ad8707c 100644
--- a/lib/gitlab/badge/pipeline/metadata.rb
+++ b/lib/gitlab/badge/pipeline/metadata.rb
@@ -13,7 +13,7 @@ module Gitlab
end
def title
- 'pipeline status'
+ "pipeline status"
end
def image_url
diff --git a/lib/gitlab/badge/pipeline/status.rb b/lib/gitlab/badge/pipeline/status.rb
index a403d839517..4f90e745516 100644
--- a/lib/gitlab/badge/pipeline/status.rb
+++ b/lib/gitlab/badge/pipeline/status.rb
@@ -17,14 +17,14 @@ module Gitlab
end
def entity
- 'pipeline'
+ "pipeline"
end
# rubocop: disable CodeReuse/ActiveRecord
def status
@project.ci_pipelines
.where(sha: @sha)
- .latest_status(@ref) || 'unknown'
+ .latest_status(@ref) || "unknown"
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/badge/pipeline/template.rb b/lib/gitlab/badge/pipeline/template.rb
index 64c3dfcd10b..4e10b735f27 100644
--- a/lib/gitlab/badge/pipeline/template.rb
+++ b/lib/gitlab/badge/pipeline/template.rb
@@ -9,15 +9,15 @@ module Gitlab
# Template object will be passed to badge.svg.erb template.
#
class Template < Badge::Template
- STATUS_RENAME = { 'success' => 'passed' }.freeze
+ STATUS_RENAME = {"success" => "passed"}.freeze
STATUS_COLOR = {
- success: '#4c1',
- failed: '#e05d44',
- running: '#dfb317',
- pending: '#dfb317',
- canceled: '#9f9f9f',
- skipped: '#9f9f9f',
- unknown: '#9f9f9f'
+ success: "#4c1",
+ failed: "#e05d44",
+ running: "#dfb317",
+ pending: "#dfb317",
+ canceled: "#9f9f9f",
+ skipped: "#9f9f9f",
+ unknown: "#9f9f9f",
}.freeze
def initialize(badge)
diff --git a/lib/gitlab/badge/template.rb b/lib/gitlab/badge/template.rb
index ed2ec50b197..a15ffdfad05 100644
--- a/lib/gitlab/badge/template.rb
+++ b/lib/gitlab/badge/template.rb
@@ -32,7 +32,7 @@ module Gitlab
end
def key_color
- '#555'
+ "#555"
end
def key_text_anchor
diff --git a/lib/gitlab/bare_repository_import/importer.rb b/lib/gitlab/bare_repository_import/importer.rb
index 3cd327f5109..c9bd0c5c018 100644
--- a/lib/gitlab/bare_repository_import/importer.rb
+++ b/lib/gitlab/bare_repository_import/importer.rb
@@ -6,14 +6,14 @@ module Gitlab
NoAdminError = Class.new(StandardError)
def self.execute(import_path)
- unless import_path.ends_with?('/')
+ unless import_path.ends_with?("/")
import_path = "#{import_path}/"
end
- repos_to_import = Dir.glob(import_path + '**/*.git')
+ repos_to_import = Dir.glob(import_path + "**/*.git")
unless user = User.admins.order_id_asc.first
- raise NoAdminError.new('No admin user found to import repositories')
+ raise NoAdminError.new("No admin user found to import repositories")
end
repos_to_import.each do |repo_path|
@@ -63,12 +63,12 @@ module Gitlab
group = find_or_create_groups
project = Projects::CreateService.new(user,
- name: project_name,
- path: project_name,
- skip_disk_validation: true,
- skip_wiki: bare_repo.wiki_exists?,
- import_type: 'bare_repository',
- namespace_id: group&.id).execute
+ name: project_name,
+ path: project_name,
+ skip_disk_validation: true,
+ skip_wiki: bare_repo.wiki_exists?,
+ import_type: "bare_repository",
+ namespace_id: group&.id).execute
if project.persisted? && mv_repositories(project)
log " * Created #{project.name} (#{project_full_path})".color(:green)
@@ -120,7 +120,7 @@ module Gitlab
# `git bundle create - --all` and streaming the bundle directly to
# Gitaly, rather than writing it on disk first
bundle_path = "#{repo_path}.bundle"
- cmd = %W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all)
+ cmd = %W[#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} bundle create #{bundle_path} --all]
output, status = Gitlab::Popen.popen(cmd)
raise output unless status.zero?
diff --git a/lib/gitlab/bare_repository_import/repository.rb b/lib/gitlab/bare_repository_import/repository.rb
index b903c581aac..10317fd890b 100644
--- a/lib/gitlab/bare_repository_import/repository.rb
+++ b/lib/gitlab/bare_repository_import/repository.rb
@@ -8,7 +8,7 @@ module Gitlab
attr_reader :group_path, :project_name, :repo_path
def initialize(root_path, repo_path)
- unless root_path.ends_with?('/')
+ unless root_path.ends_with?("/")
root_path = "#{root_path}/"
end
@@ -17,13 +17,13 @@ module Gitlab
full_path =
if hashed? && !wiki?
- repository.config.get('gitlab.fullpath')
+ repository.config.get("gitlab.fullpath")
else
repo_relative_path
end
# Split path into 'all/the/namespaces' and 'project_name'
- @group_path, _, @project_name = full_path.to_s.rpartition('/')
+ @group_path, _, @project_name = full_path.to_s.rpartition("/")
end
def wiki_exists?
@@ -31,7 +31,7 @@ module Gitlab
end
def wiki_path
- @wiki_path ||= repo_path.sub(/\.git$/, '.wiki.git')
+ @wiki_path ||= repo_path.sub(/\.git$/, ".wiki.git")
end
def project_full_path
@@ -49,13 +49,13 @@ module Gitlab
def wiki?
strong_memoize(:wiki) do
- repo_path.end_with?('.wiki.git')
+ repo_path.end_with?(".wiki.git")
end
end
def hashed?
strong_memoize(:hashed) do
- repo_relative_path.include?('@hashed')
+ repo_relative_path.include?("@hashed")
end
end
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index 75a3f17f549..cce4cdbb2fc 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -5,10 +5,10 @@ module Gitlab
class Importer
include Gitlab::ShellAdapter
- LABELS = [{ title: 'bug', color: '#FF0000' },
- { title: 'enhancement', color: '#428BCA' },
- { title: 'proposal', color: '#69D100' },
- { title: 'task', color: '#7F8C8D' }].freeze
+ LABELS = [{title: "bug", color: "#FF0000"},
+ {title: "enhancement", color: "#428BCA"},
+ {title: "proposal", color: "#69D100"},
+ {title: "task", color: "#7F8C8D"},].freeze
attr_reader :project, :client, :errors, :users
@@ -36,8 +36,8 @@ module Gitlab
return unless errors.any?
project.import_state.update_column(:last_error, {
- message: 'The remote data could not be fully imported.',
- errors: errors
+ message: "The remote data could not be fully imported.",
+ errors: errors,
}.to_json)
end
@@ -52,9 +52,9 @@ module Gitlab
return users[username] if users.key?(username)
users[username] = User.select(:id)
- .joins(:identities)
- .find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", username)
- .try(:id)
+ .joins(:identities)
+ .find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", username)
+ .try(:id)
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -68,8 +68,8 @@ module Gitlab
wiki = WikiFormatter.new(project)
gitlab_shell.import_wiki_repository(project, wiki)
- rescue StandardError => e
- errors << { type: :wiki, errors: e.message }
+ rescue => e
+ errors << {type: :wiki, errors: e.message}
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -79,31 +79,29 @@ module Gitlab
create_labels
client.issues(repo).each do |issue|
- begin
- description = ''
- description += @formatter.author_line(issue.author) unless find_user_id(issue.author)
- description += issue.description
-
- label_name = issue.kind
- milestone = issue.milestone ? project.milestones.find_or_create_by(title: issue.milestone) : nil
-
- gitlab_issue = project.issues.create!(
- iid: issue.iid,
- title: issue.title,
- description: description,
- state: issue.state,
- author_id: gitlab_user_id(project, issue.author),
- milestone: milestone,
- created_at: issue.created_at,
- updated_at: issue.updated_at
- )
-
- gitlab_issue.labels << @labels[label_name]
-
- import_issue_comments(issue, gitlab_issue) if gitlab_issue.persisted?
- rescue StandardError => e
- errors << { type: :issue, iid: issue.iid, errors: e.message }
- end
+ description = ""
+ description += @formatter.author_line(issue.author) unless find_user_id(issue.author)
+ description += issue.description
+
+ label_name = issue.kind
+ milestone = issue.milestone ? project.milestones.find_or_create_by(title: issue.milestone) : nil
+
+ gitlab_issue = project.issues.create!(
+ iid: issue.iid,
+ title: issue.title,
+ description: description,
+ state: issue.state,
+ author_id: gitlab_user_id(project, issue.author),
+ milestone: milestone,
+ created_at: issue.created_at,
+ updated_at: issue.updated_at
+ )
+
+ gitlab_issue.labels << @labels[label_name]
+
+ import_issue_comments(issue, gitlab_issue) if gitlab_issue.persisted?
+ rescue => e
+ errors << {type: :issue, iid: issue.iid, errors: e.message}
end
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -117,7 +115,7 @@ module Gitlab
# we do this check.
next unless comment.note.present?
- note = ''
+ note = ""
note += @formatter.author_line(comment.author) unless find_user_id(comment.author)
note += comment.note
@@ -129,8 +127,8 @@ module Gitlab
created_at: comment.created_at,
updated_at: comment.updated_at
)
- rescue StandardError => e
- errors << { type: :issue_comment, iid: issue.iid, errors: e.message }
+ rescue => e
+ errors << {type: :issue_comment, iid: issue.iid, errors: e.message}
end
end
end
@@ -150,37 +148,35 @@ module Gitlab
pull_requests = client.pull_requests(repo)
pull_requests.each do |pull_request|
- begin
- description = ''
- description += @formatter.author_line(pull_request.author) unless find_user_id(pull_request.author)
- description += pull_request.description
-
- source_branch_sha = pull_request.source_branch_sha
- target_branch_sha = pull_request.target_branch_sha
- source_branch_sha = project.repository.commit(source_branch_sha)&.sha || source_branch_sha
- target_branch_sha = project.repository.commit(target_branch_sha)&.sha || target_branch_sha
-
- merge_request = project.merge_requests.create!(
- iid: pull_request.iid,
- title: pull_request.title,
- description: description,
- source_project: project,
- source_branch: pull_request.source_branch_name,
- source_branch_sha: source_branch_sha,
- target_project: project,
- target_branch: pull_request.target_branch_name,
- target_branch_sha: target_branch_sha,
- state: pull_request.state,
- author_id: gitlab_user_id(project, pull_request.author),
- assignee_id: nil,
- created_at: pull_request.created_at,
- updated_at: pull_request.updated_at
- )
-
- import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
- rescue StandardError => e
- errors << { type: :pull_request, iid: pull_request.iid, errors: e.message, trace: e.backtrace.join("\n"), raw_response: pull_request.raw }
- end
+ description = ""
+ description += @formatter.author_line(pull_request.author) unless find_user_id(pull_request.author)
+ description += pull_request.description
+
+ source_branch_sha = pull_request.source_branch_sha
+ target_branch_sha = pull_request.target_branch_sha
+ source_branch_sha = project.repository.commit(source_branch_sha)&.sha || source_branch_sha
+ target_branch_sha = project.repository.commit(target_branch_sha)&.sha || target_branch_sha
+
+ merge_request = project.merge_requests.create!(
+ iid: pull_request.iid,
+ title: pull_request.title,
+ description: description,
+ source_project: project,
+ source_branch: pull_request.source_branch_name,
+ source_branch_sha: source_branch_sha,
+ target_project: project,
+ target_branch: pull_request.target_branch_name,
+ target_branch_sha: target_branch_sha,
+ state: pull_request.state,
+ author_id: gitlab_user_id(project, pull_request.author),
+ assignee_id: nil,
+ created_at: pull_request.created_at,
+ updated_at: pull_request.updated_at
+ )
+
+ import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
+ rescue => e
+ errors << {type: :pull_request, iid: pull_request.iid, errors: e.message, trace: e.backtrace.join("\n"), raw_response: pull_request.raw}
end
end
@@ -211,23 +207,20 @@ module Gitlab
end
inline_comments.each do |comment|
- begin
- attributes = pull_request_comment_attributes(comment)
- attributes[:discussion_id] = discussion_map[comment.parent_id] if comment.has_parent?
+ attributes = pull_request_comment_attributes(comment)
+ attributes[:discussion_id] = discussion_map[comment.parent_id] if comment.has_parent?
- attributes.merge!(
- position: position_map[comment.iid],
- type: 'DiffNote')
+ attributes[:position] = position_map[comment.iid]
+ attributes[:type] = "DiffNote"
- note = merge_request.notes.create!(attributes)
+ note = merge_request.notes.create!(attributes)
- # We can't store a discussion ID until a note is created, so if
- # replies are created before the parent the discussion ID won't be
- # linked properly.
- discussion_map[comment.iid] = note.discussion_id
- rescue StandardError => e
- errors << { type: :pull_request, iid: comment.iid, errors: e.message }
- end
+ # We can't store a discussion ID until a note is created, so if
+ # replies are created before the parent the discussion ID won't be
+ # linked properly.
+ discussion_map[comment.iid] = note.discussion_id
+ rescue => e
+ errors << {type: :pull_request, iid: comment.iid, errors: e.message}
end
end
@@ -237,7 +230,7 @@ module Gitlab
old_path: pr_comment.file_path,
new_path: pr_comment.file_path,
old_line: pr_comment.old_pos,
- new_line: pr_comment.new_pos
+ new_line: pr_comment.new_pos,
}
Gitlab::Diff::Position.new(params)
@@ -245,11 +238,9 @@ module Gitlab
def import_standalone_pr_comments(pr_comments, merge_request)
pr_comments.each do |comment|
- begin
- merge_request.notes.create!(pull_request_comment_attributes(comment))
- rescue StandardError => e
- errors << { type: :pull_request, iid: comment.iid, errors: e.message }
- end
+ merge_request.notes.create!(pull_request_comment_attributes(comment))
+ rescue => e
+ errors << {type: :pull_request, iid: comment.iid, errors: e.message}
end
end
@@ -259,7 +250,7 @@ module Gitlab
note: comment.note,
author_id: gitlab_user_id(project, comment.author),
created_at: comment.created_at,
- updated_at: comment.updated_at
+ updated_at: comment.updated_at,
}
end
end
diff --git a/lib/gitlab/bitbucket_import/project_creator.rb b/lib/gitlab/bitbucket_import/project_creator.rb
index 11070a68e02..ebad4f27c0f 100644
--- a/lib/gitlab/bitbucket_import/project_creator.rb
+++ b/lib/gitlab/bitbucket_import/project_creator.rb
@@ -21,10 +21,10 @@ module Gitlab
description: repo.description,
namespace_id: namespace.id,
visibility_level: repo.visibility_level,
- import_type: 'bitbucket',
+ import_type: "bitbucket",
import_source: repo.full_name,
import_url: repo.clone_url(session_data[:token]),
- import_data: { credentials: session_data },
+ import_data: {credentials: session_data},
skip_wiki: skip_wiki
).execute
end
diff --git a/lib/gitlab/bitbucket_server_import/importer.rb b/lib/gitlab/bitbucket_server_import/importer.rb
index dbbedd5dcbe..65b588cbdab 100644
--- a/lib/gitlab/bitbucket_server_import/importer.rb
+++ b/lib/gitlab/bitbucket_server_import/importer.rb
@@ -7,7 +7,7 @@ module Gitlab
attr_reader :project, :project_key, :repository_slug, :client, :errors, :users
attr_accessor :logger
- REMOTE_NAME = 'bitbucket_server'.freeze
+ REMOTE_NAME = "bitbucket_server"
BATCH_SIZE = 100
TempBranch = Struct.new(:name, :sha)
@@ -17,7 +17,7 @@ module Gitlab
end
def self.refmap
- [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head']
+ [:heads, :tags, "+refs/pull-requests/*/to:refs/merge-requests/*/head"]
end
# Unlike GitHub, you can't grab the commit SHAs for pull requests that
@@ -28,8 +28,8 @@ module Gitlab
def initialize(project, recover_missing_commits: false)
@project = project
@recover_missing_commits = recover_missing_commits
- @project_key = project.import_data.data['project_key']
- @repository_slug = project.import_data.data['repo_slug']
+ @project_key = project.import_data.data["project_key"]
+ @repository_slug = project.import_data.data["repo_slug"]
@client = BitbucketServer::Client.new(project.import_data.credentials)
@formatter = Gitlab::ImportFormatter.new
@errors = []
@@ -55,8 +55,8 @@ module Gitlab
return unless errors.any?
project.import_state.update_column(:last_error, {
- message: 'The remote data could not be fully imported.',
- errors: errors
+ message: "The remote data could not be fully imported.",
+ errors: errors,
}.to_json)
end
@@ -96,9 +96,9 @@ module Gitlab
pull_requests.each do |pull_request|
shas_to_restore << TempBranch.new(temp_branch_name(pull_request, :from),
- pull_request.source_branch_sha)
+ pull_request.source_branch_sha)
shas_to_restore << TempBranch.new(temp_branch_name(pull_request, :to),
- pull_request.target_branch_sha)
+ pull_request.target_branch_sha)
end
# Create the branches on the Bitbucket Server first
@@ -126,14 +126,14 @@ module Gitlab
end
def import_repository
- log_info(stage: 'import_repository', message: 'starting import')
+ log_info(stage: "import_repository", message: "starting import")
project.ensure_repository
project.repository.fetch_as_mirror(project.import_url, refmap: self.class.refmap, remote_name: REMOTE_NAME)
- log_info(stage: 'import_repository', message: 'finished import')
+ log_info(stage: "import_repository", message: "finished import")
rescue Gitlab::Shell::Error => e
- log_error(stage: 'import_repository', message: 'failed import', error: e.message)
+ log_error(stage: "import_repository", message: "failed import", error: e.message)
# Expire cache to prevent scenarios such as:
# 1. First import failed, but the repo was imported successfully, so +exists?+ returns true
@@ -162,34 +162,30 @@ module Gitlab
restore_branches(batch) if recover_missing_commits
batch.each do |pull_request|
- begin
- import_bitbucket_pull_request(pull_request)
- rescue StandardError => e
- backtrace = Gitlab::Profiler.clean_backtrace(e.backtrace)
- log_error(stage: 'import_pull_requests', iid: pull_request.iid, error: e.message, backtrace: backtrace)
-
- errors << { type: :pull_request, iid: pull_request.iid, errors: e.message, backtrace: backtrace.join("\n"), raw_response: pull_request.raw }
- end
+ import_bitbucket_pull_request(pull_request)
+ rescue => e
+ backtrace = Gitlab::Profiler.clean_backtrace(e.backtrace)
+ log_error(stage: "import_pull_requests", iid: pull_request.iid, error: e.message, backtrace: backtrace)
+
+ errors << {type: :pull_request, iid: pull_request.iid, errors: e.message, backtrace: backtrace.join("\n"), raw_response: pull_request.raw}
end
end
end
def delete_temp_branches
@temp_branches.each do |branch|
- begin
- client.delete_branch(project_key, repository_slug, branch.name, branch.sha)
- project.repository.delete_branch(branch.name)
- rescue BitbucketServer::Connection::ConnectionError => e
- log_error(stage: 'delete_temp_branches', branch: branch.name, error: e.message)
- @errors << { type: :delete_temp_branches, branch_name: branch.name, errors: e.message }
- end
+ client.delete_branch(project_key, repository_slug, branch.name, branch.sha)
+ project.repository.delete_branch(branch.name)
+ rescue BitbucketServer::Connection::ConnectionError => e
+ log_error(stage: "delete_temp_branches", branch: branch.name, error: e.message)
+ @errors << {type: :delete_temp_branches, branch_name: branch.name, errors: e.message}
end
end
def import_bitbucket_pull_request(pull_request)
- log_info(stage: 'import_bitbucket_pull_requests', message: 'starting', iid: pull_request.iid)
+ log_info(stage: "import_bitbucket_pull_requests", message: "starting", iid: pull_request.iid)
- description = ''
+ description = ""
description += @formatter.author_line(pull_request.author) unless find_user_id(pull_request.author_email)
description += pull_request.description if pull_request.description
author_id = gitlab_user_id(pull_request.author_email)
@@ -208,7 +204,7 @@ module Gitlab
author_id: author_id,
assignee_id: nil,
created_at: pull_request.created_at,
- updated_at: pull_request.updated_at
+ updated_at: pull_request.updated_at,
}
creator = Gitlab::Import::MergeRequestCreator.new(project)
@@ -216,11 +212,11 @@ module Gitlab
import_pull_request_comments(pull_request, merge_request) if merge_request.persisted?
- log_info(stage: 'import_bitbucket_pull_requests', message: 'finished', iid: pull_request.iid)
+ log_info(stage: "import_bitbucket_pull_requests", message: "finished", iid: pull_request.iid)
end
def import_pull_request_comments(pull_request, merge_request)
- log_info(stage: 'import_pull_request_comments', message: 'starting', iid: merge_request.iid)
+ log_info(stage: "import_pull_request_comments", message: "starting", iid: merge_request.iid)
comments, other_activities = client.activities(project_key, repository_slug, pull_request.iid).partition(&:comment?)
@@ -232,7 +228,7 @@ module Gitlab
import_inline_comments(inline_comments.map(&:comment), merge_request)
import_standalone_pr_comments(pr_comments.map(&:comment), merge_request)
- log_info(stage: 'import_pull_request_comments', message: 'finished', iid: merge_request.iid,
+ log_info(stage: "import_pull_request_comments", message: "finished", iid: merge_request.iid,
merge_event_found: merge_event.present?,
inline_comments_count: inline_comments.count,
standalone_pr_comments: pr_comments.count)
@@ -240,22 +236,22 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def import_merge_event(merge_request, merge_event)
- log_info(stage: 'import_merge_event', message: 'starting', iid: merge_request.iid)
+ log_info(stage: "import_merge_event", message: "starting", iid: merge_request.iid)
committer = merge_event.committer_email
user_id = gitlab_user_id(committer)
timestamp = merge_event.merge_timestamp
- merge_request.update({ merge_commit_sha: merge_event.merge_commit })
+ merge_request.update({merge_commit_sha: merge_event.merge_commit})
metric = MergeRequest::Metrics.find_or_initialize_by(merge_request: merge_request)
metric.update(merged_by_id: user_id, merged_at: timestamp)
- log_info(stage: 'import_merge_event', message: 'finished', iid: merge_request.iid)
+ log_info(stage: "import_merge_event", message: "finished", iid: merge_request.iid)
end
# rubocop: enable CodeReuse/ActiveRecord
def import_inline_comments(inline_comments, merge_request)
- log_info(stage: 'import_inline_comments', message: 'starting', iid: merge_request.iid)
+ log_info(stage: "import_inline_comments", message: "starting", iid: merge_request.iid)
inline_comments.each do |comment|
position = build_position(merge_request, comment)
@@ -270,12 +266,13 @@ module Gitlab
end
end
- log_info(stage: 'import_inline_comments', message: 'finished', iid: merge_request.iid)
+ log_info(stage: "import_inline_comments", message: "finished", iid: merge_request.iid)
end
def create_diff_note(merge_request, comment, position, discussion_id = nil)
attributes = pull_request_comment_attributes(comment)
- attributes.merge!(position: position, type: 'DiffNote')
+ attributes[:position] = position
+ attributes[:type] = "DiffNote"
attributes[:discussion_id] = discussion_id if discussion_id
note = merge_request.notes.build(attributes)
@@ -285,15 +282,15 @@ module Gitlab
return note
end
- log_info(stage: 'create_diff_note', message: 'creating fallback DiffNote', iid: merge_request.iid)
+ log_info(stage: "create_diff_note", message: "creating fallback DiffNote", iid: merge_request.iid)
# Bitbucket Server supports the ability to comment on any line, not just the
# line in the diff. If we can't add the note as a DiffNote, fallback to creating
# a regular note.
create_fallback_diff_note(merge_request, comment, position)
- rescue StandardError => e
- log_error(stage: 'create_diff_note', comment_id: comment.id, error: e.message)
- errors << { type: :pull_request, id: comment.id, errors: e.message }
+ rescue => e
+ log_error(stage: "create_diff_note", comment_id: comment.id, error: e.message)
+ errors << {type: :pull_request, id: comment.id, errors: e.message}
nil
end
@@ -315,7 +312,7 @@ module Gitlab
old_path: pr_comment.file_path,
new_path: pr_comment.file_path,
old_line: pr_comment.old_pos,
- new_line: pr_comment.new_pos
+ new_line: pr_comment.new_pos,
}
Gitlab::Diff::Position.new(params)
@@ -323,22 +320,20 @@ module Gitlab
def import_standalone_pr_comments(pr_comments, merge_request)
pr_comments.each do |comment|
- begin
- merge_request.notes.create!(pull_request_comment_attributes(comment))
-
- comment.comments.each do |replies|
- merge_request.notes.create!(pull_request_comment_attributes(replies))
- end
- rescue StandardError => e
- log_error(stage: 'import_standalone_pr_comments', merge_request_id: merge_request.id, comment_id: comment.id, error: e.message)
- errors << { type: :pull_request, comment_id: comment.id, errors: e.message }
+ merge_request.notes.create!(pull_request_comment_attributes(comment))
+
+ comment.comments.each do |replies|
+ merge_request.notes.create!(pull_request_comment_attributes(replies))
end
+ rescue => e
+ log_error(stage: "import_standalone_pr_comments", merge_request_id: merge_request.id, comment_id: comment.id, error: e.message)
+ errors << {type: :pull_request, comment_id: comment.id, errors: e.message}
end
end
def pull_request_comment_attributes(comment)
author = find_user_id(comment.author_email)
- note = ''
+ note = ""
unless author
author = project.creator_id
@@ -358,7 +353,7 @@ module Gitlab
note: note,
author_id: author,
created_at: comment.created_at,
- updated_at: comment.updated_at
+ updated_at: comment.updated_at,
}
end
@@ -378,7 +373,7 @@ module Gitlab
{
class: self.class.name,
project_id: project.id,
- project_path: project.full_path
+ project_path: project.full_path,
}
end
end
diff --git a/lib/gitlab/bitbucket_server_import/project_creator.rb b/lib/gitlab/bitbucket_server_import/project_creator.rb
index 48ca4951957..fc872e1f051 100644
--- a/lib/gitlab/bitbucket_server_import/project_creator.rb
+++ b/lib/gitlab/bitbucket_server_import/project_creator.rb
@@ -23,12 +23,12 @@ module Gitlab
description: repo.description,
namespace_id: namespace.id,
visibility_level: repo.visibility_level,
- import_type: 'bitbucket_server',
+ import_type: "bitbucket_server",
import_source: repo.browse_url,
import_url: repo.clone_url,
import_data: {
credentials: session_data,
- data: { project_key: project_key, repo_slug: repo_slug }
+ data: {project_key: project_key, repo_slug: repo_slug},
},
skip_wiki: true
).execute
diff --git a/lib/gitlab/blame.rb b/lib/gitlab/blame.rb
index f1a653a9d95..551484c0722 100644
--- a/lib/gitlab/blame.rb
+++ b/lib/gitlab/blame.rb
@@ -21,7 +21,7 @@ module Gitlab
sha = commit.sha
if prev_sha != sha
groups << current_group if current_group
- current_group = { commit: commit, lines: [] }
+ current_group = {commit: commit, lines: []}
end
line = highlighted_lines[i].html_safe if highlight
diff --git a/lib/gitlab/blob_helper.rb b/lib/gitlab/blob_helper.rb
index d3e15a79a8b..5a32d01c8a2 100644
--- a/lib/gitlab/blob_helper.rb
+++ b/lib/gitlab/blob_helper.rb
@@ -45,7 +45,7 @@ module Gitlab
end
def image?
- ['.png', '.jpg', '.jpeg', '.gif'].include?(extname.downcase)
+ [".png", ".jpg", ".jpeg", ".gif"].include?(extname.downcase)
end
# Internal: Lookup mime type for extension.
@@ -73,7 +73,7 @@ module Gitlab
#
# Returns a mime type String.
def mime_type
- _mime_type ? _mime_type.to_s : 'text/plain'
+ _mime_type ? _mime_type.to_s : "text/plain"
end
def binary_mime_type?
diff --git a/lib/gitlab/cache/ci/project_pipeline_status.rb b/lib/gitlab/cache/ci/project_pipeline_status.rb
index ea7013db2ce..08b7009e541 100644
--- a/lib/gitlab/cache/ci/project_pipeline_status.rb
+++ b/lib/gitlab/cache/ci/project_pipeline_status.rb
@@ -28,7 +28,7 @@ module Gitlab
pipeline_info = {
sha: pipeline.sha,
status: pipeline.status,
- ref: pipeline.ref
+ ref: pipeline.ref,
}
new(pipeline.project, pipeline_info: pipeline_info)
@@ -81,13 +81,13 @@ module Gitlab
Gitlab::Redis::Cache.with do |redis|
self.sha, self.status, self.ref = redis.hmget(cache_key, :sha, :status, :ref)
- self.status = nil if self.status.empty?
+ self.status = nil if status.empty?
end
end
def store_in_cache
Gitlab::Redis::Cache.with do |redis|
- redis.mapped_hmset(cache_key, { sha: sha, status: status, ref: ref })
+ redis.mapped_hmset(cache_key, {sha: sha, status: status, ref: ref})
end
end
@@ -98,7 +98,7 @@ module Gitlab
end
def has_cache?
- return self.loaded unless self.loaded.nil?
+ return loaded unless loaded.nil?
Gitlab::Redis::Cache.with do |redis|
redis.exists(cache_key)
@@ -106,7 +106,7 @@ module Gitlab
end
def loaded?
- self.loaded
+ loaded
end
def cache_key
diff --git a/lib/gitlab/cache/request_cache.rb b/lib/gitlab/cache/request_cache.rb
index 4c658dc0b8d..4f6fab795ac 100644
--- a/lib/gitlab/cache/request_cache.rb
+++ b/lib/gitlab/cache/request_cache.rb
@@ -32,7 +32,7 @@ module Gitlab
Gitlab::SafeRequestStore.store
else
ivar_name = # ! and ? cannot be used as ivar name
- "@cache_#{method_name.to_s.tr('!?', "\u2605\u2606")}"
+ "@cache_#{method_name.to_s.tr("!?", "\u2605\u2606")}"
instance_variable_get(ivar_name) ||
instance_variable_set(ivar_name, {})
@@ -52,7 +52,7 @@ module Gitlab
method_key = instance_exec(&method_key_block) if method_key_block
[klass.name, method_name, *instance_key, *method_key, *args]
- .join(':')
+ .join(":")
end
private cache_key_method_name
diff --git a/lib/gitlab/changes_list.rb b/lib/gitlab/changes_list.rb
index fb75a78a978..32b9f3465a5 100644
--- a/lib/gitlab/changes_list.rb
+++ b/lib/gitlab/changes_list.rb
@@ -16,12 +16,12 @@ module Gitlab
def changes
@changes ||= begin
- @raw_changes.map do |change|
+ @raw_changes.map { |change|
next if change.blank?
- oldrev, newrev, ref = change.strip.split(' ')
- { oldrev: oldrev, newrev: newrev, ref: ref }
- end.compact
+ oldrev, newrev, ref = change.strip.split(" ")
+ {oldrev: oldrev, newrev: newrev, ref: ref}
+ }.compact
end
end
end
diff --git a/lib/gitlab/chat/command.rb b/lib/gitlab/chat/command.rb
index 49b7dcf4bbe..34a095a3cce 100644
--- a/lib/gitlab/chat/command.rb
+++ b/lib/gitlab/chat/command.rb
@@ -12,7 +12,7 @@ module Gitlab
include Utils::StrongMemoize
attr_reader :project, :chat_name, :name, :arguments, :response_url,
- :channel
+ :channel
# project - The Project to schedule the command for.
# chat_name - The ChatName belonging to the user that scheduled the
@@ -50,7 +50,7 @@ module Gitlab
chat_name_id: chat_name.id,
command: name,
arguments: arguments,
- response_url: response_url
+ response_url: response_url,
}
)
@@ -63,8 +63,8 @@ module Gitlab
# pipeline - The `Ci::Pipeline` to create the environment variables for.
def build_environment_variables(pipeline)
pipeline.variables.build(
- [{ key: 'CHAT_INPUT', value: arguments },
- { key: 'CHAT_CHANNEL', value: channel }]
+ [{key: "CHAT_INPUT", value: arguments},
+ {key: "CHAT_CHANNEL", value: channel},]
)
end
diff --git a/lib/gitlab/chat/output.rb b/lib/gitlab/chat/output.rb
index 411b1555a7d..08724c9b285 100644
--- a/lib/gitlab/chat/output.rb
+++ b/lib/gitlab/chat/output.rb
@@ -9,10 +9,10 @@ module Gitlab
MissingBuildSectionError = Class.new(StandardError)
# The primary trace section to look for.
- PRIMARY_SECTION = 'chat_reply'
+ PRIMARY_SECTION = "chat_reply"
# The backup trace section in case the primary one could not be found.
- FALLBACK_SECTION = 'build_script'
+ FALLBACK_SECTION = "build_script"
# build - The `Ci::Build` to obtain the output from.
def initialize(build)
@@ -69,7 +69,7 @@ module Gitlab
if (converted = output.split("\n")[1..-1])
converted.join("\n")
else
- ''
+ ""
end
end
diff --git a/lib/gitlab/chat/responder/base.rb b/lib/gitlab/chat/responder/base.rb
index f1ad0e36793..c0f71eee172 100644
--- a/lib/gitlab/chat/responder/base.rb
+++ b/lib/gitlab/chat/responder/base.rb
@@ -20,19 +20,19 @@ module Gitlab
end
def success(*)
- raise NotImplementedError, 'You must implement #success(output)'
+ raise NotImplementedError, "You must implement #success(output)"
end
def failure
- raise NotImplementedError, 'You must implement #failure'
+ raise NotImplementedError, "You must implement #failure"
end
def send_response(output)
- raise NotImplementedError, 'You must implement #send_response(output)'
+ raise NotImplementedError, "You must implement #send_response(output)"
end
def scheduled_output
- raise NotImplementedError, 'You must implement #scheduled_output'
+ raise NotImplementedError, "You must implement #scheduled_output"
end
end
end
diff --git a/lib/gitlab/chat/responder/slack.rb b/lib/gitlab/chat/responder/slack.rb
index 0cf02c92a67..90457a214b8 100644
--- a/lib/gitlab/chat/responder/slack.rb
+++ b/lib/gitlab/chat/responder/slack.rb
@@ -4,8 +4,8 @@ module Gitlab
module Chat
module Responder
class Slack < Responder::Base
- SUCCESS_COLOR = '#B3ED8E'
- FAILURE_COLOR = '#FF5640'
+ SUCCESS_COLOR = "#B3ED8E"
+ FAILURE_COLOR = "#FF5640"
RESPONSE_TYPE = :in_channel
# Slack breaks messages apart if they're around 4 KB in size. We use a
@@ -19,8 +19,8 @@ module Gitlab
Gitlab::HTTP.post(
pipeline.chat_data.response_url,
{
- headers: { Accept: 'application/json' },
- body: output.to_json
+ headers: {Accept: "application/json"},
+ body: output.to_json,
}
)
end
@@ -50,7 +50,7 @@ module Gitlab
# We return an empty message so that Slack still shows the input
# command, without polluting the channel with standard "The job has
# been scheduled" (or similar) responses.
- { text: '' }
+ {text: ""}
end
private
diff --git a/lib/gitlab/chat_name_token.rb b/lib/gitlab/chat_name_token.rb
index 8b3c5dc9e8b..4b7ee694e86 100644
--- a/lib/gitlab/chat_name_token.rb
+++ b/lib/gitlab/chat_name_token.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'json'
+require "json"
module Gitlab
class ChatNameToken
diff --git a/lib/gitlab/checks/base_checker.rb b/lib/gitlab/checks/base_checker.rb
index 09b17b5b76b..e499ed4a209 100644
--- a/lib/gitlab/checks/base_checker.rb
+++ b/lib/gitlab/checks/base_checker.rb
@@ -31,7 +31,7 @@ module Gitlab
end
def updated_from_web?
- protocol == 'web'
+ protocol == "web"
end
def tag_exists?
diff --git a/lib/gitlab/checks/branch_check.rb b/lib/gitlab/checks/branch_check.rb
index d06b2df36f2..cdc8fe43bf2 100644
--- a/lib/gitlab/checks/branch_check.rb
+++ b/lib/gitlab/checks/branch_check.rb
@@ -4,19 +4,19 @@ module Gitlab
module Checks
class BranchCheck < BaseChecker
ERROR_MESSAGES = {
- delete_default_branch: 'The default branch of a project cannot be deleted.',
- force_push_protected_branch: 'You are not allowed to force push code to a protected branch on this project.',
- non_master_delete_protected_branch: 'You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.',
- non_web_delete_protected_branch: 'You can only delete protected branches using the web interface.',
- merge_protected_branch: 'You are not allowed to merge code into protected branches on this project.',
- push_protected_branch: 'You are not allowed to push code to protected branches on this project.'
+ delete_default_branch: "The default branch of a project cannot be deleted.",
+ force_push_protected_branch: "You are not allowed to force push code to a protected branch on this project.",
+ non_master_delete_protected_branch: "You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.",
+ non_web_delete_protected_branch: "You can only delete protected branches using the web interface.",
+ merge_protected_branch: "You are not allowed to merge code into protected branches on this project.",
+ push_protected_branch: "You are not allowed to push code to protected branches on this project.",
}.freeze
LOG_MESSAGES = {
delete_default_branch_check: "Checking if default branch is being deleted...",
protected_branch_checks: "Checking if you are force pushing to a protected branch...",
protected_branch_push_checks: "Checking if you are allowed to push to the protected branch...",
- protected_branch_deletion_checks: "Checking if you are allowed to delete the protected branch..."
+ protected_branch_deletion_checks: "Checking if you are allowed to delete the protected branch...",
}.freeze
def validate!
@@ -85,11 +85,9 @@ module Gitlab
def empty_project_push_message
<<~MESSAGE
-
- A default branch (e.g. master) does not yet exist for #{project.full_path}
- Ask a project Owner or Maintainer to create a default branch:
-
- #{project_members_url}
+ A default branch (e.g. master) does not yet exist for #{project.full_path}
+ Ask a project Owner or Maintainer to create a default branch:
+ #{project_members_url}
MESSAGE
end
diff --git a/lib/gitlab/checks/diff_check.rb b/lib/gitlab/checks/diff_check.rb
index ea0d8c85a66..6eb3647bc01 100644
--- a/lib/gitlab/checks/diff_check.rb
+++ b/lib/gitlab/checks/diff_check.rb
@@ -7,7 +7,7 @@ module Gitlab
LOG_MESSAGES = {
validate_file_paths: "Validating diffs' file paths...",
- diff_content_check: "Validating diff contents..."
+ diff_content_check: "Validating diff contents...",
}.freeze
def validate!
diff --git a/lib/gitlab/checks/lfs_check.rb b/lib/gitlab/checks/lfs_check.rb
index cc6a14d2d9a..333284424e0 100644
--- a/lib/gitlab/checks/lfs_check.rb
+++ b/lib/gitlab/checks/lfs_check.rb
@@ -3,8 +3,8 @@
module Gitlab
module Checks
class LfsCheck < BaseChecker
- LOG_MESSAGE = "Scanning repository for blobs stored in LFS and verifying their files have been uploaded to GitLab...".freeze
- ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'.freeze
+ LOG_MESSAGE = "Scanning repository for blobs stored in LFS and verifying their files have been uploaded to GitLab..."
+ ERROR_MESSAGE = 'LFS objects are missing. Ensure LFS is properly set up or try a manual "git lfs push --all".'
def validate!
return unless project.lfs_enabled?
diff --git a/lib/gitlab/checks/lfs_integrity.rb b/lib/gitlab/checks/lfs_integrity.rb
index 1652d5a30a4..d36bcc56099 100644
--- a/lib/gitlab/checks/lfs_integrity.rb
+++ b/lib/gitlab/checks/lfs_integrity.rb
@@ -14,13 +14,13 @@ module Gitlab
return false unless @newrev && @project.lfs_enabled?
new_lfs_pointers = Gitlab::Git::LfsChanges.new(@project.repository, @newrev)
- .new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)
+ .new_pointers(object_limit: ::Gitlab::Git::Repository::REV_LIST_COMMIT_LIMIT, dynamic_timeout: @time_left)
return false unless new_lfs_pointers.present?
existing_count = @project.all_lfs_objects
- .where(oid: new_lfs_pointers.map(&:lfs_oid))
- .count
+ .where(oid: new_lfs_pointers.map(&:lfs_oid))
+ .count
existing_count != new_lfs_pointers.count
end
diff --git a/lib/gitlab/checks/post_push_message.rb b/lib/gitlab/checks/post_push_message.rb
index 492dbb5a596..5ef077b517c 100644
--- a/lib/gitlab/checks/post_push_message.rb
+++ b/lib/gitlab/checks/post_push_message.rb
@@ -41,7 +41,7 @@ module Gitlab
end
def url_to_repo
- protocol == 'ssh' ? project.ssh_url_to_repo : project.http_url_to_repo
+ protocol == "ssh" ? project.ssh_url_to_repo : project.http_url_to_repo
end
end
end
diff --git a/lib/gitlab/checks/project_created.rb b/lib/gitlab/checks/project_created.rb
index 0058a402a62..9c40efd2699 100644
--- a/lib/gitlab/checks/project_created.rb
+++ b/lib/gitlab/checks/project_created.rb
@@ -3,18 +3,15 @@
module Gitlab
module Checks
class ProjectCreated < PostPushMessage
- PROJECT_CREATED = "project_created".freeze
+ PROJECT_CREATED = "project_created"
def message
<<~MESSAGE
-
- The private project #{project.full_path} was successfully created.
-
- To configure the remote, run:
- git remote add origin #{url_to_repo}
-
- To view the project, visit:
- #{project_url}
+ The private project #{project.full_path} was successfully created.
+ To configure the remote, run:
+ git remote add origin #{url_to_repo}
+ To view the project, visit:
+ #{project_url}
MESSAGE
end
diff --git a/lib/gitlab/checks/project_moved.rb b/lib/gitlab/checks/project_moved.rb
index cb3b7acaaad..5c78d1c278f 100644
--- a/lib/gitlab/checks/project_moved.rb
+++ b/lib/gitlab/checks/project_moved.rb
@@ -3,7 +3,7 @@
module Gitlab
module Checks
class ProjectMoved < PostPushMessage
- REDIRECT_NAMESPACE = "redirect_namespace".freeze
+ REDIRECT_NAMESPACE = "redirect_namespace"
def initialize(project, user, protocol, redirected_path)
@redirected_path = redirected_path
@@ -13,11 +13,9 @@ module Gitlab
def message
<<~MESSAGE
- Project '#{redirected_path}' was moved to '#{project.full_path}'.
-
- Please update your Git remote:
-
- git remote set-url origin #{url_to_repo}
+ Project '#{redirected_path}' was moved to '#{project.full_path}'.
+ Please update your Git remote:
+ git remote set-url origin #{url_to_repo}
MESSAGE
end
diff --git a/lib/gitlab/checks/tag_check.rb b/lib/gitlab/checks/tag_check.rb
index 2a75c8059bd..55613155077 100644
--- a/lib/gitlab/checks/tag_check.rb
+++ b/lib/gitlab/checks/tag_check.rb
@@ -4,15 +4,15 @@ module Gitlab
module Checks
class TagCheck < BaseChecker
ERROR_MESSAGES = {
- change_existing_tags: 'You are not allowed to change existing tags on this project.',
- update_protected_tag: 'Protected tags cannot be updated.',
- delete_protected_tag: 'Protected tags cannot be deleted.',
- create_protected_tag: 'You are not allowed to create this tag as it is protected.'
+ change_existing_tags: "You are not allowed to change existing tags on this project.",
+ update_protected_tag: "Protected tags cannot be updated.",
+ delete_protected_tag: "Protected tags cannot be deleted.",
+ create_protected_tag: "You are not allowed to create this tag as it is protected.",
}.freeze
LOG_MESSAGES = {
tag_checks: "Checking if you are allowed to change existing tags...",
- protected_tag_checks: "Checking if you are creating, updating or deleting a protected tag..."
+ protected_tag_checks: "Checking if you are creating, updating or deleting a protected tag...",
}.freeze
def validate!
diff --git a/lib/gitlab/checks/timed_logger.rb b/lib/gitlab/checks/timed_logger.rb
index f365e0a43f6..6b7d5c6dde2 100644
--- a/lib/gitlab/checks/timed_logger.rb
+++ b/lib/gitlab/checks/timed_logger.rb
@@ -28,7 +28,7 @@ module Gitlab
append_message(log_message + time_suffix_message(start: start))
rescue GRPC::DeadlineExceeded, TimeoutError
- args = { cancelled: true }
+ args = {cancelled: true}
args[:start] = start if timed
append_message(log_message + time_suffix_message(args))
diff --git a/lib/gitlab/ci/ansi2html.rb b/lib/gitlab/ci/ansi2html.rb
index 4dcb3869d4f..bcee5d9043d 100644
--- a/lib/gitlab/ci/ansi2html.rb
+++ b/lib/gitlab/ci/ansi2html.rb
@@ -8,22 +8,22 @@ module Gitlab
module Ansi2html
# keys represent the trailing digit in color changing command (30-37, 40-47, 90-97. 100-107)
COLOR = {
- 0 => 'black', # not that this is gray in the intense color table
- 1 => 'red',
- 2 => 'green',
- 3 => 'yellow',
- 4 => 'blue',
- 5 => 'magenta',
- 6 => 'cyan',
- 7 => 'white', # not that this is gray in the dark (aka default) color table
+ 0 => "black", # not that this is gray in the intense color table
+ 1 => "red",
+ 2 => "green",
+ 3 => "yellow",
+ 4 => "blue",
+ 5 => "magenta",
+ 6 => "cyan",
+ 7 => "white", # not that this is gray in the dark (aka default) color table
}.freeze
STYLE_SWITCHES = {
- bold: 0x01,
- italic: 0x02,
- underline: 0x04,
- conceal: 0x08,
- cross: 0x10
+ bold: 0x01,
+ italic: 0x02,
+ underline: 0x04,
+ conceal: 0x08,
+ cross: 0x10,
}.freeze
def self.convert(ansi, state = nil)
@@ -31,105 +31,205 @@ module Gitlab
end
class Converter
- def on_0(_) reset end
+ def on_0(_)
+ reset
+ end
- def on_1(_) enable(STYLE_SWITCHES[:bold]) end
+ def on_1(_)
+ enable(STYLE_SWITCHES[:bold])
+ end
- def on_3(_) enable(STYLE_SWITCHES[:italic]) end
+ def on_3(_)
+ enable(STYLE_SWITCHES[:italic])
+ end
- def on_4(_) enable(STYLE_SWITCHES[:underline]) end
+ def on_4(_)
+ enable(STYLE_SWITCHES[:underline])
+ end
- def on_8(_) enable(STYLE_SWITCHES[:conceal]) end
+ def on_8(_)
+ enable(STYLE_SWITCHES[:conceal])
+ end
- def on_9(_) enable(STYLE_SWITCHES[:cross]) end
+ def on_9(_)
+ enable(STYLE_SWITCHES[:cross])
+ end
- def on_21(_) disable(STYLE_SWITCHES[:bold]) end
+ def on_21(_)
+ disable(STYLE_SWITCHES[:bold])
+ end
- def on_22(_) disable(STYLE_SWITCHES[:bold]) end
+ def on_22(_)
+ disable(STYLE_SWITCHES[:bold])
+ end
- def on_23(_) disable(STYLE_SWITCHES[:italic]) end
+ def on_23(_)
+ disable(STYLE_SWITCHES[:italic])
+ end
- def on_24(_) disable(STYLE_SWITCHES[:underline]) end
+ def on_24(_)
+ disable(STYLE_SWITCHES[:underline])
+ end
- def on_28(_) disable(STYLE_SWITCHES[:conceal]) end
+ def on_28(_)
+ disable(STYLE_SWITCHES[:conceal])
+ end
- def on_29(_) disable(STYLE_SWITCHES[:cross]) end
+ def on_29(_)
+ disable(STYLE_SWITCHES[:cross])
+ end
- def on_30(_) set_fg_color(0) end
+ def on_30(_)
+ set_fg_color(0)
+ end
- def on_31(_) set_fg_color(1) end
+ def on_31(_)
+ set_fg_color(1)
+ end
- def on_32(_) set_fg_color(2) end
+ def on_32(_)
+ set_fg_color(2)
+ end
- def on_33(_) set_fg_color(3) end
+ def on_33(_)
+ set_fg_color(3)
+ end
- def on_34(_) set_fg_color(4) end
+ def on_34(_)
+ set_fg_color(4)
+ end
- def on_35(_) set_fg_color(5) end
+ def on_35(_)
+ set_fg_color(5)
+ end
- def on_36(_) set_fg_color(6) end
+ def on_36(_)
+ set_fg_color(6)
+ end
- def on_37(_) set_fg_color(7) end
+ def on_37(_)
+ set_fg_color(7)
+ end
- def on_38(stack) set_fg_color_256(stack) end
+ def on_38(stack)
+ set_fg_color_256(stack)
+ end
- def on_39(_) set_fg_color(9) end
+ def on_39(_)
+ set_fg_color(9)
+ end
- def on_40(_) set_bg_color(0) end
+ def on_40(_)
+ set_bg_color(0)
+ end
- def on_41(_) set_bg_color(1) end
+ def on_41(_)
+ set_bg_color(1)
+ end
- def on_42(_) set_bg_color(2) end
+ def on_42(_)
+ set_bg_color(2)
+ end
- def on_43(_) set_bg_color(3) end
+ def on_43(_)
+ set_bg_color(3)
+ end
- def on_44(_) set_bg_color(4) end
+ def on_44(_)
+ set_bg_color(4)
+ end
- def on_45(_) set_bg_color(5) end
+ def on_45(_)
+ set_bg_color(5)
+ end
- def on_46(_) set_bg_color(6) end
+ def on_46(_)
+ set_bg_color(6)
+ end
- def on_47(_) set_bg_color(7) end
+ def on_47(_)
+ set_bg_color(7)
+ end
- def on_48(stack) set_bg_color_256(stack) end
+ def on_48(stack)
+ set_bg_color_256(stack)
+ end
- def on_49(_) set_bg_color(9) end
+ def on_49(_)
+ set_bg_color(9)
+ end
- def on_90(_) set_fg_color(0, 'l') end
+ def on_90(_)
+ set_fg_color(0, "l")
+ end
- def on_91(_) set_fg_color(1, 'l') end
+ def on_91(_)
+ set_fg_color(1, "l")
+ end
- def on_92(_) set_fg_color(2, 'l') end
+ def on_92(_)
+ set_fg_color(2, "l")
+ end
- def on_93(_) set_fg_color(3, 'l') end
+ def on_93(_)
+ set_fg_color(3, "l")
+ end
- def on_94(_) set_fg_color(4, 'l') end
+ def on_94(_)
+ set_fg_color(4, "l")
+ end
- def on_95(_) set_fg_color(5, 'l') end
+ def on_95(_)
+ set_fg_color(5, "l")
+ end
- def on_96(_) set_fg_color(6, 'l') end
+ def on_96(_)
+ set_fg_color(6, "l")
+ end
- def on_97(_) set_fg_color(7, 'l') end
+ def on_97(_)
+ set_fg_color(7, "l")
+ end
- def on_99(_) set_fg_color(9, 'l') end
+ def on_99(_)
+ set_fg_color(9, "l")
+ end
- def on_100(_) set_bg_color(0, 'l') end
+ def on_100(_)
+ set_bg_color(0, "l")
+ end
- def on_101(_) set_bg_color(1, 'l') end
+ def on_101(_)
+ set_bg_color(1, "l")
+ end
- def on_102(_) set_bg_color(2, 'l') end
+ def on_102(_)
+ set_bg_color(2, "l")
+ end
- def on_103(_) set_bg_color(3, 'l') end
+ def on_103(_)
+ set_bg_color(3, "l")
+ end
- def on_104(_) set_bg_color(4, 'l') end
+ def on_104(_)
+ set_bg_color(4, "l")
+ end
- def on_105(_) set_bg_color(5, 'l') end
+ def on_105(_)
+ set_bg_color(5, "l")
+ end
- def on_106(_) set_bg_color(6, 'l') end
+ def on_106(_)
+ set_bg_color(6, "l")
+ end
- def on_107(_) set_bg_color(7, 'l') end
+ def on_107(_)
+ set_bg_color(7, "l")
+ end
- def on_109(_) set_bg_color(9, 'l') end
+ def on_109(_)
+ set_bg_color(9, "l")
+ end
attr_accessor :offset, :n_open_tags, :fg_color, :bg_color, :style_mask
@@ -166,9 +266,9 @@ module Gitlab
elsif s.scan(/\e(([@-_])(.*?)?)?$/)
break
elsif s.scan(/</)
- @out << '&lt;'
+ @out << "&lt;"
elsif s.scan(/\r?\n/)
- @out << '<br>'
+ @out << "<br>"
else
@out << s.scan(/./m)
end
@@ -196,18 +296,18 @@ module Gitlab
section = scanner[3]
line = scanner.matched[0...-5] # strips \r\033[0K
- @out << %{<div class="hidden" data-action="#{action}" data-timestamp="#{timestamp}" data-section="#{section}">#{line}</div>}
+ @out << %(<div class="hidden" data-action="#{action}" data-timestamp="#{timestamp}" data-section="#{section}">#{line}</div>)
end
def handle_sequence(scanner)
indicator = scanner[1]
- commands = scanner[2].split ';'
+ commands = scanner[2].split ";"
terminator = scanner[3]
# We are only interested in color and text style changes - triggered by
# sequences starting with '\e[' and ending with 'm'. Any other control
# sequence gets stripped (including stuff like "delete last line")
- return unless indicator == '[' && terminator == 'm'
+ return unless indicator == "[" && terminator == "m"
close_open_tags
@@ -224,8 +324,8 @@ module Gitlab
def evaluate_command_stack(stack)
return unless command = stack.shift
- if self.respond_to?("on_#{command}", true)
- self.__send__("on_#{command}", stack) # rubocop:disable GitlabSecurity/PublicSend
+ if respond_to?("on_#{command}", true)
+ __send__("on_#{command}", stack) # rubocop:disable GitlabSecurity/PublicSend
end
evaluate_command_stack(stack)
@@ -253,13 +353,13 @@ module Gitlab
return if css_classes.empty?
- @out << %{<span class="#{css_classes.join(' ')}">}
+ @out << %(<span class="#{css_classes.join(" ")}">)
@n_open_tags += 1
end
def close_open_tags
while @n_open_tags > 0
- @out << %{</span>}
+ @out << %(</span>)
@n_open_tags -= 1
end
end
@@ -267,15 +367,14 @@ module Gitlab
def reset_state
@offset = 0
@n_open_tags = 0
- @out = +''
+ @out = +""
reset
end
def state
- state = STATE_PARAMS.inject({}) do |h, param|
+ state = STATE_PARAMS.each_with_object({}) { |param, h|
h[param] = send(param) # rubocop:disable GitlabSecurity/PublicSend
- h
- end
+ }
Base64.urlsafe_encode64(state.to_json)
end
@@ -343,7 +442,7 @@ module Gitlab
end
def get_color_class(segments)
- [segments].flatten.compact.join('-')
+ [segments].flatten.compact.join("-")
end
end
end
diff --git a/lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb b/lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb
index cf37d700991..c2448107a3b 100644
--- a/lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb
+++ b/lib/gitlab/ci/build/artifacts/adapters/raw_stream.rb
@@ -19,7 +19,7 @@ module Gitlab
def each_blob
stream.seek(0)
- yield(stream.read, 'raw') unless stream.eof?
+ yield(stream.read, "raw") unless stream.eof?
end
end
end
diff --git a/lib/gitlab/ci/build/artifacts/metadata.rb b/lib/gitlab/ci/build/artifacts/metadata.rb
index 08dac756cc1..03243d741fb 100644
--- a/lib/gitlab/ci/build/artifacts/metadata.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'zlib'
-require 'json'
+require "zlib"
+require "json"
module Gitlab
module Ci
@@ -29,12 +29,12 @@ module Gitlab
gzip do |gz|
read_string(gz) # version
errors = read_string(gz)
- raise ParserError, 'Errors field not found!' unless errors
+ raise ParserError, "Errors field not found!" unless errors
begin
JSON.parse(errors)
rescue JSON::ParserError
- raise ParserError, 'Invalid errors field!'
+ raise ParserError, "Invalid errors field!"
end
end
end
@@ -56,13 +56,13 @@ module Gitlab
def match_entries(gz)
entries = {}
- child_pattern = '[^/]*/?$' unless @opts[:recursive]
+ child_pattern = "[^/]*/?$" unless @opts[:recursive]
match_pattern = /^#{Regexp.escape(@path)}#{child_pattern}/
until gz.eof?
begin
- path = read_string(gz)&.force_encoding('UTF-8')
- meta = read_string(gz)&.force_encoding('UTF-8')
+ path = read_string(gz)&.force_encoding("UTF-8")
+ meta = read_string(gz)&.force_encoding("UTF-8")
# We might hit an EOF while reading either value, so we should
# abort if we don't get any data.
@@ -85,11 +85,11 @@ module Gitlab
version_string = read_string(gz)
unless version_string
- raise ParserError, 'Artifacts metadata file empty!'
+ raise ParserError, "Artifacts metadata file empty!"
end
- unless version_string =~ VERSION_PATTERN
- raise ParserError, 'Invalid version!'
+ unless VERSION_PATTERN.match?(version_string)
+ raise ParserError, "Invalid version!"
end
version_string.chomp
@@ -98,7 +98,7 @@ module Gitlab
def read_uint32(gz)
binary = gz.read(4)
- binary.unpack('L>')[0] if binary
+ binary&.unpack1("L>")
end
def read_string(gz)
diff --git a/lib/gitlab/ci/build/artifacts/metadata/entry.rb b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
index d0a80518ae8..01b2200761d 100644
--- a/lib/gitlab/ci/build/artifacts/metadata/entry.rb
+++ b/lib/gitlab/ci/build/artifacts/metadata/entry.rb
@@ -50,7 +50,7 @@ module Gitlab
end
def basename
- (directory? && !blank_node?) ? name + '/' : name
+ directory? && !blank_node? ? name + "/" : name
end
def name
@@ -72,7 +72,7 @@ module Gitlab
return dirs unless has_parent? && opts[:parent]
dotted_parent = parent
- dotted_parent.name = '..'
+ dotted_parent.name = ".."
dirs.prepend(dotted_parent)
end
diff --git a/lib/gitlab/ci/build/artifacts/path.rb b/lib/gitlab/ci/build/artifacts/path.rb
index 65cd935afaa..f704e91d1e9 100644
--- a/lib/gitlab/ci/build/artifacts/path.rb
+++ b/lib/gitlab/ci/build/artifacts/path.rb
@@ -6,7 +6,7 @@ module Gitlab
module Artifacts
class Path
def initialize(path)
- @path = path.dup.force_encoding('UTF-8')
+ @path = path.dup.force_encoding("UTF-8")
end
def valid?
@@ -14,25 +14,25 @@ module Gitlab
end
def directory?
- @path.end_with?('/')
+ @path.end_with?("/")
end
def name
- @path.split('/').last.to_s
+ @path.split("/").last.to_s
end
def nodes
- @path.count('/')
+ @path.count("/")
end
def to_s
@path.tap do |path|
unless nonzero?
- raise ArgumentError, 'Path contains zero byte character!'
+ raise ArgumentError, "Path contains zero byte character!"
end
unless utf8?
- raise ArgumentError, 'Path contains non-UTF-8 byte sequence!'
+ raise ArgumentError, "Path contains non-UTF-8 byte sequence!"
end
end
end
diff --git a/lib/gitlab/ci/build/credentials/registry.rb b/lib/gitlab/ci/build/credentials/registry.rb
index 1c8588d9913..be3b7ea53b9 100644
--- a/lib/gitlab/ci/build/credentials/registry.rb
+++ b/lib/gitlab/ci/build/credentials/registry.rb
@@ -8,7 +8,7 @@ module Gitlab
attr_reader :username, :password
def initialize(build)
- @username = 'gitlab-ci-token'
+ @username = "gitlab-ci-token"
@password = build.token
end
diff --git a/lib/gitlab/ci/build/image.rb b/lib/gitlab/ci/build/image.rb
index 4dd932f61d4..7f6118be3ec 100644
--- a/lib/gitlab/ci/build/image.rb
+++ b/lib/gitlab/ci/build/image.rb
@@ -15,9 +15,9 @@ module Gitlab
end
def from_services(job)
- services = job.options[:services].to_a.map do |service|
+ services = job.options[:services].to_a.map { |service|
Gitlab::Ci::Build::Image.new(service)
- end
+ }
services.select(&:valid?).compact
end
diff --git a/lib/gitlab/ci/build/policy.rb b/lib/gitlab/ci/build/policy.rb
index 43c46ad74af..27f27729dd1 100644
--- a/lib/gitlab/ci/build/policy.rb
+++ b/lib/gitlab/ci/build/policy.rb
@@ -5,9 +5,9 @@ module Gitlab
module Build
module Policy
def self.fabricate(specs)
- specifications = specs.to_h.map do |spec, value|
- self.const_get(spec.to_s.camelize).new(value)
- end
+ specifications = specs.to_h.map { |spec, value|
+ const_get(spec.to_s.camelize).new(value)
+ }
specifications.compact
end
diff --git a/lib/gitlab/ci/build/policy/refs.rb b/lib/gitlab/ci/build/policy/refs.rb
index 0e9bb5c94bb..708daaff5a6 100644
--- a/lib/gitlab/ci/build/policy/refs.rb
+++ b/lib/gitlab/ci/build/policy/refs.rb
@@ -11,7 +11,7 @@ module Gitlab
def satisfied_by?(pipeline, seed = nil)
@patterns.any? do |pattern|
- pattern, path = pattern.split('@', 2)
+ pattern, path = pattern.split("@", 2)
matches_path?(path, pipeline) &&
matches_pattern?(pattern, pipeline)
@@ -27,8 +27,8 @@ module Gitlab
end
def matches_pattern?(pattern, pipeline)
- return true if pipeline.tag? && pattern == 'tags'
- return true if pipeline.branch? && pattern == 'branches'
+ return true if pipeline.tag? && pattern == "tags"
+ return true if pipeline.branch? && pattern == "branches"
return true if pipeline.source == pattern
return true if pipeline.source&.pluralize == pattern
diff --git a/lib/gitlab/ci/build/policy/variables.rb b/lib/gitlab/ci/build/policy/variables.rb
index 0698136166a..5f69e96f56d 100644
--- a/lib/gitlab/ci/build/policy/variables.rb
+++ b/lib/gitlab/ci/build/policy/variables.rb
@@ -12,10 +12,10 @@ module Gitlab
def satisfied_by?(pipeline, seed)
variables = seed.to_resource.scoped_variables_hash
- statements = @expressions.map do |statement|
+ statements = @expressions.map { |statement|
::Gitlab::Ci::Pipeline::Expression::Statement
.new(statement, variables)
- end
+ }
statements.any?(&:truthful?)
end
diff --git a/lib/gitlab/ci/build/step.rb b/lib/gitlab/ci/build/step.rb
index 7fcabc035ac..881fa5cb00a 100644
--- a/lib/gitlab/ci/build/step.rb
+++ b/lib/gitlab/ci/build/step.rb
@@ -4,16 +4,16 @@ module Gitlab
module Ci
module Build
class Step
- WHEN_ON_FAILURE = 'on_failure'.freeze
- WHEN_ON_SUCCESS = 'on_success'.freeze
- WHEN_ALWAYS = 'always'.freeze
+ WHEN_ON_FAILURE = "on_failure"
+ WHEN_ON_SUCCESS = "on_success"
+ WHEN_ALWAYS = "always"
attr_reader :name
attr_accessor :script, :timeout, :when, :allow_failure
class << self
def from_commands(job)
- self.new(:script).tap do |step|
+ new(:script).tap do |step|
step.script = job.options[:before_script].to_a + job.options[:script].to_a
step.timeout = job.metadata_timeout
step.when = WHEN_ON_SUCCESS
@@ -24,7 +24,7 @@ module Gitlab
after_script = job.options[:after_script]
return unless after_script
- self.new(:after_script).tap do |step|
+ new(:after_script).tap do |step|
step.script = after_script
step.timeout = job.metadata_timeout
step.when = WHEN_ALWAYS
diff --git a/lib/gitlab/ci/charts.rb b/lib/gitlab/ci/charts.rb
index 7cabaadb122..ec500d4c2bb 100644
--- a/lib/gitlab/ci/charts.rb
+++ b/lib/gitlab/ci/charts.rb
@@ -81,7 +81,7 @@ module Gitlab
def initialize(*)
@to = Date.today.end_of_month.end_of_day
@from = @to.years_ago(1).beginning_of_month.beginning_of_day
- @format = '%d %B %Y'
+ @format = "%d %B %Y"
super
end
@@ -94,7 +94,7 @@ module Gitlab
def initialize(*)
@to = Date.today.end_of_day
@from = 1.month.ago.beginning_of_day
- @format = '%d %B'
+ @format = "%d %B"
super
end
@@ -107,7 +107,7 @@ module Gitlab
def initialize(*)
@to = Date.today.end_of_day
@from = 1.week.ago.beginning_of_day
- @format = '%d %B'
+ @format = "%d %B"
super
end
diff --git a/lib/gitlab/ci/config/entry/artifacts.rb b/lib/gitlab/ci/config/entry/artifacts.rb
index 41613369ca2..99965c8ecf2 100644
--- a/lib/gitlab/ci/config/entry/artifacts.rb
+++ b/lib/gitlab/ci/config/entry/artifacts.rb
@@ -16,7 +16,7 @@ module Gitlab
attributes ALLOWED_KEYS
- entry :reports, Entry::Reports, description: 'Report-type artifacts.'
+ entry :reports, Entry::Reports, description: "Report-type artifacts."
validations do
validates :config, type: Hash
@@ -28,9 +28,9 @@ module Gitlab
validates :paths, array_of_strings: true
validates :reports, type: Hash
validates :when,
- inclusion: { in: %w[on_success on_failure always],
- message: 'should be on_success, on_failure ' \
- 'or always' }
+ inclusion: {in: %w[on_success on_failure always],
+ message: "should be on_success, on_failure " \
+ "or always",}
validates :expire_in, duration: true
end
end
diff --git a/lib/gitlab/ci/config/entry/cache.rb b/lib/gitlab/ci/config/entry/cache.rb
index 7b94af24c09..266f41db139 100644
--- a/lib/gitlab/ci/config/entry/cache.rb
+++ b/lib/gitlab/ci/config/entry/cache.rb
@@ -12,21 +12,21 @@ module Gitlab
include ::Gitlab::Config::Entry::Attributable
ALLOWED_KEYS = %i[key untracked paths policy].freeze
- DEFAULT_POLICY = 'pull-push'.freeze
+ DEFAULT_POLICY = "pull-push"
validations do
validates :config, allowed_keys: ALLOWED_KEYS
- validates :policy, inclusion: { in: %w[pull-push push pull], message: 'should be pull-push, push, or pull' }, allow_blank: true
+ validates :policy, inclusion: {in: %w[pull-push push pull], message: "should be pull-push, push, or pull"}, allow_blank: true
end
entry :key, Entry::Key,
- description: 'Cache key used to define a cache affinity.'
+ description: "Cache key used to define a cache affinity."
entry :untracked, ::Gitlab::Config::Entry::Boolean,
- description: 'Cache all untracked files.'
+ description: "Cache all untracked files."
entry :paths, Entry::Paths,
- description: 'Specify which paths should be cached across builds.'
+ description: "Specify which paths should be cached across builds."
helpers :key
diff --git a/lib/gitlab/ci/config/entry/environment.rb b/lib/gitlab/ci/config/entry/environment.rb
index 69a3a1aedef..3b05f92b9c9 100644
--- a/lib/gitlab/ci/config/entry/environment.rb
+++ b/lib/gitlab/ci/config/entry/environment.rb
@@ -15,7 +15,7 @@ module Gitlab
validations do
validate do
unless hash? || string?
- errors.add(:config, 'should be a hash or a string')
+ errors.add(:config, "should be a hash or a string")
end
end
@@ -23,25 +23,25 @@ module Gitlab
validates :name,
type: {
with: String,
- message: Gitlab::Regex.environment_name_regex_message
+ message: Gitlab::Regex.environment_name_regex_message,
}
validates :name,
format: {
with: Gitlab::Regex.environment_name_regex,
- message: Gitlab::Regex.environment_name_regex_message
+ message: Gitlab::Regex.environment_name_regex_message,
}
with_options if: :hash? do
validates :config, allowed_keys: ALLOWED_KEYS
validates :url,
- length: { maximum: 255 },
- allow_nil: true
+ length: {maximum: 255},
+ allow_nil: true
validates :action,
- inclusion: { in: %w[start stop], message: 'should be start or stop' },
- allow_nil: true
+ inclusion: {in: %w[start stop], message: "should be start or stop"},
+ allow_nil: true
validates :on_stop, type: String, allow_nil: true
end
@@ -64,7 +64,7 @@ module Gitlab
end
def action
- value[:action] || 'start'
+ value[:action] || "start"
end
def on_stop
@@ -73,7 +73,7 @@ module Gitlab
def value
case @config
- when String then { name: @config, action: 'start' }
+ when String then {name: @config, action: "start"}
when Hash then @config
else {}
end
diff --git a/lib/gitlab/ci/config/entry/global.rb b/lib/gitlab/ci/config/entry/global.rb
index 2b5a59c078e..05e000ba0fa 100644
--- a/lib/gitlab/ci/config/entry/global.rb
+++ b/lib/gitlab/ci/config/entry/global.rb
@@ -12,34 +12,34 @@ module Gitlab
include ::Gitlab::Config::Entry::Configurable
entry :before_script, Entry::Script,
- description: 'Script that will be executed before each job.'
+ description: "Script that will be executed before each job."
entry :image, Entry::Image,
- description: 'Docker image that will be used to execute jobs.'
+ description: "Docker image that will be used to execute jobs."
entry :include, Entry::Includes,
- description: 'List of external YAML files to include.'
+ description: "List of external YAML files to include."
entry :services, Entry::Services,
- description: 'Docker images that will be linked to the container.'
+ description: "Docker images that will be linked to the container."
entry :after_script, Entry::Script,
- description: 'Script that will be executed after each job.'
+ description: "Script that will be executed after each job."
entry :variables, Entry::Variables,
- description: 'Environment variables that will be used.'
+ description: "Environment variables that will be used."
entry :stages, Entry::Stages,
- description: 'Configuration of stages for this pipeline.'
+ description: "Configuration of stages for this pipeline."
entry :types, Entry::Stages,
- description: 'Deprecated: stages for this pipeline.'
+ description: "Deprecated: stages for this pipeline."
entry :cache, Entry::Cache,
- description: 'Configure caching between build jobs.'
+ description: "Configure caching between build jobs."
helpers :before_script, :image, :services, :after_script,
- :variables, :stages, :types, :cache, :jobs
+ :variables, :stages, :types, :cache, :jobs
def compose!(_deps = nil)
super(self) do
@@ -55,7 +55,7 @@ module Gitlab
factory = ::Gitlab::Config::Entry::Factory.new(Entry::Jobs)
.value(@config.except(*self.class.nodes.keys))
.with(key: :jobs, parent: self,
- description: 'Jobs definition for this pipeline')
+ description: "Jobs definition for this pipeline")
@entries[:jobs] = factory.create!
end
diff --git a/lib/gitlab/ci/config/entry/image.rb b/lib/gitlab/ci/config/entry/image.rb
index a13a0625e90..9ac5e682c3d 100644
--- a/lib/gitlab/ci/config/entry/image.rb
+++ b/lib/gitlab/ci/config/entry/image.rb
@@ -37,7 +37,7 @@ module Gitlab
end
def value
- return { name: @config } if string?
+ return {name: @config} if string?
return @config if hash?
{}
diff --git a/lib/gitlab/ci/config/entry/includes.rb b/lib/gitlab/ci/config/entry/includes.rb
index 82b2b1ccf4b..d24876ac0ad 100644
--- a/lib/gitlab/ci/config/entry/includes.rb
+++ b/lib/gitlab/ci/config/entry/includes.rb
@@ -20,8 +20,8 @@ module Gitlab
@config.each_with_index do |config, i|
@entries[i] = ::Gitlab::Config::Entry::Factory.new(Entry::Include)
- .value(config || {})
- .create!
+ .value(config || {})
+ .create!
end
end
end
diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb
index 290c9591b98..cef269d8681 100644
--- a/lib/gitlab/ci/config/entry/job.rb
+++ b/lib/gitlab/ci/config/entry/job.rb
@@ -26,74 +26,74 @@ module Gitlab
with_options allow_nil: true do
validates :tags, array_of_strings: true
validates :allow_failure, boolean: true
- validates :parallel, numericality: { only_integer: true,
- greater_than_or_equal_to: 2,
- less_than_or_equal_to: 50 }
+ validates :parallel, numericality: {only_integer: true,
+ greater_than_or_equal_to: 2,
+ less_than_or_equal_to: 50,}
validates :when,
- inclusion: { in: %w[on_success on_failure always manual delayed],
- message: 'should be on_success, on_failure, ' \
- 'always, manual or delayed' }
+ inclusion: {in: %w[on_success on_failure always manual delayed],
+ message: "should be on_success, on_failure, " \
+ "always, manual or delayed",}
validates :dependencies, array_of_strings: true
validates :extends, type: String
end
- validates :start_in, duration: { limit: '1 day' }, if: :delayed?
+ validates :start_in, duration: {limit: "1 day"}, if: :delayed?
validates :start_in, absence: true, unless: :delayed?
end
entry :before_script, Entry::Script,
- description: 'Global before script overridden in this job.'
+ description: "Global before script overridden in this job."
entry :script, Entry::Commands,
- description: 'Commands that will be executed in this job.'
+ description: "Commands that will be executed in this job."
entry :stage, Entry::Stage,
- description: 'Pipeline stage this job will be executed into.'
+ description: "Pipeline stage this job will be executed into."
entry :type, Entry::Stage,
- description: 'Deprecated: stage this job will be executed into.'
+ description: "Deprecated: stage this job will be executed into."
entry :after_script, Entry::Script,
- description: 'Commands that will be executed when finishing job.'
+ description: "Commands that will be executed when finishing job."
entry :cache, Entry::Cache,
- description: 'Cache definition for this job.'
+ description: "Cache definition for this job."
entry :image, Entry::Image,
- description: 'Image that will be used to execute this job.'
+ description: "Image that will be used to execute this job."
entry :services, Entry::Services,
- description: 'Services that will be used to execute this job.'
+ description: "Services that will be used to execute this job."
entry :only, Entry::Policy,
- description: 'Refs policy this job will be executed for.',
+ description: "Refs policy this job will be executed for.",
default: Entry::Policy::DEFAULT_ONLY
entry :except, Entry::Policy,
- description: 'Refs policy this job will be executed for.'
+ description: "Refs policy this job will be executed for."
entry :variables, Entry::Variables,
- description: 'Environment variables available for this job.'
+ description: "Environment variables available for this job."
entry :artifacts, Entry::Artifacts,
- description: 'Artifacts configuration for this job.'
+ description: "Artifacts configuration for this job."
entry :environment, Entry::Environment,
- description: 'Environment configuration for this job.'
+ description: "Environment configuration for this job."
entry :coverage, Entry::Coverage,
- description: 'Coverage configuration for this job.'
+ description: "Coverage configuration for this job."
entry :retry, Entry::Retry,
- description: 'Retry configuration for this job.'
+ description: "Retry configuration for this job."
helpers :before_script, :script, :stage, :type, :after_script,
- :cache, :image, :services, :only, :except, :variables,
- :artifacts, :environment, :coverage, :retry,
- :parallel
+ :cache, :image, :services, :only, :except, :variables,
+ :artifacts, :environment, :coverage, :retry,
+ :parallel
attributes :script, :tags, :allow_failure, :when, :dependencies,
- :retry, :parallel, :extends, :start_in
+ :retry, :parallel, :extends, :start_in
def compose!(deps = nil)
super do
@@ -116,11 +116,11 @@ module Gitlab
end
def manual_action?
- self.when == 'manual'
+ self.when == "manual"
end
def delayed?
- self.when == 'delayed'
+ self.when == "delayed"
end
def ignored?
@@ -143,24 +143,24 @@ module Gitlab
end
def to_hash
- { name: name,
- before_script: before_script_value,
- script: script_value,
- image: image_value,
- services: services_value,
- stage: stage_value,
- cache: cache_value,
- only: only_value,
- except: except_value,
- variables: variables_defined? ? variables_value : nil,
- environment: environment_defined? ? environment_value : nil,
- environment_name: environment_defined? ? environment_value[:name] : nil,
- coverage: coverage_defined? ? coverage_value : nil,
- retry: retry_defined? ? retry_value : nil,
- parallel: parallel_defined? ? parallel_value.to_i : nil,
- artifacts: artifacts_value,
- after_script: after_script_value,
- ignore: ignored? }
+ {name: name,
+ before_script: before_script_value,
+ script: script_value,
+ image: image_value,
+ services: services_value,
+ stage: stage_value,
+ cache: cache_value,
+ only: only_value,
+ except: except_value,
+ variables: variables_defined? ? variables_value : nil,
+ environment: environment_defined? ? environment_value : nil,
+ environment_name: environment_defined? ? environment_value[:name] : nil,
+ coverage: coverage_defined? ? coverage_value : nil,
+ retry: retry_defined? ? retry_value : nil,
+ parallel: parallel_defined? ? parallel_value.to_i : nil,
+ artifacts: artifacts_value,
+ after_script: after_script_value,
+ ignore: ignored?,}
end
end
end
diff --git a/lib/gitlab/ci/config/entry/jobs.rb b/lib/gitlab/ci/config/entry/jobs.rb
index 9845c4af655..87419bcb5d7 100644
--- a/lib/gitlab/ci/config/entry/jobs.rb
+++ b/lib/gitlab/ci/config/entry/jobs.rb
@@ -15,7 +15,7 @@ module Gitlab
validate do
unless has_visible_job?
- errors.add(:config, 'should contain at least one visible job')
+ errors.add(:config, "should contain at least one visible job")
end
end
@@ -25,7 +25,7 @@ module Gitlab
end
def hidden?(name)
- name.to_s.start_with?('.')
+ name.to_s.start_with?(".")
end
def node_type(name)
diff --git a/lib/gitlab/ci/config/entry/key.rb b/lib/gitlab/ci/config/entry/key.rb
index 0c10967e629..4f8bd35f0b9 100644
--- a/lib/gitlab/ci/config/entry/key.rb
+++ b/lib/gitlab/ci/config/entry/key.rb
@@ -15,7 +15,7 @@ module Gitlab
end
def self.default
- 'default'
+ "default"
end
end
end
diff --git a/lib/gitlab/ci/config/entry/policy.rb b/lib/gitlab/ci/config/entry/policy.rb
index adc3660d950..7a16ae52ef4 100644
--- a/lib/gitlab/ci/config/entry/policy.rb
+++ b/lib/gitlab/ci/config/entry/policy.rb
@@ -8,10 +8,10 @@ module Gitlab
# Entry that represents an only/except trigger policy for the job.
#
class Policy < ::Gitlab::Config::Entry::Simplifiable
- strategy :RefsPolicy, if: -> (config) { config.is_a?(Array) }
- strategy :ComplexPolicy, if: -> (config) { config.is_a?(Hash) }
+ strategy :RefsPolicy, if: ->(config) { config.is_a?(Array) }
+ strategy :ComplexPolicy, if: ->(config) { config.is_a?(Hash) }
- DEFAULT_ONLY = { refs: %w[branches tags] }.freeze
+ DEFAULT_ONLY = {refs: %w[branches tags]}.freeze
class RefsPolicy < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
@@ -21,7 +21,7 @@ module Gitlab
end
def value
- { refs: @config }
+ {refs: @config}
end
end
@@ -47,9 +47,9 @@ module Gitlab
def variables_expressions_syntax
return unless variables.is_a?(Array)
- statements = variables.map do |statement|
+ statements = variables.map { |statement|
::Gitlab::Ci::Pipeline::Expression::Statement.new(statement)
- end
+ }
statements.each do |statement|
unless statement.valid?
diff --git a/lib/gitlab/ci/config/entry/retry.rb b/lib/gitlab/ci/config/entry/retry.rb
index e9cbcb31e21..737ad96db15 100644
--- a/lib/gitlab/ci/config/entry/retry.rb
+++ b/lib/gitlab/ci/config/entry/retry.rb
@@ -8,26 +8,26 @@ module Gitlab
# Entry that represents a retry config for a job.
#
class Retry < ::Gitlab::Config::Entry::Simplifiable
- strategy :SimpleRetry, if: -> (config) { config.is_a?(Integer) }
- strategy :FullRetry, if: -> (config) { config.is_a?(Hash) }
+ strategy :SimpleRetry, if: ->(config) { config.is_a?(Integer) }
+ strategy :FullRetry, if: ->(config) { config.is_a?(Hash) }
class SimpleRetry < ::Gitlab::Config::Entry::Node
include ::Gitlab::Config::Entry::Validatable
validations do
- validates :config, numericality: { only_integer: true,
- greater_than_or_equal_to: 0,
- less_than_or_equal_to: 2 }
+ validates :config, numericality: {only_integer: true,
+ greater_than_or_equal_to: 0,
+ less_than_or_equal_to: 2,}
end
def value
{
- max: config
+ max: config,
}
end
def location
- 'retry'
+ "retry"
end
end
@@ -42,22 +42,22 @@ module Gitlab
validates :config, allowed_keys: ALLOWED_KEYS
with_options allow_nil: true do
- validates :max, numericality: { only_integer: true,
- greater_than_or_equal_to: 0,
- less_than_or_equal_to: 2 }
+ validates :max, numericality: {only_integer: true,
+ greater_than_or_equal_to: 0,
+ less_than_or_equal_to: 2,}
validates :when, array_of_strings_or_string: true
validates :when,
- allowed_array_values: { in: FullRetry.possible_retry_when_values },
- if: -> (config) { config.when.is_a?(Array) }
+ allowed_array_values: {in: FullRetry.possible_retry_when_values},
+ if: ->(config) { config.when.is_a?(Array) }
validates :when,
- inclusion: { in: FullRetry.possible_retry_when_values },
- if: -> (config) { config.when.is_a?(String) }
+ inclusion: {in: FullRetry.possible_retry_when_values},
+ if: ->(config) { config.when.is_a?(String) }
end
end
def self.possible_retry_when_values
- @possible_retry_when_values ||= ::Ci::Build.failure_reasons.keys.map(&:to_s) + ['always']
+ @possible_retry_when_values ||= ::Ci::Build.failure_reasons.keys.map(&:to_s) + ["always"]
end
def value
@@ -69,7 +69,7 @@ module Gitlab
end
def location
- 'retry'
+ "retry"
end
end
@@ -79,7 +79,7 @@ module Gitlab
end
def location
- 'retry config'
+ "retry config"
end
end
end
diff --git a/lib/gitlab/ci/config/entry/stage.rb b/lib/gitlab/ci/config/entry/stage.rb
index d6d576a3139..f18b1740866 100644
--- a/lib/gitlab/ci/config/entry/stage.rb
+++ b/lib/gitlab/ci/config/entry/stage.rb
@@ -15,7 +15,7 @@ module Gitlab
end
def self.default
- 'test'
+ "test"
end
end
end
diff --git a/lib/gitlab/ci/config/extendable/entry.rb b/lib/gitlab/ci/config/extendable/entry.rb
index 7793db09d33..3d660c73114 100644
--- a/lib/gitlab/ci/config/extendable/entry.rb
+++ b/lib/gitlab/ci/config/extendable/entry.rb
@@ -19,7 +19,7 @@ module Gitlab
@parent = parent
unless @context.key?(@key)
- raise StandardError, 'Invalid entry key!'
+ raise StandardError, "Invalid entry key!"
end
end
@@ -50,22 +50,22 @@ module Gitlab
if unknown_extension?
raise Entry::InvalidExtensionError,
- "#{key}: unknown key in `extends`"
+ "#{key}: unknown key in `extends`"
end
if invalid_base?
raise Entry::InvalidExtensionError,
- "#{key}: invalid base hash in `extends`"
+ "#{key}: invalid base hash in `extends`"
end
if nesting_too_deep?
raise Entry::NestingTooDeepError,
- "#{key}: nesting too deep in `extends`"
+ "#{key}: nesting too deep in `extends`"
end
if circular_dependency?
raise Entry::CircularDependencyError,
- "#{key}: circular dependency detected in `extends`"
+ "#{key}: circular dependency detected in `extends`"
end
@context[key] = base_hash!.deep_merge(value)
diff --git a/lib/gitlab/ci/config/external/file/base.rb b/lib/gitlab/ci/config/external/file/base.rb
index a747886093c..797d5b805ca 100644
--- a/lib/gitlab/ci/config/external/file/base.rb
+++ b/lib/gitlab/ci/config/external/file/base.rb
@@ -39,7 +39,7 @@ module Gitlab
end
def content
- raise NotImplementedError, 'subclass must implement fetching raw content'
+ raise NotImplementedError, "subclass must implement fetching raw content"
end
def to_hash
diff --git a/lib/gitlab/ci/config/external/file/project.rb b/lib/gitlab/ci/config/external/file/project.rb
index e75540dbe5a..089e6cc3628 100644
--- a/lib/gitlab/ci/config/external/file/project.rb
+++ b/lib/gitlab/ci/config/external/file/project.rb
@@ -13,7 +13,7 @@ module Gitlab
def initialize(params, context = {})
@location = params[:file]
@project_name = params[:project]
- @ref_name = params[:ref] || 'HEAD'
+ @ref_name = params[:ref] || "HEAD"
super
end
diff --git a/lib/gitlab/ci/config/external/file/template.rb b/lib/gitlab/ci/config/external/file/template.rb
index 54f4cf74c4d..af3f7fd88bd 100644
--- a/lib/gitlab/ci/config/external/file/template.rb
+++ b/lib/gitlab/ci/config/external/file/template.rb
@@ -8,7 +8,7 @@ module Gitlab
class Template < Base
attr_reader :location, :project
- SUFFIX = '.gitlab-ci.yml'.freeze
+ SUFFIX = ".gitlab-ci.yml"
def initialize(params, context)
@location = params[:template]
diff --git a/lib/gitlab/ci/config/external/mapper.rb b/lib/gitlab/ci/config/external/mapper.rb
index 108bfd5eb43..2008008def5 100644
--- a/lib/gitlab/ci/config/external/mapper.rb
+++ b/lib/gitlab/ci/config/external/mapper.rb
@@ -11,7 +11,7 @@ module Gitlab
External::File::Remote,
External::File::Template,
External::File::Local,
- External::File::Project
+ External::File::Project,
].freeze
AmbigiousSpecificationError = Class.new(StandardError)
@@ -45,16 +45,16 @@ module Gitlab
def normalize_location_string(location)
if ::Gitlab::UrlSanitizer.valid?(location)
- { remote: location }
+ {remote: location}
else
- { local: location }
+ {local: location}
end
end
def select_first_matching(location)
- matching = FILE_CLASSES.map do |file_class|
+ matching = FILE_CLASSES.map { |file_class|
file_class.new(location, context)
- end.select(&:matching?)
+ }.select(&:matching?)
raise AmbigiousSpecificationError, "Include `#{location.to_json}` needs to match exactly one accessor!" unless matching.one?
diff --git a/lib/gitlab/ci/cron_parser.rb b/lib/gitlab/ci/cron_parser.rb
index 94f4a4e36c9..e46f0ae4d4a 100644
--- a/lib/gitlab/ci/cron_parser.rb
+++ b/lib/gitlab/ci/cron_parser.rb
@@ -3,10 +3,10 @@
module Gitlab
module Ci
class CronParser
- VALID_SYNTAX_SAMPLE_TIME_ZONE = 'UTC'.freeze
- VALID_SYNTAX_SAMPLE_CRON = '* * * * *'.freeze
+ VALID_SYNTAX_SAMPLE_TIME_ZONE = "UTC"
+ VALID_SYNTAX_SAMPLE_CRON = "* * * * *"
- def initialize(cron, cron_timezone = 'UTC')
+ def initialize(cron, cron_timezone = "UTC")
@cron = cron
@cron_timezone = timezone_name(cron_timezone)
end
diff --git a/lib/gitlab/ci/mask_secret.rb b/lib/gitlab/ci/mask_secret.rb
index 58d55b1bd6f..5ddbf9a2460 100644
--- a/lib/gitlab/ci/mask_secret.rb
+++ b/lib/gitlab/ci/mask_secret.rb
@@ -8,7 +8,7 @@ module Gitlab
# We assume 'value' must be mutable, given
# that frozen string is enabled.
- value.gsub!(token, 'x' * token.length)
+ value.gsub!(token, "x" * token.length)
value
end
end
diff --git a/lib/gitlab/ci/model.rb b/lib/gitlab/ci/model.rb
index fbdb84c0522..89a50bf4a97 100644
--- a/lib/gitlab/ci/model.rb
+++ b/lib/gitlab/ci/model.rb
@@ -8,7 +8,7 @@ module Gitlab
end
def model_name
- @model_name ||= ActiveModel::Name.new(self, nil, self.name.split("::").last)
+ @model_name ||= ActiveModel::Name.new(self, nil, name.split("::").last)
end
end
end
diff --git a/lib/gitlab/ci/parsers.rb b/lib/gitlab/ci/parsers.rb
index eb63e6c8363..c5666e83201 100644
--- a/lib/gitlab/ci/parsers.rb
+++ b/lib/gitlab/ci/parsers.rb
@@ -7,7 +7,7 @@ module Gitlab
def self.parsers
{
- junit: ::Gitlab::Ci::Parsers::Test::Junit
+ junit: ::Gitlab::Ci::Parsers::Test::Junit,
}
end
diff --git a/lib/gitlab/ci/parsers/test/junit.rb b/lib/gitlab/ci/parsers/test/junit.rb
index dca60eabc1c..e5a59b85dad 100644
--- a/lib/gitlab/ci/parsers/test/junit.rb
+++ b/lib/gitlab/ci/parsers/test/junit.rb
@@ -29,13 +29,13 @@ module Gitlab
next unless node.is_a?(Hash)
# we allow only one top-level 'testsuites'
- all_cases(node['testsuites'], root, &blk) unless parent
+ all_cases(node["testsuites"], root, &blk) unless parent
# we require at least one level of testsuites or testsuite
- each_case(node['testcase'], &blk) if parent
+ each_case(node["testcase"], &blk) if parent
# we allow multiple nested 'testsuite' (eg. PHPUnit)
- all_cases(node['testsuite'], root, &blk)
+ all_cases(node["testsuite"], root, &blk)
end
end
@@ -46,19 +46,19 @@ module Gitlab
end
def create_test_case(data)
- if data['failure']
+ if data["failure"]
status = ::Gitlab::Ci::Reports::TestCase::STATUS_FAILED
- system_output = data['failure']
+ system_output = data["failure"]
else
status = ::Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS
system_output = nil
end
::Gitlab::Ci::Reports::TestCase.new(
- classname: data['classname'],
- name: data['name'],
- file: data['file'],
- execution_time: data['time'],
+ classname: data["classname"],
+ name: data["name"],
+ file: data["file"],
+ execution_time: data["time"],
status: status,
system_output: system_output
)
diff --git a/lib/gitlab/ci/pipeline/chain/command.rb b/lib/gitlab/ci/pipeline/chain/command.rb
index 7b77e86feae..c36986a5d72 100644
--- a/lib/gitlab/ci/pipeline/chain/command.rb
+++ b/lib/gitlab/ci/pipeline/chain/command.rb
@@ -12,7 +12,7 @@ module Gitlab
:ignore_skip_ci, :save_incompleted,
:seeds_block, :variables_attributes, :push_options,
:chat_data
- ) do
+ ) {
include Gitlab::Utils::StrongMemoize
def initialize(**params)
@@ -64,7 +64,7 @@ module Gitlab
project.repository.ambiguous_ref?(origin_ref)
end
end
- end
+ }
end
end
end
diff --git a/lib/gitlab/ci/pipeline/chain/populate.rb b/lib/gitlab/ci/pipeline/chain/populate.rb
index 0405292a25b..330a6567430 100644
--- a/lib/gitlab/ci/pipeline/chain/populate.rb
+++ b/lib/gitlab/ci/pipeline/chain/populate.rb
@@ -30,11 +30,11 @@ module Gitlab
end
if pipeline.stages.none?
- return error('No stages / jobs for this pipeline.')
+ return error("No stages / jobs for this pipeline.")
end
if pipeline.invalid?
- return error('Failed to build the pipeline!')
+ return error("Failed to build the pipeline!")
end
raise Populate::PopulateError if pipeline.persisted?
diff --git a/lib/gitlab/ci/pipeline/chain/skip.rb b/lib/gitlab/ci/pipeline/chain/skip.rb
index 79bbcc1ed1e..328336097c2 100644
--- a/lib/gitlab/ci/pipeline/chain/skip.rb
+++ b/lib/gitlab/ci/pipeline/chain/skip.rb
@@ -8,7 +8,7 @@ module Gitlab
include ::Gitlab::Utils::StrongMemoize
SKIP_PATTERN = /\[(ci[ _-]skip|skip[ _-]ci)\]/i
- SKIP_PUSH_OPTION = 'ci.skip'
+ SKIP_PUSH_OPTION = "ci.skip"
def perform!
if skipped?
diff --git a/lib/gitlab/ci/pipeline/chain/validate/abilities.rb b/lib/gitlab/ci/pipeline/chain/validate/abilities.rb
index ebd7e6e8289..61ed7959783 100644
--- a/lib/gitlab/ci/pipeline/chain/validate/abilities.rb
+++ b/lib/gitlab/ci/pipeline/chain/validate/abilities.rb
@@ -11,14 +11,14 @@ module Gitlab
def perform!
unless project.builds_enabled?
- return error('Pipelines are disabled!')
+ return error("Pipelines are disabled!")
end
unless allowed_to_trigger_pipeline?
if can?(current_user, :create_pipeline, project)
return error("Insufficient permissions for protected ref '#{command.ref}'")
else
- return error('Insufficient permissions to create a new pipeline')
+ return error("Insufficient permissions to create a new pipeline")
end
end
end
diff --git a/lib/gitlab/ci/pipeline/chain/validate/repository.rb b/lib/gitlab/ci/pipeline/chain/validate/repository.rb
index 9c6c2bc8e25..b8cfc81e531 100644
--- a/lib/gitlab/ci/pipeline/chain/validate/repository.rb
+++ b/lib/gitlab/ci/pipeline/chain/validate/repository.rb
@@ -10,15 +10,15 @@ module Gitlab
def perform!
unless @command.branch_exists? || @command.tag_exists?
- return error('Reference not found')
+ return error("Reference not found")
end
unless @command.sha
- return error('Commit not found')
+ return error("Commit not found")
end
if @command.ambiguous_ref?
- return error('Ref is ambiguous')
+ return error("Ref is ambiguous")
end
end
diff --git a/lib/gitlab/ci/pipeline/duration.rb b/lib/gitlab/ci/pipeline/duration.rb
index de24bbf688b..a952f6bdc55 100644
--- a/lib/gitlab/ci/pipeline/duration.rb
+++ b/lib/gitlab/ci/pipeline/duration.rb
@@ -82,11 +82,11 @@ module Gitlab
module Duration
extend self
- Period = Struct.new(:first, :last) do
+ Period = Struct.new(:first, :last) {
def duration
last - first
end
- end
+ }
# rubocop: disable CodeReuse/ActiveRecord
def from_pipeline(pipeline)
@@ -101,9 +101,9 @@ module Gitlab
def from_builds(builds)
now = Time.now
- periods = builds.map do |b|
+ periods = builds.map { |b|
Period.new(b.started_at, b.finished_at || now)
- end
+ }
from_periods(periods)
end
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/null.rb b/lib/gitlab/ci/pipeline/expression/lexeme/null.rb
index be7258c201a..99b70e17b9b 100644
--- a/lib/gitlab/ci/pipeline/expression/lexeme/null.rb
+++ b/lib/gitlab/ci/pipeline/expression/lexeme/null.rb
@@ -17,7 +17,7 @@ module Gitlab
end
def self.build(_value)
- self.new
+ new
end
end
end
diff --git a/lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb b/lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
index d7e6dacf068..27c4aecb3f1 100644
--- a/lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
+++ b/lib/gitlab/ci/pipeline/expression/lexeme/pattern.rb
@@ -5,7 +5,7 @@ module Gitlab
module Pipeline
module Expression
module Lexeme
- require_dependency 're2'
+ require_dependency "re2"
class Pattern < Lexeme::Value
PATTERN = %r{^/.+/[ismU]*$}.freeze
@@ -14,14 +14,14 @@ module Gitlab
@value = regexp
unless Gitlab::UntrustedRegexp.valid?(@value)
- raise Lexer::SyntaxError, 'Invalid regular expression!'
+ raise Lexer::SyntaxError, "Invalid regular expression!"
end
end
def evaluate(variables = {})
Gitlab::UntrustedRegexp.fabricate(@value)
rescue RegexpError
- raise Expression::RuntimeError, 'Invalid regular expression!'
+ raise Expression::RuntimeError, "Invalid regular expression!"
end
def self.build(string)
diff --git a/lib/gitlab/ci/pipeline/expression/lexer.rb b/lib/gitlab/ci/pipeline/expression/lexer.rb
index f26542361a2..dc1b020b311 100644
--- a/lib/gitlab/ci/pipeline/expression/lexer.rb
+++ b/lib/gitlab/ci/pipeline/expression/lexer.rb
@@ -15,7 +15,7 @@ module Gitlab
Expression::Lexeme::Pattern,
Expression::Lexeme::Null,
Expression::Lexeme::Equals,
- Expression::Lexeme::Matches
+ Expression::Lexeme::Matches,
].freeze
MAX_TOKENS = 100
@@ -43,18 +43,18 @@ module Gitlab
return tokens if @scanner.eos?
- lexeme = LEXEMES.find do |type|
+ lexeme = LEXEMES.find { |type|
type.scan(@scanner).tap do |token|
tokens.push(token) if token.present?
end
- end
+ }
unless lexeme.present?
- raise Lexer::SyntaxError, 'Unknown lexeme found!'
+ raise Lexer::SyntaxError, "Unknown lexeme found!"
end
end
- raise Lexer::SyntaxError, 'Too many tokens!'
+ raise Lexer::SyntaxError, "Too many tokens!"
end
end
end
diff --git a/lib/gitlab/ci/pipeline/expression/statement.rb b/lib/gitlab/ci/pipeline/expression/statement.rb
index b03611f756e..d95cce4dc00 100644
--- a/lib/gitlab/ci/pipeline/expression/statement.rb
+++ b/lib/gitlab/ci/pipeline/expression/statement.rb
@@ -14,7 +14,7 @@ module Gitlab
%w[variable equals null],
%w[string equals variable],
%w[null equals variable],
- %w[variable matches pattern]
+ %w[variable matches pattern],
].freeze
def initialize(statement, variables = {})
@@ -26,7 +26,7 @@ module Gitlab
raise StatementError if @lexer.lexemes.empty?
unless GRAMMAR.find { |syntax| syntax == @lexer.lexemes }
- raise StatementError, 'Unknown pipeline expression!'
+ raise StatementError, "Unknown pipeline expression!"
end
Expression::Parser.new(@lexer.tokens).tree
diff --git a/lib/gitlab/ci/pipeline/preloader.rb b/lib/gitlab/ci/pipeline/preloader.rb
index db0a1ea4dab..d5f1e434d12 100644
--- a/lib/gitlab/ci/pipeline/preloader.rb
+++ b/lib/gitlab/ci/pipeline/preloader.rb
@@ -15,7 +15,7 @@ module Gitlab
pipelines.each(&:commit)
pipelines.each do |pipeline|
- self.new(pipeline).tap do |preloader|
+ new(pipeline).tap do |preloader|
preloader.preload_commit_authors
preloader.preload_pipeline_warnings
preloader.preload_stages_warnings
diff --git a/lib/gitlab/ci/pipeline/seed/stage.rb b/lib/gitlab/ci/pipeline/seed/stage.rb
index 9c15064756a..fe1f441f69f 100644
--- a/lib/gitlab/ci/pipeline/seed/stage.rb
+++ b/lib/gitlab/ci/pipeline/seed/stage.rb
@@ -14,16 +14,16 @@ module Gitlab
@pipeline = pipeline
@attributes = attributes
- @builds = attributes.fetch(:builds).map do |attributes|
+ @builds = attributes.fetch(:builds).map { |attributes|
Seed::Build.new(@pipeline, attributes)
- end
+ }
end
def attributes
- { name: @attributes.fetch(:name),
- position: @attributes.fetch(:index),
- pipeline: @pipeline,
- project: @pipeline.project }
+ {name: @attributes.fetch(:name),
+ position: @attributes.fetch(:index),
+ pipeline: @pipeline,
+ project: @pipeline.project,}
end
def seeds
diff --git a/lib/gitlab/ci/reports/test_case.rb b/lib/gitlab/ci/reports/test_case.rb
index 292e273a03a..dccd716f6df 100644
--- a/lib/gitlab/ci/reports/test_case.rb
+++ b/lib/gitlab/ci/reports/test_case.rb
@@ -4,10 +4,10 @@ module Gitlab
module Ci
module Reports
class TestCase
- STATUS_SUCCESS = 'success'.freeze
- STATUS_FAILED = 'failed'.freeze
- STATUS_SKIPPED = 'skipped'.freeze
- STATUS_ERROR = 'error'.freeze
+ STATUS_SUCCESS = "success"
+ STATUS_FAILED = "failed"
+ STATUS_SKIPPED = "skipped"
+ STATUS_ERROR = "error"
STATUS_TYPES = [STATUS_SUCCESS, STATUS_FAILED, STATUS_SKIPPED, STATUS_ERROR].freeze
attr_reader :name, :classname, :execution_time, :status, :file, :system_output, :stack_trace, :key
@@ -26,7 +26,7 @@ module Gitlab
private
def sanitize_key_name(key)
- key.gsub(/[^0-9A-Za-z]/, '-')
+ key.gsub(/[^0-9A-Za-z]/, "-")
end
end
end
diff --git a/lib/gitlab/ci/reports/test_reports_comparer.rb b/lib/gitlab/ci/reports/test_reports_comparer.rb
index 11810bdc0a8..c644dff5569 100644
--- a/lib/gitlab/ci/reports/test_reports_comparer.rb
+++ b/lib/gitlab/ci/reports/test_reports_comparer.rb
@@ -29,7 +29,7 @@ module Gitlab
end
end
- %w(total_count resolved_count failed_count).each do |method|
+ %w[total_count resolved_count failed_count].each do |method|
define_method(method) do
# rubocop: disable CodeReuse/ActiveRecord
suite_comparers.sum { |suite| suite.public_send(method) } # rubocop:disable GitlabSecurity/PublicSend
diff --git a/lib/gitlab/ci/reports/test_suite.rb b/lib/gitlab/ci/reports/test_suite.rb
index b0391160c15..df3c98bb54e 100644
--- a/lib/gitlab/ci/reports/test_suite.rb
+++ b/lib/gitlab/ci/reports/test_suite.rb
@@ -38,7 +38,7 @@ module Gitlab
end
TestCase::STATUS_TYPES.each do |status_type|
- define_method("#{status_type}") do
+ define_method(status_type.to_s) do
test_cases[status_type] || {}
end
diff --git a/lib/gitlab/ci/reports/test_suite_comparer.rb b/lib/gitlab/ci/reports/test_suite_comparer.rb
index 9cb7db5934c..fb470d000b7 100644
--- a/lib/gitlab/ci/reports/test_suite_comparer.rb
+++ b/lib/gitlab/ci/reports/test_suite_comparer.rb
@@ -16,25 +16,25 @@ module Gitlab
def new_failures
strong_memoize(:new_failures) do
- head_suite.failed.reject do |key, _|
+ head_suite.failed.reject { |key, _|
base_suite.failed.include?(key)
- end.values
+ }.values
end
end
def existing_failures
strong_memoize(:existing_failures) do
- head_suite.failed.select do |key, _|
+ head_suite.failed.select { |key, _|
base_suite.failed.include?(key)
- end.values
+ }.values
end
end
def resolved_failures
strong_memoize(:resolved_failures) do
- head_suite.success.select do |key, _|
+ head_suite.success.select { |key, _|
base_suite.failed.include?(key)
- end.values
+ }.values
end
end
diff --git a/lib/gitlab/ci/status/build/cancelable.rb b/lib/gitlab/ci/status/build/cancelable.rb
index 43fb5cdbbe6..ca6b59bbe23 100644
--- a/lib/gitlab/ci/status/build/cancelable.rb
+++ b/lib/gitlab/ci/status/build/cancelable.rb
@@ -10,7 +10,7 @@ module Gitlab
end
def action_icon
- 'cancel'
+ "cancel"
end
def action_path
@@ -22,11 +22,11 @@ module Gitlab
end
def action_title
- 'Cancel'
+ "Cancel"
end
def action_button_title
- _('Cancel this job')
+ _("Cancel this job")
end
def self.matches?(build, user)
diff --git a/lib/gitlab/ci/status/build/canceled.rb b/lib/gitlab/ci/status/build/canceled.rb
index 0518b9e673d..1bd40119e2c 100644
--- a/lib/gitlab/ci/status/build/canceled.rb
+++ b/lib/gitlab/ci/status/build/canceled.rb
@@ -7,9 +7,9 @@ module Gitlab
class Canceled < Status::Extended
def illustration
{
- image: 'illustrations/canceled-job_empty.svg',
- size: 'svg-430',
- title: _('This job has been canceled')
+ image: "illustrations/canceled-job_empty.svg",
+ size: "svg-430",
+ title: _("This job has been canceled"),
}
end
diff --git a/lib/gitlab/ci/status/build/common.rb b/lib/gitlab/ci/status/build/common.rb
index 6a75ec5c37f..24d0d8d4aab 100644
--- a/lib/gitlab/ci/status/build/common.rb
+++ b/lib/gitlab/ci/status/build/common.rb
@@ -7,9 +7,9 @@ module Gitlab
module Common
def illustration
{
- image: 'illustrations/skipped-job_empty.svg',
- size: 'svg-430',
- title: _('This job does not have a trace.')
+ image: "illustrations/skipped-job_empty.svg",
+ size: "svg-430",
+ title: _("This job does not have a trace."),
}
end
diff --git a/lib/gitlab/ci/status/build/created.rb b/lib/gitlab/ci/status/build/created.rb
index 780fea23123..dd4d2793b1e 100644
--- a/lib/gitlab/ci/status/build/created.rb
+++ b/lib/gitlab/ci/status/build/created.rb
@@ -7,10 +7,10 @@ module Gitlab
class Created < Status::Extended
def illustration
{
- image: 'illustrations/job_not_triggered.svg',
- size: 'svg-306',
- title: _('This job has not been triggered yet'),
- content: _('This job depends on upstream jobs that need to succeed in order for this job to be triggered')
+ image: "illustrations/job_not_triggered.svg",
+ size: "svg-306",
+ title: _("This job has not been triggered yet"),
+ content: _("This job depends on upstream jobs that need to succeed in order for this job to be triggered"),
}
end
diff --git a/lib/gitlab/ci/status/build/erased.rb b/lib/gitlab/ci/status/build/erased.rb
index d74cfc1ee77..82c107f8cf0 100644
--- a/lib/gitlab/ci/status/build/erased.rb
+++ b/lib/gitlab/ci/status/build/erased.rb
@@ -7,9 +7,9 @@ module Gitlab
class Erased < Status::Extended
def illustration
{
- image: 'illustrations/erased-log_empty.svg',
- size: 'svg-430',
- title: _('Job has been erased')
+ image: "illustrations/erased-log_empty.svg",
+ size: "svg-430",
+ title: _("Job has been erased"),
}
end
diff --git a/lib/gitlab/ci/status/build/factory.rb b/lib/gitlab/ci/status/build/factory.rb
index 6e4bfe23f2b..806caf4d091 100644
--- a/lib/gitlab/ci/status/build/factory.rb
+++ b/lib/gitlab/ci/status/build/factory.rb
@@ -12,16 +12,16 @@ module Gitlab
Status::Build::Canceled,
Status::Build::Created,
Status::Build::Pending,
- Status::Build::Skipped],
+ Status::Build::Skipped,],
[Status::Build::Cancelable,
- Status::Build::Retryable],
+ Status::Build::Retryable,],
[Status::Build::Failed],
[Status::Build::FailedAllowed,
Status::Build::Unschedule,
Status::Build::Play,
- Status::Build::Stop],
+ Status::Build::Stop,],
[Status::Build::Action],
- [Status::Build::Retried]]
+ [Status::Build::Retried],]
end
def self.common_helpers
diff --git a/lib/gitlab/ci/status/build/failed.rb b/lib/gitlab/ci/status/build/failed.rb
index d40454df737..3c0ff7ae739 100644
--- a/lib/gitlab/ci/status/build/failed.rb
+++ b/lib/gitlab/ci/status/build/failed.rb
@@ -6,16 +6,16 @@ module Gitlab
module Build
class Failed < Status::Extended
REASONS = {
- unknown_failure: 'unknown failure',
- script_failure: 'script failure',
- api_failure: 'API failure',
- stuck_or_timeout_failure: 'stuck or timeout failure',
- runner_system_failure: 'runner system failure',
- missing_dependency_failure: 'missing dependency failure',
- runner_unsupported: 'unsupported runner',
- stale_schedule: 'stale schedule',
- job_execution_timeout: 'job execution timeout',
- archived_failure: 'archived failure'
+ unknown_failure: "unknown failure",
+ script_failure: "script failure",
+ api_failure: "API failure",
+ stuck_or_timeout_failure: "stuck or timeout failure",
+ runner_system_failure: "runner system failure",
+ missing_dependency_failure: "missing dependency failure",
+ runner_unsupported: "unsupported runner",
+ stale_schedule: "stale schedule",
+ job_execution_timeout: "job execution timeout",
+ archived_failure: "archived failure",
}.freeze
private_constant :REASONS
@@ -39,7 +39,7 @@ module Gitlab
private
def base_message
- "#{s_('CiStatusLabel|failed')} #{description}"
+ "#{s_("CiStatusLabel|failed")} #{description}"
end
def description
diff --git a/lib/gitlab/ci/status/build/failed_allowed.rb b/lib/gitlab/ci/status/build/failed_allowed.rb
index d7570fdd3e2..ab8e0e1b31d 100644
--- a/lib/gitlab/ci/status/build/failed_allowed.rb
+++ b/lib/gitlab/ci/status/build/failed_allowed.rb
@@ -10,11 +10,11 @@ module Gitlab
end
def icon
- 'status_warning'
+ "status_warning"
end
def group
- 'failed_with_warnings'
+ "failed_with_warnings"
end
def status_tooltip
diff --git a/lib/gitlab/ci/status/build/manual.rb b/lib/gitlab/ci/status/build/manual.rb
index d01b09f1398..f872cb406f1 100644
--- a/lib/gitlab/ci/status/build/manual.rb
+++ b/lib/gitlab/ci/status/build/manual.rb
@@ -7,10 +7,10 @@ module Gitlab
class Manual < Status::Extended
def illustration
{
- image: 'illustrations/manual_action.svg',
- size: 'svg-394',
- title: _('This job requires a manual action'),
- content: _('This job depends on a user to trigger its process. Often they are used to deploy code to production environments')
+ image: "illustrations/manual_action.svg",
+ size: "svg-394",
+ title: _("This job requires a manual action"),
+ content: _("This job depends on a user to trigger its process. Often they are used to deploy code to production environments"),
}
end
diff --git a/lib/gitlab/ci/status/build/pending.rb b/lib/gitlab/ci/status/build/pending.rb
index 95f668295dd..50ad4854a66 100644
--- a/lib/gitlab/ci/status/build/pending.rb
+++ b/lib/gitlab/ci/status/build/pending.rb
@@ -7,10 +7,10 @@ module Gitlab
class Pending < Status::Extended
def illustration
{
- image: 'illustrations/pending_job_empty.svg',
- size: 'svg-430',
- title: _('This job has not started yet'),
- content: _('This job is in pending state and is waiting to be picked by a runner')
+ image: "illustrations/pending_job_empty.svg",
+ size: "svg-430",
+ title: _("This job has not started yet"),
+ content: _("This job is in pending state and is waiting to be picked by a runner"),
}
end
diff --git a/lib/gitlab/ci/status/build/play.rb b/lib/gitlab/ci/status/build/play.rb
index c66b8ca5654..780808af129 100644
--- a/lib/gitlab/ci/status/build/play.rb
+++ b/lib/gitlab/ci/status/build/play.rb
@@ -6,7 +6,7 @@ module Gitlab
module Build
class Play < Status::Extended
def label
- 'manual play action'
+ "manual play action"
end
def has_action?
@@ -14,15 +14,15 @@ module Gitlab
end
def action_icon
- 'play'
+ "play"
end
def action_title
- 'Play'
+ "Play"
end
def action_button_title
- _('Trigger this manual action')
+ _("Trigger this manual action")
end
def action_path
diff --git a/lib/gitlab/ci/status/build/retryable.rb b/lib/gitlab/ci/status/build/retryable.rb
index eb6b3f21604..c2ee793cfbe 100644
--- a/lib/gitlab/ci/status/build/retryable.rb
+++ b/lib/gitlab/ci/status/build/retryable.rb
@@ -10,15 +10,15 @@ module Gitlab
end
def action_icon
- 'retry'
+ "retry"
end
def action_title
- 'Retry'
+ "Retry"
end
def action_button_title
- _('Retry this job')
+ _("Retry this job")
end
def action_path
diff --git a/lib/gitlab/ci/status/build/scheduled.rb b/lib/gitlab/ci/status/build/scheduled.rb
index 0a09dbe5f42..386a34d6343 100644
--- a/lib/gitlab/ci/status/build/scheduled.rb
+++ b/lib/gitlab/ci/status/build/scheduled.rb
@@ -7,13 +7,13 @@ module Gitlab
class Scheduled < Status::Extended
def illustration
{
- image: 'illustrations/illustrations_scheduled-job_countdown.svg',
- size: 'svg-394',
+ image: "illustrations/illustrations_scheduled-job_countdown.svg",
+ size: "svg-394",
title: _("This is a delayed job to run in %{remainingTime}"),
content: _("This job will automatically run after its timer finishes. " \
"Often they are used for incremental roll-out deploys " \
"to production environments. When unscheduled it converts " \
- "into a manual action.")
+ "into a manual action."),
}
end
diff --git a/lib/gitlab/ci/status/build/skipped.rb b/lib/gitlab/ci/status/build/skipped.rb
index 4fe2f7b3114..451b30f6391 100644
--- a/lib/gitlab/ci/status/build/skipped.rb
+++ b/lib/gitlab/ci/status/build/skipped.rb
@@ -7,9 +7,9 @@ module Gitlab
class Skipped < Status::Extended
def illustration
{
- image: 'illustrations/skipped-job_empty.svg',
- size: 'svg-430',
- title: _('This job has been skipped')
+ image: "illustrations/skipped-job_empty.svg",
+ size: "svg-430",
+ title: _("This job has been skipped"),
}
end
diff --git a/lib/gitlab/ci/status/build/stop.rb b/lib/gitlab/ci/status/build/stop.rb
index a620e7ad126..823649b785d 100644
--- a/lib/gitlab/ci/status/build/stop.rb
+++ b/lib/gitlab/ci/status/build/stop.rb
@@ -6,7 +6,7 @@ module Gitlab
module Build
class Stop < Status::Extended
def label
- 'manual stop action'
+ "manual stop action"
end
def has_action?
@@ -14,15 +14,15 @@ module Gitlab
end
def action_icon
- 'stop'
+ "stop"
end
def action_title
- 'Stop'
+ "Stop"
end
def action_button_title
- _('Stop this environment')
+ _("Stop this environment")
end
def action_path
diff --git a/lib/gitlab/ci/status/build/unschedule.rb b/lib/gitlab/ci/status/build/unschedule.rb
index 9110839cb55..e603c9ee0a5 100644
--- a/lib/gitlab/ci/status/build/unschedule.rb
+++ b/lib/gitlab/ci/status/build/unschedule.rb
@@ -6,7 +6,7 @@ module Gitlab
module Build
class Unschedule < Status::Extended
def label
- 'unschedule action'
+ "unschedule action"
end
def has_action?
@@ -14,15 +14,15 @@ module Gitlab
end
def action_icon
- 'time-out'
+ "time-out"
end
def action_title
- 'Unschedule'
+ "Unschedule"
end
def action_button_title
- _('Unschedule job')
+ _("Unschedule job")
end
def action_path
diff --git a/lib/gitlab/ci/status/canceled.rb b/lib/gitlab/ci/status/canceled.rb
index 07f37732023..0abf5acdd52 100644
--- a/lib/gitlab/ci/status/canceled.rb
+++ b/lib/gitlab/ci/status/canceled.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Canceled < Status::Core
def text
- s_('CiStatusText|canceled')
+ s_("CiStatusText|canceled")
end
def label
- s_('CiStatusLabel|canceled')
+ s_("CiStatusLabel|canceled")
end
def icon
- 'status_canceled'
+ "status_canceled"
end
def favicon
- 'favicon_status_canceled'
+ "favicon_status_canceled"
end
end
end
diff --git a/lib/gitlab/ci/status/created.rb b/lib/gitlab/ci/status/created.rb
index fface4bb97b..4fb6ad6ed97 100644
--- a/lib/gitlab/ci/status/created.rb
+++ b/lib/gitlab/ci/status/created.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Created < Status::Core
def text
- s_('CiStatusText|created')
+ s_("CiStatusText|created")
end
def label
- s_('CiStatusLabel|created')
+ s_("CiStatusLabel|created")
end
def icon
- 'status_created'
+ "status_created"
end
def favicon
- 'favicon_status_created'
+ "favicon_status_created"
end
end
end
diff --git a/lib/gitlab/ci/status/factory.rb b/lib/gitlab/ci/status/factory.rb
index 3446644eff8..654515bd509 100644
--- a/lib/gitlab/ci/status/factory.rb
+++ b/lib/gitlab/ci/status/factory.rb
@@ -34,9 +34,9 @@ module Gitlab
def extended_statuses
return @extended_statuses if defined?(@extended_statuses)
- groups = self.class.extended_statuses.map do |group|
+ groups = self.class.extended_statuses.map { |group|
Array(group).find { |status| status.matches?(@subject, @user) }
- end
+ }
@extended_statuses = groups.flatten.compact
end
diff --git a/lib/gitlab/ci/status/failed.rb b/lib/gitlab/ci/status/failed.rb
index 770ed7d4d5a..f5a67778a0c 100644
--- a/lib/gitlab/ci/status/failed.rb
+++ b/lib/gitlab/ci/status/failed.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Failed < Status::Core
def text
- s_('CiStatusText|failed')
+ s_("CiStatusText|failed")
end
def label
- s_('CiStatusLabel|failed')
+ s_("CiStatusLabel|failed")
end
def icon
- 'status_failed'
+ "status_failed"
end
def favicon
- 'favicon_status_failed'
+ "favicon_status_failed"
end
end
end
diff --git a/lib/gitlab/ci/status/manual.rb b/lib/gitlab/ci/status/manual.rb
index 50c92add400..2d8e7033e44 100644
--- a/lib/gitlab/ci/status/manual.rb
+++ b/lib/gitlab/ci/status/manual.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Manual < Status::Core
def text
- s_('CiStatusText|manual')
+ s_("CiStatusText|manual")
end
def label
- s_('CiStatusLabel|manual action')
+ s_("CiStatusLabel|manual action")
end
def icon
- 'status_manual'
+ "status_manual"
end
def favicon
- 'favicon_status_manual'
+ "favicon_status_manual"
end
end
end
diff --git a/lib/gitlab/ci/status/pending.rb b/lib/gitlab/ci/status/pending.rb
index cea7e6ed938..4aebe115c2d 100644
--- a/lib/gitlab/ci/status/pending.rb
+++ b/lib/gitlab/ci/status/pending.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Pending < Status::Core
def text
- s_('CiStatusText|pending')
+ s_("CiStatusText|pending")
end
def label
- s_('CiStatusLabel|pending')
+ s_("CiStatusLabel|pending")
end
def icon
- 'status_pending'
+ "status_pending"
end
def favicon
- 'favicon_status_pending'
+ "favicon_status_pending"
end
end
end
diff --git a/lib/gitlab/ci/status/pipeline/blocked.rb b/lib/gitlab/ci/status/pipeline/blocked.rb
index ed13a439be0..a1dbf0a63f2 100644
--- a/lib/gitlab/ci/status/pipeline/blocked.rb
+++ b/lib/gitlab/ci/status/pipeline/blocked.rb
@@ -6,11 +6,11 @@ module Gitlab
module Pipeline
class Blocked < Status::Extended
def text
- s_('CiStatusText|blocked')
+ s_("CiStatusText|blocked")
end
def label
- s_('CiStatusLabel|waiting for manual action')
+ s_("CiStatusLabel|waiting for manual action")
end
def self.matches?(pipeline, user)
diff --git a/lib/gitlab/ci/status/pipeline/delayed.rb b/lib/gitlab/ci/status/pipeline/delayed.rb
index e61acdcd167..9b87aaaacef 100644
--- a/lib/gitlab/ci/status/pipeline/delayed.rb
+++ b/lib/gitlab/ci/status/pipeline/delayed.rb
@@ -6,11 +6,11 @@ module Gitlab
module Pipeline
class Delayed < Status::Extended
def text
- s_('CiStatusText|delayed')
+ s_("CiStatusText|delayed")
end
def label
- s_('CiStatusLabel|waiting for delayed job')
+ s_("CiStatusLabel|waiting for delayed job")
end
def self.matches?(pipeline, user)
diff --git a/lib/gitlab/ci/status/pipeline/factory.rb b/lib/gitlab/ci/status/pipeline/factory.rb
index 5d1a8bbd924..606fa7bba7b 100644
--- a/lib/gitlab/ci/status/pipeline/factory.rb
+++ b/lib/gitlab/ci/status/pipeline/factory.rb
@@ -8,7 +8,7 @@ module Gitlab
def self.extended_statuses
[[Status::SuccessWarning,
Status::Pipeline::Delayed,
- Status::Pipeline::Blocked]]
+ Status::Pipeline::Blocked,]]
end
def self.common_helpers
diff --git a/lib/gitlab/ci/status/running.rb b/lib/gitlab/ci/status/running.rb
index ac7dd74cdce..65563b33fd5 100644
--- a/lib/gitlab/ci/status/running.rb
+++ b/lib/gitlab/ci/status/running.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Running < Status::Core
def text
- s_('CiStatus|running')
+ s_("CiStatus|running")
end
def label
- s_('CiStatus|running')
+ s_("CiStatus|running")
end
def icon
- 'status_running'
+ "status_running"
end
def favicon
- 'favicon_status_running'
+ "favicon_status_running"
end
end
end
diff --git a/lib/gitlab/ci/status/scheduled.rb b/lib/gitlab/ci/status/scheduled.rb
index 16ad1da89e3..2fb4c766f08 100644
--- a/lib/gitlab/ci/status/scheduled.rb
+++ b/lib/gitlab/ci/status/scheduled.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Scheduled < Status::Core
def text
- s_('CiStatusText|delayed')
+ s_("CiStatusText|delayed")
end
def label
- s_('CiStatusLabel|delayed')
+ s_("CiStatusLabel|delayed")
end
def icon
- 'status_scheduled'
+ "status_scheduled"
end
def favicon
- 'favicon_status_scheduled'
+ "favicon_status_scheduled"
end
end
end
diff --git a/lib/gitlab/ci/status/skipped.rb b/lib/gitlab/ci/status/skipped.rb
index aaec1e1d201..e5d7bd01fe2 100644
--- a/lib/gitlab/ci/status/skipped.rb
+++ b/lib/gitlab/ci/status/skipped.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Skipped < Status::Core
def text
- s_('CiStatusText|skipped')
+ s_("CiStatusText|skipped")
end
def label
- s_('CiStatusLabel|skipped')
+ s_("CiStatusLabel|skipped")
end
def icon
- 'status_skipped'
+ "status_skipped"
end
def favicon
- 'favicon_status_skipped'
+ "favicon_status_skipped"
end
end
end
diff --git a/lib/gitlab/ci/status/stage/common.rb b/lib/gitlab/ci/status/stage/common.rb
index f12daaa9676..a0dc5c4ce84 100644
--- a/lib/gitlab/ci/status/stage/common.rb
+++ b/lib/gitlab/ci/status/stage/common.rb
@@ -11,8 +11,8 @@ module Gitlab
def details_path
project_pipeline_path(subject.pipeline.project,
- subject.pipeline,
- anchor: subject.name)
+ subject.pipeline,
+ anchor: subject.name)
end
def has_action?
diff --git a/lib/gitlab/ci/status/success.rb b/lib/gitlab/ci/status/success.rb
index 020f2c5b89f..507e3c8d7b2 100644
--- a/lib/gitlab/ci/status/success.rb
+++ b/lib/gitlab/ci/status/success.rb
@@ -5,19 +5,19 @@ module Gitlab
module Status
class Success < Status::Core
def text
- s_('CiStatusText|passed')
+ s_("CiStatusText|passed")
end
def label
- s_('CiStatusLabel|passed')
+ s_("CiStatusLabel|passed")
end
def icon
- 'status_success'
+ "status_success"
end
def favicon
- 'favicon_status_success'
+ "favicon_status_success"
end
end
end
diff --git a/lib/gitlab/ci/status/success_warning.rb b/lib/gitlab/ci/status/success_warning.rb
index 6632cd9b143..9cc58742a4c 100644
--- a/lib/gitlab/ci/status/success_warning.rb
+++ b/lib/gitlab/ci/status/success_warning.rb
@@ -9,19 +9,19 @@ module Gitlab
#
class SuccessWarning < Status::Extended
def text
- s_('CiStatusText|passed')
+ s_("CiStatusText|passed")
end
def label
- s_('CiStatusLabel|passed with warnings')
+ s_("CiStatusLabel|passed with warnings")
end
def icon
- 'status_warning'
+ "status_warning"
end
def group
- 'success_with_warnings'
+ "success_with_warnings"
end
def self.matches?(subject, user)
diff --git a/lib/gitlab/ci/trace.rb b/lib/gitlab/ci/trace.rb
index bf5f2a31f0e..a2ed99402a5 100644
--- a/lib/gitlab/ci/trace.rb
+++ b/lib/gitlab/ci/trace.rb
@@ -45,14 +45,14 @@ module Gitlab
end
def set(data)
- write('w+b') do |stream|
+ write("w+b") do |stream|
data = job.hide_secrets(data)
stream.set(data)
end
end
def append(data, offset)
- write('a+b') do |stream|
+ write("a+b") do |stream|
current_length = stream.size
break current_length unless current_length == offset
@@ -67,7 +67,7 @@ module Gitlab
end
def read
- stream = Gitlab::Ci::Trace::Stream.new do
+ stream = Gitlab::Ci::Trace::Stream.new {
if trace_artifact
trace_artifact.open
elsif job.trace_chunks.any?
@@ -77,7 +77,7 @@ module Gitlab
elsif old_trace
StringIO.new(old_trace)
end
- end
+ }
yield stream
ensure
@@ -113,17 +113,17 @@ module Gitlab
private
def unsafe_write!(mode, &blk)
- stream = Gitlab::Ci::Trace::Stream.new do
+ stream = Gitlab::Ci::Trace::Stream.new {
if trace_artifact
- raise AlreadyArchivedError, 'Could not write to the archived trace'
+ raise AlreadyArchivedError, "Could not write to the archived trace"
elsif current_path
File.open(current_path, mode)
- elsif Feature.enabled?('ci_enable_live_trace')
+ elsif Feature.enabled?("ci_enable_live_trace")
Gitlab::Ci::Trace::ChunkedIO.new(job)
else
File.open(ensure_path, mode)
end
- end
+ }
yield(stream).tap do
job.touch if job.needs_touch?
@@ -133,8 +133,8 @@ module Gitlab
end
def unsafe_archive!
- raise AlreadyArchivedError, 'Could not archive again' if trace_artifact
- raise ArchiveError, 'Job is not finished yet' unless job.complete?
+ raise AlreadyArchivedError, "Could not archive again" if trace_artifact
+ raise ArchiveError, "Job is not finished yet" unless job.complete?
if job.trace_chunks.any?
Gitlab::Ci::Trace::ChunkedIO.new(job) do |stream|
@@ -147,7 +147,7 @@ module Gitlab
FileUtils.rm(current_path)
end
elsif old_trace
- StringIO.new(old_trace, 'rb').tap do |stream|
+ StringIO.new(old_trace, "rb").tap do |stream|
archive_stream!(stream)
job.erase_old_trace!
end
@@ -167,11 +167,11 @@ module Gitlab
def clone_file!(src_stream, temp_dir)
FileUtils.mkdir_p(temp_dir)
- Dir.mktmpdir('tmp-trace', temp_dir) do |dir_path|
+ Dir.mktmpdir("tmp-trace", temp_dir) do |dir_path|
temp_path = File.join(dir_path, "job.log")
FileUtils.touch(temp_path)
size = IO.copy_stream(src_stream, temp_path)
- raise ArchiveError, 'Failed to copy stream' unless size == src_stream.size
+ raise ArchiveError, "Failed to copy stream" unless size == src_stream.size
yield(temp_path)
end
@@ -185,7 +185,8 @@ module Gitlab
project: job.project,
file_type: :trace,
file: stream,
- file_sha256: Digest::SHA256.file(path).hexdigest)
+ file_sha256: Digest::SHA256.file(path).hexdigest
+ )
end
end
@@ -203,15 +204,15 @@ module Gitlab
end
def current_path
- @current_path ||= paths.find do |trace_path|
+ @current_path ||= paths.find { |trace_path|
File.exist?(trace_path)
- end
+ }
end
def paths
[
default_path,
- deprecated_path
+ deprecated_path,
].compact
end
@@ -228,12 +229,14 @@ module Gitlab
end
def deprecated_path
- File.join(
- Settings.gitlab_ci.builds_path,
- job.created_at.utc.strftime("%Y_%m"),
- job.project.ci_id.to_s,
- "#{job.id}.log"
- ) if job.project&.ci_id
+ if job.project&.ci_id
+ File.join(
+ Settings.gitlab_ci.builds_path,
+ job.created_at.utc.strftime("%Y_%m"),
+ job.project.ci_id.to_s,
+ "#{job.id}.log"
+ )
+ end
end
def trace_artifact
diff --git a/lib/gitlab/ci/trace/chunked_io.rb b/lib/gitlab/ci/trace/chunked_io.rb
index 8c6fd56493f..8c0113f6274 100644
--- a/lib/gitlab/ci/trace/chunked_io.rb
+++ b/lib/gitlab/ci/trace/chunked_io.rb
@@ -15,7 +15,7 @@ module Gitlab
attr_reader :tell, :size
attr_reader :chunk_data, :chunk_range
- alias_method :pos, :tell
+ alias pos tell
def initialize(build, &block)
@build = build
@@ -50,7 +50,7 @@ module Gitlab
-1
end
- raise ArgumentError, 'new position is outside of file' if new_pos < 0 || new_pos > size
+ raise ArgumentError, "new position is outside of file" if new_pos < 0 || new_pos > size
@tell = new_pos
end
@@ -88,9 +88,7 @@ module Gitlab
out = out.join
# If outbuf is passed, we put the output into the buffer. This supports IO.copy_stream functionality
- if outbuf
- outbuf.replace(out)
- end
+ outbuf&.replace(out)
out
end
@@ -141,14 +139,14 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def truncate(offset)
- raise ArgumentError, 'Outside of file' if offset > size || offset < 0
+ raise ArgumentError, "Outside of file" if offset > size || offset < 0
return if offset == size # Skip the following process as it doesn't affect anything
@tell = offset
@size = offset
# remove all next chunks
- trace_chunks.where('chunk_index > ?', chunk_index).fast_destroy_all
+ trace_chunks.where("chunk_index > ?", chunk_index).fast_destroy_all
# truncate current chunk
current_chunk.truncate(chunk_offset)
diff --git a/lib/gitlab/ci/trace/section_parser.rb b/lib/gitlab/ci/trace/section_parser.rb
index f33f8cc56c1..36ff14fb67f 100644
--- a/lib/gitlab/ci/trace/section_parser.rb
+++ b/lib/gitlab/ci/trace/section_parser.rb
@@ -25,7 +25,7 @@ module Gitlab
byte_start: start_[:marker],
byte_end: end_[:marker],
date_start: start_[:timestamp],
- date_end: end_[:timestamp]
+ date_end: end_[:timestamp],
}
end
end
@@ -59,17 +59,17 @@ module Gitlab
action = action.to_sym
timestamp = Time.at(time).utc
marker = if action == :start
- marker_end
- else
- marker_start
- end
+ marker_end
+ else
+ marker_start
+ end
@markers[name] ||= []
@markers[name] << {
name: name,
action: action,
timestamp: timestamp,
- marker: marker
+ marker: marker,
}
end
diff --git a/lib/gitlab/ci/trace/stream.rb b/lib/gitlab/ci/trace/stream.rb
index e61fb50a303..23ef5f93926 100644
--- a/lib/gitlab/ci/trace/stream.rb
+++ b/lib/gitlab/ci/trace/stream.rb
@@ -14,7 +14,7 @@ module Gitlab
delegate :valid?, to: :stream, allow_nil: true
- alias_method :present?, :valid?
+ alias present? valid?
def initialize
@stream = yield
@@ -22,15 +22,15 @@ module Gitlab
end
def valid?
- self.stream.present?
+ stream.present?
end
def file?
- self.path.present?
+ path.present?
end
def path
- self.stream.path if self.stream.respond_to?(:path)
+ stream.path if stream.respond_to?(:path)
end
def limit(last_bytes = LIMIT_SIZE)
@@ -123,7 +123,7 @@ module Gitlab
def reverse_line
stream.seek(0, IO::SEEK_END)
- debris = ''
+ debris = ""
until (buf = read_backward(BUFFER_SIZE)).empty?
debris, *lines = (buf + debris).each_line.to_a
diff --git a/lib/gitlab/ci/variables/collection.rb b/lib/gitlab/ci/variables/collection.rb
index a7b4e0348c2..8a513e8fa58 100644
--- a/lib/gitlab/ci/variables/collection.rb
+++ b/lib/gitlab/ci/variables/collection.rb
@@ -9,7 +9,7 @@ module Gitlab
def initialize(variables = [])
@variables = []
- variables.each { |variable| self.append(variable) }
+ variables.each { |variable| append(variable) }
end
def append(resource)
@@ -17,7 +17,7 @@ module Gitlab
end
def concat(resources)
- tap { resources.each { |variable| self.append(variable) } }
+ tap { resources.each { |variable| append(variable) } }
end
def each
@@ -26,17 +26,17 @@ module Gitlab
def +(other)
self.class.new.tap do |collection|
- self.each { |variable| collection.append(variable) }
+ each { |variable| collection.append(variable) }
other.each { |variable| collection.append(variable) }
end
end
def to_runner_variables
- self.map(&:to_runner_variable)
+ map(&:to_runner_variable)
end
def to_hash
- self.to_runner_variables
+ to_runner_variables
.map { |env| [env.fetch(:key), env.fetch(:value)] }
.to_h.with_indifferent_access
end
diff --git a/lib/gitlab/ci/variables/collection/item.rb b/lib/gitlab/ci/variables/collection/item.rb
index 833aa75adb5..9d344261d8b 100644
--- a/lib/gitlab/ci/variables/collection/item.rb
+++ b/lib/gitlab/ci/variables/collection/item.rb
@@ -10,7 +10,7 @@ module Gitlab
value.is_a?(String) || value.nil?
@variable = {
- key: key, value: value, public: public, file: file, masked: masked
+ key: key, value: value, public: public, file: file, masked: masked,
}
end
@@ -40,9 +40,9 @@ module Gitlab
def self.fabricate(resource)
case resource
when Hash
- self.new(resource.symbolize_keys)
+ new(resource.symbolize_keys)
when ::HasVariable
- self.new(resource.to_runner_variable)
+ new(resource.to_runner_variable)
when self
resource.dup
else
diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb
index 07ba6f83d47..9600b9dae8c 100644
--- a/lib/gitlab/ci/yaml_processor.rb
+++ b/lib/gitlab/ci/yaml_processor.rb
@@ -31,31 +31,31 @@ module Gitlab
def build_attributes(name)
job = @jobs.fetch(name.to_sym, {})
- { stage_idx: @stages.index(job[:stage]),
- stage: job[:stage],
- tag_list: job[:tags],
- name: job[:name].to_s,
- allow_failure: job[:ignore],
- when: job[:when] || 'on_success',
- environment: job[:environment_name],
- coverage_regex: job[:coverage],
- yaml_variables: yaml_variables(name),
- options: {
- image: job[:image],
- services: job[:services],
- artifacts: job[:artifacts],
- cache: job[:cache],
- dependencies: job[:dependencies],
- before_script: job[:before_script],
- script: job[:script],
- after_script: job[:after_script],
- environment: job[:environment],
- retry: job[:retry],
- parallel: job[:parallel],
- instance: job[:instance],
- start_in: job[:start_in],
- trigger: job[:trigger]
- }.compact }.compact
+ {stage_idx: @stages.index(job[:stage]),
+ stage: job[:stage],
+ tag_list: job[:tags],
+ name: job[:name].to_s,
+ allow_failure: job[:ignore],
+ when: job[:when] || "on_success",
+ environment: job[:environment_name],
+ coverage_regex: job[:coverage],
+ yaml_variables: yaml_variables(name),
+ options: {
+ image: job[:image],
+ services: job[:services],
+ artifacts: job[:artifacts],
+ cache: job[:cache],
+ dependencies: job[:dependencies],
+ before_script: job[:before_script],
+ script: job[:script],
+ after_script: job[:after_script],
+ environment: job[:environment],
+ retry: job[:retry],
+ parallel: job[:parallel],
+ instance: job[:instance],
+ start_in: job[:start_in],
+ trigger: job[:trigger],
+ }.compact,}.compact
end
def stage_builds_attributes(stage)
@@ -66,20 +66,20 @@ module Gitlab
def stages_attributes
@stages.uniq.map do |stage|
- seeds = stage_builds_attributes(stage).map do |attributes|
+ seeds = stage_builds_attributes(stage).map { |attributes|
job = @jobs.fetch(attributes[:name].to_sym)
attributes
.merge(only: job.fetch(:only, {}))
.merge(except: job.fetch(:except, {}))
- end
+ }
- { name: stage, index: @stages.index(stage), builds: seeds }
+ {name: stage, index: @stages.index(stage), builds: seeds}
end
end
def self.validation_message(content, opts = {})
- return 'Please provide content of .gitlab-ci.yml' if content.blank?
+ return "Please provide content of .gitlab-ci.yml" if content.blank?
begin
Gitlab::Ci::YamlProcessor.new(content, opts)
@@ -122,7 +122,7 @@ module Gitlab
.merge(job_variables(name))
variables.map do |key, value|
- { key: key.to_s, value: value, public: true }
+ {key: key.to_s, value: value, public: true}
end
end
@@ -179,7 +179,7 @@ module Gitlab
raise ValidationError, "#{name} job: on_stop job #{on_stop} have different environment name"
end
- unless on_stop_job[:environment][:action] == 'stop'
+ unless on_stop_job[:environment][:action] == "stop"
raise ValidationError, "#{name} job: on_stop job #{on_stop} needs to have action stop defined"
end
end
diff --git a/lib/gitlab/cleanup/project_upload_file_finder.rb b/lib/gitlab/cleanup/project_upload_file_finder.rb
index 2ee8b60e76a..73877e5b642 100644
--- a/lib/gitlab/cleanup/project_upload_file_finder.rb
+++ b/lib/gitlab/cleanup/project_upload_file_finder.rb
@@ -5,9 +5,9 @@ module Gitlab
class ProjectUploadFileFinder
FIND_BATCH_SIZE = 500
ABSOLUTE_UPLOAD_DIR = FileUploader.root.freeze
- EXCLUDED_SYSTEM_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/-/*".freeze
- EXCLUDED_HASHED_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/@hashed/*".freeze
- EXCLUDED_TMP_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/tmp/*".freeze
+ EXCLUDED_SYSTEM_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/-/*"
+ EXCLUDED_HASHED_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/@hashed/*"
+ EXCLUDED_TMP_UPLOADS_PATH = "#{ABSOLUTE_UPLOAD_DIR}/tmp/*"
# Paths are relative to the upload directory
def each_file_batch(batch_size: FIND_BATCH_SIZE, &block)
@@ -48,15 +48,15 @@ module Gitlab
ionice = which_ionice
cmd = %W[#{ionice} -c Idle] + cmd if ionice
- log_msg = "find command: \"#{cmd.join(' ')}\""
+ log_msg = "find command: \"#{cmd.join(" ")}\""
Rails.logger.info log_msg
cmd
end
def which_ionice
- Gitlab::Utils.which('ionice')
- rescue StandardError
+ Gitlab::Utils.which("ionice")
+ rescue
# In this case, returning false is relatively safe,
# even though it isn't very nice
false
diff --git a/lib/gitlab/cleanup/project_uploads.rb b/lib/gitlab/cleanup/project_uploads.rb
index 82a405362c2..8c3e6fac399 100644
--- a/lib/gitlab/cleanup/project_uploads.rb
+++ b/lib/gitlab/cleanup/project_uploads.rb
@@ -3,7 +3,7 @@
module Gitlab
module Cleanup
class ProjectUploads
- LOST_AND_FOUND = File.join(ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR, '-', 'project-lost-found')
+ LOST_AND_FOUND = File.join(ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR, "-", "project-lost-found")
attr_reader :logger
@@ -12,7 +12,7 @@ module Gitlab
end
def run!(dry_run: true)
- logger.info "Looking for orphaned project uploads to clean up#{'. Dry run' if dry_run}..."
+ logger.info "Looking for orphaned project uploads to clean up#{". Dry run" if dry_run}..."
each_orphan_file do |path, upload_path|
result = cleanup(path, upload_path, dry_run)
@@ -31,7 +31,7 @@ module Gitlab
correct_path = upload_path && find_correct_path(upload_path)
if correct_path
- move(path, correct_path, 'fix', dry_run)
+ move(path, correct_path, "fix", dry_run)
else
move_to_lost_and_found(path, dry_run)
end
@@ -40,8 +40,8 @@ module Gitlab
# Accepts a path in the form of "#{hex_secret}/#{filename}"
# rubocop: disable CodeReuse/ActiveRecord
def find_correct_path(upload_path)
- upload = Upload.find_by(uploader: 'FileUploader', path: upload_path)
- return unless upload && upload.local? && upload.model
+ upload = Upload.find_by(uploader: "FileUploader", path: upload_path)
+ return unless upload&.local? && upload&.model
upload.absolute_path
rescue => e
@@ -58,7 +58,7 @@ module Gitlab
def move_to_lost_and_found(path, dry_run)
new_path = path.sub(/\A#{ProjectUploadFileFinder::ABSOLUTE_UPLOAD_DIR}/, LOST_AND_FOUND)
- move(path, new_path, 'move to lost and found', dry_run)
+ move(path, new_path, "move to lost and found", dry_run)
end
def move(path, new_path, prefix, dry_run)
@@ -114,7 +114,7 @@ module Gitlab
return true if full_path.nil? || upload_path.nil?
# It's possible to reduce to one query, but `where_full_path_in` is complex
- !Upload.exists?(path: upload_path, model_id: project_id, model_type: 'Project', uploader: 'FileUploader')
+ !Upload.exists?(path: upload_path, model_id: project_id, model_type: "Project", uploader: "FileUploader")
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/cleanup/remote_uploads.rb b/lib/gitlab/cleanup/remote_uploads.rb
index 03298d960a4..2c552c2664b 100644
--- a/lib/gitlab/cleanup/remote_uploads.rb
+++ b/lib/gitlab/cleanup/remote_uploads.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Gitlab
module Cleanup
class RemoteUploads
@@ -17,15 +18,15 @@ module Gitlab
return
end
- logger.info "Looking for orphaned remote uploads to remove#{'. Dry run' if dry_run}..."
+ logger.info "Looking for orphaned remote uploads to remove#{". Dry run" if dry_run}..."
each_orphan_file do |file|
info = if dry_run
- "Can be moved to lost and found: #{file.key}"
- else
- new_path = move_to_lost_and_found(file)
- "Moved to lost and found: #{file.key} -> #{new_path}"
- end
+ "Can be moved to lost and found: #{file.key}"
+ else
+ new_path = move_to_lost_and_found(file)
+ "Moved to lost and found: #{file.key} -> #{new_path}"
+ end
logger.info(info)
end
@@ -56,22 +57,22 @@ module Gitlab
def move_to_lost_and_found(file)
new_path = "#{lost_and_found_dir}/#{file.key}"
- file.copy(configuration['remote_directory'], new_path)
+ file.copy(configuration["remote_directory"], new_path)
file.destroy
new_path
end
def lost_and_found_dir
- 'lost_and_found'
+ "lost_and_found"
end
def remote_directory
- connection.directories.new(key: configuration['remote_directory'])
+ connection.directories.new(key: configuration["remote_directory"])
end
def connection
- ::Fog::Storage.new(configuration['connection'].symbolize_keys)
+ ::Fog::Storage.new(configuration["connection"].symbolize_keys)
end
def configuration
diff --git a/lib/gitlab/closing_issue_extractor.rb b/lib/gitlab/closing_issue_extractor.rb
index 4ba921569ad..9c5709f2854 100644
--- a/lib/gitlab/closing_issue_extractor.rb
+++ b/lib/gitlab/closing_issue_extractor.rb
@@ -6,7 +6,7 @@ module Gitlab
link_pattern = Banzai::Filter::AutolinkFilter::LINK_PATTERN
pattern = Gitlab.config.gitlab.issue_closing_pattern
- pattern = pattern.sub('%{issue_ref}', "(?:(?:#{link_pattern})|(?:#{Issue.reference_pattern}))")
+ pattern = pattern.sub("%{issue_ref}", "(?:(?:#{link_pattern})|(?:#{Issue.reference_pattern}))")
Regexp.new(pattern).freeze
end
diff --git a/lib/gitlab/cluster/lifecycle_events.rb b/lib/gitlab/cluster/lifecycle_events.rb
index b05dca409d1..ba55105e8b3 100644
--- a/lib/gitlab/cluster/lifecycle_events.rb
+++ b/lib/gitlab/cluster/lifecycle_events.rb
@@ -60,7 +60,7 @@ module Gitlab
end
def do_master_restart
- @master_restart_hooks && @master_restart_hooks.each do |block|
+ @master_restart_hooks&.each do |block|
block.call
end
end
diff --git a/lib/gitlab/cluster/puma_worker_killer_initializer.rb b/lib/gitlab/cluster/puma_worker_killer_initializer.rb
index 4ed9a9a02ab..d4fe2995c99 100644
--- a/lib/gitlab/cluster/puma_worker_killer_initializer.rb
+++ b/lib/gitlab/cluster/puma_worker_killer_initializer.rb
@@ -4,7 +4,7 @@ module Gitlab
module Cluster
class PumaWorkerKillerInitializer
def self.start(puma_options, puma_per_worker_max_memory_mb: 650)
- require 'puma_worker_killer'
+ require "puma_worker_killer"
PumaWorkerKiller.config do |config|
# Note! ram is expressed in megabytes (whereas GITLAB_UNICORN_MEMORY_MAX is in bytes)
diff --git a/lib/gitlab/color_schemes.rb b/lib/gitlab/color_schemes.rb
index 881e5dbc923..0ae829c0e83 100644
--- a/lib/gitlab/color_schemes.rb
+++ b/lib/gitlab/color_schemes.rb
@@ -8,12 +8,12 @@ module Gitlab
Scheme = Struct.new(:id, :name, :css_class)
SCHEMES = [
- Scheme.new(1, 'White', 'white'),
- Scheme.new(2, 'Dark', 'dark'),
- Scheme.new(3, 'Solarized Light', 'solarized-light'),
- Scheme.new(4, 'Solarized Dark', 'solarized-dark'),
- Scheme.new(5, 'Monokai', 'monokai'),
- Scheme.new(6, 'None', 'none')
+ Scheme.new(1, "White", "white"),
+ Scheme.new(2, "Dark", "dark"),
+ Scheme.new(3, "Solarized Light", "solarized-light"),
+ Scheme.new(4, "Solarized Dark", "solarized-dark"),
+ Scheme.new(5, "Monokai", "monokai"),
+ Scheme.new(6, "None", "none"),
].freeze
# Convenience method to get a space-separated String of all the color scheme
@@ -21,7 +21,7 @@ module Gitlab
#
# Returns a String
def self.body_classes
- SCHEMES.collect(&:css_class).uniq.join(' ')
+ SCHEMES.collect(&:css_class).uniq.join(" ")
end
# Get a Scheme by its ID
diff --git a/lib/gitlab/config/entry/attributable.rb b/lib/gitlab/config/entry/attributable.rb
index 560fe63df0e..b84e9160e25 100644
--- a/lib/gitlab/config/entry/attributable.rb
+++ b/lib/gitlab/config/entry/attributable.rb
@@ -10,7 +10,7 @@ module Gitlab
def attributes(*attributes)
attributes.flatten.each do |attribute|
if method_defined?(attribute)
- raise ArgumentError, 'Method already defined!'
+ raise ArgumentError, "Method already defined!"
end
define_method(attribute) do
diff --git a/lib/gitlab/config/entry/configurable.rb b/lib/gitlab/config/entry/configurable.rb
index 37ba16dba25..9c40014133f 100644
--- a/lib/gitlab/config/entry/configurable.rb
+++ b/lib/gitlab/config/entry/configurable.rb
@@ -69,7 +69,7 @@ module Gitlab
end
define_method("#{symbol}_value") do
- return unless entries[symbol] && entries[symbol].valid?
+ return unless entries[symbol]&.valid?
entries[symbol].value
end
diff --git a/lib/gitlab/config/entry/factory.rb b/lib/gitlab/config/entry/factory.rb
index 79f9ff32514..dda55019bb9 100644
--- a/lib/gitlab/config/entry/factory.rb
+++ b/lib/gitlab/config/entry/factory.rb
@@ -12,7 +12,7 @@ module Gitlab
def initialize(entry)
@entry = entry
@metadata = {}
- @attributes = { default: entry.default }
+ @attributes = {default: entry.default}
end
def value(value)
diff --git a/lib/gitlab/config/entry/legacy_validation_helpers.rb b/lib/gitlab/config/entry/legacy_validation_helpers.rb
index d3ab5625743..5cbbb1b3013 100644
--- a/lib/gitlab/config/entry/legacy_validation_helpers.rb
+++ b/lib/gitlab/config/entry/legacy_validation_helpers.rb
@@ -54,7 +54,7 @@ module Gitlab
return true if value.is_a?(Symbol)
return false unless value.is_a?(String)
- if value.first == '/' && value.last == '/'
+ if value.first == "/" && value.last == "/"
validate_regexp(value[1...-1])
else
true
diff --git a/lib/gitlab/config/entry/node.rb b/lib/gitlab/config/entry/node.rb
index 9999ab4ff95..bcddb7ebcd1 100644
--- a/lib/gitlab/config/entry/node.rb
+++ b/lib/gitlab/config/entry/node.rb
@@ -56,9 +56,9 @@ module Gitlab
if leaf?
@config
else
- meaningful = @entries.select do |_key, value|
+ meaningful = @entries.select { |_key, value|
value.specified? && value.relevant?
- end
+ }
Hash[meaningful.map { |key, entry| [key, entry.value] }]
end
@@ -74,14 +74,14 @@ module Gitlab
def location
name = @key.presence || self.class.name.to_s.demodulize
- .underscore.humanize.downcase
+ .underscore.humanize.downcase
- ancestors.map(&:key).append(name).compact.join(':')
+ ancestors.map(&:key).append(name).compact.join(":")
end
def inspect
val = leaf? ? config : descendants
- unspecified = specified? ? '' : '(unspecified) '
+ unspecified = specified? ? "" : "(unspecified) "
"#<#{self.class.name} #{unspecified}{#{key}: #{val.inspect}}>"
end
diff --git a/lib/gitlab/config/entry/simplifiable.rb b/lib/gitlab/config/entry/simplifiable.rb
index 5fbf7565e2a..6a7789ed2be 100644
--- a/lib/gitlab/config/entry/simplifiable.rb
+++ b/lib/gitlab/config/entry/simplifiable.rb
@@ -10,12 +10,12 @@ module Gitlab
def initialize(config, **metadata)
unless self.class.const_defined?(:UnknownStrategy)
- raise ArgumentError, 'UndefinedStrategy not available!'
+ raise ArgumentError, "UndefinedStrategy not available!"
end
- strategy = self.class.strategies.find do |variant|
+ strategy = self.class.strategies.find { |variant|
variant.condition.call(config)
- end
+ }
entry = self.class.entry_class(strategy)
@@ -34,7 +34,7 @@ module Gitlab
def self.entry_class(strategy)
if strategy.present?
- self.const_get(strategy.name)
+ const_get(strategy.name)
else
self::UnknownStrategy
end
diff --git a/lib/gitlab/config/entry/validator.rb b/lib/gitlab/config/entry/validator.rb
index e5efd4a7b0a..32f3b508696 100644
--- a/lib/gitlab/config/entry/validator.rb
+++ b/lib/gitlab/config/entry/validator.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def self.name
- 'Validator'
+ "Validator"
end
end
end
diff --git a/lib/gitlab/config/entry/validators.rb b/lib/gitlab/config/entry/validators.rb
index 25bfa50f829..8dd1bc3fdf3 100644
--- a/lib/gitlab/config/entry/validators.rb
+++ b/lib/gitlab/config/entry/validators.rb
@@ -10,7 +10,7 @@ module Gitlab
if unknown_keys.any?
record.errors.add(attribute, "contains unknown keys: " +
- unknown_keys.join(', '))
+ unknown_keys.join(", "))
end
end
end
@@ -28,7 +28,7 @@ module Gitlab
unkown_values = value - options[:in]
unless unkown_values.empty?
record.errors.add(attribute, "contains unknown values: " +
- unkown_values.join(', '))
+ unkown_values.join(", "))
end
end
end
@@ -38,7 +38,7 @@ module Gitlab
def validate_each(record, attribute, value)
unless validate_array_of_strings(value)
- record.errors.add(attribute, 'should be an array of strings')
+ record.errors.add(attribute, "should be an array of strings")
end
end
end
@@ -48,7 +48,7 @@ module Gitlab
def validate_each(record, attribute, value)
unless validate_boolean(value)
- record.errors.add(attribute, 'should be a boolean value')
+ record.errors.add(attribute, "should be a boolean value")
end
end
end
@@ -58,12 +58,12 @@ module Gitlab
def validate_each(record, attribute, value)
unless validate_duration(value)
- record.errors.add(attribute, 'should be a duration')
+ record.errors.add(attribute, "should be a duration")
end
if options[:limit]
unless validate_duration_limit(value, options[:limit])
- record.errors.add(attribute, 'should not exceed the limit')
+ record.errors.add(attribute, "should not exceed the limit")
end
end
end
@@ -72,7 +72,7 @@ module Gitlab
class HashOrStringValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value.is_a?(Hash) || value.is_a?(String)
- record.errors.add(attribute, 'should be a hash or a string')
+ record.errors.add(attribute, "should be a hash or a string")
end
end
end
@@ -80,7 +80,7 @@ module Gitlab
class HashOrIntegerValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
unless value.is_a?(Hash) || value.is_a?(Integer)
- record.errors.add(attribute, 'should be a hash or an integer')
+ record.errors.add(attribute, "should be a hash or an integer")
end
end
end
@@ -92,7 +92,7 @@ module Gitlab
if validate_string(value)
validate_path(record, attribute, value)
else
- record.errors.add(attribute, 'should be a string or symbol')
+ record.errors.add(attribute, "should be a string or symbol")
end
end
@@ -101,9 +101,9 @@ module Gitlab
def validate_path(record, attribute, value)
path = CGI.unescape(value.to_s)
- if path.include?('/')
+ if path.include?("/")
record.errors.add(attribute, 'cannot contain the "/" character')
- elsif path == '.' || path == '..'
+ elsif path == "." || path == ".."
record.errors.add(attribute, 'cannot be "." or ".."')
end
end
@@ -114,15 +114,15 @@ module Gitlab
def validate_each(record, attribute, value)
unless validate_regexp(value)
- record.errors.add(attribute, 'must be a regular expression')
+ record.errors.add(attribute, "must be a regular expression")
end
end
private
def look_like_regexp?(value)
- value.is_a?(String) && value.start_with?('/') &&
- value.end_with?('/')
+ value.is_a?(String) && value.start_with?("/") &&
+ value.end_with?("/")
end
def validate_regexp(value)
@@ -137,7 +137,7 @@ module Gitlab
class ArrayOfStringsOrRegexpsValidator < RegexpValidator
def validate_each(record, attribute, value)
unless validate_array_of_strings_or_regexps(value)
- record.errors.add(attribute, 'should be an array of strings or regexps')
+ record.errors.add(attribute, "should be an array of strings or regexps")
end
end
@@ -158,7 +158,7 @@ module Gitlab
class ArrayOfStringsOrStringValidator < RegexpValidator
def validate_each(record, attribute, value)
unless validate_array_of_strings_or_string(value)
- record.errors.add(attribute, 'should be an array of strings or a string')
+ record.errors.add(attribute, "should be an array of strings or a string")
end
end
@@ -186,7 +186,7 @@ module Gitlab
def validate_each(record, attribute, value)
unless validate_variables(value)
- record.errors.add(attribute, 'should be a hash of key value pairs')
+ record.errors.add(attribute, "should be a hash of key value pairs")
end
end
end
diff --git a/lib/gitlab/config/loader/yaml.rb b/lib/gitlab/config/loader/yaml.rb
index 8159f8b8026..adaa6083fc7 100644
--- a/lib/gitlab/config/loader/yaml.rb
+++ b/lib/gitlab/config/loader/yaml.rb
@@ -16,7 +16,7 @@ module Gitlab
def load!
unless valid?
- raise Loader::FormatError, 'Invalid configuration format'
+ raise Loader::FormatError, "Invalid configuration format"
end
@config.deep_symbolize_keys
diff --git a/lib/gitlab/conflict/file.rb b/lib/gitlab/conflict/file.rb
index 0ca99506311..7f46a74f424 100644
--- a/lib/gitlab/conflict/file.rb
+++ b/lib/gitlab/conflict/file.rb
@@ -38,7 +38,7 @@ module Gitlab
lines.each do |line|
line.rich_text =
- if line.type == 'old'
+ if line.type == "old"
their_highlight[line.old_line - 1].try(:html_safe)
else
our_highlight[line.new_line - 1].try(:html_safe)
@@ -54,7 +54,7 @@ module Gitlab
sections_count = chunked_lines.size
- @sections = chunked_lines.flat_map.with_index do |(no_conflict, lines), i|
+ @sections = chunked_lines.flat_map.with_index { |(no_conflict, lines), i|
section = nil
# We need to reduce context sections to CONTEXT_LINES. Conflict sections are
@@ -77,8 +77,8 @@ module Gitlab
match_line = create_match_line(tail_lines.first)
section = [
- { conflict: false, lines: head_lines },
- { conflict: false, lines: tail_lines.unshift(match_line) }
+ {conflict: false, lines: head_lines},
+ {conflict: false, lines: tail_lines.unshift(match_line)},
]
end
elsif conflict_after
@@ -103,10 +103,10 @@ module Gitlab
# created a gap and its corresponding match line.
update_match_line_text(match_line, lines.last) unless section
- section ||= { conflict: !no_conflict, lines: lines }
+ section ||= {conflict: !no_conflict, lines: lines}
section[:id] = line_code(lines.first) unless no_conflict
section
- end
+ }
end
def line_code(line)
@@ -114,7 +114,7 @@ module Gitlab
end
def create_match_line(line)
- Gitlab::Diff::Line.new('', 'match', line.index, line.old_pos, line.new_pos)
+ Gitlab::Diff::Line.new("", "match", line.index, line.old_pos, line.new_pos)
end
# Any line beginning with a letter, an underscore, or a dollar can be used in a
@@ -151,8 +151,8 @@ module Gitlab
json_hash = {
old_path: their_path,
new_path: our_path,
- blob_icon: file_type_icon_class('file', our_mode, our_path),
- blob_path: project_blob_path(merge_request.project, ::File.join(merge_request.diff_refs.head_sha, our_path))
+ blob_icon: file_type_icon_class("file", our_mode, our_path),
+ blob_path: project_blob_path(merge_request.project, ::File.join(merge_request.diff_refs.head_sha, our_path)),
}
json_hash.tap do |json_hash|
@@ -168,9 +168,9 @@ module Gitlab
def content_path
conflict_for_path_project_merge_request_path(merge_request.project,
- merge_request,
- old_path: their_path,
- new_path: our_path)
+ merge_request,
+ old_path: their_path,
+ new_path: our_path)
end
private
@@ -185,7 +185,7 @@ module Gitlab
def their_language
strong_memoize(:their_language) do
- repository.gitattribute(their_path, 'gitlab-language')
+ repository.gitattribute(their_path, "gitlab-language")
end
end
@@ -194,20 +194,20 @@ module Gitlab
if our_path == their_path
their_language
else
- repository.gitattribute(our_path, 'gitlab-language')
+ repository.gitattribute(our_path, "gitlab-language")
end
end
end
def their_lines
strong_memoize(:their_lines) do
- lines.reject { |line| line.type == 'new' }.map(&:text).join("\n")
+ lines.reject { |line| line.type == "new" }.map(&:text).join("\n")
end
end
def our_lines
strong_memoize(:our_lines) do
- lines.reject { |line| line.type == 'old' }.map(&:text).join("\n")
+ lines.reject { |line| line.type == "old" }.map(&:text).join("\n")
end
end
end
diff --git a/lib/gitlab/conflict/file_collection.rb b/lib/gitlab/conflict/file_collection.rb
index 53406af2c4e..b06a9a54584 100644
--- a/lib/gitlab/conflict/file_collection.rb
+++ b/lib/gitlab/conflict/file_collection.rb
@@ -23,7 +23,7 @@ module Gitlab
resolution = Gitlab::Git::Conflict::Resolution.new(user, files, msg)
args = {
source_branch: merge_request.source_branch,
- target_branch: merge_request.target_branch
+ target_branch: merge_request.target_branch,
}
resolver.resolve_conflicts(@source_repo, resolution, args)
ensure
@@ -31,9 +31,9 @@ module Gitlab
end
def files
- @files ||= resolver.conflicts.map do |conflict_file|
+ @files ||= resolver.conflicts.map { |conflict_file|
Gitlab::Conflict::File.new(conflict_file, merge_request: merge_request)
- end
+ }
end
def can_be_resolved_in_ui?
@@ -60,21 +60,21 @@ module Gitlab
source_branch: merge_request.source_branch,
commit_sha: merge_request.diff_head_sha,
commit_message: default_commit_message,
- files: files
+ files: files,
}
end
def default_commit_message
- conflict_filenames = files.map do |conflict|
+ conflict_filenames = files.map { |conflict|
"# #{conflict.our_path}"
- end
+ }
- <<EOM.chomp
-Merge branch '#{merge_request.target_branch}' into '#{merge_request.source_branch}'
+ <<~EOM.chomp
+ Merge branch '#{merge_request.target_branch}' into '#{merge_request.source_branch}'
-# Conflicts:
-#{conflict_filenames.join("\n")}
-EOM
+ # Conflicts:
+ #{conflict_filenames.join("\n")}
+ EOM
end
private
diff --git a/lib/gitlab/content_disposition.rb b/lib/gitlab/content_disposition.rb
index 32207514ce5..934ecf32777 100644
--- a/lib/gitlab/content_disposition.rb
+++ b/lib/gitlab/content_disposition.rb
@@ -1,10 +1,11 @@
# frozen_string_literal: true
+
# This ports ActionDispatch::Http::ContentDisposition (https://github.com/rails/rails/pull/33829,
# which will be available in Rails 6.
module Gitlab
class ContentDisposition # :nodoc:
# Make sure we remove this patch starting with Rails 6.0.
- if Rails.version.start_with?('6.0')
+ if Rails.version.start_with?("6.0")
raise <<~MSG
Please remove this file and use `ActionDispatch::Http::ContentDisposition` instead.
MSG
@@ -39,7 +40,7 @@ module Gitlab
if filename
"#{disposition}; #{ascii_filename}; #{utf8_filename}"
else
- "#{disposition}"
+ disposition.to_s
end
end
diff --git a/lib/gitlab/contributions_calendar.rb b/lib/gitlab/contributions_calendar.rb
index 5ed6427072a..ef5c2bffcc0 100644
--- a/lib/gitlab/contributions_calendar.rb
+++ b/lib/gitlab/contributions_calendar.rb
@@ -10,10 +10,10 @@ module Gitlab
@contributor = contributor
@current_user = current_user
@projects = if @contributor.include_private_contributions?
- ContributedProjectsFinder.new(@contributor).execute(@contributor)
- else
- ContributedProjectsFinder.new(contributor).execute(current_user)
- end
+ ContributedProjectsFinder.new(@contributor).execute(@contributor)
+ else
+ ContributedProjectsFinder.new(contributor).execute(current_user)
+ end
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -36,9 +36,9 @@ module Gitlab
.from_union([repo_events, issue_events, mr_events, note_events])
.map(&:attributes)
- @activity_dates = events.each_with_object(Hash.new {|h, k| h[k] = 0 }) do |event, activities|
+ @activity_dates = events.each_with_object(Hash.new {|h, k| h[k] = 0 }) { |event, activities|
activities[event["date"]] += event["total_amount"]
- end
+ }
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -84,13 +84,13 @@ module Gitlab
.and(t[:author_id].eq(contributor.id))
date_interval = if Gitlab::Database.postgresql?
- "INTERVAL '#{Time.zone.now.utc_offset} seconds'"
- else
- "INTERVAL #{Time.zone.now.utc_offset} SECOND"
- end
+ "INTERVAL '#{Time.zone.now.utc_offset} seconds'"
+ else
+ "INTERVAL #{Time.zone.now.utc_offset} SECOND"
+ end
Event.reorder(nil)
- .select(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval}) AS date", 'count(id) as total_amount')
+ .select(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval}) AS date", "count(id) as total_amount")
.group(t[:project_id], t[:target_type], t[:action], "date(created_at + #{date_interval})")
.where(conditions)
.where("events.project_id in (#{authed_projects.to_sql})") # rubocop:disable GitlabSecurity/SqlInjection
diff --git a/lib/gitlab/correlation_id.rb b/lib/gitlab/correlation_id.rb
index 0f9bde4390e..82e36f8c00d 100644
--- a/lib/gitlab/correlation_id.rb
+++ b/lib/gitlab/correlation_id.rb
@@ -2,7 +2,7 @@
module Gitlab
module CorrelationId
- LOG_KEY = 'correlation_id'.freeze
+ LOG_KEY = "correlation_id"
class << self
def use_id(correlation_id, &blk)
diff --git a/lib/gitlab/cross_project_access.rb b/lib/gitlab/cross_project_access.rb
index 4ddc7e02d1b..e769b03bc71 100644
--- a/lib/gitlab/cross_project_access.rb
+++ b/lib/gitlab/cross_project_access.rb
@@ -4,7 +4,7 @@ module Gitlab
class CrossProjectAccess
class << self
delegate :add_check, :find_check, :checks,
- to: :instance
+ to: :instance
end
def self.instance
@@ -18,17 +18,17 @@ module Gitlab
end
def add_check(
- klass,
- actions: {},
- positive_condition: nil,
- negative_condition: nil,
- skip: false)
+ klass,
+ actions: {},
+ positive_condition: nil,
+ negative_condition: nil,
+ skip: false
+ )
new_check = CheckInfo.new(actions,
- positive_condition,
- negative_condition,
- skip
- )
+ positive_condition,
+ negative_condition,
+ skip)
@checks[klass] ||= Gitlab::CrossProjectAccess::CheckCollection.new
@checks[klass].add_check(new_check)
@@ -38,11 +38,11 @@ module Gitlab
end
def find_check(object)
- @cached_checks ||= Hash.new do |cache, new_class|
+ @cached_checks ||= Hash.new { |cache, new_class|
parent_classes = @checks.keys.select { |existing_class| new_class <= existing_class }
closest_class = closest_parent(parent_classes, new_class)
cache[new_class] = @checks[closest_class]
- end
+ }
@cached_checks[object.class]
end
diff --git a/lib/gitlab/crypto_helper.rb b/lib/gitlab/crypto_helper.rb
index 87a03d9c58f..ae78a17277a 100644
--- a/lib/gitlab/crypto_helper.rb
+++ b/lib/gitlab/crypto_helper.rb
@@ -5,9 +5,9 @@ module Gitlab
extend self
AES256_GCM_OPTIONS = {
- algorithm: 'aes-256-gcm',
+ algorithm: "aes-256-gcm",
key: Settings.attr_encrypted_db_key_base_32,
- iv: Settings.attr_encrypted_db_key_base_12
+ iv: Settings.attr_encrypted_db_key_base_12,
}.freeze
def sha256(value)
diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb
index 552aad83dd4..d3a044ae49e 100644
--- a/lib/gitlab/current_settings.rb
+++ b/lib/gitlab/current_settings.rb
@@ -26,7 +26,7 @@ module Gitlab
end
def cached_application_settings
- return in_memory_application_settings if ENV['IN_MEMORY_APPLICATION_SETTINGS'] == 'true'
+ return in_memory_application_settings if ENV["IN_MEMORY_APPLICATION_SETTINGS"] == "true"
begin
::ApplicationSetting.cached
@@ -65,10 +65,14 @@ module Gitlab
def connect_to_db?
# When the DBMS is not available, an exception (e.g. PG::ConnectionBad) is raised
- active_db_connection = ActiveRecord::Base.connection.active? rescue false
+ active_db_connection = begin
+ ActiveRecord::Base.connection.active?
+ rescue
+ false
+ end
active_db_connection &&
- Gitlab::Database.cached_table_exists?('application_settings')
+ Gitlab::Database.cached_table_exists?("application_settings")
rescue ActiveRecord::NoDatabaseError
false
end
diff --git a/lib/gitlab/cycle_analytics/base_event_fetcher.rb b/lib/gitlab/cycle_analytics/base_event_fetcher.rb
index 304d60996a6..0ba1f6bd4c3 100644
--- a/lib/gitlab/cycle_analytics/base_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/base_event_fetcher.rb
@@ -18,9 +18,9 @@ module Gitlab
def fetch
update_author!
- event_result.map do |event|
- serialize(event) if has_permission?(event['id'])
- end.compact
+ event_result.map { |event|
+ serialize(event) if has_permission?(event["id"])
+ }.compact
end
def order
@@ -30,9 +30,9 @@ module Gitlab
private
def update_author!
- return unless event_result.any? && event_result.first['author_id']
+ return unless event_result.any? && event_result.first["author_id"]
- Updater.update!(event_result, from: 'author_id', to: 'author', klass: User)
+ Updater.update!(event_result, from: "author_id", to: "author", klass: User)
end
def event_result
@@ -42,7 +42,7 @@ module Gitlab
def events_query
diff_fn = subtract_datetimes_diff(base_query, @options[:start_time_attrs], @options[:end_time_attrs])
- base_query.project(extract_diff_epoch(diff_fn).as('total_time'), *projections).order(order.desc).take(MAX_EVENTS)
+ base_query.project(extract_diff_epoch(diff_fn).as("total_time"), *projections).order(order.desc).take(MAX_EVENTS)
end
def default_order
@@ -50,7 +50,7 @@ module Gitlab
end
def serialize(_event)
- raise NotImplementedError.new("Expected #{self.name} to implement serialize(event)")
+ raise NotImplementedError.new("Expected #{name} to implement serialize(event)")
end
def has_permission?(id)
@@ -64,7 +64,7 @@ module Gitlab
end
def event_result_ids
- event_result.map { |event| event['id'] }
+ event_result.map { |event| event["id"] }
end
end
end
diff --git a/lib/gitlab/cycle_analytics/base_stage.rb b/lib/gitlab/cycle_analytics/base_stage.rb
index e2d6a301734..b39d2924c8e 100644
--- a/lib/gitlab/cycle_analytics/base_stage.rb
+++ b/lib/gitlab/cycle_analytics/base_stage.rb
@@ -19,7 +19,7 @@ module Gitlab
end
def title
- raise NotImplementedError.new("Expected #{self.name} to implement title")
+ raise NotImplementedError.new("Expected #{name} to implement title")
end
def median
@@ -48,7 +48,7 @@ module Gitlab
end
def name
- raise NotImplementedError.new("Expected #{self.name} to implement name")
+ raise NotImplementedError.new("Expected #{name} to implement name")
end
private
diff --git a/lib/gitlab/cycle_analytics/code_event_fetcher.rb b/lib/gitlab/cycle_analytics/code_event_fetcher.rb
index 591db3c35e6..44115d4cb9a 100644
--- a/lib/gitlab/cycle_analytics/code_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/code_event_fetcher.rb
@@ -9,7 +9,7 @@ module Gitlab
mr_table[:id],
mr_table[:created_at],
mr_table[:state],
- mr_table[:author_id]]
+ mr_table[:author_id],]
@order = mr_table[:created_at]
super(*args)
diff --git a/lib/gitlab/cycle_analytics/code_stage.rb b/lib/gitlab/cycle_analytics/code_stage.rb
index 2e5f9ef5a40..ead01d1317a 100644
--- a/lib/gitlab/cycle_analytics/code_stage.rb
+++ b/lib/gitlab/cycle_analytics/code_stage.rb
@@ -16,7 +16,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Code')
+ s_("CycleAnalyticsStage|Code")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/issue_event_fetcher.rb b/lib/gitlab/cycle_analytics/issue_event_fetcher.rb
index 30c6ead8968..875841cc5d7 100644
--- a/lib/gitlab/cycle_analytics/issue_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/issue_event_fetcher.rb
@@ -8,7 +8,7 @@ module Gitlab
issue_table[:iid],
issue_table[:id],
issue_table[:created_at],
- issue_table[:author_id]]
+ issue_table[:author_id],]
super(*args)
end
diff --git a/lib/gitlab/cycle_analytics/issue_stage.rb b/lib/gitlab/cycle_analytics/issue_stage.rb
index 4eae2da512c..d5059f06647 100644
--- a/lib/gitlab/cycle_analytics/issue_stage.rb
+++ b/lib/gitlab/cycle_analytics/issue_stage.rb
@@ -9,7 +9,7 @@ module Gitlab
def end_time_attrs
@end_time_attrs ||= [issue_metrics_table[:first_associated_with_milestone_at],
- issue_metrics_table[:first_added_to_board_at]]
+ issue_metrics_table[:first_added_to_board_at],]
end
def name
@@ -17,7 +17,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Issue')
+ s_("CycleAnalyticsStage|Issue")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/permissions.rb b/lib/gitlab/cycle_analytics/permissions.rb
index afefd09b614..30bd6e8c0d7 100644
--- a/lib/gitlab/cycle_analytics/permissions.rb
+++ b/lib/gitlab/cycle_analytics/permissions.rb
@@ -9,7 +9,7 @@ module Gitlab
test: :read_build,
review: :read_merge_request,
staging: :read_build,
- production: :read_issue
+ production: :read_issue,
}.freeze
def self.get(*args)
diff --git a/lib/gitlab/cycle_analytics/plan_event_fetcher.rb b/lib/gitlab/cycle_analytics/plan_event_fetcher.rb
index db8ac3becea..002abe9e089 100644
--- a/lib/gitlab/cycle_analytics/plan_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/plan_event_fetcher.rb
@@ -5,7 +5,7 @@ module Gitlab
class PlanEventFetcher < BaseEventFetcher
def initialize(*args)
@projections = [mr_diff_table[:id],
- issue_metrics_table[:first_mentioned_in_commit_at]]
+ issue_metrics_table[:first_mentioned_in_commit_at],]
super(*args)
end
@@ -27,7 +27,7 @@ module Gitlab
def merge_request_diff_commits
@merge_request_diff_commits ||=
MergeRequestDiffCommit
- .where(merge_request_diff_id: event_result.map { |event| event['id'] })
+ .where(merge_request_diff_id: event_result.map { |event| event["id"] })
.group_by(&:merge_request_diff_id)
end
@@ -42,21 +42,21 @@ module Gitlab
def first_time_reference_commit(event)
return nil unless event && merge_request_diff_commits
- commits = merge_request_diff_commits[event['id'].to_i]
+ commits = merge_request_diff_commits[event["id"].to_i]
return nil if commits.blank?
commits.find do |commit|
- next unless commit[:committed_date] && event['first_mentioned_in_commit_at']
+ next unless commit[:committed_date] && event["first_mentioned_in_commit_at"]
- commit[:committed_date].to_i == DateTime.parse(event['first_mentioned_in_commit_at'].to_s).to_i
+ commit[:committed_date].to_i == DateTime.parse(event["first_mentioned_in_commit_at"].to_s).to_i
end
end
def serialize_commit(event, commit, query)
commit = Commit.from_hash(commit.to_hash, @project)
- AnalyticsCommitSerializer.new(project: @project, total_time: event['total_time']).represent(commit)
+ AnalyticsCommitSerializer.new(project: @project, total_time: event["total_time"]).represent(commit)
end
end
end
diff --git a/lib/gitlab/cycle_analytics/plan_stage.rb b/lib/gitlab/cycle_analytics/plan_stage.rb
index 513e4575be0..19a7f2860cb 100644
--- a/lib/gitlab/cycle_analytics/plan_stage.rb
+++ b/lib/gitlab/cycle_analytics/plan_stage.rb
@@ -5,7 +5,7 @@ module Gitlab
class PlanStage < BaseStage
def start_time_attrs
@start_time_attrs ||= [issue_metrics_table[:first_associated_with_milestone_at],
- issue_metrics_table[:first_added_to_board_at]]
+ issue_metrics_table[:first_added_to_board_at],]
end
def end_time_attrs
@@ -17,7 +17,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Plan')
+ s_("CycleAnalyticsStage|Plan")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/production_stage.rb b/lib/gitlab/cycle_analytics/production_stage.rb
index 6fd7214dce7..07d1094372a 100644
--- a/lib/gitlab/cycle_analytics/production_stage.rb
+++ b/lib/gitlab/cycle_analytics/production_stage.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Production')
+ s_("CycleAnalyticsStage|Production")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/review_event_fetcher.rb b/lib/gitlab/cycle_analytics/review_event_fetcher.rb
index de100295281..9c28c64fe82 100644
--- a/lib/gitlab/cycle_analytics/review_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/review_event_fetcher.rb
@@ -9,7 +9,7 @@ module Gitlab
mr_table[:id],
mr_table[:created_at],
mr_table[:state],
- mr_table[:author_id]]
+ mr_table[:author_id],]
super(*args)
end
diff --git a/lib/gitlab/cycle_analytics/review_stage.rb b/lib/gitlab/cycle_analytics/review_stage.rb
index 294b656bc55..e92b1b22d44 100644
--- a/lib/gitlab/cycle_analytics/review_stage.rb
+++ b/lib/gitlab/cycle_analytics/review_stage.rb
@@ -16,7 +16,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Review')
+ s_("CycleAnalyticsStage|Review")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/stage_summary.rb b/lib/gitlab/cycle_analytics/stage_summary.rb
index 5198dd5b4eb..855a8d4ef8a 100644
--- a/lib/gitlab/cycle_analytics/stage_summary.rb
+++ b/lib/gitlab/cycle_analytics/stage_summary.rb
@@ -12,7 +12,7 @@ module Gitlab
def data
[serialize(Summary::Issue.new(project: @project, from: @from, current_user: @current_user)),
serialize(Summary::Commit.new(project: @project, from: @from)),
- serialize(Summary::Deploy.new(project: @project, from: @from))]
+ serialize(Summary::Deploy.new(project: @project, from: @from)),]
end
private
diff --git a/lib/gitlab/cycle_analytics/staging_event_fetcher.rb b/lib/gitlab/cycle_analytics/staging_event_fetcher.rb
index 70ce82383b3..606c56d471b 100644
--- a/lib/gitlab/cycle_analytics/staging_event_fetcher.rb
+++ b/lib/gitlab/cycle_analytics/staging_event_fetcher.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def fetch
- Updater.update!(event_result, from: 'id', to: 'build', klass: ::Ci::Build)
+ Updater.update!(event_result, from: "id", to: "build", klass: ::Ci::Build)
super
end
@@ -29,7 +29,7 @@ module Gitlab
end
def serialize(event)
- AnalyticsBuildSerializer.new.represent(event['build'])
+ AnalyticsBuildSerializer.new.represent(event["build"])
end
end
end
diff --git a/lib/gitlab/cycle_analytics/staging_stage.rb b/lib/gitlab/cycle_analytics/staging_stage.rb
index dbc2414ff66..448375cfed1 100644
--- a/lib/gitlab/cycle_analytics/staging_stage.rb
+++ b/lib/gitlab/cycle_analytics/staging_stage.rb
@@ -17,7 +17,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Staging')
+ s_("CycleAnalyticsStage|Staging")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/summary/base.rb b/lib/gitlab/cycle_analytics/summary/base.rb
index 709221c648e..9ff8bccfa81 100644
--- a/lib/gitlab/cycle_analytics/summary/base.rb
+++ b/lib/gitlab/cycle_analytics/summary/base.rb
@@ -10,11 +10,11 @@ module Gitlab
end
def title
- raise NotImplementedError.new("Expected #{self.name} to implement title")
+ raise NotImplementedError.new("Expected #{name} to implement title")
end
def value
- raise NotImplementedError.new("Expected #{self.name} to implement value")
+ raise NotImplementedError.new("Expected #{name} to implement value")
end
end
end
diff --git a/lib/gitlab/cycle_analytics/summary/commit.rb b/lib/gitlab/cycle_analytics/summary/commit.rb
index f0019b26fa2..d74f75d7d9b 100644
--- a/lib/gitlab/cycle_analytics/summary/commit.rb
+++ b/lib/gitlab/cycle_analytics/summary/commit.rb
@@ -5,7 +5,7 @@ module Gitlab
module Summary
class Commit < Base
def title
- n_('Commit', 'Commits', value)
+ n_("Commit", "Commits", value)
end
def value
diff --git a/lib/gitlab/cycle_analytics/summary/deploy.rb b/lib/gitlab/cycle_analytics/summary/deploy.rb
index 3b56dc2a7bc..1b277545e0e 100644
--- a/lib/gitlab/cycle_analytics/summary/deploy.rb
+++ b/lib/gitlab/cycle_analytics/summary/deploy.rb
@@ -5,7 +5,7 @@ module Gitlab
module Summary
class Deploy < Base
def title
- n_('Deploy', 'Deploys', value)
+ n_("Deploy", "Deploys", value)
end
def value
diff --git a/lib/gitlab/cycle_analytics/summary/issue.rb b/lib/gitlab/cycle_analytics/summary/issue.rb
index 51695c86192..c7bfa55ad7f 100644
--- a/lib/gitlab/cycle_analytics/summary/issue.rb
+++ b/lib/gitlab/cycle_analytics/summary/issue.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def title
- n_('New Issue', 'New Issues', value)
+ n_("New Issue", "New Issues", value)
end
def value
diff --git a/lib/gitlab/cycle_analytics/test_stage.rb b/lib/gitlab/cycle_analytics/test_stage.rb
index c31b664148b..52eae88ae34 100644
--- a/lib/gitlab/cycle_analytics/test_stage.rb
+++ b/lib/gitlab/cycle_analytics/test_stage.rb
@@ -16,7 +16,7 @@ module Gitlab
end
def title
- s_('CycleAnalyticsStage|Test')
+ s_("CycleAnalyticsStage|Test")
end
def legend
diff --git a/lib/gitlab/cycle_analytics/updater.rb b/lib/gitlab/cycle_analytics/updater.rb
index c642809a792..68df5a4ea06 100644
--- a/lib/gitlab/cycle_analytics/updater.rb
+++ b/lib/gitlab/cycle_analytics/updater.rb
@@ -25,7 +25,7 @@ module Gitlab
end
def items
- @items ||= @klass.find(result_ids).group_by { |item| item['id'] }
+ @items ||= @klass.find(result_ids).group_by { |item| item["id"] }
end
end
end
diff --git a/lib/gitlab/cycle_analytics/usage_data.rb b/lib/gitlab/cycle_analytics/usage_data.rb
index 913ee373f54..dd6c20539f8 100644
--- a/lib/gitlab/cycle_analytics/usage_data.rb
+++ b/lib/gitlab/cycle_analytics/usage_data.rb
@@ -9,23 +9,23 @@ module Gitlab
def initialize
@projects = Project.sorted_by_activity.limit(PROJECTS_LIMIT)
- @options = { from: 7.days.ago }
+ @options = {from: 7.days.ago}
end
def to_json
total = 0
values =
- medians_per_stage.each_with_object({}) do |(stage_name, medians), hsh|
+ medians_per_stage.each_with_object({}) { |(stage_name, medians), hsh|
calculations = stage_values(medians)
total += calculations.values.compact.sum
hsh[stage_name] = calculations
- end
+ }
values[:total] = total
- { avg_cycle_analytics: values }
+ {avg_cycle_analytics: values}
end
private
@@ -46,7 +46,7 @@ module Gitlab
{
average: average,
sd: standard_deviation(medians, average),
- missing: projects.length - medians.length
+ missing: projects.length - medians.length,
}
end
@@ -63,9 +63,9 @@ module Gitlab
def sample_variance(values, average)
return 0 if values.length <= 1
- sum = values.inject(0) do |acc, val|
+ sum = values.inject(0) { |acc, val|
acc + (val - average)**2
- end
+ }
sum / (values.length - 1)
end
diff --git a/lib/gitlab/danger/helper.rb b/lib/gitlab/danger/helper.rb
index d2b7ca015d4..b1e7b781738 100644
--- a/lib/gitlab/danger/helper.rb
+++ b/lib/gitlab/danger/helper.rb
@@ -1,13 +1,14 @@
# frozen_string_literal: true
-require 'net/http'
-require 'json'
-require_relative 'teammate'
+require "net/http"
+require "json"
+
+require_relative "teammate"
module Gitlab
module Danger
module Helper
- ROULETTE_DATA_URL = URI.parse('https://about.gitlab.com/roulette.json').freeze
+ ROULETTE_DATA_URL = URI.parse("https://about.gitlab.com/roulette.json").freeze
# Returns a list of all files that have been added, modified or renamed.
# `git.modified_files` might contain paths that already have been renamed,
@@ -37,11 +38,11 @@ module Gitlab
end
def ee?
- ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('../../CHANGELOG-EE.md')
+ ENV["CI_PROJECT_NAME"] == "gitlab-ee" || File.exist?("../../CHANGELOG-EE.md")
end
def project_name
- ee? ? 'gitlab-ee' : 'gitlab-ce'
+ ee? ? "gitlab-ee" : "gitlab-ce"
end
# Looks up the current list of GitLab team members and parses it into a
@@ -96,7 +97,7 @@ module Gitlab
CATEGORY_LABELS = {
docs: "~Documentation",
none: "",
- qa: "~QA"
+ qa: "~QA",
}.freeze
# rubocop:disable Style/RegexpLiteral
@@ -128,7 +129,7 @@ module Gitlab
# Fallbacks in case the above patterns miss anything
%r{\.rb\z} => :backend,
%r{\.(md|txt)\z} => :docs,
- %r{\.js\z} => :frontend
+ %r{\.js\z} => :frontend,
}.freeze
# rubocop:enable Style/RegexpLiteral
end
diff --git a/lib/gitlab/danger/teammate.rb b/lib/gitlab/danger/teammate.rb
index 4b822aa86c5..cc9cba4ad98 100644
--- a/lib/gitlab/danger/teammate.rb
+++ b/lib/gitlab/danger/teammate.rb
@@ -6,9 +6,9 @@ module Gitlab
attr_reader :name, :username, :projects
def initialize(options = {})
- @name = options['name']
- @username = options['username']
- @projects = options['projects']
+ @name = options["name"]
+ @username = options["username"]
+ @projects = options["projects"]
end
def markdown_name
@@ -16,7 +16,7 @@ module Gitlab
end
def in_project?(name)
- projects&.has_key?(name)
+ projects&.key?(name)
end
# Traintainers also count as reviewers
@@ -35,7 +35,7 @@ module Gitlab
private
def capabilities(project)
- projects.fetch(project, '')
+ projects.fetch(project, "")
end
end
end
diff --git a/lib/gitlab/data_builder/build.rb b/lib/gitlab/data_builder/build.rb
index 3407380127e..4fc7c92bf71 100644
--- a/lib/gitlab/data_builder/build.rb
+++ b/lib/gitlab/data_builder/build.rb
@@ -13,7 +13,7 @@ module Gitlab
author_url = build_author_url(build.commit, commit)
data = {
- object_kind: 'build',
+ object_kind: "build",
ref: build.ref,
tag: build.tag,
@@ -39,7 +39,7 @@ module Gitlab
user: {
id: user.try(:id),
name: user.try(:name),
- email: user.try(:email)
+ email: user.try(:email),
},
commit: {
@@ -52,7 +52,7 @@ module Gitlab
status: commit.status,
duration: commit.duration,
started_at: commit.started_at,
- finished_at: commit.finished_at
+ finished_at: commit.finished_at,
},
repository: {
@@ -62,8 +62,8 @@ module Gitlab
homepage: project.web_url,
git_http_url: project.http_url_to_repo,
git_ssh_url: project.ssh_url_to_repo,
- visibility_level: project.visibility_level
- }
+ visibility_level: project.visibility_level,
+ },
}
data
diff --git a/lib/gitlab/data_builder/note.rb b/lib/gitlab/data_builder/note.rb
index 65601dcdf31..4134eac500e 100644
--- a/lib/gitlab/data_builder/note.rb
+++ b/lib/gitlab/data_builder/note.rb
@@ -54,7 +54,7 @@ module Gitlab
end
def build_base_data(project, user, note)
- event_type = note.confidential? ? 'confidential_note' : 'note'
+ event_type = note.confidential? ? "confidential_note" : "note"
base_data = {
object_kind: "note",
@@ -64,7 +64,7 @@ module Gitlab
project: project.hook_attrs,
object_attributes: note.hook_attrs,
# DEPRECATED
- repository: project.hook_attrs.slice(:name, :url, :description, :homepage)
+ repository: project.hook_attrs.slice(:name, :url, :description, :homepage),
}
base_data[:object_attributes][:url] = Gitlab::UrlBuilder.build(note)
diff --git a/lib/gitlab/data_builder/pipeline.rb b/lib/gitlab/data_builder/pipeline.rb
index 76c8b4ec5c2..7167edfd9d1 100644
--- a/lib/gitlab/data_builder/pipeline.rb
+++ b/lib/gitlab/data_builder/pipeline.rb
@@ -7,12 +7,12 @@ module Gitlab
def build(pipeline)
{
- object_kind: 'pipeline',
+ object_kind: "pipeline",
object_attributes: hook_attrs(pipeline),
user: pipeline.user.try(:hook_attrs),
project: pipeline.project.hook_attrs(backward: false),
commit: pipeline.commit.try(:hook_attrs),
- builds: pipeline.builds.map(&method(:build_hook_attrs))
+ builds: pipeline.builds.map(&method(:build_hook_attrs)),
}
end
@@ -29,7 +29,7 @@ module Gitlab
created_at: pipeline.created_at,
finished_at: pipeline.finished_at,
duration: pipeline.duration,
- variables: pipeline.variables.map(&:hook_attrs)
+ variables: pipeline.variables.map(&:hook_attrs),
}
end
@@ -48,8 +48,8 @@ module Gitlab
runner: build.runner && runner_hook_attrs(build.runner),
artifacts_file: {
filename: build.artifacts_file.filename,
- size: build.artifacts_size
- }
+ size: build.artifacts_size,
+ },
}
end
@@ -58,7 +58,7 @@ module Gitlab
id: runner.id,
description: runner.description,
active: runner.active?,
- is_shared: runner.instance_type?
+ is_shared: runner.instance_type?,
}
end
end
diff --git a/lib/gitlab/data_builder/push.rb b/lib/gitlab/data_builder/push.rb
index ea08b5f7eae..1b7d783c945 100644
--- a/lib/gitlab/data_builder/push.rb
+++ b/lib/gitlab/data_builder/push.rb
@@ -27,15 +27,15 @@ module Gitlab
url: "https://test.example.com/gitlab/gitlabhq/commit/c5feabde2d8cd023215af4d2ceeb7a64839fc428",
author: {
name: "Test User",
- email: "test@example.com"
- }
- }
+ email: "test@example.com",
+ },
+ },
],
total_commits_count: 1,
push_options: [
"ci.skip",
- "custom option"
- ]
+ "custom option",
+ ],
}.freeze
# Produce a hash of post-receive data
@@ -73,13 +73,13 @@ module Gitlab
# For performance purposes maximum 20 latest commits
# will be passed as post receive hook data.
# n+1: https://gitlab.com/gitlab-org/gitlab-ce/issues/38259
- commit_attrs = Gitlab::GitalyClient.allow_n_plus_1_calls do
+ commit_attrs = Gitlab::GitalyClient.allow_n_plus_1_calls {
commits_limited.map do |commit|
commit.hook_attrs(with_changed_files: true)
end
- end
+ }
- type = Gitlab::Git.tag_ref?(ref) ? 'tag_push' : 'push'
+ type = Gitlab::Git.tag_ref?(ref) ? "tag_push" : "push"
# Hash to be passed as post_receive_data
{
@@ -102,7 +102,7 @@ module Gitlab
push_options: push_options,
# DEPRECATED
repository: project.hook_attrs.slice(:name, :url, :description, :homepage,
- :git_http_url, :git_ssh_url, :visibility_level)
+ :git_http_url, :git_ssh_url, :visibility_level),
}
end
diff --git a/lib/gitlab/data_builder/repository.rb b/lib/gitlab/data_builder/repository.rb
index 0e627fd623e..0823b12ef0d 100644
--- a/lib/gitlab/data_builder/repository.rb
+++ b/lib/gitlab/data_builder/repository.rb
@@ -6,26 +6,26 @@ module Gitlab
extend self
SAMPLE_DATA = {
- event_name: 'repository_update',
+ event_name: "repository_update",
user_id: 10,
- user_name: 'john.doe',
- user_email: 'test@example.com',
- user_avatar: 'http://example.com/avatar/user.png',
+ user_name: "john.doe",
+ user_email: "test@example.com",
+ user_avatar: "http://example.com/avatar/user.png",
project_id: 40,
changes: [
{
before: "8205ea8d81ce0c6b90fbe8280d118cc9fdad6130",
after: "4045ea7a3df38697b3730a20fb73c8bed8a3e69e",
- ref: "refs/heads/master"
- }
+ ref: "refs/heads/master",
+ },
],
- "refs": ["refs/heads/master"]
+ "refs": ["refs/heads/master"],
}.freeze
# Produce a hash of post-receive data
def update(project, user, changes, refs)
{
- event_name: 'repository_update',
+ event_name: "repository_update",
user_id: user.id,
user_name: user.name,
@@ -37,7 +37,7 @@ module Gitlab
changes: changes,
- refs: refs
+ refs: refs,
}
end
@@ -46,7 +46,7 @@ module Gitlab
{
before: oldrev,
after: newrev,
- ref: ref
+ ref: ref,
}
end
diff --git a/lib/gitlab/data_builder/wiki_page.rb b/lib/gitlab/data_builder/wiki_page.rb
index 9368446fa59..4ae9236665e 100644
--- a/lib/gitlab/data_builder/wiki_page.rb
+++ b/lib/gitlab/data_builder/wiki_page.rb
@@ -16,7 +16,7 @@ module Gitlab
object_attributes: wiki_page.hook_attrs.merge(
url: Gitlab::UrlBuilder.build(wiki_page),
action: action
- )
+ ),
}
end
end
diff --git a/lib/gitlab/database.rb b/lib/gitlab/database.rb
index b6ca777e029..05c97c54a95 100644
--- a/lib/gitlab/database.rb
+++ b/lib/gitlab/database.rb
@@ -16,23 +16,23 @@ module Gitlab
end
def self.username
- config['username'] || ENV['USER']
+ config["username"] || ENV["USER"]
end
def self.database_name
- config['database']
+ config["database"]
end
def self.adapter_name
- config['adapter']
+ config["adapter"]
end
def self.mysql?
- adapter_name.casecmp('mysql2').zero?
+ adapter_name.casecmp("mysql2").zero?
end
def self.postgresql?
- adapter_name.casecmp('postgresql').zero?
+ adapter_name.casecmp("postgresql").zero?
end
def self.read_only?
@@ -40,15 +40,15 @@ module Gitlab
end
def self.read_write?
- !self.read_only?
+ !read_only?
end
# Check whether the underlying database is in read-only mode
def self.db_read_only?
if postgresql?
pg_is_in_recovery =
- ActiveRecord::Base.connection.execute('SELECT pg_is_in_recovery()')
- .first.fetch('pg_is_in_recovery')
+ ActiveRecord::Base.connection.execute("SELECT pg_is_in_recovery()")
+ .first.fetch("pg_is_in_recovery")
Gitlab::Utils.to_boolean(pg_is_in_recovery)
else
@@ -57,7 +57,7 @@ module Gitlab
end
def self.db_read_write?
- !self.db_read_only?
+ !db_read_only?
end
def self.version
@@ -83,22 +83,22 @@ module Gitlab
# map some of the function names that changed between PostgreSQL 9 and 10
# https://wiki.postgresql.org/wiki/New_in_postgres_10
def self.pg_wal_lsn_diff
- Gitlab::Database.postgresql_9_or_less? ? 'pg_xlog_location_diff' : 'pg_wal_lsn_diff'
+ Gitlab::Database.postgresql_9_or_less? ? "pg_xlog_location_diff" : "pg_wal_lsn_diff"
end
def self.pg_current_wal_insert_lsn
- Gitlab::Database.postgresql_9_or_less? ? 'pg_current_xlog_insert_location' : 'pg_current_wal_insert_lsn'
+ Gitlab::Database.postgresql_9_or_less? ? "pg_current_xlog_insert_location" : "pg_current_wal_insert_lsn"
end
def self.pg_last_wal_receive_lsn
- Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_receive_location' : 'pg_last_wal_receive_lsn'
+ Gitlab::Database.postgresql_9_or_less? ? "pg_last_xlog_receive_location" : "pg_last_wal_receive_lsn"
end
def self.pg_last_wal_replay_lsn
- Gitlab::Database.postgresql_9_or_less? ? 'pg_last_xlog_replay_location' : 'pg_last_wal_replay_lsn'
+ Gitlab::Database.postgresql_9_or_less? ? "pg_last_xlog_replay_location" : "pg_last_wal_replay_lsn"
end
- def self.nulls_last_order(field, direction = 'ASC')
+ def self.nulls_last_order(field, direction = "ASC")
order = "#{field} #{direction}"
if postgresql?
@@ -106,13 +106,13 @@ module Gitlab
else
# `field IS NULL` will be `0` for non-NULL columns and `1` for NULL
# columns. In the (default) ascending order, `0` comes first.
- order = "#{field} IS NULL, #{order}" if direction == 'ASC'
+ order = "#{field} IS NULL, #{order}" if direction == "ASC"
end
order
end
- def self.nulls_first_order(field, direction = 'ASC')
+ def self.nulls_first_order(field, direction = "ASC")
order = "#{field} #{direction}"
if postgresql?
@@ -120,7 +120,7 @@ module Gitlab
else
# `field IS NULL` will be `0` for non-NULL columns and `1` for NULL
# columns. In the (default) ascending order, `0` comes first.
- order = "#{field} IS NULL, #{order}" if direction == 'DESC'
+ order = "#{field} IS NULL, #{order}" if direction == "DESC"
end
order
@@ -175,15 +175,15 @@ module Gitlab
return_ids = false if mysql?
disable_quote = Array(disable_quote).to_set
- tuples = rows.map do |row|
+ tuples = rows.map { |row|
keys.map do |k|
disable_quote.include?(k) ? row[k] : connection.quote(row[k])
end
- end
+ }
sql = <<-EOF
- INSERT INTO #{table} (#{columns.join(', ')})
- VALUES #{tuples.map { |tuple| "(#{tuple.join(', ')})" }.join(', ')}
+ INSERT INTO #{table} (#{columns.join(", ")})
+ VALUES #{tuples.map { |tuple| "(#{tuple.join(", ")})" }.join(", ")}
EOF
if return_ids
@@ -210,8 +210,8 @@ module Gitlab
env = Rails.env
original_config = ActiveRecord::Base.configurations
- env_config = original_config[env].merge('pool' => pool_size)
- env_config['host'] = host if host
+ env_config = original_config[env].merge("pool" => pool_size)
+ env_config["host"] = host if host
config = original_config.merge(env => env_config)
@@ -228,7 +228,7 @@ module Gitlab
end
def self.cached_column_exists?(table_name, column_name)
- connection.schema_cache.columns_hash(table_name).has_key?(column_name.to_s)
+ connection.schema_cache.columns_hash(table_name).key?(column_name.to_s)
end
def self.cached_table_exists?(table_name)
@@ -241,7 +241,7 @@ module Gitlab
row = connection.execute("SELECT VERSION()").first
if postgresql?
- row['version']
+ row["version"]
else
row.first
end
@@ -250,13 +250,13 @@ module Gitlab
private_class_method :database_version
def self.add_post_migrate_path_to_rails(force: false)
- return if ENV['SKIP_POST_DEPLOYMENT_MIGRATIONS'] && !force
+ return if ENV["SKIP_POST_DEPLOYMENT_MIGRATIONS"] && !force
- Rails.application.config.paths['db'].each do |db_path|
- path = Rails.root.join(db_path, 'post_migrate').to_s
+ Rails.application.config.paths["db"].each do |db_path|
+ path = Rails.root.join(db_path, "post_migrate").to_s
- unless Rails.application.config.paths['db/migrate'].include? path
- Rails.application.config.paths['db/migrate'] << path
+ unless Rails.application.config.paths["db/migrate"].include? path
+ Rails.application.config.paths["db/migrate"] << path
# Rails memoizes migrations at certain points where it won't read the above
# path just yet. As such we must also update the following list of paths.
diff --git a/lib/gitlab/database/count.rb b/lib/gitlab/database/count.rb
index f3d37ccd72a..a4831aa677b 100644
--- a/lib/gitlab/database/count.rb
+++ b/lib/gitlab/database/count.rb
@@ -15,12 +15,12 @@ module Gitlab
[
ActionView::Template::Error,
ActiveRecord::StatementInvalid,
- PG::Error
+ PG::Error,
].freeze
else
[
ActionView::Template::Error,
- ActiveRecord::StatementInvalid
+ ActiveRecord::StatementInvalid,
].freeze
end
diff --git a/lib/gitlab/database/count/reltuples_count_strategy.rb b/lib/gitlab/database/count/reltuples_count_strategy.rb
index c3a674aeb7e..269d6e96428 100644
--- a/lib/gitlab/database/count/reltuples_count_strategy.rb
+++ b/lib/gitlab/database/count/reltuples_count_strategy.rb
@@ -4,7 +4,7 @@ module Gitlab
module Database
module Count
class PgClass < ActiveRecord::Base
- self.table_name = 'pg_class'
+ self.table_name = "pg_class"
end
# This strategy counts based on PostgreSQL's statistics in pg_stat_user_tables.
@@ -64,11 +64,11 @@ module Gitlab
query = PgClass.joins("LEFT JOIN pg_stat_user_tables USING (relname)")
.where(relname: table_names)
- .select('pg_class.relname AS table_name, reltuples::bigint AS estimate')
+ .select("pg_class.relname AS table_name, reltuples::bigint AS estimate")
if check_statistics
- query = query.where('last_vacuum > ? OR last_autovacuum > ? OR last_analyze > ? OR last_autoanalyze > ?',
- time, time, time, time)
+ query = query.where("last_vacuum > ? OR last_autovacuum > ? OR last_analyze > ? OR last_autoanalyze > ?",
+ time, time, time, time)
end
query
diff --git a/lib/gitlab/database/count/tablesample_count_strategy.rb b/lib/gitlab/database/count/tablesample_count_strategy.rb
index cf1cf054dbf..43272396650 100644
--- a/lib/gitlab/database/count/tablesample_count_strategy.rb
+++ b/lib/gitlab/database/count/tablesample_count_strategy.rb
@@ -58,7 +58,7 @@ module Gitlab
rows = ActiveRecord::Base.connection.select_all(query)
- Integer(rows.first['count'])
+ Integer(rows.first["count"])
end
end
end
diff --git a/lib/gitlab/database/date_time.rb b/lib/gitlab/database/date_time.rb
index 79d2caff151..b2d349fd2bf 100644
--- a/lib/gitlab/database/date_time.rb
+++ b/lib/gitlab/database/date_time.rb
@@ -19,13 +19,15 @@ module Gitlab
if Gitlab::Database.postgresql?
Arel::Nodes::Subtraction.new(
Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(end_time_attrs)),
- Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(start_time_attrs)))
+ Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(start_time_attrs))
+ )
elsif Gitlab::Database.mysql?
Arel::Nodes::NamedFunction.new(
"TIMESTAMPDIFF",
- [Arel.sql('second'),
+ [Arel.sql("second"),
Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(start_time_attrs)),
- Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(end_time_attrs))])
+ Arel::Nodes::NamedFunction.new("COALESCE", Array.wrap(end_time_attrs)),]
+ )
end
end
end
diff --git a/lib/gitlab/database/grant.rb b/lib/gitlab/database/grant.rb
index 862ab96c887..5915d6c5688 100644
--- a/lib/gitlab/database/grant.rb
+++ b/lib/gitlab/database/grant.rb
@@ -8,9 +8,9 @@ module Gitlab
self.table_name =
if Database.postgresql?
- 'information_schema.role_table_grants'
+ "information_schema.role_table_grants"
else
- 'information_schema.schema_privileges'
+ "information_schema.schema_privileges"
end
# Returns true if the current user can create and execute triggers on the
@@ -35,18 +35,18 @@ module Gitlab
else
queries = [
Grant.select(1)
- .from('information_schema.user_privileges')
+ .from("information_schema.user_privileges")
.where("PRIVILEGE_TYPE = 'SUPER'")
.where("GRANTEE = CONCAT('\\'', REPLACE(CURRENT_USER(), '@', '\\'@\\''), '\\'')"),
Grant.select(1)
- .from('information_schema.schema_privileges')
+ .from("information_schema.schema_privileges")
.where("PRIVILEGE_TYPE = 'TRIGGER'")
- .where('TABLE_SCHEMA = ?', Gitlab::Database.database_name)
- .where("GRANTEE = CONCAT('\\'', REPLACE(CURRENT_USER(), '@', '\\'@\\''), '\\'')")
+ .where("TABLE_SCHEMA = ?", Gitlab::Database.database_name)
+ .where("GRANTEE = CONCAT('\\'', REPLACE(CURRENT_USER(), '@', '\\'@\\''), '\\'')"),
]
- Grant.from_union(queries, alias_as: 'privs').any?
+ Grant.from_union(queries, alias_as: "privs").any?
end
end
end
diff --git a/lib/gitlab/database/median.rb b/lib/gitlab/database/median.rb
index 1455e410d4b..09ec6a0709e 100644
--- a/lib/gitlab/database/median.rb
+++ b/lib/gitlab/database/median.rb
@@ -20,7 +20,7 @@ module Gitlab
if Gitlab::Database.postgresql?
result = result.first.presence
- result['median']&.to_f if result
+ result["median"]&.to_f if result
elsif Gitlab::Database.mysql?
result.to_a.flatten.first
end
@@ -36,26 +36,26 @@ module Gitlab
def mysql_median_datetime_sql(arel_table, query_so_far, column_sym)
query = arel_table.from
- .from(arel_table.project(Arel.sql('*')).order(arel_table[column_sym]).as(arel_table.table_name))
- .project(average([arel_table[column_sym]], 'median'))
- .where(
- Arel::Nodes::Between.new(
- Arel.sql("(select @row_id := @row_id + 1)"),
- Arel::Nodes::And.new(
- [Arel.sql('@ct/2.0'),
- Arel.sql('@ct/2.0 + 1')]
- )
- )
- ).
- # Disallow negative values
- where(arel_table[column_sym].gteq(0))
+ .from(arel_table.project(Arel.sql("*")).order(arel_table[column_sym]).as(arel_table.table_name))
+ .project(average([arel_table[column_sym]], "median"))
+ .where(
+ Arel::Nodes::Between.new(
+ Arel.sql("(select @row_id := @row_id + 1)"),
+ Arel::Nodes::And.new(
+ [Arel.sql("@ct/2.0"),
+ Arel.sql("@ct/2.0 + 1"),]
+ )
+ )
+ ).
+ # Disallow negative values
+ where(arel_table[column_sym].gteq(0))
[
Arel.sql("CREATE TEMPORARY TABLE IF NOT EXISTS #{query_so_far.to_sql}"),
Arel.sql("set @ct := (select count(1) from #{arel_table.table_name});"),
Arel.sql("set @row_id := 0;"),
query.to_sql,
- Arel.sql("DROP TEMPORARY TABLE IF EXISTS #{arel_table.table_name};")
+ Arel.sql("DROP TEMPORARY TABLE IF EXISTS #{arel_table.table_name};"),
]
end
@@ -87,7 +87,8 @@ module Gitlab
cte_table,
arel_table.project(*rank_rows(arel_table, column_sym, partition_column)).
# Disallow negative values
- where(arel_table[column_sym].gteq(zero_interval)))
+ where(arel_table[column_sym].gteq(zero_interval))
+ )
# From the CTE, select either the middle row or the middle two rows (this is accomplished
# by 'where cte.row_id between cte.ct / 2.0 AND cte.ct / 2.0 + 1'). Find the average of the
@@ -99,8 +100,8 @@ module Gitlab
Arel::Nodes::Between.new(
cte_table[:row_id],
Arel::Nodes::And.new(
- [(cte_table[:ct] / Arel.sql('2.0')),
- (cte_table[:ct] / Arel.sql('2.0') + 1)]
+ [(cte_table[:ct] / Arel.sql("2.0")),
+ (cte_table[:ct] / Arel.sql("2.0") + 1),]
)
)
)
@@ -140,25 +141,25 @@ module Gitlab
partition_row = arel_table[partition_column]
row_id =
Arel::Nodes::Over.new(
- Arel::Nodes::NamedFunction.new('rank', []),
+ Arel::Nodes::NamedFunction.new("rank", []),
Arel::Nodes::Window.new.partition(arel_table[partition_column])
.order(arel_table[column_sym])
- ).as('row_id')
+ ).as("row_id")
count = arel_table.from.from(arel_table.alias)
- .project('COUNT(*)')
- .where(arel_table[partition_column].eq(arel_table.alias[partition_column]))
- .as('ct')
+ .project("COUNT(*)")
+ .where(arel_table[partition_column].eq(arel_table.alias[partition_column]))
+ .as("ct")
[partition_row, column_row, row_id, count]
else
row_id =
Arel::Nodes::Over.new(
- Arel::Nodes::NamedFunction.new('row_number', []),
+ Arel::Nodes::NamedFunction.new("row_number", []),
Arel::Nodes::Window.new.order(arel_table[column_sym])
- ).as('row_id')
+ ).as("row_id")
- count = arel_table.project("COUNT(1)").as('ct')
+ count = arel_table.project("COUNT(1)").as("ct")
[column_row, row_id, count]
end
@@ -172,13 +173,13 @@ module Gitlab
end
def extract_epoch(arel_attribute)
- Arel.sql(%Q{EXTRACT(EPOCH FROM "#{arel_attribute.relation.name}"."#{arel_attribute.name}")})
+ Arel.sql(%{EXTRACT(EPOCH FROM "#{arel_attribute.relation.name}"."#{arel_attribute.name}")})
end
def extract_diff_epoch(diff)
return diff unless Gitlab::Database.postgresql?
- Arel.sql(%Q{EXTRACT(EPOCH FROM (#{diff.to_sql}))})
+ Arel.sql(%{EXTRACT(EPOCH FROM (#{diff.to_sql}))})
end
# Need to cast '0' to an INTERVAL before we can check if the interval is positive
diff --git a/lib/gitlab/database/migration_helpers.rb b/lib/gitlab/database/migration_helpers.rb
index 3abd0600e9d..e8432c7fba0 100644
--- a/lib/gitlab/database/migration_helpers.rb
+++ b/lib/gitlab/database/migration_helpers.rb
@@ -19,9 +19,9 @@ module Gitlab
[:created_at, :updated_at].each do |column_name|
if options[:default] && transaction_open?
- raise '`add_timestamps_with_timezone` with default value cannot be run inside a transaction. ' \
- 'You can disable transactions by calling `disable_ddl_transaction!` ' \
- 'in the body of your migration class'
+ raise "`add_timestamps_with_timezone` with default value cannot be run inside a transaction. " \
+ "You can disable transactions by calling `disable_ddl_transaction!` " \
+ "in the body of your migration class"
end
# If default value is presented, use `add_column_with_default` method instead.
@@ -51,13 +51,13 @@ module Gitlab
# See Rails' `add_index` for more info on the available arguments.
def add_concurrent_index(table_name, column_name, options = {})
if transaction_open?
- raise 'add_concurrent_index can not be run inside a transaction, ' \
- 'you can disable transactions by calling disable_ddl_transaction! ' \
- 'in the body of your migration class'
+ raise "add_concurrent_index can not be run inside a transaction, " \
+ "you can disable transactions by calling disable_ddl_transaction! " \
+ "in the body of your migration class"
end
if Database.postgresql?
- options = options.merge({ algorithm: :concurrently })
+ options = options.merge({algorithm: :concurrently})
end
if index_exists?(table_name, column_name, options)
@@ -81,13 +81,13 @@ module Gitlab
# See Rails' `remove_index` for more info on the available arguments.
def remove_concurrent_index(table_name, column_name, options = {})
if transaction_open?
- raise 'remove_concurrent_index can not be run inside a transaction, ' \
- 'you can disable transactions by calling disable_ddl_transaction! ' \
- 'in the body of your migration class'
+ raise "remove_concurrent_index can not be run inside a transaction, " \
+ "you can disable transactions by calling disable_ddl_transaction! " \
+ "in the body of your migration class"
end
if supports_drop_index_concurrently?
- options = options.merge({ algorithm: :concurrently })
+ options = options.merge({algorithm: :concurrently})
end
unless index_exists?(table_name, column_name, options)
@@ -96,7 +96,7 @@ module Gitlab
end
disable_statement_timeout do
- remove_index(table_name, options.merge({ column: column_name }))
+ remove_index(table_name, options.merge({column: column_name}))
end
end
@@ -111,13 +111,13 @@ module Gitlab
# See Rails' `remove_index` for more info on the available arguments.
def remove_concurrent_index_by_name(table_name, index_name, options = {})
if transaction_open?
- raise 'remove_concurrent_index_by_name can not be run inside a transaction, ' \
- 'you can disable transactions by calling disable_ddl_transaction! ' \
- 'in the body of your migration class'
+ raise "remove_concurrent_index_by_name can not be run inside a transaction, " \
+ "you can disable transactions by calling disable_ddl_transaction! " \
+ "in the body of your migration class"
end
if supports_drop_index_concurrently?
- options = options.merge({ algorithm: :concurrently })
+ options = options.merge({algorithm: :concurrently})
end
unless index_exists_by_name?(table_name, index_name)
@@ -126,7 +126,7 @@ module Gitlab
end
disable_statement_timeout do
- remove_index(table_name, options.merge({ name: index_name }))
+ remove_index(table_name, options.merge({name: index_name}))
end
end
@@ -134,7 +134,7 @@ module Gitlab
def supports_drop_index_concurrently?
return false unless Database.postgresql?
- version = select_one("SELECT current_setting('server_version_num') AS v")['v'].to_i
+ version = select_one("SELECT current_setting('server_version_num') AS v")["v"].to_i
version >= 90200
end
@@ -153,7 +153,7 @@ module Gitlab
# Transactions would result in ALTER TABLE locks being held for the
# duration of the transaction, defeating the purpose of this method.
if transaction_open?
- raise 'add_concurrent_foreign_key can not be run inside a transaction'
+ raise "add_concurrent_foreign_key can not be run inside a transaction"
end
# While MySQL does allow disabling of foreign keys it has no equivalent
@@ -168,10 +168,10 @@ module Gitlab
end
return add_foreign_key(source, target,
- column: column,
- on_delete: on_delete)
+ column: column,
+ on_delete: on_delete)
else
- on_delete = 'SET NULL' if on_delete == :nullify
+ on_delete = "SET NULL" if on_delete == :nullify
end
key_name = concurrent_foreign_key_name(source, column)
@@ -190,7 +190,7 @@ module Gitlab
ADD CONSTRAINT #{key_name}
FOREIGN KEY (#{column})
REFERENCES #{target} (id)
- #{on_delete ? "ON DELETE #{on_delete.upcase}" : ''}
+ #{on_delete ? "ON DELETE #{on_delete.upcase}" : ""}
NOT VALID;
EOF
end
@@ -249,11 +249,11 @@ module Gitlab
if block_given?
begin
- execute('SET statement_timeout TO 0')
+ execute("SET statement_timeout TO 0")
yield
ensure
- execute('RESET ALL')
+ execute("RESET ALL")
end
else
unless transaction_open?
@@ -267,7 +267,7 @@ module Gitlab
ERROR
end
- execute('SET LOCAL statement_timeout TO 0')
+ execute("SET LOCAL statement_timeout TO 0")
end
end
@@ -322,17 +322,17 @@ module Gitlab
# rubocop: disable Metrics/AbcSize
def update_column_in_batches(table, column, value)
if transaction_open?
- raise 'update_column_in_batches can not be run inside a transaction, ' \
- 'you can disable transactions by calling disable_ddl_transaction! ' \
- 'in the body of your migration class'
+ raise "update_column_in_batches can not be run inside a transaction, " \
+ "you can disable transactions by calling disable_ddl_transaction! " \
+ "in the body of your migration class"
end
table = Arel::Table.new(table)
- count_arel = table.project(Arel.star.count.as('count'))
+ count_arel = table.project(Arel.star.count.as("count"))
count_arel = yield table, count_arel if block_given?
- total = exec_query(count_arel.to_sql).to_hash.first['count'].to_i
+ total = exec_query(count_arel.to_sql).to_hash.first["count"].to_i
return if total == 0
@@ -347,7 +347,7 @@ module Gitlab
start_arel = table.project(table[:id]).order(table[:id].asc).take(1)
start_arel = yield table, start_arel if block_given?
- start_id = exec_query(start_arel.to_sql).to_hash.first['id'].to_i
+ start_id = exec_query(start_arel.to_sql).to_hash.first["id"].to_i
loop do
stop_arel = table.project(table[:id])
@@ -365,7 +365,7 @@ module Gitlab
.where(table[:id].gteq(start_id))
if stop_row
- stop_id = stop_row['id'].to_i
+ stop_id = stop_row["id"].to_i
start_id = stop_id
update_arel = update_arel.where(table[:id].lt(stop_id))
end
@@ -405,9 +405,9 @@ module Gitlab
# `update_column_in_batches` method.
def add_column_with_default(table, column, type, default:, limit: nil, allow_null: false, &block)
if transaction_open?
- raise 'add_column_with_default can not be run inside a transaction, ' \
- 'you can disable transactions by calling disable_ddl_transaction! ' \
- 'in the body of your migration class'
+ raise "add_column_with_default can not be run inside a transaction, " \
+ "you can disable transactions by calling disable_ddl_transaction! " \
+ "in the body of your migration class"
end
disable_statement_timeout do
@@ -452,7 +452,7 @@ module Gitlab
# type is used.
def rename_column_concurrently(table, old, new, type: nil)
if transaction_open?
- raise 'rename_column_concurrently can not be run inside a transaction'
+ raise "rename_column_concurrently can not be run inside a transaction"
end
check_trigger_permissions!(table)
@@ -461,9 +461,9 @@ module Gitlab
new_type = type || old_col.type
add_column(table, new, new_type,
- limit: old_col.limit,
- precision: old_col.precision,
- scale: old_col.scale)
+ limit: old_col.limit,
+ precision: old_col.precision,
+ scale: old_col.scale)
# We set the default value _after_ adding the column so we don't end up
# updating any existing data with the default value. This isn't
@@ -494,10 +494,10 @@ module Gitlab
if Database.postgresql?
install_rename_triggers_for_postgresql(trigger_name, quoted_table,
- quoted_old, quoted_new)
+ quoted_old, quoted_new)
else
install_rename_triggers_for_mysql(trigger_name, quoted_table,
- quoted_old, quoted_new)
+ quoted_old, quoted_new)
end
end
@@ -599,7 +599,7 @@ module Gitlab
)
unless relation.model < EachBatch
- raise TypeError, 'The relation must include the EachBatch module'
+ raise TypeError, "The relation must include the EachBatch module"
end
temp_column = "#{column}_for_type_change"
@@ -613,12 +613,12 @@ module Gitlab
# new one. Rows with NULL values in our source column are skipped since
# the target column is already NULL at this point.
relation.where.not(column => nil).each_batch(of: batch_size) do |batch, index|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
max_index = index
BackgroundMigrationWorker.perform_in(
index * interval,
- 'CopyColumn',
+ "CopyColumn",
[table, column, temp_column, start_id, end_id]
)
end
@@ -627,15 +627,15 @@ module Gitlab
# the last batch finished.
BackgroundMigrationWorker.perform_in(
(max_index * interval) + 1.hour,
- 'CleanupConcurrentTypeChange',
+ "CleanupConcurrentTypeChange",
[table, column, temp_column]
)
if perform_background_migration_inline?
# To ensure the schema is up to date immediately we perform the
# migration inline in dev / test environments.
- Gitlab::BackgroundMigration.steal('CopyColumn')
- Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange')
+ Gitlab::BackgroundMigration.steal("CopyColumn")
+ Gitlab::BackgroundMigration.steal("CleanupConcurrentTypeChange")
end
end
@@ -683,9 +683,9 @@ module Gitlab
max_index = 0
add_column(table, new_column, new_type,
- limit: old_col.limit,
- precision: old_col.precision,
- scale: old_col.scale)
+ limit: old_col.limit,
+ precision: old_col.precision,
+ scale: old_col.scale)
# We set the default value _after_ adding the column so we don't end up
# updating any existing data with the default value. This isn't
@@ -694,22 +694,22 @@ module Gitlab
install_rename_triggers(table, old_column, new_column)
- model = Class.new(ActiveRecord::Base) do
+ model = Class.new(ActiveRecord::Base) {
self.table_name = table
include ::EachBatch
- end
+ }
# Schedule the jobs that will copy the data from the old column to the
# new one. Rows with NULL values in our source column are skipped since
# the target column is already NULL at this point.
model.where.not(old_column => nil).each_batch(of: batch_size) do |batch, index|
- start_id, end_id = batch.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = batch.pluck("MIN(id), MAX(id)").first
max_index = index
BackgroundMigrationWorker.perform_in(
index * interval,
- 'CopyColumn',
+ "CopyColumn",
[table, old_column, new_column, start_id, end_id]
)
end
@@ -718,15 +718,15 @@ module Gitlab
# the last batch finished.
BackgroundMigrationWorker.perform_in(
(max_index * interval) + 1.hour,
- 'CleanupConcurrentRename',
+ "CleanupConcurrentRename",
[table, old_column, new_column]
)
if perform_background_migration_inline?
# To ensure the schema is up to date immediately we perform the
# migration inline in dev / test environments.
- Gitlab::BackgroundMigration.steal('CopyColumn')
- Gitlab::BackgroundMigration.steal('CleanupConcurrentRename')
+ Gitlab::BackgroundMigration.steal("CopyColumn")
+ Gitlab::BackgroundMigration.steal("CleanupConcurrentRename")
end
end
@@ -792,7 +792,7 @@ module Gitlab
# Returns the (base) name to use for triggers when renaming columns.
def rename_trigger_name(table, old, new)
- 'trigger_' + Digest::SHA256.hexdigest("#{table}_#{old}_#{new}").first(12)
+ "trigger_" + Digest::SHA256.hexdigest("#{table}_#{old}_#{new}").first(12)
end
# Returns an Array containing the indexes for the given column
@@ -819,9 +819,9 @@ module Gitlab
new = new.to_s
indexes_for(table, old).each do |index|
- new_columns = index.columns.map do |column|
+ new_columns = index.columns.map { |column|
column == old ? new : column
- end
+ }
# This is necessary as we can't properly rename indexes such as
# "ci_taggings_idx".
@@ -836,7 +836,7 @@ module Gitlab
unique: index.unique,
name: name,
length: index.lengths,
- order: index.orders
+ order: index.orders,
}
# These options are not supported by MySQL, so we only add them if
@@ -866,9 +866,9 @@ module Gitlab
def copy_foreign_keys(table, old, new)
foreign_keys_for(table, old).each do |fk|
add_concurrent_foreign_key(fk.from_table,
- fk.to_table,
- column: new,
- on_delete: fk.on_delete)
+ fk.to_table,
+ column: new,
+ on_delete: fk.on_delete)
end
end
@@ -890,9 +890,9 @@ module Gitlab
if Database.mysql?
locate = Arel::Nodes::NamedFunction
- .new('locate', [quoted_pattern, column])
+ .new("locate", [quoted_pattern, column])
insert_in_place = Arel::Nodes::NamedFunction
- .new('insert', [column, locate, pattern.size, quoted_replacement])
+ .new("insert", [column, locate, pattern.size, quoted_replacement])
Arel::Nodes::SqlLiteral.new(insert_in_place.to_sql)
else
@@ -926,21 +926,21 @@ module Gitlab
dbname = Database.database_name
user = Database.username
- raise <<-EOF
-Your database user is not allowed to create, drop, or execute triggers on the
-table #{table}.
+ raise <<~EOF
+ Your database user is not allowed to create, drop, or execute triggers on the
+ table #{table}.
-If you are using PostgreSQL you can solve this by logging in to the GitLab
-database (#{dbname}) using a super user and running:
+ If you are using PostgreSQL you can solve this by logging in to the GitLab
+ database (#{dbname}) using a super user and running:
- ALTER #{user} WITH SUPERUSER
+ ALTER #{user} WITH SUPERUSER
-For MySQL you instead need to run:
+ For MySQL you instead need to run:
- GRANT ALL PRIVILEGES ON #{dbname}.* TO #{user}@'%'
+ GRANT ALL PRIVILEGES ON #{dbname}.* TO #{user}@'%'
-Both queries will grant the user super user permissions, ensuring you don't run
-into similar problems in the future (e.g. when new tables are created).
+ Both queries will grant the user super user permissions, ensuring you don't run
+ into similar problems in the future (e.g. when new tables are created).
EOF
end
end
@@ -970,7 +970,7 @@ into similar problems in the future (e.g. when new tables are created).
# end
# end
def bulk_queue_background_migration_jobs_by_range(model_class, job_class_name, batch_size: BACKGROUND_MIGRATION_BATCH_SIZE)
- raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?('id')
+ raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?("id")
jobs = []
table_name = model_class.quoted_table_name
@@ -1019,7 +1019,7 @@ into similar problems in the future (e.g. when new tables are created).
# end
# end
def queue_background_migration_jobs_by_range_at_intervals(model_class, job_class_name, delay_interval, batch_size: BACKGROUND_MIGRATION_BATCH_SIZE)
- raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?('id')
+ raise "#{model_class} does not have an ID to use for batch ranges" unless model_class.column_names.include?("id")
# To not overload the worker too much we enforce a minimum interval both
# when scheduling and performing jobs.
@@ -1028,7 +1028,7 @@ into similar problems in the future (e.g. when new tables are created).
end
model_class.each_batch(of: batch_size) do |relation, index|
- start_id, end_id = relation.pluck('MIN(id), MAX(id)').first
+ start_id, end_id = relation.pluck("MIN(id), MAX(id)").first
# `BackgroundMigrationWorker.bulk_perform_in` schedules all jobs for
# the same time, which is not helpful in most cases where we wish to
diff --git a/lib/gitlab/database/multi_threaded_migration.rb b/lib/gitlab/database/multi_threaded_migration.rb
index 1d39a3d0b57..33090d343e2 100644
--- a/lib/gitlab/database/multi_threaded_migration.rb
+++ b/lib/gitlab/database/multi_threaded_migration.rb
@@ -32,18 +32,16 @@ module Gitlab
def with_multiple_threads(thread_count, join: true)
pool = Gitlab::Database.create_connection_pool(thread_count)
- threads = Array.new(thread_count) do
+ threads = Array.new(thread_count) {
Thread.new do
pool.with_connection do |connection|
- begin
- Thread.current[MULTI_THREAD_AR_CONNECTION] = connection
- yield
- ensure
- Thread.current[MULTI_THREAD_AR_CONNECTION] = nil
- end
+ Thread.current[MULTI_THREAD_AR_CONNECTION] = connection
+ yield
+ ensure
+ Thread.current[MULTI_THREAD_AR_CONNECTION] = nil
end
end
- end
+ }
threads.each(&:join) if join
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb
index f1dc3ed74fe..838d695a820 100644
--- a/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb
+++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/migration_classes.rb
@@ -18,7 +18,7 @@ module Gitlab
def build_full_path
if parent && path
- parent.full_path + '/' + path
+ parent.full_path + "/" + path
else
path
end
@@ -38,42 +38,42 @@ module Gitlab
class Namespace < ActiveRecord::Base
include MigrationClasses::Routable
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
self.inheritance_column = :_type_disabled
belongs_to :parent,
- class_name: "#{MigrationClasses.name}::Namespace"
+ class_name: "#{MigrationClasses.name}::Namespace"
has_one :route, as: :source
has_many :children,
- class_name: "#{MigrationClasses.name}::Namespace",
- foreign_key: :parent_id
+ class_name: "#{MigrationClasses.name}::Namespace",
+ foreign_key: :parent_id
# Overridden to have the correct `source_type` for the `route` relation
def self.name
- 'Namespace'
+ "Namespace"
end
def kind
- type == 'Group' ? 'group' : 'user'
+ type == "Group" ? "group" : "user"
end
end
class User < ActiveRecord::Base
- self.table_name = 'users'
+ self.table_name = "users"
end
class Route < ActiveRecord::Base
- self.table_name = 'routes'
+ self.table_name = "routes"
belongs_to :source, polymorphic: true
end
class Project < ActiveRecord::Base
include MigrationClasses::Routable
has_one :route, as: :source
- self.table_name = 'projects'
+ self.table_name = "projects"
HASHED_STORAGE_FEATURES = {
repository: 1,
- attachments: 2
+ attachments: 2,
}.freeze
def repository_storage_path
@@ -82,14 +82,14 @@ module Gitlab
# Overridden to have the correct `source_type` for the `route` relation
def self.name
- 'Project'
+ "Project"
end
def hashed_storage?(feature)
raise ArgumentError, "Invalid feature" unless HASHED_STORAGE_FEATURES.include?(feature)
return false unless respond_to?(:storage_version)
- self.storage_version && self.storage_version >= HASHED_STORAGE_FEATURES[feature]
+ storage_version && storage_version >= HASHED_STORAGE_FEATURES[feature]
end
end
end
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
index 60afa4bcd52..097623e8103 100644
--- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
+++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base.rb
@@ -8,11 +8,11 @@ module Gitlab
attr_reader :paths, :migration
delegate :update_column_in_batches,
- :execute,
- :replace_sql,
- :quote_string,
- :say,
- to: :migration
+ :execute,
+ :replace_sql,
+ :quote_string,
+ :say,
+ to: :migration
def initialize(paths, migration)
@paths = paths
@@ -38,7 +38,7 @@ module Gitlab
def perform_rename(routable, old_full_path, new_full_path)
# skips callbacks & validations
- new_path = new_full_path.split('/').last
+ new_path = new_full_path.split("/").last
routable.class.where(id: routable)
.update_all(path: new_path)
@@ -52,17 +52,17 @@ module Gitlab
quoted_old_wildcard_path = quote_string("#{old_full_path}/%")
filter = if Database.mysql?
- "lower(routes.path) = lower('#{quoted_old_full_path}') "\
- "OR routes.path LIKE '#{quoted_old_wildcard_path}'"
- else
- "routes.id IN "\
- "( SELECT routes.id FROM routes WHERE lower(routes.path) = lower('#{quoted_old_full_path}') "\
- "UNION SELECT routes.id FROM routes WHERE routes.path ILIKE '#{quoted_old_wildcard_path}' )"
- end
+ "lower(routes.path) = lower('#{quoted_old_full_path}') "\
+ "OR routes.path LIKE '#{quoted_old_wildcard_path}'"
+ else
+ "routes.id IN "\
+ "( SELECT routes.id FROM routes WHERE lower(routes.path) = lower('#{quoted_old_full_path}') "\
+ "UNION SELECT routes.id FROM routes WHERE routes.path ILIKE '#{quoted_old_wildcard_path}' )"
+ end
replace_statement = replace_sql(Route.arel_table[:path],
- old_full_path,
- new_full_path)
+ old_full_path,
+ new_full_path)
update = Arel::UpdateManager.new
.table(routes)
@@ -165,7 +165,7 @@ module Gitlab
say "renaming #{type} from #{path_after_rename} back to #{path_before_rename}"
begin
yield(path_before_rename, path_after_rename)
- rescue StandardError => e
+ rescue => e
failed_reverts << rename_info
say "Renaming #{type} from #{path_after_rename} back to "\
"#{path_before_rename} failed. Review the error and try "\
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
index 6bbad707f0f..54d8c42e897 100644
--- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
+++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces.rb
@@ -19,16 +19,16 @@ module Gitlab
MigrationClasses::Namespace.where.not(parent_id: nil)
when :top_level
MigrationClasses::Namespace.where(parent_id: nil)
- end
+ end
with_paths = MigrationClasses::Route.arel_table[:path]
- .matches_any(path_patterns)
+ .matches_any(path_patterns)
namespaces.joins(:route).where(with_paths)
end
def rename_namespace(namespace)
old_full_path, new_full_path = rename_path_for_routable(namespace)
- track_rename('namespace', old_full_path, new_full_path)
+ track_rename("namespace", old_full_path, new_full_path)
rename_namespace_dependencies(namespace, old_full_path, new_full_path)
end
@@ -37,15 +37,15 @@ module Gitlab
move_repositories(namespace, old_full_path, new_full_path)
move_uploads(old_full_path, new_full_path)
move_pages(old_full_path, new_full_path)
- rename_user(old_full_path, new_full_path) if namespace.kind == 'user'
+ rename_user(old_full_path, new_full_path) if namespace.kind == "user"
remove_cached_html_for_projects(projects_for_namespace(namespace).map(&:id))
end
def revert_renames
- reverts_for_type('namespace') do |path_before_rename, current_path|
+ reverts_for_type("namespace") do |path_before_rename, current_path|
matches_path = MigrationClasses::Route.arel_table[:path].matches(current_path)
namespace = MigrationClasses::Namespace.joins(:route)
- .where(matches_path).first&.becomes(MigrationClasses::Namespace)
+ .where(matches_path).first&.becomes(MigrationClasses::Namespace)
if namespace
perform_rename(namespace, current_path, path_before_rename)
@@ -83,8 +83,8 @@ module Gitlab
def projects_for_namespace(namespace)
namespace_ids = child_ids_for_parent(namespace, ids: [namespace.id])
namespace_or_children = MigrationClasses::Project
- .arel_table[:namespace_id]
- .in(namespace_ids)
+ .arel_table[:namespace_id]
+ .in(namespace_ids)
MigrationClasses::Project.where(namespace_or_children)
end
diff --git a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb
index 580be9fe267..49d533067b4 100644
--- a/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb
+++ b/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects.rb
@@ -18,7 +18,7 @@ module Gitlab
def rename_project(project)
old_full_path, new_full_path = rename_path_for_routable(project)
- track_rename('project', old_full_path, new_full_path)
+ track_rename("project", old_full_path, new_full_path)
move_project_folders(project, old_full_path, new_full_path)
end
@@ -34,10 +34,10 @@ module Gitlab
end
def revert_renames
- reverts_for_type('project') do |path_before_rename, current_path|
+ reverts_for_type("project") do |path_before_rename, current_path|
matches_path = MigrationClasses::Route.arel_table[:path].matches(current_path)
project = MigrationClasses::Project.joins(:route)
- .where(matches_path).first
+ .where(matches_path).first
if project
perform_rename(project, current_path, path_before_rename)
@@ -54,8 +54,8 @@ module Gitlab
def move_repository(project, old_path, new_path)
unless gitlab_shell.mv_repository(project.repository_storage,
- old_path,
- new_path)
+ old_path,
+ new_path)
Rails.logger.error "Error moving #{old_path} to #{new_path}"
end
end
@@ -64,7 +64,7 @@ module Gitlab
return @projects_for_paths if @projects_for_paths
with_paths = MigrationClasses::Route.arel_table[:path]
- .matches_any(path_patterns)
+ .matches_any(path_patterns)
@projects_for_paths = MigrationClasses::Project.joins(:route).where(with_paths)
end
diff --git a/lib/gitlab/database/sha_attribute.rb b/lib/gitlab/database/sha_attribute.rb
index 8d97adaff99..f717cef162d 100644
--- a/lib/gitlab/database/sha_attribute.rb
+++ b/lib/gitlab/database/sha_attribute.rb
@@ -17,12 +17,12 @@ module Gitlab
# using them as if they were stored as string values. This gives you the
# ease of use of string values, but without the storage overhead.
class ShaAttribute < BINARY_TYPE
- PACK_FORMAT = 'H*'.freeze
+ PACK_FORMAT = "H*"
# Casts binary data to a SHA1 in hexadecimal.
def deserialize(value)
value = super(value)
- value ? value.unpack(PACK_FORMAT)[0] : nil
+ value ? value.unpack1(PACK_FORMAT) : nil
end
# Casts a SHA1 in hexadecimal to the proper binary format.
diff --git a/lib/gitlab/database/subquery.rb b/lib/gitlab/database/subquery.rb
index 10971d2b274..555a24c5e10 100644
--- a/lib/gitlab/database/subquery.rb
+++ b/lib/gitlab/database/subquery.rb
@@ -10,7 +10,7 @@ module Gitlab
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/51729
r = relation.limit(nil).arel
r.take(relation.limit_value) if relation.limit_value
- t2 = r.as('t2')
+ t2 = r.as("t2")
relation.unscoped.joins(t.join(t2).on(t[:id].eq(t2[:id])).join_sources.first)
end
diff --git a/lib/gitlab/dependency_linker.rb b/lib/gitlab/dependency_linker.rb
index c63d9e5bb71..d5c4d48e8ac 100644
--- a/lib/gitlab/dependency_linker.rb
+++ b/lib/gitlab/dependency_linker.rb
@@ -12,7 +12,7 @@ module Gitlab
PodspecJsonLinker,
CartfileLinker,
GodepsJsonLinker,
- RequirementsTxtLinker
+ RequirementsTxtLinker,
].freeze
def self.linker(blob_name)
diff --git a/lib/gitlab/dependency_linker/base_linker.rb b/lib/gitlab/dependency_linker/base_linker.rb
index ac2efe598b4..1be572b0b66 100644
--- a/lib/gitlab/dependency_linker/base_linker.rb
+++ b/lib/gitlab/dependency_linker/base_linker.rb
@@ -44,7 +44,7 @@ module Gitlab
end
def link_tag(name, url)
- %{<a href="#{ERB::Util.html_escape_once(url)}" rel="nofollow noreferrer noopener" target="_blank">#{ERB::Util.html_escape_once(name)}</a>}
+ %(<a href="#{ERB::Util.html_escape_once(url)}" rel="nofollow noreferrer noopener" target="_blank">#{ERB::Util.html_escape_once(name)}</a>)
end
# Links package names based on regex.
diff --git a/lib/gitlab/dependency_linker/cartfile_linker.rb b/lib/gitlab/dependency_linker/cartfile_linker.rb
index 0e33f0956dd..0229201cbfd 100644
--- a/lib/gitlab/dependency_linker/cartfile_linker.rb
+++ b/lib/gitlab/dependency_linker/cartfile_linker.rb
@@ -8,7 +8,7 @@ module Gitlab
private
def link_dependencies
- link_method_call('github', REPO_REGEX, &method(:github_url))
+ link_method_call("github", REPO_REGEX, &method(:github_url))
link_method_call(%w[github git binary], URL_REGEX, &:itself)
end
end
diff --git a/lib/gitlab/dependency_linker/gemfile_linker.rb b/lib/gitlab/dependency_linker/gemfile_linker.rb
index 8ab219c4962..7bbb4df495a 100644
--- a/lib/gitlab/dependency_linker/gemfile_linker.rb
+++ b/lib/gitlab/dependency_linker/gemfile_linker.rb
@@ -20,12 +20,12 @@ module Gitlab
link_regex(/(git:|:git\s*=>)\s*['"](?<name>#{URL_REGEX})['"]/, &:itself)
# Link `source "https://rubygems.org"` to https://rubygems.org
- link_method_call('source', URL_REGEX, &:itself)
+ link_method_call("source", URL_REGEX, &:itself)
end
def link_packages
# Link `gem "package_name"` to https://rubygems.org/gems/package_name
- link_method_call('gem') do |name|
+ link_method_call("gem") do |name|
"https://rubygems.org/gems/#{name}"
end
end
diff --git a/lib/gitlab/dependency_linker/gemspec_linker.rb b/lib/gitlab/dependency_linker/gemspec_linker.rb
index b924ea86d89..fe4a6156b12 100644
--- a/lib/gitlab/dependency_linker/gemspec_linker.rb
+++ b/lib/gitlab/dependency_linker/gemspec_linker.rb
@@ -8,8 +8,8 @@ module Gitlab
private
def link_dependencies
- link_method_call('homepage', URL_REGEX, &:itself)
- link_method_call('license', &method(:license_url))
+ link_method_call("homepage", URL_REGEX, &:itself)
+ link_method_call("license", &method(:license_url))
link_method_call(%w[name add_dependency add_runtime_dependency add_development_dependency]) do |name|
"https://rubygems.org/gems/#{name}"
diff --git a/lib/gitlab/dependency_linker/godeps_json_linker.rb b/lib/gitlab/dependency_linker/godeps_json_linker.rb
index d24c137793e..2c0bccb4280 100644
--- a/lib/gitlab/dependency_linker/godeps_json_linker.rb
+++ b/lib/gitlab/dependency_linker/godeps_json_linker.rb
@@ -10,7 +10,7 @@ module Gitlab
private
def link_dependencies
- link_json('ImportPath') do |path|
+ link_json("ImportPath") do |path|
case path
when %r{\A(?<repo>gitlab\.com/#{NESTED_REPO_REGEX})\.git/(?<path>.+)\z},
%r{\A(?<repo>git(lab|hub)\.com/#{REPO_REGEX})/(?<path>.+)\z}
diff --git a/lib/gitlab/dependency_linker/json_linker.rb b/lib/gitlab/dependency_linker/json_linker.rb
index 298d214df61..4d6460b0691 100644
--- a/lib/gitlab/dependency_linker/json_linker.rb
+++ b/lib/gitlab/dependency_linker/json_linker.rb
@@ -39,7 +39,11 @@ module Gitlab
end
def json
- @json ||= JSON.parse(plain_text) rescue nil
+ @json ||= begin
+ JSON.parse(plain_text)
+ rescue
+ nil
+ end
end
end
end
diff --git a/lib/gitlab/dependency_linker/package_json_linker.rb b/lib/gitlab/dependency_linker/package_json_linker.rb
index 578e25f806a..c0299f05981 100644
--- a/lib/gitlab/dependency_linker/package_json_linker.rb
+++ b/lib/gitlab/dependency_linker/package_json_linker.rb
@@ -8,8 +8,8 @@ module Gitlab
private
def link_dependencies
- link_json('name', json["name"], &method(:package_url))
- link_json('license', &method(:license_url))
+ link_json("name", json["name"], &method(:package_url))
+ link_json("license", &method(:license_url))
link_json(%w[homepage url], URL_REGEX, &:itself)
link_packages
diff --git a/lib/gitlab/dependency_linker/podfile_linker.rb b/lib/gitlab/dependency_linker/podfile_linker.rb
index def9b04cca9..610bd6f7a42 100644
--- a/lib/gitlab/dependency_linker/podfile_linker.rb
+++ b/lib/gitlab/dependency_linker/podfile_linker.rb
@@ -10,7 +10,7 @@ module Gitlab
private
def link_packages
- link_method_call('pod', &method(:package_url))
+ link_method_call("pod", &method(:package_url))
end
end
end
diff --git a/lib/gitlab/dependency_linker/podspec_json_linker.rb b/lib/gitlab/dependency_linker/podspec_json_linker.rb
index 1a2493e7cc0..cf04992e8f5 100644
--- a/lib/gitlab/dependency_linker/podspec_json_linker.rb
+++ b/lib/gitlab/dependency_linker/podspec_json_linker.rb
@@ -10,8 +10,8 @@ module Gitlab
private
def link_dependencies
- link_json('name', json["name"], &method(:package_url))
- link_json('license', &method(:license_url))
+ link_json("name", json["name"], &method(:package_url))
+ link_json("license", &method(:license_url))
link_json(%w[homepage git], URL_REGEX, &:itself)
link_packages_at_key("dependencies", &method(:package_url))
diff --git a/lib/gitlab/dependency_linker/podspec_linker.rb b/lib/gitlab/dependency_linker/podspec_linker.rb
index 6b1758c5a43..3515c218aaf 100644
--- a/lib/gitlab/dependency_linker/podspec_linker.rb
+++ b/lib/gitlab/dependency_linker/podspec_linker.rb
@@ -12,11 +12,11 @@ module Gitlab
private
def link_dependencies
- link_method_call('homepage', URL_REGEX, &:itself)
+ link_method_call("homepage", URL_REGEX, &:itself)
link_regex(/(git:|:git\s*=>)\s*['"](?<name>#{URL_REGEX})['"]/, &:itself)
- link_method_call('license', &method(:license_url))
+ link_method_call("license", &method(:license_url))
link_regex(/license\s*=\s*\{\s*(type:|:type\s*=>)\s*#{STRING_REGEX}/, &method(:license_url))
link_method_call(%w[name dependency], &method(:package_url))
diff --git a/lib/gitlab/diff/diff_refs.rb b/lib/gitlab/diff/diff_refs.rb
index dc245377ccc..7950959b0a7 100644
--- a/lib/gitlab/diff/diff_refs.rb
+++ b/lib/gitlab/diff/diff_refs.rb
@@ -20,7 +20,7 @@ module Gitlab
Git.shas_eql?(head_sha, other.head_sha)
end
- alias_method :eql?, :==
+ alias eql? ==
def hash
[self.class, base_sha, start_sha, head_sha].hash
@@ -48,9 +48,9 @@ module Gitlab
straight = start_sha == base_sha
CompareService.new(project, head_sha).execute(project,
- start_sha,
- base_sha: base_sha,
- straight: straight)
+ start_sha,
+ base_sha: base_sha,
+ straight: straight)
end
end
end
diff --git a/lib/gitlab/diff/file.rb b/lib/gitlab/diff/file.rb
index c9d89d56884..6ced7926424 100644
--- a/lib/gitlab/diff/file.rb
+++ b/lib/gitlab/diff/file.rb
@@ -21,7 +21,7 @@ module Gitlab
# large files referred to in "Large File Storage" are much more likely to be
# binary than text.
RICH_VIEWERS = [
- DiffViewer::Image
+ DiffViewer::Image,
].sort_by { |v| v.binary? ? 0 : 1 }.freeze
def initialize(
@@ -30,7 +30,8 @@ module Gitlab
diff_refs: nil,
fallback_diff_refs: nil,
stats: nil,
- unique_identifier: nil)
+ unique_identifier: nil
+ )
@diff = diff
@stats = stats
@@ -52,7 +53,7 @@ module Gitlab
diff_refs: diff_refs,
position_type: position_type.to_s,
old_path: old_path,
- new_path: new_path
+ new_path: new_path,
}
if position_type == :text
@@ -75,7 +76,7 @@ module Gitlab
end
def line_for_position(pos)
- return nil unless pos.position_type == 'text'
+ return nil unless pos.position_type == "text"
# This method is normally used to find which line the diff was
# commented on, and in this context, it's normally the raw diff persisted
@@ -190,7 +191,7 @@ module Gitlab
def highlighted_diff_lines
@highlighted_diff_lines ||=
- Gitlab::Diff::Highlight.new(self, repository: self.repository).highlight
+ Gitlab::Diff::Highlight.new(self, repository: repository).highlight
end
# Array[<Hash>] with right/left keys that contains Gitlab::Diff::Line objects which text is hightlighted
@@ -231,7 +232,7 @@ module Gitlab
end
def diffable?
- repository.attributes(file_path).fetch('diff') { true }
+ repository.attributes(file_path).fetch("diff") { true }
end
def binary_in_repo?
@@ -322,7 +323,7 @@ module Gitlab
last_line = lines.last
if last_line.new_pos < total_blob_lines(blob) && !deleted_file?
- match_line = Gitlab::Diff::Line.new("", 'match', nil, last_line.old_pos, last_line.new_pos)
+ match_line = Gitlab::Diff::Line.new("", "match", nil, last_line.old_pos, last_line.new_pos)
lines.push(match_line)
end
@@ -350,7 +351,7 @@ module Gitlab
end
def text_position_properties(line)
- { old_line: line.old_line, new_line: line.new_line }
+ {old_line: line.old_line, new_line: line.new_line}
end
def image_position_properties(image_point)
diff --git a/lib/gitlab/diff/file_collection/base.rb b/lib/gitlab/diff/file_collection/base.rb
index c5bbf522f7c..56640f54c52 100644
--- a/lib/gitlab/diff/file_collection/base.rb
+++ b/lib/gitlab/diff/file_collection/base.rb
@@ -79,10 +79,10 @@ module Gitlab
stats = diff_stats_collection&.find_by_path(diff.new_path)
Gitlab::Diff::File.new(diff,
- repository: project.repository,
- diff_refs: diff_refs,
- fallback_diff_refs: fallback_diff_refs,
- stats: stats)
+ repository: project.repository,
+ diff_refs: diff_refs,
+ fallback_diff_refs: fallback_diff_refs,
+ stats: stats)
end
end
end
diff --git a/lib/gitlab/diff/file_collection/compare.rb b/lib/gitlab/diff/file_collection/compare.rb
index 663bad95db7..3b802bdb44d 100644
--- a/lib/gitlab/diff/file_collection/compare.rb
+++ b/lib/gitlab/diff/file_collection/compare.rb
@@ -6,9 +6,9 @@ module Gitlab
class Compare < Base
def initialize(compare, project:, diff_options:, diff_refs: nil)
super(compare,
- project: project,
+ project: project,
diff_options: diff_options,
- diff_refs: diff_refs)
+ diff_refs: diff_refs)
end
def unfold_diff_lines(positions)
diff --git a/lib/gitlab/diff/formatters/base_formatter.rb b/lib/gitlab/diff/formatters/base_formatter.rb
index 9704aed82c1..af8b8c1a5fb 100644
--- a/lib/gitlab/diff/formatters/base_formatter.rb
+++ b/lib/gitlab/diff/formatters/base_formatter.rb
@@ -42,7 +42,7 @@ module Gitlab
head_sha: head_sha,
old_path: old_path,
new_path: new_path,
- position_type: position_type
+ position_type: position_type,
}
end
diff --git a/lib/gitlab/diff/formatters/text_formatter.rb b/lib/gitlab/diff/formatters/text_formatter.rb
index f6e247ef665..f5118635019 100644
--- a/lib/gitlab/diff/formatters/text_formatter.rb
+++ b/lib/gitlab/diff/formatters/text_formatter.rb
@@ -30,9 +30,9 @@ module Gitlab
if old_line && new_line
nil
elsif new_line
- 'new'
+ "new"
else
- 'old'
+ "old"
end
end
diff --git a/lib/gitlab/diff/highlight.rb b/lib/gitlab/diff/highlight.rb
index d2484217ab9..4c2c1c33824 100644
--- a/lib/gitlab/diff/highlight.rb
+++ b/lib/gitlab/diff/highlight.rb
@@ -35,7 +35,7 @@ module Gitlab
# match the blob, which is a bug. But we shouldn't fail to render
# completely in that case, even though we want to report the error.
rescue RangeError => e
- Gitlab::Sentry.track_exception(e, issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/45441')
+ Gitlab::Sentry.track_exception(e, issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/45441")
end
end
@@ -48,7 +48,7 @@ module Gitlab
private
def highlight_line(diff_line)
- return unless diff_file && diff_file.diff_refs
+ return unless diff_file&.diff_refs
rich_line =
if diff_line.unchanged? || diff_line.added?
@@ -60,7 +60,7 @@ module Gitlab
# Only update text if line is found. This will prevent
# issues with submodules given the line only exists in diff content.
if rich_line
- line_prefix = diff_line.text =~ /\A(.)/ ? $1 : ' '
+ line_prefix = diff_line.text =~ /\A(.)/ ? $1 : " "
"#{line_prefix}#{rich_line}".html_safe
end
end
diff --git a/lib/gitlab/diff/highlight_cache.rb b/lib/gitlab/diff/highlight_cache.rb
index e4390771db2..01df0158f49 100644
--- a/lib/gitlab/diff/highlight_cache.rb
+++ b/lib/gitlab/diff/highlight_cache.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-#
+
module Gitlab
module Diff
class HighlightCache
@@ -43,7 +43,7 @@ module Gitlab
end
def key
- [diffable, 'highlighted-diff-files', Gitlab::Diff::Line::SERIALIZE_KEYS, diff_options]
+ [diffable, "highlighted-diff-files", Gitlab::Diff::Line::SERIALIZE_KEYS, diff_options]
end
private
diff --git a/lib/gitlab/diff/image_point.rb b/lib/gitlab/diff/image_point.rb
index a3ce032f8e2..90325fcf228 100644
--- a/lib/gitlab/diff/image_point.rb
+++ b/lib/gitlab/diff/image_point.rb
@@ -17,7 +17,7 @@ module Gitlab
width: width,
height: height,
x: x,
- y: y
+ y: y,
}
end
end
diff --git a/lib/gitlab/diff/inline_diff.rb b/lib/gitlab/diff/inline_diff.rb
index 5815d1bae4a..b3591177ee9 100644
--- a/lib/gitlab/diff/inline_diff.rb
+++ b/lib/gitlab/diff/inline_diff.rb
@@ -73,7 +73,7 @@ module Gitlab
def find_changed_line_pairs(lines)
# Prefixes of all diff lines, indicating their types
# For example: `" - + -+ ---+++ --+ -++"`
- line_prefixes = lines.each_with_object(+"") { |line, s| s << (line[0] || ' ') }.gsub(/[^ +-]/, ' ')
+ line_prefixes = lines.each_with_object(+"") { |line, s| s << (line[0] || " ") }.gsub(/[^ +-]/, " ")
changed_line_pairs = []
line_prefixes.scan(LINE_PAIRS_PATTERN) do
diff --git a/lib/gitlab/diff/inline_diff_markdown_marker.rb b/lib/gitlab/diff/inline_diff_markdown_marker.rb
index 3c536c43a9e..d1217e91af5 100644
--- a/lib/gitlab/diff/inline_diff_markdown_marker.rb
+++ b/lib/gitlab/diff/inline_diff_markdown_marker.rb
@@ -5,7 +5,7 @@ module Gitlab
class InlineDiffMarkdownMarker < Gitlab::StringRangeMarker
MARKDOWN_SYMBOLS = {
addition: "+",
- deletion: "-"
+ deletion: "-",
}.freeze
def mark(line_inline_diffs, mode: nil)
diff --git a/lib/gitlab/diff/inline_diff_marker.rb b/lib/gitlab/diff/inline_diff_marker.rb
index 1bbde1ffd2a..82fde1cffdc 100644
--- a/lib/gitlab/diff/inline_diff_marker.rb
+++ b/lib/gitlab/diff/inline_diff_marker.rb
@@ -9,7 +9,7 @@ module Gitlab
def mark(line_inline_diffs, mode: nil)
super(line_inline_diffs) do |text, left:, right:|
- %{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
+ %(<span class="#{html_class_names(left, right, mode)}">#{text}</span>)
end
end
diff --git a/lib/gitlab/diff/line.rb b/lib/gitlab/diff/line.rb
index 001748afb41..3b4c4a41f6a 100644
--- a/lib/gitlab/diff/line.rb
+++ b/lib/gitlab/diff/line.rb
@@ -3,7 +3,7 @@
module Gitlab
module Diff
class Line
- SERIALIZE_KEYS = %i(line_code rich_text text type index old_pos new_pos).freeze
+ SERIALIZE_KEYS = %i[line_code rich_text text type index old_pos new_pos].freeze
attr_reader :line_code, :type, :old_pos, :new_pos
attr_writer :rich_text
@@ -22,13 +22,13 @@ module Gitlab
def self.init_from_hash(hash)
new(hash[:text],
- hash[:type],
- hash[:index],
- hash[:old_pos],
- hash[:new_pos],
- parent_file: hash[:parent_file],
- line_code: hash[:line_code],
- rich_text: hash[:rich_text])
+ hash[:type],
+ hash[:index],
+ hash[:old_pos],
+ hash[:new_pos],
+ parent_file: hash[:parent_file],
+ line_code: hash[:line_code],
+ rich_text: hash[:rich_text])
end
def to_hash
@@ -88,7 +88,7 @@ module Gitlab
{
old_pos: old_pos,
- new_pos: new_pos
+ new_pos: new_pos,
}
end
diff --git a/lib/gitlab/diff/line_mapper.rb b/lib/gitlab/diff/line_mapper.rb
index fba7bff4781..e4c124329f0 100644
--- a/lib/gitlab/diff/line_mapper.rb
+++ b/lib/gitlab/diff/line_mapper.rb
@@ -39,10 +39,10 @@ module Gitlab
# - The diff line with that exact line number, if it is in the diff context
# - The first diff line with a higher line number, if it falls between diff contexts
# - The last known diff line, if it falls after the last diff context
- diff_line = diff_lines.find do |diff_line|
+ diff_line = diff_lines.find { |diff_line|
diff_from_line = diff_line.public_send(from) # rubocop:disable GitlabSecurity/PublicSend
diff_from_line && diff_from_line >= from_line
- end
+ }
diff_line ||= diff_lines.last
# If no diff line could be found, the file wasn't changed, and the
diff --git a/lib/gitlab/diff/lines_unfolder.rb b/lib/gitlab/diff/lines_unfolder.rb
index 6cf904b2b2a..48dead2c255 100644
--- a/lib/gitlab/diff/lines_unfolder.rb
+++ b/lib/gitlab/diff/lines_unfolder.rb
@@ -39,7 +39,7 @@ module Gitlab
# Blob lines, unlike diffs, doesn't start with an empty space for
# unchanged line, so the parsing and highlighting step can get fuzzy
# without the following change.
- line_prefix = ' '
+ line_prefix = " "
blob_as_diff_lines = @blob.data.each_line.map { |line| "#{line_prefix}#{line}" }
lines = Gitlab::Diff::Parser.new.parse(blob_as_diff_lines, diff_file: @diff_file).to_a
@@ -100,7 +100,7 @@ module Gitlab
blob_lines.each do |line|
new_blob_lines << Gitlab::Diff::Line.new(line.text, line.type, nil, old_pos, new_pos,
- parent_file: @diff_file)
+ parent_file: @diff_file)
old_pos += 1
new_pos += 1
@@ -144,11 +144,11 @@ module Gitlab
def build_match_line(old_pos, new_pos)
blob_lines_length = blob_lines.length
- old_line_ref = [old_pos, blob_lines_length].join(',')
- new_line_ref = [new_pos, blob_lines_length].join(',')
+ old_line_ref = [old_pos, blob_lines_length].join(",")
+ new_line_ref = [new_pos, blob_lines_length].join(",")
new_match_line_str = "@@ -#{old_line_ref}+#{new_line_ref} @@"
- Gitlab::Diff::Line.new(new_match_line_str, 'match', nil, old_pos, new_pos)
+ Gitlab::Diff::Line.new(new_match_line_str, "match", nil, old_pos, new_pos)
end
# Returns the first line position that should be extracted
@@ -223,7 +223,7 @@ module Gitlab
next last_line if bottom?
@diff_file.diff_lines.find do |line|
- line.old_pos > comment_position && line.type == 'match'
+ line.old_pos > comment_position && line.type == "match"
end
end
end
diff --git a/lib/gitlab/diff/parallel_diff.rb b/lib/gitlab/diff/parallel_diff.rb
index 77b65fea726..fff646262f9 100644
--- a/lib/gitlab/diff/parallel_diff.rb
+++ b/lib/gitlab/diff/parallel_diff.rb
@@ -19,7 +19,7 @@ module Gitlab
if line.removed?
lines << {
left: line,
- right: nil
+ right: nil,
}
# Once we come upon a new line it can be put on the right of this old line
@@ -38,7 +38,7 @@ module Gitlab
else
lines << {
left: nil,
- right: line
+ right: line,
}
free_right_index = nil
@@ -48,7 +48,7 @@ module Gitlab
# line in the right panel is the same as in the left one
lines << {
left: line,
- right: line
+ right: line,
}
free_right_index = nil
diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb
index 4a47e4b80b6..998ab5180b5 100644
--- a/lib/gitlab/diff/parser.rb
+++ b/lib/gitlab/diff/parser.rb
@@ -25,11 +25,19 @@ module Gitlab
full_line = line.delete("\n")
- if line =~ /^@@ -/
+ if /^@@ -/.match?(line)
type = "match"
- line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
- line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
+ line_old = begin
+ line.match(/\-[0-9]*/)[0].to_i.abs
+ rescue
+ 0
+ end
+ line_new = begin
+ line.match(/\+[0-9]*/)[0].to_i.abs
+ rescue
+ 0
+ end
next if line_old <= 1 && line_new <= 1 # top of file
@@ -71,9 +79,9 @@ module Gitlab
private
def filename?(line)
- line.start_with?( '--- /dev/null', '+++ /dev/null', '--- a', '+++ b',
- '+++ a', # The line will start with `+++ a` in the reverse diff of an orphan commit
- '--- /tmp/diffy', '+++ /tmp/diffy')
+ line.start_with?("--- /dev/null", "+++ /dev/null", "--- a", "+++ b",
+ "+++ a", # The line will start with `+++ a` in the reverse diff of an orphan commit
+ "--- /tmp/diffy", "+++ /tmp/diffy")
end
def identification_type(line)
@@ -82,8 +90,6 @@ module Gitlab
"new"
when "-"
"old"
- else
- nil
end
end
end
diff --git a/lib/gitlab/diff/position.rb b/lib/gitlab/diff/position.rb
index e8f98f52111..8ad7023d68f 100644
--- a/lib/gitlab/diff/position.rb
+++ b/lib/gitlab/diff/position.rb
@@ -8,17 +8,17 @@ module Gitlab
attr_accessor :formatter
delegate :old_path,
- :new_path,
- :base_sha,
- :start_sha,
- :head_sha,
- :old_line,
- :new_line,
- :width,
- :height,
- :x,
- :y,
- :position_type, to: :formatter
+ :new_path,
+ :base_sha,
+ :start_sha,
+ :head_sha,
+ :old_line,
+ :new_line,
+ :width,
+ :height,
+ :x,
+ :y,
+ :position_type, to: :formatter
# A position can belong to a text line or to an image coordinate
# it depends of the position_type argument.
@@ -34,13 +34,13 @@ module Gitlab
# behavior. In this case, we override these to prevent memoized instance
# variables like `@diff_file` and `@diff_line` from being serialized.
def init_with(coder)
- initialize(coder['attributes'])
+ initialize(coder["attributes"])
self
end
def encode_with(coder)
- coder['attributes'] = formatter.to_h
+ coder["attributes"] = formatter.to_h
end
def key
@@ -84,11 +84,11 @@ module Gitlab
end
def added?
- type == 'new'
+ type == "new"
end
def removed?
- type == 'old'
+ type == "old"
end
def paths
@@ -115,7 +115,7 @@ module Gitlab
project_id: repository.project.id,
start_sha: start_sha,
head_sha: head_sha,
- path: file_path
+ path: file_path,
}
Gitlab::SafeRequestStore.fetch(key) { find_diff_file(repository) }
@@ -123,7 +123,7 @@ module Gitlab
end
def diff_options
- { paths: paths, expanded: true, include_stats: false }
+ {paths: paths, expanded: true, include_stats: false}
end
def diff_line(repository)
@@ -153,7 +153,7 @@ module Gitlab
type ||= "text"
case type
- when 'image'
+ when "image"
Gitlab::Diff::Formatters::ImageFormatter
else
Gitlab::Diff::Formatters::TextFormatter
diff --git a/lib/gitlab/diff/position_tracer.rb b/lib/gitlab/diff/position_tracer.rb
index af3df820422..2e81a0736d5 100644
--- a/lib/gitlab/diff/position_tracer.rb
+++ b/lib/gitlab/diff/position_tracer.rb
@@ -110,21 +110,21 @@ module Gitlab
new_position = position(cd_diff, c_line, d_line)
if valid_position?(new_position)
# If the line is still in the MR, we don't treat this as outdated.
- { position: new_position, outdated: false }
+ {position: new_position, outdated: false}
else
# If the line is no longer in the MR, we unfortunately cannot show
# the current state on the CD diff, so we treat it as outdated.
ac_diff = ac_diffs.diff_file_with_new_path(c_path)
- { position: position(ac_diff, nil, c_line), outdated: true }
+ {position: position(ac_diff, nil, c_line), outdated: true}
end
else
# If the line is still in D and not in C, it is still added.
- { position: position(cd_diff, nil, d_line), outdated: false }
+ {position: position(cd_diff, nil, d_line), outdated: false}
end
else
# If the line is no longer in D, it has been removed from the MR.
- { position: position(bd_diff, b_line, nil), outdated: true }
+ {position: position(bd_diff, b_line, nil), outdated: true}
end
end
@@ -148,14 +148,14 @@ module Gitlab
# removed line into an unchanged one.
bd_diff = bd_diffs.diff_file_with_new_path(d_path)
- { position: position(bd_diff, nil, d_line), outdated: true }
+ {position: position(bd_diff, nil, d_line), outdated: true}
else
# If the line is still in C and not in D, it is still removed.
- { position: position(cd_diff, c_line, nil), outdated: false }
+ {position: position(cd_diff, c_line, nil), outdated: false}
end
else
# If the line is no longer in C, it has been removed outside of the MR.
- { position: position(ac_diff, a_line, nil), outdated: true }
+ {position: position(ac_diff, a_line, nil), outdated: true}
end
end
@@ -181,22 +181,22 @@ module Gitlab
new_position = position(cd_diff, c_line, d_line)
if valid_position?(new_position)
# If the line is still in the MR, we don't treat this as outdated.
- { position: new_position, outdated: false }
+ {position: new_position, outdated: false}
else
# If the line is no longer in the MR, we unfortunately cannot show
# the current state on the CD diff or any change on the BD diff,
# so we treat it as outdated.
- { position: nil, outdated: true }
+ {position: nil, outdated: true}
end
elsif d_line # && !c_line
# If the line is still in D but no longer in C, it has turned from
# an unchanged line into an added one.
# We don't treat this as outdated since the line is still in the MR.
- { position: position(cd_diff, nil, d_line), outdated: false }
+ {position: position(cd_diff, nil, d_line), outdated: false}
else # !d_line && (c_line || !c_line)
# If the line is no longer in D, it has turned from an unchanged line
# into a removed one.
- { position: position(bd_diff, b_line, nil), outdated: true }
+ {position: position(bd_diff, b_line, nil), outdated: true}
end
end
diff --git a/lib/gitlab/discussions_diff/highlight_cache.rb b/lib/gitlab/discussions_diff/highlight_cache.rb
index 270cfb89488..dcc5451e04e 100644
--- a/lib/gitlab/discussions_diff/highlight_cache.rb
+++ b/lib/gitlab/discussions_diff/highlight_cache.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true
-#
+
module Gitlab
module DiscussionsDiff
class HighlightCache
@@ -35,9 +35,9 @@ module Gitlab
keys = raw_keys.map { |id| cache_key_for(id) }
content =
- Redis::Cache.with do |redis|
+ Redis::Cache.with { |redis|
redis.mget(keys)
- end
+ }
content.map! do |lines|
next unless lines
diff --git a/lib/gitlab/downtime_check.rb b/lib/gitlab/downtime_check.rb
index 31bb6810391..7918521797b 100644
--- a/lib/gitlab/downtime_check.rb
+++ b/lib/gitlab/downtime_check.rb
@@ -52,7 +52,7 @@ module Gitlab
# Returns the class for the given migration file path.
def class_for_migration_file(path)
- File.basename(path, File.extname(path)).split('_', 2).last.camelize
+ File.basename(path, File.extname(path)).split("_", 2).last.camelize
.constantize
end
@@ -65,8 +65,6 @@ module Gitlab
def downtime_reason(migration)
if migration.const_defined?(DOWNTIME_REASON_CONST)
migration.const_get(DOWNTIME_REASON_CONST)
- else
- nil
end
end
end
diff --git a/lib/gitlab/downtime_check/message.rb b/lib/gitlab/downtime_check/message.rb
index ec38bd769a3..5debb754943 100644
--- a/lib/gitlab/downtime_check/message.rb
+++ b/lib/gitlab/downtime_check/message.rb
@@ -5,8 +5,8 @@ module Gitlab
class Message
attr_reader :path, :offline
- OFFLINE = "\e[31moffline\e[0m".freeze
- ONLINE = "\e[32monline\e[0m".freeze
+ OFFLINE = "\e[31moffline\e[0m"
+ ONLINE = "\e[32monline\e[0m"
# path - The file path of the migration.
# offline - When set to `true` the migration will require downtime.
diff --git a/lib/gitlab/ee_compat_check.rb b/lib/gitlab/ee_compat_check.rb
index 01fd261404b..8131e1f6523 100644
--- a/lib/gitlab/ee_compat_check.rb
+++ b/lib/gitlab/ee_compat_check.rb
@@ -4,24 +4,24 @@
module Gitlab
# Checks if a set of migrations requires downtime or not.
class EeCompatCheck
- CANONICAL_CE_PROJECT_URL = 'https://gitlab.com/gitlab-org/gitlab-ce'.freeze
- CANONICAL_EE_REPO_URL = 'https://gitlab.com/gitlab-org/gitlab-ee.git'.freeze
- CHECK_DIR = Rails.root.join('ee_compat_check')
+ CANONICAL_CE_PROJECT_URL = "https://gitlab.com/gitlab-org/gitlab-ce"
+ CANONICAL_EE_REPO_URL = "https://gitlab.com/gitlab-org/gitlab-ee.git"
+ CHECK_DIR = Rails.root.join("ee_compat_check")
IGNORED_FILES_REGEX = /VERSION|CHANGELOG\.md/i.freeze
- PLEASE_READ_THIS_BANNER = %Q{
+ PLEASE_READ_THIS_BANNER = %(
============================================================
===================== PLEASE READ THIS =====================
============================================================
- }.freeze
- STAY_STRONG_LINK_TO_DOCS = %Q{
+ )
+ STAY_STRONG_LINK_TO_DOCS = %(
Stay 💪! For more information, see
https://docs.gitlab.com/ce/development/automatic_ce_ee_merge.html
- }.freeze
- THANKS_FOR_READING_BANNER = %Q{
+ )
+ THANKS_FOR_READING_BANNER = %(
============================================================
==================== THANKS FOR READING ====================
============================================================\n
- }.freeze
+ )
attr_reader :ee_repo_dir, :patches_dir
attr_reader :ce_project_url, :ee_repo_url
@@ -29,11 +29,11 @@ module Gitlab
attr_reader :job_id, :failed_files
def initialize(branch:, ce_project_url: CANONICAL_CE_PROJECT_URL, job_id: nil)
- @ee_repo_dir = CHECK_DIR.join('ee-repo')
- @patches_dir = CHECK_DIR.join('patches')
+ @ee_repo_dir = CHECK_DIR.join("ee-repo")
+ @patches_dir = CHECK_DIR.join("patches")
@ce_branch = branch
@ce_project_url = ce_project_url
- @ee_repo_url = ce_public_repo_url.sub('gitlab-ce', 'gitlab-ee')
+ @ee_repo_url = ce_public_repo_url.sub("gitlab-ce", "gitlab-ee")
@job_id = job_id
end
@@ -41,8 +41,8 @@ module Gitlab
ensure_patches_dir
# We're generating the patch against the canonical-ce remote since forks'
# master branch are not necessarily up-to-date.
- add_remote('canonical-ce', "#{CANONICAL_CE_PROJECT_URL}.git")
- generate_patch(branch: ce_branch, patch_path: ce_patch_full_path, branch_remote: 'origin', master_remote: 'canonical-ce')
+ add_remote("canonical-ce", "#{CANONICAL_CE_PROJECT_URL}.git")
+ generate_patch(branch: ce_branch, patch_path: ce_patch_full_path, branch_remote: "origin", master_remote: "canonical-ce")
ensure_ee_repo
Dir.chdir(ee_repo_dir) do
@@ -51,17 +51,17 @@ module Gitlab
ee_remotes.each do |key, url|
add_remote(key, url)
end
- fetch(branch: 'master', depth: 20, remote: 'canonical-ee')
+ fetch(branch: "master", depth: 20, remote: "canonical-ee")
- status = catch(:halt_check) do
+ status = catch(:halt_check) {
ce_branch_compat_check!
delete_ee_branches_locally!
ee_branch_presence_check!
step("Checking out #{ee_remote_with_branch}/#{ee_branch_found}", %W[git checkout -b #{ee_branch_found} #{ee_remote_with_branch}/#{ee_branch_found}])
- generate_patch(branch: ee_branch_found, patch_path: ee_patch_full_path, branch_remote: ee_remote_with_branch, master_remote: 'canonical-ee')
+ generate_patch(branch: ee_branch_found, patch_path: ee_patch_full_path, branch_remote: ee_remote_with_branch, master_remote: "canonical-ee")
ee_branch_compat_check!
- end
+ }
delete_ee_branches_locally!
@@ -80,10 +80,10 @@ module Gitlab
remotes =
{
- 'ee' => ee_repo_url,
- 'canonical-ee' => CANONICAL_EE_REPO_URL
+ "ee" => ee_repo_url,
+ "canonical-ee" => CANONICAL_EE_REPO_URL,
}
- remotes.delete('ee') unless fork?
+ remotes.delete("ee") unless fork?
@ee_remotes = remotes
end
@@ -142,7 +142,8 @@ module Gitlab
ee_remotes.keys.each do |remote|
output, _ = step(
"Searching #{remote}",
- %W[git ls-remote #{remote} *#{minimal_ee_branch_name}*])
+ %W[git ls-remote #{remote} *#{minimal_ee_branch_name}*]
+ )
branches =
output.scan(%r{(?<=refs/heads/|refs/tags/).+}).sort_by(&:size)
@@ -195,14 +196,12 @@ module Gitlab
puts output
unless status.zero?
- @failed_files = output.lines.reduce([]) do |memo, line|
- if line.start_with?('error: patch failed:')
- file = line.sub(/\Aerror: patch failed: /, '')
+ @failed_files = output.lines.each_with_object([]) { |line, memo|
+ if line.start_with?("error: patch failed:")
+ file = line.sub(/\Aerror: patch failed: /, "")
memo << file unless file =~ IGNORED_FILES_REGEX
end
-
- memo
- end
+ }
status = 0 if failed_files.empty?
end
@@ -235,20 +234,20 @@ module Gitlab
# In total we go (20 + 54 + 148 + 403 = 625) commits deeper
depth = 20
success =
- (3..6).any? do |factor|
+ (3..6).any? { |factor|
depth += Math.exp(factor).to_i
# Repository is initially cloned with a depth of 20 so we need to fetch
# deeper in the case the branch has more than 20 commits on top of master
fetch(branch: branch, depth: depth, remote: branch_remote)
- fetch(branch: 'master', depth: depth, remote: master_remote)
+ fetch(branch: "master", depth: depth, remote: master_remote)
merge_base_found?(branch: branch, branch_remote: branch_remote, master_remote: master_remote)
- end
+ }
raise "\n#{branch} is too far behind #{master_remote}/master, please rebase it!\n" unless success
end
- def fetch(branch:, depth:, remote: 'origin')
+ def fetch(branch:, depth:, remote: "origin")
step(
"Fetching deeper...",
%W[git fetch --depth=#{depth} --prune #{remote} +refs/heads/#{branch}:refs/remotes/#{remote}/#{branch}]
@@ -282,7 +281,7 @@ module Gitlab
end
def minimal_ee_branch_name
- @minimal_ee_branch_name ||= ce_branch.sub(/(\Ace\-|\-ce\z)/, '')
+ @minimal_ee_branch_name ||= ce_branch.sub(/(\Ace\-|\-ce\z)/, "")
end
def patch_name_from_branch(branch_name)
@@ -298,7 +297,7 @@ module Gitlab
if cmd
start = Time.now
- puts "\n$ #{cmd.join(' ')}"
+ puts "\n$ #{cmd.join(" ")}"
output, status = command(cmd)
puts "\n==> Finished in #{Time.now - start} seconds"
@@ -323,7 +322,7 @@ module Gitlab
end
def applies_cleanly_msg(branch)
- %Q{
+ %(
#{PLEASE_READ_THIS_BANNER}
🎉 Congratulations!! 🎉
@@ -332,19 +331,19 @@ module Gitlab
Much ❤️! For more information, see
https://docs.gitlab.com/ce/development/automatic_ce_ee_merge.html
#{THANKS_FOR_READING_BANNER}
- }
+ )
end
def ce_branch_doesnt_apply_cleanly_and_no_ee_branch_msg
ee_repos = ee_remotes.values.uniq
- %Q{
+ %(
#{PLEASE_READ_THIS_BANNER}
💥 Oh no! 💥
The `#{ce_branch}` branch does not apply cleanly to the current
EE/master, and no `#{ee_branch_prefix}` or `#{ee_branch_suffix}` branch
- was found in #{ee_repos.join(' nor in ')}.
+ was found in #{ee_repos.join(" nor in ")}.
If you're a community contributor, don't worry, someone from
GitLab Inc. will take care of this, and you don't have to do anything.
@@ -410,11 +409,11 @@ module Gitlab
#{STAY_STRONG_LINK_TO_DOCS}
#{THANKS_FOR_READING_BANNER}
- }
+ )
end
def ee_branch_doesnt_apply_cleanly_msg
- %Q{
+ %(
#{PLEASE_READ_THIS_BANNER}
💥 Oh no! 💥
@@ -430,7 +429,7 @@ module Gitlab
#{STAY_STRONG_LINK_TO_DOCS}
#{THANKS_FOR_READING_BANNER}
- }
+ )
end
def conflicting_files_msg
diff --git a/lib/gitlab/email/attachment_uploader.rb b/lib/gitlab/email/attachment_uploader.rb
index 3323ce60158..7e5d61b4294 100644
--- a/lib/gitlab/email/attachment_uploader.rb
+++ b/lib/gitlab/email/attachment_uploader.rb
@@ -18,9 +18,9 @@ module Gitlab
File.open(tmp.path, "w+b") { |f| f.write attachment.body.decoded }
file = {
- tempfile: tmp,
- filename: attachment.filename,
- content_type: attachment.content_type
+ tempfile: tmp,
+ filename: attachment.filename,
+ content_type: attachment.content_type,
}
uploader = UploadService.new(project, file).execute
diff --git a/lib/gitlab/email/handler.rb b/lib/gitlab/email/handler.rb
index cebedb19dcc..c8be5d66e35 100644
--- a/lib/gitlab/email/handler.rb
+++ b/lib/gitlab/email/handler.rb
@@ -12,7 +12,7 @@ module Gitlab
UnsubscribeHandler,
CreateNoteHandler,
CreateMergeRequestHandler,
- CreateIssueHandler
+ CreateIssueHandler,
]
end
diff --git a/lib/gitlab/email/handler/base_handler.rb b/lib/gitlab/email/handler/base_handler.rb
index f89d1d15010..a22473e0c3a 100644
--- a/lib/gitlab/email/handler/base_handler.rb
+++ b/lib/gitlab/email/handler/base_handler.rb
@@ -22,7 +22,7 @@ module Gitlab
end
def metrics_params
- { handler: self.class.name }
+ {handler: self.class.name}
end
end
end
diff --git a/lib/gitlab/email/handler/create_issue_handler.rb b/lib/gitlab/email/handler/create_issue_handler.rb
index 78a3a9489ac..3ac4d3e2c2b 100644
--- a/lib/gitlab/email/handler/create_issue_handler.rb
+++ b/lib/gitlab/email/handler/create_issue_handler.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'gitlab/email/handler/base_handler'
+require "gitlab/email/handler/base_handler"
# handles issue creation emails with these formats:
# incoming+gitlab-org-gitlab-ce-20-Author_Token12345678-issue@incoming.gitlab.com
@@ -17,7 +17,7 @@ module Gitlab
def initialize(mail, mail_key)
super(mail, mail_key)
- if !mail_key&.include?('/') && (matched = HANDLER_REGEX.match(mail_key.to_s))
+ if !mail_key&.include?("/") && (matched = HANDLER_REGEX.match(mail_key.to_s))
@project_slug = matched[:project_slug]
@project_id = matched[:project_id]&.to_i
@incoming_email_token = matched[:incoming_email_token]
@@ -39,7 +39,8 @@ module Gitlab
verify_record!(
record: create_issue,
invalid_exception: InvalidIssueError,
- record_name: 'issue')
+ record_name: "issue"
+ )
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -54,13 +55,13 @@ module Gitlab
Issues::CreateService.new(
project,
author,
- title: mail.subject,
+ title: mail.subject,
description: message_including_reply
).execute
end
def can_handle_legacy_format?
- project_path && !incoming_email_token.include?('+') && !mail_key.include?(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY)
+ project_path && !incoming_email_token.include?("+") && !mail_key.include?(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY)
end
end
end
diff --git a/lib/gitlab/email/handler/create_merge_request_handler.rb b/lib/gitlab/email/handler/create_merge_request_handler.rb
index b3b5063f2ca..dc7f8a5614e 100644
--- a/lib/gitlab/email/handler/create_merge_request_handler.rb
+++ b/lib/gitlab/email/handler/create_merge_request_handler.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'gitlab/email/handler/base_handler'
-require 'gitlab/email/handler/reply_processing'
+require "gitlab/email/handler/base_handler"
+require "gitlab/email/handler/reply_processing"
# handles merge request creation emails with these formats:
# incoming+gitlab-org-gitlab-ce-20-Author_Token12345678-merge-request@incoming.gitlab.com
@@ -18,7 +18,7 @@ module Gitlab
def initialize(mail, mail_key)
super(mail, mail_key)
- if !mail_key&.include?('/') && (matched = HANDLER_REGEX.match(mail_key.to_s))
+ if !mail_key&.include?("/") && (matched = HANDLER_REGEX.match(mail_key.to_s))
@project_slug = matched[:project_slug]
@project_id = matched[:project_id]&.to_i
@incoming_email_token = matched[:incoming_email_token]
@@ -41,7 +41,8 @@ module Gitlab
verify_record!(
record: create_merge_request,
invalid_exception: InvalidMergeRequestError,
- record_name: 'merge_request')
+ record_name: "merge_request"
+ )
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -82,7 +83,7 @@ module Gitlab
params = {
source_project_id: project.id,
source_branch: source_branch,
- target_project_id: project.id
+ target_project_id: project.id,
}
params[:description] = message if message.present?
params
@@ -92,8 +93,8 @@ module Gitlab
patches = patch_attachments.map { |patch| patch.body.decoded }
result = Commits::CommitPatchService
- .new(project, author, branch_name: source_branch, patches: patches, start_branch: start_branch)
- .execute
+ .new(project, author, branch_name: source_branch, patches: patches, start_branch: start_branch)
+ .execute
if result[:status] != :success
message = "Could not apply patches to #{source_branch}:\n#{result[:message]}"
@@ -110,8 +111,8 @@ module Gitlab
def patch_attachments
@patches ||= mail.attachments
- .select { |attachment| attachment.filename.ends_with?('.patch') }
- .sort_by(&:filename)
+ .select { |attachment| attachment.filename.ends_with?(".patch") }
+ .sort_by(&:filename)
end
def source_branch
diff --git a/lib/gitlab/email/handler/create_note_handler.rb b/lib/gitlab/email/handler/create_note_handler.rb
index b00af15364d..2efd59ebd84 100644
--- a/lib/gitlab/email/handler/create_note_handler.rb
+++ b/lib/gitlab/email/handler/create_note_handler.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'gitlab/email/handler/base_handler'
-require 'gitlab/email/handler/reply_processing'
+require "gitlab/email/handler/base_handler"
+require "gitlab/email/handler/reply_processing"
# handles note/reply creation emails with these formats:
# incoming+1234567890abcdef1234567890abcdef@incoming.gitlab.com
@@ -29,7 +29,8 @@ module Gitlab
verify_record!(
record: create_note,
invalid_exception: InvalidNoteError,
- record_name: 'comment')
+ record_name: "comment"
+ )
end
private
diff --git a/lib/gitlab/email/handler/reply_processing.rb b/lib/gitlab/email/handler/reply_processing.rb
index d8f4be8ada1..d959fc79afe 100644
--- a/lib/gitlab/email/handler/reply_processing.rb
+++ b/lib/gitlab/email/handler/reply_processing.rb
@@ -43,9 +43,9 @@ module Gitlab
def add_attachments(reply)
attachments = Email::AttachmentUploader.new(mail).execute(project)
- reply + attachments.map do |link|
+ reply + attachments.map { |link|
"\n\n#{link[:markdown]}"
- end.join
+ }.join
end
def validate_permission!(permission)
@@ -65,9 +65,9 @@ module Gitlab
error_title = "The #{record_name} could not be created for the following reasons:"
- msg = error_title + record.errors.full_messages.map do |error|
+ msg = error_title + record.errors.full_messages.map { |error|
"\n\n- #{error}"
- end.join
+ }.join
raise invalid_exception, msg
end
diff --git a/lib/gitlab/email/handler/unsubscribe_handler.rb b/lib/gitlab/email/handler/unsubscribe_handler.rb
index 20e4c125626..490dd6ad64d 100644
--- a/lib/gitlab/email/handler/unsubscribe_handler.rb
+++ b/lib/gitlab/email/handler/unsubscribe_handler.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'gitlab/email/handler/base_handler'
+require "gitlab/email/handler/base_handler"
# handles unsubscribe emails with these formats:
# incoming+1234567890abcdef1234567890abcdef-unsubscribe@incoming.gitlab.com
@@ -11,7 +11,7 @@ module Gitlab
class UnsubscribeHandler < BaseHandler
delegate :project, to: :sent_notification, allow_nil: true
- HANDLER_REGEX_FOR = -> (suffix) { /\A(?<reply_token>\w+)#{Regexp.escape(suffix)}\z/ }.freeze
+ HANDLER_REGEX_FOR = ->(suffix) { /\A(?<reply_token>\w+)#{Regexp.escape(suffix)}\z/ }.freeze
HANDLER_REGEX = HANDLER_REGEX_FOR.call(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX).freeze
HANDLER_REGEX_LEGACY = HANDLER_REGEX_FOR.call(Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY).freeze
diff --git a/lib/gitlab/email/hook/additional_headers_interceptor.rb b/lib/gitlab/email/hook/additional_headers_interceptor.rb
index aa2ef76069b..0039aa1b585 100644
--- a/lib/gitlab/email/hook/additional_headers_interceptor.rb
+++ b/lib/gitlab/email/hook/additional_headers_interceptor.rb
@@ -5,8 +5,8 @@ module Gitlab
module Hook
class AdditionalHeadersInterceptor
def self.delivering_email(message)
- message.header['Auto-Submitted'] ||= 'auto-generated'
- message.header['X-Auto-Response-Suppress'] ||= 'All'
+ message.header["Auto-Submitted"] ||= "auto-generated"
+ message.header["X-Auto-Response-Suppress"] ||= "All"
end
end
end
diff --git a/lib/gitlab/email/hook/delivery_metrics_observer.rb b/lib/gitlab/email/hook/delivery_metrics_observer.rb
index c7af485fcc5..47b8ef081a7 100644
--- a/lib/gitlab/email/hook/delivery_metrics_observer.rb
+++ b/lib/gitlab/email/hook/delivery_metrics_observer.rb
@@ -17,14 +17,14 @@ module Gitlab
def self.delivery_attempts_counter
strong_memoize(:delivery_attempts_counter) do
Gitlab::Metrics.counter(:gitlab_emails_delivery_attempts_total,
- 'Counter of total emails delivery attempts')
+ "Counter of total emails delivery attempts")
end
end
def self.delivered_emails_counter
strong_memoize(:delivered_emails_counter) do
Gitlab::Metrics.counter(:gitlab_emails_delivered_total,
- 'Counter of total emails delievered')
+ "Counter of total emails delievered")
end
end
end
diff --git a/lib/gitlab/email/hook/email_template_interceptor.rb b/lib/gitlab/email/hook/email_template_interceptor.rb
index 13f8db2051d..c44dab605cd 100644
--- a/lib/gitlab/email/hook/email_template_interceptor.rb
+++ b/lib/gitlab/email/hook/email_template_interceptor.rb
@@ -10,7 +10,7 @@ module Gitlab
def self.delivering_email(message)
unless Gitlab::CurrentSettings.html_emails_enabled
message.parts.delete_if do |part|
- part.content_type.start_with?('text/html')
+ part.content_type.start_with?("text/html")
end
end
end
diff --git a/lib/gitlab/email/html_parser.rb b/lib/gitlab/email/html_parser.rb
index 77f299bcade..ed580957990 100644
--- a/lib/gitlab/email/html_parser.rb
+++ b/lib/gitlab/email/html_parser.rb
@@ -17,13 +17,13 @@ module Gitlab
end
def filter_replies!
- document.xpath('//blockquote').each(&:remove)
- document.xpath('//table').each(&:remove)
+ document.xpath("//blockquote").each(&:remove)
+ document.xpath("//table").each(&:remove)
# bogus links with no href are sometimes added by outlook,
# and can result in Html2Text adding extra square brackets
# to the text, so we unwrap them here.
- document.xpath('//a[not(@href)]').each do |link|
+ document.xpath("//a[not(@href)]").each do |link|
link.replace(link.children)
end
end
diff --git a/lib/gitlab/email/message/repository_push.rb b/lib/gitlab/email/message/repository_push.rb
index ec412e7a8b1..42e6bd6c055 100644
--- a/lib/gitlab/email/message/repository_push.rb
+++ b/lib/gitlab/email/message/repository_push.rb
@@ -14,7 +14,7 @@ module Gitlab
delegate :username, to: :author, prefix: :author
def initialize(notify, project_id, opts = {})
- raise ArgumentError, 'Missing options: author_id, ref, action' unless
+ raise ArgumentError, "Missing options: author_id, ref, action" unless
opts[:author_id] && opts[:ref] && opts[:action]
@notify = notify
@@ -52,7 +52,7 @@ module Gitlab
end
def compare
- @opts[:compare] if @opts[:compare]
+ @opts[:compare]
end
def diff_refs
@@ -79,11 +79,11 @@ module Gitlab
@action_name ||=
case @action
when :create
- 'pushed new'
+ "pushed new"
when :delete
- 'deleted'
+ "deleted"
else
- 'pushed to'
+ "pushed to"
end
end
@@ -92,7 +92,7 @@ module Gitlab
end
def ref_type
- @ref_type ||= Gitlab::Git.tag_ref?(@ref) ? 'tag' : 'branch'
+ @ref_type ||= Gitlab::Git.tag_ref?(@ref) ? "tag" : "branch"
end
def target_url
@@ -118,10 +118,10 @@ module Gitlab
end
def subject
- subject_text = ['[Git]']
+ subject_text = ["[Git]"]
subject_text << "[#{project.full_path}]"
subject_text << "[#{ref_name}]" if @action == :push
- subject_text << ' '
+ subject_text << " "
if @action == :push && commits
if commits.length > 1
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index d28f6b301fa..20147deb0b2 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'gitlab/email/handler'
+require_dependency "gitlab/email/handler"
# Inspired in great part by Discourse's Email::Receiver
module Gitlab
@@ -98,12 +98,12 @@ module Gitlab
def ignore_auto_submitted!(mail)
# Mail::Header#[] is case-insensitive
- auto_submitted = mail.header['Auto-Submitted']&.value
+ auto_submitted = mail.header["Auto-Submitted"]&.value
# Mail::Field#value would strip leading and trailing whitespace
raise AutoGeneratedEmailError if
# See also https://tools.ietf.org/html/rfc3834
- auto_submitted && auto_submitted != 'no'
+ auto_submitted && auto_submitted != "no"
end
end
end
diff --git a/lib/gitlab/email/reply_parser.rb b/lib/gitlab/email/reply_parser.rb
index 2743f011ca6..d26ee83a161 100644
--- a/lib/gitlab/email/reply_parser.rb
+++ b/lib/gitlab/email/reply_parser.rb
@@ -20,15 +20,15 @@ module Gitlab
body = EmailReplyTrimmer.trim(body)
end
- return '' unless body
+ return "" unless body
# not using /\s+$/ here because that deletes empty lines
- body = body.gsub(/[ \t]$/, '')
+ body = body.gsub(/[ \t]$/, "")
# NOTE: We currently don't support empty quotes.
# EmailReplyTrimmer allows this as a special case,
# so we detect it manually here.
- return "" if body.lines.all? { |l| l.strip.empty? || l.start_with?('>') }
+ return "" if body.lines.all? { |l| l.strip.empty? || l.start_with?(">") }
body.force_encoding(encoding).encode("UTF-8")
end
@@ -48,11 +48,11 @@ module Gitlab
return "" unless decoded
# Certain trigger phrases that means we didn't parse correctly
- if decoded =~ %r{(Content\-Type\:|multipart/alternative|text/plain)}
+ if %r{(Content\-Type\:|multipart/alternative|text/plain)}.match?(decoded)
return ""
end
- if (part.content_type || '').include? 'text/html'
+ if (part.content_type || "").include? "text/html"
HTMLParser.parse_reply(decoded)
else
decoded
diff --git a/lib/gitlab/emoji.rb b/lib/gitlab/emoji.rb
index ce1dfb0753c..9c3ba1c10ea 100644
--- a/lib/gitlab/emoji.rb
+++ b/lib/gitlab/emoji.rb
@@ -21,7 +21,7 @@ module Gitlab
end
def emojis_aliases
- @emoji_aliases ||= JSON.parse(File.read(Rails.root.join('fixtures', 'emojis', 'aliases.json')))
+ @emoji_aliases ||= JSON.parse(File.read(Rails.root.join("fixtures", "emojis", "aliases.json")))
end
def emoji_filename(name)
@@ -52,17 +52,17 @@ module Gitlab
data = {
name: emoji_name,
- unicode_version: emoji_unicode_version(emoji_name)
+ unicode_version: emoji_unicode_version(emoji_name),
}
- ActionController::Base.helpers.content_tag('gl-emoji', emoji_info['moji'], title: emoji_info['description'], data: data)
+ ActionController::Base.helpers.content_tag("gl-emoji", emoji_info["moji"], title: emoji_info["description"], data: data)
end
private
def emoji_unicode_versions_by_name
@emoji_unicode_versions_by_name ||=
- JSON.parse(File.read(Rails.root.join('fixtures', 'emojis', 'emoji-unicode-version-map.json')))
+ JSON.parse(File.read(Rails.root.join("fixtures", "emojis", "emoji-unicode-version-map.json")))
end
end
end
diff --git a/lib/gitlab/encoding_helper.rb b/lib/gitlab/encoding_helper.rb
index a4a154c80f7..5dfbed77677 100644
--- a/lib/gitlab/encoding_helper.rb
+++ b/lib/gitlab/encoding_helper.rb
@@ -31,7 +31,7 @@ module Gitlab
# encode and clean the bad chars
message.replace clean(message)
rescue ArgumentError => e
- return unless e.message.include?('unknown encoding name')
+ return unless e.message.include?("unknown encoding name")
encoding = detect ? detect[:encoding] : "unknown"
"--broken encoding: #{encoding}"
@@ -57,11 +57,11 @@ module Gitlab
detect = CharlockHolmes::EncodingDetector.detect(message)
if detect && detect[:encoding]
begin
- CharlockHolmes::Converter.convert(message, detect[:encoding], 'UTF-8')
+ CharlockHolmes::Converter.convert(message, detect[:encoding], "UTF-8")
rescue ArgumentError => e
Rails.logger.warn("Ignoring error converting #{detect[:encoding]} into UTF8: #{e.message}")
- ''
+ ""
end
else
clean(message)
@@ -77,7 +77,7 @@ module Gitlab
end
def binary_stringio(str)
- StringIO.new(str.freeze || '').tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
+ StringIO.new(str.freeze || "").tap { |io| io.set_encoding(Encoding::ASCII_8BIT) }
end
private
diff --git a/lib/gitlab/environment.rb b/lib/gitlab/environment.rb
index b1a9603d3a5..8f4416de435 100644
--- a/lib/gitlab/environment.rb
+++ b/lib/gitlab/environment.rb
@@ -3,7 +3,7 @@
module Gitlab
module Environment
def self.hostname
- @hostname ||= ENV['HOSTNAME'] || Socket.gethostname
+ @hostname ||= ENV["HOSTNAME"] || Socket.gethostname
end
end
end
diff --git a/lib/gitlab/error_tracking/project.rb b/lib/gitlab/error_tracking/project.rb
index 93e81da5034..b98ffcf0007 100644
--- a/lib/gitlab/error_tracking/project.rb
+++ b/lib/gitlab/error_tracking/project.rb
@@ -7,7 +7,7 @@ module Gitlab
ACCESSORS = [
:id, :name, :status, :slug, :organization_name,
- :organization_id, :organization_slug
+ :organization_id, :organization_slug,
].freeze
attr_accessor(*ACCESSORS)
diff --git a/lib/gitlab/etag_caching/middleware.rb b/lib/gitlab/etag_caching/middleware.rb
index a11d6b66409..c39866132ff 100644
--- a/lib/gitlab/etag_caching/middleware.rb
+++ b/lib/gitlab/etag_caching/middleware.rb
@@ -15,7 +15,7 @@ module Gitlab
track_event(:etag_caching_middleware_used, route)
etag, cached_value_present = get_etag(request)
- if_none_match = env['HTTP_IF_NONE_MATCH']
+ if_none_match = env["HTTP_IF_NONE_MATCH"]
if if_none_match == etag
handle_cache_hit(etag, route)
@@ -23,7 +23,7 @@ module Gitlab
track_cache_miss(if_none_match, cached_value_present, route)
status, headers, body = @app.call(env)
- headers['ETag'] = etag
+ headers["ETag"] = etag
[status, headers, body]
end
end
@@ -44,7 +44,7 @@ module Gitlab
end
def weak_etag_format(value)
- %Q{W/"#{value}"}
+ %(W/"#{value}")
end
def handle_cache_hit(etag, route)
@@ -52,7 +52,7 @@ module Gitlab
status_code = Gitlab::PollingInterval.polling_enabled? ? 304 : 429
- [status_code, { 'ETag' => etag, 'X-Gitlab-From-Cache' => 'true' }, []]
+ [status_code, {"ETag" => etag, "X-Gitlab-From-Cache" => "true"}, []]
end
def track_cache_miss(if_none_match, cached_value_present, route)
diff --git a/lib/gitlab/etag_caching/router.rb b/lib/gitlab/etag_caching/router.rb
index 0891f79198d..76f7e5cfa90 100644
--- a/lib/gitlab/etag_caching/router.rb
+++ b/lib/gitlab/etag_caching/router.rb
@@ -18,49 +18,49 @@ module Gitlab
ROUTES = [
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/noteable/issue/\d+/notes\z),
- 'issue_notes'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/noteable/issue/\d+/notes\z},
+ "issue_notes"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/issues/\d+/realtime_changes\z),
- 'issue_title'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/issues/\d+/realtime_changes\z},
+ "issue_title"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/commit/\S+/pipelines\.json\z),
- 'commit_pipelines'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/commit/\S+/pipelines\.json\z},
+ "commit_pipelines"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/merge_requests/new\.json\z),
- 'new_merge_request_pipelines'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/merge_requests/new\.json\z},
+ "new_merge_request_pipelines"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/merge_requests/\d+/pipelines\.json\z),
- 'merge_request_pipelines'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/merge_requests/\d+/pipelines\.json\z},
+ "merge_request_pipelines"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/pipelines\.json\z),
- 'project_pipelines'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/pipelines\.json\z},
+ "project_pipelines"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/pipelines/\d+\.json\z),
- 'project_pipeline'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/pipelines/\d+\.json\z},
+ "project_pipeline"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/builds/\d+\.json\z),
- 'project_build'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/builds/\d+\.json\z},
+ "project_build"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/environments\.json\z),
- 'environments'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/environments\.json\z},
+ "environments"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/import/github/realtime_changes\.json\z),
- 'realtime_changes_import_github'
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/import/github/realtime_changes\.json\z},
+ "realtime_changes_import_github"
),
Gitlab::EtagCaching::Router::Route.new(
- %r(^(?!.*(#{RESERVED_WORDS_REGEX})).*/import/gitea/realtime_changes\.json\z),
- 'realtime_changes_import_gitea'
- )
+ %r{^(?!.*(#{RESERVED_WORDS_REGEX})).*/import/gitea/realtime_changes\.json\z},
+ "realtime_changes_import_gitea"
+ ),
].freeze
def self.match(path)
diff --git a/lib/gitlab/etag_caching/store.rb b/lib/gitlab/etag_caching/store.rb
index 2395e7be026..bac9fbba340 100644
--- a/lib/gitlab/etag_caching/store.rb
+++ b/lib/gitlab/etag_caching/store.rb
@@ -4,7 +4,7 @@ module Gitlab
module EtagCaching
class Store
EXPIRY_TIME = 20.minutes
- SHARED_STATE_NAMESPACE = 'etag:'.freeze
+ SHARED_STATE_NAMESPACE = "etag:"
def get(key)
Gitlab::Redis::SharedState.with { |redis| redis.get(redis_shared_state_key(key)) }
@@ -27,7 +27,7 @@ module Gitlab
end
def redis_shared_state_key(key)
- raise 'Invalid key' if !Rails.env.production? && !Gitlab::EtagCaching::Router.match(key)
+ raise "Invalid key" if !Rails.env.production? && !Gitlab::EtagCaching::Router.match(key)
"#{SHARED_STATE_NAMESPACE}#{key}"
end
diff --git a/lib/gitlab/exclusive_lease.rb b/lib/gitlab/exclusive_lease.rb
index d466d2a514c..665b5c9d941 100644
--- a/lib/gitlab/exclusive_lease.rb
+++ b/lib/gitlab/exclusive_lease.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module Gitlab
# This class implements an 'exclusive lease'. We call it a 'lease'
@@ -12,14 +12,14 @@ module Gitlab
# ExclusiveLease.
#
class ExclusiveLease
- LUA_CANCEL_SCRIPT = <<~EOS.freeze
+ LUA_CANCEL_SCRIPT = <<~EOS
local key, uuid = KEYS[1], ARGV[1]
if redis.call("get", key) == uuid then
redis.call("del", key)
end
EOS
- LUA_RENEW_SCRIPT = <<~EOS.freeze
+ LUA_RENEW_SCRIPT = <<~EOS
local key, uuid, ttl = KEYS[1], ARGV[1], ARGV[2]
if redis.call("get", key) == uuid then
redis.call("expire", key, ttl)
@@ -45,7 +45,7 @@ module Gitlab
# Removes any existing exclusive_lease from redis
# Don't run this in a live system without making sure no one is using the leases
- def self.reset_all!(scope = '*')
+ def self.reset_all!(scope = "*")
Gitlab::Redis::SharedState.with do |redis|
redis.scan_each(match: redis_shared_state_key(scope)).each do |key|
redis.del(key)
diff --git a/lib/gitlab/exclusive_lease_helpers.rb b/lib/gitlab/exclusive_lease_helpers.rb
index 7961d4bbd6e..441c37a9396 100644
--- a/lib/gitlab/exclusive_lease_helpers.rb
+++ b/lib/gitlab/exclusive_lease_helpers.rb
@@ -12,7 +12,7 @@ module Gitlab
# because it holds the connection until all `retries` is consumed.
# This could potentially eat up all connection pools.
def in_lock(key, ttl: 1.minute, retries: 10, sleep_sec: 0.01.seconds)
- raise ArgumentError, 'Key needs to be specified' unless key
+ raise ArgumentError, "Key needs to be specified" unless key
lease = Gitlab::ExclusiveLease.new(key, timeout: ttl)
@@ -23,7 +23,7 @@ module Gitlab
break if (retries -= 1) < 0
end
- raise FailedToObtainLockError, 'Failed to obtain a lock' unless uuid
+ raise FailedToObtainLockError, "Failed to obtain a lock" unless uuid
yield
ensure
diff --git a/lib/gitlab/fake_application_settings.rb b/lib/gitlab/fake_application_settings.rb
index bd806269bf0..4243accb1a8 100644
--- a/lib/gitlab/fake_application_settings.rb
+++ b/lib/gitlab/fake_application_settings.rb
@@ -10,11 +10,11 @@ module Gitlab
# Mimic ActiveRecord predicate methods for boolean values
def self.define_predicate_methods(options)
options.each do |key, value|
- next if key.to_s.end_with?('?')
+ next if key.to_s.end_with?("?")
next unless [true, false].include?(value)
define_method "#{key}?" do
- actual_key = key.to_s.chomp('?')
+ actual_key = key.to_s.chomp("?")
self[actual_key]
end
end
diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb
index 1ae2f9dfd93..c8b75bd7c3d 100644
--- a/lib/gitlab/favicon.rb
+++ b/lib/gitlab/favicon.rb
@@ -7,12 +7,12 @@ module Gitlab
image_name =
if appearance_favicon.exists?
appearance_favicon.url
- elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
- 'favicon-yellow.png'
+ elsif Gitlab::Utils.to_boolean(ENV["CANARY"])
+ "favicon-yellow.png"
elsif Rails.env.development?
- 'favicon-blue.png'
+ "favicon-blue.png"
else
- 'favicon.png'
+ "favicon.png"
end
ActionController::Base.helpers.image_path(image_name, host: host)
@@ -20,7 +20,7 @@ module Gitlab
def status_overlay(status_name)
path = File.join(
- 'ci_favicons',
+ "ci_favicons",
"#{status_name}.png"
)
@@ -29,8 +29,8 @@ module Gitlab
def available_status_names
@available_status_names ||= begin
- Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', '*.png'))
- .map { |file| File.basename(file, '.png') }
+ Dir.glob(Rails.root.join("app", "assets", "images", "ci_favicons", "*.png"))
+ .map { |file| File.basename(file, ".png") }
.sort
end
end
diff --git a/lib/gitlab/file_detector.rb b/lib/gitlab/file_detector.rb
index 2770469ca9f..0a2e72c741d 100644
--- a/lib/gitlab/file_detector.rb
+++ b/lib/gitlab/file_detector.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'set'
+require "set"
module Gitlab
# Module that can be used to detect if a path points to a special file such as
@@ -12,30 +12,30 @@ module Gitlab
changelog: %r{\A(changelog|history|changes|news)[^/]*\z}i,
license: %r{\A((un)?licen[sc]e|copying)(\.[^/]+)?\z}i,
contributing: %r{\Acontributing[^/]*\z}i,
- version: 'version',
+ version: "version",
avatar: /\Alogo\.(png|jpg|gif)\z/,
issue_template: %r{\A\.gitlab/issue_templates/[^/]+\.md\z},
merge_request_template: %r{\A\.gitlab/merge_request_templates/[^/]+\.md\z},
xcode_config: %r{\A[^/]*\.(xcodeproj|xcworkspace)(/.+)?\z},
# Configuration files
- gitignore: '.gitignore',
- gitlab_ci: '.gitlab-ci.yml',
- route_map: '.gitlab/route-map.yml',
+ gitignore: ".gitignore",
+ gitlab_ci: ".gitlab-ci.yml",
+ route_map: ".gitlab/route-map.yml",
# Dependency files
cartfile: %r{\ACartfile[^/]*\z},
- composer_json: 'composer.json',
+ composer_json: "composer.json",
gemfile: /\A(Gemfile|gems\.rb)\z/,
- gemfile_lock: 'Gemfile.lock',
+ gemfile_lock: "Gemfile.lock",
gemspec: %r{\A[^/]*\.gemspec\z},
- godeps_json: 'Godeps.json',
- package_json: 'package.json',
- podfile: 'Podfile',
+ godeps_json: "Godeps.json",
+ package_json: "package.json",
+ podfile: "Podfile",
podspec_json: %r{\A[^/]*\.podspec\.json\z},
podspec: %r{\A[^/]*\.podspec\z},
requirements_txt: %r{\A[^/]*requirements\.txt\z},
- yarn_lock: 'yarn.lock'
+ yarn_lock: "yarn.lock",
}.freeze
# Returns an Array of file types based on the given paths.
@@ -69,10 +69,10 @@ module Gitlab
def self.type_of(path)
PATTERNS.each do |type, search|
did_match = if search.is_a?(Regexp)
- path =~ search
- else
- path.casecmp(search) == 0
- end
+ path =~ search
+ else
+ path.casecmp(search) == 0
+ end
return type if did_match
end
diff --git a/lib/gitlab/file_finder.rb b/lib/gitlab/file_finder.rb
index 3958814208c..376c2f34787 100644
--- a/lib/gitlab/file_finder.rb
+++ b/lib/gitlab/file_finder.rb
@@ -14,11 +14,11 @@ module Gitlab
end
def find(query)
- query = Gitlab::Search::Query.new(query, encode_binary: true) do
+ query = Gitlab::Search::Query.new(query, encode_binary: true) {
filter :filename, matcher: ->(filter, blob) { blob.binary_filename =~ /#{filter[:regex_value]}$/i }
filter :path, matcher: ->(filter, blob) { blob.binary_filename =~ /#{filter[:regex_value]}/i }
filter :extension, matcher: ->(filter, blob) { blob.binary_filename =~ /\.#{filter[:regex_value]}$/i }
- end
+ }
files = find_by_filename(query.term) + find_by_content(query.term)
diff --git a/lib/gitlab/file_markdown_link_builder.rb b/lib/gitlab/file_markdown_link_builder.rb
index 180140e7da2..b698d1aa047 100644
--- a/lib/gitlab/file_markdown_link_builder.rb
+++ b/lib/gitlab/file_markdown_link_builder.rb
@@ -9,7 +9,7 @@ module Gitlab
def markdown_link
return unless name = markdown_name
- markdown = "[#{name.gsub(']', '\\]')}](#{secure_url})"
+ markdown = "[#{name.gsub("]", '\\]')}](#{secure_url})"
markdown = "!#{markdown}" if image_or_video? || dangerous?
markdown
end
diff --git a/lib/gitlab/file_type_detection.rb b/lib/gitlab/file_type_detection.rb
index 25ee07cf940..f0524dfcf46 100644
--- a/lib/gitlab/file_type_detection.rb
+++ b/lib/gitlab/file_type_detection.rb
@@ -36,7 +36,7 @@ module Gitlab
def extension_match?(extensions)
return false unless filename
- extension = File.extname(filename).delete('.')
+ extension = File.extname(filename).delete(".")
extensions.include?(extension.downcase)
end
end
diff --git a/lib/gitlab/fogbugz_import/client.rb b/lib/gitlab/fogbugz_import/client.rb
index dd747a79673..41a7c801a10 100644
--- a/lib/gitlab/fogbugz_import/client.rb
+++ b/lib/gitlab/fogbugz_import/client.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'fogbugz'
+require "fogbugz"
module Gitlab
module FogbugzImport
@@ -28,15 +28,15 @@ module Gitlab
def user_map
users = {}
res = @api.command(:listPeople)
- [res['people']['person']].flatten.each do |user|
- users[user['ixPerson']] = { name: user['sFullName'], email: user['sEmail'] }
+ [res["people"]["person"]].flatten.each do |user|
+ users[user["ixPerson"]] = {name: user["sFullName"], email: user["sEmail"]}
end
users
end
def repos
res = @api.command(:listProjects)
- @repos ||= res['projects']['project'].map { |proj| FogbugzImport::Repository.new(proj) }
+ @repos ||= res["projects"]["project"].map { |proj| FogbugzImport::Repository.new(proj) }
end
def repo(id)
@@ -45,10 +45,10 @@ module Gitlab
def cases(project_id)
project_name = repo(project_id).name
- res = @api.command(:search, q: "project:'#{project_name}'", cols: 'ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events')
- return [] unless res['cases']['count'].to_i > 0
+ res = @api.command(:search, q: "project:'#{project_name}'", cols: "ixPersonAssignedTo,ixPersonOpenedBy,ixPersonClosedBy,sStatus,sPriority,sCategory,fOpen,sTitle,sLatestTextSummary,dtOpened,dtClosed,dtResolved,dtLastUpdated,events")
+ return [] unless res["cases"]["count"].to_i > 0
- res['cases']['case']
+ res["cases"]["case"]
end
def categories
diff --git a/lib/gitlab/fogbugz_import/importer.rb b/lib/gitlab/fogbugz_import/importer.rb
index 431911d1eee..37aeaec60b5 100644
--- a/lib/gitlab/fogbugz_import/importer.rb
+++ b/lib/gitlab/fogbugz_import/importer.rb
@@ -9,7 +9,7 @@ module Gitlab
@project = project
import_data = project.import_data.try(:data)
- repo_data = import_data['repo'] if import_data
+ repo_data = import_data["repo"] if import_data
if repo_data
@repo = FogbugzImport::Repository.new(repo_data)
@known_labels = Set.new
@@ -34,14 +34,14 @@ module Gitlab
private
def fb_session
- @import_data_credentials ||= project.import_data.credentials[:fb_session] if project.import_data && project.import_data.credentials
+ @import_data_credentials ||= project.import_data.credentials[:fb_session] if project.import_data&.credentials
end
def user_map
@user_map ||= begin
- user_map = Hash.new
+ user_map = {}
import_data = project.import_data.try(:data)
- stored_user_map = import_data['user_map'] if import_data
+ stored_user_map = import_data["user_map"] if import_data
user_map.update(stored_user_map) if stored_user_map
user_map
@@ -49,35 +49,35 @@ module Gitlab
end
def import_labels
- @categories['categories']['category'].each do |label|
- create_label(label['sCategory'])
+ @categories["categories"]["category"].each do |label|
+ create_label(label["sCategory"])
@known_labels << name
end
end
def nice_label_color(name)
case name
- when 'Blocker'
- '#ff0000'
- when 'Crash'
- '#ffcfcf'
- when 'Major'
- '#deffcf'
- when 'Minor'
- '#cfe9ff'
- when 'Bug'
- '#d9534f'
- when 'Feature'
- '#44ad8e'
- when 'Technical Task'
- '#4b6dd0'
+ when "Blocker"
+ "#ff0000"
+ when "Crash"
+ "#ffcfcf"
+ when "Major"
+ "#deffcf"
+ when "Minor"
+ "#cfe9ff"
+ when "Bug"
+ "#d9534f"
+ when "Feature"
+ "#44ad8e"
+ when "Technical Task"
+ "#4b6dd0"
else
- '#e2e2e2'
+ "#e2e2e2"
end
end
def create_label(name)
- params = { title: name, color: nice_label_color(name) }
+ params = {title: name, color: nice_label_color(name)}
::Labels::FindOrCreateService.new(nil, project, params).execute(skip_authorization: true)
end
@@ -85,18 +85,18 @@ module Gitlab
def user_info(person_id)
user_hash = user_map[person_id.to_s]
- user_name = ''
+ user_name = ""
gitlab_id = nil
unless user_hash.nil?
- user_name = user_hash['name']
- if user = User.find_by(id: user_hash['gitlab_user'])
+ user_name = user_hash["name"]
+ if user = User.find_by(id: user_hash["gitlab_user"])
user_name = "@#{user.username}"
gitlab_id = user.id
end
end
- { name: user_name, gitlab_id: gitlab_id }
+ {name: user_name, gitlab_id: gitlab_id}
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -105,16 +105,16 @@ module Gitlab
return unless @cases
while bug = @cases.shift
- author = user_info(bug['ixPersonOpenedBy'])[:name]
- date = DateTime.parse(bug['dtOpened'])
+ author = user_info(bug["ixPersonOpenedBy"])[:name]
+ date = DateTime.parse(bug["dtOpened"])
- comments = bug['events']['event']
+ comments = bug["events"]["event"]
content = format_content(opened_content(comments))
body = format_issue_body(author, date, content)
labels = []
- [bug['sCategory'], bug['sPriority']].each do |label|
+ [bug["sCategory"], bug["sPriority"]].each do |label|
unless label.blank?
labels << label
@@ -125,19 +125,19 @@ module Gitlab
end
end
- assignee_id = user_info(bug['ixPersonAssignedTo'])[:gitlab_id]
- author_id = user_info(bug['ixPersonOpenedBy'])[:gitlab_id] || project.creator_id
+ assignee_id = user_info(bug["ixPersonAssignedTo"])[:gitlab_id]
+ author_id = user_info(bug["ixPersonOpenedBy"])[:gitlab_id] || project.creator_id
issue = Issue.create!(
- iid: bug['ixBug'],
- project_id: project.id,
- title: bug['sTitle'],
- description: body,
- author_id: author_id,
+ iid: bug["ixBug"],
+ project_id: project.id,
+ title: bug["sTitle"],
+ description: body,
+ author_id: author_id,
assignee_ids: [assignee_id],
- state: bug['fOpen'] == 'true' ? 'opened' : 'closed',
- created_at: date,
- updated_at: DateTime.parse(bug['dtLastUpdated'])
+ state: bug["fOpen"] == "true" ? "opened" : "closed",
+ created_at: date,
+ updated_at: DateTime.parse(bug["dtLastUpdated"])
)
issue_labels = ::LabelsFinder.new(nil, project_id: project.id, title: labels).execute(skip_authorization: true)
@@ -150,32 +150,32 @@ module Gitlab
def opened_content(comments)
while comment = comments.shift
- if comment['sVerb'] == 'Opened'
- return comment['s']
+ if comment["sVerb"] == "Opened"
+ return comment["s"]
end
end
- ''
+ ""
end
def import_issue_comments(issue, comments)
Note.transaction do
while comment = comments.shift
- verb = comment['sVerb']
+ verb = comment["sVerb"]
- next if verb == 'Opened'
+ next if verb == "Opened"
- content = format_content(comment['s'])
- attachments = format_attachments(comment['rgAttachments'])
+ content = format_content(comment["s"])
+ attachments = format_attachments(comment["rgAttachments"])
updates = format_updates(comment)
next if content.blank? && attachments.empty? && updates.empty?
- author = user_info(comment['ixPerson'])[:name]
- author_id = user_info(comment['ixPerson'])[:gitlab_id] || project.creator_id
- date = DateTime.parse(comment['dt'])
+ author = user_info(comment["ixPerson"])[:name]
+ author_id = user_info(comment["ixPerson"])[:gitlab_id] || project.creator_id
+ date = DateTime.parse(comment["dt"])
body = format_issue_comment_body(
- comment['ixBugEvent'],
+ comment["ixBugEvent"],
author,
date,
content,
@@ -184,11 +184,11 @@ module Gitlab
)
note = Note.create!(
- project_id: project.id,
- noteable_type: "Issue",
- noteable_id: issue.id,
- author_id: author_id,
- note: body
+ project_id: project.id,
+ noteable_type: "Issue",
+ noteable_id: issue.id,
+ author_id: author_id,
+ note: body
)
note.update_attribute(:created_at, date)
@@ -221,21 +221,21 @@ module Gitlab
def format_attachments(raw_attachments)
return [] unless raw_attachments
- attachments = case raw_attachments['attachment']
+ attachments = case raw_attachments["attachment"]
when Array
- raw_attachments['attachment']
+ raw_attachments["attachment"]
when Hash
- [raw_attachments['attachment']]
+ [raw_attachments["attachment"]]
else
[]
- end
+ end
attachments.map! { |a| format_attachment(a) }
attachments.compact
end
def format_attachment(attachment)
- link = build_attachment_url(attachment['sURL'])
+ link = build_attachment_url(attachment["sURL"])
res = ::Projects::DownloadService.new(project, link).execute
@@ -253,12 +253,12 @@ module Gitlab
def format_updates(comment)
updates = []
- if comment['sChanges']
- updates << "*Changes: #{linkify_issues(comment['sChanges'].chomp)}*"
+ if comment["sChanges"]
+ updates << "*Changes: #{linkify_issues(comment["sChanges"].chomp)}*"
end
- if comment['evtDescription']
- updates << "*#{comment['evtDescription']}*"
+ if comment["evtDescription"]
+ updates << "*#{comment["evtDescription"]}*"
end
updates
@@ -267,10 +267,10 @@ module Gitlab
def format_issue_body(author, date, content)
body = []
body << "*By #{author} on #{date} (imported from FogBugz)*"
- body << '---'
+ body << "---"
if content.blank?
- content = '*(No description has been entered for this issue)*'
+ content = "*(No description has been entered for this issue)*"
end
body << content
@@ -281,7 +281,7 @@ module Gitlab
def format_issue_comment_body(id, author, date, content, attachments, updates)
body = []
body << "*By #{author} on #{date} (imported from FogBugz)*"
- body << '---'
+ body << "---"
if content.blank?
content = "*(No comment has been entered for this change)*"
@@ -290,12 +290,12 @@ module Gitlab
body << content
if updates.any?
- body << '---'
+ body << "---"
body += updates
end
if attachments.any?
- body << '---'
+ body << "---"
body += attachments
end
diff --git a/lib/gitlab/fogbugz_import/project_creator.rb b/lib/gitlab/fogbugz_import/project_creator.rb
index 3c71031a8d9..c5bbe2faa6a 100644
--- a/lib/gitlab/fogbugz_import/project_creator.rb
+++ b/lib/gitlab/fogbugz_import/project_creator.rb
@@ -21,10 +21,10 @@ module Gitlab
namespace: namespace,
creator: current_user,
visibility_level: Gitlab::VisibilityLevel::INTERNAL,
- import_type: 'fogbugz',
+ import_type: "fogbugz",
import_source: repo.name,
import_url: Project::UNKNOWN_IMPORT_URL,
- import_data: { data: { 'repo' => repo.raw_data, 'user_map' => user_map }, credentials: { fb_session: fb_session } }
+ import_data: {data: {"repo" => repo.raw_data, "user_map" => user_map}, credentials: {fb_session: fb_session}}
).execute
end
end
diff --git a/lib/gitlab/fogbugz_import/repository.rb b/lib/gitlab/fogbugz_import/repository.rb
index b958dcf6cbf..f20921b3c8d 100644
--- a/lib/gitlab/fogbugz_import/repository.rb
+++ b/lib/gitlab/fogbugz_import/repository.rb
@@ -14,19 +14,19 @@ module Gitlab
end
def id
- raw_data['ixProject']
+ raw_data["ixProject"]
end
def name
- raw_data['sProject']
+ raw_data["sProject"]
end
def safe_name
- name.gsub(/[^\s\w.-]/, '')
+ name.gsub(/[^\s\w.-]/, "")
end
def path
- safe_name.gsub(/[\s]/, '_')
+ safe_name.gsub(/[\s]/, "_")
end
end
end
diff --git a/lib/gitlab/gfm/reference_rewriter.rb b/lib/gitlab/gfm/reference_rewriter.rb
index 4d82acd9d87..56704bdacb5 100644
--- a/lib/gitlab/gfm/reference_rewriter.rb
+++ b/lib/gitlab/gfm/reference_rewriter.rb
@@ -75,7 +75,7 @@ module Gitlab
def find_referable(reference)
extractor = Gitlab::ReferenceExtractor.new(@source_parent,
- @current_user)
+ @current_user)
extractor.analyze(reference)
extractor.all.first
end
diff --git a/lib/gitlab/gfm/uploads_rewriter.rb b/lib/gitlab/gfm/uploads_rewriter.rb
index 2d1c9ac40ae..835d47a7600 100644
--- a/lib/gitlab/gfm/uploads_rewriter.rb
+++ b/lib/gitlab/gfm/uploads_rewriter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'fileutils'
+require "fileutils"
module Gitlab
module Gfm
@@ -36,9 +36,9 @@ module Gitlab
end
def files
- referenced_files = @text.scan(@pattern).map do
+ referenced_files = @text.scan(@pattern).map {
find_file(@source_project, $~[:secret], $~[:file])
- end
+ }
referenced_files.compact.select(&:exists?)
end
diff --git a/lib/gitlab/git.rb b/lib/gitlab/git.rb
index 44a62586a23..f1a444a13c5 100644
--- a/lib/gitlab/git.rb
+++ b/lib/gitlab/git.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require_dependency 'gitlab/encoding_helper'
+require_dependency "gitlab/encoding_helper"
module Gitlab
module Git
# The ID of empty tree.
# See http://stackoverflow.com/a/40884093/1856239 and
# https://github.com/git/git/blob/3ad8b5bf26362ac67c9020bf8c30eee54a84f56d/cache.h#L1011-L1012
- EMPTY_TREE_ID = '4b825dc642cb6eb9a060e54bf8d69288fbee4904'.freeze
- BLANK_SHA = ('0' * 40).freeze
- TAG_REF_PREFIX = "refs/tags/".freeze
- BRANCH_REF_PREFIX = "refs/heads/".freeze
+ EMPTY_TREE_ID = "4b825dc642cb6eb9a060e54bf8d69288fbee4904"
+ BLANK_SHA = ("0" * 40).freeze
+ TAG_REF_PREFIX = "refs/tags/"
+ BRANCH_REF_PREFIX = "refs/heads/"
BaseError = Class.new(StandardError)
CommandError = Class.new(BaseError)
@@ -22,15 +22,13 @@ module Gitlab
include Gitlab::EncodingHelper
def ref_name(ref)
- encode!(ref).sub(%r{\Arefs/(tags|heads|remotes)/}, '')
+ encode!(ref).sub(%r{\Arefs/(tags|heads|remotes)/}, "")
end
def branch_name(ref)
ref = ref.to_s
- if self.branch_ref?(ref)
- self.ref_name(ref)
- else
- nil
+ if branch_ref?(ref)
+ ref_name(ref)
end
end
@@ -40,16 +38,14 @@ module Gitlab
{
email: email,
name: name,
- time: Time.now
+ time: Time.now,
}
end
def tag_name(ref)
ref = ref.to_s
- if self.tag_ref?(ref)
- self.ref_name(ref)
- else
- nil
+ if tag_ref?(ref)
+ ref_name(ref)
end
end
@@ -70,7 +66,7 @@ module Gitlab
end
def check_namespace!(*objects)
- expected_namespace = self.name + '::'
+ expected_namespace = name + "::"
objects.each do |object|
unless object.class.name.start_with?(expected_namespace)
raise ArgumentError, "expected object in #{expected_namespace}, got #{object}"
diff --git a/lib/gitlab/git/attributes_at_ref_parser.rb b/lib/gitlab/git/attributes_at_ref_parser.rb
index cbddf836ce8..5b2b8290966 100644
--- a/lib/gitlab/git/attributes_at_ref_parser.rb
+++ b/lib/gitlab/git/attributes_at_ref_parser.rb
@@ -7,7 +7,7 @@ module Gitlab
delegate :attributes, to: :@parser
def initialize(repository, ref)
- blob = repository.blob_at(ref, '.gitattributes')
+ blob = repository.blob_at(ref, ".gitattributes")
@parser = AttributesParser.new(blob&.data)
end
diff --git a/lib/gitlab/git/attributes_parser.rb b/lib/gitlab/git/attributes_parser.rb
index 8b9d74ae8e7..a719357a958 100644
--- a/lib/gitlab/git/attributes_parser.rb
+++ b/lib/gitlab/git/attributes_parser.rb
@@ -15,7 +15,7 @@ module Gitlab
#
# Returns a Hash.
def attributes(file_path)
- absolute_path = File.join('/', file_path)
+ absolute_path = File.join("/", file_path)
patterns.each do |pattern, attrs|
return attrs if File.fnmatch?(pattern, absolute_path)
@@ -42,9 +42,9 @@ module Gitlab
# Returns a Hash containing the attributes and their values.
def parse_attributes(string)
values = {}
- dash = '-'
- equal = '='
- binary = 'binary'
+ dash = "-"
+ equal = "="
+ binary = "binary"
string.split(/\s+/).each do |chunk|
# Data such as "foo = bar" should be treated as "foo" and "bar" being
@@ -72,7 +72,7 @@ module Gitlab
# When the "binary" option is set the "diff" option should be set to
# the inverse. If "diff" is later set it should overwrite the
# automatically set value.
- values['diff'] = false if key == binary && value
+ values["diff"] = false if key == binary && value
end
values
@@ -92,7 +92,7 @@ module Gitlab
# Parses the Git attributes file contents.
def parse_data
pairs = []
- comment = '#'
+ comment = "#"
each_line do |line|
next if line.start_with?(comment) || line.empty?
@@ -101,7 +101,7 @@ module Gitlab
parsed = attrs ? parse_attributes(attrs) : {}
- absolute_pattern = File.join('/', pattern)
+ absolute_pattern = File.join("/", pattern)
pairs << [absolute_pattern, parsed]
end
diff --git a/lib/gitlab/git/blob.rb b/lib/gitlab/git/blob.rb
index 259a2b7911a..f2070fe15ca 100644
--- a/lib/gitlab/git/blob.rb
+++ b/lib/gitlab/git/blob.rb
@@ -25,8 +25,8 @@ module Gitlab
def find(repository, sha, path, limit: MAX_DATA_DISPLAY_SIZE)
return unless path
- path = path.sub(%r{\A/*}, '')
- path = '/' if path.empty?
+ path = path.sub(%r{\A/*}, "")
+ path = "/" if path.empty?
name = File.basename(path)
# Gitaly will think that setting the limit to 0 means unlimited, while
@@ -43,7 +43,7 @@ module Gitlab
case entry.type
when :COMMIT
- new(id: entry.oid, name: name, size: 0, data: '', path: path, commit_id: sha)
+ new(id: entry.oid, name: name, size: 0, data: "", path: path, commit_id: sha)
when :BLOB
new(id: entry.oid, name: name, size: entry.size, data: entry.data.dup, mode: entry.mode.to_s(8),
path: path, commit_id: sha, binary: binary?(entry.data))
@@ -91,8 +91,8 @@ module Gitlab
end
def initialize(options)
- %w(id name path size data mode commit_id binary).each do |key|
- self.__send__("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend
+ %w[id name path size data mode commit_id binary].each do |key|
+ __send__("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend
end
# Retain the actual size before it is encoded
@@ -111,7 +111,7 @@ module Gitlab
# Load all blob data (not just the first MAX_DATA_DISPLAY_SIZE bytes) into
# memory as a Ruby string.
def load_all_data!(repository)
- return if @data == '' # don't mess with submodule blobs
+ return if @data == "" # don't mess with submodule blobs
# Even if we return early, recalculate wether this blob is binary in
# case a blob was initialized as text but the full data isn't
@@ -169,7 +169,7 @@ module Gitlab
:lfs
end
- alias_method :external_size, :lfs_size
+ alias external_size lfs_size
private
diff --git a/lib/gitlab/git/branch.rb b/lib/gitlab/git/branch.rb
index 9447cfa0fb6..465ecc24430 100644
--- a/lib/gitlab/git/branch.rb
+++ b/lib/gitlab/git/branch.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def active?
- self.dereferenced_target.committed_date >= STALE_BRANCH_THRESHOLD.ago
+ dereferenced_target.committed_date >= STALE_BRANCH_THRESHOLD.ago
end
def stale?
diff --git a/lib/gitlab/git/bundle_file.rb b/lib/gitlab/git/bundle_file.rb
index 8384a436fcc..c6c18600f57 100644
--- a/lib/gitlab/git/bundle_file.rb
+++ b/lib/gitlab/git/bundle_file.rb
@@ -21,9 +21,9 @@ module Gitlab
end
def check!
- data = File.open(filename, 'r') { |f| f.read(MAGIC.size) }
+ data = File.open(filename, "r") { |f| f.read(MAGIC.size) }
- raise InvalidBundleError, 'Invalid bundle file' unless data == MAGIC
+ raise InvalidBundleError, "Invalid bundle file" unless data == MAGIC
end
end
end
diff --git a/lib/gitlab/git/commit.rb b/lib/gitlab/git/commit.rb
index 5863815ca85..4c5f4a27ced 100644
--- a/lib/gitlab/git/commit.rb
+++ b/lib/gitlab/git/commit.rb
@@ -14,7 +14,7 @@ module Gitlab
SERIALIZE_KEYS = [
:id, :message, :parent_ids,
:authored_date, :author_name, :author_email,
- :committed_date, :committer_name, :committer_email
+ :committed_date, :committer_name, :committer_email,
].freeze
attr_accessor *SERIALIZE_KEYS # rubocop:disable Lint/AmbiguousOperator
@@ -39,7 +39,7 @@ module Gitlab
#
def where(options)
repo = options.delete(:repo)
- raise 'Gitlab::Git::Repository is required' unless repo.respond_to?(:log)
+ raise "Gitlab::Git::Repository is required" unless repo.respond_to?(:log)
repo.log(options)
end
@@ -60,11 +60,11 @@ module Gitlab
return nil unless commit_id.is_a?(String)
# This saves us an RPC round trip.
- return nil if commit_id.include?(':')
+ return nil if commit_id.include?(":")
- commit = wrapped_gitaly_errors do
+ commit = wrapped_gitaly_errors {
repo.gitaly_commit_client.find_commit(commit_id)
- end
+ }
decorate(repo, commit) if commit
rescue Gitlab::Git::CommandError, Gitlab::Git::Repository::NoRepository, ArgumentError
diff --git a/lib/gitlab/git/conflict/file.rb b/lib/gitlab/git/conflict/file.rb
index 7ffe4a7ae81..33d4c7fd176 100644
--- a/lib/gitlab/git/conflict/file.rb
+++ b/lib/gitlab/git/conflict/file.rb
@@ -23,18 +23,18 @@ module Gitlab
return @lines if defined?(@lines)
begin
- @type = 'text'
+ @type = "text"
@lines = Gitlab::Git::Conflict::Parser.parse(content,
- our_path: our_path,
- their_path: their_path)
+ our_path: our_path,
+ their_path: their_path)
rescue Gitlab::Git::Conflict::Parser::ParserError
- @type = 'text-editor'
+ @type = "text-editor"
@lines = nil
end
end
def content
- @content ||= @raw_content.dup.force_encoding('UTF-8')
+ @content ||= @raw_content.dup.force_encoding("UTF-8")
raise UnsupportedEncoding unless @content.valid_encoding?
@@ -66,7 +66,7 @@ module Gitlab
def resolve_lines(resolution)
section_id = nil
- lines.map do |line|
+ lines.map { |line|
unless line[:type]
section_id = nil
next line
@@ -75,16 +75,16 @@ module Gitlab
section_id ||= line_code(line)
case resolution[section_id]
- when 'head'
- next unless line[:type] == 'new'
- when 'origin'
- next unless line[:type] == 'old'
+ when "head"
+ next unless line[:type] == "new"
+ when "origin"
+ next unless line[:type] == "old"
else
raise Gitlab::Git::Conflict::Resolver::ResolutionError, "Missing resolution for section ID: #{section_id}"
end
line
- end.compact
+ }.compact
end
def resolve_content(resolution)
diff --git a/lib/gitlab/git/conflict/parser.rb b/lib/gitlab/git/conflict/parser.rb
index 20de8ebde4e..6e7c05b34f2 100644
--- a/lib/gitlab/git/conflict/parser.rb
+++ b/lib/gitlab/git/conflict/parser.rb
@@ -23,7 +23,7 @@ module Gitlab
type = nil
lines = []
conflict_start = "<<<<<<< #{our_path}"
- conflict_middle = '======='
+ conflict_middle = "======="
conflict_end = ">>>>>>> #{their_path}"
text.each_line.map do |line|
@@ -32,23 +32,23 @@ module Gitlab
if full_line == conflict_start
validate_delimiter!(type.nil?)
- type = 'new'
+ type = "new"
elsif full_line == conflict_middle
- validate_delimiter!(type == 'new')
+ validate_delimiter!(type == "new")
- type = 'old'
+ type = "old"
elsif full_line == conflict_end
- validate_delimiter!(type == 'old')
+ validate_delimiter!(type == "old")
type = nil
elsif line[0] == '\\'
- type = 'nonewline'
+ type = "nonewline"
lines << {
full_line: full_line,
type: type,
line_obj_index: line_obj_index,
line_old: line_old,
- line_new: line_new
+ line_new: line_new,
}
else
lines << {
@@ -56,11 +56,11 @@ module Gitlab
type: type,
line_obj_index: line_obj_index,
line_old: line_old,
- line_new: line_new
+ line_new: line_new,
}
- line_old += 1 if type != 'new'
- line_new += 1 if type != 'old'
+ line_old += 1 if type != "new"
+ line_new += 1 if type != "old"
line_obj_index += 1
end
diff --git a/lib/gitlab/git/conflict/resolver.rb b/lib/gitlab/git/conflict/resolver.rb
index 26e82643a4c..ec5bb1d054d 100644
--- a/lib/gitlab/git/conflict/resolver.rb
+++ b/lib/gitlab/git/conflict/resolver.rb
@@ -16,9 +16,9 @@ module Gitlab
end
def conflicts
- @conflicts ||= wrapped_gitaly_errors do
+ @conflicts ||= wrapped_gitaly_errors {
gitaly_conflicts_client(@target_repository).list_conflict_files.to_a
- end
+ }
rescue GRPC::FailedPrecondition => e
raise Gitlab::Git::Conflict::Resolver::ConflictSideMissing.new(e.message)
rescue GRPC::BadStatus => e
diff --git a/lib/gitlab/git/diff.rb b/lib/gitlab/git/diff.rb
index 74a4633424f..df9818ed20d 100644
--- a/lib/gitlab/git/diff.rb
+++ b/lib/gitlab/git/diff.rb
@@ -12,14 +12,14 @@ module Gitlab
# Stats properties
attr_accessor :new_file, :renamed_file, :deleted_file
- alias_method :new_file?, :new_file
- alias_method :deleted_file?, :deleted_file
- alias_method :renamed_file?, :renamed_file
+ alias new_file? new_file
+ alias deleted_file? deleted_file
+ alias renamed_file? renamed_file
attr_accessor :expanded
attr_writer :too_large
- alias_method :expanded?, :expanded
+ alias expanded? expanded
# The default maximum content size to display a diff patch.
#
@@ -31,24 +31,24 @@ module Gitlab
# persisting limits over that.
MAX_PATCH_BYTES_UPPER_BOUND = 500.kilobytes
- SERIALIZE_KEYS = %i(diff new_path old_path a_mode b_mode new_file renamed_file deleted_file too_large).freeze
+ SERIALIZE_KEYS = %i[diff new_path old_path a_mode b_mode new_file renamed_file deleted_file too_large].freeze
class << self
def between(repo, head, base, options = {}, *paths)
straight = options.delete(:straight) || false
common_commit = if straight
- base
- else
- # Only show what is new in the source branch
- # compared to the target branch, not the other way
- # around. The linex below with merge_base is
- # equivalent to diff with three dots (git diff
- # branch1...branch2) From the git documentation:
- # "git diff A...B" is equivalent to "git diff
- # $(git-merge-base A B) B"
- repo.merge_base(head, base)
- end
+ base
+ else
+ # Only show what is new in the source branch
+ # compared to the target branch, not the other way
+ # around. The linex below with merge_base is
+ # equivalent to diff with three dots (git diff
+ # branch1...branch2) From the git documentation:
+ # "git diff A...B" is equivalent to "git diff
+ # $(git-merge-base A B) B"
+ repo.merge_base(head, base)
+ end
options ||= {}
actual_options = filter_diff_options(options)
@@ -79,7 +79,7 @@ module Gitlab
# exceeded
def filter_diff_options(options, default_options = {})
allowed_options = [:ignore_whitespace_change, :max_files, :max_lines,
- :limits, :expanded]
+ :limits, :expanded,]
if default_options
actual_defaults = default_options.dup
@@ -167,7 +167,7 @@ module Gitlab
end
def submodule?
- a_mode == '160000' || b_mode == '160000'
+ a_mode == "160000" || b_mode == "160000"
end
def line_count
@@ -183,10 +183,10 @@ module Gitlab
end
# This is used by `to_hash` and `init_from_hash`.
- alias_method :too_large, :too_large?
+ alias too_large too_large?
def too_large!
- @diff = ''
+ @diff = ""
@line_count = 0
@too_large = true
end
@@ -198,7 +198,7 @@ module Gitlab
end
def collapse!
- @diff = ''
+ @diff = ""
@line_count = 0
@collapsed = true
end
@@ -211,7 +211,7 @@ module Gitlab
end
def has_binary_notice?
- @diff.start_with?('Binary')
+ @diff.start_with?("Binary")
end
private
diff --git a/lib/gitlab/git/diff_collection.rb b/lib/gitlab/git/diff_collection.rb
index 5c70cb6c66c..88907203a93 100644
--- a/lib/gitlab/git/diff_collection.rb
+++ b/lib/gitlab/git/diff_collection.rb
@@ -7,7 +7,7 @@ module Gitlab
class DiffCollection
include Enumerable
- DEFAULT_LIMITS = { max_files: 100, max_lines: 5000 }.freeze
+ DEFAULT_LIMITS = {max_files: 100, max_lines: 5000}.freeze
attr_reader :limits
@@ -36,7 +36,7 @@ module Gitlab
@byte_count = 0
@overflow = false
@empty = true
- @array = Array.new
+ @array = []
end
def each(&block)
@@ -88,7 +88,7 @@ module Gitlab
collection
end
- alias_method :to_ary, :to_a
+ alias to_ary to_a
private
diff --git a/lib/gitlab/git/gitmodules_parser.rb b/lib/gitlab/git/gitmodules_parser.rb
index 575e12390cd..7d877c28b74 100644
--- a/lib/gitlab/git/gitmodules_parser.rb
+++ b/lib/gitlab/git/gitmodules_parser.rb
@@ -27,7 +27,7 @@ module Gitlab
# In some .gitmodules files (e.g. nodegit's), a header
# with the same name appears multiple times; we want to
# accumulate the configs across these
- @current_submodule = @result[section] || { 'name' => section }
+ @current_submodule = @result[section] || {"name" => section}
@result[section] = @current_submodule
end
@@ -72,7 +72,7 @@ module Gitlab
# If a submodule doesn't have a path, it is considered bogus
# and is ignored
submodules_by_name.each_with_object({}) do |(name, data), results|
- path = data.delete 'path'
+ path = data.delete "path"
next unless path
results[path] = data
diff --git a/lib/gitlab/git/lfs_pointer_file.rb b/lib/gitlab/git/lfs_pointer_file.rb
index b7019a221ac..efd84e30ad9 100644
--- a/lib/gitlab/git/lfs_pointer_file.rb
+++ b/lib/gitlab/git/lfs_pointer_file.rb
@@ -3,8 +3,8 @@
module Gitlab
module Git
class LfsPointerFile
- VERSION = "https://git-lfs.github.com/spec/v1".freeze
- VERSION_LINE = "version #{VERSION}".freeze
+ VERSION = "https://git-lfs.github.com/spec/v1"
+ VERSION_LINE = "version #{VERSION}"
def initialize(data)
@data = data
diff --git a/lib/gitlab/git/merge_base.rb b/lib/gitlab/git/merge_base.rb
index b27f7038c26..d85553e2f89 100644
--- a/lib/gitlab/git/merge_base.rb
+++ b/lib/gitlab/git/merge_base.rb
@@ -31,7 +31,7 @@ module Gitlab
# the repository, and thus cannot be used to find a merge base.
def unknown_refs
@unknown_refs ||= Hash[@refs.zip(commits_for_refs)]
- .select { |ref, commit| commit.nil? }.keys
+ .select { |ref, commit| commit.nil? }.keys
end
private
diff --git a/lib/gitlab/git/operation_service.rb b/lib/gitlab/git/operation_service.rb
index 8797d3dce24..6107daeca5f 100644
--- a/lib/gitlab/git/operation_service.rb
+++ b/lib/gitlab/git/operation_service.rb
@@ -3,7 +3,7 @@
module Gitlab
module Git
class OperationService
- BranchUpdate = Struct.new(:newrev, :repo_created, :branch_created) do
+ BranchUpdate = Struct.new(:newrev, :repo_created, :branch_created) {
alias_method :repo_created?, :repo_created
alias_method :branch_created?, :branch_created
@@ -16,7 +16,7 @@ module Gitlab
branch_update.branch_created
)
end
- end
+ }
end
end
end
diff --git a/lib/gitlab/git/patches/collection.rb b/lib/gitlab/git/patches/collection.rb
index ad6b5d32abc..5830ef2eeb4 100644
--- a/lib/gitlab/git/patches/collection.rb
+++ b/lib/gitlab/git/patches/collection.rb
@@ -7,9 +7,9 @@ module Gitlab
MAX_PATCH_SIZE = 2.megabytes
def initialize(one_or_more_patches)
- @patches = Array(one_or_more_patches).map do |patch_content|
+ @patches = Array(one_or_more_patches).map { |patch_content|
Gitlab::Git::Patches::Patch.new(patch_content)
- end
+ }
end
def content
diff --git a/lib/gitlab/git/path_helper.rb b/lib/gitlab/git/path_helper.rb
index e3a2031eeca..68c8b52b546 100644
--- a/lib/gitlab/git/path_helper.rb
+++ b/lib/gitlab/git/path_helper.rb
@@ -8,11 +8,11 @@ module Gitlab
class << self
def normalize_path(filename)
# Strip all leading slashes so that //foo -> foo
- filename = filename.sub(%r{\A/*}, '')
+ filename = filename.sub(%r{\A/*}, "")
# Expand relative paths (e.g. foo/../bar)
filename = Pathname.new(filename)
- filename.relative_path_from(Pathname.new(''))
+ filename.relative_path_from(Pathname.new(""))
end
end
end
diff --git a/lib/gitlab/git/pre_receive_error.rb b/lib/gitlab/git/pre_receive_error.rb
index 03caace6fce..8fd378bf571 100644
--- a/lib/gitlab/git/pre_receive_error.rb
+++ b/lib/gitlab/git/pre_receive_error.rb
@@ -7,7 +7,7 @@ module Gitlab
# in the web UI. To prevent XSS we sanitize the message on
# initialization.
class PreReceiveError < StandardError
- def initialize(msg = '')
+ def initialize(msg = "")
super(nlbr(msg))
end
diff --git a/lib/gitlab/git/push.rb b/lib/gitlab/git/push.rb
index b6577ba17f1..def088616dc 100644
--- a/lib/gitlab/git/push.rb
+++ b/lib/gitlab/git/push.rb
@@ -44,7 +44,7 @@ module Gitlab
def modified_paths
unless branch_updated?
- raise ArgumentError, 'Unable to calculate modified paths!'
+ raise ArgumentError, "Unable to calculate modified paths!"
end
strong_memoize(:modified_paths) do
diff --git a/lib/gitlab/git/raw_diff_change.rb b/lib/gitlab/git/raw_diff_change.rb
index e1002af40f6..43aac9d3508 100644
--- a/lib/gitlab/git/raw_diff_change.rb
+++ b/lib/gitlab/git/raw_diff_change.rb
@@ -29,7 +29,7 @@ module Gitlab
# When a file has been renamed:
# 85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee
def parse(raw_change)
- @blob_id, @blob_size, @raw_operation, raw_paths = raw_change.split(' ', 4)
+ @blob_id, @blob_size, @raw_operation, raw_paths = raw_change.split(" ", 4)
@blob_size = @blob_size.to_i
@operation = extract_operation
@old_path, @new_path = extract_paths(raw_paths)
@@ -52,17 +52,17 @@ module Gitlab
return :unknown unless @raw_operation
case @raw_operation[0]
- when 'A'
+ when "A"
:added
- when 'C'
+ when "C"
:copied
- when 'D'
+ when "D"
:deleted
- when 'M'
+ when "M"
:modified
- when 'R'
+ when "R"
:renamed
- when 'T'
+ when "T"
:type_changed
else
:unknown
diff --git a/lib/gitlab/git/ref.rb b/lib/gitlab/git/ref.rb
index eec91194949..ea0d162ec59 100644
--- a/lib/gitlab/git/ref.rb
+++ b/lib/gitlab/git/ref.rb
@@ -23,21 +23,19 @@ module Gitlab
# Ex.
# Ref.extract_branch_name('refs/heads/master') #=> 'master'
def self.extract_branch_name(str)
- str.gsub(%r{\Arefs/heads/}, '')
+ str.gsub(%r{\Arefs/heads/}, "")
end
def initialize(repository, name, target, dereferenced_target)
@name = Gitlab::Git.ref_name(name)
@dereferenced_target = dereferenced_target
@target = if target.respond_to?(:oid)
- target.oid
- elsif target.respond_to?(:name)
- target.name
- elsif target.is_a? String
- target
- else
- nil
- end
+ target.oid
+ elsif target.respond_to?(:name)
+ target.name
+ elsif target.is_a? String
+ target
+ end
end
end
end
diff --git a/lib/gitlab/git/remote_repository.rb b/lib/gitlab/git/remote_repository.rb
index 234541d8145..2f03330d5ef 100644
--- a/lib/gitlab/git/remote_repository.rb
+++ b/lib/gitlab/git/remote_repository.rb
@@ -54,18 +54,18 @@ module Gitlab
end
def fetch_env
- gitaly_ssh = File.absolute_path(File.join(Gitlab.config.gitaly.client_path, 'gitaly-ssh'))
+ gitaly_ssh = File.absolute_path(File.join(Gitlab.config.gitaly.client_path, "gitaly-ssh"))
gitaly_address = gitaly_client.address(storage)
gitaly_token = gitaly_client.token(storage)
request = Gitaly::SSHUploadPackRequest.new(repository: gitaly_repository)
env = {
- 'GITALY_ADDRESS' => gitaly_address,
- 'GITALY_PAYLOAD' => request.to_json,
- 'GITALY_WD' => Dir.pwd,
- 'GIT_SSH_COMMAND' => "#{gitaly_ssh} upload-pack"
+ "GITALY_ADDRESS" => gitaly_address,
+ "GITALY_PAYLOAD" => request.to_json,
+ "GITALY_WD" => Dir.pwd,
+ "GIT_SSH_COMMAND" => "#{gitaly_ssh} upload-pack",
}
- env['GITALY_TOKEN'] = gitaly_token if gitaly_token.present?
+ env["GITALY_TOKEN"] = gitaly_token if gitaly_token.present?
env
end
diff --git a/lib/gitlab/git/repository.rb b/lib/gitlab/git/repository.rb
index aea132a3dd9..9f6580c1c81 100644
--- a/lib/gitlab/git/repository.rb
+++ b/lib/gitlab/git/repository.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'tempfile'
-require 'forwardable'
+require "tempfile"
+require "forwardable"
require "rubygems/package"
module Gitlab
@@ -17,11 +17,11 @@ module Gitlab
# In https://gitlab.com/gitlab-org/gitaly/merge_requests/698
# We copied these two prefixes into gitaly-go, so don't change these
# or things will break! (REBASE_WORKTREE_PREFIX and SQUASH_WORKTREE_PREFIX)
- REBASE_WORKTREE_PREFIX = 'rebase'.freeze
- SQUASH_WORKTREE_PREFIX = 'squash'.freeze
- GITALY_INTERNAL_URL = 'ssh://gitaly/internal.git'.freeze
+ REBASE_WORKTREE_PREFIX = "rebase"
+ SQUASH_WORKTREE_PREFIX = "squash"
+ GITALY_INTERNAL_URL = "ssh://gitaly/internal.git"
GITLAB_PROJECTS_TIMEOUT = Gitlab.config.gitlab_shell.git_timeout
- EMPTY_REPOSITORY_CHECKSUM = '0000000000000000000000000000000000000000'.freeze
+ EMPTY_REPOSITORY_CHECKSUM = "0000000000000000000000000000000000000000"
NoRepository = Class.new(StandardError)
InvalidRepository = Class.new(StandardError)
@@ -35,7 +35,7 @@ module Gitlab
class << self
def create_hooks(repo_path, global_hooks_path)
- local_hooks_path = File.join(repo_path, 'hooks')
+ local_hooks_path = File.join(repo_path, "hooks")
real_local_hooks_path = :not_found
begin
@@ -50,7 +50,8 @@ module Gitlab
# Move the existing hooks somewhere safe
FileUtils.mv(
local_hooks_path,
- "#{local_hooks_path}.old.#{Time.now.to_i}")
+ "#{local_hooks_path}.old.#{Time.now.to_i}"
+ )
end
# Create the hooks symlink
@@ -74,7 +75,7 @@ module Gitlab
# has to be performed on the object pools to update the remote names.
# Else the pool can't be updated anymore and is left in an inconsistent
# state.
- alias_method :object_pool_remote_name, :gl_repository
+ alias object_pool_remote_name gl_repository
# This initializer method is only used on the client side (gitlab-ce).
# Gitaly-ruby uses a different initializer.
@@ -91,7 +92,7 @@ module Gitlab
other.is_a?(self.class) && [storage, relative_path] == [other.storage, other.relative_path]
end
- alias_method :eql?, :==
+ alias eql? ==
def hash
[self.class, storage, relative_path].hash
@@ -168,7 +169,7 @@ module Gitlab
# /refs/git-as-svn/*
# /refs/pulls/*
# This refs by default not visible in project page and not cloned to client side.
- alias_method :has_visible_content?, :has_local_branches?
+ alias has_visible_content? has_local_branches?
# Returns the number of valid tags
def tag_count
@@ -238,10 +239,10 @@ module Gitlab
prefix = archive_prefix(ref, commit.id, project_path, append_sha: append_sha)
{
- 'ArchivePrefix' => prefix,
- 'ArchivePath' => archive_file_path(storage_path, commit.id, prefix, format),
- 'CommitId' => commit.id,
- 'GitalyRepository' => gitaly_repository.to_h
+ "ArchivePrefix" => prefix,
+ "ArchivePath" => archive_file_path(storage_path, commit.id, prefix, format),
+ "CommitId" => commit.id,
+ "GitalyRepository" => gitaly_repository.to_h,
}
end
@@ -250,12 +251,12 @@ module Gitlab
def archive_prefix(ref, sha, project_path, append_sha:)
append_sha = (ref != sha) if append_sha.nil?
- formatted_ref = ref.tr('/', '-')
+ formatted_ref = ref.tr("/", "-")
prefix_segments = [project_path, formatted_ref]
prefix_segments << sha if append_sha
- prefix_segments.join('-')
+ prefix_segments.join("-")
end
private :archive_prefix
@@ -291,7 +292,7 @@ module Gitlab
end
file_name = "#{name}.#{extension}"
- File.join(storage_path, self.gl_repository, sha, file_name)
+ File.join(storage_path, gl_repository, sha, file_name)
end
private :archive_file_path
@@ -321,7 +322,7 @@ module Gitlab
skip_merges: false,
after: nil,
before: nil,
- all: false
+ all: false,
}
options = default_options.merge(options)
@@ -417,9 +418,9 @@ module Gitlab
return [] unless root_sha
- branches = wrapped_gitaly_errors do
+ branches = wrapped_gitaly_errors {
gitaly_merged_branch_names(branch_names, root_sha)
- end
+ }
Set.new(branches)
end
@@ -439,9 +440,9 @@ module Gitlab
return empty_diff_stats
end
- stats = wrapped_gitaly_errors do
+ stats = wrapped_gitaly_errors {
gitaly_commit_client.diff_stats(left_id, right_id)
- end
+ }
Gitlab::Git::DiffStatsCollection.new(stats)
rescue CommandError, TypeError
@@ -581,7 +582,7 @@ module Gitlab
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
- start_repository: start_repository
+ start_repository: start_repository,
}
wrapped_gitaly_errors do
@@ -596,7 +597,7 @@ module Gitlab
branch_name: branch_name,
message: message,
start_branch_name: start_branch_name,
- start_repository: start_repository
+ start_repository: start_repository,
}
wrapped_gitaly_errors do
@@ -610,7 +611,7 @@ module Gitlab
submodule: submodule,
commit_sha: commit_sha,
branch: branch,
- message: message
+ message: message,
}
wrapped_gitaly_errors do
@@ -753,7 +754,7 @@ module Gitlab
end
# Refactoring aid; allows us to copy code from app/models/repository.rb
- def commit(ref = 'HEAD')
+ def commit(ref = "HEAD")
Gitlab::Git::Commit.find(self, ref)
end
@@ -818,10 +819,10 @@ module Gitlab
def rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:)
wrapped_gitaly_errors do
gitaly_operation_client.user_rebase(user, rebase_id,
- branch: branch,
- branch_sha: branch_sha,
- remote_repository: remote_repository,
- remote_branch: remote_branch)
+ branch: branch,
+ branch_sha: branch_sha,
+ remote_repository: remote_repository,
+ remote_branch: remote_branch)
end
end
@@ -834,7 +835,7 @@ module Gitlab
def squash(user, squash_id, branch:, start_sha:, end_sha:, author:, message:)
wrapped_gitaly_errors do
gitaly_operation_client.user_squash(user, squash_id, branch,
- start_sha, end_sha, author, message)
+ start_sha, end_sha, author, message)
end
end
@@ -855,12 +856,13 @@ module Gitlab
def multi_action(
user, branch_name:, message:, actions:,
author_email: nil, author_name: nil,
- start_branch_name: nil, start_repository: self)
+ start_branch_name: nil, start_repository: self
+ )
wrapped_gitaly_errors do
gitaly_operation_client.user_commit_files(user, branch_name,
- message, actions, author_email, author_name,
- start_branch_name, start_repository)
+ message, actions, author_email, author_name,
+ start_branch_name, start_repository)
end
end
@@ -868,9 +870,9 @@ module Gitlab
return unless full_path.present?
# This guard avoids Gitaly log/error spam
- raise NoRepository, 'repository does not exist' unless exists?
+ raise NoRepository, "repository does not exist" unless exists?
- set_config('gitlab.fullpath' => full_path)
+ set_config("gitlab.fullpath" => full_path)
end
def set_config(entries)
@@ -925,7 +927,7 @@ module Gitlab
Rails.logger.error("Unable to clean repository on storage #{storage} with relative path #{relative_path}: #{e.message}")
Gitlab::Metrics.counter(
:failed_repository_cleanup_total,
- 'Number of failed repository cleanup events'
+ "Number of failed repository cleanup events"
).increment
end
@@ -1038,12 +1040,12 @@ module Gitlab
return unless commit_object && commit_object.type == :COMMIT
- gitmodules = gitaly_commit_client.tree_entry(ref, '.gitmodules', Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
+ gitmodules = gitaly_commit_client.tree_entry(ref, ".gitmodules", Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE)
return unless gitmodules
found_module = GitmodulesParser.new(gitmodules.data).parse[path]
- found_module && found_module['url']
+ found_module && found_module["url"]
end
# Returns true if the given ref name exists
diff --git a/lib/gitlab/git/tag.rb b/lib/gitlab/git/tag.rb
index 23d989ff258..881061760d9 100644
--- a/lib/gitlab/git/tag.rb
+++ b/lib/gitlab/git/tag.rb
@@ -68,7 +68,7 @@ module Gitlab
return @raw_tag.message.dup if full_message_fetched_from_gitaly?
if @raw_tag.message_size > MAX_TAG_MESSAGE_DISPLAY_SIZE
- '--tag message is too big'
+ "--tag message is too big"
else
self.class.get_message(@repository, target)
end
diff --git a/lib/gitlab/git/tree.rb b/lib/gitlab/git/tree.rb
index 51542bcaaa2..60e066e268e 100644
--- a/lib/gitlab/git/tree.rb
+++ b/lib/gitlab/git/tree.rb
@@ -16,7 +16,7 @@ module Gitlab
#
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/320
def where(repository, sha, path = nil, recursive = false)
- path = nil if path == '' || path == '/'
+ path = nil if path == "" || path == "/"
wrapped_gitaly_errors do
repository.gitaly_commit_client.tree_entries(repository, sha, path, recursive)
@@ -38,17 +38,17 @@ module Gitlab
#
def find_id_by_path(repository, root_id, path)
root_tree = repository.lookup(root_id)
- path_arr = path.split('/')
+ path_arr = path.split("/")
- entry = root_tree.find do |entry|
+ entry = root_tree.find { |entry|
entry[:name] == path_arr[0] && entry[:type] == :tree
- end
+ }
return nil unless entry
if path_arr.size > 1
path_arr.shift
- find_id_by_path(repository, entry[:oid], path_arr.join('/'))
+ find_id_by_path(repository, entry[:oid], path_arr.join("/"))
else
entry[:oid]
end
@@ -56,8 +56,8 @@ module Gitlab
end
def initialize(options)
- %w(id root_id name path flat_path type mode commit_id).each do |key|
- self.send("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend
+ %w[id root_id name path flat_path type mode commit_id].each do |key|
+ send("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend
end
end
diff --git a/lib/gitlab/git/util.rb b/lib/gitlab/git/util.rb
index 03c2c1367b0..cf8571bf917 100644
--- a/lib/gitlab/git/util.rb
+++ b/lib/gitlab/git/util.rb
@@ -5,7 +5,7 @@
module Gitlab
module Git
module Util
- LINE_SEP = "\n".freeze
+ LINE_SEP = "\n"
def self.count_lines(string)
case string[-1]
diff --git a/lib/gitlab/git/wiki.rb b/lib/gitlab/git/wiki.rb
index c43331bed60..9aa8c8ae8fd 100644
--- a/lib/gitlab/git/wiki.rb
+++ b/lib/gitlab/git/wiki.rb
@@ -10,21 +10,21 @@ module Gitlab
DEFAULT_PAGINATION = Kaminari.config.default_per_page
- CommitDetails = Struct.new(:user_id, :username, :name, :email, :message) do
+ CommitDetails = Struct.new(:user_id, :username, :name, :email, :message) {
def to_h
- { user_id: user_id, username: username, name: name, email: email, message: message }
+ {user_id: user_id, username: username, name: name, email: email, message: message}
end
- end
+ }
# GollumSlug inlines just enough knowledge from Gollum::Page to generate a
# slug, which is used when previewing pages that haven't been persisted
class GollumSlug
class << self
- def cname(name, char_white_sub = '-', char_other_sub = '-')
+ def cname(name, char_white_sub = "-", char_other_sub = "-")
if name.respond_to?(:gsub)
name.gsub(/\s/, char_white_sub).gsub(/[<>+]/, char_other_sub)
else
- ''
+ ""
end
end
@@ -33,22 +33,22 @@ module Gitlab
end
def canonicalize_filename(filename)
- ::File.basename(filename, ::File.extname(filename)).tr('-', ' ')
+ ::File.basename(filename, ::File.extname(filename)).tr("-", " ")
end
def generate(title, format)
ext = format_to_ext(format.to_sym)
- name = cname(title) + '.' + ext
+ name = cname(title) + "." + ext
canonical_name = canonicalize_filename(name)
path =
- if name.include?('/')
- name.sub(%r{/[^/]+$}, '/')
+ if name.include?("/")
+ name.sub(%r{/[^/]+$}, "/")
else
- ''
+ ""
end
- path + cname(canonical_name, '-', '-')
+ path + cname(canonical_name, "-", "-")
end
end
end
@@ -56,7 +56,7 @@ module Gitlab
attr_reader :repository
def self.default_ref
- 'master'
+ "master"
end
# Initialize with a Gitlab::Git::Repository instance
@@ -109,9 +109,9 @@ module Gitlab
# :per_page - The number of items per page.
# :limit - Total number of items to return.
def page_versions(page_path, options = {})
- versions = wrapped_gitaly_errors do
+ versions = wrapped_gitaly_errors {
gitaly_wiki_client.page_versions(page_path, options)
- end
+ }
# Gitaly uses gollum-lib to get the versions. Gollum defaults to 20
# per page, but also fetches 20 if `limit` or `per_page` < 20.
@@ -121,7 +121,7 @@ module Gitlab
end
def count_page_versions(page_path)
- @repository.count_commits(ref: 'HEAD', path: page_path)
+ @repository.count_commits(ref: "HEAD", path: page_path)
end
def preview_slug(title, format)
diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb
index 010bd0e520c..bff3c2f576d 100644
--- a/lib/gitlab/git_access.rb
+++ b/lib/gitlab/git_access.rb
@@ -14,22 +14,22 @@ module Gitlab
# Use the magic string '_any' to indicate we do not know what the
# changes are. This is also what gitlab-shell does.
- ANY = '_any'
+ ANY = "_any"
ERROR_MESSAGES = {
- upload: 'You are not allowed to upload code for this project.',
- download: 'You are not allowed to download code from this project.',
- auth_upload: 'You are not allowed to upload code.',
- auth_download: 'You are not allowed to download code.',
- deploy_key_upload: 'This deploy key does not have write access to this project.',
- no_repo: 'A repository for this project does not exist yet.',
- project_not_found: 'The project you were looking for could not be found.',
+ upload: "You are not allowed to upload code for this project.",
+ download: "You are not allowed to download code from this project.",
+ auth_upload: "You are not allowed to upload code.",
+ auth_download: "You are not allowed to download code.",
+ deploy_key_upload: "This deploy key does not have write access to this project.",
+ no_repo: "A repository for this project does not exist yet.",
+ project_not_found: "The project you were looking for could not be found.",
command_not_allowed: "The command you're trying to execute is not allowed.",
- upload_pack_disabled_over_http: 'Pulling over HTTP is not allowed.',
- receive_pack_disabled_over_http: 'Pushing over HTTP is not allowed.',
- read_only: 'The repository is temporarily read-only. Please try again later.',
+ upload_pack_disabled_over_http: "Pulling over HTTP is not allowed.",
+ receive_pack_disabled_over_http: "Pushing over HTTP is not allowed.",
+ read_only: "The repository is temporarily read-only. Please try again later.",
cannot_push_to_read_only: "You can't push code to a read-only GitLab instance.",
- push_code: 'You are not allowed to push code to this project.'
+ push_code: "You are not allowed to push code to this project.",
}.freeze
INTERNAL_TIMEOUT = 50.seconds.freeze
@@ -39,8 +39,8 @@ module Gitlab
Timing information for debugging purposes:
MESSAGE
- DOWNLOAD_COMMANDS = %w{git-upload-pack git-upload-archive}.freeze
- PUSH_COMMANDS = %w{git-receive-pack}.freeze
+ DOWNLOAD_COMMANDS = %w[git-upload-pack git-upload-archive].freeze
+ PUSH_COMMANDS = %w[git-receive-pack].freeze
ALL_COMMANDS = DOWNLOAD_COMMANDS + PUSH_COMMANDS
attr_reader :actor, :project, :protocol, :authentication_abilities, :namespace_path, :project_path, :redirected_path, :auth_result_type, :changes, :logger
@@ -101,7 +101,7 @@ module Gitlab
end
def request_from_ci_build?
- return false unless protocol == 'http'
+ return false unless protocol == "http"
auth_result_type == :build || auth_result_type == :ci
end
@@ -213,13 +213,13 @@ module Gitlab
project_params = {
path: project_path,
namespace_id: namespace.id,
- visibility_level: Gitlab::VisibilityLevel::PRIVATE
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE,
}
project = Projects::CreateService.new(user, project_params).execute
unless project.saved?
- raise ProjectCreationError, "Could not create project: #{project.errors.full_messages.join(', ')}"
+ raise ProjectCreationError, "Could not create project: #{project.errors.full_messages.join(", ")}"
end
@project = project
@@ -340,15 +340,15 @@ module Gitlab
end
def http?
- protocol == 'http'
+ protocol == "http"
end
def upload_pack?(command)
- command == 'git-upload-pack'
+ command == "git-upload-pack"
end
def receive_pack?(command)
- command == 'git-receive-pack'
+ command == "git-receive-pack"
end
def upload_pack_disabled_over_http?
@@ -383,12 +383,12 @@ module Gitlab
def user_access
@user_access ||= if ci?
- CiAccess.new
- elsif user && request_from_ci_build?
- BuildAccess.new(user, project: project)
- else
- UserAccess.new(user, project: project)
- end
+ CiAccess.new
+ elsif user && request_from_ci_build?
+ BuildAccess.new(user, project: project)
+ else
+ UserAccess.new(user, project: project)
+ end
end
def push_to_read_only_message
diff --git a/lib/gitlab/git_access_wiki.rb b/lib/gitlab/git_access_wiki.rb
index 0af91957fa8..7d43c468265 100644
--- a/lib/gitlab/git_access_wiki.rb
+++ b/lib/gitlab/git_access_wiki.rb
@@ -3,8 +3,8 @@
module Gitlab
class GitAccessWiki < GitAccess
ERROR_MESSAGES = {
- read_only: "You can't push code to a read-only GitLab instance.",
- write_to_wiki: "You are not allowed to write to this project's wiki."
+ read_only: "You can't push code to a read-only GitLab instance.",
+ write_to_wiki: "You are not allowed to write to this project's wiki.",
}.freeze
def guest_can_download_code?
diff --git a/lib/gitlab/git_logger.rb b/lib/gitlab/git_logger.rb
index dac4ddd320f..667d6581268 100644
--- a/lib/gitlab/git_logger.rb
+++ b/lib/gitlab/git_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class GitLogger < Gitlab::Logger
def self.file_name_noext
- 'githost'
+ "githost"
end
def format_message(severity, timestamp, progname, msg)
diff --git a/lib/gitlab/git_post_receive.rb b/lib/gitlab/git_post_receive.rb
index 426436c2164..7d98cb6191e 100644
--- a/lib/gitlab/git_post_receive.rb
+++ b/lib/gitlab/git_post_receive.rb
@@ -21,7 +21,7 @@ module Gitlab
changes.each do |change|
change.strip!
- oldrev, newrev, ref = change.split(' ')
+ oldrev, newrev, ref = change.split(" ")
yield oldrev, newrev, ref
end
@@ -34,14 +34,14 @@ module Gitlab
end
def utf8_encode_changes(changes)
- changes.force_encoding('UTF-8')
+ changes.force_encoding("UTF-8")
return changes if changes.valid_encoding?
# Convert non-UTF-8 branch/tag names to UTF-8 so they can be dumped as JSON.
detection = CharlockHolmes::EncodingDetector.detect(changes)
return changes unless detection && detection[:encoding]
- CharlockHolmes::Converter.convert(changes, detection[:encoding], 'UTF-8')
+ CharlockHolmes::Converter.convert(changes, detection[:encoding], "UTF-8")
end
end
end
diff --git a/lib/gitlab/git_ref_validator.rb b/lib/gitlab/git_ref_validator.rb
index 3f13ebeb9d0..370fb1601ce 100644
--- a/lib/gitlab/git_ref_validator.rb
+++ b/lib/gitlab/git_ref_validator.rb
@@ -9,9 +9,9 @@ module Gitlab
#
# Returns true for a valid reference name, false otherwise
def validate(ref_name)
- not_allowed_prefixes = %w(refs/heads/ refs/remotes/ -)
+ not_allowed_prefixes = %w[refs/heads/ refs/remotes/ -]
return false if ref_name.start_with?(*not_allowed_prefixes)
- return false if ref_name == 'HEAD'
+ return false if ref_name == "HEAD"
begin
Rugged::Reference.valid_name?("refs/heads/#{ref_name}")
diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb
index 5aeedb0f50d..43aef43b58e 100644
--- a/lib/gitlab/gitaly_client.rb
+++ b/lib/gitlab/gitaly_client.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'base64'
+require "base64"
-require 'gitaly'
-require 'grpc/health/v1/health_pb'
-require 'grpc/health/v1/health_services_pb'
+require "gitaly"
+require "grpc/health/v1/health_pb"
+require "grpc/health/v1/health_services_pb"
module Gitlab
module GitalyClient
@@ -27,9 +27,9 @@ module Gitlab
end
PEM_REGEX = /\-+BEGIN CERTIFICATE\-+.+?\-+END CERTIFICATE\-+/m
- SERVER_VERSION_FILE = 'GITALY_SERVER_VERSION'
+ SERVER_VERSION_FILE = "GITALY_SERVER_VERSION"
MAXIMUM_GITALY_CALLS = 30
- CLIENT_NAME = (Sidekiq.server? ? 'gitlab-sidekiq' : 'gitlab-web').freeze
+ CLIENT_NAME = (Sidekiq.server? ? "gitlab-sidekiq" : "gitlab-web").freeze
MUTEX = Mutex.new
@@ -73,21 +73,21 @@ module Gitlab
def self.stub_certs
return @certs if @certs
- @certs = stub_cert_paths.flat_map do |cert_file|
- File.read(cert_file).scan(PEM_REGEX).map do |cert|
- begin
+ @certs = stub_cert_paths.flat_map { |cert_file|
+ File.read(cert_file).scan(PEM_REGEX).map { |cert|
+
OpenSSL::X509::Certificate.new(cert).to_pem
rescue OpenSSL::OpenSSLError => e
Rails.logger.error "Could not load certificate #{cert_file} #{e}"
- Gitlab::Sentry.track_exception(e, extra: { cert_file: cert_file })
+ Gitlab::Sentry.track_exception(e, extra: {cert_file: cert_file})
nil
- end
- end.compact
- end.uniq.join("\n")
+
+ }.compact
+ }.uniq.join("\n")
end
def self.stub_creds(storage)
- if URI(address(storage)).scheme == 'tls'
+ if URI(address(storage)).scheme == "tls"
GRPC::Core::ChannelCredentials.new stub_certs
else
:this_channel_is_insecure
@@ -103,7 +103,7 @@ module Gitlab
end
def self.stub_address(storage)
- address(storage).sub(%r{^tcp://|^tls://}, '')
+ address(storage).sub(%r{^tcp://|^tls://}, "")
end
def self.clear_stubs!
@@ -120,12 +120,12 @@ module Gitlab
params = Gitlab.config.repositories.storages[storage]
raise "storage not found: #{storage.inspect}" if params.nil?
- address = params['gitaly_address']
+ address = params["gitaly_address"]
unless address.present?
raise "storage #{storage.inspect} is missing a gitaly_address"
end
- unless URI(address).scheme.in?(%w(tcp unix tls))
+ unless URI(address).scheme.in?(%w[tcp unix tls])
raise "Unsupported Gitaly address: #{address.inspect} does not use URL scheme 'tcp' or 'unix' or 'tls'"
end
@@ -137,7 +137,7 @@ module Gitlab
end
def self.connection_data(storage)
- { 'address' => address(storage), 'token' => token(storage) }
+ {"address" => address(storage), "token" => token(storage)}
end
# All Gitaly RPC call sites should use GitalyClient.call. This method
@@ -173,14 +173,15 @@ module Gitlab
self.query_time += duration
gitaly_controller_action_duration_seconds.observe(
current_transaction_labels.merge(gitaly_service: service.to_s, rpc: rpc.to_s),
- duration)
+ duration
+)
add_call_details(feature: "#{service}##{rpc}", duration: duration, request: request_hash, rpc: rpc)
end
def self.handle_grpc_unavailable!(ex)
status = ex.to_status
- raise ex unless status.details == 'Endpoint read failed'
+ raise ex unless status.details == "Endpoint read failed"
# There is a bug in grpc 1.8.x that causes a client process to get stuck
# always raising '14:Endpoint read failed'. The only thing that we can
@@ -192,7 +193,7 @@ module Gitlab
raise Gitlab::SidekiqMiddleware::Shutdown::WantShutdown.new(ex.to_s)
else
# SIGQUIT requests a Unicorn worker to shut down gracefully after the current request.
- Process.kill('QUIT', Process.pid)
+ Process.kill("QUIT", Process.pid)
end
raise ex
@@ -226,19 +227,19 @@ module Gitlab
def self.request_kwargs(storage, timeout, remote_storage: nil)
metadata = {
- 'authorization' => "Bearer #{authorization_token(storage)}",
- 'client_name' => CLIENT_NAME
+ "authorization" => "Bearer #{authorization_token(storage)}",
+ "client_name" => CLIENT_NAME,
}
feature_stack = Thread.current[:gitaly_feature_stack]
feature = feature_stack && feature_stack[0]
- metadata['call_site'] = feature.to_s if feature
- metadata['gitaly-servers'] = address_metadata(remote_storage) if remote_storage
- metadata['x-gitlab-correlation-id'] = Gitlab::CorrelationId.current_id if Gitlab::CorrelationId.current_id
+ metadata["call_site"] = feature.to_s if feature
+ metadata["gitaly-servers"] = address_metadata(remote_storage) if remote_storage
+ metadata["x-gitlab-correlation-id"] = Gitlab::CorrelationId.current_id if Gitlab::CorrelationId.current_id
metadata.merge!(server_feature_flags)
- result = { metadata: metadata }
+ result = {metadata: metadata}
# nil timeout indicates that we should use the default
timeout = default_timeout if timeout.nil?
@@ -254,16 +255,16 @@ module Gitlab
SERVER_FEATURE_FLAGS = %w[].freeze
def self.server_feature_flags
- SERVER_FEATURE_FLAGS.map do |f|
- ["gitaly-feature-#{f.tr('_', '-')}", feature_enabled?(f).to_s]
- end.to_h
+ SERVER_FEATURE_FLAGS.map { |f|
+ ["gitaly-feature-#{f.tr("_", "-")}", feature_enabled?(f).to_s]
+ }.to_h
end
def self.token(storage)
params = Gitlab.config.repositories.storages[storage]
raise "storage not found: #{storage.inspect}" if params.nil?
- params['gitaly_token'].presence || Gitlab.config.gitaly['token']
+ params["gitaly_token"].presence || Gitlab.config.gitaly["token"]
end
def self.feature_enabled?(feature_name)
@@ -338,14 +339,14 @@ module Gitlab
def self.add_call_details(details)
return unless Gitlab::SafeRequestStore[:peek_enabled]
- Gitlab::SafeRequestStore['gitaly_call_details'] ||= []
- Gitlab::SafeRequestStore['gitaly_call_details'] << details
+ Gitlab::SafeRequestStore["gitaly_call_details"] ||= []
+ Gitlab::SafeRequestStore["gitaly_call_details"] << details
end
def self.list_call_details
return [] unless Gitlab::SafeRequestStore[:peek_enabled]
- Gitlab::SafeRequestStore['gitaly_call_details'] || []
+ Gitlab::SafeRequestStore["gitaly_call_details"] || []
end
def self.expected_server_version
@@ -387,7 +388,7 @@ module Gitlab
stack_string = Gitlab::Profiler.clean_backtrace(caller).drop(1).join("\n")
- Gitlab::SafeRequestStore[:stack_counter] ||= Hash.new
+ Gitlab::SafeRequestStore[:stack_counter] ||= {}
count = Gitlab::SafeRequestStore[:stack_counter][stack_string] || 0
Gitlab::SafeRequestStore[:stack_counter][stack_string] = count + 1
diff --git a/lib/gitlab/gitaly_client/blobs_stitcher.rb b/lib/gitlab/gitaly_client/blobs_stitcher.rb
index 01bab854082..f860d8ce517 100644
--- a/lib/gitlab/gitaly_client/blobs_stitcher.rb
+++ b/lib/gitlab/gitaly_client/blobs_stitcher.rb
@@ -13,17 +13,15 @@ module Gitlab
current_blob_data = nil
@rpc_response.each do |msg|
- begin
- if msg.oid.blank? && msg.data.blank?
- next
- elsif msg.oid.present?
- yield new_blob(current_blob_data) if current_blob_data
-
- current_blob_data = msg.to_h.slice(:oid, :path, :size, :revision, :mode)
- current_blob_data[:data] = msg.data.dup
- else
- current_blob_data[:data] << msg.data
- end
+ if msg.oid.blank? && msg.data.blank?
+ next
+ elsif msg.oid.present?
+ yield new_blob(current_blob_data) if current_blob_data
+
+ current_blob_data = msg.to_h.slice(:oid, :path, :size, :revision, :mode)
+ current_blob_data[:data] = msg.data.dup
+ else
+ current_blob_data[:data] << msg.data
end
end
diff --git a/lib/gitlab/gitaly_client/cleanup_service.rb b/lib/gitlab/gitaly_client/cleanup_service.rb
index 3e8d6a773ca..779fc5c4429 100644
--- a/lib/gitlab/gitaly_client/cleanup_service.rb
+++ b/lib/gitlab/gitaly_client/cleanup_service.rb
@@ -15,14 +15,14 @@ module Gitlab
def apply_bfg_object_map(io)
first_request = Gitaly::ApplyBfgObjectMapRequest.new(repository: gitaly_repo)
- enum = Enumerator.new do |y|
+ enum = Enumerator.new { |y|
y.yield first_request
while data = io.read(RepositoryService::MAX_MSG_SIZE)
y.yield Gitaly::ApplyBfgObjectMapRequest.new(object_map: data)
break if io&.eof?
end
- end
+ }
GitalyClient.call(
storage,
diff --git a/lib/gitlab/gitaly_client/commit_service.rb b/lib/gitlab/gitaly_client/commit_service.rb
index ea12424eb4a..a5d575d2543 100644
--- a/lib/gitlab/gitaly_client/commit_service.rb
+++ b/lib/gitlab/gitaly_client/commit_service.rb
@@ -44,7 +44,7 @@ module Gitlab
else
from
end
- end
+ end
to_id = case to
when NilClass
@@ -57,7 +57,7 @@ module Gitlab
else
to
end
- end
+ end
request_params = diff_between_commits_request_params(from_id, to_id, options)
@@ -78,7 +78,7 @@ module Gitlab
end
def tree_entry(ref, path, limit = nil)
- if Pathname.new(path).cleanpath.to_s.start_with?('../')
+ if Pathname.new(path).cleanpath.to_s.start_with?("../")
# The TreeEntry RPC should return an empty reponse in this case but in
# Gitaly 0.107.0 and earlier we get an exception instead. This early return
# saves us a Gitaly roundtrip while also avoiding the exception.
@@ -114,7 +114,7 @@ module Gitlab
request = Gitaly::GetTreeEntriesRequest.new(
repository: @gitaly_repo,
revision: encode_binary(revision),
- path: path.present? ? encode_binary(path) : '.',
+ path: path.present? ? encode_binary(path) : ".",
recursive: recursive
)
@@ -238,7 +238,7 @@ module Gitlab
[]
end
- def commits_by_message(query, revision: '', path: '', limit: 1000, offset: 0)
+ def commits_by_message(query, revision: "", path: "", limit: 1000, offset: 0)
request = Gitaly::CommitsByMessageRequest.new(
repository: @gitaly_repo,
query: query,
@@ -253,10 +253,10 @@ module Gitlab
end
def languages(ref = nil)
- request = Gitaly::CommitLanguagesRequest.new(repository: @gitaly_repo, revision: ref || '')
+ request = Gitaly::CommitLanguagesRequest.new(repository: @gitaly_repo, revision: ref || "")
response = GitalyClient.call(@repository.storage, :commit_service, :commit_languages, request)
- response.languages.map { |l| { value: l.share.round(2), label: l.name, color: l.color, highlight: l.color } }
+ response.languages.map { |l| {value: l.share.round(2), label: l.name, color: l.color, highlight: l.color} }
end
def raw_blame(revision, path)
@@ -279,7 +279,7 @@ module Gitlab
key = {
storage: @gitaly_repo.storage_name,
relative_path: @gitaly_repo.relative_path,
- commit_id: revision
+ commit_id: revision,
}
return Gitlab::SafeRequestStore[key] if Gitlab::SafeRequestStore.exist?(key)
@@ -315,12 +315,12 @@ module Gitlab
def find_commits(options)
request = Gitaly::FindCommitsRequest.new(
- repository: @gitaly_repo,
- limit: options[:limit],
- offset: options[:offset],
- follow: options[:follow],
- skip_merges: options[:skip_merges],
- all: !!options[:all],
+ repository: @gitaly_repo,
+ limit: options[:limit],
+ offset: options[:offset],
+ follow: options[:follow],
+ skip_merges: options[:skip_merges],
+ all: !!options[:all],
disable_walk: true # This option is deprecated. The 'walk' implementation is being removed.
)
request.after = GitalyClient.timestamp(options[:after]) if options[:after]
@@ -337,7 +337,7 @@ module Gitlab
def filter_shas_with_signatures(shas)
request = Gitaly::FilterShasWithSignaturesRequest.new(repository: @gitaly_repo)
- enum = Enumerator.new do |y|
+ enum = Enumerator.new { |y|
shas.each_slice(20) do |revs|
request.shas = encode_repeated(revs)
@@ -345,7 +345,7 @@ module Gitlab
request = Gitaly::FilterShasWithSignaturesRequest.new
end
- end
+ }
response = GitalyClient.call(@repository.storage, :commit_service, :filter_shas_with_signatures, enum, timeout: GitalyClient.fast_timeout)
@@ -358,8 +358,8 @@ module Gitlab
request = Gitaly::ExtractCommitSignatureRequest.new(repository: @gitaly_repo, commit_id: commit_id)
response = GitalyClient.call(@repository.storage, :commit_service, :extract_commit_signature, request)
- signature = +''.b
- signed_text = +''.b
+ signature = +"".b
+ signed_text = +"".b
response.each do |message|
signature << message.signature
@@ -377,7 +377,7 @@ module Gitlab
request = Gitaly::GetCommitSignaturesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids)
response = GitalyClient.call(@repository.storage, :commit_service, :get_commit_signatures, request, timeout: GitalyClient.fast_timeout)
- signatures = Hash.new { |h, k| h[k] = [+''.b, +''.b] }
+ signatures = Hash.new { |h, k| h[k] = [+"".b, +"".b] }
current_commit_id = nil
response.each do |message|
@@ -396,7 +396,7 @@ module Gitlab
request = Gitaly::GetCommitMessagesRequest.new(repository: @gitaly_repo, commit_ids: commit_ids)
response = GitalyClient.call(@repository.storage, :commit_service, :get_commit_messages, request, timeout: GitalyClient.fast_timeout)
- messages = Hash.new { |h, k| h[k] = +''.b }
+ messages = Hash.new { |h, k| h[k] = +"".b }
current_commit_id = nil
response.each do |rpc_message|
@@ -432,7 +432,7 @@ module Gitlab
repository: @gitaly_repo,
left_commit_id: from_id,
right_commit_id: to_id,
- paths: options.fetch(:paths, []).compact.map { |path| encode_binary(path) }
+ paths: options.fetch(:paths, []).compact.map { |path| encode_binary(path) },
}
end
@@ -445,7 +445,7 @@ module Gitlab
end
def encode_repeated(array)
- Google::Protobuf::RepeatedField.new(:bytes, array.map { |s| encode_binary(s) } )
+ Google::Protobuf::RepeatedField.new(:bytes, array.map { |s| encode_binary(s) })
end
def call_find_commit(revision)
diff --git a/lib/gitlab/gitaly_client/conflict_files_stitcher.rb b/lib/gitlab/gitaly_client/conflict_files_stitcher.rb
index 0e00f6e8c44..6fe5902953c 100644
--- a/lib/gitlab/gitaly_client/conflict_files_stitcher.rb
+++ b/lib/gitlab/gitaly_client/conflict_files_stitcher.rb
@@ -34,14 +34,14 @@ module Gitlab
Gitlab::GitalyClient::Util.git_repository(header.repository),
header.commit_oid,
conflict_from_gitaly_file_header(header),
- ''
+ ""
)
end
def conflict_from_gitaly_file_header(header)
{
- ours: { path: header.our_path, mode: header.our_mode },
- theirs: { path: header.their_path }
+ ours: {path: header.our_path, mode: header.our_mode},
+ theirs: {path: header.their_path},
}
end
end
diff --git a/lib/gitlab/gitaly_client/conflicts_service.rb b/lib/gitlab/gitaly_client/conflicts_service.rb
index 6304f998563..ccc7f3dcfd4 100644
--- a/lib/gitlab/gitaly_client/conflicts_service.rb
+++ b/lib/gitlab/gitaly_client/conflicts_service.rb
@@ -39,7 +39,7 @@ module Gitlab
def resolve_conflicts(target_repository, resolution, source_branch, target_branch)
reader = binary_stringio(resolution.files.to_json)
- req_enum = Enumerator.new do |y|
+ req_enum = Enumerator.new { |y|
header = resolve_conflicts_request_header(target_repository, resolution, source_branch, target_branch)
y.yield Gitaly::ResolveConflictsRequest.new(header: header)
@@ -48,7 +48,7 @@ module Gitlab
y.yield Gitaly::ResolveConflictsRequest.new(files_json: chunk)
end
- end
+ }
response = GitalyClient.call(@repository.storage, :conflicts_service, :resolve_conflicts, req_enum, remote_storage: target_repository.storage, timeout: GitalyClient.medium_timeout)
diff --git a/lib/gitlab/gitaly_client/diff.rb b/lib/gitlab/gitaly_client/diff.rb
index dd192ccde1a..c30b8ab1bc8 100644
--- a/lib/gitlab/gitaly_client/diff.rb
+++ b/lib/gitlab/gitaly_client/diff.rb
@@ -3,7 +3,7 @@
module Gitlab
module GitalyClient
class Diff
- ATTRS = %i(from_path to_path old_mode new_mode from_id to_id patch overflow_marker collapsed too_large).freeze
+ ATTRS = %i[from_path to_path old_mode new_mode from_id to_id patch overflow_marker collapsed too_large].freeze
include AttributesBag
end
diff --git a/lib/gitlab/gitaly_client/health_check_service.rb b/lib/gitlab/gitaly_client/health_check_service.rb
index 0c495f60633..5f408c25af4 100644
--- a/lib/gitlab/gitaly_client/health_check_service.rb
+++ b/lib/gitlab/gitaly_client/health_check_service.rb
@@ -12,9 +12,9 @@ module Gitlab
request = Grpc::Health::V1::HealthCheckRequest.new
response = GitalyClient.call(@storage, :health_check, :check, request, timeout: GitalyClient.fast_timeout)
- { success: response&.status == :SERVING }
+ {success: response&.status == :SERVING}
rescue GRPC::BadStatus => e
- { success: false, message: e.to_s }
+ {success: false, message: e.to_s}
end
end
end
diff --git a/lib/gitlab/gitaly_client/object_pool_service.rb b/lib/gitlab/gitaly_client/object_pool_service.rb
index 6e7ede5fd18..287076c0139 100644
--- a/lib/gitlab/gitaly_client/object_pool_service.rb
+++ b/lib/gitlab/gitaly_client/object_pool_service.rb
@@ -13,7 +13,8 @@ module Gitlab
def create(repository)
request = Gitaly::CreateObjectPoolRequest.new(
object_pool: object_pool,
- origin: repository.gitaly_repository)
+ origin: repository.gitaly_repository
+ )
GitalyClient.call(storage, :object_pool_service, :create_object_pool, request)
end
@@ -31,7 +32,7 @@ module Gitlab
)
GitalyClient.call(storage, :object_pool_service, :link_repository_to_object_pool,
- request, timeout: GitalyClient.fast_timeout)
+ request, timeout: GitalyClient.fast_timeout)
end
def unlink_repository(repository)
@@ -41,7 +42,7 @@ module Gitlab
)
GitalyClient.call(storage, :object_pool_service, :unlink_repository_from_object_pool,
- request, timeout: GitalyClient.fast_timeout)
+ request, timeout: GitalyClient.fast_timeout)
end
end
end
diff --git a/lib/gitlab/gitaly_client/operation_service.rb b/lib/gitlab/gitaly_client/operation_service.rb
index d172c798da2..e2bb5ebff86 100644
--- a/lib/gitlab/gitaly_client/operation_service.rb
+++ b/lib/gitlab/gitaly_client/operation_service.rb
@@ -150,7 +150,7 @@ module Gitlab
branch_update = second_response.branch_update
return if branch_update.nil?
- raise Gitlab::Git::CommitError.new('failed to apply merge to branch') unless branch_update.commit_id.present?
+ raise Gitlab::Git::CommitError.new("failed to apply merge to branch") unless branch_update.commit_id.present?
Gitlab::Git::OperationService::BranchUpdate.from_gitaly(branch_update)
ensure
@@ -179,22 +179,22 @@ module Gitlab
def user_cherry_pick(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
call_cherry_pick_or_revert(:cherry_pick,
- user: user,
- commit: commit,
- branch_name: branch_name,
- message: message,
- start_branch_name: start_branch_name,
- start_repository: start_repository)
+ user: user,
+ commit: commit,
+ branch_name: branch_name,
+ message: message,
+ start_branch_name: start_branch_name,
+ start_repository: start_repository)
end
def user_revert(user:, commit:, branch_name:, message:, start_branch_name:, start_repository:)
call_cherry_pick_or_revert(:revert,
- user: user,
- commit: commit,
- branch_name: branch_name,
- message: message,
- start_branch_name: start_branch_name,
- start_repository: start_repository)
+ user: user,
+ commit: commit,
+ branch_name: branch_name,
+ message: message,
+ start_branch_name: start_branch_name,
+ start_repository: start_repository)
end
def user_rebase(user, rebase_id, branch:, branch_sha:, remote_repository:, remote_branch:)
@@ -279,12 +279,13 @@ module Gitlab
def user_commit_files(
user, branch_name, commit_message, actions, author_email, author_name,
- start_branch_name, start_repository)
+ start_branch_name, start_repository
+ )
- req_enum = Enumerator.new do |y|
+ req_enum = Enumerator.new { |y|
header = user_commit_files_request_header(user, branch_name,
- commit_message, actions, author_email, author_name,
- start_branch_name, start_repository)
+ commit_message, actions, author_email, author_name,
+ start_branch_name, start_repository)
y.yield Gitaly::UserCommitFilesRequest.new(header: header)
@@ -304,7 +305,7 @@ module Gitlab
)
end
end
- end
+ }
response = GitalyClient.call(@repository.storage, :operation_service,
:user_commit_files, req_enum, remote_storage: start_repository.storage)
@@ -328,7 +329,7 @@ module Gitlab
)
reader = binary_stringio(patches)
- chunks = Enumerator.new do |chunk|
+ chunks = Enumerator.new { |chunk|
chunk.yield Gitaly::UserApplyPatchRequest.new(header: header)
until reader.eof?
@@ -336,7 +337,7 @@ module Gitlab
chunk.yield(Gitaly::UserApplyPatchRequest.new(patches: patch_chunk))
end
- end
+ }
response = GitalyClient.call(@repository.storage, :operation_service, :user_apply_patch, chunks)
@@ -384,7 +385,8 @@ module Gitlab
def user_commit_files_request_header(
user, branch_name, commit_message, actions, author_email, author_name,
- start_branch_name, start_repository)
+ start_branch_name, start_repository
+ )
Gitaly::UserCommitFilesRequestHeader.new(
repository: @gitaly_repo,
@@ -403,7 +405,7 @@ module Gitlab
action: action[:action].upcase.to_sym,
file_path: encode_binary(action[:file_path]),
previous_path: encode_binary(action[:previous_path]),
- base64_content: action[:encoding] == 'base64',
+ base64_content: action[:encoding] == "base64",
execute_filemode: !!action[:execute_filemode],
infer_content: !!action[:infer_content]
)
diff --git a/lib/gitlab/gitaly_client/ref_service.rb b/lib/gitlab/gitaly_client/ref_service.rb
index d5633d167ac..0887574779a 100644
--- a/lib/gitlab/gitaly_client/ref_service.rb
+++ b/lib/gitlab/gitaly_client/ref_service.rb
@@ -220,7 +220,7 @@ module Gitlab
request = Gitaly::GetTagMessagesRequest.new(repository: @gitaly_repo, tag_ids: tag_ids)
response = GitalyClient.call(@repository.storage, :ref_service, :get_tag_messages, request, timeout: GitalyClient.fast_timeout)
- messages = Hash.new { |h, k| h[k] = +''.b }
+ messages = Hash.new { |h, k| h[k] = +"".b }
current_tag_id = nil
response.each do |rpc_message|
@@ -239,7 +239,7 @@ module Gitlab
end
def sort_by_param(sort_by)
- sort_by = 'name' if sort_by == 'name_asc'
+ sort_by = "name" if sort_by == "name_asc"
enum_value = Gitaly::FindLocalBranchesRequest::SortBy.resolve(sort_by.upcase.to_sym)
raise ArgumentError, "Invalid sort_by key `#{sort_by}`" unless enum_value
@@ -270,12 +270,12 @@ module Gitlab
end
def consume_find_all_remote_branches_response(remote_name, response)
- remote_name += '/' unless remote_name.ends_with?('/')
+ remote_name += "/" unless remote_name.ends_with?("/")
response.flat_map do |message|
message.branches.map do |branch|
target_commit = Gitlab::Git::Commit.decorate(@repository, branch.target_commit)
- branch_name = branch.name.sub(remote_name, '')
+ branch_name = branch.name.sub(remote_name, "")
Gitlab::Git::Branch.new(@repository, branch_name, branch.target_commit.id, target_commit)
end
end
@@ -291,7 +291,7 @@ module Gitlab
# Git messages have no encoding enforcements. However, in the UI we only
# handle UTF-8, so basically we cross our fingers that the message force
# encoded to UTF-8 is readable.
- message = response.commit_subject.dup.force_encoding('UTF-8')
+ message = response.commit_subject.dup.force_encoding("UTF-8")
# NOTE: For ease of parsing in Gitaly, we have only the subject of
# the commit and not the full message. This is ok, since all the
@@ -308,7 +308,7 @@ module Gitlab
author_email: response.commit_author.email.dup,
committed_date: Time.at(response.commit_committer.date.seconds),
committer_name: response.commit_committer.name.dup,
- committer_email: response.commit_committer.email.dup
+ committer_email: response.commit_committer.email.dup,
}
Gitlab::Git::Commit.decorate(@repository, hash)
diff --git a/lib/gitlab/gitaly_client/remote_service.rb b/lib/gitlab/gitaly_client/remote_service.rb
index 81fac37ee68..3d92a0f2f26 100644
--- a/lib/gitlab/gitaly_client/remote_service.rb
+++ b/lib/gitlab/gitaly_client/remote_service.rb
@@ -11,9 +11,9 @@ module Gitlab
request = Gitaly::FindRemoteRepositoryRequest.new(remote: remote_url)
response = GitalyClient.call(GitalyClient.random_storage,
- :remote_service,
- :find_remote_repository, request,
- timeout: GitalyClient.medium_timeout)
+ :remote_service,
+ :find_remote_repository, request,
+ timeout: GitalyClient.medium_timeout)
response.exists
end
@@ -50,8 +50,8 @@ module Gitlab
)
response = GitalyClient.call(@storage, :remote_service,
- :fetch_internal_remote, request,
- remote_storage: repository.storage)
+ :fetch_internal_remote, request,
+ remote_storage: repository.storage)
response.result
end
@@ -63,13 +63,13 @@ module Gitlab
)
response = GitalyClient.call(@storage, :remote_service,
- :find_remote_root_ref, request)
+ :find_remote_root_ref, request)
encode_utf8(response.ref)
end
def update_remote_mirror(ref_name, only_branches_matching, ssh_key: nil, known_hosts: nil)
- req_enum = Enumerator.new do |y|
+ req_enum = Enumerator.new { |y|
first_request = Gitaly::UpdateRemoteMirrorRequest.new(
repository: @gitaly_repo,
ref_name: ref_name
@@ -82,18 +82,18 @@ module Gitlab
current_size = 0
- slices = only_branches_matching.slice_before do |branch_name|
+ slices = only_branches_matching.slice_before { |branch_name|
current_size += branch_name.bytesize
next false if current_size < MAX_MSG_SIZE
current_size = 0
- end
+ }
slices.each do |slice|
y.yield Gitaly::UpdateRemoteMirrorRequest.new(only_branches_matching: slice)
end
- end
+ }
GitalyClient.call(@storage, :remote_service, :update_remote_mirror, req_enum)
end
diff --git a/lib/gitlab/gitaly_client/repository_service.rb b/lib/gitlab/gitaly_client/repository_service.rb
index a7e20d9429e..2376ecf952c 100644
--- a/lib/gitlab/gitaly_client/repository_service.rb
+++ b/lib/gitlab/gitaly_client/repository_service.rb
@@ -58,9 +58,9 @@ module Gitlab
request = Gitaly::GetInfoAttributesRequest.new(repository: @gitaly_repo)
response = GitalyClient.call(@storage, :repository_service, :get_info_attributes, request, timeout: GitalyClient.fast_timeout)
- response.each_with_object([]) do |message, attributes|
+ response.each_with_object([]) { |message, attributes|
attributes << message.attributes
- end.join
+ }.join
end
def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:, prune: true)
@@ -368,7 +368,7 @@ module Gitlab
timeout: timeout
)
- File.open(save_path, 'wb') do |f|
+ File.open(save_path, "wb") do |f|
response.each do |message|
f.write(message.data)
end
@@ -379,8 +379,8 @@ module Gitlab
def gitaly_repo_stream_request(file_path, rpc_name, request_class, timeout)
request = request_class.new(repository: @gitaly_repo)
- enum = Enumerator.new do |y|
- File.open(file_path, 'rb') do |f|
+ enum = Enumerator.new { |y|
+ File.open(file_path, "rb") do |f|
while data = f.read(MAX_MSG_SIZE)
request.data = data
@@ -388,7 +388,7 @@ module Gitlab
request = request_class.new
end
end
- end
+ }
GitalyClient.call(
@storage,
diff --git a/lib/gitlab/gitaly_client/storage_settings.rb b/lib/gitlab/gitaly_client/storage_settings.rb
index 754cccb6b3f..d047f64ebc3 100644
--- a/lib/gitlab/gitaly_client/storage_settings.rb
+++ b/lib/gitlab/gitaly_client/storage_settings.rb
@@ -11,7 +11,7 @@ module Gitlab
DirectPathAccessError = Class.new(StandardError)
InvalidConfigurationError = Class.new(StandardError)
- INVALID_STORAGE_MESSAGE = <<~MSG.freeze
+ INVALID_STORAGE_MESSAGE = <<~MSG
Storage is invalid because it has no `path` key.
For source installations, update your config/gitlab.yml Refer to gitlab.yml.example for an updated example.
@@ -39,12 +39,12 @@ module Gitlab
def initialize(storage)
raise InvalidConfigurationError, "expected a Hash, got a #{storage.class.name}" unless storage.is_a?(Hash)
- raise InvalidConfigurationError, INVALID_STORAGE_MESSAGE unless storage.has_key?('path')
+ raise InvalidConfigurationError, INVALID_STORAGE_MESSAGE unless storage.key?("path")
# Support a nil 'path' field because some of the circuit breaker tests use it.
- @legacy_disk_path = File.expand_path(storage['path'], Rails.root) if storage['path']
+ @legacy_disk_path = File.expand_path(storage["path"], Rails.root) if storage["path"]
- storage['path'] = Deprecated
+ storage["path"] = Deprecated
@hash = storage
end
diff --git a/lib/gitlab/gitaly_client/util.rb b/lib/gitlab/gitaly_client/util.rb
index 899921f76e4..96938acfc37 100644
--- a/lib/gitlab/gitaly_client/util.rb
+++ b/lib/gitlab/gitaly_client/util.rb
@@ -6,8 +6,8 @@ module Gitlab
class << self
def repository(repository_storage, relative_path, gl_repository, gl_project_path)
git_env = Gitlab::Git::HookEnv.all(gl_repository)
- git_object_directory = git_env['GIT_OBJECT_DIRECTORY_RELATIVE'].presence
- git_alternate_object_directories = Array.wrap(git_env['GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE'])
+ git_object_directory = git_env["GIT_OBJECT_DIRECTORY_RELATIVE"].presence
+ git_alternate_object_directories = Array.wrap(git_env["GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE"])
Gitaly::Repository.new(
storage_name: repository_storage,
@@ -21,9 +21,9 @@ module Gitlab
def git_repository(gitaly_repository)
Gitlab::Git::Repository.new(gitaly_repository.storage_name,
- gitaly_repository.relative_path,
- gitaly_repository.gl_repository,
- gitaly_repository.gl_project_path)
+ gitaly_repository.relative_path,
+ gitaly_repository.gl_repository,
+ gitaly_repository.gl_project_path)
end
end
end
diff --git a/lib/gitlab/gitaly_client/wiki_file.rb b/lib/gitlab/gitaly_client/wiki_file.rb
index ef2b23732d1..6b72e604870 100644
--- a/lib/gitlab/gitaly_client/wiki_file.rb
+++ b/lib/gitlab/gitaly_client/wiki_file.rb
@@ -3,7 +3,7 @@
module Gitlab
module GitalyClient
class WikiFile
- ATTRS = %i(name mime_type path raw_data).freeze
+ ATTRS = %i[name mime_type path raw_data].freeze
include AttributesBag
end
diff --git a/lib/gitlab/gitaly_client/wiki_page.rb b/lib/gitlab/gitaly_client/wiki_page.rb
index 757a429fb8a..f6ea2c96bbb 100644
--- a/lib/gitlab/gitaly_client/wiki_page.rb
+++ b/lib/gitlab/gitaly_client/wiki_page.rb
@@ -3,7 +3,7 @@
module Gitlab
module GitalyClient
class WikiPage
- ATTRS = %i(title format url_path path name historical raw_data).freeze
+ ATTRS = %i[title format url_path path name historical raw_data].freeze
include AttributesBag
include Gitlab::EncodingHelper
diff --git a/lib/gitlab/gitaly_client/wiki_service.rb b/lib/gitlab/gitaly_client/wiki_service.rb
index 2b3d622af4d..cf016d0e399 100644
--- a/lib/gitlab/gitaly_client/wiki_service.rb
+++ b/lib/gitlab/gitaly_client/wiki_service.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'stringio'
+require "stringio"
module Gitlab
module GitalyClient
@@ -24,7 +24,7 @@ module Gitlab
strio = binary_stringio(content)
- enum = Enumerator.new do |y|
+ enum = Enumerator.new { |y|
until strio.eof?
request.content = strio.read(MAX_MSG_SIZE)
@@ -32,7 +32,7 @@ module Gitlab
request = Gitaly::WikiWritePageRequest.new
end
- end
+ }
response = GitalyClient.call(@repository.storage, :wiki_service, :wiki_write_page, enum)
if error = response.duplicate_error.presence
@@ -51,7 +51,7 @@ module Gitlab
strio = binary_stringio(content)
- enum = Enumerator.new do |y|
+ enum = Enumerator.new { |y|
until strio.eof?
request.content = strio.read(MAX_MSG_SIZE)
@@ -59,7 +59,7 @@ module Gitlab
request = Gitaly::WikiUpdatePageRequest.new
end
- end
+ }
GitalyClient.call(@repository.storage, :wiki_service, :wiki_update_page, enum)
end
diff --git a/lib/gitlab/github_import.rb b/lib/gitlab/github_import.rb
index 14a6d6443ec..63a5df50997 100644
--- a/lib/gitlab/github_import.rb
+++ b/lib/gitlab/github_import.rb
@@ -3,7 +3,7 @@
module Gitlab
module GithubImport
def self.refmap
- [:heads, :tags, '+refs/pull/*/head:refs/merge-requests/*/head']
+ [:heads, :tags, "+refs/pull/*/head:refs/merge-requests/*/head"]
end
def self.new_client_for(project, token: nil, parallel: true)
@@ -14,7 +14,7 @@ module Gitlab
# Returns the ID of the ghost user.
def self.ghost_user_id
- key = 'github-import/ghost-user-id'
+ key = "github-import/ghost-user-id"
Caching.read_integer(key) || Caching.write(key, User.select(:id).ghost.id)
end
diff --git a/lib/gitlab/github_import/caching.rb b/lib/gitlab/github_import/caching.rb
index b08f133794f..b789641e1d9 100644
--- a/lib/gitlab/github_import/caching.rb
+++ b/lib/gitlab/github_import/caching.rb
@@ -135,10 +135,10 @@ module Gitlab
# Returns true when the key was overwritten, false otherwise.
def self.write_if_greater(raw_key, value, timeout: TIMEOUT)
key = cache_key_for(raw_key)
- val = Redis::Cache.with do |redis|
+ val = Redis::Cache.with { |redis|
redis
.eval(WRITE_IF_GREATER_SCRIPT, keys: [key], argv: [value, timeout])
- end
+ }
val ? true : false
end
diff --git a/lib/gitlab/github_import/client.rb b/lib/gitlab/github_import/client.rb
index a61beafae0d..c5db56a3bf3 100644
--- a/lib/gitlab/github_import/client.rb
+++ b/lib/gitlab/github_import/client.rb
@@ -46,7 +46,7 @@ module Gitlab
api_endpoint: api_endpoint
)
- @octokit.connection_options[:ssl] = { verify: verify_ssl }
+ @octokit.connection_options[:ssl] = {verify: verify_ssl}
@parallel = parallel
end
@@ -176,7 +176,7 @@ module Gitlab
def rate_limiting_enabled?
strong_memoize(:rate_limiting_enabled) do
- api_endpoint.include?('.github.com')
+ api_endpoint.include?(".github.com")
end
end
@@ -185,7 +185,7 @@ module Gitlab
end
def custom_api_endpoint
- github_omniauth_provider.dig('args', 'client_options', 'site')
+ github_omniauth_provider.dig("args", "client_options", "site")
end
def default_api_endpoint
@@ -193,24 +193,24 @@ module Gitlab
end
def verify_ssl
- github_omniauth_provider.fetch('verify_ssl', true)
+ github_omniauth_provider.fetch("verify_ssl", true)
end
def github_omniauth_provider
- @github_omniauth_provider ||= Gitlab::Auth::OAuth::Provider.config_for('github').to_h
+ @github_omniauth_provider ||= Gitlab::Auth::OAuth::Provider.config_for("github").to_h
end
def rate_limit_counter
@rate_limit_counter ||= Gitlab::Metrics.counter(
:github_importer_rate_limit_hits,
- 'The number of times we hit the GitHub rate limit when importing projects'
+ "The number of times we hit the GitHub rate limit when importing projects"
)
end
def request_count_counter
@request_counter ||= Gitlab::Metrics.counter(
:github_importer_request_count,
- 'The number of GitHub API calls performed when importing projects'
+ "The number of GitHub API calls performed when importing projects"
)
end
end
diff --git a/lib/gitlab/github_import/importer/diff_note_importer.rb b/lib/gitlab/github_import/importer/diff_note_importer.rb
index d562958e955..b6081401368 100644
--- a/lib/gitlab/github_import/importer/diff_note_importer.rb
+++ b/lib/gitlab/github_import/importer/diff_note_importer.rb
@@ -25,7 +25,7 @@ module Gitlab
MarkdownText.format(note.note, note.author, author_found)
attributes = {
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: mr_id,
project_id: project.id,
author_id: author_id,
@@ -33,10 +33,10 @@ module Gitlab
system: false,
commit_id: note.commit_id,
line_code: note.line_code,
- type: 'LegacyDiffNote',
+ type: "LegacyDiffNote",
created_at: note.created_at,
updated_at: note.updated_at,
- st_diff: note.diff_hash.to_yaml
+ st_diff: note.diff_hash.to_yaml,
}
# It's possible that during an import we'll insert tens of thousands
diff --git a/lib/gitlab/github_import/importer/issue_importer.rb b/lib/gitlab/github_import/importer/issue_importer.rb
index 656d46b6a7d..1a98be6153d 100644
--- a/lib/gitlab/github_import/importer/issue_importer.rb
+++ b/lib/gitlab/github_import/importer/issue_importer.rb
@@ -7,7 +7,7 @@ module Gitlab
include Gitlab::Import::DatabaseHelpers
attr_reader :project, :issue, :client, :user_finder, :milestone_finder,
- :issuable_finder
+ :issuable_finder
# Imports an issue if it's a regular issue and not a pull request.
def self.import_if_issue(issue, project, client)
@@ -54,7 +54,7 @@ module Gitlab
milestone_id: milestone_finder.id_for(issue),
state: issue.state,
created_at: issue.created_at,
- updated_at: issue.updated_at
+ updated_at: issue.updated_at,
}
insert_and_return_id(attributes, project.issues)
@@ -71,7 +71,7 @@ module Gitlab
issue.assignees.each do |assignee|
if (user_id = user_finder.user_id_for(assignee))
- assignees << { issue_id: issue_id, user_id: user_id }
+ assignees << {issue_id: issue_id, user_id: user_id}
end
end
diff --git a/lib/gitlab/github_import/importer/issues_importer.rb b/lib/gitlab/github_import/importer/issues_importer.rb
index ac6d0666b3a..f35d3d27f92 100644
--- a/lib/gitlab/github_import/importer/issues_importer.rb
+++ b/lib/gitlab/github_import/importer/issues_importer.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def collection_options
- { state: 'all', sort: 'created', direction: 'asc' }
+ {state: "all", sort: "created", direction: "asc"}
end
end
end
diff --git a/lib/gitlab/github_import/importer/label_links_importer.rb b/lib/gitlab/github_import/importer/label_links_importer.rb
index 2001b7e3482..164c94bc24f 100644
--- a/lib/gitlab/github_import/importer/label_links_importer.rb
+++ b/lib/gitlab/github_import/importer/label_links_importer.rb
@@ -36,7 +36,7 @@ module Gitlab
target_id: target_id,
target_type: issue.issuable_type,
created_at: time,
- updated_at: time
+ updated_at: time,
}
end
diff --git a/lib/gitlab/github_import/importer/labels_importer.rb b/lib/gitlab/github_import/importer/labels_importer.rb
index 80246fa1b77..342bb82d7fa 100644
--- a/lib/gitlab/github_import/importer/labels_importer.rb
+++ b/lib/gitlab/github_import/importer/labels_importer.rb
@@ -40,11 +40,11 @@ module Gitlab
{
title: label.name,
- color: '#' + label.color,
+ color: "#" + label.color,
project_id: project.id,
- type: 'ProjectLabel',
+ type: "ProjectLabel",
created_at: time,
- updated_at: time
+ updated_at: time,
}
end
diff --git a/lib/gitlab/github_import/importer/lfs_objects_importer.rb b/lib/gitlab/github_import/importer/lfs_objects_importer.rb
index 6046e30d4ef..1f8d80d2bec 100644
--- a/lib/gitlab/github_import/importer/lfs_objects_importer.rb
+++ b/lib/gitlab/github_import/importer/lfs_objects_importer.rb
@@ -28,7 +28,7 @@ module Gitlab
lfs_objects.each do |object|
yield object
end
- rescue StandardError => e
+ rescue => e
Rails.logger.error("The Lfs import process failed. #{e.message}")
end
end
diff --git a/lib/gitlab/github_import/importer/milestones_importer.rb b/lib/gitlab/github_import/importer/milestones_importer.rb
index 87cf2c8b598..fc75c397b1a 100644
--- a/lib/gitlab/github_import/importer/milestones_importer.rb
+++ b/lib/gitlab/github_import/importer/milestones_importer.rb
@@ -43,16 +43,16 @@ module Gitlab
project_id: project.id,
state: state_for(milestone),
created_at: milestone.created_at,
- updated_at: milestone.updated_at
+ updated_at: milestone.updated_at,
}
end
def state_for(milestone)
- milestone.state == 'open' ? :active : :closed
+ milestone.state == "open" ? :active : :closed
end
def each_milestone
- client.milestones(project.import_source, state: 'all')
+ client.milestones(project.import_source, state: "all")
end
end
end
diff --git a/lib/gitlab/github_import/importer/note_importer.rb b/lib/gitlab/github_import/importer/note_importer.rb
index 2b06d1b3baf..c0875a47d0e 100644
--- a/lib/gitlab/github_import/importer/note_importer.rb
+++ b/lib/gitlab/github_import/importer/note_importer.rb
@@ -32,7 +32,7 @@ module Gitlab
note: note_body,
system: false,
created_at: note.created_at,
- updated_at: note.updated_at
+ updated_at: note.updated_at,
}
# We're using bulk_insert here so we can bypass any validations and
diff --git a/lib/gitlab/github_import/importer/pull_request_importer.rb b/lib/gitlab/github_import/importer/pull_request_importer.rb
index e294173f992..2ffc51840cc 100644
--- a/lib/gitlab/github_import/importer/pull_request_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_request_importer.rb
@@ -7,7 +7,7 @@ module Gitlab
include Gitlab::Import::MergeRequestHelpers
attr_reader :pull_request, :project, :client, :user_finder,
- :milestone_finder, :issuable_finder
+ :milestone_finder, :issuable_finder
# pull_request - An instance of
# `Gitlab::GithubImport::Representation::PullRequest`.
@@ -59,7 +59,7 @@ module Gitlab
author_id: author_id,
assignee_id: user_finder.assignee_id_for(pull_request),
created_at: pull_request.created_at,
- updated_at: pull_request.updated_at
+ updated_at: pull_request.updated_at,
}
create_merge_request_without_hooks(project, attributes, pull_request.iid)
@@ -92,11 +92,11 @@ module Gitlab
project.repository.add_branch(merge_request.author, source_branch, pull_request.source_branch_sha)
rescue Gitlab::Git::CommandError => e
Gitlab::Sentry.track_acceptable_exception(e,
- extra: {
- source_branch: source_branch,
- project_id: merge_request.project.id,
- merge_request_id: merge_request.id
- })
+ extra: {
+ source_branch: source_branch,
+ project_id: merge_request.project.id,
+ merge_request_id: merge_request.id,
+ })
end
end
end
diff --git a/lib/gitlab/github_import/importer/pull_requests_importer.rb b/lib/gitlab/github_import/importer/pull_requests_importer.rb
index a52866c4b08..842d1dc371f 100644
--- a/lib/gitlab/github_import/importer/pull_requests_importer.rb
+++ b/lib/gitlab/github_import/importer/pull_requests_importer.rb
@@ -36,7 +36,7 @@ module Gitlab
# updating the timestamp.
project.update_column(:last_repository_updated_at, Time.zone.now)
- project.repository.fetch_remote('github', forced: false)
+ project.repository.fetch_remote("github", forced: false)
pname = project.path_with_namespace
@@ -65,13 +65,13 @@ module Gitlab
end
def collection_options
- { state: 'all', sort: 'created', direction: 'asc' }
+ {state: "all", sort: "created", direction: "asc"}
end
def repository_updates_counter
@repository_updates_counter ||= Gitlab::Metrics.counter(
:github_importer_repository_updates,
- 'The number of times repositories have to be updated again'
+ "The number of times repositories have to be updated again"
)
end
end
diff --git a/lib/gitlab/github_import/importer/releases_importer.rb b/lib/gitlab/github_import/importer/releases_importer.rb
index 0e7c9ee0d00..4d6faf055b0 100644
--- a/lib/gitlab/github_import/importer/releases_importer.rb
+++ b/lib/gitlab/github_import/importer/releases_importer.rb
@@ -36,7 +36,7 @@ module Gitlab
description: description_for(release),
created_at: release.created_at,
updated_at: release.updated_at,
- project_id: project.id
+ project_id: project.id,
}
end
diff --git a/lib/gitlab/github_import/importer/repository_importer.rb b/lib/gitlab/github_import/importer/repository_importer.rb
index e2dfb00dcc5..02b803e6742 100644
--- a/lib/gitlab/github_import/importer/repository_importer.rb
+++ b/lib/gitlab/github_import/importer/repository_importer.rb
@@ -50,7 +50,7 @@ module Gitlab
project.ensure_repository
refmap = Gitlab::GithubImport.refmap
- project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: 'github')
+ project.repository.fetch_as_mirror(project.import_url, refmap: refmap, forced: true, remote_name: "github")
true
rescue Gitlab::Git::Repository::NoRepository, Gitlab::Shell::Error => e
@@ -62,7 +62,7 @@ module Gitlab
true
rescue Gitlab::Shell::Error => e
- if e.message !~ /repository not exported/
+ if !/repository not exported/.match?(e.message)
project.create_wiki
fail_import("Failed to import the wiki: #{e.message}")
else
diff --git a/lib/gitlab/github_import/issuable_finder.rb b/lib/gitlab/github_import/issuable_finder.rb
index 211915f1d87..8ed783dc8ce 100644
--- a/lib/gitlab/github_import/issuable_finder.rb
+++ b/lib/gitlab/github_import/issuable_finder.rb
@@ -10,7 +10,7 @@ module Gitlab
attr_reader :project, :object
# The base cache key to use for storing/retrieving issuable IDs.
- CACHE_KEY = 'github-import/issuable-finder/%{project}/%{type}/%{iid}'.freeze
+ CACHE_KEY = "github-import/issuable-finder/%{project}/%{type}/%{iid}"
# project - An instance of `Project`.
# object - The object to look up or set a database ID for.
@@ -41,7 +41,7 @@ module Gitlab
CACHE_KEY % {
project: project.id,
type: cache_key_type,
- iid: cache_key_iid
+ iid: cache_key_iid,
}
end
diff --git a/lib/gitlab/github_import/label_finder.rb b/lib/gitlab/github_import/label_finder.rb
index d2479a8f565..c0280e7f51a 100644
--- a/lib/gitlab/github_import/label_finder.rb
+++ b/lib/gitlab/github_import/label_finder.rb
@@ -6,7 +6,7 @@ module Gitlab
attr_reader :project
# The base cache key to use for storing/retrieving label IDs.
- CACHE_KEY = 'github-import/label-finder/%{project}/%{name}'.freeze
+ CACHE_KEY = "github-import/label-finder/%{project}/%{name}"
# project - An instance of `Project`.
def initialize(project)
@@ -23,16 +23,16 @@ module Gitlab
mapping = @project
.labels
.pluck(:id, :name)
- .each_with_object({}) do |(id, name), hash|
+ .each_with_object({}) { |(id, name), hash|
hash[cache_key_for(name)] = id
- end
+ }
Caching.write_multiple(mapping)
end
# rubocop: enable CodeReuse/ActiveRecord
def cache_key_for(name)
- CACHE_KEY % { project: project.id, name: name }
+ CACHE_KEY % {project: project.id, name: name}
end
end
end
diff --git a/lib/gitlab/github_import/milestone_finder.rb b/lib/gitlab/github_import/milestone_finder.rb
index 5625730e796..7f9de146f4e 100644
--- a/lib/gitlab/github_import/milestone_finder.rb
+++ b/lib/gitlab/github_import/milestone_finder.rb
@@ -6,7 +6,7 @@ module Gitlab
attr_reader :project
# The base cache key to use for storing/retrieving milestone IDs.
- CACHE_KEY = 'github-import/milestone-finder/%{project}/%{iid}'.freeze
+ CACHE_KEY = "github-import/milestone-finder/%{project}/%{iid}"
# project - An instance of `Project`
def initialize(project)
@@ -26,16 +26,16 @@ module Gitlab
mapping = @project
.milestones
.pluck(:id, :iid)
- .each_with_object({}) do |(id, iid), hash|
+ .each_with_object({}) { |(id, iid), hash|
hash[cache_key_for(iid)] = id
- end
+ }
Caching.write_multiple(mapping)
end
# rubocop: enable CodeReuse/ActiveRecord
def cache_key_for(iid)
- CACHE_KEY % { project: project.id, iid: iid }
+ CACHE_KEY % {project: project.id, iid: iid}
end
end
end
diff --git a/lib/gitlab/github_import/page_counter.rb b/lib/gitlab/github_import/page_counter.rb
index c3db2d0b469..e342ddeff3e 100644
--- a/lib/gitlab/github_import/page_counter.rb
+++ b/lib/gitlab/github_import/page_counter.rb
@@ -9,10 +9,10 @@ module Gitlab
attr_reader :cache_key
# The base cache key to use for storing the last page number.
- CACHE_KEY = 'github-importer/page-counter/%{project}/%{collection}'.freeze
+ CACHE_KEY = "github-importer/page-counter/%{project}/%{collection}"
def initialize(project, collection)
- @cache_key = CACHE_KEY % { project: project.id, collection: collection }
+ @cache_key = CACHE_KEY % {project: project.id, collection: collection}
end
# Sets the page number to the given value.
diff --git a/lib/gitlab/github_import/parallel_scheduling.rb b/lib/gitlab/github_import/parallel_scheduling.rb
index d4d1357f5a3..aef37a6996b 100644
--- a/lib/gitlab/github_import/parallel_scheduling.rb
+++ b/lib/gitlab/github_import/parallel_scheduling.rb
@@ -7,7 +7,7 @@ module Gitlab
# The base cache key to use for tracking already imported objects.
ALREADY_IMPORTED_CACHE_KEY =
- 'github-importer/already-imported/%{project}/%{collection}'.freeze
+ "github-importer/already-imported/%{project}/%{collection}"
# project - An instance of `Project`.
# client - An instance of `Gitlab::GithubImport::Client`.
@@ -18,7 +18,7 @@ module Gitlab
@parallel = parallel
@page_counter = PageCounter.new(project, collection_method)
@already_imported_cache_key = ALREADY_IMPORTED_CACHE_KEY %
- { project: project.id, collection: collection_method }
+ {project: project.id, collection: collection_method}
end
def parallel?
diff --git a/lib/gitlab/github_import/representation/diff_note.rb b/lib/gitlab/github_import/representation/diff_note.rb
index be1334ca98a..0675bb359fc 100644
--- a/lib/gitlab/github_import/representation/diff_note.rb
+++ b/lib/gitlab/github_import/representation/diff_note.rb
@@ -10,8 +10,8 @@ module Gitlab
attr_reader :attributes
expose_attribute :noteable_type, :noteable_id, :commit_id, :file_path,
- :diff_hunk, :author, :note, :created_at, :updated_at,
- :github_id
+ :diff_hunk, :author, :note, :created_at, :updated_at,
+ :github_id
NOTEABLE_ID_REGEX = %r{/pull/(?<iid>\d+)}i
@@ -30,7 +30,7 @@ module Gitlab
user = Representation::User.from_api_response(note.user) if note.user
hash = {
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: matches[:iid].to_i,
file_path: note.path,
commit_id: note.commit_id,
@@ -39,7 +39,7 @@ module Gitlab
note: note.body,
created_at: note.created_at,
updated_at: note.updated_at,
- github_id: note.id
+ github_id: note.id,
}
new(hash)
@@ -76,9 +76,9 @@ module Gitlab
# These fields are not displayed for LegacyDiffNote notes, so it
# doesn't really matter what we set them to.
- a_mode: '100644',
- b_mode: '100644',
- new_file: false
+ a_mode: "100644",
+ b_mode: "100644",
+ new_file: false,
}
end
end
diff --git a/lib/gitlab/github_import/representation/issue.rb b/lib/gitlab/github_import/representation/issue.rb
index f3071b3e2b3..ac95ecdefdc 100644
--- a/lib/gitlab/github_import/representation/issue.rb
+++ b/lib/gitlab/github_import/representation/issue.rb
@@ -10,8 +10,8 @@ module Gitlab
attr_reader :attributes
expose_attribute :iid, :title, :description, :milestone_number,
- :created_at, :updated_at, :state, :assignees,
- :label_names, :author
+ :created_at, :updated_at, :state, :assignees,
+ :label_names, :author
# Builds an issue from a GitHub API response.
#
@@ -28,7 +28,7 @@ module Gitlab
title: issue.title,
description: issue.body,
milestone_number: issue.milestone&.number,
- state: issue.state == 'open' ? :opened : :closed,
+ state: issue.state == "open" ? :opened : :closed,
assignees: issue.assignees.map do |u|
Representation::User.from_api_response(u)
end,
@@ -36,7 +36,7 @@ module Gitlab
author: user,
created_at: issue.created_at,
updated_at: issue.updated_at,
- pull_request: issue.pull_request ? true : false
+ pull_request: issue.pull_request ? true : false,
}
new(hash)
@@ -64,7 +64,7 @@ module Gitlab
end
def labels?
- label_names && label_names.any?
+ label_names&.any?
end
def pull_request?
@@ -72,7 +72,7 @@ module Gitlab
end
def issuable_type
- pull_request? ? 'MergeRequest' : 'Issue'
+ pull_request? ? "MergeRequest" : "Issue"
end
end
end
diff --git a/lib/gitlab/github_import/representation/lfs_object.rb b/lib/gitlab/github_import/representation/lfs_object.rb
index a4606173f49..b1256418c24 100644
--- a/lib/gitlab/github_import/representation/lfs_object.rb
+++ b/lib/gitlab/github_import/representation/lfs_object.rb
@@ -13,7 +13,7 @@ module Gitlab
# Builds a lfs_object
def self.from_api_response(lfs_object)
- new({ oid: lfs_object.oid, link: lfs_object.link, size: lfs_object.size })
+ new({oid: lfs_object.oid, link: lfs_object.link, size: lfs_object.size})
end
# Builds a new lfs_object using a Hash that was built from a JSON payload.
diff --git a/lib/gitlab/github_import/representation/note.rb b/lib/gitlab/github_import/representation/note.rb
index 070e3b2db8d..53ecd268d77 100644
--- a/lib/gitlab/github_import/representation/note.rb
+++ b/lib/gitlab/github_import/representation/note.rb
@@ -10,7 +10,7 @@ module Gitlab
attr_reader :attributes
expose_attribute :noteable_id, :noteable_type, :author, :note,
- :created_at, :updated_at, :github_id
+ :created_at, :updated_at, :github_id
NOTEABLE_TYPE_REGEX = %r{/(?<type>(pull|issues))/(?<iid>\d+)}i
@@ -28,10 +28,10 @@ module Gitlab
end
noteable_type =
- if matches[:type] == 'pull'
- 'MergeRequest'
+ if matches[:type] == "pull"
+ "MergeRequest"
else
- 'Issue'
+ "Issue"
end
user = Representation::User.from_api_response(note.user) if note.user
@@ -42,7 +42,7 @@ module Gitlab
note: note.body,
created_at: note.created_at,
updated_at: note.updated_at,
- github_id: note.id
+ github_id: note.id,
}
new(hash)
@@ -63,7 +63,7 @@ module Gitlab
@attributes = attributes
end
- alias_method :issuable_type, :noteable_type
+ alias issuable_type noteable_type
end
end
end
diff --git a/lib/gitlab/github_import/representation/pull_request.rb b/lib/gitlab/github_import/representation/pull_request.rb
index 0ccc4bfaed3..7067b59f2f2 100644
--- a/lib/gitlab/github_import/representation/pull_request.rb
+++ b/lib/gitlab/github_import/representation/pull_request.rb
@@ -10,10 +10,10 @@ module Gitlab
attr_reader :attributes
expose_attribute :iid, :title, :description, :source_branch,
- :source_branch_sha, :target_branch, :target_branch_sha,
- :milestone_number, :author, :assignee, :created_at,
- :updated_at, :merged_at, :source_repository_id,
- :target_repository_id, :source_repository_owner
+ :source_branch_sha, :target_branch, :target_branch_sha,
+ :milestone_number, :author, :assignee, :created_at,
+ :updated_at, :merged_at, :source_repository_id,
+ :target_repository_id, :source_repository_owner
# Builds a PR from a GitHub API response.
#
@@ -36,13 +36,13 @@ module Gitlab
source_repository_id: pr.head&.repo&.id,
target_repository_id: pr.base&.repo&.id,
source_repository_owner: pr.head&.user&.login,
- state: pr.state == 'open' ? :opened : :closed,
+ state: pr.state == "open" ? :opened : :closed,
milestone_number: pr.milestone&.number,
author: user,
assignee: assignee,
created_at: pr.created_at,
updated_at: pr.updated_at,
- merged_at: pr.merged_at
+ merged_at: pr.merged_at,
}
new(hash)
@@ -106,7 +106,7 @@ module Gitlab
end
def issuable_type
- 'MergeRequest'
+ "MergeRequest"
end
end
end
diff --git a/lib/gitlab/github_import/sequential_importer.rb b/lib/gitlab/github_import/sequential_importer.rb
index 6a181caf65d..97394f1e779 100644
--- a/lib/gitlab/github_import/sequential_importer.rb
+++ b/lib/gitlab/github_import/sequential_importer.rb
@@ -12,7 +12,7 @@ module Gitlab
SEQUENTIAL_IMPORTERS = [
Importer::LabelsImporter,
Importer::MilestonesImporter,
- Importer::ReleasesImporter
+ Importer::ReleasesImporter,
].freeze
PARALLEL_IMPORTERS = [
@@ -20,7 +20,7 @@ module Gitlab
Importer::IssuesImporter,
Importer::DiffNotesImporter,
Importer::NotesImporter,
- Importer::LfsObjectsImporter
+ Importer::LfsObjectsImporter,
].freeze
# project - The project to import the data into.
diff --git a/lib/gitlab/github_import/user_finder.rb b/lib/gitlab/github_import/user_finder.rb
index 30283f147ef..36416f8db32 100644
--- a/lib/gitlab/github_import/user_finder.rb
+++ b/lib/gitlab/github_import/user_finder.rb
@@ -16,17 +16,17 @@ module Gitlab
# The base cache key to use for caching user IDs for a given GitHub user
# ID.
- ID_CACHE_KEY = 'github-import/user-finder/user-id/%s'.freeze
+ ID_CACHE_KEY = "github-import/user-finder/user-id/%s"
# The base cache key to use for caching user IDs for a given GitHub email
# address.
ID_FOR_EMAIL_CACHE_KEY =
- 'github-import/user-finder/id-for-email/%s'.freeze
+ "github-import/user-finder/id-for-email/%s"
# The base cache key to use for caching the Email addresses of GitHub
# usernames.
EMAIL_FOR_USERNAME_CACHE_KEY =
- 'github-import/user-finder/email-for-username/%s'.freeze
+ "github-import/user-finder/email-for-username/%s"
# project - An instance of `Project`
# client - An instance of `Gitlab::GithubImport::Client`
diff --git a/lib/gitlab/gitlab_import/client.rb b/lib/gitlab/gitlab_import/client.rb
index 86474159f8b..d45aa65c4ec 100644
--- a/lib/gitlab/gitlab_import/client.rb
+++ b/lib/gitlab/gitlab_import/client.rb
@@ -22,7 +22,7 @@ module Gitlab
def authorize_url(redirect_uri)
client.auth_code.authorize_url({
redirect_uri: redirect_uri,
- scope: "api"
+ scope: "api",
})
end
@@ -78,7 +78,7 @@ module Gitlab
end
def config
- Gitlab::Auth::OAuth::Provider.config_for('gitlab')
+ Gitlab::Auth::OAuth::Provider.config_for("gitlab")
end
def gitlab_options
diff --git a/lib/gitlab/gitlab_import/importer.rb b/lib/gitlab/gitlab_import/importer.rb
index e84863deba8..8281eebb96e 100644
--- a/lib/gitlab/gitlab_import/importer.rb
+++ b/lib/gitlab/gitlab_import/importer.rb
@@ -8,7 +8,7 @@ module Gitlab
def initialize(project)
@project = project
import_data = project.import_data
- if import_data && import_data.credentials && import_data.credentials[:password]
+ if import_data&.credentials && import_data.credentials[:password]
@client = Client.new(import_data.credentials[:password])
@formatter = Gitlab::ImportFormatter.new
else
@@ -57,7 +57,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def gitlab_user_id(project, gitlab_id)
user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'gitlab'", gitlab_id.to_s)
- (user && user.id) || project.creator_id
+ (user&.id) || project.creator_id
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/lib/gitlab/gl_id.rb b/lib/gitlab/gl_id.rb
index 1ed842c2264..b15fb132d72 100644
--- a/lib/gitlab/gl_id.rb
+++ b/lib/gitlab/gl_id.rb
@@ -6,7 +6,7 @@ module Gitlab
if user.present?
gl_id_from_id_value(user.id)
else
- ''
+ ""
end
end
diff --git a/lib/gitlab/gl_repository.rb b/lib/gitlab/gl_repository.rb
index 435b74806e7..d6b97745211 100644
--- a/lib/gitlab/gl_repository.rb
+++ b/lib/gitlab/gl_repository.rb
@@ -3,7 +3,7 @@
module Gitlab
module GlRepository
def self.gl_repository(project, is_wiki)
- "#{is_wiki ? 'wiki' : 'project'}-#{project.id}"
+ "#{is_wiki ? "wiki" : "project"}-#{project.id}"
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -15,7 +15,7 @@ module Gitlab
type, id = match_data.captures
project = Project.find_by(id: id)
- wiki = type == 'wiki'
+ wiki = type == "wiki"
[project, wiki]
end
diff --git a/lib/gitlab/gon_helper.rb b/lib/gitlab/gon_helper.rb
index 3235d3ccc4e..ffe80c36eed 100644
--- a/lib/gitlab/gon_helper.rb
+++ b/lib/gitlab/gon_helper.rb
@@ -7,21 +7,21 @@ module Gitlab
include WebpackHelper
def add_gon_variables
- gon.api_version = 'v4'
+ gon.api_version = "v4"
gon.default_avatar_url = default_avatar_url
gon.max_file_size = Gitlab::CurrentSettings.max_attachment_size
gon.asset_host = ActionController::Base.asset_host
gon.webpack_public_path = webpack_public_path
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
- gon.shortcuts_path = Gitlab::Routing.url_helpers.help_page_path('shortcuts')
+ gon.shortcuts_path = Gitlab::Routing.url_helpers.help_page_path("shortcuts")
gon.user_color_scheme = Gitlab::ColorSchemes.for_user(current_user).css_class
gon.sentry_dsn = Gitlab::CurrentSettings.clientside_sentry_dsn if Gitlab::CurrentSettings.clientside_sentry_enabled
gon.gitlab_url = Gitlab.config.gitlab.url
gon.revision = Gitlab.revision
- gon.gitlab_logo = ActionController::Base.helpers.asset_path('gitlab_logo.png')
+ gon.gitlab_logo = ActionController::Base.helpers.asset_path("gitlab_logo.png")
gon.sprite_icons = IconsHelper.sprite_icon_path
gon.sprite_file_icons = IconsHelper.sprite_file_icons_path
- gon.emoji_sprites_css_path = ActionController::Base.helpers.stylesheet_path('emoji_sprites')
+ gon.emoji_sprites_css_path = ActionController::Base.helpers.stylesheet_path("emoji_sprites")
gon.test_env = Rails.env.test?
gon.suggested_label_colors = LabelsHelper.suggested_colors
gon.first_day_of_week = current_user&.first_day_of_week || Gitlab::CurrentSettings.first_day_of_week
@@ -46,7 +46,7 @@ module Gitlab
# Here the `true` argument signals gon that the value should be merged
# into any existing ones, instead of overwriting them. This allows you to
# use this method to push multiple feature flags.
- gon.push({ features: { var_name => enabled } }, true)
+ gon.push({features: {var_name => enabled}}, true)
end
def default_avatar_url
@@ -56,7 +56,7 @@ module Gitlab
# We also can't use Gitlab::Utils.append_path because the image path
# may be an absolute URL.
URI.join(Gitlab.config.gitlab.url,
- ActionController::Base.helpers.image_path('no_avatar.png')).to_s
+ ActionController::Base.helpers.image_path("no_avatar.png")).to_s
end
end
end
diff --git a/lib/gitlab/google_code_import/importer.rb b/lib/gitlab/google_code_import/importer.rb
index 1e7203cb82a..27eada450de 100644
--- a/lib/gitlab/google_code_import/importer.rb
+++ b/lib/gitlab/google_code_import/importer.rb
@@ -7,18 +7,18 @@ module Gitlab
NICE_LABEL_COLOR_HASH =
{
- 'Status: New' => '#428bca',
- 'Status: Accepted' => '#5cb85c',
- 'Status: Started' => '#8e44ad',
- 'Priority: Critical' => '#ffcfcf',
- 'Priority: High' => '#deffcf',
- 'Priority: Medium' => '#fff5cc',
- 'Priority: Low' => '#cfe9ff',
- 'Type: Defect' => '#d9534f',
- 'Type: Enhancement' => '#44ad8e',
- 'Type: Task' => '#4b6dd0',
- 'Type: Review' => '#8e44ad',
- 'Type: Other' => '#7f8c8d'
+ "Status: New" => "#428bca",
+ "Status: Accepted" => "#5cb85c",
+ "Status: Started" => "#8e44ad",
+ "Priority: Critical" => "#ffcfcf",
+ "Priority: High" => "#deffcf",
+ "Priority: Medium" => "#fff5cc",
+ "Priority: Low" => "#cfe9ff",
+ "Type: Defect" => "#d9534f",
+ "Type: Enhancement" => "#44ad8e",
+ "Type: Task" => "#4b6dd0",
+ "Type: Review" => "#8e44ad",
+ "Type: Other" => "#7f8c8d",
}.freeze
def initialize(project)
@@ -48,10 +48,10 @@ module Gitlab
def user_map
@user_map ||= begin
- user_map = Hash.new do |hash, user|
+ user_map = Hash.new { |hash, user|
# Replace ... by \.\.\., so `johnsm...@gmail.com` isn't autolinked.
Client.mask_email(user).sub("...", "\\.\\.\\.")
- end
+ }
import_data = project.import_data.try(:data)
stored_user_map = import_data["user_map"] if import_data
@@ -111,13 +111,13 @@ module Gitlab
end
issue = Issue.create!(
- iid: raw_issue['id'],
- project_id: project.id,
- title: raw_issue['title'],
- description: body,
- author_id: project.creator_id,
+ iid: raw_issue["id"],
+ project_id: project.id,
+ title: raw_issue["title"],
+ description: body,
+ author_id: project.creator_id,
assignee_ids: [assignee_id],
- state: raw_issue['state'] == 'closed' ? 'closed' : 'opened'
+ state: raw_issue["state"] == "closed" ? "closed" : "opened"
)
issue_labels = ::LabelsFinder.new(nil, project_id: project.id, title: labels).execute(skip_authorization: true)
@@ -170,11 +170,11 @@ module Gitlab
# Needs to match order of `comment_columns` below.
Note.create!(
- project_id: project.id,
- noteable_type: "Issue",
- noteable_id: issue.id,
- author_id: project.creator_id,
- note: body
+ project_id: project.id,
+ noteable_type: "Issue",
+ noteable_id: issue.id,
+ author_id: project.creator_id,
+ note: body
)
end
end
@@ -184,15 +184,15 @@ module Gitlab
NICE_LABEL_COLOR_HASH[name] ||
case name
when /\AComponent:/
- '#fff39e'
+ "#fff39e"
when /\AOpSys:/
- '#e2e2e2'
+ "#e2e2e2"
when /\AMilestone:/
- '#fee3ff'
+ "#fee3ff"
when *closed_statuses.map { |s| nice_status_name(s) }
- '#cfcfcf'
+ "#cfcfcf"
else
- '#e2e2e2'
+ "#e2e2e2"
end
end
@@ -228,7 +228,7 @@ module Gitlab
end
def create_label(name)
- params = { name: name, color: nice_label_color(name) }
+ params = {name: name, color: nice_label_color(name)}
::Labels::FindOrCreateService.new(nil, project, params).execute(skip_authorization: true)
end
@@ -248,25 +248,25 @@ module Gitlab
end
if raw_updates.key?("cc")
- cc = raw_updates["cc"].map do |l|
+ cc = raw_updates["cc"].map { |l|
deleted = l.start_with?("-")
l = l[1..-1] if deleted
l = user_map[l]
l = "~~#{l}~~" if deleted
l
- end
+ }
updates << "*Cc: #{cc.join(", ")}*"
end
if raw_updates.key?("labels")
- labels = raw_updates["labels"].map do |l|
+ labels = raw_updates["labels"].map { |l|
deleted = l.start_with?("-")
l = l[1..-1] if deleted
l = nice_label_name(l)
l = "~~#{l}~~" if deleted
l
- end
+ }
updates << "*Labels: #{labels.join(", ")}*"
end
@@ -276,17 +276,17 @@ module Gitlab
end
if raw_updates.key?("blockedOn")
- blocked_ons = raw_updates["blockedOn"].map do |raw_blocked_on|
+ blocked_ons = raw_updates["blockedOn"].map { |raw_blocked_on|
format_blocking_updates(raw_blocked_on)
- end
+ }
updates << "*Blocked on: #{blocked_ons.join(", ")}*"
end
if raw_updates.key?("blocking")
- blockings = raw_updates["blocking"].map do |raw_blocked_on|
+ blockings = raw_updates["blocking"].map { |raw_blocked_on|
format_blocking_updates(raw_blocked_on)
- end
+ }
updates << "*Blocking: #{blockings.join(", ")}*"
end
@@ -314,7 +314,7 @@ module Gitlab
def format_attachments(issue_id, comment_id, raw_attachments)
return [] unless raw_attachments
- raw_attachments.map do |attachment|
+ raw_attachments.map { |attachment|
next if attachment["isDeleted"]
filename = attachment["fileName"]
@@ -323,7 +323,7 @@ module Gitlab
text = "[#{filename}](#{link})"
text = "!#{text}" if filename =~ /\.(png|jpg|jpeg|gif|bmp|tiff)\z/i
text
- end.compact
+ }.compact
end
def format_issue_comment_body(id, author, date, content, updates, attachments)
diff --git a/lib/gitlab/google_code_import/project_creator.rb b/lib/gitlab/google_code_import/project_creator.rb
index eaef85acb98..6969f2ccbe3 100644
--- a/lib/gitlab/google_code_import/project_creator.rb
+++ b/lib/gitlab/google_code_import/project_creator.rb
@@ -24,7 +24,7 @@ module Gitlab
import_type: "google_code",
import_source: repo.name,
import_url: repo.import_url,
- import_data: { data: { 'repo' => repo.raw_data, 'user_map' => user_map } }
+ import_data: {data: {"repo" => repo.raw_data, "user_map" => user_map}}
).execute
end
end
diff --git a/lib/gitlab/gpg.rb b/lib/gitlab/gpg.rb
index 32f61b1d65c..f7e82951093 100644
--- a/lib/gitlab/gpg.rb
+++ b/lib/gitlab/gpg.rb
@@ -44,9 +44,9 @@ module Gitlab
raw_keys.each_with_object({}) do |raw_key, grouped_subkeys|
primary_subkey_id = raw_key.primary_subkey.keyid
- grouped_subkeys[primary_subkey_id] = raw_key.subkeys[1..-1].map do |s|
- { keyid: s.keyid, fingerprint: s.fingerprint }
- end
+ grouped_subkeys[primary_subkey_id] = raw_key.subkeys[1..-1].map { |s|
+ {keyid: s.keyid, fingerprint: s.fingerprint}
+ }
end
end
end
@@ -57,9 +57,9 @@ module Gitlab
GPGME::Key.find(:public, fingerprints).flat_map do |raw_key|
raw_key.uids.each_with_object([]) do |uid, arr|
- name = uid.name.force_encoding('UTF-8')
- email = uid.email.force_encoding('UTF-8')
- arr << { name: name, email: email.downcase } if name.valid_encoding? && email.valid_encoding?
+ name = uid.name.force_encoding("UTF-8")
+ email = uid.email.force_encoding("UTF-8")
+ arr << {name: name, email: email.downcase} if name.valid_encoding? && email.valid_encoding?
end
end
end
@@ -85,7 +85,7 @@ module Gitlab
# `GPGME::Engine.home_dir=`
# 2. Returns the default home directory otherwise
def current_home_dir
- GPGME::Engine.info.first.home_dir || GPGME::Engine.dirinfo('homedir')
+ GPGME::Engine.info.first.home_dir || GPGME::Engine.dirinfo("homedir")
end
private
diff --git a/lib/gitlab/gpg/commit.rb b/lib/gitlab/gpg/commit.rb
index 5ff415b6126..a4471c59f2e 100644
--- a/lib/gitlab/gpg/commit.rb
+++ b/lib/gitlab/gpg/commit.rb
@@ -106,7 +106,7 @@ module Gitlab
gpg_key_primary_keyid: gpg_key&.keyid || verified_signature&.fingerprint,
gpg_key_user_name: user_infos[:name],
gpg_key_user_email: user_infos[:email],
- verification_status: verification_status
+ verification_status: verification_status,
}
end
diff --git a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
index d892d27a917..a2862daff68 100644
--- a/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
+++ b/lib/gitlab/gpg/invalid_gpg_signature_updater.rb
@@ -11,7 +11,7 @@ module Gitlab
def run
GpgSignature
.select(:id, :commit_sha, :project_id)
- .where('gpg_key_id IS NULL OR verification_status <> ?', GpgSignature.verification_statuses[:verified])
+ .where("gpg_key_id IS NULL OR verification_status <> ?", GpgSignature.verification_statuses[:verified])
.where(gpg_key_primary_keyid: @gpg_key.keyids)
.find_each { |sig| sig.gpg_commit&.update_signature!(sig) }
end
diff --git a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
index 9bb1e8fc7a2..4dd6c036fdc 100644
--- a/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
+++ b/lib/gitlab/grape_logging/formatters/lograge_with_timestamp.rb
@@ -15,7 +15,7 @@ module Gitlab
severity: severity,
duration: time[:total],
db: time[:db],
- view: time[:view]
+ view: time[:view],
}.merge(data)
::Lograge.formatter.call(attributes) + "\n"
end
@@ -23,11 +23,11 @@ module Gitlab
private
def process_params(data)
- return [] unless data.has_key?(:params)
+ return [] unless data.key?(:params)
data[:params]
.each_pair
- .map { |k, v| { key: k, value: utf8_encode_values(v) } }
+ .map { |k, v| {key: k, value: utf8_encode_values(v)} }
end
def utf8_encode_values(data)
diff --git a/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb b/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb
index fa4c5d86d44..2b2ff8bcf08 100644
--- a/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb
+++ b/lib/gitlab/grape_logging/loggers/correlation_id_logger.rb
@@ -6,7 +6,7 @@ module Gitlab
module Loggers
class CorrelationIdLogger < ::GrapeLogging::Loggers::Base
def parameters(_, _)
- { Gitlab::CorrelationId::LOG_KEY => Gitlab::CorrelationId.current_id }
+ {Gitlab::CorrelationId::LOG_KEY => Gitlab::CorrelationId.current_id}
end
end
end
diff --git a/lib/gitlab/grape_logging/loggers/perf_logger.rb b/lib/gitlab/grape_logging/loggers/perf_logger.rb
index e3b9c59bd6e..118f9c4d5a4 100644
--- a/lib/gitlab/grape_logging/loggers/perf_logger.rb
+++ b/lib/gitlab/grape_logging/loggers/perf_logger.rb
@@ -6,7 +6,7 @@ module Gitlab
module Loggers
class PerfLogger < ::GrapeLogging::Loggers::Base
def parameters(_, _)
- { gitaly_calls: Gitlab::GitalyClient.get_request_count }
+ {gitaly_calls: Gitlab::GitalyClient.get_request_count}
end
end
end
diff --git a/lib/gitlab/grape_logging/loggers/queue_duration_logger.rb b/lib/gitlab/grape_logging/loggers/queue_duration_logger.rb
index 705e23adff2..51f05400698 100644
--- a/lib/gitlab/grape_logging/loggers/queue_duration_logger.rb
+++ b/lib/gitlab/grape_logging/loggers/queue_duration_logger.rb
@@ -13,14 +13,14 @@ module Gitlab
end
def parameters(request, _)
- proxy_start = request.env['HTTP_GITLAB_WORKHORSE_PROXY_START'].presence
+ proxy_start = request.env["HTTP_GITLAB_WORKHORSE_PROXY_START"].presence
return {} unless proxy_start && start_time
# Time in milliseconds since gitlab-workhorse started the request
duration = (start_time.to_f * 1_000 - proxy_start.to_f / 1_000_000).round(2)
- { 'queue_duration': duration }
+ {'queue_duration': duration}
end
end
end
diff --git a/lib/gitlab/grape_logging/loggers/route_logger.rb b/lib/gitlab/grape_logging/loggers/route_logger.rb
index f3146b4dfd9..04820a58f8d 100644
--- a/lib/gitlab/grape_logging/loggers/route_logger.rb
+++ b/lib/gitlab/grape_logging/loggers/route_logger.rb
@@ -12,7 +12,7 @@ module Gitlab
return {} unless route
- { route: route }
+ {route: route}
rescue
# endpoint.route calls env[Grape::Env::GRAPE_ROUTING_ARGS][:route_info]
# but env[Grape::Env::GRAPE_ROUTING_ARGS] is nil in the case of a 405 response
diff --git a/lib/gitlab/graphql/authorize/authorize_resource.rb b/lib/gitlab/graphql/authorize/authorize_resource.rb
index b367a97105c..20076e7c298 100644
--- a/lib/gitlab/graphql/authorize/authorize_resource.rb
+++ b/lib/gitlab/graphql/authorize/authorize_resource.rb
@@ -11,11 +11,11 @@ module Gitlab
# If the `#authorize` call is used on multiple classes, we add the
# permissions specified on a subclass, to the ones that were specified
# on it's superclass.
- @required_permissions ||= if self.respond_to?(:superclass) && superclass.respond_to?(:required_permissions)
- superclass.required_permissions.dup
- else
- []
- end
+ @required_permissions ||= if respond_to?(:superclass) && superclass.respond_to?(:required_permissions)
+ superclass.required_permissions.dup
+ else
+ []
+ end
end
def authorize(*permissions)
@@ -43,7 +43,7 @@ module Gitlab
def authorize!(object)
unless authorized?(object)
raise Gitlab::Graphql::Errors::ResourceNotAvailable,
- "The resource that you are attempting to access does not exist or you don't have permission to perform this action"
+ "The resource that you are attempting to access does not exist or you don't have permission to perform this action"
end
end
diff --git a/lib/gitlab/graphql/authorize/instrumentation.rb b/lib/gitlab/graphql/authorize/instrumentation.rb
index 593da8471dd..39c822be189 100644
--- a/lib/gitlab/graphql/authorize/instrumentation.rb
+++ b/lib/gitlab/graphql/authorize/instrumentation.rb
@@ -12,7 +12,7 @@ module Gitlab
old_resolver = field.resolve_proc
- new_resolver = -> (obj, args, ctx) do
+ new_resolver = ->(obj, args, ctx) do
resolved_obj = old_resolver.call(obj, args, ctx)
checker = build_checker(ctx[:current_user], required_permissions)
diff --git a/lib/gitlab/graphql/expose_permissions.rb b/lib/gitlab/graphql/expose_permissions.rb
index 365b7cca24f..d7f95d5e75f 100644
--- a/lib/gitlab/graphql/expose_permissions.rb
+++ b/lib/gitlab/graphql/expose_permissions.rb
@@ -5,11 +5,11 @@ module Gitlab
module ExposePermissions
extend ActiveSupport::Concern
prepended do
- def self.expose_permissions(permission_type, description: 'Permissions for the current user on the resource')
+ def self.expose_permissions(permission_type, description: "Permissions for the current user on the resource")
field :user_permissions, permission_type,
- description: description,
- null: false,
- resolve: -> (obj, _, _) { obj }
+ description: description,
+ null: false,
+ resolve: ->(obj, _, _) { obj }
end
end
end
diff --git a/lib/gitlab/graphql/loaders/batch_model_loader.rb b/lib/gitlab/graphql/loaders/batch_model_loader.rb
index 5a0099dc6b1..6e1aed417b7 100644
--- a/lib/gitlab/graphql/loaders/batch_model_loader.rb
+++ b/lib/gitlab/graphql/loaders/batch_model_loader.rb
@@ -12,13 +12,13 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def find
- BatchLoader.for({ model: model_class, id: model_id }).batch do |loader_info, loader|
+ BatchLoader.for({model: model_class, id: model_id}).batch do |loader_info, loader|
per_model = loader_info.group_by { |info| info[:model] }
per_model.each do |model, info|
ids = info.map { |i| i[:id] }
results = model.where(id: ids)
- results.each { |record| loader.call({ model: model, id: record.id }, record) }
+ results.each { |record| loader.call({model: model, id: record.id}, record) }
end
end
end
diff --git a/lib/gitlab/graphql/mount_mutation.rb b/lib/gitlab/graphql/mount_mutation.rb
index 9048967d4e1..c23cda8ce3e 100644
--- a/lib/gitlab/graphql/mount_mutation.rb
+++ b/lib/gitlab/graphql/mount_mutation.rb
@@ -10,7 +10,7 @@ module Gitlab
# Using an underscored field name symbol will make `graphql-ruby`
# standardize the field name
field mutation_class.graphql_name.underscore.to_sym,
- mutation: mutation_class
+ mutation: mutation_class
end
end
end
diff --git a/lib/gitlab/graphql/present/instrumentation.rb b/lib/gitlab/graphql/present/instrumentation.rb
index ab03c40c22d..1c1bd9c8947 100644
--- a/lib/gitlab/graphql/present/instrumentation.rb
+++ b/lib/gitlab/graphql/present/instrumentation.rb
@@ -13,7 +13,7 @@ module Gitlab
old_resolver = field.resolve_proc
- resolve_with_presenter = -> (presented_type, args, context) do
+ resolve_with_presenter = ->(presented_type, args, context) do
# We need to wrap the original presentation type into a type that
# uses the presenter as an object.
object = presented_type.object
diff --git a/lib/gitlab/graphs/commits.rb b/lib/gitlab/graphs/commits.rb
index 66e1b2e78b4..f5eeb248627 100644
--- a/lib/gitlab/graphs/commits.rb
+++ b/lib/gitlab/graphs/commits.rb
@@ -34,9 +34,9 @@ module Gitlab
(1..31).to_a.each { |day| @commits_per_month[day] = 0 }
@commits.each do |commit|
- hour = commit.committed_date.strftime('%k').to_i
- day_of_month = commit.committed_date.strftime('%e').to_i
- weekday = commit.committed_date.strftime('%A')
+ hour = commit.committed_date.strftime("%k").to_i
+ day_of_month = commit.committed_date.strftime("%e").to_i
+ weekday = commit.committed_date.strftime("%A")
@commits_per_week_days[weekday] ||= 0
@commits_per_week_days[weekday] += 1
diff --git a/lib/gitlab/hashed_storage/rake_helper.rb b/lib/gitlab/hashed_storage/rake_helper.rb
index 38f552fab03..051fc4b3b1f 100644
--- a/lib/gitlab/hashed_storage/rake_helper.rb
+++ b/lib/gitlab/hashed_storage/rake_helper.rb
@@ -4,19 +4,19 @@ module Gitlab
module HashedStorage
module RakeHelper
def self.batch_size
- ENV.fetch('BATCH', 200).to_i
+ ENV.fetch("BATCH", 200).to_i
end
def self.listing_limit
- ENV.fetch('LIMIT', 500).to_i
+ ENV.fetch("LIMIT", 500).to_i
end
def self.range_from
- ENV['ID_FROM']
+ ENV["ID_FROM"]
end
def self.range_to
- ENV['ID_TO']
+ ENV["ID_TO"]
end
def self.range_single_item?
@@ -35,7 +35,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def self.legacy_attachments_relation
- Upload.joins(<<~SQL).where('projects.storage_version < :version OR projects.storage_version IS NULL', version: Project::HASHED_STORAGE_FEATURES[:attachments])
+ Upload.joins(<<~SQL).where("projects.storage_version < :version OR projects.storage_version IS NULL", version: Project::HASHED_STORAGE_FEATURES[:attachments])
JOIN projects
ON (uploads.model_type='Project' AND uploads.model_id=projects.id)
SQL
@@ -44,7 +44,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def self.hashed_attachments_relation
- Upload.joins(<<~SQL).where('projects.storage_version >= :version', version: Project::HASHED_STORAGE_FEATURES[:attachments])
+ Upload.joins(<<~SQL).where("projects.storage_version >= :version", version: Project::HASHED_STORAGE_FEATURES[:attachments])
JOIN projects
ON (uploads.model_type='Project' AND uploads.model_id=projects.id)
SQL
diff --git a/lib/gitlab/health_checks/base_abstract_check.rb b/lib/gitlab/health_checks/base_abstract_check.rb
index 1d31f59999c..82dfc56dda6 100644
--- a/lib/gitlab/health_checks/base_abstract_check.rb
+++ b/lib/gitlab/health_checks/base_abstract_check.rb
@@ -8,7 +8,7 @@ module Gitlab
end
def human_name
- name.sub(/_check$/, '').capitalize
+ name.sub(/_check$/, "").capitalize
end
def readiness
@@ -36,11 +36,9 @@ module Gitlab
end
def catch_timeout(seconds, &block)
- begin
- Timeout.timeout(seconds.to_i, &block)
- rescue Timeout::Error => ex
- ex
- end
+ Timeout.timeout(seconds.to_i, &block)
+ rescue Timeout::Error => ex
+ ex
end
end
end
diff --git a/lib/gitlab/health_checks/db_check.rb b/lib/gitlab/health_checks/db_check.rb
index 2bcd25cd3cc..d8e74b0158f 100644
--- a/lib/gitlab/health_checks/db_check.rb
+++ b/lib/gitlab/health_checks/db_check.rb
@@ -9,19 +9,19 @@ module Gitlab
private
def metric_prefix
- 'db_ping'
+ "db_ping"
end
def successful?(result)
- result == '1'
+ result == "1"
end
def check
catch_timeout 10.seconds do
if Gitlab::Database.postgresql?
- ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.[]('ping')&.to_s
+ ActiveRecord::Base.connection.execute("SELECT 1 as ping")&.first&.[]("ping")&.to_s
else
- ActiveRecord::Base.connection.execute('SELECT 1 as ping')&.first&.first&.to_s
+ ActiveRecord::Base.connection.execute("SELECT 1 as ping")&.first&.first&.to_s
end
end
end
diff --git a/lib/gitlab/health_checks/gitaly_check.rb b/lib/gitlab/health_checks/gitaly_check.rb
index 898733fea5d..4b5d1d97f68 100644
--- a/lib/gitlab/health_checks/gitaly_check.rb
+++ b/lib/gitlab/health_checks/gitaly_check.rb
@@ -5,7 +5,7 @@ module Gitlab
class GitalyCheck
extend BaseAbstractCheck
- METRIC_PREFIX = 'gitaly_health_check'.freeze
+ METRIC_PREFIX = "gitaly_health_check"
class << self
def readiness
@@ -17,11 +17,11 @@ module Gitlab
def metrics
Gitaly::Server.all.flat_map do |server|
result, elapsed = with_timing { server.read_writeable? }
- labels = { shard: server.storage }
+ labels = {shard: server.storage}
[
metric("#{metric_prefix}_success", result ? 1 : 0, **labels),
- metric("#{metric_prefix}_latency_seconds", elapsed, **labels)
+ metric("#{metric_prefix}_latency_seconds", elapsed, **labels),
]
end
end
diff --git a/lib/gitlab/health_checks/prometheus_text_format.rb b/lib/gitlab/health_checks/prometheus_text_format.rb
index 2a8f9d31cd5..7a591da362a 100644
--- a/lib/gitlab/health_checks/prometheus_text_format.rb
+++ b/lib/gitlab/health_checks/prometheus_text_format.rb
@@ -29,7 +29,7 @@ module Gitlab
end
def metric_text(metric)
- labels = metric.labels&.map { |key, value| "#{key}=\"#{value}\"" }&.join(',') || ''
+ labels = metric.labels&.map { |key, value| "#{key}=\"#{value}\"" }&.join(",") || ""
if labels.empty?
"#{metric.name} #{metric.value}"
diff --git a/lib/gitlab/health_checks/redis/cache_check.rb b/lib/gitlab/health_checks/redis/cache_check.rb
index 0c8fe83893b..720cfd6d819 100644
--- a/lib/gitlab/health_checks/redis/cache_check.rb
+++ b/lib/gitlab/health_checks/redis/cache_check.rb
@@ -14,11 +14,11 @@ module Gitlab
private
def metric_prefix
- 'redis_cache_ping'
+ "redis_cache_ping"
end
def successful?(result)
- result == 'PONG'
+ result == "PONG"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/health_checks/redis/queues_check.rb b/lib/gitlab/health_checks/redis/queues_check.rb
index b1e33b9f459..4317ea295e1 100644
--- a/lib/gitlab/health_checks/redis/queues_check.rb
+++ b/lib/gitlab/health_checks/redis/queues_check.rb
@@ -14,11 +14,11 @@ module Gitlab
private
def metric_prefix
- 'redis_queues_ping'
+ "redis_queues_ping"
end
def successful?(result)
- result == 'PONG'
+ result == "PONG"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/health_checks/redis/redis_check.rb b/lib/gitlab/health_checks/redis/redis_check.rb
index f7e46fce134..7c6be0831cb 100644
--- a/lib/gitlab/health_checks/redis/redis_check.rb
+++ b/lib/gitlab/health_checks/redis/redis_check.rb
@@ -10,11 +10,11 @@ module Gitlab
private
def metric_prefix
- 'redis_ping'
+ "redis_ping"
end
def successful?(result)
- result == 'PONG'
+ result == "PONG"
end
def check
diff --git a/lib/gitlab/health_checks/redis/shared_state_check.rb b/lib/gitlab/health_checks/redis/shared_state_check.rb
index 285ac271929..b46595f1fbe 100644
--- a/lib/gitlab/health_checks/redis/shared_state_check.rb
+++ b/lib/gitlab/health_checks/redis/shared_state_check.rb
@@ -14,11 +14,11 @@ module Gitlab
private
def metric_prefix
- 'redis_shared_state_ping'
+ "redis_shared_state_ping"
end
def successful?(result)
- result == 'PONG'
+ result == "PONG"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/health_checks/simple_abstract_check.rb b/lib/gitlab/health_checks/simple_abstract_check.rb
index 3588260d6eb..5c4152d9570 100644
--- a/lib/gitlab/health_checks/simple_abstract_check.rb
+++ b/lib/gitlab/health_checks/simple_abstract_check.rb
@@ -22,7 +22,7 @@ module Gitlab
[
metric("#{metric_prefix}_timeout", result.is_a?(Timeout::Error) ? 1 : 0),
metric("#{metric_prefix}_success", successful?(result) ? 1 : 0),
- metric("#{metric_prefix}_latency_seconds", elapsed)
+ metric("#{metric_prefix}_latency_seconds", elapsed),
]
end
diff --git a/lib/gitlab/highlight.rb b/lib/gitlab/highlight.rb
index a4e60bbd828..c3e565be73d 100644
--- a/lib/gitlab/highlight.rb
+++ b/lib/gitlab/highlight.rb
@@ -31,8 +31,8 @@ module Gitlab
def lexer
@lexer ||= custom_language || begin
Rouge::Lexer.guess(filename: @blob_name, source: @blob_content).new
- rescue Rouge::Guesser::Ambiguous => e
- e.alternatives.sort_by(&:tag).first
+ rescue Rouge::Guesser::Ambiguous => e
+ e.alternatives.min_by(&:tag)
end
end
diff --git a/lib/gitlab/hook_data/base_builder.rb b/lib/gitlab/hook_data/base_builder.rb
index d54175bce81..0f6c5616c67 100644
--- a/lib/gitlab/hook_data/base_builder.rb
+++ b/lib/gitlab/hook_data/base_builder.rb
@@ -27,8 +27,8 @@ module Gitlab
markdown_text.gsub(MARKDOWN_SIMPLE_IMAGE) do
if $~[:image]
url = $~[:url]
- url = "#{uploads_prefix}#{url}" if url.start_with?('/uploads')
- url = "/#{url}" unless url.start_with?('/')
+ url = "#{uploads_prefix}#{url}" if url.start_with?("/uploads")
+ url = "/#{url}" unless url.start_with?("/")
"![#{$~[:title]}](#{Gitlab.config.gitlab.url}#{url})"
else
@@ -38,7 +38,7 @@ module Gitlab
end
def uploads_prefix
- project&.full_path || ''
+ project&.full_path || ""
end
def project
diff --git a/lib/gitlab/hook_data/issuable_builder.rb b/lib/gitlab/hook_data/issuable_builder.rb
index 0803df65632..1242dcd6250 100644
--- a/lib/gitlab/hook_data/issuable_builder.rb
+++ b/lib/gitlab/hook_data/issuable_builder.rb
@@ -5,7 +5,7 @@ module Gitlab
class IssuableBuilder < BaseBuilder
CHANGES_KEYS = %i[previous current].freeze
- alias_method :issuable, :object
+ alias issuable object
def build(user: nil, changes: {})
hook_data = {
@@ -17,7 +17,7 @@ module Gitlab
labels: issuable.labels.map(&:hook_attrs),
changes: final_changes(changes.slice(*safe_keys)),
# DEPRECATED
- repository: issuable.project.hook_attrs.slice(:name, :url, :description, :homepage)
+ repository: issuable.project.hook_attrs.slice(:name, :url, :description, :homepage),
}
if issuable.is_a?(Issue)
@@ -57,9 +57,8 @@ module Gitlab
end
def final_changes(changes_hash)
- changes_hash.reduce({}) do |hash, (key, changes_array)|
+ changes_hash.each_with_object({}) do |(key, changes_array), hash|
hash[key] = Hash[CHANGES_KEYS.zip(changes_array)]
- hash
end
end
end
diff --git a/lib/gitlab/hook_data/issue_builder.rb b/lib/gitlab/hook_data/issue_builder.rb
index c99353b9d49..70aaab28684 100644
--- a/lib/gitlab/hook_data/issue_builder.rb
+++ b/lib/gitlab/hook_data/issue_builder.rb
@@ -34,21 +34,21 @@ module Gitlab
].freeze
end
- alias_method :issue, :object
+ alias issue object
def build
attrs = {
- description: absolute_image_urls(issue.description),
- url: Gitlab::UrlBuilder.build(issue),
- total_time_spent: issue.total_time_spent,
- human_total_time_spent: issue.human_total_time_spent,
- human_time_estimate: issue.human_time_estimate,
- assignee_ids: issue.assignee_ids,
- assignee_id: issue.assignee_ids.first # This key is deprecated
+ description: absolute_image_urls(issue.description),
+ url: Gitlab::UrlBuilder.build(issue),
+ total_time_spent: issue.total_time_spent,
+ human_total_time_spent: issue.human_total_time_spent,
+ human_time_estimate: issue.human_time_estimate,
+ assignee_ids: issue.assignee_ids,
+ assignee_id: issue.assignee_ids.first, # This key is deprecated
}
issue.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
- .merge!(attrs)
+ .merge!(attrs)
end
end
end
diff --git a/lib/gitlab/hook_data/merge_request_builder.rb b/lib/gitlab/hook_data/merge_request_builder.rb
index ad38e26e40a..13ae10cb74a 100644
--- a/lib/gitlab/hook_data/merge_request_builder.rb
+++ b/lib/gitlab/hook_data/merge_request_builder.rb
@@ -39,7 +39,7 @@ module Gitlab
total_time_spent
].freeze
- alias_method :merge_request, :object
+ alias merge_request object
def build
attrs = {
@@ -51,11 +51,11 @@ module Gitlab
work_in_progress: merge_request.work_in_progress?,
total_time_spent: merge_request.total_time_spent,
human_total_time_spent: merge_request.human_total_time_spent,
- human_time_estimate: merge_request.human_time_estimate
+ human_time_estimate: merge_request.human_time_estimate,
}
merge_request.attributes.with_indifferent_access.slice(*self.class.safe_hook_attributes)
- .merge!(attrs)
+ .merge!(attrs)
end
end
end
diff --git a/lib/gitlab/hook_data/note_builder.rb b/lib/gitlab/hook_data/note_builder.rb
index ae30ef6364b..746558e9f68 100644
--- a/lib/gitlab/hook_data/note_builder.rb
+++ b/lib/gitlab/hook_data/note_builder.rb
@@ -28,7 +28,7 @@ module Gitlab
updated_by_id
].freeze
- alias_method :note, :object
+ alias note object
def build
note
diff --git a/lib/gitlab/hook_data/wiki_page_builder.rb b/lib/gitlab/hook_data/wiki_page_builder.rb
index 67f06b1ca46..7893d61abf3 100644
--- a/lib/gitlab/hook_data/wiki_page_builder.rb
+++ b/lib/gitlab/hook_data/wiki_page_builder.rb
@@ -3,13 +3,13 @@
module Gitlab
module HookData
class WikiPageBuilder < BaseBuilder
- alias_method :wiki_page, :object
+ alias wiki_page object
def build
wiki_page
.attributes
.merge(
- 'content' => absolute_image_urls(wiki_page.content)
+ "content" => absolute_image_urls(wiki_page.content)
)
end
end
diff --git a/lib/gitlab/http_io.rb b/lib/gitlab/http_io.rb
index 6a9fb85b054..f243597c3da 100644
--- a/lib/gitlab/http_io.rb
+++ b/lib/gitlab/http_io.rb
@@ -14,7 +14,7 @@ module Gitlab
attr_reader :tell
attr_reader :chunk, :chunk_range
- alias_method :pos, :tell
+ alias pos tell
def initialize(url, size)
raise InvalidURLError unless ::Gitlab::UrlSanitizer.valid?(url)
@@ -57,7 +57,7 @@ module Gitlab
-1
end
- raise 'new position is outside of file' if new_pos < 0 || new_pos > size
+ raise "new position is outside of file" if new_pos < 0 || new_pos > size
@tell = new_pos
end
@@ -95,9 +95,7 @@ module Gitlab
out = out.join
# If outbuf is passed, we put the output into the buffer. This supports IO.copy_stream functionality
- if outbuf
- outbuf.replace(out)
- end
+ outbuf&.replace(out)
out
end
@@ -149,11 +147,11 @@ module Gitlab
def get_chunk
unless in_range?
- response = Net::HTTP.start(uri.hostname, uri.port, proxy_from_env: true, use_ssl: uri.scheme == 'https') do |http|
+ response = Net::HTTP.start(uri.hostname, uri.port, proxy_from_env: true, use_ssl: uri.scheme == "https") { |http|
http.request(request)
- end
+ }
- raise FailedToGetChunkError unless response.code == '200' || response.code == '206'
+ raise FailedToGetChunkError unless response.code == "200" || response.code == "206"
@chunk = response.body.force_encoding(Encoding::BINARY)
@chunk_range = response.content_range
diff --git a/lib/gitlab/i18n.rb b/lib/gitlab/i18n.rb
index 7e0398f09af..26841b18ad9 100644
--- a/lib/gitlab/i18n.rb
+++ b/lib/gitlab/i18n.rb
@@ -5,28 +5,28 @@ module Gitlab
extend self
AVAILABLE_LANGUAGES = {
- 'en' => 'English',
- 'es' => 'Español',
- 'gl_ES' => 'Galego',
- 'de' => 'Deutsch',
- 'fr' => 'Français',
- 'pt_BR' => 'Português (Brasil)',
- 'zh_CN' => '简体中文',
- 'zh_HK' => '繁體中文 (香港)',
- 'zh_TW' => '繁體中文 (臺灣)',
- 'bg' => 'български',
- 'ru' => 'Русский',
- 'eo' => 'Esperanto',
- 'it' => 'Italiano',
- 'uk' => 'Українська',
- 'ja' => '日本語',
- 'ko' => '한국어',
- 'nl_NL' => 'Nederlands',
- 'tr_TR' => 'Türkçe',
- 'id_ID' => 'Bahasa Indonesia',
- 'fil_PH' => 'Filipino',
- 'pl_PL' => 'Polski',
- 'cs_CZ' => 'Čeština'
+ "en" => "English",
+ "es" => "Español",
+ "gl_ES" => "Galego",
+ "de" => "Deutsch",
+ "fr" => "Français",
+ "pt_BR" => "Português (Brasil)",
+ "zh_CN" => "简体中文",
+ "zh_HK" => "繁體中文 (香港)",
+ "zh_TW" => "繁體中文 (臺灣)",
+ "bg" => "български",
+ "ru" => "Русский",
+ "eo" => "Esperanto",
+ "it" => "Italiano",
+ "uk" => "Українська",
+ "ja" => "日本語",
+ "ko" => "한국어",
+ "nl_NL" => "Nederlands",
+ "tr_TR" => "Türkçe",
+ "id_ID" => "Bahasa Indonesia",
+ "fil_PH" => "Filipino",
+ "pl_PL" => "Polski",
+ "cs_CZ" => "Čeština",
}.freeze
def available_locales
diff --git a/lib/gitlab/i18n/metadata_entry.rb b/lib/gitlab/i18n/metadata_entry.rb
index 3764e379681..5caabe17d41 100644
--- a/lib/gitlab/i18n/metadata_entry.rb
+++ b/lib/gitlab/i18n/metadata_entry.rb
@@ -17,7 +17,7 @@ module Gitlab
def expected_forms
return nil unless plural_information
- plural_information['nplurals'].to_i
+ plural_information["nplurals"].to_i
end
def forms_to_test
@@ -29,7 +29,7 @@ module Gitlab
def plural_information
return @plural_information if defined?(@plural_information)
- if plural_line = entry_data[:msgstr].detect { |metadata_line| metadata_line.starts_with?('Plural-Forms: ') }
+ if plural_line = entry_data[:msgstr].detect { |metadata_line| metadata_line.starts_with?("Plural-Forms: ") }
@plural_information = Hash[plural_line.scan(/(\w+)=([^;\n]+)/)]
end
end
diff --git a/lib/gitlab/i18n/po_linter.rb b/lib/gitlab/i18n/po_linter.rb
index 3e9a035010f..1079e6e1a08 100644
--- a/lib/gitlab/i18n/po_linter.rb
+++ b/lib/gitlab/i18n/po_linter.rb
@@ -20,7 +20,7 @@ module Gitlab
def validate_po
if parse_error = parse_po
- return 'PO-syntax errors' => [parse_error]
+ return "PO-syntax errors" => [parse_error]
end
validate_entries
@@ -34,12 +34,12 @@ module Gitlab
if entries.first[:msgid].empty?
@metadata_entry = Gitlab::I18n::MetadataEntry.new(entries.shift)
else
- return 'Missing metadata entry.'
+ return "Missing metadata entry."
end
- @translation_entries = entries.map do |entry_data|
+ @translation_entries = entries.map { |entry_data|
Gitlab::I18n::TranslationEntry.new(entry_data, metadata_entry.expected_forms)
- end
+ }
nil
rescue SimplePoParser::ParserError => e
@@ -73,15 +73,15 @@ module Gitlab
def validate_unescaped_chars(errors, entry)
if entry.msgid_contains_unescaped_chars?
- errors << 'contains unescaped `%`, escape it using `%%`'
+ errors << "contains unescaped `%`, escape it using `%%`"
end
if entry.plural_id_contains_unescaped_chars?
- errors << 'plural id contains unescaped `%`, escape it using `%%`'
+ errors << "plural id contains unescaped `%`, escape it using `%%`"
end
if entry.translations_contain_unescaped_chars?
- errors << 'translation contains unescaped `%`, escape it using `%%`'
+ errors << "translation contains unescaped `%`, escape it using `%%`"
end
end
@@ -91,21 +91,21 @@ module Gitlab
if entry.has_plural? && entry.all_translations.size != metadata_entry.expected_forms
errors << "should have #{metadata_entry.expected_forms} "\
- "#{'translations'.pluralize(metadata_entry.expected_forms)}"
+ "#{"translations".pluralize(metadata_entry.expected_forms)}"
end
end
def validate_newlines(errors, entry)
if entry.msgid_has_multiple_lines?
- errors << 'is defined over multiple lines, this breaks some tooling.'
+ errors << "is defined over multiple lines, this breaks some tooling."
end
if entry.plural_id_has_multiple_lines?
- errors << 'plural is defined over multiple lines, this breaks some tooling.'
+ errors << "plural is defined over multiple lines, this breaks some tooling."
end
if entry.translations_have_multiple_lines?
- errors << 'has translations defined over multiple lines, this breaks some tooling.'
+ errors << "has translations defined over multiple lines, this breaks some tooling."
end
end
@@ -160,11 +160,11 @@ module Gitlab
used_variables = entry.msgid.scan(VARIABLE_REGEX)
variables = fill_in_variables(used_variables)
- translation = if entry.msgid.include?('|')
- FastGettext::Translation.s_(entry.msgid)
- else
- FastGettext::Translation._(entry.msgid)
- end
+ translation = if entry.msgid.include?("|")
+ FastGettext::Translation.s_(entry.msgid)
+ else
+ FastGettext::Translation._(entry.msgid)
+ end
translation % variables if used_variables.any?
end
@@ -207,9 +207,9 @@ module Gitlab
# This calls the C function that defines the pluralization rule, it can
# return a boolean (`false` represents 0, `true` represents 1) or an integer
# that specifies the plural form to be used for the given number
- pluralization_result = Gitlab::I18n.with_locale(locale) do
+ pluralization_result = Gitlab::I18n.with_locale(locale) {
FastGettext.pluralisation_rule.call(counter)
- end
+ }
case pluralization_result
when false
@@ -226,13 +226,12 @@ module Gitlab
[]
elsif variables.any? { |variable| unnamed_variable?(variable) }
variables.map do |variable|
- variable == '%d' ? Random.rand(1000) : Gitlab::Utils.random_string
+ variable == "%d" ? Random.rand(1000) : Gitlab::Utils.random_string
end
else
- variables.inject({}) do |hash, variable|
+ variables.each_with_object({}) do |variable, hash|
variable_name = variable[/\w+/]
hash[variable_name] = Gitlab::Utils.random_string
- hash
end
end
end
@@ -241,11 +240,11 @@ module Gitlab
unnamed_variables, named_variables = variables.partition { |name| unnamed_variable?(name) }
if unnamed_variables.any? && named_variables.any?
- errors << 'is combining named variables with unnamed variables'
+ errors << "is combining named variables with unnamed variables"
end
if unnamed_variables.size > 1
- errors << 'is combining multiple unnamed variables'
+ errors << "is combining multiple unnamed variables"
end
end
@@ -269,7 +268,7 @@ module Gitlab
end
def unnamed_variable?(variable_name)
- !variable_name.start_with?('%{')
+ !variable_name.start_with?("%{")
end
def validate_flags(errors, entry)
diff --git a/lib/gitlab/i18n/translation_entry.rb b/lib/gitlab/i18n/translation_entry.rb
index 19c10b2e402..3a503ba8e34 100644
--- a/lib/gitlab/i18n/translation_entry.rb
+++ b/lib/gitlab/i18n/translation_entry.rb
@@ -41,10 +41,10 @@ module Gitlab
return [] unless translated?
@plural_translations ||= if has_singular_translation?
- all_translations.drop(1)
- else
- all_translations
- end
+ all_translations.drop(1)
+ else
+ all_translations
+ end
end
def flag
@@ -87,7 +87,7 @@ module Gitlab
def translation_entries
@translation_entries ||= entry_data.fetch_values(*translation_keys)
- .reject(&:empty?)
+ .reject(&:empty?)
end
def translation_keys
diff --git a/lib/gitlab/identifier.rb b/lib/gitlab/identifier.rb
index d5f94ad04f1..8cf8f1a59ec 100644
--- a/lib/gitlab/identifier.rb
+++ b/lib/gitlab/identifier.rb
@@ -5,10 +5,10 @@
module Gitlab
module Identifier
def identify(identifier)
- if identifier =~ /\Auser-\d+\Z/
+ if /\Auser-\d+\Z/.match?(identifier)
# git push over http
identify_using_user(identifier)
- elsif identifier =~ /\Akey-\d+\Z/
+ elsif /\Akey-\d+\Z/.match?(identifier)
# git push over ssh
identify_using_ssh_key(identifier)
end
@@ -46,7 +46,7 @@ module Gitlab
@identification_cache ||= {
email: {},
user: {},
- ssh_key: {}
+ ssh_key: {},
}
end
end
diff --git a/lib/gitlab/import/database_helpers.rb b/lib/gitlab/import/database_helpers.rb
index 5b3f30d894a..0f57918c72a 100644
--- a/lib/gitlab/import/database_helpers.rb
+++ b/lib/gitlab/import/database_helpers.rb
@@ -14,7 +14,7 @@ module Gitlab
# callbacks or validation rules, as doing this wouldn't scale when
# importing very large projects.
result = Gitlab::Database
- .bulk_insert(relation.table_name, [attributes], return_ids: true)
+ .bulk_insert(relation.table_name, [attributes], return_ids: true)
# MySQL doesn't support returning the IDs of a bulk insert in a way that
# is not a pain, so in this case we'll issue an extra query instead.
diff --git a/lib/gitlab/import/logger.rb b/lib/gitlab/import/logger.rb
index ab3e822a4e9..24fab7b7561 100644
--- a/lib/gitlab/import/logger.rb
+++ b/lib/gitlab/import/logger.rb
@@ -4,7 +4,7 @@ module Gitlab
module Import
class Logger < ::Gitlab::JsonLogger
def self.file_name_noext
- 'importer'
+ "importer"
end
end
end
diff --git a/lib/gitlab/import_export.rb b/lib/gitlab/import_export.rb
index f63a5ece71e..5ddf3452bc9 100644
--- a/lib/gitlab/import_export.rb
+++ b/lib/gitlab/import_export.rb
@@ -5,7 +5,7 @@ module Gitlab
extend self
# For every version update, the version history in import_export.md has to be kept up to date.
- VERSION = '0.2.4'.freeze
+ VERSION = "0.2.4"
FILENAME_LIMIT = 50
def export_path(relative_path:)
@@ -13,11 +13,11 @@ module Gitlab
end
def storage_path
- File.join(Settings.shared['path'], 'tmp/project_exports')
+ File.join(Settings.shared["path"], "tmp/project_exports")
end
def import_upload_path(filename:)
- File.join(storage_path, 'uploads', filename)
+ File.join(storage_path, "uploads", filename)
end
def project_filename
@@ -29,15 +29,15 @@ module Gitlab
end
def config_file
- Rails.root.join('lib/gitlab/import_export/import_export.yml')
+ Rails.root.join("lib/gitlab/import_export/import_export.yml")
end
def version_filename
- 'VERSION'
+ "VERSION"
end
def export_filename(project:)
- basename = "#{Time.now.strftime('%Y-%m-%d_%H-%M-%3N')}_#{project.full_path.tr('/', '_')}"
+ basename = "#{Time.now.strftime("%Y-%m-%d_%H-%M-%3N")}_#{project.full_path.tr("/", "_")}"
"#{basename[0..FILENAME_LIMIT]}_export.tar.gz"
end
diff --git a/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb b/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
index d39b6fe5955..b2716e844af 100644
--- a/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
+++ b/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy.rb
@@ -10,7 +10,7 @@ module Gitlab
StrategyError = Class.new(StandardError)
- AFTER_EXPORT_LOCK_FILE_NAME = '.after_export_action'.freeze
+ AFTER_EXPORT_LOCK_FILE_NAME = ".after_export_action"
private
diff --git a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
index b30900f7c61..ea458fbccbc 100644
--- a/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
+++ b/lib/gitlab/import_export/after_export_strategies/web_upload_strategy.rb
@@ -4,9 +4,9 @@ module Gitlab
module ImportExport
module AfterExportStrategies
class WebUploadStrategy < BaseAfterExportStrategy
- PUT_METHOD = 'PUT'.freeze
- POST_METHOD = 'POST'.freeze
- INVALID_HTTP_METHOD = 'invalid. Only PUT and POST methods allowed.'.freeze
+ PUT_METHOD = "PUT"
+ POST_METHOD = "POST"
+ INVALID_HTTP_METHOD = "invalid. Only PUT and POST methods allowed."
validates :url, url: true
@@ -30,8 +30,8 @@ module Gitlab
def handle_response_error(response)
unless response.success?
- error_code = response.dig('Error', 'Code') || response.code
- error_message = response.dig('Error', 'Message') || response.message
+ error_code = response.dig("Error", "Code") || response.code
+ error_message = response.dig("Error", "Message") || response.message
raise StrategyError.new("Error uploading the project. Code #{error_code}: #{error_message}")
end
@@ -42,7 +42,7 @@ module Gitlab
def send_file
Gitlab::HTTP.public_send(http_method.downcase, url, send_file_options) # rubocop:disable GitlabSecurity/PublicSend
ensure
- export_file.close if export_file
+ export_file&.close
end
def export_file
@@ -52,12 +52,12 @@ module Gitlab
def send_file_options
{
body_stream: export_file,
- headers: headers
+ headers: headers,
}
end
def headers
- { 'Content-Length' => export_size.to_s }
+ {"Content-Length" => export_size.to_s}
end
def export_size
diff --git a/lib/gitlab/import_export/after_export_strategy_builder.rb b/lib/gitlab/import_export/after_export_strategy_builder.rb
index 37394f46a99..7f07bd9cba7 100644
--- a/lib/gitlab/import_export/after_export_strategy_builder.rb
+++ b/lib/gitlab/import_export/after_export_strategy_builder.rb
@@ -9,7 +9,11 @@ module Gitlab
return default_strategy.new unless strategy_klass
attributes ||= {}
- klass = strategy_klass.constantize rescue nil
+ klass = begin
+ strategy_klass.constantize
+ rescue
+ nil
+ end
unless klass && klass < AfterExportStrategies::BaseAfterExportStrategy
raise StrategyNotFoundError.new("Strategy #{strategy_klass} not found")
diff --git a/lib/gitlab/import_export/attribute_cleaner.rb b/lib/gitlab/import_export/attribute_cleaner.rb
index 93b37b7bc5f..a29537fe4a9 100644
--- a/lib/gitlab/import_export/attribute_cleaner.rb
+++ b/lib/gitlab/import_export/attribute_cleaner.rb
@@ -3,7 +3,7 @@
module Gitlab
module ImportExport
class AttributeCleaner
- ALLOWED_REFERENCES = RelationFactory::PROJECT_REFERENCES + RelationFactory::USER_REFERENCES + ['group_id']
+ ALLOWED_REFERENCES = RelationFactory::PROJECT_REFERENCES + RelationFactory::USER_REFERENCES + ["group_id"]
def self.clean(*args)
new(*args).clean
@@ -16,15 +16,15 @@ module Gitlab
end
def clean
- @relation_hash.reject do |key, _value|
+ @relation_hash.reject { |key, _value|
prohibited_key?(key) || !@relation_class.attribute_method?(key) || excluded_key?(key)
- end.except('id')
+ }.except("id")
end
private
def prohibited_key?(key)
- key.end_with?('_id') && !ALLOWED_REFERENCES.include?(key)
+ key.end_with?("_id") && !ALLOWED_REFERENCES.include?(key)
end
def excluded_key?(key)
diff --git a/lib/gitlab/import_export/attributes_finder.rb b/lib/gitlab/import_export/attributes_finder.rb
index 409243e68a5..ff2d8e1a9d8 100644
--- a/lib/gitlab/import_export/attributes_finder.rb
+++ b/lib/gitlab/import_export/attributes_finder.rb
@@ -11,7 +11,7 @@ module Gitlab
def find(model_object)
parsed_hash = find_attributes_only(model_object)
- parsed_hash.empty? ? model_object : { model_object => parsed_hash }
+ parsed_hash.empty? ? model_object : {model_object => parsed_hash}
end
def parse(model_object)
@@ -21,17 +21,17 @@ module Gitlab
def find_included(value)
key = key_from_hash(value)
- @included_attributes[key].nil? ? {} : { only: @included_attributes[key] }
+ @included_attributes[key].nil? ? {} : {only: @included_attributes[key]}
end
def find_excluded(value)
key = key_from_hash(value)
- @excluded_attributes[key].nil? ? {} : { except: @excluded_attributes[key] }
+ @excluded_attributes[key].nil? ? {} : {except: @excluded_attributes[key]}
end
def find_method(value)
key = key_from_hash(value)
- @methods[key].nil? ? {} : { methods: @methods[key] }
+ @methods[key].nil? ? {} : {methods: @methods[key]}
end
def find_excluded_keys(klass_name)
diff --git a/lib/gitlab/import_export/avatar_restorer.rb b/lib/gitlab/import_export/avatar_restorer.rb
index be1b97bd7a7..93c68f43292 100644
--- a/lib/gitlab/import_export/avatar_restorer.rb
+++ b/lib/gitlab/import_export/avatar_restorer.rb
@@ -25,7 +25,7 @@ module Gitlab
end
def avatar_export_path
- File.join(@shared.export_path, 'avatar')
+ File.join(@shared.export_path, "avatar")
end
end
end
diff --git a/lib/gitlab/import_export/avatar_saver.rb b/lib/gitlab/import_export/avatar_saver.rb
index 47ca898c690..43f4f874738 100644
--- a/lib/gitlab/import_export/avatar_saver.rb
+++ b/lib/gitlab/import_export/avatar_saver.rb
@@ -14,7 +14,7 @@ module Gitlab
Gitlab::ImportExport::UploadsManager.new(
project: @project,
shared: @shared,
- relative_export_path: 'avatar'
+ relative_export_path: "avatar"
).save
rescue => e
@shared.error(e)
diff --git a/lib/gitlab/import_export/command_line_util.rb b/lib/gitlab/import_export/command_line_util.rb
index bdecff0931c..e54bdc525df 100644
--- a/lib/gitlab/import_export/command_line_util.rb
+++ b/lib/gitlab/import_export/command_line_util.rb
@@ -3,15 +3,15 @@
module Gitlab
module ImportExport
module CommandLineUtil
- UNTAR_MASK = 'u+rwX,go+rX,go-w'
- DEFAULT_DIR_MODE = 0700
+ UNTAR_MASK = "u+rwX,go+rX,go-w"
+ DEFAULT_DIR_MODE = 0o700
def tar_czf(archive:, dir:)
- tar_with_options(archive: archive, dir: dir, options: 'czf')
+ tar_with_options(archive: archive, dir: dir, options: "czf")
end
def untar_zxf(archive:, dir:)
- untar_with_options(archive: archive, dir: dir, options: 'zxf')
+ untar_with_options(archive: archive, dir: dir, options: "zxf")
end
def mkdir_p(path)
@@ -30,19 +30,19 @@ module Gitlab
end
def download(url, upload_path)
- File.open(upload_path, 'w') do |file|
+ File.open(upload_path, "w") do |file|
# Download (stream) file from the uploader's location
IO.copy_stream(URI.parse(url).open, file)
end
end
def tar_with_options(archive:, dir:, options:)
- execute(%W(tar -#{options} #{archive} -C #{dir} .))
+ execute(%W[tar -#{options} #{archive} -C #{dir} .])
end
def untar_with_options(archive:, dir:, options:)
- execute(%W(tar -#{options} #{archive} -C #{dir}))
- execute(%W(chmod -R #{UNTAR_MASK} #{dir}))
+ execute(%W[tar -#{options} #{archive} -C #{dir}])
+ execute(%W[chmod -R #{UNTAR_MASK} #{dir}])
end
def execute(cmd)
diff --git a/lib/gitlab/import_export/file_importer.rb b/lib/gitlab/import_export/file_importer.rb
index 05432f433e7..0406238a312 100644
--- a/lib/gitlab/import_export/file_importer.rb
+++ b/lib/gitlab/import_export/file_importer.rb
@@ -6,7 +6,7 @@ module Gitlab
include Gitlab::ImportExport::CommandLineUtil
MAX_RETRIES = 8
- IGNORED_FILENAMES = %w(. ..).freeze
+ IGNORED_FILENAMES = %w[. ..].freeze
def self.import(*args)
new(*args).import
diff --git a/lib/gitlab/import_export/group_project_object_builder.rb b/lib/gitlab/import_export/group_project_object_builder.rb
index 1c62591ed5a..62e6937a4d7 100644
--- a/lib/gitlab/import_export/group_project_object_builder.rb
+++ b/lib/gitlab/import_export/group_project_object_builder.rb
@@ -21,8 +21,8 @@ module Gitlab
def initialize(klass, attributes)
@klass = klass < Label ? Label : klass
@attributes = attributes
- @group = @attributes['group']
- @project = @attributes['project']
+ @group = @attributes["group"]
+ @project = @attributes["project"]
end
def find
@@ -36,12 +36,12 @@ module Gitlab
end
def where_clause
- @attributes.slice('title').map do |key, value|
+ @attributes.slice("title").map { |key, value|
scope_clause = table[:project_id].eq(@project.id)
scope_clause = scope_clause.or(table[:group_id].eq(@group.id)) if @group
table[key].eq(value).and(scope_clause)
- end.reduce(:or)
+ }.reduce(:or)
end
def table
@@ -49,13 +49,13 @@ module Gitlab
end
def project_attributes
- @attributes.except('group').tap do |atts|
+ @attributes.except("group").tap do |atts|
if label?
- atts['type'] = 'ProjectLabel' # Always create project labels
+ atts["type"] = "ProjectLabel" # Always create project labels
elsif milestone?
- if atts['group_id'] # Transform new group milestones into project ones
- atts['iid'] = nil
- atts.delete('group_id')
+ if atts["group_id"] # Transform new group milestones into project ones
+ atts["iid"] = nil
+ atts.delete("group_id")
else
claim_iid
end
@@ -79,7 +79,7 @@ module Gitlab
def claim_iid
# The milestone has to be a group milestone, as it's the only case where
# we set the IID as the maximum. The rest of them are fixed.
- milestone = @project.milestones.find_by(iid: @attributes['iid'])
+ milestone = @project.milestones.find_by(iid: @attributes["iid"])
return unless milestone
diff --git a/lib/gitlab/import_export/hash_util.rb b/lib/gitlab/import_export/hash_util.rb
index b6ce89a973b..75e18ab2dc4 100644
--- a/lib/gitlab/import_export/hash_util.rb
+++ b/lib/gitlab/import_export/hash_util.rb
@@ -16,8 +16,8 @@ module Gitlab
end
def self.deep_symbolize_array_with_date!(array)
- self.deep_symbolize_array!(array) do |hash|
- hash.select { |k, _v| k.to_s.end_with?('_date') }.each do |key, value|
+ deep_symbolize_array!(array) do |hash|
+ hash.select { |k, _v| k.to_s.end_with?("_date") }.each do |key, value|
hash[key] = Time.zone.parse(value)
end
end
diff --git a/lib/gitlab/import_export/importer.rb b/lib/gitlab/import_export/importer.rb
index 767f1b5de0e..1adf643b4d9 100644
--- a/lib/gitlab/import_export/importer.rb
+++ b/lib/gitlab/import_export/importer.rb
@@ -21,7 +21,7 @@ module Gitlab
if import_file && check_version! && restorers.all?(&:restore) && overwrite_project
project_tree.restored_project
else
- raise Projects::ImportService::Error.new(@shared.errors.join(', '))
+ raise Projects::ImportService::Error.new(@shared.errors.join(", "))
end
rescue => e
raise Projects::ImportService::Error.new(e.message)
@@ -33,7 +33,7 @@ module Gitlab
def restorers
[repo_restorer, wiki_restorer, project_tree, avatar_restorer,
- uploads_restorer, lfs_restorer, statistics_restorer]
+ uploads_restorer, lfs_restorer, statistics_restorer,]
end
def import_file
@@ -86,11 +86,11 @@ module Gitlab
end
def repo_path
- File.join(@shared.export_path, 'project.bundle')
+ File.join(@shared.export_path, "project.bundle")
end
def wiki_repo_path
- File.join(@shared.export_path, 'project.wiki.bundle')
+ File.join(@shared.export_path, "project.wiki.bundle")
end
def remove_import_file
@@ -109,14 +109,14 @@ module Gitlab
if overwrite_project?
::Projects::OverwriteProjectService.new(project, @current_user)
- .execute(project_to_overwrite)
+ .execute(project_to_overwrite)
end
true
end
def original_path
- @project.import_data&.data&.fetch('original_path', nil)
+ @project.import_data&.data&.fetch("original_path", nil)
end
def overwrite_project?
diff --git a/lib/gitlab/import_export/json_hash_builder.rb b/lib/gitlab/import_export/json_hash_builder.rb
index 477499e1688..a4ecc83142d 100644
--- a/lib/gitlab/import_export/json_hash_builder.rb
+++ b/lib/gitlab/import_export/json_hash_builder.rb
@@ -59,7 +59,7 @@ module Gitlab
# +value+ existing model to be included in the hash
# +json_config_hash+ the original hash containing the root model
def create_model_value(current_key, value, json_config_hash)
- json_config_hash[current_key] = parse_hash(value) || { include: value }
+ json_config_hash[current_key] = parse_hash(value) || {include: value}
end
# Calls attributes finder to parse the hash and add any attributes to it
@@ -70,7 +70,7 @@ module Gitlab
return nil if already_contains_methods?(value)
@attributes_finder.parse(value) do |hash|
- { include: hash_or_merge(value, hash) }
+ {include: hash_or_merge(value, hash)}
end
end
@@ -86,7 +86,7 @@ module Gitlab
# +json_config_hash+ the original hash containing the root model
def add_model_value(current_key, value, json_config_hash)
@attributes_finder.parse(value) do |hash|
- value = { value => hash } unless value.is_a?(Hash)
+ value = {value => hash} unless value.is_a?(Hash)
end
add_to_array(current_key, json_config_hash, value)
@@ -110,7 +110,7 @@ module Gitlab
# +hash+ hash containing configuration generated mainly from +@attributes_finder+
# +value+ existing model to be included in the hash
def hash_or_merge(value, hash)
- value.is_a?(Hash) ? value.merge(hash) : { value => hash }
+ value.is_a?(Hash) ? value.merge(hash) : {value => hash}
end
end
end
diff --git a/lib/gitlab/import_export/lfs_restorer.rb b/lib/gitlab/import_export/lfs_restorer.rb
index 345c7880e30..165a1c05d78 100644
--- a/lib/gitlab/import_export/lfs_restorer.rb
+++ b/lib/gitlab/import_export/lfs_restorer.rb
@@ -38,7 +38,7 @@ module Gitlab
end
def lfs_storage_path
- File.join(@shared.export_path, 'lfs-objects')
+ File.join(@shared.export_path, "lfs-objects")
end
end
end
diff --git a/lib/gitlab/import_export/lfs_saver.rb b/lib/gitlab/import_export/lfs_saver.rb
index 954f6f00078..10540b42220 100644
--- a/lib/gitlab/import_export/lfs_saver.rb
+++ b/lib/gitlab/import_export/lfs_saver.rb
@@ -36,7 +36,7 @@ module Gitlab
destination = destination_path_for_object(lfs_object)
mkdir_p(File.dirname(destination))
- File.open(destination, 'w') do |file|
+ File.open(destination, "w") do |file|
IO.copy_stream(URI.parse(lfs_object.file.url).open, file)
end
end
@@ -50,7 +50,7 @@ module Gitlab
end
def lfs_export_path
- File.join(@shared.export_path, 'lfs-objects')
+ File.join(@shared.export_path, "lfs-objects")
end
end
end
diff --git a/lib/gitlab/import_export/members_mapper.rb b/lib/gitlab/import_export/members_mapper.rb
index 6be95a16513..0846ba647c3 100644
--- a/lib/gitlab/import_export/members_mapper.rb
+++ b/lib/gitlab/import_export/members_mapper.rb
@@ -16,16 +16,14 @@ module Gitlab
def map
@map ||=
begin
- @exported_members.inject(missing_keys_tracking_hash) do |hash, member|
- if member['user']
- old_user_id = member['user']['id']
+ @exported_members.each_with_object(missing_keys_tracking_hash) do |member, hash|
+ 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
end
@@ -35,7 +33,7 @@ module Gitlab
end
def include?(old_author_id)
- map.keys.include?(old_author_id) && map[old_author_id] != default_user_id
+ map.key?(old_author_id) && map[old_author_id] != default_user_id
end
private
@@ -53,13 +51,13 @@ module Gitlab
end
def add_team_member(member, existing_user = nil)
- member['user'] = existing_user
+ member["user"] = existing_user
ProjectMember.create(member_hash(member)).persisted?
end
def member_hash(member)
- parsed_hash(member).merge('source_id' => @project.id, 'importing' => true)
+ parsed_hash(member).merge("source_id" => @project.id, "importing" => true)
end
def parsed_hash(member)
@@ -68,7 +66,7 @@ module Gitlab
end
def find_project_user_query(member)
- user_arel[:email].eq(member['user']['email']).or(user_arel[:username].eq(member['user']['username']))
+ user_arel[:email].eq(member["user"]["email"]).or(user_arel[:username].eq(member["user"]["username"]))
end
def user_arel
diff --git a/lib/gitlab/import_export/merge_request_parser.rb b/lib/gitlab/import_export/merge_request_parser.rb
index 040a70d6775..8948b1b5a25 100644
--- a/lib/gitlab/import_export/merge_request_parser.rb
+++ b/lib/gitlab/import_export/merge_request_parser.rb
@@ -14,7 +14,7 @@ module Gitlab
def parse!
if fork_merge_request? && @diff_head_sha
- @merge_request.source_project_id = @relation_hash['project_id']
+ @merge_request.source_project_id = @relation_hash["project_id"]
fetch_ref unless branch_exists?(@merge_request.source_branch)
create_target_branch unless branch_exists?(@merge_request.target_branch)
@@ -41,7 +41,7 @@ module Gitlab
end
def fork_merge_request?
- @relation_hash['source_project_id'] == FORKED_PROJECT_ID
+ @relation_hash["source_project_id"] == FORKED_PROJECT_ID
end
end
end
diff --git a/lib/gitlab/import_export/project_tree_restorer.rb b/lib/gitlab/import_export/project_tree_restorer.rb
index 51001750a6c..6504d4d813d 100644
--- a/lib/gitlab/import_export/project_tree_restorer.rb
+++ b/lib/gitlab/import_export/project_tree_restorer.rb
@@ -7,7 +7,7 @@ module Gitlab
GROUP_MODELS = [GroupLabel, Milestone].freeze
def initialize(user:, shared:, project:)
- @path = File.join(shared.export_path, 'project.json')
+ @path = File.join(shared.export_path, "project.json")
@user = user
@shared = shared
@project = project
@@ -21,10 +21,10 @@ module Gitlab
@tree_hash = ActiveSupport::JSON.decode(json)
rescue => e
Rails.logger.error("Import/Export error: #{e.message}")
- raise Gitlab::ImportExport::Error.new('Incorrect JSON format')
+ raise Gitlab::ImportExport::Error.new("Incorrect JSON format")
end
- @project_members = @tree_hash.delete('project_members')
+ @project_members = @tree_hash.delete("project_members")
RelationRenameService.rename(@tree_hash)
@@ -117,21 +117,21 @@ module Gitlab
end
def override_params
- @override_params ||= @project.import_data&.data&.fetch('override_params', nil) || {}
+ @override_params ||= @project.import_data&.data&.fetch("override_params", nil) || {}
end
def json_params
- @json_params ||= @tree_hash.reject do |key, value|
+ @json_params ||= @tree_hash.reject { |key, value|
# return params that are not 1 to many or 1 to 1 relations
value.respond_to?(:each) && !Project.column_names.include?(key)
- end
+ }
end
def visibility_level
- level = override_params['visibility_level'] || json_params['visibility_level'] || @project.visibility_level
+ level = override_params["visibility_level"] || json_params["visibility_level"] || @project.visibility_level
level = @project.group.visibility_level if @project.group && level > @project.group.visibility_level
- { 'visibility_level' => level }
+ {"visibility_level" => level}
end
# Given a relation hash containing one or more models and its relationships,
@@ -202,14 +202,14 @@ module Gitlab
end
def create_relation(relation, relation_hash_list)
- relation_array = [relation_hash_list].flatten.map do |relation_hash|
+ relation_array = [relation_hash_list].flatten.map { |relation_hash|
Gitlab::ImportExport::RelationFactory.create(relation_sym: relation.to_sym,
relation_hash: relation_hash,
members_mapper: members_mapper,
user: @user,
project: @restored_project,
excluded_keys: excluded_keys_for_relation(relation))
- end.compact
+ }.compact
relation_hash_list.is_a?(Array) ? relation_array : relation_array.first
end
@@ -223,7 +223,7 @@ module Gitlab
end
def nil_iid_pipeline?(relation_key, relation_item)
- relation_key == 'ci_pipelines' && relation_item['iid'].nil?
+ relation_key == "ci_pipelines" && relation_item["iid"].nil?
end
end
end
diff --git a/lib/gitlab/import_export/project_tree_saver.rb b/lib/gitlab/import_export/project_tree_saver.rb
index 2255635acdf..4b331753582 100644
--- a/lib/gitlab/import_export/project_tree_saver.rb
+++ b/lib/gitlab/import_export/project_tree_saver.rb
@@ -29,10 +29,10 @@ module Gitlab
def project_json_tree
if @params[:description].present?
- project_json['description'] = @params[:description]
+ project_json["description"] = @params[:description]
end
- project_json['project_members'] += group_members_json
+ project_json["project_members"] += group_members_json
RelationRenameService.add_new_associations(project_json)
@@ -49,7 +49,7 @@ module Gitlab
def group_members_json
group_members.as_json(reader.group_members_tree).each do |group_member|
- group_member['source_type'] = 'Project' # Make group members project members of the future import
+ group_member["source_type"] = "Project" # Make group members project members of the future import
end
end
diff --git a/lib/gitlab/import_export/relation_factory.rb b/lib/gitlab/import_export/relation_factory.rb
index 099b488f68e..89a20114ae4 100644
--- a/lib/gitlab/import_export/relation_factory.rb
+++ b/lib/gitlab/import_export/relation_factory.rb
@@ -3,29 +3,29 @@
module Gitlab
module ImportExport
class RelationFactory
- OVERRIDES = { snippets: :project_snippets,
- ci_pipelines: 'Ci::Pipeline',
- pipelines: 'Ci::Pipeline',
- stages: 'Ci::Stage',
- statuses: 'commit_status',
- triggers: 'Ci::Trigger',
- pipeline_schedules: 'Ci::PipelineSchedule',
- builds: 'Ci::Build',
- runners: 'Ci::Runner',
- hooks: 'ProjectHook',
- merge_access_levels: 'ProtectedBranch::MergeAccessLevel',
- push_access_levels: 'ProtectedBranch::PushAccessLevel',
- create_access_levels: 'ProtectedTag::CreateAccessLevel',
- labels: :project_labels,
- priorities: :label_priorities,
- auto_devops: :project_auto_devops,
- label: :project_label,
- custom_attributes: 'ProjectCustomAttribute',
- project_badges: 'Badge',
- metrics: 'MergeRequest::Metrics',
- ci_cd_settings: 'ProjectCiCdSetting',
- error_tracking_setting: 'ErrorTracking::ProjectErrorTrackingSetting',
- links: 'Releases::Link' }.freeze
+ OVERRIDES = {snippets: :project_snippets,
+ ci_pipelines: "Ci::Pipeline",
+ pipelines: "Ci::Pipeline",
+ stages: "Ci::Stage",
+ statuses: "commit_status",
+ triggers: "Ci::Trigger",
+ pipeline_schedules: "Ci::PipelineSchedule",
+ builds: "Ci::Build",
+ runners: "Ci::Runner",
+ hooks: "ProjectHook",
+ merge_access_levels: "ProtectedBranch::MergeAccessLevel",
+ push_access_levels: "ProtectedBranch::PushAccessLevel",
+ create_access_levels: "ProtectedTag::CreateAccessLevel",
+ labels: :project_labels,
+ priorities: :label_priorities,
+ auto_devops: :project_auto_devops,
+ label: :project_label,
+ custom_attributes: "ProjectCustomAttribute",
+ project_badges: "Badge",
+ metrics: "MergeRequest::Metrics",
+ ci_cd_settings: "ProjectCiCdSetting",
+ error_tracking_setting: "ErrorTracking::ProjectErrorTrackingSetting",
+ links: "Releases::Link",}.freeze
USER_REFERENCES = %w[author_id assignee_id updated_by_id merged_by_id latest_closed_by_id user_id created_by_id last_edited_by_id merge_user_id resolved_by_id closed_by_id].freeze
@@ -33,7 +33,7 @@ module Gitlab
BUILD_MODELS = %w[Ci::Build commit_status].freeze
- IMPORTED_OBJECT_MAX_RETRIES = 5.freeze
+ IMPORTED_OBJECT_MAX_RETRIES = 5
EXISTING_OBJECT_CHECK = %i[milestone milestones label labels project_label project_labels group_label group_labels project_feature].freeze
@@ -54,13 +54,13 @@ module Gitlab
def initialize(relation_sym:, relation_hash:, members_mapper:, user:, project:, excluded_keys: [])
@relation_name = self.class.overrides[relation_sym] || relation_sym
- @relation_hash = relation_hash.except('noteable_id')
+ @relation_hash = relation_hash.except("noteable_id")
@members_mapper = members_mapper
@user = user
@project = project
@imported_object_retries = 0
- @relation_hash['project_id'] = @project.id
+ @relation_hash["project_id"] = @project.id
# Remove excluded keys from relation_hash
# We don't do this in the parsed_relation_hash because of the 'transformed attributes'
@@ -99,7 +99,7 @@ module Gitlab
update_group_references
remove_duplicate_assignees
- setup_pipeline if @relation_name == 'Ci::Pipeline'
+ setup_pipeline if @relation_name == "Ci::Pipeline"
reset_tokens!
remove_encrypted_attributes!
@@ -114,17 +114,17 @@ module Gitlab
end
def remove_duplicate_assignees
- return unless @relation_hash['issue_assignees']
+ return unless @relation_hash["issue_assignees"]
# When an assignee did not exist in the members mapper, the importer is
# assigned. We only need to assign each user once.
- @relation_hash['issue_assignees'].uniq!(&:user_id)
+ @relation_hash["issue_assignees"].uniq!(&:user_id)
end
def setup_note
set_note_author
# attachment is deprecated and note uploads are handled by Markdown uploader
- @relation_hash['attachment'] = nil
+ @relation_hash["attachment"] = nil
end
# Sets the author for a note. If the user importing the project
@@ -132,10 +132,10 @@ module Gitlab
# will be used. Otherwise, a note stating the original author name
# is left.
def set_note_author
- old_author_id = @relation_hash['author_id']
- author = @relation_hash.delete('author')
+ old_author_id = @relation_hash["author_id"]
+ author = @relation_hash.delete("author")
- update_note_for_missing_author(author['name']) unless has_author?(old_author_id)
+ update_note_for_missing_author(author["name"]) unless has_author?(old_author_id)
end
def has_author?(old_author_id)
@@ -143,19 +143,19 @@ module Gitlab
end
def missing_author_note(updated_at, author_name)
- timestamp = updated_at.split('.').first
+ timestamp = updated_at.split(".").first
"\n\n *By #{author_name} on #{timestamp} (imported from GitLab project)*"
end
def generate_imported_object
if BUILD_MODELS.include?(@relation_name)
- @relation_hash.delete('trace') # old export files have trace
- @relation_hash.delete('token')
- @relation_hash.delete('commands')
+ @relation_hash.delete("trace") # old export files have trace
+ @relation_hash.delete("token")
+ @relation_hash.delete("commands")
imported_object
elsif @relation_name == :merge_requests
- MergeRequestParser.new(@project, @relation_hash.delete('diff_head_sha'), imported_object, @relation_hash).parse!
+ MergeRequestParser.new(@project, @relation_hash.delete("diff_head_sha"), imported_object, @relation_hash).parse!
else
imported_object
end
@@ -163,22 +163,22 @@ module Gitlab
def update_project_references
# If source and target are the same, populate them with the new project ID.
- if @relation_hash['source_project_id']
- @relation_hash['source_project_id'] = same_source_and_target? ? @relation_hash['project_id'] : MergeRequestParser::FORKED_PROJECT_ID
+ if @relation_hash["source_project_id"]
+ @relation_hash["source_project_id"] = same_source_and_target? ? @relation_hash["project_id"] : MergeRequestParser::FORKED_PROJECT_ID
end
- @relation_hash['target_project_id'] = @relation_hash['project_id'] if @relation_hash['target_project_id']
+ @relation_hash["target_project_id"] = @relation_hash["project_id"] if @relation_hash["target_project_id"]
end
def same_source_and_target?
- @relation_hash['target_project_id'] && @relation_hash['target_project_id'] == @relation_hash['source_project_id']
+ @relation_hash["target_project_id"] && @relation_hash["target_project_id"] == @relation_hash["source_project_id"]
end
def update_group_references
return unless EXISTING_OBJECT_CHECK.include?(@relation_name)
- return unless @relation_hash['group_id']
+ return unless @relation_hash["group_id"]
- @relation_hash['group_id'] = @project.group&.id
+ @relation_hash["group_id"] = @project.group&.id
end
def reset_tokens!
@@ -186,7 +186,7 @@ module Gitlab
# If we import/export a project to the same instance, tokens will have to be reset.
# We also have to reset them to avoid issues when the gitlab secrets file cannot be copied across.
- relation_class.attribute_names.select { |name| name.include?('token') }.each do |token|
+ relation_class.attribute_names.select { |name| name.include?("token") }.each do |token|
@relation_hash[token] = nil
end
end
@@ -217,8 +217,8 @@ module Gitlab
end
def update_note_for_missing_author(author_name)
- @relation_hash['note'] = '*Blank note*' if @relation_hash['note'].blank?
- @relation_hash['note'] = "#{@relation_hash['note']}#{missing_author_note(@relation_hash['updated_at'], author_name)}"
+ @relation_hash["note"] = "*Blank note*" if @relation_hash["note"].blank?
+ @relation_hash["note"] = "#{@relation_hash["note"]}#{missing_author_note(@relation_hash["updated_at"], author_name)}"
end
def admin_user?
@@ -231,11 +231,11 @@ module Gitlab
end
def setup_diff
- @relation_hash['diff'] = @relation_hash.delete('utf8_diff')
+ @relation_hash["diff"] = @relation_hash.delete("utf8_diff")
end
def setup_pipeline
- @relation_hash.fetch('stages').each do |stage|
+ @relation_hash.fetch("stages").each do |stage|
stage.statuses.each do |status|
status.pipeline = imported_object
end
@@ -247,7 +247,7 @@ module Gitlab
# Otherwise always create the record, skipping the extra SELECT clause.
@existing_or_new_object ||= begin
if EXISTING_OBJECT_CHECK.include?(@relation_name)
- attribute_hash = attribute_hash_for(['events'])
+ attribute_hash = attribute_hash_for(["events"])
existing_object.assign_attributes(attribute_hash) if attribute_hash.any?
@@ -259,9 +259,8 @@ module Gitlab
end
def attribute_hash_for(attributes)
- attributes.inject({}) do |hash, value|
+ attributes.each_with_object({}) do |value, hash|
hash[value] = parsed_relation_hash.delete(value) if parsed_relation_hash[value]
- hash
end
end
@@ -270,8 +269,8 @@ module Gitlab
end
def unknown_service?
- @relation_name == :services && parsed_relation_hash['type'] &&
- !Object.const_defined?(parsed_relation_hash['type'])
+ @relation_name == :services && parsed_relation_hash["type"] &&
+ !Object.const_defined?(parsed_relation_hash["type"])
end
def find_or_create_object!
@@ -279,9 +278,9 @@ module Gitlab
# Can't use IDs as validation exists calling `group` or `project` attributes
finder_hash = parsed_relation_hash.tap do |hash|
- hash['group'] = @project.group if relation_class.attribute_method?('group_id')
- hash['project'] = @project
- hash.delete('project_id')
+ hash["group"] = @project.group if relation_class.attribute_method?("group_id")
+ hash["project"] = @project
+ hash.delete("project_id")
end
GroupProjectObjectBuilder.build(relation_class, finder_hash)
diff --git a/lib/gitlab/import_export/relation_rename_service.rb b/lib/gitlab/import_export/relation_rename_service.rb
index 179bde5e21e..45949d912c0 100644
--- a/lib/gitlab/import_export/relation_rename_service.rb
+++ b/lib/gitlab/import_export/relation_rename_service.rb
@@ -20,7 +20,7 @@ module Gitlab
module ImportExport
class RelationRenameService
RENAMES = {
- 'pipelines' => 'ci_pipelines' # Added in 11.6, remove in 11.7
+ "pipelines" => "ci_pipelines", # Added in 11.6, remove in 11.7
}.freeze
def self.rename(tree_hash)
diff --git a/lib/gitlab/import_export/shared.rb b/lib/gitlab/import_export/shared.rb
index 725c1101d70..c04e192f686 100644
--- a/lib/gitlab/import_export/shared.rb
+++ b/lib/gitlab/import_export/shared.rb
@@ -12,7 +12,7 @@ module Gitlab
end
def active_export_count
- Dir[File.join(archive_path, '*')].count { |name| File.directory?(name) }
+ Dir[File.join(archive_path, "*")].count { |name| File.directory?(name) }
end
def export_path
@@ -60,10 +60,10 @@ module Gitlab
def log_base_data
{
- importer: 'Import/Export',
+ importer: "Import/Export",
import_jid: @project&.import_state&.jid,
project_id: @project&.id,
- project_path: @project&.full_path
+ project_path: @project&.full_path,
}
end
diff --git a/lib/gitlab/import_export/uploads_manager.rb b/lib/gitlab/import_export/uploads_manager.rb
index e232198150a..2bc4e3801bc 100644
--- a/lib/gitlab/import_export/uploads_manager.rb
+++ b/lib/gitlab/import_export/uploads_manager.rb
@@ -7,7 +7,7 @@ module Gitlab
UPLOADS_BATCH_SIZE = 100
- def initialize(project:, shared:, relative_export_path: 'uploads')
+ def initialize(project:, shared:, relative_export_path: "uploads")
@project = project
@shared = shared
@relative_export_path = relative_export_path
@@ -40,7 +40,7 @@ module Gitlab
def add_upload(upload)
uploader_context = FileUploader.extract_dynamic_path(upload).named_captures.symbolize_keys
- UploadService.new(@project, File.open(upload, 'r'), FileUploader, uploader_context).execute.to_h
+ UploadService.new(@project, File.open(upload, "r"), FileUploader, uploader_context).execute.to_h
end
def copy_project_uploads
@@ -64,7 +64,7 @@ module Gitlab
def each_uploader
avatar_path = @project.avatar&.upload&.path
- if @relative_export_path == 'avatar'
+ if @relative_export_path == "avatar"
yield(@project.avatar)
else
project_uploads_except_avatar(avatar_path).find_each(batch_size: UPLOADS_BATCH_SIZE) do |upload|
@@ -80,7 +80,7 @@ module Gitlab
end
def download_and_copy(upload)
- secret = upload.try(:secret) || ''
+ secret = upload.try(:secret) || ""
upload_path = File.join(uploads_export_path, secret, upload.filename)
mkdir_p(File.join(uploads_export_path, secret))
diff --git a/lib/gitlab/import_export/version_checker.rb b/lib/gitlab/import_export/version_checker.rb
index 6d978d00ea5..2409eedf8ed 100644
--- a/lib/gitlab/import_export/version_checker.rb
+++ b/lib/gitlab/import_export/version_checker.rb
@@ -37,7 +37,7 @@ module Gitlab
Gem::Version.new(version) != Gem::Version.new(Gitlab::ImportExport.version)
rescue => e
Rails.logger.error("Import/Export error: #{e.message}")
- raise Gitlab::ImportExport::Error.new('Incorrect VERSION format')
+ raise Gitlab::ImportExport::Error.new("Incorrect VERSION format")
end
end
end
diff --git a/lib/gitlab/import_export/version_saver.rb b/lib/gitlab/import_export/version_saver.rb
index 8230c0f1e77..b09807f3a5b 100644
--- a/lib/gitlab/import_export/version_saver.rb
+++ b/lib/gitlab/import_export/version_saver.rb
@@ -12,7 +12,7 @@ module Gitlab
def save
mkdir_p(@shared.export_path)
- File.write(version_file, Gitlab::ImportExport.version, mode: 'w')
+ File.write(version_file, Gitlab::ImportExport.version, mode: "w")
rescue => e
@shared.error(e)
false
diff --git a/lib/gitlab/import_sources.rb b/lib/gitlab/import_sources.rb
index 67952ca0f2d..bef3aac47c7 100644
--- a/lib/gitlab/import_sources.rb
+++ b/lib/gitlab/import_sources.rb
@@ -11,16 +11,16 @@ module Gitlab
# We exclude `bare_repository` here as it has no import class associated
IMPORT_TABLE = [
- ImportSource.new('github', 'GitHub', Gitlab::GithubImport::ParallelImporter),
- ImportSource.new('bitbucket', 'Bitbucket Cloud', Gitlab::BitbucketImport::Importer),
- ImportSource.new('bitbucket_server', 'Bitbucket Server', Gitlab::BitbucketServerImport::Importer),
- ImportSource.new('gitlab', 'GitLab.com', Gitlab::GitlabImport::Importer),
- ImportSource.new('google_code', 'Google Code', Gitlab::GoogleCodeImport::Importer),
- ImportSource.new('fogbugz', 'FogBugz', Gitlab::FogbugzImport::Importer),
- ImportSource.new('git', 'Repo by URL', nil),
- ImportSource.new('gitlab_project', 'GitLab export', Gitlab::ImportExport::Importer),
- ImportSource.new('gitea', 'Gitea', Gitlab::LegacyGithubImport::Importer),
- ImportSource.new('manifest', 'Manifest file', nil)
+ ImportSource.new("github", "GitHub", Gitlab::GithubImport::ParallelImporter),
+ ImportSource.new("bitbucket", "Bitbucket Cloud", Gitlab::BitbucketImport::Importer),
+ ImportSource.new("bitbucket_server", "Bitbucket Server", Gitlab::BitbucketServerImport::Importer),
+ ImportSource.new("gitlab", "GitLab.com", Gitlab::GitlabImport::Importer),
+ ImportSource.new("google_code", "Google Code", Gitlab::GoogleCodeImport::Importer),
+ ImportSource.new("fogbugz", "FogBugz", Gitlab::FogbugzImport::Importer),
+ ImportSource.new("git", "Repo by URL", nil),
+ ImportSource.new("gitlab_project", "GitLab export", Gitlab::ImportExport::Importer),
+ ImportSource.new("gitea", "Gitea", Gitlab::LegacyGithubImport::Importer),
+ ImportSource.new("manifest", "Manifest file", nil),
].freeze
class << self
diff --git a/lib/gitlab/incoming_email.rb b/lib/gitlab/incoming_email.rb
index cc0c633b943..f94820ba9ba 100644
--- a/lib/gitlab/incoming_email.rb
+++ b/lib/gitlab/incoming_email.rb
@@ -2,9 +2,9 @@
module Gitlab
module IncomingEmail
- UNSUBSCRIBE_SUFFIX = '-unsubscribe'.freeze
- UNSUBSCRIBE_SUFFIX_LEGACY = '+unsubscribe'.freeze
- WILDCARD_PLACEHOLDER = '%{key}'.freeze
+ UNSUBSCRIBE_SUFFIX = "-unsubscribe"
+ UNSUBSCRIBE_SUFFIX_LEGACY = "+unsubscribe"
+ WILDCARD_PLACEHOLDER = "%{key}"
class << self
def enabled?
@@ -12,7 +12,7 @@ module Gitlab
end
def supports_wildcard?
- config.address && config.address.include?(WILDCARD_PLACEHOLDER)
+ config.address&.include?(WILDCARD_PLACEHOLDER)
end
def supports_issue_creation?
@@ -60,7 +60,7 @@ module Gitlab
return nil unless wildcard_address
regex = Regexp.escape(wildcard_address)
- regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), '(.+)')
+ regex = regex.sub(Regexp.escape(WILDCARD_PLACEHOLDER), "(.+)")
Regexp.new(/\A#{regex}\z/).freeze
end
end
diff --git a/lib/gitlab/insecure_key_fingerprint.rb b/lib/gitlab/insecure_key_fingerprint.rb
index e4f0e9d2c73..3a73347ceaf 100644
--- a/lib/gitlab/insecure_key_fingerprint.rb
+++ b/lib/gitlab/insecure_key_fingerprint.rb
@@ -19,7 +19,7 @@ module Gitlab
end
def fingerprint
- OpenSSL::Digest::MD5.hexdigest(Base64.decode64(@key)).scan(/../).join(':')
+ OpenSSL::Digest::MD5.hexdigest(Base64.decode64(@key)).scan(/../).join(":")
end
end
end
diff --git a/lib/gitlab/issuable_metadata.rb b/lib/gitlab/issuable_metadata.rb
index 351d15605e0..eecbab37467 100644
--- a/lib/gitlab/issuable_metadata.rb
+++ b/lib/gitlab/issuable_metadata.rb
@@ -8,7 +8,7 @@ module Gitlab
issuable_collection.respond_to?(:limit_value) &&
issuable_collection.limit_value.nil?
- raise 'Collection must have a limit applied for preloading meta-data'
+ raise "Collection must have a limit applied for preloading meta-data"
end
# map has to be used here since using pluck or select will
@@ -22,7 +22,7 @@ module Gitlab
issuable_note_count = ::Note.count_for_collection(issuable_ids, collection_type)
issuable_votes_count = ::AwardEmoji.votes_for_collection(issuable_ids, collection_type)
issuable_merge_requests_count =
- if collection_type == 'Issue'
+ if collection_type == "Issue"
::MergeRequestsClosingIssues.count_for_collection(issuable_ids)
else
[]
diff --git a/lib/gitlab/issuable_sorter.rb b/lib/gitlab/issuable_sorter.rb
index 42bbfb32d0b..a4583f5fe11 100644
--- a/lib/gitlab/issuable_sorter.rb
+++ b/lib/gitlab/issuable_sorter.rb
@@ -4,7 +4,7 @@ module Gitlab
module IssuableSorter
class << self
def sort(project, issuables, &sort_key)
- grouped_items = issuables.group_by do |issuable|
+ grouped_items = issuables.group_by { |issuable|
if issuable.project.id == project.id
:project_ref
elsif issuable.project.namespace.id == project.namespace.id
@@ -12,7 +12,7 @@ module Gitlab
else
:full_ref
end
- end
+ }
natural_sort_issuables(grouped_items[:project_ref], project) +
natural_sort_issuables(grouped_items[:namespace_ref], project) +
diff --git a/lib/gitlab/issues_labels.rb b/lib/gitlab/issues_labels.rb
index 17c9cb969df..a363d6283ad 100644
--- a/lib/gitlab/issues_labels.rb
+++ b/lib/gitlab/issues_labels.rb
@@ -4,20 +4,20 @@ module Gitlab
class IssuesLabels
class << self
def generate(project)
- red = '#d9534f'
- yellow = '#f0ad4e'
- blue = '#428bca'
- green = '#5cb85c'
+ red = "#d9534f"
+ yellow = "#f0ad4e"
+ blue = "#428bca"
+ green = "#5cb85c"
labels = [
- { title: "bug", color: red },
- { title: "critical", color: red },
- { title: "confirmed", color: red },
- { title: "documentation", color: yellow },
- { title: "support", color: yellow },
- { title: "discussion", color: blue },
- { title: "suggestion", color: blue },
- { title: "enhancement", color: green }
+ {title: "bug", color: red},
+ {title: "critical", color: red},
+ {title: "confirmed", color: red},
+ {title: "documentation", color: yellow},
+ {title: "support", color: yellow},
+ {title: "discussion", color: blue},
+ {title: "suggestion", color: blue},
+ {title: "enhancement", color: green},
]
labels.each do |params|
diff --git a/lib/gitlab/job_waiter.rb b/lib/gitlab/job_waiter.rb
index e97e961771c..90dbe4d005d 100644
--- a/lib/gitlab/job_waiter.rb
+++ b/lib/gitlab/job_waiter.rb
@@ -17,7 +17,7 @@ module Gitlab
# push to that array when done. Once the waiter has popped `count` items, it
# knows all the jobs are done.
class JobWaiter
- KEY_PREFIX = "gitlab:job_waiter".freeze
+ KEY_PREFIX = "gitlab:job_waiter"
def self.notify(key, jid)
Gitlab::Redis::SharedState.with { |redis| redis.lpush(key, jid) }
diff --git a/lib/gitlab/json_cache.rb b/lib/gitlab/json_cache.rb
index 1adf83739ad..fc7c527e3d0 100644
--- a/lib/gitlab/json_cache.rb
+++ b/lib/gitlab/json_cache.rb
@@ -25,7 +25,7 @@ module Gitlab
expanded_cache_key << Rails.version
end
- expanded_cache_key.join(':')
+ expanded_cache_key.join(":")
end
def expire(key)
diff --git a/lib/gitlab/kubernetes.rb b/lib/gitlab/kubernetes.rb
index a9957a85d48..e8d25dc4fa5 100644
--- a/lib/gitlab/kubernetes.rb
+++ b/lib/gitlab/kubernetes.rb
@@ -10,7 +10,7 @@ module Gitlab
# This is the comand that is run to start a terminal session. Kubernetes
# expects `command=foo&command=bar, not `command[]=foo&command[]=bar`
EXEC_COMMAND = URI.encode_www_form(
- ['sh', '-c', 'bash || sh'].map { |value| ['command', value] }
+ ["sh", "-c", "bash || sh"].map { |value| ["command", value] }
)
# Filters an array of pods (as returned by the kubernetes API) by their labels
@@ -36,22 +36,26 @@ module Gitlab
return unless containers.present? && pod_name.present? && phase == "Running"
- created_at = DateTime.parse(metadata["creationTimestamp"]) rescue nil
+ created_at = begin
+ DateTime.parse(metadata["creationTimestamp"])
+ rescue
+ nil
+ end
containers.map do |container|
{
- selectors: { pod: pod_name, container: container["name"] },
- url: container_exec_url(api_url, namespace, pod_name, container["name"]),
- subprotocols: ['channel.k8s.io'],
- headers: ::Gitlab::Kubernetes.build_header_hash,
- created_at: created_at
+ selectors: {pod: pod_name, container: container["name"]},
+ url: container_exec_url(api_url, namespace, pod_name, container["name"]),
+ subprotocols: ["channel.k8s.io"],
+ headers: ::Gitlab::Kubernetes.build_header_hash,
+ created_at: created_at,
}
end
end
def add_terminal_auth(terminal, token:, max_session_time:, ca_pem: nil)
terminal[:headers] ||= ::Gitlab::Kubernetes.build_header_hash
- terminal[:headers]['Authorization'] << "Bearer #{token}"
+ terminal[:headers]["Authorization"] << "Bearer #{token}"
terminal[:max_session_time] = max_session_time
terminal[:ca_pem] = ca_pem if ca_pem.present?
end
@@ -59,26 +63,26 @@ module Gitlab
def container_exec_url(api_url, namespace, pod_name, container_name)
url = URI.parse(api_url)
url.path = [
- url.path.sub(%r{/+\z}, ''),
- 'api', 'v1',
- 'namespaces', ERB::Util.url_encode(namespace),
- 'pods', ERB::Util.url_encode(pod_name),
- 'exec'
- ].join('/')
+ url.path.sub(%r{/+\z}, ""),
+ "api", "v1",
+ "namespaces", ERB::Util.url_encode(namespace),
+ "pods", ERB::Util.url_encode(pod_name),
+ "exec",
+ ].join("/")
url.query = {
container: container_name,
tty: true,
stdin: true,
stdout: true,
- stderr: true
- }.to_query + '&' + EXEC_COMMAND
+ stderr: true,
+ }.to_query + "&" + EXEC_COMMAND
case url.scheme
- when 'http'
- url.scheme = 'ws'
- when 'https'
- url.scheme = 'wss'
+ when "http"
+ url.scheme = "ws"
+ when "https"
+ url.scheme = "wss"
end
url.to_s
@@ -88,29 +92,29 @@ module Gitlab
return unless token.present?
config = {
- apiVersion: 'v1',
+ apiVersion: "v1",
clusters: [
- name: 'gitlab-deploy',
+ name: "gitlab-deploy",
cluster: {
- server: url
- }
+ server: url,
+ },
],
contexts: [
- name: 'gitlab-deploy',
+ name: "gitlab-deploy",
context: {
- cluster: 'gitlab-deploy',
+ cluster: "gitlab-deploy",
namespace: namespace,
- user: 'gitlab-deploy'
- }
+ user: "gitlab-deploy",
+ },
],
- 'current-context': 'gitlab-deploy',
- kind: 'Config',
+ 'current-context': "gitlab-deploy",
+ kind: "Config",
users: [
{
- name: 'gitlab-deploy',
- user: { token: token }
- }
- ]
+ name: "gitlab-deploy",
+ user: {token: token},
+ },
+ ],
}
kubeconfig_embed_ca_pem(config, ca_pem) if ca_pem
diff --git a/lib/gitlab/kubernetes/cluster_role_binding.rb b/lib/gitlab/kubernetes/cluster_role_binding.rb
index ebea8aff5be..1cc94359790 100644
--- a/lib/gitlab/kubernetes/cluster_role_binding.rb
+++ b/lib/gitlab/kubernetes/cluster_role_binding.rb
@@ -22,14 +22,14 @@ module Gitlab
private
def metadata
- { name: name }
+ {name: name}
end
def role_ref
{
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: cluster_role_name
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: cluster_role_name,
}
end
end
diff --git a/lib/gitlab/kubernetes/config_map.rb b/lib/gitlab/kubernetes/config_map.rb
index 0bcaaa03974..9e7c5352e69 100644
--- a/lib/gitlab/kubernetes/config_map.rb
+++ b/lib/gitlab/kubernetes/config_map.rb
@@ -27,7 +27,7 @@ module Gitlab
{
name: config_map_name,
namespace: namespace,
- labels: { name: config_map_name }
+ labels: {name: config_map_name},
}
end
diff --git a/lib/gitlab/kubernetes/helm.rb b/lib/gitlab/kubernetes/helm.rb
index 42c4745ff98..baf4fa04423 100644
--- a/lib/gitlab/kubernetes/helm.rb
+++ b/lib/gitlab/kubernetes/helm.rb
@@ -3,12 +3,12 @@
module Gitlab
module Kubernetes
module Helm
- HELM_VERSION = '2.12.3'.freeze
- KUBECTL_VERSION = '1.11.7'.freeze
- NAMESPACE = 'gitlab-managed-apps'.freeze
- SERVICE_ACCOUNT = 'tiller'.freeze
- CLUSTER_ROLE_BINDING = 'tiller-admin'.freeze
- CLUSTER_ROLE = 'cluster-admin'.freeze
+ HELM_VERSION = "2.12.3"
+ KUBECTL_VERSION = "1.11.7"
+ NAMESPACE = "gitlab-managed-apps"
+ SERVICE_ACCOUNT = "tiller"
+ CLUSTER_ROLE_BINDING = "tiller-admin"
+ CLUSTER_ROLE = "cluster-admin"
end
end
end
diff --git a/lib/gitlab/kubernetes/helm/api.rb b/lib/gitlab/kubernetes/helm/api.rb
index 7dfd9ed4f35..37be5d0b533 100644
--- a/lib/gitlab/kubernetes/helm/api.rb
+++ b/lib/gitlab/kubernetes/helm/api.rb
@@ -20,7 +20,7 @@ module Gitlab
kubeclient.create_pod(command.pod_resource)
end
- alias_method :update, :install
+ alias update install
##
# Returns Pod phase
diff --git a/lib/gitlab/kubernetes/helm/certificate.rb b/lib/gitlab/kubernetes/helm/certificate.rb
index 598714e0874..8c8ae0d704f 100644
--- a/lib/gitlab/kubernetes/helm/certificate.rb
+++ b/lib/gitlab/kubernetes/helm/certificate.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
module Gitlab
module Kubernetes
module Helm
@@ -53,9 +54,9 @@ module Gitlab
extension_factory = OpenSSL::X509::ExtensionFactory.new
extension_factory.subject_certificate = cert
extension_factory.issuer_certificate = cert
- cert.add_extension(extension_factory.create_extension('subjectKeyIdentifier', 'hash'))
- cert.add_extension(extension_factory.create_extension('basicConstraints', 'CA:TRUE', true))
- cert.add_extension(extension_factory.create_extension('keyUsage', 'cRLSign,keyCertSign', true))
+ cert.add_extension(extension_factory.create_extension("subjectKeyIdentifier", "hash"))
+ cert.add_extension(extension_factory.create_extension("basicConstraints", "CA:TRUE", true))
+ cert.add_extension(extension_factory.create_extension("keyUsage", "cRLSign,keyCertSign", true))
end
cert.sign(signed_by&.key || key, OpenSSL::Digest::SHA256.new)
diff --git a/lib/gitlab/kubernetes/helm/client_command.rb b/lib/gitlab/kubernetes/helm/client_command.rb
index 9940272a8bf..93c3c737573 100644
--- a/lib/gitlab/kubernetes/helm/client_command.rb
+++ b/lib/gitlab/kubernetes/helm/client_command.rb
@@ -9,7 +9,7 @@ module Gitlab
# installing an app. We ensure the helm version stored in the
# database is correct by also updating this after transition to
# :installed,:updated in Clusters::Concerns::ApplicationStatus
- 'helm init --upgrade'
+ "helm init --upgrade"
end
def wait_for_tiller_command
@@ -20,7 +20,7 @@ module Gitlab
end
def repository_command
- ['helm', 'repo', 'add', name, repository].shelljoin if repository
+ ["helm", "repo", "add", name, repository].shelljoin if repository
end
end
end
diff --git a/lib/gitlab/kubernetes/helm/init_command.rb b/lib/gitlab/kubernetes/helm/init_command.rb
index 88ed8572ffc..f40ebe09bf1 100644
--- a/lib/gitlab/kubernetes/helm/init_command.rb
+++ b/lib/gitlab/kubernetes/helm/init_command.rb
@@ -16,7 +16,7 @@ module Gitlab
def generate_script
super + [
- init_helm_command
+ init_helm_command,
].join("\n")
end
@@ -33,7 +33,7 @@ module Gitlab
def cluster_role_binding_resource
return unless rbac?
- subjects = [{ kind: 'ServiceAccount', name: service_account_name, namespace: namespace }]
+ subjects = [{kind: "ServiceAccount", name: service_account_name, namespace: namespace}]
Gitlab::Kubernetes::ClusterRoleBinding.new(
cluster_role_binding_name,
@@ -56,18 +56,18 @@ module Gitlab
def tls_flags
[
- '--tiller-tls',
- '--tiller-tls-verify',
- '--tls-ca-cert', "#{files_dir}/ca.pem",
- '--tiller-tls-cert', "#{files_dir}/cert.pem",
- '--tiller-tls-key', "#{files_dir}/key.pem"
+ "--tiller-tls",
+ "--tiller-tls-verify",
+ "--tls-ca-cert", "#{files_dir}/ca.pem",
+ "--tiller-tls-cert", "#{files_dir}/cert.pem",
+ "--tiller-tls-key", "#{files_dir}/key.pem",
]
end
def optional_service_account_flag
return [] unless rbac?
- ['--service-account', service_account_name]
+ ["--service-account", service_account_name]
end
def cluster_role_binding_name
diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb
index f931248b747..3d2b8fca162 100644
--- a/lib/gitlab/kubernetes/helm/install_command.rb
+++ b/lib/gitlab/kubernetes/helm/install_command.rb
@@ -28,7 +28,7 @@ module Gitlab
repository_update_command,
preinstall_command,
install_command,
- postinstall_command
+ postinstall_command,
].compact.join("\n")
end
@@ -39,13 +39,13 @@ module Gitlab
private
def repository_update_command
- 'helm repo update' if repository
+ "helm repo update" if repository
end
# Uses `helm upgrade --install` which means we can use this for both
# installation and uprade of applications
def install_command
- command = ['helm', 'upgrade', name, chart] +
+ command = ["helm", "upgrade", name, chart] +
install_flag +
reset_values_flag +
optional_tls_flags +
@@ -58,27 +58,27 @@ module Gitlab
end
def preinstall_command
- preinstall.join("\n") if preinstall
+ preinstall&.join("\n")
end
def postinstall_command
- postinstall.join("\n") if postinstall
+ postinstall&.join("\n")
end
def install_flag
- ['--install']
+ ["--install"]
end
def reset_values_flag
- ['--reset-values']
+ ["--reset-values"]
end
def value_flag
- ['-f', "/data/helm/#{name}/config/values.yaml"]
+ ["-f", "/data/helm/#{name}/config/values.yaml"]
end
def namespace_flag
- ['--namespace', Gitlab::Kubernetes::Helm::NAMESPACE]
+ ["--namespace", Gitlab::Kubernetes::Helm::NAMESPACE]
end
def rbac_create_flag
@@ -92,17 +92,17 @@ module Gitlab
def optional_version_flag
return [] unless version
- ['--version', version]
+ ["--version", version]
end
def optional_tls_flags
return [] unless files.key?(:'ca.pem')
[
- '--tls',
- '--tls-ca-cert', "#{files_dir}/ca.pem",
- '--tls-cert', "#{files_dir}/cert.pem",
- '--tls-key', "#{files_dir}/key.pem"
+ "--tls",
+ "--tls-ca-cert", "#{files_dir}/ca.pem",
+ "--tls-cert", "#{files_dir}/cert.pem",
+ "--tls-key", "#{files_dir}/key.pem",
]
end
end
diff --git a/lib/gitlab/kubernetes/helm/pod.rb b/lib/gitlab/kubernetes/helm/pod.rb
index 75484f80070..b104cbb8b67 100644
--- a/lib/gitlab/kubernetes/helm/pod.rb
+++ b/lib/gitlab/kubernetes/helm/pod.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def generate
- spec = { containers: [container_specification], restartPolicy: 'Never' }
+ spec = {containers: [container_specification], restartPolicy: "Never"}
spec[:volumes] = volumes_specification
spec[:containers][0][:volumeMounts] = volume_mounts_specification
@@ -26,18 +26,18 @@ module Gitlab
def container_specification
{
- name: 'helm',
+ name: "helm",
image: "registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/#{Gitlab::Kubernetes::Helm::HELM_VERSION}-kube-#{Gitlab::Kubernetes::Helm::KUBECTL_VERSION}",
env: generate_pod_env(command),
- command: %w(/bin/sh),
- args: %w(-c $(COMMAND_SCRIPT))
+ command: %w[/bin/sh],
+ args: %w(-c $(COMMAND_SCRIPT)),
}
end
def labels
{
- 'gitlab.org/action': 'install',
- 'gitlab.org/application': command.name
+ 'gitlab.org/action': "install",
+ 'gitlab.org/application': command.name,
}
end
@@ -45,7 +45,7 @@ module Gitlab
{
name: command.pod_name,
namespace: namespace_name,
- labels: labels
+ labels: labels,
}
end
@@ -53,28 +53,28 @@ module Gitlab
{
HELM_VERSION: Gitlab::Kubernetes::Helm::HELM_VERSION,
TILLER_NAMESPACE: namespace_name,
- COMMAND_SCRIPT: command.generate_script
- }.map { |key, value| { name: key, value: value } }
+ COMMAND_SCRIPT: command.generate_script,
+ }.map { |key, value| {name: key, value: value} }
end
def volumes_specification
[
{
- name: 'configuration-volume',
+ name: "configuration-volume",
configMap: {
name: "values-content-configuration-#{command.name}",
- items: command.file_names.map { |name| { key: name, path: name } }
- }
- }
+ items: command.file_names.map { |name| {key: name, path: name} },
+ },
+ },
]
end
def volume_mounts_specification
[
{
- name: 'configuration-volume',
- mountPath: "/data/helm/#{command.name}/config"
- }
+ name: "configuration-volume",
+ mountPath: "/data/helm/#{command.name}/config",
+ },
]
end
end
diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb
index 624c2c67551..a71d1bba644 100644
--- a/lib/gitlab/kubernetes/kube_client.rb
+++ b/lib/gitlab/kubernetes/kube_client.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'uri'
+require "uri"
module Gitlab
module Kubernetes
@@ -14,10 +14,10 @@ module Gitlab
include Gitlab::Utils::StrongMemoize
SUPPORTED_API_GROUPS = {
- core: { group: 'api', version: 'v1' },
- rbac: { group: 'apis/rbac.authorization.k8s.io', version: 'v1' },
- extensions: { group: 'apis/extensions', version: 'v1beta1' },
- knative: { group: 'apis/serving.knative.dev', version: 'v1alpha1' }
+ core: {group: "api", version: "v1"},
+ rbac: {group: "apis/rbac.authorization.k8s.io", version: "v1"},
+ extensions: {group: "apis/extensions", version: "v1beta1"},
+ knative: {group: "apis/serving.knative.dev", version: "v1alpha1"},
}.freeze
SUPPORTED_API_GROUPS.each do |name, params|
@@ -152,7 +152,7 @@ module Gitlab
def join_api_url(api_prefix, api_path)
url = URI.parse(api_prefix)
- prefix = url.path.sub(%r{/+\z}, '')
+ prefix = url.path.sub(%r{/+\z}, "")
url.path = [prefix, api_path].join("/")
diff --git a/lib/gitlab/kubernetes/logger.rb b/lib/gitlab/kubernetes/logger.rb
index 5e59482419b..941cc3ed3cf 100644
--- a/lib/gitlab/kubernetes/logger.rb
+++ b/lib/gitlab/kubernetes/logger.rb
@@ -4,7 +4,7 @@ module Gitlab
module Kubernetes
class Logger < ::Gitlab::JsonLogger
def self.file_name_noext
- 'kubernetes'
+ "kubernetes"
end
end
end
diff --git a/lib/gitlab/kubernetes/namespace.rb b/lib/gitlab/kubernetes/namespace.rb
index 919f19c86d7..b7924a50113 100644
--- a/lib/gitlab/kubernetes/namespace.rb
+++ b/lib/gitlab/kubernetes/namespace.rb
@@ -17,7 +17,7 @@ module Gitlab
end
def create!
- resource = ::Kubeclient::Resource.new(metadata: { name: name })
+ resource = ::Kubeclient::Resource.new(metadata: {name: name})
@client.create_namespace(resource)
end
diff --git a/lib/gitlab/kubernetes/pod.rb b/lib/gitlab/kubernetes/pod.rb
index 81317e532b2..093e73efaba 100644
--- a/lib/gitlab/kubernetes/pod.rb
+++ b/lib/gitlab/kubernetes/pod.rb
@@ -3,11 +3,11 @@
module Gitlab
module Kubernetes
module Pod
- PENDING = 'Pending'.freeze
- RUNNING = 'Running'.freeze
- SUCCEEDED = 'Succeeded'.freeze
- FAILED = 'Failed'.freeze
- UNKNOWN = 'Unknown'.freeze
+ PENDING = "Pending"
+ RUNNING = "Running"
+ SUCCEEDED = "Succeeded"
+ FAILED = "Failed"
+ UNKNOWN = "Unknown"
PHASES = [PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN].freeze
end
end
diff --git a/lib/gitlab/kubernetes/role_binding.rb b/lib/gitlab/kubernetes/role_binding.rb
index cb0cb42d007..47e5d8a5ecb 100644
--- a/lib/gitlab/kubernetes/role_binding.rb
+++ b/lib/gitlab/kubernetes/role_binding.rb
@@ -23,24 +23,24 @@ module Gitlab
attr_reader :name, :role_name, :namespace, :service_account_name
def metadata
- { name: name, namespace: namespace }
+ {name: name, namespace: namespace}
end
def role_ref
{
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: role_name
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: role_name,
}
end
def subjects
[
{
- kind: 'ServiceAccount',
+ kind: "ServiceAccount",
name: service_account_name,
- namespace: namespace
- }
+ namespace: namespace,
+ },
]
end
end
diff --git a/lib/gitlab/kubernetes/service_account.rb b/lib/gitlab/kubernetes/service_account.rb
index d58fc1c3976..6154d87b3fd 100644
--- a/lib/gitlab/kubernetes/service_account.rb
+++ b/lib/gitlab/kubernetes/service_account.rb
@@ -19,7 +19,7 @@ module Gitlab
def metadata
{
name: name,
- namespace: namespace_name
+ namespace: namespace_name,
}
end
end
diff --git a/lib/gitlab/kubernetes/service_account_token.rb b/lib/gitlab/kubernetes/service_account_token.rb
index 2e912b26c09..a78ce58e0c0 100644
--- a/lib/gitlab/kubernetes/service_account_token.rb
+++ b/lib/gitlab/kubernetes/service_account_token.rb
@@ -19,7 +19,7 @@ module Gitlab
# as per https://kubernetes.io/docs/reference/access-authn-authz/service-accounts-admin/#to-create-additional-api-tokens
def service_acount_token_type
- 'kubernetes.io/service-account-token'
+ "kubernetes.io/service-account-token"
end
def metadata
@@ -27,8 +27,8 @@ module Gitlab
name: name,
namespace: namespace_name,
annotations: {
- "kubernetes.io/service-account.name": service_account_name
- }
+ "kubernetes.io/service-account.name": service_account_name,
+ },
}
end
end
diff --git a/lib/gitlab/language_data.rb b/lib/gitlab/language_data.rb
index bfdd7175198..0034ff0c85f 100644
--- a/lib/gitlab/language_data.rb
+++ b/lib/gitlab/language_data.rb
@@ -11,9 +11,9 @@ module Gitlab
EXTENSION_MUTEX.synchronize do
strong_memoize(:extensions) do
Set.new.tap do |set|
- YAML.load_file(Rails.root.join('vendor', 'languages.yml')).each do |_name, details|
- details['extensions']&.each do |ext|
- next unless ext.start_with?('.')
+ YAML.load_file(Rails.root.join("vendor", "languages.yml")).each do |_name, details|
+ details["extensions"]&.each do |ext|
+ next unless ext.start_with?(".")
set << ext.downcase
end
diff --git a/lib/gitlab/language_detection.rb b/lib/gitlab/language_detection.rb
index 7600e60b904..387f44056d3 100644
--- a/lib/gitlab/language_detection.rb
+++ b/lib/gitlab/language_detection.rb
@@ -26,30 +26,30 @@ module Gitlab
{
project_id: @repository.project.id,
share: detection[new_lang][:value],
- programming_language_id: lang_to_id[new_lang]
+ programming_language_id: lang_to_id[new_lang],
}
end
end
# updates analyses which records only require updating of their share
def updates
- to_update = @repository_languages.select do |lang|
+ to_update = @repository_languages.select { |lang|
detection.key?(lang.name) && detection[lang.name][:value] != lang.share
- end
+ }
to_update.map do |lang|
- { programming_language_id: lang.programming_language_id, share: detection[lang.name][:value] }
+ {programming_language_id: lang.programming_language_id, share: detection[lang.name][:value]}
end
end
# Returns the ids of the programming languages that do not occur in the detection
# as current repository languages
def deletions
- @repository_languages.map do |repo_lang|
+ @repository_languages.map { |repo_lang|
next if detection.key?(repo_lang.name)
repo_lang.programming_language_id
- end.compact
+ }.compact
end
private
@@ -61,10 +61,10 @@ module Gitlab
def detection
@detection ||=
@repository
- .languages
- .first(MAX_LANGUAGES)
- .map { |l| [l[:label], l] }
- .to_h
+ .languages
+ .first(MAX_LANGUAGES)
+ .map { |l| [l[:label], l] }
+ .to_h
end
end
end
diff --git a/lib/gitlab/legacy_github_import/base_formatter.rb b/lib/gitlab/legacy_github_import/base_formatter.rb
index 0b19cf742ed..2a24e16022d 100644
--- a/lib/gitlab/legacy_github_import/base_formatter.rb
+++ b/lib/gitlab/legacy_github_import/base_formatter.rb
@@ -23,7 +23,7 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord
def url
- raw_data.url || ''
+ raw_data.url || ""
end
end
end
diff --git a/lib/gitlab/legacy_github_import/branch_formatter.rb b/lib/gitlab/legacy_github_import/branch_formatter.rb
index 1177751457f..fc4a998da27 100644
--- a/lib/gitlab/legacy_github_import/branch_formatter.rb
+++ b/lib/gitlab/legacy_github_import/branch_formatter.rb
@@ -14,7 +14,7 @@ module Gitlab
end
def user
- raw_data.user&.login || 'unknown'
+ raw_data.user&.login || "unknown"
end
def short_sha
diff --git a/lib/gitlab/legacy_github_import/client.rb b/lib/gitlab/legacy_github_import/client.rb
index bc952147667..80cc369bfdb 100644
--- a/lib/gitlab/legacy_github_import/client.rb
+++ b/lib/gitlab/legacy_github_import/client.rb
@@ -8,9 +8,9 @@ module Gitlab
attr_reader :access_token, :host, :api_version
- def initialize(access_token, host: nil, api_version: 'v3')
+ def initialize(access_token, host: nil, api_version: "v3")
@access_token = access_token
- @host = host.to_s.sub(%r{/+\z}, '')
+ @host = host.to_s.sub(%r{/+\z}, "")
@api_version = api_version
@users = {}
@@ -26,7 +26,7 @@ module Gitlab
# If there is no config, we're connecting to github.com and we
# should verify ssl.
connection_options: {
- ssl: { verify: config ? config['verify_ssl'] : true }
+ ssl: {verify: config ? config["verify_ssl"] : true},
}
)
end
@@ -34,20 +34,20 @@ module Gitlab
def client
unless config
raise Projects::ImportService::Error,
- 'OAuth configuration for GitHub missing.'
+ "OAuth configuration for GitHub missing."
end
@client ||= ::OAuth2::Client.new(
config.app_id,
config.app_secret,
- github_options.merge(ssl: { verify: config['verify_ssl'] })
+ github_options.merge(ssl: {verify: config["verify_ssl"]})
)
end
def authorize_url(redirect_uri)
client.auth_code.authorize_url({
redirect_uri: redirect_uri,
- scope: "repo, user, user:email"
+ scope: "repo, user, user:email",
})
end
@@ -85,7 +85,7 @@ module Gitlab
end
def config
- Gitlab::Auth::OAuth::Provider.config_for('github')
+ Gitlab::Auth::OAuth::Provider.config_for("github")
end
def github_options
diff --git a/lib/gitlab/legacy_github_import/comment_formatter.rb b/lib/gitlab/legacy_github_import/comment_formatter.rb
index d83cc4f6b3c..cc9e71ed0ef 100644
--- a/lib/gitlab/legacy_github_import/comment_formatter.rb
+++ b/lib/gitlab/legacy_github_import/comment_formatter.rb
@@ -14,7 +14,7 @@ module Gitlab
author_id: author_id,
type: type,
created_at: raw_data.created_at,
- updated_at: raw_data.updated_at
+ updated_at: raw_data.updated_at,
}
end
@@ -64,7 +64,7 @@ module Gitlab
end
def type
- 'LegacyDiffNote' if on_diff?
+ "LegacyDiffNote" if on_diff?
end
end
end
diff --git a/lib/gitlab/legacy_github_import/importer.rb b/lib/gitlab/legacy_github_import/importer.rb
index f3323c98af2..e8863e61036 100644
--- a/lib/gitlab/legacy_github_import/importer.rb
+++ b/lib/gitlab/legacy_github_import/importer.rb
@@ -24,17 +24,17 @@ module Gitlab
unless credentials
raise Projects::ImportService::Error,
- "Unable to find project import data credentials for project ID: #{@project.id}"
+ "Unable to find project import data credentials for project ID: #{@project.id}"
end
opts = {}
# Gitea plan to be GitHub compliant
if project.gitea_import?
uri = URI.parse(project.import_url)
- host = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}".sub(%r{/?[\w-]+/[\w-]+\.git\z}, '')
+ host = "#{uri.scheme}://#{uri.host}:#{uri.port}#{uri.path}".sub(%r{/?[\w-]+/[\w-]+\.git\z}, "")
opts = {
host: host,
- api_version: 'v1'
+ api_version: "v1",
}
end
@@ -81,20 +81,18 @@ module Gitlab
return unless errors.any?
project.import_state.update_column(:last_error, {
- message: 'The remote data could not be fully imported.',
- errors: errors
+ message: "The remote data could not be fully imported.",
+ errors: errors,
}.to_json)
end
def import_labels
fetch_resources(:labels, repo, per_page: 100) do |labels|
labels.each do |raw|
- begin
- gh_label = LabelFormatter.new(project, raw)
- gh_label.create!
- rescue => e
- errors << { type: :label, url: Gitlab::UrlSanitizer.sanitize(gh_label.url), errors: e.message }
- end
+ gh_label = LabelFormatter.new(project, raw)
+ gh_label.create!
+ rescue => e
+ errors << {type: :label, url: Gitlab::UrlSanitizer.sanitize(gh_label.url), errors: e.message}
end
end
@@ -104,12 +102,10 @@ module Gitlab
def import_milestones
fetch_resources(:milestones, repo, state: :all, per_page: 100) do |milestones|
milestones.each do |raw|
- begin
- gh_milestone = MilestoneFormatter.new(project, raw)
- gh_milestone.create!
- rescue => e
- errors << { type: :milestone, url: Gitlab::UrlSanitizer.sanitize(gh_milestone.url), errors: e.message }
- end
+ gh_milestone = MilestoneFormatter.new(project, raw)
+ gh_milestone.create!
+ rescue => e
+ errors << {type: :milestone, url: Gitlab::UrlSanitizer.sanitize(gh_milestone.url), errors: e.message}
end
end
end
@@ -130,7 +126,7 @@ module Gitlab
apply_labels(issuable, raw)
rescue => e
- errors << { type: :issue, url: Gitlab::UrlSanitizer.sanitize(gh_issue.url), errors: e.message }
+ errors << {type: :issue, url: Gitlab::UrlSanitizer.sanitize(gh_issue.url), errors: e.message}
end
end
end
@@ -155,7 +151,7 @@ module Gitlab
apply_labels(merge_request, raw)
end
rescue => e
- errors << { type: :pull_request, url: Gitlab::UrlSanitizer.sanitize(gh_pull_request.url), errors: e.message }
+ errors << {type: :pull_request, url: Gitlab::UrlSanitizer.sanitize(gh_pull_request.url), errors: e.message}
ensure
clean_up_restored_branches(gh_pull_request)
end
@@ -176,7 +172,7 @@ module Gitlab
def remove_branch(name)
project.repository.delete_branch(name)
rescue Gitlab::Git::Repository::DeleteBranchFailed
- errors << { type: :remove_branch, name: name }
+ errors << {type: :remove_branch, name: name}
end
def clean_up_restored_branches(pull_request)
@@ -205,7 +201,7 @@ module Gitlab
# compare it against every comment in the current imported page until we find match, and that's where start importing
# 2. GH returns comments for _both_ issues and PRs through issues_comments API, while pull_requests_comments returns
# only comments on diffs, so select last note not based on noteable_type but on line_code
- line_code_is = issuable_type == :pull_requests ? 'NOT NULL' : 'NULL'
+ line_code_is = issuable_type == :pull_requests ? "NOT NULL" : "NULL"
last_note = project.notes.where("line_code IS #{line_code_is}").last
fetch_resources(resource_type, repo, per_page: 100) do |comments|
@@ -223,24 +219,22 @@ module Gitlab
def create_comments(comments)
ActiveRecord::Base.no_touching do
comments.each do |raw|
- begin
- comment = CommentFormatter.new(project, raw, client)
+ comment = CommentFormatter.new(project, raw, client)
- # GH does not return info about comment's parent, so we guess it by checking its URL!
- *_, parent, iid = URI(raw.html_url).path.split('/')
+ # GH does not return info about comment's parent, so we guess it by checking its URL!
+ *_, parent, iid = URI(raw.html_url).path.split("/")
- issuable = if parent == 'issues'
- Issue.find_by(project_id: project.id, iid: iid)
- else
- MergeRequest.find_by(target_project_id: project.id, iid: iid)
- end
+ issuable = if parent == "issues"
+ Issue.find_by(project_id: project.id, iid: iid)
+ else
+ MergeRequest.find_by(target_project_id: project.id, iid: iid)
+ end
- next unless issuable
+ next unless issuable
- issuable.notes.create!(comment.attributes)
- rescue => e
- errors << { type: :comment, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message }
- end
+ issuable.notes.create!(comment.attributes)
+ rescue => e
+ errors << {type: :comment, url: Gitlab::UrlSanitizer.sanitize(raw.url), errors: e.message}
end
end
end
@@ -249,13 +243,13 @@ module Gitlab
def discard_inserted_comments(comments, last_note)
last_note_attrs = nil
- cut_off_index = comments.find_index do |raw|
+ cut_off_index = comments.find_index { |raw|
comment = CommentFormatter.new(project, raw)
comment_attrs = comment.attributes
last_note_attrs ||= last_note.slice(*comment_attrs.keys)
comment_attrs.with_indifferent_access == last_note_attrs
- end
+ }
# No matching resource in the collection, which means we got halted right on the end of the last page, so all good
return unless cut_off_index
@@ -273,20 +267,18 @@ module Gitlab
# GitHub error message when the wiki repo has not been created,
# this means that repo has wiki enabled, but have no pages. So,
# we can skip the import.
- if e.message !~ /repository not exported/
- errors << { type: :wiki, errors: e.message }
+ unless /repository not exported/.match?(e.message)
+ errors << {type: :wiki, errors: e.message}
end
end
def import_releases
fetch_resources(:releases, repo, per_page: 100) do |releases|
releases.each do |raw|
- begin
- gh_release = ReleaseFormatter.new(project, raw)
- gh_release.create! if gh_release.valid?
- rescue => e
- errors << { type: :release, url: Gitlab::UrlSanitizer.sanitize(gh_release.url), errors: e.message }
- end
+ gh_release = ReleaseFormatter.new(project, raw)
+ gh_release.create! if gh_release.valid?
+ rescue => e
+ errors << {type: :release, url: Gitlab::UrlSanitizer.sanitize(gh_release.url), errors: e.message}
end
end
end
diff --git a/lib/gitlab/legacy_github_import/issuable_formatter.rb b/lib/gitlab/legacy_github_import/issuable_formatter.rb
index 1a0aefbbd62..cbd1cb54d3f 100644
--- a/lib/gitlab/legacy_github_import/issuable_formatter.rb
+++ b/lib/gitlab/legacy_github_import/issuable_formatter.rb
@@ -12,13 +12,13 @@ module Gitlab
delegate :number, to: :raw_data
def find_condition
- { iid: number }
+ {iid: number}
end
private
def state
- raw_data.state == 'closed' ? 'closed' : 'opened'
+ raw_data.state == "closed" ? "closed" : "opened"
end
def assigned?
diff --git a/lib/gitlab/legacy_github_import/issue_formatter.rb b/lib/gitlab/legacy_github_import/issue_formatter.rb
index 2f46e2e30d1..bf47feb7398 100644
--- a/lib/gitlab/legacy_github_import/issue_formatter.rb
+++ b/lib/gitlab/legacy_github_import/issue_formatter.rb
@@ -14,7 +14,7 @@ module Gitlab
author_id: author_id,
assignee_ids: Array(assignee_id),
created_at: raw_data.created_at,
- updated_at: raw_data.updated_at
+ updated_at: raw_data.updated_at,
}
end
diff --git a/lib/gitlab/legacy_github_import/label_formatter.rb b/lib/gitlab/legacy_github_import/label_formatter.rb
index 89200e794d8..b3c215aba98 100644
--- a/lib/gitlab/legacy_github_import/label_formatter.rb
+++ b/lib/gitlab/legacy_github_import/label_formatter.rb
@@ -7,7 +7,7 @@ module Gitlab
{
project: project,
title: title,
- color: color
+ color: color,
}
end
diff --git a/lib/gitlab/legacy_github_import/milestone_formatter.rb b/lib/gitlab/legacy_github_import/milestone_formatter.rb
index 2fe1b4258d3..f9fedc094c7 100644
--- a/lib/gitlab/legacy_github_import/milestone_formatter.rb
+++ b/lib/gitlab/legacy_github_import/milestone_formatter.rb
@@ -12,7 +12,7 @@ module Gitlab
due_date: raw_data.due_on,
state: state,
created_at: raw_data.created_at,
- updated_at: raw_data.updated_at
+ updated_at: raw_data.updated_at,
}
end
@@ -21,7 +21,7 @@ module Gitlab
end
def find_condition
- { iid: number }
+ {iid: number}
end
def number
@@ -35,7 +35,7 @@ module Gitlab
private
def state
- raw_data.state == 'closed' ? 'closed' : 'active'
+ raw_data.state == "closed" ? "closed" : "active"
end
end
end
diff --git a/lib/gitlab/legacy_github_import/project_creator.rb b/lib/gitlab/legacy_github_import/project_creator.rb
index ca1a1b8e9bd..6be3bf94c40 100644
--- a/lib/gitlab/legacy_github_import/project_creator.rb
+++ b/lib/gitlab/legacy_github_import/project_creator.rb
@@ -5,7 +5,7 @@ module Gitlab
class ProjectCreator
attr_reader :repo, :name, :namespace, :current_user, :session_data, :type
- def initialize(repo, name, namespace, current_user, session_data, type: 'github')
+ def initialize(repo, name, namespace, current_user, session_data, type: "github")
@repo = repo
@name = name
@namespace = namespace
@@ -24,7 +24,7 @@ module Gitlab
import_type: type,
import_source: repo.full_name,
import_url: import_url,
- skip_wiki: skip_wiki
+ skip_wiki: skip_wiki,
}.merge!(extra_attrs)
::Projects::CreateService.new(current_user, attrs).execute
@@ -33,7 +33,7 @@ module Gitlab
private
def import_url
- repo.clone_url.sub('://', "://#{session_data[:github_access_token]}@")
+ repo.clone_url.sub("://", "://#{session_data[:github_access_token]}@")
end
def visibility_level
diff --git a/lib/gitlab/legacy_github_import/pull_request_formatter.rb b/lib/gitlab/legacy_github_import/pull_request_formatter.rb
index 5b847f13d4a..39740d438ec 100644
--- a/lib/gitlab/legacy_github_import/pull_request_formatter.rb
+++ b/lib/gitlab/legacy_github_import/pull_request_formatter.rb
@@ -23,7 +23,7 @@ module Gitlab
assignee_id: assignee_id,
created_at: raw_data.created_at,
updated_at: raw_data.updated_at,
- imported: true
+ imported: true,
}
end
@@ -75,14 +75,14 @@ module Gitlab
end
def opened?
- state == 'opened'
+ state == "opened"
end
private
def state
- if raw_data.state == 'closed' && raw_data.merged_at.present?
- 'merged'
+ if raw_data.state == "closed" && raw_data.merged_at.present?
+ "merged"
else
super
end
diff --git a/lib/gitlab/legacy_github_import/release_formatter.rb b/lib/gitlab/legacy_github_import/release_formatter.rb
index 8c0c17780ca..f1c21795cbf 100644
--- a/lib/gitlab/legacy_github_import/release_formatter.rb
+++ b/lib/gitlab/legacy_github_import/release_formatter.rb
@@ -9,7 +9,7 @@ module Gitlab
tag: raw_data.tag_name,
description: raw_data.body,
created_at: raw_data.created_at,
- updated_at: raw_data.created_at
+ updated_at: raw_data.created_at,
}
end
@@ -18,7 +18,7 @@ module Gitlab
end
def find_condition
- { tag: raw_data.tag_name }
+ {tag: raw_data.tag_name}
end
def valid?
diff --git a/lib/gitlab/legacy_github_import/user_formatter.rb b/lib/gitlab/legacy_github_import/user_formatter.rb
index ec0e221b1ff..5d41841d2c0 100644
--- a/lib/gitlab/legacy_github_import/user_formatter.rb
+++ b/lib/gitlab/legacy_github_import/user_formatter.rb
@@ -28,7 +28,7 @@ module Gitlab
return nil unless email
User.find_by_any_email(email)
- .try(:id)
+ .try(:id)
end
# rubocop: disable CodeReuse/ActiveRecord
@@ -38,10 +38,10 @@ module Gitlab
identities = ::Identity.arel_table
User.select(:id)
- .joins(:identities).where(identities[:provider].eq(:github)
+ .joins(:identities).where(identities[:provider].eq(:github)
.and(identities[:extern_uid].eq(id)))
- .first
- .try(:id)
+ .first
+ .try(:id)
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/lib/gitlab/lfs_token.rb b/lib/gitlab/lfs_token.rb
index 31e6fc9d8c7..accbf14f961 100644
--- a/lib/gitlab/lfs_token.rb
+++ b/lib/gitlab/lfs_token.rb
@@ -26,7 +26,7 @@ module Gitlab
when Key
actor.user
else
- raise 'Bad Actor'
+ raise "Bad Actor"
end
end
@@ -52,7 +52,7 @@ module Gitlab
username: actor_name,
lfs_token: token,
repository_http_path: repository_http_path,
- expires_in: DEFAULT_EXPIRE_TIME
+ expires_in: DEFAULT_EXPIRE_TIME,
}
end
@@ -68,13 +68,13 @@ module Gitlab
def token(expire_time)
hmac_token = JSONWebToken::HMACToken.new(secret)
hmac_token.expire_time = Time.now + expire_time
- hmac_token[:data] = { actor: actor_name }
+ hmac_token[:data] = {actor: actor_name}
hmac_token.encoded
end
def token_valid?(token_to_check)
decoded_token = JSONWebToken::HMACToken.decode(token_to_check, secret).first
- decoded_token.dig('data', 'actor') == actor_name
+ decoded_token.dig("data", "actor") == actor_name
rescue JWT::DecodeError
false
end
@@ -90,7 +90,7 @@ module Gitlab
def salt
case actor
when DeployKey, Key
- actor.fingerprint.delete(':').first(16)
+ actor.fingerprint.delete(":").first(16)
when User
# Take the last 16 characters as they're more unique than the first 16
actor.id.to_s + actor.encrypted_password.last(16)
diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb
index 128a5dd8936..5712f772eb0 100644
--- a/lib/gitlab/logger.rb
+++ b/lib/gitlab/logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class Logger < ::Logger
def self.file_name
- file_name_noext + '.log'
+ file_name_noext + ".log"
end
def self.debug(message)
@@ -23,16 +23,16 @@ module Gitlab
end
def self.read_latest
- path = self.full_log_path
+ path = full_log_path
return [] unless File.readable?(path)
- tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
+ tail_output, _ = Gitlab::Popen.popen(%W[tail -n 2000 #{path}])
tail_output.split("\n")
end
def self.build
- Gitlab::SafeRequestStore[self.cache_key] ||= new(self.full_log_path)
+ Gitlab::SafeRequestStore[cache_key] ||= new(full_log_path)
end
def self.full_log_path
@@ -40,7 +40,7 @@ module Gitlab
end
def self.cache_key
- 'logger:'.freeze + self.full_log_path.to_s
+ "logger:" + full_log_path.to_s
end
end
end
diff --git a/lib/gitlab/mail_room.rb b/lib/gitlab/mail_room.rb
index 78f2d83c1af..96430db5916 100644
--- a/lib/gitlab/mail_room.rb
+++ b/lib/gitlab/mail_room.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'yaml'
-require 'json'
-require_relative 'redis/queues' unless defined?(Gitlab::Redis::Queues)
+require "yaml"
+require "json"
+require_relative "redis/queues" unless defined?(Gitlab::Redis::Queues)
module Gitlab
module MailRoom
@@ -11,8 +11,8 @@ module Gitlab
port: 143,
ssl: false,
start_tls: false,
- mailbox: 'inbox',
- idle_timeout: 60
+ mailbox: "inbox",
+ idle_timeout: 60,
}.freeze
class << self
@@ -34,9 +34,9 @@ module Gitlab
return {} unless File.exist?(config_file)
config = YAML.load_file(config_file)[rails_env].deep_symbolize_keys[:incoming_email] || {}
- config = DEFAULT_CONFIG.merge(config) do |_key, oldval, newval|
+ config = DEFAULT_CONFIG.merge(config) { |_key, oldval, newval|
newval.nil? ? oldval : newval
- end
+ }
if config[:enabled] && config[:address]
gitlab_redis_queues = Gitlab::Redis::Queues.new(rails_env)
@@ -51,11 +51,11 @@ module Gitlab
end
def rails_env
- @rails_env ||= ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
+ @rails_env ||= ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development"
end
def config_file
- ENV['MAIL_ROOM_GITLAB_CONFIG_FILE'] || File.expand_path('../../config/gitlab.yml', __dir__)
+ ENV["MAIL_ROOM_GITLAB_CONFIG_FILE"] || File.expand_path("../../config/gitlab.yml", __dir__)
end
end
end
diff --git a/lib/gitlab/manifest_import/manifest.rb b/lib/gitlab/manifest_import/manifest.rb
index 7208fe5bbc5..4a33c0c3faa 100644
--- a/lib/gitlab/manifest_import/manifest.rb
+++ b/lib/gitlab/manifest_import/manifest.rb
@@ -22,16 +22,16 @@ module Gitlab
@parsed_xml = Nokogiri::XML(file) { |config| config.strict }
@errors = []
rescue Nokogiri::XML::SyntaxError
- @errors = ['The uploaded file is not a valid XML file.']
+ @errors = ["The uploaded file is not a valid XML file."]
end
def projects
raw_projects.each_with_index.map do |project, i|
{
id: i,
- name: project['name'],
- path: project['path'],
- url: repository_url(project['name'])
+ name: project["name"],
+ path: project["path"],
+ url: repository_url(project["name"]),
}
end
end
@@ -40,11 +40,11 @@ module Gitlab
return false if @errors.any?
unless validate_remote
- @errors << 'Make sure a <remote> tag is present and is valid.'
+ @errors << "Make sure a <remote> tag is present and is valid."
end
unless validate_projects
- @errors << 'Make sure every <project> tag has name and path attributes.'
+ @errors << "Make sure every <project> tag has name and path attributes."
end
@errors.empty?
@@ -60,7 +60,7 @@ module Gitlab
def validate_projects
raw_projects.all? do |project|
- project['name'] && project['path']
+ project["name"] && project["path"]
end
end
@@ -71,12 +71,12 @@ module Gitlab
def remote
return @remote if defined?(@remote)
- remote_tag = parsed_xml.css('manifest > remote').first
- @remote = remote_tag['review'] if remote_tag
+ remote_tag = parsed_xml.css("manifest > remote").first
+ @remote = remote_tag["review"] if remote_tag
end
def raw_projects
- @raw_projects ||= parsed_xml.css('manifest > project')
+ @raw_projects ||= parsed_xml.css("manifest > project")
end
end
end
diff --git a/lib/gitlab/manifest_import/project_creator.rb b/lib/gitlab/manifest_import/project_creator.rb
index 837d65e5f7c..f6737fda199 100644
--- a/lib/gitlab/manifest_import/project_creator.rb
+++ b/lib/gitlab/manifest_import/project_creator.rb
@@ -12,17 +12,17 @@ module Gitlab
end
def execute
- group_full_path, _, project_path = repository[:path].rpartition('/')
+ group_full_path, _, project_path = repository[:path].rpartition("/")
group_full_path = File.join(destination.full_path, group_full_path) if destination
group = create_group_with_parents(group_full_path)
params = {
import_url: repository[:url],
- import_type: 'manifest',
+ import_type: "manifest",
namespace_id: group.id,
path: project_path,
name: project_path,
- visibility_level: destination.visibility_level
+ visibility_level: destination.visibility_level,
}
Projects::CreateService.new(current_user, params).execute
@@ -33,7 +33,7 @@ module Gitlab
def create_group_with_parents(full_path)
params = {
group_path: full_path,
- visibility_level: destination.visibility_level
+ visibility_level: destination.visibility_level,
}
Groups::NestedCreateService.new(current_user, params).execute
diff --git a/lib/gitlab/markup_helper.rb b/lib/gitlab/markup_helper.rb
index d419fa66e57..aa85d694b34 100644
--- a/lib/gitlab/markup_helper.rb
+++ b/lib/gitlab/markup_helper.rb
@@ -44,7 +44,7 @@ module Gitlab
#
# Returns boolean
def plain?(filename)
- extension(filename) == 'txt' || plain_filename?(filename)
+ extension(filename) == "txt" || plain_filename?(filename)
end
def previewable?(filename)
@@ -54,7 +54,7 @@ module Gitlab
private
def extension(filename)
- File.extname(filename).downcase.delete('.')
+ File.extname(filename).downcase.delete(".")
end
def plain_filename?(filename)
diff --git a/lib/gitlab/metrics/background_transaction.rb b/lib/gitlab/metrics/background_transaction.rb
index fe1722b1095..90488fcacb2 100644
--- a/lib/gitlab/metrics/background_transaction.rb
+++ b/lib/gitlab/metrics/background_transaction.rb
@@ -9,7 +9,7 @@ module Gitlab
end
def labels
- { controller: @worker_class.name, action: 'perform' }
+ {controller: @worker_class.name, action: "perform"}
end
end
end
diff --git a/lib/gitlab/metrics/influx_db.rb b/lib/gitlab/metrics/influx_db.rb
index 0b04340fbb5..6aaccf3fda5 100644
--- a/lib/gitlab/metrics/influx_db.rb
+++ b/lib/gitlab/metrics/influx_db.rb
@@ -30,13 +30,13 @@ module Gitlab
host: current_settings[:metrics_host],
port: current_settings[:metrics_port],
sample_interval: current_settings[:metrics_sample_interval] || 15,
- packet_size: current_settings[:metrics_packet_size] || 1
- }
+ packet_size: current_settings[:metrics_packet_size] || 1,
+ }
end
end
def mri?
- RUBY_ENGINE == 'ruby'
+ RUBY_ENGINE == "ruby"
end
def method_call_threshold
@@ -52,14 +52,12 @@ module Gitlab
pool&.with do |connection|
prepared.each_slice(settings[:packet_size]) do |slice|
- begin
- connection.write_points(slice)
- rescue StandardError
- end
+ connection.write_points(slice)
+ rescue
end
end
rescue Errno::EADDRNOTAVAIL, SocketError => ex
- Gitlab::EnvironmentLogger.error('Cannot resolve InfluxDB address. GitLab Performance Monitoring will not work.')
+ Gitlab::EnvironmentLogger.error("Cannot resolve InfluxDB address. GitLab Performance Monitoring will not work.")
Gitlab::EnvironmentLogger.error(ex)
end
@@ -80,7 +78,7 @@ module Gitlab
end
def escape_value(value)
- value.to_s.gsub('=', '\\=')
+ value.to_s.gsub("=", '\\=')
end
# Measures the execution time of a block.
@@ -110,20 +108,20 @@ module Gitlab
real_time = (real_stop - real_start)
cpu_time = cpu_stop - cpu_start
- real_duration_seconds = fetch_histogram("gitlab_#{name}_real_duration_seconds".to_sym) do
+ real_duration_seconds = fetch_histogram("gitlab_#{name}_real_duration_seconds".to_sym) {
docstring "Measure #{name}"
base_labels Transaction::BASE_LABELS
buckets EXECUTION_MEASUREMENT_BUCKETS
- end
+ }
real_duration_seconds.observe(trans.labels, real_time)
- cpu_duration_seconds = fetch_histogram("gitlab_#{name}_cpu_duration_seconds".to_sym) do
+ cpu_duration_seconds = fetch_histogram("gitlab_#{name}_cpu_duration_seconds".to_sym) {
docstring "Measure #{name}"
base_labels Transaction::BASE_LABELS
buckets EXECUTION_MEASUREMENT_BUCKETS
with_feature "prometheus_metrics_measure_#{name}_cpu_duration"
- end
+ }
cpu_duration_seconds.observe(trans.labels, cpu_time)
# InfluxDB stores the _real_time and _cpu_time time values as milliseconds
@@ -152,7 +150,7 @@ module Gitlab
# Returns the prefix to use for the name of a series.
def series_prefix
- @series_prefix ||= Sidekiq.server? ? 'sidekiq_' : 'rails_'
+ @series_prefix ||= Sidekiq.server? ? "sidekiq_" : "rails_"
end
# Allow access from other metrics related middlewares
@@ -166,13 +164,13 @@ module Gitlab
if influx_metrics_enabled?
if @pool.nil?
MUTEX.synchronize do
- @pool ||= ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) do
+ @pool ||= ConnectionPool.new(size: settings[:pool_size], timeout: settings[:timeout]) {
host = settings[:host]
port = settings[:port]
InfluxDB::Client
- .new(udp: { host: host, port: port })
- end
+ .new(udp: {host: host, port: port})
+ }
end
end
diff --git a/lib/gitlab/metrics/instrumentation.rb b/lib/gitlab/metrics/instrumentation.rb
index ff3fffe7b95..80f53b9ab4c 100644
--- a/lib/gitlab/metrics/instrumentation.rb
+++ b/lib/gitlab/metrics/instrumentation.rb
@@ -149,9 +149,9 @@ module Gitlab
# method also accepts them.
args_signature =
if method.arity == 0
- ''
+ ""
else
- '*args'
+ "*args"
end
proxy_module.class_eval <<-EOF, __FILE__, __LINE__ + 1
diff --git a/lib/gitlab/metrics/method_call.rb b/lib/gitlab/metrics/method_call.rb
index d0c63a862c2..93a23f5e955 100644
--- a/lib/gitlab/metrics/method_call.rb
+++ b/lib/gitlab/metrics/method_call.rb
@@ -5,11 +5,11 @@ module Gitlab
# Class for tracking timing information about method calls
class MethodCall
include Gitlab::Metrics::Methods
- BASE_LABELS = { module: nil, method: nil }.freeze
+ BASE_LABELS = {module: nil, method: nil}.freeze
attr_reader :real_time, :cpu_time, :call_count, :labels
define_histogram :gitlab_method_call_duration_seconds do
- docstring 'Method calls real duration'
+ docstring "Method calls real duration"
base_labels Transaction::BASE_LABELS.merge(BASE_LABELS)
buckets [0.01, 0.05, 0.1, 0.5, 1]
with_feature :prometheus_metrics_method_instrumentation
@@ -23,7 +23,7 @@ module Gitlab
@method_name = method_name
@transaction = transaction
@name = name
- @labels = { module: @module_name, method: @method_name }
+ @labels = {module: @module_name, method: @method_name}
@real_time = 0.0
@cpu_time = 0.0
@call_count = 0
@@ -56,7 +56,7 @@ module Gitlab
{
duration: real_time.in_milliseconds.to_i,
cpu_duration: cpu_time.in_milliseconds.to_i,
- call_count: call_count
+ call_count: call_count,
},
method: @name
)
diff --git a/lib/gitlab/metrics/metric.rb b/lib/gitlab/metrics/metric.rb
index 9e4d70a71ff..95e15e22baa 100644
--- a/lib/gitlab/metrics/metric.rb
+++ b/lib/gitlab/metrics/metric.rb
@@ -43,10 +43,10 @@ module Gitlab
time = System.real_time(:nanosecond) + rand(JITTER_RANGE)
{
- series: @series,
- tags: @tags,
- values: @values,
- timestamp: time.to_i
+ series: @series,
+ tags: @tags,
+ values: @values,
+ timestamp: time.to_i,
}
end
end
diff --git a/lib/gitlab/metrics/prometheus.rb b/lib/gitlab/metrics/prometheus.rb
index cab1edab48f..fdf83018d5d 100644
--- a/lib/gitlab/metrics/prometheus.rb
+++ b/lib/gitlab/metrics/prometheus.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'prometheus/client'
+require "prometheus/client"
module Gitlab
module Metrics
diff --git a/lib/gitlab/metrics/rack_middleware.rb b/lib/gitlab/metrics/rack_middleware.rb
index 9aa97515961..59e59694ae8 100644
--- a/lib/gitlab/metrics/rack_middleware.rb
+++ b/lib/gitlab/metrics/rack_middleware.rb
@@ -15,7 +15,6 @@ module Gitlab
begin
retval = trans.run { @app.call(env) }
-
rescue Exception => error # rubocop: disable Lint/RescueException
trans.add_event(:rails_exception)
@@ -33,7 +32,7 @@ module Gitlab
trans = WebTransaction.new(env)
trans.set(:request_uri, filtered_path(env), false)
- trans.set(:request_method, env['REQUEST_METHOD'], false)
+ trans.set(:request_method, env["REQUEST_METHOD"], false)
trans
end
@@ -41,7 +40,7 @@ module Gitlab
private
def filtered_path(env)
- ActionDispatch::Request.new(env).filtered_path.presence || env['REQUEST_URI']
+ ActionDispatch::Request.new(env).filtered_path.presence || env["REQUEST_URI"]
end
end
end
diff --git a/lib/gitlab/metrics/requests_rack_middleware.rb b/lib/gitlab/metrics/requests_rack_middleware.rb
index 26aa0910047..42e328c2322 100644
--- a/lib/gitlab/metrics/requests_rack_middleware.rb
+++ b/lib/gitlab/metrics/requests_rack_middleware.rb
@@ -8,20 +8,20 @@ module Gitlab
end
def self.http_request_total
- @http_request_total ||= ::Gitlab::Metrics.counter(:http_requests_total, 'Request count')
+ @http_request_total ||= ::Gitlab::Metrics.counter(:http_requests_total, "Request count")
end
def self.rack_uncaught_errors_count
- @rack_uncaught_errors_count ||= ::Gitlab::Metrics.counter(:rack_uncaught_errors_total, 'Request handling uncaught errors count')
+ @rack_uncaught_errors_count ||= ::Gitlab::Metrics.counter(:rack_uncaught_errors_total, "Request handling uncaught errors count")
end
def self.http_request_duration_seconds
- @http_request_duration_seconds ||= ::Gitlab::Metrics.histogram(:http_request_duration_seconds, 'Request handling execution time',
- {}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25])
+ @http_request_duration_seconds ||= ::Gitlab::Metrics.histogram(:http_request_duration_seconds, "Request handling execution time",
+ {}, [0.05, 0.1, 0.25, 0.5, 0.7, 1, 2.5, 5, 10, 25])
end
def call(env)
- method = env['REQUEST_METHOD'].downcase
+ method = env["REQUEST_METHOD"].downcase
started = Time.now.to_f
begin
RequestsRackMiddleware.http_request_total.increment(method: method)
@@ -29,7 +29,7 @@ module Gitlab
status, headers, body = @app.call(env)
elapsed = Time.now.to_f - started
- RequestsRackMiddleware.http_request_duration_seconds.observe({ method: method, status: status }, elapsed)
+ RequestsRackMiddleware.http_request_duration_seconds.observe({method: method, status: status}, elapsed)
[status, headers, body]
rescue
diff --git a/lib/gitlab/metrics/samplers/base_sampler.rb b/lib/gitlab/metrics/samplers/base_sampler.rb
index 6a062e93f0f..6cf9d547fb8 100644
--- a/lib/gitlab/metrics/samplers/base_sampler.rb
+++ b/lib/gitlab/metrics/samplers/base_sampler.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'logger'
+require "logger"
module Gitlab
module Metrics
diff --git a/lib/gitlab/metrics/samplers/influx_sampler.rb b/lib/gitlab/metrics/samplers/influx_sampler.rb
index 5138b37f83e..d332dbcc44f 100644
--- a/lib/gitlab/metrics/samplers/influx_sampler.rb
+++ b/lib/gitlab/metrics/samplers/influx_sampler.rb
@@ -36,11 +36,11 @@ module Gitlab
end
def sample_memory_usage
- add_metric('memory_usage', value: System.memory_usage)
+ add_metric("memory_usage", value: System.memory_usage)
end
def sample_file_descriptors
- add_metric('file_descriptors', value: System.file_descriptor_count)
+ add_metric("file_descriptors", value: System.file_descriptor_count)
end
def sample_gc
@@ -57,11 +57,11 @@ module Gitlab
stats[:count] = stats[:minor_gc_count] + stats[:major_gc_count]
- add_metric('gc_statistics', stats)
+ add_metric("gc_statistics", stats)
end
def add_metric(series, values, tags = {})
- prefix = sidekiq? ? 'sidekiq_' : 'rails_'
+ prefix = sidekiq? ? "sidekiq_" : "rails_"
@metrics << Metric.new("#{prefix}#{series}", values, tags)
end
diff --git a/lib/gitlab/metrics/samplers/ruby_sampler.rb b/lib/gitlab/metrics/samplers/ruby_sampler.rb
index 18a69321905..22e992389ee 100644
--- a/lib/gitlab/metrics/samplers/ruby_sampler.rb
+++ b/lib/gitlab/metrics/samplers/ruby_sampler.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'prometheus/client/support/unicorn'
+require "prometheus/client/support/unicorn"
module Gitlab
module Metrics
@@ -24,14 +24,14 @@ module Gitlab
def init_metrics
metrics = {}
- metrics[:sampler_duration] = ::Gitlab::Metrics.counter(with_prefix(:sampler, :duration_seconds_total), 'Sampler time', labels)
- metrics[:total_time] = ::Gitlab::Metrics.counter(with_prefix(:gc, :duration_seconds_total), 'Total GC time', labels)
+ metrics[:sampler_duration] = ::Gitlab::Metrics.counter(with_prefix(:sampler, :duration_seconds_total), "Sampler time", labels)
+ metrics[:total_time] = ::Gitlab::Metrics.counter(with_prefix(:gc, :duration_seconds_total), "Total GC time", labels)
GC.stat.keys.each do |key|
metrics[key] = ::Gitlab::Metrics.gauge(with_prefix(:gc_stat, key), to_doc_string(key), labels, :livesum)
end
- metrics[:memory_usage] = ::Gitlab::Metrics.gauge(with_prefix(:memory, :bytes), 'Memory used', labels, :livesum)
- metrics[:file_descriptors] = ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), 'File descriptors used', labels, :livesum)
+ metrics[:memory_usage] = ::Gitlab::Metrics.gauge(with_prefix(:memory, :bytes), "Memory used", labels, :livesum)
+ metrics[:file_descriptors] = ::Gitlab::Metrics.gauge(with_prefix(:file, :descriptors), "File descriptors used", labels, :livesum)
metrics
end
@@ -67,9 +67,9 @@ module Gitlab
worker_no = ::Prometheus::Client::Support::Unicorn.worker_id
if worker_no
- { worker: worker_no }
+ {worker: worker_no}
else
- { worker: 'master' }
+ {worker: "master"}
end
end
end
diff --git a/lib/gitlab/metrics/samplers/unicorn_sampler.rb b/lib/gitlab/metrics/samplers/unicorn_sampler.rb
index bec64e864b3..7ee303a824e 100644
--- a/lib/gitlab/metrics/samplers/unicorn_sampler.rb
+++ b/lib/gitlab/metrics/samplers/unicorn_sampler.rb
@@ -9,11 +9,11 @@ module Gitlab
end
def unicorn_active_connections
- @unicorn_active_connections ||= ::Gitlab::Metrics.gauge(:unicorn_active_connections, 'Unicorn active connections', {}, :max)
+ @unicorn_active_connections ||= ::Gitlab::Metrics.gauge(:unicorn_active_connections, "Unicorn active connections", {}, :max)
end
def unicorn_queued_connections
- @unicorn_queued_connections ||= ::Gitlab::Metrics.gauge(:unicorn_queued_connections, 'Unicorn queued connections', {}, :max)
+ @unicorn_queued_connections ||= ::Gitlab::Metrics.gauge(:unicorn_queued_connections, "Unicorn queued connections", {}, :max)
end
def enabled?
@@ -23,13 +23,13 @@ module Gitlab
def sample
Raindrops::Linux.tcp_listener_stats(tcp_listeners).each do |addr, stats|
- unicorn_active_connections.set({ socket_type: 'tcp', socket_address: addr }, stats.active)
- unicorn_queued_connections.set({ socket_type: 'tcp', socket_address: addr }, stats.queued)
+ unicorn_active_connections.set({socket_type: "tcp", socket_address: addr}, stats.active)
+ unicorn_queued_connections.set({socket_type: "tcp", socket_address: addr}, stats.queued)
end
Raindrops::Linux.unix_listener_stats(unix_listeners).each do |addr, stats|
- unicorn_active_connections.set({ socket_type: 'unix', socket_address: addr }, stats.active)
- unicorn_queued_connections.set({ socket_type: 'unix', socket_address: addr }, stats.queued)
+ unicorn_active_connections.set({socket_type: "unix", socket_address: addr}, stats.active)
+ unicorn_queued_connections.set({socket_type: "unix", socket_address: addr}, stats.queued)
end
end
diff --git a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
index 71a5406815f..36e0ccd7ee1 100644
--- a/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
+++ b/lib/gitlab/metrics/sidekiq_metrics_exporter.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'webrick'
-require 'prometheus/client/rack/exporter'
+require "webrick"
+require "prometheus/client/rack/exporter"
module Gitlab
module Metrics
class SidekiqMetricsExporter < Daemon
- LOG_FILENAME = File.join(Rails.root, 'log', 'sidekiq_exporter.log')
+ LOG_FILENAME = File.join(Rails.root, "log", "sidekiq_exporter.log")
def enabled?
::Gitlab::Metrics.metrics_folder_present? && settings.enabled
@@ -23,7 +23,7 @@ module Gitlab
def start_working
logger = WEBrick::Log.new(LOG_FILENAME)
access_log = [
- [logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT]
+ [logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT],
]
@server = ::WEBrick::HTTPServer.new(Port: settings.port, BindAddress: settings.address,
@@ -33,7 +33,7 @@ module Gitlab
end
def stop_working
- server.shutdown if server
+ server&.shutdown
@server = nil
end
@@ -41,7 +41,7 @@ module Gitlab
Rack::Builder.app do
use Rack::Deflater
use ::Prometheus::Client::Rack::Exporter
- run -> (env) { [404, {}, ['']] }
+ run ->(env) { [404, {}, [""]] }
end
end
end
diff --git a/lib/gitlab/metrics/sidekiq_middleware.rb b/lib/gitlab/metrics/sidekiq_middleware.rb
index 0b4485feea9..43a32e9b97b 100644
--- a/lib/gitlab/metrics/sidekiq_middleware.rb
+++ b/lib/gitlab/metrics/sidekiq_middleware.rb
@@ -11,7 +11,7 @@ module Gitlab
begin
# Old gitlad-shell messages don't provide enqueued_at/created_at attributes
- trans.set(:sidekiq_queue_duration, Time.now.to_f - (message['enqueued_at'] || message['created_at'] || 0))
+ trans.set(:sidekiq_queue_duration, Time.now.to_f - (message["enqueued_at"] || message["created_at"] || 0))
trans.run { yield }
rescue Exception => error # rubocop: disable Lint/RescueException
trans.add_event(:sidekiq_exception)
diff --git a/lib/gitlab/metrics/subscribers/action_view.rb b/lib/gitlab/metrics/subscribers/action_view.rb
index c068f8017fd..f45d6356772 100644
--- a/lib/gitlab/metrics/subscribers/action_view.rb
+++ b/lib/gitlab/metrics/subscribers/action_view.rb
@@ -7,21 +7,21 @@ module Gitlab
class ActionView < ActiveSupport::Subscriber
include Gitlab::Metrics::Methods
define_histogram :gitlab_view_rendering_duration_seconds do
- docstring 'View rendering time'
- base_labels Transaction::BASE_LABELS.merge({ path: nil })
+ docstring "View rendering time"
+ base_labels Transaction::BASE_LABELS.merge({path: nil})
buckets [0.001, 0.01, 0.1, 1, 10.0]
with_feature :prometheus_metrics_view_instrumentation
end
attach_to :action_view
- SERIES = 'views'.freeze
+ SERIES = "views"
def render_template(event)
track(event) if current_transaction
end
- alias_method :render_view, :render_template
+ alias render_view render_template
private
@@ -36,17 +36,17 @@ module Gitlab
end
def relative_path(path)
- path.gsub(%r{^#{Rails.root.to_s}/?}, '')
+ path.gsub(%r{^#{Rails.root.to_s}/?}, "")
end
def values_for(event)
- { duration: event.duration }
+ {duration: event.duration}
end
def tags_for(event)
path = relative_path(event.payload[:identifier])
- { view: path }
+ {view: path}
end
def current_transaction
diff --git a/lib/gitlab/metrics/subscribers/active_record.rb b/lib/gitlab/metrics/subscribers/active_record.rb
index a02dd850582..28fbb69872c 100644
--- a/lib/gitlab/metrics/subscribers/active_record.rb
+++ b/lib/gitlab/metrics/subscribers/active_record.rb
@@ -8,14 +8,14 @@ module Gitlab
include Gitlab::Metrics::Methods
attach_to :active_record
- IGNORABLE_SQL = %w{BEGIN COMMIT}.freeze
+ IGNORABLE_SQL = %w[BEGIN COMMIT].freeze
def sql(event)
return unless current_transaction
payload = event.payload
- return if payload[:name] == 'SCHEMA' || IGNORABLE_SQL.include?(payload[:sql])
+ return if payload[:name] == "SCHEMA" || IGNORABLE_SQL.include?(payload[:sql])
self.class.gitlab_sql_duration_seconds.observe(current_transaction.labels, event.duration / 1000.0)
@@ -26,7 +26,7 @@ module Gitlab
private
define_histogram :gitlab_sql_duration_seconds do
- docstring 'SQL time'
+ docstring "SQL time"
base_labels Transaction::BASE_LABELS
buckets [0.01, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0]
end
diff --git a/lib/gitlab/metrics/subscribers/rails_cache.rb b/lib/gitlab/metrics/subscribers/rails_cache.rb
index 01db507761b..365cb719470 100644
--- a/lib/gitlab/metrics/subscribers/rails_cache.rb
+++ b/lib/gitlab/metrics/subscribers/rails_cache.rb
@@ -50,7 +50,7 @@ module Gitlab
def observe(key, duration)
return unless current_transaction
- metric_cache_operation_duration_seconds.observe(current_transaction.labels.merge({ operation: key }), duration / 1000.0)
+ metric_cache_operation_duration_seconds.observe(current_transaction.labels.merge({operation: key}), duration / 1000.0)
current_transaction.increment(:cache_duration, duration, false)
current_transaction.increment(:cache_count, 1, false)
current_transaction.increment("cache_#{key}_duration".to_sym, duration, false)
@@ -66,8 +66,8 @@ module Gitlab
def metric_cache_operation_duration_seconds
@metric_cache_operation_duration_seconds ||= ::Gitlab::Metrics.histogram(
:gitlab_cache_operation_duration_seconds,
- 'Cache access time',
- Transaction::BASE_LABELS.merge({ action: nil }),
+ "Cache access time",
+ Transaction::BASE_LABELS.merge({action: nil}),
[0.001, 0.01, 0.1, 1, 10]
)
end
@@ -75,7 +75,7 @@ module Gitlab
def metric_cache_misses_total
@metric_cache_misses_total ||= ::Gitlab::Metrics.counter(
:gitlab_cache_misses_total,
- 'Cache read miss',
+ "Cache read miss",
Transaction::BASE_LABELS
)
end
diff --git a/lib/gitlab/metrics/system.rb b/lib/gitlab/metrics/system.rb
index 426496855e3..e6d510e57e0 100644
--- a/lib/gitlab/metrics/system.rb
+++ b/lib/gitlab/metrics/system.rb
@@ -7,11 +7,11 @@ module Gitlab
# This module relies on the /proc filesystem being available. If /proc is
# not available the methods of this module will be stubbed.
module System
- if File.exist?('/proc')
+ if File.exist?("/proc")
# Returns the current process' memory usage in bytes.
def self.memory_usage
mem = 0
- match = File.read('/proc/self/status').match(/VmRSS:\s+(\d+)/)
+ match = File.read("/proc/self/status").match(/VmRSS:\s+(\d+)/)
if match && match[1]
mem = match[1].to_f * 1024
@@ -21,7 +21,7 @@ module Gitlab
end
def self.file_descriptor_count
- Dir.glob('/proc/self/fd/*').length
+ Dir.glob("/proc/self/fd/*").length
end
else
def self.memory_usage
diff --git a/lib/gitlab/metrics/transaction.rb b/lib/gitlab/metrics/transaction.rb
index e91803ecd62..6d9dc75a84c 100644
--- a/lib/gitlab/metrics/transaction.rb
+++ b/lib/gitlab/metrics/transaction.rb
@@ -7,12 +7,12 @@ module Gitlab
include Gitlab::Metrics::Methods
# base labels shared among all transactions
- BASE_LABELS = { controller: nil, action: nil }.freeze
+ BASE_LABELS = {controller: nil, action: nil}.freeze
THREAD_KEY = :_gitlab_metrics_transaction
# The series to store events (e.g. Git pushes) in.
- EVENT_SERIES = 'events'.freeze
+ EVENT_SERIES = "events"
attr_reader :tags, :values, :method, :metrics
@@ -75,8 +75,8 @@ module Gitlab
# event_name - The name of the event (e.g. "git_push").
# tags - A set of tags to attach to the event.
def add_event(event_name, tags = {})
- self.class.transaction_metric(event_name, :counter, prefix: 'event_', use_feature_flag: true, tags: tags).increment(tags.merge(labels))
- @metrics << Metric.new(EVENT_SERIES, { count: 1 }, tags.merge(event: event_name), :event)
+ self.class.transaction_metric(event_name, :counter, prefix: "event_", use_feature_flag: true, tags: tags).increment(tags.merge(labels))
+ @metrics << Metric.new(EVENT_SERIES, {count: 1}, tags.merge(event: event_name), :event)
end
# Returns a MethodCall object for the given name.
@@ -104,13 +104,13 @@ module Gitlab
end
def track_self
- values = { duration: duration_milliseconds, allocated_memory: allocated_memory }
+ values = {duration: duration_milliseconds, allocated_memory: allocated_memory}
@values.each do |name, value|
values[name] = value
end
- add_metric('transactions', values, @tags)
+ add_metric("transactions", values, @tags)
end
def submit
@@ -120,12 +120,12 @@ module Gitlab
submit << method.to_metric if method.above_threshold?
end
- submit_hashes = submit.map do |metric|
+ submit_hashes = submit.map { |metric|
hash = metric.to_hash
hash[:tags][:action] ||= action if action && !metric.event?
hash
- end
+ }
::Gitlab::Metrics.submit_metrics(submit_hashes)
end
@@ -140,13 +140,13 @@ module Gitlab
end
define_histogram :gitlab_transaction_duration_seconds do
- docstring 'Transaction duration'
+ docstring "Transaction duration"
base_labels BASE_LABELS
buckets [0.1, 0.25, 0.5, 1.0, 2.5, 5.0]
end
define_histogram :gitlab_transaction_allocated_memory_bytes do
- docstring 'Transaction allocated memory bytes'
+ docstring "Transaction allocated memory bytes"
base_labels BASE_LABELS
buckets [100, 1000, 10000, 100000, 1000000, 10000000]
with_feature :prometheus_metrics_transaction_allocated_memory
diff --git a/lib/gitlab/metrics/web_transaction.rb b/lib/gitlab/metrics/web_transaction.rb
index b2a43d46fb2..8986537b03f 100644
--- a/lib/gitlab/metrics/web_transaction.rb
+++ b/lib/gitlab/metrics/web_transaction.rb
@@ -3,8 +3,8 @@
module Gitlab
module Metrics
class WebTransaction < Transaction
- CONTROLLER_KEY = 'action_controller.instance'.freeze
- ENDPOINT_KEY = 'api.endpoint'.freeze
+ CONTROLLER_KEY = "action_controller.instance"
+ ENDPOINT_KEY = "api.endpoint"
ALLOWED_SUFFIXES = Set.new(%w[json js atom rss xml zip])
def initialize(env)
@@ -17,10 +17,10 @@ module Gitlab
# memoize transaction labels only source env variables were present
@labels = if @env[CONTROLLER_KEY]
- labels_from_controller || {}
- elsif @env[ENDPOINT_KEY]
- labels_from_endpoint || {}
- end
+ labels_from_controller || {}
+ elsif @env[ENDPOINT_KEY]
+ labels_from_endpoint || {}
+ end
@labels || {}
end
@@ -30,7 +30,7 @@ module Gitlab
def labels_from_controller
controller = @env[CONTROLLER_KEY]
- action = "#{controller.action_name}"
+ action = controller.action_name.to_s
# Devise exposes a method called "request_format" that does the below.
# However, this method is not available to all controllers (e.g. certain
@@ -45,7 +45,7 @@ module Gitlab
action = "#{action}.#{suffix}"
end
- { controller: controller.class.name, action: action }
+ {controller: controller.class.name, action: action}
end
def labels_from_endpoint
@@ -61,20 +61,20 @@ module Gitlab
if route
path = endpoint_paths_cache[route.request_method][route.path]
- { controller: 'Grape', action: "#{route.request_method} #{path}" }
+ {controller: "Grape", action: "#{route.request_method} #{path}"}
end
end
def endpoint_paths_cache
- @endpoint_paths_cache ||= Hash.new do |hash, http_method|
- hash[http_method] = Hash.new do |inner_hash, raw_path|
+ @endpoint_paths_cache ||= Hash.new { |hash, http_method|
+ hash[http_method] = Hash.new { |inner_hash, raw_path|
inner_hash[raw_path] = endpoint_instrumentable_path(raw_path)
- end
- end
+ }
+ }
end
def endpoint_instrumentable_path(raw_path)
- raw_path.sub('(.:format)', '').sub('/:version', '')
+ raw_path.sub("(.:format)", "").sub("/:version", "")
end
end
end
diff --git a/lib/gitlab/middleware/basic_health_check.rb b/lib/gitlab/middleware/basic_health_check.rb
index acf8c301b8f..2594392dc3f 100644
--- a/lib/gitlab/middleware/basic_health_check.rb
+++ b/lib/gitlab/middleware/basic_health_check.rb
@@ -12,17 +12,17 @@ module Gitlab
class BasicHealthCheck
# This can't be frozen because Rails::Rack::Logger wraps the body
# rubocop:disable Style/MutableConstant
- OK_RESPONSE = [200, { 'Content-Type' => 'text/plain' }, ["GitLab OK"]]
- EMPTY_RESPONSE = [404, { 'Content-Type' => 'text/plain' }, [""]]
+ OK_RESPONSE = [200, {"Content-Type" => "text/plain"}, ["GitLab OK"]]
+ EMPTY_RESPONSE = [404, {"Content-Type" => "text/plain"}, [""]]
# rubocop:enable Style/MutableConstant
- HEALTH_PATH = '/-/health'
+ HEALTH_PATH = "/-/health"
def initialize(app)
@app = app
end
def call(env)
- return @app.call(env) unless env['PATH_INFO'] == HEALTH_PATH
+ return @app.call(env) unless env["PATH_INFO"] == HEALTH_PATH
request = ActionDispatch::Request.new(env)
diff --git a/lib/gitlab/middleware/go.rb b/lib/gitlab/middleware/go.rb
index f9efef38825..9da495a7f2d 100644
--- a/lib/gitlab/middleware/go.rb
+++ b/lib/gitlab/middleware/go.rb
@@ -31,7 +31,7 @@ module Gitlab
body = go_body(path)
return unless body
- response = Rack::Response.new(body, 200, { 'Content-Type' => 'text/html' })
+ response = Rack::Response.new(body, 200, {"Content-Type" => "text/html"})
response.finish
end
@@ -44,26 +44,26 @@ module Gitlab
project_url = Gitlab::Utils.append_path(config.gitlab.url, path)
import_prefix = strip_url(project_url.to_s)
- repository_url = if Gitlab::CurrentSettings.enabled_git_access_protocol == 'ssh'
- shell = config.gitlab_shell
- port = ":#{shell.ssh_port}" unless shell.ssh_port == 22
- "ssh://#{shell.ssh_user}@#{shell.ssh_host}#{port}/#{path}.git"
- else
- "#{project_url}.git"
- end
+ repository_url = if Gitlab::CurrentSettings.enabled_git_access_protocol == "ssh"
+ shell = config.gitlab_shell
+ port = ":#{shell.ssh_port}" unless shell.ssh_port == 22
+ "ssh://#{shell.ssh_user}@#{shell.ssh_host}#{port}/#{path}.git"
+ else
+ "#{project_url}.git"
+ end
- meta_tag = tag :meta, name: 'go-import', content: "#{import_prefix} git #{repository_url}"
+ meta_tag = tag :meta, name: "go-import", content: "#{import_prefix} git #{repository_url}"
head_tag = content_tag :head, meta_tag
content_tag :html, head_tag
end
def strip_url(url)
- url.gsub(%r{\Ahttps?://}, '')
+ url.gsub(%r{\Ahttps?://}, "")
end
def project_path(request)
path_info = request.env["PATH_INFO"]
- path_info.sub!(%r{^/}, '')
+ path_info.sub!(%r{^/}, "")
project_path_match = "#{path_info}/".match(PROJECT_PATH_REGEX)
return unless project_path_match
@@ -77,15 +77,15 @@ module Gitlab
# `path2/../pathN`, for example.
# We find all potential project paths out of the path segments
- path_segments = path.split('/')
- simple_project_path = path_segments.first(2).join('/')
+ path_segments = path.split("/")
+ simple_project_path = path_segments.first(2).join("/")
# If the path is at most 2 segments long, it is a simple `namespace/project` path and we're done
return simple_project_path if path_segments.length <= 2
project_paths = []
begin
- project_paths << path_segments.join('/')
+ project_paths << path_segments.join("/")
path_segments.pop
end while path_segments.length >= 2
diff --git a/lib/gitlab/middleware/multipart.rb b/lib/gitlab/middleware/multipart.rb
index 433151b80e7..dd7cd0713d7 100644
--- a/lib/gitlab/middleware/multipart.rb
+++ b/lib/gitlab/middleware/multipart.rb
@@ -28,12 +28,12 @@
module Gitlab
module Middleware
class Multipart
- RACK_ENV_KEY = 'HTTP_GITLAB_WORKHORSE_MULTIPART_FIELDS'.freeze
+ RACK_ENV_KEY = "HTTP_GITLAB_WORKHORSE_MULTIPART_FIELDS"
class Handler
def initialize(env, message)
@request = ActionDispatch::Request.new(env)
- @rewritten_fields = message['rewritten_fields']
+ @rewritten_fields = message["rewritten_fields"]
@open_files = []
end
@@ -72,7 +72,7 @@ module Gitlab
case path_value
when nil
- value_hash[path_key] = open_file(value_hash.dig(path_key), '')
+ value_hash[path_key] = open_file(value_hash.dig(path_key), "")
@open_files << value_hash[path_key]
value_hash
when Hash
@@ -87,7 +87,7 @@ module Gitlab
allowed_paths = [
::FileUploader.root,
Gitlab.config.uploads.storage_path,
- File.join(Rails.root, 'public/uploads/tmp')
+ File.join(Rails.root, "public/uploads/tmp"),
]
::UploadedFile.from_params(params, key, allowed_paths)
diff --git a/lib/gitlab/middleware/rails_queue_duration.rb b/lib/gitlab/middleware/rails_queue_duration.rb
index a147e165262..311bbee36f8 100644
--- a/lib/gitlab/middleware/rails_queue_duration.rb
+++ b/lib/gitlab/middleware/rails_queue_duration.rb
@@ -7,7 +7,7 @@
module Gitlab
module Middleware
class RailsQueueDuration
- GITLAB_RAILS_QUEUE_DURATION_KEY = 'GITLAB_RAILS_QUEUE_DURATION'
+ GITLAB_RAILS_QUEUE_DURATION_KEY = "GITLAB_RAILS_QUEUE_DURATION"
def initialize(app)
@app = app
@@ -15,7 +15,7 @@ module Gitlab
def call(env)
trans = Gitlab::Metrics.current_transaction
- proxy_start = env['HTTP_GITLAB_WORKHORSE_PROXY_START'].presence
+ proxy_start = env["HTTP_GITLAB_WORKHORSE_PROXY_START"].presence
if trans && proxy_start
# Time in milliseconds since gitlab-workhorse started the request
duration = Time.now.to_f * 1_000 - proxy_start.to_f / 1_000_000
diff --git a/lib/gitlab/middleware/read_only/controller.rb b/lib/gitlab/middleware/read_only/controller.rb
index 817db12ac55..53e8451bb35 100644
--- a/lib/gitlab/middleware/read_only/controller.rb
+++ b/lib/gitlab/middleware/read_only/controller.rb
@@ -4,18 +4,18 @@ module Gitlab
module Middleware
class ReadOnly
class Controller
- DISALLOWED_METHODS = %w(POST PATCH PUT DELETE).freeze
- APPLICATION_JSON = 'application/json'.freeze
- APPLICATION_JSON_TYPES = %W{#{APPLICATION_JSON} application/vnd.git-lfs+json}.freeze
- ERROR_MESSAGE = 'You cannot perform write operations on a read-only instance'.freeze
+ DISALLOWED_METHODS = %w[POST PATCH PUT DELETE].freeze
+ APPLICATION_JSON = "application/json"
+ APPLICATION_JSON_TYPES = %W[#{APPLICATION_JSON} application/vnd.git-lfs+json].freeze
+ ERROR_MESSAGE = "You cannot perform write operations on a read-only instance"
WHITELISTED_GIT_ROUTES = {
- 'projects/git_http' => %w{git_upload_pack git_receive_pack}
+ "projects/git_http" => %w[git_upload_pack git_receive_pack],
}.freeze
WHITELISTED_GIT_LFS_ROUTES = {
- 'projects/lfs_api' => %w{batch},
- 'projects/lfs_locks_api' => %w{verify create unlock}
+ "projects/lfs_api" => %w[batch],
+ "projects/lfs_locks_api" => %w[verify create unlock],
}.freeze
def initialize(app, env)
@@ -25,15 +25,15 @@ module Gitlab
def call
if disallowed_request? && Gitlab::Database.read_only?
- Rails.logger.debug('GitLab ReadOnly: preventing possible non read-only operation')
+ Rails.logger.debug("GitLab ReadOnly: preventing possible non read-only operation")
if json_request?
- return [403, { 'Content-Type' => APPLICATION_JSON }, [{ 'message' => ERROR_MESSAGE }.to_json]]
+ return [403, {"Content-Type" => APPLICATION_JSON}, [{"message" => ERROR_MESSAGE}.to_json]]
else
rack_flash.alert = ERROR_MESSAGE
- rack_session['flash'] = rack_flash.to_session_value
+ rack_session["flash"] = rack_flash.to_session_value
- return [301, { 'Location' => last_visited_url }, []]
+ return [301, {"Location" => last_visited_url}, []]
end
end
@@ -43,7 +43,7 @@ module Gitlab
private
def disallowed_request?
- DISALLOWED_METHODS.include?(@env['REQUEST_METHOD']) &&
+ DISALLOWED_METHODS.include?(@env["REQUEST_METHOD"]) &&
!whitelisted_routes
end
@@ -56,23 +56,27 @@ module Gitlab
end
def rack_session
- @env['rack.session']
+ @env["rack.session"]
end
def request
- @env['actionpack.request'] ||= ActionDispatch::Request.new(@env)
+ @env["actionpack.request"] ||= ActionDispatch::Request.new(@env)
end
def last_visited_url
- @env['HTTP_REFERER'] || rack_session['user_return_to'] || Gitlab::Routing.url_helpers.root_url
+ @env["HTTP_REFERER"] || rack_session["user_return_to"] || Gitlab::Routing.url_helpers.root_url
end
def route_hash
- @route_hash ||= Rails.application.routes.recognize_path(request.url, { method: request.request_method }) rescue {}
+ @route_hash ||= begin
+ Rails.application.routes.recognize_path(request.url, {method: request.request_method})
+ rescue
+ {}
+ end
end
def relative_url
- File.join('', Gitlab.config.gitlab.relative_url_root).chomp('/')
+ File.join("", Gitlab.config.gitlab.relative_url_root).chomp("/")
end
# Overridden in EE module
@@ -83,7 +87,7 @@ module Gitlab
def grack_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match
return false unless
- request.path.end_with?('.git/git-upload-pack', '.git/git-receive-pack')
+ request.path.end_with?(".git/git-upload-pack", ".git/git-receive-pack")
WHITELISTED_GIT_ROUTES[route_hash[:controller]]&.include?(route_hash[:action])
end
@@ -94,8 +98,8 @@ module Gitlab
def lfs_route?
# Calling route_hash may be expensive. Only do it if we think there's a possible match
- unless request.path.end_with?('/info/lfs/objects/batch',
- '/info/lfs/locks', '/info/lfs/locks/verify') ||
+ unless request.path.end_with?("/info/lfs/objects/batch",
+ "/info/lfs/locks", "/info/lfs/locks/verify") ||
%r{/info/lfs/locks/\d+/unlock\z}.match?(request.path)
return false
end
diff --git a/lib/gitlab/middleware/release_env.rb b/lib/gitlab/middleware/release_env.rb
index 849cf8f759b..7ed18314728 100644
--- a/lib/gitlab/middleware/release_env.rb
+++ b/lib/gitlab/middleware/release_env.rb
@@ -8,10 +8,10 @@ module Gitlab
# them due to this. Put this middleware as the first middleware so that
# it would clear the env after the request is done, allowing GC gets a
# chance to release memory for the last request.
- ReleaseEnv = Struct.new(:app) do
+ ReleaseEnv = Struct.new(:app) {
def call(env)
app.call(env).tap { env.clear }
end
- end
+ }
end
end
diff --git a/lib/gitlab/middleware/static.rb b/lib/gitlab/middleware/static.rb
index 972fed2134c..6b1b5a4d34e 100644
--- a/lib/gitlab/middleware/static.rb
+++ b/lib/gitlab/middleware/static.rb
@@ -6,7 +6,7 @@ module Gitlab
UPLOADS_REGEX = %r{\A/uploads(/|\z)}.freeze
def call(env)
- return @app.call(env) if env['PATH_INFO'] =~ UPLOADS_REGEX
+ return @app.call(env) if env["PATH_INFO"] =~ UPLOADS_REGEX
super
end
diff --git a/lib/gitlab/multi_collection_paginator.rb b/lib/gitlab/multi_collection_paginator.rb
index 5375077d7dc..726e398c245 100644
--- a/lib/gitlab/multi_collection_paginator.rb
+++ b/lib/gitlab/multi_collection_paginator.rb
@@ -5,7 +5,7 @@ module Gitlab
attr_reader :first_collection, :second_collection, :per_page
def initialize(*collections, per_page: nil)
- raise ArgumentError.new('Only 2 collections are supported') if collections.size != 2
+ raise ArgumentError.new("Only 2 collections are supported") if collections.size != 2
@per_page = (per_page || Kaminari.config.default_per_page).to_i
@first_collection, @second_collection = collections
@@ -23,27 +23,27 @@ module Gitlab
private
def paginated_first_collection(page)
- @first_collection_pages ||= Hash.new do |hash, page|
+ @first_collection_pages ||= Hash.new { |hash, page|
hash[page] = first_collection.page(page).per(per_page)
- end
+ }
@first_collection_pages[page]
end
def paginated_second_collection(page)
- @second_collection_pages ||= Hash.new do |hash, page|
+ @second_collection_pages ||= Hash.new { |hash, page|
second_collection_page = page - first_collection_page_count
offset = if second_collection_page < 1 || first_collection_page_count.zero?
- 0
- else
- per_page - first_collection_last_page_size
- end
+ 0
+ else
+ per_page - first_collection_last_page_size
+ end
hash[page] = second_collection.page(second_collection_page)
- .per(per_page - paginated_first_collection(page).size)
- .padding(offset)
- end
+ .per(per_page - paginated_first_collection(page).size)
+ .padding(offset)
+ }
@second_collection_pages[page]
end
@@ -60,8 +60,8 @@ module Gitlab
return @first_collection_last_page_size if defined?(@first_collection_last_page_size)
@first_collection_last_page_size = paginated_first_collection(first_collection_page_count)
- .except(:select)
- .size
+ .except(:select)
+ .size
end
# rubocop: enable CodeReuse/ActiveRecord
end
diff --git a/lib/gitlab/namespace_sanitizer.rb b/lib/gitlab/namespace_sanitizer.rb
index d755bbbcaf9..5b6d732f245 100644
--- a/lib/gitlab/namespace_sanitizer.rb
+++ b/lib/gitlab/namespace_sanitizer.rb
@@ -3,7 +3,7 @@
module Gitlab
class NamespaceSanitizer
def self.sanitize(namespace)
- namespace.gsub(/[^-a-z0-9]/, '-').gsub(/^-+/, '')
+ namespace.gsub(/[^-a-z0-9]/, "-").gsub(/^-+/, "")
end
end
end
diff --git a/lib/gitlab/object_hierarchy.rb b/lib/gitlab/object_hierarchy.rb
index f2772c733c7..f06f06455bd 100644
--- a/lib/gitlab/object_hierarchy.rb
+++ b/lib/gitlab/object_hierarchy.rb
@@ -108,7 +108,7 @@ module Gitlab
.recursive(ancestors.to_arel, descendants.to_arel)
.from_union([
model.unscoped.from(ancestors_table),
- model.unscoped.from(descendants_table)
+ model.unscoped.from(descendants_table),
])
read_only(relation)
diff --git a/lib/gitlab/omniauth_initializer.rb b/lib/gitlab/omniauth_initializer.rb
index e0ac9eec1f2..b354d516e59 100644
--- a/lib/gitlab/omniauth_initializer.rb
+++ b/lib/gitlab/omniauth_initializer.rb
@@ -8,7 +8,7 @@ module Gitlab
def execute(providers)
providers.each do |provider|
- name = provider['name'].to_sym
+ name = provider["name"].to_sym
add_provider_to_devise(name, *arguments_for(provider))
setup_provider(name)
@@ -28,12 +28,12 @@ module Gitlab
provider_arguments << provider[argument] if provider[argument]
end
- case provider['args']
+ case provider["args"]
when Array
# An Array from the configuration will be expanded.
- provider_arguments.concat provider['args']
+ provider_arguments.concat provider["args"]
when Hash
- hash_arguments = provider['args'].merge(provider_defaults(provider))
+ hash_arguments = provider["args"].merge(provider_defaults(provider))
# A Hash from the configuration will be passed as is.
provider_arguments << hash_arguments.symbolize_keys
@@ -43,13 +43,13 @@ module Gitlab
end
def provider_defaults(provider)
- case provider['name']
- when 'cas3'
- { on_single_sign_out: cas3_signout_handler }
- when 'authentiq'
- { remote_sign_out_handler: authentiq_signout_handler }
- when 'shibboleth'
- { fail_with_empty_uid: true }
+ case provider["name"]
+ when "cas3"
+ {on_single_sign_out: cas3_signout_handler}
+ when "authentiq"
+ {remote_sign_out_handler: authentiq_signout_handler}
+ when "shibboleth"
+ {fail_with_empty_uid: true}
else
{}
end
@@ -67,7 +67,7 @@ module Gitlab
def authentiq_signout_handler
lambda do |request|
- authentiq_session = request.params['sid']
+ authentiq_session = request.params["sid"]
if Gitlab::Auth::OAuth::Session.valid?(:authentiq, authentiq_session)
Gitlab::Auth::OAuth::Session.destroy(:authentiq, authentiq_session)
true
@@ -89,7 +89,7 @@ module Gitlab
def setup_provider(provider)
case provider
when :kerberos
- require 'omniauth-kerberos'
+ require "omniauth-kerberos"
when *omniauth_customized_providers
require_dependency "omni_auth/strategies/#{provider}"
end
diff --git a/lib/gitlab/optimistic_locking.rb b/lib/gitlab/optimistic_locking.rb
index ce4ba9f752b..83d14c0e460 100644
--- a/lib/gitlab/optimistic_locking.rb
+++ b/lib/gitlab/optimistic_locking.rb
@@ -16,6 +16,6 @@ module Gitlab
retry
end
- alias_method :retry_optimistic_lock, :retry_lock
+ alias retry_optimistic_lock retry_lock
end
end
diff --git a/lib/gitlab/otp_key_rotator.rb b/lib/gitlab/otp_key_rotator.rb
index 1d3200aa099..7d3aea38a09 100644
--- a/lib/gitlab/otp_key_rotator.rb
+++ b/lib/gitlab/otp_key_rotator.rb
@@ -56,7 +56,7 @@ module Gitlab
def rollback!
ActiveRecord::Base.transaction do
CSV.foreach(filename, headers: HEADERS, return_headers: false) do |row|
- User.where(id: row['user_id']).update_all(encrypted_otp_secret: row['old_value'])
+ User.where(id: row["user_id"]).update_all(encrypted_otp_secret: row["old_value"])
end
end
end
@@ -76,7 +76,7 @@ module Gitlab
iv: user[:iv].unpack("m").join,
salt: user[:salt].unpack("m").join,
algorithm: otp_secret_settings[:algorithm],
- insecure_mode: otp_secret_settings[:insecure_mode]
+ insecure_mode: otp_secret_settings[:insecure_mode],
}
decrypted = Encryptor.decrypt(original, opts.merge(key: old_key))
diff --git a/lib/gitlab/pages_client.rb b/lib/gitlab/pages_client.rb
index d74fdba2241..6345be0d829 100644
--- a/lib/gitlab/pages_client.rb
+++ b/lib/gitlab/pages_client.rb
@@ -42,10 +42,10 @@ module Gitlab
def request_kwargs(timeout)
encoded_token = Base64.strict_encode64(token.to_s)
metadata = {
- 'authorization' => "Bearer #{encoded_token}"
+ "authorization" => "Bearer #{encoded_token}",
}
- result = { metadata: metadata }
+ result = {metadata: metadata}
return result unless timeout
@@ -75,12 +75,12 @@ module Gitlab
def address
addr = config.address
- addr = addr.sub(%r{^tcp://}, '') if URI(addr).scheme == 'tcp'
+ addr = addr.sub(%r{^tcp://}, "") if URI(addr).scheme == "tcp"
addr
end
def grpc_creds
- if address.start_with?('unix:')
+ if address.start_with?("unix:")
:this_channel_is_insecure
elsif @certificate
GRPC::Core::ChannelCredentials.new(@certificate)
@@ -99,11 +99,11 @@ module Gitlab
end
def token_path
- Rails.root.join('.gitlab_pages_secret').to_s
+ Rails.root.join(".gitlab_pages_secret").to_s
end
def write_token(new_token)
- Tempfile.open(File.basename(token_path), File.dirname(token_path), encoding: 'ascii-8bit') do |f|
+ Tempfile.open(File.basename(token_path), File.dirname(token_path), encoding: "ascii-8bit") do |f|
f.write(new_token)
f.close
File.link(f.path, token_path)
diff --git a/lib/gitlab/patch/sprockets_base_file_digest_key.rb b/lib/gitlab/patch/sprockets_base_file_digest_key.rb
index 1c472638145..48ec8b19d8d 100644
--- a/lib/gitlab/patch/sprockets_base_file_digest_key.rb
+++ b/lib/gitlab/patch/sprockets_base_file_digest_key.rb
@@ -8,7 +8,7 @@ module Gitlab
module SprocketsBaseFileDigestKey
def file_digest(path)
if stat = self.stat(path)
- digest = self.stat_digest(path, stat)
+ digest = stat_digest(path, stat)
integrity_uri = self.integrity_uri(digest)
key = Sprockets::UnloadedAsset.new(path, self).file_digest_key(integrity_uri)
diff --git a/lib/gitlab/path_regex.rb b/lib/gitlab/path_regex.rb
index 3c888be0710..def61009216 100644
--- a/lib/gitlab/path_regex.rb
+++ b/lib/gitlab/path_regex.rb
@@ -125,9 +125,9 @@ module Gitlab
# allow non-regex validations, etc), `NAMESPACE_FORMAT_REGEX_JS` serves as a Javascript-compatible version of
# `NAMESPACE_FORMAT_REGEX`, with the negative lookbehind assertion removed. This means that the client-side validation
# will pass for usernames ending in `.atom` and `.git`, but will be caught by the server-side validation.
- PATH_START_CHAR = '[a-zA-Z0-9_\.]'.freeze
- PATH_REGEX_STR = PATH_START_CHAR + '[a-zA-Z0-9_\-\.]*'.freeze
- NAMESPACE_FORMAT_REGEX_JS = PATH_REGEX_STR + '[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'.freeze
+ PATH_START_CHAR = '[a-zA-Z0-9_\.]'
+ PATH_REGEX_STR = PATH_START_CHAR + '[a-zA-Z0-9_\-\.]*'
+ NAMESPACE_FORMAT_REGEX_JS = PATH_REGEX_STR + '[a-zA-Z0-9_\-]|[a-zA-Z0-9_]'
NO_SUFFIX_REGEX = /(?<!\.git|\.atom)/.freeze
NAMESPACE_FORMAT_REGEX = /(?:#{NAMESPACE_FORMAT_REGEX_JS})#{NO_SUFFIX_REGEX}/.freeze
@@ -238,7 +238,7 @@ module Gitlab
def single_line_regexp(regex)
# Turns a multiline extended regexp into a single line one,
# because `rake routes` breaks on multiline regexes.
- Regexp.new(regex.source.gsub(/\(\?#.+?\)/, '').gsub(/\s*/, ''), regex.options ^ Regexp::EXTENDED).freeze
+ Regexp.new(regex.source.gsub(/\(\?#.+?\)/, "").gsub(/\s*/, ""), regex.options ^ Regexp::EXTENDED).freeze
end
end
end
diff --git a/lib/gitlab/performance_bar.rb b/lib/gitlab/performance_bar.rb
index 4b0c7b5c7f8..8ae4420333e 100644
--- a/lib/gitlab/performance_bar.rb
+++ b/lib/gitlab/performance_bar.rb
@@ -2,7 +2,7 @@
module Gitlab
module PerformanceBar
- ALLOWED_USER_IDS_KEY = 'performance_bar_allowed_user_ids:v2'.freeze
+ ALLOWED_USER_IDS_KEY = "performance_bar_allowed_user_ids:v2"
EXPIRY_TIME = 5.minutes
def self.enabled?(user = nil)
diff --git a/lib/gitlab/performance_bar/peek_query_tracker.rb b/lib/gitlab/performance_bar/peek_query_tracker.rb
index ac392432427..42d7616d88b 100644
--- a/lib/gitlab/performance_bar/peek_query_tracker.rb
+++ b/lib/gitlab/performance_bar/peek_query_tracker.rb
@@ -24,13 +24,13 @@ module Gitlab
PEEK_DB_CLIENT.query_details = []
end
- subscribe('sql.active_record') do |_, start, finish, _, data|
+ subscribe("sql.active_record") do |_, start, finish, _, data|
if Gitlab::SafeRequestStore.store[:peek_enabled]
# data[:cached] is only available starting from Rails 5.1.0
# https://github.com/rails/rails/blob/v5.1.0/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L113
# Before that, data[:name] was set to 'CACHE'
# https://github.com/rails/rails/blob/v4.2.9/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb#L80
- unless data.fetch(:cached, data[:name] == 'CACHE')
+ unless data.fetch(:cached, data[:name] == "CACHE")
track_query(data[:sql].strip, data[:binds], start, finish)
end
end
@@ -39,7 +39,7 @@ module Gitlab
def track_query(raw_query, bindings, start, finish)
duration = (finish - start) * 1000.0
- query_info = { duration: duration.round(3), sql: raw_query }
+ query_info = {duration: duration.round(3), sql: raw_query}
PEEK_DB_CLIENT.query_details << query_info
end
diff --git a/lib/gitlab/plugin.rb b/lib/gitlab/plugin.rb
index 23353f36025..68620376cff 100644
--- a/lib/gitlab/plugin.rb
+++ b/lib/gitlab/plugin.rb
@@ -3,7 +3,7 @@
module Gitlab
module Plugin
def self.files
- Dir.glob(Rails.root.join('plugins/*')).select do |entry|
+ Dir.glob(Rails.root.join("plugins/*")).select do |entry|
File.file?(entry)
end
end
@@ -15,9 +15,9 @@ module Gitlab
end
def self.execute(file, data)
- result = Gitlab::Popen.popen_with_detail([file]) do |stdin|
+ result = Gitlab::Popen.popen_with_detail([file]) { |stdin|
stdin.write(data.to_json)
- end
+ }
exit_status = result.status&.exitstatus
[exit_status.zero?, result.stderr]
diff --git a/lib/gitlab/plugin_logger.rb b/lib/gitlab/plugin_logger.rb
index df3bd56fd2f..8f85bf0d9bb 100644
--- a/lib/gitlab/plugin_logger.rb
+++ b/lib/gitlab/plugin_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class PluginLogger < Gitlab::Logger
def self.file_name_noext
- 'plugin'
+ "plugin"
end
end
end
diff --git a/lib/gitlab/polling_interval.rb b/lib/gitlab/polling_interval.rb
index 0f69990df63..3db3a04d881 100644
--- a/lib/gitlab/polling_interval.rb
+++ b/lib/gitlab/polling_interval.rb
@@ -2,7 +2,7 @@
module Gitlab
class PollingInterval
- HEADER_NAME = 'Poll-Interval'.freeze
+ HEADER_NAME = "Poll-Interval"
def self.set_header(response, interval:)
if polling_enabled?
diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb
index 7fa00d0c68c..a7d39986ac4 100644
--- a/lib/gitlab/popen.rb
+++ b/lib/gitlab/popen.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'fileutils'
-require 'open3'
+require "fileutils"
+require "open3"
module Gitlab
module Popen
@@ -23,15 +23,15 @@ module Gitlab
end
path ||= Dir.pwd
- vars['PWD'] = path
- options = { chdir: path }
+ vars["PWD"] = path
+ options = {chdir: path}
unless File.directory?(path)
FileUtils.mkdir_p(path)
end
- cmd_stdout = ''
- cmd_stderr = ''
+ cmd_stdout = ""
+ cmd_stderr = ""
cmd_status = nil
start = Time.now
diff --git a/lib/gitlab/private_commit_email.rb b/lib/gitlab/private_commit_email.rb
index 536fc9dae3a..886c2c32d36 100644
--- a/lib/gitlab/private_commit_email.rb
+++ b/lib/gitlab/private_commit_email.rb
@@ -2,7 +2,7 @@
module Gitlab
module PrivateCommitEmail
- TOKEN = "_private".freeze
+ TOKEN = "_private"
class << self
def regex
diff --git a/lib/gitlab/profiler.rb b/lib/gitlab/profiler.rb
index 93a9fcf1591..dc6b7ee989e 100644
--- a/lib/gitlab/profiler.rb
+++ b/lib/gitlab/profiler.rb
@@ -1,9 +1,8 @@
-# coding: utf-8
# frozen_string_literal: true
module Gitlab
module Profiler
- FILTERED_STRING = '[FILTERED]'.freeze
+ FILTERED_STRING = "[FILTERED]"
IGNORE_BACKTRACES = %w[
lib/gitlab/i18n.rb
@@ -43,11 +42,11 @@ module Gitlab
if post_data
verb = :post
- headers['Content-Type'] = 'application/json'
+ headers["Content-Type"] = "application/json"
end
if private_token
- headers['Private-Token'] = private_token
+ headers["Private-Token"] = private_token
user = nil # private_token overrides user
end
@@ -57,21 +56,21 @@ module Gitlab
# Make an initial call for an asset path in development mode to avoid
# sprockets dominating the profiler output.
- ActionController::Base.helpers.asset_path('katex.css') if Rails.env.development?
+ ActionController::Base.helpers.asset_path("katex.css") if Rails.env.development?
# Rails loads internationalization files lazily the first time a
# translation is needed. Running this prevents this overhead from showing
# up in profiles.
- ::I18n.t('.')[:test_string]
+ ::I18n.t(".")[:test_string]
# Remove API route mounting from the profile.
- app.get('/api/v4/users')
+ app.get("/api/v4/users")
- result = with_custom_logger(logger) do
+ result = with_custom_logger(logger) {
with_user(user) do
RubyProf.profile { app.public_send(verb, url, post_data, headers) } # rubocop:disable GitlabSecurity/PublicSend
end
- end
+ }
RequestStore.end!
@@ -103,7 +102,7 @@ module Gitlab
super
Gitlab::Profiler.clean_backtrace(caller).each do |caller_line|
- stripped_caller_line = caller_line.sub("#{Rails.root}/", '')
+ stripped_caller_line = caller_line.sub("#{Rails.root}/", "")
super(" ↳ #{stripped_caller_line}")
end
@@ -158,18 +157,18 @@ module Gitlab
def self.log_load_times_by_model(logger)
return unless logger.respond_to?(:load_times_by_model)
- summarised_load_times = logger.load_times_by_model.to_a.map do |(model, times)|
+ summarised_load_times = logger.load_times_by_model.to_a.map { |(model, times)|
[model, times.count, times.sum]
- end
+ }
- summarised_load_times.sort_by(&:last).reverse.each do |(model, query_count, time)|
+ summarised_load_times.sort_by(&:last).reverse_each do |(model, query_count, time)|
logger.info("#{model} total (#{query_count}): #{time.round(2)}ms")
end
end
# rubocop: enable CodeReuse/ActiveRecord
def self.print_by_total_time(result, options = {})
- default_options = { sort_method: :total_time }
+ default_options = {sort_method: :total_time}
Gitlab::Profiler::TotalTimeFlatPrinter.new(result).print(STDOUT, default_options.merge(options))
end
diff --git a/lib/gitlab/profiler/total_time_flat_printer.rb b/lib/gitlab/profiler/total_time_flat_printer.rb
index 2c105d2722b..123a89d2880 100644
--- a/lib/gitlab/profiler/total_time_flat_printer.rb
+++ b/lib/gitlab/profiler/total_time_flat_printer.rb
@@ -32,7 +32,7 @@ module Gitlab
method.children_time, # children
method.called, # calls
method.recursive? ? "*" : " ", # cycle
- method_name(method) # name
+ method_name(method), # name
]
end
end
diff --git a/lib/gitlab/project_authorizations/with_nested_groups.rb b/lib/gitlab/project_authorizations/with_nested_groups.rb
index 2372a316ab0..07ef664596e 100644
--- a/lib/gitlab/project_authorizations/with_nested_groups.rb
+++ b/lib/gitlab/project_authorizations/with_nested_groups.rb
@@ -32,8 +32,8 @@ module Gitlab
# access to.
Namespace
.unscoped
- .select([alias_as_column(projects[:id], 'project_id'),
- cte_alias[:access_level]])
+ .select([alias_as_column(projects[:id], "project_id"),
+ cte_alias[:access_level],])
.from(cte_alias)
.joins(:projects),
@@ -42,13 +42,13 @@ module Gitlab
.unscoped
.select([links[:project_id],
least(cte_alias[:access_level],
- links[:group_access],
- 'access_level')])
+ links[:group_access],
+ "access_level"),])
.from(cte_alias)
- .joins('INNER JOIN project_group_links ON project_group_links.group_id = namespaces.id')
- .joins('INNER JOIN projects ON projects.id = project_group_links.project_id')
- .joins('INNER JOIN namespaces p_ns ON p_ns.id = projects.namespace_id')
- .where('p_ns.share_with_group_lock IS FALSE')
+ .joins("INNER JOIN project_group_links ON project_group_links.group_id = namespaces.id")
+ .joins("INNER JOIN projects ON projects.id = project_group_links.project_id")
+ .joins("INNER JOIN namespaces p_ns ON p_ns.id = projects.namespace_id")
+ .where("p_ns.share_with_group_lock IS FALSE"),
]
ProjectAuthorization
@@ -75,7 +75,7 @@ module Gitlab
# Sub groups of any groups the user is a member of.
cte << Group.select([namespaces[:id],
greatest(members[:access_level],
- cte.table[:access_level], 'access_level')])
+ cte.table[:access_level], "access_level"),])
.joins(join_cte(cte))
.joins(join_members)
.except(:order)
@@ -90,7 +90,7 @@ module Gitlab
cond = members[:source_id]
.eq(namespaces[:id])
- .and(members[:source_type].eq('Namespace'))
+ .and(members[:source_type].eq("Namespace"))
.and(members[:requested_at].eq(nil))
.and(members[:user_id].eq(user.id))
@@ -106,11 +106,11 @@ module Gitlab
end
def greatest(left, right, column_alias)
- sql_function('GREATEST', [left, right], column_alias)
+ sql_function("GREATEST", [left, right], column_alias)
end
def least(left, right, column_alias)
- sql_function('LEAST', [left, right], column_alias)
+ sql_function("LEAST", [left, right], column_alias)
end
def sql_function(name, args, column_alias)
diff --git a/lib/gitlab/project_authorizations/without_nested_groups.rb b/lib/gitlab/project_authorizations/without_nested_groups.rb
index 50b41b17649..f5daa209ba4 100644
--- a/lib/gitlab/project_authorizations/without_nested_groups.rb
+++ b/lib/gitlab/project_authorizations/without_nested_groups.rb
@@ -23,7 +23,7 @@ module Gitlab
user.groups_projects.select_for_project_authorization,
# Projects shared with groups the user is a member of
- user.groups.joins(:shared_projects).select_for_project_authorization
+ user.groups.joins(:shared_projects).select_for_project_authorization,
]
ProjectAuthorization
diff --git a/lib/gitlab/project_search_results.rb b/lib/gitlab/project_search_results.rb
index a68f8801c2a..d43cf442ada 100644
--- a/lib/gitlab/project_search_results.rb
+++ b/lib/gitlab/project_search_results.rb
@@ -14,13 +14,13 @@ module Gitlab
def objects(scope, page = nil)
case scope
- when 'notes'
+ when "notes"
notes.page(page).per(per_page)
- when 'blobs'
+ when "blobs"
paginated_blobs(blobs, page)
- when 'wiki_blobs'
+ when "wiki_blobs"
paginated_blobs(wiki_blobs, page)
- when 'commits'
+ when "commits"
Kaminari.paginate_array(commits).page(page).per(per_page)
else
super(scope, page, false)
@@ -35,7 +35,7 @@ module Gitlab
def limited_notes_count
return @limited_notes_count if defined?(@limited_notes_count)
- types = %w(issue merge_request commit snippet)
+ types = %w[issue merge_request commit snippet]
@limited_notes_count = 0
types.each do |type|
@@ -58,9 +58,9 @@ module Gitlab
def single_commit_result?
return false if commits_count != 1
- counts = %i(limited_milestones_count limited_notes_count
+ counts = %i[limited_milestones_count limited_notes_count
limited_merge_requests_count limited_issues_count
- blobs_count wiki_blobs_count)
+ blobs_count wiki_blobs_count]
counts.all? { |count_method| public_send(count_method).zero? } # rubocop:disable GitlabSecurity/PublicSend
end
@@ -85,10 +85,10 @@ module Gitlab
@wiki_blobs ||= begin
if project.wiki_enabled? && query.present?
- unless project.wiki.empty?
- Gitlab::WikiFileFinder.new(project, repository_wiki_ref).find(query)
- else
+ if project.wiki.empty?
[]
+ else
+ Gitlab::WikiFileFinder.new(project, repository_wiki_ref).find(query)
end
else
[]
@@ -102,7 +102,7 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def notes_finder(type)
- NotesFinder.new(project, @current_user, search: query, target_type: type).execute.user.order('updated_at DESC')
+ NotesFinder.new(project, @current_user, search: query, target_type: type).execute.user.order("updated_at DESC")
end
# rubocop: enable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/project_service_logger.rb b/lib/gitlab/project_service_logger.rb
index 9b0357d3161..1b75e1d04e6 100644
--- a/lib/gitlab/project_service_logger.rb
+++ b/lib/gitlab/project_service_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class ProjectServiceLogger < Gitlab::JsonLogger
def self.file_name_noext
- 'integrations_json'
+ "integrations_json"
end
end
end
diff --git a/lib/gitlab/project_template.rb b/lib/gitlab/project_template.rb
index 9b6ff602fcd..1eaac9c3a40 100644
--- a/lib/gitlab/project_template.rb
+++ b/lib/gitlab/project_template.rb
@@ -4,7 +4,7 @@ module Gitlab
class ProjectTemplate
attr_reader :title, :name, :description, :preview, :logo
- def initialize(name, title, description, preview, logo = 'illustrations/gitlab_logo.svg')
+ def initialize(name, title, description, preview, logo = "illustrations/gitlab_logo.svg")
@name, @title, @description, @preview, @logo = name, title, description, preview, logo
end
@@ -25,21 +25,21 @@ module Gitlab
end
TEMPLATES_TABLE = [
- ProjectTemplate.new('rails', 'Ruby on Rails', _('Includes an MVC structure, Gemfile, Rakefile, along with many others, to help you get started.'), 'https://gitlab.com/gitlab-org/project-templates/rails', 'illustrations/logos/rails.svg'),
- ProjectTemplate.new('spring', 'Spring', _('Includes an MVC structure, mvnw and pom.xml to help you get started.'), 'https://gitlab.com/gitlab-org/project-templates/spring', 'illustrations/logos/spring.svg'),
- ProjectTemplate.new('express', 'NodeJS Express', _('Includes an MVC structure to help you get started.'), 'https://gitlab.com/gitlab-org/project-templates/express', 'illustrations/logos/express.svg'),
- ProjectTemplate.new('dotnetcore', '.NET Core', _('A .NET Core console application template, customizable for any .NET Core project'), 'https://gitlab.com/gitlab-org/project-templates/dotnetcore', 'illustrations/logos/dotnet.svg'),
- ProjectTemplate.new('gomicro', 'Go Micro', _('Go Micro is a framework for micro service development.'), 'https://gitlab.com/gitlab-org/project-templates/go-micro'),
- ProjectTemplate.new('hugo', 'Pages/Hugo', _('Everything you need to create a GitLab Pages site using Hugo.'), 'https://gitlab.com/pages/hugo'),
- ProjectTemplate.new('jekyll', 'Pages/Jekyll', _('Everything you need to create a GitLab Pages site using Jekyll.'), 'https://gitlab.com/pages/jekyll'),
- ProjectTemplate.new('plainhtml', 'Pages/Plain HTML', _('Everything you need to create a GitLab Pages site using plain HTML.'), 'https://gitlab.com/pages/plain-html'),
- ProjectTemplate.new('gitbook', 'Pages/GitBook', _('Everything you need to create a GitLab Pages site using GitBook.'), 'https://gitlab.com/pages/gitbook'),
- ProjectTemplate.new('hexo', 'Pages/Hexo', _('Everything you need to create a GitLab Pages site using Hexo.'), 'https://gitlab.com/pages/hexo'),
- ProjectTemplate.new('nfhugo', 'Netlify/Hugo', _('A Hugo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfhugo', 'illustrations/logos/netlify.svg'),
- ProjectTemplate.new('nfjekyll', 'Netlify/Jekyll', _('A Jekyll site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfjekyll', 'illustrations/logos/netlify.svg'),
- ProjectTemplate.new('nfplainhtml', 'Netlify/Plain HTML', _('A plain HTML site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfplain-html', 'illustrations/logos/netlify.svg'),
- ProjectTemplate.new('nfgitbook', 'Netlify/GitBook', _('A GitBook site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfgitbook', 'illustrations/logos/netlify.svg'),
- ProjectTemplate.new('nfhexo', 'Netlify/Hexo', _('A Hexo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfhexo', 'illustrations/logos/netlify.svg')
+ ProjectTemplate.new("rails", "Ruby on Rails", _("Includes an MVC structure, Gemfile, Rakefile, along with many others, to help you get started."), "https://gitlab.com/gitlab-org/project-templates/rails", "illustrations/logos/rails.svg"),
+ ProjectTemplate.new("spring", "Spring", _("Includes an MVC structure, mvnw and pom.xml to help you get started."), "https://gitlab.com/gitlab-org/project-templates/spring", "illustrations/logos/spring.svg"),
+ ProjectTemplate.new("express", "NodeJS Express", _("Includes an MVC structure to help you get started."), "https://gitlab.com/gitlab-org/project-templates/express", "illustrations/logos/express.svg"),
+ ProjectTemplate.new("dotnetcore", ".NET Core", _("A .NET Core console application template, customizable for any .NET Core project"), "https://gitlab.com/gitlab-org/project-templates/dotnetcore", "illustrations/logos/dotnet.svg"),
+ ProjectTemplate.new("gomicro", "Go Micro", _("Go Micro is a framework for micro service development."), "https://gitlab.com/gitlab-org/project-templates/go-micro"),
+ ProjectTemplate.new("hugo", "Pages/Hugo", _("Everything you need to create a GitLab Pages site using Hugo."), "https://gitlab.com/pages/hugo"),
+ ProjectTemplate.new("jekyll", "Pages/Jekyll", _("Everything you need to create a GitLab Pages site using Jekyll."), "https://gitlab.com/pages/jekyll"),
+ ProjectTemplate.new("plainhtml", "Pages/Plain HTML", _("Everything you need to create a GitLab Pages site using plain HTML."), "https://gitlab.com/pages/plain-html"),
+ ProjectTemplate.new("gitbook", "Pages/GitBook", _("Everything you need to create a GitLab Pages site using GitBook."), "https://gitlab.com/pages/gitbook"),
+ ProjectTemplate.new("hexo", "Pages/Hexo", _("Everything you need to create a GitLab Pages site using Hexo."), "https://gitlab.com/pages/hexo"),
+ ProjectTemplate.new("nfhugo", "Netlify/Hugo", _("A Hugo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfhugo", "illustrations/logos/netlify.svg"),
+ ProjectTemplate.new("nfjekyll", "Netlify/Jekyll", _("A Jekyll site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfjekyll", "illustrations/logos/netlify.svg"),
+ ProjectTemplate.new("nfplainhtml", "Netlify/Plain HTML", _("A plain HTML site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfplain-html", "illustrations/logos/netlify.svg"),
+ ProjectTemplate.new("nfgitbook", "Netlify/GitBook", _("A GitBook site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfgitbook", "illustrations/logos/netlify.svg"),
+ ProjectTemplate.new("nfhexo", "Netlify/Hexo", _("A Hexo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfhexo", "illustrations/logos/netlify.svg"),
].freeze
class << self
diff --git a/lib/gitlab/project_transfer.rb b/lib/gitlab/project_transfer.rb
index d8f1d1e2316..171da51f270 100644
--- a/lib/gitlab/project_transfer.rb
+++ b/lib/gitlab/project_transfer.rb
@@ -5,8 +5,8 @@ module Gitlab
class ProjectTransfer
# nil parent_path (or parent_path_was) represents a root namespace
def move_namespace(path, parent_path_was, parent_path)
- parent_path_was ||= ''
- parent_path ||= ''
+ parent_path_was ||= ""
+ parent_path ||= ""
new_parent_folder = File.join(root_dir, parent_path)
FileUtils.mkdir_p(new_parent_folder)
from = File.join(root_dir, parent_path_was, path)
@@ -14,7 +14,7 @@ module Gitlab
move(from, to, "")
end
- alias_method :move_project, :move_namespace
+ alias move_project move_namespace
def rename_project(path_was, path, namespace_path)
base_dir = File.join(root_dir, namespace_path)
@@ -32,7 +32,7 @@ module Gitlab
private
def move(path_was, path, base_dir = nil)
- base_dir = root_dir unless base_dir
+ base_dir ||= root_dir
from = File.join(base_dir, path_was)
to = File.join(base_dir, path)
FileUtils.mv(from, to)
diff --git a/lib/gitlab/prometheus/additional_metrics_parser.rb b/lib/gitlab/prometheus/additional_metrics_parser.rb
index bd4ca578840..3a3f3629861 100644
--- a/lib/gitlab/prometheus/additional_metrics_parser.rb
+++ b/lib/gitlab/prometheus/additional_metrics_parser.rb
@@ -3,7 +3,7 @@
module Gitlab
module Prometheus
module AdditionalMetricsParser
- CONFIG_ROOT = 'config/prometheus'.freeze
+ CONFIG_ROOT = "config/prometheus"
MUTEX = Mutex.new
extend self
diff --git a/lib/gitlab/prometheus/metric.rb b/lib/gitlab/prometheus/metric.rb
index 7ebfc2e25a9..2ef4c3f6b39 100644
--- a/lib/gitlab/prometheus/metric.rb
+++ b/lib/gitlab/prometheus/metric.rb
@@ -11,7 +11,7 @@ module Gitlab
def initialize(params = {})
super(params)
- @y_label ||= 'Values'
+ @y_label ||= "Values"
end
end
end
diff --git a/lib/gitlab/prometheus/metric_group.rb b/lib/gitlab/prometheus/metric_group.rb
index 394556e8708..2912bab54f7 100644
--- a/lib/gitlab/prometheus/metric_group.rb
+++ b/lib/gitlab/prometheus/metric_group.rb
@@ -10,13 +10,13 @@ module Gitlab
validates :name, :priority, :metrics, presence: true
def self.common_metrics
- all_groups = ::PrometheusMetric.common.group_by(&:group_title).map do |name, metrics|
+ all_groups = ::PrometheusMetric.common.group_by(&:group_title).map { |name, metrics|
MetricGroup.new(
name: name,
priority: metrics.map(&:priority).max,
metrics: metrics.map(&:to_query_metric)
)
- end
+ }
all_groups.sort_by(&:priority).reverse
end
diff --git a/lib/gitlab/prometheus/queries/deployment_query.rb b/lib/gitlab/prometheus/queries/deployment_query.rb
index fc32c4353f0..4559f23508c 100644
--- a/lib/gitlab/prometheus/queries/deployment_query.rb
+++ b/lib/gitlab/prometheus/queries/deployment_query.rb
@@ -24,7 +24,7 @@ module Gitlab
cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end),
cpu_before: client_query(cpu_avg_query, time: deployment.created_at.to_f),
- cpu_after: client_query(cpu_avg_query, time: timeframe_end)
+ cpu_after: client_query(cpu_avg_query, time: timeframe_end),
}
end
end
diff --git a/lib/gitlab/prometheus/queries/environment_query.rb b/lib/gitlab/prometheus/queries/environment_query.rb
index 56195f85a70..fd284246397 100644
--- a/lib/gitlab/prometheus/queries/environment_query.rb
+++ b/lib/gitlab/prometheus/queries/environment_query.rb
@@ -18,7 +18,7 @@ module Gitlab
memory_values: client_query_range(memory_query, start: timeframe_start, stop: timeframe_end),
memory_current: client_query(memory_query, time: timeframe_end),
cpu_values: client_query_range(cpu_query, start: timeframe_start, stop: timeframe_end),
- cpu_current: client_query(cpu_query, time: timeframe_end)
+ cpu_current: client_query(cpu_query, time: timeframe_end),
}
end
end
diff --git a/lib/gitlab/prometheus/queries/matched_metric_query.rb b/lib/gitlab/prometheus/queries/matched_metric_query.rb
index 32294756aa2..b640a045768 100644
--- a/lib/gitlab/prometheus/queries/matched_metric_query.rb
+++ b/lib/gitlab/prometheus/queries/matched_metric_query.rb
@@ -4,7 +4,7 @@ module Gitlab
module Prometheus
module Queries
class MatchedMetricQuery < BaseQuery
- MAX_QUERY_ITEMS = 40.freeze
+ MAX_QUERY_ITEMS = 40
def query
groups_data.map do |group, data|
@@ -12,7 +12,7 @@ module Gitlab
group: group.name,
priority: group.priority,
active_metrics: data[:active_metrics],
- metrics_missing_requirements: data[:metrics_missing_requirements]
+ metrics_missing_requirements: data[:metrics_missing_requirements],
}
end
end
@@ -26,7 +26,7 @@ module Gitlab
groups = {}
metrics_groups.each do |group|
- groups[group] ||= { active_metrics: 0, metrics_missing_requirements: 0 }
+ groups[group] ||= {active_metrics: 0, metrics_missing_requirements: 0}
active_metrics = group.metrics.count { |metric| metric.required_metrics.all?(&lookup.method(:has_key?)) }
groups[group][:active_metrics] += active_metrics
@@ -42,16 +42,16 @@ module Gitlab
series = metric_groups.flat_map(&:metrics).flat_map(&:required_metrics).uniq
- lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map do |batched_series|
+ lookup = series.each_slice(MAX_QUERY_ITEMS).flat_map { |batched_series|
client_series(*batched_series, start: timeframe_start, stop: timeframe_end)
.select(&method(:has_matching_label?))
- .map { |series_info| [series_info['__name__'], true] }
- end
+ .map { |series_info| [series_info["__name__"], true] }
+ }
lookup.to_h
end
def has_matching_label?(series_info)
- series_info.key?('environment')
+ series_info.key?("environment")
end
def available_metrics
diff --git a/lib/gitlab/prometheus/queries/query_additional_metrics.rb b/lib/gitlab/prometheus/queries/query_additional_metrics.rb
index 960d3536ec0..c10438cfe16 100644
--- a/lib/gitlab/prometheus/queries/query_additional_metrics.rb
+++ b/lib/gitlab/prometheus/queries/query_additional_metrics.rb
@@ -15,23 +15,23 @@ module Gitlab
query_processor = method(:process_query).curry[query_context]
lambda do |group|
- metrics = group.metrics.map do |metric|
+ metrics = group.metrics.map { |metric|
metric_hsh = {
title: metric.title,
weight: metric.weight,
y_label: metric.y_label,
- queries: metric.queries.map(&query_processor).select(&method(:query_with_result))
+ queries: metric.queries.map(&query_processor).select(&method(:query_with_result)),
}
metric_hsh[:id] = metric.id if metric.id
metric_hsh
- end
+ }
{
group: group.name,
priority: group.priority,
- metrics: metrics.select(&method(:metric_with_any_queries))
+ metrics: metrics.select(&method(:metric_with_any_queries)),
}
end
end
@@ -72,12 +72,12 @@ module Gitlab
end
def matched_metrics(project)
- result = Gitlab::Prometheus::MetricGroup.for_project(project).map do |group|
+ result = Gitlab::Prometheus::MetricGroup.for_project(project).map { |group|
group.metrics.select! do |metric|
metric.required_metrics.all?(&available_metrics.method(:include?))
end
group
- end
+ }
result.select { |group| group.metrics.any? }
end
@@ -90,7 +90,7 @@ module Gitlab
def base_query_context(timeframe_start, timeframe_end)
{
timeframe_start: timeframe_start,
- timeframe_end: timeframe_end
+ timeframe_end: timeframe_end,
}
end
end
diff --git a/lib/gitlab/prometheus/query_variables.rb b/lib/gitlab/prometheus/query_variables.rb
index 1cc85d4b4a6..ef02c830dac 100644
--- a/lib/gitlab/prometheus/query_variables.rb
+++ b/lib/gitlab/prometheus/query_variables.rb
@@ -6,8 +6,8 @@ module Gitlab
def self.call(environment)
{
ci_environment_slug: environment.slug,
- kube_namespace: environment.deployment_platform&.actual_namespace || '',
- environment_filter: %{container_name!="POD",environment="#{environment.slug}"}
+ kube_namespace: environment.deployment_platform&.actual_namespace || "",
+ environment_filter: %(container_name!="POD",environment="#{environment.slug}"),
}
end
end
diff --git a/lib/gitlab/prometheus_client.rb b/lib/gitlab/prometheus_client.rb
index 45828c77a33..a7bcc04fa12 100644
--- a/lib/gitlab/prometheus_client.rb
+++ b/lib/gitlab/prometheus_client.rb
@@ -13,42 +13,42 @@ module Gitlab
end
def ping
- json_api_get('query', query: '1')
+ json_api_get("query", query: "1")
end
def query(query, time: Time.now)
- get_result('vector') do
- json_api_get('query', query: query, time: time.to_f)
+ get_result("vector") do
+ json_api_get("query", query: query, time: time.to_f)
end
end
def query_range(query, start: 8.hours.ago, stop: Time.now)
- get_result('matrix') do
- json_api_get('query_range',
- query: query,
- start: start.to_f,
- end: stop.to_f,
- step: 1.minute.to_i)
+ get_result("matrix") do
+ json_api_get("query_range",
+ query: query,
+ start: start.to_f,
+ end: stop.to_f,
+ step: 1.minute.to_i)
end
end
- def label_values(name = '__name__')
+ def label_values(name = "__name__")
json_api_get("label/#{name}/values")
end
def series(*matches, start: 8.hours.ago, stop: Time.now)
- json_api_get('series', 'match': matches, start: start.to_f, end: stop.to_f)
+ json_api_get("series", 'match': matches, start: start.to_f, end: stop.to_f)
end
private
def json_api_get(type, args = {})
- path = ['api', 'v1', type].join('/')
+ path = ["api", "v1", type].join("/")
get(path, args)
rescue JSON::ParserError
- raise PrometheusClient::Error, 'Parsing response failed'
+ raise PrometheusClient::Error, "Parsing response failed"
rescue Errno::ECONNREFUSED
- raise PrometheusClient::Error, 'Connection refused'
+ raise PrometheusClient::Error, "Connection refused"
end
def get(path, args)
@@ -70,19 +70,19 @@ module Gitlab
def handle_response(response)
json_data = JSON.parse(response.body)
- if response.code == 200 && json_data['status'] == 'success'
- json_data['data'] || {}
+ if response.code == 200 && json_data["status"] == "success"
+ json_data["data"] || {}
else
raise PrometheusClient::Error, "#{response.code} - #{response.body}"
end
end
def handle_exception_response(response)
- if response.code == 200 && response['status'] == 'success'
- response['data'] || {}
+ if response.code == 200 && response["status"] == "success"
+ response["data"] || {}
elsif response.code == 400
json_data = JSON.parse(response.body)
- raise PrometheusClient::QueryError, json_data['error'] || 'Bad data received'
+ raise PrometheusClient::QueryError, json_data["error"] || "Bad data received"
else
raise PrometheusClient::Error, "#{response.code} - #{response.body}"
end
@@ -90,7 +90,7 @@ module Gitlab
def get_result(expected_type)
data = yield
- data['result'] if data['resultType'] == expected_type
+ data["result"] if data["resultType"] == expected_type
end
end
end
diff --git a/lib/gitlab/protocol_access.rb b/lib/gitlab/protocol_access.rb
index efeb1e07d49..c5889f8c4a7 100644
--- a/lib/gitlab/protocol_access.rb
+++ b/lib/gitlab/protocol_access.rb
@@ -3,7 +3,7 @@
module Gitlab
module ProtocolAccess
def self.allowed?(protocol)
- if protocol == 'web'
+ if protocol == "web"
true
elsif Gitlab::CurrentSettings.enabled_git_access_protocol.blank?
true
diff --git a/lib/gitlab/query_limiting.rb b/lib/gitlab/query_limiting.rb
index 31e6b120e45..72d2cde1c09 100644
--- a/lib/gitlab/query_limiting.rb
+++ b/lib/gitlab/query_limiting.rb
@@ -21,10 +21,10 @@ module Gitlab
def self.whitelist(issue_url)
return unless enable_whitelist?
- unless issue_url.start_with?('https://')
+ unless issue_url.start_with?("https://")
raise(
ArgumentError,
- 'You must provide a valid issue URL in order to whitelist a block of code'
+ "You must provide a valid issue URL in order to whitelist a block of code"
)
end
diff --git a/lib/gitlab/query_limiting/active_support_subscriber.rb b/lib/gitlab/query_limiting/active_support_subscriber.rb
index 065862174bb..3e9614da57b 100644
--- a/lib/gitlab/query_limiting/active_support_subscriber.rb
+++ b/lib/gitlab/query_limiting/active_support_subscriber.rb
@@ -6,7 +6,7 @@ module Gitlab
attach_to :active_record
def sql(event)
- unless event.payload.fetch(:cached, event.payload[:name] == 'CACHE')
+ unless event.payload.fetch(:cached, event.payload[:name] == "CACHE")
Transaction.current&.increment
end
end
diff --git a/lib/gitlab/query_limiting/middleware.rb b/lib/gitlab/query_limiting/middleware.rb
index 949ae79a047..65810b0a7cf 100644
--- a/lib/gitlab/query_limiting/middleware.rb
+++ b/lib/gitlab/query_limiting/middleware.rb
@@ -5,17 +5,17 @@ module Gitlab
# Middleware for reporting (or raising) when a request performs more than a
# certain amount of database queries.
class Middleware
- CONTROLLER_KEY = 'action_controller.instance'.freeze
- ENDPOINT_KEY = 'api.endpoint'.freeze
+ CONTROLLER_KEY = "action_controller.instance"
+ ENDPOINT_KEY = "api.endpoint"
def initialize(app)
@app = app
end
def call(env)
- transaction, retval = Transaction.run do
+ transaction, retval = Transaction.run {
@app.call(env)
- end
+ }
transaction.action = action_name(env)
transaction.act_upon_results
@@ -37,7 +37,7 @@ module Gitlab
controller = env[CONTROLLER_KEY]
action = "#{controller.class.name}##{controller.action_name}"
- if controller.content_type == 'text/html'
+ if controller.content_type == "text/html"
action
else
"#{action} (#{controller.content_type})"
@@ -46,7 +46,11 @@ module Gitlab
def action_for_grape(env)
endpoint = env[ENDPOINT_KEY]
- route = endpoint.route rescue nil
+ route = begin
+ endpoint.route
+ rescue
+ nil
+ end
"#{route.request_method} #{route.path}" if route
end
diff --git a/lib/gitlab/query_limiting/transaction.rb b/lib/gitlab/query_limiting/transaction.rb
index e8fad067fa6..a764d88d5f6 100644
--- a/lib/gitlab/query_limiting/transaction.rb
+++ b/lib/gitlab/query_limiting/transaction.rb
@@ -69,7 +69,7 @@ module Gitlab
end
def error_message
- header = 'Too many SQL queries were executed'
+ header = "Too many SQL queries were executed"
header = "#{header} in #{action}" if action
"#{header}: a maximum of #{THRESHOLD} is allowed but #{count} SQL queries were executed"
diff --git a/lib/gitlab/quick_actions/command_definition.rb b/lib/gitlab/quick_actions/command_definition.rb
index 259345b8a9a..5b36bc7f9ec 100644
--- a/lib/gitlab/quick_actions/command_definition.rb
+++ b/lib/gitlab/quick_actions/command_definition.rb
@@ -10,9 +10,9 @@ module Gitlab
@name = name
@aliases = attributes[:aliases] || []
- @description = attributes[:description] || ''
- @warning = attributes[:warning] || ''
- @explanation = attributes[:explanation] || ''
+ @description = attributes[:description] || ""
+ @warning = attributes[:warning] || ""
+ @explanation = attributes[:explanation] || ""
@params = attributes[:params] || []
@condition_block = attributes[:condition_block]
@parse_params_block = attributes[:parse_params_block]
@@ -37,10 +37,10 @@ module Gitlab
return unless available?(context)
message = if explanation.respond_to?(:call)
- execute_block(explanation, context, arg)
- else
- explanation
- end
+ execute_block(explanation, context, arg)
+ else
+ explanation
+ end
warning.empty? ? message : "#{message} (#{warning})"
end
@@ -54,12 +54,20 @@ module Gitlab
def to_h(context)
desc = description
if desc.respond_to?(:call)
- desc = context.instance_exec(&desc) rescue ''
+ desc = begin
+ context.instance_exec(&desc)
+ rescue
+ ""
+ end
end
prms = params
if prms.respond_to?(:call)
- prms = Array(context.instance_exec(&prms)) rescue params
+ prms = begin
+ Array(context.instance_exec(&prms))
+ rescue
+ params
+ end
end
{
@@ -67,7 +75,7 @@ module Gitlab
aliases: aliases,
description: desc,
warning: warning,
- params: prms
+ params: prms,
}
end
diff --git a/lib/gitlab/quick_actions/dsl.rb b/lib/gitlab/quick_actions/dsl.rb
index a3aab92061b..aad462e5383 100644
--- a/lib/gitlab/quick_actions/dsl.rb
+++ b/lib/gitlab/quick_actions/dsl.rb
@@ -29,11 +29,11 @@ module Gitlab
# command :command_key do |arguments|
# # Awesome code block
# end
- def desc(text = '', &block)
+ def desc(text = "", &block)
@description = block_given? ? block : text
end
- def warning(message = '')
+ def warning(message = "")
@warning = message
end
@@ -62,7 +62,7 @@ module Gitlab
# command :command_key do |arguments|
# # Awesome code block
# end
- def explanation(text = '', &block)
+ def explanation(text = "", &block)
@explanation = block_given? ? block : text
end
@@ -147,10 +147,10 @@ module Gitlab
action_block: block
)
- self.command_definitions << definition
+ command_definitions << definition
definition.all_names.each do |name|
- self.command_definitions_by_name[name] = definition
+ command_definitions_by_name[name] = definition
end
@description = nil
diff --git a/lib/gitlab/quick_actions/extractor.rb b/lib/gitlab/quick_actions/extractor.rb
index ff9bb293b47..2fa83527224 100644
--- a/lib/gitlab/quick_actions/extractor.rb
+++ b/lib/gitlab/quick_actions/extractor.rb
@@ -42,7 +42,7 @@ module Gitlab
content.gsub!(commands_regex(only: only)) do
if $~[:cmd]
commands << [$~[:cmd].downcase, $~[:arg]].reject(&:blank?)
- ''
+ ""
else
$~[0]
end
@@ -117,9 +117,9 @@ module Gitlab
def perform_substitutions(content, commands)
return unless content
- substitution_definitions = self.command_definitions.select do |definition|
+ substitution_definitions = command_definitions.select { |definition|
definition.is_a?(Gitlab::QuickActions::SubstitutionDefinition)
- end
+ }
substitution_definitions.each do |substitution|
match_data = substitution.match(content.downcase)
@@ -136,7 +136,7 @@ module Gitlab
end
def command_names(limit_to_commands:)
- command_definitions.flat_map do |command|
+ command_definitions.flat_map { |command|
next if command.noop?
if limit_to_commands && (command.all_names & limit_to_commands).empty?
@@ -144,7 +144,7 @@ module Gitlab
end
command.all_names
- end.compact
+ }.compact
end
end
end
diff --git a/lib/gitlab/quick_actions/spend_time_and_date_separator.rb b/lib/gitlab/quick_actions/spend_time_and_date_separator.rb
index f5176376a60..e1ffe5cc834 100644
--- a/lib/gitlab/quick_actions/spend_time_and_date_separator.rb
+++ b/lib/gitlab/quick_actions/spend_time_and_date_separator.rb
@@ -28,7 +28,7 @@ module Gitlab
private
def get_time
- raw_time = @spend_arg.gsub(DATE_REGEX, '')
+ raw_time = @spend_arg.gsub(DATE_REGEX, "")
Gitlab::TimeTrackingFormatter.parse(raw_time)
end
@@ -43,7 +43,11 @@ module Gitlab
def valid_date?
string_date = @spend_arg.match(DATE_REGEX)[0]
- date = Date.parse(string_date) rescue nil
+ date = begin
+ Date.parse(string_date)
+ rescue
+ nil
+ end
date_past_or_today?(date)
end
diff --git a/lib/gitlab/redis/cache.rb b/lib/gitlab/redis/cache.rb
index 6e8403ad878..5ece44f707a 100644
--- a/lib/gitlab/redis/cache.rb
+++ b/lib/gitlab/redis/cache.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
# please require all dependencies below:
-require_relative 'wrapper' unless defined?(::Rails) && ::Rails.root.present?
+require_relative "wrapper" unless defined?(::Rails) && ::Rails.root.present?
module Gitlab
module Redis
class Cache < ::Gitlab::Redis::Wrapper
- CACHE_NAMESPACE = 'cache:gitlab'.freeze
- DEFAULT_REDIS_CACHE_URL = 'redis://localhost:6380'.freeze
- REDIS_CACHE_CONFIG_ENV_VAR_NAME = 'GITLAB_REDIS_CACHE_CONFIG_FILE'.freeze
+ CACHE_NAMESPACE = "cache:gitlab"
+ DEFAULT_REDIS_CACHE_URL = "redis://localhost:6380"
+ REDIS_CACHE_CONFIG_ENV_VAR_NAME = "GITLAB_REDIS_CACHE_CONFIG_FILE"
class << self
def default_url
@@ -21,7 +21,7 @@ module Gitlab
return file_name unless file_name.nil?
# otherwise, if config files exists for this class, use it
- file_name = config_file_path('redis.cache.yml')
+ file_name = config_file_path("redis.cache.yml")
return file_name if File.file?(file_name)
# this will force use of DEFAULT_REDIS_QUEUES_URL when config file is absent
diff --git a/lib/gitlab/redis/queues.rb b/lib/gitlab/redis/queues.rb
index 8b42c269dd0..8f45d2016d1 100644
--- a/lib/gitlab/redis/queues.rb
+++ b/lib/gitlab/redis/queues.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
# please require all dependencies below:
-require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper)
+require_relative "wrapper" unless defined?(::Gitlab::Redis::Wrapper)
module Gitlab
module Redis
class Queues < ::Gitlab::Redis::Wrapper
- SIDEKIQ_NAMESPACE = 'resque:gitlab'.freeze
- MAILROOM_NAMESPACE = 'mail_room:gitlab'.freeze
- DEFAULT_REDIS_QUEUES_URL = 'redis://localhost:6381'.freeze
- REDIS_QUEUES_CONFIG_ENV_VAR_NAME = 'GITLAB_REDIS_QUEUES_CONFIG_FILE'.freeze
+ SIDEKIQ_NAMESPACE = "resque:gitlab"
+ MAILROOM_NAMESPACE = "mail_room:gitlab"
+ DEFAULT_REDIS_QUEUES_URL = "redis://localhost:6381"
+ REDIS_QUEUES_CONFIG_ENV_VAR_NAME = "GITLAB_REDIS_QUEUES_CONFIG_FILE"
class << self
def default_url
@@ -22,7 +22,7 @@ module Gitlab
return file_name if file_name
# otherwise, if config files exists for this class, use it
- file_name = config_file_path('redis.queues.yml')
+ file_name = config_file_path("redis.queues.yml")
return file_name if File.file?(file_name)
# this will force use of DEFAULT_REDIS_QUEUES_URL when config file is absent
diff --git a/lib/gitlab/redis/shared_state.rb b/lib/gitlab/redis/shared_state.rb
index 9066606ca21..fa1fd9f2ca5 100644
--- a/lib/gitlab/redis/shared_state.rb
+++ b/lib/gitlab/redis/shared_state.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
# please require all dependencies below:
-require_relative 'wrapper' unless defined?(::Gitlab::Redis::Wrapper)
+require_relative "wrapper" unless defined?(::Gitlab::Redis::Wrapper)
module Gitlab
module Redis
class SharedState < ::Gitlab::Redis::Wrapper
- SESSION_NAMESPACE = 'session:gitlab'.freeze
- USER_SESSIONS_NAMESPACE = 'session:user:gitlab'.freeze
- USER_SESSIONS_LOOKUP_NAMESPACE = 'session:lookup:user:gitlab'.freeze
- DEFAULT_REDIS_SHARED_STATE_URL = 'redis://localhost:6382'.freeze
- REDIS_SHARED_STATE_CONFIG_ENV_VAR_NAME = 'GITLAB_REDIS_SHARED_STATE_CONFIG_FILE'.freeze
+ SESSION_NAMESPACE = "session:gitlab"
+ USER_SESSIONS_NAMESPACE = "session:user:gitlab"
+ USER_SESSIONS_LOOKUP_NAMESPACE = "session:lookup:user:gitlab"
+ DEFAULT_REDIS_SHARED_STATE_URL = "redis://localhost:6382"
+ REDIS_SHARED_STATE_CONFIG_ENV_VAR_NAME = "GITLAB_REDIS_SHARED_STATE_CONFIG_FILE"
class << self
def default_url
@@ -23,7 +23,7 @@ module Gitlab
return file_name if file_name
# otherwise, if config files exists for this class, use it
- file_name = config_file_path('redis.shared_state.yml')
+ file_name = config_file_path("redis.shared_state.yml")
return file_name if File.file?(file_name)
# this will force use of DEFAULT_REDIS_SHARED_STATE_URL when config file is absent
diff --git a/lib/gitlab/redis/wrapper.rb b/lib/gitlab/redis/wrapper.rb
index 07a1e20b076..90ec49facf4 100644
--- a/lib/gitlab/redis/wrapper.rb
+++ b/lib/gitlab/redis/wrapper.rb
@@ -2,14 +2,14 @@
# This file should only be used by sub-classes, not directly by any clients of the sub-classes
# please require all dependencies below:
-require 'active_support/core_ext/hash/keys'
-require 'active_support/core_ext/module/delegation'
+require "active_support/core_ext/hash/keys"
+require "active_support/core_ext/module/delegation"
module Gitlab
module Redis
class Wrapper
- DEFAULT_REDIS_URL = 'redis://localhost:6379'.freeze
- REDIS_CONFIG_ENV_VAR_NAME = 'GITLAB_REDIS_CONFIG_FILE'.freeze
+ DEFAULT_REDIS_URL = "redis://localhost:6379"
+ REDIS_CONFIG_ENV_VAR_NAME = "GITLAB_REDIS_CONFIG_FILE"
class << self
delegate :params, :url, to: :new
@@ -63,7 +63,7 @@ module Gitlab
return file_name unless file_name.nil?
# otherwise, if config files exists for wrapper class, use it
- file_name = config_file_path('resque.yml')
+ file_name = config_file_path("resque.yml")
return file_name if File.file?(file_name)
# nil will force use of DEFAULT_REDIS_URL when config file is absent
@@ -98,7 +98,7 @@ module Gitlab
redis_url = config.delete(:url)
redis_uri = URI.parse(redis_url)
- if redis_uri.scheme == 'unix'
+ if redis_uri.scheme == "unix"
# Redis::Store does not handle Unix sockets well, so let's do it for them
config[:path] = redis_uri.path
query = redis_uri.query
@@ -121,9 +121,9 @@ module Gitlab
config_data = fetch_config
if config_data
- config_data.is_a?(String) ? { url: config_data } : config_data.deep_symbolize_keys
+ config_data.is_a?(String) ? {url: config_data} : config_data.deep_symbolize_keys
else
- { url: self.class.default_url }
+ {url: self.class.default_url}
end
end
diff --git a/lib/gitlab/reference_extractor.rb b/lib/gitlab/reference_extractor.rb
index 00f817c2399..1dba71d3303 100644
--- a/lib/gitlab/reference_extractor.rb
+++ b/lib/gitlab/reference_extractor.rb
@@ -3,7 +3,7 @@
module Gitlab
# Extract possible GFM references from an arbitrary String for further processing.
class ReferenceExtractor < Banzai::ReferenceExtractor
- REFERABLES = %i(user issue label milestone merge_request snippet commit commit_range directly_addressed_user epic).freeze
+ REFERABLES = %i[user issue label milestone merge_request snippet commit commit_range directly_addressed_user epic].freeze
attr_accessor :project, :current_user, :author
def initialize(project, current_user = nil)
@@ -34,7 +34,7 @@ module Gitlab
end
def issues
- if project && project.jira_tracker?
+ if project&.jira_tracker?
if project.issues_enabled?
@references[:all_issues] ||= references(:external_issue) + references(:issue)
else
@@ -54,9 +54,9 @@ module Gitlab
def self.references_pattern
return @pattern if @pattern
- patterns = REFERABLES.map do |ref|
+ patterns = REFERABLES.map { |ref|
ref.to_s.classify.constantize.try(:reference_pattern)
- end
+ }
@pattern = Regexp.union(patterns.compact)
end
diff --git a/lib/gitlab/repo_path.rb b/lib/gitlab/repo_path.rb
index 202d310e237..480bc6d1284 100644
--- a/lib/gitlab/repo_path.rb
+++ b/lib/gitlab/repo_path.rb
@@ -6,12 +6,12 @@ module Gitlab
def self.parse(repo_path)
wiki = false
- project_path = repo_path.sub(/\.git\z/, '').sub(%r{\A/}, '')
+ project_path = repo_path.sub(/\.git\z/, "").sub(%r{\A/}, "")
project, was_redirected = find_project(project_path)
- if project_path.end_with?('.wiki') && project.nil?
- project, was_redirected = find_project(project_path.chomp('.wiki'))
+ if project_path.end_with?(".wiki") && project.nil?
+ project, was_redirected = find_project(project_path.chomp(".wiki"))
wiki = true
end
diff --git a/lib/gitlab/repository_cache_adapter.rb b/lib/gitlab/repository_cache_adapter.rb
index 931298b5117..eec75247b8e 100644
--- a/lib/gitlab/repository_cache_adapter.rb
+++ b/lib/gitlab/repository_cache_adapter.rb
@@ -160,7 +160,7 @@ module Gitlab
private
def memoizable_name(name)
- "#{name.to_s.tr('?!', '')}"
+ name.to_s.tr("?!", "").to_s
end
def expire_request_store_method_caches(methods)
diff --git a/lib/gitlab/repository_check_logger.rb b/lib/gitlab/repository_check_logger.rb
index e90b0a002af..9fd2727e59e 100644
--- a/lib/gitlab/repository_check_logger.rb
+++ b/lib/gitlab/repository_check_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class RepositoryCheckLogger < Gitlab::Logger
def self.file_name_noext
- 'repocheck'
+ "repocheck"
end
end
end
diff --git a/lib/gitlab/request_profiler.rb b/lib/gitlab/request_profiler.rb
index 64593153686..0abebf3d215 100644
--- a/lib/gitlab/request_profiler.rb
+++ b/lib/gitlab/request_profiler.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'fileutils'
+require "fileutils"
module Gitlab
module RequestProfiler
- PROFILES_DIR = "#{Gitlab.config.shared.path}/tmp/requests_profiles".freeze
+ PROFILES_DIR = "#{Gitlab.config.shared.path}/tmp/requests_profiles"
def profile_token
- Rails.cache.fetch('profile-token') do
+ Rails.cache.fetch("profile-token") do
Devise.friendly_token
end
end
diff --git a/lib/gitlab/request_profiler/middleware.rb b/lib/gitlab/request_profiler/middleware.rb
index 7615f6f443b..1a6ec735449 100644
--- a/lib/gitlab/request_profiler/middleware.rb
+++ b/lib/gitlab/request_profiler/middleware.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'ruby-prof'
+require "ruby-prof"
module Gitlab
module RequestProfiler
@@ -18,7 +18,7 @@ module Gitlab
end
def profile?(env)
- header_token = env['HTTP_X_PROFILE_TOKEN']
+ header_token = env["HTTP_X_PROFILE_TOKEN"]
return unless header_token.present?
profile_token = Gitlab::RequestProfiler.profile_token
@@ -29,18 +29,18 @@ module Gitlab
def call_with_profiling(env)
ret = nil
- result = RubyProf::Profile.profile do
- ret = catch(:warden) do
+ result = RubyProf::Profile.profile {
+ ret = catch(:warden) {
@app.call(env)
- end
- end
+ }
+ }
printer = RubyProf::CallStackPrinter.new(result)
- file_name = "#{env['PATH_INFO'].tr('/', '|')}_#{Time.current.to_i}.html"
+ file_name = "#{env["PATH_INFO"].tr("/", "|")}_#{Time.current.to_i}.html"
file_path = "#{PROFILES_DIR}/#{file_name}"
FileUtils.mkdir_p(PROFILES_DIR)
- File.open(file_path, 'wb') do |file|
+ File.open(file_path, "wb") do |file|
printer.print(file)
end
diff --git a/lib/gitlab/request_profiler/profile.rb b/lib/gitlab/request_profiler/profile.rb
index 46996ef8c51..da27ce806c7 100644
--- a/lib/gitlab/request_profiler/profile.rb
+++ b/lib/gitlab/request_profiler/profile.rb
@@ -5,7 +5,7 @@ module Gitlab
class Profile
attr_reader :name, :time, :request_path
- alias_method :to_param, :name
+ alias to_param name
def self.all
Dir["#{PROFILES_DIR}/*.html"].map do |path|
@@ -15,7 +15,7 @@ module Gitlab
def self.find(name)
name_dup = name.dup
- name_dup << '.html' unless name.end_with?('.html')
+ name_dup << ".html" unless name.end_with?(".html")
file_path = "#{PROFILES_DIR}/#{name_dup}"
return unless File.exist?(file_path)
@@ -37,7 +37,7 @@ module Gitlab
def set_attributes
_, path, timestamp = name.split(/(.*)_(\d+)\.html$/)
- @request_path = path.tr('|', '/')
+ @request_path = path.tr("|", "/")
@time = Time.at(timestamp.to_i).utc
end
end
diff --git a/lib/gitlab/route_map.rb b/lib/gitlab/route_map.rb
index a555bf1d812..46620f7988d 100644
--- a/lib/gitlab/route_map.rb
+++ b/lib/gitlab/route_map.rb
@@ -8,10 +8,10 @@ module Gitlab
begin
entries = YAML.safe_load(data)
rescue
- raise FormatError, 'Route map is not valid YAML'
+ raise FormatError, "Route map is not valid YAML"
end
- raise FormatError, 'Route map is not an array' unless entries.is_a?(Array)
+ raise FormatError, "Route map is not an array" unless entries.is_a?(Array)
@map = entries.map { |entry| parse_entry(entry) }
end
@@ -30,15 +30,15 @@ module Gitlab
private
def parse_entry(entry)
- raise FormatError, 'Route map entry is not a hash' unless entry.is_a?(Hash)
- raise FormatError, 'Route map entry does not have a source key' unless entry.key?('source')
- raise FormatError, 'Route map entry does not have a public key' unless entry.key?('public')
+ raise FormatError, "Route map entry is not a hash" unless entry.is_a?(Hash)
+ raise FormatError, "Route map entry does not have a source key" unless entry.key?("source")
+ raise FormatError, "Route map entry does not have a public key" unless entry.key?("public")
- source_pattern = entry['source']
- public_path = entry['public']
+ source_pattern = entry["source"]
+ public_path = entry["public"]
- if source_pattern.start_with?('/') && source_pattern.end_with?('/')
- source_pattern = source_pattern[1...-1].gsub('\/', '/')
+ if source_pattern.start_with?("/") && source_pattern.end_with?("/")
+ source_pattern = source_pattern[1...-1].gsub('\/', "/")
begin
source_pattern = Gitlab::UntrustedRegexp.new('\A' + source_pattern + '\z')
@@ -49,7 +49,7 @@ module Gitlab
{
source: source_pattern,
- public: public_path
+ public: public_path,
}
end
end
diff --git a/lib/gitlab/routing.rb b/lib/gitlab/routing.rb
index 3b05f181ed2..7a2fb3ad52c 100644
--- a/lib/gitlab/routing.rb
+++ b/lib/gitlab/routing.rb
@@ -14,7 +14,7 @@ module Gitlab
end
def self.includes_helpers(klass)
- self._includers << klass
+ _includers << klass
end
def self.add_helpers(mod)
@@ -56,9 +56,9 @@ module Gitlab
paths.each do |path|
router.match "/#{path}(/*rest)",
- via: [:get, :post, :patch, :delete],
- to: router.redirect { |params, request| build_redirect_path.call(request, params, path) },
- as: "legacy_#{path}_redirect"
+ via: [:get, :post, :patch, :delete],
+ to: router.redirect { |params, request| build_redirect_path.call(request, params, path) },
+ as: "legacy_#{path}_redirect"
end
end
end
diff --git a/lib/gitlab/sanitizers/svg.rb b/lib/gitlab/sanitizers/svg.rb
index 0d4e6be2129..a17df42ce22 100644
--- a/lib/gitlab/sanitizers/svg.rb
+++ b/lib/gitlab/sanitizers/svg.rb
@@ -47,11 +47,11 @@ module Gitlab
end
def unsafe_href?(attr)
- attribute_name_with_namespace(attr) == 'xlink:href' && !attr.value.start_with?('#')
+ attribute_name_with_namespace(attr) == "xlink:href" && !attr.value.start_with?("#")
end
def data_attribute?(attr)
- attr.name.start_with?('data-') && attr.name =~ DATA_ATTR_PATTERN && attr.namespace.nil?
+ attr.name.start_with?("data-") && attr.name =~ DATA_ATTR_PATTERN && attr.namespace.nil?
end
end
end
diff --git a/lib/gitlab/sanitizers/svg/whitelist.rb b/lib/gitlab/sanitizers/svg/whitelist.rb
index b4da24b3215..3a7ca597835 100644
--- a/lib/gitlab/sanitizers/svg/whitelist.rb
+++ b/lib/gitlab/sanitizers/svg/whitelist.rb
@@ -25,86 +25,86 @@ module Gitlab
ALLOWED_DATA_ATTRIBUTES_IN_ELEMENTS = %w[svg].freeze
ALLOWED_ATTRIBUTES = {
- 'a' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage target text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'altGlyph' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight format glyph-orientation-horizontal glyph-orientation-vertical glyphRef id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'altGlyphDef' => %w[id xml:base xml:lang xml:space],
- 'altGlyphItem' => %w[id xml:base xml:lang xml:space],
- 'animate' => %w[accumulate additive alignment-baseline attributeName attributeType baseline-shift begin by calcMode clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dur enable-background end externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight from glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning keySplines keyTimes letter-spacing lighting-color marker-end marker-mid marker-start mask max min onbegin onend onload onrepeat opacity overflow pointer-events repeatCount repeatDur requiredExtensions requiredFeatures restart shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width systemLanguage text-anchor text-decoration text-rendering to unicode-bidi values visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'animateColor' => %w[accumulate additive alignment-baseline attributeName attributeType baseline-shift begin by calcMode clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dur enable-background end externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight from glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning keySplines keyTimes letter-spacing lighting-color marker-end marker-mid marker-start mask max min onbegin onend onload onrepeat opacity overflow pointer-events repeatCount repeatDur requiredExtensions requiredFeatures restart shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width systemLanguage text-anchor text-decoration text-rendering to unicode-bidi values visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'animateMotion' => %w[accumulate additive begin by calcMode dur end externalResourcesRequired fill from id keyPoints keySplines keyTimes max min onbegin onend onload onrepeat origin path repeatCount repeatDur requiredExtensions requiredFeatures restart rotate systemLanguage to values xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'animateTransform' => %w[accumulate additive attributeName attributeType begin by calcMode dur end externalResourcesRequired fill from id keySplines keyTimes max min onbegin onend onload onrepeat repeatCount repeatDur requiredExtensions requiredFeatures restart systemLanguage to type values xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'circle' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events r requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'clipPath' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule clipPathUnits color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'color-profile' => %w[id local name rendering-intent xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'cursor' => %w[externalResourcesRequired id requiredExtensions requiredFeatures systemLanguage x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'defs' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'desc' => %w[class id style xml:base xml:lang xml:space],
- 'ellipse' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rx ry shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'feBlend' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask mode opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feColorMatrix' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering type unicode-bidi values visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feComponentTransfer' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feComposite' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 k1 k2 k3 k4 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity operator overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feConvolveMatrix' => %w[alignment-baseline baseline-shift bias class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display divisor dominant-baseline edgeMode enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelMatrix kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity order overflow pointer-events preserveAlpha result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style targetX targetY text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feDiffuseLighting' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor diffuseConstant direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style surfaceScale text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feDisplacementMap' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result scale shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xChannelSelector xml:base xml:lang xml:space y yChannelSelector],
- 'feDistantLight' => %w[azimuth elevation id xml:base xml:lang xml:space],
- 'feFlood' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feFuncA' => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
- 'feFuncB' => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
- 'feFuncG' => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
- 'feFuncR' => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
- 'feGaussianBlur' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stdDeviation stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feImage' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events preserveAspectRatio result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'feMerge' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feMergeNode' => %w[id xml:base xml:lang xml:space],
- 'feMorphology' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity operator overflow pointer-events radius result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feOffset' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'fePointLight' => %w[id x xml:base xml:lang xml:space y z],
- 'feSpecularLighting' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering specularConstant specularExponent stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style surfaceScale text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feSpotLight' => %w[id limitingConeAngle pointsAtX pointsAtY pointsAtZ specularExponent x xml:base xml:lang xml:space y z],
- 'feTile' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'feTurbulence' => %w[alignment-baseline baseFrequency baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask numOctaves opacity overflow pointer-events result seed shape-rendering stitchTiles stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering type unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'filter' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter filterRes filterUnits flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events primitiveUnits shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'font' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x horiz-origin-y id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'font-face' => %w[accent-height alphabetic ascent bbox cap-height descent font-family font-size font-stretch font-style font-variant font-weight hanging id ideographic mathematical overline-position overline-thickness panose-1 slope stemh stemv strikethrough-position strikethrough-thickness underline-position underline-thickness unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical widths x-height xml:base xml:lang xml:space],
- 'font-face-format' => %w[id string xml:base xml:lang xml:space],
- 'font-face-name' => %w[id name xml:base xml:lang xml:space],
- 'font-face-src' => %w[id xml:base xml:lang xml:space],
- 'font-face-uri' => %w[id xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'foreignObject' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'g' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'glyph' => %w[alignment-baseline arabic-form baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x id image-rendering kerning lang letter-spacing lighting-color marker-end marker-mid marker-start mask opacity orientation overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'glyphRef' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight format glyph-orientation-horizontal glyph-orientation-vertical glyphRef id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'hkern' => %w[g1 g2 id k u1 u2 xml:base xml:lang xml:space],
- 'image' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'line' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode x1 x2 xml:base xml:lang xml:space y1 y2],
- 'linearGradient' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical gradientTransform gradientUnits id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering spreadMethod stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x1 x2 xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space y1 y2],
- 'marker' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start markerHeight markerUnits markerWidth mask opacity orient overflow pointer-events preserveAspectRatio refX refY shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi viewBox visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'mask' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask maskContentUnits maskUnits opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'metadata' => %w[id xml:base xml:lang xml:space],
- 'missing-glyph' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'mpath' => %w[externalResourcesRequired id xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'path' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pathLength pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'pattern' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow patternContentUnits patternTransform patternUnits pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi viewBox visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'polygon' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events points requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'polyline' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events points requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'radialGradient' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight fx fy glyph-orientation-horizontal glyph-orientation-vertical gradientTransform gradientUnits id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events r shape-rendering spreadMethod stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space],
- 'rect' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rx ry shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'script' => %w[externalResourcesRequired id type xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'set' => %w[attributeName attributeType begin dur end externalResourcesRequired fill id max min onbegin onend onload onrepeat repeatCount repeatDur requiredExtensions requiredFeatures restart systemLanguage to xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
- 'stop' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask offset opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'style' => %w[id media title type xml:base xml:lang xml:space],
- 'svg' => %w[alignment-baseline baseProfile baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering contentScriptType contentStyleType cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onabort onactivate onclick onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onresize onscroll onunload onzoom opacity overflow pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi version viewBox visibility width word-spacing writing-mode x xml:base xml:lang xml:space xmlns y zoomAndPan],
- 'switch' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'symbol' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events preserveAspectRatio shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi viewBox visibility word-spacing writing-mode xml:base xml:lang xml:space],
- 'text' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength transform unicode-bidi visibility word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'textPath' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask method onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering spacing startOffset stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space],
- 'title' => %w[class id style xml:base xml:lang xml:space],
- 'tref' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode x xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space y],
- 'tspan' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode x xml:base xml:lang xml:space y],
- 'use' => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
- 'view' => %w[externalResourcesRequired id preserveAspectRatio viewBox viewTarget xml:base xml:lang xml:space zoomAndPan],
- 'vkern' => %w[g1 g2 id k u1 u2 xml:base xml:lang xml:space]
+ "a" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage target text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "altGlyph" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight format glyph-orientation-horizontal glyph-orientation-vertical glyphRef id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "altGlyphDef" => %w[id xml:base xml:lang xml:space],
+ "altGlyphItem" => %w[id xml:base xml:lang xml:space],
+ "animate" => %w[accumulate additive alignment-baseline attributeName attributeType baseline-shift begin by calcMode clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dur enable-background end externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight from glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning keySplines keyTimes letter-spacing lighting-color marker-end marker-mid marker-start mask max min onbegin onend onload onrepeat opacity overflow pointer-events repeatCount repeatDur requiredExtensions requiredFeatures restart shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width systemLanguage text-anchor text-decoration text-rendering to unicode-bidi values visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "animateColor" => %w[accumulate additive alignment-baseline attributeName attributeType baseline-shift begin by calcMode clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dur enable-background end externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight from glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning keySplines keyTimes letter-spacing lighting-color marker-end marker-mid marker-start mask max min onbegin onend onload onrepeat opacity overflow pointer-events repeatCount repeatDur requiredExtensions requiredFeatures restart shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width systemLanguage text-anchor text-decoration text-rendering to unicode-bidi values visibility word-spacing writing-mode xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "animateMotion" => %w[accumulate additive begin by calcMode dur end externalResourcesRequired fill from id keyPoints keySplines keyTimes max min onbegin onend onload onrepeat origin path repeatCount repeatDur requiredExtensions requiredFeatures restart rotate systemLanguage to values xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "animateTransform" => %w[accumulate additive attributeName attributeType begin by calcMode dur end externalResourcesRequired fill from id keySplines keyTimes max min onbegin onend onload onrepeat repeatCount repeatDur requiredExtensions requiredFeatures restart systemLanguage to type values xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "circle" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events r requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "clipPath" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule clipPathUnits color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "color-profile" => %w[id local name rendering-intent xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "cursor" => %w[externalResourcesRequired id requiredExtensions requiredFeatures systemLanguage x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "defs" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "desc" => %w[class id style xml:base xml:lang xml:space],
+ "ellipse" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rx ry shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "feBlend" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask mode opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feColorMatrix" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering type unicode-bidi values visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feComponentTransfer" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feComposite" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 k1 k2 k3 k4 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity operator overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feConvolveMatrix" => %w[alignment-baseline baseline-shift bias class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display divisor dominant-baseline edgeMode enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelMatrix kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity order overflow pointer-events preserveAlpha result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style targetX targetY text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feDiffuseLighting" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor diffuseConstant direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style surfaceScale text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feDisplacementMap" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in in2 kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result scale shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xChannelSelector xml:base xml:lang xml:space y yChannelSelector],
+ "feDistantLight" => %w[azimuth elevation id xml:base xml:lang xml:space],
+ "feFlood" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feFuncA" => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
+ "feFuncB" => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
+ "feFuncG" => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
+ "feFuncR" => %w[amplitude exponent id intercept offset slope tableValues type xml:base xml:lang xml:space],
+ "feGaussianBlur" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stdDeviation stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feImage" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events preserveAspectRatio result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "feMerge" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feMergeNode" => %w[id xml:base xml:lang xml:space],
+ "feMorphology" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity operator overflow pointer-events radius result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feOffset" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "fePointLight" => %w[id x xml:base xml:lang xml:space y z],
+ "feSpecularLighting" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kernelUnitLength kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering specularConstant specularExponent stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style surfaceScale text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feSpotLight" => %w[id limitingConeAngle pointsAtX pointsAtY pointsAtZ specularExponent x xml:base xml:lang xml:space y z],
+ "feTile" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering in kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events result shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "feTurbulence" => %w[alignment-baseline baseFrequency baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask numOctaves opacity overflow pointer-events result seed shape-rendering stitchTiles stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering type unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "filter" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter filterRes filterUnits flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events primitiveUnits shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "font" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x horiz-origin-y id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "font-face" => %w[accent-height alphabetic ascent bbox cap-height descent font-family font-size font-stretch font-style font-variant font-weight hanging id ideographic mathematical overline-position overline-thickness panose-1 slope stemh stemv strikethrough-position strikethrough-thickness underline-position underline-thickness unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical widths x-height xml:base xml:lang xml:space],
+ "font-face-format" => %w[id string xml:base xml:lang xml:space],
+ "font-face-name" => %w[id name xml:base xml:lang xml:space],
+ "font-face-src" => %w[id xml:base xml:lang xml:space],
+ "font-face-uri" => %w[id xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "foreignObject" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "g" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "glyph" => %w[alignment-baseline arabic-form baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x id image-rendering kerning lang letter-spacing lighting-color marker-end marker-mid marker-start mask opacity orientation overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "glyphRef" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight format glyph-orientation-horizontal glyph-orientation-vertical glyphRef id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "hkern" => %w[g1 g2 id k u1 u2 xml:base xml:lang xml:space],
+ "image" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "line" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode x1 x2 xml:base xml:lang xml:space y1 y2],
+ "linearGradient" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical gradientTransform gradientUnits id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering spreadMethod stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode x1 x2 xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space y1 y2],
+ "marker" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start markerHeight markerUnits markerWidth mask opacity orient overflow pointer-events preserveAspectRatio refX refY shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi viewBox visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "mask" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask maskContentUnits maskUnits opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "metadata" => %w[id xml:base xml:lang xml:space],
+ "missing-glyph" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi vert-adv-y vert-origin-x vert-origin-y visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "mpath" => %w[externalResourcesRequired id xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "path" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor d direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pathLength pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "pattern" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow patternContentUnits patternTransform patternUnits pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi viewBox visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "polygon" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events points requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "polyline" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events points requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "radialGradient" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor cx cy direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight fx fy glyph-orientation-horizontal glyph-orientation-vertical gradientTransform gradientUnits id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask opacity overflow pointer-events r shape-rendering spreadMethod stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space],
+ "rect" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rx ry shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "script" => %w[externalResourcesRequired id type xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "set" => %w[attributeName attributeType begin dur end externalResourcesRequired fill id max min onbegin onend onload onrepeat repeatCount repeatDur requiredExtensions requiredFeatures restart systemLanguage to xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space],
+ "stop" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask offset opacity overflow pointer-events shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "style" => %w[id media title type xml:base xml:lang xml:space],
+ "svg" => %w[alignment-baseline baseProfile baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering contentScriptType contentStyleType cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onabort onactivate onclick onerror onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup onresize onscroll onunload onzoom opacity overflow pointer-events preserveAspectRatio requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering unicode-bidi version viewBox visibility width word-spacing writing-mode x xml:base xml:lang xml:space xmlns y zoomAndPan],
+ "switch" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "symbol" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events preserveAspectRatio shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style text-anchor text-decoration text-rendering unicode-bidi viewBox visibility word-spacing writing-mode xml:base xml:lang xml:space],
+ "text" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength transform unicode-bidi visibility word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "textPath" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask method onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering spacing startOffset stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space],
+ "title" => %w[class id style xml:base xml:lang xml:space],
+ "tref" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode x xlink:arcrole xlink:href xlink:role xlink:title xlink:type xml:base xml:lang xml:space y],
+ "tspan" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline dx dy enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical id image-rendering kerning lengthAdjust letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures rotate shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering textLength unicode-bidi visibility word-spacing writing-mode x xml:base xml:lang xml:space y],
+ "use" => %w[alignment-baseline baseline-shift class clip clip-path clip-rule color color-interpolation color-interpolation-filters color-profile color-rendering cursor direction display dominant-baseline enable-background externalResourcesRequired fill fill-opacity fill-rule filter flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-orientation-horizontal glyph-orientation-vertical height id image-rendering kerning letter-spacing lighting-color marker-end marker-mid marker-start mask onactivate onclick onfocusin onfocusout onload onmousedown onmousemove onmouseout onmouseover onmouseup opacity overflow pointer-events requiredExtensions requiredFeatures shape-rendering stop-color stop-opacity stroke stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width style systemLanguage text-anchor text-decoration text-rendering transform unicode-bidi visibility width word-spacing writing-mode x xlink:actuate xlink:arcrole xlink:href xlink:role xlink:show xlink:title xlink:type xml:base xml:lang xml:space y],
+ "view" => %w[externalResourcesRequired id preserveAspectRatio viewBox viewTarget xml:base xml:lang xml:space zoomAndPan],
+ "vkern" => %w[g1 g2 id k u1 u2 xml:base xml:lang xml:space],
}.freeze
end
end
diff --git a/lib/gitlab/search/found_blob.rb b/lib/gitlab/search/found_blob.rb
index a62ab1521a7..4b275b80ac2 100644
--- a/lib/gitlab/search/found_blob.rb
+++ b/lib/gitlab/search/found_blob.rb
@@ -84,7 +84,7 @@ module Gitlab
def fetch_blob
path = [ref, blob_filename]
- missing_blob = { binary_filename: blob_filename }
+ missing_blob = {binary_filename: blob_filename}
BatchLoader.for(path).batch(default_value: missing_blob) do |refs, loader|
Gitlab::Git::Blob.batch(repository, refs, blob_size_limit: 1024).each do |blob|
@@ -97,7 +97,7 @@ module Gitlab
ref: ref,
startline: 1,
binary_data: blob.data,
- project: project
+ project: project,
}
loader.call([ref, blob.path], data)
@@ -138,10 +138,10 @@ module Gitlab
startline = matches[:startline]
startline = startline.to_i - index
extname = Regexp.escape(File.extname(filename))
- basename = filename.sub(/#{extname}$/, '')
+ basename = filename.sub(/#{extname}$/, "")
end
- data << line.sub(prefix.to_s, '')
+ data << line.sub(prefix.to_s, "")
end
{
@@ -150,7 +150,7 @@ module Gitlab
ref: ref,
startline: startline,
binary_data: data.join,
- project: project
+ project: project,
}
end
diff --git a/lib/gitlab/search/query.rb b/lib/gitlab/search/query.rb
index ba0e16607a6..124ca4841fc 100644
--- a/lib/gitlab/search/query.rb
+++ b/lib/gitlab/search/query.rb
@@ -8,9 +8,9 @@ module Gitlab
def initialize(query, filter_opts = {}, &block)
@raw_query = query.dup
@filters = []
- @filter_options = { default_parser: :downcase.to_proc }.merge(filter_opts)
+ @filter_options = {default_parser: :downcase.to_proc}.merge(filter_opts)
- self.instance_eval(&block) if block_given?
+ instance_eval(&block) if block_given?
@query = Gitlab::Search::ParsedQuery.new(*extract_filters)
# set the ParsedQuery as our default delegator thanks to SimpleDelegator
@@ -20,7 +20,7 @@ module Gitlab
private
def filter(name, **attributes)
- filter = { parser: @filter_options[:default_parser], name: name }.merge(attributes)
+ filter = {parser: @filter_options[:default_parser], name: name}.merge(attributes)
@filters << filter
end
@@ -32,21 +32,21 @@ module Gitlab
def extract_filters
fragments = []
- filters = @filters.each_with_object([]) do |filter, parsed_filters|
+ filters = @filters.each_with_object([]) { |filter, parsed_filters|
match = @raw_query.split.find { |part| part =~ /\A#{filter[:name]}:/ }
next unless match
- input = match.split(':')[1..-1].join
+ input = match.split(":")[1..-1].join
next if input.empty?
filter[:value] = parse_filter(filter, input)
- filter[:regex_value] = Regexp.escape(filter[:value]).gsub('\*', '.*?')
+ filter[:regex_value] = Regexp.escape(filter[:value]).gsub('\*', ".*?")
fragments << match
parsed_filters << filter
- end
+ }
- query = (@raw_query.split - fragments).join(' ')
+ query = (@raw_query.split - fragments).join(" ")
[query, filters]
end
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index 491148ec1a6..63b9087fb16 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -24,17 +24,17 @@ module Gitlab
def objects(scope, page = nil, without_count = true)
collection = case scope
- when 'projects'
+ when "projects"
projects.page(page).per(per_page)
- when 'issues'
+ when "issues"
issues.page(page).per(per_page)
- when 'merge_requests'
+ when "merge_requests"
merge_requests.page(page).per(per_page)
- when 'milestones'
+ when "milestones"
milestones.page(page).per(per_page)
else
Kaminari.paginate_array([]).page(page).per(per_page)
- end
+ end
without_count ? collection.without_count : collection
end
@@ -99,7 +99,7 @@ module Gitlab
issues.full_search(query)
end
- issues.reorder('updated_at DESC')
+ issues.reorder("updated_at DESC")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -107,7 +107,7 @@ module Gitlab
def milestones
milestones = Milestone.where(project_id: project_ids_relation)
milestones = milestones.search(query)
- milestones.reorder('updated_at DESC')
+ milestones.reorder("updated_at DESC")
end
# rubocop: enable CodeReuse/ActiveRecord
@@ -125,12 +125,12 @@ module Gitlab
merge_requests.full_search(query)
end
- merge_requests.reorder('updated_at DESC')
+ merge_requests.reorder("updated_at DESC")
end
# rubocop: enable CodeReuse/ActiveRecord
def default_scope
- 'projects'
+ "projects"
end
# rubocop: disable CodeReuse/ActiveRecord
diff --git a/lib/gitlab/sentry.rb b/lib/gitlab/sentry.rb
index 956c16117f5..851a1f9a5a8 100644
--- a/lib/gitlab/sentry.rb
+++ b/lib/gitlab/sentry.rb
@@ -45,7 +45,7 @@ module Gitlab
context # Make sure we've set everything we know in the context
tags = {
- Gitlab::CorrelationId::LOG_KEY.to_sym => Gitlab::CorrelationId.current_id
+ Gitlab::CorrelationId::LOG_KEY.to_sym => Gitlab::CorrelationId.current_id,
}
Raven.capture_exception(exception, tags: tags, extra: extra)
diff --git a/lib/gitlab/setup_helper.rb b/lib/gitlab/setup_helper.rb
index 2b7e12639be..a662b1d3311 100644
--- a/lib/gitlab/setup_helper.rb
+++ b/lib/gitlab/setup_helper.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'toml-rb'
+require "toml-rb"
module Gitlab
module SetupHelper
@@ -19,29 +19,29 @@ module Gitlab
Gitlab.config.repositories.storages.each do |key, val|
if address
- if address != val['gitaly_address']
+ if address != val["gitaly_address"]
raise ArgumentError, "Your gitlab.yml contains more than one gitaly_address."
end
- elsif URI(val['gitaly_address']).scheme != 'unix'
+ elsif URI(val["gitaly_address"]).scheme != "unix"
raise ArgumentError, "Automatic config.toml generation only supports 'unix:' addresses."
else
- address = val['gitaly_address']
+ address = val["gitaly_address"]
end
- storages << { name: key, path: storage_paths[key] }
+ storages << {name: key, path: storage_paths[key]}
end
if Rails.env.test?
- storage_path = Rails.root.join('tmp', 'tests', 'second_storage').to_s
+ storage_path = Rails.root.join("tmp", "tests", "second_storage").to_s
FileUtils.mkdir(storage_path) unless File.exist?(storage_path)
- storages << { name: 'test_second_storage', path: storage_path }
+ storages << {name: "test_second_storage", path: storage_path}
end
- config = { socket_path: address.sub(/\Aunix:/, ''), storage: storages }
- config[:auth] = { token: 'secret' } if Rails.env.test?
- config[:'gitaly-ruby'] = { dir: File.join(gitaly_dir, 'ruby') } if gitaly_ruby
- config[:'gitlab-shell'] = { dir: Gitlab.config.gitlab_shell.path }
+ config = {socket_path: address.sub(/\Aunix:/, ""), storage: storages}
+ config[:auth] = {token: "secret"} if Rails.env.test?
+ config[:'gitaly-ruby'] = {dir: File.join(gitaly_dir, "ruby")} if gitaly_ruby
+ config[:'gitlab-shell'] = {dir: Gitlab.config.gitlab_shell.path}
config[:bin_dir] = Gitlab.config.gitaly.client_path
TomlRB.dump(config)
@@ -49,7 +49,7 @@ module Gitlab
# rubocop:disable Rails/Output
def create_gitaly_configuration(dir, storage_paths, force: false)
- config_path = File.join(dir, 'config.toml')
+ config_path = File.join(dir, "config.toml")
FileUtils.rm_f(config_path) if force
File.open(config_path, File::WRONLY | File::CREAT | File::EXCL) do |f|
diff --git a/lib/gitlab/shard_health_cache.rb b/lib/gitlab/shard_health_cache.rb
index 6612347438e..dca3ab942a5 100644
--- a/lib/gitlab/shard_health_cache.rb
+++ b/lib/gitlab/shard_health_cache.rb
@@ -2,7 +2,7 @@
module Gitlab
class ShardHealthCache
- HEALTHY_SHARDS_KEY = 'gitlab-healthy-shards'.freeze
+ HEALTHY_SHARDS_KEY = "gitlab-healthy-shards"
HEALTHY_SHARDS_TIMEOUT = 300
# Clears the Redis set storing the list of healthy shards
diff --git a/lib/gitlab/shell.rb b/lib/gitlab/shell.rb
index 40b641b8317..c1ba80c9cbc 100644
--- a/lib/gitlab/shell.rb
+++ b/lib/gitlab/shell.rb
@@ -2,15 +2,15 @@
# Gitaly note: SSH key operations are not part of Gitaly so will never be migrated.
-require 'securerandom'
+require "securerandom"
module Gitlab
class Shell
- GITLAB_SHELL_ENV_VARS = %w(GIT_TERMINAL_PROMPT).freeze
+ GITLAB_SHELL_ENV_VARS = %w[GIT_TERMINAL_PROMPT].freeze
Error = Class.new(StandardError)
- KeyAdder = Struct.new(:io) do
+ KeyAdder = Struct.new(:io) {
def add_key(id, key)
key = Gitlab::Shell.strip_key(key)
# Newline and tab are part of the 'protocol' used to transmit id+key to the other end
@@ -20,7 +20,7 @@ module Gitlab
io.puts("#{id}\t#{key}")
end
- end
+ }
class << self
def secret_token
@@ -30,18 +30,18 @@ module Gitlab
end
def ensure_secret_token!
- return if File.exist?(File.join(Gitlab.config.gitlab_shell.path, '.gitlab_shell_secret'))
+ return if File.exist?(File.join(Gitlab.config.gitlab_shell.path, ".gitlab_shell_secret"))
generate_and_link_secret_token
end
def version_required
@version_required ||= File.read(Rails.root
- .join('GITLAB_SHELL_VERSION')).strip
+ .join("GITLAB_SHELL_VERSION")).strip
end
def strip_key(key)
- key.split(/[ ]+/)[0, 2].join(' ')
+ key.split(/[ ]+/)[0, 2].join(" ")
end
private
@@ -57,7 +57,7 @@ module Gitlab
File.write(secret_file, @secret_token)
end
- link_path = File.join(shell_path, '.gitlab_shell_secret')
+ link_path = File.join(shell_path, ".gitlab_shell_secret")
if File.exist?(shell_path) && !File.exist?(link_path)
FileUtils.symlink(secret_file, link_path)
end
@@ -84,12 +84,12 @@ module Gitlab
#
def create_repository(storage, disk_path, gl_project_path)
relative_path = disk_path.dup
- relative_path << '.git' unless relative_path.end_with?('.git')
+ relative_path << ".git" unless relative_path.end_with?(".git")
# During creation of a repository, gl_repository may not be known
# because that depends on a yet-to-be assigned project ID in the
# database (e.g. project-1234), so for now it is blank.
- repository = Gitlab::Git::Repository.new(storage, relative_path, '', gl_project_path)
+ repository = Gitlab::Git::Repository.new(storage, relative_path, "", gl_project_path)
wrapped_gitaly_errors { repository.gitaly_repository_client.create_repository }
true
@@ -116,7 +116,7 @@ module Gitlab
# import_repository("nfs-file06", "gitlab/gitlab-ci", "https://gitlab.com/gitlab-org/gitlab-test.git")
#
def import_repository(storage, name, url, gl_project_path)
- if url.start_with?('.', '/')
+ if url.start_with?(".", "/")
raise Error.new("don't use disk paths with import_repository: #{url.inspect}")
end
@@ -179,10 +179,10 @@ module Gitlab
# add_key("key-42", "sha-rsa ...")
#
def add_key(key_id, key_content)
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
gitlab_shell_fast_execute([gitlab_shell_keys_path,
- 'add-key', key_id, self.class.strip_key(key_content)])
+ "add-key", key_id, self.class.strip_key(key_content),])
end
# Batch-add keys to authorized_keys
@@ -190,9 +190,9 @@ module Gitlab
# Ex.
# batch_add_keys { |adder| adder.add_key("key-42", "sha-rsa ...") }
def batch_add_keys(&block)
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
- IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys), 'w') do |io|
+ IO.popen(%W[#{gitlab_shell_path}/bin/gitlab-keys batch-add-keys], "w") do |io|
yield(KeyAdder.new(io))
end
end
@@ -203,9 +203,9 @@ module Gitlab
# remove_key("key-342", "sha-rsa ...")
#
def remove_key(key_id, key_content = nil)
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
- args = [gitlab_shell_keys_path, 'rm-key', key_id]
+ args = [gitlab_shell_keys_path, "rm-key", key_id]
args << key_content if key_content
gitlab_shell_fast_execute(args)
end
@@ -216,9 +216,9 @@ module Gitlab
# remove_all_keys
#
def remove_all_keys
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
- gitlab_shell_fast_execute([gitlab_shell_keys_path, 'clear'])
+ gitlab_shell_fast_execute([gitlab_shell_keys_path, "clear"])
end
# Remove ssh keys from gitlab shell that are not in the DB
@@ -228,7 +228,7 @@ module Gitlab
#
# rubocop: disable CodeReuse/ActiveRecord
def remove_keys_not_found_in_db
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
Rails.logger.info("Removing keys not found in DB")
@@ -253,7 +253,7 @@ module Gitlab
# batch_read_key_ids { |batch| keys = Key.where(id: batch) }
#
def batch_read_key_ids(batch_size: 100, &block)
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
list_key_ids do |key_id_stream|
key_id_stream.lazy.each_slice(batch_size) do |lines|
@@ -269,9 +269,9 @@ module Gitlab
# list_key_ids
#
def list_key_ids(&block)
- return unless self.authorized_keys_enabled?
+ return unless authorized_keys_enabled?
- IO.popen(%W(#{gitlab_shell_path}/bin/gitlab-keys list-key-ids), &block)
+ IO.popen(%W[#{gitlab_shell_path}/bin/gitlab-keys list-key-ids], &block)
end
# Add empty directory for storing repositories
@@ -299,7 +299,7 @@ module Gitlab
rescue GRPC::InvalidArgument => e
raise ArgumentError, e.message
end
- alias_method :rm_directory, :rm_namespace
+ alias rm_directory rm_namespace
# Move namespace directory inside repositories storage
#
@@ -309,11 +309,11 @@ module Gitlab
def mv_namespace(storage, old_name, new_name)
Gitlab::GitalyClient::NamespaceService.new(storage).rename(old_name, new_name)
rescue GRPC::InvalidArgument => e
- Gitlab::Sentry.track_acceptable_exception(e, extra: { old_name: old_name, new_name: new_name, storage: storage })
+ Gitlab::Sentry.track_acceptable_exception(e, extra: {old_name: old_name, new_name: new_name, storage: storage})
false
end
- alias_method :mv_directory, :mv_namespace # Note: ShellWorker uses this alias
+ alias mv_directory mv_namespace # Note: ShellWorker uses this alias
def url_to_repo(path)
Gitlab.config.gitlab_shell.ssh_path_prefix + "#{path}.git"
@@ -341,7 +341,7 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord
def hooks_path
- File.join(gitlab_shell_path, 'hooks')
+ File.join(gitlab_shell_path, "hooks")
end
protected
@@ -361,11 +361,11 @@ module Gitlab
end
def gitlab_shell_projects_path
- File.join(gitlab_shell_path, 'bin', 'gitlab-projects')
+ File.join(gitlab_shell_path, "bin", "gitlab-projects")
end
def gitlab_shell_keys_path
- File.join(gitlab_shell_path, 'bin', 'gitlab-keys')
+ File.join(gitlab_shell_path, "bin", "gitlab-keys")
end
def authorized_keys_enabled?
@@ -421,7 +421,7 @@ module Gitlab
def initialize(shard_name, repository_relative_path, gl_project_path)
@shard_name = shard_name
@repository_relative_path = repository_relative_path
- @output = ''
+ @output = ""
@gl_project_path = gl_project_path
end
diff --git a/lib/gitlab/sherlock.rb b/lib/gitlab/sherlock.rb
index a1471c9de47..725929d01f5 100644
--- a/lib/gitlab/sherlock.rb
+++ b/lib/gitlab/sherlock.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module Gitlab
module Sherlock
@@ -11,11 +11,11 @@ module Gitlab
end
def self.enabled?
- Rails.env.development? && !!ENV['ENABLE_SHERLOCK']
+ Rails.env.development? && !!ENV["ENABLE_SHERLOCK"]
end
def self.enable_line_profiler?
- RUBY_ENGINE == 'ruby'
+ RUBY_ENGINE == "ruby"
end
end
end
diff --git a/lib/gitlab/sherlock/collection.rb b/lib/gitlab/sherlock/collection.rb
index ce3a376cf75..01074cc542b 100644
--- a/lib/gitlab/sherlock/collection.rb
+++ b/lib/gitlab/sherlock/collection.rb
@@ -19,7 +19,7 @@ module Gitlab
synchronize { @transactions << transaction }
end
- alias_method :<<, :add
+ alias << add
def each(&block)
synchronize { @transactions.each(&block) }
diff --git a/lib/gitlab/sherlock/file_sample.rb b/lib/gitlab/sherlock/file_sample.rb
index 604b6df12cc..7b6fc34d997 100644
--- a/lib/gitlab/sherlock/file_sample.rb
+++ b/lib/gitlab/sherlock/file_sample.rb
@@ -18,7 +18,7 @@ module Gitlab
end
def relative_path
- @relative_path ||= @file.gsub(%r{^#{Rails.root.to_s}/?}, '')
+ @relative_path ||= @file.gsub(%r{^#{Rails.root.to_s}/?}, "")
end
def to_param
diff --git a/lib/gitlab/sherlock/line_profiler.rb b/lib/gitlab/sherlock/line_profiler.rb
index 209ba784f9c..aa7e1afc386 100644
--- a/lib/gitlab/sherlock/line_profiler.rb
+++ b/lib/gitlab/sherlock/line_profiler.rb
@@ -36,13 +36,13 @@ module Gitlab
profile_mri(&block)
else
raise NotImplementedError,
- 'Line profiling is not supported on this platform'
+ "Line profiling is not supported on this platform"
end
end
# Profiles the given block using rblineprof (MRI only).
def profile_mri
- require 'rblineprof'
+ require "rblineprof"
retval = nil
samples = lineprof(/^#{Rails.root.to_s}/) { retval = yield }
@@ -93,7 +93,7 @@ module Gitlab
end
def mri?
- RUBY_ENGINE == 'ruby'
+ RUBY_ENGINE == "ruby"
end
end
end
diff --git a/lib/gitlab/sherlock/middleware.rb b/lib/gitlab/sherlock/middleware.rb
index 747cb0f9142..5e504fb5760 100644
--- a/lib/gitlab/sherlock/middleware.rb
+++ b/lib/gitlab/sherlock/middleware.rb
@@ -31,12 +31,12 @@ module Gitlab
end
def instrument?(env)
- !!(env['HTTP_ACCEPT'] =~ CONTENT_TYPES &&
- env['REQUEST_URI'] !~ IGNORE_PATHS)
+ !!(env["HTTP_ACCEPT"] =~ CONTENT_TYPES &&
+ env["REQUEST_URI"] !~ IGNORE_PATHS)
end
def transaction_from_env(env)
- Transaction.new(env['REQUEST_METHOD'], env['REQUEST_URI'])
+ Transaction.new(env["REQUEST_METHOD"], env["REQUEST_URI"])
end
end
end
diff --git a/lib/gitlab/sherlock/query.rb b/lib/gitlab/sherlock/query.rb
index 11561eec32a..8ce2b00dd31 100644
--- a/lib/gitlab/sherlock/query.rb
+++ b/lib/gitlab/sherlock/query.rb
@@ -45,11 +45,11 @@ module Gitlab
@query = query
@started_at = started_at
@finished_at = finished_at
- @backtrace = caller_locations.map do |loc|
+ @backtrace = caller_locations.map { |loc|
Location.from_ruby_location(loc)
- end
+ }
- unless @query.end_with?(';')
+ unless @query.end_with?(";")
@query = "#{@query};"
end
end
diff --git a/lib/gitlab/sherlock/transaction.rb b/lib/gitlab/sherlock/transaction.rb
index d04624977dc..a3fbd205faf 100644
--- a/lib/gitlab/sherlock/transaction.rb
+++ b/lib/gitlab/sherlock/transaction.rb
@@ -24,9 +24,9 @@ module Gitlab
def run
@started_at = Time.now
- retval = with_subscriptions do
+ retval = with_subscriptions {
profile_lines { yield }
- end
+ }
@finished_at = Time.now
@@ -88,10 +88,10 @@ module Gitlab
end
def subscribe_to_active_record
- ActiveSupport::Notifications.subscribe('sql.active_record') do |_, start, finish, _, data|
+ ActiveSupport::Notifications.subscribe("sql.active_record") do |_, start, finish, _, data|
next unless same_thread?
- unless data.fetch(:cached, data[:name] == 'CACHE')
+ unless data.fetch(:cached, data[:name] == "CACHE")
track_query(data[:sql].strip, data[:binds], start, finish)
end
end
diff --git a/lib/gitlab/sidekiq_config.rb b/lib/gitlab/sidekiq_config.rb
index 3b8de64913b..e2f02ca2608 100644
--- a/lib/gitlab/sidekiq_config.rb
+++ b/lib/gitlab/sidekiq_config.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'yaml'
-require 'set'
+require "yaml"
+require "set"
module Gitlab
module SidekiqConfig
@@ -12,16 +12,16 @@ module Gitlab
def self.worker_queues(rails_path = Rails.root.to_s)
@worker_queues ||= {}
- @worker_queues[rails_path] ||= QUEUE_CONFIG_PATHS.flat_map do |path|
+ @worker_queues[rails_path] ||= QUEUE_CONFIG_PATHS.flat_map { |path|
full_path = File.join(rails_path, path)
File.exist?(full_path) ? YAML.load_file(full_path) : []
- end
+ }
end
# This method is called by `bin/sidekiq-cluster` in EE, which runs outside
# of bundler/Rails context, so we cannot use any gem or Rails methods.
- def self.expand_queues(queues, all_queues = self.worker_queues)
+ def self.expand_queues(queues, all_queues = worker_queues)
return [] if queues.empty?
queues_set = all_queues.to_set
@@ -38,27 +38,27 @@ module Gitlab
def self.config_queues
@config_queues ||= begin
- config = YAML.load_file(Rails.root.join('config/sidekiq_queues.yml'))
+ config = YAML.load_file(Rails.root.join("config/sidekiq_queues.yml"))
config[:queues].map(&:first)
end
end
def self.cron_workers
- @cron_workers ||= Settings.cron_jobs.map { |job_name, options| options['job_class'].constantize }
+ @cron_workers ||= Settings.cron_jobs.map { |job_name, options| options["job_class"].constantize }
end
def self.workers
- @workers ||= find_workers(Rails.root.join('app', 'workers'))
+ @workers ||= find_workers(Rails.root.join("app", "workers"))
end
def self.find_workers(root)
- concerns = root.join('concerns').to_s
+ concerns = root.join("concerns").to_s
- workers = Dir[root.join('**', '*.rb')]
+ workers = Dir[root.join("**", "*.rb")]
.reject { |path| path.start_with?(concerns) }
workers.map! do |path|
- ns = Pathname.new(path).relative_path_from(root).to_s.gsub('.rb', '')
+ ns = Pathname.new(path).relative_path_from(root).to_s.gsub(".rb", "")
ns.camelize.constantize
end
diff --git a/lib/gitlab/sidekiq_logger.rb b/lib/gitlab/sidekiq_logger.rb
index ce82a6f04bb..d2a8453fc73 100644
--- a/lib/gitlab/sidekiq_logger.rb
+++ b/lib/gitlab/sidekiq_logger.rb
@@ -3,7 +3,7 @@
module Gitlab
class SidekiqLogger < Gitlab::Logger
def self.file_name_noext
- 'sidekiq'
+ "sidekiq"
end
end
end
diff --git a/lib/gitlab/sidekiq_logging/json_formatter.rb b/lib/gitlab/sidekiq_logging/json_formatter.rb
index 88888c5994e..d279955114f 100644
--- a/lib/gitlab/sidekiq_logging/json_formatter.rb
+++ b/lib/gitlab/sidekiq_logging/json_formatter.rb
@@ -6,7 +6,7 @@ module Gitlab
def call(severity, timestamp, progname, data)
output = {
severity: severity,
- time: timestamp.utc.iso8601(3)
+ time: timestamp.utc.iso8601(3),
}
case data
diff --git a/lib/gitlab/sidekiq_logging/structured_logger.rb b/lib/gitlab/sidekiq_logging/structured_logger.rb
index fdc0d518c59..dfb0942a99c 100644
--- a/lib/gitlab/sidekiq_logging/structured_logger.rb
+++ b/lib/gitlab/sidekiq_logging/structured_logger.rb
@@ -25,32 +25,32 @@ module Gitlab
private
def base_message(payload)
- "#{payload['class']} JID-#{payload['jid']}"
+ "#{payload["class"]} JID-#{payload["jid"]}"
end
def log_job_start(started_at, payload)
- payload['message'] = "#{base_message(payload)}: start"
- payload['job_status'] = 'start'
+ payload["message"] = "#{base_message(payload)}: start"
+ payload["job_status"] = "start"
payload
end
def log_job_done(started_at, payload, job_exception = nil)
payload = payload.dup
- payload['duration'] = elapsed(started_at)
- payload['completed_at'] = Time.now.utc
+ payload["duration"] = elapsed(started_at)
+ payload["completed_at"] = Time.now.utc
message = base_message(payload)
if job_exception
- payload['message'] = "#{message}: fail: #{payload['duration']} sec"
- payload['job_status'] = 'fail'
- payload['error_message'] = job_exception.message
- payload['error'] = job_exception.class
- payload['error_backtrace'] = backtrace_cleaner.clean(job_exception.backtrace)
+ payload["message"] = "#{message}: fail: #{payload["duration"]} sec"
+ payload["job_status"] = "fail"
+ payload["error_message"] = job_exception.message
+ payload["error"] = job_exception.class
+ payload["error_backtrace"] = backtrace_cleaner.clean(job_exception.backtrace)
else
- payload['message'] = "#{message}: done: #{payload['duration']} sec"
- payload['job_status'] = 'done'
+ payload["message"] = "#{message}: done: #{payload["duration"]} sec"
+ payload["job_status"] = "done"
end
convert_to_iso8601(payload, DONE_TIMESTAMP_FIELDS)
@@ -62,10 +62,10 @@ module Gitlab
job = job.dup
# Add process id params
- job['pid'] = ::Process.pid
+ job["pid"] = ::Process.pid
- job.delete('args') unless ENV['SIDEKIQ_LOG_ARGUMENTS']
- job['args'] = limited_job_args(job['args']) if job['args']
+ job.delete("args") unless ENV["SIDEKIQ_LOG_ARGUMENTS"]
+ job["args"] = limited_job_args(job["args"]) if job["args"]
convert_to_iso8601(job, START_TIMESTAMP_FIELDS)
@@ -100,13 +100,13 @@ module Gitlab
return unless args.is_a?(Array)
total_length = 0
- limited_args = args.take_while do |arg|
+ limited_args = args.take_while { |arg|
total_length += arg.to_json.length
total_length <= MAXIMUM_JOB_ARGUMENTS_LENGTH
- end
+ }
- limited_args.push('...') if total_length > MAXIMUM_JOB_ARGUMENTS_LENGTH
+ limited_args.push("...") if total_length > MAXIMUM_JOB_ARGUMENTS_LENGTH
limited_args
end
diff --git a/lib/gitlab/sidekiq_middleware/arguments_logger.rb b/lib/gitlab/sidekiq_middleware/arguments_logger.rb
index 2859aa5f4a6..431d4a1280d 100644
--- a/lib/gitlab/sidekiq_middleware/arguments_logger.rb
+++ b/lib/gitlab/sidekiq_middleware/arguments_logger.rb
@@ -4,7 +4,7 @@ module Gitlab
module SidekiqMiddleware
class ArgumentsLogger
def call(worker, job, queue)
- Sidekiq.logger.info "arguments: #{JSON.dump(job['args'])}"
+ Sidekiq.logger.info "arguments: #{JSON.dump(job["args"])}"
yield
end
end
diff --git a/lib/gitlab/sidekiq_middleware/shutdown.rb b/lib/gitlab/sidekiq_middleware/shutdown.rb
index 19f3be83bce..bd3ec3803e5 100644
--- a/lib/gitlab/sidekiq_middleware/shutdown.rb
+++ b/lib/gitlab/sidekiq_middleware/shutdown.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'mutex_m'
+require "mutex_m"
module Gitlab
module SidekiqMiddleware
@@ -8,11 +8,11 @@ module Gitlab
extend Mutex_m
# Default the RSS limit to 0, meaning the MemoryKiller is disabled
- MAX_RSS = (ENV['SIDEKIQ_MEMORY_KILLER_MAX_RSS'] || 0).to_s.to_i
+ MAX_RSS = (ENV["SIDEKIQ_MEMORY_KILLER_MAX_RSS"] || 0).to_s.to_i
# Give Sidekiq 15 minutes of grace time after exceeding the RSS limit
- GRACE_TIME = (ENV['SIDEKIQ_MEMORY_KILLER_GRACE_TIME'] || 15 * 60).to_s.to_i
+ GRACE_TIME = (ENV["SIDEKIQ_MEMORY_KILLER_GRACE_TIME"] || 15 * 60).to_s.to_i
# Wait 30 seconds for running jobs to finish during graceful shutdown
- SHUTDOWN_WAIT = (ENV['SIDEKIQ_MEMORY_KILLER_SHUTDOWN_WAIT'] || 30).to_s.to_i
+ SHUTDOWN_WAIT = (ENV["SIDEKIQ_MEMORY_KILLER_SHUTDOWN_WAIT"] || 30).to_s.to_i
# This exception can be used to request that the middleware start shutting down Sidekiq
WantShutdown = Class.new(StandardError)
@@ -70,21 +70,21 @@ module Gitlab
def do_shutdown(worker, job, shutdown_exception)
Sidekiq.logger.warn "Sidekiq worker PID-#{pid} shutting down because of #{shutdown_exception} after job "\
- "#{worker.class} JID-#{job['jid']}"
+ "#{worker.class} JID-#{job["jid"]}"
Sidekiq.logger.warn "Sidekiq worker PID-#{pid} will stop fetching new jobs in #{GRACE_TIME} seconds, and will be shut down #{SHUTDOWN_WAIT} seconds later"
# Wait `GRACE_TIME` to give the memory intensive job time to finish.
# Then, tell Sidekiq to stop fetching new jobs.
- wait_and_signal(GRACE_TIME, 'SIGTSTP', 'stop fetching new jobs')
+ wait_and_signal(GRACE_TIME, "SIGTSTP", "stop fetching new jobs")
# Wait `SHUTDOWN_WAIT` to give already fetched jobs time to finish.
# Then, tell Sidekiq to gracefully shut down by giving jobs a few more
# moments to finish, killing and requeuing them if they didn't, and
# then terminating itself.
- wait_and_signal(SHUTDOWN_WAIT, 'SIGTERM', 'gracefully shut down')
+ wait_and_signal(SHUTDOWN_WAIT, "SIGTERM", "gracefully shut down")
# Wait for Sidekiq to shutdown gracefully, and kill it if it didn't.
- wait_and_signal(Sidekiq.options[:timeout] + 2, 'SIGKILL', 'die')
+ wait_and_signal(Sidekiq.options[:timeout] + 2, "SIGKILL", "die")
end
def check_rss!
@@ -97,7 +97,7 @@ module Gitlab
end
def get_rss
- output, status = Gitlab::Popen.popen(%W(ps -o rss= -p #{pid}), Rails.root.to_s)
+ output, status = Gitlab::Popen.popen(%W[ps -o rss= -p #{pid}], Rails.root.to_s)
return 0 unless status.zero?
output.to_i
diff --git a/lib/gitlab/sidekiq_status.rb b/lib/gitlab/sidekiq_status.rb
index 583a970bf4e..867e6d53fdc 100644
--- a/lib/gitlab/sidekiq_status.rb
+++ b/lib/gitlab/sidekiq_status.rb
@@ -18,7 +18,7 @@ module Gitlab
# expire after a certain period of time to prevent storing too many keys in
# Redis.
module SidekiqStatus
- STATUS_KEY = 'gitlab-sidekiq-status:%s'.freeze
+ STATUS_KEY = "gitlab-sidekiq-status:%s"
# The default time (in seconds) after which a status key is expired
# automatically. The default of 30 minutes should be more than sufficient
@@ -50,7 +50,7 @@ module Gitlab
#
# Returns true or false.
def self.all_completed?(job_ids)
- self.num_running(job_ids).zero?
+ num_running(job_ids).zero?
end
# Returns true if the given job is running
@@ -64,7 +64,7 @@ module Gitlab
#
# job_ids - The Sidekiq job IDs to check.
def self.num_running(job_ids)
- responses = self.job_status(job_ids)
+ responses = job_status(job_ids)
responses.select(&:present?).count
end
@@ -73,7 +73,7 @@ module Gitlab
#
# job_ids - The Sidekiq job IDs to check.
def self.num_completed(job_ids)
- job_ids.size - self.num_running(job_ids)
+ job_ids.size - num_running(job_ids)
end
# Returns the job status for each of the given job IDs.
diff --git a/lib/gitlab/sidekiq_status/client_middleware.rb b/lib/gitlab/sidekiq_status/client_middleware.rb
index bfd5038557d..5f2f32eaa41 100644
--- a/lib/gitlab/sidekiq_status/client_middleware.rb
+++ b/lib/gitlab/sidekiq_status/client_middleware.rb
@@ -4,9 +4,9 @@ module Gitlab
module SidekiqStatus
class ClientMiddleware
def call(_, job, _, _)
- status_expiration = job['status_expiration'] || Gitlab::SidekiqStatus::DEFAULT_EXPIRATION
+ status_expiration = job["status_expiration"] || Gitlab::SidekiqStatus::DEFAULT_EXPIRATION
- Gitlab::SidekiqStatus.set(job['jid'], status_expiration)
+ Gitlab::SidekiqStatus.set(job["jid"], status_expiration)
yield
end
end
diff --git a/lib/gitlab/sidekiq_status/server_middleware.rb b/lib/gitlab/sidekiq_status/server_middleware.rb
index 01bc58fd2be..e3215b0174b 100644
--- a/lib/gitlab/sidekiq_status/server_middleware.rb
+++ b/lib/gitlab/sidekiq_status/server_middleware.rb
@@ -6,7 +6,7 @@ module Gitlab
def call(worker, job, queue)
ret = yield
- Gitlab::SidekiqStatus.unset(job['jid'])
+ Gitlab::SidekiqStatus.unset(job["jid"])
ret
end
diff --git a/lib/gitlab/sidekiq_versioning.rb b/lib/gitlab/sidekiq_versioning.rb
index 8164a5a9d7a..288640e9706 100644
--- a/lib/gitlab/sidekiq_versioning.rb
+++ b/lib/gitlab/sidekiq_versioning.rb
@@ -15,7 +15,7 @@ module Gitlab
Sidekiq.redis do |conn|
conn.pipelined do
queues.each do |queue|
- conn.sadd('queues', queue)
+ conn.sadd("queues", queue)
end
end
end
diff --git a/lib/gitlab/slash_commands/command.rb b/lib/gitlab/slash_commands/command.rb
index 7c963fcf38a..6cc9ebf158e 100644
--- a/lib/gitlab/slash_commands/command.rb
+++ b/lib/gitlab/slash_commands/command.rb
@@ -10,7 +10,7 @@ module Gitlab
Gitlab::SlashCommands::IssueSearch,
Gitlab::SlashCommands::IssueMove,
Gitlab::SlashCommands::Deploy,
- Gitlab::SlashCommands::Run
+ Gitlab::SlashCommands::Run,
]
end
@@ -32,9 +32,9 @@ module Gitlab
def match_command
match = nil
service =
- available_commands.find do |klass|
+ available_commands.find { |klass|
match = klass.match(params[:text])
- end
+ }
[service, match]
end
diff --git a/lib/gitlab/slash_commands/deploy.rb b/lib/gitlab/slash_commands/deploy.rb
index 157d924f99f..f33a5ba5b5d 100644
--- a/lib/gitlab/slash_commands/deploy.rb
+++ b/lib/gitlab/slash_commands/deploy.rb
@@ -8,7 +8,7 @@ module Gitlab
end
def self.help_message
- 'deploy <environment> to <target-environment>'
+ "deploy <environment> to <target-environment>"
end
def self.available?(project)
@@ -43,9 +43,9 @@ module Gitlab
environment = project.environments.find_by(name: from)
return unless environment
- actions = environment.actions_for(to).select do |action|
+ actions = environment.actions_for(to).select { |action|
action.starts_environment?
- end
+ }
if actions.many?
actions.find { |action| action.name == to.to_s }
diff --git a/lib/gitlab/slash_commands/help.rb b/lib/gitlab/slash_commands/help.rb
index dbe15baa3d7..0688bbd5fa4 100644
--- a/lib/gitlab/slash_commands/help.rb
+++ b/lib/gitlab/slash_commands/help.rb
@@ -11,7 +11,7 @@ module Gitlab
end
def self.help_message
- 'help'
+ "help"
end
def self.allowed?(_project, _user)
diff --git a/lib/gitlab/slash_commands/issue_move.rb b/lib/gitlab/slash_commands/issue_move.rb
index d2f1f130b38..42a5de9a567 100644
--- a/lib/gitlab/slash_commands/issue_move.rb
+++ b/lib/gitlab/slash_commands/issue_move.rb
@@ -14,7 +14,7 @@ module Gitlab
end
def self.help_message
- 'issue move <issue_id> (to)? <project_path>'
+ "issue move <issue_id> (to)? <project_path>"
end
def self.allowed?(project, user)
@@ -30,7 +30,7 @@ module Gitlab
end
new_issue = Issues::MoveService.new(project, current_user)
- .execute(old_issue, target_project)
+ .execute(old_issue, target_project)
presenter(new_issue).present(old_issue)
rescue Issues::MoveService::MoveError => e
diff --git a/lib/gitlab/slash_commands/issue_new.rb b/lib/gitlab/slash_commands/issue_new.rb
index 48379031537..6faa19740f2 100644
--- a/lib/gitlab/slash_commands/issue_new.rb
+++ b/lib/gitlab/slash_commands/issue_new.rb
@@ -10,7 +10,7 @@ module Gitlab
end
def self.help_message
- 'issue new <title> *`⇧ Shift`*+*`↵ Enter`* <description>'
+ "issue new <title> *`⇧ Shift`*+*`↵ Enter`* <description>"
end
def self.allowed?(project, user)
diff --git a/lib/gitlab/slash_commands/presenters/base.rb b/lib/gitlab/slash_commands/presenters/base.rb
index 73814aa180f..ca3aab9d67e 100644
--- a/lib/gitlab/slash_commands/presenters/base.rb
+++ b/lib/gitlab/slash_commands/presenters/base.rb
@@ -31,7 +31,7 @@ module Gitlab
def ephemeral_response(message)
response = {
response_type: :ephemeral,
- status: 200
+ status: 200,
}.merge(message)
format_response(response)
@@ -40,7 +40,7 @@ module Gitlab
def in_channel_response(message)
response = {
response_type: :in_channel,
- status: 200
+ status: 200,
}.merge(message)
format_response(response)
@@ -69,7 +69,7 @@ module Gitlab
[
@resource.project.namespace.becomes(Namespace),
@resource.project,
- @resource
+ @resource,
]
)
end
diff --git a/lib/gitlab/slash_commands/presenters/help.rb b/lib/gitlab/slash_commands/presenters/help.rb
index 480d7aa6a30..35c27530060 100644
--- a/lib/gitlab/slash_commands/presenters/help.rb
+++ b/lib/gitlab/slash_commands/presenters/help.rb
@@ -13,7 +13,7 @@ module Gitlab
def help_message(trigger, text)
return "No commands available :thinking_face:" unless @resource.present?
- if text.start_with?('help')
+ if text.start_with?("help")
header_with_list("Available commands", full_commands(trigger))
else
header_with_list("Unknown command, these commands are available", full_commands(trigger))
diff --git a/lib/gitlab/slash_commands/presenters/issue_base.rb b/lib/gitlab/slash_commands/presenters/issue_base.rb
index b6db103b82b..8f7ed78234d 100644
--- a/lib/gitlab/slash_commands/presenters/issue_base.rb
+++ b/lib/gitlab/slash_commands/presenters/issue_base.rb
@@ -5,11 +5,11 @@ module Gitlab
module Presenters
module IssueBase
def color(issuable)
- issuable.open? ? '#38ae67' : '#d22852'
+ issuable.open? ? "#38ae67" : "#d22852"
end
def status_text(issuable)
- issuable.open? ? 'Open' : 'Closed'
+ issuable.open? ? "Open" : "Closed"
end
def project
@@ -25,18 +25,18 @@ module Gitlab
{
title: "Assignee",
value: resource.assignees.any? ? resource.assignees.first.name : "_None_",
- short: true
+ short: true,
},
{
title: "Milestone",
value: resource.milestone ? resource.milestone.title : "_None_",
- short: true
+ short: true,
},
{
title: "Labels",
- value: resource.labels.any? ? resource.label_names.join(', ') : "_None_",
- short: true
- }
+ value: resource.labels.any? ? resource.label_names.join(", ") : "_None_",
+ short: true,
+ },
]
end
diff --git a/lib/gitlab/slash_commands/presenters/issue_move.rb b/lib/gitlab/slash_commands/presenters/issue_move.rb
index ca0644ede95..fb16aa3a9c7 100644
--- a/lib/gitlab/slash_commands/presenters/issue_move.rb
+++ b/lib/gitlab/slash_commands/presenters/issue_move.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
# frozen_string_literal: true
module Gitlab
@@ -23,22 +22,22 @@ module Gitlab
{
attachments: [
{
- title: "#{@resource.title} · #{@resource.to_reference}",
- title_link: resource_url,
- author_name: author.name,
- author_icon: author.avatar_url,
- fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
- pretext: pretext(old_issue),
- color: color(@resource),
- fields: fields,
+ title: "#{@resource.title} · #{@resource.to_reference}",
+ title_link: resource_url,
+ author_name: author.name,
+ author_icon: author.avatar_url,
+ fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
+ pretext: pretext(old_issue),
+ color: color(@resource),
+ fields: fields,
mrkdwn_in: [
:title,
:pretext,
:text,
- :fields
- ]
- }
- ]
+ :fields,
+ ],
+ },
+ ],
}
end
diff --git a/lib/gitlab/slash_commands/presenters/issue_new.rb b/lib/gitlab/slash_commands/presenters/issue_new.rb
index ac78745ae70..aff1ae53bfd 100644
--- a/lib/gitlab/slash_commands/presenters/issue_new.rb
+++ b/lib/gitlab/slash_commands/presenters/issue_new.rb
@@ -16,22 +16,22 @@ module Gitlab
{
attachments: [
{
- title: "#{@resource.title} · #{@resource.to_reference}",
- title_link: resource_url,
- author_name: author.name,
- author_icon: author.avatar_url,
- fallback: "New issue #{@resource.to_reference}: #{@resource.title}",
- pretext: pretext,
- color: color(@resource),
- fields: fields,
+ title: "#{@resource.title} · #{@resource.to_reference}",
+ title_link: resource_url,
+ author_name: author.name,
+ author_icon: author.avatar_url,
+ fallback: "New issue #{@resource.to_reference}: #{@resource.title}",
+ pretext: pretext,
+ color: color(@resource),
+ fields: fields,
mrkdwn_in: [
:title,
:pretext,
:text,
- :fields
- ]
- }
- ]
+ :fields,
+ ],
+ },
+ ],
}
end
diff --git a/lib/gitlab/slash_commands/presenters/issue_search.rb b/lib/gitlab/slash_commands/presenters/issue_search.rb
index 0d497efec0e..7fa7894fc51 100644
--- a/lib/gitlab/slash_commands/presenters/issue_search.rb
+++ b/lib/gitlab/slash_commands/presenters/issue_search.rb
@@ -8,12 +8,12 @@ module Gitlab
def present
text = if @resource.count >= 5
- "Here are the first 5 issues I found:"
- elsif @resource.one?
- "Here is the only issue I found:"
- else
- "Here are the #{@resource.count} issues I found:"
- end
+ "Here are the first 5 issues I found:"
+ elsif @resource.one?
+ "Here is the only issue I found:"
+ else
+ "Here are the #{@resource.count} issues I found:"
+ end
ephemeral_response(text: text, attachments: attachments)
end
@@ -30,8 +30,8 @@ module Gitlab
text: "#{url} · #{issue.title} (#{status_text(issue)})",
mrkdwn_in: [
- :text
- ]
+ :text,
+ ],
}
end
end
diff --git a/lib/gitlab/slash_commands/presenters/issue_show.rb b/lib/gitlab/slash_commands/presenters/issue_show.rb
index 5a2c79a928e..d0ff981673a 100644
--- a/lib/gitlab/slash_commands/presenters/issue_show.rb
+++ b/lib/gitlab/slash_commands/presenters/issue_show.rb
@@ -20,22 +20,22 @@ module Gitlab
{
attachments: [
{
- title: "#{@resource.title} · #{@resource.to_reference}",
- title_link: resource_url,
- author_name: author.name,
- author_icon: author.avatar_url,
- fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
- pretext: pretext,
- text: text,
- color: color(@resource),
- fields: fields,
+ title: "#{@resource.title} · #{@resource.to_reference}",
+ title_link: resource_url,
+ author_name: author.name,
+ author_icon: author.avatar_url,
+ fallback: "Issue #{@resource.to_reference}: #{@resource.title}",
+ pretext: pretext,
+ text: text,
+ color: color(@resource),
+ fields: fields,
mrkdwn_in: [
:pretext,
:text,
- :fields
- ]
- }
- ]
+ :fields,
+ ],
+ },
+ ],
}
end
diff --git a/lib/gitlab/slash_commands/presenters/run.rb b/lib/gitlab/slash_commands/presenters/run.rb
index c4bbc231464..7960c4b2851 100644
--- a/lib/gitlab/slash_commands/presenters/run.rb
+++ b/lib/gitlab/slash_commands/presenters/run.rb
@@ -17,13 +17,13 @@ module Gitlab
# rubocop: enable CodeReuse/ActiveRecord
def unsupported_chat_service
- ephemeral_response(text: 'Sorry, this chat service is currently not supported by GitLab ChatOps.')
+ ephemeral_response(text: "Sorry, this chat service is currently not supported by GitLab ChatOps.")
end
def failed_to_schedule(command)
ephemeral_response(
- text: 'The command could not be scheduled. Make sure that your ' \
- 'project has a .gitlab-ci.yml that defines a job with the ' \
+ text: "The command could not be scheduled. Make sure that your " \
+ "project has a .gitlab-ci.yml that defines a job with the " \
"name #{command.inspect}"
)
end
diff --git a/lib/gitlab/slash_commands/run.rb b/lib/gitlab/slash_commands/run.rb
index 10a545e28ac..df54030235a 100644
--- a/lib/gitlab/slash_commands/run.rb
+++ b/lib/gitlab/slash_commands/run.rb
@@ -9,7 +9,7 @@ module Gitlab
end
def self.help_message
- 'run <command> <arguments>'
+ "run <command> <arguments>"
end
def self.available?(project)
diff --git a/lib/gitlab/snippet_search_results.rb b/lib/gitlab/snippet_search_results.rb
index e360b552f89..422799f9d43 100644
--- a/lib/gitlab/snippet_search_results.rb
+++ b/lib/gitlab/snippet_search_results.rb
@@ -13,9 +13,9 @@ module Gitlab
def objects(scope, page = nil)
case scope
- when 'snippet_titles'
+ when "snippet_titles"
snippet_titles.page(page).per(per_page)
- when 'snippet_blobs'
+ when "snippet_blobs"
snippet_blobs.page(page).per(per_page)
else
super(scope, nil, false)
@@ -34,18 +34,18 @@ module Gitlab
# rubocop: disable CodeReuse/ActiveRecord
def snippet_titles
- limit_snippets.search(query).order('updated_at DESC').includes(:author)
+ limit_snippets.search(query).order("updated_at DESC").includes(:author)
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def snippet_blobs
- limit_snippets.search_code(query).order('updated_at DESC').includes(:author)
+ limit_snippets.search_code(query).order("updated_at DESC").includes(:author)
end
# rubocop: enable CodeReuse/ActiveRecord
def default_scope
- 'snippet_blobs'
+ "snippet_blobs"
end
end
end
diff --git a/lib/gitlab/sql/glob.rb b/lib/gitlab/sql/glob.rb
index f3421bd95d2..40973210c59 100644
--- a/lib/gitlab/sql/glob.rb
+++ b/lib/gitlab/sql/glob.rb
@@ -10,9 +10,9 @@ module Gitlab
def to_like(pattern)
<<~SQL
REPLACE(REPLACE(REPLACE(#{pattern},
- #{q('%')}, #{q('\\%')}),
- #{q('_')}, #{q('\\_')}),
- #{q('*')}, #{q('%')})
+ #{q("%")}, #{q('\\%')}),
+ #{q("_")}, #{q('\\_')}),
+ #{q("*")}, #{q("%")})
SQL
end
diff --git a/lib/gitlab/sql/pattern.rb b/lib/gitlab/sql/pattern.rb
index 92388262035..4b019ba4eb9 100644
--- a/lib/gitlab/sql/pattern.rb
+++ b/lib/gitlab/sql/pattern.rb
@@ -44,7 +44,7 @@ module Gitlab
# case insensitive match with the query as a whole
if lower_exact_match
Arel::Nodes::NamedFunction
- .new('LOWER', [arel_table[column]])
+ .new("LOWER", [arel_table[column]])
.eq(query)
else
arel_table[column].matches(sanitize_sql_like(query))
@@ -55,7 +55,7 @@ module Gitlab
def select_fuzzy_words(query)
quoted_words = query.scan(REGEX_QUOTED_WORD)
- query = quoted_words.reduce(query) { |q, quoted_word| q.sub(quoted_word, '') }
+ query = quoted_words.reduce(query) { |q, quoted_word| q.sub(quoted_word, "") }
words = query.split
diff --git a/lib/gitlab/sql/recursive_cte.rb b/lib/gitlab/sql/recursive_cte.rb
index e45ac5d4765..52fbe48eca9 100644
--- a/lib/gitlab/sql/recursive_cte.rb
+++ b/lib/gitlab/sql/recursive_cte.rb
@@ -48,7 +48,7 @@ module Gitlab
#
# alias_table - The Arel table to use as the alias.
def alias_to(alias_table)
- Arel::Nodes::As.new(table, Arel::Table.new(alias_table.name.tr('.', '_')))
+ Arel::Nodes::As.new(table, Arel::Table.new(alias_table.name.tr(".", "_")))
end
# Applies the CTE to the given relation, returning a new one that will
diff --git a/lib/gitlab/sql/union.rb b/lib/gitlab/sql/union.rb
index f05592fc3a3..4ec399d5685 100644
--- a/lib/gitlab/sql/union.rb
+++ b/lib/gitlab/sql/union.rb
@@ -24,19 +24,19 @@ module Gitlab
# aren't incremented properly when joining relations together this way.
# By using "unprepared_statements" we remove the usage of placeholders
# (thus fixing this problem), at a slight performance cost.
- fragments = ActiveRecord::Base.connection.unprepared_statement do
+ fragments = ActiveRecord::Base.connection.unprepared_statement {
@relations.map { |rel| rel.reorder(nil).to_sql }.reject(&:blank?)
- end
+ }
if fragments.any?
fragments.join("\n#{union_keyword}\n")
else
- 'NULL'
+ "NULL"
end
end
def union_keyword
- @remove_duplicates ? 'UNION' : 'UNION ALL'
+ @remove_duplicates ? "UNION" : "UNION ALL"
end
end
end
diff --git a/lib/gitlab/ssh_public_key.rb b/lib/gitlab/ssh_public_key.rb
index 6df54852d02..a34c177338b 100644
--- a/lib/gitlab/ssh_public_key.rb
+++ b/lib/gitlab/ssh_public_key.rb
@@ -8,7 +8,7 @@ module Gitlab
Technology.new(:rsa, OpenSSL::PKey::RSA, [1024, 2048, 3072, 4096]),
Technology.new(:dsa, OpenSSL::PKey::DSA, [1024, 2048, 3072]),
Technology.new(:ecdsa, OpenSSL::PKey::EC, [256, 384, 521]),
- Technology.new(:ed25519, Net::SSH::Authentication::ED25519::PubKey, [256])
+ Technology.new(:ed25519, Net::SSH::Authentication::ED25519::PubKey, [256]),
].freeze
def self.technology(name)
@@ -32,7 +32,7 @@ module Gitlab
content << part
if Gitlab::SSHPublicKey.new(content).valid?
- break [content, parts[index + 1]].compact.join(' ') # Add the comment part if present
+ break [content, parts[index + 1]].compact.join(" ") # Add the comment part if present
elsif parts.size == index + 1 # return original content if we've reached the last element
break key_content
end
diff --git a/lib/gitlab/string_range_marker.rb b/lib/gitlab/string_range_marker.rb
index 780fe4c7725..ae7d7c9ffe6 100644
--- a/lib/gitlab/string_range_marker.rb
+++ b/lib/gitlab/string_range_marker.rb
@@ -58,8 +58,8 @@ module Gitlab
# The raw and rich lines are the same except for HTML tags,
# so skip over any `<...>` segment
- while rich_char == '<'
- until rich_char == '>'
+ while rich_char == "<"
+ until rich_char == ">"
rich_pos += 1
rich_char = rich_line[rich_pos]
end
@@ -69,9 +69,9 @@ module Gitlab
end
# multi-char HTML entities in the rich line correspond to a single character in the raw line
- if rich_char == '&'
+ if rich_char == "&"
multichar_mapping = [rich_pos]
- until rich_char == ';'
+ until rich_char == ";"
rich_pos += 1
multichar_mapping << rich_pos
rich_char = rich_line[rich_pos]
diff --git a/lib/gitlab/task_helpers.rb b/lib/gitlab/task_helpers.rb
index 8532845f3cb..6d74d700d46 100644
--- a/lib/gitlab/task_helpers.rb
+++ b/lib/gitlab/task_helpers.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'rainbow/ext/string'
-require_dependency 'gitlab/utils/strong_memoize'
+require "rainbow/ext/string"
+require_dependency "gitlab/utils/strong_memoize"
# rubocop:disable Rails/Output
module Gitlab
@@ -24,7 +24,7 @@ module Gitlab
# Returns "yes" the user chose to continue
# Raises Gitlab::TaskAbortedByUserError if the user chose *not* to continue
def ask_to_continue
- answer = prompt("Do you want to continue (yes/no)? ".color(:blue), %w{yes no})
+ answer = prompt("Do you want to continue (yes/no)? ".color(:blue), %w[yes no])
raise Gitlab::TaskAbortedByUserError unless answer == "yes"
end
@@ -33,18 +33,18 @@ module Gitlab
# It will primarily use lsb_relase to determine the OS.
# It has fallbacks to Debian, SuSE, OS X and systems running systemd.
def os_name
- os_name = run_command(%w(lsb_release -irs))
+ os_name = run_command(%w[lsb_release -irs])
os_name ||=
- if File.readable?('/etc/system-release')
- File.read('/etc/system-release')
- elsif File.readable?('/etc/debian_version')
- "Debian #{File.read('/etc/debian_version')}"
- elsif File.readable?('/etc/SuSE-release')
- File.read('/etc/SuSE-release')
- elsif os_x_version = run_command(%w(sw_vers -productVersion))
+ if File.readable?("/etc/system-release")
+ File.read("/etc/system-release")
+ elsif File.readable?("/etc/debian_version")
+ "Debian #{File.read("/etc/debian_version")}"
+ elsif File.readable?("/etc/SuSE-release")
+ File.read("/etc/SuSE-release")
+ elsif os_x_version = run_command(%w[sw_vers -productVersion])
"Mac OS X #{os_x_version}"
- elsif File.readable?('/etc/os-release')
- File.read('/etc/os-release').match(/PRETTY_NAME=\"(.+)\"/)[1]
+ elsif File.readable?("/etc/os-release")
+ File.read("/etc/os-release").match(/PRETTY_NAME=\"(.+)\"/)[1]
end
os_name.try(:squish)
@@ -85,7 +85,7 @@ module Gitlab
output, _ = Gitlab::Popen.popen(command)
output
rescue Errno::ENOENT
- '' # if the command does not exist, return an empty string
+ "" # if the command does not exist, return an empty string
end
# Runs the given command and raises a Gitlab::TaskFailedError exception if
@@ -101,7 +101,7 @@ module Gitlab
end
def uid_for(user_name)
- run_command(%W(id -u #{user_name})).chomp.to_i
+ run_command(%W[id -u #{user_name}]).chomp.to_i
end
def gid_for(group_name)
@@ -116,7 +116,7 @@ module Gitlab
def gitlab_user?
strong_memoize(:is_gitlab_user) do
- current_user = run_command(%w(whoami)).chomp
+ current_user = run_command(%w[whoami]).chomp
current_user == gitlab_user
end
end
@@ -125,7 +125,7 @@ module Gitlab
return if gitlab_user?
strong_memoize(:warned_user_not_gitlab) do
- current_user = run_command(%w(whoami)).chomp
+ current_user = run_command(%w[whoami]).chomp
puts " Warning ".color(:black).background(:yellow)
puts " You are running as user #{current_user.color(:magenta)}, we hope you know what you are doing."
@@ -138,7 +138,7 @@ module Gitlab
def all_repos
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
Gitlab.config.repositories.storages.each_value do |repository_storage|
- IO.popen(%W(find #{repository_storage.legacy_disk_path} -mindepth 2 -type d -name *.git)) do |find|
+ IO.popen(%W[find #{repository_storage.legacy_disk_path} -mindepth 2 -type d -name *.git]) do |find|
find.each_line do |path|
yield path.chomp
end
@@ -154,13 +154,13 @@ module Gitlab
end
def user_home
- Rails.env.test? ? Rails.root.join('tmp/tests') : Gitlab.config.gitlab.user_home
+ Rails.env.test? ? Rails.root.join("tmp/tests") : Gitlab.config.gitlab.user_home
end
def checkout_or_clone_version(version:, repo:, target_dir:)
version =
if version.starts_with?("=")
- version.sub(/\A=/, '') # tag or branch
+ version.sub(/\A=/, "") # tag or branch
else
"v#{version}" # tag
end
diff --git a/lib/gitlab/tcp_checker.rb b/lib/gitlab/tcp_checker.rb
index f37a044b607..651a7ae5dab 100644
--- a/lib/gitlab/tcp_checker.rb
+++ b/lib/gitlab/tcp_checker.rb
@@ -39,7 +39,7 @@ module Gitlab
private
def join_host_port(host, port)
- host = "[#{host}]" if host.include?(':')
+ host = "[#{host}]" if host.include?(":")
"#{host}:#{port}"
end
diff --git a/lib/gitlab/template/base_template.rb b/lib/gitlab/template/base_template.rb
index 0b4cc571dc0..637643332bd 100644
--- a/lib/gitlab/template/base_template.rb
+++ b/lib/gitlab/template/base_template.rb
@@ -14,7 +14,7 @@ module Gitlab
def name
File.basename(@path, self.class.extension)
end
- alias_method :key, :name
+ alias key name
def content
@finder.read(@path)
@@ -28,7 +28,7 @@ module Gitlab
end
def to_json
- { key: key, name: name, content: content }
+ {key: key, name: name, content: content}
end
def <=>(other)
@@ -45,7 +45,7 @@ module Gitlab
end
def find(key, project = nil)
- path = self.finder(project).find(key)
+ path = finder(project).find(key)
path.present? ? new(path, project) : nil
end
@@ -90,13 +90,13 @@ module Gitlab
return [] if project && !project.repository.exists?
if categories.any?
- categories.keys.map do |category|
- files = self.by_category(category, project)
- [category, files.map { |t| { name: t.name } }]
- end.to_h
+ categories.keys.map { |category|
+ files = by_category(category, project)
+ [category, files.map { |t| {name: t.name} }]
+ }.to_h
else
- files = self.all(project)
- files.map { |t| { name: t.name } }
+ files = all(project)
+ files.map { |t| {name: t.name} }
end
end
end
diff --git a/lib/gitlab/template/dockerfile_template.rb b/lib/gitlab/template/dockerfile_template.rb
index 3b516bb862a..34c550cff94 100644
--- a/lib/gitlab/template/dockerfile_template.rb
+++ b/lib/gitlab/template/dockerfile_template.rb
@@ -10,21 +10,21 @@ module Gitlab
class << self
def extension
- '.Dockerfile'
+ ".Dockerfile"
end
def categories
{
- "General" => ''
+ "General" => "",
}
end
def base_dir
- Rails.root.join('vendor/Dockerfile')
+ Rails.root.join("vendor/Dockerfile")
end
def finder(project = nil)
- Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::GlobalTemplateFinder.new(base_dir, extension, categories)
end
end
end
diff --git a/lib/gitlab/template/finders/global_template_finder.rb b/lib/gitlab/template/finders/global_template_finder.rb
index 2dd4b7a4092..b6100f219ce 100644
--- a/lib/gitlab/template/finders/global_template_finder.rb
+++ b/lib/gitlab/template/finders/global_template_finder.rb
@@ -27,7 +27,7 @@ module Gitlab
end
def list_files_for(dir)
- dir = "#{dir}/" unless dir.end_with?('/')
+ dir = "#{dir}/" unless dir.end_with?("/")
Dir.glob(File.join(dir, "*#{@extension}")).select { |f| f =~ self.class.filter_regex(@extension) }
end
diff --git a/lib/gitlab/template/finders/repo_template_finder.rb b/lib/gitlab/template/finders/repo_template_finder.rb
index 8e234148a63..0d3ddf41ede 100644
--- a/lib/gitlab/template/finders/repo_template_finder.rb
+++ b/lib/gitlab/template/finders/repo_template_finder.rb
@@ -40,7 +40,7 @@ module Gitlab
def list_files_for(dir)
return [] unless @commit
- dir = "#{dir}/" unless dir.end_with?('/')
+ dir = "#{dir}/" unless dir.end_with?("/")
entries = @repository.tree(:head, dir).entries
diff --git a/lib/gitlab/template/gitignore_template.rb b/lib/gitlab/template/gitignore_template.rb
index 72a1b7460c2..27318e6e33e 100644
--- a/lib/gitlab/template/gitignore_template.rb
+++ b/lib/gitlab/template/gitignore_template.rb
@@ -5,22 +5,22 @@ module Gitlab
class GitignoreTemplate < BaseTemplate
class << self
def extension
- '.gitignore'
+ ".gitignore"
end
def categories
{
- "Languages" => '',
- "Global" => 'Global'
+ "Languages" => "",
+ "Global" => "Global",
}
end
def base_dir
- Rails.root.join('vendor/gitignore')
+ Rails.root.join("vendor/gitignore")
end
def finder(project = nil)
- Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::GlobalTemplateFinder.new(base_dir, extension, categories)
end
end
end
diff --git a/lib/gitlab/template/gitlab_ci_yml_template.rb b/lib/gitlab/template/gitlab_ci_yml_template.rb
index fbefb5f7f0e..4760304bed9 100644
--- a/lib/gitlab/template/gitlab_ci_yml_template.rb
+++ b/lib/gitlab/template/gitlab_ci_yml_template.rb
@@ -10,27 +10,27 @@ module Gitlab
class << self
def extension
- '.gitlab-ci.yml'
+ ".gitlab-ci.yml"
end
def categories
{
- 'General' => '',
- 'Pages' => 'Pages',
- 'Auto deploy' => 'autodeploy'
+ "General" => "",
+ "Pages" => "Pages",
+ "Auto deploy" => "autodeploy",
}
end
def base_dir
- Rails.root.join('lib/gitlab/ci/templates')
+ Rails.root.join("lib/gitlab/ci/templates")
end
def finder(project = nil)
- Gitlab::Template::Finders::GlobalTemplateFinder.new(self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::GlobalTemplateFinder.new(base_dir, extension, categories)
end
def dropdown_names(context)
- categories = context == 'autodeploy' ? ['Auto deploy'] : %w(General Pages)
+ categories = context == "autodeploy" ? ["Auto deploy"] : %w[General Pages]
super().slice(*categories)
end
end
diff --git a/lib/gitlab/template/issue_template.rb b/lib/gitlab/template/issue_template.rb
index 01b191733d4..a1e5c53be94 100644
--- a/lib/gitlab/template/issue_template.rb
+++ b/lib/gitlab/template/issue_template.rb
@@ -5,15 +5,15 @@ module Gitlab
class IssueTemplate < BaseTemplate
class << self
def extension
- '.md'
+ ".md"
end
def base_dir
- '.gitlab/issue_templates/'
+ ".gitlab/issue_templates/"
end
def finder(project)
- Gitlab::Template::Finders::RepoTemplateFinder.new(project, self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::RepoTemplateFinder.new(project, base_dir, extension, categories)
end
end
end
diff --git a/lib/gitlab/template/merge_request_template.rb b/lib/gitlab/template/merge_request_template.rb
index 357b31cd82e..d32822691df 100644
--- a/lib/gitlab/template/merge_request_template.rb
+++ b/lib/gitlab/template/merge_request_template.rb
@@ -5,15 +5,15 @@ module Gitlab
class MergeRequestTemplate < BaseTemplate
class << self
def extension
- '.md'
+ ".md"
end
def base_dir
- '.gitlab/merge_request_templates/'
+ ".gitlab/merge_request_templates/"
end
def finder(project)
- Gitlab::Template::Finders::RepoTemplateFinder.new(project, self.base_dir, self.extension, self.categories)
+ Gitlab::Template::Finders::RepoTemplateFinder.new(project, base_dir, extension, categories)
end
end
end
diff --git a/lib/gitlab/testing/request_blocker_middleware.rb b/lib/gitlab/testing/request_blocker_middleware.rb
index 513cbe839ba..49894f35462 100644
--- a/lib/gitlab/testing/request_blocker_middleware.rb
+++ b/lib/gitlab/testing/request_blocker_middleware.rb
@@ -46,7 +46,6 @@ module Gitlab
sleep 0.2 if slow_requests?
@app.call(env)
end
-
ensure
decrement_active_requests
end
diff --git a/lib/gitlab/testing/request_inspector_middleware.rb b/lib/gitlab/testing/request_inspector_middleware.rb
index 36cdfebcc28..7b2bdc4f8f8 100644
--- a/lib/gitlab/testing/request_inspector_middleware.rb
+++ b/lib/gitlab/testing/request_inspector_middleware.rb
@@ -32,12 +32,12 @@ module Gitlab
def call(env)
return @app.call(env) unless @@log_requests.true?
- url = env['REQUEST_URI']
+ url = env["REQUEST_URI"]
env.merge! http_headers_env(@@inject_headers) if @@inject_headers.any?
request_headers = env_http_headers(env)
status, headers, body = @app.call(env)
- full_body = +''
+ full_body = +""
body.each { |b| full_body << b }
request = OpenStruct.new(
@@ -55,17 +55,17 @@ module Gitlab
private
def env_http_headers(env)
- Hash[*env.select { |k, v| k.start_with? 'HTTP_' }
- .collect { |k, v| [k.sub(/^HTTP_/, ''), v] }
- .collect { |k, v| [k.split('_').collect(&:capitalize).join('-'), v] }
+ Hash[*env.select { |k, v| k.start_with? "HTTP_" }
+ .collect { |k, v| [k.sub(/^HTTP_/, ""), v] }
+ .collect { |k, v| [k.split("_").collect(&:capitalize).join("-"), v] }
.sort
.flatten]
end
def http_headers_env(headers)
Hash[*headers
- .collect { |k, v| [k.split('-').collect(&:upcase).join('_'), v] }
- .collect { |k, v| [k.prepend('HTTP_'), v] }
+ .collect { |k, v| [k.split("-").collect(&:upcase).join("_"), v] }
+ .collect { |k, v| [k.prepend("HTTP_"), v] }
.flatten]
end
diff --git a/lib/gitlab/themes.rb b/lib/gitlab/themes.rb
index 63860b9cb26..4b06d5725ba 100644
--- a/lib/gitlab/themes.rb
+++ b/lib/gitlab/themes.rb
@@ -14,16 +14,16 @@ module Gitlab
# All available Themes
THEMES = [
- Theme.new(1, 'Indigo', 'ui-indigo'),
- Theme.new(6, 'Light Indigo', 'ui-light-indigo'),
- Theme.new(4, 'Blue', 'ui-blue'),
- Theme.new(7, 'Light Blue', 'ui-light-blue'),
- Theme.new(5, 'Green', 'ui-green'),
- Theme.new(8, 'Light Green', 'ui-light-green'),
- Theme.new(9, 'Red', 'ui-red'),
- Theme.new(10, 'Light Red', 'ui-light-red'),
- Theme.new(2, 'Dark', 'ui-dark'),
- Theme.new(3, 'Light', 'ui-light')
+ Theme.new(1, "Indigo", "ui-indigo"),
+ Theme.new(6, "Light Indigo", "ui-light-indigo"),
+ Theme.new(4, "Blue", "ui-blue"),
+ Theme.new(7, "Light Blue", "ui-light-blue"),
+ Theme.new(5, "Green", "ui-green"),
+ Theme.new(8, "Light Green", "ui-light-green"),
+ Theme.new(9, "Red", "ui-red"),
+ Theme.new(10, "Light Red", "ui-light-red"),
+ Theme.new(2, "Dark", "ui-dark"),
+ Theme.new(3, "Light", "ui-light"),
].freeze
# Convenience method to get a space-separated String of all the theme
@@ -31,7 +31,7 @@ module Gitlab
#
# Returns a String
def body_classes
- THEMES.collect(&:css_class).uniq.join(' ')
+ THEMES.collect(&:css_class).uniq.join(" ")
end
# Get a Theme by its ID
diff --git a/lib/gitlab/time_tracking_formatter.rb b/lib/gitlab/time_tracking_formatter.rb
index cc206010e74..f89d605b296 100644
--- a/lib/gitlab/time_tracking_formatter.rb
+++ b/lib/gitlab/time_tracking_formatter.rb
@@ -6,9 +6,13 @@ module Gitlab
def parse(string)
with_custom_config do
- string.sub!(/\A-/, '')
+ string.sub!(/\A-/, "")
- seconds = ChronicDuration.parse(string, default_unit: 'hours') rescue nil
+ seconds = begin
+ ChronicDuration.parse(string, default_unit: "hours")
+ rescue
+ nil
+ end
seconds *= -1 if seconds && Regexp.last_match
seconds
end
@@ -16,7 +20,9 @@ module Gitlab
def output(seconds)
with_custom_config do
- ChronicDuration.output(seconds, format: :short, limit_to_hours: false, weeks: true) rescue nil
+ ChronicDuration.output(seconds, format: :short, limit_to_hours: false, weeks: true)
+ rescue
+ nil
end
end
diff --git a/lib/gitlab/timeless.rb b/lib/gitlab/timeless.rb
index 4f974c98c71..3a946198e60 100644
--- a/lib/gitlab/timeless.rb
+++ b/lib/gitlab/timeless.rb
@@ -11,7 +11,6 @@ module Gitlab
else
block.call
end
-
ensure
model.record_timestamps = original_record_timestamps
end
diff --git a/lib/gitlab/tracing.rb b/lib/gitlab/tracing.rb
index 29517591c51..08e55374655 100644
--- a/lib/gitlab/tracing.rb
+++ b/lib/gitlab/tracing.rb
@@ -11,11 +11,11 @@ module Gitlab
end
def self.connection_string
- ENV['GITLAB_TRACING']
+ ENV["GITLAB_TRACING"]
end
def self.tracing_url_template
- ENV['GITLAB_TRACING_URL']
+ ENV["GITLAB_TRACING_URL"]
end
def self.tracing_url_enabled?
diff --git a/lib/gitlab/tracing/common.rb b/lib/gitlab/tracing/common.rb
index 3a08ede8138..18cb3bf9d33 100644
--- a/lib/gitlab/tracing/common.rb
+++ b/lib/gitlab/tracing/common.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'opentracing'
+require "opentracing"
module Gitlab
module Tracing
@@ -21,7 +21,7 @@ module Gitlab
# Add correlation details to the span if we have them
correlation_id = Gitlab::CorrelationId.current_id
if correlation_id
- span.set_tag('correlation_id', correlation_id)
+ span.set_tag("correlation_id", correlation_id)
end
begin
@@ -43,7 +43,7 @@ module Gitlab
end
def log_exception_on_span(span, exception)
- span.set_tag('error', true)
+ span.set_tag("error", true)
span.log_kv(kv_tags_for_exception(exception))
end
@@ -51,16 +51,16 @@ module Gitlab
case exception
when Exception
{
- 'event': 'error',
+ 'event': "error",
'error.kind': exception.class.to_s,
- 'message': Gitlab::UrlSanitizer.sanitize(exception.message),
- 'stack': exception.backtrace&.join("\n")
+ 'message': Gitlab::UrlSanitizer.sanitize(exception.message),
+ 'stack': exception.backtrace&.join("\n"),
}
else
{
- 'event': 'error',
- 'error.kind': exception.class.to_s,
- 'error.object': Gitlab::UrlSanitizer.sanitize(exception.to_s)
+ 'event': "error",
+ 'error.kind': exception.class.to_s,
+ 'error.object': Gitlab::UrlSanitizer.sanitize(exception.to_s),
}
end
end
diff --git a/lib/gitlab/tracing/factory.rb b/lib/gitlab/tracing/factory.rb
index fc714164353..1218c52331b 100644
--- a/lib/gitlab/tracing/factory.rb
+++ b/lib/gitlab/tracing/factory.rb
@@ -36,7 +36,7 @@ module Gitlab
{
driver_name: parsed.host,
- options: parse_query(parsed.query)
+ options: parse_query(parsed.query),
}
end
private_class_method :parse_connection_string
diff --git a/lib/gitlab/tracing/grpc_interceptor.rb b/lib/gitlab/tracing/grpc_interceptor.rb
index 6c2aab73125..5a74ba107c4 100644
--- a/lib/gitlab/tracing/grpc_interceptor.rb
+++ b/lib/gitlab/tracing/grpc_interceptor.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'opentracing'
-require 'grpc'
+require "opentracing"
+require "grpc"
module Gitlab
module Tracing
@@ -10,25 +10,25 @@ module Gitlab
include Singleton
def request_response(request:, call:, method:, metadata:)
- wrap_with_tracing(method, 'unary', metadata) do
+ wrap_with_tracing(method, "unary", metadata) do
yield
end
end
def client_streamer(requests:, call:, method:, metadata:)
- wrap_with_tracing(method, 'client_stream', metadata) do
+ wrap_with_tracing(method, "client_stream", metadata) do
yield
end
end
def server_streamer(request:, call:, method:, metadata:)
- wrap_with_tracing(method, 'server_stream', metadata) do
+ wrap_with_tracing(method, "server_stream", metadata) do
yield
end
end
def bidi_streamer(requests:, call:, method:, metadata:)
- wrap_with_tracing(method, 'bidi_stream', metadata) do
+ wrap_with_tracing(method, "bidi_stream", metadata) do
yield
end
end
@@ -37,10 +37,10 @@ module Gitlab
def wrap_with_tracing(method, grpc_type, metadata)
tags = {
- 'component' => 'grpc',
- 'span.kind' => 'client',
- 'grpc.method' => method,
- 'grpc.type' => grpc_type
+ "component" => "grpc",
+ "span.kind" => "client",
+ "grpc.method" => method,
+ "grpc.type" => grpc_type,
}
in_tracing_span(operation_name: "grpc:#{method}", tags: tags) do |span|
diff --git a/lib/gitlab/tracing/jaeger_factory.rb b/lib/gitlab/tracing/jaeger_factory.rb
index 2682007302a..fb3003ecb4d 100644
--- a/lib/gitlab/tracing/jaeger_factory.rb
+++ b/lib/gitlab/tracing/jaeger_factory.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'jaeger/client'
+require "jaeger/client"
module Gitlab
module Tracing
@@ -21,7 +21,7 @@ module Gitlab
kwargs = {
service_name: service_name,
sampler: get_sampler(options[:sampler], options[:sampler_param]),
- reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint])
+ reporter: get_reporter(service_name, options[:http_endpoint], options[:udp_endpoint]),
}.compact
extra_params = options.except(:sampler, :sampler_param, :http_endpoint, :udp_endpoint, :strict_parsing, :debug) # rubocop: disable CodeReuse/ActiveRecord
@@ -46,8 +46,6 @@ module Gitlab
when "const"
const_value = sampler_param == "1"
Jaeger::Samplers::Const.new(const_value)
- else
- nil
end
end
private_class_method :get_sampler
diff --git a/lib/gitlab/tracing/rack_middleware.rb b/lib/gitlab/tracing/rack_middleware.rb
index e6a31293f7b..5e5f083a14b 100644
--- a/lib/gitlab/tracing/rack_middleware.rb
+++ b/lib/gitlab/tracing/rack_middleware.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'opentracing'
+require "opentracing"
module Gitlab
module Tracing
class RackMiddleware
include Common
- REQUEST_METHOD = 'REQUEST_METHOD'
+ REQUEST_METHOD = "REQUEST_METHOD"
def initialize(app)
@app = app
@@ -18,15 +18,15 @@ module Gitlab
context = tracer.extract(OpenTracing::FORMAT_RACK, env)
tags = {
- 'component' => 'rack',
- 'span.kind' => 'server',
- 'http.method' => method,
- 'http.url' => self.class.build_sanitized_url_from_env(env)
+ "component" => "rack",
+ "span.kind" => "server",
+ "http.method" => method,
+ "http.url" => self.class.build_sanitized_url_from_env(env),
}
in_tracing_span(operation_name: "http:#{method}", child_of: context, tags: tags) do |span|
@app.call(env).tap do |status_code, _headers, _body|
- span.set_tag('http.status_code', status_code)
+ span.set_tag("http.status_code", status_code)
end
end
end
diff --git a/lib/gitlab/tracing/rails/action_view_subscriber.rb b/lib/gitlab/tracing/rails/action_view_subscriber.rb
index 88816e1fb32..bb86e45d347 100644
--- a/lib/gitlab/tracing/rails/action_view_subscriber.rb
+++ b/lib/gitlab/tracing/rails/action_view_subscriber.rb
@@ -6,10 +6,10 @@ module Gitlab
class ActionViewSubscriber
include RailsCommon
- COMPONENT_TAG = 'ActionView'
- RENDER_TEMPLATE_NOTIFICATION_TOPIC = 'render_template.action_view'
- RENDER_COLLECTION_NOTIFICATION_TOPIC = 'render_collection.action_view'
- RENDER_PARTIAL_NOTIFICATION_TOPIC = 'render_partial.action_view'
+ COMPONENT_TAG = "ActionView"
+ RENDER_TEMPLATE_NOTIFICATION_TOPIC = "render_template.action_view"
+ RENDER_COLLECTION_NOTIFICATION_TOPIC = "render_collection.action_view"
+ RENDER_PARTIAL_NOTIFICATION_TOPIC = "render_partial.action_view"
# Instruments Rails ActionView events for opentracing.
# Returns a lambda, which, when called will unsubscribe from the notifications
@@ -25,7 +25,7 @@ module Gitlab
end,
ActiveSupport::Notifications.subscribe(RENDER_PARTIAL_NOTIFICATION_TOPIC) do |_, start, finish, _, payload|
subscriber.notify_render_partial(start, finish, payload)
- end
+ end,
]
create_unsubscriber subscriptions
@@ -48,25 +48,25 @@ module Gitlab
def tags_for_render_template(payload)
{
- 'component' => COMPONENT_TAG,
- 'template.id' => payload[:identifier],
- 'template.layout' => payload[:layout]
+ "component" => COMPONENT_TAG,
+ "template.id" => payload[:identifier],
+ "template.layout" => payload[:layout],
}
end
def tags_for_render_collection(payload)
{
- 'component' => COMPONENT_TAG,
- 'template.id' => payload[:identifier],
- 'template.count' => payload[:count] || 0,
- 'template.cache.hits' => payload[:cache_hits] || 0
+ "component" => COMPONENT_TAG,
+ "template.id" => payload[:identifier],
+ "template.count" => payload[:count] || 0,
+ "template.cache.hits" => payload[:cache_hits] || 0,
}
end
def tags_for_render_partial(payload)
{
- 'component' => COMPONENT_TAG,
- 'template.id' => payload[:identifier]
+ "component" => COMPONENT_TAG,
+ "template.id" => payload[:identifier],
}
end
end
diff --git a/lib/gitlab/tracing/rails/active_record_subscriber.rb b/lib/gitlab/tracing/rails/active_record_subscriber.rb
index 32f5658e57e..5fbf07038a4 100644
--- a/lib/gitlab/tracing/rails/active_record_subscriber.rb
+++ b/lib/gitlab/tracing/rails/active_record_subscriber.rb
@@ -6,18 +6,18 @@ module Gitlab
class ActiveRecordSubscriber
include RailsCommon
- ACTIVE_RECORD_NOTIFICATION_TOPIC = 'sql.active_record'
- OPERATION_NAME_PREFIX = 'active_record:'
- DEFAULT_OPERATION_NAME = 'sqlquery'
+ ACTIVE_RECORD_NOTIFICATION_TOPIC = "sql.active_record"
+ OPERATION_NAME_PREFIX = "active_record:"
+ DEFAULT_OPERATION_NAME = "sqlquery"
# Instruments Rails ActiveRecord events for opentracing.
# Returns a lambda, which, when called will unsubscribe from the notifications
def self.instrument
subscriber = new
- subscription = ActiveSupport::Notifications.subscribe(ACTIVE_RECORD_NOTIFICATION_TOPIC) do |_, start, finish, _, payload|
+ subscription = ActiveSupport::Notifications.subscribe(ACTIVE_RECORD_NOTIFICATION_TOPIC) { |_, start, finish, _, payload|
subscriber.notify(start, finish, payload)
- end
+ }
create_unsubscriber [subscription]
end
@@ -35,12 +35,12 @@ module Gitlab
def tags_for_notification(payload)
{
- 'component' => 'ActiveRecord',
- 'span.kind' => 'client',
- 'db.type' => 'sql',
- 'db.connection_id' => payload[:connection_id],
- 'db.cached' => payload[:cached] || false,
- 'db.statement' => payload[:sql]
+ "component" => "ActiveRecord",
+ "span.kind" => "client",
+ "db.type" => "sql",
+ "db.connection_id" => payload[:connection_id],
+ "db.cached" => payload[:cached] || false,
+ "db.statement" => payload[:sql],
}
end
end
diff --git a/lib/gitlab/tracing/sidekiq/client_middleware.rb b/lib/gitlab/tracing/sidekiq/client_middleware.rb
index 2b71c1ea21e..008f106d6e3 100644
--- a/lib/gitlab/tracing/sidekiq/client_middleware.rb
+++ b/lib/gitlab/tracing/sidekiq/client_middleware.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'opentracing'
+require "opentracing"
module Gitlab
module Tracing
@@ -8,12 +8,13 @@ module Gitlab
class ClientMiddleware
include SidekiqCommon
- SPAN_KIND = 'client'
+ SPAN_KIND = "client"
def call(worker_class, job, queue, redis_pool)
in_tracing_span(
- operation_name: "sidekiq:#{job['class']}",
- tags: tags_from_job(job, SPAN_KIND)) do |span|
+ operation_name: "sidekiq:#{job["class"]}",
+ tags: tags_from_job(job, SPAN_KIND)
+ ) do |span|
# Inject the details directly into the job
tracer.inject(span.context, OpenTracing::FORMAT_TEXT_MAP, job)
diff --git a/lib/gitlab/tracing/sidekiq/server_middleware.rb b/lib/gitlab/tracing/sidekiq/server_middleware.rb
index 5b43c4310e6..d83fb17148e 100644
--- a/lib/gitlab/tracing/sidekiq/server_middleware.rb
+++ b/lib/gitlab/tracing/sidekiq/server_middleware.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'opentracing'
+require "opentracing"
module Gitlab
module Tracing
@@ -8,15 +8,16 @@ module Gitlab
class ServerMiddleware
include SidekiqCommon
- SPAN_KIND = 'server'
+ SPAN_KIND = "server"
def call(worker, job, queue)
context = tracer.extract(OpenTracing::FORMAT_TEXT_MAP, job)
in_tracing_span(
- operation_name: "sidekiq:#{job['class']}",
+ operation_name: "sidekiq:#{job["class"]}",
child_of: context,
- tags: tags_from_job(job, SPAN_KIND)) do |span|
+ tags: tags_from_job(job, SPAN_KIND)
+ ) do |span|
yield
end
end
diff --git a/lib/gitlab/tracing/sidekiq/sidekiq_common.rb b/lib/gitlab/tracing/sidekiq/sidekiq_common.rb
index a911a29d773..d8208d54c60 100644
--- a/lib/gitlab/tracing/sidekiq/sidekiq_common.rb
+++ b/lib/gitlab/tracing/sidekiq/sidekiq_common.rb
@@ -8,12 +8,12 @@ module Gitlab
def tags_from_job(job, kind)
{
- 'component' => 'sidekiq',
- 'span.kind' => kind,
- 'sidekiq.queue' => job['queue'],
- 'sidekiq.jid' => job['jid'],
- 'sidekiq.retry' => job['retry'].to_s,
- 'sidekiq.args' => job['args']&.join(", ")
+ "component" => "sidekiq",
+ "span.kind" => kind,
+ "sidekiq.queue" => job["queue"],
+ "sidekiq.jid" => job["jid"],
+ "sidekiq.retry" => job["retry"].to_s,
+ "sidekiq.args" => job["args"]&.join(", "),
}
end
end
diff --git a/lib/gitlab/tree_summary.rb b/lib/gitlab/tree_summary.rb
index 453d78e2f7b..833e3880f1a 100644
--- a/lib/gitlab/tree_summary.rb
+++ b/lib/gitlab/tree_summary.rb
@@ -71,14 +71,14 @@ module Gitlab
end
def build_entry(entry)
- { file_name: entry.name, type: entry.type }
+ {file_name: entry.name, type: entry.type}
end
def fill_last_commits!(entries)
# Ensure the path is in "path/" format
ensured_path =
if path
- File.join(*[path, ""])
+ File.join(path, "")
end
commits_hsh = repository.list_last_commits_for_tree(commit.id, ensured_path, offset: offset, limit: limit)
@@ -109,7 +109,7 @@ module Gitlab
[
*tree.trees,
*tree.blobs,
- *tree.submodules
+ *tree.submodules,
]
end
end
diff --git a/lib/gitlab/untrusted_regexp.rb b/lib/gitlab/untrusted_regexp.rb
index ba1137313d8..31a087c066e 100644
--- a/lib/gitlab/untrusted_regexp.rb
+++ b/lib/gitlab/untrusted_regexp.rb
@@ -11,7 +11,7 @@ module Gitlab
# there is a strict limit on total execution time. See the RE2 documentation
# at https://github.com/google/re2/wiki/Syntax for more details.
class UntrustedRegexp
- require_dependency 're2'
+ require_dependency "re2"
delegate :===, :source, to: :regexp
@@ -40,7 +40,7 @@ module Gitlab
end
def ==(other)
- self.source == other.source
+ source == other.source
end
# Handles regular expressions with the preferred RE2 library where possible
@@ -57,7 +57,7 @@ module Gitlab
end
def self.valid?(pattern)
- !!self.fabricate(pattern)
+ !!fabricate(pattern)
rescue RegexpError
false
end
@@ -65,13 +65,13 @@ module Gitlab
def self.fabricate(pattern)
matches = pattern.match(%r{^/(?<regexp>.+)/(?<flags>[ismU]*)$})
- raise RegexpError, 'Invalid regular expression!' if matches.nil?
+ raise RegexpError, "Invalid regular expression!" if matches.nil?
expression = matches[:regexp]
flags = matches[:flags]
expression.prepend("(?#{flags})") if flags.present?
- self.new(expression, multiline: false)
+ new(expression, multiline: false)
end
private
@@ -83,7 +83,7 @@ module Gitlab
def scan_regexp
@scan_regexp ||=
if regexp.number_of_capturing_groups.zero?
- RE2::Regexp.new('(' + regexp.source + ')')
+ RE2::Regexp.new("(" + regexp.source + ")")
else
regexp
end
diff --git a/lib/gitlab/url_blocker.rb b/lib/gitlab/url_blocker.rb
index 9b7b0db9525..e153d6b6437 100644
--- a/lib/gitlab/url_blocker.rb
+++ b/lib/gitlab/url_blocker.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'resolv'
-require 'ipaddress'
+require "resolv"
+require "ipaddress"
module Gitlab
class UrlBlocker
@@ -27,9 +27,9 @@ module Gitlab
validate_unicode_restriction!(uri) if ascii_only
begin
- addrs_info = Addrinfo.getaddrinfo(uri.hostname, port, nil, :STREAM).map do |addr|
+ addrs_info = Addrinfo.getaddrinfo(uri.hostname, port, nil, :STREAM).map { |addr|
addr.ipv6_v4mapped? ? addr.ipv6_to_ipv4 : addr
- end
+ }
rescue SocketError
return true
end
@@ -60,7 +60,7 @@ module Gitlab
uri_str = uri.to_s
sanitized_uri = ActionController::Base.helpers.sanitize(uri_str, tags: [])
if sanitized_uri != uri_str
- raise BlockedUrlError, 'HTML/CSS/JS tags are not allowed'
+ raise BlockedUrlError, "HTML/CSS/JS tags are not allowed"
end
end
@@ -69,7 +69,7 @@ module Gitlab
Addressable::URI.parse(url)
rescue Addressable::URI::InvalidURIError, URI::InvalidURIError
- raise BlockedUrlError, 'URI is invalid'
+ raise BlockedUrlError, "URI is invalid"
end
def multiline?(url)
@@ -82,12 +82,12 @@ module Gitlab
return if port >= 1024
return if ports.include?(port)
- raise BlockedUrlError, "Only allowed ports are #{ports.join(', ')}, and any over 1024"
+ raise BlockedUrlError, "Only allowed ports are #{ports.join(", ")}, and any over 1024"
end
def validate_protocol!(protocol, protocols)
if protocol.blank? || (protocols.any? && !protocols.include?(protocol))
- raise BlockedUrlError, "Only allowed protocols are #{protocols.join(', ')}"
+ raise BlockedUrlError, "Only allowed protocols are #{protocols.join(", ")}"
end
end
@@ -134,7 +134,7 @@ module Gitlab
end
def validate_link_local!(addrs_info)
- netmask = IPAddr.new('169.254.0.0/16')
+ netmask = IPAddr.new("169.254.0.0/16")
return unless addrs_info.any? { |addr| addr.ipv6_linklocal? || netmask.include?(addr.ip_address) }
raise BlockedUrlError, "Requests to the link local network are not allowed"
@@ -151,7 +151,7 @@ module Gitlab
end
def internal_shell?(uri)
- uri.scheme == 'ssh' &&
+ uri.scheme == "ssh" &&
uri.hostname == config.gitlab_shell.ssh_host &&
(uri.port.blank? || uri.port == config.gitlab_shell.ssh_port)
end
diff --git a/lib/gitlab/url_builder.rb b/lib/gitlab/url_builder.rb
index f86d599e4cb..a5819b63640 100644
--- a/lib/gitlab/url_builder.rb
+++ b/lib/gitlab/url_builder.rb
@@ -42,12 +42,12 @@ module Gitlab
end
def commit_url(opts = {})
- return '' if object.project.nil?
+ return "" if object.project.nil?
namespace_project_commit_url({
namespace_id: object.project.namespace,
project_id: object.project,
- id: object.id
+ id: object.id,
}.merge!(opts))
end
diff --git a/lib/gitlab/url_sanitizer.rb b/lib/gitlab/url_sanitizer.rb
index 880712de5fe..dbd0b2deb7a 100644
--- a/lib/gitlab/url_sanitizer.rb
+++ b/lib/gitlab/url_sanitizer.rb
@@ -9,7 +9,7 @@ module Gitlab
content.gsub(regexp) { |url| new(url).masked_url }
rescue Addressable::URI::InvalidURIError
- content.gsub(regexp, '')
+ content.gsub(regexp, "")
end
def self.valid?(url)
@@ -44,7 +44,7 @@ module Gitlab
end
def credentials
- @credentials ||= { user: @url.user.presence, password: @url.password.presence }
+ @credentials ||= {user: @url.user.presence, password: @url.password.presence}
end
def full_url
@@ -59,10 +59,10 @@ module Gitlab
raw_credentials = match[1] if match
if raw_credentials.present?
- url.sub!("#{raw_credentials}@", '')
+ url.sub!("#{raw_credentials}@", "")
- user, _, password = raw_credentials.partition(':')
- @credentials ||= { user: user.presence, password: password.presence }
+ user, _, password = raw_credentials.partition(":")
+ @credentials ||= {user: user.presence, password: password.presence}
end
url = Addressable::URI.parse(url)
@@ -88,12 +88,12 @@ module Gitlab
end
def valid_credentials?
- credentials && credentials.is_a?(Hash) && credentials.any?
+ credentials&.is_a?(Hash) && credentials&.any?
end
def encode_percent(string)
# CGI.escape converts spaces to +, but this doesn't work for git clone
- CGI.escape(string).gsub('+', '%20')
+ CGI.escape(string).gsub("+", "%20")
end
end
end
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index 0101ccc046a..a8fad547c2e 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -6,15 +6,15 @@ module Gitlab
class << self
def data(force_refresh: false)
- Rails.cache.fetch('usage_data', force: force_refresh, expires_in: 2.weeks) { uncached_data }
+ Rails.cache.fetch("usage_data", force: force_refresh, expires_in: 2.weeks) { uncached_data }
end
def uncached_data
license_usage_data.merge(system_usage_data)
- .merge(features_usage_data)
- .merge(components_usage_data)
- .merge(cycle_analytics_usage_data)
- .merge(usage_counters)
+ .merge(features_usage_data)
+ .merge(components_usage_data)
+ .merge(cycle_analytics_usage_data)
+ .merge(usage_counters)
end
def to_json(force_refresh: false)
@@ -29,7 +29,7 @@ module Gitlab
installation_type: Gitlab::INSTALLATION_TYPE,
active_user_count: count(User.active),
recorded_at: Time.now,
- edition: 'CE'
+ edition: "CE",
}
usage_data
@@ -80,8 +80,8 @@ module Gitlab
milestones: count(Milestone),
pages_domains: count(PagesDomain),
projects: count(Project),
- projects_imported_from_github: count(Project.where(import_type: 'github')),
- projects_with_repositories_enabled: count(ProjectFeature.where('repository_access_level > ?', ProjectFeature::DISABLED)),
+ projects_imported_from_github: count(Project.where(import_type: "github")),
+ projects_with_repositories_enabled: count(ProjectFeature.where("repository_access_level > ?", ProjectFeature::DISABLED)),
protected_branches: count(ProtectedBranch),
releases: count(Release),
remote_mirrors: count(RemoteMirror),
@@ -89,10 +89,10 @@ module Gitlab
suggestions: count(Suggestion),
todos: count(Todo),
uploads: count(Upload),
- web_hooks: count(WebHook)
+ web_hooks: count(WebHook),
}
- .merge(services_usage)
- .merge(approximate_counts)
+ .merge(services_usage)
+ .merge(approximate_counts),
}.tap do |data|
if Feature.enabled?(:group_overview_security_dashboard)
data[:counts][:user_preferences] = user_preferences_usage
@@ -118,21 +118,21 @@ module Gitlab
mattermost_enabled: Gitlab.config.mattermost.enabled,
omniauth_enabled: Gitlab::Auth.omniauth_enabled?,
reply_by_email_enabled: Gitlab::IncomingEmail.enabled?,
- signup_enabled: Gitlab::CurrentSettings.allow_signup?
+ signup_enabled: Gitlab::CurrentSettings.allow_signup?,
}
end
def usage_counters
{
- web_ide_commits: Gitlab::WebIdeCommitsCounter.total_count
+ web_ide_commits: Gitlab::WebIdeCommitsCounter.total_count,
}
end
def components_usage_data
{
- gitlab_pages: { enabled: Gitlab.config.pages.enabled, version: Gitlab::Pages::VERSION },
- git: { version: Gitlab::Git.version },
- database: { adapter: Gitlab::Database.adapter_name, version: Gitlab::Database.version }
+ gitlab_pages: {enabled: Gitlab.config.pages.enabled, version: Gitlab::Pages::VERSION},
+ git: {version: Gitlab::Git.version},
+ database: {adapter: Gitlab::Database.adapter_name, version: Gitlab::Database.version},
}
end
@@ -141,7 +141,7 @@ module Gitlab
types = {
SlackService: :projects_slack_notifications_active,
SlackSlashCommandsService: :projects_slack_slash_active,
- PrometheusService: :projects_prometheus_active
+ PrometheusService: :projects_prometheus_active,
}
results = count(Service.unscoped.where(type: types.keys, active: true).group(:type), fallback: Hash.new(-1))
@@ -159,9 +159,9 @@ module Gitlab
)
{
- projects_jira_server_active: services['server'] || 0,
- projects_jira_cloud_active: services['cloud'] || 0,
- projects_jira_active: services['server'] == -1 ? -1 : services.values.sum
+ projects_jira_server_active: services["server"] || 0,
+ projects_jira_cloud_active: services["cloud"] || 0,
+ projects_jira_active: services["server"] == -1 ? -1 : services.values.sum,
}
end
diff --git a/lib/gitlab/user_access.rb b/lib/gitlab/user_access.rb
index 980a8014409..432ed725af1 100644
--- a/lib/gitlab/user_access.rb
+++ b/lib/gitlab/user_access.rb
@@ -20,9 +20,9 @@ module Gitlab
return false unless can_access_git?
permission_cache[action] =
- permission_cache.fetch(action) do
+ permission_cache.fetch(action) {
user.can?(action, project)
- end
+ }
end
def cannot_do_action?(action)
@@ -99,7 +99,7 @@ module Gitlab
end
def can_access_git?
- user && user.can?(:access_git)
+ user&.can?(:access_git)
end
def protected_branch_accessible_to?(ref, action:)
@@ -107,7 +107,8 @@ module Gitlab
ref, user,
project: project,
action: action,
- protected_refs: project.protected_branches)
+ protected_refs: project.protected_branches
+ )
end
def protected_tag_accessible_to?(ref, action:)
@@ -115,7 +116,8 @@ module Gitlab
ref, user,
project: project,
action: action,
- protected_refs: project.protected_tags)
+ protected_refs: project.protected_tags
+ )
end
request_cache def protected?(kind, project, ref)
diff --git a/lib/gitlab/user_extractor.rb b/lib/gitlab/user_extractor.rb
index 874599688bb..2a2da6c6434 100644
--- a/lib/gitlab/user_extractor.rb
+++ b/lib/gitlab/user_extractor.rb
@@ -35,7 +35,7 @@ module Gitlab
def matches
@matches ||= {
emails: @text.scan(EMAIL_REGEXP).flatten.uniq,
- usernames: @text.scan(USERNAME_REGEXP).flatten.uniq
+ usernames: @text.scan(USERNAME_REGEXP).flatten.uniq,
}
end
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index 99fa65e0e90..327a5c5c115 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -7,8 +7,8 @@ module Gitlab
# Ensure that the relative path will not traverse outside the base directory
def check_path_traversal!(path)
raise StandardError.new("Invalid path") if path.start_with?("..#{File::SEPARATOR}") ||
- path.include?("#{File::SEPARATOR}..#{File::SEPARATOR}") ||
- path.end_with?("#{File::SEPARATOR}..")
+ path.include?("#{File::SEPARATOR}..#{File::SEPARATOR}") ||
+ path.end_with?("#{File::SEPARATOR}..")
path
end
@@ -26,23 +26,23 @@ module Gitlab
end
def ensure_utf8_size(str, bytes:)
- raise ArgumentError, 'Empty string provided!' if str.empty?
- raise ArgumentError, 'Negative string size provided!' if bytes.negative?
+ raise ArgumentError, "Empty string provided!" if str.empty?
+ raise ArgumentError, "Negative string size provided!" if bytes.negative?
- truncated = str.each_char.each_with_object(+'') do |char, object|
+ truncated = str.each_char.each_with_object(+"") { |char, object|
if object.bytesize + char.bytesize > bytes
break object
else
object.concat(char)
end
- end
+ }
- truncated + ('0' * (bytes - truncated.bytesize))
+ truncated + ("0" * (bytes - truncated.bytesize))
end
# Append path to host, making sure there's one single / in between
def append_path(host, path)
- "#{host.to_s.sub(%r{\/+$}, '')}/#{path.to_s.sub(%r{^\/+}, '')}"
+ "#{host.to_s.sub(%r{\/+$}, "")}/#{path.to_s.sub(%r{^\/+}, "")}"
end
# A slugified version of the string, suitable for inclusion in URLs and
@@ -53,18 +53,18 @@ module Gitlab
# * Maximum length is 63 bytes
# * First/Last Character is not a hyphen
def slugify(str)
- return str.downcase
- .gsub(/[^a-z0-9]/, '-')[0..62]
- .gsub(/(\A-+|-+\z)/, '')
+ str.downcase
+ .gsub(/[^a-z0-9]/, "-")[0..62]
+ .gsub(/(\A-+|-+\z)/, "")
end
# Converts newlines into HTML line break elements
def nlbr(str)
- ActionView::Base.full_sanitizer.sanitize(+str, tags: []).gsub(/\r?\n/, '<br>').html_safe
+ ActionView::Base.full_sanitizer.sanitize(+str, tags: []).gsub(/\r?\n/, "<br>").html_safe
end
def remove_line_breaks(str)
- str.gsub(/\r?\n/, '')
+ str.gsub(/\r?\n/, "")
end
def to_boolean(value)
@@ -77,9 +77,9 @@ module Gitlab
def boolean_to_yes_no(bool)
if bool
- 'Yes'
+ "Yes"
else
- 'No'
+ "No"
end
end
@@ -92,9 +92,9 @@ module Gitlab
#
# which('ruby') #=> /usr/bin/ruby
def which(cmd, env = ENV)
- exts = env['PATHEXT'] ? env['PATHEXT'].split(';') : ['']
+ exts = env["PATHEXT"] ? env["PATHEXT"].split(";") : [""]
- env['PATH'].split(File::PATH_SEPARATOR).each do |path|
+ env["PATH"].split(File::PATH_SEPARATOR).each do |path|
exts.each do |ext|
exe = File.join(path, "#{cmd}#{ext}")
return exe if File.executable?(exe) && !File.directory?(exe)
@@ -113,7 +113,7 @@ module Gitlab
def ensure_array_from_string(string_or_array)
return string_or_array if string_or_array.is_a?(Array)
- string_or_array.split(',').map(&:strip)
+ string_or_array.split(",").map(&:strip)
end
def deep_indifferent_access(data)
diff --git a/lib/gitlab/utils/merge_hash.rb b/lib/gitlab/utils/merge_hash.rb
index 48ba13b8561..612f800830d 100644
--- a/lib/gitlab/utils/merge_hash.rb
+++ b/lib/gitlab/utils/merge_hash.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'gitlab/utils'
+require_dependency "gitlab/utils"
module Gitlab
module Utils
diff --git a/lib/gitlab/utils/override.rb b/lib/gitlab/utils/override.rb
index f5299439fce..18a65b2e409 100644
--- a/lib/gitlab/utils/override.rb
+++ b/lib/gitlab/utils/override.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'gitlab/utils'
+require_dependency "gitlab/utils"
module Gitlab
module Utils
@@ -10,7 +10,8 @@ module Gitlab
extension = new(klass)
parents = extension.parents_for(klass)
extension.verify_method!(
- klass: klass, parents: parents, method_name: method_name, sub_method_arity: arity)
+ klass: klass, parents: parents, method_name: method_name, sub_method_arity: arity
+ )
end
attr_reader :subject
@@ -33,15 +34,16 @@ module Gitlab
klass: klass,
parents: parents,
method_name: method_name,
- sub_method_arity: arity)
+ sub_method_arity: arity
+ )
end
end
end
def verify_method!(klass:, parents:, method_name:, sub_method_arity:)
- overridden_parent = parents.find do |parent|
+ overridden_parent = parents.find { |parent|
instance_method_defined?(parent, method_name)
- end
+ }
raise NotImplementedError.new("#{klass}\##{method_name} doesn't exist!") unless overridden_parent
@@ -61,7 +63,7 @@ module Gitlab
end
def verify_override?(method_name)
- method_names.has_key?(method_name)
+ method_names.key?(method_name)
end
private
@@ -117,7 +119,7 @@ module Gitlab
# This would make sure we're overriding something. See:
# https://gitlab.com/gitlab-org/gitlab-ee/issues/1819
def override(method_name)
- return unless ENV['STATIC_VERIFICATION']
+ return unless ENV["STATIC_VERIFICATION"]
Override.extensions[self] ||= Extension.new(self)
Override.extensions[self].add_method_name(method_name)
@@ -126,7 +128,7 @@ module Gitlab
def method_added(method_name)
super
- return unless ENV['STATIC_VERIFICATION']
+ return unless ENV["STATIC_VERIFICATION"]
return unless Override.extensions[self]&.verify_override?(method_name)
method_arity = instance_method(method_name).arity
@@ -156,7 +158,7 @@ module Gitlab
end
def queue_verification(base)
- return unless ENV['STATIC_VERIFICATION']
+ return unless ENV["STATIC_VERIFICATION"]
if base.is_a?(Class) # We could check for Class in `override`
# This could be `nil` if `override` was never called
diff --git a/lib/gitlab/utils/strong_memoize.rb b/lib/gitlab/utils/strong_memoize.rb
index 3021a91dd83..b575a98320a 100644
--- a/lib/gitlab/utils/strong_memoize.rb
+++ b/lib/gitlab/utils/strong_memoize.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_dependency 'gitlab/utils'
+require_dependency "gitlab/utils"
module Gitlab
module Utils
diff --git a/lib/gitlab/verify/batch_verifier.rb b/lib/gitlab/verify/batch_verifier.rb
index dbda19a4a66..6f8b8afd0cf 100644
--- a/lib/gitlab/verify/batch_verifier.rb
+++ b/lib/gitlab/verify/batch_verifier.rb
@@ -47,15 +47,15 @@ module Gitlab
expected = expected_checksum(object)
actual = actual_checksum(object)
- return failure(object, 'Checksum missing') unless expected.present?
- return failure(object, 'Checksum mismatch') unless expected == actual
+ return failure(object, "Checksum missing") unless expected.present?
+ return failure(object, "Checksum mismatch") unless expected == actual
success
end
# We don't calculate checksum for remote objects, so just check existence
def verify_remote(object)
- return failure(object, 'Remote object does not exist') unless remote_object_exists?(object)
+ return failure(object, "Remote object does not exist") unless remote_object_exists?(object)
success
end
@@ -71,7 +71,7 @@ module Gitlab
# It's already set to Logger::INFO, but acts as if it is set to
# Logger::DEBUG, and this fixes it...
def fix_google_api_logger
- if Object.const_defined?('Google::Apis')
+ if Object.const_defined?("Google::Apis")
Google::Apis.logger.level = Logger::INFO
end
end
diff --git a/lib/gitlab/verify/job_artifacts.rb b/lib/gitlab/verify/job_artifacts.rb
index 3b90c8b1a8e..603b1ede8ee 100644
--- a/lib/gitlab/verify/job_artifacts.rb
+++ b/lib/gitlab/verify/job_artifacts.rb
@@ -4,7 +4,7 @@ module Gitlab
module Verify
class JobArtifacts < BatchVerifier
def name
- 'Job artifacts'
+ "Job artifacts"
end
def describe(object)
diff --git a/lib/gitlab/verify/lfs_objects.rb b/lib/gitlab/verify/lfs_objects.rb
index 20dbb7addff..f2dc359f49b 100644
--- a/lib/gitlab/verify/lfs_objects.rb
+++ b/lib/gitlab/verify/lfs_objects.rb
@@ -4,7 +4,7 @@ module Gitlab
module Verify
class LfsObjects < BatchVerifier
def name
- 'LFS objects'
+ "LFS objects"
end
def describe(object)
diff --git a/lib/gitlab/verify/rake_task.rb b/lib/gitlab/verify/rake_task.rb
index 3efed311237..0e908684b16 100644
--- a/lib/gitlab/verify/rake_task.rb
+++ b/lib/gitlab/verify/rake_task.rb
@@ -5,12 +5,12 @@ module Gitlab
class RakeTask
def self.run!(verify_kls)
verifier = verify_kls.new(
- batch_size: ENV.fetch('BATCH', 200).to_i,
- start: ENV['ID_FROM'],
- finish: ENV['ID_TO']
+ batch_size: ENV.fetch("BATCH", 200).to_i,
+ start: ENV["ID_FROM"],
+ finish: ENV["ID_TO"]
)
- verbose = Gitlab::Utils.to_boolean(ENV['VERBOSE'])
+ verbose = Gitlab::Utils.to_boolean(ENV["VERBOSE"])
new(verifier, verbose).run!
end
@@ -27,7 +27,7 @@ module Gitlab
verifier.run_batches { |*args| run_batch(*args) }
- say 'Done!'
+ say "Done!"
end
def verbose?
diff --git a/lib/gitlab/verify/uploads.rb b/lib/gitlab/verify/uploads.rb
index 875e8a120e9..50ddb7dbb85 100644
--- a/lib/gitlab/verify/uploads.rb
+++ b/lib/gitlab/verify/uploads.rb
@@ -4,7 +4,7 @@ module Gitlab
module Verify
class Uploads < BatchVerifier
def name
- 'Uploads'
+ "Uploads"
end
def describe(object)
diff --git a/lib/gitlab/visibility_level.rb b/lib/gitlab/visibility_level.rb
index a3c7de87765..a0e05d2f1f8 100644
--- a/lib/gitlab/visibility_level.rb
+++ b/lib/gitlab/visibility_level.rb
@@ -11,10 +11,10 @@ module Gitlab
included do
scope :public_only, -> { where(visibility_level: PUBLIC) }
- scope :public_and_internal_only, -> { where(visibility_level: [PUBLIC, INTERNAL] ) }
+ scope :public_and_internal_only, -> { where(visibility_level: [PUBLIC, INTERNAL]) }
scope :non_public_only, -> { where.not(visibility_level: PUBLIC) }
- scope :public_to_user, -> (user = nil) do
+ scope :public_to_user, ->(user = nil) do
where(visibility_level: VisibilityLevel.levels_for_user(user))
end
end
@@ -44,24 +44,24 @@ module Gitlab
def options
{
- N_('VisibilityLevel|Private') => PRIVATE,
- N_('VisibilityLevel|Internal') => INTERNAL,
- N_('VisibilityLevel|Public') => PUBLIC
+ N_("VisibilityLevel|Private") => PRIVATE,
+ N_("VisibilityLevel|Internal") => INTERNAL,
+ N_("VisibilityLevel|Public") => PUBLIC,
}
end
def string_options
{
- 'private' => PRIVATE,
- 'internal' => INTERNAL,
- 'public' => PUBLIC
+ "private" => PRIVATE,
+ "internal" => INTERNAL,
+ "public" => PUBLIC,
}
end
def allowed_levels
restricted_levels = Gitlab::CurrentSettings.restricted_visibility_levels
- self.values - Array(restricted_levels)
+ values - Array(restricted_levels)
end
def closest_allowed_level(target_level)
@@ -96,7 +96,7 @@ module Gitlab
end
def level_name(level)
- level_name = N_('VisibilityLevel|Unknown')
+ level_name = N_("VisibilityLevel|Unknown")
options.each do |name, lvl|
level_name = name if lvl == level.to_i
end
diff --git a/lib/gitlab/web_ide_commits_counter.rb b/lib/gitlab/web_ide_commits_counter.rb
index 1cd9b5295b9..3d016210a11 100644
--- a/lib/gitlab/web_ide_commits_counter.rb
+++ b/lib/gitlab/web_ide_commits_counter.rb
@@ -2,7 +2,7 @@
module Gitlab
module WebIdeCommitsCounter
- WEB_IDE_COMMITS_KEY = "WEB_IDE_COMMITS_COUNT".freeze
+ WEB_IDE_COMMITS_KEY = "WEB_IDE_COMMITS_COUNT"
class << self
def increment
diff --git a/lib/gitlab/webpack/dev_server_middleware.rb b/lib/gitlab/webpack/dev_server_middleware.rb
index fda41da5a94..55d175bd6f9 100644
--- a/lib/gitlab/webpack/dev_server_middleware.rb
+++ b/lib/gitlab/webpack/dev_server_middleware.rb
@@ -8,7 +8,7 @@ module Gitlab
module Webpack
class DevServerMiddleware < Rack::Proxy
def initialize(app = nil, opts = {})
- @proxy_host = opts.fetch(:proxy_host, 'localhost')
+ @proxy_host = opts.fetch(:proxy_host, "localhost")
@proxy_port = opts.fetch(:proxy_port, 3808)
@proxy_path = opts[:proxy_path] if opts[:proxy_path]
@@ -16,10 +16,10 @@ module Gitlab
end
def perform_request(env)
- if @proxy_path && env['PATH_INFO'].start_with?("/#{@proxy_path}")
+ if @proxy_path && env["PATH_INFO"].start_with?("/#{@proxy_path}")
if relative_url_root = Rails.application.config.relative_url_root
- env['SCRIPT_NAME'] = ""
- env['REQUEST_PATH'].sub!(/\A#{Regexp.escape(relative_url_root)}/, '')
+ env["SCRIPT_NAME"] = ""
+ env["REQUEST_PATH"].sub!(/\A#{Regexp.escape(relative_url_root)}/, "")
end
super(env)
diff --git a/lib/gitlab/webpack/manifest.rb b/lib/gitlab/webpack/manifest.rb
index 1d2aff5e5b4..dfd1e251531 100644
--- a/lib/gitlab/webpack/manifest.rb
+++ b/lib/gitlab/webpack/manifest.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'webpack/rails/manifest'
+require "webpack/rails/manifest"
module Gitlab
module Webpack
diff --git a/lib/gitlab/wiki_file_finder.rb b/lib/gitlab/wiki_file_finder.rb
index e9be6db50da..7c0c0b50913 100644
--- a/lib/gitlab/wiki_file_finder.rb
+++ b/lib/gitlab/wiki_file_finder.rb
@@ -13,7 +13,7 @@ module Gitlab
private
def search_filenames(query)
- safe_query = Regexp.escape(query.tr(' ', '-'))
+ safe_query = Regexp.escape(query.tr(" ", "-"))
safe_query = Regexp.new(safe_query, Regexp::IGNORECASE)
filenames = repository.ls_files(ref)
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb
index 265f6213a99..2e5b9ae0589 100644
--- a/lib/gitlab/workhorse.rb
+++ b/lib/gitlab/workhorse.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'base64'
-require 'json'
-require 'securerandom'
-require 'uri'
+require "base64"
+require "json"
+require "securerandom"
+require "uri"
module Gitlab
class Workhorse
- SEND_DATA_HEADER = 'Gitlab-Workhorse-Send-Data'.freeze
- VERSION_FILE = 'GITLAB_WORKHORSE_VERSION'.freeze
- INTERNAL_API_CONTENT_TYPE = 'application/vnd.gitlab-workhorse+json'.freeze
- INTERNAL_API_REQUEST_HEADER = 'Gitlab-Workhorse-Api-Request'.freeze
- NOTIFICATION_CHANNEL = 'workhorse:notifications'.freeze
+ SEND_DATA_HEADER = "Gitlab-Workhorse-Send-Data"
+ VERSION_FILE = "GITLAB_WORKHORSE_VERSION"
+ INTERNAL_API_CONTENT_TYPE = "application/vnd.gitlab-workhorse+json"
+ INTERNAL_API_REQUEST_HEADER = "Gitlab-Workhorse-Api-Request"
+ NOTIFICATION_CHANNEL = "workhorse:notifications"
ALLOWED_GIT_HTTP_ACTIONS = %w[git_receive_pack git_upload_pack info_refs].freeze
- DETECT_HEADER = 'Gitlab-Workhorse-Detect-Content-Type'.freeze
+ DETECT_HEADER = "Gitlab-Workhorse-Detect-Content-Type"
# Supposedly the effective key size for HMAC-SHA256 is 256 bits, i.e. 32
# bytes https://tools.ietf.org/html/rfc4868#section-2.6
@@ -34,8 +34,8 @@ module Gitlab
GitConfigOptions: [],
GitalyServer: {
address: Gitlab::GitalyClient.address(project.repository_storage),
- token: Gitlab::GitalyClient.token(project.repository_storage)
- }
+ token: Gitlab::GitalyClient.token(project.repository_storage),
+ },
}
# Custom option for git-receive-pack command
@@ -49,76 +49,76 @@ module Gitlab
def send_git_blob(repository, blob)
params = {
- 'GitalyServer' => gitaly_server_hash(repository),
- 'GetBlobRequest' => {
+ "GitalyServer" => gitaly_server_hash(repository),
+ "GetBlobRequest" => {
repository: repository.gitaly_repository.to_h,
oid: blob.id,
- limit: -1
- }
+ limit: -1,
+ },
}
[
SEND_DATA_HEADER,
- "git-blob:#{encode(params)}"
+ "git-blob:#{encode(params)}",
]
end
def send_git_archive(repository, ref:, format:, append_sha:)
- format ||= 'tar.gz'
+ format ||= "tar.gz"
format = format.downcase
params = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha)
raise "Repository or ref not found" if params.empty?
- params['GitalyServer'] = gitaly_server_hash(repository)
+ params["GitalyServer"] = gitaly_server_hash(repository)
# If present DisableCache must be a Boolean. Otherwise workhorse ignores it.
- params['DisableCache'] = true if git_archive_cache_disabled?
+ params["DisableCache"] = true if git_archive_cache_disabled?
[
SEND_DATA_HEADER,
- "git-archive:#{encode(params)}"
+ "git-archive:#{encode(params)}",
]
end
def send_git_snapshot(repository)
params = {
- 'GitalyServer' => gitaly_server_hash(repository),
- 'GetSnapshotRequest' => Gitaly::GetSnapshotRequest.new(
+ "GitalyServer" => gitaly_server_hash(repository),
+ "GetSnapshotRequest" => Gitaly::GetSnapshotRequest.new(
repository: repository.gitaly_repository
- ).to_json
+ ).to_json,
}
[
SEND_DATA_HEADER,
- "git-snapshot:#{encode(params)}"
+ "git-snapshot:#{encode(params)}",
]
end
def send_git_diff(repository, diff_refs)
params = {
- 'GitalyServer' => gitaly_server_hash(repository),
- 'RawDiffRequest' => Gitaly::RawDiffRequest.new(
+ "GitalyServer" => gitaly_server_hash(repository),
+ "RawDiffRequest" => Gitaly::RawDiffRequest.new(
gitaly_diff_or_patch_hash(repository, diff_refs)
- ).to_json
+ ).to_json,
}
[
SEND_DATA_HEADER,
- "git-diff:#{encode(params)}"
+ "git-diff:#{encode(params)}",
]
end
def send_git_patch(repository, diff_refs)
params = {
- 'GitalyServer' => gitaly_server_hash(repository),
- 'RawPatchRequest' => Gitaly::RawPatchRequest.new(
+ "GitalyServer" => gitaly_server_hash(repository),
+ "RawPatchRequest" => Gitaly::RawPatchRequest.new(
gitaly_diff_or_patch_hash(repository, diff_refs)
- ).to_json
+ ).to_json,
}
[
SEND_DATA_HEADER,
- "git-format-patch:#{encode(params)}"
+ "git-format-patch:#{encode(params)}",
]
end
@@ -127,45 +127,45 @@ module Gitlab
archive = file.file_storage? ? file.path : file.url
params = {
- 'Archive' => archive,
- 'Entry' => Base64.encode64(entry.to_s)
+ "Archive" => archive,
+ "Entry" => Base64.encode64(entry.to_s),
}
[
SEND_DATA_HEADER,
- "artifacts-entry:#{encode(params)}"
+ "artifacts-entry:#{encode(params)}",
]
end
def send_url(url, allow_redirects: false)
params = {
- 'URL' => url,
- 'AllowRedirects' => allow_redirects
+ "URL" => url,
+ "AllowRedirects" => allow_redirects,
}
[
SEND_DATA_HEADER,
- "send-url:#{encode(params)}"
+ "send-url:#{encode(params)}",
]
end
def terminal_websocket(terminal)
details = {
- 'Terminal' => {
- 'Subprotocols' => terminal[:subprotocols],
- 'Url' => terminal[:url],
- 'Header' => terminal[:headers],
- 'MaxSessionTime' => terminal[:max_session_time]
- }
+ "Terminal" => {
+ "Subprotocols" => terminal[:subprotocols],
+ "Url" => terminal[:url],
+ "Header" => terminal[:headers],
+ "MaxSessionTime" => terminal[:max_session_time],
+ },
}
- details['Terminal']['CAPem'] = terminal[:ca_pem] if terminal.key?(:ca_pem)
+ details["Terminal"]["CAPem"] = terminal[:ca_pem] if terminal.key?(:ca_pem)
details
end
def version
path = Rails.root.join(VERSION_FILE)
- path.readable? ? path.read.chomp : 'unknown'
+ path.readable? ? path.read.chomp : "unknown"
end
def secret
@@ -179,8 +179,8 @@ module Gitlab
def write_secret
bytes = SecureRandom.random_bytes(SECRET_LENGTH)
- File.open(secret_path, 'w:BINARY', 0600) do |f|
- f.chmod(0600) # If the file already existed, the '0600' passed to 'open' above was a no-op.
+ File.open(secret_path, "w:BINARY", 0o600) do |f|
+ f.chmod(0o600) # If the file already existed, the '0600' passed to 'open' above was a no-op.
f.write(Base64.strict_encode64(bytes))
end
end
@@ -194,7 +194,7 @@ module Gitlab
encoded_message,
secret,
true,
- { iss: 'gitlab-workhorse', verify_iss: true, algorithm: 'HS256' }
+ {iss: "gitlab-workhorse", verify_iss: true, algorithm: "HS256"}
)
end
@@ -223,7 +223,7 @@ module Gitlab
def gitaly_server_hash(repository)
{
address: Gitlab::GitalyClient.address(repository.project.repository_storage),
- token: Gitlab::GitalyClient.token(repository.project.repository_storage)
+ token: Gitlab::GitalyClient.token(repository.project.repository_storage),
}
end
@@ -231,12 +231,12 @@ module Gitlab
{
repository: repository.gitaly_repository,
left_commit_id: diff_refs.base_sha,
- right_commit_id: diff_refs.head_sha
+ right_commit_id: diff_refs.head_sha,
}
end
def git_archive_cache_disabled?
- ENV['WORKHORSE_ARCHIVE_CACHE_DISABLED'].present? || Feature.enabled?(:workhorse_archive_cache_disabled)
+ ENV["WORKHORSE_ARCHIVE_CACHE_DISABLED"].present? || Feature.enabled?(:workhorse_archive_cache_disabled)
end
end
end
diff --git a/lib/google_api/auth.rb b/lib/google_api/auth.rb
index 56f056fd869..36b60ce19ca 100644
--- a/lib/google_api/auth.rb
+++ b/lib/google_api/auth.rb
@@ -22,7 +22,7 @@ module GoogleApi
def get_token(code)
ret = client.auth_code.get_token(code, redirect_uri: redirect_uri)
- return ret.token, ret.expires_at
+ [ret.token, ret.expires_at]
end
protected
@@ -34,7 +34,7 @@ module GoogleApi
private
def config
- Gitlab::Auth::OAuth::Provider.config_for('google_oauth2')
+ Gitlab::Auth::OAuth::Provider.config_for("google_oauth2")
end
def client
@@ -47,9 +47,9 @@ module GoogleApi
@client = ::OAuth2::Client.new(
config.app_id,
config.app_secret,
- site: 'https://accounts.google.com',
- token_url: '/o/oauth2/token',
- authorize_url: '/o/oauth2/auth'
+ site: "https://accounts.google.com",
+ token_url: "/o/oauth2/token",
+ authorize_url: "/o/oauth2/auth"
)
end
end
diff --git a/lib/google_api/cloud_platform/client.rb b/lib/google_api/cloud_platform/client.rb
index e74ff6a9129..6be1ecb60c4 100644
--- a/lib/google_api/cloud_platform/client.rb
+++ b/lib/google_api/cloud_platform/client.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'google/apis/compute_v1'
-require 'google/apis/container_v1'
-require 'google/apis/cloudbilling_v1'
-require 'google/apis/cloudresourcemanager_v1'
+require "google/apis/compute_v1"
+require "google/apis/container_v1"
+require "google/apis/cloudbilling_v1"
+require "google/apis/cloudresourcemanager_v1"
module GoogleApi
module CloudPlatform
class Client < GoogleApi::Auth
- SCOPE = 'https://www.googleapis.com/auth/cloud-platform'.freeze
+ SCOPE = "https://www.googleapis.com/auth/cloud-platform"
LEAST_TOKEN_LIFE_TIME = 10.minutes
class << self
@@ -62,12 +62,12 @@ module GoogleApi
"name": cluster_name,
"initial_node_count": cluster_size,
"node_config": {
- "machine_type": machine_type
+ "machine_type": machine_type,
},
"legacy_abac": {
- "enabled": legacy_abac
- }
- }
+ "enabled": legacy_abac,
+ },
+ },
}
)
@@ -89,12 +89,12 @@ module GoogleApi
private
def token_life_time(expires_at)
- DateTime.strptime(expires_at, '%s').to_time.utc - Time.now.utc
+ DateTime.strptime(expires_at, "%s").to_time.utc - Time.now.utc
end
def user_agent_header
Google::Apis::RequestOptions.new.tap do |options|
- options.header = { 'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)" }
+ options.header = {'User-Agent': "GitLab/#{Gitlab::VERSION.match('(\d+\.\d+)').captures.first} (GPN:GitLab;)"}
end
end
end
diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb
index 2e98227a05e..92c69a798bd 100644
--- a/lib/haml_lint/inline_javascript.rb
+++ b/lib/haml_lint/inline_javascript.rb
@@ -2,24 +2,24 @@
# frozen_string_literal: true
unless Rails.env.production?
- require_dependency 'haml_lint/haml_visitor'
- require_dependency 'haml_lint/linter'
- require_dependency 'haml_lint/linter_registry'
+ require_dependency "haml_lint/haml_visitor"
+ require_dependency "haml_lint/linter"
+ require_dependency "haml_lint/linter_registry"
module HamlLint
class Linter::InlineJavaScript < Linter
include LinterRegistry
def visit_filter(node)
- return unless node.filter_type == 'javascript'
+ return unless node.filter_type == "javascript"
- record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
+ record_lint(node, "Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)")
end
def visit_tag(node)
- return unless node.tag_name == 'script'
+ return unless node.tag_name == "script"
- record_lint(node, 'Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)')
+ record_lint(node, "Inline JavaScript is discouraged (https://docs.gitlab.com/ee/development/gotchas.html#do-not-use-inline-javascript-in-views)")
end
end
end
diff --git a/lib/json_web_token/hmac_token.rb b/lib/json_web_token/hmac_token.rb
index ec0917ab49d..2275c0e3a1d 100644
--- a/lib/json_web_token/hmac_token.rb
+++ b/lib/json_web_token/hmac_token.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'jwt'
+require "jwt"
module JSONWebToken
class HMACToken < Token
IAT_LEEWAY = 60
- JWT_ALGORITHM = 'HS256'
+ JWT_ALGORITHM = "HS256"
def initialize(secret)
super()
@@ -18,7 +18,7 @@ module JSONWebToken
end
def encoded
- JWT.encode(payload, secret, JWT_ALGORITHM, { typ: 'JWT' })
+ JWT.encode(payload, secret, JWT_ALGORITHM, {typ: "JWT"})
end
private
diff --git a/lib/json_web_token/rsa_token.rb b/lib/json_web_token/rsa_token.rb
index bcce811cd28..021d5b7258a 100644
--- a/lib/json_web_token/rsa_token.rb
+++ b/lib/json_web_token/rsa_token.rb
@@ -12,9 +12,9 @@ module JSONWebToken
def encoded
headers = {
kid: kid,
- typ: 'JWT'
+ typ: "JWT",
}
- JWT.encode(payload, key, 'RS256', headers)
+ JWT.encode(payload, key, "RS256", headers)
end
private
@@ -39,7 +39,7 @@ module JSONWebToken
kid = Base32.encode(kid[0..29])
# insert colon every 4 characters
- kid.scan(/.{4}/).join(':')
+ kid.scan(/.{4}/).join(":")
end
end
end
diff --git a/lib/json_web_token/token.rb b/lib/json_web_token/token.rb
index c59beef02c9..f69a86ef5cc 100644
--- a/lib/json_web_token/token.rb
+++ b/lib/json_web_token/token.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module JSONWebToken
class Token
@@ -46,7 +46,7 @@ module JSONWebToken
iss: issuer,
iat: issued_at.to_i,
nbf: not_before.to_i,
- exp: expire_time.to_i
+ exp: expire_time.to_i,
}.compact
end
end
diff --git a/lib/mattermost/client.rb b/lib/mattermost/client.rb
index 293d0c563c5..e6f633f81be 100644
--- a/lib/mattermost/client.rb
+++ b/lib/mattermost/client.rb
@@ -52,12 +52,12 @@ module Mattermost
json_response = JSON.parse(response.body)
unless response.success?
- raise Mattermost::ClientError.new(json_response['message'] || 'Undefined error')
+ raise Mattermost::ClientError.new(json_response["message"] || "Undefined error")
end
json_response
rescue JSON::JSONError
- raise Mattermost::ClientError.new('Cannot parse response')
+ raise Mattermost::ClientError.new("Cannot parse response")
end
end
end
diff --git a/lib/mattermost/command.rb b/lib/mattermost/command.rb
index a02745486d6..866338d07f3 100644
--- a/lib/mattermost/command.rb
+++ b/lib/mattermost/command.rb
@@ -3,10 +3,10 @@
module Mattermost
class Command < Client
def create(params)
- response = session_post('/api/v4/commands',
+ response = session_post("/api/v4/commands",
body: params.to_json)
- response['token']
+ response["token"]
end
end
end
diff --git a/lib/mattermost/session.rb b/lib/mattermost/session.rb
index e2083848a8d..7096e41fcbd 100644
--- a/lib/mattermost/session.rb
+++ b/lib/mattermost/session.rb
@@ -3,7 +3,7 @@
module Mattermost
class NoSessionError < Mattermost::Error
def message
- 'No session could be set up, is Mattermost configured with Single Sign On?'
+ "No session could be set up, is Mattermost configured with Single Sign On?"
end
end
@@ -52,7 +52,8 @@ module Mattermost
# Next methods are needed for Doorkeeper
def pre_auth
@pre_auth ||= Doorkeeper::OAuth::PreAuthorization.new(
- Doorkeeper.configuration, server.client_via_uid, params)
+ Doorkeeper.configuration, server.client_via_uid, params
+ )
end
def authorization
@@ -107,14 +108,14 @@ module Mattermost
raise Mattermost::NoSessionError unless @token
@headers = {
- Authorization: "Bearer #{@token}"
+ Authorization: "Bearer #{@token}",
}
@token
end
def destroy
- post('/api/v4/users/logout')
+ post("/api/v4/users/logout")
end
def oauth_uri
@@ -122,15 +123,15 @@ module Mattermost
@oauth_uri = nil
- response = get('/oauth/gitlab/login', follow_redirects: false, format: 'text/html')
+ response = get("/oauth/gitlab/login", follow_redirects: false, format: "text/html")
return unless (300...400) === response.code
- redirect_uri = response.headers['location']
+ redirect_uri = response.headers["location"]
return unless redirect_uri
oauth_cookie = parse_cookie(response)
@headers = {
- Cookie: oauth_cookie.to_cookie_string
+ Cookie: oauth_cookie.to_cookie_string,
}
@oauth_uri = URI.parse(redirect_uri)
@@ -147,7 +148,7 @@ module Mattermost
response = get(token_uri, follow_redirects: false)
if (200...400) === response.code
- response.headers['token']
+ response.headers["token"]
end
end
@@ -181,7 +182,7 @@ module Mattermost
def parse_cookie(response)
cookie_hash = Gitlab::HTTP::CookieHash.new
- response.get_fields('Set-Cookie').each { |c| cookie_hash.add_cookies(c) }
+ response.get_fields("Set-Cookie").each { |c| cookie_hash.add_cookies(c) }
cookie_hash
end
end
diff --git a/lib/mattermost/team.rb b/lib/mattermost/team.rb
index 58120178f50..12e6cb65ce4 100644
--- a/lib/mattermost/team.rb
+++ b/lib/mattermost/team.rb
@@ -10,10 +10,10 @@ module Mattermost
# Creates a team on the linked Mattermost instance, the team admin will be the
# `current_user` passed to the Mattermost::Client instance
def create(name:, display_name:, type:)
- session_post('/api/v4/teams', body: {
+ session_post("/api/v4/teams", body: {
name: name,
display_name: display_name,
- type: type
+ type: type,
}.to_json)
end
diff --git a/lib/microsoft_teams/activity.rb b/lib/microsoft_teams/activity.rb
index 207e90d2638..6e70b00446c 100644
--- a/lib/microsoft_teams/activity.rb
+++ b/lib/microsoft_teams/activity.rb
@@ -11,10 +11,10 @@ module MicrosoftTeams
def prepare
{
- 'activityTitle' => @title,
- 'activitySubtitle' => @subtitle,
- 'activityText' => @text,
- 'activityImage' => @image
+ "activityTitle" => @title,
+ "activitySubtitle" => @subtitle,
+ "activityText" => @text,
+ "activityImage" => @image,
}
end
end
diff --git a/lib/microsoft_teams/notifier.rb b/lib/microsoft_teams/notifier.rb
index c7dec09ba6b..e2e14f70274 100644
--- a/lib/microsoft_teams/notifier.rb
+++ b/lib/microsoft_teams/notifier.rb
@@ -4,7 +4,7 @@ module MicrosoftTeams
class Notifier
def initialize(webhook)
@webhook = webhook
- @header = { 'Content-type' => 'application/json' }
+ @header = {"Content-type" => "application/json"}
end
def ping(options = {})
@@ -29,17 +29,17 @@ module MicrosoftTeams
private
def body(options = {})
- result = { 'sections' => [] }
+ result = {"sections" => []}
- result['title'] = options[:title]
- result['summary'] = options[:summary]
- result['sections'] << MicrosoftTeams::Activity.new(options[:activity]).prepare
+ result["title"] = options[:title]
+ result["summary"] = options[:summary]
+ result["sections"] << MicrosoftTeams::Activity.new(options[:activity]).prepare
attachments = options[:attachments]
unless attachments.blank?
- result['sections'] << {
- 'title' => 'Details',
- 'facts' => [{ 'name' => 'Attachments', 'value' => attachments }]
+ result["sections"] << {
+ "title" => "Details",
+ "facts" => [{"name" => "Attachments", "value" => attachments}],
}
end
diff --git a/lib/milestone_array.rb b/lib/milestone_array.rb
index 461e73e9670..107abe2913d 100644
--- a/lib/milestone_array.rb
+++ b/lib/milestone_array.rb
@@ -4,18 +4,18 @@ module MilestoneArray
class << self
def sort(array, sort_method)
case sort_method
- when 'due_date_asc'
- sort_asc_nulls_last(array, 'due_date')
- when 'due_date_desc'
- sort_desc_nulls_last(array, 'due_date')
- when 'start_date_asc'
- sort_asc_nulls_last(array, 'start_date')
- when 'start_date_desc'
- sort_desc_nulls_last(array, 'start_date')
- when 'name_asc'
- sort_asc(array, 'title')
- when 'name_desc'
- sort_asc(array, 'title').reverse
+ when "due_date_asc"
+ sort_asc_nulls_last(array, "due_date")
+ when "due_date_desc"
+ sort_desc_nulls_last(array, "due_date")
+ when "start_date_asc"
+ sort_asc_nulls_last(array, "start_date")
+ when "start_date_desc"
+ sort_desc_nulls_last(array, "start_date")
+ when "name_asc"
+ sort_asc(array, "title")
+ when "name_desc"
+ sort_asc(array, "title").reverse
else
array
end
diff --git a/lib/mysql_zero_date.rb b/lib/mysql_zero_date.rb
index f36610abf8f..3be5a7d76b2 100644
--- a/lib/mysql_zero_date.rb
+++ b/lib/mysql_zero_date.rb
@@ -7,7 +7,7 @@
# and NO_ZERO_DATE has to be explicitly disabled. Disabling strict mode
# is not sufficient.
-require 'active_record/connection_adapters/abstract_mysql_adapter'
+require "active_record/connection_adapters/abstract_mysql_adapter"
module MysqlZeroDate
def configure_connection
diff --git a/lib/object_storage/direct_upload.rb b/lib/object_storage/direct_upload.rb
index fd26663fef0..4fe5c4a14b3 100644
--- a/lib/object_storage/direct_upload.rb
+++ b/lib/object_storage/direct_upload.rb
@@ -27,7 +27,7 @@ module ObjectStorage
def initialize(credentials, bucket_name, object_name, has_length:, maximum_size: nil)
unless has_length
- raise ArgumentError, 'maximum_size has to be specified if length is unknown' unless maximum_size
+ raise ArgumentError, "maximum_size has to be specified if length is unknown" unless maximum_size
end
@credentials = credentials
@@ -45,7 +45,7 @@ module ObjectStorage
DeleteURL: delete_url,
MultipartUpload: multipart_upload_hash,
CustomPutHeaders: true,
- PutHeaders: upload_options
+ PutHeaders: upload_options,
}.compact
end
@@ -56,7 +56,7 @@ module ObjectStorage
PartSize: rounded_multipart_part_size,
PartURLs: multipart_part_urls,
CompleteURL: multipart_complete_url,
- AbortURL: multipart_abort_url
+ AbortURL: multipart_abort_url,
}
end
@@ -88,32 +88,32 @@ module ObjectStorage
# Implements https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadUploadPart.html
def multipart_part_upload_url(part_number)
connection.signed_url({
- method: 'PUT',
+ method: "PUT",
bucket_name: bucket_name,
object_name: object_name,
- query: { 'uploadId' => upload_id, 'partNumber' => part_number },
- headers: upload_options
+ query: {"uploadId" => upload_id, "partNumber" => part_number},
+ headers: upload_options,
}, expire_at)
end
# Implements https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadComplete.html
def multipart_complete_url
connection.signed_url({
- method: 'POST',
+ method: "POST",
bucket_name: bucket_name,
object_name: object_name,
- query: { 'uploadId' => upload_id },
- headers: { 'Content-Type' => 'application/xml' }
+ query: {"uploadId" => upload_id},
+ headers: {"Content-Type" => "application/xml"},
}, expire_at)
end
# Implements https://docs.aws.amazon.com/AmazonS3/latest/API/mpUploadAbort.html
def multipart_abort_url
connection.signed_url({
- method: 'DELETE',
+ method: "DELETE",
bucket_name: bucket_name,
object_name: object_name,
- query: { 'uploadId' => upload_id }
+ query: {"uploadId" => upload_id},
}, expire_at)
end
@@ -132,12 +132,12 @@ module ObjectStorage
[
# round maximum_size up to minimum_mulitpart_size
(maximum_size + MINIMUM_MULTIPART_SIZE - 1) / MINIMUM_MULTIPART_SIZE,
- MAXIMUM_MULTIPART_PARTS
+ MAXIMUM_MULTIPART_PARTS,
].min
end
def aws?
- provider == 'AWS'
+ provider == "AWS"
end
def requires_multipart_upload?
diff --git a/lib/omni_auth/strategies/bitbucket.rb b/lib/omni_auth/strategies/bitbucket.rb
index 6c914b4222a..043b8e58ad1 100644
--- a/lib/omni_auth/strategies/bitbucket.rb
+++ b/lib/omni_auth/strategies/bitbucket.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'omniauth-oauth2'
+require "omniauth-oauth2"
module OmniAuth
module Strategies
class Bitbucket < OmniAuth::Strategies::OAuth2
- option :name, 'bitbucket'
+ option :name, "bitbucket"
option :client_options, {
- site: 'https://bitbucket.org',
- authorize_url: 'https://bitbucket.org/site/oauth2/authorize',
- token_url: 'https://bitbucket.org/site/oauth2/access_token'
+ site: "https://bitbucket.org",
+ authorize_url: "https://bitbucket.org/site/oauth2/authorize",
+ token_url: "https://bitbucket.org/site/oauth2/access_token",
}
uid do
- raw_info['username']
+ raw_info["username"]
end
info do
{
- name: raw_info['display_name'],
- avatar: raw_info['links']['avatar']['href'],
- email: primary_email
+ name: raw_info["display_name"],
+ avatar: raw_info["links"]["avatar"]["href"],
+ email: primary_email,
}
end
def raw_info
- @raw_info ||= access_token.get('api/2.0/user').parsed
+ @raw_info ||= access_token.get("api/2.0/user").parsed
end
def primary_email
- primary = emails.find { |i| i['is_primary'] && i['is_confirmed'] }
- primary && primary['email'] || nil
+ primary = emails.find { |i| i["is_primary"] && i["is_confirmed"] }
+ primary && primary["email"] || nil
end
def emails
- email_response = access_token.get('api/2.0/user/emails').parsed
- @emails ||= email_response && email_response['values'] || nil
+ email_response = access_token.get("api/2.0/user/emails").parsed
+ @emails ||= email_response && email_response["values"] || nil
end
def callback_url
diff --git a/lib/omni_auth/strategies/jwt.rb b/lib/omni_auth/strategies/jwt.rb
index 2f3d477a591..02d0ecd2c63 100644
--- a/lib/omni_auth/strategies/jwt.rb
+++ b/lib/omni_auth/strategies/jwt.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'omniauth'
-require 'openssl'
-require 'jwt'
+require "omniauth"
+require "openssl"
+require "jwt"
module OmniAuth
module Strategies
@@ -14,17 +14,17 @@ module OmniAuth
args [:secret]
option :secret, nil
- option :algorithm, 'HS256'
- option :uid_claim, 'email'
- option :required_claims, %w(name email)
- option :info_map, { name: "name", email: "email" }
+ option :algorithm, "HS256"
+ option :uid_claim, "email"
+ option :required_claims, %w[name email]
+ option :info_map, {name: "name", email: "email"}
option :auth_url, nil
option :valid_within, nil
uid { decoded[options.uid_claim] }
extra do
- { raw_info: decoded }
+ {raw_info: decoded}
end
info do
@@ -40,17 +40,17 @@ module OmniAuth
def decoded
secret =
case options.algorithm
- when *%w[RS256 RS384 RS512]
+ when "RS256", "RS384", "RS512"
OpenSSL::PKey::RSA.new(options.secret).public_key
- when *%w[ES256 ES384 ES512]
+ when "ES256", "ES384", "ES512"
OpenSSL::PKey::EC.new(options.secret).tap { |key| key.private_key = nil }
- when *%w(HS256 HS384 HS512)
+ when "HS256", "HS384", "HS512"
options.secret
else
raise NotImplementedError, "Unsupported algorithm: #{options.algorithm}"
end
- @decoded ||= ::JWT.decode(request.params['jwt'], secret, true, { algorithm: options.algorithm }).first
+ @decoded ||= ::JWT.decode(request.params["jwt"], secret, true, {algorithm: options.algorithm}).first
(options.required_claims || []).each do |field|
raise ClaimInvalid, "Missing required '#{field}' claim" unless @decoded.key?(field.to_s)
diff --git a/lib/peek/views/gitaly.rb b/lib/peek/views/gitaly.rb
index 30f95a10024..80097cda3a4 100644
--- a/lib/peek/views/gitaly.rb
+++ b/lib/peek/views/gitaly.rb
@@ -15,7 +15,7 @@ module Peek
{
duration: formatted_duration,
calls: calls,
- details: details
+ details: details,
}
end
@@ -44,7 +44,7 @@ module Peek
end
def setup_subscribers
- subscribe 'start_processing.action_controller' do
+ subscribe "start_processing.action_controller" do
::Gitlab::GitalyClient.query_time = 0
end
end
diff --git a/lib/peek/views/host.rb b/lib/peek/views/host.rb
index b77355ea11b..3fbf86b64f0 100644
--- a/lib/peek/views/host.rb
+++ b/lib/peek/views/host.rb
@@ -6,7 +6,7 @@ module Peek
def results
{
hostname: Gitlab::Environment.hostname,
- canary: Gitlab::Utils.to_boolean(ENV['CANARY'])
+ canary: Gitlab::Utils.to_boolean(ENV["CANARY"]),
}
end
end
diff --git a/lib/peek/views/tracing.rb b/lib/peek/views/tracing.rb
index 0de32a8fdda..e513b248052 100644
--- a/lib/peek/views/tracing.rb
+++ b/lib/peek/views/tracing.rb
@@ -5,7 +5,7 @@ module Peek
class Tracing < View
def results
{
- tracing_url: Gitlab::Tracing.tracing_url
+ tracing_url: Gitlab::Tracing.tracing_url,
}
end
end
diff --git a/lib/quality/helm_client.rb b/lib/quality/helm_client.rb
index cf1f03b35b5..a5852988758 100644
--- a/lib/quality/helm_client.rb
+++ b/lib/quality/helm_client.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'time'
-require_relative '../gitlab/popen' unless defined?(Gitlab::Popen)
+require "time"
+require_relative "../gitlab/popen" unless defined?(Gitlab::Popen)
module Quality
class HelmClient
@@ -11,7 +11,7 @@ module Quality
RELEASE_JSON_ATTRIBUTES = %w[Name Revision Updated Status Chart AppVersion Namespace].freeze
- Release = Struct.new(:name, :revision, :last_update, :status, :chart, :app_version, :namespace) do
+ Release = Struct.new(:name, :revision, :last_update, :status, :chart, :app_version, :namespace) {
def revision
@revision ||= self[:revision].to_i
end
@@ -19,7 +19,7 @@ module Quality
def last_update
@last_update ||= Time.parse(self[:last_update])
end
- end
+ }
# A single page of data and the corresponding page number.
Page = Struct.new(:releases, :number)
@@ -34,17 +34,17 @@ module Quality
def delete(release_name:)
run_command([
- 'delete',
+ "delete",
%(--tiller-namespace "#{namespace}"),
- '--purge',
- release_name
+ "--purge",
+ release_name,
])
end
private
def run_command(command)
- final_command = ['helm', *command].join(' ')
+ final_command = ["helm", *command].join(" ")
puts "Running command: `#{final_command}`" # rubocop:disable Rails/Output
result = Gitlab::Popen.popen_with_detail([final_command])
@@ -58,18 +58,18 @@ module Quality
def raw_releases(args = [])
command = [
- 'list',
+ "list",
%(--namespace "#{namespace}"),
%(--tiller-namespace "#{namespace}" --output json),
- *args
+ *args,
]
json = JSON.parse(run_command(command))
- releases = json['Releases'].map do |json_release|
+ releases = json["Releases"].map { |json_release|
Release.new(*json_release.values_at(*RELEASE_JSON_ATTRIBUTES))
- end
+ }
- [releases, json['Next']]
+ [releases, json["Next"]]
rescue JSON::ParserError => ex
puts "Ignoring this JSON parsing error: #{ex}" # rubocop:disable Rails/Output
[[], nil]
@@ -84,7 +84,7 @@ module Quality
return to_enum(__method__, args) unless block_given?
page = 1
- offset = ''
+ offset = ""
loop do
final_args = args.dup
diff --git a/lib/quality/kubernetes_client.rb b/lib/quality/kubernetes_client.rb
index 2ff9e811425..16a3305534d 100644
--- a/lib/quality/kubernetes_client.rb
+++ b/lib/quality/kubernetes_client.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../gitlab/popen' unless defined?(Gitlab::Popen)
+require_relative "../gitlab/popen" unless defined?(Gitlab::Popen)
module Quality
class KubernetesClient
@@ -15,10 +15,10 @@ module Quality
def cleanup(release_name:)
command = [
%(--namespace "#{namespace}"),
- 'delete',
- 'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa',
- '--now',
- %(-l release="#{release_name}")
+ "delete",
+ "ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa",
+ "--now",
+ %(-l release="#{release_name}"),
]
run_command(command)
@@ -27,7 +27,7 @@ module Quality
private
def run_command(command)
- final_command = ['kubectl', *command].join(' ')
+ final_command = ["kubectl", *command].join(" ")
puts "Running command: `#{final_command}`" # rubocop:disable Rails/Output
result = Gitlab::Popen.popen_with_detail([final_command])
diff --git a/lib/rouge/formatters/html_gitlab.rb b/lib/rouge/formatters/html_gitlab.rb
index e2a7d3ef5ba..088fb158444 100644
--- a/lib/rouge/formatters/html_gitlab.rb
+++ b/lib/rouge/formatters/html_gitlab.rb
@@ -3,7 +3,7 @@
module Rouge
module Formatters
class HTMLGitlab < Rouge::Formatters::HTML
- tag 'html_gitlab'
+ tag "html_gitlab"
# Creates a new <tt>Rouge::Formatter::HTMLGitlab</tt> instance.
#
diff --git a/lib/rspec_flaky/config.rb b/lib/rspec_flaky/config.rb
index 55c1d4747b4..c07ca65ee48 100644
--- a/lib/rspec_flaky/config.rb
+++ b/lib/rspec_flaky/config.rb
@@ -3,19 +3,19 @@
module RspecFlaky
class Config
def self.generate_report?
- !!(ENV['FLAKY_RSPEC_GENERATE_REPORT'] =~ /1|true/)
+ !!(ENV["FLAKY_RSPEC_GENERATE_REPORT"] =~ /1|true/)
end
def self.suite_flaky_examples_report_path
- ENV['SUITE_FLAKY_RSPEC_REPORT_PATH'] || Rails.root.join("rspec_flaky/suite-report.json")
+ ENV["SUITE_FLAKY_RSPEC_REPORT_PATH"] || Rails.root.join("rspec_flaky/suite-report.json")
end
def self.flaky_examples_report_path
- ENV['FLAKY_RSPEC_REPORT_PATH'] || Rails.root.join("rspec_flaky/report.json")
+ ENV["FLAKY_RSPEC_REPORT_PATH"] || Rails.root.join("rspec_flaky/report.json")
end
def self.new_flaky_examples_report_path
- ENV['NEW_FLAKY_RSPEC_REPORT_PATH'] || Rails.root.join("rspec_flaky/new-report.json")
+ ENV["NEW_FLAKY_RSPEC_REPORT_PATH"] || Rails.root.join("rspec_flaky/new-report.json")
end
end
end
diff --git a/lib/rspec_flaky/flaky_example.rb b/lib/rspec_flaky/flaky_example.rb
index da5dbf06bc9..e4484dde6a5 100644
--- a/lib/rspec_flaky/flaky_example.rb
+++ b/lib/rspec_flaky/flaky_example.rb
@@ -23,8 +23,8 @@ module RspecFlaky
self.flaky_reports += 1
self.last_attempts_count = last_attempts_count if last_attempts_count
- if ENV['CI_PROJECT_URL'] && ENV['CI_JOB_ID']
- self.last_flaky_job = "#{ENV['CI_PROJECT_URL']}/-/jobs/#{ENV['CI_JOB_ID']}"
+ if ENV["CI_PROJECT_URL"] && ENV["CI_JOB_ID"]
+ self.last_flaky_job = "#{ENV["CI_PROJECT_URL"]}/-/jobs/#{ENV["CI_JOB_ID"]}"
end
end
@@ -32,7 +32,8 @@ module RspecFlaky
super.merge(
first_flaky_at: first_flaky_at,
last_flaky_at: last_flaky_at,
- last_flaky_job: last_flaky_job)
+ last_flaky_job: last_flaky_job
+ )
end
end
end
diff --git a/lib/rspec_flaky/flaky_examples_collection.rb b/lib/rspec_flaky/flaky_examples_collection.rb
index 290a51766e9..173e1deb544 100644
--- a/lib/rspec_flaky/flaky_examples_collection.rb
+++ b/lib/rspec_flaky/flaky_examples_collection.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'active_support/hash_with_indifferent_access'
+require "active_support/hash_with_indifferent_access"
-require_relative 'flaky_example'
+require_relative "flaky_example"
module RspecFlaky
class FlakyExamplesCollection < SimpleDelegator
@@ -12,12 +12,12 @@ module RspecFlaky
end
collection_of_flaky_examples =
- collection.map do |uid, example|
+ collection.map { |uid, example|
[
uid,
- example.is_a?(RspecFlaky::FlakyExample) ? example : RspecFlaky::FlakyExample.new(example)
+ example.is_a?(RspecFlaky::FlakyExample) ? example : RspecFlaky::FlakyExample.new(example),
]
- end
+ }
super(Hash[collection_of_flaky_examples])
end
diff --git a/lib/rspec_flaky/listener.rb b/lib/rspec_flaky/listener.rb
index 19cc0baa2d3..db21cf69029 100644
--- a/lib/rspec_flaky/listener.rb
+++ b/lib/rspec_flaky/listener.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'json'
+require "json"
-require_dependency 'rspec_flaky/config'
-require_dependency 'rspec_flaky/example'
-require_dependency 'rspec_flaky/flaky_example'
-require_dependency 'rspec_flaky/flaky_examples_collection'
-require_dependency 'rspec_flaky/report'
+require_dependency "rspec_flaky/config"
+require_dependency "rspec_flaky/example"
+require_dependency "rspec_flaky/flaky_example"
+require_dependency "rspec_flaky/flaky_examples_collection"
+require_dependency "rspec_flaky/report"
module RspecFlaky
class Listener
diff --git a/lib/rspec_flaky/report.rb b/lib/rspec_flaky/report.rb
index 9a0fb88c424..1d7c9aa49a7 100644
--- a/lib/rspec_flaky/report.rb
+++ b/lib/rspec_flaky/report.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'json'
-require 'time'
+require "json"
+require "time"
-require_dependency 'rspec_flaky/config'
-require_dependency 'rspec_flaky/flaky_examples_collection'
+require_dependency "rspec_flaky/config"
+require_dependency "rspec_flaky/flaky_examples_collection"
module RspecFlaky
# This class is responsible for loading/saving JSON reports, and pruning
@@ -46,9 +46,9 @@ module RspecFlaky
def prune_outdated(days: OUTDATED_DAYS_THRESHOLD)
outdated_date_threshold = Time.now - (3600 * 24 * days)
updated_hash = flaky_examples.dup
- .delete_if do |uid, hash|
+ .delete_if { |uid, hash|
hash[:last_flaky_at] && Time.parse(hash[:last_flaky_at]).to_i < outdated_date_threshold.to_i
- end
+ }
self.class.new(RspecFlaky::FlakyExamplesCollection.new(updated_hash))
end
diff --git a/lib/safe_zip/extract.rb b/lib/safe_zip/extract.rb
index 679c021c730..9abb53d4cdb 100644
--- a/lib/safe_zip/extract.rb
+++ b/lib/safe_zip/extract.rb
@@ -43,7 +43,7 @@ module SafeZip
extracted += extract_all_entries(zip_archive, params,
zip_archive.lazy.reject(&:directory?).reject(&:file?))
- raise NoMatchingError, 'No entries extracted' unless extracted > 0
+ raise NoMatchingError, "No entries extracted" unless extracted > 0
end
end
@@ -57,16 +57,16 @@ module SafeZip
def legacy_unsafe_extract_with_system_zip(params)
# Requires UnZip at least 6.00 Info-ZIP.
# -n never overwrite existing files
- args = %W(unzip -n -qq #{archive_path})
+ args = %W[unzip -n -qq #{archive_path}]
# We add * to end of directory, because we want to extract directory and all subdirectories
args += params.directories_wildcard
# Target directory where we extract
- args += %W(-d #{params.extract_path})
+ args += %W[-d #{params.extract_path}]
unless system(*args)
- raise Error, 'archive failed to extract'
+ raise Error, "archive failed to extract"
end
end
end
diff --git a/lib/safe_zip/extract_params.rb b/lib/safe_zip/extract_params.rb
index bd3b788bac9..17f0b38fb33 100644
--- a/lib/safe_zip/extract_params.rb
+++ b/lib/safe_zip/extract_params.rb
@@ -20,7 +20,7 @@ module SafeZip
def target_directories
strong_memoize(:target_directories) do
directories.map do |directory|
- ::File.join(::File.expand_path(directory, extract_path), '')
+ ::File.join(::File.expand_path(directory, extract_path), "")
end
end
end
@@ -28,7 +28,7 @@ module SafeZip
def directories_wildcard
strong_memoize(:directories_wildcard) do
directories.map do |directory|
- ::File.join(directory, '*')
+ ::File.join(directory, "*")
end
end
end
diff --git a/lib/sentry/client.rb b/lib/sentry/client.rb
index 49ec196b103..2a0836cae96 100644
--- a/lib/sentry/client.rb
+++ b/lib/sentry/client.rb
@@ -29,9 +29,9 @@ module Sentry
def request_params
{
headers: {
- 'Authorization' => "Bearer #{@token}"
+ "Authorization" => "Bearer #{@token}",
},
- follow_redirects: false
+ follow_redirects: false,
}
end
@@ -44,7 +44,7 @@ module Sentry
def get_issues(issue_status:, limit:)
http_get(issues_api_url, query: {
query: "is:#{issue_status}",
- limit: limit
+ limit: limit,
})
end
@@ -62,14 +62,14 @@ module Sentry
def projects_api_url
projects_url = URI(@url)
- projects_url.path = '/api/0/projects/'
+ projects_url.path = "/api/0/projects/"
projects_url
end
def issues_api_url
- issues_url = URI(@url + '/issues/')
- issues_url.path.squeeze!('/')
+ issues_url = URI(@url + "/issues/")
+ issues_url.path.squeeze!("/")
issues_url
end
@@ -87,53 +87,53 @@ module Sentry
issues_url = ErrorTracking::ProjectErrorTrackingSetting.extract_sentry_external_url(issues_url)
uri = URI(issues_url)
- uri.path.squeeze!('/')
+ uri.path.squeeze!("/")
uri.to_s
end
def map_to_error(issue)
- id = issue.fetch('id')
- project = issue.fetch('project')
+ id = issue.fetch("id")
+ project = issue.fetch("project")
- count = issue.fetch('count', nil)
+ count = issue.fetch("count", nil)
- frequency = issue.dig('stats', '24h')
- message = issue.dig('metadata', 'value')
+ frequency = issue.dig("stats", "24h")
+ message = issue.dig("metadata", "value")
external_url = issue_url(id)
Gitlab::ErrorTracking::Error.new(
id: id,
- first_seen: issue.fetch('firstSeen', nil),
- last_seen: issue.fetch('lastSeen', nil),
- title: issue.fetch('title', nil),
- type: issue.fetch('type', nil),
- user_count: issue.fetch('userCount', nil),
+ first_seen: issue.fetch("firstSeen", nil),
+ last_seen: issue.fetch("lastSeen", nil),
+ title: issue.fetch("title", nil),
+ type: issue.fetch("type", nil),
+ user_count: issue.fetch("userCount", nil),
count: count,
message: message,
- culprit: issue.fetch('culprit', nil),
+ culprit: issue.fetch("culprit", nil),
external_url: external_url,
- short_id: issue.fetch('shortId', nil),
- status: issue.fetch('status', nil),
+ short_id: issue.fetch("shortId", nil),
+ status: issue.fetch("status", nil),
frequency: frequency,
- project_id: project.fetch('id'),
- project_name: project.fetch('name', nil),
- project_slug: project.fetch('slug', nil)
+ project_id: project.fetch("id"),
+ project_name: project.fetch("name", nil),
+ project_slug: project.fetch("slug", nil)
)
end
def map_to_project(project)
- organization = project.fetch('organization')
+ organization = project.fetch("organization")
Gitlab::ErrorTracking::Project.new(
- id: project.fetch('id'),
- name: project.fetch('name'),
- slug: project.fetch('slug'),
- status: project.dig('status'),
- organization_name: organization.fetch('name'),
- organization_id: organization.fetch('id'),
- organization_slug: organization.fetch('slug')
+ id: project.fetch("id"),
+ name: project.fetch("name"),
+ slug: project.fetch("slug"),
+ status: project.dig("status"),
+ organization_name: organization.fetch("name"),
+ organization_id: organization.fetch("id"),
+ organization_slug: organization.fetch("slug")
)
end
end
diff --git a/lib/static_model.rb b/lib/static_model.rb
index 86bf8d62f9a..0734fceb0fc 100644
--- a/lib/static_model.rb
+++ b/lib/static_model.rb
@@ -7,7 +7,7 @@ module StaticModel
class_methods do
# Used by ActiveRecord's polymorphic association to set object_id
def primary_key
- 'id'
+ "id"
end
# Used by ActiveRecord's polymorphic association to set object_type
diff --git a/lib/system_check/app/active_users_check.rb b/lib/system_check/app/active_users_check.rb
index 8446c2fc2c8..f837a12aea9 100644
--- a/lib/system_check/app/active_users_check.rb
+++ b/lib/system_check/app/active_users_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module App
class ActiveUsersCheck < SystemCheck::BaseCheck
- set_name 'Active users:'
+ set_name "Active users:"
def multi_check
active_users = User.active.count
diff --git a/lib/system_check/app/database_config_exists_check.rb b/lib/system_check/app/database_config_exists_check.rb
index 1769145ed63..e0a6a5c64a7 100644
--- a/lib/system_check/app/database_config_exists_check.rb
+++ b/lib/system_check/app/database_config_exists_check.rb
@@ -3,22 +3,22 @@
module SystemCheck
module App
class DatabaseConfigExistsCheck < SystemCheck::BaseCheck
- set_name 'Database config exists?'
+ set_name "Database config exists?"
def check?
- database_config_file = Rails.root.join('config', 'database.yml')
+ database_config_file = Rails.root.join("config", "database.yml")
File.exist?(database_config_file)
end
def show_error
try_fixing_it(
- 'Copy config/database.yml.<your db> to config/database.yml',
- 'Check that the information in config/database.yml is correct'
+ "Copy config/database.yml.<your db> to config/database.yml",
+ "Check that the information in config/database.yml is correct"
)
for_more_information(
- 'doc/install/databases.md',
- 'http://guides.rubyonrails.org/getting_started.html#configuring-a-database'
+ "doc/install/databases.md",
+ "http://guides.rubyonrails.org/getting_started.html#configuring-a-database"
)
fix_and_rerun
end
diff --git a/lib/system_check/app/git_config_check.rb b/lib/system_check/app/git_config_check.rb
index 4e8d607096c..e50a103a089 100644
--- a/lib/system_check/app/git_config_check.rb
+++ b/lib/system_check/app/git_config_check.rb
@@ -4,15 +4,15 @@ module SystemCheck
module App
class GitConfigCheck < SystemCheck::BaseCheck
OPTIONS = {
- 'core.autocrlf' => 'input'
+ "core.autocrlf" => "input",
}.freeze
- set_name 'Git configured correctly?'
+ set_name "Git configured correctly?"
def check?
- correct_options = OPTIONS.map do |name, value|
- run_command(%W(#{Gitlab.config.git.bin_path} config --global --get #{name})).try(:squish) == value
- end
+ correct_options = OPTIONS.map { |name, value|
+ run_command(%W[#{Gitlab.config.git.bin_path} config --global --get #{name}]).try(:squish) == value
+ }
correct_options.all?
end
@@ -24,19 +24,19 @@ module SystemCheck
def repair!
return false unless gitlab_user?
- command_success = OPTIONS.map do |name, value|
- system(*%W(#{Gitlab.config.git.bin_path} config --global #{name} #{value}))
- end
+ command_success = OPTIONS.map { |name, value|
+ system(Gitlab.config.git.bin_path.to_s, "config", "--global", name.to_s, value.to_s)
+ }
command_success.all?
end
def show_error
try_fixing_it(
- sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS['core.autocrlf']}\"")
+ sudo_gitlab("\"#{Gitlab.config.git.bin_path}\" config --global core.autocrlf \"#{OPTIONS["core.autocrlf"]}\"")
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
end
end
diff --git a/lib/system_check/app/git_user_default_ssh_config_check.rb b/lib/system_check/app/git_user_default_ssh_config_check.rb
index 6cd53779bfd..bac06a6108f 100644
--- a/lib/system_check/app/git_user_default_ssh_config_check.rb
+++ b/lib/system_check/app/git_user_default_ssh_config_check.rb
@@ -12,8 +12,8 @@ module SystemCheck
known_hosts
].freeze
- set_name 'Git user has default SSH configuration?'
- set_skip_reason 'skipped (git user is not present / configured)'
+ set_name "Git user has default SSH configuration?"
+ set_skip_reason "skipped (git user is not present / configured)"
def skip?
!home_dir || !File.directory?(home_dir)
@@ -26,9 +26,9 @@ module SystemCheck
def show_error
backup_dir = "~/gitlab-check-backup-#{Time.now.to_i}"
- instructions = forbidden_files.map do |filename|
+ instructions = forbidden_files.map { |filename|
"sudo mv #{Shellwords.escape(filename)} #{backup_dir}"
- end
+ }
try_fixing_it("mkdir #{backup_dir}", *instructions)
for_more_information('doc/ssh/README.md in section "SSH on the GitLab server"')
@@ -55,13 +55,13 @@ module SystemCheck
def ssh_dir
return nil unless home_dir
- File.join(home_dir, '.ssh')
+ File.join(home_dir, ".ssh")
end
def forbidden_files
@forbidden_files ||=
begin
- present = Dir[File.join(ssh_dir, '*')]
+ present = Dir[File.join(ssh_dir, "*")]
whitelisted = WHITELIST.map { |basename| File.join(ssh_dir, basename) }
present - whitelisted
diff --git a/lib/system_check/app/git_version_check.rb b/lib/system_check/app/git_version_check.rb
index 7c3e7759dd0..59f6abba2ce 100644
--- a/lib/system_check/app/git_version_check.rb
+++ b/lib/system_check/app/git_version_check.rb
@@ -3,15 +3,15 @@
module SystemCheck
module App
class GitVersionCheck < SystemCheck::BaseCheck
- set_name -> { "Git version >= #{self.required_version} ?" }
- set_check_pass -> { "yes (#{self.current_version})" }
+ set_name -> { "Git version >= #{required_version} ?" }
+ set_check_pass -> { "yes (#{current_version})" }
def self.required_version
- @required_version ||= Gitlab::VersionInfo.parse('2.18.0')
+ @required_version ||= Gitlab::VersionInfo.parse("2.18.0")
end
def self.current_version
- @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W(#{Gitlab.config.git.bin_path} --version)))
+ @current_version ||= Gitlab::VersionInfo.parse(Gitlab::TaskHelpers.run_command(%W[#{Gitlab.config.git.bin_path} --version]))
end
def check?
diff --git a/lib/system_check/app/gitlab_config_exists_check.rb b/lib/system_check/app/gitlab_config_exists_check.rb
index 1cc5ead0d89..b29aa66d8a9 100644
--- a/lib/system_check/app/gitlab_config_exists_check.rb
+++ b/lib/system_check/app/gitlab_config_exists_check.rb
@@ -3,21 +3,21 @@
module SystemCheck
module App
class GitlabConfigExistsCheck < SystemCheck::BaseCheck
- set_name 'GitLab config exists?'
+ set_name "GitLab config exists?"
def check?
- gitlab_config_file = Rails.root.join('config', 'gitlab.yml')
+ gitlab_config_file = Rails.root.join("config", "gitlab.yml")
File.exist?(gitlab_config_file)
end
def show_error
try_fixing_it(
- 'Copy config/gitlab.yml.example to config/gitlab.yml',
- 'Update config/gitlab.yml to match your setup'
+ "Copy config/gitlab.yml.example to config/gitlab.yml",
+ "Update config/gitlab.yml to match your setup"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/gitlab_config_up_to_date_check.rb b/lib/system_check/app/gitlab_config_up_to_date_check.rb
index 58c7e3039c8..be4144941c1 100644
--- a/lib/system_check/app/gitlab_config_up_to_date_check.rb
+++ b/lib/system_check/app/gitlab_config_up_to_date_check.rb
@@ -3,27 +3,27 @@
module SystemCheck
module App
class GitlabConfigUpToDateCheck < SystemCheck::BaseCheck
- set_name 'GitLab config up to date?'
+ set_name "GitLab config up to date?"
set_skip_reason "can't check because of previous errors"
def skip?
- gitlab_config_file = Rails.root.join('config', 'gitlab.yml')
+ gitlab_config_file = Rails.root.join("config", "gitlab.yml")
!File.exist?(gitlab_config_file)
end
def check?
# omniauth or ldap could have been deleted from the file
- !Gitlab.config['git_host']
+ !Gitlab.config["git_host"]
end
def show_error
try_fixing_it(
- 'Back-up your config/gitlab.yml',
- 'Copy config/gitlab.yml.example to config/gitlab.yml',
- 'Update config/gitlab.yml to match your setup'
+ "Back-up your config/gitlab.yml",
+ "Copy config/gitlab.yml.example to config/gitlab.yml",
+ "Update config/gitlab.yml to match your setup"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/init_script_exists_check.rb b/lib/system_check/app/init_script_exists_check.rb
index d36dbe7d67d..99c1f8eab91 100644
--- a/lib/system_check/app/init_script_exists_check.rb
+++ b/lib/system_check/app/init_script_exists_check.rb
@@ -3,24 +3,24 @@
module SystemCheck
module App
class InitScriptExistsCheck < SystemCheck::BaseCheck
- set_name 'Init script exists?'
- set_skip_reason 'skipped (omnibus-gitlab has no init script)'
+ set_name "Init script exists?"
+ set_skip_reason "skipped (omnibus-gitlab has no init script)"
def skip?
omnibus_gitlab?
end
def check?
- script_path = '/etc/init.d/gitlab'
+ script_path = "/etc/init.d/gitlab"
File.exist?(script_path)
end
def show_error
try_fixing_it(
- 'Install the init script'
+ "Install the init script"
)
for_more_information(
- see_installation_guide_section 'Install Init Script'
+ see_installation_guide_section("Install Init Script")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/init_script_up_to_date_check.rb b/lib/system_check/app/init_script_up_to_date_check.rb
index 569c41df6e4..79ef616b5cd 100644
--- a/lib/system_check/app/init_script_up_to_date_check.rb
+++ b/lib/system_check/app/init_script_up_to_date_check.rb
@@ -3,10 +3,10 @@
module SystemCheck
module App
class InitScriptUpToDateCheck < SystemCheck::BaseCheck
- SCRIPT_PATH = '/etc/init.d/gitlab'.freeze
+ SCRIPT_PATH = "/etc/init.d/gitlab"
- set_name 'Init script up-to-date?'
- set_skip_reason 'skipped (omnibus-gitlab has no init script)'
+ set_name "Init script up-to-date?"
+ set_skip_reason "skipped (omnibus-gitlab has no init script)"
def skip?
return true if omnibus_gitlab?
@@ -19,7 +19,7 @@ module SystemCheck
end
def check?
- recipe_path = Rails.root.join('lib/support/init.d/', 'gitlab')
+ recipe_path = Rails.root.join("lib/support/init.d/", "gitlab")
recipe_content = File.read(recipe_path)
script_content = File.read(SCRIPT_PATH)
@@ -29,10 +29,10 @@ module SystemCheck
def show_error
try_fixing_it(
- 'Re-download the init script'
+ "Re-download the init script"
)
for_more_information(
- see_installation_guide_section 'Install Init Script'
+ see_installation_guide_section("Install Init Script")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/log_writable_check.rb b/lib/system_check/app/log_writable_check.rb
index e26ad143eb8..15c69a53c75 100644
--- a/lib/system_check/app/log_writable_check.rb
+++ b/lib/system_check/app/log_writable_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module App
class LogWritableCheck < SystemCheck::BaseCheck
- set_name 'Log directory writable?'
+ set_name "Log directory writable?"
def check?
File.writable?(log_path)
@@ -15,7 +15,7 @@ module SystemCheck
"sudo chmod -R u+rwX #{log_path}"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
@@ -23,7 +23,7 @@ module SystemCheck
private
def log_path
- Rails.root.join('log')
+ Rails.root.join("log")
end
end
end
diff --git a/lib/system_check/app/migrations_are_up_check.rb b/lib/system_check/app/migrations_are_up_check.rb
index b12e9ac6bba..4d84a248e31 100644
--- a/lib/system_check/app/migrations_are_up_check.rb
+++ b/lib/system_check/app/migrations_are_up_check.rb
@@ -3,17 +3,17 @@
module SystemCheck
module App
class MigrationsAreUpCheck < SystemCheck::BaseCheck
- set_name 'All migrations up?'
+ set_name "All migrations up?"
def check?
- migration_status, _ = Gitlab::Popen.popen(%w(bundle exec rake db:migrate:status))
+ migration_status, _ = Gitlab::Popen.popen(%w[bundle exec rake db:migrate:status])
migration_status !~ /down\s+\d{14}/
end
def show_error
try_fixing_it(
- sudo_gitlab('bundle exec rake db:migrate RAILS_ENV=production')
+ sudo_gitlab("bundle exec rake db:migrate RAILS_ENV=production")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/orphaned_group_members_check.rb b/lib/system_check/app/orphaned_group_members_check.rb
index 3e6ffb8190b..4d8b4b5a54d 100644
--- a/lib/system_check/app/orphaned_group_members_check.rb
+++ b/lib/system_check/app/orphaned_group_members_check.rb
@@ -3,17 +3,17 @@
module SystemCheck
module App
class OrphanedGroupMembersCheck < SystemCheck::BaseCheck
- set_name 'Database contains orphaned GroupMembers?'
- set_check_pass 'no'
- set_check_fail 'yes'
+ set_name "Database contains orphaned GroupMembers?"
+ set_check_pass "no"
+ set_check_fail "yes"
def check?
- !GroupMember.where('user_id not in (select id from users)').exists?
+ !GroupMember.where("user_id not in (select id from users)").exists?
end
def show_error
try_fixing_it(
- 'You can delete the orphaned records using something along the lines of:',
+ "You can delete the orphaned records using something along the lines of:",
sudo_gitlab("bundle exec rails runner -e production 'GroupMember.where(\"user_id NOT IN (SELECT id FROM users)\").delete_all'")
)
end
diff --git a/lib/system_check/app/projects_have_namespace_check.rb b/lib/system_check/app/projects_have_namespace_check.rb
index 2bf2529acf1..b47ce5ac0b7 100644
--- a/lib/system_check/app/projects_have_namespace_check.rb
+++ b/lib/system_check/app/projects_have_namespace_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module App
class ProjectsHaveNamespaceCheck < SystemCheck::BaseCheck
- set_name 'Projects have namespace:'
+ set_name "Projects have namespace:"
set_skip_reason "can't check, you have no projects"
def skip?
@@ -11,15 +11,15 @@ module SystemCheck
end
def multi_check
- $stdout.puts ''
+ $stdout.puts ""
Project.find_each(batch_size: 100) do |project|
$stdout.print sanitized_message(project)
if project.namespace
- $stdout.puts 'yes'.color(:green)
+ $stdout.puts "yes".color(:green)
else
- $stdout.puts 'no'.color(:red)
+ $stdout.puts "no".color(:red)
show_error
end
end
diff --git a/lib/system_check/app/redis_version_check.rb b/lib/system_check/app/redis_version_check.rb
index 890f8b44d13..6f66fe8fe43 100644
--- a/lib/system_check/app/redis_version_check.rb
+++ b/lib/system_check/app/redis_version_check.rb
@@ -3,11 +3,11 @@
module SystemCheck
module App
class RedisVersionCheck < SystemCheck::BaseCheck
- MIN_REDIS_VERSION = '2.8.0'.freeze
+ MIN_REDIS_VERSION = "2.8.0"
set_name "Redis version >= #{MIN_REDIS_VERSION}?"
def check?
- redis_version = run_command(%w(redis-cli --version))
+ redis_version = run_command(%w[redis-cli --version])
redis_version = redis_version.try(:match, /redis-cli (\d+\.\d+\.\d+)/)
redis_version && (Gem::Version.new(redis_version[1]) > Gem::Version.new(MIN_REDIS_VERSION))
@@ -18,7 +18,7 @@ module SystemCheck
"Update your redis server to a version >= #{MIN_REDIS_VERSION}"
)
for_more_information(
- 'gitlab-public-wiki/wiki/Trouble-Shooting-Guide in section sidekiq'
+ "gitlab-public-wiki/wiki/Trouble-Shooting-Guide in section sidekiq"
)
fix_and_rerun
end
diff --git a/lib/system_check/app/ruby_version_check.rb b/lib/system_check/app/ruby_version_check.rb
index 60e07718338..81540b43f49 100644
--- a/lib/system_check/app/ruby_version_check.rb
+++ b/lib/system_check/app/ruby_version_check.rb
@@ -3,8 +3,8 @@
module SystemCheck
module App
class RubyVersionCheck < SystemCheck::BaseCheck
- set_name -> { "Ruby version >= #{self.required_version} ?" }
- set_check_pass -> { "yes (#{self.current_version})" }
+ set_name -> { "Ruby version >= #{required_version} ?" }
+ set_check_pass -> { "yes (#{current_version})" }
def self.required_version
@required_version ||= Gitlab::VersionInfo.new(2, 3, 5)
diff --git a/lib/system_check/app/tmp_writable_check.rb b/lib/system_check/app/tmp_writable_check.rb
index 6687df091d3..63f6e57b498 100644
--- a/lib/system_check/app/tmp_writable_check.rb
+++ b/lib/system_check/app/tmp_writable_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module App
class TmpWritableCheck < SystemCheck::BaseCheck
- set_name 'Tmp directory writable?'
+ set_name "Tmp directory writable?"
def check?
File.writable?(tmp_path)
@@ -15,7 +15,7 @@ module SystemCheck
"sudo chmod -R u+rwX #{tmp_path}"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
@@ -23,7 +23,7 @@ module SystemCheck
private
def tmp_path
- Rails.root.join('tmp')
+ Rails.root.join("tmp")
end
end
end
diff --git a/lib/system_check/app/uploads_directory_exists_check.rb b/lib/system_check/app/uploads_directory_exists_check.rb
index 940eff9d4cf..dd61b8093c8 100644
--- a/lib/system_check/app/uploads_directory_exists_check.rb
+++ b/lib/system_check/app/uploads_directory_exists_check.rb
@@ -3,10 +3,10 @@
module SystemCheck
module App
class UploadsDirectoryExistsCheck < SystemCheck::BaseCheck
- set_name 'Uploads directory exists?'
+ set_name "Uploads directory exists?"
def check?
- File.directory?(Rails.root.join('public/uploads'))
+ File.directory?(Rails.root.join("public/uploads"))
end
def show_error
@@ -14,7 +14,7 @@ module SystemCheck
"sudo -u #{gitlab_user} mkdir #{Rails.root}/public/uploads"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
diff --git a/lib/system_check/app/uploads_path_permission_check.rb b/lib/system_check/app/uploads_path_permission_check.rb
index 4a49f3bc2bb..e1fdf88d6f7 100644
--- a/lib/system_check/app/uploads_path_permission_check.rb
+++ b/lib/system_check/app/uploads_path_permission_check.rb
@@ -3,15 +3,15 @@
module SystemCheck
module App
class UploadsPathPermissionCheck < SystemCheck::BaseCheck
- set_name 'Uploads directory has correct permissions?'
- set_skip_reason 'skipped (no uploads folder found)'
+ set_name "Uploads directory has correct permissions?"
+ set_skip_reason "skipped (no uploads folder found)"
def skip?
!File.directory?(rails_uploads_path)
end
def check?
- File.stat(uploads_fullpath).mode == 040700
+ File.stat(uploads_fullpath).mode == 0o40700
end
def show_error
@@ -19,7 +19,7 @@ module SystemCheck
"sudo chmod 700 #{uploads_fullpath}"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
@@ -27,7 +27,7 @@ module SystemCheck
private
def rails_uploads_path
- Rails.root.join('public/uploads')
+ Rails.root.join("public/uploads")
end
def uploads_fullpath
diff --git a/lib/system_check/app/uploads_path_tmp_permission_check.rb b/lib/system_check/app/uploads_path_tmp_permission_check.rb
index ae374f4707c..1c6aea6d9ac 100644
--- a/lib/system_check/app/uploads_path_tmp_permission_check.rb
+++ b/lib/system_check/app/uploads_path_tmp_permission_check.rb
@@ -3,8 +3,8 @@
module SystemCheck
module App
class UploadsPathTmpPermissionCheck < SystemCheck::BaseCheck
- set_name 'Uploads directory tmp has correct permissions?'
- set_skip_reason 'skipped (no tmp uploads folder yet)'
+ set_name "Uploads directory tmp has correct permissions?"
+ set_skip_reason "skipped (no tmp uploads folder yet)"
def skip?
!File.directory?(uploads_fullpath) || !Dir.exist?(upload_path_tmp)
@@ -13,7 +13,7 @@ module SystemCheck
def check?
# If tmp upload dir has incorrect permissions, assume others do as well
# Verify drwx------ permissions
- File.stat(upload_path_tmp).mode == 040700 && File.owned?(upload_path_tmp)
+ File.stat(upload_path_tmp).mode == 0o40700 && File.owned?(upload_path_tmp)
end
def show_error
@@ -23,7 +23,7 @@ module SystemCheck
"sudo find #{uploads_fullpath} -type d -not -path #{uploads_fullpath} -exec chmod 0700 {} \\;"
)
for_more_information(
- see_installation_guide_section 'GitLab'
+ see_installation_guide_section("GitLab")
)
fix_and_rerun
end
@@ -31,11 +31,11 @@ module SystemCheck
private
def upload_path_tmp
- File.join(uploads_fullpath, 'tmp')
+ File.join(uploads_fullpath, "tmp")
end
def uploads_fullpath
- File.realpath(Rails.root.join('public/uploads'))
+ File.realpath(Rails.root.join("public/uploads"))
end
end
end
diff --git a/lib/system_check/base_check.rb b/lib/system_check/base_check.rb
index 46aad8aa885..d374bea1936 100644
--- a/lib/system_check/base_check.rb
+++ b/lib/system_check/base_check.rb
@@ -40,28 +40,28 @@ module SystemCheck
#
# @return [String] term when check passed ('yes' if not re-defined in a subclass)
def self.check_pass
- call_or_return(@check_pass) || 'yes'
+ call_or_return(@check_pass) || "yes"
end
## Term to be displayed when check failed
#
# @return [String] term when check failed ('no' if not re-defined in a subclass)
def self.check_fail
- call_or_return(@check_fail) || 'no'
+ call_or_return(@check_fail) || "no"
end
# Name of the SystemCheck defined by the subclass
#
# @return [String] the name
def self.display_name
- call_or_return(@name) || self.name
+ call_or_return(@name) || name
end
# Skip reason defined by the subclass
#
# @return [String] the reason
def self.skip_reason
- call_or_return(@skip_reason) || 'skipped'
+ call_or_return(@skip_reason) || "skipped"
end
# Define a reason why we skipped the SystemCheck (during runtime)
diff --git a/lib/system_check/gitaly_check.rb b/lib/system_check/gitaly_check.rb
index 3d2517a7aca..9ce78d9c8d3 100644
--- a/lib/system_check/gitaly_check.rb
+++ b/lib/system_check/gitaly_check.rb
@@ -2,14 +2,14 @@
module SystemCheck
class GitalyCheck < BaseCheck
- set_name 'Gitaly:'
+ set_name "Gitaly:"
def multi_check
Gitlab::HealthChecks::GitalyCheck.readiness.each do |result|
$stdout.print "#{result.labels[:shard]} ... "
if result.success
- $stdout.puts 'OK'.color(:green)
+ $stdout.puts "OK".color(:green)
else
$stdout.puts "FAIL: #{result.message}".color(:red)
end
diff --git a/lib/system_check/gitlab_shell_check.rb b/lib/system_check/gitlab_shell_check.rb
index 31c4ec33247..bd12c57051b 100644
--- a/lib/system_check/gitlab_shell_check.rb
+++ b/lib/system_check/gitlab_shell_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
# Used by gitlab:gitlab_shell:check rake task
class GitlabShellCheck < BaseCheck
- set_name 'GitLab Shell:'
+ set_name "GitLab Shell:"
def multi_check
check_gitlab_shell
@@ -26,17 +26,17 @@ module SystemCheck
def check_gitlab_shell_self_test
gitlab_shell_repo_base = gitlab_shell_path
- check_cmd = File.expand_path('bin/check', gitlab_shell_repo_base)
+ check_cmd = File.expand_path("bin/check", gitlab_shell_repo_base)
$stdout.puts "Running #{check_cmd}"
if system(check_cmd, chdir: gitlab_shell_repo_base)
- $stdout.puts 'gitlab-shell self-check successful'.color(:green)
+ $stdout.puts "gitlab-shell self-check successful".color(:green)
else
- $stdout.puts 'gitlab-shell self-check failed'.color(:red)
+ $stdout.puts "gitlab-shell self-check failed".color(:red)
try_fixing_it(
- 'Make sure GitLab is running;',
- 'Check the gitlab-shell configuration file:',
- sudo_gitlab("editor #{File.expand_path('config.yml', gitlab_shell_repo_base)}")
+ "Make sure GitLab is running;",
+ "Check the gitlab-shell configuration file:",
+ sudo_gitlab("editor #{File.expand_path("config.yml", gitlab_shell_repo_base)}")
)
fix_and_rerun
end
diff --git a/lib/system_check/helpers.rb b/lib/system_check/helpers.rb
index 07d479848fe..daad28c78ff 100644
--- a/lib/system_check/helpers.rb
+++ b/lib/system_check/helpers.rb
@@ -6,14 +6,14 @@ module SystemCheck
# Display a message telling to fix and rerun the checks
def fix_and_rerun
- $stdout.puts ' Please fix the error above and rerun the checks.'.color(:red)
+ $stdout.puts " Please fix the error above and rerun the checks.".color(:red)
end
# Display a formatted list of references (documentation or links) where to find more information
#
# @param [Array<String>] sources one or more references (documentation or links)
def for_more_information(*sources)
- $stdout.puts ' For more information see:'.color(:blue)
+ $stdout.puts " For more information see:".color(:blue)
sources.each do |source|
$stdout.puts " #{source}"
end
@@ -25,15 +25,15 @@ module SystemCheck
# @deprecated This will no longer be used when all checks were executed using SystemCheck
def finished_checking(component)
- $stdout.puts ''
- $stdout.puts "Checking #{component.color(:yellow)} ... #{'Finished'.color(:green)}"
- $stdout.puts ''
+ $stdout.puts ""
+ $stdout.puts "Checking #{component.color(:yellow)} ... #{"Finished".color(:green)}"
+ $stdout.puts ""
end
# @deprecated This will no longer be used when all checks were executed using SystemCheck
def start_checking(component)
$stdout.puts "Checking #{component.color(:yellow)} ..."
- $stdout.puts ''
+ $stdout.puts ""
end
# Display a formatted list of instructions on how to fix the issue identified by the #check?
@@ -42,7 +42,7 @@ module SystemCheck
def try_fixing_it(*steps)
steps = steps.shift if steps.first.is_a?(Array)
- $stdout.puts ' Try fixing it:'.color(:blue)
+ $stdout.puts " Try fixing it:".color(:blue)
steps.each do |step|
$stdout.puts " #{step}"
end
@@ -57,15 +57,11 @@ module SystemCheck
end
def should_sanitize?
- if ENV['SANITIZE'] == 'true'
- true
- else
- false
- end
+ ENV["SANITIZE"] == "true"
end
def omnibus_gitlab?
- Dir.pwd == '/opt/gitlab/embedded/service/gitlab-rails'
+ Dir.pwd == "/opt/gitlab/embedded/service/gitlab-rails"
end
def sudo_gitlab(command)
diff --git a/lib/system_check/incoming_email/foreman_configured_check.rb b/lib/system_check/incoming_email/foreman_configured_check.rb
index 944913087da..f5206998276 100644
--- a/lib/system_check/incoming_email/foreman_configured_check.rb
+++ b/lib/system_check/incoming_email/foreman_configured_check.rb
@@ -3,20 +3,20 @@
module SystemCheck
module IncomingEmail
class ForemanConfiguredCheck < SystemCheck::BaseCheck
- set_name 'Foreman configured correctly?'
+ set_name "Foreman configured correctly?"
def check?
- path = Rails.root.join('Procfile')
+ path = Rails.root.join("Procfile")
File.exist?(path) && File.read(path) =~ /^mail_room:/
end
def show_error
try_fixing_it(
- 'Enable mail_room in your Procfile.'
+ "Enable mail_room in your Procfile."
)
for_more_information(
- 'doc/administration/reply_by_email.md'
+ "doc/administration/reply_by_email.md"
)
fix_and_rerun
end
diff --git a/lib/system_check/incoming_email/imap_authentication_check.rb b/lib/system_check/incoming_email/imap_authentication_check.rb
index 613c2296375..d9f67011ee2 100644
--- a/lib/system_check/incoming_email/imap_authentication_check.rb
+++ b/lib/system_check/incoming_email/imap_authentication_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module IncomingEmail
class ImapAuthenticationCheck < SystemCheck::BaseCheck
- set_name 'IMAP server credentials are correct?'
+ set_name "IMAP server credentials are correct?"
def check?
if config
@@ -17,10 +17,10 @@ module SystemCheck
def show_error
try_fixing_it(
"An error occurred: #{@error.class}: #{@error.message}",
- 'Check that the information in config/gitlab.yml is correct'
+ "Check that the information in config/gitlab.yml is correct"
)
for_more_information(
- 'doc/administration/reply_by_email.md'
+ "doc/administration/reply_by_email.md"
)
fix_and_rerun
end
@@ -43,7 +43,7 @@ module SystemCheck
def mail_room_config_path
@mail_room_config_path ||=
- Rails.root.join('config', 'mail_room.yml').to_s
+ Rails.root.join("config", "mail_room.yml").to_s
end
def load_config
diff --git a/lib/system_check/incoming_email/initd_configured_check.rb b/lib/system_check/incoming_email/initd_configured_check.rb
index acb4b5a9e74..ae300938958 100644
--- a/lib/system_check/incoming_email/initd_configured_check.rb
+++ b/lib/system_check/incoming_email/initd_configured_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module IncomingEmail
class InitdConfiguredCheck < SystemCheck::BaseCheck
- set_name 'Init.d configured correctly?'
+ set_name "Init.d configured correctly?"
def skip?
omnibus_gitlab?
@@ -15,10 +15,10 @@ module SystemCheck
def show_error
try_fixing_it(
- 'Enable mail_room in the init.d configuration.'
+ "Enable mail_room in the init.d configuration."
)
for_more_information(
- 'doc/administration/reply_by_email.md'
+ "doc/administration/reply_by_email.md"
)
fix_and_rerun
end
@@ -26,8 +26,8 @@ module SystemCheck
private
def mail_room_configured?
- path = '/etc/default/gitlab'
- File.exist?(path) && File.read(path).include?('mail_room_enabled=true')
+ path = "/etc/default/gitlab"
+ File.exist?(path) && File.read(path).include?("mail_room_enabled=true")
end
end
end
diff --git a/lib/system_check/incoming_email/mail_room_running_check.rb b/lib/system_check/incoming_email/mail_room_running_check.rb
index b7aead4624e..f979b1f322d 100644
--- a/lib/system_check/incoming_email/mail_room_running_check.rb
+++ b/lib/system_check/incoming_email/mail_room_running_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module IncomingEmail
class MailRoomRunningCheck < SystemCheck::BaseCheck
- set_name 'MailRoom running?'
+ set_name "MailRoom running?"
def skip?
return true if omnibus_gitlab?
@@ -20,11 +20,11 @@ module SystemCheck
def show_error
try_fixing_it(
- sudo_gitlab('RAILS_ENV=production bin/mail_room start')
+ sudo_gitlab("RAILS_ENV=production bin/mail_room start")
)
for_more_information(
- see_installation_guide_section('Install Init Script'),
- 'see log/mail_room.log for possible errors'
+ see_installation_guide_section("Install Init Script"),
+ "see log/mail_room.log for possible errors"
)
fix_and_rerun
end
@@ -32,12 +32,12 @@ module SystemCheck
private
def mail_room_configured?
- path = '/etc/default/gitlab'
- File.exist?(path) && File.read(path).include?('mail_room_enabled=true')
+ path = "/etc/default/gitlab"
+ File.exist?(path) && File.read(path).include?("mail_room_enabled=true")
end
def mail_room_running?
- ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww))
+ ps_ux, _ = Gitlab::Popen.popen(%w[ps uxww])
ps_ux.include?("mail_room")
end
end
diff --git a/lib/system_check/incoming_email_check.rb b/lib/system_check/incoming_email_check.rb
index 155b6547595..96642eb651d 100644
--- a/lib/system_check/incoming_email_check.rb
+++ b/lib/system_check/incoming_email_check.rb
@@ -3,12 +3,12 @@
module SystemCheck
# Used by gitlab:incoming_email:check rake task
class IncomingEmailCheck < BaseCheck
- set_name 'Incoming Email:'
+ set_name "Incoming Email:"
def multi_check
if Gitlab.config.incoming_email.enabled
checks = [
- SystemCheck::IncomingEmail::ImapAuthenticationCheck
+ SystemCheck::IncomingEmail::ImapAuthenticationCheck,
]
if Rails.env.production?
@@ -18,9 +18,9 @@ module SystemCheck
checks << SystemCheck::IncomingEmail::ForemanConfiguredCheck
end
- SystemCheck.run('Reply by email', checks)
+ SystemCheck.run("Reply by email", checks)
else
- $stdout.puts 'Reply by email is disabled in config/gitlab.yml'
+ $stdout.puts "Reply by email is disabled in config/gitlab.yml"
end
end
end
diff --git a/lib/system_check/ldap_check.rb b/lib/system_check/ldap_check.rb
index 619fb3cccb8..45fd6285829 100644
--- a/lib/system_check/ldap_check.rb
+++ b/lib/system_check/ldap_check.rb
@@ -3,18 +3,18 @@
module SystemCheck
# Used by gitlab:ldap:check rake task
class LdapCheck < BaseCheck
- set_name 'LDAP:'
+ set_name "LDAP:"
def multi_check
if Gitlab::Auth::LDAP::Config.enabled?
# Only show up to 100 results because LDAP directories can be very big.
# This setting only affects the `rake gitlab:check` script.
- limit = ENV['LDAP_CHECK_LIMIT']
+ limit = ENV["LDAP_CHECK_LIMIT"]
limit = 100 if limit.blank?
check_ldap(limit)
else
- $stdout.puts 'LDAP is disabled in config/gitlab.yml'
+ $stdout.puts "LDAP is disabled in config/gitlab.yml"
end
end
@@ -32,7 +32,7 @@ module SystemCheck
$stdout.puts "LDAP users with access to your GitLab server (only showing the first #{limit} results)"
- users = adapter.users(adapter.config.uid, '*', limit)
+ users = adapter.users(adapter.config.uid, "*", limit)
users.each do |user|
$stdout.puts "\tDN: #{user.dn}\t #{adapter.config.uid}: #{user.uid}"
end
@@ -47,12 +47,12 @@ module SystemCheck
auth = adapter.config.has_auth?
message = if auth && adapter.ldap.bind
- 'Success'.color(:green)
- elsif auth
- 'Failed. Check `bind_dn` and `password` configuration values'.color(:red)
- else
- 'Anonymous. No `bind_dn` or `password` configured'.color(:yellow)
- end
+ "Success".color(:green)
+ elsif auth
+ "Failed. Check `bind_dn` and `password` configuration values".color(:red)
+ else
+ "Anonymous. No `bind_dn` or `password` configured".color(:yellow)
+ end
$stdout.puts "LDAP authentication... #{message}"
end
diff --git a/lib/system_check/orphans/namespace_check.rb b/lib/system_check/orphans/namespace_check.rb
index 53b2d8fd5b3..71bb4809a45 100644
--- a/lib/system_check/orphans/namespace_check.rb
+++ b/lib/system_check/orphans/namespace_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module Orphans
class NamespaceCheck < SystemCheck::BaseCheck
- set_name 'Orphaned namespaces:'
+ set_name "Orphaned namespaces:"
def multi_check
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
@@ -36,14 +36,14 @@ module SystemCheck
def disk_namespaces(storage_path)
fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result|
namespace = File.basename(namespace_path)
- next if namespace.eql?('@hashed')
+ next if namespace.eql?("@hashed")
result << namespace
end
end
def fetch_disk_namespaces(storage_path)
- Dir.glob(File.join(storage_path, '*'))
+ Dir.glob(File.join(storage_path, "*"))
end
def existing_namespaces
diff --git a/lib/system_check/orphans/repository_check.rb b/lib/system_check/orphans/repository_check.rb
index 33020417e95..c1b290486b0 100644
--- a/lib/system_check/orphans/repository_check.rb
+++ b/lib/system_check/orphans/repository_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
module Orphans
class RepositoryCheck < SystemCheck::BaseCheck
- set_name 'Orphaned repositories:'
+ set_name "Orphaned repositories:"
def multi_check
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
@@ -37,7 +37,7 @@ module SystemCheck
def disk_repositories(storage_path)
fetch_disk_namespaces(storage_path).each_with_object([]) do |namespace_path, result|
namespace = File.basename(namespace_path)
- next if namespace.eql?('@hashed')
+ next if namespace.eql?("@hashed")
fetch_disk_repositories(namespace_path).each do |repo|
result << "#{namespace}/#{File.basename(repo)}"
@@ -62,11 +62,11 @@ module SystemCheck
end
def fetch_disk_namespaces(storage_path)
- Dir.glob(File.join(storage_path, '*'))
+ Dir.glob(File.join(storage_path, "*"))
end
def fetch_disk_repositories(namespace_path)
- Dir.glob(File.join(namespace_path, '*'))
+ Dir.glob(File.join(namespace_path, "*"))
end
end
end
diff --git a/lib/system_check/rake_task/app_task.rb b/lib/system_check/rake_task/app_task.rb
index cc32feb8604..3dba8800139 100644
--- a/lib/system_check/rake_task/app_task.rb
+++ b/lib/system_check/rake_task/app_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'GitLab App'
+ "GitLab App"
end
def self.checks
@@ -30,7 +30,7 @@ module SystemCheck
SystemCheck::App::RubyVersionCheck,
SystemCheck::App::GitVersionCheck,
SystemCheck::App::GitUserDefaultSSHConfigCheck,
- SystemCheck::App::ActiveUsersCheck
+ SystemCheck::App::ActiveUsersCheck,
]
end
end
diff --git a/lib/system_check/rake_task/gitaly_task.rb b/lib/system_check/rake_task/gitaly_task.rb
index 0c3f694f98a..cf7ac292445 100644
--- a/lib/system_check/rake_task/gitaly_task.rb
+++ b/lib/system_check/rake_task/gitaly_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Gitaly'
+ "Gitaly"
end
def self.checks
diff --git a/lib/system_check/rake_task/gitlab_shell_task.rb b/lib/system_check/rake_task/gitlab_shell_task.rb
index 120e984c68b..453962260cb 100644
--- a/lib/system_check/rake_task/gitlab_shell_task.rb
+++ b/lib/system_check/rake_task/gitlab_shell_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'GitLab Shell'
+ "GitLab Shell"
end
def self.checks
diff --git a/lib/system_check/rake_task/gitlab_task.rb b/lib/system_check/rake_task/gitlab_task.rb
index 7ff36fd6eb5..6001d72f643 100644
--- a/lib/system_check/rake_task/gitlab_task.rb
+++ b/lib/system_check/rake_task/gitlab_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'GitLab'
+ "GitLab"
end
def self.manual_run_checks!
@@ -25,7 +25,7 @@ module SystemCheck
SystemCheck::RakeTask::SidekiqTask,
SystemCheck::RakeTask::IncomingEmailTask,
SystemCheck::RakeTask::LdapTask,
- SystemCheck::RakeTask::AppTask
+ SystemCheck::RakeTask::AppTask,
]
end
end
diff --git a/lib/system_check/rake_task/incoming_email_task.rb b/lib/system_check/rake_task/incoming_email_task.rb
index c296c46feab..562367d63fa 100644
--- a/lib/system_check/rake_task/incoming_email_task.rb
+++ b/lib/system_check/rake_task/incoming_email_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Incoming Email'
+ "Incoming Email"
end
def self.checks
diff --git a/lib/system_check/rake_task/ldap_task.rb b/lib/system_check/rake_task/ldap_task.rb
index 03a180b9dfb..10e85da0c1f 100644
--- a/lib/system_check/rake_task/ldap_task.rb
+++ b/lib/system_check/rake_task/ldap_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'LDAP'
+ "LDAP"
end
def self.checks
diff --git a/lib/system_check/rake_task/orphans/namespace_task.rb b/lib/system_check/rake_task/orphans/namespace_task.rb
index 2822da45bc1..20a321ef4df 100644
--- a/lib/system_check/rake_task/orphans/namespace_task.rb
+++ b/lib/system_check/rake_task/orphans/namespace_task.rb
@@ -8,7 +8,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Orphans'
+ "Orphans"
end
def self.checks
diff --git a/lib/system_check/rake_task/orphans/repository_task.rb b/lib/system_check/rake_task/orphans/repository_task.rb
index f14b3af22e8..8eb84c707da 100644
--- a/lib/system_check/rake_task/orphans/repository_task.rb
+++ b/lib/system_check/rake_task/orphans/repository_task.rb
@@ -8,7 +8,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Orphans'
+ "Orphans"
end
def self.checks
diff --git a/lib/system_check/rake_task/orphans_task.rb b/lib/system_check/rake_task/orphans_task.rb
index 31f8ede25e0..5677e4e21a8 100644
--- a/lib/system_check/rake_task/orphans_task.rb
+++ b/lib/system_check/rake_task/orphans_task.rb
@@ -7,13 +7,13 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Orphans'
+ "Orphans"
end
def self.checks
[
SystemCheck::Orphans::NamespaceCheck,
- SystemCheck::Orphans::RepositoryCheck
+ SystemCheck::Orphans::RepositoryCheck,
]
end
end
diff --git a/lib/system_check/rake_task/rake_task_helpers.rb b/lib/system_check/rake_task/rake_task_helpers.rb
index 95f2a34a719..0c4b3967168 100644
--- a/lib/system_check/rake_task/rake_task_helpers.rb
+++ b/lib/system_check/rake_task/rake_task_helpers.rb
@@ -9,7 +9,7 @@ module SystemCheck
def run!
warn_user_is_not_gitlab
- if self.respond_to?(:manual_run_checks!)
+ if respond_to?(:manual_run_checks!)
manual_run_checks!
else
run_checks!
diff --git a/lib/system_check/rake_task/sidekiq_task.rb b/lib/system_check/rake_task/sidekiq_task.rb
index 3ccf009d4b9..5c3af5e1a2c 100644
--- a/lib/system_check/rake_task/sidekiq_task.rb
+++ b/lib/system_check/rake_task/sidekiq_task.rb
@@ -7,7 +7,7 @@ module SystemCheck
extend RakeTaskHelpers
def self.name
- 'Sidekiq'
+ "Sidekiq"
end
def self.checks
diff --git a/lib/system_check/sidekiq_check.rb b/lib/system_check/sidekiq_check.rb
index 2f5fc2cea89..f7d1e7bf172 100644
--- a/lib/system_check/sidekiq_check.rb
+++ b/lib/system_check/sidekiq_check.rb
@@ -3,7 +3,7 @@
module SystemCheck
# Used by gitlab:sidekiq:check rake task
class SidekiqCheck < BaseCheck
- set_name 'Sidekiq:'
+ set_name "Sidekiq:"
def multi_check
check_sidekiq_running
@@ -34,24 +34,24 @@ module SystemCheck
process_count = sidekiq_process_count
return if process_count.zero?
- $stdout.print 'Number of Sidekiq processes ... '
+ $stdout.print "Number of Sidekiq processes ... "
if process_count == 1
- $stdout.puts '1'.color(:green)
+ $stdout.puts "1".color(:green)
else
- $stdout.puts "#{process_count}".color(:red)
+ $stdout.puts process_count.to_s.color(:red)
try_fixing_it(
- 'sudo service gitlab stop',
+ "sudo service gitlab stop",
"sudo pkill -u #{gitlab_user} -f sidekiq",
"sleep 10 && sudo pkill -9 -u #{gitlab_user} -f sidekiq",
- 'sudo service gitlab start'
+ "sudo service gitlab start"
)
fix_and_rerun
end
end
def sidekiq_process_count
- ps_ux, _ = Gitlab::Popen.popen(%w(ps uxww))
+ ps_ux, _ = Gitlab::Popen.popen(%w[ps uxww])
ps_ux.scan(/sidekiq \d+\.\d+\.\d+/).count
end
end
diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb
index 11818ae54f8..0801e4e0d9b 100644
--- a/lib/system_check/simple_executor.rb
+++ b/lib/system_check/simple_executor.rb
@@ -67,7 +67,7 @@ module SystemCheck
print_check_failure(check_klass)
if check.can_repair?
- $stdout.print 'Trying to fix error automatically. ...'
+ $stdout.print "Trying to fix error automatically. ..."
if check.repair!
print_success
@@ -79,7 +79,7 @@ module SystemCheck
check.show_error
end
- rescue StandardError => e
+ rescue => e
$stdout.puts "Exception: #{e.message}".color(:red)
end
@@ -98,11 +98,11 @@ module SystemCheck
end
def print_success
- $stdout.puts 'Success'.color(:green)
+ $stdout.puts "Success".color(:green)
end
def print_failure
- $stdout.puts 'Failed'.color(:red)
+ $stdout.puts "Failed".color(:red)
end
# Prints header content for the series of checks to be executed for this component
@@ -110,16 +110,16 @@ module SystemCheck
# @param [String] component name of the component relative to the checks being executed
def start_checking(component)
$stdout.puts "Checking #{component.color(:yellow)} ..."
- $stdout.puts ''
+ $stdout.puts ""
end
# Prints footer content for the series of checks executed for this component
#
# @param [String] component name of the component relative to the checks being executed
def finished_checking(component)
- $stdout.puts ''
- $stdout.puts "Checking #{component.color(:yellow)} ... #{'Finished'.color(:green)}"
- $stdout.puts ''
+ $stdout.puts ""
+ $stdout.puts "Checking #{component.color(:yellow)} ... #{"Finished".color(:green)}"
+ $stdout.puts ""
end
end
end
diff --git a/lib/tasks/brakeman.rake b/lib/tasks/brakeman.rake
index 2301ec9b228..284b077f1d3 100644
--- a/lib/tasks/brakeman.rake
+++ b/lib/tasks/brakeman.rake
@@ -1,11 +1,11 @@
-desc 'Security check via brakeman'
+desc "Security check via brakeman"
task :brakeman do
# We get 0 warnings at level 'w3' but we would like to reach 'w2'. Merge
# requests are welcome!
- if system(*%w(brakeman --no-progress --skip-files lib/backup/repository.rb -w3 -z))
- puts 'Security check succeed'
+ if system("brakeman", "--no-progress", "--skip-files", "lib/backup/repository.rb", "-w3", "-z")
+ puts "Security check succeed"
else
- puts 'Security check failed'
+ puts "Security check failed"
exit 1
end
end
diff --git a/lib/tasks/cache.rake b/lib/tasks/cache.rake
index cb4d5abffbc..3b2cae9eef5 100644
--- a/lib/tasks/cache.rake
+++ b/lib/tasks/cache.rake
@@ -1,7 +1,7 @@
namespace :cache do
namespace :clear do
REDIS_CLEAR_BATCH_SIZE = 1000 # There seems to be no speedup when pushing beyond 1,000
- REDIS_SCAN_START_STOP = '0'.freeze # Magic value, see http://redis.io/commands/scan
+ REDIS_SCAN_START_STOP = "0".freeze # Magic value, see http://redis.io/commands/scan
desc "GitLab | Clear redis cache"
task redis: :environment do
@@ -29,5 +29,5 @@ namespace :cache do
task all: [:redis]
end
- task clear: 'cache:clear:redis'
+ task clear: "cache:clear:redis"
end
diff --git a/lib/tasks/ci/cleanup.rake b/lib/tasks/ci/cleanup.rake
index 2f4d11bd942..4ae3754f3ef 100644
--- a/lib/tasks/ci/cleanup.rake
+++ b/lib/tasks/ci/cleanup.rake
@@ -2,7 +2,7 @@ namespace :ci do
namespace :cleanup do
desc "GitLab CI | Clean running builds"
task builds: :environment do
- Ci::Build.running.update_all(status: 'canceled')
+ Ci::Build.running.update_all(status: "canceled")
end
end
end
diff --git a/lib/tasks/config_lint.rake b/lib/tasks/config_lint.rake
index ddbcf1e1eb8..6ebe4374378 100644
--- a/lib/tasks/config_lint.rake
+++ b/lib/tasks/config_lint.rake
@@ -1,8 +1,8 @@
module ConfigLint
def self.run(files)
- failures = files.reject do |file|
+ failures = files.reject { |file|
yield(file)
- end
+ }
if failures.present?
puts failures
@@ -14,12 +14,12 @@ end
desc "Checks syntax for shell scripts and nginx config files in 'lib/support/'"
task :config_lint do
shell_scripts = [
- 'lib/support/init.d/gitlab',
- 'lib/support/init.d/gitlab.default.example',
- 'lib/support/deploy/deploy.sh'
+ "lib/support/init.d/gitlab",
+ "lib/support/init.d/gitlab.default.example",
+ "lib/support/deploy/deploy.sh",
]
ConfigLint.run(shell_scripts) do |file|
- Kernel.system('bash', '-n', file)
+ Kernel.system("bash", "-n", file)
end
end
diff --git a/lib/tasks/dev.rake b/lib/tasks/dev.rake
index b1db4dc94a6..7b4d55ce9a5 100644
--- a/lib/tasks/dev.rake
+++ b/lib/tasks/dev.rake
@@ -3,7 +3,7 @@ task dev: ["dev:setup"]
namespace :dev do
desc "GitLab | Setup developer environment (db, fixtures)"
task setup: :environment do
- ENV['force'] = 'yes'
+ ENV["force"] = "yes"
Rake::Task["gitlab:setup"].invoke
Rake::Task["gitlab:shell:setup"].invoke
end
diff --git a/lib/tasks/downtime_check.rake b/lib/tasks/downtime_check.rake
index 557f4fef10b..b55882a3973 100644
--- a/lib/tasks/downtime_check.rake
+++ b/lib/tasks/downtime_check.rake
@@ -1,12 +1,12 @@
-desc 'Checks if migrations in a branch require downtime'
+desc "Checks if migrations in a branch require downtime"
task downtime_check: :environment do
repo = if defined?(Gitlab::License)
- 'gitlab-ee'
- else
- 'gitlab-ce'
- end
+ "gitlab-ee"
+ else
+ "gitlab-ce"
+ end
`git fetch https://gitlab.com/gitlab-org/#{repo}.git --depth 1`
- Rake::Task['gitlab:db:downtime_check'].invoke('FETCH_HEAD')
+ Rake::Task["gitlab:db:downtime_check"].invoke("FETCH_HEAD")
end
diff --git a/lib/tasks/ee_compat_check.rake b/lib/tasks/ee_compat_check.rake
index f494fa5c5c2..e9f88fad326 100644
--- a/lib/tasks/ee_compat_check.rake
+++ b/lib/tasks/ee_compat_check.rake
@@ -1,4 +1,4 @@
-desc 'Checks if the branch would apply cleanly to EE'
+desc "Checks if the branch would apply cleanly to EE"
task ee_compat_check: :environment do
- Rake::Task['gitlab:dev:ee_compat_check'].invoke
+ Rake::Task["gitlab:dev:ee_compat_check"].invoke
end
diff --git a/lib/tasks/eslint.rake b/lib/tasks/eslint.rake
index 51f5d768102..49d2a8cd821 100644
--- a/lib/tasks/eslint.rake
+++ b/lib/tasks/eslint.rake
@@ -1,8 +1,8 @@
unless Rails.env.production?
desc "GitLab | Run ESLint"
- task eslint: ['yarn:check'] do
- unless system('yarn run eslint')
- abort('rake eslint failed')
+ task eslint: ["yarn:check"] do
+ unless system("yarn run eslint")
+ abort("rake eslint failed")
end
end
end
diff --git a/lib/tasks/gemojione.rake b/lib/tasks/gemojione.rake
index 560a52053d8..e7fc46be9b3 100644
--- a/lib/tasks/gemojione.rake
+++ b/lib/tasks/gemojione.rake
@@ -1,34 +1,34 @@
namespace :gemojione do
- desc 'Generates Emoji SHA256 digests'
+ desc "Generates Emoji SHA256 digests"
- task aliases: ['yarn:check', 'environment'] do
- require 'json'
+ task aliases: ["yarn:check", "environment"] do
+ require "json"
aliases = {}
- index_file = File.join(Rails.root, 'fixtures', 'emojis', 'index.json')
+ index_file = File.join(Rails.root, "fixtures", "emojis", "index.json")
index = JSON.parse(File.read(index_file))
index.each_pair do |key, data|
- data['aliases'].each do |a|
- a.tr!(':', '')
+ data["aliases"].each do |a|
+ a.tr!(":", "")
aliases[a] = key
end
end
- out = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json')
- File.open(out, 'w') do |handle|
- handle.write(JSON.pretty_generate(aliases, indent: ' ', space: '', space_before: ''))
+ out = File.join(Rails.root, "fixtures", "emojis", "aliases.json")
+ File.open(out, "w") do |handle|
+ handle.write(JSON.pretty_generate(aliases, indent: " ", space: "", space_before: ""))
end
end
- task digests: ['yarn:check', 'environment'] do
- require 'digest/sha2'
- require 'json'
+ task digests: ["yarn:check", "environment"] do
+ require "digest/sha2"
+ require "json"
# We don't have `node_modules` available in built versions of GitLab
- FileUtils.cp_r(Rails.root.join('node_modules', 'emoji-unicode-version', 'emoji-unicode-version-map.json'), File.join(Rails.root, 'fixtures', 'emojis'))
+ FileUtils.cp_r(Rails.root.join("node_modules", "emoji-unicode-version", "emoji-unicode-version-map.json"), File.join(Rails.root, "fixtures", "emojis"))
dir = Gemojione.images_path
resultant_emoji_map = {}
@@ -36,28 +36,28 @@ namespace :gemojione do
Gitlab::Emoji.emojis.each do |name, emoji_hash|
# Ignore aliases
unless Gitlab::Emoji.emojis_aliases.key?(name)
- fpath = File.join(dir, "#{emoji_hash['unicode']}.png")
+ fpath = File.join(dir, "#{emoji_hash["unicode"]}.png")
hash_digest = Digest::SHA256.file(fpath).hexdigest
- category = emoji_hash['category']
- if name == 'gay_pride_flag'
- category = 'flags'
+ category = emoji_hash["category"]
+ if name == "gay_pride_flag"
+ category = "flags"
end
entry = {
category: category,
- moji: emoji_hash['moji'],
- description: emoji_hash['description'],
+ moji: emoji_hash["moji"],
+ description: emoji_hash["description"],
unicodeVersion: Gitlab::Emoji.emoji_unicode_version(name),
- digest: hash_digest
+ digest: hash_digest,
}
resultant_emoji_map[name] = entry
end
end
- out = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json')
- File.open(out, 'w') do |handle|
+ out = File.join(Rails.root, "fixtures", "emojis", "digests.json")
+ File.open(out, "w") do |handle|
handle.write(JSON.pretty_generate(resultant_emoji_map))
end
end
@@ -70,8 +70,8 @@ namespace :gemojione do
# occasionally, such as when new Emojis are added to Gemojione.
task sprite: :environment do
begin
- require 'sprite_factory'
- require 'rmagick'
+ require "sprite_factory"
+ require "rmagick"
rescue LoadError
# noop
end
@@ -91,22 +91,22 @@ namespace :gemojione do
Gitlab::Emoji.emojis.each do |name, emoji_hash|
# Ignore aliases
unless Gitlab::Emoji.emojis_aliases.key?(name)
- emoji_unicode_string_to_name_map[emoji_hash['unicode']] = name
+ emoji_unicode_string_to_name_map[emoji_hash["unicode"]] = name
end
end
# Copy the Gemojione assets to the temporary folder for renaming
emoji_dir = "app/assets/images/emoji"
FileUtils.rm_rf(emoji_dir)
- FileUtils.mkdir_p(emoji_dir, mode: 0700)
- FileUtils.cp_r(File.join(Gemojione.images_path, '.'), emoji_dir)
+ FileUtils.mkdir_p(emoji_dir, mode: 0o700)
+ FileUtils.cp_r(File.join(Gemojione.images_path, "."), emoji_dir)
Dir[File.join(emoji_dir, "**/*.png")].each do |png|
image_path = png
rename_to_named_emoji_image!(emoji_unicode_string_to_name_map, image_path)
end
Dir.mktmpdir do |tmpdir|
- FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir)
+ FileUtils.cp_r(File.join(emoji_dir, "."), tmpdir)
Dir.chdir(tmpdir) do
Dir["**/*.png"].each do |png|
@@ -115,28 +115,28 @@ namespace :gemojione do
end
end
- style_path = Rails.root.join(*%w(app assets stylesheets framework emoji_sprites.scss))
+ style_path = Rails.root.join("app", "assets", "stylesheets", "framework", "emoji_sprites.scss")
# Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.cssurl = "image-url('$IMAGE')"
SpriteFactory.run!(tmpdir, {
output_style: style_path,
output_image: "app/assets/images/emoji.png",
- selector: '.emoji-',
- style: :scss,
- nocomments: true,
- pngcrush: true,
- layout: :packed
+ selector: ".emoji-",
+ style: :scss,
+ nocomments: true,
+ pngcrush: true,
+ layout: :packed,
})
# SpriteFactory's SCSS is a bit too verbose for our purposes here, so
# let's simplify it
- system(%Q(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
- system(%Q(sed -i '' "s/ no-repeat//" #{style_path}))
- system(%Q(sed -i '' "s/ 0px/ 0/g" #{style_path}))
+ system(%(sed -i '' "s/width: #{SIZE}px; height: #{SIZE}px; background: image-url('emoji.png')/background-position:/" #{style_path}))
+ system(%(sed -i '' "s/ no-repeat//" #{style_path}))
+ system(%(sed -i '' "s/ 0px/ 0/g" #{style_path}))
# Append a generic rule that applies to all Emojis
- File.open(style_path, 'a') do |f|
+ File.open(style_path, "a") do |f|
f.puts
f.puts <<-CSS.strip_heredoc
.emoji-icon {
@@ -164,7 +164,7 @@ namespace :gemojione do
# Now do it again but for Retina
Dir.mktmpdir do |tmpdir|
# Copy the Gemojione assets to the temporary folder for resizing
- FileUtils.cp_r(File.join(emoji_dir, '.'), tmpdir)
+ FileUtils.cp_r(File.join(emoji_dir, "."), tmpdir)
Dir.chdir(tmpdir) do
Dir["**/*.png"].each do |png|
@@ -176,10 +176,10 @@ namespace :gemojione do
# Combine the resized assets into a packed sprite and re-generate the SCSS
SpriteFactory.run!(tmpdir, {
output_image: "app/assets/images/emoji@2x.png",
- style: false,
- nocomments: true,
- pngcrush: true,
- layout: :packed
+ style: false,
+ nocomments: true,
+ pngcrush: true,
+ layout: :packed,
})
end
end
diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake
index 2235a6ba194..81754bb9eeb 100644
--- a/lib/tasks/gettext.rake
+++ b/lib/tasks/gettext.rake
@@ -4,8 +4,8 @@ namespace :gettext do
# Customize list of translatable files
# See: https://github.com/grosser/gettext_i18n_rails#customizing-list-of-translatable-files
def files_to_translate
- folders = %W(ee app lib config #{locale_path}).join(',')
- exts = %w(rb erb haml slim rhtml js jsx vue handlebars hbs mustache).join(',')
+ folders = %W[ee app lib config #{locale_path}].join(",")
+ exts = %w[rb erb haml slim rhtml js jsx vue handlebars hbs mustache].join(",")
Dir.glob(
"{#{folders}}/**/*.{#{exts}}"
@@ -14,55 +14,55 @@ namespace :gettext do
task :compile do
# See: https://gitlab.com/gitlab-org/gitlab-ce/issues/33014#note_31218998
- FileUtils.touch(File.join(Rails.root, 'locale/gitlab.pot'))
+ FileUtils.touch(File.join(Rails.root, "locale/gitlab.pot"))
- Rake::Task['gettext:po_to_json'].invoke
+ Rake::Task["gettext:po_to_json"].invoke
end
task :regenerate do
- pot_file = 'locale/gitlab.pot'
+ pot_file = "locale/gitlab.pot"
# Remove all translated files, this speeds up finding
- FileUtils.rm Dir['locale/**/gitlab.*']
+ FileUtils.rm Dir["locale/**/gitlab.*"]
# remove the `pot` file to ensure it's completely regenerated
FileUtils.rm_f pot_file
- Rake::Task['gettext:find'].invoke
+ Rake::Task["gettext:find"].invoke
# leave only the required changes.
`git checkout -- locale/*/gitlab.po`
# Remove timestamps from the pot file
pot_content = File.read pot_file
- pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, '')
+ pot_content.gsub!(/^"POT?\-(?:Creation|Revision)\-Date\:.*\n/, "")
File.write pot_file, pot_content
puts <<~MSG
- All done. Please commit the changes to `locale/gitlab.pot`.
+ All done. Please commit the changes to `locale/gitlab.pot`.
MSG
end
- desc 'Lint all po files in `locale/'
+ desc "Lint all po files in `locale/"
task lint: :environment do
- require 'simple_po_parser'
- require 'gitlab/utils'
+ require "simple_po_parser"
+ require "gitlab/utils"
FastGettext.silence_errors
- files = Dir.glob(Rails.root.join('locale/*/gitlab.po'))
+ files = Dir.glob(Rails.root.join("locale/*/gitlab.po"))
- linters = files.map do |file|
+ linters = files.map { |file|
locale = File.basename(File.dirname(file))
Gitlab::I18n::PoLinter.new(file, locale)
- end
+ }
- pot_file = Rails.root.join('locale/gitlab.pot')
+ pot_file = Rails.root.join("locale/gitlab.pot")
linters.unshift(Gitlab::I18n::PoLinter.new(pot_file))
failed_linters = linters.select { |linter| linter.errors.any? }
if failed_linters.empty?
- puts 'All PO files are valid.'
+ puts "All PO files are valid."
else
failed_linters.each do |linter|
report_errors_for_file(linter.po_path, linter.errors)
@@ -73,17 +73,17 @@ namespace :gettext do
end
task :updated_check do
- pot_file = 'locale/gitlab.pot'
+ pot_file = "locale/gitlab.pot"
# Removing all pre-translated files speeds up `gettext:find` as the
# files don't need to be merged.
# Having `LC_MESSAGES/gitlab.mo files present also confuses the output.
- FileUtils.rm Dir['locale/**/gitlab.*']
+ FileUtils.rm Dir["locale/**/gitlab.*"]
FileUtils.rm_f pot_file
# `gettext:find` writes touches to temp files to `stderr` which would cause
# `static-analysis` to report failures. We can ignore these.
silence_stderr do
- Rake::Task['gettext:find'].invoke
+ Rake::Task["gettext:find"].invoke
end
pot_diff = `git diff -- #{pot_file} | grep -E '^(\\+|-)msgid'`.strip
@@ -112,8 +112,8 @@ namespace :gettext do
errors_for_file.each do |message_id, errors|
puts " #{message_id}"
errors.each do |error|
- spaces = ' ' * 4
- error = error.lines.join("#{spaces}")
+ spaces = " " * 4
+ error = error.lines.join(spaces.to_s)
puts "#{spaces}#{error}"
end
end
diff --git a/lib/tasks/gitlab/artifacts/check.rake b/lib/tasks/gitlab/artifacts/check.rake
index a105261ed51..662204b650c 100644
--- a/lib/tasks/gitlab/artifacts/check.rake
+++ b/lib/tasks/gitlab/artifacts/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :artifacts do
- desc 'GitLab | Artifacts | Check integrity of uploaded job artifacts'
+ desc "GitLab | Artifacts | Check integrity of uploaded job artifacts"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::JobArtifacts)
end
diff --git a/lib/tasks/gitlab/artifacts/migrate.rake b/lib/tasks/gitlab/artifacts/migrate.rake
index e7634d2ed4f..3458d6ca5f5 100644
--- a/lib/tasks/gitlab/artifacts/migrate.rake
+++ b/lib/tasks/gitlab/artifacts/migrate.rake
@@ -1,24 +1,23 @@
-require 'logger'
-require 'resolv-replace'
+require "logger"
+require "resolv-replace"
desc "GitLab | Migrate files for artifacts to comply with new storage format"
namespace :gitlab do
namespace :artifacts do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of artifacts')
+ logger.info("Starting transfer of artifacts")
Ci::Build.joins(:project)
.with_artifacts_stored_locally
.find_each(batch_size: 10) do |build|
- begin
- build.artifacts_file.migrate!(ObjectStorage::Store::REMOTE)
- build.artifacts_metadata.migrate!(ObjectStorage::Store::REMOTE)
- logger.info("Transferred artifact ID #{build.id} with size #{build.artifacts_size} to object storage")
- rescue => e
- logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
- end
+ build.artifacts_file.migrate!(ObjectStorage::Store::REMOTE)
+ build.artifacts_metadata.migrate!(ObjectStorage::Store::REMOTE)
+
+ logger.info("Transferred artifact ID #{build.id} with size #{build.artifacts_size} to object storage")
+ rescue => e
+ logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/assets.rake b/lib/tasks/gitlab/assets.rake
index 7a42e4e92a0..9d425af8266 100644
--- a/lib/tasks/gitlab/assets.rake
+++ b/lib/tasks/gitlab/assets.rake
@@ -1,8 +1,8 @@
namespace :gitlab do
namespace :assets do
- desc 'GitLab | Assets | Compile all frontend assets'
+ desc "GitLab | Assets | Compile all frontend assets"
task :compile do
- require_dependency 'gitlab/task_helpers'
+ require_dependency "gitlab/task_helpers"
%w[
yarn:check
@@ -13,18 +13,18 @@ namespace :gitlab do
].each(&Gitlab::TaskHelpers.method(:invoke_and_time_task))
end
- desc 'GitLab | Assets | Clean up old compiled frontend assets'
- task clean: ['rake:assets:clean']
+ desc "GitLab | Assets | Clean up old compiled frontend assets"
+ task clean: ["rake:assets:clean"]
- desc 'GitLab | Assets | Remove all compiled frontend assets'
- task purge: ['rake:assets:clobber']
+ desc "GitLab | Assets | Remove all compiled frontend assets"
+ task purge: ["rake:assets:clobber"]
- desc 'GitLab | Assets | Uninstall frontend dependencies'
- task purge_modules: ['yarn:clobber']
+ desc "GitLab | Assets | Uninstall frontend dependencies"
+ task purge_modules: ["yarn:clobber"]
- desc 'GitLab | Assets | Fix all absolute url references in CSS'
+ desc "GitLab | Assets | Fix all absolute url references in CSS"
task :fix_urls do
- css_files = Dir['public/assets/*.css']
+ css_files = Dir["public/assets/*.css"]
css_files.each do |file|
# replace url(/assets/*) with url(./*)
puts "Fixing #{file}"
@@ -38,7 +38,7 @@ namespace :gitlab do
FileUtils.rm(gzip)
mtime = File.stat(file).mtime
- File.open(gzip, 'wb+') do |f|
+ File.open(gzip, "wb+") do |f|
gz = Zlib::GzipWriter.new(f, Zlib::BEST_COMPRESSION)
gz.mtime = mtime
gz.write IO.binread(file)
diff --git a/lib/tasks/gitlab/backup.rake b/lib/tasks/gitlab/backup.rake
index 3a1a36e36ce..1204dd2195c 100644
--- a/lib/tasks/gitlab/backup.rake
+++ b/lib/tasks/gitlab/backup.rake
@@ -1,4 +1,4 @@
-require 'active_record/fixtures'
+require "active_record/fixtures"
namespace :gitlab do
namespace :backup do
@@ -23,16 +23,16 @@ namespace :gitlab do
end
# Restore backup of GitLab system
- desc 'GitLab | Restore a previously created backup'
+ desc "GitLab | Restore a previously created backup"
task restore: :gitlab_environment do
warn_user_is_not_gitlab
backup = Backup::Manager.new(progress)
backup.unpack
- unless backup.skipped?('db')
+ unless backup.skipped?("db")
begin
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
warning = <<-MSG.strip_heredoc
Before restoring the database, we will remove all existing
tables to avoid future upgrade problems. Be aware that if you have
@@ -41,31 +41,31 @@ namespace :gitlab do
MSG
puts warning.color(:red)
ask_to_continue
- puts 'Removing all tables. Press `Ctrl-C` within 5 seconds to abort'.color(:yellow)
+ puts "Removing all tables. Press `Ctrl-C` within 5 seconds to abort".color(:yellow)
sleep(5)
end
# Drop all tables Load the schema to ensure we don't have any newer tables
# hanging out from a failed upgrade
- puts_time 'Cleaning the database ... '.color(:blue)
- Rake::Task['gitlab:db:drop_tables'].invoke
- puts_time 'done'.color(:green)
- Rake::Task['gitlab:backup:db:restore'].invoke
+ puts_time "Cleaning the database ... ".color(:blue)
+ Rake::Task["gitlab:db:drop_tables"].invoke
+ puts_time "done".color(:green)
+ Rake::Task["gitlab:backup:db:restore"].invoke
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
exit 1
end
end
- Rake::Task['gitlab:backup:repo:restore'].invoke unless backup.skipped?('repositories')
- Rake::Task['gitlab:backup:uploads:restore'].invoke unless backup.skipped?('uploads')
- Rake::Task['gitlab:backup:builds:restore'].invoke unless backup.skipped?('builds')
- Rake::Task['gitlab:backup:artifacts:restore'].invoke unless backup.skipped?('artifacts')
- Rake::Task["gitlab:backup:pages:restore"].invoke unless backup.skipped?('pages')
- Rake::Task['gitlab:backup:lfs:restore'].invoke unless backup.skipped?('lfs')
- Rake::Task['gitlab:backup:registry:restore'].invoke unless backup.skipped?('registry')
- Rake::Task['gitlab:shell:setup'].invoke
- Rake::Task['cache:clear'].invoke
+ Rake::Task["gitlab:backup:repo:restore"].invoke unless backup.skipped?("repositories")
+ Rake::Task["gitlab:backup:uploads:restore"].invoke unless backup.skipped?("uploads")
+ Rake::Task["gitlab:backup:builds:restore"].invoke unless backup.skipped?("builds")
+ Rake::Task["gitlab:backup:artifacts:restore"].invoke unless backup.skipped?("artifacts")
+ Rake::Task["gitlab:backup:pages:restore"].invoke unless backup.skipped?("pages")
+ Rake::Task["gitlab:backup:lfs:restore"].invoke unless backup.skipped?("lfs")
+ Rake::Task["gitlab:backup:registry:restore"].invoke unless backup.skipped?("registry")
+ Rake::Task["gitlab:shell:setup"].invoke
+ Rake::Task["cache:clear"].invoke
backup.cleanup
end
@@ -74,7 +74,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping repositories ...".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("repositories")
+ if ENV["SKIP"]&.include?("repositories")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Repository.new(progress).dump
@@ -93,7 +93,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping database ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("db")
+ if ENV["SKIP"]&.include?("db")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Database.new(progress).dump
@@ -112,7 +112,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping builds ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("builds")
+ if ENV["SKIP"]&.include?("builds")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Builds.new(progress).dump
@@ -131,7 +131,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping uploads ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("uploads")
+ if ENV["SKIP"]&.include?("uploads")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Uploads.new(progress).dump
@@ -150,7 +150,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping artifacts ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("artifacts")
+ if ENV["SKIP"]&.include?("artifacts")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Artifacts.new(progress).dump
@@ -169,7 +169,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping pages ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("pages")
+ if ENV["SKIP"]&.include?("pages")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Pages.new(progress).dump
@@ -188,7 +188,7 @@ namespace :gitlab do
task create: :gitlab_environment do
puts_time "Dumping lfs objects ... ".color(:blue)
- if ENV["SKIP"] && ENV["SKIP"].include?("lfs")
+ if ENV["SKIP"]&.include?("lfs")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Lfs.new(progress).dump
@@ -208,7 +208,7 @@ namespace :gitlab do
puts_time "Dumping container registry images ... ".color(:blue)
if Gitlab.config.registry.enabled
- if ENV["SKIP"] && ENV["SKIP"].include?("registry")
+ if ENV["SKIP"]&.include?("registry")
puts_time "[SKIPPED]".color(:cyan)
else
Backup::Registry.new(progress).dump
@@ -236,10 +236,10 @@ namespace :gitlab do
end
def progress
- if ENV['CRON']
+ if ENV["CRON"]
# We need an object we can say 'puts' and 'print' to; let's use a
# StringIO.
- require 'stringio'
+ require "stringio"
StringIO.new
else
$stdout
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index b594f150c3b..365c8b674a1 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -1,11 +1,11 @@
namespace :gitlab do
- desc 'GitLab | Check the configuration of GitLab and its environment'
+ desc "GitLab | Check the configuration of GitLab and its environment"
task check: :gitlab_environment do
SystemCheck::RakeTask::GitlabTask.run!
end
namespace :app do
- desc 'GitLab | Check the configuration of the GitLab Rails app'
+ desc "GitLab | Check the configuration of the GitLab Rails app"
task check: :gitlab_environment do
SystemCheck::RakeTask::AppTask.run!
end
@@ -19,7 +19,7 @@ namespace :gitlab do
end
namespace :gitaly do
- desc 'GitLab | Check the health of Gitaly'
+ desc "GitLab | Check the health of Gitaly"
task check: :gitlab_environment do
SystemCheck::RakeTask::GitalyTask.run!
end
@@ -41,24 +41,24 @@ namespace :gitlab do
namespace :ldap do
task :check, [:limit] => :gitlab_environment do |_, args|
- ENV['LDAP_CHECK_LIMIT'] = args.limit if args.limit.present?
+ ENV["LDAP_CHECK_LIMIT"] = args.limit if args.limit.present?
SystemCheck::RakeTask::LdapTask.run!
end
end
namespace :orphans do
- desc 'Gitlab | Check for orphaned namespaces and repositories'
+ desc "Gitlab | Check for orphaned namespaces and repositories"
task check: :gitlab_environment do
SystemCheck::RakeTask::OrphansTask.run!
end
- desc 'GitLab | Check for orphaned namespaces in the repositories path'
+ desc "GitLab | Check for orphaned namespaces in the repositories path"
task check_namespaces: :gitlab_environment do
SystemCheck::RakeTask::Orphans::NamespaceTask.run!
end
- desc 'GitLab | Check for orphaned repositories in the repositories path'
+ desc "GitLab | Check for orphaned repositories in the repositories path"
task check_repositories: :gitlab_environment do
SystemCheck::RakeTask::Orphans::RepositoryTask.run!
end
diff --git a/lib/tasks/gitlab/cleanup.rake b/lib/tasks/gitlab/cleanup.rake
index 451ba651674..3d8b537ecc3 100644
--- a/lib/tasks/gitlab/cleanup.rake
+++ b/lib/tasks/gitlab/cleanup.rake
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require 'set'
+
+require "set"
namespace :gitlab do
namespace :cleanup do
@@ -12,7 +13,7 @@ namespace :gitlab do
all_dirs = Gitlab::GitalyClient::StorageService
.new(server.storage)
.list_directories(depth: 0)
- .reject { |dir| dir.ends_with?('.git') || namespaces.include?(File.basename(dir)) }
+ .reject { |dir| dir.ends_with?(".git") || namespaces.include?(File.basename(dir)) }
puts "Looking for directories to remove... "
all_dirs.each do |dir_path|
@@ -22,7 +23,7 @@ namespace :gitlab do
.remove(dir_path)
puts "Removed...#{dir_path}"
- rescue StandardError => e
+ rescue => e
puts "Cannot remove #{dir_path}: #{e.message}".color(:red)
end
else
@@ -45,7 +46,7 @@ namespace :gitlab do
.new(server.storage)
.list_directories
.each do |path|
- repo_with_namespace = path.chomp('.git').chomp('.wiki')
+ repo_with_namespace = path.chomp(".git").chomp(".wiki")
# TODO ignoring hashed repositories for now. But revisit to fully support
# possible orphaned hashed repos
@@ -53,13 +54,13 @@ namespace :gitlab do
next if Project.find_by_full_path(repo_with_namespace)
new_path = path + move_suffix
- puts path.inspect + ' -> ' + new_path.inspect
+ puts path.inspect + " -> " + new_path.inspect
begin
Gitlab::GitalyClient::NamespaceService
.new(server.storage)
.rename(path, new_path)
- rescue StandardError => e
+ rescue => e
puts "Error occured while moving the repository: #{e.message}".color(:red)
end
end
@@ -69,7 +70,7 @@ namespace :gitlab do
desc "GitLab | Cleanup | Block users that have been removed in LDAP"
task block_removed_ldap_users: :gitlab_environment do
warn_user_is_not_gitlab
- block_flag = ENV['BLOCK']
+ block_flag = ENV["BLOCK"]
User.find_each do |user|
next unless user.ldap_user?
@@ -105,7 +106,7 @@ namespace :gitlab do
end
end
- desc 'GitLab | Cleanup | Clean orphan remote upload files that do not exist in the db'
+ desc "GitLab | Cleanup | Clean orphan remote upload files that do not exist in the db"
task remote_upload_files: :environment do
cleaner = Gitlab::Cleanup::RemoteUploads.new(logger: logger)
cleaner.run!(dry_run: dry_run?)
@@ -116,23 +117,23 @@ namespace :gitlab do
end
def remove?
- ENV['REMOVE'] == 'true'
+ ENV["REMOVE"] == "true"
end
def dry_run?
- ENV['DRY_RUN'] != 'false'
+ ENV["DRY_RUN"] != "false"
end
def logger
return @logger if defined?(@logger)
@logger = if Rails.env.development? || Rails.env.production?
- Logger.new(STDOUT).tap do |stdout_logger|
- stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger))
- end
- else
- Rails.logger
- end
+ Logger.new(STDOUT).tap do |stdout_logger|
+ stdout_logger.extend(ActiveSupport::Logger.broadcast(Rails.logger))
+ end
+ else
+ Rails.logger
+ end
end
end
end
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index b94b21775ee..0dd6a5b5c29 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :db do
- desc 'GitLab | Manually insert schema migration version'
+ desc "GitLab | Manually insert schema migration version"
task :mark_migration_complete, [:version] => :environment do |_, args|
unless args[:version]
puts "Must specify a migration version as an argument".color(:red)
@@ -22,18 +22,18 @@ namespace :gitlab do
end
end
- desc 'Drop all tables'
+ desc "Drop all tables"
task drop_tables: :environment do
connection = ActiveRecord::Base.connection
# If MySQL, turn off foreign key checks
- connection.execute('SET FOREIGN_KEY_CHECKS=0') if Gitlab::Database.mysql?
+ connection.execute("SET FOREIGN_KEY_CHECKS=0") if Gitlab::Database.mysql?
tables = connection.data_sources
# Removes the entry from the array
- tables.delete 'schema_migrations'
+ tables.delete "schema_migrations"
# Truncate schema_migrations to ensure migrations re-run
- connection.execute('TRUNCATE schema_migrations') if connection.data_source_exists? 'schema_migrations'
+ connection.execute("TRUNCATE schema_migrations") if connection.data_source_exists? "schema_migrations"
# Drop tables with cascade to avoid dependent table errors
# PG: http://www.postgresql.org/docs/current/static/ddl-depend.html
@@ -42,28 +42,28 @@ namespace :gitlab do
tables.each { |t| connection.execute("DROP TABLE IF EXISTS #{connection.quote_table_name(t)} CASCADE") }
# If MySQL, re-enable foreign key checks
- connection.execute('SET FOREIGN_KEY_CHECKS=1') if Gitlab::Database.mysql?
+ connection.execute("SET FOREIGN_KEY_CHECKS=1") if Gitlab::Database.mysql?
end
- desc 'Configures the database by running migrate, or by loading the schema and seeding if needed'
+ desc "Configures the database by running migrate, or by loading the schema and seeding if needed"
task configure: :environment do
# Check if we have existing db tables
# The schema_migrations table will still exist if drop_tables was called
if ActiveRecord::Base.connection.tables.count > 1
- Rake::Task['db:migrate'].invoke
+ Rake::Task["db:migrate"].invoke
else
# Add post-migrate paths to ensure we mark all migrations as up
Gitlab::Database.add_post_migrate_path_to_rails(force: true)
- Rake::Task['db:schema:load'].invoke
- Rake::Task['db:seed_fu'].invoke
+ Rake::Task["db:schema:load"].invoke
+ Rake::Task["db:seed_fu"].invoke
end
end
- desc 'Checks if migrations require downtime or not'
+ desc "Checks if migrations require downtime or not"
task :downtime_check, [:ref] => :environment do |_, args|
- abort 'You must specify a Git reference to compare with' unless args[:ref]
+ abort "You must specify a Git reference to compare with" unless args[:ref]
- require 'shellwords'
+ require "shellwords"
ref = Shellwords.escape(args[:ref])
diff --git a/lib/tasks/gitlab/dev.rake b/lib/tasks/gitlab/dev.rake
index 77c28615856..64a7306724e 100644
--- a/lib/tasks/gitlab/dev.rake
+++ b/lib/tasks/gitlab/dev.rake
@@ -1,13 +1,13 @@
namespace :gitlab do
namespace :dev do
- desc 'Checks if the branch would apply cleanly to EE'
+ desc "Checks if the branch would apply cleanly to EE"
task :ee_compat_check, [:branch] => :environment do |_, args|
opts =
- if ENV['CI']
+ if ENV["CI"]
{
- ce_project_url: ENV['CI_PROJECT_URL'],
- branch: ENV['CI_COMMIT_REF_NAME'],
- job_id: ENV['CI_JOB_ID']
+ ce_project_url: ENV["CI_PROJECT_URL"],
+ branch: ENV["CI_COMMIT_REF_NAME"],
+ job_id: ENV["CI_JOB_ID"],
}
else
unless args[:branch]
@@ -18,7 +18,7 @@ namespace :gitlab do
args
end
- if File.basename(Rails.root) == 'gitlab-ee'
+ if File.basename(Rails.root) == "gitlab-ee"
puts "Skipping EE projects"
exit 0
elsif Gitlab::EeCompatCheck.new(opts || {}).check
diff --git a/lib/tasks/gitlab/exclusive_lease.rake b/lib/tasks/gitlab/exclusive_lease.rake
index 83722bf6d94..547d35f9310 100644
--- a/lib/tasks/gitlab/exclusive_lease.rake
+++ b/lib/tasks/gitlab/exclusive_lease.rake
@@ -1,9 +1,9 @@
namespace :gitlab do
namespace :exclusive_lease do
- desc 'GitLab | Clear existing exclusive leases for specified scope (default: *)'
+ desc "GitLab | Clear existing exclusive leases for specified scope (default: *)"
task :clear, [:scope] => [:environment] do |_, args|
args[:scope].nil? ? Gitlab::ExclusiveLease.reset_all! : Gitlab::ExclusiveLease.reset_all!(args[:scope])
- puts 'All exclusive lease entries were removed.'
+ puts "All exclusive lease entries were removed."
end
end
end
diff --git a/lib/tasks/gitlab/git.rake b/lib/tasks/gitlab/git.rake
index 8a53b51d4fe..2924d40d2ce 100644
--- a/lib/tasks/gitlab/git.rake
+++ b/lib/tasks/gitlab/git.rake
@@ -1,12 +1,11 @@
namespace :gitlab do
namespace :git do
- desc 'GitLab | Git | Check all repos integrity'
+ desc "GitLab | Git | Check all repos integrity"
task fsck: :gitlab_environment do
failures = []
Project.find_each(batch_size: 100) do |project|
begin
project.repository.fsck
-
rescue => e
failures << "#{project.full_path} on #{project.repository_storage}: #{e}"
end
diff --git a/lib/tasks/gitlab/gitaly.rake b/lib/tasks/gitlab/gitaly.rake
index 80de3d2ef51..c5e1d7084df 100644
--- a/lib/tasks/gitlab/gitaly.rake
+++ b/lib/tasks/gitlab/gitaly.rake
@@ -9,7 +9,7 @@ namespace :gitlab do
Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
end
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitaly.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitaly.git")
version = Gitlab::GitalyClient.expected_server_version
@@ -18,19 +18,20 @@ Usage: rake "gitlab:gitaly:install[/installation/dir,/storage/path]")
command = %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE]
_, status = Gitlab::Popen.popen(%w[which gmake])
- command << (status.zero? ? 'gmake' : 'make')
+ command << (status.zero? ? "gmake" : "make")
if Rails.env.test?
command.push(
- 'BUNDLE_FLAGS=--no-deployment',
- "BUNDLE_PATH=#{Bundler.bundle_path}")
+ "BUNDLE_FLAGS=--no-deployment",
+ "BUNDLE_PATH=#{Bundler.bundle_path}"
+ )
end
- storage_paths = { 'default' => args.storage_path }
+ storage_paths = {"default" => args.storage_path}
Gitlab::SetupHelper.create_gitaly_configuration(args.dir, storage_paths)
Dir.chdir(args.dir) do
# In CI we run scripts/gitaly-test-build instead of this command
- unless ENV['CI'].present?
+ unless ENV["CI"].present?
Bundler.with_original_env { run_command!(command) }
end
end
diff --git a/lib/tasks/gitlab/helpers.rake b/lib/tasks/gitlab/helpers.rake
index 14d1125a03d..5ca40df05cb 100644
--- a/lib/tasks/gitlab/helpers.rake
+++ b/lib/tasks/gitlab/helpers.rake
@@ -1,5 +1,5 @@
# Prevent StateMachine warnings from outputting during a cron task
-StateMachines::Machine.ignore_method_conflicts = true if ENV['CRON']
+StateMachines::Machine.ignore_method_conflicts = true if ENV["CRON"]
task gitlab_environment: :environment do
extend SystemCheck::Helpers
diff --git a/lib/tasks/gitlab/import.rake b/lib/tasks/gitlab/import.rake
index adfcc3cda22..a224515b63e 100644
--- a/lib/tasks/gitlab/import.rake
+++ b/lib/tasks/gitlab/import.rake
@@ -11,7 +11,7 @@ namespace :gitlab do
desc "GitLab | Import bare repositories from repositories -> storages into GitLab project instance"
task :repos, [:import_path] => :environment do |_t, args|
unless args.import_path
- puts 'Please specify an import path that contains the repositories'.color(:red)
+ puts "Please specify an import path that contains the repositories".color(:red)
exit 1
end
diff --git a/lib/tasks/gitlab/import_export.rake b/lib/tasks/gitlab/import_export.rake
index 900dbf7be24..f34c83aba7b 100644
--- a/lib/tasks/gitlab/import_export.rake
+++ b/lib/tasks/gitlab/import_export.rake
@@ -7,20 +7,20 @@ namespace :gitlab do
desc "GitLab | Display exported DB structure"
task data: :environment do
- puts YAML.load_file(Gitlab::ImportExport.config_file)['project_tree'].to_yaml(SortKeys: true)
+ puts YAML.load_file(Gitlab::ImportExport.config_file)["project_tree"].to_yaml(SortKeys: true)
end
- desc 'GitLab | Bumps the Import/Export version in fixtures and project templates'
+ desc "GitLab | Bumps the Import/Export version in fixtures and project templates"
task bump_version: :environment do
- archives = Dir['vendor/project_templates/*.tar.gz']
- archives.push('spec/features/projects/import_export/test_project_export.tar.gz')
+ archives = Dir["vendor/project_templates/*.tar.gz"]
+ archives.push("spec/features/projects/import_export/test_project_export.tar.gz")
archives.each do |archive|
raise ArgumentError unless File.exist?(archive)
Dir.mktmpdir do |tmp_dir|
system("tar -zxf #{archive} -C #{tmp_dir} > /dev/null")
- File.write(File.join(tmp_dir, 'VERSION'), Gitlab::ImportExport.version, mode: 'w')
+ File.write(File.join(tmp_dir, "VERSION"), Gitlab::ImportExport.version, mode: "w")
system("tar -zcvf #{archive} -C #{tmp_dir} . > /dev/null")
end
end
diff --git a/lib/tasks/gitlab/info.rake b/lib/tasks/gitlab/info.rake
index b8798fb3cfd..d3075d8282b 100644
--- a/lib/tasks/gitlab/info.rake
+++ b/lib/tasks/gitlab/info.rake
@@ -3,26 +3,26 @@ namespace :gitlab do
desc "GitLab | Show information about GitLab and its environment"
task info: :gitlab_environment do
# check if there is an RVM environment
- rvm_version = run_and_match(%w(rvm --version), /[\d\.]+/).try(:to_s)
+ rvm_version = run_and_match(%w[rvm --version], /[\d\.]+/).try(:to_s)
# check Ruby version
- ruby_version = run_and_match(%w(ruby --version), /[\d\.p]+/).try(:to_s)
+ ruby_version = run_and_match(%w[ruby --version], /[\d\.p]+/).try(:to_s)
# check Gem version
- gem_version = run_command(%w(gem --version))
+ gem_version = run_command(%w[gem --version])
# check Bundler version
- bunder_version = run_and_match(%w(bundle --version), /[\d\.]+/).try(:to_s)
+ bunder_version = run_and_match(%w[bundle --version], /[\d\.]+/).try(:to_s)
# check Rake version
- rake_version = run_and_match(%w(rake --version), /[\d\.]+/).try(:to_s)
+ rake_version = run_and_match(%w[rake --version], /[\d\.]+/).try(:to_s)
# check redis version
- redis_version = run_and_match(%w(redis-cli --version), /redis-cli (\d+\.\d+\.\d+)/).to_a
+ redis_version = run_and_match(%w[redis-cli --version], /redis-cli (\d+\.\d+\.\d+)/).to_a
# check Git version
- git_version = run_and_match([Gitlab.config.git.bin_path, '--version'], /git version ([\d\.]+)/).to_a
+ git_version = run_and_match([Gitlab.config.git.bin_path, "--version"], /git version ([\d\.]+)/).to_a
# check Go version
- go_version = run_and_match(%w(go version), /go version (.+)/).to_a
+ go_version = run_and_match(%w[go version], /go version (.+)/).to_a
puts ""
puts "System information".color(:yellow)
puts "System:\t\t#{os_name || "unknown".color(:red)}"
- puts "Current User:\t#{run_command(%w(whoami))}"
+ puts "Current User:\t#{run_command(%w[whoami])}"
puts "Using RVM:\t#{rvm_version.present? ? "yes".color(:green) : "no"}"
puts "RVM Version:\t#{rvm_version}" if rvm_version.present?
puts "Ruby Version:\t#{ruby_version || "unknown".color(:red)}"
@@ -42,7 +42,7 @@ namespace :gitlab do
http_clone_url = project.http_url_to_repo
ssh_clone_url = project.ssh_url_to_repo
- omniauth_providers = Gitlab.config.omniauth.providers.map { |provider| provider['name'] }
+ omniauth_providers = Gitlab.config.omniauth.providers.map { |provider| provider["name"] }
puts ""
puts "GitLab information".color(:yellow)
@@ -55,7 +55,7 @@ namespace :gitlab do
puts "SSH Clone URL:\t#{ssh_clone_url}"
puts "Using LDAP:\t#{Gitlab.config.ldap.enabled ? "yes".color(:green) : "no"}"
puts "Using Omniauth:\t#{Gitlab::Auth.omniauth_enabled? ? "yes".color(:green) : "no"}"
- puts "Omniauth Providers: #{omniauth_providers.join(', ')}" if Gitlab::Auth.omniauth_enabled?
+ puts "Omniauth Providers: #{omniauth_providers.join(", ")}" if Gitlab::Auth.omniauth_enabled?
# check Gitolite version
gitlab_shell_version_file = "#{Gitlab.config.gitlab_shell.path}/VERSION"
diff --git a/lib/tasks/gitlab/ldap.rake b/lib/tasks/gitlab/ldap.rake
index 0459de27c96..3a17961afe3 100644
--- a/lib/tasks/gitlab/ldap.rake
+++ b/lib/tasks/gitlab/ldap.rake
@@ -1,38 +1,38 @@
namespace :gitlab do
namespace :ldap do
- desc 'GitLab | LDAP | Rename provider'
+ desc "GitLab | LDAP | Rename provider"
task :rename_provider, [:old_provider, :new_provider] => :gitlab_environment do |_, args|
old_provider = args[:old_provider] ||
- prompt('What is the old provider? Ex. \'ldapmain\': '.color(:blue))
+ prompt("What is the old provider? Ex. 'ldapmain': ".color(:blue))
new_provider = args[:new_provider] ||
- prompt('What is the new provider ID? Ex. \'ldapcustom\': '.color(:blue))
- puts '' # Add some separation in the output
+ prompt("What is the new provider ID? Ex. 'ldapcustom': ".color(:blue))
+ puts "" # Add some separation in the output
identities = Identity.where(provider: old_provider)
identity_count = identities.count
if identities.empty?
puts "Found no user identities with '#{old_provider}' provider."
- puts 'Please check the provider name and try again.'
+ puts "Please check the provider name and try again."
exit 1
end
- plural_id_count = ActionController::Base.helpers.pluralize(identity_count, 'user')
+ plural_id_count = ActionController::Base.helpers.pluralize(identity_count, "user")
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "#{plural_id_count} with provider '#{old_provider}' will be updated to '#{new_provider}'"
- puts 'If the new provider is incorrect, users will be unable to sign in'
+ puts "If the new provider is incorrect, users will be unable to sign in"
ask_to_continue
- puts ''
+ puts ""
end
updated_count = identities.update_all(provider: new_provider)
if updated_count == identity_count
- puts 'User identities were successfully updated'.color(:green)
+ puts "User identities were successfully updated".color(:green)
else
- plural_updated_count = ActionController::Base.helpers.pluralize(updated_count, 'user')
- puts 'Some user identities could not be updated'.color(:red)
+ plural_updated_count = ActionController::Base.helpers.pluralize(updated_count, "user")
+ puts "Some user identities could not be updated".color(:red)
puts "Successfully updated #{plural_updated_count} out of #{plural_id_count} total"
end
end
diff --git a/lib/tasks/gitlab/lfs/check.rake b/lib/tasks/gitlab/lfs/check.rake
index 869463d4e5d..dbcb9697643 100644
--- a/lib/tasks/gitlab/lfs/check.rake
+++ b/lib/tasks/gitlab/lfs/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :lfs do
- desc 'GitLab | LFS | Check integrity of uploaded LFS objects'
+ desc "GitLab | LFS | Check integrity of uploaded LFS objects"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::LfsObjects)
end
diff --git a/lib/tasks/gitlab/lfs/migrate.rake b/lib/tasks/gitlab/lfs/migrate.rake
index a45e5ca91e0..7560e1022ce 100644
--- a/lib/tasks/gitlab/lfs/migrate.rake
+++ b/lib/tasks/gitlab/lfs/migrate.rake
@@ -1,21 +1,20 @@
-require 'logger'
+require "logger"
desc "GitLab | Migrate LFS objects to remote storage"
namespace :gitlab do
namespace :lfs do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of LFS files to object storage')
+ logger.info("Starting transfer of LFS files to object storage")
LfsObject.with_files_stored_locally
.find_each(batch_size: 10) do |lfs_object|
- begin
- lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
- logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
- rescue => e
- logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
- end
+ lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
+
+ logger.info("Transferred LFS object #{lfs_object.oid} of size #{lfs_object.size.to_i.bytes} to object storage")
+ rescue => e
+ logger.error("Failed to transfer LFS object #{lfs_object.oid} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/list_repos.rake b/lib/tasks/gitlab/list_repos.rake
index b854c34a8e5..43dc65adf89 100644
--- a/lib/tasks/gitlab/list_repos.rake
+++ b/lib/tasks/gitlab/list_repos.rake
@@ -1,12 +1,12 @@
namespace :gitlab do
task list_repos: :environment do
scope = Project
- if ENV['SINCE']
- date = Time.parse(ENV['SINCE'])
+ if ENV["SINCE"]
+ date = Time.parse(ENV["SINCE"])
warn "Listing repositories with activity or changes since #{date}"
- project_ids = Project.where('last_activity_at > ? OR updated_at > ?', date, date).pluck(:id).sort
- namespace_ids = Namespace.where(['updated_at > ?', date]).pluck(:id).sort
- scope = scope.where('id IN (?) OR namespace_id in (?)', project_ids, namespace_ids)
+ project_ids = Project.where("last_activity_at > ? OR updated_at > ?", date, date).pluck(:id).sort
+ namespace_ids = Namespace.where(["updated_at > ?", date]).pluck(:id).sort
+ scope = scope.where("id IN (?) OR namespace_id in (?)", project_ids, namespace_ids)
end
scope.find_each do |project|
diff --git a/lib/tasks/gitlab/pages.rake b/lib/tasks/gitlab/pages.rake
index 100e480bd66..1f536d8c6e8 100644
--- a/lib/tasks/gitlab/pages.rake
+++ b/lib/tasks/gitlab/pages.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :pages do
- desc 'Ping the pages admin API'
+ desc "Ping the pages admin API"
task admin_ping: :gitlab_environment do
Gitlab::PagesClient.ping
puts "OK: gitlab-pages admin API is reachable"
diff --git a/lib/tasks/gitlab/setup.rake b/lib/tasks/gitlab/setup.rake
index e876b23d43f..ec4d3c06f77 100644
--- a/lib/tasks/gitlab/setup.rake
+++ b/lib/tasks/gitlab/setup.rake
@@ -18,7 +18,7 @@ namespace :gitlab do
def setup_db
warn_user_is_not_gitlab
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "This will create the necessary database tables and seed the database."
puts "You will lose any previous data stored in the database."
ask_to_continue
@@ -49,10 +49,10 @@ namespace :gitlab do
return false unless Gitlab::Database.postgresql?
cmd = <<~SQL
- SELECT pg_terminate_backend(pg_stat_activity.pid)
- FROM pg_stat_activity
- WHERE datname = current_database()
- AND pid <> pg_backend_pid();
+ SELECT pg_terminate_backend(pg_stat_activity.pid)
+ FROM pg_stat_activity
+ WHERE datname = current_database()
+ AND pid <> pg_backend_pid();
SQL
ActiveRecord::Base.connection.execute(cmd)&.result_status == PG::PGRES_TUPLES_OK
diff --git a/lib/tasks/gitlab/shell.rake b/lib/tasks/gitlab/shell.rake
index 0ebc6f00793..75604da22ad 100644
--- a/lib/tasks/gitlab/shell.rake
+++ b/lib/tasks/gitlab/shell.rake
@@ -5,11 +5,11 @@ namespace :gitlab do
warn_user_is_not_gitlab
default_version = Gitlab::Shell.version_required
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitlab-shell.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitlab-shell.git")
gitlab_url = Gitlab.config.gitlab.url
# gitlab-shell requires a / at the end of the url
- gitlab_url += '/' unless gitlab_url.end_with?('/')
+ gitlab_url += "/" unless gitlab_url.end_with?("/")
target_dir = Gitlab.config.gitlab_shell.path
checkout_or_clone_version(version: default_version, repo: args.repo, target_dir: target_dir)
@@ -19,40 +19,40 @@ namespace :gitlab do
config = {
user: Gitlab.config.gitlab.user,
gitlab_url: gitlab_url,
- http_settings: { self_signed_cert: false }.stringify_keys,
+ http_settings: {self_signed_cert: false}.stringify_keys,
auth_file: File.join(user_home, ".ssh", "authorized_keys"),
redis: {
bin: `which redis-cli`.chomp,
- namespace: "resque:gitlab"
+ namespace: "resque:gitlab",
}.stringify_keys,
log_level: "INFO",
- audit_usernames: false
+ audit_usernames: false,
}.stringify_keys
- redis_url = URI.parse(ENV['REDIS_URL'] || "redis://localhost:6379")
+ redis_url = URI.parse(ENV["REDIS_URL"] || "redis://localhost:6379")
- if redis_url.scheme == 'unix'
- config['redis']['socket'] = redis_url.path
+ if redis_url.scheme == "unix"
+ config["redis"]["socket"] = redis_url.path
else
- config['redis']['host'] = redis_url.host
- config['redis']['port'] = redis_url.port
+ config["redis"]["host"] = redis_url.host
+ config["redis"]["port"] = redis_url.port
end
# Generate config.yml based on existing gitlab settings
File.open("config.yml", "w+") {|f| f.puts config.to_yaml}
[
- %w(bin/install) + repository_storage_paths_args,
- %w(bin/compile)
+ %w[bin/install] + repository_storage_paths_args,
+ %w[bin/compile],
].each do |cmd|
unless Kernel.system(*cmd)
- raise "command failed: #{cmd.join(' ')}"
+ raise "command failed: #{cmd.join(" ")}"
end
end
end
# (Re)create hooks
- Rake::Task['gitlab:shell:create_hooks'].invoke
+ Rake::Task["gitlab:shell:create_hooks"].invoke
Gitlab::Shell.ensure_secret_token!
end
@@ -67,25 +67,25 @@ namespace :gitlab do
Project.find_each(batch_size: 1000) do |project|
path_to_repo = project.repository.path_to_repo
if File.exist?(path_to_repo)
- print '-'
+ print "-"
else
if Gitlab::Shell.new.create_repository(project.repository_storage,
- project.disk_path)
- print '.'
+ project.disk_path)
+ print "."
else
- print 'F'
+ print "F"
end
end
end
end
- desc 'Create or repair repository hooks symlink'
+ desc "Create or repair repository hooks symlink"
task create_hooks: :gitlab_environment do
warn_user_is_not_gitlab
- puts 'Creating/Repairing hooks symlinks for all repositories'
- system(*%W(#{Gitlab.config.gitlab_shell.path}/bin/create-hooks) + repository_storage_paths_args)
- puts 'done'.color(:green)
+ puts "Creating/Repairing hooks symlinks for all repositories"
+ system(*%W[#{Gitlab.config.gitlab_shell.path}/bin/create-hooks] + repository_storage_paths_args)
+ puts "done".color(:green)
end
end
@@ -94,7 +94,7 @@ namespace :gitlab do
ensure_write_to_authorized_keys_is_enabled
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts "This task will now rebuild the authorized_keys file."
puts "You will lose any data stored in the authorized_keys file."
ask_to_continue
@@ -106,7 +106,7 @@ namespace :gitlab do
Gitlab::Shell.new.batch_add_keys do |adder|
Key.find_each(batch_size: 1000) do |key|
adder.add_key(key.shell_id, key.key)
- print '.'
+ print "."
end
end
puts ""
@@ -115,7 +115,6 @@ namespace :gitlab do
puts "Failed to add keys...".color(:red)
exit 1
end
-
rescue Gitlab::TaskAbortedByUserError
puts "Quitting...".color(:red)
exit 1
@@ -126,7 +125,7 @@ namespace :gitlab do
puts authorized_keys_is_disabled_warning
- unless ENV['force'] == 'yes'
+ unless ENV["force"] == "yes"
puts 'Do you want to permanently enable the "Write to authorized_keys file" setting now?'
ask_to_continue
end
@@ -135,7 +134,7 @@ namespace :gitlab do
Gitlab::CurrentSettings.current_application_settings.update!(authorized_keys_enabled: true)
puts 'Successfully enabled "Write to authorized_keys file"!'
- puts ''
+ puts ""
end
def authorized_keys_is_disabled_warning
diff --git a/lib/tasks/gitlab/storage.rake b/lib/tasks/gitlab/storage.rake
index f9ce3e1d338..ad9ef0b2e61 100644
--- a/lib/tasks/gitlab/storage.rake
+++ b/lib/tasks/gitlab/storage.rake
@@ -1,9 +1,9 @@
namespace :gitlab do
namespace :storage do
- desc 'GitLab | Storage | Migrate existing projects to Hashed Storage'
+ desc "GitLab | Storage | Migrate existing projects to Hashed Storage"
task migrate_to_hashed: :environment do
if Gitlab::Database.read_only?
- warn 'This task requires database write access. Exiting.'
+ warn "This task requires database write access. Exiting."
next
end
@@ -29,7 +29,7 @@ namespace :gitlab do
legacy_projects_count = Project.with_unmigrated_storage.count
if legacy_projects_count == 0
- warn 'There are no projects requiring storage migration. Nothing to do!'
+ warn "There are no projects requiring storage migration. Nothing to do!"
next
end
@@ -39,58 +39,58 @@ namespace :gitlab do
helper.project_id_batches do |start, finish|
storage_migrator.bulk_schedule(start: start, finish: finish)
- print '.'
+ print "."
end
- puts ' Done!'
+ puts " Done!"
end
- desc 'Gitlab | Storage | Summary of existing projects using Legacy Storage'
+ desc "Gitlab | Storage | Summary of existing projects using Legacy Storage"
task legacy_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('projects using Legacy Storage', Project.without_storage_feature(:repository))
+ helper.relation_summary("projects using Legacy Storage", Project.without_storage_feature(:repository))
end
- desc 'Gitlab | Storage | List existing projects using Legacy Storage'
+ desc "Gitlab | Storage | List existing projects using Legacy Storage"
task list_legacy_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.projects_list('projects using Legacy Storage', Project.without_storage_feature(:repository))
+ helper.projects_list("projects using Legacy Storage", Project.without_storage_feature(:repository))
end
- desc 'Gitlab | Storage | Summary of existing projects using Hashed Storage'
+ desc "Gitlab | Storage | Summary of existing projects using Hashed Storage"
task hashed_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('projects using Hashed Storage', Project.with_storage_feature(:repository))
+ helper.relation_summary("projects using Hashed Storage", Project.with_storage_feature(:repository))
end
- desc 'Gitlab | Storage | List existing projects using Hashed Storage'
+ desc "Gitlab | Storage | List existing projects using Hashed Storage"
task list_hashed_projects: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.projects_list('projects using Hashed Storage', Project.with_storage_feature(:repository))
+ helper.projects_list("projects using Hashed Storage", Project.with_storage_feature(:repository))
end
- desc 'Gitlab | Storage | Summary of project attachments using Legacy Storage'
+ desc "Gitlab | Storage | Summary of project attachments using Legacy Storage"
task legacy_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('attachments using Legacy Storage', helper.legacy_attachments_relation)
+ helper.relation_summary("attachments using Legacy Storage", helper.legacy_attachments_relation)
end
- desc 'Gitlab | Storage | List existing project attachments using Legacy Storage'
+ desc "Gitlab | Storage | List existing project attachments using Legacy Storage"
task list_legacy_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.attachments_list('attachments using Legacy Storage', helper.legacy_attachments_relation)
+ helper.attachments_list("attachments using Legacy Storage", helper.legacy_attachments_relation)
end
- desc 'Gitlab | Storage | Summary of project attachments using Hashed Storage'
+ desc "Gitlab | Storage | Summary of project attachments using Hashed Storage"
task hashed_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.relation_summary('attachments using Hashed Storage', helper.hashed_attachments_relation)
+ helper.relation_summary("attachments using Hashed Storage", helper.hashed_attachments_relation)
end
- desc 'Gitlab | Storage | List existing project attachments using Hashed Storage'
+ desc "Gitlab | Storage | List existing project attachments using Hashed Storage"
task list_hashed_attachments: :environment do
helper = Gitlab::HashedStorage::RakeHelper
- helper.attachments_list('attachments using Hashed Storage', helper.hashed_attachments_relation)
+ helper.attachments_list("attachments using Hashed Storage", helper.hashed_attachments_relation)
end
end
end
diff --git a/lib/tasks/gitlab/tcp_check.rake b/lib/tasks/gitlab/tcp_check.rake
index 1400f57d6b9..6a44862a9ff 100644
--- a/lib/tasks/gitlab/tcp_check.rake
+++ b/lib/tasks/gitlab/tcp_check.rake
@@ -13,7 +13,7 @@ namespace :gitlab do
else
puts "TCP connection to #{checker.remote} failed: #{checker.error}".color(:red)
puts
- puts 'Check that host and port are correct, and that the traffic is permitted through any firewalls.'
+ puts "Check that host and port are correct, and that the traffic is permitted through any firewalls."
exit 1
end
end
diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake
index 2222807fe13..7a64baf7f8d 100644
--- a/lib/tasks/gitlab/test.rake
+++ b/lib/tasks/gitlab/test.rake
@@ -2,14 +2,14 @@ namespace :gitlab do
desc "GitLab | Run all tests"
task :test do
cmds = [
- %w(rake brakeman),
- %w(rake rubocop),
- %w(rake spec),
- %w(rake karma)
+ %w[rake brakeman],
+ %w[rake rubocop],
+ %w[rake spec],
+ %w[rake karma],
]
cmds.each do |cmd|
- system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
+ system({"RAILS_ENV" => "test", "force" => "yes"}, *cmd) || raise("#{cmd} failed!")
end
end
end
diff --git a/lib/tasks/gitlab/traces.rake b/lib/tasks/gitlab/traces.rake
index 5a232091a7e..8e060a77cbd 100644
--- a/lib/tasks/gitlab/traces.rake
+++ b/lib/tasks/gitlab/traces.rake
@@ -1,12 +1,12 @@
-require 'logger'
-require 'resolv-replace'
+require "logger"
+require "resolv-replace"
desc "GitLab | Archive legacy traces to trace artifacts"
namespace :gitlab do
namespace :traces do
task archive: :environment do
logger = Logger.new(STDOUT)
- logger.info('Archiving legacy traces')
+ logger.info("Archiving legacy traces")
Ci::Build.finished.without_archived_trace
.order(id: :asc)
@@ -21,18 +21,17 @@ namespace :gitlab do
task migrate: :environment do
logger = Logger.new(STDOUT)
- logger.info('Starting transfer of job traces')
+ logger.info("Starting transfer of job traces")
Ci::Build.joins(:project)
.with_archived_trace_stored_locally
.find_each(batch_size: 10) do |build|
- begin
- build.job_artifacts_trace.file.migrate!(ObjectStorage::Store::REMOTE)
- logger.info("Transferred job trace of #{build.id} to object storage")
- rescue => e
- logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
- end
+ build.job_artifacts_trace.file.migrate!(ObjectStorage::Store::REMOTE)
+
+ logger.info("Transferred job trace of #{build.id} to object storage")
+ rescue => e
+ logger.error("Failed to transfer artifacts of #{build.id} with error: #{e.message}")
end
end
end
diff --git a/lib/tasks/gitlab/track_deployment.rake b/lib/tasks/gitlab/track_deployment.rake
index 6f101aea303..8814a53fd90 100644
--- a/lib/tasks/gitlab/track_deployment.rake
+++ b/lib/tasks/gitlab/track_deployment.rake
@@ -1,8 +1,8 @@
namespace :gitlab do
- desc 'GitLab | Tracks a deployment in GitLab Performance Monitoring'
+ desc "GitLab | Tracks a deployment in GitLab Performance Monitoring"
task track_deployment: :environment do
metric = Gitlab::Metrics::Metric
- .new('deployments', version: Gitlab::VERSION)
+ .new("deployments", version: Gitlab::VERSION)
Gitlab::Metrics.submit_metrics([metric.to_hash])
end
diff --git a/lib/tasks/gitlab/two_factor.rake b/lib/tasks/gitlab/two_factor.rake
index 6b22499a5c8..d2400181dfd 100644
--- a/lib/tasks/gitlab/two_factor.rake
+++ b/lib/tasks/gitlab/two_factor.rake
@@ -22,12 +22,12 @@ namespace :gitlab do
namespace :rotate_key do
def rotator
- @rotator ||= Gitlab::OtpKeyRotator.new(ENV['filename'])
+ @rotator ||= Gitlab::OtpKeyRotator.new(ENV["filename"])
end
desc "Encrypt user OTP secrets with a new encryption key"
task apply: :environment do |t, args|
- rotator.rotate!(old_key: ENV['old_key'], new_key: ENV['new_key'])
+ rotator.rotate!(old_key: ENV["old_key"], new_key: ENV["new_key"])
end
desc "Rollback to secrets encrypted with the old encryption key"
diff --git a/lib/tasks/gitlab/update_templates.rake b/lib/tasks/gitlab/update_templates.rake
index abe10f5580e..eef13a9d90e 100644
--- a/lib/tasks/gitlab/update_templates.rake
+++ b/lib/tasks/gitlab/update_templates.rake
@@ -25,7 +25,7 @@ namespace :gitlab do
import_url: template.clone_url,
namespace_id: admin.namespace.id,
path: template.name,
- skip_wiki: true
+ skip_wiki: true,
}
puts "Creating project for #{template.title}"
@@ -102,10 +102,10 @@ namespace :gitlab do
Template.new(
"https://gitlab.com/gitlab-org/Dockerfile.git",
/(\.{1,2}|LICENSE|CONTRIBUTING.md|\.Dockerfile)\z/
- )
+ ),
].freeze
def vendor_directory
- Rails.root.join('vendor')
+ Rails.root.join("vendor")
end
end
diff --git a/lib/tasks/gitlab/uploads/check.rake b/lib/tasks/gitlab/uploads/check.rake
index 2be2ec7f9c9..d7d55bef28d 100644
--- a/lib/tasks/gitlab/uploads/check.rake
+++ b/lib/tasks/gitlab/uploads/check.rake
@@ -1,6 +1,6 @@
namespace :gitlab do
namespace :uploads do
- desc 'GitLab | Uploads | Check integrity of uploaded files'
+ desc "GitLab | Uploads | Check integrity of uploaded files"
task check: :environment do
Gitlab::Verify::RakeTask.run!(Gitlab::Verify::Uploads)
end
diff --git a/lib/tasks/gitlab/uploads/migrate.rake b/lib/tasks/gitlab/uploads/migrate.rake
index 1c93609a006..c2ab52b9907 100644
--- a/lib/tasks/gitlab/uploads/migrate.rake
+++ b/lib/tasks/gitlab/uploads/migrate.rake
@@ -3,17 +3,17 @@ namespace :gitlab do
namespace :migrate do
desc "GitLab | Uploads | Migrate all uploaded files to object storage"
task all: :environment do
- categories = [%w(AvatarUploader Project :avatar),
- %w(AvatarUploader Group :avatar),
- %w(AvatarUploader User :avatar),
- %w(AttachmentUploader Note :attachment),
- %w(AttachmentUploader Appearance :logo),
- %w(AttachmentUploader Appearance :header_logo),
- %w(FaviconUploader Appearance :favicon),
- %w(FileUploader Project),
- %w(PersonalFileUploader Snippet),
- %w(NamespaceFileUploader Snippet),
- %w(FileUploader MergeRequest)]
+ categories = [%w[AvatarUploader Project :avatar],
+ %w[AvatarUploader Group :avatar],
+ %w[AvatarUploader User :avatar],
+ %w[AttachmentUploader Note :attachment],
+ %w[AttachmentUploader Appearance :logo],
+ %w[AttachmentUploader Appearance :header_logo],
+ %w[FaviconUploader Appearance :favicon],
+ %w[FileUploader Project],
+ %w[PersonalFileUploader Snippet],
+ %w[NamespaceFileUploader Snippet],
+ %w[FileUploader MergeRequest],]
categories.each do |args|
Rake::Task["gitlab:uploads:migrate"].invoke(*args)
@@ -24,11 +24,11 @@ namespace :gitlab do
# The following is the actual rake task that migrates uploads of specified
# category to object storage
- desc 'GitLab | Uploads | Migrate the uploaded files of specified type to object storage'
+ desc "GitLab | Uploads | Migrate the uploaded files of specified type to object storage"
task :migrate, [:uploader_class, :model_class, :mounted_as] => :environment do |task, args|
- batch_size = ENV.fetch('BATCH', 200).to_i
+ batch_size = ENV.fetch("BATCH", 200).to_i
@to_store = ObjectStorage::Store::REMOTE
- @mounted_as = args.mounted_as&.gsub(':', '')&.to_sym
+ @mounted_as = args.mounted_as&.gsub(":", "")&.to_sym
@uploader_class = args.uploader_class.constantize
@model_class = args.model_class.constantize
@@ -37,9 +37,9 @@ namespace :gitlab do
def enqueue_batch(batch, index)
job = ObjectStorage::MigrateUploadsWorker.enqueue!(batch,
- @model_class,
- @mounted_as,
- @to_store)
+ @model_class,
+ @mounted_as,
+ @to_store)
puts "Enqueued job ##{index}: #{job}"
rescue ObjectStorage::MigrateUploadsWorker::SanityCheckError => e
# continue for the next batch
diff --git a/lib/tasks/gitlab/web_hook.rake b/lib/tasks/gitlab/web_hook.rake
index 15cec80b6a6..92038fa3228 100644
--- a/lib/tasks/gitlab/web_hook.rake
+++ b/lib/tasks/gitlab/web_hook.rake
@@ -2,8 +2,8 @@ namespace :gitlab do
namespace :web_hook do
desc "GitLab | Adds a webhook to the projects"
task add: :environment do
- web_hook_url = ENV['URL']
- namespace_path = ENV['NAMESPACE']
+ web_hook_url = ENV["URL"]
+ namespace_path = ENV["NAMESPACE"]
projects = find_projects(namespace_path)
@@ -22,8 +22,8 @@ namespace :gitlab do
desc "GitLab | Remove a webhook from the projects"
task rm: :environment do
- web_hook_url = ENV['URL']
- namespace_path = ENV['NAMESPACE']
+ web_hook_url = ENV["URL"]
+ namespace_path = ENV["NAMESPACE"]
web_hooks = find_web_hooks(namespace_path)
@@ -46,7 +46,7 @@ namespace :gitlab do
desc "GitLab | List webhooks"
task list: :environment do
- namespace_path = ENV['NAMESPACE']
+ namespace_path = ENV["NAMESPACE"]
web_hooks = find_web_hooks(namespace_path)
web_hooks.find_each do |hook|
diff --git a/lib/tasks/gitlab/workhorse.rake b/lib/tasks/gitlab/workhorse.rake
index b917a293095..be1d278f63b 100644
--- a/lib/tasks/gitlab/workhorse.rake
+++ b/lib/tasks/gitlab/workhorse.rake
@@ -8,14 +8,14 @@ namespace :gitlab do
abort %(Please specify the directory where you want to install gitlab-workhorse:\n rake "gitlab:workhorse:install[/home/git/gitlab-workhorse]")
end
- args.with_defaults(repo: 'https://gitlab.com/gitlab-org/gitlab-workhorse.git')
+ args.with_defaults(repo: "https://gitlab.com/gitlab-org/gitlab-workhorse.git")
version = Gitlab::Workhorse.version
checkout_or_clone_version(version: version, repo: args.repo, target_dir: args.dir)
_, status = Gitlab::Popen.popen(%w[which gmake])
- command = status.zero? ? 'gmake' : 'make'
+ command = status.zero? ? "gmake" : "make"
Dir.chdir(args.dir) do
run_command!([command])
diff --git a/lib/tasks/grape.rake b/lib/tasks/grape.rake
index ea2698da606..b0739faa9c4 100644
--- a/lib/tasks/grape.rake
+++ b/lib/tasks/grape.rake
@@ -1,5 +1,5 @@
namespace :grape do
- desc 'Print compiled grape routes'
+ desc "Print compiled grape routes"
task routes: :environment do
API::API.routes.each do |route|
puts "#{route.options[:method]} #{route.path} - #{route_description(route.options)}"
diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake
index 786efd14b1a..63344f448cb 100644
--- a/lib/tasks/haml-lint.rake
+++ b/lib/tasks/haml-lint.rake
@@ -1,13 +1,13 @@
unless Rails.env.production?
- require 'haml_lint/rake_task'
- require 'haml_lint/inline_javascript'
+ require "haml_lint/rake_task"
+ require "haml_lint/inline_javascript"
# Workaround for warnings from parser/current
# Keep it even if it no longer emits any warnings,
# because we'll still see warnings in console/server anyway,
# and we don't need to break static-analysis for this.
task :haml_lint do
- require 'parser'
+ require "parser"
def Parser.warn(*args)
puts(*args) # static-analysis ignores stdout if status is 0
end
diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake
index f912f521dfb..6bd83ef1b2b 100644
--- a/lib/tasks/import.rake
+++ b/lib/tasks/import.rake
@@ -1,5 +1,5 @@
-require 'benchmark'
-require 'rainbow/ext/string'
+require "benchmark"
+require "rainbow/ext/string"
class GithubImport
def self.run!(*args)
@@ -7,7 +7,7 @@ class GithubImport
end
def initialize(token, gitlab_username, project_path, extras)
- @options = { token: token }
+ @options = {token: token}
@project_path = project_path
@current_user = UserFinder.new(gitlab_username).find_by_username
@@ -21,7 +21,7 @@ class GithubImport
.new(@options[:token], @current_user, @github_repo)
.choose_one!
- raise 'No repo found!' unless @repo
+ raise "No repo found!" unless @repo
show_warning!
@@ -38,7 +38,7 @@ class GithubImport
STDIN.getch
- puts 'Starting the import (this could take a while)'.color(:green)
+ puts "Starting the import (this could take a while)".color(:green)
end
def import!
@@ -46,11 +46,11 @@ class GithubImport
import_success = false
- timings = Benchmark.measure do
+ timings = Benchmark.measure {
import_success = Gitlab::GithubImport::SequentialImporter
.new(@project, token: @options[:token])
.execute
- end
+ }
if import_success
@project.after_import
@@ -63,7 +63,7 @@ class GithubImport
def new_project
Project.transaction do
- namespace_path, _sep, name = @project_path.rpartition('/')
+ namespace_path, _sep, name = @project_path.rpartition("/")
namespace = find_or_create_namespace(namespace_path)
project = Projects::CreateService.new(
@@ -77,9 +77,9 @@ class GithubImport
).execute
project.update!(
- import_type: 'github',
+ import_type: "github",
import_source: @repo.full_name,
- import_url: @repo.clone_url.sub('://', "://#{@options[:token]}@")
+ import_url: @repo.clone_url.sub("://", "://#{@options[:token]}@")
)
project
@@ -119,7 +119,7 @@ class GithubRepos
print "\tName: #{repo.full_name}\n".color(:green)
end
- print 'ID? '.bright
+ print "ID? ".bright
repos.find { |repo| repo.id == repo_id }
end
@@ -138,9 +138,9 @@ class GithubRepos
end
namespace :import do
- desc 'Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)'
+ desc "Import a GitHub project - Example: import:github[ToKeN,root,root/blah,my/github_repo] (optional my/github_repo)"
task :github, [:token, :gitlab_username, :project_path] => :environment do |_t, args|
- abort 'Project path must be: namespace(s)/project_name'.color(:red) unless args.project_path.include?('/')
+ abort "Project path must be: namespace(s)/project_name".color(:red) unless args.project_path.include?("/")
GithubImport.run!(args.token, args.gitlab_username, args.project_path, args.extras)
end
diff --git a/lib/tasks/karma.rake b/lib/tasks/karma.rake
index 62a12174efa..3a00073d509 100644
--- a/lib/tasks/karma.rake
+++ b/lib/tasks/karma.rake
@@ -1,21 +1,21 @@
unless Rails.env.production?
namespace :karma do
- desc 'GitLab | Karma | Generate fixtures for JavaScript tests'
+ desc "GitLab | Karma | Generate fixtures for JavaScript tests"
RSpec::Core::RakeTask.new(:fixtures, [:pattern]) do |t, args|
- args.with_defaults(pattern: 'spec/javascripts/fixtures/*.rb')
- ENV['NO_KNAPSACK'] = 'true'
+ args.with_defaults(pattern: "spec/javascripts/fixtures/*.rb")
+ ENV["NO_KNAPSACK"] = "true"
t.pattern = args[:pattern]
- t.rspec_opts = '--format documentation'
+ t.rspec_opts = "--format documentation"
end
- desc 'GitLab | Karma | Run JavaScript tests'
- task tests: ['yarn:check'] do
+ desc "GitLab | Karma | Run JavaScript tests"
+ task tests: ["yarn:check"] do
sh "yarn run karma" do |ok, res|
- abort('rake karma:tests failed') unless ok
+ abort("rake karma:tests failed") unless ok
end
end
end
- desc 'GitLab | Karma | Shortcut for karma:fixtures and karma:tests'
- task karma: ['karma:fixtures', 'karma:tests']
+ desc "GitLab | Karma | Shortcut for karma:fixtures and karma:tests"
+ task karma: ["karma:fixtures", "karma:tests"]
end
diff --git a/lib/tasks/lint.rake b/lib/tasks/lint.rake
index 5d673a1a285..6680bf0fb4a 100644
--- a/lib/tasks/lint.rake
+++ b/lib/tasks/lint.rake
@@ -1,7 +1,7 @@
unless Rails.env.production?
namespace :lint do
task :static_verification_env do
- ENV['STATIC_VERIFICATION'] = 'true'
+ ENV["STATIC_VERIFICATION"] = "true"
end
desc "GitLab | lint | Static verification"
@@ -14,16 +14,14 @@ unless Rails.env.production?
desc "GitLab | lint | Lint JavaScript files using ESLint"
task :javascript do
- Rake::Task['eslint'].invoke
+ Rake::Task["eslint"].invoke
end
desc "GitLab | lint | Lint HAML files"
task :haml do
- begin
- Rake::Task['haml_lint'].invoke
- rescue RuntimeError # The haml_lint tasks raise a RuntimeError
- exit(1)
- end
+ Rake::Task["haml_lint"].invoke
+ rescue RuntimeError # The haml_lint tasks raise a RuntimeError
+ exit(1)
end
desc "GitLab | lint | Run several lint checks"
@@ -38,7 +36,7 @@ unless Rails.env.production?
gettext:updated_check
lint:static_verification
].each do |task|
- pid = Process.fork do
+ pid = Process.fork {
rd_out, wr_out = IO.pipe
rd_err, wr_err = IO.pipe
stdout = $stdout.dup
@@ -65,7 +63,7 @@ unless Rails.env.production?
IO.copy_stream(rd_out, $stdout)
IO.copy_stream(rd_err, $stderr)
end
- end
+ }
Process.waitpid(pid)
status += $?.exitstatus
diff --git a/lib/tasks/migrate/add_limits_mysql.rake b/lib/tasks/migrate/add_limits_mysql.rake
index c77fa49d586..81392a3769b 100644
--- a/lib/tasks/migrate/add_limits_mysql.rake
+++ b/lib/tasks/migrate/add_limits_mysql.rake
@@ -1,9 +1,9 @@
-require Rails.root.join('db/migrate/limits_to_mysql')
-require Rails.root.join('db/migrate/markdown_cache_limits_to_mysql')
-require Rails.root.join('db/migrate/merge_request_diff_file_limits_to_mysql')
-require Rails.root.join('db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql')
-require Rails.root.join('db/migrate/gpg_keys_limits_to_mysql')
-require Rails.root.join('db/migrate/prometheus_metrics_limits_to_mysql')
+require Rails.root.join("db/migrate/limits_to_mysql")
+require Rails.root.join("db/migrate/markdown_cache_limits_to_mysql")
+require Rails.root.join("db/migrate/merge_request_diff_file_limits_to_mysql")
+require Rails.root.join("db/migrate/limits_ci_build_trace_chunks_raw_data_for_mysql")
+require Rails.root.join("db/migrate/gpg_keys_limits_to_mysql")
+require Rails.root.join("db/migrate/prometheus_metrics_limits_to_mysql")
desc "GitLab | Add limits to strings in mysql database"
task add_limits_mysql: :environment do
diff --git a/lib/tasks/migrate/composite_primary_keys.rake b/lib/tasks/migrate/composite_primary_keys.rake
index eb112434dd9..fb8bba42a84 100644
--- a/lib/tasks/migrate/composite_primary_keys.rake
+++ b/lib/tasks/migrate/composite_primary_keys.rake
@@ -1,14 +1,14 @@
namespace :gitlab do
namespace :db do
- desc 'GitLab | Adds primary keys to tables that only have composite unique keys'
+ desc "GitLab | Adds primary keys to tables that only have composite unique keys"
task composite_primary_keys_add: :environment do
- require Rails.root.join('db/optional_migrations/composite_primary_keys')
+ require Rails.root.join("db/optional_migrations/composite_primary_keys")
CompositePrimaryKeysMigration.new.up
end
- desc 'GitLab | Removes previously added composite primary keys'
+ desc "GitLab | Removes previously added composite primary keys"
task composite_primary_keys_drop: :environment do
- require Rails.root.join('db/optional_migrations/composite_primary_keys')
+ require Rails.root.join("db/optional_migrations/composite_primary_keys")
CompositePrimaryKeysMigration.new.down
end
end
diff --git a/lib/tasks/migrate/migrate_iids.rake b/lib/tasks/migrate/migrate_iids.rake
index aa2d01730d7..b04ab63efa9 100644
--- a/lib/tasks/migrate/migrate_iids.rake
+++ b/lib/tasks/migrate/migrate_iids.rake
@@ -1,51 +1,45 @@
desc "GitLab | Build internal ids for issues and merge requests"
task migrate_iids: :environment do
- puts 'Issues'.color(:yellow)
+ puts "Issues".color(:yellow)
Issue.where(iid: nil).find_each(batch_size: 100) do |issue|
- begin
- issue.set_iid
+ issue.set_iid
- if issue.update_attribute(:iid, issue.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if issue.update_attribute(:iid, issue.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
- puts 'Merge Requests'.color(:yellow)
+ puts "done"
+ puts "Merge Requests".color(:yellow)
MergeRequest.where(iid: nil).find_each(batch_size: 100) do |mr|
- begin
- mr.set_iid
+ mr.set_iid
- if mr.update_attribute(:iid, mr.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if mr.update_attribute(:iid, mr.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
- puts 'Milestones'.color(:yellow)
+ puts "done"
+ puts "Milestones".color(:yellow)
Milestone.where(iid: nil).find_each(batch_size: 100) do |m|
- begin
- m.set_iid
+ m.set_iid
- if m.update_attribute(:iid, m.iid)
- print '.'
- else
- print 'F'
- end
- rescue
- print 'F'
+ if m.update_attribute(:iid, m.iid)
+ print "."
+ else
+ print "F"
end
+ rescue
+ print "F"
end
- puts 'done'
+ puts "done"
end
diff --git a/lib/tasks/migrate/setup_postgresql.rake b/lib/tasks/migrate/setup_postgresql.rake
index f69d204c579..5d1a1433fd8 100644
--- a/lib/tasks/migrate/setup_postgresql.rake
+++ b/lib/tasks/migrate/setup_postgresql.rake
@@ -1,15 +1,15 @@
-desc 'GitLab | Sets up PostgreSQL'
+desc "GitLab | Sets up PostgreSQL"
task setup_postgresql: :environment do
- require Rails.root.join('db/migrate/20151007120511_namespaces_projects_path_lower_indexes')
- require Rails.root.join('db/migrate/20151008110232_add_users_lower_username_email_indexes')
- require Rails.root.join('db/migrate/20161212142807_add_lower_path_index_to_routes')
- require Rails.root.join('db/migrate/20170317203554_index_routes_path_for_like')
- require Rails.root.join('db/migrate/20170724214302_add_lower_path_index_to_redirect_routes')
- require Rails.root.join('db/migrate/20170503185032_index_redirect_routes_path_for_like')
- require Rails.root.join('db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb')
- require Rails.root.join('db/migrate/20180215181245_users_name_lower_index.rb')
- require Rails.root.join('db/migrate/20180504195842_project_name_lower_index.rb')
- require Rails.root.join('db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb')
+ require Rails.root.join("db/migrate/20151007120511_namespaces_projects_path_lower_indexes")
+ require Rails.root.join("db/migrate/20151008110232_add_users_lower_username_email_indexes")
+ require Rails.root.join("db/migrate/20161212142807_add_lower_path_index_to_routes")
+ require Rails.root.join("db/migrate/20170317203554_index_routes_path_for_like")
+ require Rails.root.join("db/migrate/20170724214302_add_lower_path_index_to_redirect_routes")
+ require Rails.root.join("db/migrate/20170503185032_index_redirect_routes_path_for_like")
+ require Rails.root.join("db/migrate/20171220191323_add_index_on_namespaces_lower_name.rb")
+ require Rails.root.join("db/migrate/20180215181245_users_name_lower_index.rb")
+ require Rails.root.join("db/migrate/20180504195842_project_name_lower_index.rb")
+ require Rails.root.join("db/post_migrate/20180306164012_add_path_index_to_redirect_routes.rb")
NamespacesProjectsPathLowerIndexes.new.up
AddUsersLowerUsernameEmailIndexes.new.up
@@ -23,17 +23,17 @@ task setup_postgresql: :environment do
AddPathIndexToRedirectRoutes.new.up
end
-desc 'GitLab | Generate PostgreSQL Password Hash'
+desc "GitLab | Generate PostgreSQL Password Hash"
task :postgresql_md5_hash do
- require 'digest'
- username = ENV.fetch('USERNAME') do |missing|
+ require "digest"
+ username = ENV.fetch("USERNAME") { |missing|
puts "You must provide an username with '#{missing}' ENV variable"
exit(1)
- end
- password = ENV.fetch('PASSWORD') do |missing|
+ }
+ password = ENV.fetch("PASSWORD") { |missing|
puts "You must provide a password with '#{missing}' ENV variable"
exit(1)
- end
+ }
hash = Digest::MD5.hexdigest("#{password}#{username}")
puts "The MD5 hash of your database password for user: #{username} -> #{hash}"
end
diff --git a/lib/tasks/plugins.rake b/lib/tasks/plugins.rake
index e73dd7e68df..d6434d58ab6 100644
--- a/lib/tasks/plugins.rake
+++ b/lib/tasks/plugins.rake
@@ -1,7 +1,7 @@
namespace :plugins do
- desc 'Validate existing plugins'
+ desc "Validate existing plugins"
task validate: :environment do
- puts 'Validating plugins from /plugins directory'
+ puts "Validating plugins from /plugins directory"
Gitlab::Plugin.files.each do |file|
success, message = Gitlab::Plugin.execute(file, Gitlab::DataBuilder::Push::SAMPLE_DATA)
diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake
index 78ffccc9d06..17327b57c73 100644
--- a/lib/tasks/rubocop.rake
+++ b/lib/tasks/rubocop.rake
@@ -1,5 +1,5 @@
unless Rails.env.production?
- require 'rubocop/rake_task'
+ require "rubocop/rake_task"
RuboCop::RakeTask.new
end
diff --git a/lib/tasks/scss-lint.rake b/lib/tasks/scss-lint.rake
index 250fd8699e4..e64a0d71a4a 100644
--- a/lib/tasks/scss-lint.rake
+++ b/lib/tasks/scss-lint.rake
@@ -1,8 +1,8 @@
unless Rails.env.production?
- require 'scss_lint/rake_task'
+ require "scss_lint/rake_task"
SCSSLint::RakeTask.new do |t|
- t.config = '.scss-lint.yml'
+ t.config = ".scss-lint.yml"
# See https://github.com/brigade/scss-lint/issues/726
# Hack, otherwise linter won't respect scss_files option in config file.
t.files = []
diff --git a/lib/tasks/services.rake b/lib/tasks/services.rake
index 56b81106c5f..1c0a39fbc8f 100644
--- a/lib/tasks/services.rake
+++ b/lib/tasks/services.rake
@@ -1,60 +1,60 @@
-services_template = <<-ERB
-# Services
+services_template = <<~ERB
+ # Services
-<% services.each do |service| %>
-## <%= service[:title] %>
+ <% services.each do |service| %>
+ ## <%= service[:title] %>
-<% unless service[:description].blank? %>
-<%= service[:description] %>
-<% end %>
+ <% unless service[:description].blank? %>
+ <%= service[:description] %>
+ <% end %>
-### Create/Edit <%= service[:title] %> service
+ ### Create/Edit <%= service[:title] %> service
-Set <%= service[:title] %> service for a project.
-<% unless service[:help].blank? %>
+ Set <%= service[:title] %> service for a project.
+ <% unless service[:help].blank? %>
-> <%= service[:help].gsub("\n", ' ') %>
+ > <%= service[:help].gsub("\n", ' ') %>
-<% end %>
+ <% end %>
-```
-PUT /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ PUT /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-Parameters:
+ Parameters:
-<% service[:params].each do |param| %>
-- `<%= param[:name] %>` <%= param[:required] ? "(**required**)" : "(optional)" %><%= [" -", param[:description]].join(" ").gsub("\n", '') unless param[:description].blank? %>
+ <% service[:params].each do |param| %>
+ - `<%= param[:name] %>` <%= param[:required] ? "(**required**)" : "(optional)" %><%= [" -", param[:description]].join(" ").gsub("\n", '') unless param[:description].blank? %>
-<% end %>
+ <% end %>
-### Delete <%= service[:title] %> service
+ ### Delete <%= service[:title] %> service
-Delete <%= service[:title] %> service for a project.
+ Delete <%= service[:title] %> service for a project.
-```
-DELETE /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ DELETE /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-### Get <%= service[:title] %> service settings
+ ### Get <%= service[:title] %> service settings
-Get <%= service[:title] %> service settings for a project.
+ Get <%= service[:title] %> service settings for a project.
-```
-GET /projects/:id/services/<%= service[:dashed_name] %>
+ ```
+ GET /projects/:id/services/<%= service[:dashed_name] %>
-```
+ ```
-<% end %>
+ <% end %>
ERB
namespace :services do
task doc: :environment do
- services = Service.available_services_names.map do |s|
+ services = Service.available_services_names.map { |s|
service_start = Time.now
klass = "#{s}_service".classify.constantize
@@ -66,30 +66,30 @@ namespace :services do
service_hash[:dashed_name] = s.dasherize
service_hash[:description] = service.description
service_hash[:help] = service.help
- service_hash[:params] = service.fields.map do |p|
+ service_hash[:params] = service.fields.map { |p|
param_hash = {}
param_hash[:name] = p[:name]
param_hash[:description] = p[:placeholder] || p[:title]
- param_hash[:required] = klass.validators_on(p[:name].to_sym).any? do |v|
+ param_hash[:required] = klass.validators_on(p[:name].to_sym).any? { |v|
v.class == ActiveRecord::Validations::PresenceValidator
- end
+ }
param_hash
- end
+ }
service_hash[:params].sort_by! { |p| p[:required] ? 0 : 1 }
puts "Collected data for: #{service.title}, #{Time.now - service_start}"
service_hash
- end
+ }
doc_start = Time.now
- doc_path = File.join(Rails.root, 'doc', 'api', 'services.md')
+ doc_path = File.join(Rails.root, "doc", "api", "services.md")
- result = ERB.new(services_template, 0, '>')
+ result = ERB.new(services_template, 0, ">")
.result(OpenStruct.new(services: services).instance_eval { binding })
- File.open(doc_path, 'w') do |f|
+ File.open(doc_path, "w") do |f|
f.write result
end
diff --git a/lib/tasks/sidekiq.rake b/lib/tasks/sidekiq.rake
index dd9ce86f7ca..68c61cb9099 100644
--- a/lib/tasks/sidekiq.rake
+++ b/lib/tasks/sidekiq.rake
@@ -1,21 +1,21 @@
namespace :sidekiq do
desc "GitLab | Stop sidekiq"
task :stop do
- system(*%w(bin/background_jobs stop))
+ system("bin/background_jobs", "stop")
end
desc "GitLab | Start sidekiq"
task :start do
- system(*%w(bin/background_jobs start))
+ system("bin/background_jobs", "start")
end
- desc 'GitLab | Restart sidekiq'
+ desc "GitLab | Restart sidekiq"
task :restart do
- system(*%w(bin/background_jobs restart))
+ system("bin/background_jobs", "restart")
end
desc "GitLab | Start sidekiq with launchd on Mac OS X"
task :launchd do
- system(*%w(bin/background_jobs start_no_deamonize))
+ system("bin/background_jobs", "start_no_deamonize")
end
end
diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake
index 2eddcb3c777..f7d47c1b945 100644
--- a/lib/tasks/spec.rake
+++ b/lib/tasks/spec.rake
@@ -1,56 +1,56 @@
-Rake::Task["spec"].clear if Rake::Task.task_defined?('spec')
+Rake::Task["spec"].clear if Rake::Task.task_defined?("spec")
namespace :spec do
- desc 'GitLab | Rspec | Run request specs'
+ desc "GitLab | Rspec | Run request specs"
task :api do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @api)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @api],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run feature specs'
+ desc "GitLab | Rspec | Run feature specs"
task :feature do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @feature)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @feature],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run model specs'
+ desc "GitLab | Rspec | Run model specs"
task :models do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @models)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @models],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run service specs'
+ desc "GitLab | Rspec | Run service specs"
task :services do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @services)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @services],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run lib specs'
+ desc "GitLab | Rspec | Run lib specs"
task :lib do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag @lib)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag @lib],
]
run_commands(cmds)
end
- desc 'GitLab | Rspec | Run other specs'
+ desc "GitLab | Rspec | Run other specs"
task :other do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services)
+ %w[rake gitlab:setup],
+ %w[rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services],
]
run_commands(cmds)
end
@@ -59,14 +59,14 @@ end
desc "GitLab | Run specs"
task :spec do
cmds = [
- %w(rake gitlab:setup),
- %w(rspec spec)
+ %w[rake gitlab:setup],
+ %w[rspec spec],
]
run_commands(cmds)
end
def run_commands(cmds)
cmds.each do |cmd|
- system({ 'RAILS_ENV' => 'test', 'force' => 'yes' }, *cmd) || raise("#{cmd} failed!")
+ system({"RAILS_ENV" => "test", "force" => "yes"}, *cmd) || raise("#{cmd} failed!")
end
end
diff --git a/lib/tasks/tokens.rake b/lib/tasks/tokens.rake
index eec024f9bbb..99ddf008434 100644
--- a/lib/tasks/tokens.rake
+++ b/lib/tasks/tokens.rake
@@ -1,7 +1,7 @@
-require_relative '../../app/models/concerns/token_authenticatable.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/base.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/insecure.rb'
-require_relative '../../app/models/concerns/token_authenticatable_strategies/digest.rb'
+require_relative "../../app/models/concerns/token_authenticatable.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/base.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/insecure.rb"
+require_relative "../../app/models/concerns/token_authenticatable_strategies/digest.rb"
namespace :tokens do
desc "Reset all GitLab incoming email tokens"
@@ -27,7 +27,7 @@ end
class TmpUser < ActiveRecord::Base
include TokenAuthenticatable
- self.table_name = 'users'
+ self.table_name = "users"
add_authentication_token_field :incoming_email_token, token_generator: -> { SecureRandom.hex.to_i(16).to_s(36) }
add_authentication_token_field :feed_token
diff --git a/lib/tasks/yarn.rake b/lib/tasks/yarn.rake
index 2ac88a039e7..8d2a1339821 100644
--- a/lib/tasks/yarn.rake
+++ b/lib/tasks/yarn.rake
@@ -1,40 +1,39 @@
-
namespace :yarn do
- desc 'Ensure Yarn is installed'
+ desc "Ensure Yarn is installed"
task :available do
- unless system('yarn --version', out: File::NULL)
+ unless system("yarn --version", out: File::NULL)
warn(
- 'Error: Yarn executable was not detected in the system.'.color(:red),
- 'Download Yarn at https://yarnpkg.com/en/docs/install'.color(:green)
+ "Error: Yarn executable was not detected in the system.".color(:red),
+ "Download Yarn at https://yarnpkg.com/en/docs/install".color(:green)
)
abort
end
end
- desc 'Ensure Node dependencies are installed'
- task check: ['yarn:available'] do
- unless system('yarn check --ignore-engines', out: File::NULL)
+ desc "Ensure Node dependencies are installed"
+ task check: ["yarn:available"] do
+ unless system("yarn check --ignore-engines", out: File::NULL)
warn(
- 'Error: You have unmet dependencies. (`yarn check` command failed)'.color(:red),
- 'Run `yarn install` to install missing modules.'.color(:green)
+ "Error: You have unmet dependencies. (`yarn check` command failed)".color(:red),
+ "Run `yarn install` to install missing modules.".color(:green)
)
abort
end
end
- desc 'Install Node dependencies with Yarn'
- task install: ['yarn:available'] do
- unless system('yarn install --pure-lockfile --ignore-engines')
- abort 'Error: Unable to install node modules.'.color(:red)
+ desc "Install Node dependencies with Yarn"
+ task install: ["yarn:available"] do
+ unless system("yarn install --pure-lockfile --ignore-engines")
+ abort "Error: Unable to install node modules.".color(:red)
end
end
- desc 'Remove Node dependencies'
+ desc "Remove Node dependencies"
task :clobber do
- warn 'Purging ./node_modules directory'.color(:red)
- FileUtils.rm_rf 'node_modules'
+ warn "Purging ./node_modules directory".color(:red)
+ FileUtils.rm_rf "node_modules"
end
end
-desc 'Install Node dependencies with Yarn'
-task yarn: ['yarn:install']
+desc "Install Node dependencies with Yarn"
+task yarn: ["yarn:install"]
diff --git a/lib/unfold_form.rb b/lib/unfold_form.rb
index 05bb3ed7f1c..2fca1d69b73 100644
--- a/lib/unfold_form.rb
+++ b/lib/unfold_form.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative 'gt_one_coercion'
+require_relative "gt_one_coercion"
class UnfoldForm
include Virtus.model
diff --git a/lib/uploaded_file.rb b/lib/uploaded_file.rb
index aae542f02ac..87f1b87626d 100644
--- a/lib/uploaded_file.rb
+++ b/lib/uploaded_file.rb
@@ -27,7 +27,7 @@ class UploadedFile
@content_type = content_type
@sha256 = sha256
@remote_id = remote_id
- @tempfile = File.new(path, 'rb')
+ @tempfile = File.new(path, "rb")
end
def self.from_params(params, field, upload_paths)
@@ -40,13 +40,13 @@ class UploadedFile
file_path = File.realpath(params["#{field}.path"])
paths = Array(upload_paths) << Dir.tmpdir
- unless self.allowed_path?(file_path, paths.compact)
+ unless allowed_path?(file_path, paths.compact)
raise InvalidPathError, "insecure path used '#{file_path}'"
end
UploadedFile.new(file_path,
filename: params["#{field}.name"],
- content_type: params["#{field}.type"] || 'application/octet-stream',
+ content_type: params["#{field}.type"] || "application/octet-stream",
sha256: params["#{field}.sha256"],
remote_id: params["#{field}.remote_id"])
end
@@ -71,7 +71,7 @@ class UploadedFile
@tempfile.path
end
- alias_method :local_path, :path
+ alias local_path path
def method_missing(method_name, *args, &block) #:nodoc:
@tempfile.__send__(method_name, *args, &block) # rubocop:disable GitlabSecurity/PublicSend
diff --git a/lib/version_check.rb b/lib/version_check.rb
index c9f102f6b19..85e922ba2a7 100644
--- a/lib/version_check.rb
+++ b/lib/version_check.rb
@@ -6,7 +6,7 @@ require "base64"
# check if it is a new version for update
class VersionCheck
def self.data
- { version: Gitlab::VERSION }
+ {version: Gitlab::VERSION}
end
def self.url
@@ -16,6 +16,6 @@ class VersionCheck
end
def self.host
- 'https://version.gitlab.com/check.svg'
+ "https://version.gitlab.com/check.svg"
end
end
diff --git a/locale/unfound_translations.rb b/locale/unfound_translations.rb
index 0826d64049b..1e147e96847 100644
--- a/locale/unfound_translations.rb
+++ b/locale/unfound_translations.rb
@@ -4,13 +4,13 @@
# https://github.com/grosser/gettext_i18n_rails#unfound-translations-with-rake-gettextfind
# NotificationSetting.email_events
-N_('NotificationEvent|New note')
-N_('NotificationEvent|New issue')
-N_('NotificationEvent|Reopen issue')
-N_('NotificationEvent|Close issue')
-N_('NotificationEvent|Reassign issue')
-N_('NotificationEvent|New merge request')
-N_('NotificationEvent|Close merge request')
-N_('NotificationEvent|Reassign merge request')
-N_('NotificationEvent|Merge merge request')
-N_('NotificationEvent|Failed pipeline')
+N_("NotificationEvent|New note")
+N_("NotificationEvent|New issue")
+N_("NotificationEvent|Reopen issue")
+N_("NotificationEvent|Close issue")
+N_("NotificationEvent|Reassign issue")
+N_("NotificationEvent|New merge request")
+N_("NotificationEvent|Close merge request")
+N_("NotificationEvent|Reassign merge request")
+N_("NotificationEvent|Merge merge request")
+N_("NotificationEvent|Failed pipeline")
diff --git a/plugins/examples/save_to_file.rb b/plugins/examples/save_to_file.rb
index 61b0df9bfd6..988a701625c 100755
--- a/plugins/examples/save_to_file.rb
+++ b/plugins/examples/save_to_file.rb
@@ -1,3 +1,3 @@
#!/usr/bin/env ruby
x = STDIN.read
-File.write('/tmp/rb-data.txt', x)
+File.write("/tmp/rb-data.txt", x)
diff --git a/qa/Gemfile b/qa/Gemfile
index f29006617ed..96f5db8bf57 100644
--- a/qa/Gemfile
+++ b/qa/Gemfile
@@ -1,11 +1,11 @@
-source 'https://rubygems.org'
+source "https://rubygems.org"
-gem 'pry-byebug', '~> 3.5.1', platform: :mri
-gem 'capybara', '~> 2.16.1'
-gem 'capybara-screenshot', '~> 1.0.18'
-gem 'rake', '~> 12.3.0'
-gem 'rspec', '~> 3.7'
-gem 'selenium-webdriver', '~> 3.12'
-gem 'airborne', '~> 0.2.13'
-gem 'nokogiri', '~> 1.10.1'
-gem 'rspec-retry', '~> 0.6.1'
+gem "pry-byebug", "~> 3.5.1", platform: :mri
+gem "capybara", "~> 2.16.1"
+gem "capybara-screenshot", "~> 1.0.18"
+gem "rake", "~> 12.3.0"
+gem "rspec", "~> 3.7"
+gem "selenium-webdriver", "~> 3.12"
+gem "airborne", "~> 0.2.13"
+gem "nokogiri", "~> 1.10.1"
+gem "rspec-retry", "~> 0.6.1"
diff --git a/qa/Rakefile b/qa/Rakefile
index 9a7b9c6bb35..e595c1cc214 100644
--- a/qa/Rakefile
+++ b/qa/Rakefile
@@ -1,5 +1,5 @@
-require_relative 'qa/tools/revoke_all_personal_access_tokens'
-require_relative 'qa/tools/delete_subgroups'
+require_relative "qa/tools/revoke_all_personal_access_tokens"
+require_relative "qa/tools/delete_subgroups"
desc "Revokes all personal access tokens"
task :revoke_personal_access_tokens do
diff --git a/qa/bin/qa b/qa/bin/qa
index 6a772e93cee..22f8abb0d0a 100755
--- a/qa/bin/qa
+++ b/qa/bin/qa
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
-require_relative '../qa'
+require_relative "../qa"
QA::Scenario
.const_get(ARGV.shift)
diff --git a/qa/qa.rb b/qa/qa.rb
index 2b3ffabbbaa..f079097de18 100644
--- a/qa/qa.rb
+++ b/qa/qa.rb
@@ -1,35 +1,35 @@
# frozen_string_literal: true
-$: << File.expand_path(File.dirname(__FILE__))
+$: << __dir__
-Encoding.default_external = 'UTF-8'
+Encoding.default_external = "UTF-8"
module QA
##
# GitLab QA runtime classes, mostly singletons.
#
module Runtime
- autoload :Release, 'qa/runtime/release'
- autoload :User, 'qa/runtime/user'
- autoload :Namespace, 'qa/runtime/namespace'
- autoload :Scenario, 'qa/runtime/scenario'
- autoload :Browser, 'qa/runtime/browser'
- autoload :Env, 'qa/runtime/env'
- autoload :Address, 'qa/runtime/address'
- autoload :Path, 'qa/runtime/path'
- autoload :Fixtures, 'qa/runtime/fixtures'
- autoload :Logger, 'qa/runtime/logger'
+ autoload :Release, "qa/runtime/release"
+ autoload :User, "qa/runtime/user"
+ autoload :Namespace, "qa/runtime/namespace"
+ autoload :Scenario, "qa/runtime/scenario"
+ autoload :Browser, "qa/runtime/browser"
+ autoload :Env, "qa/runtime/env"
+ autoload :Address, "qa/runtime/address"
+ autoload :Path, "qa/runtime/path"
+ autoload :Fixtures, "qa/runtime/fixtures"
+ autoload :Logger, "qa/runtime/logger"
module API
- autoload :Client, 'qa/runtime/api/client'
- autoload :Request, 'qa/runtime/api/request'
+ autoload :Client, "qa/runtime/api/client"
+ autoload :Request, "qa/runtime/api/request"
end
module Key
- autoload :Base, 'qa/runtime/key/base'
- autoload :RSA, 'qa/runtime/key/rsa'
- autoload :ECDSA, 'qa/runtime/key/ecdsa'
- autoload :ED25519, 'qa/runtime/key/ed25519'
+ autoload :Base, "qa/runtime/key/base"
+ autoload :RSA, "qa/runtime/key/rsa"
+ autoload :ECDSA, "qa/runtime/key/ecdsa"
+ autoload :ED25519, "qa/runtime/key/ed25519"
end
end
@@ -37,44 +37,44 @@ module QA
# GitLab QA fabrication mechanisms
#
module Resource
- autoload :ApiFabricator, 'qa/resource/api_fabricator'
- autoload :Base, 'qa/resource/base'
-
- autoload :Sandbox, 'qa/resource/sandbox'
- autoload :Group, 'qa/resource/group'
- autoload :Issue, 'qa/resource/issue'
- autoload :Project, 'qa/resource/project'
- autoload :Label, 'qa/resource/label'
- autoload :MergeRequest, 'qa/resource/merge_request'
- autoload :ProjectImportedFromGithub, 'qa/resource/project_imported_from_github'
- autoload :MergeRequestFromFork, 'qa/resource/merge_request_from_fork'
- autoload :DeployKey, 'qa/resource/deploy_key'
- autoload :DeployToken, 'qa/resource/deploy_token'
- autoload :Branch, 'qa/resource/branch'
- autoload :CiVariable, 'qa/resource/ci_variable'
- autoload :Runner, 'qa/resource/runner'
- autoload :PersonalAccessToken, 'qa/resource/personal_access_token'
- autoload :KubernetesCluster, 'qa/resource/kubernetes_cluster'
- autoload :User, 'qa/resource/user'
- autoload :ProjectMilestone, 'qa/resource/project_milestone'
- autoload :Wiki, 'qa/resource/wiki'
- autoload :File, 'qa/resource/file'
- autoload :Fork, 'qa/resource/fork'
- autoload :SSHKey, 'qa/resource/ssh_key'
+ autoload :ApiFabricator, "qa/resource/api_fabricator"
+ autoload :Base, "qa/resource/base"
+
+ autoload :Sandbox, "qa/resource/sandbox"
+ autoload :Group, "qa/resource/group"
+ autoload :Issue, "qa/resource/issue"
+ autoload :Project, "qa/resource/project"
+ autoload :Label, "qa/resource/label"
+ autoload :MergeRequest, "qa/resource/merge_request"
+ autoload :ProjectImportedFromGithub, "qa/resource/project_imported_from_github"
+ autoload :MergeRequestFromFork, "qa/resource/merge_request_from_fork"
+ autoload :DeployKey, "qa/resource/deploy_key"
+ autoload :DeployToken, "qa/resource/deploy_token"
+ autoload :Branch, "qa/resource/branch"
+ autoload :CiVariable, "qa/resource/ci_variable"
+ autoload :Runner, "qa/resource/runner"
+ autoload :PersonalAccessToken, "qa/resource/personal_access_token"
+ autoload :KubernetesCluster, "qa/resource/kubernetes_cluster"
+ autoload :User, "qa/resource/user"
+ autoload :ProjectMilestone, "qa/resource/project_milestone"
+ autoload :Wiki, "qa/resource/wiki"
+ autoload :File, "qa/resource/file"
+ autoload :Fork, "qa/resource/fork"
+ autoload :SSHKey, "qa/resource/ssh_key"
module Events
- autoload :Base, 'qa/resource/events/base'
- autoload :Project, 'qa/resource/events/project'
+ autoload :Base, "qa/resource/events/base"
+ autoload :Project, "qa/resource/events/project"
end
module Repository
- autoload :Push, 'qa/resource/repository/push'
- autoload :ProjectPush, 'qa/resource/repository/project_push'
- autoload :WikiPush, 'qa/resource/repository/wiki_push'
+ autoload :Push, "qa/resource/repository/push"
+ autoload :ProjectPush, "qa/resource/repository/project_push"
+ autoload :WikiPush, "qa/resource/repository/wiki_push"
end
module Settings
- autoload :HashedStorage, 'qa/resource/settings/hashed_storage'
+ autoload :HashedStorage, "qa/resource/settings/hashed_storage"
end
end
@@ -85,34 +85,34 @@ module QA
##
# Support files
#
- autoload :Bootable, 'qa/scenario/bootable'
- autoload :Actable, 'qa/scenario/actable'
- autoload :Template, 'qa/scenario/template'
+ autoload :Bootable, "qa/scenario/bootable"
+ autoload :Actable, "qa/scenario/actable"
+ autoload :Template, "qa/scenario/template"
##
# Test scenario entrypoints.
#
module Test
- autoload :Instance, 'qa/scenario/test/instance'
+ autoload :Instance, "qa/scenario/test/instance"
module Instance
- autoload :All, 'qa/scenario/test/instance/all'
- autoload :Smoke, 'qa/scenario/test/instance/smoke'
+ autoload :All, "qa/scenario/test/instance/all"
+ autoload :Smoke, "qa/scenario/test/instance/smoke"
end
module Integration
- autoload :Github, 'qa/scenario/test/integration/github'
- autoload :LDAPNoTLS, 'qa/scenario/test/integration/ldap_no_tls'
- autoload :LDAPTLS, 'qa/scenario/test/integration/ldap_tls'
- autoload :InstanceSAML, 'qa/scenario/test/integration/instance_saml'
- autoload :OAuth, 'qa/scenario/test/integration/oauth'
- autoload :Kubernetes, 'qa/scenario/test/integration/kubernetes'
- autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
- autoload :ObjectStorage, 'qa/scenario/test/integration/object_storage'
+ autoload :Github, "qa/scenario/test/integration/github"
+ autoload :LDAPNoTLS, "qa/scenario/test/integration/ldap_no_tls"
+ autoload :LDAPTLS, "qa/scenario/test/integration/ldap_tls"
+ autoload :InstanceSAML, "qa/scenario/test/integration/instance_saml"
+ autoload :OAuth, "qa/scenario/test/integration/oauth"
+ autoload :Kubernetes, "qa/scenario/test/integration/kubernetes"
+ autoload :Mattermost, "qa/scenario/test/integration/mattermost"
+ autoload :ObjectStorage, "qa/scenario/test/integration/object_storage"
end
module Sanity
- autoload :Framework, 'qa/scenario/test/sanity/framework'
- autoload :Selectors, 'qa/scenario/test/sanity/selectors'
+ autoload :Framework, "qa/scenario/test/sanity/framework"
+ autoload :Selectors, "qa/scenario/test/sanity/selectors"
end
end
end
@@ -123,196 +123,196 @@ module QA
# Needed to execute click-driven-only black-box tests.
#
module Page
- autoload :Base, 'qa/page/base'
- autoload :View, 'qa/page/view'
- autoload :Element, 'qa/page/element'
- autoload :Validator, 'qa/page/validator'
+ autoload :Base, "qa/page/base"
+ autoload :View, "qa/page/view"
+ autoload :Element, "qa/page/element"
+ autoload :Validator, "qa/page/validator"
module Main
- autoload :Login, 'qa/page/main/login'
- autoload :Menu, 'qa/page/main/menu'
- autoload :OAuth, 'qa/page/main/oauth'
- autoload :SignUp, 'qa/page/main/sign_up'
+ autoload :Login, "qa/page/main/login"
+ autoload :Menu, "qa/page/main/menu"
+ autoload :OAuth, "qa/page/main/oauth"
+ autoload :SignUp, "qa/page/main/sign_up"
end
module Settings
- autoload :Common, 'qa/page/settings/common'
+ autoload :Common, "qa/page/settings/common"
end
module Dashboard
- autoload :Projects, 'qa/page/dashboard/projects'
- autoload :Groups, 'qa/page/dashboard/groups'
+ autoload :Projects, "qa/page/dashboard/projects"
+ autoload :Groups, "qa/page/dashboard/groups"
end
module Group
- autoload :New, 'qa/page/group/new'
- autoload :Show, 'qa/page/group/show'
+ autoload :New, "qa/page/group/new"
+ autoload :Show, "qa/page/group/show"
end
module File
- autoload :Form, 'qa/page/file/form'
- autoload :Show, 'qa/page/file/show'
+ autoload :Form, "qa/page/file/form"
+ autoload :Show, "qa/page/file/show"
module Shared
- autoload :CommitMessage, 'qa/page/file/shared/commit_message'
+ autoload :CommitMessage, "qa/page/file/shared/commit_message"
end
end
module Project
- autoload :New, 'qa/page/project/new'
- autoload :Show, 'qa/page/project/show'
- autoload :Activity, 'qa/page/project/activity'
- autoload :Menu, 'qa/page/project/menu'
+ autoload :New, "qa/page/project/new"
+ autoload :Show, "qa/page/project/show"
+ autoload :Activity, "qa/page/project/activity"
+ autoload :Menu, "qa/page/project/menu"
module Branches
- autoload :Show, 'qa/page/project/branches/show'
+ autoload :Show, "qa/page/project/branches/show"
end
module Commit
- autoload :Show, 'qa/page/project/commit/show'
+ autoload :Show, "qa/page/project/commit/show"
end
module Import
- autoload :Github, 'qa/page/project/import/github'
+ autoload :Github, "qa/page/project/import/github"
end
module Pipeline
- autoload :Index, 'qa/page/project/pipeline/index'
- autoload :Show, 'qa/page/project/pipeline/show'
+ autoload :Index, "qa/page/project/pipeline/index"
+ autoload :Show, "qa/page/project/pipeline/show"
end
module Job
- autoload :Show, 'qa/page/project/job/show'
+ autoload :Show, "qa/page/project/job/show"
end
module Settings
- autoload :Common, 'qa/page/project/settings/common'
- autoload :Advanced, 'qa/page/project/settings/advanced'
- autoload :Main, 'qa/page/project/settings/main'
- autoload :Repository, 'qa/page/project/settings/repository'
- autoload :CICD, 'qa/page/project/settings/ci_cd'
- autoload :DeployKeys, 'qa/page/project/settings/deploy_keys'
- autoload :DeployTokens, 'qa/page/project/settings/deploy_tokens'
- autoload :ProtectedBranches, 'qa/page/project/settings/protected_branches'
- autoload :CiVariables, 'qa/page/project/settings/ci_variables'
- autoload :Runners, 'qa/page/project/settings/runners'
- autoload :MergeRequest, 'qa/page/project/settings/merge_request'
- autoload :Members, 'qa/page/project/settings/members'
- autoload :MirroringRepositories, 'qa/page/project/settings/mirroring_repositories'
+ autoload :Common, "qa/page/project/settings/common"
+ autoload :Advanced, "qa/page/project/settings/advanced"
+ autoload :Main, "qa/page/project/settings/main"
+ autoload :Repository, "qa/page/project/settings/repository"
+ autoload :CICD, "qa/page/project/settings/ci_cd"
+ autoload :DeployKeys, "qa/page/project/settings/deploy_keys"
+ autoload :DeployTokens, "qa/page/project/settings/deploy_tokens"
+ autoload :ProtectedBranches, "qa/page/project/settings/protected_branches"
+ autoload :CiVariables, "qa/page/project/settings/ci_variables"
+ autoload :Runners, "qa/page/project/settings/runners"
+ autoload :MergeRequest, "qa/page/project/settings/merge_request"
+ autoload :Members, "qa/page/project/settings/members"
+ autoload :MirroringRepositories, "qa/page/project/settings/mirroring_repositories"
end
module SubMenus
- autoload :CiCd, 'qa/page/project/sub_menus/ci_cd'
- autoload :Common, 'qa/page/project/sub_menus/common'
- autoload :Issues, 'qa/page/project/sub_menus/issues'
- autoload :Operations, 'qa/page/project/sub_menus/operations'
- autoload :Repository, 'qa/page/project/sub_menus/repository'
- autoload :Settings, 'qa/page/project/sub_menus/settings'
+ autoload :CiCd, "qa/page/project/sub_menus/ci_cd"
+ autoload :Common, "qa/page/project/sub_menus/common"
+ autoload :Issues, "qa/page/project/sub_menus/issues"
+ autoload :Operations, "qa/page/project/sub_menus/operations"
+ autoload :Repository, "qa/page/project/sub_menus/repository"
+ autoload :Settings, "qa/page/project/sub_menus/settings"
end
module Issue
- autoload :New, 'qa/page/project/issue/new'
- autoload :Show, 'qa/page/project/issue/show'
- autoload :Index, 'qa/page/project/issue/index'
+ autoload :New, "qa/page/project/issue/new"
+ autoload :Show, "qa/page/project/issue/show"
+ autoload :Index, "qa/page/project/issue/index"
end
module Fork
- autoload :New, 'qa/page/project/fork/new'
+ autoload :New, "qa/page/project/fork/new"
end
module Milestone
- autoload :New, 'qa/page/project/milestone/new'
- autoload :Index, 'qa/page/project/milestone/index'
+ autoload :New, "qa/page/project/milestone/new"
+ autoload :Index, "qa/page/project/milestone/index"
end
module Operations
module Environments
- autoload :Index, 'qa/page/project/operations/environments/index'
- autoload :Show, 'qa/page/project/operations/environments/show'
+ autoload :Index, "qa/page/project/operations/environments/index"
+ autoload :Show, "qa/page/project/operations/environments/show"
end
module Kubernetes
- autoload :Index, 'qa/page/project/operations/kubernetes/index'
- autoload :Add, 'qa/page/project/operations/kubernetes/add'
- autoload :AddExisting, 'qa/page/project/operations/kubernetes/add_existing'
- autoload :Show, 'qa/page/project/operations/kubernetes/show'
+ autoload :Index, "qa/page/project/operations/kubernetes/index"
+ autoload :Add, "qa/page/project/operations/kubernetes/add"
+ autoload :AddExisting, "qa/page/project/operations/kubernetes/add_existing"
+ autoload :Show, "qa/page/project/operations/kubernetes/show"
end
end
module Wiki
- autoload :Edit, 'qa/page/project/wiki/edit'
- autoload :New, 'qa/page/project/wiki/new'
- autoload :Show, 'qa/page/project/wiki/show'
+ autoload :Edit, "qa/page/project/wiki/edit"
+ autoload :New, "qa/page/project/wiki/new"
+ autoload :Show, "qa/page/project/wiki/show"
end
module WebIDE
- autoload :Edit, 'qa/page/project/web_ide/edit'
+ autoload :Edit, "qa/page/project/web_ide/edit"
end
end
module Profile
- autoload :Menu, 'qa/page/profile/menu'
- autoload :PersonalAccessTokens, 'qa/page/profile/personal_access_tokens'
- autoload :SSHKeys, 'qa/page/profile/ssh_keys'
+ autoload :Menu, "qa/page/profile/menu"
+ autoload :PersonalAccessTokens, "qa/page/profile/personal_access_tokens"
+ autoload :SSHKeys, "qa/page/profile/ssh_keys"
end
module Issuable
- autoload :Sidebar, 'qa/page/issuable/sidebar'
+ autoload :Sidebar, "qa/page/issuable/sidebar"
end
module Alert
- autoload :AutoDevopsAlert, 'qa/page/alert/auto_devops_alert'
+ autoload :AutoDevopsAlert, "qa/page/alert/auto_devops_alert"
end
module Layout
- autoload :Banner, 'qa/page/layout/banner'
+ autoload :Banner, "qa/page/layout/banner"
end
module Label
- autoload :New, 'qa/page/label/new'
- autoload :Index, 'qa/page/label/index'
+ autoload :New, "qa/page/label/new"
+ autoload :Index, "qa/page/label/index"
end
module MergeRequest
- autoload :New, 'qa/page/merge_request/new'
- autoload :Show, 'qa/page/merge_request/show'
+ autoload :New, "qa/page/merge_request/new"
+ autoload :Show, "qa/page/merge_request/show"
end
module Admin
- autoload :Menu, 'qa/page/admin/menu'
+ autoload :Menu, "qa/page/admin/menu"
module Settings
- autoload :Repository, 'qa/page/admin/settings/repository'
- autoload :General, 'qa/page/admin/settings/general'
+ autoload :Repository, "qa/page/admin/settings/repository"
+ autoload :General, "qa/page/admin/settings/general"
module Component
- autoload :RepositoryStorage, 'qa/page/admin/settings/component/repository_storage'
- autoload :AccountAndLimit, 'qa/page/admin/settings/component/account_and_limit'
+ autoload :RepositoryStorage, "qa/page/admin/settings/component/repository_storage"
+ autoload :AccountAndLimit, "qa/page/admin/settings/component/account_and_limit"
end
end
end
module Mattermost
- autoload :Main, 'qa/page/mattermost/main'
- autoload :Login, 'qa/page/mattermost/login'
+ autoload :Main, "qa/page/mattermost/main"
+ autoload :Login, "qa/page/mattermost/login"
end
##
# Classes describing components that are used by several pages.
#
module Component
- autoload :ClonePanel, 'qa/page/component/clone_panel'
- autoload :LazyLoader, 'qa/page/component/lazy_loader'
- autoload :LegacyClonePanel, 'qa/page/component/legacy_clone_panel'
- autoload :Dropzone, 'qa/page/component/dropzone'
- autoload :GroupsFilter, 'qa/page/component/groups_filter'
- autoload :Select2, 'qa/page/component/select2'
- autoload :DropdownFilter, 'qa/page/component/dropdown_filter'
- autoload :UsersSelect, 'qa/page/component/users_select'
- autoload :Note, 'qa/page/component/note'
+ autoload :ClonePanel, "qa/page/component/clone_panel"
+ autoload :LazyLoader, "qa/page/component/lazy_loader"
+ autoload :LegacyClonePanel, "qa/page/component/legacy_clone_panel"
+ autoload :Dropzone, "qa/page/component/dropzone"
+ autoload :GroupsFilter, "qa/page/component/groups_filter"
+ autoload :Select2, "qa/page/component/select2"
+ autoload :DropdownFilter, "qa/page/component/dropdown_filter"
+ autoload :UsersSelect, "qa/page/component/users_select"
+ autoload :Note, "qa/page/component/note"
module Issuable
- autoload :Common, 'qa/page/component/issuable/common'
+ autoload :Common, "qa/page/component/issuable/common"
end
end
end
@@ -321,8 +321,8 @@ module QA
# Classes describing operations on Git repositories.
#
module Git
- autoload :Repository, 'qa/git/repository'
- autoload :Location, 'qa/git/location'
+ autoload :Repository, "qa/git/repository"
+ autoload :Location, "qa/git/location"
end
##
@@ -330,18 +330,18 @@ module QA
# with these services, like through the shell.
#
module Service
- autoload :Shellout, 'qa/service/shellout'
- autoload :KubernetesCluster, 'qa/service/kubernetes_cluster'
- autoload :Omnibus, 'qa/service/omnibus'
- autoload :Runner, 'qa/service/runner'
+ autoload :Shellout, "qa/service/shellout"
+ autoload :KubernetesCluster, "qa/service/kubernetes_cluster"
+ autoload :Omnibus, "qa/service/omnibus"
+ autoload :Runner, "qa/service/runner"
end
##
# Classes that make it possible to execute features tests.
#
module Specs
- autoload :Config, 'qa/specs/config'
- autoload :Runner, 'qa/specs/runner'
+ autoload :Config, "qa/specs/config"
+ autoload :Runner, "qa/specs/runner"
end
##
@@ -350,15 +350,15 @@ module QA
module Vendor
module SAMLIdp
module Page
- autoload :Base, 'qa/vendor/saml_idp/page/base'
- autoload :Login, 'qa/vendor/saml_idp/page/login'
+ autoload :Base, "qa/vendor/saml_idp/page/base"
+ autoload :Login, "qa/vendor/saml_idp/page/login"
end
end
module Github
module Page
- autoload :Base, 'qa/vendor/github/page/base'
- autoload :Login, 'qa/vendor/github/page/login'
+ autoload :Base, "qa/vendor/github/page/base"
+ autoload :Login, "qa/vendor/github/page/login"
end
end
end
@@ -367,11 +367,11 @@ module QA
#
module Support
module Page
- autoload :Logging, 'qa/support/page/logging'
+ autoload :Logging, "qa/support/page/logging"
end
- autoload :Api, 'qa/support/api'
- autoload :Waiter, 'qa/support/waiter'
- autoload :Retrier, 'qa/support/retrier'
+ autoload :Api, "qa/support/api"
+ autoload :Waiter, "qa/support/waiter"
+ autoload :Retrier, "qa/support/retrier"
end
end
diff --git a/qa/qa/fixtures/auto_devops_rack/Gemfile b/qa/qa/fixtures/auto_devops_rack/Gemfile
index fc7514242d0..4dc1482dfd2 100644
--- a/qa/qa/fixtures/auto_devops_rack/Gemfile
+++ b/qa/qa/fixtures/auto_devops_rack/Gemfile
@@ -1,3 +1,3 @@
-source 'https://rubygems.org'
-gem 'rack'
-gem 'rake'
+source "https://rubygems.org"
+gem "rack"
+gem "rake"
diff --git a/qa/qa/fixtures/auto_devops_rack/Rakefile b/qa/qa/fixtures/auto_devops_rack/Rakefile
index c865c9aaac1..20b1195c252 100644
--- a/qa/qa/fixtures/auto_devops_rack/Rakefile
+++ b/qa/qa/fixtures/auto_devops_rack/Rakefile
@@ -1,4 +1,4 @@
-require 'rake/testtask'
+require "rake/testtask"
task default: %w[test]
diff --git a/qa/qa/fixtures/auto_devops_rack/config.ru b/qa/qa/fixtures/auto_devops_rack/config.ru
index e990662145a..ea4aebd050f 100644
--- a/qa/qa/fixtures/auto_devops_rack/config.ru
+++ b/qa/qa/fixtures/auto_devops_rack/config.ru
@@ -1 +1 @@
-run lambda { |env| [200, { 'Content-Type' => 'text/plain' }, StringIO.new("Hello World! #{ENV['OPTIONAL_MESSAGE']}\n")] }
+run lambda { |env| [200, {"Content-Type" => "text/plain"}, StringIO.new("Hello World! #{ENV["OPTIONAL_MESSAGE"]}\n")] }
diff --git a/qa/qa/git/location.rb b/qa/qa/git/location.rb
index b74f38f3ae3..b2b7d80f123 100644
--- a/qa/qa/git/location.rb
+++ b/qa/qa/git/location.rb
@@ -1,5 +1,5 @@
-require 'uri'
-require 'forwardable'
+require "uri"
+require "forwardable"
module QA
module Git
@@ -14,12 +14,12 @@ module QA
def initialize(git_uri)
@git_uri = git_uri
@uri =
- if git_uri =~ %r{\A(?:ssh|http|https)://}
+ if %r{\A(?:ssh|http|https)://}.match?(git_uri)
URI.parse(git_uri)
else
- *rest, path = git_uri.split(':')
+ *rest, path = git_uri.split(":")
# Host cannot have : so we'll need to escape it
- user_host = rest.join('%3A').sub(/\A\[(.+)\]\z/, '\1')
+ user_host = rest.join("%3A").sub(/\A\[(.+)\]\z/, '\1')
URI.parse("ssh://#{user_host}/#{path}")
end
end
diff --git a/qa/qa/git/repository.rb b/qa/qa/git/repository.rb
index 0aa94101098..907506ff0e8 100644
--- a/qa/qa/git/repository.rb
+++ b/qa/qa/git/repository.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'cgi'
-require 'uri'
-require 'open3'
-require 'fileutils'
-require 'tmpdir'
-require 'tempfile'
-require 'securerandom'
+require "cgi"
+require "uri"
+require "open3"
+require "fileutils"
+require "tmpdir"
+require "tempfile"
+require "securerandom"
module QA
module Git
@@ -22,7 +22,7 @@ module QA
# We set HOME to the current working directory (which is a
# temporary directory created in .perform()) so the temporarily dropped
# .netrc can be utilised
- self.env_vars = [%Q{HOME="#{tmp_home_dir}"}]
+ self.env_vars = [%(HOME="#{tmp_home_dir}")]
@use_lfs = false
end
@@ -55,7 +55,7 @@ module QA
self.username, self.password = default_credentials
end
- def clone(opts = '')
+ def clone(opts = "")
clone_result = run("git clone #{opts} #{uri} ./")
return clone_result.response unless clone_result.success
@@ -65,17 +65,17 @@ module QA
end
def checkout(branch_name, new_branch: false)
- opts = new_branch ? '-b' : ''
- run(%Q{git checkout #{opts} "#{branch_name}"}).to_s
+ opts = new_branch ? "-b" : ""
+ run(%(git checkout #{opts} "#{branch_name}")).to_s
end
def shallow_clone
- clone('--depth 1')
+ clone("--depth 1")
end
def configure_identity(name, email)
- run(%Q{git config user.name #{name}})
- run(%Q{git config user.email #{email}})
+ run(%(git config user.name #{name}))
+ run(%(git config user.email #{email}))
end
def commit_file(name, contents, message)
@@ -87,20 +87,20 @@ module QA
::File.write(name, contents)
if use_lfs?
- git_lfs_track_result = run(%Q{git lfs track #{name} --lockable})
+ git_lfs_track_result = run(%(git lfs track #{name} --lockable))
return git_lfs_track_result.response unless git_lfs_track_result.success
end
- git_add_result = run(%Q{git add #{name}})
+ git_add_result = run(%(git add #{name}))
git_lfs_track_result.to_s + git_add_result.to_s
end
def commit(message)
- run(%Q{git commit -m "#{message}"}).to_s
+ run(%(git commit -m "#{message}")).to_s
end
- def push_changes(branch = 'master')
+ def push_changes(branch = "master")
run("git push #{uri} #{branch}").to_s
end
@@ -109,22 +109,22 @@ module QA
end
def commits
- run('git log --oneline').to_s.split("\n")
+ run("git log --oneline").to_s.split("\n")
end
def use_ssh_key(key)
@private_key_file = Tempfile.new("id_#{SecureRandom.hex(8)}")
File.binwrite(private_key_file, key.private_key)
- File.chmod(0700, private_key_file)
+ File.chmod(0o700, private_key_file)
@known_hosts_file = Tempfile.new("known_hosts_#{SecureRandom.hex(8)}")
- keyscan_params = ['-H']
+ keyscan_params = ["-H"]
keyscan_params << "-p #{uri.port}" if uri.port
keyscan_params << uri.host
- res = run("ssh-keyscan #{keyscan_params.join(' ')} >> #{known_hosts_file.path}")
+ res = run("ssh-keyscan #{keyscan_params.join(" ")} >> #{known_hosts_file.path}")
return res.response unless res.success?
- self.env_vars << %Q{GIT_SSH_COMMAND="ssh -i #{private_key_file.path} -o UserKnownHostsFile=#{known_hosts_file.path}"}
+ env_vars << %(GIT_SSH_COMMAND="ssh -i #{private_key_file.path} -o UserKnownHostsFile=#{known_hosts_file.path}")
end
def delete_ssh_key
@@ -134,7 +134,7 @@ module QA
known_hosts_file.close(true)
end
- def push_with_git_protocol(version, file_name, file_content, commit_message = 'Initial commit')
+ def push_with_git_protocol(version, file_name, file_content, commit_message = "Initial commit")
self.git_protocol = version
add_file(file_name, file_content)
commit(commit_message)
@@ -153,7 +153,7 @@ module QA
# ls-remote is one command known to respond to Git protocol v2 so we use
# it to get output including the version reported via Git tracing
output = run("git ls-remote #{uri}", "GIT_TRACE_PACKET=1")
- output[/git< version (\d+)/, 1] || 'unknown'
+ output[/git< version (\d+)/, 1] || "unknown"
end
def try_add_credentials_to_netrc
@@ -168,12 +168,12 @@ module QA
attr_reader :uri, :username, :password, :known_hosts_file,
:private_key_file, :use_lfs
- alias_method :use_lfs?, :use_lfs
+ alias use_lfs? use_lfs
- Result = Struct.new(:success, :response) do
+ Result = Struct.new(:success, :response) {
alias_method :success?, :success
alias_method :to_s, :response
- end
+ }
def add_credentials?
return false if !username || !password
@@ -192,13 +192,13 @@ module QA
touch_gitconfig_result = run("touch #{tmp_home_dir}/.gitconfig")
return touch_gitconfig_result.response unless touch_gitconfig_result.success?
- git_lfs_install_result = run('git lfs install')
+ git_lfs_install_result = run("git lfs install")
touch_gitconfig_result.to_s + git_lfs_install_result.to_s
end
def run(command_str, *extra_env)
- command = [env_vars, *extra_env, command_str, '2>&1'].compact.join(' ')
+ command = [env_vars, *extra_env, command_str, "2>&1"].compact.join(" ")
Runtime::Logger.debug "Git: pwd=[#{Dir.pwd}], command=[#{command}]"
output, status = Open3.capture2e(command)
@@ -229,8 +229,8 @@ module QA
# a temporary directory created in .perform()
#
FileUtils.mkdir_p(tmp_home_dir)
- File.open(netrc_file_path, 'a') { |file| file.puts(netrc_content) }
- File.chmod(0600, netrc_file_path)
+ File.open(netrc_file_path, "a") { |file| file.puts(netrc_content) }
+ File.chmod(0o600, netrc_file_path)
end
def tmp_home_dir
@@ -238,7 +238,7 @@ module QA
end
def netrc_file_path
- @netrc_file_path ||= File.join(tmp_home_dir, '.netrc')
+ @netrc_file_path ||= File.join(tmp_home_dir, ".netrc")
end
def netrc_content
diff --git a/qa/qa/page/admin/menu.rb b/qa/qa/page/admin/menu.rb
index 25564f2dc6e..bfceb84b6fa 100644
--- a/qa/qa/page/admin/menu.rb
+++ b/qa/qa/page/admin/menu.rb
@@ -4,7 +4,7 @@ module QA
module Page
module Admin
class Menu < Page::Base
- view 'app/views/layouts/nav/sidebar/_admin.html.haml' do
+ view "app/views/layouts/nav/sidebar/_admin.html.haml" do
element :admin_sidebar
element :admin_sidebar_submenu
element :admin_settings_item
diff --git a/qa/qa/page/admin/settings/component/account_and_limit.rb b/qa/qa/page/admin/settings/component/account_and_limit.rb
index a61c8cc77cd..a8d5e118e3f 100644
--- a/qa/qa/page/admin/settings/component/account_and_limit.rb
+++ b/qa/qa/page/admin/settings/component/account_and_limit.rb
@@ -6,7 +6,7 @@ module QA
module Settings
module Component
class AccountAndLimit < Page::Base
- view 'app/views/admin/application_settings/_account_and_limit.html.haml' do
+ view "app/views/admin/application_settings/_account_and_limit.html.haml" do
element :receive_max_input_size_field
element :save_changes_button
end
diff --git a/qa/qa/page/admin/settings/component/repository_storage.rb b/qa/qa/page/admin/settings/component/repository_storage.rb
index 2ed0cd73aa3..47264c7aa53 100644
--- a/qa/qa/page/admin/settings/component/repository_storage.rb
+++ b/qa/qa/page/admin/settings/component/repository_storage.rb
@@ -6,7 +6,7 @@ module QA
module Settings
module Component
class RepositoryStorage < Page::Base
- view 'app/views/admin/application_settings/_repository_storage.html.haml' do
+ view "app/views/admin/application_settings/_repository_storage.html.haml" do
element :hashed_storage_checkbox
element :save_changes_button
end
diff --git a/qa/qa/page/admin/settings/general.rb b/qa/qa/page/admin/settings/general.rb
index 93b290f7e03..fdf942d5cad 100644
--- a/qa/qa/page/admin/settings/general.rb
+++ b/qa/qa/page/admin/settings/general.rb
@@ -7,7 +7,7 @@ module QA
class General < Page::Base
include QA::Page::Settings::Common
- view 'app/views/admin/application_settings/show.html.haml' do
+ view "app/views/admin/application_settings/show.html.haml" do
element :account_and_limit_settings
end
diff --git a/qa/qa/page/admin/settings/repository.rb b/qa/qa/page/admin/settings/repository.rb
index b7f1deb21bd..c4b5ad09665 100644
--- a/qa/qa/page/admin/settings/repository.rb
+++ b/qa/qa/page/admin/settings/repository.rb
@@ -7,7 +7,7 @@ module QA
class Repository < Page::Base
include QA::Page::Settings::Common
- view 'app/views/admin/application_settings/repository.html.haml' do
+ view "app/views/admin/application_settings/repository.html.haml" do
element :repository_storage_settings
end
diff --git a/qa/qa/page/alert/auto_devops_alert.rb b/qa/qa/page/alert/auto_devops_alert.rb
index 8f66c805b77..dcbc3f4c121 100644
--- a/qa/qa/page/alert/auto_devops_alert.rb
+++ b/qa/qa/page/alert/auto_devops_alert.rb
@@ -4,7 +4,7 @@ module QA
module Page
module Alert
class AutoDevopsAlert < Page::Base
- view 'app/views/shared/_auto_devops_implicitly_enabled_banner.html.haml' do
+ view "app/views/shared/_auto_devops_implicitly_enabled_banner.html.haml" do
element :auto_devops_banner
end
end
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb
index 11ebd70292e..0646f24d03b 100644
--- a/qa/qa/page/base.rb
+++ b/qa/qa/page/base.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'capybara/dsl'
+require "capybara/dsl"
module QA
module Page
@@ -71,10 +71,10 @@ module QA
JS
return false unless wait(interval: 0.5, max: 60, reload: false) do
- page.evaluate_script('xhr.readyState == XMLHttpRequest.DONE')
+ page.evaluate_script("xhr.readyState == XMLHttpRequest.DONE")
end
- page.evaluate_script('xhr.status') == 200
+ page.evaluate_script("xhr.status") == 200
end
def find_element(name, text: nil, wait: Capybara.default_max_wait_time)
@@ -126,7 +126,7 @@ module QA
end
def finished_loading?
- has_no_css?('.fa-spinner', wait: Capybara.default_max_wait_time)
+ has_no_css?(".fa-spinner", wait: Capybara.default_max_wait_time)
end
def within_element(name)
@@ -154,7 +154,7 @@ module QA
end
def click_body
- find('body').click
+ find("body").click
end
def self.path
diff --git a/qa/qa/page/component/clone_panel.rb b/qa/qa/page/component/clone_panel.rb
index b80877f5ecd..1aa45638154 100644
--- a/qa/qa/page/component/clone_panel.rb
+++ b/qa/qa/page/component/clone_panel.rb
@@ -5,7 +5,7 @@ module QA
module Component
module ClonePanel
def self.included(base)
- base.view 'app/views/projects/buttons/_clone.html.haml' do
+ base.view "app/views/projects/buttons/_clone.html.haml" do
element :clone_dropdown
element :clone_options
element :ssh_clone_url
diff --git a/qa/qa/page/component/dropdown_filter.rb b/qa/qa/page/component/dropdown_filter.rb
index e896c382779..27d0c053500 100644
--- a/qa/qa/page/component/dropdown_filter.rb
+++ b/qa/qa/page/component/dropdown_filter.rb
@@ -6,10 +6,10 @@ module QA
module DropdownFilter
def filter_and_select(item)
wait(reload: false) do
- page.has_css?('.dropdown-input-field')
+ page.has_css?(".dropdown-input-field")
end
- find('.dropdown-input-field').set(item)
+ find(".dropdown-input-field").set(item)
click_link item
end
end
diff --git a/qa/qa/page/component/dropzone.rb b/qa/qa/page/component/dropzone.rb
index fd44c57123a..58182d735ba 100644
--- a/qa/qa/page/component/dropzone.rb
+++ b/qa/qa/page/component/dropzone.rb
@@ -17,8 +17,8 @@ module QA
def attach_file(attachment)
filename = ::File.basename(attachment)
- field_style = { visibility: 'visible', height: '', width: '' }
- page.attach_file(attachment, class: 'dz-hidden-input', make_visible: field_style)
+ field_style = {visibility: "visible", height: "", width: ""}
+ page.attach_file(attachment, class: "dz-hidden-input", make_visible: field_style)
# Wait for link to be appended to dropzone text
page.wait(reload: false) do
diff --git a/qa/qa/page/component/groups_filter.rb b/qa/qa/page/component/groups_filter.rb
index cc50bb439b4..0ea8b48e47f 100644
--- a/qa/qa/page/component/groups_filter.rb
+++ b/qa/qa/page/component/groups_filter.rb
@@ -5,11 +5,11 @@ module QA
module Component
module GroupsFilter
def self.included(base)
- base.view 'app/views/shared/groups/_search_form.html.haml' do
+ base.view "app/views/shared/groups/_search_form.html.haml" do
element :groups_filter
end
- base.view 'app/assets/javascripts/groups/components/groups.vue' do
+ base.view "app/assets/javascripts/groups/components/groups.vue" do
element :groups_list_tree_container
end
end
@@ -28,7 +28,7 @@ module QA
end
# If there are no groups we'll know immediately because we filtered the list
- return false if page.has_text?('No groups or projects matched your search', wait: 0)
+ return false if page.has_text?("No groups or projects matched your search", wait: 0)
# The name will be present as filter input so we check for a link, not text
page.has_link?(name, wait: 0)
diff --git a/qa/qa/page/component/issuable/common.rb b/qa/qa/page/component/issuable/common.rb
index cfd8ac1e7c8..48a5b89a2d5 100644
--- a/qa/qa/page/component/issuable/common.rb
+++ b/qa/qa/page/component/issuable/common.rb
@@ -6,24 +6,24 @@ module QA
module Issuable
module Common
def self.included(base)
- base.view 'app/assets/javascripts/issue_show/components/title.vue' do
+ base.view "app/assets/javascripts/issue_show/components/title.vue" do
element :edit_button
end
- base.view 'app/assets/javascripts/issue_show/components/fields/title.vue' do
+ base.view "app/assets/javascripts/issue_show/components/fields/title.vue" do
element :title_input
end
- base.view 'app/assets/javascripts/issue_show/components/fields/description.vue' do
+ base.view "app/assets/javascripts/issue_show/components/fields/description.vue" do
element :description_textarea
end
- base.view 'app/assets/javascripts/issue_show/components/edit_actions.vue' do
+ base.view "app/assets/javascripts/issue_show/components/edit_actions.vue" do
element :save_button
element :delete_button
end
- base.view 'app/assets/javascripts/issue_show/components/edit_actions.vue' do
+ base.view "app/assets/javascripts/issue_show/components/edit_actions.vue" do
element :save_button
element :delete_button
end
diff --git a/qa/qa/page/component/lazy_loader.rb b/qa/qa/page/component/lazy_loader.rb
index 6f74a4691ba..5555195ee25 100644
--- a/qa/qa/page/component/lazy_loader.rb
+++ b/qa/qa/page/component/lazy_loader.rb
@@ -5,7 +5,7 @@ module QA
module Component
module LazyLoader
def self.included(base)
- base.view 'app/assets/javascripts/lazy_loader.js' do
+ base.view "app/assets/javascripts/lazy_loader.js" do
element :js_lazy_loaded
end
end
diff --git a/qa/qa/page/component/legacy_clone_panel.rb b/qa/qa/page/component/legacy_clone_panel.rb
index e495cf4ef04..50f207fdddc 100644
--- a/qa/qa/page/component/legacy_clone_panel.rb
+++ b/qa/qa/page/component/legacy_clone_panel.rb
@@ -5,26 +5,26 @@ module QA
module Component
module LegacyClonePanel
def self.included(base)
- base.view 'app/views/shared/_clone_panel.html.haml' do
+ base.view "app/views/shared/_clone_panel.html.haml" do
element :clone_dropdown
- element :clone_options_dropdown, '.clone-options-dropdown' # rubocop:disable QA/ElementWithPattern
- element :project_repository_location, 'text_field_tag :project_clone' # rubocop:disable QA/ElementWithPattern
+ element :clone_options_dropdown, ".clone-options-dropdown" # rubocop:disable QA/ElementWithPattern
+ element :project_repository_location, "text_field_tag :project_clone" # rubocop:disable QA/ElementWithPattern
end
end
def choose_repository_clone_http
- choose_repository_clone('HTTP', 'http')
+ choose_repository_clone("HTTP", "http")
end
def choose_repository_clone_ssh
# It's not always beginning with ssh:// so detecting with @
# would be more reliable because ssh would always contain it.
# We can't use .git because HTTP also contain that part.
- choose_repository_clone('SSH', '@')
+ choose_repository_clone("SSH", "@")
end
def repository_location
- Git::Location.new(find('#project_clone').value)
+ Git::Location.new(find("#project_clone").value)
end
private
@@ -33,7 +33,7 @@ module QA
wait(reload: false) do
click_element :clone_dropdown
- page.within('.clone-options-dropdown') do
+ page.within(".clone-options-dropdown") do
click_link(kind)
end
diff --git a/qa/qa/page/component/note.rb b/qa/qa/page/component/note.rb
index f5add6bc9b5..224b9cd00aa 100644
--- a/qa/qa/page/component/note.rb
+++ b/qa/qa/page/component/note.rb
@@ -5,21 +5,21 @@ module QA
module Component
module Note
def self.included(base)
- base.view 'app/assets/javascripts/notes/components/comment_form.vue' do
+ base.view "app/assets/javascripts/notes/components/comment_form.vue" do
element :note_dropdown
element :discussion_option
end
- base.view 'app/assets/javascripts/notes/components/note_form.vue' do
+ base.view "app/assets/javascripts/notes/components/note_form.vue" do
element :reply_input
element :reply_comment_button
end
- base.view 'app/assets/javascripts/notes/components/noteable_discussion.vue' do
+ base.view "app/assets/javascripts/notes/components/noteable_discussion.vue" do
element :discussion_reply
end
- base.view 'app/assets/javascripts/notes/components/toggle_replies_widget.vue' do
+ base.view "app/assets/javascripts/notes/components/toggle_replies_widget.vue" do
element :expand_replies
element :collapse_replies
end
diff --git a/qa/qa/page/component/select2.rb b/qa/qa/page/component/select2.rb
index 98bcb96b92c..46c59999b9a 100644
--- a/qa/qa/page/component/select2.rb
+++ b/qa/qa/page/component/select2.rb
@@ -3,17 +3,17 @@ module QA
module Component
module Select2
def select_item(item_text)
- find('.select2-result-label', text: item_text).click
+ find(".select2-result-label", text: item_text).click
end
def clear_current_selection_if_present
- if has_css?('a > abbr.select2-search-choice-close', wait: 1.0)
- find('a > abbr.select2-search-choice-close').click
+ if has_css?("a > abbr.select2-search-choice-close", wait: 1.0)
+ find("a > abbr.select2-search-choice-close").click
end
end
def search_and_select(item_text)
- find('.select2-input').set(item_text)
+ find(".select2-input").set(item_text)
select_item(item_text)
end
end
diff --git a/qa/qa/page/component/users_select.rb b/qa/qa/page/component/users_select.rb
index f88d6450a33..e51943f24b4 100644
--- a/qa/qa/page/component/users_select.rb
+++ b/qa/qa/page/component/users_select.rb
@@ -6,7 +6,7 @@ module QA
module UsersSelect
def select_user(element, username)
find("#{element_selector_css(element)} input").set(username)
- find('.ajax-users-dropdown .user-username', text: "@#{username}").click
+ find(".ajax-users-dropdown .user-username", text: "@#{username}").click
end
end
end
diff --git a/qa/qa/page/dashboard/groups.rb b/qa/qa/page/dashboard/groups.rb
index 7a07515de62..3292fa96851 100644
--- a/qa/qa/page/dashboard/groups.rb
+++ b/qa/qa/page/dashboard/groups.rb
@@ -6,12 +6,12 @@ module QA
class Groups < Page::Base
include Page::Component::GroupsFilter
- view 'app/views/shared/groups/_search_form.html.haml' do
- element :groups_filter, 'search_field_tag :filter' # rubocop:disable QA/ElementWithPattern
- element :groups_filter_placeholder, 'Search by name' # rubocop:disable QA/ElementWithPattern
+ view "app/views/shared/groups/_search_form.html.haml" do
+ element :groups_filter, "search_field_tag :filter" # rubocop:disable QA/ElementWithPattern
+ element :groups_filter_placeholder, "Search by name" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/dashboard/_groups_head.html.haml' do
+ view "app/views/dashboard/_groups_head.html.haml" do
element :new_group_button, 'link_to _("New group")' # rubocop:disable QA/ElementWithPattern
end
@@ -24,7 +24,7 @@ module QA
end
def go_to_new_group
- click_on 'New group'
+ click_on "New group"
end
end
end
diff --git a/qa/qa/page/dashboard/projects.rb b/qa/qa/page/dashboard/projects.rb
index 0f434577b3b..9ccc65a7662 100644
--- a/qa/qa/page/dashboard/projects.rb
+++ b/qa/qa/page/dashboard/projects.rb
@@ -2,9 +2,9 @@ module QA
module Page
module Dashboard
class Projects < Page::Base
- view 'app/views/dashboard/projects/index.html.haml'
+ view "app/views/dashboard/projects/index.html.haml"
- view 'app/views/shared/projects/_search_form.html.haml' do
+ view "app/views/shared/projects/_search_form.html.haml" do
element :form_filter_by_name, /form_tag.+id: 'project-filter-form'/ # rubocop:disable QA/ElementWithPattern
end
@@ -17,7 +17,7 @@ module QA
private
def filter_by_name(name)
- page.within('form#project-filter-form') do
+ page.within("form#project-filter-form") do
fill_in :name, with: name
end
end
diff --git a/qa/qa/page/element.rb b/qa/qa/page/element.rb
index 9944a39ce07..fdeb1c0d656 100644
--- a/qa/qa/page/element.rb
+++ b/qa/qa/page/element.rb
@@ -9,7 +9,7 @@ module QA
end
def selector
- "qa-#{@name.to_s.tr('_', '-')}"
+ "qa-#{@name.to_s.tr("_", "-")}"
end
def selector_css
diff --git a/qa/qa/page/file/form.rb b/qa/qa/page/file/form.rb
index a1534231691..e6cc8402b17 100644
--- a/qa/qa/page/file/form.rb
+++ b/qa/qa/page/file/form.rb
@@ -5,16 +5,16 @@ module QA
include Shared::CommitMessage
include Page::Component::DropdownFilter
- view 'app/views/projects/blob/_editor.html.haml' do
+ view "app/views/projects/blob/_editor.html.haml" do
element :file_name, "text_field_tag 'file_name'" # rubocop:disable QA/ElementWithPattern
- element :editor, '#editor' # rubocop:disable QA/ElementWithPattern
+ element :editor, "#editor" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/_commit_button.html.haml' do
+ view "app/views/projects/_commit_button.html.haml" do
element :commit_changes, "button_tag 'Commit changes'" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/blob/_template_selectors.html.haml' do
+ view "app/views/projects/blob/_template_selectors.html.haml" do
element :template_type_dropdown
element :gitignore_dropdown
element :gitlab_ci_yml_dropdown
@@ -23,7 +23,7 @@ module QA
end
def add_name(name)
- fill_in 'file_name', with: name
+ fill_in "file_name", with: name
end
def add_content(content)
@@ -31,11 +31,11 @@ module QA
end
def remove_content
- text_area.send_keys([:command, 'a'], :backspace)
+ text_area.send_keys([:command, "a"], :backspace)
end
def commit_changes
- click_on 'Commit changes'
+ click_on "Commit changes"
end
def select_template(template_type, template)
@@ -43,16 +43,16 @@ module QA
click_link template_type
case template_type
- when '.gitignore'
+ when ".gitignore"
click_element :gitignore_dropdown
- when '.gitlab-ci.yml'
+ when ".gitlab-ci.yml"
click_element :gitlab_ci_yml_dropdown
- when 'Dockerfile'
+ when "Dockerfile"
click_element :dockerfile_dropdown
- when 'LICENSE'
+ when "LICENSE"
click_element :license_dropdown
else
- raise %Q(Unsupported template_type "#{template_type}". Please confirm that it is a valid option.)
+ raise %(Unsupported template_type "#{template_type}". Please confirm that it is a valid option.)
end
filter_and_select template
end
@@ -60,7 +60,7 @@ module QA
private
def text_area
- find('#editor>textarea', visible: false)
+ find("#editor>textarea", visible: false)
end
end
end
diff --git a/qa/qa/page/file/shared/commit_message.rb b/qa/qa/page/file/shared/commit_message.rb
index aa1bb081cd3..7d8cc757427 100644
--- a/qa/qa/page/file/shared/commit_message.rb
+++ b/qa/qa/page/file/shared/commit_message.rb
@@ -4,13 +4,13 @@ module QA
module Shared
module CommitMessage
def self.included(base)
- base.view 'app/views/shared/_commit_message_container.html.haml' do
+ base.view "app/views/shared/_commit_message_container.html.haml" do
element :commit_message, "text_area_tag 'commit_message'" # rubocop:disable QA/ElementWithPattern
end
end
def add_commit_message(message)
- fill_in 'commit_message', with: message
+ fill_in "commit_message", with: message
end
end
end
diff --git a/qa/qa/page/file/show.rb b/qa/qa/page/file/show.rb
index abd8ebb089f..b4ba02a4426 100644
--- a/qa/qa/page/file/show.rb
+++ b/qa/qa/page/file/show.rb
@@ -4,25 +4,25 @@ module QA
class Show < Page::Base
include Shared::CommitMessage
- view 'app/helpers/blob_helper.rb' do
+ view "app/helpers/blob_helper.rb" do
element :edit_button, "_('Edit')" # rubocop:disable QA/ElementWithPattern
element :delete_button, /label:\s+"Delete"/ # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/blob/_remove.html.haml' do
+ view "app/views/projects/blob/_remove.html.haml" do
element :delete_file_button, "button_tag 'Delete file'" # rubocop:disable QA/ElementWithPattern
end
def click_edit
- click_on 'Edit'
+ click_on "Edit"
end
def click_delete
- click_on 'Delete'
+ click_on "Delete"
end
def click_delete_file
- click_on 'Delete file'
+ click_on "Delete file"
end
end
end
diff --git a/qa/qa/page/group/new.rb b/qa/qa/page/group/new.rb
index 39584daf334..a8db21d785d 100644
--- a/qa/qa/page/group/new.rb
+++ b/qa/qa/page/group/new.rb
@@ -2,24 +2,24 @@ module QA
module Page
module Group
class New < Page::Base
- view 'app/views/shared/_group_form.html.haml' do
- element :group_path_field, 'text_field :path' # rubocop:disable QA/ElementWithPattern
- element :group_name_field, 'text_field :name' # rubocop:disable QA/ElementWithPattern
- element :group_description_field, 'text_area :description' # rubocop:disable QA/ElementWithPattern
+ view "app/views/shared/_group_form.html.haml" do
+ element :group_path_field, "text_field :path" # rubocop:disable QA/ElementWithPattern
+ element :group_name_field, "text_field :name" # rubocop:disable QA/ElementWithPattern
+ element :group_description_field, "text_area :description" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/groups/new.html.haml' do
+ view "app/views/groups/new.html.haml" do
element :create_group_button, "submit 'Create group'" # rubocop:disable QA/ElementWithPattern
- element :visibility_radios, 'visibility_level:' # rubocop:disable QA/ElementWithPattern
+ element :visibility_radios, "visibility_level:" # rubocop:disable QA/ElementWithPattern
end
def set_path(path)
- fill_in 'group_path', with: path
- fill_in 'group_name', with: path
+ fill_in "group_path", with: path
+ fill_in "group_name", with: path
end
def set_description(description)
- fill_in 'group_description', with: description
+ fill_in "group_description", with: description
end
def set_visibility(visibility)
@@ -27,7 +27,7 @@ module QA
end
def create
- click_button 'Create group'
+ click_button "Create group"
end
end
end
diff --git a/qa/qa/page/group/show.rb b/qa/qa/page/group/show.rb
index 41716326685..287967771a6 100644
--- a/qa/qa/page/group/show.rb
+++ b/qa/qa/page/group/show.rb
@@ -6,7 +6,7 @@ module QA
class Show < Page::Base
include Page::Component::GroupsFilter
- view 'app/views/groups/_home_panel.html.haml' do
+ view "app/views/groups/_home_panel.html.haml" do
element :new_project_or_subgroup_dropdown
element :new_project_or_subgroup_dropdown_toggle
element :new_project_option
@@ -14,8 +14,8 @@ module QA
element :new_in_group_button
end
- view 'app/assets/javascripts/groups/constants.js' do
- element :no_result_text, 'No groups or projects matched your search' # rubocop:disable QA/ElementWithPattern
+ view "app/assets/javascripts/groups/constants.js" do
+ element :no_result_text, "No groups or projects matched your search" # rubocop:disable QA/ElementWithPattern
end
def go_to_subgroup(name)
diff --git a/qa/qa/page/issuable/sidebar.rb b/qa/qa/page/issuable/sidebar.rb
index d3751b712c9..3d1fdf61c47 100644
--- a/qa/qa/page/issuable/sidebar.rb
+++ b/qa/qa/page/issuable/sidebar.rb
@@ -2,19 +2,19 @@ module QA
module Page
module Issuable
class Sidebar < Page::Base
- view 'app/views/shared/issuable/_sidebar.html.haml' do
+ view "app/views/shared/issuable/_sidebar.html.haml" do
element :labels_block, ".issuable-show-labels" # rubocop:disable QA/ElementWithPattern
- element :milestones_block, '.block.milestone' # rubocop:disable QA/ElementWithPattern
+ element :milestones_block, ".block.milestone" # rubocop:disable QA/ElementWithPattern
end
def has_label?(label)
- page.within('.issuable-show-labels') do
- !!find('span', text: label)
+ page.within(".issuable-show-labels") do
+ !!find("span", text: label)
end
end
def has_milestone?(milestone)
- page.within('.block.milestone') do
+ page.within(".block.milestone") do
!!find("[href*='/milestones/']", text: milestone)
end
end
diff --git a/qa/qa/page/label/index.rb b/qa/qa/page/label/index.rb
index de0cfa9f293..8bf9692f6fc 100644
--- a/qa/qa/page/label/index.rb
+++ b/qa/qa/page/label/index.rb
@@ -6,15 +6,15 @@ module QA
class Index < Page::Base
include Component::LazyLoader
- view 'app/views/shared/labels/_nav.html.haml' do
+ view "app/views/shared/labels/_nav.html.haml" do
element :label_create_new
end
- view 'app/views/shared/empty_states/_labels.html.haml' do
+ view "app/views/shared/empty_states/_labels.html.haml" do
element :label_svg
end
- view 'app/views/shared/empty_states/_priority_labels.html.haml' do
+ view "app/views/shared/empty_states/_priority_labels.html.haml" do
element :label_svg
end
diff --git a/qa/qa/page/label/new.rb b/qa/qa/page/label/new.rb
index b5422dc9400..00aa01e7f9a 100644
--- a/qa/qa/page/label/new.rb
+++ b/qa/qa/page/label/new.rb
@@ -2,7 +2,7 @@ module QA
module Page
module Label
class New < Page::Base
- view 'app/views/shared/labels/_form.html.haml' do
+ view "app/views/shared/labels/_form.html.haml" do
element :label_title
element :label_description
element :label_color
diff --git a/qa/qa/page/layout/banner.rb b/qa/qa/page/layout/banner.rb
index 2223f2adec8..acd8bd6799c 100644
--- a/qa/qa/page/layout/banner.rb
+++ b/qa/qa/page/layout/banner.rb
@@ -2,13 +2,13 @@ module QA
module Page
module Layout
class Banner < Page::Base
- view 'app/views/layouts/header/_read_only_banner.html.haml' do
+ view "app/views/layouts/header/_read_only_banner.html.haml" do
element :flash_notice, ".flash-notice" # rubocop:disable QA/ElementWithPattern
end
def has_notice?(message)
- page.within('.flash-notice') do
- !!find('span', text: message)
+ page.within(".flash-notice") do
+ !!find("span", text: message)
end
end
end
diff --git a/qa/qa/page/main/login.rb b/qa/qa/page/main/login.rb
index e03fe9ab83a..2d1056fe461 100644
--- a/qa/qa/page/main/login.rb
+++ b/qa/qa/page/main/login.rb
@@ -2,41 +2,41 @@ module QA
module Page
module Main
class Login < Page::Base
- view 'app/views/devise/passwords/edit.html.haml' do
+ view "app/views/devise/passwords/edit.html.haml" do
element :password_field
element :password_confirmation
element :change_password_button
end
- view 'app/views/devise/sessions/_new_base.html.haml' do
+ view "app/views/devise/sessions/_new_base.html.haml" do
element :login_field
element :password_field
element :sign_in_button
end
- view 'app/views/devise/sessions/_new_ldap.html.haml' do
+ view "app/views/devise/sessions/_new_ldap.html.haml" do
element :username_field
element :password_field
element :sign_in_button
end
- view 'app/views/devise/shared/_tabs_ldap.html.haml' do
+ view "app/views/devise/shared/_tabs_ldap.html.haml" do
element :ldap_tab
element :standard_tab
element :register_tab
end
- view 'app/views/devise/shared/_tabs_normal.html.haml' do
+ view "app/views/devise/shared/_tabs_normal.html.haml" do
element :sign_in_tab
element :register_tab
end
- view 'app/helpers/auth_helper.rb' do
+ view "app/helpers/auth_helper.rb" do
element :saml_login_button
element :github_login_button
end
- view 'app/views/layouts/devise.html.haml' do
+ view "app/views/layouts/devise.html.haml" do
element :login_page
end
@@ -87,7 +87,7 @@ module QA
end
def self.path
- '/users/sign_in'
+ "/users/sign_in"
end
def has_sign_in_tab?
@@ -103,15 +103,15 @@ module QA
end
def sign_in_tab?
- has_css?(".active", text: 'Sign in')
+ has_css?(".active", text: "Sign in")
end
def ldap_tab?
- has_css?(".active", text: 'LDAP')
+ has_css?(".active", text: "LDAP")
end
def standard_tab?
- has_css?(".active", text: 'Standard')
+ has_css?(".active", text: "Standard")
end
def switch_to_sign_in_tab
@@ -161,7 +161,7 @@ module QA
end
def set_initial_password_if_present
- return unless has_content?('Change your password')
+ return unless has_content?("Change your password")
fill_element :password_field, Runtime::User.password
fill_element :password_confirmation, Runtime::User.password
diff --git a/qa/qa/page/main/menu.rb b/qa/qa/page/main/menu.rb
index 55500e831c6..b14bc729daf 100644
--- a/qa/qa/page/main/menu.rb
+++ b/qa/qa/page/main/menu.rb
@@ -4,24 +4,24 @@ module QA
module Page
module Main
class Menu < Page::Base
- view 'app/views/layouts/header/_current_user_dropdown.html.haml' do
+ view "app/views/layouts/header/_current_user_dropdown.html.haml" do
element :user_sign_out_link, 'link_to _("Sign out")' # rubocop:disable QA/ElementWithPattern
element :settings_link, 'link_to s_("CurrentUser|Settings")' # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/layouts/header/_default.html.haml' do
+ view "app/views/layouts/header/_default.html.haml" do
element :navbar
element :user_avatar
- element :user_menu, '.dropdown-menu' # rubocop:disable QA/ElementWithPattern
+ element :user_menu, ".dropdown-menu" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/layouts/nav/_dashboard.html.haml' do
+ view "app/views/layouts/nav/_dashboard.html.haml" do
element :admin_area_link
element :projects_dropdown
element :groups_dropdown
end
- view 'app/views/layouts/nav/projects_dropdown/_show.html.haml' do
+ view "app/views/layouts/nav/projects_dropdown/_show.html.haml" do
element :projects_dropdown_sidebar
element :your_projects_link
end
@@ -31,7 +31,7 @@ module QA
click_element :groups_dropdown
end
- page.within('.qa-groups-dropdown-sidebar') do
+ page.within(".qa-groups-dropdown-sidebar") do
click_element :your_groups_link
end
end
@@ -41,7 +41,7 @@ module QA
click_element :projects_dropdown
end
- page.within('.qa-projects-dropdown-sidebar') do
+ page.within(".qa-projects-dropdown-sidebar") do
click_element :your_projects_link
end
end
@@ -52,17 +52,17 @@ module QA
def sign_out
within_user_menu do
- click_link 'Sign out'
+ click_link "Sign out"
end
end
def go_to_profile_settings
retry_until(reload: false) do
within_user_menu do
- click_link 'Settings'
+ click_link "Settings"
end
- has_text?('User Settings')
+ has_text?("User Settings")
end
end
@@ -77,7 +77,7 @@ module QA
private
def within_top_menu
- page.within('.qa-navbar') do
+ page.within(".qa-navbar") do
yield
end
end
@@ -86,7 +86,7 @@ module QA
within_top_menu do
click_element :user_avatar
- page.within('.dropdown-menu') do
+ page.within(".dropdown-menu") do
yield
end
end
diff --git a/qa/qa/page/main/oauth.rb b/qa/qa/page/main/oauth.rb
index bc44d274314..62858ca0aaa 100644
--- a/qa/qa/page/main/oauth.rb
+++ b/qa/qa/page/main/oauth.rb
@@ -2,16 +2,16 @@ module QA
module Page
module Main
class OAuth < Page::Base
- view 'app/views/doorkeeper/authorizations/new.html.haml' do
+ view "app/views/doorkeeper/authorizations/new.html.haml" do
element :authorization_button, 'submit_tag _("Authorize")' # rubocop:disable QA/ElementWithPattern
end
def needs_authorization?
- page.current_url.include?('/oauth')
+ page.current_url.include?("/oauth")
end
def authorize!
- click_button 'Authorize'
+ click_button "Authorize"
end
end
end
diff --git a/qa/qa/page/main/sign_up.rb b/qa/qa/page/main/sign_up.rb
index 46a105003d0..8fe9c956bb7 100644
--- a/qa/qa/page/main/sign_up.rb
+++ b/qa/qa/page/main/sign_up.rb
@@ -4,7 +4,7 @@ module QA
module Page
module Main
class SignUp < Page::Base
- view 'app/views/devise/shared/_signup_box.html.haml' do
+ view "app/views/devise/shared/_signup_box.html.haml" do
element :new_user_name
element :new_user_username
element :new_user_email
@@ -23,11 +23,11 @@ module QA
check_element :new_user_accept_terms if has_element?(:new_user_accept_terms)
- signed_in = retry_until do
+ signed_in = retry_until {
click_element :new_user_register_button
Page::Main::Menu.act { has_personal_area? }
- end
+ }
raise "Failed to register and sign in" unless signed_in
end
diff --git a/qa/qa/page/mattermost/login.rb b/qa/qa/page/mattermost/login.rb
index 9b21300ea3c..902e5f7ab9f 100644
--- a/qa/qa/page/mattermost/login.rb
+++ b/qa/qa/page/mattermost/login.rb
@@ -7,18 +7,18 @@ module QA
#
# See gitlab-org/gitlab-qa#154
#
- view 'app/views/projects/mattermosts/new.html.haml'
+ view "app/views/projects/mattermosts/new.html.haml"
def sign_in_using_oauth
- click_link class: 'btn btn-custom-login gitlab'
+ click_link class: "btn btn-custom-login gitlab"
- if page.has_content?('Authorize GitLab Mattermost to use your account?')
- click_button 'Authorize'
+ if page.has_content?("Authorize GitLab Mattermost to use your account?")
+ click_button "Authorize"
end
end
def self.path
- '/login'
+ "/login"
end
end
end
diff --git a/qa/qa/page/mattermost/main.rb b/qa/qa/page/mattermost/main.rb
index bc2f9acc729..309d1dabe72 100644
--- a/qa/qa/page/mattermost/main.rb
+++ b/qa/qa/page/mattermost/main.rb
@@ -7,7 +7,7 @@ module QA
#
# See gitlab-org/gitlab-qa#154
#
- view 'app/views/projects/mattermosts/new.html.haml'
+ view "app/views/projects/mattermosts/new.html.haml"
def initialize
visit(Runtime::Scenario.mattermost_address)
diff --git a/qa/qa/page/merge_request/new.rb b/qa/qa/page/merge_request/new.rb
index 20d9c336367..3fe20ac88d6 100644
--- a/qa/qa/page/merge_request/new.rb
+++ b/qa/qa/page/merge_request/new.rb
@@ -2,31 +2,31 @@ module QA
module Page
module MergeRequest
class New < Page::Base
- view 'app/views/shared/issuable/_form.html.haml' do
+ view "app/views/shared/issuable/_form.html.haml" do
element :issuable_create_button
end
- view 'app/views/shared/issuable/form/_title.html.haml' do
+ view "app/views/shared/issuable/form/_title.html.haml" do
element :issuable_form_title
end
- view 'app/views/shared/issuable/form/_metadata.html.haml' do
+ view "app/views/shared/issuable/form/_metadata.html.haml" do
element :issuable_milestone_dropdown
end
- view 'app/views/shared/form_elements/_description.html.haml' do
+ view "app/views/shared/form_elements/_description.html.haml" do
element :issuable_form_description
end
- view 'app/views/shared/issuable/_milestone_dropdown.html.haml' do
+ view "app/views/shared/issuable/_milestone_dropdown.html.haml" do
element :issuable_dropdown_menu_milestone
end
- view 'app/views/shared/issuable/_label_dropdown.html.haml' do
+ view "app/views/shared/issuable/_label_dropdown.html.haml" do
element :issuable_label
end
- view 'app/views/shared/issuable/form/_metadata_merge_request_assignee.html.haml' do
+ view "app/views/shared/issuable/form/_metadata_merge_request_assignee.html.haml" do
element :assign_to_me_link
end
diff --git a/qa/qa/page/merge_request/show.rb b/qa/qa/page/merge_request/show.rb
index 976e431186d..f716b71cdde 100644
--- a/qa/qa/page/merge_request/show.rb
+++ b/qa/qa/page/merge_request/show.rb
@@ -6,51 +6,51 @@ module QA
class Show < Page::Base
include Page::Component::Note
- view 'app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue' do
+ view "app/assets/javascripts/vue_merge_request_widget/components/states/ready_to_merge.vue" do
element :merge_button
- element :fast_forward_message, 'Fast-forward merge without a merge commit' # rubocop:disable QA/ElementWithPattern
+ element :fast_forward_message, "Fast-forward merge without a merge commit" # rubocop:disable QA/ElementWithPattern
element :merge_moment_dropdown
element :merge_when_pipeline_succeeds_option
element :merge_immediately_option
end
- view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.vue' do
- element :merged_status, 'The changes were merged into' # rubocop:disable QA/ElementWithPattern
+ view "app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_merged.vue" do
+ element :merged_status, "The changes were merged into" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue' do
+ view "app/assets/javascripts/vue_merge_request_widget/components/states/mr_widget_rebase.vue" do
element :mr_rebase_button
- element :no_fast_forward_message, 'Fast-forward merge is not possible' # rubocop:disable QA/ElementWithPattern
+ element :no_fast_forward_message, "Fast-forward merge is not possible" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/vue_merge_request_widget/components/states/squash_before_merge.vue' do
+ view "app/assets/javascripts/vue_merge_request_widget/components/states/squash_before_merge.vue" do
element :squash_checkbox
end
- view 'app/views/projects/merge_requests/show.html.haml' do
+ view "app/views/projects/merge_requests/show.html.haml" do
element :notes_tab
element :diffs_tab
end
- view 'app/assets/javascripts/diffs/components/diff_line_gutter_content.vue' do
+ view "app/assets/javascripts/diffs/components/diff_line_gutter_content.vue" do
element :diff_comment
end
- view 'app/assets/javascripts/diffs/components/inline_diff_table_row.vue' do
+ view "app/assets/javascripts/diffs/components/inline_diff_table_row.vue" do
element :new_diff_line
end
- view 'app/views/shared/issuable/_sidebar.html.haml' do
+ view "app/views/shared/issuable/_sidebar.html.haml" do
element :assignee_block
element :labels_block
end
- view 'app/views/projects/merge_requests/_mr_title.html.haml' do
+ view "app/views/projects/merge_requests/_mr_title.html.haml" do
element :edit_button
end
def fast_forward_possible?
- has_no_text?('Fast-forward merge is not possible')
+ has_no_text?("Fast-forward merge is not possible")
end
def has_merge_button?
@@ -85,9 +85,9 @@ module QA
click_element :mr_rebase_button
- success = wait do
- has_text?('Fast-forward merge without a merge commit')
- end
+ success = wait {
+ has_text?("Fast-forward merge without a merge commit")
+ }
raise "Rebase did not appear to be successful" unless success
end
@@ -100,7 +100,7 @@ module QA
def has_label?(label)
page.within(element_selector_css(:labels_block)) do
- element = find('span', text: label)
+ element = find("span", text: label)
!element.nil?
end
end
@@ -118,9 +118,9 @@ module QA
merge_immediately
- success = wait do
- has_text?('The changes were merged into')
- end
+ success = wait {
+ has_text?("The changes were merged into")
+ }
raise "Merge did not appear to be successful" unless success
end
diff --git a/qa/qa/page/profile/menu.rb b/qa/qa/page/profile/menu.rb
index 2d503499e13..d01fcb8165a 100644
--- a/qa/qa/page/profile/menu.rb
+++ b/qa/qa/page/profile/menu.rb
@@ -4,29 +4,29 @@ module QA
module Page
module Profile
class Menu < Page::Base
- view 'app/views/layouts/nav/sidebar/_profile.html.haml' do
- element :access_token_link, 'link_to profile_personal_access_tokens_path' # rubocop:disable QA/ElementWithPattern
- element :access_token_title, 'Access Tokens' # rubocop:disable QA/ElementWithPattern
- element :top_level_items, '.sidebar-top-level-items' # rubocop:disable QA/ElementWithPattern
- element :ssh_keys, 'SSH Keys' # rubocop:disable QA/ElementWithPattern
+ view "app/views/layouts/nav/sidebar/_profile.html.haml" do
+ element :access_token_link, "link_to profile_personal_access_tokens_path" # rubocop:disable QA/ElementWithPattern
+ element :access_token_title, "Access Tokens" # rubocop:disable QA/ElementWithPattern
+ element :top_level_items, ".sidebar-top-level-items" # rubocop:disable QA/ElementWithPattern
+ element :ssh_keys, "SSH Keys" # rubocop:disable QA/ElementWithPattern
end
def click_access_tokens
within_sidebar do
- click_link('Access Tokens')
+ click_link("Access Tokens")
end
end
def click_ssh_keys
within_sidebar do
- click_link('SSH Keys')
+ click_link("SSH Keys")
end
end
private
def within_sidebar
- page.within('.sidebar-top-level-items') do
+ page.within(".sidebar-top-level-items") do
yield
end
end
diff --git a/qa/qa/page/profile/personal_access_tokens.rb b/qa/qa/page/profile/personal_access_tokens.rb
index 8c12eff5cf1..c89c06a0548 100644
--- a/qa/qa/page/profile/personal_access_tokens.rb
+++ b/qa/qa/page/profile/personal_access_tokens.rb
@@ -2,19 +2,19 @@ module QA
module Page
module Profile
class PersonalAccessTokens < Page::Base
- view 'app/views/shared/_personal_access_tokens_form.html.haml' do
+ view "app/views/shared/_personal_access_tokens_form.html.haml" do
element :personal_access_token_name_field
element :create_token_button
end
- view 'app/views/shared/tokens/_scopes_form.html.haml' do
+ view "app/views/shared/tokens/_scopes_form.html.haml" do
element :api_radio, 'qa-#{scope}-radio' # rubocop:disable QA/ElementWithPattern, Lint/InterpolationCheck
end
- view 'app/views/shared/_personal_access_tokens_created_container.html.haml' do
+ view "app/views/shared/_personal_access_tokens_created_container.html.haml" do
element :created_personal_access_token
end
- view 'app/views/shared/_personal_access_tokens_table.html.haml' do
+ view "app/views/shared/_personal_access_tokens_table.html.haml" do
element :revoke_button
end
@@ -35,11 +35,11 @@ module QA
end
def has_token_row_for_name?(token_name)
- page.has_css?('tr', text: token_name, wait: 1.0)
+ page.has_css?("tr", text: token_name, wait: 1.0)
end
def first_token_row_for_name(token_name)
- page.find('tr', text: token_name, match: :first, wait: 1.0)
+ page.find("tr", text: token_name, match: :first, wait: 1.0)
end
def revoke_first_token_with_name(token_name)
diff --git a/qa/qa/page/profile/ssh_keys.rb b/qa/qa/page/profile/ssh_keys.rb
index ce1813b14d0..02234a073ec 100644
--- a/qa/qa/page/profile/ssh_keys.rb
+++ b/qa/qa/page/profile/ssh_keys.rb
@@ -4,13 +4,13 @@ module QA
module Page
module Profile
class SSHKeys < Page::Base
- view 'app/views/profiles/keys/_form.html.haml' do
+ view "app/views/profiles/keys/_form.html.haml" do
element :key_title_field
element :key_public_key_field
element :add_key_button
end
- view 'app/views/profiles/keys/_key_details.html.haml' do
+ view "app/views/profiles/keys/_key_details.html.haml" do
element :delete_key_button
end
diff --git a/qa/qa/page/project/activity.rb b/qa/qa/page/project/activity.rb
index 56fbaa90790..e1c9a5b673d 100644
--- a/qa/qa/page/project/activity.rb
+++ b/qa/qa/page/project/activity.rb
@@ -2,12 +2,12 @@ module QA
module Page
module Project
class Activity < Page::Base
- view 'app/views/shared/_event_filter.html.haml' do
+ view "app/views/shared/_event_filter.html.haml" do
element :push_events, "event_filter_link EventFilter::PUSH, _('Push events')" # rubocop:disable QA/ElementWithPattern
end
def go_to_push_events
- click_on 'Push events'
+ click_on "Push events"
end
end
end
diff --git a/qa/qa/page/project/branches/show.rb b/qa/qa/page/project/branches/show.rb
index 922a6ddb086..333da0f3879 100644
--- a/qa/qa/page/project/branches/show.rb
+++ b/qa/qa/page/project/branches/show.rb
@@ -5,13 +5,13 @@ module QA
module Project
module Branches
class Show < Page::Base
- view 'app/views/projects/branches/_branch.html.haml' do
+ view "app/views/projects/branches/_branch.html.haml" do
element :remove_btn
end
- view 'app/views/projects/branches/_panel.html.haml' do
+ view "app/views/projects/branches/_panel.html.haml" do
element :all_branches
end
- view 'app/views/projects/branches/index.html.haml' do
+ view "app/views/projects/branches/index.html.haml" do
element :delete_merged_branches
end
@@ -50,11 +50,11 @@ module QA
end
def wait_for_texts_not_to_be_visible(texts)
- text_not_visible = wait do
+ text_not_visible = wait {
texts.all? do |text|
has_no_text?(text)
end
- end
+ }
raise "Expected text(s) #{texts} not to be visible" unless text_not_visible
end
end
diff --git a/qa/qa/page/project/commit/show.rb b/qa/qa/page/project/commit/show.rb
index 9770b8a657c..2224c8b252e 100644
--- a/qa/qa/page/project/commit/show.rb
+++ b/qa/qa/page/project/commit/show.rb
@@ -5,7 +5,7 @@ module QA
module Project
module Commit
class Show < Page::Base
- view 'app/views/projects/commit/_commit_box.html.haml' do
+ view "app/views/projects/commit/_commit_box.html.haml" do
element :options_button
element :email_patches
element :plain_diff
diff --git a/qa/qa/page/project/fork/new.rb b/qa/qa/page/project/fork/new.rb
index 140c004b458..5186cf6a270 100644
--- a/qa/qa/page/project/fork/new.rb
+++ b/qa/qa/page/project/fork/new.rb
@@ -3,8 +3,8 @@ module QA
module Project
module Fork
class New < Page::Base
- view 'app/views/projects/forks/_fork_button.html.haml' do
- element :namespace, 'link_to project_forks_path' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/forks/_fork_button.html.haml" do
+ element :namespace, "link_to project_forks_path" # rubocop:disable QA/ElementWithPattern
end
def choose_namespace(namespace = Runtime::Namespace.path)
diff --git a/qa/qa/page/project/import/github.rb b/qa/qa/page/project/import/github.rb
index 45c8d834a74..eedabfb0192 100644
--- a/qa/qa/page/project/import/github.rb
+++ b/qa/qa/page/project/import/github.rb
@@ -5,12 +5,12 @@ module QA
class Github < Page::Base
include Page::Component::Select2
- view 'app/views/import/github/new.html.haml' do
- element :personal_access_token_field, 'text_field_tag :personal_access_token' # rubocop:disable QA/ElementWithPattern
+ view "app/views/import/github/new.html.haml" do
+ element :personal_access_token_field, "text_field_tag :personal_access_token" # rubocop:disable QA/ElementWithPattern
element :list_repos_button, "submit_tag _('List your GitHub repositories')" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/import_projects/components/provider_repo_table_row.vue' do
+ view "app/assets/javascripts/import_projects/components/provider_repo_table_row.vue" do
element :project_import_row
element :project_namespace_select
element :project_path_field
@@ -18,11 +18,11 @@ module QA
end
def add_personal_access_token(personal_access_token)
- fill_in 'personal_access_token', with: personal_access_token
+ fill_in "personal_access_token", with: personal_access_token
end
def list_repos
- click_button 'List your GitHub repositories'
+ click_button "List your GitHub repositories"
end
def import!(full_path, name)
@@ -68,7 +68,7 @@ module QA
def wait_for_success
wait(max: 60, interval: 1.0, reload: false) do
- page.has_content?('Done', wait: 1.0)
+ page.has_content?("Done", wait: 1.0)
end
end
end
diff --git a/qa/qa/page/project/issue/index.rb b/qa/qa/page/project/issue/index.rb
index 1035bf74a43..d7f915349e0 100644
--- a/qa/qa/page/project/issue/index.rb
+++ b/qa/qa/page/project/issue/index.rb
@@ -3,8 +3,8 @@ module QA
module Project
module Issue
class Index < Page::Base
- view 'app/views/projects/issues/_issue.html.haml' do
- element :issue_link, 'link_to issue.title' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/issues/_issue.html.haml" do
+ element :issue_link, "link_to issue.title" # rubocop:disable QA/ElementWithPattern
end
def go_to_issue(title)
diff --git a/qa/qa/page/project/issue/new.rb b/qa/qa/page/project/issue/new.rb
index 03b605ab24b..d88893dc7fe 100644
--- a/qa/qa/page/project/issue/new.rb
+++ b/qa/qa/page/project/issue/new.rb
@@ -3,28 +3,28 @@ module QA
module Project
module Issue
class New < Page::Base
- view 'app/views/shared/issuable/_form.html.haml' do
+ view "app/views/shared/issuable/_form.html.haml" do
element :submit_issue_button, 'form.submit "Submit' # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/shared/issuable/form/_title.html.haml' do
- element :issue_title_textbox, 'form.text_field :title' # rubocop:disable QA/ElementWithPattern
+ view "app/views/shared/issuable/form/_title.html.haml" do
+ element :issue_title_textbox, "form.text_field :title" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/shared/form_elements/_description.html.haml' do
+ view "app/views/shared/form_elements/_description.html.haml" do
element :issue_description_textarea, "render 'projects/zen', f: form, attr: :description" # rubocop:disable QA/ElementWithPattern
end
def add_title(title)
- fill_in 'issue_title', with: title
+ fill_in "issue_title", with: title
end
def add_description(description)
- fill_in 'issue_description', with: description
+ fill_in "issue_description", with: description
end
def create_new_issue
- click_on 'Submit issue'
+ click_on "Submit issue"
end
end
end
diff --git a/qa/qa/page/project/issue/show.rb b/qa/qa/page/project/issue/show.rb
index 9df3db1bba0..6edd2f57c81 100644
--- a/qa/qa/page/project/issue/show.rb
+++ b/qa/qa/page/project/issue/show.rb
@@ -8,22 +8,22 @@ module QA
include Page::Component::Issuable::Common
include Page::Component::Note
- view 'app/views/shared/notes/_form.html.haml' do
- element :new_note_form, 'new-note' # rubocop:disable QA/ElementWithPattern
- element :new_note_form, 'attr: :note' # rubocop:disable QA/ElementWithPattern
+ view "app/views/shared/notes/_form.html.haml" do
+ element :new_note_form, "new-note" # rubocop:disable QA/ElementWithPattern
+ element :new_note_form, "attr: :note" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/notes/components/comment_form.vue' do
+ view "app/assets/javascripts/notes/components/comment_form.vue" do
element :comment_button
element :comment_input
end
- view 'app/assets/javascripts/notes/components/discussion_filter.vue' do
+ view "app/assets/javascripts/notes/components/discussion_filter.vue" do
element :discussion_filter
element :filter_options
end
- view 'app/assets/javascripts/notes/components/noteable_note.vue' do
+ view "app/assets/javascripts/notes/components/noteable_note.vue" do
element :noteable_note_item
end
@@ -33,7 +33,7 @@ module QA
fill_element :comment_input, text
unless attachment.nil?
- QA::Page::Component::Dropzone.new(self, '.new-note')
+ QA::Page::Component::Dropzone.new(self, ".new-note")
.attach_file(attachment)
end
@@ -47,15 +47,15 @@ module QA
end
def select_comments_only_filter
- select_filter_with_text('Show comments only')
+ select_filter_with_text("Show comments only")
end
def select_history_only_filter
- select_filter_with_text('Show history only')
+ select_filter_with_text("Show history only")
end
def select_all_activities_filter
- select_filter_with_text('Show all activity')
+ select_filter_with_text("Show all activity")
end
private
diff --git a/qa/qa/page/project/job/show.rb b/qa/qa/page/project/job/show.rb
index 9c218f4ed8b..29decc028e4 100644
--- a/qa/qa/page/project/job/show.rb
+++ b/qa/qa/page/project/job/show.rb
@@ -2,17 +2,17 @@ module QA::Page
module Project::Job
class Show < QA::Page::Base
COMPLETED_STATUSES = %w[passed failed canceled blocked skipped manual].freeze # excludes created, pending, running
- PASSED_STATUS = 'passed'.freeze
+ PASSED_STATUS = "passed".freeze
- view 'app/assets/javascripts/jobs/components/job_log.vue' do
+ view "app/assets/javascripts/jobs/components/job_log.vue" do
element :build_trace
end
- view 'app/assets/javascripts/vue_shared/components/ci_badge_link.vue' do
+ view "app/assets/javascripts/vue_shared/components/ci_badge_link.vue" do
element :status_badge
end
- view 'app/assets/javascripts/jobs/components/stages_dropdown.vue' do
+ view "app/assets/javascripts/jobs/components/stages_dropdown.vue" do
element :pipeline_path
end
diff --git a/qa/qa/page/project/menu.rb b/qa/qa/page/project/menu.rb
index 46dfe87fe25..41da83d66b5 100644
--- a/qa/qa/page/project/menu.rb
+++ b/qa/qa/page/project/menu.rb
@@ -12,7 +12,7 @@ module QA
include SubMenus::Repository
include SubMenus::Settings
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :activity_link
element :merge_requests_link
element :wiki_link
diff --git a/qa/qa/page/project/milestone/index.rb b/qa/qa/page/project/milestone/index.rb
index a1519c9ef1c..332696796b4 100644
--- a/qa/qa/page/project/milestone/index.rb
+++ b/qa/qa/page/project/milestone/index.rb
@@ -3,7 +3,7 @@ module QA
module Project
module Milestone
class Index < Page::Base
- view 'app/views/projects/milestones/index.html.haml' do
+ view "app/views/projects/milestones/index.html.haml" do
element :new_project_milestone
end
diff --git a/qa/qa/page/project/milestone/new.rb b/qa/qa/page/project/milestone/new.rb
index 992ef89004b..a0b9c7b8b11 100644
--- a/qa/qa/page/project/milestone/new.rb
+++ b/qa/qa/page/project/milestone/new.rb
@@ -3,7 +3,7 @@ module QA
module Project
module Milestone
class New < Page::Base
- view 'app/views/projects/milestones/_form.html.haml' do
+ view "app/views/projects/milestones/_form.html.haml" do
element :milestone_create_button
element :milestone_title
element :milestone_description
diff --git a/qa/qa/page/project/new.rb b/qa/qa/page/project/new.rb
index 9f1867ef8a5..ebda3b2b044 100644
--- a/qa/qa/page/project/new.rb
+++ b/qa/qa/page/project/new.rb
@@ -4,22 +4,22 @@ module QA
class New < Page::Base
include Page::Component::Select2
- view 'app/views/projects/new.html.haml' do
+ view "app/views/projects/new.html.haml" do
element :project_create_from_template_tab
element :import_project_tab, "Import project" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/_new_project_fields.html.haml' do
+ view "app/views/projects/_new_project_fields.html.haml" do
element :project_namespace_select
- element :project_namespace_field, 'namespaces_options' # rubocop:disable QA/ElementWithPattern
- element :project_name, 'text_field :name' # rubocop:disable QA/ElementWithPattern
- element :project_path, 'text_field :path' # rubocop:disable QA/ElementWithPattern
- element :project_description, 'text_area :description' # rubocop:disable QA/ElementWithPattern
+ element :project_namespace_field, "namespaces_options" # rubocop:disable QA/ElementWithPattern
+ element :project_name, "text_field :name" # rubocop:disable QA/ElementWithPattern
+ element :project_path, "text_field :path" # rubocop:disable QA/ElementWithPattern
+ element :project_description, "text_area :description" # rubocop:disable QA/ElementWithPattern
element :project_create_button, "submit 'Create project'" # rubocop:disable QA/ElementWithPattern
- element :visibility_radios, 'visibility_level:' # rubocop:disable QA/ElementWithPattern
+ element :visibility_radios, "visibility_level:" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/_import_project_pane.html.haml' do
+ view "app/views/projects/_import_project_pane.html.haml" do
element :import_github, "icon('github', text: 'GitHub')" # rubocop:disable QA/ElementWithPattern
end
@@ -30,19 +30,19 @@ module QA
end
def go_to_import_project
- click_on 'Import project'
+ click_on "Import project"
end
def choose_name(name)
- fill_in 'project_name', with: name
+ fill_in "project_name", with: name
end
def add_description(description)
- fill_in 'project_description', with: description
+ fill_in "project_description", with: description
end
def create_new_project
- click_on 'Create project'
+ click_on "Create project"
end
def go_to_create_from_template
@@ -54,7 +54,7 @@ module QA
end
def go_to_github_import
- click_link 'GitHub'
+ click_link "GitHub"
end
end
end
diff --git a/qa/qa/page/project/operations/environments/index.rb b/qa/qa/page/project/operations/environments/index.rb
index 63965a57edd..401d3566779 100644
--- a/qa/qa/page/project/operations/environments/index.rb
+++ b/qa/qa/page/project/operations/environments/index.rb
@@ -6,7 +6,7 @@ module QA
module Operations
module Environments
class Index < Page::Base
- view 'app/assets/javascripts/environments/components/environment_item.vue' do
+ view "app/assets/javascripts/environments/components/environment_item.vue" do
element :environment_link
end
diff --git a/qa/qa/page/project/operations/environments/show.rb b/qa/qa/page/project/operations/environments/show.rb
index aa88c218c89..a5142b3e042 100644
--- a/qa/qa/page/project/operations/environments/show.rb
+++ b/qa/qa/page/project/operations/environments/show.rb
@@ -6,7 +6,7 @@ module QA
module Operations
module Environments
class Show < Page::Base
- view 'app/views/projects/environments/_external_url.html.haml' do
+ view "app/views/projects/environments/_external_url.html.haml" do
element :view_deployment
end
diff --git a/qa/qa/page/project/operations/kubernetes/add.rb b/qa/qa/page/project/operations/kubernetes/add.rb
index 939f912ea85..46df5d2e833 100644
--- a/qa/qa/page/project/operations/kubernetes/add.rb
+++ b/qa/qa/page/project/operations/kubernetes/add.rb
@@ -4,12 +4,12 @@ module QA
module Operations
module Kubernetes
class Add < Page::Base
- view 'app/views/clusters/clusters/new.html.haml' do
+ view "app/views/clusters/clusters/new.html.haml" do
element :add_existing_cluster_button, "Add existing cluster" # rubocop:disable QA/ElementWithPattern
end
def add_existing_cluster
- click_on 'Add existing cluster'
+ click_on "Add existing cluster"
end
end
end
diff --git a/qa/qa/page/project/operations/kubernetes/add_existing.rb b/qa/qa/page/project/operations/kubernetes/add_existing.rb
index ffd5b36e1ae..cfe9538b1f7 100644
--- a/qa/qa/page/project/operations/kubernetes/add_existing.rb
+++ b/qa/qa/page/project/operations/kubernetes/add_existing.rb
@@ -4,33 +4,33 @@ module QA
module Operations
module Kubernetes
class AddExisting < Page::Base
- view 'app/views/clusters/clusters/user/_form.html.haml' do
- element :cluster_name, 'text_field :name' # rubocop:disable QA/ElementWithPattern
- element :api_url, 'text_field :api_url' # rubocop:disable QA/ElementWithPattern
- element :ca_certificate, 'text_area :ca_cert' # rubocop:disable QA/ElementWithPattern
- element :token, 'text_field :token' # rubocop:disable QA/ElementWithPattern
+ view "app/views/clusters/clusters/user/_form.html.haml" do
+ element :cluster_name, "text_field :name" # rubocop:disable QA/ElementWithPattern
+ element :api_url, "text_field :api_url" # rubocop:disable QA/ElementWithPattern
+ element :ca_certificate, "text_area :ca_cert" # rubocop:disable QA/ElementWithPattern
+ element :token, "text_field :token" # rubocop:disable QA/ElementWithPattern
element :add_cluster_button, "submit s_('ClusterIntegration|Add Kubernetes cluster')" # rubocop:disable QA/ElementWithPattern
element :rbac_checkbox
end
def set_cluster_name(name)
- fill_in 'cluster_name', with: name
+ fill_in "cluster_name", with: name
end
def set_api_url(api_url)
- fill_in 'cluster_platform_kubernetes_attributes_api_url', with: api_url
+ fill_in "cluster_platform_kubernetes_attributes_api_url", with: api_url
end
def set_ca_certificate(ca_certificate)
- fill_in 'cluster_platform_kubernetes_attributes_ca_cert', with: ca_certificate
+ fill_in "cluster_platform_kubernetes_attributes_ca_cert", with: ca_certificate
end
def set_token(token)
- fill_in 'cluster_platform_kubernetes_attributes_token', with: token
+ fill_in "cluster_platform_kubernetes_attributes_token", with: token
end
def add_cluster!
- click_on 'Add Kubernetes cluster'
+ click_on "Add Kubernetes cluster"
end
def uncheck_rbac!
diff --git a/qa/qa/page/project/operations/kubernetes/index.rb b/qa/qa/page/project/operations/kubernetes/index.rb
index 67a74af1cd2..be64d96ef92 100644
--- a/qa/qa/page/project/operations/kubernetes/index.rb
+++ b/qa/qa/page/project/operations/kubernetes/index.rb
@@ -4,12 +4,12 @@ module QA
module Operations
module Kubernetes
class Index < Page::Base
- view 'app/views/clusters/clusters/_empty_state.html.haml' do
+ view "app/views/clusters/clusters/_empty_state.html.haml" do
element :add_kubernetes_cluster_button, "link_to s_('ClusterIntegration|Add Kubernetes cluster')" # rubocop:disable QA/ElementWithPattern
end
def add_kubernetes_cluster
- click_on 'Add Kubernetes cluster'
+ click_on "Add Kubernetes cluster"
end
end
end
diff --git a/qa/qa/page/project/operations/kubernetes/show.rb b/qa/qa/page/project/operations/kubernetes/show.rb
index d4e1679b6bf..37129fd61b0 100644
--- a/qa/qa/page/project/operations/kubernetes/show.rb
+++ b/qa/qa/page/project/operations/kubernetes/show.rb
@@ -4,38 +4,38 @@ module QA
module Operations
module Kubernetes
class Show < Page::Base
- view 'app/assets/javascripts/clusters/components/application_row.vue' do
- element :application_row, 'js-cluster-application-row-${this.id}' # rubocop:disable QA/ElementWithPattern
+ view "app/assets/javascripts/clusters/components/application_row.vue" do
+ element :application_row, "js-cluster-application-row-${this.id}" # rubocop:disable QA/ElementWithPattern
element :install_button, "s__('ClusterIntegration|Install')" # rubocop:disable QA/ElementWithPattern
element :installed_button, "s__('ClusterIntegration|Installed')" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/clusters/components/applications.vue' do
+ view "app/assets/javascripts/clusters/components/applications.vue" do
element :ingress_ip_address, 'id="ingress-ip-address"' # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/clusters/clusters/_form.html.haml' do
+ view "app/views/clusters/clusters/_form.html.haml" do
element :base_domain
element :save_domain
end
def install!(application_name)
within(".js-cluster-application-row-#{application_name}") do
- page.has_button?('Install', wait: 30)
- click_on 'Install'
+ page.has_button?("Install", wait: 30)
+ click_on "Install"
end
end
def await_installed(application_name)
within(".js-cluster-application-row-#{application_name}") do
- page.has_text?('Installed', wait: 300)
+ page.has_text?("Installed", wait: 300)
end
end
def ingress_ip
# We need to wait longer since it can take some time before the
# ip address is assigned for the ingress controller
- page.find('#ingress-ip-address', wait: 1200).value
+ page.find("#ingress-ip-address", wait: 1200).value
end
def set_domain(domain)
diff --git a/qa/qa/page/project/pipeline/index.rb b/qa/qa/page/project/pipeline/index.rb
index 19d83ecc4f4..4dbdebc80fc 100644
--- a/qa/qa/page/project/pipeline/index.rb
+++ b/qa/qa/page/project/pipeline/index.rb
@@ -1,16 +1,16 @@
module QA::Page
module Project::Pipeline
class Index < QA::Page::Base
- view 'app/assets/javascripts/pipelines/components/pipeline_url.vue' do
+ view "app/assets/javascripts/pipelines/components/pipeline_url.vue" do
element :pipeline_link, 'class="js-pipeline-url-link"' # rubocop:disable QA/ElementWithPattern
end
def go_to_latest_pipeline
- css = '.js-pipeline-url-link'
+ css = ".js-pipeline-url-link"
- link = wait(reload: false) do
+ link = wait(reload: false) {
first(css)
- end
+ }
link.click
end
diff --git a/qa/qa/page/project/pipeline/show.rb b/qa/qa/page/project/pipeline/show.rb
index 6f8a66bf527..295d48258ce 100644
--- a/qa/qa/page/project/pipeline/show.rb
+++ b/qa/qa/page/project/pipeline/show.rb
@@ -1,44 +1,44 @@
module QA::Page
module Project::Pipeline
class Show < QA::Page::Base
- view 'app/assets/javascripts/vue_shared/components/header_ci_component.vue' do
+ view "app/assets/javascripts/vue_shared/components/header_ci_component.vue" do
element :pipeline_header, /header class.*ci-header-container.*/ # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/pipelines/components/graph/graph_component.vue' do
+ view "app/assets/javascripts/pipelines/components/graph/graph_component.vue" do
element :pipeline_graph, /class.*pipeline-graph.*/ # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/pipelines/components/graph/job_item.vue' do
+ view "app/assets/javascripts/pipelines/components/graph/job_item.vue" do
element :job_component, /class.*ci-job-component.*/ # rubocop:disable QA/ElementWithPattern
element :job_link
end
- view 'app/assets/javascripts/vue_shared/components/ci_icon.vue' do
- element :status_icon, 'ci-status-icon-${status}' # rubocop:disable QA/ElementWithPattern
+ view "app/assets/javascripts/vue_shared/components/ci_icon.vue" do
+ element :status_icon, "ci-status-icon-${status}" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/pipelines/_info.html.haml' do
+ view "app/views/projects/pipelines/_info.html.haml" do
element :pipeline_badges
end
def running?
- within('.ci-header-container') do
- page.has_content?('running')
+ within(".ci-header-container") do
+ page.has_content?("running")
end
end
def has_build?(name, status: :success, wait: nil)
- within('.pipeline-graph') do
- within('.ci-job-component', text: name) do
- has_selector?(".ci-status-icon-#{status}", { wait: wait }.compact)
+ within(".pipeline-graph") do
+ within(".ci-job-component", text: name) do
+ has_selector?(".ci-status-icon-#{status}", {wait: wait}.compact)
end
end
end
def has_tag?(tag_name)
within_element(:pipeline_badges) do
- has_selector?('.badge', text: tag_name)
+ has_selector?(".badge", text: tag_name)
end
end
@@ -47,7 +47,7 @@ module QA::Page
end
def go_to_first_job
- css = '.js-pipeline-graph-job-link'
+ css = ".js-pipeline-graph-job-link"
wait(reload: false) do
has_css?(css)
diff --git a/qa/qa/page/project/settings/advanced.rb b/qa/qa/page/project/settings/advanced.rb
index 578f097e2dc..9e9cde6aa23 100644
--- a/qa/qa/page/project/settings/advanced.rb
+++ b/qa/qa/page/project/settings/advanced.rb
@@ -3,9 +3,9 @@ module QA
module Project
module Settings
class Advanced < Page::Base
- view 'app/views/projects/edit.html.haml' do
- element :project_path_field, 'text_field :path' # rubocop:disable QA/ElementWithPattern
- element :project_name_field, 'text_field :name' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/edit.html.haml" do
+ element :project_path_field, "text_field :path" # rubocop:disable QA/ElementWithPattern
+ element :project_name_field, "text_field :name" # rubocop:disable QA/ElementWithPattern
element :rename_project_button, "submit 'Rename project'" # rubocop:disable QA/ElementWithPattern
end
@@ -24,7 +24,7 @@ module QA
end
def rename_project!
- click_on 'Rename project'
+ click_on "Rename project"
end
end
end
diff --git a/qa/qa/page/project/settings/ci_cd.rb b/qa/qa/page/project/settings/ci_cd.rb
index 2de39b8ebf5..c8f8234ab63 100644
--- a/qa/qa/page/project/settings/ci_cd.rb
+++ b/qa/qa/page/project/settings/ci_cd.rb
@@ -5,14 +5,14 @@ module QA # rubocop:disable Naming/FileName
class CICD < Page::Base
include Common
- view 'app/views/projects/settings/ci_cd/show.html.haml' do
+ view "app/views/projects/settings/ci_cd/show.html.haml" do
element :autodevops_settings
element :runners_settings
element :variables_settings
end
- view 'app/views/projects/settings/ci_cd/_autodevops_form.html.haml' do
- element :enable_auto_devops_field, 'check_box :enabled' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/settings/ci_cd/_autodevops_form.html.haml" do
+ element :enable_auto_devops_field, "check_box :enabled" # rubocop:disable QA/ElementWithPattern
element :enable_auto_devops_button, "%strong= s_('CICD|Default to Auto DevOps pipeline')" # rubocop:disable QA/ElementWithPattern
element :save_changes_button, "submit _('Save changes')" # rubocop:disable QA/ElementWithPattern
end
@@ -31,8 +31,8 @@ module QA # rubocop:disable Naming/FileName
def enable_auto_devops
expand_section(:autodevops_settings) do
- check 'Default to Auto DevOps pipeline'
- click_on 'Save changes'
+ check "Default to Auto DevOps pipeline"
+ click_on "Save changes"
end
end
end
diff --git a/qa/qa/page/project/settings/ci_variables.rb b/qa/qa/page/project/settings/ci_variables.rb
index e7a6e4bf628..f9dda69da46 100644
--- a/qa/qa/page/project/settings/ci_variables.rb
+++ b/qa/qa/page/project/settings/ci_variables.rb
@@ -5,15 +5,15 @@ module QA
class CiVariables < Page::Base
include Common
- view 'app/views/ci/variables/_variable_row.html.haml' do
- element :variable_row, '.ci-variable-row-body' # rubocop:disable QA/ElementWithPattern
- element :variable_key, '.qa-ci-variable-input-key' # rubocop:disable QA/ElementWithPattern
- element :variable_value, '.qa-ci-variable-input-value' # rubocop:disable QA/ElementWithPattern
+ view "app/views/ci/variables/_variable_row.html.haml" do
+ element :variable_row, ".ci-variable-row-body" # rubocop:disable QA/ElementWithPattern
+ element :variable_key, ".qa-ci-variable-input-key" # rubocop:disable QA/ElementWithPattern
+ element :variable_value, ".qa-ci-variable-input-value" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/ci/variables/_index.html.haml' do
- element :save_variables, '.js-ci-variables-save-button' # rubocop:disable QA/ElementWithPattern
- element :reveal_values, '.js-secret-value-reveal-button' # rubocop:disable QA/ElementWithPattern
+ view "app/views/ci/variables/_index.html.haml" do
+ element :save_variables, ".js-ci-variables-save-button" # rubocop:disable QA/ElementWithPattern
+ element :reveal_values, ".js-secret-value-reveal-button" # rubocop:disable QA/ElementWithPattern
end
def fill_variable(key, value)
@@ -33,16 +33,16 @@ module QA
end
def save_variables
- find('.js-ci-variables-save-button').click
+ find(".js-ci-variables-save-button").click
end
def reveal_variables
- find('.js-secret-value-reveal-button').click
+ find(".js-secret-value-reveal-button").click
end
def variable_value(key)
- within('.ci-variable-row-body', text: key) do
- find('.qa-ci-variable-input-value').value
+ within(".ci-variable-row-body", text: key) do
+ find(".qa-ci-variable-input-value").value
end
end
end
diff --git a/qa/qa/page/project/settings/common.rb b/qa/qa/page/project/settings/common.rb
index f3b217677f2..8349ad4e29c 100644
--- a/qa/qa/page/project/settings/common.rb
+++ b/qa/qa/page/project/settings/common.rb
@@ -7,7 +7,7 @@ module QA
def self.included(base)
base.class_eval do
- view 'app/views/projects/edit.html.haml' do
+ view "app/views/projects/edit.html.haml" do
element :advanced_settings_expand, "= expanded ? 'Collapse' : 'Expand'" # rubocop:disable QA/ElementWithPattern
end
end
diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb
index e0f9e84096d..b286b16f1b1 100644
--- a/qa/qa/page/project/settings/deploy_keys.rb
+++ b/qa/qa/page/project/settings/deploy_keys.rb
@@ -3,32 +3,32 @@ module QA
module Project
module Settings
class DeployKeys < Page::Base
- view 'app/views/projects/deploy_keys/_form.html.haml' do
- element :deploy_key_title, 'text_field :title' # rubocop:disable QA/ElementWithPattern
- element :deploy_key_key, 'text_area :key' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/deploy_keys/_form.html.haml" do
+ element :deploy_key_title, "text_field :title" # rubocop:disable QA/ElementWithPattern
+ element :deploy_key_key, "text_area :key" # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/deploy_keys/components/app.vue' do
+ view "app/assets/javascripts/deploy_keys/components/app.vue" do
element :deploy_keys_section, /class=".*deploy\-keys.*"/ # rubocop:disable QA/ElementWithPattern
element :project_deploy_keys, 'class="qa-project-deploy-keys"' # rubocop:disable QA/ElementWithPattern
end
- view 'app/assets/javascripts/deploy_keys/components/key.vue' do
+ view "app/assets/javascripts/deploy_keys/components/key.vue" do
element :key
element :key_title
element :key_fingerprint
end
def add_key
- click_on 'Add key'
+ click_on "Add key"
end
def fill_key_title(title)
- fill_in 'deploy_key_title', with: title
+ fill_in "deploy_key_title", with: title
end
def fill_key_value(key)
- fill_in 'deploy_key_key', with: key
+ fill_in "deploy_key_key", with: key
end
def find_fingerprint(title)
diff --git a/qa/qa/page/project/settings/deploy_tokens.rb b/qa/qa/page/project/settings/deploy_tokens.rb
index 2d42372cbc5..f3934197aad 100644
--- a/qa/qa/page/project/settings/deploy_tokens.rb
+++ b/qa/qa/page/project/settings/deploy_tokens.rb
@@ -3,7 +3,7 @@ module QA
module Project
module Settings
class DeployTokens < Page::Base
- view 'app/views/projects/deploy_tokens/_form.html.haml' do
+ view "app/views/projects/deploy_tokens/_form.html.haml" do
element :deploy_token_name
element :deploy_token_expires_at
element :deploy_token_read_repository
@@ -11,7 +11,7 @@ module QA
element :create_deploy_token
end
- view 'app/views/projects/deploy_tokens/_new_deploy_token.html.haml' do
+ view "app/views/projects/deploy_tokens/_new_deploy_token.html.haml" do
element :created_deploy_token_section
element :deploy_token_user
element :deploy_token
diff --git a/qa/qa/page/project/settings/main.rb b/qa/qa/page/project/settings/main.rb
index d8cf1d49dd2..61cfd39f0be 100644
--- a/qa/qa/page/project/settings/main.rb
+++ b/qa/qa/page/project/settings/main.rb
@@ -5,7 +5,7 @@ module QA
class Main < Page::Base
include Common
- view 'app/views/projects/edit.html.haml' do
+ view "app/views/projects/edit.html.haml" do
element :advanced_settings
end
diff --git a/qa/qa/page/project/settings/members.rb b/qa/qa/page/project/settings/members.rb
index 7fed93ca83f..28ed205a87a 100644
--- a/qa/qa/page/project/settings/members.rb
+++ b/qa/qa/page/project/settings/members.rb
@@ -7,12 +7,12 @@ module QA
class Members < Page::Base
include Page::Component::UsersSelect
- view 'app/views/projects/project_members/_new_project_member.html.haml' do
+ view "app/views/projects/project_members/_new_project_member.html.haml" do
element :member_select_input
element :add_member_button
end
- view 'app/views/projects/project_members/_team.html.haml' do
+ view "app/views/projects/project_members/_team.html.haml" do
element :members_list
end
diff --git a/qa/qa/page/project/settings/merge_request.rb b/qa/qa/page/project/settings/merge_request.rb
index d044d3715a9..9ac8b8b797d 100644
--- a/qa/qa/page/project/settings/merge_request.rb
+++ b/qa/qa/page/project/settings/merge_request.rb
@@ -5,12 +5,12 @@ module QA
class MergeRequest < QA::Page::Base
include Common
- view 'app/views/projects/edit.html.haml' do
+ view "app/views/projects/edit.html.haml" do
element :merge_request_settings
element :save_merge_request_changes
end
- view 'app/views/projects/_merge_request_merge_method_settings.html.haml' do
+ view "app/views/projects/_merge_request_merge_method_settings.html.haml" do
element :radio_button_merge_ff
end
diff --git a/qa/qa/page/project/settings/mirroring_repositories.rb b/qa/qa/page/project/settings/mirroring_repositories.rb
index 831166f6373..3c811a172b6 100644
--- a/qa/qa/page/project/settings/mirroring_repositories.rb
+++ b/qa/qa/page/project/settings/mirroring_repositories.rb
@@ -5,12 +5,12 @@ module QA
module Project
module Settings
class MirroringRepositories < Page::Base
- view 'app/views/projects/mirrors/_authentication_method.html.haml' do
+ view "app/views/projects/mirrors/_authentication_method.html.haml" do
element :authentication_method
element :password
end
- view 'app/views/projects/mirrors/_mirror_repos.html.haml' do
+ view "app/views/projects/mirrors/_mirror_repos.html.haml" do
element :mirror_repository_url_input
element :mirror_repository_button
element :mirror_repository_url
@@ -18,11 +18,11 @@ module QA
element :mirrored_repository_row
end
- view 'app/views/projects/mirrors/_mirror_repos_form.html.haml' do
+ view "app/views/projects/mirrors/_mirror_repos_form.html.haml" do
element :mirror_direction
end
- view 'app/views/shared/_remote_mirror_update_button.html.haml' do
+ view "app/views/shared/_remote_mirror_update_button.html.haml" do
element :update_now_button
end
@@ -65,13 +65,13 @@ module QA
wait(interval: 1) do
within_element_by_index(:mirrored_repository_row, row_index) do
last_update = find_element(:mirror_last_update_at, wait: 0)
- last_update.has_text?('just now') || last_update.has_text?('seconds')
+ last_update.has_text?("just now") || last_update.has_text?("seconds")
end
end
# Fail early if the page still shows that there has been no update
within_element_by_index(:mirrored_repository_row, row_index) do
- find_element(:mirror_last_update_at, wait: 0).assert_no_text('Never')
+ find_element(:mirror_last_update_at, wait: 0).assert_no_text("Never")
end
end
diff --git a/qa/qa/page/project/settings/protected_branches.rb b/qa/qa/page/project/settings/protected_branches.rb
index 76591a4e3fe..6f84e56a197 100644
--- a/qa/qa/page/project/settings/protected_branches.rb
+++ b/qa/qa/page/project/settings/protected_branches.rb
@@ -3,23 +3,23 @@ module QA
module Project
module Settings
class ProtectedBranches < Page::Base
- view 'app/views/projects/protected_branches/shared/_dropdown.html.haml' do
+ view "app/views/projects/protected_branches/shared/_dropdown.html.haml" do
element :protected_branch_select
element :protected_branch_dropdown
end
- view 'app/views/projects/protected_branches/_create_protected_branch.html.haml' do
+ view "app/views/projects/protected_branches/_create_protected_branch.html.haml" do
element :allowed_to_push_select
element :allowed_to_push_dropdown
element :allowed_to_merge_select
element :allowed_to_merge_dropdown
end
- view 'app/views/projects/protected_branches/_update_protected_branch.html.haml' do
+ view "app/views/projects/protected_branches/_update_protected_branch.html.haml" do
element :allowed_to_merge
end
- view 'app/views/projects/protected_branches/shared/_branches_list.html.haml' do
+ view "app/views/projects/protected_branches/shared/_branches_list.html.haml" do
element :protected_branches_list
end
@@ -32,29 +32,29 @@ module QA
end
def allow_no_one_to_push
- click_allow(:push, 'No one')
+ click_allow(:push, "No one")
end
def allow_devs_and_maintainers_to_push
- click_allow(:push, 'Developers + Maintainers')
+ click_allow(:push, "Developers + Maintainers")
end
# @deprecated
- alias_method :allow_devs_and_masters_to_push, :allow_devs_and_maintainers_to_push
+ alias allow_devs_and_masters_to_push allow_devs_and_maintainers_to_push
def allow_no_one_to_merge
- click_allow(:merge, 'No one')
+ click_allow(:merge, "No one")
end
def allow_devs_and_maintainers_to_merge
- click_allow(:merge, 'Developers + Maintainers')
+ click_allow(:merge, "Developers + Maintainers")
end
# @deprecated
- alias_method :allow_devs_and_masters_to_merge, :allow_devs_and_maintainers_to_merge
+ alias allow_devs_and_masters_to_merge allow_devs_and_maintainers_to_merge
def protect_branch
- click_on 'Protect'
+ click_on "Protect"
end
private
diff --git a/qa/qa/page/project/settings/repository.rb b/qa/qa/page/project/settings/repository.rb
index ac0b87aca5e..7598876ed78 100644
--- a/qa/qa/page/project/settings/repository.rb
+++ b/qa/qa/page/project/settings/repository.rb
@@ -5,15 +5,15 @@ module QA
class Repository < Page::Base
include Common
- view 'app/views/projects/deploy_keys/_index.html.haml' do
+ view "app/views/projects/deploy_keys/_index.html.haml" do
element :deploy_keys_settings
end
- view 'app/views/projects/protected_branches/shared/_index.html.haml' do
+ view "app/views/projects/protected_branches/shared/_index.html.haml" do
element :protected_branches_settings
end
- view 'app/views/projects/mirrors/_mirror_repos.html.haml' do
+ view "app/views/projects/mirrors/_mirror_repos.html.haml" do
element :mirroring_repositories_settings
end
diff --git a/qa/qa/page/project/settings/runners.rb b/qa/qa/page/project/settings/runners.rb
index ac930f5385a..81ec1807798 100644
--- a/qa/qa/page/project/settings/runners.rb
+++ b/qa/qa/page/project/settings/runners.rb
@@ -3,30 +3,30 @@ module QA
module Project
module Settings
class Runners < Page::Base
- view 'app/views/ci/runner/_how_to_setup_runner.html.haml' do
- element :registration_token, '%code#registration_token' # rubocop:disable QA/ElementWithPattern
- element :coordinator_address, '%code#coordinator_address' # rubocop:disable QA/ElementWithPattern
+ view "app/views/ci/runner/_how_to_setup_runner.html.haml" do
+ element :registration_token, "%code#registration_token" # rubocop:disable QA/ElementWithPattern
+ element :coordinator_address, "%code#coordinator_address" # rubocop:disable QA/ElementWithPattern
end
##
# TODO, phase-out CSS classes added in Ruby helpers.
#
- view 'app/helpers/runners_helper.rb' do
+ view "app/helpers/runners_helper.rb" do
# rubocop:disable Lint/InterpolationCheck
element :runner_status, 'runner-status-#{status}' # rubocop:disable QA/ElementWithPattern
# rubocop:enable Lint/InterpolationCheck
end
def registration_token
- find('code#registration_token').text
+ find("code#registration_token").text
end
def coordinator_address
- find('code#coordinator_address').text
+ find("code#coordinator_address").text
end
def has_online_runner?
- page.has_css?('.runner-status-online')
+ page.has_css?(".runner-status-online")
end
end
end
diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb
index 9c21d9ddbfa..8f26cc5a50c 100644
--- a/qa/qa/page/project/show.rb
+++ b/qa/qa/page/project/show.rb
@@ -6,52 +6,52 @@ module QA
class Show < Page::Base
include Page::Component::ClonePanel
- view 'app/views/layouts/header/_new_dropdown.haml' do
+ view "app/views/layouts/header/_new_dropdown.haml" do
element :new_menu_toggle
element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/_last_push.html.haml' do
+ view "app/views/projects/_last_push.html.haml" do
element :create_merge_request
end
- view 'app/views/projects/_home_panel.html.haml' do
+ view "app/views/projects/_home_panel.html.haml" do
element :project_name
end
- view 'app/views/projects/_files.html.haml' do
- element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/_files.html.haml" do
+ element :tree_holder, ".tree-holder" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/buttons/_dropdown.html.haml' do
+ view "app/views/projects/buttons/_dropdown.html.haml" do
element :create_new_dropdown
end
- view 'app/views/projects/buttons/_fork.html.haml' do
+ view "app/views/projects/buttons/_fork.html.haml" do
element :fork_label, "%span= s_('ProjectOverview|Fork')" # rubocop:disable QA/ElementWithPattern
element :fork_link, "link_to new_project_fork_path(@project)" # rubocop:disable QA/ElementWithPattern
end
- view 'app/views/projects/empty.html.haml' do
+ view "app/views/projects/empty.html.haml" do
element :quick_actions
end
- view 'app/views/projects/tree/_tree_content.html.haml' do
+ view "app/views/projects/tree/_tree_content.html.haml" do
element :file_tree
end
- view 'app/views/projects/tree/_tree_header.html.haml' do
+ view "app/views/projects/tree/_tree_header.html.haml" do
element :add_to_tree
element :new_file_option
element :web_ide_button
end
- view 'app/views/shared/_ref_switcher.html.haml' do
+ view "app/views/shared/_ref_switcher.html.haml" do
element :branches_select
element :branches_dropdown
end
- view 'app/views/projects/blob/viewers/_loading.html.haml' do
+ view "app/views/projects/blob/viewers/_loading.html.haml" do
element :spinner
end
@@ -63,7 +63,7 @@ module QA
def create_first_new_file!
within_element(:quick_actions) do
- click_link_with_text 'New file'
+ click_link_with_text "New file"
end
end
@@ -73,7 +73,7 @@ module QA
end
def fork_project
- click_on 'Fork'
+ click_on "Fork"
end
def go_to_file(filename)
@@ -90,7 +90,7 @@ module QA
def go_to_new_issue
click_element :new_menu_toggle
- click_link 'New issue'
+ click_link "New issue"
end
def last_commit_content
@@ -110,7 +110,7 @@ module QA
end
def project_name
- find('.qa-project-name').text
+ find(".qa-project-name").text
end
def switch_to_branch(branch_name)
@@ -123,7 +123,7 @@ module QA
def wait_for_import
wait(reload: true) do
- has_css?('.tree-holder')
+ has_css?(".tree-holder")
end
end
end
diff --git a/qa/qa/page/project/sub_menus/ci_cd.rb b/qa/qa/page/project/sub_menus/ci_cd.rb
index adae2ce08c4..3f80c46e15f 100644
--- a/qa/qa/page/project/sub_menus/ci_cd.rb
+++ b/qa/qa/page/project/sub_menus/ci_cd.rb
@@ -7,7 +7,7 @@ module QA
module CiCd
def self.included(base)
base.class_eval do
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :link_pipelines
end
end
diff --git a/qa/qa/page/project/sub_menus/common.rb b/qa/qa/page/project/sub_menus/common.rb
index c94e1e85256..42f5a451411 100644
--- a/qa/qa/page/project/sub_menus/common.rb
+++ b/qa/qa/page/project/sub_menus/common.rb
@@ -6,13 +6,13 @@ module QA
module SubMenus
module Common
def within_sidebar
- within('.sidebar-top-level-items') do
+ within(".sidebar-top-level-items") do
yield
end
end
def within_submenu
- within('.fly-out-list') do
+ within(".fly-out-list") do
yield
end
end
diff --git a/qa/qa/page/project/sub_menus/issues.rb b/qa/qa/page/project/sub_menus/issues.rb
index f81e4f34909..d8d7c4ca785 100644
--- a/qa/qa/page/project/sub_menus/issues.rb
+++ b/qa/qa/page/project/sub_menus/issues.rb
@@ -7,7 +7,7 @@ module QA
module Issues
def self.included(base)
base.class_eval do
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :issues_item
element :labels_link
element :milestones_link
@@ -17,7 +17,7 @@ module QA
def click_issues
within_sidebar do
- click_link('Issues')
+ click_link("Issues")
end
end
diff --git a/qa/qa/page/project/sub_menus/operations.rb b/qa/qa/page/project/sub_menus/operations.rb
index cf9fc453565..00c54b95d9e 100644
--- a/qa/qa/page/project/sub_menus/operations.rb
+++ b/qa/qa/page/project/sub_menus/operations.rb
@@ -7,7 +7,7 @@ module QA
module Operations
def self.included(base)
base.class_eval do
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :link_operations
element :operations_environments_link
end
@@ -25,7 +25,7 @@ module QA
def click_operations_kubernetes
hover_operations do
within_submenu do
- click_link('Kubernetes')
+ click_link("Kubernetes")
end
end
end
diff --git a/qa/qa/page/project/sub_menus/repository.rb b/qa/qa/page/project/sub_menus/repository.rb
index 29eaa9a74de..d4b6e8b7a8b 100644
--- a/qa/qa/page/project/sub_menus/repository.rb
+++ b/qa/qa/page/project/sub_menus/repository.rb
@@ -7,7 +7,7 @@ module QA
module Repository
def self.included(base)
base.class_eval do
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :project_menu_repo
element :branches_link
end
diff --git a/qa/qa/page/project/sub_menus/settings.rb b/qa/qa/page/project/sub_menus/settings.rb
index 62c594c0210..38a3626086f 100644
--- a/qa/qa/page/project/sub_menus/settings.rb
+++ b/qa/qa/page/project/sub_menus/settings.rb
@@ -7,7 +7,7 @@ module QA
module Settings
def self.included(base)
base.class_eval do
- view 'app/views/layouts/nav/sidebar/_project.html.haml' do
+ view "app/views/layouts/nav/sidebar/_project.html.haml" do
element :settings_item
element :link_members_settings
end
@@ -17,7 +17,7 @@ module QA
def click_ci_cd_settings
hover_settings do
within_submenu do
- click_link('CI / CD')
+ click_link("CI / CD")
end
end
end
@@ -33,14 +33,14 @@ module QA
def click_repository_settings
hover_settings do
within_submenu do
- click_link('Repository')
+ click_link("Repository")
end
end
end
def go_to_settings
within_sidebar do
- click_on 'Settings'
+ click_on "Settings"
end
end
diff --git a/qa/qa/page/project/web_ide/edit.rb b/qa/qa/page/project/web_ide/edit.rb
index 2b6c01888d5..076d7cff54e 100644
--- a/qa/qa/page/project/web_ide/edit.rb
+++ b/qa/qa/page/project/web_ide/edit.rb
@@ -7,29 +7,29 @@ module QA
class Edit < Page::Base
include Page::Component::DropdownFilter
- view 'app/assets/javascripts/ide/components/ide_tree.vue' do
+ view "app/assets/javascripts/ide/components/ide_tree.vue" do
element :new_file
end
- view 'app/assets/javascripts/ide/components/ide_tree_list.vue' do
+ view "app/assets/javascripts/ide/components/ide_tree_list.vue" do
element :file_list
end
- view 'app/assets/javascripts/ide/components/new_dropdown/modal.vue' do
+ view "app/assets/javascripts/ide/components/new_dropdown/modal.vue" do
element :full_file_path
element :template_list
end
- view 'app/assets/javascripts/ide/components/file_templates/bar.vue' do
+ view "app/assets/javascripts/ide/components/file_templates/bar.vue" do
element :file_templates_bar
element :file_template_dropdown
end
- view 'app/assets/javascripts/ide/components/file_templates/dropdown.vue' do
+ view "app/assets/javascripts/ide/components/file_templates/dropdown.vue" do
element :dropdown_filter_input
end
- view 'app/assets/javascripts/ide/components/commit_sidebar/form.vue' do
+ view "app/assets/javascripts/ide/components/commit_sidebar/form.vue" do
element :begin_commit_button
element :commit_button
end
@@ -43,11 +43,9 @@ module QA
def create_new_file_from_template(file_name, template)
click_element :new_file
within_element(:template_list) do
- begin
- click_on file_name
- rescue Capybara::ElementNotFound
- raise ElementNotFound, %Q(Couldn't find file template named "#{file_name}". Please confirm that it is a valid option.)
- end
+ click_on file_name
+ rescue Capybara::ElementNotFound
+ raise ElementNotFound, %(Couldn't find file template named "#{file_name}". Please confirm that it is a valid option.)
end
wait(reload: false) do
@@ -58,7 +56,7 @@ module QA
begin
click_on template
rescue Capybara::ElementNotFound
- raise ElementNotFound, %Q(Couldn't find template "#{template}" for #{file_name}. Please confirm that it exists in the list of templates.)
+ raise ElementNotFound, %(Couldn't find template "#{template}" for #{file_name}. Please confirm that it exists in the list of templates.)
end
end
end
@@ -80,13 +78,13 @@ module QA
# Retry the attempt to click :commit_button just in case part of the
# animation is still in process even when the buttons have the
# expected visibility.
- commit_success_msg_shown = retry_until do
+ commit_success_msg_shown = retry_until {
click_element :commit_button
wait(reload: false) do
- has_text?('Your changes have been committed')
+ has_text?("Your changes have been committed")
end
- end
+ }
raise "The changes do not appear to have been committed successfully." unless commit_success_msg_shown
end
diff --git a/qa/qa/page/project/wiki/edit.rb b/qa/qa/page/project/wiki/edit.rb
index 8d0eafa1818..3fc7510bc93 100644
--- a/qa/qa/page/project/wiki/edit.rb
+++ b/qa/qa/page/project/wiki/edit.rb
@@ -3,22 +3,22 @@ module QA
module Project
module Wiki
class Edit < Page::Base
- view 'app/views/projects/wikis/_main_links.html.haml' do
- element :new_page_link, 'New page' # rubocop:disable QA/ElementWithPattern
- element :page_history_link, 'Page history' # rubocop:disable QA/ElementWithPattern
- element :edit_page_link, 'Edit' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/wikis/_main_links.html.haml" do
+ element :new_page_link, "New page" # rubocop:disable QA/ElementWithPattern
+ element :page_history_link, "Page history" # rubocop:disable QA/ElementWithPattern
+ element :edit_page_link, "Edit" # rubocop:disable QA/ElementWithPattern
end
def go_to_new_page
- click_on 'New page'
+ click_on "New page"
end
def got_to_view_history_page
- click_on 'Page history'
+ click_on "Page history"
end
def go_to_edit_page
- click_on 'Edit'
+ click_on "Edit"
end
end
end
diff --git a/qa/qa/page/project/wiki/new.rb b/qa/qa/page/project/wiki/new.rb
index b90e03be36a..e9687e26dd7 100644
--- a/qa/qa/page/project/wiki/new.rb
+++ b/qa/qa/page/project/wiki/new.rb
@@ -7,7 +7,7 @@ module QA
class New < Page::Base
include Component::LazyLoader
- view 'app/views/projects/wikis/_form.html.haml' do
+ view "app/views/projects/wikis/_form.html.haml" do
element :wiki_title_textbox
element :wiki_content_textarea
element :wiki_message_textbox
@@ -15,11 +15,11 @@ module QA
element :create_page_button
end
- view 'app/views/shared/empty_states/_wikis.html.haml' do
+ view "app/views/shared/empty_states/_wikis.html.haml" do
element :create_first_page_link
end
- view 'app/views/shared/empty_states/_wikis_layout.html.haml' do
+ view "app/views/shared/empty_states/_wikis_layout.html.haml" do
element :svg_content
end
diff --git a/qa/qa/page/project/wiki/show.rb b/qa/qa/page/project/wiki/show.rb
index dffbc5d60a2..a7462426d41 100644
--- a/qa/qa/page/project/wiki/show.rb
+++ b/qa/qa/page/project/wiki/show.rb
@@ -7,12 +7,12 @@ module QA
class Show < Page::Base
include Page::Component::LegacyClonePanel
- view 'app/views/projects/wikis/pages.html.haml' do
- element :clone_repository_link, 'Clone repository' # rubocop:disable QA/ElementWithPattern
+ view "app/views/projects/wikis/pages.html.haml" do
+ element :clone_repository_link, "Clone repository" # rubocop:disable QA/ElementWithPattern
end
def go_to_clone_repository
- click_on 'Clone repository'
+ click_on "Clone repository"
end
end
end
diff --git a/qa/qa/page/settings/common.rb b/qa/qa/page/settings/common.rb
index 9fea74eabc9..9ab9d3526c0 100644
--- a/qa/qa/page/settings/common.rb
+++ b/qa/qa/page/settings/common.rb
@@ -9,9 +9,9 @@ module QA
within_element(element_name) do
# Because it is possible to click the button before the JS toggle code is bound
wait(reload: false) do
- click_button 'Expand' unless first('button', text: 'Collapse')
+ click_button "Expand" unless first("button", text: "Collapse")
- has_content?('Collapse')
+ has_content?("Collapse")
end
yield if block_given?
diff --git a/qa/qa/page/validator.rb b/qa/qa/page/validator.rb
index 117d8d4db67..905a3f27269 100644
--- a/qa/qa/page/validator.rb
+++ b/qa/qa/page/validator.rb
@@ -3,31 +3,31 @@ module QA
class Validator
ValidationError = Class.new(StandardError)
- Error = Struct.new(:page, :message) do
+ Error = Struct.new(:page, :message) {
def to_s
"Error: #{page} - #{message}"
end
- end
+ }
def initialize(constant)
@module = constant
end
def constants
- @consts ||= @module.constants.map do |const|
+ @consts ||= @module.constants.map { |const|
@module.const_get(const)
- end
+ }
end
def descendants
- @descendants ||= constants.map do |const|
+ @descendants ||= constants.map { |const|
case const
when Class
const if const < Page::Base
when Module
Page::Validator.new(const).descendants
end
- end
+ }
@descendants.flatten.compact
end
@@ -45,7 +45,7 @@ module QA
def validate!
return if errors.none?
- raise ValidationError, 'Page views / elements validation error!'
+ raise ValidationError, "Page views / elements validation error!"
end
end
end
diff --git a/qa/qa/page/view.rb b/qa/qa/page/view.rb
index c59fad2e223..f1a5a6cef75 100644
--- a/qa/qa/page/view.rb
+++ b/qa/qa/page/view.rb
@@ -1,4 +1,4 @@
-require 'pathname'
+require "pathname"
module QA
module Page
@@ -11,7 +11,7 @@ module QA
end
def pathname
- @pathname ||= ::Pathname.new(::File.join(__dir__, '../../../', @path))
+ @pathname ||= ::Pathname.new(::File.join(__dir__, "../../../", @path))
.cleanpath.expand_path
end
diff --git a/qa/qa/resource/api_fabricator.rb b/qa/qa/resource/api_fabricator.rb
index 98eebac0880..9dc5a2e8981 100644
--- a/qa/qa/resource/api_fabricator.rb
+++ b/qa/qa/resource/api_fabricator.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'active_support/core_ext/object/deep_dup'
-require 'capybara/dsl'
+require "active_support/core_ext/object/deep_dup"
+require "capybara/dsl"
module QA
module Resource
@@ -68,7 +68,8 @@ module QA
def api_post
response = post(
Runtime::API::Request.new(api_client, api_post_path).url,
- api_post_body)
+ api_post_body
+ )
unless response.code == HTTP_STATUS_CREATED
raise ResourceFabricationFailedError, "Fabrication of #{self.class.name} using the API failed (#{response.code}) with `#{response}`."
@@ -79,7 +80,7 @@ module QA
def api_client
@api_client ||= begin
- Runtime::API::Client.new(:gitlab, is_new_session: !current_url.start_with?('http'))
+ Runtime::API::Client.new(:gitlab, is_new_session: !current_url.start_with?("http"))
end
end
diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb
index 523d92c7ef3..0ee4139f10b 100644
--- a/qa/qa/resource/base.rb
+++ b/qa/qa/resource/base.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'forwardable'
-require 'capybara/dsl'
-require 'active_support/core_ext/array/extract_options'
+require "forwardable"
+require "capybara/dsl"
+require "active_support/core_ext/array/extract_options"
module QA
module Resource
@@ -88,7 +88,7 @@ module QA
end
def self.do_fabricate!(resource:, prepare_block:, parents: [])
- prepare_block.call(resource) if prepare_block
+ prepare_block&.call(resource)
resource_web_url = yield
resource.web_url = resource_web_url
@@ -101,7 +101,7 @@ module QA
return yield unless Runtime::Env.debug?
start = Time.now
- prefix = "==#{'=' * parents.size}>"
+ prefix = "==#{"=" * parents.size}>"
msg = [prefix]
msg << "Built a #{name}"
msg << "as a dependency of #{parents.last}" if parents.any?
@@ -109,7 +109,7 @@ module QA
yield.tap do
msg << "in #{Time.now - start} seconds"
- puts msg.join(' ')
+ puts msg.join(" ")
puts if parents.empty?
end
end
@@ -133,7 +133,8 @@ module QA
instance_variable_get("@#{name}") ||
instance_variable_set(
"@#{name}",
- populate_attribute(name, block))
+ populate_attribute(name, block)
+ )
end
end
end
diff --git a/qa/qa/resource/branch.rb b/qa/qa/resource/branch.rb
index bd52c4abe02..4abd5040da4 100644
--- a/qa/qa/resource/branch.rb
+++ b/qa/qa/resource/branch.rb
@@ -4,16 +4,16 @@ module QA
module Resource
class Branch < Base
attr_accessor :project, :branch_name,
- :allow_to_push, :allow_to_merge, :protected
+ :allow_to_push, :allow_to_merge, :protected
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'protected-branch-project'
+ resource.name = "protected-branch-project"
end
end
def initialize
- @branch_name = 'test/branch'
+ @branch_name = "test/branch"
@allow_to_push = true
@allow_to_merge = true
@protected = false
@@ -24,18 +24,18 @@ module QA
Repository::ProjectPush.fabricate! do |resource|
resource.project = project
- resource.file_name = 'kick-off.txt'
- resource.commit_message = 'First commit'
+ resource.file_name = "kick-off.txt"
+ resource.commit_message = "First commit"
end
- branch = Repository::ProjectPush.fabricate! do |resource|
+ branch = Repository::ProjectPush.fabricate! { |resource|
resource.project = project
- resource.file_name = 'README.md'
- resource.commit_message = 'Add readme'
- resource.branch_name = 'master'
+ resource.file_name = "README.md"
+ resource.commit_message = "Add readme"
+ resource.branch_name = "master"
resource.new_branch = false
resource.remote_branch = @branch_name
- end
+ }
Page::Project::Show.perform do |page|
page.wait { page.has_content?(branch_name) }
@@ -65,7 +65,7 @@ module QA
end
page.wait(reload: false) do
- !page.first('.btn-success').disabled?
+ !page.first(".btn-success").disabled?
end
page.protect_branch
diff --git a/qa/qa/resource/ci_variable.rb b/qa/qa/resource/ci_variable.rb
index 0570c47d41c..80aca61151c 100644
--- a/qa/qa/resource/ci_variable.rb
+++ b/qa/qa/resource/ci_variable.rb
@@ -7,8 +7,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-ci-variables'
- resource.description = 'project for adding CI variable test'
+ resource.name = "project-with-ci-variables"
+ resource.description = "project for adding CI variable test"
end
end
diff --git a/qa/qa/resource/deploy_key.rb b/qa/qa/resource/deploy_key.rb
index 9565598efb0..6a1491d6045 100644
--- a/qa/qa/resource/deploy_key.rb
+++ b/qa/qa/resource/deploy_key.rb
@@ -15,8 +15,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-to-deploy'
- resource.description = 'project for adding deploy key test'
+ resource.name = "project-to-deploy"
+ resource.description = "project for adding deploy key test"
end
end
diff --git a/qa/qa/resource/deploy_token.rb b/qa/qa/resource/deploy_token.rb
index cee4422f6b4..a815f0bec41 100644
--- a/qa/qa/resource/deploy_token.rb
+++ b/qa/qa/resource/deploy_token.rb
@@ -23,8 +23,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-to-deploy'
- resource.description = 'project for adding deploy token test'
+ resource.name = "project-to-deploy"
+ resource.description = "project for adding deploy token test"
end
end
diff --git a/qa/qa/resource/events/base.rb b/qa/qa/resource/events/base.rb
index b50b620b143..7162c80404b 100644
--- a/qa/qa/resource/events/base.rb
+++ b/qa/qa/resource/events/base.rb
@@ -11,7 +11,7 @@ module QA
def events(action: nil)
path = [api_get_events]
path << "?action=#{CGI.escape(action)}" if action
- parse_body(api_get_from("#{path.join}"))
+ parse_body(api_get_from(path.join.to_s))
end
private
@@ -21,9 +21,9 @@ module QA
end
def wait_for_event
- event_found = QA::Support::Waiter.wait(max: max_wait) do
+ event_found = QA::Support::Waiter.wait(max: max_wait) {
yield
- end
+ }
raise EventNotFoundError, "Timed out waiting for event" unless event_found
end
diff --git a/qa/qa/resource/events/project.rb b/qa/qa/resource/events/project.rb
index 99c78254f42..c8a073f34ae 100644
--- a/qa/qa/resource/events/project.rb
+++ b/qa/qa/resource/events/project.rb
@@ -7,16 +7,16 @@ module QA
include Events::Base
def wait_for_push(commit_message)
- QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_push with commit message "#{commit_message}"])
+ QA::Runtime::Logger.debug(%(#{self.class.name} - wait_for_push with commit message "#{commit_message}"))
wait_for_event do
- events(action: 'pushed').any? { |event| event.dig(:push_data, :commit_title) == commit_message }
+ events(action: "pushed").any? { |event| event.dig(:push_data, :commit_title) == commit_message }
end
end
def wait_for_push_new_branch(branch_name = "master")
- QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_push_new_branch with branch_name "#{branch_name}"])
+ QA::Runtime::Logger.debug(%(#{self.class.name} - wait_for_push_new_branch with branch_name "#{branch_name}"))
wait_for_event do
- events(action: 'pushed').any? { |event| event.dig(:push_data, :ref) == branch_name }
+ events(action: "pushed").any? { |event| event.dig(:push_data, :ref) == branch_name }
end
end
end
diff --git a/qa/qa/resource/file.rb b/qa/qa/resource/file.rb
index 57e82ac19ad..ea89ba0d937 100644
--- a/qa/qa/resource/file.rb
+++ b/qa/qa/resource/file.rb
@@ -4,19 +4,19 @@ module QA
module Resource
class File < Base
attr_accessor :name,
- :content,
- :commit_message
+ :content,
+ :commit_message
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-new-file'
+ resource.name = "project-with-new-file"
end
end
def initialize
- @name = 'QA Test - File name'
- @content = 'QA Test - File content'
- @commit_message = 'QA Test - Commit message'
+ @name = "QA Test - File name"
+ @content = "QA Test - File content"
+ @commit_message = "QA Test - Commit message"
end
def fabricate!
diff --git a/qa/qa/resource/fork.rb b/qa/qa/resource/fork.rb
index 03bc1f0820b..1869796e625 100644
--- a/qa/qa/resource/fork.rb
+++ b/qa/qa/resource/fork.rb
@@ -42,7 +42,7 @@ module QA
end
Page::Layout::Banner.perform do |page|
- page.has_notice?('The project was successfully forked.')
+ page.has_notice?("The project was successfully forked.")
end
populate(:project)
diff --git a/qa/qa/resource/group.rb b/qa/qa/resource/group.rb
index d7f9ec6a836..e6b6b4143e1 100644
--- a/qa/qa/resource/group.rb
+++ b/qa/qa/resource/group.rb
@@ -28,7 +28,7 @@ module QA
Page::Group::New.perform do |group_new|
group_new.set_path(path)
group_new.set_description(description)
- group_new.set_visibility('Public')
+ group_new.set_visibility("Public")
group_new.create
end
@@ -56,7 +56,7 @@ module QA
end
def api_post_path
- '/groups'
+ "/groups"
end
def api_post_body
@@ -64,7 +64,7 @@ module QA
parent_id: sandbox.id,
path: path,
name: path,
- visibility: 'public'
+ visibility: "public",
}
end
end
diff --git a/qa/qa/resource/issue.rb b/qa/qa/resource/issue.rb
index 2c2f27fe231..87e05909d11 100644
--- a/qa/qa/resource/issue.rb
+++ b/qa/qa/resource/issue.rb
@@ -7,8 +7,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-for-issues'
- resource.description = 'project for adding issues'
+ resource.name = "project-for-issues"
+ resource.description = "project for adding issues"
end
end
diff --git a/qa/qa/resource/kubernetes_cluster.rb b/qa/qa/resource/kubernetes_cluster.rb
index 93a06be6818..58c27847645 100644
--- a/qa/qa/resource/kubernetes_cluster.rb
+++ b/qa/qa/resource/kubernetes_cluster.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
@@ -16,13 +16,16 @@ module QA
@project.visit!
Page::Project::Menu.perform(
- &:click_operations_kubernetes)
+ &:click_operations_kubernetes
+ )
Page::Project::Operations::Kubernetes::Index.perform(
- &:add_kubernetes_cluster)
+ &:add_kubernetes_cluster
+ )
Page::Project::Operations::Kubernetes::Add.perform(
- &:add_existing_cluster)
+ &:add_existing_cluster
+ )
Page::Project::Operations::Kubernetes::AddExisting.perform do |page|
page.set_cluster_name(@cluster.cluster_name)
diff --git a/qa/qa/resource/label.rb b/qa/qa/resource/label.rb
index c0869cb1f2a..f59144437be 100644
--- a/qa/qa/resource/label.rb
+++ b/qa/qa/resource/label.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
@@ -11,14 +11,14 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-label'
+ resource.name = "project-with-label"
end
end
def initialize
@title = "qa-test-#{SecureRandom.hex(8)}"
- @description = 'This is a test label'
- @color = '#0033CC'
+ @description = "This is a test label"
+ @color = "#0033CC"
end
def fabricate!
diff --git a/qa/qa/resource/merge_request.rb b/qa/qa/resource/merge_request.rb
index 45cb317e0eb..6169e760738 100644
--- a/qa/qa/resource/merge_request.rb
+++ b/qa/qa/resource/merge_request.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
class MergeRequest < Base
attr_accessor :title,
- :description,
- :source_branch,
- :target_branch,
- :assignee,
- :milestone,
- :labels,
- :file_name,
- :file_content
+ :description,
+ :source_branch,
+ :target_branch,
+ :assignee,
+ :milestone,
+ :labels,
+ :file_name,
+ :file_content
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-merge-request'
+ resource.name = "project-with-merge-request"
end
end
@@ -26,7 +26,7 @@ module QA
Repository::ProjectPush.fabricate! do |resource|
resource.project = project
- resource.branch_name = 'master'
+ resource.branch_name = "master"
resource.remote_branch = target_branch
end
end
@@ -43,8 +43,8 @@ module QA
end
def initialize
- @title = 'QA test - merge request'
- @description = 'This is a test merge request'
+ @title = "QA test - merge request"
+ @description = "This is a test merge request"
@source_branch = "qa-test-feature-#{SecureRandom.hex(8)}"
@target_branch = "master"
@assignee = nil
@@ -63,7 +63,7 @@ module QA
page.fill_title(@title)
page.fill_description(@description)
page.choose_milestone(@milestone) if @milestone
- page.assign_to_me if @assignee == 'me'
+ page.assign_to_me if @assignee == "me"
labels.each do |label|
page.select_label(label)
end
diff --git a/qa/qa/resource/merge_request_from_fork.rb b/qa/qa/resource/merge_request_from_fork.rb
index 5d20a6e9c75..87a0aba9472 100644
--- a/qa/qa/resource/merge_request_from_fork.rb
+++ b/qa/qa/resource/merge_request_from_fork.rb
@@ -13,7 +13,7 @@ module QA
Repository::ProjectPush.fabricate! do |resource|
resource.project = fork.project
resource.branch_name = fork_branch
- resource.file_name = 'file2.txt'
+ resource.file_name = "file2.txt"
resource.user = fork.user
end
end
diff --git a/qa/qa/resource/personal_access_token.rb b/qa/qa/resource/personal_access_token.rb
index b8dd0a3562f..48ba57f6f03 100644
--- a/qa/qa/resource/personal_access_token.rb
+++ b/qa/qa/resource/personal_access_token.rb
@@ -17,7 +17,7 @@ module QA
Page::Profile::Menu.perform(&:click_access_tokens)
Page::Profile::PersonalAccessTokens.perform do |page|
- page.fill_token_name(name || 'api-test-token')
+ page.fill_token_name(name || "api-test-token")
page.check_api
page.create_token
end
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb
index de1e9f04c36..1fabad13345 100644
--- a/qa/qa/resource/project.rb
+++ b/qa/qa/resource/project.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
@@ -31,7 +31,7 @@ module QA
end
def initialize
- @description = 'My awesome project'
+ @description = "My awesome project"
end
def name=(raw_name)
@@ -47,7 +47,7 @@ module QA
page.choose_test_namespace
page.choose_name(@name)
page.add_description(@description)
- page.set_visibility('Public')
+ page.set_visibility("Public")
page.create_new_project
end
end
@@ -63,7 +63,7 @@ module QA
end
def api_post_path
- '/projects'
+ "/projects"
end
def api_post_body
@@ -72,7 +72,7 @@ module QA
path: name,
name: name,
description: description,
- visibility: 'public'
+ visibility: "public",
}
end
diff --git a/qa/qa/resource/project_imported_from_github.rb b/qa/qa/resource/project_imported_from_github.rb
index 0d25e7dd842..cecae9c9377 100644
--- a/qa/qa/resource/project_imported_from_github.rb
+++ b/qa/qa/resource/project_imported_from_github.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
diff --git a/qa/qa/resource/project_milestone.rb b/qa/qa/resource/project_milestone.rb
index a4d6657caff..9b06831c998 100644
--- a/qa/qa/resource/project_milestone.rb
+++ b/qa/qa/resource/project_milestone.rb
@@ -12,7 +12,7 @@ module QA
def title=(title)
@title = "#{title}-#{SecureRandom.hex(4)}"
- @description = 'A milestone'
+ @description = "A milestone"
end
def fabricate!
diff --git a/qa/qa/resource/repository/project_push.rb b/qa/qa/resource/repository/project_push.rb
index cad89ebb0bb..4e7aead978c 100644
--- a/qa/qa/resource/repository/project_push.rb
+++ b/qa/qa/resource/repository/project_push.rb
@@ -8,16 +8,16 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-code'
- resource.description = 'Project with repository'
+ resource.name = "project-with-code"
+ resource.description = "Project with repository"
end
end
def initialize
- @file_name = 'file.txt'
- @file_content = '# This is test project'
+ @file_name = "file.txt"
+ @file_content = "# This is test project"
@commit_message = "This is a test commit"
- @branch_name = 'master'
+ @branch_name = "master"
@new_branch = true
@wait_for_push = true
end
diff --git a/qa/qa/resource/repository/push.rb b/qa/qa/resource/repository/push.rb
index a5827fb6e73..5b415de99a3 100644
--- a/qa/qa/resource/repository/push.rb
+++ b/qa/qa/resource/repository/push.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'pathname'
+require "pathname"
module QA
module Resource
module Repository
class Push < Base
attr_accessor :file_name, :file_content, :commit_message,
- :branch_name, :new_branch, :output, :repository_http_uri,
- :repository_ssh_uri, :ssh_key, :user, :use_lfs
+ :branch_name, :new_branch, :output, :repository_http_uri,
+ :repository_ssh_uri, :ssh_key, :user, :use_lfs
attr_writer :remote_branch
def initialize
- @file_name = 'file.txt'
- @file_content = '# This is test file'
+ @file_name = "file.txt"
+ @file_content = "# This is test file"
@commit_message = "This is a test commit"
- @branch_name = 'master'
+ @branch_name = "master"
@new_branch = true
@repository_http_uri = ""
@ssh_key = nil
@@ -36,7 +36,7 @@ module QA
def files=(files)
if !files.is_a?(Array) ||
files.empty? ||
- files.any? { |file| !file.has_key?(:name) || !file.has_key?(:content) }
+ files.any? { |file| !file.key?(:name) || !file.key?(:content) }
raise ArgumentError, "Please provide an array of hashes e.g.: [{name: 'file1', content: 'foo'}]"
end
@@ -45,7 +45,7 @@ module QA
def fabricate!
Git::Repository.perform do |repository|
- @output = ''
+ @output = ""
if ssh_key
repository.uri = repository_ssh_uri
@@ -57,8 +57,8 @@ module QA
repository.use_lfs = use_lfs
- username = 'GitLab QA'
- email = 'root@gitlab.com'
+ username = "GitLab QA"
+ email = "root@gitlab.com"
if user
repository.username = user.username
diff --git a/qa/qa/resource/repository/wiki_push.rb b/qa/qa/resource/repository/wiki_push.rb
index 77c4c8a514d..647b689599e 100644
--- a/qa/qa/resource/repository/wiki_push.rb
+++ b/qa/qa/resource/repository/wiki_push.rb
@@ -6,17 +6,17 @@ module QA
class WikiPush < Repository::Push
attribute :wiki do
Wiki.fabricate! do |resource|
- resource.title = 'Home'
- resource.content = '# My First Wiki Content'
- resource.message = 'Update home'
+ resource.title = "Home"
+ resource.content = "# My First Wiki Content"
+ resource.message = "Update home"
end
end
def initialize
- @file_name = 'Home.md'
- @file_content = '# Welcome to My Wiki'
- @commit_message = 'Updating Home Page'
- @branch_name = 'master'
+ @file_name = "Home.md"
+ @file_content = "# Welcome to My Wiki"
+ @commit_message = "Updating Home Page"
+ @branch_name = "master"
@new_branch = false
end
diff --git a/qa/qa/resource/runner.rb b/qa/qa/resource/runner.rb
index 08ae3f22117..bb1e4b88d92 100644
--- a/qa/qa/resource/runner.rb
+++ b/qa/qa/resource/runner.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
@@ -9,8 +9,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-with-ci-cd'
- resource.description = 'Project with CI/CD Pipelines'
+ resource.name = "project-with-ci-cd"
+ resource.description = "Project with CI/CD Pipelines"
end
end
@@ -23,7 +23,7 @@ module QA
end
def image
- @image || 'gitlab/gitlab-runner:alpine'
+ @image || "gitlab/gitlab-runner:alpine"
end
def fabricate!
diff --git a/qa/qa/resource/sandbox.rb b/qa/qa/resource/sandbox.rb
index 41ce857a8b8..f7d6b27290d 100644
--- a/qa/qa/resource/sandbox.rb
+++ b/qa/qa/resource/sandbox.rb
@@ -26,8 +26,8 @@ module QA
Page::Group::New.perform do |group|
group.set_path(path)
- group.set_description('GitLab QA Sandbox Group')
- group.set_visibility('Public')
+ group.set_description("GitLab QA Sandbox Group")
+ group.set_visibility("Public")
group.create
end
end
@@ -45,14 +45,14 @@ module QA
end
def api_post_path
- '/groups'
+ "/groups"
end
def api_post_body
{
path: path,
name: path,
- visibility: 'public'
+ visibility: "public",
}
end
end
diff --git a/qa/qa/resource/user.rb b/qa/qa/resource/user.rb
index 6c5e91b6488..cdafa364738 100644
--- a/qa/qa/resource/user.rb
+++ b/qa/qa/resource/user.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'securerandom'
+require "securerandom"
module QA
module Resource
@@ -21,7 +21,7 @@ module QA
end
def password
- @password || 'password'
+ @password || "password"
end
def name
@@ -36,7 +36,7 @@ module QA
@public_email ||= begin
api_public_email = api_resource&.dig(:public_email)
- api_public_email && api_public_email != '' ? api_public_email : Runtime::User.default_email
+ api_public_email && api_public_email != "" ? api_public_email : Runtime::User.default_email
end
end
@@ -75,7 +75,7 @@ module QA
end
def api_post_path
- '/users'
+ "/users"
end
def api_post_body
@@ -84,18 +84,18 @@ module QA
password: password,
username: username,
name: name,
- skip_confirmation: true
+ skip_confirmation: true,
}.merge(ldap_post_body)
end
def self.fabricate_or_use(username, password)
if Runtime::Env.signup_disabled?
- self.new.tap do |user|
+ new.tap do |user|
user.username = username
user.password = password
end
else
- self.fabricate!
+ fabricate!
end
end
@@ -105,8 +105,8 @@ module QA
return {} unless extern_uid && provider
{
- extern_uid: extern_uid,
- provider: provider
+ extern_uid: extern_uid,
+ provider: provider,
}
end
diff --git a/qa/qa/resource/wiki.rb b/qa/qa/resource/wiki.rb
index e942e9718a0..3d5f6a5ebfa 100644
--- a/qa/qa/resource/wiki.rb
+++ b/qa/qa/resource/wiki.rb
@@ -7,8 +7,8 @@ module QA
attribute :project do
Project.fabricate! do |resource|
- resource.name = 'project-for-wikis'
- resource.description = 'project for adding wikis'
+ resource.name = "project-for-wikis"
+ resource.description = "project for adding wikis"
end
end
diff --git a/qa/qa/runtime/api/client.rb b/qa/qa/runtime/api/client.rb
index aff84c89f0e..dc0f23d9300 100644
--- a/qa/qa/runtime/api/client.rb
+++ b/qa/qa/runtime/api/client.rb
@@ -1,4 +1,4 @@
-require 'airborne'
+require "airborne"
module QA
module Runtime
diff --git a/qa/qa/runtime/api/request.rb b/qa/qa/runtime/api/request.rb
index ff9f0004524..2b84f24d0a6 100644
--- a/qa/qa/runtime/api/request.rb
+++ b/qa/qa/runtime/api/request.rb
@@ -2,7 +2,7 @@ module QA
module Runtime
module API
class Request
- API_VERSION = 'v4'.freeze
+ API_VERSION = "v4".freeze
def initialize(api_client, path, **query_string)
query_string[:private_token] ||= api_client.personal_access_token unless query_string[:oauth_access_token]
@@ -28,11 +28,11 @@ module QA
#
# Returns the relative path to the requested API resource
def request_path(path, version: API_VERSION, **query_string)
- full_path = ::File.join('/api', version, path)
+ full_path = ::File.join("/api", version, path)
if query_string.any?
- full_path << (path.include?('?') ? '&' : '?')
- full_path << query_string.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join('&')
+ full_path << (path.include?("?") ? "&" : "?")
+ full_path << query_string.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join("&")
end
full_path
diff --git a/qa/qa/runtime/browser.rb b/qa/qa/runtime/browser.rb
index 0b805b855ac..ee1e4d11a1e 100644
--- a/qa/qa/runtime/browser.rb
+++ b/qa/qa/runtime/browser.rb
@@ -1,7 +1,7 @@
-require 'rspec/core'
-require 'capybara/rspec'
-require 'capybara-screenshot/rspec'
-require 'selenium-webdriver'
+require "rspec/core"
+require "capybara/rspec"
+require "capybara-screenshot/rspec"
+require "selenium-webdriver"
module QA
module Runtime
@@ -44,16 +44,16 @@ module QA
Capybara.register_driver QA::Runtime::Env.browser do |app|
capabilities = Selenium::WebDriver::Remote::Capabilities.send(QA::Runtime::Env.browser,
- # This enables access to logs with `page.driver.manage.get_log(:browser)`
- loggingPrefs: {
- browser: "ALL",
- client: "ALL",
- driver: "ALL",
- server: "ALL"
- })
+ # This enables access to logs with `page.driver.manage.get_log(:browser)`
+ loggingPrefs: {
+ browser: "ALL",
+ client: "ALL",
+ driver: "ALL",
+ server: "ALL",
+ })
if QA::Runtime::Env.accept_insecure_certs?
- capabilities['acceptInsecureCerts'] = true
+ capabilities["acceptInsecureCerts"] = true
end
# QA::Runtime::Env.browser.capitalize will work for every driver type except PhantomJS.
@@ -79,7 +79,7 @@ module QA
# Use the same profile on QA runs if CHROME_REUSE_PROFILE is true.
# Useful to speed up local QA.
if QA::Runtime::Env.reuse_chrome_profile?
- qa_profile_dir = ::File.expand_path('../../tmp/qa-profile', __dir__)
+ qa_profile_dir = ::File.expand_path("../../tmp/qa-profile", __dir__)
options.add_argument("user-data-dir=#{qa_profile_dir}")
end
@@ -90,7 +90,7 @@ module QA
browser: QA::Runtime::Env.browser,
clear_local_storage: true,
desired_capabilities: capabilities,
- options: options
+ options: options,
}
selenium_options[:url] = QA::Runtime::Env.remote_grid if QA::Runtime::Env.remote_grid
@@ -110,7 +110,7 @@ module QA
end
Capybara::Screenshot.register_filename_prefix_formatter(:rspec) do |example|
- ::File.join(QA::Runtime::Namespace.name, example.file_path.sub('./qa/specs/features/', ''))
+ ::File.join(QA::Runtime::Namespace.name, example.file_path.sub("./qa/specs/features/", ""))
end
Capybara.configure do |config|
@@ -118,7 +118,7 @@ module QA
config.javascript_driver = QA::Runtime::Env.browser
config.default_max_wait_time = 10
# https://github.com/mattheworiordan/capybara-screenshot/issues/164
- config.save_path = ::File.expand_path('../../tmp', __dir__)
+ config.save_path = ::File.expand_path("../../tmp", __dir__)
end
end
diff --git a/qa/qa/runtime/env.rb b/qa/qa/runtime/env.rb
index dd0ddbdbd6b..0caa67b5034 100644
--- a/qa/qa/runtime/env.rb
+++ b/qa/qa/runtime/env.rb
@@ -10,7 +10,7 @@ module QA
# The environment variables used to indicate if the environment under test
# supports the given feature
SUPPORTED_FEATURES = {
- git_protocol_v2: 'QA_CAN_TEST_GIT_PROTOCOL_V2'
+ git_protocol_v2: "QA_CAN_TEST_GIT_PROTOCOL_V2",
}.freeze
def supported_features
@@ -18,42 +18,42 @@ module QA
end
def debug?
- enabled?(ENV['QA_DEBUG'], default: false)
+ enabled?(ENV["QA_DEBUG"], default: false)
end
def log_destination
- ENV['QA_LOG_PATH'] || $stdout
+ ENV["QA_LOG_PATH"] || $stdout
end
# set to 'false' to have Chrome run visibly instead of headless
def chrome_headless?
- enabled?(ENV['CHROME_HEADLESS'])
+ enabled?(ENV["CHROME_HEADLESS"])
end
# set to 'true' to have Chrome use a fixed profile directory
def reuse_chrome_profile?
- enabled?(ENV['CHROME_REUSE_PROFILE'], default: false)
+ enabled?(ENV["CHROME_REUSE_PROFILE"], default: false)
end
def accept_insecure_certs?
- enabled?(ENV['ACCEPT_INSECURE_CERTS'])
+ enabled?(ENV["ACCEPT_INSECURE_CERTS"])
end
def running_in_ci?
- ENV['CI'] || ENV['CI_SERVER']
+ ENV["CI"] || ENV["CI_SERVER"]
end
def qa_cookies
- ENV['QA_COOKIES'] && ENV['QA_COOKIES'].split(';')
+ ENV["QA_COOKIES"]&.split(";")
end
def signup_disabled?
- enabled?(ENV['SIGNUP_DISABLED'], default: false)
+ enabled?(ENV["SIGNUP_DISABLED"], default: false)
end
# specifies token that can be used for the api
def personal_access_token
- @personal_access_token ||= ENV['PERSONAL_ACCESS_TOKEN']
+ @personal_access_token ||= ENV["PERSONAL_ACCESS_TOKEN"]
end
def remote_grid
@@ -63,49 +63,49 @@ module QA
# - "https://user:pass@somehost.com:443/wd/hub"
# - "http://localhost:4444/wd/hub"
- return if (ENV['QA_REMOTE_GRID'] || '').empty?
+ return if (ENV["QA_REMOTE_GRID"] || "").empty?
- "#{remote_grid_protocol}://#{remote_grid_credentials}#{ENV['QA_REMOTE_GRID']}/wd/hub"
+ "#{remote_grid_protocol}://#{remote_grid_credentials}#{ENV["QA_REMOTE_GRID"]}/wd/hub"
end
def remote_grid_username
- ENV['QA_REMOTE_GRID_USERNAME']
+ ENV["QA_REMOTE_GRID_USERNAME"]
end
def remote_grid_access_key
- ENV['QA_REMOTE_GRID_ACCESS_KEY']
+ ENV["QA_REMOTE_GRID_ACCESS_KEY"]
end
def remote_grid_protocol
- ENV['QA_REMOTE_GRID_PROTOCOL'] || 'http'
+ ENV["QA_REMOTE_GRID_PROTOCOL"] || "http"
end
def browser
- ENV['QA_BROWSER'].nil? ? :chrome : ENV['QA_BROWSER'].to_sym
+ ENV["QA_BROWSER"].nil? ? :chrome : ENV["QA_BROWSER"].to_sym
end
def user_username
- ENV['GITLAB_USERNAME']
+ ENV["GITLAB_USERNAME"]
end
def user_password
- ENV['GITLAB_PASSWORD']
+ ENV["GITLAB_PASSWORD"]
end
def admin_username
- ENV['GITLAB_ADMIN_USERNAME']
+ ENV["GITLAB_ADMIN_USERNAME"]
end
def admin_password
- ENV['GITLAB_ADMIN_PASSWORD']
+ ENV["GITLAB_ADMIN_PASSWORD"]
end
def github_username
- ENV['GITHUB_USERNAME']
+ ENV["GITHUB_USERNAME"]
end
def github_password
- ENV['GITHUB_PASSWORD']
+ ENV["GITHUB_PASSWORD"]
end
def forker?
@@ -113,47 +113,47 @@ module QA
end
def forker_username
- ENV['GITLAB_FORKER_USERNAME']
+ ENV["GITLAB_FORKER_USERNAME"]
end
def forker_password
- ENV['GITLAB_FORKER_PASSWORD']
+ ENV["GITLAB_FORKER_PASSWORD"]
end
def gitlab_qa_username_1
- ENV['GITLAB_QA_USERNAME_1'] || 'gitlab-qa-user1'
+ ENV["GITLAB_QA_USERNAME_1"] || "gitlab-qa-user1"
end
def gitlab_qa_password_1
- ENV['GITLAB_QA_PASSWORD_1']
+ ENV["GITLAB_QA_PASSWORD_1"]
end
def gitlab_qa_username_2
- ENV['GITLAB_QA_USERNAME_2'] || 'gitlab-qa-user2'
+ ENV["GITLAB_QA_USERNAME_2"] || "gitlab-qa-user2"
end
def gitlab_qa_password_2
- ENV['GITLAB_QA_PASSWORD_2']
+ ENV["GITLAB_QA_PASSWORD_2"]
end
def ldap_username
- @ldap_username ||= ENV['GITLAB_LDAP_USERNAME']
+ @ldap_username ||= ENV["GITLAB_LDAP_USERNAME"]
end
def ldap_password
- @ldap_password ||= ENV['GITLAB_LDAP_PASSWORD']
+ @ldap_password ||= ENV["GITLAB_LDAP_PASSWORD"]
end
def sandbox_name
- ENV['GITLAB_SANDBOX_NAME']
+ ENV["GITLAB_SANDBOX_NAME"]
end
def namespace_name
- ENV['GITLAB_NAMESPACE_NAME']
+ ENV["GITLAB_NAMESPACE_NAME"]
end
def auto_devops_project_name
- ENV['GITLAB_AUTO_DEVOPS_PROJECT_NAME']
+ ENV["GITLAB_AUTO_DEVOPS_PROJECT_NAME"]
end
def gcloud_account_key
@@ -165,7 +165,7 @@ module QA
end
def gcloud_zone
- ENV.fetch('GCLOUD_ZONE')
+ ENV.fetch("GCLOUD_ZONE")
end
def has_gcloud_credentials?
@@ -174,7 +174,7 @@ module QA
# Specifies the token that can be used for the GitHub API
def github_access_token
- ENV['GITHUB_ACCESS_TOKEN'].to_s.strip
+ ENV["GITHUB_ACCESS_TOKEN"].to_s.strip
end
def require_github_access_token!
@@ -187,7 +187,7 @@ module QA
# the feature is supported in the environment under test.
# All features are supported by default.
def can_test?(feature)
- raise ArgumentError, %Q(Unknown feature "#{feature}") unless SUPPORTED_FEATURES.include? feature
+ raise ArgumentError, %(Unknown feature "#{feature}") unless SUPPORTED_FEATURES.include? feature
enabled?(ENV[SUPPORTED_FEATURES[feature]], default: true)
end
@@ -196,12 +196,12 @@ module QA
def remote_grid_credentials
if remote_grid_username
- raise ArgumentError, %Q(Please provide an access key for user "#{remote_grid_username}") unless remote_grid_access_key
+ raise ArgumentError, %(Please provide an access key for user "#{remote_grid_username}") unless remote_grid_access_key
return "#{remote_grid_username}:#{remote_grid_access_key}@"
end
- ''
+ ""
end
def enabled?(value, default: true)
diff --git a/qa/qa/runtime/key/base.rb b/qa/qa/runtime/key/base.rb
index 67a992e2115..ecd1f619846 100644
--- a/qa/qa/runtime/key/base.rb
+++ b/qa/qa/runtime/key/base.rb
@@ -19,7 +19,7 @@ module QA
private
def ssh_keygen(name, bits, path)
- cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << ''
+ cmd = %W[ssh-keygen -t #{name} -b #{bits} -f #{path} -N] << ""
Service::Shellout.shell(cmd)
end
diff --git a/qa/qa/runtime/key/ecdsa.rb b/qa/qa/runtime/key/ecdsa.rb
index 20adad45913..b2e58c08687 100644
--- a/qa/qa/runtime/key/ecdsa.rb
+++ b/qa/qa/runtime/key/ecdsa.rb
@@ -4,7 +4,7 @@ module QA
module Key
class ECDSA < Base
def initialize(bits = 521)
- super('ecdsa', bits)
+ super("ecdsa", bits)
end
end
end
diff --git a/qa/qa/runtime/key/ed25519.rb b/qa/qa/runtime/key/ed25519.rb
index 63865c1cee5..04f1afcc4a9 100644
--- a/qa/qa/runtime/key/ed25519.rb
+++ b/qa/qa/runtime/key/ed25519.rb
@@ -4,7 +4,7 @@ module QA
module Key
class ED25519 < Base
def initialize
- super('ed25519', 256)
+ super("ed25519", 256)
end
end
end
diff --git a/qa/qa/runtime/key/rsa.rb b/qa/qa/runtime/key/rsa.rb
index d94bde52325..af7842076df 100644
--- a/qa/qa/runtime/key/rsa.rb
+++ b/qa/qa/runtime/key/rsa.rb
@@ -3,7 +3,7 @@ module QA
module Key
class RSA < Base
def initialize(bits = 4096)
- super('rsa', bits)
+ super("rsa", bits)
end
end
end
diff --git a/qa/qa/runtime/logger.rb b/qa/qa/runtime/logger.rb
index bd5c4fe5bf5..a9c2c6f9e8d 100644
--- a/qa/qa/runtime/logger.rb
+++ b/qa/qa/runtime/logger.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'logger'
+require "logger"
module QA
module Runtime
diff --git a/qa/qa/runtime/namespace.rb b/qa/qa/runtime/namespace.rb
index 9d7c1aea508..26b83074c7f 100644
--- a/qa/qa/runtime/namespace.rb
+++ b/qa/qa/runtime/namespace.rb
@@ -10,7 +10,7 @@ module QA
def name
# If any changes are made to the name tag, following script has to be considered:
# https://ops.gitlab.net/gitlab-com/gl-infra/traffic-generator/blob/master/bin/janitor.bash
- @name ||= Runtime::Env.namespace_name || "qa-test-#{time.strftime('%Y-%m-%d-%H-%M-%S')}-#{SecureRandom.hex(8)}"
+ @name ||= Runtime::Env.namespace_name || "qa-test-#{time.strftime("%Y-%m-%d-%H-%M-%S")}-#{SecureRandom.hex(8)}"
end
def path
@@ -18,7 +18,7 @@ module QA
end
def sandbox_name
- Runtime::Env.sandbox_name || 'gitlab-qa-sandbox-group'
+ Runtime::Env.sandbox_name || "gitlab-qa-sandbox-group"
end
end
end
diff --git a/qa/qa/runtime/path.rb b/qa/qa/runtime/path.rb
index 3169c5dd743..725e16257ea 100644
--- a/qa/qa/runtime/path.rb
+++ b/qa/qa/runtime/path.rb
@@ -6,7 +6,7 @@ module QA
extend self
def qa_root
- ::File.expand_path('../../', __dir__)
+ ::File.expand_path("../../", __dir__)
end
end
end
diff --git a/qa/qa/runtime/release.rb b/qa/qa/runtime/release.rb
index b1f7ec482c8..8d6570f6d15 100644
--- a/qa/qa/runtime/release.rb
+++ b/qa/qa/runtime/release.rb
@@ -21,7 +21,7 @@ module QA
end
def self.method_missing(name, *args)
- self.new.strategy.public_send(name, *args)
+ new.strategy.public_send(name, *args)
end
end
end
diff --git a/qa/qa/runtime/user.rb b/qa/qa/runtime/user.rb
index e8bcb8a9f50..62139a42cda 100644
--- a/qa/qa/runtime/user.rb
+++ b/qa/qa/runtime/user.rb
@@ -4,15 +4,15 @@ module QA
extend self
def default_username
- 'root'
+ "root"
end
def default_email
- 'admin@example.com'
+ "admin@example.com"
end
def default_password
- '5iveL!fe'
+ "5iveL!fe"
end
def username
diff --git a/qa/qa/scenario/bootable.rb b/qa/qa/scenario/bootable.rb
index dd12ea6d492..6f4ac07cf26 100644
--- a/qa/qa/scenario/bootable.rb
+++ b/qa/qa/scenario/bootable.rb
@@ -1,4 +1,4 @@
-require 'optparse'
+require "optparse"
module QA
module Scenario
@@ -11,24 +11,24 @@ module QA
module ClassMethods
def launch!(argv)
- return self.perform(*argv) unless has_attributes?
+ return perform(*argv) unless has_attributes?
- arguments = OptionParser.new do |parser|
+ arguments = OptionParser.new { |parser|
options.to_a.each do |opt|
parser.on(opt.arg, opt.desc) do |value|
Runtime::Scenario.define(opt.name, value)
end
end
- end
+ }
arguments.parse!(argv)
- self.perform(Runtime::Scenario.attributes, *arguments.default_argv)
+ perform(Runtime::Scenario.attributes, *arguments.default_argv)
end
private
- def attribute(name, arg, desc = '')
+ def attribute(name, arg, desc = "")
options.push(Option.new(name, arg, desc))
end
diff --git a/qa/qa/scenario/test/instance.rb b/qa/qa/scenario/test/instance.rb
index b4098619e4e..06bac5d2256 100644
--- a/qa/qa/scenario/test/instance.rb
+++ b/qa/qa/scenario/test/instance.rb
@@ -11,7 +11,7 @@ module QA
include Bootable
def self.perform(*args)
- self.tap do |scenario|
+ tap do |scenario|
yield scenario if block_given?
break scenario.do_perform(*args)
end
diff --git a/qa/qa/scenario/test/sanity/selectors.rb b/qa/qa/scenario/test/sanity/selectors.rb
index cff320cb751..5056ba592f0 100644
--- a/qa/qa/scenario/test/sanity/selectors.rb
+++ b/qa/qa/scenario/test/sanity/selectors.rb
@@ -8,9 +8,9 @@ module QA
PAGES = [QA::Page].freeze
def perform(*)
- validators = PAGES.map do |pages|
+ validators = PAGES.map { |pages|
Page::Validator.new(pages)
- end
+ }
validators.map(&:errors).flatten.tap do |errors|
break if errors.none?
@@ -45,7 +45,7 @@ module QA
validators.each(&:validate!)
- puts 'Views / selectors validation passed!'
+ puts "Views / selectors validation passed!"
end
end
end
diff --git a/qa/qa/service/kubernetes_cluster.rb b/qa/qa/service/kubernetes_cluster.rb
index 41ab702d8b2..1929dfb5682 100644
--- a/qa/qa/service/kubernetes_cluster.rb
+++ b/qa/qa/service/kubernetes_cluster.rb
@@ -1,6 +1,6 @@
-require 'securerandom'
-require 'mkmf'
-require 'pathname'
+require "securerandom"
+require "mkmf"
+require "pathname"
module QA
module Service
@@ -21,7 +21,7 @@ module QA
validate_dependencies
login_if_not_already_logged_in
- shell <<~CMD.tr("\n", ' ')
+ shell <<~CMD.tr("\n", " ")
gcloud container clusters
create #{cluster_name}
#{auth_options}
@@ -37,22 +37,22 @@ module QA
@admin_user = "#{cluster_name}-admin"
master_auth = JSON.parse(`gcloud container clusters describe #{cluster_name} --zone #{Runtime::Env.gcloud_zone} --format 'json(masterAuth.username, masterAuth.password)'`)
- shell <<~CMD.tr("\n", ' ')
+ shell <<~CMD.tr("\n", " ")
kubectl config set-credentials #{@admin_user}
- --username #{master_auth['masterAuth']['username']}
- --password #{master_auth['masterAuth']['password']}
+ --username #{master_auth["masterAuth"]["username"]}
+ --password #{master_auth["masterAuth"]["password"]}
CMD
if rbac
create_service_account
secrets = JSON.parse(`kubectl get secrets -o json`)
- gitlab_account = secrets['items'].find do |item|
- item['metadata']['annotations']['kubernetes.io/service-account.name'] == 'gitlab-account'
- end
+ gitlab_account = secrets["items"].find { |item|
+ item["metadata"]["annotations"]["kubernetes.io/service-account.name"] == "gitlab-account"
+ }
- @ca_certificate = Base64.decode64(gitlab_account['data']['ca.crt'])
- @token = Base64.decode64(gitlab_account['data']['token'])
+ @ca_certificate = Base64.decode64(gitlab_account["data"]["ca.crt"])
+ @token = Base64.decode64(gitlab_account["data"]["token"])
else
@ca_certificate = Base64.decode64(`kubectl get secrets -o jsonpath="{.items[0].data['ca\\.crt']}"`)
@token = Base64.decode64(`kubectl get secrets -o jsonpath='{.items[0].data.token}'`)
@@ -62,18 +62,18 @@ module QA
end
def remove!
- shell <<~CMD.tr("\n", ' ')
- gcloud container clusters delete
- --zone #{Runtime::Env.gcloud_zone}
- #{cluster_name}
- --quiet --async
- CMD
+ shell <<~CMD.tr("\n", " ")
+ gcloud container clusters delete
+ --zone #{Runtime::Env.gcloud_zone}
+ #{cluster_name}
+ --quiet --async
+ CMD
end
private
def create_service_account
- shell('kubectl create -f -', stdin_data: service_account)
+ shell("kubectl create -f -", stdin_data: service_account)
shell("kubectl --user #{@admin_user} create -f -", stdin_data: service_account_role_binding)
end
@@ -109,8 +109,8 @@ module QA
end
def validate_dependencies
- find_executable('gcloud') || raise("You must first install `gcloud` executable to run these tests.")
- find_executable('kubectl') || raise("You must first install `kubectl` executable to run these tests.")
+ find_executable("gcloud") || raise("You must first install `gcloud` executable to run these tests.")
+ find_executable("kubectl") || raise("You must first install `kubectl` executable to run these tests.")
end
def login_if_not_already_logged_in
@@ -128,13 +128,13 @@ module QA
def attempt_login_with_env_vars
puts "No gcloud account. Attempting to login from env vars GCLOUD_ACCOUNT_EMAIL and GCLOUD_ACCOUNT_KEY."
- gcloud_account_key = Tempfile.new('gcloud-account-key')
+ gcloud_account_key = Tempfile.new("gcloud-account-key")
gcloud_account_key.write(Runtime::Env.gcloud_account_key)
gcloud_account_key.close
gcloud_account_email = Runtime::Env.gcloud_account_email
shell("gcloud auth activate-service-account #{gcloud_account_email} --key-file #{gcloud_account_key.path}")
ensure
- gcloud_account_key && gcloud_account_key.unlink
+ gcloud_account_key&.unlink
end
end
end
diff --git a/qa/qa/service/runner.rb b/qa/qa/service/runner.rb
index 9417c707105..c1a85b38029 100644
--- a/qa/qa/service/runner.rb
+++ b/qa/qa/service/runner.rb
@@ -1,4 +1,4 @@
-require 'securerandom'
+require "securerandom"
module QA
module Service
@@ -8,16 +8,16 @@ module QA
attr_accessor :token, :address, :tags, :image
def initialize(name)
- @image = 'gitlab/gitlab-runner:alpine'
+ @image = "gitlab/gitlab-runner:alpine"
@name = name || "qa-runner-#{SecureRandom.hex(4)}"
- @network = Runtime::Scenario.attributes[:network] || 'test'
+ @network = Runtime::Scenario.attributes[:network] || "test"
@tags = %w[qa test]
end
def network
shell "docker network inspect #{@network}"
rescue CommandError
- 'bridge'
+ "bridge"
else
@network
end
@@ -27,14 +27,14 @@ module QA
end
def register!
- shell <<~CMD.tr("\n", ' ')
+ shell <<~CMD.tr("\n", " ")
docker run -d --rm --entrypoint=/bin/sh
--network #{network} --name #{@name}
-e CI_SERVER_URL=#{@address}
-e REGISTER_NON_INTERACTIVE=true
-e REGISTRATION_TOKEN=#{@token}
-e RUNNER_EXECUTOR=shell
- -e RUNNER_TAG_LIST=#{@tags.join(',')}
+ -e RUNNER_TAG_LIST=#{@tags.join(",")}
-e RUNNER_NAME=#{@name}
#{@image} -c 'gitlab-runner register && gitlab-runner run'
CMD
diff --git a/qa/qa/service/shellout.rb b/qa/qa/service/shellout.rb
index 43dc0851571..6593558b634 100644
--- a/qa/qa/service/shellout.rb
+++ b/qa/qa/service/shellout.rb
@@ -1,4 +1,4 @@
-require 'open3'
+require "open3"
module QA
module Service
diff --git a/qa/qa/specs/features/api/1_manage/users_spec.rb b/qa/qa/specs/features/api/1_manage/users_spec.rb
index ba1ba204d24..4e299bdb88c 100644
--- a/qa/qa/specs/features/api/1_manage/users_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/users_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
module QA
- context 'Manage' do
- describe 'Users API' do
+ context "Manage" do
+ describe "Users API" do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
- let(:request) { Runtime::API::Request.new(@api_client, '/users') }
+ let(:request) { Runtime::API::Request.new(@api_client, "/users") }
- it 'GET /users' do
+ it "GET /users" do
get request.url
expect_status(200)
end
- it 'GET /users/:username with a valid username' do
- get request.url, { params: { username: Runtime::User.username } }
+ it "GET /users/:username with a valid username" do
+ get request.url, {params: {username: Runtime::User.username}}
expect_status(200)
expect(json_body).to contain_exactly(
@@ -24,8 +24,8 @@ module QA
)
end
- it 'GET /users/:username with an invalid username' do
- get request.url, { params: { username: SecureRandom.hex(10) } }
+ it "GET /users/:username with an invalid username" do
+ get request.url, {params: {username: SecureRandom.hex(10)}}
expect_status(200)
expect(json_body).to eq([])
diff --git a/qa/qa/specs/features/api/3_create/repository/files_spec.rb b/qa/qa/specs/features/api/3_create/repository/files_spec.rb
index bc0b5ebfe10..eaf37750623 100644
--- a/qa/qa/specs/features/api/3_create/repository/files_spec.rb
+++ b/qa/qa/specs/features/api/3_create/repository/files_spec.rb
@@ -1,7 +1,7 @@
-require 'securerandom'
+require "securerandom"
module QA
- describe 'API basics' do
+ describe "API basics" do
before(:context) do
@api_client = Runtime::API::Client.new(:gitlab)
end
@@ -9,8 +9,8 @@ module QA
let(:project_name) { "api-basics-#{SecureRandom.hex(8)}" }
let(:sanitized_project_path) { CGI.escape("#{Runtime::User.username}/#{project_name}") }
- it 'user creates a project with a file and deletes them afterwards' do
- create_project_request = Runtime::API::Request.new(@api_client, '/projects')
+ it "user creates a project with a file and deletes them afterwards" do
+ create_project_request = Runtime::API::Request.new(@api_client, "/projects")
post create_project_request.url, path: project_name, name: project_name
expect_status(201)
@@ -19,26 +19,26 @@ module QA
)
create_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/README.md")
- post create_file_request.url, branch: 'master', content: 'Hello world', commit_message: 'Add README.md'
+ post create_file_request.url, branch: "master", content: "Hello world", commit_message: "Add README.md"
expect_status(201)
expect(json_body).to match(
- a_hash_including(branch: 'master', file_path: 'README.md')
+ a_hash_including(branch: "master", file_path: "README.md")
)
- get_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/README.md", ref: 'master')
+ get_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/README.md", ref: "master")
get get_file_request.url
expect_status(200)
expect(json_body).to match(
a_hash_including(
- ref: 'master',
- file_path: 'README.md', file_name: 'README.md',
- encoding: 'base64', content: 'SGVsbG8gd29ybGQ='
+ ref: "master",
+ file_path: "README.md", file_name: "README.md",
+ encoding: "base64", content: "SGVsbG8gd29ybGQ="
)
)
- delete_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/README.md", branch: 'master', commit_message: 'Remove README.md')
+ delete_file_request = Runtime::API::Request.new(@api_client, "/projects/#{sanitized_project_path}/repository/files/README.md", branch: "master", commit_message: "Remove README.md")
delete delete_file_request.url
expect_status(204)
@@ -54,7 +54,7 @@ module QA
expect_status(202)
expect(json_body).to match(
- a_hash_including(message: '202 Accepted')
+ a_hash_including(message: "202 Accepted")
)
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb
index 8f24a27b26f..220c6bf322a 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb
@@ -1,7 +1,7 @@
module QA
- context 'Manage', :smoke do
- describe 'basic user login' do
- it 'user logs in using basic credentials and logs out' do
+ context "Manage", :smoke do
+ describe "basic user login" do
+ it "user logs in using basic credentials and logs out" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb
index a397df03bd2..7d3679f7b38 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_gitlab_via_ldap_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module QA
- context 'Manage', :orchestrated, :ldap_no_tls, :ldap_tls do
- describe 'LDAP login' do
- it 'user logs into GitLab using LDAP credentials' do
+ context "Manage", :orchestrated, :ldap_no_tls, :ldap_tls do
+ describe "LDAP login" do
+ it "user logs into GitLab using LDAP credentials" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb
index b1d641b507f..83d2bb7511f 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_into_mattermost_via_gitlab_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module QA
- context 'Manage', :orchestrated, :mattermost do
- describe 'Mattermost login' do
- it 'user logs into Mattermost using GitLab OAuth' do
+ context "Manage", :orchestrated, :mattermost do
+ describe "Mattermost login" do
+ it "user logs into Mattermost using GitLab OAuth" do
Runtime::Browser.visit(:gitlab, Page::Main::Login) do
Page::Main::Login.act { sign_in_using_credentials }
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb
index 87f0e9030d2..102c2f2f129 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_instance_wide_saml_sso_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
module QA
- context 'Manage', :orchestrated, :instance_saml do
- describe 'Instance wide SAML SSO' do
- it 'User logs in to gitlab with SAML SSO' do
+ context "Manage", :orchestrated, :instance_saml do
+ describe "Instance wide SAML SSO" do
+ it "User logs in to gitlab with SAML SSO" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_with_saml }
Vendor::SAMLIdp::Page::Login.act { login }
- expect(page).to have_content('Welcome to GitLab')
+ expect(page).to have_content("Welcome to GitLab")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb
index a118176eb8a..125bce542a8 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/login_via_oauth_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
module QA
- context 'Manage', :orchestrated, :oauth do
- describe 'OAuth login' do
- it 'User logs in to GitLab with GitHub OAuth' do
+ context "Manage", :orchestrated, :oauth do
+ describe "OAuth login" do
+ it "User logs in to GitLab with GitHub OAuth" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_with_github)
Vendor::Github::Page::Login.perform(&:login)
- expect(page).to have_content('Welcome to GitLab')
+ expect(page).to have_content("Welcome to GitLab")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
index 185837edacf..363afbff7c2 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/login/register_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module QA
- shared_examples 'registration and login' do
- it 'user registers and logs in' do
+ shared_examples "registration and login" do
+ it "user registers and logs in" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Resource::User.fabricate_via_browser_ui!
@@ -16,15 +16,15 @@ module QA
end
end
- context 'Manage', :skip_signup_disabled do
- describe 'standard' do
- it_behaves_like 'registration and login'
+ context "Manage", :skip_signup_disabled do
+ describe "standard" do
+ it_behaves_like "registration and login"
end
end
- context 'Manage', :orchestrated, :ldap_no_tls, :skip_signup_disabled do
- describe 'while LDAP is enabled' do
- it_behaves_like 'registration and login'
+ context "Manage", :orchestrated, :ldap_no_tls, :skip_signup_disabled do
+ describe "while LDAP is enabled" do
+ it_behaves_like "registration and login"
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/add_project_member_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/add_project_member_spec.rb
index 4070a225260..e815e95d429 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/project/add_project_member_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/project/add_project_member_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
module QA
- context 'Manage' do
- describe 'Add project member' do
- it 'user adds project member' do
+ context "Manage" do
+ describe "Add project member" do
+ it "user adds project member" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
- project = Resource::Project.fabricate! do |resource|
- resource.name = 'add-member-project'
- end
+ project = Resource::Project.fabricate! { |resource|
+ resource.name = "add-member-project"
+ }
project.visit!
Page::Project::Menu.perform(&:click_members_settings)
diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb
index 6632c2977ef..b6d0f30626d 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/project/create_project_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
module QA
- context 'Manage', :smoke do
- describe 'Project creation' do
- it 'user creates a new project' do
+ context "Manage", :smoke do
+ describe "Project creation" do
+ it "user creates a new project" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- created_project = Resource::Project.fabricate_via_browser_ui! do |project|
- project.name = 'awesome-project'
- project.description = 'create awesome project test'
- end
+ created_project = Resource::Project.fabricate_via_browser_ui! { |project|
+ project.name = "awesome-project"
+ project.description = "create awesome project test"
+ }
expect(page).to have_content(created_project.name)
expect(page).to have_content(
/Project \S?awesome-project\S+ was successfully created/
)
- expect(page).to have_content('create awesome project test')
- expect(page).to have_content('The repository for this project is empty')
+ expect(page).to have_content("create awesome project test")
+ expect(page).to have_content("The repository for this project is empty")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb
index a9eafd61a91..8e604ca79ce 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/project/import_github_repo_spec.rb
@@ -2,13 +2,13 @@
module QA
# https://gitlab.com/gitlab-org/gitlab-ce/issues/58158
- context 'Manage', :github, :quarantine do
- describe 'Project import from GitHub' do
+ context "Manage", :github, :quarantine do
+ describe "Project import from GitHub" do
let(:imported_project) do
Resource::ProjectImportedFromGithub.fabricate! do |project|
- project.name = 'imported-project'
+ project.name = "imported-project"
project.personal_access_token = Runtime::Env.github_access_token
- project.github_repository_path = 'gitlab-qa/test-project'
+ project.github_repository_path = "gitlab-qa/test-project"
end
end
@@ -22,7 +22,7 @@ module QA
expect_status(202)
end
- it 'user imports a GitHub repo' do
+ it "user imports a GitHub repo" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
@@ -44,56 +44,56 @@ module QA
end
def verify_repository_import
- expect(page).to have_content('This test project is used for automated GitHub import by GitLab QA.')
+ expect(page).to have_content("This test project is used for automated GitHub import by GitLab QA.")
expect(page).to have_content(imported_project.name)
end
def verify_issues_import
QA::Support::Retrier.retry_on_exception do
Page::Project::Menu.act { click_issues }
- expect(page).to have_content('This is a sample issue')
+ expect(page).to have_content("This is a sample issue")
- click_link 'This is a sample issue'
+ click_link "This is a sample issue"
- expect(page).to have_content('We should populate this project with issues, pull requests and wiki pages.')
+ expect(page).to have_content("We should populate this project with issues, pull requests and wiki pages.")
# Comments
- comment_text = 'This is a comment from @rymai.'
+ comment_text = "This is a comment from @rymai."
Page::Project::Issue::Show.perform do |issue_page|
expect(issue_page).to have_comment(comment_text)
end
Page::Issuable::Sidebar.perform do |issuable|
- expect(issuable).to have_label('enhancement')
- expect(issuable).to have_label('help wanted')
- expect(issuable).to have_label('good first issue')
+ expect(issuable).to have_label("enhancement")
+ expect(issuable).to have_label("help wanted")
+ expect(issuable).to have_label("good first issue")
end
end
end
def verify_merge_requests_import
Page::Project::Menu.act { click_merge_requests }
- expect(page).to have_content('Improve README.md')
+ expect(page).to have_content("Improve README.md")
- click_link 'Improve README.md'
+ click_link "Improve README.md"
- expect(page).to have_content('This improves the README file a bit.')
+ expect(page).to have_content("This improves the README file a bit.")
# Review comment are not supported yet
- expect(page).not_to have_content('Really nice change.')
+ expect(page).not_to have_content("Really nice change.")
# Comments
- expect(page).to have_content('Nice work! This is a comment from @rymai.')
+ expect(page).to have_content("Nice work! This is a comment from @rymai.")
# Diff comments
- expect(page).to have_content('[Review comment] I like that!')
- expect(page).to have_content('[Review comment] Nice blank line.')
- expect(page).to have_content('[Single diff comment] Much better without this line!')
+ expect(page).to have_content("[Review comment] I like that!")
+ expect(page).to have_content("[Review comment] Nice blank line.")
+ expect(page).to have_content("[Single diff comment] Much better without this line!")
Page::Issuable::Sidebar.perform do |issuable|
- expect(issuable).to have_label('bug')
- expect(issuable).to have_label('enhancement')
+ expect(issuable).to have_label("bug")
+ expect(issuable).to have_label("enhancement")
end
end
@@ -110,7 +110,7 @@ module QA
def verify_wiki_import
Page::Project::Menu.act { click_wiki }
- expect(page).to have_content('Welcome to the test-project wiki!')
+ expect(page).to have_content("Welcome to the test-project wiki!")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb
index e172206eb88..34ca4b2b379 100644
--- a/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb
+++ b/qa/qa/specs/features/browser_ui/1_manage/project/view_project_activity_spec.rb
@@ -2,23 +2,23 @@
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/21
- context 'Manage', :quarantine do
- describe 'Project activity' do
- it 'user creates an event in the activity page upon Git push' do
+ context "Manage", :quarantine do
+ describe "Project activity" do
+ it "user creates an event in the activity page upon Git push" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project_push = Resource::Repository::ProjectPush.fabricate! do |push|
- push.file_name = 'README.md'
- push.file_content = '# This is a test project'
- push.commit_message = 'Add README.md'
- end
+ project_push = Resource::Repository::ProjectPush.fabricate! { |push|
+ push.file_name = "README.md"
+ push.file_content = "# This is a test project"
+ push.commit_message = "Add README.md"
+ }
project_push.project.visit!
Page::Project::Menu.perform(&:go_to_activity)
Page::Project::Activity.perform(&:go_to_push_events)
- expect(page).to have_content('pushed new branch master')
+ expect(page).to have_content("pushed new branch master")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb
index fa779bd1f4e..82e174f2d91 100644
--- a/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb
+++ b/qa/qa/specs/features/browser_ui/2_plan/issue/collapse_comments_in_discussions_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
module QA
- context 'Plan' do
- describe 'collapse comments in issue discussions' do
- let(:issue_title) { 'issue title' }
+ context "Plan" do
+ describe "collapse comments in issue discussions" do
+ let(:issue_title) { "issue title" }
- it 'user collapses reply for comments in an issue' do
+ it "user collapses reply for comments in an issue" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb
index 7145b950b6c..d3e5c9e25e0 100644
--- a/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb
+++ b/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module QA
- context 'Plan', :smoke do
- describe 'Issue creation' do
- let(:issue_title) { 'issue title' }
+ context "Plan", :smoke do
+ describe "Issue creation" do
+ let(:issue_title) { "issue title" }
def create_issue
Runtime::Browser.visit(:gitlab, Page::Main::Login)
@@ -14,7 +14,7 @@ module QA
end
end
- it 'user creates an issue' do
+ it "user creates an issue" do
create_issue
Page::Project::Menu.act { click_issues }
@@ -22,25 +22,25 @@ module QA
expect(page).to have_content(issue_title)
end
- context 'when using attachments in comments', :object_storage do
+ context "when using attachments in comments", :object_storage do
let(:file_to_attach) do
- File.absolute_path(File.join('spec', 'fixtures', 'banana_sample.gif'))
+ File.absolute_path(File.join("spec", "fixtures", "banana_sample.gif"))
end
- it 'user comments on an issue with an attachment' do
+ it "user comments on an issue with an attachment" do
create_issue
Page::Project::Issue::Show.perform do |show|
show.select_all_activities_filter
- show.comment('See attached banana for scale', attachment: file_to_attach)
+ show.comment("See attached banana for scale", attachment: file_to_attach)
show.refresh
image_url = find('a[href$="banana_sample.gif"]')[:href]
- found = show.wait(reload: false) do
+ found = show.wait(reload: false) {
show.asset_exists?(image_url)
- end
+ }
expect(found).to be_truthy
end
diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/filter_issue_comments_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/filter_issue_comments_spec.rb
index ac34f72bb8f..f742b7f25e2 100644
--- a/qa/qa/specs/features/browser_ui/2_plan/issue/filter_issue_comments_spec.rb
+++ b/qa/qa/specs/features/browser_ui/2_plan/issue/filter_issue_comments_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
module QA
- context 'Plan' do
- describe 'filter issue comments activities' do
- let(:issue_title) { 'issue title' }
+ context "Plan" do
+ describe "filter issue comments activities" do
+ let(:issue_title) { "issue title" }
- it 'user filters comments and activites in an issue' do
+ it "user filters comments and activites in an issue" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
@@ -17,8 +17,8 @@ module QA
Page::Project::Issue::Show.perform do |show_page|
show_page.select_comments_only_filter
- show_page.comment('/confidential')
- show_page.comment('My own comment')
+ show_page.comment("/confidential")
+ show_page.comment("My own comment")
expect(show_page).not_to have_content("made the issue confidential")
expect(show_page).to have_content("My own comment")
diff --git a/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb b/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb
index 7e8b42e286f..a6a01b357cd 100644
--- a/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb
+++ b/qa/qa/specs/features/browser_ui/2_plan/issue/issue_suggestions_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
module QA
- context 'Plan' do
- describe 'issue suggestions' do
- let(:issue_title) { 'Issue Lists are awesome' }
+ context "Plan" do
+ describe "issue suggestions" do
+ let(:issue_title) { "Issue Lists are awesome" }
- it 'user sees issue suggestions when creating a new issue' do
+ it "user sees issue suggestions when creating a new issue" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project = Resource::Project.fabricate! do |resource|
- resource.name = 'project-for-issue-suggestions'
- resource.description = 'project for issue suggestions'
- end
+ project = Resource::Project.fabricate! { |resource|
+ resource.name = "project-for-issue-suggestions"
+ resource.description = "project for issue suggestions"
+ }
Resource::Issue.fabricate! do |issue|
issue.title = issue_title
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb
index c06f13ee204..9d8a5bdc88f 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/create_merge_request_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Merge request creation' do
- it 'user creates a new merge request' do
+ context "Create" do
+ describe "Merge request creation" do
+ it "user creates a new merge request" do
gitlab_account_username = "@#{Runtime::User.username}"
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- current_project = Resource::Project.fabricate! do |project|
- project.name = 'project-with-merge-request-and-milestone'
- end
+ current_project = Resource::Project.fabricate! { |project|
+ project.name = "project-with-merge-request-and-milestone"
+ }
- current_milestone = Resource::ProjectMilestone.fabricate! do |milestone|
- milestone.title = 'unique-milestone'
+ current_milestone = Resource::ProjectMilestone.fabricate! { |milestone|
+ milestone.title = "unique-milestone"
milestone.project = current_project
- end
+ }
- new_label = Resource::Label.fabricate! do |label|
+ new_label = Resource::Label.fabricate! { |label|
label.project = current_project
- label.title = 'qa-mr-test-label'
- label.description = 'Merge Request label'
- end
+ label.title = "qa-mr-test-label"
+ label.description = "Merge Request label"
+ }
Resource::MergeRequest.fabricate! do |merge_request|
- merge_request.title = 'This is a merge request with a milestone'
- merge_request.description = 'Great feature with milestone'
+ merge_request.title = "This is a merge request with a milestone"
+ merge_request.description = "Great feature with milestone"
merge_request.project = current_project
merge_request.milestone = current_milestone
- merge_request.assignee = 'me'
+ merge_request.assignee = "me"
merge_request.labels.push(new_label)
end
Page::MergeRequest::Show.perform do |merge_request|
- expect(merge_request).to have_content('This is a merge request with a milestone')
- expect(merge_request).to have_content('Great feature with milestone')
+ expect(merge_request).to have_content("This is a merge request with a milestone")
+ expect(merge_request).to have_content("Great feature with milestone")
expect(merge_request).to have_content(/Opened [\w\s]+ ago/)
expect(merge_request).to have_assignee(gitlab_account_username)
expect(merge_request).to have_label(new_label.title)
@@ -48,23 +48,23 @@ module QA
end
end
- describe 'creates a merge request', :smoke do
- it 'user creates a new merge request' do
+ describe "creates a merge request", :smoke do
+ it "user creates a new merge request" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- current_project = Resource::Project.fabricate! do |project|
- project.name = 'project-with-merge-request'
- end
+ current_project = Resource::Project.fabricate! { |project|
+ project.name = "project-with-merge-request"
+ }
Resource::MergeRequest.fabricate! do |merge_request|
- merge_request.title = 'This is a merge request'
- merge_request.description = 'Great feature'
+ merge_request.title = "This is a merge request"
+ merge_request.description = "Great feature"
merge_request.project = current_project
end
- expect(page).to have_content('This is a merge request')
- expect(page).to have_content('Great feature')
+ expect(page).to have_content("This is a merge request")
+ expect(page).to have_content("Great feature")
expect(page).to have_content(/Opened [\w\s]+ ago/)
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
index 6ca7af8a3af..823baf6c496 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/merge_merge_request_from_fork_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Merge request creation from fork' do
- it 'user forks a project, submits a merge request and maintainer merges it' do
+ context "Create" do
+ describe "Merge request creation from fork" do
+ it "user forks a project, submits a merge request and maintainer merges it" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- merge_request = Resource::MergeRequestFromFork.fabricate! do |merge_request|
- merge_request.fork_branch = 'feature-branch'
- end
+ merge_request = Resource::MergeRequestFromFork.fabricate! { |merge_request|
+ merge_request.fork_branch = "feature-branch"
+ }
Page::Main::Menu.perform(&:sign_out)
Page::Main::Login.perform(&:sign_in_using_credentials)
@@ -18,7 +18,7 @@ module QA
Page::MergeRequest::Show.perform(&:merge!)
- expect(page).to have_content('The changes were merged')
+ expect(page).to have_content("The changes were merged")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
index 3fbcd77dac6..8b3efade663 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/rebase_merge_request_spec.rb
@@ -1,24 +1,24 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Merge request rebasing' do
- it 'user rebases source branch of merge request' do
+ context "Create" do
+ describe "Merge request rebasing" do
+ it "user rebases source branch of merge request" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project = Resource::Project.fabricate! do |project|
+ project = Resource::Project.fabricate! { |project|
project.name = "only-fast-forward"
- end
+ }
project.visit!
Page::Project::Menu.perform(&:go_to_settings)
Page::Project::Settings::MergeRequest.perform(&:enable_ff_only)
- merge_request = Resource::MergeRequest.fabricate! do |merge_request|
+ merge_request = Resource::MergeRequest.fabricate! { |merge_request|
merge_request.project = project
- merge_request.title = 'Needs rebasing'
- end
+ merge_request.title = "Needs rebasing"
+ }
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
@@ -31,7 +31,7 @@ module QA
merge_request.visit!
Page::MergeRequest::Show.perform do |merge_request|
- expect(merge_request).to have_content('Needs rebasing')
+ expect(merge_request).to have_content("Needs rebasing")
expect(merge_request).not_to be_fast_forward_possible
expect(merge_request).not_to have_merge_button
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb
index f146636c49a..0cf01b155b2 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/squash_merge_request_spec.rb
@@ -2,33 +2,33 @@
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/31
- context 'Create' do
- describe 'Merge request squashing' do
- it 'user squashes commits while merging' do
+ context "Create" do
+ describe "Merge request squashing" do
+ it "user squashes commits while merging" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project = Resource::Project.fabricate! do |project|
+ project = Resource::Project.fabricate! { |project|
project.name = "squash-before-merge"
- end
+ }
- merge_request = Resource::MergeRequest.fabricate! do |merge_request|
+ merge_request = Resource::MergeRequest.fabricate! { |merge_request|
merge_request.project = project
- merge_request.title = 'Squashing commits'
- end
+ merge_request.title = "Squashing commits"
+ }
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
- push.commit_message = 'to be squashed'
+ push.commit_message = "to be squashed"
push.branch_name = merge_request.source_branch
push.new_branch = false
- push.file_name = 'other.txt'
+ push.file_name = "other.txt"
push.file_content = "Test with unicode characters ❤✓€❄"
end
merge_request.visit!
- expect(page).to have_text('to be squashed')
+ expect(page).to have_text("to be squashed")
Page::MergeRequest::Show.perform do |merge_request_page|
merge_request_page.mark_to_squash
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb
index de5c535c757..0bbbb9a3f07 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_file_template_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'File templates' do
+ context "Create" do
+ describe "File templates" do
include Runtime::Fixtures
def login
@@ -13,17 +13,17 @@ module QA
before(:all) do
login
- @project = Resource::Project.fabricate! do |project|
- project.name = 'file-template-project'
- project.description = 'Add file templates via the Files view'
- end
+ @project = Resource::Project.fabricate! { |project|
+ project.name = "file-template-project"
+ project.description = "Add file templates via the Files view"
+ }
# There's no 'New File' dropdown when the project is blank, so we first
# add a dummy file so that the dropdown will appear
Resource::File.fabricate! do |file|
file.project = @project
- file.name = 'README.md'
- file.content = '# Readme'
+ file.name = "README.md"
+ file.content = "# Readme"
end
Page::Main::Menu.perform(&:sign_out)
@@ -31,29 +31,29 @@ module QA
templates = [
{
- file_name: '.gitignore',
- name: 'Android',
- api_path: 'gitignores',
- api_key: 'Android'
+ file_name: ".gitignore",
+ name: "Android",
+ api_path: "gitignores",
+ api_key: "Android",
},
{
- file_name: '.gitlab-ci.yml',
- name: 'Julia',
- api_path: 'gitlab_ci_ymls',
- api_key: 'Julia'
+ file_name: ".gitlab-ci.yml",
+ name: "Julia",
+ api_path: "gitlab_ci_ymls",
+ api_key: "Julia",
},
{
- file_name: 'Dockerfile',
- name: 'Python',
- api_path: 'dockerfiles',
- api_key: 'Python'
+ file_name: "Dockerfile",
+ name: "Python",
+ api_path: "dockerfiles",
+ api_key: "Python",
},
{
- file_name: 'LICENSE',
- name: 'Mozilla Public License 2.0',
- api_path: 'licenses',
- api_key: 'mpl-2.0'
- }
+ file_name: "LICENSE",
+ name: "Mozilla Public License 2.0",
+ api_path: "licenses",
+ api_key: "mpl-2.0",
+ },
]
templates.each do |template|
@@ -68,15 +68,15 @@ module QA
page.select_template template[:file_name], template[:name]
end
- expect(page).to have_content('Template applied')
- expect(page).to have_button('Undo')
+ expect(page).to have_content("Template applied")
+ expect(page).to have_button("Undo")
expect(page).to have_content(content[0..100])
Page::File::Form.perform(&:commit_changes)
- expect(page).to have_content('The file has been successfully created.')
+ expect(page).to have_content("The file has been successfully created.")
expect(page).to have_content(template[:file_name])
- expect(page).to have_content('Add new file')
+ expect(page).to have_content("Add new file")
expect(page).to have_content(content[0..100])
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_list_delete_branches_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_list_delete_branches_spec.rb
index 8e181eb28c6..ee9925040c3 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/add_list_delete_branches_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_list_delete_branches_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Create, list, and delete branches via web' do
- master_branch = 'master'
- second_branch = 'second-branch'
- third_branch = 'third-branch'
- file_1_master = 'file.txt'
- file_2_master = 'other-file.txt'
- file_second_branch = 'file-2.txt'
- file_third_branch = 'file-3.txt'
+ context "Create" do
+ describe "Create, list, and delete branches via web" do
+ master_branch = "master"
+ second_branch = "second-branch"
+ third_branch = "third-branch"
+ file_1_master = "file.txt"
+ file_2_master = "other-file.txt"
+ file_second_branch = "file-2.txt"
+ file_third_branch = "file-3.txt"
first_commit_message_of_master_branch = "Add #{file_1_master}"
second_commit_message_of_master_branch = "Add #{file_2_master}"
commit_message_of_second_branch = "Add #{file_second_branch}"
@@ -19,10 +19,10 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project = Resource::Project.fabricate! do |proj|
- proj.name = 'project-qa-test'
- proj.description = 'project for qa test'
- end
+ project = Resource::Project.fabricate! { |proj|
+ proj.name = "project-qa-test"
+ proj.description = "project for qa test"
+ }
Git::Repository.perform do |repository|
repository.uri = project.repository_http_location.uri
@@ -31,11 +31,11 @@ module QA
repository.act do
clone
- configure_identity('GitLab QA', 'root@gitlab.com')
- commit_file(file_1_master, 'Test file content', first_commit_message_of_master_branch)
+ configure_identity("GitLab QA", "root@gitlab.com")
+ commit_file(file_1_master, "Test file content", first_commit_message_of_master_branch)
push_changes
checkout(second_branch, new_branch: true)
- commit_file(file_second_branch, 'File 2 content', commit_message_of_second_branch)
+ commit_file(file_second_branch, "File 2 content", commit_message_of_second_branch)
push_changes(second_branch)
checkout(master_branch)
# This second commit on master is needed for the master branch to be ahead
@@ -43,12 +43,12 @@ module QA
# show the 'merged' badge on it.
# Refer to the below issue note:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/55524#note_126100848
- commit_file(file_2_master, 'Other test file content', second_commit_message_of_master_branch)
+ commit_file(file_2_master, "Other test file content", second_commit_message_of_master_branch)
push_changes
merge(second_branch)
push_changes
checkout(third_branch, new_branch: true)
- commit_file(file_third_branch, 'File 3 content', commit_message_of_third_branch)
+ commit_file(file_third_branch, "File 3 content", commit_message_of_third_branch)
push_changes(third_branch)
end
end
@@ -56,7 +56,7 @@ module QA
project.visit!
end
- it 'branches are correctly listed after CRUD operations' do
+ it "branches are correctly listed after CRUD operations" do
Page::Project::Menu.perform(&:click_repository_branches)
expect(page).to have_content(master_branch)
@@ -67,7 +67,7 @@ module QA
expect(page).to have_content(commit_message_of_third_branch)
Page::Project::Branches::Show.perform do |branches|
- expect(branches).to have_branch_with_badge(second_branch, 'merged')
+ expect(branches).to have_branch_with_badge(second_branch, "merged")
end
Page::Project::Branches::Show.perform do |branches_view|
@@ -79,7 +79,7 @@ module QA
Page::Project::Branches::Show.perform(&:delete_merged_branches)
expect(page).to have_content(
- 'Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.'
+ "Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes."
)
page.refresh
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb
index ff879fdeb16..bb2792e317d 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/add_ssh_key_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'SSH keys support' do
+ context "Create" do
+ describe "SSH keys support" do
let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
- it 'user adds and then removes an SSH key', :smoke do
+ it "user adds and then removes an SSH key", :smoke do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- key = Resource::SSHKey.fabricate! do |resource|
+ key = Resource::SSHKey.fabricate! { |resource|
resource.title = key_title
- end
+ }
expect(page).to have_content("Title: #{key_title}")
expect(page).to have_content(key.fingerprint)
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb
index f2584f55a60..2f9dd8ba399 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/clone_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Git clone over HTTP', :ldap_no_tls do
+ context "Create" do
+ describe "Git clone over HTTP", :ldap_no_tls do
before(:all) do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- @project = Resource::Project.fabricate! do |scenario|
- scenario.name = 'project-with-code'
- scenario.description = 'project for git clone tests'
- end
+ @project = Resource::Project.fabricate! { |scenario|
+ scenario.name = "project-with-code"
+ scenario.description = "project for git clone tests"
+ }
@project.visit!
Git::Repository.perform do |repository|
@@ -19,16 +19,16 @@ module QA
repository.act do
clone
- configure_identity('GitLab QA', 'root@gitlab.com')
- commit_file('test.rb', 'class Test; end', 'Add Test class')
- commit_file('README.md', '# Test', 'Add Readme')
+ configure_identity("GitLab QA", "root@gitlab.com")
+ commit_file("test.rb", "class Test; end", "Add Test class")
+ commit_file("README.md", "# Test", "Add Readme")
push_changes
end
end
@project.wait_for_push_new_branch
end
- it 'user performs a deep clone' do
+ it "user performs a deep clone" do
Git::Repository.perform do |repository|
repository.uri = @project.repository_http_location.uri
repository.use_default_credentials
@@ -39,7 +39,7 @@ module QA
end
end
- it 'user performs a shallow clone' do
+ it "user performs a shallow clone" do
Git::Repository.perform do |repository|
repository.uri = @project.repository_http_location.uri
repository.use_default_credentials
@@ -47,7 +47,7 @@ module QA
repository.shallow_clone
expect(repository.commits.size).to eq 1
- expect(repository.commits.first).to include 'Add Readme'
+ expect(repository.commits.first).to include "Add Readme"
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb
index 46346d1b984..86868d6ac7e 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/create_edit_delete_file_via_web_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Files management' do
- it 'user creates, edits and deletes a file via the Web' do
+ context "Create" do
+ describe "Files management" do
+ it "user creates, edits and deletes a file via the Web" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
# Create
- file_name = 'QA Test - File name'
- file_content = 'QA Test - File content'
- commit_message_for_create = 'QA Test - Create new file'
+ file_name = "QA Test - File name"
+ file_content = "QA Test - File content"
+ commit_message_for_create = "QA Test - Create new file"
Resource::File.fabricate! do |file|
file.name = file_name
@@ -18,14 +18,14 @@ module QA
file.commit_message = commit_message_for_create
end
- expect(page).to have_content('The file has been successfully created.')
+ expect(page).to have_content("The file has been successfully created.")
expect(page).to have_content(file_name)
expect(page).to have_content(file_content)
expect(page).to have_content(commit_message_for_create)
# Edit
- updated_file_content = 'QA Test - Updated file content'
- commit_message_for_update = 'QA Test - Update file'
+ updated_file_content = "QA Test - Updated file content"
+ commit_message_for_update = "QA Test - Update file"
Page::File::Show.act { click_edit }
@@ -36,12 +36,12 @@ module QA
commit_changes
end
- expect(page).to have_content('Your changes have been successfully committed.')
+ expect(page).to have_content("Your changes have been successfully committed.")
expect(page).to have_content(updated_file_content)
expect(page).to have_content(commit_message_for_update)
# Delete
- commit_message_for_delete = 'QA Test - Delete file'
+ commit_message_for_delete = "QA Test - Delete file"
Page::File::Show.act do
click_delete
@@ -49,7 +49,7 @@ module QA
click_delete_file
end
- expect(page).to have_content('The file has been successfully deleted.')
+ expect(page).to have_content("The file has been successfully deleted.")
expect(page).to have_content(commit_message_for_delete)
expect(page).to have_no_content(file_name)
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb
index d1535d6519d..2525001f0fb 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_http_spec.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Push over HTTP using Git protocol version 2', :requires_git_protocol_v2 do
- it 'user pushes to the repository' do
+ context "Create" do
+ describe "Push over HTTP using Git protocol version 2", :requires_git_protocol_v2 do
+ it "user pushes to the repository" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a project to push to
- project = Resource::Project.fabricate! do |project|
- project.name = 'git-protocol-project'
- end
+ project = Resource::Project.fabricate! { |project|
+ project.name = "git-protocol-project"
+ }
- file_name = 'README.md'
- file_content = 'Test Git protocol v2'
- git_protocol = '2'
+ file_name = "README.md"
+ file_content = "Test Git protocol v2"
+ git_protocol = "2"
git_protocol_reported = nil
# Use Git to clone the project, push a file to it, and then check the
# supported Git protocol
Git::Repository.perform do |repository|
- username = 'GitLab QA'
- email = 'root@gitlab.com'
+ username = "GitLab QA"
+ email = "root@gitlab.com"
repository.uri = project.repository_http_location.uri
repository.use_default_credentials
@@ -31,7 +31,8 @@ module QA
git_protocol_reported = repository.push_with_git_protocol(
git_protocol,
file_name,
- file_content)
+ file_content
+ )
end
project.visit!
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb
index 48800cc81e5..d3d70ed7252 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/protocol_v2_push_ssh_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Push over SSH using Git protocol version 2', :requires_git_protocol_v2 do
+ context "Create" do
+ describe "Push over SSH using Git protocol version 2", :requires_git_protocol_v2 do
# Note: If you run this test against GDK make sure you've enabled sshd and
# enabled setting the Git protocol by adding `AcceptEnv GIT_PROTOCOL` to
# `sshd_config`
@@ -36,22 +36,22 @@ module QA
end
end
- it 'user pushes to the repository' do
+ it "user pushes to the repository" do
# Create a project to push to
- project = Resource::Project.fabricate! do |project|
- project.name = 'git-protocol-project'
- end
+ project = Resource::Project.fabricate! { |project|
+ project.name = "git-protocol-project"
+ }
- file_name = 'README.md'
- file_content = 'Test Git protocol v2'
- git_protocol = '2'
+ file_name = "README.md"
+ file_content = "Test Git protocol v2"
+ git_protocol = "2"
git_protocol_reported = nil
# Use Git to clone the project, push a file to it, and then check the
# supported Git protocol
Git::Repository.perform do |repository|
- username = 'GitLab QA'
- email = 'root@gitlab.com'
+ username = "GitLab QA"
+ email = "root@gitlab.com"
repository.uri = project.repository_ssh_location.uri
@@ -63,7 +63,8 @@ module QA
git_protocol_reported = repository.push_with_git_protocol(
git_protocol,
file_name,
- file_content)
+ file_content
+ )
ensure
repository.delete_ssh_key
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_http_private_token_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_http_private_token_spec.rb
index 1f4fb08accc..a3ecb5ba97a 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_http_private_token_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_http_private_token_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Git push over HTTP', :ldap_no_tls do
- it 'user using a personal access token pushes code to the repository' do
+ context "Create" do
+ describe "Git push over HTTP", :ldap_no_tls do
+ it "user using a personal access token pushes code to the repository" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
@@ -14,19 +14,19 @@ module QA
user.password = access_token
end
- push = Resource::Repository::ProjectPush.fabricate! do |push|
+ push = Resource::Repository::ProjectPush.fabricate! { |push|
push.user = user
- push.file_name = 'README.md'
- push.file_content = '# This is a test project'
- push.commit_message = 'Add README.md'
- end
+ push.file_name = "README.md"
+ push.file_content = "# This is a test project"
+ push.commit_message = "Add README.md"
+ }
push.project.visit!
Page::Project::Show.perform(&:wait_for_viewers_to_load)
- expect(page).to have_content('README.md')
- expect(page).to have_content('This is a test project')
+ expect(page).to have_content("README.md")
+ expect(page).to have_content("This is a test project")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb
index 99601e3d230..45506e19e62 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_mirroring_over_http_spec.rb
@@ -2,23 +2,23 @@
module QA
# https://gitlab.com/gitlab-org/quality/staging/issues/40
- context 'Create', :quarantine do
- describe 'Push mirror a repository over HTTP' do
- it 'configures and syncs a (push) mirrored repository' do
+ context "Create", :quarantine do
+ describe "Push mirror a repository over HTTP" do
+ it "configures and syncs a (push) mirrored repository" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- target_project = Resource::Project.fabricate! do |project|
- project.name = 'push-mirror-target-project'
- end
+ target_project = Resource::Project.fabricate! { |project|
+ project.name = "push-mirror-target-project"
+ }
target_project_uri = target_project.repository_http_location.uri
target_project_uri.user = Runtime::User.username
- source_project_push = Resource::Repository::ProjectPush.fabricate! do |push|
- push.file_name = 'README.md'
- push.file_content = '# This is a test project'
- push.commit_message = 'Add README.md'
- end
+ source_project_push = Resource::Repository::ProjectPush.fabricate! { |push|
+ push.file_name = "README.md"
+ push.file_content = "# This is a test project"
+ push.commit_message = "Add README.md"
+ }
source_project_push.project.visit!
Page::Project::Menu.perform(&:click_repository_settings)
@@ -36,8 +36,8 @@ module QA
# Check that the target project has the commit from the source
target_project.visit!
- expect(page).to have_content('README.md')
- expect(page).to have_content('This is a test project')
+ expect(page).to have_content("README.md")
+ expect(page).to have_content("This is a test project")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
index 243f0b83b77..291c1015eb3 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_file_size_spec.rb
@@ -2,14 +2,14 @@
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/37
- context 'Create', :quarantine do
- describe 'push after setting the file size limit via admin/application_settings' do
+ context "Create", :quarantine do
+ describe "push after setting the file size limit via admin/application_settings" do
before(:all) do
- push = Resource::Repository::ProjectPush.fabricate! do |p|
- p.file_name = 'README.md'
- p.file_content = '# This is a test project'
- p.commit_message = 'Add README.md'
- end
+ push = Resource::Repository::ProjectPush.fabricate! { |p|
+ p.file_name = "README.md"
+ p.file_content = "# This is a test project"
+ p.commit_message = "Add README.md"
+ }
@project = push.project
end
@@ -25,23 +25,23 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- set_file_size_limit('')
+ set_file_size_limit("")
end
- it 'push successful when the file size is under the limit' do
+ it "push successful when the file size is under the limit" do
set_file_size_limit(5)
expect(page).to have_content("Application settings saved successfully")
- push = push_new_file('oversize_file_1.bin', wait_for_push: true)
- expect(push.output).not_to have_content 'remote: fatal: pack exceeds maximum allowed size'
+ push = push_new_file("oversize_file_1.bin", wait_for_push: true)
+ expect(push.output).not_to have_content "remote: fatal: pack exceeds maximum allowed size"
end
- it 'push fails when the file size is above the limit' do
+ it "push fails when the file size is above the limit" do
set_file_size_limit(1)
expect(page).to have_content("Application settings saved successfully")
- push = push_new_file('oversize_file_2.bin', wait_for_push: false)
- expect(push.output).to have_content 'remote: fatal: pack exceeds maximum allowed size'
+ push = push_new_file("oversize_file_2.bin", wait_for_push: false)
+ expect(push.output).to have_content "remote: fatal: pack exceeds maximum allowed size"
end
def set_file_size_limit(limit)
@@ -63,7 +63,7 @@ module QA
p.project = @project
p.file_name = file_name
p.file_content = SecureRandom.random_bytes(2000000)
- p.commit_message = 'Adding a new file'
+ p.commit_message = "Adding a new file"
p.wait_for_push = wait_for_push
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb
index 58e6c160a3a..d369152acd0 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_over_http_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Git push over HTTP', :ldap_no_tls do
- it 'user pushes code to the repository' do
+ context "Create" do
+ describe "Git push over HTTP", :ldap_no_tls do
+ it "user pushes code to the repository" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project_push = Resource::Repository::ProjectPush.fabricate! do |push|
- push.file_name = 'README.md'
- push.file_content = '# This is a test project'
- push.commit_message = 'Add README.md'
- end
+ project_push = Resource::Repository::ProjectPush.fabricate! { |push|
+ push.file_name = "README.md"
+ push.file_content = "# This is a test project"
+ push.commit_message = "Add README.md"
+ }
project_push.project.visit!
- expect(page).to have_content('README.md')
- expect(page).to have_content('This is a test project')
+ expect(page).to have_content("README.md")
+ expect(page).to have_content("This is a test project")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb
index 4464fb812b7..b3fb52a63a9 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/push_protected_branch_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Protected branch support', :ldap_no_tls do
- let(:branch_name) { 'protected-branch' }
- let(:commit_message) { 'Protected push commit message' }
+ context "Create" do
+ describe "Protected branch support", :ldap_no_tls do
+ let(:branch_name) { "protected-branch" }
+ let(:commit_message) { "Protected push commit message" }
let(:project) do
Resource::Project.fabricate! do |resource|
- resource.name = 'protected-branch-project'
+ resource.name = "protected-branch-project"
end
end
@@ -20,11 +20,11 @@ module QA
# We need to clear localStorage because we're using it for the dropdown,
# and capybara doesn't do this for us.
# https://github.com/teamcapybara/capybara/issues/1702
- Capybara.execute_script 'localStorage.clear()'
+ Capybara.execute_script "localStorage.clear()"
end
- context 'when developers and maintainers are allowed to push to a protected branch' do
- it 'user with push rights successfully pushes to the protected branch' do
+ context "when developers and maintainers are allowed to push to a protected branch" do
+ it "user with push rights successfully pushes to the protected branch" do
create_protected_branch(allow_to_push: true)
push = push_new_file(branch_name)
@@ -33,16 +33,16 @@ module QA
end
end
- context 'when developers and maintainers are not allowed to push to a protected branch' do
- it 'user without push rights fails to push to the protected branch' do
+ context "when developers and maintainers are not allowed to push to a protected branch" do
+ it "user without push rights fails to push to the protected branch" do
create_protected_branch(allow_to_push: false)
push = push_new_file(branch_name)
expect(push.output)
- .to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
+ .to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
expect(push.output)
- .to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
+ .to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
end
end
@@ -58,9 +58,9 @@ module QA
def push_new_file(branch)
Resource::Repository::ProjectPush.fabricate! do |resource|
resource.project = project
- resource.file_name = 'new_file.md'
- resource.file_content = '# This is a new file'
- resource.commit_message = 'Add new_file.md'
+ resource.file_name = "new_file.md"
+ resource.file_content = "# This is a new file"
+ resource.commit_message = "Add new_file.md"
resource.branch_name = branch_name
resource.new_branch = false
resource.wait_for_push = false
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb
index 7223831d96f..d1dd67444b0 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/use_ssh_key_spec.rb
@@ -1,32 +1,32 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'SSH key support' do
+ context "Create" do
+ describe "SSH key support" do
# Note: If you run this test against GDK make sure you've enabled sshd
# See: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/run_qa_against_gdk.md
let(:key_title) { "key for ssh tests #{Time.now.to_f}" }
- it 'user adds an ssh key and pushes code to the repository' do
+ it "user adds an ssh key and pushes code to the repository" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- key = Resource::SSHKey.fabricate! do |resource|
+ key = Resource::SSHKey.fabricate! { |resource|
resource.title = key_title
- end
+ }
- project_push = Resource::Repository::ProjectPush.fabricate! do |push|
+ project_push = Resource::Repository::ProjectPush.fabricate! { |push|
push.ssh_key = key
- push.file_name = 'README.md'
- push.file_content = '# Test Use SSH Key'
- push.commit_message = 'Add README.md'
- end
+ push.file_name = "README.md"
+ push.file_content = "# Test Use SSH Key"
+ push.commit_message = "Add README.md"
+ }
project_push.project.visit!
- expect(page).to have_content('README.md')
- expect(page).to have_content('Test Use SSH Key')
+ expect(page).to have_content("README.md")
+ expect(page).to have_content("Test Use SSH Key")
Page::Main::Menu.perform(&:go_to_profile_settings)
Page::Profile::Menu.perform(&:click_ssh_keys)
diff --git a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb
index b862a7bd1ed..01fcc7a9190 100644
--- a/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/repository/user_views_raw_diff_patch_requests_spec.rb
@@ -1,30 +1,30 @@
# frozen_string_literal: true
module QA
- context 'Create' do
+ context "Create" do
# failure reported: https://gitlab.com/gitlab-org/quality/nightly/issues/42
# also failing in staging until the fix is picked into the next release:
# https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24533
- describe 'Commit data', :quarantine do
+ describe "Commit data", :quarantine do
before(:context) do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project_push = Resource::Repository::ProjectPush.fabricate! do |push|
- push.file_name = 'README.md'
- push.file_content = '# This is a test project'
- push.commit_message = 'Add README.md'
- end
+ project_push = Resource::Repository::ProjectPush.fabricate! { |push|
+ push.file_name = "README.md"
+ push.file_content = "# This is a test project"
+ push.commit_message = "Add README.md"
+ }
@project = project_push.project
# first file added has no parent commit, thus no diff data
# add second file to repo to enable diff from initial commit
- @commit_message = 'Add second file'
+ @commit_message = "Add second file"
Page::Project::Show.perform(&:create_new_file!)
Page::File::Form.perform do |f|
- f.add_name('second')
- f.add_content('second file content')
+ f.add_name("second")
+ f.add_content("second file content")
f.add_commit_message(@commit_message)
f.commit_changes
end
@@ -38,30 +38,30 @@ module QA
end
def raw_content
- find('pre').text
+ find("pre").text
end
- it 'user views raw email patch' do
- user = Resource::User.fabricate_via_api! do |user|
+ it "user views raw email patch" do
+ user = Resource::User.fabricate_via_api! { |user|
user.username = Runtime::User.username
- end
+ }
view_commit
Page::Project::Commit::Show.perform(&:select_email_patches)
expect(page).to have_content("From: #{user.name} <#{user.public_email}>")
- expect(page).to have_content('Subject: [PATCH] Add second file')
- expect(page).to have_content('diff --git a/second b/second')
+ expect(page).to have_content("Subject: [PATCH] Add second file")
+ expect(page).to have_content("diff --git a/second b/second")
end
- it 'user views raw commit diff' do
+ it "user views raw commit diff" do
view_commit
Page::Project::Commit::Show.perform(&:select_plain_diff)
- expect(raw_content).to start_with('diff --git a/second b/second')
- expect(page).to have_content('+second file content')
+ expect(raw_content).to start_with("diff --git a/second b/second")
+ expect(page).to have_content("+second file content")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
index f176ec31abd..82a3a664642 100644
--- a/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/web_ide/add_file_template_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Web IDE file templates' do
+ context "Create" do
+ describe "Web IDE file templates" do
include Runtime::Fixtures
def login
@@ -13,18 +13,18 @@ module QA
before(:all) do
login
- @project = Resource::Project.fabricate! do |project|
- project.name = 'file-template-project'
- project.description = 'Add file templates via the Web IDE'
- end
+ @project = Resource::Project.fabricate! { |project|
+ project.name = "file-template-project"
+ project.description = "Add file templates via the Web IDE"
+ }
@project.visit!
# Add a file via the regular Files view because the Web IDE isn't
# available unless there is a file present
Page::Project::Show.perform(&:create_first_new_file!)
Page::File::Form.perform do |page|
- page.add_name('dummy')
- page.add_content('Enable the Web IDE')
+ page.add_name("dummy")
+ page.add_content("Enable the Web IDE")
page.commit_changes
end
@@ -33,29 +33,29 @@ module QA
templates = [
{
- file_name: '.gitignore',
- name: 'Android',
- api_path: 'gitignores',
- api_key: 'Android'
+ file_name: ".gitignore",
+ name: "Android",
+ api_path: "gitignores",
+ api_key: "Android",
},
{
- file_name: '.gitlab-ci.yml',
- name: 'Julia',
- api_path: 'gitlab_ci_ymls',
- api_key: 'Julia'
+ file_name: ".gitlab-ci.yml",
+ name: "Julia",
+ api_path: "gitlab_ci_ymls",
+ api_key: "Julia",
},
{
- file_name: 'Dockerfile',
- name: 'Python',
- api_path: 'dockerfiles',
- api_key: 'Python'
+ file_name: "Dockerfile",
+ name: "Python",
+ api_path: "dockerfiles",
+ api_key: "Python",
},
{
- file_name: 'LICENSE',
- name: 'Mozilla Public License 2.0',
- api_path: 'licenses',
- api_key: 'mpl-2.0'
- }
+ file_name: "LICENSE",
+ name: "Mozilla Public License 2.0",
+ api_path: "licenses",
+ api_key: "mpl-2.0",
+ },
]
templates.each do |template|
@@ -72,7 +72,7 @@ module QA
expect(page.has_file?(template[:file_name])).to be_truthy
end
- expect(page).to have_button('Undo')
+ expect(page).to have_button("Undo")
expect(page).to have_content(content[0..100])
Page::Project::WebIDE::Edit.perform(&:commit_changes)
diff --git a/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb b/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb
index 29589ec870a..423d294ff6b 100644
--- a/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/wiki/create_edit_clone_push_wiki_spec.rb
@@ -1,24 +1,24 @@
# frozen_string_literal: true
module QA
- context 'Create' do
- describe 'Wiki management' do
+ context "Create" do
+ describe "Wiki management" do
def validate_content(content)
- expect(page).to have_content('Wiki was successfully updated')
+ expect(page).to have_content("Wiki was successfully updated")
expect(page).to have_content(/#{content}/)
end
- it 'user creates, edits, clones, and pushes to the wiki' do
+ it "user creates, edits, clones, and pushes to the wiki" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- wiki = Resource::Wiki.fabricate! do |resource|
- resource.title = 'Home'
- resource.content = '# My First Wiki Content'
- resource.message = 'Update home'
- end
+ wiki = Resource::Wiki.fabricate! { |resource|
+ resource.title = "Home"
+ resource.content = "# My First Wiki Content"
+ resource.message = "Update home"
+ }
- validate_content('My First Wiki Content')
+ validate_content("My First Wiki Content")
Page::Project::Wiki::Edit.perform(&:go_to_edit_page)
Page::Project::Wiki::New.perform do |page|
@@ -26,17 +26,17 @@ module QA
page.save_changes
end
- validate_content('My Second Wiki Content')
+ validate_content("My Second Wiki Content")
Resource::Repository::WikiPush.fabricate! do |push|
push.wiki = wiki
- push.file_name = 'Home.md'
- push.file_content = '# My Third Wiki Content'
- push.commit_message = 'Update Home.md'
+ push.file_name = "Home.md"
+ push.file_content = "# My Third Wiki Content"
+ push.commit_message = "Update Home.md"
end
Page::Project::Menu.perform(&:click_wiki)
- expect(page).to have_content('My Third Wiki Content')
+ expect(page).to have_content("My Third Wiki Content")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
index e444bc7ef1b..c685447e6de 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_variable/add_ci_variable_spec.rb
@@ -2,25 +2,25 @@
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/30
- context 'Verify', :quarantine do
- describe 'CI variable support' do
- it 'user adds a CI variable' do
+ context "Verify", :quarantine do
+ describe "CI variable support" do
+ it "user adds a CI variable" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Resource::CiVariable.fabricate! do |resource|
- resource.key = 'VARIABLE_KEY'
- resource.value = 'some CI variable'
+ resource.key = "VARIABLE_KEY"
+ resource.value = "some CI variable"
end
Page::Project::Settings::CICD.perform do |settings|
settings.expand_ci_variables do |page|
- expect(page).to have_field(with: 'VARIABLE_KEY')
- expect(page).not_to have_field(with: 'some CI variable')
+ expect(page).to have_field(with: "VARIABLE_KEY")
+ expect(page).not_to have_field(with: "some CI variable")
page.reveal_variables
- expect(page).to have_field(with: 'some CI variable')
+ expect(page).to have_field(with: "some CI variable")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb
index 2238d6c382e..316a34e56de 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/create_and_process_pipeline_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
module QA
- context 'Verify', :orchestrated, :docker do
- describe 'Pipeline creation and processing' do
+ context "Verify", :orchestrated, :docker do
+ describe "Pipeline creation and processing" do
let(:executor) { "qa-runner-#{Time.now.to_i}" }
after do
Service::Runner.new(executor).remove!
end
- it 'users creates a pipeline which gets processed' do
+ it "users creates a pipeline which gets processed" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
- project = Resource::Project.fabricate! do |project|
- project.name = 'project-with-pipelines'
- project.description = 'Project with CI/CD Pipelines.'
- end
+ project = Resource::Project.fabricate! { |project|
+ project.name = "project-with-pipelines"
+ project.description = "Project with CI/CD Pipelines."
+ }
Resource::Runner.fabricate! do |runner|
runner.project = project
@@ -26,8 +26,8 @@ module QA
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
- push.file_name = '.gitlab-ci.yml'
- push.commit_message = 'Add .gitlab-ci.yml'
+ push.file_name = ".gitlab-ci.yml"
+ push.commit_message = "Add .gitlab-ci.yml"
push.file_content = <<~EOF
test-success:
tags:
@@ -60,24 +60,24 @@ module QA
EOF
end
- expect(page).to have_content('Add .gitlab-ci.yml')
+ expect(page).to have_content("Add .gitlab-ci.yml")
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
- expect(page).to have_content('All 1')
- expect(page).to have_content('Add .gitlab-ci.yml')
+ expect(page).to have_content("All 1")
+ expect(page).to have_content("Add .gitlab-ci.yml")
- puts 'Waiting for the runner to process the pipeline'
+ puts "Waiting for the runner to process the pipeline"
sleep 15 # Runner should process all jobs within 15 seconds.
Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
expect(pipeline).to be_running
- expect(pipeline).to have_build('test-success', status: :success)
- expect(pipeline).to have_build('test-failure', status: :failed)
- expect(pipeline).to have_build('test-tags', status: :pending)
- expect(pipeline).to have_build('test-artifacts', status: :success)
+ expect(pipeline).to have_build("test-success", status: :success)
+ expect(pipeline).to have_build("test-failure", status: :failed)
+ expect(pipeline).to have_build("test-tags", status: :pending)
+ expect(pipeline).to have_build("test-artifacts", status: :success)
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb
index 3af7db751e7..b75c7612aa1 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/runner/register_runner_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
module QA
- context 'Verify', :docker do
- describe 'Runner registration' do
+ context "Verify", :docker do
+ describe "Runner registration" do
let(:executor) { "qa-runner-#{Time.now.to_i}" }
after do
Service::Runner.new(executor).remove!
end
- it 'user registers a new specific runner' do
+ it "user registers a new specific runner" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb
index aa01e5a618e..db8f0131135 100644
--- a/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb
+++ b/qa/qa/specs/features/browser_ui/6_release/deploy_key/add_deploy_key_spec.rb
@@ -2,20 +2,20 @@
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/staging/issues/26
- context 'Release', :quarantine do
- describe 'Deploy key creation' do
- it 'user adds a deploy key' do
+ context "Release", :quarantine do
+ describe "Deploy key creation" do
+ it "user adds a deploy key" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
key = Runtime::Key::RSA.new
- deploy_key_title = 'deploy key title'
+ deploy_key_title = "deploy key title"
deploy_key_value = key.public_key
- deploy_key = Resource::DeployKey.fabricate! do |resource|
+ deploy_key = Resource::DeployKey.fabricate! { |resource|
resource.title = deploy_key_title
resource.key = deploy_key_value
- end
+ }
expect(deploy_key.fingerprint).to eq key.fingerprint
diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
index 3f65eabc756..904a9ebee06 100644
--- a/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
+++ b/qa/qa/specs/features/browser_ui/6_release/deploy_key/clone_using_deploy_key_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'digest/sha1'
+require "digest/sha1"
module QA
# Failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/70
- context 'Release', :docker, :quarantine do
- describe 'Git clone using a deploy key' do
+ context "Release", :docker, :quarantine do
+ describe "Git clone using a deploy key" do
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
@@ -16,9 +16,9 @@ module QA
@runner_name = "qa-runner-#{Time.now.to_i}"
- @project = Resource::Project.fabricate! do |resource|
- resource.name = 'deploy-key-clone-project'
- end
+ @project = Resource::Project.fabricate! { |resource|
+ resource.name = "deploy-key-clone-project"
+ }
@repository_location = @project.repository_ssh_location
@@ -26,7 +26,7 @@ module QA
resource.project = @project
resource.name = @runner_name
resource.tags = %w[qa docker]
- resource.image = 'gitlab/gitlab-runner:ubuntu'
+ resource.image = "gitlab/gitlab-runner:ubuntu"
end
Page::Main::Menu.perform(&:sign_out)
@@ -39,7 +39,7 @@ module QA
keys = [
[Runtime::Key::RSA, 8192],
[Runtime::Key::ECDSA, 521],
- [Runtime::Key::ED25519]
+ [Runtime::Key::ED25519],
]
keys.each do |(key_class, bits)|
@@ -63,26 +63,26 @@ module QA
end
gitlab_ci = <<~YAML
- cat-config:
- script:
- - mkdir -p ~/.ssh
- - ssh-keyscan -p #{@repository_location.port} #{@repository_location.host} >> ~/.ssh/known_hosts
- - eval $(ssh-agent -s)
- - ssh-add -D
- - echo "$#{deploy_key_name}" | ssh-add -
- - git clone #{@repository_location.git_uri}
- - cd #{@project.name}
- - git checkout #{deploy_key_name}
- - sha1sum .gitlab-ci.yml
- tags:
- - qa
- - docker
+ cat-config:
+ script:
+ - mkdir -p ~/.ssh
+ - ssh-keyscan -p #{@repository_location.port} #{@repository_location.host} >> ~/.ssh/known_hosts
+ - eval $(ssh-agent -s)
+ - ssh-add -D
+ - echo "$#{deploy_key_name}" | ssh-add -
+ - git clone #{@repository_location.git_uri}
+ - cd #{@project.name}
+ - git checkout #{deploy_key_name}
+ - sha1sum .gitlab-ci.yml
+ tags:
+ - qa
+ - docker
YAML
Resource::Repository::ProjectPush.fabricate! do |resource|
resource.project = @project
- resource.file_name = '.gitlab-ci.yml'
- resource.commit_message = 'Add .gitlab-ci.yml'
+ resource.file_name = ".gitlab-ci.yml"
+ resource.commit_message = "Add .gitlab-ci.yml"
resource.file_content = gitlab_ci
resource.branch_name = deploy_key_name
resource.new_branch = true
diff --git a/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb b/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb
index 9f34e4218c1..4b58f63dcd8 100644
--- a/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb
+++ b/qa/qa/specs/features/browser_ui/6_release/deploy_token/add_deploy_token_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
module QA
- context 'Release' do
- describe 'Deploy token creation' do
- it 'user adds a deploy token' do
+ context "Release" do
+ describe "Deploy token creation" do
+ it "user adds a deploy token" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
- deploy_token_name = 'deploy token name'
+ deploy_token_name = "deploy token name"
deploy_token_expires_at = Date.today + 7 # 1 Week from now
- deploy_token = Resource::DeployToken.fabricate! do |resource|
+ deploy_token = Resource::DeployToken.fabricate! { |resource|
resource.name = deploy_token_name
resource.expires_at = deploy_token_expires_at
- end
+ }
expect(deploy_token.username.length).to be > 0
expect(deploy_token.password.length).to be > 0
diff --git a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb
index 2aa386f35ce..fcc13a1c6d0 100644
--- a/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb
+++ b/qa/qa/specs/features/browser_ui/7_configure/auto_devops/create_project_with_auto_devops_spec.rb
@@ -1,31 +1,31 @@
# frozen_string_literal: true
-require 'pathname'
+require "pathname"
module QA
# Transient failure issue: https://gitlab.com/gitlab-org/quality/nightly/issues/68
- context 'Configure' do
+ context "Configure" do
def login
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
end
- describe 'Auto DevOps support', :orchestrated, :kubernetes, :quarantine do
- context 'when rbac is enabled' do
+ describe "Auto DevOps support", :orchestrated, :kubernetes, :quarantine do
+ context "when rbac is enabled" do
before(:all) do
login
- @project = Resource::Project.fabricate! do |p|
- p.name = Runtime::Env.auto_devops_project_name || 'project-with-autodevops'
- p.description = 'Project with Auto DevOps'
- end
+ @project = Resource::Project.fabricate! { |p|
+ p.name = Runtime::Env.auto_devops_project_name || "project-with-autodevops"
+ p.description = "Project with Auto DevOps"
+ }
# Disable code_quality check in Auto DevOps pipeline as it takes
# too long and times out the test
Resource::CiVariable.fabricate! do |resource|
resource.project = @project
- resource.key = 'CODE_QUALITY_DISABLED'
- resource.value = '1'
+ resource.key = "CODE_QUALITY_DISABLED"
+ resource.value = "1"
end
# Create Auto DevOps compatible repo
@@ -33,8 +33,8 @@ module QA
push.project = @project
push.directory = Pathname
.new(__dir__)
- .join('../../../../../fixtures/auto_devops_rack')
- push.commit_message = 'Create Auto DevOps compatible rack application'
+ .join("../../../../../fixtures/auto_devops_rack")
+ push.commit_message = "Create Auto DevOps compatible rack application"
end
# Create and connect K8s cluster
@@ -53,13 +53,13 @@ module QA
@cluster&.remove!
end
- it 'runs auto devops' do
+ it "runs auto devops" do
@project.visit!
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('build')
+ pipeline.go_to_job("build")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
@@ -68,7 +68,7 @@ module QA
end
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('test')
+ pipeline.go_to_job("test")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
@@ -77,7 +77,7 @@ module QA
end
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('production')
+ pipeline.go_to_job("production")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 1200)
@@ -87,21 +87,21 @@ module QA
Page::Project::Menu.perform(&:click_operations_environments)
Page::Project::Operations::Environments::Index.perform do |index|
- index.go_to_environment('production')
+ index.go_to_environment("production")
end
Page::Project::Operations::Environments::Show.perform do |show|
show.view_deployment do
- expect(page).to have_content('Hello World!')
+ expect(page).to have_content("Hello World!")
end
end
end
- it 'user sets application secret variable and Auto DevOps passes it to container' do
+ it "user sets application secret variable and Auto DevOps passes it to container" do
# Set an application secret CI variable (prefixed with K8S_SECRET_)
Resource::CiVariable.fabricate! do |resource|
resource.project = @project
- resource.key = 'K8S_SECRET_OPTIONAL_MESSAGE'
- resource.value = 'You can see this application secret'
+ resource.key = "K8S_SECRET_OPTIONAL_MESSAGE"
+ resource.value = "You can see this application secret"
end
# Our current Auto DevOps implementation won't update the production
@@ -110,16 +110,16 @@ module QA
# Workaround: push new code and use the resultant pipeline.
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = @project
- push.commit_message = 'Force a Deployment change by pushing new code'
- push.file_name = 'new_file.txt'
- push.file_content = 'new file contents'
+ push.commit_message = "Force a Deployment change by pushing new code"
+ push.file_name = "new_file.txt"
+ push.file_content = "new file contents"
end
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('build')
+ pipeline.go_to_job("build")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
@@ -128,7 +128,7 @@ module QA
end
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('test')
+ pipeline.go_to_job("test")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 600)
@@ -137,7 +137,7 @@ module QA
end
Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.go_to_job('production')
+ pipeline.go_to_job("production")
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 1200)
@@ -146,27 +146,27 @@ module QA
Page::Project::Menu.perform(&:click_operations_environments)
Page::Project::Operations::Environments::Index.perform do |index|
- index.go_to_environment('production')
+ index.go_to_environment("production")
end
Page::Project::Operations::Environments::Show.perform do |show|
show.view_deployment do
- expect(page).to have_content('Hello World!')
- expect(page).to have_content('You can see this application secret')
+ expect(page).to have_content("Hello World!")
+ expect(page).to have_content("You can see this application secret")
end
end
end
end
end
- describe 'Auto DevOps', :smoke do
- it 'enables AutoDevOps by default' do
+ describe "Auto DevOps", :smoke do
+ it "enables AutoDevOps by default" do
login
- project = Resource::Project.fabricate! do |p|
- p.name = Runtime::Env.auto_devops_project_name || 'project-with-autodevops'
- p.description = 'Project with AutoDevOps'
- end
+ project = Resource::Project.fabricate! { |p|
+ p.name = Runtime::Env.auto_devops_project_name || "project-with-autodevops"
+ p.description = "Project with AutoDevOps"
+ }
project.visit!
@@ -179,15 +179,15 @@ module QA
push.project = project
push.directory = Pathname
.new(__dir__)
- .join('../../../../../fixtures/auto_devops_rack')
- push.commit_message = 'Create AutoDevOps compatible Project'
+ .join("../../../../../fixtures/auto_devops_rack")
+ push.commit_message = "Create AutoDevOps compatible Project"
end
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform(&:go_to_latest_pipeline)
Page::Project::Pipeline::Show.perform do |pipeline|
- expect(pipeline).to have_tag('Auto DevOps')
+ expect(pipeline).to have_tag("Auto DevOps")
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/7_configure/mattermost/create_group_with_mattermost_team_spec.rb b/qa/qa/specs/features/browser_ui/7_configure/mattermost/create_group_with_mattermost_team_spec.rb
index 7096864e011..1d2387e2aa9 100644
--- a/qa/qa/specs/features/browser_ui/7_configure/mattermost/create_group_with_mattermost_team_spec.rb
+++ b/qa/qa/specs/features/browser_ui/7_configure/mattermost/create_group_with_mattermost_team_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module QA
- context 'Configure', :orchestrated, :mattermost do
- describe 'Mattermost support' do
- it 'user creates a group with a mattermost team' do
+ context "Configure", :orchestrated, :mattermost do
+ describe "Mattermost support" do
+ it "user creates a group with a mattermost team" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.act { sign_in_using_credentials }
Page::Main::Menu.act { go_to_groups }
diff --git a/qa/qa/specs/features/sanity/framework_spec.rb b/qa/qa/specs/features/sanity/framework_spec.rb
index aae0f0ade71..4f38dabf33b 100644
--- a/qa/qa/specs/features/sanity/framework_spec.rb
+++ b/qa/qa/specs/features/sanity/framework_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
module QA
- context 'Framework sanity checks', :orchestrated, :framework do
- describe 'Passing orchestrated example' do
- it 'succeeds' do
+ context "Framework sanity checks", :orchestrated, :framework do
+ describe "Passing orchestrated example" do
+ it "succeeds" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
- expect(page).to have_text('Open source software to collaborate on code')
+ expect(page).to have_text("Open source software to collaborate on code")
end
end
- describe 'Failing orchestrated example' do
- it 'fails' do
+ describe "Failing orchestrated example" do
+ it "fails" do
Runtime::Browser.visit(:gitlab, Page::Main::Login)
expect(page).to have_text("These Aren't the Texts You're Looking For", wait: 1)
diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb
index 1bd8101c36d..8e15f4a5011 100644
--- a/qa/qa/specs/runner.rb
+++ b/qa/qa/specs/runner.rb
@@ -1,11 +1,11 @@
-require 'rspec/core'
+require "rspec/core"
module QA
module Specs
class Runner < Scenario::Template
attr_accessor :tty, :tags, :options
- DEFAULT_TEST_PATH_ARGS = ['--', File.expand_path('./features', __dir__)].freeze
+ DEFAULT_TEST_PATH_ARGS = ["--", File.expand_path("./features", __dir__)].freeze
def initialize
@tty = false
@@ -15,10 +15,10 @@ module QA
def perform
args = []
- args.push('--tty') if tty
+ args.push("--tty") if tty
if tags.any?
- tags.each { |tag| args.push(['--tag', tag.to_s]) }
+ tags.each { |tag| args.push(["--tag", tag.to_s]) }
else
args.push(%w[--tag ~orchestrated]) unless (%w[-t --tag] & options).any?
end
diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb
index 8aa7d6812ac..c8eeeb9588e 100644
--- a/qa/qa/support/api.rb
+++ b/qa/qa/support/api.rb
@@ -6,7 +6,8 @@ module QA
method: :post,
url: url,
payload: payload,
- verify_ssl: false)
+ verify_ssl: false
+ )
rescue RestClient::ExceptionWithResponse => e
e.response
end
@@ -15,7 +16,8 @@ module QA
RestClient::Request.execute(
method: :get,
url: url,
- verify_ssl: false)
+ verify_ssl: false
+ )
rescue RestClient::ExceptionWithResponse => e
e.response
end
@@ -24,7 +26,8 @@ module QA
RestClient::Request.execute(
method: :delete,
url: url,
- verify_ssl: false)
+ verify_ssl: false
+ )
rescue RestClient::ExceptionWithResponse => e
e.response
end
@@ -33,7 +36,8 @@ module QA
RestClient::Request.execute(
method: :head,
url: url,
- verify_ssl: false)
+ verify_ssl: false
+ )
rescue RestClient::ExceptionWithResponse => e
e.response
end
diff --git a/qa/qa/support/page/logging.rb b/qa/qa/support/page/logging.rb
index 69b6332ecce..41cb07f6aa0 100644
--- a/qa/qa/support/page/logging.rb
+++ b/qa/qa/support/page/logging.rb
@@ -35,9 +35,9 @@ module QA
def find_element(name, text: nil, wait: Capybara.default_max_wait_time)
msg = ["finding :#{name}"]
- msg << %Q(with text "#{text}") if text
+ msg << %(with text "#{text}") if text
msg << "(wait: #{wait})"
- log(msg.compact.join(' '))
+ log(msg.compact.join(" "))
element = super
@@ -63,15 +63,15 @@ module QA
end
def fill_element(name, content)
- masked_content = name.to_s.include?('password') ? '*****' : content
+ masked_content = name.to_s.include?("password") ? "*****" : content
- log(%Q(filling :#{name} with "#{masked_content}"))
+ log(%(filling :#{name} with "#{masked_content}"))
super
end
def select_element(name, value)
- log(%Q(selecting "#{value}" in :#{name}))
+ log(%(selecting "#{value}" in :#{name}))
super
end
@@ -80,11 +80,11 @@ module QA
found = super
msg = ["has_element? :#{name}"]
- msg << %Q(with text "#{text}") if text
+ msg << %(with text "#{text}") if text
msg << "(wait: #{wait})"
msg << "returned: #{found}"
- log(msg.compact.join(' '))
+ log(msg.compact.join(" "))
found
end
@@ -100,7 +100,7 @@ module QA
def has_text?(text)
found = super
- log(%Q{has_text?('#{text}') returned #{found}})
+ log(%{has_text?('#{text}') returned #{found}})
found
end
@@ -108,13 +108,13 @@ module QA
def has_no_text?(text)
found = super
- log(%Q{has_no_text?('#{text}') returned #{found}})
+ log(%{has_no_text?('#{text}') returned #{found}})
found
end
def finished_loading?
- log('waiting for loading to complete...')
+ log("waiting for loading to complete...")
now = Time.now
loaded = super
diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb
index 8be4e9f5365..4b01850db45 100644
--- a/qa/qa/support/retrier.rb
+++ b/qa/qa/support/retrier.rb
@@ -15,7 +15,7 @@ module QA
yield
rescue StandardError, RSpec::Expectations::ExpectationNotMetError
sleep sleep_interval
- reload_page.refresh if reload_page
+ reload_page&.refresh
attempts += 1
retry if attempts < max_attempts
diff --git a/qa/qa/tools/delete_subgroups.rb b/qa/qa/tools/delete_subgroups.rb
index c5c48e77ade..e5ec1f065bc 100644
--- a/qa/qa/tools/delete_subgroups.rb
+++ b/qa/qa/tools/delete_subgroups.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../qa'
+require_relative "../../qa"
# This script deletes all subgroups of a group specified by ENV['GROUP_NAME_OR_PATH']
# Required environment variables: PERSONAL_ACCESS_TOKEN and GITLAB_ADDRESS
@@ -13,14 +13,14 @@ module QA
include Support::Api
def initialize
- raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS']
- raise ArgumentError, "Please provide PERSONAL_ACCESS_TOKEN" unless ENV['PERSONAL_ACCESS_TOKEN']
+ raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV["GITLAB_ADDRESS"]
+ raise ArgumentError, "Please provide PERSONAL_ACCESS_TOKEN" unless ENV["PERSONAL_ACCESS_TOKEN"]
- @api_client = Runtime::API::Client.new(ENV['GITLAB_ADDRESS'], personal_access_token: ENV['PERSONAL_ACCESS_TOKEN'])
+ @api_client = Runtime::API::Client.new(ENV["GITLAB_ADDRESS"], personal_access_token: ENV["PERSONAL_ACCESS_TOKEN"])
end
def run
- STDOUT.puts 'Running...'
+ STDOUT.puts "Running..."
# Fetch group's id
group_id = fetch_group_id
@@ -58,7 +58,7 @@ module QA
end
def fetch_group_id
- group_search_response = get Runtime::API::Request.new(@api_client, "/groups", search: ENV['GROUP_NAME_OR_PATH'] || 'gitlab-qa-sandbox-group').url
+ group_search_response = get Runtime::API::Request.new(@api_client, "/groups", search: ENV["GROUP_NAME_OR_PATH"] || "gitlab-qa-sandbox-group").url
JSON.parse(group_search_response.body).first["id"]
end
end
diff --git a/qa/qa/tools/revoke_all_personal_access_tokens.rb b/qa/qa/tools/revoke_all_personal_access_tokens.rb
index 7484b633bf6..fbb6a26977c 100644
--- a/qa/qa/tools/revoke_all_personal_access_tokens.rb
+++ b/qa/qa/tools/revoke_all_personal_access_tokens.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require_relative '../../qa'
-require 'net/protocol.rb'
+require_relative "../../qa"
+require "net/protocol.rb"
# This script revokes all personal access tokens with the name of 'api-test-token' on the host specified by GITLAB_ADDRESS
# Required environment variables: GITLAB_USERNAME, GITLAB_PASSWORD and GITLAB_ADDRESS
# Run `rake revoke_personal_access_tokens`
@@ -12,25 +12,25 @@ module QA
def run
do_run
rescue Net::ReadTimeout
- STDOUT.puts 'Net::ReadTimeout during run. Trying again'
+ STDOUT.puts "Net::ReadTimeout during run. Trying again"
run
end
private
def do_run
- raise ArgumentError, "Please provide GITLAB_USERNAME" unless ENV['GITLAB_USERNAME']
- raise ArgumentError, "Please provide GITLAB_PASSWORD" unless ENV['GITLAB_PASSWORD']
- raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV['GITLAB_ADDRESS']
+ raise ArgumentError, "Please provide GITLAB_USERNAME" unless ENV["GITLAB_USERNAME"]
+ raise ArgumentError, "Please provide GITLAB_PASSWORD" unless ENV["GITLAB_PASSWORD"]
+ raise ArgumentError, "Please provide GITLAB_ADDRESS" unless ENV["GITLAB_ADDRESS"]
- STDOUT.puts 'Running...'
+ STDOUT.puts "Running..."
- Runtime::Browser.visit(ENV['GITLAB_ADDRESS'], Page::Main::Login)
+ Runtime::Browser.visit(ENV["GITLAB_ADDRESS"], Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
Page::Main::Menu.perform(&:go_to_profile_settings)
Page::Profile::Menu.perform(&:click_access_tokens)
- token_name = 'api-test-token'
+ token_name = "api-test-token"
Page::Profile::PersonalAccessTokens.perform do |page|
while page.has_token_row_for_name?(token_name)
diff --git a/qa/qa/vendor/github/page/login.rb b/qa/qa/vendor/github/page/login.rb
index 6d8f9aa7c12..561d45944da 100644
--- a/qa/qa/vendor/github/page/login.rb
+++ b/qa/qa/vendor/github/page/login.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'capybara/dsl'
+require "capybara/dsl"
module QA
module Vendor
@@ -8,12 +8,12 @@ module QA
module Page
class Login < Page::Base
def login
- fill_in 'login', with: QA::Runtime::Env.github_username
- fill_in 'password', with: QA::Runtime::Env.github_password
- click_on 'Sign in'
+ fill_in "login", with: QA::Runtime::Env.github_username
+ fill_in "password", with: QA::Runtime::Env.github_password
+ click_on "Sign in"
unless has_no_text?("Authorize GitLab-OAuth")
- click_on 'Authorize gitlab-qa' if has_button?('Authorize gitlab-qa')
+ click_on "Authorize gitlab-qa" if has_button?("Authorize gitlab-qa")
end
end
end
diff --git a/qa/qa/vendor/saml_idp/page/login.rb b/qa/qa/vendor/saml_idp/page/login.rb
index 9c1f9904a7a..1189ec9a124 100644
--- a/qa/qa/vendor/saml_idp/page/login.rb
+++ b/qa/qa/vendor/saml_idp/page/login.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'capybara/dsl'
+require "capybara/dsl"
module QA
module Vendor
@@ -8,9 +8,9 @@ module QA
module Page
class Login < Page::Base
def login
- fill_in 'username', with: 'user1'
- fill_in 'password', with: 'user1pass'
- click_on 'Login'
+ fill_in "username", with: "user1"
+ fill_in "password", with: "user1pass"
+ click_on "Login"
end
end
end
diff --git a/qa/spec/factory/resource/user_spec.rb b/qa/spec/factory/resource/user_spec.rb
index 820c506b715..1cd46d4fabc 100644
--- a/qa/spec/factory/resource/user_spec.rb
+++ b/qa/spec/factory/resource/user_spec.rb
@@ -4,32 +4,32 @@ describe QA::Resource::User do
describe "#fabricate_via_api!" do
Response = Struct.new(:code, :body)
- it 'fetches an existing user' do
+ it "fetches an existing user" do
existing_users = [
{
- id: '0',
- name: 'name',
- username: 'name',
- web_url: ''
- }
+ id: "0",
+ name: "name",
+ username: "name",
+ web_url: "",
+ },
]
- users_response = Response.new('200', JSON.dump(existing_users))
- single_user_response = Response.new('200', JSON.dump(existing_users.first))
+ users_response = Response.new("200", JSON.dump(existing_users))
+ single_user_response = Response.new("200", JSON.dump(existing_users.first))
expect(subject).to receive(:api_get_from).with("/users?username=name").and_return(users_response)
expect(subject).to receive(:api_get_from).with("/users/0").and_return(single_user_response)
- subject.username = 'name'
+ subject.username = "name"
subject.fabricate_via_api!
expect(subject.api_response).to eq(existing_users.first)
end
- it 'tries to create a user if it does not exist' do
- expect(subject).to receive(:api_get_from).with("/users?username=foo").and_return(Response.new('200', '[]'))
- expect(subject).to receive(:api_post).and_return({ web_url: '' })
+ it "tries to create a user if it does not exist" do
+ expect(subject).to receive(:api_get_from).with("/users?username=foo").and_return(Response.new("200", "[]"))
+ expect(subject).to receive(:api_post).and_return({web_url: ""})
- subject.username = 'foo'
+ subject.username = "foo"
subject.fabricate_via_api!
end
end
diff --git a/qa/spec/git/location_spec.rb b/qa/spec/git/location_spec.rb
index aef906ee836..96ba366e796 100644
--- a/qa/spec/git/location_spec.rb
+++ b/qa/spec/git/location_spec.rb
@@ -1,53 +1,53 @@
describe QA::Git::Location do
- describe '.new' do
- context 'when URI starts with ssh://' do
- context 'when URI has port' do
- it 'parses correctly' do
+ describe ".new" do
+ context "when URI starts with ssh://" do
+ context "when URI has port" do
+ it "parses correctly" do
uri = described_class
- .new('ssh://git@qa.test:2222/sandbox/qa/repo.git')
+ .new("ssh://git@qa.test:2222/sandbox/qa/repo.git")
- expect(uri.user).to eq('git')
- expect(uri.host).to eq('qa.test')
+ expect(uri.user).to eq("git")
+ expect(uri.host).to eq("qa.test")
expect(uri.port).to eq(2222)
- expect(uri.path).to eq('/sandbox/qa/repo.git')
+ expect(uri.path).to eq("/sandbox/qa/repo.git")
end
end
- context 'when URI does not have port' do
- it 'parses correctly' do
+ context "when URI does not have port" do
+ it "parses correctly" do
uri = described_class
- .new('ssh://git@qa.test/sandbox/qa/repo.git')
+ .new("ssh://git@qa.test/sandbox/qa/repo.git")
- expect(uri.user).to eq('git')
- expect(uri.host).to eq('qa.test')
+ expect(uri.user).to eq("git")
+ expect(uri.host).to eq("qa.test")
expect(uri.port).to eq(22)
- expect(uri.path).to eq('/sandbox/qa/repo.git')
+ expect(uri.path).to eq("/sandbox/qa/repo.git")
end
end
end
- context 'when URI does not start with ssh://' do
- context 'when host does not have colons' do
- it 'parses correctly' do
+ context "when URI does not start with ssh://" do
+ context "when host does not have colons" do
+ it "parses correctly" do
uri = described_class
- .new('git@qa.test:sandbox/qa/repo.git')
+ .new("git@qa.test:sandbox/qa/repo.git")
- expect(uri.user).to eq('git')
- expect(uri.host).to eq('qa.test')
+ expect(uri.user).to eq("git")
+ expect(uri.host).to eq("qa.test")
expect(uri.port).to eq(22)
- expect(uri.path).to eq('/sandbox/qa/repo.git')
+ expect(uri.path).to eq("/sandbox/qa/repo.git")
end
end
- context 'when host has a colon' do
- it 'parses correctly' do
+ context "when host has a colon" do
+ it "parses correctly" do
uri = described_class
- .new('[git@qa:test]:sandbox/qa/repo.git')
+ .new("[git@qa:test]:sandbox/qa/repo.git")
- expect(uri.user).to eq('git')
- expect(uri.host).to eq('qa%3Atest')
+ expect(uri.user).to eq("git")
+ expect(uri.host).to eq("qa%3Atest")
expect(uri.port).to eq(22)
- expect(uri.path).to eq('/sandbox/qa/repo.git')
+ expect(uri.path).to eq("/sandbox/qa/repo.git")
end
end
end
diff --git a/qa/spec/git/repository_spec.rb b/qa/spec/git/repository_spec.rb
index 62c81050bd9..f76f4a94996 100644
--- a/qa/spec/git/repository_spec.rb
+++ b/qa/spec/git/repository_spec.rb
@@ -1,13 +1,13 @@
describe QA::Git::Repository do
include Helpers::StubENV
- shared_context 'git directory' do
+ shared_context "git directory" do
let(:repository) { described_class.new }
let(:tmp_git_dir) { Dir.mktmpdir }
let(:tmp_netrc_dir) { Dir.mktmpdir }
before do
- stub_env('GITLAB_USERNAME', 'root')
+ stub_env("GITLAB_USERNAME", "root")
cd_empty_temp_directory
set_bad_uri
@@ -26,34 +26,34 @@ describe QA::Git::Repository do
end
def set_bad_uri
- repository.uri = 'http://foo/bar.git'
+ repository.uri = "http://foo/bar.git"
end
end
- context 'with default credentials' do
- include_context 'git directory' do
+ context "with default credentials" do
+ include_context "git directory" do
before do
repository.use_default_credentials
end
end
- describe '#clone' do
- it 'is unable to resolve host' do
+ describe "#clone" do
+ it "is unable to resolve host" do
expect(repository.clone).to include("fatal: unable to access 'http://root@foo/bar.git/'")
end
end
- describe '#push_changes' do
+ describe "#push_changes" do
before do
`git init` # need a repo to push from
end
- it 'fails to push changes' do
+ it "fails to push changes" do
expect(repository.push_changes).to include("error: failed to push some refs to 'http://root@foo/bar.git'")
end
end
- describe '#git_protocol=' do
+ describe "#git_protocol=" do
[0, 1, 2].each do |version|
it "configures git to use protocol version #{version}" do
expect(repository).to receive(:run).with("git config protocol.version #{version}")
@@ -61,57 +61,57 @@ describe QA::Git::Repository do
end
end
- it 'raises an error if the version is unsupported' do
- expect { repository.git_protocol = 'foo' }.to raise_error(ArgumentError, "Please specify the protocol you would like to use: 0, 1, or 2")
+ it "raises an error if the version is unsupported" do
+ expect { repository.git_protocol = "foo" }.to raise_error(ArgumentError, "Please specify the protocol you would like to use: 0, 1, or 2")
end
end
- describe '#fetch_supported_git_protocol' do
+ describe "#fetch_supported_git_protocol" do
it "reports the detected version" do
expect(repository).to receive(:run).and_return("packet: git< version 2")
- expect(repository.fetch_supported_git_protocol).to eq('2')
+ expect(repository.fetch_supported_git_protocol).to eq("2")
end
- it 'reports unknown if version is unknown' do
+ it "reports unknown if version is unknown" do
expect(repository).to receive(:run).and_return("packet: git< version -1")
- expect(repository.fetch_supported_git_protocol).to eq('unknown')
+ expect(repository.fetch_supported_git_protocol).to eq("unknown")
end
- it 'reports unknown if content does not identify a version' do
+ it "reports unknown if content does not identify a version" do
expect(repository).to receive(:run).and_return("foo")
- expect(repository.fetch_supported_git_protocol).to eq('unknown')
+ expect(repository.fetch_supported_git_protocol).to eq("unknown")
end
end
- describe '#use_default_credentials' do
- it 'adds credentials to .netrc' do
- expect(File.read(File.join(tmp_netrc_dir, '.netrc')))
+ describe "#use_default_credentials" do
+ it "adds credentials to .netrc" do
+ expect(File.read(File.join(tmp_netrc_dir, ".netrc")))
.to eq("machine foo login #{QA::Runtime::User.default_username} password #{QA::Runtime::User.default_password}\n")
end
end
end
- context 'with specific credentials' do
- include_context 'git directory'
+ context "with specific credentials" do
+ include_context "git directory"
- context 'before setting credentials' do
- it 'does not add credentials to .netrc' do
+ context "before setting credentials" do
+ it "does not add credentials to .netrc" do
expect(repository).not_to receive(:save_netrc_content)
end
end
- describe '#password=' do
- it 'raises an error if no username was given' do
- expect { repository.password = 'foo' }
+ describe "#password=" do
+ it "raises an error if no username was given" do
+ expect { repository.password = "foo" }
.to raise_error(QA::Git::Repository::InvalidCredentialsError,
"Please provide a username when setting a password")
end
- it 'adds credentials to .netrc' do
- repository.username = 'user'
- repository.password = 'foo'
+ it "adds credentials to .netrc" do
+ repository.username = "user"
+ repository.password = "foo"
- expect(File.read(File.join(tmp_netrc_dir, '.netrc')))
+ expect(File.read(File.join(tmp_netrc_dir, ".netrc")))
.to eq("machine foo login user password foo\n")
end
end
diff --git a/qa/spec/helpers/stub_env.rb b/qa/spec/helpers/stub_env.rb
index 62b4a1df787..9d6eb7cf470 100644
--- a/qa/spec/helpers/stub_env.rb
+++ b/qa/spec/helpers/stub_env.rb
@@ -13,7 +13,7 @@ module Helpers
private
- STUBBED_KEY = '__STUBBED__'.freeze
+ STUBBED_KEY = "__STUBBED__".freeze
def add_stubbed_value(key, value)
allow(ENV).to receive(:[]).with(key).and_return(value)
diff --git a/qa/spec/page/base_spec.rb b/qa/spec/page/base_spec.rb
index 32a350f2154..d9b037a9599 100644
--- a/qa/spec/page/base_spec.rb
+++ b/qa/spec/page/base_spec.rb
@@ -1,88 +1,88 @@
describe QA::Page::Base do
- describe 'page helpers' do
- it 'exposes helpful page helpers' do
+ describe "page helpers" do
+ it "exposes helpful page helpers" do
expect(subject).to respond_to :refresh, :wait, :scroll_to
end
end
- describe '.view', 'DSL for defining view partials' do
+ describe ".view", "DSL for defining view partials" do
subject do
Class.new(described_class) do
- view 'path/to/some/view.html.haml' do
- element :something, 'string pattern' # rubocop:disable QA/ElementWithPattern
+ view "path/to/some/view.html.haml" do
+ element :something, "string pattern" # rubocop:disable QA/ElementWithPattern
element :something_else, /regexp pattern/ # rubocop:disable QA/ElementWithPattern
end
- view 'path/to/some/_partial.html.haml' do
- element :another_element, 'string pattern' # rubocop:disable QA/ElementWithPattern
+ view "path/to/some/_partial.html.haml" do
+ element :another_element, "string pattern" # rubocop:disable QA/ElementWithPattern
end
end
end
- it 'makes it possible to define page views' do
+ it "makes it possible to define page views" do
expect(subject.views.size).to eq 2
- expect(subject.views).to all(be_an_instance_of QA::Page::View)
+ expect(subject.views).to all(be_an_instance_of(QA::Page::View))
end
- it 'populates views objects with data about elements' do
+ it "populates views objects with data about elements" do
expect(subject.elements.size).to eq 3
- expect(subject.elements).to all(be_an_instance_of QA::Page::Element)
+ expect(subject.elements).to all(be_an_instance_of(QA::Page::Element))
expect(subject.elements.map(&:name))
.to eq [:something, :something_else, :another_element]
end
end
- describe '.errors' do
- let(:view) { double('view') }
+ describe ".errors" do
+ let(:view) { double("view") }
- context 'when page has views and elements defined' do
+ context "when page has views and elements defined" do
before do
allow(described_class).to receive(:views)
.and_return([view])
- allow(view).to receive(:errors).and_return(['some error'])
+ allow(view).to receive(:errors).and_return(["some error"])
end
- it 'iterates views composite and returns errors' do
- expect(described_class.errors).to eq ['some error']
+ it "iterates views composite and returns errors" do
+ expect(described_class.errors).to eq ["some error"]
end
end
- context 'when page has no views and elements defined' do
+ context "when page has no views and elements defined" do
before do
allow(described_class).to receive(:views).and_return([])
end
- it 'appends an error about missing views / elements block' do
+ it "appends an error about missing views / elements block" do
expect(described_class.errors)
- .to include 'Page class does not have views / elements defined!'
+ .to include "Page class does not have views / elements defined!"
end
end
end
- describe '#wait' do
+ describe "#wait" do
subject { Class.new(described_class).new }
- context 'when the condition is true' do
- it 'does not refresh' do
+ context "when the condition is true" do
+ it "does not refresh" do
expect(subject).not_to receive(:refresh)
subject.wait(max: 0.01) { true }
end
- it 'returns true' do
+ it "returns true" do
expect(subject.wait(max: 0.1) { true }).to be_truthy
end
end
- context 'when the condition is false' do
- it 'refreshes' do
+ context "when the condition is false" do
+ it "refreshes" do
expect(subject).to receive(:refresh).at_least(:once)
subject.wait(max: 0.01) { false }
end
- it 'returns false' do
+ it "returns false" do
allow(subject).to receive(:refresh)
expect(subject.wait(max: 0.01) { false }).to be_falsey
diff --git a/qa/spec/page/element_spec.rb b/qa/spec/page/element_spec.rb
index 8598c57ad34..5b485c27b3b 100644
--- a/qa/spec/page/element_spec.rb
+++ b/qa/spec/page/element_spec.rb
@@ -1,51 +1,51 @@
describe QA::Page::Element do
- describe '#selector' do
- it 'transforms element name into QA-specific selector' do
+ describe "#selector" do
+ it "transforms element name into QA-specific selector" do
expect(described_class.new(:sign_in_button).selector)
- .to eq 'qa-sign-in-button'
+ .to eq "qa-sign-in-button"
end
end
- describe '#selector_css' do
- it 'transforms element name into QA-specific clickable css selector' do
+ describe "#selector_css" do
+ it "transforms element name into QA-specific clickable css selector" do
expect(described_class.new(:sign_in_button).selector_css)
- .to eq '.qa-sign-in-button'
+ .to eq ".qa-sign-in-button"
end
end
- context 'when pattern is an expression' do
+ context "when pattern is an expression" do
subject { described_class.new(:something, /button 'Sign in'/) }
- it 'matches when there is a match' do
+ it "matches when there is a match" do
expect(subject.matches?("button 'Sign in'")).to be true
end
- it 'does not match if pattern is not present' do
+ it "does not match if pattern is not present" do
expect(subject.matches?("button 'Sign out'")).to be false
end
end
- context 'when pattern is a string' do
- subject { described_class.new(:something, 'button') }
+ context "when pattern is a string" do
+ subject { described_class.new(:something, "button") }
- it 'matches when there is match' do
- expect(subject.matches?('some button in the view')).to be true
+ it "matches when there is match" do
+ expect(subject.matches?("some button in the view")).to be true
end
- it 'does not match if pattern is not present' do
- expect(subject.matches?('text_field :name')).to be false
+ it "does not match if pattern is not present" do
+ expect(subject.matches?("text_field :name")).to be false
end
end
- context 'when pattern is not provided' do
+ context "when pattern is not provided" do
subject { described_class.new(:some_name) }
- it 'matches when QA specific selector is present' do
- expect(subject.matches?('some qa-some-name selector')).to be true
+ it "matches when QA specific selector is present" do
+ expect(subject.matches?("some qa-some-name selector")).to be true
end
- it 'does not match if QA selector is not there' do
- expect(subject.matches?('some_name selector')).to be false
+ it "does not match if QA selector is not there" do
+ expect(subject.matches?("some_name selector")).to be false
end
end
end
diff --git a/qa/spec/page/logging_spec.rb b/qa/spec/page/logging_spec.rb
index 707a7ff6d98..451dd5f0713 100644
--- a/qa/spec/page/logging_spec.rb
+++ b/qa/spec/page/logging_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'capybara/dsl'
-require 'logger'
+require "capybara/dsl"
+require "logger"
describe QA::Support::Page::Logging do
let(:page) { double.as_null_object }
@@ -12,22 +12,22 @@ describe QA::Support::Page::Logging do
QA::Runtime::Logger.logger = logger
allow(Capybara).to receive(:current_session).and_return(page)
- allow(page).to receive(:current_url).and_return('http://current-url')
+ allow(page).to receive(:current_url).and_return("http://current-url")
allow(page).to receive(:has_css?).with(any_args).and_return(true)
end
subject do
- Class.new(QA::Page::Base) do
+ Class.new(QA::Page::Base) {
prepend QA::Support::Page::Logging
- end.new
+ }.new
end
- it 'logs refresh' do
+ it "logs refresh" do
expect { subject.refresh }
.to output(%r{refreshing http://current-url}).to_stdout_from_any_process
end
- it 'logs wait' do
+ it "logs wait" do
expect { subject.wait(max: 0) {} }
.to output(/next wait uses reload: true/).to_stdout_from_any_process
expect { subject.wait(max: 0) {} }
@@ -36,7 +36,7 @@ describe QA::Support::Page::Logging do
.to output(/ended wait after .* seconds$/).to_stdout_from_any_process
end
- it 'logs wait with reload false' do
+ it "logs wait with reload false" do
expect { subject.wait(max: 0, reload: false) {} }
.to output(/next wait uses reload: false/).to_stdout_from_any_process
expect { subject.wait(max: 0, reload: false) {} }
@@ -45,87 +45,87 @@ describe QA::Support::Page::Logging do
.to output(/ended wait after .* seconds$/).to_stdout_from_any_process
end
- it 'logs scroll_to' do
+ it "logs scroll_to" do
expect { subject.scroll_to(:element) }
.to output(/scrolling to :element/).to_stdout_from_any_process
end
- it 'logs asset_exists?' do
- expect { subject.asset_exists?('http://asset-url') }
+ it "logs asset_exists?" do
+ expect { subject.asset_exists?("http://asset-url") }
.to output(%r{asset_exists\? http://asset-url returned false}).to_stdout_from_any_process
end
- it 'logs find_element' do
+ it "logs find_element" do
expect { subject.find_element(:element) }
.to output(/finding :element/).to_stdout_from_any_process
expect { subject.find_element(:element) }
.to output(/found :element/).to_stdout_from_any_process
end
- it 'logs find_element with text' do
- expect { subject.find_element(:element, text: 'foo') }
+ it "logs find_element with text" do
+ expect { subject.find_element(:element, text: "foo") }
.to output(/finding :element with text "foo"/).to_stdout_from_any_process
- expect { subject.find_element(:element, text: 'foo') }
+ expect { subject.find_element(:element, text: "foo") }
.to output(/found :element/).to_stdout_from_any_process
end
- it 'logs click_element' do
+ it "logs click_element" do
expect { subject.click_element(:element) }
.to output(/clicking :element/).to_stdout_from_any_process
end
- it 'logs fill_element' do
- expect { subject.fill_element(:element, 'foo') }
+ it "logs fill_element" do
+ expect { subject.fill_element(:element, "foo") }
.to output(/filling :element with "foo"/).to_stdout_from_any_process
end
- it 'logs has_element?' do
+ it "logs has_element?" do
expect { subject.has_element?(:element) }
.to output(/has_element\? :element \(wait: 2\) returned: true/).to_stdout_from_any_process
end
- it 'logs has_element? with text' do
+ it "logs has_element? with text" do
expect { subject.has_element?(:element, text: "some text") }
.to output(/has_element\? :element with text \"some text\" \(wait: 2\) returned: true/).to_stdout_from_any_process
end
- it 'logs has_no_element?' do
+ it "logs has_no_element?" do
allow(page).to receive(:has_no_css?).and_return(true)
expect { subject.has_no_element?(:element) }
.to output(/has_no_element\? :element returned true/).to_stdout_from_any_process
end
- it 'logs has_text?' do
+ it "logs has_text?" do
allow(page).to receive(:has_text?).and_return(true)
- expect { subject.has_text? 'foo' }
+ expect { subject.has_text? "foo" }
.to output(/has_text\?\('foo'\) returned true/).to_stdout_from_any_process
end
- it 'logs has_no_text?' do
- allow(page).to receive(:has_no_text?).with('foo').and_return(true)
+ it "logs has_no_text?" do
+ allow(page).to receive(:has_no_text?).with("foo").and_return(true)
- expect { subject.has_no_text? 'foo' }
+ expect { subject.has_no_text? "foo" }
.to output(/has_no_text\?\('foo'\) returned true/).to_stdout_from_any_process
end
- it 'logs finished_loading?' do
+ it "logs finished_loading?" do
expect { subject.finished_loading? }
.to output(/waiting for loading to complete\.\.\./).to_stdout_from_any_process
expect { subject.finished_loading? }
.to output(/loading complete after .* seconds$/).to_stdout_from_any_process
end
- it 'logs within_element' do
+ it "logs within_element" do
expect { subject.within_element(:element) }
.to output(/within element :element/).to_stdout_from_any_process
expect { subject.within_element(:element) }
.to output(/end within element :element/).to_stdout_from_any_process
end
- context 'all_elements' do
- it 'logs the number of elements found' do
+ context "all_elements" do
+ it "logs the number of elements found" do
allow(page).to receive(:all).and_return([1, 2])
expect { subject.all_elements(:element) }
@@ -134,7 +134,7 @@ describe QA::Support::Page::Logging do
.to output(/found 2 :element/).to_stdout_from_any_process
end
- it 'logs 0 if no elements are found' do
+ it "logs 0 if no elements are found" do
allow(page).to receive(:all).and_return([])
expect { subject.all_elements(:element) }
diff --git a/qa/spec/page/validator_spec.rb b/qa/spec/page/validator_spec.rb
index 0ae6e66d767..7c243fd638b 100644
--- a/qa/spec/page/validator_spec.rb
+++ b/qa/spec/page/validator_spec.rb
@@ -1,33 +1,33 @@
describe QA::Page::Validator do
- describe '#constants' do
+ describe "#constants" do
subject do
described_class.new(QA::Page::Project)
end
- it 'returns all constants that are module children' do
+ it "returns all constants that are module children" do
expect(subject.constants)
.to include QA::Page::Project::New, QA::Page::Project::Settings
end
end
- describe '#descendants' do
+ describe "#descendants" do
subject do
described_class.new(QA::Page::Project)
end
- it 'recursively returns all descendants that are page objects' do
+ it "recursively returns all descendants that are page objects" do
expect(subject.descendants)
.to include QA::Page::Project::New, QA::Page::Project::Settings::Repository
end
- it 'does not return modules that aggregate page objects' do
+ it "does not return modules that aggregate page objects" do
expect(subject.descendants)
.not_to include QA::Page::Project::Settings
end
end
- context 'when checking validation errors' do
- let(:view) { spy('view') }
+ context "when checking validation errors" do
+ let(:view) { spy("view") }
before do
allow(QA::Page::Admin::Settings::Repository)
@@ -38,38 +38,38 @@ describe QA::Page::Validator do
described_class.new(QA::Page::Admin)
end
- context 'when there are no validation errors' do
+ context "when there are no validation errors" do
before do
allow(view).to receive(:errors).and_return([])
end
- describe '#errors' do
- it 'does not return errors' do
+ describe "#errors" do
+ it "does not return errors" do
expect(subject.errors).to be_empty
end
end
- describe '#validate!' do
- it 'does not raise error' do
+ describe "#validate!" do
+ it "does not raise error" do
expect { subject.validate! }.not_to raise_error
end
end
end
- context 'when there are validation errors' do
+ context "when there are validation errors" do
before do
allow(view).to receive(:errors)
- .and_return(['some error', 'another error'])
+ .and_return(["some error", "another error"])
end
- describe '#errors' do
- it 'returns errors' do
+ describe "#errors" do
+ it "returns errors" do
expect(subject.errors.count).to eq 2
end
end
- describe '#validate!' do
- it 'raises validation error' do
+ describe "#validate!" do
+ it "raises validation error" do
expect { subject.validate! }
.to raise_error described_class::ValidationError
end
diff --git a/qa/spec/page/view_spec.rb b/qa/spec/page/view_spec.rb
index d7b3ccd316d..ac33de53a42 100644
--- a/qa/spec/page/view_spec.rb
+++ b/qa/spec/page/view_spec.rb
@@ -1,69 +1,69 @@
describe QA::Page::View do
let(:element) do
- double('element', name: :something, pattern: /some element/)
+ double("element", name: :something, pattern: /some element/)
end
- subject { described_class.new('some/file.html', [element]) }
+ subject { described_class.new("some/file.html", [element]) }
- describe '.evaluate' do
- it 'evaluates a block and returns a DSL object' do
- results = described_class.evaluate do
+ describe ".evaluate" do
+ it "evaluates a block and returns a DSL object" do
+ results = described_class.evaluate {
element :something
element :something_else
- end
+ }
expect(results.elements.size).to eq 2
end
end
- describe '#pathname' do
- it 'returns an absolute and clean path to the view' do
- expect(subject.pathname.to_s).not_to include 'qa/page/'
- expect(subject.pathname.to_s).to include 'some/file.html'
+ describe "#pathname" do
+ it "returns an absolute and clean path to the view" do
+ expect(subject.pathname.to_s).not_to include "qa/page/"
+ expect(subject.pathname.to_s).to include "some/file.html"
end
end
- describe '#errors' do
- context 'when view partial is present' do
+ describe "#errors" do
+ context "when view partial is present" do
before do
allow(subject.pathname).to receive(:readable?)
.and_return(true)
end
- context 'when pattern is found' do
+ context "when pattern is found" do
before do
allow(::File).to receive(:foreach)
- .and_yield('some element').once
+ .and_yield("some element").once
allow(element).to receive(:matches?)
- .with('some element').and_return(true)
+ .with("some element").and_return(true)
end
- it 'walks through the view and asserts on elements existence' do
+ it "walks through the view and asserts on elements existence" do
expect(subject.errors).to be_empty
end
end
- context 'when pattern has not been found' do
+ context "when pattern has not been found" do
before do
allow(::File).to receive(:foreach)
- .and_yield('some element').once
+ .and_yield("some element").once
allow(element).to receive(:matches?)
- .with('some element').and_return(false)
+ .with("some element").and_return(false)
end
- it 'returns an array of errors related to missing elements' do
+ it "returns an array of errors related to missing elements" do
expect(subject.errors).not_to be_empty
expect(subject.errors.first)
- .to match %r(Missing element `.*` in `.*/some/file.html` view)
+ .to match %r{Missing element `.*` in `.*/some/file.html` view}
end
end
end
- context 'when view partial has not been found' do
- it 'returns an error when it is not able to find the partial' do
+ context "when view partial has not been found" do
+ it "returns an error when it is not able to find the partial" do
expect(subject.errors).to be_one
expect(subject.errors.first)
- .to match %r(Missing view partial `.*/some/file.html`!)
+ .to match %r{Missing view partial `.*/some/file.html`!}
end
end
end
diff --git a/qa/spec/resource/api_fabricator_spec.rb b/qa/spec/resource/api_fabricator_spec.rb
index a5ed4422f6e..03066fd0dc9 100644
--- a/qa/spec/resource/api_fabricator_spec.rb
+++ b/qa/spec/resource/api_fabricator_spec.rb
@@ -4,7 +4,7 @@ describe QA::Resource::ApiFabricator do
let(:resource_without_api_support) do
Class.new do
def self.name
- 'FooBarResource'
+ "FooBarResource"
end
end
end
@@ -12,105 +12,105 @@ describe QA::Resource::ApiFabricator do
let(:resource_with_api_support) do
Class.new do
def self.name
- 'FooBarResource'
+ "FooBarResource"
end
def api_get_path
- '/foo'
+ "/foo"
end
def api_post_path
- '/bar'
+ "/bar"
end
def api_post_body
- { name: 'John Doe' }
+ {name: "John Doe"}
end
end
end
before do
- allow(subject).to receive(:current_url).and_return('')
+ allow(subject).to receive(:current_url).and_return("")
end
subject { resource.tap { |f| f.include(described_class) }.new }
- describe '#api_support?' do
- let(:api_client) { spy('Runtime::API::Client') }
- let(:api_client_instance) { double('API Client') }
+ describe "#api_support?" do
+ let(:api_client) { spy("Runtime::API::Client") }
+ let(:api_client_instance) { double("API Client") }
- context 'when resource does not support fabrication via the API' do
+ context "when resource does not support fabrication via the API" do
let(:resource) { resource_without_api_support }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to be_api_support
end
end
- context 'when resource supports fabrication via the API' do
+ context "when resource supports fabrication via the API" do
let(:resource) { resource_with_api_support }
- it 'returns false' do
+ it "returns false" do
expect(subject).to be_api_support
end
end
end
- describe '#fabricate_via_api!' do
- let(:api_client) { spy('Runtime::API::Client') }
- let(:api_client_instance) { double('API Client') }
+ describe "#fabricate_via_api!" do
+ let(:api_client) { spy("Runtime::API::Client") }
+ let(:api_client_instance) { double("API Client") }
before do
- stub_const('QA::Runtime::API::Client', api_client)
+ stub_const("QA::Runtime::API::Client", api_client)
allow(api_client).to receive(:new).and_return(api_client_instance)
- allow(api_client_instance).to receive(:personal_access_token).and_return('foo')
+ allow(api_client_instance).to receive(:personal_access_token).and_return("foo")
end
- context 'when resource does not support fabrication via the API' do
+ context "when resource does not support fabrication via the API" do
let(:resource) { resource_without_api_support }
- it 'raises a NotImplementedError exception' do
+ it "raises a NotImplementedError exception" do
expect { subject.fabricate_via_api! }.to raise_error(NotImplementedError, "Resource FooBarResource does not support fabrication via the API!")
end
end
- context 'when resource supports fabrication via the API' do
+ context "when resource supports fabrication via the API" do
let(:resource) { resource_with_api_support }
- let(:api_request) { spy('Runtime::API::Request') }
- let(:resource_web_url) { 'http://example.org/api/v4/foo' }
- let(:response) { { id: 1, name: 'John Doe', web_url: resource_web_url } }
- let(:raw_post) { double('Raw POST response', code: 201, body: response.to_json) }
+ let(:api_request) { spy("Runtime::API::Request") }
+ let(:resource_web_url) { "http://example.org/api/v4/foo" }
+ let(:response) { {id: 1, name: "John Doe", web_url: resource_web_url} }
+ let(:raw_post) { double("Raw POST response", code: 201, body: response.to_json) }
before do
- stub_const('QA::Runtime::API::Request', api_request)
+ stub_const("QA::Runtime::API::Request", api_request)
allow(api_request).to receive(:new).and_return(double(url: resource_web_url))
end
- context 'when creating a resource' do
+ context "when creating a resource" do
before do
allow(subject).to receive(:post).with(resource_web_url, subject.api_post_body).and_return(raw_post)
end
- it 'returns the resource URL' do
+ it "returns the resource URL" do
expect(api_request).to receive(:new).with(api_client_instance, subject.api_post_path).and_return(double(url: resource_web_url))
expect(subject).to receive(:post).with(resource_web_url, subject.api_post_body).and_return(raw_post)
expect(subject.fabricate_via_api!).to eq(resource_web_url)
end
- it 'populates api_resource with the resource' do
+ it "populates api_resource with the resource" do
subject.fabricate_via_api!
expect(subject.api_resource).to eq(response)
end
- context 'when the POST fails' do
- let(:post_response) { { error: "Name already taken." } }
- let(:raw_post) { double('Raw POST response', code: 400, body: post_response.to_json) }
+ context "when the POST fails" do
+ let(:post_response) { {error: "Name already taken."} }
+ let(:raw_post) { double("Raw POST response", code: 400, body: post_response.to_json) }
- it 'raises a ResourceFabricationFailedError exception' do
+ it "raises a ResourceFabricationFailedError exception" do
expect(api_request).to receive(:new).with(api_client_instance, subject.api_post_path).and_return(double(url: resource_web_url))
expect(subject).to receive(:post).with(resource_web_url, subject.api_post_body).and_return(raw_post)
@@ -120,36 +120,36 @@ describe QA::Resource::ApiFabricator do
end
end
- context '#transform_api_resource' do
+ context "#transform_api_resource" do
let(:resource) do
Class.new do
def self.name
- 'FooBarResource'
+ "FooBarResource"
end
def api_get_path
- '/foo'
+ "/foo"
end
def api_post_path
- '/bar'
+ "/bar"
end
def api_post_body
- { name: 'John Doe' }
+ {name: "John Doe"}
end
def transform_api_resource(resource)
- resource[:new] = 'foobar'
+ resource[:new] = "foobar"
resource
end
end
end
- let(:response) { { existing: 'foo', web_url: resource_web_url } }
- let(:transformed_resource) { { existing: 'foo', new: 'foobar', web_url: resource_web_url } }
+ let(:response) { {existing: "foo", web_url: resource_web_url} }
+ let(:transformed_resource) { {existing: "foo", new: "foobar", web_url: resource_web_url} }
- it 'transforms the resource' do
+ it "transforms the resource" do
expect(subject).to receive(:post).with(resource_web_url, subject.api_post_body).and_return(raw_post)
expect(subject).to receive(:transform_api_resource).with(response).and_return(transformed_resource)
diff --git a/qa/spec/resource/base_spec.rb b/qa/spec/resource/base_spec.rb
index 4a6b76c869f..2b72b90f499 100644
--- a/qa/spec/resource/base_spec.rb
+++ b/qa/spec/resource/base_spec.rb
@@ -3,14 +3,14 @@
describe QA::Resource::Base do
include Helpers::StubENV
- let(:resource) { spy('resource') }
- let(:location) { 'http://location' }
+ let(:resource) { spy("resource") }
+ let(:location) { "http://location" }
- shared_context 'fabrication context' do
+ shared_context "fabrication context" do
subject do
Class.new(described_class) do
def self.name
- 'MyResource'
+ "MyResource"
end
end
end
@@ -21,10 +21,10 @@ describe QA::Resource::Base do
end
end
- shared_examples 'fabrication method' do |fabrication_method_called, actual_fabrication_method = nil|
+ shared_examples "fabrication method" do |fabrication_method_called, actual_fabrication_method = nil|
let(:fabrication_method_used) { actual_fabrication_method || fabrication_method_called }
- it 'yields resource before calling resource method' do
+ it "yields resource before calling resource method" do
expect(resource).to receive(:something!).ordered
expect(resource).to receive(fabrication_method_used).ordered.and_return(location)
@@ -33,30 +33,30 @@ describe QA::Resource::Base do
end
end
- it 'does not log the resource and build method when QA_DEBUG=false' do
- stub_env('QA_DEBUG', 'false')
+ it "does not log the resource and build method when QA_DEBUG=false" do
+ stub_env("QA_DEBUG", "false")
expect(resource).to receive(fabrication_method_used).and_return(location)
- expect { subject.public_send(fabrication_method_called, 'something', resource: resource) }
+ expect { subject.public_send(fabrication_method_called, "something", resource: resource) }
.not_to output.to_stdout
end
end
- describe '.fabricate!' do
- context 'when resource does not support fabrication via the API' do
+ describe ".fabricate!" do
+ context "when resource does not support fabrication via the API" do
before do
expect(described_class).to receive(:fabricate_via_api!).and_raise(NotImplementedError)
end
- it 'calls .fabricate_via_browser_ui!' do
+ it "calls .fabricate_via_browser_ui!" do
expect(described_class).to receive(:fabricate_via_browser_ui!)
described_class.fabricate!
end
end
- context 'when resource supports fabrication via the API' do
- it 'calls .fabricate_via_browser_ui!' do
+ context "when resource supports fabrication via the API" do
+ it "calls .fabricate_via_browser_ui!" do
expect(described_class).to receive(:fabricate_via_api!)
described_class.fabricate!
@@ -64,12 +64,12 @@ describe QA::Resource::Base do
end
end
- describe '.fabricate_via_api!' do
- include_context 'fabrication context'
+ describe ".fabricate_via_api!" do
+ include_context "fabrication context"
- it_behaves_like 'fabrication method', :fabricate_via_api!
+ it_behaves_like "fabrication method", :fabricate_via_api!
- it 'instantiates the resource, calls resource method returns the resource' do
+ it "instantiates the resource, calls resource method returns the resource" do
expect(resource).to receive(:fabricate_via_api!).and_return(location)
result = subject.fabricate_via_api!(resource: resource, parents: [])
@@ -77,57 +77,57 @@ describe QA::Resource::Base do
expect(result).to eq(resource)
end
- it 'logs the resource and build method when QA_DEBUG=true' do
- stub_env('QA_DEBUG', 'true')
+ it "logs the resource and build method when QA_DEBUG=true" do
+ stub_env("QA_DEBUG", "true")
expect(resource).to receive(:fabricate_via_api!).and_return(location)
- expect { subject.fabricate_via_api!('something', resource: resource, parents: []) }
+ expect { subject.fabricate_via_api!("something", resource: resource, parents: []) }
.to output(/==> Built a MyResource via api in [\d\.\-e]+ seconds+/)
.to_stdout
end
end
- describe '.fabricate_via_browser_ui!' do
- include_context 'fabrication context'
+ describe ".fabricate_via_browser_ui!" do
+ include_context "fabrication context"
- it_behaves_like 'fabrication method', :fabricate_via_browser_ui!, :fabricate!
+ it_behaves_like "fabrication method", :fabricate_via_browser_ui!, :fabricate!
- it 'instantiates the resource and calls resource method' do
- subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
+ it "instantiates the resource and calls resource method" do
+ subject.fabricate_via_browser_ui!("something", resource: resource, parents: [])
- expect(resource).to have_received(:fabricate!).with('something')
+ expect(resource).to have_received(:fabricate!).with("something")
end
- it 'returns fabrication resource' do
- result = subject.fabricate_via_browser_ui!('something', resource: resource, parents: [])
+ it "returns fabrication resource" do
+ result = subject.fabricate_via_browser_ui!("something", resource: resource, parents: [])
expect(result).to eq(resource)
end
- it 'logs the resource and build method when QA_DEBUG=true' do
- stub_env('QA_DEBUG', 'true')
+ it "logs the resource and build method when QA_DEBUG=true" do
+ stub_env("QA_DEBUG", "true")
- expect { subject.fabricate_via_browser_ui!('something', resource: resource, parents: []) }
+ expect { subject.fabricate_via_browser_ui!("something", resource: resource, parents: []) }
.to output(/==> Built a MyResource via browser_ui in [\d\.\-e]+ seconds+/)
.to_stdout
end
end
- shared_context 'simple resource' do
+ shared_context "simple resource" do
subject do
Class.new(QA::Resource::Base) do
attribute :test do
- 'block'
+ "block"
end
attribute :no_block
def fabricate!
- 'any'
+ "any"
end
def self.current_url
- 'http://stub'
+ "http://stub"
end
end
end
@@ -135,78 +135,78 @@ describe QA::Resource::Base do
let(:resource) { subject.new }
end
- describe '.attribute' do
- include_context 'simple resource'
+ describe ".attribute" do
+ include_context "simple resource"
- context 'when the attribute is populated via a block' do
- it 'returns value from the block' do
+ context "when the attribute is populated via a block" do
+ it "returns value from the block" do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
- expect(result.test).to eq('block')
+ expect(result.test).to eq("block")
end
end
- context 'when the attribute is populated via the api' do
- let(:api_resource) { { no_block: 'api' } }
+ context "when the attribute is populated via the api" do
+ let(:api_resource) { {no_block: "api"} }
before do
expect(resource).to receive(:api_resource).and_return(api_resource)
end
- it 'returns value from api' do
+ it "returns value from api" do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
- expect(result.no_block).to eq('api')
+ expect(result.no_block).to eq("api")
end
- context 'when the attribute also has a block' do
- let(:api_resource) { { test: 'api_with_block' } }
+ context "when the attribute also has a block" do
+ let(:api_resource) { {test: "api_with_block"} }
before do
allow(QA::Runtime::Logger).to receive(:info)
end
- it 'returns value from api and emits an INFO log entry' do
+ it "returns value from api and emits an INFO log entry" do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
- expect(result.test).to eq('api_with_block')
+ expect(result.test).to eq("api_with_block")
expect(QA::Runtime::Logger)
.to have_received(:info).with(/api_with_block/)
end
end
end
- context 'when the attribute is populated via direct assignment' do
+ context "when the attribute is populated via direct assignment" do
before do
- resource.test = 'value'
+ resource.test = "value"
end
- it 'returns value from the assignment' do
+ it "returns value from the assignment" do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
- expect(result.test).to eq('value')
+ expect(result.test).to eq("value")
end
- context 'when the api also has such response' do
+ context "when the api also has such response" do
before do
- allow(resource).to receive(:api_resource).and_return({ test: 'api' })
+ allow(resource).to receive(:api_resource).and_return({test: "api"})
end
- it 'returns value from the assignment' do
+ it "returns value from the assignment" do
result = subject.fabricate!(resource: resource)
expect(result).to be_a(described_class)
- expect(result.test).to eq('value')
+ expect(result.test).to eq("value")
end
end
end
- context 'when the attribute has no value' do
- it 'raises an error because no values could be found' do
+ context "when the attribute has no value" do
+ it "raises an error because no values could be found" do
result = subject.fabricate!(resource: resource)
expect { result.no_block }
@@ -214,61 +214,61 @@ describe QA::Resource::Base do
end
end
- context 'when multiple resources have the same attribute name' do
+ context "when multiple resources have the same attribute name" do
let(:base) do
Class.new(QA::Resource::Base) do
def fabricate!
- 'any'
+ "any"
end
def self.current_url
- 'http://stub'
+ "http://stub"
end
end
end
let(:first_resource) do
Class.new(base) do
attribute :test do
- 'first block'
+ "first block"
end
end
end
let(:second_resource) do
Class.new(base) do
attribute :test do
- 'second block'
+ "second block"
end
end
end
- it 'has unique attribute values' do
+ it "has unique attribute values" do
first_result = first_resource.fabricate!(resource: first_resource.new)
second_result = second_resource.fabricate!(resource: second_resource.new)
- expect(first_result.test).to eq 'first block'
- expect(second_result.test).to eq 'second block'
+ expect(first_result.test).to eq "first block"
+ expect(second_result.test).to eq "second block"
end
end
end
- describe '#web_url' do
- include_context 'simple resource'
+ describe "#web_url" do
+ include_context "simple resource"
- it 'sets #web_url to #current_url after fabrication' do
+ it "sets #web_url to #current_url after fabrication" do
subject.fabricate!(resource: resource)
expect(resource.web_url).to eq(subject.current_url)
end
end
- describe '#visit!' do
- include_context 'simple resource'
+ describe "#visit!" do
+ include_context "simple resource"
before do
allow(resource).to receive(:visit)
end
- it 'calls #visit with the underlying #web_url' do
+ it "calls #visit with the underlying #web_url" do
resource.web_url = subject.current_url
resource.visit!
diff --git a/qa/spec/resource/events/base_spec.rb b/qa/spec/resource/events/base_spec.rb
index 9cdf4785092..bebf67e40c9 100644
--- a/qa/spec/resource/events/base_spec.rb
+++ b/qa/spec/resource/events/base_spec.rb
@@ -4,7 +4,7 @@ describe QA::Resource::Events::Base do
let(:resource) do
Class.new(QA::Resource::Base) do
def api_get_path
- '/foo'
+ "/foo"
end
end
end
@@ -12,18 +12,18 @@ describe QA::Resource::Events::Base do
subject { resource.tap { |f| f.include(described_class) }.new }
describe "#events" do
- it 'fetches all events when called without parameters' do
- allow(subject).to receive(:parse_body).and_return('returned')
+ it "fetches all events when called without parameters" do
+ allow(subject).to receive(:parse_body).and_return("returned")
- expect(subject).to receive(:api_get_from).with('/foo/events')
- expect(subject.events).to eq('returned')
+ expect(subject).to receive(:api_get_from).with("/foo/events")
+ expect(subject.events).to eq("returned")
end
- it 'fetches events with a specified action type' do
- allow(subject).to receive(:parse_body).and_return('returned')
+ it "fetches events with a specified action type" do
+ allow(subject).to receive(:parse_body).and_return("returned")
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
- expect(subject.events(action: 'pushed')).to eq('returned')
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed")
+ expect(subject.events(action: "pushed")).to eq("returned")
end
end
end
diff --git a/qa/spec/resource/events/project_spec.rb b/qa/spec/resource/events/project_spec.rb
index b3efdb518f3..0f96b2a1d31 100644
--- a/qa/spec/resource/events/project_spec.rb
+++ b/qa/spec/resource/events/project_spec.rb
@@ -4,7 +4,7 @@ describe QA::Resource::Events::Project do
let(:resource) do
Class.new(QA::Resource::Base) do
def api_get_path
- '/foo'
+ "/foo"
end
end
end
@@ -13,21 +13,21 @@ describe QA::Resource::Events::Project do
{
"action_name": "pushed",
"push_data": {
- "commit_title": "foo commit"
- }
+ "commit_title": "foo commit",
+ },
},
{
"action_name": "pushed",
"push_data": {
- "ref": "master"
- }
+ "ref": "master",
+ },
},
{
"action_name": "pushed",
"push_data": {
- "ref": "another-branch"
- }
- }
+ "ref": "another-branch",
+ },
+ },
]
end
@@ -39,31 +39,31 @@ describe QA::Resource::Events::Project do
subject { resource.tap { |f| f.include(described_class) }.new }
describe "#wait_for_push" do
- it 'waits for a push with a specified commit message' do
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
- expect { subject.wait_for_push('foo commit') }.not_to raise_error
+ it "waits for a push with a specified commit message" do
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed")
+ expect { subject.wait_for_push("foo commit") }.not_to raise_error
end
- it 'raises an error if a push with the specified commit message is not found' do
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
- expect { subject.wait_for_push('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
+ it "raises an error if a push with the specified commit message is not found" do
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed").at_least(:once)
+ expect { subject.wait_for_push("bar") }.to raise_error(QA::Resource::Events::EventNotFoundError)
end
end
describe "#wait_for_push_new_branch" do
- it 'waits for a push to master if no branch is given' do
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
+ it "waits for a push to master if no branch is given" do
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed")
expect { subject.wait_for_push_new_branch }.not_to raise_error
end
- it 'waits for a push to the given branch' do
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed')
- expect { subject.wait_for_push_new_branch('another-branch') }.not_to raise_error
+ it "waits for a push to the given branch" do
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed")
+ expect { subject.wait_for_push_new_branch("another-branch") }.not_to raise_error
end
- it 'raises an error if a push with the specified branch is not found' do
- expect(subject).to receive(:api_get_from).with('/foo/events?action=pushed').at_least(:once)
- expect { subject.wait_for_push_new_branch('bar') }.to raise_error(QA::Resource::Events::EventNotFoundError)
+ it "raises an error if a push with the specified branch is not found" do
+ expect(subject).to receive(:api_get_from).with("/foo/events?action=pushed").at_least(:once)
+ expect { subject.wait_for_push_new_branch("bar") }.to raise_error(QA::Resource::Events::EventNotFoundError)
end
end
end
diff --git a/qa/spec/resource/repository/push_spec.rb b/qa/spec/resource/repository/push_spec.rb
index bf3ebce0cfe..dab0a00cc85 100644
--- a/qa/spec/resource/repository/push_spec.rb
+++ b/qa/spec/resource/repository/push_spec.rb
@@ -1,25 +1,25 @@
# frozen_string_literal: true
describe QA::Resource::Repository::Push do
- describe '.files=' do
+ describe ".files=" do
let(:files) do
[
{
- name: 'file.txt',
- content: 'foo'
- }
+ name: "file.txt",
+ content: "foo",
+ },
]
end
- it 'raises an error if files is not an array' do
- expect { subject.files = '' }.to raise_error(ArgumentError)
+ it "raises an error if files is not an array" do
+ expect { subject.files = "" }.to raise_error(ArgumentError)
end
- it 'raises an error if files is an empty array' do
+ it "raises an error if files is an empty array" do
expect { subject.files = [] }.to raise_error(ArgumentError)
end
- it 'does not raise if files is an array' do
+ it "does not raise if files is an array" do
expect { subject.files = files }.not_to raise_error
end
end
diff --git a/qa/spec/resource/user_spec.rb b/qa/spec/resource/user_spec.rb
index d612dfc530e..dec08629701 100644
--- a/qa/spec/resource/user_spec.rb
+++ b/qa/spec/resource/user_spec.rb
@@ -6,88 +6,88 @@ describe QA::Resource::User do
name: "GitLab QA",
username: "gitlab-qa",
web_url: "https://staging.gitlab.com/gitlab-qa",
- public_email: "1614863-gitlab-qa@users.noreply.staging.gitlab.com"
+ public_email: "1614863-gitlab-qa@users.noreply.staging.gitlab.com",
}
end
- describe '#username' do
- it 'generates a default username' do
+ describe "#username" do
+ it "generates a default username" do
expect(subject.username).to match(/qa-user-\w+/)
end
- it 'is possible to set the username' do
- subject.username = 'johndoe'
+ it "is possible to set the username" do
+ subject.username = "johndoe"
- expect(subject.username).to eq('johndoe')
+ expect(subject.username).to eq("johndoe")
end
end
- describe '#password' do
- it 'generates a default password' do
- expect(subject.password).to eq('password')
+ describe "#password" do
+ it "generates a default password" do
+ expect(subject.password).to eq("password")
end
- it 'is possible to set the password' do
- subject.password = 'secret'
+ it "is possible to set the password" do
+ subject.password = "secret"
- expect(subject.password).to eq('secret')
+ expect(subject.password).to eq("secret")
end
end
- describe '#name' do
- it 'defaults to the username' do
+ describe "#name" do
+ it "defaults to the username" do
expect(subject.name).to eq(subject.username)
end
- it 'retrieves the name from the api_resource if present' do
+ it "retrieves the name from the api_resource if present" do
subject.__send__(:api_resource=, api_resource)
expect(subject.name).to eq(api_resource[:name])
end
- it 'is possible to set the name' do
- subject.name = 'John Doe'
+ it "is possible to set the name" do
+ subject.name = "John Doe"
- expect(subject.name).to eq('John Doe')
+ expect(subject.name).to eq("John Doe")
end
end
- describe '#email' do
- it 'defaults to the <username>@example.com' do
+ describe "#email" do
+ it "defaults to the <username>@example.com" do
expect(subject.email).to eq("#{subject.username}@example.com")
end
- it 'is possible to set the email' do
- subject.email = 'johndoe@example.org'
+ it "is possible to set the email" do
+ subject.email = "johndoe@example.org"
- expect(subject.email).to eq('johndoe@example.org')
+ expect(subject.email).to eq("johndoe@example.org")
end
end
- describe '#public_email' do
- it 'defaults to QA::Runtime::User.default_email' do
+ describe "#public_email" do
+ it "defaults to QA::Runtime::User.default_email" do
expect(subject.public_email).to eq(QA::Runtime::User.default_email)
end
- it 'retrieves the public_email from the api_resource if present' do
+ it "retrieves the public_email from the api_resource if present" do
subject.__send__(:api_resource=, api_resource)
expect(subject.public_email).to eq(api_resource[:public_email])
end
- it 'defaults to QA::Runtime::User.default_email if the public_email from the api_resource is blank' do
- subject.__send__(:api_resource=, api_resource.merge(public_email: ''))
+ it "defaults to QA::Runtime::User.default_email if the public_email from the api_resource is blank" do
+ subject.__send__(:api_resource=, api_resource.merge(public_email: ""))
expect(subject.public_email).to eq(QA::Runtime::User.default_email)
end
end
- describe '#credentials_given?' do
- it 'returns false when username and email have not been overridden' do
+ describe "#credentials_given?" do
+ it "returns false when username and email have not been overridden" do
expect(subject).not_to be_credentials_given
end
- it 'returns false even after username and email have been called' do
+ it "returns false even after username and email have been called" do
# Call #username and #password to ensure this doesn't set their respective
# instance variable.
subject.username
@@ -96,21 +96,21 @@ describe QA::Resource::User do
expect(subject).not_to be_credentials_given
end
- it 'returns false if only the username has been overridden' do
- subject.username = 'johndoe'
+ it "returns false if only the username has been overridden" do
+ subject.username = "johndoe"
expect(subject).not_to be_credentials_given
end
- it 'returns false if only the password has been overridden' do
- subject.password = 'secret'
+ it "returns false if only the password has been overridden" do
+ subject.password = "secret"
expect(subject).not_to be_credentials_given
end
- it 'returns true if both the username and password have been overridden' do
- subject.username = 'johndoe'
- subject.password = 'secret'
+ it "returns true if both the username and password have been overridden" do
+ subject.username = "johndoe"
+ subject.password = "secret"
expect(subject).to be_credentials_given
end
diff --git a/qa/spec/runtime/api/client_spec.rb b/qa/spec/runtime/api/client_spec.rb
index af43facc73d..3a0a01a74b1 100644
--- a/qa/spec/runtime/api/client_spec.rb
+++ b/qa/spec/runtime/api/client_spec.rb
@@ -1,38 +1,38 @@
describe QA::Runtime::API::Client do
include Helpers::StubENV
- describe 'initialization' do
- it 'defaults to :gitlab address' do
+ describe "initialization" do
+ it "defaults to :gitlab address" do
expect(described_class.new.address).to eq :gitlab
end
- it 'uses specified address' do
- client = described_class.new('http:///example.com')
+ it "uses specified address" do
+ client = described_class.new("http:///example.com")
- expect(client.address).to eq 'http:///example.com'
+ expect(client.address).to eq "http:///example.com"
end
end
- describe '#personal_access_token' do
- context 'when QA::Runtime::Env.personal_access_token is present' do
+ describe "#personal_access_token" do
+ context "when QA::Runtime::Env.personal_access_token is present" do
before do
- allow(QA::Runtime::Env).to receive(:personal_access_token).and_return('a_token')
+ allow(QA::Runtime::Env).to receive(:personal_access_token).and_return("a_token")
end
- it 'returns specified token from env' do
- expect(described_class.new.personal_access_token).to eq 'a_token'
+ it "returns specified token from env" do
+ expect(described_class.new.personal_access_token).to eq "a_token"
end
end
- context 'when QA::Runtime::Env.personal_access_token is nil' do
+ context "when QA::Runtime::Env.personal_access_token is nil" do
before do
allow(QA::Runtime::Env).to receive(:personal_access_token).and_return(nil)
end
- it 'returns a created token' do
- expect(subject).to receive(:create_personal_access_token).and_return('created_token')
+ it "returns a created token" do
+ expect(subject).to receive(:create_personal_access_token).and_return("created_token")
- expect(subject.personal_access_token).to eq 'created_token'
+ expect(subject.personal_access_token).to eq "created_token"
end
end
end
diff --git a/qa/spec/runtime/api/request_spec.rb b/qa/spec/runtime/api/request_spec.rb
index 08233e3c1d6..48b024b8733 100644
--- a/qa/spec/runtime/api/request_spec.rb
+++ b/qa/spec/runtime/api/request_spec.rb
@@ -1,50 +1,50 @@
describe QA::Runtime::API::Request do
- let(:client) { QA::Runtime::API::Client.new('http://example.com') }
- let(:request) { described_class.new(client, '/users') }
+ let(:client) { QA::Runtime::API::Client.new("http://example.com") }
+ let(:request) { described_class.new(client, "/users") }
before do
- allow(client).to receive(:personal_access_token).and_return('a_token')
+ allow(client).to receive(:personal_access_token).and_return("a_token")
end
- describe '#url' do
- it 'returns the full API request url' do
- expect(request.url).to eq 'http://example.com/api/v4/users?private_token=a_token'
+ describe "#url" do
+ it "returns the full API request url" do
+ expect(request.url).to eq "http://example.com/api/v4/users?private_token=a_token"
end
- context 'when oauth_access_token is passed in the query string' do
- let(:request) { described_class.new(client, '/users', { oauth_access_token: 'foo' }) }
+ context "when oauth_access_token is passed in the query string" do
+ let(:request) { described_class.new(client, "/users", {oauth_access_token: "foo"}) }
- it 'does not adds a private_token query string' do
- expect(request.url).to eq 'http://example.com/api/v4/users?oauth_access_token=foo'
+ it "does not adds a private_token query string" do
+ expect(request.url).to eq "http://example.com/api/v4/users?oauth_access_token=foo"
end
end
end
- describe '#request_path' do
- it 'prepends the api path' do
- expect(request.request_path('/users')).to eq '/api/v4/users'
+ describe "#request_path" do
+ it "prepends the api path" do
+ expect(request.request_path("/users")).to eq "/api/v4/users"
end
- it 'adds the personal access token' do
- expect(request.request_path('/users', private_token: 'token'))
- .to eq '/api/v4/users?private_token=token'
+ it "adds the personal access token" do
+ expect(request.request_path("/users", private_token: "token"))
+ .to eq "/api/v4/users?private_token=token"
end
- it 'adds the oauth access token' do
- expect(request.request_path('/users', access_token: 'otoken'))
- .to eq '/api/v4/users?access_token=otoken'
+ it "adds the oauth access token" do
+ expect(request.request_path("/users", access_token: "otoken"))
+ .to eq "/api/v4/users?access_token=otoken"
end
- it 'respects query parameters' do
- expect(request.request_path('/users?page=1')).to eq '/api/v4/users?page=1'
- expect(request.request_path('/users', private_token: 'token', foo: 'bar/baz'))
- .to eq '/api/v4/users?private_token=token&foo=bar%2Fbaz'
- expect(request.request_path('/users?page=1', private_token: 'token', foo: 'bar/baz'))
- .to eq '/api/v4/users?page=1&private_token=token&foo=bar%2Fbaz'
+ it "respects query parameters" do
+ expect(request.request_path("/users?page=1")).to eq "/api/v4/users?page=1"
+ expect(request.request_path("/users", private_token: "token", foo: "bar/baz"))
+ .to eq "/api/v4/users?private_token=token&foo=bar%2Fbaz"
+ expect(request.request_path("/users?page=1", private_token: "token", foo: "bar/baz"))
+ .to eq "/api/v4/users?page=1&private_token=token&foo=bar%2Fbaz"
end
- it 'uses a different api version' do
- expect(request.request_path('/users', version: 'other_version')).to eq '/api/other_version/users'
+ it "uses a different api version" do
+ expect(request.request_path("/users", version: "other_version")).to eq "/api/other_version/users"
end
end
end
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb
index fc51f45c3a1..60def583fb1 100644
--- a/qa/spec/runtime/env_spec.rb
+++ b/qa/spec/runtime/env_spec.rb
@@ -3,36 +3,36 @@
describe QA::Runtime::Env do
include Helpers::StubENV
- shared_examples 'boolean method' do |**kwargs|
- it_behaves_like 'boolean method with parameter', kwargs
+ shared_examples "boolean method" do |**kwargs|
+ it_behaves_like "boolean method with parameter", kwargs
end
- shared_examples 'boolean method with parameter' do |method:, param: nil, env_key:, default:|
- context 'when there is an env variable set' do
- it 'returns false when falsey values specified' do
- stub_env(env_key, 'false')
+ shared_examples "boolean method with parameter" do |method:, param: nil, env_key:, default:|
+ context "when there is an env variable set" do
+ it "returns false when falsey values specified" do
+ stub_env(env_key, "false")
expect(described_class.public_send(method, *param)).to be_falsey
- stub_env(env_key, 'no')
+ stub_env(env_key, "no")
expect(described_class.public_send(method, *param)).to be_falsey
- stub_env(env_key, '0')
+ stub_env(env_key, "0")
expect(described_class.public_send(method, *param)).to be_falsey
end
- it 'returns true when anything else specified' do
- stub_env(env_key, 'true')
+ it "returns true when anything else specified" do
+ stub_env(env_key, "true")
expect(described_class.public_send(method, *param)).to be_truthy
- stub_env(env_key, '1')
+ stub_env(env_key, "1")
expect(described_class.public_send(method, *param)).to be_truthy
- stub_env(env_key, 'anything')
+ stub_env(env_key, "anything")
expect(described_class.public_send(method, *param)).to be_truthy
end
end
- context 'when there is no env variable set' do
+ context "when there is no env variable set" do
it "returns the default, #{default}" do
stub_env(env_key, nil)
expect(described_class.public_send(method, *param)).to be(default)
@@ -40,229 +40,229 @@ describe QA::Runtime::Env do
end
end
- describe '.signup_disabled?' do
- it_behaves_like 'boolean method',
+ describe ".signup_disabled?" do
+ it_behaves_like "boolean method",
method: :signup_disabled?,
- env_key: 'SIGNUP_DISABLED',
+ env_key: "SIGNUP_DISABLED",
default: false
end
- describe '.debug?' do
- it_behaves_like 'boolean method',
+ describe ".debug?" do
+ it_behaves_like "boolean method",
method: :debug?,
- env_key: 'QA_DEBUG',
+ env_key: "QA_DEBUG",
default: false
end
- describe '.chrome_headless?' do
- it_behaves_like 'boolean method',
+ describe ".chrome_headless?" do
+ it_behaves_like "boolean method",
method: :chrome_headless?,
- env_key: 'CHROME_HEADLESS',
+ env_key: "CHROME_HEADLESS",
default: true
end
- describe '.running_in_ci?' do
- context 'when there is an env variable set' do
- it 'returns true if CI' do
- stub_env('CI', 'anything')
+ describe ".running_in_ci?" do
+ context "when there is an env variable set" do
+ it "returns true if CI" do
+ stub_env("CI", "anything")
expect(described_class.running_in_ci?).to be_truthy
end
- it 'returns true if CI_SERVER' do
- stub_env('CI_SERVER', 'anything')
+ it "returns true if CI_SERVER" do
+ stub_env("CI_SERVER", "anything")
expect(described_class.running_in_ci?).to be_truthy
end
end
- context 'when there is no env variable set' do
- it 'returns true' do
- stub_env('CI', nil)
- stub_env('CI_SERVER', nil)
+ context "when there is no env variable set" do
+ it "returns true" do
+ stub_env("CI", nil)
+ stub_env("CI_SERVER", nil)
expect(described_class.running_in_ci?).to be_falsey
end
end
end
- describe '.personal_access_token' do
+ describe ".personal_access_token" do
around do |example|
described_class.instance_variable_set(:@personal_access_token, nil)
example.run
described_class.instance_variable_set(:@personal_access_token, nil)
end
- context 'when PERSONAL_ACCESS_TOKEN is set' do
+ context "when PERSONAL_ACCESS_TOKEN is set" do
before do
- stub_env('PERSONAL_ACCESS_TOKEN', 'a_token')
+ stub_env("PERSONAL_ACCESS_TOKEN", "a_token")
end
- it 'returns specified token from env' do
- expect(described_class.personal_access_token).to eq 'a_token'
+ it "returns specified token from env" do
+ expect(described_class.personal_access_token).to eq "a_token"
end
end
- context 'when @personal_access_token is set' do
+ context "when @personal_access_token is set" do
before do
- described_class.personal_access_token = 'another_token'
+ described_class.personal_access_token = "another_token"
end
- it 'returns the instance variable value' do
- expect(described_class.personal_access_token).to eq 'another_token'
+ it "returns the instance variable value" do
+ expect(described_class.personal_access_token).to eq "another_token"
end
end
end
- describe '.personal_access_token=' do
+ describe ".personal_access_token=" do
around do |example|
described_class.instance_variable_set(:@personal_access_token, nil)
example.run
described_class.instance_variable_set(:@personal_access_token, nil)
end
- it 'saves the token' do
- described_class.personal_access_token = 'a_token'
+ it "saves the token" do
+ described_class.personal_access_token = "a_token"
- expect(described_class.personal_access_token).to eq 'a_token'
+ expect(described_class.personal_access_token).to eq "a_token"
end
end
- describe '.forker?' do
+ describe ".forker?" do
before do
- stub_env('GITLAB_FORKER_USERNAME', nil)
- stub_env('GITLAB_FORKER_PASSWORD', nil)
+ stub_env("GITLAB_FORKER_USERNAME", nil)
+ stub_env("GITLAB_FORKER_PASSWORD", nil)
end
- it 'returns false if no forker credentials are defined' do
+ it "returns false if no forker credentials are defined" do
expect(described_class).not_to be_forker
end
- it 'returns false if only forker username is defined' do
- stub_env('GITLAB_FORKER_USERNAME', 'foo')
+ it "returns false if only forker username is defined" do
+ stub_env("GITLAB_FORKER_USERNAME", "foo")
expect(described_class).not_to be_forker
end
- it 'returns false if only forker password is defined' do
- stub_env('GITLAB_FORKER_PASSWORD', 'bar')
+ it "returns false if only forker password is defined" do
+ stub_env("GITLAB_FORKER_PASSWORD", "bar")
expect(described_class).not_to be_forker
end
- it 'returns true if forker username and password are defined' do
- stub_env('GITLAB_FORKER_USERNAME', 'foo')
- stub_env('GITLAB_FORKER_PASSWORD', 'bar')
+ it "returns true if forker username and password are defined" do
+ stub_env("GITLAB_FORKER_USERNAME", "foo")
+ stub_env("GITLAB_FORKER_PASSWORD", "bar")
expect(described_class).to be_forker
end
end
- describe '.github_access_token' do
+ describe ".github_access_token" do
it 'returns "" if GITHUB_ACCESS_TOKEN is not defined' do
- stub_env('GITHUB_ACCESS_TOKEN', nil)
+ stub_env("GITHUB_ACCESS_TOKEN", nil)
- expect(described_class.github_access_token).to eq('')
+ expect(described_class.github_access_token).to eq("")
end
- it 'returns stripped string if GITHUB_ACCESS_TOKEN is defined' do
- stub_env('GITHUB_ACCESS_TOKEN', ' abc123 ')
- expect(described_class.github_access_token).to eq('abc123')
+ it "returns stripped string if GITHUB_ACCESS_TOKEN is defined" do
+ stub_env("GITHUB_ACCESS_TOKEN", " abc123 ")
+ expect(described_class.github_access_token).to eq("abc123")
end
end
- describe '.require_github_access_token!' do
- it 'raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined' do
- stub_env('GITHUB_ACCESS_TOKEN', nil)
+ describe ".require_github_access_token!" do
+ it "raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined" do
+ stub_env("GITHUB_ACCESS_TOKEN", nil)
expect { described_class.require_github_access_token! }.to raise_error(ArgumentError)
end
- it 'does not raise if GITHUB_ACCESS_TOKEN is defined' do
- stub_env('GITHUB_ACCESS_TOKEN', ' abc123 ')
+ it "does not raise if GITHUB_ACCESS_TOKEN is defined" do
+ stub_env("GITHUB_ACCESS_TOKEN", " abc123 ")
expect { described_class.require_github_access_token! }.not_to raise_error
end
end
- describe '.log_destination' do
- it 'returns $stdout if QA_LOG_PATH is not defined' do
- stub_env('QA_LOG_PATH', nil)
+ describe ".log_destination" do
+ it "returns $stdout if QA_LOG_PATH is not defined" do
+ stub_env("QA_LOG_PATH", nil)
expect(described_class.log_destination).to eq($stdout)
end
- it 'returns the path if QA_LOG_PATH is defined' do
- stub_env('QA_LOG_PATH', 'path/to_file')
+ it "returns the path if QA_LOG_PATH is defined" do
+ stub_env("QA_LOG_PATH", "path/to_file")
- expect(described_class.log_destination).to eq('path/to_file')
+ expect(described_class.log_destination).to eq("path/to_file")
end
end
- describe '.can_test?' do
- it_behaves_like 'boolean method with parameter',
+ describe ".can_test?" do
+ it_behaves_like "boolean method with parameter",
method: :can_test?,
param: :git_protocol_v2,
- env_key: 'QA_CAN_TEST_GIT_PROTOCOL_V2',
+ env_key: "QA_CAN_TEST_GIT_PROTOCOL_V2",
default: true
- it 'raises ArgumentError if feature is unknown' do
+ it "raises ArgumentError if feature is unknown" do
expect { described_class.can_test? :foo }.to raise_error(ArgumentError, 'Unknown feature "foo"')
end
end
- describe 'remote grid credentials' do
- it 'is blank if username is empty' do
- stub_env('QA_REMOTE_GRID_USERNAME', nil)
+ describe "remote grid credentials" do
+ it "is blank if username is empty" do
+ stub_env("QA_REMOTE_GRID_USERNAME", nil)
- expect(described_class.send(:remote_grid_credentials)).to eq('')
+ expect(described_class.send(:remote_grid_credentials)).to eq("")
end
- it 'throws ArgumentError if GRID_ACCESS_KEY is not specified with USERNAME' do
- stub_env('QA_REMOTE_GRID_USERNAME', 'foo')
+ it "throws ArgumentError if GRID_ACCESS_KEY is not specified with USERNAME" do
+ stub_env("QA_REMOTE_GRID_USERNAME", "foo")
expect { described_class.send(:remote_grid_credentials) }.to raise_error(ArgumentError, 'Please provide an access key for user "foo"')
end
- it 'returns a user:key@ combination when all args are satiated' do
- stub_env('QA_REMOTE_GRID_USERNAME', 'foo')
- stub_env('QA_REMOTE_GRID_ACCESS_KEY', 'bar')
+ it "returns a user:key@ combination when all args are satiated" do
+ stub_env("QA_REMOTE_GRID_USERNAME", "foo")
+ stub_env("QA_REMOTE_GRID_ACCESS_KEY", "bar")
- expect(described_class.send(:remote_grid_credentials)).to eq('foo:bar@')
+ expect(described_class.send(:remote_grid_credentials)).to eq("foo:bar@")
end
end
- describe '.remote_grid_protocol' do
- it 'defaults protocol to http' do
- stub_env('QA_REMOTE_GRID_PROTOCOL', nil)
- expect(described_class.remote_grid_protocol).to eq('http')
+ describe ".remote_grid_protocol" do
+ it "defaults protocol to http" do
+ stub_env("QA_REMOTE_GRID_PROTOCOL", nil)
+ expect(described_class.remote_grid_protocol).to eq("http")
end
end
- describe '.remote_grid' do
- it 'is falsey if QA_REMOTE_GRID is not set' do
+ describe ".remote_grid" do
+ it "is falsey if QA_REMOTE_GRID is not set" do
expect(described_class.remote_grid).to be_falsey
end
- it 'accepts https protocol' do
- stub_env('QA_REMOTE_GRID', 'localhost:4444')
- stub_env('QA_REMOTE_GRID_PROTOCOL', 'https')
+ it "accepts https protocol" do
+ stub_env("QA_REMOTE_GRID", "localhost:4444")
+ stub_env("QA_REMOTE_GRID_PROTOCOL", "https")
- expect(described_class.remote_grid).to eq('https://localhost:4444/wd/hub')
+ expect(described_class.remote_grid).to eq("https://localhost:4444/wd/hub")
end
- context 'with credentials' do
- it 'has a grid of http://user:key@grid/wd/hub' do
- stub_env('QA_REMOTE_GRID_USERNAME', 'foo')
- stub_env('QA_REMOTE_GRID_ACCESS_KEY', 'bar')
- stub_env('QA_REMOTE_GRID', 'localhost:4444')
+ context "with credentials" do
+ it "has a grid of http://user:key@grid/wd/hub" do
+ stub_env("QA_REMOTE_GRID_USERNAME", "foo")
+ stub_env("QA_REMOTE_GRID_ACCESS_KEY", "bar")
+ stub_env("QA_REMOTE_GRID", "localhost:4444")
- expect(described_class.remote_grid).to eq('http://foo:bar@localhost:4444/wd/hub')
+ expect(described_class.remote_grid).to eq("http://foo:bar@localhost:4444/wd/hub")
end
end
- context 'without credentials' do
- it 'has a grid of http://grid/wd/hub' do
- stub_env('QA_REMOTE_GRID', 'localhost:4444')
+ context "without credentials" do
+ it "has a grid of http://grid/wd/hub" do
+ stub_env("QA_REMOTE_GRID", "localhost:4444")
- expect(described_class.remote_grid).to eq('http://localhost:4444/wd/hub')
+ expect(described_class.remote_grid).to eq("http://localhost:4444/wd/hub")
end
end
end
diff --git a/qa/spec/runtime/key/ecdsa_spec.rb b/qa/spec/runtime/key/ecdsa_spec.rb
index 8951e82b9bb..fb4f044de79 100644
--- a/qa/spec/runtime/key/ecdsa_spec.rb
+++ b/qa/spec/runtime/key/ecdsa_spec.rb
@@ -1,5 +1,5 @@
describe QA::Runtime::Key::ECDSA do
- describe '#public_key' do
+ describe "#public_key" do
[256, 384, 521].each do |bits|
it "generates a public #{bits}-bits ECDSA key" do
subject = described_class.new(bits).public_key
@@ -9,8 +9,8 @@ describe QA::Runtime::Key::ECDSA do
end
end
- describe '#new' do
- it 'does not support arbitrary bits' do
+ describe "#new" do
+ it "does not support arbitrary bits" do
expect { described_class.new(123) }
.to raise_error(QA::Service::Shellout::CommandError)
end
diff --git a/qa/spec/runtime/key/ed25519_spec.rb b/qa/spec/runtime/key/ed25519_spec.rb
index 4844e7affdf..8b8e445d543 100644
--- a/qa/spec/runtime/key/ed25519_spec.rb
+++ b/qa/spec/runtime/key/ed25519_spec.rb
@@ -1,8 +1,8 @@
describe QA::Runtime::Key::ED25519 do
- describe '#public_key' do
+ describe "#public_key" do
subject { described_class.new.public_key }
- it 'generates a public ED25519 key' do
+ it "generates a public ED25519 key" do
expect(subject).to match(%r{\Assh\-ed25519 AAAA[0-9A-Za-z+/]})
end
end
diff --git a/qa/spec/runtime/key/rsa_spec.rb b/qa/spec/runtime/key/rsa_spec.rb
index fbcc7ffdcb4..85ff0f32657 100644
--- a/qa/spec/runtime/key/rsa_spec.rb
+++ b/qa/spec/runtime/key/rsa_spec.rb
@@ -1,8 +1,8 @@
describe QA::Runtime::Key::RSA do
- describe '#public_key' do
+ describe "#public_key" do
subject { described_class.new.public_key }
- it 'generates a public RSA key' do
+ it "generates a public RSA key" do
expect(subject).to match(%r{\Assh\-rsa AAAA[0-9A-Za-z+/]+={0,3}})
end
end
diff --git a/qa/spec/runtime/logger_spec.rb b/qa/spec/runtime/logger_spec.rb
index 44be3381bff..db82279fd73 100644
--- a/qa/spec/runtime/logger_spec.rb
+++ b/qa/spec/runtime/logger_spec.rb
@@ -7,27 +7,27 @@ describe QA::Runtime::Logger do
described_class.logger = logger
end
- it 'logs debug' do
- expect { described_class.debug('test') }.to output(/DEBUG -- : test/).to_stdout_from_any_process
+ it "logs debug" do
+ expect { described_class.debug("test") }.to output(/DEBUG -- : test/).to_stdout_from_any_process
end
- it 'logs info' do
- expect { described_class.info('test') }.to output(/INFO -- : test/).to_stdout_from_any_process
+ it "logs info" do
+ expect { described_class.info("test") }.to output(/INFO -- : test/).to_stdout_from_any_process
end
- it 'logs warn' do
- expect { described_class.warn('test') }.to output(/WARN -- : test/).to_stdout_from_any_process
+ it "logs warn" do
+ expect { described_class.warn("test") }.to output(/WARN -- : test/).to_stdout_from_any_process
end
- it 'logs error' do
- expect { described_class.error('test') }.to output(/ERROR -- : test/).to_stdout_from_any_process
+ it "logs error" do
+ expect { described_class.error("test") }.to output(/ERROR -- : test/).to_stdout_from_any_process
end
- it 'logs fatal' do
- expect { described_class.fatal('test') }.to output(/FATAL -- : test/).to_stdout_from_any_process
+ it "logs fatal" do
+ expect { described_class.fatal("test") }.to output(/FATAL -- : test/).to_stdout_from_any_process
end
- it 'logs unknown' do
- expect { described_class.unknown('test') }.to output(/ANY -- : test/).to_stdout_from_any_process
+ it "logs unknown" do
+ expect { described_class.unknown("test") }.to output(/ANY -- : test/).to_stdout_from_any_process
end
end
diff --git a/qa/spec/runtime/release_spec.rb b/qa/spec/runtime/release_spec.rb
index e6b5a8dc315..f5d2c29bfb3 100644
--- a/qa/spec/runtime/release_spec.rb
+++ b/qa/spec/runtime/release_spec.rb
@@ -1,26 +1,26 @@
describe QA::Runtime::Release do
- context 'when release version has extension strategy' do
- let(:strategy) { spy('strategy') }
+ context "when release version has extension strategy" do
+ let(:strategy) { spy("strategy") }
before do
- stub_const('QA::CE::Strategy', strategy)
- stub_const('QA::EE::Strategy', strategy)
+ stub_const("QA::CE::Strategy", strategy)
+ stub_const("QA::EE::Strategy", strategy)
end
- describe '#version' do
- it 'return either CE or EE version' do
+ describe "#version" do
+ it "return either CE or EE version" do
expect(subject.version).to eq(:CE).or eq(:EE)
end
end
- describe '#strategy' do
- it 'return the strategy constant' do
+ describe "#strategy" do
+ it "return the strategy constant" do
expect(subject.strategy).to eq strategy
end
end
- describe 'delegated class methods' do
- it 'delegates all calls to strategy class' do
+ describe "delegated class methods" do
+ it "delegates all calls to strategy class" do
described_class.some_method(1, 2)
expect(strategy).to have_received(:some_method)
@@ -29,20 +29,20 @@ describe QA::Runtime::Release do
end
end
- context 'when release version does not have extension strategy' do
+ context "when release version does not have extension strategy" do
before do
allow_any_instance_of(described_class)
- .to receive(:version).and_return('something')
+ .to receive(:version).and_return("something")
end
- describe '#strategy' do
- it 'raises error' do
+ describe "#strategy" do
+ it "raises error" do
expect { subject.strategy }.to raise_error(LoadError)
end
end
- describe 'delegated class methods' do
- it 'raises error' do
+ describe "delegated class methods" do
+ it "raises error" do
expect { described_class.some_method(2, 3) }.to raise_error(LoadError)
end
end
diff --git a/qa/spec/runtime/scenario_spec.rb b/qa/spec/runtime/scenario_spec.rb
index 7009192bcc0..531a2ffd62c 100644
--- a/qa/spec/runtime/scenario_spec.rb
+++ b/qa/spec/runtime/scenario_spec.rb
@@ -3,23 +3,23 @@ describe QA::Runtime::Scenario do
Module.new.extend(described_class)
end
- it 'makes it possible to define global scenario attributes' do
- subject.define(:my_attribute, 'some-value')
- subject.define(:another_attribute, 'another-value')
+ it "makes it possible to define global scenario attributes" do
+ subject.define(:my_attribute, "some-value")
+ subject.define(:another_attribute, "another-value")
- expect(subject.my_attribute).to eq 'some-value'
- expect(subject.another_attribute).to eq 'another-value'
+ expect(subject.my_attribute).to eq "some-value"
+ expect(subject.another_attribute).to eq "another-value"
expect(subject.attributes)
- .to eq(my_attribute: 'some-value', another_attribute: 'another-value')
+ .to eq(my_attribute: "some-value", another_attribute: "another-value")
end
- it 'raises error when attribute is not known' do
+ it "raises error when attribute is not known" do
expect { subject.invalid_accessor }
.to raise_error ArgumentError, /invalid_accessor/
end
- it 'raises error when attribute is empty' do
- subject.define(:empty_attribute, '')
+ it "raises error when attribute is empty" do
+ subject.define(:empty_attribute, "")
expect { subject.empty_attribute }
.to raise_error ArgumentError, /empty_attribute/
diff --git a/qa/spec/scenario/actable_spec.rb b/qa/spec/scenario/actable_spec.rb
index 422763910e4..c19bdf85415 100644
--- a/qa/spec/scenario/actable_spec.rb
+++ b/qa/spec/scenario/actable_spec.rb
@@ -11,37 +11,37 @@ describe QA::Scenario::Actable do
end
end
- describe '.act' do
- it 'provides means to run steps' do
+ describe ".act" do
+ it "provides means to run steps" do
result = subject.act { do_something }
- expect(result).to eq 'some'
+ expect(result).to eq "some"
end
- it 'supports passing variables' do
- result = subject.act('thing') do |variable|
+ it "supports passing variables" do
+ result = subject.act("thing") { |variable|
do_something(variable)
- end
+ }
- expect(result).to eq 'something'
+ expect(result).to eq "something"
end
- it 'returns value from the last method' do
- result = subject.act { 'test' }
+ it "returns value from the last method" do
+ result = subject.act { "test" }
- expect(result).to eq 'test'
+ expect(result).to eq "test"
end
end
- describe '.perform' do
- it 'makes it possible to pass binding' do
- variable = 'something'
+ describe ".perform" do
+ it "makes it possible to pass binding" do
+ variable = "something"
- result = subject.perform do |object|
+ result = subject.perform { |object|
object.something = variable
- end
+ }
- expect(result).to eq 'something'
+ expect(result).to eq "something"
end
end
end
diff --git a/qa/spec/scenario/bootable_spec.rb b/qa/spec/scenario/bootable_spec.rb
index 273aac7677e..c172cf61282 100644
--- a/qa/spec/scenario/bootable_spec.rb
+++ b/qa/spec/scenario/bootable_spec.rb
@@ -4,20 +4,20 @@ describe QA::Scenario::Bootable do
.include(described_class)
end
- it 'makes it possible to define the scenario attribute' do
+ it "makes it possible to define the scenario attribute" do
subject.class_eval do
- attribute :something, '--something SOMETHING', 'Some attribute'
- attribute :another, '--another ANOTHER', 'Some other attribute'
+ attribute :something, "--something SOMETHING", "Some attribute"
+ attribute :another, "--another ANOTHER", "Some other attribute"
end
expect(subject).to receive(:perform)
- .with(something: 'test', another: 'other')
+ .with(something: "test", another: "other")
subject.launch!(%w[--another other --something test])
end
- it 'does not require attributes to be defined' do
- expect(subject).to receive(:perform).with('some', 'argv')
+ it "does not require attributes to be defined" do
+ expect(subject).to receive(:perform).with("some", "argv")
subject.launch!(%w[some argv])
end
diff --git a/qa/spec/scenario/test/instance/all_spec.rb b/qa/spec/scenario/test/instance/all_spec.rb
index 9311d1d8199..a91f5e4d441 100644
--- a/qa/spec/scenario/test/instance/all_spec.rb
+++ b/qa/spec/scenario/test/instance/all_spec.rb
@@ -1,3 +1,3 @@
describe QA::Scenario::Test::Instance::All do
- it_behaves_like 'a QA scenario class'
+ it_behaves_like "a QA scenario class"
end
diff --git a/qa/spec/scenario/test/instance/smoke_spec.rb b/qa/spec/scenario/test/instance/smoke_spec.rb
index b5db9783af3..c3ba8e3e66a 100644
--- a/qa/spec/scenario/test/instance/smoke_spec.rb
+++ b/qa/spec/scenario/test/instance/smoke_spec.rb
@@ -1,5 +1,5 @@
describe QA::Scenario::Test::Instance::Smoke do
- it_behaves_like 'a QA scenario class' do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:smoke] }
end
end
diff --git a/qa/spec/scenario/test/integration/github_spec.rb b/qa/spec/scenario/test/integration/github_spec.rb
index c2aeb1ded1d..8982654ab6f 100644
--- a/qa/spec/scenario/test/integration/github_spec.rb
+++ b/qa/spec/scenario/test/integration/github_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Github do
- context '#perform' do
- let(:env) { spy('Runtime::Env') }
+ context "#perform" do
+ let(:env) { spy("Runtime::Env") }
before do
- stub_const('QA::Runtime::Env', env)
+ stub_const("QA::Runtime::Env", env)
end
- it_behaves_like 'a QA scenario class' do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:github] }
- it 'requires a GitHub access token' do
- subject.perform('gitlab_address')
+ it "requires a GitHub access token" do
+ subject.perform("gitlab_address")
expect(env).to have_received(:require_github_access_token!)
end
diff --git a/qa/spec/scenario/test/integration/instance_saml_spec.rb b/qa/spec/scenario/test/integration/instance_saml_spec.rb
index cb8a6a630cc..487f8e3bfa3 100644
--- a/qa/spec/scenario/test/integration/instance_saml_spec.rb
+++ b/qa/spec/scenario/test/integration/instance_saml_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::InstanceSAML do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:instance_saml] }
end
end
diff --git a/qa/spec/scenario/test/integration/kubernetes_spec.rb b/qa/spec/scenario/test/integration/kubernetes_spec.rb
index cb43994b229..10546bd68cd 100644
--- a/qa/spec/scenario/test/integration/kubernetes_spec.rb
+++ b/qa/spec/scenario/test/integration/kubernetes_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Kubernetes do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:kubernetes] }
end
end
diff --git a/qa/spec/scenario/test/integration/ldap_spec.rb b/qa/spec/scenario/test/integration/ldap_spec.rb
index b6d798bf504..ac1169285c3 100644
--- a/qa/spec/scenario/test/integration/ldap_spec.rb
+++ b/qa/spec/scenario/test/integration/ldap_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::LDAPNoTLS do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:ldap_no_tls] }
end
end
end
describe QA::Scenario::Test::Integration::LDAPTLS do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:ldap_tls] }
end
end
diff --git a/qa/spec/scenario/test/integration/mattermost_spec.rb b/qa/spec/scenario/test/integration/mattermost_spec.rb
index 59caf2ba2cd..9e61804b26c 100644
--- a/qa/spec/scenario/test/integration/mattermost_spec.rb
+++ b/qa/spec/scenario/test/integration/mattermost_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::Mattermost do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:args) { %w[gitlab_address mattermost_address] }
let(:tags) { [:mattermost] }
- let(:options) { ['path1']}
+ let(:options) { ["path1"]}
- it 'requires a GitHub access token' do
+ it "requires a GitHub access token" do
subject.perform(*args)
expect(attributes).to have_received(:define)
- .with(:mattermost_address, 'mattermost_address')
+ .with(:mattermost_address, "mattermost_address")
end
end
end
diff --git a/qa/spec/scenario/test/integration/oauth_spec.rb b/qa/spec/scenario/test/integration/oauth_spec.rb
index c1c320be576..82a6e0f9eb9 100644
--- a/qa/spec/scenario/test/integration/oauth_spec.rb
+++ b/qa/spec/scenario/test/integration/oauth_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::OAuth do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:oauth] }
end
end
diff --git a/qa/spec/scenario/test/integration/object_storage_spec.rb b/qa/spec/scenario/test/integration/object_storage_spec.rb
index 2b7188223e0..79f432ef2d9 100644
--- a/qa/spec/scenario/test/integration/object_storage_spec.rb
+++ b/qa/spec/scenario/test/integration/object_storage_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
describe QA::Scenario::Test::Integration::ObjectStorage do
- context '#perform' do
- it_behaves_like 'a QA scenario class' do
+ context "#perform" do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:object_storage] }
end
end
diff --git a/qa/spec/scenario/test/sanity/framework_spec.rb b/qa/spec/scenario/test/sanity/framework_spec.rb
index 44ac780556e..d09c8107a84 100644
--- a/qa/spec/scenario/test/sanity/framework_spec.rb
+++ b/qa/spec/scenario/test/sanity/framework_spec.rb
@@ -1,5 +1,5 @@
describe QA::Scenario::Test::Sanity::Framework do
- it_behaves_like 'a QA scenario class' do
+ it_behaves_like "a QA scenario class" do
let(:tags) { [:framework] }
end
end
diff --git a/qa/spec/scenario/test/sanity/selectors_spec.rb b/qa/spec/scenario/test/sanity/selectors_spec.rb
index 45d21d54955..20f79e1a260 100644
--- a/qa/spec/scenario/test/sanity/selectors_spec.rb
+++ b/qa/spec/scenario/test/sanity/selectors_spec.rb
@@ -1,16 +1,16 @@
describe QA::Scenario::Test::Sanity::Selectors do
- let(:validator) { spy('validator') }
+ let(:validator) { spy("validator") }
before do
- stub_const('QA::Page::Validator', validator)
+ stub_const("QA::Page::Validator", validator)
end
- context 'when there are errors detected' do
+ context "when there are errors detected" do
before do
- allow(validator).to receive(:errors).and_return(['some error'])
+ allow(validator).to receive(:errors).and_return(["some error"])
end
- it 'outputs information about errors' do
+ it "outputs information about errors" do
expect { described_class.perform }
.to output(/some error/).to_stderr
@@ -20,18 +20,18 @@ describe QA::Scenario::Test::Sanity::Selectors do
end
end
- context 'when there are no errors detected' do
+ context "when there are no errors detected" do
before do
allow(validator).to receive(:errors).and_return([])
end
- it 'processes pages module' do
+ it "processes pages module" do
described_class.perform
expect(validator).to have_received(:new).with(QA::Page)
end
- it 'triggers validation' do
+ it "triggers validation" do
described_class.perform
expect(validator).to have_received(:validate!).at_least(:once)
diff --git a/qa/spec/shared_examples/scenario_shared_examples.rb b/qa/spec/shared_examples/scenario_shared_examples.rb
index 5fd55d7d96b..dd3a7688ec8 100644
--- a/qa/spec/shared_examples/scenario_shared_examples.rb
+++ b/qa/spec/shared_examples/scenario_shared_examples.rb
@@ -1,46 +1,46 @@
# frozen_string_literal: true
-shared_examples 'a QA scenario class' do
- let(:attributes) { spy('Runtime::Scenario') }
- let(:release) { spy('Runtime::Release') }
- let(:runner) { spy('Specs::Runner') }
+shared_examples "a QA scenario class" do
+ let(:attributes) { spy("Runtime::Scenario") }
+ let(:release) { spy("Runtime::Release") }
+ let(:runner) { spy("Specs::Runner") }
- let(:args) { ['gitlab_address'] }
+ let(:args) { ["gitlab_address"] }
let(:tags) { [] }
let(:options) { %w[path1 path2] }
before do
- stub_const('QA::Runtime::Release', release)
- stub_const('QA::Runtime::Scenario', attributes)
- stub_const('QA::Specs::Runner', runner)
+ stub_const("QA::Runtime::Release", release)
+ stub_const("QA::Runtime::Scenario", attributes)
+ stub_const("QA::Specs::Runner", runner)
allow(runner).to receive(:perform).and_yield(runner)
end
- it 'responds to perform' do
+ it "responds to perform" do
expect(subject).to respond_to(:perform)
end
- it 'sets an address of the subject' do
+ it "sets an address of the subject" do
subject.perform(*args)
- expect(attributes).to have_received(:define).with(:gitlab_address, 'gitlab_address')
+ expect(attributes).to have_received(:define).with(:gitlab_address, "gitlab_address")
end
- it 'performs before hooks' do
+ it "performs before hooks" do
subject.perform(*args)
expect(release).to have_received(:perform_before_hooks)
end
- it 'sets tags on runner' do
+ it "sets tags on runner" do
subject.perform(*args)
expect(runner).to have_received(:tags=).with(tags)
end
- context 'specifying RSpec options' do
- it 'sets options on runner' do
+ context "specifying RSpec options" do
+ it "sets options on runner" do
subject.perform(*args, *options)
expect(runner).to have_received(:options=).with(options)
diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb
index cbdd6e881b1..83ce4fa7378 100644
--- a/qa/spec/spec_helper.rb
+++ b/qa/spec/spec_helper.rb
@@ -1,13 +1,13 @@
-require_relative '../qa'
-require 'rspec/retry'
+require_relative "../qa"
+require "rspec/retry"
%w[helpers shared_examples].each do |d|
- Dir[::File.join(__dir__, d, '**', '*.rb')].each { |f| require f }
+ Dir[::File.join(__dir__, d, "**", "*.rb")].each { |f| require f }
end
RSpec.configure do |config|
config.before(:context) do
- if self.class.metadata.keys.include?(:quarantine)
+ if self.class.metadata.key?(:quarantine)
skip_or_run_quarantined_tests(self.class.metadata.keys, config.inclusion_filter.rules.keys)
end
end
@@ -40,7 +40,7 @@ RSpec.configure do |config|
config.display_try_failure_messages = true
config.around do |example|
- retry_times = example.metadata.keys.include?(:quarantine) ? 1 : 3
+ retry_times = example.metadata.key?(:quarantine) ? 1 : 3
example.run_with_retry retry: retry_times
end
end
@@ -63,7 +63,7 @@ def skip_or_run_quarantined_tests(metadata_keys, filter_keys)
if filter_keys.include?(:quarantine)
skip("Only running tests tagged with :quarantine and any of #{included_filters}") unless quarantine_and_optional_other_tag?(metadata_keys, included_filters)
else
- skip('In quarantine') if metadata_keys.include?(:quarantine)
+ skip("In quarantine") if metadata_keys.include?(:quarantine)
end
end
diff --git a/qa/spec/spec_helper_spec.rb b/qa/spec/spec_helper_spec.rb
index 27ec1ec80fe..dfa3a8450de 100644
--- a/qa/spec/spec_helper_spec.rb
+++ b/qa/spec/spec_helper_spec.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
-describe 'rspec config tests' do
+describe "rspec config tests" do
let(:group) do
RSpec.describe do
- shared_examples 'passing tests' do
- example 'not in quarantine' do
+ shared_examples "passing tests" do
+ example "not in quarantine" do
end
- example 'in quarantine', :quarantine do
+ example "in quarantine", :quarantine do
end
end
- context 'default' do
- it_behaves_like 'passing tests'
+ context "default" do
+ it_behaves_like "passing tests"
end
- context 'foo', :foo do
- it_behaves_like 'passing tests'
+ context "foo", :foo do
+ it_behaves_like "passing tests"
end
- context 'quarantine', :quarantine do
- it_behaves_like 'passing tests'
+ context "quarantine", :quarantine do
+ it_behaves_like "passing tests"
end
- context 'bar quarantine', :bar, :quarantine do
- it_behaves_like 'passing tests'
+ context "bar quarantine", :bar, :quarantine do
+ it_behaves_like "passing tests"
end
end
end
@@ -34,23 +34,23 @@ describe 'rspec config tests' do
@expectations = [1, 2, 3]
end
- example 'not in quarantine' do
+ example "not in quarantine" do
expect(@expectations.shift).to be(3)
end
- example 'in quarantine', :quarantine do
+ example "in quarantine", :quarantine do
expect(@expectations.shift).to be(3)
end
end
end
- context 'with no tags focussed' do
+ context "with no tags focussed" do
before do
group.run
end
- context 'in a context tagged :foo' do
- it 'skips tests in quarantine' do
+ context "in a context tagged :foo" do
+ it "skips tests in quarantine" do
context = group.children.find { |c| c.description == "foo" }
examples = context.descendant_filtered_examples
expect(examples.count).to eq(2)
@@ -60,12 +60,12 @@ describe 'rspec config tests' do
ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('In quarantine')
+ expect(ex.execution_result.pending_message).to eq("In quarantine")
end
end
- context 'in an untagged context' do
- it 'skips tests in quarantine' do
+ context "in an untagged context" do
+ it "skips tests in quarantine" do
context = group.children.find { |c| c.description == "default" }
examples = context.descendant_filtered_examples
expect(examples.count).to eq(2)
@@ -75,12 +75,12 @@ describe 'rspec config tests' do
ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('In quarantine')
+ expect(ex.execution_result.pending_message).to eq("In quarantine")
end
end
- context 'in a context tagged :quarantine' do
- it 'skips all tests' do
+ context "in a context tagged :quarantine" do
+ it "skips all tests" do
context = group.children.find { |c| c.description == "quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to eq(2)
@@ -90,12 +90,12 @@ describe 'rspec config tests' do
ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('In quarantine')
+ expect(ex.execution_result.pending_message).to eq("In quarantine")
end
end
end
- context 'with :quarantine focussed' do
+ context "with :quarantine focussed" do
before do
RSpec.configure do |config|
config.inclusion_filter = :quarantine
@@ -109,8 +109,8 @@ describe 'rspec config tests' do
end
end
- context 'in an untagged context' do
- it 'only runs quarantined tests' do
+ context "in an untagged context" do
+ it "only runs quarantined tests" do
context = group.children.find { |c| c.description == "default" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(1)
@@ -120,8 +120,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :foo' do
- it 'only runs quarantined tests' do
+ context "in a context tagged :foo" do
+ it "only runs quarantined tests" do
context = group.children.find { |c| c.description == "foo" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(1)
@@ -131,8 +131,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :quarantine' do
- it 'runs all tests' do
+ context "in a context tagged :quarantine" do
+ it "runs all tests" do
context = group.children.find { |c| c.description == "quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -146,7 +146,7 @@ describe 'rspec config tests' do
end
end
- context 'with a non-quarantine tag (:foo) focussed' do
+ context "with a non-quarantine tag (:foo) focussed" do
before do
RSpec.configure do |config|
config.inclusion_filter = :foo
@@ -160,15 +160,15 @@ describe 'rspec config tests' do
end
end
- context 'in an untagged context' do
- it 'runs no tests' do
+ context "in an untagged context" do
+ it "runs no tests" do
context = group.children.find { |c| c.description == "default" }
expect(context.descendant_filtered_examples.count).to eq(0)
end
end
- context 'in a context tagged :foo' do
- it 'skips quarantined tests' do
+ context "in a context tagged :foo" do
+ it "skips quarantined tests" do
context = group.children.find { |c| c.description == "foo" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -178,22 +178,22 @@ describe 'rspec config tests' do
ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('In quarantine')
+ expect(ex.execution_result.pending_message).to eq("In quarantine")
end
end
- context 'in a context tagged :quarantine' do
- it 'runs no tests' do
+ context "in a context tagged :quarantine" do
+ it "runs no tests" do
context = group.children.find { |c| c.description == "quarantine" }
expect(context.descendant_filtered_examples.count).to eq(0)
end
end
end
- context 'with :quarantine and a non-quarantine tag (:foo) focussed' do
+ context "with :quarantine and a non-quarantine tag (:foo) focussed" do
before do
RSpec.configure do |config|
- config.inclusion_filter = { quarantine: true, foo: true }
+ config.inclusion_filter = {quarantine: true, foo: true}
end
group.run
@@ -204,8 +204,8 @@ describe 'rspec config tests' do
end
end
- context 'in an untagged context' do
- it 'ignores untagged tests and skips tests even if in quarantine' do
+ context "in an untagged context" do
+ it "ignores untagged tests and skips tests even if in quarantine" do
context = group.children.find { |c| c.description == "default" }
examples = context.descendant_filtered_examples
expect(examples.count).to eq(1)
@@ -215,8 +215,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :foo' do
- it 'only runs quarantined tests' do
+ context "in a context tagged :foo" do
+ it "only runs quarantined tests" do
context = group.children.find { |c| c.description == "foo" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -229,8 +229,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :quarantine' do
- it 'skips all tests' do
+ context "in a context tagged :quarantine" do
+ it "skips all tests" do
context = group.children.find { |c| c.description == "quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -243,8 +243,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :bar and :quarantine' do
- it 'skips all tests' do
+ context "in a context tagged :bar and :quarantine" do
+ it "skips all tests" do
context = group.children.find { |c| c.description == "quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -258,10 +258,10 @@ describe 'rspec config tests' do
end
end
- context 'with :quarantine and multiple non-quarantine tags focussed' do
+ context "with :quarantine and multiple non-quarantine tags focussed" do
before do
RSpec.configure do |config|
- config.inclusion_filter = { bar: true, foo: true, quarantine: true }
+ config.inclusion_filter = {bar: true, foo: true, quarantine: true}
end
group.run
@@ -272,8 +272,8 @@ describe 'rspec config tests' do
end
end
- context 'in a context tagged :foo' do
- it 'only runs quarantined tests' do
+ context "in a context tagged :foo" do
+ it "only runs quarantined tests" do
context = group.children.find { |c| c.description == "foo" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -283,28 +283,28 @@ describe 'rspec config tests' do
ex = examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('Only running tests tagged with :quarantine and any of [:bar, :foo]')
+ expect(ex.execution_result.pending_message).to eq("Only running tests tagged with :quarantine and any of [:bar, :foo]")
end
end
- context 'in a context tagged :quarantine' do
- it 'skips all tests' do
+ context "in a context tagged :quarantine" do
+ it "skips all tests" do
context = group.children.find { |c| c.description == "quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('Only running tests tagged with :quarantine and any of [:bar, :foo]')
+ expect(ex.execution_result.pending_message).to eq("Only running tests tagged with :quarantine and any of [:bar, :foo]")
ex = examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:pending)
- expect(ex.execution_result.pending_message).to eq('Only running tests tagged with :quarantine and any of [:bar, :foo]')
+ expect(ex.execution_result.pending_message).to eq("Only running tests tagged with :quarantine and any of [:bar, :foo]")
end
end
- context 'in a context tagged :bar and :quarantine' do
- it 'runs all tests' do
+ context "in a context tagged :bar and :quarantine" do
+ it "runs all tests" do
context = group.children.find { |c| c.description == "bar quarantine" }
examples = context.descendant_filtered_examples
expect(examples.count).to be(2)
@@ -318,20 +318,20 @@ describe 'rspec config tests' do
end
end
- context 'rspec retry' do
- context 'in an untagged context' do
+ context "rspec retry" do
+ context "in an untagged context" do
before do
group_2.run
end
- it 'should run example :retry times' do
+ it "should run example :retry times" do
examples = group_2.descendant_filtered_examples
- ex = examples.find { |e| e.description == 'not in quarantine' }
+ ex = examples.find { |e| e.description == "not in quarantine" }
expect(ex.execution_result.status).to eq(:passed)
end
end
- context 'with :quarantine focussed' do
+ context "with :quarantine focussed" do
before do
RSpec.configure do |config|
config.inclusion_filter = :quarantine
@@ -345,9 +345,9 @@ describe 'rspec config tests' do
end
end
- it 'should run example once only' do
+ it "should run example once only" do
examples = group_2.descendant_filtered_examples
- ex = examples.find { |e| e.description == 'in quarantine' }
+ ex = examples.find { |e| e.description == "in quarantine" }
expect(ex.execution_result.status).to eq(:failed)
end
end
diff --git a/qa/spec/specs/runner_spec.rb b/qa/spec/specs/runner_spec.rb
index 741821ddf8c..9b1b7a04e24 100644
--- a/qa/spec/specs/runner_spec.rb
+++ b/qa/spec/specs/runner_spec.rb
@@ -1,32 +1,32 @@
# frozen_string_literal: true
describe QA::Specs::Runner do
- context '#perform' do
+ context "#perform" do
before do
allow(QA::Runtime::Browser).to receive(:configure!)
end
- it 'excludes the orchestrated tag by default' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "excludes the orchestrated tag by default" do
+ expect_rspec_runner_arguments(["--tag", "~orchestrated", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
- context 'when tty is set' do
+ context "when tty is set" do
subject { described_class.new.tap { |runner| runner.tty = true } }
- it 'sets the `--tty` flag' do
- expect_rspec_runner_arguments(['--tty', '--tag', '~orchestrated', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "sets the `--tty` flag" do
+ expect_rspec_runner_arguments(["--tty", "--tag", "~orchestrated", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
end
- context 'when tags are set' do
+ context "when tags are set" do
subject { described_class.new.tap { |runner| runner.tags = %i[orchestrated github] } }
- it 'focuses on the given tags' do
- expect_rspec_runner_arguments(['--tag', 'orchestrated', '--tag', 'github', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "focuses on the given tags" do
+ expect_rspec_runner_arguments(["--tag", "orchestrated", "--tag", "github", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
@@ -35,8 +35,8 @@ describe QA::Specs::Runner do
context 'when "--tag smoke" is set as options' do
subject { described_class.new.tap { |runner| runner.options = %w[--tag smoke] } }
- it 'focuses on the given tag without excluded the orchestrated tag' do
- expect_rspec_runner_arguments(['--tag', 'smoke', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "focuses on the given tag without excluded the orchestrated tag" do
+ expect_rspec_runner_arguments(["--tag", "smoke", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
@@ -45,8 +45,8 @@ describe QA::Specs::Runner do
context 'when "qa/specs/features/foo" is set as options' do
subject { described_class.new.tap { |runner| runner.options = %w[qa/specs/features/foo] } }
- it 'passes the given tests path and excludes the orchestrated tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', 'qa/specs/features/foo'])
+ it "passes the given tests path and excludes the orchestrated tag" do
+ expect_rspec_runner_arguments(["--tag", "~orchestrated", "qa/specs/features/foo"])
subject.perform
end
@@ -55,36 +55,36 @@ describe QA::Specs::Runner do
context 'when "-- qa/specs/features/foo" is set as options' do
subject { described_class.new.tap { |runner| runner.options = %w[-- qa/specs/features/foo] } }
- it 'passes the given tests path and excludes the orchestrated tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--', 'qa/specs/features/foo'])
+ it "passes the given tests path and excludes the orchestrated tag" do
+ expect_rspec_runner_arguments(["--tag", "~orchestrated", "--", "qa/specs/features/foo"])
subject.perform
end
end
- context 'when SIGNUP_DISABLED is true' do
+ context "when SIGNUP_DISABLED is true" do
before do
allow(QA::Runtime::Env).to receive(:signup_disabled?).and_return(true)
end
subject { described_class.new }
- it 'it includes default args and excludes the skip_signup_disabled tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~skip_signup_disabled', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "it includes default args and excludes the skip_signup_disabled tag" do
+ expect_rspec_runner_arguments(["--tag", "~orchestrated", "--tag", "~skip_signup_disabled", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
end
- context 'when git protocol v2 is not supported' do
+ context "when git protocol v2 is not supported" do
before do
allow(QA::Runtime::Env).to receive(:can_test?).with(:git_protocol_v2).and_return(false)
end
subject { described_class.new }
- it 'it includes default args and excludes the requires_git_protocol_v2 tag' do
- expect_rspec_runner_arguments(['--tag', '~orchestrated', '--tag', '~requires_git_protocol_v2', *described_class::DEFAULT_TEST_PATH_ARGS])
+ it "it includes default args and excludes the requires_git_protocol_v2 tag" do
+ expect_rspec_runner_arguments(["--tag", "~orchestrated", "--tag", "~requires_git_protocol_v2", *described_class::DEFAULT_TEST_PATH_ARGS])
subject.perform
end
diff --git a/qa/spec/support/waiter_spec.rb b/qa/spec/support/waiter_spec.rb
index 8283b65e1be..ed912d78a39 100644
--- a/qa/spec/support/waiter_spec.rb
+++ b/qa/spec/support/waiter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'logger'
+require "logger"
describe QA::Support::Waiter do
before do
@@ -9,28 +9,28 @@ describe QA::Support::Waiter do
QA::Runtime::Logger.logger = logger
end
- describe '.wait' do
- context 'when the condition is true' do
- it 'logs the start' do
+ describe ".wait" do
+ context "when the condition is true" do
+ it "logs the start" do
expect { subject.wait(max: 0) {} }
- .to output(/with wait: max 0; interval 0.1/).to_stdout_from_any_process
+ .to output(/with wait: max 0; interval 0.1/).to_stdout_from_any_process
end
- it 'logs the end' do
+ it "logs the end" do
expect { subject.wait(max: 0) {} }
- .to output(/ended wait after .* seconds$/).to_stdout_from_any_process
+ .to output(/ended wait after .* seconds$/).to_stdout_from_any_process
end
end
- context 'when the condition is false' do
- it 'logs the start' do
+ context "when the condition is false" do
+ it "logs the start" do
expect { subject.wait(max: 0) { false } }
- .to output(/with wait: max 0; interval 0.1/).to_stdout_from_any_process
+ .to output(/with wait: max 0; interval 0.1/).to_stdout_from_any_process
end
- it 'logs the end' do
+ it "logs the end" do
expect { subject.wait(max: 0) { false } }
- .to output(/ended wait after .* seconds$/).to_stdout_from_any_process
+ .to output(/ended wait after .* seconds$/).to_stdout_from_any_process
end
end
end
diff --git a/rubocop/code_reuse_helpers.rb b/rubocop/code_reuse_helpers.rb
index 0929a55d901..cca621c9c36 100644
--- a/rubocop/code_reuse_helpers.rb
+++ b/rubocop/code_reuse_helpers.rb
@@ -32,47 +32,47 @@ module RuboCop
# Returns true if the given node resides in app/finders or ee/app/finders.
def in_finder?(node)
- in_directory?(node, 'finders')
+ in_directory?(node, "finders")
end
# Returns true if the given node resides in app/models or ee/app/models.
def in_model?(node)
- in_directory?(node, 'models')
+ in_directory?(node, "models")
end
# Returns true if the given node resides in app/services or ee/app/services.
def in_service_class?(node)
- in_directory?(node, 'services')
+ in_directory?(node, "services")
end
# Returns true if the given node resides in app/presenters or
# ee/app/presenters.
def in_presenter?(node)
- in_directory?(node, 'presenters')
+ in_directory?(node, "presenters")
end
# Returns true if the given node resides in app/serializers or
# ee/app/serializers.
def in_serializer?(node)
- in_directory?(node, 'serializers')
+ in_directory?(node, "serializers")
end
# Returns true if the given node resides in app/workers or ee/app/workers.
def in_worker?(node)
- in_directory?(node, 'workers')
+ in_directory?(node, "workers")
end
# Returns true if the given node resides in app/controllers or
# ee/app/controllers.
def in_controller?(node)
- in_directory?(node, 'controllers')
+ in_directory?(node, "controllers")
end
# Returns true if the given node resides in lib/api or ee/lib/api.
def in_api?(node)
file_path_for_node(node).start_with?(
- File.join(ce_lib_directory, 'api'),
- File.join(ee_lib_directory, 'api')
+ File.join(ce_lib_directory, "api"),
+ File.join(ee_lib_directory, "api")
)
end
@@ -134,23 +134,23 @@ module RuboCop
end
def ce_app_directory
- File.join(rails_root, 'app')
+ File.join(rails_root, "app")
end
def ee_app_directory
- File.join(rails_root, 'ee', 'app')
+ File.join(rails_root, "ee", "app")
end
def ce_lib_directory
- File.join(rails_root, 'lib')
+ File.join(rails_root, "lib")
end
def ee_lib_directory
- File.join(rails_root, 'ee', 'lib')
+ File.join(rails_root, "ee", "lib")
end
def rails_root
- File.expand_path('..', __dir__)
+ File.expand_path("..", __dir__)
end
end
end
diff --git a/rubocop/cop/avoid_break_from_strong_memoize.rb b/rubocop/cop/avoid_break_from_strong_memoize.rb
index 9b436118db3..e60615498d0 100644
--- a/rubocop/cop/avoid_break_from_strong_memoize.rb
+++ b/rubocop/cop/avoid_break_from_strong_memoize.rb
@@ -21,7 +21,7 @@ module RuboCop
# end
#
class AvoidBreakFromStrongMemoize < RuboCop::Cop::Cop
- MSG = 'Do not use break inside strong_memoize, use next instead.'
+ MSG = "Do not use break inside strong_memoize, use next instead."
def on_block(node)
block_body = node.body
diff --git a/rubocop/cop/avoid_return_from_blocks.rb b/rubocop/cop/avoid_return_from_blocks.rb
index 40b2aed019f..cbce8989b77 100644
--- a/rubocop/cop/avoid_return_from_blocks.rb
+++ b/rubocop/cop/avoid_return_from_blocks.rb
@@ -21,7 +21,7 @@ module RuboCop
# end
#
class AvoidReturnFromBlocks < RuboCop::Cop::Cop
- MSG = 'Do not return from a block, use next or break instead.'
+ MSG = "Do not return from a block, use next or break instead."
DEF_METHODS = %i[define_method lambda].freeze
WHITELISTED_METHODS = %i[each each_filename times loop].freeze
diff --git a/rubocop/cop/avoid_route_redirect_leading_slash.rb b/rubocop/cop/avoid_route_redirect_leading_slash.rb
index 7ac1c881269..a3606bbcd60 100644
--- a/rubocop/cop/avoid_route_redirect_leading_slash.rb
+++ b/rubocop/cop/avoid_route_redirect_leading_slash.rb
@@ -35,7 +35,7 @@ module RuboCop
path = node.location.expression.source_buffer.name
dirname = File.dirname(path)
filename = File.basename(path)
- dirname.end_with?('config/routes') || filename.end_with?('routes.rb')
+ dirname.end_with?("config/routes") || filename.end_with?("routes.rb")
end
def autocorrect(node)
@@ -45,7 +45,7 @@ module RuboCop
end
def remove_leading_slash(node)
- node.source.sub('/', '')
+ node.source.sub("/", "")
end
end
end
diff --git a/rubocop/cop/code_reuse/active_record.rb b/rubocop/cop/code_reuse/active_record.rb
index 2be8f7c11aa..dd8b0a8c1bd 100644
--- a/rubocop/cop/code_reuse/active_record.rb
+++ b/rubocop/cop/code_reuse/active_record.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers'
+require_relative "../../code_reuse_helpers"
module RuboCop
module Cop
@@ -9,7 +9,7 @@ module RuboCop
class ActiveRecord < RuboCop::Cop::Cop
include CodeReuseHelpers
- MSG = 'This method can only be used inside an ActiveRecord model'
+ MSG = "This method can only be used inside an ActiveRecord model"
# Various methods from ActiveRecord::Querying that are blacklisted. We
# exclude some generic ones such as `any?` and `first`, as these may
@@ -62,7 +62,7 @@ module RuboCop
take!: false,
unscope: false,
where: false,
- with: true
+ with: true,
}.freeze
# Directories that allow the use of the blacklisted methods. These
@@ -113,7 +113,7 @@ module RuboCop
WHITELISTED_DIRECTORIES.any? do |directory|
path.start_with?(
File.join(rails_root, directory),
- File.join(rails_root, 'ee', directory)
+ File.join(rails_root, "ee", directory)
)
end
end
@@ -149,7 +149,7 @@ module RuboCop
end
def indentation_of(node)
- ' ' * node.loc.expression.source_line[/\A */].length
+ " " * node.loc.expression.source_line[/\A */].length
end
def surrounding_scope_of(node)
diff --git a/rubocop/cop/code_reuse/finder.rb b/rubocop/cop/code_reuse/finder.rb
index 1d70befe79b..9c8c17636b6 100644
--- a/rubocop/cop/code_reuse/finder.rb
+++ b/rubocop/cop/code_reuse/finder.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers'
+require_relative "../../code_reuse_helpers"
module RuboCop
module Cop
@@ -9,12 +9,12 @@ module RuboCop
class Finder < RuboCop::Cop::Cop
include CodeReuseHelpers
- IN_FINDER = 'Finders can not be used inside a Finder.'
+ IN_FINDER = "Finders can not be used inside a Finder."
IN_MODEL_CLASS_METHOD =
- 'Finders can not be used inside model class methods.'
+ "Finders can not be used inside model class methods."
- SUFFIX = 'Finder'
+ SUFFIX = "Finder"
def on_class(node)
if in_finder?(node)
diff --git a/rubocop/cop/code_reuse/presenter.rb b/rubocop/cop/code_reuse/presenter.rb
index 5f8f2839ca6..127716a8d8e 100644
--- a/rubocop/cop/code_reuse/presenter.rb
+++ b/rubocop/cop/code_reuse/presenter.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers.rb'
+require_relative "../../code_reuse_helpers.rb"
module RuboCop
module Cop
@@ -9,13 +9,13 @@ module RuboCop
class Presenter < RuboCop::Cop::Cop
include CodeReuseHelpers
- IN_SERVICE = 'Presenters can not be used in a Service class.'
- IN_FINDER = 'Presenters can not be used in a Finder.'
- IN_PRESENTER = 'Presenters can not be used in a Presenter.'
- IN_SERIALIZER = 'Presenters can not be used in a Serializer.'
- IN_MODEL = 'Presenters can not be used in a model.'
- IN_WORKER = 'Presenters can not be used in a worker.'
- SUFFIX = 'Presenter'
+ IN_SERVICE = "Presenters can not be used in a Service class."
+ IN_FINDER = "Presenters can not be used in a Finder."
+ IN_PRESENTER = "Presenters can not be used in a Presenter."
+ IN_SERIALIZER = "Presenters can not be used in a Serializer."
+ IN_MODEL = "Presenters can not be used in a model."
+ IN_WORKER = "Presenters can not be used in a worker."
+ SUFFIX = "Presenter"
def on_class(node)
message =
diff --git a/rubocop/cop/code_reuse/serializer.rb b/rubocop/cop/code_reuse/serializer.rb
index 2212c50514e..b4344dde0c8 100644
--- a/rubocop/cop/code_reuse/serializer.rb
+++ b/rubocop/cop/code_reuse/serializer.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers.rb'
+require_relative "../../code_reuse_helpers.rb"
module RuboCop
module Cop
@@ -9,13 +9,13 @@ module RuboCop
class Serializer < RuboCop::Cop::Cop
include CodeReuseHelpers
- IN_SERVICE = 'Serializers can not be used in a Service class.'
- IN_FINDER = 'Serializers can not be used in a Finder.'
- IN_PRESENTER = 'Serializers can not be used in a Presenter.'
- IN_SERIALIZER = 'Serializers can not be used in a Serializer.'
- IN_MODEL = 'Serializers can not be used in a model.'
- IN_WORKER = 'Serializers can not be used in a worker.'
- SUFFIX = 'Serializer'
+ IN_SERVICE = "Serializers can not be used in a Service class."
+ IN_FINDER = "Serializers can not be used in a Finder."
+ IN_PRESENTER = "Serializers can not be used in a Presenter."
+ IN_SERIALIZER = "Serializers can not be used in a Serializer."
+ IN_MODEL = "Serializers can not be used in a model."
+ IN_WORKER = "Serializers can not be used in a worker."
+ SUFFIX = "Serializer"
def on_class(node)
message =
diff --git a/rubocop/cop/code_reuse/service_class.rb b/rubocop/cop/code_reuse/service_class.rb
index 768b43fb684..eb13b4fc04e 100644
--- a/rubocop/cop/code_reuse/service_class.rb
+++ b/rubocop/cop/code_reuse/service_class.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers.rb'
+require_relative "../../code_reuse_helpers.rb"
module RuboCop
module Cop
@@ -9,11 +9,11 @@ module RuboCop
class ServiceClass < RuboCop::Cop::Cop
include CodeReuseHelpers
- IN_FINDER = 'Service classes can not be used in a Finder.'
- IN_PRESENTER = 'Service classes can not be used in a Presenter.'
- IN_SERIALIZER = 'Service classes can not be used in a Serializer.'
- IN_MODEL = 'Service classes can not be used in a model.'
- SUFFIX = 'Service'
+ IN_FINDER = "Service classes can not be used in a Finder."
+ IN_PRESENTER = "Service classes can not be used in a Presenter."
+ IN_SERIALIZER = "Service classes can not be used in a Serializer."
+ IN_MODEL = "Service classes can not be used in a model."
+ SUFFIX = "Service"
def on_class(node)
check_all_send_nodes(node)
diff --git a/rubocop/cop/code_reuse/worker.rb b/rubocop/cop/code_reuse/worker.rb
index e38d2783d0f..e8082247a97 100644
--- a/rubocop/cop/code_reuse/worker.rb
+++ b/rubocop/cop/code_reuse/worker.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require_relative '../../code_reuse_helpers.rb'
+require_relative "../../code_reuse_helpers.rb"
module RuboCop
module Cop
@@ -9,16 +9,16 @@ module RuboCop
class Worker < RuboCop::Cop::Cop
include CodeReuseHelpers
- IN_CONTROLLER = 'Workers can not be used in a controller.'
- IN_API = 'Workers can not be used in a Grape API.'
- IN_FINDER = 'Workers can not be used in a Finder.'
- IN_PRESENTER = 'Workers can not be used in a Presenter.'
- IN_SERIALIZER = 'Workers can not be used in a Serializer.'
+ IN_CONTROLLER = "Workers can not be used in a controller."
+ IN_API = "Workers can not be used in a Grape API."
+ IN_FINDER = "Workers can not be used in a Finder."
+ IN_PRESENTER = "Workers can not be used in a Presenter."
+ IN_SERIALIZER = "Workers can not be used in a Serializer."
IN_MODEL_CLASS_METHOD =
- 'Workers can not be used in model class methods.'
+ "Workers can not be used in model class methods."
- SUFFIX = 'Worker'
+ SUFFIX = "Worker"
def on_class(node)
if in_model?(node)
diff --git a/rubocop/cop/destroy_all.rb b/rubocop/cop/destroy_all.rb
index 38b6cb40f91..d2f08ec0888 100644
--- a/rubocop/cop/destroy_all.rb
+++ b/rubocop/cop/destroy_all.rb
@@ -4,9 +4,9 @@ module RuboCop
module Cop
# Cop that blacklists the use of `destroy_all`.
class DestroyAll < RuboCop::Cop::Cop
- MSG = 'Use `delete_all` instead of `destroy_all`. ' \
- '`destroy_all` will load the rows into memory, then execute a ' \
- '`DELETE` for every individual row.'
+ MSG = "Use `delete_all` instead of `destroy_all`. " \
+ "`destroy_all` will load the rows into memory, then execute a " \
+ "`DELETE` for every individual row."
def_node_matcher :destroy_all?, <<~PATTERN
(send {send ivar lvar const} :destroy_all ...)
diff --git a/rubocop/cop/gitlab/finder_with_find_by.rb b/rubocop/cop/gitlab/finder_with_find_by.rb
index f45a37ddc06..691458c758a 100644
--- a/rubocop/cop/gitlab/finder_with_find_by.rb
+++ b/rubocop/cop/gitlab/finder_with_find_by.rb
@@ -3,15 +3,14 @@ module RuboCop
module Gitlab
class FinderWithFindBy < RuboCop::Cop::Cop
FIND_PATTERN = /\Afind(_by\!?)?\z/
- ALLOWED_MODULES = ['FinderMethods'].freeze
+ ALLOWED_MODULES = ["FinderMethods"].freeze
def message(used_method)
<<~MSG
- Don't chain finders `#execute` method with `##{used_method}`.
- Instead include `FinderMethods` in the Finder and call `##{used_method}`
- directly on the finder instance.
-
- This will make sure all authorization checks are performed on the resource.
+ Don't chain finders `#execute` method with `##{used_method}`.
+ Instead include `FinderMethods` in the Finder and call `##{used_method}`
+ directly on the finder instance.
+ This will make sure all authorization checks are performed on the resource.
MSG
end
@@ -26,8 +25,8 @@ module RuboCop
upto_including_execute = node.descendants.first.source_range
before_execute = node.descendants[1].source_range
range_to_remove = node.source_range
- .with(begin_pos: before_execute.end_pos,
- end_pos: upto_including_execute.end_pos)
+ .with(begin_pos: before_execute.end_pos,
+ end_pos: upto_including_execute.end_pos)
corrector.remove(range_to_remove)
end
diff --git a/rubocop/cop/gitlab/httparty.rb b/rubocop/cop/gitlab/httparty.rb
index 215f18b6993..6e3ca9fff2c 100644
--- a/rubocop/cop/gitlab/httparty.rb
+++ b/rubocop/cop/gitlab/httparty.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helpers'
+require_relative "../../spec_helpers"
module RuboCop
module Cop
@@ -50,7 +50,7 @@ module RuboCop
def autocorrect_httparty_node(node)
_, method_name, *arg_nodes = *node
- replacement = "Gitlab::HTTP.#{method_name}(#{arg_nodes.map(&:source).join(', ')})"
+ replacement = "Gitlab::HTTP.#{method_name}(#{arg_nodes.map(&:source).join(", ")})"
lambda do |corrector|
corrector.replace(node.source_range, replacement)
diff --git a/rubocop/cop/gitlab/predicate_memoization.rb b/rubocop/cop/gitlab/predicate_memoization.rb
index 3c25d61d087..cb0d29e313a 100644
--- a/rubocop/cop/gitlab/predicate_memoization.rb
+++ b/rubocop/cop/gitlab/predicate_memoization.rb
@@ -19,7 +19,7 @@ module RuboCop
private
def predicate_method?(node)
- node.method_name.to_s.end_with?('?')
+ node.method_name.to_s.end_with?("?")
end
def or_ivar_assignment?(or_assignment)
diff --git a/rubocop/cop/gitlab/union.rb b/rubocop/cop/gitlab/union.rb
index 09541d8af3b..75f7ab98280 100644
--- a/rubocop/cop/gitlab/union.rb
+++ b/rubocop/cop/gitlab/union.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require_relative '../../spec_helpers'
+
+require_relative "../../spec_helpers"
module RuboCop
module Cop
@@ -9,7 +10,7 @@ module RuboCop
class Union < RuboCop::Cop::Cop
include SpecHelpers
- MSG = 'Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly'
+ MSG = "Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly"
def_node_matcher :raw_union?, <<~PATTERN
(send (const (const (const nil? :Gitlab) :SQL) :Union) :new ...)
diff --git a/rubocop/cop/group_public_or_visible_to_user.rb b/rubocop/cop/group_public_or_visible_to_user.rb
index beda0b7f8ba..1b3b4450dfd 100644
--- a/rubocop/cop/group_public_or_visible_to_user.rb
+++ b/rubocop/cop/group_public_or_visible_to_user.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-#
+
module RuboCop
module Cop
# Cop that blacklists the usage of Group.public_or_visible_to_user
class GroupPublicOrVisibleToUser < RuboCop::Cop::Cop
- MSG = '`Group.public_or_visible_to_user` should be used with extreme care. ' \
- 'Please ensure that you are not using it on its own and that the amount ' \
- 'of rows being filtered is reasonable.'
+ MSG = "`Group.public_or_visible_to_user` should be used with extreme care. " \
+ "Please ensure that you are not using it on its own and that the amount " \
+ "of rows being filtered is reasonable."
def_node_matcher :public_or_visible_to_user?, <<~PATTERN
(send (const nil? :Group) :public_or_visible_to_user ...)
diff --git a/rubocop/cop/include_sidekiq_worker.rb b/rubocop/cop/include_sidekiq_worker.rb
index 8da4a147219..15d760395b6 100644
--- a/rubocop/cop/include_sidekiq_worker.rb
+++ b/rubocop/cop/include_sidekiq_worker.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helpers'
+require_relative "../spec_helpers"
module RuboCop
module Cop
@@ -6,7 +6,7 @@ module RuboCop
class IncludeSidekiqWorker < RuboCop::Cop::Cop
include SpecHelpers
- MSG = 'Include `ApplicationWorker`, not `Sidekiq::Worker`.'.freeze
+ MSG = "Include `ApplicationWorker`, not `Sidekiq::Worker`.".freeze
def_node_matcher :includes_sidekiq_worker?, <<~PATTERN
(send nil? :include (const (const nil? :Sidekiq) :Worker))
@@ -21,7 +21,7 @@ module RuboCop
def autocorrect(node)
lambda do |corrector|
- corrector.replace(node.source_range, 'ApplicationWorker')
+ corrector.replace(node.source_range, "ApplicationWorker")
end
end
end
diff --git a/rubocop/cop/inject_enterprise_edition_module.rb b/rubocop/cop/inject_enterprise_edition_module.rb
index 1d37b1bd12d..81957264729 100644
--- a/rubocop/cop/inject_enterprise_edition_module.rb
+++ b/rubocop/cop/inject_enterprise_edition_module.rb
@@ -6,8 +6,8 @@ module RuboCop
# the last line of a file. Injecting a module in the middle of a file will
# cause merge conflicts, while placing it on the last line will not.
class InjectEnterpriseEditionModule < RuboCop::Cop::Cop
- MSG = 'Injecting EE modules must be done on the last line of this file' \
- ', outside of any class or module definitions'
+ MSG = "Injecting EE modules must be done on the last line of this file" \
+ ", outside of any class or module definitions"
METHODS = Set.new(%i[include extend prepend]).freeze
diff --git a/rubocop/cop/line_break_around_conditional_block.rb b/rubocop/cop/line_break_around_conditional_block.rb
index 8118b314b63..0dd5d8220ee 100644
--- a/rubocop/cop/line_break_around_conditional_block.rb
+++ b/rubocop/cop/line_break_around_conditional_block.rb
@@ -45,7 +45,7 @@ module RuboCop
class LineBreakAroundConditionalBlock < RuboCop::Cop::Cop
include RangeHelp
- MSG = 'Add a line break around conditional blocks'
+ MSG = "Add a line break around conditional blocks"
def on_if(node)
# This cop causes errors in haml files, so let's skip those
@@ -125,7 +125,7 @@ module RuboCop
end
def in_haml?(node)
- node.location.expression.source_buffer.name.end_with?('.haml.rb')
+ node.location.expression.source_buffer.name.end_with?(".haml.rb")
end
end
end
diff --git a/rubocop/cop/migration/add_column.rb b/rubocop/cop/migration/add_column.rb
index 2530d6477e8..fc518e86059 100644
--- a/rubocop/cop/migration/add_column.rb
+++ b/rubocop/cop/migration/add_column.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -10,8 +10,8 @@ module RuboCop
WHITELISTED_TABLES = [:application_settings].freeze
- MSG = '`add_column` with a default value requires downtime, ' \
- 'use `add_column_with_default` instead'.freeze
+ MSG = "`add_column` with a default value requires downtime, " \
+ "use `add_column_with_default` instead".freeze
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/add_concurrent_foreign_key.rb b/rubocop/cop/migration/add_concurrent_foreign_key.rb
index d78c7b9b043..fed93d9ca7a 100644
--- a/rubocop/cop/migration/add_concurrent_foreign_key.rb
+++ b/rubocop/cop/migration/add_concurrent_foreign_key.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,7 +8,7 @@ module RuboCop
class AddConcurrentForeignKey < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead'.freeze
+ MSG = "`add_foreign_key` requires downtime, use `add_concurrent_foreign_key` instead".freeze
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/add_concurrent_index.rb b/rubocop/cop/migration/add_concurrent_index.rb
index a2e4ac72565..4ee89438d19 100644
--- a/rubocop/cop/migration/add_concurrent_index.rb
+++ b/rubocop/cop/migration/add_concurrent_index.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,8 +8,8 @@ module RuboCop
class AddConcurrentIndex < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`add_concurrent_index` is not reversible so you must manually define ' \
- 'the `up` and `down` methods in your migration class, using `remove_concurrent_index` in `down`'.freeze
+ MSG = "`add_concurrent_index` is not reversible so you must manually define " \
+ "the `up` and `down` methods in your migration class, using `remove_concurrent_index` in `down`".freeze
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/add_index.rb b/rubocop/cop/migration/add_index.rb
index 4aea3c0cce3..94f6f9dcfef 100644
--- a/rubocop/cop/migration/add_index.rb
+++ b/rubocop/cop/migration/add_index.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -7,7 +7,7 @@ module RuboCop
class AddIndex < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`add_index` requires downtime, use `add_concurrent_index` instead'.freeze
+ MSG = "`add_index` requires downtime, use `add_concurrent_index` instead".freeze
def on_def(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/add_reference.rb b/rubocop/cop/migration/add_reference.rb
index 1d471b9797e..f56cda463f8 100644
--- a/rubocop/cop/migration/add_reference.rb
+++ b/rubocop/cop/migration/add_reference.rb
@@ -1,5 +1,6 @@
# frozen_string_literal: true
-require_relative '../../migration_helpers'
+
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,7 +9,7 @@ module RuboCop
class AddReference < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`add_reference` requires `index: true` or `index: { options... }`'
+ MSG = "`add_reference` requires `index: true` or `index: { options... }`"
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/add_timestamps.rb b/rubocop/cop/migration/add_timestamps.rb
index ba32d6a9960..c0dc99a74b2 100644
--- a/rubocop/cop/migration/add_timestamps.rb
+++ b/rubocop/cop/migration/add_timestamps.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -7,7 +7,7 @@ module RuboCop
class AddTimestamps < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'Do not use `add_timestamps`, use `add_timestamps_with_timezone` instead'.freeze
+ MSG = "Do not use `add_timestamps`, use `add_timestamps_with_timezone` instead".freeze
# Check methods.
def on_send(node)
diff --git a/rubocop/cop/migration/datetime.rb b/rubocop/cop/migration/datetime.rb
index 03ad3f3f601..b20ebfb1fec 100644
--- a/rubocop/cop/migration/datetime.rb
+++ b/rubocop/cop/migration/datetime.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -7,7 +7,7 @@ module RuboCop
class Datetime < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'Do not use the `%s` data type, use `datetime_with_timezone` instead'.freeze
+ MSG = "Do not use the `%s` data type, use `datetime_with_timezone` instead".freeze
# Check methods in table creation.
def on_def(node)
diff --git a/rubocop/cop/migration/hash_index.rb b/rubocop/cop/migration/hash_index.rb
index 3206b73bd3d..f939a84deb0 100644
--- a/rubocop/cop/migration/hash_index.rb
+++ b/rubocop/cop/migration/hash_index.rb
@@ -1,5 +1,5 @@
-require 'set'
-require_relative '../../migration_helpers'
+require "set"
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,8 +8,8 @@ module RuboCop
class HashIndex < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'hash indexes should be avoided at all costs since they are not ' \
- 'recorded in the PostgreSQL WAL, you should use a btree index instead'.freeze
+ MSG = "hash indexes should be avoided at all costs since they are not " \
+ "recorded in the PostgreSQL WAL, you should use a btree index instead".freeze
NAMES = Set.new([:add_index, :index, :add_concurrent_index]).freeze
@@ -26,9 +26,9 @@ module RuboCop
opts.each_node(:pair) do |pair|
next unless hash_key_type(pair) == :sym &&
- hash_key_name(pair) == :using
+ hash_key_name(pair) == :using
- if hash_key_value(pair).to_s == 'hash'
+ if hash_key_value(pair).to_s == "hash"
add_offense(pair, location: :expression)
end
end
diff --git a/rubocop/cop/migration/remove_column.rb b/rubocop/cop/migration/remove_column.rb
index fffb4ab7fab..5d57fe2001e 100644
--- a/rubocop/cop/migration/remove_column.rb
+++ b/rubocop/cop/migration/remove_column.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,7 +8,7 @@ module RuboCop
class RemoveColumn < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`remove_column` must only be used in post-deployment migrations'.freeze
+ MSG = "`remove_column` must only be used in post-deployment migrations".freeze
def on_def(node)
def_method = node.children[0]
diff --git a/rubocop/cop/migration/remove_concurrent_index.rb b/rubocop/cop/migration/remove_concurrent_index.rb
index 2328740cf36..1439341c4b6 100644
--- a/rubocop/cop/migration/remove_concurrent_index.rb
+++ b/rubocop/cop/migration/remove_concurrent_index.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,8 +8,8 @@ module RuboCop
class RemoveConcurrentIndex < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`remove_concurrent_index` is not reversible so you must manually define ' \
- 'the `up` and `down` methods in your migration class, using `add_concurrent_index` in `down`'.freeze
+ MSG = "`remove_concurrent_index` is not reversible so you must manually define " \
+ "the `up` and `down` methods in your migration class, using `add_concurrent_index` in `down`".freeze
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/remove_index.rb b/rubocop/cop/migration/remove_index.rb
index 4df3b1ba756..eecdbf3ebd4 100644
--- a/rubocop/cop/migration/remove_index.rb
+++ b/rubocop/cop/migration/remove_index.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -7,7 +7,7 @@ module RuboCop
class RemoveIndex < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = '`remove_index` requires downtime, use `remove_concurrent_index` instead'.freeze
+ MSG = "`remove_index` requires downtime, use `remove_concurrent_index` instead".freeze
def on_def(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/reversible_add_column_with_default.rb b/rubocop/cop/migration/reversible_add_column_with_default.rb
index dd49188defa..50bd5050a60 100644
--- a/rubocop/cop/migration/reversible_add_column_with_default.rb
+++ b/rubocop/cop/migration/reversible_add_column_with_default.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -16,8 +16,8 @@ module RuboCop
(def :change ...)
PATTERN
- MSG = '`add_column_with_default` is not reversible so you must manually define ' \
- 'the `up` and `down` methods in your migration class, using `remove_column` in `down`'.freeze
+ MSG = "`add_column_with_default` is not reversible so you must manually define " \
+ "the `up` and `down` methods in your migration class, using `remove_column` in `down`".freeze
def on_send(node)
return unless in_migration?(node)
diff --git a/rubocop/cop/migration/safer_boolean_column.rb b/rubocop/cop/migration/safer_boolean_column.rb
index a7d922c752f..ce32dbdde6d 100644
--- a/rubocop/cop/migration/safer_boolean_column.rb
+++ b/rubocop/cop/migration/safer_boolean_column.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -19,9 +19,9 @@ module RuboCop
class SaferBooleanColumn < RuboCop::Cop::Cop
include MigrationHelpers
- DEFAULT_OFFENSE = 'Boolean columns on the `%s` table should have a default. You may wish to use `add_column_with_default`.'.freeze
- NULL_OFFENSE = 'Boolean columns on the `%s` table should disallow nulls.'.freeze
- DEFAULT_AND_NULL_OFFENSE = 'Boolean columns on the `%s` table should have a default and should disallow nulls. You may wish to use `add_column_with_default`.'.freeze
+ DEFAULT_OFFENSE = "Boolean columns on the `%s` table should have a default. You may wish to use `add_column_with_default`.".freeze
+ NULL_OFFENSE = "Boolean columns on the `%s` table should disallow nulls.".freeze
+ DEFAULT_AND_NULL_OFFENSE = "Boolean columns on the `%s` table should have a default and should disallow nulls. You may wish to use `add_column_with_default`.".freeze
SMALL_TABLES = %i[
application_settings
@@ -47,12 +47,12 @@ module RuboCop
nulls_allowed = nulls_allowed?(opts)
offense = if no_default && nulls_allowed
- DEFAULT_AND_NULL_OFFENSE
- elsif no_default
- DEFAULT_OFFENSE
- elsif nulls_allowed
- NULL_OFFENSE
- end
+ DEFAULT_AND_NULL_OFFENSE
+ elsif no_default
+ DEFAULT_OFFENSE
+ elsif nulls_allowed
+ NULL_OFFENSE
+ end
add_offense(node, location: :expression, message: format(offense, table)) if offense
end
@@ -61,7 +61,7 @@ module RuboCop
return true unless opts
each_hash_node_pair(opts) do |key, value|
- break value == 'nil' if key == :default
+ break value == "nil" if key == :default
end
end
@@ -69,7 +69,7 @@ module RuboCop
return true unless opts
each_hash_node_pair(opts) do |key, value|
- break value != 'false' if key == :null
+ break value != "false" if key == :null
end
end
diff --git a/rubocop/cop/migration/timestamps.rb b/rubocop/cop/migration/timestamps.rb
index 6cf5648b996..4c96ff110c5 100644
--- a/rubocop/cop/migration/timestamps.rb
+++ b/rubocop/cop/migration/timestamps.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -7,7 +7,7 @@ module RuboCop
class Timestamps < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'Do not use `timestamps`, use `timestamps_with_timezone` instead'.freeze
+ MSG = "Do not use `timestamps`, use `timestamps_with_timezone` instead".freeze
# Check methods in table creation.
def on_def(node)
diff --git a/rubocop/cop/migration/update_column_in_batches.rb b/rubocop/cop/migration/update_column_in_batches.rb
index 5461abc5ee0..6b75f5dd9cf 100644
--- a/rubocop/cop/migration/update_column_in_batches.rb
+++ b/rubocop/cop/migration/update_column_in_batches.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -8,8 +8,8 @@ module RuboCop
class UpdateColumnInBatches < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'Migration running `update_column_in_batches` must have a spec file at' \
- ' `%s`.'.freeze
+ MSG = "Migration running `update_column_in_batches` must have a spec file at" \
+ " `%s`.".freeze
def on_send(node)
return unless in_migration?(node)
@@ -28,14 +28,14 @@ module RuboCop
source_name = node.location.expression.source_buffer.name
path = Pathname.new(source_name).relative_path_from(rails_root)
dirname = File.dirname(path)
- .sub(%r{\Adb/(migrate|post_migrate)}, 'spec/migrations')
- filename = File.basename(source_name, '.rb').sub(/\A\d+_/, '')
+ .sub(%r{\Adb/(migrate|post_migrate)}, "spec/migrations")
+ filename = File.basename(source_name, ".rb").sub(/\A\d+_/, "")
File.join(dirname, "#{filename}_spec.rb")
end
def rails_root
- Pathname.new(File.expand_path('../../..', __dir__))
+ Pathname.new(File.expand_path("../../..", __dir__))
end
end
end
diff --git a/rubocop/cop/migration/update_large_table.rb b/rubocop/cop/migration/update_large_table.rb
index c15eec22d04..3a00d42e211 100644
--- a/rubocop/cop/migration/update_large_table.rb
+++ b/rubocop/cop/migration/update_large_table.rb
@@ -1,4 +1,4 @@
-require_relative '../../migration_helpers'
+require_relative "../../migration_helpers"
module RuboCop
module Cop
@@ -15,9 +15,9 @@ module RuboCop
class UpdateLargeTable < RuboCop::Cop::Cop
include MigrationHelpers
- MSG = 'Using `%s` on the `%s` table will take a long time to ' \
- 'complete, and should be avoided unless absolutely ' \
- 'necessary'.freeze
+ MSG = "Using `%s` on the `%s` table will take a long time to " \
+ "complete, and should be avoided unless absolutely " \
+ "necessary".freeze
LARGE_TABLES = %i[
ci_build_trace_sections
@@ -43,7 +43,7 @@ module RuboCop
:change_column_type_concurrently
:rename_column_concurrently
:update_column_in_batches
- ].join(' ').freeze
+ ].join(" ").freeze
def_node_matcher :batch_update?, <<~PATTERN
(send nil? ${#{BATCH_UPDATE_METHODS}} $(sym ...) ...)
diff --git a/rubocop/cop/prefer_class_methods_over_module.rb b/rubocop/cop/prefer_class_methods_over_module.rb
index 0dfa80ccfab..85c71b708bb 100644
--- a/rubocop/cop/prefer_class_methods_over_module.rb
+++ b/rubocop/cop/prefer_class_methods_over_module.rb
@@ -29,19 +29,19 @@ module RuboCop
class PreferClassMethodsOverModule < RuboCop::Cop::Cop
include RangeHelp
- MSG = 'Do not use module ClassMethods, use class_methods block instead.'
+ MSG = "Do not use module ClassMethods, use class_methods block instead."
def_node_matcher :extend_activesupport_concern?, <<~PATTERN
(:send nil? :extend (:const (:const nil? :ActiveSupport) :Concern))
PATTERN
def on_module(node)
- add_offense(node) if node.defined_module_name == 'ClassMethods' && module_extends_activesupport_concern?(node)
+ add_offense(node) if node.defined_module_name == "ClassMethods" && module_extends_activesupport_concern?(node)
end
def autocorrect(node)
lambda do |corrector|
- corrector.replace(module_range(node), 'class_methods do')
+ corrector.replace(module_range(node), "class_methods do")
end
end
diff --git a/rubocop/cop/project_path_helper.rb b/rubocop/cop/project_path_helper.rb
index f3810622eb1..2842638064e 100644
--- a/rubocop/cop/project_path_helper.rb
+++ b/rubocop/cop/project_path_helper.rb
@@ -1,9 +1,9 @@
module RuboCop
module Cop
class ProjectPathHelper < RuboCop::Cop::Cop
- MSG = 'Use short project path helpers without explicitly passing the namespace: ' \
- '`foo_project_bar_path(project, bar)` instead of ' \
- '`foo_namespace_project_bar_path(project.namespace, project, bar)`.'.freeze
+ MSG = "Use short project path helpers without explicitly passing the namespace: " \
+ "`foo_project_bar_path(project, bar)` instead of " \
+ "`foo_namespace_project_bar_path(project.namespace, project, bar)`.".freeze
METHOD_NAME_PATTERN = /\A([a-z_]+_)?namespace_project(?:_[a-z_]+)?_(?:url|path)\z/.freeze
@@ -21,12 +21,12 @@ module RuboCop
end
def autocorrect(node)
- helper_name = method_name(node).to_s.sub('namespace_project', 'project')
+ helper_name = method_name(node).to_s.sub("namespace_project", "project")
arguments = arguments(node)
arguments.shift # Remove namespace argument
- replacement = "#{helper_name}(#{arguments.map(&:source).join(', ')})"
+ replacement = "#{helper_name}(#{arguments.map(&:source).join(", ")})"
lambda do |corrector|
corrector.replace(node.source_range, replacement)
diff --git a/rubocop/cop/qa/element_with_pattern.rb b/rubocop/cop/qa/element_with_pattern.rb
index 9d80946f1ba..054dfcaf678 100644
--- a/rubocop/cop/qa/element_with_pattern.rb
+++ b/rubocop/cop/qa/element_with_pattern.rb
@@ -1,4 +1,4 @@
-require_relative '../../qa_helpers'
+require_relative "../../qa_helpers"
module RuboCop
module Cop
@@ -20,12 +20,12 @@ module RuboCop
def on_send(node)
return unless in_qa_file?(node)
- return unless method_name(node).to_s == 'element'
+ return unless method_name(node).to_s == "element"
element_name, pattern = node.arguments
return unless pattern
- add_offense(node, location: pattern.source_range, message: MESSAGE % "qa-#{element_name.value.to_s.tr('_', '-')}")
+ add_offense(node, location: pattern.source_range, message: MESSAGE % "qa-#{element_name.value.to_s.tr("_", "-")}")
end
private
diff --git a/rubocop/cop/rspec/env_assignment.rb b/rubocop/cop/rspec/env_assignment.rb
index 8b61fa8e264..59afb839f9d 100644
--- a/rubocop/cop/rspec/env_assignment.rb
+++ b/rubocop/cop/rspec/env_assignment.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helpers'
+require_relative "../../spec_helpers"
module RuboCop
module Cop
diff --git a/rubocop/cop/rspec/factories_in_migration_specs.rb b/rubocop/cop/rspec/factories_in_migration_specs.rb
index 0c5aa838a2c..b6a4e72bc9a 100644
--- a/rubocop/cop/rspec/factories_in_migration_specs.rb
+++ b/rubocop/cop/rspec/factories_in_migration_specs.rb
@@ -1,4 +1,4 @@
-require_relative '../../spec_helpers'
+require_relative "../../spec_helpers"
module RuboCop
module Cop
@@ -20,7 +20,7 @@ module RuboCop
FORBIDDEN_METHODS = %i[build build_list create create_list].freeze
def_node_search :forbidden_factory_usage?, <<~PATTERN
- (send {(const nil? :FactoryBot) nil?} {#{FORBIDDEN_METHODS.map(&:inspect).join(' ')}} ...)
+ (send {(const nil? :FactoryBot) nil?} {#{FORBIDDEN_METHODS.map(&:inspect).join(" ")}} ...)
PATTERN
# Following is what node.children looks like on a match:
diff --git a/rubocop/cop/ruby_interpolation_in_translation.rb b/rubocop/cop/ruby_interpolation_in_translation.rb
index c431b4a1977..eea4d9d2339 100644
--- a/rubocop/cop/ruby_interpolation_in_translation.rb
+++ b/rubocop/cop/ruby_interpolation_in_translation.rb
@@ -5,7 +5,7 @@ module RuboCop
class RubyInterpolationInTranslation < RuboCop::Cop::Cop
MSG = "Don't use ruby interpolation \#{} inside translated strings, instead use \%{}"
- TRANSLATION_METHODS = ':_ :s_ :N_ :n_'
+ TRANSLATION_METHODS = ":_ :s_ :N_ :n_"
def_node_matcher :translation_method?, <<~PATTERN
(send nil? {#{TRANSLATION_METHODS}} $dstr ...)
diff --git a/rubocop/cop/safe_params.rb b/rubocop/cop/safe_params.rb
index 250c16232e4..3b34fe40f9c 100644
--- a/rubocop/cop/safe_params.rb
+++ b/rubocop/cop/safe_params.rb
@@ -3,7 +3,7 @@
module RuboCop
module Cop
class SafeParams < RuboCop::Cop::Cop
- MSG = 'Use `safe_params` instead of `params` in url_for.'.freeze
+ MSG = "Use `safe_params` instead of `params` in url_for."
METHOD_NAME_PATTERN = :url_for
UNSAFE_PARAM = :params
diff --git a/rubocop/cop/sidekiq_options_queue.rb b/rubocop/cop/sidekiq_options_queue.rb
index 253d2958866..d49bb7264c4 100644
--- a/rubocop/cop/sidekiq_options_queue.rb
+++ b/rubocop/cop/sidekiq_options_queue.rb
@@ -1,4 +1,4 @@
-require_relative '../spec_helpers'
+require_relative "../spec_helpers"
module RuboCop
module Cop
@@ -6,7 +6,7 @@ module RuboCop
class SidekiqOptionsQueue < RuboCop::Cop::Cop
include SpecHelpers
- MSG = 'Do not manually set a queue; `ApplicationWorker` sets one automatically.'.freeze
+ MSG = "Do not manually set a queue; `ApplicationWorker` sets one automatically.".freeze
def_node_matcher :sidekiq_options?, <<~PATTERN
(send nil? :sidekiq_options $...)
diff --git a/rubocop/migration_helpers.rb b/rubocop/migration_helpers.rb
index c066d424437..fc4aec8c2ca 100644
--- a/rubocop/migration_helpers.rb
+++ b/rubocop/migration_helpers.rb
@@ -5,13 +5,13 @@ module RuboCop
def in_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name)
- dirname.end_with?('db/migrate', 'db/post_migrate')
+ dirname.end_with?("db/migrate", "db/post_migrate")
end
def in_post_deployment_migration?(node)
dirname = File.dirname(node.location.expression.source_buffer.name)
- dirname.end_with?('db/post_migrate')
+ dirname.end_with?("db/post_migrate")
end
end
end
diff --git a/rubocop/qa_helpers.rb b/rubocop/qa_helpers.rb
index f4adf7f4e9f..7ca724c4ec5 100644
--- a/rubocop/qa_helpers.rb
+++ b/rubocop/qa_helpers.rb
@@ -5,7 +5,7 @@ module RuboCop
def in_qa_file?(node)
path = node.location.expression.source_buffer.name
- path.start_with?(File.join(Dir.pwd, 'qa'))
+ path.start_with?(File.join(Dir.pwd, "qa"))
end
end
end
diff --git a/rubocop/rubocop.rb b/rubocop/rubocop.rb
index 3e33419eb2e..80f0f610781 100644
--- a/rubocop/rubocop.rb
+++ b/rubocop/rubocop.rb
@@ -1,44 +1,44 @@
# rubocop:disable Naming/FileName
-require_relative 'cop/gitlab/module_with_instance_variables'
-require_relative 'cop/gitlab/predicate_memoization'
-require_relative 'cop/gitlab/httparty'
-require_relative 'cop/gitlab/finder_with_find_by'
-require_relative 'cop/gitlab/union'
-require_relative 'cop/include_sidekiq_worker'
-require_relative 'cop/safe_params'
-require_relative 'cop/avoid_return_from_blocks'
-require_relative 'cop/avoid_break_from_strong_memoize'
-require_relative 'cop/avoid_route_redirect_leading_slash'
-require_relative 'cop/line_break_around_conditional_block'
-require_relative 'cop/prefer_class_methods_over_module'
-require_relative 'cop/migration/add_column'
-require_relative 'cop/migration/add_concurrent_foreign_key'
-require_relative 'cop/migration/add_concurrent_index'
-require_relative 'cop/migration/add_index'
-require_relative 'cop/migration/add_reference'
-require_relative 'cop/migration/add_timestamps'
-require_relative 'cop/migration/datetime'
-require_relative 'cop/migration/hash_index'
-require_relative 'cop/migration/remove_column'
-require_relative 'cop/migration/remove_concurrent_index'
-require_relative 'cop/migration/remove_index'
-require_relative 'cop/migration/reversible_add_column_with_default'
-require_relative 'cop/migration/safer_boolean_column'
-require_relative 'cop/migration/timestamps'
-require_relative 'cop/migration/update_column_in_batches'
-require_relative 'cop/migration/update_large_table'
-require_relative 'cop/project_path_helper'
-require_relative 'cop/rspec/env_assignment'
-require_relative 'cop/rspec/factories_in_migration_specs'
-require_relative 'cop/qa/element_with_pattern'
-require_relative 'cop/sidekiq_options_queue'
-require_relative 'cop/destroy_all'
-require_relative 'cop/ruby_interpolation_in_translation'
-require_relative 'code_reuse_helpers'
-require_relative 'cop/code_reuse/finder'
-require_relative 'cop/code_reuse/service_class'
-require_relative 'cop/code_reuse/presenter'
-require_relative 'cop/code_reuse/serializer'
-require_relative 'cop/code_reuse/active_record'
-require_relative 'cop/group_public_or_visible_to_user'
-require_relative 'cop/inject_enterprise_edition_module'
+require_relative "cop/gitlab/module_with_instance_variables"
+require_relative "cop/gitlab/predicate_memoization"
+require_relative "cop/gitlab/httparty"
+require_relative "cop/gitlab/finder_with_find_by"
+require_relative "cop/gitlab/union"
+require_relative "cop/include_sidekiq_worker"
+require_relative "cop/safe_params"
+require_relative "cop/avoid_return_from_blocks"
+require_relative "cop/avoid_break_from_strong_memoize"
+require_relative "cop/avoid_route_redirect_leading_slash"
+require_relative "cop/line_break_around_conditional_block"
+require_relative "cop/prefer_class_methods_over_module"
+require_relative "cop/migration/add_column"
+require_relative "cop/migration/add_concurrent_foreign_key"
+require_relative "cop/migration/add_concurrent_index"
+require_relative "cop/migration/add_index"
+require_relative "cop/migration/add_reference"
+require_relative "cop/migration/add_timestamps"
+require_relative "cop/migration/datetime"
+require_relative "cop/migration/hash_index"
+require_relative "cop/migration/remove_column"
+require_relative "cop/migration/remove_concurrent_index"
+require_relative "cop/migration/remove_index"
+require_relative "cop/migration/reversible_add_column_with_default"
+require_relative "cop/migration/safer_boolean_column"
+require_relative "cop/migration/timestamps"
+require_relative "cop/migration/update_column_in_batches"
+require_relative "cop/migration/update_large_table"
+require_relative "cop/project_path_helper"
+require_relative "cop/rspec/env_assignment"
+require_relative "cop/rspec/factories_in_migration_specs"
+require_relative "cop/qa/element_with_pattern"
+require_relative "cop/sidekiq_options_queue"
+require_relative "cop/destroy_all"
+require_relative "cop/ruby_interpolation_in_translation"
+require_relative "code_reuse_helpers"
+require_relative "cop/code_reuse/finder"
+require_relative "cop/code_reuse/service_class"
+require_relative "cop/code_reuse/presenter"
+require_relative "cop/code_reuse/serializer"
+require_relative "cop/code_reuse/active_record"
+require_relative "cop/group_public_or_visible_to_user"
+require_relative "cop/inject_enterprise_edition_module"
diff --git a/rubocop/spec_helpers.rb b/rubocop/spec_helpers.rb
index 63c1b975a65..ac015592300 100644
--- a/rubocop/spec_helpers.rb
+++ b/rubocop/spec_helpers.rb
@@ -1,20 +1,20 @@
module RuboCop
module SpecHelpers
SPEC_HELPERS = %w[fast_spec_helper.rb rails_helper.rb spec_helper.rb].freeze
- MIGRATION_SPEC_DIRECTORIES = ['spec/migrations', 'spec/lib/gitlab/background_migration'].freeze
+ MIGRATION_SPEC_DIRECTORIES = ["spec/migrations", "spec/lib/gitlab/background_migration"].freeze
# Returns true if the given node originated from the spec directory.
def in_spec?(node)
path = node.location.expression.source_buffer.name
!SPEC_HELPERS.include?(File.basename(path)) &&
- path.start_with?(File.join(Dir.pwd, 'spec'), File.join(Dir.pwd, 'ee', 'spec'))
+ path.start_with?(File.join(Dir.pwd, "spec"), File.join(Dir.pwd, "ee", "spec"))
end
def migration_directories
- @migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map do |dir|
- [File.join(Dir.pwd, dir), File.join(Dir.pwd, 'ee', dir)]
- end.flatten
+ @migration_directories ||= MIGRATION_SPEC_DIRECTORIES.map { |dir|
+ [File.join(Dir.pwd, dir), File.join(Dir.pwd, "ee", dir)]
+ }.flatten
end
# Returns true if the given node originated from a migration spec.
diff --git a/scripts/detect-new-flaky-examples b/scripts/detect-new-flaky-examples
index 3bee4f9a34b..b818cdcff5d 100755
--- a/scripts/detect-new-flaky-examples
+++ b/scripts/detect-new-flaky-examples
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
-require 'json'
+require "json"
report_file = ARGV.shift
unless report_file
- puts 'usage: detect-new-flaky-examples <report-file>'
+ puts "usage: detect-new-flaky-examples <report-file>"
exit 1
end
diff --git a/scripts/gitaly-test-build b/scripts/gitaly-test-build
index 374401caf89..070e01e466a 100755
--- a/scripts/gitaly-test-build
+++ b/scripts/gitaly-test-build
@@ -1,8 +1,8 @@
#!/usr/bin/env ruby
-require 'fileutils'
+require "fileutils"
-require_relative 'gitaly_test'
+require_relative "gitaly_test"
# This script assumes tmp/tests/gitaly already contains the correct
# Gitaly version. We just have to compile it and run its 'bundle
@@ -12,18 +12,18 @@ class GitalyTestBuild
include GitalyTest
def run
- abort 'gitaly build failed' unless system(env, 'make', chdir: tmp_tests_gitaly_dir)
+ abort "gitaly build failed" unless system(env, "make", chdir: tmp_tests_gitaly_dir)
check_gitaly_config!
# Starting gitaly further validates its configuration
pid = start_gitaly
- Process.kill('TERM', pid)
+ Process.kill("TERM", pid)
# Make the 'gitaly' executable look newer than 'GITALY_SERVER_VERSION'.
# Without this a gitaly executable created in the setup-test-env job
# will look stale compared to GITALY_SERVER_VERSION.
- FileUtils.touch(File.join(tmp_tests_gitaly_dir, 'gitaly'), mtime: Time.now + (1 << 24))
+ FileUtils.touch(File.join(tmp_tests_gitaly_dir, "gitaly"), mtime: Time.now + (1 << 24))
end
end
diff --git a/scripts/gitaly-test-spawn b/scripts/gitaly-test-spawn
index e9f91f75650..2c816c5b887 100755
--- a/scripts/gitaly-test-spawn
+++ b/scripts/gitaly-test-spawn
@@ -2,7 +2,7 @@
# This script is used both in CI and in local development 'rspec' runs.
-require_relative 'gitaly_test'
+require_relative "gitaly_test"
class GitalyTestSpawn
include GitalyTest
@@ -16,7 +16,7 @@ class GitalyTestSpawn
pid = start_gitaly
# In local development this pid file is used by rspec.
- IO.write(File.expand_path('../tmp/tests/gitaly.pid', __dir__), pid)
+ IO.write(File.expand_path("../tmp/tests/gitaly.pid", __dir__), pid)
end
end
diff --git a/scripts/gitaly_test.rb b/scripts/gitaly_test.rb
index dee4c2eba7e..0a7ec4fb779 100644
--- a/scripts/gitaly_test.rb
+++ b/scripts/gitaly_test.rb
@@ -4,48 +4,48 @@
# Please be careful when modifying this file. Your changes must work
# both for local development rspec runs, and in CI.
-require 'socket'
+require "socket"
module GitalyTest
def tmp_tests_gitaly_dir
- File.expand_path('../tmp/tests/gitaly', __dir__)
+ File.expand_path("../tmp/tests/gitaly", __dir__)
end
def gemfile
- File.join(tmp_tests_gitaly_dir, 'ruby', 'Gemfile')
+ File.join(tmp_tests_gitaly_dir, "ruby", "Gemfile")
end
def env
env_hash = {
- 'HOME' => File.expand_path('tmp/tests'),
- 'GEM_PATH' => Gem.path.join(':'),
- 'BUNDLE_APP_CONFIG' => File.join(File.dirname(gemfile), '.bundle/config'),
- 'BUNDLE_FLAGS' => "--jobs=4 --retry=3",
- 'BUNDLE_INSTALL_FLAGS' => nil,
- 'BUNDLE_GEMFILE' => gemfile,
- 'RUBYOPT' => nil
+ "HOME" => File.expand_path("tmp/tests"),
+ "GEM_PATH" => Gem.path.join(":"),
+ "BUNDLE_APP_CONFIG" => File.join(File.dirname(gemfile), ".bundle/config"),
+ "BUNDLE_FLAGS" => "--jobs=4 --retry=3",
+ "BUNDLE_INSTALL_FLAGS" => nil,
+ "BUNDLE_GEMFILE" => gemfile,
+ "RUBYOPT" => nil,
}
- if ENV['CI']
- bundle_path = File.expand_path('../vendor/gitaly-ruby', __dir__)
- env_hash['BUNDLE_FLAGS'] << " --path=#{bundle_path}"
+ if ENV["CI"]
+ bundle_path = File.expand_path("../vendor/gitaly-ruby", __dir__)
+ env_hash["BUNDLE_FLAGS"] << " --path=#{bundle_path}"
end
env_hash
end
def config_path
- File.join(tmp_tests_gitaly_dir, 'config.toml')
+ File.join(tmp_tests_gitaly_dir, "config.toml")
end
def start_gitaly
args = %W[#{tmp_tests_gitaly_dir}/gitaly #{config_path}]
- pid = spawn(env, *args, [:out, :err] => 'log/gitaly-test.log')
+ pid = spawn(env, *args, [:out, :err] => "log/gitaly-test.log")
begin
try_connect!
rescue
- Process.kill('TERM', pid)
+ Process.kill("TERM", pid)
raise
end
@@ -53,8 +53,8 @@ module GitalyTest
end
def check_gitaly_config!
- puts 'Checking gitaly-ruby bundle...'
- abort 'bundle check failed' unless system(env, 'bundle', 'check', chdir: File.dirname(gemfile))
+ puts "Checking gitaly-ruby bundle..."
+ abort "bundle check failed" unless system(env, "bundle", "check", chdir: File.dirname(gemfile))
end
def read_socket_path
@@ -79,18 +79,16 @@ module GitalyTest
socket = read_socket_path
Integer(timeout / delay).times do
- begin
- UNIXSocket.new(socket)
- puts ' OK'
-
- return
- rescue Errno::ENOENT, Errno::ECONNREFUSED
- print '.'
- sleep delay
- end
+ UNIXSocket.new(socket)
+ puts " OK"
+
+ return
+ rescue Errno::ENOENT, Errno::ECONNREFUSED
+ print "."
+ sleep delay
end
- puts ' FAILED'
+ puts " FAILED"
raise "could not connect to #{socket}"
end
diff --git a/scripts/lint-changelog-yaml b/scripts/lint-changelog-yaml
index 06d502c4676..74c530f7803 100755
--- a/scripts/lint-changelog-yaml
+++ b/scripts/lint-changelog-yaml
@@ -1,17 +1,17 @@
#!/usr/bin/env ruby
-require 'yaml'
+require "yaml"
-invalid_changelogs = Dir['changelogs/**/*'].reject do |changelog|
+invalid_changelogs = Dir["changelogs/**/*"].reject { |changelog|
next true if changelog =~ /((README|archive)\.md|unreleased(-ee)?)$/
- next false unless changelog.end_with?('.yml')
+ next false unless changelog.end_with?(".yml")
begin
YAML.load_file(changelog)
rescue => exception
puts exception
end
-end
+}
if invalid_changelogs.any?
puts
diff --git a/scripts/lint-rugged b/scripts/lint-rugged
index 22e3e1f1505..6cdb055d0ff 100755
--- a/scripts/lint-rugged
+++ b/scripts/lint-rugged
@@ -2,19 +2,19 @@
ALLOWED = [
# Needed to handle repositories that are not in any storage
- 'lib/gitlab/bare_repository_import/repository.rb',
+ "lib/gitlab/bare_repository_import/repository.rb",
# Needed to avoid using the git binary to validate a branch name
- 'lib/gitlab/git_ref_validator.rb'
+ "lib/gitlab/git_ref_validator.rb",
].freeze
rugged_lines = IO.popen(%w[git grep -i -n rugged -- app config lib], &:read).lines
rugged_lines = rugged_lines.select { |l| /^[^:]*\.rb:/ =~ l }
rugged_lines = rugged_lines.reject { |l| l.start_with?(*ALLOWED) }
-rugged_lines = rugged_lines.reject do |line|
- code, _comment = line.split('# ', 2)
+rugged_lines = rugged_lines.reject { |line|
+ code, _comment = line.split("# ", 2)
code !~ /rugged/i
-end
+}
exit if rugged_lines.empty?
diff --git a/scripts/merge-reports b/scripts/merge-reports
index 3a421f1f1fc..bf4fb269b9c 100755
--- a/scripts/merge-reports
+++ b/scripts/merge-reports
@@ -1,10 +1,10 @@
#!/usr/bin/env ruby
-require 'json'
+require "json"
main_report_file = ARGV.shift
unless main_report_file
- puts 'usage: merge-reports <main-report> [extra reports...]'
+ puts "usage: merge-reports <main-report> [extra reports...]"
exit 1
end
@@ -16,9 +16,9 @@ ARGV.each do |report_file|
report = JSON.parse(File.read(report_file))
# Remove existing values
- updates = report.delete_if do |key, value|
+ updates = report.delete_if { |key, value|
main_report[key] && main_report[key] == value
- end
+ }
new_report.merge!(updates)
puts "Merged #{report_file} adding #{updates.size} results."
diff --git a/scripts/merge-simplecov b/scripts/merge-simplecov
index 65f93f8830b..31ac6abc35d 100755
--- a/scripts/merge-simplecov
+++ b/scripts/merge-simplecov
@@ -1,22 +1,20 @@
#!/usr/bin/env ruby
-require_relative '../spec/simplecov_env'
+require_relative "../spec/simplecov_env"
SimpleCovEnv.configure_profile
module SimpleCov
module ResultMerger
class << self
def resultset_files
- Dir.glob(File.join(SimpleCov.coverage_path, '*', '.resultset.json'))
+ Dir.glob(File.join(SimpleCov.coverage_path, "*", ".resultset.json"))
end
def resultset_hashes
resultset_files.map do |path|
- begin
- JSON.parse(File.read(path))
- rescue
- {}
- end
+ JSON.parse(File.read(path))
+ rescue
+ {}
end
end
diff --git a/scripts/no-ee-check b/scripts/no-ee-check
index 29d319dc822..7f3fef842d0 100755
--- a/scripts/no-ee-check
+++ b/scripts/no-ee-check
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
-ee_path = File.join(File.expand_path(__dir__), '../ee')
+ee_path = File.join(File.expand_path(__dir__), "../ee")
if Dir.exist?(ee_path)
- puts 'The repository contains /ee directory. There should be no /ee directory in CE repo.'
+ puts "The repository contains /ee directory. There should be no /ee directory in CE repo."
exit 1
end
diff --git a/scripts/prune-old-flaky-specs b/scripts/prune-old-flaky-specs
index a00a334fd6e..97d49ffa5a2 100755
--- a/scripts/prune-old-flaky-specs
+++ b/scripts/prune-old-flaky-specs
@@ -3,17 +3,17 @@
# lib/rspec_flaky/flaky_examples_collection.rb is requiring
# `active_support/hash_with_indifferent_access`, and we install the `activesupport`
# gem manually on the CI
-require 'rubygems'
+require "rubygems"
# In newer Ruby, alias_method is not private then we don't need __send__
singleton_class.__send__(:alias_method, :require_dependency, :require) # rubocop:disable GitlabSecurity/PublicSend
-$:.unshift(File.expand_path('../lib', __dir__))
+$:.unshift(File.expand_path("../lib", __dir__))
-require 'rspec_flaky/report'
+require "rspec_flaky/report"
report_file = ARGV.shift
unless report_file
- puts 'usage: prune-old-flaky-specs <report-file> <new-report-file>'
+ puts "usage: prune-old-flaky-specs <report-file> <new-report-file>"
exit 1
end
diff --git a/scripts/review_apps/automated_cleanup.rb b/scripts/review_apps/automated_cleanup.rb
index 4166070f7cd..bc0e76b9bc5 100755
--- a/scripts/review_apps/automated_cleanup.rb
+++ b/scripts/review_apps/automated_cleanup.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'gitlab'
-require_relative File.expand_path('../../lib/quality/helm_client.rb', __dir__)
-require_relative File.expand_path('../../lib/quality/kubernetes_client.rb', __dir__)
+require "gitlab"
+require_relative File.expand_path("../../lib/quality/helm_client.rb", __dir__)
+require_relative File.expand_path("../../lib/quality/kubernetes_client.rb", __dir__)
class AutomatedCleanup
attr_reader :project_path, :gitlab_token
@@ -10,27 +10,27 @@ class AutomatedCleanup
DEPLOYMENTS_PER_PAGE = 100
HELM_RELEASES_BATCH_SIZE = 5
IGNORED_HELM_ERRORS = [
- 'transport is closing',
- 'error upgrading connection'
+ "transport is closing",
+ "error upgrading connection",
].freeze
IGNORED_KUBERNETES_ERRORS = [
- 'NotFound'
+ "NotFound",
].freeze
def self.ee?
- ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
+ ENV["CI_PROJECT_NAME"] == "gitlab-ee" || File.exist?("CHANGELOG-EE.md")
end
- def initialize(project_path: ENV['CI_PROJECT_PATH'], gitlab_token: ENV['GITLAB_BOT_REVIEW_APPS_CLEANUP_TOKEN'])
+ def initialize(project_path: ENV["CI_PROJECT_PATH"], gitlab_token: ENV["GITLAB_BOT_REVIEW_APPS_CLEANUP_TOKEN"])
@project_path = project_path
@gitlab_token = gitlab_token
- ENV['TILLER_NAMESPACE'] ||= review_apps_namespace
+ ENV["TILLER_NAMESPACE"] ||= review_apps_namespace
end
def gitlab
@gitlab ||= begin
Gitlab.configure do |config|
- config.endpoint = 'https://gitlab.com/api/v4'
+ config.endpoint = "https://gitlab.com/api/v4"
# gitlab-bot's token "GitLab review apps cleanup"
config.private_token = gitlab_token
end
@@ -40,7 +40,7 @@ class AutomatedCleanup
end
def review_apps_namespace
- self.class.ee? ? 'review-apps-ee' : 'review-apps-ce'
+ self.class.ee? ? "review-apps-ee" : "review-apps-ce"
end
def helm
@@ -61,7 +61,7 @@ class AutomatedCleanup
gitlab.deployments(project_path, per_page: DEPLOYMENTS_PER_PAGE).auto_paginate do |deployment|
environment = deployment.environment
- next unless environment.name.start_with?('review/')
+ next unless environment.name.start_with?("review/")
next if checked_environments.include?(environment.slug)
last_deploy = deployment.created_at
@@ -74,7 +74,7 @@ class AutomatedCleanup
elsif deployed_at < stop_threshold
stop_environment(environment, deployment)
else
- print_release_state(subject: 'Review app', release_name: environment.slug, release_date: last_deploy, action: 'leaving')
+ print_release_state(subject: "Review app", release_name: environment.slug, release_date: last_deploy, action: "leaving")
end
checked_environments << environment.slug
@@ -87,10 +87,10 @@ class AutomatedCleanup
threshold_day = threshold_time(days: days)
helm_releases.each do |release|
- if release.status == 'FAILED' || release.last_update < threshold_day
+ if release.status == "FAILED" || release.last_update < threshold_day
delete_helm_release(release)
else
- print_release_state(subject: 'Release', release_name: release.name, release_date: release.last_update, action: 'leaving')
+ print_release_state(subject: "Release", release_name: release.name, release_date: release.last_update, action: "leaving")
end
end
end
@@ -98,23 +98,23 @@ class AutomatedCleanup
private
def delete_environment(environment, deployment)
- print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'deleting')
+ print_release_state(subject: "Review app", release_name: environment.slug, release_date: deployment.created_at, action: "deleting")
gitlab.delete_environment(project_path, environment.id)
end
def stop_environment(environment, deployment)
- print_release_state(subject: 'Review app', release_name: environment.slug, release_date: deployment.created_at, action: 'stopping')
+ print_release_state(subject: "Review app", release_name: environment.slug, release_date: deployment.created_at, action: "stopping")
gitlab.stop_environment(project_path, environment.id)
end
def helm_releases
- args = ['--all', '--date', "--max #{HELM_RELEASES_BATCH_SIZE}"]
+ args = ["--all", "--date", "--max #{HELM_RELEASES_BATCH_SIZE}"]
helm.releases(args: args)
end
def delete_helm_release(release)
- print_release_state(subject: 'Release', release_name: release.name, release_status: release.status, release_date: release.last_update, action: 'cleaning')
+ print_release_state(subject: "Release", release_name: release.name, release_status: release.status, release_date: release.last_update, action: "cleaning")
helm.delete(release_name: release.name)
kubernetes.cleanup(release_name: release.name)
rescue Quality::HelmClient::CommandFailedError => ex
@@ -148,13 +148,13 @@ end
automated_cleanup = AutomatedCleanup.new
-timed('Review apps cleanup') do
+timed("Review apps cleanup") do
automated_cleanup.perform_gitlab_environment_cleanup!(days_for_stop: 2, days_for_delete: 3)
end
puts
-timed('Helm releases cleanup') do
+timed("Helm releases cleanup") do
automated_cleanup.perform_helm_releases_cleanup!(days: 3)
end
diff --git a/scripts/security-harness b/scripts/security-harness
index 8369cf06223..51eaefe2003 100755
--- a/scripts/security-harness
+++ b/scripts/security-harness
@@ -1,9 +1,9 @@
#!/usr/bin/env ruby
-require 'digest'
-require 'fileutils'
+require "digest"
+require "fileutils"
-harness_path = File.expand_path('../.git/security_harness', __dir__)
+harness_path = File.expand_path("../.git/security_harness", __dir__)
hook_path = File.expand_path("../.git/hooks/pre-push", __dir__)
if File.exist?(hook_path)
@@ -18,11 +18,11 @@ if File.exist?(hook_path)
exit 1
end
else
- File.open(hook_path, 'w') do |file|
+ File.open(hook_path, "w") do |file|
IO.copy_stream(DATA, file)
end
- File.chmod(0755, hook_path)
+ File.chmod(0o755, hook_path)
end
# Toggle the harness on or off
diff --git a/scripts/static-analysis b/scripts/static-analysis
index 642c50ec0a8..74bf635bffa 100755
--- a/scripts/static-analysis
+++ b/scripts/static-analysis
@@ -1,13 +1,13 @@
#!/usr/bin/env ruby
# We don't have auto-loading here
-require_relative '../lib/gitlab/popen'
-require_relative '../lib/gitlab/popen/runner'
+require_relative "../lib/gitlab/popen"
+require_relative "../lib/gitlab/popen/runner"
def emit_warnings(static_analysis)
static_analysis.warned_results.each do |result|
puts
- puts "**** #{result.cmd.join(' ')} had the following warning(s):"
+ puts "**** #{result.cmd.join(" ")} had the following warning(s):"
puts
puts result.stderr
puts
@@ -17,7 +17,7 @@ end
def emit_errors(static_analysis)
static_analysis.failed_results.each do |result|
puts
- puts "**** #{result.cmd.join(' ')} failed with the following error(s):"
+ puts "**** #{result.cmd.join(" ")} failed with the following error(s):"
puts
puts result.stdout
puts result.stderr
@@ -33,14 +33,14 @@ tasks = [
%w[yarn run prettier-all],
%w[bundle exec rubocop --parallel],
%w[scripts/lint-conflicts.sh],
- %w[scripts/lint-rugged]
+ %w[scripts/lint-rugged],
]
static_analysis = Gitlab::Popen::Runner.new
static_analysis.run(tasks) do |cmd, &run|
puts
- puts "$ #{cmd.join(' ')}"
+ puts "$ #{cmd.join(" ")}"
result = run.call
@@ -49,21 +49,21 @@ static_analysis.run(tasks) do |cmd, &run|
end
puts
-puts '==================================================='
+puts "==================================================="
puts
puts
if static_analysis.all_success_and_clean?
- puts 'All static analyses passed successfully.'
+ puts "All static analyses passed successfully."
elsif static_analysis.all_success?
- puts 'All static analyses passed successfully, but we have warnings:'
+ puts "All static analyses passed successfully, but we have warnings:"
puts
emit_warnings(static_analysis)
exit 2
else
- puts 'Some static analyses failed:'
+ puts "Some static analyses failed:"
emit_warnings(static_analysis)
emit_errors(static_analysis)
diff --git a/scripts/sync-reports b/scripts/sync-reports
index 5ed65e78005..ba7360d4d47 100755
--- a/scripts/sync-reports
+++ b/scripts/sync-reports
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
-require 'rubygems'
-require 'fog/aws'
+require "rubygems"
+require "fog/aws"
class SyncReports
ACTIONS = %w[get put].freeze
@@ -18,9 +18,9 @@ class SyncReports
def perform_sync!
case options[:action]
- when 'get'
+ when "get"
get_reports!
- when 'put'
+ when "put"
put_reports!
end
end
@@ -60,21 +60,21 @@ class SyncReports
def storage
@storage ||=
Fog::Storage.new(
- provider: 'AWS',
- aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
- aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY']
+ provider: "AWS",
+ aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
+ aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
)
end
end
-def usage!(error: 'action')
+def usage!(error: "action")
print "\n[ERROR]: "
case error
- when 'action'
- puts "Please specify an action as first argument: #{SyncReports::ACTIONS.join(', ')}\n\n"
- when 'bucket'
+ when "action"
+ puts "Please specify an action as first argument: #{SyncReports::ACTIONS.join(", ")}\n\n"
+ when "bucket"
puts "Please specify a bucket as second argument!\n\n"
- when 'files'
+ when "files"
puts "Please specify one or more file paths as third argument!\n\n"
end
puts "Usage: #{__FILE__} [get|put] bucket report_path ...\n\n"
@@ -85,11 +85,11 @@ end
if $0 == __FILE__
action = ARGV.shift
- usage!(error: 'action') unless SyncReports::ACTIONS.include?(action)
+ usage!(error: "action") unless SyncReports::ACTIONS.include?(action)
bucket = ARGV.shift
- usage!(error: 'bucket') unless bucket
- usage!(error: 'files') unless ARGV.any?
+ usage!(error: "bucket") unless bucket
+ usage!(error: "files") unless ARGV.any?
SyncReports.new(action: action, bucket: bucket, report_paths: ARGV)
end
diff --git a/scripts/trigger-build b/scripts/trigger-build
index 9dbafffddfc..00b7c0caf39 100755
--- a/scripts/trigger-build
+++ b/scripts/trigger-build
@@ -1,18 +1,18 @@
#!/usr/bin/env ruby
# frozen_string_literal: true
-require 'gitlab'
+require "gitlab"
#
# Configure credentials to be used with gitlab gem
#
Gitlab.configure do |config|
- config.endpoint = 'https://gitlab.com/api/v4'
+ config.endpoint = "https://gitlab.com/api/v4"
end
module Trigger
def self.ee?
- ENV['CI_PROJECT_NAME'] == 'gitlab-ee' || File.exist?('CHANGELOG-EE.md')
+ ENV["CI_PROJECT_NAME"] == "gitlab-ee" || File.exist?("CHANGELOG-EE.md")
end
class Base
@@ -21,7 +21,8 @@ module Trigger
downstream_project_path,
trigger_token,
ref,
- variables)
+ variables
+ )
puts "Triggered downstream pipeline: #{pipeline.web_url}\n"
puts "Waiting for downstream pipeline status"
@@ -68,12 +69,12 @@ module Trigger
def base_variables
{
- 'GITLAB_REF_SLUG' => ENV['CI_COMMIT_TAG'] ? ENV['CI_COMMIT_REF_NAME'] : ENV['CI_COMMIT_REF_SLUG'],
- 'TRIGGERED_USER' => ENV['TRIGGERED_USER'] || ENV['GITLAB_USER_NAME'],
- 'TRIGGER_SOURCE' => ENV['CI_JOB_URL'],
- 'TOP_UPSTREAM_SOURCE_PROJECT' => ENV['CI_PROJECT_PATH'],
- 'TOP_UPSTREAM_SOURCE_JOB' => ENV['CI_JOB_URL'],
- 'TOP_UPSTREAM_SOURCE_SHA' => ENV['CI_COMMIT_SHA']
+ "GITLAB_REF_SLUG" => ENV["CI_COMMIT_TAG"] ? ENV["CI_COMMIT_REF_NAME"] : ENV["CI_COMMIT_REF_SLUG"],
+ "TRIGGERED_USER" => ENV["TRIGGERED_USER"] || ENV["GITLAB_USER_NAME"],
+ "TRIGGER_SOURCE" => ENV["CI_JOB_URL"],
+ "TOP_UPSTREAM_SOURCE_PROJECT" => ENV["CI_PROJECT_PATH"],
+ "TOP_UPSTREAM_SOURCE_JOB" => ENV["CI_JOB_URL"],
+ "TOP_UPSTREAM_SOURCE_SHA" => ENV["CI_COMMIT_SHA"],
}
end
@@ -89,27 +90,27 @@ module Trigger
private
def downstream_project_path
- 'gitlab-org/omnibus-gitlab'
+ "gitlab-org/omnibus-gitlab"
end
def ref
- ENV['OMNIBUS_BRANCH'] || 'master'
+ ENV["OMNIBUS_BRANCH"] || "master"
end
def trigger_token
- ENV['BUILD_TRIGGER_TOKEN']
+ ENV["BUILD_TRIGGER_TOKEN"]
end
def access_token
- ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
+ ENV["GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN"]
end
def extra_variables
{
- 'GITLAB_VERSION' => ENV['CI_COMMIT_SHA'],
- 'ALTERNATIVE_SOURCES' => 'true',
- 'ee' => Trigger.ee? ? 'true' : 'false',
- 'QA_BRANCH' => ENV['QA_BRANCH'] || 'master'
+ "GITLAB_VERSION" => ENV["CI_COMMIT_SHA"],
+ "ALTERNATIVE_SOURCES" => "true",
+ "ee" => Trigger.ee? ? "true" : "false",
+ "QA_BRANCH" => ENV["QA_BRANCH"] || "master",
}
end
end
@@ -118,31 +119,31 @@ module Trigger
private
def downstream_project_path
- ENV['CNG_PROJECT_PATH'] || 'gitlab-org/build/CNG-mirror'
+ ENV["CNG_PROJECT_PATH"] || "gitlab-org/build/CNG-mirror"
end
def ref
- ENV['CNG_BRANCH'] || 'master'
+ ENV["CNG_BRANCH"] || "master"
end
def trigger_token
- ENV['BUILD_TRIGGER_TOKEN']
+ ENV["BUILD_TRIGGER_TOKEN"]
end
def access_token
- ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
+ ENV["GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN"]
end
def extra_variables
- edition = Trigger.ee? ? 'EE' : 'CE'
+ edition = Trigger.ee? ? "EE" : "CE"
{
# Back-compatibility until https://gitlab.com/gitlab-org/build/CNG/merge_requests/189 is merged
- "GITLAB_#{edition}_VERSION" => ENV['CI_COMMIT_REF_NAME'],
- "GITLAB_VERSION" => ENV['CI_COMMIT_REF_NAME'],
- "GITLAB_TAG" => ENV['CI_COMMIT_TAG'],
- "GITLAB_ASSETS_TAG" => ENV['CI_COMMIT_REF_SLUG'],
- "#{edition}_PIPELINE" => 'true'
+ "GITLAB_#{edition}_VERSION" => ENV["CI_COMMIT_REF_NAME"],
+ "GITLAB_VERSION" => ENV["CI_COMMIT_REF_NAME"],
+ "GITLAB_TAG" => ENV["CI_COMMIT_TAG"],
+ "GITLAB_ASSETS_TAG" => ENV["CI_COMMIT_REF_SLUG"],
+ "#{edition}_PIPELINE" => "true",
}
end
@@ -150,7 +151,7 @@ module Trigger
raw_version = super
# if the version matches semver format, treat it as a tag and prepend `v`
- if raw_version =~ Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/)
+ if raw_version&.match?(Regexp.compile(/^\d+\.\d+\.\d+(-rc\d+)?(-ee)?$/))
"v#{raw_version}"
else
raw_version
@@ -163,10 +164,10 @@ module Trigger
Gitlab.private_token = access_token
Gitlab.create_commit_comment(
- ENV['CI_PROJECT_PATH'],
- ENV['CI_COMMIT_SHA'],
- "The [`#{ENV['CI_JOB_NAME']}`](#{ENV['CI_JOB_URL']}) job from pipeline #{ENV['CI_PIPELINE_URL']} triggered #{downstream_pipeline.web_url} downstream.")
-
+ ENV["CI_PROJECT_PATH"],
+ ENV["CI_COMMIT_SHA"],
+ "The [`#{ENV["CI_JOB_NAME"]}`](#{ENV["CI_JOB_URL"]}) job from pipeline #{ENV["CI_PIPELINE_URL"]} triggered #{downstream_pipeline.web_url} downstream."
+ )
rescue Gitlab::Error::Error => error
puts "Ignoring the following error: #{error}"
end
@@ -227,9 +228,9 @@ module Trigger
end
case ARGV[0]
-when 'omnibus'
+when "omnibus"
Trigger::Omnibus.new.invoke!(post_comment: true).wait!
-when 'cng'
+when "cng"
Trigger::CNG.new.invoke!.wait!
else
puts "Please provide a valid option:
diff --git a/scripts/trigger-build-docs b/scripts/trigger-build-docs
index dfc8ee6050a..aa496f552b5 100755
--- a/scripts/trigger-build-docs
+++ b/scripts/trigger-build-docs
@@ -1,19 +1,19 @@
#!/usr/bin/env ruby
-require 'gitlab'
+require "gitlab"
#
# Configure credentials to be used with gitlab gem
#
Gitlab.configure do |config|
- config.endpoint = 'https://gitlab.com/api/v4'
+ config.endpoint = "https://gitlab.com/api/v4"
config.private_token = ENV["DOCS_API_TOKEN"] # GitLab Docs bot access token with Developer access to gitlab-docs
end
#
# The remote docs project
#
-GITLAB_DOCS_REPO = 'gitlab-com/gitlab-docs'.freeze
+GITLAB_DOCS_REPO = "gitlab-com/gitlab-docs".freeze
#
# Truncate the remote docs branch name otherwise we hit the filesystem
@@ -34,7 +34,7 @@ end
# https://gitlab.com/gitlab-com/gitlab-docs/issues/154.
#
def create_remote_branch
- Gitlab.create_branch(GITLAB_DOCS_REPO, docs_branch, 'master')
+ Gitlab.create_branch(GITLAB_DOCS_REPO, docs_branch, "master")
puts "=> Remote branch '#{docs_branch}' created"
pipelines = nil
@@ -43,7 +43,7 @@ def create_remote_branch
loop do
sleep 1
puts "=> Waiting for pipeline to start..."
- pipelines = Gitlab.pipelines(GITLAB_DOCS_REPO, { ref: docs_branch })
+ pipelines = Gitlab.pipelines(GITLAB_DOCS_REPO, {ref: docs_branch})
break if pipelines.any?
end
@@ -69,14 +69,14 @@ end
#
def slug
case ENV["CI_PROJECT_NAME"]
- when 'gitlab-ce'
- 'ce'
- when 'gitlab-ee'
- 'ee'
- when 'gitlab-runner'
- 'runner'
- when 'omnibus-gitlab'
- 'omnibus'
+ when "gitlab-ce"
+ "ce"
+ when "gitlab-ee"
+ "ee"
+ when "gitlab-runner"
+ "runner"
+ when "omnibus-gitlab"
+ "omnibus"
end
end
@@ -95,7 +95,7 @@ def trigger_pipeline
app_url = "http://#{docs_branch}.#{ENV["DOCS_REVIEW_APPS_DOMAIN"]}/#{slug}"
# Create the cross project pipeline using CI_JOB_TOKEN
- pipeline = Gitlab.run_trigger(GITLAB_DOCS_REPO, ENV["CI_JOB_TOKEN"], docs_branch, { param_name => ENV["CI_COMMIT_REF_NAME"] })
+ pipeline = Gitlab.run_trigger(GITLAB_DOCS_REPO, ENV["CI_JOB_TOKEN"], docs_branch, {param_name => ENV["CI_COMMIT_REF_NAME"]})
puts "=> Follow the status of the triggered pipeline:"
puts ""
@@ -118,10 +118,10 @@ end
# are no stale remote branches and the Review server doesn't fill.
#
case ARGV[0]
-when 'deploy'
+when "deploy"
create_remote_branch
trigger_pipeline
-when 'cleanup'
+when "cleanup"
remove_remote_branch
else
puts "Please provide a valid option:
diff --git a/spec/bin/changelog_spec.rb b/spec/bin/changelog_spec.rb
index b2c2fb810e8..39b1820f603 100644
--- a/spec/bin/changelog_spec.rb
+++ b/spec/bin/changelog_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-load File.expand_path('../../bin/changelog', __dir__)
+load File.expand_path("../../bin/changelog", __dir__)
-describe 'bin/changelog' do
- let(:options) { OpenStruct.new(title: 'Test title', type: 'fixed', dry_run: true) }
+describe "bin/changelog" do
+ let(:options) { OpenStruct.new(title: "Test title", type: "fixed", dry_run: true) }
describe ChangelogEntry do
- it 'truncates the file path' do
+ it "truncates the file path" do
entry = described_class.new(options)
allow(entry).to receive(:ee?).and_return(false)
- allow(entry).to receive(:branch_name).and_return('long-branch-' * 100)
+ allow(entry).to receive(:branch_name).and_return("long-branch-" * 100)
file_path = entry.send(:file_path)
expect(file_path.length).to eq(140)
@@ -18,14 +18,14 @@ describe 'bin/changelog' do
end
describe ChangelogOptionParser do
- describe '.parse' do
- it 'parses --amend' do
+ describe ".parse" do
+ it "parses --amend" do
options = described_class.parse(%w[foo bar --amend])
expect(options.amend).to eq true
end
- it 'parses --force and -f' do
+ it "parses --force and -f" do
%w[--force -f].each do |flag|
options = described_class.parse(%W[foo #{flag} bar])
@@ -33,7 +33,7 @@ describe 'bin/changelog' do
end
end
- it 'parses --merge-request and -m' do
+ it "parses --merge-request and -m" do
%w[--merge-request -m].each do |flag|
options = described_class.parse(%W[foo #{flag} 1234 bar])
@@ -41,7 +41,7 @@ describe 'bin/changelog' do
end
end
- it 'parses --dry-run and -n' do
+ it "parses --dry-run and -n" do
%w[--dry-run -n].each do |flag|
options = described_class.parse(%W[foo #{flag} bar])
@@ -49,59 +49,59 @@ describe 'bin/changelog' do
end
end
- it 'parses --git-username and -u' do
- allow(described_class).to receive(:git_user_name).and_return('Jane Doe')
+ it "parses --git-username and -u" do
+ allow(described_class).to receive(:git_user_name).and_return("Jane Doe")
%w[--git-username -u].each do |flag|
options = described_class.parse(%W[foo #{flag} bar])
- expect(options.author).to eq 'Jane Doe'
+ expect(options.author).to eq "Jane Doe"
end
end
- it 'parses --type and -t' do
+ it "parses --type and -t" do
%w[--type -t].each do |flag|
options = described_class.parse(%W[foo #{flag} security])
- expect(options.type).to eq 'security'
+ expect(options.type).to eq "security"
end
end
- it 'parses -h' do
- expect do
+ it "parses -h" do
+ expect {
expect { described_class.parse(%w[foo -h bar]) }.to output.to_stdout
- end.to raise_error(ChangelogHelpers::Done)
+ }.to raise_error(ChangelogHelpers::Done)
end
- it 'assigns title' do
+ it "assigns title" do
options = described_class.parse(%W[foo -m 1 bar\n baz\r\n --amend])
- expect(options.title).to eq 'foo bar baz'
+ expect(options.title).to eq "foo bar baz"
end
end
- describe '.read_type' do
- let(:type) { '1' }
+ describe ".read_type" do
+ let(:type) { "1" }
- it 'reads type from $stdin' do
+ it "reads type from $stdin" do
expect($stdin).to receive(:getc).and_return(type)
- expect do
- expect(described_class.read_type).to eq('added')
- end.to output.to_stdout
+ expect {
+ expect(described_class.read_type).to eq("added")
+ }.to output.to_stdout
end
- context 'invalid type given' do
- let(:type) { '99' }
+ context "invalid type given" do
+ let(:type) { "99" }
- it 'shows error message and exits the program' do
+ it "shows error message and exits the program" do
allow($stdin).to receive(:getc).and_return(type)
- expect do
+ expect {
expect { described_class.read_type }.to raise_error(
ChangelogHelpers::Abort,
- 'Invalid category index, please select an index between 1 and 8'
+ "Invalid category index, please select an index between 1 and 8"
)
- end.to output.to_stdout
+ }.to output.to_stdout
end
end
end
diff --git a/spec/config/application_spec.rb b/spec/config/application_spec.rb
index 01ed81964c3..ef9c2159b6e 100644
--- a/spec/config/application_spec.rb
+++ b/spec/config/application_spec.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Application do # rubocop:disable RSpec/FilePath
using RSpec::Parameterized::TableSyntax
FILTERED_PARAM = ActionDispatch::Http::ParameterFilter::FILTERED
- context 'when parameters are logged' do
- describe 'rails does not leak confidential parameters' do
+ context "when parameters are logged" do
+ describe "rails does not leak confidential parameters" do
def request_for_url(input_url)
env = Rack::MockRequest.env_for(input_url)
- env['action_dispatch.parameter_filter'] = described_class.config.filter_parameters
+ env["action_dispatch.parameter_filter"] = described_class.config.filter_parameters
ActionDispatch::Request.new(env)
end
where(:input_url, :output_query) do
- '/' | {}
- '/?safe=1' | { 'safe' => '1' }
- '/?private_token=secret' | { 'private_token' => FILTERED_PARAM }
- '/?mixed=1&private_token=secret' | { 'mixed' => '1', 'private_token' => FILTERED_PARAM }
- '/?note=secret&noteable=1&prefix_note=2' | { 'note' => FILTERED_PARAM, 'noteable' => '1', 'prefix_note' => '2' }
- '/?note[note]=secret&target_type=1' | { 'note' => FILTERED_PARAM, 'target_type' => '1' }
- '/?safe[note]=secret&target_type=1' | { 'safe' => { 'note' => FILTERED_PARAM }, 'target_type' => '1' }
+ "/" | {}
+ "/?safe=1" | {"safe" => "1"}
+ "/?private_token=secret" | {"private_token" => FILTERED_PARAM}
+ "/?mixed=1&private_token=secret" | {"mixed" => "1", "private_token" => FILTERED_PARAM}
+ "/?note=secret&noteable=1&prefix_note=2" | {"note" => FILTERED_PARAM, "noteable" => "1", "prefix_note" => "2"}
+ "/?note[note]=secret&target_type=1" | {"note" => FILTERED_PARAM, "target_type" => "1"}
+ "/?safe[note]=secret&target_type=1" | {"safe" => {"note" => FILTERED_PARAM}, "target_type" => "1"}
end
with_them do
diff --git a/spec/config/mail_room_spec.rb b/spec/config/mail_room_spec.rb
index 74634dac713..33c1a6aa402 100644
--- a/spec/config/mail_room_spec.rb
+++ b/spec/config/mail_room_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'mail_room.yml' do
+describe "mail_room.yml" do
include StubENV
- let(:mailroom_config_path) { 'config/mail_room.yml' }
- let(:gitlab_config_path) { 'config/mail_room.yml' }
- let(:queues_config_path) { 'config/redis.queues.yml' }
+ let(:mailroom_config_path) { "config/mail_room.yml" }
+ let(:gitlab_config_path) { "config/mail_room.yml" }
+ let(:queues_config_path) { "config/redis.queues.yml" }
let(:configuration) do
vars = {
- 'MAIL_ROOM_GITLAB_CONFIG_FILE' => absolute_path(gitlab_config_path),
- 'GITLAB_REDIS_QUEUES_CONFIG_FILE' => absolute_path(queues_config_path)
+ "MAIL_ROOM_GITLAB_CONFIG_FILE" => absolute_path(gitlab_config_path),
+ "GITLAB_REDIS_QUEUES_CONFIG_FILE" => absolute_path(queues_config_path),
}
cmd = "puts ERB.new(File.read(#{absolute_path(mailroom_config_path).inspect})).result"
- output, status = Gitlab::Popen.popen(%W(ruby -rerb -e #{cmd}), absolute_path('config'), vars)
+ output, status = Gitlab::Popen.popen(%W[ruby -rerb -e #{cmd}], absolute_path("config"), vars)
raise "Error interpreting #{mailroom_config_path}: #{output}" unless status.zero?
YAML.load(output)
end
before do
- stub_env('GITLAB_REDIS_QUEUES_CONFIG_FILE', absolute_path(queues_config_path))
+ stub_env("GITLAB_REDIS_QUEUES_CONFIG_FILE", absolute_path(queues_config_path))
clear_queues_raw_config
end
@@ -29,31 +29,31 @@ describe 'mail_room.yml' do
clear_queues_raw_config
end
- context 'when incoming email is disabled' do
- let(:gitlab_config_path) { 'spec/fixtures/config/mail_room_disabled.yml' }
+ context "when incoming email is disabled" do
+ let(:gitlab_config_path) { "spec/fixtures/config/mail_room_disabled.yml" }
- it 'contains no configuration' do
+ it "contains no configuration" do
expect(configuration[:mailboxes]).to be_nil
end
end
- context 'when incoming email is enabled' do
- let(:gitlab_config_path) { 'spec/fixtures/config/mail_room_enabled.yml' }
- let(:queues_config_path) { 'spec/fixtures/config/redis_queues_new_format_host.yml' }
+ context "when incoming email is enabled" do
+ let(:gitlab_config_path) { "spec/fixtures/config/mail_room_enabled.yml" }
+ let(:queues_config_path) { "spec/fixtures/config/redis_queues_new_format_host.yml" }
let(:gitlab_redis_queues) { Gitlab::Redis::Queues.new(Rails.env) }
- it 'contains the intended configuration' do
+ it "contains the intended configuration" do
expect(configuration[:mailboxes].length).to eq(1)
mailbox = configuration[:mailboxes].first
- expect(mailbox[:host]).to eq('imap.gmail.com')
+ expect(mailbox[:host]).to eq("imap.gmail.com")
expect(mailbox[:port]).to eq(993)
expect(mailbox[:ssl]).to eq(true)
expect(mailbox[:start_tls]).to eq(false)
- expect(mailbox[:email]).to eq('gitlab-incoming@gmail.com')
- expect(mailbox[:password]).to eq('[REDACTED]')
- expect(mailbox[:name]).to eq('inbox')
+ expect(mailbox[:email]).to eq("gitlab-incoming@gmail.com")
+ expect(mailbox[:password]).to eq("[REDACTED]")
+ expect(mailbox[:name]).to eq("inbox")
expect(mailbox[:idle_timeout]).to eq(60)
redis_url = gitlab_redis_queues.url
diff --git a/spec/config/object_store_settings_spec.rb b/spec/config/object_store_settings_spec.rb
index b1ada3c99db..aa3d382c92e 100644
--- a/spec/config/object_store_settings_spec.rb
+++ b/spec/config/object_store_settings_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
-require Rails.root.join('config', 'object_store_settings.rb')
+require "spec_helper"
+require Rails.root.join("config", "object_store_settings.rb")
describe ObjectStoreSettings do
- describe '.parse' do
- it 'should set correct default values' do
+ describe ".parse" do
+ it "should set correct default values" do
settings = described_class.parse(nil)
- expect(settings['enabled']).to be false
- expect(settings['direct_upload']).to be false
- expect(settings['background_upload']).to be true
- expect(settings['remote_directory']).to be nil
+ expect(settings["enabled"]).to be false
+ expect(settings["direct_upload"]).to be false
+ expect(settings["background_upload"]).to be true
+ expect(settings["remote_directory"]).to be nil
end
- it 'respects original values' do
+ it "respects original values" do
original_settings = Settingslogic.new({
- 'enabled' => true,
- 'remote_directory' => 'artifacts'
+ "enabled" => true,
+ "remote_directory" => "artifacts",
})
settings = described_class.parse(original_settings)
- expect(settings['enabled']).to be true
- expect(settings['direct_upload']).to be false
- expect(settings['background_upload']).to be true
- expect(settings['remote_directory']).to eq 'artifacts'
+ expect(settings["enabled"]).to be true
+ expect(settings["direct_upload"]).to be false
+ expect(settings["background_upload"]).to be true
+ expect(settings["remote_directory"]).to eq "artifacts"
end
end
end
diff --git a/spec/config/settings_spec.rb b/spec/config/settings_spec.rb
index c89b5f48dc0..71f7f7a443f 100644
--- a/spec/config/settings_spec.rb
+++ b/spec/config/settings_spec.rb
@@ -1,59 +1,59 @@
-require 'spec_helper'
+require "spec_helper"
describe Settings do
- describe 'omniauth' do
- it 'defaults to enabled' do
+ describe "omniauth" do
+ it "defaults to enabled" do
expect(described_class.omniauth.enabled).to be true
end
end
- describe '.attr_encrypted_db_key_base_truncated' do
- it 'is a string with maximum 32 bytes size' do
+ describe ".attr_encrypted_db_key_base_truncated" do
+ it "is a string with maximum 32 bytes size" do
expect(described_class.attr_encrypted_db_key_base_truncated.bytesize)
.to be <= 32
end
end
- describe '.attr_encrypted_db_key_base_12' do
- context 'when db key base secret is less than 12 bytes' do
+ describe ".attr_encrypted_db_key_base_12" do
+ context "when db key base secret is less than 12 bytes" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('a' * 10)
+ .and_return("a" * 10)
end
- it 'expands db key base secret to 12 bytes' do
+ it "expands db key base secret to 12 bytes" do
expect(described_class.attr_encrypted_db_key_base_12)
- .to eq(('a' * 10) + ('0' * 2))
+ .to eq(("a" * 10) + ("0" * 2))
end
end
- context 'when key has multiple multi-byte UTF chars exceeding 12 bytes' do
+ context "when key has multiple multi-byte UTF chars exceeding 12 bytes" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('❤' * 18)
+ .and_return("❤" * 18)
end
- it 'does not use more than 32 bytes' do
+ it "does not use more than 32 bytes" do
db_key_base = described_class.attr_encrypted_db_key_base_12
- expect(db_key_base).to eq('❤' * 4)
+ expect(db_key_base).to eq("❤" * 4)
expect(db_key_base.bytesize).to eq 12
end
end
end
- describe '.attr_encrypted_db_key_base_32' do
- context 'when db key base secret is less than 32 bytes' do
+ describe ".attr_encrypted_db_key_base_32" do
+ context "when db key base secret is less than 32 bytes" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('a' * 10)
+ .and_return("a" * 10)
end
- it 'expands db key base secret to 32 bytes' do
- expanded_key_base = ('a' * 10) + ('0' * 22)
+ it "expands db key base secret to 32 bytes" do
+ expanded_key_base = ("a" * 10) + ("0" * 22)
expect(expanded_key_base.bytesize).to eq 32
expect(described_class.attr_encrypted_db_key_base_32)
@@ -61,45 +61,45 @@ describe Settings do
end
end
- context 'when db key base secret is 32 bytes' do
+ context "when db key base secret is 32 bytes" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('a' * 32)
+ .and_return("a" * 32)
end
- it 'returns original value' do
+ it "returns original value" do
expect(described_class.attr_encrypted_db_key_base_32)
- .to eq 'a' * 32
+ .to eq "a" * 32
end
end
- context 'when db key base contains multi-byte UTF character' do
+ context "when db key base contains multi-byte UTF character" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('❤' * 6)
+ .and_return("❤" * 6)
end
- it 'does not use more than 32 bytes' do
+ it "does not use more than 32 bytes" do
db_key_base = described_class.attr_encrypted_db_key_base_32
- expect(db_key_base).to eq '❤❤❤❤❤❤' + ('0' * 14)
+ expect(db_key_base).to eq "❤❤❤❤❤❤" + ("0" * 14)
expect(db_key_base.bytesize).to eq 32
end
end
- context 'when db key base multi-byte UTF chars exceeding 32 bytes' do
+ context "when db key base multi-byte UTF chars exceeding 32 bytes" do
before do
allow(described_class)
.to receive(:attr_encrypted_db_key_base)
- .and_return('❤' * 18)
+ .and_return("❤" * 18)
end
- it 'does not use more than 32 bytes' do
+ it "does not use more than 32 bytes" do
db_key_base = described_class.attr_encrypted_db_key_base_32
- expect(db_key_base).to eq(('❤' * 10) + ('0' * 2))
+ expect(db_key_base).to eq(("❤" * 10) + ("0" * 2))
expect(db_key_base.bytesize).to eq 32
end
end
diff --git a/spec/controllers/abuse_reports_controller_spec.rb b/spec/controllers/abuse_reports_controller_spec.rb
index 7104305e9d2..fac7bc1c402 100644
--- a/spec/controllers/abuse_reports_controller_spec.rb
+++ b/spec/controllers/abuse_reports_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AbuseReportsController do
let(:reporter) { create(:user) }
@@ -13,56 +13,56 @@ describe AbuseReportsController do
sign_in(reporter)
end
- describe 'GET new' do
- context 'when the user has already been deleted' do
- it 'redirects the reporter to root_path' do
+ describe "GET new" do
+ context "when the user has already been deleted" do
+ it "redirects the reporter to root_path" do
user_id = user.id
user.destroy
- get :new, params: { user_id: user_id }
+ get :new, params: {user_id: user_id}
expect(response).to redirect_to root_path
- expect(flash[:alert]).to eq('Cannot create the abuse report. The user has been deleted.')
+ expect(flash[:alert]).to eq("Cannot create the abuse report. The user has been deleted.")
end
end
- context 'when the user has already been blocked' do
- it 'redirects the reporter to the user\'s profile' do
+ context "when the user has already been blocked" do
+ it "redirects the reporter to the user's profile" do
user.block
- get :new, params: { user_id: user.id }
+ get :new, params: {user_id: user.id}
expect(response).to redirect_to user
- expect(flash[:alert]).to eq('Cannot create the abuse report. This user has been blocked.')
+ expect(flash[:alert]).to eq("Cannot create the abuse report. This user has been blocked.")
end
end
end
- describe 'POST create' do
- context 'with valid attributes' do
- it 'saves the abuse report' do
- expect do
- post :create, params: { abuse_report: attrs }
- end.to change { AbuseReport.count }.by(1)
+ describe "POST create" do
+ context "with valid attributes" do
+ it "saves the abuse report" do
+ expect {
+ post :create, params: {abuse_report: attrs}
+ }.to change { AbuseReport.count }.by(1)
end
- it 'calls notify' do
+ it "calls notify" do
expect_any_instance_of(AbuseReport).to receive(:notify)
- post :create, params: { abuse_report: attrs }
+ post :create, params: {abuse_report: attrs}
end
- it 'redirects back to the reported user' do
- post :create, params: { abuse_report: attrs }
+ it "redirects back to the reported user" do
+ post :create, params: {abuse_report: attrs}
expect(response).to redirect_to user
end
end
- context 'with invalid attributes' do
- it 'renders new' do
+ context "with invalid attributes" do
+ it "renders new" do
attrs.delete(:user_id)
- post :create, params: { abuse_report: attrs }
+ post :create, params: {abuse_report: attrs}
expect(response).to render_template(:new)
end
diff --git a/spec/controllers/admin/appearances_controller_spec.rb b/spec/controllers/admin/appearances_controller_spec.rb
index 621aa148301..7b48838b807 100644
--- a/spec/controllers/admin/appearances_controller_spec.rb
+++ b/spec/controllers/admin/appearances_controller_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Admin::AppearancesController do
let(:admin) { create(:admin) }
- let(:header_message) { 'Header message' }
- let(:footer_message) { 'Footer' }
+ let(:header_message) { "Header message" }
+ let(:footer_message) { "Footer" }
- describe 'POST #create' do
+ describe "POST #create" do
let(:create_params) do
{
- title: 'Foo',
- description: 'Bar',
+ title: "Foo",
+ description: "Bar",
header_message: header_message,
- footer_message: footer_message
+ footer_message: footer_message,
}
end
@@ -21,23 +21,23 @@ describe Admin::AppearancesController do
sign_in(admin)
end
- it 'creates appearance with footer and header message' do
- post :create, params: { appearance: create_params }
+ it "creates appearance with footer and header message" do
+ post :create, params: {appearance: create_params}
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: false,
- message_background_color: '#E75E40',
- message_font_color: '#FFFFFF'
+ message_background_color: "#E75E40",
+ message_font_color: "#FFFFFF"
)
end
- context 'when enabling header and footer in email' do
- it 'creates appearance with enabled flag' do
+ context "when enabling header and footer in email" do
+ it "creates appearance with enabled flag" do
create_params[:email_header_and_footer_enabled] = true
- post :create, params: { appearance: create_params }
+ post :create, params: {appearance: create_params}
expect(Appearance.current).to have_attributes(
header_message: header_message,
@@ -48,11 +48,11 @@ describe Admin::AppearancesController do
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
let(:update_params) do
{
header_message: header_message,
- footer_message: footer_message
+ footer_message: footer_message,
}
end
@@ -62,23 +62,23 @@ describe Admin::AppearancesController do
sign_in(admin)
end
- it 'updates appearance with footer and header message' do
- put :update, params: { appearance: update_params }
+ it "updates appearance with footer and header message" do
+ put :update, params: {appearance: update_params}
expect(Appearance.current).to have_attributes(
header_message: header_message,
footer_message: footer_message,
email_header_and_footer_enabled: false,
- message_background_color: '#E75E40',
- message_font_color: '#FFFFFF'
+ message_background_color: "#E75E40",
+ message_font_color: "#FFFFFF"
)
end
- context 'when enabling header and footer in email' do
- it 'updates appearance with enabled flag' do
+ context "when enabling header and footer in email" do
+ it "updates appearance with enabled flag" do
update_params[:email_header_and_footer_enabled] = true
- post :update, params: { appearance: update_params }
+ post :update, params: {appearance: update_params}
expect(Appearance.current).to have_attributes(
header_message: header_message,
diff --git a/spec/controllers/admin/application_settings_controller_spec.rb b/spec/controllers/admin/application_settings_controller_spec.rb
index 9af472df74e..03c48073e7b 100644
--- a/spec/controllers/admin/application_settings_controller_spec.rb
+++ b/spec/controllers/admin/application_settings_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ApplicationSettingsController do
include StubENV
@@ -9,96 +9,96 @@ describe Admin::ApplicationSettingsController do
let(:user) { create(:user)}
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- describe 'GET #usage_data with no access' do
+ describe "GET #usage_data with no access" do
before do
sign_in(user)
end
- it 'returns 404' do
+ it "returns 404" do
get :usage_data, format: :html
expect(response.status).to eq(404)
end
end
- describe 'GET #usage_data' do
+ describe "GET #usage_data" do
before do
sign_in(admin)
end
- it 'returns HTML data' do
+ it "returns HTML data" do
get :usage_data, format: :html
- expect(response.body).to start_with('<span')
+ expect(response.body).to start_with("<span")
expect(response.status).to eq(200)
end
- it 'returns JSON data' do
+ it "returns JSON data" do
get :usage_data, format: :json
body = JSON.parse(response.body)
expect(body["version"]).to eq(Gitlab::VERSION)
- expect(body).to include('counts')
+ expect(body).to include("counts")
expect(response.status).to eq(200)
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
before do
sign_in(admin)
end
- it 'updates the password_authentication_enabled_for_git setting' do
- put :update, params: { application_setting: { password_authentication_enabled_for_git: "0" } }
+ it "updates the password_authentication_enabled_for_git setting" do
+ put :update, params: {application_setting: {password_authentication_enabled_for_git: "0"}}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.password_authentication_enabled_for_git).to eq(false)
end
- it 'updates the default_project_visibility for string value' do
- put :update, params: { application_setting: { default_project_visibility: "20" } }
+ it "updates the default_project_visibility for string value" do
+ put :update, params: {application_setting: {default_project_visibility: "20"}}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.default_project_visibility).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'update the restricted levels for string values' do
- put :update, params: { application_setting: { restricted_visibility_levels: %w[10 20] } }
+ it "update the restricted levels for string values" do
+ put :update, params: {application_setting: {restricted_visibility_levels: %w[10 20]}}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.restricted_visibility_levels).to eq([10, 20])
end
- it 'updates the restricted_visibility_levels when empty array is passed' do
- put :update, params: { application_setting: { restricted_visibility_levels: [""] } }
+ it "updates the restricted_visibility_levels when empty array is passed" do
+ put :update, params: {application_setting: {restricted_visibility_levels: [""]}}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.restricted_visibility_levels).to be_empty
end
- it 'updates the receive_max_input_size setting' do
- put :update, params: { application_setting: { receive_max_input_size: "1024" } }
+ it "updates the receive_max_input_size setting" do
+ put :update, params: {application_setting: {receive_max_input_size: "1024"}}
expect(response).to redirect_to(admin_application_settings_path)
expect(ApplicationSetting.current.receive_max_input_size).to eq(1024)
end
end
- describe 'PUT #reset_registration_token' do
+ describe "PUT #reset_registration_token" do
before do
sign_in(admin)
end
subject { put :reset_registration_token }
- it 'resets runner registration token' do
+ it "resets runner registration token" do
expect { subject }.to change { ApplicationSetting.current.runners_registration_token }
end
- it 'redirects the user to admin runners page' do
+ it "redirects the user to admin runners page" do
subject
expect(response).to redirect_to(admin_runners_path)
diff --git a/spec/controllers/admin/applications_controller_spec.rb b/spec/controllers/admin/applications_controller_spec.rb
index 7e1ce70dc7d..db750e77318 100644
--- a/spec/controllers/admin/applications_controller_spec.rb
+++ b/spec/controllers/admin/applications_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ApplicationsController do
let(:admin) { create(:admin) }
@@ -8,8 +8,8 @@ describe Admin::ApplicationsController do
sign_in(admin)
end
- describe 'GET #new' do
- it 'renders the application form' do
+ describe "GET #new" do
+ it "renders the application form" do
get :new
expect(response).to render_template :new
@@ -17,22 +17,22 @@ describe Admin::ApplicationsController do
end
end
- describe 'GET #edit' do
- it 'renders the application form' do
- get :edit, params: { id: application.id }
+ describe "GET #edit" do
+ it "renders the application form" do
+ get :edit, params: {id: application.id}
expect(response).to render_template :edit
expect(assigns[:scopes]).to be_kind_of(Doorkeeper::OAuth::Scopes)
end
end
- describe 'POST #create' do
- it 'creates the application' do
+ describe "POST #create" do
+ it "creates the application" do
create_params = attributes_for(:application, trusted: true)
- expect do
- post :create, params: { doorkeeper_application: create_params }
- end.to change { Doorkeeper::Application.count }.by(1)
+ expect {
+ post :create, params: {doorkeeper_application: create_params}
+ }.to change { Doorkeeper::Application.count }.by(1)
application = Doorkeeper::Application.last
@@ -40,28 +40,28 @@ describe Admin::ApplicationsController do
expect(application).to have_attributes(create_params.except(:uid, :owner_type))
end
- it 'renders the application form on errors' do
- expect do
- post :create, params: { doorkeeper_application: attributes_for(:application).merge(redirect_uri: nil) }
- end.not_to change { Doorkeeper::Application.count }
+ it "renders the application form on errors" do
+ expect {
+ post :create, params: {doorkeeper_application: attributes_for(:application).merge(redirect_uri: nil)}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to render_template :new
expect(assigns[:scopes]).to be_kind_of(Doorkeeper::OAuth::Scopes)
end
end
- describe 'PATCH #update' do
- it 'updates the application' do
- patch :update, params: { id: application.id, doorkeeper_application: { redirect_uri: 'http://example.com/', trusted: true } }
+ describe "PATCH #update" do
+ it "updates the application" do
+ patch :update, params: {id: application.id, doorkeeper_application: {redirect_uri: "http://example.com/", trusted: true}}
application.reload
expect(response).to redirect_to(admin_application_path(application))
- expect(application).to have_attributes(redirect_uri: 'http://example.com/', trusted: true)
+ expect(application).to have_attributes(redirect_uri: "http://example.com/", trusted: true)
end
- it 'renders the application form on errors' do
- patch :update, params: { id: application.id, doorkeeper_application: { redirect_uri: nil } }
+ it "renders the application form on errors" do
+ patch :update, params: {id: application.id, doorkeeper_application: {redirect_uri: nil}}
expect(response).to render_template :edit
expect(assigns[:scopes]).to be_kind_of(Doorkeeper::OAuth::Scopes)
diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb
index 6eb9f7867d5..f8fbb289332 100644
--- a/spec/controllers/admin/dashboard_controller_spec.rb
+++ b/spec/controllers/admin/dashboard_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::DashboardController do
- describe '#index' do
- context 'with pending_delete projects' do
+ describe "#index" do
+ context "with pending_delete projects" do
render_views
- it 'does not retrieve projects that are pending deletion' do
+ it "does not retrieve projects that are pending deletion" do
sign_in(create(:admin))
project = create(:project)
diff --git a/spec/controllers/admin/gitaly_servers_controller_spec.rb b/spec/controllers/admin/gitaly_servers_controller_spec.rb
index b7378aa37d0..c3db95d0667 100644
--- a/spec/controllers/admin/gitaly_servers_controller_spec.rb
+++ b/spec/controllers/admin/gitaly_servers_controller_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::GitalyServersController do
- describe '#index' do
+ describe "#index" do
before do
sign_in(create(:admin))
end
- it 'shows the gitaly servers page' do
+ it "shows the gitaly servers page" do
get :index
expect(response).to have_gitlab_http_status(200)
diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb
index 647fce0ecef..1c30961a835 100644
--- a/spec/controllers/admin/groups_controller_spec.rb
+++ b/spec/controllers/admin/groups_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::GroupsController do
let(:group) { create(:group) }
@@ -9,54 +9,54 @@ describe Admin::GroupsController do
sign_in(admin)
end
- describe 'DELETE #destroy' do
- it 'schedules a group destroy' do
+ describe "DELETE #destroy" do
+ it "schedules a group destroy" do
Sidekiq::Testing.fake! do
- expect { delete :destroy, params: { id: project.group.path } }.to change(GroupDestroyWorker.jobs, :size).by(1)
+ expect { delete :destroy, params: {id: project.group.path} }.to change(GroupDestroyWorker.jobs, :size).by(1)
end
end
- it 'redirects to the admin group path' do
- delete :destroy, params: { id: project.group.path }
+ it "redirects to the admin group path" do
+ delete :destroy, params: {id: project.group.path}
expect(response).to redirect_to(admin_groups_path)
end
end
- describe 'PUT #members_update' do
+ describe "PUT #members_update" do
let(:group_user) { create(:user) }
- it 'adds user to members' do
+ it "adds user to members" do
put :members_update, params: {
- id: group,
- user_ids: group_user.id,
- access_level: Gitlab::Access::GUEST
- }
+ id: group,
+ user_ids: group_user.id,
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'Users were successfully added.'
+ expect(response).to set_flash.to "Users were successfully added."
expect(response).to redirect_to(admin_group_path(group))
expect(group.users).to include group_user
end
- it 'can add unlimited members' do
+ it "can add unlimited members" do
put :members_update, params: {
- id: group,
- user_ids: 1.upto(1000).to_a.join(','),
- access_level: Gitlab::Access::GUEST
- }
+ id: group,
+ user_ids: 1.upto(1000).to_a.join(","),
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'Users were successfully added.'
+ expect(response).to set_flash.to "Users were successfully added."
expect(response).to redirect_to(admin_group_path(group))
end
- it 'adds no user to members' do
+ it "adds no user to members" do
put :members_update, params: {
- id: group,
- user_ids: '',
- access_level: Gitlab::Access::GUEST
- }
+ id: group,
+ user_ids: "",
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'No users specified.'
+ expect(response).to set_flash.to "No users specified."
expect(response).to redirect_to(admin_group_path(group))
expect(group.users).not_to include group_user
end
diff --git a/spec/controllers/admin/health_check_controller_spec.rb b/spec/controllers/admin/health_check_controller_spec.rb
index e13401fc06b..218b2d02d51 100644
--- a/spec/controllers/admin/health_check_controller_spec.rb
+++ b/spec/controllers/admin/health_check_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::HealthCheckController do
let(:admin) { create(:admin) }
@@ -7,8 +7,8 @@ describe Admin::HealthCheckController do
sign_in(admin)
end
- describe 'GET show' do
- it 'loads the health information' do
+ describe "GET show" do
+ it "loads the health information" do
get :show
expect(assigns[:errors]).not_to be_nil
diff --git a/spec/controllers/admin/hooks_controller_spec.rb b/spec/controllers/admin/hooks_controller_spec.rb
index 9bc58344e4e..c14b795284f 100644
--- a/spec/controllers/admin/hooks_controller_spec.rb
+++ b/spec/controllers/admin/hooks_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::HooksController do
let(:admin) { create(:admin) }
@@ -7,8 +7,8 @@ describe Admin::HooksController do
sign_in(admin)
end
- describe 'POST #create' do
- it 'sets all parameters' do
+ describe "POST #create" do
+ it "sets all parameters" do
hook_params = {
enable_ssl_verification: true,
token: "TEST TOKEN",
@@ -17,10 +17,10 @@ describe Admin::HooksController do
push_events: true,
tag_push_events: true,
repository_update_events: true,
- merge_requests_events: true
+ merge_requests_events: true,
}
- post :create, params: { hook: hook_params }
+ post :create, params: {hook: hook_params}
expect(response).to have_gitlab_http_status(302)
expect(SystemHook.all.size).to eq(1)
diff --git a/spec/controllers/admin/identities_controller_spec.rb b/spec/controllers/admin/identities_controller_spec.rb
index e5428c8ddeb..d030e4bd796 100644
--- a/spec/controllers/admin/identities_controller_spec.rb
+++ b/spec/controllers/admin/identities_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::IdentitiesController do
let(:admin) { create(:admin) }
@@ -7,23 +7,23 @@ describe Admin::IdentitiesController do
sign_in(admin)
end
- describe 'UPDATE identity' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
+ describe "UPDATE identity" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain", extern_uid: "uid=myuser,ou=people,dc=example,dc=com") }
- it 'repairs ldap blocks' do
+ it "repairs ldap blocks" do
expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute)
- put :update, params: { user_id: user.username, id: user.ldap_identity.id, identity: { provider: 'twitter' } }
+ put :update, params: {user_id: user.username, id: user.ldap_identity.id, identity: {provider: "twitter"}}
end
end
- describe 'DELETE identity' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain', extern_uid: 'uid=myuser,ou=people,dc=example,dc=com') }
+ describe "DELETE identity" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain", extern_uid: "uid=myuser,ou=people,dc=example,dc=com") }
- it 'repairs ldap blocks' do
+ it "repairs ldap blocks" do
expect_any_instance_of(RepairLdapBlockedUserService).to receive(:execute)
- delete :destroy, params: { user_id: user.username, id: user.ldap_identity.id }
+ delete :destroy, params: {user_id: user.username, id: user.ldap_identity.id}
end
end
end
diff --git a/spec/controllers/admin/impersonations_controller_spec.rb b/spec/controllers/admin/impersonations_controller_spec.rb
index 944680b3f42..13368084c01 100644
--- a/spec/controllers/admin/impersonations_controller_spec.rb
+++ b/spec/controllers/admin/impersonations_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ImpersonationsController do
let(:impersonator) { create(:admin) }
diff --git a/spec/controllers/admin/projects_controller_spec.rb b/spec/controllers/admin/projects_controller_spec.rb
index 8166657f674..e620e9c0765 100644
--- a/spec/controllers/admin/projects_controller_spec.rb
+++ b/spec/controllers/admin/projects_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ProjectsController do
let!(:project) { create(:project, :public) }
@@ -7,22 +7,22 @@ describe Admin::ProjectsController do
sign_in(create(:admin))
end
- describe 'GET /projects' do
+ describe "GET /projects" do
render_views
- it 'retrieves the project for the given visibility level' do
- get :index, params: { visibility_level: [Gitlab::VisibilityLevel::PUBLIC] }
+ it "retrieves the project for the given visibility level" do
+ get :index, params: {visibility_level: [Gitlab::VisibilityLevel::PUBLIC]}
expect(response.body).to match(project.name)
end
- it 'does not retrieve the project' do
- get :index, params: { visibility_level: [Gitlab::VisibilityLevel::INTERNAL] }
+ it "does not retrieve the project" do
+ get :index, params: {visibility_level: [Gitlab::VisibilityLevel::INTERNAL]}
expect(response.body).not_to match(project.name)
end
- it 'does not respond with projects pending deletion' do
+ it "does not respond with projects pending deletion" do
pending_delete_project = create(:project, pending_delete: true)
get :index
@@ -32,7 +32,7 @@ describe Admin::ProjectsController do
expect(response.body).to match(project.name)
end
- it 'does not have N+1 queries', :use_clean_rails_memory_store_caching, :request_store do
+ it "does not have N+1 queries", :use_clean_rails_memory_store_caching, :request_store do
get :index
control_count = ActiveRecord::QueryRecorder.new { get :index }.count
@@ -43,11 +43,11 @@ describe Admin::ProjectsController do
end
end
- describe 'GET /projects/:id' do
+ describe "GET /projects/:id" do
render_views
- it 'renders show page' do
- get :show, params: { namespace_id: project.namespace.path, id: project.path }
+ it "renders show page" do
+ get :show, params: {namespace_id: project.namespace.path, id: project.path}
expect(response).to have_gitlab_http_status(200)
expect(response.body).to match(project.name)
diff --git a/spec/controllers/admin/requests_profiles_controller_spec.rb b/spec/controllers/admin/requests_profiles_controller_spec.rb
index 10850cb4603..acdb7ac90a6 100644
--- a/spec/controllers/admin/requests_profiles_controller_spec.rb
+++ b/spec/controllers/admin/requests_profiles_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Admin::RequestsProfilesController do
set(:admin) { create(:admin) }
@@ -9,9 +9,9 @@ describe Admin::RequestsProfilesController do
sign_in(admin)
end
- describe '#show' do
+ describe "#show" do
let(:basename) { "profile_#{Time.now.to_i}.html" }
- let(:tmpdir) { Dir.mktmpdir('profiler-test') }
+ let(:tmpdir) { Dir.mktmpdir("profiler-test") }
let(:test_file) { File.join(tmpdir, basename) }
let(:profile) { Gitlab::RequestProfiler::Profile.new(basename) }
let(:sample_data) do
@@ -27,8 +27,8 @@ describe Admin::RequestsProfilesController do
end
before do
- stub_const('Gitlab::RequestProfiler::PROFILES_DIR', tmpdir)
- output = File.open(test_file, 'w')
+ stub_const("Gitlab::RequestProfiler::PROFILES_DIR", tmpdir)
+ output = File.open(test_file, "w")
output.write(sample_data)
output.close
end
@@ -37,8 +37,8 @@ describe Admin::RequestsProfilesController do
File.unlink(test_file)
end
- it 'loads an HTML profile' do
- get :show, params: { name: basename }
+ it "loads an HTML profile" do
+ get :show, params: {name: basename}
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(sample_data)
diff --git a/spec/controllers/admin/runners_controller_spec.rb b/spec/controllers/admin/runners_controller_spec.rb
index 82e24213408..2d7a3c48833 100644
--- a/spec/controllers/admin/runners_controller_spec.rb
+++ b/spec/controllers/admin/runners_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::RunnersController do
let!(:runner) { create(:ci_runner) }
@@ -7,16 +7,16 @@ describe Admin::RunnersController do
sign_in(create(:admin))
end
- describe '#index' do
+ describe "#index" do
render_views
- it 'lists all runners' do
+ it "lists all runners" do
get :index
expect(response).to have_gitlab_http_status(200)
end
- it 'avoids N+1 queries', :request_store do
+ it "avoids N+1 queries", :request_store do
get :index
control_count = ActiveRecord::QueryRecorder.new { get :index }.count
@@ -27,32 +27,32 @@ describe Admin::RunnersController do
expect { get :index }.not_to exceed_query_limit(control_count + 1)
expect(response).to have_gitlab_http_status(200)
- expect(response.body).to have_content('tag1')
- expect(response.body).to have_content('tag2')
+ expect(response.body).to have_content("tag1")
+ expect(response.body).to have_content("tag2")
end
end
- describe '#show' do
- it 'shows a particular runner' do
- get :show, params: { id: runner.id }
+ describe "#show" do
+ it "shows a particular runner" do
+ get :show, params: {id: runner.id}
expect(response).to have_gitlab_http_status(200)
end
- it 'shows 404 for unknown runner' do
- get :show, params: { id: 0 }
+ it "shows 404 for unknown runner" do
+ get :show, params: {id: 0}
expect(response).to have_gitlab_http_status(404)
end
end
- describe '#update' do
- it 'updates the runner and ticks the queue' do
+ describe "#update" do
+ it "updates the runner and ticks the queue" do
new_desc = runner.description.swapcase
- expect do
- post :update, params: { id: runner.id, runner: { description: new_desc } }
- end.to change { runner.ensure_runner_queue_value }
+ expect {
+ post :update, params: {id: runner.id, runner: {description: new_desc}}
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -61,22 +61,22 @@ describe Admin::RunnersController do
end
end
- describe '#destroy' do
- it 'destroys the runner' do
- delete :destroy, params: { id: runner.id }
+ describe "#destroy" do
+ it "destroys the runner" do
+ delete :destroy, params: {id: runner.id}
expect(response).to have_gitlab_http_status(302)
expect(Ci::Runner.find_by(id: runner.id)).to be_nil
end
end
- describe '#resume' do
- it 'marks the runner as active and ticks the queue' do
+ describe "#resume" do
+ it "marks the runner as active and ticks the queue" do
runner.update(active: false)
- expect do
- post :resume, params: { id: runner.id }
- end.to change { runner.ensure_runner_queue_value }
+ expect {
+ post :resume, params: {id: runner.id}
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -85,13 +85,13 @@ describe Admin::RunnersController do
end
end
- describe '#pause' do
- it 'marks the runner as inactive and ticks the queue' do
+ describe "#pause" do
+ it "marks the runner as inactive and ticks the queue" do
runner.update(active: true)
- expect do
- post :pause, params: { id: runner.id }
- end.to change { runner.ensure_runner_queue_value }
+ expect {
+ post :pause, params: {id: runner.id}
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
diff --git a/spec/controllers/admin/services_controller_spec.rb b/spec/controllers/admin/services_controller_spec.rb
index ec161b92245..da5387417c0 100644
--- a/spec/controllers/admin/services_controller_spec.rb
+++ b/spec/controllers/admin/services_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ServicesController do
let(:admin) { create(:admin) }
@@ -7,18 +7,18 @@ describe Admin::ServicesController do
sign_in(admin)
end
- describe 'GET #edit' do
+ describe "GET #edit" do
let!(:project) { create(:project) }
Service.available_services_names.each do |service_name|
- context "#{service_name}" do
+ context service_name.to_s do
let!(:service) do
service_template = "#{service_name}_service".camelize.constantize
service_template.where(template: true).first_or_create
end
- it 'successfully displays the template' do
- get :edit, params: { id: service.id }
+ it "successfully displays the template" do
+ get :edit, params: {id: service.id}
expect(response).to have_gitlab_http_status(200)
end
@@ -34,25 +34,25 @@ describe Admin::ServicesController do
active: false,
template: true,
properties: {
- project_url: 'http://abc',
- issues_url: 'http://abc',
- new_issue_url: 'http://abc'
+ project_url: "http://abc",
+ issues_url: "http://abc",
+ new_issue_url: "http://abc",
}
)
end
- it 'calls the propagation worker when service is active' do
+ it "calls the propagation worker when service is active" do
expect(PropagateServiceTemplateWorker).to receive(:perform_async).with(service.id)
- put :update, params: { id: service.id, service: { active: true } }
+ put :update, params: {id: service.id, service: {active: true}}
expect(response).to have_gitlab_http_status(302)
end
- it 'does not call the propagation worker when service is not active' do
+ it "does not call the propagation worker when service is not active" do
expect(PropagateServiceTemplateWorker).not_to receive(:perform_async)
- put :update, params: { id: service.id, service: { properties: {} } }
+ put :update, params: {id: service.id, service: {properties: {}}}
expect(response).to have_gitlab_http_status(302)
end
diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb
index 2b946ec1c68..1dd457febb4 100644
--- a/spec/controllers/admin/spam_logs_controller_spec.rb
+++ b/spec/controllers/admin/spam_logs_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::SpamLogsController do
let(:admin) { create(:admin) }
@@ -10,23 +10,23 @@ describe Admin::SpamLogsController do
sign_in(admin)
end
- describe '#index' do
- it 'lists all spam logs' do
+ describe "#index" do
+ it "lists all spam logs" do
get :index
expect(response).to have_gitlab_http_status(200)
end
end
- describe '#destroy' do
- it 'removes only the spam log when removing log' do
- expect { delete :destroy, params: { id: first_spam.id } }.to change { SpamLog.count }.by(-1)
+ describe "#destroy" do
+ it "removes only the spam log when removing log" do
+ expect { delete :destroy, params: {id: first_spam.id} }.to change { SpamLog.count }.by(-1)
expect(User.find(user.id)).to be_truthy
expect(response).to have_gitlab_http_status(200)
end
- it 'removes user and his spam logs when removing the user' do
- delete :destroy, params: { id: first_spam.id, remove_user: true }
+ it "removes user and his spam logs when removing the user" do
+ delete :destroy, params: {id: first_spam.id, remove_user: true}
expect(flash[:notice]).to eq "User #{user.username} was successfully removed."
expect(response).to have_gitlab_http_status(302)
@@ -35,12 +35,12 @@ describe Admin::SpamLogsController do
end
end
- describe '#mark_as_ham' do
+ describe "#mark_as_ham" do
before do
allow_any_instance_of(AkismetService).to receive(:submit_ham).and_return(true)
end
- it 'submits the log as ham' do
- post :mark_as_ham, params: { id: first_spam.id }
+ it "submits the log as ham" do
+ post :mark_as_ham, params: {id: first_spam.id}
expect(response).to have_gitlab_http_status(302)
expect(SpamLog.find(first_spam.id).submitted_as_ham).to be_truthy
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index cb24a6ef142..6f626e689de 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::UsersController do
let(:user) { create(:user) }
@@ -8,32 +8,32 @@ describe Admin::UsersController do
sign_in(admin)
end
- describe 'GET #index' do
- it 'retrieves all users' do
+ describe "GET #index" do
+ it "retrieves all users" do
get :index
expect(assigns(:users)).to match_array([user, admin])
end
- it 'filters by admins' do
- get :index, params: { filter: 'admins' }
+ it "filters by admins" do
+ get :index, params: {filter: "admins"}
expect(assigns(:users)).to eq([admin])
end
end
- describe 'GET :id' do
- it 'finds a user case-insensitively' do
- user = create(:user, username: 'CaseSensitive')
+ describe "GET :id" do
+ it "finds a user case-insensitively" do
+ user = create(:user, username: "CaseSensitive")
- get :show, params: { id: user.username.downcase }
+ get :show, params: {id: user.username.downcase}
expect(response).to be_redirect
expect(response.location).to end_with(user.username)
end
end
- describe 'DELETE #user with projects' do
+ describe "DELETE #user with projects" do
let(:project) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, author: user) }
@@ -41,16 +41,16 @@ describe Admin::UsersController do
project.add_developer(user)
end
- it 'deletes user and ghosts their contributions' do
- delete :destroy, params: { id: user.username }, format: :json
+ it "deletes user and ghosts their contributions" do
+ delete :destroy, params: {id: user.username}, format: :json
expect(response).to have_gitlab_http_status(200)
expect(User.exists?(user.id)).to be_falsy
expect(issue.reload.author).to be_ghost
end
- it 'deletes the user and their contributions when hard delete is specified' do
- delete :destroy, params: { id: user.username, hard_delete: true }, format: :json
+ it "deletes the user and their contributions when hard delete is specified" do
+ delete :destroy, params: {id: user.username, hard_delete: true}, format: :json
expect(response).to have_gitlab_http_status(200)
expect(User.exists?(user.id)).to be_falsy
@@ -58,187 +58,187 @@ describe Admin::UsersController do
end
end
- describe 'PUT block/:id' do
- it 'blocks user' do
- put :block, params: { id: user.username }
+ describe "PUT block/:id" do
+ it "blocks user" do
+ put :block, params: {id: user.username}
user.reload
expect(user.blocked?).to be_truthy
- expect(flash[:notice]).to eq 'Successfully blocked'
+ expect(flash[:notice]).to eq "Successfully blocked"
end
end
- describe 'PUT unblock/:id' do
- context 'ldap blocked users' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain') }
+ describe "PUT unblock/:id" do
+ context "ldap blocked users" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain") }
before do
user.ldap_block
end
- it 'does not unblock user' do
- put :unblock, params: { id: user.username }
+ it "does not unblock user" do
+ put :unblock, params: {id: user.username}
user.reload
expect(user.blocked?).to be_truthy
- expect(flash[:alert]).to eq 'This user cannot be unlocked manually from GitLab'
+ expect(flash[:alert]).to eq "This user cannot be unlocked manually from GitLab"
end
end
- context 'manually blocked users' do
+ context "manually blocked users" do
before do
user.block
end
- it 'unblocks user' do
- put :unblock, params: { id: user.username }
+ it "unblocks user" do
+ put :unblock, params: {id: user.username}
user.reload
expect(user.blocked?).to be_falsey
- expect(flash[:notice]).to eq 'Successfully unblocked'
+ expect(flash[:notice]).to eq "Successfully unblocked"
end
end
end
- describe 'PUT unlock/:id' do
+ describe "PUT unlock/:id" do
before do
request.env["HTTP_REFERER"] = "/"
user.lock_access!
end
- it 'unlocks user' do
- put :unlock, params: { id: user.username }
+ it "unlocks user" do
+ put :unlock, params: {id: user.username}
user.reload
expect(user.access_locked?).to be_falsey
end
end
- describe 'PUT confirm/:id' do
+ describe "PUT confirm/:id" do
let(:user) { create(:user, confirmed_at: nil) }
before do
request.env["HTTP_REFERER"] = "/"
end
- it 'confirms user' do
- put :confirm, params: { id: user.username }
+ it "confirms user" do
+ put :confirm, params: {id: user.username}
user.reload
expect(user.confirmed?).to be_truthy
end
end
- describe 'PATCH disable_two_factor' do
- it 'disables 2FA for the user' do
+ describe "PATCH disable_two_factor" do
+ it "disables 2FA for the user" do
expect(user).to receive(:disable_two_factor!)
allow(subject).to receive(:user).and_return(user)
go
end
- it 'redirects back' do
+ it "redirects back" do
go
expect(response).to redirect_to(admin_user_path(user))
end
- it 'displays an alert' do
+ it "displays an alert" do
go
expect(flash[:notice])
- .to eq 'Two-factor Authentication has been disabled for this user'
+ .to eq "Two-factor Authentication has been disabled for this user"
end
def go
- patch :disable_two_factor, params: { id: user.to_param }
+ patch :disable_two_factor, params: {id: user.to_param}
end
end
- describe 'POST create' do
- it 'creates the user' do
- expect { post :create, params: { user: attributes_for(:user) } }.to change { User.count }.by(1)
+ describe "POST create" do
+ it "creates the user" do
+ expect { post :create, params: {user: attributes_for(:user)} }.to change { User.count }.by(1)
end
- it 'shows only one error message for an invalid email' do
- post :create, params: { user: attributes_for(:user, email: 'bogus') }
+ it "shows only one error message for an invalid email" do
+ post :create, params: {user: attributes_for(:user, email: "bogus")}
expect(assigns[:user].errors).to contain_exactly("Email is invalid")
end
end
- describe 'POST update' do
- context 'when the password has changed' do
+ describe "POST update" do
+ context "when the password has changed" do
def update_password(user, password, password_confirmation = nil)
params = {
id: user.to_param,
user: {
password: password,
- password_confirmation: password_confirmation || password
- }
+ password_confirmation: password_confirmation || password,
+ },
}
post :update, params: params
end
- context 'when the admin changes his own password' do
- it 'updates the password' do
- expect { update_password(admin, 'AValidPassword1') }
+ context "when the admin changes his own password" do
+ it "updates the password" do
+ expect { update_password(admin, "AValidPassword1") }
.to change { admin.reload.encrypted_password }
end
- it 'does not set the new password to expire immediately' do
- expect { update_password(admin, 'AValidPassword1') }
+ it "does not set the new password to expire immediately" do
+ expect { update_password(admin, "AValidPassword1") }
.not_to change { admin.reload.password_expires_at }
end
end
- context 'when the new password is valid' do
- it 'redirects to the user' do
- update_password(user, 'AValidPassword1')
+ context "when the new password is valid" do
+ it "redirects to the user" do
+ update_password(user, "AValidPassword1")
expect(response).to redirect_to(admin_user_path(user))
end
- it 'updates the password' do
- expect { update_password(user, 'AValidPassword1') }
+ it "updates the password" do
+ expect { update_password(user, "AValidPassword1") }
.to change { user.reload.encrypted_password }
end
- it 'sets the new password to expire immediately' do
- expect { update_password(user, 'AValidPassword1') }
+ it "sets the new password to expire immediately" do
+ expect { update_password(user, "AValidPassword1") }
.to change { user.reload.password_expires_at }.to be_within(2.seconds).of(Time.now)
end
end
- context 'when the new password is invalid' do
- it 'shows the edit page again' do
- update_password(user, 'invalid')
+ context "when the new password is invalid" do
+ it "shows the edit page again" do
+ update_password(user, "invalid")
expect(response).to render_template(:edit)
end
- it 'returns the error message' do
- update_password(user, 'invalid')
+ it "returns the error message" do
+ update_password(user, "invalid")
expect(assigns[:user].errors).to contain_exactly(a_string_matching(/too short/))
end
- it 'does not update the password' do
- expect { update_password(user, 'invalid') }
+ it "does not update the password" do
+ expect { update_password(user, "invalid") }
.not_to change { user.reload.encrypted_password }
end
end
- context 'when the new password does not match the password confirmation' do
- it 'shows the edit page again' do
- update_password(user, 'AValidPassword1', 'AValidPassword2')
+ context "when the new password does not match the password confirmation" do
+ it "shows the edit page again" do
+ update_password(user, "AValidPassword1", "AValidPassword2")
expect(response).to render_template(:edit)
end
- it 'returns the error message' do
- update_password(user, 'AValidPassword1', 'AValidPassword2')
+ it "returns the error message" do
+ update_password(user, "AValidPassword1", "AValidPassword2")
expect(assigns[:user].errors).to contain_exactly(a_string_matching(/doesn't match/))
end
- it 'does not update the password' do
- expect { update_password(user, 'AValidPassword1', 'AValidPassword2') }
+ it "does not update the password" do
+ expect { update_password(user, "AValidPassword1", "AValidPassword2") }
.not_to change { user.reload.encrypted_password }
end
end
@@ -252,13 +252,13 @@ describe Admin::UsersController do
end
it "shows a notice" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(flash[:alert]).to eq("You cannot impersonate a blocked user")
end
it "doesn't sign us in as the user" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(warden.user).to eq(admin)
end
@@ -266,25 +266,25 @@ describe Admin::UsersController do
context "when the user is not blocked" do
it "stores the impersonator in the session" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(session[:impersonator_id]).to eq(admin.id)
end
it "signs us in as the user" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(warden.user).to eq(user)
end
it "redirects to root" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(response).to redirect_to(root_path)
end
it "shows a notice" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(flash[:alert]).to eq("You are now impersonating #{user.username}")
end
@@ -296,7 +296,7 @@ describe Admin::UsersController do
end
it "shows error page" do
- post :impersonate, params: { id: user.username }
+ post :impersonate, params: {id: user.username}
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index dca74bd5f84..851c4b0144c 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -1,19 +1,18 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe ApplicationController do
include TermsHelper
let(:user) { create(:user) }
- describe '#check_password_expiration' do
+ describe "#check_password_expiration" do
let(:controller) { described_class.new }
before do
allow(controller).to receive(:session).and_return({})
end
- it 'redirects 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
@@ -24,7 +23,7 @@ describe ApplicationController do
controller.send(:check_password_expiration)
end
- it 'does 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
@@ -34,7 +33,7 @@ describe ApplicationController do
controller.send(:check_password_expiration)
end
- it 'does 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)
@@ -44,7 +43,7 @@ describe ApplicationController do
controller.send(:check_password_expiration)
end
- it 'does not redirect if the user is over their password expiry but password authentication is disabled for the web interface' do
+ it "does not redirect if the user is over their password expiry but password authentication is disabled for the web interface" do
stub_application_setting(password_authentication_enabled_for_web: false)
stub_application_setting(password_authentication_enabled_for_git: false)
user.password_expires_at = Time.new(2002)
@@ -56,7 +55,7 @@ describe ApplicationController do
end
end
- describe '#add_gon_variables' do
+ describe "#add_gon_variables" do
before do
Gon.clear
sign_in user
@@ -70,74 +69,74 @@ describe ApplicationController do
end
end
- shared_examples 'setting gon variables' do
- it 'sets gon variables' do
+ shared_examples "setting gon variables" do
+ it "sets gon variables" do
get :index, format: format
expect(json_response.size).not_to be_zero
end
end
- shared_examples 'not setting gon variables' do
- it 'does not set gon variables' do
+ shared_examples "not setting gon variables" do
+ it "does not set gon variables" do
get :index, format: format
expect(json_response.size).to be_zero
end
end
- context 'with html format' do
+ context "with html format" do
let(:format) { :html }
- it_behaves_like 'setting gon variables'
+ it_behaves_like "setting gon variables"
- context 'for peek requests' do
+ context "for peek requests" do
before do
- request.path = '/-/peek'
+ request.path = "/-/peek"
end
- it_behaves_like 'not setting gon variables'
+ it_behaves_like "not setting gon variables"
end
end
- context 'with json format' do
+ context "with json format" do
let(:format) { :json }
- it_behaves_like 'not setting gon variables'
+ it_behaves_like "not setting gon variables"
end
end
- describe 'session expiration' do
+ describe "session expiration" do
controller(described_class) do
# The anonymous controller will report 401 and fail to run any actions.
# Normally, GitLab will just redirect you to sign in.
skip_before_action :authenticate_user!, only: :index
def index
- render html: 'authenticated'
+ render html: "authenticated"
end
end
- context 'authenticated user' do
- it 'does not set the expire_after option' do
+ context "authenticated user" do
+ it "does not set the expire_after option" do
sign_in(create(:user))
get :index
- expect(request.env['rack.session.options'][:expire_after]).to be_nil
+ expect(request.env["rack.session.options"][:expire_after]).to be_nil
end
end
- context 'unauthenticated user' do
- it 'sets the expire_after option' do
+ context "unauthenticated user" do
+ it "sets the expire_after option" do
get :index
- expect(request.env['rack.session.options'][:expire_after]).to eq(Settings.gitlab['unauthenticated_session_expire_delay'])
+ expect(request.env["rack.session.options"][:expire_after]).to eq(Settings.gitlab["unauthenticated_session_expire_delay"])
end
end
end
- describe 'response format' do
+ describe "response format" do
controller(described_class) do
def index
respond_to do |format|
@@ -152,18 +151,18 @@ describe ApplicationController do
sign_in user
end
- context 'when format is handled' do
+ context "when format is handled" do
let(:requested_format) { :json }
- it 'returns 200 response' do
+ it "returns 200 response" do
get :index, format: requested_format
expect(response).to have_gitlab_http_status 200
end
end
- context 'when format is not handled' do
- it 'returns 404 response' do
+ context "when format is not handled" do
+ it "returns 404 response" do
get :index
expect(response).to have_gitlab_http_status 404
@@ -171,48 +170,48 @@ describe ApplicationController do
end
end
- describe '#route_not_found' do
- it 'renders 404 if authenticated' do
+ describe "#route_not_found" do
+ it "renders 404 if authenticated" do
allow(controller).to receive(:current_user).and_return(user)
expect(controller).to receive(:not_found)
controller.send(:route_not_found)
end
- it 'does redirect to login page via authenticate_user! if not authenticated' do
+ it "does redirect to login page via authenticate_user! if not authenticated" do
allow(controller).to receive(:current_user).and_return(nil)
expect(controller).to receive(:authenticate_user!)
controller.send(:route_not_found)
end
end
- describe '#set_page_title_header' do
+ describe "#set_page_title_header" do
let(:controller) { described_class.new }
- it 'URI encodes UTF-8 characters in the title' do
+ it "URI encodes UTF-8 characters in the title" do
response = double(headers: {})
- allow_any_instance_of(PageLayoutHelper).to receive(:page_title).and_return('€100 · GitLab')
+ allow_any_instance_of(PageLayoutHelper).to receive(:page_title).and_return("€100 · GitLab")
allow(controller).to receive(:response).and_return(response)
controller.send(:set_page_title_header)
- expect(response.headers['Page-Title']).to eq('%E2%82%AC100%20%C2%B7%20GitLab')
+ expect(response.headers["Page-Title"]).to eq("%E2%82%AC100%20%C2%B7%20GitLab")
end
end
- context 'two-factor authentication' do
+ context "two-factor authentication" do
let(:controller) { described_class.new }
- describe '#check_two_factor_requirement' do
+ describe "#check_two_factor_requirement" do
subject { controller.send :check_two_factor_requirement }
- it 'does not redirect if 2FA is not required' do
+ it "does not redirect if 2FA is not required" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(false)
expect(controller).not_to receive(:redirect_to)
subject
end
- it 'does not redirect if user is not logged in' do
+ it "does not redirect if user is not logged in" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(controller).to receive(:current_user).and_return(nil)
expect(controller).not_to receive(:redirect_to)
@@ -220,7 +219,7 @@ describe ApplicationController do
subject
end
- it 'does not redirect if user has 2FA enabled' do
+ it "does not redirect if user has 2FA enabled" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(controller).to receive(:current_user).twice.and_return(user)
allow(user).to receive(:two_factor_enabled?).and_return(true)
@@ -229,7 +228,7 @@ describe ApplicationController do
subject
end
- it 'does not redirect if 2FA setup can be skipped' do
+ it "does not redirect if 2FA setup can be skipped" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(controller).to receive(:current_user).twice.and_return(user)
allow(user).to receive(:two_factor_enabled?).and_return(false)
@@ -239,7 +238,7 @@ describe ApplicationController do
subject
end
- it 'redirects to 2FA setup otherwise' do
+ it "redirects to 2FA setup otherwise" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(controller).to receive(:current_user).twice.and_return(user)
allow(user).to receive(:two_factor_enabled?).and_return(false)
@@ -251,23 +250,23 @@ describe ApplicationController do
end
end
- describe '#two_factor_authentication_required?' do
+ describe "#two_factor_authentication_required?" do
subject { controller.send :two_factor_authentication_required? }
- it 'returns false if no 2FA requirement is present' do
+ it "returns false if no 2FA requirement is present" do
allow(controller).to receive(:current_user).and_return(nil)
expect(subject).to be_falsey
end
- it 'returns true if a 2FA requirement is set in the application settings' do
+ it "returns true if a 2FA requirement is set in the application settings" do
stub_application_setting require_two_factor_authentication: true
allow(controller).to receive(:current_user).and_return(nil)
expect(subject).to be_truthy
end
- it 'returns true if a 2FA requirement is set on the user' do
+ it "returns true if a 2FA requirement is set on the user" do
user.require_two_factor_authentication_from_group = true
allow(controller).to receive(:current_user).and_return(user)
@@ -275,27 +274,27 @@ describe ApplicationController do
end
end
- describe '#two_factor_grace_period' do
+ describe "#two_factor_grace_period" do
subject { controller.send :two_factor_grace_period }
- it 'returns the grace period from the application settings' do
+ it "returns the grace period from the application settings" do
stub_application_setting two_factor_grace_period: 23
allow(controller).to receive(:current_user).and_return(nil)
expect(subject).to eq 23
end
- context 'with a 2FA requirement set on the user' do
+ context "with a 2FA requirement set on the user" do
let(:user) { create :user, require_two_factor_authentication_from_group: true, two_factor_grace_period: 23 }
- it 'returns the user grace period if lower than the application grace period' do
+ it "returns the user grace period if lower than the application grace period" do
stub_application_setting two_factor_grace_period: 24
allow(controller).to receive(:current_user).and_return(user)
expect(subject).to eq 23
end
- it 'returns the application grace period if lower than the user grace period' do
+ it "returns the application grace period if lower than the user grace period" do
stub_application_setting two_factor_grace_period: 22
allow(controller).to receive(:current_user).and_return(user)
@@ -304,27 +303,27 @@ describe ApplicationController do
end
end
- describe '#two_factor_grace_period_expired?' do
+ describe "#two_factor_grace_period_expired?" do
subject { controller.send :two_factor_grace_period_expired? }
before do
allow(controller).to receive(:current_user).and_return(user)
end
- it 'returns false if the user has not started their grace period yet' do
+ it "returns false if the user has not started their grace period yet" do
expect(subject).to be_falsey
end
- context 'with grace period started' do
+ context "with grace period started" do
let(:user) { create :user, otp_grace_period_started_at: 2.hours.ago }
- it 'returns true if the grace period has expired' do
+ it "returns true if the grace period has expired" do
allow(controller).to receive(:two_factor_grace_period).and_return(1)
expect(subject).to be_truthy
end
- it 'returns false if the grace period is still active' do
+ it "returns false if the grace period is still active" do
allow(controller).to receive(:two_factor_grace_period).and_return(3)
expect(subject).to be_falsey
@@ -332,27 +331,27 @@ describe ApplicationController do
end
end
- describe '#two_factor_skippable' do
+ describe "#two_factor_skippable" do
subject { controller.send :two_factor_skippable? }
before do
allow(controller).to receive(:current_user).and_return(user)
end
- it 'returns false if 2FA is not required' do
+ it "returns false if 2FA is not required" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(false)
expect(subject).to be_falsey
end
- it 'returns false if the user has already enabled 2FA' do
+ it "returns false if the user has already enabled 2FA" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(user).to receive(:two_factor_enabled?).and_return(true)
expect(subject).to be_falsey
end
- it 'returns false if the 2FA grace period has expired' do
+ it "returns false if the 2FA grace period has expired" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(user).to receive(:two_factor_enabled?).and_return(false)
allow(controller).to receive(:two_factor_grace_period_expired?).and_return(true)
@@ -360,7 +359,7 @@ describe ApplicationController do
expect(subject).to be_falsey
end
- it 'returns true otherwise' do
+ it "returns true otherwise" do
allow(controller).to receive(:two_factor_authentication_required?).and_return(true)
allow(user).to receive(:two_factor_enabled?).and_return(false)
allow(controller).to receive(:two_factor_grace_period_expired?).and_return(false)
@@ -369,27 +368,27 @@ describe ApplicationController do
end
end
- describe '#skip_two_factor?' do
+ describe "#skip_two_factor?" do
subject { controller.send :skip_two_factor? }
- it 'returns false if 2FA setup was not skipped' do
+ it "returns false if 2FA setup was not skipped" do
allow(controller).to receive(:session).and_return({})
expect(subject).to be_falsey
end
- context 'with 2FA setup skipped' do
+ context "with 2FA setup skipped" do
before do
- allow(controller).to receive(:session).and_return({ skip_two_factor: 2.hours.from_now })
+ allow(controller).to receive(:session).and_return({skip_two_factor: 2.hours.from_now})
end
- it 'returns false if the grace period has expired' do
+ it "returns false if the grace period has expired" do
Timecop.freeze(3.hours.from_now) do
expect(subject).to be_falsey
end
end
- it 'returns true if the grace period is still active' do
+ it "returns true if the grace period is still active" do
Timecop.freeze(1.hour.from_now) do
expect(subject).to be_truthy
end
@@ -398,19 +397,19 @@ describe ApplicationController do
end
end
- context 'terms' do
+ context "terms" do
controller(described_class) do
def index
- render html: 'authenticated'
+ render html: "authenticated"
end
end
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in user
end
- it 'does not query more when terms are enforced' do
+ it "does not query more when terms are enforced" do
control = ActiveRecord::QueryRecorder.new { get :index }
enforce_terms
@@ -418,18 +417,18 @@ describe ApplicationController do
expect { get :index }.not_to exceed_query_limit(control)
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- it 'redirects if the user did not accept the terms' do
+ it "redirects if the user did not accept the terms" do
get :index
expect(response).to have_gitlab_http_status(302)
end
- it 'does not redirect when the user accepted terms' do
+ it "does not redirect when the user accepted terms" do
accept_terms(user)
get :index
@@ -439,12 +438,12 @@ describe ApplicationController do
end
end
- describe '#append_info_to_payload' do
+ describe "#append_info_to_payload" do
controller(described_class) do
attr_reader :last_payload
def index
- render html: 'authenticated'
+ render html: "authenticated"
end
def append_info_to_payload(payload)
@@ -454,57 +453,57 @@ describe ApplicationController do
end
end
- it 'does not log errors with a 200 response' do
+ it "does not log errors with a 200 response" do
get :index
- expect(controller.last_payload.has_key?(:response)).to be_falsey
+ expect(controller.last_payload.key?(:response)).to be_falsey
end
- it 'does log correlation id' do
- Gitlab::CorrelationId.use_id('new-id') do
+ it "does log correlation id" do
+ Gitlab::CorrelationId.use_id("new-id") do
get :index
end
- expect(controller.last_payload).to include('correlation_id' => 'new-id')
+ expect(controller.last_payload).to include("correlation_id" => "new-id")
end
- context '422 errors' do
- it 'logs a response with a string' do
- response = spy(ActionDispatch::Response, status: 422, body: 'Hello world', content_type: 'application/json', cookies: {})
+ context "422 errors" do
+ it "logs a response with a string" do
+ response = spy(ActionDispatch::Response, status: 422, body: "Hello world", content_type: "application/json", cookies: {})
allow(controller).to receive(:response).and_return(response)
get :index
- expect(controller.last_payload[:response]).to eq('Hello world')
+ expect(controller.last_payload[:response]).to eq("Hello world")
end
- it 'logs a response with an array' do
- body = ['I want', 'my hat back']
- response = spy(ActionDispatch::Response, status: 422, body: body, content_type: 'application/json', cookies: {})
+ it "logs a response with an array" do
+ body = ["I want", "my hat back"]
+ response = spy(ActionDispatch::Response, status: 422, body: body, content_type: "application/json", cookies: {})
allow(controller).to receive(:response).and_return(response)
get :index
expect(controller.last_payload[:response]).to eq(body)
end
- it 'does not log a string with an empty body' do
- response = spy(ActionDispatch::Response, status: 422, body: nil, content_type: 'application/json', cookies: {})
+ it "does not log a string with an empty body" do
+ response = spy(ActionDispatch::Response, status: 422, body: nil, content_type: "application/json", cookies: {})
allow(controller).to receive(:response).and_return(response)
get :index
- expect(controller.last_payload.has_key?(:response)).to be_falsey
+ expect(controller.last_payload.key?(:response)).to be_falsey
end
- it 'does not log an HTML body' do
- response = spy(ActionDispatch::Response, status: 422, body: 'This is a test', content_type: 'application/html', cookies: {})
+ it "does not log an HTML body" do
+ response = spy(ActionDispatch::Response, status: 422, body: "This is a test", content_type: "application/html", cookies: {})
allow(controller).to receive(:response).and_return(response)
get :index
- expect(controller.last_payload.has_key?(:response)).to be_falsey
+ expect(controller.last_payload.key?(:response)).to be_falsey
end
end
end
- describe '#access_denied' do
+ describe "#access_denied" do
controller(described_class) do
def index
access_denied!(params[:message], params[:status])
@@ -515,31 +514,31 @@ describe ApplicationController do
sign_in user
end
- it 'renders a 404 without a message' do
+ it "renders a 404 without a message" do
get :index
expect(response).to have_gitlab_http_status(404)
- expect(response).to render_template('errors/not_found')
+ expect(response).to render_template("errors/not_found")
end
- it 'renders a 403 when a message is passed to access denied' do
- get :index, params: { message: 'None shall pass' }
+ it "renders a 403 when a message is passed to access denied" do
+ get :index, params: {message: "None shall pass"}
expect(response).to have_gitlab_http_status(403)
- expect(response).to render_template('errors/access_denied')
+ expect(response).to render_template("errors/access_denied")
end
- it 'renders a status passed to access denied' do
- get :index, params: { status: 401 }
+ it "renders a status passed to access denied" do
+ get :index, params: {status: 401}
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when invalid UTF-8 parameters are received' do
+ context "when invalid UTF-8 parameters are received" do
controller(described_class) do
def index
- params[:text].split(' ')
+ params[:text].split(" ")
render json: :ok
end
@@ -549,121 +548,121 @@ describe ApplicationController do
sign_in user
end
- context 'html' do
- subject { get :index, params: { text: "hi \255" } }
+ context "html" do
+ subject { get :index, params: {text: "hi \255"} }
- it 'renders 412' do
+ it "renders 412" do
expect { subject }.to raise_error(ActionController::BadRequest)
end
end
- context 'js' do
- subject { get :index, format: :js, params: { text: "hi \255" } }
+ context "js" do
+ subject { get :index, format: :js, params: {text: "hi \255"} }
- it 'renders 412' do
+ it "renders 412" do
expect { subject }.to raise_error(ActionController::BadRequest)
end
end
end
- context 'X-GitLab-Custom-Error header' do
+ context "X-GitLab-Custom-Error header" do
before do
sign_in user
end
- context 'given a 422 error page' do
+ context "given a 422 error page" do
controller do
def index
- render 'errors/omniauth_error', layout: 'errors', status: 422
+ render "errors/omniauth_error", layout: "errors", status: 422
end
end
- it 'sets a custom header' do
+ it "sets a custom header" do
get :index
- expect(response.headers['X-GitLab-Custom-Error']).to eq '1'
+ expect(response.headers["X-GitLab-Custom-Error"]).to eq "1"
end
end
- context 'given a 500 error page' do
+ context "given a 500 error page" do
controller do
def index
- render 'errors/omniauth_error', layout: 'errors', status: 500
+ render "errors/omniauth_error", layout: "errors", status: 500
end
end
- it 'sets a custom header' do
+ it "sets a custom header" do
get :index
- expect(response.headers['X-GitLab-Custom-Error']).to eq '1'
+ expect(response.headers["X-GitLab-Custom-Error"]).to eq "1"
end
end
- context 'given a 200 success page' do
+ context "given a 200 success page" do
controller do
def index
- render 'errors/omniauth_error', layout: 'errors', status: 200
+ render "errors/omniauth_error", layout: "errors", status: 200
end
end
- it 'does not set a custom header' do
+ it "does not set a custom header" do
get :index
- expect(response.headers['X-GitLab-Custom-Error']).to be_nil
+ expect(response.headers["X-GitLab-Custom-Error"]).to be_nil
end
end
- context 'given a json response' do
+ context "given a json response" do
controller do
def index
render json: {}, status: :unprocessable_entity
end
end
- it 'does not set a custom header' do
+ it "does not set a custom header" do
get :index, format: :json
- expect(response.headers['X-GitLab-Custom-Error']).to be_nil
+ expect(response.headers["X-GitLab-Custom-Error"]).to be_nil
end
end
- context 'given a json response for an html request' do
+ context "given a json response for an html request" do
controller do
def index
render json: {}, status: :unprocessable_entity
end
end
- it 'does not set a custom header' do
+ it "does not set a custom header" do
get :index
- expect(response.headers['X-GitLab-Custom-Error']).to be_nil
+ expect(response.headers["X-GitLab-Custom-Error"]).to be_nil
end
end
end
- context 'control headers' do
+ context "control headers" do
controller(described_class) do
def index
render json: :ok
end
end
- context 'user not logged in' do
- it 'sets the default headers' do
+ context "user not logged in" do
+ it "sets the default headers" do
get :index
- expect(response.headers['Cache-Control']).to be_nil
+ expect(response.headers["Cache-Control"]).to be_nil
end
end
- context 'user logged in' do
- it 'sets the default headers' do
+ context "user logged in" do
+ it "sets the default headers" do
sign_in(user)
get :index
- expect(response.headers['Cache-Control']).to eq 'max-age=0, private, must-revalidate, no-store'
+ expect(response.headers["Cache-Control"]).to eq "max-age=0, private, must-revalidate, no-store"
end
it 'does not set the "no-store" header for XHR requests' do
@@ -671,7 +670,7 @@ describe ApplicationController do
get :index, xhr: true
- expect(response.headers['Cache-Control']).to eq 'max-age=0, private, must-revalidate'
+ expect(response.headers["Cache-Control"]).to eq "max-age=0, private, must-revalidate"
end
end
end
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb
index 4458a7223bf..3467a505078 100644
--- a/spec/controllers/autocomplete_controller_spec.rb
+++ b/spec/controllers/autocomplete_controller_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe AutocompleteController do
let(:project) { create(:project) }
let(:user) { project.owner }
- context 'GET users' do
+ context "GET users" do
let!(:user2) { create(:user) }
let!(:non_member) { create(:user) }
- context 'project members' do
+ context "project members" do
before do
sign_in(user)
end
- describe 'GET #users with project ID' do
+ describe "GET #users with project ID" do
before do
- get(:users, params: { project_id: project.id })
+ get(:users, params: {project_id: project.id})
end
- it 'returns the project members' do
+ it "returns the project members" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
expect(json_response.map { |u| u["username"] }).to include(user.username)
end
end
- describe 'GET #users with unknown project' do
+ describe "GET #users with unknown project" do
before do
- get(:users, params: { project_id: 'unknown' })
+ get(:users, params: {project_id: "unknown"})
end
it { expect(response).to have_gitlab_http_status(404) }
end
end
- context 'group members' do
+ context "group members" do
let(:group) { create(:group) }
before do
@@ -42,48 +42,48 @@ describe AutocompleteController do
sign_in(user)
end
- describe 'GET #users with group ID' do
+ describe "GET #users with group ID" do
before do
- get(:users, params: { group_id: group.id })
+ get(:users, params: {group_id: group.id})
end
- it 'returns the group members' do
+ it "returns the group members" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
expect(json_response.first["username"]).to eq user.username
end
end
- describe 'GET #users with unknown group ID' do
+ describe "GET #users with unknown group ID" do
before do
- get(:users, params: { group_id: 'unknown' })
+ get(:users, params: {group_id: "unknown"})
end
it { expect(response).to have_gitlab_http_status(404) }
end
end
- context 'non-member login for public project' do
+ context "non-member login for public project" do
let(:project) { create(:project, :public) }
before do
sign_in(non_member)
end
- describe 'GET #users with project ID' do
+ describe "GET #users with project ID" do
before do
- get(:users, params: { project_id: project.id, current_user: true })
+ get(:users, params: {project_id: project.id, current_user: true})
end
- it 'returns the project members and non-members' do
+ it "returns the project members and non-members" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(2)
- expect(json_response.map { |u| u['username'] }).to include(user.username, non_member.username)
+ expect(json_response.map { |u| u["username"] }).to include(user.username, non_member.username)
end
end
end
- context 'all users' do
+ context "all users" do
before do
sign_in(user)
get(:users)
@@ -93,22 +93,22 @@ describe AutocompleteController do
it { expect(json_response.size).to eq User.count }
end
- context 'user order' do
- it 'shows exact matches first' do
- reported_user = create(:user, username: 'reported_user', name: 'Doug')
- user = create(:user, username: 'user', name: 'User')
- user1 = create(:user, username: 'user1', name: 'Ian')
+ context "user order" do
+ it "shows exact matches first" do
+ reported_user = create(:user, username: "reported_user", name: "Doug")
+ user = create(:user, username: "user", name: "User")
+ user1 = create(:user, username: "user1", name: "Ian")
sign_in(user)
- get(:users, params: { search: 'user' })
+ get(:users, params: {search: "user"})
- response_usernames = json_response.map { |user| user['username'] }
+ response_usernames = json_response.map { |user| user["username"] }
expect(response_usernames.take(3)).to match_array([user.username, reported_user.username, user1.username])
end
end
- context 'limited users per page' do
+ context "limited users per page" do
before do
25.times do
create(:user)
@@ -122,45 +122,45 @@ describe AutocompleteController do
it { expect(json_response.size).to eq(20) }
end
- context 'unauthenticated user' do
+ context "unauthenticated user" do
let(:public_project) { create(:project, :public) }
- describe 'GET #users with public project' do
+ describe "GET #users with public project" do
before do
public_project.add_guest(user)
- get(:users, params: { project_id: public_project.id })
+ get(:users, params: {project_id: public_project.id})
end
it { expect(json_response).to be_kind_of(Array) }
it { expect(json_response.size).to eq 2 }
end
- describe 'GET #users with project' do
+ describe "GET #users with project" do
before do
- get(:users, params: { project_id: project.id })
+ get(:users, params: {project_id: project.id})
end
it { expect(response).to have_gitlab_http_status(404) }
end
- describe 'GET #users with unknown project' do
+ describe "GET #users with unknown project" do
before do
- get(:users, params: { project_id: 'unknown' })
+ get(:users, params: {project_id: "unknown"})
end
it { expect(response).to have_gitlab_http_status(404) }
end
- describe 'GET #users with inaccessible group' do
+ describe "GET #users with inaccessible group" do
before do
project.add_guest(user)
- get(:users, params: { group_id: user.namespace.id })
+ get(:users, params: {group_id: user.namespace.id})
end
it { expect(response).to have_gitlab_http_status(404) }
end
- describe 'GET #users with no project' do
+ describe "GET #users with no project" do
before do
get(:users)
end
@@ -169,9 +169,9 @@ describe AutocompleteController do
it { expect(json_response).to be_empty }
end
- describe 'GET #users with todo filter' do
- it 'gives an array of users' do
- get :users, params: { todo_filter: true }
+ describe "GET #users with todo filter" do
+ it "gives an array of users" do
+ get :users, params: {todo_filter: true}
expect(response.status).to eq 200
expect(json_response).to be_kind_of(Array)
@@ -179,100 +179,100 @@ describe AutocompleteController do
end
end
- context 'author of issuable included' do
- context 'authenticated' do
+ context "author of issuable included" do
+ context "authenticated" do
before do
sign_in(user)
end
- it 'includes the author' do
- get(:users, params: { author_id: non_member.id })
+ it "includes the author" do
+ get(:users, params: {author_id: non_member.id})
expect(json_response.first["username"]).to eq non_member.username
end
- it 'rejects non existent user ids' do
- get(:users, params: { author_id: 99999 })
+ it "rejects non existent user ids" do
+ get(:users, params: {author_id: 99999})
- expect(json_response.collect { |u| u['id'] }).not_to include(99999)
+ expect(json_response.collect { |u| u["id"] }).not_to include(99999)
end
end
- context 'without authenticating' do
- it 'returns empty result' do
- get(:users, params: { author_id: non_member.id })
+ context "without authenticating" do
+ it "returns empty result" do
+ get(:users, params: {author_id: non_member.id})
expect(json_response).to be_empty
end
end
end
- context 'skip_users parameter included' do
+ context "skip_users parameter included" do
before do
sign_in(user)
end
- it 'skips the user IDs passed' do
- get(:users, params: { skip_users: [user, user2].map(&:id) })
+ it "skips the user IDs passed" do
+ get(:users, params: {skip_users: [user, user2].map(&:id)})
- response_user_ids = json_response.map { |user| user['id'] }
+ response_user_ids = json_response.map { |user| user["id"] }
expect(response_user_ids).to contain_exactly(non_member.id)
end
end
end
- context 'GET projects' do
+ context "GET projects" do
let(:authorized_project) { create(:project) }
- let(:authorized_search_project) { create(:project, name: 'rugged') }
+ let(:authorized_search_project) { create(:project, name: "rugged") }
before do
sign_in(user)
project.add_maintainer(user)
end
- context 'authorized projects' do
+ context "authorized projects" do
before do
authorized_project.add_maintainer(user)
end
- describe 'GET #projects with project ID' do
+ describe "GET #projects with project ID" do
before do
- get(:projects, params: { project_id: project.id })
+ get(:projects, params: {project_id: project.id})
end
- it 'returns projects' do
+ it "returns projects" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
- expect(json_response.first['id']).to eq authorized_project.id
- expect(json_response.first['name_with_namespace']).to eq authorized_project.full_name
+ expect(json_response.first["id"]).to eq authorized_project.id
+ expect(json_response.first["name_with_namespace"]).to eq authorized_project.full_name
end
end
end
- context 'authorized projects and search' do
+ context "authorized projects and search" do
before do
authorized_project.add_maintainer(user)
authorized_search_project.add_maintainer(user)
end
- describe 'GET #projects with project ID and search' do
+ describe "GET #projects with project ID and search" do
before do
- get(:projects, params: { project_id: project.id, search: 'rugged' })
+ get(:projects, params: {project_id: project.id, search: "rugged"})
end
- it 'returns projects' do
+ it "returns projects" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
- expect(json_response.first['id']).to eq authorized_search_project.id
- expect(json_response.first['name_with_namespace']).to eq authorized_search_project.full_name
+ expect(json_response.first["id"]).to eq authorized_search_project.id
+ expect(json_response.first["name_with_namespace"]).to eq authorized_search_project.full_name
end
end
end
- context 'authorized projects apply limit' do
+ context "authorized projects apply limit" do
before do
allow(Kaminari.config).to receive(:default_per_page).and_return(2)
@@ -281,19 +281,19 @@ describe AutocompleteController do
end
end
- describe 'GET #projects with project ID' do
+ describe "GET #projects with project ID" do
before do
- get(:projects, params: { project_id: project.id })
+ get(:projects, params: {project_id: project.id})
end
- it 'returns projects' do
+ it "returns projects" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(Kaminari.config.default_per_page)
end
end
end
- context 'authorized projects with offset' do
+ context "authorized projects with offset" do
before do
authorized_project2 = create(:project)
authorized_project3 = create(:project)
@@ -303,31 +303,31 @@ describe AutocompleteController do
authorized_project3.add_maintainer(user)
end
- describe 'GET #projects with project ID and offset_id' do
+ describe "GET #projects with project ID and offset_id" do
before do
- get(:projects, params: { project_id: project.id, offset_id: authorized_project.id })
+ get(:projects, params: {project_id: project.id, offset_id: authorized_project.id})
end
- it 'returns projects' do
+ it "returns projects" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq 2 # Of a total of 3
end
end
end
- context 'authorized projects without admin_issue ability' do
+ context "authorized projects without admin_issue ability" do
before do
authorized_project.add_guest(user)
expect(user.can?(:admin_issue, authorized_project)).to eq(false)
end
- describe 'GET #projects with project ID' do
+ describe "GET #projects with project ID" do
before do
- get(:projects, params: { project_id: project.id })
+ get(:projects, params: {project_id: project.id})
end
- it 'returns no projects' do
+ it "returns no projects" do
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(0)
end
@@ -335,23 +335,23 @@ describe AutocompleteController do
end
end
- context 'GET award_emojis' do
+ context "GET award_emojis" do
let(:user2) { create(:user) }
- let!(:award_emoji1) { create_list(:award_emoji, 2, user: user, name: 'thumbsup') }
- let!(:award_emoji2) { create_list(:award_emoji, 1, user: user, name: 'thumbsdown') }
- let!(:award_emoji3) { create_list(:award_emoji, 3, user: user, name: 'star') }
- let!(:award_emoji4) { create_list(:award_emoji, 1, user: user, name: 'tea') }
+ let!(:award_emoji1) { create_list(:award_emoji, 2, user: user, name: "thumbsup") }
+ let!(:award_emoji2) { create_list(:award_emoji, 1, user: user, name: "thumbsdown") }
+ let!(:award_emoji3) { create_list(:award_emoji, 3, user: user, name: "star") }
+ let!(:award_emoji4) { create_list(:award_emoji, 1, user: user, name: "tea") }
- context 'unauthorized user' do
- it 'returns empty json' do
+ context "unauthorized user" do
+ it "returns empty json" do
get :award_emojis
expect(json_response).to be_empty
end
end
- context 'sign in as user without award emoji' do
- it 'returns empty json' do
+ context "sign in as user without award emoji" do
+ it "returns empty json" do
sign_in(user2)
get :award_emojis
@@ -359,16 +359,16 @@ describe AutocompleteController do
end
end
- context 'sign in as user with award emoji' do
- it 'returns json sorted by name count' do
+ context "sign in as user with award emoji" do
+ it "returns json sorted by name count" do
sign_in(user)
get :award_emojis
expect(json_response.count).to eq 4
- expect(json_response[0]).to match('name' => 'star')
- expect(json_response[1]).to match('name' => 'thumbsup')
- expect(json_response[2]).to match('name' => 'tea')
- expect(json_response[3]).to match('name' => 'thumbsdown')
+ expect(json_response[0]).to match("name" => "star")
+ expect(json_response[1]).to match("name" => "thumbsup")
+ expect(json_response[2]).to match("name" => "tea")
+ expect(json_response[3]).to match("name" => "thumbsdown")
end
end
end
diff --git a/spec/controllers/boards/issues_controller_spec.rb b/spec/controllers/boards/issues_controller_spec.rb
index 5eb05f01b8d..b5b41b81651 100644
--- a/spec/controllers/boards/issues_controller_spec.rb
+++ b/spec/controllers/boards/issues_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::IssuesController do
let(:project) { create(:project, :private) }
@@ -6,8 +6,8 @@ describe Boards::IssuesController do
let(:user) { create(:user) }
let(:guest) { create(:user) }
- let(:planning) { create(:label, project: project, name: 'Planning') }
- let(:development) { create(:label, project: project, name: 'Development') }
+ let(:planning) { create(:label, project: project, name: "Planning") }
+ let(:development) { create(:label, project: project, name: "Development") }
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
let!(:list2) { create(:list, board: board, label: development, position: 1) }
@@ -17,19 +17,19 @@ describe Boards::IssuesController do
project.add_guest(guest)
end
- describe 'GET index', :request_store do
- let(:johndoe) { create(:user, avatar: fixture_file_upload(File.join('spec/fixtures/dk.png'))) }
+ describe "GET index", :request_store do
+ let(:johndoe) { create(:user, avatar: fixture_file_upload(File.join("spec/fixtures/dk.png"))) }
- context 'with invalid board id' do
- it 'returns a not found 404 response' do
+ context "with invalid board id" do
+ it "returns a not found 404 response" do
list_issues user: user, board: 999, list: list2
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when list id is present' do
- context 'with valid list id' do
+ context "when list id is present" do
+ context "with valid list id" do
let(:group) { create(:group, :private, projects: [project]) }
let(:group_board) { create(:board, group: group) }
let!(:list3) { create(:list, board: group_board, label: development, position: 2) }
@@ -39,7 +39,7 @@ describe Boards::IssuesController do
group.add_maintainer(user)
end
- it 'returns issues that have the list label applied' do
+ it "returns issues that have the list label applied" do
issue = create(:labeled_issue, project: project, labels: [planning])
create(:labeled_issue, project: project, labels: [planning])
create(:labeled_issue, project: project, labels: [development], due_date: Date.tomorrow)
@@ -50,12 +50,12 @@ describe Boards::IssuesController do
parsed_response = JSON.parse(response.body)
- expect(response).to match_response_schema('entities/issue_boards')
- expect(parsed_response['issues'].length).to eq 2
+ expect(response).to match_response_schema("entities/issue_boards")
+ expect(parsed_response["issues"].length).to eq 2
expect(development.issues.map(&:relative_position)).not_to include(nil)
end
- it 'avoids N+1 database queries' do
+ it "avoids N+1 database queries" do
create(:labeled_issue, project: project, labels: [development])
control_count = ActiveRecord::QueryRecorder.new { list_issues(user: user, board: board, list: list2) }.count
@@ -66,7 +66,7 @@ describe Boards::IssuesController do
expect { list_issues(user: user, board: board, list: list2) }.not_to exceed_query_limit(control_count)
end
- it 'avoids N+1 database queries when adding a project', :request_store do
+ it "avoids N+1 database queries when adding a project", :request_store do
create(:labeled_issue, project: project, labels: [development])
control_count = ActiveRecord::QueryRecorder.new { list_issues(user: user, board: group_board, list: list3) }.count
@@ -83,7 +83,7 @@ describe Boards::IssuesController do
expect { list_issues(user: user, board: group_board, list: list3) }.not_to exceed_query_limit(control_count + (2 * 8 - 1))
end
- it 'avoids N+1 database queries when adding a subgroup, project, and issue', :nested_groups do
+ it "avoids N+1 database queries when adding a subgroup, project, and issue", :nested_groups do
create(:project, group: sub_group_1)
create(:labeled_issue, project: project, labels: [development])
control_count = ActiveRecord::QueryRecorder.new { list_issues(user: user, board: group_board, list: list3) }.count
@@ -100,8 +100,8 @@ describe Boards::IssuesController do
end
end
- context 'with invalid list id' do
- it 'returns a not found 404 response' do
+ context "with invalid list id" do
+ it "returns a not found 404 response" do
list_issues user: user, board: board, list: 999
expect(response).to have_gitlab_http_status(404)
@@ -109,9 +109,9 @@ describe Boards::IssuesController do
end
end
- context 'when list id is missing' do
- it 'returns opened issues without board labels applied' do
- bug = create(:label, project: project, name: 'Bug')
+ context "when list id is missing" do
+ it "returns opened issues without board labels applied" do
+ bug = create(:label, project: project, name: "Bug")
create(:issue, project: project)
create(:labeled_issue, project: project, labels: [planning])
create(:labeled_issue, project: project, labels: [development])
@@ -121,15 +121,15 @@ describe Boards::IssuesController do
parsed_response = JSON.parse(response.body)
- expect(response).to match_response_schema('entities/issue_boards')
- expect(parsed_response['issues'].length).to eq 2
+ expect(response).to match_response_schema("entities/issue_boards")
+ expect(parsed_response["issues"].length).to eq 2
end
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
let(:unauth_user) { create(:user) }
- it 'returns a forbidden 403 response' do
+ it "returns a forbidden 403 response" do
list_issues user: unauth_user, board: board, list: list2
expect(response).to have_gitlab_http_status(403)
@@ -141,7 +141,7 @@ describe Boards::IssuesController do
params = {
board_id: board.to_param,
- list_id: list.try(:to_param)
+ list_id: list.try(:to_param),
}
unless board.try(:parent)&.is_a?(Group)
@@ -153,70 +153,70 @@ describe Boards::IssuesController do
end
end
- describe 'POST create' do
- context 'with valid params' do
- it 'returns a successful 200 response' do
- create_issue user: user, board: board, list: list1, title: 'New issue'
+ describe "POST create" do
+ context "with valid params" do
+ it "returns a successful 200 response" do
+ create_issue user: user, board: board, list: list1, title: "New issue"
expect(response).to have_gitlab_http_status(200)
end
- it 'returns the created issue' do
- create_issue user: user, board: board, list: list1, title: 'New issue'
+ it "returns the created issue" do
+ create_issue user: user, board: board, list: list1, title: "New issue"
- expect(response).to match_response_schema('entities/issue_board')
+ expect(response).to match_response_schema("entities/issue_board")
end
end
- context 'with invalid params' do
- context 'when title is nil' do
- it 'returns an unprocessable entity 422 response' do
+ context "with invalid params" do
+ context "when title is nil" do
+ it "returns an unprocessable entity 422 response" do
create_issue user: user, board: board, list: list1, title: nil
expect(response).to have_gitlab_http_status(422)
end
end
- context 'when list does not belongs to project board' do
- it 'returns a not found 404 response' do
+ context "when list does not belongs to project board" do
+ it "returns a not found 404 response" do
list = create(:list)
- create_issue user: user, board: board, list: list, title: 'New issue'
+ create_issue user: user, board: board, list: list, title: "New issue"
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with invalid board id' do
- it 'returns a not found 404 response' do
- create_issue user: user, board: 999, list: list1, title: 'New issue'
+ context "with invalid board id" do
+ it "returns a not found 404 response" do
+ create_issue user: user, board: 999, list: list1, title: "New issue"
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with invalid list id' do
- it 'returns a not found 404 response' do
- create_issue user: user, board: board, list: 999, title: 'New issue'
+ context "with invalid list id" do
+ it "returns a not found 404 response" do
+ create_issue user: user, board: board, list: 999, title: "New issue"
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'with guest user' do
- context 'in open list' do
- it 'returns a successful 200 response' do
+ context "with guest user" do
+ context "in open list" do
+ it "returns a successful 200 response" do
open_list = board.lists.create(list_type: :backlog)
- create_issue user: guest, board: board, list: open_list, title: 'New issue'
+ create_issue user: guest, board: board, list: open_list, title: "New issue"
expect(response).to have_gitlab_http_status(200)
end
end
- context 'in label list' do
- it 'returns a forbidden 403 response' do
- create_issue user: guest, board: board, list: list1, title: 'New issue'
+ context "in label list" do
+ it "returns a forbidden 403 response" do
+ create_issue user: guest, board: board, list: list1, title: "New issue"
expect(response).to have_gitlab_http_status(403)
end
@@ -227,59 +227,59 @@ describe Boards::IssuesController do
sign_in(user)
post :create, params: {
- board_id: board.to_param,
- list_id: list.to_param,
- issue: { title: title, project_id: project.id }
- },
+ board_id: board.to_param,
+ list_id: list.to_param,
+ issue: {title: title, project_id: project.id},
+ },
format: :json
end
end
- describe 'PATCH update' do
+ describe "PATCH update" do
let!(:issue) { create(:labeled_issue, project: project, labels: [planning]) }
- context 'with valid params' do
- it 'returns a successful 200 response' do
+ context "with valid params" do
+ it "returns a successful 200 response" do
move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(200)
end
- it 'moves issue to the desired list' do
+ it "moves issue to the desired list" do
move user: user, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(issue.reload.labels).to contain_exactly(development)
end
end
- context 'with invalid params' do
- it 'returns a unprocessable entity 422 response for invalid lists' do
+ context "with invalid params" do
+ it "returns a unprocessable entity 422 response for invalid lists" do
move user: user, board: board, issue: issue, from_list_id: nil, to_list_id: nil
expect(response).to have_gitlab_http_status(422)
end
- it 'returns a not found 404 response for invalid board id' do
+ it "returns a not found 404 response for invalid board id" do
move user: user, board: 999, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a not found 404 response for invalid issue id' do
+ it "returns a not found 404 response for invalid issue id" do
move user: user, board: board, issue: double(id: 999), from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
- it 'returns a forbidden 403 response' do
+ it "returns a forbidden 403 response" do
move user: guest, board: board, issue: issue, from_list_id: list1.id, to_list_id: list2.id
expect(response).to have_gitlab_http_status(403)
@@ -290,13 +290,13 @@ describe Boards::IssuesController do
sign_in(user)
patch :update, params: {
- namespace_id: project.namespace.to_param,
- project_id: project.id,
- board_id: board.to_param,
- id: issue.id,
- from_list_id: from_list_id,
- to_list_id: to_list_id
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project.id,
+ board_id: board.to_param,
+ id: issue.id,
+ from_list_id: from_list_id,
+ to_list_id: to_list_id,
+ },
format: :json
end
end
diff --git a/spec/controllers/boards/lists_controller_spec.rb b/spec/controllers/boards/lists_controller_spec.rb
index e5b8aa2e678..8ae5b5cda8f 100644
--- a/spec/controllers/boards/lists_controller_spec.rb
+++ b/spec/controllers/boards/lists_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::ListsController do
let(:project) { create(:project) }
@@ -11,29 +11,29 @@ describe Boards::ListsController do
project.add_guest(guest)
end
- describe 'GET index' do
- it 'returns a successful 200 response' do
+ describe "GET index" do
+ it "returns a successful 200 response" do
read_board_list user: user, board: board
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
- it 'returns a list of board lists' do
+ it "returns a list of board lists" do
create(:list, board: board)
read_board_list user: user, board: board
parsed_response = JSON.parse(response.body)
- expect(response).to match_response_schema('lists')
+ expect(response).to match_response_schema("lists")
expect(parsed_response.length).to eq 3
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
let(:unauth_user) { create(:user) }
- it 'returns a forbidden 403 response' do
+ it "returns a forbidden 403 response" do
read_board_list user: unauth_user, board: board
expect(response).to have_gitlab_http_status(403)
@@ -44,43 +44,43 @@ describe Boards::ListsController do
sign_in(user)
get :index, params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- board_id: board.to_param
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ board_id: board.to_param,
+ },
format: :json
end
end
- describe 'POST create' do
- context 'with valid params' do
- let(:label) { create(:label, project: project, name: 'Development') }
+ describe "POST create" do
+ context "with valid params" do
+ let(:label) { create(:label, project: project, name: "Development") }
- it 'returns a successful 200 response' do
+ it "returns a successful 200 response" do
create_board_list user: user, board: board, label_id: label.id
expect(response).to have_gitlab_http_status(200)
end
- it 'returns the created list' do
+ it "returns the created list" do
create_board_list user: user, board: board, label_id: label.id
- expect(response).to match_response_schema('list')
+ expect(response).to match_response_schema("list")
end
end
- context 'with invalid params' do
- context 'when label is nil' do
- it 'returns a not found 404 response' do
+ context "with invalid params" do
+ context "when label is nil" do
+ it "returns a not found 404 response" do
create_board_list user: user, board: board, label_id: nil
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when label that does not belongs to project' do
- it 'returns a not found 404 response' do
- label = create(:label, name: 'Development')
+ context "when label that does not belongs to project" do
+ it "returns a not found 404 response" do
+ label = create(:label, name: "Development")
create_board_list user: user, board: board, label_id: label.id
@@ -89,9 +89,9 @@ describe Boards::ListsController do
end
end
- context 'with unauthorized user' do
- it 'returns a forbidden 403 response' do
- label = create(:label, project: project, name: 'Development')
+ context "with unauthorized user" do
+ it "returns a forbidden 403 response" do
+ label = create(:label, project: project, name: "Development")
create_board_list user: guest, board: board, label_id: label.id
@@ -103,51 +103,51 @@ describe Boards::ListsController do
sign_in(user)
post :create, params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- board_id: board.to_param,
- list: { label_id: label_id }
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ board_id: board.to_param,
+ list: {label_id: label_id},
+ },
format: :json
end
end
- describe 'PATCH update' do
+ describe "PATCH update" do
let!(:planning) { create(:list, board: board, position: 0) }
let!(:development) { create(:list, board: board, position: 1) }
- context 'with valid position' do
- it 'returns a successful 200 response' do
+ context "with valid position" do
+ it "returns a successful 200 response" do
move user: user, board: board, list: planning, position: 1
expect(response).to have_gitlab_http_status(200)
end
- it 'moves the list to the desired position' do
+ it "moves the list to the desired position" do
move user: user, board: board, list: planning, position: 1
expect(planning.reload.position).to eq 1
end
end
- context 'with invalid position' do
- it 'returns an unprocessable entity 422 response' do
+ context "with invalid position" do
+ it "returns an unprocessable entity 422 response" do
move user: user, board: board, list: planning, position: 6
expect(response).to have_gitlab_http_status(422)
end
end
- context 'with invalid list id' do
- it 'returns a not found 404 response' do
+ context "with invalid list id" do
+ it "returns a not found 404 response" do
move user: user, board: board, list: 999, position: 1
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with unauthorized user' do
- it 'returns a forbidden 403 response' do
+ context "with unauthorized user" do
+ it "returns a forbidden 403 response" do
move user: guest, board: board, list: planning, position: 6
expect(response).to have_gitlab_http_status(403)
@@ -157,42 +157,42 @@ describe Boards::ListsController do
def move(user:, board:, list:, position:)
sign_in(user)
- params = { namespace_id: project.namespace.to_param,
- project_id: project,
- board_id: board.to_param,
- id: list.to_param,
- list: { position: position },
- format: :json }
+ params = {namespace_id: project.namespace.to_param,
+ project_id: project,
+ board_id: board.to_param,
+ id: list.to_param,
+ list: {position: position},
+ format: :json,}
patch :update, params: params, as: :json
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let!(:planning) { create(:list, board: board, position: 0) }
- context 'with valid list id' do
- it 'returns a successful 200 response' do
+ context "with valid list id" do
+ it "returns a successful 200 response" do
remove_board_list user: user, board: board, list: planning
expect(response).to have_gitlab_http_status(200)
end
- it 'removes list from board' do
+ it "removes list from board" do
expect { remove_board_list user: user, board: board, list: planning }.to change(board.lists, :size).by(-1)
end
end
- context 'with invalid list id' do
- it 'returns a not found 404 response' do
+ context "with invalid list id" do
+ it "returns a not found 404 response" do
remove_board_list user: user, board: board, list: 999
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with unauthorized user' do
- it 'returns a forbidden 403 response' do
+ context "with unauthorized user" do
+ it "returns a forbidden 403 response" do
remove_board_list user: guest, board: board, list: planning
expect(response).to have_gitlab_http_status(403)
@@ -203,32 +203,32 @@ describe Boards::ListsController do
sign_in(user)
delete :destroy, params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- board_id: board.to_param,
- id: list.to_param
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ board_id: board.to_param,
+ id: list.to_param,
+ },
format: :json
end
end
- describe 'POST generate' do
- context 'when board lists is empty' do
- it 'returns a successful 200 response' do
+ describe "POST generate" do
+ context "when board lists is empty" do
+ it "returns a successful 200 response" do
generate_default_lists user: user, board: board
expect(response).to have_gitlab_http_status(200)
end
- it 'returns the defaults lists' do
+ it "returns the defaults lists" do
generate_default_lists user: user, board: board
- expect(response).to match_response_schema('lists')
+ expect(response).to match_response_schema("lists")
end
end
- context 'when board lists is not empty' do
- it 'returns an unprocessable entity 422 response' do
+ context "when board lists is not empty" do
+ it "returns an unprocessable entity 422 response" do
create(:list, board: board)
generate_default_lists user: user, board: board
@@ -237,8 +237,8 @@ describe Boards::ListsController do
end
end
- context 'with unauthorized user' do
- it 'returns a forbidden 403 response' do
+ context "with unauthorized user" do
+ it "returns a forbidden 403 response" do
generate_default_lists user: guest, board: board
expect(response).to have_gitlab_http_status(403)
@@ -249,10 +249,10 @@ describe Boards::ListsController do
sign_in(user)
post :generate, params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- board_id: board.to_param
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ board_id: board.to_param,
+ },
format: :json
end
end
diff --git a/spec/controllers/concerns/checks_collaboration_spec.rb b/spec/controllers/concerns/checks_collaboration_spec.rb
index d7f110e11f3..98aaf537e3d 100644
--- a/spec/controllers/concerns/checks_collaboration_spec.rb
+++ b/spec/controllers/concerns/checks_collaboration_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe ChecksCollaboration do
include ProjectForksHelper
let(:helper) do
- fake_class = Class.new(ApplicationController) do
+ fake_class = Class.new(ApplicationController) {
include ChecksCollaboration
- end
+ }
fake_class.new
end
- describe '#can_collaborate_with_project?' do
+ describe "#can_collaborate_with_project?" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
@@ -22,30 +22,30 @@ describe ChecksCollaboration do
end
end
- it 'is true if the user can push to the project' do
+ it "is true if the user can push to the project" do
project.add_developer(user)
expect(helper.can_collaborate_with_project?(project)).to be_truthy
end
- it 'is true when the user can push to a branch of the project' do
- fake_access = double('Gitlab::UserAccess')
- expect(fake_access).to receive(:can_push_to_branch?).with('a-branch').and_return(true)
+ it "is true when the user can push to a branch of the project" do
+ fake_access = double("Gitlab::UserAccess")
+ expect(fake_access).to receive(:can_push_to_branch?).with("a-branch").and_return(true)
expect(Gitlab::UserAccess).to receive(:new).with(user, project: project).and_return(fake_access)
- expect(helper.can_collaborate_with_project?(project, ref: 'a-branch')).to be_truthy
+ expect(helper.can_collaborate_with_project?(project, ref: "a-branch")).to be_truthy
end
- context 'when the user has forked the project' do
+ context "when the user has forked the project" do
before do
fork_project(project, user, namespace: user.namespace)
end
- it 'is true' do
+ it "is true" do
expect(helper.can_collaborate_with_project?(project)).to be_truthy
end
- it 'is false when the project is archived' do
+ it "is false when the project is archived" do
project.archived = true
expect(helper.can_collaborate_with_project?(project)).to be_falsy
diff --git a/spec/controllers/concerns/continue_params_spec.rb b/spec/controllers/concerns/continue_params_spec.rb
index e2f683ae393..b6959f878c0 100644
--- a/spec/controllers/concerns/continue_params_spec.rb
+++ b/spec/controllers/concerns/continue_params_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ContinueParams do
let(:controller_class) do
@@ -6,7 +6,7 @@ describe ContinueParams do
include ContinueParams
def request
- @request ||= Struct.new(:host, :port).new('test.host', 80)
+ @request ||= Struct.new(:host, :port).new("test.host", 80)
end
end
end
@@ -16,30 +16,30 @@ describe ContinueParams do
ActionController::Parameters.new(continue: params)
end
- it 'cleans up any params that are not allowed' do
+ it "cleans up any params that are not allowed" do
allow(controller).to receive(:params) do
- strong_continue_params(to: '/hello',
- notice: 'world',
- notice_now: '!',
- something: 'else')
+ strong_continue_params(to: "/hello",
+ notice: "world",
+ notice_now: "!",
+ something: "else")
end
- expect(controller.continue_params.keys).to contain_exactly(*%w(to notice notice_now))
+ expect(controller.continue_params.keys).to contain_exactly("to", "notice", "notice_now")
end
- it 'does not allow cross host redirection' do
+ it "does not allow cross host redirection" do
allow(controller).to receive(:params) do
- strong_continue_params(to: '//example.com')
+ strong_continue_params(to: "//example.com")
end
expect(controller.continue_params[:to]).to be_nil
end
- it 'allows redirecting to a path with querystring' do
+ it "allows redirecting to a path with querystring" do
allow(controller).to receive(:params) do
- strong_continue_params(to: '/hello/world?query=string')
+ strong_continue_params(to: "/hello/world?query=string")
end
- expect(controller.continue_params[:to]).to eq('/hello/world?query=string')
+ expect(controller.continue_params[:to]).to eq("/hello/world?query=string")
end
end
diff --git a/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb b/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
index 9b2d054f4fc..7ea9535095a 100644
--- a/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
+++ b/spec/controllers/concerns/controller_with_cross_project_access_check_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ControllerWithCrossProjectAccessCheck do
let(:user) { create(:user) }
@@ -9,15 +9,15 @@ describe ControllerWithCrossProjectAccessCheck do
render_views
- context 'When reading cross project is not allowed' do
+ context "When reading cross project is not allowed" do
before do
allow(Ability).to receive(:allowed).and_call_original
allow(Ability).to receive(:allowed?)
- .with(user, :read_cross_project, :global)
- .and_return(false)
+ .with(user, :read_cross_project, :global)
+ .and_return(false)
end
- describe '#requires_cross_project_access' do
+ describe "#requires_cross_project_access" do
controller(ApplicationController) do
# `described_class` is not available in this context
include ControllerWithCrossProjectAccessCheck # rubocop:disable RSpec/DescribedClass
@@ -43,7 +43,7 @@ describe ControllerWithCrossProjectAccessCheck do
end
end
- it 'renders a 403 with trying to access a cross project page' do
+ it "renders a 403 with trying to access a cross project page" do
message = "This page is unavailable because you are not allowed to read "\
"information across multiple projects."
@@ -53,7 +53,7 @@ describe ControllerWithCrossProjectAccessCheck do
expect(response.body).to match(/#{message}/)
end
- it 'is skipped when the `if` condition returns false' do
+ it "is skipped when the `if` condition returns false" do
expect(controller).to receive(:if_condition).and_return(false)
get :index
@@ -61,7 +61,7 @@ describe ControllerWithCrossProjectAccessCheck do
expect(response).to have_gitlab_http_status(200)
end
- it 'is skipped when the `unless` condition returns true' do
+ it "is skipped when the `unless` condition returns true" do
expect(controller).to receive(:unless_condition).and_return(true)
get :index
@@ -69,14 +69,14 @@ describe ControllerWithCrossProjectAccessCheck do
expect(response).to have_gitlab_http_status(200)
end
- it 'correctly renders an action that does not require cross project access' do
- get :show, params: { id: 'nothing' }
+ it "correctly renders an action that does not require cross project access" do
+ get :show, params: {id: "nothing"}
expect(response).to have_gitlab_http_status(200)
end
end
- describe '#skip_cross_project_access_check' do
+ describe "#skip_cross_project_access_check" do
controller(ApplicationController) do
# `described_class` is not available in this context
include ControllerWithCrossProjectAccessCheck # rubocop:disable RSpec/DescribedClass
@@ -108,13 +108,13 @@ describe ControllerWithCrossProjectAccessCheck do
end
end
- it 'renders a success when the check is skipped' do
+ it "renders a success when the check is skipped" do
get :index
expect(response).to have_gitlab_http_status(200)
end
- it 'is executed when the `if` condition returns false' do
+ it "is executed when the `if` condition returns false" do
expect(controller).to receive(:if_condition).and_return(false)
get :index
@@ -122,7 +122,7 @@ describe ControllerWithCrossProjectAccessCheck do
expect(response).to have_gitlab_http_status(403)
end
- it 'is executed when the `unless` condition returns true' do
+ it "is executed when the `unless` condition returns true" do
expect(controller).to receive(:unless_condition).and_return(true)
get :index
@@ -130,14 +130,14 @@ describe ControllerWithCrossProjectAccessCheck do
expect(response).to have_gitlab_http_status(403)
end
- it 'does not skip the check on an action that is not skipped' do
- get :show, params: { id: 'hello' }
+ it "does not skip the check on an action that is not skipped" do
+ get :show, params: {id: "hello"}
expect(response).to have_gitlab_http_status(403)
end
- it 'does not skip the check on an action that was not defined to skip' do
- get :edit, params: { id: 'hello' }
+ it "does not skip the check on an action that was not defined to skip" do
+ get :edit, params: {id: "hello"}
expect(response).to have_gitlab_http_status(403)
end
diff --git a/spec/controllers/concerns/group_tree_spec.rb b/spec/controllers/concerns/group_tree_spec.rb
index 9fe17210d50..26711b4a17d 100644
--- a/spec/controllers/concerns/group_tree_spec.rb
+++ b/spec/controllers/concerns/group_tree_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupTree do
let(:group) { create(:group, :public) }
@@ -18,18 +18,18 @@ describe GroupTree do
sign_in(user)
end
- describe 'GET #index' do
- it 'filters groups' do
- other_group = create(:group, name: 'filter')
+ describe "GET #index" do
+ it "filters groups" do
+ other_group = create(:group, name: "filter")
other_group.add_owner(user)
- get :index, params: { filter: 'filt' }, format: :json
+ get :index, params: {filter: "filt"}, format: :json
expect(assigns(:groups)).to contain_exactly(other_group)
end
- context 'for subgroups', :nested_groups do
- it 'only renders root groups when no parent was given' do
+ context "for subgroups", :nested_groups do
+ it "only renders root groups when no parent was given" do
create(:group, :public, parent: group)
get :index, format: :json
@@ -37,62 +37,62 @@ describe GroupTree do
expect(assigns(:groups)).to contain_exactly(group)
end
- it 'contains only the subgroup when a parent was given' do
+ it "contains only the subgroup when a parent was given" do
subgroup = create(:group, :public, parent: group)
- get :index, params: { parent_id: group.id }, format: :json
+ get :index, params: {parent_id: group.id}, format: :json
expect(assigns(:groups)).to contain_exactly(subgroup)
end
- it 'allows filtering for subgroups and includes the parents for rendering' do
- subgroup = create(:group, :public, parent: group, name: 'filter')
+ it "allows filtering for subgroups and includes the parents for rendering" do
+ subgroup = create(:group, :public, parent: group, name: "filter")
- get :index, params: { filter: 'filt' }, format: :json
+ get :index, params: {filter: "filt"}, format: :json
expect(assigns(:groups)).to contain_exactly(group, subgroup)
end
- it 'does not include groups the user does not have access to' do
+ it "does not include groups the user does not have access to" do
parent = create(:group, :private)
- subgroup = create(:group, :private, parent: parent, name: 'filter')
+ subgroup = create(:group, :private, parent: parent, name: "filter")
subgroup.add_developer(user)
- _other_subgroup = create(:group, :private, parent: parent, name: 'filte')
+ _other_subgroup = create(:group, :private, parent: parent, name: "filte")
- get :index, params: { filter: 'filt' }, format: :json
+ get :index, params: {filter: "filt"}, format: :json
expect(assigns(:groups)).to contain_exactly(parent, subgroup)
end
- it 'preloads parents regardless of pagination' do
+ it "preloads parents regardless of pagination" do
allow(Kaminari.config).to receive(:default_per_page).and_return(1)
group = create(:group, :public)
subgroup = create(:group, :public, parent: group)
- search_result = create(:group, :public, name: 'result', parent: subgroup)
+ search_result = create(:group, :public, name: "result", parent: subgroup)
- get :index, params: { filter: 'resu' }, format: :json
+ get :index, params: {filter: "resu"}, format: :json
expect(assigns(:groups)).to contain_exactly(group, subgroup, search_result)
end
end
- context 'json content' do
- it 'shows groups as json' do
+ context "json content" do
+ it "shows groups as json" do
get :index, format: :json
- expect(json_response.first['id']).to eq(group.id)
+ expect(json_response.first["id"]).to eq(group.id)
end
- context 'nested groups', :nested_groups do
- it 'expands the tree when filtering' do
- subgroup = create(:group, :public, parent: group, name: 'filter')
+ context "nested groups", :nested_groups do
+ it "expands the tree when filtering" do
+ subgroup = create(:group, :public, parent: group, name: "filter")
- get :index, params: { filter: 'filt' }, format: :json
+ get :index, params: {filter: "filt"}, format: :json
- children_response = json_response.first['children']
+ children_response = json_response.first["children"]
- expect(json_response.first['id']).to eq(group.id)
- expect(children_response.first['id']).to eq(subgroup.id)
+ expect(json_response.first["id"]).to eq(group.id)
+ expect(children_response.first["id"]).to eq(subgroup.id)
end
end
end
diff --git a/spec/controllers/concerns/internal_redirect_spec.rb b/spec/controllers/concerns/internal_redirect_spec.rb
index 7e23b56356e..9ab02cb094f 100644
--- a/spec/controllers/concerns/internal_redirect_spec.rb
+++ b/spec/controllers/concerns/internal_redirect_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe InternalRedirect do
let(:controller_class) do
@@ -6,86 +6,86 @@ describe InternalRedirect do
include InternalRedirect
def request
- @request ||= Struct.new(:host, :port).new('test.host', 80)
+ @request ||= Struct.new(:host, :port).new("test.host", 80)
end
end
end
subject(:controller) { controller_class.new }
- describe '#safe_redirect_path' do
- it 'is `nil` for invalid uris' do
- expect(controller.safe_redirect_path('Hello world')).to be_nil
+ describe "#safe_redirect_path" do
+ it "is `nil` for invalid uris" do
+ expect(controller.safe_redirect_path("Hello world")).to be_nil
end
- it 'is `nil` for paths trying to include a host' do
- expect(controller.safe_redirect_path('//example.com/hello/world')).to be_nil
+ it "is `nil` for paths trying to include a host" do
+ expect(controller.safe_redirect_path("//example.com/hello/world")).to be_nil
end
- it 'returns the path if it is valid' do
- expect(controller.safe_redirect_path('/hello/world')).to eq('/hello/world')
+ it "returns the path if it is valid" do
+ expect(controller.safe_redirect_path("/hello/world")).to eq("/hello/world")
end
- it 'returns the path with querystring if it is valid' do
- expect(controller.safe_redirect_path('/hello/world?hello=world#L123'))
- .to eq('/hello/world?hello=world#L123')
+ it "returns the path with querystring if it is valid" do
+ expect(controller.safe_redirect_path("/hello/world?hello=world#L123"))
+ .to eq("/hello/world?hello=world#L123")
end
end
- describe '#safe_redirect_path_for_url' do
- it 'is `nil` for invalid urls' do
- expect(controller.safe_redirect_path_for_url('Hello world')).to be_nil
+ describe "#safe_redirect_path_for_url" do
+ it "is `nil` for invalid urls" do
+ expect(controller.safe_redirect_path_for_url("Hello world")).to be_nil
end
- it 'is `nil` for urls from a with a different host' do
- expect(controller.safe_redirect_path_for_url('http://example.com/hello/world')).to be_nil
+ it "is `nil` for urls from a with a different host" do
+ expect(controller.safe_redirect_path_for_url("http://example.com/hello/world")).to be_nil
end
- it 'is `nil` for urls from a with a different port' do
- expect(controller.safe_redirect_path_for_url('http://test.host:3000/hello/world')).to be_nil
+ it "is `nil` for urls from a with a different port" do
+ expect(controller.safe_redirect_path_for_url("http://test.host:3000/hello/world")).to be_nil
end
- it 'returns the path if the url is on the same host' do
- expect(controller.safe_redirect_path_for_url('http://test.host/hello/world')).to eq('/hello/world')
+ it "returns the path if the url is on the same host" do
+ expect(controller.safe_redirect_path_for_url("http://test.host/hello/world")).to eq("/hello/world")
end
- it 'returns the path including querystring if the url is on the same host' do
- expect(controller.safe_redirect_path_for_url('http://test.host/hello/world?hello=world#L123'))
- .to eq('/hello/world?hello=world#L123')
+ it "returns the path including querystring if the url is on the same host" do
+ expect(controller.safe_redirect_path_for_url("http://test.host/hello/world?hello=world#L123"))
+ .to eq("/hello/world?hello=world#L123")
end
end
- describe '#sanitize_redirect' do
- let(:valid_path) { '/hello/world?hello=world' }
+ describe "#sanitize_redirect" do
+ let(:valid_path) { "/hello/world?hello=world" }
let(:valid_url) { "http://test.host#{valid_path}" }
- it 'returns `nil` for invalid paths' do
- invalid_path = '//not/valid'
+ it "returns `nil` for invalid paths" do
+ invalid_path = "//not/valid"
expect(controller.sanitize_redirect(invalid_path)).to eq nil
end
- it 'returns `nil` for invalid urls' do
- input = 'http://test.host:3000/invalid'
+ it "returns `nil` for invalid urls" do
+ input = "http://test.host:3000/invalid"
expect(controller.sanitize_redirect(input)).to eq nil
end
- it 'returns input for valid paths' do
+ it "returns input for valid paths" do
expect(controller.sanitize_redirect(valid_path)).to eq valid_path
end
- it 'returns path for valid urls' do
+ it "returns path for valid urls" do
expect(controller.sanitize_redirect(valid_url)).to eq valid_path
end
end
- describe '#host_allowed?' do
- it 'allows uris with the same host and port' do
- expect(controller.host_allowed?(URI('http://test.host/test'))).to be(true)
+ describe "#host_allowed?" do
+ it "allows uris with the same host and port" do
+ expect(controller.host_allowed?(URI("http://test.host/test"))).to be(true)
end
- it 'rejects uris with other host and port' do
- expect(controller.host_allowed?(URI('http://example.com/test'))).to be(false)
+ it "rejects uris with other host and port" do
+ expect(controller.host_allowed?(URI("http://example.com/test"))).to be(false)
end
end
end
diff --git a/spec/controllers/concerns/issuable_collections_spec.rb b/spec/controllers/concerns/issuable_collections_spec.rb
index 8580900215c..14fa178472f 100644
--- a/spec/controllers/concerns/issuable_collections_spec.rb
+++ b/spec/controllers/concerns/issuable_collections_spec.rb
@@ -1,18 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe IssuableCollections do
let(:user) { create(:user) }
let(:controller) do
- klass = Class.new do
- def self.helper_method(name); end
+ klass = Class.new {
+ def self.helper_method(name)
+ end
include IssuableCollections
def finder_type
IssuesFinder
end
- end
+ }
controller = klass.new
@@ -22,24 +23,24 @@ describe IssuableCollections do
controller
end
- describe '#set_sort_order_from_user_preference' do
- describe 'when sort param given' do
- let(:params) { { sort: 'updated_desc' } }
+ describe "#set_sort_order_from_user_preference" do
+ describe "when sort param given" do
+ let(:params) { {sort: "updated_desc"} }
- context 'when issuable_sorting_field is defined' do
+ context "when issuable_sorting_field is defined" do
before do
controller.class.define_method(:issuable_sorting_field) { :issues_sort}
end
- it 'sets user_preference with the right value' do
+ it "sets user_preference with the right value" do
controller.send(:set_sort_order_from_user_preference)
- expect(user.user_preference.reload.issues_sort).to eq('updated_desc')
+ expect(user.user_preference.reload.issues_sort).to eq("updated_desc")
end
end
- context 'when no issuable_sorting_field is defined on the controller' do
- it 'does not touch user_preference' do
+ context "when no issuable_sorting_field is defined on the controller" do
+ it "does not touch user_preference" do
allow(user).to receive(:user_preference)
controller.send(:set_sort_order_from_user_preference)
@@ -49,55 +50,55 @@ describe IssuableCollections do
end
end
- context 'when a user sorting preference exists' do
+ context "when a user sorting preference exists" do
let(:params) { {} }
before do
controller.class.define_method(:issuable_sorting_field) { :issues_sort }
end
- it 'returns the set preference' do
- user.user_preference.update(issues_sort: 'updated_asc')
+ it "returns the set preference" do
+ user.user_preference.update(issues_sort: "updated_asc")
sort_preference = controller.send(:set_sort_order_from_user_preference)
- expect(sort_preference).to eq('updated_asc')
+ expect(sort_preference).to eq("updated_asc")
end
end
end
- describe '#set_set_order_from_cookie' do
- describe 'when sort param given' do
+ describe "#set_set_order_from_cookie" do
+ describe "when sort param given" do
let(:cookies) { {} }
- let(:params) { { sort: 'downvotes_asc' } }
+ let(:params) { {sort: "downvotes_asc"} }
- it 'sets the cookie with the right values and flags' do
+ it "sets the cookie with the right values and flags" do
allow(controller).to receive(:cookies).and_return(cookies)
controller.send(:set_sort_order_from_cookie)
- expect(cookies['issue_sort']).to eq({ value: 'popularity', secure: false, httponly: false })
+ expect(cookies["issue_sort"]).to eq({value: "popularity", secure: false, httponly: false})
end
end
- describe 'when cookie exists' do
- let(:cookies) { { 'issue_sort' => 'id_asc' } }
+ describe "when cookie exists" do
+ let(:cookies) { {"issue_sort" => "id_asc"} }
let(:params) { {} }
- it 'sets the cookie with the right values and flags' do
+ it "sets the cookie with the right values and flags" do
allow(controller).to receive(:cookies).and_return(cookies)
controller.send(:set_sort_order_from_cookie)
- expect(cookies['issue_sort']).to eq({ value: 'created_asc', secure: false, httponly: false })
+ expect(cookies["issue_sort"]).to eq({value: "created_asc", secure: false, httponly: false})
end
end
end
- describe '#page_count_for_relation' do
- let(:params) { { state: 'opened' } }
+ describe "#page_count_for_relation" do
+ let(:params) { {state: "opened"} }
- it 'returns the number of pages' do
+ it "returns the number of pages" do
relation = double(:relation, limit_value: 20)
pages = controller.send(:page_count_for_relation, relation, 28)
@@ -105,51 +106,51 @@ describe IssuableCollections do
end
end
- describe '#finder_options' do
+ describe "#finder_options" do
let(:params) do
{
- assignee_id: '1',
- assignee_username: 'user1',
- author_id: '2',
- author_username: 'user2',
- authorized_only: 'yes',
+ assignee_id: "1",
+ assignee_username: "user1",
+ author_id: "2",
+ author_username: "user2",
+ authorized_only: "yes",
confidential: true,
- due_date: '2017-01-01',
- group_id: '3',
- iids: '4',
- label_name: 'foo',
- milestone_title: 'bar',
- my_reaction_emoji: 'thumbsup',
- non_archived: 'true',
- project_id: '5',
- scope: 'all',
- search: 'baz',
- sort: 'priority',
- state: 'opened',
- invalid_param: 'invalid_param'
+ due_date: "2017-01-01",
+ group_id: "3",
+ iids: "4",
+ label_name: "foo",
+ milestone_title: "bar",
+ my_reaction_emoji: "thumbsup",
+ non_archived: "true",
+ project_id: "5",
+ scope: "all",
+ search: "baz",
+ sort: "priority",
+ state: "opened",
+ invalid_param: "invalid_param",
}
end
- it 'only allows whitelisted params' do
+ it "only allows whitelisted params" do
allow(controller).to receive(:cookies).and_return({})
allow(controller).to receive(:current_user).and_return(nil)
finder_options = controller.send(:finder_options)
expect(finder_options).to eq(ActionController::Parameters.new({
- 'assignee_id' => '1',
- 'assignee_username' => 'user1',
- 'author_id' => '2',
- 'author_username' => 'user2',
- 'confidential' => true,
- 'label_name' => 'foo',
- 'milestone_title' => 'bar',
- 'my_reaction_emoji' => 'thumbsup',
- 'due_date' => '2017-01-01',
- 'scope' => 'all',
- 'search' => 'baz',
- 'sort' => 'priority',
- 'state' => 'opened'
+ "assignee_id" => "1",
+ "assignee_username" => "user1",
+ "author_id" => "2",
+ "author_username" => "user2",
+ "confidential" => true,
+ "label_name" => "foo",
+ "milestone_title" => "bar",
+ "my_reaction_emoji" => "thumbsup",
+ "due_date" => "2017-01-01",
+ "scope" => "all",
+ "search" => "baz",
+ "sort" => "priority",
+ "state" => "opened",
}).permit!)
end
end
diff --git a/spec/controllers/concerns/lfs_request_spec.rb b/spec/controllers/concerns/lfs_request_spec.rb
index 7b49d4b6a3a..f25c6553d63 100644
--- a/spec/controllers/concerns/lfs_request_spec.rb
+++ b/spec/controllers/concerns/lfs_request_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe LfsRequest do
include ProjectForksHelper
@@ -32,17 +32,17 @@ describe LfsRequest do
stub_lfs_setting(enabled: true)
end
- describe '#storage_project' do
- it 'assigns the project as storage project' do
- get :show, params: { id: project.id }
+ describe "#storage_project" do
+ it "assigns the project as storage project" do
+ get :show, params: {id: project.id}
expect(assigns(:storage_project)).to eq(project)
end
- it 'assigns the source of a forked project' do
+ it "assigns the source of a forked project" do
forked_project = fork_project(project)
- get :show, params: { id: forked_project.id }
+ get :show, params: {id: forked_project.id}
expect(assigns(:storage_project)).to eq(project)
end
diff --git a/spec/controllers/concerns/send_file_upload_spec.rb b/spec/controllers/concerns/send_file_upload_spec.rb
index cf3b24f50a3..856ba7e8b93 100644
--- a/spec/controllers/concerns/send_file_upload_spec.rb
+++ b/spec/controllers/concerns/send_file_upload_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SendFileUpload do
let(:uploader_class) do
@@ -25,9 +25,9 @@ describe SendFileUpload do
let(:object) { build_stubbed(:user) }
let(:uploader) { uploader_class.new(object, :file) }
- describe '#send_upload' do
+ describe "#send_upload" do
let(:controller) { controller_class.new }
- let(:temp_file) { Tempfile.new('test') }
+ let(:temp_file) { Tempfile.new("test") }
let(:params) { {} }
subject { controller.send_upload(uploader, **params) }
@@ -40,28 +40,28 @@ describe SendFileUpload do
FileUtils.rm_f(temp_file)
end
- context 'when local file is used' do
+ context "when local file is used" do
before do
uploader.store!(temp_file)
end
- it 'sends a file' do
+ it "sends a file" do
expect(controller).to receive(:send_file).with(uploader.path, anything)
subject
end
end
- context 'with inline image' do
- let(:filename) { 'test.png' }
- let(:params) { { disposition: 'inline', attachment: filename } }
+ context "with inline image" do
+ let(:filename) { "test.png" }
+ let(:params) { {disposition: "inline", attachment: filename} }
- it 'sends a file with inline disposition' do
+ it "sends a file with inline disposition" do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expected_params = {
- filename: 'test.png',
- disposition: "inline; filename*=UTF-8''test.png"
+ filename: "test.png",
+ disposition: "inline; filename*=UTF-8''test.png",
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
@@ -69,32 +69,32 @@ describe SendFileUpload do
end
end
- context 'with attachment' do
- let(:filename) { 'test.js' }
- let(:params) { { attachment: filename } }
+ context "with attachment" do
+ let(:filename) { "test.js" }
+ let(:params) { {attachment: filename} }
- it 'sends a file with content-type of text/plain' do
+ it "sends a file with content-type of text/plain" do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expected_params = {
- content_type: 'text/plain',
- filename: 'test.js',
- disposition: "attachment; filename*=UTF-8''test.js"
+ content_type: "text/plain",
+ filename: "test.js",
+ disposition: "attachment; filename*=UTF-8''test.js",
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
subject
end
- context 'with non-ASCII encoded filename' do
- let(:filename) { 'テスト.txt' }
+ context "with non-ASCII encoded filename" do
+ let(:filename) { "テスト.txt" }
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
- it 'sends content-disposition for non-ASCII encoded filenames' do
+ it "sends content-disposition for non-ASCII encoded filenames" do
expected_params = {
filename: filename,
- disposition: "attachment; filename*=UTF-8''%E3%83%86%E3%82%B9%E3%83%88.txt"
+ disposition: "attachment; filename*=UTF-8''%E3%83%86%E3%82%B9%E3%83%88.txt",
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
@@ -102,7 +102,7 @@ describe SendFileUpload do
end
end
- context 'with a proxied file in object storage' do
+ context "with a proxied file in object storage" do
before do
stub_uploads_object_storage(uploader: uploader_class)
uploader.object_store = ObjectStorage::Store::REMOTE
@@ -110,9 +110,9 @@ describe SendFileUpload do
allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { true }
end
- it 'sends a file with a custom type' do
+ it "sends a file with a custom type" do
headers = double
- expected_headers = %r(response-content-disposition=attachment%3B%20filename%3D%22test.js%22%3B%20filename%2A%3DUTF-8%27%27test.js&response-content-type=application/ecmascript)
+ expected_headers = %r{response-content-disposition=attachment%3B%20filename%3D%22test.js%22%3B%20filename%2A%3DUTF-8%27%27test.js&response-content-type=application/ecmascript}
expect(Gitlab::Workhorse).to receive(:send_url).with(expected_headers).and_call_original
expect(headers).to receive(:store).with(Gitlab::Workhorse::SEND_DATA_HEADER, /^send-url:/)
@@ -125,15 +125,15 @@ describe SendFileUpload do
end
end
- context 'when remote file is used' do
+ context "when remote file is used" do
before do
stub_uploads_object_storage(uploader: uploader_class)
uploader.object_store = ObjectStorage::Store::REMOTE
uploader.store!(temp_file)
end
- shared_examples 'proxied file' do
- it 'sends a file' do
+ shared_examples "proxied file" do
+ it "sends a file" do
headers = double
expect(Gitlab::Workhorse).not_to receive(:send_url).with(/response-content-disposition/)
expect(Gitlab::Workhorse).not_to receive(:send_url).with(/response-content-type/)
@@ -148,29 +148,29 @@ describe SendFileUpload do
end
end
- context 'and proxying is enabled' do
+ context "and proxying is enabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { true }
end
- it_behaves_like 'proxied file'
+ it_behaves_like "proxied file"
end
- context 'and proxying is disabled' do
+ context "and proxying is disabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:proxy_download) { false }
end
- it 'sends a file' do
+ it "sends a file" do
expect(controller).to receive(:redirect_to).with(/#{uploader.path}/)
subject
end
- context 'with proxy requested' do
- let(:params) { { proxy: true } }
+ context "with proxy requested" do
+ let(:params) { {proxy: true} }
- it_behaves_like 'proxied file'
+ it_behaves_like "proxied file"
end
end
end
diff --git a/spec/controllers/dashboard/groups_controller_spec.rb b/spec/controllers/dashboard/groups_controller_spec.rb
index c8d99f79277..c6639905334 100644
--- a/spec/controllers/dashboard/groups_controller_spec.rb
+++ b/spec/controllers/dashboard/groups_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Dashboard::GroupsController do
let(:user) { create(:user) }
@@ -7,11 +7,11 @@ describe Dashboard::GroupsController do
sign_in(user)
end
- it 'renders group trees' do
+ it "renders group trees" do
expect(described_class).to include(GroupTree)
end
- it 'only includes projects the user is a member of' do
+ it "only includes projects the user is a member of" do
member_of_group = create(:group)
member_of_group.add_developer(user)
create(:group, :public)
@@ -21,19 +21,19 @@ describe Dashboard::GroupsController do
expect(assigns(:groups)).to contain_exactly(member_of_group)
end
- context 'when rendering an expanded hierarchy with public groups you are not a member of', :nested_groups do
- let!(:top_level_result) { create(:group, name: 'chef-top') }
- let!(:top_level_a) { create(:group, name: 'top-a') }
- let!(:sub_level_result_a) { create(:group, name: 'chef-sub-a', parent: top_level_a) }
- let!(:other_group) { create(:group, name: 'other') }
+ context "when rendering an expanded hierarchy with public groups you are not a member of", :nested_groups do
+ let!(:top_level_result) { create(:group, name: "chef-top") }
+ let!(:top_level_a) { create(:group, name: "top-a") }
+ let!(:sub_level_result_a) { create(:group, name: "chef-sub-a", parent: top_level_a) }
+ let!(:other_group) { create(:group, name: "other") }
before do
top_level_result.add_maintainer(user)
top_level_a.add_maintainer(user)
end
- it 'renders only groups the user is a member of when searching hierarchy correctly' do
- get :index, params: { filter: 'chef' }, format: :json
+ it "renders only groups the user is a member of when searching hierarchy correctly" do
+ get :index, params: {filter: "chef"}, format: :json
expect(response).to have_gitlab_http_status(200)
all_groups = [top_level_result, top_level_a, sub_level_result_a]
diff --git a/spec/controllers/dashboard/labels_controller_spec.rb b/spec/controllers/dashboard/labels_controller_spec.rb
index a3bfb2f3a87..c236f55fa62 100644
--- a/spec/controllers/dashboard/labels_controller_spec.rb
+++ b/spec/controllers/dashboard/labels_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Dashboard::LabelsController do
let(:project) { create(:project) }
@@ -13,7 +13,7 @@ describe Dashboard::LabelsController do
describe "#index" do
let!(:unrelated_label) { create(:label, project: create(:project, :public)) }
- it 'returns global labels for projects the user has a relationship with' do
+ it "returns global labels for projects the user has a relationship with" do
get :index, format: :json
expect(json_response).to be_kind_of(Array)
diff --git a/spec/controllers/dashboard/milestones_controller_spec.rb b/spec/controllers/dashboard/milestones_controller_spec.rb
index 4b164d0aa6b..92eecaaec77 100644
--- a/spec/controllers/dashboard/milestones_controller_spec.rb
+++ b/spec/controllers/dashboard/milestones_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Dashboard::MilestonesController do
let(:project) { create(:project) }
@@ -15,8 +15,8 @@ describe Dashboard::MilestonesController do
let(:issue) { create(:issue, project: project, milestone: project_milestone) }
let(:group_issue) { create(:issue, milestone: group_milestone) }
- let!(:label) { create(:label, project: project, title: 'Issue Label', issues: [issue]) }
- let!(:group_label) { create(:group_label, group: group, title: 'Group Issue Label', issues: [group_issue]) }
+ let!(:label) { create(:label, project: project, title: "Issue Label", issues: [issue]) }
+ let!(:group_label) { create(:group_label, group: group, title: "Group Issue Label", issues: [group_issue]) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: project_milestone) }
let(:milestone_path) { dashboard_milestone_path(milestone.safe_title, title: milestone.title) }
@@ -26,16 +26,16 @@ describe Dashboard::MilestonesController do
group.add_developer(user)
end
- it_behaves_like 'milestone tabs'
+ it_behaves_like "milestone tabs"
describe "#show" do
render_views
def view_milestone
- get :show, params: { id: milestone.safe_title, title: milestone.title }
+ get :show, params: {id: milestone.safe_title, title: milestone.title}
end
- it 'shows milestone page' do
+ it "shows milestone page" do
view_milestone
expect(response).to have_gitlab_http_status(200)
@@ -48,7 +48,7 @@ describe Dashboard::MilestonesController do
render_views
- it 'returns group and project milestones to which the user belongs' do
+ it "returns group and project milestones to which the user belongs" do
get :index, format: :json
expect(response).to have_gitlab_http_status(200)
@@ -57,25 +57,25 @@ describe Dashboard::MilestonesController do
expect(json_response.map { |i| i["group_name"] }.compact).to match_array(group.name)
end
- it 'searches legacy project milestones by title when search_title is given' do
- project_milestone = create(:milestone, title: 'Project milestone title', project: project)
+ it "searches legacy project milestones by title when search_title is given" do
+ project_milestone = create(:milestone, title: "Project milestone title", project: project)
- get :index, params: { search_title: 'Project mil' }
+ get :index, params: {search_title: "Project mil"}
expect(response.body).to include(project_milestone.title)
expect(response.body).not_to include(group_milestone.title)
end
- it 'searches group milestones by title when search_title is given' do
- group_milestone = create(:milestone, title: 'Group milestone title', group: group)
+ it "searches group milestones by title when search_title is given" do
+ group_milestone = create(:milestone, title: "Group milestone title", group: group)
- get :index, params: { search_title: 'Group mil' }
+ get :index, params: {search_title: "Group mil"}
expect(response.body).to include(group_milestone.title)
expect(response.body).not_to include(project_milestone.title)
end
- it 'should show counts of group and project milestones to which the user belongs to' do
+ it "should show counts of group and project milestones to which the user belongs to" do
get :index
expect(response.body).to include("Open\n<span class=\"badge badge-pill\">2</span>")
diff --git a/spec/controllers/dashboard/projects_controller_spec.rb b/spec/controllers/dashboard/projects_controller_spec.rb
index 2975205e09c..097cea70b48 100644
--- a/spec/controllers/dashboard/projects_controller_spec.rb
+++ b/spec/controllers/dashboard/projects_controller_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
+require "spec_helper"
describe Dashboard::ProjectsController do
- it_behaves_like 'authenticates sessionless user', :index, :atom
+ it_behaves_like "authenticates sessionless user", :index, :atom
end
diff --git a/spec/controllers/dashboard/todos_controller_spec.rb b/spec/controllers/dashboard/todos_controller_spec.rb
index d88beaff0e1..da544caecdb 100644
--- a/spec/controllers/dashboard/todos_controller_spec.rb
+++ b/spec/controllers/dashboard/todos_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Dashboard::TodosController do
let(:user) { create(:user) }
@@ -11,48 +11,48 @@ describe Dashboard::TodosController do
project.add_developer(user)
end
- describe 'GET #index' do
- context 'project authorization' do
- it 'renders 404 when user does not have read access on given project' do
+ describe "GET #index" do
+ context "project authorization" do
+ it "renders 404 when user does not have read access on given project" do
unauthorized_project = create(:project, :private)
- get :index, params: { project_id: unauthorized_project.id }
+ get :index, params: {project_id: unauthorized_project.id}
expect(response).to have_gitlab_http_status(404)
end
- it 'renders 404 when given project does not exists' do
- get :index, params: { project_id: 999 }
+ it "renders 404 when given project does not exists" do
+ get :index, params: {project_id: 999}
expect(response).to have_gitlab_http_status(404)
end
it 'renders 200 when filtering for "any project" todos' do
- get :index, params: { project_id: '' }
+ get :index, params: {project_id: ""}
expect(response).to have_gitlab_http_status(200)
end
- it 'renders 200 when user has access on given project' do
+ it "renders 200 when user has access on given project" do
authorized_project = create(:project, :public)
- get :index, params: { project_id: authorized_project.id }
+ get :index, params: {project_id: authorized_project.id}
expect(response).to have_gitlab_http_status(200)
end
end
- context 'group authorization' do
- it 'renders 404 when user does not have read access on given group' do
+ context "group authorization" do
+ it "renders 404 when user does not have read access on given group" do
unauthorized_group = create(:group, :private)
- get :index, params: { group_id: unauthorized_group.id }
+ get :index, params: {group_id: unauthorized_group.id}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when using pagination' do
+ context "when using pagination" do
let(:last_page) { user.todos.page.total_pages }
let!(:issues) { create_list(:issue, 3, project: project, assignees: [user]) }
@@ -61,45 +61,45 @@ describe Dashboard::TodosController do
allow(Kaminari.config).to receive(:default_per_page).and_return(2)
end
- it 'redirects to last_page if page number is larger than number of pages' do
- get :index, params: { page: (last_page + 1).to_param }
+ it "redirects to last_page if page number is larger than number of pages" do
+ get :index, params: {page: (last_page + 1).to_param}
expect(response).to redirect_to(dashboard_todos_path(page: last_page))
end
- it 'goes to the correct page' do
- get :index, params: { page: last_page }
+ it "goes to the correct page" do
+ get :index, params: {page: last_page}
expect(assigns(:todos).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
end
- it 'does not redirect to external sites when provided a host field' do
+ it "does not redirect to external sites when provided a host field" do
external_host = "www.example.com"
- get :index, params: { page: (last_page + 1).to_param, host: external_host }
+ get :index, params: {page: (last_page + 1).to_param, host: external_host}
expect(response).to redirect_to(dashboard_todos_path(page: last_page))
end
- context 'when providing no filters' do
- it 'does not perform a query to get the page count, but gets that from the user' do
+ context "when providing no filters" do
+ it "does not perform a query to get the page count, but gets that from the user" do
allow(controller).to receive(:current_user).and_return(user)
expect(user).to receive(:todos_pending_count).and_call_original
- get :index, params: { page: (last_page + 1).to_param, sort: :created_asc }
+ get :index, params: {page: (last_page + 1).to_param, sort: :created_asc}
expect(response).to redirect_to(dashboard_todos_path(page: last_page, sort: :created_asc))
end
end
- context 'when providing filters' do
- it 'performs a query to get the correct page count' do
+ context "when providing filters" do
+ it "performs a query to get the correct page count" do
allow(controller).to receive(:current_user).and_return(user)
expect(user).not_to receive(:todos_pending_count)
- get :index, params: { page: (last_page + 1).to_param, project_id: project.id }
+ get :index, params: {page: (last_page + 1).to_param, project_id: project.id}
expect(response).to redirect_to(dashboard_todos_path(page: last_page, project_id: project.id))
end
@@ -107,29 +107,29 @@ describe Dashboard::TodosController do
end
end
- describe 'PATCH #restore' do
+ describe "PATCH #restore" do
let(:todo) { create(:todo, :done, user: user, project: project, author: author) }
- it 'restores the todo to pending state' do
- patch :restore, params: { id: todo.id }
+ it "restores the todo to pending state" do
+ patch :restore, params: {id: todo.id}
expect(todo.reload).to be_pending
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq({ "count" => "1", "done_count" => "0" })
+ expect(json_response).to eq({"count" => "1", "done_count" => "0"})
end
end
- describe 'PATCH #bulk_restore' do
+ describe "PATCH #bulk_restore" do
let(:todos) { create_list(:todo, 2, :done, user: user, project: project, author: author) }
- it 'restores the todos to pending state' do
- patch :bulk_restore, params: { ids: todos.map(&:id) }
+ it "restores the todos to pending state" do
+ patch :bulk_restore, params: {ids: todos.map(&:id)}
todos.each do |todo|
expect(todo.reload).to be_pending
end
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq({ 'count' => '2', 'done_count' => '0' })
+ expect(json_response).to eq({"count" => "2", "done_count" => "0"})
end
end
end
diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb
index c857a78d5e8..dc39a02707d 100644
--- a/spec/controllers/dashboard_controller_spec.rb
+++ b/spec/controllers/dashboard_controller_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe DashboardController do
- context 'signed in' do
+ context "signed in" do
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -10,17 +10,17 @@ describe DashboardController do
sign_in(user)
end
- describe 'GET issues' do
- it_behaves_like 'issuables list meta-data', :issue, :issues
- it_behaves_like 'issuables requiring filter', :issues
+ describe "GET issues" do
+ it_behaves_like "issuables list meta-data", :issue, :issues
+ it_behaves_like "issuables requiring filter", :issues
end
- describe 'GET merge requests' do
- it_behaves_like 'issuables list meta-data', :merge_request, :merge_requests
- it_behaves_like 'issuables requiring filter', :merge_requests
+ describe "GET merge requests" do
+ it_behaves_like "issuables list meta-data", :merge_request, :merge_requests
+ it_behaves_like "issuables requiring filter", :merge_requests
end
end
- it_behaves_like 'authenticates sessionless user', :issues, :atom, author_id: User.first
- it_behaves_like 'authenticates sessionless user', :issues_calendar, :ics
+ it_behaves_like "authenticates sessionless user", :issues, :atom, author_id: User.first
+ it_behaves_like "authenticates sessionless user", :issues_calendar, :ics
end
diff --git a/spec/controllers/explore/groups_controller_spec.rb b/spec/controllers/explore/groups_controller_spec.rb
index 9e0ad9ea86f..a540e3d319f 100644
--- a/spec/controllers/explore/groups_controller_spec.rb
+++ b/spec/controllers/explore/groups_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Explore::GroupsController do
let(:user) { create(:user) }
@@ -7,11 +7,11 @@ describe Explore::GroupsController do
sign_in(user)
end
- it 'renders group trees' do
+ it "renders group trees" do
expect(described_class).to include(GroupTree)
end
- it 'includes public projects' do
+ it "includes public projects" do
member_of_group = create(:group)
member_of_group.add_developer(user)
public_group = create(:group, :public)
diff --git a/spec/controllers/explore/projects_controller_spec.rb b/spec/controllers/explore/projects_controller_spec.rb
index d57367e931e..c64e3608421 100644
--- a/spec/controllers/explore/projects_controller_spec.rb
+++ b/spec/controllers/explore/projects_controller_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Explore::ProjectsController do
- describe 'GET #trending' do
- context 'sorting by update date' do
+ describe "GET #trending" do
+ context "sorting by update date" do
let(:project1) { create(:project, :public, updated_at: 3.days.ago) }
let(:project2) { create(:project, :public, updated_at: 1.day.ago) }
@@ -11,14 +11,14 @@ describe Explore::ProjectsController do
create(:trending_project, project: project2)
end
- it 'sorts by last updated' do
- get :trending, params: { sort: 'updated_desc' }
+ it "sorts by last updated" do
+ get :trending, params: {sort: "updated_desc"}
expect(assigns(:projects)).to eq [project2, project1]
end
- it 'sorts by oldest updated' do
- get :trending, params: { sort: 'updated_asc' }
+ it "sorts by oldest updated" do
+ get :trending, params: {sort: "updated_asc"}
expect(assigns(:projects)).to eq [project1, project2]
end
diff --git a/spec/controllers/google_api/authorizations_controller_spec.rb b/spec/controllers/google_api/authorizations_controller_spec.rb
index 1e8e82da4f3..37b0bfba36c 100644
--- a/spec/controllers/google_api/authorizations_controller_spec.rb
+++ b/spec/controllers/google_api/authorizations_controller_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe GoogleApi::AuthorizationsController do
- describe 'GET|POST #callback' do
+ describe "GET|POST #callback" do
let(:user) { create(:user) }
- let(:token) { 'token' }
- let(:expires_at) { 1.hour.since.strftime('%s') }
+ let(:token) { "token" }
+ let(:expires_at) { 1.hour.since.strftime("%s") }
- subject { get :callback, params: { code: 'xxx', state: @state } }
+ subject { get :callback, params: {code: "xxx", state: @state} }
before do
sign_in(user)
@@ -15,7 +15,7 @@ describe GoogleApi::AuthorizationsController do
.to receive(:get_token).and_return([token, expires_at])
end
- it 'sets token and expires_at in session' do
+ it "sets token and expires_at in session" do
subject
expect(session[GoogleApi::CloudPlatform::Client.session_key_for_token])
@@ -24,24 +24,24 @@ describe GoogleApi::AuthorizationsController do
.to eq(expires_at)
end
- context 'when redirect uri key is stored in state' do
+ context "when redirect uri key is stored in state" do
set(:project) { create(:project) }
let(:redirect_uri) { project_clusters_url(project).to_s }
before do
@state = GoogleApi::CloudPlatform::Client
- .new_session_key_for_redirect_uri do |key|
+ .new_session_key_for_redirect_uri { |key|
session[key] = redirect_uri
- end
+ }
end
- it 'redirects to the URL stored in state param' do
+ it "redirects to the URL stored in state param" do
expect(subject).to redirect_to(redirect_uri)
end
end
- context 'when redirection url is not stored in state' do
- it 'redirects to root_path' do
+ context "when redirection url is not stored in state" do
+ it "redirects to root_path" do
expect(subject).to redirect_to(root_path)
end
end
diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb
index a0f40874db1..ed16faaa2dd 100644
--- a/spec/controllers/graphql_controller_spec.rb
+++ b/spec/controllers/graphql_controller_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe GraphqlController do
- describe 'execute' do
+ describe "execute" do
let(:user) { nil }
before do
@@ -12,101 +12,101 @@ describe GraphqlController do
subject { query_response }
- context 'graphql is disabled by feature flag' do
+ context "graphql is disabled by feature flag" do
let(:user) { nil }
before do
stub_feature_flags(graphql: false)
end
- it 'returns 404' do
+ it "returns 404" do
run_test_query!
expect(response).to have_gitlab_http_status(404)
end
end
- context 'signed out' do
+ context "signed out" do
let(:user) { nil }
- it 'runs the query with current_user: nil' do
- is_expected.to eq('echo' => 'nil says: test success')
+ it "runs the query with current_user: nil" do
+ is_expected.to eq("echo" => "nil says: test success")
end
end
- context 'signed in' do
- let(:user) { create(:user, username: 'Simon') }
+ context "signed in" do
+ let(:user) { create(:user, username: "Simon") }
- it 'runs the query with current_user set' do
- is_expected.to eq('echo' => '"Simon" says: test success')
+ it "runs the query with current_user set" do
+ is_expected.to eq("echo" => '"Simon" says: test success')
end
end
- context 'invalid variables' do
- it 'returns an error' do
+ context "invalid variables" do
+ it "returns an error" do
run_test_query!(variables: "This is not JSON")
expect(response).to have_gitlab_http_status(422)
- expect(json_response['errors'].first['message']).not_to be_nil
+ expect(json_response["errors"].first["message"]).not_to be_nil
end
end
end
- context 'token authentication' do
+ context "token authentication" do
before do
stub_authentication_activity_metrics(debug: false)
end
- let(:user) { create(:user, username: 'Simon') }
+ let(:user) { create(:user, username: "Simon") }
let(:personal_access_token) { create(:personal_access_token, user: user) }
context "when the 'personal_access_token' param is populated with the personal access token" do
- it 'logs the user in' do
+ it "logs the user in" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
- .and increment(:user_session_override_counter)
- .and increment(:user_sessionless_authentication_counter)
+ .and increment(:user_session_override_counter)
+ .and increment(:user_sessionless_authentication_counter)
run_test_query!(private_token: personal_access_token.token)
expect(response).to have_gitlab_http_status(200)
- expect(query_response).to eq('echo' => '"Simon" says: test success')
+ expect(query_response).to eq("echo" => '"Simon" says: test success')
end
end
- context 'when the personal access token has no api scope' do
- it 'does not log the user in' do
+ context "when the personal access token has no api scope" do
+ it "does not log the user in" do
personal_access_token.update(scopes: [:read_user])
run_test_query!(private_token: personal_access_token.token)
expect(response).to have_gitlab_http_status(200)
- expect(query_response).to eq('echo' => 'nil says: test success')
+ expect(query_response).to eq("echo" => "nil says: test success")
end
end
- context 'without token' do
- it 'shows public data' do
+ context "without token" do
+ it "shows public data" do
run_test_query!
- expect(query_response).to eq('echo' => 'nil says: test success')
+ expect(query_response).to eq("echo" => "nil says: test success")
end
end
end
# Chosen to exercise all the moving parts in GraphqlController#execute
- def run_test_query!(variables: { 'text' => 'test success' }, private_token: nil)
+ def run_test_query!(variables: {"text" => "test success"}, private_token: nil)
query = <<~QUERY
query Echo($text: String) {
echo(text: $text)
}
QUERY
- post :execute, params: { query: query, operationName: 'Echo', variables: variables, private_token: private_token }
+ post :execute, params: {query: query, operationName: "Echo", variables: variables, private_token: private_token}
end
def query_response
- json_response['data']
+ json_response["data"]
end
end
diff --git a/spec/controllers/groups/avatars_controller_spec.rb b/spec/controllers/groups/avatars_controller_spec.rb
index 772d1d0c1dd..ff1d8d8432a 100644
--- a/spec/controllers/groups/avatars_controller_spec.rb
+++ b/spec/controllers/groups/avatars_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::AvatarsController do
let(:user) { create(:user) }
@@ -9,8 +9,8 @@ describe Groups::AvatarsController do
sign_in(user)
end
- it 'removes avatar from DB calling destroy' do
- delete :destroy, params: { group_id: group.path }
+ it "removes avatar from DB calling destroy" do
+ delete :destroy, params: {group_id: group.path}
@group = assigns(:group)
expect(@group.avatar.present?).to be_falsey
expect(@group).to be_valid
diff --git a/spec/controllers/groups/boards_controller_spec.rb b/spec/controllers/groups/boards_controller_spec.rb
index 4228e727b52..f76fcc1c2f0 100644
--- a/spec/controllers/groups/boards_controller_spec.rb
+++ b/spec/controllers/groups/boards_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::BoardsController do
let(:group) { create(:group) }
@@ -9,20 +9,20 @@ describe Groups::BoardsController do
sign_in(user)
end
- describe 'GET index' do
- it 'creates a new board when group does not have one' do
+ describe "GET index" do
+ it "creates a new board when group does not have one" do
expect { list_boards }.to change(group.boards, :count).by(1)
end
- context 'when format is HTML' do
- it 'renders template' do
+ context "when format is HTML" do
+ it "renders template" do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- it 'redirects to latest visited board' do
+ it "redirects to latest visited board" do
board = create(:board, group: group)
create(:board_group_recent_visit, group: board.group, board: board, user: user)
@@ -31,7 +31,7 @@ describe Groups::BoardsController do
expect(response).to redirect_to(group_board_path(id: board.id))
end
- it 'renders template if visited board is not found' do
+ it "renders template if visited board is not found" do
temporary_board = create(:board, group: group)
visited = create(:board_group_recent_visit, group: temporary_board.group, board: temporary_board, user: user)
temporary_board.delete
@@ -41,27 +41,27 @@ describe Groups::BoardsController do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project, :global).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_group, group).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
list_boards
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
- context 'when user is signed out' do
+ context "when user is signed out" do
let(:group) { create(:group, :public) }
- it 'renders template' do
+ it "renders template" do
sign_out(user)
board = create(:board, group: group)
@@ -70,13 +70,13 @@ describe Groups::BoardsController do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
end
- context 'when format is JSON' do
- it 'return an array with one group board' do
+ context "when format is JSON" do
+ it "return an array with one group board" do
create(:board, group: group)
expect(Boards::Visits::LatestService).not_to receive(:new)
@@ -85,95 +85,95 @@ describe Groups::BoardsController do
parsed_response = JSON.parse(response.body)
- expect(response).to match_response_schema('boards')
+ expect(response).to match_response_schema("boards")
expect(parsed_response.length).to eq 1
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project, :global).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_group, group).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
list_boards format: :json
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
end
def list_boards(format: :html)
- get :index, params: { group_id: group }, format: format
+ get :index, params: {group_id: group}, format: format
end
end
- describe 'GET show' do
+ describe "GET show" do
let!(:board) { create(:board, group: group) }
- context 'when format is HTML' do
- it 'renders template' do
+ context "when format is HTML" do
+ it "renders template" do
expect { read_board board: board }.to change(BoardGroupRecentVisit, :count).by(1)
expect(response).to render_template :show
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project, :global).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_group, group).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
read_board board: board
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
- context 'when user is signed out' do
+ context "when user is signed out" do
let(:group) { create(:group, :public) }
- it 'does not save visit' do
+ it "does not save visit" do
sign_out(user)
expect { read_board board: board }.to change(BoardGroupRecentVisit, :count).by(0)
expect(response).to render_template :show
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
end
- context 'when format is JSON' do
- it 'returns project board' do
+ context "when format is JSON" do
+ it "returns project board" do
expect(Boards::Visits::CreateService).not_to receive(:new)
read_board board: board, format: :json
- expect(response).to match_response_schema('board')
+ expect(response).to match_response_schema("board")
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project, :global).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_group, group).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
read_board board: board, format: :json
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
end
- context 'when board does not belong to group' do
- it 'returns a not found 404 response' do
+ context "when board does not belong to group" do
+ it "returns a not found 404 response" do
another_board = create(:board)
read_board board: another_board
@@ -184,9 +184,9 @@ describe Groups::BoardsController do
def read_board(board:, format: :html)
get :show, params: {
- group_id: group,
- id: board.to_param
- },
+ group_id: group,
+ id: board.to_param,
+ },
format: format
end
end
diff --git a/spec/controllers/groups/children_controller_spec.rb b/spec/controllers/groups/children_controller_spec.rb
index e1b97013408..c406546cb35 100644
--- a/spec/controllers/groups/children_controller_spec.rb
+++ b/spec/controllers/groups/children_controller_spec.rb
@@ -1,168 +1,168 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::ChildrenController do
let(:group) { create(:group, :public) }
let(:user) { create(:user) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- describe 'GET #index' do
- context 'for projects' do
+ describe "GET #index" do
+ context "for projects" do
let!(:public_project) { create(:project, :public, namespace: group) }
let!(:private_project) { create(:project, :private, namespace: group) }
- context 'as a user' do
+ context "as a user" do
before do
sign_in(user)
end
- it 'shows all children' do
- get :index, params: { group_id: group.to_param }, format: :json
+ it "shows all children" do
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_project, private_project)
end
- context 'being member of private subgroup' do
- it 'shows public and private children the user is member of' do
+ context "being member of private subgroup" do
+ it "shows public and private children the user is member of" do
group_member.destroy!
private_project.add_guest(user)
- get :index, params: { group_id: group.to_param }, format: :json
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_project, private_project)
end
end
end
- context 'as a guest' do
- it 'shows the public children' do
- get :index, params: { group_id: group.to_param }, format: :json
+ context "as a guest" do
+ it "shows the public children" do
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_project)
end
end
end
- context 'for subgroups', :nested_groups do
+ context "for subgroups", :nested_groups do
let!(:public_subgroup) { create(:group, :public, parent: group) }
let!(:private_subgroup) { create(:group, :private, parent: group) }
let!(:public_project) { create(:project, :public, namespace: group) }
let!(:private_project) { create(:project, :private, namespace: group) }
- context 'as a user' do
+ context "as a user" do
before do
sign_in(user)
end
- it 'shows all children' do
- get :index, params: { group_id: group.to_param }, format: :json
+ it "shows all children" do
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_subgroup, private_subgroup, public_project, private_project)
end
- context 'being member of private subgroup' do
- it 'shows public and private children the user is member of' do
+ context "being member of private subgroup" do
+ it "shows public and private children the user is member of" do
group_member.destroy!
private_subgroup.add_guest(user)
private_project.add_guest(user)
- get :index, params: { group_id: group.to_param }, format: :json
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_subgroup, private_subgroup, public_project, private_project)
end
end
end
- context 'as a guest' do
- it 'shows the public children' do
- get :index, params: { group_id: group.to_param }, format: :json
+ context "as a guest" do
+ it "shows the public children" do
+ get :index, params: {group_id: group.to_param}, format: :json
expect(assigns(:children)).to contain_exactly(public_subgroup, public_project)
end
end
- context 'filtering children' do
- it 'expands the tree for matching projects' do
- project = create(:project, :public, namespace: public_subgroup, name: 'filterme')
+ context "filtering children" do
+ it "expands the tree for matching projects" do
+ project = create(:project, :public, namespace: public_subgroup, name: "filterme")
- get :index, params: { group_id: group.to_param, filter: 'filter' }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "filter"}, format: :json
group_json = json_response.first
- project_json = group_json['children'].first
+ project_json = group_json["children"].first
- expect(group_json['id']).to eq(public_subgroup.id)
- expect(project_json['id']).to eq(project.id)
+ expect(group_json["id"]).to eq(public_subgroup.id)
+ expect(project_json["id"]).to eq(project.id)
end
- it 'expands the tree for matching subgroups' do
- matched_group = create(:group, :public, parent: public_subgroup, name: 'filterme')
+ it "expands the tree for matching subgroups" do
+ matched_group = create(:group, :public, parent: public_subgroup, name: "filterme")
- get :index, params: { group_id: group.to_param, filter: 'filter' }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "filter"}, format: :json
group_json = json_response.first
- matched_group_json = group_json['children'].first
+ matched_group_json = group_json["children"].first
- expect(group_json['id']).to eq(public_subgroup.id)
- expect(matched_group_json['id']).to eq(matched_group.id)
+ expect(group_json["id"]).to eq(public_subgroup.id)
+ expect(matched_group_json["id"]).to eq(matched_group.id)
end
- it 'merges the trees correctly' do
- shared_subgroup = create(:group, :public, parent: group, path: 'hardware')
- matched_project_1 = create(:project, :public, namespace: shared_subgroup, name: 'mobile-soc')
+ it "merges the trees correctly" do
+ shared_subgroup = create(:group, :public, parent: group, path: "hardware")
+ matched_project_1 = create(:project, :public, namespace: shared_subgroup, name: "mobile-soc")
- l2_subgroup = create(:group, :public, parent: shared_subgroup, path: 'broadcom')
- l3_subgroup = create(:group, :public, parent: l2_subgroup, path: 'wifi-group')
- matched_project_2 = create(:project, :public, namespace: l3_subgroup, name: 'mobile')
+ l2_subgroup = create(:group, :public, parent: shared_subgroup, path: "broadcom")
+ l3_subgroup = create(:group, :public, parent: l2_subgroup, path: "wifi-group")
+ matched_project_2 = create(:project, :public, namespace: l3_subgroup, name: "mobile")
- get :index, params: { group_id: group.to_param, filter: 'mobile' }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "mobile"}, format: :json
shared_group_json = json_response.first
- expect(shared_group_json['id']).to eq(shared_subgroup.id)
+ expect(shared_group_json["id"]).to eq(shared_subgroup.id)
- matched_project_1_json = shared_group_json['children'].detect { |child| child['type'] == 'project' }
- expect(matched_project_1_json['id']).to eq(matched_project_1.id)
+ matched_project_1_json = shared_group_json["children"].detect { |child| child["type"] == "project" }
+ expect(matched_project_1_json["id"]).to eq(matched_project_1.id)
- l2_subgroup_json = shared_group_json['children'].detect { |child| child['type'] == 'group' }
- expect(l2_subgroup_json['id']).to eq(l2_subgroup.id)
+ l2_subgroup_json = shared_group_json["children"].detect { |child| child["type"] == "group" }
+ expect(l2_subgroup_json["id"]).to eq(l2_subgroup.id)
- l3_subgroup_json = l2_subgroup_json['children'].first
- expect(l3_subgroup_json['id']).to eq(l3_subgroup.id)
+ l3_subgroup_json = l2_subgroup_json["children"].first
+ expect(l3_subgroup_json["id"]).to eq(l3_subgroup.id)
- matched_project_2_json = l3_subgroup_json['children'].first
- expect(matched_project_2_json['id']).to eq(matched_project_2.id)
+ matched_project_2_json = l3_subgroup_json["children"].first
+ expect(matched_project_2_json["id"]).to eq(matched_project_2.id)
end
- it 'expands the tree upto a specified parent' do
+ it "expands the tree upto a specified parent" do
subgroup = create(:group, :public, parent: group)
l2_subgroup = create(:group, :public, parent: subgroup)
- create(:project, :public, namespace: l2_subgroup, name: 'test')
+ create(:project, :public, namespace: l2_subgroup, name: "test")
- get :index, params: { group_id: subgroup.to_param, filter: 'test' }, format: :json
+ get :index, params: {group_id: subgroup.to_param, filter: "test"}, format: :json
expect(response).to have_http_status(200)
end
- it 'returns an array with one element when only one result is matched' do
- create(:project, :public, namespace: group, name: 'match')
+ it "returns an array with one element when only one result is matched" do
+ create(:project, :public, namespace: group, name: "match")
- get :index, params: { group_id: group.to_param, filter: 'match' }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "match"}, format: :json
expect(json_response).to be_kind_of(Array)
expect(json_response.size).to eq(1)
end
- it 'returns an empty array when there are no search results' do
+ it "returns an empty array when there are no search results" do
subgroup = create(:group, :public, parent: group)
l2_subgroup = create(:group, :public, parent: subgroup)
- create(:project, :public, namespace: l2_subgroup, name: 'no-match')
+ create(:project, :public, namespace: l2_subgroup, name: "no-match")
- get :index, params: { group_id: subgroup.to_param, filter: 'test' }, format: :json
+ get :index, params: {group_id: subgroup.to_param, filter: "test"}, format: :json
expect(json_response).to eq([])
end
- it 'succeeds if multiple pages contain matching subgroups' do
- create(:group, parent: group, name: 'subgroup-filter-1')
- create(:group, parent: group, name: 'subgroup-filter-2')
+ it "succeeds if multiple pages contain matching subgroups" do
+ create(:group, parent: group, name: "subgroup-filter-1")
+ create(:group, parent: group, name: "subgroup-filter-2")
# Creating the group-to-nest first so it would be loaded into the
# relation first before it's parents, this is what would cause the
@@ -172,28 +172,28 @@ describe Groups::ChildrenController do
# collection first, and the pagination would cut off the actual search
# result. In this case the hierarchy can be rendered without crashing,
# it's just incomplete.
- group_to_nest = create(:group, parent: group, name: 'subsubgroup-filter-3')
+ group_to_nest = create(:group, parent: group, name: "subsubgroup-filter-3")
subgroup = create(:group, parent: group)
3.times do |i|
subgroup = create(:group, parent: subgroup)
end
group_to_nest.update!(parent: subgroup)
- get :index, params: { group_id: group.to_param, filter: 'filter', per_page: 3 }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "filter", per_page: 3}, format: :json
expect(response).to have_gitlab_http_status(200)
end
- it 'includes pagination headers' do
+ it "includes pagination headers" do
2.times { |i| create(:group, :public, parent: public_subgroup, name: "filterme#{i}") }
- get :index, params: { group_id: group.to_param, filter: 'filter', per_page: 1 }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "filter", per_page: 1}, format: :json
expect(response).to include_pagination_headers
end
end
- context 'queries per rendered element', :request_store do
+ context "queries per rendered element", :request_store do
# We need to make sure the following counts are preloaded
# otherwise they will cause an extra query
# 1. Count of visible projects in the element
@@ -203,10 +203,10 @@ describe Groups::ChildrenController do
let(:expected_queries_per_project) { 0 }
def get_list
- get :index, params: { group_id: group.to_param }, format: :json
+ get :index, params: {group_id: group.to_param}, format: :json
end
- it 'queries the expected amount for a group row' do
+ it "queries the expected amount for a group row" do
control = ActiveRecord::QueryRecorder.new { get_list }
_new_group = create(:group, :public, parent: group)
@@ -214,24 +214,24 @@ describe Groups::ChildrenController do
expect { get_list }.not_to exceed_query_limit(control).with_threshold(expected_queries_per_group)
end
- it 'queries the expected amount for a project row' do
+ it "queries the expected amount for a project row" do
control = ActiveRecord::QueryRecorder.new { get_list }
_new_project = create(:project, :public, namespace: group)
expect { get_list }.not_to exceed_query_limit(control).with_threshold(expected_queries_per_project)
end
- context 'when rendering hierarchies' do
+ context "when rendering hierarchies" do
# When loading hierarchies we load the all the ancestors for matched projects
# in 1 separate query
let(:extra_queries_for_hierarchies) { 1 }
def get_filtered_list
- get :index, params: { group_id: group.to_param, filter: 'filter' }, format: :json
+ get :index, params: {group_id: group.to_param, filter: "filter"}, format: :json
end
- it 'queries the expected amount when nested rows are increased for a group' do
- matched_group = create(:group, :public, parent: group, name: 'filterme')
+ it "queries the expected amount when nested rows are increased for a group" do
+ matched_group = create(:group, :public, parent: group, name: "filterme")
control = ActiveRecord::QueryRecorder.new { get_filtered_list }
@@ -240,19 +240,19 @@ describe Groups::ChildrenController do
expect { get_filtered_list }.not_to exceed_query_limit(control).with_threshold(extra_queries_for_hierarchies)
end
- it 'queries the expected amount when a new group match is added' do
- create(:group, :public, parent: public_subgroup, name: 'filterme')
+ it "queries the expected amount when a new group match is added" do
+ create(:group, :public, parent: public_subgroup, name: "filterme")
control = ActiveRecord::QueryRecorder.new { get_filtered_list }
- create(:group, :public, parent: public_subgroup, name: 'filterme2')
- create(:group, :public, parent: public_subgroup, name: 'filterme3')
+ create(:group, :public, parent: public_subgroup, name: "filterme2")
+ create(:group, :public, parent: public_subgroup, name: "filterme3")
expect { get_filtered_list }.not_to exceed_query_limit(control).with_threshold(extra_queries_for_hierarchies)
end
- it 'queries the expected amount when nested rows are increased for a project' do
- matched_project = create(:project, :public, namespace: group, name: 'filterme')
+ it "queries the expected amount when nested rows are increased for a project" do
+ matched_project = create(:project, :public, namespace: group, name: "filterme")
control = ActiveRecord::QueryRecorder.new { get_filtered_list }
@@ -264,53 +264,53 @@ describe Groups::ChildrenController do
end
end
- context 'pagination' do
+ context "pagination" do
let(:per_page) { 3 }
before do
allow(Kaminari.config).to receive(:default_per_page).and_return(per_page)
end
- context 'with only projects' do
+ context "with only projects" do
let!(:other_project) { create(:project, :public, namespace: group) }
- let!(:first_page_projects) { create_list(:project, per_page, :public, namespace: group ) }
+ let!(:first_page_projects) { create_list(:project, per_page, :public, namespace: group) }
- it 'has projects on the first page' do
- get :index, params: { group_id: group.to_param, sort: 'id_desc' }, format: :json
+ it "has projects on the first page" do
+ get :index, params: {group_id: group.to_param, sort: "id_desc"}, format: :json
expect(assigns(:children)).to contain_exactly(*first_page_projects)
end
- it 'has projects on the second page' do
- get :index, params: { group_id: group.to_param, sort: 'id_desc', page: 2 }, format: :json
+ it "has projects on the second page" do
+ get :index, params: {group_id: group.to_param, sort: "id_desc", page: 2}, format: :json
expect(assigns(:children)).to contain_exactly(other_project)
end
end
- context 'with subgroups and projects', :nested_groups do
+ context "with subgroups and projects", :nested_groups do
let!(:first_page_subgroups) { create_list(:group, per_page, :public, parent: group) }
let!(:other_subgroup) { create(:group, :public, parent: group) }
let!(:next_page_projects) { create_list(:project, per_page, :public, namespace: group) }
- it 'contains all subgroups' do
- get :index, params: { group_id: group.to_param, sort: 'id_asc' }, format: :json
+ it "contains all subgroups" do
+ get :index, params: {group_id: group.to_param, sort: "id_asc"}, format: :json
expect(assigns(:children)).to contain_exactly(*first_page_subgroups)
end
- it 'contains the project and group on the second page' do
- get :index, params: { group_id: group.to_param, sort: 'id_asc', page: 2 }, format: :json
+ it "contains the project and group on the second page" do
+ get :index, params: {group_id: group.to_param, sort: "id_asc", page: 2}, format: :json
expect(assigns(:children)).to contain_exactly(other_subgroup, *next_page_projects.take(per_page - 1))
end
- context 'with a mixed first page' do
+ context "with a mixed first page" do
let!(:first_page_subgroups) { [create(:group, :public, parent: group)] }
let!(:first_page_projects) { create_list(:project, per_page, :public, namespace: group) }
- it 'correctly calculates the counts' do
- get :index, params: { group_id: group.to_param, sort: 'id_asc', page: 2 }, format: :json
+ it "correctly calculates the counts" do
+ get :index, params: {group_id: group.to_param, sort: "id_asc", page: 2}, format: :json
expect(response).to have_gitlab_http_status(200)
end
diff --git a/spec/controllers/groups/clusters/applications_controller_spec.rb b/spec/controllers/groups/clusters/applications_controller_spec.rb
index dd5263b077c..654f6f0e269 100644
--- a/spec/controllers/groups/clusters/applications_controller_spec.rb
+++ b/spec/controllers/groups/clusters/applications_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Groups::Clusters::ApplicationsController do
include AccessMatchersForController
@@ -9,13 +9,13 @@ describe Groups::Clusters::ApplicationsController do
Clusters::Cluster::APPLICATIONS[application]
end
- describe 'POST create' do
+ describe "POST create" do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:group) { cluster.group }
- let(:application) { 'helm' }
- let(:params) { { application: application, id: cluster.id } }
+ let(:application) { "helm" }
+ let(:params) { {application: application, id: cluster.id} }
- describe 'functionality' do
+ describe "functionality" do
let(:user) { create(:user) }
before do
@@ -23,7 +23,7 @@ describe Groups::Clusters::ApplicationsController do
sign_in(user)
end
- it 'schedule an application installation' do
+ it "schedule an application installation" do
expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once
expect { go }.to change { current_application.count }
@@ -31,33 +31,33 @@ describe Groups::Clusters::ApplicationsController do
expect(cluster.application_helm).to be_scheduled
end
- context 'when cluster do not exists' do
+ context "when cluster do not exists" do
before do
cluster.destroy!
end
- it 'return 404' do
+ it "return 404" do
expect { go }.not_to change { current_application.count }
expect(response).to have_http_status(:not_found)
end
end
- context 'when application is unknown' do
- let(:application) { 'unkwnown-app' }
+ context "when application is unknown" do
+ let(:application) { "unkwnown-app" }
- it 'return 404' do
+ it "return 404" do
go
expect(response).to have_http_status(:not_found)
end
end
- context 'when application is already installing' do
+ context "when application is already installing" do
before do
create(:clusters_applications_helm, :installing, cluster: cluster)
end
- it 'returns 400' do
+ it "returns 400" do
go
expect(response).to have_http_status(:bad_request)
@@ -65,7 +65,7 @@ describe Groups::Clusters::ApplicationsController do
end
end
- describe 'security' do
+ describe "security" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
end
diff --git a/spec/controllers/groups/clusters_controller_spec.rb b/spec/controllers/groups/clusters_controller_spec.rb
index ef23ffaa843..7e7d1701eb6 100644
--- a/spec/controllers/groups/clusters_controller_spec.rb
+++ b/spec/controllers/groups/clusters_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Groups::ClustersController do
include AccessMatchersForController
@@ -15,30 +15,30 @@ describe Groups::ClustersController do
sign_in(user)
end
- describe 'GET index' do
+ describe "GET index" do
def go(params = {})
get :index, params: params.reverse_merge(group_id: group)
end
- context 'when feature flag is not enabled' do
+ context "when feature flag is not enabled" do
before do
stub_feature_flags(group_clusters: false)
end
- it 'renders 404' do
+ it "renders 404" do
go
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when feature flag is enabled' do
+ context "when feature flag is enabled" do
before do
stub_feature_flags(group_clusters: true)
end
- describe 'functionality' do
- context 'when group has one or more clusters' do
+ describe "functionality" do
+ context "when group has one or more clusters" do
let(:group) { create(:group) }
let!(:enabled_cluster) do
@@ -49,7 +49,7 @@ describe Groups::ClustersController do
create(:cluster, :disabled, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group])
end
- it 'lists available clusters' do
+ it "lists available clusters" do
go
expect(response).to have_gitlab_http_status(:ok)
@@ -57,7 +57,7 @@ describe Groups::ClustersController do
expect(assigns(:clusters)).to match_array([enabled_cluster, disabled_cluster])
end
- context 'when page is specified' do
+ context "when page is specified" do
let(:last_page) { group.clusters.page.total_pages }
before do
@@ -65,7 +65,7 @@ describe Groups::ClustersController do
create_list(:cluster, 2, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group])
end
- it 'redirects to the page' do
+ it "redirects to the page" do
go(page: last_page)
expect(response).to have_gitlab_http_status(:ok)
@@ -74,10 +74,10 @@ describe Groups::ClustersController do
end
end
- context 'when group does not have a cluster' do
+ context "when group does not have a cluster" do
let(:group) { create(:group) }
- it 'returns an empty state page' do
+ it "returns an empty state page" do
go
expect(response).to have_gitlab_http_status(:ok)
@@ -88,7 +88,7 @@ describe Groups::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
let(:cluster) { create(:cluster, :provided_by_gcp, cluster_type: :group_type, groups: [group]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -102,14 +102,14 @@ describe Groups::ClustersController do
end
end
- describe 'GET new' do
+ describe "GET new" do
def go
- get :new, params: { group_id: group }
+ get :new, params: {group_id: group}
end
- describe 'functionality for new cluster' do
- context 'when omniauth has been configured' do
- let(:key) { 'secret-key' }
+ describe "functionality for new cluster" do
+ context "when omniauth has been configured" do
+ let(:key) { "secret-key" }
let(:session_key_for_redirect_uri) do
GoogleApi::CloudPlatform::Client.session_key_for_redirect_uri(key)
end
@@ -118,7 +118,7 @@ describe Groups::ClustersController do
allow(SecureRandom).to receive(:hex).and_return(key)
end
- it 'has authorize_url' do
+ it "has authorize_url" do
go
expect(assigns(:authorize_url)).to include(key)
@@ -126,31 +126,31 @@ describe Groups::ClustersController do
end
end
- context 'when omniauth has not configured' do
+ context "when omniauth has not configured" do
before do
stub_omniauth_setting(providers: [])
end
- it 'does not have authorize_url' do
+ it "does not have authorize_url" do
go
expect(assigns(:authorize_url)).to be_nil
end
end
- context 'when access token is valid' do
+ context "when access token is valid" do
before do
stub_google_api_validate_token
end
- it 'has new object' do
+ it "has new object" do
go
expect(assigns(:gcp_cluster)).to be_an_instance_of(Clusters::ClusterPresenter)
end
end
- context 'when access token is expired' do
+ context "when access token is expired" do
before do
stub_google_api_expired_token
end
@@ -158,20 +158,20 @@ describe Groups::ClustersController do
it { expect(@valid_gcp_token).to be_falsey }
end
- context 'when access token is not stored in session' do
+ context "when access token is not stored in session" do
it { expect(@valid_gcp_token).to be_falsey }
end
end
- describe 'functionality for existing cluster' do
- it 'has new object' do
+ describe "functionality for existing cluster" do
+ it "has new object" do
go
expect(assigns(:user_cluster)).to be_an_instance_of(Clusters::ClusterPresenter)
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
it { expect { go }.to be_allowed_for(:maintainer).of(group) }
@@ -183,17 +183,17 @@ describe Groups::ClustersController do
end
end
- describe 'POST create for new cluster' do
- let(:legacy_abac_param) { 'true' }
+ describe "POST create for new cluster" do
+ let(:legacy_abac_param) { "true" }
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
provider_gcp_attributes: {
- gcp_project_id: 'gcp-project-12345',
- legacy_abac: legacy_abac_param
- }
- }
+ gcp_project_id: "gcp-project-12345",
+ legacy_abac: legacy_abac_param,
+ },
+ },
}
end
@@ -201,13 +201,13 @@ describe Groups::ClustersController do
post :create_gcp, params: params.merge(group_id: group)
end
- describe 'functionality' do
- context 'when access token is valid' do
+ describe "functionality" do
+ context "when access token is valid" do
before do
stub_google_api_validate_token
end
- it 'creates a new cluster' do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
.and change { Clusters::Providers::Gcp.count }
@@ -220,10 +220,10 @@ describe Groups::ClustersController do
expect(cluster.provider_gcp).to be_legacy_abac
end
- context 'when legacy_abac param is false' do
- let(:legacy_abac_param) { 'false' }
+ context "when legacy_abac param is false" do
+ let(:legacy_abac_param) { "false" }
- it 'creates a new cluster with legacy_abac_disabled' do
+ it "creates a new cluster with legacy_abac_disabled" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
.and change { Clusters::Providers::Gcp.count }
@@ -232,7 +232,7 @@ describe Groups::ClustersController do
end
end
- context 'when access token is expired' do
+ context "when access token is expired" do
before do
stub_google_api_expired_token
end
@@ -240,22 +240,22 @@ describe Groups::ClustersController do
it { expect(@valid_gcp_token).to be_falsey }
end
- context 'when access token is not stored in session' do
+ context "when access token is not stored in session" do
it { expect(@valid_gcp_token).to be_falsey }
end
end
- describe 'security' do
+ describe "security" do
before do
allow_any_instance_of(described_class)
- .to receive(:token_in_session).and_return('token')
+ .to receive(:token_in_session).and_return("token")
allow_any_instance_of(described_class)
.to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
allow_any_instance_of(GoogleApi::CloudPlatform::Client)
.to receive(:projects_zones_clusters_create) do
OpenStruct.new(
- self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123',
- status: 'RUNNING'
+ self_link: "projects/gcp-project-12345/zones/us-central1-a/operations/ope-123",
+ status: "RUNNING"
)
end
@@ -273,16 +273,16 @@ describe Groups::ClustersController do
end
end
- describe 'POST create for existing cluster' do
+ describe "POST create for existing cluster" do
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
platform_kubernetes_attributes: {
- api_url: 'http://my-url',
- token: 'test'
- }
- }
+ api_url: "http://my-url",
+ token: "test",
+ },
+ },
}
end
@@ -290,9 +290,9 @@ describe Groups::ClustersController do
post :create_user, params: params.merge(group_id: group)
end
- describe 'functionality' do
- context 'when creates a cluster' do
- it 'creates a new cluster' do
+ describe "functionality" do
+ context "when creates a cluster" do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
@@ -306,21 +306,21 @@ describe Groups::ClustersController do
end
end
- context 'when creates a RBAC-enabled cluster' do
+ context "when creates a RBAC-enabled cluster" do
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
platform_kubernetes_attributes: {
- api_url: 'http://my-url',
- token: 'test',
- authorization_type: 'rbac'
- }
- }
+ api_url: "http://my-url",
+ token: "test",
+ authorization_type: "rbac",
+ },
+ },
}
end
- it 'creates a new cluster' do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
@@ -336,7 +336,7 @@ describe Groups::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
it { expect { go }.to be_allowed_for(:maintainer).of(group) }
@@ -348,34 +348,34 @@ describe Groups::ClustersController do
end
end
- describe 'GET cluster_status' do
+ describe "GET cluster_status" do
let(:cluster) { create(:cluster, :providing_by_gcp, cluster_type: :group_type, groups: [group]) }
def go
get :cluster_status,
params: {
group_id: group.to_param,
- id: cluster
+ id: cluster,
},
format: :json
end
- describe 'functionality' do
- it 'responds with matching schema' do
+ describe "functionality" do
+ it "responds with matching schema" do
go
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('cluster_status')
+ expect(response).to match_response_schema("cluster_status")
end
- it 'invokes schedule_status_update on each application' do
+ it "invokes schedule_status_update on each application" do
expect_any_instance_of(Clusters::Applications::Ingress).to receive(:schedule_status_update)
go
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
it { expect { go }.to be_allowed_for(:maintainer).of(group) }
@@ -387,19 +387,19 @@ describe Groups::ClustersController do
end
end
- describe 'GET show' do
+ describe "GET show" do
let(:cluster) { create(:cluster, :provided_by_gcp, cluster_type: :group_type, groups: [group]) }
def go
get :show,
params: {
group_id: group,
- id: cluster
+ id: cluster,
}
end
- describe 'functionality' do
- it 'renders view' do
+ describe "functionality" do
+ it "renders view" do
go
expect(response).to have_gitlab_http_status(:ok)
@@ -407,7 +407,7 @@ describe Groups::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(group) }
it { expect { go }.to be_allowed_for(:maintainer).of(group) }
@@ -419,7 +419,7 @@ describe Groups::ClustersController do
end
end
- describe 'PUT update' do
+ describe "PUT update" do
def go(format: :html)
put :update, params: params.merge(
group_id: group.to_param,
@@ -429,76 +429,76 @@ describe Groups::ClustersController do
end
let(:cluster) { create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [group]) }
- let(:domain) { 'test-domain.com' }
+ let(:domain) { "test-domain.com" }
let(:params) do
{
cluster: {
enabled: false,
- name: 'my-new-cluster-name',
- base_domain: domain
- }
+ name: "my-new-cluster-name",
+ base_domain: domain,
+ },
}
end
- it 'updates and redirects back to show page' do
+ it "updates and redirects back to show page" do
go
cluster.reload
expect(response).to redirect_to(group_cluster_path(group, cluster))
- expect(flash[:notice]).to eq('Kubernetes cluster was successfully updated.')
+ expect(flash[:notice]).to eq("Kubernetes cluster was successfully updated.")
expect(cluster.enabled).to be_falsey
- expect(cluster.name).to eq('my-new-cluster-name')
- expect(cluster.domain).to eq('test-domain.com')
+ expect(cluster.name).to eq("my-new-cluster-name")
+ expect(cluster.domain).to eq("test-domain.com")
end
- context 'when domain is invalid' do
- let(:domain) { 'http://not-a-valid-domain' }
+ context "when domain is invalid" do
+ let(:domain) { "http://not-a-valid-domain" }
- it 'should not update cluster attributes' do
+ it "should not update cluster attributes" do
go
cluster.reload
expect(response).to render_template(:show)
- expect(cluster.name).not_to eq('my-new-cluster-name')
- expect(cluster.domain).not_to eq('test-domain.com')
+ expect(cluster.name).not_to eq("my-new-cluster-name")
+ expect(cluster.domain).not_to eq("test-domain.com")
end
end
- context 'when format is json' do
- context 'when changing parameters' do
- context 'when valid parameters are used' do
+ context "when format is json" do
+ context "when changing parameters" do
+ context "when valid parameters are used" do
let(:params) do
{
cluster: {
enabled: false,
- name: 'my-new-cluster-name',
- domain: domain
- }
+ name: "my-new-cluster-name",
+ domain: domain,
+ },
}
end
- it 'updates and redirects back to show page' do
+ it "updates and redirects back to show page" do
go(format: :json)
cluster.reload
expect(response).to have_http_status(:no_content)
expect(cluster.enabled).to be_falsey
- expect(cluster.name).to eq('my-new-cluster-name')
+ expect(cluster.name).to eq("my-new-cluster-name")
end
end
- context 'when invalid parameters are used' do
+ context "when invalid parameters are used" do
let(:params) do
{
cluster: {
enabled: false,
- name: ''
- }
+ name: "",
+ },
}
end
- it 'rejects changes' do
+ it "rejects changes" do
go(format: :json)
expect(response).to have_http_status(:bad_request)
@@ -507,7 +507,7 @@ describe Groups::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
set(:cluster) { create(:cluster, :provided_by_gcp, cluster_type: :group_type, groups: [group]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -521,61 +521,61 @@ describe Groups::ClustersController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) }
def go
delete :destroy,
params: {
group_id: group,
- id: cluster
+ id: cluster,
}
end
- describe 'functionality' do
- context 'when cluster is provided by GCP' do
- context 'when cluster is created' do
- it 'destroys and redirects back to clusters list' do
+ describe "functionality" do
+ context "when cluster is provided by GCP" do
+ context "when cluster is created" do
+ it "destroys and redirects back to clusters list" do
expect { go }
.to change { Clusters::Cluster.count }.by(-1)
.and change { Clusters::Platforms::Kubernetes.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(-1)
expect(response).to redirect_to(group_clusters_path(group))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
- context 'when cluster is being created' do
+ context "when cluster is being created" do
let!(:cluster) { create(:cluster, :providing_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) }
- it 'destroys and redirects back to clusters list' do
+ it "destroys and redirects back to clusters list" do
expect { go }
.to change { Clusters::Cluster.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(-1)
expect(response).to redirect_to(group_clusters_path(group))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
end
- context 'when cluster is provided by user' do
+ context "when cluster is provided by user" do
let!(:cluster) { create(:cluster, :provided_by_user, :production_environment, cluster_type: :group_type, groups: [group]) }
- it 'destroys and redirects back to clusters list' do
+ it "destroys and redirects back to clusters list" do
expect { go }
.to change { Clusters::Cluster.count }.by(-1)
.and change { Clusters::Platforms::Kubernetes.count }.by(-1)
.and change { Clusters::Providers::Gcp.count }.by(0)
expect(response).to redirect_to(group_clusters_path(group))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
end
- describe 'security' do
+ describe "security" do
set(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, cluster_type: :group_type, groups: [group]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -589,8 +589,8 @@ describe Groups::ClustersController do
end
end
- context 'no group_id param' do
- it 'does not respond to any action without group_id param' do
+ context "no group_id param" do
+ it "does not respond to any action without group_id param" do
expect { get :index }.to raise_error(ActionController::UrlGenerationError)
end
end
diff --git a/spec/controllers/groups/group_members_controller_spec.rb b/spec/controllers/groups/group_members_controller_spec.rb
index 3a801fabafc..6ac2b4efcf0 100644
--- a/spec/controllers/groups/group_members_controller_spec.rb
+++ b/spec/controllers/groups/group_members_controller_spec.rb
@@ -1,74 +1,74 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::GroupMembersController do
let(:user) { create(:user) }
let(:group) { create(:group, :public, :access_requestable) }
- describe 'GET index' do
- it 'renders index with 200 status code' do
- get :index, params: { group_id: group }
+ describe "GET index" do
+ it "renders index with 200 status code" do
+ get :index, params: {group_id: group}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:index)
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:group_user) { create(:user) }
before do
sign_in(user)
end
- context 'when user does not have enough rights' do
+ context "when user does not have enough rights" do
before do
group.add_developer(user)
end
- it 'returns 403' do
+ it "returns 403" do
post :create, params: {
- group_id: group,
- user_ids: group_user.id,
- access_level: Gitlab::Access::GUEST
- }
+ group_id: group,
+ user_ids: group_user.id,
+ access_level: Gitlab::Access::GUEST,
+ }
expect(response).to have_gitlab_http_status(403)
expect(group.users).not_to include group_user
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
group.add_owner(user)
end
- it 'adds user to members' do
+ it "adds user to members" do
post :create, params: {
- group_id: group,
- user_ids: group_user.id,
- access_level: Gitlab::Access::GUEST
- }
+ group_id: group,
+ user_ids: group_user.id,
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'Users were successfully added.'
+ expect(response).to set_flash.to "Users were successfully added."
expect(response).to redirect_to(group_group_members_path(group))
expect(group.users).to include group_user
end
- it 'adds no user to members' do
+ it "adds no user to members" do
post :create, params: {
- group_id: group,
- user_ids: '',
- access_level: Gitlab::Access::GUEST
- }
+ group_id: group,
+ user_ids: "",
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'No users specified.'
+ expect(response).to set_flash.to "No users specified."
expect(response).to redirect_to(group_group_members_path(group))
expect(group.users).not_to include group_user
end
end
end
- describe 'PUT update' do
+ describe "PUT update" do
let(:requester) { create(:group_member, :access_request, group: group) }
before do
@@ -79,9 +79,9 @@ describe Groups::GroupMembersController do
Gitlab::Access.options.each do |label, value|
it "can change the access level to #{label}" do
put :update, params: {
- group_member: { access_level: value },
+ group_member: {access_level: value},
group_id: group,
- id: requester
+ id: requester,
}, xhr: true
expect(requester.reload.human_access).to eq(label)
@@ -89,50 +89,50 @@ describe Groups::GroupMembersController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:member) { create(:group_member, :developer, group: group) }
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 403' do
- delete :destroy, params: { group_id: group, id: 42 }
+ context "when member is not found" do
+ it "returns 403" do
+ delete :destroy, params: {group_id: group, id: 42}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when member is found' do
- context 'when user does not have enough rights' do
+ context "when member is found" do
+ context "when user does not have enough rights" do
before do
group.add_developer(user)
end
- it 'returns 403' do
- delete :destroy, params: { group_id: group, id: member }
+ it "returns 403" do
+ delete :destroy, params: {group_id: group, id: member}
expect(response).to have_gitlab_http_status(403)
expect(group.members).to include member
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
group.add_owner(user)
end
- it '[HTML] removes user from members' do
- delete :destroy, params: { group_id: group, id: member }
+ it "[HTML] removes user from members" do
+ delete :destroy, params: {group_id: group, id: member}
- expect(response).to set_flash.to 'User was successfully removed from group and any subresources.'
+ expect(response).to set_flash.to "User was successfully removed from group and any subresources."
expect(response).to redirect_to(group_group_members_path(group))
expect(group.members).not_to include member
end
- it '[JS] removes user from members' do
- delete :destroy, params: { group_id: group, id: member }, xhr: true
+ it "[JS] removes user from members" do
+ delete :destroy, params: {group_id: group, id: member}, xhr: true
expect(response).to be_success
expect(group.members).not_to include member
@@ -141,62 +141,62 @@ describe Groups::GroupMembersController do
end
end
- describe 'DELETE leave' do
+ describe "DELETE leave" do
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 404' do
- delete :leave, params: { group_id: group }
+ context "when member is not found" do
+ it "returns 404" do
+ delete :leave, params: {group_id: group}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when member is found' do
- context 'and is not an owner' do
+ context "when member is found" do
+ context "and is not an owner" do
before do
group.add_developer(user)
end
- it 'removes user from members' do
- delete :leave, params: { group_id: group }
+ it "removes user from members" do
+ delete :leave, params: {group_id: group}
expect(response).to set_flash.to "You left the \"#{group.name}\" group."
expect(response).to redirect_to(dashboard_groups_path)
expect(group.users).not_to include user
end
- it 'supports json request' do
- delete :leave, params: { group_id: group }, format: :json
+ it "supports json request" do
+ delete :leave, params: {group_id: group}, format: :json
expect(response).to have_gitlab_http_status(200)
- expect(json_response['notice']).to eq "You left the \"#{group.name}\" group."
+ expect(json_response["notice"]).to eq "You left the \"#{group.name}\" group."
end
end
- context 'and is an owner' do
+ context "and is an owner" do
before do
group.add_owner(user)
end
- it 'cannot removes himself from the group' do
- delete :leave, params: { group_id: group }
+ it "cannot removes himself from the group" do
+ delete :leave, params: {group_id: group}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'and is a requester' do
+ context "and is a requester" do
before do
group.request_access(user)
end
- it 'removes user from members' do
- delete :leave, params: { group_id: group }
+ it "removes user from members" do
+ delete :leave, params: {group_id: group}
- expect(response).to set_flash.to 'Your access request to the group has been withdrawn.'
+ expect(response).to set_flash.to "Your access request to the group has been withdrawn."
expect(response).to redirect_to(group_path(group))
expect(group.requesters).to be_empty
expect(group.users).not_to include user
@@ -205,57 +205,57 @@ describe Groups::GroupMembersController do
end
end
- describe 'POST request_access' do
+ describe "POST request_access" do
before do
sign_in(user)
end
- it 'creates a new GroupMember that is not a team member' do
- post :request_access, params: { group_id: group }
+ it "creates a new GroupMember that is not a team member" do
+ post :request_access, params: {group_id: group}
- expect(response).to set_flash.to 'Your request for access has been queued for review.'
+ expect(response).to set_flash.to "Your request for access has been queued for review."
expect(response).to redirect_to(group_path(group))
expect(group.requesters.exists?(user_id: user)).to be_truthy
expect(group.users).not_to include user
end
end
- describe 'POST approve_access_request' do
+ describe "POST approve_access_request" do
let(:member) { create(:group_member, :access_request, group: group) }
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 403' do
- post :approve_access_request, params: { group_id: group, id: 42 }
+ context "when member is not found" do
+ it "returns 403" do
+ post :approve_access_request, params: {group_id: group, id: 42}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when member is found' do
- context 'when user does not have enough rights' do
+ context "when member is found" do
+ context "when user does not have enough rights" do
before do
group.add_developer(user)
end
- it 'returns 403' do
- post :approve_access_request, params: { group_id: group, id: member }
+ it "returns 403" do
+ post :approve_access_request, params: {group_id: group, id: member}
expect(response).to have_gitlab_http_status(403)
expect(group.members).not_to include member
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
group.add_owner(user)
end
- it 'adds user to members' do
- post :approve_access_request, params: { group_id: group, id: member }
+ it "adds user to members" do
+ post :approve_access_request, params: {group_id: group, id: member}
expect(response).to redirect_to(group_group_members_path(group))
expect(group.members).to include member
diff --git a/spec/controllers/groups/labels_controller_spec.rb b/spec/controllers/groups/labels_controller_spec.rb
index fa664a29066..62692caca4f 100644
--- a/spec/controllers/groups/labels_controller_spec.rb
+++ b/spec/controllers/groups/labels_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::LabelsController do
set(:group) { create(:group) }
@@ -11,39 +11,39 @@ describe Groups::LabelsController do
sign_in(user)
end
- describe 'GET #index' do
- set(:label_1) { create(:label, project: project, title: 'label_1') }
- set(:group_label_1) { create(:group_label, group: group, title: 'group_label_1') }
+ describe "GET #index" do
+ set(:label_1) { create(:label, project: project, title: "label_1") }
+ set(:group_label_1) { create(:group_label, group: group, title: "group_label_1") }
- it 'returns group and project labels by default' do
- get :index, params: { group_id: group }, format: :json
+ it "returns group and project labels by default" do
+ get :index, params: {group_id: group}, format: :json
- label_ids = json_response.map {|label| label['title']}
+ label_ids = json_response.map {|label| label["title"]}
expect(label_ids).to match_array([label_1.title, group_label_1.title])
end
- context 'with ancestor group', :nested_groups do
+ context "with ancestor group", :nested_groups do
set(:subgroup) { create(:group, parent: group) }
- set(:subgroup_label_1) { create(:group_label, group: subgroup, title: 'subgroup_label_1') }
+ set(:subgroup_label_1) { create(:group_label, group: subgroup, title: "subgroup_label_1") }
before do
subgroup.add_owner(user)
end
- it 'returns ancestor group labels', :nested_groups do
- get :index, params: { group_id: subgroup, include_ancestor_groups: true, only_group_labels: true }, format: :json
+ it "returns ancestor group labels", :nested_groups do
+ get :index, params: {group_id: subgroup, include_ancestor_groups: true, only_group_labels: true}, format: :json
- label_ids = json_response.map {|label| label['title']}
+ label_ids = json_response.map {|label| label["title"]}
expect(label_ids).to match_array([group_label_1.title, subgroup_label_1.title])
end
end
end
- describe 'POST #toggle_subscription' do
- it 'allows user to toggle subscription on group labels' do
+ describe "POST #toggle_subscription" do
+ it "allows user to toggle subscription on group labels" do
label = create(:group_label, group: group)
- post :toggle_subscription, params: { group_id: group.to_param, id: label.to_param }
+ post :toggle_subscription, params: {group_id: group.to_param, id: label.to_param}
expect(response).to have_gitlab_http_status(200)
end
diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb
index 043cf28514b..167ffa18195 100644
--- a/spec/controllers/groups/milestones_controller_spec.rb
+++ b/spec/controllers/groups/milestones_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::MilestonesController do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
let!(:project2) { create(:project, group: group) }
let(:user) { create(:user) }
- let(:title) { '肯定不是中文的问题' }
+ let(:title) { "肯定不是中文的问题" }
let(:milestone) do
project_milestone = create(:milestone, project: project)
@@ -21,7 +21,7 @@ describe Groups::MilestonesController do
{
title: title,
start_date: Date.today,
- due_date: 1.month.from_now.to_date
+ due_date: 1.month.from_now.to_date,
}
end
@@ -31,45 +31,45 @@ describe Groups::MilestonesController do
project.add_maintainer(user)
end
- describe '#index' do
- describe 'as HTML' do
+ describe "#index" do
+ describe "as HTML" do
render_views
- it 'shows group milestones page' do
+ it "shows group milestones page" do
milestone
- get :index, params: { group_id: group.to_param }
+ get :index, params: {group_id: group.to_param}
expect(response).to have_gitlab_http_status(200)
expect(response.body).to include(milestone.title)
end
- it 'searches legacy milestones by title when search_title is given' do
- project_milestone = create(:milestone, project: project, title: 'Project milestone title')
+ it "searches legacy milestones by title when search_title is given" do
+ project_milestone = create(:milestone, project: project, title: "Project milestone title")
- get :index, params: { group_id: group.to_param, search_title: 'Project mil' }
+ get :index, params: {group_id: group.to_param, search_title: "Project mil"}
expect(response.body).to include(project_milestone.title)
expect(response.body).not_to include(milestone.title)
end
- it 'searches group milestones by title when search_title is given' do
- group_milestone = create(:milestone, title: 'Group milestone title', group: group)
+ it "searches group milestones by title when search_title is given" do
+ group_milestone = create(:milestone, title: "Group milestone title", group: group)
- get :index, params: { group_id: group.to_param, search_title: 'Group mil' }
+ get :index, params: {group_id: group.to_param, search_title: "Group mil"}
expect(response.body).to include(group_milestone.title)
expect(response.body).not_to include(milestone.title)
end
end
- context 'as JSON' do
- let!(:milestone) { create(:milestone, group: group, title: 'group milestone') }
- let!(:legacy_milestone1) { create(:milestone, project: project, title: 'legacy') }
- let!(:legacy_milestone2) { create(:milestone, project: project2, title: 'legacy') }
+ context "as JSON" do
+ let!(:milestone) { create(:milestone, group: group, title: "group milestone") }
+ let!(:legacy_milestone1) { create(:milestone, project: project, title: "legacy") }
+ let!(:legacy_milestone2) { create(:milestone, project: project2, title: "legacy") }
- it 'lists legacy group milestones and group milestones' do
- get :index, params: { group_id: group.to_param }, format: :json
+ it "lists legacy group milestones and group milestones" do
+ get :index, params: {group_id: group.to_param}, format: :json
milestones = JSON.parse(response.body)
@@ -77,44 +77,44 @@ describe Groups::MilestonesController do
expect(milestones.first["title"]).to eq("group milestone")
expect(milestones.second["title"]).to eq("legacy")
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
end
- describe '#show' do
- let(:milestone1) { create(:milestone, project: project, title: 'legacy') }
- let(:milestone2) { create(:milestone, project: project, title: 'legacy') }
+ describe "#show" do
+ let(:milestone1) { create(:milestone, project: project, title: "legacy") }
+ let(:milestone2) { create(:milestone, project: project, title: "legacy") }
let(:group_milestone) { create(:milestone, group: group) }
- context 'when there is a title parameter' do
- it 'searches for a legacy group milestone' do
+ context "when there is a title parameter" do
+ it "searches for a legacy group milestone" do
expect(GroupMilestone).to receive(:build)
expect(Milestone).not_to receive(:find_by_iid)
- get :show, params: { group_id: group.to_param, id: title, title: milestone1.safe_title }
+ get :show, params: {group_id: group.to_param, id: title, title: milestone1.safe_title}
end
end
- context 'when there is not a title parameter' do
- it 'searches for a group milestone' do
+ context "when there is not a title parameter" do
+ it "searches for a group milestone" do
expect(GlobalMilestone).not_to receive(:build)
expect(Milestone).to receive(:find_by_iid)
- get :show, params: { group_id: group.to_param, id: group_milestone.id }
+ get :show, params: {group_id: group.to_param, id: group_milestone.id}
end
end
end
- it_behaves_like 'milestone tabs'
+ it_behaves_like "milestone tabs"
describe "#create" do
it "creates group milestone with Chinese title" do
post :create,
- params: {
- group_id: group.to_param,
- milestone: milestone_params
- }
+ params: {
+ group_id: group.to_param,
+ milestone: milestone_params,
+ }
milestone = Milestone.find_by_title(title)
@@ -132,11 +132,11 @@ describe Groups::MilestonesController do
milestone_params[:title] = "title changed"
put :update,
- params: {
- id: milestone.iid,
- group_id: group.to_param,
- milestone: milestone_params
- }
+ params: {
+ id: milestone.iid,
+ group_id: group.to_param,
+ milestone: milestone_params,
+ }
milestone.reload
expect(response).to redirect_to(group_milestone_path(group, milestone.iid))
@@ -144,8 +144,8 @@ describe Groups::MilestonesController do
end
context "legacy group milestones" do
- let!(:milestone1) { create(:milestone, project: project, title: 'legacy milestone', description: "old description") }
- let!(:milestone2) { create(:milestone, project: project2, title: 'legacy milestone', description: "old description") }
+ let!(:milestone1) { create(:milestone, project: project, title: "legacy milestone", description: "old description") }
+ let!(:milestone2) { create(:milestone, project: project2, title: "legacy milestone", description: "old description") }
it "updates only group milestones state" do
milestone_params[:title] = "title changed"
@@ -153,12 +153,12 @@ describe Groups::MilestonesController do
milestone_params[:state_event] = "close"
put :update,
- params: {
- id: milestone1.title.to_slug.to_s,
- group_id: group.to_param,
- milestone: milestone_params,
- title: milestone1.title
- }
+ params: {
+ id: milestone1.title.to_slug.to_s,
+ group_id: group.to_param,
+ milestone: milestone_params,
+ title: milestone1.title,
+ }
expect(response).to redirect_to(group_milestone_path(group, milestone1.safe_title, title: milestone1.title))
@@ -176,32 +176,32 @@ describe Groups::MilestonesController do
let(:milestone) { create(:milestone, group: group) }
it "removes milestone" do
- delete :destroy, params: { group_id: group.to_param, id: milestone.iid }, format: :js
+ delete :destroy, params: {group_id: group.to_param, id: milestone.iid}, format: :js
expect(response).to be_success
expect { Milestone.find(milestone.id) }.to raise_exception(ActiveRecord::RecordNotFound)
end
end
- describe '#ensure_canonical_path' do
+ describe "#ensure_canonical_path" do
before do
sign_in(user)
end
- context 'for a GET request' do
- context 'when requesting the canonical path' do
- context 'non-show path' do
- context 'with exactly matching casing' do
- it 'does not redirect' do
- get :index, params: { group_id: group.to_param }
+ context "for a GET request" do
+ context "when requesting the canonical path" do
+ context "non-show path" do
+ context "with exactly matching casing" do
+ it "does not redirect" do
+ get :index, params: {group_id: group.to_param}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :index, params: { group_id: group.to_param.upcase }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :index, params: {group_id: group.to_param.upcase}
expect(response).to redirect_to(group_milestones_path(group.to_param))
expect(controller).not_to set_flash[:notice]
@@ -209,18 +209,18 @@ describe Groups::MilestonesController do
end
end
- context 'show path' do
- context 'with exactly matching casing' do
- it 'does not redirect' do
- get :show, params: { group_id: group.to_param, id: title }
+ context "show path" do
+ context "with exactly matching casing" do
+ it "does not redirect" do
+ get :show, params: {group_id: group.to_param, id: title}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :show, params: { group_id: group.to_param.upcase, id: title }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :show, params: {group_id: group.to_param.upcase, id: title}
expect(response).to redirect_to(group_milestone_path(group.to_param, title))
expect(controller).not_to set_flash[:notice]
@@ -229,45 +229,45 @@ describe Groups::MilestonesController do
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
- it 'redirects to the canonical path' do
- get :merge_requests, params: { group_id: redirect_route.path, id: title }
+ it "redirects to the canonical path" do
+ get :merge_requests, params: {group_id: redirect_route.path, id: title}
expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
- context 'when the old group path is a substring of the scheme or host' do
- let(:redirect_route) { group.redirect_routes.create(path: 'http') }
+ context "when the old group path is a substring of the scheme or host" do
+ let(:redirect_route) { group.redirect_routes.create(path: "http") }
- it 'does not modify the requested host' do
- get :merge_requests, params: { group_id: redirect_route.path, id: title }
+ it "does not modify the requested host" do
+ get :merge_requests, params: {group_id: redirect_route.path, id: title}
expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
- context 'when the old group path is substring of groups' do
+ context "when the old group path is substring of groups" do
# I.e. /groups/oups should not become /grfoo/oups
- let(:redirect_route) { group.redirect_routes.create(path: 'oups') }
+ let(:redirect_route) { group.redirect_routes.create(path: "oups") }
- it 'does not modify the /groups part of the path' do
- get :merge_requests, params: { group_id: redirect_route.path, id: title }
+ it "does not modify the /groups part of the path" do
+ get :merge_requests, params: {group_id: redirect_route.path, id: title}
expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
- context 'when the old group path is substring of groups plus the new path' do
+ context "when the old group path is substring of groups plus the new path" do
# I.e. /groups/oups/oup should not become /grfoos
- let(:redirect_route) { group.redirect_routes.create(path: 'oups/oup') }
+ let(:redirect_route) { group.redirect_routes.create(path: "oups/oup") }
- it 'does not modify the /groups part of the path' do
- get :merge_requests, params: { group_id: redirect_route.path, id: title }
+ it "does not modify the /groups part of the path" do
+ get :merge_requests, params: {group_id: redirect_route.path, id: title}
expect(response).to redirect_to(merge_requests_group_milestone_path(group.to_param, title))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
@@ -277,38 +277,38 @@ describe Groups::MilestonesController do
end
end
- context 'for a non-GET request' do
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
+ context "for a non-GET request" do
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
post :create,
- params: {
- group_id: group.to_param,
- milestone: { title: title }
- }
+ params: {
+ group_id: group.to_param,
+ milestone: {title: title},
+ }
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
+ it "does not redirect to the correct casing" do
post :create,
- params: {
- group_id: group.to_param,
- milestone: { title: title }
- }
+ params: {
+ group_id: group.to_param,
+ milestone: {title: title},
+ }
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
- it 'returns not found' do
+ it "returns not found" do
post :create,
- params: {
- group_id: redirect_route.path,
- milestone: { title: title }
- }
+ params: {
+ group_id: redirect_route.path,
+ milestone: {title: title},
+ }
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/groups/runners_controller_spec.rb b/spec/controllers/groups/runners_controller_spec.rb
index 469459bfc02..fbf3107177d 100644
--- a/spec/controllers/groups/runners_controller_spec.rb
+++ b/spec/controllers/groups/runners_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::RunnersController do
let(:user) { create(:user) }
@@ -8,7 +8,7 @@ describe Groups::RunnersController do
let(:params) do
{
group_id: group,
- id: runner
+ id: runner,
}
end
@@ -17,13 +17,13 @@ describe Groups::RunnersController do
group.add_maintainer(user)
end
- describe '#update' do
- it 'updates the runner and ticks the queue' do
+ describe "#update" do
+ it "updates the runner and ticks the queue" do
new_desc = runner.description.swapcase
- expect do
- post :update, params: params.merge(runner: { description: new_desc } )
- end.to change { runner.ensure_runner_queue_value }
+ expect {
+ post :update, params: params.merge(runner: {description: new_desc})
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -32,8 +32,8 @@ describe Groups::RunnersController do
end
end
- describe '#destroy' do
- it 'destroys the runner' do
+ describe "#destroy" do
+ it "destroys the runner" do
delete :destroy, params: params
expect(response).to have_gitlab_http_status(302)
@@ -41,13 +41,13 @@ describe Groups::RunnersController do
end
end
- describe '#resume' do
- it 'marks the runner as active and ticks the queue' do
+ describe "#resume" do
+ it "marks the runner as active and ticks the queue" do
runner.update(active: false)
- expect do
+ expect {
post :resume, params: params
- end.to change { runner.ensure_runner_queue_value }
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -56,13 +56,13 @@ describe Groups::RunnersController do
end
end
- describe '#pause' do
- it 'marks the runner as inactive and ticks the queue' do
+ describe "#pause" do
+ it "marks the runner as inactive and ticks the queue" do
runner.update(active: true)
- expect do
+ expect {
post :pause, params: params
- end.to change { runner.ensure_runner_queue_value }
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
diff --git a/spec/controllers/groups/settings/ci_cd_controller_spec.rb b/spec/controllers/groups/settings/ci_cd_controller_spec.rb
index 40673d10b91..65c465fc5f5 100644
--- a/spec/controllers/groups/settings/ci_cd_controller_spec.rb
+++ b/spec/controllers/groups/settings/ci_cd_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::Settings::CiCdController do
let(:group) { create(:group) }
@@ -8,58 +8,58 @@ describe Groups::Settings::CiCdController do
sign_in(user)
end
- describe 'GET #show' do
- context 'when user is owner' do
+ describe "GET #show" do
+ context "when user is owner" do
before do
group.add_owner(user)
end
- it 'renders show with 200 status code' do
- get :show, params: { group_id: group }
+ it "renders show with 200 status code" do
+ get :show, params: {group_id: group}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:show)
end
end
- context 'when user is not owner' do
+ context "when user is not owner" do
before do
group.add_maintainer(user)
end
- it 'renders a 404' do
- get :show, params: { group_id: group }
+ it "renders a 404" do
+ get :show, params: {group_id: group}
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'PUT #reset_registration_token' do
- subject { put :reset_registration_token, params: { group_id: group } }
+ describe "PUT #reset_registration_token" do
+ subject { put :reset_registration_token, params: {group_id: group} }
- context 'when user is owner' do
+ context "when user is owner" do
before do
group.add_owner(user)
end
- it 'resets runner registration token' do
+ it "resets runner registration token" do
expect { subject }.to change { group.reload.runners_token }
end
- it 'redirects the user to admin runners page' do
+ it "redirects the user to admin runners page" do
subject
expect(response).to redirect_to(group_settings_ci_cd_path)
end
end
- context 'when user is not owner' do
+ context "when user is not owner" do
before do
group.add_maintainer(user)
end
- it 'renders a 404' do
+ it "renders a 404" do
subject
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/controllers/groups/shared_projects_controller_spec.rb b/spec/controllers/groups/shared_projects_controller_spec.rb
index dab7700cf64..9e244b45556 100644
--- a/spec/controllers/groups/shared_projects_controller_spec.rb
+++ b/spec/controllers/groups/shared_projects_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::SharedProjectsController do
def get_shared_projects(params = {})
@@ -22,14 +22,14 @@ describe Groups::SharedProjectsController do
shared_project
end
- let(:json_project_ids) { json_response.map { |project_info| project_info['id'] } }
+ let(:json_project_ids) { json_response.map { |project_info| project_info["id"] } }
before do
sign_in(user)
end
- describe 'GET #index' do
- it 'returns only projects shared with the group' do
+ describe "GET #index" do
+ it "returns only projects shared with the group" do
create(:project, namespace: group)
get_shared_projects
@@ -37,26 +37,26 @@ describe Groups::SharedProjectsController do
expect(json_project_ids).to contain_exactly(shared_project.id)
end
- it 'allows filtering shared projects' do
+ it "allows filtering shared projects" do
project = create(:project, namespace: user.namespace, name: "Searching for")
share_project(project)
- get_shared_projects(filter: 'search')
+ get_shared_projects(filter: "search")
expect(json_project_ids).to contain_exactly(project.id)
end
- it 'allows sorting projects' do
- shared_project.update!(name: 'bbb')
- second_project = create(:project, namespace: user.namespace, name: 'aaaa')
+ it "allows sorting projects" do
+ shared_project.update!(name: "bbb")
+ second_project = create(:project, namespace: user.namespace, name: "aaaa")
share_project(second_project)
- get_shared_projects(sort: 'name_asc')
+ get_shared_projects(sort: "name_asc")
expect(json_project_ids).to eq([second_project.id, shared_project.id])
end
- it 'does not include archived projects' do
+ it "does not include archived projects" do
archived_project = create(:project, :archived, namespace: user.namespace)
share_project(archived_project)
diff --git a/spec/controllers/groups/uploads_controller_spec.rb b/spec/controllers/groups/uploads_controller_spec.rb
index 0104ba827da..1c7fafb4f08 100644
--- a/spec/controllers/groups/uploads_controller_spec.rb
+++ b/spec/controllers/groups/uploads_controller_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::UploadsController do
include WorkhorseHelpers
let(:model) { create(:group, :public) }
let(:params) do
- { group_id: model }
+ {group_id: model}
end
- it_behaves_like 'handle uploads' do
+ it_behaves_like "handle uploads" do
let(:uploader_class) { NamespaceFileUploader }
end
def post_authorize(verified: true)
request.headers.merge!(workhorse_internal_api_request_header) if verified
- post :authorize, params: { group_id: model.full_path }, format: :json
+ post :authorize, params: {group_id: model.full_path}, format: :json
end
end
diff --git a/spec/controllers/groups/variables_controller_spec.rb b/spec/controllers/groups/variables_controller_spec.rb
index 29ec3588316..7eea7c7c66b 100644
--- a/spec/controllers/groups/variables_controller_spec.rb
+++ b/spec/controllers/groups/variables_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::VariablesController do
let(:group) { create(:group) }
@@ -9,17 +9,17 @@ describe Groups::VariablesController do
group.add_maintainer(user)
end
- describe 'GET #show' do
+ describe "GET #show" do
let!(:variable) { create(:ci_group_variable, group: group) }
subject do
- get :show, params: { group_id: group }, format: :json
+ get :show, params: {group_id: group}, format: :json
end
- include_examples 'GET #show lists all variables'
+ include_examples "GET #show lists all variables"
end
- describe 'PATCH #update' do
+ describe "PATCH #update" do
let!(:variable) { create(:ci_group_variable, group: group) }
let(:owner) { group }
@@ -27,11 +27,11 @@ describe Groups::VariablesController do
patch :update,
params: {
group_id: group,
- variables_attributes: variables_attributes
+ variables_attributes: variables_attributes,
},
format: :json
end
- include_examples 'PATCH #update updates variables'
+ include_examples "PATCH #update updates variables"
end
end
diff --git a/spec/controllers/groups_controller_spec.rb b/spec/controllers/groups_controller_spec.rb
index 7d87b33e503..6c4088e2311 100644
--- a/spec/controllers/groups_controller_spec.rb
+++ b/spec/controllers/groups_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupsController do
let(:user) { create(:user) }
@@ -11,56 +11,56 @@ describe GroupsController do
let!(:developer) { group.add_developer(create(:user)).user }
let!(:guest) { group.add_guest(create(:user)).user }
- shared_examples 'member with ability to create subgroups' do
- it 'renders the new page' do
+ shared_examples "member with ability to create subgroups" do
+ it "renders the new page" do
sign_in(member)
- get :new, params: { parent_id: group.id }
+ get :new, params: {parent_id: group.id}
expect(response).to render_template(:new)
end
end
- shared_examples 'member without ability to create subgroups' do
- it 'renders the 404 page' do
+ shared_examples "member without ability to create subgroups" do
+ it "renders the 404 page" do
sign_in(member)
- get :new, params: { parent_id: group.id }
+ get :new, params: {parent_id: group.id}
expect(response).not_to render_template(:new)
expect(response.status).to eq(404)
end
end
- describe 'GET #show' do
+ describe "GET #show" do
before do
sign_in(user)
project
end
- context 'as atom' do
- it 'assigns events for all the projects in the group' do
+ context "as atom" do
+ it "assigns events for all the projects in the group" do
create(:event, project: project)
- get :show, params: { id: group.to_param }, format: :atom
+ get :show, params: {id: group.to_param}, format: :atom
expect(assigns(:events)).not_to be_empty
end
end
end
- describe 'GET edit' do
- it 'sets the badge API endpoint' do
+ describe "GET edit" do
+ it "sets the badge API endpoint" do
sign_in(owner)
- get :edit, params: { id: group.to_param }
+ get :edit, params: {id: group.to_param}
expect(assigns(:badge_api_endpoint)).not_to be_nil
end
end
- describe 'GET #new' do
- context 'when creating subgroups', :nested_groups do
+ describe "GET #new" do
+ context "when creating subgroups", :nested_groups do
[true, false].each do |can_create_group_status|
context "and can_create_group is #{can_create_group_status}" do
before do
@@ -69,7 +69,7 @@ describe GroupsController do
[:admin, :owner].each do |member_type|
context "and logged in as #{member_type.capitalize}" do
- it_behaves_like 'member with ability to create subgroups' do
+ it_behaves_like "member with ability to create subgroups" do
let(:member) { send(member_type) }
end
end
@@ -77,7 +77,7 @@ describe GroupsController do
[:guest, :developer, :maintainer].each do |member_type|
context "and logged in as #{member_type.capitalize}" do
- it_behaves_like 'member without ability to create subgroups' do
+ it_behaves_like "member without ability to create subgroups" do
let(:member) { send(member_type) }
end
end
@@ -87,7 +87,7 @@ describe GroupsController do
end
end
- describe 'GET #activity' do
+ describe "GET #activity" do
render_views
before do
@@ -95,46 +95,46 @@ describe GroupsController do
project
end
- context 'as json' do
- it 'includes all projects in event feed' do
+ context "as json" do
+ it "includes all projects in event feed" do
3.times do
project = create(:project, group: group)
create(:event, project: project)
end
- get :activity, params: { id: group.to_param }, format: :json
+ get :activity, params: {id: group.to_param}, format: :json
expect(response).to have_gitlab_http_status(200)
- expect(json_response['count']).to eq(3)
+ expect(json_response["count"]).to eq(3)
expect(assigns(:projects).limit_value).to be_nil
end
end
end
- describe 'POST #create' do
- context 'when creating subgroups', :nested_groups do
+ describe "POST #create" do
+ context "when creating subgroups", :nested_groups do
[true, false].each do |can_create_group_status|
context "and can_create_group is #{can_create_group_status}" do
- context 'and logged in as Owner' do
- it 'creates the subgroup' do
+ context "and logged in as Owner" do
+ it "creates the subgroup" do
owner.update_attribute(:can_create_group, can_create_group_status)
sign_in(owner)
- post :create, params: { group: { parent_id: group.id, path: 'subgroup' } }
+ post :create, params: {group: {parent_id: group.id, path: "subgroup"}}
expect(response).to be_redirect
expect(response.body).to match(%r{http://test.host/#{group.path}/subgroup})
end
end
- context 'and logged in as Developer' do
- it 'renders the new template' do
+ context "and logged in as Developer" do
+ it "renders the new template" do
developer.update_attribute(:can_create_group, can_create_group_status)
sign_in(developer)
previous_group_count = Group.count
- post :create, params: { group: { parent_id: group.id, path: 'subgroup' } }
+ post :create, params: {group: {parent_id: group.id, path: "subgroup"}}
expect(response).to render_template(:new)
expect(Group.count).to eq(previous_group_count)
@@ -144,35 +144,35 @@ describe GroupsController do
end
end
- context 'when creating a top level group' do
+ context "when creating a top level group" do
before do
sign_in(developer)
end
- context 'and can_create_group is enabled' do
+ context "and can_create_group is enabled" do
before do
developer.update_attribute(:can_create_group, true)
end
- it 'creates the Group' do
+ it "creates the Group" do
original_group_count = Group.count
- post :create, params: { group: { path: 'subgroup' } }
+ post :create, params: {group: {path: "subgroup"}}
expect(Group.count).to eq(original_group_count + 1)
expect(response).to be_redirect
end
end
- context 'and can_create_group is disabled' do
+ context "and can_create_group is disabled" do
before do
developer.update_attribute(:can_create_group, false)
end
- it 'does not create the Group' do
+ it "does not create the Group" do
original_group_count = Group.count
- post :create, params: { group: { path: 'subgroup' } }
+ post :create, params: {group: {path: "subgroup"}}
expect(Group.count).to eq(original_group_count)
expect(response).to render_template(:new)
@@ -181,9 +181,9 @@ describe GroupsController do
end
end
- describe 'GET #index' do
- context 'as a user' do
- it 'redirects to Groups Dashboard' do
+ describe "GET #index" do
+ context "as a user" do
+ it "redirects to Groups Dashboard" do
sign_in(user)
get :index
@@ -192,8 +192,8 @@ describe GroupsController do
end
end
- context 'as a guest' do
- it 'redirects to Explore Groups' do
+ context "as a guest" do
+ it "redirects to Explore Groups" do
get :index
expect(response).to redirect_to(explore_groups_path)
@@ -201,9 +201,9 @@ describe GroupsController do
end
end
- describe 'GET #issues' do
- let(:issue_1) { create(:issue, project: project, title: 'foo') }
- let(:issue_2) { create(:issue, project: project, title: 'bar') }
+ describe "GET #issues" do
+ let(:issue_1) { create(:issue, project: project, title: "foo") }
+ let(:issue_2) { create(:issue, project: project, title: "bar") }
before do
create_list(:award_emoji, 3, awardable: issue_2)
@@ -213,46 +213,46 @@ describe GroupsController do
sign_in(user)
end
- context 'sorting by votes' do
- it 'sorts most popular issues' do
- get :issues, params: { id: group.to_param, sort: 'upvotes_desc' }
+ context "sorting by votes" do
+ it "sorts most popular issues" do
+ get :issues, params: {id: group.to_param, sort: "upvotes_desc"}
expect(assigns(:issues)).to eq [issue_2, issue_1]
end
- it 'sorts least popular issues' do
- get :issues, params: { id: group.to_param, sort: 'downvotes_desc' }
+ it "sorts least popular issues" do
+ get :issues, params: {id: group.to_param, sort: "downvotes_desc"}
expect(assigns(:issues)).to eq [issue_2, issue_1]
end
end
- context 'searching' do
+ context "searching" do
before do
# Remove in https://gitlab.com/gitlab-org/gitlab-ce/issues/54643
stub_feature_flags(use_cte_for_group_issues_search: false)
stub_feature_flags(use_subquery_for_group_issues_search: true)
end
- it 'works with popularity sort' do
- get :issues, params: { id: group.to_param, search: 'foo', sort: 'popularity' }
+ it "works with popularity sort" do
+ get :issues, params: {id: group.to_param, search: "foo", sort: "popularity"}
expect(assigns(:issues)).to eq([issue_1])
end
- it 'works with priority sort' do
- get :issues, params: { id: group.to_param, search: 'foo', sort: 'priority' }
+ it "works with priority sort" do
+ get :issues, params: {id: group.to_param, search: "foo", sort: "priority"}
expect(assigns(:issues)).to eq([issue_1])
end
- it 'works with label priority sort' do
- get :issues, params: { id: group.to_param, search: 'foo', sort: 'label_priority' }
+ it "works with label priority sort" do
+ get :issues, params: {id: group.to_param, search: "foo", sort: "label_priority"}
expect(assigns(:issues)).to eq([issue_1])
end
end
end
- describe 'GET #merge_requests' do
+ describe "GET #merge_requests" do
let(:merge_request_1) { create(:merge_request, source_project: project) }
let(:merge_request_2) { create(:merge_request, :simple, source_project: project) }
@@ -264,114 +264,114 @@ describe GroupsController do
sign_in(user)
end
- context 'sorting by votes' do
- it 'sorts most popular merge requests' do
- get :merge_requests, params: { id: group.to_param, sort: 'upvotes_desc' }
+ context "sorting by votes" do
+ it "sorts most popular merge requests" do
+ get :merge_requests, params: {id: group.to_param, sort: "upvotes_desc"}
expect(assigns(:merge_requests)).to eq [merge_request_2, merge_request_1]
end
- it 'sorts least popular merge requests' do
- get :merge_requests, params: { id: group.to_param, sort: 'downvotes_desc' }
+ it "sorts least popular merge requests" do
+ get :merge_requests, params: {id: group.to_param, sort: "downvotes_desc"}
expect(assigns(:merge_requests)).to eq [merge_request_2, merge_request_1]
end
end
end
- describe 'DELETE #destroy' do
- context 'as another user' do
- it 'returns 404' do
+ describe "DELETE #destroy" do
+ context "as another user" do
+ it "returns 404" do
sign_in(create(:user))
- delete :destroy, params: { id: group.to_param }
+ delete :destroy, params: {id: group.to_param}
expect(response.status).to eq(404)
end
end
- context 'as the group owner' do
+ context "as the group owner" do
before do
sign_in(user)
end
- it 'schedules a group destroy' do
+ it "schedules a group destroy" do
Sidekiq::Testing.fake! do
- expect { delete :destroy, params: { id: group.to_param } }.to change(GroupDestroyWorker.jobs, :size).by(1)
+ expect { delete :destroy, params: {id: group.to_param} }.to change(GroupDestroyWorker.jobs, :size).by(1)
end
end
- it 'redirects to the root path' do
- delete :destroy, params: { id: group.to_param }
+ it "redirects to the root path" do
+ delete :destroy, params: {id: group.to_param}
expect(response).to redirect_to(root_path)
end
end
end
- describe 'PUT update' do
+ describe "PUT update" do
before do
sign_in(user)
end
- it 'updates the path successfully' do
- post :update, params: { id: group.to_param, group: { path: 'new_path' } }
+ it "updates the path successfully" do
+ post :update, params: {id: group.to_param, group: {path: "new_path"}}
expect(response).to have_gitlab_http_status(302)
expect(controller).to set_flash[:notice]
end
- it 'does not update the path on error' do
+ it "does not update the path on error" do
allow_any_instance_of(Group).to receive(:move_dir).and_raise(Gitlab::UpdatePathError)
- post :update, params: { id: group.to_param, group: { path: 'new_path' } }
+ post :update, params: {id: group.to_param, group: {path: "new_path"}}
expect(assigns(:group).errors).not_to be_empty
- expect(assigns(:group).path).not_to eq('new_path')
+ expect(assigns(:group).path).not_to eq("new_path")
end
end
- describe '#ensure_canonical_path' do
+ describe "#ensure_canonical_path" do
before do
sign_in(user)
end
- context 'for a GET request' do
- context 'when requesting groups at the root path' do
+ context "for a GET request" do
+ context "when requesting groups at the root path" do
before do
allow(request).to receive(:original_fullpath).and_return("/#{group_full_path}")
- get :show, params: { id: group_full_path }
+ get :show, params: {id: group_full_path}
end
- context 'when requesting the canonical path with different casing' do
+ context "when requesting the canonical path with different casing" do
let(:group_full_path) { group.to_param.upcase }
- it 'redirects to the correct casing' do
+ it "redirects to the correct casing" do
expect(response).to redirect_to(group)
expect(controller).not_to set_flash[:notice]
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
let(:group_full_path) { redirect_route.path }
- it 'redirects to the canonical path' do
+ it "redirects to the canonical path" do
expect(response).to redirect_to(group)
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
- context 'when the old group path is a substring of the scheme or host' do
- let(:redirect_route) { group.redirect_routes.create(path: 'http') }
+ context "when the old group path is a substring of the scheme or host" do
+ let(:redirect_route) { group.redirect_routes.create(path: "http") }
- it 'does not modify the requested host' do
+ it "does not modify the requested host" do
expect(response).to redirect_to(group)
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
- context 'when the old group path is substring of groups' do
+ context "when the old group path is substring of groups" do
# I.e. /groups/oups should not become /grfoo/oups
- let(:redirect_route) { group.redirect_routes.create(path: 'oups') }
+ let(:redirect_route) { group.redirect_routes.create(path: "oups") }
- it 'does not modify the /groups part of the path' do
+ it "does not modify the /groups part of the path" do
expect(response).to redirect_to(group)
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
@@ -379,20 +379,20 @@ describe GroupsController do
end
end
- context 'when requesting groups under the /groups path' do
- context 'when requesting the canonical path' do
- context 'non-show path' do
- context 'with exactly matching casing' do
- it 'does not redirect' do
- get :issues, params: { id: group.to_param }
+ context "when requesting groups under the /groups path" do
+ context "when requesting the canonical path" do
+ context "non-show path" do
+ context "with exactly matching casing" do
+ it "does not redirect" do
+ get :issues, params: {id: group.to_param}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :issues, params: { id: group.to_param.upcase }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :issues, params: {id: group.to_param.upcase}
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).not_to set_flash[:notice]
@@ -400,18 +400,18 @@ describe GroupsController do
end
end
- context 'show path' do
- context 'with exactly matching casing' do
- it 'does not redirect' do
- get :show, params: { id: group.to_param }
+ context "show path" do
+ context "with exactly matching casing" do
+ it "does not redirect" do
+ get :show, params: {id: group.to_param}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'with different casing' do
- it 'redirects to the correct casing at the root path' do
- get :show, params: { id: group.to_param.upcase }
+ context "with different casing" do
+ it "redirects to the correct casing at the root path" do
+ get :show, params: {id: group.to_param.upcase}
expect(response).to redirect_to(group)
expect(controller).not_to set_flash[:notice]
@@ -420,45 +420,45 @@ describe GroupsController do
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
- it 'redirects to the canonical path' do
- get :issues, params: { id: redirect_route.path }
+ it "redirects to the canonical path" do
+ get :issues, params: {id: redirect_route.path}
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
- context 'when the old group path is a substring of the scheme or host' do
- let(:redirect_route) { group.redirect_routes.create(path: 'http') }
+ context "when the old group path is a substring of the scheme or host" do
+ let(:redirect_route) { group.redirect_routes.create(path: "http") }
- it 'does not modify the requested host' do
- get :issues, params: { id: redirect_route.path }
+ it "does not modify the requested host" do
+ get :issues, params: {id: redirect_route.path}
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
- context 'when the old group path is substring of groups' do
+ context "when the old group path is substring of groups" do
# I.e. /groups/oups should not become /grfoo/oups
- let(:redirect_route) { group.redirect_routes.create(path: 'oups') }
+ let(:redirect_route) { group.redirect_routes.create(path: "oups") }
- it 'does not modify the /groups part of the path' do
- get :issues, params: { id: redirect_route.path }
+ it "does not modify the /groups part of the path" do
+ get :issues, params: {id: redirect_route.path}
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
end
end
- context 'when the old group path is substring of groups plus the new path' do
+ context "when the old group path is substring of groups plus the new path" do
# I.e. /groups/oups/oup should not become /grfoos
- let(:redirect_route) { group.redirect_routes.create(path: 'oups/oup') }
+ let(:redirect_route) { group.redirect_routes.create(path: "oups/oup") }
- it 'does not modify the /groups part of the path' do
- get :issues, params: { id: redirect_route.path }
+ it "does not modify the /groups part of the path" do
+ get :issues, params: {id: redirect_route.path}
expect(response).to redirect_to(issues_group_path(group.to_param))
expect(controller).to set_flash[:notice].to(group_moved_message(redirect_route, group))
@@ -467,52 +467,52 @@ describe GroupsController do
end
end
- context 'for a POST request' do
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
- post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
+ context "for a POST request" do
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
+ post :update, params: {id: group.to_param.upcase, group: {path: "new_path"}}
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
- post :update, params: { id: group.to_param.upcase, group: { path: 'new_path' } }
+ it "does not redirect to the correct casing" do
+ post :update, params: {id: group.to_param.upcase, group: {path: "new_path"}}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
- it 'returns not found' do
- post :update, params: { id: redirect_route.path, group: { path: 'new_path' } }
+ it "returns not found" do
+ post :update, params: {id: redirect_route.path, group: {path: "new_path"}}
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'for a DELETE request' do
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
- delete :destroy, params: { id: group.to_param.upcase }
+ context "for a DELETE request" do
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
+ delete :destroy, params: {id: group.to_param.upcase}
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
- delete :destroy, params: { id: group.to_param.upcase }
+ it "does not redirect to the correct casing" do
+ delete :destroy, params: {id: group.to_param.upcase}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { group.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { group.redirect_routes.create(path: "old-path") }
- it 'returns not found' do
- delete :destroy, params: { id: redirect_route.path }
+ it "returns not found" do
+ delete :destroy, params: {id: redirect_route.path}
expect(response).to have_gitlab_http_status(404)
end
@@ -525,12 +525,12 @@ describe GroupsController do
end
end
- describe 'PUT transfer', :postgresql do
+ describe "PUT transfer", :postgresql do
before do
sign_in(user)
end
- context 'when transferring to a subgroup goes right' do
+ context "when transferring to a subgroup goes right" do
let(:new_parent_group) { create(:group, :public) }
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
let!(:new_parent_group_member) { create(:group_member, :owner, group: new_parent_group, user: user) }
@@ -539,20 +539,20 @@ describe GroupsController do
put :transfer,
params: {
id: group.to_param,
- new_parent_group_id: new_parent_group.id
+ new_parent_group_id: new_parent_group.id,
}
end
- it 'should return a notice' do
+ it "should return a notice" do
expect(flash[:notice]).to eq("Group '#{group.name}' was successfully transferred.")
end
- it 'should redirect to the new path' do
+ it "should redirect to the new path" do
expect(response).to redirect_to("/#{new_parent_group.path}/#{group.path}")
end
end
- context 'when converting to a root group goes right' do
+ context "when converting to a root group goes right" do
let(:group) { create(:group, :public, :nested) }
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
@@ -560,44 +560,44 @@ describe GroupsController do
put :transfer,
params: {
id: group.to_param,
- new_parent_group_id: ''
+ new_parent_group_id: "",
}
end
- it 'should return a notice' do
+ it "should return a notice" do
expect(flash[:notice]).to eq("Group '#{group.name}' was successfully transferred.")
end
- it 'should redirect to the new path' do
+ it "should redirect to the new path" do
expect(response).to redirect_to("/#{group.path}")
end
end
- context 'When the transfer goes wrong' do
+ context "When the transfer goes wrong" do
let(:new_parent_group) { create(:group, :public) }
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
let!(:new_parent_group_member) { create(:group_member, :owner, group: new_parent_group, user: user) }
before do
- allow_any_instance_of(::Groups::TransferService).to receive(:proceed_to_transfer).and_raise(Gitlab::UpdatePathError, 'namespace directory cannot be moved')
+ allow_any_instance_of(::Groups::TransferService).to receive(:proceed_to_transfer).and_raise(Gitlab::UpdatePathError, "namespace directory cannot be moved")
put :transfer,
params: {
id: group.to_param,
- new_parent_group_id: new_parent_group.id
+ new_parent_group_id: new_parent_group.id,
}
end
- it 'should return an alert' do
+ it "should return an alert" do
expect(flash[:alert]).to eq "Transfer failed: namespace directory cannot be moved"
end
- it 'should redirect to the current path' do
+ it "should redirect to the current path" do
expect(response).to render_template(:edit)
end
end
- context 'when the user is not allowed to transfer the group' do
+ context "when the user is not allowed to transfer the group" do
let(:new_parent_group) { create(:group, :public) }
let!(:group_member) { create(:group_member, :guest, group: group, user: user) }
let!(:new_parent_group_member) { create(:group_member, :guest, group: new_parent_group, user: user) }
@@ -606,30 +606,30 @@ describe GroupsController do
put :transfer,
params: {
id: group.to_param,
- new_parent_group_id: new_parent_group.id
+ new_parent_group_id: new_parent_group.id,
}
end
- it 'should be denied' do
+ it "should be denied" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'token authentication' do
- it_behaves_like 'authenticates sessionless user', :show, :atom, public: true do
+ context "token authentication" do
+ it_behaves_like "authenticates sessionless user", :show, :atom, public: true do
before do
default_params.merge!(id: group)
end
end
- it_behaves_like 'authenticates sessionless user', :issues, :atom, public: true do
+ it_behaves_like "authenticates sessionless user", :issues, :atom, public: true do
before do
default_params.merge!(id: group, author_id: user.id)
end
end
- it_behaves_like 'authenticates sessionless user', :issues_calendar, :ics, public: true do
+ it_behaves_like "authenticates sessionless user", :issues_calendar, :ics, public: true do
before do
default_params.merge!(id: group)
end
diff --git a/spec/controllers/health_check_controller_spec.rb b/spec/controllers/health_check_controller_spec.rb
index 29e159ad5d7..c3168198437 100644
--- a/spec/controllers/health_check_controller_spec.rb
+++ b/spec/controllers/health_check_controller_spec.rb
@@ -1,135 +1,135 @@
-require 'spec_helper'
+require "spec_helper"
describe HealthCheckController do
include StubENV
let(:json_response) { JSON.parse(response.body) }
- let(:xml_response) { Hash.from_xml(response.body)['hash'] }
+ let(:xml_response) { Hash.from_xml(response.body)["hash"] }
let(:token) { Gitlab::CurrentSettings.health_check_access_token }
- let(:whitelisted_ip) { '127.0.0.1' }
- let(:not_whitelisted_ip) { '127.0.0.2' }
+ let(:whitelisted_ip) { "127.0.0.1" }
+ let(:not_whitelisted_ip) { "127.0.0.2" }
before do
allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- describe 'GET #index' do
- context 'when services are up but accessed from outside whitelisted ips' do
+ describe "GET #index" do
+ context "when services are up but accessed from outside whitelisted ips" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(not_whitelisted_ip)
end
- it 'returns a not found page' do
+ it "returns a not found page" do
get :index
expect(response).to be_not_found
end
- context 'when services are accessed with token' do
- it 'supports passing the token in the header' do
- request.headers['TOKEN'] = token
+ context "when services are accessed with token" do
+ it "supports passing the token in the header" do
+ request.headers["TOKEN"] = token
get :index
expect(response).to be_success
- expect(response.content_type).to eq 'text/plain'
+ expect(response.content_type).to eq "text/plain"
end
- it 'supports passing the token in query params' do
- get :index, params: { token: token }
+ it "supports passing the token in query params" do
+ get :index, params: {token: token}
expect(response).to be_success
- expect(response.content_type).to eq 'text/plain'
+ expect(response.content_type).to eq "text/plain"
end
end
end
- context 'when services are up and accessed from whitelisted ips' do
+ context "when services are up and accessed from whitelisted ips" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(whitelisted_ip)
end
- it 'supports successful plaintext response' do
+ it "supports successful plaintext response" do
get :index
expect(response).to be_success
- expect(response.content_type).to eq 'text/plain'
+ expect(response.content_type).to eq "text/plain"
end
- it 'supports successful json response' do
+ it "supports successful json response" do
get :index, format: :json
expect(response).to be_success
- expect(response.content_type).to eq 'application/json'
- expect(json_response['healthy']).to be true
+ expect(response.content_type).to eq "application/json"
+ expect(json_response["healthy"]).to be true
end
- it 'supports successful xml response' do
+ it "supports successful xml response" do
get :index, format: :xml
expect(response).to be_success
- expect(response.content_type).to eq 'application/xml'
- expect(xml_response['healthy']).to be true
+ expect(response.content_type).to eq "application/xml"
+ expect(xml_response["healthy"]).to be true
end
- it 'supports successful responses for specific checks' do
- get :index, params: { checks: 'email' }, format: :json
+ it "supports successful responses for specific checks" do
+ get :index, params: {checks: "email"}, format: :json
expect(response).to be_success
- expect(response.content_type).to eq 'application/json'
- expect(json_response['healthy']).to be true
+ expect(response.content_type).to eq "application/json"
+ expect(json_response["healthy"]).to be true
end
end
- context 'when a service is down but NO access token' do
- it 'returns a not found page' do
+ context "when a service is down but NO access token" do
+ it "returns a not found page" do
get :index
expect(response).to be_not_found
end
end
- context 'when a service is down and an endpoint is accessed from whitelisted ip' do
+ context "when a service is down and an endpoint is accessed from whitelisted ip" do
before do
- allow(HealthCheck::Utils).to receive(:process_checks).with(['standard']).and_return('The server is on fire')
- allow(HealthCheck::Utils).to receive(:process_checks).with(['email']).and_return('Email is on fire')
+ allow(HealthCheck::Utils).to receive(:process_checks).with(["standard"]).and_return("The server is on fire")
+ allow(HealthCheck::Utils).to receive(:process_checks).with(["email"]).and_return("Email is on fire")
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(whitelisted_ip)
end
- it 'supports failure plaintext response' do
+ it "supports failure plaintext response" do
get :index
expect(response).to have_gitlab_http_status(500)
- expect(response.content_type).to eq 'text/plain'
- expect(response.body).to include('The server is on fire')
+ expect(response.content_type).to eq "text/plain"
+ expect(response.body).to include("The server is on fire")
end
- it 'supports failure json response' do
+ it "supports failure json response" do
get :index, format: :json
expect(response).to have_gitlab_http_status(500)
- expect(response.content_type).to eq 'application/json'
- expect(json_response['healthy']).to be false
- expect(json_response['message']).to include('The server is on fire')
+ expect(response.content_type).to eq "application/json"
+ expect(json_response["healthy"]).to be false
+ expect(json_response["message"]).to include("The server is on fire")
end
- it 'supports failure xml response' do
+ it "supports failure xml response" do
get :index, format: :xml
expect(response).to have_gitlab_http_status(500)
- expect(response.content_type).to eq 'application/xml'
- expect(xml_response['healthy']).to be false
- expect(xml_response['message']).to include('The server is on fire')
+ expect(response.content_type).to eq "application/xml"
+ expect(xml_response["healthy"]).to be false
+ expect(xml_response["message"]).to include("The server is on fire")
end
- it 'supports failure responses for specific checks' do
- get :index, params: { checks: 'email' }, format: :json
+ it "supports failure responses for specific checks" do
+ get :index, params: {checks: "email"}, format: :json
expect(response).to have_gitlab_http_status(500)
- expect(response.content_type).to eq 'application/json'
- expect(json_response['healthy']).to be false
- expect(json_response['message']).to include('Email is on fire')
+ expect(response.content_type).to eq "application/json"
+ expect(json_response["healthy"]).to be false
+ expect(json_response["message"]).to include("Email is on fire")
end
end
end
diff --git a/spec/controllers/health_controller_spec.rb b/spec/controllers/health_controller_spec.rb
index f685f2b41c0..e34f9afa11f 100644
--- a/spec/controllers/health_controller_spec.rb
+++ b/spec/controllers/health_controller_spec.rb
@@ -1,118 +1,118 @@
-require 'spec_helper'
+require "spec_helper"
describe HealthController do
include StubENV
let(:json_response) { JSON.parse(response.body) }
let(:token) { Gitlab::CurrentSettings.health_check_access_token }
- let(:whitelisted_ip) { '127.0.0.1' }
- let(:not_whitelisted_ip) { '127.0.0.2' }
+ let(:whitelisted_ip) { "127.0.0.1" }
+ let(:not_whitelisted_ip) { "127.0.0.2" }
before do
allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip])
stub_storage_settings({}) # Hide the broken storage
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- describe '#readiness' do
- shared_context 'endpoint responding with readiness data' do
+ describe "#readiness" do
+ shared_context "endpoint responding with readiness data" do
let(:request_params) { {} }
subject { get :readiness, params: request_params }
- it 'responds with readiness checks data' do
+ it "responds with readiness checks data" do
subject
- expect(json_response['db_check']['status']).to eq('ok')
- expect(json_response['cache_check']['status']).to eq('ok')
- expect(json_response['queues_check']['status']).to eq('ok')
- expect(json_response['shared_state_check']['status']).to eq('ok')
- expect(json_response['gitaly_check']['status']).to eq('ok')
+ expect(json_response["db_check"]["status"]).to eq("ok")
+ expect(json_response["cache_check"]["status"]).to eq("ok")
+ expect(json_response["queues_check"]["status"]).to eq("ok")
+ expect(json_response["shared_state_check"]["status"]).to eq("ok")
+ expect(json_response["gitaly_check"]["status"]).to eq("ok")
end
end
- context 'accessed from whitelisted ip' do
+ context "accessed from whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(whitelisted_ip)
end
- it_behaves_like 'endpoint responding with readiness data'
+ it_behaves_like "endpoint responding with readiness data"
end
- context 'accessed from not whitelisted ip' do
+ context "accessed from not whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(not_whitelisted_ip)
end
- it 'responds with resource not found' do
+ it "responds with resource not found" do
get :readiness
expect(response.status).to eq(404)
end
- context 'accessed with valid token' do
- context 'token passed in request header' do
+ context "accessed with valid token" do
+ context "token passed in request header" do
before do
- request.headers['TOKEN'] = token
+ request.headers["TOKEN"] = token
end
- it_behaves_like 'endpoint responding with readiness data'
+ it_behaves_like "endpoint responding with readiness data"
end
end
- context 'token passed as URL param' do
- it_behaves_like 'endpoint responding with readiness data' do
- let(:request_params) { { token: token } }
+ context "token passed as URL param" do
+ it_behaves_like "endpoint responding with readiness data" do
+ let(:request_params) { {token: token} }
end
end
end
end
- describe '#liveness' do
- shared_context 'endpoint responding with liveness data' do
+ describe "#liveness" do
+ shared_context "endpoint responding with liveness data" do
subject { get :liveness }
- it 'responds with liveness checks data' do
+ it "responds with liveness checks data" do
subject
- expect(json_response['db_check']['status']).to eq('ok')
- expect(json_response['cache_check']['status']).to eq('ok')
- expect(json_response['queues_check']['status']).to eq('ok')
- expect(json_response['shared_state_check']['status']).to eq('ok')
+ expect(json_response["db_check"]["status"]).to eq("ok")
+ expect(json_response["cache_check"]["status"]).to eq("ok")
+ expect(json_response["queues_check"]["status"]).to eq("ok")
+ expect(json_response["shared_state_check"]["status"]).to eq("ok")
end
end
- context 'accessed from whitelisted ip' do
+ context "accessed from whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(whitelisted_ip)
end
- it_behaves_like 'endpoint responding with liveness data'
+ it_behaves_like "endpoint responding with liveness data"
end
- context 'accessed from not whitelisted ip' do
+ context "accessed from not whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(not_whitelisted_ip)
end
- it 'responds with resource not found' do
+ it "responds with resource not found" do
get :liveness
expect(response.status).to eq(404)
end
- context 'accessed with valid token' do
- context 'token passed in request header' do
+ context "accessed with valid token" do
+ context "token passed in request header" do
before do
- request.headers['TOKEN'] = token
+ request.headers["TOKEN"] = token
end
- it_behaves_like 'endpoint responding with liveness data'
+ it_behaves_like "endpoint responding with liveness data"
end
- context 'token passed as URL param' do
- it_behaves_like 'endpoint responding with liveness data' do
- subject { get :liveness, params: { token: token } }
+ context "token passed as URL param" do
+ it_behaves_like "endpoint responding with liveness data" do
+ subject { get :liveness, params: {token: token} }
end
end
end
diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb
index dca67c18caa..573297cbc0b 100644
--- a/spec/controllers/help_controller_spec.rb
+++ b/spec/controllers/help_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe HelpController do
let(:user) { create(:user) }
@@ -7,144 +7,144 @@ describe HelpController do
sign_in(user)
end
- describe 'GET #index' do
- context 'with absolute url' do
- it 'keeps the URL absolute' do
+ describe "GET #index" do
+ context "with absolute url" do
+ it "keeps the URL absolute" do
stub_readme("[API](/api/README.md)")
get :index
- expect(assigns[:help_index]).to eq '[API](/api/README.md)'
+ expect(assigns[:help_index]).to eq "[API](/api/README.md)"
end
end
- context 'with relative url' do
- it 'prefixes it with /help/' do
+ context "with relative url" do
+ it "prefixes it with /help/" do
stub_readme("[API](api/README.md)")
get :index
- expect(assigns[:help_index]).to eq '[API](/help/api/README.md)'
+ expect(assigns[:help_index]).to eq "[API](/help/api/README.md)"
end
end
- context 'when url is an external link' do
- it 'does not change it' do
+ context "when url is an external link" do
+ it "does not change it" do
stub_readme("[external](https://some.external.link)")
get :index
- expect(assigns[:help_index]).to eq '[external](https://some.external.link)'
+ expect(assigns[:help_index]).to eq "[external](https://some.external.link)"
end
end
- context 'when relative url with external on same line' do
- it 'prefix it with /help/' do
+ context "when relative url with external on same line" do
+ it "prefix it with /help/" do
stub_readme("[API](api/README.md) [external](https://some.external.link)")
get :index
- expect(assigns[:help_index]).to eq '[API](/help/api/README.md) [external](https://some.external.link)'
+ expect(assigns[:help_index]).to eq "[API](/help/api/README.md) [external](https://some.external.link)"
end
end
- context 'when relative url with http:// in query' do
- it 'prefix it with /help/' do
+ context "when relative url with http:// in query" do
+ it "prefix it with /help/" do
stub_readme("[API](api/README.md?go=https://example.com/)")
get :index
- expect(assigns[:help_index]).to eq '[API](/help/api/README.md?go=https://example.com/)'
+ expect(assigns[:help_index]).to eq "[API](/help/api/README.md?go=https://example.com/)"
end
end
- context 'when mailto URL' do
- it 'do not change it' do
+ context "when mailto URL" do
+ it "do not change it" do
stub_readme("[report bug](mailto:bugs@example.com)")
get :index
- expect(assigns[:help_index]).to eq '[report bug](mailto:bugs@example.com)'
+ expect(assigns[:help_index]).to eq "[report bug](mailto:bugs@example.com)"
end
end
- context 'when protocol-relative link' do
- it 'do not change it' do
+ context "when protocol-relative link" do
+ it "do not change it" do
stub_readme("[protocol-relative](//example.com)")
get :index
- expect(assigns[:help_index]).to eq '[protocol-relative](//example.com)'
+ expect(assigns[:help_index]).to eq "[protocol-relative](//example.com)"
end
end
end
- describe 'GET #show' do
- context 'for Markdown formats' do
- context 'when requested file exists' do
+ describe "GET #show" do
+ context "for Markdown formats" do
+ context "when requested file exists" do
before do
- get :show, params: { path: 'ssh/README' }, format: :md
+ get :show, params: {path: "ssh/README"}, format: :md
end
- it 'assigns to @markdown' do
+ it "assigns to @markdown" do
expect(assigns[:markdown]).not_to be_empty
end
- it 'renders HTML' do
- expect(response).to render_template('show.html.haml')
- expect(response.content_type).to eq 'text/html'
+ it "renders HTML" do
+ expect(response).to render_template("show.html.haml")
+ expect(response.content_type).to eq "text/html"
end
end
- context 'when requested file is missing' do
- it 'renders not found' do
- get :show, params: { path: 'foo/bar' }, format: :md
+ context "when requested file is missing" do
+ it "renders not found" do
+ get :show, params: {path: "foo/bar"}, format: :md
expect(response).to be_not_found
end
end
end
- context 'for image formats' do
- context 'when requested file exists' do
- it 'renders the raw file' do
+ context "for image formats" do
+ context "when requested file exists" do
+ it "renders the raw file" do
get :show,
- params: {
- path: 'user/project/img/labels_default'
- },
- format: :png
+ params: {
+ path: "user/project/img/labels_default",
+ },
+ format: :png
expect(response).to be_success
- expect(response.content_type).to eq 'image/png'
- expect(response.headers['Content-Disposition']).to match(/^inline;/)
+ expect(response.content_type).to eq "image/png"
+ expect(response.headers["Content-Disposition"]).to match(/^inline;/)
end
end
- context 'when requested file is missing' do
- it 'renders not found' do
+ context "when requested file is missing" do
+ it "renders not found" do
get :show,
- params: {
- path: 'foo/bar'
- },
- format: :png
+ params: {
+ path: "foo/bar",
+ },
+ format: :png
expect(response).to be_not_found
end
end
end
- context 'for other formats' do
- it 'always renders not found' do
+ context "for other formats" do
+ it "always renders not found" do
get :show,
- params: {
- path: 'ssh/README'
- },
- format: :foo
+ params: {
+ path: "ssh/README",
+ },
+ format: :foo
expect(response).to be_not_found
end
end
end
- describe 'GET #ui' do
- context 'for UI Development Kit' do
- it 'renders found' do
+ describe "GET #ui" do
+ context "for UI Development Kit" do
+ it "renders found" do
get :ui
expect(response).to have_gitlab_http_status(200)
end
diff --git a/spec/controllers/import/bitbucket_controller_spec.rb b/spec/controllers/import/bitbucket_controller_spec.rb
index 0bc09c86939..8081d8f9947 100644
--- a/spec/controllers/import/bitbucket_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::BitbucketController do
include ImportSpecHelper
@@ -7,7 +7,7 @@ describe Import::BitbucketController do
let(:token) { "asdasd12345" }
let(:secret) { "sekrettt" }
let(:refresh_token) { SecureRandom.hex(15) }
- let(:access_params) { { token: token, expires_at: nil, expires_in: nil, refresh_token: nil } }
+ let(:access_params) { {token: token, expires_at: nil, expires_in: nil, refresh_token: nil} }
let(:code) { SecureRandom.hex(8) }
def assign_session_tokens
@@ -35,14 +35,15 @@ describe Import::BitbucketController do
allow_any_instance_of(OAuth2::Client)
.to receive(:get_token)
.with(hash_including(
- 'grant_type' => 'authorization_code',
- 'code' => code,
- redirect_uri: users_import_bitbucket_callback_url),
- {})
+ "grant_type" => "authorization_code",
+ "code" => code,
+ :redirect_uri => users_import_bitbucket_callback_url
+ ),
+ {})
.and_return(access_token)
- stub_omniauth_provider('bitbucket')
+ stub_omniauth_provider("bitbucket")
- get :callback, params: { code: code }
+ get :callback, params: {code: code}
expect(session[:bitbucket_token]).to eq(token)
expect(session[:bitbucket_refresh_token]).to eq(refresh_token)
@@ -54,12 +55,12 @@ describe Import::BitbucketController do
describe "GET status" do
before do
- @repo = double(slug: 'vim', owner: 'asd', full_name: 'asd/vim', "valid?" => true)
+ @repo = double(:slug => "vim", :owner => "asd", :full_name => "asd/vim", "valid?" => true)
assign_session_tokens
end
it "assigns variables" do
- @project = create(:project, import_type: 'bitbucket', creator_id: user.id)
+ @project = create(:project, import_type: "bitbucket", creator_id: user.id)
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
@@ -70,7 +71,7 @@ describe Import::BitbucketController do
end
it "does not show already added project" do
- @project = create(:project, import_type: 'bitbucket', creator_id: user.id, import_source: 'asd/vim')
+ @project = create(:project, import_type: "bitbucket", creator_id: user.id, import_source: "asd/vim")
allow_any_instance_of(Bitbucket::Client).to receive(:repos).and_return([@repo])
get :status
@@ -88,7 +89,7 @@ describe Import::BitbucketController do
end
let(:bitbucket_repo) do
- double(slug: "vim", owner: bitbucket_username, name: 'vim')
+ double(slug: "vim", owner: bitbucket_username, name: "vim")
end
let(:project) { create(:project) }
@@ -99,7 +100,7 @@ describe Import::BitbucketController do
assign_session_tokens
end
- it 'returns 200 response when the project is imported successfully' do
+ it "returns 200 response when the project is imported successfully" do
allow(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params)
.and_return(double(execute: project))
@@ -109,7 +110,7 @@ describe Import::BitbucketController do
expect(response).to have_gitlab_http_status(200)
end
- it 'returns 422 response when the project could not be imported' do
+ it "returns 422 response when the project could not be imported" do
allow(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, bitbucket_repo.name, user.namespace, user, access_params)
.and_return(double(execute: build(:project)))
@@ -142,10 +143,10 @@ describe Import::BitbucketController do
end
end
- context 'when the Bitbucket user is unauthorized' do
+ context "when the Bitbucket user is unauthorized" do
render_views
- it 'returns unauthorized' do
+ it "returns unauthorized" do
allow(controller).to receive(:current_user).and_return(user)
allow(user).to receive(:can?).and_return(false)
@@ -229,87 +230,87 @@ describe Import::BitbucketController do
end
end
- context 'user has chosen an existing nested namespace and name for the project', :postgresql do
- let(:parent_namespace) { create(:group, name: 'foo') }
- let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
- let(:test_name) { 'test_name' }
+ context "user has chosen an existing nested namespace and name for the project", :postgresql do
+ let(:parent_namespace) { create(:group, name: "foo") }
+ let(:nested_namespace) { create(:group, name: "bar", parent: parent_namespace) }
+ let(:test_name) { "test_name" }
before do
parent_namespace.add_owner(user)
nested_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, nested_namespace, user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: nested_namespace.full_path, new_name: test_name }, format: :json
+ post :create, params: {target_namespace: nested_namespace.full_path, new_name: test_name}, format: :json
end
end
- context 'user has chosen a non-existent nested namespaces and name for the project', :postgresql do
- let(:test_name) { 'test_name' }
+ context "user has chosen a non-existent nested namespaces and name for the project", :postgresql do
+ let(:test_name) { "test_name" }
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json }
.to change { Namespace.count }.by(2)
end
- it 'new namespace has the right parent' do
+ it "new namespace has the right parent" do
allow(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json
- expect(Namespace.find_by_path_or_name('bar').parent.path).to eq('foo')
+ expect(Namespace.find_by_path_or_name("bar").parent.path).to eq("foo")
end
end
- context 'user has chosen existent and non-existent nested namespaces and name for the project', :postgresql do
- let(:test_name) { 'test_name' }
- let!(:parent_namespace) { create(:group, name: 'foo') }
+ context "user has chosen existent and non-existent nested namespaces and name for the project", :postgresql do
+ let(:test_name) { "test_name" }
+ let!(:parent_namespace) { create(:group, name: "foo") }
before do
parent_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::BitbucketImport::ProjectCreator)
.to receive(:new).with(bitbucket_repo, test_name, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :json }
.to change { Namespace.count }.by(2)
end
end
- context 'when user can not create projects in the chosen namespace' do
- it 'returns 422 response' do
- other_namespace = create(:group, name: 'other_namespace')
+ context "when user can not create projects in the chosen namespace" do
+ it "returns 422 response" do
+ other_namespace = create(:group, name: "other_namespace")
- post :create, params: { target_namespace: other_namespace.name }, format: :json
+ post :create, params: {target_namespace: other_namespace.name}, format: :json
expect(response).to have_gitlab_http_status(422)
end
diff --git a/spec/controllers/import/bitbucket_server_controller_spec.rb b/spec/controllers/import/bitbucket_server_controller_spec.rb
index a125e6ed16d..93f0a84baa7 100644
--- a/spec/controllers/import/bitbucket_server_controller_spec.rb
+++ b/spec/controllers/import/bitbucket_server_controller_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::BitbucketServerController do
let(:user) { create(:user) }
- let(:project_key) { 'test-project' }
- let(:repo_slug) { 'some-repo' }
+ let(:project_key) { "test-project" }
+ let(:repo_slug) { "some-repo" }
let(:client) { instance_double(BitbucketServer::Client) }
def assign_session_tokens
- session[:bitbucket_server_url] = 'http://localhost:7990'
- session[:bitbucket_server_username] = 'bitbucket'
- session[:bitbucket_server_personal_access_token] = 'some-token'
+ session[:bitbucket_server_url] = "http://localhost:7990"
+ session[:bitbucket_server_username] = "bitbucket"
+ session[:bitbucket_server_personal_access_token] = "some-token"
end
before do
@@ -17,17 +17,17 @@ describe Import::BitbucketServerController do
allow(controller).to receive(:bitbucket_server_import_enabled?).and_return(true)
end
- describe 'GET new' do
+ describe "GET new" do
render_views
- it 'shows the input form' do
+ it "shows the input form" do
get :new
- expect(response.body).to have_text('Bitbucket Server URL')
+ expect(response.body).to have_text("Bitbucket Server URL")
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:project_name) { "my-project_123" }
before do
@@ -39,56 +39,56 @@ describe Import::BitbucketServerController do
set(:project) { create(:project) }
- it 'returns the new project' do
+ it "returns the new project" do
allow(Gitlab::BitbucketServerImport::ProjectCreator)
.to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything)
.and_return(double(execute: project))
- post :create, params: { project: project_key, repository: repo_slug }, format: :json
+ post :create, params: {project: project_key, repository: repo_slug}, format: :json
expect(response).to have_gitlab_http_status(200)
end
- context 'with project key with tildes' do
- let(:project_key) { '~someuser_123' }
+ context "with project key with tildes" do
+ let(:project_key) { "~someuser_123" }
- it 'successfully creates a project' do
+ it "successfully creates a project" do
allow(Gitlab::BitbucketServerImport::ProjectCreator)
.to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything)
.and_return(double(execute: project))
- post :create, params: { project: project_key, repository: repo_slug, format: :json }
+ post :create, params: {project: project_key, repository: repo_slug, format: :json}
expect(response).to have_gitlab_http_status(200)
end
end
- it 'returns an error when an invalid project key is used' do
- post :create, params: { project: 'some&project' }
+ it "returns an error when an invalid project key is used" do
+ post :create, params: {project: "some&project"}
expect(response).to have_gitlab_http_status(422)
end
- it 'returns an error when an invalid repository slug is used' do
- post :create, params: { project: 'some-project', repository: 'try*this' }
+ it "returns an error when an invalid repository slug is used" do
+ post :create, params: {project: "some-project", repository: "try*this"}
expect(response).to have_gitlab_http_status(422)
end
- it 'returns an error when the project cannot be found' do
+ it "returns an error when the project cannot be found" do
allow(client).to receive(:repo).with(project_key, repo_slug).and_return(nil)
- post :create, params: { project: project_key, repository: repo_slug }, format: :json
+ post :create, params: {project: project_key, repository: repo_slug}, format: :json
expect(response).to have_gitlab_http_status(422)
end
- it 'returns an error when the project cannot be saved' do
+ it "returns an error when the project cannot be saved" do
allow(Gitlab::BitbucketServerImport::ProjectCreator)
.to receive(:new).with(project_key, repo_slug, anything, project_name, user.namespace, user, anything)
.and_return(double(execute: build(:project)))
- post :create, params: { project: project_key, repository: repo_slug }, format: :json
+ post :create, params: {project: project_key, repository: repo_slug}, format: :json
expect(response).to have_gitlab_http_status(422)
end
@@ -96,18 +96,18 @@ describe Import::BitbucketServerController do
it "returns an error when the server can't be contacted" do
expect(client).to receive(:repo).with(project_key, repo_slug).and_raise(::BitbucketServer::Connection::ConnectionError)
- post :create, params: { project: project_key, repository: repo_slug }, format: :json
+ post :create, params: {project: project_key, repository: repo_slug}, format: :json
expect(response).to have_gitlab_http_status(422)
end
end
- describe 'POST configure' do
- let(:token) { 'token' }
- let(:username) { 'bitbucket-user' }
- let(:url) { 'http://localhost:7990/bitbucket' }
+ describe "POST configure" do
+ let(:token) { "token" }
+ let(:username) { "bitbucket-user" }
+ let(:url) { "http://localhost:7990/bitbucket" }
- it 'clears out existing session' do
+ it "clears out existing session" do
post :configure
expect(session[:bitbucket_server_url]).to be_nil
@@ -118,8 +118,8 @@ describe Import::BitbucketServerController do
expect(response).to redirect_to(status_import_bitbucket_server_path)
end
- it 'sets the session variables' do
- post :configure, params: { personal_access_token: token, bitbucket_username: username, bitbucket_server_url: url }
+ it "sets the session variables" do
+ post :configure, params: {personal_access_token: token, bitbucket_username: username, bitbucket_server_url: url}
expect(session[:bitbucket_server_url]).to eq(url)
expect(session[:bitbucket_server_username]).to eq(username)
@@ -129,20 +129,20 @@ describe Import::BitbucketServerController do
end
end
- describe 'GET status' do
+ describe "GET status" do
render_views
before do
allow(controller).to receive(:bitbucket_client).and_return(client)
- @repo = double(slug: 'vim', project_key: 'asd', full_name: 'asd/vim', "valid?" => true, project_name: 'asd', browse_url: 'http://test', name: 'vim')
- @invalid_repo = double(slug: 'invalid', project_key: 'foobar', full_name: 'asd/foobar', "valid?" => false, browse_url: 'http://bad-repo')
- @created_repo = double(slug: 'created', project_key: 'existing', full_name: 'group/created', "valid?" => true, browse_url: 'http://existing')
+ @repo = double(:slug => "vim", :project_key => "asd", :full_name => "asd/vim", "valid?" => true, :project_name => "asd", :browse_url => "http://test", :name => "vim")
+ @invalid_repo = double(:slug => "invalid", :project_key => "foobar", :full_name => "asd/foobar", "valid?" => false, :browse_url => "http://bad-repo")
+ @created_repo = double(:slug => "created", :project_key => "existing", :full_name => "group/created", "valid?" => true, :browse_url => "http://existing")
assign_session_tokens
end
- it 'assigns repository categories' do
- created_project = create(:project, :import_finished, import_type: 'bitbucket_server', creator_id: user.id, import_source: @created_repo.browse_url)
+ it "assigns repository categories" do
+ created_project = create(:project, :import_finished, import_type: "bitbucket_server", creator_id: user.id, import_source: @created_repo.browse_url)
repos = instance_double(BitbucketServer::Collection)
expect(repos).to receive(:partition).and_return([[@repo, @created_repo], [@invalid_repo]])
@@ -159,19 +159,19 @@ describe Import::BitbucketServerController do
end
end
- describe 'GET jobs' do
+ describe "GET jobs" do
before do
assign_session_tokens
end
- it 'returns a list of imported projects' do
- created_project = create(:project, import_type: 'bitbucket_server', creator_id: user.id)
+ it "returns a list of imported projects" do
+ created_project = create(:project, import_type: "bitbucket_server", creator_id: user.id)
get :jobs
expect(json_response.count).to eq(1)
- expect(json_response.first['id']).to eq(created_project.id)
- expect(json_response.first['import_status']).to eq('none')
+ expect(json_response.first["id"]).to eq(created_project.id)
+ expect(json_response.first["import_status"]).to eq("none")
end
end
end
diff --git a/spec/controllers/import/fogbugz_controller_spec.rb b/spec/controllers/import/fogbugz_controller_spec.rb
index 5f0f6dea821..17a5ac69771 100644
--- a/spec/controllers/import/fogbugz_controller_spec.rb
+++ b/spec/controllers/import/fogbugz_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::FogbugzController do
include ImportSpecHelper
@@ -9,14 +9,14 @@ describe Import::FogbugzController do
sign_in(user)
end
- describe 'GET status' do
+ describe "GET status" do
before do
- @repo = OpenStruct.new(name: 'vim')
+ @repo = OpenStruct.new(name: "vim")
stub_client(valid?: true)
end
- it 'assigns variables' do
- @project = create(:project, import_type: 'fogbugz', creator_id: user.id)
+ it "assigns variables" do
+ @project = create(:project, import_type: "fogbugz", creator_id: user.id)
stub_client(repos: [@repo])
get :status
@@ -25,8 +25,8 @@ describe Import::FogbugzController do
expect(assigns(:repos)).to eq([@repo])
end
- it 'does not show already added project' do
- @project = create(:project, import_type: 'fogbugz', creator_id: user.id, import_source: 'vim')
+ it "does not show already added project" do
+ @project = create(:project, import_type: "fogbugz", creator_id: user.id, import_source: "vim")
stub_client(repos: [@repo])
get :status
diff --git a/spec/controllers/import/gitea_controller_spec.rb b/spec/controllers/import/gitea_controller_spec.rb
index 8cbec79095f..19c049596db 100644
--- a/spec/controllers/import/gitea_controller_spec.rb
+++ b/spec/controllers/import/gitea_controller_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::GiteaController do
include ImportSpecHelper
let(:provider) { :gitea }
- let(:host_url) { 'https://try.gitea.io' }
+ let(:host_url) { "https://try.gitea.io" }
- include_context 'a GitHub-ish import controller'
+ include_context "a GitHub-ish import controller"
def assign_host_url
session[:gitea_host_url] = host_url
end
describe "GET new" do
- it_behaves_like 'a GitHub-ish import controller: GET new' do
+ it_behaves_like "a GitHub-ish import controller: GET new" do
before do
assign_host_url
end
@@ -21,20 +21,20 @@ describe Import::GiteaController do
end
describe "POST personal_access_token" do
- it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
+ it_behaves_like "a GitHub-ish import controller: POST personal_access_token"
end
describe "GET status" do
- it_behaves_like 'a GitHub-ish import controller: GET status' do
+ it_behaves_like "a GitHub-ish import controller: GET status" do
before do
assign_host_url
end
- let(:extra_assign_expectations) { { gitea_host_url: host_url } }
+ let(:extra_assign_expectations) { {gitea_host_url: host_url} }
end
end
- describe 'POST create' do
- it_behaves_like 'a GitHub-ish import controller: POST create' do
+ describe "POST create" do
+ it_behaves_like "a GitHub-ish import controller: POST create" do
before do
assign_host_url
end
@@ -42,7 +42,7 @@ describe Import::GiteaController do
end
describe "GET realtime_changes" do
- it_behaves_like 'a GitHub-ish import controller: GET realtime_changes' do
+ it_behaves_like "a GitHub-ish import controller: GET realtime_changes" do
before do
assign_host_url
end
diff --git a/spec/controllers/import/github_controller_spec.rb b/spec/controllers/import/github_controller_spec.rb
index 162dff98ec5..356bd7437da 100644
--- a/spec/controllers/import/github_controller_spec.rb
+++ b/spec/controllers/import/github_controller_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::GithubController do
include ImportSpecHelper
let(:provider) { :github }
- include_context 'a GitHub-ish import controller'
+ include_context "a GitHub-ish import controller"
describe "GET new" do
- it_behaves_like 'a GitHub-ish import controller: GET new'
+ it_behaves_like "a GitHub-ish import controller: GET new"
it "redirects to GitHub for an access token if logged in with GitHub" do
allow(controller).to receive(:logged_in_with_provider?).and_return(true)
@@ -40,7 +40,7 @@ describe Import::GithubController do
.to receive(:get_token).and_return(token)
allow_any_instance_of(Gitlab::LegacyGithubImport::Client)
.to receive(:github_options).and_return({})
- stub_omniauth_provider('github')
+ stub_omniauth_provider("github")
get :callback
@@ -50,18 +50,18 @@ describe Import::GithubController do
end
describe "POST personal_access_token" do
- it_behaves_like 'a GitHub-ish import controller: POST personal_access_token'
+ it_behaves_like "a GitHub-ish import controller: POST personal_access_token"
end
describe "GET status" do
- it_behaves_like 'a GitHub-ish import controller: GET status'
+ it_behaves_like "a GitHub-ish import controller: GET status"
end
describe "POST create" do
- it_behaves_like 'a GitHub-ish import controller: POST create'
+ it_behaves_like "a GitHub-ish import controller: POST create"
end
describe "GET realtime_changes" do
- it_behaves_like 'a GitHub-ish import controller: GET realtime_changes'
+ it_behaves_like "a GitHub-ish import controller: GET realtime_changes"
end
end
diff --git a/spec/controllers/import/gitlab_controller_spec.rb b/spec/controllers/import/gitlab_controller_spec.rb
index a874a7d36f6..fd4fb74df3d 100644
--- a/spec/controllers/import/gitlab_controller_spec.rb
+++ b/spec/controllers/import/gitlab_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::GitlabController do
include ImportSpecHelper
let(:user) { create(:user) }
let(:token) { "asdasd12345" }
- let(:access_params) { { gitlab_access_token: token } }
+ let(:access_params) { {gitlab_access_token: token} }
def assign_session_token
session[:gitlab_access_token] = token
@@ -20,7 +20,7 @@ describe Import::GitlabController do
it "updates access token" do
allow_any_instance_of(Gitlab::GitlabImport::Client)
.to receive(:get_token).and_return(token)
- stub_omniauth_provider('gitlab')
+ stub_omniauth_provider("gitlab")
get :callback
@@ -31,12 +31,12 @@ describe Import::GitlabController do
describe "GET status" do
before do
- @repo = OpenStruct.new(path: 'vim', path_with_namespace: 'asd/vim')
+ @repo = OpenStruct.new(path: "vim", path_with_namespace: "asd/vim")
assign_session_token
end
it "assigns variables" do
- @project = create(:project, import_type: 'gitlab', creator_id: user.id)
+ @project = create(:project, import_type: "gitlab", creator_id: user.id)
stub_client(projects: [@repo])
get :status
@@ -46,7 +46,7 @@ describe Import::GitlabController do
end
it "does not show already added project" do
- @project = create(:project, import_type: 'gitlab', creator_id: user.id, import_source: 'asd/vim')
+ @project = create(:project, import_type: "gitlab", creator_id: user.id, import_source: "asd/vim")
stub_client(projects: [@repo])
get :status
@@ -60,14 +60,14 @@ describe Import::GitlabController do
let(:project) { create(:project) }
let(:gitlab_username) { user.username }
let(:gitlab_user) do
- { username: gitlab_username }.with_indifferent_access
+ {username: gitlab_username}.with_indifferent_access
end
let(:gitlab_repo) do
{
- path: 'vim',
+ path: "vim",
path_with_namespace: "#{gitlab_username}/vim",
- owner: { name: gitlab_username },
- namespace: { path: gitlab_username }
+ owner: {name: gitlab_username},
+ namespace: {path: gitlab_username},
}.with_indifferent_access
end
@@ -76,7 +76,7 @@ describe Import::GitlabController do
assign_session_token
end
- it 'returns 200 response when the project is imported successfully' do
+ it "returns 200 response when the project is imported successfully" do
allow(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
.and_return(double(execute: project))
@@ -86,7 +86,7 @@ describe Import::GitlabController do
expect(response).to have_gitlab_http_status(200)
end
- it 'returns 422 response when the project could not be imported' do
+ it "returns 422 response when the project could not be imported" do
allow(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, user.namespace, user, access_params)
.and_return(double(execute: build(:project)))
@@ -195,86 +195,86 @@ describe Import::GitlabController do
end
end
- context 'user has chosen an existing nested namespace for the project', :postgresql do
- let(:parent_namespace) { create(:group, name: 'foo') }
- let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
+ context "user has chosen an existing nested namespace for the project", :postgresql do
+ let(:parent_namespace) { create(:group, name: "foo") }
+ let(:nested_namespace) { create(:group, name: "bar", parent: parent_namespace) }
before do
parent_namespace.add_owner(user)
nested_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, nested_namespace, user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: nested_namespace.full_path }, format: :json
+ post :create, params: {target_namespace: nested_namespace.full_path}, format: :json
end
end
- context 'user has chosen a non-existent nested namespaces for the project', :postgresql do
- let(:test_name) { 'test_name' }
+ context "user has chosen a non-existent nested namespaces for the project", :postgresql do
+ let(:test_name) { "test_name" }
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar' }, format: :json
+ post :create, params: {target_namespace: "foo/bar"}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/bar' }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/bar"}, format: :json }
.to change { Namespace.count }.by(2)
end
- it 'new namespace has the right parent' do
+ it "new namespace has the right parent" do
allow(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar' }, format: :json
+ post :create, params: {target_namespace: "foo/bar"}, format: :json
- expect(Namespace.find_by_path_or_name('bar').parent.path).to eq('foo')
+ expect(Namespace.find_by_path_or_name("bar").parent.path).to eq("foo")
end
end
- context 'user has chosen existent and non-existent nested namespaces and name for the project', :postgresql do
- let(:test_name) { 'test_name' }
- let!(:parent_namespace) { create(:group, name: 'foo') }
+ context "user has chosen existent and non-existent nested namespaces and name for the project", :postgresql do
+ let(:test_name) { "test_name" }
+ let!(:parent_namespace) { create(:group, name: "foo") }
before do
parent_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/foobar/bar' }, format: :json
+ post :create, params: {target_namespace: "foo/foobar/bar"}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::GitlabImport::ProjectCreator)
.to receive(:new).with(gitlab_repo, kind_of(Namespace), user, access_params)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/foobar/bar' }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/foobar/bar"}, format: :json }
.to change { Namespace.count }.by(2)
end
end
- context 'when user can not create projects in the chosen namespace' do
- it 'returns 422 response' do
- other_namespace = create(:group, name: 'other_namespace')
+ context "when user can not create projects in the chosen namespace" do
+ it "returns 422 response" do
+ other_namespace = create(:group, name: "other_namespace")
- post :create, params: { target_namespace: other_namespace.name }, format: :json
+ post :create, params: {target_namespace: other_namespace.name}, format: :json
expect(response).to have_gitlab_http_status(422)
end
diff --git a/spec/controllers/import/gitlab_projects_controller_spec.rb b/spec/controllers/import/gitlab_projects_controller_spec.rb
index 55bd8ae7182..be05a4064a3 100644
--- a/spec/controllers/import/gitlab_projects_controller_spec.rb
+++ b/spec/controllers/import/gitlab_projects_controller_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::GitlabProjectsController do
set(:namespace) { create(:namespace) }
set(:user) { namespace.owner }
- let(:file) { fixture_file_upload('spec/fixtures/project_export.tar.gz', 'text/plain') }
+ let(:file) { fixture_file_upload("spec/fixtures/project_export.tar.gz", "text/plain") }
before do
sign_in(user)
end
- describe 'POST create' do
- context 'with an invalid path' do
- it 'redirects with an error' do
- post :create, params: { namespace_id: namespace.id, path: '/test', file: file }
+ describe "POST create" do
+ context "with an invalid path" do
+ it "redirects with an error" do
+ post :create, params: {namespace_id: namespace.id, path: "/test", file: file}
- expect(flash[:alert]).to start_with('Project could not be imported')
+ expect(flash[:alert]).to start_with("Project could not be imported")
expect(response).to have_gitlab_http_status(302)
end
- it 'redirects with an error when a relative path is used' do
- post :create, params: { namespace_id: namespace.id, path: '../test', file: file }
+ it "redirects with an error when a relative path is used" do
+ post :create, params: {namespace_id: namespace.id, path: "../test", file: file}
- expect(flash[:alert]).to start_with('Project could not be imported')
+ expect(flash[:alert]).to start_with("Project could not be imported")
expect(response).to have_gitlab_http_status(302)
end
end
- context 'with a valid path' do
- it 'redirects to the new project path' do
- post :create, params: { namespace_id: namespace.id, path: 'test', file: file }
+ context "with a valid path" do
+ it "redirects to the new project path" do
+ post :create, params: {namespace_id: namespace.id, path: "test", file: file}
- expect(flash[:notice]).to include('is being imported')
+ expect(flash[:notice]).to include("is being imported")
expect(response).to have_gitlab_http_status(302)
end
end
diff --git a/spec/controllers/import/google_code_controller_spec.rb b/spec/controllers/import/google_code_controller_spec.rb
index 3e5ed2afd93..3e053df0df9 100644
--- a/spec/controllers/import/google_code_controller_spec.rb
+++ b/spec/controllers/import/google_code_controller_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Import::GoogleCodeController do
include ImportSpecHelper
let(:user) { create(:user) }
- let(:dump_file) { fixture_file_upload('spec/fixtures/GoogleCodeProjectHosting.json', 'application/json') }
+ let(:dump_file) { fixture_file_upload("spec/fixtures/GoogleCodeProjectHosting.json", "application/json") }
before do
sign_in(user)
@@ -12,7 +12,7 @@ describe Import::GoogleCodeController do
describe "POST callback" do
it "stores Google Takeout dump list in session" do
- post :callback, params: { dump_file: dump_file }
+ post :callback, params: {dump_file: dump_file}
expect(session[:google_code_dump]).to be_a(Hash)
expect(session[:google_code_dump]["kind"]).to eq("projecthosting#user")
@@ -22,12 +22,12 @@ describe Import::GoogleCodeController do
describe "GET status" do
before do
- @repo = OpenStruct.new(name: 'vim')
+ @repo = OpenStruct.new(name: "vim")
stub_client(valid?: true)
end
it "assigns variables" do
- @project = create(:project, import_type: 'google_code', creator_id: user.id)
+ @project = create(:project, import_type: "google_code", creator_id: user.id)
stub_client(repos: [@repo], incompatible_repos: [])
get :status
@@ -38,7 +38,7 @@ describe Import::GoogleCodeController do
end
it "does not show already added project" do
- @project = create(:project, import_type: 'google_code', creator_id: user.id, import_source: 'vim')
+ @project = create(:project, import_type: "google_code", creator_id: user.id, import_source: "vim")
stub_client(repos: [@repo], incompatible_repos: [])
get :status
diff --git a/spec/controllers/instance_statistics/cohorts_controller_spec.rb b/spec/controllers/instance_statistics/cohorts_controller_spec.rb
index 596d3c7abe5..bb51ad6821d 100644
--- a/spec/controllers/instance_statistics/cohorts_controller_spec.rb
+++ b/spec/controllers/instance_statistics/cohorts_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe InstanceStatistics::CohortsController do
let(:user) { create(:user) }
@@ -9,9 +9,9 @@ describe InstanceStatistics::CohortsController do
sign_in(user)
end
- it_behaves_like 'instance statistics availability'
+ it_behaves_like "instance statistics availability"
- it 'renders a 404 when the usage ping is disabled' do
+ it "renders a 404 when the usage ping is disabled" do
stub_application_setting(usage_ping_enabled: false)
get :index
diff --git a/spec/controllers/instance_statistics/conversational_development_index_controller_spec.rb b/spec/controllers/instance_statistics/conversational_development_index_controller_spec.rb
index 4935cb265bf..64e0879343b 100644
--- a/spec/controllers/instance_statistics/conversational_development_index_controller_spec.rb
+++ b/spec/controllers/instance_statistics/conversational_development_index_controller_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe InstanceStatistics::ConversationalDevelopmentIndexController do
- it_behaves_like 'instance statistics availability'
+ it_behaves_like "instance statistics availability"
end
diff --git a/spec/controllers/invites_controller_spec.rb b/spec/controllers/invites_controller_spec.rb
index 7bbaf36e4df..d6de1c60903 100644
--- a/spec/controllers/invites_controller_spec.rb
+++ b/spec/controllers/invites_controller_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe InvitesController do
- let(:token) { '123456' }
+ let(:token) { "123456" }
let(:user) { create(:user) }
- let(:member) { create(:project_member, invite_token: token, invite_email: 'test@abc.com', user: user) }
+ let(:member) { create(:project_member, invite_token: token, invite_email: "test@abc.com", user: user) }
before do
controller.instance_variable_set(:@member, member)
sign_in(user)
end
- describe 'GET #accept' do
- it 'accepts user' do
- get :accept, params: { id: token }
+ describe "GET #accept" do
+ it "accepts user" do
+ get :accept, params: {id: token}
member.reload
expect(response).to have_gitlab_http_status(302)
expect(member.user).to eq(user)
- expect(flash[:notice]).to include 'You have been granted'
+ expect(flash[:notice]).to include "You have been granted"
end
end
- describe 'GET #decline' do
- it 'declines user' do
- get :decline, params: { id: token }
+ describe "GET #decline" do
+ it "declines user" do
+ get :decline, params: {id: token}
expect {member.reload}.to raise_error ActiveRecord::RecordNotFound
expect(response).to have_gitlab_http_status(302)
- expect(flash[:notice]).to include 'You have declined the invitation to join'
+ expect(flash[:notice]).to include "You have declined the invitation to join"
end
end
end
diff --git a/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb b/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
index c9d36a16008..c5ad30b0fd0 100644
--- a/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/ldap/omniauth_callbacks_controller_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Ldap::OmniauthCallbacksController do
- include_context 'Ldap::OmniauthCallbacksController'
+ include_context "Ldap::OmniauthCallbacksController"
- it 'allows sign in' do
+ it "allows sign in" do
post provider
- expect(request.env['warden']).to be_authenticated
+ expect(request.env["warden"]).to be_authenticated
end
- it 'respects remember me checkbox' do
- expect do
- post provider, params: { remember_me: '1' }
- end.to change { user.reload.remember_created_at }.from(nil)
+ it "respects remember me checkbox" do
+ expect {
+ post provider, params: {remember_me: "1"}
+ }.to change { user.reload.remember_created_at }.from(nil)
end
- context 'with 2FA' do
+ context "with 2FA" do
let(:user) { create(:omniauth_user, :two_factor_via_otp, extern_uid: uid, provider: provider) }
- it 'passes remember_me to the Devise view' do
- post provider, params: { remember_me: '1' }
+ it "passes remember_me to the Devise view" do
+ post provider, params: {remember_me: "1"}
- expect(assigns[:user].remember_me).to eq '1'
+ expect(assigns[:user].remember_me).to eq "1"
end
end
- context 'access denied' do
+ context "access denied" do
let(:valid_login?) { false }
- it 'warns the user' do
+ it "warns the user" do
post provider
expect(flash[:alert]).to match(/Access denied for your LDAP account*/)
@@ -37,22 +37,22 @@ describe Ldap::OmniauthCallbacksController do
it "doesn't authenticate user" do
post provider
- expect(request.env['warden']).not_to be_authenticated
+ expect(request.env["warden"]).not_to be_authenticated
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'sign up' do
- let(:user) { double(email: 'new@example.com') }
+ context "sign up" do
+ let(:user) { double(email: "new@example.com") }
before do
stub_omniauth_setting(block_auto_created_users: false)
end
- it 'is allowed' do
+ it "is allowed" do
post provider
- expect(request.env['warden']).to be_authenticated
+ expect(request.env["warden"]).to be_authenticated
end
end
end
diff --git a/spec/controllers/metrics_controller_spec.rb b/spec/controllers/metrics_controller_spec.rb
index c7c83369d7c..147bfe60a76 100644
--- a/spec/controllers/metrics_controller_spec.rb
+++ b/spec/controllers/metrics_controller_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe MetricsController do
include StubENV
let(:json_response) { JSON.parse(response.body) }
let(:metrics_multiproc_dir) { Dir.mktmpdir }
- let(:whitelisted_ip) { '127.0.0.1' }
- let(:whitelisted_ip_range) { '10.0.0.0/24' }
- let(:ip_in_whitelisted_range) { '10.0.0.1' }
- let(:not_whitelisted_ip) { '10.0.1.1' }
+ let(:whitelisted_ip) { "127.0.0.1" }
+ let(:whitelisted_ip_range) { "10.0.0.0/24" }
+ let(:ip_in_whitelisted_range) { "10.0.0.1" }
+ let(:not_whitelisted_ip) { "10.0.1.1" }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
allow(Prometheus::Client.configuration).to receive(:multiprocess_files_dir).and_return(metrics_multiproc_dir)
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(true)
allow(Settings.monitoring).to receive(:ip_whitelist).and_return([whitelisted_ip, whitelisted_ip_range])
allow_any_instance_of(MetricsService).to receive(:metrics_text).and_return("prometheus_counter 1")
end
- describe '#index' do
- shared_examples_for 'endpoint providing metrics' do
- it 'returns prometheus metrics' do
+ describe "#index" do
+ shared_examples_for "endpoint providing metrics" do
+ it "returns prometheus metrics" do
get :index
expect(response.status).to eq(200)
expect(response.body).to match(/^prometheus_counter 1$/)
end
- context 'prometheus metrics are disabled' do
+ context "prometheus metrics are disabled" do
before do
allow(Gitlab::Metrics).to receive(:prometheus_metrics_enabled?).and_return(false)
end
- it 'returns proper response' do
+ it "returns proper response" do
get :index
expect(response.status).to eq(200)
@@ -41,28 +41,28 @@ describe MetricsController do
end
end
- context 'accessed from whitelisted ip' do
+ context "accessed from whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(whitelisted_ip)
end
- it_behaves_like 'endpoint providing metrics'
+ it_behaves_like "endpoint providing metrics"
end
- context 'accessed from ip in whitelisted range' do
+ context "accessed from ip in whitelisted range" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(ip_in_whitelisted_range)
end
- it_behaves_like 'endpoint providing metrics'
+ it_behaves_like "endpoint providing metrics"
end
- context 'accessed from not whitelisted ip' do
+ context "accessed from not whitelisted ip" do
before do
allow(Gitlab::RequestContext).to receive(:client_ip).and_return(not_whitelisted_ip)
end
- it 'returns the expected error response' do
+ it "returns the expected error response" do
get :index
expect(response.status).to eq(404)
diff --git a/spec/controllers/notification_settings_controller_spec.rb b/spec/controllers/notification_settings_controller_spec.rb
index cf52ce834b6..00beda78802 100644
--- a/spec/controllers/notification_settings_controller_spec.rb
+++ b/spec/controllers/notification_settings_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NotificationSettingsController do
let(:project) { create(:project) }
@@ -9,20 +9,20 @@ describe NotificationSettingsController do
project.add_developer(user)
end
- describe '#create' do
- context 'when not authorized' do
- it 'redirects to sign in page' do
+ describe "#create" do
+ context "when not authorized" do
+ it "redirects to sign in page" do
post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :participating }
- }
+ params: {
+ project_id: project.id,
+ notification_setting: {level: :participating},
+ }
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'when authorized' do
+ context "when authorized" do
let(:notification_setting) { user.notification_settings_for(source) }
let(:custom_events) do
events = {}
@@ -38,15 +38,15 @@ describe NotificationSettingsController do
sign_in(user)
end
- context 'for projects' do
+ context "for projects" do
let(:source) { project }
- it 'creates notification setting' do
+ it "creates notification setting" do
post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :participating }
- }
+ params: {
+ project_id: project.id,
+ notification_setting: {level: :participating},
+ }
expect(response.status).to eq 200
expect(notification_setting.level).to eq("participating")
@@ -55,13 +55,13 @@ describe NotificationSettingsController do
expect(notification_setting.source_type).to eq("Project")
end
- context 'with custom settings' do
- it 'creates notification setting' do
+ context "with custom settings" do
+ it "creates notification setting" do
post :create,
- params: {
- project_id: project.id,
- notification_setting: { level: :custom }.merge(custom_events)
- }
+ params: {
+ project_id: project.id,
+ notification_setting: {level: :custom}.merge(custom_events),
+ }
expect(response.status).to eq 200
expect(notification_setting.level).to eq("custom")
@@ -73,15 +73,15 @@ describe NotificationSettingsController do
end
end
- context 'for groups' do
+ context "for groups" do
let(:source) { group }
- it 'creates notification setting' do
+ it "creates notification setting" do
post :create,
- params: {
- namespace_id: group.id,
- notification_setting: { level: :watch }
- }
+ params: {
+ namespace_id: group.id,
+ notification_setting: {level: :watch},
+ }
expect(response.status).to eq 200
expect(notification_setting.level).to eq("watch")
@@ -90,13 +90,13 @@ describe NotificationSettingsController do
expect(notification_setting.source_type).to eq("Namespace")
end
- context 'with custom settings' do
- it 'creates notification setting' do
+ context "with custom settings" do
+ it "creates notification setting" do
post :create,
- params: {
- namespace_id: group.id,
- notification_setting: { level: :custom }.merge(custom_events)
- }
+ params: {
+ namespace_id: group.id,
+ notification_setting: {level: :custom}.merge(custom_events),
+ }
expect(response.status).to eq 200
expect(notification_setting.level).to eq("custom")
@@ -109,56 +109,56 @@ describe NotificationSettingsController do
end
end
- context 'not authorized' do
+ context "not authorized" do
let(:private_project) { create(:project, :private) }
before do
sign_in(user)
end
- it 'returns 404' do
+ it "returns 404" do
post :create,
- params: {
- project_id: private_project.id,
- notification_setting: { level: :participating }
- }
+ params: {
+ project_id: private_project.id,
+ notification_setting: {level: :participating},
+ }
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe '#update' do
+ describe "#update" do
let(:notification_setting) { user.global_notification_setting }
- context 'when not authorized' do
- it 'redirects to sign in page' do
+ context "when not authorized" do
+ it "redirects to sign in page" do
put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
+ params: {
+ id: notification_setting,
+ notification_setting: {level: :participating},
+ }
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'when authorized' do
+ context "when authorized" do
before do
sign_in(user)
end
- it 'returns success' do
+ it "returns success" do
put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
+ params: {
+ id: notification_setting,
+ notification_setting: {level: :participating},
+ }
expect(response.status).to eq 200
end
- context 'and setting custom notification setting' do
+ context "and setting custom notification setting" do
let(:custom_events) do
events = {}
@@ -167,31 +167,31 @@ describe NotificationSettingsController do
end
end
- it 'returns success' do
+ it "returns success" do
put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating, events: custom_events }
- }
+ params: {
+ id: notification_setting,
+ notification_setting: {level: :participating, events: custom_events},
+ }
expect(response.status).to eq 200
end
end
end
- context 'not authorized' do
+ context "not authorized" do
let(:other_user) { create(:user) }
before do
sign_in(other_user)
end
- it 'returns 404' do
+ it "returns 404" do
put :update,
- params: {
- id: notification_setting,
- notification_setting: { level: :participating }
- }
+ params: {
+ id: notification_setting,
+ notification_setting: {level: :participating},
+ }
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/oauth/applications_controller_spec.rb b/spec/controllers/oauth/applications_controller_spec.rb
index caf2b87428b..a0968f1ce08 100644
--- a/spec/controllers/oauth/applications_controller_spec.rb
+++ b/spec/controllers/oauth/applications_controller_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Oauth::ApplicationsController do
let(:user) { create(:user) }
- context 'project members' do
+ context "project members" do
before do
sign_in(user)
end
- describe 'GET #index' do
- it 'shows list of applications' do
+ describe "GET #index" do
+ it "shows list of applications" do
get :index
expect(response).to have_gitlab_http_status(200)
end
- it 'shows list of applications' do
+ it "shows list of applications" do
disable_user_oauth
get :index
@@ -24,15 +24,15 @@ describe Oauth::ApplicationsController do
end
end
- describe 'POST #create' do
- it 'creates an application' do
+ describe "POST #create" do
+ it "creates an application" do
post :create, params: oauth_params
expect(response).to have_gitlab_http_status(302)
expect(response).to redirect_to(oauth_application_path(Doorkeeper::Application.last))
end
- it 'redirects back to profile page if OAuth applications are disabled' do
+ it "redirects back to profile page if OAuth applications are disabled" do
disable_user_oauth
post :create, params: oauth_params
@@ -41,20 +41,20 @@ describe Oauth::ApplicationsController do
expect(response).to redirect_to(profile_path)
end
- context 'redirect_uri' do
+ context "redirect_uri" do
render_views
- it 'shows an error for a forbidden URI' do
+ it "shows an error for a forbidden URI" do
invalid_uri_params = {
doorkeeper_application: {
- name: 'foo',
- redirect_uri: 'javascript://alert()'
- }
+ name: "foo",
+ redirect_uri: "javascript://alert()",
+ },
}
post :create, params: invalid_uri_params
- expect(response.body).to include 'Redirect URI is forbidden by the server'
+ expect(response.body).to include "Redirect URI is forbidden by the server"
end
end
end
@@ -67,9 +67,9 @@ describe Oauth::ApplicationsController do
def oauth_params
{
doorkeeper_application: {
- name: 'foo',
- redirect_uri: 'http://example.org'
- }
+ name: "foo",
+ redirect_uri: "http://example.org",
+ },
}
end
end
diff --git a/spec/controllers/oauth/authorizations_controller_spec.rb b/spec/controllers/oauth/authorizations_controller_spec.rb
index cc8fa2c01b4..d3fd45623ab 100644
--- a/spec/controllers/oauth/authorizations_controller_spec.rb
+++ b/spec/controllers/oauth/authorizations_controller_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Oauth::AuthorizationsController do
let(:user) { create(:user) }
- let!(:application) { create(:oauth_application, scopes: 'api read_user', redirect_uri: 'http://example.com') }
+ let!(:application) { create(:oauth_application, scopes: "api read_user", redirect_uri: "http://example.com") }
let(:params) do
{
response_type: "code",
client_id: application.uid,
redirect_uri: application.redirect_uri,
- state: 'state'
+ state: "state",
}
end
@@ -16,50 +16,50 @@ describe Oauth::AuthorizationsController do
sign_in(user)
end
- describe 'GET #new' do
- context 'without valid params' do
- it 'returns 200 code and renders error view' do
+ describe "GET #new" do
+ context "without valid params" do
+ it "returns 200 code and renders error view" do
get :new
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('doorkeeper/authorizations/error')
+ expect(response).to render_template("doorkeeper/authorizations/error")
end
end
- context 'with valid params' do
+ context "with valid params" do
render_views
- it 'returns 200 code and renders view' do
+ it "returns 200 code and renders view" do
get :new, params: params
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('doorkeeper/authorizations/new')
+ expect(response).to render_template("doorkeeper/authorizations/new")
end
- it 'deletes session.user_return_to and redirects when skip authorization' do
+ it "deletes session.user_return_to and redirects when skip authorization" do
application.update(trusted: true)
- request.session['user_return_to'] = 'http://example.com'
+ request.session["user_return_to"] = "http://example.com"
get :new, params: params
- expect(request.session['user_return_to']).to be_nil
+ expect(request.session["user_return_to"]).to be_nil
expect(response).to have_gitlab_http_status(302)
end
- context 'when there is already an access token for the application' do
- context 'when the request scope matches any of the created token scopes' do
+ context "when there is already an access token for the application" do
+ context "when the request scope matches any of the created token scopes" do
before do
- scopes = Doorkeeper::OAuth::Scopes.from_string('api')
+ scopes = Doorkeeper::OAuth::Scopes.from_string("api")
allow(Doorkeeper.configuration).to receive(:scopes).and_return(scopes)
create :oauth_access_token, application: application, resource_owner_id: user.id, scopes: scopes
end
- it 'authorizes the request and redirects' do
+ it "authorizes the request and redirects" do
get :new, params: params
- expect(request.session['user_return_to']).to be_nil
+ expect(request.session["user_return_to"]).to be_nil
expect(response).to have_gitlab_http_status(302)
end
end
diff --git a/spec/controllers/omniauth_callbacks_controller_spec.rb b/spec/controllers/omniauth_callbacks_controller_spec.rb
index 232a5e2793b..4e231989fbb 100644
--- a/spec/controllers/omniauth_callbacks_controller_spec.rb
+++ b/spec/controllers/omniauth_callbacks_controller_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe OmniauthCallbacksController, type: :controller do
include LoginHelpers
- describe 'omniauth' do
+ describe "omniauth" do
let(:user) { create(:omniauth_user, extern_uid: extern_uid, provider: provider) }
before do
@@ -11,20 +11,20 @@ describe OmniauthCallbacksController, type: :controller do
stub_omniauth_provider(provider, context: request)
end
- context 'when the user is on the last sign in attempt' do
- let(:extern_uid) { 'my-uid' }
+ context "when the user is on the last sign in attempt" do
+ let(:extern_uid) { "my-uid" }
before do
user.update(failed_attempts: User.maximum_attempts.pred)
subject.response = ActionDispatch::Response.new
end
- context 'when using a form based provider' do
+ context "when using a form based provider" do
let(:provider) { :ldap }
- it 'locks the user when sign in fails' do
+ it "locks the user when sign in fails" do
allow(subject).to receive(:params).and_return(ActionController::Parameters.new(username: user.username))
- request.env['omniauth.error.strategy'] = OmniAuth::Strategies::LDAP.new(nil)
+ request.env["omniauth.error.strategy"] = OmniAuth::Strategies::LDAP.new(nil)
subject.send(:failure)
@@ -32,11 +32,11 @@ describe OmniauthCallbacksController, type: :controller do
end
end
- context 'when using a button based provider' do
+ context "when using a button based provider" do
let(:provider) { :github }
- it 'does not lock the user when sign in fails' do
- request.env['omniauth.error.strategy'] = OmniAuth::Strategies::GitHub.new(nil)
+ it "does not lock the user when sign in fails" do
+ request.env["omniauth.error.strategy"] = OmniAuth::Strategies::GitHub.new(nil)
subject.send(:failure)
@@ -45,20 +45,20 @@ describe OmniauthCallbacksController, type: :controller do
end
end
- context 'when sign in fails' do
+ context "when sign in fails" do
include RoutesHelpers
- let(:extern_uid) { 'my-uid' }
+ let(:extern_uid) { "my-uid" }
let(:provider) { :saml }
def stub_route_as(path)
allow(@routes).to receive(:generate_extras) { [path, []] }
end
- it 'it calls through to the failure handler' do
- request.env['omniauth.error'] = OneLogin::RubySaml::ValidationError.new("Fingerprint mismatch")
- request.env['omniauth.error.strategy'] = OmniAuth::Strategies::SAML.new(nil)
- stub_route_as('/users/auth/saml/callback')
+ it "it calls through to the failure handler" do
+ request.env["omniauth.error"] = OneLogin::RubySaml::ValidationError.new("Fingerprint mismatch")
+ request.env["omniauth.error.strategy"] = OmniAuth::Strategies::SAML.new(nil)
+ stub_route_as("/users/auth/saml/callback")
ForgeryProtection.with_forgery_protection do
post :failure
@@ -68,152 +68,152 @@ describe OmniauthCallbacksController, type: :controller do
end
end
- context 'when a redirect fragment is provided' do
+ context "when a redirect fragment is provided" do
let(:provider) { :jwt }
- let(:extern_uid) { 'my-uid' }
+ let(:extern_uid) { "my-uid" }
before do
- request.env['omniauth.params'] = { 'redirect_fragment' => 'L101' }
+ request.env["omniauth.params"] = {"redirect_fragment" => "L101"}
end
- context 'when a redirect url is stored' do
- it 'redirects with fragment' do
- post provider, session: { user_return_to: '/fake/url' }
+ context "when a redirect url is stored" do
+ it "redirects with fragment" do
+ post provider, session: {user_return_to: "/fake/url"}
- expect(response).to redirect_to('/fake/url#L101')
+ expect(response).to redirect_to("/fake/url#L101")
end
end
- context 'when a redirect url with a fragment is stored' do
- it 'redirects with the new fragment' do
- post provider, session: { user_return_to: '/fake/url#replaceme' }
+ context "when a redirect url with a fragment is stored" do
+ it "redirects with the new fragment" do
+ post provider, session: {user_return_to: "/fake/url#replaceme"}
- expect(response).to redirect_to('/fake/url#L101')
+ expect(response).to redirect_to("/fake/url#L101")
end
end
- context 'when no redirect url is stored' do
- it 'does not redirect with the fragment' do
+ context "when no redirect url is stored" do
+ it "does not redirect with the fragment" do
post provider
expect(response.redirect?).to be true
- expect(response.location).not_to include('#L101')
+ expect(response.location).not_to include("#L101")
end
end
end
- context 'strategies' do
- context 'github' do
- let(:extern_uid) { 'my-uid' }
+ context "strategies" do
+ context "github" do
+ let(:extern_uid) { "my-uid" }
let(:provider) { :github }
- it 'allows sign in' do
+ it "allows sign in" do
post provider
- expect(request.env['warden']).to be_authenticated
+ expect(request.env["warden"]).to be_authenticated
end
- shared_context 'sign_up' do
- let(:user) { double(email: 'new@example.com') }
+ shared_context "sign_up" do
+ let(:user) { double(email: "new@example.com") }
before do
stub_omniauth_setting(block_auto_created_users: false)
end
end
- context 'sign up' do
- include_context 'sign_up'
+ context "sign up" do
+ include_context "sign_up"
- it 'is allowed' do
+ it "is allowed" do
post provider
- expect(request.env['warden']).to be_authenticated
+ expect(request.env["warden"]).to be_authenticated
end
end
- context 'when OAuth is disabled' do
+ context "when OAuth is disabled" do
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
settings = Gitlab::CurrentSettings.current_application_settings
settings.update(disabled_oauth_sign_in_sources: [provider.to_s])
end
- it 'prevents login via POST' do
+ it "prevents login via POST" do
post provider
- expect(request.env['warden']).not_to be_authenticated
+ expect(request.env["warden"]).not_to be_authenticated
end
- it 'shows warning when attempting login' do
+ it "shows warning when attempting login" do
post provider
expect(response).to redirect_to new_user_session_path
- expect(flash[:alert]).to eq('Signing in using GitHub has been disabled')
+ expect(flash[:alert]).to eq("Signing in using GitHub has been disabled")
end
- it 'allows linking the disabled provider' do
+ it "allows linking the disabled provider" do
user.identities.destroy_all # rubocop: disable DestroyAll
sign_in(user)
expect { post provider }.to change { user.reload.identities.count }.by(1)
end
- context 'sign up' do
- include_context 'sign_up'
+ context "sign up" do
+ include_context "sign_up"
- it 'is prevented' do
+ it "is prevented" do
post provider
- expect(request.env['warden']).not_to be_authenticated
+ expect(request.env["warden"]).not_to be_authenticated
end
end
end
end
- context 'auth0' do
- let(:extern_uid) { '' }
+ context "auth0" do
+ let(:extern_uid) { "" }
let(:provider) { :auth0 }
- it 'does not allow sign in without extern_uid' do
- post 'auth0'
+ it "does not allow sign in without extern_uid" do
+ post "auth0"
- expect(request.env['warden']).not_to be_authenticated
+ expect(request.env["warden"]).not_to be_authenticated
expect(response.status).to eq(302)
- expect(controller).to set_flash[:alert].to('Wrong extern UID provided. Make sure Auth0 is configured correctly.')
+ expect(controller).to set_flash[:alert].to("Wrong extern UID provided. Make sure Auth0 is configured correctly.")
end
end
end
end
- describe '#saml' do
- let(:user) { create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') }
- let(:mock_saml_response) { File.read('spec/fixtures/authentication/saml_response.xml') }
+ describe "#saml" do
+ let(:user) { create(:omniauth_user, :two_factor, extern_uid: "my-uid", provider: "saml") }
+ let(:mock_saml_response) { File.read("spec/fixtures/authentication/saml_response.xml") }
let(:saml_config) { mock_saml_config_with_upstream_two_factor_authn_contexts }
before do
- stub_omniauth_saml_config({ enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'],
- providers: [saml_config] })
- mock_auth_hash('saml', 'my-uid', user.email, mock_saml_response)
+ stub_omniauth_saml_config({enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"],
+ providers: [saml_config],})
+ mock_auth_hash("saml", "my-uid", user.email, mock_saml_response)
request.env["devise.mapping"] = Devise.mappings[:user]
- request.env['omniauth.auth'] = Rails.application.env_config['omniauth.auth']
- post :saml, params: { SAMLResponse: mock_saml_response }
+ request.env["omniauth.auth"] = Rails.application.env_config["omniauth.auth"]
+ post :saml, params: {SAMLResponse: mock_saml_response}
end
- context 'when worth two factors' do
+ context "when worth two factors" do
let(:mock_saml_response) do
- File.read('spec/fixtures/authentication/saml_response.xml')
- .gsub('urn:oasis:names:tc:SAML:2.0:ac:classes:Password', 'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN')
+ File.read("spec/fixtures/authentication/saml_response.xml")
+ .gsub("urn:oasis:names:tc:SAML:2.0:ac:classes:Password", "urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN")
end
- it 'expects user to be signed_in' do
- expect(request.env['warden']).to be_authenticated
+ it "expects user to be signed_in" do
+ expect(request.env["warden"]).to be_authenticated
end
end
- context 'when not worth two factors' do
- it 'expects user to provide second factor' do
- expect(response).to render_template('devise/sessions/two_factor')
- expect(request.env['warden']).not_to be_authenticated
+ context "when not worth two factors" do
+ it "expects user to provide second factor" do
+ expect(response).to render_template("devise/sessions/two_factor")
+ expect(request.env["warden"]).not_to be_authenticated
end
end
end
diff --git a/spec/controllers/passwords_controller_spec.rb b/spec/controllers/passwords_controller_spec.rb
index 0af55cf3408..d6d69b594fb 100644
--- a/spec/controllers/passwords_controller_spec.rb
+++ b/spec/controllers/passwords_controller_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe PasswordsController do
- describe '#check_password_authentication_available' do
+ describe "#check_password_authentication_available" do
before do
@request.env["devise.mapping"] = Devise.mappings[:user]
end
- context 'when password authentication is disabled for the web interface and Git' do
- it 'prevents a password reset' do
+ context "when password authentication is disabled for the web interface and Git" do
+ it "prevents a password reset" do
stub_application_setting(password_authentication_enabled_for_web: false)
stub_application_setting(password_authentication_enabled_for_git: false)
post :create
expect(response).to have_gitlab_http_status(302)
- expect(flash[:alert]).to eq 'Password authentication is unavailable.'
+ expect(flash[:alert]).to eq "Password authentication is unavailable."
end
end
- context 'when reset email belongs to an ldap user' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain', email: 'ldapuser@gitlab.com') }
+ context "when reset email belongs to an ldap user" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain", email: "ldapuser@gitlab.com") }
- it 'prevents a password reset' do
- post :create, params: { user: { email: user.email } }
+ it "prevents a password reset" do
+ post :create, params: {user: {email: user.email}}
- expect(flash[:alert]).to eq 'Password authentication is unavailable.'
+ expect(flash[:alert]).to eq "Password authentication is unavailable."
end
end
end
diff --git a/spec/controllers/profiles/accounts_controller_spec.rb b/spec/controllers/profiles/accounts_controller_spec.rb
index bb2ab27e2dd..49df3ca74a6 100644
--- a/spec/controllers/profiles/accounts_controller_spec.rb
+++ b/spec/controllers/profiles/accounts_controller_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::AccountsController do
- describe 'DELETE unlink' do
+ describe "DELETE unlink" do
let(:user) { create(:omniauth_user) }
before do
sign_in(user)
end
- it 'renders 404 if someone tries to unlink a non existent provider' do
- delete :unlink, params: { provider: 'github' }
+ it "renders 404 if someone tries to unlink a non existent provider" do
+ delete :unlink, params: {provider: "github"}
expect(response).to have_gitlab_http_status(404)
end
@@ -21,7 +21,7 @@ describe Profiles::AccountsController do
it "does not allow to unlink connected account" do
identity = user.identities.last
- delete :unlink, params: { provider: provider.to_s }
+ delete :unlink, params: {provider: provider.to_s}
expect(response).to have_gitlab_http_status(302)
expect(user.reload.identities).to include(identity)
@@ -33,10 +33,10 @@ describe Profiles::AccountsController do
describe "#{provider} provider" do
let(:user) { create(:omniauth_user, provider: provider.to_s) }
- it 'allows to unlink connected account' do
+ it "allows to unlink connected account" do
identity = user.identities.last
- delete :unlink, params: { provider: provider.to_s }
+ delete :unlink, params: {provider: provider.to_s}
expect(response).to have_gitlab_http_status(302)
expect(user.reload.identities).not_to include(identity)
diff --git a/spec/controllers/profiles/avatars_controller_spec.rb b/spec/controllers/profiles/avatars_controller_spec.rb
index 1ee0bf44e92..f160ad867dc 100644
--- a/spec/controllers/profiles/avatars_controller_spec.rb
+++ b/spec/controllers/profiles/avatars_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::AvatarsController do
let(:user) { create(:user, avatar: fixture_file_upload("spec/fixtures/dk.png")) }
@@ -8,7 +8,7 @@ describe Profiles::AvatarsController do
controller.instance_variable_set(:@user, user)
end
- it 'removes avatar from DB by calling destroy' 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/emails_controller_spec.rb b/spec/controllers/profiles/emails_controller_spec.rb
index a8a1f96befe..64bf0728c1c 100644
--- a/spec/controllers/profiles/emails_controller_spec.rb
+++ b/spec/controllers/profiles/emails_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::EmailsController do
let(:user) { create(:user) }
@@ -7,29 +7,29 @@ describe Profiles::EmailsController do
sign_in(user)
end
- describe '#create' do
- let(:email_params) { { email: "add_email@example.com" } }
+ describe "#create" do
+ let(:email_params) { {email: "add_email@example.com"} }
- it 'sends an email confirmation' do
- expect { post(:create, params: { email: email_params }) }.to change { ActionMailer::Base.deliveries.size }
+ it "sends an email confirmation" do
+ expect { post(:create, params: {email: email_params}) }.to change { ActionMailer::Base.deliveries.size }
expect(ActionMailer::Base.deliveries.last.to).to eq [email_params[:email]]
expect(ActionMailer::Base.deliveries.last.subject).to match "Confirmation instructions"
end
end
- describe '#resend_confirmation_instructions' do
- let(:email_params) { { email: "add_email@example.com" } }
+ describe "#resend_confirmation_instructions" do
+ let(:email_params) { {email: "add_email@example.com"} }
- it 'resends an email confirmation' do
- email = user.emails.create(email: 'add_email@example.com')
+ it "resends an email confirmation" do
+ email = user.emails.create(email: "add_email@example.com")
- expect { put(:resend_confirmation_instructions, params: { id: email }) }.to change { ActionMailer::Base.deliveries.size }
+ expect { put(:resend_confirmation_instructions, params: {id: email}) }.to change { ActionMailer::Base.deliveries.size }
expect(ActionMailer::Base.deliveries.last.to).to eq [email_params[:email]]
expect(ActionMailer::Base.deliveries.last.subject).to match "Confirmation instructions"
end
- it 'unable to resend an email confirmation' do
- expect { put(:resend_confirmation_instructions, params: { id: 1 }) }.not_to change { ActionMailer::Base.deliveries.size }
+ it "unable to resend an email confirmation" do
+ expect { put(:resend_confirmation_instructions, params: {id: 1}) }.not_to change { ActionMailer::Base.deliveries.size }
end
end
end
diff --git a/spec/controllers/profiles/keys_controller_spec.rb b/spec/controllers/profiles/keys_controller_spec.rb
index 5e2cc82bd8c..77c5a651fea 100644
--- a/spec/controllers/profiles/keys_controller_spec.rb
+++ b/spec/controllers/profiles/keys_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::KeysController do
let(:user) { create(:user) }
@@ -6,7 +6,7 @@ describe Profiles::KeysController do
describe "#get_keys" do
describe "non existent user" do
it "does not generally work" do
- get :get_keys, params: { username: 'not-existent' }
+ get :get_keys, params: {username: "not-existent"}
expect(response).not_to be_success
end
@@ -14,19 +14,19 @@ describe Profiles::KeysController do
describe "user with no keys" do
it "does generally work" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response).to be_success
end
it "renders all keys separated with a new line" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response.body).to eq("")
end
it "responds with text/plain content type" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response.content_type).to eq("text/plain")
end
end
@@ -37,31 +37,31 @@ describe Profiles::KeysController do
let!(:deploy_key) { create(:deploy_key, user: user) }
it "does generally work" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response).to be_success
end
it "renders all non deploy keys separated with a new line" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
- expect(response.body).not_to eq('')
+ expect(response.body).not_to eq("")
expect(response.body).to eq(user.all_ssh_keys.join("\n"))
- expect(response.body).to include(key.key.sub(' dummy@gitlab.com', ''))
- expect(response.body).to include(another_key.key.sub(' dummy@gitlab.com', ''))
+ expect(response.body).to include(key.key.sub(" dummy@gitlab.com", ""))
+ expect(response.body).to include(another_key.key.sub(" dummy@gitlab.com", ""))
expect(response.body).not_to include(deploy_key.key)
end
it "does not render the comment of the key" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response.body).not_to match(/dummy@gitlab.com/)
end
it "responds with text/plain content type" do
- get :get_keys, params: { username: user.username }
+ get :get_keys, params: {username: user.username}
expect(response.content_type).to eq("text/plain")
end
diff --git a/spec/controllers/profiles/notifications_controller_spec.rb b/spec/controllers/profiles/notifications_controller_spec.rb
index 1b76446a0cf..39249b098f7 100644
--- a/spec/controllers/profiles/notifications_controller_spec.rb
+++ b/spec/controllers/profiles/notifications_controller_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::NotificationsController do
let(:user) do
create(:user) do |user|
- user.emails.create(email: 'original@example.com')
- user.emails.create(email: 'new@example.com')
- user.notification_email = 'original@example.com'
+ user.emails.create(email: "original@example.com")
+ user.emails.create(email: "new@example.com")
+ user.notification_email = "original@example.com"
user.save!
end
end
- describe 'GET show' do
- it 'renders' do
+ describe "GET show" do
+ it "renders" do
sign_in(user)
get :show
@@ -20,26 +20,26 @@ describe Profiles::NotificationsController do
end
end
- describe 'POST update' do
- it 'updates only permitted attributes' do
+ describe "POST update" do
+ it "updates only permitted attributes" do
sign_in(user)
- put :update, params: { user: { notification_email: 'new@example.com', notified_of_own_activity: true, admin: true } }
+ put :update, params: {user: {notification_email: "new@example.com", notified_of_own_activity: true, admin: true}}
user.reload
- expect(user.notification_email).to eq('new@example.com')
+ expect(user.notification_email).to eq("new@example.com")
expect(user.notified_of_own_activity).to eq(true)
expect(user.admin).to eq(false)
- expect(controller).to set_flash[:notice].to('Notification settings saved')
+ expect(controller).to set_flash[:notice].to("Notification settings saved")
end
- it 'shows an error message if the params are invalid' do
+ it "shows an error message if the params are invalid" do
sign_in(user)
- put :update, params: { user: { notification_email: '' } }
+ put :update, params: {user: {notification_email: ""}}
- expect(user.reload.notification_email).to eq('original@example.com')
- expect(controller).to set_flash[:alert].to('Failed to save new settings')
+ expect(user.reload.notification_email).to eq("original@example.com")
+ expect(controller).to set_flash[:alert].to("Failed to save new settings")
end
end
end
diff --git a/spec/controllers/profiles/personal_access_tokens_controller_spec.rb b/spec/controllers/profiles/personal_access_tokens_controller_spec.rb
index 021bf2429e3..08d93c92348 100644
--- a/spec/controllers/profiles/personal_access_tokens_controller_spec.rb
+++ b/spec/controllers/profiles/personal_access_tokens_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::PersonalAccessTokensController do
let(:user) { create(:user) }
@@ -8,16 +8,16 @@ describe Profiles::PersonalAccessTokensController do
sign_in(user)
end
- describe '#create' do
+ describe "#create" do
def created_token
PersonalAccessToken.order(:created_at).last
end
it "allows creation of a token with scopes" do
- name = 'My PAT'
+ name = "My PAT"
scopes = %w[api read_user]
- post :create, params: { personal_access_token: token_attributes.merge(scopes: scopes, name: name) }
+ post :create, params: {personal_access_token: token_attributes.merge(scopes: scopes, name: name)}
expect(created_token).not_to be_nil
expect(created_token.name).to eq(name)
@@ -28,18 +28,18 @@ describe Profiles::PersonalAccessTokensController do
it "allows creation of a token with an expiry date" do
expires_at = 5.days.from_now.to_date
- post :create, params: { personal_access_token: token_attributes.merge(expires_at: expires_at) }
+ post :create, params: {personal_access_token: token_attributes.merge(expires_at: expires_at)}
expect(created_token).not_to be_nil
expect(created_token.expires_at).to eq(expires_at)
end
end
- describe '#index' do
+ describe "#index" do
let!(:active_personal_access_token) { create(:personal_access_token, user: user) }
let!(:inactive_personal_access_token) { create(:personal_access_token, :revoked, user: user) }
let!(:impersonation_personal_access_token) { create(:personal_access_token, :impersonation, user: user) }
- let(:token_value) { 's3cr3t' }
+ let(:token_value) { "s3cr3t" }
before do
PersonalAccessToken.redis_store!(user.id, token_value)
diff --git a/spec/controllers/profiles/preferences_controller_spec.rb b/spec/controllers/profiles/preferences_controller_spec.rb
index ee881f85233..a05fc71d07b 100644
--- a/spec/controllers/profiles/preferences_controller_spec.rb
+++ b/spec/controllers/profiles/preferences_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::PreferencesController do
let(:user) { create(:user) }
@@ -9,42 +9,42 @@ describe Profiles::PreferencesController do
allow(subject).to receive(:current_user).and_return(user)
end
- describe 'GET show' do
- it 'renders' do
+ describe "GET show" do
+ it "renders" do
get :show
expect(response).to render_template :show
end
- it 'assigns user' do
+ it "assigns user" do
get :show
expect(assigns[:user]).to eq user
end
end
- describe 'PATCH update' do
+ describe "PATCH update" do
def go(params: {}, format: :js)
params.reverse_merge!(
- color_scheme_id: '1',
- dashboard: 'stars',
- theme_id: '1'
+ color_scheme_id: "1",
+ dashboard: "stars",
+ theme_id: "1"
)
- patch :update, params: { user: params }, format: format
+ patch :update, params: {user: params}, format: format
end
- context 'on successful update' do
- it 'sets the flash' do
+ context "on successful update" do
+ it "sets the flash" do
go
- expect(flash[:notice]).to eq 'Preferences saved.'
+ expect(flash[:notice]).to eq "Preferences saved."
end
it "changes the user's preferences" do
prefs = {
- color_scheme_id: '1',
- dashboard: 'stars',
- theme_id: '2',
- first_day_of_week: '1',
- preferred_language: 'jp'
+ color_scheme_id: "1",
+ dashboard: "stars",
+ theme_id: "2",
+ first_day_of_week: "1",
+ preferred_language: "jp",
}.with_indifferent_access
expect(user).to receive(:assign_attributes).with(ActionController::Parameters.new(prefs).permit!)
@@ -54,19 +54,19 @@ describe Profiles::PreferencesController do
end
end
- context 'on failed update' do
- it 'sets the flash' do
+ context "on failed update" do
+ it "sets the flash" do
expect(user).to receive(:save).and_return(false)
go
- expect(flash[:alert]).to eq('Failed to save preferences.')
+ expect(flash[:alert]).to eq("Failed to save preferences.")
end
end
- context 'on invalid dashboard setting' do
- it 'sets the flash' do
- prefs = { dashboard: 'invalid' }
+ context "on invalid dashboard setting" do
+ it "sets the flash" do
+ prefs = {dashboard: "invalid"}
go params: prefs
@@ -74,15 +74,15 @@ describe Profiles::PreferencesController do
end
end
- context 'as js' do
- it 'renders' do
+ context "as js" do
+ it "renders" do
go
expect(response).to render_template :update
end
end
- context 'as html' do
- it 'redirects' do
+ context "as html" do
+ it "redirects" do
go format: :html
expect(response).to redirect_to(profile_preferences_path)
end
diff --git a/spec/controllers/profiles/two_factor_auths_controller_spec.rb b/spec/controllers/profiles/two_factor_auths_controller_spec.rb
index 0151a434998..1b86a1d893e 100644
--- a/spec/controllers/profiles/two_factor_auths_controller_spec.rb
+++ b/spec/controllers/profiles/two_factor_auths_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Profiles::TwoFactorAuthsController do
before do
@@ -8,18 +8,18 @@ describe Profiles::TwoFactorAuthsController do
allow(subject).to receive(:current_user).and_return(user)
end
- describe 'GET show' do
+ describe "GET show" do
let(:user) { create(:user) }
- it 'generates otp_secret for user' do
- expect(User).to receive(:generate_otp_secret).with(32).and_return('secret').once
+ it "generates otp_secret for user" do
+ expect(User).to receive(:generate_otp_secret).with(32).and_return("secret").once
get :show
get :show # Second hit shouldn't re-generate it
end
- it 'assigns qr_code' do
- code = double('qr code')
+ it "assigns qr_code" do
+ code = double("qr code")
expect(subject).to receive(:build_qr_code).and_return(code)
get :show
@@ -27,76 +27,76 @@ describe Profiles::TwoFactorAuthsController do
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:user) { create(:user) }
- let(:pin) { 'pin-code' }
+ let(:pin) { "pin-code" }
def go
- post :create, params: { pin_code: pin }
+ post :create, params: {pin_code: pin}
end
- context 'with valid pin' do
+ context "with valid pin" do
before do
expect(user).to receive(:validate_and_consume_otp!).with(pin).and_return(true)
end
- it 'enables 2fa for the user' do
+ it "enables 2fa for the user" do
go
user.reload
expect(user).to be_two_factor_enabled
end
- it 'presents plaintext codes for the user to save' do
- expect(user).to receive(:generate_otp_backup_codes!).and_return(%w(a b c))
+ it "presents plaintext codes for the user to save" do
+ expect(user).to receive(:generate_otp_backup_codes!).and_return(%w[a b c])
go
- expect(assigns[:codes]).to match_array %w(a b c)
+ expect(assigns[:codes]).to match_array %w[a b c]
end
- it 'renders create' do
+ it "renders create" do
go
expect(response).to render_template(:create)
end
end
- context 'with invalid pin' do
+ context "with invalid pin" do
before do
expect(user).to receive(:validate_and_consume_otp!).with(pin).and_return(false)
end
- it 'assigns error' do
+ it "assigns error" do
go
- expect(assigns[:error]).to eq 'Invalid pin code'
+ expect(assigns[:error]).to eq "Invalid pin code"
end
- it 'assigns qr_code' do
- code = double('qr code')
+ it "assigns qr_code" do
+ code = double("qr code")
expect(subject).to receive(:build_qr_code).and_return(code)
go
expect(assigns[:qr_code]).to eq code
end
- it 'renders show' do
+ it "renders show" do
go
expect(response).to render_template(:show)
end
end
end
- describe 'POST codes' do
+ describe "POST codes" do
let(:user) { create(:user, :two_factor) }
- it 'presents plaintext codes for the user to save' do
- expect(user).to receive(:generate_otp_backup_codes!).and_return(%w(a b c))
+ it "presents plaintext codes for the user to save" do
+ expect(user).to receive(:generate_otp_backup_codes!).and_return(%w[a b c])
post :codes
- expect(assigns[:codes]).to match_array %w(a b c)
+ expect(assigns[:codes]).to match_array %w[a b c]
end
- it 'persists the generated codes' do
+ it "persists the generated codes" do
post :codes
user.reload
@@ -104,16 +104,16 @@ describe Profiles::TwoFactorAuthsController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:user) { create(:user, :two_factor) }
- it 'disables two factor' do
+ it "disables two factor" do
expect(user).to receive(:disable_two_factor!)
delete :destroy
end
- it 'redirects to profile_account_path' do
+ it "redirects to profile_account_path" do
delete :destroy
expect(response).to redirect_to(profile_account_path)
diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb
index 11cb59aa12a..aa7061d2fc5 100644
--- a/spec/controllers/profiles_controller_spec.rb
+++ b/spec/controllers/profiles_controller_spec.rb
@@ -1,41 +1,41 @@
-require('spec_helper')
+require("spec_helper")
describe ProfilesController, :request_store do
let(:user) { create(:user) }
- describe 'POST update' do
- it 'does not update password' do
+ describe "POST update" do
+ it "does not update password" do
sign_in(user)
- expect do
+ expect {
post :update,
- params: { user: { password: 'hello12345', password_confirmation: 'hello12345' } }
- end.not_to change { user.reload.encrypted_password }
+ params: {user: {password: "hello12345", password_confirmation: "hello12345"}}
+ }.not_to change { user.reload.encrypted_password }
expect(response.status).to eq(302)
end
end
- describe 'PUT update' do
- it 'allows an email update from a user without an external email address' do
+ describe "PUT update" do
+ it "allows an email update from a user without an external email address" do
sign_in(user)
put :update,
- params: { user: { email: "john@gmail.com", name: "John" } }
+ params: {user: {email: "john@gmail.com", name: "John"}}
user.reload
expect(response.status).to eq(302)
- expect(user.unconfirmed_email).to eq('john@gmail.com')
+ expect(user.unconfirmed_email).to eq("john@gmail.com")
end
it "allows an email update without confirmation if existing verified email" do
user = create(:user)
- create(:email, :confirmed, user: user, email: 'john@gmail.com')
+ create(:email, :confirmed, user: user, email: "john@gmail.com")
sign_in(user)
put :update,
- params: { user: { email: "john@gmail.com", name: "John" } }
+ params: {user: {email: "john@gmail.com", name: "John"}}
user.reload
@@ -43,62 +43,62 @@ describe ProfilesController, :request_store do
expect(user.unconfirmed_email).to eq nil
end
- it 'ignores an email update from a user with an external email address' do
- stub_omniauth_setting(sync_profile_from_provider: ['ldap'])
+ it "ignores an email update from a user with an external email address" do
+ stub_omniauth_setting(sync_profile_from_provider: ["ldap"])
stub_omniauth_setting(sync_profile_attributes: true)
ldap_user = create(:omniauth_user)
- ldap_user.create_user_synced_attributes_metadata(provider: 'ldap', name_synced: true, email_synced: true)
+ ldap_user.create_user_synced_attributes_metadata(provider: "ldap", name_synced: true, email_synced: true)
sign_in(ldap_user)
put :update,
- params: { user: { email: "john@gmail.com", name: "John" } }
+ params: {user: {email: "john@gmail.com", name: "John"}}
ldap_user.reload
expect(response.status).to eq(302)
- expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
+ expect(ldap_user.unconfirmed_email).not_to eq("john@gmail.com")
end
- it 'ignores an email and name update but allows a location update from a user with external email and name, but not external location' do
- stub_omniauth_setting(sync_profile_from_provider: ['ldap'])
+ it "ignores an email and name update but allows a location update from a user with external email and name, but not external location" do
+ stub_omniauth_setting(sync_profile_from_provider: ["ldap"])
stub_omniauth_setting(sync_profile_attributes: true)
- ldap_user = create(:omniauth_user, name: 'Alex')
- ldap_user.create_user_synced_attributes_metadata(provider: 'ldap', name_synced: true, email_synced: true, location_synced: false)
+ ldap_user = create(:omniauth_user, name: "Alex")
+ ldap_user.create_user_synced_attributes_metadata(provider: "ldap", name_synced: true, email_synced: true, location_synced: false)
sign_in(ldap_user)
put :update,
- params: { user: { email: "john@gmail.com", name: "John", location: "City, Country" } }
+ params: {user: {email: "john@gmail.com", name: "John", location: "City, Country"}}
ldap_user.reload
expect(response.status).to eq(302)
- expect(ldap_user.unconfirmed_email).not_to eq('john@gmail.com')
- expect(ldap_user.name).not_to eq('John')
- expect(ldap_user.location).to eq('City, Country')
+ expect(ldap_user.unconfirmed_email).not_to eq("john@gmail.com")
+ expect(ldap_user.name).not_to eq("John")
+ expect(ldap_user.location).to eq("City, Country")
end
- it 'allows setting a user status' do
+ it "allows setting a user status" do
sign_in(user)
- put :update, params: { user: { status: { message: 'Working hard!' } } }
+ put :update, params: {user: {status: {message: "Working hard!"}}}
- expect(user.reload.status.message).to eq('Working hard!')
+ expect(user.reload.status.message).to eq("Working hard!")
expect(response).to have_gitlab_http_status(302)
end
end
- describe 'PUT update_username' do
+ describe "PUT update_username" do
let(:namespace) { user.namespace }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:new_username) { generate(:username) }
- it 'allows username change' do
+ it "allows username change" do
sign_in(user)
put :update_username,
- params: { user: { username: new_username } }
+ params: {user: {username: new_username}}
user.reload
@@ -106,47 +106,47 @@ describe ProfilesController, :request_store do
expect(user.username).to eq(new_username)
end
- it 'updates a username using JSON request' do
+ it "updates a username using JSON request" do
sign_in(user)
put :update_username,
- params: {
- user: { username: new_username }
- },
- format: :json
+ params: {
+ user: {username: new_username},
+ },
+ format: :json
expect(response.status).to eq(200)
- expect(json_response['message']).to eq('Username successfully changed')
+ expect(json_response["message"]).to eq("Username successfully changed")
end
- it 'renders an error message when the username was not updated' do
+ it "renders an error message when the username was not updated" do
sign_in(user)
put :update_username,
- params: {
- user: { username: 'invalid username.git' }
- },
- format: :json
+ params: {
+ user: {username: "invalid username.git"},
+ },
+ format: :json
expect(response.status).to eq(422)
- expect(json_response['message']).to match(/Username change failed/)
+ expect(json_response["message"]).to match(/Username change failed/)
end
- it 'raises a correct error when the username is missing' do
+ it "raises a correct error when the username is missing" do
sign_in(user)
- expect { put :update_username, params: { user: { gandalf: 'you shall not pass' } } }
+ expect { put :update_username, params: {user: {gandalf: "you shall not pass"}} }
.to raise_error(ActionController::ParameterMissing)
end
- context 'with legacy storage' do
- it 'moves dependent projects to new namespace' do
+ context "with legacy storage" do
+ it "moves dependent projects to new namespace" do
project = create(:project_empty_repo, :legacy_storage, namespace: namespace)
sign_in(user)
put :update_username,
- params: { user: { username: new_username } }
+ params: {user: {username: new_username}}
user.reload
@@ -155,8 +155,8 @@ describe ProfilesController, :request_store do
end
end
- context 'with hashed storage' do
- it 'keeps repository location unchanged on disk' do
+ context "with hashed storage" do
+ it "keeps repository location unchanged on disk" do
project = create(:project_empty_repo, namespace: namespace)
before_disk_path = project.disk_path
@@ -164,7 +164,7 @@ describe ProfilesController, :request_store do
sign_in(user)
put :update_username,
- params: { user: { username: new_username } }
+ params: {user: {username: new_username}}
user.reload
diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb
index 29df00e6bb0..9628ff4b194 100644
--- a/spec/controllers/projects/artifacts_controller_spec.rb
+++ b/spec/controllers/projects/artifacts_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ArtifactsController do
let(:user) { project.owner }
@@ -6,10 +6,10 @@ describe Projects::ArtifactsController do
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit.sha,
- ref: project.default_branch,
- status: 'success')
+ project: project,
+ sha: project.commit.sha,
+ ref: project.default_branch,
+ status: "success")
end
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
@@ -18,73 +18,74 @@ describe Projects::ArtifactsController do
sign_in(user)
end
- describe 'GET download' do
+ describe "GET download" do
def download_artifact(extra_params = {})
- params = { namespace_id: project.namespace, project_id: project, job_id: job }.merge(extra_params)
+ params = {namespace_id: project.namespace, project_id: project, job_id: job}.merge(extra_params)
get :download, params: params
end
- context 'when no file type is supplied' do
+ context "when no file type is supplied" do
let(:filename) { job.artifacts_file.filename }
- it 'sends the artifacts file' do
+ it "sends the artifacts file" do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expect(controller).to receive(:send_file)
- .with(
- job.artifacts_file.file.path,
- hash_including(disposition: %Q(attachment; filename*=UTF-8''#{filename}))).and_call_original
+ .with(
+ job.artifacts_file.file.path,
+ hash_including(disposition: %(attachment; filename*=UTF-8''#{filename}))
+ ).and_call_original
download_artifact
end
end
- context 'when a file type is supplied' do
- context 'when an invalid file type is supplied' do
- let(:file_type) { 'invalid' }
+ context "when a file type is supplied" do
+ context "when an invalid file type is supplied" do
+ let(:file_type) { "invalid" }
- it 'returns 404' do
+ it "returns 404" do
download_artifact(file_type: file_type)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when codequality file type is supplied' do
- let(:file_type) { 'codequality' }
+ context "when codequality file type is supplied" do
+ let(:file_type) { "codequality" }
let(:filename) { job.job_artifacts_codequality.filename }
- context 'when file is stored locally' do
+ context "when file is stored locally" do
before do
create(:ci_job_artifact, :codequality, job: job)
end
- it 'sends the codequality report' do
+ it "sends the codequality report" do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expect(controller).to receive(:send_file)
- .with(job.job_artifacts_codequality.file.path,
- hash_including(disposition: %Q(attachment; filename*=UTF-8''#{filename}))).and_call_original
+ .with(job.job_artifacts_codequality.file.path,
+ hash_including(disposition: %(attachment; filename*=UTF-8''#{filename}))).and_call_original
download_artifact(file_type: file_type)
end
end
- context 'when file is stored remotely' do
+ context "when file is stored remotely" do
before do
stub_artifacts_object_storage
create(:ci_job_artifact, :remote_store, :codequality, job: job)
end
- it 'sends the codequality report' do
+ it "sends the codequality report" do
expect(controller).to receive(:redirect_to).and_call_original
download_artifact(file_type: file_type)
end
- context 'when proxied' do
- it 'sends the codequality report' do
+ context "when proxied" do
+ it "sends the codequality report" do
expect(Gitlab::Workhorse).to receive(:send_url).and_call_original
download_artifact(file_type: file_type, proxy: true)
@@ -95,71 +96,71 @@ describe Projects::ArtifactsController do
end
end
- describe 'GET browse' do
- context 'when the directory exists' do
- it 'renders the browse view' do
- get :browse, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'other_artifacts_0.1.2' }
+ describe "GET browse" do
+ context "when the directory exists" do
+ it "renders the browse view" do
+ get :browse, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "other_artifacts_0.1.2"}
- expect(response).to render_template('projects/artifacts/browse')
+ expect(response).to render_template("projects/artifacts/browse")
end
end
- context 'when the directory does not exist' do
- it 'responds Not Found' do
- get :browse, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'unknown' }
+ context "when the directory does not exist" do
+ it "responds Not Found" do
+ get :browse, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "unknown"}
expect(response).to be_not_found
end
end
end
- describe 'GET file' do
+ describe "GET file" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
- context 'when the file is served by GitLab Pages' do
+ context "when the file is served by GitLab Pages" do
before do
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
- context 'when the file exists' do
- it 'renders the file view' do
- get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' }
+ context "when the file exists" do
+ it "renders the file view" do
+ get :file, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "ci_artifacts.txt"}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when the file does not exist' do
- it 'responds Not Found' do
- get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'unknown' }
+ context "when the file does not exist" do
+ it "responds Not Found" do
+ get :file, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "unknown"}
expect(response).to be_not_found
end
end
end
- context 'when the file is served through Rails' do
- context 'when the file exists' do
- it 'renders the file view' do
- get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'ci_artifacts.txt' }
+ context "when the file is served through Rails" do
+ context "when the file exists" do
+ it "renders the file view" do
+ get :file, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "ci_artifacts.txt"}
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to render_template('projects/artifacts/file')
+ expect(response).to render_template("projects/artifacts/file")
end
end
- context 'when the file does not exist' do
- it 'responds Not Found' do
- get :file, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: 'unknown' }
+ context "when the file does not exist" do
+ it "responds Not Found" do
+ get :file, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: "unknown"}
expect(response).to be_not_found
end
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:private_project) { create(:project, :repository, :private) }
let(:pipeline) { create(:ci_pipeline, project: private_project) }
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
@@ -170,33 +171,33 @@ describe Projects::ArtifactsController do
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
- it 'does not redirect the request' do
- get :file, params: { namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: 'ci_artifacts.txt' }
+ it "does not redirect the request" do
+ get :file, params: {namespace_id: private_project.namespace, project_id: private_project, job_id: job, path: "ci_artifacts.txt"}
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to render_template('projects/artifacts/file')
+ expect(response).to render_template("projects/artifacts/file")
end
end
end
- describe 'GET raw' do
- subject { get(:raw, params: { namespace_id: project.namespace, project_id: project, job_id: job, path: path }) }
+ describe "GET raw" do
+ subject { get(:raw, params: {namespace_id: project.namespace, project_id: project, job_id: job, path: path}) }
- context 'when the file exists' do
- let(:path) { 'ci_artifacts.txt' }
+ context "when the file exists" do
+ let(:path) { "ci_artifacts.txt" }
- shared_examples 'a valid file' do
- it 'serves the file using workhorse' do
+ shared_examples "a valid file" do
+ it "serves the file using workhorse" do
subject
expect(response).to have_gitlab_http_status(200)
- expect(send_data).to start_with('artifacts-entry:')
+ expect(send_data).to start_with("artifacts-entry:")
- expect(params.keys).to eq(%w(Archive Entry))
- expect(params['Archive']).to start_with(archive_path)
+ expect(params.keys).to eq(%w[Archive Entry])
+ expect(params["Archive"]).to start_with(archive_path)
# On object storage, the URL can end with a query string
- expect(params['Archive']).to match(/build_artifacts.zip(\?[^?]+)?$/)
- expect(params['Entry']).to eq(Base64.encode64('ci_artifacts.txt'))
+ expect(params["Archive"]).to match(/build_artifacts.zip(\?[^?]+)?$/)
+ expect(params["Entry"]).to eq(Base64.encode64("ci_artifacts.txt"))
end
def send_data
@@ -205,116 +206,116 @@ describe Projects::ArtifactsController do
def params
@params ||= begin
- base64_params = send_data.sub(/\Aartifacts\-entry:/, '')
+ base64_params = send_data.sub(/\Aartifacts\-entry:/, "")
JSON.parse(Base64.urlsafe_decode64(base64_params))
end
end
end
- context 'when using local file storage' do
- it_behaves_like 'a valid file' do
+ context "when using local file storage" do
+ it_behaves_like "a valid file" do
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
let(:store) { ObjectStorage::Store::LOCAL }
let(:archive_path) { JobArtifactUploader.root }
end
end
- context 'when using remote file storage' do
+ context "when using remote file storage" do
before do
stub_artifacts_object_storage
end
- it_behaves_like 'a valid file' do
+ it_behaves_like "a valid file" do
let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
let!(:job) { create(:ci_build, :success, pipeline: pipeline) }
let(:store) { ObjectStorage::Store::REMOTE }
- let(:archive_path) { 'https://' }
+ let(:archive_path) { "https://" }
end
end
end
end
- describe 'GET latest_succeeded' do
- def params_from_ref(ref = pipeline.ref, job_name = job.name, path = 'browse')
+ describe "GET latest_succeeded" do
+ def params_from_ref(ref = pipeline.ref, job_name = job.name, path = "browse")
{
namespace_id: project.namespace,
project_id: project,
ref_name_and_path: File.join(ref, path),
- job: job_name
+ job: job_name,
}
end
- context 'cannot find the job' do
- shared_examples 'not found' do
+ context "cannot find the job" do
+ shared_examples "not found" do
it { expect(response).to have_gitlab_http_status(:not_found) }
end
- context 'has no such ref' do
+ context "has no such ref" do
before do
- get :latest_succeeded, params: params_from_ref('TAIL', job.name)
+ get :latest_succeeded, params: params_from_ref("TAIL", job.name)
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'has no such job' do
+ context "has no such job" do
before do
- get :latest_succeeded, params: params_from_ref(pipeline.ref, 'NOBUILD')
+ get :latest_succeeded, params: params_from_ref(pipeline.ref, "NOBUILD")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'has no path' do
+ context "has no path" do
before do
- get :latest_succeeded, params: params_from_ref(pipeline.sha, job.name, '')
+ get :latest_succeeded, params: params_from_ref(pipeline.sha, job.name, "")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
- context 'found the job and redirect' do
- shared_examples 'redirect to the job' do
- it 'redirects' do
+ context "found the job and redirect" do
+ shared_examples "redirect to the job" do
+ it "redirects" do
path = browse_project_job_artifacts_path(project, job)
expect(response).to redirect_to(path)
end
end
- context 'with regular branch' do
+ context "with regular branch" do
before do
- pipeline.update(ref: 'master',
- sha: project.commit('master').sha)
+ pipeline.update(ref: "master",
+ sha: project.commit("master").sha)
- get :latest_succeeded, params: params_from_ref('master')
+ get :latest_succeeded, params: params_from_ref("master")
end
- it_behaves_like 'redirect to the job'
+ it_behaves_like "redirect to the job"
end
- context 'with branch name containing slash' do
+ context "with branch name containing slash" do
before do
- pipeline.update(ref: 'improve/awesome',
- sha: project.commit('improve/awesome').sha)
+ pipeline.update(ref: "improve/awesome",
+ sha: project.commit("improve/awesome").sha)
- get :latest_succeeded, params: params_from_ref('improve/awesome')
+ get :latest_succeeded, params: params_from_ref("improve/awesome")
end
- it_behaves_like 'redirect to the job'
+ it_behaves_like "redirect to the job"
end
- context 'with branch name and path containing slashes' do
+ context "with branch name and path containing slashes" do
before do
- pipeline.update(ref: 'improve/awesome',
- sha: project.commit('improve/awesome').sha)
+ pipeline.update(ref: "improve/awesome",
+ sha: project.commit("improve/awesome").sha)
- get :latest_succeeded, params: params_from_ref('improve/awesome', job.name, 'file/README.md')
+ get :latest_succeeded, params: params_from_ref("improve/awesome", job.name, "file/README.md")
end
- it 'redirects' do
- path = file_project_job_artifacts_path(project, job, 'README.md')
+ it "redirects" do
+ path = file_project_job_artifacts_path(project, job, "README.md")
expect(response).to redirect_to(path)
end
diff --git a/spec/controllers/projects/autocomplete_sources_controller_spec.rb b/spec/controllers/projects/autocomplete_sources_controller_spec.rb
index 4bc72042710..cbc0aa4fd35 100644
--- a/spec/controllers/projects/autocomplete_sources_controller_spec.rb
+++ b/spec/controllers/projects/autocomplete_sources_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::AutocompleteSourcesController do
set(:group) { create(:group) }
@@ -8,21 +8,21 @@ describe Projects::AutocompleteSourcesController do
set(:issue) { create(:issue, project: project) }
set(:user) { create(:user) }
- describe 'GET members' do
+ describe "GET members" do
before do
group.add_owner(user)
sign_in(user)
end
- it 'returns an array of member object' do
- get :members, format: :json, params: { namespace_id: group.path, project_id: project.path, type: issue.class.name, type_id: issue.id }
+ it "returns an array of member object" do
+ get :members, format: :json, params: {namespace_id: group.path, project_id: project.path, type: issue.class.name, type_id: issue.id}
- all = json_response.find {|member| member["username"] == 'all'}
+ all = json_response.find {|member| member["username"] == "all"}
the_group = json_response.find {|member| member["username"] == group.full_path}
the_user = json_response.find {|member| member["username"] == user.username}
- expect(all.symbolize_keys).to include(username: 'all',
- name: 'All Project and Group Members',
+ expect(all.symbolize_keys).to include(username: "all",
+ name: "All Project and Group Members",
count: 1)
expect(the_group.symbolize_keys).to include(type: group.class.name,
diff --git a/spec/controllers/projects/avatars_controller_spec.rb b/spec/controllers/projects/avatars_controller_spec.rb
index 95b7ae5885a..d2e7e06d0bf 100644
--- a/spec/controllers/projects/avatars_controller_spec.rb
+++ b/spec/controllers/projects/avatars_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::AvatarsController do
let(:project) { create(:project, :repository) }
@@ -7,47 +7,47 @@ describe Projects::AvatarsController do
controller.instance_variable_set(:@project, project)
end
- describe 'GET #show' do
- subject { get :show, params: { namespace_id: project.namespace, project_id: project } }
+ describe "GET #show" do
+ subject { get :show, params: {namespace_id: project.namespace, project_id: project} }
- context 'when repository has no avatar' do
- it 'shows 404' do
+ context "when repository has no avatar" do
+ it "shows 404" do
subject
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when repository has an avatar' do
+ context "when repository has an avatar" do
before do
allow(project).to receive(:avatar_in_git).and_return(filepath)
end
- context 'when the avatar is stored in the repository' do
- let(:filepath) { 'files/images/logo-white.png' }
+ context "when the avatar is stored in the repository" do
+ let(:filepath) { "files/images/logo-white.png" }
- it 'sends the avatar' do
+ it "sends the avatar" do
subject
expect(response).to have_gitlab_http_status(200)
- expect(response.header['Content-Disposition']).to eq('inline')
- expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
+ expect(response.header["Content-Disposition"]).to eq("inline")
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
end
- context 'when the avatar is stored in lfs' do
- it_behaves_like 'repository lfs file load' do
- let(:filename) { 'lfs_object.iso' }
+ context "when the avatar is stored in lfs" do
+ it_behaves_like "repository lfs file load" do
+ let(:filename) { "lfs_object.iso" }
let(:filepath) { "files/lfs/#{filename}" }
end
end
end
end
- describe 'DELETE #destroy' do
- it 'removes avatar from DB by calling destroy' do
- delete :destroy, params: { namespace_id: project.namespace.id, project_id: project.id }
+ describe "DELETE #destroy" do
+ it "removes avatar from DB by calling destroy" do
+ delete :destroy, params: {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/badges_controller_spec.rb b/spec/controllers/projects/badges_controller_spec.rb
index 8eac3d9a459..6a18388cd48 100644
--- a/spec/controllers/projects/badges_controller_spec.rb
+++ b/spec/controllers/projects/badges_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::BadgesController do
let(:project) { pipeline.project }
@@ -10,45 +10,45 @@ describe Projects::BadgesController do
sign_in(user)
end
- it 'requests the pipeline badge successfully' do
+ it "requests the pipeline badge successfully" do
get_badge(:pipeline)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'requests the coverage badge successfully' do
+ it "requests the coverage badge successfully" do
get_badge(:coverage)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'renders the `flat` badge layout by default' do
+ it "renders the `flat` badge layout by default" do
get_badge(:coverage)
- expect(response).to render_template('projects/badges/badge')
+ expect(response).to render_template("projects/badges/badge")
end
- context 'when style param is set to `flat`' do
- it 'renders the `flat` badge layout' do
- get_badge(:coverage, 'flat')
+ context "when style param is set to `flat`" do
+ it "renders the `flat` badge layout" do
+ get_badge(:coverage, "flat")
- expect(response).to render_template('projects/badges/badge')
+ expect(response).to render_template("projects/badges/badge")
end
end
- context 'when style param is set to an invalid type' do
- it 'renders the `flat` (default) badge layout' do
- get_badge(:coverage, 'xxx')
+ context "when style param is set to an invalid type" do
+ it "renders the `flat` (default) badge layout" do
+ get_badge(:coverage, "xxx")
- expect(response).to render_template('projects/badges/badge')
+ expect(response).to render_template("projects/badges/badge")
end
end
- context 'when style param is set to `flat-square`' do
- it 'renders the `flat-square` badge layout' do
- get_badge(:coverage, 'flat-square')
+ context "when style param is set to `flat-square`" do
+ it "renders the `flat-square` badge layout" do
+ get_badge(:coverage, "flat-square")
- expect(response).to render_template('projects/badges/badge_flat-square')
+ expect(response).to render_template("projects/badges/badge_flat-square")
end
end
@@ -57,7 +57,7 @@ describe Projects::BadgesController do
namespace_id: project.namespace.to_param,
project_id: project,
ref: pipeline.ref,
- style: style
+ style: style,
}
get badge, params: params, format: :svg
diff --git a/spec/controllers/projects/blame_controller_spec.rb b/spec/controllers/projects/blame_controller_spec.rb
index eb110ea0002..1eaa67fc867 100644
--- a/spec/controllers/projects/blame_controller_spec.rb
+++ b/spec/controllers/projects/blame_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::BlameController do
let(:project) { create(:project, :repository) }
@@ -16,20 +16,20 @@ describe Projects::BlameController do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ })
end
context "valid file" do
- let(:id) { 'master/files/ruby/popen.rb' }
+ let(:id) { "master/files/ruby/popen.rb" }
it { is_expected.to respond_with(:success) }
end
context "invalid file" do
- let(:id) { 'master/files/ruby/missing_file.rb'}
+ let(:id) { "master/files/ruby/missing_file.rb"}
it { expect(response).to have_gitlab_http_status(404) }
end
end
diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb
index 38957e96798..8d6a86a2b81 100644
--- a/spec/controllers/projects/blob_controller_spec.rb
+++ b/spec/controllers/projects/blob_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe Projects::BlobController do
include ProjectForksHelper
@@ -8,99 +8,99 @@ describe Projects::BlobController do
describe "GET show" do
render_views
- context 'with file path' do
+ context "with file path" do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ })
end
context "valid branch, valid file" do
- let(:id) { 'master/README.md' }
+ let(:id) { "master/README.md" }
it { is_expected.to respond_with(:success) }
end
context "valid branch, invalid file" do
- let(:id) { 'master/invalid-path.rb' }
+ let(:id) { "master/invalid-path.rb" }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid file" do
- let(:id) { 'invalid-branch/README.md' }
+ let(:id) { "invalid-branch/README.md" }
it { is_expected.to respond_with(:not_found) }
end
context "binary file" do
- let(:id) { 'binary-encoding/encoding/binary-1.bin' }
+ let(:id) { "binary-encoding/encoding/binary-1.bin" }
it { is_expected.to respond_with(:success) }
end
context "Markdown file" do
- let(:id) { 'master/README.md' }
+ let(:id) { "master/README.md" }
it { is_expected.to respond_with(:success) }
end
end
- context 'with file path and JSON format' do
+ context "with file path and JSON format" do
context "valid branch, valid file" do
- let(:id) { 'master/README.md' }
+ let(:id) { "master/README.md" }
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- },
- format: :json)
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ },
+ format: :json)
end
it do
expect(response).to be_ok
- expect(json_response).to have_key 'html'
- expect(json_response).to have_key 'raw_path'
+ expect(json_response).to have_key "html"
+ expect(json_response).to have_key "raw_path"
end
end
context "with viewer=none" do
- let(:id) { 'master/README.md' }
+ let(:id) { "master/README.md" }
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id,
- viewer: 'none'
- },
- format: :json)
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ viewer: "none",
+ },
+ format: :json)
end
it do
expect(response).to be_ok
- expect(json_response).not_to have_key 'html'
- expect(json_response).to have_key 'raw_path'
+ expect(json_response).not_to have_key "html"
+ expect(json_response).to have_key "raw_path"
end
end
end
- context 'with tree path' do
+ context "with tree path" do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ })
controller.instance_variable_set(:@blob, nil)
end
- context 'redirect to tree' do
- let(:id) { 'markdown/doc' }
- it 'redirects' do
+ context "redirect to tree" do
+ let(:id) { "markdown/doc" }
+ it "redirects" do
expect(subject)
.to redirect_to("/#{project.full_path}/tree/markdown/doc")
end
@@ -108,15 +108,15 @@ describe Projects::BlobController do
end
end
- describe 'GET diff' do
+ describe "GET diff" do
let(:user) { create(:user) }
render_views
def do_get(opts = {})
- params = { namespace_id: project.namespace,
- project_id: project,
- id: 'master/CHANGELOG' }
+ params = {namespace_id: project.namespace,
+ project_id: project,
+ id: "master/CHANGELOG",}
get :diff, params: params.merge(opts)
end
@@ -126,43 +126,43 @@ describe Projects::BlobController do
sign_in(user)
end
- context 'when essential params are missing' do
- it 'renders nothing' do
+ context "when essential params are missing" do
+ it "renders nothing" do
do_get
expect(response.body).to be_blank
end
end
- context 'when essential params are present' do
- context 'when rendering for commit' do
- it 'renders the diff content' do
+ context "when essential params are present" do
+ context "when rendering for commit" do
+ it "renders the diff content" do
do_get(since: 1, to: 5, offset: 10)
expect(response.body).to be_present
end
end
- context 'when rendering for merge request' do
- it 'renders diff context lines Gitlab::Diff::Line array' do
+ context "when rendering for merge request" do
+ it "renders diff context lines Gitlab::Diff::Line array" do
do_get(since: 1, to: 5, offset: 10, from_merge_request: true)
lines = JSON.parse(response.body)
- expect(lines.first).to have_key('type')
- expect(lines.first).to have_key('rich_text')
- expect(lines.first).to have_key('rich_text')
+ expect(lines.first).to have_key("type")
+ expect(lines.first).to have_key("rich_text")
+ expect(lines.first).to have_key("rich_text")
end
- context 'when rendering match lines' do
+ context "when rendering match lines" do
it 'adds top match line when "since" is less than 1' do
do_get(since: 5, to: 10, offset: 10, from_merge_request: true)
match_line = JSON.parse(response.body).first
- expect(match_line['type']).to eq('match')
- expect(match_line['meta_data']).to have_key('old_pos')
- expect(match_line['meta_data']).to have_key('new_pos')
+ expect(match_line["type"]).to eq("match")
+ expect(match_line["meta_data"]).to have_key("old_pos")
+ expect(match_line["meta_data"]).to have_key("new_pos")
end
it 'does not add top match line when "since" is equal 1' do
@@ -170,7 +170,7 @@ describe Projects::BlobController do
match_line = JSON.parse(response.body).first
- expect(match_line['type']).to be_nil
+ expect(match_line["type"]).to be_nil
end
it 'adds bottom match line when "t"o is less than blob size' do
@@ -178,45 +178,45 @@ describe Projects::BlobController do
match_line = JSON.parse(response.body).last
- expect(match_line['type']).to eq('match')
- expect(match_line['meta_data']).to have_key('old_pos')
- expect(match_line['meta_data']).to have_key('new_pos')
+ expect(match_line["type"]).to eq("match")
+ expect(match_line["meta_data"]).to have_key("old_pos")
+ expect(match_line["meta_data"]).to have_key("new_pos")
end
it 'does not add bottom match line when "to" is less than blob size' do
- commit_id = project.repository.commit('master').id
- blob = project.repository.blob_at(commit_id, 'CHANGELOG')
+ commit_id = project.repository.commit("master").id
+ blob = project.repository.blob_at(commit_id, "CHANGELOG")
do_get(since: 1, to: blob.lines.count, offset: 10, from_merge_request: true, bottom: true)
match_line = JSON.parse(response.body).last
- expect(match_line['type']).to be_nil
+ expect(match_line["type"]).to be_nil
end
end
end
end
end
- describe 'GET edit' do
+ describe "GET edit" do
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
- id: 'master/CHANGELOG'
+ id: "master/CHANGELOG",
}
end
- context 'anonymous' do
+ context "anonymous" do
before do
get :edit, params: default_params
end
- it 'redirects to sign in and returns' do
+ it "redirects to sign in and returns" do
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'as guest' do
+ context "as guest" do
let(:guest) { create(:user) }
before do
@@ -224,12 +224,12 @@ describe Projects::BlobController do
get :edit, params: default_params
end
- it 'redirects to blob show' do
- expect(response).to redirect_to(project_blob_path(project, 'master/CHANGELOG'))
+ it "redirects to blob show" do
+ expect(response).to redirect_to(project_blob_path(project, "master/CHANGELOG"))
end
end
- context 'as developer' do
+ context "as developer" do
let(:developer) { create(:user) }
before do
@@ -238,12 +238,12 @@ describe Projects::BlobController do
get :edit, params: default_params
end
- it 'redirects to blob show' do
+ it "redirects to blob show" do
expect(response).to have_gitlab_http_status(200)
end
end
- context 'as maintainer' do
+ context "as maintainer" do
let(:maintainer) { create(:user) }
before do
@@ -252,27 +252,27 @@ describe Projects::BlobController do
get :edit, params: default_params
end
- it 'redirects to blob show' do
+ it "redirects to blob show" do
expect(response).to have_gitlab_http_status(200)
end
end
end
- describe 'PUT update' do
+ describe "PUT update" do
let(:user) { create(:user) }
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
- id: 'master/CHANGELOG',
- branch_name: 'master',
- content: 'Added changes',
- commit_message: 'Update CHANGELOG'
+ id: "master/CHANGELOG",
+ branch_name: "master",
+ content: "Added changes",
+ commit_message: "Update CHANGELOG",
}
end
def blob_after_edit_path
- project_blob_path(project, 'master/CHANGELOG')
+ project_blob_path(project, "master/CHANGELOG")
end
before do
@@ -281,21 +281,21 @@ describe Projects::BlobController do
sign_in(user)
end
- it 'redirects to blob' do
+ it "redirects to blob" do
put :update, params: default_params
expect(response).to redirect_to(blob_after_edit_path)
end
- context '?from_merge_request_iid' do
+ context "?from_merge_request_iid" do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:mr_params) { default_params.merge(from_merge_request_iid: merge_request.iid) }
- it 'redirects to MR diff' do
+ it "redirects to MR diff" do
put :update, params: mr_params
after_edit_path = diffs_project_merge_request_path(project, merge_request)
- file_anchor = "##{Digest::SHA1.hexdigest('CHANGELOG')}"
+ file_anchor = "##{Digest::SHA1.hexdigest("CHANGELOG")}"
expect(response).to redirect_to(after_edit_path + file_anchor)
end
@@ -313,7 +313,7 @@ describe Projects::BlobController do
end
end
- context 'when user has forked project' do
+ context "when user has forked project" do
let!(:forked_project) { fork_project(project, guest, namespace: guest.namespace, repository: true) }
let(:guest) { create(:user) }
@@ -321,20 +321,20 @@ describe Projects::BlobController do
sign_in(guest)
end
- context 'when editing on the fork' do
+ context "when editing on the fork" do
before do
default_params[:namespace_id] = forked_project.namespace
default_params[:project_id] = forked_project
end
- it 'redirects to blob' do
+ it "redirects to blob" do
put :update, params: default_params
- expect(response).to redirect_to(project_blob_path(forked_project, 'master/CHANGELOG'))
+ expect(response).to redirect_to(project_blob_path(forked_project, "master/CHANGELOG"))
end
end
- context 'when editing on the original repository' do
+ context "when editing on the original repository" do
it "redirects to forked project new merge request" do
default_params[:branch_name] = "fork-test-1"
default_params[:create_merge_request] = 1
@@ -348,7 +348,7 @@ describe Projects::BlobController do
source_project_id: forked_project.id,
target_project_id: project.id,
source_branch: "fork-test-1",
- target_branch: "master"
+ target_branch: "master",
}
)
)
@@ -357,9 +357,9 @@ describe Projects::BlobController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:user) { create(:user) }
- let(:project_root_path) { project_tree_path(project, 'master') }
+ let(:project_root_path) { project_tree_path(project, "master") }
before do
project.add_maintainer(user)
@@ -367,60 +367,60 @@ describe Projects::BlobController do
sign_in(user)
end
- context 'for a file in a subdirectory' do
+ context "for a file in a subdirectory" do
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
- id: 'master/files/whitespace',
- original_branch: 'master',
- branch_name: 'master',
- commit_message: 'Delete whitespace'
+ id: "master/files/whitespace",
+ original_branch: "master",
+ branch_name: "master",
+ commit_message: "Delete whitespace",
}
end
- let(:after_delete_path) { project_tree_path(project, 'master/files') }
+ let(:after_delete_path) { project_tree_path(project, "master/files") }
- it 'redirects to the sub directory' do
+ it "redirects to the sub directory" do
delete :destroy, params: default_params
expect(response).to redirect_to(after_delete_path)
end
end
- context 'if deleted file is the last one in a subdirectory' do
+ context "if deleted file is the last one in a subdirectory" do
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
- id: 'master/bar/branch-test.txt',
- original_branch: 'master',
- branch_name: 'master',
- commit_message: 'Delete whitespace'
+ id: "master/bar/branch-test.txt",
+ original_branch: "master",
+ branch_name: "master",
+ commit_message: "Delete whitespace",
}
end
- it 'redirects to the project root' do
+ it "redirects to the project root" do
delete :destroy, params: default_params
expect(response).to redirect_to(project_root_path)
end
- context 'when deleting a file in a branch other than master' do
+ context "when deleting a file in a branch other than master" do
let(:default_params) do
{
namespace_id: project.namespace,
project_id: project,
- id: 'binary-encoding/foo/bar/.gitkeep',
- original_branch: 'binary-encoding',
- branch_name: 'binary-encoding',
- commit_message: 'Delete whitespace'
+ id: "binary-encoding/foo/bar/.gitkeep",
+ original_branch: "binary-encoding",
+ branch_name: "binary-encoding",
+ commit_message: "Delete whitespace",
}
end
- let(:after_delete_path) { project_tree_path(project, 'binary-encoding') }
+ let(:after_delete_path) { project_tree_path(project, "binary-encoding") }
- it 'redirects to the project root of the branch' do
+ it "redirects to the project root of the branch" do
delete :destroy, params: default_params
expect(response).to redirect_to(after_delete_path)
diff --git a/spec/controllers/projects/boards_controller_spec.rb b/spec/controllers/projects/boards_controller_spec.rb
index 09199067024..b95d79827b4 100644
--- a/spec/controllers/projects/boards_controller_spec.rb
+++ b/spec/controllers/projects/boards_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::BoardsController do
let(:project) { create(:project) }
@@ -9,26 +9,26 @@ describe Projects::BoardsController do
sign_in(user)
end
- describe 'GET index' do
- it 'creates a new project board when project does not have one' do
+ describe "GET index" do
+ it "creates a new project board when project does not have one" do
expect { list_boards }.to change(project.boards, :count).by(1)
end
- it 'sets boards_endpoint instance variable to a boards path' do
+ it "sets boards_endpoint instance variable to a boards path" do
list_boards
expect(assigns(:boards_endpoint)).to eq project_boards_path(project)
end
- context 'when format is HTML' do
- it 'renders template' do
+ context "when format is HTML" do
+ it "renders template" do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- it 'redirects to latest visited board' do
+ it "redirects to latest visited board" do
board = create(:board, project: project)
create(:board_project_recent_visit, project: board.project, board: board, user: user)
@@ -37,7 +37,7 @@ describe Projects::BoardsController do
expect(response).to redirect_to(namespace_project_board_path(id: board.id))
end
- it 'renders template if visited board is not found' do
+ it "renders template if visited board is not found" do
temporary_board = create(:board, project: project)
visited = create(:board_project_recent_visit, project: temporary_board.project, board: temporary_board, user: user)
temporary_board.delete
@@ -47,27 +47,27 @@ describe Projects::BoardsController do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
list_boards
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
- context 'when user is signed out' do
+ context "when user is signed out" do
let(:project) { create(:project, :public) }
- it 'renders template' do
+ it "renders template" do
sign_out(user)
board = create(:board, project: project)
@@ -76,13 +76,13 @@ describe Projects::BoardsController do
list_boards
expect(response).to render_template :index
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
end
- context 'when format is JSON' do
- it 'returns a list of project boards' do
+ context "when format is JSON" do
+ it "returns a list of project boards" do
create_list(:board, 2, project: project)
expect(Boards::Visits::LatestService).not_to receive(:new)
@@ -91,29 +91,29 @@ describe Projects::BoardsController do
parsed_response = JSON.parse(response.body)
- expect(response).to match_response_schema('boards')
+ expect(response).to match_response_schema("boards")
expect(parsed_response.length).to eq 2
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
list_boards format: :json
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
end
- context 'issues are disabled' do
+ context "issues are disabled" do
let(:project) { create(:project, :issues_disabled) }
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
list_boards
expect(response).to have_gitlab_http_status(404)
@@ -122,84 +122,84 @@ describe Projects::BoardsController do
def list_boards(format: :html)
get :index, params: {
- namespace_id: project.namespace,
- project_id: project
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ },
format: format
end
end
- describe 'GET show' do
+ describe "GET show" do
let!(:board) { create(:board, project: project) }
- it 'sets boards_endpoint instance variable to a boards path' do
+ it "sets boards_endpoint instance variable to a boards path" do
read_board board: board
expect(assigns(:boards_endpoint)).to eq project_boards_path(project)
end
- context 'when format is HTML' do
- it 'renders template' do
+ context "when format is HTML" do
+ it "renders template" do
expect { read_board board: board }.to change(BoardProjectRecentVisit, :count).by(1)
expect(response).to render_template :show
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
read_board board: board
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
- context 'when user is signed out' do
+ context "when user is signed out" do
let(:project) { create(:project, :public) }
- it 'does not save visit' do
+ it "does not save visit" do
sign_out(user)
expect { read_board board: board }.to change(BoardProjectRecentVisit, :count).by(0)
expect(response).to render_template :show
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
end
end
- context 'when format is JSON' do
- it 'returns project board' do
+ context "when format is JSON" do
+ it "returns project board" do
expect(Boards::Visits::CreateService).not_to receive(:new)
read_board board: board, format: :json
- expect(response).to match_response_schema('board')
+ expect(response).to match_response_schema("board")
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_project, project).and_return(true)
allow(Ability).to receive(:allowed?).with(user, :read_board, project).and_return(false)
end
- it 'returns a not found 404 response' do
+ it "returns a not found 404 response" do
read_board board: board, format: :json
expect(response).to have_gitlab_http_status(404)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
end
- context 'when board does not belong to project' do
- it 'returns a not found 404 response' do
+ context "when board does not belong to project" do
+ it "returns a not found 404 response" do
another_board = create(:board)
read_board board: another_board
@@ -210,10 +210,10 @@ describe Projects::BoardsController do
def read_board(board:, format: :html)
get :show, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: board.to_param
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: board.to_param,
+ },
format: format
end
end
diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb
index 52a20fa8d07..0878dd8ed87 100644
--- a/spec/controllers/projects/branches_controller_spec.rb
+++ b/spec/controllers/projects/branches_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::BranchesController do
let(:project) { create(:project, :repository) }
@@ -9,8 +9,8 @@ describe Projects::BranchesController do
project.add_maintainer(user)
project.add_developer(user)
- allow(project).to receive(:branches).and_return(['master', 'foo/bar/baz'])
- allow(project).to receive(:tags).and_return(['v1.0.0', 'v2.0.0'])
+ allow(project).to receive(:branches).and_return(["master", "foo/bar/baz"])
+ allow(project).to receive(:tags).and_return(["v1.0.0", "v2.0.0"])
controller.instance_variable_set(:@project, project)
end
@@ -22,18 +22,18 @@ describe Projects::BranchesController do
sign_in(user)
post :create,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- branch_name: branch,
- ref: ref
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ branch_name: branch,
+ ref: ref,
+ }
end
context "valid branch name, valid source" do
let(:branch) { "merge_branch" }
let(:ref) { "master" }
- it 'redirects' do
+ it "redirects" do
expect(subject)
.to redirect_to("/#{project.full_path}/tree/merge_branch")
end
@@ -42,7 +42,7 @@ describe Projects::BranchesController do
context "invalid branch name, valid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "master" }
- it 'redirects' do
+ it "redirects" do
expect(subject)
.to redirect_to("/#{project.full_path}/tree/alert('merge');")
end
@@ -51,20 +51,20 @@ describe Projects::BranchesController do
context "valid branch name, invalid ref" do
let(:branch) { "merge_branch" }
let(:ref) { "<script>alert('ref');</script>" }
- it { is_expected.to render_template('new') }
+ it { is_expected.to render_template("new") }
end
context "invalid branch name, invalid ref" do
let(:branch) { "<script>alert('merge');</script>" }
let(:ref) { "<script>alert('ref');</script>" }
- it { is_expected.to render_template('new') }
+ it { is_expected.to render_template("new") }
end
context "valid branch name with encoded slashes" do
let(:branch) { "feature%2Ftest" }
let(:ref) { "<script>alert('ref');</script>" }
- it { is_expected.to render_template('new') }
- it { project.repository.branch_exists?('feature/test') }
+ it { is_expected.to render_template("new") }
+ it { project.repository.branch_exists?("feature/test") }
end
end
@@ -76,89 +76,89 @@ describe Projects::BranchesController do
sign_in(user)
end
- it 'redirects' do
+ it "redirects" do
post :create,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
expect(subject)
.to redirect_to("/#{project.full_path}/tree/1-feature-branch")
end
- it 'posts a system note' do
+ it "posts a system note" do
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, "1-feature-branch")
post :create,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
end
- context 'repository-less project' do
+ context "repository-less project" do
let(:project) { create :project }
- it 'redirects to newly created branch' do
- result = { status: :success, branch: double(name: branch) }
+ it "redirects to newly created branch" do
+ result = {status: :success, branch: double(name: branch)}
expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result)
expect(SystemNoteService).to receive(:new_issue_branch).and_return(true)
post :create,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
expect(response).to redirect_to project_tree_path(project, branch)
end
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'redirects to autodeploy setup page' do
- result = { status: :success, branch: double(name: branch) }
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "redirects to autodeploy setup page" do
+ result = {status: :success, branch: double(name: branch)}
expect_any_instance_of(CreateBranchService).to receive(:execute).and_return(result)
expect(SystemNoteService).to receive(:new_issue_branch).and_return(true)
post :create,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
before do
project.services << build(:kubernetes_service)
end
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
before do
create(:cluster, :provided_by_gcp, projects: [project])
end
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- it 'redirects to autodeploy setup page' do
- result = { status: :success, branch: double(name: branch) }
+ it "redirects to autodeploy setup page" do
+ result = {status: :success, branch: double(name: branch)}
create(:cluster, :provided_by_gcp, projects: [project])
@@ -166,35 +166,35 @@ describe Projects::BranchesController do
expect(SystemNoteService).to receive(:new_issue_branch).and_return(true)
post :create,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
expect(response.location).to include(project_new_blob_path(project, branch))
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when create branch service fails' do
+ context "when create branch service fails" do
let(:branch) { "./invalid-branch-name" }
it "doesn't post a system note" do
expect(SystemNoteService).not_to receive(:new_issue_branch)
post :create,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
end
end
- context 'without issue feature access' do
+ context "without issue feature access" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
@@ -205,38 +205,38 @@ describe Projects::BranchesController do
expect(SystemNoteService).not_to receive(:new_issue_branch)
post :create,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- branch_name: branch,
- issue_iid: issue.iid
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ branch_name: branch,
+ issue_iid: issue.iid,
+ }
end
end
end
end
- describe 'POST create with JSON format' do
+ describe "POST create with JSON format" do
before do
sign_in(user)
end
- context 'with valid params' do
- it 'returns a successful 200 response' do
- create_branch name: 'my-branch', ref: 'master'
+ context "with valid params" do
+ it "returns a successful 200 response" do
+ create_branch name: "my-branch", ref: "master"
expect(response).to have_gitlab_http_status(200)
end
- it 'returns the created branch' do
- create_branch name: 'my-branch', ref: 'master'
+ it "returns the created branch" do
+ create_branch name: "my-branch", ref: "master"
- expect(response).to match_response_schema('branch')
+ expect(response).to match_response_schema("branch")
end
end
- context 'with invalid params' do
- it 'returns an unprocessable entity 422 response' do
+ context "with invalid params" do
+ it "returns an unprocessable entity 422 response" do
create_branch name: "<script>alert('merge');</script>", ref: "<script>alert('ref');</script>"
expect(response).to have_gitlab_http_status(422)
@@ -245,13 +245,13 @@ describe Projects::BranchesController do
def create_branch(name:, ref:)
post :create,
- format: :json,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- branch_name: name,
- ref: ref
- }
+ format: :json,
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ branch_name: name,
+ ref: ref,
+ }
end
end
@@ -262,14 +262,14 @@ describe Projects::BranchesController do
sign_in(user)
end
- it 'returns 303' do
+ it "returns 303" do
post :destroy,
- format: :html,
- params: {
- id: 'foo/bar/baz',
- namespace_id: project.namespace,
- project_id: project
- }
+ format: :html,
+ params: {
+ id: "foo/bar/baz",
+ namespace_id: project.namespace,
+ project_id: project,
+ }
expect(response).to have_gitlab_http_status(303)
end
@@ -282,15 +282,15 @@ describe Projects::BranchesController do
sign_in(user)
post :destroy,
- format: format,
- params: {
- id: branch,
- namespace_id: project.namespace,
- project_id: project
- }
+ format: format,
+ params: {
+ id: branch,
+ namespace_id: project.namespace,
+ project_id: project,
+ }
end
- context 'as JS' do
+ context "as JS" do
let(:branch) { "feature" }
let(:format) { :js }
@@ -323,56 +323,56 @@ describe Projects::BranchesController do
end
end
- context 'as JSON' do
+ context "as JSON" do
let(:branch) { "feature" }
let(:format) { :json }
- context 'valid branch name, valid source' do
+ context "valid branch name, valid source" do
let(:branch) { "feature" }
- it 'returns JSON response with message' do
- expect(json_response).to eql("message" => 'Branch was deleted')
+ it "returns JSON response with message" do
+ expect(json_response).to eql("message" => "Branch was deleted")
end
it { expect(response).to have_gitlab_http_status(200) }
end
- context 'valid branch name with unencoded slashes' do
+ context "valid branch name with unencoded slashes" do
let(:branch) { "improve/awesome" }
- it 'returns JSON response with message' do
- expect(json_response).to eql('message' => 'Branch was deleted')
+ it "returns JSON response with message" do
+ expect(json_response).to eql("message" => "Branch was deleted")
end
it { expect(response).to have_gitlab_http_status(200) }
end
context "valid branch name with encoded slashes" do
- let(:branch) { 'improve%2Fawesome' }
+ let(:branch) { "improve%2Fawesome" }
- it 'returns JSON response with message' do
- expect(json_response).to eql('message' => 'Branch was deleted')
+ it "returns JSON response with message" do
+ expect(json_response).to eql("message" => "Branch was deleted")
end
it { expect(response).to have_gitlab_http_status(200) }
end
- context 'invalid branch name, valid ref' do
- let(:branch) { 'no-branch' }
+ context "invalid branch name, valid ref" do
+ let(:branch) { "no-branch" }
- it 'returns JSON response with message' do
- expect(json_response).to eql('message' => 'No such branch')
+ it "returns JSON response with message" do
+ expect(json_response).to eql("message" => "No such branch")
end
it { expect(response).to have_gitlab_http_status(404) }
end
end
- context 'as HTML' do
+ context "as HTML" do
let(:branch) { "feature" }
let(:format) { :html }
- it 'redirects to branches path' do
+ it "redirects to branches path" do
expect(response)
.to redirect_to(project_branches_path(project))
end
@@ -382,36 +382,36 @@ describe Projects::BranchesController do
describe "DELETE destroy_all_merged" do
def destroy_all_merged
delete :destroy_all_merged,
- params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ }
end
- context 'when user is allowed to push' do
+ context "when user is allowed to push" do
before do
sign_in(user)
end
- it 'redirects to branches' do
+ it "redirects to branches" do
destroy_all_merged
expect(response).to redirect_to project_branches_path(project)
end
- it 'starts worker to delete merged branches' do
+ it "starts worker to delete merged branches" do
expect_any_instance_of(DeleteMergedBranchesService).to receive(:async_execute)
destroy_all_merged
end
end
- context 'when user is not allowed to push' do
+ context "when user is not allowed to push" do
before do
sign_in(developer)
end
- it 'responds with status 404' do
+ it "responds with status 404" do
destroy_all_merged
expect(response).to have_gitlab_http_status(404)
@@ -426,20 +426,20 @@ describe Projects::BranchesController do
sign_in(user)
end
- context 'when rendering a JSON format' do
- it 'filters branches by name' do
+ context "when rendering a JSON format" do
+ it "filters branches by name" do
get :index,
- format: :json,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- search: 'master'
- }
+ format: :json,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ search: "master",
+ }
parsed_response = JSON.parse(response.body)
expect(parsed_response.length).to eq 1
- expect(parsed_response.first).to eq 'master'
+ expect(parsed_response.first).to eq "master"
end
end
@@ -447,73 +447,73 @@ describe Projects::BranchesController do
# `RequestStore.active?` in GitalyClient.enforce_gitaly_request_limits
# And the main goal of this test is making sure TooManyInvocationsError
# was not raised whenever the cache is enabled yet cold.
- context 'when cache is enabled yet cold', :request_store do
- it 'return with a status 200' do
+ context "when cache is enabled yet cold", :request_store do
+ it "return with a status 200" do
get :index,
- format: :html,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- state: 'all'
- }
+ format: :html,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ state: "all",
+ }
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when branch contains an invalid UTF-8 sequence' do
+ context "when branch contains an invalid UTF-8 sequence" do
before do
project.repository.create_branch("wrong-\xE5-utf8-sequence")
end
- it 'return with a status 200' do
+ it "return with a status 200" do
get :index,
- format: :html,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- state: 'all'
- }
+ format: :html,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ state: "all",
+ }
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when deprecated sort/search/page parameters are specified' do
- it 'returns with a status 301 when sort specified' do
+ context "when deprecated sort/search/page parameters are specified" do
+ it "returns with a status 301 when sort specified" do
get :index,
- format: :html,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- sort: 'updated_asc'
- }
+ format: :html,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ sort: "updated_asc",
+ }
- expect(response).to redirect_to project_branches_filtered_path(project, state: 'all')
+ expect(response).to redirect_to project_branches_filtered_path(project, state: "all")
end
- it 'returns with a status 301 when search specified' do
+ it "returns with a status 301 when search specified" do
get :index,
- format: :html,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- search: 'feature'
- }
+ format: :html,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ search: "feature",
+ }
- expect(response).to redirect_to project_branches_filtered_path(project, state: 'all')
+ expect(response).to redirect_to project_branches_filtered_path(project, state: "all")
end
- it 'returns with a status 301 when page specified' do
+ it "returns with a status 301 when page specified" do
get :index,
- format: :html,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- page: 2
- }
-
- expect(response).to redirect_to project_branches_filtered_path(project, state: 'all')
+ format: :html,
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ page: 2,
+ }
+
+ expect(response).to redirect_to project_branches_filtered_path(project, state: "all")
end
end
end
diff --git a/spec/controllers/projects/ci/lints_controller_spec.rb b/spec/controllers/projects/ci/lints_controller_spec.rb
index cfa010c2d1c..f06d1fa44a3 100644
--- a/spec/controllers/projects/ci/lints_controller_spec.rb
+++ b/spec/controllers/projects/ci/lints_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Ci::LintsController do
let(:project) { create(:project, :repository) }
@@ -8,113 +8,112 @@ describe Projects::Ci::LintsController do
sign_in(user)
end
- describe 'GET #show' do
- context 'with enough privileges' do
+ describe "GET #show" do
+ context "with enough privileges" do
before do
project.add_developer(user)
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ get :show, params: {namespace_id: project.namespace, project_id: project}
end
- it 'should be success' do
+ it "should be success" do
expect(response).to be_success
end
- it 'should render show page' do
+ it "should render show page" do
expect(response).to render_template :show
end
- it 'should retrieve project' do
+ it "should retrieve project" do
expect(assigns(:project)).to eq(project)
end
end
- context 'without enough privileges' do
+ context "without enough privileges" do
before do
project.add_guest(user)
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ get :show, params: {namespace_id: project.namespace, project_id: project}
end
- it 'should respond with 404' do
+ it "should respond with 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'POST #create' do
- let(:remote_file_path) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ describe "POST #create" do
+ let(:remote_file_path) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
let(:remote_file_content) do
<<~HEREDOC
- before_script:
- - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
- - ruby -v
- - which ruby
- - bundle install --jobs $(nproc) "${FLAGS[@]}"
+ before_script:
+ - apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs
+ - ruby -v
+ - which ruby
+ - bundle install --jobs $(nproc) "${FLAGS[@]}"
HEREDOC
end
let(:content) do
<<~HEREDOC
- include:
- - #{remote_file_path}
-
- rubocop:
- script:
- - bundle exec rubocop
+ include:
+ - #{remote_file_path}
+ rubocop:
+ script:
+ - bundle exec rubocop
HEREDOC
end
- context 'with a valid gitlab-ci.yml' do
+ context "with a valid gitlab-ci.yml" do
before do
WebMock.stub_request(:get, remote_file_path).to_return(body: remote_file_content)
project.add_developer(user)
- post :create, params: { namespace_id: project.namespace, project_id: project, content: content }
+ post :create, params: {namespace_id: project.namespace, project_id: project, content: content}
end
- it 'should be success' do
+ it "should be success" do
expect(response).to be_success
end
- it 'render show page' do
+ it "render show page" do
expect(response).to render_template :show
end
- it 'should retrieve project' do
+ it "should retrieve project" do
expect(assigns(:project)).to eq(project)
end
end
- context 'with an invalid gitlab-ci.yml' do
+ context "with an invalid gitlab-ci.yml" do
let(:content) do
<<~HEREDOC
- rubocop:
- scriptt:
- - bundle exec rubocop
+ rubocop:
+ scriptt:
+ - bundle exec rubocop
HEREDOC
end
before do
project.add_developer(user)
- post :create, params: { namespace_id: project.namespace, project_id: project, content: content }
+ post :create, params: {namespace_id: project.namespace, project_id: project, content: content}
end
- it 'should assign errors' do
- expect(assigns[:error]).to eq('jobs:rubocop config contains unknown keys: scriptt')
+ it "should assign errors" do
+ expect(assigns[:error]).to eq("jobs:rubocop config contains unknown keys: scriptt")
end
end
- context 'without enough privileges' do
+ context "without enough privileges" do
before do
project.add_guest(user)
- post :create, params: { namespace_id: project.namespace, project_id: project, content: content }
+ post :create, params: {namespace_id: project.namespace, project_id: project, content: content}
end
- it 'should respond with 404' do
+ it "should respond with 404" do
expect(response).to have_gitlab_http_status(404)
end
end
diff --git a/spec/controllers/projects/clusters/applications_controller_spec.rb b/spec/controllers/projects/clusters/applications_controller_spec.rb
index cb558259225..7f974f46e7b 100644
--- a/spec/controllers/projects/clusters/applications_controller_spec.rb
+++ b/spec/controllers/projects/clusters/applications_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Clusters::ApplicationsController do
include AccessMatchersForController
@@ -9,13 +9,13 @@ describe Projects::Clusters::ApplicationsController do
Clusters::Cluster::APPLICATIONS[application]
end
- describe 'POST create' do
+ describe "POST create" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- let(:application) { 'helm' }
- let(:params) { { application: application, id: cluster.id } }
+ let(:application) { "helm" }
+ let(:params) { {application: application, id: cluster.id} }
- describe 'functionality' do
+ describe "functionality" do
let(:user) { create(:user) }
before do
@@ -23,7 +23,7 @@ describe Projects::Clusters::ApplicationsController do
sign_in(user)
end
- it 'schedule an application installation' do
+ it "schedule an application installation" do
expect(ClusterInstallAppWorker).to receive(:perform_async).with(application, anything).once
expect { go }.to change { current_application.count }
@@ -31,33 +31,33 @@ describe Projects::Clusters::ApplicationsController do
expect(cluster.application_helm).to be_scheduled
end
- context 'when cluster do not exists' do
+ context "when cluster do not exists" do
before do
cluster.destroy!
end
- it 'return 404' do
+ it "return 404" do
expect { go }.not_to change { current_application.count }
expect(response).to have_http_status(:not_found)
end
end
- context 'when application is unknown' do
- let(:application) { 'unkwnown-app' }
+ context "when application is unknown" do
+ let(:application) { "unkwnown-app" }
- it 'return 404' do
+ it "return 404" do
go
expect(response).to have_http_status(:not_found)
end
end
- context 'when application is already installing' do
+ context "when application is already installing" do
before do
create(:clusters_applications_helm, :installing, cluster: cluster)
end
- it 'returns 400' do
+ it "returns 400" do
go
expect(response).to have_http_status(:bad_request)
@@ -65,7 +65,7 @@ describe Projects::Clusters::ApplicationsController do
end
end
- describe 'security' do
+ describe "security" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
end
diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb
index d94c18ddc02..4850d83a418 100644
--- a/spec/controllers/projects/clusters_controller_spec.rb
+++ b/spec/controllers/projects/clusters_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ClustersController do
include AccessMatchersForController
@@ -16,17 +16,17 @@ describe Projects::ClustersController do
sign_in(user)
end
- describe 'GET index' do
+ describe "GET index" do
def go(params = {})
get :index, params: params.reverse_merge(namespace_id: project.namespace.to_param, project_id: project)
end
- describe 'functionality' do
- context 'when project has one or more clusters' do
+ describe "functionality" do
+ context "when project has one or more clusters" do
let(:project) { create(:project) }
let!(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let!(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
- it 'lists available clusters' do
+ it "lists available clusters" do
go
expect(response).to have_gitlab_http_status(:ok)
@@ -34,7 +34,7 @@ describe Projects::ClustersController do
expect(assigns(:clusters)).to match_array([enabled_cluster, disabled_cluster])
end
- context 'when page is specified' do
+ context "when page is specified" do
let(:last_page) { project.clusters.page.total_pages }
before do
@@ -42,7 +42,7 @@ describe Projects::ClustersController do
create_list(:cluster, 2, :provided_by_gcp, :production_environment, projects: [project])
end
- it 'redirects to the page' do
+ it "redirects to the page" do
go(page: last_page)
expect(response).to have_gitlab_http_status(:ok)
@@ -51,10 +51,10 @@ describe Projects::ClustersController do
end
end
- context 'when project does not have a cluster' do
+ context "when project does not have a cluster" do
let(:project) { create(:project) }
- it 'returns an empty state page' do
+ it "returns an empty state page" do
go
expect(response).to have_gitlab_http_status(:ok)
@@ -64,7 +64,7 @@ describe Projects::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -78,14 +78,14 @@ describe Projects::ClustersController do
end
end
- describe 'GET new' do
+ describe "GET new" do
def go
- get :new, params: { namespace_id: project.namespace, project_id: project }
+ get :new, params: {namespace_id: project.namespace, project_id: project}
end
- describe 'functionality for new cluster' do
- context 'when omniauth has been configured' do
- let(:key) { 'secret-key' }
+ describe "functionality for new cluster" do
+ context "when omniauth has been configured" do
+ let(:key) { "secret-key" }
let(:session_key_for_redirect_uri) do
GoogleApi::CloudPlatform::Client.session_key_for_redirect_uri(key)
end
@@ -94,7 +94,7 @@ describe Projects::ClustersController do
allow(SecureRandom).to receive(:hex).and_return(key)
end
- it 'has authorize_url' do
+ it "has authorize_url" do
go
expect(assigns(:authorize_url)).to include(key)
@@ -102,31 +102,31 @@ describe Projects::ClustersController do
end
end
- context 'when omniauth has not configured' do
+ context "when omniauth has not configured" do
before do
stub_omniauth_setting(providers: [])
end
- it 'does not have authorize_url' do
+ it "does not have authorize_url" do
go
expect(assigns(:authorize_url)).to be_nil
end
end
- context 'when access token is valid' do
+ context "when access token is valid" do
before do
stub_google_api_validate_token
end
- it 'has new object' do
+ it "has new object" do
go
expect(assigns(:gcp_cluster)).to be_an_instance_of(Clusters::ClusterPresenter)
end
end
- context 'when access token is expired' do
+ context "when access token is expired" do
before do
stub_google_api_expired_token
end
@@ -134,20 +134,20 @@ describe Projects::ClustersController do
it { expect(@valid_gcp_token).to be_falsey }
end
- context 'when access token is not stored in session' do
+ context "when access token is not stored in session" do
it { expect(@valid_gcp_token).to be_falsey }
end
end
- describe 'functionality for existing cluster' do
- it 'has new object' do
+ describe "functionality for existing cluster" do
+ it "has new object" do
go
expect(assigns(:user_cluster)).to be_an_instance_of(Clusters::ClusterPresenter)
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
@@ -159,17 +159,17 @@ describe Projects::ClustersController do
end
end
- describe 'POST create for new cluster' do
- let(:legacy_abac_param) { 'true' }
+ describe "POST create for new cluster" do
+ let(:legacy_abac_param) { "true" }
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
provider_gcp_attributes: {
- gcp_project_id: 'gcp-project-12345',
- legacy_abac: legacy_abac_param
- }
- }
+ gcp_project_id: "gcp-project-12345",
+ legacy_abac: legacy_abac_param,
+ },
+ },
}
end
@@ -177,13 +177,13 @@ describe Projects::ClustersController do
post :create_gcp, params: params.merge(namespace_id: project.namespace, project_id: project)
end
- describe 'functionality' do
- context 'when access token is valid' do
+ describe "functionality" do
+ context "when access token is valid" do
before do
stub_google_api_validate_token
end
- it 'creates a new cluster' do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
.and change { Clusters::Providers::Gcp.count }
@@ -193,10 +193,10 @@ describe Projects::ClustersController do
expect(project.clusters.first.provider_gcp).to be_legacy_abac
end
- context 'when legacy_abac param is false' do
- let(:legacy_abac_param) { 'false' }
+ context "when legacy_abac param is false" do
+ let(:legacy_abac_param) { "false" }
- it 'creates a new cluster with legacy_abac_disabled' do
+ it "creates a new cluster with legacy_abac_disabled" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
.and change { Clusters::Providers::Gcp.count }
@@ -205,7 +205,7 @@ describe Projects::ClustersController do
end
end
- context 'when access token is expired' do
+ context "when access token is expired" do
before do
stub_google_api_expired_token
end
@@ -213,22 +213,22 @@ describe Projects::ClustersController do
it { expect(@valid_gcp_token).to be_falsey }
end
- context 'when access token is not stored in session' do
+ context "when access token is not stored in session" do
it { expect(@valid_gcp_token).to be_falsey }
end
end
- describe 'security' do
+ describe "security" do
before do
allow_any_instance_of(described_class)
- .to receive(:token_in_session).and_return('token')
+ .to receive(:token_in_session).and_return("token")
allow_any_instance_of(described_class)
.to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
allow_any_instance_of(GoogleApi::CloudPlatform::Client)
.to receive(:projects_zones_clusters_create) do
OpenStruct.new(
- self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123',
- status: 'RUNNING'
+ self_link: "projects/gcp-project-12345/zones/us-central1-a/operations/ope-123",
+ status: "RUNNING"
)
end
@@ -246,17 +246,17 @@ describe Projects::ClustersController do
end
end
- describe 'POST create for existing cluster' do
+ describe "POST create for existing cluster" do
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
platform_kubernetes_attributes: {
- api_url: 'http://my-url',
- token: 'test',
- namespace: 'aaa'
- }
- }
+ api_url: "http://my-url",
+ token: "test",
+ namespace: "aaa",
+ },
+ },
}
end
@@ -264,9 +264,9 @@ describe Projects::ClustersController do
post :create_user, params: params.merge(namespace_id: project.namespace, project_id: project)
end
- describe 'functionality' do
- context 'when creates a cluster' do
- it 'creates a new cluster' do
+ describe "functionality" do
+ context "when creates a cluster" do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
@@ -279,22 +279,22 @@ describe Projects::ClustersController do
end
end
- context 'when creates a RBAC-enabled cluster' do
+ context "when creates a RBAC-enabled cluster" do
let(:params) do
{
cluster: {
- name: 'new-cluster',
+ name: "new-cluster",
platform_kubernetes_attributes: {
- api_url: 'http://my-url',
- token: 'test',
- namespace: 'aaa',
- authorization_type: 'rbac'
- }
- }
+ api_url: "http://my-url",
+ token: "test",
+ namespace: "aaa",
+ authorization_type: "rbac",
+ },
+ },
}
end
- it 'creates a new cluster' do
+ it "creates a new cluster" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { go }.to change { Clusters::Cluster.count }
@@ -309,10 +309,10 @@ describe Projects::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
before do
allow(ClusterConfigureWorker).to receive(:perform_async)
- stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
+ stub_kubeclient_get_namespace("https://kubernetes.example.com", namespace: "my-namespace")
end
it { expect { go }.to be_allowed_for(:admin) }
@@ -326,7 +326,7 @@ describe Projects::ClustersController do
end
end
- describe 'GET cluster_status' do
+ describe "GET cluster_status" do
let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project]) }
def go
@@ -334,27 +334,27 @@ describe Projects::ClustersController do
params: {
namespace_id: project.namespace.to_param,
project_id: project.to_param,
- id: cluster
+ id: cluster,
},
format: :json
end
- describe 'functionality' do
+ describe "functionality" do
it "responds with matching schema" do
go
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('cluster_status')
+ expect(response).to match_response_schema("cluster_status")
end
- it 'invokes schedule_status_update on each application' do
+ it "invokes schedule_status_update on each application" do
expect_any_instance_of(Clusters::Applications::Ingress).to receive(:schedule_status_update)
go
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
@@ -366,7 +366,7 @@ describe Projects::ClustersController do
end
end
- describe 'GET show' do
+ describe "GET show" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
def go
@@ -374,11 +374,11 @@ describe Projects::ClustersController do
params: {
namespace_id: project.namespace,
project_id: project,
- id: cluster
+ id: cluster,
}
end
- describe 'functionality' do
+ describe "functionality" do
it "renders view" do
go
@@ -387,7 +387,7 @@ describe Projects::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
@@ -399,18 +399,17 @@ describe Projects::ClustersController do
end
end
- describe 'PUT update' do
+ describe "PUT update" do
def go(format: :html)
put :update, params: params.merge(namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: cluster,
- format: format
- )
+ format: format)
end
before do
allow(ClusterConfigureWorker).to receive(:perform_async)
- stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
+ stub_kubeclient_get_namespace("https://kubernetes.example.com", namespace: "my-namespace")
end
let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
@@ -419,11 +418,11 @@ describe Projects::ClustersController do
{
cluster: {
enabled: false,
- name: 'my-new-cluster-name',
+ name: "my-new-cluster-name",
platform_kubernetes_attributes: {
- namespace: 'my-namespace'
- }
- }
+ namespace: "my-namespace",
+ },
+ },
}
end
@@ -432,24 +431,24 @@ describe Projects::ClustersController do
cluster.reload
expect(response).to redirect_to(project_cluster_path(project, cluster))
- expect(flash[:notice]).to eq('Kubernetes cluster was successfully updated.')
+ expect(flash[:notice]).to eq("Kubernetes cluster was successfully updated.")
expect(cluster.enabled).to be_falsey
- expect(cluster.name).to eq('my-new-cluster-name')
- expect(cluster.platform_kubernetes.namespace).to eq('my-namespace')
+ expect(cluster.name).to eq("my-new-cluster-name")
+ expect(cluster.platform_kubernetes.namespace).to eq("my-namespace")
end
- context 'when format is json' do
- context 'when changing parameters' do
- context 'when valid parameters are used' do
+ context "when format is json" do
+ context "when changing parameters" do
+ context "when valid parameters are used" do
let(:params) do
{
cluster: {
enabled: false,
- name: 'my-new-cluster-name',
+ name: "my-new-cluster-name",
platform_kubernetes_attributes: {
- namespace: 'my-namespace'
- }
- }
+ namespace: "my-namespace",
+ },
+ },
}
end
@@ -459,20 +458,20 @@ describe Projects::ClustersController do
cluster.reload
expect(response).to have_http_status(:no_content)
expect(cluster.enabled).to be_falsey
- expect(cluster.name).to eq('my-new-cluster-name')
- expect(cluster.platform_kubernetes.namespace).to eq('my-namespace')
+ expect(cluster.name).to eq("my-new-cluster-name")
+ expect(cluster.platform_kubernetes.namespace).to eq("my-namespace")
end
end
- context 'when invalid parameters are used' do
+ context "when invalid parameters are used" do
let(:params) do
{
cluster: {
enabled: false,
platform_kubernetes_attributes: {
- namespace: 'my invalid namespace #@'
- }
- }
+ namespace: 'my invalid namespace #@',
+ },
+ },
}
end
@@ -485,7 +484,7 @@ describe Projects::ClustersController do
end
end
- describe 'security' do
+ describe "security" do
set(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -499,7 +498,7 @@ describe Projects::ClustersController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) }
def go
@@ -507,13 +506,13 @@ describe Projects::ClustersController do
params: {
namespace_id: project.namespace,
project_id: project,
- id: cluster
+ id: cluster,
}
end
- describe 'functionality' do
- context 'when cluster is provided by GCP' do
- context 'when cluster is created' do
+ describe "functionality" do
+ context "when cluster is provided by GCP" do
+ context "when cluster is created" do
it "destroys and redirects back to clusters list" do
expect { go }
.to change { Clusters::Cluster.count }.by(-1)
@@ -521,11 +520,11 @@ describe Projects::ClustersController do
.and change { Clusters::Providers::Gcp.count }.by(-1)
expect(response).to redirect_to(project_clusters_path(project))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
- context 'when cluster is being created' do
+ context "when cluster is being created" do
let!(:cluster) { create(:cluster, :providing_by_gcp, :production_environment, projects: [project]) }
it "destroys and redirects back to clusters list" do
@@ -534,12 +533,12 @@ describe Projects::ClustersController do
.and change { Clusters::Providers::Gcp.count }.by(-1)
expect(response).to redirect_to(project_clusters_path(project))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
end
- context 'when cluster is provided by user' do
+ context "when cluster is provided by user" do
let!(:cluster) { create(:cluster, :provided_by_user, :production_environment, projects: [project]) }
it "destroys and redirects back to clusters list" do
@@ -549,12 +548,12 @@ describe Projects::ClustersController do
.and change { Clusters::Providers::Gcp.count }.by(0)
expect(response).to redirect_to(project_clusters_path(project))
- expect(flash[:notice]).to eq('Kubernetes cluster integration was successfully removed.')
+ expect(flash[:notice]).to eq("Kubernetes cluster integration was successfully removed.")
end
end
end
- describe 'security' do
+ describe "security" do
set(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -568,8 +567,8 @@ describe Projects::ClustersController do
end
end
- context 'no project_id param' do
- it 'does not respond to any action without project_id param' do
+ context "no project_id param" do
+ it "does not respond to any action without project_id param" do
expect { get :index }.to raise_error(ActionController::UrlGenerationError)
end
end
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb
index 19cac47325c..44ce59fae6c 100644
--- a/spec/controllers/projects/commit_controller_spec.rb
+++ b/spec/controllers/projects/commit_controller_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CommitController do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let(:commit) { project.commit("master") }
- let(:master_pickable_sha) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' }
+ let(:master_pickable_sha) { "7d3b0f7cff5f37573aea97cebfd5692ea1689924" }
let(:master_pickable_commit) { project.commit(master_pickable_sha) }
before do
@@ -12,36 +12,36 @@ describe Projects::CommitController do
project.add_maintainer(user)
end
- describe 'GET show' do
+ describe "GET show" do
render_views
def go(extra_params = {})
params = {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
get :show, params: params.merge(extra_params)
end
- context 'with valid id' do
- it 'responds with 200' do
+ context "with valid id" do
+ it "responds with 200" do
go(id: commit.id)
expect(response).to be_ok
end
end
- context 'with invalid id' do
- it 'responds with 404' do
+ context "with invalid id" do
+ it "responds with 404" do
go(id: commit.id.reverse)
expect(response).to be_not_found
end
end
- it 'handles binary files' do
- go(id: TestEnv::BRANCH_SHA['binary-encoding'], format: 'html')
+ it "handles binary files" do
+ go(id: TestEnv::BRANCH_SHA["binary-encoding"], format: "html")
expect(response).to be_success
end
@@ -71,10 +71,10 @@ describe Projects::CommitController do
go(id: commit.id, format: format)
- expect(response.body).not_to include('&amp;')
- expect(response.body).not_to include('&gt;')
- expect(response.body).not_to include('&lt;')
- expect(response.body).not_to include('&quot;')
+ expect(response.body).not_to include("&amp;")
+ expect(response.body).not_to include("&gt;")
+ expect(response.body).not_to include("&lt;")
+ expect(response.body).not_to include("&quot;")
end
end
@@ -94,69 +94,69 @@ describe Projects::CommitController do
end
end
- context 'commit that removes a submodule' do
+ context "commit that removes a submodule" do
render_views
let(:fork_project) { create(:forked_project_with_submodules, visibility_level: 20) }
- let(:commit) { fork_project.commit('remove-submodule') }
+ let(:commit) { fork_project.commit("remove-submodule") }
- it 'renders it' do
+ it "renders it" do
get(:show,
- params: {
- namespace_id: fork_project.namespace,
- project_id: fork_project,
- id: commit.id
- })
+ params: {
+ namespace_id: fork_project.namespace,
+ project_id: fork_project,
+ id: commit.id,
+ })
expect(response).to be_success
end
end
- context 'in the context of a merge_request' do
+ context "in the context of a merge_request" do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:commit) { merge_request.commits.first }
- it 'prepare diff notes in the context of the merge request' do
+ it "prepare diff notes in the context of the merge request" do
go(id: commit.id, merge_request_iid: merge_request.iid)
expect(assigns(:new_diff_note_attrs)).to eq({
- noteable_type: 'MergeRequest',
- noteable_id: merge_request.id,
- commit_id: commit.id
- })
+ noteable_type: "MergeRequest",
+ noteable_id: merge_request.id,
+ commit_id: commit.id,
+ })
expect(response).to be_ok
end
end
end
- describe 'GET branches' do
- it 'contains branch and tags information' do
- commit = project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
+ describe "GET branches" do
+ it "contains branch and tags information" do
+ commit = project.commit("5937ac0a7beb003549fc5fd26fc247adbce4a52e")
get(:branches,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: commit.id,
+ })
- expect(assigns(:branches)).to include('master', 'feature_conflict')
+ expect(assigns(:branches)).to include("master", "feature_conflict")
expect(assigns(:branches_limit_exceeded)).to be_falsey
- expect(assigns(:tags)).to include('v1.1.0')
+ expect(assigns(:tags)).to include("v1.1.0")
expect(assigns(:tags_limit_exceeded)).to be_falsey
end
- it 'returns :limit_exceeded when number of branches/tags reach a threshhold' do
- commit = project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
+ it "returns :limit_exceeded when number of branches/tags reach a threshhold" do
+ commit = project.commit("5937ac0a7beb003549fc5fd26fc247adbce4a52e")
allow_any_instance_of(Repository).to receive(:branch_count).and_return(1001)
allow_any_instance_of(Repository).to receive(:tag_count).and_return(1001)
get(:branches,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: commit.id,
+ })
expect(assigns(:branches)).to eq([])
expect(assigns(:branches_limit_exceeded)).to be_truthy
@@ -165,145 +165,145 @@ describe Projects::CommitController do
end
end
- describe 'POST revert' do
- context 'when target branch is not provided' do
- it 'renders the 404 page' do
+ describe "POST revert" do
+ context "when target branch is not provided" do
+ it "renders the 404 page" do
post(:revert,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: commit.id,
+ })
expect(response).not_to be_success
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the revert was successful' do
- it 'redirects to the commits page' do
+ context "when the revert was successful" do
+ it "redirects to the commits page" do
post(:revert,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: commit.id
- })
-
- expect(response).to redirect_to project_commits_path(project, 'master')
- expect(flash[:notice]).to eq('The commit has been successfully reverted.')
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: commit.id,
+ })
+
+ expect(response).to redirect_to project_commits_path(project, "master")
+ expect(flash[:notice]).to eq("The commit has been successfully reverted.")
end
end
- context 'when the revert failed' do
+ context "when the revert failed" do
before do
post(:revert,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: commit.id,
+ })
end
- it 'redirects to the commit page' do
+ it "redirects to the commit page" do
# Reverting a commit that has been already reverted.
post(:revert,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: commit.id,
+ })
expect(response).to redirect_to project_commit_path(project, commit.id)
- expect(flash[:alert]).to match('Sorry, we cannot revert this commit automatically.')
+ expect(flash[:alert]).to match("Sorry, we cannot revert this commit automatically.")
end
end
end
- describe 'POST cherry_pick' do
- context 'when target branch is not provided' do
- it 'renders the 404 page' do
+ describe "POST cherry_pick" do
+ context "when target branch is not provided" do
+ it "renders the 404 page" do
post(:cherry_pick,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: master_pickable_commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: master_pickable_commit.id,
+ })
expect(response).not_to be_success
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the cherry-pick was successful' do
- it 'redirects to the commits page' do
+ context "when the cherry-pick was successful" do
+ it "redirects to the commits page" do
post(:cherry_pick,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: master_pickable_commit.id
- })
-
- expect(response).to redirect_to project_commits_path(project, 'master')
- expect(flash[:notice]).to eq('The commit has been successfully cherry-picked into master.')
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: master_pickable_commit.id,
+ })
+
+ expect(response).to redirect_to project_commits_path(project, "master")
+ expect(flash[:notice]).to eq("The commit has been successfully cherry-picked into master.")
end
end
- context 'when the cherry_pick failed' do
+ context "when the cherry_pick failed" do
before do
post(:cherry_pick,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: master_pickable_commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: master_pickable_commit.id,
+ })
end
- it 'redirects 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,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- start_branch: 'master',
- id: master_pickable_commit.id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ start_branch: "master",
+ id: master_pickable_commit.id,
+ })
expect(response).to redirect_to project_commit_path(project, master_pickable_commit.id)
- expect(flash[:alert]).to match('Sorry, we cannot cherry-pick this commit automatically.')
+ expect(flash[:alert]).to match("Sorry, we cannot cherry-pick this commit automatically.")
end
end
end
- describe 'GET diff_for_path' do
+ describe "GET diff_for_path" do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
get :diff_for_path, params: params.merge(extra_params)
end
- let(:existing_path) { '.gitmodules' }
- let(:commit2) { project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let(:existing_path) { ".gitmodules" }
+ let(:commit2) { project.commit("5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
- context 'when the commit exists' do
- context 'when the user has access to the project' do
- context 'when the path exists in the diff' do
- it 'enables diff notes' do
+ context "when the commit exists" do
+ context "when the user has access to the project" do
+ context "when the path exists in the diff" do
+ it "enables diff notes" do
diff_for_path(id: commit2.id, old_path: existing_path, new_path: existing_path)
expect(assigns(:diff_notes_disabled)).to be_falsey
- expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: 'Commit',
+ expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: "Commit",
commit_id: commit2.id)
end
- it 'only renders the diffs for the path given' do
+ it "only renders the diffs for the path given" do
expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs|
expect(diffs.diff_files.map(&:new_path)).to contain_exactly(existing_path)
meth.call(diffs)
@@ -313,83 +313,83 @@ describe Projects::CommitController do
end
end
- context 'when the path does not exist in the diff' do
+ context "when the path does not exist in the diff" do
before do
diff_for_path(id: commit.id, old_path: existing_path.succ, new_path: existing_path.succ)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when the user does not have access to the project' do
+ context "when the user does not have access to the project" do
before do
project.team.truncate
diff_for_path(id: commit.id, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when the commit does not exist' do
+ context "when the commit does not exist" do
before do
diff_for_path(id: commit.id.reverse, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'GET pipelines' do
+ describe "GET pipelines" do
def get_pipelines(extra_params = {})
params = {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
get :pipelines, params: params.merge(extra_params)
end
- context 'when the commit exists' do
- context 'when the commit has pipelines' do
+ context "when the commit exists" do
+ context "when the commit has pipelines" do
before do
create(:ci_pipeline, project: project, sha: commit.id)
end
- context 'when rendering a HTML format' do
- it 'shows pipelines' do
+ context "when rendering a HTML format" do
+ it "shows pipelines" do
get_pipelines(id: commit.id)
expect(response).to be_ok
end
end
- context 'when rendering a JSON format' do
- it 'responds with serialized pipelines' do
+ context "when rendering a JSON format" do
+ it "responds with serialized pipelines" do
get_pipelines(id: commit.id, format: :json)
expect(response).to be_ok
- expect(JSON.parse(response.body)['pipelines']).not_to be_empty
- expect(JSON.parse(response.body)['count']['all']).to eq 1
+ expect(JSON.parse(response.body)["pipelines"]).not_to be_empty
+ expect(JSON.parse(response.body)["count"]["all"]).to eq 1
expect(response).to include_pagination_headers
end
end
end
end
- context 'when the commit does not exist' do
+ context "when the commit does not exist" do
before do
- get_pipelines(id: 'e7a412c8da9f6d0081a633a4a402dde1c4694ebd')
+ get_pipelines(id: "e7a412c8da9f6d0081a633a4a402dde1c4694ebd")
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
diff --git a/spec/controllers/projects/commits_controller_spec.rb b/spec/controllers/projects/commits_controller_spec.rb
index 8cb9130b834..669eedf0e12 100644
--- a/spec/controllers/projects/commits_controller_spec.rb
+++ b/spec/controllers/projects/commits_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CommitsController do
let(:project) { create(:project, :repository) }
@@ -8,19 +8,19 @@ describe Projects::CommitsController do
project.add_maintainer(user)
end
- context 'signed in' do
+ context "signed in" do
before do
sign_in(user)
end
describe "GET commits_root" do
context "no ref is provided" do
- it 'should redirect to the default branch of the project' do
+ it "should redirect to the default branch of the project" do
get(:commits_root,
- params: {
- namespace_id: project.namespace,
- project_id: project
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ })
expect(response).to redirect_to project_commits_path(project)
end
@@ -30,36 +30,36 @@ describe Projects::CommitsController do
describe "GET show" do
render_views
- context 'with file path' do
+ context "with file path" do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ })
end
context "valid branch, valid file" do
- let(:id) { 'master/README.md' }
+ let(:id) { "master/README.md" }
it { is_expected.to respond_with(:success) }
end
context "valid branch, invalid file" do
- let(:id) { 'master/invalid-path.rb' }
+ let(:id) { "master/invalid-path.rb" }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid file" do
- let(:id) { 'invalid-branch/README.md' }
+ let(:id) { "invalid-branch/README.md" }
it { is_expected.to respond_with(:not_found) }
end
context "branch with invalid format, valid file" do
- let(:id) { 'branch with space/README.md' }
+ let(:id) { "branch with space/README.md" }
it { is_expected.to respond_with(:not_found) }
end
@@ -69,41 +69,41 @@ describe Projects::CommitsController do
context "when the ref does not exist with the suffix" do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: "master.atom"
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: "master.atom",
+ })
end
it "renders as atom" do
expect(response).to be_success
- expect(response.content_type).to eq('application/atom+xml')
+ expect(response.content_type).to eq("application/atom+xml")
end
- it 'renders summary with type=html' do
+ it "renders summary with type=html" do
expect(response.body).to include('<summary type="html">')
end
end
context "when the ref exists with the suffix" do
before do
- commit = project.repository.commit('master')
+ commit = project.repository.commit("master")
allow_any_instance_of(Repository).to receive(:commit).and_call_original
- allow_any_instance_of(Repository).to receive(:commit).with('master.atom').and_return(commit)
+ allow_any_instance_of(Repository).to receive(:commit).with("master.atom").and_return(commit)
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: "master.atom"
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: "master.atom",
+ })
end
it "renders as HTML" do
expect(response).to be_success
- expect(response.content_type).to eq('text/html')
+ expect(response.content_type).to eq("text/html")
end
end
end
@@ -114,31 +114,31 @@ describe Projects::CommitsController do
before do
get(:signatures,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- },
- format: :json)
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ },
+ format: :json)
end
context "valid branch" do
- let(:id) { 'master' }
+ let(:id) { "master" }
it { is_expected.to respond_with(:success) }
end
context "invalid branch format" do
- let(:id) { 'some branch' }
+ let(:id) { "some branch" }
it { is_expected.to respond_with(:not_found) }
end
end
end
- context 'token authentication' do
- context 'public project' do
- it_behaves_like 'authenticates sessionless user', :show, :atom, public: true do
+ context "token authentication" do
+ context "public project" do
+ it_behaves_like "authenticates sessionless user", :show, :atom, public: true do
before do
public_project = create(:project, :repository, :public)
@@ -147,8 +147,8 @@ describe Projects::CommitsController do
end
end
- context 'private project' do
- it_behaves_like 'authenticates sessionless user', :show, :atom, public: false do
+ context "private project" do
+ it_behaves_like "authenticates sessionless user", :show, :atom, public: false do
before do
private_project = create(:project, :repository, :private)
private_project.add_maintainer(user)
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
index cfd70e93efb..9f89b29480c 100644
--- a/spec/controllers/projects/compare_controller_spec.rb
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CompareController do
let(:project) { create(:project, :repository) }
@@ -9,19 +9,19 @@ describe Projects::CompareController do
project.add_maintainer(user)
end
- describe 'GET index' do
+ describe "GET index" do
render_views
before do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
end
- it 'returns successfully' do
+ it "returns successfully" do
expect(response).to be_success
end
end
- describe 'GET show' do
+ describe "GET show" do
render_views
subject(:show_request) { get :show, params: request_params }
@@ -32,19 +32,19 @@ describe Projects::CompareController do
project_id: project,
from: source_ref,
to: target_ref,
- w: whitespace
+ w: whitespace,
}
end
let(:whitespace) { nil }
- context 'when the refs exist' do
- context 'when we set the white space param' do
+ context "when the refs exist" do
+ context "when we set the white space param" do
let(:source_ref) { "08f22f25" }
let(:target_ref) { "66eceea0" }
let(:whitespace) { 1 }
- it 'shows some diffs with ignore whitespace change option' do
+ it "shows some diffs with ignore whitespace change option" do
show_request
expect(response).to be_success
@@ -57,12 +57,12 @@ describe Projects::CompareController do
end
end
- context 'when we do not set the white space param' do
+ context "when we do not set the white space param" do
let(:source_ref) { "improve%2Fawesome" }
let(:target_ref) { "feature" }
let(:whitespace) { nil }
- it 'sets the diffs and commits ivars' do
+ it "sets the diffs and commits ivars" do
show_request
expect(response).to be_success
@@ -72,11 +72,11 @@ describe Projects::CompareController do
end
end
- context 'when the source ref does not exist' do
- let(:source_ref) { 'non-existent-source-ref' }
+ context "when the source ref does not exist" do
+ let(:source_ref) { "non-existent-source-ref" }
let(:target_ref) { "feature" }
- it 'sets empty diff and commit ivars' do
+ it "sets empty diff and commit ivars" do
show_request
expect(response).to be_success
@@ -85,11 +85,11 @@ describe Projects::CompareController do
end
end
- context 'when the target ref does not exist' do
- let(:target_ref) { 'non-existent-target-ref' }
+ context "when the target ref does not exist" do
+ let(:target_ref) { "non-existent-target-ref" }
let(:source_ref) { "improve%2Fawesome" }
- it 'sets empty diff and commit ivars' do
+ it "sets empty diff and commit ivars" do
show_request
expect(response).to be_success
@@ -98,55 +98,55 @@ describe Projects::CompareController do
end
end
- context 'when the target ref is invalid' do
+ context "when the target ref is invalid" do
let(:target_ref) { "master%' AND 2554=4423 AND '%'='" }
let(:source_ref) { "improve%2Fawesome" }
- it 'shows a flash message and redirects' do
+ it "shows a flash message and redirects" do
show_request
- expect(flash[:alert]).to eq('Invalid branch name')
+ expect(flash[:alert]).to eq("Invalid branch name")
expect(response).to have_http_status(302)
end
end
- context 'when the source ref is invalid' do
+ context "when the source ref is invalid" do
let(:source_ref) { "master%' AND 2554=4423 AND '%'='" }
let(:target_ref) { "improve%2Fawesome" }
- it 'shows a flash message and redirects' do
+ it "shows a flash message and redirects" do
show_request
- expect(flash[:alert]).to eq('Invalid branch name')
+ expect(flash[:alert]).to eq("Invalid branch name")
expect(response).to have_http_status(302)
end
end
end
- describe 'GET diff_for_path' do
+ describe "GET diff_for_path" do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
get :diff_for_path, params: params.merge(extra_params)
end
- let(:existing_path) { 'files/ruby/feature.rb' }
+ let(:existing_path) { "files/ruby/feature.rb" }
let(:source_ref) { "improve%2Fawesome" }
let(:target_ref) { "feature" }
- context 'when the source and target refs exist' do
- context 'when the user has access target the project' do
- context 'when the path exists in the diff' do
- it 'disables diff notes' do
+ context "when the source and target refs exist" do
+ context "when the user has access target the project" do
+ context "when the path exists in the diff" do
+ it "disables diff notes" do
diff_for_path(from: source_ref, to: target_ref, old_path: existing_path, new_path: existing_path)
expect(assigns(:diff_notes_disabled)).to be_truthy
end
- it 'only renders the diffs for the path given' do
+ it "only renders the diffs for the path given" do
expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs|
expect(diffs.diff_files.map(&:new_path)).to contain_exactly(existing_path)
meth.call(diffs)
@@ -156,51 +156,51 @@ describe Projects::CompareController do
end
end
- context 'when the path does not exist in the diff' do
+ context "when the path does not exist in the diff" do
before do
diff_for_path(from: source_ref, to: target_ref, old_path: existing_path.succ, new_path: existing_path.succ)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when the user does not have access target the project' do
+ context "when the user does not have access target the project" do
before do
project.team.truncate
diff_for_path(from: source_ref, to: target_ref, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when the source ref does not exist' do
+ context "when the source ref does not exist" do
before do
diff_for_path(from: source_ref.succ, to: target_ref, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the target ref does not exist' do
+ context "when the target ref does not exist" do
before do
diff_for_path(from: source_ref, to: target_ref.succ, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'POST create' do
+ describe "POST create" do
subject(:create_request) { post :create, params: request_params }
let(:request_params) do
@@ -208,49 +208,49 @@ describe Projects::CompareController do
namespace_id: project.namespace,
project_id: project,
from: source_ref,
- to: target_ref
+ to: target_ref,
}
end
- context 'when sending valid params' do
+ context "when sending valid params" do
let(:source_ref) { "improve%2Fawesome" }
let(:target_ref) { "feature" }
- it 'redirects back to show' do
+ it "redirects back to show" do
create_request
expect(response).to redirect_to(project_compare_path(project, to: target_ref, from: source_ref))
end
end
- context 'when sending invalid params' do
- context 'when the source ref is empty and target ref is set' do
- let(:source_ref) { '' }
- let(:target_ref) { 'master' }
+ context "when sending invalid params" do
+ context "when the source ref is empty and target ref is set" do
+ let(:source_ref) { "" }
+ let(:target_ref) { "master" }
- it 'redirects back to index and preserves the target ref' do
+ it "redirects back to index and preserves the target ref" do
create_request
expect(response).to redirect_to(project_compare_index_path(project, to: target_ref))
end
end
- context 'when the target ref is empty and source ref is set' do
- let(:source_ref) { 'master' }
- let(:target_ref) { '' }
+ context "when the target ref is empty and source ref is set" do
+ let(:source_ref) { "master" }
+ let(:target_ref) { "" }
- it 'redirects back to index and preserves source ref' do
+ it "redirects back to index and preserves source ref" do
create_request
expect(response).to redirect_to(project_compare_index_path(project, from: source_ref))
end
end
- context 'when the target and source ref are empty' do
- let(:source_ref) { '' }
- let(:target_ref) { '' }
+ context "when the target and source ref are empty" do
+ let(:source_ref) { "" }
+ let(:target_ref) { "" }
- it 'redirects back to index' do
+ it "redirects back to index" do
create_request
expect(response).to redirect_to(namespace_project_compare_index_path)
@@ -259,7 +259,7 @@ describe Projects::CompareController do
end
end
- describe 'GET signatures' do
+ describe "GET signatures" do
subject(:signatures_request) { get :signatures, params: request_params }
let(:request_params) do
@@ -268,19 +268,19 @@ describe Projects::CompareController do
project_id: project,
from: source_ref,
to: target_ref,
- format: :json
+ format: :json,
}
end
- context 'when the source and target refs exist' do
+ context "when the source and target refs exist" do
let(:source_ref) { "improve%2Fawesome" }
let(:target_ref) { "feature" }
- context 'when the user has access to the project' do
+ context "when the user has access to the project" do
render_views
- let(:signature_commit) { build(:commit, project: project, safe_message: "message", sha: 'signature_commit') }
- let(:non_signature_commit) { build(:commit, project: project, safe_message: "message", sha: 'non_signature_commit') }
+ let(:signature_commit) { build(:commit, project: project, safe_message: "message", sha: "signature_commit") }
+ let(:non_signature_commit) { build(:commit, project: project, safe_message: "message", sha: "non_signature_commit") }
before do
escaped_source_ref = Addressable::URI.unescape(source_ref)
@@ -296,25 +296,25 @@ describe Projects::CompareController do
expect(non_signature_commit).to receive(:has_signature?).and_return(false)
end
- it 'returns only the commit with a signature' do
+ it "returns only the commit with a signature" do
signatures_request
expect(response).to have_gitlab_http_status(200)
parsed_body = JSON.parse(response.body)
- signatures = parsed_body['signatures']
+ signatures = parsed_body["signatures"]
expect(signatures.size).to eq(1)
- expect(signatures.first['commit_sha']).to eq(signature_commit.sha)
- expect(signatures.first['html']).to be_present
+ expect(signatures.first["commit_sha"]).to eq(signature_commit.sha)
+ expect(signatures.first["html"]).to be_present
end
end
- context 'when the user does not have access to the project' do
+ context "when the user does not have access to the project" do
before do
project.team.truncate
end
- it 'returns a 404' do
+ it "returns a 404" do
signatures_request
expect(response).to have_gitlab_http_status(404)
@@ -322,29 +322,29 @@ describe Projects::CompareController do
end
end
- context 'when the source ref does not exist' do
- let(:source_ref) { 'non-existent-ref-source' }
+ context "when the source ref does not exist" do
+ let(:source_ref) { "non-existent-ref-source" }
let(:target_ref) { "feature" }
- it 'returns no signatures' do
+ it "returns no signatures" do
signatures_request
expect(response).to have_gitlab_http_status(200)
parsed_body = JSON.parse(response.body)
- expect(parsed_body['signatures']).to be_empty
+ expect(parsed_body["signatures"]).to be_empty
end
end
- context 'when the target ref does not exist' do
- let(:target_ref) { 'non-existent-ref-target' }
+ context "when the target ref does not exist" do
+ let(:target_ref) { "non-existent-ref-target" }
let(:source_ref) { "improve%2Fawesome" }
- it 'returns no signatures' do
+ it "returns no signatures" do
signatures_request
expect(response).to have_gitlab_http_status(200)
parsed_body = JSON.parse(response.body)
- expect(parsed_body['signatures']).to be_empty
+ expect(parsed_body["signatures"]).to be_empty
end
end
end
diff --git a/spec/controllers/projects/cycle_analytics_controller_spec.rb b/spec/controllers/projects/cycle_analytics_controller_spec.rb
index 6a63cbdf8e2..7530eb1e666 100644
--- a/spec/controllers/projects/cycle_analytics_controller_spec.rb
+++ b/spec/controllers/projects/cycle_analytics_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CycleAnalyticsController do
let(:project) { create(:project, :repository) }
@@ -9,21 +9,21 @@ describe Projects::CycleAnalyticsController do
project.add_maintainer(user)
end
- describe 'cycle analytics not set up flag' do
- context 'with no data' do
- it 'is true' do
+ describe "cycle analytics not set up flag" do
+ context "with no data" do
+ it "is true" do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ })
expect(response).to be_success
expect(assigns(:cycle_analytics_no_data)).to eq(true)
end
end
- context 'with data' do
+ context "with data" do
before do
issue = create(:issue, project: project, created_at: 4.days.ago)
milestone = create(:milestone, project: project, created_at: 5.days.ago)
@@ -32,12 +32,12 @@ describe Projects::CycleAnalyticsController do
create_merge_request_closing_issue(user, project, issue)
end
- it 'is false' do
+ it "is false" do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ })
expect(response).to be_success
expect(assigns(:cycle_analytics_no_data)).to eq(false)
diff --git a/spec/controllers/projects/deploy_keys_controller_spec.rb b/spec/controllers/projects/deploy_keys_controller_spec.rb
index e54cf3e8181..1ca8c393172 100644
--- a/spec/controllers/projects/deploy_keys_controller_spec.rb
+++ b/spec/controllers/projects/deploy_keys_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DeployKeysController do
let(:project) { create(:project, :repository) }
@@ -10,20 +10,20 @@ describe Projects::DeployKeysController do
sign_in(user)
end
- describe 'GET index' do
+ describe "GET index" do
let(:params) do
- { namespace_id: project.namespace, project_id: project }
+ {namespace_id: project.namespace, project_id: project}
end
- context 'when html requested' do
- it 'redirects to project settings with the correct anchor' do
+ context "when html requested" do
+ it "redirects to project settings with the correct anchor" do
get :index, params: params
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-deploy-keys-settings"))
end
end
- context 'when json requested' do
+ context "when json requested" do
let(:project2) { create(:project, :internal)}
let(:project_private) { create(:project, :private)}
@@ -47,46 +47,46 @@ describe Projects::DeployKeysController do
project2.add_developer(user)
end
- it 'returns json in a correct format' do
+ it "returns json in a correct format" do
get :index, params: params.merge(format: :json)
json = JSON.parse(response.body)
- expect(json.keys).to match_array(%w(enabled_keys available_project_keys public_keys))
- expect(json['enabled_keys'].count).to eq(1)
- expect(json['available_project_keys'].count).to eq(1)
- expect(json['public_keys'].count).to eq(1)
+ expect(json.keys).to match_array(%w[enabled_keys available_project_keys public_keys])
+ expect(json["enabled_keys"].count).to eq(1)
+ expect(json["available_project_keys"].count).to eq(1)
+ expect(json["public_keys"].count).to eq(1)
end
end
end
- describe 'POST create' do
- def create_params(title = 'my-key')
+ describe "POST create" do
+ def create_params(title = "my-key")
{
namespace_id: project.namespace.path,
project_id: project.path,
deploy_key: {
title: title,
key: attributes_for(:deploy_key)[:key],
- deploy_keys_projects_attributes: { '0' => { can_push: '1' } }
- }
+ deploy_keys_projects_attributes: {"0" => {can_push: "1"}},
+ },
}
end
- it 'creates a new deploy key for the project' do
+ it "creates a new deploy key for the project" do
expect { post :create, params: create_params }.to change(project.deploy_keys, :count).by(1)
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-deploy-keys-settings"))
end
- it 'redirects to project settings with the correct anchor' do
+ it "redirects to project settings with the correct anchor" do
post :create, params: create_params
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-deploy-keys-settings"))
end
- context 'when the deploy key is invalid' do
- it 'shows an alert with the validations errors' do
+ context "when the deploy key is invalid" do
+ it "shows an alert with the validations errors" do
post :create, params: create_params(nil)
expect(flash[:alert]).to eq("Title can't be blank, Deploy keys projects deploy key title can't be blank")
@@ -94,92 +94,92 @@ describe Projects::DeployKeysController do
end
end
- describe '/enable/:id' do
+ describe "/enable/:id" do
let(:deploy_key) { create(:deploy_key) }
let(:project2) { create(:project) }
let!(:deploy_keys_project_internal) do
create(:deploy_keys_project, project: project2, deploy_key: deploy_key)
end
- context 'with anonymous user' do
+ context "with anonymous user" do
before do
sign_out(:user)
end
- it 'redirects to login' do
- expect do
- put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
- end.not_to change { DeployKeysProject.count }
+ it "redirects to login" do
+ expect {
+ put :enable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
+ }.not_to change { DeployKeysProject.count }
expect(response).to have_http_status(302)
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'with user with no permission' do
+ context "with user with no permission" do
before do
sign_in(create(:user))
end
- it 'returns 404' do
- expect do
- put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
- end.not_to change { DeployKeysProject.count }
+ it "returns 404" do
+ expect {
+ put :enable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
+ }.not_to change { DeployKeysProject.count }
expect(response).to have_http_status(404)
end
end
- context 'with user with permission' do
+ context "with user with permission" do
before do
project2.add_maintainer(user)
end
- it 'returns 302' do
- expect do
- put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
- end.to change { DeployKeysProject.count }.by(1)
+ it "returns 302" do
+ expect {
+ put :enable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
+ }.to change { DeployKeysProject.count }.by(1)
expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1)
expect(response).to have_http_status(302)
- expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: "js-deploy-keys-settings"))
end
- it 'returns 404' do
- put :enable, params: { id: 0, namespace_id: project.namespace, project_id: project }
+ it "returns 404" do
+ put :enable, params: {id: 0, namespace_id: project.namespace, project_id: project}
expect(response).to have_http_status(404)
end
end
- context 'with admin' do
+ context "with admin" do
before do
sign_in(create(:admin))
end
- it 'returns 302' do
- expect do
- put :enable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
- end.to change { DeployKeysProject.count }.by(1)
+ it "returns 302" do
+ expect {
+ put :enable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
+ }.to change { DeployKeysProject.count }.by(1)
expect(DeployKeysProject.where(project_id: project.id, deploy_key_id: deploy_key.id).count).to eq(1)
expect(response).to have_http_status(302)
- expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: "js-deploy-keys-settings"))
end
end
end
- describe '/disable/:id' do
+ describe "/disable/:id" do
let(:deploy_key) { create(:deploy_key) }
let!(:deploy_key_project) { create(:deploy_keys_project, project: project, deploy_key: deploy_key) }
- context 'with anonymous user' do
+ context "with anonymous user" do
before do
sign_out(:user)
end
- it 'redirects to login' do
- put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
+ it "redirects to login" do
+ put :disable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
expect(response).to have_http_status(302)
expect(response).to redirect_to(new_user_session_path)
@@ -187,48 +187,48 @@ describe Projects::DeployKeysController do
end
end
- context 'with user with no permission' do
+ context "with user with no permission" do
before do
sign_in(create(:user))
end
- it 'returns 404' do
- put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
+ it "returns 404" do
+ put :disable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
expect(response).to have_http_status(404)
expect(DeployKey.find(deploy_key.id)).to eq(deploy_key)
end
end
- context 'with user with permission' do
- it 'returns 302' do
- put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
+ context "with user with permission" do
+ it "returns 302" do
+ put :disable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
expect(response).to have_http_status(302)
- expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: "js-deploy-keys-settings"))
expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'returns 404' do
- put :disable, params: { id: 0, namespace_id: project.namespace, project_id: project }
+ it "returns 404" do
+ put :disable, params: {id: 0, namespace_id: project.namespace, project_id: project}
expect(response).to have_http_status(404)
end
end
- context 'with admin' do
+ context "with admin" do
before do
sign_in(create(:admin))
end
- it 'returns 302' do
- expect do
- put :disable, params: { id: deploy_key.id, namespace_id: project.namespace, project_id: project }
- end.to change { DeployKey.count }.by(-1)
+ it "returns 302" do
+ expect {
+ put :disable, params: {id: deploy_key.id, namespace_id: project.namespace, project_id: project}
+ }.to change { DeployKey.count }.by(-1)
expect(response).to have_http_status(302)
- expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: 'js-deploy-keys-settings'))
+ expect(response).to redirect_to(namespace_project_settings_repository_path(anchor: "js-deploy-keys-settings"))
expect { DeployKey.find(deploy_key.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
diff --git a/spec/controllers/projects/deployments_controller_spec.rb b/spec/controllers/projects/deployments_controller_spec.rb
index 5c33098fd31..2d92d2f8495 100644
--- a/spec/controllers/projects/deployments_controller_spec.rb
+++ b/spec/controllers/projects/deployments_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DeploymentsController do
include ApiHelpers
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:environment) { create(:environment, name: 'production', project: project) }
+ let(:environment) { create(:environment, name: "production", project: project) }
before do
project.add_maintainer(user)
@@ -13,8 +13,8 @@ describe Projects::DeploymentsController do
sign_in(user)
end
- describe 'GET #index' do
- it 'returns list of deployments from last 8 hours' do
+ describe "GET #index" do
+ it "returns list of deployments from last 8 hours" do
create(:deployment, :success, environment: environment, created_at: 9.hours.ago)
create(:deployment, :success, environment: environment, created_at: 7.hours.ago)
create(:deployment, :success, environment: environment)
@@ -23,61 +23,61 @@ describe Projects::DeploymentsController do
expect(response).to be_ok
- expect(json_response['deployments'].count).to eq(2)
+ expect(json_response["deployments"].count).to eq(2)
end
- it 'returns a list with deployments information' do
+ it "returns a list with deployments information" do
create(:deployment, :success, environment: environment)
get :index, params: deployment_params
expect(response).to be_ok
- expect(response).to match_response_schema('deployments')
+ expect(response).to match_response_schema("deployments")
end
end
- describe 'GET #metrics' do
+ describe "GET #metrics" do
let(:deployment) { create(:deployment, :success, project: project, environment: environment) }
before do
allow(controller).to receive(:deployment).and_return(deployment)
end
- context 'when metrics are disabled' do
+ context "when metrics are disabled" do
before do
allow(deployment).to receive(:has_metrics?).and_return false
end
- it 'responds with not found' do
+ it "responds with not found" do
get :metrics, params: deployment_params(id: deployment.id)
expect(response).to be_not_found
end
end
- context 'when metrics are enabled' do
+ context "when metrics are enabled" do
before do
allow(deployment).to receive(:has_metrics?).and_return true
end
- context 'when environment has no metrics' do
+ context "when environment has no metrics" do
before do
expect(deployment).to receive(:metrics).and_return(nil)
end
- it 'returns a empty response 204 resposne' do
+ it "returns a empty response 204 resposne" do
get :metrics, params: deployment_params(id: deployment.id)
expect(response).to have_gitlab_http_status(204)
- expect(response.body).to eq('')
+ expect(response.body).to eq("")
end
end
- context 'when environment has some metrics' do
+ context "when environment has some metrics" do
let(:empty_metrics) do
{
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
}
end
@@ -85,22 +85,22 @@ describe Projects::DeploymentsController do
expect(deployment).to receive(:metrics).and_return(empty_metrics)
end
- it 'returns a metrics JSON document' do
+ it "returns a metrics JSON document" do
get :metrics, params: deployment_params(id: deployment.id)
expect(response).to be_ok
- expect(json_response['success']).to be(true)
- expect(json_response['metrics']).to eq({})
- expect(json_response['last_update']).to eq(42)
+ expect(json_response["success"]).to be(true)
+ expect(json_response["metrics"]).to eq({})
+ expect(json_response["last_update"]).to eq(42)
end
end
- context 'when metrics service does not implement deployment metrics' do
+ context "when metrics service does not implement deployment metrics" do
before do
allow(deployment).to receive(:metrics).and_raise(NotImplementedError)
end
- it 'responds with not found' do
+ it "responds with not found" do
get :metrics, params: deployment_params(id: deployment.id)
expect(response).to be_not_found
@@ -109,50 +109,50 @@ describe Projects::DeploymentsController do
end
end
- describe 'GET #additional_metrics' do
+ describe "GET #additional_metrics" do
let(:deployment) { create(:deployment, :success, project: project, environment: environment) }
before do
allow(controller).to receive(:deployment).and_return(deployment)
end
- context 'when metrics are disabled' do
+ context "when metrics are disabled" do
before do
allow(deployment).to receive(:has_metrics?).and_return false
end
- it 'responds with not found' do
+ it "responds with not found" do
get :metrics, params: deployment_params(id: deployment.id)
expect(response).to be_not_found
end
end
- context 'when metrics are enabled' do
- let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
+ context "when metrics are enabled" do
+ let(:prometheus_adapter) { double("prometheus_adapter", can_query?: true) }
before do
allow(deployment).to receive(:prometheus_adapter).and_return(prometheus_adapter)
end
- context 'when environment has no metrics' do
+ context "when environment has no metrics" do
before do
expect(deployment).to receive(:additional_metrics).and_return({})
end
- it 'returns a empty response 204 response' do
+ it "returns a empty response 204 response" do
get :additional_metrics, params: deployment_params(id: deployment.id, format: :json)
expect(response).to have_gitlab_http_status(204)
- expect(response.body).to eq('')
+ expect(response.body).to eq("")
end
end
- context 'when environment has some metrics' do
+ context "when environment has some metrics" do
let(:empty_metrics) do
{
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
}
end
@@ -160,13 +160,13 @@ describe Projects::DeploymentsController do
expect(deployment).to receive(:additional_metrics).and_return(empty_metrics)
end
- it 'returns a metrics JSON document' do
+ it "returns a metrics JSON document" do
get :additional_metrics, params: deployment_params(id: deployment.id, format: :json)
expect(response).to be_ok
- expect(json_response['success']).to be(true)
- expect(json_response['metrics']).to eq({})
- expect(json_response['last_update']).to eq(42)
+ expect(json_response["success"]).to be(true)
+ expect(json_response["metrics"]).to eq({})
+ expect(json_response["last_update"]).to eq(42)
end
end
end
diff --git a/spec/controllers/projects/discussions_controller_spec.rb b/spec/controllers/projects/discussions_controller_spec.rb
index 0b9f336cf13..85876ce0178 100644
--- a/spec/controllers/projects/discussions_controller_spec.rb
+++ b/spec/controllers/projects/discussions_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DiscussionsController do
let(:user) { create(:user) }
@@ -12,58 +12,58 @@ describe Projects::DiscussionsController do
namespace_id: project.namespace,
project_id: project,
merge_request_id: merge_request,
- id: note.discussion_id
+ id: note.discussion_id,
}
end
- describe 'GET show' do
+ describe "GET show" do
before do
sign_in user
end
- context 'when user is not authorized to read the MR' do
- it 'returns 404' do
- get :show, params: request_params, session: { format: :json }
+ context "when user is not authorized to read the MR" do
+ it "returns 404" do
+ get :show, params: request_params, session: {format: :json}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user is authorized to read the MR' do
+ context "when user is authorized to read the MR" do
before do
project.add_reporter(user)
end
- it 'returns status 200' do
- get :show, params: request_params, session: { format: :json }
+ it "returns status 200" do
+ get :show, params: request_params, session: {format: :json}
expect(response).to have_gitlab_http_status(200)
end
- it 'returns status 404 if MR does not exists' do
+ it "returns status 404 if MR does not exists" do
merge_request.destroy!
- get :show, params: request_params, session: { format: :json }
+ get :show, params: request_params, session: {format: :json}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user is authorized but note is LegacyDiffNote' do
+ context "when user is authorized but note is LegacyDiffNote" do
before do
project.add_developer(user)
- note.update!(type: 'LegacyDiffNote')
+ note.update!(type: "LegacyDiffNote")
end
- it 'returns status 200' do
- get :show, params: request_params, session: { format: :json }
+ it "returns status 200" do
+ get :show, params: request_params, session: {format: :json}
expect(response).to have_gitlab_http_status(200)
end
end
end
- describe 'POST resolve' do
+ describe "POST resolve" do
before do
sign_in user
end
@@ -110,7 +110,7 @@ describe Projects::DiscussionsController do
it "returns the name of the resolving user" do
post :resolve, params: request_params
- expect(JSON.parse(response.body)['resolved_by']['name']).to eq(user.name)
+ expect(JSON.parse(response.body)["resolved_by"]["name"]).to eq(user.name)
end
it "returns status 200" do
@@ -121,26 +121,26 @@ describe Projects::DiscussionsController do
it "renders discussion with serializer" do
expect_any_instance_of(DiscussionSerializer).to receive(:represent)
- .with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
+ .with(instance_of(Discussion), {context: instance_of(described_class), render_truncated_diff_lines: true})
post :resolve, params: request_params
end
- context 'diff discussion' do
+ context "diff discussion" do
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
let(:discussion) { note.discussion }
it "returns truncated diff lines" do
post :resolve, params: request_params
- expect(JSON.parse(response.body)['truncated_diff_lines']).to be_present
+ expect(JSON.parse(response.body)["truncated_diff_lines"]).to be_present
end
end
end
end
end
- describe 'DELETE unresolve' do
+ describe "DELETE unresolve" do
before do
sign_in user
@@ -187,12 +187,12 @@ describe Projects::DiscussionsController do
context "when vue_mr_discussions cookie is present" do
before do
- allow(controller).to receive(:cookies).and_return({ vue_mr_discussions: 'true' })
+ allow(controller).to receive(:cookies).and_return({vue_mr_discussions: "true"})
end
it "renders discussion with serializer" do
expect_any_instance_of(DiscussionSerializer).to receive(:represent)
- .with(instance_of(Discussion), { context: instance_of(described_class), render_truncated_diff_lines: true })
+ .with(instance_of(Discussion), {context: instance_of(described_class), render_truncated_diff_lines: true})
delete :unresolve, params: request_params
end
diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb
index 36ce1119100..eae7637b8d9 100644
--- a/spec/controllers/projects/environments_controller_spec.rb
+++ b/spec/controllers/projects/environments_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::EnvironmentsController do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:environment) do
- create(:environment, name: 'production', project: project)
+ create(:environment, name: "production", project: project)
end
before do
@@ -14,15 +14,15 @@ describe Projects::EnvironmentsController do
sign_in(user)
end
- describe 'GET index' do
- context 'when a request for the HTML is made' do
- it 'responds with status code 200' do
+ describe "GET index" do
+ context "when a request for the HTML is made" do
+ it "responds with status code 200" do
get :index, params: environment_params
expect(response).to have_gitlab_http_status(:ok)
end
- it 'expires etag cache to force reload environments list' do
+ it "expires etag cache to force reload environments list" do
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:touch).with(project_environments_path(project, format: :json))
@@ -30,149 +30,149 @@ describe Projects::EnvironmentsController do
end
end
- context 'when requesting JSON response for folders' do
+ context "when requesting JSON response for folders" do
before do
create(:environment, project: project,
- name: 'staging/review-1',
+ name: "staging/review-1",
state: :available)
create(:environment, project: project,
- name: 'staging/review-2',
+ name: "staging/review-2",
state: :available)
create(:environment, project: project,
- name: 'staging/review-3',
+ name: "staging/review-3",
state: :stopped)
end
- let(:environments) { json_response['environments'] }
+ let(:environments) { json_response["environments"] }
- context 'with default parameters' do
+ context "with default parameters" do
before do
get :index, params: environment_params(format: :json)
end
- it 'responds with a flat payload describing available environments' do
+ it "responds with a flat payload describing available environments" do
expect(environments.count).to eq 3
- expect(environments.first).to include('name' => 'production', 'name_without_type' => 'production')
- expect(environments.second).to include('name' => 'staging/review-1', 'name_without_type' => 'review-1')
- expect(environments.third).to include('name' => 'staging/review-2', 'name_without_type' => 'review-2')
- expect(json_response['available_count']).to eq 3
- expect(json_response['stopped_count']).to eq 1
+ expect(environments.first).to include("name" => "production", "name_without_type" => "production")
+ expect(environments.second).to include("name" => "staging/review-1", "name_without_type" => "review-1")
+ expect(environments.third).to include("name" => "staging/review-2", "name_without_type" => "review-2")
+ expect(json_response["available_count"]).to eq 3
+ expect(json_response["stopped_count"]).to eq 1
end
- it 'sets the polling interval header' do
+ it "sets the polling interval header" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response.headers['Poll-Interval']).to eq("3000")
+ expect(response.headers["Poll-Interval"]).to eq("3000")
end
end
- context 'when a folder-based nested structure is requested' do
+ context "when a folder-based nested structure is requested" do
before do
get :index, params: environment_params(format: :json, nested: true)
end
- it 'responds with a payload containing the latest environment for each folder' do
+ it "responds with a payload containing the latest environment for each folder" do
expect(environments.count).to eq 2
- expect(environments.first['name']).to eq 'production'
- expect(environments.second['name']).to eq 'staging'
- expect(environments.second['size']).to eq 2
- expect(environments.second['latest']['name']).to eq 'staging/review-2'
+ expect(environments.first["name"]).to eq "production"
+ expect(environments.second["name"]).to eq "staging"
+ expect(environments.second["size"]).to eq 2
+ expect(environments.second["latest"]["name"]).to eq "staging/review-2"
end
end
- context 'when requesting available environments scope' do
+ context "when requesting available environments scope" do
before do
get :index, params: environment_params(format: :json, nested: true, scope: :available)
end
- it 'responds with a payload describing available environments' do
+ it "responds with a payload describing available environments" do
expect(environments.count).to eq 2
- expect(environments.first['name']).to eq 'production'
- expect(environments.second['name']).to eq 'staging'
- expect(environments.second['size']).to eq 2
- expect(environments.second['latest']['name']).to eq 'staging/review-2'
+ expect(environments.first["name"]).to eq "production"
+ expect(environments.second["name"]).to eq "staging"
+ expect(environments.second["size"]).to eq 2
+ expect(environments.second["latest"]["name"]).to eq "staging/review-2"
end
- it 'contains values describing environment scopes sizes' do
- expect(json_response['available_count']).to eq 3
- expect(json_response['stopped_count']).to eq 1
+ it "contains values describing environment scopes sizes" do
+ expect(json_response["available_count"]).to eq 3
+ expect(json_response["stopped_count"]).to eq 1
end
end
- context 'when requesting stopped environments scope' do
+ context "when requesting stopped environments scope" do
before do
get :index, params: environment_params(format: :json, nested: true, scope: :stopped)
end
- it 'responds with a payload describing stopped environments' do
+ it "responds with a payload describing stopped environments" do
expect(environments.count).to eq 1
- expect(environments.first['name']).to eq 'staging'
- expect(environments.first['size']).to eq 1
- expect(environments.first['latest']['name']).to eq 'staging/review-3'
+ expect(environments.first["name"]).to eq "staging"
+ expect(environments.first["size"]).to eq 1
+ expect(environments.first["latest"]["name"]).to eq "staging/review-3"
end
- it 'contains values describing environment scopes sizes' do
- expect(json_response['available_count']).to eq 3
- expect(json_response['stopped_count']).to eq 1
+ it "contains values describing environment scopes sizes" do
+ expect(json_response["available_count"]).to eq 3
+ expect(json_response["stopped_count"]).to eq 1
end
end
end
end
- describe 'GET folder' do
+ describe "GET folder" do
before do
create(:environment, project: project,
- name: 'staging-1.0/review',
+ name: "staging-1.0/review",
state: :available)
create(:environment, project: project,
- name: 'staging-1.0/zzz',
+ name: "staging-1.0/zzz",
state: :available)
end
- context 'when using default format' do
- it 'responds with HTML' do
+ context "when using default format" do
+ it "responds with HTML" do
get :folder, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: 'staging-1.0'
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: "staging-1.0",
+ }
expect(response).to be_ok
- expect(response).to render_template 'folder'
+ expect(response).to render_template "folder"
end
end
- context 'when using JSON format' do
- it 'sorts the subfolders lexicographically' do
+ context "when using JSON format" do
+ it "sorts the subfolders lexicographically" do
get :folder, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: 'staging-1.0'
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: "staging-1.0",
+ },
format: :json
expect(response).to be_ok
- expect(response).not_to render_template 'folder'
- expect(json_response['environments'][0])
- .to include('name' => 'staging-1.0/review', 'name_without_type' => 'review')
- expect(json_response['environments'][1])
- .to include('name' => 'staging-1.0/zzz', 'name_without_type' => 'zzz')
+ expect(response).not_to render_template "folder"
+ expect(json_response["environments"][0])
+ .to include("name" => "staging-1.0/review", "name_without_type" => "review")
+ expect(json_response["environments"][1])
+ .to include("name" => "staging-1.0/zzz", "name_without_type" => "zzz")
end
end
end
- describe 'GET show' do
- context 'with valid id' do
- it 'responds with a status code 200' do
+ describe "GET show" do
+ context "with valid id" do
+ it "responds with a status code 200" do
get :show, params: environment_params
expect(response).to be_ok
end
end
- context 'with invalid id' do
- it 'responds with a status code 404' do
+ context "with invalid id" do
+ it "responds with a status code 404" do
params = environment_params
params[:id] = 12345
get :show, params: params
@@ -182,26 +182,26 @@ describe Projects::EnvironmentsController do
end
end
- describe 'GET edit' do
- it 'responds with a status code 200' do
+ describe "GET edit" do
+ it "responds with a status code 200" do
get :edit, params: environment_params
expect(response).to be_ok
end
end
- describe 'PATCH #update' do
- it 'responds with a 302' do
- patch_params = environment_params.merge(environment: { external_url: 'https://git.gitlab.com' })
+ describe "PATCH #update" do
+ it "responds with a 302" do
+ patch_params = environment_params.merge(environment: {external_url: "https://git.gitlab.com"})
patch :update, params: patch_params
expect(response).to have_gitlab_http_status(302)
end
end
- describe 'PATCH #stop' do
- context 'when env not available' do
- it 'returns 404' do
+ describe "PATCH #stop" do
+ context "when env not available" do
+ it "returns 404" do
allow_any_instance_of(Environment).to receive(:available?) { false }
patch :stop, params: environment_params(format: :json)
@@ -210,8 +210,8 @@ describe Projects::EnvironmentsController do
end
end
- context 'when stop action' do
- it 'returns action url' do
+ context "when stop action" do
+ it "returns action url" do
action = create(:ci_build, :manual)
allow_any_instance_of(Environment)
@@ -221,13 +221,14 @@ describe Projects::EnvironmentsController do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq(
- { 'redirect_url' =>
- project_job_url(project, action) })
+ {"redirect_url" =>
+ project_job_url(project, action)}
+ )
end
end
- context 'when no stop action' do
- it 'returns env url' do
+ context "when no stop action" do
+ it "returns env url" do
allow_any_instance_of(Environment)
.to receive_messages(available?: true, stop_with_action!: nil)
@@ -235,21 +236,22 @@ describe Projects::EnvironmentsController do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq(
- { 'redirect_url' =>
- project_environment_url(project, environment) })
+ {"redirect_url" =>
+ project_environment_url(project, environment)}
+ )
end
end
end
- describe 'GET #terminal' do
- context 'with valid id' do
- it 'responds with a status code 200' do
+ describe "GET #terminal" do
+ context "with valid id" do
+ it "responds with a status code 200" do
get :terminal, params: environment_params
expect(response).to have_gitlab_http_status(200)
end
- it 'loads the terminals for the environment' do
+ it "loads the terminals for the environment" do
# In EE we have to stub EE::Environment since it overwrites the
# "terminals" method.
expect_any_instance_of(defined?(EE) ? EE::Environment : Environment)
@@ -259,8 +261,8 @@ describe Projects::EnvironmentsController do
end
end
- context 'with invalid id' do
- it 'responds with a status code 404' do
+ context "with invalid id" do
+ it "responds with a status code 404" do
get :terminal, params: environment_params(id: 666)
expect(response).to have_gitlab_http_status(404)
@@ -268,14 +270,14 @@ describe Projects::EnvironmentsController do
end
end
- describe 'GET #terminal_websocket_authorize' do
- context 'with valid workhorse signature' do
+ describe "GET #terminal_websocket_authorize" do
+ context "with valid workhorse signature" do
before do
allow(Gitlab::Workhorse).to receive(:verify_api_request!).and_return(nil)
end
- context 'and valid id' do
- it 'returns the first terminal for the environment' do
+ context "and valid id" do
+ it "returns the first terminal for the environment" do
# In EE we have to stub EE::Environment since it overwrites the
# "terminals" method.
expect_any_instance_of(defined?(EE) ? EE::Environment : Environment)
@@ -295,8 +297,8 @@ describe Projects::EnvironmentsController do
end
end
- context 'and invalid id' do
- it 'returns 404' do
+ context "and invalid id" do
+ it "returns 404" do
get :terminal_websocket_authorize, params: environment_params(id: 666)
expect(response).to have_gitlab_http_status(404)
@@ -304,8 +306,8 @@ describe Projects::EnvironmentsController do
end
end
- context 'with invalid workhorse signature' do
- it 'aborts with an exception' do
+ context "with invalid workhorse signature" do
+ it "aborts with an exception" do
allow(Gitlab::Workhorse).to receive(:verify_api_request!).and_raise(JWT::DecodeError)
expect { get :terminal_websocket_authorize, params: environment_params }.to raise_error(JWT::DecodeError)
@@ -315,43 +317,43 @@ describe Projects::EnvironmentsController do
end
end
- describe 'GET #metrics_redirect' do
+ describe "GET #metrics_redirect" do
let(:project) { create(:project) }
- it 'redirects to environment if it exists' do
- environment = create(:environment, name: 'production', project: project)
+ it "redirects to environment if it exists" do
+ environment = create(:environment, name: "production", project: project)
- get :metrics_redirect, params: { namespace_id: project.namespace, project_id: project }
+ get :metrics_redirect, params: {namespace_id: project.namespace, project_id: project}
expect(response).to redirect_to(environment_metrics_path(environment))
end
- it 'redirects to empty page if no environment exists' do
- get :metrics_redirect, params: { namespace_id: project.namespace, project_id: project }
+ it "redirects to empty page if no environment exists" do
+ get :metrics_redirect, params: {namespace_id: project.namespace, project_id: project}
expect(response).to be_ok
- expect(response).to render_template 'empty'
+ expect(response).to render_template "empty"
end
end
- describe 'GET #metrics' do
+ describe "GET #metrics" do
before do
allow(controller).to receive(:environment).and_return(environment)
end
- context 'when environment has no metrics' do
+ context "when environment has no metrics" do
before do
expect(environment).to receive(:metrics).and_return(nil)
end
- it 'returns a metrics page' do
+ it "returns a metrics page" do
get :metrics, params: environment_params
expect(response).to be_ok
end
- context 'when requesting metrics as JSON' do
- it 'returns a metrics JSON document' do
+ context "when requesting metrics as JSON" do
+ it "returns a metrics JSON document" do
get :metrics, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(204)
@@ -360,38 +362,38 @@ describe Projects::EnvironmentsController do
end
end
- context 'when environment has some metrics' do
+ context "when environment has some metrics" do
before do
expect(environment).to receive(:metrics).and_return({
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
})
end
- it 'returns a metrics JSON document' do
+ it "returns a metrics JSON document" do
get :metrics, params: environment_params(format: :json)
expect(response).to be_ok
- expect(json_response['success']).to be(true)
- expect(json_response['metrics']).to eq({})
- expect(json_response['last_update']).to eq(42)
+ expect(json_response["success"]).to be(true)
+ expect(json_response["metrics"]).to eq({})
+ expect(json_response["last_update"]).to eq(42)
end
end
end
- describe 'GET #additional_metrics' do
+ describe "GET #additional_metrics" do
before do
allow(controller).to receive(:environment).and_return(environment)
end
- context 'when environment has no metrics' do
+ context "when environment has no metrics" do
before do
expect(environment).to receive(:additional_metrics).and_return(nil)
end
- context 'when requesting metrics as JSON' do
- it 'returns a metrics JSON document' do
+ context "when requesting metrics as JSON" do
+ it "returns a metrics JSON document" do
get :additional_metrics, params: environment_params(format: :json)
expect(response).to have_gitlab_http_status(204)
@@ -400,94 +402,94 @@ describe Projects::EnvironmentsController do
end
end
- context 'when environment has some metrics' do
+ context "when environment has some metrics" do
before do
expect(environment)
.to receive(:additional_metrics)
- .and_return({
- success: true,
- data: {},
- last_update: 42
- })
+ .and_return({
+ success: true,
+ data: {},
+ last_update: 42,
+ })
end
- it 'returns a metrics JSON document' do
+ it "returns a metrics JSON document" do
get :additional_metrics, params: environment_params(format: :json)
expect(response).to be_ok
- expect(json_response['success']).to be(true)
- expect(json_response['data']).to eq({})
- expect(json_response['last_update']).to eq(42)
+ expect(json_response["success"]).to be(true)
+ expect(json_response["data"]).to eq({})
+ expect(json_response["last_update"]).to eq(42)
end
end
end
- describe 'GET #search' do
+ describe "GET #search" do
before do
- create(:environment, name: 'staging', project: project)
- create(:environment, name: 'review/patch-1', project: project)
- create(:environment, name: 'review/patch-2', project: project)
+ create(:environment, name: "staging", project: project)
+ create(:environment, name: "review/patch-1", project: project)
+ create(:environment, name: "review/patch-2", project: project)
end
- let(:query) { 'pro' }
+ let(:query) { "pro" }
- it 'responds with status code 200' do
+ it "responds with status code 200" do
get :search, params: environment_params(format: :json, query: query)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns matched results' do
+ it "returns matched results" do
get :search, params: environment_params(format: :json, query: query)
- expect(json_response).to contain_exactly('production')
+ expect(json_response).to contain_exactly("production")
end
- context 'when query is review' do
- let(:query) { 'review' }
+ context "when query is review" do
+ let(:query) { "review" }
- it 'returns matched results' do
+ it "returns matched results" do
get :search, params: environment_params(format: :json, query: query)
- expect(json_response).to contain_exactly('review/patch-1', 'review/patch-2')
+ expect(json_response).to contain_exactly("review/patch-1", "review/patch-2")
end
end
- context 'when query is empty' do
- let(:query) { '' }
+ context "when query is empty" do
+ let(:query) { "" }
- it 'returns matched results' do
+ it "returns matched results" do
get :search, params: environment_params(format: :json, query: query)
expect(json_response)
- .to contain_exactly('production', 'staging', 'review/patch-1', 'review/patch-2')
+ .to contain_exactly("production", "staging", "review/patch-1", "review/patch-2")
end
end
- context 'when query is review/patch-3' do
- let(:query) { 'review/patch-3' }
+ context "when query is review/patch-3" do
+ let(:query) { "review/patch-3" }
- it 'responds with status code 204' do
+ it "responds with status code 204" do
get :search, params: environment_params(format: :json, query: query)
expect(response).to have_gitlab_http_status(:no_content)
end
end
- context 'when query is partially matched in the middle of environment name' do
- let(:query) { 'patch' }
+ context "when query is partially matched in the middle of environment name" do
+ let(:query) { "patch" }
- it 'responds with status code 204' do
+ it "responds with status code 204" do
get :search, params: environment_params(format: :json, query: query)
expect(response).to have_gitlab_http_status(:no_content)
end
end
- context 'when query contains a wildcard character' do
- let(:query) { 'review%' }
+ context "when query contains a wildcard character" do
+ let(:query) { "review%" }
- it 'prevents wildcard injection' do
+ it "prevents wildcard injection" do
get :search, params: environment_params(format: :json, query: query)
expect(response).to have_gitlab_http_status(:no_content)
diff --git a/spec/controllers/projects/error_tracking_controller_spec.rb b/spec/controllers/projects/error_tracking_controller_spec.rb
index 844c61f1ace..6cebdd46fdb 100644
--- a/spec/controllers/projects/error_tracking_controller_spec.rb
+++ b/spec/controllers/projects/error_tracking_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
describe Projects::ErrorTrackingController do
set(:project) { create(:project) }
@@ -11,33 +11,33 @@ describe Projects::ErrorTrackingController do
project.add_maintainer(user)
end
- describe 'GET #index' do
- describe 'html' do
- it 'renders index with 200 status code' do
+ describe "GET #index" do
+ describe "html" do
+ it "renders index with 200 status code" do
get :index, params: project_params
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
- context 'with insufficient permissions' do
+ context "with insufficient permissions" do
before do
project.add_guest(user)
end
- it 'returns 404' do
+ it "returns 404" do
get :index, params: project_params
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'with an anonymous user' do
+ context "with an anonymous user" do
before do
sign_out(user)
end
- it 'redirects to sign-in page' do
+ it "redirects to sign-in page" do
get :index, params: project_params
expect(response).to redirect_to(new_user_session_path)
@@ -45,20 +45,20 @@ describe Projects::ErrorTrackingController do
end
end
- describe 'format json' do
- shared_examples 'no data' do
- it 'returns no data' do
+ describe "format json" do
+ shared_examples "no data" do
+ it "returns no data" do
get :index, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('error_tracking/index')
- expect(json_response['external_url']).to be_nil
- expect(json_response['errors']).to eq([])
+ expect(response).to match_response_schema("error_tracking/index")
+ expect(json_response["external_url"]).to be_nil
+ expect(json_response["errors"]).to eq([])
end
end
let(:list_issues_service) { spy(:list_issues_service) }
- let(:external_url) { 'http://example.com' }
+ let(:external_url) { "http://example.com" }
before do
expect(ErrorTracking::ListIssuesService)
@@ -66,7 +66,7 @@ describe Projects::ErrorTrackingController do
.and_return(list_issues_service)
end
- context 'service result is successful' do
+ context "service result is successful" do
before do
expect(list_issues_service).to receive(:execute)
.and_return(status: :success, issues: [error])
@@ -76,34 +76,34 @@ describe Projects::ErrorTrackingController do
let(:error) { build(:error_tracking_error) }
- it 'returns a list of errors' do
+ it "returns a list of errors" do
get :index, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('error_tracking/index')
- expect(json_response['external_url']).to eq(external_url)
- expect(json_response['errors']).to eq([error].as_json)
+ expect(response).to match_response_schema("error_tracking/index")
+ expect(json_response["external_url"]).to eq(external_url)
+ expect(json_response["errors"]).to eq([error].as_json)
end
end
- context 'service result is erroneous' do
- let(:error_message) { 'error message' }
+ context "service result is erroneous" do
+ let(:error_message) { "error message" }
- context 'without http_status' do
+ context "without http_status" do
before do
expect(list_issues_service).to receive(:execute)
.and_return(status: :error, message: error_message)
end
- it 'returns 400 with message' do
+ it "returns 400 with message" do
get :index, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to eq(error_message)
+ expect(json_response["message"]).to eq(error_message)
end
end
- context 'with explicit http_status' do
+ context "with explicit http_status" do
let(:http_status) { :no_content }
before do
@@ -114,43 +114,43 @@ describe Projects::ErrorTrackingController do
)
end
- it 'returns http_status with message' do
+ it "returns http_status with message" do
get :index, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(http_status)
- expect(json_response['message']).to eq(error_message)
+ expect(json_response["message"]).to eq(error_message)
end
end
end
end
end
- describe 'POST #list_projects' do
- context 'with insufficient permissions' do
+ describe "POST #list_projects" do
+ context "with insufficient permissions" do
before do
project.add_guest(user)
end
- it 'returns 404' do
+ it "returns 404" do
post :list_projects, params: list_projects_params
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'with an anonymous user' do
+ context "with an anonymous user" do
before do
sign_out(user)
end
- it 'redirects to sign-in page' do
+ it "redirects to sign-in page" do
post :list_projects, params: list_projects_params
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
- context 'with authorized user' do
+ context "with authorized user" do
let(:list_projects_service) { spy(:list_projects_service) }
let(:sentry_project) { build(:error_tracking_project) }
@@ -166,39 +166,39 @@ describe Projects::ErrorTrackingController do
.and_return(list_projects_service)
end
- context 'service result is successful' do
+ context "service result is successful" do
before do
expect(list_projects_service).to receive(:execute)
.and_return(status: :success, projects: [sentry_project])
end
- it 'returns a list of projects' do
+ it "returns a list of projects" do
post :list_projects, params: list_projects_params
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('error_tracking/list_projects')
- expect(json_response['projects']).to eq([sentry_project].as_json)
+ expect(response).to match_response_schema("error_tracking/list_projects")
+ expect(json_response["projects"]).to eq([sentry_project].as_json)
end
end
- context 'service result is erroneous' do
- let(:error_message) { 'error message' }
+ context "service result is erroneous" do
+ let(:error_message) { "error message" }
- context 'without http_status' do
+ context "without http_status" do
before do
expect(list_projects_service).to receive(:execute)
.and_return(status: :error, message: error_message)
end
- it 'returns 400 with message' do
+ it "returns 400 with message" do
get :list_projects, params: list_projects_params
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to eq(error_message)
+ expect(json_response["message"]).to eq(error_message)
end
end
- context 'with explicit http_status' do
+ context "with explicit http_status" do
let(:http_status) { :no_content }
before do
@@ -209,11 +209,11 @@ describe Projects::ErrorTrackingController do
)
end
- it 'returns http_status with message' do
+ it "returns http_status with message" do
get :list_projects, params: list_projects_params
expect(response).to have_gitlab_http_status(http_status)
- expect(json_response['message']).to eq(error_message)
+ expect(json_response["message"]).to eq(error_message)
end
end
end
@@ -225,8 +225,8 @@ describe Projects::ErrorTrackingController do
project_params(
format: :json,
error_tracking_setting: {
- api_host: 'gitlab.com',
- token: 'token'
+ api_host: "gitlab.com",
+ token: "token",
}
)
end
diff --git a/spec/controllers/projects/find_file_controller_spec.rb b/spec/controllers/projects/find_file_controller_spec.rb
index 9072d67af07..42a156261df 100644
--- a/spec/controllers/projects/find_file_controller_spec.rb
+++ b/spec/controllers/projects/find_file_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::FindFileController do
let(:project) { create(:project, :repository) }
@@ -17,38 +17,38 @@ describe Projects::FindFileController do
before do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ })
end
context "valid branch" do
- let(:id) { 'master' }
+ let(:id) { "master" }
it { is_expected.to respond_with(:success) }
end
context "invalid branch" do
- let(:id) { 'invalid-branch' }
+ let(:id) { "invalid-branch" }
it { is_expected.to respond_with(:not_found) }
end
end
describe "GET #list" do
- def go(format: 'json')
+ def go(format: "json")
get :list,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: id
- },
- format: format
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: id,
+ },
+ format: format
end
context "valid branch" do
- let(:id) { 'master' }
- it 'returns an array of file path list' do
+ let(:id) { "master" }
+ it "returns an array of file path list" do
go
json = JSON.parse(response.body)
@@ -59,9 +59,9 @@ describe Projects::FindFileController do
end
context "invalid branch" do
- let(:id) { 'invalid-branch' }
+ let(:id) { "invalid-branch" }
- it 'responds with status 404' do
+ it "responds with status 404" do
go
is_expected.to respond_with(:not_found)
end
diff --git a/spec/controllers/projects/forks_controller_spec.rb b/spec/controllers/projects/forks_controller_spec.rb
index 0e1663c8585..372eb0844ed 100644
--- a/spec/controllers/projects/forks_controller_spec.rb
+++ b/spec/controllers/projects/forks_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ForksController do
let(:user) { create(:user) }
@@ -10,69 +10,69 @@ describe Projects::ForksController do
group.add_owner(user)
end
- describe 'GET index' do
+ describe "GET index" do
def get_forks
get :index,
params: {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
end
- context 'when fork is public' do
+ context "when fork is public" do
before do
forked_project.update_attribute(:visibility_level, Project::PUBLIC)
end
- it 'is visible for non logged in users' do
+ it "is visible for non logged in users" do
get_forks
expect(assigns[:forks]).to be_present
end
end
- context 'when fork is private' do
+ context "when fork is private" do
before do
forked_project.update(visibility_level: Project::PRIVATE, group: group)
end
- it 'is 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
end
- context 'when user is logged in' do
+ context "when user is logged in" do
before do
sign_in(project.creator)
end
- context 'when user is not a Project member neither a group member' do
- it 'does not see the Project listed' do
+ context "when user is not a Project member neither a group member" do
+ it "does not see the Project listed" do
get_forks
expect(assigns[:forks]).to be_blank
end
end
- context 'when user is a member of the Project' do
+ context "when user is a member of the Project" do
before do
forked_project.add_developer(project.creator)
end
- it 'sees the project listed' do
+ it "sees the project listed" do
get_forks
expect(assigns[:forks]).to be_present
end
end
- context 'when user is a member of the Group' do
+ context "when user is a member of the Group" do
before do
forked_project.group.add_developer(project.creator)
end
- it 'sees the project listed' do
+ it "sees the project listed" do
get_forks
expect(assigns[:forks]).to be_present
@@ -82,17 +82,17 @@ describe Projects::ForksController do
end
end
- describe 'GET new' do
+ describe "GET new" do
def get_new
get :new,
params: {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
end
- context 'when user is signed in' do
- it 'responds with status 200' do
+ context "when user is signed in" do
+ it "responds with status 200" do
sign_in(user)
get_new
@@ -101,8 +101,8 @@ describe Projects::ForksController do
end
end
- context 'when user is not signed in' do
- it 'redirects to the sign-in page' do
+ context "when user is not signed in" do
+ it "redirects to the sign-in page" do
sign_out(user)
get_new
@@ -112,18 +112,18 @@ describe Projects::ForksController do
end
end
- describe 'POST create' do
+ describe "POST create" do
def post_create
post :create,
params: {
namespace_id: project.namespace,
project_id: project,
- namespace_key: user.namespace.id
+ namespace_key: user.namespace.id,
}
end
- context 'when user is signed in' do
- it 'responds with status 302' do
+ context "when user is signed in" do
+ it "responds with status 302" do
sign_in(user)
post_create
@@ -133,8 +133,8 @@ describe Projects::ForksController do
end
end
- context 'when user is not signed in' do
- it 'redirects to the sign-in page' do
+ context "when user is not signed in" do
+ it "redirects to the sign-in page" do
sign_out(user)
post_create
diff --git a/spec/controllers/projects/graphs_controller_spec.rb b/spec/controllers/projects/graphs_controller_spec.rb
index 8decd8f1382..fa9ed78a683 100644
--- a/spec/controllers/projects/graphs_controller_spec.rb
+++ b/spec/controllers/projects/graphs_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::GraphsController do
let(:project) { create(:project, :repository) }
@@ -9,34 +9,35 @@ describe Projects::GraphsController do
project.add_maintainer(user)
end
- describe 'GET languages' do
+ describe "GET languages" do
it "redirects_to action charts" do
- get(:commits, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
+ get(:commits, params: {namespace_id: project.namespace.path, project_id: project.path, id: "master"})
expect(response).to redirect_to action: :charts
end
end
- describe 'GET commits' do
+ describe "GET commits" do
it "redirects_to action charts" do
- get(:commits, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
+ get(:commits, params: {namespace_id: project.namespace.path, project_id: project.path, id: "master"})
expect(response).to redirect_to action: :charts
end
end
- describe 'charts' do
- context 'when languages were previously detected' do
+ describe "charts" do
+ context "when languages were previously detected" do
let!(:repository_language) { create(:repository_language, project: project) }
- it 'sets the languages properly' do
- get(:charts, params: { namespace_id: project.namespace.path, project_id: project.path, id: 'master' })
+ it "sets the languages properly" do
+ get(:charts, params: {namespace_id: project.namespace.path, project_id: project.path, id: "master"})
expect(assigns[:languages]).to eq(
[value: repository_language.share,
label: repository_language.name,
color: repository_language.color,
- highlight: repository_language.color])
+ highlight: repository_language.color]
+ )
end
end
end
diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb
index 675eeff8d12..c18eeaedd5e 100644
--- a/spec/controllers/projects/group_links_controller_spec.rb
+++ b/spec/controllers/projects/group_links_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::GroupLinksController do
let(:group) { create(:group, :private) }
@@ -11,95 +11,95 @@ describe Projects::GroupLinksController do
sign_in(user)
end
- describe '#create' do
- shared_context 'link project to group' do
+ describe "#create" do
+ shared_context "link project to group" do
before do
post(:create, params: {
- namespace_id: project.namespace,
- project_id: project,
- link_group_id: group.id,
- link_group_access: ProjectGroupLink.default_access
- })
+ namespace_id: project.namespace,
+ project_id: project,
+ link_group_id: group.id,
+ link_group_access: ProjectGroupLink.default_access,
+ })
end
end
- context 'when project is not allowed to be shared with a group' do
+ context "when project is not allowed to be shared with a group" do
before do
group.update(share_with_group_lock: false)
end
- include_context 'link project to group'
+ include_context "link project to group"
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user has access to group he want to link project to' do
+ context "when user has access to group he want to link project to" do
before do
group.add_developer(user)
end
- include_context 'link project to group'
+ include_context "link project to group"
- it 'links project with selected group' do
+ it "links project with selected group" do
expect(group.shared_projects).to include project
end
- it 'redirects to project group links page' do
+ it "redirects to project group links page" do
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
- context 'when user doers not have access to group he want to link to' do
- include_context 'link project to group'
+ context "when user doers not have access to group he want to link to" do
+ include_context "link project to group"
- it 'renders 404' do
+ it "renders 404" do
expect(response.status).to eq 404
end
- it 'does not share project with that group' do
+ it "does not share project with that group" do
expect(group.shared_projects).not_to include project
end
end
- context 'when project group id equal link group id' do
+ context "when project group id equal link group id" do
before do
post(:create, params: {
- namespace_id: project.namespace,
- project_id: project,
- link_group_id: group2.id,
- link_group_access: ProjectGroupLink.default_access
- })
+ namespace_id: project.namespace,
+ project_id: project,
+ link_group_id: group2.id,
+ link_group_access: ProjectGroupLink.default_access,
+ })
end
- it 'does not share project with selected group' do
+ it "does not share project with selected group" do
expect(group2.shared_projects).not_to include project
end
- it 'redirects to project group links page' do
+ it "redirects to project group links page" do
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
- context 'when link group id is not present' do
+ context "when link group id is not present" do
before do
post(:create, params: {
- namespace_id: project.namespace,
- project_id: project,
- link_group_access: ProjectGroupLink.default_access
- })
+ namespace_id: project.namespace,
+ project_id: project,
+ link_group_access: ProjectGroupLink.default_access,
+ })
end
- it 'redirects to project group links page' do
+ it "redirects to project group links page" do
expect(response).to redirect_to(
project_project_members_path(project)
)
- expect(flash[:alert]).to eq('Please select a group.')
+ expect(flash[:alert]).to eq("Please select a group.")
end
end
end
diff --git a/spec/controllers/projects/hooks_controller_spec.rb b/spec/controllers/projects/hooks_controller_spec.rb
index 3037c922b68..b766030a94a 100644
--- a/spec/controllers/projects/hooks_controller_spec.rb
+++ b/spec/controllers/projects/hooks_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::HooksController do
let(:project) { create(:project) }
@@ -9,9 +9,9 @@ describe Projects::HooksController do
sign_in(user)
end
- describe '#index' do
- it 'redirects to settings/integrations page' do
- get(:index, params: { namespace_id: project.namespace, project_id: project })
+ describe "#index" do
+ it "redirects to settings/integrations page" do
+ get(:index, params: {namespace_id: project.namespace, project_id: project})
expect(response).to redirect_to(
project_settings_integrations_path(project)
@@ -19,8 +19,8 @@ describe Projects::HooksController do
end
end
- describe '#create' do
- it 'sets all parameters' do
+ describe "#create" do
+ it "sets all parameters" do
hook_params = {
enable_ssl_verification: true,
token: "TEST TOKEN",
@@ -35,10 +35,10 @@ describe Projects::HooksController do
note_events: true,
job_events: true,
pipeline_events: true,
- wiki_page_events: true
+ wiki_page_events: true,
}
- post :create, params: { namespace_id: project.namespace, project_id: project, hook: hook_params }
+ post :create, params: {namespace_id: project.namespace, project_id: project, hook: hook_params}
expect(response).to have_http_status(302)
expect(ProjectHook.all.size).to eq(1)
diff --git a/spec/controllers/projects/imports_controller_spec.rb b/spec/controllers/projects/imports_controller_spec.rb
index 3ebfe4b0918..b80a16476d1 100644
--- a/spec/controllers/projects/imports_controller_spec.rb
+++ b/spec/controllers/projects/imports_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ImportsController do
let(:user) { create(:user) }
@@ -9,111 +9,111 @@ describe Projects::ImportsController do
project.add_maintainer(user)
end
- describe 'GET #show' do
- context 'when repository does not exists' do
- it 'renders template' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ describe "GET #show" do
+ context "when repository does not exists" do
+ it "renders template" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to render_template :show
end
- it 'sets flash.now if params is present' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project, continue: { to: '/', notice_now: 'Started' } }
+ it "sets flash.now if params is present" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project, continue: {to: "/", notice_now: "Started"}}
- expect(flash.now[:notice]).to eq 'Started'
+ expect(flash.now[:notice]).to eq "Started"
end
end
- context 'when repository exists' do
- let(:project) { create(:project_empty_repo, import_url: 'https://github.com/vim/vim.git') }
+ context "when repository exists" do
+ let(:project) { create(:project_empty_repo, import_url: "https://github.com/vim/vim.git") }
let(:import_state) { project.import_state }
- context 'when import is in progress' do
+ context "when import is in progress" do
before do
import_state.update(status: :started)
end
- it 'renders template' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ it "renders template" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to render_template :show
end
- it 'sets flash.now if params is present' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project, continue: { to: '/', notice_now: 'In progress' } }
+ it "sets flash.now if params is present" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project, continue: {to: "/", notice_now: "In progress"}}
- expect(flash.now[:notice]).to eq 'In progress'
+ expect(flash.now[:notice]).to eq "In progress"
end
end
- context 'when import failed' do
+ context "when import failed" do
before do
import_state.update(status: :failed)
end
- it 'redirects to new_namespace_project_import_path' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ it "redirects to new_namespace_project_import_path" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to redirect_to new_project_import_path(project)
end
end
- context 'when import finished' do
+ context "when import finished" do
before do
import_state.update(status: :finished)
end
- context 'when project is a fork' do
- it 'redirects to namespace_project_path' do
+ context "when project is a fork" do
+ it "redirects to namespace_project_path" do
allow_any_instance_of(Project).to receive(:forked?).and_return(true)
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
- expect(flash[:notice]).to eq 'The project was successfully forked.'
+ expect(flash[:notice]).to eq "The project was successfully forked."
expect(response).to redirect_to project_path(project)
end
end
- context 'when project is external' do
- it 'redirects to namespace_project_path' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ context "when project is external" do
+ it "redirects to namespace_project_path" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
- expect(flash[:notice]).to eq 'The project was successfully imported.'
+ expect(flash[:notice]).to eq "The project was successfully imported."
expect(response).to redirect_to project_path(project)
end
end
- context 'when continue params is present' do
+ context "when continue params is present" do
let(:params) do
{
to: project_path(project),
- notice: 'Finished'
+ notice: "Finished",
}
end
- it 'redirects to internal params[:to]' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project, continue: params }
+ it "redirects to internal params[:to]" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project, continue: params}
expect(flash[:notice]).to eq params[:notice]
expect(response).to redirect_to params[:to]
end
- it 'does not redirect to external params[:to]' do
+ it "does not redirect to external params[:to]" do
params[:to] = "//google.com"
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project, continue: params }
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project, continue: params}
expect(response).not_to redirect_to params[:to]
end
end
end
- context 'when import never happened' do
+ context "when import never happened" do
before do
import_state.update(status: :none)
end
- it 'redirects to namespace_project_path' do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }
+ it "redirects to namespace_project_path" do
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to redirect_to project_path(project)
end
diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb
index c34d7c13d57..85bc675b512 100644
--- a/spec/controllers/projects/issues_controller_spec.rb
+++ b/spec/controllers/projects/issues_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::IssuesController do
let(:project) { create(:project) }
@@ -6,27 +6,27 @@ describe Projects::IssuesController do
let(:issue) { create(:issue, project: project) }
describe "GET #index" do
- context 'external issue tracker' do
+ context "external issue tracker" do
before do
sign_in(user)
project.add_developer(user)
create(:jira_service, project: project)
end
- context 'when GitLab issues disabled' do
- it 'returns 404 status' do
+ context "when GitLab issues disabled" do
+ it "returns 404 status" do
project.issues_enabled = false
project.save!
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when GitLab issues enabled' do
+ context "when GitLab issues enabled" do
it 'renders the "index" template' do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:index)
@@ -34,7 +34,7 @@ describe Projects::IssuesController do
end
end
- context 'internal issue tracker' do
+ context "internal issue tracker" do
before do
sign_in(user)
project.add_developer(user)
@@ -42,18 +42,18 @@ describe Projects::IssuesController do
it_behaves_like "issuables list meta-data", :issue
- it_behaves_like 'set sort order from user preference' do
- let(:sorting_param) { 'updated_asc' }
+ it_behaves_like "set sort order from user preference" do
+ let(:sorting_param) { "updated_asc" }
end
it "returns index" do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
end
it "returns 301 if request path doesn't match project path" do
- get :index, params: { namespace_id: project.namespace, project_id: project.path.upcase }
+ get :index, params: {namespace_id: project.namespace, project_id: project.path.upcase}
expect(response).to redirect_to(project_issues_path(project))
end
@@ -62,12 +62,12 @@ describe Projects::IssuesController do
project.issues_enabled = false
project.save!
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with page param' do
+ context "with page param" do
let(:last_page) { project.issues.page.total_pages }
let!(:issue_list) { create_list(:issue, 2, project: project) }
@@ -77,50 +77,50 @@ describe Projects::IssuesController do
allow(Kaminari.config).to receive(:default_per_page).and_return(1)
end
- it 'redirects to last_page if page number is larger than number of pages' do
+ it "redirects to last_page if page number is larger than number of pages" do
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- page: (last_page + 1).to_param
+ page: (last_page + 1).to_param,
}
expect(response).to redirect_to(namespace_project_issues_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
- it 'redirects to specified page' do
+ it "redirects to specified page" do
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- page: last_page.to_param
+ page: last_page.to_param,
}
expect(assigns(:issues).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
end
- it 'does not redirect to external sites when provided a host field' do
+ it "does not redirect to external sites when provided a host field" do
external_host = "www.example.com"
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
page: (last_page + 1).to_param,
- host: external_host
+ host: external_host,
}
expect(response).to redirect_to(namespace_project_issues_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
- it 'does not use pagination if disabled' do
+ it "does not use pagination if disabled" do
allow(controller).to receive(:pagination_disabled?).and_return(true)
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- page: (last_page + 1).to_param
+ page: (last_page + 1).to_param,
}
expect(response).to have_gitlab_http_status(200)
@@ -129,50 +129,50 @@ describe Projects::IssuesController do
end
end
- describe 'GET #new' do
- it 'redirects to signin if not logged in' do
- get :new, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET #new" do
+ it "redirects to signin if not logged in" do
+ get :new, params: {namespace_id: project.namespace, project_id: project}
- expect(flash[:alert]).to eq 'You need to sign in or sign up before continuing.'
+ expect(flash[:alert]).to eq "You need to sign in or sign up before continuing."
expect(response).to redirect_to(new_user_session_path)
end
- context 'internal issue tracker' do
+ context "internal issue tracker" do
before do
sign_in(user)
project.add_developer(user)
end
- it 'builds a new issue' do
- get :new, params: { namespace_id: project.namespace, project_id: project }
+ it "builds a new issue" do
+ get :new, params: {namespace_id: project.namespace, project_id: project}
expect(assigns(:issue)).to be_a_new(Issue)
end
- it 'fills in an issue for a merge request' do
+ it "fills in an issue for a merge request" do
project_with_repository = create(:project, :repository)
project_with_repository.add_developer(user)
mr = create(:merge_request_with_diff_notes, source_project: project_with_repository)
- get :new, params: { namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_to_resolve_discussions_of: mr.iid }
+ get :new, params: {namespace_id: project_with_repository.namespace, project_id: project_with_repository, merge_request_to_resolve_discussions_of: mr.iid}
expect(assigns(:issue).title).not_to be_empty
expect(assigns(:issue).description).not_to be_empty
end
- it 'fills in an issue for a discussion' do
+ it "fills in an issue for a discussion" do
note = create(:note_on_merge_request, project: project)
- get :new, params: { namespace_id: project.namespace.path, project_id: project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id }
+ get :new, params: {namespace_id: project.namespace.path, project_id: project, merge_request_to_resolve_discussions_of: note.noteable.iid, discussion_to_resolve: note.discussion_id}
expect(assigns(:issue).title).not_to be_empty
expect(assigns(:issue).description).not_to be_empty
end
end
- context 'external issue tracker' do
+ context "external issue tracker" do
let!(:service) do
- create(:custom_issue_tracker_service, project: project, title: 'Custom Issue Tracker', new_issue_url: 'http://test.com')
+ create(:custom_issue_tracker_service, project: project, title: "Custom Issue Tracker", new_issue_url: "http://test.com")
end
before do
@@ -183,20 +183,20 @@ describe Projects::IssuesController do
allow(project).to receive(:external_issue_tracker).and_return(external)
end
- context 'when GitLab issues disabled' do
- it 'returns 404 status' do
+ context "when GitLab issues disabled" do
+ it "returns 404 status" do
project.issues_enabled = false
project.save!
- get :new, params: { namespace_id: project.namespace, project_id: project }
+ get :new, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when GitLab issues enabled' do
+ context "when GitLab issues enabled" do
it 'renders the "new" template' do
- get :new, params: { namespace_id: project.namespace, project_id: project }
+ get :new, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:new)
@@ -205,49 +205,49 @@ describe Projects::IssuesController do
end
end
- describe 'Redirect after sign in' do
- context 'with an AJAX request' do
- it 'does not store the visited URL' do
+ describe "Redirect after sign in" do
+ context "with an AJAX request" do
+ it "does not store the visited URL" do
get :show, params: {
format: :json,
namespace_id: project.namespace,
project_id: project,
- id: issue.iid
+ id: issue.iid,
}, xhr: true
- expect(session['user_return_to']).to be_blank
+ expect(session["user_return_to"]).to be_blank
end
end
- context 'without an AJAX request' do
- it 'stores the visited URL' do
+ context "without an AJAX request" do
+ it "stores the visited URL" do
get :show,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: issue.iid
+ id: issue.iid,
}
- expect(session['user_return_to']).to eq("/#{project.namespace.to_param}/#{project.to_param}/issues/#{issue.iid}")
+ expect(session["user_return_to"]).to eq("/#{project.namespace.to_param}/#{project.to_param}/issues/#{issue.iid}")
end
end
end
- describe 'POST #move' do
+ describe "POST #move" do
before do
sign_in(user)
project.add_developer(user)
end
- context 'when moving issue to another private project' do
+ context "when moving issue to another private project" do
let(:another_project) { create(:project, :private) }
- context 'when user has access to move issue' do
+ context "when user has access to move issue" do
before do
another_project.add_reporter(user)
end
- it 'moves issue to another project' do
+ it "moves issue to another project" do
move_issue
expect(response).to have_gitlab_http_status :ok
@@ -255,8 +255,8 @@ describe Projects::IssuesController do
end
end
- context 'when user does not have access to move issue' do
- it 'responds with 404' do
+ context "when user does not have access to move issue" do
+ it "responds with 404" do
move_issue
expect(response).to have_gitlab_http_status :not_found
@@ -269,21 +269,21 @@ describe Projects::IssuesController do
namespace_id: project.namespace.to_param,
project_id: project,
id: issue.iid,
- move_to_project_id: another_project.id
+ move_to_project_id: another_project.id,
},
format: :json
end
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
subject do
put :update,
params: {
namespace_id: project.namespace,
project_id: project,
id: issue.to_param,
- issue: { title: 'New title' }
+ issue: {title: "New title"},
},
format: :json
end
@@ -292,39 +292,39 @@ describe Projects::IssuesController do
sign_in(user)
end
- context 'when user has access to update issue' do
+ context "when user has access to update issue" do
before do
project.add_developer(user)
end
- it 'updates the issue' do
+ it "updates the issue" do
subject
expect(response).to have_http_status(:ok)
- expect(issue.reload.title).to eq('New title')
+ expect(issue.reload.title).to eq("New title")
end
- context 'when Akismet is enabled and the issue is identified as spam' do
+ context "when Akismet is enabled and the issue is identified as spam" do
before do
stub_application_setting(recaptcha_enabled: true)
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- it 'renders json with recaptcha_html' do
+ it "renders json with recaptcha_html" do
subject
- expect(JSON.parse(response.body)).to have_key('recaptcha_html')
+ expect(JSON.parse(response.body)).to have_key("recaptcha_html")
end
end
end
- context 'when user does not have access to update issue' do
+ context "when user does not have access to update issue" do
before do
project.add_guest(user)
end
- it 'responds with 404' do
+ it "responds with 404" do
subject
expect(response).to have_http_status(:not_found)
@@ -332,17 +332,17 @@ describe Projects::IssuesController do
end
end
- describe 'GET #realtime_changes' do
+ describe "GET #realtime_changes" do
def go(id:)
get :realtime_changes,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: id
+ id: id,
}
end
- context 'when an issue was edited' do
+ context "when an issue was edited" do
before do
project.add_developer(user)
@@ -351,17 +351,17 @@ describe Projects::IssuesController do
sign_in(user)
end
- it 'returns last edited time' do
+ it "returns last edited time" do
go(id: issue.iid)
data = JSON.parse(response.body)
- expect(data).to include('updated_at')
- expect(data['updated_at']).to eq(issue.last_edited_at.to_time.iso8601)
+ expect(data).to include("updated_at")
+ expect(data["updated_at"]).to eq(issue.last_edited_at.to_time.iso8601)
end
end
- context 'when an issue was edited by a deleted user' do
+ context "when an issue was edited by a deleted user" do
let(:deleted_user) { create(:user) }
before do
@@ -373,32 +373,32 @@ describe Projects::IssuesController do
sign_in(user)
end
- it 'returns 200' do
+ it "returns 200" do
go(id: issue.iid)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when getting the changes' do
+ context "when getting the changes" do
before do
project.add_developer(user)
sign_in(user)
end
- it 'returns the necessary data' do
+ it "returns the necessary data" do
go(id: issue.iid)
data = JSON.parse(response.body)
- expect(data).to include('title_text', 'description', 'description_text')
- expect(data).to include('task_status', 'lock_version')
+ expect(data).to include("title_text", "description", "description_text")
+ expect(data).to include("task_status", "lock_version")
end
end
end
- describe 'Confidential Issues' do
+ describe "Confidential Issues" do
let(:project) { create(:project_empty_repo, :public) }
let(:assignee) { create(:assignee) }
let(:author) { create(:user) }
@@ -409,22 +409,22 @@ describe Projects::IssuesController do
let!(:unescaped_parameter_value) { create(:issue, :confidential, project: project, author: author) }
let!(:request_forgery_timing_attack) { create(:issue, :confidential, project: project, assignees: [assignee]) }
- describe 'GET #index' do
- it 'does not list confidential issues for guests' do
+ describe "GET #index" do
+ it "does not list confidential issues for guests" do
sign_out(:user)
get_issues
expect(assigns(:issues)).to eq [issue]
end
- it 'does 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 'does 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.add_guest(member)
@@ -433,7 +433,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to eq [issue]
end
- it 'lists confidential issues for author' do
+ it "lists confidential issues for author" do
sign_in(author)
get_issues
@@ -441,7 +441,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).not_to include request_forgery_timing_attack
end
- it 'lists confidential issues for assignee' do
+ it "lists confidential issues for assignee" do
sign_in(assignee)
get_issues
@@ -449,7 +449,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to include request_forgery_timing_attack
end
- it 'lists confidential issues for project members' do
+ it "lists confidential issues for project members" do
sign_in(member)
project.add_developer(member)
@@ -459,7 +459,7 @@ describe Projects::IssuesController do
expect(assigns(:issues)).to include request_forgery_timing_attack
end
- it 'lists confidential issues for admin' do
+ it "lists confidential issues for admin" do
sign_in(admin)
get_issues
@@ -471,27 +471,27 @@ describe Projects::IssuesController do
get :index,
params: {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
end
end
- shared_examples_for 'restricted action' do |http_status|
- it 'returns 404 for guests' do
+ shared_examples_for "restricted action" do |http_status|
+ it "returns 404 for guests" do
sign_out(:user)
go(id: unescaped_parameter_value.to_param)
expect(response).to have_gitlab_http_status :not_found
end
- it 'returns 404 for non project members' do
+ it "returns 404 for non project members" do
sign_in(non_member)
go(id: unescaped_parameter_value.to_param)
expect(response).to have_gitlab_http_status :not_found
end
- it 'returns 404 for project members with guest role' do
+ it "returns 404 for project members with guest role" do
sign_in(member)
project.add_guest(member)
go(id: unescaped_parameter_value.to_param)
@@ -529,15 +529,15 @@ describe Projects::IssuesController do
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
def update_issue(issue_params: {}, additional_params: {}, id: nil)
id ||= issue.iid
params = {
namespace_id: project.namespace.to_param,
project_id: project,
id: id,
- issue: { title: 'New title' }.merge(issue_params),
- format: :json
+ issue: {title: "New title"}.merge(issue_params),
+ format: :json,
}.merge(additional_params)
put :update, params: params
@@ -552,92 +552,93 @@ describe Projects::IssuesController do
project.add_developer(user)
end
- it_behaves_like 'restricted action', success: 200
- it_behaves_like 'update invalid issuable', Issue
+ it_behaves_like "restricted action", success: 200
+ it_behaves_like "update invalid issuable", Issue
- context 'changing the assignee' do
- it 'limits the attributes exposed on the assignee' do
+ context "changing the assignee" do
+ it "limits the attributes exposed on the assignee" do
assignee = create(:user)
project.add_developer(assignee)
- update_issue(issue_params: { assignee_ids: [assignee.id] })
+ update_issue(issue_params: {assignee_ids: [assignee.id]})
body = JSON.parse(response.body)
- expect(body['assignees'].first.keys)
- .to match_array(%w(id name username avatar_url state web_url))
+ expect(body["assignees"].first.keys)
+ .to match_array(%w[id name username avatar_url state web_url])
end
end
- context 'Akismet is enabled' do
+ context "Akismet is enabled" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
stub_application_setting(recaptcha_enabled: true)
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
end
- context 'when an issue is not identified as spam' do
+ context "when an issue is not identified as spam" do
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
- it 'normally updates the issue' do
- expect { update_issue(issue_params: { title: 'Foo' }) }.to change { issue.reload.title }.to('Foo')
+ it "normally updates the issue" do
+ expect { update_issue(issue_params: {title: "Foo"}) }.to change { issue.reload.title }.to("Foo")
end
end
- context 'when an issue is identified as spam' do
+ context "when an issue is identified as spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when captcha is not verified' do
+ context "when captcha is not verified" do
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
end
- it 'rejects an issue recognized as a spam' do
+ it "rejects an issue recognized as a spam" do
expect { update_issue }.not_to change { issue.reload.title }
end
- it 'rejects an issue recognized as a spam when recaptcha disabled' do
+ it "rejects an issue recognized as a spam when recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
expect { update_issue }.not_to change { issue.reload.title }
end
- it 'creates a spam log' do
- update_issue(issue_params: { title: 'Spam title' })
+ it "creates a spam log" do
+ update_issue(issue_params: {title: "Spam title"})
spam_logs = SpamLog.all
expect(spam_logs.count).to eq(1)
- expect(spam_logs.first.title).to eq('Spam title')
+ expect(spam_logs.first.title).to eq("Spam title")
expect(spam_logs.first.recaptcha_verified).to be_falsey
end
- it 'renders recaptcha_html json response' do
+ it "renders recaptcha_html json response" do
update_issue
- expect(json_response).to have_key('recaptcha_html')
+ expect(json_response).to have_key("recaptcha_html")
end
- it 'returns 200 status' do
+ it "returns 200 status" do
update_issue
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when captcha is verified' do
- let(:spammy_title) { 'Whatever' }
+ context "when captcha is verified" do
+ let(:spammy_title) { "Whatever" }
let!(:spam_logs) { create_list(:spam_log, 2, user: user, title: spammy_title) }
def update_verified_issue
update_issue(
- issue_params: { title: spammy_title },
- additional_params: { spam_log_id: spam_logs.last.id, recaptcha_verification: true })
+ issue_params: {title: spammy_title},
+ additional_params: {spam_log_id: spam_logs.last.id, recaptcha_verification: true}
+ )
end
before do
@@ -645,22 +646,22 @@ describe Projects::IssuesController do
.and_return(true)
end
- it 'returns 200 status' do
+ it "returns 200 status" do
expect(response).to have_gitlab_http_status(200)
end
- it 'accepts an issue after recaptcha is verified' do
+ it "accepts an issue after recaptcha is verified" do
expect { update_verified_issue }.to change { issue.reload.title }.to(spammy_title)
end
- it 'marks spam log as recaptcha_verified' do
+ it "marks spam log as recaptcha_verified" do
expect { update_verified_issue }.to change { SpamLog.last.recaptcha_verified }.from(false).to(true)
end
- it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do
+ it "does not mark spam log as recaptcha_verified when it does not belong to current_user" do
spam_log = create(:spam_log)
- expect { update_issue(issue_params: { spam_log_id: spam_log.id, recaptcha_verification: true }) }
+ expect { update_issue(issue_params: {spam_log_id: spam_log.id, recaptcha_verification: true}) }
.not_to change { SpamLog.last.recaptcha_verified }
end
end
@@ -668,59 +669,59 @@ describe Projects::IssuesController do
end
end
- describe 'GET #show' do
- it_behaves_like 'restricted action', success: 200
+ describe "GET #show" do
+ it_behaves_like "restricted action", success: 200
def go(id:)
get :show,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: id
+ id: id,
}
end
- it 'avoids (most) N+1s loading labels', :request_store do
+ it "avoids (most) N+1s loading labels", :request_store do
label = create(:label, project: project).to_reference
labels = create_list(:label, 10, project: project).map(&:to_reference)
- issue = create(:issue, project: project, description: 'Test issue')
+ issue = create(:issue, project: project, description: "Test issue")
- control_count = ActiveRecord::QueryRecorder.new { issue.update(description: [issue.description, label].join(' ')) }.count
+ control_count = ActiveRecord::QueryRecorder.new { issue.update(description: [issue.description, label].join(" ")) }.count
# Follow-up to get rid of this `2 * label.count` requirement: https://gitlab.com/gitlab-org/gitlab-ce/issues/52230
- expect { issue.update(description: [issue.description, labels].join(' ')) }
+ expect { issue.update(description: [issue.description, labels].join(" ")) }
.not_to exceed_query_limit(control_count + 2 * labels.count)
end
end
- describe 'GET #realtime_changes' do
- it_behaves_like 'restricted action', success: 200
+ describe "GET #realtime_changes" do
+ it_behaves_like "restricted action", success: 200
def go(id:)
get :realtime_changes,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: id
+ id: id,
}
end
end
- describe 'GET #edit' do
- it_behaves_like 'restricted action', success: 200
+ describe "GET #edit" do
+ it_behaves_like "restricted action", success: 200
def go(id:)
get :edit,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: id
+ id: id,
}
end
end
- describe 'PUT #update' do
- it_behaves_like 'restricted action', success: 302
+ describe "PUT #update" do
+ it_behaves_like "restricted action", success: 302
def go(id:)
put :update,
@@ -728,13 +729,13 @@ describe Projects::IssuesController do
namespace_id: project.namespace.to_param,
project_id: project,
id: id,
- issue: { title: 'New title' }
+ issue: {title: "New title"},
}
end
end
end
- describe 'POST #create' do
+ describe "POST #create" do
def post_new_issue(issue_attrs = {}, additional_params = {})
sign_in(user)
project = create(:project, :public)
@@ -743,13 +744,13 @@ describe Projects::IssuesController do
post :create, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- issue: { title: 'Title', description: 'Description' }.merge(issue_attrs)
+ issue: {title: "Title", description: "Description"}.merge(issue_attrs),
}.merge(additional_params)
project.issues.first
end
- context 'resolving discussions in MergeRequest' do
+ context "resolving discussions in MergeRequest" do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
@@ -760,167 +761,167 @@ describe Projects::IssuesController do
end
let(:merge_request_params) do
- { merge_request_to_resolve_discussions_of: merge_request.iid }
+ {merge_request_to_resolve_discussions_of: merge_request.iid}
end
def post_issue(issue_params, other_params: {})
- post :create, params: { namespace_id: project.namespace.to_param, project_id: project, issue: issue_params, merge_request_to_resolve_discussions_of: merge_request.iid }.merge(other_params)
+ post :create, params: {namespace_id: project.namespace.to_param, project_id: project, issue: issue_params, merge_request_to_resolve_discussions_of: merge_request.iid}.merge(other_params)
end
- it 'creates an issue for the project' do
- expect { post_issue({ title: 'Hello' }) }.to change { project.issues.reload.size }.by(1)
+ it "creates an issue for the project" do
+ expect { post_issue({title: "Hello"}) }.to change { project.issues.reload.size }.by(1)
end
it "doesn't overwrite given params" do
- post_issue(description: 'Manually entered description')
+ post_issue(description: "Manually entered description")
- expect(assigns(:issue).description).to eq('Manually entered description')
+ expect(assigns(:issue).description).to eq("Manually entered description")
end
- it 'resolves the discussion in the merge_request' do
- post_issue(title: 'Hello')
+ it "resolves the discussion in the merge_request" do
+ post_issue(title: "Hello")
discussion.first_note.reload
expect(discussion.resolved?).to eq(true)
end
- it 'sets a flash message' do
- post_issue(title: 'Hello')
+ it "sets a flash message" do
+ post_issue(title: "Hello")
- expect(flash[:notice]).to eq('Resolved all discussions.')
+ expect(flash[:notice]).to eq("Resolved all discussions.")
end
describe "resolving a single discussion" do
before do
- post_issue({ title: 'Hello' }, other_params: { discussion_to_resolve: discussion.id })
+ post_issue({title: "Hello"}, other_params: {discussion_to_resolve: discussion.id})
end
- it 'resolves a single discussion' do
+ it "resolves a single discussion" do
discussion.first_note.reload
expect(discussion.resolved?).to eq(true)
end
- it 'sets a flash message that one discussion was resolved' do
- expect(flash[:notice]).to eq('Resolved 1 discussion.')
+ it "sets a flash message that one discussion was resolved" do
+ expect(flash[:notice]).to eq("Resolved 1 discussion.")
end
end
end
- context 'Akismet is enabled' do
+ context "Akismet is enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
end
- context 'when an issue is not identified as spam' do
+ context "when an issue is not identified as spam" do
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
- it 'does not create an issue' do
- expect { post_new_issue(title: '') }.not_to change(Issue, :count)
+ it "does not create an issue" do
+ expect { post_new_issue(title: "") }.not_to change(Issue, :count)
end
end
- context 'when an issue is identified as spam' do
+ context "when an issue is identified as spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when captcha is not verified' do
+ context "when captcha is not verified" do
def post_spam_issue
- post_new_issue(title: 'Spam Title', description: 'Spam lives here')
+ post_new_issue(title: "Spam Title", description: "Spam lives here")
end
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(false)
end
- it 'rejects an issue recognized as a spam' do
+ it "rejects an issue recognized as a spam" do
expect { post_spam_issue }.not_to change(Issue, :count)
end
- it 'creates a spam log' do
+ it "creates a spam log" do
post_spam_issue
spam_logs = SpamLog.all
expect(spam_logs.count).to eq(1)
- expect(spam_logs.first.title).to eq('Spam Title')
+ expect(spam_logs.first.title).to eq("Spam Title")
expect(spam_logs.first.recaptcha_verified).to be_falsey
end
- it 'does not create an issue when it is not valid' do
- expect { post_new_issue(title: '') }.not_to change(Issue, :count)
+ it "does not create an issue when it is not valid" do
+ expect { post_new_issue(title: "") }.not_to change(Issue, :count)
end
- it 'does not create an issue when recaptcha is not enabled' do
+ it "does not create an issue when recaptcha is not enabled" do
stub_application_setting(recaptcha_enabled: false)
expect { post_spam_issue }.not_to change(Issue, :count)
end
end
- context 'when captcha is verified' do
- let!(:spam_logs) { create_list(:spam_log, 2, user: user, title: 'Title') }
+ context "when captcha is verified" do
+ let!(:spam_logs) { create_list(:spam_log, 2, user: user, title: "Title") }
def post_verified_issue
- post_new_issue({}, { spam_log_id: spam_logs.last.id, recaptcha_verification: true } )
+ post_new_issue({}, {spam_log_id: spam_logs.last.id, recaptcha_verification: true})
end
before do
allow_any_instance_of(described_class).to receive(:verify_recaptcha).and_return(true)
end
- it 'accepts an issue after recaptcha is verified' do
+ it "accepts an issue after recaptcha is verified" do
expect { post_verified_issue }.to change(Issue, :count)
end
- it 'marks spam log as recaptcha_verified' do
+ it "marks spam log as recaptcha_verified" do
expect { post_verified_issue }.to change { SpamLog.last.recaptcha_verified }.from(false).to(true)
end
- it 'does not mark spam log as recaptcha_verified when it does not belong to current_user' do
+ it "does not mark spam log as recaptcha_verified when it does not belong to current_user" do
spam_log = create(:spam_log)
- expect { post_new_issue({}, { spam_log_id: spam_log.id, recaptcha_verification: true } ) }
+ expect { post_new_issue({}, {spam_log_id: spam_log.id, recaptcha_verification: true}) }
.not_to change { SpamLog.last.recaptcha_verified }
end
end
end
end
- context 'user agent details are saved' do
+ context "user agent details are saved" do
before do
- request.env['action_dispatch.remote_ip'] = '127.0.0.1'
+ request.env["action_dispatch.remote_ip"] = "127.0.0.1"
end
- it 'creates a user agent detail' do
+ it "creates a user agent detail" do
expect { post_new_issue }.to change(UserAgentDetail, :count).by(1)
end
end
- context 'when description has quick actions' do
+ context "when description has quick actions" do
before do
sign_in(user)
end
- it 'can add spent time' do
- issue = post_new_issue(description: '/spend 1h')
+ it "can add spent time" do
+ issue = post_new_issue(description: "/spend 1h")
expect(issue.total_time_spent).to eq(3600)
end
- it 'can set the time estimate' do
- issue = post_new_issue(description: '/estimate 2h')
+ it "can set the time estimate" do
+ issue = post_new_issue(description: "/estimate 2h")
expect(issue.time_estimate).to eq(7200)
end
end
end
- describe 'POST #mark_as_spam' do
- context 'properly submits to Akismet' do
+ describe "POST #mark_as_spam" do
+ context "properly submits to Akismet" do
before do
allow_any_instance_of(AkismetService).to receive_messages(submit_spam: true)
allow_any_instance_of(ApplicationSetting).to receive_messages(akismet_enabled: true)
@@ -934,11 +935,11 @@ describe Projects::IssuesController do
post :mark_as_spam, params: {
namespace_id: project.namespace,
project_id: project,
- id: issue.iid
+ id: issue.iid,
}
end
- it 'updates issue' do
+ it "updates issue" do
post_spam
expect(issue.submittable_as_spam?).to be_falsey
end
@@ -952,7 +953,7 @@ describe Projects::IssuesController do
end
it "rejects a developer to destroy an issue" do
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
expect(response).to have_gitlab_http_status(404)
end
end
@@ -967,41 +968,41 @@ describe Projects::IssuesController do
end
it "deletes the issue" do
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
expect(response).to have_gitlab_http_status(302)
expect(controller).to set_flash[:notice].to(/The issue was successfully deleted\./)
end
- it 'delegates the update of the todos count cache to TodoService' do
+ it "delegates the update of the todos count cache to TodoService" do
expect_any_instance_of(TodoService).to receive(:destroy_target).with(issue).once
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
end
end
end
- describe 'POST #toggle_award_emoji' do
+ describe "POST #toggle_award_emoji" do
before do
sign_in(user)
project.add_developer(user)
end
it "toggles the award emoji" do
- expect do
+ expect {
post(:toggle_award_emoji, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: issue.iid,
- name: "thumbsup"
- })
- end.to change { issue.award_emoji.count }.by(1)
+ namespace_id: project.namespace,
+ project_id: project,
+ id: issue.iid,
+ name: "thumbsup",
+ })
+ }.to change { issue.award_emoji.count }.by(1)
expect(response).to have_gitlab_http_status(200)
end
end
- describe 'POST create_merge_request' do
+ describe "POST create_merge_request" do
let(:project) { create(:project, :repository, :public) }
before do
@@ -1009,17 +1010,17 @@ describe Projects::IssuesController do
sign_in(user)
end
- it 'creates a new merge request' do
+ it "creates a new merge request" do
expect { create_merge_request }.to change(project.merge_requests, :count).by(1)
end
- it 'render merge request as json' do
+ it "render merge request as json" do
create_merge_request
- expect(response).to match_response_schema('merge_request')
+ expect(response).to match_response_schema("merge_request")
end
- it 'is not available when the project is archived' do
+ it "is not available when the project is archived" do
project.update!(archived: true)
create_merge_request
@@ -1027,7 +1028,7 @@ describe Projects::IssuesController do
expect(response).to have_gitlab_http_status(404)
end
- it 'is not available for users who cannot create merge requests' do
+ it "is not available for users who cannot create merge requests" do
sign_in(create(:user))
create_merge_request
@@ -1037,20 +1038,20 @@ describe Projects::IssuesController do
def create_merge_request
post :create_merge_request, params: {
- namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- id: issue.to_param
- },
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: issue.to_param,
+ },
format: :json
end
end
- describe 'POST #import_csv' do
+ describe "POST #import_csv" do
let(:project) { create(:project, :public) }
- let(:file) { fixture_file_upload('spec/fixtures/csv_comma.csv') }
+ let(:file) { fixture_file_upload("spec/fixtures/csv_comma.csv") }
- context 'unauthorized' do
- it 'returns 404 for guests' do
+ context "unauthorized" do
+ it "returns 404 for guests" do
sign_out(:user)
import_csv
@@ -1058,7 +1059,7 @@ describe Projects::IssuesController do
expect(response).to have_gitlab_http_status :not_found
end
- it 'returns 404 for project members with reporter role' do
+ it "returns 404 for project members with reporter role" do
sign_in(user)
project.add_reporter(user)
@@ -1068,7 +1069,7 @@ describe Projects::IssuesController do
end
end
- context 'authorized' do
+ context "authorized" do
before do
sign_in(user)
project.add_developer(user)
@@ -1077,7 +1078,7 @@ describe Projects::IssuesController do
it "returns 302 for project members with developer role" do
import_csv
- expect(flash[:notice]).to include('Your issues are being imported')
+ expect(flash[:notice]).to include("Your issues are being imported")
expect(response).to redirect_to(project_issues_path(project))
end
@@ -1086,64 +1087,64 @@ describe Projects::IssuesController do
import_csv
- expect(flash[:alert]).to include('File upload error.')
+ expect(flash[:alert]).to include("File upload error.")
expect(response).to redirect_to(project_issues_path(project))
end
end
def import_csv
- post :import_csv, params: { namespace_id: project.namespace.to_param,
- project_id: project.to_param,
- file: file }
+ post :import_csv, params: {namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ file: file,}
end
end
- describe 'GET #discussions' do
+ describe "GET #discussions" do
let!(:discussion) { create(:discussion_note_on_issue, noteable: issue, project: issue.project) }
- context 'when authenticated' do
+ context "when authenticated" do
before do
project.add_developer(user)
sign_in(user)
end
- it 'returns discussion json' do
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ it "returns discussion json" do
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion discussion_path individual_note resolvable resolved resolved_at resolved_by resolved_by_push commit_id for_commit project_id])
end
- it 'renders the author status html if there is a status' do
+ it "renders the author status html if there is a status" do
create(:user_status, user: discussion.author)
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
- note_json = json_response.first['notes'].first
+ note_json = json_response.first["notes"].first
- expect(note_json['author']['status_tooltip_html']).to be_present
+ expect(note_json["author"]["status_tooltip_html"]).to be_present
end
- it 'does not cause an extra query for the status' do
- control = ActiveRecord::QueryRecorder.new do
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
- end
+ it "does not cause an extra query for the status" do
+ control = ActiveRecord::QueryRecorder.new {
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
+ }
create(:user_status, user: discussion.author)
second_discussion = create(:discussion_note_on_issue, noteable: issue, project: issue.project, author: create(:user))
create(:user_status, user: second_discussion.author)
- expect { get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } }
+ expect { get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid} }
.not_to exceed_query_limit(control)
end
- context 'when user is setting notes filters' do
+ context "when user is setting notes filters" do
let(:issuable) { issue }
let(:issuable_parent) { project }
let!(:discussion_note) { create(:discussion_note_on_issue, :system, noteable: issuable, project: project) }
- it_behaves_like 'issuable notes filter'
+ it_behaves_like "issuable notes filter"
end
- context 'with cross-reference system note', :request_store do
+ context "with cross-reference system note", :request_store do
let(:new_issue) { create(:issue) }
let(:cross_reference) { "mentioned in #{new_issue.to_reference(issue.project)}" }
@@ -1151,36 +1152,36 @@ describe Projects::IssuesController do
create(:discussion_note_on_issue, :system, noteable: issue, project: issue.project, note: cross_reference)
end
- it 'filters notes that the user should not see' do
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ it "filters notes that the user should not see" do
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
expect(JSON.parse(response.body).count).to eq(1)
end
- it 'does not result in N+1 queries' do
+ it "does not result in N+1 queries" do
# Instantiate the controller variables to ensure QueryRecorder has an accurate base count
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
RequestStore.clear!
- control_count = ActiveRecord::QueryRecorder.new do
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid }
- end.count
+ control_count = ActiveRecord::QueryRecorder.new {
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid}
+ }.count
RequestStore.clear!
create_list(:discussion_note_on_issue, 2, :system, noteable: issue, project: issue.project, note: cross_reference)
- expect { get :discussions, params: { namespace_id: project.namespace, project_id: project, id: issue.iid } }.not_to exceed_query_limit(control_count)
+ expect { get :discussions, params: {namespace_id: project.namespace, project_id: project, id: issue.iid} }.not_to exceed_query_limit(control_count)
end
end
end
end
- context 'private project with token authentication' do
+ context "private project with token authentication" do
let(:private_project) { create(:project, :private) }
- it_behaves_like 'authenticates sessionless user', :index, :atom do
+ it_behaves_like "authenticates sessionless user", :index, :atom do
before do
default_params.merge!(project_id: private_project, namespace_id: private_project.namespace)
@@ -1188,7 +1189,7 @@ describe Projects::IssuesController do
end
end
- it_behaves_like 'authenticates sessionless user', :calendar, :ics do
+ it_behaves_like "authenticates sessionless user", :calendar, :ics do
before do
default_params.merge!(project_id: private_project, namespace_id: private_project.namespace)
@@ -1197,16 +1198,16 @@ describe Projects::IssuesController do
end
end
- context 'public project with token authentication' do
+ context "public project with token authentication" do
let(:public_project) { create(:project, :public) }
- it_behaves_like 'authenticates sessionless user', :index, :atom, public: true do
+ it_behaves_like "authenticates sessionless user", :index, :atom, public: true do
before do
default_params.merge!(project_id: public_project, namespace_id: public_project.namespace)
end
end
- it_behaves_like 'authenticates sessionless user', :calendar, :ics, public: true do
+ it_behaves_like "authenticates sessionless user", :calendar, :ics, public: true do
before do
default_params.merge!(project_id: public_project, namespace_id: public_project.namespace)
end
diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb
index d8a331b3cf0..53381608c12 100644
--- a/spec/controllers/projects/jobs_controller_spec.rb
+++ b/spec/controllers/projects/jobs_controller_spec.rb
@@ -1,5 +1,4 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Projects::JobsController, :clean_gitlab_redis_shared_state do
include ApiHelpers
@@ -14,71 +13,71 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
stub_not_protect_default_branch
end
- describe 'GET index' do
- context 'when scope is pending' do
+ describe "GET index" do
+ context "when scope is pending" do
before do
create(:ci_build, :pending, pipeline: pipeline)
- get_index(scope: 'pending')
+ get_index(scope: "pending")
end
- it 'has only pending builds' do
+ it "has only pending builds" do
expect(response).to have_gitlab_http_status(:ok)
- expect(assigns(:builds).first.status).to eq('pending')
+ expect(assigns(:builds).first.status).to eq("pending")
end
end
- context 'when scope is running' do
+ context "when scope is running" do
before do
create(:ci_build, :running, pipeline: pipeline)
- get_index(scope: 'running')
+ get_index(scope: "running")
end
- it 'has only running jobs' do
+ it "has only running jobs" do
expect(response).to have_gitlab_http_status(:ok)
- expect(assigns(:builds).first.status).to eq('running')
+ expect(assigns(:builds).first.status).to eq("running")
end
end
- context 'when scope is finished' do
+ context "when scope is finished" do
before do
create(:ci_build, :success, pipeline: pipeline)
- get_index(scope: 'finished')
+ get_index(scope: "finished")
end
- it 'has only finished jobs' do
+ it "has only finished jobs" do
expect(response).to have_gitlab_http_status(:ok)
- expect(assigns(:builds).first.status).to eq('success')
+ expect(assigns(:builds).first.status).to eq("success")
end
end
- context 'when page is specified' do
+ context "when page is specified" do
let(:last_page) { project.builds.page.total_pages }
- context 'when page number is eligible' do
+ context "when page number is eligible" do
before do
create_list(:ci_build, 2, pipeline: pipeline)
get_index(page: last_page.to_param)
end
- it 'redirects to the page' do
+ it "redirects to the page" do
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:builds).current_page).to eq(last_page)
end
end
end
- context 'number of queries' do
+ context "number of queries" do
before do
Ci::Build::AVAILABLE_STATUSES.each do |status|
create_job(status, status)
end
end
- it 'verifies number of queries', :request_store do
+ it "verifies number of queries", :request_store do
recorded = ActiveRecord::QueryRecorder.new { get_index }
expect(recorded.count).to be_within(5).of(7)
end
@@ -86,37 +85,37 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def create_job(name, status)
pipeline = create(:ci_pipeline, project: project)
create(:ci_build, :tags, :triggered, :artifacts,
- pipeline: pipeline, name: name, status: status)
+ pipeline: pipeline, name: name, status: status)
end
end
def get_index(**extra_params)
params = {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
get :index, params: params.merge(extra_params)
end
end
- describe 'GET show' do
+ describe "GET show" do
let!(:job) { create(:ci_build, :failed, pipeline: pipeline) }
let!(:second_job) { create(:ci_build, :failed, pipeline: pipeline) }
let!(:third_job) { create(:ci_build, :failed) }
- context 'when requesting HTML' do
- context 'when job exists' do
+ context "when requesting HTML" do
+ context "when job exists" do
before do
get_show(id: job.id)
end
- it 'has a job' do
+ it "has a job" do
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:build).id).to eq(job.id)
end
- it 'has the correct build collection' do
+ it "has the correct build collection" do
builds = assigns(:builds).map(&:id)
expect(builds).to include(job.id, second_job.id)
@@ -124,18 +123,18 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'when job does not exist' do
+ context "when job does not exist" do
before do
get_show(id: 1234)
end
- it 'renders not_found' do
+ it "renders not_found" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
- context 'when requesting JSON' do
+ context "when requesting JSON" do
let(:merge_request) { create(:merge_request, source_project: project) }
before do
@@ -147,102 +146,102 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
get_show(id: job.id, format: :json)
end
- context 'when job failed' do
- it 'exposes needed information' do
+ context "when job failed" do
+ it "exposes needed information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['raw_path']).to match(%r{jobs/\d+/raw\z})
- expect(json_response['merge_request']['path']).to match(%r{merge_requests/\d+\z})
- expect(json_response['new_issue_path']).to include('/issues/new')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["raw_path"]).to match(%r{jobs/\d+/raw\z})
+ expect(json_response["merge_request"]["path"]).to match(%r{merge_requests/\d+\z})
+ expect(json_response["new_issue_path"]).to include("/issues/new")
end
end
- context 'when job is running' do
- context 'job is cancelable' do
+ context "when job is running" do
+ context "job is cancelable" do
let(:job) { create(:ci_build, :running, pipeline: pipeline) }
- it 'cancel_path is present with correct redirect' do
+ it "cancel_path is present with correct redirect" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['cancel_path']).to include(CGI.escape(json_response['build_path']))
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["cancel_path"]).to include(CGI.escape(json_response["build_path"]))
end
end
- context 'with web terminal' do
+ context "with web terminal" do
let(:job) { create(:ci_build, :running, :with_runner_session, pipeline: pipeline) }
- it 'exposes the terminal path' do
+ it "exposes the terminal path" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['terminal_path']).to match(%r{/terminal})
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["terminal_path"]).to match(%r{/terminal})
end
end
end
- context 'when job has artifacts' do
- context 'with not expiry date' do
+ context "when job has artifacts" do
+ context "with not expiry date" do
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
- it 'exposes needed information' do
+ it "exposes needed information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['artifact']['download_path']).to match(%r{artifacts/download})
- expect(json_response['artifact']['browse_path']).to match(%r{artifacts/browse})
- expect(json_response['artifact']).not_to have_key('expired')
- expect(json_response['artifact']).not_to have_key('expired_at')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["artifact"]["download_path"]).to match(%r{artifacts/download})
+ expect(json_response["artifact"]["browse_path"]).to match(%r{artifacts/browse})
+ expect(json_response["artifact"]).not_to have_key("expired")
+ expect(json_response["artifact"]).not_to have_key("expired_at")
end
end
- context 'with expiry date' do
+ context "with expiry date" do
let(:job) { create(:ci_build, :success, :artifacts, :expired, pipeline: pipeline) }
- it 'exposes needed information' do
+ it "exposes needed information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['artifact']).not_to have_key('download_path')
- expect(json_response['artifact']).not_to have_key('browse_path')
- expect(json_response['artifact']['expired']).to eq(true)
- expect(json_response['artifact']['expire_at']).not_to be_empty
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["artifact"]).not_to have_key("download_path")
+ expect(json_response["artifact"]).not_to have_key("browse_path")
+ expect(json_response["artifact"]["expired"]).to eq(true)
+ expect(json_response["artifact"]["expire_at"]).not_to be_empty
end
end
end
- context 'when job passed with no trace' do
+ context "when job passed with no trace" do
let(:job) { create(:ci_build, :success, :artifacts, pipeline: pipeline) }
- it 'exposes empty state illustrations' do
+ it "exposes empty state illustrations" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['status']['illustration']).to have_key('image')
- expect(json_response['status']['illustration']).to have_key('size')
- expect(json_response['status']['illustration']).to have_key('title')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["status"]["illustration"]).to have_key("image")
+ expect(json_response["status"]["illustration"]).to have_key("size")
+ expect(json_response["status"]["illustration"]).to have_key("title")
end
end
- context 'with no deployment' do
+ context "with no deployment" do
let(:job) { create(:ci_build, :success, pipeline: pipeline) }
- it 'does not exposes the deployment information' do
+ it "does not exposes the deployment information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['deployment_status']).to be_nil
+ expect(json_response["deployment_status"]).to be_nil
end
end
- context 'with deployment' do
+ context "with deployment" do
let(:merge_request) { create(:merge_request, source_project: project) }
- let(:environment) { create(:environment, project: project, name: 'staging', state: :available) }
+ let(:environment) { create(:environment, project: project, name: "staging", state: :available) }
let(:job) { create(:ci_build, :running, environment: environment.name, pipeline: pipeline) }
- it 'exposes the deployment information' do
+ it "exposes the deployment information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response).to match_schema('job/job_details')
- expect(json_response['deployment_status']["status"]).to eq 'creating'
- expect(json_response['deployment_status']["environment"]).not_to be_nil
+ expect(json_response).to match_schema("job/job_details")
+ expect(json_response["deployment_status"]["status"]).to eq "creating"
+ expect(json_response["deployment_status"]["environment"]).not_to be_nil
end
end
- context 'when user can edit runner' do
- context 'that belongs to the project' do
+ context "when user can edit runner" do
+ context "that belongs to the project" do
let(:runner) { create(:ci_runner, :project, projects: [project]) }
let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) }
@@ -253,14 +252,14 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
get_show(id: job.id, format: :json)
end
- it 'user can edit runner' do
+ it "user can edit runner" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runner']).to have_key('edit_path')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runner"]).to have_key("edit_path")
end
end
- context 'that belongs to group' do
+ context "that belongs to group" do
let(:group) { create(:group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) }
@@ -273,14 +272,14 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
get_show(id: job.id, format: :json)
end
- it 'user can not edit runner' do
+ it "user can not edit runner" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runner']).not_to have_key('edit_path')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runner"]).not_to have_key("edit_path")
end
end
- context 'that belongs to instance' do
+ context "that belongs to instance" do
let(:runner) { create(:ci_runner, :instance) }
let(:job) { create(:ci_build, :success, pipeline: pipeline, runner: runner) }
let(:user) { create(:user, :admin) }
@@ -292,50 +291,50 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
get_show(id: job.id, format: :json)
end
- it 'user can not edit runner' do
+ it "user can not edit runner" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runner']).not_to have_key('edit_path')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runner"]).not_to have_key("edit_path")
end
end
end
- context 'when no runners are available' do
+ context "when no runners are available" do
let(:runner) { create(:ci_runner, :instance, active: false) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
- it 'exposes needed information' do
+ it "exposes needed information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runners']['online']).to be false
- expect(json_response['runners']['available']).to be false
- expect(json_response['stuck']).to be true
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runners"]["online"]).to be false
+ expect(json_response["runners"]["available"]).to be false
+ expect(json_response["stuck"]).to be true
end
end
- context 'when no runner is online' do
+ context "when no runner is online" do
let(:runner) { create(:ci_runner, :instance) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
- it 'exposes needed information' do
+ it "exposes needed information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runners']['online']).to be false
- expect(json_response['runners']['available']).to be true
- expect(json_response['stuck']).to be true
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runners"]["online"]).to be false
+ expect(json_response["runners"]["available"]).to be true
+ expect(json_response["stuck"]).to be true
end
end
- context 'settings_path' do
- context 'when user is developer' do
- it 'settings_path is not available' do
+ context "settings_path" do
+ context "when user is developer" do
+ it "settings_path is not available" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runners']).not_to have_key('settings_path')
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runners"]).not_to have_key("settings_path")
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
let(:user) { create(:user, :admin) }
before do
@@ -343,36 +342,36 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
sign_in(user)
end
- it 'settings_path is available' do
+ it "settings_path is available" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['runners']['settings_path']).to match(/runners/)
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["runners"]["settings_path"]).to match(/runners/)
end
end
end
- context 'when no trace is available' do
- it 'has_trace is false' do
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['has_trace']).to be false
+ context "when no trace is available" do
+ it "has_trace is false" do
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["has_trace"]).to be false
end
end
- context 'when job has trace' do
+ context "when job has trace" do
let(:job) { create(:ci_build, :running, :trace_live, pipeline: pipeline) }
it "has_trace is true" do
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['has_trace']).to be true
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["has_trace"]).to be true
end
end
- it 'exposes the stage the job belongs to' do
- expect(json_response['stage']).to eq('test')
+ it "exposes the stage the job belongs to" do
+ expect(json_response["stage"]).to eq("test")
end
end
- context 'when requesting JSON job is triggered' do
+ context "when requesting JSON job is triggered" do
let!(:merge_request) { create(:merge_request, source_project: project) }
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, trigger: trigger) }
@@ -385,71 +384,71 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
allow_any_instance_of(Ci::Build).to receive(:merge_request).and_return(merge_request)
end
- context 'with no variables' do
+ context "with no variables" do
before do
get_show(id: job.id, format: :json)
end
- it 'exposes trigger information' do
+ it "exposes trigger information" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
- expect(json_response['trigger']['short_token']).to eq 'toke'
- expect(json_response['trigger']['variables'].length).to eq 0
+ expect(response).to match_response_schema("job/job_details")
+ expect(json_response["trigger"]["short_token"]).to eq "toke"
+ expect(json_response["trigger"]["variables"].length).to eq 0
end
end
- context 'with variables' do
+ context "with variables" do
before do
- create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: "TRIGGER_VALUE_1")
end
- context 'user is a maintainer' do
+ context "user is a maintainer" do
before do
project.add_maintainer(user)
get_show(id: job.id, format: :json)
end
- it 'returns a job_detail' do
+ it "returns a job_detail" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
+ expect(response).to match_response_schema("job/job_details")
end
- it 'exposes trigger information and variables' do
- expect(json_response['trigger']['short_token']).to eq 'toke'
- expect(json_response['trigger']['variables'].length).to eq 1
+ it "exposes trigger information and variables" do
+ expect(json_response["trigger"]["short_token"]).to eq "toke"
+ expect(json_response["trigger"]["variables"].length).to eq 1
end
- it 'exposes correct variable properties' do
- first_variable = json_response['trigger']['variables'].first
+ it "exposes correct variable properties" do
+ first_variable = json_response["trigger"]["variables"].first
- expect(first_variable['key']).to eq "TRIGGER_KEY_1"
- expect(first_variable['value']).to eq "TRIGGER_VALUE_1"
- expect(first_variable['public']).to eq false
+ expect(first_variable["key"]).to eq "TRIGGER_KEY_1"
+ expect(first_variable["value"]).to eq "TRIGGER_VALUE_1"
+ expect(first_variable["public"]).to eq false
end
end
- context 'user is not a mantainer' do
+ context "user is not a mantainer" do
before do
get_show(id: job.id, format: :json)
end
- it 'returns a job_detail' do
+ it "returns a job_detail" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('job/job_details')
+ expect(response).to match_response_schema("job/job_details")
end
- it 'exposes trigger information and variables' do
- expect(json_response['trigger']['short_token']).to eq 'toke'
- expect(json_response['trigger']['variables'].length).to eq 1
+ it "exposes trigger information and variables" do
+ expect(json_response["trigger"]["short_token"]).to eq "toke"
+ expect(json_response["trigger"]["variables"].length).to eq 1
end
- it 'exposes correct variable properties' do
- first_variable = json_response['trigger']['variables'].first
+ it "exposes correct variable properties" do
+ first_variable = json_response["trigger"]["variables"].first
- expect(first_variable['key']).to eq "TRIGGER_KEY_1"
- expect(first_variable['value']).to be_nil
- expect(first_variable['public']).to eq false
+ expect(first_variable["key"]).to eq "TRIGGER_KEY_1"
+ expect(first_variable["value"]).to be_nil
+ expect(first_variable["public"]).to eq false
end
end
end
@@ -458,65 +457,65 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def get_show(**extra_params)
params = {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
get :show, params: params.merge(extra_params)
end
end
- describe 'GET trace.json' do
+ describe "GET trace.json" do
before do
get_trace
end
- context 'when job has a trace artifact' do
+ context "when job has a trace artifact" do
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
- it 'returns a trace' do
+ it "returns a trace" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to eq job.id
- expect(json_response['status']).to eq job.status
- expect(json_response['html']).to eq(job.trace.html)
+ expect(json_response["id"]).to eq job.id
+ expect(json_response["status"]).to eq job.status
+ expect(json_response["html"]).to eq(job.trace.html)
end
end
- context 'when job has a trace' do
+ context "when job has a trace" do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
- it 'returns a trace' do
+ it "returns a trace" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to eq job.id
- expect(json_response['status']).to eq job.status
- expect(json_response['html']).to eq('BUILD TRACE')
+ expect(json_response["id"]).to eq job.id
+ expect(json_response["status"]).to eq job.status
+ expect(json_response["html"]).to eq("BUILD TRACE")
end
end
- context 'when job has no traces' do
+ context "when job has no traces" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'returns no traces' do
+ it "returns no traces" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to eq job.id
- expect(json_response['status']).to eq job.status
- expect(json_response['html']).to be_nil
+ expect(json_response["id"]).to eq job.id
+ expect(json_response["status"]).to eq job.status
+ expect(json_response["html"]).to be_nil
end
end
- context 'when job has a trace with ANSI sequence and Unicode' do
+ context "when job has a trace with ANSI sequence and Unicode" do
let(:job) { create(:ci_build, :unicode_trace_live, pipeline: pipeline) }
- it 'returns a trace with Unicode' do
+ it "returns a trace with Unicode" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to eq job.id
- expect(json_response['status']).to eq job.status
- expect(json_response['html']).to include("ヾ(´༎ຶД༎ຶ`)ノ")
+ expect(json_response["id"]).to eq job.id
+ expect(json_response["status"]).to eq job.status
+ expect(json_response["html"]).to include("ヾ(´༎ຶД༎ຶ`)ノ")
end
end
- context 'when trace artifact is in ObjectStorage' do
- let(:url) { 'http://object-storage/trace' }
- let(:file_path) { expand_fixture_path('trace/sample_trace') }
+ context "when trace artifact is in ObjectStorage" do
+ let(:url) { "http://object-storage/trace" }
+ let(:file_path) { expand_fixture_path("trace/sample_trace") }
let!(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) }
before do
@@ -525,27 +524,27 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
end
- context 'when there are no network issues' do
+ context "when there are no network issues" do
before do
stub_remote_url_206(url, file_path)
get_trace
end
- it 'returns a trace' do
+ it "returns a trace" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to eq job.id
- expect(json_response['status']).to eq job.status
- expect(json_response['html']).to eq(job.trace.html)
+ expect(json_response["id"]).to eq job.id
+ expect(json_response["status"]).to eq job.status
+ expect(json_response["html"]).to eq(job.trace.html)
end
end
- context 'when there is a network issue' do
+ context "when there is a network issue" do
before do
stub_remote_url_500(url)
end
- it 'returns a trace' do
+ it "returns a trace" do
expect { get_trace }.to raise_error(Gitlab::HttpIO::FailedToGetChunkError)
end
end
@@ -553,37 +552,37 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def get_trace
get :trace, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ },
format: :json
end
end
- describe 'GET status.json' do
+ describe "GET status.json" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- let(:status) { job.detailed_status(double('user')) }
+ let(:status) { job.detailed_status(double("user")) }
before do
get :status, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ },
format: :json
end
- it 'return a detailed job status in json' do
+ it "return a detailed job status in json" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['text']).to eq status.text
- expect(json_response['label']).to eq status.label
- expect(json_response['icon']).to eq status.icon
- expect(json_response['favicon']).to match_asset_path "/assets/ci_favicons/#{status.favicon}.png"
+ expect(json_response["text"]).to eq status.text
+ expect(json_response["label"]).to eq status.label
+ expect(json_response["icon"]).to eq status.icon
+ expect(json_response["favicon"]).to match_asset_path "/assets/ci_favicons/#{status.favicon}.png"
end
end
- describe 'POST retry' do
+ describe "POST retry" do
before do
project.add_developer(user)
sign_in(user)
@@ -591,186 +590,186 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
post_retry
end
- context 'when job is retryable' do
+ context "when job is retryable" do
let(:job) { create(:ci_build, :retryable, pipeline: pipeline) }
- it 'redirects to the retried job page' do
+ it "redirects to the retried job page" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: Ci::Build.last.id))
end
end
- context 'when job is not retryable' do
+ context "when job is not retryable" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'renders unprocessable_entity' do
+ it "renders unprocessable_entity" do
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
def post_retry
post :retry, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ }
end
end
- describe 'POST play' do
+ describe "POST play" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
+ name: "master", project: project)
sign_in(user)
post_play
end
- context 'when job is playable' do
+ context "when job is playable" do
let(:job) { create(:ci_build, :playable, pipeline: pipeline) }
- it 'redirects to the played job page' do
+ it "redirects to the played job page" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end
- it 'transits to pending' do
+ it "transits to pending" do
expect(job.reload).to be_pending
end
end
- context 'when job is not playable' do
+ context "when job is not playable" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'renders unprocessable_entity' do
+ it "renders unprocessable_entity" do
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
def post_play
post :play, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ }
end
end
- describe 'POST cancel' do
+ describe "POST cancel" do
before do
project.add_developer(user)
sign_in(user)
end
- context 'when continue url is present' do
+ context "when continue url is present" do
let(:job) { create(:ci_build, :cancelable, pipeline: pipeline) }
- context 'when continue to is a safe url' do
- let(:url) { '/test' }
+ context "when continue to is a safe url" do
+ let(:url) { "/test" }
before do
- post_cancel(continue: { to: url })
+ post_cancel(continue: {to: url})
end
- it 'redirects to the continue url' do
+ it "redirects to the continue url" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(url)
end
- it 'transits to canceled' do
+ it "transits to canceled" do
expect(job.reload).to be_canceled
end
end
- context 'when continue to is not a safe url' do
- let(:url) { 'http://example.com' }
+ context "when continue to is not a safe url" do
+ let(:url) { "http://example.com" }
- it 'raises an error' do
+ it "raises an error" do
expect { cancel_with_redirect(url) }.to raise_error
end
end
end
- context 'when continue url is not present' do
+ context "when continue url is not present" do
before do
post_cancel
end
- context 'when job is cancelable' do
+ context "when job is cancelable" do
let(:job) { create(:ci_build, :cancelable, pipeline: pipeline) }
- it 'redirects to the builds page' do
+ it "redirects to the builds page" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(builds_namespace_project_pipeline_path(id: pipeline.id))
end
- it 'transits to canceled' do
+ it "transits to canceled" do
expect(job.reload).to be_canceled
end
end
- context 'when job is not cancelable' do
+ context "when job is not cancelable" do
let(:job) { create(:ci_build, :canceled, pipeline: pipeline) }
- it 'returns unprocessable_entity' do
+ it "returns unprocessable_entity" do
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
end
def post_cancel(additional_params = {})
- post :cancel, params: { namespace_id: project.namespace,
- project_id: project,
- id: job.id }.merge(additional_params)
+ post :cancel, params: {namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,}.merge(additional_params)
end
end
- describe 'POST unschedule' do
+ describe "POST unschedule" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
+ name: "master", project: project)
sign_in(user)
post_unschedule
end
- context 'when job is scheduled' do
+ context "when job is scheduled" do
let(:job) { create(:ci_build, :scheduled, pipeline: pipeline) }
- it 'redirects to the unscheduled job page' do
+ it "redirects to the unscheduled job page" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end
- it 'transits to manual' do
+ it "transits to manual" do
expect(job.reload).to be_manual
end
end
- context 'when job is not scheduled' do
+ context "when job is not scheduled" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'renders unprocessable_entity' do
+ it "renders unprocessable_entity" do
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
def post_unschedule
post :unschedule, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ }
end
end
- describe 'POST erase' do
+ describe "POST erase" do
let(:role) { :maintainer }
before do
@@ -780,48 +779,48 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
post_erase
end
- context 'when job is erasable' do
+ context "when job is erasable" do
let(:job) { create(:ci_build, :erasable, :trace_artifact, pipeline: pipeline) }
- it 'redirects to the erased job page' do
+ it "redirects to the erased job page" do
expect(response).to have_gitlab_http_status(:found)
expect(response).to redirect_to(namespace_project_job_path(id: job.id))
end
- it 'erases artifacts' do
+ it "erases artifacts" do
expect(job.artifacts_file.exists?).to be_falsey
expect(job.artifacts_metadata.exists?).to be_falsey
end
- it 'erases trace' do
+ it "erases trace" do
expect(job.trace.exist?).to be_falsey
end
end
- context 'when job is not erasable' do
+ context "when job is not erasable" do
let(:job) { create(:ci_build, :erased, pipeline: pipeline) }
- it 'returns unprocessable_entity' do
+ it "returns unprocessable_entity" do
expect(response).to have_gitlab_http_status(:unprocessable_entity)
end
end
- context 'when user is developer' do
+ context "when user is developer" do
let(:role) { :developer }
let(:job) { create(:ci_build, :erasable, :trace_artifact, pipeline: pipeline, user: triggered_by) }
- context 'when triggered by same user' do
+ context "when triggered by same user" do
let(:triggered_by) { user }
- it 'has successful status' do
+ it "has successful status" do
expect(response).to have_gitlab_http_status(:found)
end
end
- context 'when triggered by different user' do
+ context "when triggered by different user" do
let(:triggered_by) { create(:user) }
- it 'does not have successful status' do
+ it "does not have successful status" do
expect(response).not_to have_gitlab_http_status(:found)
end
end
@@ -829,20 +828,20 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def post_erase
post :erase, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ }
end
end
- describe 'GET raw' do
+ describe "GET raw" do
subject do
post :raw, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: job.id
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: job.id,
+ }
end
context "when job has a trace artifact" do
@@ -861,7 +860,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
context "when job has a trace file" do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
- it 'sends a trace file' do
+ it "sends a trace file" do
response = subject
expect(response).to have_gitlab_http_status(:ok)
@@ -878,65 +877,65 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
job.update_column(:trace, "Sample trace")
end
- it 'sends a trace file' do
+ it "sends a trace file" do
response = subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(response.headers['Content-Disposition']).to match(/^inline/)
- expect(response.body).to eq('Sample trace')
+ expect(response.headers["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(response.headers["Content-Disposition"]).to match(/^inline/)
+ expect(response.body).to eq("Sample trace")
end
- context 'when trace format is not text/plain' do
+ context "when trace format is not text/plain" do
before do
- job.update_column(:trace, '<html></html>')
+ job.update_column(:trace, "<html></html>")
end
- it 'sets content disposition to attachment' do
+ it "sets content disposition to attachment" do
response = subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response.headers['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(response.headers['Content-Disposition']).to match(/^attachment/)
+ expect(response.headers["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(response.headers["Content-Disposition"]).to match(/^attachment/)
end
end
end
- context 'when job does not have a trace file' do
+ context "when job does not have a trace file" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'returns not_found' do
+ it "returns not_found" do
response = subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response.body).to eq ''
+ expect(response.body).to eq ""
end
end
- context 'when the trace artifact is in ObjectStorage' do
+ context "when the trace artifact is in ObjectStorage" do
let!(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
before do
allow_any_instance_of(JobArtifactUploader).to receive(:file_storage?) { false }
end
- it 'redirect to the trace file url' do
+ it "redirect to the trace file url" do
expect(subject).to redirect_to(job.job_artifacts_trace.file.url)
end
end
end
- describe 'GET #terminal' do
+ describe "GET #terminal" do
before do
project.add_developer(user)
sign_in(user)
end
- context 'when job exists' do
- context 'and it has a terminal' do
+ context "when job exists" do
+ context "and it has a terminal" do
let!(:job) { create(:ci_build, :running, :with_runner_session, pipeline: pipeline) }
- it 'has a job' do
+ it "has a job" do
get_terminal(id: job.id)
expect(response).to have_gitlab_http_status(:ok)
@@ -944,10 +943,10 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'and does not have a terminal' do
+ context "and does not have a terminal" do
let!(:job) { create(:ci_build, :running, pipeline: pipeline) }
- it 'returns not_found' do
+ it "returns not_found" do
get_terminal(id: job.id)
expect(response).to have_gitlab_http_status(:not_found)
@@ -955,8 +954,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'when job does not exist' do
- it 'renders not_found' do
+ context "when job does not exist" do
+ it "renders not_found" do
get_terminal(id: 1234)
expect(response).to have_gitlab_http_status(:not_found)
@@ -966,14 +965,14 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def get_terminal(**extra_params)
params = {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
get :terminal, params: params.merge(extra_params)
end
end
- describe 'GET #terminal_websocket_authorize' do
+ describe "GET #terminal_websocket_authorize" do
let!(:job) { create(:ci_build, :running, :with_runner_session, pipeline: pipeline) }
before do
@@ -981,13 +980,13 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
sign_in(user)
end
- context 'with valid workhorse signature' do
+ context "with valid workhorse signature" do
before do
allow(Gitlab::Workhorse).to receive(:verify_api_request!).and_return(nil)
end
- context 'and valid id' do
- it 'returns the terminal for the job' do
+ context "and valid id" do
+ it "returns the terminal for the job" do
expect(Gitlab::Workhorse)
.to receive(:terminal_websocket)
.and_return(workhorse: :response)
@@ -1000,8 +999,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'and invalid id' do
- it 'returns 404' do
+ context "and invalid id" do
+ it "returns 404" do
get_terminal_websocket(id: 1234)
expect(response).to have_gitlab_http_status(404)
@@ -1009,8 +1008,8 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
end
end
- context 'with invalid workhorse signature' do
- it 'aborts with an exception' do
+ context "with invalid workhorse signature" do
+ it "aborts with an exception" do
allow(Gitlab::Workhorse).to receive(:verify_api_request!).and_raise(JWT::DecodeError)
expect { get_terminal_websocket(id: job.id) }.to raise_error(JWT::DecodeError)
@@ -1020,7 +1019,7 @@ describe Projects::JobsController, :clean_gitlab_redis_shared_state do
def get_terminal_websocket(**extra_params)
params = {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
get :terminal_websocket_authorize, params: params.merge(extra_params)
diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb
index 32897a0f1b4..c9437b9ae5c 100644
--- a/spec/controllers/projects/labels_controller_spec.rb
+++ b/spec/controllers/projects/labels_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::LabelsController do
let(:group) { create(:group) }
@@ -11,53 +11,53 @@ describe Projects::LabelsController do
sign_in(user)
end
- describe 'GET #index' do
- let!(:label_1) { create(:label, project: project, priority: 1, title: 'Label 1') }
- let!(:label_2) { create(:label, project: project, priority: 3, title: 'Label 2') }
- let!(:label_3) { create(:label, project: project, priority: 1, title: 'Label 3') }
- let!(:label_4) { create(:label, project: project, title: 'Label 4') }
- let!(:label_5) { create(:label, project: project, title: 'Label 5') }
+ describe "GET #index" do
+ let!(:label_1) { create(:label, project: project, priority: 1, title: "Label 1") }
+ let!(:label_2) { create(:label, project: project, priority: 3, title: "Label 2") }
+ let!(:label_3) { create(:label, project: project, priority: 1, title: "Label 3") }
+ let!(:label_4) { create(:label, project: project, title: "Label 4") }
+ let!(:label_5) { create(:label, project: project, title: "Label 5") }
- let!(:group_label_1) { create(:group_label, group: group, title: 'Group Label 1') }
- let!(:group_label_2) { create(:group_label, group: group, title: 'Group Label 2') }
- let!(:group_label_3) { create(:group_label, group: group, title: 'Group Label 3') }
- let!(:group_label_4) { create(:group_label, group: group, title: 'Group Label 4') }
+ let!(:group_label_1) { create(:group_label, group: group, title: "Group Label 1") }
+ let!(:group_label_2) { create(:group_label, group: group, title: "Group Label 2") }
+ let!(:group_label_3) { create(:group_label, group: group, title: "Group Label 3") }
+ let!(:group_label_4) { create(:group_label, group: group, title: "Group Label 4") }
before do
create(:label_priority, project: project, label: group_label_1, priority: 3)
create(:label_priority, project: project, label: group_label_2, priority: 1)
end
- context '@prioritized_labels' do
+ context "@prioritized_labels" do
before do
list_labels
end
- it 'does not include labels without priority' do
+ it "does not include labels without priority" do
list_labels
expect(assigns(:prioritized_labels)).not_to include(group_label_3, group_label_4, label_4, label_5)
end
- it 'is sorted by priority, then label title' do
+ it "is sorted by priority, then label title" do
expect(assigns(:prioritized_labels)).to eq [group_label_2, label_1, label_3, group_label_1, label_2]
end
end
- context '@labels' do
- it 'is sorted by label title' do
+ context "@labels" do
+ it "is sorted by label title" do
list_labels
expect(assigns(:labels)).to eq [group_label_3, group_label_4, label_4, label_5]
end
- it 'does not include labels with priority' do
+ it "does not include labels with priority" do
list_labels
expect(assigns(:labels)).not_to include(group_label_2, label_1, label_3, group_label_1, label_2)
end
- it 'does not include group labels when project does not belong to a group' do
+ it "does not include group labels when project does not belong to a group" do
project.update(namespace: create(:namespace))
list_labels
@@ -67,32 +67,32 @@ describe Projects::LabelsController do
end
def list_labels
- get :index, params: { namespace_id: project.namespace.to_param, project_id: project }
+ get :index, params: {namespace_id: project.namespace.to_param, project_id: project}
end
end
- describe 'POST #generate' do
- context 'personal project' do
+ describe "POST #generate" do
+ context "personal project" do
let(:personal_project) { create(:project, namespace: user.namespace) }
- it 'creates labels' do
- post :generate, params: { namespace_id: personal_project.namespace.to_param, project_id: personal_project }
+ it "creates labels" do
+ post :generate, params: {namespace_id: personal_project.namespace.to_param, project_id: personal_project}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'project belonging to a group' do
- it 'creates labels' do
- post :generate, params: { namespace_id: project.namespace.to_param, project_id: project }
+ context "project belonging to a group" do
+ it "creates labels" do
+ post :generate, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to have_gitlab_http_status(302)
end
end
end
- describe 'POST #toggle_subscription' do
- it 'allows user to toggle subscription on project labels' do
+ describe "POST #toggle_subscription" do
+ it "allows user to toggle subscription on project labels" do
label = create(:label, project: project)
toggle_subscription(label)
@@ -100,7 +100,7 @@ describe Projects::LabelsController do
expect(response).to have_gitlab_http_status(200)
end
- it 'allows user to toggle subscription on group labels' do
+ it "allows user to toggle subscription on group labels" do
group_label = create(:group_label, group: group)
toggle_subscription(group_label)
@@ -109,82 +109,82 @@ describe Projects::LabelsController do
end
def toggle_subscription(label)
- post :toggle_subscription, params: { namespace_id: project.namespace.to_param, project_id: project, id: label.to_param }
+ post :toggle_subscription, params: {namespace_id: project.namespace.to_param, project_id: project, id: label.to_param}
end
end
- describe 'POST #promote' do
+ describe "POST #promote" do
let!(:promoted_label_name) { "Promoted Label" }
let!(:label_1) { create(:label, title: promoted_label_name, project: project) }
- context 'not group reporters' do
- it 'denies access' do
- post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
+ context "not group reporters" do
+ it "denies access" do
+ post :promote, params: {namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'group reporter' do
+ context "group reporter" do
before do
group.add_reporter(user)
end
- it 'gives access' do
- post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
+ it "gives access" do
+ post :promote, params: {namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param}
expect(response).to redirect_to(namespace_project_labels_path)
end
- it 'promotes the label' do
- post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
+ it "promotes the label" do
+ post :promote, params: {namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param}
expect(Label.where(id: label_1.id)).to be_empty
expect(GroupLabel.find_by(title: promoted_label_name)).not_to be_nil
end
- it 'renders label name without parsing it as HTML' do
- label_1.update!(name: 'CCC&lt;img src=x onerror=alert(document.domain)&gt;')
+ it "renders label name without parsing it as HTML" do
+ label_1.update!(name: "CCC&lt;img src=x onerror=alert(document.domain)&gt;")
- post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
+ post :promote, params: {namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param}
expect(flash[:notice]).to eq("CCC&lt;img src=x onerror=alert(document.domain)&gt; promoted to <a href=\"#{group_labels_path(project.group)}\"><u>group label</u></a>.")
end
- context 'service raising InvalidRecord' do
+ context "service raising InvalidRecord" do
before do
expect_any_instance_of(Labels::PromoteService).to receive(:execute) do |label|
raise ActiveRecord::RecordInvalid.new(label_1)
end
end
- it 'returns to label list' do
- post :promote, params: { namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param }
+ it "returns to label list" do
+ post :promote, params: {namespace_id: project.namespace.to_param, project_id: project, id: label_1.to_param}
expect(response).to redirect_to(namespace_project_labels_path)
end
end
end
end
- describe '#ensure_canonical_path' do
+ describe "#ensure_canonical_path" do
before do
sign_in(user)
end
- context 'for a GET request' do
- context 'when requesting the canonical path' do
- context 'non-show path' do
- context 'with exactly matching casing' do
- it 'does not redirect' do
- get :index, params: { namespace_id: project.namespace, project_id: project.to_param }
+ context "for a GET request" do
+ context "when requesting the canonical path" do
+ context "non-show path" do
+ context "with exactly matching casing" do
+ it "does not redirect" do
+ get :index, params: {namespace_id: project.namespace, project_id: project.to_param}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :index, params: { namespace_id: project.namespace, project_id: project.to_param.upcase }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :index, params: {namespace_id: project.namespace, project_id: project.to_param.upcase}
expect(response).to redirect_to(project_labels_path(project))
expect(controller).not_to set_flash[:notice]
@@ -193,11 +193,11 @@ describe Projects::LabelsController do
end
end
- context 'when requesting a redirected path' do
- let!(:redirect_route) { project.redirect_routes.create(path: project.full_path + 'old') }
+ context "when requesting a redirected path" do
+ let!(:redirect_route) { project.redirect_routes.create(path: project.full_path + "old") }
- it 'redirects to the canonical path' do
- get :index, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }
+ it "redirects to the canonical path" do
+ get :index, params: {namespace_id: project.namespace, project_id: project.to_param + "old"}
expect(response).to redirect_to(project_labels_path(project))
expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, project))
@@ -206,26 +206,26 @@ describe Projects::LabelsController do
end
end
- context 'for a non-GET request' do
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
- post :generate, params: { namespace_id: project.namespace, project_id: project }
+ context "for a non-GET request" do
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
+ post :generate, params: {namespace_id: project.namespace, project_id: project}
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
- post :generate, params: { namespace_id: project.namespace, project_id: project }
+ it "does not redirect to the correct casing" do
+ post :generate, params: {namespace_id: project.namespace, project_id: project}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
- let!(:redirect_route) { project.redirect_routes.create(path: project.full_path + 'old') }
+ context "when requesting a redirected path" do
+ let!(:redirect_route) { project.redirect_routes.create(path: project.full_path + "old") }
- it 'returns not found' do
- post :generate, params: { namespace_id: project.namespace, project_id: project.to_param + 'old' }
+ it "returns not found" do
+ post :generate, params: {namespace_id: project.namespace, project_id: project.to_param + "old"}
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb
index 6c8c7cd8f2b..603a2e4f334 100644
--- a/spec/controllers/projects/mattermosts_controller_spec.rb
+++ b/spec/controllers/projects/mattermosts_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MattermostsController do
let!(:project) { create(:project) }
@@ -9,49 +9,49 @@ describe Projects::MattermostsController do
sign_in(user)
end
- describe 'GET #new' do
+ describe "GET #new" do
before do
allow_any_instance_of(MattermostSlashCommandsService)
.to receive(:list_teams).and_return([])
end
- it 'accepts the request' do
+ it "accepts the request" do
get(:new,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project
- })
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ })
expect(response).to have_gitlab_http_status(200)
end
end
- describe 'POST #create' do
- let(:mattermost_params) { { trigger: 'http://localhost:3000/trigger', team_id: 'abc' } }
+ describe "POST #create" do
+ let(:mattermost_params) { {trigger: "http://localhost:3000/trigger", team_id: "abc"} }
subject do
post(:create,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- mattermost: mattermost_params
- })
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ mattermost: mattermost_params,
+ })
end
- context 'no request can be made to mattermost' do
- it 'shows the error' do
+ context "no request can be made to mattermost" do
+ it "shows the error" do
allow_any_instance_of(MattermostSlashCommandsService).to receive(:configure).and_return([false, "error message"])
expect(subject).to redirect_to(new_project_mattermost_url(project))
end
end
- context 'the request is succesull' do
+ context "the request is succesull" do
before do
- allow_any_instance_of(Mattermost::Command).to receive(:create).and_return('token')
+ allow_any_instance_of(Mattermost::Command).to receive(:create).and_return("token")
end
- it 'redirects to the new page' do
+ it "redirects to the new page" do
subject
service = project.services.last
diff --git a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
index 039f35875d2..3dcdad347ef 100644
--- a/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/conflicts_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MergeRequests::ConflictsController do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_with_conflicts) do
- create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr|
+ create(:merge_request, source_branch: "conflict-resolvable", target_branch: "conflict-start", source_project: project, merge_status: :unchecked) do |mr|
mr.mark_as_unmergeable
end
end
@@ -14,75 +14,75 @@ describe Projects::MergeRequests::ConflictsController do
sign_in(user)
end
- describe 'GET show' do
- context 'when the conflicts cannot be resolved in the UI' do
+ describe "GET show" do
+ context "when the conflicts cannot be resolved in the UI" do
before do
allow(Gitlab::Git::Conflict::Parser).to receive(:parse)
.and_raise(Gitlab::Git::Conflict::Parser::UnmergeableFile)
get :show,
- params: {
- namespace_id: merge_request_with_conflicts.project.namespace.to_param,
- project_id: merge_request_with_conflicts.project,
- id: merge_request_with_conflicts.iid
- },
- format: 'json'
+ params: {
+ namespace_id: merge_request_with_conflicts.project.namespace.to_param,
+ project_id: merge_request_with_conflicts.project,
+ id: merge_request_with_conflicts.iid,
+ },
+ format: "json"
end
- it 'returns a 200 status code' do
+ it "returns a 200 status code" do
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns JSON with a message' do
- expect(json_response.keys).to contain_exactly('message', 'type')
+ it "returns JSON with a message" do
+ expect(json_response.keys).to contain_exactly("message", "type")
end
end
- context 'with valid conflicts' do
+ context "with valid conflicts" do
before do
get :show,
- params: {
- namespace_id: merge_request_with_conflicts.project.namespace.to_param,
- project_id: merge_request_with_conflicts.project,
- id: merge_request_with_conflicts.iid
- },
- format: 'json'
+ params: {
+ namespace_id: merge_request_with_conflicts.project.namespace.to_param,
+ project_id: merge_request_with_conflicts.project,
+ id: merge_request_with_conflicts.iid,
+ },
+ format: "json"
end
- it 'matches the schema' do
- expect(response).to match_response_schema('conflicts')
+ it "matches the schema" do
+ expect(response).to match_response_schema("conflicts")
end
- it 'includes meta info about the MR' do
- expect(json_response['commit_message']).to include('Merge branch')
- expect(json_response['commit_sha']).to match(/\h{40}/)
- expect(json_response['source_branch']).to eq(merge_request_with_conflicts.source_branch)
- expect(json_response['target_branch']).to eq(merge_request_with_conflicts.target_branch)
+ it "includes meta info about the MR" do
+ expect(json_response["commit_message"]).to include("Merge branch")
+ expect(json_response["commit_sha"]).to match(/\h{40}/)
+ expect(json_response["source_branch"]).to eq(merge_request_with_conflicts.source_branch)
+ expect(json_response["target_branch"]).to eq(merge_request_with_conflicts.target_branch)
end
- it 'includes each file that has conflicts' do
- filenames = json_response['files'].map { |file| file['new_path'] }
+ it "includes each file that has conflicts" do
+ filenames = json_response["files"].map { |file| file["new_path"] }
- expect(filenames).to contain_exactly('files/ruby/popen.rb', 'files/ruby/regex.rb')
+ expect(filenames).to contain_exactly("files/ruby/popen.rb", "files/ruby/regex.rb")
end
- it 'splits files into sections with lines' do
- json_response['files'].each do |file|
- file['sections'].each do |section|
- expect(section).to include('conflict', 'lines')
+ it "splits files into sections with lines" do
+ json_response["files"].each do |file|
+ file["sections"].each do |section|
+ expect(section).to include("conflict", "lines")
- section['lines'].each do |line|
- if section['conflict']
- expect(line['type']).to be_in(%w(old new))
- expect(line.values_at('old_line', 'new_line')).to contain_exactly(nil, a_kind_of(Integer))
+ section["lines"].each do |line|
+ if section["conflict"]
+ expect(line["type"]).to be_in(%w[old new])
+ expect(line.values_at("old_line", "new_line")).to contain_exactly(nil, a_kind_of(Integer))
else
- if line['type'].nil?
- expect(line['old_line']).not_to eq(nil)
- expect(line['new_line']).not_to eq(nil)
+ if line["type"].nil?
+ expect(line["old_line"]).not_to eq(nil)
+ expect(line["new_line"]).not_to eq(nil)
else
- expect(line['type']).to eq('match')
- expect(line['old_line']).to eq(nil)
- expect(line['new_line']).to eq(nil)
+ expect(line["type"]).to eq("match")
+ expect(line["old_line"]).to eq(nil)
+ expect(line["new_line"]).to eq(nil)
end
end
end
@@ -90,223 +90,223 @@ describe Projects::MergeRequests::ConflictsController do
end
end
- it 'has unique section IDs across files' do
- section_ids = json_response['files'].flat_map do |file|
- file['sections'].map { |section| section['id'] }.compact
- end
+ it "has unique section IDs across files" do
+ section_ids = json_response["files"].flat_map { |file|
+ file["sections"].map { |section| section["id"] }.compact
+ }
expect(section_ids.uniq).to eq(section_ids)
end
end
end
- describe 'GET conflict_for_path' do
+ describe "GET conflict_for_path" do
def conflict_for_path(path)
get :conflict_for_path,
- params: {
- namespace_id: merge_request_with_conflicts.project.namespace.to_param,
- project_id: merge_request_with_conflicts.project,
- id: merge_request_with_conflicts.iid,
- old_path: path,
- new_path: path
- },
- format: 'json'
+ params: {
+ namespace_id: merge_request_with_conflicts.project.namespace.to_param,
+ project_id: merge_request_with_conflicts.project,
+ id: merge_request_with_conflicts.iid,
+ old_path: path,
+ new_path: path,
+ },
+ format: "json"
end
- context 'when the conflicts cannot be resolved in the UI' do
+ context "when the conflicts cannot be resolved in the UI" do
before do
allow(Gitlab::Git::Conflict::Parser).to receive(:parse)
.and_raise(Gitlab::Git::Conflict::Parser::UnmergeableFile)
- conflict_for_path('files/ruby/regex.rb')
+ conflict_for_path("files/ruby/regex.rb")
end
- it 'returns a 404 status code' do
+ it "returns a 404 status code" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'when the file does not exist cannot be resolved in the UI' do
+ context "when the file does not exist cannot be resolved in the UI" do
before do
- conflict_for_path('files/ruby/regexp.rb')
+ conflict_for_path("files/ruby/regexp.rb")
end
- it 'returns a 404 status code' do
+ it "returns a 404 status code" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'with an existing file' do
- let(:path) { 'files/ruby/regex.rb' }
+ context "with an existing file" do
+ let(:path) { "files/ruby/regex.rb" }
before do
conflict_for_path(path)
end
- it 'returns a 200 status code' do
+ it "returns a 200 status code" do
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns the file in JSON format' do
+ it "returns the file in JSON format" do
content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts)
- .file_for_path(path, path)
- .content
-
- expect(json_response).to include('old_path' => path,
- 'new_path' => path,
- 'blob_icon' => 'file-text-o',
- 'blob_path' => a_string_ending_with(path),
- 'content' => content)
+ .file_for_path(path, path)
+ .content
+
+ expect(json_response).to include("old_path" => path,
+ "new_path" => path,
+ "blob_icon" => "file-text-o",
+ "blob_path" => a_string_ending_with(path),
+ "content" => content)
end
end
end
- context 'POST resolve_conflicts' do
+ context "POST resolve_conflicts" do
let!(:original_head_sha) { merge_request_with_conflicts.diff_head_sha }
def resolve_conflicts(files)
post :resolve_conflicts,
- params: {
- namespace_id: merge_request_with_conflicts.project.namespace.to_param,
- project_id: merge_request_with_conflicts.project,
- id: merge_request_with_conflicts.iid,
- files: files,
- commit_message: 'Commit message'
- },
- format: 'json'
+ params: {
+ namespace_id: merge_request_with_conflicts.project.namespace.to_param,
+ project_id: merge_request_with_conflicts.project,
+ id: merge_request_with_conflicts.iid,
+ files: files,
+ commit_message: "Commit message",
+ },
+ format: "json"
end
- context 'with valid params' do
+ context "with valid params" do
before do
resolved_files = [
{
- 'new_path' => 'files/ruby/popen.rb',
- 'old_path' => 'files/ruby/popen.rb',
- 'sections' => {
- '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14' => 'head'
- }
+ "new_path" => "files/ruby/popen.rb",
+ "old_path" => "files/ruby/popen.rb",
+ "sections" => {
+ "2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14" => "head",
+ },
}, {
- 'new_path' => 'files/ruby/regex.rb',
- 'old_path' => 'files/ruby/regex.rb',
- 'sections' => {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21' => 'origin',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49' => 'origin'
- }
- }
+ "new_path" => "files/ruby/regex.rb",
+ "old_path" => "files/ruby/regex.rb",
+ "sections" => {
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21" => "origin",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49" => "origin",
+ },
+ },
]
resolve_conflicts(resolved_files)
end
- it 'creates a new commit on the branch' do
+ it "creates a new commit on the branch" do
expect(original_head_sha).not_to eq(merge_request_with_conflicts.source_branch_head.sha)
- expect(merge_request_with_conflicts.source_branch_head.message).to include('Commit message')
+ expect(merge_request_with_conflicts.source_branch_head.message).to include("Commit message")
end
- it 'returns an OK response' do
+ it "returns an OK response" do
expect(response).to have_gitlab_http_status(:ok)
end
end
- context 'when sections are missing' do
+ context "when sections are missing" do
before do
resolved_files = [
{
- 'new_path' => 'files/ruby/popen.rb',
- 'old_path' => 'files/ruby/popen.rb',
- 'sections' => {
- '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14' => 'head'
- }
+ "new_path" => "files/ruby/popen.rb",
+ "old_path" => "files/ruby/popen.rb",
+ "sections" => {
+ "2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14" => "head",
+ },
}, {
- 'new_path' => 'files/ruby/regex.rb',
- 'old_path' => 'files/ruby/regex.rb',
- 'sections' => {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head'
- }
- }
+ "new_path" => "files/ruby/regex.rb",
+ "old_path" => "files/ruby/regex.rb",
+ "sections" => {
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ },
+ },
]
resolve_conflicts(resolved_files)
end
- it 'returns a 400 error' do
+ it "returns a 400 error" do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'has a message with the name of the first missing section' do
- expect(json_response['message']).to include('6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21')
+ it "has a message with the name of the first missing section" do
+ expect(json_response["message"]).to include("6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21")
end
- it 'does not create a new commit' do
+ it "does not create a new commit" do
expect(original_head_sha).to eq(merge_request_with_conflicts.source_branch_head.sha)
end
end
- context 'when files are missing' do
+ context "when files are missing" do
before do
resolved_files = [
{
- 'new_path' => 'files/ruby/regex.rb',
- 'old_path' => 'files/ruby/regex.rb',
- 'sections' => {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21' => 'origin',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49' => 'origin'
- }
- }
+ "new_path" => "files/ruby/regex.rb",
+ "old_path" => "files/ruby/regex.rb",
+ "sections" => {
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21" => "origin",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49" => "origin",
+ },
+ },
]
resolve_conflicts(resolved_files)
end
- it 'returns a 400 error' do
+ it "returns a 400 error" do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'has a message with the name of the missing file' do
- expect(json_response['message']).to include('files/ruby/popen.rb')
+ it "has a message with the name of the missing file" do
+ expect(json_response["message"]).to include("files/ruby/popen.rb")
end
- it 'does not create a new commit' do
+ it "does not create a new commit" do
expect(original_head_sha).to eq(merge_request_with_conflicts.source_branch_head.sha)
end
end
- context 'when a file has identical content to the conflict' do
+ context "when a file has identical content to the conflict" do
before do
content = MergeRequests::Conflicts::ListService.new(merge_request_with_conflicts)
- .file_for_path('files/ruby/popen.rb', 'files/ruby/popen.rb')
- .content
+ .file_for_path("files/ruby/popen.rb", "files/ruby/popen.rb")
+ .content
resolved_files = [
{
- 'new_path' => 'files/ruby/popen.rb',
- 'old_path' => 'files/ruby/popen.rb',
- 'content' => content
+ "new_path" => "files/ruby/popen.rb",
+ "old_path" => "files/ruby/popen.rb",
+ "content" => content,
}, {
- 'new_path' => 'files/ruby/regex.rb',
- 'old_path' => 'files/ruby/regex.rb',
- 'sections' => {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21' => 'origin',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49' => 'origin'
- }
- }
+ "new_path" => "files/ruby/regex.rb",
+ "old_path" => "files/ruby/regex.rb",
+ "sections" => {
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21" => "origin",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49" => "origin",
+ },
+ },
]
resolve_conflicts(resolved_files)
end
- it 'returns a 400 error' do
+ it "returns a 400 error" do
expect(response).to have_gitlab_http_status(:bad_request)
end
- it 'has a message with the path of the problem file' do
- expect(json_response['message']).to include('files/ruby/popen.rb')
+ it "has a message with the path of the problem file" do
+ expect(json_response["message"]).to include("files/ruby/popen.rb")
end
- it 'does not create a new commit' do
+ it "does not create a new commit" do
expect(original_head_sha).to eq(merge_request_with_conflicts.source_branch_head.sha)
end
end
diff --git a/spec/controllers/projects/merge_requests/creations_controller_spec.rb b/spec/controllers/projects/merge_requests/creations_controller_spec.rb
index f031a74c5bd..49d8c4a6b83 100644
--- a/spec/controllers/projects/merge_requests/creations_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/creations_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MergeRequests::CreationsController do
let(:project) { create(:project, :repository) }
@@ -9,9 +9,9 @@ describe Projects::MergeRequests::CreationsController do
namespace_id: fork_project.namespace.to_param,
project_id: fork_project,
merge_request: {
- source_branch: 'remove-submodule',
- target_branch: 'master'
- }
+ source_branch: "remove-submodule",
+ target_branch: "master",
+ },
}
end
@@ -21,16 +21,16 @@ describe Projects::MergeRequests::CreationsController do
sign_in(user)
end
- describe 'GET new' do
- context 'merge request that removes a submodule' do
- it 'renders new merge request widget template' do
+ describe "GET new" do
+ context "merge request that removes a submodule" do
+ it "renders new merge request widget template" do
get :new, params: get_diff_params
expect(response).to be_success
end
end
- context 'merge request with some commits' do
+ context "merge request with some commits" do
render_views
let(:large_diff_params) do
@@ -38,20 +38,20 @@ describe Projects::MergeRequests::CreationsController do
namespace_id: fork_project.namespace.to_param,
project_id: fork_project,
merge_request: {
- source_branch: 'master',
- target_branch: 'fix'
- }
+ source_branch: "master",
+ target_branch: "fix",
+ },
}
end
- describe 'with artificial limits' do
+ describe "with artificial limits" do
before do
# Load MergeRequestdiff so stub_const won't override it with its own definition
# See https://github.com/rspec/rspec-mocks/issues/1079
stub_const("#{MergeRequestDiff}::COMMITS_SAFE_SIZE", 2)
end
- it 'limits total commits' do
+ it "limits total commits" do
get :new, params: large_diff_params
expect(response).to be_success
@@ -61,11 +61,11 @@ describe Projects::MergeRequests::CreationsController do
expect(total).to be > 0
expect(assigns(:hidden_commit_count)).to be > 0
expect(response).to have_gitlab_http_status(200)
- expect(response.body).to match %r(<span class="commits-count">2 commits</span>)
+ expect(response.body).to match %r{<span class="commits-count">2 commits</span>}
end
end
- it 'shows total commits' do
+ it "shows total commits" do
get :new, params: large_diff_params
expect(response).to be_success
@@ -75,17 +75,17 @@ describe Projects::MergeRequests::CreationsController do
expect(total).to be > 0
expect(assigns(:hidden_commit_count)).to eq(0)
expect(response).to have_gitlab_http_status(200)
- expect(response.body).to match %r(<span class="commits-count">#{total} commits</span>)
+ expect(response.body).to match %r{<span class="commits-count">#{total} commits</span>}
end
end
end
- describe 'GET diffs' do
- context 'when merge request cannot be created' do
- it 'does not assign diffs var' do
+ describe "GET diffs" do
+ context "when merge request cannot be created" do
+ it "does not assign diffs var" do
allow_any_instance_of(MergeRequest).to receive(:can_be_created).and_return(false)
- get :diffs, params: get_diff_params.merge(format: 'json')
+ get :diffs, params: get_diff_params.merge(format: "json")
expect(response).to be_success
expect(assigns[:diffs]).to be_nil
@@ -93,118 +93,118 @@ describe Projects::MergeRequests::CreationsController do
end
end
- describe 'GET pipelines' do
+ describe "GET pipelines" do
before do
- create(:ci_pipeline, sha: fork_project.commit('remove-submodule').id,
- ref: 'remove-submodule',
+ create(:ci_pipeline, sha: fork_project.commit("remove-submodule").id,
+ ref: "remove-submodule",
project: fork_project)
end
- it 'renders JSON including serialized pipelines' do
- get :pipelines, params: get_diff_params.merge(format: 'json')
+ it "renders JSON including serialized pipelines" do
+ get :pipelines, params: get_diff_params.merge(format: "json")
expect(response).to be_ok
- expect(json_response).to have_key 'pipelines'
- expect(json_response['pipelines']).not_to be_empty
+ expect(json_response).to have_key "pipelines"
+ expect(json_response["pipelines"]).not_to be_empty
end
end
- describe 'GET diff_for_path' do
+ describe "GET diff_for_path" do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project,
- format: 'json'
+ format: "json",
}
get :diff_for_path, params: params.merge(extra_params)
end
- let(:existing_path) { 'files/ruby/feature.rb' }
+ let(:existing_path) { "files/ruby/feature.rb" }
- context 'when both branches are in the same project' do
- it 'disables diff notes' do
- diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: { source_branch: 'feature', target_branch: 'master' })
+ context "when both branches are in the same project" do
+ it "disables diff notes" do
+ diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: {source_branch: "feature", target_branch: "master"})
expect(assigns(:diff_notes_disabled)).to be_truthy
end
- it 'only renders the diffs for the path given' do
+ it "only renders the diffs for the path given" do
expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs|
expect(diffs.diff_files.map(&:new_path)).to contain_exactly(existing_path)
meth.call(diffs)
end
- diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: { source_branch: 'feature', target_branch: 'master' })
+ diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: {source_branch: "feature", target_branch: "master"})
end
end
- context 'when the source branch is in a different project to the target' do
+ context "when the source branch is in a different project to the target" do
let(:other_project) { create(:project, :repository) }
before do
other_project.add_maintainer(user)
end
- context 'when the path exists in the diff' do
- it 'disables diff notes' do
- diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: { source_project: other_project, source_branch: 'feature', target_branch: 'master' })
+ context "when the path exists in the diff" do
+ it "disables diff notes" do
+ diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: {source_project: other_project, source_branch: "feature", target_branch: "master"})
expect(assigns(:diff_notes_disabled)).to be_truthy
end
- it 'only renders the diffs for the path given' do
+ it "only renders the diffs for the path given" do
expect(controller).to receive(:render_diff_for_path).and_wrap_original do |meth, diffs|
expect(diffs.diff_files.map(&:new_path)).to contain_exactly(existing_path)
meth.call(diffs)
end
- diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: { source_project: other_project, source_branch: 'feature', target_branch: 'master' })
+ diff_for_path(old_path: existing_path, new_path: existing_path, merge_request: {source_project: other_project, source_branch: "feature", target_branch: "master"})
end
end
- context 'when the path does not exist in the diff' do
+ context "when the path does not exist in the diff" do
before do
- diff_for_path(old_path: 'files/ruby/nopen.rb', new_path: 'files/ruby/nopen.rb', merge_request: { source_project: other_project, source_branch: 'feature', target_branch: 'master' })
+ diff_for_path(old_path: "files/ruby/nopen.rb", new_path: "files/ruby/nopen.rb", merge_request: {source_project: other_project, source_branch: "feature", target_branch: "master"})
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
end
- describe 'GET #branch_to' do
+ describe "GET #branch_to" do
before do
allow(Ability).to receive(:allowed?).and_call_original
end
- it 'fetches the commit if a user has access' do
+ it "fetches the commit if a user has access" do
expect(Ability).to receive(:allowed?).with(user, :read_project, project) { true }
get :branch_to,
- params: {
- namespace_id: fork_project.namespace,
- project_id: fork_project,
- target_project_id: project.id,
- ref: 'master'
- }
+ params: {
+ namespace_id: fork_project.namespace,
+ project_id: fork_project,
+ target_project_id: project.id,
+ ref: "master",
+ }
expect(assigns(:commit)).not_to be_nil
expect(response).to have_gitlab_http_status(200)
end
- it 'does not load the commit when the user cannot read the project' do
+ it "does not load the commit when the user cannot read the project" do
expect(Ability).to receive(:allowed?).with(user, :read_project, project) { false }
get :branch_to,
- params: {
- namespace_id: fork_project.namespace,
- project_id: fork_project,
- target_project_id: project.id,
- ref: 'master'
- }
+ params: {
+ namespace_id: fork_project.namespace,
+ project_id: fork_project,
+ target_project_id: project.id,
+ ref: "master",
+ }
expect(assigns(:commit)).to be_nil
expect(response).to have_gitlab_http_status(200)
diff --git a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
index e85f32d6e30..47673fe1c3d 100644
--- a/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests/diffs_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MergeRequests::DiffsController do
include ProjectForksHelper
@@ -12,49 +12,49 @@ describe Projects::MergeRequests::DiffsController do
sign_in(user)
end
- describe 'GET show' do
+ describe "GET show" do
def go(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project,
id: merge_request.iid,
- format: 'json'
+ format: "json",
}
get :show, params: params.merge(extra_params)
end
- context 'with default params' do
- context 'for the same project' do
+ context "with default params" do
+ context "for the same project" do
before do
allow(controller).to receive(:rendered_for_merge_request?).and_return(true)
end
- it 'serializes merge request diff collection' do
+ it "serializes merge request diff collection" do
expect_any_instance_of(DiffsSerializer).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
go
end
end
- context 'when note has no position' do
+ context "when note has no position" do
before do
create(:legacy_diff_note_on_merge_request, project: project, noteable: merge_request, position: nil)
end
- it 'serializes merge request diff collection' do
+ it "serializes merge request diff collection" do
expect_any_instance_of(DiffsSerializer).to receive(:represent).with(an_instance_of(Gitlab::Diff::FileCollection::MergeRequestDiff), an_instance_of(Hash))
go
end
end
- context 'with forked projects with submodules' do
+ context "with forked projects with submodules" do
render_views
let(:project) { create(:project, :repository) }
let(:forked_project) { fork_project_with_submodules(project) }
- let(:merge_request) { create(:merge_request_with_diffs, source_project: forked_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
+ let(:merge_request) { create(:merge_request_with_diffs, source_project: forked_project, source_branch: "add-submodule-version-bump", target_branch: "master", target_project: project) }
before do
project.add_developer(user)
@@ -63,83 +63,83 @@ describe Projects::MergeRequests::DiffsController do
go
end
- it 'renders' do
+ it "renders" do
expect(response).to be_success
- expect(response.body).to have_content('Subproject commit')
+ expect(response.body).to have_content("Subproject commit")
end
end
end
- context 'with view' do
+ context "with view" do
before do
- go(view: 'parallel')
+ go(view: "parallel")
end
- it 'saves the preferred diff view in a cookie' do
- expect(response.cookies['diff_view']).to eq('parallel')
+ it "saves the preferred diff view in a cookie" do
+ expect(response.cookies["diff_view"]).to eq("parallel")
end
end
end
- describe 'GET diff_for_path' do
+ describe "GET diff_for_path" do
def diff_for_path(extra_params = {})
params = {
namespace_id: project.namespace.to_param,
project_id: project,
id: merge_request.iid,
- format: 'json'
+ format: "json",
}
get :diff_for_path, params: params.merge(extra_params)
end
- let(:existing_path) { 'files/ruby/popen.rb' }
+ let(:existing_path) { "files/ruby/popen.rb" }
- context 'when the merge request exists' do
- context 'when the user can view the merge request' do
- context 'when the path exists in the diff' do
- it 'enables diff notes' do
+ context "when the merge request exists" do
+ context "when the user can view the merge request" do
+ context "when the path exists in the diff" do
+ it "enables diff notes" do
diff_for_path(old_path: existing_path, new_path: existing_path)
expect(assigns(:diff_notes_disabled)).to be_falsey
- expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: 'MergeRequest',
+ expect(assigns(:new_diff_note_attrs)).to eq(noteable_type: "MergeRequest",
noteable_id: merge_request.id,
commit_id: nil)
end
- it 'only renders the diffs for the path given' do
+ it "only renders the diffs for the path given" do
diff_for_path(old_path: existing_path, new_path: existing_path)
- paths = JSON.parse(response.body)["diff_files"].map { |file| file['new_path'] }
+ paths = JSON.parse(response.body)["diff_files"].map { |file| file["new_path"] }
expect(paths).to include(existing_path)
end
end
end
- context 'when the user cannot view the merge request' do
+ context "when the user cannot view the merge request" do
before do
project.team.truncate
diff_for_path(old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when the merge request does not exist' do
+ context "when the merge request does not exist" do
before do
diff_for_path(id: merge_request.iid.succ, old_path: existing_path, new_path: existing_path)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the merge request belongs to a different project' do
+ context "when the merge request belongs to a different project" do
let(:other_project) { create(:project) }
before do
@@ -147,7 +147,7 @@ describe Projects::MergeRequests::DiffsController do
diff_for_path(old_path: existing_path, new_path: existing_path, project_id: other_project)
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index 79f97aa4170..91d66d354f1 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MergeRequestsController do
include ProjectForksHelper
@@ -7,7 +7,7 @@ describe Projects::MergeRequestsController do
let(:user) { project.owner }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
let(:merge_request_with_conflicts) do
- create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr|
+ create(:merge_request, source_branch: "conflict-resolvable", target_branch: "conflict-start", source_project: project, merge_status: :unchecked) do |mr|
mr.mark_as_unmergeable
end
end
@@ -16,17 +16,17 @@ describe Projects::MergeRequestsController do
sign_in(user)
end
- describe 'GET commit_change_content' do
- it 'renders commit_change_content template' do
+ describe "GET commit_change_content" do
+ it "renders commit_change_content template" do
get :commit_change_content,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: merge_request.iid
+ id: merge_request.iid,
},
- format: 'html'
+ format: "html"
- expect(response).to render_template('_commit_change_content')
+ expect(response).to render_template("_commit_change_content")
end
end
@@ -35,17 +35,17 @@ describe Projects::MergeRequestsController do
params = {
namespace_id: project.namespace.to_param,
project_id: project,
- id: merge_request.iid
+ id: merge_request.iid,
}
get :show, params: params.merge(extra_params)
end
- describe 'as html' do
- context 'when diff files were cleaned' do
+ describe "as html" do
+ context "when diff files were cleaned" do
render_views
- it 'renders page when diff size is not persisted and diff_refs does not exist' do
+ it "renders page when diff size is not persisted and diff_refs does not exist" do
diff = merge_request.merge_request_diff
diff.clean!
@@ -76,37 +76,37 @@ describe Projects::MergeRequestsController do
end
end
- context 'when user is setting notes filters' do
+ context "when user is setting notes filters" do
let(:issuable) { merge_request }
let(:issuable_parent) { project }
let!(:discussion_note) { create(:discussion_note_on_merge_request, :system, noteable: issuable, project: project) }
let!(:discussion_comment) { create(:discussion_note_on_merge_request, noteable: issuable, project: project) }
- it_behaves_like 'issuable notes filter'
+ it_behaves_like "issuable notes filter"
end
- describe 'as json' do
- context 'with basic serializer param' do
- it 'renders basic MR entity as json' do
- go(serializer: 'basic', format: :json)
+ describe "as json" do
+ context "with basic serializer param" do
+ it "renders basic MR entity as json" do
+ go(serializer: "basic", format: :json)
- expect(response).to match_response_schema('entities/merge_request_basic')
+ expect(response).to match_response_schema("entities/merge_request_basic")
end
end
- context 'with widget serializer param' do
- it 'renders widget MR entity as json' do
- go(serializer: 'widget', format: :json)
+ context "with widget serializer param" do
+ it "renders widget MR entity as json" do
+ go(serializer: "widget", format: :json)
- expect(response).to match_response_schema('entities/merge_request_widget')
+ expect(response).to match_response_schema("entities/merge_request_widget")
end
end
- context 'when no serialiser was passed' do
- it 'renders widget MR entity as json' do
+ context "when no serialiser was passed" do
+ it "renders widget MR entity as json" do
go(serializer: nil, format: :json)
- expect(response).to match_response_schema('entities/merge_request_widget')
+ expect(response).to match_response_schema("entities/merge_request_widget")
end
end
@@ -130,7 +130,7 @@ describe Projects::MergeRequestsController do
end
describe "as patch" do
- it 'triggers workhorse to serve the request' do
+ it "triggers workhorse to serve the request" do
go(format: :patch)
expect(response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-format-patch:")
@@ -138,60 +138,60 @@ describe Projects::MergeRequestsController do
end
end
- describe 'GET index' do
+ describe "GET index" do
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
def get_merge_requests(page = nil)
get :index,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- state: 'opened',
- page: page.to_param
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ state: "opened",
+ page: page.to_param,
+ }
end
it_behaves_like "issuables list meta-data", :merge_request
- it_behaves_like 'set sort order from user preference' do
- let(:sorting_param) { 'updated_asc' }
+ it_behaves_like "set sort order from user preference" do
+ let(:sorting_param) { "updated_asc" }
end
- context 'when page param' do
+ context "when page param" do
let(:last_page) { project.merge_requests.page.total_pages }
let!(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project) }
- it 'redirects to last_page if page number is larger than number of pages' do
+ it "redirects to last_page if page number is larger than number of pages" do
get_merge_requests(last_page + 1)
expect(response).to redirect_to(namespace_project_merge_requests_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
- it 'redirects to specified page' do
+ it "redirects to specified page" do
get_merge_requests(last_page)
expect(assigns(:merge_requests).current_page).to eq(last_page)
expect(response).to have_gitlab_http_status(200)
end
- it 'does not redirect to external sites when provided a host field' do
+ it "does not redirect to external sites when provided a host field" do
external_host = "www.example.com"
get :index,
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- state: 'opened',
+ state: "opened",
page: (last_page + 1).to_param,
- host: external_host
+ host: external_host,
}
expect(response).to redirect_to(namespace_project_merge_requests_path(page: last_page, state: controller.params[:state], scope: controller.params[:scope]))
end
end
- context 'when filtering by opened state' do
- context 'with opened merge requests' do
- it 'lists those merge requests' do
+ context "when filtering by opened state" do
+ context "with opened merge requests" do
+ it "lists those merge requests" do
expect(merge_request).to be_persisted
get_merge_requests
@@ -200,13 +200,13 @@ describe Projects::MergeRequestsController do
end
end
- context 'with reopened merge requests' do
+ context "with reopened merge requests" do
before do
merge_request.close!
merge_request.reopen!
end
- it 'lists those merge requests' do
+ it "lists those merge requests" do
get_merge_requests
expect(assigns(:merge_requests)).to include(merge_request)
@@ -215,87 +215,87 @@ describe Projects::MergeRequestsController do
end
end
- describe 'PUT update' do
+ describe "PUT update" do
def update_merge_request(mr_params, additional_params = {})
params = {
namespace_id: project.namespace,
project_id: project,
id: merge_request.iid,
- merge_request: mr_params
+ merge_request: mr_params,
}.merge(additional_params)
put :update, params: params
end
- context 'changing the assignee' do
- it 'limits the attributes exposed on the assignee' do
+ context "changing the assignee" do
+ it "limits the attributes exposed on the assignee" do
assignee = create(:user)
project.add_developer(assignee)
- update_merge_request({ assignee_id: assignee.id }, format: :json)
+ update_merge_request({assignee_id: assignee.id}, format: :json)
body = JSON.parse(response.body)
- expect(body['assignee'].keys)
- .to match_array(%w(name username avatar_url id state web_url))
+ expect(body["assignee"].keys)
+ .to match_array(%w[name username avatar_url id state web_url])
end
end
- context 'when user does not have access to update issue' do
+ context "when user does not have access to update issue" do
before do
reporter = create(:user)
project.add_reporter(reporter)
sign_in(reporter)
end
- it 'responds with 404' do
- update_merge_request(title: 'New title')
+ it "responds with 404" do
+ update_merge_request(title: "New title")
expect(response).to have_http_status(:not_found)
end
end
- context 'there is no source project' do
+ context "there is no source project" do
let(:project) { create(:project, :repository) }
let(:forked_project) { fork_project_with_submodules(project) }
- let!(:merge_request) { create(:merge_request, source_project: forked_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
+ let!(:merge_request) { create(:merge_request, source_project: forked_project, source_branch: "add-submodule-version-bump", target_branch: "master", target_project: project) }
before do
forked_project.destroy
end
- it 'closes MR without errors' do
- update_merge_request(state_event: 'close')
+ it "closes MR without errors" do
+ update_merge_request(state_event: "close")
expect(response).to redirect_to([merge_request.target_project.namespace.becomes(Namespace), merge_request.target_project, merge_request])
expect(merge_request.reload.closed?).to be_truthy
end
- it 'allows editing of a closed merge request' do
+ it "allows editing of a closed merge request" do
merge_request.close!
- update_merge_request(title: 'New title')
+ update_merge_request(title: "New title")
expect(response).to redirect_to([merge_request.target_project.namespace.becomes(Namespace), merge_request.target_project, merge_request])
- expect(merge_request.reload.title).to eq 'New title'
+ expect(merge_request.reload.title).to eq "New title"
end
- it 'does not allow to update target branch closed merge request' do
+ it "does not allow to update target branch closed merge request" do
merge_request.close!
- update_merge_request(target_branch: 'new_branch')
+ update_merge_request(target_branch: "new_branch")
expect { merge_request.reload.target_branch }.not_to change { merge_request.target_branch }
end
- it_behaves_like 'update invalid issuable', MergeRequest
+ it_behaves_like "update invalid issuable", MergeRequest
end
- context 'two merge requests with the same source branch' do
- it 'does not allow a closed merge request to be reopened if another one is open' do
+ context "two merge requests with the same source branch" do
+ it "does not allow a closed merge request to be reopened if another one is open" do
merge_request.close!
create(:merge_request, source_project: merge_request.source_project, source_branch: merge_request.source_branch)
- update_merge_request(state_event: 'reopen')
+ update_merge_request(state_event: "reopen")
errors = assigns[:merge_request].errors
@@ -305,18 +305,18 @@ describe Projects::MergeRequestsController do
end
end
- describe 'POST merge' do
+ describe "POST merge" do
let(:base_params) do
{
namespace_id: project.namespace,
project_id: project,
id: merge_request.iid,
squash: false,
- format: 'json'
+ format: "json",
}
end
- context 'when user cannot access' do
+ context "when user cannot access" do
let(:user) { create(:user) }
before do
@@ -324,79 +324,79 @@ describe Projects::MergeRequestsController do
post :merge, params: base_params, xhr: true
end
- it 'returns 404' do
+ it "returns 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the merge request is not mergeable' do
+ context "when the merge request is not mergeable" do
before do
merge_request.update(title: "WIP: #{merge_request.title}")
post :merge, params: base_params
end
- it 'returns :failed' do
- expect(json_response).to eq('status' => 'failed')
+ it "returns :failed" do
+ expect(json_response).to eq("status" => "failed")
end
end
- context 'when the sha parameter does not match the source SHA' do
+ context "when the sha parameter does not match the source SHA" do
before do
- post :merge, params: base_params.merge(sha: 'foo')
+ post :merge, params: base_params.merge(sha: "foo")
end
- it 'returns :sha_mismatch' do
- expect(json_response).to eq('status' => 'sha_mismatch')
+ it "returns :sha_mismatch" do
+ expect(json_response).to eq("status" => "sha_mismatch")
end
end
- context 'when the sha parameter matches the source SHA' do
+ context "when the sha parameter matches the source SHA" do
def merge_with_sha(params = {})
post_params = base_params.merge(sha: merge_request.diff_head_sha).merge(params)
post :merge, params: post_params, as: :json
end
- it 'returns :success' do
+ it "returns :success" do
merge_with_sha
- expect(json_response).to eq('status' => 'success')
+ expect(json_response).to eq("status" => "success")
end
- it 'starts the merge immediately with permitted params' do
- expect(MergeWorker).to receive(:perform_async).with(merge_request.id, anything, { 'squash' => false })
+ it "starts the merge immediately with permitted params" do
+ expect(MergeWorker).to receive(:perform_async).with(merge_request.id, anything, {"squash" => false})
merge_with_sha
end
- context 'when squash is passed as 1' do
- it 'updates the squash attribute on the MR to true' do
+ context "when squash is passed as 1" do
+ it "updates the squash attribute on the MR to true" do
merge_request.update(squash: false)
- merge_with_sha(squash: '1')
+ merge_with_sha(squash: "1")
expect(merge_request.reload.squash).to be_truthy
end
end
- context 'when squash is passed as 0' do
- it 'updates the squash attribute on the MR to false' do
+ context "when squash is passed as 0" do
+ it "updates the squash attribute on the MR to false" do
merge_request.update(squash: true)
- merge_with_sha(squash: '0')
+ merge_with_sha(squash: "0")
expect(merge_request.reload.squash).to be_falsey
end
end
- context 'when a squash commit message is passed' do
- let(:message) { 'My custom squash commit message' }
+ context "when a squash commit message is passed" do
+ let(:message) { "My custom squash commit message" }
- it 'passes the same message to SquashService' do
- params = { squash: '1', squash_commit_message: message }
+ it "passes the same message to SquashService" do
+ params = {squash: "1", squash_commit_message: message}
expect_next_instance_of(MergeRequests::SquashService, project, user, params.merge(merge_request: merge_request)) do |squash_service|
expect(squash_service).to receive(:execute).and_return({
status: :success,
- squash_sha: SecureRandom.hex(20)
+ squash_sha: SecureRandom.hex(20),
})
end
@@ -404,22 +404,22 @@ describe Projects::MergeRequestsController do
end
end
- context 'when the pipeline succeeds is passed' do
+ context "when the pipeline succeeds is passed" do
let!(:head_pipeline) do
create(:ci_empty_pipeline, project: project, sha: merge_request.diff_head_sha, ref: merge_request.source_branch, head_pipeline_of: merge_request)
end
def merge_when_pipeline_succeeds
- post :merge, params: base_params.merge(sha: merge_request.diff_head_sha, merge_when_pipeline_succeeds: '1')
+ post :merge, params: base_params.merge(sha: merge_request.diff_head_sha, merge_when_pipeline_succeeds: "1")
end
- it 'returns :merge_when_pipeline_succeeds' do
+ it "returns :merge_when_pipeline_succeeds" do
merge_when_pipeline_succeeds
- expect(json_response).to eq('status' => 'merge_when_pipeline_succeeds')
+ expect(json_response).to eq("status" => "merge_when_pipeline_succeeds")
end
- it 'sets the MR to merge when the pipeline succeeds' do
+ it "sets the MR to merge when the pipeline succeeds" do
service = double(:merge_when_pipeline_succeeds_service)
expect(MergeRequests::MergeWhenPipelineSucceedsService)
@@ -430,92 +430,92 @@ describe Projects::MergeRequestsController do
merge_when_pipeline_succeeds
end
- context 'when project.only_allow_merge_if_pipeline_succeeds? is true' do
+ context "when project.only_allow_merge_if_pipeline_succeeds? is true" do
before do
project.update_column(:only_allow_merge_if_pipeline_succeeds, true)
end
- context 'and head pipeline is not the current one' do
+ context "and head pipeline is not the current one" do
before do
- head_pipeline.update(sha: 'not_current_sha')
+ head_pipeline.update(sha: "not_current_sha")
end
- it 'returns :failed' do
+ it "returns :failed" do
merge_when_pipeline_succeeds
- expect(json_response).to eq('status' => 'failed')
+ expect(json_response).to eq("status" => "failed")
end
end
- it 'returns :merge_when_pipeline_succeeds' do
+ it "returns :merge_when_pipeline_succeeds" do
merge_when_pipeline_succeeds
- expect(json_response).to eq('status' => 'merge_when_pipeline_succeeds')
+ expect(json_response).to eq("status" => "merge_when_pipeline_succeeds")
end
end
end
- describe 'only_allow_merge_if_all_discussions_are_resolved? setting' do
+ describe "only_allow_merge_if_all_discussions_are_resolved? setting" do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) }
- context 'when enabled' do
+ context "when enabled" do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, true)
end
- context 'with unresolved discussion' do
+ context "with unresolved discussion" do
before do
expect(merge_request).not_to be_discussions_resolved
end
- it 'returns :failed' do
+ it "returns :failed" do
merge_with_sha
- expect(json_response).to eq('status' => 'failed')
+ expect(json_response).to eq("status" => "failed")
end
end
- context 'with all discussions resolved' do
+ context "with all discussions resolved" do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
expect(merge_request).to be_discussions_resolved
end
- it 'returns :success' do
+ it "returns :success" do
merge_with_sha
- expect(json_response).to eq('status' => 'success')
+ expect(json_response).to eq("status" => "success")
end
end
end
- context 'when disabled' do
+ context "when disabled" do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, false)
end
- context 'with unresolved discussion' do
+ context "with unresolved discussion" do
before do
expect(merge_request).not_to be_discussions_resolved
end
- it 'returns :success' do
+ it "returns :success" do
merge_with_sha
- expect(json_response).to eq('status' => 'success')
+ expect(json_response).to eq("status" => "success")
end
end
- context 'with all discussions resolved' do
+ context "with all discussions resolved" do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
expect(merge_request).to be_discussions_resolved
end
- it 'returns :success' do
+ it "returns :success" do
merge_with_sha
- expect(json_response).to eq('status' => 'success')
+ expect(json_response).to eq("status" => "success")
end
end
end
@@ -527,7 +527,7 @@ describe Projects::MergeRequestsController do
let(:user) { create(:user) }
it "denies access to users unless they're admin or project owner" do
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
expect(response).to have_gitlab_http_status(404)
end
@@ -542,70 +542,70 @@ describe Projects::MergeRequestsController do
end
it "deletes the merge request" do
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
expect(response).to have_gitlab_http_status(302)
expect(controller).to set_flash[:notice].to(/The merge request was successfully deleted\./)
end
- it 'delegates the update of the todos count cache to TodoService' do
+ it "delegates the update of the todos count cache to TodoService" do
expect_any_instance_of(TodoService).to receive(:destroy_target).with(merge_request).once
- delete :destroy, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ delete :destroy, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
end
end
end
- describe 'GET commits' do
- def go(format: 'html')
+ describe "GET commits" do
+ def go(format: "html")
get :commits,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: merge_request.iid
- },
- format: format
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: merge_request.iid,
+ },
+ format: format
end
- it 'renders the commits template to a string' do
- go format: 'json'
+ it "renders the commits template to a string" do
+ go format: "json"
- expect(response).to render_template('projects/merge_requests/_commits')
- expect(json_response).to have_key('html')
+ expect(response).to render_template("projects/merge_requests/_commits")
+ expect(json_response).to have_key("html")
end
end
- describe 'GET pipelines' do
+ describe "GET pipelines" do
before do
create(:ci_pipeline, project: merge_request.source_project,
ref: merge_request.source_branch,
sha: merge_request.diff_head_sha)
get :pipelines,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: merge_request.iid
- },
- format: :json
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: merge_request.iid,
+ },
+ format: :json
end
- it 'responds with serialized pipelines' do
- expect(json_response['pipelines']).not_to be_empty
- expect(json_response['count']['all']).to eq 1
+ it "responds with serialized pipelines" do
+ expect(json_response["pipelines"]).not_to be_empty
+ expect(json_response["count"]["all"]).to eq 1
expect(response).to include_pagination_headers
end
end
- describe 'GET test_reports' do
+ describe "GET test_reports" do
subject do
get :test_reports,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: merge_request.iid
- },
- format: :json
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: merge_request.iid,
+ },
+ format: :json
end
before do
@@ -613,75 +613,75 @@ describe Projects::MergeRequestsController do
.to receive(:compare_test_reports).and_return(comparison_status)
end
- context 'when comparison is being processed' do
- let(:comparison_status) { { status: :parsing } }
+ context "when comparison is being processed" do
+ let(:comparison_status) { {status: :parsing} }
- it 'sends polling interval' do
+ it "sends polling interval" do
expect(Gitlab::PollingInterval).to receive(:set_header)
subject
end
- it 'returns 204 HTTP status' do
+ it "returns 204 HTTP status" do
subject
expect(response).to have_gitlab_http_status(:no_content)
end
end
- context 'when comparison is done' do
- let(:comparison_status) { { status: :parsed, data: { summary: 1 } } }
+ context "when comparison is done" do
+ let(:comparison_status) { {status: :parsed, data: {summary: 1}} }
- it 'does not send polling interval' do
+ it "does not send polling interval" do
expect(Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
- it 'returns 200 HTTP status' do
+ it "returns 200 HTTP status" do
subject
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response).to eq({ 'summary' => 1 })
+ expect(json_response).to eq({"summary" => 1})
end
end
- context 'when user created corrupted test reports' do
- let(:comparison_status) { { status: :error, status_reason: 'Failed to parse test reports' } }
+ context "when user created corrupted test reports" do
+ let(:comparison_status) { {status: :error, status_reason: "Failed to parse test reports"} }
- it 'does not send polling interval' do
+ it "does not send polling interval" do
expect(Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
- it 'returns 400 HTTP status' do
+ it "returns 400 HTTP status" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response).to eq({ 'status_reason' => 'Failed to parse test reports' })
+ expect(json_response).to eq({"status_reason" => "Failed to parse test reports"})
end
end
- context 'when something went wrong on our system' do
+ context "when something went wrong on our system" do
let(:comparison_status) { {} }
- it 'does not send polling interval' do
+ it "does not send polling interval" do
expect(Gitlab::PollingInterval).not_to receive(:set_header)
subject
end
- it 'returns 500 HTTP status' do
+ it "returns 500 HTTP status" do
subject
expect(response).to have_gitlab_http_status(:internal_server_error)
- expect(json_response).to eq({ 'status_reason' => 'Unknown error' })
+ expect(json_response).to eq({"status_reason" => "Unknown error"})
end
end
end
- describe 'POST remove_wip' do
+ describe "POST remove_wip" do
before do
merge_request.title = merge_request.wip_title
merge_request.save
@@ -691,33 +691,33 @@ describe Projects::MergeRequestsController do
format: :json,
namespace_id: merge_request.project.namespace.to_param,
project_id: merge_request.project,
- id: merge_request.iid
+ id: merge_request.iid,
},
xhr: true
end
- it 'removes the wip status' do
+ it "removes the wip status" do
expect(merge_request.reload.title).to eq(merge_request.wipless_title)
end
- it 'renders MergeRequest as JSON' do
- expect(json_response.keys).to include('id', 'iid', 'description')
+ it "renders MergeRequest as JSON" do
+ expect(json_response.keys).to include("id", "iid", "description")
end
end
- describe 'POST cancel_merge_when_pipeline_succeeds' do
+ describe "POST cancel_merge_when_pipeline_succeeds" do
subject do
post :cancel_merge_when_pipeline_succeeds,
params: {
format: :json,
namespace_id: merge_request.project.namespace.to_param,
project_id: merge_request.project,
- id: merge_request.iid
+ id: merge_request.iid,
},
xhr: true
end
- it 'calls MergeRequests::MergeWhenPipelineSucceedsService' do
+ it "calls MergeRequests::MergeWhenPipelineSucceedsService" do
mwps_service = double
allow(MergeRequests::MergeWhenPipelineSucceedsService)
@@ -731,54 +731,54 @@ describe Projects::MergeRequestsController do
it { is_expected.to have_gitlab_http_status(:success) }
- it 'renders MergeRequest as JSON' do
+ it "renders MergeRequest as JSON" do
subject
- expect(json_response.keys).to include('id', 'iid', 'description')
+ expect(json_response.keys).to include("id", "iid", "description")
end
end
- describe 'POST assign_related_issues' do
+ describe "POST assign_related_issues" do
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
def post_assign_issues
merge_request.update!(description: "Closes #{issue1.to_reference} and #{issue2.to_reference}",
author: user,
- source_branch: 'feature',
- target_branch: 'master')
+ source_branch: "feature",
+ target_branch: "master")
post :assign_related_issues,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: merge_request.iid
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: merge_request.iid,
+ }
end
- it 'shows a flash message on success' do
+ it "shows a flash message on success" do
post_assign_issues
- expect(flash[:notice]).to eq '2 issues have been assigned to you'
+ expect(flash[:notice]).to eq "2 issues have been assigned to you"
end
- it 'correctly pluralizes flash message on success' do
+ it "correctly pluralizes flash message on success" do
issue2.assignees = [user]
post_assign_issues
- expect(flash[:notice]).to eq '1 issue has been assigned to you'
+ expect(flash[:notice]).to eq "1 issue has been assigned to you"
end
- it 'calls MergeRequests::AssignIssuesService' do
+ it "calls MergeRequests::AssignIssuesService" do
expect(MergeRequests::AssignIssuesService).to receive(:new)
.with(project, user, merge_request: merge_request)
- .and_return(double(execute: { count: 1 }))
+ .and_return(double(execute: {count: 1}))
post_assign_issues
end
- it 'is skipped when not signed in' do
+ it "is skipped when not signed in" do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
sign_out(:user)
@@ -788,57 +788,57 @@ describe Projects::MergeRequestsController do
end
end
- describe 'GET ci_environments_status' do
- context 'the environment is from a forked project' do
+ describe "GET ci_environments_status" do
+ context "the environment is from a forked project" do
let(:forked) { fork_project(project, user, repository: true) }
let(:sha) { forked.commit.sha }
let(:environment) { create(:environment, project: forked) }
let(:pipeline) { create(:ci_pipeline, sha: sha, project: forked) }
let(:build) { create(:ci_build, pipeline: pipeline) }
- let!(:deployment) { create(:deployment, :succeed, environment: environment, sha: sha, ref: 'master', deployable: build) }
+ let!(:deployment) { create(:deployment, :succeed, environment: environment, sha: sha, ref: "master", deployable: build) }
let(:merge_request) do
- create(:merge_request, source_project: forked, target_project: project, target_branch: 'master', head_pipeline: pipeline)
+ create(:merge_request, source_project: forked, target_project: project, target_branch: "master", head_pipeline: pipeline)
end
- it 'links to the environment on that project' do
+ it "links to the environment on that project" do
get_ci_environments_status
- expect(json_response.first['url']).to match /#{forked.full_path}/
+ expect(json_response.first["url"]).to match /#{forked.full_path}/
end
context "when environment_target is 'merge_commit'" do
- it 'returns nothing' do
- get_ci_environments_status(environment_target: 'merge_commit')
+ it "returns nothing" do
+ get_ci_environments_status(environment_target: "merge_commit")
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
- context 'when is merged' do
+ context "when is merged" do
let(:source_environment) { create(:environment, project: project) }
let(:merge_commit_sha) { project.repository.merge(user, forked.commit.id, merge_request, "merged in test") }
let(:post_merge_pipeline) { create(:ci_pipeline, sha: merge_commit_sha, project: project) }
let(:post_merge_build) { create(:ci_build, pipeline: post_merge_pipeline) }
- let!(:source_deployment) { create(:deployment, :succeed, environment: source_environment, sha: merge_commit_sha, ref: 'master', deployable: post_merge_build) }
+ let!(:source_deployment) { create(:deployment, :succeed, environment: source_environment, sha: merge_commit_sha, ref: "master", deployable: post_merge_build) }
before do
merge_request.update!(merge_commit_sha: merge_commit_sha)
merge_request.mark_as_merged!
end
- it 'returns the environment on the source project' do
- get_ci_environments_status(environment_target: 'merge_commit')
+ it "returns the environment on the source project" do
+ get_ci_environments_status(environment_target: "merge_commit")
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response.first['url']).to match /#{project.full_path}/
+ expect(json_response.first["url"]).to match /#{project.full_path}/
end
end
end
# we're trying to reduce the overall number of queries for this method.
# set a hard limit for now. https://gitlab.com/gitlab-org/gitlab-ce/issues/52287
- it 'keeps queries in check' do
+ it "keeps queries in check" do
control_count = ActiveRecord::QueryRecorder.new { get_ci_environments_status }.count
expect(control_count).to be <= 137
@@ -849,7 +849,7 @@ describe Projects::MergeRequestsController do
namespace_id: merge_request.project.namespace.to_param,
project_id: merge_request.project,
id: merge_request.iid,
- format: 'json'
+ format: "json",
}
get :ci_environments_status, params: params.merge(extra_params)
@@ -857,8 +857,8 @@ describe Projects::MergeRequestsController do
end
end
- describe 'GET pipeline_status.json' do
- context 'when head_pipeline exists' do
+ describe "GET pipeline_status.json" do
+ context "when head_pipeline exists" do
let!(:pipeline) do
create(:ci_pipeline, project: merge_request.source_project,
ref: merge_request.source_branch,
@@ -866,27 +866,27 @@ describe Projects::MergeRequestsController do
head_pipeline_of: merge_request)
end
- let(:status) { pipeline.detailed_status(double('user')) }
+ let(:status) { pipeline.detailed_status(double("user")) }
before do
get_pipeline_status
end
- it 'return a detailed head_pipeline status in json' do
+ it "return a detailed head_pipeline status in json" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['text']).to eq status.text
- expect(json_response['label']).to eq status.label
- expect(json_response['icon']).to eq status.icon
- expect(json_response['favicon']).to match_asset_path "/assets/ci_favicons/#{status.favicon}.png"
+ expect(json_response["text"]).to eq status.text
+ expect(json_response["label"]).to eq status.label
+ expect(json_response["icon"]).to eq status.icon
+ expect(json_response["favicon"]).to match_asset_path "/assets/ci_favicons/#{status.favicon}.png"
end
end
- context 'when head_pipeline does not exist' do
+ context "when head_pipeline does not exist" do
before do
get_pipeline_status
end
- it 'return empty' do
+ it "return empty" do
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).to be_empty
end
@@ -894,27 +894,27 @@ describe Projects::MergeRequestsController do
def get_pipeline_status
get :pipeline_status, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: merge_request.iid
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: merge_request.iid,
+ },
format: :json
end
end
- describe 'POST #rebase' do
+ describe "POST #rebase" do
let(:viewer) { user }
def post_rebase
- post :rebase, params: { namespace_id: project.namespace, project_id: project, id: merge_request }
+ post :rebase, params: {namespace_id: project.namespace, project_id: project, id: merge_request}
end
def expect_rebase_worker_for(user)
expect(RebaseWorker).to receive(:perform_async).with(merge_request.id, user.id)
end
- context 'successfully' do
- it 'enqeues a RebaseWorker' do
+ context "successfully" do
+ it "enqeues a RebaseWorker" do
expect_rebase_worker_for(viewer)
post_rebase
@@ -923,7 +923,7 @@ describe Projects::MergeRequestsController do
end
end
- context 'with a forked project' do
+ context "with a forked project" do
let(:forked_project) { fork_project(project, fork_owner, repository: true) }
let(:fork_owner) { create(:user) }
@@ -934,8 +934,8 @@ describe Projects::MergeRequestsController do
forked_project.add_reporter(user)
end
- context 'user cannot push to source branch' do
- it 'returns 404' do
+ context "user cannot push to source branch" do
+ it "returns 404" do
expect_rebase_worker_for(viewer).never
post_rebase
@@ -944,14 +944,14 @@ describe Projects::MergeRequestsController do
end
end
- context 'user can push to source branch' do
+ context "user can push to source branch" do
before do
project.add_reporter(fork_owner)
sign_in(fork_owner)
end
- it 'returns 200' do
+ it "returns 200" do
expect_rebase_worker_for(fork_owner)
post_rebase
@@ -962,26 +962,26 @@ describe Projects::MergeRequestsController do
end
end
- describe 'GET discussions' do
- context 'when authenticated' do
+ describe "GET discussions" do
+ context "when authenticated" do
before do
project.add_developer(user)
sign_in(user)
end
- it 'returns 200' do
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ it "returns 200" do
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
expect(response.status).to eq(200)
end
- context 'highlight preloading' do
- context 'with commit diff notes' do
+ context "highlight preloading" do
+ context "with commit diff notes" do
let!(:commit_diff_note) do
create(:diff_note_on_commit, project: merge_request.project)
end
- it 'preloads notes diffs highlights' do
+ it "preloads notes diffs highlights" do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = commit_diff_note.note_diff_file
@@ -989,16 +989,16 @@ describe Projects::MergeRequestsController do
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
end
end
- context 'with diff notes' do
+ context "with diff notes" do
let!(:diff_note) do
create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.project)
end
- it 'preloads notes diffs highlights' do
+ it "preloads notes diffs highlights" do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = diff_note.note_diff_file
@@ -1006,10 +1006,10 @@ describe Projects::MergeRequestsController do
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
end
- it 'does not preload highlights when diff note is resolved' do
+ it "does not preload highlights when diff note is resolved" do
Notes::ResolveService.new(diff_note.project, user).execute(diff_note)
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
@@ -1019,22 +1019,22 @@ describe Projects::MergeRequestsController do
expect(collection).to receive(:find_by_id).with(note_diff_file.id).and_call_original
end
- get :discussions, params: { namespace_id: project.namespace, project_id: project, id: merge_request.iid }
+ get :discussions, params: {namespace_id: project.namespace, project_id: project, id: merge_request.iid}
end
end
end
end
end
- describe 'GET edit' do
- it 'responds successfully' do
- get :edit, params: { namespace_id: project.namespace, project_id: project, id: merge_request }
+ describe "GET edit" do
+ it "responds successfully" do
+ get :edit, params: {namespace_id: project.namespace, project_id: project, id: merge_request}
expect(response).to have_gitlab_http_status(:success)
end
- it 'assigns the noteable to make sure autocompletes work' do
- get :edit, params: { namespace_id: project.namespace, project_id: project, id: merge_request }
+ it "assigns the noteable to make sure autocompletes work" do
+ get :edit, params: {namespace_id: project.namespace, project_id: project, id: merge_request}
expect(assigns(:noteable)).not_to be_nil
end
diff --git a/spec/controllers/projects/milestones_controller_spec.rb b/spec/controllers/projects/milestones_controller_spec.rb
index ac54b3c3952..6136f77ac26 100644
--- a/spec/controllers/projects/milestones_controller_spec.rb
+++ b/spec/controllers/projects/milestones_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MilestonesController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
let(:issue) { create(:issue, project: project, milestone: milestone) }
- let!(:label) { create(:label, project: project, title: 'Issue Label', issues: [issue]) }
+ let!(:label) { create(:label, project: project, title: "Issue Label", issues: [issue]) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
let(:milestone_path) { namespace_project_milestone_path }
@@ -15,40 +15,40 @@ describe Projects::MilestonesController do
controller.instance_variable_set(:@project, project)
end
- it_behaves_like 'milestone tabs'
+ it_behaves_like "milestone tabs"
describe "#show" do
render_views
def view_milestone(options = {})
- params = { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
+ params = {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}
get :show, params: params.merge(options)
end
- it 'shows milestone page' do
+ it "shows milestone page" do
view_milestone
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq 'text/html'
+ expect(response.content_type).to eq "text/html"
end
- it 'returns milestone json' do
+ it "returns milestone json" do
view_milestone format: :json
expect(response).to have_http_status(404)
- expect(response.content_type).to eq 'application/json'
+ expect(response.content_type).to eq "application/json"
end
end
describe "#index" do
context "as html" do
- def render_index(project:, page:, search_title: '')
+ def render_index(project:, page:, search_title: "")
get :index, params: {
- namespace_id: project.namespace.id,
- project_id: project.id,
- search_title: search_title,
- page: page
- }
+ namespace_id: project.namespace.id,
+ project_id: project.id,
+ search_title: search_title,
+ page: page,
+ }
end
it "queries only projects milestones" do
@@ -60,16 +60,16 @@ describe Projects::MilestonesController do
expect(milestones.where(project_id: nil)).to be_empty
end
- it 'searches milestones by title when search_title is given' do
- milestone1 = create(:milestone, title: 'Project milestone title', project: project)
+ it "searches milestones by title when search_title is given" do
+ milestone1 = create(:milestone, title: "Project milestone title", project: project)
- render_index project: project, page: 1, search_title: 'Project mile'
+ render_index project: project, page: 1, search_title: "Project mile"
milestones = assigns(:milestones)
expect(milestones).to eq([milestone1])
end
- it 'renders paginated milestones without missing or duplicates' do
+ it "renders paginated milestones without missing or duplicates" do
allow(Milestone).to receive(:default_per_page).and_return(2)
create_list(:milestone, 5, project: project)
@@ -99,10 +99,10 @@ describe Projects::MilestonesController do
let!(:group) { create(:group, :public) }
let!(:group_milestone) { create(:milestone, group: group) }
- context 'with a single group ancestor' do
+ context "with a single group ancestor" do
before do
project.update(namespace: group)
- get :index, params: { namespace_id: project.namespace.id, project_id: project.id }, format: :json
+ get :index, params: {namespace_id: project.namespace.id, project_id: project.id}, format: :json
end
it "queries projects milestones and groups milestones" do
@@ -113,13 +113,13 @@ describe Projects::MilestonesController do
end
end
- context 'with nested groups', :nested_groups do
+ context "with nested groups", :nested_groups do
let!(:subgroup) { create(:group, :public, parent: group) }
let!(:subgroup_milestone) { create(:milestone, group: subgroup) }
before do
project.update(namespace: subgroup)
- get :index, params: { namespace_id: project.namespace.id, project_id: project.id }, format: :json
+ get :index, params: {namespace_id: project.namespace.id, project_id: project.id}, format: :json
end
it "queries projects milestones and all ancestors milestones" do
@@ -136,7 +136,7 @@ describe Projects::MilestonesController do
it "removes milestone" do
expect(issue.milestone_id).to eq(milestone.id)
- delete :destroy, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }, format: :js
+ delete :destroy, params: {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}, format: :js
expect(response).to be_success
expect(Event.recent.first.action).to eq(Event::DESTROYED)
@@ -150,59 +150,59 @@ describe Projects::MilestonesController do
# Check system note left for milestone removal
last_note = project.issues.find(issue.id).notes[-1].note
- expect(last_note).to eq('removed milestone')
+ expect(last_note).to eq("removed milestone")
end
end
- describe '#promote' do
+ describe "#promote" do
let(:group) { create(:group) }
before do
project.update(namespace: group)
end
- context 'when user does not have permission to promote milestone' do
+ context "when user does not have permission to promote milestone" do
before do
group.add_guest(user)
end
- it 'renders 404' do
- post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
+ it "renders 404" do
+ post :promote, params: {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'promotion succeeds' do
+ context "promotion succeeds" do
before do
group.add_developer(user)
end
- it 'shows group milestone' do
- post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
+ it "shows group milestone" do
+ post :promote, params: {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}
expect(flash[:notice]).to eq("#{milestone.title} promoted to <a href=\"#{group_milestone_path(project.group, milestone.iid)}\"><u>group milestone</u></a>.")
expect(response).to redirect_to(project_milestones_path(project))
end
- it 'renders milestone name without parsing it as HTML' do
- milestone.update!(name: 'CCC&lt;img src=x onerror=alert(document.domain)&gt;')
+ it "renders milestone name without parsing it as HTML" do
+ milestone.update!(name: "CCC&lt;img src=x onerror=alert(document.domain)&gt;")
- post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
+ post :promote, params: {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}
expect(flash[:notice]).to eq("CCC promoted to <a href=\"#{group_milestone_path(project.group, milestone.iid)}\"><u>group milestone</u></a>.")
end
end
- context 'when user cannot admin group milestones' do
+ context "when user cannot admin group milestones" do
before do
project.add_developer(user)
end
- it 'renders 404' do
+ it "renders 404" do
project.update(namespace: user.namespace)
- post :promote, params: { namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid }
+ post :promote, params: {namespace_id: project.namespace.id, project_id: project.id, id: milestone.iid}
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/projects/mirrors_controller_spec.rb b/spec/controllers/projects/mirrors_controller_spec.rb
index 86a12a5e903..8be82ef4011 100644
--- a/spec/controllers/projects/mirrors_controller_spec.rb
+++ b/spec/controllers/projects/mirrors_controller_spec.rb
@@ -1,48 +1,48 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MirrorsController do
include ReactiveCachingHelpers
- describe 'setting up a remote mirror' do
+ describe "setting up a remote mirror" do
set(:project) { create(:project, :repository) }
- context 'when the current project is not a mirror' do
- it 'allows to create a remote mirror' do
+ context "when the current project is not a mirror" do
+ it "allows to create a remote mirror" do
sign_in(project.owner)
- expect do
- do_put(project, remote_mirrors_attributes: { '0' => { 'enabled' => 1, 'url' => 'http://foo.com' } })
- end.to change { RemoteMirror.count }.to(1)
+ expect {
+ do_put(project, remote_mirrors_attributes: {"0" => {"enabled" => 1, "url" => "http://foo.com"}})
+ }.to change { RemoteMirror.count }.to(1)
end
end
- context 'setting up SSH public-key authentication' do
+ context "setting up SSH public-key authentication" do
let(:ssh_mirror_attributes) do
{
- 'auth_method' => 'ssh_public_key',
- 'url' => 'ssh://git@example.com',
- 'ssh_known_hosts' => 'test'
+ "auth_method" => "ssh_public_key",
+ "url" => "ssh://git@example.com",
+ "ssh_known_hosts" => "test",
}
end
- it 'processes a successful update' do
+ it "processes a successful update" do
sign_in(project.owner)
- do_put(project, remote_mirrors_attributes: { '0' => ssh_mirror_attributes })
+ do_put(project, remote_mirrors_attributes: {"0" => ssh_mirror_attributes})
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-push-remote-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-push-remote-settings"))
expect(RemoteMirror.count).to eq(1)
expect(RemoteMirror.first).to have_attributes(
- auth_method: 'ssh_public_key',
- url: 'ssh://git@example.com',
+ auth_method: "ssh_public_key",
+ url: "ssh://git@example.com",
ssh_public_key: match(/\Assh-rsa /),
- ssh_known_hosts: 'test'
+ ssh_known_hosts: "test"
)
end
end
end
- describe '#update' do
+ describe "#update" do
let(:project) { create(:project, :repository, :remote_mirror) }
before do
@@ -53,42 +53,42 @@ describe Projects::MirrorsController do
Sidekiq::Testing.fake! { example.run }
end
- context 'With valid URL for a push' do
+ context "With valid URL for a push" do
let(:remote_mirror_attributes) do
- { "0" => { "enabled" => "0", url: 'https://updated.example.com' } }
+ {"0" => {"enabled" => "0", :url => "https://updated.example.com"}}
end
- it 'processes a successful update' do
+ it "processes a successful update" do
do_put(project, remote_mirrors_attributes: remote_mirror_attributes)
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-push-remote-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-push-remote-settings"))
expect(flash[:notice]).to match(/successfully updated/)
end
- it 'should create a RemoteMirror object' do
+ it "should create a RemoteMirror object" do
expect { do_put(project, remote_mirrors_attributes: remote_mirror_attributes) }.to change(RemoteMirror, :count).by(1)
end
end
- context 'With invalid URL for a push' do
+ context "With invalid URL for a push" do
let(:remote_mirror_attributes) do
- { "0" => { "enabled" => "0", url: 'ftp://invalid.invalid' } }
+ {"0" => {"enabled" => "0", :url => "ftp://invalid.invalid"}}
end
- it 'processes an unsuccessful update' do
+ it "processes an unsuccessful update" do
do_put(project, remote_mirrors_attributes: remote_mirror_attributes)
- expect(response).to redirect_to(project_settings_repository_path(project, anchor: 'js-push-remote-settings'))
+ expect(response).to redirect_to(project_settings_repository_path(project, anchor: "js-push-remote-settings"))
expect(flash[:alert]).to match(/Only allowed protocols are/)
end
- it 'should not create a RemoteMirror object' do
+ it "should not create a RemoteMirror object" do
expect { do_put(project, remote_mirrors_attributes: remote_mirror_attributes) }.not_to change(RemoteMirror, :count)
end
end
end
- describe '#ssh_host_keys', :use_clean_rails_memory_store_caching do
+ describe "#ssh_host_keys", :use_clean_rails_memory_store_caching do
let(:project) { create(:project) }
let(:cache) { SshHostKey.new(project: project, url: "ssh://example.com:22") }
@@ -96,7 +96,7 @@ describe Projects::MirrorsController do
sign_in(project.owner)
end
- context 'invalid URLs' do
+ context "invalid URLs" do
%w[
INVALID
git@example.com:foo/bar.git
@@ -106,13 +106,13 @@ describe Projects::MirrorsController do
do_get(project, url)
expect(response).to have_gitlab_http_status(400)
- expect(json_response).to eq('message' => 'Invalid URL')
+ expect(json_response).to eq("message" => "Invalid URL")
end
end
end
- context 'no data in cache' do
- it 'requests the cache to be filled and returns a 204 response' do
+ context "no data in cache" do
+ it "requests the cache to be filled and returns a 204 response" do
expect(ReactiveCachingWorker).to receive(:perform_async).with(cache.class, cache.id).at_least(:once)
do_get(project)
@@ -121,33 +121,33 @@ describe Projects::MirrorsController do
end
end
- context 'error in the cache' do
- it 'returns the error with a 400 response' do
- stub_reactive_cache(cache, error: 'An error')
+ context "error in the cache" do
+ it "returns the error with a 400 response" do
+ stub_reactive_cache(cache, error: "An error")
do_get(project)
expect(response).to have_gitlab_http_status(400)
- expect(json_response).to eq('message' => 'An error')
+ expect(json_response).to eq("message" => "An error")
end
end
- context 'data in the cache' do
- let(:ssh_key) { 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf' }
- let(:ssh_fp) { { type: 'ed25519', bits: 256, fingerprint: '2e:65:6a:c8:cf:bf:b2:8b:9a:bd:6d:9f:11:5c:12:16', index: 0 } }
+ context "data in the cache" do
+ let(:ssh_key) { "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAfuCHKVTjquxvt6CM6tdG4SLp1Btn/nOeHHE5UOzRdf" }
+ let(:ssh_fp) { {type: "ed25519", bits: 256, fingerprint: "2e:65:6a:c8:cf:bf:b2:8b:9a:bd:6d:9f:11:5c:12:16", index: 0} }
- it 'returns the data with a 200 response' do
+ it "returns the data with a 200 response" do
stub_reactive_cache(cache, known_hosts: ssh_key)
do_get(project)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq('known_hosts' => ssh_key, 'fingerprints' => [ssh_fp.stringify_keys], 'host_keys_changed' => true)
+ expect(json_response).to eq("known_hosts" => ssh_key, "fingerprints" => [ssh_fp.stringify_keys], "host_keys_changed" => true)
end
end
- def do_get(project, url = 'ssh://example.com')
- get :ssh_host_keys, params: { namespace_id: project.namespace, project_id: project, ssh_url: url }
+ def do_get(project, url = "ssh://example.com")
+ get :ssh_host_keys, params: {namespace_id: project.namespace, project_id: project, ssh_url: url}
end
end
diff --git a/spec/controllers/projects/notes_controller_spec.rb b/spec/controllers/projects/notes_controller_spec.rb
index 0b0f5117784..9fbb64561a7 100644
--- a/spec/controllers/projects/notes_controller_spec.rb
+++ b/spec/controllers/projects/notes_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::NotesController do
include ProjectForksHelper
@@ -12,18 +12,18 @@ describe Projects::NotesController do
{
namespace_id: project.namespace,
project_id: project,
- id: note
+ id: note,
}
end
- describe 'GET index' do
+ describe "GET index" do
let(:request_params) do
{
namespace_id: project.namespace,
project_id: project,
- target_type: 'issue',
+ target_type: "issue",
target_id: issue.id,
- format: 'json'
+ format: "json",
}
end
@@ -35,10 +35,10 @@ describe Projects::NotesController do
project.add_developer(user)
end
- it 'passes last_fetched_at from headers to NotesFinder' do
+ it "passes last_fetched_at from headers to NotesFinder" do
last_fetched_at = 3.hours.ago.to_i
- request.headers['X-Last-Fetched-At'] = last_fetched_at
+ request.headers["X-Last-Fetched-At"] = last_fetched_at
expect(NotesFinder).to receive(:new)
.with(anything, anything, hash_including(last_fetched_at: last_fetched_at))
@@ -47,12 +47,12 @@ describe Projects::NotesController do
get :index, params: request_params
end
- context 'when user notes_filter is present' do
+ context "when user notes_filter is present" do
let(:notes_json) { parsed_response[:notes] }
let!(:comment) { create(:note, noteable: issue, project: project) }
let!(:system_note) { create(:note, noteable: issue, project: project, system: true) }
- it 'filters system notes by comments' do
+ it "filters system notes by comments" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issue)
get :index, params: request_params
@@ -61,7 +61,7 @@ describe Projects::NotesController do
expect(notes_json.first[:id].to_i).to eq(comment.id)
end
- it 'returns all notes' do
+ it "returns all notes" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:all_notes], issue)
get :index, params: request_params
@@ -69,7 +69,7 @@ describe Projects::NotesController do
expect(notes_json.map { |note| note[:id].to_i }).to contain_exactly(comment.id, system_note.id)
end
- it 'does not merge label event notes' do
+ it "does not merge label event notes" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issue)
expect(ResourceEvents::MergeIntoNotesService).not_to receive(:new)
@@ -78,13 +78,13 @@ describe Projects::NotesController do
end
end
- context 'for a discussion note' do
+ context "for a discussion note" do
let(:project) { create(:project, :repository) }
let!(:note) { create(:discussion_note_on_merge_request, project: project) }
- let(:params) { request_params.merge(target_type: 'merge_request', target_id: note.noteable_id, html: true) }
+ let(:params) { request_params.merge(target_type: "merge_request", target_id: note.noteable_id, html: true) }
- it 'responds with the expected attributes' do
+ it "responds with the expected attributes" do
get :index, params: params
expect(note_json[:id]).to eq(note.id)
@@ -94,13 +94,13 @@ describe Projects::NotesController do
end
end
- context 'for a diff discussion note' do
+ context "for a diff discussion note" do
let(:project) { create(:project, :repository) }
let!(:note) { create(:diff_note_on_merge_request, project: project) }
- let(:params) { request_params.merge(target_type: 'merge_request', target_id: note.noteable_id, html: true) }
+ let(:params) { request_params.merge(target_type: "merge_request", target_id: note.noteable_id, html: true) }
- it 'responds with the expected attributes' do
+ it "responds with the expected attributes" do
get :index, params: params
expect(note_json[:id]).to eq(note.id)
@@ -110,16 +110,16 @@ describe Projects::NotesController do
end
end
- context 'for a commit note' do
+ context "for a commit note" do
let(:project) { create(:project, :repository) }
let!(:note) { create(:note_on_commit, project: project) }
- context 'when displayed on a merge request' do
+ context "when displayed on a merge request" do
let(:merge_request) { create(:merge_request, source_project: project) }
- let(:params) { request_params.merge(target_type: 'merge_request', target_id: merge_request.id, html: true) }
+ let(:params) { request_params.merge(target_type: "merge_request", target_id: merge_request.id, html: true) }
- it 'responds with the expected attributes' do
+ it "responds with the expected attributes" do
get :index, params: params
expect(note_json[:id]).to eq(note.id)
@@ -129,10 +129,10 @@ describe Projects::NotesController do
end
end
- context 'when displayed on the commit' do
- let(:params) { request_params.merge(target_type: 'commit', target_id: note.commit_id, html: true) }
+ context "when displayed on the commit" do
+ let(:params) { request_params.merge(target_type: "commit", target_id: note.commit_id, html: true) }
- it 'responds with the expected attributes' do
+ it "responds with the expected attributes" do
get :index, params: params
expect(note_json[:id]).to eq(note.id)
@@ -141,13 +141,13 @@ describe Projects::NotesController do
expect(note_json[:discussion_line_code]).to be_nil
end
- context 'when user cannot read commit' do
+ context "when user cannot read commit" do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :download_code, project).and_return(false)
end
- it 'renders 404' do
+ it "renders 404" do
get :index, params: params
expect(response).to have_gitlab_http_status(404)
@@ -156,12 +156,12 @@ describe Projects::NotesController do
end
end
- context 'for a regular note' do
+ context "for a regular note" do
let!(:note) { create(:note_on_merge_request, project: project) }
- let(:params) { request_params.merge(target_type: 'merge_request', target_id: note.noteable_id, html: true) }
+ let(:params) { request_params.merge(target_type: "merge_request", target_id: note.noteable_id, html: true) }
- it 'responds with the expected attributes' do
+ it "responds with the expected attributes" do
get :index, params: params
expect(note_json[:id]).to eq(note.id)
@@ -172,7 +172,7 @@ describe Projects::NotesController do
end
end
- context 'with cross-reference system note', :request_store do
+ context "with cross-reference system note", :request_store do
let(:new_issue) { create(:issue) }
let(:cross_reference) { "mentioned in #{new_issue.to_reference(issue.project)}" }
@@ -181,22 +181,22 @@ describe Projects::NotesController do
create(:discussion_note_on_issue, :system, noteable: issue, project: issue.project, note: cross_reference)
end
- it 'filters notes that the user should not see' do
+ it "filters notes that the user should not see" do
get :index, params: request_params
expect(parsed_response[:notes].count).to eq(1)
expect(note_json[:id]).to eq(note.id.to_s)
end
- it 'does not result in N+1 queries' do
+ it "does not result in N+1 queries" do
# Instantiate the controller variables to ensure QueryRecorder has an accurate base count
get :index, params: request_params
RequestStore.clear!
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
get :index, params: request_params
- end.count
+ }.count
RequestStore.clear!
@@ -207,17 +207,17 @@ describe Projects::NotesController do
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
let(:request_params) do
{
- note: { note: 'some note', noteable_id: merge_request.id, noteable_type: 'MergeRequest' },
+ note: {note: "some note", noteable_id: merge_request.id, noteable_type: "MergeRequest"},
namespace_id: project.namespace,
project_id: project,
- merge_request_diff_head_sha: 'sha',
- target_type: 'merge_request',
- target_id: merge_request.id
+ merge_request_diff_head_sha: "sha",
+ target_type: "merge_request",
+ target_id: merge_request.id,
}
end
@@ -238,22 +238,22 @@ describe Projects::NotesController do
expect(response).to have_gitlab_http_status(200)
end
- it 'returns discussion JSON when the return_discussion param is set' do
- post :create, params: request_params.merge(format: :json, return_discussion: 'true')
+ it "returns discussion JSON when the return_discussion param is set" do
+ post :create, params: request_params.merge(format: :json, return_discussion: "true")
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to have_key 'discussion'
- expect(json_response['discussion']['notes'][0]['note']).to eq(request_params[:note][:note])
+ expect(json_response).to have_key "discussion"
+ expect(json_response["discussion"]["notes"][0]["note"]).to eq(request_params[:note][:note])
end
- context 'when merge_request_diff_head_sha present' do
+ context "when merge_request_diff_head_sha present" do
before do
service_params = ActionController::Parameters.new({
- note: 'some note',
+ note: "some note",
noteable_id: merge_request.id.to_s,
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
commit_id: nil,
- merge_request_diff_head_sha: 'sha'
+ merge_request_diff_head_sha: "sha",
}).permit!
expect(Notes::CreateService).to receive(:new).with(project, user, service_params).and_return(double(execute: true))
@@ -266,23 +266,23 @@ describe Projects::NotesController do
end
end
- context 'when creating a comment on a commit with SHA1 starting with a large number' do
- let(:commit) { create(:commit, project: project, id: '842616594688d2351480dfebd67b3d8d15571e6d') }
+ context "when creating a comment on a commit with SHA1 starting with a large number" do
+ let(:commit) { create(:commit, project: project, id: "842616594688d2351480dfebd67b3d8d15571e6d") }
- it 'creates a note successfully' do
- expect do
+ it "creates a note successfully" do
+ expect {
post :create, params: {
- note: { note: 'some note', commit_id: commit.id },
+ note: {note: "some note", commit_id: commit.id},
namespace_id: project.namespace,
project_id: project,
- target_type: 'commit',
- target_id: commit.id
+ target_type: "commit",
+ target_id: commit.id,
}
- end.to change { Note.count }.by(1)
+ }.to change { Note.count }.by(1)
end
end
- context 'when creating a commit comment from an MR fork' do
+ context "when creating a commit comment from an MR fork" do
let(:project) { create(:project, :repository) }
let(:forked_project) do
@@ -290,42 +290,42 @@ describe Projects::NotesController do
end
let(:merge_request) do
- create(:merge_request, source_project: forked_project, target_project: project, source_branch: 'feature', target_branch: 'master')
+ create(:merge_request, source_project: forked_project, target_project: project, source_branch: "feature", target_branch: "master")
end
let(:existing_comment) do
- create(:note_on_commit, note: 'a note', project: forked_project, commit_id: merge_request.commit_shas.first)
+ create(:note_on_commit, note: "a note", project: forked_project, commit_id: merge_request.commit_shas.first)
end
def post_create(extra_params = {})
post :create, params: {
- note: { note: 'some other note', noteable_id: merge_request.id },
+ note: {note: "some other note", noteable_id: merge_request.id},
namespace_id: project.namespace,
project_id: project,
- target_type: 'merge_request',
+ target_type: "merge_request",
target_id: merge_request.id,
note_project_id: forked_project.id,
- in_reply_to_discussion_id: existing_comment.discussion_id
+ in_reply_to_discussion_id: existing_comment.discussion_id,
}.merge(extra_params)
end
- context 'when the note_project_id is not correct' do
- it 'returns a 404' do
+ context "when the note_project_id is not correct" do
+ it "returns a 404" do
post_create(note_project_id: Project.maximum(:id).succ)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the user has no access to the fork' do
- it 'returns a 404' do
+ context "when the user has no access to the fork" do
+ it "returns a 404" do
post_create
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when the user has access to the fork' do
+ context "when the user has access to the fork" do
let(:discussion) { forked_project.notes.find_discussion(existing_comment.discussion_id) }
before do
@@ -334,13 +334,13 @@ describe Projects::NotesController do
existing_comment
end
- it 'creates the note' do
+ it "creates the note" do
expect { post_create }.to change { forked_project.notes.count }.by(1)
end
end
end
- context 'when target_id and noteable_id do not match' do
+ context "when target_id and noteable_id do not match" do
let(:locked_issue) { create(:issue, :locked, project: project) }
let(:issue) {create(:issue, project: project)}
@@ -349,13 +349,13 @@ describe Projects::NotesController do
project.project_member(user).destroy
end
- it 'uses target_id and ignores noteable_id' do
+ it "uses target_id and ignores noteable_id" do
request_params = {
- note: { note: 'some note', noteable_type: 'Issue', noteable_id: locked_issue.id },
- target_type: 'issue',
+ note: {note: "some note", noteable_type: "Issue", noteable_id: locked_issue.id},
+ target_type: "issue",
target_id: issue.id,
project_id: project,
- namespace_id: project.namespace
+ namespace_id: project.namespace,
}
expect { post :create, params: request_params }.to change { issue.notes.count }.by(1)
@@ -364,14 +364,14 @@ describe Projects::NotesController do
end
end
- context 'when the merge request discussion is locked' do
+ context "when the merge request discussion is locked" do
before do
project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
merge_request.update_attribute(:discussion_locked, true)
end
- context 'when a noteable is not found' do
- it 'returns 404 status' do
+ context "when a noteable is not found" do
+ it "returns 404 status" do
request_params[:target_id] = 9999
post :create, params: request_params.merge(format: :json)
@@ -379,43 +379,43 @@ describe Projects::NotesController do
end
end
- context 'when a user is a team member' do
- it 'returns 302 status for html' do
+ context "when a user is a team member" do
+ it "returns 302 status for html" do
post :create, params: request_params
expect(response).to have_gitlab_http_status(302)
end
- it 'returns 200 status for json' do
+ it "returns 200 status for json" do
post :create, params: request_params.merge(format: :json)
expect(response).to have_gitlab_http_status(200)
end
- it 'creates a new note' do
+ it "creates a new note" do
expect { post :create, params: request_params }.to change { Note.count }.by(1)
end
end
- context 'when a user is not a team member' do
+ context "when a user is not a team member" do
before do
project.project_member(user).destroy
end
- it 'returns 404 status' do
+ it "returns 404 status" do
post :create, params: request_params
expect(response).to have_gitlab_http_status(404)
end
- it 'does not create a new note' do
+ it "does not create a new note" do
expect { post :create, params: request_params }.not_to change { Note.count }
end
end
end
end
- describe 'PUT update' do
+ describe "PUT update" do
context "should update the note with a valid issue" do
let(:request_params) do
{
@@ -424,8 +424,8 @@ describe Projects::NotesController do
id: note,
format: :json,
note: {
- note: "New comment"
- }
+ note: "New comment",
+ },
}
end
@@ -454,8 +454,8 @@ describe Projects::NotesController do
id: note,
format: :json,
note: {
- note: "New comment"
- }
+ note: "New comment",
+ },
}
expect { put :update, params: request_params }.not_to change { note.reload.note }
expect(response).to have_gitlab_http_status(404)
@@ -463,17 +463,17 @@ describe Projects::NotesController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:request_params) do
{
- namespace_id: project.namespace,
- project_id: project,
- id: note,
- format: :js
+ namespace_id: project.namespace,
+ project_id: project,
+ id: note,
+ format: :js,
}
end
- context 'user is the author of a note' do
+ context "user is the author of a note" do
before do
sign_in(note.author)
project.add_developer(note.author)
@@ -490,7 +490,7 @@ describe Projects::NotesController do
end
end
- context 'user is not the author of a note' do
+ context "user is not the author of a note" do
before do
sign_in(user)
project.add_developer(user)
@@ -504,16 +504,16 @@ describe Projects::NotesController do
end
end
- describe 'POST toggle_award_emoji' do
+ describe "POST toggle_award_emoji" do
before do
sign_in(user)
project.add_developer(user)
end
it "toggles the award emoji" do
- expect do
+ expect {
post(:toggle_award_emoji, params: request_params.merge(name: "thumbsup"))
- end.to change { note.award_emoji.count }.by(1)
+ }.to change { note.award_emoji.count }.by(1)
expect(response).to have_gitlab_http_status(200)
end
@@ -521,9 +521,9 @@ describe Projects::NotesController do
it "removes the already awarded emoji" do
post(:toggle_award_emoji, params: request_params.merge(name: "thumbsup"))
- expect do
+ expect {
post(:toggle_award_emoji, params: request_params.merge(name: "thumbsup"))
- end.to change { AwardEmoji.count }.by(-1)
+ }.to change { AwardEmoji.count }.by(-1)
expect(response).to have_gitlab_http_status(200)
end
@@ -534,7 +534,7 @@ describe Projects::NotesController do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
- describe 'POST resolve' do
+ describe "POST resolve" do
before do
sign_in user
end
@@ -593,7 +593,7 @@ describe Projects::NotesController do
end
end
- describe 'DELETE unresolve' do
+ describe "DELETE unresolve" do
before do
sign_in user
diff --git a/spec/controllers/projects/pages_controller_spec.rb b/spec/controllers/projects/pages_controller_spec.rb
index d6eece47804..9dd690a9094 100644
--- a/spec/controllers/projects/pages_controller_spec.rb
+++ b/spec/controllers/projects/pages_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PagesController do
let(:user) { create(:user) }
@@ -7,7 +7,7 @@ describe Projects::PagesController do
let(:request_params) do
{
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
end
@@ -17,18 +17,18 @@ describe Projects::PagesController do
project.add_maintainer(user)
end
- describe 'GET show' do
- it 'returns 200 status' do
+ describe "GET show" do
+ it "returns 200 status" do
get :show, params: request_params
expect(response).to have_gitlab_http_status(200)
end
- context 'when the project is in a subgroup' do
+ context "when the project is in a subgroup" do
let(:group) { create(:group, :nested) }
let(:project) { create(:project, namespace: group) }
- it 'returns a 200 status code' do
+ it "returns a 200 status code" do
get :show, params: request_params
expect(response).to have_gitlab_http_status(200)
@@ -36,19 +36,19 @@ describe Projects::PagesController do
end
end
- describe 'DELETE destroy' do
- it 'returns 302 status' do
+ describe "DELETE destroy" do
+ it "returns 302 status" do
delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(302)
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- it 'returns 404 status' do
+ it "returns 404 status" do
delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(404)
@@ -56,21 +56,21 @@ describe Projects::PagesController do
end
end
- context 'pages disabled' do
+ context "pages disabled" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
end
- describe 'GET show' do
- it 'returns 404 status' do
+ describe "GET show" do
+ it "returns 404 status" do
get :show, params: request_params
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'DELETE destroy' do
- it 'returns 404 status' do
+ describe "DELETE destroy" do
+ it "returns 404 status" do
delete :destroy, params: request_params
expect(response).to have_gitlab_http_status(404)
@@ -78,34 +78,34 @@ describe Projects::PagesController do
end
end
- describe 'PATCH update' do
+ describe "PATCH update" do
let(:request_params) do
{
namespace_id: project.namespace,
project_id: project,
- project: { pages_https_only: 'false' }
+ project: {pages_https_only: "false"},
}
end
- let(:update_service) { double(execute: { status: :success }) }
+ let(:update_service) { double(execute: {status: :success}) }
before do
allow(Projects::UpdateService).to receive(:new) { update_service }
end
- it 'returns 302 status' do
+ it "returns 302 status" do
patch :update, params: request_params
expect(response).to have_gitlab_http_status(:found)
end
- it 'redirects back to the pages settings' do
+ it "redirects back to the pages settings" do
patch :update, params: request_params
expect(response).to redirect_to(project_pages_path(project))
end
- it 'calls the update service' do
+ it "calls the update service" do
expect(Projects::UpdateService)
.to receive(:new)
.with(project, user, ActionController::Parameters.new(request_params[:project]).permit!)
diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb
index ffb9867a203..0190e800300 100644
--- a/spec/controllers/projects/pages_domains_controller_spec.rb
+++ b/spec/controllers/projects/pages_domains_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PagesDomainsController do
let(:user) { create(:user) }
@@ -8,12 +8,12 @@ describe Projects::PagesDomainsController do
let(:request_params) do
{
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
}
end
let(:pages_domain_params) do
- build(:pages_domain, domain: 'my.otherdomain.com').slice(:key, :certificate, :domain)
+ build(:pages_domain, domain: "my.otherdomain.com").slice(:key, :certificate, :domain)
end
before do
@@ -22,7 +22,7 @@ describe Projects::PagesDomainsController do
project.add_maintainer(user)
end
- describe 'GET show' do
+ describe "GET show" do
def make_request
get(:show, params: request_params.merge(id: pages_domain.domain))
end
@@ -30,15 +30,15 @@ describe Projects::PagesDomainsController do
it "displays the 'show' page" do
make_request
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('show')
+ expect(response).to render_template("show")
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- it 'renders 404 page' do
+ it "renders 404 page" do
make_request
expect(response).to have_gitlab_http_status(404)
@@ -46,20 +46,20 @@ describe Projects::PagesDomainsController do
end
end
- describe 'GET new' do
+ describe "GET new" do
it "displays the 'new' page" do
get(:new, params: request_params)
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('new')
+ expect(response).to render_template("new")
end
end
- describe 'POST create' do
+ describe "POST create" do
it "creates a new pages domain" do
- expect do
+ expect {
post(:create, params: request_params.merge(pages_domain: pages_domain_params))
- end.to change { PagesDomain.count }.by(1)
+ }.to change { PagesDomain.count }.by(1)
created_domain = PagesDomain.reorder(:id).last
@@ -68,16 +68,16 @@ describe Projects::PagesDomainsController do
end
end
- describe 'GET edit' do
+ describe "GET edit" do
it "displays the 'edit' page" do
get(:edit, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('edit')
+ expect(response).to render_template("edit")
end
end
- describe 'PATCH update' do
+ describe "PATCH update" do
before do
controller.instance_variable_set(:@domain, pages_domain)
end
@@ -90,7 +90,7 @@ describe Projects::PagesDomainsController do
request_params.merge(id: pages_domain.domain, pages_domain: pages_domain_params)
end
- it 'updates the domain' do
+ it "updates the domain" do
expect(pages_domain)
.to receive(:update)
.with(ActionController::Parameters.new(pages_domain_params).permit!)
@@ -99,36 +99,36 @@ describe Projects::PagesDomainsController do
patch(:update, params: params)
end
- it 'redirects to the project page' do
+ it "redirects to the project page" do
patch(:update, params: params)
- expect(flash[:notice]).to eq 'Domain was updated'
+ expect(flash[:notice]).to eq "Domain was updated"
expect(response).to redirect_to(project_pages_path(project))
end
- context 'the domain is invalid' do
- it 'renders the edit action' do
+ context "the domain is invalid" do
+ it "renders the edit action" do
allow(pages_domain).to receive(:update).and_return(false)
patch(:update, params: params)
- expect(response).to render_template('edit')
+ expect(response).to render_template("edit")
end
end
- context 'the parameters include the domain' do
- it 'renders 400 Bad Request' do
+ context "the parameters include the domain" do
+ it "renders 400 Bad Request" do
expect(pages_domain)
.to receive(:update)
.with(hash_not_including(:domain))
.and_return(true)
- patch(:update, params: params.deep_merge(pages_domain: { domain: 'abc' }))
+ patch(:update, params: params.deep_merge(pages_domain: {domain: "abc"}))
end
end
end
- describe 'POST verify' do
+ describe "POST verify" do
let(:params) { request_params.merge(id: pages_domain.domain) }
def stub_service
@@ -139,63 +139,63 @@ describe Projects::PagesDomainsController do
service
end
- it 'handles verification success' do
+ it "handles verification success" do
expect(stub_service).to receive(:execute).and_return(status: :success)
post :verify, params: params
expect(response).to redirect_to project_pages_domain_path(project, pages_domain)
- expect(flash[:notice]).to eq('Successfully verified domain ownership')
+ expect(flash[:notice]).to eq("Successfully verified domain ownership")
end
- it 'handles verification failure' do
+ it "handles verification failure" do
expect(stub_service).to receive(:execute).and_return(status: :failed)
post :verify, params: params
expect(response).to redirect_to project_pages_domain_path(project, pages_domain)
- expect(flash[:alert]).to eq('Failed to verify domain ownership')
+ expect(flash[:alert]).to eq("Failed to verify domain ownership")
end
- it 'returns a 404 response for an unknown domain' do
- post :verify, params: request_params.merge(id: 'unknown-domain')
+ it "returns a 404 response for an unknown domain" do
+ post :verify, params: request_params.merge(id: "unknown-domain")
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
it "deletes the pages domain" do
- expect do
+ expect {
delete(:destroy, params: request_params.merge(id: pages_domain.domain))
- end.to change { PagesDomain.count }.by(-1)
+ }.to change { PagesDomain.count }.by(-1)
expect(response).to redirect_to(project_pages_path(project))
end
end
- context 'pages disabled' do
+ context "pages disabled" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
end
- describe 'GET show' do
- it 'returns 404 status' do
+ describe "GET show" do
+ it "returns 404 status" do
get(:show, params: request_params.merge(id: pages_domain.domain))
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET new' do
- it 'returns 404 status' do
+ describe "GET new" do
+ it "returns 404 status" do
get :new, params: request_params
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'POST create' do
+ describe "POST create" do
it "returns 404 status" do
post(:create, params: request_params.merge(pages_domain: pages_domain_params))
@@ -203,7 +203,7 @@ describe Projects::PagesDomainsController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
it "deletes the pages domain" do
delete(:destroy, params: request_params.merge(id: pages_domain.domain))
diff --git a/spec/controllers/projects/pipeline_schedules_controller_spec.rb b/spec/controllers/projects/pipeline_schedules_controller_spec.rb
index fa732437fc1..05764ef4a15 100644
--- a/spec/controllers/projects/pipeline_schedules_controller_spec.rb
+++ b/spec/controllers/projects/pipeline_schedules_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PipelineSchedulesController do
include AccessMatchersForController
@@ -11,7 +11,7 @@ describe Projects::PipelineSchedulesController do
project.add_developer(user)
end
- describe 'GET #index' do
+ describe "GET #index" do
render_views
let(:scope) { nil }
@@ -23,14 +23,14 @@ describe Projects::PipelineSchedulesController do
sign_in(user)
end
- it 'renders the index view' do
+ it "renders the index view" do
visit_pipelines_schedules
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:index)
end
- it 'avoids N + 1 queries', :request_store do
+ it "avoids N + 1 queries", :request_store do
control_count = ActiveRecord::QueryRecorder.new { visit_pipelines_schedules }.count
create_list(:ci_pipeline_schedule, 2, project: project)
@@ -38,14 +38,14 @@ describe Projects::PipelineSchedulesController do
expect { visit_pipelines_schedules }.not_to exceed_query_limit(control_count)
end
- context 'when the scope is set to active' do
- let(:scope) { 'active' }
+ context "when the scope is set to active" do
+ let(:scope) { "active" }
before do
visit_pipelines_schedules
end
- it 'only shows active pipeline schedules' do
+ it "only shows active pipeline schedules" do
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:schedules)).to include(pipeline_schedule)
expect(assigns(:schedules)).not_to include(inactive_pipeline_schedule)
@@ -53,11 +53,11 @@ describe Projects::PipelineSchedulesController do
end
def visit_pipelines_schedules
- get :index, params: { namespace_id: project.namespace.to_param, project_id: project, scope: scope }
+ get :index, params: {namespace_id: project.namespace.to_param, project_id: project, scope: scope}
end
end
- describe 'GET #new' do
+ describe "GET #new" do
set(:user) { create(:user) }
before do
@@ -65,16 +65,16 @@ describe Projects::PipelineSchedulesController do
sign_in(user)
end
- it 'initializes a pipeline schedule model' do
- get :new, params: { namespace_id: project.namespace.to_param, project_id: project }
+ it "initializes a pipeline schedule model" do
+ get :new, params: {namespace_id: project.namespace.to_param, project_id: project}
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:schedule)).to be_a_new(Ci::PipelineSchedule)
end
end
- describe 'POST #create' do
- describe 'functionality' do
+ describe "POST #create" do
+ describe "functionality" do
set(:user) { create(:user) }
before do
@@ -86,14 +86,14 @@ describe Projects::PipelineSchedulesController do
attributes_for(:ci_pipeline_schedule)
end
- context 'when variables_attributes has one variable' do
+ context "when variables_attributes has one variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
+ variables_attributes: [{key: "AAA", secret_value: "AAA123"}],
})
end
- it 'creates a new schedule' do
+ it "creates a new schedule" do
expect { go }
.to change { Ci::PipelineSchedule.count }.by(1)
.and change { Ci::PipelineScheduleVariable.count }.by(1)
@@ -107,25 +107,25 @@ describe Projects::PipelineSchedulesController do
end
end
- context 'when variables_attributes has two variables and duplicated' do
+ context "when variables_attributes has two variables and duplicated" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' },
- { key: 'AAA', secret_value: 'BBB123' }]
+ variables_attributes: [{key: "AAA", secret_value: "AAA123"},
+ {key: "AAA", secret_value: "BBB123"},],
})
end
- it 'returns an error that the keys of variable are duplicated' do
+ it "returns an error that the keys of variable are duplicated" do
expect { go }
.to change { Ci::PipelineSchedule.count }.by(0)
.and change { Ci::PipelineScheduleVariable.count }.by(0)
- expect(assigns(:schedule).errors['variables']).not_to be_empty
+ expect(assigns(:schedule).errors["variables"]).not_to be_empty
end
end
end
- describe 'security' do
+ describe "security" do
let(:schedule) { attributes_for(:ci_pipeline_schedule) }
it { expect { go }.to be_allowed_for(:admin) }
@@ -140,12 +140,12 @@ describe Projects::PipelineSchedulesController do
end
def go
- post :create, params: { namespace_id: project.namespace.to_param, project_id: project, schedule: schedule }
+ post :create, params: {namespace_id: project.namespace.to_param, project_id: project, schedule: schedule}
end
end
- describe 'PUT #update' do
- describe 'functionality' do
+ describe "PUT #update" do
+ describe "functionality" do
set(:user) { create(:user) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: user) }
@@ -154,132 +154,132 @@ describe Projects::PipelineSchedulesController do
sign_in(user)
end
- context 'when a pipeline schedule has no variables' do
+ context "when a pipeline schedule has no variables" do
let(:basic_param) do
- { description: 'updated_desc', cron: '0 1 * * *', cron_timezone: 'UTC', ref: 'patch-x', active: true }
+ {description: "updated_desc", cron: "0 1 * * *", cron_timezone: "UTC", ref: "patch-x", active: true}
end
- context 'when params include one variable' do
+ context "when params include one variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
+ variables_attributes: [{key: "AAA", secret_value: "AAA123"}],
})
end
- it 'inserts new variable to the pipeline schedule' do
+ it "inserts new variable to the pipeline schedule" do
expect { go }.to change { Ci::PipelineScheduleVariable.count }.by(1)
pipeline_schedule.reload
expect(response).to have_gitlab_http_status(:found)
- expect(pipeline_schedule.variables.last.key).to eq('AAA')
- expect(pipeline_schedule.variables.last.value).to eq('AAA123')
+ expect(pipeline_schedule.variables.last.key).to eq("AAA")
+ expect(pipeline_schedule.variables.last.value).to eq("AAA123")
end
end
- context 'when params include two duplicated variables' do
+ context "when params include two duplicated variables" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' },
- { key: 'AAA', secret_value: 'BBB123' }]
+ variables_attributes: [{key: "AAA", secret_value: "AAA123"},
+ {key: "AAA", secret_value: "BBB123"},],
})
end
- it 'returns an error that variables are duplciated' do
+ it "returns an error that variables are duplciated" do
go
- expect(assigns(:schedule).errors['variables']).not_to be_empty
+ expect(assigns(:schedule).errors["variables"]).not_to be_empty
end
end
end
- context 'when a pipeline schedule has one variable' do
+ context "when a pipeline schedule has one variable" do
let(:basic_param) do
- { description: 'updated_desc', cron: '0 1 * * *', cron_timezone: 'UTC', ref: 'patch-x', active: true }
+ {description: "updated_desc", cron: "0 1 * * *", cron_timezone: "UTC", ref: "patch-x", active: true}
end
let!(:pipeline_schedule_variable) do
create(:ci_pipeline_schedule_variable,
- key: 'CCC', pipeline_schedule: pipeline_schedule)
+ key: "CCC", pipeline_schedule: pipeline_schedule)
end
- context 'when adds a new variable' do
+ context "when adds a new variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'AAA', secret_value: 'AAA123' }]
+ variables_attributes: [{key: "AAA", secret_value: "AAA123"}],
})
end
- it 'adds the new variable' do
+ it "adds the new variable" do
expect { go }.to change { Ci::PipelineScheduleVariable.count }.by(1)
pipeline_schedule.reload
- expect(pipeline_schedule.variables.last.key).to eq('AAA')
+ expect(pipeline_schedule.variables.last.key).to eq("AAA")
end
end
- context 'when adds a new duplicated variable' do
+ context "when adds a new duplicated variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ key: 'CCC', secret_value: 'AAA123' }]
+ variables_attributes: [{key: "CCC", secret_value: "AAA123"}],
})
end
- it 'returns an error' do
+ it "returns an error" do
expect { go }.not_to change { Ci::PipelineScheduleVariable.count }
pipeline_schedule.reload
- expect(assigns(:schedule).errors['variables']).not_to be_empty
+ expect(assigns(:schedule).errors["variables"]).not_to be_empty
end
end
- context 'when updates a variable' do
+ context "when updates a variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ id: pipeline_schedule_variable.id, secret_value: 'new_value' }]
+ variables_attributes: [{id: pipeline_schedule_variable.id, secret_value: "new_value"}],
})
end
- it 'updates the variable' do
+ it "updates the variable" do
expect { go }.not_to change { Ci::PipelineScheduleVariable.count }
pipeline_schedule_variable.reload
- expect(pipeline_schedule_variable.value).to eq('new_value')
+ expect(pipeline_schedule_variable.value).to eq("new_value")
end
end
- context 'when deletes a variable' do
+ context "when deletes a variable" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ id: pipeline_schedule_variable.id, _destroy: true }]
+ variables_attributes: [{id: pipeline_schedule_variable.id, _destroy: true}],
})
end
- it 'delete the existsed variable' do
+ it "delete the existsed variable" do
expect { go }.to change { Ci::PipelineScheduleVariable.count }.by(-1)
end
end
- context 'when deletes and creates a same key simultaneously' do
+ context "when deletes and creates a same key simultaneously" do
let(:schedule) do
basic_param.merge({
- variables_attributes: [{ id: pipeline_schedule_variable.id, _destroy: true },
- { key: 'CCC', secret_value: 'CCC123' }]
+ variables_attributes: [{id: pipeline_schedule_variable.id, _destroy: true},
+ {key: "CCC", secret_value: "CCC123"},],
})
end
- it 'updates the variable' do
+ it "updates the variable" do
expect { go }.not_to change { Ci::PipelineScheduleVariable.count }
pipeline_schedule.reload
- expect(pipeline_schedule.variables.last.key).to eq('CCC')
- expect(pipeline_schedule.variables.last.value).to eq('CCC123')
+ expect(pipeline_schedule.variables.last.key).to eq("CCC")
+ expect(pipeline_schedule.variables.last.value).to eq("CCC123")
end
end
end
end
- describe 'security' do
- let(:schedule) { { description: 'updated_desc' } }
+ describe "security" do
+ let(:schedule) { {description: "updated_desc"} }
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
@@ -291,7 +291,7 @@ describe Projects::PipelineSchedulesController do
it { expect { go }.to be_denied_for(:external) }
it { expect { go }.to be_denied_for(:visitor) }
- context 'when a developer created a pipeline schedule' do
+ context "when a developer created a pipeline schedule" do
let(:developer_1) { create(:user) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: developer_1) }
@@ -304,7 +304,7 @@ describe Projects::PipelineSchedulesController do
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
end
- context 'when a maintainer created a pipeline schedule' do
+ context "when a maintainer created a pipeline schedule" do
let(:maintainer_1) { create(:user) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: maintainer_1) }
@@ -319,16 +319,16 @@ describe Projects::PipelineSchedulesController do
end
def go
- put :update, params: { namespace_id: project.namespace.to_param,
- project_id: project,
- id: pipeline_schedule,
- schedule: schedule },
+ put :update, params: {namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: pipeline_schedule,
+ schedule: schedule,},
as: :html
end
end
- describe 'GET #edit' do
- describe 'functionality' do
+ describe "GET #edit" do
+ describe "functionality" do
let(:user) { create(:user) }
before do
@@ -336,15 +336,15 @@ describe Projects::PipelineSchedulesController do
sign_in(user)
end
- it 'loads the pipeline schedule' do
- get :edit, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ it "loads the pipeline schedule" do
+ get :edit, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
expect(response).to have_gitlab_http_status(:ok)
expect(assigns(:schedule)).to eq(pipeline_schedule)
end
end
- describe 'security' do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
@@ -357,12 +357,12 @@ describe Projects::PipelineSchedulesController do
end
def go
- get :edit, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ get :edit, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
end
end
- describe 'GET #take_ownership' do
- describe 'security' do
+ describe "GET #take_ownership" do
+ describe "security" do
it { expect { go }.to be_allowed_for(:admin) }
it { expect { go }.to be_allowed_for(:owner).of(project) }
it { expect { go }.to be_allowed_for(:maintainer).of(project) }
@@ -375,13 +375,13 @@ describe Projects::PipelineSchedulesController do
end
def go
- post :take_ownership, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ post :take_ownership, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
end
end
- describe 'POST #play', :clean_gitlab_redis_cache do
+ describe "POST #play", :clean_gitlab_redis_cache do
set(:user) { create(:user) }
- let(:ref) { 'master' }
+ let(:ref) { "master" }
before do
project.add_developer(user)
@@ -389,81 +389,81 @@ describe Projects::PipelineSchedulesController do
sign_in(user)
end
- context 'when an anonymous user makes the request' do
+ context "when an anonymous user makes the request" do
before do
sign_out(user)
end
- it 'does not allow pipeline to be executed' do
+ it "does not allow pipeline to be executed" do
expect(RunPipelineScheduleWorker).not_to receive(:perform_async)
- post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ post :play, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when a developer makes the request' do
- it 'executes a new pipeline' do
- expect(RunPipelineScheduleWorker).to receive(:perform_async).with(pipeline_schedule.id, user.id).and_return('job-123')
+ context "when a developer makes the request" do
+ it "executes a new pipeline" do
+ expect(RunPipelineScheduleWorker).to receive(:perform_async).with(pipeline_schedule.id, user.id).and_return("job-123")
- post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ post :play, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
- expect(flash[:notice]).to start_with 'Successfully scheduled a pipeline to run'
+ expect(flash[:notice]).to start_with "Successfully scheduled a pipeline to run"
expect(response).to have_gitlab_http_status(302)
end
- it 'prevents users from scheduling the same pipeline repeatedly' do
+ it "prevents users from scheduling the same pipeline repeatedly" do
2.times do
- post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ post :play, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
end
expect(flash.to_a.size).to eq(2)
- expect(flash[:alert]).to eq 'You cannot play this scheduled pipeline at the moment. Please wait a minute.'
+ expect(flash[:alert]).to eq "You cannot play this scheduled pipeline at the moment. Please wait a minute."
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when a developer attempts to schedule a protected ref' do
- it 'does not allow pipeline to be executed' do
+ context "when a developer attempts to schedule a protected ref" do
+ it "does not allow pipeline to be executed" do
create(:protected_branch, project: project, name: ref)
protected_schedule = create(:ci_pipeline_schedule, project: project, ref: ref)
expect(RunPipelineScheduleWorker).not_to receive(:perform_async)
- post :play, params: { namespace_id: project.namespace.to_param, project_id: project, id: protected_schedule.id }
+ post :play, params: {namespace_id: project.namespace.to_param, project_id: project, id: protected_schedule.id}
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'DELETE #destroy' do
+ describe "DELETE #destroy" do
set(:user) { create(:user) }
- context 'when a developer makes the request' do
+ context "when a developer makes the request" do
before do
project.add_developer(user)
sign_in(user)
- delete :destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
+ delete :destroy, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
end
- it 'does not delete the pipeline schedule' do
+ it "does not delete the pipeline schedule" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'when a maintainer makes the request' do
+ context "when a maintainer makes the request" do
before do
project.add_maintainer(user)
sign_in(user)
end
- it 'destroys the pipeline schedule' do
- expect do
- delete :destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id }
- end.to change { project.pipeline_schedules.count }.by(-1)
+ it "destroys the pipeline schedule" do
+ expect {
+ delete :destroy, params: {namespace_id: project.namespace.to_param, project_id: project, id: pipeline_schedule.id}
+ }.to change { project.pipeline_schedules.count }.by(-1)
expect(response).to have_gitlab_http_status(302)
end
diff --git a/spec/controllers/projects/pipelines_controller_spec.rb b/spec/controllers/projects/pipelines_controller_spec.rb
index ece8532cb84..ac669964143 100644
--- a/spec/controllers/projects/pipelines_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PipelinesController do
include ApiHelpers
@@ -15,34 +15,34 @@ describe Projects::PipelinesController do
sign_in(user)
end
- describe 'GET index.json' do
+ describe "GET index.json" do
before do
- %w(pending running success failed canceled).each_with_index do |status, index|
+ %w[pending running success failed canceled].each_with_index do |status, index|
create_pipeline(status, project.commit("HEAD~#{index}"))
end
end
- context 'when using persisted stages', :request_store do
+ context "when using persisted stages", :request_store do
before do
stub_feature_flags(ci_pipeline_persisted_stages: true)
end
- it 'returns serialized pipelines', :request_store do
- queries = ActiveRecord::QueryRecorder.new do
+ it "returns serialized pipelines", :request_store do
+ queries = ActiveRecord::QueryRecorder.new {
get_pipelines_index_json
- end
+ }
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline')
+ expect(response).to match_response_schema("pipeline")
- expect(json_response).to include('pipelines')
- expect(json_response['pipelines'].count).to eq 5
- expect(json_response['count']['all']).to eq '5'
- expect(json_response['count']['running']).to eq '1'
- expect(json_response['count']['pending']).to eq '1'
- expect(json_response['count']['finished']).to eq '3'
+ expect(json_response).to include("pipelines")
+ expect(json_response["pipelines"].count).to eq 5
+ expect(json_response["count"]["all"]).to eq "5"
+ expect(json_response["count"]["running"]).to eq "1"
+ expect(json_response["count"]["pending"]).to eq "1"
+ expect(json_response["count"]["finished"]).to eq "3"
- json_response.dig('pipelines', 0, 'details', 'stages').tap do |stages|
+ json_response.dig("pipelines", 0, "details", "stages").tap do |stages|
expect(stages.count).to eq 3
end
@@ -50,46 +50,46 @@ describe Projects::PipelinesController do
end
end
- context 'when using legacy stages', :request_store do
+ context "when using legacy stages", :request_store do
before do
stub_feature_flags(ci_pipeline_persisted_stages: false)
end
- it 'returns JSON with serialized pipelines' do
+ it "returns JSON with serialized pipelines" do
get_pipelines_index_json
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline')
+ expect(response).to match_response_schema("pipeline")
- expect(json_response).to include('pipelines')
- expect(json_response['pipelines'].count).to eq 5
- expect(json_response['count']['all']).to eq '5'
- expect(json_response['count']['running']).to eq '1'
- expect(json_response['count']['pending']).to eq '1'
- expect(json_response['count']['finished']).to eq '3'
+ expect(json_response).to include("pipelines")
+ expect(json_response["pipelines"].count).to eq 5
+ expect(json_response["count"]["all"]).to eq "5"
+ expect(json_response["count"]["running"]).to eq "1"
+ expect(json_response["count"]["pending"]).to eq "1"
+ expect(json_response["count"]["finished"]).to eq "3"
- json_response.dig('pipelines', 0, 'details', 'stages').tap do |stages|
+ json_response.dig("pipelines", 0, "details", "stages").tap do |stages|
expect(stages.count).to eq 3
end
end
- it 'does not execute N+1 queries' do
- queries = ActiveRecord::QueryRecorder.new do
+ it "does not execute N+1 queries" do
+ queries = ActiveRecord::QueryRecorder.new {
get_pipelines_index_json
- end
+ }
expect(queries.count).to be <= 36
end
end
- it 'does not include coverage data for the pipelines' do
+ it "does not include coverage data for the pipelines" do
get_pipelines_index_json
- expect(json_response['pipelines'][0]).not_to include('coverage')
+ expect(json_response["pipelines"][0]).not_to include("coverage")
end
- context 'when performing gitaly calls', :request_store do
- it 'limits the Gitaly requests' do
+ context "when performing gitaly calls", :request_store do
+ it "limits the Gitaly requests" do
# Isolate from test preparation (Repository#exists? is also cached in RequestStore)
RequestStore.end!
RequestStore.clear!
@@ -100,10 +100,10 @@ describe Projects::PipelinesController do
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:project) { create(:project, :private, :repository) }
- it 'returns `not_found` when the user does not have access' do
+ it "returns `not_found` when the user does not have access" do
sign_in(create(:user))
get_pipelines_index_json
@@ -111,18 +111,18 @@ describe Projects::PipelinesController do
expect(response).to have_gitlab_http_status(:not_found)
end
- it 'returns the pipelines when the user has access' do
+ it "returns the pipelines when the user has access" do
get_pipelines_index_json
- expect(json_response['pipelines'].size).to eq(5)
+ expect(json_response["pipelines"].size).to eq(5)
end
end
def get_pipelines_index_json
get :index, params: {
- namespace_id: project.namespace,
- project_id: project
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ },
format: :json
end
@@ -131,9 +131,9 @@ describe Projects::PipelinesController do
project: project,
sha: sha)
- create_build(pipeline, 'build', 1, 'build')
- create_build(pipeline, 'test', 2, 'test')
- create_build(pipeline, 'deploy', 3, 'deploy')
+ create_build(pipeline, "build", 1, "build")
+ create_build(pipeline, "test", 2, "test")
+ create_build(pipeline, "deploy", 3, "deploy")
end
def create_build(pipeline, stage, stage_idx, name)
@@ -142,19 +142,19 @@ describe Projects::PipelinesController do
end
end
- describe 'GET show.json' do
+ describe "GET show.json" do
let(:pipeline) { create(:ci_pipeline_with_one_job, project: project) }
- it 'returns the pipeline' do
+ it "returns the pipeline" do
get_pipeline_json
expect(response).to have_gitlab_http_status(:ok)
expect(json_response).not_to be_an(Array)
- expect(json_response['id']).to be(pipeline.id)
- expect(json_response['details']).to have_key 'stages'
+ expect(json_response["id"]).to be(pipeline.id)
+ expect(json_response["details"]).to have_key "stages"
end
- context 'when the pipeline has multiple stages and groups', :request_store do
+ context "when the pipeline has multiple stages and groups", :request_store do
let(:project) { create(:project, :repository) }
let(:pipeline) do
@@ -164,21 +164,21 @@ describe Projects::PipelinesController do
end
before do
- create_build('build', 0, 'build')
- create_build('test', 1, 'rspec 0')
- create_build('deploy', 2, 'production')
- create_build('post deploy', 3, 'pages 0')
+ create_build("build", 0, "build")
+ create_build("test", 1, "rspec 0")
+ create_build("deploy", 2, "production")
+ create_build("post deploy", 3, "pages 0")
end
- it 'does not perform N + 1 queries' do
+ it "does not perform N + 1 queries" do
control_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
- create_build('test', 1, 'rspec 1')
- create_build('test', 1, 'spinach 0')
- create_build('test', 1, 'spinach 1')
- create_build('test', 1, 'audit')
- create_build('post deploy', 3, 'pages 1')
- create_build('post deploy', 3, 'pages 2')
+ create_build("test", 1, "rspec 1")
+ create_build("test", 1, "spinach 0")
+ create_build("test", 1, "spinach 1")
+ create_build("test", 1, "audit")
+ create_build("post deploy", 3, "pages 1")
+ create_build("post deploy", 3, "pages 2")
new_count = ActiveRecord::QueryRecorder.new { get_pipeline_json }.count
@@ -186,29 +186,29 @@ describe Projects::PipelinesController do
end
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
let(:feature) { ProjectFeature::DISABLED }
- it 'users can not see internal pipelines' do
+ it "users can not see internal pipelines" do
get_pipeline_json
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when pipeline is external' do
+ context "when pipeline is external" do
let(:pipeline) { create(:ci_pipeline, source: :external, project: project) }
- it 'users can see the external pipeline' do
+ it "users can see the external pipeline" do
get_pipeline_json
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['id']).to be(pipeline.id)
+ expect(json_response["id"]).to be(pipeline.id)
end
end
end
def get_pipeline_json
- get :show, params: { namespace_id: project.namespace, project_id: project, id: pipeline }, format: :json
+ get :show, params: {namespace_id: project.namespace, project_id: project, id: pipeline}, format: :json
end
def create_build(stage, stage_idx, name)
@@ -216,48 +216,48 @@ describe Projects::PipelinesController do
end
end
- describe 'GET stages.json' do
+ describe "GET stages.json" do
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when accessing existing stage' do
+ context "when accessing existing stage" do
before do
- create(:ci_build, :retried, :failed, pipeline: pipeline, stage: 'build')
- create(:ci_build, pipeline: pipeline, stage: 'build')
+ create(:ci_build, :retried, :failed, pipeline: pipeline, stage: "build")
+ create(:ci_build, pipeline: pipeline, stage: "build")
end
- context 'without retried' do
+ context "without retried" do
before do
- get_stage('build')
+ get_stage("build")
end
- it 'returns pipeline jobs without the retried builds' do
+ it "returns pipeline jobs without the retried builds" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline_stage')
- expect(json_response['latest_statuses'].length).to eq 1
- expect(json_response).not_to have_key('retried')
+ expect(response).to match_response_schema("pipeline_stage")
+ expect(json_response["latest_statuses"].length).to eq 1
+ expect(json_response).not_to have_key("retried")
end
end
- context 'with retried' do
+ context "with retried" do
before do
- get_stage('build', retried: true)
+ get_stage("build", retried: true)
end
- it 'returns pipelines jobs with the retried builds' do
+ it "returns pipelines jobs with the retried builds" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline_stage')
- expect(json_response['latest_statuses'].length).to eq 1
- expect(json_response['retried'].length).to eq 1
+ expect(response).to match_response_schema("pipeline_stage")
+ expect(json_response["latest_statuses"].length).to eq 1
+ expect(json_response["retried"].length).to eq 1
end
end
end
- context 'when accessing unknown stage' do
+ context "when accessing unknown stage" do
before do
- get_stage('test')
+ get_stage("test")
end
- it 'responds with not found' do
+ it "responds with not found" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
@@ -269,120 +269,121 @@ describe Projects::PipelinesController do
project_id: project,
id: pipeline.id,
stage: name,
- format: :json)
-}
+ format: :json
+),
+ }
end
end
- describe 'GET stages_ajax.json' do
+ describe "GET stages_ajax.json" do
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when accessing existing stage' do
+ context "when accessing existing stage" do
before do
- create(:ci_build, pipeline: pipeline, stage: 'build')
+ create(:ci_build, pipeline: pipeline, stage: "build")
- get_stage_ajax('build')
+ get_stage_ajax("build")
end
- it 'returns html source for stage dropdown' do
+ it "returns html source for stage dropdown" do
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to render_template('projects/pipelines/_stage')
- expect(json_response).to include('html')
+ expect(response).to render_template("projects/pipelines/_stage")
+ expect(json_response).to include("html")
end
end
- context 'when accessing unknown stage' do
+ context "when accessing unknown stage" do
before do
- get_stage_ajax('test')
+ get_stage_ajax("test")
end
- it 'responds with not found' do
+ it "responds with not found" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
def get_stage_ajax(name)
get :stage_ajax, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: pipeline.id,
- stage: name
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ stage: name,
+ },
format: :json
end
end
- describe 'GET status.json' do
+ describe "GET status.json" do
let(:pipeline) { create(:ci_pipeline, project: project) }
- let(:status) { pipeline.detailed_status(double('user')) }
+ let(:status) { pipeline.detailed_status(double("user")) }
before do
get :status, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: pipeline.id
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ },
format: :json
end
- it 'return a detailed pipeline status in json' do
+ it "return a detailed pipeline status in json" do
expect(response).to have_gitlab_http_status(:ok)
- expect(json_response['text']).to eq status.text
- expect(json_response['label']).to eq status.label
- expect(json_response['icon']).to eq status.icon
- expect(json_response['favicon']).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png")
+ expect(json_response["text"]).to eq status.text
+ expect(json_response["label"]).to eq status.label
+ expect(json_response["icon"]).to eq status.icon
+ expect(json_response["favicon"]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png")
end
end
- describe 'POST retry.json' do
+ describe "POST retry.json" do
let!(:pipeline) { create(:ci_pipeline, :failed, project: project) }
let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
before do
post :retry, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: pipeline.id
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ },
format: :json
end
- it 'retries a pipeline without returning any content' do
+ it "retries a pipeline without returning any content" do
expect(response).to have_gitlab_http_status(:no_content)
expect(build.reload).to be_retried
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
let(:feature) { ProjectFeature::DISABLED }
- it 'fails to retry pipeline' do
+ it "fails to retry pipeline" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
- describe 'POST cancel.json' do
+ describe "POST cancel.json" do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
before do
post :cancel, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: pipeline.id
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: pipeline.id,
+ },
format: :json
end
- it 'cancels a pipeline without returning any content' do
+ it "cancels a pipeline without returning any content" do
expect(response).to have_gitlab_http_status(:no_content)
expect(pipeline.reload).to be_canceled
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
let(:feature) { ProjectFeature::DISABLED }
- it 'fails to retry pipeline' do
+ it "fails to retry pipeline" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
diff --git a/spec/controllers/projects/pipelines_settings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb
index 269f105bed2..f8c57071c41 100644
--- a/spec/controllers/projects/pipelines_settings_controller_spec.rb
+++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PipelinesSettingsController do
set(:user) { create(:user) }
@@ -11,9 +11,9 @@ describe Projects::PipelinesSettingsController do
sign_in(user)
end
- describe 'GET show' do
- it 'redirects with 302 status code' do
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET show" do
+ it "redirects with 302 status code" do
+ get :show, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(302)
end
diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb
index 3cc3fe69fba..7f3748e2c5f 100644
--- a/spec/controllers/projects/project_members_controller_spec.rb
+++ b/spec/controllers/projects/project_members_controller_spec.rb
@@ -1,78 +1,78 @@
-require('spec_helper')
+require("spec_helper")
describe Projects::ProjectMembersController do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :access_requestable) }
- describe 'GET index' do
- it 'should have the project_members address with a 200 status code' do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET index" do
+ it "should have the project_members address with a 200 status code" do
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:project_user) { create(:user) }
before do
sign_in(user)
end
- context 'when user does not have enough rights' do
+ context "when user does not have enough rights" do
before do
project.add_developer(user)
end
- it 'returns 404' do
+ it "returns 404" do
post :create, params: {
- namespace_id: project.namespace,
- project_id: project,
- user_ids: project_user.id,
- access_level: Gitlab::Access::GUEST
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ user_ids: project_user.id,
+ access_level: Gitlab::Access::GUEST,
+ }
expect(response).to have_gitlab_http_status(404)
expect(project.users).not_to include project_user
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
project.add_maintainer(user)
end
- it 'adds user to members' do
+ it "adds user to members" do
expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(status: :success)
post :create, params: {
- namespace_id: project.namespace,
- project_id: project,
- user_ids: project_user.id,
- access_level: Gitlab::Access::GUEST
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ user_ids: project_user.id,
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'Users were successfully added.'
+ expect(response).to set_flash.to "Users were successfully added."
expect(response).to redirect_to(project_project_members_path(project))
end
- it 'adds no user to members' do
- expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(status: :failure, message: 'Message')
+ it "adds no user to members" do
+ expect_any_instance_of(Members::CreateService).to receive(:execute).and_return(status: :failure, message: "Message")
post :create, params: {
- namespace_id: project.namespace,
- project_id: project,
- user_ids: '',
- access_level: Gitlab::Access::GUEST
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ user_ids: "",
+ access_level: Gitlab::Access::GUEST,
+ }
- expect(response).to set_flash.to 'Message'
+ expect(response).to set_flash.to "Message"
expect(response).to redirect_to(project_project_members_path(project))
end
end
end
- describe 'PUT update' do
+ describe "PUT update" do
let(:requester) { create(:project_member, :access_request, project: project) }
before do
@@ -83,10 +83,10 @@ describe Projects::ProjectMembersController do
Gitlab::Access.options.each do |label, value|
it "can change the access level to #{label}" do
put :update, params: {
- project_member: { access_level: value },
+ project_member: {access_level: value},
namespace_id: project.namespace,
project_id: project,
- id: requester
+ id: requester,
}, xhr: true
expect(requester.reload.human_access).to eq(label)
@@ -94,54 +94,54 @@ describe Projects::ProjectMembersController do
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:member) { create(:project_member, :developer, project: project) }
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 404' do
+ context "when member is not found" do
+ it "returns 404" do
delete :destroy, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: 42
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: 42,
+ }
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when member is found' do
- context 'when user does not have enough rights' do
+ context "when member is found" do
+ context "when user does not have enough rights" do
before do
project.add_developer(user)
end
- it 'returns 404' do
+ it "returns 404" do
delete :destroy, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: member
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: member,
+ }
expect(response).to have_gitlab_http_status(404)
expect(project.members).to include member
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
project.add_maintainer(user)
end
- it '[HTML] removes user from members' do
+ it "[HTML] removes user from members" do
delete :destroy, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: member
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: member,
+ }
expect(response).to redirect_to(
project_project_members_path(project)
@@ -149,11 +149,11 @@ describe Projects::ProjectMembersController do
expect(project.members).not_to include member
end
- it '[JS] removes user from members' do
+ it "[JS] removes user from members" do
delete :destroy, params: {
namespace_id: project.namespace,
project_id: project,
- id: member
+ id: member,
}, xhr: true
expect(response).to be_success
@@ -163,33 +163,33 @@ describe Projects::ProjectMembersController do
end
end
- describe 'DELETE leave' do
+ describe "DELETE leave" do
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 404' do
+ context "when member is not found" do
+ it "returns 404" do
delete :leave, params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ }
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when member is found' do
- context 'and is not an owner' do
+ context "when member is found" do
+ context "and is not an owner" do
before do
project.add_developer(user)
end
- it 'removes user from members' do
+ it "removes user from members" do
delete :leave, params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ }
expect(response).to set_flash.to "You left the \"#{project.human_name}\" project."
expect(response).to redirect_to(dashboard_projects_path)
@@ -197,35 +197,35 @@ describe Projects::ProjectMembersController do
end
end
- context 'and is an owner' do
+ context "and is an owner" do
let(:project) { create(:project, namespace: user.namespace) }
before do
project.add_maintainer(user)
end
- it 'cannot remove themselves from the project' do
+ it "cannot remove themselves from the project" do
delete :leave, params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ }
expect(response).to have_gitlab_http_status(403)
end
end
- context 'and is a requester' do
+ context "and is a requester" do
before do
project.request_access(user)
end
- it 'removes user from members' do
+ it "removes user from members" do
delete :leave, params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ }
- expect(response).to set_flash.to 'Your access request to the project has been withdrawn.'
+ expect(response).to set_flash.to "Your access request to the project has been withdrawn."
expect(response).to redirect_to(project_path(project))
expect(project.requesters).to be_empty
expect(project.users).not_to include user
@@ -234,18 +234,18 @@ describe Projects::ProjectMembersController do
end
end
- describe 'POST request_access' do
+ describe "POST request_access" do
before do
sign_in(user)
end
- it 'creates a new ProjectMember that is not a team member' do
+ it "creates a new ProjectMember that is not a team member" do
post :request_access, params: {
- namespace_id: project.namespace,
- project_id: project
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ }
- expect(response).to set_flash.to 'Your request for access has been queued for review.'
+ expect(response).to set_flash.to "Your request for access has been queued for review."
expect(response).to redirect_to(
project_path(project)
)
@@ -254,54 +254,54 @@ describe Projects::ProjectMembersController do
end
end
- describe 'POST approve' do
+ describe "POST approve" do
let(:member) { create(:project_member, :access_request, project: project) }
before do
sign_in(user)
end
- context 'when member is not found' do
- it 'returns 404' do
+ context "when member is not found" do
+ it "returns 404" do
post :approve_access_request, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: 42
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: 42,
+ }
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when member is found' do
- context 'when user does not have enough rights' do
+ context "when member is found" do
+ context "when user does not have enough rights" do
before do
project.add_developer(user)
end
- it 'returns 404' do
+ it "returns 404" do
post :approve_access_request, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: member
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: member,
+ }
expect(response).to have_gitlab_http_status(404)
expect(project.members).not_to include member
end
end
- context 'when user has enough rights' do
+ context "when user has enough rights" do
before do
project.add_maintainer(user)
end
- it 'adds user to members' do
+ it "adds user to members" do
post :approve_access_request, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: member
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: member,
+ }
expect(response).to redirect_to(
project_project_members_path(project)
@@ -312,7 +312,7 @@ describe Projects::ProjectMembersController do
end
end
- describe 'POST apply_import' do
+ describe "POST apply_import" do
let(:another_project) { create(:project, :private) }
let(:member) { create(:user) }
@@ -322,81 +322,81 @@ describe Projects::ProjectMembersController do
sign_in(user)
end
- shared_context 'import applied' do
+ shared_context "import applied" do
before do
post(:apply_import, params: {
- namespace_id: project.namespace,
- project_id: project,
- source_project_id: another_project.id
- })
+ namespace_id: project.namespace,
+ project_id: project,
+ source_project_id: another_project.id,
+ })
end
end
- context 'when user can access source project members' do
+ context "when user can access source project members" do
before do
another_project.add_guest(user)
end
- include_context 'import applied'
+ include_context "import applied"
- it 'imports source project members' do
+ it "imports source project members" do
expect(project.team_members).to include member
- expect(response).to set_flash.to 'Successfully imported'
+ expect(response).to set_flash.to "Successfully imported"
expect(response).to redirect_to(
project_project_members_path(project)
)
end
end
- context 'when user is not member of a source project' do
- include_context 'import applied'
+ context "when user is not member of a source project" do
+ include_context "import applied"
- it 'does not import team members' do
+ it "does not import team members" do
expect(project.team_members).not_to include member
end
- it 'responds with not found' do
+ it "responds with not found" do
expect(response.status).to eq 404
end
end
end
- describe 'POST create' do
+ describe "POST create" do
let(:stranger) { create(:user) }
- context 'when creating owner' do
+ context "when creating owner" do
before do
project.add_maintainer(user)
sign_in(user)
end
- it 'does not create a member' do
- expect do
+ it "does not create a member" do
+ expect {
post :create, params: {
- user_ids: stranger.id,
- namespace_id: project.namespace,
- access_level: Member::OWNER,
- project_id: project
- }
- end.to change { project.members.count }.by(0)
+ user_ids: stranger.id,
+ namespace_id: project.namespace,
+ access_level: Member::OWNER,
+ project_id: project,
+ }
+ }.to change { project.members.count }.by(0)
end
end
- context 'when create maintainer' do
+ context "when create maintainer" do
before do
project.add_maintainer(user)
sign_in(user)
end
- it 'creates a member' do
- expect do
+ it "creates a member" do
+ expect {
post :create, params: {
- user_ids: stranger.id,
- namespace_id: project.namespace,
- access_level: Member::MAINTAINER,
- project_id: project
- }
- end.to change { project.members.count }.by(1)
+ user_ids: stranger.id,
+ namespace_id: project.namespace,
+ access_level: Member::MAINTAINER,
+ project_id: project,
+ }
+ }.to change { project.members.count }.by(1)
end
end
end
diff --git a/spec/controllers/projects/prometheus/metrics_controller_spec.rb b/spec/controllers/projects/prometheus/metrics_controller_spec.rb
index 635763ce1d3..c6866820c83 100644
--- a/spec/controllers/projects/prometheus/metrics_controller_spec.rb
+++ b/spec/controllers/projects/prometheus/metrics_controller_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Prometheus::MetricsController do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
+ let(:prometheus_adapter) { double("prometheus_adapter", can_query?: true) }
before do
project.add_maintainer(user)
sign_in(user)
end
- describe 'GET #active_common' do
- context 'when prometheus_adapter can query' do
+ describe "GET #active_common" do
+ context "when prometheus_adapter can query" do
before do
allow(controller).to receive(:prometheus_adapter).and_return(prometheus_adapter)
end
- context 'when prometheus metrics are enabled' do
- context 'when data is not present' do
+ context "when prometheus metrics are enabled" do
+ context "when data is not present" do
before do
allow(prometheus_adapter).to receive(:query).with(:matched_metrics).and_return({})
end
- it 'returns no content response' do
+ it "returns no content response" do
get :active_common, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(204)
end
end
- context 'when data is available' do
- let(:sample_response) { { some_data: 1 } }
+ context "when data is available" do
+ let(:sample_response) { {some_data: 1} }
before do
allow(prometheus_adapter).to receive(:query).with(:matched_metrics).and_return(sample_response)
end
- it 'returns no content response' do
+ it "returns no content response" do
get :active_common, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(200)
@@ -45,8 +45,8 @@ describe Projects::Prometheus::MetricsController do
end
end
- context 'when requesting non json response' do
- it 'returns not found response' do
+ context "when requesting non json response" do
+ it "returns not found response" do
get :active_common, params: project_params
expect(response).to have_gitlab_http_status(404)
@@ -55,9 +55,9 @@ describe Projects::Prometheus::MetricsController do
end
end
- context 'when prometheus_adapter cannot query' do
- it 'renders 404' do
- prometheus_adapter = double('prometheus_adapter', can_query?: false)
+ context "when prometheus_adapter cannot query" do
+ it "renders 404" do
+ prometheus_adapter = double("prometheus_adapter", can_query?: false)
allow(controller).to receive(:prometheus_adapter).and_return(prometheus_adapter)
allow(prometheus_adapter).to receive(:query).with(:matched_metrics).and_return({})
@@ -68,8 +68,8 @@ describe Projects::Prometheus::MetricsController do
end
end
- context 'when prometheus_adapter is disabled' do
- it 'renders 404' do
+ context "when prometheus_adapter is disabled" do
+ it "renders 404" do
get :active_common, params: project_params(format: :json)
expect(response).to have_gitlab_http_status(404)
@@ -77,12 +77,12 @@ describe Projects::Prometheus::MetricsController do
end
end
- describe '#prometheus_adapter' do
+ describe "#prometheus_adapter" do
before do
allow(controller).to receive(:project).and_return(project)
end
- it 'calls prometheus adapter service' do
+ it "calls prometheus adapter service" do
expect_any_instance_of(::Prometheus::AdapterService).to receive(:prometheus_adapter)
subject.__send__(:prometheus_adapter)
diff --git a/spec/controllers/projects/protected_branches_controller_spec.rb b/spec/controllers/projects/protected_branches_controller_spec.rb
index 483d3bbc37c..4f589159ff0 100644
--- a/spec/controllers/projects/protected_branches_controller_spec.rb
+++ b/spec/controllers/projects/protected_branches_controller_spec.rb
@@ -1,9 +1,9 @@
-require('spec_helper')
+require("spec_helper")
describe Projects::ProtectedBranchesController do
let(:project) { create(:project, :repository) }
let(:protected_branch) { create(:protected_branch, project: project) }
- let(:project_params) { { namespace_id: project.namespace.to_param, project_id: project } }
+ let(:project_params) { {namespace_id: project.namespace.to_param, project_id: project} }
let(:base_params) { project_params.merge(id: protected_branch.id) }
let(:user) { create(:user) }
@@ -15,15 +15,15 @@ describe Projects::ProtectedBranchesController do
let(:project) { create(:project_empty_repo, :public) }
it "redirects empty repo to projects page" do
- get(:index, params: { namespace_id: project.namespace.to_param, project_id: project })
+ get(:index, params: {namespace_id: project.namespace.to_param, project_id: project})
end
end
describe "POST #create" do
- let(:maintainer_access_level) { [{ access_level: Gitlab::Access::MAINTAINER }] }
+ let(:maintainer_access_level) { [{access_level: Gitlab::Access::MAINTAINER}] }
let(:access_level_params) do
- { merge_access_levels_attributes: maintainer_access_level,
- push_access_levels_attributes: maintainer_access_level }
+ {merge_access_levels_attributes: maintainer_access_level,
+ push_access_levels_attributes: maintainer_access_level,}
end
let(:create_params) { attributes_for(:protected_branch).merge(access_level_params) }
@@ -31,13 +31,13 @@ describe Projects::ProtectedBranchesController do
sign_in(user)
end
- it 'creates the protected branch rule' do
- expect do
+ it "creates the protected branch rule" do
+ expect {
post(:create, params: project_params.merge(protected_branch: create_params))
- end.to change(ProtectedBranch, :count).by(1)
+ }.to change(ProtectedBranch, :count).by(1)
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
allow(ProtectedBranchPolicy).to receive(:new).and_return(policy)
@@ -52,20 +52,20 @@ describe Projects::ProtectedBranchesController do
end
describe "PUT #update" do
- let(:update_params) { { name: 'new_name' } }
+ let(:update_params) { {name: "new_name"} }
before do
sign_in(user)
end
- it 'updates the protected branch rule' do
+ it "updates the protected branch rule" do
put(:update, params: base_params.merge(protected_branch: update_params))
- expect(protected_branch.reload.name).to eq('new_name')
- expect(json_response["name"]).to eq('new_name')
+ expect(protected_branch.reload.name).to eq("new_name")
+ expect(json_response["name"]).to eq("new_name")
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
allow(ProtectedBranchPolicy).to receive(:new).and_return(policy)
@@ -92,7 +92,7 @@ describe Projects::ProtectedBranchesController do
expect { ProtectedBranch.find(protected_branch.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
allow(ProtectedBranchPolicy).to receive(:new).and_return(policy)
diff --git a/spec/controllers/projects/protected_tags_controller_spec.rb b/spec/controllers/projects/protected_tags_controller_spec.rb
index 1553e081dee..24b1aea5ea3 100644
--- a/spec/controllers/projects/protected_tags_controller_spec.rb
+++ b/spec/controllers/projects/protected_tags_controller_spec.rb
@@ -1,11 +1,11 @@
-require('spec_helper')
+require("spec_helper")
describe Projects::ProtectedTagsController do
describe "GET #index" do
let(:project) { create(:project_empty_repo, :public) }
it "redirects empty repo to projects page" do
- get(:index, params: { namespace_id: project.namespace.to_param, project_id: project })
+ get(:index, params: {namespace_id: project.namespace.to_param, project_id: project})
end
end
@@ -20,7 +20,7 @@ describe Projects::ProtectedTagsController do
end
it "deletes the protected tag" do
- delete(:destroy, params: { namespace_id: project.namespace.to_param, project_id: project, id: protected_tag.id })
+ delete(:destroy, params: {namespace_id: project.namespace.to_param, project_id: project, id: protected_tag.id})
expect { ProtectedTag.find(protected_tag.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
diff --git a/spec/controllers/projects/raw_controller_spec.rb b/spec/controllers/projects/raw_controller_spec.rb
index cffdf30da6b..cdd8c49da0c 100644
--- a/spec/controllers/projects/raw_controller_spec.rb
+++ b/spec/controllers/projects/raw_controller_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::RawController do
let(:project) { create(:project, :public, :repository) }
- describe 'GET #show' do
+ describe "GET #show" do
subject do
get(:show,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: filepath
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: filepath,
+ })
end
- context 'regular filename' do
- let(:filepath) { 'master/README.md' }
+ context "regular filename" do
+ let(:filepath) { "master/README.md" }
- it 'delivers ASCII file' do
+ it "delivers ASCII file" do
subject
expect(response).to have_gitlab_http_status(200)
- expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(response.header['Content-Disposition']).to eq('inline')
+ expect(response.header["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(response.header["Content-Disposition"]).to eq("inline")
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
- expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end
end
- context 'image header' do
- let(:filepath) { 'master/files/images/6049019_460s.jpg' }
+ context "image header" do
+ let(:filepath) { "master/files/images/6049019_460s.jpg" }
- it 'leaves image content disposition' do
+ it "leaves image content disposition" do
subject
expect(response).to have_gitlab_http_status(200)
- expect(response.header['Content-Disposition']).to eq('inline')
+ expect(response.header["Content-Disposition"]).to eq("inline")
expect(response.header[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
- expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end
end
- it_behaves_like 'repository lfs file load' do
- let(:filename) { 'lfs_object.iso' }
+ it_behaves_like "repository lfs file load" do
+ let(:filename) { "lfs_object.iso" }
let(:filepath) { "be93687/files/lfs/#{filename}" }
end
end
diff --git a/spec/controllers/projects/refs_controller_spec.rb b/spec/controllers/projects/refs_controller_spec.rb
index 62f2af947e4..40601ba93d5 100644
--- a/spec/controllers/projects/refs_controller_spec.rb
+++ b/spec/controllers/projects/refs_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::RefsController do
let(:project) { create(:project, :repository) }
@@ -9,46 +9,46 @@ describe Projects::RefsController do
project.add_developer(user)
end
- describe 'GET #logs_tree' do
+ describe "GET #logs_tree" do
def default_get(format = :html)
get :logs_tree,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: 'master',
- path: 'foo/bar/baz.html'
- },
- format: format
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: "master",
+ path: "foo/bar/baz.html",
+ },
+ format: format
end
def xhr_get(format = :html)
get :logs_tree, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: 'master',
- path: 'foo/bar/baz.html',
- format: format
+ id: "master",
+ path: "foo/bar/baz.html",
+ format: format,
}, xhr: true
end
- it 'never throws MissingTemplate' do
+ it "never throws MissingTemplate" do
expect { default_get }.not_to raise_error
expect { xhr_get(:json) }.not_to raise_error
expect { xhr_get }.not_to raise_error
end
- it 'renders 404 for non-JS requests' do
+ it "renders 404 for non-JS requests" do
xhr_get
expect(response).to be_not_found
end
- it 'renders JS' do
+ it "renders JS" do
xhr_get(:js)
expect(response).to be_success
end
- it 'renders JSON' do
+ it "renders JSON" do
xhr_get(:json)
expect(response).to be_success
diff --git a/spec/controllers/projects/registry/repositories_controller_spec.rb b/spec/controllers/projects/registry/repositories_controller_spec.rb
index eca187af33d..fb144450643 100644
--- a/spec/controllers/projects/registry/repositories_controller_spec.rb
+++ b/spec/controllers/projects/registry/repositories_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Registry::RepositoriesController do
let(:user) { create(:user) }
@@ -9,64 +9,64 @@ describe Projects::Registry::RepositoriesController do
stub_container_registry_config(enabled: true)
end
- context 'when user has access to registry' do
+ context "when user has access to registry" do
before do
project.add_developer(user)
end
- describe 'GET index' do
- context 'when root container repository exists' do
+ describe "GET index" do
+ context "when root container repository exists" do
before do
create(:container_repository, :root, project: project)
end
- it 'does not create root container repository' do
+ it "does not create root container repository" do
expect { go_to_index }.not_to change { ContainerRepository.all.count }
end
end
- context 'when root container repository is not created' do
- context 'when there are tags for this repository' do
+ context "when root container repository is not created" do
+ context "when there are tags for this repository" do
before do
stub_container_registry_tags(repository: project.full_path,
tags: %w[rc1 latest])
end
- it 'successfully renders container repositories' do
+ it "successfully renders container repositories" do
go_to_index
expect(response).to have_gitlab_http_status(:ok)
end
- it 'creates a root container repository' do
+ it "creates a root container repository" do
expect { go_to_index }.to change { ContainerRepository.all.count }.by(1)
expect(ContainerRepository.first).to be_root_repository
end
- it 'json has a list of projects' do
+ it "json has a list of projects" do
go_to_index(format: :json)
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/repositories')
+ expect(response).to match_response_schema("registry/repositories")
end
end
- context 'when there are no tags for this repository' do
+ context "when there are no tags for this repository" do
before do
stub_container_registry_tags(repository: :any, tags: [])
end
- it 'successfully renders container repositories' do
+ it "successfully renders container repositories" do
go_to_index
expect(response).to have_gitlab_http_status(:ok)
end
- it 'does not ensure root container repository' do
+ it "does not ensure root container repository" do
expect { go_to_index }.not_to change { ContainerRepository.all.count }
end
- it 'responds with json if asked' do
+ it "responds with json if asked" do
go_to_index(format: :json)
expect(response).to have_gitlab_http_status(:ok)
@@ -76,8 +76,8 @@ describe Projects::Registry::RepositoriesController do
end
end
- describe 'DELETE destroy' do
- context 'when root container repository exists' do
+ describe "DELETE destroy" do
+ context "when root container repository exists" do
let!(:repository) do
create(:container_repository, :root, project: project)
end
@@ -86,7 +86,7 @@ describe Projects::Registry::RepositoriesController do
stub_container_registry_tags(repository: :any, tags: [])
end
- it 'schedules a job to delete a repository' do
+ it "schedules a job to delete a repository" do
expect(DeleteContainerRepositoryWorker).to receive(:perform_async).with(user.id, repository.id)
delete_repository(repository)
@@ -96,15 +96,15 @@ describe Projects::Registry::RepositoriesController do
end
end
- context 'when user does not have access to registry' do
- describe 'GET index' do
- it 'responds with 404' do
+ context "when user does not have access to registry" do
+ describe "GET index" do
+ it "responds with 404" do
go_to_index
expect(response).to have_gitlab_http_status(:not_found)
end
- it 'does not ensure root container repository' do
+ it "does not ensure root container repository" do
expect { go_to_index }.not_to change { ContainerRepository.all.count }
end
end
@@ -112,18 +112,18 @@ describe Projects::Registry::RepositoriesController do
def go_to_index(format: :html)
get :index, params: {
- namespace_id: project.namespace,
- project_id: project
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ },
format: format
end
def delete_repository(repository)
delete :destroy, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: repository
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ id: repository,
+ },
format: :json
end
end
diff --git a/spec/controllers/projects/registry/tags_controller_spec.rb b/spec/controllers/projects/registry/tags_controller_spec.rb
index 74ed89ba1c3..7fa7352d5b6 100644
--- a/spec/controllers/projects/registry/tags_controller_spec.rb
+++ b/spec/controllers/projects/registry/tags_controller_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Registry::TagsController do
let(:user) { create(:user) }
let(:project) { create(:project, :private) }
let(:repository) do
- create(:container_repository, name: 'image', project: project)
+ create(:container_repository, name: "image", project: project)
end
before do
@@ -13,7 +13,7 @@ describe Projects::Registry::TagsController do
stub_container_registry_config(enabled: true)
end
- describe 'GET index' do
+ describe "GET index" do
let(:tags) do
Array.new(40) { |i| "tag#{i}" }
end
@@ -22,40 +22,40 @@ describe Projects::Registry::TagsController do
stub_container_registry_tags(repository: /image/, tags: tags, with_manifest: true)
end
- context 'when user can control the registry' do
+ context "when user can control the registry" do
before do
project.add_developer(user)
end
- it 'receive a list of tags' do
+ it "receive a list of tags" do
get_tags
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/tags')
+ expect(response).to match_response_schema("registry/tags")
expect(response).to include_pagination_headers
end
end
- context 'when user can read the registry' do
+ context "when user can read the registry" do
before do
project.add_reporter(user)
end
- it 'receive a list of tags' do
+ it "receive a list of tags" do
get_tags
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/tags')
+ expect(response).to match_response_schema("registry/tags")
expect(response).to include_pagination_headers
end
end
- context 'when user does not have access to registry' do
+ context "when user does not have access to registry" do
before do
project.add_guest(user)
end
- it 'does not receive a list of tags' do
+ it "does not receive a list of tags" do
get_tags
expect(response).to have_gitlab_http_status(:not_found)
@@ -66,35 +66,35 @@ describe Projects::Registry::TagsController do
def get_tags
get :index, params: {
- namespace_id: project.namespace,
- project_id: project,
- repository_id: repository
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ repository_id: repository,
+ },
format: :json
end
end
- describe 'POST destroy' do
- context 'when user has access to registry' do
+ describe "POST destroy" do
+ context "when user has access to registry" do
before do
project.add_developer(user)
end
- context 'when there is matching tag present' do
+ context "when there is matching tag present" do
before do
stub_container_registry_tags(repository: repository.path, tags: %w[rc1 test.])
end
- it 'makes it possible to delete regular tag' do
+ it "makes it possible to delete regular tag" do
expect_any_instance_of(ContainerRegistry::Tag).to receive(:delete)
- destroy_tag('rc1')
+ destroy_tag("rc1")
end
- it 'makes it possible to delete a tag that ends with a dot' do
+ it "makes it possible to delete a tag that ends with a dot" do
expect_any_instance_of(ContainerRegistry::Tag).to receive(:delete)
- destroy_tag('test.')
+ destroy_tag("test.")
end
end
end
@@ -103,11 +103,11 @@ describe Projects::Registry::TagsController do
def destroy_tag(name)
post :destroy, params: {
- namespace_id: project.namespace,
- project_id: project,
- repository_id: repository,
- id: name
- },
+ namespace_id: project.namespace,
+ project_id: project,
+ repository_id: repository,
+ id: name,
+ },
format: :json
end
end
diff --git a/spec/controllers/projects/releases_controller_spec.rb b/spec/controllers/projects/releases_controller_spec.rb
index 5b9d21d3d5b..3781282de85 100644
--- a/spec/controllers/projects/releases_controller_spec.rb
+++ b/spec/controllers/projects/releases_controller_spec.rb
@@ -1,28 +1,28 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ReleasesController do
let!(:project) { create(:project, :repository, :public) }
let!(:user) { create(:user) }
- describe 'GET #index' do
- it 'renders a 200' do
+ describe "GET #index" do
+ it "renders a 200" do
get_index
expect(response.status).to eq(200)
end
- context 'when the project is private' do
+ context "when the project is private" do
let!(:project) { create(:project, :repository, :private) }
- it 'renders a 302' do
+ it "renders a 302" do
get_index
expect(response.status).to eq(302)
end
- it 'renders a 200 for a logged in developer' do
+ it "renders a 200 for a logged in developer" do
project.add_developer(user)
sign_in(user)
@@ -31,7 +31,7 @@ describe Projects::ReleasesController do
expect(response.status).to eq(200)
end
- it 'renders a 404 when logged in but not in the project' do
+ it "renders a 404 when logged in but not in the project" do
sign_in(user)
get_index
@@ -44,6 +44,6 @@ describe Projects::ReleasesController do
private
def get_index
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
end
end
diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb
index 5f4f6f8558f..0dbda136b95 100644
--- a/spec/controllers/projects/repositories_controller_spec.rb
+++ b/spec/controllers/projects/repositories_controller_spec.rb
@@ -4,16 +4,16 @@ describe Projects::RepositoriesController do
let(:project) { create(:project, :repository) }
describe "GET archive" do
- context 'as a guest' do
- it 'responds with redirect in correct format' do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip"
+ context "as a guest" do
+ it "responds with redirect in correct format" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "master"}, format: "zip"
- expect(response.header["Content-Type"]).to start_with('text/html')
+ expect(response.header["Content-Type"]).to start_with("text/html")
expect(response).to be_redirect
end
end
- context 'as a user' do
+ context "as a user" do
let(:user) { create(:user) }
before do
@@ -22,45 +22,45 @@ describe Projects::RepositoriesController do
end
it "uses Gitlab::Workhorse" do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip"
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "master"}, format: "zip"
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
- it 'responds with redirect to the short name archive if fully qualified' do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master/#{project.path}-master" }, format: "zip"
+ it "responds with redirect to the short name archive if fully qualified" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "master/#{project.path}-master"}, format: "zip"
expect(assigns(:ref)).to eq("master")
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
- it 'handles legacy queries with no ref' do
- get :archive, params: { namespace_id: project.namespace, project_id: project }, format: "zip"
+ it "handles legacy queries with no ref" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project}, format: "zip"
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
- it 'handles legacy queries with the ref specified as ref in params' do
- get :archive, params: { namespace_id: project.namespace, project_id: project, ref: 'feature' }, format: 'zip'
+ it "handles legacy queries with the ref specified as ref in params" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project, ref: "feature"}, format: "zip"
expect(response).to have_gitlab_http_status(200)
- expect(assigns(:ref)).to eq('feature')
+ expect(assigns(:ref)).to eq("feature")
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
- it 'handles legacy queries with the ref specified as id in params' do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature' }, format: 'zip'
+ it "handles legacy queries with the ref specified as id in params" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "feature"}, format: "zip"
expect(response).to have_gitlab_http_status(200)
- expect(assigns(:ref)).to eq('feature')
+ expect(assigns(:ref)).to eq("feature")
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
- it 'prioritizes the id param over the ref param when both are specified' do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: 'feature', ref: 'feature_conflict' }, format: 'zip'
+ it "prioritizes the id param over the ref param when both are specified" do
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "feature", ref: "feature_conflict"}, format: "zip"
expect(response).to have_gitlab_http_status(200)
- expect(assigns(:ref)).to eq('feature')
+ expect(assigns(:ref)).to eq("feature")
expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:")
end
@@ -70,7 +70,7 @@ describe Projects::RepositoriesController do
end
it "renders Not Found" do
- get :archive, params: { namespace_id: project.namespace, project_id: project, id: "master" }, format: "zip"
+ get :archive, params: {namespace_id: project.namespace, project_id: project, id: "master"}, format: "zip"
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/projects/runners_controller_spec.rb b/spec/controllers/projects/runners_controller_spec.rb
index 0baaa4e7192..2c002fe183c 100644
--- a/spec/controllers/projects/runners_controller_spec.rb
+++ b/spec/controllers/projects/runners_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::RunnersController do
let(:user) { create(:user) }
@@ -9,7 +9,7 @@ describe Projects::RunnersController do
{
namespace_id: project.namespace,
project_id: project,
- id: runner
+ id: runner,
}
end
@@ -18,13 +18,13 @@ describe Projects::RunnersController do
project.add_maintainer(user)
end
- describe '#update' do
- it 'updates the runner and ticks the queue' do
+ describe "#update" do
+ it "updates the runner and ticks the queue" do
new_desc = runner.description.swapcase
- expect do
- post :update, params: params.merge(runner: { description: new_desc } )
- end.to change { runner.ensure_runner_queue_value }
+ expect {
+ post :update, params: params.merge(runner: {description: new_desc})
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -33,8 +33,8 @@ describe Projects::RunnersController do
end
end
- describe '#destroy' do
- it 'destroys the runner' do
+ describe "#destroy" do
+ it "destroys the runner" do
delete :destroy, params: params
expect(response).to have_gitlab_http_status(302)
@@ -42,13 +42,13 @@ describe Projects::RunnersController do
end
end
- describe '#resume' do
- it 'marks the runner as active and ticks the queue' do
+ describe "#resume" do
+ it "marks the runner as active and ticks the queue" do
runner.update(active: false)
- expect do
+ expect {
post :resume, params: params
- end.to change { runner.ensure_runner_queue_value }
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
@@ -57,13 +57,13 @@ describe Projects::RunnersController do
end
end
- describe '#pause' do
- it 'marks the runner as inactive and ticks the queue' do
+ describe "#pause" do
+ it "marks the runner as inactive and ticks the queue" do
runner.update(active: true)
- expect do
+ expect {
post :pause, params: params
- end.to change { runner.ensure_runner_queue_value }
+ }.to change { runner.ensure_runner_queue_value }
runner.reload
diff --git a/spec/controllers/projects/serverless/functions_controller_spec.rb b/spec/controllers/projects/serverless/functions_controller_spec.rb
index 276cf340962..00637628fa9 100644
--- a/spec/controllers/projects/serverless/functions_controller_spec.rb
+++ b/spec/controllers/projects/serverless/functions_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Serverless::FunctionsController do
include KubernetesHelpers
@@ -29,15 +29,15 @@ describe Projects::Serverless::FunctionsController do
project_id: project.to_param)
end
- describe 'GET #index' do
- context 'empty cache' do
- it 'has no data' do
- get :index, params: params({ format: :json })
+ describe "GET #index" do
+ context "empty cache" do
+ it "has no data" do
+ get :index, params: params({format: :json})
expect(response).to have_gitlab_http_status(204)
end
- it 'renders an html page' do
+ it "renders an html page" do
get :index, params: params
expect(response).to have_gitlab_http_status(200)
@@ -45,26 +45,26 @@ describe Projects::Serverless::FunctionsController do
end
end
- describe 'GET #show' do
- context 'invalid data' do
- it 'has a bad function name' do
- get :show, params: params({ format: :json, environment_id: "*", id: "foo" })
+ describe "GET #show" do
+ context "invalid data" do
+ it "has a bad function name" do
+ get :show, params: params({format: :json, environment_id: "*", id: "foo"})
expect(response).to have_gitlab_http_status(404)
end
end
- context 'valid data', :use_clean_rails_memory_store_caching do
+ context "valid data", :use_clean_rails_memory_store_caching do
before do
stub_kubeclient_service_pods
stub_reactive_cache(knative,
{
services: kube_knative_services_body(namespace: namespace.namespace, name: cluster.project.name)["items"],
- pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"]
+ pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"],
})
end
- it 'has a valid function name' do
- get :show, params: params({ format: :json, environment_id: "*", id: cluster.project.name })
+ it "has a valid function name" do
+ get :show, params: params({format: :json, environment_id: "*", id: cluster.project.name})
expect(response).to have_gitlab_http_status(200)
expect(json_response).to include(
@@ -76,18 +76,18 @@ describe Projects::Serverless::FunctionsController do
end
end
- describe 'GET #index with data', :use_clean_rails_memory_store_caching do
+ describe "GET #index with data", :use_clean_rails_memory_store_caching do
before do
stub_kubeclient_service_pods
stub_reactive_cache(knative,
{
services: kube_knative_services_body(namespace: namespace.namespace, name: cluster.project.name)["items"],
- pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"]
+ pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"],
})
end
- it 'has data' do
- get :index, params: params({ format: :json })
+ it "has data" do
+ get :index, params: params({format: :json})
expect(response).to have_gitlab_http_status(200)
@@ -99,7 +99,7 @@ describe Projects::Serverless::FunctionsController do
)
end
- it 'has data in html' do
+ it "has data in html" do
get :index, params: params
expect(response).to have_gitlab_http_status(200)
diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb
index 601a292bf54..165a0c3e06a 100644
--- a/spec/controllers/projects/services_controller_spec.rb
+++ b/spec/controllers/projects/services_controller_spec.rb
@@ -1,80 +1,80 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ServicesController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { create(:jira_service, project: project) }
- let(:service_params) { { username: 'username', password: 'password', url: 'http://example.com' } }
+ let(:service_params) { {username: "username", password: "password", url: "http://example.com"} }
before do
sign_in(user)
project.add_maintainer(user)
end
- describe '#test' do
- context 'when can_test? returns false' do
- it 'renders 404' do
+ describe "#test" do
+ context "when can_test? returns false" do
+ it "renders 404" do
allow_any_instance_of(Service).to receive(:can_test?).and_return(false)
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param }
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when validations fail' do
- let(:service_params) { { active: 'true', url: '' } }
+ context "when validations fail" do
+ let(:service_params) { {active: "true", url: ""} }
- it 'returns error messages in JSON response' do
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params }
+ it "returns error messages in JSON response" do
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params}
- expect(json_response['message']).to eq "Validations failed."
- expect(json_response['service_response']).to include "Url can't be blank"
+ expect(json_response["message"]).to eq "Validations failed."
+ expect(json_response["service_response"]).to include "Url can't be blank"
expect(response).to have_gitlab_http_status(200)
end
end
- context 'success' do
- context 'with empty project' do
+ context "success" do
+ context "with empty project" do
let(:project) { create(:project) }
- context 'with chat notification service' do
- let(:service) { project.create_microsoft_teams_service(webhook: 'http://webhook.com') }
+ context "with chat notification service" do
+ let(:service) { project.create_microsoft_teams_service(webhook: "http://webhook.com") }
- it 'returns success' do
+ it "returns success" do
allow_any_instance_of(MicrosoftTeams::Notifier).to receive(:ping).and_return(true)
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param }
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param}
expect(response.status).to eq(200)
end
end
- it 'returns success' do
- stub_request(:get, 'http://example.com/rest/api/2/serverInfo')
- .to_return(status: 200, body: '{}')
+ it "returns success" do
+ stub_request(:get, "http://example.com/rest/api/2/serverInfo")
+ .to_return(status: 200, body: "{}")
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params }
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params}
expect(response.status).to eq(200)
end
end
- it 'returns success' do
- stub_request(:get, 'http://example.com/rest/api/2/serverInfo')
- .to_return(status: 200, body: '{}')
+ it "returns success" do
+ stub_request(:get, "http://example.com/rest/api/2/serverInfo")
+ .to_return(status: 200, body: "{}")
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params }
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params}
expect(response.status).to eq(200)
end
- context 'when service is configured for the first time' do
+ context "when service is configured for the first time" do
before do
allow_any_instance_of(ServiceHook).to receive(:execute).and_return(true)
end
- it 'persist the object' do
+ it "persist the object" do
do_put
expect(response).to have_gitlab_http_status(200)
@@ -82,7 +82,7 @@ describe Projects::ServicesController do
expect(BuildkiteService.first).to be_present
end
- it 'creates the ServiceHook object' do
+ it "creates the ServiceHook object" do
do_put
expect(response).to have_gitlab_http_status(200)
@@ -92,95 +92,95 @@ describe Projects::ServicesController do
def do_put
put :test, params: {
- namespace_id: project.namespace,
- project_id: project,
- id: 'buildkite',
- service: { 'active' => '1', 'push_events' => '1', token: 'token', 'project_url' => 'http://test.com' }
- }
+ namespace_id: project.namespace,
+ project_id: project,
+ id: "buildkite",
+ service: {"active" => "1", "push_events" => "1", :token => "token", "project_url" => "http://test.com"},
+ }
end
end
end
- context 'failure' do
- it 'returns success status code and the error message' do
- stub_request(:get, 'http://example.com/rest/api/2/serverInfo')
+ context "failure" do
+ it "returns success status code and the error message" do
+ stub_request(:get, "http://example.com/rest/api/2/serverInfo")
.to_return(status: 404)
- put :test, params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params }
+ put :test, params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: service_params}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to eq(
- 'error' => true,
- 'message' => 'Test failed.',
- 'service_response' => '',
- 'test_failed' => true
+ "error" => true,
+ "message" => "Test failed.",
+ "service_response" => "",
+ "test_failed" => true
)
end
end
end
- describe 'PUT #update' do
- context 'when param `active` is set to true' do
- it 'activates the service and redirects to integrations paths' do
+ describe "PUT #update" do
+ context "when param `active` is set to true" do
+ it "activates the service and redirects to integrations paths" do
put :update,
- params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: { active: true } }
+ params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: {active: true}}
expect(response).to redirect_to(project_settings_integrations_path(project))
- expect(flash[:notice]).to eq 'JIRA activated.'
+ expect(flash[:notice]).to eq "JIRA activated."
end
end
- context 'when param `active` is set to false' do
- it 'does not activate the service but saves the settings' do
+ context "when param `active` is set to false" do
+ it "does not activate the service but saves the settings" do
put :update,
- params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: { active: false } }
+ params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: {active: false}}
- expect(flash[:notice]).to eq 'JIRA settings saved, but not activated.'
+ expect(flash[:notice]).to eq "JIRA settings saved, but not activated."
end
end
- context 'with a deprecated service' do
+ context "with a deprecated service" do
let(:service) { create(:kubernetes_service, project: project) }
before do
put :update,
- params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: { namespace: 'updated_namespace' } }
+ params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: {namespace: "updated_namespace"}}
end
- it 'should not update the service' do
+ it "should not update the service" do
service.reload
- expect(service.namespace).not_to eq('updated_namespace')
+ expect(service.namespace).not_to eq("updated_namespace")
end
end
- context 'when activating JIRA service from a template' do
+ context "when activating JIRA service from a template" do
let(:template_service) { create(:jira_service, project: project, template: true) }
- it 'activate JIRA service from template' do
- put :update, params: { namespace_id: project.namespace, project_id: project, id: service.to_param, service: { active: true } }
+ it "activate JIRA service from template" do
+ put :update, params: {namespace_id: project.namespace, project_id: project, id: service.to_param, service: {active: true}}
- expect(flash[:notice]).to eq 'JIRA activated.'
+ expect(flash[:notice]).to eq "JIRA activated."
end
end
end
describe "GET #edit" do
before do
- get :edit, params: { namespace_id: project.namespace, project_id: project, id: service_id }
+ get :edit, params: {namespace_id: project.namespace, project_id: project, id: service_id}
end
- context 'with approved services' do
- let(:service_id) { 'jira' }
+ context "with approved services" do
+ let(:service_id) { "jira" }
- it 'should render edit page' do
+ it "should render edit page" do
expect(response).to be_success
end
end
- context 'with a deprecated service' do
- let(:service_id) { 'kubernetes' }
+ context "with a deprecated service" do
+ let(:service_id) { "kubernetes" }
- it 'should render edit page' do
+ it "should render edit page" do
expect(response).to be_success
end
end
diff --git a/spec/controllers/projects/settings/ci_cd_controller_spec.rb b/spec/controllers/projects/settings/ci_cd_controller_spec.rb
index 41cc0607cee..02074da5a61 100644
--- a/spec/controllers/projects/settings/ci_cd_controller_spec.rb
+++ b/spec/controllers/projects/settings/ci_cd_controller_spec.rb
@@ -1,4 +1,4 @@
-require('spec_helper')
+require("spec_helper")
describe Projects::Settings::CiCdController do
set(:user) { create(:user) }
@@ -10,15 +10,15 @@ describe Projects::Settings::CiCdController do
sign_in(user)
end
- describe 'GET show' do
- it 'renders show with 200 status code' do
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET show" do
+ it "renders show with 200 status code" do
+ get :show, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:show)
end
- context 'with group runners' do
+ context "with group runners" do
let(:parent_group) { create(:group) }
let(:group) { create(:group, parent: parent_group) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
@@ -26,17 +26,17 @@ describe Projects::Settings::CiCdController do
let!(:project_runner) { create(:ci_runner, :project, projects: [other_project]) }
let!(:shared_runner) { create(:ci_runner, :instance) }
- it 'sets assignable project runners only' do
+ it "sets assignable project runners only" do
group.add_maintainer(user)
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ get :show, params: {namespace_id: project.namespace, project_id: project}
expect(assigns(:assignable_runners)).to contain_exactly(project_runner)
end
end
end
- describe '#reset_cache' do
+ describe "#reset_cache" do
before do
sign_in(user)
@@ -45,28 +45,28 @@ describe Projects::Settings::CiCdController do
allow(ResetProjectCacheService).to receive_message_chain(:new, :execute).and_return(true)
end
- subject { post :reset_cache, params: { namespace_id: project.namespace, project_id: project }, format: :json }
+ subject { post :reset_cache, params: {namespace_id: project.namespace, project_id: project}, format: :json }
- it 'calls reset project cache service' do
+ it "calls reset project cache service" do
expect(ResetProjectCacheService).to receive_message_chain(:new, :execute)
subject
end
- context 'when service returns successfully' do
- it 'returns a success header' do
+ context "when service returns successfully" do
+ it "returns a success header" do
subject
expect(response).to have_gitlab_http_status(:ok)
end
end
- context 'when service does not return successfully' do
+ context "when service does not return successfully" do
before do
allow(ResetProjectCacheService).to receive_message_chain(:new, :execute).and_return(false)
end
- it 'returns an error header' do
+ it "returns an error header" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
@@ -74,45 +74,45 @@ describe Projects::Settings::CiCdController do
end
end
- describe 'PUT #reset_registration_token' do
- subject { put :reset_registration_token, params: { namespace_id: project.namespace, project_id: project } }
- it 'resets runner registration token' do
+ describe "PUT #reset_registration_token" do
+ subject { put :reset_registration_token, params: {namespace_id: project.namespace, project_id: project} }
+ it "resets runner registration token" do
expect { subject }.to change { project.reload.runners_token }
end
- it 'redirects the user to admin runners page' do
+ it "redirects the user to admin runners page" do
subject
expect(response).to redirect_to(namespace_project_settings_ci_cd_path)
end
end
- describe 'PATCH update' do
- let(:params) { { ci_config_path: '' } }
+ describe "PATCH update" do
+ let(:params) { {ci_config_path: ""} }
subject do
patch :update,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- project: params
- }
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ project: params,
+ }
end
- it 'redirects to the settings page' do
+ it "redirects to the settings page" do
subject
expect(response).to have_gitlab_http_status(302)
expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.")
end
- context 'when updating the auto_devops settings' do
- let(:params) { { auto_devops_attributes: { enabled: '', domain: 'mepmep.md' } } }
+ context "when updating the auto_devops settings" do
+ let(:params) { {auto_devops_attributes: {enabled: "", domain: "mepmep.md"}} }
- context 'following the instance default' do
- let(:params) { { auto_devops_attributes: { enabled: '' } } }
+ context "following the instance default" do
+ let(:params) { {auto_devops_attributes: {enabled: ""}} }
- it 'allows enabled to be set to nil' do
+ it "allows enabled to be set to nil" do
subject
project_auto_devops.reload
@@ -120,33 +120,33 @@ describe Projects::Settings::CiCdController do
end
end
- context 'when run_auto_devops_pipeline is true' do
+ context "when run_auto_devops_pipeline is true" do
before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true)
end
- context 'when the project repository is empty' do
- it 'sets a warning flash' do
+ context "when the project repository is empty" do
+ it "sets a warning flash" do
expect(subject).to set_flash[:warning]
end
- it 'does not queue a CreatePipelineWorker' do
+ it "does not queue a CreatePipelineWorker" do
expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args)
subject
end
end
- context 'when the project repository is not empty' do
+ context "when the project repository is not empty" do
let(:project) { create(:project, :repository) }
- it 'sets a success flash' do
+ it "sets a success flash" do
allow(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args)
expect(subject).to set_flash[:success]
end
- it 'queues a CreatePipelineWorker' do
+ it "queues a CreatePipelineWorker" do
expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args)
subject
@@ -154,12 +154,12 @@ describe Projects::Settings::CiCdController do
end
end
- context 'when run_auto_devops_pipeline is not true' do
+ context "when run_auto_devops_pipeline is not true" do
before do
expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false)
end
- it 'does not queue a CreatePipelineWorker' do
+ it "does not queue a CreatePipelineWorker" do
expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args)
subject
@@ -167,11 +167,11 @@ describe Projects::Settings::CiCdController do
end
end
- context 'when updating general settings' do
- context 'when build_timeout_human_readable is not specified' do
- let(:params) { { build_timeout_human_readable: '' } }
+ context "when updating general settings" do
+ context "when build_timeout_human_readable is not specified" do
+ let(:params) { {build_timeout_human_readable: ""} }
- it 'set default timeout' do
+ it "set default timeout" do
subject
project.reload
@@ -179,10 +179,10 @@ describe Projects::Settings::CiCdController do
end
end
- context 'when build_timeout_human_readable is specified' do
- let(:params) { { build_timeout_human_readable: '1h 30m' } }
+ context "when build_timeout_human_readable is specified" do
+ let(:params) { {build_timeout_human_readable: "1h 30m"} }
- it 'set specified timeout' do
+ it "set specified timeout" do
subject
project.reload
diff --git a/spec/controllers/projects/settings/integrations_controller_spec.rb b/spec/controllers/projects/settings/integrations_controller_spec.rb
index 8624eb4d1a0..52fff43c007 100644
--- a/spec/controllers/projects/settings/integrations_controller_spec.rb
+++ b/spec/controllers/projects/settings/integrations_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Settings::IntegrationsController do
let(:project) { create(:project, :public) }
@@ -9,9 +9,9 @@ describe Projects::Settings::IntegrationsController do
sign_in(user)
end
- describe 'GET show' do
- it 'renders show with 200 status code' do
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET show" do
+ it "renders show with 200 status code" do
+ get :show, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:show)
diff --git a/spec/controllers/projects/settings/operations_controller_spec.rb b/spec/controllers/projects/settings/operations_controller_spec.rb
index d989ec22481..35e4ea15dbc 100644
--- a/spec/controllers/projects/settings/operations_controller_spec.rb
+++ b/spec/controllers/projects/settings/operations_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Settings::OperationsController do
set(:user) { create(:user) }
@@ -11,21 +11,21 @@ describe Projects::Settings::OperationsController do
project.add_maintainer(user)
end
- context 'error tracking' do
- describe 'GET #show' do
- it 'renders show template' do
+ context "error tracking" do
+ describe "GET #show" do
+ it "renders show template" do
get :show, params: project_params(project)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to render_template(:show)
end
- context 'with existing setting' do
+ context "with existing setting" do
let!(:error_tracking_setting) do
create(:project_error_tracking_setting, project: project)
end
- it 'loads existing setting' do
+ it "loads existing setting" do
get :show, params: project_params(project)
expect(controller.helpers.error_tracking_setting)
@@ -33,32 +33,32 @@ describe Projects::Settings::OperationsController do
end
end
- context 'without an existing setting' do
- it 'builds a new setting' do
+ context "without an existing setting" do
+ it "builds a new setting" do
get :show, params: project_params(project)
expect(controller.helpers.error_tracking_setting).to be_new_record
end
end
- context 'with insufficient permissions' do
+ context "with insufficient permissions" do
before do
project.add_reporter(user)
end
- it 'renders 404' do
+ it "renders 404" do
get :show, params: project_params(project)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'as an anonymous user' do
+ context "as an anonymous user" do
before do
sign_out(user)
end
- it 'redirects to signup page' do
+ it "redirects to signup page" do
get :show, params: project_params(project)
expect(response).to redirect_to(new_user_session_path)
@@ -66,42 +66,42 @@ describe Projects::Settings::OperationsController do
end
end
- describe 'PATCH #update' do
+ describe "PATCH #update" do
let(:operations_update_service) { spy(:operations_update_service) }
let(:operations_url) { project_settings_operations_url(project) }
let(:error_tracking_params) do
{
error_tracking_setting_attributes: {
- enabled: '1',
- api_url: 'http://url',
- token: 'token'
- }
+ enabled: "1",
+ api_url: "http://url",
+ token: "token",
+ },
}
end
let(:error_tracking_permitted) do
ActionController::Parameters.new(error_tracking_params).permit!
end
- context 'when update succeeds' do
+ context "when update succeeds" do
before do
stub_operations_update_service_returning(status: :success)
end
- it 'shows a notice' do
+ it "shows a notice" do
patch :update, params: project_params(project, error_tracking_params)
expect(response).to redirect_to(operations_url)
- expect(flash[:notice]).to eq _('Your changes have been saved')
+ expect(flash[:notice]).to eq _("Your changes have been saved")
end
end
- context 'when update fails' do
+ context "when update fails" do
before do
stub_operations_update_service_returning(status: :error)
end
- it 'renders show page' do
+ it "renders show page" do
patch :update, params: project_params(project, error_tracking_params)
expect(response).to have_gitlab_http_status(:ok)
@@ -109,24 +109,24 @@ describe Projects::Settings::OperationsController do
end
end
- context 'with insufficient permissions' do
+ context "with insufficient permissions" do
before do
project.add_reporter(user)
end
- it 'renders 404' do
+ it "renders 404" do
patch :update, params: project_params(project)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'as an anonymous user' do
+ context "as an anonymous user" do
before do
sign_out(user)
end
- it 'redirects to signup page' do
+ it "redirects to signup page" do
patch :update, params: project_params(project)
expect(response).to redirect_to(new_user_session_path)
@@ -151,7 +151,7 @@ describe Projects::Settings::OperationsController do
{
namespace_id: project.namespace,
project_id: project,
- project: params
+ project: params,
}
end
end
diff --git a/spec/controllers/projects/settings/repository_controller_spec.rb b/spec/controllers/projects/settings/repository_controller_spec.rb
index 638cce60a25..67f70247ea1 100644
--- a/spec/controllers/projects/settings/repository_controller_spec.rb
+++ b/spec/controllers/projects/settings/repository_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Settings::RepositoryController do
let(:project) { create(:project_empty_repo, :public) }
@@ -9,22 +9,22 @@ describe Projects::Settings::RepositoryController do
sign_in(user)
end
- describe 'GET show' do
- it 'renders show with 200 status code' do
- get :show, params: { namespace_id: project.namespace, project_id: project }
+ describe "GET show" do
+ it "renders show with 200 status code" do
+ get :show, params: {namespace_id: project.namespace, project_id: project}
expect(response).to have_gitlab_http_status(200)
expect(response).to render_template(:show)
end
end
- describe 'PUT cleanup' do
- let(:object_map) { fixture_file_upload('spec/fixtures/bfg_object_map.txt') }
+ describe "PUT cleanup" do
+ let(:object_map) { fixture_file_upload("spec/fixtures/bfg_object_map.txt") }
- it 'enqueues a RepositoryCleanupWorker' do
+ it "enqueues a RepositoryCleanupWorker" do
allow(RepositoryCleanupWorker).to receive(:perform_async)
- put :cleanup, params: { namespace_id: project.namespace, project_id: project, project: { object_map: object_map } }
+ put :cleanup, params: {namespace_id: project.namespace, project_id: project, project: {object_map: object_map}}
expect(response).to redirect_to project_settings_repository_path(project)
expect(RepositoryCleanupWorker).to have_received(:perform_async).once
diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb
index 8d9cb2c8ac0..cf0cd46a95d 100644
--- a/spec/controllers/projects/snippets_controller_spec.rb
+++ b/spec/controllers/projects/snippets_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::SnippetsController do
let(:project) { create(:project_empty_repo, :public) }
@@ -10,28 +10,28 @@ describe Projects::SnippetsController do
project.add_maintainer(user2)
end
- describe 'GET #index' do
- context 'when page param' do
+ describe "GET #index" do
+ context "when page param" do
let(:last_page) { project.snippets.page.total_pages }
let!(:project_snippet) { create(:project_snippet, :public, project: project, author: user) }
- it 'redirects to last_page if page number is larger than number of pages' do
+ it "redirects to last_page if page number is larger than number of pages" do
get :index,
params: {
namespace_id: project.namespace,
project_id: project,
- page: (last_page + 1).to_param
+ page: (last_page + 1).to_param,
}
expect(response).to redirect_to(namespace_project_snippets_path(page: last_page))
end
- it 'redirects to specified page' do
+ it "redirects to specified page" do
get :index,
params: {
namespace_id: project.namespace,
project_id: project,
- page: last_page.to_param
+ page: last_page.to_param,
}
expect(assigns(:snippets).current_page).to eq(last_page)
@@ -39,38 +39,38 @@ describe Projects::SnippetsController do
end
end
- context 'when the project snippet is private' do
+ context "when the project snippet is private" do
let!(:project_snippet) { create(:project_snippet, :private, project: project, author: user) }
- context 'when anonymous' do
- it 'does not include the private snippet' do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ context "when anonymous" do
+ it "does not include the private snippet" do
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(assigns(:snippets)).not_to include(project_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when signed in as the author' do
+ context "when signed in as the author" do
before do
sign_in(user)
end
- it 'renders the snippet' do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ it "renders the snippet" do
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(assigns(:snippets)).to include(project_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when signed in as a project member' do
+ context "when signed in as a project member" do
before do
sign_in(user2)
end
- it 'renders the snippet' do
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ it "renders the snippet" do
+ get :index, params: {namespace_id: project.namespace, project_id: project}
expect(assigns(:snippets)).to include(project_snippet)
expect(response).to have_gitlab_http_status(200)
@@ -79,7 +79,7 @@ describe Projects::SnippetsController do
end
end
- describe 'POST #create' do
+ describe "POST #create" do
def create_snippet(project, snippet_params = {}, additional_params = {})
sign_in(user)
@@ -88,45 +88,45 @@ describe Projects::SnippetsController do
post :create, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- project_snippet: { title: 'Title', content: 'Content', description: 'Description' }.merge(snippet_params)
+ project_snippet: {title: "Title", content: "Content", description: "Description"}.merge(snippet_params),
}.merge(additional_params)
Snippet.last
end
- it 'creates the snippet correctly' do
+ it "creates the snippet correctly" do
snippet = create_snippet(project, visibility_level: Snippet::PRIVATE)
- expect(snippet.title).to eq('Title')
- expect(snippet.content).to eq('Content')
- expect(snippet.description).to eq('Description')
+ expect(snippet.title).to eq("Title")
+ expect(snippet.content).to eq("Content")
+ expect(snippet.description).to eq("Description")
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
- it 'creates the snippet' do
+ context "when the snippet is private" do
+ it "creates the snippet" do
expect { create_snippet(project, visibility_level: Snippet::PRIVATE) }
.to change { Snippet.count }.by(1)
end
end
- context 'when the snippet is public' do
- it 'rejects the shippet' do
+ context "when the snippet is public" do
+ it "rejects the shippet" do
expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }
.not_to change { Snippet.count }
expect(response).to render_template(:new)
end
- it 'creates a spam log' do
+ it "creates a spam log" do
expect { create_snippet(project, visibility_level: Snippet::PUBLIC) }
.to change { SpamLog.count }.by(1)
end
- it 'renders :new with recaptcha disabled' do
+ it "renders :new with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
create_snippet(project, visibility_level: Snippet::PUBLIC)
@@ -134,25 +134,25 @@ describe Projects::SnippetsController do
expect(response).to render_template(:new)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
+ it "renders :verify with recaptcha enabled" do
create_snippet(project, visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
create_snippet(project,
- { visibility_level: Snippet::PUBLIC },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ {visibility_level: Snippet::PUBLIC},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(project_snippet_path(project, Snippet.last))
end
@@ -161,7 +161,7 @@ describe Projects::SnippetsController do
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
let(:project) { create :project, :public }
let(:snippet) { create :project_snippet, author: user, project: project, visibility_level: visibility_level }
@@ -174,110 +174,110 @@ describe Projects::SnippetsController do
namespace_id: project.namespace.to_param,
project_id: project,
id: snippet.id,
- project_snippet: { title: 'Title', content: 'Content' }.merge(snippet_params)
+ project_snippet: {title: "Title", content: "Content"}.merge(snippet_params),
}.merge(additional_params)
snippet.reload
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
+ context "when the snippet is private" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'updates the snippet' do
- expect { update_snippet(title: 'Foo') }
- .to change { snippet.reload.title }.to('Foo')
+ it "updates the snippet" do
+ expect { update_snippet(title: "Foo") }
+ .to change { snippet.reload.title }.to("Foo")
end
end
- context 'when the snippet is public' do
+ context "when the snippet is public" do
let(:visibility_level) { Snippet::PUBLIC }
- it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo') }
+ it "rejects the shippet" do
+ expect { update_snippet(title: "Foo") }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo") }
.to change { SpamLog.count }.by(1)
end
- it 'renders :edit with recaptcha disabled' do
+ it "renders :edit with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
- update_snippet(title: 'Foo')
+ update_snippet(title: "Foo")
expect(response).to render_template(:edit)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
- update_snippet(title: 'Foo')
+ it "renders :verify with recaptcha enabled" do
+ update_snippet(title: "Foo")
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
- snippet = update_snippet({ title: spammy_title },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ snippet = update_snippet({title: spammy_title},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(project_snippet_path(project, snippet))
end
end
end
- context 'when the private snippet is made public' do
+ context "when the private snippet is made public" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ it "rejects the shippet" do
+ expect { update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC) }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC) }
.to change { SpamLog.count }.by(1)
end
- it 'renders :edit with recaptcha disabled' do
+ it "renders :edit with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
- update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
+ update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:edit)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
- update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
+ it "renders :verify with recaptcha enabled" do
+ update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
- snippet = update_snippet({ title: spammy_title, visibility_level: Snippet::PUBLIC },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ snippet = update_snippet({title: spammy_title, visibility_level: Snippet::PUBLIC},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(project_snippet_path(project, snippet))
end
@@ -286,7 +286,7 @@ describe Projects::SnippetsController do
end
end
- describe 'POST #mark_as_spam' do
+ describe "POST #mark_as_spam" do
let(:snippet) { create(:project_snippet, :private, project: project, author: user) }
before do
@@ -301,14 +301,14 @@ describe Projects::SnippetsController do
sign_in(admin)
post :mark_as_spam,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: snippet.id
- }
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: snippet.id,
+ }
end
- it 'updates the snippet' do
+ it "updates the snippet" do
mark_as_spam
expect(snippet.reload).not_to be_submittable_as_spam
@@ -317,37 +317,37 @@ describe Projects::SnippetsController do
%w[show raw].each do |action|
describe "GET ##{action}" do
- context 'when the project snippet is private' do
+ context "when the project snippet is private" do
let(:project_snippet) { create(:project_snippet, :private, project: project, author: user) }
- context 'when anonymous' do
- it 'responds with status 404' do
- get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
+ context "when anonymous" do
+ it "responds with status 404" do
+ get action, params: {namespace_id: project.namespace, project_id: project, id: project_snippet.to_param}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when signed in as the author' do
+ context "when signed in as the author" do
before do
sign_in(user)
end
- it 'renders the snippet' do
- get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
+ it "renders the snippet" do
+ get action, params: {namespace_id: project.namespace, project_id: project, id: project_snippet.to_param}
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when signed in as a project member' do
+ context "when signed in as a project member" do
before do
sign_in(user2)
end
- it 'renders the snippet' do
- get action, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }
+ it "renders the snippet" do
+ get action, params: {namespace_id: project.namespace, project_id: project, id: project_snippet.to_param}
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200)
@@ -355,22 +355,22 @@ describe Projects::SnippetsController do
end
end
- context 'when the project snippet does not exist' do
- context 'when anonymous' do
- it 'responds with status 404' do
- get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
+ context "when the project snippet does not exist" do
+ context "when anonymous" do
+ it "responds with status 404" do
+ get action, params: {namespace_id: project.namespace, project_id: project, id: 42}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 404' do
- get action, params: { namespace_id: project.namespace, project_id: project, id: 42 }
+ it "responds with status 404" do
+ get action, params: {namespace_id: project.namespace, project_id: project, id: 42}
expect(response).to have_gitlab_http_status(404)
end
@@ -385,33 +385,33 @@ describe Projects::SnippetsController do
before do
sign_in(user)
- get :show, params: { namespace_id: project.namespace, project_id: project, id: project_snippet.to_param }, format: :js
+ get :show, params: {namespace_id: project.namespace, project_id: project, id: project_snippet.to_param}, format: :js
end
- context 'when snippet is private' do
+ context "when snippet is private" do
let(:snippet_permission) { :private }
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when snippet is public' do
+ context "when snippet is public" do
let(:snippet_permission) { :public }
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:project) { create(:project_empty_repo, :private) }
- context 'when snippet is public' do
+ context "when snippet is public" do
let(:project_snippet) { create(:project_snippet, :public, project: project, author: user) }
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(assigns(:snippet)).to eq(project_snippet)
expect(response).to have_gitlab_http_status(404)
end
@@ -419,7 +419,7 @@ describe Projects::SnippetsController do
end
end
- describe 'GET #raw' do
+ describe "GET #raw" do
let(:project_snippet) do
create(
:project_snippet, :public,
@@ -429,22 +429,22 @@ describe Projects::SnippetsController do
)
end
- context 'CRLF line ending' do
+ context "CRLF line ending" do
let(:params) do
{
namespace_id: project.namespace,
project_id: project,
- id: project_snippet.to_param
+ id: project_snippet.to_param,
}
end
- it 'returns LF line endings by default' do
+ it "returns LF line endings by default" do
get :raw, params: params
expect(response.body).to eq("first line\nsecond line\nthird line")
end
- it 'does not convert line endings when parameter present' do
+ it "does not convert line endings when parameter present" do
get :raw, params: params.merge(line_ending: :raw)
expect(response.body).to eq("first line\r\nsecond line\r\nthird line")
diff --git a/spec/controllers/projects/tags/releases_controller_spec.rb b/spec/controllers/projects/tags/releases_controller_spec.rb
index 29f206c574b..ec9fa705658 100644
--- a/spec/controllers/projects/tags/releases_controller_spec.rb
+++ b/spec/controllers/projects/tags/releases_controller_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Tags::ReleasesController do
let!(:project) { create(:project, :repository) }
@@ -13,20 +13,20 @@ describe Projects::Tags::ReleasesController do
sign_in(user)
end
- describe 'GET #edit' do
- it 'initializes a new release' do
+ describe "GET #edit" do
+ it "initializes a new release" do
tag_id = release.tag
project.releases.destroy_all # rubocop: disable DestroyAll
- get :edit, params: { namespace_id: project.namespace, project_id: project, tag_id: tag_id }
+ get :edit, params: {namespace_id: project.namespace, project_id: project, tag_id: tag_id}
release = assigns(:release)
expect(release).not_to be_nil
expect(release).not_to be_persisted
end
- it 'retrieves an existing release' do
- get :edit, params: { namespace_id: project.namespace, project_id: project, tag_id: release.tag }
+ it "retrieves an existing release" do
+ get :edit, params: {namespace_id: project.namespace, project_id: project, tag_id: release.tag}
release = assigns(:release)
expect(release).not_to be_nil
@@ -34,16 +34,16 @@ describe Projects::Tags::ReleasesController do
end
end
- describe 'PUT #update' do
- it 'updates release note description' do
- update_release('description updated')
+ describe "PUT #update" do
+ it "updates release note description" do
+ update_release("description updated")
release = project.releases.find_by_tag(tag)
expect(release.description).to eq("description updated")
end
- it 'deletes release note when description is null' do
- expect { update_release('') }.to change(project.releases, :count).by(-1)
+ it "deletes release note when description is null" do
+ expect { update_release("") }.to change(project.releases, :count).by(-1)
end
end
@@ -52,7 +52,7 @@ describe Projects::Tags::ReleasesController do
namespace_id: project.namespace.to_param,
project_id: project,
tag_id: release.tag,
- release: { description: description }
+ release: {description: description},
}
end
end
diff --git a/spec/controllers/projects/tags_controller_spec.rb b/spec/controllers/projects/tags_controller_spec.rb
index 379430bff3b..b149ea7fa31 100644
--- a/spec/controllers/projects/tags_controller_spec.rb
+++ b/spec/controllers/projects/tags_controller_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::TagsController do
let(:project) { create(:project, :public, :repository) }
let!(:release) { create(:release, project: project) }
- let!(:invalid_release) { create(:release, project: project, tag: 'does-not-exist') }
+ let!(:invalid_release) { create(:release, project: project, tag: "does-not-exist") }
- describe 'GET index' do
+ describe "GET index" do
before do
- get :index, params: { namespace_id: project.namespace.to_param, project_id: project }
+ get :index, params: {namespace_id: project.namespace.to_param, project_id: project}
end
- it 'returns the tags for the page' do
- expect(assigns(:tags).map(&:name)).to eq(['v1.1.0', 'v1.0.0'])
+ it "returns the tags for the page" do
+ expect(assigns(:tags).map(&:name)).to eq(["v1.1.0", "v1.0.0"])
end
- it 'returns releases matching those tags' do
+ it "returns releases matching those tags" do
expect(assigns(:releases)).to include(release)
expect(assigns(:releases)).not_to include(invalid_release)
end
end
- describe 'GET show' do
+ describe "GET show" do
before do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project, id: id }
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project, id: id}
end
context "valid tag" do
- let(:id) { 'v1.0.0' }
+ let(:id) { "v1.0.0" }
it { is_expected.to respond_with(:success) }
end
context "invalid tag" do
- let(:id) { 'latest' }
+ let(:id) { "latest" }
it { is_expected.to respond_with(:not_found) }
end
end
- context 'private project with token authentication' do
+ context "private project with token authentication" do
let(:private_project) { create(:project, :repository, :private) }
- it_behaves_like 'authenticates sessionless user', :index, :atom do
+ it_behaves_like "authenticates sessionless user", :index, :atom do
before do
default_params.merge!(project_id: private_project, namespace_id: private_project.namespace)
@@ -48,10 +48,10 @@ describe Projects::TagsController do
end
end
- context 'public project with token authentication' do
+ context "public project with token authentication" do
let(:public_project) { create(:project, :repository, :public) }
- it_behaves_like 'authenticates sessionless user', :index, :atom, public: true do
+ it_behaves_like "authenticates sessionless user", :index, :atom, public: true do
before do
default_params.merge!(project_id: public_project, namespace_id: public_project.namespace)
end
diff --git a/spec/controllers/projects/templates_controller_spec.rb b/spec/controllers/projects/templates_controller_spec.rb
index 01e53669627..7bbd6f65269 100644
--- a/spec/controllers/projects/templates_controller_spec.rb
+++ b/spec/controllers/projects/templates_controller_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::TemplatesController do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
- let(:file_path_1) { '.gitlab/issue_templates/bug.md' }
+ let(:file_path_1) { ".gitlab/issue_templates/bug.md" }
let(:body) { JSON.parse(response.body) }
before do
@@ -14,36 +14,36 @@ describe Projects::TemplatesController do
before do
project.add_user(user, Gitlab::Access::MAINTAINER)
- project.repository.create_file(user, file_path_1, 'something valid',
- message: 'test 3', branch_name: 'master')
+ project.repository.create_file(user, file_path_1, "something valid",
+ message: "test 3", branch_name: "master")
end
- describe '#show' do
- it 'renders template name and content as json' do
- get(:show, params: { namespace_id: project.namespace.to_param, template_type: "issue", key: "bug", project_id: project }, format: :json)
+ describe "#show" do
+ it "renders template name and content as json" do
+ get(:show, params: {namespace_id: project.namespace.to_param, template_type: "issue", key: "bug", project_id: project}, format: :json)
expect(response.status).to eq(200)
expect(body["name"]).to eq("bug")
expect(body["content"]).to eq("something valid")
end
- it 'renders 404 when unauthorized' do
+ it "renders 404 when unauthorized" do
sign_in(user2)
- get(:show, params: { namespace_id: project.namespace.to_param, template_type: "issue", key: "bug", project_id: project }, format: :json)
+ get(:show, params: {namespace_id: project.namespace.to_param, template_type: "issue", key: "bug", project_id: project}, format: :json)
expect(response.status).to eq(404)
end
- it 'renders 404 when template type is not found' do
+ it "renders 404 when template type is not found" do
sign_in(user)
- get(:show, params: { namespace_id: project.namespace.to_param, template_type: "dont_exist", key: "bug", project_id: project }, format: :json)
+ get(:show, params: {namespace_id: project.namespace.to_param, template_type: "dont_exist", key: "bug", project_id: project}, format: :json)
expect(response.status).to eq(404)
end
- it 'renders 404 without errors' do
+ it "renders 404 without errors" do
sign_in(user)
- expect { get(:show, params: { namespace_id: project.namespace.to_param, template_type: "dont_exist", key: "bug", project_id: project }, format: :json) }.not_to raise_error
+ expect { get(:show, params: {namespace_id: project.namespace.to_param, template_type: "dont_exist", key: "bug", project_id: project}, format: :json) }.not_to raise_error
end
end
end
diff --git a/spec/controllers/projects/todos_controller_spec.rb b/spec/controllers/projects/todos_controller_spec.rb
index 987772f38aa..652795c8040 100644
--- a/spec/controllers/projects/todos_controller_spec.rb
+++ b/spec/controllers/projects/todos_controller_spec.rb
@@ -1,4 +1,4 @@
-require('spec_helper')
+require("spec_helper")
describe Projects::TodosController do
let(:user) { create(:user) }
@@ -7,10 +7,10 @@ describe Projects::TodosController do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:parent) { project }
- shared_examples 'project todos actions' do
- it_behaves_like 'todos actions'
+ shared_examples "project todos actions" do
+ it_behaves_like "todos actions"
- context 'when not authorized for resource' do
+ context "when not authorized for resource" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
@@ -25,37 +25,37 @@ describe Projects::TodosController do
end
end
- context 'Issues' do
- describe 'POST create' do
+ context "Issues" do
+ describe "POST create" do
def post_create
post :create,
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: issue.id,
- issuable_type: 'issue'
+ issuable_type: "issue",
},
- format: 'html'
+ format: "html"
end
- it_behaves_like 'project todos actions'
+ it_behaves_like "project todos actions"
end
end
- context 'Merge Requests' do
- describe 'POST create' do
+ context "Merge Requests" do
+ describe "POST create" do
def post_create
post :create,
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: merge_request.id,
- issuable_type: 'merge_request'
+ issuable_type: "merge_request",
},
- format: 'html'
+ format: "html"
end
- it_behaves_like 'project todos actions'
+ it_behaves_like "project todos actions"
end
end
end
diff --git a/spec/controllers/projects/tree_controller_spec.rb b/spec/controllers/projects/tree_controller_spec.rb
index b15a2bc84a5..fa72764bb2d 100644
--- a/spec/controllers/projects/tree_controller_spec.rb
+++ b/spec/controllers/projects/tree_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::TreeController do
let(:project) { create(:project, :repository) }
@@ -17,74 +17,74 @@ describe Projects::TreeController do
before do
get(:show,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: id,
+ })
end
context "valid branch, no path" do
- let(:id) { 'master' }
+ let(:id) { "master" }
it { is_expected.to respond_with(:success) }
end
context "valid branch, valid path" do
- let(:id) { 'master/encoding/' }
+ let(:id) { "master/encoding/" }
it { is_expected.to respond_with(:success) }
end
context "valid branch, invalid path" do
- let(:id) { 'master/invalid-path/' }
+ let(:id) { "master/invalid-path/" }
it { is_expected.to respond_with(:not_found) }
end
context "invalid branch, valid path" do
- let(:id) { 'invalid-branch/encoding/' }
+ let(:id) { "invalid-branch/encoding/" }
it { is_expected.to respond_with(:not_found) }
end
context "valid empty branch, invalid path" do
- let(:id) { 'empty-branch/invalid-path/' }
+ let(:id) { "empty-branch/invalid-path/" }
it { is_expected.to respond_with(:not_found) }
end
context "valid empty branch" do
- let(:id) { 'empty-branch' }
+ let(:id) { "empty-branch" }
it { is_expected.to respond_with(:success) }
end
context "invalid SHA commit ID" do
- let(:id) { 'ff39438/.gitignore' }
+ let(:id) { "ff39438/.gitignore" }
it { is_expected.to respond_with(:not_found) }
end
context "valid SHA commit ID" do
- let(:id) { '6d39438' }
+ let(:id) { "6d39438" }
it { is_expected.to respond_with(:success) }
end
context "valid SHA commit ID with path" do
- let(:id) { '6d39438/.gitignore' }
+ let(:id) { "6d39438/.gitignore" }
it { expect(response).to have_gitlab_http_status(302) }
end
end
- describe 'GET show with blob path' do
+ describe "GET show with blob path" do
render_views
before do
get(:show,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: id
- })
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: id,
+ })
end
- context 'redirect to blob' do
- let(:id) { 'master/README.md' }
- it 'redirects' do
+ context "redirect to blob" do
+ let(:id) { "master/README.md" }
+ it "redirects" do
redirect_url = "/#{project.full_path}/blob/master/README.md"
expect(subject)
.to redirect_to(redirect_url)
@@ -92,40 +92,40 @@ describe Projects::TreeController do
end
end
- describe '#create_dir' do
+ describe "#create_dir" do
render_views
before do
post(:create_dir,
- params: {
- namespace_id: project.namespace.to_param,
- project_id: project,
- id: 'master',
- dir_name: path,
- branch_name: branch_name,
- commit_message: 'Test commit message'
- })
+ params: {
+ namespace_id: project.namespace.to_param,
+ project_id: project,
+ id: "master",
+ dir_name: path,
+ branch_name: branch_name,
+ commit_message: "Test commit message",
+ })
end
- context 'successful creation' do
- let(:path) { 'files/new_dir'}
- let(:branch_name) { 'master-test'}
+ context "successful creation" do
+ let(:path) { "files/new_dir"}
+ let(:branch_name) { "master-test"}
- it 'redirects to the new directory' do
+ it "redirects to the new directory" do
expect(subject)
- .to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}")
- expect(flash[:notice]).to eq('The directory has been successfully created.')
+ .to redirect_to("/#{project.full_path}/tree/#{branch_name}/#{path}")
+ expect(flash[:notice]).to eq("The directory has been successfully created.")
end
end
- context 'unsuccessful creation' do
- let(:path) { 'README.md' }
- let(:branch_name) { 'master'}
+ context "unsuccessful creation" do
+ let(:path) { "README.md" }
+ let(:branch_name) { "master"}
- it 'does not allow overwriting of existing files' do
+ it "does not allow overwriting of existing files" do
expect(subject)
- .to redirect_to("/#{project.full_path}/tree/master")
- expect(flash[:alert]).to eq('A file with this name already exists')
+ .to redirect_to("/#{project.full_path}/tree/master")
+ expect(flash[:alert]).to eq("A file with this name already exists")
end
end
end
diff --git a/spec/controllers/projects/uploads_controller_spec.rb b/spec/controllers/projects/uploads_controller_spec.rb
index cfa67683dd3..ac01c6dd75c 100644
--- a/spec/controllers/projects/uploads_controller_spec.rb
+++ b/spec/controllers/projects/uploads_controller_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::UploadsController do
include WorkhorseHelpers
let(:model) { create(:project, :public) }
let(:params) do
- { namespace_id: model.namespace.to_param, project_id: model }
+ {namespace_id: model.namespace.to_param, project_id: model}
end
- it_behaves_like 'handle uploads'
+ it_behaves_like "handle uploads"
- context 'when the URL the old style, without /-/system' do
- it 'responds with a redirect to the login page' do
- get :show, params: { namespace_id: 'project', project_id: 'avatar', filename: 'foo.png', secret: 'bar' }
+ context "when the URL the old style, without /-/system" do
+ it "responds with a redirect to the login page" do
+ get :show, params: {namespace_id: "project", project_id: "avatar", filename: "foo.png", secret: "bar"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -28,13 +28,13 @@ describe Projects::UploadsController do
post_authorize
expect(response).to have_gitlab_http_status(500)
- expect(response.body).to eq('Error uploading file')
+ expect(response.body).to eq("Error uploading file")
end
end
def post_authorize(verified: true)
request.headers.merge!(workhorse_internal_api_request_header) if verified
- post :authorize, params: { namespace_id: model.namespace, project_id: model.path }, format: :json
+ post :authorize, params: {namespace_id: model.namespace, project_id: model.path}, format: :json
end
end
diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb
index 8cceda72c28..39198270922 100644
--- a/spec/controllers/projects/variables_controller_spec.rb
+++ b/spec/controllers/projects/variables_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::VariablesController do
let(:project) { create(:project) }
@@ -9,17 +9,17 @@ describe Projects::VariablesController do
project.add_maintainer(user)
end
- describe 'GET #show' do
+ describe "GET #show" do
let!(:variable) { create(:ci_variable, project: project) }
subject do
- get :show, params: { namespace_id: project.namespace.to_param, project_id: project }, format: :json
+ get :show, params: {namespace_id: project.namespace.to_param, project_id: project}, format: :json
end
- include_examples 'GET #show lists all variables'
+ include_examples "GET #show lists all variables"
end
- describe 'PATCH #update' do
+ describe "PATCH #update" do
let!(:variable) { create(:ci_variable, project: project) }
let(:owner) { project }
@@ -28,11 +28,11 @@ describe Projects::VariablesController do
params: {
namespace_id: project.namespace.to_param,
project_id: project,
- variables_attributes: variables_attributes
+ variables_attributes: variables_attributes,
},
format: :json
end
- include_examples 'PATCH #update updates variables'
+ include_examples "PATCH #update updates variables"
end
end
diff --git a/spec/controllers/projects/wikis_controller_spec.rb b/spec/controllers/projects/wikis_controller_spec.rb
index b2f40231796..134ec46331e 100644
--- a/spec/controllers/projects/wikis_controller_spec.rb
+++ b/spec/controllers/projects/wikis_controller_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::WikisController do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.owner }
let(:project_wiki) { ProjectWiki.new(project, user) }
let(:wiki) { project_wiki.wiki }
- let(:wiki_title) { 'page-title-test' }
+ let(:wiki_title) { "page-title-test" }
before do
- create_page(wiki_title, 'hello world')
+ create_page(wiki_title, "hello world")
sign_in(user)
end
@@ -17,12 +17,12 @@ describe Projects::WikisController do
destroy_page(wiki_title)
end
- describe 'GET #show' do
+ describe "GET #show" do
render_views
- subject { get :show, params: { namespace_id: project.namespace, project_id: project, id: wiki_title } }
+ subject { get :show, params: {namespace_id: project.namespace, project_id: project, id: wiki_title} }
- it 'limits the retrieved pages for the sidebar' do
+ it "limits the retrieved pages for the sidebar" do
expect(controller).to receive(:load_wiki).and_return(project_wiki)
# empty? call
@@ -36,68 +36,68 @@ describe Projects::WikisController do
expect(response.body).to include(wiki_title)
end
- context 'when page content encoding is invalid' do
- it 'sets flash error' do
+ context "when page content encoding is invalid" do
+ it "sets flash error" do
allow(controller).to receive(:valid_encoding?).and_return(false)
subject
expect(response).to have_http_status(:ok)
- expect(flash[:notice]).to eq 'The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.'
+ expect(flash[:notice]).to eq "The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository."
end
end
- context 'when page is a file' do
+ context "when page is a file" do
include WikiHelpers
let(:path) { upload_file_to_wiki(project, user, file_name) }
before do
- get :show, params: { namespace_id: project.namespace, project_id: project, id: path }
+ get :show, params: {namespace_id: project.namespace, project_id: project, id: path}
end
- context 'when file is an image' do
- let(:file_name) { 'dk.png' }
+ context "when file is an image" do
+ let(:file_name) { "dk.png" }
- it 'delivers the image' do
- expect(response.headers['Content-Disposition']).to match(/^inline/)
+ it "delivers the image" do
+ expect(response.headers["Content-Disposition"]).to match(/^inline/)
expect(response.headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
- context 'when file is a svg' do
- let(:file_name) { 'unsanitized.svg' }
+ context "when file is a svg" do
+ let(:file_name) { "unsanitized.svg" }
- it 'delivers the image' do
- expect(response.headers['Content-Disposition']).to match(/^inline/)
+ it "delivers the image" do
+ expect(response.headers["Content-Disposition"]).to match(/^inline/)
expect(response.headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
end
end
- context 'when file is a pdf' do
- let(:file_name) { 'git-cheat-sheet.pdf' }
+ context "when file is a pdf" do
+ let(:file_name) { "git-cheat-sheet.pdf" }
- it 'sets the content type to sets the content response headers' do
- expect(response.headers['Content-Disposition']).to match(/^inline/)
+ it "sets the content type to sets the content response headers" do
+ expect(response.headers["Content-Disposition"]).to match(/^inline/)
expect(response.headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
end
end
end
- describe 'POST #preview_markdown' do
- it 'renders json in a correct format' do
- post :preview_markdown, params: { namespace_id: project.namespace, project_id: project, id: 'page/path', text: '*Markdown* text' }
+ describe "POST #preview_markdown" do
+ it "renders json in a correct format" do
+ post :preview_markdown, params: {namespace_id: project.namespace, project_id: project, id: "page/path", text: "*Markdown* text"}
- expect(JSON.parse(response.body).keys).to match_array(%w(body references))
+ expect(JSON.parse(response.body).keys).to match_array(%w[body references])
end
end
- describe 'GET #edit' do
- subject { get(:edit, params: { namespace_id: project.namespace, project_id: project, id: wiki_title }) }
+ describe "GET #edit" do
+ subject { get(:edit, params: {namespace_id: project.namespace, project_id: project, id: wiki_title}) }
- context 'when page content encoding is invalid' do
- it 'redirects to show' do
+ context "when page content encoding is invalid" do
+ it "redirects to show" do
allow(controller).to receive(:valid_encoding?).and_return(false)
subject
@@ -106,33 +106,33 @@ describe Projects::WikisController do
end
end
- context 'when page content encoding is valid' do
+ context "when page content encoding is valid" do
render_views
- it 'shows the edit page' do
+ it "shows the edit page" do
subject
expect(response).to have_http_status(:ok)
- expect(response.body).to include('Edit Page')
+ expect(response.body).to include("Edit Page")
end
end
end
- describe 'PATCH #update' do
- let(:new_title) { 'New title' }
- let(:new_content) { 'New content' }
+ describe "PATCH #update" do
+ let(:new_title) { "New title" }
+ let(:new_content) { "New content" }
subject do
patch(:update,
- params: {
- namespace_id: project.namespace,
- project_id: project,
- id: wiki_title,
- wiki: { title: new_title, content: new_content }
- })
+ params: {
+ namespace_id: project.namespace,
+ project_id: project,
+ id: wiki_title,
+ wiki: {title: new_title, content: new_content},
+ })
end
- context 'when page content encoding is invalid' do
- it 'redirects to show' do
+ context "when page content encoding is invalid" do
+ it "redirects to show" do
allow(controller).to receive(:valid_encoding?).and_return(false)
subject
@@ -140,10 +140,10 @@ describe Projects::WikisController do
end
end
- context 'when page content encoding is valid' do
+ context "when page content encoding is valid" do
render_views
- it 'updates the page' do
+ it "updates the page" do
subject
wiki_page = project_wiki.pages.first
@@ -162,7 +162,7 @@ describe Projects::WikisController do
Gitlab::Git::Wiki::CommitDetails.new(user.id, user.username, user.name, user.email, "created page #{name}")
end
- def destroy_page(title, dir = '')
+ def destroy_page(title, dir = "")
page = wiki.page(title: title, dir: dir)
project_wiki.delete_page(page, "test commit")
end
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb
index a1662658ade..cec2242907b 100644
--- a/spec/controllers/projects_controller_spec.rb
+++ b/spec/controllers/projects_controller_spec.rb
@@ -1,4 +1,4 @@
-require('spec_helper')
+require("spec_helper")
describe ProjectsController do
include ProjectForksHelper
@@ -6,44 +6,44 @@ describe ProjectsController do
let(:project) { create(:project) }
let(:public_project) { create(:project, :public) }
let(:user) { create(:user) }
- let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
- let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
+ let(:jpg) { fixture_file_upload("spec/fixtures/rails_sample.jpg", "image/jpg") }
+ let(:txt) { fixture_file_upload("spec/fixtures/doc_sample.txt", "text/plain") }
- describe 'GET new' do
- context 'with an authenticated user' do
+ describe "GET new" do
+ context "with an authenticated user" do
let(:group) { create(:group) }
before do
sign_in(user)
end
- context 'when namespace_id param is present' do
- context 'when user has access to the namespace' do
- it 'renders the template' do
+ context "when namespace_id param is present" do
+ context "when user has access to the namespace" do
+ it "renders the template" do
group.add_owner(user)
- get :new, params: { namespace_id: group.id }
+ get :new, params: {namespace_id: group.id}
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('new')
+ expect(response).to render_template("new")
end
end
- context 'when user does not have access to the namespace' do
- it 'responds with status 404' do
- get :new, params: { namespace_id: group.id }
+ context "when user does not have access to the namespace" do
+ it "responds with status 404" do
+ get :new, params: {namespace_id: group.id}
expect(response).to have_gitlab_http_status(404)
- expect(response).not_to render_template('new')
+ expect(response).not_to render_template("new")
end
end
end
end
end
- describe 'GET index' do
- context 'as a user' do
- it 'redirects to root page' do
+ describe "GET index" do
+ context "as a user" do
+ it "redirects to root page" do
sign_in(user)
get :index
@@ -52,8 +52,8 @@ describe ProjectsController do
end
end
- context 'as a guest' do
- it 'redirects to Explore page' do
+ context "as a guest" do
+ it "redirects to Explore page" do
get :index
expect(response).to redirect_to(explore_root_path)
@@ -71,7 +71,7 @@ describe ProjectsController do
let(:private_project) { create(:project, :private) }
it "does not initialize notification setting" do
- get :show, params: { namespace_id: private_project.namespace, id: private_project }
+ get :show, params: {namespace_id: private_project.namespace, id: private_project}
expect(assigns(:notification_setting)).to be_nil
end
end
@@ -79,7 +79,7 @@ describe ProjectsController do
context "user has access to project" do
context "and does not have notification setting" do
it "initializes notification as disabled" do
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
expect(assigns(:notification_setting).level).to eq("global")
end
end
@@ -92,7 +92,7 @@ describe ProjectsController do
end
it "shows current notification setting" do
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
expect(assigns(:notification_setting).level).to eq("watch")
end
end
@@ -106,42 +106,42 @@ describe ProjectsController do
project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
end
- it 'shows wiki homepage' do
- get :show, params: { namespace_id: project.namespace, id: project }
+ it "shows wiki homepage" do
+ get :show, params: {namespace_id: project.namespace, id: project}
- expect(response).to render_template('projects/_wiki')
+ expect(response).to render_template("projects/_wiki")
end
- it 'shows issues list page if wiki is disabled' do
+ it "shows issues list page if wiki is disabled" do
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
create(:issue, project: project)
- get :show, params: { namespace_id: project.namespace, id: project }
+ get :show, params: {namespace_id: project.namespace, id: project}
- expect(response).to render_template('projects/issues/_issues')
+ expect(response).to render_template("projects/issues/_issues")
expect(assigns(:issuable_meta_data)).not_to be_nil
end
- it 'shows customize workflow page if wiki and issues are disabled' do
+ it "shows customize workflow page if wiki and issues are disabled" do
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
- get :show, params: { namespace_id: project.namespace, id: project }
+ get :show, params: {namespace_id: project.namespace, id: project}
expect(response).to render_template("projects/_customize_workflow")
end
- it 'shows activity if enabled by user' do
- user.update_attribute(:project_view, 'activity')
+ it "shows activity if enabled by user" do
+ user.update_attribute(:project_view, "activity")
- get :show, params: { namespace_id: project.namespace, id: project }
+ get :show, params: {namespace_id: project.namespace, id: project}
expect(response).to render_template("projects/_activity")
end
end
end
- context 'when the storage is not available', :broken_storage do
+ context "when the storage is not available", :broken_storage do
set(:project) { create(:project, :broken_storage) }
before do
@@ -149,8 +149,8 @@ describe ProjectsController do
sign_in(user)
end
- it 'renders a 503' do
- get :show, params: { namespace_id: project.namespace, id: project }
+ it "renders a 503" do
+ get :show, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(503)
end
@@ -168,11 +168,11 @@ describe ProjectsController do
before do
user.update(project_view: project_view)
- get :show, params: { namespace_id: empty_project.namespace, id: empty_project }
+ get :show, params: {namespace_id: empty_project.namespace, id: empty_project}
end
it "renders the empty project view" do
- expect(response).to render_template('empty')
+ expect(response).to render_template("empty")
end
end
end
@@ -190,13 +190,13 @@ describe ProjectsController do
before do
user.update(project_view: project_view)
- get :show, params: { namespace_id: empty_project.namespace, id: empty_project }
+ get :show, params: {namespace_id: empty_project.namespace, id: empty_project}
end
it "renders the empty project view" do
allow(Project).to receive(:repo).and_raise(Gitlab::Git::Repository::NoRepository)
- expect(response).to render_template('projects/no_repo')
+ expect(response).to render_template("projects/no_repo")
end
end
end
@@ -209,60 +209,60 @@ describe ProjectsController do
it "renders the activity view" do
allow(controller).to receive(:current_user).and_return(user)
- allow(user).to receive(:project_view).and_return('activity')
+ allow(user).to receive(:project_view).and_return("activity")
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
- expect(response).to render_template('_activity')
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
+ expect(response).to render_template("_activity")
end
it "renders the files view" do
allow(controller).to receive(:current_user).and_return(user)
- allow(user).to receive(:project_view).and_return('files')
+ allow(user).to receive(:project_view).and_return("files")
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
- expect(response).to render_template('_files')
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
+ expect(response).to render_template("_files")
end
it "renders the readme view" do
allow(controller).to receive(:current_user).and_return(user)
- allow(user).to receive(:project_view).and_return('readme')
+ allow(user).to receive(:project_view).and_return("readme")
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
- expect(response).to render_template('_readme')
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
+ expect(response).to render_template("_readme")
end
end
context "when the url contains .atom" do
- let(:public_project_with_dot_atom) { build(:project, :public, name: 'my.atom', path: 'my.atom') }
+ let(:public_project_with_dot_atom) { build(:project, :public, name: "my.atom", path: "my.atom") }
- it 'expects 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
- context 'when the project is pending deletions' do
- it 'renders a 404 error' do
+ context "when the project is pending deletions" do
+ it "renders a 404 error" do
project = create(:project, pending_delete: true)
sign_in(user)
- get :show, params: { namespace_id: project.namespace, id: project }
+ get :show, params: {namespace_id: project.namespace, id: project}
expect(response.status).to eq 404
end
end
context "redirection from http://someproject.git" do
- it 'redirects to project page (format.html)' do
+ it "redirects to project page (format.html)" do
project = create(:project, :public)
- get :show, params: { namespace_id: project.namespace, id: project }, format: :git
+ get :show, params: {namespace_id: project.namespace, id: project}, format: :git
expect(response).to have_gitlab_http_status(302)
expect(response).to redirect_to(namespace_project_path)
end
end
- context 'when the project is forked and has a repository', :request_store do
+ context "when the project is forked and has a repository", :request_store do
let(:public_project) { create(:project, :public, :repository) }
let(:other_user) { create(:user) }
@@ -275,25 +275,25 @@ describe ProjectsController do
fork_project(public_project)
end
- it 'does not increase the number of queries when the project is forked' do
+ it "does not increase the number of queries when the project is forked" do
expected_query = /#{public_project.fork_network.find_forks_in(other_user.namespace).to_sql}/
- expect { get(:show, params: { namespace_id: public_project.namespace, id: public_project }) }
+ expect { get(:show, params: {namespace_id: public_project.namespace, id: public_project}) }
.not_to exceed_query_limit(2).for_query(expected_query)
end
end
end
- describe 'GET edit' do
- it 'sets the badge API endpoint' do
+ describe "GET edit" do
+ it "sets the badge API endpoint" do
sign_in(user)
project.add_maintainer(user)
get :edit,
- params: {
- namespace_id: project.namespace.path,
- id: project.path
- }
+ params: {
+ namespace_id: project.namespace.path,
+ id: project.path,
+ }
expect(assigns(:badge_api_endpoint)).not_to be_nil
end
@@ -308,20 +308,20 @@ describe ProjectsController do
sign_in(admin)
end
- shared_examples_for 'updating a project' do
- context 'when only renaming a project path' do
+ shared_examples_for "updating a project" do
+ context "when only renaming a project path" do
it "sets the repository to the right path after a rename" do
- original_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ original_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
project.repository.path
- end
+ }
- expect { update_project path: 'renamed_path' }
+ expect { update_project path: "renamed_path" }
.to change { project.reload.path }
- expect(project.path).to include 'renamed_path'
+ expect(project.path).to include "renamed_path"
- assign_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ assign_repository_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
assigns(:repository).path
- end
+ }
if project.hashed_storage?(:repository)
expect(assign_repository_path).to eq(original_repository_path)
@@ -333,15 +333,15 @@ describe ProjectsController do
end
end
- context 'when project has container repositories with tags' do
+ context "when project has container repositories with tags" do
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags(repository: /image/, tags: %w[rc1])
create(:container_repository, project: project, name: :image)
end
- it 'does not allow to rename the project' do
- expect { update_project path: 'renamed_path' }
+ it "does not allow to rename the project" do
+ expect { update_project path: "renamed_path" }
.not_to change { project.reload.path }
expect(controller).to set_flash.now[:alert].to(/container registry tags/)
@@ -349,19 +349,19 @@ describe ProjectsController do
end
end
- it 'updates Fast Forward Merge attributes' do
+ it "updates Fast Forward Merge attributes" do
controller.instance_variable_set(:@project, project)
params = {
- merge_method: :ff
+ merge_method: :ff,
}
put :update,
- params: {
- namespace_id: project.namespace,
- id: project.id,
- project: params
- }
+ params: {
+ namespace_id: project.namespace,
+ id: project.id,
+ project: params,
+ }
expect(response).to have_gitlab_http_status(302)
params.each do |param, value|
@@ -371,44 +371,44 @@ describe ProjectsController do
def update_project(**parameters)
put :update,
- params: {
- namespace_id: project.namespace.path,
- id: project.path,
- project: parameters
- }
+ params: {
+ namespace_id: project.namespace.path,
+ id: project.path,
+ project: parameters,
+ }
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let(:project) { create(:project, :repository) }
- it_behaves_like 'updating a project'
+ it_behaves_like "updating a project"
end
- context 'legacy storage' do
+ context "legacy storage" do
let(:project) { create(:project, :repository, :legacy_storage) }
- it_behaves_like 'updating a project'
+ it_behaves_like "updating a project"
end
end
- describe '#transfer' do
+ describe "#transfer" do
render_views
let(:project) { create(:project, :repository) }
let(:admin) { create(:admin) }
let(:new_namespace) { create(:namespace) }
- it 'updates namespace' do
+ it "updates namespace" do
sign_in(admin)
put :transfer,
- params: {
- namespace_id: project.namespace.path,
- new_namespace_id: new_namespace.id,
- id: project.path
- },
- format: :js
+ params: {
+ namespace_id: project.namespace.path,
+ new_namespace_id: new_namespace.id,
+ id: project.path,
+ },
+ format: :js
project.reload
@@ -416,26 +416,26 @@ describe ProjectsController do
expect(response).to have_gitlab_http_status(200)
end
- context 'when new namespace is empty' do
- it 'project namespace is not changed' do
+ context "when new namespace is empty" do
+ it "project namespace is not changed" do
controller.instance_variable_set(:@project, project)
sign_in(admin)
old_namespace = project.namespace
put :transfer,
- params: {
- namespace_id: old_namespace.path,
- new_namespace_id: nil,
- id: project.path
- },
- format: :js
+ params: {
+ namespace_id: old_namespace.path,
+ new_namespace_id: nil,
+ id: project.path,
+ },
+ format: :js
project.reload
expect(project.namespace).to eq(old_namespace)
expect(response).to have_gitlab_http_status(200)
- expect(flash[:alert]).to eq 'Please select a new namespace for your project.'
+ expect(flash[:alert]).to eq "Please select a new namespace for your project."
end
end
end
@@ -448,7 +448,7 @@ describe ProjectsController do
sign_in(admin)
orig_id = project.id
- delete :destroy, params: { namespace_id: project.namespace, id: project }
+ delete :destroy, params: {namespace_id: project.namespace, id: project}
expect { Project.find(orig_id) }.to raise_error(ActiveRecord::RecordNotFound)
expect(response).to have_gitlab_http_status(302)
@@ -468,20 +468,20 @@ describe ProjectsController do
project.merge_requests << merge_request
sign_in(admin)
- delete :destroy, params: { namespace_id: forked_project.namespace, id: forked_project }
+ delete :destroy, params: {namespace_id: forked_project.namespace, id: forked_project}
- expect(merge_request.reload.state).to eq('closed')
+ expect(merge_request.reload.state).to eq("closed")
end
end
end
- describe 'PUT #new_issuable_address for issue' do
+ describe "PUT #new_issuable_address for issue" do
subject do
put :new_issuable_address,
params: {
namespace_id: project.namespace,
id: project,
- issuable_type: 'issue'
+ issuable_type: "issue",
}
user.reload
end
@@ -492,26 +492,26 @@ describe ProjectsController do
allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
end
- it 'has http status 200' do
+ it "has http status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'changes the user incoming email token' do
+ it "changes the user incoming email token" do
expect { subject }.to change { user.incoming_email_token }
end
- it 'changes projects new issue address' do
- expect { subject }.to change { project.new_issuable_address(user, 'issue') }
+ it "changes projects new issue address" do
+ expect { subject }.to change { project.new_issuable_address(user, "issue") }
end
end
- describe 'PUT #new_issuable_address for merge request' do
+ describe "PUT #new_issuable_address for merge request" do
subject do
put :new_issuable_address,
params: {
namespace_id: project.namespace,
id: project,
- issuable_type: 'merge_request'
+ issuable_type: "merge_request",
}
user.reload
end
@@ -522,16 +522,16 @@ describe ProjectsController do
allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
end
- it 'has http status 200' do
+ it "has http status 200" do
expect(response).to have_http_status(200)
end
- it 'changes the user incoming email token' do
+ it "changes the user incoming email token" do
expect { subject }.to change { user.incoming_email_token }
end
- it 'changes projects new merge request address' do
- expect { subject }.to change { project.new_issuable_address(user, 'merge_request') }
+ it "changes projects new merge request address" do
+ expect { subject }.to change { project.new_issuable_address(user, "merge_request") }
end
end
@@ -540,68 +540,68 @@ describe ProjectsController do
sign_in(user)
expect(user.starred?(public_project)).to be_falsey
post(:toggle_star,
- params: {
- namespace_id: public_project.namespace,
- id: public_project
- })
+ params: {
+ namespace_id: public_project.namespace,
+ id: public_project,
+ })
expect(user.starred?(public_project)).to be_truthy
post(:toggle_star,
- params: {
- namespace_id: public_project.namespace,
- id: public_project
- })
+ params: {
+ namespace_id: public_project.namespace,
+ id: public_project,
+ })
expect(user.starred?(public_project)).to be_falsey
end
it "does nothing if user is not signed in" do
post(:toggle_star,
- params: {
- namespace_id: project.namespace,
- id: public_project
- })
+ params: {
+ namespace_id: project.namespace,
+ id: public_project,
+ })
expect(user.starred?(public_project)).to be_falsey
post(:toggle_star,
- params: {
- namespace_id: project.namespace,
- id: public_project
- })
+ params: {
+ namespace_id: project.namespace,
+ id: public_project,
+ })
expect(user.starred?(public_project)).to be_falsey
end
end
describe "DELETE remove_fork" do
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- context 'with forked project' do
+ context "with forked project" do
let(:forked_project) { fork_project(create(:project, :public), user) }
- it 'removes fork from project' do
+ it "removes fork from project" do
delete(:remove_fork,
- params: {
- namespace_id: forked_project.namespace.to_param,
- id: forked_project.to_param
- },
- format: :js)
+ params: {
+ namespace_id: forked_project.namespace.to_param,
+ id: forked_project.to_param,
+ },
+ format: :js)
expect(forked_project.reload.forked?).to be_falsey
- expect(flash[:notice]).to eq('The fork relationship has been removed.')
+ expect(flash[:notice]).to eq("The fork relationship has been removed.")
expect(response).to render_template(:remove_fork)
end
end
- context 'when project not forked' do
+ context "when project not forked" do
let(:unforked_project) { create(:project, namespace: user.namespace) }
- it 'does nothing if project was not forked' do
+ it "does nothing if project was not forked" do
delete(:remove_fork,
- params: {
- namespace_id: unforked_project.namespace,
- id: unforked_project
- },
- format: :js)
+ params: {
+ namespace_id: unforked_project.namespace,
+ id: unforked_project,
+ },
+ format: :js)
expect(flash[:notice]).to be_nil
expect(response).to render_template(:remove_fork)
@@ -611,11 +611,11 @@ describe ProjectsController do
it "does nothing if user is not signed in" do
delete(:remove_fork,
- params: {
- namespace_id: project.namespace,
- id: project
- },
- format: :js)
+ params: {
+ namespace_id: project.namespace,
+ id: project,
+ },
+ format: :js)
expect(response).to have_gitlab_http_status(401)
end
end
@@ -623,18 +623,18 @@ describe ProjectsController do
describe "GET refs" do
let(:project) { create(:project, :public, :repository) }
- it 'gets a list of branches and tags' do
- get :refs, params: { namespace_id: project.namespace, id: project, sort: 'updated_desc' }
+ it "gets a list of branches and tags" do
+ get :refs, params: {namespace_id: project.namespace, id: project, sort: "updated_desc"}
parsed_body = JSON.parse(response.body)
- expect(parsed_body['Branches']).to include('master')
- expect(parsed_body['Tags'].first).to eq('v1.1.0')
- expect(parsed_body['Tags'].last).to eq('v1.0.0')
- expect(parsed_body['Commits']).to be_nil
+ expect(parsed_body["Branches"]).to include("master")
+ expect(parsed_body["Tags"].first).to eq("v1.1.0")
+ expect(parsed_body["Tags"].last).to eq("v1.0.0")
+ expect(parsed_body["Commits"]).to be_nil
end
it "gets a list of branches, tags and commits" do
- get :refs, params: { namespace_id: project.namespace, id: project, ref: "123456" }
+ get :refs, params: {namespace_id: project.namespace, id: project, ref: "123456"}
parsed_body = JSON.parse(response.body)
expect(parsed_body["Branches"]).to include("master")
@@ -644,12 +644,12 @@ describe ProjectsController do
context "when preferred language is Japanese" do
before do
- user.update!(preferred_language: 'ja')
+ user.update!(preferred_language: "ja")
sign_in(user)
end
it "gets a list of branches, tags and commits" do
- get :refs, params: { namespace_id: project.namespace, id: project, ref: "123456" }
+ get :refs, params: {namespace_id: project.namespace, id: project, ref: "123456"}
parsed_body = JSON.parse(response.body)
expect(parsed_body["Branches"]).to include("master")
@@ -658,16 +658,16 @@ describe ProjectsController do
end
end
- context 'when private project' do
+ context "when private project" do
let(:project) { create(:project, :repository) }
- context 'as a guest' do
- it 'renders forbidden' do
+ context "as a guest" do
+ it "renders forbidden" do
user = create(:user)
project.add_guest(user)
sign_in(user)
- get :refs, params: { namespace_id: project.namespace, id: project }
+ get :refs, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(404)
end
@@ -675,57 +675,57 @@ describe ProjectsController do
end
end
- describe 'POST #preview_markdown' do
+ describe "POST #preview_markdown" do
before do
sign_in(user)
end
- it 'renders json in a correct format' do
- post :preview_markdown, params: { namespace_id: public_project.namespace, id: public_project, text: '*Markdown* text' }
+ it "renders json in a correct format" do
+ post :preview_markdown, params: {namespace_id: public_project.namespace, id: public_project, text: "*Markdown* text"}
- expect(JSON.parse(response.body).keys).to match_array(%w(body references))
+ expect(JSON.parse(response.body).keys).to match_array(%w[body references])
end
- context 'state filter on references' do
+ context "state filter on references" do
let(:issue) { create(:issue, :closed, project: public_project) }
let(:merge_request) { create(:merge_request, :closed, target_project: public_project) }
- it 'renders JSON body with state filter for issues' do
+ it "renders JSON body with state filter for issues" do
post :preview_markdown, params: {
- namespace_id: public_project.namespace,
- id: public_project,
- text: issue.to_reference
- }
+ namespace_id: public_project.namespace,
+ id: public_project,
+ text: issue.to_reference,
+ }
json_response = JSON.parse(response.body)
- expect(json_response['body']).to match(/\##{issue.iid} \(closed\)/)
+ expect(json_response["body"]).to match(/\##{issue.iid} \(closed\)/)
end
- it 'renders JSON body with state filter for MRs' do
+ it "renders JSON body with state filter for MRs" do
post :preview_markdown, params: {
- namespace_id: public_project.namespace,
- id: public_project,
- text: merge_request.to_reference
- }
+ namespace_id: public_project.namespace,
+ id: public_project,
+ text: merge_request.to_reference,
+ }
json_response = JSON.parse(response.body)
- expect(json_response['body']).to match(/\!#{merge_request.iid} \(closed\)/)
+ expect(json_response["body"]).to match(/\!#{merge_request.iid} \(closed\)/)
end
end
end
- describe '#ensure_canonical_path' do
+ describe "#ensure_canonical_path" do
before do
sign_in(user)
end
- context 'for a GET request' do
- context 'when requesting the canonical path' do
+ context "for a GET request" do
+ context "when requesting the canonical path" do
context "with exactly matching casing" do
it "loads the project" do
- get :show, params: { namespace_id: public_project.namespace, id: public_project }
+ get :show, params: {namespace_id: public_project.namespace, id: public_project}
expect(assigns(:project)).to eq(public_project)
expect(response).to have_gitlab_http_status(200)
@@ -734,7 +734,7 @@ describe ProjectsController do
context "with different casing" do
it "redirects to the normalized path" do
- get :show, params: { namespace_id: public_project.namespace, id: public_project.path.upcase }
+ get :show, params: {namespace_id: public_project.namespace, id: public_project.path.upcase}
expect(assigns(:project)).to eq(public_project)
expect(response).to redirect_to("/#{public_project.full_path}")
@@ -743,18 +743,18 @@ describe ProjectsController do
end
end
- context 'when requesting a redirected path' do
+ context "when requesting a redirected path" do
let!(:redirect_route) { public_project.redirect_routes.create!(path: "foo/bar") }
- it 'redirects to the canonical path' do
- get :show, params: { namespace_id: 'foo', id: 'bar' }
+ it "redirects to the canonical path" do
+ get :show, params: {namespace_id: "foo", id: "bar"}
expect(response).to redirect_to(public_project)
expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, public_project))
end
- it 'redirects to the canonical path (testing non-show action)' do
- get :refs, params: { namespace_id: 'foo', id: 'bar' }
+ it "redirects to the canonical path (testing non-show action)" do
+ get :refs, params: {namespace_id: "foo", id: "bar"}
expect(response).to redirect_to(refs_project_path(public_project))
expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, public_project))
@@ -762,56 +762,56 @@ describe ProjectsController do
end
end
- context 'for a POST request' do
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
- post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase }
+ context "for a POST request" do
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
+ post :toggle_star, params: {namespace_id: public_project.namespace, id: public_project.path.upcase}
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
- post :toggle_star, params: { namespace_id: public_project.namespace, id: public_project.path.upcase }
+ it "does not redirect to the correct casing" do
+ post :toggle_star, params: {namespace_id: public_project.namespace, id: public_project.path.upcase}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
+ context "when requesting a redirected path" do
let!(:redirect_route) { public_project.redirect_routes.create!(path: "foo/bar") }
- it 'returns not found' do
- post :toggle_star, params: { namespace_id: 'foo', id: 'bar' }
+ it "returns not found" do
+ post :toggle_star, params: {namespace_id: "foo", id: "bar"}
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'for a DELETE request' do
+ context "for a DELETE request" do
before do
sign_in(create(:admin))
end
- context 'when requesting the canonical path with different casing' do
- it 'does not 404' do
- delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase }
+ context "when requesting the canonical path with different casing" do
+ it "does not 404" do
+ delete :destroy, params: {namespace_id: project.namespace, id: project.path.upcase}
expect(response).not_to have_gitlab_http_status(404)
end
- it 'does not redirect to the correct casing' do
- delete :destroy, params: { namespace_id: project.namespace, id: project.path.upcase }
+ it "does not redirect to the correct casing" do
+ delete :destroy, params: {namespace_id: project.namespace, id: project.path.upcase}
expect(response).not_to have_gitlab_http_status(301)
end
end
- context 'when requesting a redirected path' do
+ context "when requesting a redirected path" do
let!(:redirect_route) { project.redirect_routes.create!(path: "foo/bar") }
- it 'returns not found' do
- delete :destroy, params: { namespace_id: 'foo', id: 'bar' }
+ it "returns not found" do
+ delete :destroy, params: {namespace_id: "foo", id: "bar"}
expect(response).to have_gitlab_http_status(404)
end
@@ -819,57 +819,57 @@ describe ProjectsController do
end
end
- describe '#export' do
+ describe "#export" do
before do
sign_in(user)
project.add_maintainer(user)
end
- context 'when project export is enabled' do
- it 'returns 302' do
- get :export, params: { namespace_id: project.namespace, id: project }
+ context "when project export is enabled" do
+ it "returns 302" do
+ get :export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when project export is disabled' do
+ context "when project export is disabled" do
before do
stub_application_setting(project_export_enabled?: false)
end
- it 'returns 404' do
- get :export, params: { namespace_id: project.namespace, id: project }
+ it "returns 404" do
+ get :export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe '#download_export' do
+ describe "#download_export" do
before do
sign_in(user)
project.add_maintainer(user)
end
- context 'object storage enabled' do
- context 'when project export is enabled' do
- it 'returns 302' do
- get :download_export, params: { namespace_id: project.namespace, id: project }
+ context "object storage enabled" do
+ context "when project export is enabled" do
+ it "returns 302" do
+ get :download_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when project export is disabled' do
+ context "when project export is disabled" do
before do
stub_application_setting(project_export_enabled?: false)
end
- it 'returns 404' do
- get :download_export, params: { namespace_id: project.namespace, id: project }
+ it "returns 404" do
+ get :download_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(404)
end
@@ -877,66 +877,66 @@ describe ProjectsController do
end
end
- describe '#remove_export' do
+ describe "#remove_export" do
before do
sign_in(user)
project.add_maintainer(user)
end
- context 'when project export is enabled' do
- it 'returns 302' do
- post :remove_export, params: { namespace_id: project.namespace, id: project }
+ context "when project export is enabled" do
+ it "returns 302" do
+ post :remove_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when project export is disabled' do
+ context "when project export is disabled" do
before do
stub_application_setting(project_export_enabled?: false)
end
- it 'returns 404' do
- post :remove_export, params: { namespace_id: project.namespace, id: project }
+ it "returns 404" do
+ post :remove_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe '#generate_new_export' do
+ describe "#generate_new_export" do
before do
sign_in(user)
project.add_maintainer(user)
end
- context 'when project export is enabled' do
- it 'returns 302' do
- post :generate_new_export, params: { namespace_id: project.namespace, id: project }
+ context "when project export is enabled" do
+ it "returns 302" do
+ post :generate_new_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(302)
end
end
- context 'when project export is disabled' do
+ context "when project export is disabled" do
before do
stub_application_setting(project_export_enabled?: false)
end
- it 'returns 404' do
- post :generate_new_export, params: { namespace_id: project.namespace, id: project }
+ it "returns 404" do
+ post :generate_new_export, params: {namespace_id: project.namespace, id: project}
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'private project with token authentication' do
+ context "private project with token authentication" do
let(:private_project) { create(:project, :private) }
- it_behaves_like 'authenticates sessionless user', :show, :atom do
+ it_behaves_like "authenticates sessionless user", :show, :atom do
before do
default_params.merge!(id: private_project, namespace_id: private_project.namespace)
@@ -945,63 +945,63 @@ describe ProjectsController do
end
end
- context 'public project with token authentication' do
+ context "public project with token authentication" do
let(:public_project) { create(:project, :public) }
- it_behaves_like 'authenticates sessionless user', :show, :atom, public: true do
+ it_behaves_like "authenticates sessionless user", :show, :atom, public: true do
before do
default_params.merge!(id: public_project, namespace_id: public_project.namespace)
end
end
end
- describe 'GET resolve' do
- shared_examples 'resolvable endpoint' do
- it 'redirects to the project page' do
- get :resolve, params: { id: project.id }
+ describe "GET resolve" do
+ shared_examples "resolvable endpoint" do
+ it "redirects to the project page" do
+ get :resolve, params: {id: project.id}
expect(response).to have_gitlab_http_status(302)
expect(response).to redirect_to(project_path(project))
end
end
- context 'with an authenticated user' do
+ context "with an authenticated user" do
before do
sign_in(user)
end
- context 'when user has access to the project' do
+ context "when user has access to the project" do
before do
project.add_developer(user)
end
- it_behaves_like 'resolvable endpoint'
+ it_behaves_like "resolvable endpoint"
end
- context 'when user has no access to the project' do
- it 'gives 404 for existing project' do
- get :resolve, params: { id: project.id }
+ context "when user has no access to the project" do
+ it "gives 404 for existing project" do
+ get :resolve, params: {id: project.id}
expect(response).to have_gitlab_http_status(404)
end
end
- it 'gives 404 for non-existing project' do
- get :resolve, params: { id: '0' }
+ it "gives 404 for non-existing project" do
+ get :resolve, params: {id: "0"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'non authenticated user' do
- context 'with a public project' do
+ context "non authenticated user" do
+ context "with a public project" do
let(:project) { public_project }
- it_behaves_like 'resolvable endpoint'
+ it_behaves_like "resolvable endpoint"
end
- it 'gives 404 for private project' do
- get :resolve, params: { id: project.id }
+ it "gives 404 for private project" do
+ get :resolve, params: {id: project.id}
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb
index fd151e8a298..6d008de40db 100644
--- a/spec/controllers/registrations_controller_spec.rb
+++ b/spec/controllers/registrations_controller_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe RegistrationsController do
include TermsHelper
- describe '#create' do
- let(:user_params) { { user: { name: 'new_user', username: 'new_username', email: 'new@user.com', password: 'Any_password' } } }
+ describe "#create" do
+ let(:user_params) { {user: {name: "new_user", username: "new_username", email: "new@user.com", password: "Any_password"}} }
- context 'email confirmation' do
+ context "email confirmation" do
around do |example|
perform_enqueued_jobs do
example.run
end
end
- context 'when send_user_confirmation_email is false' do
- it 'signs the user in' do
+ context "when send_user_confirmation_email is false" do
+ it "signs the user in" do
allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(false)
expect { post(:create, params: user_params) }.not_to change { ActionMailer::Base.deliveries.size }
@@ -22,8 +22,8 @@ describe RegistrationsController do
end
end
- context 'when send_user_confirmation_email is true' do
- it 'does not authenticate user and sends confirmation email' do
+ context "when send_user_confirmation_email is true" do
+ it "does not authenticate user and sends confirmation email" do
allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(true)
post(:create, params: user_params)
@@ -33,8 +33,8 @@ describe RegistrationsController do
end
end
- context 'when signup_enabled? is false' do
- it 'redirects to sign_in' do
+ context "when signup_enabled? is false" do
+ it "redirects to sign_in" do
allow_any_instance_of(ApplicationSetting).to receive(:signup_enabled?).and_return(false)
expect { post(:create, params: user_params) }.not_to change(User, :count)
@@ -43,46 +43,46 @@ describe RegistrationsController do
end
end
- context 'when reCAPTCHA is enabled' do
+ context "when reCAPTCHA is enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'displays an error when the reCAPTCHA is not solved' do
+ it "displays an error when the reCAPTCHA is not solved" do
# Without this, `verify_recaptcha` arbitrarily returns true in test env
- Recaptcha.configuration.skip_verify_env.delete('test')
+ Recaptcha.configuration.skip_verify_env.delete("test")
post(:create, params: user_params)
expect(response).to render_template(:new)
- expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ expect(flash[:alert]).to include "There was an error with the reCAPTCHA. Please solve the reCAPTCHA again."
end
- it 'redirects to the dashboard when the recaptcha is solved' do
+ it "redirects to the dashboard when the recaptcha is solved" do
# Avoid test ordering issue and ensure `verify_recaptcha` returns true
- unless Recaptcha.configuration.skip_verify_env.include?('test')
- Recaptcha.configuration.skip_verify_env << 'test'
+ unless Recaptcha.configuration.skip_verify_env.include?("test")
+ Recaptcha.configuration.skip_verify_env << "test"
end
post(:create, params: user_params)
- expect(flash[:notice]).to include 'Welcome! You have signed up successfully.'
+ expect(flash[:notice]).to include "Welcome! You have signed up successfully."
end
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- it 'redirects back with a notice when the checkbox was not checked' do
+ it "redirects back with a notice when the checkbox was not checked" do
post :create, params: user_params
expect(flash[:alert]).to match /you must accept our terms/i
end
- it 'creates the user with agreement when terms are accepted' do
- post :create, params: user_params.merge(terms_opt_in: '1')
+ it "creates the user with agreement when terms are accepted" do
+ post :create, params: user_params.merge(terms_opt_in: "1")
expect(subject.current_user).to be_present
expect(subject.current_user.terms_accepted?).to be(true)
@@ -90,7 +90,7 @@ describe RegistrationsController do
end
end
- describe '#destroy' do
+ describe "#destroy" do
let(:user) { create(:user) }
before do
@@ -104,59 +104,59 @@ describe RegistrationsController do
end
def expect_password_failure
- expect_failure('Invalid password')
+ expect_failure("Invalid password")
end
def expect_username_failure
- expect_failure('Invalid username')
+ expect_failure("Invalid username")
end
def expect_success
- expect(flash[:notice]).to eq 'Account scheduled for removal.'
+ expect(flash[:notice]).to eq "Account scheduled for removal."
expect(response.status).to eq(303)
expect(response).to redirect_to new_user_session_path
end
- context 'user requires password confirmation' do
- it 'fails if password confirmation is not provided' do
+ context "user requires password confirmation" do
+ it "fails if password confirmation is not provided" do
post :destroy
expect_password_failure
end
- it 'fails if password confirmation is wrong' do
- post :destroy, params: { password: 'wrong password' }
+ it "fails if password confirmation is wrong" do
+ post :destroy, params: {password: "wrong password"}
expect_password_failure
end
- it 'succeeds if password is confirmed' do
- post :destroy, params: { password: '12345678' }
+ it "succeeds if password is confirmed" do
+ post :destroy, params: {password: "12345678"}
expect_success
end
end
- context 'user does not require password confirmation' do
+ context "user does not require password confirmation" do
before do
stub_application_setting(password_authentication_enabled_for_web: false)
stub_application_setting(password_authentication_enabled_for_git: false)
end
- it 'fails if username confirmation is not provided' do
+ it "fails if username confirmation is not provided" do
post :destroy
expect_username_failure
end
- it 'fails if username confirmation is wrong' do
- post :destroy, params: { username: 'wrong username' }
+ it "fails if username confirmation is wrong" do
+ post :destroy, params: {username: "wrong username"}
expect_username_failure
end
- it 'succeeds if username is confirmed' do
- post :destroy, params: { username: user.username }
+ it "succeeds if username is confirmed" do
+ post :destroy, params: {username: user.username}
expect_success
end
diff --git a/spec/controllers/root_controller_spec.rb b/spec/controllers/root_controller_spec.rb
index 995f803d757..d89fd1f409e 100644
--- a/spec/controllers/root_controller_spec.rb
+++ b/spec/controllers/root_controller_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe RootController do
- describe 'GET index' do
- context 'when user is not logged in' do
- it 'redirects to the sign-in page' do
+ describe "GET index" do
+ context "when user is not logged in" do
+ it "redirects to the sign-in page" do
get :index
expect(response).to redirect_to(new_user_session_path)
end
- context 'when a custom home page URL is defined' do
+ context "when a custom home page URL is defined" do
before do
- stub_application_setting(home_page_url: 'https://gitlab.com')
+ stub_application_setting(home_page_url: "https://gitlab.com")
end
- it 'redirects the user to the custom home page URL' do
+ it "redirects the user to the custom home page URL" do
get :index
- expect(response).to redirect_to('https://gitlab.com')
+ expect(response).to redirect_to("https://gitlab.com")
end
end
end
- context 'with a user' do
+ context "with a user" do
let(:user) { create(:user) }
before do
@@ -30,95 +30,95 @@ describe RootController do
allow(subject).to receive(:current_user).and_return(user)
end
- context 'who has customized their dashboard setting for starred projects' do
+ context "who has customized their dashboard setting for starred projects" do
before do
- user.dashboard = 'stars'
+ user.dashboard = "stars"
end
- it 'redirects to their specified dashboard' do
+ it "redirects to their specified dashboard" do
get :index
expect(response).to redirect_to starred_dashboard_projects_path
end
end
- context 'who has customized their dashboard setting for project activities' do
+ context "who has customized their dashboard setting for project activities" do
before do
- user.dashboard = 'project_activity'
+ user.dashboard = "project_activity"
end
- it 'redirects to the activity list' do
+ it "redirects to the activity list" do
get :index
expect(response).to redirect_to activity_dashboard_path
end
end
- context 'who has customized their dashboard setting for starred project activities' do
+ context "who has customized their dashboard setting for starred project activities" do
before do
- user.dashboard = 'starred_project_activity'
+ user.dashboard = "starred_project_activity"
end
- it 'redirects to the activity list' do
+ it "redirects to the activity list" do
get :index
- expect(response).to redirect_to activity_dashboard_path(filter: 'starred')
+ expect(response).to redirect_to activity_dashboard_path(filter: "starred")
end
end
- context 'who has customized their dashboard setting for groups' do
+ context "who has customized their dashboard setting for groups" do
before do
- user.dashboard = 'groups'
+ user.dashboard = "groups"
end
- it 'redirects to their group list' do
+ it "redirects to their group list" do
get :index
expect(response).to redirect_to dashboard_groups_path
end
end
- context 'who has customized their dashboard setting for todos' do
+ context "who has customized their dashboard setting for todos" do
before do
- user.dashboard = 'todos'
+ user.dashboard = "todos"
end
- it 'redirects to their todo list' do
+ it "redirects to their todo list" do
get :index
expect(response).to redirect_to dashboard_todos_path
end
end
- context 'who has customized their dashboard setting for assigned issues' do
+ context "who has customized their dashboard setting for assigned issues" do
before do
- user.dashboard = 'issues'
+ user.dashboard = "issues"
end
- it 'redirects to their assigned issues' do
+ it "redirects to their assigned issues" do
get :index
expect(response).to redirect_to issues_dashboard_path(assignee_username: user.username)
end
end
- context 'who has customized their dashboard setting for assigned merge requests' do
+ context "who has customized their dashboard setting for assigned merge requests" do
before do
- user.dashboard = 'merge_requests'
+ user.dashboard = "merge_requests"
end
- it 'redirects to their assigned merge requests' do
+ it "redirects to their assigned merge requests" do
get :index
expect(response).to redirect_to merge_requests_dashboard_path(assignee_username: user.username)
end
end
- context 'who uses the default dashboard setting' do
- it 'renders the default dashboard' do
+ context "who uses the default dashboard setting" do
+ it "renders the default dashboard" do
get :index
- expect(response).to render_template 'dashboard/projects/index'
+ expect(response).to render_template "dashboard/projects/index"
end
end
end
diff --git a/spec/controllers/search_controller_spec.rb b/spec/controllers/search_controller_spec.rb
index 02a0cfe0272..50504566502 100644
--- a/spec/controllers/search_controller_spec.rb
+++ b/spec/controllers/search_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SearchController do
let(:user) { create(:user) }
@@ -7,43 +7,43 @@ describe SearchController do
sign_in(user)
end
- it 'finds issue comments' do
+ it "finds issue comments" do
project = create(:project, :public)
note = create(:note_on_issue, project: project)
- get :show, params: { project_id: project.id, scope: 'notes', search: note.note }
+ get :show, params: {project_id: project.id, scope: "notes", search: note.note}
expect(assigns[:search_objects].first).to eq note
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?)
- .with(user, :read_cross_project, :global) { false }
+ .with(user, :read_cross_project, :global) { false }
end
- it 'still allows accessing the search page' do
+ it "still allows accessing the search page" do
get :show
expect(response).to have_gitlab_http_status(200)
end
- it 'still blocks searches without a project_id' do
- get :show, params: { search: 'hello' }
+ it "still blocks searches without a project_id" do
+ get :show, params: {search: "hello"}
expect(response).to have_gitlab_http_status(403)
end
- it 'allows searches with a project_id' do
- get :show, params: { search: 'hello', project_id: create(:project, :public).id }
+ it "allows searches with a project_id" do
+ get :show, params: {search: "hello", project_id: create(:project, :public).id}
expect(response).to have_gitlab_http_status(200)
end
end
- context 'on restricted projects' do
- context 'when signed out' do
+ context "on restricted projects" do
+ context "when signed out" do
before do
sign_out(user)
end
@@ -52,7 +52,7 @@ describe SearchController do
project = create(:project, :public, :issues_private)
note = create(:note_on_issue, project: project)
- get :show, params: { project_id: project.id, scope: 'notes', search: note.note }
+ get :show, params: {project_id: project.id, scope: "notes", search: note.note}
expect(assigns[:search_objects].count).to eq(0)
end
@@ -62,7 +62,7 @@ describe SearchController do
project = create(:project, :public, :merge_requests_private)
note = create(:note_on_merge_request, project: project)
- get :show, params: { project_id: project.id, scope: 'notes', search: note.note }
+ get :show, params: {project_id: project.id, scope: "notes", search: note.note}
expect(assigns[:search_objects].count).to eq(0)
end
@@ -71,7 +71,7 @@ describe SearchController do
project = create(:project, :public, :snippets_private)
note = create(:note_on_project_snippet, project: project)
- get :show, params: { project_id: project.id, scope: 'notes', search: note.note }
+ get :show, params: {project_id: project.id, scope: "notes", search: note.note}
expect(assigns[:search_objects].count).to eq(0)
end
diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb
index 75c91dd8607..c5a485c5539 100644
--- a/spec/controllers/sent_notifications_controller_spec.rb
+++ b/spec/controllers/sent_notifications_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe SentNotificationsController do
let(:user) { create(:user) }
@@ -11,88 +11,88 @@ describe SentNotificationsController do
end
end
- describe 'GET unsubscribe' do
- context 'when the user is not logged in' do
- context 'when the force param is passed' do
+ describe "GET unsubscribe" do
+ context "when the user is not logged in" do
+ context "when the force param is passed" do
before do
- get(:unsubscribe, params: { id: sent_notification.reply_key, force: true })
+ get(:unsubscribe, params: {id: sent_notification.reply_key, force: true})
end
- it 'unsubscribes the user' do
+ it "unsubscribes the user" do
expect(issue.subscribed?(user, project)).to be_falsey
end
- it 'sets the flash message' do
+ it "sets the flash message" do
expect(controller).to set_flash[:notice].to(/unsubscribed/)
end
- it 'redirects to the login page' do
+ it "redirects to the login page" do
expect(response).to redirect_to(new_user_session_path)
end
end
- context 'when the force param is not passed' do
+ context "when the force param is not passed" do
before do
- get(:unsubscribe, params: { id: sent_notification.reply_key })
+ get(:unsubscribe, params: {id: sent_notification.reply_key})
end
- it 'does not unsubscribe the user' do
+ it "does not unsubscribe the user" do
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'does not set the flash message' do
+ it "does not set the flash message" do
expect(controller).not_to set_flash[:notice]
end
- it 'redirects to the login page' do
+ it "redirects to the login page" do
expect(response).to render_template :unsubscribe
end
end
end
- context 'when the user is logged in' do
+ context "when the user is logged in" do
before do
sign_in(user)
end
- context 'when the ID passed does not exist' do
+ context "when the ID passed does not exist" do
before do
- get(:unsubscribe, params: { id: sent_notification.reply_key.reverse })
+ get(:unsubscribe, params: {id: sent_notification.reply_key.reverse})
end
- it 'does not unsubscribe the user' do
+ it "does not unsubscribe the user" do
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'does not set the flash message' do
+ it "does not set the flash message" do
expect(controller).not_to set_flash[:notice]
end
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'when the force param is passed' do
+ context "when the force param is passed" do
before do
- get(:unsubscribe, params: { id: sent_notification.reply_key, force: true })
+ get(:unsubscribe, params: {id: sent_notification.reply_key, force: true})
end
- it 'unsubscribes the user' do
+ it "unsubscribes the user" do
expect(issue.subscribed?(user, project)).to be_falsey
end
- it 'sets the flash message' do
+ it "sets the flash message" do
expect(controller).to set_flash[:notice].to(/unsubscribed/)
end
- it 'redirects to the issue page' do
+ it "redirects to the issue page" do
expect(response)
.to redirect_to(project_issue_path(project, issue))
end
end
- context 'when the force param is not passed' do
+ context "when the force param is not passed" do
let(:merge_request) do
create(:merge_request, source_project: project, author: user) do |merge_request|
merge_request.subscriptions.create(user: user, project: project, subscribed: true)
@@ -101,18 +101,18 @@ describe SentNotificationsController do
let(:sent_notification) { create(:sent_notification, project: project, noteable: merge_request, recipient: user) }
before do
- get(:unsubscribe, params: { id: sent_notification.reply_key })
+ get(:unsubscribe, params: {id: sent_notification.reply_key})
end
- it 'unsubscribes the user' do
+ it "unsubscribes the user" do
expect(merge_request.subscribed?(user, project)).to be_falsey
end
- it 'sets the flash message' do
+ it "sets the flash message" do
expect(controller).to set_flash[:notice].to(/unsubscribed/)
end
- it 'redirects to the merge request page' do
+ it "redirects to the merge request page" do
expect(response)
.to redirect_to(project_merge_request_path(project, merge_request))
end
diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb
index ea7242c1aa8..25cf9058a3e 100644
--- a/spec/controllers/sessions_controller_spec.rb
+++ b/spec/controllers/sessions_controller_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe SessionsController do
include DeviseHelpers
- describe '#new' do
+ describe "#new" do
before do
set_devise_mapping(context: @request)
end
- context 'when auto sign-in is enabled' do
+ context "when auto sign-in is enabled" do
before do
stub_omniauth_setting(auto_sign_in_with_provider: :saml)
allow(controller).to receive(:omniauth_authorize_path).with(:user, :saml)
- .and_return('/saml')
+ .and_return("/saml")
end
- context 'and no auto_sign_in param is passed' do
- it 'redirects to :omniauth_authorize_path' do
+ context "and no auto_sign_in param is passed" do
+ it "redirects to :omniauth_authorize_path" do
get(:new)
expect(response).to have_gitlab_http_status(302)
- expect(response).to redirect_to('/saml')
+ expect(response).to redirect_to("/saml")
end
end
- context 'and auto_sign_in=false param is passed' do
- it 'responds with 200' do
- get(:new, params: { auto_sign_in: 'false' })
+ context "and auto_sign_in=false param is passed" do
+ it "responds with 200" do
+ get(:new, params: {auto_sign_in: "false"})
expect(response).to have_gitlab_http_status(200)
end
@@ -34,132 +34,132 @@ describe SessionsController do
end
end
- describe '#create' do
+ describe "#create" do
before do
set_devise_mapping(context: @request)
end
- context 'when using standard authentications' do
- context 'invalid password' do
- it 'does not authenticate user' do
- post(:create, params: { user: { login: 'invalid', password: 'invalid' } })
+ context "when using standard authentications" do
+ context "invalid password" do
+ it "does not authenticate user" do
+ post(:create, params: {user: {login: "invalid", password: "invalid"}})
expect(response)
.to set_flash.now[:alert].to /Invalid Login or password/
end
end
- context 'when using valid password', :clean_gitlab_redis_shared_state do
+ context "when using valid password", :clean_gitlab_redis_shared_state do
let(:user) { create(:user) }
- let(:user_params) { { login: user.username, password: user.password } }
+ let(:user_params) { {login: user.username, password: user.password} }
- it 'authenticates user correctly' do
- post(:create, params: { user: user_params })
+ it "authenticates user correctly" do
+ post(:create, params: {user: user_params})
expect(subject.current_user). to eq user
end
- it 'creates an audit log record' do
- expect { post(:create, params: { user: user_params }) }.to change { SecurityEvent.count }.by(1)
- expect(SecurityEvent.last.details[:with]).to eq('standard')
+ it "creates an audit log record" do
+ expect { post(:create, params: {user: user_params}) }.to change { SecurityEvent.count }.by(1)
+ expect(SecurityEvent.last.details[:with]).to eq("standard")
end
- include_examples 'user login request with unique ip limit', 302 do
+ include_examples "user login request with unique ip limit", 302 do
def request
- post(:create, params: { user: user_params })
+ post(:create, params: {user: user_params})
expect(subject.current_user).to eq user
subject.sign_out user
end
end
- it 'updates the user activity' do
- expect do
- post(:create, params: { user: user_params })
- end.to change { user.reload.last_activity_on }.to(Date.today)
+ it "updates the user activity" do
+ expect {
+ post(:create, params: {user: user_params})
+ }.to change { user.reload.last_activity_on }.to(Date.today)
end
end
- context 'when reCAPTCHA is enabled' do
+ context "when reCAPTCHA is enabled" do
let(:user) { create(:user) }
- let(:user_params) { { login: user.username, password: user.password } }
+ let(:user_params) { {login: user.username, password: user.password} }
before do
stub_application_setting(recaptcha_enabled: true)
request.headers[described_class::CAPTCHA_HEADER] = 1
end
- it 'displays an error when the reCAPTCHA is not solved' do
+ it "displays an error when the reCAPTCHA is not solved" do
# Without this, `verify_recaptcha` arbitrarily returns true in test env
- Recaptcha.configuration.skip_verify_env.delete('test')
+ Recaptcha.configuration.skip_verify_env.delete("test")
counter = double(:counter)
expect(counter).to receive(:increment)
expect(Gitlab::Metrics).to receive(:counter)
- .with(:failed_login_captcha_total, anything)
- .and_return(counter)
+ .with(:failed_login_captcha_total, anything)
+ .and_return(counter)
- post(:create, params: { user: user_params })
+ post(:create, params: {user: user_params})
expect(response).to render_template(:new)
- expect(flash[:alert]).to include 'There was an error with the reCAPTCHA. Please solve the reCAPTCHA again.'
+ expect(flash[:alert]).to include "There was an error with the reCAPTCHA. Please solve the reCAPTCHA again."
expect(subject.current_user).to be_nil
end
- it 'successfully logs in a user when reCAPTCHA is solved' do
+ it "successfully logs in a user when reCAPTCHA is solved" do
# Avoid test ordering issue and ensure `verify_recaptcha` returns true
- Recaptcha.configuration.skip_verify_env << 'test'
+ Recaptcha.configuration.skip_verify_env << "test"
counter = double(:counter)
expect(counter).to receive(:increment)
expect(Gitlab::Metrics).to receive(:counter)
- .with(:successful_login_captcha_total, anything)
- .and_return(counter)
+ .with(:successful_login_captcha_total, anything)
+ .and_return(counter)
expect(Gitlab::Metrics).to receive(:counter).and_call_original
- post(:create, params: { user: user_params })
+ post(:create, params: {user: user_params})
expect(subject.current_user).to eq user
end
end
end
- context 'when using two-factor authentication via OTP' do
+ context "when using two-factor authentication via OTP" do
let(:user) { create(:user, :two_factor) }
def authenticate_2fa(user_params)
- post(:create, params: { user: user_params }, session: { otp_user_id: user.id })
+ post(:create, params: {user: user_params}, session: {otp_user_id: user.id})
end
- context 'remember_me field' do
- it 'sets a remember_user_token cookie when enabled' do
+ context "remember_me field" do
+ it "sets a remember_user_token cookie when enabled" do
allow(controller).to receive(:find_user).and_return(user)
expect(controller)
.to receive(:remember_me).with(user).and_call_original
- authenticate_2fa(remember_me: '1', otp_attempt: user.current_otp)
+ authenticate_2fa(remember_me: "1", otp_attempt: user.current_otp)
- expect(response.cookies['remember_user_token']).to be_present
+ expect(response.cookies["remember_user_token"]).to be_present
end
- it 'does nothing when disabled' do
+ it "does nothing when disabled" do
allow(controller).to receive(:find_user).and_return(user)
expect(controller).not_to receive(:remember_me)
- authenticate_2fa(remember_me: '0', otp_attempt: user.current_otp)
+ authenticate_2fa(remember_me: "0", otp_attempt: user.current_otp)
- expect(response.cookies['remember_user_token']).to be_nil
+ expect(response.cookies["remember_user_token"]).to be_nil
end
end
##
# See #14900 issue
#
- context 'when authenticating with login and OTP of another user' do
- context 'when another user has 2FA enabled' do
+ context "when authenticating with login and OTP of another user" do
+ context "when another user has 2FA enabled" do
let(:another_user) { create(:user, :two_factor) }
- context 'when OTP is valid for another user' do
- it 'does not authenticate' do
+ context "when OTP is valid for another user" do
+ it "does not authenticate" do
authenticate_2fa(login: another_user.username,
otp_attempt: another_user.current_otp)
@@ -167,73 +167,73 @@ describe SessionsController do
end
end
- context 'when OTP is invalid for another user' do
- it 'does not authenticate' do
+ context "when OTP is invalid for another user" do
+ it "does not authenticate" do
authenticate_2fa(login: another_user.username,
- otp_attempt: 'invalid')
+ otp_attempt: "invalid")
expect(subject.current_user).not_to eq another_user
end
end
- context 'when authenticating with OTP' do
- context 'when OTP is valid' do
- it 'authenticates correctly' do
+ context "when authenticating with OTP" do
+ context "when OTP is valid" do
+ it "authenticates correctly" do
authenticate_2fa(otp_attempt: user.current_otp)
expect(subject.current_user).to eq user
end
end
- context 'when OTP is invalid' do
+ context "when OTP is invalid" do
before do
- authenticate_2fa(otp_attempt: 'invalid')
+ authenticate_2fa(otp_attempt: "invalid")
end
- it 'does not authenticate' do
+ it "does not authenticate" do
expect(subject.current_user).not_to eq user
end
- it 'warns about invalid OTP code' do
+ it "warns about invalid OTP code" do
expect(response).to set_flash.now[:alert]
.to /Invalid two-factor code/
end
end
end
- context 'when the user is on their last attempt' do
+ context "when the user is on their last attempt" do
before do
user.update(failed_attempts: User.maximum_attempts.pred)
end
- context 'when OTP is valid' do
- it 'authenticates correctly' do
+ context "when OTP is valid" do
+ it "authenticates correctly" do
authenticate_2fa(otp_attempt: user.current_otp)
expect(subject.current_user).to eq user
end
end
- context 'when OTP is invalid' do
+ context "when OTP is invalid" do
before do
- authenticate_2fa(otp_attempt: 'invalid')
+ authenticate_2fa(otp_attempt: "invalid")
end
- it 'does not authenticate' do
+ it "does not authenticate" do
expect(subject.current_user).not_to eq user
end
- it 'warns about invalid login' do
+ it "warns about invalid login" do
expect(response).to set_flash.now[:alert]
.to /Invalid Login or password/
end
- it 'locks the user' do
+ it "locks the user" do
expect(user.reload).to be_access_locked
end
- it 'keeps the user locked on future login attempts' do
- post(:create, params: { user: { login: user.username, password: user.password } })
+ it "keeps the user locked on future login attempts" do
+ post(:create, params: {user: {login: user.username, password: user.password}})
expect(response)
.to set_flash.now[:alert].to /Invalid Login or password/
@@ -241,12 +241,12 @@ describe SessionsController do
end
end
- context 'when another user does not have 2FA enabled' do
+ context "when another user does not have 2FA enabled" do
let(:another_user) { create(:user) }
- it 'does not leak that 2FA is disabled for another user' do
+ it "does not leak that 2FA is disabled for another user" do
authenticate_2fa(login: another_user.username,
- otp_attempt: 'invalid')
+ otp_attempt: "invalid")
expect(response).to set_flash.now[:alert]
.to /Invalid two-factor code/
@@ -261,33 +261,33 @@ describe SessionsController do
end
end
- context 'when using two-factor authentication via U2F device' do
+ context "when using two-factor authentication via U2F device" do
let(:user) { create(:user, :two_factor) }
def authenticate_2fa_u2f(user_params)
- post(:create, params: { user: user_params }, session: { otp_user_id: user.id })
+ post(:create, params: {user: user_params}, session: {otp_user_id: user.id})
end
- context 'remember_me field' do
- it 'sets a remember_user_token cookie when enabled' do
+ context "remember_me field" do
+ it "sets a remember_user_token cookie when enabled" do
allow(U2fRegistration).to receive(:authenticate).and_return(true)
allow(controller).to receive(:find_user).and_return(user)
expect(controller)
.to receive(:remember_me).with(user).and_call_original
- authenticate_2fa_u2f(remember_me: '1', login: user.username, device_response: "{}")
+ authenticate_2fa_u2f(remember_me: "1", login: user.username, device_response: "{}")
- expect(response.cookies['remember_user_token']).to be_present
+ expect(response.cookies["remember_user_token"]).to be_present
end
- it 'does nothing when disabled' do
+ it "does nothing when disabled" do
allow(U2fRegistration).to receive(:authenticate).and_return(true)
allow(controller).to receive(:find_user).and_return(user)
expect(controller).not_to receive(:remember_me)
- authenticate_2fa_u2f(remember_me: '0', login: user.username, device_response: "{}")
+ authenticate_2fa_u2f(remember_me: "0", login: user.username, device_response: "{}")
- expect(response.cookies['remember_user_token']).to be_nil
+ expect(response.cookies["remember_user_token"]).to be_nil
end
end
@@ -309,7 +309,7 @@ describe SessionsController do
search_path = "/search?search=seed_project"
request.headers[:HTTP_REFERER] = "http://#{host}#{search_path}"
- get(:new, params: { redirect_to_referer: :yes })
+ get(:new, params: {redirect_to_referer: :yes})
expect(controller.stored_location_for(:redirect)).to eq(search_path)
end
diff --git a/spec/controllers/snippets/notes_controller_spec.rb b/spec/controllers/snippets/notes_controller_spec.rb
index 6efbd1f6c71..b184bc0439f 100644
--- a/spec/controllers/snippets/notes_controller_spec.rb
+++ b/spec/controllers/snippets/notes_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Snippets::NotesController do
let(:user) { create(:user) }
@@ -11,12 +11,12 @@ describe Snippets::NotesController do
let(:note_on_internal) { create(:note_on_personal_snippet, noteable: internal_snippet) }
let(:note_on_public) { create(:note_on_personal_snippet, noteable: public_snippet) }
- describe 'GET index' do
- context 'when a snippet is public' do
+ describe "GET index" do
+ context "when a snippet is public" do
before do
note_on_public
- get :index, params: { snippet_id: public_snippet }
+ get :index, params: {snippet_id: public_snippet}
end
it "returns status 200" do
@@ -28,58 +28,58 @@ describe Snippets::NotesController do
end
end
- context 'when a snippet is internal' do
+ context "when a snippet is internal" do
before do
note_on_internal
end
- context 'when user not logged in' do
+ context "when user not logged in" do
it "returns status 404" do
- get :index, params: { snippet_id: internal_snippet }
+ get :index, params: {snippet_id: internal_snippet}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user logged in' do
+ context "when user logged in" do
before do
sign_in(user)
end
it "returns status 200" do
- get :index, params: { snippet_id: internal_snippet }
+ get :index, params: {snippet_id: internal_snippet}
expect(response).to have_gitlab_http_status(200)
end
end
end
- context 'when a snippet is private' do
+ context "when a snippet is private" do
before do
note_on_private
end
- context 'when user not logged in' do
+ context "when user not logged in" do
it "returns status 404" do
- get :index, params: { snippet_id: private_snippet }
+ get :index, params: {snippet_id: private_snippet}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user other than author logged in' do
+ context "when user other than author logged in" do
before do
sign_in(user)
end
it "returns status 404" do
- get :index, params: { snippet_id: private_snippet }
+ get :index, params: {snippet_id: private_snippet}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when author logged in' do
+ context "when author logged in" do
before do
note_on_private
@@ -87,20 +87,20 @@ describe Snippets::NotesController do
end
it "returns status 200" do
- get :index, params: { snippet_id: private_snippet }
+ get :index, params: {snippet_id: private_snippet}
expect(response).to have_gitlab_http_status(200)
end
it "returns 1 note" do
- get :index, params: { snippet_id: private_snippet }
+ get :index, params: {snippet_id: private_snippet}
- expect(JSON.parse(response.body)['notes'].count).to eq(1)
+ expect(JSON.parse(response.body)["notes"].count).to eq(1)
end
end
end
- context 'dont show non visible notes' do
+ context "dont show non visible notes" do
before do
note_on_public
@@ -110,23 +110,23 @@ describe Snippets::NotesController do
end
it "does not return any note" do
- get :index, params: { snippet_id: public_snippet }
+ get :index, params: {snippet_id: public_snippet}
- expect(JSON.parse(response.body)['notes'].count).to eq(0)
+ expect(JSON.parse(response.body)["notes"].count).to eq(0)
end
end
end
- describe 'DELETE destroy' do
+ describe "DELETE destroy" do
let(:request_params) do
{
snippet_id: public_snippet,
id: note_on_public,
- format: :js
+ format: :js,
}
end
- context 'when user is the author of a note' do
+ context "when user is the author of a note" do
before do
sign_in(note_on_public.author)
end
@@ -141,7 +141,7 @@ describe Snippets::NotesController do
expect { delete :destroy, params: request_params }.to change { Note.count }.from(1).to(0)
end
- context 'system note' do
+ context "system note" do
before do
expect_any_instance_of(Note).to receive(:system?).and_return(true)
end
@@ -152,7 +152,7 @@ describe Snippets::NotesController do
end
end
- context 'when user is not the author of a note' do
+ context "when user is not the author of a note" do
before do
sign_in(user)
@@ -171,13 +171,13 @@ describe Snippets::NotesController do
end
end
- describe 'POST toggle_award_emoji' do
+ describe "POST toggle_award_emoji" do
let(:note) { create(:note_on_personal_snippet, noteable: public_snippet) }
before do
sign_in(user)
end
- subject { post(:toggle_award_emoji, params: { snippet_id: public_snippet, id: note.id, name: "thumbsup" }) }
+ subject { post(:toggle_award_emoji, params: {snippet_id: public_snippet, id: note.id, name: "thumbsup"}) }
it "toggles the award emoji" do
expect { subject }.to change { note.award_emoji.count }.by(1)
@@ -186,7 +186,7 @@ describe Snippets::NotesController do
end
it "removes the already awarded emoji when it exists" do
- note.toggle_award_emoji('thumbsup', user) # create award emoji before
+ note.toggle_award_emoji("thumbsup", user) # create award emoji before
expect { subject }.to change { AwardEmoji.count }.by(-1)
diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb
index 5c6858dc7b2..faea78aa2fa 100644
--- a/spec/controllers/snippets_controller_spec.rb
+++ b/spec/controllers/snippets_controller_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe SnippetsController do
let(:user) { create(:user) }
- describe 'GET #index' do
+ describe "GET #index" do
let(:user) { create(:user) }
- context 'when username parameter is present' do
- it 'renders snippets of a user when username is present' do
- get :index, params: { username: user.username }
+ context "when username parameter is present" do
+ it "renders snippets of a user when username is present" do
+ get :index, params: {username: user.username}
expect(response).to render_template(:index)
end
end
- context 'when username parameter is not present' do
- it 'redirects to explore snippets page when user is not logged in' do
+ context "when username parameter is not present" do
+ it "redirects to explore snippets page when user is not logged in" do
get :index
expect(response).to redirect_to(explore_snippets_path)
end
- it 'redirects to snippets dashboard page when user is logged in' do
+ it "redirects to snippets dashboard page when user is logged in" do
sign_in(user)
get :index
@@ -31,21 +31,21 @@ describe SnippetsController do
end
end
- describe 'GET #new' do
- context 'when signed in' do
+ describe "GET #new" do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 200' do
+ it "responds with status 200" do
get :new
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when not signed in' do
- it 'redirects to the sign in page' do
+ context "when not signed in" do
+ it "redirects to the sign in page" do
get :new
expect(response).to redirect_to(new_user_session_path)
@@ -53,108 +53,108 @@ describe SnippetsController do
end
end
- describe 'GET #show' do
- context 'when the personal snippet is private' do
+ describe "GET #show" do
+ context "when the personal snippet is private" do
let(:personal_snippet) { create(:personal_snippet, :private, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- context 'when signed in user is not the author' do
+ context "when signed in user is not the author" do
let(:other_author) { create(:author) }
let(:other_personal_snippet) { create(:personal_snippet, :private, author: other_author) }
- it 'responds with status 404' do
- get :show, params: { id: other_personal_snippet.to_param }
+ it "responds with status 404" do
+ get :show, params: {id: other_personal_snippet.to_param}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when signed in user is the author' do
- it 'renders the snippet' do
- get :show, params: { id: personal_snippet.to_param }
+ context "when signed in user is the author" do
+ it "renders the snippet" do
+ get :show, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with status 404 when embeddable content is requested' do
- get :show, params: { id: personal_snippet.to_param }, format: :js
+ it "responds with status 404 when embeddable content is requested" do
+ get :show, params: {id: personal_snippet.to_param}, format: :js
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when not signed in' do
- it 'redirects to the sign in page' do
- get :show, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :show, params: {id: personal_snippet.to_param}
expect(response).to redirect_to(new_user_session_path)
end
end
end
- context 'when the personal snippet is internal' do
+ context "when the personal snippet is internal" do
let(:personal_snippet) { create(:personal_snippet, :internal, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'renders the snippet' do
- get :show, params: { id: personal_snippet.to_param }
+ it "renders the snippet" do
+ get :show, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with status 404 when embeddable content is requested' do
- get :show, params: { id: personal_snippet.to_param }, format: :js
+ it "responds with status 404 when embeddable content is requested" do
+ get :show, params: {id: personal_snippet.to_param}, format: :js
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when not signed in' do
- it 'redirects to the sign in page' do
- get :show, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :show, params: {id: personal_snippet.to_param}
expect(response).to redirect_to(new_user_session_path)
end
end
end
- context 'when the personal snippet is public' do
+ context "when the personal snippet is public" do
let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'renders the snippet' do
- get :show, params: { id: personal_snippet.to_param }
+ it "renders the snippet" do
+ get :show, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with status 200 when embeddable content is requested' do
- get :show, params: { id: personal_snippet.to_param }, format: :js
+ it "responds with status 200 when embeddable content is requested" do
+ get :show, params: {id: personal_snippet.to_param}, format: :js
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when not signed in' do
- it 'renders the snippet' do
- get :show, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "renders the snippet" do
+ get :show, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
@@ -162,22 +162,22 @@ describe SnippetsController do
end
end
- context 'when the personal snippet does not exist' do
- context 'when signed in' do
+ context "when the personal snippet does not exist" do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 404' do
- get :show, params: { id: 'doesntexist' }
+ it "responds with status 404" do
+ get :show, params: {id: "doesntexist"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when not signed in' do
- it 'responds with status 404' do
- get :show, params: { id: 'doesntexist' }
+ context "when not signed in" do
+ it "responds with status 404" do
+ get :show, params: {id: "doesntexist"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -185,28 +185,28 @@ describe SnippetsController do
end
end
- describe 'POST #create' do
+ describe "POST #create" do
def create_snippet(snippet_params = {}, additional_params = {})
sign_in(user)
post :create, params: {
- personal_snippet: { title: 'Title', content: 'Content', description: 'Description' }.merge(snippet_params)
+ personal_snippet: {title: "Title", content: "Content", description: "Description"}.merge(snippet_params),
}.merge(additional_params)
Snippet.last
end
- it 'creates the snippet correctly' do
+ it "creates the snippet correctly" do
snippet = create_snippet(visibility_level: Snippet::PRIVATE)
- expect(snippet.title).to eq('Title')
- expect(snippet.content).to eq('Content')
- expect(snippet.description).to eq('Description')
+ expect(snippet.title).to eq("Title")
+ expect(snippet.content).to eq("Content")
+ expect(snippet.description).to eq("Description")
end
- context 'when the snippet description contains a file' do
- let(:picture_file) { '/-/system/temp/secret56/picture.jpg' }
- let(:text_file) { '/-/system/temp/secret78/text.txt' }
+ context "when the snippet description contains a file" do
+ let(:picture_file) { "/-/system/temp/secret56/picture.jpg" }
+ let(:text_file) { "/-/system/temp/secret78/text.txt" }
let(:description) do
"Description with picture: ![picture](/uploads#{picture_file}) and "\
"text: [text.txt](/uploads#{text_file})"
@@ -217,13 +217,13 @@ describe SnippetsController do
allow(FileUtils).to receive(:move)
end
- subject { create_snippet({ description: description }, { files: [picture_file, text_file] }) }
+ subject { create_snippet({description: description}, {files: [picture_file, text_file]}) }
- it 'creates the snippet' do
+ it "creates the snippet" do
expect { subject }.to change { Snippet.count }.by(1)
end
- it 'stores the snippet description correctly' do
+ it "stores the snippet description correctly" do
snippet = subject
expected_description = "Description with picture: "\
@@ -234,30 +234,30 @@ describe SnippetsController do
end
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
- it 'creates the snippet' do
+ context "when the snippet is private" do
+ it "creates the snippet" do
expect { create_snippet(visibility_level: Snippet::PRIVATE) }
.to change { Snippet.count }.by(1)
end
end
- context 'when the snippet is public' do
- it 'rejects the shippet' do
+ context "when the snippet is public" do
+ it "rejects the shippet" do
expect { create_snippet(visibility_level: Snippet::PUBLIC) }
.not_to change { Snippet.count }
end
- it 'creates a spam log' do
+ it "creates a spam log" do
expect { create_snippet(visibility_level: Snippet::PUBLIC) }
.to change { SpamLog.count }.by(1)
end
- it 'renders :new with recaptcha disabled' do
+ it "renders :new with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
create_snippet(visibility_level: Snippet::PUBLIC)
@@ -265,24 +265,24 @@ describe SnippetsController do
expect(response).to render_template(:new)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
+ it "renders :verify with recaptcha enabled" do
create_snippet(visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
- snippet = create_snippet({ title: spammy_title },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ snippet = create_snippet({title: spammy_title},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(snippet_path(snippet))
end
@@ -291,7 +291,7 @@ describe SnippetsController do
end
end
- describe 'PUT #update' do
+ describe "PUT #update" do
let(:project) { create :project }
let(:snippet) { create :personal_snippet, author: user, project: project, visibility_level: visibility_level }
@@ -300,110 +300,110 @@ describe SnippetsController do
put :update, params: {
id: snippet.id,
- personal_snippet: { title: 'Title', content: 'Content' }.merge(snippet_params)
+ personal_snippet: {title: "Title", content: "Content"}.merge(snippet_params),
}.merge(additional_params)
snippet.reload
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
+ context "when the snippet is private" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'updates the snippet' do
- expect { update_snippet(title: 'Foo') }
- .to change { snippet.reload.title }.to('Foo')
+ it "updates the snippet" do
+ expect { update_snippet(title: "Foo") }
+ .to change { snippet.reload.title }.to("Foo")
end
end
- context 'when a private snippet is made public' do
+ context "when a private snippet is made public" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'rejects the snippet' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ it "rejects the snippet" do
+ expect { update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC) }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC) }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC) }
.to change { SpamLog.count }.by(1)
end
- it 'renders :edit with recaptcha disabled' do
+ it "renders :edit with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
- update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
+ update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:edit)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
- update_snippet(title: 'Foo', visibility_level: Snippet::PUBLIC)
+ it "renders :verify with recaptcha enabled" do
+ update_snippet(title: "Foo", visibility_level: Snippet::PUBLIC)
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
- snippet = update_snippet({ title: spammy_title, visibility_level: Snippet::PUBLIC },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ snippet = update_snippet({title: spammy_title, visibility_level: Snippet::PUBLIC},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(snippet_path(snippet))
end
end
end
- context 'when the snippet is public' do
+ context "when the snippet is public" do
let(:visibility_level) { Snippet::PUBLIC }
- it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo') }
+ it "rejects the shippet" do
+ expect { update_snippet(title: "Foo") }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo") }
.to change { SpamLog.count }.by(1)
end
- it 'renders :edit with recaptcha disabled' do
+ it "renders :edit with recaptcha disabled" do
stub_application_setting(recaptcha_enabled: false)
- update_snippet(title: 'Foo')
+ update_snippet(title: "Foo")
expect(response).to render_template(:edit)
end
- context 'recaptcha enabled' do
+ context "recaptcha enabled" do
before do
stub_application_setting(recaptcha_enabled: true)
end
- it 'renders :verify with recaptcha enabled' do
- update_snippet(title: 'Foo')
+ it "renders :verify with recaptcha enabled" do
+ update_snippet(title: "Foo")
expect(response).to render_template(:verify)
end
- it 'renders snippet page when recaptcha verified' do
- spammy_title = 'Whatever'
+ it "renders snippet page when recaptcha verified" do
+ spammy_title = "Whatever"
spam_logs = create_list(:spam_log, 2, user: user, title: spammy_title)
- snippet = update_snippet({ title: spammy_title },
- { spam_log_id: spam_logs.last.id,
- recaptcha_verification: true })
+ snippet = update_snippet({title: spammy_title},
+ {spam_log_id: spam_logs.last.id,
+ recaptcha_verification: true,})
expect(response).to redirect_to(snippet_path(snippet))
end
@@ -412,7 +412,7 @@ describe SnippetsController do
end
end
- describe 'POST #mark_as_spam' do
+ describe "POST #mark_as_spam" do
let(:snippet) { create(:personal_snippet, :public, author: user) }
before do
@@ -425,10 +425,10 @@ describe SnippetsController do
create(:user_agent_detail, subject: snippet)
sign_in(admin)
- post :mark_as_spam, params: { id: snippet.id }
+ post :mark_as_spam, params: {id: snippet.id}
end
- it 'updates the snippet' do
+ it "updates the snippet" do
mark_as_spam
expect(snippet.reload).not_to be_submittable_as_spam
@@ -436,39 +436,39 @@ describe SnippetsController do
end
describe "GET #raw" do
- context 'when the personal snippet is private' do
+ context "when the personal snippet is private" do
let(:personal_snippet) { create(:personal_snippet, :private, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- context 'when signed in user is not the author' do
+ context "when signed in user is not the author" do
let(:other_author) { create(:author) }
let(:other_personal_snippet) { create(:personal_snippet, :private, author: other_author) }
- it 'responds with status 404' do
- get :raw, params: { id: other_personal_snippet.to_param }
+ it "responds with status 404" do
+ get :raw, params: {id: other_personal_snippet.to_param}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when signed in user is the author' do
+ context "when signed in user is the author" do
before do
- get :raw, params: { id: personal_snippet.to_param }
+ get :raw, params: {id: personal_snippet.to_param}
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
- it 'has expected headers' do
- expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
+ it "has expected headers" do
+ expect(response.header["Content-Type"]).to eq("text/plain; charset=utf-8")
- expect(response.header['Content-Disposition']).to match(/inline/)
+ expect(response.header["Content-Disposition"]).to match(/inline/)
end
it "sets #{Gitlab::Workhorse::DETECT_HEADER} header" do
@@ -478,77 +478,77 @@ describe SnippetsController do
end
end
- context 'when not signed in' do
- it 'redirects to the sign in page' do
- get :raw, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(response).to redirect_to(new_user_session_path)
end
end
end
- context 'when the personal snippet is internal' do
+ context "when the personal snippet is internal" do
let(:personal_snippet) { create(:personal_snippet, :internal, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 200' do
- get :raw, params: { id: personal_snippet.to_param }
+ it "responds with status 200" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when not signed in' do
- it 'redirects to the sign in page' do
- get :raw, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "redirects to the sign in page" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(response).to redirect_to(new_user_session_path)
end
end
end
- context 'when the personal snippet is public' do
+ context "when the personal snippet is public" do
let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 200' do
- get :raw, params: { id: personal_snippet.to_param }
+ it "responds with status 200" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
end
- context 'CRLF line ending' do
+ context "CRLF line ending" do
let(:personal_snippet) do
create(:personal_snippet, :public, author: user, content: "first line\r\nsecond line\r\nthird line")
end
- it 'returns LF line endings by default' do
- get :raw, params: { id: personal_snippet.to_param }
+ it "returns LF line endings by default" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(response.body).to eq("first line\nsecond line\nthird line")
end
- it 'does not convert line endings when parameter present' do
- get :raw, params: { id: personal_snippet.to_param, line_ending: :raw }
+ it "does not convert line endings when parameter present" do
+ get :raw, params: {id: personal_snippet.to_param, line_ending: :raw}
expect(response.body).to eq("first line\r\nsecond line\r\nthird line")
end
end
end
- context 'when not signed in' do
- it 'responds with status 200' do
- get :raw, params: { id: personal_snippet.to_param }
+ context "when not signed in" do
+ it "responds with status 200" do
+ get :raw, params: {id: personal_snippet.to_param}
expect(assigns(:snippet)).to eq(personal_snippet)
expect(response).to have_gitlab_http_status(200)
@@ -556,22 +556,22 @@ describe SnippetsController do
end
end
- context 'when the personal snippet does not exist' do
- context 'when signed in' do
+ context "when the personal snippet does not exist" do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'responds with status 404' do
- get :raw, params: { id: 'doesntexist' }
+ it "responds with status 404" do
+ get :raw, params: {id: "doesntexist"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when not signed in' do
- it 'redirects to the sign in path' do
- get :raw, params: { id: 'doesntexist' }
+ context "when not signed in" do
+ it "redirects to the sign in path" do
+ get :raw, params: {id: "doesntexist"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -579,7 +579,7 @@ describe SnippetsController do
end
end
- context 'award emoji on snippets' do
+ context "award emoji on snippets" do
let(:personal_snippet) { create(:personal_snippet, :public, author: user) }
let(:another_user) { create(:user) }
@@ -587,36 +587,36 @@ describe SnippetsController do
sign_in(another_user)
end
- describe 'POST #toggle_award_emoji' do
+ describe "POST #toggle_award_emoji" do
it "toggles the award emoji" do
- expect do
- post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" })
- end.to change { personal_snippet.award_emoji.count }.from(0).to(1)
+ expect {
+ post(:toggle_award_emoji, params: {id: personal_snippet.to_param, name: "thumbsup"})
+ }.to change { personal_snippet.award_emoji.count }.from(0).to(1)
expect(response.status).to eq(200)
end
it "removes the already awarded emoji" do
- post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" })
+ post(:toggle_award_emoji, params: {id: personal_snippet.to_param, name: "thumbsup"})
- expect do
- post(:toggle_award_emoji, params: { id: personal_snippet.to_param, name: "thumbsup" })
- end.to change { personal_snippet.award_emoji.count }.from(1).to(0)
+ expect {
+ post(:toggle_award_emoji, params: {id: personal_snippet.to_param, name: "thumbsup"})
+ }.to change { personal_snippet.award_emoji.count }.from(1).to(0)
expect(response.status).to eq(200)
end
end
end
- describe 'POST #preview_markdown' do
+ describe "POST #preview_markdown" do
let(:snippet) { create(:personal_snippet, :public) }
- it 'renders json in a correct format' do
+ it "renders json in a correct format" do
sign_in(user)
- post :preview_markdown, params: { id: snippet, text: '*Markdown* text' }
+ post :preview_markdown, params: {id: snippet, text: "*Markdown* text"}
- expect(JSON.parse(response.body).keys).to match_array(%w(body references))
+ expect(JSON.parse(response.body).keys).to match_array(%w[body references])
end
end
end
diff --git a/spec/controllers/uploads_controller_spec.rb b/spec/controllers/uploads_controller_spec.rb
index e52a5fe42f2..a0cf997925b 100644
--- a/spec/controllers/uploads_controller_spec.rb
+++ b/spec/controllers/uploads_controller_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
-shared_examples 'content not cached without revalidation' do
- it 'ensures content will not be cached without revalidation' do
- expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate')
+require "spec_helper"
+shared_examples "content not cached without revalidation" do
+ it "ensures content will not be cached without revalidation" do
+ expect(subject["Cache-Control"]).to eq("max-age=0, private, must-revalidate")
end
end
-shared_examples 'content not cached without revalidation and no-store' do
- it 'ensures content will not be cached without revalidation' do
+shared_examples "content not cached without revalidation and no-store" do
+ it "ensures content will not be cached without revalidation" do
# Fixed in newer versions of ActivePack, it will only output a single `private`.
- expect(subject['Cache-Control']).to eq('max-age=0, private, must-revalidate, no-store')
+ expect(subject["Cache-Control"]).to eq("max-age=0, private, must-revalidate, no-store")
end
end
-shared_examples 'content publicly cached' do
- it 'ensures content is publicly cached' do
- expect(subject['Cache-Control']).to eq('max-age=300, public')
+shared_examples "content publicly cached" do
+ it "ensures content is publicly cached" do
+ expect(subject["Cache-Control"]).to eq("max-age=300, public")
end
end
describe UploadsController do
let!(:user) { create(:user, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
- describe 'POST create' do
- let(:model) { 'personal_snippet' }
+ describe "POST create" do
+ let(:model) { "personal_snippet" }
let(:snippet) { create(:personal_snippet, :public) }
- let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
- let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
+ let(:jpg) { fixture_file_upload("spec/fixtures/rails_sample.jpg", "image/jpg") }
+ let(:txt) { fixture_file_upload("spec/fixtures/doc_sample.txt", "text/plain") }
- context 'when a user does not have permissions to upload a file' do
+ context "when a user does not have permissions to upload a file" do
it "returns 401 when the user is not logged in" do
- post :create, params: { model: model, id: snippet.id }, format: :json
+ post :create, params: {model: model, id: snippet.id}, format: :json
expect(response).to have_gitlab_http_status(401)
end
@@ -38,45 +38,45 @@ describe UploadsController do
private_snippet = create(:personal_snippet, :private)
sign_in(user)
- post :create, params: { model: model, id: private_snippet.id }, format: :json
+ post :create, params: {model: model, id: private_snippet.id}, format: :json
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when a user is logged in' do
+ context "when a user is logged in" do
before do
sign_in(user)
end
it "returns an error without file" do
- post :create, params: { model: model, id: snippet.id }, format: :json
+ post :create, params: {model: model, id: snippet.id}, format: :json
expect(response).to have_gitlab_http_status(422)
end
it "returns an error with invalid model" do
- expect { post :create, params: { model: 'invalid', id: snippet.id }, format: :json }
- .to raise_error(ActionController::UrlGenerationError)
+ expect { post :create, params: {model: "invalid", id: snippet.id}, format: :json }
+ .to raise_error(ActionController::UrlGenerationError)
end
it "returns 404 status when object not found" do
- post :create, params: { model: model, id: 9999 }, format: :json
+ post :create, params: {model: model, id: 9999}, format: :json
expect(response).to have_gitlab_http_status(404)
end
- context 'with valid image' do
+ context "with valid image" do
before do
- post :create, params: { model: 'personal_snippet', id: snippet.id, file: jpg }, format: :json
+ post :create, params: {model: "personal_snippet", id: snippet.id, file: jpg}, format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
expect(response.body).to match '\"alt\":\"rails_sample\"'
expect(response.body).to match "\"url\":\"/uploads"
end
- it 'creates a corresponding Upload record' do
+ it "creates a corresponding Upload record" do
upload = Upload.last
aggregate_failures do
@@ -86,17 +86,17 @@ describe UploadsController do
end
end
- context 'with valid non-image file' do
+ context "with valid non-image file" do
before do
- post :create, params: { model: 'personal_snippet', id: snippet.id, file: txt }, format: :json
+ post :create, params: {model: "personal_snippet", id: snippet.id, file: txt}, format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
expect(response.body).to match '\"alt\":\"doc_sample.txt\"'
expect(response.body).to match "\"url\":\"/uploads"
end
- it 'creates a corresponding Upload record' do
+ it "creates a corresponding Upload record" do
upload = Upload.last
aggregate_failures do
@@ -106,36 +106,36 @@ describe UploadsController do
end
end
- context 'temporal with valid image' do
+ context "temporal with valid image" do
subject do
- post :create, params: { model: 'personal_snippet', file: jpg }, format: :json
+ post :create, params: {model: "personal_snippet", file: jpg}, format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
subject
expect(response.body).to match '\"alt\":\"rails_sample\"'
expect(response.body).to match "\"url\":\"/uploads/-/system/temp"
end
- it 'does not create an Upload record' do
+ it "does not create an Upload record" do
expect { subject }.not_to change { Upload.count }
end
end
- context 'temporal with valid non-image file' do
+ context "temporal with valid non-image file" do
subject do
- post :create, params: { model: 'personal_snippet', file: txt }, format: :json
+ post :create, params: {model: "personal_snippet", file: txt}, format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
subject
expect(response.body).to match '\"alt\":\"doc_sample.txt\"'
expect(response.body).to match "\"url\":\"/uploads/-/system/temp"
end
- it 'does not create an Upload record' do
+ it "does not create an Upload record" do
expect { subject }.not_to change { Upload.count }
end
end
@@ -143,24 +143,24 @@ describe UploadsController do
end
describe "GET show" do
- context 'Content-Disposition security measures' do
+ context "Content-Disposition security measures" do
let(:project) { create(:project, :public) }
- context 'for PNG files' do
- it 'returns Content-Disposition: inline' do
+ context "for PNG files" do
+ it "returns Content-Disposition: inline" do
note = create(:note, :with_attachment, project: project)
- get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
- expect(response['Content-Disposition']).to start_with('inline;')
+ expect(response["Content-Disposition"]).to start_with("inline;")
end
end
- context 'for SVG files' do
- it 'returns Content-Disposition: attachment' do
+ context "for SVG files" do
+ it "returns Content-Disposition: attachment" do
note = create(:note, :with_svg_attachment, project: project)
- get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'unsanitized.svg' }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "unsanitized.svg"}
- expect(response['Content-Disposition']).to start_with('attachment;')
+ expect(response["Content-Disposition"]).to start_with("attachment;")
end
end
end
@@ -177,7 +177,7 @@ describe UploadsController do
end
it "redirects to the sign in page" do
- get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" }
+ get :show, params: {model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -185,14 +185,14 @@ describe UploadsController do
context "when the user isn't blocked" do
it "responds with status 200" do
- get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" }
+ get :show, params: {model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content publicly cached' do
+ it_behaves_like "content publicly cached" do
subject do
- get :show, params: { model: 'user', mounted_as: 'avatar', id: user.id, filename: 'dk.png' }
+ get :show, params: {model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png"}
response
end
@@ -202,14 +202,14 @@ describe UploadsController do
context "when not signed in" do
it "responds with status 200" do
- get :show, params: { model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png" }
+ get :show, params: {model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content publicly cached' do
+ it_behaves_like "content publicly cached" do
subject do
- get :show, params: { model: 'user', mounted_as: 'avatar', id: user.id, filename: 'dk.png' }
+ get :show, params: {model: "user", mounted_as: "avatar", id: user.id, filename: "dk.png"}
response
end
@@ -227,14 +227,14 @@ describe UploadsController do
context "when not signed in" do
it "responds with status 200" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation' do
+ it_behaves_like "content not cached without revalidation" do
subject do
- get :show, params: { model: 'project', mounted_as: 'avatar', id: project.id, filename: 'dk.png' }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
response
end
@@ -247,14 +247,14 @@ describe UploadsController do
end
it "responds with status 200" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'project', mounted_as: 'avatar', id: project.id, filename: 'dk.png' }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
response
end
@@ -269,7 +269,7 @@ describe UploadsController do
context "when not signed in" do
it "redirects to the sign in page" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -292,7 +292,7 @@ describe UploadsController do
end
it "redirects to the sign in page" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -300,14 +300,14 @@ describe UploadsController do
context "when the user isn't blocked" do
it "responds with status 200" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'project', mounted_as: 'avatar', id: project.id, filename: 'dk.png' }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
response
end
@@ -317,7 +317,7 @@ describe UploadsController do
context "when the user doesn't have access to the project" do
it "responds with status 404" do
- get :show, params: { model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png" }
+ get :show, params: {model: "project", mounted_as: "avatar", id: project.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(404)
end
@@ -332,14 +332,14 @@ describe UploadsController do
context "when the group is public" do
context "when not signed in" do
it "responds with status 200" do
- get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation' do
+ it_behaves_like "content not cached without revalidation" do
subject do
- get :show, params: { model: 'group', mounted_as: 'avatar', id: group.id, filename: 'dk.png' }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
response
end
@@ -352,14 +352,14 @@ describe UploadsController do
end
it "responds with status 200" do
- get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'group', mounted_as: 'avatar', id: group.id, filename: 'dk.png' }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
response
end
@@ -388,7 +388,7 @@ describe UploadsController do
end
it "redirects to the sign in page" do
- get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -396,14 +396,14 @@ describe UploadsController do
context "when the user isn't blocked" do
it "responds with status 200" do
- get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'group', mounted_as: 'avatar', id: group.id, filename: 'dk.png' }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
response
end
@@ -413,7 +413,7 @@ describe UploadsController do
context "when the user doesn't have access to the project" do
it "responds with status 404" do
- get :show, params: { model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png" }
+ get :show, params: {model: "group", mounted_as: "avatar", id: group.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(404)
end
@@ -433,14 +433,14 @@ describe UploadsController do
context "when not signed in" do
it "responds with status 200" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation' do
+ it_behaves_like "content not cached without revalidation" do
subject do
- get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
response
end
@@ -453,14 +453,14 @@ describe UploadsController do
end
it "responds with status 200" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
response
end
@@ -475,7 +475,7 @@ describe UploadsController do
context "when not signed in" do
it "redirects to the sign in page" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -498,7 +498,7 @@ describe UploadsController do
end
it "redirects to the sign in page" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to redirect_to(new_user_session_path)
end
@@ -506,14 +506,14 @@ describe UploadsController do
context "when the user isn't blocked" do
it "responds with status 200" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content not cached without revalidation and no-store' do
+ it_behaves_like "content not cached without revalidation and no-store" do
subject do
- get :show, params: { model: 'note', mounted_as: 'attachment', id: note.id, filename: 'dk.png' }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
response
end
@@ -523,7 +523,7 @@ describe UploadsController do
context "when the user doesn't have access to the project" do
it "responds with status 404" do
- get :show, params: { model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png" }
+ get :show, params: {model: "note", mounted_as: "attachment", id: note.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(404)
end
@@ -532,20 +532,20 @@ describe UploadsController do
end
end
- context 'Appearance' do
- context 'when viewing a custom header logo' do
- let!(:appearance) { create :appearance, header_logo: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
+ context "Appearance" do
+ context "when viewing a custom header logo" do
+ let!(:appearance) { create :appearance, header_logo: fixture_file_upload("spec/fixtures/dk.png", "image/png") }
- context 'when not signed in' do
- it 'responds with status 200' do
- get :show, params: { model: 'appearance', mounted_as: 'header_logo', id: appearance.id, filename: 'dk.png' }
+ context "when not signed in" do
+ it "responds with status 200" do
+ get :show, params: {model: "appearance", mounted_as: "header_logo", id: appearance.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content publicly cached' do
+ it_behaves_like "content publicly cached" do
subject do
- get :show, params: { model: 'appearance', mounted_as: 'header_logo', id: appearance.id, filename: 'dk.png' }
+ get :show, params: {model: "appearance", mounted_as: "header_logo", id: appearance.id, filename: "dk.png"}
response
end
@@ -553,19 +553,19 @@ describe UploadsController do
end
end
- context 'when viewing a custom logo' do
- let!(:appearance) { create :appearance, logo: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
+ context "when viewing a custom logo" do
+ let!(:appearance) { create :appearance, logo: fixture_file_upload("spec/fixtures/dk.png", "image/png") }
- context 'when not signed in' do
- it 'responds with status 200' do
- get :show, params: { model: 'appearance', mounted_as: 'logo', id: appearance.id, filename: 'dk.png' }
+ context "when not signed in" do
+ it "responds with status 200" do
+ get :show, params: {model: "appearance", mounted_as: "logo", id: appearance.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
end
- it_behaves_like 'content publicly cached' do
+ it_behaves_like "content publicly cached" do
subject do
- get :show, params: { model: 'appearance', mounted_as: 'logo', id: appearance.id, filename: 'dk.png' }
+ get :show, params: {model: "appearance", mounted_as: "logo", id: appearance.id, filename: "dk.png"}
response
end
@@ -574,21 +574,21 @@ describe UploadsController do
end
end
- context 'original filename or a version filename must match' do
- let!(:appearance) { create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png', 'image/png') }
+ context "original filename or a version filename must match" do
+ let!(:appearance) { create :appearance, favicon: fixture_file_upload("spec/fixtures/dk.png", "image/png") }
- context 'has a valid filename on the original file' do
- it 'successfully returns the file' do
- get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'dk.png' }
+ context "has a valid filename on the original file" do
+ it "successfully returns the file" do
+ get :show, params: {model: "appearance", mounted_as: "favicon", id: appearance.id, filename: "dk.png"}
expect(response).to have_gitlab_http_status(200)
- expect(response.header['Content-Disposition']).to end_with 'filename="dk.png"'
+ expect(response.header["Content-Disposition"]).to end_with 'filename="dk.png"'
end
end
- context 'has an invalid filename on the original file' do
- it 'returns a 404' do
- get :show, params: { model: 'appearance', mounted_as: 'favicon', id: appearance.id, filename: 'bogus.png' }
+ context "has an invalid filename on the original file" do
+ it "returns a 404" do
+ get :show, params: {model: "appearance", mounted_as: "favicon", id: appearance.id, filename: "bogus.png"}
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/controllers/user_callouts_controller_spec.rb b/spec/controllers/user_callouts_controller_spec.rb
index c71d75a3e7f..6bb5c7a77da 100644
--- a/spec/controllers/user_callouts_controller_spec.rb
+++ b/spec/controllers/user_callouts_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UserCalloutsController do
let(:user) { create(:user) }
@@ -8,27 +8,27 @@ describe UserCalloutsController do
end
describe "POST #create" do
- subject { post :create, params: { feature_name: feature_name }, format: :json }
+ subject { post :create, params: {feature_name: feature_name}, format: :json }
- context 'with valid feature name' do
+ context "with valid feature name" do
let(:feature_name) { UserCallout.feature_names.keys.first }
- context 'when callout entry does not exist' do
- it 'should create a callout entry with dismissed state' do
+ context "when callout entry does not exist" do
+ it "should create a callout entry with dismissed state" do
expect { subject }.to change { UserCallout.count }.by(1)
end
- it 'should return success' do
+ it "should return success" do
subject
expect(response).to have_gitlab_http_status(:ok)
end
end
- context 'when callout entry already exists' do
+ context "when callout entry already exists" do
let!(:callout) { create(:user_callout, feature_name: UserCallout.feature_names.keys.first, user: user) }
- it 'should return success' do
+ it "should return success" do
subject
expect(response).to have_gitlab_http_status(:ok)
@@ -36,10 +36,10 @@ describe UserCalloutsController do
end
end
- context 'with invalid feature name' do
- let(:feature_name) { 'bogus_feature_name' }
+ context "with invalid feature name" do
+ let(:feature_name) { "bogus_feature_name" }
- it 'should return bad request' do
+ it "should return bad request" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
diff --git a/spec/controllers/users/terms_controller_spec.rb b/spec/controllers/users/terms_controller_spec.rb
index cbfd2b17864..18439d755f3 100644
--- a/spec/controllers/users/terms_controller_spec.rb
+++ b/spec/controllers/users/terms_controller_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::TermsController do
include TermsHelper
@@ -9,26 +9,26 @@ describe Users::TermsController do
sign_in user
end
- describe 'GET #index' do
- it 'redirects when no terms exist' do
+ describe "GET #index" do
+ it "redirects when no terms exist" do
get :index
expect(response).to have_gitlab_http_status(:redirect)
end
- context 'when terms exist' do
+ context "when terms exist" do
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
term
end
- it 'shows terms when they exist' do
+ it "shows terms when they exist" do
get :index
expect(response).to have_gitlab_http_status(:success)
end
- it 'shows a message when the user already accepted the terms' do
+ it "shows a message when the user already accepted the terms" do
accept_terms(user)
get :index
@@ -38,57 +38,57 @@ describe Users::TermsController do
end
end
- describe 'POST #accept' do
- it 'saves that the user accepted the terms' do
- post :accept, params: { id: term.id }
+ describe "POST #accept" do
+ it "saves that the user accepted the terms" do
+ post :accept, params: {id: term.id}
agreement = user.term_agreements.find_by(term: term)
expect(agreement.accepted).to eq(true)
end
- it 'redirects to a path when specified' do
- post :accept, params: { id: term.id, redirect: groups_path }
+ it "redirects to a path when specified" do
+ post :accept, params: {id: term.id, redirect: groups_path}
expect(response).to redirect_to(groups_path)
end
- it 'redirects to the referer when no redirect specified' do
+ it "redirects to the referer when no redirect specified" do
request.env["HTTP_REFERER"] = groups_url
- post :accept, params: { id: term.id }
+ post :accept, params: {id: term.id}
expect(response).to redirect_to(groups_path)
end
- context 'redirecting to another domain' do
- it 'is prevented when passing a redirect param' do
- post :accept, params: { id: term.id, redirect: '//example.com/random/path' }
+ context "redirecting to another domain" do
+ it "is prevented when passing a redirect param" do
+ post :accept, params: {id: term.id, redirect: "//example.com/random/path"}
expect(response).to redirect_to(root_path)
end
- it 'is prevented when redirecting to the referer' do
- request.env["HTTP_REFERER"] = 'http://example.com/and/a/path'
+ it "is prevented when redirecting to the referer" do
+ request.env["HTTP_REFERER"] = "http://example.com/and/a/path"
- post :accept, params: { id: term.id }
+ post :accept, params: {id: term.id}
expect(response).to redirect_to(root_path)
end
end
end
- describe 'POST #decline' do
- it 'stores that the user declined the terms' do
- post :decline, params: { id: term.id }
+ describe "POST #decline" do
+ it "stores that the user declined the terms" do
+ post :decline, params: {id: term.id}
agreement = user.term_agreements.find_by(term: term)
expect(agreement.accepted).to eq(false)
end
- it 'signs out the user' do
- post :decline, params: { id: term.id }
+ it "signs out the user" do
+ post :decline, params: {id: term.id}
expect(response).to redirect_to(root_path)
expect(assigns(:current_user)).to be_nil
diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb
index af61026098b..35ff6459881 100644
--- a/spec/controllers/users_controller_spec.rb
+++ b/spec/controllers/users_controller_spec.rb
@@ -1,83 +1,83 @@
-require 'spec_helper'
+require "spec_helper"
describe UsersController do
let(:user) { create(:user) }
let(:private_user) { create(:user, private_profile: true) }
let(:public_user) { create(:user) }
- describe 'GET #show' do
- context 'with rendered views' do
+ describe "GET #show" do
+ context "with rendered views" do
render_views
- describe 'when logged in' do
+ describe "when logged in" do
before do
sign_in(user)
end
- it 'renders the show template' do
- get :show, params: { username: user.username }
+ it "renders the show template" do
+ get :show, params: {username: user.username}
expect(response).to be_success
- expect(response).to render_template('show')
+ expect(response).to render_template("show")
end
end
- describe 'when logged out' do
- it 'renders the show template' do
- get :show, params: { username: user.username }
+ describe "when logged out" do
+ it "renders the show template" do
+ get :show, params: {username: user.username}
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('show')
+ expect(response).to render_template("show")
end
end
end
- context 'when public visibility level is restricted' do
+ context "when public visibility level is restricted" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- context 'when logged out' do
- it 'redirects to login page' do
- get :show, params: { username: user.username }
+ context "when logged out" do
+ it "redirects to login page" do
+ get :show, params: {username: user.username}
expect(response).to redirect_to new_user_session_path
end
end
- context 'when logged in' do
+ context "when logged in" do
before do
sign_in(user)
end
- it 'renders show' do
- get :show, params: { username: user.username }
+ it "renders show" do
+ get :show, params: {username: user.username}
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('show')
+ expect(response).to render_template("show")
end
end
end
- context 'when a user by that username does not exist' do
- context 'when logged out' do
- it 'redirects to login page' do
- get :show, params: { username: 'nonexistent' }
+ context "when a user by that username does not exist" do
+ context "when logged out" do
+ it "redirects to login page" do
+ get :show, params: {username: "nonexistent"}
expect(response).to redirect_to new_user_session_path
end
end
- context 'when logged in' do
+ context "when logged in" do
before do
sign_in(user)
end
- it 'renders 404' do
- get :show, params: { username: 'nonexistent' }
+ it "renders 404" do
+ get :show, params: {username: "nonexistent"}
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'json with events' do
+ context "json with events" do
let(:project) { create(:project) }
before do
project.add_developer(user)
@@ -86,33 +86,33 @@ describe UsersController do
sign_in(user)
end
- it 'loads events' do
- get :show, params: { username: user }, format: :json
+ it "loads events" do
+ get :show, params: {username: user}, format: :json
expect(assigns(:events)).not_to be_empty
end
- it 'hides events if the user cannot read cross project' do
+ it "hides events if the user cannot read cross project" do
allow(Ability).to receive(:allowed?).and_call_original
expect(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
- get :show, params: { username: user }, format: :json
+ get :show, params: {username: user}, format: :json
expect(assigns(:events)).to be_empty
end
- it 'hides events if the user has a private profile' do
+ it "hides events if the user has a private profile" do
Gitlab::DataBuilder::Push.build_sample(project, private_user)
- get :show, params: { username: private_user.username }, format: :json
+ get :show, params: {username: private_user.username}, format: :json
expect(assigns(:events)).to be_empty
end
end
end
- describe 'GET #calendar' do
- context 'for user' do
+ describe "GET #calendar" do
+ context "for user" do
let(:project) { create(:project) }
before do
@@ -120,30 +120,30 @@ describe UsersController do
project.add_developer(user)
end
- context 'with public profile' do
- it 'renders calendar' do
+ context "with public profile" do
+ it "renders calendar" do
push_data = Gitlab::DataBuilder::Push.build_sample(project, public_user)
EventCreateService.new.push(project, public_user, push_data)
- get :calendar, params: { username: public_user.username }, format: :json
+ get :calendar, params: {username: public_user.username}, format: :json
expect(response).to have_gitlab_http_status(200)
end
end
- context 'with private profile' do
- it 'does not render calendar' do
+ context "with private profile" do
+ it "does not render calendar" do
push_data = Gitlab::DataBuilder::Push.build_sample(project, private_user)
EventCreateService.new.push(project, private_user, push_data)
- get :calendar, params: { username: private_user.username }, format: :json
+ get :calendar, params: {username: private_user.username}, format: :json
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
- context 'forked project' do
+ context "forked project" do
let(:project) { create(:project) }
let(:forked_project) { Projects::ForkService.new(project, user).execute }
@@ -160,14 +160,14 @@ describe UsersController do
EventCreateService.new.push(forked_project, user, fork_push_data)
end
- it 'includes forked projects' do
- get :calendar, params: { username: user.username }
+ it "includes forked projects" do
+ get :calendar, params: {username: user.username}
expect(assigns(:contributions_calendar).projects.count).to eq(2)
end
end
end
- describe 'GET #calendar_activities' do
+ describe "GET #calendar_activities" do
let!(:project) { create(:project) }
let(:user) { create(:user) }
@@ -178,35 +178,35 @@ describe UsersController do
project.add_developer(user)
end
- it 'assigns @calendar_date' do
- get :calendar_activities, params: { username: user.username, date: '2014-07-31' }
- expect(assigns(:calendar_date)).to eq(Date.parse('2014-07-31'))
+ it "assigns @calendar_date" do
+ get :calendar_activities, params: {username: user.username, date: "2014-07-31"}
+ expect(assigns(:calendar_date)).to eq(Date.parse("2014-07-31"))
end
- context 'for user' do
- context 'with public profile' do
- it 'renders calendar_activities' do
+ context "for user" do
+ context "with public profile" do
+ it "renders calendar_activities" do
push_data = Gitlab::DataBuilder::Push.build_sample(project, public_user)
EventCreateService.new.push(project, public_user, push_data)
- get :calendar_activities, params: { username: public_user.username }
+ get :calendar_activities, params: {username: public_user.username}
expect(assigns[:events]).not_to be_empty
end
end
- context 'with private profile' do
- it 'does not render calendar_activities' do
+ context "with private profile" do
+ it "does not render calendar_activities" do
push_data = Gitlab::DataBuilder::Push.build_sample(project, private_user)
EventCreateService.new.push(project, private_user, push_data)
- get :calendar_activities, params: { username: private_user.username }
+ get :calendar_activities, params: {username: private_user.username}
expect(response).to have_gitlab_http_status(:not_found)
end
end
end
end
- describe 'GET #contributed' do
+ describe "GET #contributed" do
let(:project) { create(:project, :public) }
let(:current_user) { create(:user) }
@@ -217,116 +217,116 @@ describe UsersController do
project.add_developer(private_user)
end
- context 'with public profile' do
- it 'renders contributed projects' do
+ context "with public profile" do
+ it "renders contributed projects" do
create(:push_event, project: project, author: public_user)
- get :contributed, params: { username: public_user.username }
+ get :contributed, params: {username: public_user.username}
expect(assigns[:contributed_projects]).not_to be_empty
end
end
- context 'with private profile' do
- it 'does not render contributed projects' do
+ context "with private profile" do
+ it "does not render contributed projects" do
create(:push_event, project: project, author: private_user)
- get :contributed, params: { username: private_user.username }
+ get :contributed, params: {username: private_user.username}
expect(assigns[:contributed_projects]).to be_empty
end
end
end
- describe 'GET #snippets' do
+ describe "GET #snippets" do
before do
sign_in(user)
end
- context 'format html' do
- it 'renders snippets page' do
- get :snippets, params: { username: user.username }
+ context "format html" do
+ it "renders snippets page" do
+ get :snippets, params: {username: user.username}
expect(response).to have_gitlab_http_status(200)
- expect(response).to render_template('show')
+ expect(response).to render_template("show")
end
end
- context 'format json' do
- it 'response with snippets json data' do
- get :snippets, params: { username: user.username }, format: :json
+ context "format json" do
+ it "response with snippets json data" do
+ get :snippets, params: {username: user.username}, format: :json
expect(response).to have_gitlab_http_status(200)
- expect(JSON.parse(response.body)).to have_key('html')
+ expect(JSON.parse(response.body)).to have_key("html")
end
end
end
- describe 'GET #exists' do
+ describe "GET #exists" do
before do
sign_in(user)
end
- context 'when user exists' do
- it 'returns JSON indicating the user exists' do
- get :exists, params: { username: user.username }
+ context "when user exists" do
+ it "returns JSON indicating the user exists" do
+ get :exists, params: {username: user.username}
- expected_json = { exists: true }.to_json
+ expected_json = {exists: true}.to_json
expect(response.body).to eq(expected_json)
end
- context 'when the casing is different' do
- let(:user) { create(:user, username: 'CamelCaseUser') }
+ context "when the casing is different" do
+ let(:user) { create(:user, username: "CamelCaseUser") }
- it 'returns JSON indicating the user exists' do
- get :exists, params: { username: user.username.downcase }
+ it "returns JSON indicating the user exists" do
+ get :exists, params: {username: user.username.downcase}
- expected_json = { exists: true }.to_json
+ expected_json = {exists: true}.to_json
expect(response.body).to eq(expected_json)
end
end
end
- context 'when the user does not exist' do
- it 'returns JSON indicating the user does not exist' do
- get :exists, params: { username: 'foo' }
+ context "when the user does not exist" do
+ it "returns JSON indicating the user does not exist" do
+ get :exists, params: {username: "foo"}
- expected_json = { exists: false }.to_json
+ expected_json = {exists: false}.to_json
expect(response.body).to eq(expected_json)
end
- context 'when a user changed their username' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'old-username') }
+ context "when a user changed their username" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "old-username") }
- it 'returns JSON indicating a user by that username does not exist' do
- get :exists, params: { username: 'old-username' }
+ it "returns JSON indicating a user by that username does not exist" do
+ get :exists, params: {username: "old-username"}
- expected_json = { exists: false }.to_json
+ expected_json = {exists: false}.to_json
expect(response.body).to eq(expected_json)
end
end
end
end
- describe '#ensure_canonical_path' do
+ describe "#ensure_canonical_path" do
before do
sign_in(user)
end
- context 'for a GET request' do
- context 'when requesting users at the root path' do
- context 'when requesting the canonical path' do
- let(:user) { create(:user, username: 'CamelCaseUser') }
+ context "for a GET request" do
+ context "when requesting users at the root path" do
+ context "when requesting the canonical path" do
+ let(:user) { create(:user, username: "CamelCaseUser") }
- context 'with exactly matching casing' do
- it 'responds with success' do
- get :show, params: { username: user.username }
+ context "with exactly matching casing" do
+ it "responds with success" do
+ get :show, params: {username: user.username}
expect(response).to be_success
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :show, params: { username: user.username.downcase }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :show, params: {username: user.username.downcase}
expect(response).to redirect_to(user)
expect(controller).not_to set_flash[:notice]
@@ -334,32 +334,32 @@ describe UsersController do
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "old-path") }
- it 'redirects to the canonical path' do
- get :show, params: { username: redirect_route.path }
+ it "redirects to the canonical path" do
+ get :show, params: {username: redirect_route.path}
expect(response).to redirect_to(user)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
- context 'when the old path is a substring of the scheme or host' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'http') }
+ context "when the old path is a substring of the scheme or host" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "http") }
- it 'does not modify the requested host' do
- get :show, params: { username: redirect_route.path }
+ it "does not modify the requested host" do
+ get :show, params: {username: redirect_route.path}
expect(response).to redirect_to(user)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
- context 'when the old path is substring of users' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'ser') }
+ context "when the old path is substring of users" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "ser") }
- it 'redirects to the canonical path' do
- get :show, params: { username: redirect_route.path }
+ it "redirects to the canonical path" do
+ get :show, params: {username: redirect_route.path}
expect(response).to redirect_to(user)
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
@@ -368,21 +368,21 @@ describe UsersController do
end
end
- context 'when requesting users under the /users path' do
- context 'when requesting the canonical path' do
- let(:user) { create(:user, username: 'CamelCaseUser') }
+ context "when requesting users under the /users path" do
+ context "when requesting the canonical path" do
+ let(:user) { create(:user, username: "CamelCaseUser") }
- context 'with exactly matching casing' do
- it 'responds with success' do
- get :projects, params: { username: user.username }
+ context "with exactly matching casing" do
+ it "responds with success" do
+ get :projects, params: {username: user.username}
expect(response).to be_success
end
end
- context 'with different casing' do
- it 'redirects to the correct casing' do
- get :projects, params: { username: user.username.downcase }
+ context "with different casing" do
+ it "redirects to the correct casing" do
+ get :projects, params: {username: user.username.downcase}
expect(response).to redirect_to(user_projects_path(user))
expect(controller).not_to set_flash[:notice]
@@ -390,33 +390,33 @@ describe UsersController do
end
end
- context 'when requesting a redirected path' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'old-path') }
+ context "when requesting a redirected path" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "old-path") }
- it 'redirects to the canonical path' do
- get :projects, params: { username: redirect_route.path }
+ it "redirects to the canonical path" do
+ get :projects, params: {username: redirect_route.path}
expect(response).to redirect_to(user_projects_path(user))
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
- context 'when the old path is a substring of the scheme or host' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'http') }
+ context "when the old path is a substring of the scheme or host" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "http") }
- it 'does not modify the requested host' do
- get :projects, params: { username: redirect_route.path }
+ it "does not modify the requested host" do
+ get :projects, params: {username: redirect_route.path}
expect(response).to redirect_to(user_projects_path(user))
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
end
end
- context 'when the old path is substring of users' do
- let(:redirect_route) { user.namespace.redirect_routes.create(path: 'ser') }
+ context "when the old path is substring of users" do
+ let(:redirect_route) { user.namespace.redirect_routes.create(path: "ser") }
# I.e. /users/ser should not become /ufoos/ser
- it 'does not modify the /users part of the path' do
- get :projects, params: { username: redirect_route.path }
+ it "does not modify the /users part of the path" do
+ get :projects, params: {username: redirect_route.path}
expect(response).to redirect_to(user_projects_path(user))
expect(controller).to set_flash[:notice].to(user_moved_message(redirect_route, user))
@@ -427,8 +427,8 @@ describe UsersController do
end
end
- context 'token authentication' do
- it_behaves_like 'authenticates sessionless user', :show, :atom, public: true do
+ context "token authentication" do
+ it_behaves_like "authenticates sessionless user", :show, :atom, public: true do
before do
default_params.merge!(username: user.username)
end
diff --git a/spec/db/development/import_common_metrics_spec.rb b/spec/db/development/import_common_metrics_spec.rb
index 25061ef0887..eed16b64df7 100644
--- a/spec/db/development/import_common_metrics_spec.rb
+++ b/spec/db/development/import_common_metrics_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Import metrics on development seed' do
- subject { load Rails.root.join('db', 'fixtures', 'development', '99_common_metrics.rb') }
+describe "Import metrics on development seed" do
+ subject { load Rails.root.join("db", "fixtures", "development", "99_common_metrics.rb") }
it "imports all prometheus metrics" do
expect(PrometheusMetric.common).to be_empty
diff --git a/spec/db/importers/common_metrics_importer_spec.rb b/spec/db/importers/common_metrics_importer_spec.rb
index 6133b17ac61..4afbcd658b9 100644
--- a/spec/db/importers/common_metrics_importer_spec.rb
+++ b/spec/db/importers/common_metrics_importer_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
require Rails.root.join("db", "importers", "common_metrics_importer.rb")
describe Importers::PrometheusMetric do
@@ -10,11 +10,11 @@ describe Importers::PrometheusMetric do
end
end
- it 'group enum equals ::PrometheusMetric' do
+ it "group enum equals ::PrometheusMetric" do
expect(described_class.groups).to eq(::PrometheusMetric.groups)
end
- it 'GROUP_TITLES equals ::PrometheusMetric' do
+ it "GROUP_TITLES equals ::PrometheusMetric" do
expect(described_class::GROUP_TITLES).to eq(existing_group_titles)
end
end
@@ -24,9 +24,9 @@ describe Importers::CommonMetricsImporter do
context "does import common_metrics.yml" do
let(:groups) { subject.content }
- let(:metrics) { groups.map { |group| group['metrics'] }.flatten }
- let(:queries) { metrics.map { |group| group['queries'] }.flatten }
- let(:query_ids) { queries.map { |query| query['id'] } }
+ let(:metrics) { groups.map { |group| group["metrics"] }.flatten }
+ let(:queries) { metrics.map { |group| group["queries"] }.flatten }
+ let(:query_ids) { queries.map { |query| query["id"] } }
before do
subject.execute
@@ -63,21 +63,21 @@ describe Importers::CommonMetricsImporter do
end
end
- context 'does import properly all fields' do
- let(:query_identifier) { 'response-metric' }
+ context "does import properly all fields" do
+ let(:query_identifier) { "response-metric" }
let(:group) do
{
- group: 'Response metrics (NGINX Ingress)',
+ group: "Response metrics (NGINX Ingress)",
metrics: [{
title: "Throughput",
y_label: "Requests / Sec",
queries: [{
id: query_identifier,
- query_range: 'my-query',
- unit: 'my-unit',
- label: 'status code'
- }]
- }]
+ query_range: "my-query",
+ unit: "my-unit",
+ label: "status code",
+ }],
+ }],
}
end
@@ -85,50 +85,50 @@ describe Importers::CommonMetricsImporter do
expect(subject).to receive(:content) { [group.deep_stringify_keys] }
end
- shared_examples 'stores metric' do
+ shared_examples "stores metric" do
let(:metric) { PrometheusMetric.find_by(identifier: query_identifier) }
- it 'with all data' do
- expect(metric.group).to eq('nginx_ingress')
- expect(metric.title).to eq('Throughput')
- expect(metric.y_label).to eq('Requests / Sec')
- expect(metric.unit).to eq('my-unit')
- expect(metric.legend).to eq('status code')
- expect(metric.query).to eq('my-query')
+ it "with all data" do
+ expect(metric.group).to eq("nginx_ingress")
+ expect(metric.title).to eq("Throughput")
+ expect(metric.y_label).to eq("Requests / Sec")
+ expect(metric.unit).to eq("my-unit")
+ expect(metric.legend).to eq("status code")
+ expect(metric.query).to eq("my-query")
end
end
- context 'if ID is missing' do
+ context "if ID is missing" do
let(:query_identifier) { }
- it 'raises exception' do
+ it "raises exception" do
expect { subject.execute }.to raise_error(described_class::MissingQueryId)
end
end
- context 'for existing common metric with different ID' do
- let!(:existing_metric) { create(:prometheus_metric, :common, identifier: 'my-existing-metric') }
+ context "for existing common metric with different ID" do
+ let!(:existing_metric) { create(:prometheus_metric, :common, identifier: "my-existing-metric") }
before do
subject.execute
end
- it_behaves_like 'stores metric' do
- it 'and existing metric is not changed' do
+ it_behaves_like "stores metric" do
+ it "and existing metric is not changed" do
expect(metric).not_to eq(existing_metric)
end
end
end
- context 'when metric with ID exists ' do
- let!(:existing_metric) { create(:prometheus_metric, :common, identifier: 'response-metric') }
+ context "when metric with ID exists " do
+ let!(:existing_metric) { create(:prometheus_metric, :common, identifier: "response-metric") }
before do
subject.execute
end
- it_behaves_like 'stores metric' do
- it 'and existing metric is changed' do
+ it_behaves_like "stores metric" do
+ it "and existing metric is changed" do
expect(metric).to eq(existing_metric)
end
end
diff --git a/spec/db/production/import_common_metrics_spec.rb b/spec/db/production/import_common_metrics_spec.rb
index 1e4ff818a86..9b82470a52c 100644
--- a/spec/db/production/import_common_metrics_spec.rb
+++ b/spec/db/production/import_common_metrics_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Import metrics on production seed' do
- subject { load Rails.root.join('db', 'fixtures', 'production', '999_common_metrics.rb') }
+describe "Import metrics on production seed" do
+ subject { load Rails.root.join("db", "fixtures", "production", "999_common_metrics.rb") }
it "imports all prometheus metrics" do
expect(PrometheusMetric.common).to be_empty
diff --git a/spec/db/production/settings_spec.rb b/spec/db/production/settings_spec.rb
index db19e98b851..475a4fa323d 100644
--- a/spec/db/production/settings_spec.rb
+++ b/spec/db/production/settings_spec.rb
@@ -1,59 +1,59 @@
-require 'spec_helper'
-require 'rainbow/ext/string'
+require "spec_helper"
+require "rainbow/ext/string"
-describe 'seed production settings' do
- let(:settings_file) { Rails.root.join('db/fixtures/production/010_settings.rb') }
+describe "seed production settings" do
+ let(:settings_file) { Rails.root.join("db/fixtures/production/010_settings.rb") }
let(:settings) { Gitlab::CurrentSettings.current_application_settings }
before do
# It's important to set this variable so that we don't save a memoized
# (supposed to be) in-memory record in `Gitlab::CurrentSettings.in_memory_application_settings`
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- context 'GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN is set in the environment' do
+ context "GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN is set in the environment" do
before do
- stub_env('GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN', '013456789')
+ stub_env("GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN", "013456789")
end
- it 'writes the token to the database' do
+ it "writes the token to the database" do
load(settings_file)
- expect(settings.runners_registration_token).to eq('013456789')
+ expect(settings.runners_registration_token).to eq("013456789")
end
end
- context 'GITLAB_PROMETHEUS_METRICS_ENABLED is set in the environment' do
- context 'GITLAB_PROMETHEUS_METRICS_ENABLED is true' do
+ context "GITLAB_PROMETHEUS_METRICS_ENABLED is set in the environment" do
+ context "GITLAB_PROMETHEUS_METRICS_ENABLED is true" do
before do
- stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', 'true')
+ stub_env("GITLAB_PROMETHEUS_METRICS_ENABLED", "true")
end
- it 'prometheus_metrics_enabled is set to true ' do
+ it "prometheus_metrics_enabled is set to true " do
load(settings_file)
expect(settings.prometheus_metrics_enabled).to eq(true)
end
end
- context 'GITLAB_PROMETHEUS_METRICS_ENABLED is false' do
+ context "GITLAB_PROMETHEUS_METRICS_ENABLED is false" do
before do
- stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', 'false')
+ stub_env("GITLAB_PROMETHEUS_METRICS_ENABLED", "false")
end
- it 'prometheus_metrics_enabled is set to false' do
+ it "prometheus_metrics_enabled is set to false" do
load(settings_file)
expect(settings.prometheus_metrics_enabled).to eq(false)
end
end
- context 'GITLAB_PROMETHEUS_METRICS_ENABLED is default' do
+ context "GITLAB_PROMETHEUS_METRICS_ENABLED is default" do
before do
- stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '')
+ stub_env("GITLAB_PROMETHEUS_METRICS_ENABLED", "")
end
- it 'prometheus_metrics_enabled is set to true' do
+ it "prometheus_metrics_enabled is set to true" do
load(settings_file)
expect(settings.prometheus_metrics_enabled).to eq(true)
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index 897b4411055..e0b90ded007 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Database schema' do
+describe "Database schema" do
let(:connection) { ActiveRecord::Base.connection }
let(:tables) { connection.tables }
@@ -55,10 +55,10 @@ describe 'Database schema' do
users: %w[color_scheme_id created_by_id theme_id],
users_star_projects: %w[user_id],
web_hooks: %w[service_id],
- suggestions: %w[commit_id]
+ suggestions: %w[commit_id],
}.with_indifferent_access.freeze
- context 'for table' do
+ context "for table" do
ActiveRecord::Base.connection.tables.sort.each do |table|
describe table do
let(:indexes) { connection.indexes(table) }
@@ -66,9 +66,9 @@ describe 'Database schema' do
let(:foreign_keys) { connection.foreign_keys(table) }
let(:primary_key_column) { connection.primary_key(table) }
- context 'all foreign keys' do
+ context "all foreign keys" do
# for index to be effective, the FK constraint has to be at first place
- it 'are indexed' do
+ it "are indexed" do
first_indexed_column = indexes.map(&:columns).map(&:first)
foreign_keys_columns = foreign_keys.map(&:column)
@@ -82,13 +82,13 @@ describe 'Database schema' do
end
end
- context 'columns ending with _id' do
+ context "columns ending with _id" do
let(:column_names) { columns.map(&:name) }
- let(:column_names_with_id) { column_names.select { |column_name| column_name.ends_with?('_id') } }
+ let(:column_names_with_id) { column_names.select { |column_name| column_name.ends_with?("_id") } }
let(:foreign_keys_columns) { foreign_keys.map(&:column) }
let(:ignored_columns) { ignored_fk_columns(table) }
- it 'do have the foreign keys' do
+ it "do have the foreign keys" do
expect(column_names_with_id - ignored_columns).to contain_exactly(*foreign_keys_columns)
end
end
diff --git a/spec/dependencies/omniauth_saml_spec.rb b/spec/dependencies/omniauth_saml_spec.rb
index ccc604dc230..9b4801be98e 100644
--- a/spec/dependencies/omniauth_saml_spec.rb
+++ b/spec/dependencies/omniauth_saml_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'omniauth/strategies/saml'
+require "spec_helper"
+require "omniauth/strategies/saml"
-describe 'processing of SAMLResponse in dependencies' do
- let(:mock_saml_response) { File.read('spec/fixtures/authentication/saml_response.xml') }
+describe "processing of SAMLResponse in dependencies" do
+ let(:mock_saml_response) { File.read("spec/fixtures/authentication/saml_response.xml") }
let(:saml_strategy) { OmniAuth::Strategies::SAML.new({}) }
let(:session_mock) { {} }
- let(:settings) { OpenStruct.new({ soft: false, idp_cert_fingerprint: 'something' }) }
+ let(:settings) { OpenStruct.new({soft: false, idp_cert_fingerprint: "something"}) }
let(:auth_hash) { Gitlab::Auth::Saml::AuthHash.new(saml_strategy) }
subject { auth_hash.authn_context }
@@ -13,10 +13,10 @@ describe 'processing of SAMLResponse in dependencies' do
before do
allow(saml_strategy).to receive(:session).and_return(session_mock)
allow_any_instance_of(OneLogin::RubySaml::Response).to receive(:is_valid?).and_return(true)
- saml_strategy.send(:handle_response, mock_saml_response, {}, settings ) { }
+ saml_strategy.send(:handle_response, mock_saml_response, {}, settings) { }
end
- it 'can extract AuthnContextClassRef from SAMLResponse param' do
- is_expected.to eq 'urn:oasis:names:tc:SAML:2.0:ac:classes:Password'
+ it "can extract AuthnContextClassRef from SAMLResponse param" do
+ is_expected.to eq "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
end
end
diff --git a/spec/factories/abuse_reports.rb b/spec/factories/abuse_reports.rb
index 021971ac421..93164f3d73a 100644
--- a/spec/factories/abuse_reports.rb
+++ b/spec/factories/abuse_reports.rb
@@ -2,6 +2,6 @@ FactoryBot.define do
factory :abuse_report do
reporter factory: :user
user
- message 'User sends spam'
+ message "User sends spam"
end
end
diff --git a/spec/factories/appearances.rb b/spec/factories/appearances.rb
index dd5129229d4..1b235f742f4 100644
--- a/spec/factories/appearances.rb
+++ b/spec/factories/appearances.rb
@@ -8,15 +8,15 @@ FactoryBot.define do
end
trait :with_logo do
- logo { fixture_file_upload('spec/fixtures/dk.png') }
+ logo { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :with_header_logo do
- header_logo { fixture_file_upload('spec/fixtures/dk.png') }
+ header_logo { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :with_favicon do
- favicon { fixture_file_upload('spec/fixtures/dk.png') }
+ favicon { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :with_logos do
diff --git a/spec/factories/chat_names.rb b/spec/factories/chat_names.rb
index 56993e5da18..59116619a00 100644
--- a/spec/factories/chat_names.rb
+++ b/spec/factories/chat_names.rb
@@ -3,8 +3,8 @@ FactoryBot.define do
user factory: :user
service factory: :service
- team_id 'T0001'
- team_domain 'Awesome Team'
+ team_id "T0001"
+ team_domain "Awesome Team"
sequence(:chat_id) { |n| "U#{n}" }
chat_name { generate(:username) }
diff --git a/spec/factories/ci/bridge.rb b/spec/factories/ci/bridge.rb
index b1d82b98411..cb0227f8fa4 100644
--- a/spec/factories/ci/bridge.rb
+++ b/spec/factories/ci/bridge.rb
@@ -1,17 +1,17 @@
FactoryBot.define do
factory :ci_bridge, class: Ci::Bridge do
- name ' bridge'
- stage 'test'
+ name " bridge"
+ stage "test"
stage_idx 0
- ref 'master'
+ ref "master"
tag false
- created_at 'Di 29. Okt 09:50:00 CET 2013'
+ created_at "Di 29. Okt 09:50:00 CET 2013"
status :success
pipeline factory: :ci_pipeline
trait :variables do
- yaml_variables [{ key: 'BRIDGE', value: 'cross', public: true }]
+ yaml_variables [{key: "BRIDGE", value: "cross", public: true}]
end
transient { downstream nil }
@@ -21,7 +21,7 @@ FactoryBot.define do
if evaluator.downstream.present?
bridge.options = bridge.options.to_h.merge(
- trigger: { project: evaluator.downstream.full_path }
+ trigger: {project: evaluator.downstream.full_path}
)
end
end
diff --git a/spec/factories/ci/build_trace_chunks.rb b/spec/factories/ci/build_trace_chunks.rb
index 3e8e2736423..b0334452faf 100644
--- a/spec/factories/ci/build_trace_chunks.rb
+++ b/spec/factories/ci/build_trace_chunks.rb
@@ -8,7 +8,7 @@ FactoryBot.define do
data_store :redis
transient do
- initial_data 'test data'
+ initial_data "test data"
end
after(:create) do |build_trace_chunk, evaluator|
@@ -24,7 +24,7 @@ FactoryBot.define do
data_store :database
transient do
- initial_data 'test data'
+ initial_data "test data"
end
after(:build) do |build_trace_chunk, evaluator|
@@ -40,7 +40,7 @@ FactoryBot.define do
data_store :fog
transient do
- initial_data 'test data'
+ initial_data "test data"
end
after(:create) do |build_trace_chunk, evaluator|
diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb
index 0b3e67b4987..5e2ad567b04 100644
--- a/spec/factories/ci/builds.rb
+++ b/spec/factories/ci/builds.rb
@@ -2,26 +2,26 @@ include ActionDispatch::TestProcess
FactoryBot.define do
factory :ci_build, class: Ci::Build do
- name 'test'
- stage 'test'
+ name "test"
+ stage "test"
stage_idx 0
- ref 'master'
+ ref "master"
tag false
protected false
- created_at 'Di 29. Okt 09:50:00 CET 2013'
+ created_at "Di 29. Okt 09:50:00 CET 2013"
pending
options do
{
- image: 'ruby:2.1',
- services: ['postgres'],
- script: ['ls -a']
+ image: "ruby:2.1",
+ services: ["postgres"],
+ script: ["ls -a"],
}
end
yaml_variables do
[
- { key: 'DB_NAME', value: 'postgres', public: true }
+ {key: "DB_NAME", value: "postgres", public: true},
]
end
@@ -33,112 +33,112 @@ FactoryBot.define do
end
trait :started do
- started_at 'Di 29. Okt 09:51:28 CET 2013'
+ started_at "Di 29. Okt 09:51:28 CET 2013"
end
trait :finished do
started
- finished_at 'Di 29. Okt 09:53:28 CET 2013'
+ finished_at "Di 29. Okt 09:53:28 CET 2013"
end
trait :success do
finished
- status 'success'
+ status "success"
end
trait :failed do
finished
- status 'failed'
+ status "failed"
end
trait :canceled do
finished
- status 'canceled'
+ status "canceled"
end
trait :skipped do
started
- status 'skipped'
+ status "skipped"
end
trait :running do
started
- status 'running'
+ status "running"
end
trait :pending do
- queued_at 'Di 29. Okt 09:50:59 CET 2013'
- status 'pending'
+ queued_at "Di 29. Okt 09:50:59 CET 2013"
+ status "pending"
end
trait :created do
- status 'created'
+ status "created"
end
trait :scheduled do
schedulable
- status 'scheduled'
+ status "scheduled"
scheduled_at { 1.minute.since }
end
trait :expired_scheduled do
schedulable
- status 'scheduled'
+ status "scheduled"
scheduled_at { 1.minute.ago }
end
trait :manual do
- status 'manual'
- self.when 'manual'
+ status "manual"
+ self.when "manual"
end
trait :teardown_environment do
- environment 'staging'
+ environment "staging"
options do
{
- script: %w(ls),
- environment: { name: 'staging',
- action: 'stop',
- url: 'http://staging.example.com/$CI_JOB_NAME' }
+ script: %w[ls],
+ environment: {name: "staging",
+ action: "stop",
+ url: "http://staging.example.com/$CI_JOB_NAME",},
}
end
end
trait :deploy_to_production do
- environment 'production'
+ environment "production"
options do
{
- script: %w(ls),
- environment: { name: 'production',
- url: 'http://prd.example.com/$CI_JOB_NAME' }
+ script: %w[ls],
+ environment: {name: "production",
+ url: "http://prd.example.com/$CI_JOB_NAME",},
}
end
end
trait :start_review_app do
- environment 'review/$CI_COMMIT_REF_NAME'
+ environment "review/$CI_COMMIT_REF_NAME"
options do
{
- script: %w(ls),
- environment: { name: 'review/$CI_COMMIT_REF_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- on_stop: 'stop_review_app' }
+ script: %w[ls],
+ environment: {name: "review/$CI_COMMIT_REF_NAME",
+ url: "http://staging.example.com/$CI_JOB_NAME",
+ on_stop: "stop_review_app",},
}
end
end
trait :stop_review_app do
- name 'stop_review_app'
- environment 'review/$CI_COMMIT_REF_NAME'
+ name "stop_review_app"
+ environment "review/$CI_COMMIT_REF_NAME"
options do
{
- script: %w(ls),
- environment: { name: 'review/$CI_COMMIT_REF_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- action: 'stop' }
+ script: %w[ls],
+ environment: {name: "review/$CI_COMMIT_REF_NAME",
+ url: "http://staging.example.com/$CI_JOB_NAME",
+ action: "stop",},
}
end
end
@@ -160,18 +160,18 @@ FactoryBot.define do
end
trait :schedulable do
- self.when 'delayed'
+ self.when "delayed"
options do
{
- script: ['ls -a'],
- start_in: '1 minute'
+ script: ["ls -a"],
+ start_in: "1 minute",
}
end
end
trait :actionable do
- self.when 'manual'
+ self.when "manual"
end
trait :retried do
@@ -209,12 +209,12 @@ FactoryBot.define do
trait :coverage do
coverage 99.9
- coverage_regex '/(d+)/'
+ coverage_regex "/(d+)/"
end
trait :trace_live do
after(:create) do |build, evaluator|
- build.trace.set('BUILD TRACE')
+ build.trace.set("BUILD TRACE")
end
end
@@ -228,7 +228,9 @@ FactoryBot.define do
after(:create) do |build, evaluator|
trace = File.binread(
File.expand_path(
- Rails.root.join('spec/fixtures/trace/ansi-sequence-and-unicode')))
+ Rails.root.join("spec/fixtures/trace/ansi-sequence-and-unicode")
+ )
+ )
build.trace.set(trace)
end
@@ -248,9 +250,11 @@ FactoryBot.define do
after(:create) do |build, _|
build.update!(
legacy_artifacts_file: fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip'),
+ Rails.root.join("spec/fixtures/ci_build_artifacts.zip"), "application/zip"
+ ),
legacy_artifacts_metadata: fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/ci_build_artifacts_metadata.gz"), "application/x-gzip"
+ )
)
end
end
@@ -288,23 +292,23 @@ FactoryBot.define do
trait :extended_options do
options do
{
- image: { name: 'ruby:2.1', entrypoint: '/bin/sh' },
- services: ['postgres', { name: 'docker:stable-dind', entrypoint: '/bin/sh', command: 'sleep 30', alias: 'docker' }],
- script: %w(echo),
- after_script: %w(ls date),
- artifacts: {
- name: 'artifacts_file',
- untracked: false,
- paths: ['out/'],
- when: 'always',
- expire_in: '7d'
- },
- cache: {
- key: 'cache_key',
- untracked: false,
- paths: ['vendor/*'],
- policy: 'pull-push'
- }
+ image: {name: "ruby:2.1", entrypoint: "/bin/sh"},
+ services: ["postgres", {name: "docker:stable-dind", entrypoint: "/bin/sh", command: "sleep 30", alias: "docker"}],
+ script: %w[echo],
+ after_script: %w[ls date],
+ artifacts: {
+ name: "artifacts_file",
+ untracked: false,
+ paths: ["out/"],
+ when: "always",
+ expire_in: "7d",
+ },
+ cache: {
+ key: "cache_key",
+ untracked: false,
+ paths: ["vendor/*"],
+ policy: "pull-push",
+ },
}
end
end
@@ -314,8 +318,8 @@ FactoryBot.define do
end
trait :non_playable do
- status 'created'
- self.when 'manual'
+ status "created"
+ self.when "manual"
end
trait :protected do
@@ -334,7 +338,7 @@ FactoryBot.define do
trait :with_runner_session do
after(:build) do |build|
- build.build_runner_session(url: 'https://localhost')
+ build.build_runner_session(url: "https://localhost")
end
end
end
diff --git a/spec/factories/ci/group_variables.rb b/spec/factories/ci/group_variables.rb
index 9bf520a2c0a..4bb871b2aad 100644
--- a/spec/factories/ci/group_variables.rb
+++ b/spec/factories/ci/group_variables.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :ci_group_variable, class: Ci::GroupVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
- value 'VARIABLE_VALUE'
+ value "VARIABLE_VALUE"
masked false
trait(:protected) do
diff --git a/spec/factories/ci/job_artifacts.rb b/spec/factories/ci/job_artifacts.rb
index 2c76c22ba69..03e387addd6 100644
--- a/spec/factories/ci/job_artifacts.rb
+++ b/spec/factories/ci/job_artifacts.rb
@@ -19,7 +19,8 @@ FactoryBot.define do
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
+ Rails.root.join("spec/fixtures/trace/sample_trace"), "text/plain"
+ )
end
end
@@ -28,7 +29,8 @@ FactoryBot.define do
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
+ Rails.root.join("spec/fixtures/ci_build_artifacts.zip"), "application/zip"
+ )
end
end
@@ -37,7 +39,8 @@ FactoryBot.define do
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/ci_build_artifacts_metadata.gz"), "application/x-gzip"
+ )
end
end
@@ -47,7 +50,8 @@ FactoryBot.define do
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts.zip'), 'application/zip')
+ Rails.root.join("spec/fixtures/ci_build_artifacts.zip"), "application/zip"
+ )
end
end
@@ -63,7 +67,8 @@ FactoryBot.define do
after(:build) do |artifact, _|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/ci_build_artifacts_metadata.gz"), "application/x-gzip"
+ )
end
end
@@ -73,7 +78,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/trace/sample_trace'), 'text/plain')
+ Rails.root.join("spec/fixtures/trace/sample_trace"), "text/plain"
+ )
end
end
@@ -83,7 +89,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/junit/junit.xml.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/junit/junit.xml.gz"), "application/x-gzip"
+ )
end
end
@@ -93,7 +100,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/junit/junit_ant.xml.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/junit/junit_ant.xml.gz"), "application/x-gzip"
+ )
end
end
@@ -103,7 +111,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/junit/junit_with_three_testsuites.xml.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/junit/junit_with_three_testsuites.xml.gz"), "application/x-gzip"
+ )
end
end
@@ -113,7 +122,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/junit/junit_with_corrupted_data.xml.gz'), 'application/x-gzip')
+ Rails.root.join("spec/fixtures/junit/junit_with_corrupted_data.xml.gz"), "application/x-gzip"
+ )
end
end
@@ -123,7 +133,8 @@ FactoryBot.define do
after(:build) do |artifact, evaluator|
artifact.file = fixture_file_upload(
- Rails.root.join('spec/fixtures/codequality/codequality.json'), 'application/json')
+ Rails.root.join("spec/fixtures/codequality/codequality.json"), "application/json"
+ )
end
end
diff --git a/spec/factories/ci/pipeline_schedule.rb b/spec/factories/ci/pipeline_schedule.rb
index b2b79807429..a3efef8a080 100644
--- a/spec/factories/ci/pipeline_schedule.rb
+++ b/spec/factories/ci/pipeline_schedule.rb
@@ -1,24 +1,24 @@
FactoryBot.define do
factory :ci_pipeline_schedule, class: Ci::PipelineSchedule do
- cron '0 1 * * *'
+ cron "0 1 * * *"
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
- ref 'master'
+ ref "master"
active true
description "pipeline schedule"
project
trait :nightly do
- cron '0 1 * * *'
+ cron "0 1 * * *"
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
end
trait :weekly do
- cron '0 1 * * 6'
+ cron "0 1 * * 6"
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
end
trait :monthly do
- cron '0 1 22 * *'
+ cron "0 1 22 * *"
cron_timezone Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE
end
diff --git a/spec/factories/ci/pipeline_schedule_variables.rb b/spec/factories/ci/pipeline_schedule_variables.rb
index 8d29118e310..56766d4e14e 100644
--- a/spec/factories/ci/pipeline_schedule_variables.rb
+++ b/spec/factories/ci/pipeline_schedule_variables.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :ci_pipeline_schedule_variable, class: Ci::PipelineScheduleVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
- value 'VARIABLE_VALUE'
+ value "VARIABLE_VALUE"
pipeline_schedule factory: :ci_pipeline_schedule
end
diff --git a/spec/factories/ci/pipeline_variables.rb b/spec/factories/ci/pipeline_variables.rb
index b18055d7b3a..ef1bfa573b5 100644
--- a/spec/factories/ci/pipeline_variables.rb
+++ b/spec/factories/ci/pipeline_variables.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :ci_pipeline_variable, class: Ci::PipelineVariable do
sequence(:key) { |n| "VARIABLE_#{n}" }
- value 'VARIABLE_VALUE'
+ value "VARIABLE_VALUE"
pipeline factory: :ci_empty_pipeline
end
diff --git a/spec/factories/ci/pipelines.rb b/spec/factories/ci/pipelines.rb
index 8a44ce52849..18a9c232560 100644
--- a/spec/factories/ci/pipelines.rb
+++ b/spec/factories/ci/pipelines.rb
@@ -1,9 +1,9 @@
FactoryBot.define do
factory :ci_empty_pipeline, class: Ci::Pipeline do
source :push
- ref 'master'
- sha '97de212e80737a608d939f648d959671fb0a0142'
- status 'pending'
+ ref "master"
+ sha "97de212e80737a608d939f648d959671fb0a0142"
+ status "pending"
protected false
project
@@ -17,7 +17,7 @@ FactoryBot.define do
factory :ci_pipeline_with_one_job do
after(:build) do |pipeline|
allow(pipeline).to receive(:ci_yaml_file) do
- pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({ rspec: { script: "ls" } }))
+ pipeline.instance_variable_set(:@ci_yaml_file, YAML.dump({rspec: {script: "ls"}}))
end
end
end
@@ -41,7 +41,7 @@ FactoryBot.define do
# Populates pipeline with errors
pipeline.config_processor if evaluator.config
else
- pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
+ pipeline.instance_variable_set(:@ci_yaml_file, File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml")))
end
end
diff --git a/spec/factories/ci/runners.rb b/spec/factories/ci/runners.rb
index 24e70913b87..5378b099b6f 100644
--- a/spec/factories/ci/runners.rb
+++ b/spec/factories/ci/runners.rb
@@ -51,7 +51,7 @@ FactoryBot.define do
trait :tagged_only do
run_untagged false
- tag_list %w(tag1 tag2)
+ tag_list %w[tag1 tag2]
end
trait :locked do
diff --git a/spec/factories/ci/stages.rb b/spec/factories/ci/stages.rb
index ce61e6bf759..32161ce590a 100644
--- a/spec/factories/ci/stages.rb
+++ b/spec/factories/ci/stages.rb
@@ -3,7 +3,7 @@ FactoryBot.define do
skip_create
transient do
- name 'test'
+ name "test"
status nil
warnings nil
pipeline factory: :ci_empty_pipeline
@@ -20,8 +20,8 @@ FactoryBot.define do
project factory: :project
pipeline factory: :ci_empty_pipeline
- name 'test'
+ name "test"
position 1
- status 'pending'
+ status "pending"
end
end
diff --git a/spec/factories/ci/variables.rb b/spec/factories/ci/variables.rb
index 97a7c9ba252..e62ce3b1935 100644
--- a/spec/factories/ci/variables.rb
+++ b/spec/factories/ci/variables.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :ci_variable, class: Ci::Variable do
sequence(:key) { |n| "VARIABLE_#{n}" }
- value 'VARIABLE_VALUE'
+ value "VARIABLE_VALUE"
masked false
trait(:protected) do
diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb
index fe56ac5b71d..1bcd10a6f20 100644
--- a/spec/factories/clusters/applications/helm.rb
+++ b/spec/factories/clusters/applications/helm.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :clusters_applications_helm, class: Clusters::Applications::Helm do
- cluster factory: %i(cluster provided_by_gcp)
+ cluster factory: %i[cluster provided_by_gcp]
trait :not_installable do
status(-2)
@@ -32,12 +32,12 @@ FactoryBot.define do
trait :errored do
status(-1)
- status_reason 'something went wrong'
+ status_reason "something went wrong"
end
trait :update_errored do
status(6)
- status_reason 'something went wrong'
+ status_reason "something went wrong"
end
trait :timeouted do
@@ -46,31 +46,31 @@ FactoryBot.define do
end
factory :clusters_applications_ingress, class: Clusters::Applications::Ingress do
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp]
end
factory :clusters_applications_cert_managers, class: Clusters::Applications::CertManager do
- email 'admin@example.com'
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+ email "admin@example.com"
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp]
end
factory :clusters_applications_prometheus, class: Clusters::Applications::Prometheus do
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp]
end
factory :clusters_applications_runner, class: Clusters::Applications::Runner do
- runner factory: %i(ci_runner)
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+ runner factory: %i[ci_runner]
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp]
end
factory :clusters_applications_knative, class: Clusters::Applications::Knative do
- hostname 'example.com'
- cluster factory: %i(cluster with_installed_helm provided_by_gcp)
+ hostname "example.com"
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp]
end
factory :clusters_applications_jupyter, class: Clusters::Applications::Jupyter do
oauth_application factory: :oauth_application
- cluster factory: %i(cluster with_installed_helm provided_by_gcp project)
+ cluster factory: %i[cluster with_installed_helm provided_by_gcp project]
end
end
end
diff --git a/spec/factories/clusters/clusters.rb b/spec/factories/clusters/clusters.rb
index a2e5f4862db..7cf0535d7ba 100644
--- a/spec/factories/clusters/clusters.rb
+++ b/spec/factories/clusters/clusters.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :cluster, class: Clusters::Cluster do
user
- name 'test-cluster'
+ name "test-cluster"
cluster_type :project_type
trait :instance do
@@ -57,11 +57,11 @@ FactoryBot.define do
end
trait :with_installed_helm do
- application_helm factory: %i(clusters_applications_helm installed)
+ application_helm factory: %i[clusters_applications_helm installed]
end
trait :with_domain do
- domain 'example.com'
+ domain "example.com"
end
end
end
diff --git a/spec/factories/clusters/platforms/kubernetes.rb b/spec/factories/clusters/platforms/kubernetes.rb
index bf30a9c3a61..b7db4807376 100644
--- a/spec/factories/clusters/platforms/kubernetes.rb
+++ b/spec/factories/clusters/platforms/kubernetes.rb
@@ -2,16 +2,16 @@ FactoryBot.define do
factory :cluster_platform_kubernetes, class: Clusters::Platforms::Kubernetes do
cluster
namespace nil
- api_url 'https://kubernetes.example.com'
- token { 'a' * 40 }
+ api_url "https://kubernetes.example.com"
+ token { "a" * 40 }
trait :configured do
- api_url 'https://kubernetes.example.com'
- username 'xxxxxx'
- password 'xxxxxx'
+ api_url "https://kubernetes.example.com"
+ username "xxxxxx"
+ password "xxxxxx"
before(:create) do |platform_kubernetes, evaluator|
- pem_file = File.expand_path(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
+ pem_file = File.expand_path(Rails.root.join("spec/fixtures/clusters/sample_cert.pem"))
platform_kubernetes.ca_cert = File.read(pem_file)
end
end
diff --git a/spec/factories/clusters/providers/gcp.rb b/spec/factories/clusters/providers/gcp.rb
index a002ab28519..fae612249ac 100644
--- a/spec/factories/clusters/providers/gcp.rb
+++ b/spec/factories/clusters/providers/gcp.rb
@@ -1,22 +1,22 @@
FactoryBot.define do
factory :cluster_provider_gcp, class: Clusters::Providers::Gcp do
cluster
- gcp_project_id 'test-gcp-project'
+ gcp_project_id "test-gcp-project"
trait :scheduled do
- access_token 'access_token_123'
+ access_token "access_token_123"
end
trait :creating do
- access_token 'access_token_123'
+ access_token "access_token_123"
after(:build) do |gcp, evaluator|
- gcp.make_creating('operation-123')
+ gcp.make_creating("operation-123")
end
end
trait :created do
- endpoint '111.111.111.111'
+ endpoint "111.111.111.111"
after(:build) do |gcp, evaluator|
gcp.make_created
@@ -25,7 +25,7 @@ FactoryBot.define do
trait :errored do
after(:build) do |gcp, evaluator|
- gcp.make_errored('Something wrong')
+ gcp.make_errored("Something wrong")
end
end
end
diff --git a/spec/factories/commit_statuses.rb b/spec/factories/commit_statuses.rb
index 381bf07f6a0..96cba785931 100644
--- a/spec/factories/commit_statuses.rb
+++ b/spec/factories/commit_statuses.rb
@@ -1,48 +1,48 @@
FactoryBot.define do
factory :commit_status, class: CommitStatus do
- name 'default'
- stage 'test'
+ name "default"
+ stage "test"
stage_idx 0
- status 'success'
- description 'commit status'
+ status "success"
+ description "commit status"
pipeline factory: :ci_pipeline_with_one_job
- started_at 'Tue, 26 Jan 2016 08:21:42 +0100'
- finished_at 'Tue, 26 Jan 2016 08:23:42 +0100'
+ started_at "Tue, 26 Jan 2016 08:21:42 +0100"
+ finished_at "Tue, 26 Jan 2016 08:23:42 +0100"
trait :success do
- status 'success'
+ status "success"
end
trait :failed do
- status 'failed'
+ status "failed"
end
trait :canceled do
- status 'canceled'
+ status "canceled"
end
trait :skipped do
- status 'skipped'
+ status "skipped"
end
trait :running do
- status 'running'
+ status "running"
end
trait :pending do
- status 'pending'
+ status "pending"
end
trait :created do
- status 'created'
+ status "created"
end
trait :manual do
- status 'manual'
+ status "manual"
end
trait :scheduled do
- status 'scheduled'
+ status "scheduled"
end
after(:build) do |build, evaluator|
@@ -50,8 +50,8 @@ FactoryBot.define do
end
factory :generic_commit_status, class: GenericCommitStatus do
- name 'generic'
- description 'external commit status'
+ name "generic"
+ description "external commit status"
end
end
end
diff --git a/spec/factories/commits.rb b/spec/factories/commits.rb
index 2bcc4b6cf52..ea0c0daac9c 100644
--- a/spec/factories/commits.rb
+++ b/spec/factories/commits.rb
@@ -1,4 +1,4 @@
-require_relative '../support/helpers/repo_helpers'
+require_relative "../support/helpers/repo_helpers"
FactoryBot.define do
factory :commit do
diff --git a/spec/factories/container_repositories.rb b/spec/factories/container_repositories.rb
index 00fad7975c9..c81060e9312 100644
--- a/spec/factories/container_repositories.rb
+++ b/spec/factories/container_repositories.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :container_repository do
- name 'test_image'
+ name "test_image"
project
transient do
@@ -8,7 +8,7 @@ FactoryBot.define do
end
trait :root do
- name ''
+ name ""
end
after(:build) do |repository, evaluator|
@@ -17,16 +17,16 @@ FactoryBot.define do
allow(repository.client)
.to receive(:repository_tags)
.and_return({
- 'name' => repository.path,
- 'tags' => evaluator.tags
+ "name" => repository.path,
+ "tags" => evaluator.tags,
})
evaluator.tags.each do |tag|
allow(repository.client)
.to receive(:repository_tag_digest)
.with(repository.path, tag)
- .and_return('sha256:4c8e63ca4cb663ce6c688cb06f1c3' \
- '72b088dac5b6d7ad7d49cd620d85cf72a15')
+ .and_return("sha256:4c8e63ca4cb663ce6c688cb06f1c3" \
+ "72b088dac5b6d7ad7d49cd620d85cf72a15")
end
end
end
diff --git a/spec/factories/deployments.rb b/spec/factories/deployments.rb
index 011c98599a3..e011bbd72f4 100644
--- a/spec/factories/deployments.rb
+++ b/spec/factories/deployments.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :deployment, class: Deployment do
- sha '97de212e80737a608d939f648d959671fb0a0142'
- ref 'master'
+ sha "97de212e80737a608d939f648d959671fb0a0142"
+ ref "master"
tag false
user nil
project nil
@@ -18,8 +18,8 @@ FactoryBot.define do
end
trait :review_app do
- sha { TestEnv::BRANCH_SHA['pages-deploy'] }
- ref 'pages-deploy'
+ sha { TestEnv::BRANCH_SHA["pages-deploy"] }
+ ref "pages-deploy"
end
trait :running do
diff --git a/spec/factories/environments.rb b/spec/factories/environments.rb
index 9d9e3d693b8..74100f0002f 100644
--- a/spec/factories/environments.rb
+++ b/spec/factories/environments.rb
@@ -7,7 +7,7 @@ FactoryBot.define do
trait :with_review_app do |environment|
transient do
- ref 'master'
+ ref "master"
end
# At this point `review app` is an ephemeral concept related to
@@ -22,16 +22,16 @@ FactoryBot.define do
pipeline: pipeline)
deployment = create(:deployment,
- :success,
- environment: environment,
- project: environment.project,
- deployable: deployable,
- ref: evaluator.ref,
- sha: environment.project.commit(evaluator.ref).id)
+ :success,
+ environment: environment,
+ project: environment.project,
+ deployable: deployable,
+ ref: evaluator.ref,
+ sha: environment.project.commit(evaluator.ref).id)
teardown_build = create(:ci_build, :manual,
- name: "#{environment.name}:teardown",
- pipeline: pipeline)
+ name: "#{environment.name}:teardown",
+ pipeline: pipeline)
deployment.update_column(:on_stop, teardown_build.name)
environment.update_attribute(:deployments, [deployment])
@@ -39,8 +39,8 @@ FactoryBot.define do
end
trait :non_playable do
- status 'created'
- self.when 'manual'
+ status "created"
+ self.when "manual"
end
end
end
diff --git a/spec/factories/error_tracking/error.rb b/spec/factories/error_tracking/error.rb
index ff883a3d22c..e9820bd9ab0 100644
--- a/spec/factories/error_tracking/error.rb
+++ b/spec/factories/error_tracking/error.rb
@@ -2,21 +2,21 @@
FactoryBot.define do
factory :error_tracking_error, class: Gitlab::ErrorTracking::Error do
- id 'id'
- title 'title'
- type 'error'
+ id "id"
+ title "title"
+ type "error"
user_count 1
count 2
first_seen { Time.now }
last_seen { Time.now }
- message 'message'
- culprit 'culprit'
- external_url 'http://example.com/id'
- project_id 'project1'
- project_name 'project name'
- project_slug 'project_name'
- short_id 'ID'
- status 'unresolved'
+ message "message"
+ culprit "culprit"
+ external_url "http://example.com/id"
+ project_id "project1"
+ project_name "project name"
+ project_slug "project_name"
+ short_id "ID"
+ status "unresolved"
frequency []
skip_create
diff --git a/spec/factories/error_tracking/project.rb b/spec/factories/error_tracking/project.rb
index 5e9219b241f..2faa2307427 100644
--- a/spec/factories/error_tracking/project.rb
+++ b/spec/factories/error_tracking/project.rb
@@ -2,13 +2,13 @@
FactoryBot.define do
factory :error_tracking_project, class: Gitlab::ErrorTracking::Project do
- id '1'
- name 'Sentry Example'
- slug 'sentry-example'
- status 'active'
- organization_name 'Sentry'
- organization_id '1'
- organization_slug 'sentry'
+ id "1"
+ name "Sentry Example"
+ slug "sentry-example"
+ status "active"
+ organization_name "Sentry"
+ organization_id "1"
+ organization_slug "sentry"
skip_create
end
diff --git a/spec/factories/events.rb b/spec/factories/events.rb
index bf8411b1894..ff898bc38f1 100644
--- a/spec/factories/events.rb
+++ b/spec/factories/events.rb
@@ -33,7 +33,7 @@ FactoryBot.define do
commit_count 1
action :pushed
ref_type :branch
- ref 'master'
- commit_to '3cdce97ed87c91368561584e7358f4d46e3e173c'
+ ref "master"
+ commit_to "3cdce97ed87c91368561584e7358f4d46e3e173c"
end
end
diff --git a/spec/factories/file_uploaders.rb b/spec/factories/file_uploaders.rb
index 8404985bfea..92218f661f2 100644
--- a/spec/factories/file_uploaders.rb
+++ b/spec/factories/file_uploaders.rb
@@ -6,8 +6,8 @@ FactoryBot.define do
secret nil
transient do
- fixture { 'rails_sample.jpg' }
- path { File.join(Rails.root, 'spec/fixtures', fixture) }
+ fixture { "rails_sample.jpg" }
+ path { File.join(Rails.root, "spec/fixtures", fixture) }
file { Rack::Test::UploadedFile.new(path) }
end
diff --git a/spec/factories/gitaly/tag.rb b/spec/factories/gitaly/tag.rb
index e99776d524a..ed5bdf4e42e 100644
--- a/spec/factories/gitaly/tag.rb
+++ b/spec/factories/gitaly/tag.rb
@@ -2,8 +2,8 @@ FactoryBot.define do
factory :gitaly_tag, class: Gitaly::Tag do
skip_create
- name { 'v3.1.4' }
- message { 'Pie release' }
+ name { "v3.1.4" }
+ message { "Pie release" }
target_commit factory: :gitaly_commit
end
end
diff --git a/spec/factories/gpg_keys.rb b/spec/factories/gpg_keys.rb
index 3c0f43cc1b6..aa52f873fa7 100644
--- a/spec/factories/gpg_keys.rb
+++ b/spec/factories/gpg_keys.rb
@@ -1,4 +1,4 @@
-require_relative '../support/helpers/gpg_helpers'
+require_relative "../support/helpers/gpg_helpers"
FactoryBot.define do
factory :gpg_key do
diff --git a/spec/factories/group_members.rb b/spec/factories/group_members.rb
index 077c6ddc5ae..1d0228c36b4 100644
--- a/spec/factories/group_members.rb
+++ b/spec/factories/group_members.rb
@@ -13,8 +13,8 @@ FactoryBot.define do
trait(:invited) do
user_id nil
- invite_token 'xxx'
- invite_email 'email@email.com'
+ invite_token "xxx"
+ invite_email "email@email.com"
end
end
end
diff --git a/spec/factories/groups.rb b/spec/factories/groups.rb
index 3b354c0d96b..967358af6a6 100644
--- a/spec/factories/groups.rb
+++ b/spec/factories/groups.rb
@@ -1,8 +1,8 @@
FactoryBot.define do
factory :group, class: Group, parent: :namespace do
sequence(:name) { |n| "group#{n}" }
- path { name.downcase.gsub(/\s/, '_') }
- type 'Group'
+ path { name.downcase.gsub(/\s/, "_") }
+ type "Group"
owner nil
after(:create) do |group|
@@ -26,7 +26,7 @@ FactoryBot.define do
end
trait :with_avatar do
- avatar { fixture_file_upload('spec/fixtures/dk.png') }
+ avatar { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :access_requestable do
diff --git a/spec/factories/identities.rb b/spec/factories/identities.rb
index 122d0d42938..81f502889cb 100644
--- a/spec/factories/identities.rb
+++ b/spec/factories/identities.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :identity do
- provider 'ldapmain'
- extern_uid 'my-ldap-id'
+ provider "ldapmain"
+ extern_uid "my-ldap-id"
end
end
diff --git a/spec/factories/keys.rb b/spec/factories/keys.rb
index 3f0c60f32b7..dc98f71a704 100644
--- a/spec/factories/keys.rb
+++ b/spec/factories/keys.rb
@@ -1,22 +1,22 @@
-require_relative '../support/helpers/key_generator_helper'
+require_relative "../support/helpers/key_generator_helper"
FactoryBot.define do
factory :key do
title
- key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com' }
+ key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + " dummy@gitlab.com" }
factory :key_without_comment do
key { Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate }
end
- factory :deploy_key, class: 'DeployKey'
+ factory :deploy_key, class: "DeployKey"
factory :personal_key do
user
end
factory :another_key do
- factory :another_deploy_key, class: 'DeployKey'
+ factory :another_deploy_key, class: "DeployKey"
end
factory :rsa_key_2048 do
@@ -31,7 +31,7 @@ FactoryBot.define do
KEY
end
- factory :rsa_deploy_key_2048, class: 'DeployKey'
+ factory :rsa_deploy_key_2048, class: "DeployKey"
end
factory :rsa_key_4096 do
diff --git a/spec/factories/lfs_file_locks.rb b/spec/factories/lfs_file_locks.rb
index b9d24f82b65..e4e97344ad1 100644
--- a/spec/factories/lfs_file_locks.rb
+++ b/spec/factories/lfs_file_locks.rb
@@ -2,6 +2,6 @@ FactoryBot.define do
factory :lfs_file_lock do
user
project
- path 'README.md'
+ path "README.md"
end
end
diff --git a/spec/factories/lfs_objects.rb b/spec/factories/lfs_objects.rb
index c909471bb55..9f0aae022f5 100644
--- a/spec/factories/lfs_objects.rb
+++ b/spec/factories/lfs_objects.rb
@@ -13,7 +13,7 @@ FactoryBot.define do
# The uniqueness constraint means we can't use the correct OID for all LFS
# objects, so the test needs to decide which (if any) object gets it
trait :correct_oid do
- oid 'b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75'
+ oid "b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75"
end
trait :object_storage do
diff --git a/spec/factories/merge_request_diff_files.rb b/spec/factories/merge_request_diff_files.rb
index 469a7a0ac8d..e00044fda52 100644
--- a/spec/factories/merge_request_diff_files.rb
+++ b/spec/factories/merge_request_diff_files.rb
@@ -11,9 +11,9 @@ FactoryBot.define do
too_large false
a_mode 0
b_mode 100644
- new_path 'foo'
- old_path 'foo'
- diff ''
+ new_path "foo"
+ old_path "foo"
+ diff ""
binary false
trait :new_file do
@@ -24,9 +24,9 @@ FactoryBot.define do
too_large false
a_mode 0
b_mode 100644
- new_path 'foo'
- old_path 'foo'
- diff ''
+ new_path "foo"
+ old_path "foo"
+ diff ""
binary false
end
@@ -38,9 +38,9 @@ FactoryBot.define do
too_large false
a_mode 100644
b_mode 100644
- new_path 'bar'
- old_path 'baz'
- diff ''
+ new_path "bar"
+ old_path "baz"
+ diff ""
binary false
end
end
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index 2392bfc4a53..c8f67324b20 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -85,7 +85,7 @@ FactoryBot.define do
trait :remove_source_branch do
merge_params do
- { 'force_remove_source_branch' => '1' }
+ {"force_remove_source_branch" => "1"}
end
end
@@ -97,12 +97,13 @@ FactoryBot.define do
:with_test_reports,
project: merge_request.source_project,
ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha)
+ sha: merge_request.diff_head_sha
+ )
end
end
trait :deployed_review_app do
- target_branch 'pages-deploy-target'
+ target_branch "pages-deploy-target"
transient do
deployment { create(:deployment, :review_app) }
diff --git a/spec/factories/namespaces.rb b/spec/factories/namespaces.rb
index 6feafa5ece9..6450d99880a 100644
--- a/spec/factories/namespaces.rb
+++ b/spec/factories/namespaces.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :namespace do
sequence(:name) { |n| "namespace#{n}" }
- path { name.downcase.gsub(/\s/, '_') }
+ path { name.downcase.gsub(/\s/, "_") }
# This is a workaround to avoid the user creating another namespace via
# User#ensure_namespace_correct. We should try to remove it and then
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index c51f2f958f9..4cb26a854f1 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -1,4 +1,4 @@
-require_relative '../support/helpers/repo_helpers'
+require_relative "../support/helpers/repo_helpers"
include ActionDispatch::TestProcess
@@ -39,7 +39,7 @@ FactoryBot.define do
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do
association :project, :repository
- position ''
+ position ""
end
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
@@ -103,7 +103,7 @@ FactoryBot.define do
trait :on_commit do
association :project, :repository
noteable nil
- noteable_type 'Commit'
+ noteable_type "Commit"
noteable_id nil
commit_id { RepoHelpers.sample_commit.id }
end
diff --git a/spec/factories/oauth_applications.rb b/spec/factories/oauth_applications.rb
index 4427da1d6c7..8551cef0648 100644
--- a/spec/factories/oauth_applications.rb
+++ b/spec/factories/oauth_applications.rb
@@ -1,9 +1,9 @@
FactoryBot.define do
- factory :oauth_application, class: 'Doorkeeper::Application', aliases: [:application] do
+ factory :oauth_application, class: "Doorkeeper::Application", aliases: [:application] do
sequence(:name) { |n| "OAuth App #{n}" }
uid { Doorkeeper::OAuth::Helpers::UniqueToken.generate }
redirect_uri { generate(:url) }
owner
- owner_type 'User'
+ owner_type "User"
end
end
diff --git a/spec/factories/pages_domains.rb b/spec/factories/pages_domains.rb
index 20671da016e..aac1d21e407 100644
--- a/spec/factories/pages_domains.rb
+++ b/spec/factories/pages_domains.rb
@@ -1,5 +1,5 @@
FactoryBot.define do
- factory :pages_domain, class: 'PagesDomain' do
+ factory :pages_domain, class: "PagesDomain" do
sequence(:domain) { |n| "my#{n}.domain.com" }
verified_at { Time.now }
enabled_until { 1.week.from_now }
diff --git a/spec/factories/personal_access_tokens.rb b/spec/factories/personal_access_tokens.rb
index e7fd22a96b2..3308281180e 100644
--- a/spec/factories/personal_access_tokens.rb
+++ b/spec/factories/personal_access_tokens.rb
@@ -4,7 +4,7 @@ FactoryBot.define do
sequence(:name) { |n| "PAT #{n}" }
revoked false
expires_at { 5.days.from_now }
- scopes ['api']
+ scopes ["api"]
impersonation false
after(:build) { |personal_access_token| personal_access_token.ensure_token }
diff --git a/spec/factories/programming_languages.rb b/spec/factories/programming_languages.rb
index d3511d42b6c..5c722502585 100644
--- a/spec/factories/programming_languages.rb
+++ b/spec/factories/programming_languages.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :programming_language do
- name 'Ruby'
- color '#123456'
+ name "Ruby"
+ color "#123456"
end
end
diff --git a/spec/factories/project_error_tracking_settings.rb b/spec/factories/project_error_tracking_settings.rb
index be30bd0260a..5d70d53e511 100644
--- a/spec/factories/project_error_tracking_settings.rb
+++ b/spec/factories/project_error_tracking_settings.rb
@@ -3,10 +3,10 @@
FactoryBot.define do
factory :project_error_tracking_setting, class: ErrorTracking::ProjectErrorTrackingSetting do
project
- api_url 'https://gitlab.com/api/0/projects/sentry-org/sentry-project'
+ api_url "https://gitlab.com/api/0/projects/sentry-org/sentry-project"
enabled true
- token 'access_token_123'
- project_name 'Sentry Project'
- organization_name 'Sentry Org'
+ token "access_token_123"
+ project_name "Sentry Project"
+ organization_name "Sentry Org"
end
end
diff --git a/spec/factories/project_members.rb b/spec/factories/project_members.rb
index c72e0487895..1dff25516b2 100644
--- a/spec/factories/project_members.rb
+++ b/spec/factories/project_members.rb
@@ -12,8 +12,8 @@ FactoryBot.define do
trait(:invited) do
user_id nil
- invite_token 'xxx'
- invite_email 'email@email.com'
+ invite_token "xxx"
+ invite_email "email@email.com"
end
end
end
diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb
index 30d3b22d868..fd892166298 100644
--- a/spec/factories/projects.rb
+++ b/spec/factories/projects.rb
@@ -1,4 +1,4 @@
-require_relative '../support/helpers/test_env'
+require_relative "../support/helpers/test_env"
FactoryBot.define do
PAGES_ACCESS_LEVEL_SCHEMA_VERSION ||= 20180423204600
@@ -7,9 +7,9 @@ FactoryBot.define do
#
# Project does not have bare repository.
# Use this factory if you don't need repository in tests
- factory :project, class: 'Project' do
+ factory :project, class: "Project" do
sequence(:name) { |n| "project#{n}" }
- path { name.downcase.gsub(/\s/, '_') }
+ path { name.downcase.gsub(/\s/, "_") }
# Behaves differently to nil due to cache_has_external_issue_tracker
has_external_issue_tracker false
@@ -45,7 +45,7 @@ FactoryBot.define do
snippets_access_level: evaluator.snippets_access_level,
issues_access_level: evaluator.issues_access_level,
merge_requests_access_level: merge_requests_access_level,
- repository_access_level: evaluator.repository_access_level
+ repository_access_level: evaluator.repository_access_level,
}
if ActiveRecord::Migrator.current_version >= PAGES_ACCESS_LEVEL_SCHEMA_VERSION
@@ -118,7 +118,7 @@ FactoryBot.define do
end
trait :with_avatar do
- avatar { fixture_file_upload('spec/fixtures/dk.png') }
+ avatar { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :with_export do
@@ -129,7 +129,7 @@ FactoryBot.define do
trait :broken_storage do
after(:create) do |project|
- project.update_column(:repository_storage, 'broken')
+ project.update_column(:repository_storage, "broken")
end
end
@@ -154,7 +154,7 @@ FactoryBot.define do
filename,
content,
message: "Automatically created file #{filename}",
- branch_name: 'master'
+ branch_name: "master"
)
end
end
@@ -175,21 +175,24 @@ FactoryBot.define do
project.repository.create_file(
project.creator,
".gitlab/#{templates_path}/bug.md",
- 'something valid',
- message: 'test 3',
- branch_name: 'master')
+ "something valid",
+ message: "test 3",
+ branch_name: "master"
+ )
project.repository.create_file(
project.creator,
".gitlab/#{templates_path}/template_test.md",
- 'template_test',
- message: 'test 1',
- branch_name: 'master')
+ "template_test",
+ message: "test 1",
+ branch_name: "master"
+ )
project.repository.create_file(
project.creator,
".gitlab/#{templates_path}/feature_proposal.md",
- 'feature_proposal',
- message: 'test 2',
- branch_name: 'master')
+ "feature_proposal",
+ message: "test 2",
+ branch_name: "master"
+ )
end
end
end
@@ -220,7 +223,7 @@ FactoryBot.define do
trait :wiki_repo do
after(:create) do |project|
- raise 'Failed to create wiki repository!' unless project.create_wiki
+ raise "Failed to create wiki repository!" unless project.create_wiki
end
end
@@ -233,7 +236,7 @@ FactoryBot.define do
raise "Failed to create repository!" unless project.create_repository
project.gitlab_shell.rm_directory(project.repository_storage,
- File.join("#{project.disk_path}.git", 'refs'))
+ File.join("#{project.disk_path}.git", "refs"))
end
end
@@ -289,7 +292,7 @@ FactoryBot.define do
end
factory :forked_project_with_submodules, parent: :project do
- path { 'forked-gitlabhq' }
+ path { "forked-gitlabhq" }
after :create do |project|
TestEnv.copy_repo(project,
@@ -305,9 +308,9 @@ FactoryBot.define do
project.create_redmine_service(
active: true,
properties: {
- 'project_url' => 'http://redmine/projects/project_name_in_redmine',
- 'issues_url' => 'http://redmine/projects/project_name_in_redmine/issues/:id',
- 'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new'
+ "project_url" => "http://redmine/projects/project_name_in_redmine",
+ "issues_url" => "http://redmine/projects/project_name_in_redmine/issues/:id",
+ "new_issue_url" => "http://redmine/projects/project_name_in_redmine/issues/new",
}
)
end
@@ -320,8 +323,8 @@ FactoryBot.define do
project.create_youtrack_service(
active: true,
properties: {
- 'project_url' => 'http://youtrack/projects/project_guid_in_youtrack',
- 'issues_url' => 'http://youtrack/issues/:id'
+ "project_url" => "http://youtrack/projects/project_guid_in_youtrack",
+ "issues_url" => "http://youtrack/issues/:id",
}
)
end
@@ -345,8 +348,8 @@ FactoryBot.define do
project.create_prometheus_service(
active: true,
properties: {
- api_url: 'https://prometheus.example.com/',
- manual_configuration: true
+ api_url: "https://prometheus.example.com/",
+ manual_configuration: true,
}
)
end
diff --git a/spec/factories/prometheus_metrics.rb b/spec/factories/prometheus_metrics.rb
index c56644bfb96..c52187b7751 100644
--- a/spec/factories/prometheus_metrics.rb
+++ b/spec/factories/prometheus_metrics.rb
@@ -2,13 +2,13 @@
FactoryBot.define do
factory :prometheus_metric, class: PrometheusMetric do
- title 'title'
- query 'avg(metric)'
- y_label 'y_label'
- unit 'm/s'
+ title "title"
+ query "avg(metric)"
+ y_label "y_label"
+ unit "m/s"
group :business
project
- legend 'legend'
+ legend "legend"
trait :common do
common true
diff --git a/spec/factories/releases.rb b/spec/factories/releases.rb
index cab6b4a811f..191cab02aa5 100644
--- a/spec/factories/releases.rb
+++ b/spec/factories/releases.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :release do
tag "v1.1.0"
- sha 'b83d6e391c22777fca1ed3012fce84f633d7fed0'
+ sha "b83d6e391c22777fca1ed3012fce84f633d7fed0"
name { tag }
description "Awesome release"
project
diff --git a/spec/factories/remote_mirrors.rb b/spec/factories/remote_mirrors.rb
index adc7da27522..ecc58b1c2b2 100644
--- a/spec/factories/remote_mirrors.rb
+++ b/spec/factories/remote_mirrors.rb
@@ -1,5 +1,5 @@
FactoryBot.define do
- factory :remote_mirror, class: 'RemoteMirror' do
+ factory :remote_mirror, class: "RemoteMirror" do
association :project, :repository
url "http://foo:bar@test.com"
end
diff --git a/spec/factories/services.rb b/spec/factories/services.rb
index 70c34f8640b..e41634e2d0d 100644
--- a/spec/factories/services.rb
+++ b/spec/factories/services.rb
@@ -1,34 +1,34 @@
FactoryBot.define do
factory :service do
project
- type 'Service'
+ type "Service"
end
factory :custom_issue_tracker_service, class: CustomIssueTrackerService do
project
- type 'CustomIssueTrackerService'
- category 'issue_tracker'
+ type "CustomIssueTrackerService"
+ category "issue_tracker"
active true
properties(
- project_url: 'https://project.url.com',
- issues_url: 'https://issues.url.com',
- new_issue_url: 'https://newissue.url.com'
+ project_url: "https://project.url.com",
+ issues_url: "https://issues.url.com",
+ new_issue_url: "https://newissue.url.com"
)
end
factory :kubernetes_service do
project
- type 'KubernetesService'
+ type "KubernetesService"
active true
properties({
- api_url: 'https://kubernetes.example.com',
- token: 'a' * 40
+ api_url: "https://kubernetes.example.com",
+ token: "a" * 40,
})
end
factory :mock_deployment_service do
project
- type 'MockDeploymentService'
+ type "MockDeploymentService"
active true
end
@@ -36,8 +36,8 @@ FactoryBot.define do
project
active true
properties({
- api_url: 'https://prometheus.example.com/',
- manual_configuration: true
+ api_url: "https://prometheus.example.com/",
+ manual_configuration: true,
})
end
@@ -45,10 +45,10 @@ FactoryBot.define do
project
active true
properties(
- url: 'https://jira.example.com',
- username: 'jira_user',
- password: 'my-secret-password',
- project_key: 'jira-key'
+ url: "https://jira.example.com",
+ username: "jira_user",
+ password: "my-secret-password",
+ project_key: "jira-key"
)
end
@@ -56,10 +56,10 @@ FactoryBot.define do
project
active true
properties(
- url: 'https://mysite.atlassian.net',
- username: 'jira_user',
- password: 'my-secret-password',
- project_key: 'jira-key'
+ url: "https://mysite.atlassian.net",
+ username: "jira_user",
+ password: "my-secret-password",
+ project_key: "jira-key"
)
end
end
diff --git a/spec/factories/spam_logs.rb b/spec/factories/spam_logs.rb
index a467f850a80..461b9bbb294 100644
--- a/spec/factories/spam_logs.rb
+++ b/spec/factories/spam_logs.rb
@@ -2,7 +2,7 @@ FactoryBot.define do
factory :spam_log do
user
sequence(:source_ip) { |n| "42.42.42.#{n % 255}" }
- noteable_type 'Issue'
+ noteable_type "Issue"
sequence(:title) { |n| "Spam title #{n}" }
description { "Spam description\nwith\nmultiple\nlines" }
end
diff --git a/spec/factories/system_note_metadata.rb b/spec/factories/system_note_metadata.rb
index e913068da40..3eddf5231ec 100644
--- a/spec/factories/system_note_metadata.rb
+++ b/spec/factories/system_note_metadata.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
factory :system_note_metadata do
note
- action 'merge'
+ action "merge"
end
end
diff --git a/spec/factories/trending_project.rb b/spec/factories/trending_project.rb
index f7c634fd21f..c4f016588be 100644
--- a/spec/factories/trending_project.rb
+++ b/spec/factories/trending_project.rb
@@ -1,6 +1,6 @@
FactoryBot.define do
# TrendingProject
- factory :trending_project, class: 'TrendingProject' do
+ factory :trending_project, class: "TrendingProject" do
project
end
end
diff --git a/spec/factories/uploads.rb b/spec/factories/uploads.rb
index 7256f785e1f..8ea244079ce 100644
--- a/spec/factories/uploads.rb
+++ b/spec/factories/uploads.rb
@@ -9,11 +9,11 @@ FactoryBot.define do
# we should build a mount agnostic upload by default
transient do
- filename 'myfile.jpg'
+ filename "myfile.jpg"
end
# this needs to comply with RecordsUpload::Concern#upload_path
- path { File.join("uploads/-/system", model.class.to_s.underscore, mount_point.to_s, 'avatar.jpg') }
+ path { File.join("uploads/-/system", model.class.to_s.underscore, mount_point.to_s, "avatar.jpg") }
trait :personal_snippet_upload do
uploader "PersonalFileUploader"
diff --git a/spec/factories/user_agent_details.rb b/spec/factories/user_agent_details.rb
index 7183a8e1140..88409e04743 100644
--- a/spec/factories/user_agent_details.rb
+++ b/spec/factories/user_agent_details.rb
@@ -1,7 +1,7 @@
FactoryBot.define do
factory :user_agent_detail do
- ip_address '127.0.0.1'
- user_agent 'AppleWebKit/537.36'
+ ip_address "127.0.0.1"
+ user_agent "AppleWebKit/537.36"
association :subject, factory: :issue
end
end
diff --git a/spec/factories/user_statuses.rb b/spec/factories/user_statuses.rb
index 9998ae9609c..a4f4f3a033e 100644
--- a/spec/factories/user_statuses.rb
+++ b/spec/factories/user_statuses.rb
@@ -3,7 +3,7 @@
FactoryBot.define do
factory :user_status do
user
- emoji 'coffee'
- message 'I crave coffee'
+ emoji "coffee"
+ message "I crave coffee"
end
end
diff --git a/spec/factories/users.rb b/spec/factories/users.rb
index 1d2b724a5e5..288a5fdb2a9 100644
--- a/spec/factories/users.rb
+++ b/spec/factories/users.rb
@@ -34,7 +34,7 @@ FactoryBot.define do
end
trait :with_avatar do
- avatar { fixture_file_upload('spec/fixtures/dk.png') }
+ avatar { fixture_file_upload("spec/fixtures/dk.png") }
end
trait :two_factor_via_otp do
@@ -68,14 +68,14 @@ FactoryBot.define do
factory :omniauth_user do
transient do
- extern_uid '123456'
- provider 'ldapmain'
+ extern_uid "123456"
+ provider "ldapmain"
end
after(:create) do |user, evaluator|
identity_attrs = {
provider: evaluator.provider,
- extern_uid: evaluator.extern_uid
+ extern_uid: evaluator.extern_uid,
}
if evaluator.respond_to?(:saml_provider)
diff --git a/spec/factories/web_hook_log.rb b/spec/factories/web_hook_log.rb
index 17837260a4b..d29a11d31b4 100644
--- a/spec/factories/web_hook_log.rb
+++ b/spec/factories/web_hook_log.rb
@@ -1,13 +1,13 @@
FactoryBot.define do
factory :web_hook_log do
web_hook factory: :project_hook
- trigger 'push_hooks'
+ trigger "push_hooks"
url { generate(:url) }
request_headers {}
request_data {}
response_headers {}
- response_body ''
- response_status '200'
+ response_body ""
+ response_status "200"
execution_duration 2.0
internal_error_message nil
end
diff --git a/spec/factories/wiki_directories.rb b/spec/factories/wiki_directories.rb
index b105c82b19d..95a6e68af37 100644
--- a/spec/factories/wiki_directories.rb
+++ b/spec/factories/wiki_directories.rb
@@ -2,7 +2,7 @@ FactoryBot.define do
factory :wiki_directory do
skip_create
- slug '/path_up_to/dir'
+ slug "/path_up_to/dir"
initialize_with { new(slug) }
end
end
diff --git a/spec/factories/wiki_pages.rb b/spec/factories/wiki_pages.rb
index ae257d769e8..9cd2554acc1 100644
--- a/spec/factories/wiki_pages.rb
+++ b/spec/factories/wiki_pages.rb
@@ -1,18 +1,18 @@
-require 'ostruct'
+require "ostruct"
FactoryBot.define do
factory :wiki_page do
transient do
attrs do
{
- title: 'Title.with.dot',
- content: 'Content for wiki page',
- format: 'markdown'
+ title: "Title.with.dot",
+ content: "Content for wiki page",
+ format: "markdown",
}
end
end
- page { OpenStruct.new(url_path: 'some-name') }
+ page { OpenStruct.new(url_path: "some-name") }
association :wiki, factory: :project_wiki, strategy: :build
initialize_with { new(wiki, page, true) }
diff --git a/spec/factories_spec.rb b/spec/factories_spec.rb
index 66b71d0f556..12d333a000c 100644
--- a/spec/factories_spec.rb
+++ b/spec/factories_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'factories' do
+describe "factories" do
FactoryBot.factories.each do |factory|
describe "#{factory.name} factory" do
- it 'does not raise error when built' do
+ it "does not raise error when built" do
expect { build(factory.name) }.not_to raise_error
end
- it 'does not raise error when created' do
+ it "does not raise error when created" do
expect { create(factory.name) }.not_to raise_error
end
factory.definition.defined_traits.map(&:name).each do |trait_name|
describe "linting #{trait_name} trait" do
- skip 'does not raise error when created' do
+ skip "does not raise error when created" do
expect { create(factory.name, trait_name) }.not_to raise_error
end
end
diff --git a/spec/fast_spec_helper.rb b/spec/fast_spec_helper.rb
index 0b5ab16ad71..8712a33af99 100644
--- a/spec/fast_spec_helper.rb
+++ b/spec/fast_spec_helper.rb
@@ -1,12 +1,12 @@
-require 'bundler/setup'
+require "bundler/setup"
-ENV['GITLAB_ENV'] = 'test'
-ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true'
+ENV["GITLAB_ENV"] = "test"
+ENV["IN_MEMORY_APPLICATION_SETTINGS"] = "true"
-require_relative '../config/settings'
-require_relative 'support/rspec'
-require 'active_support/all'
+require_relative "../config/settings"
+require_relative "support/rspec"
+require "active_support/all"
-ActiveSupport::Dependencies.autoload_paths << 'lib'
-ActiveSupport::Dependencies.autoload_paths << 'ee/lib'
-ActiveSupport::XmlMini.backend = 'Nokogiri'
+ActiveSupport::Dependencies.autoload_paths << "lib"
+ActiveSupport::Dependencies.autoload_paths << "ee/lib"
+ActiveSupport::XmlMini.backend = "Nokogiri"
diff --git a/spec/features/abuse_report_spec.rb b/spec/features/abuse_report_spec.rb
index eb12eebe8e6..c4c6de43b33 100644
--- a/spec/features/abuse_report_spec.rb
+++ b/spec/features/abuse_report_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Abuse reports' do
+describe "Abuse reports" do
let(:another_user) { create(:user) }
before do
sign_in(create(:user))
end
- it 'Report abuse' do
+ it "Report abuse" do
visit user_path(another_user)
- click_link 'Report abuse'
+ click_link "Report abuse"
- fill_in 'abuse_report_message', with: 'This user sends spam'
- click_button 'Send report'
+ fill_in "abuse_report_message", with: "This user sends spam"
+ click_button "Send report"
- expect(page).to have_content 'Thank you for your report'
+ expect(page).to have_content "Thank you for your report"
visit user_path(another_user)
diff --git a/spec/features/admin/admin_abuse_reports_spec.rb b/spec/features/admin/admin_abuse_reports_spec.rb
index 3ff1a66b0b2..66bb8b984b1 100644
--- a/spec/features/admin/admin_abuse_reports_spec.rb
+++ b/spec/features/admin/admin_abuse_reports_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin::AbuseReports", :js do
let(:user) { create(:user) }
- context 'as an admin' do
+ context "as an admin" do
before do
sign_in(create(:admin))
end
- describe 'if a user has been reported for abuse' do
+ describe "if a user has been reported for abuse" do
let!(:abuse_report) { create(:abuse_report, user: user) }
- describe 'in the abuse report view' do
- it 'presents information about abuse report' do
+ describe "in the abuse report view" do
+ it "presents information about abuse report" do
visit admin_abuse_reports_path
- expect(page).to have_content('Abuse Reports')
+ expect(page).to have_content("Abuse Reports")
expect(page).to have_content(abuse_report.message)
expect(page).to have_link(user.name, href: user_path(user))
- expect(page).to have_link('Remove user')
+ expect(page).to have_link("Remove user")
end
end
- describe 'in the profile page of the user' do
- it 'shows a link to the admin view of the user' do
+ describe "in the profile page 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)
+ expect(page).to have_link "", href: admin_user_path(user)
end
end
end
- describe 'if a many users have been reported for abuse' do
+ describe "if a many users have been reported for abuse" do
let(:report_count) { AbuseReport.default_per_page + 3 }
before do
@@ -40,12 +40,12 @@ describe "Admin::AbuseReports", :js do
end
end
- describe 'in the abuse report view' do
- it 'presents information about abuse report' do
+ describe "in the abuse report view" do
+ it "presents information about abuse report" do
visit admin_abuse_reports_path
- expect(page).to have_selector('.pagination')
- expect(page).to have_selector('.pagination .js-pagination-page', count: (report_count.to_f / AbuseReport.default_per_page).ceil)
+ expect(page).to have_selector(".pagination")
+ expect(page).to have_selector(".pagination .js-pagination-page", count: (report_count.to_f / AbuseReport.default_per_page).ceil)
end
end
end
diff --git a/spec/features/admin/admin_appearance_spec.rb b/spec/features/admin/admin_appearance_spec.rb
index 83cd686818c..2bc53e73519 100644
--- a/spec/features/admin/admin_appearance_spec.rb
+++ b/spec/features/admin/admin_appearance_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin Appearance' do
+describe "Admin Appearance" do
let!(:appearance) { create(:appearance) }
- it 'Create new appearance' do
+ it "Create new appearance" do
sign_in(create(:admin))
visit admin_appearances_path
- fill_in 'appearance_title', with: 'MyCompany'
- fill_in 'appearance_description', with: 'dev server'
- fill_in 'appearance_new_project_guidelines', with: 'Custom project guidelines'
- click_button 'Update appearance settings'
+ fill_in "appearance_title", with: "MyCompany"
+ fill_in "appearance_description", with: "dev server"
+ fill_in "appearance_new_project_guidelines", with: "Custom project guidelines"
+ click_button "Update appearance settings"
expect(current_path).to eq admin_appearances_path
- expect(page).to have_content 'Appearance'
+ expect(page).to have_content "Appearance"
- expect(page).to have_field('appearance_title', with: 'MyCompany')
- expect(page).to have_field('appearance_description', with: 'dev server')
- expect(page).to have_field('appearance_new_project_guidelines', with: 'Custom project guidelines')
- expect(page).to have_content 'Last edit'
+ expect(page).to have_field("appearance_title", with: "MyCompany")
+ expect(page).to have_field("appearance_description", with: "dev server")
+ expect(page).to have_field("appearance_new_project_guidelines", with: "Custom project guidelines")
+ expect(page).to have_content "Last edit"
end
- it 'Preview sign-in page appearance' do
+ it "Preview sign-in page appearance" do
sign_in(create(:admin))
visit admin_appearances_path
@@ -30,7 +30,7 @@ describe 'Admin Appearance' do
expect_custom_sign_in_appearance(appearance)
end
- it 'Preview new project page appearance' do
+ it "Preview new project page appearance" do
sign_in(create(:admin))
visit admin_appearances_path
@@ -39,91 +39,91 @@ describe 'Admin Appearance' do
expect_custom_new_project_appearance(appearance)
end
- context 'Custom system header and footer' do
+ context "Custom system header and footer" do
before do
sign_in(create(:admin))
end
- context 'when system header and footer messages are empty' do
- it 'shows custom system header and footer fields' do
+ context "when system header and footer messages are empty" do
+ it "shows custom system header and footer fields" do
visit admin_appearances_path
- expect(page).to have_field('appearance_header_message', with: '')
- expect(page).to have_field('appearance_footer_message', with: '')
- expect(page).to have_field('appearance_message_background_color')
- expect(page).to have_field('appearance_message_font_color')
+ expect(page).to have_field("appearance_header_message", with: "")
+ expect(page).to have_field("appearance_footer_message", with: "")
+ expect(page).to have_field("appearance_message_background_color")
+ expect(page).to have_field("appearance_message_font_color")
end
end
- context 'when system header and footer messages are not empty' do
+ context "when system header and footer messages are not empty" do
before do
- appearance.update(header_message: 'Foo', footer_message: 'Bar')
+ appearance.update(header_message: "Foo", footer_message: "Bar")
end
- it 'shows custom system header and footer fields' do
+ it "shows custom system header and footer fields" do
visit admin_appearances_path
- expect(page).to have_field('appearance_header_message', with: appearance.header_message)
- expect(page).to have_field('appearance_footer_message', with: appearance.footer_message)
- expect(page).to have_field('appearance_message_background_color')
- expect(page).to have_field('appearance_message_font_color')
+ expect(page).to have_field("appearance_header_message", with: appearance.header_message)
+ expect(page).to have_field("appearance_footer_message", with: appearance.footer_message)
+ expect(page).to have_field("appearance_message_background_color")
+ expect(page).to have_field("appearance_message_font_color")
end
end
end
- it 'Custom sign-in page' do
+ it "Custom sign-in page" do
visit new_user_session_path
expect_custom_sign_in_appearance(appearance)
end
- it 'Custom new project page' do
+ it "Custom new project page" do
sign_in create(:user)
visit new_project_path
expect_custom_new_project_appearance(appearance)
end
- it 'Appearance logo' do
+ it "Appearance logo" do
sign_in(create(:admin))
visit admin_appearances_path
attach_file(:appearance_logo, logo_fixture)
- click_button 'Update appearance settings'
+ click_button "Update appearance settings"
expect(page).to have_css(logo_selector)
- click_link 'Remove logo'
+ click_link "Remove logo"
expect(page).not_to have_css(logo_selector)
end
- it 'Header logos' do
+ it "Header logos" do
sign_in(create(:admin))
visit admin_appearances_path
attach_file(:appearance_header_logo, logo_fixture)
- click_button 'Update appearance settings'
+ click_button "Update appearance settings"
expect(page).to have_css(header_logo_selector)
- click_link 'Remove header logo'
+ click_link "Remove header logo"
expect(page).not_to have_css(header_logo_selector)
end
- it 'Favicon' do
+ it "Favicon" do
sign_in(create(:admin))
visit admin_appearances_path
attach_file(:appearance_favicon, logo_fixture)
- click_button 'Update appearance settings'
+ click_button "Update appearance settings"
- expect(page).to have_css('.appearance-light-logo-preview')
+ expect(page).to have_css(".appearance-light-logo-preview")
- click_link 'Remove favicon'
+ click_link "Remove favicon"
- expect(page).not_to have_css('.appearance-light-logo-preview')
+ expect(page).not_to have_css(".appearance-light-logo-preview")
# allowed file types
- attach_file(:appearance_favicon, Rails.root.join('spec', 'fixtures', 'sanitized.svg'))
- click_button 'Update appearance settings'
+ attach_file(:appearance_favicon, Rails.root.join("spec", "fixtures", "sanitized.svg"))
+ click_button "Update appearance settings"
expect(page).to have_content 'Favicon You are not allowed to upload "svg" files, allowed types: png, ico'
end
@@ -146,6 +146,6 @@ describe 'Admin Appearance' do
end
def logo_fixture
- Rails.root.join('spec', 'fixtures', 'dk.png')
+ Rails.root.join("spec", "fixtures", "dk.png")
end
end
diff --git a/spec/features/admin/admin_broadcast_messages_spec.rb b/spec/features/admin/admin_broadcast_messages_spec.rb
index f6dc499df29..08f34b9c67c 100644
--- a/spec/features/admin/admin_broadcast_messages_spec.rb
+++ b/spec/features/admin/admin_broadcast_messages_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin Broadcast Messages' do
+describe "Admin Broadcast Messages" do
before do
sign_in(create(:admin))
- create(:broadcast_message, :expired, message: 'Migration to new server')
+ create(:broadcast_message, :expired, message: "Migration to new server")
visit admin_broadcast_messages_path
end
- it 'See broadcast messages list' do
- expect(page).to have_content 'Migration to new server'
+ it "See broadcast messages list" do
+ expect(page).to have_content "Migration to new server"
end
- it 'Create a customized broadcast message' do
- fill_in 'broadcast_message_message', with: 'Application update from **4:00 CST to 5:00 CST**'
- fill_in 'broadcast_message_color', with: '#f2dede'
- fill_in 'broadcast_message_font', with: '#b94a48'
- select Date.today.next_year.year, from: 'broadcast_message_ends_at_1i'
- click_button 'Add broadcast message'
+ it "Create a customized broadcast message" do
+ fill_in "broadcast_message_message", with: "Application update from **4:00 CST to 5:00 CST**"
+ fill_in "broadcast_message_color", with: "#f2dede"
+ fill_in "broadcast_message_font", with: "#b94a48"
+ select Date.today.next_year.year, from: "broadcast_message_ends_at_1i"
+ click_button "Add broadcast message"
expect(current_path).to eq admin_broadcast_messages_path
- expect(page).to have_content 'Application update from 4:00 CST to 5:00 CST'
- expect(page).to have_selector 'strong', text: '4:00 CST to 5:00 CST'
+ expect(page).to have_content "Application update from 4:00 CST to 5:00 CST"
+ expect(page).to have_selector "strong", text: "4:00 CST to 5:00 CST"
expect(page).to have_selector %(div[style="background-color: #f2dede; color: #b94a48"])
end
- it 'Edit an existing broadcast message' do
- click_link 'Edit'
- fill_in 'broadcast_message_message', with: 'Application update RIGHT NOW'
- click_button 'Update broadcast message'
+ it "Edit an existing broadcast message" do
+ click_link "Edit"
+ fill_in "broadcast_message_message", with: "Application update RIGHT NOW"
+ click_button "Update broadcast message"
expect(current_path).to eq admin_broadcast_messages_path
- expect(page).to have_content 'Application update RIGHT NOW'
+ expect(page).to have_content "Application update RIGHT NOW"
end
- it 'Remove an existing broadcast message' do
- click_link 'Remove'
+ it "Remove an existing broadcast message" do
+ click_link "Remove"
expect(current_path).to eq admin_broadcast_messages_path
- expect(page).not_to have_content 'Migration to new server'
+ expect(page).not_to have_content "Migration to new server"
end
- it 'Live preview a customized broadcast message', :js do
- fill_in 'broadcast_message_message', with: "Live **Markdown** previews. :tada:"
+ it "Live preview a customized broadcast message", :js do
+ fill_in "broadcast_message_message", with: "Live **Markdown** previews. :tada:"
- page.within('.broadcast-message-preview') do
- expect(page).to have_selector('strong', text: 'Markdown')
- expect(page).to have_emoji('tada')
+ page.within(".broadcast-message-preview") do
+ expect(page).to have_selector("strong", text: "Markdown")
+ expect(page).to have_emoji("tada")
end
end
end
diff --git a/spec/features/admin/admin_browse_spam_logs_spec.rb b/spec/features/admin/admin_browse_spam_logs_spec.rb
index 4645fde7522..c2247fcd92f 100644
--- a/spec/features/admin/admin_browse_spam_logs_spec.rb
+++ b/spec/features/admin/admin_browse_spam_logs_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin browse spam logs' do
- let!(:spam_log) { create(:spam_log, description: 'abcde ' * 20) }
+describe "Admin browse spam logs" do
+ let!(:spam_log) { create(:spam_log, description: "abcde " * 20) }
before do
sign_in(create(:admin))
end
- it 'Browse spam logs' do
+ it "Browse spam logs" do
visit admin_spam_logs_path
- expect(page).to have_content('Spam Logs')
+ expect(page).to have_content("Spam Logs")
expect(page).to have_content(spam_log.source_ip)
expect(page).to have_content(spam_log.noteable_type)
- expect(page).to have_content('N')
+ expect(page).to have_content("N")
expect(page).to have_content(spam_log.title)
expect(page).to have_content("#{spam_log.description[0...97]}...")
- expect(page).to have_link('Remove user')
- expect(page).to have_link('Block user')
+ expect(page).to have_link("Remove user")
+ expect(page).to have_link("Block user")
end
end
diff --git a/spec/features/admin/admin_browses_logs_spec.rb b/spec/features/admin/admin_browses_logs_spec.rb
index 02f50d7e27f..bb9f37a74d6 100644
--- a/spec/features/admin/admin_browses_logs_spec.rb
+++ b/spec/features/admin/admin_browses_logs_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin browses logs' do
+describe "Admin browses logs" do
before do
sign_in(create(:admin))
end
- it 'shows available log files' do
+ it "shows available log files" do
visit admin_logs_path
- expect(page).to have_link 'application.log'
- expect(page).to have_link 'githost.log'
- expect(page).to have_link 'test.log'
- expect(page).to have_link 'sidekiq.log'
- expect(page).to have_link 'repocheck.log'
+ expect(page).to have_link "application.log"
+ expect(page).to have_link "githost.log"
+ expect(page).to have_link "test.log"
+ expect(page).to have_link "sidekiq.log"
+ expect(page).to have_link "repocheck.log"
end
end
diff --git a/spec/features/admin/admin_builds_spec.rb b/spec/features/admin/admin_builds_spec.rb
index 51b42d1b43b..4d5bc50f84e 100644
--- a/spec/features/admin/admin_builds_spec.rb
+++ b/spec/features/admin/admin_builds_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin Builds' do
+describe "Admin Builds" do
before do
sign_in(create(:admin))
end
- describe 'GET /admin/builds' do
+ describe "GET /admin/builds" do
let(:pipeline) { create(:ci_pipeline) }
- context 'All tab' do
- context 'when have jobs' do
- it 'shows all jobs' do
+ context "All tab" do
+ context "when have jobs" do
+ it "shows all jobs" do
create(:ci_build, pipeline: pipeline, status: :pending)
create(:ci_build, pipeline: pipeline, status: :running)
create(:ci_build, pipeline: pipeline, status: :success)
@@ -18,27 +18,27 @@ describe 'Admin Builds' do
visit admin_jobs_path
- expect(page).to have_selector('.nav-links li.active', text: 'All')
- expect(page).to have_selector('.row-content-block', text: 'All jobs')
- expect(page.all('.build-link').size).to eq(4)
- expect(page).to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "All")
+ expect(page).to have_selector(".row-content-block", text: "All jobs")
+ expect(page.all(".build-link").size).to eq(4)
+ expect(page).to have_button "Stop all jobs"
end
end
- context 'when have no jobs' do
- it 'shows a message' do
+ context "when have no jobs" do
+ it "shows a message" do
visit admin_jobs_path
- expect(page).to have_selector('.nav-links li.active', text: 'All')
- expect(page).to have_content 'No jobs to show'
- expect(page).not_to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "All")
+ expect(page).to have_content "No jobs to show"
+ expect(page).not_to have_button "Stop all jobs"
end
end
end
- context 'Pending tab' do
- context 'when have pending jobs' do
- it 'shows pending jobs' do
+ context "Pending tab" do
+ context "when have pending jobs" do
+ it "shows pending jobs" do
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
build2 = create(:ci_build, pipeline: pipeline, status: :running)
build3 = create(:ci_build, pipeline: pipeline, status: :success)
@@ -46,31 +46,31 @@ describe 'Admin Builds' do
visit admin_jobs_path(scope: :pending)
- expect(page).to have_selector('.nav-links li.active', text: 'Pending')
- expect(page.find('.build-link')).to have_content(build1.id)
- expect(page.find('.build-link')).not_to have_content(build2.id)
- expect(page.find('.build-link')).not_to have_content(build3.id)
- expect(page.find('.build-link')).not_to have_content(build4.id)
- expect(page).to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Pending")
+ expect(page.find(".build-link")).to have_content(build1.id)
+ expect(page.find(".build-link")).not_to have_content(build2.id)
+ expect(page.find(".build-link")).not_to have_content(build3.id)
+ expect(page.find(".build-link")).not_to have_content(build4.id)
+ expect(page).to have_button "Stop all jobs"
end
end
- context 'when have no jobs pending' do
- it 'shows a message' do
+ context "when have no jobs pending" do
+ it "shows a message" do
create(:ci_build, pipeline: pipeline, status: :success)
visit admin_jobs_path(scope: :pending)
- expect(page).to have_selector('.nav-links li.active', text: 'Pending')
- expect(page).to have_content 'No jobs to show'
- expect(page).not_to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Pending")
+ expect(page).to have_content "No jobs to show"
+ expect(page).not_to have_button "Stop all jobs"
end
end
end
- context 'Running tab' do
- context 'when have running jobs' do
- it 'shows running jobs' do
+ context "Running tab" do
+ context "when have running jobs" do
+ it "shows running jobs" do
build1 = create(:ci_build, pipeline: pipeline, status: :running)
build2 = create(:ci_build, pipeline: pipeline, status: :success)
build3 = create(:ci_build, pipeline: pipeline, status: :failed)
@@ -78,54 +78,54 @@ describe 'Admin Builds' do
visit admin_jobs_path(scope: :running)
- expect(page).to have_selector('.nav-links li.active', text: 'Running')
- expect(page.find('.build-link')).to have_content(build1.id)
- expect(page.find('.build-link')).not_to have_content(build2.id)
- expect(page.find('.build-link')).not_to have_content(build3.id)
- expect(page.find('.build-link')).not_to have_content(build4.id)
- expect(page).to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Running")
+ expect(page.find(".build-link")).to have_content(build1.id)
+ expect(page.find(".build-link")).not_to have_content(build2.id)
+ expect(page.find(".build-link")).not_to have_content(build3.id)
+ expect(page.find(".build-link")).not_to have_content(build4.id)
+ expect(page).to have_button "Stop all jobs"
end
end
- context 'when have no jobs running' do
- it 'shows a message' do
+ context "when have no jobs running" do
+ it "shows a message" do
create(:ci_build, pipeline: pipeline, status: :success)
visit admin_jobs_path(scope: :running)
- expect(page).to have_selector('.nav-links li.active', text: 'Running')
- expect(page).to have_content 'No jobs to show'
- expect(page).not_to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Running")
+ expect(page).to have_content "No jobs to show"
+ expect(page).not_to have_button "Stop all jobs"
end
end
end
- context 'Finished tab' do
- context 'when have finished jobs' do
- it 'shows finished jobs' do
+ context "Finished tab" do
+ context "when have finished jobs" do
+ it "shows finished jobs" do
build1 = create(:ci_build, pipeline: pipeline, status: :pending)
build2 = create(:ci_build, pipeline: pipeline, status: :running)
build3 = create(:ci_build, pipeline: pipeline, status: :success)
visit admin_jobs_path(scope: :finished)
- expect(page).to have_selector('.nav-links li.active', text: 'Finished')
- expect(page.find('.build-link')).not_to have_content(build1.id)
- expect(page.find('.build-link')).not_to have_content(build2.id)
- expect(page.find('.build-link')).to have_content(build3.id)
- expect(page).to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Finished")
+ expect(page.find(".build-link")).not_to have_content(build1.id)
+ expect(page.find(".build-link")).not_to have_content(build2.id)
+ expect(page.find(".build-link")).to have_content(build3.id)
+ expect(page).to have_button "Stop all jobs"
end
end
- context 'when have no jobs finished' do
- it 'shows a message' do
+ context "when have no jobs finished" do
+ it "shows a message" do
create(:ci_build, pipeline: pipeline, status: :running)
visit admin_jobs_path(scope: :finished)
- expect(page).to have_selector('.nav-links li.active', text: 'Finished')
- expect(page).to have_content 'No jobs to show'
- expect(page).to have_button 'Stop all jobs'
+ expect(page).to have_selector(".nav-links li.active", text: "Finished")
+ expect(page).to have_content "No jobs to show"
+ expect(page).to have_button "Stop all jobs"
end
end
end
diff --git a/spec/features/admin/admin_deploy_keys_spec.rb b/spec/features/admin/admin_deploy_keys_spec.rb
index cb96830cb7c..98e3f855967 100644
--- a/spec/features/admin/admin_deploy_keys_spec.rb
+++ b/spec/features/admin/admin_deploy_keys_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'admin deploy keys' do
+RSpec.describe "admin deploy keys" do
let!(:deploy_key) { create(:deploy_key, public: true) }
let!(:another_deploy_key) { create(:another_deploy_key, public: true) }
@@ -8,74 +8,74 @@ RSpec.describe 'admin deploy keys' do
sign_in(create(:admin))
end
- it 'show all public deploy keys' do
+ it "show all public deploy keys" do
visit admin_deploy_keys_path
- page.within(find('.deploy-keys-list', match: :first)) do
+ page.within(find(".deploy-keys-list", match: :first)) do
expect(page).to have_content(deploy_key.title)
expect(page).to have_content(another_deploy_key.title)
end
end
- it 'shows all the projects the deploy key has write access' do
+ it "shows all the projects the deploy key has write access" do
write_key = create(:deploy_keys_project, :write_access, deploy_key: deploy_key)
visit admin_deploy_keys_path
- page.within(find('.deploy-keys-list', match: :first)) do
+ page.within(find(".deploy-keys-list", match: :first)) do
expect(page).to have_content(write_key.project.full_name)
end
end
- describe 'create a new deploy key' do
+ describe "create a new deploy key" do
let(:new_ssh_key) { attributes_for(:key)[:key] }
before do
visit admin_deploy_keys_path
- click_link 'New deploy key'
+ click_link "New deploy key"
end
- it 'creates a new deploy key' do
- fill_in 'deploy_key_title', with: 'laptop'
- fill_in 'deploy_key_key', with: new_ssh_key
- click_button 'Create'
+ it "creates a new deploy key" do
+ fill_in "deploy_key_title", with: "laptop"
+ fill_in "deploy_key_key", with: new_ssh_key
+ click_button "Create"
expect(current_path).to eq admin_deploy_keys_path
- page.within(find('.deploy-keys-list', match: :first)) do
- expect(page).to have_content('laptop')
+ page.within(find(".deploy-keys-list", match: :first)) do
+ expect(page).to have_content("laptop")
end
end
end
- describe 'update an existing deploy key' do
+ describe "update an existing deploy key" do
before do
visit admin_deploy_keys_path
- find('tr', text: deploy_key.title).click_link('Edit')
+ find("tr", text: deploy_key.title).click_link("Edit")
end
- it 'updates an existing deploy key' do
- fill_in 'deploy_key_title', with: 'new-title'
- click_button 'Save changes'
+ it "updates an existing deploy key" do
+ fill_in "deploy_key_title", with: "new-title"
+ click_button "Save changes"
expect(current_path).to eq admin_deploy_keys_path
- page.within(find('.deploy-keys-list', match: :first)) do
- expect(page).to have_content('new-title')
+ page.within(find(".deploy-keys-list", match: :first)) do
+ expect(page).to have_content("new-title")
end
end
end
- describe 'remove an existing deploy key' do
+ describe "remove an existing deploy key" do
before do
visit admin_deploy_keys_path
end
- it 'removes an existing deploy key' do
- find('tr', text: deploy_key.title).click_link('Remove')
+ it "removes an existing deploy key" do
+ find("tr", text: deploy_key.title).click_link("Remove")
expect(current_path).to eq admin_deploy_keys_path
- page.within(find('.deploy-keys-list', match: :first)) do
+ page.within(find(".deploy-keys-list", match: :first)) do
expect(page).not_to have_content(deploy_key.title)
end
end
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 f066b088800..98aa56deba1 100644
--- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb
+++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Admin disables Git access protocol', :js do
+describe "Admin disables Git access protocol", :js do
include StubENV
include MobileHelpers
@@ -8,95 +8,95 @@ describe 'Admin disables Git access protocol', :js do
let(:admin) { create(:admin) }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(admin)
end
- context 'with HTTP disabled' do
+ context "with HTTP disabled" do
before do
disable_http_protocol
end
- it 'shows only SSH url' do
+ it "shows only SSH url" do
visit_project
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
- find('.clone-dropdown-btn').click
+ find(".clone-dropdown-btn").click
- within('.git-clone-holder') do
- expect(page).to have_content('Clone with SSH')
- expect(page).not_to have_content('Clone with HTTP')
+ within(".git-clone-holder") do
+ expect(page).to have_content("Clone with SSH")
+ expect(page).not_to have_content("Clone with HTTP")
end
end
- context 'mobile component' do
- it 'shows only the SSH clone information' do
+ context "mobile component" do
+ it "shows only the SSH clone information" do
resize_screen_xs
visit_project
- find('.dropdown-toggle').click
+ find(".dropdown-toggle").click
- expect(page).to have_content('Copy SSH clone URL')
- expect(page).not_to have_content('Copy HTTP clone URL')
+ expect(page).to have_content("Copy SSH clone URL")
+ expect(page).not_to have_content("Copy HTTP clone URL")
end
end
end
- context 'with SSH disabled' do
+ context "with SSH disabled" do
before do
disable_ssh_protocol
end
- it 'shows only HTTP url' do
+ it "shows only HTTP url" do
visit_project
- find('.clone-dropdown-btn').click
+ find(".clone-dropdown-btn").click
expect(page).to have_content("git clone #{project.http_url_to_repo}")
- within('.git-clone-holder') do
- expect(page).to have_content('Clone with HTTP')
- expect(page).not_to have_content('Clone with SSH')
+ within(".git-clone-holder") do
+ expect(page).to have_content("Clone with HTTP")
+ expect(page).not_to have_content("Clone with SSH")
end
end
- context 'mobile component' do
- it 'shows only the HTTP clone information' do
+ context "mobile component" do
+ it "shows only the HTTP clone information" do
resize_screen_xs
visit_project
- find('.dropdown-toggle').click
+ find(".dropdown-toggle").click
- expect(page).to have_content('Copy HTTP clone URL')
- expect(page).not_to have_content('Copy SSH clone URL')
+ expect(page).to have_content("Copy HTTP clone URL")
+ expect(page).not_to have_content("Copy SSH clone URL")
end
end
end
- context 'with nothing disabled' do
+ context "with nothing disabled" do
before do
create(:personal_key, user: admin)
end
- it 'shows default SSH url and protocol selection dropdown' do
+ it "shows default SSH url and protocol selection dropdown" do
visit_project
expect(page).to have_content("git clone #{project.ssh_url_to_repo}")
- find('.clone-dropdown-btn').click
+ find(".clone-dropdown-btn").click
- within('.git-clone-holder') do
- expect(page).to have_content('Clone with SSH')
- expect(page).to have_content('Clone with HTTP')
+ within(".git-clone-holder") do
+ expect(page).to have_content("Clone with SSH")
+ expect(page).to have_content("Clone with HTTP")
end
end
- context 'mobile component' do
- it 'shows both SSH and HTTP clone information' do
+ context "mobile component" do
+ it "shows both SSH and HTTP clone information" do
resize_screen_xs
visit_project
- find('.dropdown-toggle').click
+ find(".dropdown-toggle").click
- expect(page).to have_content('Copy HTTP clone URL')
- expect(page).to have_content('Copy SSH clone URL')
+ expect(page).to have_content("Copy HTTP clone URL")
+ expect(page).to have_content("Copy SSH clone URL")
end
end
end
@@ -116,9 +116,9 @@ describe 'Admin disables Git access protocol', :js do
def switch_git_protocol(value)
visit admin_application_settings_path
- page.within('.as-visibility-access') do
- find('#application_setting_enabled_git_access_protocol').find(:xpath, "option[#{value}]").select_option
- click_on 'Save'
+ page.within(".as-visibility-access") do
+ find("#application_setting_enabled_git_access_protocol").find(:xpath, "option[#{value}]").select_option
+ click_on "Save"
end
end
end
diff --git a/spec/features/admin/admin_disables_two_factor_spec.rb b/spec/features/admin/admin_disables_two_factor_spec.rb
index e41835b4f24..fc8ad034c7c 100644
--- a/spec/features/admin/admin_disables_two_factor_spec.rb
+++ b/spec/features/admin/admin_disables_two_factor_spec.rb
@@ -1,29 +1,29 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Admin disables 2FA for a user' do
- it 'successfully', :js do
+describe "Admin disables 2FA for a user" do
+ it "successfully", :js do
sign_in(create(:admin))
user = create(:user, :two_factor)
edit_user(user)
- page.within('.two-factor-status') do
- accept_confirm { click_link 'Disable' }
+ page.within(".two-factor-status") do
+ accept_confirm { click_link "Disable" }
end
- page.within('.two-factor-status') do
- expect(page).to have_content 'Disabled'
- expect(page).not_to have_button 'Disable'
+ page.within(".two-factor-status") do
+ expect(page).to have_content "Disabled"
+ expect(page).not_to have_button "Disable"
end
end
- it 'for a user without 2FA enabled' do
+ it "for a user without 2FA enabled" do
sign_in(create(:admin))
user = create(:user)
edit_user(user)
- page.within('.two-factor-status') do
- expect(page).not_to have_button 'Disable'
+ page.within(".two-factor-status") do
+ expect(page).not_to have_button "Disable"
end
end
diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb
index 735ca60f7da..28e583acad1 100644
--- a/spec/features/admin/admin_groups_spec.rb
+++ b/spec/features/admin/admin_groups_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin Groups' do
+describe "Admin Groups" do
include Select2Helper
let(:internal) { Gitlab::VisibilityLevel::INTERNAL }
@@ -13,78 +13,78 @@ describe 'Admin Groups' do
stub_application_setting(default_group_visibility: internal)
end
- describe 'list' do
- it 'renders groups' do
+ describe "list" do
+ it "renders groups" do
visit admin_groups_path
expect(page).to have_content(group.name)
end
end
- describe 'create a group' do
- it 'creates new group' do
+ describe "create a group" do
+ it "creates new group" do
visit admin_groups_path
- page.within '#content-body' do
+ page.within "#content-body" do
click_link "New group"
end
- path_component = 'gitlab'
- group_name = 'GitLab group name'
- group_description = 'Description of group for GitLab'
+ path_component = "gitlab"
+ group_name = "GitLab group name"
+ group_description = "Description of group for GitLab"
- fill_in 'group_path', with: path_component
- fill_in 'group_name', with: group_name
- fill_in 'group_description', with: group_description
+ fill_in "group_path", with: path_component
+ fill_in "group_name", with: group_name
+ fill_in "group_description", with: group_description
click_button "Create group"
expect(current_path).to eq admin_group_path(Group.find_by(path: path_component))
- content = page.find('div#content-body')
- h3_texts = content.all('h3').collect(&:text).join("\n")
+ content = page.find("div#content-body")
+ h3_texts = content.all("h3").collect(&:text).join("\n")
expect(h3_texts).to match group_name
- li_texts = content.all('li').collect(&:text).join("\n")
+ li_texts = content.all("li").collect(&:text).join("\n")
expect(li_texts).to match group_name
expect(li_texts).to match path_component
expect(li_texts).to match group_description
end
- it 'shows the visibility level radio populated with the default value' do
+ it "shows the visibility level radio populated with the default value" do
visit new_admin_group_path
expect_selected_visibility(internal)
end
- it 'when entered in group name, it auto filled the group path', :js do
+ it "when entered in group name, it auto filled the group path", :js do
visit admin_groups_path
click_link "New group"
- group_name = 'gitlab'
- fill_in 'group_name', with: group_name
- path_field = find('input#group_path')
+ group_name = "gitlab"
+ fill_in "group_name", with: group_name
+ path_field = find("input#group_path")
expect(path_field.value).to eq group_name
end
- it 'auto populates the group path with the group name', :js do
+ it "auto populates the group path with the group name", :js do
visit admin_groups_path
click_link "New group"
- group_name = 'my gitlab project'
- fill_in 'group_name', with: group_name
- path_field = find('input#group_path')
- expect(path_field.value).to eq 'my-gitlab-project'
+ group_name = "my gitlab project"
+ fill_in "group_name", with: group_name
+ path_field = find("input#group_path")
+ expect(path_field.value).to eq "my-gitlab-project"
end
- it 'when entering in group path, group name does not change anymore', :js do
+ it "when entering in group path, group name does not change anymore", :js do
visit admin_groups_path
click_link "New group"
- group_path = 'my-gitlab-project'
- group_name = 'My modified gitlab project'
- fill_in 'group_path', with: group_path
- fill_in 'group_name', with: group_name
- path_field = find('input#group_path')
- expect(path_field.value).to eq 'my-gitlab-project'
+ group_path = "my-gitlab-project"
+ group_name = "My modified gitlab project"
+ fill_in "group_path", with: group_path
+ fill_in "group_name", with: group_name
+ path_field = find("input#group_path")
+ expect(path_field.value).to eq "my-gitlab-project"
end
end
- describe 'show a group' do
- it 'shows the group' do
+ describe "show a group" do
+ it "shows the group" do
group = create(:group, :private)
visit admin_group_path(group)
@@ -93,8 +93,8 @@ describe 'Admin Groups' do
end
end
- describe 'group edit' do
- it 'shows the visibility level radio populated with the group visibility_level value' do
+ describe "group edit" do
+ it "shows the visibility level radio populated with the group visibility_level value" do
group = create(:group, :private)
visit admin_group_edit_path(group)
@@ -102,90 +102,90 @@ describe 'Admin Groups' do
expect_selected_visibility(group.visibility_level)
end
- it 'edit group path does not change group name', :js do
+ it "edit group path does not change group name", :js do
group = create(:group, :private)
visit admin_group_edit_path(group)
- name_field = find('input#group_name')
+ name_field = find("input#group_name")
original_name = name_field.value
- fill_in 'group_path', with: 'this-new-path'
+ fill_in "group_path", with: "this-new-path"
expect(name_field.value).to eq original_name
end
end
- describe 'add user into a group', :js do
- shared_context 'adds user into a group' do
+ describe "add user into a group", :js do
+ shared_context "adds user into a group" do
it do
visit admin_group_path(group)
- select2(user_selector, from: '#user_ids', multiple: true)
- page.within '#new_project_member' do
- select2(Gitlab::Access::REPORTER, from: '#access_level')
+ select2(user_selector, from: "#user_ids", multiple: true)
+ page.within "#new_project_member" do
+ select2(Gitlab::Access::REPORTER, from: "#access_level")
end
click_button "Add users to group"
page.within ".group-users-list" do
expect(page).to have_content(user.name)
- expect(page).to have_content('Reporter')
+ expect(page).to have_content("Reporter")
end
end
end
- it_behaves_like 'adds user into a group' do
+ it_behaves_like "adds user into a group" do
let(:user_selector) { user.id }
end
- it_behaves_like 'adds user into a group' do
+ it_behaves_like "adds user into a group" do
let(:user_selector) { user.email }
end
end
- describe 'add admin himself to a group' do
+ describe "add admin himself to a group" do
before do
group.add_user(:user, Gitlab::Access::OWNER)
end
- it 'adds admin a to a group as developer', :js do
+ it "adds admin a to a group as developer", :js do
visit group_group_members_path(group)
- page.within '.users-group-form' do
- select2(current_user.id, from: '#user_ids', multiple: true)
- select 'Developer', from: 'access_level'
+ page.within ".users-group-form" do
+ select2(current_user.id, from: "#user_ids", multiple: true)
+ select "Developer", from: "access_level"
end
- click_button 'Add to group'
+ click_button "Add to group"
- page.within '.content-list' do
+ page.within ".content-list" do
expect(page).to have_content(current_user.name)
- expect(page).to have_content('Developer')
+ expect(page).to have_content("Developer")
end
end
end
- describe 'admin remove himself from a group', :js do
- it 'removes admin from the group' do
+ describe "admin remove himself from a group", :js do
+ it "removes admin from the group" do
group.add_user(current_user, Gitlab::Access::DEVELOPER)
visit group_group_members_path(group)
- page.within '.content-list' do
+ page.within ".content-list" do
expect(page).to have_content(current_user.name)
- expect(page).to have_content('Developer')
+ expect(page).to have_content("Developer")
end
- accept_confirm { find(:css, 'li', text: current_user.name).find(:css, 'a.btn-remove').click }
+ accept_confirm { find(:css, "li", text: current_user.name).find(:css, "a.btn-remove").click }
visit group_group_members_path(group)
- page.within '.content-list' do
+ page.within ".content-list" do
expect(page).not_to have_content(current_user.name)
- expect(page).not_to have_content('Developer')
+ expect(page).not_to have_content("Developer")
end
end
end
- describe 'shared projects' do
- it 'renders shared project' do
+ describe "shared projects" do
+ it "renders shared project" do
empty_project = create(:project)
empty_project.project_group_links.create!(
group_access: Gitlab::Access::MAINTAINER,
@@ -195,7 +195,7 @@ describe 'Admin Groups' do
visit admin_group_path(group)
expect(page).to have_content(empty_project.full_name)
- expect(page).to have_content('Projects shared with')
+ expect(page).to have_content("Projects shared with")
end
end
diff --git a/spec/features/admin/admin_health_check_spec.rb b/spec/features/admin/admin_health_check_spec.rb
index 790051dd933..1fde3479bb9 100644
--- a/spec/features/admin/admin_health_check_spec.rb
+++ b/spec/features/admin/admin_health_check_spec.rb
@@ -1,60 +1,60 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin Health Check", :feature do
include StubENV
set(:admin) { create(:admin) }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(admin)
end
- describe '#show' do
+ describe "#show" do
before do
visit admin_health_check_path
end
- it 'has a health check access token' do
- page.has_text? 'Health Check'
- page.has_text? 'Health information can be retrieved'
+ it "has a health check access token" do
+ page.has_text? "Health Check"
+ page.has_text? "Health information can be retrieved"
token = Gitlab::CurrentSettings.health_check_access_token
expect(page).to have_content("Access token is #{token}")
- expect(page).to have_selector('#health-check-token', text: token)
+ expect(page).to have_selector("#health-check-token", text: token)
end
- describe 'reload access token' do
- it 'changes the access token' do
+ describe "reload access token" do
+ it "changes the access token" do
orig_token = Gitlab::CurrentSettings.health_check_access_token
- click_button 'Reset health check access token'
+ click_button "Reset health check access token"
- expect(page).to have_content('New health check access token has been generated!')
- expect(find('#health-check-token').text).not_to eq orig_token
+ expect(page).to have_content("New health check access token has been generated!")
+ expect(find("#health-check-token").text).not_to eq orig_token
end
end
end
- context 'when services are up' do
+ context "when services are up" do
before do
stub_storage_settings({}) # Hide the broken storage
visit admin_health_check_path
end
- it 'shows healthy status' do
- expect(page).to have_content('Current Status: Healthy')
+ it "shows healthy status" do
+ expect(page).to have_content("Current Status: Healthy")
end
end
- context 'when a service is down' do
+ context "when a service is down" do
before do
- allow(HealthCheck::Utils).to receive(:process_checks).and_return('The server is on fire')
+ allow(HealthCheck::Utils).to receive(:process_checks).and_return("The server is on fire")
visit admin_health_check_path
end
- it 'shows unhealthy status' do
- expect(page).to have_content('Current Status: Unhealthy')
- expect(page).to have_content('The server is on fire')
+ it "shows unhealthy status" do
+ expect(page).to have_content("Current Status: Unhealthy")
+ expect(page).to have_content("The server is on fire")
end
end
end
diff --git a/spec/features/admin/admin_hook_logs_spec.rb b/spec/features/admin/admin_hook_logs_spec.rb
index 928f97b6d29..225b44ae5db 100644
--- a/spec/features/admin/admin_hook_logs_spec.rb
+++ b/spec/features/admin/admin_hook_logs_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin::HookLogs' do
+describe "Admin::HookLogs" do
let(:project) { create(:project) }
let(:system_hook) { create(:system_hook) }
- let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: 'some error') }
+ let(:hook_log) { create(:web_hook_log, web_hook: system_hook, internal_error_message: "some error") }
before do
sign_in(create(:admin))
end
- it 'show list of hook logs' do
+ it "show list of hook logs" do
hook_log
visit edit_admin_hook_path(system_hook)
- expect(page).to have_content('Recent Deliveries')
+ expect(page).to have_content("Recent Deliveries")
expect(page).to have_content(hook_log.url)
end
- it 'show hook log details' do
+ it "show hook log details" do
hook_log
visit edit_admin_hook_path(system_hook)
- click_link 'View details'
+ click_link "View details"
expect(page).to have_content("POST #{hook_log.url}")
expect(page).to have_content(hook_log.internal_error_message)
- expect(page).to have_content('Resend Request')
+ expect(page).to have_content("Resend Request")
end
- it 'retry hook log' do
+ it "retry hook log" do
WebMock.stub_request(:post, system_hook.url)
hook_log
visit edit_admin_hook_path(system_hook)
- click_link 'View details'
- click_link 'Resend Request'
+ click_link "View details"
+ click_link "Resend Request"
expect(current_path).to eq(edit_admin_hook_path(system_hook))
end
diff --git a/spec/features/admin/admin_hooks_spec.rb b/spec/features/admin/admin_hooks_spec.rb
index 25ed3bdc88e..7f5af4e84a1 100644
--- a/spec/features/admin/admin_hooks_spec.rb
+++ b/spec/features/admin/admin_hooks_spec.rb
@@ -1,144 +1,144 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin::Hooks' do
+describe "Admin::Hooks" do
let(:user) { create(:admin) }
before do
sign_in(user)
end
- describe 'GET /admin/hooks' do
- it 'is ok' do
+ describe "GET /admin/hooks" do
+ it "is ok" do
visit admin_root_path
- page.within '.nav-sidebar' do
- click_on 'System Hooks', match: :first
+ page.within ".nav-sidebar" do
+ click_on "System Hooks", match: :first
end
expect(current_path).to eq(admin_hooks_path)
end
- it 'has hooks list' do
+ it "has hooks list" do
system_hook = create(:system_hook)
visit admin_hooks_path
expect(page).to have_content(system_hook.url)
end
- it 'renders plugins list as well' do
- allow(Gitlab::Plugin).to receive(:files).and_return(['foo.rb', 'bar.clj'])
+ it "renders plugins list as well" do
+ allow(Gitlab::Plugin).to receive(:files).and_return(["foo.rb", "bar.clj"])
visit admin_hooks_path
- expect(page).to have_content('Plugins')
- expect(page).to have_content('foo.rb')
- expect(page).to have_content('bar.clj')
+ expect(page).to have_content("Plugins")
+ expect(page).to have_content("foo.rb")
+ expect(page).to have_content("bar.clj")
end
end
- describe 'New Hook' do
+ describe "New Hook" do
let(:url) { generate(:url) }
- it 'adds new hook' do
+ it "adds new hook" do
visit admin_hooks_path
- fill_in 'hook_url', with: url
- check 'Enable SSL verification'
+ fill_in "hook_url", with: url
+ check "Enable SSL verification"
- expect { click_button 'Add system hook' }.to change(SystemHook, :count).by(1)
- expect(page).to have_content 'SSL Verification: enabled'
+ expect { click_button "Add system hook" }.to change(SystemHook, :count).by(1)
+ expect(page).to have_content "SSL Verification: enabled"
expect(current_path).to eq(admin_hooks_path)
expect(page).to have_content(url)
end
end
- describe 'Update existing hook' do
+ describe "Update existing hook" do
let(:new_url) { generate(:url) }
before do
create(:system_hook)
end
- it 'updates existing hook' do
+ it "updates existing hook" do
visit admin_hooks_path
- click_link 'Edit'
- fill_in 'hook_url', with: new_url
- check 'Enable SSL verification'
- click_button 'Save changes'
+ click_link "Edit"
+ fill_in "hook_url", with: new_url
+ check "Enable SSL verification"
+ click_button "Save changes"
- expect(page).to have_content 'SSL Verification: enabled'
+ expect(page).to have_content "SSL Verification: enabled"
expect(current_path).to eq(admin_hooks_path)
expect(page).to have_content(new_url)
end
end
- describe 'Remove existing hook', :js do
+ describe "Remove existing hook", :js do
before do
create(:system_hook)
end
- context 'removes existing hook' do
- it 'from hooks list page' do
+ context "removes existing hook" do
+ it "from hooks list page" do
visit admin_hooks_path
- expect { accept_confirm { find(:link, 'Remove').send_keys(:return) } }.to change(SystemHook, :count).by(-1)
+ expect { accept_confirm { find(:link, "Remove").send_keys(:return) } }.to change(SystemHook, :count).by(-1)
end
- it 'from hook edit page' do
+ it "from hook edit page" do
visit admin_hooks_path
- click_link 'Edit'
+ click_link "Edit"
- expect { accept_confirm { find(:link, 'Remove').send_keys(:return) } }.to change(SystemHook, :count).by(-1)
+ expect { accept_confirm { find(:link, "Remove").send_keys(:return) } }.to change(SystemHook, :count).by(-1)
end
end
end
- describe 'Test', :js do
+ describe "Test", :js do
before do
system_hook = create(:system_hook)
WebMock.stub_request(:post, system_hook.url)
visit admin_hooks_path
- find('.hook-test-button.dropdown').click
- click_link 'Push events'
+ find(".hook-test-button.dropdown").click
+ click_link "Push events"
end
it { expect(current_path).to eq(admin_hooks_path) }
end
- context 'Merge request hook' do
- describe 'New Hook' do
+ context "Merge request hook" do
+ describe "New Hook" do
let(:url) { generate(:url) }
- it 'adds new hook' do
+ it "adds new hook" do
visit admin_hooks_path
- fill_in 'hook_url', with: url
- uncheck 'Repository update events'
- check 'Merge request events'
+ fill_in "hook_url", with: url
+ uncheck "Repository update events"
+ check "Merge request events"
- expect { click_button 'Add system hook' }.to change(SystemHook, :count).by(1)
+ expect { click_button "Add system hook" }.to change(SystemHook, :count).by(1)
expect(current_path).to eq(admin_hooks_path)
expect(page).to have_content(url)
end
end
- describe 'Test', :js do
+ describe "Test", :js do
before do
system_hook = create(:system_hook)
WebMock.stub_request(:post, system_hook.url)
end
- it 'succeeds if the user has a repository with a merge request' do
+ it "succeeds if the user has a repository with a merge request" do
project = create(:project, :repository)
create(:project_member, user: user, project: project)
create(:merge_request, source_project: project)
visit admin_hooks_path
- find('.hook-test-button.dropdown').click
- click_link 'Merge requests events'
+ find(".hook-test-button.dropdown").click
+ click_link "Merge requests events"
- expect(page).to have_content 'Hook executed successfully'
+ expect(page).to have_content "Hook executed successfully"
end
end
end
diff --git a/spec/features/admin/admin_labels_spec.rb b/spec/features/admin/admin_labels_spec.rb
index 238ea2a25bd..ddf79f7b879 100644
--- a/spec/features/admin/admin_labels_spec.rb
+++ b/spec/features/admin/admin_labels_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'admin issues labels' do
- let!(:bug_label) { Label.create(title: 'bug', template: true) }
- let!(:feature_label) { Label.create(title: 'feature', template: true) }
+RSpec.describe "admin issues labels" do
+ let!(:bug_label) { Label.create(title: "bug", template: true) }
+ let!(:feature_label) { Label.create(title: "feature", template: true) }
before do
sign_in(create(:admin))
end
- describe 'list' do
+ describe "list" do
before do
visit admin_labels_path
end
- it 'renders labels list' do
- page.within '.manage-labels-list' do
- expect(page).to have_content('bug')
- expect(page).to have_content('feature')
+ it "renders labels list" do
+ page.within ".manage-labels-list" do
+ expect(page).to have_content("bug")
+ expect(page).to have_content("feature")
end
end
- it 'deletes label' do
+ it "deletes label" do
page.within "#label_#{bug_label.id}" do
- click_link 'Delete'
+ click_link "Delete"
end
- page.within '.manage-labels-list' do
- expect(page).not_to have_content('bug')
+ page.within ".manage-labels-list" do
+ expect(page).not_to have_content("bug")
end
end
- it 'deletes all labels', :js do
- page.within '.labels' do
- page.all('.remove-row').each do |remove|
+ it "deletes all labels", :js do
+ page.within ".labels" do
+ page.all(".remove-row").each do |remove|
accept_confirm { remove.click }
wait_for_requests
end
@@ -41,57 +41,57 @@ RSpec.describe 'admin issues labels' do
wait_for_requests
expect(page).to have_content("There are no labels yet")
- expect(page).not_to have_content('bug')
- expect(page).not_to have_content('feature_label')
+ expect(page).not_to have_content("bug")
+ expect(page).not_to have_content("feature_label")
end
end
- describe 'create' do
+ describe "create" do
before do
visit new_admin_label_path
end
- it 'creates new label' do
- fill_in 'Title', with: 'support'
- fill_in 'Background color', with: '#F95610'
- click_button 'Save'
+ it "creates new label" do
+ fill_in "Title", with: "support"
+ fill_in "Background color", with: "#F95610"
+ click_button "Save"
- page.within '.manage-labels-list' do
- expect(page).to have_content('support')
+ page.within ".manage-labels-list" do
+ expect(page).to have_content("support")
end
end
- it 'does not creates label with invalid color' do
- fill_in 'Title', with: 'support'
- fill_in 'Background color', with: '#12'
- click_button 'Save'
+ it "does not creates label with invalid color" do
+ fill_in "Title", with: "support"
+ fill_in "Background color", with: "#12"
+ click_button "Save"
- page.within '.label-form' do
- expect(page).to have_content('Color must be a valid color code')
+ page.within ".label-form" do
+ expect(page).to have_content("Color must be a valid color code")
end
end
- it 'does not creates label if label already exists' do
- fill_in 'Title', with: 'bug'
- fill_in 'Background color', with: '#F95610'
- click_button 'Save'
+ it "does not creates label if label already exists" do
+ fill_in "Title", with: "bug"
+ fill_in "Background color", with: "#F95610"
+ click_button "Save"
- page.within '.label-form' do
- expect(page).to have_content 'Title has already been taken'
+ page.within ".label-form" do
+ expect(page).to have_content "Title has already been taken"
end
end
end
- describe 'edit' do
- it 'changes bug label' do
+ describe "edit" do
+ it "changes bug label" do
visit edit_admin_label_path(bug_label)
- fill_in 'Title', with: 'fix'
- fill_in 'Background color', with: '#F15610'
- click_button 'Save'
+ fill_in "Title", with: "fix"
+ fill_in "Background color", with: "#F15610"
+ click_button "Save"
- page.within '.manage-labels-list' do
- expect(page).to have_content('fix')
+ page.within ".manage-labels-list" do
+ expect(page).to have_content("fix")
end
end
end
diff --git a/spec/features/admin/admin_manage_applications_spec.rb b/spec/features/admin/admin_manage_applications_spec.rb
index a4904272706..8a5ce1d265f 100644
--- a/spec/features/admin/admin_manage_applications_spec.rb
+++ b/spec/features/admin/admin_manage_applications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'admin manage applications' do
+RSpec.describe "admin manage applications" do
before do
sign_in(create(:admin))
end
@@ -8,34 +8,34 @@ RSpec.describe 'admin manage applications' do
it do
visit admin_applications_path
- click_on 'New application'
- expect(page).to have_content('New application')
+ click_on "New application"
+ expect(page).to have_content("New application")
- fill_in :doorkeeper_application_name, with: 'test'
- fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com'
+ fill_in :doorkeeper_application_name, with: "test"
+ fill_in :doorkeeper_application_redirect_uri, with: "https://test.com"
check :doorkeeper_application_trusted
- click_on 'Submit'
- expect(page).to have_content('Application: test')
- expect(page).to have_content('Application ID')
- expect(page).to have_content('Secret')
- expect(page).to have_content('Trusted Y')
+ click_on "Submit"
+ expect(page).to have_content("Application: test")
+ expect(page).to have_content("Application ID")
+ expect(page).to have_content("Secret")
+ expect(page).to have_content("Trusted Y")
- click_on 'Edit'
- expect(page).to have_content('Edit application')
+ click_on "Edit"
+ expect(page).to have_content("Edit application")
- fill_in :doorkeeper_application_name, with: 'test_changed'
+ fill_in :doorkeeper_application_name, with: "test_changed"
uncheck :doorkeeper_application_trusted
- click_on 'Submit'
- expect(page).to have_content('test_changed')
- expect(page).to have_content('Application ID')
- expect(page).to have_content('Secret')
- expect(page).to have_content('Trusted N')
+ click_on "Submit"
+ expect(page).to have_content("test_changed")
+ expect(page).to have_content("Application ID")
+ expect(page).to have_content("Secret")
+ expect(page).to have_content("Trusted N")
visit admin_applications_path
- page.within '.oauth-applications' do
- click_on 'Destroy'
+ page.within ".oauth-applications" do
+ click_on "Destroy"
end
- expect(page.find('.oauth-applications')).not_to have_content('test_changed')
+ expect(page.find(".oauth-applications")).not_to have_content("test_changed")
end
end
diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb
index 2b6bfa40beb..eaab27efe52 100644
--- a/spec/features/admin/admin_projects_spec.rb
+++ b/spec/features/admin/admin_projects_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin::Projects" do
include Select2Helper
@@ -23,23 +23,23 @@ describe "Admin::Projects" do
expect(current_path).to eq(admin_projects_path)
end
- it 'renders projects list without archived project' do
+ it "renders projects list without archived project" do
expect(page).to have_content(project.name)
expect(page).not_to have_content(archived_project.name)
end
- it 'renders all projects', :js do
- find(:css, '#sort-projects-dropdown').click
- click_link 'Show archived projects'
+ it "renders all projects", :js do
+ find(:css, "#sort-projects-dropdown").click
+ click_link "Show archived projects"
expect(page).to have_content(project.name)
expect(page).to have_content(archived_project.name)
- expect(page).to have_xpath("//span[@class='badge badge-warning']", text: 'archived')
+ expect(page).to have_xpath("//span[@class='badge badge-warning']", text: "archived")
end
- it 'renders only archived projects', :js do
- find(:css, '#sort-projects-dropdown').click
- click_link 'Show archived projects only'
+ it "renders only archived projects", :js do
+ find(:css, "#sort-projects-dropdown").click
+ click_link "Show archived projects only"
expect(page).to have_content(archived_project.name)
expect(page).not_to have_content(project.name)
@@ -63,68 +63,68 @@ describe "Admin::Projects" do
end
end
- describe 'transfer project' do
+ describe "transfer project" do
# The gitlab-shell transfer will fail for a project without a repository
let(:project) { create(:project, :repository) }
before do
- create(:group, name: 'Web')
+ create(:group, name: "Web")
allow_any_instance_of(Projects::TransferService)
.to receive(:move_uploads_to_new_namespace).and_return(true)
end
- it 'transfers project to group web', :js do
+ it "transfers project to group web", :js do
visit admin_project_path(project)
- click_button 'Search for Namespace'
- click_link 'group: web'
- click_button 'Transfer'
+ click_button "Search for Namespace"
+ click_link "group: web"
+ click_button "Transfer"
expect(page).to have_content("Web / #{project.name}")
- expect(page).to have_content('Namespace: Web')
+ expect(page).to have_content("Namespace: Web")
end
end
- describe 'add admin himself to a project' do
+ describe "add admin himself to a project" do
before do
project.add_maintainer(user)
end
- it 'adds admin a to a project as developer', :js do
+ it "adds admin a to a project as developer", :js do
visit project_project_members_path(project)
- page.within '.users-project-form' do
- select2(current_user.id, from: '#user_ids', multiple: true)
- select 'Developer', from: 'access_level'
+ page.within ".users-project-form" do
+ select2(current_user.id, from: "#user_ids", multiple: true)
+ select "Developer", from: "access_level"
end
- click_button 'Add to project'
+ click_button "Add to project"
- page.within '.content-list' do
+ page.within ".content-list" do
expect(page).to have_content(current_user.name)
- expect(page).to have_content('Developer')
+ expect(page).to have_content("Developer")
end
end
end
- describe 'admin remove himself from a project' do
+ describe "admin remove himself from a project" do
before do
project.add_maintainer(user)
project.add_developer(current_user)
end
- it 'removes admin from the project' do
+ it "removes admin from the project" do
visit project_project_members_path(project)
- page.within '.content-list' do
+ page.within ".content-list" do
expect(page).to have_content(current_user.name)
- expect(page).to have_content('Developer')
+ expect(page).to have_content("Developer")
end
- find(:css, '.content-list li', text: current_user.name).find(:css, 'a.btn-remove').click
+ find(:css, ".content-list li", text: current_user.name).find(:css, "a.btn-remove").click
- expect(page).not_to have_selector(:css, '.content-list')
+ expect(page).not_to have_selector(:css, ".content-list")
end
end
end
diff --git a/spec/features/admin/admin_requests_profiles_spec.rb b/spec/features/admin/admin_requests_profiles_spec.rb
index 2503fc9067d..333768dd911 100644
--- a/spec/features/admin/admin_requests_profiles_spec.rb
+++ b/spec/features/admin/admin_requests_profiles_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin::RequestsProfilesController' do
+describe "Admin::RequestsProfilesController" do
before do
FileUtils.mkdir_p(Gitlab::RequestProfiler::PROFILES_DIR)
sign_in(create(:admin))
@@ -10,8 +10,8 @@ describe 'Admin::RequestsProfilesController' do
Gitlab::RequestProfiler.remove_all_profiles
end
- describe 'GET /admin/requests_profiles' do
- it 'shows the current profile token' do
+ describe "GET /admin/requests_profiles" do
+ it "shows the current profile token" do
allow(Rails).to receive(:cache).and_return(ActiveSupport::Cache::MemoryStore.new)
visit admin_requests_profiles_path
@@ -19,7 +19,7 @@ describe 'Admin::RequestsProfilesController' do
expect(page).to have_content("X-Profile-Token: #{Gitlab::RequestProfiler.profile_token}")
end
- it 'lists all available profiles' do
+ it "lists all available profiles" do
time1 = 1.hour.ago
time2 = 2.hours.ago
time3 = 3.hours.ago
@@ -33,21 +33,21 @@ describe 'Admin::RequestsProfilesController' do
visit admin_requests_profiles_path
- within('.card', text: '/gitlab-org/gitlab-ce') do
+ within(".card", text: "/gitlab-org/gitlab-ce") do
expect(page).to have_selector("a[href='#{admin_requests_profile_path(profile1)}']", text: time1.to_s(:long))
expect(page).to have_selector("a[href='#{admin_requests_profile_path(profile2)}']", text: time2.to_s(:long))
end
- within('.card', text: '/gitlab-com/infrastructure') do
+ within(".card", text: "/gitlab-com/infrastructure") do
expect(page).to have_selector("a[href='#{admin_requests_profile_path(profile3)}']", text: time3.to_s(:long))
end
end
end
- describe 'GET /admin/requests_profiles/:profile' do
- context 'when a profile exists' do
- it 'displays the content of the profile' do
- content = 'This is a request profile'
+ describe "GET /admin/requests_profiles/:profile" do
+ context "when a profile exists" do
+ it "displays the content of the profile" do
+ content = "This is a request profile"
profile = "|gitlab-org|gitlab-ce_#{Time.now.to_i}.html"
File.write("#{Gitlab::RequestProfiler::PROFILES_DIR}/#{profile}", content)
@@ -58,11 +58,11 @@ describe 'Admin::RequestsProfilesController' do
end
end
- context 'when a profile does not exist' do
- it 'shows an error message' do
- visit admin_requests_profile_path('|non|existent_12345.html')
+ context "when a profile does not exist" do
+ it "shows an error message" do
+ visit admin_requests_profile_path("|non|existent_12345.html")
- expect(page).to have_content('Profile not found')
+ expect(page).to have_content("Profile not found")
end
end
end
diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb
index 97b432a6751..087d9445971 100644
--- a/spec/features/admin/admin_runners_spec.rb
+++ b/spec/features/admin/admin_runners_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin Runners" do
include StubENV
@@ -6,7 +6,7 @@ describe "Admin Runners" do
include SortingHelper
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(create(:admin))
end
@@ -14,7 +14,7 @@ describe "Admin Runners" do
let(:pipeline) { create(:ci_pipeline) }
context "when there are runners" do
- it 'has all necessary texts' do
+ it "has all necessary texts" do
runner = create(:ci_runner, contacted_at: Time.now)
create(:ci_build, pipeline: pipeline, runner_id: runner.id)
visit admin_runners_path
@@ -23,196 +23,196 @@ describe "Admin Runners" do
expect(page).to have_text "Runners currently online: 1"
end
- describe 'search', :js do
+ describe "search", :js do
before do
- create(:ci_runner, description: 'runner-foo')
- create(:ci_runner, description: 'runner-bar')
+ create(:ci_runner, description: "runner-foo")
+ create(:ci_runner, description: "runner-bar")
visit admin_runners_path
end
- it 'shows correct runner when description matches' do
- input_filtered_search_keys('runner-foo')
+ it "shows correct runner when description matches" do
+ input_filtered_search_keys("runner-foo")
expect(page).to have_content("runner-foo")
expect(page).not_to have_content("runner-bar")
end
- it 'shows no runner when description does not match' do
- input_filtered_search_keys('runner-baz')
+ it "shows no runner when description does not match" do
+ input_filtered_search_keys("runner-baz")
- expect(page).to have_text 'No runners found'
+ expect(page).to have_text "No runners found"
end
end
- describe 'filter by status', :js do
- it 'shows correct runner when status matches' do
- create(:ci_runner, description: 'runner-active', active: true)
- create(:ci_runner, description: 'runner-paused', active: false)
+ describe "filter by status", :js do
+ it "shows correct runner when status matches" do
+ create(:ci_runner, description: "runner-active", active: true)
+ create(:ci_runner, description: "runner-paused", active: false)
visit admin_runners_path
- expect(page).to have_content 'runner-active'
- expect(page).to have_content 'runner-paused'
+ expect(page).to have_content "runner-active"
+ expect(page).to have_content "runner-paused"
- input_filtered_search_keys('status:active')
- expect(page).to have_content 'runner-active'
- expect(page).not_to have_content 'runner-paused'
+ input_filtered_search_keys("status:active")
+ expect(page).to have_content "runner-active"
+ expect(page).not_to have_content "runner-paused"
end
- it 'shows no runner when status does not match' do
- create(:ci_runner, :online, description: 'runner-active', active: true)
- create(:ci_runner, :online, description: 'runner-paused', active: false)
+ it "shows no runner when status does not match" do
+ create(:ci_runner, :online, description: "runner-active", active: true)
+ create(:ci_runner, :online, description: "runner-paused", active: false)
visit admin_runners_path
- input_filtered_search_keys('status:offline')
+ input_filtered_search_keys("status:offline")
- expect(page).not_to have_content 'runner-active'
- expect(page).not_to have_content 'runner-paused'
+ expect(page).not_to have_content "runner-active"
+ expect(page).not_to have_content "runner-paused"
- expect(page).to have_text 'No runners found'
+ expect(page).to have_text "No runners found"
end
- it 'shows correct runner when status is selected and search term is entered' do
- create(:ci_runner, description: 'runner-a-1', active: true)
- create(:ci_runner, description: 'runner-a-2', active: false)
- create(:ci_runner, description: 'runner-b-1', active: true)
+ it "shows correct runner when status is selected and search term is entered" do
+ create(:ci_runner, description: "runner-a-1", active: true)
+ create(:ci_runner, description: "runner-a-2", active: false)
+ create(:ci_runner, description: "runner-b-1", active: true)
visit admin_runners_path
- input_filtered_search_keys('status:active')
- expect(page).to have_content 'runner-a-1'
- expect(page).to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ input_filtered_search_keys("status:active")
+ expect(page).to have_content "runner-a-1"
+ expect(page).to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
- input_filtered_search_keys('status:active runner-a')
- expect(page).to have_content 'runner-a-1'
- expect(page).not_to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ input_filtered_search_keys("status:active runner-a")
+ expect(page).to have_content "runner-a-1"
+ expect(page).not_to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
end
end
- describe 'filter by type', :js do
- it 'shows correct runner when type matches' do
- create :ci_runner, :project, description: 'runner-project'
- create :ci_runner, :group, description: 'runner-group'
+ describe "filter by type", :js do
+ it "shows correct runner when type matches" do
+ create :ci_runner, :project, description: "runner-project"
+ create :ci_runner, :group, description: "runner-group"
visit admin_runners_path
- expect(page).to have_content 'runner-project'
- expect(page).to have_content 'runner-group'
+ expect(page).to have_content "runner-project"
+ expect(page).to have_content "runner-group"
- input_filtered_search_keys('type:project_type')
- expect(page).to have_content 'runner-project'
- expect(page).not_to have_content 'runner-group'
+ input_filtered_search_keys("type:project_type")
+ expect(page).to have_content "runner-project"
+ expect(page).not_to have_content "runner-group"
end
- it 'shows no runner when type does not match' do
- create :ci_runner, :project, description: 'runner-project'
- create :ci_runner, :group, description: 'runner-group'
+ it "shows no runner when type does not match" do
+ create :ci_runner, :project, description: "runner-project"
+ create :ci_runner, :group, description: "runner-group"
visit admin_runners_path
- input_filtered_search_keys('type:instance_type')
+ input_filtered_search_keys("type:instance_type")
- expect(page).not_to have_content 'runner-project'
- expect(page).not_to have_content 'runner-group'
+ expect(page).not_to have_content "runner-project"
+ expect(page).not_to have_content "runner-group"
- expect(page).to have_text 'No runners found'
+ expect(page).to have_text "No runners found"
end
- it 'shows correct runner when type is selected and search term is entered' do
- create :ci_runner, :project, description: 'runner-a-1'
- create :ci_runner, :instance, description: 'runner-a-2'
- create :ci_runner, :project, description: 'runner-b-1'
+ it "shows correct runner when type is selected and search term is entered" do
+ create :ci_runner, :project, description: "runner-a-1"
+ create :ci_runner, :instance, description: "runner-a-2"
+ create :ci_runner, :project, description: "runner-b-1"
visit admin_runners_path
- input_filtered_search_keys('type:project_type')
- expect(page).to have_content 'runner-a-1'
- expect(page).to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ input_filtered_search_keys("type:project_type")
+ expect(page).to have_content "runner-a-1"
+ expect(page).to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
- input_filtered_search_keys('type:project_type runner-a')
- expect(page).to have_content 'runner-a-1'
- expect(page).not_to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ input_filtered_search_keys("type:project_type runner-a")
+ expect(page).to have_content "runner-a-1"
+ expect(page).not_to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
end
end
- describe 'filter by tag', :js do
- it 'shows correct runner when tag matches' do
- create :ci_runner, description: 'runner-blue', tag_list: ['blue']
- create :ci_runner, description: 'runner-red', tag_list: ['red']
+ describe "filter by tag", :js do
+ it "shows correct runner when tag matches" do
+ create :ci_runner, description: "runner-blue", tag_list: ["blue"]
+ create :ci_runner, description: "runner-red", tag_list: ["red"]
visit admin_runners_path
- expect(page).to have_content 'runner-blue'
- expect(page).to have_content 'runner-red'
+ expect(page).to have_content "runner-blue"
+ expect(page).to have_content "runner-red"
- input_filtered_search_keys('tag:blue')
+ input_filtered_search_keys("tag:blue")
- expect(page).to have_content 'runner-blue'
- expect(page).not_to have_content 'runner-red'
+ expect(page).to have_content "runner-blue"
+ expect(page).not_to have_content "runner-red"
end
- it 'shows no runner when tag does not match' do
- create :ci_runner, description: 'runner-blue', tag_list: ['blue']
- create :ci_runner, description: 'runner-red', tag_list: ['blue']
+ it "shows no runner when tag does not match" do
+ create :ci_runner, description: "runner-blue", tag_list: ["blue"]
+ create :ci_runner, description: "runner-red", tag_list: ["blue"]
visit admin_runners_path
- input_filtered_search_keys('tag:red')
+ input_filtered_search_keys("tag:red")
- expect(page).not_to have_content 'runner-blue'
- expect(page).not_to have_content 'runner-blue'
- expect(page).to have_text 'No runners found'
+ expect(page).not_to have_content "runner-blue"
+ expect(page).not_to have_content "runner-blue"
+ expect(page).to have_text "No runners found"
end
- it 'shows correct runner when tag is selected and search term is entered' do
- create :ci_runner, description: 'runner-a-1', tag_list: ['blue']
- create :ci_runner, description: 'runner-a-2', tag_list: ['red']
- create :ci_runner, description: 'runner-b-1', tag_list: ['blue']
+ it "shows correct runner when tag is selected and search term is entered" do
+ create :ci_runner, description: "runner-a-1", tag_list: ["blue"]
+ create :ci_runner, description: "runner-a-2", tag_list: ["red"]
+ create :ci_runner, description: "runner-b-1", tag_list: ["blue"]
visit admin_runners_path
- input_filtered_search_keys('tag:blue')
+ input_filtered_search_keys("tag:blue")
- expect(page).to have_content 'runner-a-1'
- expect(page).to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ expect(page).to have_content "runner-a-1"
+ expect(page).to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
- input_filtered_search_keys('tag:blue runner-a')
+ input_filtered_search_keys("tag:blue runner-a")
- expect(page).to have_content 'runner-a-1'
- expect(page).not_to have_content 'runner-b-1'
- expect(page).not_to have_content 'runner-a-2'
+ expect(page).to have_content "runner-a-1"
+ expect(page).not_to have_content "runner-b-1"
+ expect(page).not_to have_content "runner-a-2"
end
end
- it 'sorts by last contact date', :js do
- create(:ci_runner, description: 'runner-1', created_at: '2018-07-12 15:37', contacted_at: '2018-07-12 15:37')
- create(:ci_runner, description: 'runner-2', created_at: '2018-07-12 16:37', contacted_at: '2018-07-12 16:37')
+ it "sorts by last contact date", :js do
+ create(:ci_runner, description: "runner-1", created_at: "2018-07-12 15:37", contacted_at: "2018-07-12 15:37")
+ create(:ci_runner, description: "runner-2", created_at: "2018-07-12 16:37", contacted_at: "2018-07-12 16:37")
visit admin_runners_path
- within '.runners-content .gl-responsive-table-row:nth-child(2)' do
- expect(page).to have_content 'runner-2'
+ within ".runners-content .gl-responsive-table-row:nth-child(2)" do
+ expect(page).to have_content "runner-2"
end
- within '.runners-content .gl-responsive-table-row:nth-child(3)' do
- expect(page).to have_content 'runner-1'
+ within ".runners-content .gl-responsive-table-row:nth-child(3)" do
+ expect(page).to have_content "runner-1"
end
- sorting_by 'Last Contact'
+ sorting_by "Last Contact"
- within '.runners-content .gl-responsive-table-row:nth-child(2)' do
- expect(page).to have_content 'runner-1'
+ within ".runners-content .gl-responsive-table-row:nth-child(2)" do
+ expect(page).to have_content "runner-1"
end
- within '.runners-content .gl-responsive-table-row:nth-child(3)' do
- expect(page).to have_content 'runner-2'
+ within ".runners-content .gl-responsive-table-row:nth-child(3)" do
+ expect(page).to have_content "runner-2"
end
end
end
@@ -222,50 +222,50 @@ describe "Admin Runners" do
visit admin_runners_path
end
- it 'has all necessary texts including no runner message' do
+ it "has all necessary texts including no runner message" do
expect(page).to have_text "Set up a shared Runner manually"
expect(page).to have_text "Runners currently online: 0"
- expect(page).to have_text 'No runners found'
+ expect(page).to have_text "No runners found"
end
end
- context 'group runner' do
+ context "group runner" do
let(:group) { create(:group) }
let!(:runner) { create(:ci_runner, :group, groups: [group]) }
- it 'shows the label and does not show the project count' do
+ it "shows the label and does not show the project count" do
visit admin_runners_path
within "#runner_#{runner.id}" do
- expect(page).to have_selector '.badge', text: 'group'
- expect(page).to have_text 'n/a'
+ expect(page).to have_selector ".badge", text: "group"
+ expect(page).to have_text "n/a"
end
end
end
- context 'shared runner' do
- it 'shows the label and does not show the project count' do
+ context "shared runner" do
+ it "shows the label and does not show the project count" do
runner = create(:ci_runner, :instance)
visit admin_runners_path
within "#runner_#{runner.id}" do
- expect(page).to have_selector '.badge', text: 'shared'
- expect(page).to have_text 'n/a'
+ expect(page).to have_selector ".badge", text: "shared"
+ expect(page).to have_text "n/a"
end
end
end
- context 'specific runner' do
- it 'shows the label and the project count' do
+ context "specific runner" do
+ it "shows the label and the project count" do
project = create(:project)
runner = create(:ci_runner, :project, projects: [project])
visit admin_runners_path
within "#runner_#{runner.id}" do
- expect(page).to have_selector '.badge', text: 'specific'
- expect(page).to have_text '1'
+ expect(page).to have_selector ".badge", text: "specific"
+ expect(page).to have_text "1"
end
end
end
@@ -280,64 +280,64 @@ describe "Admin Runners" do
visit admin_runner_path(runner)
end
- describe 'runner info' do
- it { expect(find_field('runner_token').value).to eq runner.token }
+ describe "runner info" do
+ it { expect(find_field("runner_token").value).to eq runner.token }
end
- describe 'projects' do
- it 'contains project names' do
+ describe "projects" do
+ it "contains project names" do
expect(page).to have_content(@project1.full_name)
expect(page).to have_content(@project2.full_name)
end
end
- describe 'search' do
+ describe "search" do
before do
- search_form = find('#runner-projects-search')
- search_form.fill_in 'search', with: @project1.name
- search_form.click_button 'Search'
+ search_form = find("#runner-projects-search")
+ search_form.fill_in "search", with: @project1.name
+ search_form.click_button "Search"
end
- it 'contains name of correct project' do
+ it "contains name of correct project" do
expect(page).to have_content(@project1.full_name)
expect(page).not_to have_content(@project2.full_name)
end
end
- describe 'enable/create' do
- shared_examples 'assignable runner' do
- it 'enables a runner for a project' do
- within '.unassigned-projects' do
- click_on 'Enable'
+ describe "enable/create" do
+ shared_examples "assignable runner" do
+ it "enables a runner for a project" do
+ within ".unassigned-projects" do
+ click_on "Enable"
end
- assigned_project = page.find('.assigned-projects')
+ assigned_project = page.find(".assigned-projects")
expect(assigned_project).to have_content(@project2.path)
end
end
- context 'with specific runner' do
+ context "with specific runner" do
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
before do
visit admin_runner_path(runner)
end
- it_behaves_like 'assignable runner'
+ it_behaves_like "assignable runner"
end
- context 'with locked runner' do
+ context "with locked runner" do
let(:runner) { create(:ci_runner, :project, projects: [@project1], locked: true) }
before do
visit admin_runner_path(runner)
end
- it_behaves_like 'assignable runner'
+ it_behaves_like "assignable runner"
end
- context 'with shared runner' do
+ context "with shared runner" do
let(:runner) { create(:ci_runner, :instance) }
before do
@@ -345,48 +345,48 @@ describe "Admin Runners" do
visit admin_runner_path(runner)
end
- it_behaves_like 'assignable runner'
+ it_behaves_like "assignable runner"
end
end
- describe 'disable/destroy' do
+ describe "disable/destroy" do
let(:runner) { create(:ci_runner, :project, projects: [@project1]) }
before do
visit admin_runner_path(runner)
end
- it 'enables specific runner for project' do
- within '.assigned-projects' do
- click_on 'Disable'
+ it "enables specific runner for project" do
+ within ".assigned-projects" do
+ click_on "Disable"
end
- new_runner_project = page.find('.unassigned-projects')
+ new_runner_project = page.find(".unassigned-projects")
expect(new_runner_project).to have_content(@project1.path)
end
end
end
- describe 'runners registration token' do
+ describe "runners registration token" do
let!(:token) { Gitlab::CurrentSettings.runners_registration_token }
before do
visit admin_runners_path
end
- it 'has a registration token' do
- expect(page.find('#registration_token')).to have_content(token)
+ it "has a registration token" do
+ expect(page.find("#registration_token")).to have_content(token)
end
- describe 'reload registration token' do
- let(:page_token) { find('#registration_token').text }
+ describe "reload registration token" do
+ let(:page_token) { find("#registration_token").text }
before do
- click_button 'Reset runners registration token'
+ click_button "Reset runners registration token"
end
- it 'changes registration token' do
+ it "changes registration token" do
expect(page_token).not_to eq token
end
end
diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb
index 04f39b807d7..f295a3d8567 100644
--- a/spec/features/admin/admin_settings_spec.rb
+++ b/spec/features/admin/admin_settings_spec.rb
@@ -1,190 +1,190 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin updates settings' do
+describe "Admin updates settings" do
include StubENV
include TermsHelper
let(:admin) { create(:admin) }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(admin)
end
- context 'General page' do
+ context "General page" do
before do
visit admin_application_settings_path
end
- it 'Change visibility settings' do
- page.within('.as-visibility-access') do
+ it "Change visibility settings" do
+ page.within(".as-visibility-access") do
choose "application_setting_default_project_visibility_20"
- click_button 'Save changes'
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
end
- it 'Uncheck all restricted visibility levels' do
- page.within('.as-visibility-access') do
- find('#application_setting_visibility_level_0').set(false)
- find('#application_setting_visibility_level_10').set(false)
- find('#application_setting_visibility_level_20').set(false)
- click_button 'Save changes'
+ it "Uncheck all restricted visibility levels" do
+ page.within(".as-visibility-access") do
+ find("#application_setting_visibility_level_0").set(false)
+ find("#application_setting_visibility_level_10").set(false)
+ find("#application_setting_visibility_level_20").set(false)
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(find('#application_setting_visibility_level_0')).not_to be_checked
- expect(find('#application_setting_visibility_level_10')).not_to be_checked
- expect(find('#application_setting_visibility_level_20')).not_to be_checked
+ expect(find("#application_setting_visibility_level_0")).not_to be_checked
+ expect(find("#application_setting_visibility_level_10")).not_to be_checked
+ expect(find("#application_setting_visibility_level_20")).not_to be_checked
end
- it 'Modify import sources' do
+ it "Modify import sources" do
expect(Gitlab::CurrentSettings.import_sources).not_to be_empty
- page.within('.as-visibility-access') do
+ page.within(".as-visibility-access") do
Gitlab::ImportSources.options.map do |name, _|
uncheck name
end
- click_button 'Save changes'
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
expect(Gitlab::CurrentSettings.import_sources).to be_empty
- page.within('.as-visibility-access') do
+ page.within(".as-visibility-access") do
check "Repo by URL"
- click_button 'Save changes'
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(Gitlab::CurrentSettings.import_sources).to eq(['git'])
+ expect(Gitlab::CurrentSettings.import_sources).to eq(["git"])
end
- it 'Change Visibility and Access Controls' do
- page.within('.as-visibility-access') do
- uncheck 'Project export enabled'
- click_button 'Save changes'
+ it "Change Visibility and Access Controls" do
+ page.within(".as-visibility-access") do
+ uncheck "Project export enabled"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.project_export_enabled).to be_falsey
expect(page).to have_content "Application settings saved successfully"
end
- it 'Change Keys settings' do
- page.within('.as-visibility-access') do
- select 'Are forbidden', from: 'RSA SSH keys'
- select 'Are allowed', from: 'DSA SSH keys'
- select 'Must be at least 384 bits', from: 'ECDSA SSH keys'
- select 'Are forbidden', from: 'ED25519 SSH keys'
- click_on 'Save changes'
+ it "Change Keys settings" do
+ page.within(".as-visibility-access") do
+ select "Are forbidden", from: "RSA SSH keys"
+ select "Are allowed", from: "DSA SSH keys"
+ select "Must be at least 384 bits", from: "ECDSA SSH keys"
+ select "Are forbidden", from: "ED25519 SSH keys"
+ click_on "Save changes"
end
forbidden = ApplicationSetting::FORBIDDEN_KEY_VALUE.to_s
- expect(page).to have_content 'Application settings saved successfully'
- expect(find_field('RSA SSH keys').value).to eq(forbidden)
- expect(find_field('DSA SSH keys').value).to eq('0')
- expect(find_field('ECDSA SSH keys').value).to eq('384')
- expect(find_field('ED25519 SSH keys').value).to eq(forbidden)
+ expect(page).to have_content "Application settings saved successfully"
+ expect(find_field("RSA SSH keys").value).to eq(forbidden)
+ expect(find_field("DSA SSH keys").value).to eq("0")
+ expect(find_field("ECDSA SSH keys").value).to eq("384")
+ expect(find_field("ED25519 SSH keys").value).to eq(forbidden)
end
- it 'Change Account and Limit Settings' do
- page.within('.as-account-limit') do
- uncheck 'Gravatar enabled'
- click_button 'Save changes'
+ it "Change Account and Limit Settings" do
+ page.within(".as-account-limit") do
+ uncheck "Gravatar enabled"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.gravatar_enabled).to be_falsey
expect(page).to have_content "Application settings saved successfully"
end
- it 'Change New users set to external', :js do
- user_internal_regex = find('#application_setting_user_default_internal_regex', visible: :all)
+ it "Change New users set to external", :js do
+ user_internal_regex = find("#application_setting_user_default_internal_regex", visible: :all)
expect(user_internal_regex).to be_readonly
- expect(user_internal_regex['placeholder']).to eq 'To define internal users, first enable new users set to external'
+ expect(user_internal_regex["placeholder"]).to eq "To define internal users, first enable new users set to external"
- check 'application_setting_user_default_external'
+ check "application_setting_user_default_external"
expect(user_internal_regex).not_to be_readonly
- expect(user_internal_regex['placeholder']).to eq 'Regex pattern'
+ expect(user_internal_regex["placeholder"]).to eq "Regex pattern"
end
- it 'Change Sign-in restrictions' do
- page.within('.as-signin') do
- fill_in 'Home page URL', with: 'https://about.gitlab.com/'
- click_button 'Save changes'
+ it "Change Sign-in restrictions" do
+ page.within(".as-signin") do
+ fill_in "Home page URL", with: "https://about.gitlab.com/"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.home_page_url).to eq "https://about.gitlab.com/"
expect(page).to have_content "Application settings saved successfully"
end
- it 'Terms of Service' do
+ it "Terms of Service" do
# Already have the admin accept terms, so they don't need to accept in this spec.
_existing_terms = create(:term)
accept_terms(admin)
- page.within('.as-terms') do
- check 'Require all users to accept Terms of Service and Privacy Policy when they access GitLab.'
- fill_in 'Terms of Service Agreement', with: 'Be nice!'
- click_button 'Save changes'
+ page.within(".as-terms") do
+ check "Require all users to accept Terms of Service and Privacy Policy when they access GitLab."
+ fill_in "Terms of Service Agreement", with: "Be nice!"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.enforce_terms).to be(true)
- expect(Gitlab::CurrentSettings.terms).to eq 'Be nice!'
- expect(page).to have_content 'Application settings saved successfully'
+ expect(Gitlab::CurrentSettings.terms).to eq "Be nice!"
+ expect(page).to have_content "Application settings saved successfully"
end
- it 'Modify oauth providers' do
+ it "Modify oauth providers" do
expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to be_empty
- page.within('.as-signin') do
- uncheck 'Google'
- click_button 'Save changes'
+ page.within(".as-signin") do
+ uncheck "Google"
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include('google_oauth2')
+ expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include("google_oauth2")
- page.within('.as-signin') do
+ page.within(".as-signin") do
check "Google"
- click_button 'Save changes'
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).not_to include('google_oauth2')
+ expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).not_to include("google_oauth2")
end
- it 'Oauth providers do not raise validation errors when saving unrelated changes' do
+ it "Oauth providers do not raise validation errors when saving unrelated changes" do
expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to be_empty
- page.within('.as-signin') do
- uncheck 'Google'
- click_button 'Save changes'
+ page.within(".as-signin") do
+ uncheck "Google"
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include('google_oauth2')
+ expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include("google_oauth2")
# Remove google_oauth2 from the Omniauth strategies
allow(Devise).to receive(:omniauth_providers).and_return([])
# Save an unrelated setting
- page.within('.as-terms') do
- click_button 'Save changes'
+ page.within(".as-terms") do
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include('google_oauth2')
+ expect(Gitlab::CurrentSettings.disabled_oauth_sign_in_sources).to include("google_oauth2")
end
- it 'Configure web terminal' do
- page.within('.as-terminal') do
- fill_in 'Max session time', with: 15
- click_button 'Save changes'
+ it "Configure web terminal" do
+ page.within(".as-terminal") do
+ fill_in "Max session time", with: 15
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
@@ -192,72 +192,72 @@ describe 'Admin updates settings' do
end
end
- context 'Integrations page' do
+ context "Integrations page" do
before do
visit integrations_admin_application_settings_path
end
- it 'Enable hiding third party offers' do
- page.within('.as-third-party-offers') do
- check 'Do not display offers from third parties within GitLab'
- click_button 'Save changes'
+ it "Enable hiding third party offers" do
+ page.within(".as-third-party-offers") do
+ check "Do not display offers from third parties within GitLab"
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
expect(Gitlab::CurrentSettings.hide_third_party_offers).to be true
end
- it 'Change Slack Notifications Service template settings' do
- first(:link, 'Service Templates').click
- click_link 'Slack notifications'
- fill_in 'Webhook', with: 'http://localhost'
- fill_in 'Username', with: 'test_user'
- fill_in 'service_push_channel', with: '#test_channel'
- page.check('Notify only broken pipelines')
- page.check('Notify only default branch')
+ it "Change Slack Notifications Service template settings" do
+ first(:link, "Service Templates").click
+ click_link "Slack notifications"
+ fill_in "Webhook", with: "http://localhost"
+ fill_in "Username", with: "test_user"
+ fill_in "service_push_channel", with: "#test_channel"
+ page.check("Notify only broken pipelines")
+ page.check("Notify only default branch")
check_all_events
- click_on 'Save'
+ click_on "Save"
- expect(page).to have_content 'Application settings saved successfully'
+ expect(page).to have_content "Application settings saved successfully"
- click_link 'Slack notifications'
+ click_link "Slack notifications"
- page.all('input[type=checkbox]').each do |checkbox|
+ page.all("input[type=checkbox]").each do |checkbox|
expect(checkbox).to be_checked
end
- expect(find_field('Webhook').value).to eq 'http://localhost'
- expect(find_field('Username').value).to eq 'test_user'
- expect(find('#service_push_channel').value).to eq '#test_channel'
+ expect(find_field("Webhook").value).to eq "http://localhost"
+ expect(find_field("Username").value).to eq "test_user"
+ expect(find("#service_push_channel").value).to eq "#test_channel"
end
end
- context 'CI/CD page' do
- it 'Change CI/CD settings' do
+ context "CI/CD page" do
+ it "Change CI/CD settings" do
visit ci_cd_admin_application_settings_path
- page.within('.as-ci-cd') do
- check 'Default to Auto DevOps pipeline for all projects'
- fill_in 'application_setting_auto_devops_domain', with: 'domain.com'
- click_button 'Save changes'
+ page.within(".as-ci-cd") do
+ check "Default to Auto DevOps pipeline for all projects"
+ fill_in "application_setting_auto_devops_domain", with: "domain.com"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.auto_devops_enabled?).to be true
- expect(Gitlab::CurrentSettings.auto_devops_domain).to eq('domain.com')
+ expect(Gitlab::CurrentSettings.auto_devops_domain).to eq("domain.com")
expect(page).to have_content "Application settings saved successfully"
end
end
- context 'Reporting page' do
- it 'Change Spam settings' do
+ context "Reporting page" do
+ it "Change Spam settings" do
visit reporting_admin_application_settings_path
- page.within('.as-spam') do
- check 'Enable reCAPTCHA'
- fill_in 'reCAPTCHA Site Key', with: 'key'
- fill_in 'reCAPTCHA Private Key', with: 'key'
- fill_in 'IPs per user', with: 15
- click_button 'Save changes'
+ page.within(".as-spam") do
+ check "Enable reCAPTCHA"
+ fill_in "reCAPTCHA Site Key", with: "key"
+ fill_in "reCAPTCHA Private Key", with: "key"
+ fill_in "IPs per user", with: 15
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
@@ -266,71 +266,71 @@ describe 'Admin updates settings' do
end
end
- context 'Metrics and profiling page' do
+ context "Metrics and profiling page" do
before do
visit metrics_and_profiling_admin_application_settings_path
end
- it 'Change Influx settings' do
- page.within('.as-influx') do
- check 'Enable InfluxDB Metrics'
- click_button 'Save changes'
+ it "Change Influx settings" do
+ page.within(".as-influx") do
+ check "Enable InfluxDB Metrics"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.metrics_enabled?).to be true
expect(page).to have_content "Application settings saved successfully"
end
- it 'Change Prometheus settings' do
- page.within('.as-prometheus') do
- check 'Enable Prometheus Metrics'
- click_button 'Save changes'
+ it "Change Prometheus settings" do
+ page.within(".as-prometheus") do
+ check "Enable Prometheus Metrics"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.prometheus_metrics_enabled?).to be true
expect(page).to have_content "Application settings saved successfully"
end
- it 'Change Performance bar settings' do
+ it "Change Performance bar settings" do
group = create(:group)
- page.within('.as-performance-bar') do
- check 'Enable the Performance Bar'
- fill_in 'Allowed group', with: group.path
- click_on 'Save changes'
+ page.within(".as-performance-bar") do
+ check "Enable the Performance Bar"
+ fill_in "Allowed group", with: group.path
+ click_on "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
- expect(find_field('Enable the Performance Bar')).to be_checked
- expect(find_field('Allowed group').value).to eq group.path
+ expect(find_field("Enable the Performance Bar")).to be_checked
+ expect(find_field("Allowed group").value).to eq group.path
- page.within('.as-performance-bar') do
- uncheck 'Enable the Performance Bar'
- click_on 'Save changes'
+ page.within(".as-performance-bar") do
+ uncheck "Enable the Performance Bar"
+ click_on "Save changes"
end
- expect(page).to have_content 'Application settings saved successfully'
- expect(find_field('Enable the Performance Bar')).not_to be_checked
- expect(find_field('Allowed group').value).to be_nil
+ expect(page).to have_content "Application settings saved successfully"
+ expect(find_field("Enable the Performance Bar")).not_to be_checked
+ expect(find_field("Allowed group").value).to be_nil
end
- it 'loads usage ping payload on click', :js do
- expect(page).to have_button 'Preview payload'
+ it "loads usage ping payload on click", :js do
+ expect(page).to have_button "Preview payload"
- find('.js-usage-ping-payload-trigger').click
+ find(".js-usage-ping-payload-trigger").click
- expect(page).to have_selector '.js-usage-ping-payload'
- expect(page).to have_button 'Hide payload'
+ expect(page).to have_selector ".js-usage-ping-payload"
+ expect(page).to have_button "Hide payload"
end
end
- context 'Network page' do
- it 'Enable outbound requests' do
+ context "Network page" do
+ it "Enable outbound requests" do
visit network_admin_application_settings_path
- page.within('.as-outbound') do
- check 'Allow requests to the local network from hooks and services'
- click_button 'Save changes'
+ page.within(".as-outbound") do
+ check "Allow requests to the local network from hooks and services"
+ click_button "Save changes"
end
expect(page).to have_content "Application settings saved successfully"
@@ -338,17 +338,17 @@ describe 'Admin updates settings' do
end
end
- context 'Preferences page' do
+ context "Preferences page" do
before do
visit preferences_admin_application_settings_path
end
- it 'Change Help page' do
- page.within('.as-help-page') do
- fill_in 'Help page text', with: 'Example text'
- check 'Hide marketing-related entries from help'
- fill_in 'Support page URL', with: 'http://example.com/help'
- click_button 'Save changes'
+ it "Change Help page" do
+ page.within(".as-help-page") do
+ fill_in "Help page text", with: "Example text"
+ check "Hide marketing-related entries from help"
+ fill_in "Support page URL", with: "http://example.com/help"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.help_page_text).to eq "Example text"
@@ -357,11 +357,11 @@ describe 'Admin updates settings' do
expect(page).to have_content "Application settings saved successfully"
end
- it 'Change Pages settings' do
- page.within('.as-pages') do
- fill_in 'Maximum size of pages (MB)', with: 15
- check 'Require users to prove ownership of custom domains'
- click_button 'Save changes'
+ it "Change Pages settings" do
+ page.within(".as-pages") do
+ fill_in "Maximum size of pages (MB)", with: 15
+ check "Require users to prove ownership of custom domains"
+ click_button "Save changes"
end
expect(Gitlab::CurrentSettings.max_pages_size).to eq 15
@@ -371,12 +371,12 @@ describe 'Admin updates settings' do
end
def check_all_events
- page.check('Active')
- page.check('Push')
- page.check('Tag push')
- page.check('Note')
- page.check('Issue')
- page.check('Merge request')
- page.check('Pipeline')
+ page.check("Active")
+ page.check("Push")
+ page.check("Tag push")
+ page.check("Note")
+ page.check("Issue")
+ page.check("Merge request")
+ page.check("Pipeline")
end
end
diff --git a/spec/features/admin/admin_system_info_spec.rb b/spec/features/admin/admin_system_info_spec.rb
index 5a989319d5b..c8e78bec107 100644
--- a/spec/features/admin/admin_system_info_spec.rb
+++ b/spec/features/admin/admin_system_info_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin System Info' do
+describe "Admin System Info" do
before do
sign_in(create(:admin))
end
- describe 'GET /admin/system_info' do
+ describe "GET /admin/system_info" do
let(:cpu) { double(:cpu, length: 2) }
let(:memory) { double(:memory, active_bytes: 4294967296, total_bytes: 17179869184) }
- context 'when all info is available' do
+ context "when all info is available" do
before do
allow(Vmstat).to receive(:cpu).and_return(cpu)
allow(Vmstat).to receive(:memory).and_return(memory)
visit admin_system_info_path
end
- it 'shows system info page' do
- expect(page).to have_content 'CPU 2 cores'
- expect(page).to have_content 'Memory Usage 4 GB / 16 GB'
- expect(page).to have_content 'Disk Usage'
- expect(page).to have_content 'Uptime'
+ it "shows system info page" do
+ expect(page).to have_content "CPU 2 cores"
+ expect(page).to have_content "Memory Usage 4 GB / 16 GB"
+ expect(page).to have_content "Disk Usage"
+ expect(page).to have_content "Uptime"
end
end
- context 'when CPU info is not available' do
+ context "when CPU info is not available" do
before do
allow(Vmstat).to receive(:cpu).and_raise(Errno::ENOENT)
allow(Vmstat).to receive(:memory).and_return(memory)
visit admin_system_info_path
end
- it 'shows system info page with no CPU info' do
- expect(page).to have_content 'CPU Unable to collect CPU info'
- expect(page).to have_content 'Memory Usage 4 GB / 16 GB'
- expect(page).to have_content 'Disk Usage'
- expect(page).to have_content 'Uptime'
+ it "shows system info page with no CPU info" do
+ expect(page).to have_content "CPU Unable to collect CPU info"
+ expect(page).to have_content "Memory Usage 4 GB / 16 GB"
+ expect(page).to have_content "Disk Usage"
+ expect(page).to have_content "Uptime"
end
end
- context 'when memory info is not available' do
+ context "when memory info is not available" do
before do
allow(Vmstat).to receive(:cpu).and_return(cpu)
allow(Vmstat).to receive(:memory).and_raise(Errno::ENOENT)
visit admin_system_info_path
end
- it 'shows system info page with no CPU info' do
- expect(page).to have_content 'CPU 2 cores'
- expect(page).to have_content 'Memory Usage Unable to collect memory info'
- expect(page).to have_content 'Disk Usage'
- expect(page).to have_content 'Uptime'
+ it "shows system info page with no CPU info" do
+ expect(page).to have_content "CPU 2 cores"
+ expect(page).to have_content "Memory Usage Unable to collect memory info"
+ expect(page).to have_content "Disk Usage"
+ expect(page).to have_content "Uptime"
end
end
end
diff --git a/spec/features/admin/admin_users_impersonation_tokens_spec.rb b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
index c7860bebb06..5ccfe7c23e7 100644
--- a/spec/features/admin/admin_users_impersonation_tokens_spec.rb
+++ b/spec/features/admin/admin_users_impersonation_tokens_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin > Users > Impersonation Tokens', :js do
+describe "Admin > Users > Impersonation Tokens", :js do
let(:admin) { create(:admin) }
let!(:user) { create(:user) }
@@ -22,7 +22,7 @@ describe 'Admin > Users > Impersonation Tokens', :js do
describe "token creation" do
it "allows creation of a token" do
- name = 'Hello World'
+ name = "Hello World"
visit admin_user_impersonation_tokens_path(user_id: user.username)
fill_in "Name", with: name
@@ -39,19 +39,19 @@ describe 'Admin > Users > Impersonation Tokens', :js do
click_on "Create impersonation token"
expect(active_impersonation_tokens).to have_text(name)
- expect(active_impersonation_tokens).to have_text('In')
- expect(active_impersonation_tokens).to have_text('api')
- expect(active_impersonation_tokens).to have_text('read_user')
+ expect(active_impersonation_tokens).to have_text("In")
+ expect(active_impersonation_tokens).to have_text("api")
+ expect(active_impersonation_tokens).to have_text("read_user")
expect(PersonalAccessTokensFinder.new(impersonation: true).execute.count).to equal(1)
expect(created_impersonation_token).not_to be_empty
end
end
- describe 'active tokens' do
+ describe "active tokens" do
let!(:impersonation_token) { create(:personal_access_token, :impersonation, user: user) }
let!(:personal_access_token) { create(:personal_access_token, user: user) }
- it 'only shows impersonation tokens' do
+ it "only shows impersonation tokens" do
visit admin_user_impersonation_tokens_path(user_id: user.username)
expect(active_impersonation_tokens).to have_text(impersonation_token.name)
diff --git a/spec/features/admin/admin_users_spec.rb b/spec/features/admin/admin_users_spec.rb
index b1c6f308bc6..877930d79c2 100644
--- a/spec/features/admin/admin_users_spec.rb
+++ b/spec/features/admin/admin_users_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin::Users" do
include Spec::Support::Helpers::Features::ResponsiveTableHelpers
let!(:user) do
- create(:omniauth_user, provider: 'twitter', extern_uid: '123456')
+ create(:omniauth_user, provider: "twitter", extern_uid: "123456")
end
let!(:current_user) { create(:admin, last_activity_on: 5.days.ago) }
@@ -29,119 +29,119 @@ describe "Admin::Users" do
expect(page).to have_content(current_user.last_activity_on.strftime("%e %b, %Y"))
expect(page).to have_content(user.email)
expect(page).to have_content(user.name)
- expect(page).to have_link('Block', href: block_admin_user_path(user))
- expect(page).to have_button('Delete user')
- expect(page).to have_button('Delete user and contributions')
+ expect(page).to have_link("Block", href: block_admin_user_path(user))
+ expect(page).to have_button("Delete user")
+ expect(page).to have_button("Delete user and contributions")
end
describe "view extra user information", :js do
- it 'does not have the user popover open' do
- expect(page).not_to have_selector('#__BV_popover_1__')
+ it "does not have the user popover open" do
+ expect(page).not_to have_selector("#__BV_popover_1__")
end
- it 'shows the user popover on hover' do
- first_user_link = page.first('.js-user-link')
+ it "shows the user popover on hover" do
+ first_user_link = page.first(".js-user-link")
first_user_link.hover
- expect(page).to have_selector('#__BV_popover_1__')
+ expect(page).to have_selector("#__BV_popover_1__")
end
end
- describe 'search and sort' do
+ describe "search and sort" do
before do
- create(:user, name: 'Foo Bar', last_activity_on: 3.days.ago)
- create(:user, name: 'Foo Baz', last_activity_on: 2.days.ago)
- create(:user, name: 'Dmitriy')
+ create(:user, name: "Foo Bar", last_activity_on: 3.days.ago)
+ create(:user, name: "Foo Baz", last_activity_on: 2.days.ago)
+ create(:user, name: "Dmitriy")
end
- it 'searches users by name' do
- visit admin_users_path(search_query: 'Foo')
+ it "searches users by name" do
+ visit admin_users_path(search_query: "Foo")
- expect(page).to have_content('Foo Bar')
- expect(page).to have_content('Foo Baz')
- expect(page).not_to have_content('Dmitriy')
+ expect(page).to have_content("Foo Bar")
+ expect(page).to have_content("Foo Baz")
+ expect(page).not_to have_content("Dmitriy")
end
- it 'sorts users by name' do
+ it "sorts users by name" do
visit admin_users_path
- sort_by('Name')
+ sort_by("Name")
- expect(first_row.text).to include('Dmitriy')
- expect(second_row.text).to include('Foo Bar')
+ expect(first_row.text).to include("Dmitriy")
+ expect(second_row.text).to include("Foo Bar")
end
- it 'sorts search results only' do
- visit admin_users_path(search_query: 'Foo')
+ it "sorts search results only" do
+ visit admin_users_path(search_query: "Foo")
- sort_by('Name')
+ sort_by("Name")
- expect(page).not_to have_content('Dmitriy')
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
+ expect(page).not_to have_content("Dmitriy")
+ expect(first_row.text).to include("Foo Bar")
+ expect(second_row.text).to include("Foo Baz")
end
- it 'searches with respect of sorting' do
- visit admin_users_path(sort: 'Name')
+ it "searches with respect of sorting" do
+ visit admin_users_path(sort: "Name")
- fill_in :search_query, with: 'Foo'
- click_button('Search users')
+ fill_in :search_query, with: "Foo"
+ click_button("Search users")
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
+ expect(first_row.text).to include("Foo Bar")
+ expect(second_row.text).to include("Foo Baz")
end
- it 'sorts users by recent last activity' do
- visit admin_users_path(search_query: 'Foo')
+ it "sorts users by recent last activity" do
+ visit admin_users_path(search_query: "Foo")
- sort_by('Recent last activity')
+ sort_by("Recent last activity")
- expect(first_row.text).to include('Foo Baz')
- expect(second_row.text).to include('Foo Bar')
+ expect(first_row.text).to include("Foo Baz")
+ expect(second_row.text).to include("Foo Bar")
end
- it 'sorts users by oldest last activity' do
- visit admin_users_path(search_query: 'Foo')
+ it "sorts users by oldest last activity" do
+ visit admin_users_path(search_query: "Foo")
- sort_by('Oldest last activity')
+ sort_by("Oldest last activity")
- expect(first_row.text).to include('Foo Bar')
- expect(second_row.text).to include('Foo Baz')
+ expect(first_row.text).to include("Foo Bar")
+ expect(second_row.text).to include("Foo Baz")
end
end
- describe 'Two-factor Authentication filters' do
- it 'counts users who have enabled 2FA' do
+ describe "Two-factor Authentication filters" do
+ it "counts users who have enabled 2FA" do
create(:user, :two_factor)
visit admin_users_path
- page.within('.filter-two-factor-enabled small') do
- expect(page).to have_content('1')
+ page.within(".filter-two-factor-enabled small") do
+ expect(page).to have_content("1")
end
end
- it 'filters by users who have enabled 2FA' do
+ it "filters by users who have enabled 2FA" do
user = create(:user, :two_factor)
visit admin_users_path
- click_link '2FA Enabled'
+ click_link "2FA Enabled"
expect(page).to have_content(user.email)
end
- it 'counts users who have not enabled 2FA' do
+ it "counts users who have not enabled 2FA" do
visit admin_users_path
- page.within('.filter-two-factor-disabled small') do
- expect(page).to have_content('2') # Including admin
+ page.within(".filter-two-factor-disabled small") do
+ expect(page).to have_content("2") # Including admin
end
end
- it 'filters by users who have not enabled 2FA' do
+ it "filters by users who have not enabled 2FA" do
visit admin_users_path
- click_link '2FA Disabled'
+ click_link "2FA Disabled"
expect(page).to have_content(user.email)
end
@@ -149,7 +149,7 @@ describe "Admin::Users" do
end
describe "GET /admin/users/new" do
- let(:user_username) { 'bang' }
+ let(:user_username) { "bang" }
before do
visit new_admin_user_path
@@ -164,7 +164,7 @@ describe "Admin::Users" do
it "applies defaults to user" do
click_button "Create user"
- user = User.find_by(username: 'bang')
+ user = User.find_by(username: "bang")
expect(user.projects_limit)
.to eq(Gitlab.config.gitlab.default_projects_limit)
expect(user.can_create_group)
@@ -173,9 +173,9 @@ describe "Admin::Users" 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')
+ user = User.find_by(username: "bang")
+ expect(user.name).to eq("Big Bang")
+ expect(user.email).to eq("bigbang@mail.com")
end
it "calls send mail" do
@@ -189,26 +189,26 @@ describe "Admin::Users" do
click_button "Create user"
end
- user = User.find_by(username: 'bang')
+ user = User.find_by(username: "bang")
email = ActionMailer::Base.deliveries.last
- expect(email.subject).to have_content('Account was created')
+ expect(email.subject).to have_content("Account was created")
expect(email.text_part.body).to have_content(user.email)
- expect(email.text_part.body).to have_content('password')
+ expect(email.text_part.body).to have_content("password")
end
- context 'username contains spaces' do
- let(:user_username) { 'Bing bang' }
+ context "username contains spaces" do
+ let(:user_username) { "Bing bang" }
it "doesn't create the user and shows an error message" do
expect { click_button "Create user" }.to change {User.count}.by(0)
- expect(page).to have_content('The form contains the following error')
- expect(page).to have_content('Username can contain only letters, digits')
+ expect(page).to have_content("The form contains the following error")
+ expect(page).to have_content("Username can contain only letters, digits")
end
end
- context 'with new users set to external enabled' do
- context 'with regex to match internal user email address set', :js do
+ context "with new users set to external enabled" do
+ context "with regex to match internal user email address set", :js do
before do
stub_application_setting(user_default_external: true)
stub_application_setting(user_default_internal_regex: '\.internal@')
@@ -217,50 +217,50 @@ describe "Admin::Users" do
end
def expects_external_to_be_checked
- expect(find('#user_external')).to be_checked
+ expect(find("#user_external")).to be_checked
end
def expects_external_to_be_unchecked
- expect(find('#user_external')).not_to be_checked
+ expect(find("#user_external")).not_to be_checked
end
def expects_warning_to_be_hidden
- expect(find('#warning_external_automatically_set', visible: :all)[:class]).to include 'hidden'
+ expect(find("#warning_external_automatically_set", visible: :all)[:class]).to include "hidden"
end
def expects_warning_to_be_shown
- expect(find('#warning_external_automatically_set')[:class]).not_to include 'hidden'
+ expect(find("#warning_external_automatically_set")[:class]).not_to include "hidden"
end
- it 'automatically unchecks external for matching email' do
+ it "automatically unchecks external for matching email" do
expects_external_to_be_checked
expects_warning_to_be_hidden
- fill_in 'user_email', with: 'test.internal@domain.ch'
+ fill_in "user_email", with: "test.internal@domain.ch"
expects_external_to_be_unchecked
expects_warning_to_be_shown
- fill_in 'user_email', with: 'test@domain.ch'
+ fill_in "user_email", with: "test@domain.ch"
expects_external_to_be_checked
expects_warning_to_be_hidden
- uncheck 'user_external'
+ uncheck "user_external"
expects_warning_to_be_hidden
end
- it 'creates an internal user' do
- user_name = 'tester1'
- fill_in 'user_email', with: 'test.internal@domain.ch'
- fill_in 'user_name', with: 'tester1 name'
- fill_in 'user_username', with: user_name
+ it "creates an internal user" do
+ user_name = "tester1"
+ fill_in "user_email", with: "test.internal@domain.ch"
+ fill_in "user_name", with: "tester1 name"
+ fill_in "user_username", with: user_name
expects_external_to_be_unchecked
expects_warning_to_be_shown
- click_button 'Create user'
+ click_button "Create user"
new_user = User.find_by(username: user_name)
@@ -278,121 +278,121 @@ describe "Admin::Users" do
expect(page).to have_content(user.email)
expect(page).to have_content(user.name)
expect(page).to have_content(user.id)
- expect(page).to have_link('Block user', href: block_admin_user_path(user))
- expect(page).to have_button('Delete user')
- expect(page).to have_button('Delete user and contributions')
+ expect(page).to have_link("Block user", href: block_admin_user_path(user))
+ expect(page).to have_button("Delete user")
+ expect(page).to have_button("Delete user and contributions")
end
- describe 'Impersonation' do
+ describe "Impersonation" do
let(:another_user) { create(:user) }
- context 'before impersonating' do
+ context "before impersonating" do
subject { visit admin_user_path(user_to_visit) }
let(:user_to_visit) { another_user }
- context 'for other users' do
- it 'shows impersonate button for other users' do
+ context "for other users" do
+ it "shows impersonate button for other users" do
subject
- expect(page).to have_content('Impersonate')
+ expect(page).to have_content("Impersonate")
end
end
- context 'for admin itself' do
+ context "for admin itself" do
let(:user_to_visit) { current_user }
- it 'does not show impersonate button for admin itself' do
+ it "does not show impersonate button for admin itself" do
subject
- expect(page).not_to have_content('Impersonate')
+ expect(page).not_to have_content("Impersonate")
end
end
- context 'for blocked user' do
+ context "for blocked user" do
before do
another_user.block
end
- it 'does not show impersonate button for blocked user' do
+ it "does not show impersonate button for blocked user" do
subject
- expect(page).not_to have_content('Impersonate')
+ expect(page).not_to have_content("Impersonate")
end
end
- context 'when impersonation is disabled' do
+ context "when impersonation is disabled" do
before do
stub_config_setting(impersonation_enabled: false)
end
- it 'does not show impersonate button' do
+ it "does not show impersonate button" do
subject
- expect(page).not_to have_content('Impersonate')
+ expect(page).not_to have_content("Impersonate")
end
end
end
- context 'when impersonating' do
- subject { click_link 'Impersonate' }
+ context "when impersonating" do
+ subject { click_link "Impersonate" }
before do
visit admin_user_path(another_user)
end
- it 'logs in as the user when impersonate is clicked' do
+ it "logs in as the user when impersonate is clicked" do
subject
- expect(page.find(:css, '.header-user .profile-link')['data-user']).to eql(another_user.username)
+ expect(page.find(:css, ".header-user .profile-link")["data-user"]).to eql(another_user.username)
end
- it 'sees impersonation log out icon' do
+ it "sees impersonation log out icon" do
subject
- icon = first('.fa.fa-user-secret')
+ icon = first(".fa.fa-user-secret")
expect(icon).not_to be nil
end
- context 'a user with an expired password' do
+ context "a user with an expired password" do
before do
another_user.update(password_expires_at: Time.now - 5.minutes)
end
- it 'does not redirect to password change page' do
+ it "does not redirect to password change page" do
subject
- expect(current_path).to eq('/')
+ expect(current_path).to eq("/")
end
end
end
- context 'ending impersonation' do
- subject { find(:css, 'li.impersonation a').click }
+ context "ending impersonation" do
+ subject { find(:css, "li.impersonation a").click }
before do
visit admin_user_path(another_user)
- click_link 'Impersonate'
+ click_link "Impersonate"
end
- it 'logs out of impersonated user back to original user' do
+ it "logs out of impersonated user back to original user" do
subject
- expect(page.find(:css, '.header-user .profile-link')['data-user']).to eq(current_user.username)
+ expect(page.find(:css, ".header-user .profile-link")["data-user"]).to eq(current_user.username)
end
- it 'is redirected back to the impersonated users page in the admin after stopping' do
+ it "is redirected back to the impersonated users page in the admin after stopping" do
subject
expect(current_path).to eq("/admin/users/#{another_user.username}")
end
- context 'a user with an expired password' do
+ context "a user with an expired password" do
before do
another_user.update(password_expires_at: Time.now - 5.minutes)
end
- it 'is redirected back to the impersonated users page in the admin after stopping' do
+ it "is redirected back to the impersonated users page in the admin after stopping" do
subject
expect(current_path).to eq("/admin/users/#{another_user.username}")
@@ -401,23 +401,23 @@ describe "Admin::Users" do
end
end
- describe 'Two-factor Authentication status' do
- it 'shows when enabled' do
+ describe "Two-factor Authentication status" do
+ it "shows when enabled" do
user.update_attribute(:otp_required_for_login, true)
visit admin_user_path(user)
- expect_two_factor_status('Enabled')
+ expect_two_factor_status("Enabled")
end
- it 'shows when disabled' do
+ it "shows when disabled" do
visit admin_user_path(user)
- expect_two_factor_status('Disabled')
+ expect_two_factor_status("Disabled")
end
def expect_two_factor_status(status)
- page.within('.two-factor-status') do
+ page.within(".two-factor-status") do
expect(page).to have_content(status)
end
end
@@ -431,8 +431,8 @@ describe "Admin::Users" do
end
it "has user edit page" do
- expect(page).to have_content('Name')
- expect(page).to have_content('Password')
+ expect(page).to have_content("Name")
+ expect(page).to have_content("Password")
end
describe "Update user" do
@@ -446,25 +446,25 @@ describe "Admin::Users" do
end
it "shows page with new data" do
- expect(page).to have_content('bigbang@mail.com')
- expect(page).to have_content('Big Bang')
+ expect(page).to have_content("bigbang@mail.com")
+ expect(page).to have_content("Big Bang")
end
it "changes user entry" do
user.reload
- expect(user.name).to eq('Big Bang')
+ expect(user.name).to eq("Big Bang")
expect(user.admin?).to be_truthy
expect(user.password_expires_at).to be <= Time.now
end
end
- describe 'update username to non ascii char' do
+ describe "update username to non ascii char" do
it do
- fill_in 'user_username', with: '\u3042\u3044'
- click_button('Save')
+ fill_in "user_username", with: '\u3042\u3044'
+ click_button("Save")
- page.within '#error_explanation' do
- expect(page).to have_content('Username')
+ page.within "#error_explanation" do
+ expect(page).to have_content("Username")
end
expect(page).to have_selector(%(form[action="/admin/users/#{user.username}"]))
@@ -483,39 +483,39 @@ describe "Admin::Users" do
end
it "lists group projects" do
- within(:css, '.append-bottom-default + .card') do
- expect(page).to have_content 'Group projects'
+ within(:css, ".append-bottom-default + .card") do
+ expect(page).to have_content "Group projects"
expect(page).to have_link group.name, href: admin_group_path(group)
end
end
- it 'allows navigation to the group details' do
- within(:css, '.append-bottom-default + .card') do
+ it "allows navigation to the group details" do
+ within(:css, ".append-bottom-default + .card") do
click_link group.name
end
- within(:css, 'h3.page-title') do
+ within(:css, "h3.page-title") do
expect(page).to have_content "Group: #{group.name}"
end
expect(page).to have_content project.name
end
- it 'shows the group access level' do
- within(:css, '.append-bottom-default + .card') do
- expect(page).to have_content 'Developer'
+ it "shows the group access level" do
+ within(:css, ".append-bottom-default + .card") do
+ expect(page).to have_content "Developer"
end
end
- it 'allows group membership to be revoked', :js do
- page.within(first('.group_member')) do
- accept_confirm { find('.btn-remove').click }
+ it "allows group membership to be revoked", :js do
+ page.within(first(".group_member")) do
+ accept_confirm { find(".btn-remove").click }
end
wait_for_requests
- expect(page).not_to have_selector('.group_member')
+ expect(page).not_to have_selector(".group_member")
end
end
- describe 'show breadcrumbs' do
+ describe "show breadcrumbs" do
it do
visit admin_user_path(user)
@@ -543,26 +543,26 @@ describe "Admin::Users" do
visit admin_user_identities_path(user)
- find('.table').find(:link, 'Edit').click
+ find(".table").find(:link, "Edit").click
check_breadcrumb("Edit Identity")
end
end
- describe 'show user attributes' do
+ describe "show user attributes" do
it do
visit admin_users_path
click_link user.name
- expect(page).to have_content 'Account'
- expect(page).to have_content 'Personal projects limit'
+ expect(page).to have_content "Account"
+ expect(page).to have_content "Personal projects limit"
end
end
- describe 'remove users secondary email', :js do
+ describe "remove users secondary email", :js do
let!(:secondary_email) do
- create :email, email: 'secondary@example.com', user: user
+ create :email, email: "secondary@example.com", user: user
end
it do
@@ -576,7 +576,7 @@ describe "Admin::Users" do
end
end
- describe 'show user keys' do
+ describe "show user keys" do
let!(:key1) do
create(:key, user: user, title: "ssh-rsa Key1", key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key1")
end
@@ -589,7 +589,7 @@ describe "Admin::Users" do
visit admin_users_path
click_link user.name
- click_link 'SSH keys'
+ click_link "SSH keys"
expect(page).to have_content(key1.title)
expect(page).to have_content(key2.title)
@@ -599,57 +599,57 @@ describe "Admin::Users" do
expect(page).to have_content(key2.title)
expect(page).to have_content(key2.key)
- click_link 'Remove'
+ click_link "Remove"
expect(page).not_to have_content(key2.title)
end
end
- describe 'show user identities' do
- it 'shows user identities' do
+ describe "show user identities" do
+ it "shows user identities" do
visit admin_user_identities_path(user)
expect(page).to have_content(user.name)
- expect(page).to have_content('twitter')
+ expect(page).to have_content("twitter")
end
end
- describe 'update user identities' do
+ describe "update user identities" do
before do
allow(Gitlab::Auth::OAuth::Provider).to receive(:providers).and_return([:twitter, :twitter_updated])
end
- it 'modifies twitter identity' do
+ it "modifies twitter identity" do
visit admin_user_identities_path(user)
- find('.table').find(:link, 'Edit').click
- fill_in 'identity_extern_uid', with: '654321'
- select 'twitter_updated', from: 'identity_provider'
- click_button 'Save changes'
+ find(".table").find(:link, "Edit").click
+ fill_in "identity_extern_uid", with: "654321"
+ select "twitter_updated", from: "identity_provider"
+ click_button "Save changes"
expect(page).to have_content(user.name)
- expect(page).to have_content('twitter_updated')
- expect(page).to have_content('654321')
+ expect(page).to have_content("twitter_updated")
+ expect(page).to have_content("654321")
end
end
- describe 'remove user with identities' do
- it 'removes user with twitter identity' do
+ describe "remove user with identities" do
+ it "removes user with twitter identity" do
visit admin_user_identities_path(user)
- click_link 'Delete'
+ click_link "Delete"
expect(page).to have_content(user.name)
- expect(page).not_to have_content('twitter')
+ expect(page).not_to have_content("twitter")
end
end
def check_breadcrumb(content)
- expect(find('.breadcrumbs-sub-title')).to have_content(content)
+ expect(find(".breadcrumbs-sub-title")).to have_content(content)
end
def sort_by(text)
- page.within('.user-sort-dropdown') do
+ page.within(".user-sort-dropdown") do
click_link text
end
end
diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb
index d04bb9acd9e..30205d74b8c 100644
--- a/spec/features/admin/admin_uses_repository_checks_spec.rb
+++ b/spec/features/admin/admin_uses_repository_checks_spec.rb
@@ -1,25 +1,25 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Admin uses repository checks' do
+describe "Admin uses repository checks" do
include StubENV
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(create(:admin))
end
- it 'to trigger a single check' do
+ it "to trigger a single check" do
project = create(:project)
visit_admin_project_page(project)
- page.within('.repository-check') do
- click_button 'Trigger repository check'
+ page.within(".repository-check") do
+ click_button "Trigger repository check"
end
- expect(page).to have_content('Repository check was triggered')
+ expect(page).to have_content("Repository check was triggered")
end
- it 'to see a single failed repository check', :js do
+ it "to see a single failed repository check", :js do
project = create(:project)
project.update_columns(
last_repository_check_failed: true,
@@ -27,19 +27,19 @@ describe 'Admin uses repository checks' do
)
visit_admin_project_page(project)
- page.within('.alert') do
+ page.within(".alert") do
expect(page.text).to match(/Last repository check \(just now\) failed/)
end
end
- it 'to clear all repository checks', :js do
+ it "to clear all repository checks", :js do
visit repository_admin_application_settings_path
expect(RepositoryCheck::ClearWorker).to receive(:perform_async)
- accept_confirm { find(:link, 'Clear all repository checks').send_keys(:return) }
+ accept_confirm { find(:link, "Clear all repository checks").send_keys(:return) }
- expect(page).to have_content('Started asynchronous removal of all repository check states.')
+ expect(page).to have_content("Started asynchronous removal of all repository check states.")
end
def visit_admin_project_page(project)
diff --git a/spec/features/admin/dashboard_spec.rb b/spec/features/admin/dashboard_spec.rb
index a6ca0803469..5a904441fa0 100644
--- a/spec/features/admin/dashboard_spec.rb
+++ b/spec/features/admin/dashboard_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'admin visits dashboard' do
+describe "admin visits dashboard" do
include ProjectForksHelper
before do
sign_in(create(:admin))
end
- context 'counting forks' do
- it 'correctly counts 2 forks of a project' do
+ context "counting forks" do
+ it "correctly counts 2 forks of a project" do
project = create(:project)
project_fork = fork_project(project)
fork_project(project_fork)
@@ -16,13 +16,13 @@ describe 'admin visits dashboard' do
# Make sure the fork_networks & fork_networks reltuples have been updated
# to get a correct count on postgresql
if Gitlab::Database.postgresql?
- ActiveRecord::Base.connection.execute('ANALYZE fork_networks')
- ActiveRecord::Base.connection.execute('ANALYZE fork_network_members')
+ ActiveRecord::Base.connection.execute("ANALYZE fork_networks")
+ ActiveRecord::Base.connection.execute("ANALYZE fork_network_members")
end
visit admin_root_path
- expect(page).to have_content('Forks 2')
+ expect(page).to have_content("Forks 2")
end
end
end
diff --git a/spec/features/admin/services/admin_activates_prometheus_spec.rb b/spec/features/admin/services/admin_activates_prometheus_spec.rb
index 904fe5b406b..5cef07a4a1e 100644
--- a/spec/features/admin/services/admin_activates_prometheus_spec.rb
+++ b/spec/features/admin/services/admin_activates_prometheus_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Admin activates Prometheus' do
+describe "Admin activates Prometheus" do
let(:admin) { create(:user, :admin) }
before do
@@ -8,14 +8,14 @@ describe 'Admin activates Prometheus' do
visit(admin_application_settings_services_path)
- click_link('Prometheus')
+ click_link("Prometheus")
end
- it 'activates service' do
- check('Active')
- fill_in('API URL', with: 'http://prometheus.example.com')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("API URL", with: "http://prometheus.example.com")
+ click_button("Save")
- expect(page).to have_content('Application settings saved successfully')
+ expect(page).to have_content("Application settings saved successfully")
end
end
diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb
index dfa1c92ea49..f2d2e128839 100644
--- a/spec/features/atom/dashboard_issues_spec.rb
+++ b/spec/features/atom/dashboard_issues_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe "Dashboard Issues Feed" do
describe "GET /issues" do
- let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
- let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
+ let!(:user) { create(:user, email: "private1@example.com", public_email: "public1@example.com") }
+ let!(:assignee) { create(:user, email: "private2@example.com", public_email: "public2@example.com") }
let!(:project1) { create(:project) }
let!(:project2) { create(:project) }
@@ -18,7 +18,7 @@ describe "Dashboard Issues Feed" do
visit issues_dashboard_path(:atom, private_token: personal_access_token.token)
- expect(response_headers['Content-Type']).to have_content('application/atom+xml')
+ expect(response_headers["Content-Type"]).to have_content("application/atom+xml")
expect(page.status_code).to eq(400)
end
@@ -27,30 +27,30 @@ describe "Dashboard Issues Feed" do
visit issues_dashboard_path(:atom, private_token: personal_access_token.token, assignee_username: user.username)
- expect(response_headers['Content-Type']).to have_content('application/atom+xml')
- expect(body).to have_selector('title', text: "#{user.name} issues")
+ expect(response_headers["Content-Type"]).to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{user.name} issues")
end
it "renders atom feed via feed token" do
visit issues_dashboard_path(:atom, feed_token: user.feed_token, assignee_username: user.username)
- expect(response_headers['Content-Type']).to have_content('application/atom+xml')
- expect(body).to have_selector('title', text: "#{user.name} issues")
+ expect(response_headers["Content-Type"]).to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{user.name} issues")
end
it "renders atom feed with url parameters" do
- visit issues_dashboard_path(:atom, feed_token: user.feed_token, state: 'opened', assignee_username: user.username)
+ visit issues_dashboard_path(:atom, feed_token: user.feed_token, state: "opened", assignee_username: user.username)
link = find('link[type="application/atom+xml"]')
params = CGI.parse(URI.parse(link[:href]).query)
- expect(params).to include('feed_token' => [user.feed_token])
- expect(params).to include('state' => ['opened'])
- expect(params).to include('assignee_username' => [user.username.to_s])
+ expect(params).to include("feed_token" => [user.feed_token])
+ expect(params).to include("state" => ["opened"])
+ expect(params).to include("assignee_username" => [user.username.to_s])
end
context "issue with basic fields" do
- let!(:issue2) { create(:issue, author: user, assignees: [assignee], project: project2, description: 'test desc') }
+ let!(:issue2) { create(:issue, author: user, assignees: [assignee], project: project2, description: "test desc") }
it "renders issue fields" do
visit issues_dashboard_path(:atom, feed_token: user.feed_token, assignee_username: assignee.username)
@@ -58,17 +58,17 @@ describe "Dashboard Issues Feed" do
entry = find(:xpath, "//feed/entry[contains(summary/text(),'#{issue2.title}')]")
expect(entry).to be_present
- expect(entry).to have_selector('author email', text: issue2.author_public_email)
- expect(entry).to have_selector('assignees email', text: assignee.public_email)
- expect(entry).not_to have_selector('labels')
- expect(entry).not_to have_selector('milestone')
- expect(entry).to have_selector('description', text: issue2.description)
+ expect(entry).to have_selector("author email", text: issue2.author_public_email)
+ expect(entry).to have_selector("assignees email", text: assignee.public_email)
+ expect(entry).not_to have_selector("labels")
+ expect(entry).not_to have_selector("milestone")
+ expect(entry).to have_selector("description", text: issue2.description)
end
end
context "issue with label and milestone" do
- let!(:milestone1) { create(:milestone, project: project1, title: 'v1') }
- let!(:label1) { create(:label, project: project1, title: 'label1') }
+ let!(:milestone1) { create(:milestone, project: project1, title: "v1") }
+ let!(:label1) { create(:label, project: project1, title: "label1") }
let!(:issue1) { create(:issue, author: user, assignees: [assignee], project: project1, milestone: milestone1) }
before do
@@ -81,11 +81,11 @@ describe "Dashboard Issues Feed" do
entry = find(:xpath, "//feed/entry[contains(summary/text(),'#{issue1.title}')]")
expect(entry).to be_present
- expect(entry).to have_selector('author email', text: issue1.author_public_email)
- expect(entry).to have_selector('assignees email', text: assignee.public_email)
- expect(entry).to have_selector('labels label', text: label1.title)
- expect(entry).to have_selector('milestone', text: milestone1.title)
- expect(entry).not_to have_selector('description')
+ expect(entry).to have_selector("author email", text: issue1.author_public_email)
+ expect(entry).to have_selector("assignees email", text: assignee.public_email)
+ expect(entry).to have_selector("labels label", text: label1.title)
+ expect(entry).to have_selector("milestone", text: milestone1.title)
+ expect(entry).not_to have_selector("description")
end
end
end
diff --git a/spec/features/atom/dashboard_spec.rb b/spec/features/atom/dashboard_spec.rb
index 947587220a9..dd8ff8ebdf2 100644
--- a/spec/features/atom/dashboard_spec.rb
+++ b/spec/features/atom/dashboard_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Dashboard Feed" do
describe "GET /" do
@@ -9,21 +9,21 @@ describe "Dashboard Feed" do
personal_access_token = create(:personal_access_token, user: user)
visit dashboard_projects_path(:atom, private_token: personal_access_token.token)
- expect(body).to have_selector('feed title')
+ expect(body).to have_selector("feed title")
end
end
context "projects atom feed via feed token" do
it "renders projects atom feed" do
visit dashboard_projects_path(:atom, feed_token: user.feed_token)
- expect(body).to have_selector('feed title')
+ expect(body).to have_selector("feed title")
end
end
- context 'feed content' do
+ context "feed content" do
let(:project) { create(:project) }
- let(:issue) { create(:issue, project: project, author: user, description: '') }
- let(:note) { create(:note, noteable: issue, author: user, note: 'Bug confirmed', project: project) }
+ let(:issue) { create(:issue, project: project, author: user, description: "") }
+ let(:note) { create(:note, noteable: issue, author: user, note: "Bug confirmed", project: project) }
before do
project.add_maintainer(user)
diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb
index 714a9885caa..2e641033a91 100644
--- a/spec/features/atom/issues_spec.rb
+++ b/spec/features/atom/issues_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Issues Feed' do
- describe 'GET /issues' do
- let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
- let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
+describe "Issues Feed" do
+ describe "GET /issues" do
+ let!(:user) { create(:user, email: "private1@example.com", public_email: "public1@example.com") }
+ let!(:assignee) { create(:user, email: "private2@example.com", public_email: "public2@example.com") }
let!(:group) { create(:group) }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) }
@@ -13,73 +13,73 @@ describe 'Issues Feed' do
group.add_developer(user)
end
- context 'when authenticated' do
- it 'renders atom feed' do
+ context "when authenticated" do
+ it "renders atom feed" do
sign_in user
visit project_issues_path(project, :atom)
- expect(response_headers['Content-Type'])
- .to have_content('application/atom+xml')
- expect(body).to have_selector('title', text: "#{project.name} issues")
- expect(body).to have_selector('author email', text: issue.author_public_email)
- expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('entry summary', text: issue.title)
+ expect(response_headers["Content-Type"])
+ .to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{project.name} issues")
+ expect(body).to have_selector("author email", text: issue.author_public_email)
+ expect(body).to have_selector("assignees assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("entry summary", text: issue.title)
end
end
- context 'when authenticated via personal access token' do
- it 'renders atom feed' do
+ context "when authenticated via personal access token" do
+ it "renders atom feed" do
personal_access_token = create(:personal_access_token, user: user)
visit project_issues_path(project, :atom,
- private_token: personal_access_token.token)
+ private_token: personal_access_token.token)
- expect(response_headers['Content-Type'])
- .to have_content('application/atom+xml')
- expect(body).to have_selector('title', text: "#{project.name} issues")
- expect(body).to have_selector('author email', text: issue.author_public_email)
- expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('entry summary', text: issue.title)
+ expect(response_headers["Content-Type"])
+ .to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{project.name} issues")
+ expect(body).to have_selector("author email", text: issue.author_public_email)
+ expect(body).to have_selector("assignees assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("entry summary", text: issue.title)
end
end
- context 'when authenticated via feed token' do
- it 'renders atom feed' do
+ context "when authenticated via feed token" do
+ it "renders atom feed" do
visit project_issues_path(project, :atom,
- feed_token: user.feed_token)
+ feed_token: user.feed_token)
- expect(response_headers['Content-Type'])
- .to have_content('application/atom+xml')
- expect(body).to have_selector('title', text: "#{project.name} issues")
- expect(body).to have_selector('author email', text: issue.author_public_email)
- expect(body).to have_selector('assignees assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('assignee email', text: issue.assignees.first.public_email)
- expect(body).to have_selector('entry summary', text: issue.title)
+ expect(response_headers["Content-Type"])
+ .to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{project.name} issues")
+ expect(body).to have_selector("author email", text: issue.author_public_email)
+ expect(body).to have_selector("assignees assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("assignee email", text: issue.assignees.first.public_email)
+ expect(body).to have_selector("entry summary", text: issue.title)
end
end
it "renders atom feed with url parameters for project issues" do
- visit project_issues_path(project, :atom, feed_token: user.feed_token, state: 'opened', assignee_id: user.id)
+ visit project_issues_path(project, :atom, feed_token: user.feed_token, state: "opened", assignee_id: user.id)
link = find('link[type="application/atom+xml"]')
params = CGI.parse(URI.parse(link[:href]).query)
- expect(params).to include('feed_token' => [user.feed_token])
- expect(params).to include('state' => ['opened'])
- expect(params).to include('assignee_id' => [user.id.to_s])
+ expect(params).to include("feed_token" => [user.feed_token])
+ expect(params).to include("state" => ["opened"])
+ expect(params).to include("assignee_id" => [user.id.to_s])
end
it "renders atom feed with url parameters for group issues" do
- visit issues_group_path(group, :atom, feed_token: user.feed_token, state: 'opened', assignee_id: user.id)
+ visit issues_group_path(group, :atom, feed_token: user.feed_token, state: "opened", assignee_id: user.id)
link = find('link[type="application/atom+xml"]')
params = CGI.parse(URI.parse(link[:href]).query)
- expect(params).to include('feed_token' => [user.feed_token])
- expect(params).to include('state' => ['opened'])
- expect(params).to include('assignee_id' => [user.id.to_s])
+ expect(params).to include("feed_token" => [user.feed_token])
+ expect(params).to include("state" => ["opened"])
+ expect(params).to include("assignee_id" => [user.id.to_s])
end
end
end
diff --git a/spec/features/atom/users_spec.rb b/spec/features/atom/users_spec.rb
index 7de8bea5049..3a8e22aa79b 100644
--- a/spec/features/atom/users_spec.rb
+++ b/spec/features/atom/users_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe "User Feed" do
describe "GET /" do
let!(:user) { create(:user) }
- context 'user atom feed via personal access token' do
+ context "user atom feed via personal access token" do
it "renders user atom feed" do
personal_access_token = create(:personal_access_token, user: user)
visit user_path(user, :atom, private_token: personal_access_token.token)
- expect(body).to have_selector('feed title')
+ expect(body).to have_selector("feed title")
end
end
- context 'user atom feed via feed token' do
+ context "user atom feed via feed token" do
it "renders user atom feed" do
visit user_path(user, :atom, feed_token: user.feed_token)
- expect(body).to have_selector('feed title')
+ expect(body).to have_selector("feed title")
end
end
- context 'feed content' do
+ context "feed content" do
let(:project) { create(:project, :repository) }
let(:issue) do
create(:issue,
- project: project,
- author: user,
- description: "Houston, we have a bug!\n\n***\n\nI guess.")
+ project: project,
+ author: user,
+ description: "Houston, we have a bug!\n\n***\n\nI guess.")
end
let(:note) do
create(:note,
- noteable: issue,
- author: user,
- note: 'Bug confirmed :+1:',
- project: project)
+ noteable: issue,
+ author: user,
+ note: "Bug confirmed :+1:",
+ project: project)
end
let(:merge_request) do
create(:merge_request,
- title: 'Fix bug',
- author: user,
- source_project: project,
- target_project: project,
- description: "Here is the fix: ![an image](image.png)")
+ title: "Fix bug",
+ author: user,
+ source_project: project,
+ target_project: project,
+ description: "Here is the fix: ![an image](image.png)")
end
let(:push_event) { create(:push_event, project: project, author: user) }
let!(:push_event_payload) { create(:push_event_payload, event: push_event) }
@@ -54,28 +54,28 @@ describe "User Feed" do
visit user_path(user, :atom, feed_token: user.feed_token)
end
- it 'has issue opened event' do
+ it "has issue opened event" do
expect(body).to have_content("#{safe_name} opened issue ##{issue.iid}")
end
- it 'has issue comment event' do
+ it "has issue comment event" do
expect(body)
.to have_content("#{safe_name} commented on issue ##{issue.iid}")
end
- it 'has XHTML summaries in issue descriptions' do
+ it "has XHTML summaries in issue descriptions" do
expect(body).to match %r{<hr ?/>}
end
- it 'has XHTML summaries in notes' do
+ it "has XHTML summaries in notes" do
expect(body).to match /Bug confirmed <gl-emoji[^>]*>/
end
- it 'has XHTML summaries in merge request descriptions' do
+ it "has XHTML summaries in merge request descriptions" do
expect(body).to match %r{Here is the fix: <a[^>]*><img[^>]*/></a>}
end
- it 'has push event commit ID' do
+ it "has push event commit ID" do
expect(body).to have_content(Commit.truncate_sha(push_event.commit_id))
end
end
diff --git a/spec/features/boards/add_issues_modal_spec.rb b/spec/features/boards/add_issues_modal_spec.rb
index 030993462b5..b5bdbfeaf81 100644
--- a/spec/features/boards/add_issues_modal_spec.rb
+++ b/spec/features/boards/add_issues_modal_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards add issue modal', :js do
+describe "Issue Boards add issue modal", :js do
let(:project) { create(:project, :public) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
- let!(:planning) { create(:label, project: project, name: 'Planning') }
+ let!(:planning) { create(:label, project: project, name: "Planning") }
let!(:label) { create(:label, project: project) }
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
let!(:list2) { create(:list, board: board, label: label, position: 1) }
- let!(:issue) { create(:issue, project: project, title: 'abc', description: 'def') }
- let!(:issue2) { create(:issue, project: project, title: 'hij', description: 'klm') }
+ let!(:issue) { create(:issue, project: project, title: "abc", description: "def") }
+ let!(:issue2) { create(:issue, project: project, title: "hij", description: "klm") }
before do
project.add_maintainer(user)
@@ -20,235 +20,235 @@ describe 'Issue Boards add issue modal', :js do
wait_for_requests
end
- it 'resets filtered search state' do
- visit project_board_path(project, board, search: 'testing')
+ it "resets filtered search state" do
+ visit project_board_path(project, board, search: "testing")
wait_for_requests
- click_button('Add issues')
+ click_button("Add issues")
- page.within('.add-issues-modal') do
- expect(find('.form-control').value).to eq('')
- expect(page).to have_selector('.clear-search', visible: false)
- expect(find('.form-control')[:placeholder]).to eq('Search or filter results...')
+ page.within(".add-issues-modal") do
+ expect(find(".form-control").value).to eq("")
+ expect(page).to have_selector(".clear-search", visible: false)
+ expect(find(".form-control")[:placeholder]).to eq("Search or filter results...")
end
end
- context 'modal interaction' do
- it 'opens modal' do
- click_button('Add issues')
+ context "modal interaction" do
+ it "opens modal" do
+ click_button("Add issues")
- expect(page).to have_selector('.add-issues-modal')
+ expect(page).to have_selector(".add-issues-modal")
end
- it 'closes modal' do
- click_button('Add issues')
+ it "closes modal" do
+ click_button("Add issues")
- page.within('.add-issues-modal') do
- find('.close').click
+ page.within(".add-issues-modal") do
+ find(".close").click
end
- expect(page).not_to have_selector('.add-issues-modal')
+ expect(page).not_to have_selector(".add-issues-modal")
end
- it 'closes modal if cancel button clicked' do
- click_button('Add issues')
+ it "closes modal if cancel button clicked" do
+ click_button("Add issues")
- page.within('.add-issues-modal') do
- click_button 'Cancel'
+ page.within(".add-issues-modal") do
+ click_button "Cancel"
end
- expect(page).not_to have_selector('.add-issues-modal')
+ expect(page).not_to have_selector(".add-issues-modal")
end
- it 'does not show tooltip on add issues button' do
- button = page.find('.filter-dropdown-container button', text: 'Add issues')
+ it "does not show tooltip on add issues button" do
+ button = page.find(".filter-dropdown-container button", text: "Add issues")
expect(button[:title]).not_to eq("Please add a list to your board first")
end
end
- context 'issues list' do
+ context "issues list" do
before do
- click_button('Add issues')
+ click_button("Add issues")
wait_for_requests
end
- it 'loads issues' do
- page.within('.add-issues-modal') do
- page.within('.nav-links') do
- expect(page).to have_content('2')
+ it "loads issues" do
+ page.within(".add-issues-modal") do
+ page.within(".nav-links") do
+ expect(page).to have_content("2")
end
- expect(page).to have_selector('.board-card', count: 2)
+ expect(page).to have_selector(".board-card", count: 2)
end
end
- it 'shows selected issues' do
- page.within('.add-issues-modal') do
- click_link 'Selected issues'
+ it "shows selected issues" do
+ page.within(".add-issues-modal") do
+ click_link "Selected issues"
- expect(page).not_to have_selector('.board-card')
+ expect(page).not_to have_selector(".board-card")
end
end
- context 'list dropdown' do
- it 'resets after deleting list' do
- page.within('.add-issues-modal') do
- expect(find('.add-issues-footer')).to have_button(planning.title)
+ context "list dropdown" do
+ it "resets after deleting list" do
+ page.within(".add-issues-modal") do
+ expect(find(".add-issues-footer")).to have_button(planning.title)
- click_button 'Cancel'
+ click_button "Cancel"
end
- accept_confirm { first('.board-delete').click }
+ accept_confirm { first(".board-delete").click }
- click_button('Add issues')
+ click_button("Add issues")
wait_for_requests
- page.within('.add-issues-modal') do
- expect(find('.add-issues-footer')).not_to have_button(planning.title)
- expect(find('.add-issues-footer')).to have_button(label.title)
+ page.within(".add-issues-modal") do
+ expect(find(".add-issues-footer")).not_to have_button(planning.title)
+ expect(find(".add-issues-footer")).to have_button(label.title)
end
end
end
- context 'search' do
- it 'returns issues' do
- page.within('.add-issues-modal') do
- find('.form-control').native.send_keys(issue.title)
- find('.form-control').native.send_keys(:enter)
+ context "search" do
+ it "returns issues" do
+ page.within(".add-issues-modal") do
+ find(".form-control").native.send_keys(issue.title)
+ find(".form-control").native.send_keys(:enter)
wait_for_requests
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'returns no issues' do
- page.within('.add-issues-modal') do
- find('.form-control').native.send_keys('testing search')
- find('.form-control').native.send_keys(:enter)
+ it "returns no issues" do
+ page.within(".add-issues-modal") do
+ find(".form-control").native.send_keys("testing search")
+ find(".form-control").native.send_keys(:enter)
wait_for_requests
- expect(page).not_to have_selector('.board-card')
+ expect(page).not_to have_selector(".board-card")
expect(page).not_to have_content("You haven't added any issues to your project yet")
end
end
end
- context 'selecing issues' do
- it 'selects single issue' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ context "selecing issues" do
+ it "selects single issue" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- page.within('.nav-links') do
- expect(page).to have_content('Selected issues 1')
+ page.within(".nav-links") do
+ expect(page).to have_content("Selected issues 1")
end
end
end
- it 'changes button text' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ it "changes button text" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- expect(first('.add-issues-footer .btn')).to have_content('Add 1 issue')
+ expect(first(".add-issues-footer .btn")).to have_content("Add 1 issue")
end
end
- it 'changes button text with plural' do
- page.within('.add-issues-modal') do
- all('.board-card .js-board-card-number-container').each do |el|
+ it "changes button text with plural" do
+ page.within(".add-issues-modal") do
+ all(".board-card .js-board-card-number-container").each do |el|
el.click
end
- expect(first('.add-issues-footer .btn')).to have_content('Add 2 issues')
+ expect(first(".add-issues-footer .btn")).to have_content("Add 2 issues")
end
end
- it 'shows only selected issues on selected tab' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ it "shows only selected issues on selected tab" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- click_link 'Selected issues'
+ click_link "Selected issues"
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'selects all issues' do
- page.within('.add-issues-modal') do
- click_button 'Select all'
+ it "selects all issues" do
+ page.within(".add-issues-modal") do
+ click_button "Select all"
- expect(page).to have_selector('.is-active', count: 2)
+ expect(page).to have_selector(".is-active", count: 2)
end
end
- it 'deselects all issues' do
- page.within('.add-issues-modal') do
- click_button 'Select all'
+ it "deselects all issues" do
+ page.within(".add-issues-modal") do
+ click_button "Select all"
- expect(page).to have_selector('.is-active', count: 2)
+ expect(page).to have_selector(".is-active", count: 2)
- click_button 'Deselect all'
+ click_button "Deselect all"
- expect(page).not_to have_selector('.is-active')
+ expect(page).not_to have_selector(".is-active")
end
end
- it 'selects all that arent already selected' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ it "selects all that arent already selected" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- expect(page).to have_selector('.is-active', count: 1)
+ expect(page).to have_selector(".is-active", count: 1)
- click_button 'Select all'
+ click_button "Select all"
- expect(page).to have_selector('.is-active', count: 2)
+ expect(page).to have_selector(".is-active", count: 2)
end
end
- it 'unselects from selected tab' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ it "unselects from selected tab" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- click_link 'Selected issues'
+ click_link "Selected issues"
- first('.board-card .board-card-number').click
+ first(".board-card .board-card-number").click
- expect(page).not_to have_selector('.is-active')
+ expect(page).not_to have_selector(".is-active")
end
end
end
- context 'adding issues' do
- it 'adds to board' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ context "adding issues" do
+ it "adds to board" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
- click_button 'Add 1 issue'
+ click_button "Add 1 issue"
end
- page.within(find('.board:nth-child(2)')) do
- expect(page).to have_selector('.board-card')
+ page.within(find(".board:nth-child(2)")) do
+ expect(page).to have_selector(".board-card")
end
end
- it 'adds to second list' do
- page.within('.add-issues-modal') do
- first('.board-card .board-card-number').click
+ it "adds to second list" do
+ page.within(".add-issues-modal") do
+ first(".board-card .board-card-number").click
click_button planning.title
click_link label.title
- click_button 'Add 1 issue'
+ click_button "Add 1 issue"
end
- page.within(find('.board:nth-child(3)')) do
- expect(page).to have_selector('.board-card')
+ page.within(find(".board:nth-child(3)")) do
+ expect(page).to have_selector(".board-card")
end
end
end
diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb
index ea69ec0319b..37392fec4c6 100644
--- a/spec/features/boards/boards_spec.rb
+++ b/spec/features/boards/boards_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards', :js do
+describe "Issue Boards", :js do
include DragTo
include MobileHelpers
@@ -14,154 +14,154 @@ describe 'Issue Boards', :js do
project.add_maintainer(user)
project.add_maintainer(user2)
- set_cookie('sidebar_collapsed', 'true')
+ set_cookie("sidebar_collapsed", "true")
sign_in(user)
end
- context 'no lists' do
+ context "no lists" do
before do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'shows blank state' do
- expect(page).to have_content('Welcome to your Issue Board!')
+ it "shows blank state" do
+ expect(page).to have_content("Welcome to your Issue Board!")
end
- it 'shows tooltip on add issues button' do
- button = page.find('.filter-dropdown-container button', text: 'Add issues')
+ it "shows tooltip on add issues button" do
+ button = page.find(".filter-dropdown-container button", text: "Add issues")
expect(button[:"data-original-title"]).to eq("Please add a list to your board first")
end
- it 'hides the blank state when clicking nevermind button' do
- page.within(find('.board-blank-state')) do
+ it "hides the blank state when clicking nevermind button" do
+ page.within(find(".board-blank-state")) do
click_button("Nevermind, I'll use my own")
end
- expect(page).to have_selector('.board', count: 2)
+ expect(page).to have_selector(".board", count: 2)
end
- it 'creates default lists' do
- lists = ['Open', 'To Do', 'Doing', 'Closed']
+ it "creates default lists" do
+ lists = ["Open", "To Do", "Doing", "Closed"]
- page.within(find('.board-blank-state')) do
- click_button('Add default lists')
+ page.within(find(".board-blank-state")) do
+ click_button("Add default lists")
end
wait_for_requests
- expect(page).to have_selector('.board', count: 4)
+ expect(page).to have_selector(".board", count: 4)
- page.all('.board').each_with_index do |list, i|
- expect(list.find('.board-title')).to have_content(lists[i])
+ page.all(".board").each_with_index do |list, i|
+ expect(list.find(".board-title")).to have_content(lists[i])
end
end
end
- context 'with lists' do
+ context "with lists" do
let(:milestone) { create(:milestone, project: project) }
- let(:planning) { create(:label, project: project, name: 'Planning', description: 'Test') }
- let(:development) { create(:label, project: project, name: 'Development') }
- let(:testing) { create(:label, project: project, name: 'Testing') }
- let(:bug) { create(:label, project: project, name: 'Bug') }
- let!(:backlog) { create(:label, project: project, name: 'Backlog') }
- let!(:closed) { create(:label, project: project, name: 'Closed') }
- let!(:accepting) { create(:label, project: project, name: 'Accepting Merge Requests') }
- let!(:a_plus) { create(:label, project: project, name: 'A+') }
+ let(:planning) { create(:label, project: project, name: "Planning", description: "Test") }
+ let(:development) { create(:label, project: project, name: "Development") }
+ let(:testing) { create(:label, project: project, name: "Testing") }
+ let(:bug) { create(:label, project: project, name: "Bug") }
+ let!(:backlog) { create(:label, project: project, name: "Backlog") }
+ let!(:closed) { create(:label, project: project, name: "Closed") }
+ let!(:accepting) { create(:label, project: project, name: "Accepting Merge Requests") }
+ let!(:a_plus) { create(:label, project: project, name: "A+") }
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
let!(:list2) { create(:list, board: board, label: development, position: 1) }
let!(:confidential_issue) { create(:labeled_issue, :confidential, project: project, author: user, labels: [planning], relative_position: 9) }
- let!(:issue1) { create(:labeled_issue, project: project, title: 'aaa', description: '111', assignees: [user], labels: [planning], relative_position: 8) }
- let!(:issue2) { create(:labeled_issue, project: project, title: 'bbb', description: '222', author: user2, labels: [planning], relative_position: 7) }
- let!(:issue3) { create(:labeled_issue, project: project, title: 'ccc', description: '333', labels: [planning], relative_position: 6) }
- let!(:issue4) { create(:labeled_issue, project: project, title: 'ddd', description: '444', labels: [planning], relative_position: 5) }
- let!(:issue5) { create(:labeled_issue, project: project, title: 'eee', description: '555', labels: [planning], milestone: milestone, relative_position: 4) }
- let!(:issue6) { create(:labeled_issue, project: project, title: 'fff', description: '666', labels: [planning, development], relative_position: 3) }
- let!(:issue7) { create(:labeled_issue, project: project, title: 'ggg', description: '777', labels: [development], relative_position: 2) }
- let!(:issue8) { create(:closed_issue, project: project, title: 'hhh', description: '888') }
- let!(:issue9) { create(:labeled_issue, project: project, title: 'iii', description: '999', labels: [planning, testing, bug, accepting], relative_position: 1) }
- let!(:issue10) { create(:labeled_issue, project: project, title: 'issue +', description: 'A+ great issue', labels: [a_plus]) }
+ let!(:issue1) { create(:labeled_issue, project: project, title: "aaa", description: "111", assignees: [user], labels: [planning], relative_position: 8) }
+ let!(:issue2) { create(:labeled_issue, project: project, title: "bbb", description: "222", author: user2, labels: [planning], relative_position: 7) }
+ let!(:issue3) { create(:labeled_issue, project: project, title: "ccc", description: "333", labels: [planning], relative_position: 6) }
+ let!(:issue4) { create(:labeled_issue, project: project, title: "ddd", description: "444", labels: [planning], relative_position: 5) }
+ let!(:issue5) { create(:labeled_issue, project: project, title: "eee", description: "555", labels: [planning], milestone: milestone, relative_position: 4) }
+ let!(:issue6) { create(:labeled_issue, project: project, title: "fff", description: "666", labels: [planning, development], relative_position: 3) }
+ let!(:issue7) { create(:labeled_issue, project: project, title: "ggg", description: "777", labels: [development], relative_position: 2) }
+ let!(:issue8) { create(:closed_issue, project: project, title: "hhh", description: "888") }
+ let!(:issue9) { create(:labeled_issue, project: project, title: "iii", description: "999", labels: [planning, testing, bug, accepting], relative_position: 1) }
+ let!(:issue10) { create(:labeled_issue, project: project, title: "issue +", description: "A+ great issue", labels: [a_plus]) }
before do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 4)
- expect(find('.board:nth-child(2)')).to have_selector('.board-card')
- expect(find('.board:nth-child(3)')).to have_selector('.board-card')
- expect(find('.board:nth-child(4)')).to have_selector('.board-card')
+ expect(page).to have_selector(".board", count: 4)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card")
+ expect(find(".board:nth-child(3)")).to have_selector(".board-card")
+ expect(find(".board:nth-child(4)")).to have_selector(".board-card")
end
- it 'shows description tooltip on list title', :quarantine do
- page.within('.board:nth-child(2)') do
- expect(find('.board-title span.has-tooltip')[:title]).to eq('Test')
+ it "shows description tooltip on list title", :quarantine do
+ page.within(".board:nth-child(2)") do
+ expect(find(".board-title span.has-tooltip")[:title]).to eq("Test")
end
end
- it 'shows issues in lists' do
+ it "shows issues in lists" do
wait_for_board_cards(2, 8)
wait_for_board_cards(3, 2)
end
- it 'shows confidential issues with icon' do
- page.within(find('.board:nth-child(2)')) do
- expect(page).to have_selector('.confidential-icon', count: 1)
+ it "shows confidential issues with icon" do
+ page.within(find(".board:nth-child(2)")) do
+ expect(page).to have_selector(".confidential-icon", count: 1)
end
end
- it 'search closed list' do
- find('.filtered-search').set(issue8.title)
- find('.filtered-search').native.send_keys(:enter)
+ it "search closed list" do
+ find(".filtered-search").set(issue8.title)
+ find(".filtered-search").native.send_keys(:enter)
wait_for_requests
- expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 0)
- expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
- expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 1)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card", count: 0)
+ expect(find(".board:nth-child(3)")).to have_selector(".board-card", count: 0)
+ expect(find(".board:nth-child(4)")).to have_selector(".board-card", count: 1)
end
- it 'search list' do
- find('.filtered-search').set(issue5.title)
- find('.filtered-search').native.send_keys(:enter)
+ it "search list" do
+ find(".filtered-search").set(issue5.title)
+ find(".filtered-search").native.send_keys(:enter)
wait_for_requests
- expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 1)
- expect(find('.board:nth-child(3)')).to have_selector('.board-card', count: 0)
- expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 0)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card", count: 1)
+ expect(find(".board:nth-child(3)")).to have_selector(".board-card", count: 0)
+ expect(find(".board:nth-child(4)")).to have_selector(".board-card", count: 0)
end
- it 'allows user to delete board' do
- page.within(find('.board:nth-child(2)')) do
- accept_confirm { find('.board-delete').click }
+ it "allows user to delete board" do
+ page.within(find(".board:nth-child(2)")) do
+ accept_confirm { find(".board-delete").click }
end
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'removes checkmark in new list dropdown after deleting' do
- click_button 'Add list'
+ it "removes checkmark in new list dropdown after deleting" do
+ click_button "Add list"
wait_for_requests
- find('.js-new-board-list').click
+ find(".js-new-board-list").click
- page.within(find('.board:nth-child(2)')) do
- accept_confirm { find('.board-delete').click }
+ page.within(find(".board:nth-child(2)")) do
+ accept_confirm { find(".board-delete").click }
end
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'infinite scrolls list' do
+ it "infinite scrolls list" do
50.times do
create(:labeled_issue, project: project, labels: [planning])
end
@@ -169,198 +169,198 @@ describe 'Issue Boards', :js do
visit project_board_path(project, board)
wait_for_requests
- page.within(find('.board:nth-child(2)')) do
- expect(page.find('.board-header')).to have_content('58')
- expect(page).to have_selector('.board-card', count: 20)
- expect(page).to have_content('Showing 20 of 58 issues')
+ page.within(find(".board:nth-child(2)")) do
+ expect(page.find(".board-header")).to have_content("58")
+ expect(page).to have_selector(".board-card", count: 20)
+ expect(page).to have_content("Showing 20 of 58 issues")
- find('.board .board-list')
+ find(".board .board-list")
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests
- expect(page).to have_selector('.board-card', count: 40)
- expect(page).to have_content('Showing 40 of 58 issues')
+ expect(page).to have_selector(".board-card", count: 40)
+ expect(page).to have_content("Showing 40 of 58 issues")
- find('.board .board-list')
+ find(".board .board-list")
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
wait_for_requests
- expect(page).to have_selector('.board-card', count: 58)
- expect(page).to have_content('Showing all issues')
+ expect(page).to have_selector(".board-card", count: 58)
+ expect(page).to have_content("Showing all issues")
end
end
- context 'closed' do
- it 'shows list of closed issues' do
+ context "closed" do
+ it "shows list of closed issues" do
wait_for_board_cards(4, 1)
wait_for_requests
end
- it 'moves issue to closed' do
+ it "moves issue to closed" do
drag(list_from_index: 1, list_to_index: 3)
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 2)
- expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
- expect(find('.board:nth-child(4)')).to have_selector('.board-card', count: 2)
- expect(find('.board:nth-child(4)')).to have_content(issue9.title)
- expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
+ expect(find(".board:nth-child(2)")).not_to have_content(issue9.title)
+ expect(find(".board:nth-child(4)")).to have_selector(".board-card", count: 2)
+ expect(find(".board:nth-child(4)")).to have_content(issue9.title)
+ expect(find(".board:nth-child(4)")).not_to have_content(planning.title)
end
- it 'removes all of the same issue to closed' do
+ it "removes all of the same issue to closed" do
drag(list_from_index: 1, list_to_index: 3)
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 2)
- expect(find('.board:nth-child(2)')).not_to have_content(issue9.title)
- expect(find('.board:nth-child(4)')).to have_content(issue9.title)
- expect(find('.board:nth-child(4)')).not_to have_content(planning.title)
+ expect(find(".board:nth-child(2)")).not_to have_content(issue9.title)
+ expect(find(".board:nth-child(4)")).to have_content(issue9.title)
+ expect(find(".board:nth-child(4)")).not_to have_content(planning.title)
end
end
- context 'lists' do
- it 'changes position of list' do
- drag(list_from_index: 2, list_to_index: 1, selector: '.board-header')
+ context "lists" do
+ it "changes position of list" do
+ drag(list_from_index: 2, list_to_index: 1, selector: ".board-header")
wait_for_board_cards(2, 2)
wait_for_board_cards(3, 8)
wait_for_board_cards(4, 1)
- expect(find('.board:nth-child(2)')).to have_content(development.title)
- expect(find('.board:nth-child(2)')).to have_content(planning.title)
+ expect(find(".board:nth-child(2)")).to have_content(development.title)
+ expect(find(".board:nth-child(2)")).to have_content(planning.title)
end
- it 'issue moves between lists' do
+ it "issue moves between lists" do
drag(list_from_index: 1, from_index: 1, list_to_index: 2)
wait_for_board_cards(2, 7)
wait_for_board_cards(3, 2)
wait_for_board_cards(4, 1)
- expect(find('.board:nth-child(3)')).to have_content(issue6.title)
- expect(find('.board:nth-child(3)').all('.board-card').last).to have_content(development.title)
+ expect(find(".board:nth-child(3)")).to have_content(issue6.title)
+ expect(find(".board:nth-child(3)").all(".board-card").last).to have_content(development.title)
end
- it 'issue moves between lists' do
+ it "issue moves between lists" do
drag(list_from_index: 2, list_to_index: 1)
wait_for_board_cards(2, 9)
wait_for_board_cards(3, 1)
wait_for_board_cards(4, 1)
- expect(find('.board:nth-child(2)')).to have_content(issue7.title)
- expect(find('.board:nth-child(2)').all('.board-card').first).to have_content(planning.title)
+ expect(find(".board:nth-child(2)")).to have_content(issue7.title)
+ expect(find(".board:nth-child(2)").all(".board-card").first).to have_content(planning.title)
end
- it 'issue moves from closed' do
+ it "issue moves from closed" do
drag(list_from_index: 2, list_to_index: 3)
wait_for_board_cards(2, 8)
wait_for_board_cards(3, 1)
wait_for_board_cards(4, 2)
- expect(find('.board:nth-child(4)')).to have_content(issue8.title)
+ expect(find(".board:nth-child(4)")).to have_content(issue8.title)
end
- context 'issue card' do
- it 'shows assignee' do
- page.within(find('.board:nth-child(2)')) do
- expect(page).to have_selector('.avatar', count: 1)
+ context "issue card" do
+ it "shows assignee" do
+ page.within(find(".board:nth-child(2)")) do
+ expect(page).to have_selector(".avatar", count: 1)
end
end
end
- context 'new list' do
- it 'shows all labels in new list dropdown' do
- click_button 'Add list'
+ context "new list" do
+ it "shows all labels in new list dropdown" do
+ click_button "Add list"
wait_for_requests
- page.within('.dropdown-menu-issues-board-new') do
+ page.within(".dropdown-menu-issues-board-new") do
expect(page).to have_content(planning.title)
expect(page).to have_content(development.title)
expect(page).to have_content(testing.title)
end
end
- it 'creates new list for label' do
- click_button 'Add list'
+ it "creates new list for label" do
+ click_button "Add list"
wait_for_requests
- page.within('.dropdown-menu-issues-board-new') do
+ page.within(".dropdown-menu-issues-board-new") do
click_link testing.title
end
wait_for_requests
- expect(page).to have_selector('.board', count: 5)
+ expect(page).to have_selector(".board", count: 5)
end
- it 'creates new list for Backlog label' do
- click_button 'Add list'
+ it "creates new list for Backlog label" do
+ click_button "Add list"
wait_for_requests
- page.within('.dropdown-menu-issues-board-new') do
+ page.within(".dropdown-menu-issues-board-new") do
click_link backlog.title
end
wait_for_requests
- expect(page).to have_selector('.board', count: 5)
+ expect(page).to have_selector(".board", count: 5)
end
- it 'creates new list for Closed label' do
- click_button 'Add list'
+ it "creates new list for Closed label" do
+ click_button "Add list"
wait_for_requests
- page.within('.dropdown-menu-issues-board-new') do
+ page.within(".dropdown-menu-issues-board-new") do
click_link closed.title
end
wait_for_requests
- expect(page).to have_selector('.board', count: 5)
+ expect(page).to have_selector(".board", count: 5)
end
- it 'keeps dropdown open after adding new list' do
- click_button 'Add list'
+ it "keeps dropdown open after adding new list" do
+ click_button "Add list"
wait_for_requests
- page.within('.dropdown-menu-issues-board-new') do
+ page.within(".dropdown-menu-issues-board-new") do
click_link closed.title
end
wait_for_requests
- expect(page).to have_css('#js-add-list.show')
+ expect(page).to have_css("#js-add-list.show")
end
- it 'creates new list from a new label' do
- click_button 'Add list'
+ it "creates new list from a new label" do
+ click_button "Add list"
wait_for_requests
- click_link 'Create project label'
+ click_link "Create project label"
- fill_in('new_label_name', with: 'Testing New Label')
+ fill_in("new_label_name", with: "Testing New Label")
- first('.suggest-colors a').click
+ first(".suggest-colors a").click
- click_button 'Create'
+ click_button "Create"
wait_for_requests
wait_for_requests
- expect(page).to have_selector('.board', count: 5)
+ expect(page).to have_selector(".board", count: 5)
end
end
end
- context 'filtering' do
- it 'filters by author' do
+ context "filtering" do
+ it "filters by author" do
set_filter("author", user2.username)
click_filter_link(user2.username)
submit_filter
@@ -370,7 +370,7 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((3..4))
end
- it 'filters by assignee' do
+ it "filters by assignee" do
set_filter("assignee", user.username)
click_filter_link(user.username)
submit_filter
@@ -381,7 +381,7 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((3..4))
end
- it 'filters by milestone' do
+ it "filters by milestone" do
set_filter("milestone", "\"#{milestone.title}")
click_filter_link(milestone.title)
submit_filter
@@ -392,7 +392,7 @@ describe 'Issue Boards', :js do
wait_for_board_cards(4, 0)
end
- it 'filters by label' do
+ it "filters by label" do
set_filter("label", testing.title)
click_filter_link(testing.title)
submit_filter
@@ -402,7 +402,7 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((3..4))
end
- it 'filters by label with encoded character' do
+ it "filters by label with encoded character" do
set_filter("label", a_plus.title)
click_filter_link(a_plus.title)
submit_filter
@@ -411,43 +411,43 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((2..4))
end
- it 'filters by label with space after reload', :quarantine do
+ it "filters by label with space after reload", :quarantine do
set_filter("label", "\"#{accepting.title}")
click_filter_link(accepting.title)
submit_filter
# Test after reload
- page.evaluate_script 'window.location.reload()'
+ page.evaluate_script "window.location.reload()"
wait_for_board_cards(2, 1)
wait_for_empty_boards((3..4))
wait_for_requests
- page.within(find('.board:nth-child(2)')) do
- expect(page.find('.board-header')).to have_content('1')
- expect(page).to have_selector('.board-card', count: 1)
+ page.within(find(".board:nth-child(2)")) do
+ expect(page.find(".board-header")).to have_content("1")
+ expect(page).to have_selector(".board-card", count: 1)
end
- page.within(find('.board:nth-child(3)')) do
- expect(page.find('.board-header')).to have_content('0')
- expect(page).to have_selector('.board-card', count: 0)
+ page.within(find(".board:nth-child(3)")) do
+ expect(page.find(".board-header")).to have_content("0")
+ expect(page).to have_selector(".board-card", count: 0)
end
end
- it 'removes filtered labels' do
+ it "removes filtered labels" do
set_filter("label", testing.title)
click_filter_link(testing.title)
submit_filter
wait_for_board_cards(2, 1)
- find('.clear-search').click
+ find(".clear-search").click
submit_filter
wait_for_board_cards(2, 8)
end
- it 'infinite scrolls list with label filter' do
+ it "infinite scrolls list with label filter" do
50.times do
create(:labeled_issue, project: project, labels: [planning, testing])
end
@@ -458,26 +458,26 @@ describe 'Issue Boards', :js do
wait_for_requests
- page.within(find('.board:nth-child(2)')) do
- expect(page.find('.board-header')).to have_content('51')
- expect(page).to have_selector('.board-card', count: 20)
- expect(page).to have_content('Showing 20 of 51 issues')
+ page.within(find(".board:nth-child(2)")) do
+ expect(page.find(".board-header")).to have_content("51")
+ expect(page).to have_selector(".board-card", count: 20)
+ expect(page).to have_content("Showing 20 of 51 issues")
- find('.board .board-list')
+ find(".board .board-list")
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
- expect(page).to have_selector('.board-card', count: 40)
- expect(page).to have_content('Showing 40 of 51 issues')
+ expect(page).to have_selector(".board-card", count: 40)
+ expect(page).to have_content("Showing 40 of 51 issues")
- find('.board .board-list')
+ find(".board .board-list")
evaluate_script("document.querySelectorAll('.board .board-list')[1].scrollTop = document.querySelectorAll('.board .board-list')[1].scrollHeight")
- expect(page).to have_selector('.board-card', count: 51)
- expect(page).to have_content('Showing all issues')
+ expect(page).to have_selector(".board-card", count: 51)
+ expect(page).to have_content("Showing all issues")
end
end
- it 'filters by multiple labels', :quarantine do
+ it "filters by multiple labels", :quarantine do
set_filter("label", testing.title)
click_filter_link(testing.title)
@@ -492,15 +492,15 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((3..4))
end
- it 'filters by clicking label button on issue' do
- page.within(find('.board:nth-child(2)')) do
- expect(page).to have_selector('.board-card', count: 8)
- expect(find('.board-card', match: :first)).to have_content(bug.title)
+ it "filters by clicking label button on issue" do
+ page.within(find(".board:nth-child(2)")) do
+ expect(page).to have_selector(".board-card", count: 8)
+ expect(find(".board-card", match: :first)).to have_content(bug.title)
click_button(bug.title)
wait_for_requests
end
- page.within('.tokens-container') do
+ page.within(".tokens-container") do
expect(page).to have_content(bug.title)
end
@@ -510,15 +510,15 @@ describe 'Issue Boards', :js do
wait_for_empty_boards((3..4))
end
- it 'removes label filter by clicking label button on issue' do
- page.within(find('.board:nth-child(2)')) do
- page.within(find('.board-card', match: :first)) do
+ it "removes label filter by clicking label button on issue" do
+ page.within(find(".board:nth-child(2)")) do
+ page.within(find(".board-card", match: :first)) do
click_button(bug.title)
end
wait_for_requests
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".board-card", count: 1)
end
wait_for_requests
@@ -526,39 +526,39 @@ describe 'Issue Boards', :js do
end
end
- context 'keyboard shortcuts' do
+ context "keyboard shortcuts" do
before do
visit project_board_path(project, board)
wait_for_requests
end
- it 'allows user to use keyboard shortcuts' do
- find('body').native.send_keys('i')
- expect(page).to have_content('New Issue')
+ it "allows user to use keyboard shortcuts" do
+ find("body").native.send_keys("i")
+ expect(page).to have_content("New Issue")
end
end
- context 'signed out user' do
+ context "signed out user" do
before do
sign_out(:user)
visit project_board_path(project, board)
wait_for_requests
end
- it 'displays lists' do
- expect(page).to have_selector('.board')
+ it "displays lists" do
+ expect(page).to have_selector(".board")
end
- it 'does not show create new list' do
- expect(page).not_to have_button('.js-new-board-list')
+ it "does not show create new list" do
+ expect(page).not_to have_button(".js-new-board-list")
end
- it 'does not allow dragging' do
- expect(page).not_to have_selector('.user-can-drag')
+ it "does not allow dragging" do
+ expect(page).not_to have_selector(".user-can-drag")
end
end
- context 'as guest user' do
+ context "as guest user" do
let(:user_guest) { create(:user) }
before do
@@ -569,17 +569,17 @@ describe 'Issue Boards', :js do
wait_for_requests
end
- it 'does not show create new list' do
- expect(page).not_to have_selector('.js-new-board-list')
+ it "does not show create new list" do
+ expect(page).not_to have_selector(".js-new-board-list")
end
end
- def drag(selector: '.board-list', list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0)
+ def drag(selector: ".board-list", list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0)
# ensure there is enough horizontal space for four boards
resize_window(2000, 800)
drag_to(selector: selector,
- scrollable: '#board-app',
+ scrollable: "#board-app",
list_from_index: list_from_index,
from_index: from_index,
to_index: to_index,
@@ -588,8 +588,8 @@ describe 'Issue Boards', :js do
def wait_for_board_cards(board_number, expected_cards)
page.within(find(".board:nth-child(#{board_number})")) do
- expect(page.find('.board-header')).to have_content(expected_cards.to_s)
- expect(page).to have_selector('.board-card', count: expected_cards)
+ expect(page.find(".board-header")).to have_content(expected_cards.to_s)
+ expect(page).to have_selector(".board-card", count: expected_cards)
end
end
@@ -600,15 +600,15 @@ describe 'Issue Boards', :js do
end
def set_filter(type, text)
- find('.filtered-search').native.send_keys("#{type}:#{text}")
+ find(".filtered-search").native.send_keys("#{type}:#{text}")
end
def submit_filter
- find('.filtered-search').native.send_keys(:enter)
+ find(".filtered-search").native.send_keys(:enter)
end
def click_filter_link(link_text)
- page.within('.filtered-search-box') do
+ page.within(".filtered-search-box") do
expect(page).to have_button(link_text)
click_button(link_text)
diff --git a/spec/features/boards/issue_ordering_spec.rb b/spec/features/boards/issue_ordering_spec.rb
index 21779336559..5e3eb5b619a 100644
--- a/spec/features/boards/issue_ordering_spec.rb
+++ b/spec/features/boards/issue_ordering_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards', :js do
+describe "Issue Boards", :js do
include DragTo
let(:project) { create(:project, :public) }
@@ -8,9 +8,9 @@ describe 'Issue Boards', :js do
let(:user) { create(:user) }
let(:label) { create(:label, project: project) }
let!(:list1) { create(:list, board: board, label: label, position: 0) }
- let!(:issue1) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label], relative_position: 3) }
- let!(:issue2) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label], relative_position: 2) }
- let!(:issue3) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label], relative_position: 1) }
+ let!(:issue1) { create(:labeled_issue, project: project, title: "testing 1", labels: [label], relative_position: 3) }
+ let!(:issue2) { create(:labeled_issue, project: project, title: "testing 2", labels: [label], relative_position: 2) }
+ let!(:issue3) { create(:labeled_issue, project: project, title: "testing 3", labels: [label], relative_position: 1) }
before do
project.add_maintainer(user)
@@ -18,147 +18,147 @@ describe 'Issue Boards', :js do
sign_in(user)
end
- context 'un-ordered issues' do
+ context "un-ordered issues" do
let!(:issue4) { create(:labeled_issue, project: project, labels: [label]) }
before do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'has un-ordered issue as last issue' do
- page.within(find('.board:nth-child(2)')) do
- expect(all('.board-card').last).to have_content(issue4.title)
+ it "has un-ordered issue as last issue" do
+ page.within(find(".board:nth-child(2)")) do
+ expect(all(".board-card").last).to have_content(issue4.title)
end
end
- it 'moves un-ordered issue to top of list' do
+ it "moves un-ordered issue to top of list" do
drag(from_index: 3, to_index: 0, duration: 1180)
wait_for_requests
- page.within(find('.board:nth-child(2)')) do
- expect(first('.board-card')).to have_content(issue4.title)
+ page.within(find(".board:nth-child(2)")) do
+ expect(first(".board-card")).to have_content(issue4.title)
end
end
end
- context 'ordering in list' do
+ context "ordering in list" do
before do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'moves from middle to top' do
+ it "moves from middle to top" do
drag(from_index: 1, to_index: 0)
wait_for_requests
- expect(first('.board-card')).to have_content(issue2.title)
+ expect(first(".board-card")).to have_content(issue2.title)
end
- it 'moves from middle to bottom' do
+ it "moves from middle to bottom" do
drag(from_index: 1, to_index: 2)
wait_for_requests
- expect(all('.board-card').last).to have_content(issue2.title)
+ expect(all(".board-card").last).to have_content(issue2.title)
end
- it 'moves from top to bottom' do
+ it "moves from top to bottom" do
drag(from_index: 0, to_index: 2)
wait_for_requests
- expect(all('.board-card').last).to have_content(issue3.title)
+ expect(all(".board-card").last).to have_content(issue3.title)
end
- it 'moves from bottom to top' do
+ it "moves from bottom to top" do
drag(from_index: 2, to_index: 0, duration: 1020)
wait_for_requests
- expect(first('.board-card')).to have_content(issue1.title)
+ expect(first(".board-card")).to have_content(issue1.title)
end
- it 'moves from top to middle' do
+ it "moves from top to middle" do
drag(from_index: 0, to_index: 1)
wait_for_requests
- expect(first('.board-card')).to have_content(issue2.title)
+ expect(first(".board-card")).to have_content(issue2.title)
end
- it 'moves from bottom to middle' do
+ it "moves from bottom to middle" do
drag(from_index: 2, to_index: 1)
wait_for_requests
- expect(all('.board-card').last).to have_content(issue2.title)
+ expect(all(".board-card").last).to have_content(issue2.title)
end
end
- context 'ordering when changing list' do
+ context "ordering when changing list" do
let(:label2) { create(:label, project: project) }
let!(:list2) { create(:list, board: board, label: label2, position: 1) }
- let!(:issue4) { create(:labeled_issue, project: project, title: 'testing 1', labels: [label2], relative_position: 3.0) }
- let!(:issue5) { create(:labeled_issue, project: project, title: 'testing 2', labels: [label2], relative_position: 2.0) }
- let!(:issue6) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label2], relative_position: 1.0) }
+ let!(:issue4) { create(:labeled_issue, project: project, title: "testing 1", labels: [label2], relative_position: 3.0) }
+ let!(:issue5) { create(:labeled_issue, project: project, title: "testing 2", labels: [label2], relative_position: 2.0) }
+ let!(:issue6) { create(:labeled_issue, project: project, title: "testing 3", labels: [label2], relative_position: 1.0) }
before do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 4)
+ expect(page).to have_selector(".board", count: 4)
end
- it 'moves to top of another list' do
+ it "moves to top of another list" do
drag(list_from_index: 1, list_to_index: 2)
wait_for_requests
- expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
- expect(all('.board')[2]).to have_selector('.board-card', count: 4)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card", count: 2)
+ expect(all(".board")[2]).to have_selector(".board-card", count: 4)
- page.within(all('.board')[2]) do
- expect(first('.board-card')).to have_content(issue3.title)
+ page.within(all(".board")[2]) do
+ expect(first(".board-card")).to have_content(issue3.title)
end
end
- it 'moves to bottom of another list' do
+ it "moves to bottom of another list" do
drag(list_from_index: 1, list_to_index: 2, to_index: 2, duration: 1020)
wait_for_requests
- expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
- expect(all('.board')[2]).to have_selector('.board-card', count: 4)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card", count: 2)
+ expect(all(".board")[2]).to have_selector(".board-card", count: 4)
- page.within(all('.board')[2]) do
- expect(all('.board-card').last).to have_content(issue3.title)
+ page.within(all(".board")[2]) do
+ expect(all(".board-card").last).to have_content(issue3.title)
end
end
- it 'moves to index of another list' do
+ it "moves to index of another list" do
drag(list_from_index: 1, list_to_index: 2, to_index: 1)
wait_for_requests
- expect(find('.board:nth-child(2)')).to have_selector('.board-card', count: 2)
- expect(all('.board')[2]).to have_selector('.board-card', count: 4)
+ expect(find(".board:nth-child(2)")).to have_selector(".board-card", count: 2)
+ expect(all(".board")[2]).to have_selector(".board-card", count: 4)
- page.within(all('.board')[2]) do
- expect(all('.board-card')[1]).to have_content(issue3.title)
+ page.within(all(".board")[2]) do
+ expect(all(".board-card")[1]).to have_content(issue3.title)
end
end
end
- def drag(selector: '.board-list', list_from_index: 1, from_index: 0, to_index: 0, list_to_index: 1, duration: 1000)
+ def drag(selector: ".board-list", list_from_index: 1, from_index: 0, to_index: 0, list_to_index: 1, duration: 1000)
drag_to(selector: selector,
- scrollable: '#board-app',
+ scrollable: "#board-app",
list_from_index: list_from_index,
from_index: from_index,
to_index: to_index,
diff --git a/spec/features/boards/keyboard_shortcut_spec.rb b/spec/features/boards/keyboard_shortcut_spec.rb
index d820a59aa16..d5bf4db2835 100644
--- a/spec/features/boards/keyboard_shortcut_spec.rb
+++ b/spec/features/boards/keyboard_shortcut_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards shortcut', :js do
- context 'issues are enabled' do
+describe "Issue Boards shortcut", :js do
+ context "issues are enabled" do
let(:project) { create(:project) }
before do
@@ -12,15 +12,15 @@ describe 'Issue Boards shortcut', :js do
visit project_path(project)
end
- it 'takes user to issue board index' do
- find('body').native.send_keys('gb')
- expect(page).to have_selector('.boards-list')
+ it "takes user to issue board index" do
+ find("body").native.send_keys("gb")
+ expect(page).to have_selector(".boards-list")
wait_for_requests
end
end
- context 'issues are not enabled' do
+ context "issues are not enabled" do
let(:project) { create(:project, :issues_disabled) }
before do
@@ -29,8 +29,8 @@ describe 'Issue Boards shortcut', :js do
visit project_path(project)
end
- it 'does not take user to the issue board index' do
- find('body').native.send_keys('gb')
+ it "does not take user to the issue board index" do
+ find("body").native.send_keys("gb")
expect(page).to have_selector("body[data-page='projects:show']")
end
diff --git a/spec/features/boards/modal_filter_spec.rb b/spec/features/boards/modal_filter_spec.rb
index e42d18b457e..3d3005fe462 100644
--- a/spec/features/boards/modal_filter_spec.rb
+++ b/spec/features/boards/modal_filter_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards add issue modal filtering', :js do
+describe "Issue Boards add issue modal filtering", :js do
let(:project) { create(:project, :public) }
let(:board) { create(:board, project: project) }
- let(:planning) { create(:label, project: project, name: 'Planning') }
+ let(:planning) { create(:label, project: project, name: "Planning") }
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
@@ -15,64 +15,64 @@ describe 'Issue Boards add issue modal filtering', :js do
sign_in(user)
end
- it 'shows empty state when no results found' do
+ it "shows empty state when no results found" do
visit_board
- page.within('.add-issues-modal') do
- find('.form-control').native.send_keys('testing empty state')
- find('.form-control').native.send_keys(:enter)
+ page.within(".add-issues-modal") do
+ find(".form-control").native.send_keys("testing empty state")
+ find(".form-control").native.send_keys(:enter)
wait_for_requests
- expect(page).to have_content('There are no issues to show.')
+ expect(page).to have_content("There are no issues to show.")
end
end
- it 'restores filters when closing' do
+ it "restores filters when closing" do
visit_board
- set_filter('milestone')
- click_filter_link('Upcoming')
+ set_filter("milestone")
+ click_filter_link("Upcoming")
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.board-card', count: 0)
+ expect(page).to have_selector(".board-card", count: 0)
- click_button 'Cancel'
+ click_button "Cancel"
end
- click_button('Add issues')
+ click_button("Add issues")
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'resotres filters after clicking clear button' do
+ it "resotres filters after clicking clear button" do
visit_board
- set_filter('milestone')
- click_filter_link('Upcoming')
+ set_filter("milestone")
+ click_filter_link("Upcoming")
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.board-card', count: 0)
+ expect(page).to have_selector(".board-card", count: 0)
- find('.clear-search').click
+ find(".clear-search").click
wait_for_requests
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- context 'author' do
+ context "author" do
let!(:issue) { create(:issue, project: project, author: user2) }
before do
@@ -81,21 +81,21 @@ describe 'Issue Boards add issue modal filtering', :js do
visit_board
end
- it 'filters by selected user' do
- set_filter('author')
+ it "filters by selected user" do
+ set_filter("author")
click_filter_link(user2.name)
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: user2.name)
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: user2.name)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
end
- context 'assignee' do
+ context "assignee" do
let!(:issue) { create(:issue, project: project, assignees: [user2]) }
before do
@@ -104,34 +104,34 @@ describe 'Issue Boards add issue modal filtering', :js do
visit_board
end
- it 'filters by unassigned' do
- set_filter('assignee')
- click_filter_link('None')
+ it "filters by unassigned" do
+ set_filter("assignee")
+ click_filter_link("None")
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: 'None')
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: "None")
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'filters by selected user' do
- set_filter('assignee')
+ it "filters by selected user" do
+ set_filter("assignee")
click_filter_link(user2.name)
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: user2.name)
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: user2.name)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
end
- context 'milestone' do
+ context "milestone" do
let(:milestone) { create(:milestone, project: project) }
let!(:issue) { create(:issue, project: project, milestone: milestone) }
@@ -139,34 +139,34 @@ describe 'Issue Boards add issue modal filtering', :js do
visit_board
end
- it 'filters by upcoming milestone' do
- set_filter('milestone')
- click_filter_link('Upcoming')
+ it "filters by upcoming milestone" do
+ set_filter("milestone")
+ click_filter_link("Upcoming")
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: 'Upcoming')
- expect(page).to have_selector('.board-card', count: 0)
+ expect(page).to have_selector(".js-visual-token", text: "Upcoming")
+ expect(page).to have_selector(".board-card", count: 0)
end
end
- it 'filters by selected milestone' do
- set_filter('milestone')
+ it "filters by selected milestone" do
+ set_filter("milestone")
click_filter_link(milestone.name)
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: milestone.name)
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: milestone.name)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
end
- context 'label' do
+ context "label" do
let(:label) { create(:label, project: project) }
let!(:issue) { create(:labeled_issue, project: project, labels: [label]) }
@@ -174,29 +174,29 @@ describe 'Issue Boards add issue modal filtering', :js do
visit_board
end
- it 'filters by no label' do
- set_filter('label')
- click_filter_link('None')
+ it "filters by no label" do
+ set_filter("label")
+ click_filter_link("None")
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: 'None')
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: "None")
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'filters by label' do
- set_filter('label')
+ it "filters by label" do
+ set_filter("label")
click_filter_link(label.title)
submit_filter
- page.within('.add-issues-modal') do
+ page.within(".add-issues-modal") do
wait_for_requests
- expect(page).to have_selector('.js-visual-token', text: label.title)
- expect(page).to have_selector('.board-card', count: 1)
+ expect(page).to have_selector(".js-visual-token", text: label.title)
+ expect(page).to have_selector(".board-card", count: 1)
end
end
end
@@ -205,19 +205,19 @@ describe 'Issue Boards add issue modal filtering', :js do
visit project_board_path(project, board)
wait_for_requests
- click_button('Add issues')
+ click_button("Add issues")
end
- def set_filter(type, text = '')
- find('.add-issues-modal .filtered-search').native.send_keys("#{type}:#{text}")
+ def set_filter(type, text = "")
+ find(".add-issues-modal .filtered-search").native.send_keys("#{type}:#{text}")
end
def submit_filter
- find('.add-issues-modal .filtered-search').native.send_keys(:enter)
+ find(".add-issues-modal .filtered-search").native.send_keys(:enter)
end
def click_filter_link(link_text)
- page.within('.add-issues-modal .filtered-search-box') do
+ page.within(".add-issues-modal .filtered-search-box") do
expect(page).to have_button(link_text)
click_button(link_text)
diff --git a/spec/features/boards/new_issue_spec.rb b/spec/features/boards/new_issue_spec.rb
index d0c4534e317..856beb9df25 100644
--- a/spec/features/boards/new_issue_spec.rb
+++ b/spec/features/boards/new_issue_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards new issue', :js do
+describe "Issue Boards new issue", :js do
let(:project) { create(:project, :public) }
let(:board) { create(:board, project: project) }
let!(:list) { create(:list, board: board, position: 0) }
let(:user) { create(:user) }
- context 'authorized user' do
+ context "authorized user" do
before do
project.add_maintainer(user)
@@ -15,113 +15,113 @@ describe 'Issue Boards new issue', :js do
visit project_board_path(project, board)
wait_for_requests
- expect(page).to have_selector('.board', count: 3)
+ expect(page).to have_selector(".board", count: 3)
end
- it 'displays new issue button' do
- expect(first('.board')).to have_selector('.issue-count-badge-add-button', count: 1)
+ it "displays new issue button" do
+ expect(first(".board")).to have_selector(".issue-count-badge-add-button", count: 1)
end
- it 'does not display new issue button in closed list' do
- page.within('.board:nth-child(3)') do
- expect(page).not_to have_selector('.issue-count-badge-add-button')
+ it "does not display new issue button in closed list" do
+ page.within(".board:nth-child(3)") do
+ expect(page).not_to have_selector(".issue-count-badge-add-button")
end
end
- it 'shows form when clicking button' do
- page.within(first('.board')) do
- find('.issue-count-badge-add-button').click
+ it "shows form when clicking button" do
+ page.within(first(".board")) do
+ find(".issue-count-badge-add-button").click
- expect(page).to have_selector('.board-new-issue-form')
+ expect(page).to have_selector(".board-new-issue-form")
end
end
- it 'hides form when clicking cancel' do
- page.within(first('.board')) do
- find('.issue-count-badge-add-button').click
+ it "hides form when clicking cancel" do
+ page.within(first(".board")) do
+ find(".issue-count-badge-add-button").click
- expect(page).to have_selector('.board-new-issue-form')
+ expect(page).to have_selector(".board-new-issue-form")
- click_button 'Cancel'
+ click_button "Cancel"
- expect(page).not_to have_selector('.board-new-issue-form')
+ expect(page).not_to have_selector(".board-new-issue-form")
end
end
- it 'creates new issue' do
- page.within(first('.board')) do
- find('.issue-count-badge-add-button').click
+ it "creates new issue" do
+ page.within(first(".board")) do
+ find(".issue-count-badge-add-button").click
end
- page.within(first('.board-new-issue-form')) do
- find('.form-control').set('bug')
- click_button 'Submit issue'
+ page.within(first(".board-new-issue-form")) do
+ find(".form-control").set("bug")
+ click_button "Submit issue"
end
wait_for_requests
- page.within(first('.board .issue-count-badge-count')) do
- expect(page).to have_content('1')
+ page.within(first(".board .issue-count-badge-count")) do
+ expect(page).to have_content("1")
end
- page.within(first('.board-card')) do
- issue = project.issues.find_by_title('bug')
+ page.within(first(".board-card")) do
+ issue = project.issues.find_by_title("bug")
expect(page).to have_content(issue.to_reference)
expect(page).to have_link(issue.title, href: issue_path(issue))
end
end
- it 'shows sidebar when creating new issue' do
- page.within(first('.board')) do
- find('.issue-count-badge-add-button').click
+ it "shows sidebar when creating new issue" do
+ page.within(first(".board")) do
+ find(".issue-count-badge-add-button").click
end
- page.within(first('.board-new-issue-form')) do
- find('.form-control').set('bug')
- click_button 'Submit issue'
+ page.within(first(".board-new-issue-form")) do
+ find(".form-control").set("bug")
+ click_button "Submit issue"
end
wait_for_requests
- expect(page).to have_selector('.issue-boards-sidebar')
+ expect(page).to have_selector(".issue-boards-sidebar")
end
- it 'successfuly loads labels to be added to newly created issue' do
- page.within(first('.board')) do
- find('.issue-count-badge-add-button').click
+ it "successfuly loads labels to be added to newly created issue" do
+ page.within(first(".board")) do
+ find(".issue-count-badge-add-button").click
end
- page.within(first('.board-new-issue-form')) do
- find('.form-control').set('new issue')
- click_button 'Submit issue'
+ page.within(first(".board-new-issue-form")) do
+ find(".form-control").set("new issue")
+ click_button "Submit issue"
end
wait_for_requests
- page.within(first('.issue-boards-sidebar')) do
- find('.labels .edit-link').click
+ page.within(first(".issue-boards-sidebar")) do
+ find(".labels .edit-link").click
wait_for_requests
- expect(page).to have_selector('.labels .dropdown-content li a')
+ expect(page).to have_selector(".labels .dropdown-content li a")
end
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
before do
visit project_board_path(project, board)
wait_for_requests
end
- it 'displays new issue button in open list' do
- expect(first('.board')).to have_selector('.issue-count-badge-add-button', count: 1)
+ it "displays new issue button in open list" do
+ expect(first(".board")).to have_selector(".issue-count-badge-add-button", count: 1)
end
- it 'does not display new issue button in label list' do
- page.within('.board:nth-child(2)') do
- expect(page).not_to have_selector('.issue-count-badge-add-button')
+ it "does not display new issue button in label list" do
+ page.within(".board:nth-child(2)") do
+ expect(page).not_to have_selector(".issue-count-badge-add-button")
end
end
end
diff --git a/spec/features/boards/reload_boards_on_browser_back_spec.rb b/spec/features/boards/reload_boards_on_browser_back_spec.rb
index 4b4bd705a77..1a88d7d94e8 100644
--- a/spec/features/boards/reload_boards_on_browser_back_spec.rb
+++ b/spec/features/boards/reload_boards_on_browser_back_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Ensure Boards do not show stale data on browser back', :js do
+describe "Ensure Boards do not show stale data on browser back", :js do
let(:project) {create(:project, :public)}
let(:board) {create(:board, project: project)}
let(:user) {create(:user)}
- context 'authorized user' do
+ context "authorized user" do
before do
project.add_maintainer(user)
@@ -14,18 +14,18 @@ describe 'Ensure Boards do not show stale data on browser back', :js do
visit project_board_path(project, board)
wait_for_requests
- page.within(first('.board .issue-count-badge-count')) do
- expect(page).to have_content('0')
+ page.within(first(".board .issue-count-badge-count")) do
+ expect(page).to have_content("0")
end
end
- it 'created issue is listed on board' do
+ it "created issue is listed on board" do
visit new_project_issue_path(project)
wait_for_requests
- fill_in 'issue_title', with: 'issue should be shown'
+ fill_in "issue_title", with: "issue should be shown"
- click_button 'Submit issue'
+ click_button "Submit issue"
page.go_back
wait_for_requests
@@ -33,12 +33,12 @@ describe 'Ensure Boards do not show stale data on browser back', :js do
page.go_back
wait_for_requests
- page.within(first('.board .issue-count-badge-count')) do
- expect(page).to have_content('1')
+ page.within(first(".board .issue-count-badge-count")) do
+ expect(page).to have_content("1")
end
- page.within(first('.board-card')) do
- issue = project.issues.find_by_title('issue should be shown')
+ page.within(first(".board-card")) do
+ issue = project.issues.find_by_title("issue should be shown")
expect(page).to have_content(issue.to_reference)
expect(page).to have_link(issue.title, href: issue_path(issue))
diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb
index ee38e756f9e..d900e306d43 100644
--- a/spec/features/boards/sidebar_spec.rb
+++ b/spec/features/boards/sidebar_spec.rb
@@ -1,21 +1,21 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Boards', :js do
+describe "Issue Boards", :js do
include BoardHelpers
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:project) { create(:project, :public) }
let!(:milestone) { create(:milestone, project: project) }
- let!(:development) { create(:label, project: project, name: 'Development') }
- let!(:bug) { create(:label, project: project, name: 'Bug') }
- let!(:regression) { create(:label, project: project, name: 'Regression') }
- let!(:stretch) { create(:label, project: project, name: 'Stretch') }
+ let!(:development) { create(:label, project: project, name: "Development") }
+ let!(:bug) { create(:label, project: project, name: "Bug") }
+ let!(:regression) { create(:label, project: project, name: "Regression") }
+ let!(:stretch) { create(:label, project: project, name: "Stretch") }
let!(:issue1) { create(:labeled_issue, project: project, assignees: [user], milestone: milestone, labels: [development], relative_position: 2) }
let!(:issue2) { create(:labeled_issue, project: project, labels: [development, stretch], relative_position: 1) }
let(:board) { create(:board, project: project) }
let!(:list) { create(:list, board: board, label: development, position: 0) }
- let(:card) { find('.board:nth-child(2)').first('.board-card') }
+ let(:card) { find(".board:nth-child(2)").first(".board-card") }
around do |example|
Timecop.freeze { example.run }
@@ -30,81 +30,81 @@ describe 'Issue Boards', :js do
wait_for_requests
end
- it 'shows sidebar when clicking issue' do
+ it "shows sidebar when clicking issue" do
click_card(card)
- expect(page).to have_selector('.issue-boards-sidebar')
+ expect(page).to have_selector(".issue-boards-sidebar")
end
- it 'closes sidebar when clicking issue' do
+ it "closes sidebar when clicking issue" do
click_card(card)
- expect(page).to have_selector('.issue-boards-sidebar')
+ expect(page).to have_selector(".issue-boards-sidebar")
click_card(card)
- expect(page).not_to have_selector('.issue-boards-sidebar')
+ expect(page).not_to have_selector(".issue-boards-sidebar")
end
- it 'closes sidebar when clicking close button' do
+ it "closes sidebar when clicking close button" do
click_card(card)
- expect(page).to have_selector('.issue-boards-sidebar')
+ expect(page).to have_selector(".issue-boards-sidebar")
- find('.gutter-toggle').click
+ find(".gutter-toggle").click
- expect(page).not_to have_selector('.issue-boards-sidebar')
+ expect(page).not_to have_selector(".issue-boards-sidebar")
end
- it 'shows issue details when sidebar is open' do
+ it "shows issue details when sidebar is open" do
click_card(card)
- page.within('.issue-boards-sidebar') do
+ page.within(".issue-boards-sidebar") do
expect(page).to have_content(issue2.title)
expect(page).to have_content(issue2.to_reference)
end
end
- it 'removes card from board when clicking ' do
+ it "removes card from board when clicking " do
click_card(card)
- page.within('.issue-boards-sidebar') do
- click_button 'Remove from board'
+ page.within(".issue-boards-sidebar") do
+ click_button "Remove from board"
end
wait_for_requests
- page.within(find('.board:nth-child(2)')) do
- expect(page).to have_selector('.board-card', count: 1)
+ page.within(find(".board:nth-child(2)")) do
+ expect(page).to have_selector(".board-card", count: 1)
end
end
- it 'does not show remove button for backlog or closed issues' do
+ it "does not show remove button for backlog or closed issues" do
create(:issue, project: project)
create(:issue, :closed, project: project)
visit project_board_path(project, board)
wait_for_requests
- click_card(find('.board:nth-child(1)').first('.board-card'))
+ click_card(find(".board:nth-child(1)").first(".board-card"))
- expect(find('.issue-boards-sidebar')).not_to have_button 'Remove from board'
+ expect(find(".issue-boards-sidebar")).not_to have_button "Remove from board"
- click_card(find('.board:nth-child(3)').first('.board-card'))
+ click_card(find(".board:nth-child(3)").first(".board-card"))
- expect(find('.issue-boards-sidebar')).not_to have_button 'Remove from board'
+ expect(find(".issue-boards-sidebar")).not_to have_button "Remove from board"
end
- context 'assignee' do
- it 'updates the issues assignee' do
+ context "assignee" do
+ it "updates the issues assignee" do
click_card(card)
- page.within('.assignee') do
- click_link 'Edit'
+ page.within(".assignee") do
+ click_link "Edit"
wait_for_requests
- page.within('.dropdown-menu-user') do
+ page.within(".dropdown-menu-user") do
click_link user.name
wait_for_requests
@@ -113,55 +113,55 @@ describe 'Issue Boards', :js do
expect(page).to have_content(user.name)
end
- expect(card).to have_selector('.avatar')
+ expect(card).to have_selector(".avatar")
end
- it 'removes the assignee' do
- card_two = find('.board:nth-child(2)').find('.board-card:nth-child(2)')
+ it "removes the assignee" do
+ card_two = find(".board:nth-child(2)").find(".board-card:nth-child(2)")
click_card(card_two)
- page.within('.assignee') do
- click_link 'Edit'
+ page.within(".assignee") do
+ click_link "Edit"
wait_for_requests
- page.within('.dropdown-menu-user') do
- click_link 'Unassigned'
+ page.within(".dropdown-menu-user") do
+ click_link "Unassigned"
end
wait_for_requests
- expect(page).to have_content('No assignee')
+ expect(page).to have_content("No assignee")
end
- expect(card_two).not_to have_selector('.avatar')
+ expect(card_two).not_to have_selector(".avatar")
end
- it 'assignees to current user' do
+ it "assignees to current user" do
click_card(card)
- page.within(find('.assignee')) do
- expect(page).to have_content('No assignee')
+ page.within(find(".assignee")) do
+ expect(page).to have_content("No assignee")
- click_button 'assign yourself'
+ click_button "assign yourself"
wait_for_requests
expect(page).to have_content(user.name)
end
- expect(card).to have_selector('.avatar')
+ expect(card).to have_selector(".avatar")
end
- it 'updates assignee dropdown' do
+ it "updates assignee dropdown" do
click_card(card)
- page.within('.assignee') do
- click_link 'Edit'
+ page.within(".assignee") do
+ click_link "Edit"
wait_for_requests
- page.within('.dropdown-menu-user') do
+ page.within(".dropdown-menu-user") do
click_link user.name
wait_for_requests
@@ -170,24 +170,24 @@ describe 'Issue Boards', :js do
expect(page).to have_content(user.name)
end
- page.within(find('.board:nth-child(2)')) do
- find('.board-card:nth-child(2)').click
+ page.within(find(".board:nth-child(2)")) do
+ find(".board-card:nth-child(2)").click
end
- page.within('.assignee') do
- click_link 'Edit'
+ page.within(".assignee") do
+ click_link "Edit"
- expect(find('.dropdown-menu')).to have_selector('.is-active')
+ expect(find(".dropdown-menu")).to have_selector(".is-active")
end
end
end
- context 'milestone' do
- it 'adds a milestone' do
+ context "milestone" do
+ it "adds a milestone" do
click_card(card)
- page.within('.milestone') do
- click_link 'Edit'
+ page.within(".milestone") do
+ click_link "Edit"
wait_for_requests
@@ -195,17 +195,17 @@ describe 'Issue Boards', :js do
wait_for_requests
- page.within('.value') do
+ page.within(".value") do
expect(page).to have_content(milestone.title)
end
end
end
- it 'removes a milestone' do
+ it "removes a milestone" do
click_card(card)
- page.within('.milestone') do
- click_link 'Edit'
+ page.within(".milestone") do
+ click_link "Edit"
wait_for_requests
@@ -213,19 +213,19 @@ describe 'Issue Boards', :js do
wait_for_requests
- page.within('.value') do
+ page.within(".value") do
expect(page).not_to have_content(milestone.title)
end
end
end
end
- context 'due date' do
- it 'updates due date' do
+ context "due date" do
+ it "updates due date" do
click_card(card)
- page.within('.due_date') do
- click_link 'Edit'
+ page.within(".due_date") do
+ click_link "Edit"
click_button Date.today.day
@@ -236,28 +236,28 @@ describe 'Issue Boards', :js do
end
end
- context 'labels' do
- it 'shows current labels when editing' do
+ context "labels" do
+ it "shows current labels when editing" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
+ page.within(".labels") do
+ click_link "Edit"
wait_for_requests
- page.within('.value') do
- expect(page).to have_selector('.badge', count: 2)
+ page.within(".value") do
+ expect(page).to have_selector(".badge", count: 2)
expect(page).to have_content(development.title)
expect(page).to have_content(stretch.title)
end
end
end
- it 'adds a single label' do
+ it "adds a single label" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
+ page.within(".labels") do
+ click_link "Edit"
wait_for_requests
@@ -265,23 +265,23 @@ describe 'Issue Boards', :js do
wait_for_requests
- find('.dropdown-menu-close-icon').click
+ find(".dropdown-menu-close-icon").click
- page.within('.value') do
- expect(page).to have_selector('.badge', count: 3)
+ page.within(".value") do
+ expect(page).to have_selector(".badge", count: 3)
expect(page).to have_content(bug.title)
end
end
- expect(card).to have_selector('.badge', count: 3)
+ expect(card).to have_selector(".badge", count: 3)
expect(card).to have_content(bug.title)
end
- it 'adds a multiple labels' do
+ it "adds a multiple labels" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
+ page.within(".labels") do
+ click_link "Edit"
wait_for_requests
@@ -290,76 +290,76 @@ describe 'Issue Boards', :js do
wait_for_requests
- find('.dropdown-menu-close-icon').click
+ find(".dropdown-menu-close-icon").click
- page.within('.value') do
- expect(page).to have_selector('.badge', count: 4)
+ page.within(".value") do
+ expect(page).to have_selector(".badge", count: 4)
expect(page).to have_content(bug.title)
expect(page).to have_content(regression.title)
end
end
- expect(card).to have_selector('.badge', count: 4)
+ expect(card).to have_selector(".badge", count: 4)
expect(card).to have_content(bug.title)
expect(card).to have_content(regression.title)
end
- it 'removes a label' do
+ it "removes a label" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
+ page.within(".labels") do
+ click_link "Edit"
wait_for_requests
- within('.dropdown-menu-labels') do
+ within(".dropdown-menu-labels") do
click_link stretch.title
end
wait_for_requests
- find('.dropdown-menu-close-icon').click
+ find(".dropdown-menu-close-icon").click
- page.within('.value') do
- expect(page).to have_selector('.badge', count: 1)
+ page.within(".value") do
+ expect(page).to have_selector(".badge", count: 1)
expect(page).not_to have_content(stretch.title)
end
end
- expect(card).to have_selector('.badge', count: 1)
+ expect(card).to have_selector(".badge", count: 1)
expect(card).not_to have_content(stretch.title)
end
- it 'creates project label' do
+ it "creates project label" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
- click_link 'Create project label'
- fill_in 'new_label_name', with: 'test label'
- first('.suggest-colors-dropdown a').click
- click_button 'Create'
+ page.within(".labels") do
+ click_link "Edit"
+ click_link "Create project label"
+ fill_in "new_label_name", with: "test label"
+ first(".suggest-colors-dropdown a").click
+ click_button "Create"
wait_for_requests
- expect(page).to have_link 'test label'
+ expect(page).to have_link "test label"
end
end
end
- context 'subscription' do
- it 'changes issue subscription' do
+ context "subscription" do
+ it "changes issue subscription" do
click_card(card)
wait_for_requests
- page.within('.subscriptions') do
- find('.js-issuable-subscribe-button button:not(.is-checked)').click
+ page.within(".subscriptions") do
+ find(".js-issuable-subscribe-button button:not(.is-checked)").click
wait_for_requests
- expect(page).to have_css('.js-issuable-subscribe-button button.is-checked')
+ expect(page).to have_css(".js-issuable-subscribe-button button.is-checked")
end
end
- it 'has checked subscription toggle when already subscribed' do
+ it "has checked subscription toggle when already subscribed" do
create(:subscription, user: user, project: project, subscribable: issue2, subscribed: true)
visit project_board_path(project, board)
wait_for_requests
@@ -367,11 +367,11 @@ describe 'Issue Boards', :js do
click_card(card)
wait_for_requests
- page.within('.subscriptions') do
- find('.js-issuable-subscribe-button button.is-checked').click
+ page.within(".subscriptions") do
+ find(".js-issuable-subscribe-button button.is-checked").click
wait_for_requests
- expect(page).to have_css('.js-issuable-subscribe-button button:not(.is-checked)')
+ expect(page).to have_css(".js-issuable-subscribe-button button:not(.is-checked)")
end
end
end
diff --git a/spec/features/boards/sub_group_project_spec.rb b/spec/features/boards/sub_group_project_spec.rb
index de2cb4c335e..90a980fdea1 100644
--- a/spec/features/boards/sub_group_project_spec.rb
+++ b/spec/features/boards/sub_group_project_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Sub-group project issue boards', :js do
+describe "Sub-group project issue boards", :js do
let(:group) { create(:group) }
let(:nested_group_1) { create(:group, parent: group) }
let(:project) { create(:project, group: nested_group_1) }
@@ -19,25 +19,25 @@ describe 'Sub-group project issue boards', :js do
wait_for_requests
end
- it 'creates new label from sidebar' do
- find('.board-card').click
+ it "creates new label from sidebar" do
+ find(".board-card").click
- page.within '.labels' do
- click_link 'Edit'
- click_link 'Create project label'
+ page.within ".labels" do
+ click_link "Edit"
+ click_link "Create project label"
end
- page.within '.dropdown-new-label' do
- fill_in 'new_label_name', with: 'test label'
- first('.suggest-colors-dropdown a').click
+ page.within ".dropdown-new-label" do
+ fill_in "new_label_name", with: "test label"
+ first(".suggest-colors-dropdown a").click
- click_button 'Create'
+ click_button "Create"
wait_for_requests
end
- page.within '.labels' do
- expect(page).to have_link 'test label'
+ page.within ".labels" do
+ expect(page).to have_link "test label"
end
end
end
diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb
index 8cb9b57a049..76fed0dfff9 100644
--- a/spec/features/calendar_spec.rb
+++ b/spec/features/calendar_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Contributions Calendar', :js do
+describe "Contributions Calendar", :js do
let(:user) { create(:user) }
let(:contributed_project) { create(:project, :public, :repository) }
let(:issue_note) { create(:note, project: contributed_project) }
# Ex/ Sunday Jan 1, 2016
- date_format = '%A %b %-d, %Y'
+ date_format = "%A %b %-d, %Y"
- issue_title = 'Bug in old browser'
- issue_params = { title: issue_title }
+ issue_title = "Bug in old browser"
+ issue_params = {title: issue_title}
def get_cell_color_selector(contributions)
activity_colors = ["#ededed", "rgb(172, 213, 242)", "rgb(127, 168, 201)", "rgb(82, 123, 160)", "rgb(37, 78, 119)"]
@@ -33,9 +33,9 @@ describe 'Contributions Calendar', :js do
def get_cell_date_selector(contributions, date)
contribution_text =
if contributions.zero?
- 'No contributions'
+ "No contributions"
else
- "#{contributions} #{'contribution'.pluralize(contributions)}"
+ "#{contributions} #{"contribution".pluralize(contributions)}"
end
"#{get_cell_color_selector(contributions)}[data-original-title='#{contribution_text}<br />#{date}']"
@@ -45,11 +45,11 @@ describe 'Contributions Calendar', :js do
event = create(:push_event, project: contributed_project, author: user)
create(:push_event_payload,
- event: event,
- commit_from: '11f9ac0a48b62cef25eedede4c1819964f08d5ce',
- commit_to: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
- commit_count: 3,
- ref: 'master')
+ event: event,
+ commit_from: "11f9ac0a48b62cef25eedede4c1819964f08d5ce",
+ commit_to: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
+ commit_count: 3,
+ ref: "master")
end
def note_comment_contribution
@@ -57,33 +57,33 @@ describe 'Contributions Calendar', :js do
project: contributed_project,
action: Event::COMMENTED,
target: issue_note,
- author_id: user.id
+ author_id: user.id,
}
Event.create(note_comment_params)
end
def selected_day_activities(visible: true)
- find('#js-overview .user-calendar-activities', visible: visible).text
+ find("#js-overview .user-calendar-activities", visible: visible).text
end
before do
sign_in user
end
- describe 'calendar day selection' do
+ describe "calendar day selection" do
before do
visit user.username
- page.find('.js-overview-tab a').click
+ page.find(".js-overview-tab a").click
wait_for_requests
end
- it 'displays calendar' do
- expect(find('#js-overview')).to have_css('.js-contrib-calendar')
+ it "displays calendar" do
+ expect(find("#js-overview")).to have_css(".js-contrib-calendar")
end
- describe 'select calendar day' do
- let(:cells) { page.all('#js-overview .user-contrib-cell') }
+ describe "select calendar day" do
+ let(:cells) { page.all("#js-overview .user-contrib-cell") }
before do
cells[0].click
@@ -91,90 +91,90 @@ describe 'Contributions Calendar', :js do
@first_day_activities = selected_day_activities
end
- it 'displays calendar day activities' do
+ it "displays calendar day activities" do
expect(selected_day_activities).not_to be_empty
end
- describe 'select another calendar day' do
+ describe "select another calendar day" do
before do
cells[1].click
wait_for_requests
end
- it 'displays different calendar day activities' do
+ it "displays different calendar day activities" do
expect(selected_day_activities).not_to eq(@first_day_activities)
end
end
- describe 'deselect calendar day' do
+ describe "deselect calendar day" do
before do
cells[0].click
- page.find('.js-overview-tab a').click
+ page.find(".js-overview-tab a").click
wait_for_requests
end
- it 'hides calendar day activities' do
+ it "hides calendar day activities" do
expect(selected_day_activities(visible: false)).to be_empty
end
end
end
end
- describe 'calendar daily activities' do
- shared_context 'visit user page' do
+ describe "calendar daily activities" do
+ shared_context "visit user page" do
before do
visit user.username
- page.find('.js-overview-tab a').click
+ page.find(".js-overview-tab a").click
wait_for_requests
end
end
- shared_examples 'a day with activity' do |contribution_count:|
- include_context 'visit user page'
+ shared_examples "a day with activity" do |contribution_count:|
+ include_context "visit user page"
- it 'displays calendar activity square color for 1 contribution' do
- expect(find('#js-overview')).to have_selector(get_cell_color_selector(contribution_count), count: 1)
+ it "displays calendar activity square color for 1 contribution" do
+ expect(find("#js-overview")).to have_selector(get_cell_color_selector(contribution_count), count: 1)
end
- it 'displays calendar activity square on the correct date' do
+ it "displays calendar activity square on the correct date" do
today = Date.today.strftime(date_format)
- expect(find('#js-overview')).to have_selector(get_cell_date_selector(contribution_count, today), count: 1)
+ expect(find("#js-overview")).to have_selector(get_cell_date_selector(contribution_count, today), count: 1)
end
end
- describe '1 issue creation calendar activity' do
+ describe "1 issue creation calendar activity" do
before do
Issues::CreateService.new(contributed_project, user, issue_params).execute
end
- it_behaves_like 'a day with activity', contribution_count: 1
+ it_behaves_like "a day with activity", contribution_count: 1
- describe 'issue title is shown on activity page' do
- include_context 'visit user page'
+ describe "issue title is shown on activity page" do
+ include_context "visit user page"
- it 'displays calendar activity log' do
- expect(find('#js-overview .overview-content-list .event-target-title')).to have_content issue_title
+ it "displays calendar activity log" do
+ expect(find("#js-overview .overview-content-list .event-target-title")).to have_content issue_title
end
end
end
- describe '1 comment calendar activity' do
+ describe "1 comment calendar activity" do
before do
note_comment_contribution
end
- it_behaves_like 'a day with activity', contribution_count: 1
+ it_behaves_like "a day with activity", contribution_count: 1
end
- describe '10 calendar activities' do
+ describe "10 calendar activities" do
before do
10.times { push_code_contribution }
end
- it_behaves_like 'a day with activity', contribution_count: 10
+ it_behaves_like "a day with activity", contribution_count: 10
end
- describe 'calendar activity on two days' do
+ describe "calendar activity on two days" do
before do
push_code_contribution
@@ -182,20 +182,20 @@ describe 'Contributions Calendar', :js do
Issues::CreateService.new(contributed_project, user, issue_params).execute
end
end
- include_context 'visit user page'
+ include_context "visit user page"
- it 'displays calendar activity squares for both days' do
- expect(find('#js-overview')).to have_selector(get_cell_color_selector(1), count: 2)
+ it "displays calendar activity squares for both days" do
+ expect(find("#js-overview")).to have_selector(get_cell_color_selector(1), count: 2)
end
- it 'displays calendar activity square for yesterday' do
+ it "displays calendar activity square for yesterday" do
yesterday = Date.yesterday.strftime(date_format)
- expect(find('#js-overview')).to have_selector(get_cell_date_selector(1, yesterday), count: 1)
+ expect(find("#js-overview")).to have_selector(get_cell_date_selector(1, yesterday), count: 1)
end
- it 'displays calendar activity square for today' do
+ it "displays calendar activity square for today" do
today = Date.today.strftime(date_format)
- expect(find('#js-overview')).to have_selector(get_cell_date_selector(1, today), count: 1)
+ expect(find("#js-overview")).to have_selector(get_cell_date_selector(1, today), count: 1)
end
end
end
diff --git a/spec/features/clusters/cluster_detail_page_spec.rb b/spec/features/clusters/cluster_detail_page_spec.rb
index 0a9c4bcaf12..19737b4dcb0 100644
--- a/spec/features/clusters/cluster_detail_page_spec.rb
+++ b/spec/features/clusters/cluster_detail_page_spec.rb
@@ -1,66 +1,66 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Clusterable > Show page' do
+describe "Clusterable > Show page" do
let(:current_user) { create(:user) }
before do
sign_in(current_user)
end
- shared_examples 'editing domain' do
+ shared_examples "editing domain" do
before do
clusterable.add_maintainer(current_user)
end
- it 'allow the user to set domain' do
+ it "allow the user to set domain" do
visit cluster_path
- within '#cluster-integration' do
- fill_in('cluster_base_domain', with: 'test.com')
- click_on 'Save changes'
+ within "#cluster-integration" do
+ fill_in("cluster_base_domain", with: "test.com")
+ click_on "Save changes"
end
expect(page.status_code).to eq(200)
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
end
- context 'when there is a cluster with ingress and external ip' do
+ context "when there is a cluster with ingress and external ip" do
before do
- cluster.create_application_ingress!(external_ip: '192.168.1.100')
+ cluster.create_application_ingress!(external_ip: "192.168.1.100")
visit cluster_path
end
- it 'shows help text with the domain as an alternative to custom domain' do
- within '#cluster-integration' do
- expect(page).to have_content('Alternatively 192.168.1.100.nip.io can be used instead of a custom domain')
+ it "shows help text with the domain as an alternative to custom domain" do
+ within "#cluster-integration" do
+ expect(page).to have_content("Alternatively 192.168.1.100.nip.io can be used instead of a custom domain")
end
end
end
- context 'when there is no ingress' do
- it 'alternative to custom domain is not shown' do
+ context "when there is no ingress" do
+ it "alternative to custom domain is not shown" do
visit cluster_path
- within '#cluster-integration' do
- expect(page).not_to have_content('can be used instead of a custom domain.')
+ within "#cluster-integration" do
+ expect(page).not_to have_content("can be used instead of a custom domain.")
end
end
end
end
- context 'when clusterable is a project' do
- it_behaves_like 'editing domain' do
+ context "when clusterable is a project" do
+ it_behaves_like "editing domain" do
let(:clusterable) { create(:project) }
let(:cluster) { create(:cluster, :provided_by_gcp, :project, projects: [clusterable]) }
let(:cluster_path) { project_cluster_path(clusterable, cluster) }
end
end
- context 'when clusterable is a group' do
- it_behaves_like 'editing domain' do
+ context "when clusterable is a group" do
+ it_behaves_like "editing domain" do
let(:clusterable) { create(:group) }
let(:cluster) { create(:cluster, :provided_by_gcp, :group, groups: [clusterable]) }
let(:cluster_path) { group_cluster_path(clusterable, cluster) }
diff --git a/spec/features/commits/user_uses_quick_actions_spec.rb b/spec/features/commits/user_uses_quick_actions_spec.rb
index 9a4b7bd2444..235e6792642 100644
--- a/spec/features/commits/user_uses_quick_actions_spec.rb
+++ b/spec/features/commits/user_uses_quick_actions_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'Commit > User uses quick actions', :js do
+describe "Commit > User uses quick actions", :js do
include Spec::Support::Helpers::Features::NotesHelpers
include RepoHelpers
@@ -17,15 +17,15 @@ describe 'Commit > User uses quick actions', :js do
visit project_commit_path(project, commit.id)
end
- describe 'Tagging a commit' do
- let(:tag_name) { 'v1.2.3' }
- let(:tag_message) { 'Stable release' }
+ describe "Tagging a commit" do
+ let(:tag_name) { "v1.2.3" }
+ let(:tag_message) { "Stable release" }
let(:truncated_commit_sha) { Commit.truncate_sha(commit.sha) }
- it 'tags this commit' do
+ it "tags this commit" do
add_note("/tag #{tag_name} #{tag_message}")
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(page).to have_content "tagged commit #{truncated_commit_sha}"
expect(page).to have_content tag_name
@@ -35,12 +35,12 @@ describe 'Commit > User uses quick actions', :js do
expect(page).to have_content truncated_commit_sha
end
- describe 'preview', :js do
- it 'removes quick action from note and explains it' do
+ describe "preview", :js do
+ it "removes quick action from note and explains it" do
preview_note("/tag #{tag_name} #{tag_message}")
- expect(page).not_to have_content '/tag'
- expect(page).to have_content %{Tags this commit to #{tag_name} with "#{tag_message}"}
+ expect(page).not_to have_content "/tag"
+ expect(page).to have_content %(Tags this commit to #{tag_name} with "#{tag_message}")
expect(page).to have_content tag_name
end
end
diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb
index 5c6c1c4fd15..5bc56c8325c 100644
--- a/spec/features/commits_spec.rb
+++ b/spec/features/commits_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Commits' do
+describe "Commits" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- describe 'CI' do
+ describe "CI" do
before do
sign_in(user)
stub_ci_pipeline_to_return_yaml_file
@@ -14,104 +14,104 @@ describe 'Commits' do
let!(:pipeline) do
create(:ci_pipeline,
- project: project,
- user: creator,
- ref: project.default_branch,
- sha: project.commit.sha,
- status: :success,
- created_at: 5.months.ago)
+ project: project,
+ user: creator,
+ ref: project.default_branch,
+ sha: project.commit.sha,
+ status: :success,
+ created_at: 5.months.ago)
end
- context 'commit status is Generic Commit Status' do
+ context "commit status is Generic Commit Status" do
let!(:status) { create(:generic_commit_status, pipeline: pipeline) }
before do
project.add_reporter(user)
end
- describe 'Commit builds' do
+ describe "Commit builds" do
before do
visit pipeline_path(pipeline)
end
it { expect(page).to have_content pipeline.sha[0..7] }
- it 'contains generic commit status build' do
- page.within('.table-holder') do
+ it "contains generic commit status build" do
+ page.within(".table-holder") do
expect(page).to have_content "##{status.id}" # build id
- expect(page).to have_content 'generic' # build name
+ expect(page).to have_content "generic" # build name
end
end
end
end
- context 'commit status is Ci Build' do
+ context "commit status is Ci Build" do
let!(:build) { create(:ci_build, pipeline: pipeline) }
- let(:artifacts_file) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
+ let(:artifacts_file) { fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif") }
- context 'when logged as developer' do
+ context "when logged as developer" do
before do
project.add_developer(user)
end
- describe 'Project commits' do
+ describe "Project commits" do
let!(:pipeline_from_other_branch) do
create(:ci_pipeline,
- project: project,
- ref: 'fix',
- sha: project.commit.sha,
- status: :failed)
+ project: project,
+ ref: "fix",
+ sha: project.commit.sha,
+ status: :failed)
end
before do
visit project_commits_path(project, :master)
end
- it 'shows correct build status from default branch' do
+ it "shows correct build status from default branch" do
page.within("//li[@id='commit-#{pipeline.short_sha}']") do
- expect(page).to have_css('.ci-status-link')
- expect(page).to have_css('.ci-status-icon-success')
+ expect(page).to have_css(".ci-status-link")
+ expect(page).to have_css(".ci-status-icon-success")
end
end
end
- describe 'Commit builds', :js do
+ describe "Commit builds", :js do
before do
visit pipeline_path(pipeline)
end
- it 'shows pipeline`s data' do
+ it "shows pipeline`s data" do
expect(page).to have_content pipeline.sha[0..7]
expect(page).to have_content pipeline.git_commit_message
expect(page).to have_content pipeline.user.name
end
end
- context 'Download artifacts' do
+ context "Download artifacts" do
before do
build.update(legacy_artifacts_file: artifacts_file)
end
it do
visit pipeline_path(pipeline)
- click_on 'Download artifacts'
- expect(page.response_headers['Content-Type']).to eq(artifacts_file.content_type)
+ click_on "Download artifacts"
+ expect(page.response_headers["Content-Type"]).to eq(artifacts_file.content_type)
end
end
- describe 'Cancel all builds' do
- it 'cancels commit', :js do
+ describe "Cancel all builds" do
+ it "cancels commit", :js do
visit pipeline_path(pipeline)
- click_on 'Cancel running'
- expect(page).to have_content 'canceled'
+ click_on "Cancel running"
+ expect(page).to have_content "canceled"
end
end
- describe 'Cancel build' do
- it 'cancels build', :js do
+ describe "Cancel build" do
+ it "cancels build", :js do
visit pipeline_path(pipeline)
- find('.js-btn-cancel-pipeline').click
- expect(page).to have_content 'canceled'
+ find(".js-btn-cancel-pipeline").click
+ expect(page).to have_content "canceled"
end
end
end
@@ -123,24 +123,25 @@ describe 'Commits' do
visit pipeline_path(pipeline)
end
- it 'Renders header', :js do
+ it "Renders header", :js do
expect(page).to have_content pipeline.sha[0..7]
expect(page).to have_content pipeline.git_commit_message
expect(page).to have_content pipeline.user.name
- expect(page).not_to have_link('Cancel running')
- expect(page).not_to have_link('Retry')
+ expect(page).not_to have_link("Cancel running")
+ expect(page).not_to have_link("Retry")
end
it do
- expect(page).to have_link('Download artifacts')
+ expect(page).to have_link("Download artifacts")
end
end
- context 'when accessing internal project with disallowed access', :js do
+ context "when accessing internal project with disallowed access", :js do
before do
project.update(
visibility_level: Gitlab::VisibilityLevel::INTERNAL,
- public_builds: false)
+ public_builds: false
+ )
build.update(legacy_artifacts_file: artifacts_file)
visit pipeline_path(pipeline)
end
@@ -150,48 +151,48 @@ describe 'Commits' do
expect(page).to have_content pipeline.git_commit_message
expect(page).to have_content pipeline.user.name
- expect(page).not_to have_link('Cancel running')
- expect(page).not_to have_link('Retry')
+ expect(page).not_to have_link("Cancel running")
+ expect(page).not_to have_link("Retry")
end
end
end
- describe '.gitlab-ci.yml not found warning' do
+ describe ".gitlab-ci.yml not found warning" do
before do
project.add_reporter(user)
end
- context 'ci builds enabled' do
- it 'does not show warning' do
+ context "ci builds enabled" do
+ it "does not show warning" do
visit pipeline_path(pipeline)
- expect(page).not_to have_content '.gitlab-ci.yml not found in this commit'
+ expect(page).not_to have_content ".gitlab-ci.yml not found in this commit"
end
- it 'shows warning' do
+ it "shows warning" do
stub_ci_pipeline_yaml_file(nil)
visit pipeline_path(pipeline)
- expect(page).to have_content '.gitlab-ci.yml not found in this commit'
+ expect(page).to have_content ".gitlab-ci.yml not found in this commit"
end
end
- context 'ci builds disabled' do
- it 'does not show warning' do
+ context "ci builds disabled" do
+ it "does not show warning" do
stub_ci_builds_disabled
stub_ci_pipeline_yaml_file(nil)
visit pipeline_path(pipeline)
- expect(page).not_to have_content '.gitlab-ci.yml not found in this commit'
+ expect(page).not_to have_content ".gitlab-ci.yml not found in this commit"
end
end
end
end
- context 'viewing commits for a branch' do
- let(:branch_name) { 'master' }
+ context "viewing commits for a branch" do
+ let(:branch_name) { "master" }
before do
project.add_maintainer(user)
@@ -199,7 +200,7 @@ describe 'Commits' do
visit project_commits_path(project, branch_name)
end
- it 'includes the committed_date for each commit' do
+ it "includes the committed_date for each commit" do
commits = project.repository.commits(branch_name, limit: 40)
commits.each do |commit|
@@ -207,11 +208,11 @@ describe 'Commits' do
end
end
- it 'shows the ref switcher with the multi-file editor enabled', :js do
- set_cookie('new_repo', 'true')
+ it "shows the ref switcher with the multi-file editor enabled", :js do
+ set_cookie("new_repo", "true")
visit project_commits_path(project, branch_name)
- expect(find('.js-project-refs-dropdown')).to have_content branch_name
+ expect(find(".js-project-refs-dropdown")).to have_content branch_name
end
end
end
diff --git a/spec/features/container_registry_spec.rb b/spec/features/container_registry_spec.rb
index 6f9901815e1..155aeb39165 100644
--- a/spec/features/container_registry_spec.rb
+++ b/spec/features/container_registry_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe "Container Registry", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:container_repository) do
- create(:container_repository, name: 'my/image')
+ create(:container_repository, name: "my/image")
end
before do
@@ -15,45 +15,45 @@ describe "Container Registry", :js do
stub_container_registry_tags(repository: :any, tags: [])
end
- context 'when there are no image repositories' do
- it 'user visits container registry main page' do
+ context "when there are no image repositories" do
+ it "user visits container registry main page" do
visit_container_registry
- expect(page).to have_content 'No container images'
+ expect(page).to have_content "No container images"
end
end
- context 'when there are image repositories' do
+ context "when there are image repositories" do
before do
stub_container_registry_tags(repository: %r{my/image}, tags: %w[latest], with_manifest: true)
project.container_repositories << container_repository
end
- it 'user wants to see multi-level container repository' do
+ it "user wants to see multi-level container repository" do
visit_container_registry
- expect(page).to have_content('my/image')
+ expect(page).to have_content("my/image")
end
- it 'user removes entire container repository' do
+ it "user removes entire container repository" do
visit_container_registry
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
- click_on(class: 'js-remove-repo')
+ click_on(class: "js-remove-repo")
end
- it 'user removes a specific tag from container repository' do
+ it "user removes a specific tag from container repository" do
visit_container_registry
- find('.js-toggle-repo').click
+ find(".js-toggle-repo").click
wait_for_requests
expect_any_instance_of(ContainerRegistry::Tag)
.to receive(:delete).and_return(true)
- click_on(class: 'js-delete-registry')
+ click_on(class: "js-delete-registry")
end
end
diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb
index f4b2b9033ab..f8fddd6e31e 100644
--- a/spec/features/cycle_analytics_spec.rb
+++ b/spec/features/cycle_analytics_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Cycle Analytics', :js do
+describe "Cycle Analytics", :js do
let(:user) { create(:user) }
let(:guest) { create(:user) }
let(:project) { create(:project, :repository) }
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
let(:milestone) { create(:milestone, project: project) }
let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") }
- let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
+ let(:pipeline) { create(:ci_empty_pipeline, status: "created", project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
- context 'as an allowed user' do
- context 'when project is new' do
+ context "as an allowed user" do
+ context "when project is new" do
before do
project.add_maintainer(user)
@@ -20,18 +20,18 @@ describe 'Cycle Analytics', :js do
wait_for_requests
end
- it 'shows introductory message' do
- expect(page).to have_content('Introducing Cycle Analytics')
+ it "shows introductory message" do
+ expect(page).to have_content("Introducing Cycle Analytics")
end
- it 'shows pipeline summary' do
- expect(new_issues_counter).to have_content('-')
- expect(commits_counter).to have_content('-')
- expect(deploys_counter).to have_content('-')
+ it "shows pipeline summary" do
+ expect(new_issues_counter).to have_content("-")
+ expect(commits_counter).to have_content("-")
+ expect(deploys_counter).to have_content("-")
end
- it 'shows active stage with empty message' do
- expect(page).to have_selector('.stage-nav-item.active', text: 'Issue')
+ it "shows active stage with empty message" do
+ expect(page).to have_selector(".stage-nav-item.active", text: "Issue")
expect(page).to have_content("We don't have enough data to show this stage.")
end
end
@@ -48,31 +48,31 @@ describe 'Cycle Analytics', :js do
visit project_cycle_analytics_path(project)
end
- it 'shows pipeline summary' do
- expect(new_issues_counter).to have_content('1')
- expect(commits_counter).to have_content('2')
- expect(deploys_counter).to have_content('1')
+ it "shows pipeline summary" do
+ expect(new_issues_counter).to have_content("1")
+ expect(commits_counter).to have_content("2")
+ expect(deploys_counter).to have_content("1")
end
- it 'shows data on each stage' do
+ it "shows data on each stage" do
expect_issue_to_be_present
- click_stage('Plan')
- expect(find('.stage-events')).to have_content(mr.commits.last.title)
+ click_stage("Plan")
+ expect(find(".stage-events")).to have_content(mr.commits.last.title)
- click_stage('Code')
+ click_stage("Code")
expect_merge_request_to_be_present
- click_stage('Test')
+ click_stage("Test")
expect_build_to_be_present
- click_stage('Review')
+ click_stage("Review")
expect_merge_request_to_be_present
- click_stage('Staging')
+ click_stage("Staging")
expect_build_to_be_present
- click_stage('Production')
+ click_stage("Production")
expect_issue_to_be_present
end
@@ -80,20 +80,20 @@ describe 'Cycle Analytics', :js do
before do
_two_weeks_old_issue = create(:issue, project: project, created_at: 2.weeks.ago)
- click_button('Last 30 days')
- click_link('Last 7 days')
+ click_button("Last 30 days")
+ click_link("Last 7 days")
wait_for_requests
end
- it 'shows only relevant data' do
- expect(new_issues_counter).to have_content('1')
+ it "shows only relevant data" do
+ expect(new_issues_counter).to have_content("1")
end
end
end
context "when my preferred language is Spanish" do
before do
- user.update_attribute(:preferred_language, 'es')
+ user.update_attribute(:preferred_language, "es")
project.add_maintainer(user)
sign_in(user)
@@ -101,11 +101,11 @@ describe 'Cycle Analytics', :js do
wait_for_requests
end
- it 'shows the content in Spanish' do
- expect(page).to have_content('Estado del Pipeline')
+ it "shows the content in Spanish" do
+ expect(page).to have_content("Estado del Pipeline")
end
- it 'resets the language to English' do
+ it "resets the language to English" do
expect(I18n.locale).to eq(:en)
end
end
@@ -125,14 +125,14 @@ describe 'Cycle Analytics', :js do
wait_for_requests
end
- it 'needs permissions to see restricted stages' do
- expect(find('.stage-events')).to have_content(issue.title)
+ it "needs permissions to see restricted stages" do
+ expect(find(".stage-events")).to have_content(issue.title)
- click_stage('Code')
- expect(find('.stage-events')).to have_content('You need permission.')
+ click_stage("Code")
+ expect(find(".stage-events")).to have_content("You need permission.")
- click_stage('Review')
- expect(find('.stage-events')).to have_content('You need permission.')
+ click_stage("Review")
+ expect(find(".stage-events")).to have_content("You need permission.")
end
end
@@ -149,25 +149,25 @@ describe 'Cycle Analytics', :js do
end
def expect_issue_to_be_present
- expect(find('.stage-events')).to have_content(issue.title)
- expect(find('.stage-events')).to have_content(issue.author.name)
- expect(find('.stage-events')).to have_content("##{issue.iid}")
+ expect(find(".stage-events")).to have_content(issue.title)
+ expect(find(".stage-events")).to have_content(issue.author.name)
+ expect(find(".stage-events")).to have_content("##{issue.iid}")
end
def expect_build_to_be_present
- expect(find('.stage-events')).to have_content(@build.ref)
- expect(find('.stage-events')).to have_content(@build.short_sha)
- expect(find('.stage-events')).to have_content("##{@build.id}")
+ expect(find(".stage-events")).to have_content(@build.ref)
+ expect(find(".stage-events")).to have_content(@build.short_sha)
+ expect(find(".stage-events")).to have_content("##{@build.id}")
end
def expect_merge_request_to_be_present
- expect(find('.stage-events')).to have_content(mr.title)
- expect(find('.stage-events')).to have_content(mr.author.name)
- expect(find('.stage-events')).to have_content("!#{mr.iid}")
+ expect(find(".stage-events")).to have_content(mr.title)
+ expect(find(".stage-events")).to have_content(mr.author.name)
+ expect(find(".stage-events")).to have_content("!#{mr.iid}")
end
def click_stage(stage_name)
- find('.stage-nav li', text: stage_name).click
+ find(".stage-nav li", text: stage_name).click
wait_for_requests
end
end
diff --git a/spec/features/dashboard/active_tab_spec.rb b/spec/features/dashboard/active_tab_spec.rb
index f4d0f82d248..96ed446b068 100644
--- a/spec/features/dashboard/active_tab_spec.rb
+++ b/spec/features/dashboard/active_tab_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Dashboard Active Tab', :js do
+RSpec.describe "Dashboard Active Tab", :js do
before do
sign_in(create(:user))
end
- shared_examples 'page has active tab' do |title|
+ shared_examples "page has active tab" do |title|
it "#{title} tab" do
subject
- expect(page).to have_selector('.navbar-sub-nav li.active', count: 1)
- expect(find('.navbar-sub-nav li.active')).to have_content(title)
+ expect(page).to have_selector(".navbar-sub-nav li.active", count: 1)
+ expect(find(".navbar-sub-nav li.active")).to have_content(title)
end
end
- context 'on dashboard projects' do
- it_behaves_like 'page has active tab', 'Projects' do
+ context "on dashboard projects" do
+ it_behaves_like "page has active tab", "Projects" do
subject { visit dashboard_projects_path }
end
end
- context 'on dashboard groups' do
- it_behaves_like 'page has active tab', 'Groups' do
+ context "on dashboard groups" do
+ it_behaves_like "page has active tab", "Groups" do
subject { visit dashboard_groups_path }
end
end
- context 'on activity projects' do
- it_behaves_like 'page has active tab', 'Activity' do
+ context "on activity projects" do
+ it_behaves_like "page has active tab", "Activity" do
subject { visit activity_dashboard_path }
end
end
- context 'on instance statistics' do
+ context "on instance statistics" do
subject { visit instance_statistics_root_path }
- it 'shows Instance Statistics` as active' do
+ it "shows Instance Statistics` as active" do
subject
- expect(find('.navbar-sub-nav li.active')).to have_link('Instance Statistics')
+ expect(find(".navbar-sub-nav li.active")).to have_link("Instance Statistics")
end
end
end
diff --git a/spec/features/dashboard/activity_spec.rb b/spec/features/dashboard/activity_spec.rb
index bf91dc121d8..7dd25b59886 100644
--- a/spec/features/dashboard/activity_spec.rb
+++ b/spec/features/dashboard/activity_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > Activity' do
+describe "Dashboard > Activity" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- context 'rss' do
+ context "rss" do
before do
visit activity_dashboard_path
end
@@ -16,7 +16,7 @@ describe 'Dashboard > Activity' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'event filters', :js do
+ context "event filters", :js do
let(:project) { create(:project, :repository) }
let(:merge_request) do
@@ -24,17 +24,17 @@ describe 'Dashboard > Activity' do
end
let(:note) { create(:note, project: project, noteable: merge_request) }
- let(:milestone) { create(:milestone, :active, project: project, title: '1.0') }
+ let(:milestone) { create(:milestone, :active, project: project, title: "1.0") }
let!(:push_event) do
event = create(:push_event, project: project, author: user)
create(:push_event_payload,
- event: event,
- action: :created,
- commit_to: '0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e',
- ref: 'new_design',
- commit_count: 1)
+ event: event,
+ action: :created,
+ commit_to: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e",
+ ref: "new_design",
+ commit_count: 1)
event
end
@@ -66,95 +66,95 @@ describe 'Dashboard > Activity' do
wait_for_requests
end
- it 'user should see all events' do
- within '.content_list' do
- expect(page).to have_content('pushed new branch')
- expect(page).to have_content('joined')
- expect(page).to have_content('accepted')
- expect(page).to have_content('closed')
- expect(page).to have_content('commented on')
- expect(page).to have_content('closed milestone')
+ it "user should see all events" do
+ within ".content_list" do
+ expect(page).to have_content("pushed new branch")
+ expect(page).to have_content("joined")
+ expect(page).to have_content("accepted")
+ expect(page).to have_content("closed")
+ expect(page).to have_content("commented on")
+ expect(page).to have_content("closed milestone")
end
end
- it 'user should see only pushed events' do
- click_link('Push events')
+ it "user should see only pushed events" do
+ click_link("Push events")
wait_for_requests
- within '.content_list' do
- expect(page).to have_content('pushed new branch')
- expect(page).not_to have_content('joined')
- expect(page).not_to have_content('accepted')
- expect(page).not_to have_content('closed')
- expect(page).not_to have_content('commented on')
+ within ".content_list" do
+ expect(page).to have_content("pushed new branch")
+ expect(page).not_to have_content("joined")
+ expect(page).not_to have_content("accepted")
+ expect(page).not_to have_content("closed")
+ expect(page).not_to have_content("commented on")
end
end
- it 'user should see only merged events' do
- click_link('Merge events')
+ it "user should see only merged events" do
+ click_link("Merge events")
wait_for_requests
- within '.content_list' do
- expect(page).not_to have_content('pushed new branch')
- expect(page).not_to have_content('joined')
- expect(page).to have_content('accepted')
- expect(page).not_to have_content('closed')
- expect(page).not_to have_content('commented on')
+ within ".content_list" do
+ expect(page).not_to have_content("pushed new branch")
+ expect(page).not_to have_content("joined")
+ expect(page).to have_content("accepted")
+ expect(page).not_to have_content("closed")
+ expect(page).not_to have_content("commented on")
end
end
- it 'user should see only issues events' do
- click_link('Issue events')
+ it "user should see only issues events" do
+ click_link("Issue events")
wait_for_requests
- within '.content_list' do
- expect(page).not_to have_content('pushed new branch')
- expect(page).not_to have_content('joined')
- expect(page).not_to have_content('accepted')
- expect(page).to have_content('closed')
- expect(page).not_to have_content('commented on')
- expect(page).to have_content('closed milestone')
+ within ".content_list" do
+ expect(page).not_to have_content("pushed new branch")
+ expect(page).not_to have_content("joined")
+ expect(page).not_to have_content("accepted")
+ expect(page).to have_content("closed")
+ expect(page).not_to have_content("commented on")
+ expect(page).to have_content("closed milestone")
end
end
- it 'user should see only comments events' do
- click_link('Comments')
+ it "user should see only comments events" do
+ click_link("Comments")
wait_for_requests
- within '.content_list' do
- expect(page).not_to have_content('pushed new branch')
- expect(page).not_to have_content('joined')
- expect(page).not_to have_content('accepted')
- expect(page).not_to have_content('closed')
- expect(page).to have_content('commented on')
+ within ".content_list" do
+ expect(page).not_to have_content("pushed new branch")
+ expect(page).not_to have_content("joined")
+ expect(page).not_to have_content("accepted")
+ expect(page).not_to have_content("closed")
+ expect(page).to have_content("commented on")
end
end
- it 'user should see only joined events' do
- click_link('Team')
+ it "user should see only joined events" do
+ click_link("Team")
wait_for_requests
- within '.content_list' do
- expect(page).not_to have_content('pushed new branch')
- expect(page).to have_content('joined')
- expect(page).not_to have_content('accepted')
- expect(page).not_to have_content('closed')
- expect(page).not_to have_content('commented on')
+ within ".content_list" do
+ expect(page).not_to have_content("pushed new branch")
+ expect(page).to have_content("joined")
+ expect(page).not_to have_content("accepted")
+ expect(page).not_to have_content("closed")
+ expect(page).not_to have_content("commented on")
end
end
- it 'user see selected event after page reloading' do
- click_link('Push events')
+ it "user see selected event after page reloading" do
+ click_link("Push events")
wait_for_requests
visit activity_dashboard_path
wait_for_requests
- within '.content_list' do
- expect(page).to have_content('pushed new branch')
- expect(page).not_to have_content('joined')
- expect(page).not_to have_content('accepted')
- expect(page).not_to have_content('closed')
- expect(page).not_to have_content('commented on')
+ within ".content_list" do
+ expect(page).to have_content("pushed new branch")
+ expect(page).not_to have_content("joined")
+ expect(page).not_to have_content("accepted")
+ expect(page).not_to have_content("closed")
+ expect(page).not_to have_content("commented on")
end
end
end
diff --git a/spec/features/dashboard/archived_projects_spec.rb b/spec/features/dashboard/archived_projects_spec.rb
index d31df322d10..20515896196 100644
--- a/spec/features/dashboard/archived_projects_spec.rb
+++ b/spec/features/dashboard/archived_projects_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Dashboard Archived Project' do
+RSpec.describe "Dashboard Archived Project" do
let(:user) { create :user }
let(:project) { create :project}
let(:archived_project) { create(:project, :archived) }
@@ -14,35 +14,35 @@ RSpec.describe 'Dashboard Archived Project' do
visit dashboard_projects_path
end
- it 'renders non archived projects' do
+ it "renders non archived projects" do
expect(page).to have_link(project.name)
expect(page).not_to have_link(archived_project.name)
end
- it 'renders all projects' do
- click_link 'Show archived projects'
+ it "renders all projects" do
+ click_link "Show archived projects"
expect(page).to have_link(project.name)
expect(page).to have_link(archived_project.name)
end
- it 'renders only archived projects' do
- click_link 'Show archived projects only'
+ it "renders only archived projects" do
+ click_link "Show archived projects only"
expect(page).to have_content(archived_project.name)
expect(page).not_to have_content(project.name)
end
- it 'searches archived projects', :js do
- click_button 'Last updated'
- click_link 'Show archived projects'
+ it "searches archived projects", :js do
+ click_button "Last updated"
+ click_link "Show archived projects"
expect(page).to have_link(project.name)
expect(page).to have_link(archived_project.name)
- fill_in 'project-filter-form-field', with: archived_project.name
+ fill_in "project-filter-form-field", with: archived_project.name
- find('#project-filter-form-field').native.send_keys :return
+ find("#project-filter-form-field").native.send_keys :return
expect(page).not_to have_link(project.name)
expect(page).to have_link(archived_project.name)
diff --git a/spec/features/dashboard/datetime_on_tooltips_spec.rb b/spec/features/dashboard/datetime_on_tooltips_spec.rb
index f44bd55ecf6..16be89d023d 100644
--- a/spec/features/dashboard/datetime_on_tooltips_spec.rb
+++ b/spec/features/dashboard/datetime_on_tooltips_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Tooltips on .timeago dates', :js do
+describe "Tooltips on .timeago dates", :js do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
let(:created_date) { Date.yesterday.to_time }
- let(:expected_format) { created_date.in_time_zone.strftime('%b %-d, %Y %l:%M%P') }
+ let(:expected_format) { created_date.in_time_zone.strftime("%b %-d, %Y %l:%M%P") }
- context 'on the activity tab' do
+ context "on the activity tab" do
before do
project.add_maintainer(user)
- Event.create( project: project, author_id: user.id, action: Event::JOINED,
- updated_at: created_date, created_at: created_date)
+ Event.create(project: project, author_id: user.id, action: Event::JOINED,
+ updated_at: created_date, created_at: created_date)
sign_in user
visit user_activity_path(user)
wait_for_requests
- page.find('.js-timeago').hover
+ page.find(".js-timeago").hover
end
- it 'has the datetime formated correctly' do
- expect(page).to have_selector('.local-timeago', text: expected_format)
+ it "has the datetime formated correctly" do
+ expect(page).to have_selector(".local-timeago", text: expected_format)
end
end
- context 'on the snippets tab' do
+ context "on the snippets tab" do
before do
project.add_maintainer(user)
create(:snippet, author: user, updated_at: created_date, created_at: created_date)
@@ -34,11 +34,11 @@ describe 'Tooltips on .timeago dates', :js do
visit user_snippets_path(user)
wait_for_requests
- page.find('.js-timeago.snippet-created-ago').hover
+ page.find(".js-timeago.snippet-created-ago").hover
end
- it 'has the datetime formated correctly' do
- expect(page).to have_selector('.local-timeago', text: expected_format)
+ it "has the datetime formated correctly" do
+ expect(page).to have_selector(".local-timeago", text: expected_format)
end
end
end
diff --git a/spec/features/dashboard/group_spec.rb b/spec/features/dashboard/group_spec.rb
index 259f220c68b..ff2d52a8f8e 100644
--- a/spec/features/dashboard/group_spec.rb
+++ b/spec/features/dashboard/group_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Dashboard Group' do
+RSpec.describe "Dashboard Group" do
before do
sign_in(create(:user))
end
- it 'defaults sort dropdown to last created' do
+ it "defaults sort dropdown to last created" do
visit dashboard_groups_path
- expect(page).to have_button('Last created')
+ expect(page).to have_button("Last created")
end
- it 'creates new group', :js do
+ it "creates new group", :js do
visit dashboard_groups_path
- find('.btn-success').click
- new_name = 'Samurai'
- new_description = 'Tokugawa Shogunate'
+ find(".btn-success").click
+ new_name = "Samurai"
+ new_description = "Tokugawa Shogunate"
- fill_in 'group_name', with: new_name
- fill_in 'group_description', with: new_description
- click_button 'Create group'
+ fill_in "group_name", with: new_name
+ fill_in "group_description", with: new_description
+ click_button "Create group"
expect(current_path).to eq group_path(Group.find_by(name: new_name))
expect(page).to have_content(new_name)
diff --git a/spec/features/dashboard/groups_list_spec.rb b/spec/features/dashboard/groups_list_spec.rb
index e75c43d5338..dc6b6ae1014 100644
--- a/spec/features/dashboard/groups_list_spec.rb
+++ b/spec/features/dashboard/groups_list_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Groups page', :js do
+describe "Dashboard Groups page", :js do
let(:user) { create :user }
let(:group) { create(:group) }
let(:nested_group) { create(:group, :nested) }
@@ -8,12 +8,12 @@ describe 'Dashboard Groups page', :js do
def click_group_caret(group)
within("#group-#{group.id}") do
- first('.folder-caret').click
+ first(".folder-caret").click
end
wait_for_requests
end
- it 'shows groups user is member of' do
+ it "shows groups user is member of" do
group.add_owner(user)
nested_group.add_owner(user)
expect(another_group).to be_persisted
@@ -27,7 +27,7 @@ describe 'Dashboard Groups page', :js do
expect(page).not_to have_content(another_group.name)
end
- it 'shows subgroups the user is member of', :nested_groups do
+ it "shows subgroups the user is member of", :nested_groups do
group.add_owner(user)
nested_group.add_owner(user)
@@ -40,7 +40,7 @@ describe 'Dashboard Groups page', :js do
expect(page).to have_content(nested_group.name)
end
- context 'when filtering groups', :nested_groups do
+ context "when filtering groups", :nested_groups do
before do
group.add_owner(user)
nested_group.add_owner(user)
@@ -51,8 +51,8 @@ describe 'Dashboard Groups page', :js do
visit dashboard_groups_path
end
- it 'expands when filtering groups' do
- fill_in 'filter', with: nested_group.name
+ it "expands when filtering groups" do
+ fill_in "filter", with: nested_group.name
wait_for_requests
expect(page).not_to have_content(group.name)
@@ -61,25 +61,25 @@ describe 'Dashboard Groups page', :js do
expect(page).not_to have_content(another_group.name)
end
- it 'resets search when user cleans the input' do
- fill_in 'filter', with: group.name
+ it "resets search when user cleans the input" do
+ fill_in "filter", with: group.name
wait_for_requests
expect(page).to have_content(group.name)
expect(page).not_to have_content(nested_group.parent.name)
- fill_in 'filter', with: ''
+ fill_in "filter", with: ""
page.find('[name="filter"]').send_keys(:enter)
wait_for_requests
expect(page).to have_content(group.name)
expect(page).to have_content(nested_group.parent.name)
expect(page).not_to have_content(another_group.name)
- expect(page.all('.js-groups-list-holder .content-list li').length).to eq 2
+ expect(page.all(".js-groups-list-holder .content-list li").length).to eq 2
end
end
- context 'with subgroups', :nested_groups do
+ context "with subgroups", :nested_groups do
let!(:subgroup) { create(:group, :public, parent: group) }
before do
@@ -91,13 +91,13 @@ describe 'Dashboard Groups page', :js do
visit dashboard_groups_path
end
- it 'shows subgroups inside of its parent group' do
+ it "shows subgroups inside of its parent group" do
expect(page).to have_selector("#group-#{group.id}")
click_group_caret(group)
expect(page).to have_selector("#group-#{group.id} #group-#{subgroup.id}")
end
- it 'can toggle parent group' do
+ it "can toggle parent group" do
# expand
click_group_caret(group)
@@ -110,7 +110,7 @@ describe 'Dashboard Groups page', :js do
end
end
- context 'when using pagination' do
+ context "when using pagination" do
let(:group) { create(:group, created_at: 5.days.ago) }
let(:group2) { create(:group, created_at: 2.days.ago) }
@@ -124,8 +124,8 @@ describe 'Dashboard Groups page', :js do
visit dashboard_groups_path
end
- it 'loads results for next page' do
- expect(page).to have_selector('.gl-pagination .page-item a[role=menuitemradio]', count: 2)
+ it "loads results for next page" do
+ expect(page).to have_selector(".gl-pagination .page-item a[role=menuitemradio]", count: 2)
# Check first page
expect(page).to have_content(group2.full_name)
@@ -134,7 +134,7 @@ describe 'Dashboard Groups page', :js do
expect(page).not_to have_selector("#group-#{group.id}")
# Go to next page
- find('.gl-pagination .page-item:not(.active) a[role=menuitemradio]').click
+ find(".gl-pagination .page-item:not(.active) a[role=menuitemradio]").click
wait_for_requests
@@ -146,10 +146,10 @@ describe 'Dashboard Groups page', :js do
end
end
- context 'when signed in as admin' do
+ context "when signed in as admin" do
let(:admin) { create(:admin) }
- it 'shows only groups admin is member of' do
+ it "shows only groups admin is member of" do
group.add_owner(admin)
expect(another_group).to be_persisted
diff --git a/spec/features/dashboard/help_spec.rb b/spec/features/dashboard/help_spec.rb
index 467a503a62d..c019efbdc4c 100644
--- a/spec/features/dashboard/help_spec.rb
+++ b/spec/features/dashboard/help_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Dashboard Help' do
+RSpec.describe "Dashboard Help" do
before do
sign_in(create(:user))
end
- context 'documentation' do
- it 'renders correctly markdown' do
+ context "documentation" do
+ it "renders correctly markdown" do
visit help_page_path("administration/raketasks/maintenance")
- expect(page).to have_content('Gather information about GitLab and the system it runs on')
+ expect(page).to have_content("Gather information about GitLab and the system it runs on")
- node = find('.documentation h2 a#user-content-check-gitlab-configuration')
- expect(node[:href]).to eq '#check-gitlab-configuration'
- expect(find(:xpath, "#{node.path}/..").text).to eq 'Check GitLab configuration'
+ node = find(".documentation h2 a#user-content-check-gitlab-configuration")
+ expect(node[:href]).to eq "#check-gitlab-configuration"
+ expect(find(:xpath, "#{node.path}/..").text).to eq "Check GitLab configuration"
end
end
end
diff --git a/spec/features/dashboard/instance_statistics_spec.rb b/spec/features/dashboard/instance_statistics_spec.rb
index 21ee2796bd8..86fa1a88a91 100644
--- a/spec/features/dashboard/instance_statistics_spec.rb
+++ b/spec/features/dashboard/instance_statistics_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Showing instance statistics' do
+describe "Showing instance statistics" do
before do
sign_in user if user
end
@@ -10,51 +10,51 @@ describe 'Showing instance statistics' do
# Using a path that is publicly accessible
subject { visit explore_projects_path }
- context 'for unauthenticated users' do
+ context "for unauthenticated users" do
let(:user) { nil }
- it 'does not show the instance statistics link' do
+ it "does not show the instance statistics link" do
subject
- expect(page).not_to have_link('Instance Statistics')
+ expect(page).not_to have_link("Instance Statistics")
end
end
- context 'for regular users' do
+ context "for regular users" do
let(:user) { create(:user) }
- context 'when instance statistics are publicly available' do
+ context "when instance statistics are publicly available" do
before do
stub_application_setting(instance_statistics_visibility_private: false)
end
- it 'shows the instance statistics link' do
+ it "shows the instance statistics link" do
subject
- expect(page).to have_link('Instance Statistics')
+ expect(page).to have_link("Instance Statistics")
end
end
- context 'when instance statistics are not publicly available' do
+ context "when instance statistics are not publicly available" do
before do
stub_application_setting(instance_statistics_visibility_private: true)
end
- it 'shows the instance statistics link' do
+ it "shows the instance statistics link" do
subject
- expect(page).not_to have_link('Instance Statistics')
+ expect(page).not_to have_link("Instance Statistics")
end
end
end
- context 'for admins' do
+ context "for admins" do
let(:user) { create(:admin) }
- it 'shows the instance statistics link' do
+ it "shows the instance statistics link" do
subject
- expect(page).to have_link('Instance Statistics')
+ expect(page).to have_link("Instance Statistics")
end
end
end
diff --git a/spec/features/dashboard/issuables_counter_spec.rb b/spec/features/dashboard/issuables_counter_spec.rb
index fbc2e5cc3d3..7b8c07e33ed 100644
--- a/spec/features/dashboard/issuables_counter_spec.rb
+++ b/spec/features/dashboard/issuables_counter_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
+describe "Navigation bar counter", :use_clean_rails_memory_store_caching do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let(:issue) { create(:issue, project: project) }
@@ -12,10 +12,10 @@ describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
sign_in(user)
end
- it 'reflects dashboard issues count' do
+ it "reflects dashboard issues count" do
visit issues_path
- expect_counters('issues', '1')
+ expect_counters("issues", "1")
issue.assignees = []
@@ -24,14 +24,14 @@ describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
Timecop.travel(3.minutes.from_now) do
visit issues_path
- expect_counters('issues', '0')
+ expect_counters("issues", "0")
end
end
- it 'reflects dashboard merge requests count' do
+ it "reflects dashboard merge requests count" do
visit merge_requests_path
- expect_counters('merge_requests', '1')
+ expect_counters("merge_requests", "1")
merge_request.update(assignee: nil)
@@ -40,7 +40,7 @@ describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
Timecop.travel(3.minutes.from_now) do
visit merge_requests_path
- expect_counters('merge_requests', '0')
+ expect_counters("merge_requests", "0")
end
end
@@ -53,9 +53,9 @@ describe 'Navigation bar counter', :use_clean_rails_memory_store_caching do
end
def expect_counters(issuable_type, count)
- dashboard_count = find('.nav-links li.active')
+ dashboard_count = find(".nav-links li.active")
nav_count = find(".dashboard-shortcuts-#{issuable_type}")
- header_count = find(".header-content .#{issuable_type.tr('_', '-')}-count")
+ header_count = find(".header-content .#{issuable_type.tr("_", "-")}-count")
expect(dashboard_count).to have_content(count)
expect(nav_count).to have_content(count)
diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb
index c0434f767bb..f00c27dae7f 100644
--- a/spec/features/dashboard/issues_filter_spec.rb
+++ b/spec/features/dashboard/issues_filter_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Issues filtering', :js do
+describe "Dashboard Issues filtering", :js do
include Spec::Support::Helpers::Features::SortingHelpers
include FilteredSearchHelpers
@@ -18,75 +18,75 @@ describe 'Dashboard Issues filtering', :js do
visit_issues
end
- context 'without any filter' do
- it 'shows error message' do
- expect(page).to have_content 'Please select at least one filter to see results'
+ context "without any filter" do
+ it "shows error message" do
+ expect(page).to have_content "Please select at least one filter to see results"
end
end
- context 'filtering by milestone' do
- it 'shows all issues with no milestone' do
+ context "filtering by milestone" do
+ it "shows all issues with no milestone" do
input_filtered_search("milestone:none")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_selector('.issue', count: 1)
+ expect(page).to have_selector(".issue", count: 1)
end
- it 'shows all issues with the selected milestone' do
+ it "shows all issues with the selected milestone" do
input_filtered_search("milestone:%\"#{milestone.title}\"")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_selector('.issue', count: 1)
+ expect(page).to have_selector(".issue", count: 1)
end
- it 'updates atom feed link' do
- visit_issues(milestone_title: '', assignee_username: user.username)
+ it "updates atom feed link" do
+ visit_issues(milestone_title: "", assignee_username: user.username)
link = find('.nav-controls a[title="Subscribe to RSS feed"]')
params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
- expect(params).to include('feed_token' => [user.feed_token])
- expect(params).to include('milestone_title' => [''])
- expect(params).to include('assignee_username' => [user.username.to_s])
- expect(auto_discovery_params).to include('feed_token' => [user.feed_token])
- expect(auto_discovery_params).to include('milestone_title' => [''])
- expect(auto_discovery_params).to include('assignee_username' => [user.username.to_s])
+ expect(params).to include("feed_token" => [user.feed_token])
+ expect(params).to include("milestone_title" => [""])
+ expect(params).to include("assignee_username" => [user.username.to_s])
+ expect(auto_discovery_params).to include("feed_token" => [user.feed_token])
+ expect(auto_discovery_params).to include("milestone_title" => [""])
+ expect(auto_discovery_params).to include("assignee_username" => [user.username.to_s])
end
end
- context 'filtering by label' do
+ context "filtering by label" do
let(:label) { create(:label, project: project) }
let!(:label_link) { create(:label_link, label: label, target: issue) }
- it 'shows all issues with the selected label' do
+ it "shows all issues with the selected label" do
input_filtered_search("label:~#{label.title}")
- page.within 'ul.content-list' do
+ page.within "ul.content-list" do
expect(page).to have_content issue.title
expect(page).not_to have_content issue2.title
end
end
end
- context 'sorting' do
+ context "sorting" do
before do
visit_issues(assignee_username: user.username)
end
- it 'remembers last sorting value' do
- sort_by('Created date')
+ it "remembers last sorting value" do
+ sort_by("Created date")
visit_issues(assignee_username: user.username)
- expect(find('.issues-filters')).to have_content('Created date')
+ expect(find(".issues-filters")).to have_content("Created date")
end
- it 'keeps sorting issues after visiting Projects Issues page' do
- sort_by('Created date')
+ it "keeps sorting issues after visiting Projects Issues page" do
+ sort_by("Created date")
visit project_issues_path(project)
- expect(find('.issues-filters')).to have_content('Created date')
+ expect(find(".issues-filters")).to have_content("Created date")
end
end
diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb
index 9957bec0f0b..b168cd5f7c5 100644
--- a/spec/features/dashboard/issues_spec.rb
+++ b/spec/features/dashboard/issues_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-RSpec.describe 'Dashboard Issues' do
+RSpec.describe "Dashboard Issues" do
include FilteredSearchHelpers
let(:current_user) { create :user }
@@ -19,14 +19,14 @@ RSpec.describe 'Dashboard Issues' do
visit issues_dashboard_path(assignee_username: current_user.username)
end
- describe 'issues' do
- it 'shows issues assigned to current user' do
+ describe "issues" do
+ it "shows issues assigned to current user" do
expect(page).to have_content(assigned_issue.title)
expect(page).not_to have_content(authored_issue.title)
expect(page).not_to have_content(other_issue.title)
end
- it 'shows issues when current user is author', :js do
+ it "shows issues when current user is author", :js do
reset_filters
input_filtered_search("author:#{current_user.to_reference}")
@@ -36,45 +36,45 @@ RSpec.describe 'Dashboard Issues' do
expect(page).not_to have_content(other_issue.title)
end
- it 'state filter tabs work' do
- find('#state-closed').click
- expect(page).to have_current_path(issues_dashboard_url(assignee_username: current_user.username, state: 'closed'), url: true)
+ it "state filter tabs work" do
+ find("#state-closed").click
+ expect(page).to have_current_path(issues_dashboard_url(assignee_username: current_user.username, state: "closed"), url: true)
end
it_behaves_like "it has an RSS button with current_user's feed token"
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- describe 'new issue dropdown' do
- it 'shows projects only with issues feature enabled', :js do
- find('.new-project-item-select-button').click
+ describe "new issue dropdown" do
+ it "shows projects only with issues feature enabled", :js do
+ find(".new-project-item-select-button").click
- page.within('.select2-results') do
+ page.within(".select2-results") do
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(project_with_issues_disabled.full_name)
end
end
- it 'shows the new issue page', :js do
- find('.new-project-item-select-button').click
+ it "shows the new issue page", :js do
+ find(".new-project-item-select-button").click
wait_for_requests
project_path = "/#{project.full_path}"
- project_json = { name: project.full_name, url: project_path }.to_json
+ project_json = {name: project.full_name, url: project_path}.to_json
# simulate selection, and prevent overlap by dropdown menu
- first('.project-item-select', visible: false)
+ first(".project-item-select", visible: false)
execute_script("$('.project-item-select').val('#{project_json}').trigger('change');")
- find('#select2-drop-mask', visible: false)
+ find("#select2-drop-mask", visible: false)
execute_script("$('#select2-drop-mask').remove();")
- find('.new-project-item-link').click
+ find(".new-project-item-link").click
expect(page).to have_current_path("#{project_path}/issues/new")
- page.within('#content-body') do
- expect(page).to have_selector('.issue-form')
+ page.within("#content-body") do
+ expect(page).to have_selector(".issue-form")
end
end
end
diff --git a/spec/features/dashboard/label_filter_spec.rb b/spec/features/dashboard/label_filter_spec.rb
index 2d4659d380f..508db409655 100644
--- a/spec/features/dashboard/label_filter_spec.rb
+++ b/spec/features/dashboard/label_filter_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > label filter', :js do
+describe "Dashboard > label filter", :js do
include FilteredSearchHelpers
- let(:filtered_search) { find('.filtered-search') }
+ let(:filtered_search) { find(".filtered-search") }
let(:filter_dropdown) { find("#js-dropdown-label .filter-dropdown") }
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
- let(:project2) { create(:project, name: 'test2', path: 'test2', namespace: user.namespace) }
- let(:label) { create(:label, title: 'bug', color: '#ff0000') }
- let(:label2) { create(:label, title: 'bug') }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
+ let(:project2) { create(:project, name: "test2", path: "test2", namespace: user.namespace) }
+ let(:label) { create(:label, title: "bug", color: "#ff0000") }
+ let(:label2) { create(:label, title: "bug") }
before do
project.labels << label
@@ -22,11 +22,11 @@ describe 'Dashboard > label filter', :js do
init_label_search
end
- context 'duplicate labels' do
- it 'removes duplicate labels' do
- filtered_search.send_keys('bu')
+ context "duplicate labels" do
+ it "removes duplicate labels" do
+ filtered_search.send_keys("bu")
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', text: 'bug', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", text: "bug", count: 1)
end
end
end
diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb
index 9ffa75aee47..c3c4836859a 100644
--- a/spec/features/dashboard/merge_requests_spec.rb
+++ b/spec/features/dashboard/merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Merge Requests' do
+describe "Dashboard Merge Requests" do
include Spec::Support::Helpers::Features::SortingHelpers
include FilteredSearchHelpers
include ProjectForksHelper
@@ -17,7 +17,7 @@ describe 'Dashboard Merge Requests' do
sign_in(current_user)
end
- context 'new merge request dropdown' do
+ context "new merge request dropdown" do
let(:project_with_disabled_merge_requests) { create(:project, :merge_requests_disabled) }
before do
@@ -25,25 +25,25 @@ describe 'Dashboard Merge Requests' do
visit merge_requests_dashboard_path
end
- it 'shows projects only with merge requests feature enabled', :js do
- find('.new-project-item-select-button').click
+ it "shows projects only with merge requests feature enabled", :js do
+ find(".new-project-item-select-button").click
- page.within('.select2-results') do
+ page.within(".select2-results") do
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(project_with_disabled_merge_requests.full_name)
end
end
end
- context 'no merge requests exist' do
- it 'shows an empty state' do
+ context "no merge requests exist" do
+ it "shows an empty state" do
visit merge_requests_dashboard_path(assignee_username: current_user.username)
- expect(page).to have_selector('.empty-state')
+ expect(page).to have_selector(".empty-state")
end
end
- context 'merge requests exist' do
+ context "merge requests exist" do
let!(:assigned_merge_request) do
create(:merge_request,
assignee: current_user,
@@ -53,37 +53,37 @@ describe 'Dashboard Merge Requests' do
let!(:assigned_merge_request_from_fork) do
create(:merge_request,
- source_branch: 'markdown', assignee: current_user,
- target_project: public_project, source_project: forked_project,
- author: create(:user))
+ source_branch: "markdown", assignee: current_user,
+ target_project: public_project, source_project: forked_project,
+ author: create(:user))
end
let!(:authored_merge_request) do
create(:merge_request,
- source_branch: 'markdown',
- source_project: project,
- author: current_user)
+ source_branch: "markdown",
+ source_project: project,
+ author: current_user)
end
let!(:authored_merge_request_from_fork) do
create(:merge_request,
- source_branch: 'feature_conflict',
- author: current_user,
- target_project: public_project, source_project: forked_project)
+ source_branch: "feature_conflict",
+ author: current_user,
+ target_project: public_project, source_project: forked_project)
end
let!(:other_merge_request) do
create(:merge_request,
- source_branch: 'fix',
- source_project: project,
- author: create(:user))
+ source_branch: "fix",
+ source_project: project,
+ author: create(:user))
end
before do
visit merge_requests_dashboard_path(assignee_username: current_user.username)
end
- it 'shows assigned merge requests' do
+ it "shows assigned merge requests" do
expect(page).to have_content(assigned_merge_request.title)
expect(page).to have_content(assigned_merge_request_from_fork.title)
@@ -92,7 +92,7 @@ describe 'Dashboard Merge Requests' do
expect(page).not_to have_content(other_merge_request.title)
end
- it 'shows authored merge requests', :js do
+ it "shows authored merge requests", :js do
reset_filters
input_filtered_search("author:#{current_user.to_reference}")
@@ -104,26 +104,26 @@ describe 'Dashboard Merge Requests' do
expect(page).not_to have_content(other_merge_request.title)
end
- it 'shows error message without filter', :js do
+ it "shows error message without filter", :js do
reset_filters
- expect(page).to have_content('Please select at least one filter to see results')
+ expect(page).to have_content("Please select at least one filter to see results")
end
- it 'shows sorted merge requests' do
- sort_by('Created date')
+ it "shows sorted merge requests" do
+ sort_by("Created date")
visit merge_requests_dashboard_path(assignee_username: current_user.username)
- expect(find('.issues-filters')).to have_content('Created date')
+ expect(find(".issues-filters")).to have_content("Created date")
end
- it 'keeps sorting merge requests after visiting Projects MR page' do
- sort_by('Created date')
+ it "keeps sorting merge requests after visiting Projects MR page" do
+ sort_by("Created date")
visit project_merge_requests_path(project)
- expect(find('.issues-filters')).to have_content('Created date')
+ expect(find(".issues-filters")).to have_content("Created date")
end
end
end
diff --git a/spec/features/dashboard/milestone_tabs_spec.rb b/spec/features/dashboard/milestone_tabs_spec.rb
index 21de7c2f06f..227ed252331 100644
--- a/spec/features/dashboard/milestone_tabs_spec.rb
+++ b/spec/features/dashboard/milestone_tabs_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard milestone tabs', :js do
+describe "Dashboard milestone tabs", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let!(:label) { create(:label, project: project) }
@@ -20,21 +20,21 @@ describe 'Dashboard milestone tabs', :js do
visit dashboard_milestone_path(milestone.safe_title, title: milestone.title)
end
- it 'loads merge requests async' do
- click_link 'Merge Requests'
+ it "loads merge requests async" do
+ click_link "Merge Requests"
- expect(page).to have_selector('.milestone-merge_requests-list')
+ expect(page).to have_selector(".milestone-merge_requests-list")
end
- it 'loads participants async' do
- click_link 'Participants'
+ it "loads participants async" do
+ click_link "Participants"
- expect(page).to have_selector('#tab-participants .bordered-list')
+ expect(page).to have_selector("#tab-participants .bordered-list")
end
- it 'loads labels async' do
- click_link 'Labels'
+ it "loads labels async" do
+ click_link "Labels"
- expect(page).to have_selector('#tab-labels .bordered-list')
+ expect(page).to have_selector("#tab-labels .bordered-list")
end
end
diff --git a/spec/features/dashboard/milestones_spec.rb b/spec/features/dashboard/milestones_spec.rb
index 8fb2e37e269..c7285894d82 100644
--- a/spec/features/dashboard/milestones_spec.rb
+++ b/spec/features/dashboard/milestones_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > Milestones' do
- describe 'as anonymous user' do
+describe "Dashboard > Milestones" do
+ describe "as anonymous user" do
before do
visit dashboard_milestones_path
end
- it 'is redirected to sign-in page' do
+ it "is redirected to sign-in page" do
expect(current_path).to eq new_user_session_path
end
end
- describe 'as logged-in user' do
+ describe "as logged-in user" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -24,7 +24,7 @@ describe 'Dashboard > Milestones' do
visit dashboard_milestones_path
end
- it 'sees milestones' do
+ it "sees milestones" do
expect(current_path).to eq dashboard_milestones_path
expect(page).to have_content(milestone.title)
expect(page).to have_content(group.name)
diff --git a/spec/features/dashboard/project_member_activity_index_spec.rb b/spec/features/dashboard/project_member_activity_index_spec.rb
index 16919fe63ad..79a8e8be658 100644
--- a/spec/features/dashboard/project_member_activity_index_spec.rb
+++ b/spec/features/dashboard/project_member_activity_index_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project member activity', :js do
+describe "Project member activity", :js do
let(:user) { create(:user) }
- let(:project) { create(:project, :public, name: 'x', namespace: user.namespace) }
+ let(:project) { create(:project, :public, name: "x", namespace: user.namespace) }
before do
project.add_maintainer(user)
@@ -14,36 +14,36 @@ describe 'Project member activity', :js do
wait_for_requests
end
- context 'when a user joins the project' do
+ context "when a user joins the project" do
before do
visit_activities_and_wait_with_event(Event::JOINED)
end
it "presents the correct message" do
- expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
- expect(page.find('.event-title').text).to eq("joined project")
+ expect(page.find(".event-user-info").text).to eq("#{user.name} #{user.to_reference}")
+ expect(page.find(".event-title").text).to eq("joined project")
end
end
- context 'when a user leaves the project' do
+ context "when a user leaves the project" do
before do
visit_activities_and_wait_with_event(Event::LEFT)
end
it "presents the correct message" do
- expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
- expect(page.find('.event-title').text).to eq("left project")
+ expect(page.find(".event-user-info").text).to eq("#{user.name} #{user.to_reference}")
+ expect(page.find(".event-title").text).to eq("left project")
end
end
- context 'when a users membership expires for the project' do
+ context "when a users membership expires for the project" do
before do
visit_activities_and_wait_with_event(Event::EXPIRED)
end
it "presents the correct message" do
- expect(page.find('.event-user-info').text).to eq("#{user.name} #{user.to_reference}")
- expect(page.find('.event-title').text).to eq("removed due to membership expiration from project")
+ expect(page.find(".event-user-info").text).to eq("#{user.name} #{user.to_reference}")
+ expect(page.find(".event-title").text).to eq("removed due to membership expiration from project")
end
end
end
diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb
index 9d1c1e3acc7..84b13421b0a 100644
--- a/spec/features/dashboard/projects_spec.rb
+++ b/spec/features/dashboard/projects_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Projects' do
+describe "Dashboard Projects" do
let(:user) { create(:user) }
- let(:project) { create(:project, :repository, name: 'awesome stuff') }
- let(:project2) { create(:project, :public, name: 'Community project') }
+ let(:project) { create(:project, :repository, name: "awesome stuff") }
+ let(:project2) { create(:project, :public, name: "Community project") }
before do
project.add_developer(user)
@@ -16,49 +16,49 @@ describe 'Dashboard Projects' do
end
end
- it 'shows the project the user in a member of in the list' do
+ it "shows the project the user in a member of in the list" do
visit dashboard_projects_path
- expect(page).to have_content('awesome stuff')
+ expect(page).to have_content("awesome stuff")
end
it 'shows "New project" button' do
visit dashboard_projects_path
- page.within '#content-body' do
- expect(page).to have_link('New project')
+ page.within "#content-body" do
+ expect(page).to have_link("New project")
end
end
- context 'when user has access to the project' do
- it 'shows role badge' do
+ context "when user has access to the project" do
+ it "shows role badge" do
visit dashboard_projects_path
- page.within '.user-access-role' do
- expect(page).to have_content('Developer')
+ page.within ".user-access-role" do
+ expect(page).to have_content("Developer")
end
end
- context 'when role changes', :use_clean_rails_memory_store_fragment_caching do
- it 'displays the right role' do
+ context "when role changes", :use_clean_rails_memory_store_fragment_caching do
+ it "displays the right role" do
visit dashboard_projects_path
- page.within '.user-access-role' do
- expect(page).to have_content('Developer')
+ page.within ".user-access-role" do
+ expect(page).to have_content("Developer")
end
project.members.last.update(access_level: 40)
visit dashboard_projects_path
- page.within '.user-access-role' do
- expect(page).to have_content('Maintainer')
+ page.within ".user-access-role" do
+ expect(page).to have_content("Maintainer")
end
end
end
end
- context 'when last_repository_updated_at, last_activity_at and update_at are present' do
- it 'shows the last_repository_updated_at attribute as the update date' do
+ context "when last_repository_updated_at, last_activity_at and update_at are present" do
+ it "shows the last_repository_updated_at attribute as the update date" do
project.update!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago)
visit dashboard_projects_path
@@ -66,7 +66,7 @@ describe 'Dashboard Projects' do
expect(page).to have_xpath("//time[@datetime='#{project.last_repository_updated_at.getutc.iso8601}']")
end
- it 'shows the last_activity_at attribute as the update date' do
+ it "shows the last_activity_at attribute as the update date" do
project.update!(last_repository_updated_at: 1.hour.ago, last_activity_at: Time.now)
visit dashboard_projects_path
@@ -75,8 +75,8 @@ describe 'Dashboard Projects' do
end
end
- context 'when last_repository_updated_at and last_activity_at are missing' do
- it 'shows the updated_at attribute as the update date' do
+ context "when last_repository_updated_at and last_activity_at are missing" do
+ it "shows the updated_at attribute as the update date" do
project.update!(last_repository_updated_at: nil, last_activity_at: nil)
project.touch
@@ -86,57 +86,57 @@ describe 'Dashboard Projects' do
end
end
- context 'when on Your projects tab' do
- it 'shows all projects by default' do
+ context "when on Your projects tab" do
+ it "shows all projects by default" do
visit dashboard_projects_path
expect(page).to have_content(project.name)
- expect(find('.nav-links li:nth-child(1) .badge-pill')).to have_content(1)
+ expect(find(".nav-links li:nth-child(1) .badge-pill")).to have_content(1)
end
- it 'shows personal projects on personal projects tab', :js do
+ it "shows personal projects on personal projects tab", :js do
project3 = create(:project, namespace: user.namespace)
visit dashboard_projects_path
- click_link 'Personal'
+ click_link "Personal"
expect(page).not_to have_content(project.name)
expect(page).to have_content(project3.name)
end
- it 'sorts projects by most stars when sorting by most stars' do
+ it "sorts projects by most stars when sorting by most stars" do
project_with_most_stars = create(:project, namespace: user.namespace, star_count: 10)
visit dashboard_projects_path(sort: :stars_desc)
- expect(first('.project-row')).to have_content(project_with_most_stars.title)
+ expect(first(".project-row")).to have_content(project_with_most_stars.title)
end
end
- context 'when on Starred projects tab', :js do
- it 'shows the empty state when there are no starred projects' do
+ context "when on Starred projects tab", :js do
+ it "shows the empty state when there are no starred projects" do
visit(starred_dashboard_projects_path)
- element = page.find('.row.empty-state')
+ element = page.find(".row.empty-state")
expect(element).to have_content("You don't have starred projects yet.")
- expect(element.find('.svg-content img')['src']).to have_content('illustrations/starred_empty')
+ expect(element.find(".svg-content img")["src"]).to have_content("illustrations/starred_empty")
end
- it 'shows only starred projects' do
+ it "shows only starred projects" do
user.toggle_star(project2)
visit(starred_dashboard_projects_path)
expect(page).not_to have_content(project.name)
expect(page).to have_content(project2.name)
- expect(find('.nav-links li:nth-child(1) .badge-pill')).to have_content(1)
- expect(find('.nav-links li:nth-child(2) .badge-pill')).to have_content(1)
+ expect(find(".nav-links li:nth-child(1) .badge-pill")).to have_content(1)
+ expect(find(".nav-links li:nth-child(2) .badge-pill")).to have_content(1)
end
end
- describe 'with a pipeline', :clean_gitlab_redis_shared_state do
+ describe "with a pipeline", :clean_gitlab_redis_shared_state do
let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch) }
before do
@@ -146,18 +146,18 @@ describe 'Dashboard Projects' do
pipeline.succeed
end
- it 'shows that the last pipeline passed' do
+ it "shows that the last pipeline passed" do
visit dashboard_projects_path
- page.within('.controls') do
+ page.within(".controls") do
expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']")
- expect(page).to have_css('.ci-status-link')
- expect(page).to have_css('.ci-status-icon-success')
- expect(page).to have_link('Commit: passed')
+ expect(page).to have_css(".ci-status-link")
+ expect(page).to have_css(".ci-status-icon-success")
+ expect(page).to have_link("Commit: passed")
end
end
- context 'guest user of project and project has private pipelines' do
+ context "guest user of project and project has private pipelines" do
let(:guest_user) { create(:user) }
before do
@@ -166,24 +166,24 @@ describe 'Dashboard Projects' do
sign_in(guest_user)
end
- it 'shows that the last pipeline passed' do
+ it "shows that the last pipeline passed" do
visit dashboard_projects_path
- page.within('.controls') do
+ page.within(".controls") do
expect(page).not_to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit, ref: pipeline.ref)}']")
- expect(page).not_to have_css('.ci-status-link')
- expect(page).not_to have_css('.ci-status-icon-success')
- expect(page).not_to have_link('Commit: passed')
+ expect(page).not_to have_css(".ci-status-link")
+ expect(page).not_to have_css(".ci-status-icon-success")
+ expect(page).not_to have_link("Commit: passed")
end
end
end
end
- context 'last push widget', :use_clean_rails_memory_store_caching do
+ context "last push widget", :use_clean_rails_memory_store_caching do
before do
event = create(:push_event, project: project, author: user)
- create(:push_event_payload, event: event, ref: 'feature', action: :created)
+ create(:push_event_payload, event: event, ref: "feature", action: :created)
Users::LastPushEventService.new(user).cache_last_push_event(event)
@@ -191,17 +191,17 @@ describe 'Dashboard Projects' do
end
it 'shows "Create merge request" button' do
- expect(page).to have_content 'You pushed to feature'
+ expect(page).to have_content "You pushed to feature"
- within('#content-body') do
- find_link('Create merge request', visible: false).click
+ within("#content-body") do
+ find_link("Create merge request", visible: false).click
end
- expect(page).to have_selector('.merge-request-form')
+ expect(page).to have_selector(".merge-request-form")
expect(current_path).to eq project_new_merge_request_path(project)
- expect(find('#merge_request_target_project_id', visible: false).value).to eq project.id.to_s
- expect(find('input#merge_request_source_branch', visible: false).value).to eq 'feature'
- expect(find('input#merge_request_target_branch', visible: false).value).to eq 'master'
+ expect(find("#merge_request_target_project_id", visible: false).value).to eq project.id.to_s
+ expect(find("input#merge_request_source_branch", visible: false).value).to eq "feature"
+ expect(find("input#merge_request_target_branch", visible: false).value).to eq "master"
end
end
end
diff --git a/spec/features/dashboard/root_explore_spec.rb b/spec/features/dashboard/root_explore_spec.rb
index 5b686d8b6f1..e2a16a6e347 100644
--- a/spec/features/dashboard/root_explore_spec.rb
+++ b/spec/features/dashboard/root_explore_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Root explore' do
+describe "Root explore" do
set(:public_project) { create(:project, :public) }
set(:archived_project) { create(:project, :archived) }
set(:internal_project) { create(:project, :internal) }
@@ -12,7 +12,7 @@ describe 'Root explore' do
allow(Gitlab).to receive(:com?).and_return(true)
end
- context 'when logged in' do
+ context "when logged in" do
set(:user) { create(:user) }
before do
@@ -20,14 +20,14 @@ describe 'Root explore' do
visit explore_projects_path
end
- include_examples 'shows public and internal projects'
+ include_examples "shows public and internal projects"
end
- context 'when not logged in' do
+ context "when not logged in" do
before do
visit explore_projects_path
end
- include_examples 'shows public projects'
+ include_examples "shows public projects"
end
end
diff --git a/spec/features/dashboard/shortcuts_spec.rb b/spec/features/dashboard/shortcuts_spec.rb
index 55f5ff04d01..9163c1a7982 100644
--- a/spec/features/dashboard/shortcuts_spec.rb
+++ b/spec/features/dashboard/shortcuts_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard shortcuts', :js do
- context 'logged in' do
+describe "Dashboard shortcuts", :js do
+ context "logged in" do
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -11,49 +11,49 @@ describe 'Dashboard shortcuts', :js do
visit root_dashboard_path
end
- it 'Navigate to tabs' do
- find('body').send_keys([:shift, 'I'])
+ it "Navigate to tabs" do
+ find("body").send_keys([:shift, "I"])
- check_page_title('Issues')
+ check_page_title("Issues")
- find('body').send_keys([:shift, 'M'])
+ find("body").send_keys([:shift, "M"])
- check_page_title('Merge Requests')
+ check_page_title("Merge Requests")
- find('body').send_keys([:shift, 'T'])
+ find("body").send_keys([:shift, "T"])
- check_page_title('Todos')
+ check_page_title("Todos")
- find('body').send_keys([:shift, 'P'])
+ find("body").send_keys([:shift, "P"])
- check_page_title('Projects')
+ check_page_title("Projects")
end
end
- context 'logged out' do
+ context "logged out" do
before do
visit explore_root_path
end
- it 'Navigate to tabs' do
- find('body').send_keys([:shift, 'G'])
+ it "Navigate to tabs" do
+ find("body").send_keys([:shift, "G"])
- find('.nothing-here-block')
- expect(page).to have_content('No public groups')
+ find(".nothing-here-block")
+ expect(page).to have_content("No public groups")
- find('body').send_keys([:shift, 'S'])
+ find("body").send_keys([:shift, "S"])
- find('.nothing-here-block')
- expect(page).to have_content('No snippets found')
+ find(".nothing-here-block")
+ expect(page).to have_content("No snippets found")
- find('body').send_keys([:shift, 'P'])
+ find("body").send_keys([:shift, "P"])
- find('.nothing-here-block')
- expect(page).to have_content('This user doesn\'t have any personal projects')
+ find(".nothing-here-block")
+ expect(page).to have_content("This user doesn't have any personal projects")
end
end
def check_page_title(title)
- expect(find('.page-title')).to have_content(title)
+ expect(find(".page-title")).to have_content(title)
end
end
diff --git a/spec/features/dashboard/snippets_spec.rb b/spec/features/dashboard/snippets_spec.rb
index 0e248c8732d..adf4a1a5cb6 100644
--- a/spec/features/dashboard/snippets_spec.rb
+++ b/spec/features/dashboard/snippets_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard snippets' do
- context 'when the project has snippets' do
+describe "Dashboard snippets" do
+ context "when the project has snippets" do
let(:project) { create(:project, :public) }
let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
before do
@@ -10,32 +10,32 @@ describe 'Dashboard snippets' do
visit dashboard_snippets_path
end
- it_behaves_like 'paginated snippets'
+ it_behaves_like "paginated snippets"
end
- context 'when there are no project snippets', :js do
+ context "when there are no project snippets", :js do
let(:project) { create(:project, :public) }
before do
sign_in(project.owner)
visit dashboard_snippets_path
end
- it 'shows the empty state when there are no snippets' do
- element = page.find('.row.empty-state')
+ it "shows the empty state when there are no snippets" do
+ element = page.find(".row.empty-state")
expect(element).to have_content("Snippets are small pieces of code or notes that you want to keep.")
- expect(element.find('.svg-content img')['src']).to have_content('illustrations/snippets_empty')
+ expect(element.find(".svg-content img")["src"]).to have_content("illustrations/snippets_empty")
end
end
- context 'filtering by visibility' do
+ context "filtering by visibility" do
let(:user) { create(:user) }
let!(:snippets) do
[
create(:personal_snippet, :public, author: user),
create(:personal_snippet, :internal, author: user),
create(:personal_snippet, :private, author: user),
- create(:personal_snippet, :public)
+ create(:personal_snippet, :public),
]
end
@@ -45,32 +45,32 @@ describe 'Dashboard snippets' do
visit dashboard_snippets_path
end
- it 'contains all snippets of logged user' do
- expect(page).to have_selector('.snippet-row', count: 3)
+ it "contains all snippets of logged user" do
+ expect(page).to have_selector(".snippet-row", count: 3)
expect(page).to have_content(snippets[0].title)
expect(page).to have_content(snippets[1].title)
expect(page).to have_content(snippets[2].title)
end
- it 'contains all private snippets of logged user when clicking on private' do
- click_link('Private')
+ it "contains all private snippets of logged user when clicking on private" do
+ click_link("Private")
- expect(page).to have_selector('.snippet-row', count: 1)
+ expect(page).to have_selector(".snippet-row", count: 1)
expect(page).to have_content(snippets[2].title)
end
- it 'contains all internal snippets of logged user when clicking on internal' do
- click_link('Internal')
+ it "contains all internal snippets of logged user when clicking on internal" do
+ click_link("Internal")
- expect(page).to have_selector('.snippet-row', count: 1)
+ expect(page).to have_selector(".snippet-row", count: 1)
expect(page).to have_content(snippets[1].title)
end
- it 'contains all public snippets of logged user when clicking on public' do
- click_link('Public')
+ it "contains all public snippets of logged user when clicking on public" do
+ click_link("Public")
- expect(page).to have_selector('.snippet-row', count: 1)
+ expect(page).to have_selector(".snippet-row", count: 1)
expect(page).to have_content(snippets[0].title)
end
end
diff --git a/spec/features/dashboard/todos/target_state_spec.rb b/spec/features/dashboard/todos/target_state_spec.rb
index d55c32b3082..5bf18142b9b 100644
--- a/spec/features/dashboard/todos/target_state_spec.rb
+++ b/spec/features/dashboard/todos/target_state_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dashboard > Todo target states' do
+describe "Dashboard > Todo target states" do
let(:user) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public) }
@@ -9,53 +9,53 @@ describe 'Dashboard > Todo target states' do
sign_in(user)
end
- it 'on a closed issue todo has closed label' do
- issue_closed = create(:issue, state: 'closed')
+ it "on a closed issue todo has closed label" do
+ issue_closed = create(:issue, state: "closed")
create_todo issue_closed
visit dashboard_todos_path
- page.within '.todos-list' do
- expect(page).to have_content('Closed')
+ page.within ".todos-list" do
+ expect(page).to have_content("Closed")
end
end
- it 'on an open issue todo does not have an open label' do
+ it "on an open issue todo does not have an open label" do
issue_open = create(:issue)
create_todo issue_open
visit dashboard_todos_path
- page.within '.todos-list' do
- expect(page).not_to have_content('Open')
+ page.within ".todos-list" do
+ expect(page).not_to have_content("Open")
end
end
- it 'on a merged merge request todo has merged label' do
+ it "on a merged merge request todo has merged label" do
mr_merged = create(:merge_request, :simple, :merged, author: user)
create_todo mr_merged
visit dashboard_todos_path
- page.within '.todos-list' do
- expect(page).to have_content('Merged')
+ page.within ".todos-list" do
+ expect(page).to have_content("Merged")
end
end
- it 'on a closed merge request todo has closed label' do
+ it "on a closed merge request todo has closed label" do
mr_closed = create(:merge_request, :simple, :closed, author: user)
create_todo mr_closed
visit dashboard_todos_path
- page.within '.todos-list' do
- expect(page).to have_content('Closed')
+ page.within ".todos-list" do
+ expect(page).to have_content("Closed")
end
end
- it 'on an open merge request todo does not have an open label' do
+ it "on an open merge request todo does not have an open label" do
mr_open = create(:merge_request, :simple, author: user)
create_todo mr_open
visit dashboard_todos_path
- page.within '.todos-list' do
- expect(page).not_to have_content('Open')
+ page.within ".todos-list" do
+ expect(page).not_to have_content("Open")
end
end
diff --git a/spec/features/dashboard/todos/todos_filtering_spec.rb b/spec/features/dashboard/todos/todos_filtering_spec.rb
index 85f865321cf..81cfe418743 100644
--- a/spec/features/dashboard/todos/todos_filtering_spec.rb
+++ b/spec/features/dashboard/todos/todos_filtering_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > User filters todos', :js do
- let(:user_1) { create(:user, username: 'user_1', name: 'user_1') }
- let(:user_2) { create(:user, username: 'user_2', name: 'user_2') }
+describe "Dashboard > User filters todos", :js do
+ let(:user_1) { create(:user, username: "user_1", name: "user_1") }
+ let(:user_2) { create(:user, username: "user_2", name: "user_2") }
- let(:project_1) { create(:project, name: 'project_1') }
- let(:project_2) { create(:project, name: 'project_2') }
+ let(:project_1) { create(:project, name: "project_1") }
+ let(:project_2) { create(:project, name: "project_2") }
- let(:issue) { create(:issue, title: 'issue', project: project_1) }
+ let(:issue) { create(:issue, title: "issue", project: project_1) }
- let!(:merge_request) { create(:merge_request, source_project: project_2, title: 'merge_request') }
+ let!(:merge_request) { create(:merge_request, source_project: project_2, title: "merge_request") }
before do
create(:todo, user: user_1, author: user_2, project: project_1, target: issue, action: 1)
@@ -21,10 +21,10 @@ describe 'Dashboard > User filters todos', :js do
visit dashboard_todos_path
end
- it 'filters by project' do
- click_button 'Project'
- within '.dropdown-menu-project' do
- fill_in 'Search projects', with: project_1.full_name
+ it "filters by project" do
+ click_button "Project"
+ within ".dropdown-menu-project" do
+ fill_in "Search projects", with: project_1.full_name
click_link project_1.full_name
end
@@ -34,33 +34,33 @@ describe 'Dashboard > User filters todos', :js do
expect(page).not_to have_content project_2.full_name
end
- context 'Author filter' do
- it 'filters by author' do
- click_button 'Author'
+ context "Author filter" do
+ it "filters by author" do
+ click_button "Author"
- within '.dropdown-menu-author' do
- fill_in 'Search authors', with: user_1.name
+ within ".dropdown-menu-author" do
+ fill_in "Search authors", with: user_1.name
click_link user_1.name
end
wait_for_requests
- expect(find('.todos-list')).to have_content 'merge request'
- expect(find('.todos-list')).not_to have_content 'issue'
+ expect(find(".todos-list")).to have_content "merge request"
+ expect(find(".todos-list")).not_to have_content "issue"
end
- it 'shows only authors of existing todos' do
- click_button 'Author'
+ it "shows only authors of existing todos" do
+ click_button "Author"
- within '.dropdown-menu-author' do
+ within ".dropdown-menu-author" do
# It should contain two users + 'Any Author'
- expect(page).to have_selector('.dropdown-menu-user-link', count: 3)
+ expect(page).to have_selector(".dropdown-menu-user-link", count: 3)
expect(page).to have_content(user_1.name)
expect(page).to have_content(user_2.name)
end
end
- it 'shows only authors of existing done todos' do
+ it "shows only authors of existing done todos" do
user_3 = create :user
user_4 = create :user
create(:todo, user: user_1, author: user_3, project: project_1, target: issue, action: 1, state: :done)
@@ -69,13 +69,13 @@ describe 'Dashboard > User filters todos', :js do
project_1.add_developer(user_3)
project_2.add_developer(user_4)
- visit dashboard_todos_path(state: 'done')
+ visit dashboard_todos_path(state: "done")
- click_button 'Author'
+ click_button "Author"
- within '.dropdown-menu-author' do
+ within ".dropdown-menu-author" do
# It should contain two users + 'Any Author'
- expect(page).to have_selector('.dropdown-menu-user-link', count: 3)
+ expect(page).to have_selector(".dropdown-menu-user-link", count: 3)
expect(page).to have_content(user_3.name)
expect(page).to have_content(user_4.name)
expect(page).not_to have_content(user_1.name)
@@ -84,51 +84,51 @@ describe 'Dashboard > User filters todos', :js do
end
end
- it 'filters by type' do
- click_button 'Type'
- within '.dropdown-menu-type' do
- click_link 'Issue'
+ it "filters by type" do
+ click_button "Type"
+ within ".dropdown-menu-type" do
+ click_link "Issue"
end
wait_for_requests
- expect(find('.todos-list')).to have_content issue.to_reference
- expect(find('.todos-list')).not_to have_content merge_request.to_reference
+ expect(find(".todos-list")).to have_content issue.to_reference
+ expect(find(".todos-list")).not_to have_content merge_request.to_reference
end
- describe 'filter by action' do
+ describe "filter by action" do
before do
create(:todo, :build_failed, user: user_1, author: user_2, project: project_1)
create(:todo, :marked, user: user_1, author: user_2, project: project_1, target: issue)
end
- it 'filters by Assigned' do
- filter_action('Assigned')
+ it "filters by Assigned" do
+ filter_action("Assigned")
expect_to_see_action(:assigned)
end
- it 'filters by Mentioned' do
- filter_action('Mentioned')
+ it "filters by Mentioned" do
+ filter_action("Mentioned")
expect_to_see_action(:mentioned)
end
- it 'filters by Added' do
- filter_action('Added')
+ it "filters by Added" do
+ filter_action("Added")
expect_to_see_action(:marked)
end
- it 'filters by Pipelines' do
- filter_action('Pipelines')
+ it "filters by Pipelines" do
+ filter_action("Pipelines")
expect_to_see_action(:build_failed)
end
def filter_action(name)
- click_button 'Action'
- within '.dropdown-menu-action' do
+ click_button "Action"
+ within ".dropdown-menu-action" do
click_link name
end
@@ -137,16 +137,16 @@ describe 'Dashboard > User filters todos', :js do
def expect_to_see_action(action_name)
action_names = {
- assigned: ' assigned you ',
- mentioned: ' mentioned ',
- marked: ' added a todo for ',
- build_failed: ' build failed for '
+ assigned: " assigned you ",
+ mentioned: " mentioned ",
+ marked: " added a todo for ",
+ build_failed: " build failed for ",
}
action_name_text = action_names.delete(action_name)
- expect(find('.todos-list')).to have_content action_name_text
+ expect(find(".todos-list")).to have_content action_name_text
action_names.each_value do |other_action_text|
- expect(find('.todos-list')).not_to have_content other_action_text
+ expect(find(".todos-list")).not_to have_content other_action_text
end
end
end
diff --git a/spec/features/dashboard/todos/todos_sorting_spec.rb b/spec/features/dashboard/todos/todos_sorting_spec.rb
index b87caaa1c07..724afa6020e 100644
--- a/spec/features/dashboard/todos/todos_sorting_spec.rb
+++ b/spec/features/dashboard/todos/todos_sorting_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > User sorts todos' do
+describe "Dashboard > User sorts todos" do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) }
+ let(:label_1) { create(:label, title: "label_1", project: project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: project, priority: 2) }
+ let(:label_3) { create(:label, title: "label_3", project: project, priority: 3) }
before do
project.add_developer(user)
end
- context 'sort options' do
- let(:issue_1) { create(:issue, title: 'issue_1', project: project) }
- let(:issue_2) { create(:issue, title: 'issue_2', project: project) }
- let(:issue_3) { create(:issue, title: 'issue_3', project: project) }
- let(:issue_4) { create(:issue, title: 'issue_4', project: project) }
+ context "sort options" do
+ let(:issue_1) { create(:issue, title: "issue_1", project: project) }
+ let(:issue_2) { create(:issue, title: "issue_2", project: project) }
+ let(:issue_3) { create(:issue, title: "issue_3", project: project) }
+ let(:issue_4) { create(:issue, title: "issue_4", project: project) }
- let!(:merge_request_1) { create(:merge_request, source_project: project, title: 'merge_request_1') }
+ let!(:merge_request_1) { create(:merge_request, source_project: project, title: "merge_request_1") }
before do
create(:todo, user: user, project: project, target: issue_4, created_at: 5.hours.ago)
@@ -36,44 +36,44 @@ describe 'Dashboard > User sorts todos' do
visit dashboard_todos_path
end
- it 'sorts with oldest created todos first' do
- click_link 'Last created'
+ it "sorts with oldest created todos first" do
+ click_link "Last created"
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content('merge_request_1')
- expect(results_list.all('p')[1]).to have_content('issue_1')
- expect(results_list.all('p')[2]).to have_content('issue_3')
- expect(results_list.all('p')[3]).to have_content('issue_2')
- expect(results_list.all('p')[4]).to have_content('issue_4')
+ results_list = page.find(".todos-list")
+ expect(results_list.all("p")[0]).to have_content("merge_request_1")
+ expect(results_list.all("p")[1]).to have_content("issue_1")
+ expect(results_list.all("p")[2]).to have_content("issue_3")
+ expect(results_list.all("p")[3]).to have_content("issue_2")
+ expect(results_list.all("p")[4]).to have_content("issue_4")
end
- it 'sorts with newest created todos first' do
- click_link 'Oldest created'
+ it "sorts with newest created todos first" do
+ click_link "Oldest created"
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content('issue_4')
- expect(results_list.all('p')[1]).to have_content('issue_2')
- expect(results_list.all('p')[2]).to have_content('issue_3')
- expect(results_list.all('p')[3]).to have_content('issue_1')
- expect(results_list.all('p')[4]).to have_content('merge_request_1')
+ results_list = page.find(".todos-list")
+ expect(results_list.all("p")[0]).to have_content("issue_4")
+ expect(results_list.all("p")[1]).to have_content("issue_2")
+ expect(results_list.all("p")[2]).to have_content("issue_3")
+ expect(results_list.all("p")[3]).to have_content("issue_1")
+ expect(results_list.all("p")[4]).to have_content("merge_request_1")
end
- it 'sorts by label priority' do
- click_link 'Label priority'
+ it "sorts by label priority" do
+ click_link "Label priority"
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content('issue_3')
- expect(results_list.all('p')[1]).to have_content('merge_request_1')
- expect(results_list.all('p')[2]).to have_content('issue_1')
- expect(results_list.all('p')[3]).to have_content('issue_2')
- expect(results_list.all('p')[4]).to have_content('issue_4')
+ results_list = page.find(".todos-list")
+ expect(results_list.all("p")[0]).to have_content("issue_3")
+ expect(results_list.all("p")[1]).to have_content("merge_request_1")
+ expect(results_list.all("p")[2]).to have_content("issue_1")
+ expect(results_list.all("p")[3]).to have_content("issue_2")
+ expect(results_list.all("p")[4]).to have_content("issue_4")
end
end
- context 'issues and merge requests' do
- let(:issue_1) { create(:issue, id: 10000, title: 'issue_1', project: project) }
- let(:issue_2) { create(:issue, id: 10001, title: 'issue_2', project: project) }
- let(:merge_request_1) { create(:merge_request, id: 10000, title: 'merge_request_1', source_project: project) }
+ context "issues and merge requests" do
+ let(:issue_1) { create(:issue, id: 10000, title: "issue_1", project: project) }
+ let(:issue_2) { create(:issue, id: 10001, title: "issue_2", project: project) }
+ let(:merge_request_1) { create(:merge_request, id: 10000, title: "merge_request_1", source_project: project) }
before do
issue_1.labels << label_1
@@ -88,12 +88,12 @@ describe 'Dashboard > User sorts todos' do
end
it "doesn't mix issues and merge requests label priorities" do
- click_link 'Label priority'
+ click_link "Label priority"
- results_list = page.find('.todos-list')
- expect(results_list.all('p')[0]).to have_content('issue_1')
- expect(results_list.all('p')[1]).to have_content('issue_2')
- expect(results_list.all('p')[2]).to have_content('merge_request_1')
+ results_list = page.find(".todos-list")
+ expect(results_list.all("p")[0]).to have_content("issue_1")
+ expect(results_list.all("p")[1]).to have_content("issue_2")
+ expect(results_list.all("p")[2]).to have_content("merge_request_1")
end
end
end
diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb
index fd8677feab5..06ad00025dc 100644
--- a/spec/features/dashboard/todos/todos_spec.rb
+++ b/spec/features/dashboard/todos/todos_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Todos' do
+describe "Dashboard Todos" do
let(:user) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, due_date: Date.today) }
- context 'User does not have todos' do
+ context "User does not have todos" do
before do
sign_in(user)
visit dashboard_todos_path
end
it 'shows "All done" message' do
- expect(page).to have_content 'Todos let you see what you should do next'
+ expect(page).to have_content "Todos let you see what you should do next"
end
end
- context 'User has a todo', :js do
+ context "User has a todo", :js do
before do
create(:todo, :mentioned, user: user, project: project, target: issue, author: author)
sign_in(user)
@@ -25,142 +25,142 @@ describe 'Dashboard Todos' do
visit dashboard_todos_path
end
- it 'has todo present' do
- expect(page).to have_selector('.todos-list .todo', count: 1)
+ it "has todo present" do
+ expect(page).to have_selector(".todos-list .todo", count: 1)
end
- it 'shows due date as today' do
- within first('.todo') do
- expect(page).to have_content 'Due today'
+ it "shows due date as today" do
+ within first(".todo") do
+ expect(page).to have_content "Due today"
end
end
- shared_examples 'deleting the todo' do
+ shared_examples "deleting the todo" do
before do
- within first('.todo') do
- click_link 'Done'
+ within first(".todo") do
+ click_link "Done"
end
end
- it 'is marked as done-reversible in the list' do
- expect(page).to have_selector('.todos-list .todo.todo-pending.done-reversible')
+ it "is marked as done-reversible in the list" do
+ expect(page).to have_selector(".todos-list .todo.todo-pending.done-reversible")
end
- it 'shows Undo button' do
- expect(page).to have_selector('.js-undo-todo', visible: true)
- expect(page).to have_selector('.js-done-todo', visible: false)
+ it "shows Undo button" do
+ expect(page).to have_selector(".js-undo-todo", visible: true)
+ expect(page).to have_selector(".js-done-todo", visible: false)
end
- it 'updates todo count' do
- expect(page).to have_content 'Todos 0'
- expect(page).to have_content 'Done 1'
+ it "updates todo count" do
+ expect(page).to have_content "Todos 0"
+ expect(page).to have_content "Done 1"
end
it 'has not "All done" message' do
- expect(page).not_to have_selector('.todos-all-done')
+ expect(page).not_to have_selector(".todos-all-done")
end
end
- shared_examples 'deleting and restoring the todo' do
+ shared_examples "deleting and restoring the todo" do
before do
- within first('.todo') do
- click_link 'Done'
+ within first(".todo") do
+ click_link "Done"
wait_for_requests
- click_link 'Undo'
+ click_link "Undo"
end
end
- it 'is marked back as pending in the list' do
- expect(page).not_to have_selector('.todos-list .todo.todo-pending.done-reversible')
- expect(page).to have_selector('.todos-list .todo.todo-pending')
+ it "is marked back as pending in the list" do
+ expect(page).not_to have_selector(".todos-list .todo.todo-pending.done-reversible")
+ expect(page).to have_selector(".todos-list .todo.todo-pending")
end
- it 'shows Done button' do
- expect(page).to have_selector('.js-undo-todo', visible: false)
- expect(page).to have_selector('.js-done-todo', visible: true)
+ it "shows Done button" do
+ expect(page).to have_selector(".js-undo-todo", visible: false)
+ expect(page).to have_selector(".js-done-todo", visible: true)
end
- it 'updates todo count' do
- expect(page).to have_content 'Todos 1'
- expect(page).to have_content 'Done 0'
+ it "updates todo count" do
+ expect(page).to have_content "Todos 1"
+ expect(page).to have_content "Done 0"
end
end
- it_behaves_like 'deleting the todo'
- it_behaves_like 'deleting and restoring the todo'
+ it_behaves_like "deleting the todo"
+ it_behaves_like "deleting and restoring the todo"
- context 'todo is stale on the page' do
+ context "todo is stale on the page" do
before do
todos = TodosFinder.new(user, state: :pending).execute
TodoService.new.mark_todos_as_done(todos, user)
end
- it_behaves_like 'deleting the todo'
- it_behaves_like 'deleting and restoring the todo'
+ it_behaves_like "deleting the todo"
+ it_behaves_like "deleting and restoring the todo"
end
end
- context 'User created todos for themself' do
+ context "User created todos for themself" do
before do
sign_in(user)
end
- context 'issue assigned todo' do
+ context "issue assigned todo" do
before do
create(:todo, :assigned, user: user, project: project, target: issue, author: user)
visit dashboard_todos_path
end
- it 'shows issue assigned to yourself message' do
- page.within('.js-todos-all') do
+ it "shows issue assigned to yourself message" do
+ page.within(".js-todos-all") do
expect(page).to have_content("You assigned issue #{issue.to_reference(full: true)} to yourself")
end
end
end
- context 'marked todo' do
+ context "marked todo" do
before do
create(:todo, :marked, user: user, project: project, target: issue, author: user)
visit dashboard_todos_path
end
- it 'shows you added a todo message' do
- page.within('.js-todos-all') do
+ it "shows you added a todo message" do
+ page.within(".js-todos-all") do
expect(page).to have_content("You added a todo for issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
+ expect(page).not_to have_content("to yourself")
end
end
end
- context 'mentioned todo' do
+ context "mentioned todo" do
before do
create(:todo, :mentioned, user: user, project: project, target: issue, author: user)
visit dashboard_todos_path
end
- it 'shows you mentioned yourself message' do
- page.within('.js-todos-all') do
+ it "shows you mentioned yourself message" do
+ page.within(".js-todos-all") do
expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
+ expect(page).not_to have_content("to yourself")
end
end
end
- context 'directly_addressed todo' do
+ context "directly_addressed todo" do
before do
create(:todo, :directly_addressed, user: user, project: project, target: issue, author: user)
visit dashboard_todos_path
end
- it 'shows you directly addressed yourself message' do
- page.within('.js-todos-all') do
+ it "shows you directly addressed yourself message" do
+ page.within(".js-todos-all") do
expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
+ expect(page).not_to have_content("to yourself")
end
end
end
- context 'approval todo' do
+ context "approval todo" do
let(:merge_request) { create(:merge_request) }
before do
@@ -168,66 +168,66 @@ describe 'Dashboard Todos' do
visit dashboard_todos_path
end
- it 'shows you set yourself as an approver message' do
- page.within('.js-todos-all') do
+ it "shows you set yourself as an approver message" do
+ page.within(".js-todos-all") do
expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference(full: true)}")
- expect(page).not_to have_content('to yourself')
+ expect(page).not_to have_content("to yourself")
end
end
end
end
- context 'User has done todos', :js do
+ context "User has done todos", :js do
before do
create(:todo, :mentioned, :done, user: user, project: project, target: issue, author: author)
sign_in(user)
visit dashboard_todos_path(state: :done)
end
- it 'has the done todo present' do
- expect(page).to have_selector('.todos-list .todo.todo-done', count: 1)
+ it "has the done todo present" do
+ expect(page).to have_selector(".todos-list .todo.todo-done", count: 1)
end
- describe 'restoring the todo' do
+ describe "restoring the todo" do
before do
- within first('.todo') do
- click_link 'Add todo'
+ within first(".todo") do
+ click_link "Add todo"
end
end
- it 'is removed from the list' do
- expect(page).not_to have_selector('.todos-list .todo.todo-done')
+ it "is removed from the list" do
+ expect(page).not_to have_selector(".todos-list .todo.todo-done")
end
- it 'updates todo count' do
- expect(page).to have_content 'Todos 1'
- expect(page).to have_content 'Done 0'
+ it "updates todo count" do
+ expect(page).to have_content "Todos 1"
+ expect(page).to have_content "Done 0"
end
end
end
- context 'User has Todos with labels spanning multiple projects' do
+ context "User has Todos with labels spanning multiple projects" do
before do
label1 = create(:label, project: project)
- note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: 'Issue', project: issue.project)
+ note1 = create(:note_on_issue, note: "Hello #{label1.to_reference(format: :name)}", noteable_id: issue.id, noteable_type: "Issue", project: issue.project)
create(:todo, :mentioned, project: project, target: issue, user: user, note_id: note1.id)
project2 = create(:project, :public)
label2 = create(:label, project: project2)
issue2 = create(:issue, project: project2)
- note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: 'Issue', project: project2)
+ note2 = create(:note_on_issue, note: "Test #{label2.to_reference(format: :name)}", noteable_id: issue2.id, noteable_type: "Issue", project: project2)
create(:todo, :mentioned, project: project2, target: issue2, user: user, note_id: note2.id)
gitlab_sign_in(user)
visit dashboard_todos_path
end
- it 'shows page with two Todos' do
- expect(page).to have_selector('.todos-list .todo', count: 2)
+ it "shows page with two Todos" do
+ expect(page).to have_selector(".todos-list .todo", count: 2)
end
end
- context 'User has multiple pages of Todos' do
+ context "User has multiple pages of Todos" do
before do
allow(Todo).to receive(:default_per_page).and_return(1)
@@ -237,87 +237,87 @@ describe 'Dashboard Todos' do
sign_in(user)
end
- it 'is paginated' do
+ it "is paginated" do
visit dashboard_todos_path
- expect(page).to have_selector('.gl-pagination')
+ expect(page).to have_selector(".gl-pagination")
end
- it 'is has the right number of pages' do
+ it "is has the right number of pages" do
visit dashboard_todos_path
- expect(page).to have_selector('.gl-pagination .js-pagination-page', count: 2)
+ expect(page).to have_selector(".gl-pagination .js-pagination-page", count: 2)
end
- describe 'mark all as done', :js do
+ describe "mark all as done", :js do
before do
visit dashboard_todos_path
- find('.js-todos-mark-all').click
+ find(".js-todos-mark-all").click
end
it 'shows "All done" message!' do
- expect(page).to have_content 'Todos 0'
+ expect(page).to have_content "Todos 0"
expect(page).to have_content "You're all done!"
- expect(page).not_to have_selector('.gl-pagination')
+ expect(page).not_to have_selector(".gl-pagination")
end
it 'shows "Undo mark all as done" button' do
- expect(page).to have_selector('.js-todos-mark-all', visible: false)
- expect(page).to have_selector('.js-todos-undo-all', visible: true)
+ expect(page).to have_selector(".js-todos-mark-all", visible: false)
+ expect(page).to have_selector(".js-todos-undo-all", visible: true)
end
end
- describe 'undo mark all as done', :js do
+ describe "undo mark all as done", :js do
before do
visit dashboard_todos_path
end
- it 'shows the restored todo list' do
+ it "shows the restored todo list" do
mark_all_and_undo
- expect(page).to have_selector('.todos-list .todo', count: 1)
- expect(page).to have_selector('.gl-pagination')
+ expect(page).to have_selector(".todos-list .todo", count: 1)
+ expect(page).to have_selector(".gl-pagination")
expect(page).not_to have_content "You're all done!"
end
- it 'updates todo count' do
+ it "updates todo count" do
mark_all_and_undo
- expect(page).to have_content 'Todos 2'
- expect(page).to have_content 'Done 0'
+ expect(page).to have_content "Todos 2"
+ expect(page).to have_content "Done 0"
end
it 'shows "Mark all as done" button' do
mark_all_and_undo
- expect(page).to have_selector('.js-todos-mark-all', visible: true)
- expect(page).to have_selector('.js-todos-undo-all', visible: false)
+ expect(page).to have_selector(".js-todos-mark-all", visible: true)
+ expect(page).to have_selector(".js-todos-undo-all", visible: false)
end
- context 'User has deleted a todo' do
+ context "User has deleted a todo" do
before do
- within first('.todo') do
- click_link 'Done'
+ within first(".todo") do
+ click_link "Done"
end
end
- it 'shows the restored todo list with the deleted todo' do
+ it "shows the restored todo list with the deleted todo" do
mark_all_and_undo
- expect(page).to have_selector('.todos-list .todo.todo-pending', count: 1)
+ expect(page).to have_selector(".todos-list .todo.todo-pending", count: 1)
end
end
def mark_all_and_undo
- find('.js-todos-mark-all').click
+ find(".js-todos-mark-all").click
wait_for_requests
- find('.js-todos-undo-all').click
+ find(".js-todos-undo-all").click
wait_for_requests
end
end
end
- context 'User has a Build Failed todo' do
+ context "User has a Build Failed todo" do
let!(:todo) { create(:todo, :build_failed, user: user, project: project, author: author) }
before do
@@ -325,11 +325,11 @@ describe 'Dashboard Todos' do
visit dashboard_todos_path
end
- it 'shows the todo' do
- expect(page).to have_content 'The build failed for merge request'
+ it "shows the todo" do
+ expect(page).to have_content "The build failed for merge request"
end
- it 'links to the pipelines for the merge request' do
+ it "links to the pipelines for the merge request" do
href = pipelines_project_merge_request_path(project, todo.target)
expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href: href
diff --git a/spec/features/dashboard/user_filters_projects_spec.rb b/spec/features/dashboard/user_filters_projects_spec.rb
index cc86114e436..1f08b04e50b 100644
--- a/spec/features/dashboard/user_filters_projects_spec.rb
+++ b/spec/features/dashboard/user_filters_projects_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard > User filters projects' do
+describe "Dashboard > User filters projects" do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'Victorialand', namespace: user.namespace) }
+ let(:project) { create(:project, name: "Victorialand", namespace: user.namespace) }
let(:user2) { create(:user) }
- let(:project2) { create(:project, name: 'Treasure', namespace: user2.namespace) }
+ let(:project2) { create(:project, name: "Treasure", namespace: user2.namespace) }
before do
project.add_maintainer(user)
@@ -12,7 +12,7 @@ describe 'Dashboard > User filters projects' do
sign_in(user)
end
- describe 'filtering personal projects' do
+ describe "filtering personal projects" do
before do
project2.add_developer(user)
@@ -20,26 +20,26 @@ describe 'Dashboard > User filters projects' do
end
it 'filters by projects "Owned by me"' do
- click_link 'Owned by me'
+ click_link "Owned by me"
- expect(page).to have_css('.is-active', text: 'Owned by me')
- expect(page).to have_content('Victorialand')
- expect(page).not_to have_content('Treasure')
+ expect(page).to have_css(".is-active", text: "Owned by me")
+ expect(page).to have_content("Victorialand")
+ expect(page).not_to have_content("Treasure")
end
end
- describe 'filtering starred projects', :js do
+ describe "filtering starred projects", :js do
before do
user.toggle_star(project)
visit dashboard_projects_path
end
- it 'returns message when starred projects fitler returns no results' do
- fill_in 'project-filter-form-field', with: 'Beta\n'
+ it "returns message when starred projects fitler returns no results" do
+ fill_in "project-filter-form-field", with: 'Beta\n'
- expect(page).to have_content('This user doesn\'t have any personal projects')
- expect(page).not_to have_content('You don\'t have starred projects yet')
+ expect(page).to have_content("This user doesn't have any personal projects")
+ expect(page).not_to have_content("You don't have starred projects yet")
end
end
end
diff --git a/spec/features/discussion_comments/commit_spec.rb b/spec/features/discussion_comments/commit_spec.rb
index 7a3b1d7ed47..327e9be315c 100644
--- a/spec/features/discussion_comments/commit_spec.rb
+++ b/spec/features/discussion_comments/commit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Discussion Comments Commit', :js do
+describe "Discussion Comments Commit", :js do
include RepoHelpers
let(:user) { create(:user) }
@@ -14,5 +14,5 @@ describe 'Discussion Comments Commit', :js do
visit project_commit_path(project, sample_commit.id)
end
- it_behaves_like 'discussion comments', 'commit'
+ it_behaves_like "discussion comments", "commit"
end
diff --git a/spec/features/discussion_comments/issue_spec.rb b/spec/features/discussion_comments/issue_spec.rb
index 5ec19460bbd..6e0f4ffa5e6 100644
--- a/spec/features/discussion_comments/issue_spec.rb
+++ b/spec/features/discussion_comments/issue_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Discussion Comments Issue', :js do
+describe "Discussion Comments Issue", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
@@ -12,5 +12,5 @@ describe 'Discussion Comments Issue', :js do
visit project_issue_path(project, issue)
end
- it_behaves_like 'discussion comments', 'issue'
+ it_behaves_like "discussion comments", "issue"
end
diff --git a/spec/features/discussion_comments/merge_request_spec.rb b/spec/features/discussion_comments/merge_request_spec.rb
index f940e973923..2cf0a732449 100644
--- a/spec/features/discussion_comments/merge_request_spec.rb
+++ b/spec/features/discussion_comments/merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Discussion Comments Merge Request', :js do
+describe "Discussion Comments Merge Request", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -12,5 +12,5 @@ describe 'Discussion Comments Merge Request', :js do
visit project_merge_request_path(project, merge_request)
end
- it_behaves_like 'discussion comments', 'merge request'
+ it_behaves_like "discussion comments", "merge request"
end
diff --git a/spec/features/discussion_comments/snippets_spec.rb b/spec/features/discussion_comments/snippets_spec.rb
index d330e89505e..c2f80303d97 100644
--- a/spec/features/discussion_comments/snippets_spec.rb
+++ b/spec/features/discussion_comments/snippets_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Discussion Comments Snippet', :js do
+describe "Discussion Comments Snippet", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:snippet) { create(:project_snippet, :private, project: project, author: user) }
@@ -12,5 +12,5 @@ describe 'Discussion Comments Snippet', :js do
visit project_snippet_path(project, snippet)
end
- it_behaves_like 'discussion comments', 'snippet'
+ it_behaves_like "discussion comments", "snippet"
end
diff --git a/spec/features/display_system_header_and_footer_bar_spec.rb b/spec/features/display_system_header_and_footer_bar_spec.rb
index af9d9a5834f..165768fe3dc 100644
--- a/spec/features/display_system_header_and_footer_bar_spec.rb
+++ b/spec/features/display_system_header_and_footer_bar_spec.rb
@@ -1,60 +1,60 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'Display system header and footer bar' do
+describe "Display system header and footer bar" do
let(:header_message) { "Foo" }
let(:footer_message) { "Bar" }
- shared_examples 'system header is configured' do
- it 'shows system header' do
- expect(page).to have_css('.header-message')
+ shared_examples "system header is configured" do
+ it "shows system header" do
+ expect(page).to have_css(".header-message")
end
- it 'shows the correct content' do
- page.within('.header-message') do
+ it "shows the correct content" do
+ page.within(".header-message") do
expect(page).to have_content(header_message)
end
end
end
- shared_examples 'system footer is configured' do
- it 'shows system footer' do
- expect(page).to have_css('.footer-message')
+ shared_examples "system footer is configured" do
+ it "shows system footer" do
+ expect(page).to have_css(".footer-message")
end
- it 'shows the correct content' do
- page.within('.footer-message') do
+ it "shows the correct content" do
+ page.within(".footer-message") do
expect(page).to have_content(footer_message)
end
end
end
- shared_examples 'system header is not configured' do
- it 'does not show system header' do
- expect(page).not_to have_css('.header-message')
+ shared_examples "system header is not configured" do
+ it "does not show system header" do
+ expect(page).not_to have_css(".header-message")
end
end
- shared_examples 'system footer is not configured' do
- it 'does not show system footer' do
- expect(page).not_to have_css('.footer-message')
+ shared_examples "system footer is not configured" do
+ it "does not show system footer" do
+ expect(page).not_to have_css(".footer-message")
end
end
- context 'when authenticated' do
- context 'when system header and footer are not configured' do
+ context "when authenticated" do
+ context "when system header and footer are not configured" do
before do
sign_in(create(:user))
visit root_path
end
- it_behaves_like 'system header is not configured'
- it_behaves_like 'system footer is not configured'
+ it_behaves_like "system header is not configured"
+ it_behaves_like "system footer is not configured"
end
- context 'when only system header is defined' do
+ context "when only system header is defined" do
before do
create(:appearance, header_message: header_message)
@@ -62,11 +62,11 @@ describe 'Display system header and footer bar' do
visit root_path
end
- it_behaves_like 'system header is configured'
- it_behaves_like 'system footer is not configured'
+ it_behaves_like "system header is configured"
+ it_behaves_like "system footer is not configured"
end
- context 'when only system footer is defined' do
+ context "when only system footer is defined" do
before do
create(:appearance, footer_message: footer_message)
@@ -74,11 +74,11 @@ describe 'Display system header and footer bar' do
visit root_path
end
- it_behaves_like 'system header is not configured'
- it_behaves_like 'system footer is configured'
+ it_behaves_like "system header is not configured"
+ it_behaves_like "system footer is configured"
end
- context 'when system header and footer are defined' do
+ context "when system header and footer are defined" do
before do
create(:appearance, header_message: header_message, footer_message: footer_message)
@@ -86,52 +86,52 @@ describe 'Display system header and footer bar' do
visit root_path
end
- it_behaves_like 'system header is configured'
- it_behaves_like 'system footer is configured'
+ it_behaves_like "system header is configured"
+ it_behaves_like "system footer is configured"
end
end
- context 'when not authenticated' do
- context 'when system header and footer are not configured' do
+ context "when not authenticated" do
+ context "when system header and footer are not configured" do
before do
visit root_path
end
- it_behaves_like 'system header is not configured'
- it_behaves_like 'system footer is not configured'
+ it_behaves_like "system header is not configured"
+ it_behaves_like "system footer is not configured"
end
- context 'when only system header is defined' do
+ context "when only system header is defined" do
before do
create(:appearance, header_message: header_message)
visit root_path
end
- it_behaves_like 'system header is configured'
- it_behaves_like 'system footer is not configured'
+ it_behaves_like "system header is configured"
+ it_behaves_like "system footer is not configured"
end
- context 'when only system footer is defined' do
+ context "when only system footer is defined" do
before do
create(:appearance, footer_message: footer_message)
visit root_path
end
- it_behaves_like 'system header is not configured'
- it_behaves_like 'system footer is configured'
+ it_behaves_like "system header is not configured"
+ it_behaves_like "system footer is configured"
end
- context 'when system header and footer are defined' do
+ context "when system header and footer are defined" do
before do
create(:appearance, header_message: header_message, footer_message: footer_message)
visit root_path
end
- it_behaves_like 'system header is configured'
- it_behaves_like 'system footer is configured'
+ it_behaves_like "system header is configured"
+ it_behaves_like "system footer is configured"
end
end
end
diff --git a/spec/features/error_pages_spec.rb b/spec/features/error_pages_spec.rb
index cd7bcf29cc9..ff0084cc997 100644
--- a/spec/features/error_pages_spec.rb
+++ b/spec/features/error_pages_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Error Pages' do
+describe "Error Pages" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
@@ -8,35 +8,35 @@ describe 'Error Pages' do
sign_in(user)
end
- shared_examples 'shows nav links' do
- it 'shows nav links' do
+ shared_examples "shows nav links" do
+ it "shows nav links" do
expect(page).to have_link("Home", href: root_path)
expect(page).to have_link("Help", href: help_path)
expect(page).to have_link(nil, href: destroy_user_session_path)
end
end
- describe '404' do
+ describe "404" do
before do
- visit '/not-a-real-page'
+ visit "/not-a-real-page"
end
- it 'allows user to search' do
- fill_in 'search', with: 'something'
- click_button 'Search'
+ it "allows user to search" do
+ fill_in "search", with: "something"
+ click_button "Search"
expect(page).to have_current_path(%r{^/search\?.*search=something.*})
end
- it_behaves_like 'shows nav links'
+ it_behaves_like "shows nav links"
end
- describe '403' do
+ describe "403" do
before do
- visit '/'
+ visit "/"
visit edit_project_path(project)
end
- it_behaves_like 'shows nav links'
+ it_behaves_like "shows nav links"
end
end
diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb
index 8d801161148..fa48e59683a 100644
--- a/spec/features/expand_collapse_diffs_spec.rb
+++ b/spec/features/expand_collapse_diffs_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Expand and collapse diffs', :js do
- let(:branch) { 'expand-collapse-diffs' }
+describe "Expand and collapse diffs", :js do
+ let(:branch) { "expand-collapse-diffs" }
let(:project) { create(:project, :repository) }
before do
@@ -15,7 +15,7 @@ describe 'Expand and collapse diffs', :js do
# Ensure that undiffable.md is in .gitattributes
project.repository.copy_gitattributes(branch)
visit project_commit_path(project, project.commit(branch))
- execute_script('window.ajaxUris = []; $(document).ajaxSend(function(event, xhr, settings) { ajaxUris.push(settings.url) });')
+ execute_script("window.ajaxUris = []; $(document).ajaxSend(function(event, xhr, settings) { ajaxUris.push(settings.url) });")
end
def file_container(filename)
@@ -26,281 +26,281 @@ describe 'Expand and collapse diffs', :js do
# reload.
#
files = [
- 'small_diff.md', 'large_diff.md', 'large_diff_renamed.md', 'undiffable.md',
- 'too_large.md', 'too_large_image.jpg'
+ "small_diff.md", "large_diff.md", "large_diff_renamed.md", "undiffable.md",
+ "too_large.md", "too_large_image.jpg",
]
files.each do |file|
- define_method(file.split('.').first) { file_container(file) }
+ define_method(file.split(".").first) { file_container(file) }
end
- it 'should show the diff content with a highlighted line when linking to line' do
- expect(large_diff).not_to have_selector('.code')
- expect(large_diff).to have_selector('.nothing-here-block')
+ it "should show the diff content with a highlighted line when linking to line" do
+ expect(large_diff).not_to have_selector(".code")
+ expect(large_diff).to have_selector(".nothing-here-block")
visit project_commit_path(project, project.commit(branch), anchor: "#{large_diff[:id]}_0_1")
- execute_script('window.location.reload()')
+ execute_script("window.location.reload()")
wait_for_requests
- expect(large_diff).to have_selector('.code')
- expect(large_diff).not_to have_selector('.nothing-here-block')
- expect(large_diff).to have_selector('.hll')
+ expect(large_diff).to have_selector(".code")
+ expect(large_diff).not_to have_selector(".nothing-here-block")
+ expect(large_diff).to have_selector(".hll")
end
- it 'should show the diff content when linking to file' do
- expect(large_diff).not_to have_selector('.code')
- expect(large_diff).to have_selector('.nothing-here-block')
+ it "should show the diff content when linking to file" do
+ expect(large_diff).not_to have_selector(".code")
+ expect(large_diff).to have_selector(".nothing-here-block")
visit project_commit_path(project, project.commit(branch), anchor: large_diff[:id])
- execute_script('window.location.reload()')
+ execute_script("window.location.reload()")
wait_for_requests
- expect(large_diff).to have_selector('.code')
- expect(large_diff).not_to have_selector('.nothing-here-block')
+ expect(large_diff).to have_selector(".code")
+ expect(large_diff).not_to have_selector(".nothing-here-block")
end
- context 'visiting a commit with collapsed diffs' do
- it 'shows small diffs immediately' do
- expect(small_diff).to have_selector('.code')
- expect(small_diff).not_to have_selector('.nothing-here-block')
+ context "visiting a commit with collapsed diffs" do
+ it "shows small diffs immediately" do
+ expect(small_diff).to have_selector(".code")
+ expect(small_diff).not_to have_selector(".nothing-here-block")
end
- it 'shows non-renderable diffs as such immediately, regardless of their size' do
- expect(undiffable).not_to have_selector('.code')
- expect(undiffable).to have_selector('.nothing-here-block')
- expect(undiffable).to have_content('gitattributes')
+ it "shows non-renderable diffs as such immediately, regardless of their size" do
+ expect(undiffable).not_to have_selector(".code")
+ expect(undiffable).to have_selector(".nothing-here-block")
+ expect(undiffable).to have_content("gitattributes")
end
- it 'does not allow diffs that are larger than the maximum size to be expanded' do
- expect(too_large).not_to have_selector('.code')
- expect(too_large).to have_selector('.nothing-here-block')
- expect(too_large).to have_content('too large')
+ it "does not allow diffs that are larger than the maximum size to be expanded" do
+ expect(too_large).not_to have_selector(".code")
+ expect(too_large).to have_selector(".nothing-here-block")
+ expect(too_large).to have_content("too large")
end
- it 'shows image diffs immediately, regardless of their size' do
- expect(too_large_image).not_to have_selector('.nothing-here-block')
- expect(too_large_image).to have_selector('.image')
+ it "shows image diffs immediately, regardless of their size" do
+ expect(too_large_image).not_to have_selector(".nothing-here-block")
+ expect(too_large_image).to have_selector(".image")
end
- context 'expanding a diff for a renamed file' do
+ context "expanding a diff for a renamed file" do
before do
- large_diff_renamed.find('.click-to-expand').click
+ large_diff_renamed.find(".click-to-expand").click
wait_for_requests
end
- it 'shows the old content' do
- old_line = large_diff_renamed.find('.line_content.old')
+ it "shows the old content" do
+ old_line = large_diff_renamed.find(".line_content.old")
- expect(old_line).to have_content('two copies')
+ expect(old_line).to have_content("two copies")
end
- it 'shows the new content' do
- new_line = large_diff_renamed.find('.line_content.new', match: :prefer_exact)
+ it "shows the new content" do
+ new_line = large_diff_renamed.find(".line_content.new", match: :prefer_exact)
- expect(new_line).to have_content('three copies')
+ expect(new_line).to have_content("three copies")
end
end
- context 'expanding a large diff' do
+ context "expanding a large diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `large_diff.md` title
- all('.diff-toggle-caret')[1].click
+ all(".diff-toggle-caret")[1].click
wait_for_requests
end
- it 'shows the diff content' do
- expect(large_diff).to have_selector('.code')
- expect(large_diff).not_to have_selector('.nothing-here-block')
+ it "shows the diff content" do
+ expect(large_diff).to have_selector(".code")
+ expect(large_diff).not_to have_selector(".nothing-here-block")
end
- context 'adding a comment to the expanded diff' do
- let(:comment_text) { 'A comment' }
+ context "adding a comment to the expanded diff" do
+ let(:comment_text) { "A comment" }
before do
- large_diff.find('.diff-line-num', match: :prefer_exact).hover
- large_diff.find('.add-diff-note', match: :prefer_exact).click
- large_diff.find('.note-textarea').send_keys comment_text
- large_diff.find_button('Comment').click
+ large_diff.find(".diff-line-num", match: :prefer_exact).hover
+ large_diff.find(".add-diff-note", match: :prefer_exact).click
+ large_diff.find(".note-textarea").send_keys comment_text
+ large_diff.find_button("Comment").click
wait_for_requests
end
- it 'adds the comment' do
- expect(large_diff.find('.notes')).to have_content comment_text
+ it "adds the comment" do
+ expect(large_diff.find(".notes")).to have_content comment_text
end
- context 'reloading the page' do
+ context "reloading the page" do
before do
refresh
end
- it 'collapses the large diff by default' do
- expect(large_diff).not_to have_selector('.code')
- expect(large_diff).to have_selector('.nothing-here-block')
+ it "collapses the large diff by default" do
+ expect(large_diff).not_to have_selector(".code")
+ expect(large_diff).to have_selector(".nothing-here-block")
end
- context 'expanding the diff' do
+ context "expanding the diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `large_diff.md` title
- all('.diff-toggle-caret')[1].click
+ all(".diff-toggle-caret")[1].click
wait_for_requests
end
- it 'shows the diff content' do
- expect(large_diff).to have_selector('.code')
- expect(large_diff).not_to have_selector('.nothing-here-block')
+ it "shows the diff content" do
+ expect(large_diff).to have_selector(".code")
+ expect(large_diff).not_to have_selector(".nothing-here-block")
end
- it 'shows the diff comment' do
- expect(large_diff.find('.notes')).to have_content comment_text
+ it "shows the diff comment" do
+ expect(large_diff.find(".notes")).to have_content comment_text
end
end
end
end
end
- context 'collapsing an expanded diff' do
+ context "collapsing an expanded diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `small_diff.md` title
- all('.diff-toggle-caret')[3].click
+ all(".diff-toggle-caret")[3].click
end
- it 'hides the diff content' do
- expect(small_diff).not_to have_selector('.code')
- expect(small_diff).to have_selector('.nothing-here-block')
+ it "hides the diff content" do
+ expect(small_diff).not_to have_selector(".code")
+ expect(small_diff).to have_selector(".nothing-here-block")
end
- context 're-expanding the same diff' do
+ context "re-expanding the same diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `small_diff.md` title
- all('.diff-toggle-caret')[3].click
+ all(".diff-toggle-caret")[3].click
end
- it 'shows the diff content' do
- expect(small_diff).to have_selector('.code')
- expect(small_diff).not_to have_selector('.nothing-here-block')
+ it "shows the diff content" do
+ expect(small_diff).to have_selector(".code")
+ expect(small_diff).not_to have_selector(".nothing-here-block")
end
- it 'does not make a new HTTP request' do
- expect(evaluate_script('ajaxUris')).not_to include(a_string_matching('small_diff.md'))
+ it "does not make a new HTTP request" do
+ expect(evaluate_script("ajaxUris")).not_to include(a_string_matching("small_diff.md"))
end
end
end
- context 'expanding a diff when symlink was converted to a regular file' do
- let(:branch) { 'symlink-expand-diff' }
+ context "expanding a diff when symlink was converted to a regular file" do
+ let(:branch) { "symlink-expand-diff" }
- it 'shows the content of the regular file' do
- expect(page).to have_content('This diff is collapsed')
- expect(page).to have_no_content('No longer a symlink')
+ it "shows the content of the regular file" do
+ expect(page).to have_content("This diff is collapsed")
+ expect(page).to have_no_content("No longer a symlink")
- find('.click-to-expand').click
+ find(".click-to-expand").click
wait_for_requests
- expect(page).to have_content('No longer a symlink')
+ expect(page).to have_content("No longer a symlink")
end
end
end
- context 'visiting a commit without collapsed diffs' do
- let(:branch) { 'feature' }
+ context "visiting a commit without collapsed diffs" do
+ let(:branch) { "feature" }
- it 'does not show Expand all button' do
- expect(page).not_to have_link('Expand all')
+ it "does not show Expand all button" do
+ expect(page).not_to have_link("Expand all")
end
end
- context 'visiting a commit with more than safe files' do
- let(:branch) { 'expand-collapse-files' }
+ context "visiting a commit with more than safe files" do
+ let(:branch) { "expand-collapse-files" }
# safe-files -> 100 | safe-lines -> 5000 | commit-files -> 105
- it 'does collapsing from the safe number of files to the end on small files' do
- expect(page).to have_link('Expand all')
+ it "does collapsing from the safe number of files to the end on small files" do
+ expect(page).to have_link("Expand all")
- expect(page).to have_selector('.diff-content', count: 105)
- expect(page).to have_selector('.diff-collapsed', count: 5)
+ expect(page).to have_selector(".diff-content", count: 105)
+ expect(page).to have_selector(".diff-collapsed", count: 5)
- %w(file-95.txt file-96.txt file-97.txt file-98.txt file-99.txt).each do |filename|
- expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector('.diff-collapsed')
+ %w[file-95.txt file-96.txt file-97.txt file-98.txt file-99.txt].each do |filename|
+ expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector(".diff-collapsed")
end
end
end
- context 'visiting a commit with more than safe lines' do
- let(:branch) { 'expand-collapse-lines' }
+ context "visiting a commit with more than safe lines" do
+ let(:branch) { "expand-collapse-lines" }
# safe-files -> 100 | safe-lines -> 5000 | commit_files -> 8 (each 1250 lines)
- it 'does collapsing from the safe number of lines to the end' do
- expect(page).to have_link('Expand all')
+ it "does collapsing from the safe number of lines to the end" do
+ expect(page).to have_link("Expand all")
- expect(page).to have_selector('.diff-content', count: 6)
- expect(page).to have_selector('.diff-collapsed', count: 2)
+ expect(page).to have_selector(".diff-content", count: 6)
+ expect(page).to have_selector(".diff-collapsed", count: 2)
- %w(file-4.txt file-5.txt).each do |filename|
- expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector('.diff-collapsed')
+ %w[file-4.txt file-5.txt].each do |filename|
+ expect(find("[data-blob-diff-path*='#{filename}']")).to have_selector(".diff-collapsed")
end
end
end
- context 'expanding all diffs' do
+ context "expanding all diffs" do
before do
- click_link('Expand all')
+ click_link("Expand all")
# Wait for elements to appear to ensure full page reload
- expect(page).to have_content('This diff was suppressed by a .gitattributes entry')
- expect(page).to have_content('This source diff could not be displayed because it is too large.')
- expect(page).to have_content('too_large_image.jpg')
- find('.note-textarea')
+ expect(page).to have_content("This diff was suppressed by a .gitattributes entry")
+ expect(page).to have_content("This source diff could not be displayed because it is too large.")
+ expect(page).to have_content("too_large_image.jpg")
+ find(".note-textarea")
wait_for_requests
- execute_script('window.ajaxUris = []; $(document).ajaxSend(function(event, xhr, settings) { ajaxUris.push(settings.url) });')
+ execute_script("window.ajaxUris = []; $(document).ajaxSend(function(event, xhr, settings) { ajaxUris.push(settings.url) });")
end
- it 'reloads the page with all diffs expanded' do
- expect(small_diff).to have_selector('.code')
- expect(small_diff).not_to have_selector('.nothing-here-block')
+ it "reloads the page with all diffs expanded" do
+ expect(small_diff).to have_selector(".code")
+ expect(small_diff).not_to have_selector(".nothing-here-block")
- expect(large_diff).to have_selector('.code')
- expect(large_diff).not_to have_selector('.nothing-here-block')
+ expect(large_diff).to have_selector(".code")
+ expect(large_diff).not_to have_selector(".nothing-here-block")
end
- context 'collapsing an expanded diff' do
+ context "collapsing an expanded diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `small_diff.md` title
- all('.diff-toggle-caret')[3].click
+ all(".diff-toggle-caret")[3].click
end
- it 'hides the diff content' do
- expect(small_diff).not_to have_selector('.code')
- expect(small_diff).to have_selector('.nothing-here-block')
+ it "hides the diff content" do
+ expect(small_diff).not_to have_selector(".code")
+ expect(small_diff).to have_selector(".nothing-here-block")
end
- context 're-expanding the same diff' do
+ context "re-expanding the same diff" do
before do
# Wait for diffs
- find('.js-file-title', match: :first)
+ find(".js-file-title", match: :first)
# Click `small_diff.md` title
- all('.diff-toggle-caret')[3].click
+ all(".diff-toggle-caret")[3].click
end
- it 'shows the diff content' do
- expect(small_diff).to have_selector('.code')
- expect(small_diff).not_to have_selector('.nothing-here-block')
+ it "shows the diff content" do
+ expect(small_diff).to have_selector(".code")
+ expect(small_diff).not_to have_selector(".nothing-here-block")
end
- it 'does not make a new HTTP request' do
- expect(evaluate_script('ajaxUris')).not_to include(a_string_matching('small_diff.md'))
+ it "does not make a new HTTP request" do
+ expect(evaluate_script("ajaxUris")).not_to include(a_string_matching("small_diff.md"))
end
end
end
diff --git a/spec/features/explore/groups_list_spec.rb b/spec/features/explore/groups_list_spec.rb
index 8ed4051856e..dc0b9d06db8 100644
--- a/spec/features/explore/groups_list_spec.rb
+++ b/spec/features/explore/groups_list_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Explore Groups page', :js do
+describe "Explore Groups page", :js do
let!(:user) { create :user }
let!(:group) { create(:group) }
let!(:public_group) { create(:group, :public) }
@@ -16,14 +16,14 @@ describe 'Explore Groups page', :js do
wait_for_requests
end
- it 'shows groups user is member of' do
+ it "shows groups user is member of" do
expect(page).to have_content(group.full_name)
expect(page).to have_content(public_group.full_name)
expect(page).not_to have_content(private_group.full_name)
end
- it 'filters groups' do
- fill_in 'filter', with: group.name
+ it "filters groups" do
+ fill_in "filter", with: group.name
wait_for_requests
expect(page).to have_content(group.full_name)
@@ -31,59 +31,59 @@ describe 'Explore Groups page', :js do
expect(page).not_to have_content(private_group.full_name)
end
- it 'resets search when user cleans the input' do
- fill_in 'filter', with: group.name
+ it "resets search when user cleans the input" do
+ fill_in "filter", with: group.name
wait_for_requests
expect(page).to have_content(group.full_name)
expect(page).not_to have_content(public_group.full_name)
- fill_in 'filter', with: ""
+ fill_in "filter", with: ""
page.find('[name="filter"]').send_keys(:enter)
wait_for_requests
expect(page).to have_content(group.full_name)
expect(page).to have_content(public_group.full_name)
expect(page).not_to have_content(private_group.full_name)
- expect(page.all('.js-groups-list-holder .content-list li').length).to eq 2
+ expect(page.all(".js-groups-list-holder .content-list li").length).to eq 2
end
- it 'shows non-archived projects count' do
+ it "shows non-archived projects count" do
# Initially project is not archived
- expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("1")
+ expect(find(".js-groups-list-holder .content-list li:first-child .stats .number-projects")).to have_text("1")
# Archive project
::Projects::UpdateService.new(empty_project, user, archived: true).execute
visit explore_groups_path
# Check project count
- expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("0")
+ expect(find(".js-groups-list-holder .content-list li:first-child .stats .number-projects")).to have_text("0")
# Unarchive project
::Projects::UpdateService.new(empty_project, user, archived: false).execute
visit explore_groups_path
# Check project count
- expect(find('.js-groups-list-holder .content-list li:first-child .stats .number-projects')).to have_text("1")
+ expect(find(".js-groups-list-holder .content-list li:first-child .stats .number-projects")).to have_text("1")
end
- describe 'landing component' do
- it 'should show a landing component' do
- expect(page).to have_content('Below you will find all the groups that are public.')
+ describe "landing component" do
+ it "should show a landing component" do
+ expect(page).to have_content("Below you will find all the groups that are public.")
end
- it 'should be dismissable' do
- find('.dismiss-button').click
+ it "should be dismissable" do
+ find(".dismiss-button").click
- expect(page).not_to have_content('Below you will find all the groups that are public.')
+ expect(page).not_to have_content("Below you will find all the groups that are public.")
end
- it 'should persistently not show once dismissed' do
- find('.dismiss-button').click
+ it "should persistently not show once dismissed" do
+ find(".dismiss-button").click
visit explore_groups_path
- expect(page).not_to have_content('Below you will find all the groups that are public.')
+ expect(page).not_to have_content("Below you will find all the groups that are public.")
end
end
end
diff --git a/spec/features/explore/groups_spec.rb b/spec/features/explore/groups_spec.rb
index e4ef47d88dd..d81c774a768 100644
--- a/spec/features/explore/groups_spec.rb
+++ b/spec/features/explore/groups_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Explore Groups', :js do
+describe "Explore Groups", :js do
let(:user) { create :user }
let(:group) { create :group }
let!(:private_project) do
@@ -24,7 +24,7 @@ describe 'Explore Groups', :js do
end
end
- shared_examples 'renders public and internal projects' do
+ shared_examples "renders public and internal projects" do
it do
visit_page
expect(page).to have_content(public_project.name)
@@ -33,7 +33,7 @@ describe 'Explore Groups', :js do
end
end
- shared_examples 'renders only public project' do
+ shared_examples "renders only public project" do
it do
visit_page
expect(page).to have_content(public_project.name)
@@ -42,46 +42,46 @@ describe 'Explore Groups', :js do
end
end
- shared_examples 'renders group in public groups area' do
+ shared_examples "renders group in public groups area" do
it do
visit explore_groups_path
expect(page).to have_content(group.name)
end
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it_behaves_like 'renders public and internal projects' do
+ it_behaves_like "renders public and internal projects" do
subject(:visit_page) { visit group_path(group) }
end
- it_behaves_like 'renders public and internal projects' do
+ it_behaves_like "renders public and internal projects" do
subject(:visit_page) { visit issues_group_path(group) }
end
- it_behaves_like 'renders public and internal projects' do
+ it_behaves_like "renders public and internal projects" do
subject(:visit_page) { visit merge_requests_group_path(group) }
end
- it_behaves_like 'renders group in public groups area'
+ it_behaves_like "renders group in public groups area"
end
- context 'when signed out' do
- it_behaves_like 'renders only public project' do
+ context "when signed out" do
+ it_behaves_like "renders only public project" do
subject(:visit_page) { visit group_path(group) }
end
- it_behaves_like 'renders only public project' do
+ it_behaves_like "renders only public project" do
subject(:visit_page) { visit issues_group_path(group) }
end
- it_behaves_like 'renders only public project' do
+ it_behaves_like "renders only public project" do
subject(:visit_page) { visit merge_requests_group_path(group) }
end
- it_behaves_like 'renders group in public groups area'
+ it_behaves_like "renders group in public groups area"
end
end
diff --git a/spec/features/explore/user_explores_projects_spec.rb b/spec/features/explore/user_explores_projects_spec.rb
index c724c3d17f8..d574c04c4c0 100644
--- a/spec/features/explore/user_explores_projects_spec.rb
+++ b/spec/features/explore/user_explores_projects_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User explores projects' do
+describe "User explores projects" do
set(:archived_project) { create(:project, :archived) }
set(:internal_project) { create(:project, :internal) }
set(:private_project) { create(:project, :private) }
set(:public_project) { create(:project, :public) }
- context 'when not signed in' do
- context 'when viewing public projects' do
+ context "when not signed in" do
+ context "when viewing public projects" do
before do
visit(explore_projects_path)
end
- include_examples 'shows public projects'
+ include_examples "shows public projects"
end
end
- context 'when signed in' do
+ context "when signed in" do
set(:user) { create(:user) }
before do
sign_in(user)
end
- context 'when viewing public projects' do
+ context "when viewing public projects" do
before do
visit(explore_projects_path)
end
- include_examples 'shows public and internal projects'
+ include_examples "shows public and internal projects"
end
- context 'when viewing most starred projects' do
+ context "when viewing most starred projects" do
before do
visit(starred_explore_projects_path)
end
- include_examples 'shows public and internal projects'
+ include_examples "shows public and internal projects"
end
- context 'when viewing trending projects' do
+ context "when viewing trending projects" do
before do
[archived_project, public_project].each { |project| create(:note_on_issue, project: project) }
@@ -48,7 +48,7 @@ describe 'User explores projects' do
visit(trending_explore_projects_path)
end
- include_examples 'shows public projects'
+ include_examples "shows public projects"
end
end
end
diff --git a/spec/features/global_search_spec.rb b/spec/features/global_search_spec.rb
index d7692181453..7927dc067e5 100644
--- a/spec/features/global_search_spec.rb
+++ b/spec/features/global_search_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Global search' do
+describe "Global search" do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -9,10 +9,10 @@ describe 'Global search' do
sign_in(user)
end
- describe 'I search through the issues and I see pagination' do
+ describe "I search through the issues and I see pagination" do
before do
allow_any_instance_of(Gitlab::SearchResults).to receive(:per_page).and_return(1)
- create_list(:issue, 2, project: project, title: 'initial')
+ create_list(:issue, 2, project: project, title: "initial")
end
it "has a pagination" do
@@ -22,7 +22,7 @@ describe 'Global search' do
click_button "Go"
select_filter("Issues")
- expect(page).to have_selector('.gl-pagination .next')
+ expect(page).to have_selector(".gl-pagination .next")
end
end
end
diff --git a/spec/features/group_variables_spec.rb b/spec/features/group_variables_spec.rb
index 1a53e7c9512..96e29157fee 100644
--- a/spec/features/group_variables_spec.rb
+++ b/spec/features/group_variables_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group variables', :js do
+describe "Group variables", :js do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let!(:variable) { create(:ci_group_variable, key: 'test_key', value: 'test_value', group: group) }
+ let!(:variable) { create(:ci_group_variable, key: "test_key", value: "test_value", group: group) }
let(:page_path) { group_settings_ci_cd_path(group) }
before do
@@ -13,5 +13,5 @@ describe 'Group variables', :js do
visit page_path
end
- it_behaves_like 'variable list'
+ it_behaves_like "variable list"
end
diff --git a/spec/features/groups/activity_spec.rb b/spec/features/groups/activity_spec.rb
index 88fc12ae1e4..0d76257b265 100644
--- a/spec/features/groups/activity_spec.rb
+++ b/spec/features/groups/activity_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group activity page' do
- let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user }
+describe "Group activity page" do
+ let(:user) { create(:group_member, :developer, user: create(:user), group: group).user }
let(:group) { create(:group) }
let(:path) { activity_group_path(group) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- describe 'RSS' do
+ describe "RSS" do
before do
visit path
end
@@ -19,7 +19,7 @@ describe 'Group activity page' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when project is in the group', :js do
+ context "when project is in the group", :js do
let(:project) { create(:project, :public, namespace: group) }
before do
@@ -28,13 +28,13 @@ describe 'Group activity page' do
visit path
end
- it 'renders user joined to project event' do
- expect(page).to have_content 'joined project'
+ it "renders user joined to project event" do
+ expect(page).to have_content "joined project"
end
end
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/groups/board_sidebar_spec.rb b/spec/features/groups/board_sidebar_spec.rb
index 9f597efa7b7..b8ff449d7a7 100644
--- a/spec/features/groups/board_sidebar_spec.rb
+++ b/spec/features/groups/board_sidebar_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'Group Issue Boards', :js do
+describe "Group Issue Boards", :js do
include BoardHelpers
let(:group) { create(:group) }
- let(:user) { create(:group_member, user: create(:user), group: group ).user }
+ let(:user) { create(:group_member, user: create(:user), group: group).user }
let!(:project_1) { create(:project, :public, group: group) }
let!(:project_2) { create(:project, :public, group: group) }
- let!(:project_1_label) { create(:label, project: project_1, name: 'Development 1') }
- let!(:project_2_label) { create(:label, project: project_2, name: 'Development 2') }
- let!(:group_label) { create(:group_label, title: 'Bug', description: 'Fusce consequat', group: group) }
+ let!(:project_1_label) { create(:label, project: project_1, name: "Development 1") }
+ let!(:project_2_label) { create(:label, project: project_2, name: "Development 2") }
+ let!(:group_label) { create(:group_label, title: "Bug", description: "Fusce consequat", group: group) }
let!(:issue_1) { create(:labeled_issue, project: project_1, relative_position: 1) }
let!(:issue_2) { create(:labeled_issue, project: project_2, relative_position: 2) }
let(:board) { create(:board, group: group) }
let!(:list) { create(:list, board: board, label: project_1_label, position: 0) }
- let(:card) { find('.board:nth-child(1)').first('.board-card') }
+ let(:card) { find(".board:nth-child(1)").first(".board-card") }
before do
sign_in(user)
@@ -25,16 +25,16 @@ describe 'Group Issue Boards', :js do
wait_for_requests
end
- context 'labels' do
- it 'only shows valid labels for the issue project and group' do
+ context "labels" do
+ it "only shows valid labels for the issue project and group" do
click_card(card)
- page.within('.labels') do
- click_link 'Edit'
+ page.within(".labels") do
+ click_link "Edit"
wait_for_requests
- page.within('.selectbox') do
+ page.within(".selectbox") do
expect(page).to have_content(project_1_label.title)
expect(page).to have_content(group_label.title)
expect(page).not_to have_content(project_2_label.title)
diff --git a/spec/features/groups/board_spec.rb b/spec/features/groups/board_spec.rb
index 86a4a016f3d..1c843a36bf7 100644
--- a/spec/features/groups/board_spec.rb
+++ b/spec/features/groups/board_spec.rb
@@ -1,32 +1,32 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Group Boards' do
+describe "Group Boards" do
let(:group) { create(:group) }
let!(:project) { create(:project_empty_repo, group: group) }
- let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
+ let(:user) { create(:group_member, :maintainer, user: create(:user), group: group).user }
before do
sign_in(user)
end
- context 'Creates a an issue', :js do
+ context "Creates a an issue", :js do
before do
visit group_boards_path(group)
end
- it 'Adds an issue to the backlog' do
- page.within(find('.board', match: :first)) do
- issue_title = 'New Issue'
- find(:css, '.issue-count-badge-add-button').click
- expect(find('.board-new-issue-form')).to be_visible
+ it "Adds an issue to the backlog" do
+ page.within(find(".board", match: :first)) do
+ issue_title = "New Issue"
+ find(:css, ".issue-count-badge-add-button").click
+ expect(find(".board-new-issue-form")).to be_visible
- fill_in 'issue_title', with: issue_title
- find('.dropdown-menu-toggle').click
+ fill_in "issue_title", with: issue_title
+ find(".dropdown-menu-toggle").click
wait_for_requests
click_link(project.name)
- click_button 'Submit issue'
+ click_button "Submit issue"
expect(page).to have_content(issue_title)
end
diff --git a/spec/features/groups/clusters/user_spec.rb b/spec/features/groups/clusters/user_spec.rb
index 2410cd92e3f..400ba6a96f7 100644
--- a/spec/features/groups/clusters/user_spec.rb
+++ b/spec/features/groups/clusters/user_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'User Cluster', :js do
+describe "User Cluster", :js do
include GoogleApi::CloudPlatformHelpers
let(:group) { create(:group) }
@@ -16,110 +16,110 @@ describe 'User Cluster', :js do
allow_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute)
end
- context 'when user does not have a cluster and visits cluster index page' do
+ context "when user does not have a cluster and visits cluster index page" do
before do
visit group_clusters_path(group)
- click_link 'Add Kubernetes cluster'
- click_link 'Add existing cluster'
+ click_link "Add Kubernetes cluster"
+ click_link "Add existing cluster"
end
- context 'when user filled form with valid parameters' do
- shared_examples 'valid cluster user form' do
- it 'user sees a cluster details page' do
+ context "when user filled form with valid parameters" do
+ shared_examples "valid cluster user form" do
+ it "user sees a cluster details page" do
subject
- expect(page).to have_content('Kubernetes cluster integration')
- expect(page.find_field('cluster[name]').value).to eq('dev-cluster')
- expect(page.find_field('cluster[platform_kubernetes_attributes][api_url]').value)
- .to have_content('http://example.com')
- expect(page.find_field('cluster[platform_kubernetes_attributes][token]').value)
- .to have_content('my-token')
+ expect(page).to have_content("Kubernetes cluster integration")
+ expect(page.find_field("cluster[name]").value).to eq("dev-cluster")
+ expect(page.find_field("cluster[platform_kubernetes_attributes][api_url]").value)
+ .to have_content("http://example.com")
+ expect(page.find_field("cluster[platform_kubernetes_attributes][token]").value)
+ .to have_content("my-token")
end
end
before do
- fill_in 'cluster_name', with: 'dev-cluster'
- fill_in 'cluster_platform_kubernetes_attributes_api_url', with: 'http://example.com'
- fill_in 'cluster_platform_kubernetes_attributes_token', with: 'my-token'
+ fill_in "cluster_name", with: "dev-cluster"
+ fill_in "cluster_platform_kubernetes_attributes_api_url", with: "http://example.com"
+ fill_in "cluster_platform_kubernetes_attributes_token", with: "my-token"
end
- subject { click_button 'Add Kubernetes cluster' }
+ subject { click_button "Add Kubernetes cluster" }
- it_behaves_like 'valid cluster user form'
+ it_behaves_like "valid cluster user form"
- context 'RBAC is enabled for the cluster' do
+ context "RBAC is enabled for the cluster" do
before do
- check 'cluster_platform_kubernetes_attributes_authorization_type'
+ check "cluster_platform_kubernetes_attributes_authorization_type"
end
- it_behaves_like 'valid cluster user form'
+ it_behaves_like "valid cluster user form"
- it 'user sees a cluster details page with RBAC enabled' do
+ it "user sees a cluster details page with RBAC enabled" do
subject
- expect(page.find_field('cluster[platform_kubernetes_attributes][authorization_type]', disabled: true)).to be_checked
+ expect(page.find_field("cluster[platform_kubernetes_attributes][authorization_type]", disabled: true)).to be_checked
end
end
end
- context 'when user filled form with invalid parameters' do
+ context "when user filled form with invalid parameters" do
before do
- click_button 'Add Kubernetes cluster'
+ click_button "Add Kubernetes cluster"
end
- it 'user sees a validation error' do
- expect(page).to have_css('#error_explanation')
+ it "user sees a validation error" do
+ expect(page).to have_css("#error_explanation")
end
end
end
- context 'when user does have a cluster and visits cluster page' do
+ context "when user does have a cluster and visits cluster page" do
let(:cluster) { create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [group]) }
before do
visit group_cluster_path(group, cluster)
end
- it 'user sees a cluster details page' do
- expect(page).to have_button('Save changes')
+ it "user sees a cluster details page" do
+ expect(page).to have_button("Save changes")
end
- context 'when user disables the cluster' do
+ context "when user disables the cluster" do
before do
- page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
- page.within('#cluster-integration') { click_button 'Save changes' }
+ page.find(:css, ".js-cluster-enable-toggle-area .js-project-feature-toggle").click
+ page.within("#cluster-integration") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
end
end
- context 'when user changes cluster parameters' do
+ context "when user changes cluster parameters" do
before do
- fill_in 'cluster_name', with: 'my-dev-cluster'
- fill_in 'cluster_platform_kubernetes_attributes_token', with: 'new-token'
- page.within('#js-cluster-details') { click_button 'Save changes' }
+ fill_in "cluster_name", with: "my-dev-cluster"
+ fill_in "cluster_platform_kubernetes_attributes_token", with: "new-token"
+ page.within("#js-cluster-details") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
- expect(cluster.reload.name).to eq('my-dev-cluster')
- expect(cluster.reload.platform_kubernetes.token).to eq('new-token')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
+ expect(cluster.reload.name).to eq("my-dev-cluster")
+ expect(cluster.reload.platform_kubernetes.token).to eq("new-token")
end
end
- context 'when user destroy the cluster' do
+ context "when user destroy the cluster" do
before do
page.accept_confirm do
- click_link 'Remove integration'
+ click_link "Remove integration"
end
end
- it 'user sees creation form with the successful message' do
- expect(page).to have_content('Kubernetes cluster integration was successfully removed.')
- expect(page).to have_link('Add Kubernetes cluster')
+ it "user sees creation form with the successful message" do
+ expect(page).to have_content("Kubernetes cluster integration was successfully removed.")
+ expect(page).to have_link("Add Kubernetes cluster")
end
end
end
diff --git a/spec/features/groups/empty_states_spec.rb b/spec/features/groups/empty_states_spec.rb
index e4eb0d355d1..96f3d2af229 100644
--- a/spec/features/groups/empty_states_spec.rb
+++ b/spec/features/groups/empty_states_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group empty states' do
+describe "Group empty states" do
let(:group) { create(:group) }
- let(:user) { create(:group_member, :developer, user: create(:user), group: group ).user }
+ let(:user) { create(:group_member, :developer, user: create(:user), group: group).user }
before do
sign_in(user)
@@ -15,7 +15,7 @@ describe 'Group empty states' do
context "for #{issuable_name}s" do
let(:path) { public_send(:"#{issuable}s_group_path", group) }
- context 'group has a project' do
+ context "group has a project" do
let(:project) { create(:project, namespace: group) }
before do
@@ -23,11 +23,11 @@ describe 'Group empty states' do
end
context "the project has #{issuable_name}s" do
- it 'does not display an empty state' do
+ it "does not display an empty state" do
create(issuable, project_relation => project)
visit path
- expect(page).not_to have_selector('.empty-state')
+ expect(page).not_to have_selector(".empty-state")
end
it "displays link to create new #{issuable} when no open #{issuable} is found" do
@@ -36,22 +36,22 @@ describe 'Group empty states' do
visit public_send(issuable_link_fn, project)
- page.within(find('.empty-state')) do
+ page.within(find(".empty-state")) do
expect(page).to have_content(/There are no open #{issuable.to_s.humanize.downcase}/)
expect(page).to have_selector("#new_#{issuable}_body_link")
end
end
- it 'displays link to create new issue when the current search gave no results' do
+ it "displays link to create new issue when the current search gave no results" do
create(issuable, project_relation => project)
issuable_link_fn = "project_#{issuable}s_path"
- visit public_send(issuable_link_fn, project, author_username: 'foo', scope: 'all', state: 'opened')
+ visit public_send(issuable_link_fn, project, author_username: "foo", scope: "all", state: "opened")
- page.within(find('.empty-state')) do
+ page.within(find(".empty-state")) do
expect(page).to have_content(/Sorry, your filter produced no results/)
- new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path'
+ new_issuable_path = issuable == :issue ? "new_project_issue_path" : "project_new_merge_request_path"
path = public_send(new_issuable_path, project)
@@ -64,9 +64,9 @@ describe 'Group empty states' do
issuable_link_fn = "project_#{issuable}s_path"
- visit public_send(issuable_link_fn, project, state: 'closed')
+ visit public_send(issuable_link_fn, project, state: "closed")
- page.within(find('.empty-state')) do
+ page.within(find(".empty-state")) do
expect(page).to have_content(/There are no closed #{issuable.to_s.humanize.downcase}/)
end
end
@@ -77,40 +77,40 @@ describe 'Group empty states' do
visit path
end
- it 'displays an empty state' do
- expect(page).to have_selector('.empty-state')
+ it "displays an empty state" do
+ expect(page).to have_selector(".empty-state")
end
it "shows a new #{issuable_name} button" do
- within '.empty-state' do
+ within ".empty-state" do
expect(page).to have_content("create #{issuable_name}")
end
end
it "the new #{issuable_name} button opens a project dropdown" do
- within '.empty-state' do
- find('.new-project-item-select-button').click
+ within ".empty-state" do
+ find(".new-project-item-select-button").click
end
- expect(page).to have_selector('.ajax-project-dropdown')
+ expect(page).to have_selector(".ajax-project-dropdown")
end
end
end
shared_examples "no projects" do
- it 'displays an empty state' do
- expect(page).to have_selector('.empty-state')
+ it "displays an empty state" do
+ expect(page).to have_selector(".empty-state")
end
it "does not show a new #{issuable_name} button" do
- within '.empty-state' do
+ within ".empty-state" do
expect(page).not_to have_link("create #{issuable_name}")
end
end
end
- context 'group without a project' do
- context 'group has a subgroup', :nested_groups do
+ context "group without a project" do
+ context "group has a subgroup", :nested_groups do
let(:subgroup) { create(:group, parent: group) }
let(:subgroup_project) { create(:project, namespace: subgroup) }
@@ -121,8 +121,8 @@ describe 'Group empty states' do
visit path
end
- it 'does not display an empty state' do
- expect(page).not_to have_selector('.empty-state')
+ it "does not display an empty state" do
+ expect(page).not_to have_selector(".empty-state")
end
end
@@ -131,13 +131,13 @@ describe 'Group empty states' do
visit path
end
- it 'displays an empty state' do
- expect(page).to have_selector('.empty-state')
+ it "displays an empty state" do
+ expect(page).to have_selector(".empty-state")
end
end
end
- context 'group has no subgroups' do
+ context "group has no subgroups" do
before do
visit path
end
@@ -146,7 +146,7 @@ describe 'Group empty states' do
end
end
- context 'group has only a project with issues disabled' do
+ context "group has only a project with issues disabled" do
let(:project_with_issues_disabled) { create(:empty_project, :issues_disabled, group: group) }
before do
diff --git a/spec/features/groups/group_settings_spec.rb b/spec/features/groups/group_settings_spec.rb
index 378e4d5febc..b123f9b4d2c 100644
--- a/spec/features/groups/group_settings_spec.rb
+++ b/spec/features/groups/group_settings_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Edit group settings' do
+describe "Edit group settings" do
let(:user) { create(:user) }
- let(:group) { create(:group, path: 'foo') }
+ let(:group) { create(:group, path: "foo") }
before do
group.add_owner(user)
sign_in(user)
end
- describe 'when the group path is changed' do
- let(:new_group_path) { 'bar' }
+ describe "when the group path is changed" do
+ let(:new_group_path) { "bar" }
let(:old_group_full_path) { "/#{group.path}" }
let(:new_group_full_path) { "/#{new_group_path}" }
- it 'the group is accessible via the new path' do
+ it "the group is accessible via the new path" do
update_path(new_group_path)
visit new_group_full_path
expect(current_path).to eq(new_group_full_path)
- expect(find('h1.home-panel-title')).to have_content(group.name)
+ expect(find("h1.home-panel-title")).to have_content(group.name)
end
- it 'the old group path redirects to the new path' do
+ it "the old group path redirects to the new path" do
update_path(new_group_path)
visit old_group_full_path
expect(current_path).to eq(new_group_full_path)
- expect(find('h1.home-panel-title')).to have_content(group.name)
+ expect(find("h1.home-panel-title")).to have_content(group.name)
end
- context 'with a subgroup' do
- let!(:subgroup) { create(:group, parent: group, path: 'subgroup') }
+ context "with a subgroup" do
+ let!(:subgroup) { create(:group, parent: group, path: "subgroup") }
let(:old_subgroup_full_path) { "/#{group.path}/#{subgroup.path}" }
let(:new_subgroup_full_path) { "/#{new_group_path}/#{subgroup.path}" }
- it 'the subgroup is accessible via the new path' do
+ it "the subgroup is accessible via the new path" do
update_path(new_group_path)
visit new_subgroup_full_path
expect(current_path).to eq(new_subgroup_full_path)
- expect(find('h1.home-panel-title')).to have_content(subgroup.name)
+ expect(find("h1.home-panel-title")).to have_content(subgroup.name)
end
- it 'the old subgroup path redirects to the new path' do
+ it "the old subgroup path redirects to the new path" do
update_path(new_group_path)
visit old_subgroup_full_path
expect(current_path).to eq(new_subgroup_full_path)
- expect(find('h1.home-panel-title')).to have_content(subgroup.name)
+ expect(find("h1.home-panel-title")).to have_content(subgroup.name)
end
end
- context 'with a project' do
+ context "with a project" do
let!(:project) { create(:project, group: group) }
let(:old_project_full_path) { "/#{group.path}/#{project.path}" }
let(:new_project_full_path) { "/#{new_group_path}/#{project.path}" }
@@ -61,71 +61,71 @@ describe 'Edit group settings' do
TestEnv.clean_test_path
end
- it 'the project is accessible via the new path' do
+ it "the project is accessible via the new path" do
update_path(new_group_path)
visit new_project_full_path
expect(current_path).to eq(new_project_full_path)
- expect(find('.breadcrumbs')).to have_content(project.path)
+ expect(find(".breadcrumbs")).to have_content(project.path)
end
- it 'the old project path redirects to the new path' do
+ it "the old project path redirects to the new path" do
update_path(new_group_path)
visit old_project_full_path
expect(current_path).to eq(new_project_full_path)
- expect(find('.breadcrumbs')).to have_content(project.path)
+ expect(find(".breadcrumbs")).to have_content(project.path)
end
end
end
- describe 'edit group avatar' do
+ describe "edit group avatar" do
before do
visit edit_group_path(group)
- attach_file(:group_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
+ attach_file(:group_avatar, Rails.root.join("spec", "fixtures", "banana_sample.gif"))
expect { save_group }.to change { group.reload.avatar? }.to(true)
end
- it 'uploads new group avatar' do
+ it "uploads new group avatar" do
expect(group.avatar).to be_instance_of AvatarUploader
expect(group.avatar.url).to eq "/uploads/-/system/group/avatar/#{group.id}/banana_sample.gif"
- expect(page).to have_link('Remove avatar')
+ expect(page).to have_link("Remove avatar")
end
- it 'removes group avatar' do
- expect { click_link 'Remove avatar' }.to change { group.reload.avatar? }.to(false)
- expect(page).not_to have_link('Remove avatar')
+ it "removes group avatar" do
+ expect { click_link "Remove avatar" }.to change { group.reload.avatar? }.to(false)
+ expect(page).not_to have_link("Remove avatar")
end
end
- describe 'edit group path' do
- it 'has a root URL label for top-level group' do
+ describe "edit group path" do
+ it "has a root URL label for top-level group" do
visit edit_group_path(group)
- expect(find(:css, '.group-root-path').text).to eq(root_url)
+ expect(find(:css, ".group-root-path").text).to eq(root_url)
end
- it 'has a parent group URL label for a subgroup group', :postgresql do
+ it "has a parent group URL label for a subgroup group", :postgresql do
subgroup = create(:group, parent: group)
visit edit_group_path(subgroup)
- expect(find(:css, '.group-root-path').text).to eq(group_url(subgroup.parent) + '/')
+ expect(find(:css, ".group-root-path").text).to eq(group_url(subgroup.parent) + "/")
end
end
def update_path(new_group_path)
visit edit_group_path(group)
- page.within('.gs-advanced') do
- fill_in 'group_path', with: new_group_path
- click_button 'Change group path'
+ page.within(".gs-advanced") do
+ fill_in "group_path", with: new_group_path
+ click_button "Change group path"
end
end
def save_group
- page.within('.gs-general') do
- click_button 'Save changes'
+ page.within(".gs-general") do
+ click_button "Save changes"
end
end
end
diff --git a/spec/features/groups/issues_spec.rb b/spec/features/groups/issues_spec.rb
index 176f4a668ff..3bf76ce9eb1 100644
--- a/spec/features/groups/issues_spec.rb
+++ b/spec/features/groups/issues_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group issues page' do
+describe "Group issues page" do
include FilteredSearchHelpers
let(:group) { create(:group) }
@@ -8,15 +8,15 @@ describe 'Group issues page' do
let(:project_with_issues_disabled) { create(:project, :issues_disabled, group: group) }
let(:path) { issues_group_path(group) }
- context 'with shared examples' do
+ context "with shared examples" do
let(:issuable) { create(:issue, project: project, title: "this is my created issuable")}
- include_examples 'project features apply to issuables', Issue
+ include_examples "project features apply to issuables", Issue
- context 'rss feed' do
+ context "rss feed" do
let(:access_level) { ProjectFeature::ENABLED }
- context 'when signed in' do
+ context "when signed in" do
let(:user) do
user_in_group.ensure_feed_token
user_in_group.save!
@@ -27,7 +27,7 @@ describe 'Group issues page' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
let(:user) { nil }
it_behaves_like "it has an RSS button without a feed token"
@@ -35,43 +35,43 @@ describe 'Group issues page' do
end
end
- context 'assignee', :js do
+ context "assignee", :js do
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
let(:user2) { user_outside_group }
- it 'filters by only group users' do
- filtered_search.set('assignee:')
+ it "filters by only group users" do
+ filtered_search.set("assignee:")
- expect(find('#js-dropdown-assignee .filter-dropdown')).to have_content(user.name)
- expect(find('#js-dropdown-assignee .filter-dropdown')).not_to have_content(user2.name)
+ expect(find("#js-dropdown-assignee .filter-dropdown")).to have_content(user.name)
+ expect(find("#js-dropdown-assignee .filter-dropdown")).not_to have_content(user2.name)
end
end
end
- context 'issues list', :nested_groups do
+ context "issues list", :nested_groups do
let(:subgroup) { create(:group, parent: group) }
let(:subgroup_project) { create(:project, :public, group: subgroup)}
- let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
- let!(:issue) { create(:issue, project: project, title: 'root group issue') }
- let!(:subgroup_issue) { create(:issue, project: subgroup_project, title: 'subgroup issue') }
+ let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
+ let!(:issue) { create(:issue, project: project, title: "root group issue") }
+ let!(:subgroup_issue) { create(:issue, project: subgroup_project, title: "subgroup issue") }
- it 'returns all group and subgroup issues' do
+ it "returns all group and subgroup issues" do
visit issues_group_path(group)
- page.within('.issuable-list') do
- expect(page).to have_selector('li.issue', count: 2)
- expect(page).to have_content('root group issue')
- expect(page).to have_content('subgroup issue')
+ page.within(".issuable-list") do
+ expect(page).to have_selector("li.issue", count: 2)
+ expect(page).to have_content("root group issue")
+ expect(page).to have_content("subgroup issue")
end
end
- context 'when project is archived' do
+ context "when project is archived" do
before do
::Projects::UpdateService.new(project, user_in_group, archived: true).execute
end
- it 'does not render issue' do
+ it "does not render issue" do
visit path
expect(page).not_to have_content issue.title[0..80]
@@ -79,9 +79,9 @@ describe 'Group issues page' do
end
end
- context 'projects with issues disabled' do
- describe 'issue dropdown' do
- let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
+ context "projects with issues disabled" do
+ describe "issue dropdown" do
+ let(:user_in_group) { create(:group_member, :maintainer, user: create(:user), group: group).user }
before do
[project, project_with_issues_disabled].each { |project| project.add_maintainer(user_in_group) }
@@ -89,10 +89,10 @@ describe 'Group issues page' do
visit issues_group_path(group)
end
- it 'shows projects only with issues feature enabled', :js do
- find('.new-project-item-link').click
+ it "shows projects only with issues feature enabled", :js do
+ find(".new-project-item-link").click
- page.within('.select2-results') do
+ page.within(".select2-results") do
expect(page).to have_content(project.full_name)
expect(page).not_to have_content(project_with_issues_disabled.full_name)
end
diff --git a/spec/features/groups/labels/create_spec.rb b/spec/features/groups/labels/create_spec.rb
index f5062a65321..e0d6f0af636 100644
--- a/spec/features/groups/labels/create_spec.rb
+++ b/spec/features/groups/labels/create_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Create a group label' do
+describe "Create a group label" do
let(:user) { create(:user) }
let(:group) { create(:group) }
@@ -12,12 +12,12 @@ describe 'Create a group label' do
visit group_labels_path(group)
end
- it 'creates a new label' do
- click_link 'New label'
- fill_in 'Title', with: 'test-label'
- click_button 'Create label'
+ it "creates a new label" do
+ click_link "New label"
+ fill_in "Title", with: "test-label"
+ click_button "Create label"
- expect(page).to have_content 'test-label'
+ expect(page).to have_content "test-label"
expect(current_path).to eq(group_labels_path(group))
end
end
diff --git a/spec/features/groups/labels/edit_spec.rb b/spec/features/groups/labels/edit_spec.rb
index 7cfc27a8905..b6198fef829 100644
--- a/spec/features/groups/labels/edit_spec.rb
+++ b/spec/features/groups/labels/edit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Edit group label' do
+describe "Edit group label" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:label) { create(:group_label, group: group) }
@@ -11,11 +11,11 @@ describe 'Edit group label' do
visit edit_group_label_path(group, label)
end
- it 'update label with new title' do
- fill_in 'label_title', with: 'new label name'
- click_button 'Save changes'
+ it "update label with new title" do
+ fill_in "label_title", with: "new label name"
+ click_button "Save changes"
expect(current_path).to eq(root_path)
- expect(label.reload.title).to eq('new label name')
+ expect(label.reload.title).to eq("new label name")
end
end
diff --git a/spec/features/groups/labels/index_spec.rb b/spec/features/groups/labels/index_spec.rb
index 62308d3b518..ba36174b059 100644
--- a/spec/features/groups/labels/index_spec.rb
+++ b/spec/features/groups/labels/index_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Group labels' do
+describe "Group labels" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let!(:label) { create(:group_label, group: group) }
@@ -14,16 +14,16 @@ describe 'Group labels' do
visit group_labels_path(group)
end
- it 'shows labels that belong to the group' do
+ it "shows labels that belong to the group" do
expect(page).to have_content(label.name)
expect(page).not_to have_content(label2.name)
end
- it 'shows a new label button' do
- expect(page).to have_link('New label')
+ it "shows a new label button" do
+ expect(page).to have_link("New label")
end
- it 'shows an edit label button', :js do
- expect(page).to have_selector('.label-action.edit')
+ it "shows an edit label button", :js do
+ expect(page).to have_selector(".label-action.edit")
end
end
diff --git a/spec/features/groups/labels/search_labels_spec.rb b/spec/features/groups/labels/search_labels_spec.rb
index 14b88a561b1..76b7aa477c2 100644
--- a/spec/features/groups/labels/search_labels_spec.rb
+++ b/spec/features/groups/labels/search_labels_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Search for labels', :js do
+describe "Search for labels", :js do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) }
- let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) }
+ let!(:label1) { create(:group_label, title: "Foo", description: "Lorem ipsum", group: group) }
+ let!(:label2) { create(:group_label, title: "Bar", description: "Fusce consequat", group: group) }
before do
group.add_maintainer(user)
@@ -15,9 +15,9 @@ describe 'Search for labels', :js do
visit group_labels_path(group)
end
- it 'searches for label by title' do
- fill_in 'label-search', with: 'Bar'
- find('#label-search').native.send_keys(:enter)
+ it "searches for label by title" do
+ fill_in "label-search", with: "Bar"
+ find("#label-search").native.send_keys(:enter)
expect(page).to have_content(label2.title)
expect(page).to have_content(label2.description)
@@ -25,9 +25,9 @@ describe 'Search for labels', :js do
expect(page).not_to have_content(label1.description)
end
- it 'searches for label by description' do
- fill_in 'label-search', with: 'Lorem'
- find('#label-search').native.send_keys(:enter)
+ it "searches for label by description" do
+ fill_in "label-search", with: "Lorem"
+ find("#label-search").native.send_keys(:enter)
expect(page).to have_content(label1.title)
expect(page).to have_content(label1.description)
@@ -35,11 +35,11 @@ describe 'Search for labels', :js do
expect(page).not_to have_content(label2.description)
end
- it 'shows nothing found message' do
- fill_in 'label-search', with: 'nonexistent'
- find('#label-search').native.send_keys(:enter)
+ it "shows nothing found message" do
+ fill_in "label-search", with: "nonexistent"
+ find("#label-search").native.send_keys(:enter)
- expect(page).to have_content('No labels with such name or description')
+ expect(page).to have_content("No labels with such name or description")
expect(page).not_to have_content(label1.title)
expect(page).not_to have_content(label1.description)
expect(page).not_to have_content(label2.title)
diff --git a/spec/features/groups/labels/sort_labels_spec.rb b/spec/features/groups/labels/sort_labels_spec.rb
index 2aea4d77675..ad752e8af51 100644
--- a/spec/features/groups/labels/sort_labels_spec.rb
+++ b/spec/features/groups/labels/sort_labels_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Sort labels', :js do
+describe "Sort labels", :js do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) }
- let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) }
+ let!(:label1) { create(:group_label, title: "Foo", description: "Lorem ipsum", group: group) }
+ let!(:label2) { create(:group_label, title: "Bar", description: "Fusce consequat", group: group) }
before do
group.add_maintainer(user)
@@ -15,34 +15,34 @@ describe 'Sort labels', :js do
visit group_labels_path(group)
end
- it 'sorts by title by default' do
- expect(page).to have_button('Name')
+ it "sorts by title by default" do
+ expect(page).to have_button("Name")
# assert default sorting
- within '.other-labels' do
- expect(page.all('.label-list-item').first.text).to include('Bar')
- expect(page.all('.label-list-item').last.text).to include('Foo')
+ within ".other-labels" do
+ expect(page.all(".label-list-item").first.text).to include("Bar")
+ expect(page.all(".label-list-item").last.text).to include("Foo")
end
end
- it 'sorts by date' do
- click_button 'Name'
+ it "sorts by date" do
+ click_button "Name"
- sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
+ sort_options = find("ul.dropdown-menu-sort li").all("a").collect(&:text)
- expect(sort_options[0]).to eq('Name')
- expect(sort_options[1]).to eq('Name, descending')
- expect(sort_options[2]).to eq('Last created')
- expect(sort_options[3]).to eq('Oldest created')
- expect(sort_options[4]).to eq('Last updated')
- expect(sort_options[5]).to eq('Oldest updated')
+ expect(sort_options[0]).to eq("Name")
+ expect(sort_options[1]).to eq("Name, descending")
+ expect(sort_options[2]).to eq("Last created")
+ expect(sort_options[3]).to eq("Oldest created")
+ expect(sort_options[4]).to eq("Last updated")
+ expect(sort_options[5]).to eq("Oldest updated")
- click_link 'Name, descending'
+ click_link "Name, descending"
# assert default sorting
- within '.other-labels' do
- expect(page.all('.label-list-item').first.text).to include('Foo')
- expect(page.all('.label-list-item').last.text).to include('Bar')
+ within ".other-labels" do
+ expect(page.all(".label-list-item").first.text).to include("Foo")
+ expect(page.all(".label-list-item").last.text).to include("Bar")
end
end
end
diff --git a/spec/features/groups/labels/subscription_spec.rb b/spec/features/groups/labels/subscription_spec.rb
index 22b51b297a6..d9a95a744e6 100644
--- a/spec/features/groups/labels/subscription_spec.rb
+++ b/spec/features/groups/labels/subscription_spec.rb
@@ -1,91 +1,91 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Labels subscription' do
+describe "Labels subscription" do
let(:user) { create(:user) }
let(:group) { create(:group) }
- let!(:label1) { create(:group_label, group: group, title: 'foo') }
- let!(:label2) { create(:group_label, group: group, title: 'bar') }
+ let!(:label1) { create(:group_label, group: group, title: "foo") }
+ let!(:label2) { create(:group_label, group: group, title: "bar") }
- context 'when signed in' do
+ context "when signed in" do
before do
group.add_developer(user)
gitlab_sign_in user
end
- it 'users can subscribe/unsubscribe to group labels', :js do
+ it "users can subscribe/unsubscribe to group labels", :js do
visit group_labels_path(group)
expect(page).to have_content(label1.title)
within "#group_label_#{label1.id}" do
- expect(page).not_to have_button 'Unsubscribe'
+ expect(page).not_to have_button "Unsubscribe"
- click_button 'Subscribe'
+ click_button "Subscribe"
- expect(page).not_to have_button 'Subscribe'
- expect(page).to have_button 'Unsubscribe'
+ expect(page).not_to have_button "Subscribe"
+ expect(page).to have_button "Unsubscribe"
- click_button 'Unsubscribe'
+ click_button "Unsubscribe"
- expect(page).to have_button 'Subscribe'
- expect(page).not_to have_button 'Unsubscribe'
+ expect(page).to have_button "Subscribe"
+ expect(page).not_to have_button "Unsubscribe"
end
end
- context 'subscription filter' do
+ context "subscription filter" do
before do
visit group_labels_path(group)
end
- it 'shows only subscribed labels' do
+ it "shows only subscribed labels" do
label1.subscribe(user)
click_subscribed_tab
- page.within('.labels-container') do
+ page.within(".labels-container") do
expect(page).to have_content label1.title
end
end
- it 'shows no subscribed labels message' do
+ it "shows no subscribed labels message" do
click_subscribed_tab
- page.within('.labels-container') do
+ page.within(".labels-container") do
expect(page).not_to have_content label1.title
- expect(page).to have_content('You do not have any subscriptions yet')
+ expect(page).to have_content("You do not have any subscriptions yet")
end
end
end
end
- context 'when not signed in' do
+ context "when not signed in" do
before do
visit group_labels_path(group)
end
- it 'users can not subscribe/unsubscribe to labels' do
+ it "users can not subscribe/unsubscribe to labels" do
expect(page).to have_content label1.title
- expect(page).not_to have_button('Subscribe')
+ expect(page).not_to have_button("Subscribe")
end
- it 'does not show subscribed tab' do
- page.within('.nav-tabs') do
- expect(page).not_to have_link 'Subscribed'
+ it "does not show subscribed tab" do
+ page.within(".nav-tabs") do
+ expect(page).not_to have_link "Subscribed"
end
end
end
def click_link_on_dropdown(text)
- find('.dropdown-group-label').click
+ find(".dropdown-group-label").click
- page.within('.dropdown-group-label') do
- find('a.js-subscribe-button', text: text).click
+ page.within(".dropdown-group-label") do
+ find("a.js-subscribe-button", text: text).click
end
end
def click_subscribed_tab
- page.within('.nav-tabs') do
- click_link 'Subscribed'
+ page.within(".nav-tabs") do
+ click_link "Subscribed"
end
end
end
diff --git a/spec/features/groups/labels/user_sees_links_to_issuables.rb b/spec/features/groups/labels/user_sees_links_to_issuables.rb
index 1fdba78fa6c..8fc90ba655b 100644
--- a/spec/features/groups/labels/user_sees_links_to_issuables.rb
+++ b/spec/features/groups/labels/user_sees_links_to_issuables.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Labels > User sees links to issuables' do
+describe "Groups > Labels > User sees links to issuables" do
set(:group) { create(:group, :public) }
before do
- create(:group_label, group: group, title: 'bug')
+ create(:group_label, group: group, title: "bug")
visit group_labels_path(group)
end
- it 'shows links to MRs and issues' do
- expect(page).to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to MRs and issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
diff --git a/spec/features/groups/members/filter_members_spec.rb b/spec/features/groups/members/filter_members_spec.rb
index 386d81546d7..9ac28ceac65 100644
--- a/spec/features/groups/members/filter_members_spec.rb
+++ b/spec/features/groups/members/filter_members_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Filter members' do
+describe "Groups > Members > Filter members" do
let(:user) { create(:user) }
let(:user_with_2fa) { create(:user, :two_factor_via_otp) }
let(:group) { create(:group) }
@@ -12,28 +12,28 @@ describe 'Groups > Members > Filter members' do
sign_in(user)
end
- it 'shows all members' do
+ it "shows all members" do
visit_members_list
expect(first_member).to include(user.name)
expect(second_member).to include(user_with_2fa.name)
- expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: '2FA: Everyone')
+ expect(page).to have_css(".member-filter-2fa-dropdown .dropdown-toggle-text", text: "2FA: Everyone")
end
- it 'shows only 2FA members' do
- visit_members_list(two_factor: 'enabled')
+ it "shows only 2FA members" do
+ visit_members_list(two_factor: "enabled")
expect(first_member).to include(user_with_2fa.name)
expect(members_list.size).to eq(1)
- expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: '2FA: Enabled')
+ expect(page).to have_css(".member-filter-2fa-dropdown .dropdown-toggle-text", text: "2FA: Enabled")
end
- it 'shows only non 2FA members' do
- visit_members_list(two_factor: 'disabled')
+ it "shows only non 2FA members" do
+ visit_members_list(two_factor: "disabled")
expect(first_member).to include(user.name)
expect(members_list.size).to eq(1)
- expect(page).to have_css('.member-filter-2fa-dropdown .dropdown-toggle-text', text: '2FA: Disabled')
+ expect(page).to have_css(".member-filter-2fa-dropdown .dropdown-toggle-text", text: "2FA: Disabled")
end
def visit_members_list(options = {})
@@ -41,7 +41,7 @@ describe 'Groups > Members > Filter members' do
end
def members_list
- page.all('ul.content-list > li')
+ page.all("ul.content-list > li")
end
def first_member
diff --git a/spec/features/groups/members/leave_group_spec.rb b/spec/features/groups/members/leave_group_spec.rb
index 7a91c64d7db..89d2f0467ec 100644
--- a/spec/features/groups/members/leave_group_spec.rb
+++ b/spec/features/groups/members/leave_group_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Leave group' do
+describe "Groups > Members > Leave group" do
let(:user) { create(:user) }
let(:other_user) { create(:user) }
let(:group) { create(:group) }
@@ -9,51 +9,51 @@ describe 'Groups > Members > Leave group' do
gitlab_sign_in(user)
end
- it 'guest leaves the group' do
+ it "guest leaves the group" do
group.add_guest(user)
group.add_owner(other_user)
visit group_path(group)
- click_link 'Leave group'
+ click_link "Leave group"
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
- it 'guest leaves the group as last member' do
+ it "guest leaves the group as last member" do
group.add_guest(user)
visit group_path(group)
- click_link 'Leave group'
+ click_link "Leave group"
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
- it 'owner leaves the group if they is not the last owner' do
+ it "owner leaves the group if they is not the last owner" do
group.add_owner(user)
group.add_owner(other_user)
visit group_path(group)
- click_link 'Leave group'
+ click_link "Leave group"
expect(current_path).to eq(dashboard_groups_path)
expect(page).to have_content left_group_message(group)
expect(group.users).not_to include(user)
end
- it 'owner can not leave the group if they is a last owner' do
+ it "owner can not leave the group if they is a last owner" do
group.add_owner(user)
visit group_path(group)
- expect(page).not_to have_content 'Leave group'
+ expect(page).not_to have_content "Leave group"
visit group_group_members_path(group)
- expect(find(:css, '.project-members-page li', text: user.name)).not_to have_selector(:css, 'a.btn-remove')
+ expect(find(:css, ".project-members-page li", text: user.name)).not_to have_selector(:css, "a.btn-remove")
end
def left_group_message(group)
diff --git a/spec/features/groups/members/list_members_spec.rb b/spec/features/groups/members/list_members_spec.rb
index 4ba7161601e..f25f4d920f4 100644
--- a/spec/features/groups/members/list_members_spec.rb
+++ b/spec/features/groups/members/list_members_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > List members' do
+describe "Groups > Members > List members" do
include Select2Helper
include Spec::Support::Helpers::Features::ListRowsHelpers
- let(:user1) { create(:user, name: 'John Doe') }
- let(:user2) { create(:user, name: 'Mary Jane') }
+ let(:user1) { create(:user, name: "John Doe") }
+ let(:user2) { create(:user, name: "Mary Jane") }
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
@@ -13,7 +13,7 @@ describe 'Groups > Members > List members' do
sign_in(user1)
end
- it 'show members from current group and parent', :nested_groups do
+ it "show members from current group and parent", :nested_groups do
group.add_developer(user1)
nested_group.add_developer(user2)
@@ -23,7 +23,7 @@ describe 'Groups > Members > List members' do
expect(second_row.text).to include(user2.name)
end
- it 'show user once if member of both current group and parent', :nested_groups do
+ it "show user once if member of both current group and parent", :nested_groups do
group.add_developer(user1)
nested_group.add_developer(user1)
@@ -33,14 +33,14 @@ describe 'Groups > Members > List members' do
expect(second_row).to be_blank
end
- describe 'showing status of members' do
+ describe "showing status of members" do
before do
group.add_developer(user2)
end
subject { visit group_group_members_path(group) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { user2 }
end
end
diff --git a/spec/features/groups/members/manage_members_spec.rb b/spec/features/groups/members/manage_members_spec.rb
index e2b4a491a13..0631229160e 100644
--- a/spec/features/groups/members/manage_members_spec.rb
+++ b/spec/features/groups/members/manage_members_spec.rb
@@ -1,73 +1,73 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Manage members' do
+describe "Groups > Members > Manage members" do
include Select2Helper
include Spec::Support::Helpers::Features::ListRowsHelpers
- let(:user1) { create(:user, name: 'John Doe') }
- let(:user2) { create(:user, name: 'Mary Jane') }
+ let(:user1) { create(:user, name: "John Doe") }
+ let(:user2) { create(:user, name: "Mary Jane") }
let(:group) { create(:group) }
before do
sign_in(user1)
end
- it 'update user to owner level', :js do
+ it "update user to owner level", :js do
group.add_owner(user1)
group.add_developer(user2)
visit group_group_members_path(group)
page.within(second_row) do
- click_button('Developer')
- click_link('Owner')
+ click_button("Developer")
+ click_link("Owner")
- expect(page).to have_button('Owner')
+ expect(page).to have_button("Owner")
end
end
- it 'add user to group', :js do
+ it "add user to group", :js do
group.add_owner(user1)
visit group_group_members_path(group)
- add_user(user2.id, 'Reporter')
+ add_user(user2.id, "Reporter")
page.within(second_row) do
expect(page).to have_content(user2.name)
- expect(page).to have_button('Reporter')
+ expect(page).to have_button("Reporter")
end
end
- it 'do not disclose email addresses', :js do
+ it "do not disclose email addresses", :js do
group.add_owner(user1)
- create(:user, email: 'undisclosed_email@gitlab.com', name: "Jane 'invisible' Doe")
+ create(:user, email: "undisclosed_email@gitlab.com", name: "Jane 'invisible' Doe")
visit group_group_members_path(group)
- find('.select2-container').click
- select_input = find('.select2-input')
+ find(".select2-container").click
+ select_input = find(".select2-input")
- select_input.send_keys('@gitlab.com')
+ select_input.send_keys("@gitlab.com")
wait_for_requests
- expect(page).to have_content('No matches found')
+ expect(page).to have_content("No matches found")
select_input.native.clear
- select_input.send_keys('undisclosed_email@gitlab.com')
+ select_input.send_keys("undisclosed_email@gitlab.com")
wait_for_requests
expect(page).to have_content("Jane 'invisible' Doe")
end
- it 'remove user from group', :js do
+ it "remove user from group", :js do
group.add_owner(user1)
group.add_developer(user2)
visit group_group_members_path(group)
accept_confirm do
- find(:css, '.project-members-page li', text: user2.name).find(:css, 'a.btn-remove').click
+ find(:css, ".project-members-page li", text: user2.name).find(:css, "a.btn-remove").click
end
wait_for_requests
@@ -76,47 +76,47 @@ describe 'Groups > Members > Manage members' do
expect(group.users).not_to include(user2)
end
- it 'add yourself to group when already an owner', :js do
+ it "add yourself to group when already an owner", :js do
group.add_owner(user1)
visit group_group_members_path(group)
- add_user(user1.id, 'Reporter')
+ add_user(user1.id, "Reporter")
page.within(first_row) do
expect(page).to have_content(user1.name)
- expect(page).to have_content('Owner')
+ expect(page).to have_content("Owner")
end
end
- it 'invite user to group', :js do
+ it "invite user to group", :js do
group.add_owner(user1)
visit group_group_members_path(group)
- add_user('test@example.com', 'Reporter')
+ add_user("test@example.com", "Reporter")
page.within(second_row) do
- expect(page).to have_content('test@example.com')
- expect(page).to have_content('Invited')
- expect(page).to have_button('Reporter')
+ expect(page).to have_content("test@example.com")
+ expect(page).to have_content("Invited")
+ expect(page).to have_button("Reporter")
end
end
- it 'guest can not manage other users' do
+ it "guest can not manage other users" do
group.add_guest(user1)
group.add_developer(user2)
visit group_group_members_path(group)
- expect(page).not_to have_button 'Add to group'
+ expect(page).not_to have_button "Add to group"
page.within(second_row) do
# Can not modify user2 role
- expect(page).not_to have_button 'Developer'
+ expect(page).not_to have_button "Developer"
# Can not remove user2
- expect(page).not_to have_css('a.btn-remove')
+ expect(page).not_to have_css("a.btn-remove")
end
end
diff --git a/spec/features/groups/members/master_manages_access_requests_spec.rb b/spec/features/groups/members/master_manages_access_requests_spec.rb
index bd615c99412..a768638f382 100644
--- a/spec/features/groups/members/master_manages_access_requests_spec.rb
+++ b/spec/features/groups/members/master_manages_access_requests_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Maintainer manages access requests' do
- it_behaves_like 'Maintainer manages access requests' do
+describe "Groups > Members > Maintainer manages access requests" do
+ it_behaves_like "Maintainer manages access requests" do
let(:entity) { create(:group, :public, :access_requestable) }
let(:members_page_path) { group_group_members_path(entity) }
end
diff --git a/spec/features/groups/members/request_access_spec.rb b/spec/features/groups/members/request_access_spec.rb
index 94510f917a3..8b36627d1b6 100644
--- a/spec/features/groups/members/request_access_spec.rb
+++ b/spec/features/groups/members/request_access_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Request access' do
+describe "Groups > Members > Request access" do
let(:user) { create(:user) }
let(:owner) { create(:user) }
let(:group) { create(:group, :public, :access_requestable) }
@@ -12,67 +12,67 @@ describe 'Groups > Members > Request access' do
visit group_path(group)
end
- it 'request access feature is disabled' do
+ it "request access feature is disabled" do
group.update(request_access_enabled: false)
visit group_path(group)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'user can request access to a group' do
- perform_enqueued_jobs { click_link 'Request Access' }
+ it "user can request access to a group" do
+ perform_enqueued_jobs { click_link "Request Access" }
expect(ActionMailer::Base.deliveries.last.to).to eq [owner.notification_email]
expect(ActionMailer::Base.deliveries.last.subject).to match "Request to join the #{group.name} group"
expect(group.requesters.exists?(user_id: user)).to be_truthy
- expect(page).to have_content 'Your request for access has been queued for review.'
+ expect(page).to have_content "Your request for access has been queued for review."
- expect(page).to have_content 'Withdraw Access Request'
- expect(page).not_to have_content 'Leave group'
+ expect(page).to have_content "Withdraw Access Request"
+ expect(page).not_to have_content "Leave group"
end
- it 'user does not see private projects' do
- perform_enqueued_jobs { click_link 'Request Access' }
+ it "user does not see private projects" do
+ perform_enqueued_jobs { click_link "Request Access" }
expect(page).not_to have_content project.name
end
- it 'user does not see group in the Dashboard > Groups page' do
- perform_enqueued_jobs { click_link 'Request Access' }
+ it "user does not see group in the Dashboard > Groups page" do
+ perform_enqueued_jobs { click_link "Request Access" }
visit dashboard_groups_path
expect(page).not_to have_content group.name
end
- it 'user is not listed in the group members page' do
- click_link 'Request Access'
+ it "user is not listed in the group members page" do
+ click_link "Request Access"
expect(group.requesters.exists?(user_id: user)).to be_truthy
- first(:link, 'Members').click
+ first(:link, "Members").click
- page.within('.content') do
+ page.within(".content") do
expect(page).not_to have_content(user.name)
end
end
- it 'user can withdraw its request for access' do
- click_link 'Request Access'
+ it "user can withdraw its request for access" do
+ click_link "Request Access"
expect(group.requesters.exists?(user_id: user)).to be_truthy
- click_link 'Withdraw Access Request'
+ click_link "Withdraw Access Request"
expect(group.requesters.exists?(user_id: user)).to be_falsey
- expect(page).to have_content 'Your access request to the group has been withdrawn.'
+ expect(page).to have_content "Your access request to the group has been withdrawn."
end
- it 'member does not see the request access button' do
+ it "member does not see the request access button" do
group.add_owner(user)
visit group_path(group)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
end
diff --git a/spec/features/groups/members/search_members_spec.rb b/spec/features/groups/members/search_members_spec.rb
index e7efdf7dfef..4ceed7771d7 100644
--- a/spec/features/groups/members/search_members_spec.rb
+++ b/spec/features/groups/members/search_members_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Search group member' do
+describe "Search group member" do
let(:user) { create :user }
let(:member) { create :user }
@@ -16,10 +16,10 @@ describe 'Search group member' do
visit group_group_members_path(guest_group)
end
- it 'renders member users' do
- page.within '.member-search-form' do
- fill_in 'search', with: member.name
- find('.member-search-btn').click
+ it "renders member users" do
+ page.within ".member-search-form" do
+ fill_in "search", with: member.name
+ find(".member-search-btn").click
end
group_members_list = find(".card .content-list")
diff --git a/spec/features/groups/members/sort_members_spec.rb b/spec/features/groups/members/sort_members_spec.rb
index ee32f6d77fe..868e8a39317 100644
--- a/spec/features/groups/members/sort_members_spec.rb
+++ b/spec/features/groups/members/sort_members_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > Members > Sort members' do
- let(:owner) { create(:user, name: 'John Doe') }
- let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) }
+describe "Groups > Members > Sort members" do
+ let(:owner) { create(:user, name: "John Doe") }
+ let(:developer) { create(:user, name: "Mary Jane", last_sign_in_at: 5.days.ago) }
let(:group) { create(:group) }
before do
@@ -12,76 +12,76 @@ describe 'Groups > Members > Sort members' do
sign_in(owner)
end
- it 'sorts alphabetically by default' do
+ it "sorts alphabetically by default" do
visit_members_list(sort: nil)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, ascending")
end
- it 'sorts by access level ascending' do
+ it "sorts by access level ascending" do
visit_members_list(sort: :access_level_asc)
expect(first_member).to include(developer.name)
expect(second_member).to include(owner.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Access level, ascending")
end
- it 'sorts by access level descending' do
+ it "sorts by access level descending" do
visit_members_list(sort: :access_level_desc)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, descending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Access level, descending")
end
- it 'sorts by last joined' do
+ it "sorts by last joined" do
visit_members_list(sort: :last_joined)
expect(first_member).to include(developer.name)
expect(second_member).to include(owner.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Last joined')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Last joined")
end
- it 'sorts by oldest joined' do
+ it "sorts by oldest joined" do
visit_members_list(sort: :oldest_joined)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest joined')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Oldest joined")
end
- it 'sorts by name ascending' do
+ it "sorts by name ascending" do
visit_members_list(sort: :name_asc)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, ascending")
end
- it 'sorts by name descending' do
+ it "sorts by name descending" do
visit_members_list(sort: :name_desc)
expect(first_member).to include(developer.name)
expect(second_member).to include(owner.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, descending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, descending")
end
- it 'sorts by recent sign in', :clean_gitlab_redis_shared_state do
+ it "sorts by recent sign in", :clean_gitlab_redis_shared_state do
visit_members_list(sort: :recent_sign_in)
expect(first_member).to include(owner.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Recent sign in')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Recent sign in")
end
- it 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do
+ it "sorts by oldest sign in", :clean_gitlab_redis_shared_state do
visit_members_list(sort: :oldest_sign_in)
expect(first_member).to include(developer.name)
expect(second_member).to include(owner.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest sign in')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Oldest sign in")
end
def visit_members_list(sort:)
@@ -89,10 +89,10 @@ describe 'Groups > Members > Sort members' do
end
def first_member
- page.all('ul.content-list > li').first.text
+ page.all("ul.content-list > li").first.text
end
def second_member
- page.all('ul.content-list > li').last.text
+ page.all("ul.content-list > li").last.text
end
end
diff --git a/spec/features/groups/merge_requests_spec.rb b/spec/features/groups/merge_requests_spec.rb
index 54a8016c157..9eed560eaa0 100644
--- a/spec/features/groups/merge_requests_spec.rb
+++ b/spec/features/groups/merge_requests_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group merge requests page' do
+describe "Group merge requests page" do
include FilteredSearchHelpers
let(:path) { merge_requests_group_path(group) }
- let(:issuable) { create(:merge_request, source_project: project, target_project: project, title: 'this is my created issuable') }
+ let(:issuable) { create(:merge_request, source_project: project, target_project: project, title: "this is my created issuable") }
let(:access_level) { ProjectFeature::ENABLED }
let(:user) { user_in_group }
- include_examples 'project features apply to issuables', MergeRequest
+ include_examples "project features apply to issuables", MergeRequest
- context 'archived issuable' do
+ context "archived issuable" do
let(:project_archived) { create(:project, :archived, :merge_requests_enabled, :repository, group: group) }
- let(:issuable_archived) { create(:merge_request, source_project: project_archived, target_project: project_archived, title: 'issuable of an archived project') }
+ let(:issuable_archived) { create(:merge_request, source_project: project_archived, target_project: project_archived, title: "issuable of an archived project") }
before do
issuable_archived
visit path
end
- it 'hides archived merge requests' do
+ it "hides archived merge requests" do
expect(page).to have_content(issuable.title)
expect(page).not_to have_content(issuable_archived.title)
end
- it 'ignores archived merge request count badges in navbar' do
- expect(first(:link, text: 'Merge Requests').find('.badge').text).to eq("1")
+ it "ignores archived merge request count badges in navbar" do
+ expect(first(:link, text: "Merge Requests").find(".badge").text).to eq("1")
end
- it 'ignores archived merge request count badges in state-filters' do
- expect(page.find('#state-opened span.badge').text).to eq("1")
- expect(page.find('#state-merged span.badge').text).to eq("0")
- expect(page.find('#state-closed span.badge').text).to eq("0")
- expect(page.find('#state-all span.badge').text).to eq("1")
+ it "ignores archived merge request count badges in state-filters" do
+ expect(page.find("#state-opened span.badge").text).to eq("1")
+ expect(page.find("#state-merged span.badge").text).to eq("0")
+ expect(page.find("#state-closed span.badge").text).to eq("0")
+ expect(page.find("#state-all span.badge").text).to eq("1")
end
end
- context 'when merge request assignee to user' do
+ context "when merge request assignee to user" do
before do
issuable.update!(assignee: user)
@@ -46,28 +46,28 @@ describe 'Group merge requests page' do
it { expect(page).to have_content issuable.title[0..80] }
end
- context 'group filtered search', :js do
+ context "group filtered search", :js do
let(:user2) { user_outside_group }
- it 'filters by assignee only group users' do
- filtered_search.set('assignee:')
+ it "filters by assignee only group users" do
+ filtered_search.set("assignee:")
- expect(find('#js-dropdown-assignee .filter-dropdown')).to have_content(user.name)
- expect(find('#js-dropdown-assignee .filter-dropdown')).not_to have_content(user2.name)
+ expect(find("#js-dropdown-assignee .filter-dropdown")).to have_content(user.name)
+ expect(find("#js-dropdown-assignee .filter-dropdown")).not_to have_content(user2.name)
end
end
- describe 'new merge request dropdown' do
+ describe "new merge request dropdown" do
let(:project_with_merge_requests_disabled) { create(:project, :merge_requests_disabled, group: group) }
before do
visit path
end
- it 'shows projects only with merge requests feature enabled', :js do
- find('.new-project-item-link').click
+ it "shows projects only with merge requests feature enabled", :js do
+ find(".new-project-item-link").click
- page.within('.select2-results') do
+ page.within(".select2-results") do
expect(page).to have_content(project.name_with_namespace)
expect(page).not_to have_content(project_with_merge_requests_disabled.name_with_namespace)
end
diff --git a/spec/features/groups/milestone_spec.rb b/spec/features/groups/milestone_spec.rb
index d57eb87ca77..b86c4e99f90 100644
--- a/spec/features/groups/milestone_spec.rb
+++ b/spec/features/groups/milestone_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Group milestones' do
+describe "Group milestones" do
let(:group) { create(:group) }
let!(:project) { create(:project_empty_repo, group: group) }
- let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
+ let(:user) { create(:group_member, :maintainer, user: create(:user), group: group).user }
around do |example|
Timecop.freeze { example.run }
@@ -13,79 +13,79 @@ describe 'Group milestones' do
sign_in(user)
end
- context 'create a milestone', :js do
+ context "create a milestone", :js do
before do
visit new_group_milestone_path(group)
end
- it 'renders description preview' do
- description = find('.note-textarea')
+ it "renders description preview" do
+ description = find(".note-textarea")
- description.native.send_keys('')
+ description.native.send_keys("")
- click_button('Preview')
+ click_button("Preview")
- preview = find('.js-md-preview')
+ preview = find(".js-md-preview")
- expect(preview).to have_content('Nothing to preview.')
+ expect(preview).to have_content("Nothing to preview.")
- click_button('Write')
+ click_button("Write")
- description.native.send_keys(':+1: Nice')
+ description.native.send_keys(":+1: Nice")
- click_button('Preview')
+ click_button("Preview")
- expect(preview).to have_css('gl-emoji')
- expect(find('#milestone_description', visible: false)).not_to be_visible
+ expect(preview).to have_css("gl-emoji")
+ expect(find("#milestone_description", visible: false)).not_to be_visible
end
- it 'creates milestone with start date' do
- fill_in 'Title', with: 'testing'
- find('#milestone_start_date').click
+ it "creates milestone with start date" do
+ fill_in "Title", with: "testing"
+ find("#milestone_start_date").click
- page.within(find('.pika-single')) do
- click_button '1'
+ page.within(find(".pika-single")) do
+ click_button "1"
end
- click_button 'Create milestone'
+ click_button "Create milestone"
- expect(find('.start_date')).to have_content(Date.today.at_beginning_of_month.strftime('%b %-d, %Y'))
+ expect(find(".start_date")).to have_content(Date.today.at_beginning_of_month.strftime("%b %-d, %Y"))
end
- it 'description input does not support autocomplete' do
- description = find('.note-textarea')
- description.native.send_keys('!')
+ it "description input does not support autocomplete" do
+ description = find(".note-textarea")
+ description.native.send_keys("!")
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
end
- context 'milestones list' do
- context 'when no milestones' do
- it 'renders no milestones text' do
+ context "milestones list" do
+ context "when no milestones" do
+ it "renders no milestones text" do
visit group_milestones_path(group)
- expect(page).to have_content('No milestones to show')
+ expect(page).to have_content("No milestones to show")
end
end
- context 'when milestones exists' do
+ context "when milestones exists" do
let!(:other_project) { create(:project_empty_repo, group: group) }
let!(:active_project_milestone1) do
create(
:milestone,
project: project,
- state: 'active',
- title: 'v1.0',
- due_date: '2114-08-20',
- description: 'Lorem Ipsum is simply dummy text'
+ state: "active",
+ title: "v1.0",
+ due_date: "2114-08-20",
+ description: "Lorem Ipsum is simply dummy text"
)
end
- let!(:active_project_milestone2) { create(:milestone, project: other_project, state: 'active', title: 'v1.1') }
- let!(:closed_project_milestone1) { create(:milestone, project: project, state: 'closed', title: 'v2.0') }
- let!(:closed_project_milestone2) { create(:milestone, project: other_project, state: 'closed', title: 'v2.0') }
- let!(:active_group_milestone) { create(:milestone, group: group, state: 'active', title: 'GL-113') }
- let!(:closed_group_milestone) { create(:milestone, group: group, state: 'closed') }
+ let!(:active_project_milestone2) { create(:milestone, project: other_project, state: "active", title: "v1.1") }
+ let!(:closed_project_milestone1) { create(:milestone, project: project, state: "closed", title: "v2.0") }
+ let!(:closed_project_milestone2) { create(:milestone, project: other_project, state: "closed", title: "v2.0") }
+ let!(:active_group_milestone) { create(:milestone, group: group, state: "active", title: "GL-113") }
+ let!(:closed_group_milestone) { create(:milestone, group: group, state: "closed") }
let!(:issue) do
create :issue, project: project, assignees: [user], author: user, milestone: active_project_milestone1
end
@@ -94,84 +94,84 @@ describe 'Group milestones' do
visit group_milestones_path(group)
end
- it 'counts milestones correctly' do
- expect(find('.top-area .active .badge').text).to eq("3")
- expect(find('.top-area .closed .badge').text).to eq("3")
- expect(find('.top-area .all .badge').text).to eq("6")
+ it "counts milestones correctly" do
+ expect(find(".top-area .active .badge").text).to eq("3")
+ expect(find(".top-area .closed .badge").text).to eq("3")
+ expect(find(".top-area .all .badge").text).to eq("6")
end
- it 'lists legacy group milestones and group milestones' do
- legacy_milestone = GroupMilestone.build_collection(group, group.projects, { state: 'active' }).first
+ it "lists legacy group milestones and group milestones" do
+ legacy_milestone = GroupMilestone.build_collection(group, group.projects, {state: "active"}).first
expect(page).to have_selector("#milestone_#{active_group_milestone.id}", count: 1)
expect(page).to have_selector("#milestone_#{legacy_milestone.milestone.id}", count: 1)
end
- it 'shows milestone detail and supports its edit' do
+ it "shows milestone detail and supports its edit" do
page.within(".milestones #milestone_#{active_group_milestone.id}") do
click_link(active_group_milestone.title)
end
- page.within('.detail-page-header') do
- click_link('Edit')
+ page.within(".detail-page-header") do
+ click_link("Edit")
end
- expect(page).to have_selector('.milestone-form')
+ expect(page).to have_selector(".milestone-form")
end
- it 'renders milestones' do
- expect(page).to have_content('v1.0')
- expect(page).to have_content('v1.1')
- expect(page).to have_content('GL-113')
+ it "renders milestones" do
+ expect(page).to have_content("v1.0")
+ expect(page).to have_content("v1.1")
+ expect(page).to have_content("GL-113")
expect(page).to have_link(
- '1 Issue',
- href: issues_group_path(group, milestone_title: 'v1.0')
+ "1 Issue",
+ href: issues_group_path(group, milestone_title: "v1.0")
)
expect(page).to have_link(
- '0 Merge Requests',
- href: merge_requests_group_path(group, milestone_title: 'v1.0')
+ "0 Merge Requests",
+ href: merge_requests_group_path(group, milestone_title: "v1.0")
)
end
- it 'renders group milestone details' do
- click_link 'v1.0'
+ it "renders group milestone details" do
+ click_link "v1.0"
- expect(page).to have_content('expires on Aug 20, 2114')
- expect(page).to have_content('v1.0')
- expect(page).to have_content('Issues 1 Open: 1 Closed: 0')
+ expect(page).to have_content("expires on Aug 20, 2114")
+ expect(page).to have_content("v1.0")
+ expect(page).to have_content("Issues 1 Open: 1 Closed: 0")
expect(page).to have_link(issue.title, href: project_issue_path(issue.project, issue))
end
- describe 'labels' do
+ describe "labels" do
before do
- create(:label, project: project, title: 'bug') do |label|
+ create(:label, project: project, title: "bug") do |label|
issue.labels << label
end
- create(:label, project: project, title: 'feature') do |label|
+ create(:label, project: project, title: "feature") do |label|
issue.labels << label
end
end
- it 'renders labels' do
- click_link 'v1.0'
+ it "renders labels" do
+ click_link "v1.0"
- page.within('#tab-issues') do
- expect(page).to have_content 'bug'
- expect(page).to have_content 'feature'
+ page.within("#tab-issues") do
+ expect(page).to have_content "bug"
+ expect(page).to have_content "feature"
end
end
- it 'renders labels list', :js do
- click_link 'v1.0'
+ it "renders labels list", :js do
+ click_link "v1.0"
- page.within('.content .nav-links') do
+ page.within(".content .nav-links") do
page.find(:xpath, "//a[@href='#tab-labels']").click
end
- page.within('#tab-labels') do
- expect(page).to have_content 'bug'
- expect(page).to have_content 'feature'
+ page.within("#tab-labels") do
+ expect(page).to have_content "bug"
+ expect(page).to have_content "feature"
end
end
end
diff --git a/spec/features/groups/milestones_sorting_spec.rb b/spec/features/groups/milestones_sorting_spec.rb
index 7bc015ea28f..40ddbce4686 100644
--- a/spec/features/groups/milestones_sorting_spec.rb
+++ b/spec/features/groups/milestones_sorting_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Milestones sorting', :js do
+describe "Milestones sorting", :js do
let(:group) { create(:group) }
let!(:project) { create(:project_empty_repo, group: group) }
let!(:other_project) { create(:project_empty_repo, group: group) }
- let!(:project_milestone1) { create(:milestone, project: project, title: 'v1.0', due_date: 10.days.from_now) }
- let!(:other_project_milestone1) { create(:milestone, project: other_project, title: 'v1.0', due_date: 10.days.from_now) }
- let!(:project_milestone2) { create(:milestone, project: project, title: 'v2.0', due_date: 5.days.from_now) }
- let!(:other_project_milestone2) { create(:milestone, project: other_project, title: 'v2.0', due_date: 5.days.from_now) }
- let!(:group_milestone) { create(:milestone, group: group, title: 'v3.0', due_date: 7.days.from_now) }
- let(:user) { create(:group_member, :maintainer, user: create(:user), group: group ).user }
+ let!(:project_milestone1) { create(:milestone, project: project, title: "v1.0", due_date: 10.days.from_now) }
+ let!(:other_project_milestone1) { create(:milestone, project: other_project, title: "v1.0", due_date: 10.days.from_now) }
+ let!(:project_milestone2) { create(:milestone, project: project, title: "v2.0", due_date: 5.days.from_now) }
+ let!(:other_project_milestone2) { create(:milestone, project: other_project, title: "v2.0", due_date: 5.days.from_now) }
+ let!(:group_milestone) { create(:milestone, group: group, title: "v3.0", due_date: 7.days.from_now) }
+ let(:user) { create(:group_member, :maintainer, user: create(:user), group: group).user }
before do
sign_in(user)
end
- it 'visit group milestones and sort by due_date_asc' do
+ it "visit group milestones and sort by due_date_asc" do
visit group_milestones_path(group)
- expect(page).to have_button('Due soon')
+ expect(page).to have_button("Due soon")
# assert default sorting
- within '.milestones' do
- expect(page.all('ul.content-list > li').first.text).to include('v2.0')
- expect(page.all('ul.content-list > li')[1].text).to include('v3.0')
- expect(page.all('ul.content-list > li').last.text).to include('v1.0')
+ within ".milestones" do
+ expect(page.all("ul.content-list > li").first.text).to include("v2.0")
+ expect(page.all("ul.content-list > li")[1].text).to include("v3.0")
+ expect(page.all("ul.content-list > li").last.text).to include("v1.0")
end
- click_button 'Due soon'
+ click_button "Due soon"
- sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
+ sort_options = find("ul.dropdown-menu-sort li").all("a").collect(&:text)
- expect(sort_options[0]).to eq('Due soon')
- expect(sort_options[1]).to eq('Due later')
- expect(sort_options[2]).to eq('Start soon')
- expect(sort_options[3]).to eq('Start later')
- expect(sort_options[4]).to eq('Name, ascending')
- expect(sort_options[5]).to eq('Name, descending')
+ expect(sort_options[0]).to eq("Due soon")
+ expect(sort_options[1]).to eq("Due later")
+ expect(sort_options[2]).to eq("Start soon")
+ expect(sort_options[3]).to eq("Start later")
+ expect(sort_options[4]).to eq("Name, ascending")
+ expect(sort_options[5]).to eq("Name, descending")
- click_link 'Due later'
+ click_link "Due later"
- expect(page).to have_button('Due later')
+ expect(page).to have_button("Due later")
# assert descending sorting
- within '.milestones' do
- expect(page.all('ul.content-list > li').first.text).to include('v1.0')
- expect(page.all('ul.content-list > li')[1].text).to include('v3.0')
- expect(page.all('ul.content-list > li').last.text).to include('v2.0')
+ within ".milestones" do
+ expect(page.all("ul.content-list > li").first.text).to include("v1.0")
+ expect(page.all("ul.content-list > li")[1].text).to include("v3.0")
+ expect(page.all("ul.content-list > li").last.text).to include("v2.0")
end
end
end
diff --git a/spec/features/groups/settings/ci_cd_spec.rb b/spec/features/groups/settings/ci_cd_spec.rb
index d422fd18346..b892ca31f6a 100644
--- a/spec/features/groups/settings/ci_cd_spec.rb
+++ b/spec/features/groups/settings/ci_cd_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Group CI/CD settings' do
+describe "Group CI/CD settings" do
include WaitForRequests
let(:user) {create(:user)}
@@ -13,25 +13,25 @@ describe 'Group CI/CD settings' do
sign_in(user)
end
- describe 'runners registration token' do
+ describe "runners registration token" do
let!(:token) { group.runners_token }
before do
visit group_settings_ci_cd_path(group)
end
- it 'has a registration token' do
- expect(page.find('#registration_token')).to have_content(token)
+ it "has a registration token" do
+ expect(page.find("#registration_token")).to have_content(token)
end
- describe 'reload registration token' do
- let(:page_token) { find('#registration_token').text }
+ describe "reload registration token" do
+ let(:page_token) { find("#registration_token").text }
before do
- click_button 'Reset runners registration token'
+ click_button "Reset runners registration token"
end
- it 'changes registration token' do
+ it "changes registration token" do
expect(page_token).not_to eq token
end
end
diff --git a/spec/features/groups/settings/group_badges_spec.rb b/spec/features/groups/settings/group_badges_spec.rb
index a5c8dbf18d0..dde5948fd04 100644
--- a/spec/features/groups/settings/group_badges_spec.rb
+++ b/spec/features/groups/settings/group_badges_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group Badges' do
+describe "Group Badges" do
include WaitForRequests
let(:user) { create(:user) }
let(:group) { create(:group) }
- let(:badge_link_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/commits/master'}
- let(:badge_image_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg'}
+ let(:badge_link_url) { "https://gitlab.com/gitlab-org/gitlab-ee/commits/master"}
+ let(:badge_image_url) { "https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg"}
let!(:badge_1) { create(:group_badge, group: group) }
let!(:badge_2) { create(:group_badge, group: group) }
@@ -17,106 +17,106 @@ describe 'Group Badges' do
visit(edit_group_path(group))
end
- it 'shows a list of badges', :js do
- page.within '.badge-settings' do
+ it "shows a list of badges", :js do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
expect(rows[0]).to have_content badge_1.link_url
expect(rows[1]).to have_content badge_2.link_url
end
end
- context 'adding a badge', :js do
- it 'user can preview a badge' do
- page.within '.badge-settings form' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
- within '#badge-preview' do
- expect(find('a')[:href]).to eq badge_link_url
- expect(find('a img')[:src]).to eq badge_image_url
+ context "adding a badge", :js do
+ it "user can preview a badge" do
+ page.within ".badge-settings form" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
+ within "#badge-preview" do
+ expect(find("a")[:href]).to eq badge_link_url
+ expect(find("a img")[:src]).to eq badge_image_url
end
end
end
it do
- page.within '.badge-settings' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
+ page.within ".badge-settings" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
- click_button 'Add badge'
+ click_button "Add badge"
wait_for_requests
- within '.card-body' do
- expect(find('a')[:href]).to eq badge_link_url
- expect(find('a img')[:src]).to eq badge_image_url
+ within ".card-body" do
+ expect(find("a")[:href]).to eq badge_link_url
+ expect(find("a img")[:src]).to eq badge_image_url
end
end
end
end
- context 'editing a badge', :js do
- it 'form is shown when clicking edit button in list' do
- page.within '.badge-settings' do
+ context "editing a badge", :js do
+ it "form is shown when clicking edit button in list" do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
rows[1].find('[aria-label="Edit"]').click
- within 'form' do
- expect(find('#badge-link-url').value).to eq badge_2.link_url
- expect(find('#badge-image-url').value).to eq badge_2.image_url
+ within "form" do
+ expect(find("#badge-link-url").value).to eq badge_2.link_url
+ expect(find("#badge-image-url").value).to eq badge_2.image_url
end
end
end
- it 'updates a badge when submitting the edit form' do
- page.within '.badge-settings' do
+ it "updates a badge when submitting the edit form" do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
rows[1].find('[aria-label="Edit"]').click
- within 'form' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
+ within "form" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
- click_button 'Save changes'
+ click_button "Save changes"
wait_for_requests
end
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
expect(rows[1]).to have_content badge_link_url
end
end
end
- context 'deleting a badge', :js do
+ context "deleting a badge", :js do
def click_delete_button(badge_row)
badge_row.find('[aria-label="Delete"]').click
end
- it 'shows a modal when deleting a badge' do
+ it "shows a modal when deleting a badge" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
click_delete_button(rows[1])
- expect(find('.modal .modal-title')).to have_content 'Delete badge?'
+ expect(find(".modal .modal-title")).to have_content "Delete badge?"
end
- it 'deletes a badge when confirming the modal' do
+ it "deletes a badge when confirming the modal" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
click_delete_button(rows[1])
- find('.modal .btn-danger').click
+ find(".modal .btn-danger").click
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 1
expect(rows[0]).to have_content badge_1.link_url
end
diff --git a/spec/features/groups/share_lock_spec.rb b/spec/features/groups/share_lock_spec.rb
index 704d9f12888..7865168ce4d 100644
--- a/spec/features/groups/share_lock_spec.rb
+++ b/spec/features/groups/share_lock_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group share with group lock' do
+describe "Group share with group lock" do
let(:root_owner) { create(:user) }
let(:root_group) { create(:group) }
@@ -9,11 +9,11 @@ describe 'Group share with group lock' do
sign_in(root_owner)
end
- context 'with a subgroup', :nested_groups do
+ context "with a subgroup", :nested_groups do
let!(:subgroup) { create(:group, parent: root_group) }
- context 'when enabling the parent group share with group lock' do
- it 'the subgroup share with group lock becomes enabled' do
+ context "when enabling the parent group share with group lock" do
+ it "the subgroup share with group lock becomes enabled" do
visit edit_group_path(root_group)
enable_group_lock
@@ -22,15 +22,15 @@ describe 'Group share with group lock' do
end
end
- context 'when disabling the parent group share with group lock (which was already enabled)' do
+ context "when disabling the parent group share with group lock (which was already enabled)" do
before do
visit edit_group_path(root_group)
enable_group_lock
end
- context 'and the subgroup share with group lock is enabled' do
- it 'the subgroup share with group lock does not change' do
+ context "and the subgroup share with group lock is enabled" do
+ it "the subgroup share with group lock does not change" do
visit edit_group_path(root_group)
disable_group_lock
@@ -39,14 +39,14 @@ describe 'Group share with group lock' do
end
end
- context 'but the subgroup share with group lock is disabled' do
+ context "but the subgroup share with group lock is disabled" do
before do
visit edit_group_path(subgroup)
disable_group_lock
end
- it 'the subgroup share with group lock does not change' do
+ it "the subgroup share with group lock does not change" do
visit edit_group_path(root_group)
disable_group_lock
@@ -58,16 +58,16 @@ describe 'Group share with group lock' do
end
def enable_group_lock
- page.within('.gs-permissions') do
- check 'group_share_with_group_lock'
- click_on 'Save changes'
+ page.within(".gs-permissions") do
+ check "group_share_with_group_lock"
+ click_on "Save changes"
end
end
def disable_group_lock
- page.within('.gs-permissions') do
- uncheck 'group_share_with_group_lock'
- click_on 'Save changes'
+ page.within(".gs-permissions") do
+ uncheck "group_share_with_group_lock"
+ click_on "Save changes"
end
end
end
diff --git a/spec/features/groups/show_spec.rb b/spec/features/groups/show_spec.rb
index 9671a4d8c49..e401f395212 100644
--- a/spec/features/groups/show_spec.rb
+++ b/spec/features/groups/show_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group show page' do
+describe "Group show page" do
let(:group) { create(:group) }
let(:path) { group_path(group) }
- context 'when signed in' do
+ context "when signed in" do
let(:user) do
- create(:group_member, :developer, user: create(:user), group: group ).user
+ create(:group_member, :developer, user: create(:user), group: group).user
end
before do
@@ -16,15 +16,15 @@ describe 'Group show page' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
- context 'when group does not exist' do
- let(:path) { group_path('not-exist') }
+ context "when group does not exist" do
+ let(:path) { group_path("not-exist") }
it { expect(status_code).to eq(404) }
end
end
- context 'when signed out' do
- describe 'RSS' do
+ context "when signed out" do
+ describe "RSS" do
before do
visit path
end
@@ -32,10 +32,10 @@ describe 'Group show page' do
it_behaves_like "an autodiscoverable RSS feed without a feed token"
end
- context 'when group has a public project', :js do
+ context "when group has a public project", :js do
let!(:project) { create(:project, :public, namespace: group) }
- it 'renders public project' do
+ it "renders public project" do
visit path
expect(page).to have_link group.name
@@ -43,10 +43,10 @@ describe 'Group show page' do
end
end
- context 'when group has a private project', :js do
+ context "when group has a private project", :js do
let!(:project) { create(:project, :private, namespace: group) }
- it 'does not render private project' do
+ it "does not render private project" do
visit path
expect(page).to have_link group.name
@@ -55,7 +55,7 @@ describe 'Group show page' do
end
end
- context 'subgroup support' do
+ context "subgroup support" do
let(:user) { create(:user) }
before do
@@ -63,32 +63,32 @@ describe 'Group show page' do
sign_in(user)
end
- context 'when subgroups are supported', :js, :nested_groups do
+ context "when subgroups are supported", :js, :nested_groups do
before do
allow(Group).to receive(:supports_nested_objects?) { true }
visit path
end
- it 'allows creating subgroups' do
+ it "allows creating subgroups" do
expect(page).to have_css("li[data-text='New subgroup']", visible: false)
end
end
- context 'when subgroups are not supported' do
+ context "when subgroups are not supported" do
before do
allow(Group).to receive(:supports_nested_objects?) { false }
visit path
end
- it 'allows creating subgroups' do
+ it "allows creating subgroups" do
expect(page).not_to have_selector("li[data-text='New subgroup']", visible: false)
end
end
end
- context 'group has a project with emoji in description', :js do
+ context "group has a project with emoji in description", :js do
let(:user) { create(:user) }
- let!(:project) { create(:project, description: ':smile:', namespace: group) }
+ let!(:project) { create(:project, description: ":smile:", namespace: group) }
before do
group.add_owner(user)
@@ -96,13 +96,13 @@ describe 'Group show page' do
visit path
end
- it 'shows the project info' do
+ it "shows the project info" do
expect(page).to have_content(project.title)
- expect(page).to have_emoji('smile')
+ expect(page).to have_emoji("smile")
end
end
- context 'where group has projects' do
+ context "where group has projects" do
let(:user) { create(:user) }
before do
@@ -110,16 +110,16 @@ describe 'Group show page' do
sign_in(user)
end
- it 'allows users to sorts projects by most stars', :js do
+ it "allows users to sorts projects by most stars", :js do
project1 = create(:project, namespace: group, star_count: 2)
project2 = create(:project, namespace: group, star_count: 3)
project3 = create(:project, namespace: group, star_count: 0)
visit group_path(group, sort: :stars_desc)
- expect(find('.group-row:nth-child(1) .namespace-title > a')).to have_content(project2.title)
- expect(find('.group-row:nth-child(2) .namespace-title > a')).to have_content(project1.title)
- expect(find('.group-row:nth-child(3) .namespace-title > a')).to have_content(project3.title)
+ expect(find(".group-row:nth-child(1) .namespace-title > a")).to have_content(project2.title)
+ expect(find(".group-row:nth-child(2) .namespace-title > a")).to have_content(project1.title)
+ expect(find(".group-row:nth-child(3) .namespace-title > a")).to have_content(project3.title)
end
end
end
diff --git a/spec/features/groups/user_browse_projects_group_page_spec.rb b/spec/features/groups/user_browse_projects_group_page_spec.rb
index 916363c41dd..7fdf81c37d0 100644
--- a/spec/features/groups/user_browse_projects_group_page_spec.rb
+++ b/spec/features/groups/user_browse_projects_group_page_spec.rb
@@ -1,27 +1,27 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User browse group projects page' do
+describe "User browse group projects page" do
let(:user) { create :user }
let(:group) { create :group }
- context 'when user is owner' do
+ context "when user is owner" do
before do
group.add_owner(user)
end
- context 'when user signed in' do
+ context "when user signed in" do
before do
sign_in(user)
end
- context 'when group has archived project', :js do
+ context "when group has archived project", :js do
let!(:project) { create :project, :archived, namespace: group }
- it 'renders projects list' do
+ it "renders projects list" do
visit projects_group_path(group)
expect(page).to have_link project.name
- expect(page).to have_xpath("//span[@class='badge badge-warning']", text: 'archived')
+ expect(page).to have_xpath("//span[@class='badge badge-warning']", text: "archived")
end
end
end
diff --git a/spec/features/groups/user_sees_users_dropdowns_in_issuables_list_spec.rb b/spec/features/groups/user_sees_users_dropdowns_in_issuables_list_spec.rb
index 6d6f206d761..9ef501cef49 100644
--- a/spec/features/groups/user_sees_users_dropdowns_in_issuables_list_spec.rb
+++ b/spec/features/groups/user_sees_users_dropdowns_in_issuables_list_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups > User sees users dropdowns in issuables list' do
+describe "Groups > User sees users dropdowns in issuables list" do
let(:entity) { create(:group) }
let(:user_in_dropdown) { create(:user) }
let!(:user_not_in_dropdown) { create(:user) }
@@ -10,12 +10,12 @@ describe 'Groups > User sees users dropdowns in issuables list' do
entity.add_developer(user_in_dropdown)
end
- it_behaves_like 'issuable user dropdown behaviors' do
+ it_behaves_like "issuable user dropdown behaviors" do
let(:issuable) { create(:issue, project: project) }
let(:issuables_path) { issues_group_path(entity) }
end
- it_behaves_like 'issuable user dropdown behaviors' do
+ it_behaves_like "issuable user dropdown behaviors" do
let(:issuable) { create(:merge_request, source_project: project) }
let(:issuables_path) { merge_requests_group_path(entity) }
end
diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb
index c2f32c76422..64468f259dc 100644
--- a/spec/features/groups_spec.rb
+++ b/spec/features/groups_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group' do
+describe "Group" do
let(:user) { create(:admin) }
before do
@@ -13,118 +13,118 @@ describe 'Group' do
end
end
- describe 'create a group' do
+ describe "create a group" do
before do
visit new_group_path
end
- describe 'as a non-admin' do
+ describe "as a non-admin" do
let(:user) { create(:user) }
- it 'creates a group and persists visibility radio selection', :js do
+ it "creates a group and persists visibility radio selection", :js do
stub_application_setting(default_group_visibility: :private)
- fill_in 'Group name', with: 'test-group'
+ fill_in "Group name", with: "test-group"
find("input[name='group[visibility_level]'][value='#{Gitlab::VisibilityLevel::PUBLIC}']").click
- click_button 'Create group'
+ click_button "Create group"
- group = Group.find_by(name: 'test-group')
+ group = Group.find_by(name: "test-group")
expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
expect(current_path).to eq(group_path(group))
- expect(page).to have_selector '.visibility-icon .fa-globe'
+ expect(page).to have_selector ".visibility-icon .fa-globe"
end
end
- describe 'with space in group path' do
- it 'renders new group form with validation errors' do
- fill_in 'Group URL', with: 'space group'
- click_button 'Create group'
+ describe "with space in group path" do
+ it "renders new group form with validation errors" do
+ fill_in "Group URL", with: "space group"
+ click_button "Create group"
expect(current_path).to eq(groups_path)
expect(page).to have_namespace_error_message
end
end
- describe 'with .atom at end of group path' do
- it 'renders new group form with validation errors' do
- fill_in 'Group URL', with: 'atom_group.atom'
- click_button 'Create group'
+ describe "with .atom at end of group path" do
+ it "renders new group form with validation errors" do
+ fill_in "Group URL", with: "atom_group.atom"
+ click_button "Create group"
expect(current_path).to eq(groups_path)
expect(page).to have_namespace_error_message
end
end
- describe 'with .git at end of group path' do
- it 'renders new group form with validation errors' do
- fill_in 'Group URL', with: 'git_group.git'
- click_button 'Create group'
+ describe "with .git at end of group path" do
+ it "renders new group form with validation errors" do
+ fill_in "Group URL", with: "git_group.git"
+ click_button "Create group"
expect(current_path).to eq(groups_path)
expect(page).to have_namespace_error_message
end
end
- describe 'Mattermost team creation' do
+ describe "Mattermost team creation" do
before do
stub_mattermost_setting(enabled: mattermost_enabled)
visit new_group_path
end
- context 'Mattermost enabled' do
+ context "Mattermost enabled" do
let(:mattermost_enabled) { true }
- it 'displays a team creation checkbox' do
- expect(page).to have_selector('#group_create_chat_team')
+ it "displays a team creation checkbox" do
+ expect(page).to have_selector("#group_create_chat_team")
end
- it 'checks the checkbox by default' do
- expect(find('#group_create_chat_team')['checked']).to eq(true)
+ it "checks the checkbox by default" do
+ expect(find("#group_create_chat_team")["checked"]).to eq(true)
end
- it 'updates the team URL on graph path update', :js do
+ it "updates the team URL on graph path update", :js do
out_span = find('span[data-bind-out="create_chat_team"]', visible: false)
expect(out_span.text).to be_empty
- fill_in('group_path', with: 'test-group')
+ fill_in("group_path", with: "test-group")
- expect(out_span.text).to eq('test-group')
+ expect(out_span.text).to eq("test-group")
end
end
- context 'Mattermost disabled' do
+ context "Mattermost disabled" do
let(:mattermost_enabled) { false }
- it 'doesnt show a team creation checkbox if Mattermost not enabled' do
- expect(page).not_to have_selector('#group_create_chat_team')
+ it "doesnt show a team creation checkbox if Mattermost not enabled" do
+ expect(page).not_to have_selector("#group_create_chat_team")
end
end
end
end
- describe 'create a nested group', :nested_groups, :js do
- let(:group) { create(:group, path: 'foo') }
+ describe "create a nested group", :nested_groups, :js do
+ let(:group) { create(:group, path: "foo") }
- context 'as admin' do
+ context "as admin" do
before do
visit new_group_path(group, parent_id: group.id)
end
- it 'creates a nested group' do
- fill_in 'Group name', with: 'bar'
- fill_in 'Group URL', with: 'bar'
- click_button 'Create group'
+ it "creates a nested group" do
+ fill_in "Group name", with: "bar"
+ fill_in "Group URL", with: "bar"
+ click_button "Create group"
- expect(current_path).to eq(group_path('foo/bar'))
+ expect(current_path).to eq(group_path("foo/bar"))
expect(page).to have_content("Group 'bar' was successfully created.")
end
end
- context 'as group owner' do
- it 'creates a nested group' do
+ context "as group owner" do
+ it "creates a nested group" do
user = create(:user)
group.add_owner(user)
@@ -133,111 +133,111 @@ describe 'Group' do
visit new_group_path(group, parent_id: group.id)
- fill_in 'Group name', with: 'bar'
- fill_in 'Group URL', with: 'bar'
- click_button 'Create group'
+ fill_in "Group name", with: "bar"
+ fill_in "Group URL", with: "bar"
+ click_button "Create group"
- expect(current_path).to eq(group_path('foo/bar'))
+ expect(current_path).to eq(group_path("foo/bar"))
expect(page).to have_content("Group 'bar' was successfully created.")
end
end
end
- it 'checks permissions to avoid exposing groups by parent_id' do
- group = create(:group, :private, path: 'secret-group')
+ it "checks permissions to avoid exposing groups by parent_id" do
+ group = create(:group, :private, path: "secret-group")
sign_out(:user)
sign_in(create(:user))
visit new_group_path(parent_id: group.id)
- expect(page).not_to have_content('secret-group')
+ expect(page).not_to have_content("secret-group")
end
- describe 'group edit', :js do
+ describe "group edit", :js do
let(:group) { create(:group, :public) }
let(:path) { edit_group_path(group) }
- let(:new_name) { 'new-name' }
+ let(:new_name) { "new-name" }
before do
visit path
end
- it_behaves_like 'dirty submit form', [{ form: '.js-general-settings-form', input: 'input[name="group[name]"]' },
- { form: '.js-general-settings-form', input: '#group_visibility_level_0' },
- { form: '.js-general-permissions-form', input: '#group_request_access_enabled' },
- { form: '.js-general-permissions-form', input: 'input[name="group[two_factor_grace_period]"]' }]
+ it_behaves_like "dirty submit form", [{form: ".js-general-settings-form", input: 'input[name="group[name]"]'},
+ {form: ".js-general-settings-form", input: "#group_visibility_level_0"},
+ {form: ".js-general-permissions-form", input: "#group_request_access_enabled"},
+ {form: ".js-general-permissions-form", input: 'input[name="group[two_factor_grace_period]"]'},]
- it 'saves new settings' do
- page.within('.gs-general') do
- fill_in 'group_name', with: new_name
- click_button 'Save changes'
+ it "saves new settings" do
+ page.within(".gs-general") do
+ fill_in "group_name", with: new_name
+ click_button "Save changes"
end
- expect(page).to have_content 'successfully updated'
- expect(find('#group_name').value).to eq(new_name)
+ expect(page).to have_content "successfully updated"
+ expect(find("#group_name").value).to eq(new_name)
page.within ".breadcrumbs" do
expect(page).to have_content new_name
end
end
- it 'focuses confirmation field on remove group' do
- click_button('Remove group')
+ it "focuses confirmation field on remove group" do
+ click_button("Remove group")
- expect(page).to have_selector '#confirm_name_input:focus'
+ expect(page).to have_selector "#confirm_name_input:focus"
end
- it 'removes group' do
- expect { remove_with_confirm('Remove group', group.path) }.to change {Group.count}.by(-1)
+ it "removes group" do
+ expect { remove_with_confirm("Remove group", group.path) }.to change {Group.count}.by(-1)
expect(group.members.all.count).to be_zero
expect(page).to have_content "scheduled for deletion"
end
end
- describe 'group page with markdown description' do
+ describe "group page with markdown description" do
let(:group) { create(:group) }
let(:path) { group_path(group) }
- it 'parses Markdown' do
- group.update_attribute(:description, 'This is **my** group')
+ it "parses Markdown" do
+ group.update_attribute(:description, "This is **my** group")
visit path
- expect(page).to have_css('.home-panel-description-markdown > p > strong')
+ expect(page).to have_css(".home-panel-description-markdown > p > strong")
end
- it 'passes through html-pipeline' do
- group.update_attribute(:description, 'This group is the :poop:')
+ it "passes through html-pipeline" do
+ group.update_attribute(:description, "This group is the :poop:")
visit path
- expect(page).to have_css('.home-panel-description-markdown > p > gl-emoji')
+ expect(page).to have_css(".home-panel-description-markdown > p > gl-emoji")
end
- it 'sanitizes unwanted tags' do
- group.update_attribute(:description, '# Group Description')
+ it "sanitizes unwanted tags" do
+ group.update_attribute(:description, "# Group Description")
visit path
- expect(page).not_to have_css('.home-panel-description-markdown h1')
+ expect(page).not_to have_css(".home-panel-description-markdown h1")
end
- it 'permits `rel` attribute on links' do
- group.update_attribute(:description, 'https://google.com/')
+ it "permits `rel` attribute on links" do
+ group.update_attribute(:description, "https://google.com/")
visit path
- expect(page).to have_css('.home-panel-description-markdown a[rel]')
+ expect(page).to have_css(".home-panel-description-markdown a[rel]")
end
end
- describe 'group page with nested groups', :nested_groups, :js do
+ describe "group page with nested groups", :nested_groups, :js do
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, namespace: group) }
let!(:path) { group_path(group) }
- it 'it renders projects and groups on the page' do
+ it "it renders projects and groups on the page" do
visit path
wait_for_requests
@@ -248,7 +248,7 @@ describe 'Group' do
def remove_with_confirm(button_text, confirm_with)
click_button button_text
- fill_in 'confirm_name_input', with: confirm_with
- click_button 'Confirm'
+ fill_in "confirm_name_input", with: confirm_with
+ click_button "Confirm"
end
end
diff --git a/spec/features/help_pages_spec.rb b/spec/features/help_pages_spec.rb
index e24b1f4349d..f5ee7369ee5 100644
--- a/spec/features/help_pages_spec.rb
+++ b/spec/features/help_pages_spec.rb
@@ -1,96 +1,96 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Help Pages' do
- describe 'Get the main help page' do
- shared_examples_for 'help page' do |prefix: ''|
- it 'prefixes links correctly' do
+describe "Help Pages" do
+ describe "Get the main help page" do
+ shared_examples_for "help page" do |prefix: ""|
+ it "prefixes links correctly" do
expect(page).to have_selector(%(div.documentation-index > table tbody tr td a[href="#{prefix}/help/api/README.md"]))
end
end
- context 'without a trailing slash' do
+ context "without a trailing slash" do
before do
visit help_path
end
- it_behaves_like 'help page'
+ it_behaves_like "help page"
end
- context 'with a trailing slash' do
+ context "with a trailing slash" do
before do
- visit help_path + '/'
+ visit help_path + "/"
end
- it_behaves_like 'help page'
+ it_behaves_like "help page"
end
- context 'with a relative installation' do
+ context "with a relative installation" do
before do
- stub_config_setting(relative_url_root: '/gitlab')
+ stub_config_setting(relative_url_root: "/gitlab")
visit help_path
end
- it_behaves_like 'help page', prefix: '/gitlab'
+ it_behaves_like "help page", prefix: "/gitlab"
end
- context 'quick link shortcuts', :js do
+ context "quick link shortcuts", :js do
before do
visit help_path
end
- it 'focuses search bar' do
- find('.js-trigger-search-bar').click
+ it "focuses search bar" do
+ find(".js-trigger-search-bar").click
- expect(page).to have_selector('#search:focus')
+ expect(page).to have_selector("#search:focus")
end
- it 'opens shortcuts help dialog' do
- find('.js-trigger-shortcut').click
+ it "opens shortcuts help dialog" do
+ find(".js-trigger-shortcut").click
- expect(page).to have_selector('#modal-shortcuts')
+ expect(page).to have_selector("#modal-shortcuts")
end
end
end
- context 'in a production environment with version check enabled' do
+ context "in a production environment with version check enabled" do
before do
stub_application_setting(version_check_enabled: true)
allow(Rails.env).to receive(:production?).and_return(true)
- allow(VersionCheck).to receive(:url).and_return('/version-check-url')
+ allow(VersionCheck).to receive(:url).and_return("/version-check-url")
sign_in(create(:user))
visit help_path
end
- it 'has a version check image' do
+ it "has a version check image" do
# Check `data-src` due to lazy image loading
- expect(find('.js-version-status-badge', visible: false)['data-src'])
- .to end_with('/version-check-url')
+ expect(find(".js-version-status-badge", visible: false)["data-src"])
+ .to end_with("/version-check-url")
end
end
- describe 'when help page is customized' do
+ describe "when help page is customized" do
before do
stub_application_setting(help_page_hide_commercial_content: true,
- help_page_text: 'My Custom Text',
- help_page_support_url: 'http://example.com/help')
+ help_page_text: "My Custom Text",
+ help_page_support_url: "http://example.com/help")
sign_in(create(:user))
visit help_path
end
- it 'should display custom help page text' do
+ it "should display custom help page text" do
expect(page).to have_text "My Custom Text"
end
- it 'should hide marketing content when enabled' do
+ it "should hide marketing content when enabled" do
expect(page).not_to have_link "Get a support subscription"
end
- it 'should use a custom support url' do
+ it "should use a custom support url" do
expect(page).to have_link "See our website for getting help", href: "http://example.com/help"
end
end
diff --git a/spec/features/ics/dashboard_issues_spec.rb b/spec/features/ics/dashboard_issues_spec.rb
index debae0ea930..7f2a8b058a6 100644
--- a/spec/features/ics/dashboard_issues_spec.rb
+++ b/spec/features/ics/dashboard_issues_spec.rb
@@ -1,101 +1,101 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dashboard Issues Calendar Feed' do
- describe 'GET /issues' do
- let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
- let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
+describe "Dashboard Issues Calendar Feed" do
+ describe "GET /issues" do
+ let!(:user) { create(:user, email: "private1@example.com", public_email: "public1@example.com") }
+ let!(:assignee) { create(:user, email: "private2@example.com", public_email: "public2@example.com") }
let!(:project) { create(:project) }
- let(:milestone) { create(:milestone, project_id: project.id, title: 'v1.0') }
+ let(:milestone) { create(:milestone, project_id: project.id, title: "v1.0") }
before do
project.add_maintainer(user)
end
- context 'when authenticated' do
- context 'with no referer' do
- it 'renders calendar feed' do
+ context "when authenticated" do
+ context "with no referer" do
+ it "renders calendar feed" do
sign_in user
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date')
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date")
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'with GitLab as the referer' do
- it 'renders calendar feed as text/plain' do
+ context "with GitLab as the referer" do
+ it "renders calendar feed as text/plain" do
sign_in user
- page.driver.header('Referer', issues_dashboard_url(host: Settings.gitlab.base_url))
+ page.driver.header("Referer", issues_dashboard_url(host: Settings.gitlab.base_url))
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date')
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date")
- expect(response_headers['Content-Type']).to have_content('text/plain')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/plain")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'when filtered by milestone' do
- it 'renders calendar feed' do
+ context "when filtered by milestone" do
+ it "renders calendar feed" do
sign_in user
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date',
- milestone_title: milestone.title)
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date",
+ milestone_title: milestone.title)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
end
- context 'when authenticated via personal access token' do
- it 'renders calendar feed' do
+ context "when authenticated via personal access token" do
+ it "renders calendar feed" do
personal_access_token = create(:personal_access_token, user: user)
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date',
- private_token: personal_access_token.token)
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date",
+ private_token: personal_access_token.token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'when authenticated via feed token' do
- it 'renders calendar feed' do
+ context "when authenticated via feed token" do
+ it "renders calendar feed" do
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date',
- feed_token: user.feed_token)
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date",
+ feed_token: user.feed_token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'issue with due date' do
+ context "issue with due date" do
let!(:issue) do
- create(:issue, author: user, assignees: [assignee], project: project, title: 'test title',
- description: 'test desc', due_date: Date.tomorrow)
+ create(:issue, author: user, assignees: [assignee], project: project, title: "test title",
+ description: "test desc", due_date: Date.tomorrow)
end
- it 'renders issue fields' do
+ it "renders issue fields" do
visit issues_dashboard_path(:ics,
- due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
- sort: 'closest_future_date',
- feed_token: user.feed_token)
+ due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name,
+ sort: "closest_future_date",
+ feed_token: user.feed_token)
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars
expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
expect(body).to have_text(expected_description)
- expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
+ expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime("%Y%m%d")}")
expect(body).to have_text("URL:#{issue_url(issue)}")
- expect(body).to have_text('TRANSP:TRANSPARENT')
+ expect(body).to have_text("TRANSP:TRANSPARENT")
end
end
end
diff --git a/spec/features/ics/group_issues_spec.rb b/spec/features/ics/group_issues_spec.rb
index 4177c7f8704..1fc60c46f1a 100644
--- a/spec/features/ics/group_issues_spec.rb
+++ b/spec/features/ics/group_issues_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Group Issues Calendar Feed' do
- describe 'GET /issues' do
- let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
- let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
+describe "Group Issues Calendar Feed" do
+ describe "GET /issues" do
+ let!(:user) { create(:user, email: "private1@example.com", public_email: "public1@example.com") }
+ let!(:assignee) { create(:user, email: "private2@example.com", public_email: "public2@example.com") }
let!(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
@@ -12,65 +12,65 @@ describe 'Group Issues Calendar Feed' do
group.add_developer(user)
end
- context 'when authenticated' do
- context 'with no referer' do
- it 'renders calendar feed' do
+ context "when authenticated" do
+ context "with no referer" do
+ it "renders calendar feed" do
sign_in user
visit issues_group_path(group, :ics)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'with GitLab as the referer' do
- it 'renders calendar feed as text/plain' do
+ context "with GitLab as the referer" do
+ it "renders calendar feed as text/plain" do
sign_in user
- page.driver.header('Referer', issues_group_url(group, host: Settings.gitlab.base_url))
+ page.driver.header("Referer", issues_group_url(group, host: Settings.gitlab.base_url))
visit issues_group_path(group, :ics)
- expect(response_headers['Content-Type']).to have_content('text/plain')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/plain")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
end
- context 'when authenticated via personal access token' do
- it 'renders calendar feed' do
+ context "when authenticated via personal access token" do
+ it "renders calendar feed" do
personal_access_token = create(:personal_access_token, user: user)
visit issues_group_path(group, :ics, private_token: personal_access_token.token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'when authenticated via feed token' do
- it 'renders calendar feed' do
+ context "when authenticated via feed token" do
+ it "renders calendar feed" do
visit issues_group_path(group, :ics, feed_token: user.feed_token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'issue with due date' do
+ context "issue with due date" do
let!(:issue) do
- create(:issue, author: user, assignees: [assignee], project: project, title: 'test title',
- description: 'test desc', due_date: Date.tomorrow)
+ create(:issue, author: user, assignees: [assignee], project: project, title: "test title",
+ description: "test desc", due_date: Date.tomorrow)
end
- it 'renders issue fields' do
+ it "renders issue fields" do
visit issues_group_path(group, :ics, feed_token: user.feed_token)
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars
expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
expect(body).to have_text(expected_description)
- expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
+ expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime("%Y%m%d")}")
expect(body).to have_text("URL:#{issue_url(issue)}")
- expect(body).to have_text('TRANSP:TRANSPARENT')
+ expect(body).to have_text("TRANSP:TRANSPARENT")
end
end
end
diff --git a/spec/features/ics/project_issues_spec.rb b/spec/features/ics/project_issues_spec.rb
index 0d9844be099..e36011ad63f 100644
--- a/spec/features/ics/project_issues_spec.rb
+++ b/spec/features/ics/project_issues_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Issues Calendar Feed' do
- describe 'GET /issues' do
- let!(:user) { create(:user, email: 'private1@example.com', public_email: 'public1@example.com') }
- let!(:assignee) { create(:user, email: 'private2@example.com', public_email: 'public2@example.com') }
+describe "Project Issues Calendar Feed" do
+ describe "GET /issues" do
+ let!(:user) { create(:user, email: "private1@example.com", public_email: "public1@example.com") }
+ let!(:assignee) { create(:user, email: "private2@example.com", public_email: "public2@example.com") }
let!(:project) { create(:project) }
let!(:issue) { create(:issue, author: user, assignees: [assignee], project: project) }
@@ -11,74 +11,74 @@ describe 'Project Issues Calendar Feed' do
project.add_developer(user)
end
- context 'when authenticated' do
- context 'with no referer' do
- it 'renders calendar feed' do
+ context "when authenticated" do
+ context "with no referer" do
+ it "renders calendar feed" do
sign_in user
visit project_issues_path(project, :ics)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'with GitLab as the referer' do
- it 'renders calendar feed as text/plain' do
+ context "with GitLab as the referer" do
+ it "renders calendar feed as text/plain" do
sign_in user
- page.driver.header('Referer', project_issues_url(project, host: Settings.gitlab.base_url))
+ page.driver.header("Referer", project_issues_url(project, host: Settings.gitlab.base_url))
visit project_issues_path(project, :ics)
- expect(response_headers['Content-Type']).to have_content('text/plain')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/plain")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
end
- context 'when authenticated via personal access token' do
- it 'renders calendar feed' do
+ context "when authenticated via personal access token" do
+ it "renders calendar feed" do
personal_access_token = create(:personal_access_token, user: user)
visit project_issues_path(project, :ics, private_token: personal_access_token.token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'when authenticated via feed token' do
- it 'renders calendar feed' do
+ context "when authenticated via feed token" do
+ it "renders calendar feed" do
visit project_issues_path(project, :ics, feed_token: user.feed_token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
- context 'issue with due date' do
+ context "issue with due date" do
let!(:issue) do
- create(:issue, author: user, assignees: [assignee], project: project, title: 'test title',
- description: 'test desc', due_date: Date.tomorrow)
+ create(:issue, author: user, assignees: [assignee], project: project, title: "test title",
+ description: "test desc", due_date: Date.tomorrow)
end
- it 'renders issue fields' do
+ it "renders issue fields" do
visit project_issues_path(project, :ics, feed_token: user.feed_token)
expect(body).to have_text("SUMMARY:test title (in #{project.full_path})")
# line length for ics is 75 chars
expected_description = "DESCRIPTION:Find out more at #{issue_url(issue)}".insert(75, "\r\n")
expect(body).to have_text(expected_description)
- expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime('%Y%m%d')}")
+ expect(body).to have_text("DTSTART;VALUE=DATE:#{Date.tomorrow.strftime("%Y%m%d")}")
expect(body).to have_text("URL:#{issue_url(issue)}")
- expect(body).to have_text('TRANSP:TRANSPARENT')
+ expect(body).to have_text("TRANSP:TRANSPARENT")
end
end
- context 'sorted by priority' do
- it 'renders calendar feed' do
- visit project_issues_path(project, :ics, sort: 'priority', feed_token: user.feed_token)
+ context "sorted by priority" do
+ it "renders calendar feed" do
+ visit project_issues_path(project, :ics, sort: "priority", feed_token: user.feed_token)
- expect(response_headers['Content-Type']).to have_content('text/calendar')
- expect(body).to have_text('BEGIN:VCALENDAR')
+ expect(response_headers["Content-Type"]).to have_content("text/calendar")
+ expect(body).to have_text("BEGIN:VCALENDAR")
end
end
end
diff --git a/spec/features/ide_spec.rb b/spec/features/ide_spec.rb
index 6eb59ef72c2..014b95ac046 100644
--- a/spec/features/ide_spec.rb
+++ b/spec/features/ide_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'IDE', :js do
- describe 'sub-groups', :nested_groups do
+describe "IDE", :js do
+ describe "sub-groups", :nested_groups do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
@@ -13,13 +13,13 @@ describe 'IDE', :js do
visit project_path(subgroup_project)
- click_link('Web IDE')
+ click_link("Web IDE")
wait_for_requests
end
- it 'loads project in web IDE' do
- expect(page).to have_selector('.context-header', text: subgroup_project.name)
+ it "loads project in web IDE" do
+ expect(page).to have_selector(".context-header", text: subgroup_project.name)
end
end
end
diff --git a/spec/features/import/manifest_import_spec.rb b/spec/features/import/manifest_import_spec.rb
index a90cdd8d920..0e77fb0120b 100644
--- a/spec/features/import/manifest_import_spec.rb
+++ b/spec/features/import/manifest_import_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Import multiple repositories by uploading a manifest file', :js, :postgresql do
+describe "Import multiple repositories by uploading a manifest file", :js, :postgresql do
include Select2Helper
let(:user) { create(:admin) }
@@ -12,40 +12,40 @@ describe 'Import multiple repositories by uploading a manifest file', :js, :post
group.add_owner(user)
end
- it 'parses manifest file and list repositories' do
+ it "parses manifest file and list repositories" do
visit new_import_manifest_path
- attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
- click_on 'List available repositories'
+ attach_file("manifest", Rails.root.join("spec/fixtures/aosp_manifest.xml"))
+ click_on "List available repositories"
- expect(page).to have_button('Import all repositories')
- expect(page).to have_content('https://android-review.googlesource.com/platform/build/blueprint')
+ expect(page).to have_button("Import all repositories")
+ expect(page).to have_content("https://android-review.googlesource.com/platform/build/blueprint")
end
- it 'imports successfully imports a project' do
+ it "imports successfully imports a project" do
visit new_import_manifest_path
- attach_file('manifest', Rails.root.join('spec/fixtures/aosp_manifest.xml'))
- click_on 'List available repositories'
+ attach_file("manifest", Rails.root.join("spec/fixtures/aosp_manifest.xml"))
+ click_on "List available repositories"
page.within(first_row) do
- click_on 'Import'
+ click_on "Import"
- expect(page).to have_content 'Done'
+ expect(page).to have_content "Done"
expect(page).to have_content("#{group.full_path}/build/make")
end
end
- it 'renders an error if invalid file was provided' do
+ it "renders an error if invalid file was provided" do
visit new_import_manifest_path
- attach_file('manifest', Rails.root.join('spec/fixtures/banana_sample.gif'))
- click_on 'List available repositories'
+ attach_file("manifest", Rails.root.join("spec/fixtures/banana_sample.gif"))
+ click_on "List available repositories"
- expect(page).to have_content 'The uploaded file is not a valid XML file.'
+ expect(page).to have_content "The uploaded file is not a valid XML file."
end
def first_row
- page.all('table.import-jobs tbody tr')[0]
+ page.all("table.import-jobs tbody tr")[0]
end
end
diff --git a/spec/features/instance_statistics/cohorts_spec.rb b/spec/features/instance_statistics/cohorts_spec.rb
index 40e65515ceb..74aae7b26dd 100644
--- a/spec/features/instance_statistics/cohorts_spec.rb
+++ b/spec/features/instance_statistics/cohorts_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Cohorts page' do
+describe "Cohorts page" do
before do
sign_in(create(:admin))
stub_application_setting(usage_ping_enabled: true)
end
- it 'See users count per month' do
+ it "See users count per month" do
2.times { create(:user) }
visit instance_statistics_cohorts_path
- expect(page).to have_content("#{Time.now.strftime('%b %Y')} 3 0")
+ expect(page).to have_content("#{Time.now.strftime("%b %Y")} 3 0")
end
end
diff --git a/spec/features/instance_statistics/conversational_development_index_spec.rb b/spec/features/instance_statistics/conversational_development_index_spec.rb
index d8be554d734..5011cc7cd5c 100644
--- a/spec/features/instance_statistics/conversational_development_index_spec.rb
+++ b/spec/features/instance_statistics/conversational_development_index_spec.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Conversational Development Index' do
+describe "Conversational Development Index" do
before do
sign_in(create(:admin))
end
- it 'has dismissable intro callout', :js do
+ it "has dismissable intro callout", :js do
visit instance_statistics_conversational_development_index_index_path
- expect(page).to have_content 'Introducing Your Conversational Development Index'
+ expect(page).to have_content "Introducing Your Conversational Development Index"
- find('.js-close-callout').click
+ find(".js-close-callout").click
- expect(page).not_to have_content 'Introducing Your Conversational Development Index'
+ expect(page).not_to have_content "Introducing Your Conversational Development Index"
end
- context 'when usage ping is disabled' do
+ context "when usage ping is disabled" do
before do
stub_application_setting(usage_ping_enabled: false)
end
- it 'shows empty state' do
+ it "shows empty state" do
visit instance_statistics_conversational_development_index_index_path
- expect(page).to have_content('Usage ping is not enabled')
+ expect(page).to have_content("Usage ping is not enabled")
end
- it 'hides the intro callout' do
+ it "hides the intro callout" do
visit instance_statistics_conversational_development_index_index_path
- expect(page).not_to have_content 'Introducing Your Conversational Development Index'
+ expect(page).not_to have_content "Introducing Your Conversational Development Index"
end
end
- context 'when there is no data to display' do
- it 'shows empty state' do
+ context "when there is no data to display" do
+ it "shows empty state" do
stub_application_setting(usage_ping_enabled: true)
visit instance_statistics_conversational_development_index_index_path
- expect(page).to have_content('Data is still calculating')
+ expect(page).to have_content("Data is still calculating")
end
end
- context 'when there is data to display' do
- it 'shows numbers for each metric' do
+ context "when there is data to display" do
+ it "shows numbers for each metric" do
stub_application_setting(usage_ping_enabled: true)
create(:conversational_development_index_metric)
visit instance_statistics_conversational_development_index_index_path
expect(page).to have_content(
- 'Issues created per active user 1.2 You 9.3 Lead 13.3%'
+ "Issues created per active user 1.2 You 9.3 Lead 13.3%"
)
end
end
diff --git a/spec/features/instance_statistics/instance_statistics.rb b/spec/features/instance_statistics/instance_statistics.rb
index d03e6e68075..15d7b0615b3 100644
--- a/spec/features/instance_statistics/instance_statistics.rb
+++ b/spec/features/instance_statistics/instance_statistics.rb
@@ -1,23 +1,23 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Cohorts page', :js do
+describe "Cohorts page", :js do
before do
sign_in(create(:admin))
end
- it 'hides cohorts nav button when usage ping is disabled' do
+ it "hides cohorts nav button when usage ping is disabled" do
stub_application_setting(usage_ping_enabled: false)
visit instance_statistics_root_path
- expect(find('.nav-sidebar')).not_to have_content('Cohorts')
+ expect(find(".nav-sidebar")).not_to have_content("Cohorts")
end
- it 'shows cohorts nav button when usage ping is enabled' do
+ it "shows cohorts nav button when usage ping is enabled" do
stub_application_setting(usage_ping_enabled: true)
visit instance_statistics_root_path
- expect(find('.nav-sidebar')).to have_content('Cohorts')
+ expect(find(".nav-sidebar")).to have_content("Cohorts")
end
end
diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb
index 9e1a12a9c2a..ed83533210a 100644
--- a/spec/features/invites_spec.rb
+++ b/spec/features/invites_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Invites' do
+describe "Invites" do
let(:user) { create(:user) }
- let(:owner) { create(:user, name: 'John Doe') }
- let(:group) { create(:group, name: 'Owned') }
+ let(:owner) { create(:user, name: "John Doe") }
+ let(:group) { create(:group, name: "Owned") }
let(:project) { create(:project, :repository, namespace: group) }
let(:group_invite) { group.group_members.invite.last }
before do
project.add_maintainer(owner)
group.add_user(owner, Gitlab::Access::OWNER)
- group.add_developer('user@example.com', owner)
+ group.add_developer("user@example.com", owner)
group_invite.generate_invite_token!
end
@@ -22,100 +22,100 @@ describe 'Invites' do
end
def fill_in_sign_up_form(new_user)
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email
+ fill_in "new_user_password", with: new_user.password
click_button "Register"
end
def fill_in_sign_in_form(user)
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: user.password
- check 'user_remember_me'
- click_button 'Sign in'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: user.password
+ check "user_remember_me"
+ click_button "Sign in"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit invite_path(group_invite.raw_invite_token)
end
- it 'renders sign in page with sign in notice' do
+ it "renders sign in page with sign in notice" do
expect(current_path).to eq(new_user_session_path)
- expect(page).to have_content('To accept this invitation, sign in')
+ expect(page).to have_content("To accept this invitation, sign in")
end
- it 'sign in and redirects to invitation page' do
+ it "sign in and redirects to invitation page" do
fill_in_sign_in_form(user)
expect(current_path).to eq(invite_path(group_invite.raw_invite_token))
expect(page).to have_content(
- 'You have been invited by John Doe to join group Owned as Developer.'
+ "You have been invited by John Doe to join group Owned as Developer."
)
- expect(page).to have_link('Accept invitation')
- expect(page).to have_link('Decline')
+ expect(page).to have_link("Accept invitation")
+ expect(page).to have_link("Decline")
end
end
- context 'when signed in as an exists member' do
+ context "when signed in as an exists member" do
before do
sign_in(owner)
end
- it 'shows message user already a member' do
+ it "shows message user already a member" do
visit invite_path(group_invite.raw_invite_token)
- expect(page).to have_content('However, you are already a member of this group.')
+ expect(page).to have_content("However, you are already a member of this group.")
end
end
- describe 'accepting the invitation' do
+ describe "accepting the invitation" do
before do
sign_in(user)
visit invite_path(group_invite.raw_invite_token)
end
- it 'grants access and redirects to group page' do
- page.click_link 'Accept invitation'
+ it "grants access and redirects to group page" do
+ page.click_link "Accept invitation"
expect(current_path).to eq(group_path(group))
expect(page).to have_content(
- 'You have been granted Developer access to group Owned.'
+ "You have been granted Developer access to group Owned."
)
end
end
- describe 'declining the application' do
- context 'when signed in' do
+ describe "declining the application" do
+ context "when signed in" do
before do
sign_in(user)
visit invite_path(group_invite.raw_invite_token)
end
- it 'declines application and redirects to dashboard' do
- page.click_link 'Decline'
+ it "declines application and redirects to dashboard" do
+ page.click_link "Decline"
expect(current_path).to eq(dashboard_projects_path)
expect(page).to have_content(
- 'You have declined the invitation to join group Owned.'
+ "You have declined the invitation to join group Owned."
)
end
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit decline_invite_path(group_invite.raw_invite_token)
end
- it 'declines application and redirects to sign in page' do
+ it "declines application and redirects to sign in page" do
expect(current_path).to eq(new_user_session_path)
expect(page).to have_content(
- 'You have declined the invitation to join group Owned.'
+ "You have declined the invitation to join group Owned."
)
end
end
end
- describe 'invite an user using their email address' do
+ describe "invite an user using their email address" do
let(:new_user) { build_stubbed(:user) }
let(:invite_email) { new_user.email }
let(:group_invite) { create(:group_member, :invited, group: group, invite_email: invite_email) }
@@ -126,10 +126,10 @@ describe 'Invites' do
visit invite_path(group_invite.raw_invite_token)
end
- context 'email confirmation disabled' do
+ context "email confirmation disabled" do
let(:send_email_confirmation) { false }
- it 'signs up and redirects to the dashboard page with all the projects/groups invitations automatically accepted' do
+ it "signs up and redirects to the dashboard page with all the projects/groups invitations automatically accepted" do
fill_in_sign_up_form(new_user)
expect(current_path).to eq(dashboard_projects_path)
@@ -138,10 +138,10 @@ describe 'Invites' do
expect(page).to have_content(group.full_name)
end
- context 'the user sign-up using a different email address' do
+ context "the user sign-up using a different email address" do
let(:invite_email) { build_stubbed(:user).email }
- it 'signs up and redirects to the invitation page' do
+ it "signs up and redirects to the invitation page" do
fill_in_sign_up_form(new_user)
expect(current_path).to eq(invite_path(group_invite.raw_invite_token))
@@ -149,10 +149,10 @@ describe 'Invites' do
end
end
- context 'email confirmation enabled' do
+ context "email confirmation enabled" do
let(:send_email_confirmation) { true }
- it 'signs up and redirects to root page with all the project/groups invitation automatically accepted' do
+ it "signs up and redirects to root page with all the project/groups invitation automatically accepted" do
fill_in_sign_up_form(new_user)
confirm_email_and_sign_in(new_user)
@@ -167,13 +167,13 @@ describe 'Invites' do
sign_in(owner)
visit project_project_members_path(project)
- expect(page).to have_content 'Invited'
+ expect(page).to have_content "Invited"
end
- context 'the user sign-up using a different email address' do
+ context "the user sign-up using a different email address" do
let(:invite_email) { build_stubbed(:user).email }
- it 'signs up and redirects to the invitation page' do
+ it "signs up and redirects to the invitation page" do
fill_in_sign_up_form(new_user)
confirm_email_and_sign_in(new_user)
diff --git a/spec/features/issuables/close_reopen_report_toggle_spec.rb b/spec/features/issuables/close_reopen_report_toggle_spec.rb
index 26c44baeb21..0e53079d344 100644
--- a/spec/features/issuables/close_reopen_report_toggle_spec.rb
+++ b/spec/features/issuables/close_reopen_report_toggle_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Issuables Close/Reopen/Report toggle' do
+describe "Issuables Close/Reopen/Report toggle" do
let(:user) { create(:user) }
- shared_examples 'an issuable close/reopen/report toggle' do
- let(:container) { find('.issuable-close-dropdown') }
+ shared_examples "an issuable close/reopen/report toggle" do
+ let(:container) { find(".issuable-close-dropdown") }
let(:human_model_name) { issuable.model_name.human.downcase }
- it 'shows toggle' do
+ it "shows toggle" do
expect(page).to have_link("Close #{human_model_name}")
- expect(page).to have_selector('.issuable-close-dropdown')
+ expect(page).to have_selector(".issuable-close-dropdown")
end
- it 'opens a dropdown when toggle is clicked' do
- container.find('.dropdown-toggle').click
+ it "opens a dropdown when toggle is clicked" do
+ container.find(".dropdown-toggle").click
- expect(container).to have_selector('.dropdown-menu')
+ expect(container).to have_selector(".dropdown-menu")
expect(container).to have_content("Close #{human_model_name}")
- expect(container).to have_content('Report abuse')
+ expect(container).to have_content("Report abuse")
expect(container).to have_content("Report #{human_model_name.pluralize} that are abusive, inappropriate or spam.")
- expect(container).to have_selector('.close-item.droplab-item-selected')
- expect(container).to have_selector('.report-item')
- expect(container).not_to have_selector('.report-item.droplab-item-selected')
- expect(container).not_to have_selector('.reopen-item')
+ expect(container).to have_selector(".close-item.droplab-item-selected")
+ expect(container).to have_selector(".report-item")
+ expect(container).not_to have_selector(".report-item.droplab-item-selected")
+ expect(container).not_to have_selector(".reopen-item")
end
- it 'changes the button when an item is selected' do
- button = container.find('.issuable-close-button')
+ it "changes the button when an item is selected" do
+ button = container.find(".issuable-close-button")
- container.find('.dropdown-toggle').click
- container.find('.report-item').click
+ container.find(".dropdown-toggle").click
+ container.find(".report-item").click
- expect(container).not_to have_selector('.dropdown-menu')
- expect(button).to have_content('Report abuse')
+ expect(container).not_to have_selector(".dropdown-menu")
+ expect(button).to have_content("Report abuse")
- container.find('.dropdown-toggle').click
- container.find('.close-item').click
+ container.find(".dropdown-toggle").click
+ container.find(".close-item").click
expect(button).to have_content("Close #{human_model_name}")
end
end
- context 'on an issue' do
+ context "on an issue" do
let(:project) { create(:project) }
let(:issuable) { create(:issue, project: project) }
@@ -50,33 +50,33 @@ describe 'Issuables Close/Reopen/Report toggle' do
login_as user
end
- context 'when user has permission to update', :js do
+ context "when user has permission to update", :js do
before do
visit project_issue_path(project, issuable)
end
- it_behaves_like 'an issuable close/reopen/report toggle'
+ it_behaves_like "an issuable close/reopen/report toggle"
- context 'when the issue is closed and locked' do
+ context "when the issue is closed and locked" do
let(:issuable) { create(:issue, :closed, :locked, project: project) }
- it 'hides the reopen button' do
- expect(page).not_to have_link('Reopen issue')
+ it "hides the reopen button" do
+ expect(page).not_to have_link("Reopen issue")
end
- context 'when the issue author is the current user' do
+ context "when the issue author is the current user" do
before do
issuable.update(author: user)
end
- it 'hides the reopen button' do
- expect(page).not_to have_link('Reopen issue')
+ it "hides the reopen button" do
+ expect(page).not_to have_link("Reopen issue")
end
end
end
end
- context 'when user doesnt have permission to update' do
+ context "when user doesnt have permission to update" do
let(:cant_project) { create(:project) }
let(:cant_issuable) { create(:issue, project: cant_project) }
@@ -86,17 +86,17 @@ describe 'Issuables Close/Reopen/Report toggle' do
visit project_issue_path(cant_project, cant_issuable)
end
- it 'only shows the `Report abuse` and `New issue` buttons' do
- expect(page).to have_link('Report abuse')
- expect(page).to have_link('New issue')
- expect(page).not_to have_link('Close issue')
- expect(page).not_to have_link('Reopen issue')
- expect(page).not_to have_link('Edit')
+ it "only shows the `Report abuse` and `New issue` buttons" do
+ expect(page).to have_link("Report abuse")
+ expect(page).to have_link("New issue")
+ expect(page).not_to have_link("Close issue")
+ expect(page).not_to have_link("Reopen issue")
+ expect(page).not_to have_link("Edit")
end
end
end
- context 'on a merge request' do
+ context "on a merge request" do
let(:project) { create(:project, :repository) }
let(:issuable) { create(:merge_request, source_project: project) }
@@ -105,37 +105,37 @@ describe 'Issuables Close/Reopen/Report toggle' do
login_as user
end
- context 'when user has permission to update', :js do
+ context "when user has permission to update", :js do
before do
visit project_merge_request_path(project, issuable)
end
- it_behaves_like 'an issuable close/reopen/report toggle'
+ it_behaves_like "an issuable close/reopen/report toggle"
- context 'when the merge request is merged' do
+ context "when the merge request is merged" do
let(:issuable) { create(:merge_request, :merged, source_project: project) }
- it 'shows only the `Report abuse` and `Edit` button' do
- expect(page).to have_link('Report abuse')
- expect(page).to have_link('Edit')
- expect(page).not_to have_link('Close merge request')
- expect(page).not_to have_link('Reopen merge request')
+ it "shows only the `Report abuse` and `Edit` button" do
+ expect(page).to have_link("Report abuse")
+ expect(page).to have_link("Edit")
+ expect(page).not_to have_link("Close merge request")
+ expect(page).not_to have_link("Reopen merge request")
end
- context 'when the merge request author is the current user' do
+ context "when the merge request author is the current user" do
let(:issuable) { create(:merge_request, :merged, source_project: project, author: user) }
- it 'shows only the `Edit` button' do
- expect(page).to have_link('Edit')
- expect(page).not_to have_link('Report abuse')
- expect(page).not_to have_link('Close merge request')
- expect(page).not_to have_link('Reopen merge request')
+ it "shows only the `Edit` button" do
+ expect(page).to have_link("Edit")
+ expect(page).not_to have_link("Report abuse")
+ expect(page).not_to have_link("Close merge request")
+ expect(page).not_to have_link("Reopen merge request")
end
end
end
end
- context 'when user doesnt have permission to update' do
+ context "when user doesnt have permission to update" do
let(:cant_project) { create(:project, :repository) }
let(:cant_issuable) { create(:merge_request, source_project: cant_project) }
@@ -145,11 +145,11 @@ describe 'Issuables Close/Reopen/Report toggle' do
visit project_merge_request_path(cant_project, cant_issuable)
end
- it 'only shows a `Report abuse` button' do
- expect(page).to have_link('Report abuse')
- expect(page).not_to have_link('Close merge request')
- expect(page).not_to have_link('Reopen merge request')
- expect(page).not_to have_link('Edit')
+ it "only shows a `Report abuse` button" do
+ expect(page).to have_link("Report abuse")
+ expect(page).not_to have_link("Close merge request")
+ expect(page).not_to have_link("Reopen merge request")
+ expect(page).not_to have_link("Edit")
end
end
end
diff --git a/spec/features/issuables/discussion_lock_spec.rb b/spec/features/issuables/discussion_lock_spec.rb
index 7ea29ff252b..9f1cfdc96a7 100644
--- a/spec/features/issuables/discussion_lock_spec.rb
+++ b/spec/features/issuables/discussion_lock_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Discussion Lock', :js do
+describe "Discussion Lock", :js do
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project, author: user) }
let(:project) { create(:project, :public) }
@@ -9,96 +9,96 @@ describe 'Discussion Lock', :js do
sign_in(user)
end
- context 'when a user is a team member' do
+ context "when a user is a team member" do
before do
project.add_developer(user)
end
- context 'when the discussion is unlocked' do
- it 'the user can lock the issue' do
+ context "when the discussion is unlocked" do
+ it "the user can lock the issue" do
visit project_issue_path(project, issue)
- expect(find('.issuable-sidebar')).to have_content('Unlocked')
+ expect(find(".issuable-sidebar")).to have_content("Unlocked")
- page.within('.issuable-sidebar') do
- find('.lock-edit').click
- click_button('Lock')
+ page.within(".issuable-sidebar") do
+ find(".lock-edit").click
+ click_button("Lock")
end
- expect(find('#notes')).to have_content('locked this issue')
+ expect(find("#notes")).to have_content("locked this issue")
end
end
- context 'when the discussion is locked' do
+ context "when the discussion is locked" do
before do
issue.update_attribute(:discussion_locked, true)
visit project_issue_path(project, issue)
end
- it 'the user can unlock the issue' do
- expect(find('.issuable-sidebar')).to have_content('Locked')
+ it "the user can unlock the issue" do
+ expect(find(".issuable-sidebar")).to have_content("Locked")
- page.within('.issuable-sidebar') do
- find('.lock-edit').click
- click_button('Unlock')
+ page.within(".issuable-sidebar") do
+ find(".lock-edit").click
+ click_button("Unlock")
end
- expect(find('#notes')).to have_content('unlocked this issue')
- expect(find('.issuable-sidebar')).to have_content('Unlocked')
+ expect(find("#notes")).to have_content("unlocked this issue")
+ expect(find(".issuable-sidebar")).to have_content("Unlocked")
end
- it 'the user can create a comment' do
- page.within('#notes .js-main-target-form') do
- fill_in 'note[note]', with: 'Some new comment'
- click_button 'Comment'
+ it "the user can create a comment" do
+ page.within("#notes .js-main-target-form") do
+ fill_in "note[note]", with: "Some new comment"
+ click_button "Comment"
end
wait_for_requests
- expect(find('div#notes')).to have_content('Some new comment')
+ expect(find("div#notes")).to have_content("Some new comment")
end
end
end
- context 'when a user is not a team member' do
- context 'when the discussion is unlocked' do
+ context "when a user is not a team member" do
+ context "when the discussion is unlocked" do
before do
visit project_issue_path(project, issue)
end
- it 'the user can not lock the issue' do
- expect(find('.issuable-sidebar')).to have_content('Unlocked')
- expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit')
+ it "the user can not lock the issue" do
+ expect(find(".issuable-sidebar")).to have_content("Unlocked")
+ expect(find(".issuable-sidebar")).not_to have_selector(".lock-edit")
end
- it 'the user can create a comment' do
- page.within('#notes .js-main-target-form') do
- fill_in 'note[note]', with: 'Some new comment'
- click_button 'Comment'
+ it "the user can create a comment" do
+ page.within("#notes .js-main-target-form") do
+ fill_in "note[note]", with: "Some new comment"
+ click_button "Comment"
end
wait_for_requests
- expect(find('div#notes')).to have_content('Some new comment')
+ expect(find("div#notes")).to have_content("Some new comment")
end
end
- context 'when the discussion is locked' do
+ context "when the discussion is locked" do
before do
issue.update_attribute(:discussion_locked, true)
visit project_issue_path(project, issue)
end
- it 'the user can not unlock the issue' do
- expect(find('.issuable-sidebar')).to have_content('Locked')
- expect(find('.issuable-sidebar')).not_to have_selector('.lock-edit')
+ it "the user can not unlock the issue" do
+ expect(find(".issuable-sidebar")).to have_content("Locked")
+ expect(find(".issuable-sidebar")).not_to have_selector(".lock-edit")
end
- it 'the user can not create a comment' do
- page.within('#notes') do
- expect(page).not_to have_selector('js-main-target-form')
- expect(page.find('.disabled-comment'))
- .to have_content('This issue is locked. Only project members can comment.')
+ it "the user can not create a comment" do
+ page.within("#notes") do
+ expect(page).not_to have_selector("js-main-target-form")
+ expect(page.find(".disabled-comment"))
+ .to have_content("This issue is locked. Only project members can comment.")
end
end
end
diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb
index 7b6e9cd66b2..a88273ce9e8 100644
--- a/spec/features/issuables/issuable_list_spec.rb
+++ b/spec/features/issuables/issuable_list_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'issuable list' do
+describe "issuable list" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -24,33 +24,33 @@ describe 'issuable list' do
it "counts upvotes, downvotes and notes count for each #{issuable_type.to_s.humanize}" do
visit_issuable_list(issuable_type)
- expect(first('.fa-thumbs-up').find(:xpath, '..')).to have_content(1)
- expect(first('.fa-thumbs-down').find(:xpath, '..')).to have_content(1)
- expect(first('.fa-comments').find(:xpath, '..')).to have_content(2)
+ expect(first(".fa-thumbs-up").find(:xpath, "..")).to have_content(1)
+ expect(first(".fa-thumbs-down").find(:xpath, "..")).to have_content(1)
+ expect(first(".fa-comments").find(:xpath, "..")).to have_content(2)
end
- it 'sorts labels alphabetically' do
- label1 = create(:label, project: project, title: 'a')
- label2 = create(:label, project: project, title: 'z')
- label3 = create(:label, project: project, title: 'X')
- label4 = create(:label, project: project, title: 'B')
+ it "sorts labels alphabetically" do
+ label1 = create(:label, project: project, title: "a")
+ label2 = create(:label, project: project, title: "z")
+ label3 = create(:label, project: project, title: "X")
+ label4 = create(:label, project: project, title: "B")
issuable = create_issuable(issuable_type)
issuable.labels << [label1, label2, label3, label4]
visit_issuable_list(issuable_type)
- expect(all('.label-link')[0].text).to have_content('B')
- expect(all('.label-link')[1].text).to have_content('X')
- expect(all('.label-link')[2].text).to have_content('a')
- expect(all('.label-link')[3].text).to have_content('z')
+ expect(all(".label-link")[0].text).to have_content("B")
+ expect(all(".label-link")[1].text).to have_content("X")
+ expect(all(".label-link")[2].text).to have_content("a")
+ expect(all(".label-link")[3].text).to have_content("z")
end
end
it "counts merge requests closing issues icons for each issue" do
visit_issuable_list(:issue)
- expect(page).to have_selector('.icon-merge-request-unmerged', count: 1)
- expect(first('.icon-merge-request-unmerged').find(:xpath, '..')).to have_content(1)
+ expect(page).to have_selector(".icon-merge-request-unmerged", count: 1)
+ expect(first(".icon-merge-request-unmerged").find(:xpath, "..")).to have_content(1)
end
def visit_issuable_list(issuable_type)
@@ -77,7 +77,7 @@ describe 'issuable list' do
else
create(:merge_request, source_project: project, source_branch: generate(:branch))
source_branch = FFaker::Name.name
- pipeline = create(:ci_empty_pipeline, project: project, ref: source_branch, status: %w(running failed success).sample, sha: 'any')
+ pipeline = create(:ci_empty_pipeline, project: project, ref: source_branch, status: %w[running failed success].sample, sha: "any")
create(:merge_request, title: FFaker::Lorem.sentence, source_project: project, source_branch: source_branch, head_pipeline: pipeline)
end
@@ -92,8 +92,8 @@ describe 'issuable list' do
if issuable_type == :issue
issue = Issue.reorder(:iid).first
merge_request = create(:merge_request,
- source_project: project,
- source_branch: generate(:branch))
+ source_project: project,
+ source_branch: generate(:branch))
create(:merge_requests_closing_issues, issue: issue, merge_request: merge_request)
end
diff --git a/spec/features/issuables/markdown_references/internal_references_spec.rb b/spec/features/issuables/markdown_references/internal_references_spec.rb
index 23385ba65fc..52e6927b37e 100644
--- a/spec/features/issuables/markdown_references/internal_references_spec.rb
+++ b/spec/features/issuables/markdown_references/internal_references_spec.rb
@@ -74,7 +74,7 @@ describe "Internal references", :js do
end
expect(page).to have_content("mentioned in merge request #{private_project_merge_request.to_reference(public_project)}")
- .and have_content(private_project_user.name)
+ .and have_content(private_project_user.name)
end
end
end
@@ -133,7 +133,7 @@ describe "Internal references", :js do
it "shows references" do
expect(page).to have_content("mentioned in merge request #{private_project_merge_request.to_reference(public_project)}")
- .and have_content(private_project_user.name)
+ .and have_content(private_project_user.name)
end
end
end
diff --git a/spec/features/issuables/markdown_references/jira_spec.rb b/spec/features/issuables/markdown_references/jira_spec.rb
index 8eaccfc0949..8845548cc21 100644
--- a/spec/features/issuables/markdown_references/jira_spec.rb
+++ b/spec/features/issuables/markdown_references/jira_spec.rb
@@ -102,7 +102,7 @@ describe "Jira", :js do
context "when no tracker is enabled for the actual project" do
let(:actual_project) { create(:project, :public, :repository, :issues_disabled) }
- include_examples 'correct references' do
+ include_examples "correct references" do
let(:referenced_issues) { [issue_other_project] }
let(:jira_referenced) { false }
end
diff --git a/spec/features/issuables/shortcuts_issuable_spec.rb b/spec/features/issuables/shortcuts_issuable_spec.rb
index a0ae6720a9f..9a05ec19915 100644
--- a/spec/features/issuables/shortcuts_issuable_spec.rb
+++ b/spec/features/issuables/shortcuts_issuable_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Blob shortcuts', :js do
+describe "Blob shortcuts", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project, author: user) }
let(:merge_request) { create(:merge_request, source_project: project) }
- let(:note_text) { 'I got this!' }
+ let(:note_text) { "I got this!" }
before do
project.add_developer(user)
@@ -14,32 +14,32 @@ describe 'Blob shortcuts', :js do
shared_examples "quotes the selected text" do
it "quotes the selected text" do
- select_element('.note-text')
- find('body').native.send_key('r')
+ select_element(".note-text")
+ find("body").native.send_key("r")
- expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text)
+ expect(find(".js-main-target-form .js-vue-comment-form").value).to include(note_text)
end
end
describe 'pressing "r"' do
- describe 'On an Issue' do
+ describe "On an Issue" do
before do
create(:note, noteable: issue, project: project, note: note_text)
visit project_issue_path(project, issue)
wait_for_requests
end
- include_examples 'quotes the selected text'
+ include_examples "quotes the selected text"
end
- describe 'On a Merge Request' do
+ describe "On a Merge Request" do
before do
create(:note, noteable: merge_request, project: project, note: note_text)
visit project_merge_request_path(project, merge_request)
wait_for_requests
end
- include_examples 'quotes the selected text'
+ include_examples "quotes the selected text"
end
end
end
diff --git a/spec/features/issuables/sorting_list_spec.rb b/spec/features/issuables/sorting_list_spec.rb
index 0601dd47c03..8bd5593f882 100644
--- a/spec/features/issuables/sorting_list_spec.rb
+++ b/spec/features/issuables/sorting_list_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe 'Sort Issuable List' do
+require "spec_helper"
+
+describe "Sort Issuable List" do
let(:project) { create(:project, :public) }
let(:first_created_issuable) { issuables.order_created_asc.first }
@@ -10,24 +11,24 @@ describe 'Sort Issuable List' do
let(:first_updated_issuable) { issuables.order_updated_asc.first }
let(:last_updated_issuable) { issuables.order_updated_desc.first }
- context 'for merge requests' do
+ context "for merge requests" do
include MergeRequestHelpers
let!(:issuables) do
- timestamps = [{ created_at: 3.minutes.ago, updated_at: 20.seconds.ago },
- { created_at: 2.minutes.ago, updated_at: 30.seconds.ago },
- { created_at: 4.minutes.ago, updated_at: 10.seconds.ago }]
+ timestamps = [{created_at: 3.minutes.ago, updated_at: 20.seconds.ago},
+ {created_at: 2.minutes.ago, updated_at: 30.seconds.ago},
+ {created_at: 4.minutes.ago, updated_at: 10.seconds.ago},]
timestamps.each_with_index do |ts, i|
- create issuable_type, { title: "#{issuable_type}_#{i}",
- source_branch: "#{issuable_type}_#{i}",
- source_project: project }.merge(ts)
+ create issuable_type, {title: "#{issuable_type}_#{i}",
+ source_branch: "#{issuable_type}_#{i}",
+ source_project: project,}.merge(ts)
end
MergeRequest.all
end
- context 'default sort order' do
+ context "default sort order" do
context 'in the "merge requests" tab', :js do
let(:issuable_type) { :merge_request }
@@ -43,9 +44,9 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :merge_request }
it 'is "created date"' do
- visit_merge_requests_with_state(project, 'open')
+ visit_merge_requests_with_state(project, "open")
- expect(selected_sort_order).to eq('created date')
+ expect(selected_sort_order).to eq("created date")
expect(first_merge_request).to include(last_created_issuable.title)
expect(last_merge_request).to include(first_created_issuable.title)
end
@@ -55,9 +56,9 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :merged_merge_request }
it 'is "last updated"' do
- visit_merge_requests_with_state(project, 'merged')
+ visit_merge_requests_with_state(project, "merged")
- expect(find('.issues-other-filters')).to have_content('Last updated')
+ expect(find(".issues-other-filters")).to have_content("Last updated")
expect(first_merge_request).to include(last_updated_issuable.title)
expect(last_merge_request).to include(first_updated_issuable.title)
end
@@ -67,9 +68,9 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :closed_merge_request }
it 'is "last updated"' do
- visit_merge_requests_with_state(project, 'closed')
+ visit_merge_requests_with_state(project, "closed")
- expect(find('.issues-other-filters')).to have_content('Last updated')
+ expect(find(".issues-other-filters")).to have_content("Last updated")
expect(first_merge_request).to include(last_updated_issuable.title)
expect(last_merge_request).to include(first_updated_issuable.title)
end
@@ -79,29 +80,29 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :merge_request }
it 'is "created date"' do
- visit_merge_requests_with_state(project, 'all')
+ visit_merge_requests_with_state(project, "all")
- expect(find('.issues-other-filters')).to have_content('Created date')
+ expect(find(".issues-other-filters")).to have_content("Created date")
expect(first_merge_request).to include(last_created_issuable.title)
expect(last_merge_request).to include(first_created_issuable.title)
end
end
- context 'custom sorting' do
+ context "custom sorting" do
let(:issuable_type) { :merge_request }
- it 'supports sorting in asc and desc order' do
- visit_merge_requests_with_state(project, 'open')
+ it "supports sorting in asc and desc order" do
+ visit_merge_requests_with_state(project, "open")
- page.within('.issues-other-filters') do
- click_button('Created date')
- click_link('Last updated')
+ page.within(".issues-other-filters") do
+ click_button("Created date")
+ click_link("Last updated")
end
expect(first_merge_request).to include(last_updated_issuable.title)
expect(last_merge_request).to include(first_updated_issuable.title)
- find('.issues-other-filters .filter-dropdown-container .qa-reverse-sort').click
+ find(".issues-other-filters .filter-dropdown-container .qa-reverse-sort").click
expect(first_merge_request).to include(first_updated_issuable.title)
expect(last_merge_request).to include(last_updated_issuable.title)
@@ -110,30 +111,30 @@ describe 'Sort Issuable List' do
end
end
- context 'for issues' do
+ context "for issues" do
include IssueHelpers
let!(:issuables) do
- timestamps = [{ created_at: 3.minutes.ago, updated_at: 20.seconds.ago },
- { created_at: 2.minutes.ago, updated_at: 30.seconds.ago },
- { created_at: 4.minutes.ago, updated_at: 10.seconds.ago }]
+ timestamps = [{created_at: 3.minutes.ago, updated_at: 20.seconds.ago},
+ {created_at: 2.minutes.ago, updated_at: 30.seconds.ago},
+ {created_at: 4.minutes.ago, updated_at: 10.seconds.ago},]
timestamps.each_with_index do |ts, i|
- create issuable_type, { title: "#{issuable_type}_#{i}",
- project: project }.merge(ts)
+ create issuable_type, {title: "#{issuable_type}_#{i}",
+ project: project,}.merge(ts)
end
Issue.all
end
- context 'default sort order' do
+ context "default sort order" do
context 'in the "issues" tab', :js do
let(:issuable_type) { :issue }
it 'is "created date"' do
visit_issues project
- expect(find('.issues-other-filters')).to have_content('Created date')
+ expect(find(".issues-other-filters")).to have_content("Created date")
expect(first_issue).to include(last_created_issuable.title)
expect(last_issue).to include(first_created_issuable.title)
end
@@ -143,9 +144,9 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :issue }
it 'is "created date"' do
- visit_issues_with_state(project, 'open')
+ visit_issues_with_state(project, "open")
- expect(find('.issues-other-filters')).to have_content('Created date')
+ expect(find(".issues-other-filters")).to have_content("Created date")
expect(first_issue).to include(last_created_issuable.title)
expect(last_issue).to include(first_created_issuable.title)
end
@@ -155,9 +156,9 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :closed_issue }
it 'is "last updated"' do
- visit_issues_with_state(project, 'closed')
+ visit_issues_with_state(project, "closed")
- expect(find('.issues-other-filters')).to have_content('Last updated')
+ expect(find(".issues-other-filters")).to have_content("Last updated")
expect(first_issue).to include(last_updated_issuable.title)
expect(last_issue).to include(first_updated_issuable.title)
end
@@ -167,44 +168,44 @@ describe 'Sort Issuable List' do
let(:issuable_type) { :issue }
it 'is "created date"' do
- visit_issues_with_state(project, 'all')
+ visit_issues_with_state(project, "all")
- expect(find('.issues-other-filters')).to have_content('Created date')
+ expect(find(".issues-other-filters")).to have_content("Created date")
expect(first_issue).to include(last_created_issuable.title)
expect(last_issue).to include(first_created_issuable.title)
end
end
- context 'when the sort in the URL is id_desc' do
+ context "when the sort in the URL is id_desc" do
let(:issuable_type) { :issue }
before do
- visit_issues(project, sort: 'id_desc')
+ visit_issues(project, sort: "id_desc")
end
- it 'shows the sort order as created date' do
- expect(find('.issues-other-filters')).to have_content('Created date')
+ it "shows the sort order as created date" do
+ expect(find(".issues-other-filters")).to have_content("Created date")
expect(first_issue).to include(last_created_issuable.title)
expect(last_issue).to include(first_created_issuable.title)
end
end
end
- context 'custom sorting' do
+ context "custom sorting" do
let(:issuable_type) { :issue }
- it 'supports sorting in asc and desc order' do
- visit_issues_with_state(project, 'open')
+ it "supports sorting in asc and desc order" do
+ visit_issues_with_state(project, "open")
- page.within('.issues-other-filters') do
- click_button('Created date')
- click_link('Last updated')
+ page.within(".issues-other-filters") do
+ click_button("Created date")
+ click_link("Last updated")
end
expect(first_issue).to include(last_updated_issuable.title)
expect(last_issue).to include(first_updated_issuable.title)
- find('.issues-other-filters .filter-dropdown-container .qa-reverse-sort').click
+ find(".issues-other-filters .filter-dropdown-container .qa-reverse-sort").click
expect(first_issue).to include(first_updated_issuable.title)
expect(last_issue).to include(last_updated_issuable.title)
@@ -213,7 +214,7 @@ describe 'Sort Issuable List' do
end
def selected_sort_order
- find('.filter-dropdown-container .dropdown button').text.downcase
+ find(".filter-dropdown-container .dropdown button").text.downcase
end
def visit_merge_requests_with_state(project, state)
diff --git a/spec/features/issuables/user_sees_sidebar_spec.rb b/spec/features/issuables/user_sees_sidebar_spec.rb
index c6c2e58ecea..d7c3bfcc1d8 100644
--- a/spec/features/issuables/user_sees_sidebar_spec.rb
+++ b/spec/features/issuables/user_sees_sidebar_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Sidebar on Mobile' do
+describe "Issue Sidebar on Mobile" do
include MobileHelpers
let(:project) { create(:project, :public, :repository) }
@@ -12,7 +12,7 @@ describe 'Issue Sidebar on Mobile' do
sign_in(user)
end
- context 'mobile sidebar on merge requests', :js do
+ context "mobile sidebar on merge requests", :js do
before do
visit project_merge_request_path(merge_request.project, merge_request)
end
@@ -20,7 +20,7 @@ describe 'Issue Sidebar on Mobile' do
it_behaves_like "issue sidebar stays collapsed on mobile"
end
- context 'mobile sidebar on issues', :js do
+ context "mobile sidebar on issues", :js do
before do
visit project_issue_path(project, issue)
end
diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb
index 06cb2e36334..6154dad8259 100644
--- a/spec/features/issues/bulk_assignment_labels_spec.rb
+++ b/spec/features/issues/bulk_assignment_labels_spec.rb
@@ -1,122 +1,122 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issues > Labels bulk assignment' do
+describe "Issues > Labels bulk assignment" do
let(:user) { create(:user) }
let!(:project) { create(:project) }
let!(:issue1) { create(:issue, project: project, title: "Issue 1") }
let!(:issue2) { create(:issue, project: project, title: "Issue 2") }
- let!(:bug) { create(:label, project: project, title: 'bug') }
- let!(:feature) { create(:label, project: project, title: 'feature') }
- let!(:wontfix) { create(:label, project: project, title: 'wontfix') }
+ let!(:bug) { create(:label, project: project, title: "bug") }
+ let!(:feature) { create(:label, project: project, title: "feature") }
+ let!(:wontfix) { create(:label, project: project, title: "wontfix") }
- context 'as an allowed user', :js do
+ context "as an allowed user", :js do
before do
project.add_maintainer(user)
sign_in user
end
- context 'sidebar' do
+ context "sidebar" do
before do
enable_bulk_update
end
- it 'is present when bulk edit is enabled' do
- expect(page).to have_css('.issuable-sidebar')
+ it "is present when bulk edit is enabled" do
+ expect(page).to have_css(".issuable-sidebar")
end
- it 'is not present when bulk edit is disabled' do
+ it "is not present when bulk edit is disabled" do
disable_bulk_update
- expect(page).not_to have_css('.issuable-sidebar')
+ expect(page).not_to have_css(".issuable-sidebar")
end
end
- context 'can bulk assign' do
+ context "can bulk assign" do
before do
enable_bulk_update
end
- context 'a label' do
- context 'to all issues' do
+ context "a label" do
+ context "to all issues" do
before do
- check 'check-all-issues'
- open_labels_dropdown ['bug']
+ check "check-all-issues"
+ open_labels_dropdown ["bug"]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "bug"
end
end
- context 'to a issue' do
+ context "to a issue" do
before do
check "selected_issue_#{issue1.id}"
- open_labels_dropdown ['bug']
+ open_labels_dropdown ["bug"]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "bug"
end
end
end
- context 'multiple labels' do
- context 'to all issues' do
+ context "multiple labels" do
+ context "to all issues" do
before do
- check 'check-all-issues'
- open_labels_dropdown %w(bug feature)
+ check "check-all-issues"
+ open_labels_dropdown %w[bug feature]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
end
end
- context 'to a issue' do
+ context "to a issue" do
before do
check "selected_issue_#{issue1.id}"
- open_labels_dropdown %w(bug feature)
+ open_labels_dropdown %w[bug feature]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "feature"
end
end
end
end
- context 'can assign a label to all issues when label is present' do
+ context "can assign a label to all issues when label is present" do
before do
issue2.labels << bug
issue2.labels << feature
enable_bulk_update
- check 'check-all-issues'
+ check "check-all-issues"
- open_labels_dropdown ['bug']
+ open_labels_dropdown ["bug"]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "bug"
end
end
- context 'can bulk un-assign' do
- context 'all labels to all issues' do
+ context "can bulk un-assign" do
+ context "all labels to all issues" do
before do
issue1.labels << bug
issue1.labels << feature
@@ -124,37 +124,37 @@ describe 'Issues > Labels bulk assignment' do
issue2.labels << feature
enable_bulk_update
- check 'check-all-issues'
- unmark_labels_in_dropdown %w(bug feature)
+ check "check-all-issues"
+ unmark_labels_in_dropdown %w[bug feature]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).not_to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "feature"
end
end
- context 'a label to a issue' do
+ context "a label to a issue" do
before do
issue1.labels << bug
issue2.labels << feature
enable_bulk_update
check_issue issue1
- unmark_labels_in_dropdown ['bug']
+ unmark_labels_in_dropdown ["bug"]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
end
end
- context 'a label and keep the others label' do
+ context "a label and keep the others label" do
before do
issue1.labels << bug
issue1.labels << feature
@@ -164,68 +164,68 @@ describe 'Issues > Labels bulk assignment' do
enable_bulk_update
check_issue issue1
check_issue issue2
- unmark_labels_in_dropdown ['bug']
+ unmark_labels_in_dropdown ["bug"]
update_issues
end
it do
- expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
end
end
end
- context 'toggling a milestone' do
- let!(:milestone) { create(:milestone, project: project, title: 'First Release') }
+ context "toggling a milestone" do
+ let!(:milestone) { create(:milestone, project: project, title: "First Release") }
- context 'setting a milestone' do
+ context "setting a milestone" do
before do
issue1.labels << bug
issue2.labels << feature
enable_bulk_update
end
- it 'keeps labels' do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
+ it "keeps labels" do
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
- check 'check-all-issues'
+ check "check-all-issues"
- open_milestone_dropdown(['First Release'])
+ open_milestone_dropdown(["First Release"])
update_issues
- 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'
- expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
+ 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"
+ expect(find("#issue_#{issue2.id}")).to have_content "First Release"
end
end
- context 'setting a milestone and adding another label' do
+ context "setting a milestone and adding another label" do
before do
issue1.labels << bug
enable_bulk_update
end
- it 'keeps existing label and new label is present' do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ it "keeps existing label and new label is present" do
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
- check 'check-all-issues'
- open_milestone_dropdown ['First Release']
- open_labels_dropdown ['feature']
+ check "check-all-issues"
+ open_milestone_dropdown ["First Release"]
+ open_labels_dropdown ["feature"]
update_issues
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).to have_content "feature"
+ expect(find("#issue_#{issue1.id}")).to have_content "First Release"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).to have_content "First Release"
end
end
- context 'setting a milestone and removing existing label' do
+ context "setting a milestone and removing existing label" do
before do
issue1.labels << bug
issue1.labels << feature
@@ -234,26 +234,26 @@ describe 'Issues > Labels bulk assignment' do
enable_bulk_update
end
- 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'
+ 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"
- check 'check-all-issues'
+ check "check-all-issues"
- open_milestone_dropdown ['First Release']
- unmark_labels_in_dropdown ['feature']
+ open_milestone_dropdown ["First Release"]
+ unmark_labels_in_dropdown ["feature"]
update_issues
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
- expect(find("#issue_#{issue1.id}")).to have_content 'First Release'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).not_to have_content "feature"
+ expect(find("#issue_#{issue1.id}")).to have_content "First Release"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).to have_content "First Release"
end
end
- context 'unsetting a milestone' do
+ context "unsetting a milestone" do
before do
issue1.milestone = milestone
issue2.milestone = milestone
@@ -265,47 +265,47 @@ describe 'Issues > Labels bulk assignment' do
enable_bulk_update
end
- 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'
- expect(find("#issue_#{issue2.id}")).to have_content 'First Release'
+ 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"
+ expect(find("#issue_#{issue2.id}")).to have_content "First Release"
- check 'check-all-issues'
- open_milestone_dropdown(['No Milestone'])
+ check "check-all-issues"
+ open_milestone_dropdown(["No Milestone"])
update_issues
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).not_to have_content 'First Release'
- expect(find("#issue_#{issue2.id}")).to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'First Release'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).not_to have_content "First Release"
+ expect(find("#issue_#{issue2.id}")).to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "First Release"
end
end
end
- context 'toggling checked issues' do
+ context "toggling checked issues" do
before do
issue1.labels << bug
enable_bulk_update
end
it do
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
check_issue issue1
- open_labels_dropdown ['feature']
+ open_labels_dropdown ["feature"]
uncheck_issue issue1
check_issue issue1
update_issues
sleep 1 # needed
- expect(find("#issue_#{issue1.id}")).to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).not_to have_content 'feature'
+ expect(find("#issue_#{issue1.id}")).to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).not_to have_content "feature"
end
end
# Special case https://gitlab.com/gitlab-org/gitlab-ce/issues/24877
- context 'unmarking common label' do
+ context "unmarking common label" do
before do
issue1.labels << bug
issue1.labels << feature
@@ -314,55 +314,55 @@ describe 'Issues > Labels bulk assignment' do
enable_bulk_update
end
- it 'applies label from filtered results' do
- check 'check-all-issues'
+ it "applies label from filtered results" do
+ check "check-all-issues"
- page.within('.issues-bulk-update') do
- click_button 'Select labels'
+ page.within(".issues-bulk-update") do
+ click_button "Select labels"
wait_for_requests
- expect(find('.dropdown-menu-labels li', text: 'bug')).to have_css('.is-active')
- expect(find('.dropdown-menu-labels li', text: 'feature')).to have_css('.is-indeterminate')
+ expect(find(".dropdown-menu-labels li", text: "bug")).to have_css(".is-active")
+ expect(find(".dropdown-menu-labels li", text: "feature")).to have_css(".is-indeterminate")
- click_link 'bug'
- find('.dropdown-input-field', visible: true).set('wontfix')
- click_link 'wontfix'
+ click_link "bug"
+ find(".dropdown-input-field", visible: true).set("wontfix")
+ click_link "wontfix"
end
update_issues
- page.within '.issues-holder' do
- expect(find("#issue_#{issue1.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue1.id}")).to have_content 'feature'
- expect(find("#issue_#{issue1.id}")).to have_content 'wontfix'
+ page.within ".issues-holder" do
+ expect(find("#issue_#{issue1.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue1.id}")).to have_content "feature"
+ expect(find("#issue_#{issue1.id}")).to have_content "wontfix"
- expect(find("#issue_#{issue2.id}")).not_to have_content 'bug'
- expect(find("#issue_#{issue2.id}")).not_to have_content 'feature'
- expect(find("#issue_#{issue2.id}")).to have_content 'wontfix'
+ expect(find("#issue_#{issue2.id}")).not_to have_content "bug"
+ expect(find("#issue_#{issue2.id}")).not_to have_content "feature"
+ expect(find("#issue_#{issue2.id}")).to have_content "wontfix"
end
end
end
end
- context 'as a guest' do
+ context "as a guest" do
before do
sign_in user
visit project_issues_path(project)
end
- context 'cannot bulk assign labels' do
+ context "cannot bulk assign labels" do
it do
- expect(page).not_to have_button 'Edit issues'
- expect(page).not_to have_css '.check-all-issues'
- expect(page).not_to have_css '.issue-check'
+ expect(page).not_to have_button "Edit issues"
+ expect(page).not_to have_css ".check-all-issues"
+ expect(page).not_to have_css ".issue-check"
end
end
end
def open_milestone_dropdown(items = [])
- page.within('.issues-bulk-update') do
- click_button 'Select milestone'
+ page.within(".issues-bulk-update") do
+ click_button "Select milestone"
wait_for_requests
items.map do |item|
click_link item
@@ -371,8 +371,8 @@ describe 'Issues > Labels bulk assignment' do
end
def open_labels_dropdown(items = [], unmark = false)
- page.within('.issues-bulk-update') do
- click_button 'Select labels'
+ page.within(".issues-bulk-update") do
+ click_button "Select labels"
wait_for_requests
items.map do |item|
click_link item
@@ -381,7 +381,7 @@ describe 'Issues > Labels bulk assignment' do
if unmark
items.map do |item|
# Make sure we are unmarking the item no matter the state it has currently
- click_link item until find('a', text: item)[:class] == 'label-item'
+ click_link item until find("a", text: item)[:class] == "label-item"
end
end
end
@@ -392,7 +392,7 @@ describe 'Issues > Labels bulk assignment' do
end
def check_issue(issue, uncheck = false)
- page.within('.issues-list') do
+ page.within(".issues-list") do
if uncheck
uncheck "selected_issue_#{issue.id}"
else
@@ -406,16 +406,16 @@ describe 'Issues > Labels bulk assignment' do
end
def update_issues
- find('.update-selected-issues').click
+ find(".update-selected-issues").click
wait_for_requests
end
def enable_bulk_update
visit project_issues_path(project)
- click_button 'Edit issues'
+ click_button "Edit issues"
end
def disable_bulk_update
- click_button 'Cancel'
+ click_button "Cancel"
end
end
diff --git a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb
index ada57285abf..6b436a8b488 100644
--- a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb
+++ b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Resolving all open discussions in a merge request from an issue', :js do
+describe "Resolving all open discussions in a merge request from an issue", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -9,90 +9,90 @@ describe 'Resolving all open discussions in a merge request from an issue', :js
def resolve_all_discussions_link_selector
text = "Resolve all discussions in new issue"
url = new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
- %Q{a[data-original-title="#{text}"][href="#{url}"]}
+ %(a[data-original-title="#{text}"][href="#{url}"])
end
- describe 'as a user with access to the project' do
+ describe "as a user with access to the project" do
before do
project.add_maintainer(user)
sign_in user
visit project_merge_request_path(project, merge_request)
end
- it 'shows a button to resolve all discussions by creating a new issue' do
- within('.line-resolve-all-container') do
+ it "shows a button to resolve all discussions by creating a new issue" do
+ within(".line-resolve-all-container") do
expect(page).to have_selector resolve_all_discussions_link_selector
end
end
- context 'resolving the discussion' do
+ context "resolving the discussion" do
before do
- click_button 'Resolve discussion'
+ click_button "Resolve discussion"
end
- it 'hides the link for creating a new issue' do
+ it "hides the link for creating a new issue" do
expect(page).not_to have_selector resolve_all_discussions_link_selector
end
end
- context 'creating an issue for discussions' do
+ context "creating an issue for discussions" do
before do
find(resolve_all_discussions_link_selector).click
end
- it_behaves_like 'creating an issue for a discussion'
+ it_behaves_like "creating an issue for a discussion"
end
- context 'for a project where all discussions need to be resolved before merging' do
+ context "for a project where all discussions need to be resolved before merging" do
before do
project.update_attribute(:only_allow_merge_if_all_discussions_are_resolved, true)
end
- context 'with the internal tracker disabled' do
+ context "with the internal tracker disabled" do
before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
visit project_merge_request_path(project, merge_request)
end
- it 'does not show a link to create a new issue' do
- expect(page).not_to have_link 'Create an issue to resolve them later'
+ it "does not show a link to create a new issue" do
+ expect(page).not_to have_link "Create an issue to resolve them later"
end
end
- context 'merge request has discussions that need to be resolved' do
+ context "merge request has discussions that need to be resolved" do
before do
visit project_merge_request_path(project, merge_request)
end
- it 'shows a warning that the merge request contains unresolved discussions' do
- expect(page).to have_content 'There are unresolved discussions.'
+ it "shows a warning that the merge request contains unresolved discussions" do
+ expect(page).to have_content "There are unresolved discussions."
end
- it 'has a link to resolve all discussions by creating an issue' do
- page.within '.mr-widget-body' do
- expect(page).to have_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
+ it "has a link to resolve all discussions by creating an issue" do
+ page.within ".mr-widget-body" do
+ expect(page).to have_link "Create an issue to resolve them later", href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
end
end
- context 'creating an issue for discussions' do
+ context "creating an issue for discussions" do
before do
- page.click_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
+ page.click_link "Create an issue to resolve them later", href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
end
- it_behaves_like 'creating an issue for a discussion'
+ it_behaves_like "creating an issue for a discussion"
end
end
end
end
- describe 'as a reporter' do
+ describe "as a reporter" do
before do
project.add_reporter(user)
sign_in user
visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid)
end
- it 'Shows a notice to ask someone else to resolve the discussions' do
+ it "Shows a notice to ask someone else to resolve the discussions" do
expect(page).to have_content("The discussions at #{merge_request.to_reference} will stay unresolved. Ask someone with permission to resolve them.")
end
end
diff --git a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb
index b20730bdb22..61b8f56ca0f 100644
--- a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb
+++ b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb
@@ -1,73 +1,73 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Resolve an open discussion in a merge request by creating an issue', :js do
+describe "Resolve an open discussion in a merge request by creating an issue", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) }
let(:merge_request) { create(:merge_request, source_project: project) }
let!(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
def resolve_discussion_selector
- title = 'Resolve this discussion in a new issue'
+ title = "Resolve this discussion in a new issue"
url = new_project_issue_path(project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid)
"a[data-original-title=\"#{title}\"][href=\"#{url}\"]"
end
- describe 'As a user with access to the project' do
+ describe "As a user with access to the project" do
before do
project.add_maintainer(user)
sign_in user
visit project_merge_request_path(project, merge_request)
end
- context 'with the internal tracker disabled' do
+ context "with the internal tracker disabled" do
before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
visit project_merge_request_path(project, merge_request)
end
- it 'does not show a link to create a new issue' do
+ it "does not show a link to create a new issue" do
expect(page).not_to have_css resolve_discussion_selector
end
end
- context 'resolving the discussion' do
+ context "resolving the discussion" do
before do
- click_button 'Resolve discussion'
+ click_button "Resolve discussion"
end
- it 'hides the link for creating a new issue' do
+ it "hides the link for creating a new issue" do
expect(page).not_to have_css resolve_discussion_selector
end
- it 'shows the link for creating a new issue when unresolving a discussion' do
- page.within '.diff-content' do
- click_button 'Unresolve discussion'
+ it "shows the link for creating a new issue when unresolving a discussion" do
+ page.within ".diff-content" do
+ click_button "Unresolve discussion"
end
expect(page).to have_css resolve_discussion_selector
end
end
- it 'has a link to create a new issue for a discussion' do
+ it "has a link to create a new issue for a discussion" do
expect(page).to have_css resolve_discussion_selector
end
- context 'creating the issue' do
+ context "creating the issue" do
before do
find(resolve_discussion_selector).click
end
- it 'has a hidden field for the discussion' do
- discussion_field = find('#discussion_to_resolve', visible: false)
+ it "has a hidden field for the discussion" do
+ discussion_field = find("#discussion_to_resolve", visible: false)
expect(discussion_field.value).to eq(discussion.id.to_s)
end
- it_behaves_like 'creating an issue for a discussion'
+ it_behaves_like "creating an issue for a discussion"
end
end
- describe 'as a reporter' do
+ describe "as a reporter" do
before do
project.add_reporter(user)
sign_in user
@@ -75,7 +75,7 @@ describe 'Resolve an open discussion in a merge request by creating an issue', :
discussion_to_resolve: discussion.id)
end
- it 'Shows a notice to ask someone else to resolve the discussions' do
+ it "Shows a notice to ask someone else to resolve the discussions" do
expect(page).to have_content("The discussion at #{merge_request.to_reference}"\
" (discussion #{discussion.first_note.id}) will stay unresolved."\
" Ask someone with permission to resolve it.")
diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
index e0b1e286dee..d0567633596 100644
--- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb
@@ -1,22 +1,22 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dropdown assignee', :js do
+describe "Dropdown assignee", :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
- let!(:user) { create(:user, name: 'administrator', username: 'root') }
- let!(:user_john) { create(:user, name: 'John', username: 'th0mas') }
- let!(:user_jacob) { create(:user, name: 'Jacob', username: 'otter32') }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_assignee) { '#js-dropdown-assignee' }
+ let!(:user) { create(:user, name: "administrator", username: "root") }
+ let!(:user_john) { create(:user, name: "John", username: "th0mas") }
+ let!(:user_jacob) { create(:user, name: "Jacob", username: "otter32") }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_assignee) { "#js-dropdown-assignee" }
let(:filter_dropdown) { find("#{js_dropdown_assignee} .filter-dropdown") }
def dropdown_assignee_size
- filter_dropdown.all('.filter-dropdown-item').size
+ filter_dropdown.all(".filter-dropdown-item").size
end
def click_assignee(text)
- find('#js-dropdown-assignee .filter-dropdown .filter-dropdown-item', text: text).click
+ find("#js-dropdown-assignee .filter-dropdown .filter-dropdown-item", text: text).click
end
before do
@@ -29,88 +29,88 @@ describe 'Dropdown assignee', :js do
visit project_issues_path(project)
end
- describe 'behavior' do
- it 'opens when the search bar has assignee:' do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ describe "behavior" do
+ it "opens when the search bar has assignee:" do
+ input_filtered_search("assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).to have_css(js_dropdown_assignee, visible: false)
end
- it 'should show loading indicator when opened' do
+ it "should show loading indicator when opened" do
slow_requests do
# We aren't using `input_filtered_search` because we want to see the loading indicator
- filtered_search.set('assignee:')
+ filtered_search.set("assignee:")
- expect(page).to have_css('#js-dropdown-assignee .filter-dropdown-loading', visible: true)
+ expect(page).to have_css("#js-dropdown-assignee .filter-dropdown-loading", visible: true)
end
end
- it 'should hide loading indicator when loaded' do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ it "should hide loading indicator when loaded" do
+ input_filtered_search("assignee:", submit: false, extra_space: false)
- expect(find(js_dropdown_assignee)).not_to have_css('.filter-dropdown-loading')
+ expect(find(js_dropdown_assignee)).not_to have_css(".filter-dropdown-loading")
end
- it 'should load all the assignees when opened' do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ it "should load all the assignees when opened" do
+ input_filtered_search("assignee:", submit: false, extra_space: false)
expect(dropdown_assignee_size).to eq(4)
end
- it 'shows current user at top of dropdown' do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ it "shows current user at top of dropdown" do
+ input_filtered_search("assignee:", submit: false, extra_space: false)
- expect(filter_dropdown.first('.filter-dropdown-item')).to have_content(user.name)
+ expect(filter_dropdown.first(".filter-dropdown-item")).to have_content(user.name)
end
end
- describe 'filtering' do
+ describe "filtering" do
before do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ input_filtered_search("assignee:", submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_john.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
end
- it 'filters by name' do
- input_filtered_search('jac', submit: false, extra_space: false)
+ it "filters by name" do
+ input_filtered_search("jac", submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name)
end
- it 'filters by case insensitive name' do
- input_filtered_search('JAC', submit: false, extra_space: false)
+ it "filters by case insensitive name" do
+ input_filtered_search("JAC", submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user.name)
end
- it 'filters by username with symbol' do
- input_filtered_search('@ott', submit: false, extra_space: false)
+ it "filters by username with symbol" do
+ input_filtered_search("@ott", submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user_john.name)
end
- it 'filters by case insensitive username with symbol' do
- input_filtered_search('@OTT', submit: false, extra_space: false)
+ it "filters by case insensitive username with symbol" do
+ input_filtered_search("@OTT", submit: false, extra_space: false)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user_jacob.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_content(user.name)
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user_john.name)
end
- it 'filters by username without symbol' do
- input_filtered_search('ott', submit: false, extra_space: false)
+ it "filters by username without symbol" do
+ input_filtered_search("ott", submit: false, extra_space: false)
wait_for_requests
@@ -119,8 +119,8 @@ describe 'Dropdown assignee', :js do
expect(find("#{js_dropdown_assignee} .filter-dropdown")).to have_no_content(user_john.name)
end
- it 'filters by case insensitive username without symbol' do
- input_filtered_search('OTT', submit: false, extra_space: false)
+ it "filters by case insensitive username without symbol" do
+ input_filtered_search("OTT", submit: false, extra_space: false)
wait_for_requests
@@ -130,12 +130,12 @@ describe 'Dropdown assignee', :js do
end
end
- describe 'selecting from dropdown' do
+ describe "selecting from dropdown" do
before do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ input_filtered_search("assignee:", submit: false, extra_space: false)
end
- it 'fills in the assignee username when the assignee has not been filtered' do
+ it "fills in the assignee username when the assignee has not been filtered" do
click_assignee(user_jacob.name)
wait_for_requests
@@ -145,8 +145,8 @@ describe 'Dropdown assignee', :js do
expect_filtered_search_input_empty
end
- it 'fills in the assignee username when the assignee has been filtered' do
- input_filtered_search('roo', submit: false, extra_space: false)
+ it "fills in the assignee username when the assignee has been filtered" do
+ input_filtered_search("roo", submit: false, extra_space: false)
click_assignee(user.name)
wait_for_requests
@@ -156,35 +156,35 @@ describe 'Dropdown assignee', :js do
expect_filtered_search_input_empty
end
- it 'selects `None`' do
- find('#js-dropdown-assignee .filter-dropdown-item', text: 'None').click
+ it "selects `None`" do
+ find("#js-dropdown-assignee .filter-dropdown-item", text: "None").click
expect(page).to have_css(js_dropdown_assignee, visible: false)
- expect_tokens([assignee_token('None')])
+ expect_tokens([assignee_token("None")])
expect_filtered_search_input_empty
end
- it 'selects `Any`' do
- find('#js-dropdown-assignee .filter-dropdown-item', text: 'Any').click
+ it "selects `Any`" do
+ find("#js-dropdown-assignee .filter-dropdown-item", text: "Any").click
expect(page).to have_css(js_dropdown_assignee, visible: false)
- expect_tokens([assignee_token('Any')])
+ expect_tokens([assignee_token("Any")])
expect_filtered_search_input_empty
end
end
- describe 'selecting from dropdown without Ajax call' do
+ describe "selecting from dropdown without Ajax call" do
before do
Gitlab::Testing::RequestBlockerMiddleware.block_requests!
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ input_filtered_search("assignee:", submit: false, extra_space: false)
end
after do
Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
end
- it 'selects current user' do
- find('#js-dropdown-assignee .filter-dropdown-item', text: user.username).click
+ it "selects current user" do
+ find("#js-dropdown-assignee .filter-dropdown-item", text: user.username).click
expect(page).to have_css(js_dropdown_assignee, visible: false)
expect_tokens([assignee_token(user.username)])
@@ -192,49 +192,49 @@ describe 'Dropdown assignee', :js do
end
end
- describe 'input has existing content' do
- it 'opens assignee dropdown with existing search term' do
- input_filtered_search('searchTerm assignee:', submit: false, extra_space: false)
+ describe "input has existing content" do
+ it "opens assignee dropdown with existing search term" do
+ input_filtered_search("searchTerm assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
- it 'opens assignee dropdown with existing author' do
- input_filtered_search('author:@user assignee:', submit: false, extra_space: false)
+ it "opens assignee dropdown with existing author" do
+ input_filtered_search("author:@user assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
- it 'opens assignee dropdown with existing label' do
- input_filtered_search('label:~bug assignee:', submit: false, extra_space: false)
+ it "opens assignee dropdown with existing label" do
+ input_filtered_search("label:~bug assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
- it 'opens assignee dropdown with existing milestone' do
- input_filtered_search('milestone:%v1.0 assignee:', submit: false, extra_space: false)
+ it "opens assignee dropdown with existing milestone" do
+ input_filtered_search("milestone:%v1.0 assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
- it 'opens assignee dropdown with existing my-reaction' do
- input_filtered_search('my-reaction:star assignee:', submit: false, extra_space: false)
+ it "opens assignee dropdown with existing my-reaction" do
+ input_filtered_search("my-reaction:star assignee:", submit: false, extra_space: false)
expect(page).to have_css(js_dropdown_assignee, visible: true)
end
end
- describe 'caching requests' do
- it 'caches requests after the first load' do
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ describe "caching requests" do
+ it "caches requests after the first load" do
+ input_filtered_search("assignee:", submit: false, extra_space: false)
initial_size = dropdown_assignee_size
expect(initial_size).to be > 0
new_user = create(:user)
project.add_maintainer(new_user)
- find('.filtered-search-box .clear-search').click
- input_filtered_search('assignee:', submit: false, extra_space: false)
+ find(".filtered-search-box .clear-search").click
+ input_filtered_search("assignee:", submit: false, extra_space: false)
expect(dropdown_assignee_size).to eq(initial_size)
end
diff --git a/spec/features/issues/filtered_search/dropdown_author_spec.rb b/spec/features/issues/filtered_search/dropdown_author_spec.rb
index bedc61b9eed..26e61e3d390 100644
--- a/spec/features/issues/filtered_search/dropdown_author_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_author_spec.rb
@@ -1,14 +1,14 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dropdown author', :js do
+describe "Dropdown author", :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
- let!(:user) { create(:user, name: 'administrator', username: 'root') }
- let!(:user_john) { create(:user, name: 'John', username: 'th0mas') }
- let!(:user_jacob) { create(:user, name: 'Jacob', username: 'ooter32') }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_author) { '#js-dropdown-author' }
+ let!(:user) { create(:user, name: "administrator", username: "root") }
+ let!(:user_john) { create(:user, name: "John", username: "th0mas") }
+ let!(:user_jacob) { create(:user, name: "Jacob", username: "ooter32") }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_author) { "#js-dropdown-author" }
def send_keys_to_filtered_search(input)
input.split("").each do |i|
@@ -20,11 +20,11 @@ describe 'Dropdown author', :js do
end
def dropdown_author_size
- page.all('#js-dropdown-author .filter-dropdown .filter-dropdown-item').size
+ page.all("#js-dropdown-author .filter-dropdown .filter-dropdown-item").size
end
def click_author(text)
- find('#js-dropdown-author .filter-dropdown .filter-dropdown-item', text: text).click
+ find("#js-dropdown-author .filter-dropdown .filter-dropdown-item", text: text).click
end
before do
@@ -37,90 +37,90 @@ describe 'Dropdown author', :js do
visit project_issues_path(project)
end
- describe 'behavior' do
- it 'opens when the search bar has author:' do
- filtered_search.set('author:')
+ describe "behavior" do
+ it "opens when the search bar has author:" do
+ filtered_search.set("author:")
expect(page).to have_css(js_dropdown_author, visible: true)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).to have_css(js_dropdown_author, visible: false)
end
- it 'should show loading indicator when opened' do
+ it "should show loading indicator when opened" do
slow_requests do
- filtered_search.set('author:')
+ filtered_search.set("author:")
- expect(page).to have_css('#js-dropdown-author .filter-dropdown-loading', visible: true)
+ expect(page).to have_css("#js-dropdown-author .filter-dropdown-loading", visible: true)
end
end
- it 'should hide loading indicator when loaded' do
- send_keys_to_filtered_search('author:')
+ it "should hide loading indicator when loaded" do
+ send_keys_to_filtered_search("author:")
- expect(page).not_to have_css('#js-dropdown-author .filter-dropdown-loading')
+ expect(page).not_to have_css("#js-dropdown-author .filter-dropdown-loading")
end
- it 'should load all the authors when opened' do
- send_keys_to_filtered_search('author:')
+ it "should load all the authors when opened" do
+ send_keys_to_filtered_search("author:")
expect(dropdown_author_size).to eq(4)
end
- it 'shows current user at top of dropdown' do
- send_keys_to_filtered_search('author:')
+ it "shows current user at top of dropdown" do
+ send_keys_to_filtered_search("author:")
- expect(first('#js-dropdown-author li')).to have_content(user.name)
+ expect(first("#js-dropdown-author li")).to have_content(user.name)
end
end
- describe 'filtering' do
+ describe "filtering" do
before do
- filtered_search.set('author')
- send_keys_to_filtered_search(':')
+ filtered_search.set("author")
+ send_keys_to_filtered_search(":")
end
- it 'filters by name' do
- send_keys_to_filtered_search('jac')
+ it "filters by name" do
+ send_keys_to_filtered_search("jac")
expect(dropdown_author_size).to eq(1)
end
- it 'filters by case insensitive name' do
- send_keys_to_filtered_search('Jac')
+ it "filters by case insensitive name" do
+ send_keys_to_filtered_search("Jac")
expect(dropdown_author_size).to eq(1)
end
- it 'filters by username with symbol' do
- send_keys_to_filtered_search('@oot')
+ it "filters by username with symbol" do
+ send_keys_to_filtered_search("@oot")
expect(dropdown_author_size).to eq(2)
end
- it 'filters by username without symbol' do
- send_keys_to_filtered_search('oot')
+ it "filters by username without symbol" do
+ send_keys_to_filtered_search("oot")
expect(dropdown_author_size).to eq(2)
end
- it 'filters by case insensitive username without symbol' do
- send_keys_to_filtered_search('OOT')
+ it "filters by case insensitive username without symbol" do
+ send_keys_to_filtered_search("OOT")
expect(dropdown_author_size).to eq(2)
end
end
- describe 'selecting from dropdown' do
+ describe "selecting from dropdown" do
before do
- filtered_search.set('author')
- send_keys_to_filtered_search(':')
+ filtered_search.set("author")
+ send_keys_to_filtered_search(":")
end
- it 'fills in the author username when the author has not been filtered' do
+ it "fills in the author username when the author has not been filtered" do
click_author(user_jacob.name)
wait_for_requests
@@ -130,7 +130,7 @@ describe 'Dropdown author', :js do
expect_filtered_search_input_empty
end
- it 'fills in the author username when the author has been filtered' do
+ it "fills in the author username when the author has been filtered" do
click_author(user.name)
wait_for_requests
@@ -141,18 +141,18 @@ describe 'Dropdown author', :js do
end
end
- describe 'selecting from dropdown without Ajax call' do
+ describe "selecting from dropdown without Ajax call" do
before do
Gitlab::Testing::RequestBlockerMiddleware.block_requests!
- filtered_search.set('author:')
+ filtered_search.set("author:")
end
after do
Gitlab::Testing::RequestBlockerMiddleware.allow_requests!
end
- it 'selects current user' do
- find('#js-dropdown-author .filter-dropdown-item', text: user.username).click
+ it "selects current user" do
+ find("#js-dropdown-author .filter-dropdown-item", text: user.username).click
expect(page).to have_css(js_dropdown_author, visible: false)
expect_tokens([author_token(user.username)])
@@ -160,45 +160,45 @@ describe 'Dropdown author', :js do
end
end
- describe 'input has existing content' do
- it 'opens author dropdown with existing search term' do
- filtered_search.set('searchTerm author:')
+ describe "input has existing content" do
+ it "opens author dropdown with existing search term" do
+ filtered_search.set("searchTerm author:")
expect(page).to have_css(js_dropdown_author, visible: true)
end
- it 'opens author dropdown with existing assignee' do
- filtered_search.set('assignee:@user author:')
+ it "opens author dropdown with existing assignee" do
+ filtered_search.set("assignee:@user author:")
expect(page).to have_css(js_dropdown_author, visible: true)
end
- it 'opens author dropdown with existing label' do
- filtered_search.set('label:~bug author:')
+ it "opens author dropdown with existing label" do
+ filtered_search.set("label:~bug author:")
expect(page).to have_css(js_dropdown_author, visible: true)
end
- it 'opens author dropdown with existing milestone' do
- filtered_search.set('milestone:%v1.0 author:')
+ it "opens author dropdown with existing milestone" do
+ filtered_search.set("milestone:%v1.0 author:")
expect(page).to have_css(js_dropdown_author, visible: true)
end
end
- describe 'caching requests' do
- it 'caches requests after the first load' do
- filtered_search.set('author')
- send_keys_to_filtered_search(':')
+ describe "caching requests" do
+ it "caches requests after the first load" do
+ filtered_search.set("author")
+ send_keys_to_filtered_search(":")
initial_size = dropdown_author_size
expect(initial_size).to be > 0
new_user = create(:user)
project.add_maintainer(new_user)
- find('.filtered-search-box .clear-search').click
- filtered_search.set('author')
- send_keys_to_filtered_search(':')
+ find(".filtered-search-box .clear-search").click
+ filtered_search.set("author")
+ send_keys_to_filtered_search(":")
expect(dropdown_author_size).to eq(initial_size)
end
diff --git a/spec/features/issues/filtered_search/dropdown_emoji_spec.rb b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb
index f36d4e8f23f..ed7db9b26b9 100644
--- a/spec/features/issues/filtered_search/dropdown_emoji_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_emoji_spec.rb
@@ -1,14 +1,14 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dropdown emoji', :js do
+describe "Dropdown emoji", :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :public) }
- let!(:user) { create(:user, name: 'administrator', username: 'root') }
+ let!(:user) { create(:user, name: "administrator", username: "root") }
let!(:issue) { create(:issue, project: project) }
- let!(:award_emoji_star) { create(:award_emoji, name: 'star', user: user, awardable: issue) }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_emoji) { '#js-dropdown-my-reaction' }
+ let!(:award_emoji_star) { create(:award_emoji, name: "star", user: user, awardable: issue) }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_emoji) { "#js-dropdown-my-reaction" }
def send_keys_to_filtered_search(input)
input.split("").each do |i|
@@ -20,178 +20,178 @@ describe 'Dropdown emoji', :js do
end
def dropdown_emoji_size
- all('gl-emoji[data-name]').size
+ all("gl-emoji[data-name]").size
end
def click_emoji(text)
- find('#js-dropdown-my-reaction .filter-dropdown .filter-dropdown-item', text: text).click
+ find("#js-dropdown-my-reaction .filter-dropdown .filter-dropdown-item", text: text).click
end
before do
project.add_maintainer(user)
- create_list(:award_emoji, 2, user: user, name: 'thumbsup')
- create_list(:award_emoji, 1, user: user, name: 'thumbsdown')
- create_list(:award_emoji, 3, user: user, name: 'star')
- create_list(:award_emoji, 1, user: user, name: 'tea')
+ create_list(:award_emoji, 2, user: user, name: "thumbsup")
+ create_list(:award_emoji, 1, user: user, name: "thumbsdown")
+ create_list(:award_emoji, 3, user: user, name: "star")
+ create_list(:award_emoji, 1, user: user, name: "tea")
end
- context 'when user not logged in' do
+ context "when user not logged in" do
before do
visit project_issues_path(project)
end
- describe 'behavior' do
- it 'does not open when the search bar has my-reaction:' do
- filtered_search.set('my-reaction:')
+ describe "behavior" do
+ it "does not open when the search bar has my-reaction:" do
+ filtered_search.set("my-reaction:")
expect(page).not_to have_css(js_dropdown_emoji)
end
end
end
- context 'when user loggged in' do
+ context "when user loggged in" do
before do
sign_in(user)
visit project_issues_path(project)
end
- describe 'behavior' do
- it 'opens when the search bar has my-reaction:' do
- filtered_search.set('my-reaction:')
+ describe "behavior" do
+ it "opens when the search bar has my-reaction:" do
+ filtered_search.set("my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).to have_css(js_dropdown_emoji, visible: false)
end
- it 'should show loading indicator when opened' do
+ it "should show loading indicator when opened" do
slow_requests do
- filtered_search.set('my-reaction:')
+ filtered_search.set("my-reaction:")
- expect(page).to have_css('#js-dropdown-my-reaction .filter-dropdown-loading', visible: true)
+ expect(page).to have_css("#js-dropdown-my-reaction .filter-dropdown-loading", visible: true)
end
end
- it 'should hide loading indicator when loaded' do
- send_keys_to_filtered_search('my-reaction:')
+ it "should hide loading indicator when loaded" do
+ send_keys_to_filtered_search("my-reaction:")
- expect(page).not_to have_css('#js-dropdown-my-reaction .filter-dropdown-loading')
+ expect(page).not_to have_css("#js-dropdown-my-reaction .filter-dropdown-loading")
end
- it 'should load all the emojis when opened' do
- send_keys_to_filtered_search('my-reaction:')
+ it "should load all the emojis when opened" do
+ send_keys_to_filtered_search("my-reaction:")
expect(dropdown_emoji_size).to eq(4)
end
- it 'shows the most populated emoji at top of dropdown' do
- send_keys_to_filtered_search('my-reaction:')
+ it "shows the most populated emoji at top of dropdown" do
+ send_keys_to_filtered_search("my-reaction:")
- expect(first('#js-dropdown-my-reaction .filter-dropdown li')).to have_content(award_emoji_star.name)
+ expect(first("#js-dropdown-my-reaction .filter-dropdown li")).to have_content(award_emoji_star.name)
end
end
- describe 'filtering' do
+ describe "filtering" do
before do
- filtered_search.set('my-reaction')
- send_keys_to_filtered_search(':')
+ filtered_search.set("my-reaction")
+ send_keys_to_filtered_search(":")
end
- it 'filters by name' do
- send_keys_to_filtered_search('up')
+ it "filters by name" do
+ send_keys_to_filtered_search("up")
expect(dropdown_emoji_size).to eq(1)
end
- it 'filters by case insensitive name' do
- send_keys_to_filtered_search('Up')
+ it "filters by case insensitive name" do
+ send_keys_to_filtered_search("Up")
expect(dropdown_emoji_size).to eq(1)
end
end
- describe 'selecting from dropdown' do
+ describe "selecting from dropdown" do
before do
- filtered_search.set('my-reaction')
- send_keys_to_filtered_search(':')
+ filtered_search.set("my-reaction")
+ send_keys_to_filtered_search(":")
end
- it 'selects `None`' do
- find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'None').click
+ it "selects `None`" do
+ find("#js-dropdown-my-reaction .filter-dropdown-item", text: "None").click
expect(page).to have_css(js_dropdown_emoji, visible: false)
- expect_tokens([reaction_token('None', false)])
+ expect_tokens([reaction_token("None", false)])
expect_filtered_search_input_empty
end
- it 'selects `Any`' do
- find('#js-dropdown-my-reaction .filter-dropdown-item', text: 'Any').click
+ it "selects `Any`" do
+ find("#js-dropdown-my-reaction .filter-dropdown-item", text: "Any").click
expect(page).to have_css(js_dropdown_emoji, visible: false)
- expect_tokens([reaction_token('Any', false)])
+ expect_tokens([reaction_token("Any", false)])
expect_filtered_search_input_empty
end
- it 'fills in the my-reaction name' do
- click_emoji('thumbsup')
+ it "fills in the my-reaction name" do
+ click_emoji("thumbsup")
wait_for_requests
expect(page).to have_css(js_dropdown_emoji, visible: false)
- expect_tokens([reaction_token('thumbsup')])
+ expect_tokens([reaction_token("thumbsup")])
expect_filtered_search_input_empty
end
end
- describe 'input has existing content' do
- it 'opens my-reaction dropdown with existing search term' do
- filtered_search.set('searchTerm my-reaction:')
+ describe "input has existing content" do
+ it "opens my-reaction dropdown with existing search term" do
+ filtered_search.set("searchTerm my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
- it 'opens my-reaction dropdown with existing assignee' do
- filtered_search.set('assignee:@user my-reaction:')
+ it "opens my-reaction dropdown with existing assignee" do
+ filtered_search.set("assignee:@user my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
- it 'opens my-reaction dropdown with existing label' do
- filtered_search.set('label:~bug my-reaction:')
+ it "opens my-reaction dropdown with existing label" do
+ filtered_search.set("label:~bug my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
- it 'opens my-reaction dropdown with existing milestone' do
- filtered_search.set('milestone:%v1.0 my-reaction:')
+ it "opens my-reaction dropdown with existing milestone" do
+ filtered_search.set("milestone:%v1.0 my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
- it 'opens my-reaction dropdown with existing my-reaction' do
- filtered_search.set('my-reaction:star my-reaction:')
+ it "opens my-reaction dropdown with existing my-reaction" do
+ filtered_search.set("my-reaction:star my-reaction:")
expect(page).to have_css(js_dropdown_emoji, visible: true)
end
end
- describe 'caching requests' do
- it 'caches requests after the first load' do
- filtered_search.set('my-reaction')
- send_keys_to_filtered_search(':')
+ describe "caching requests" do
+ it "caches requests after the first load" do
+ filtered_search.set("my-reaction")
+ send_keys_to_filtered_search(":")
initial_size = dropdown_emoji_size
expect(initial_size).to be > 0
- create_list(:award_emoji, 1, user: user, name: 'smile')
- find('.filtered-search-box .clear-search').click
- filtered_search.set('my-reaction')
- send_keys_to_filtered_search(':')
+ create_list(:award_emoji, 1, user: user, name: "smile")
+ find(".filtered-search-box .clear-search").click
+ filtered_search.set("my-reaction")
+ send_keys_to_filtered_search(":")
expect(dropdown_emoji_size).to eq(initial_size)
end
diff --git a/spec/features/issues/filtered_search/dropdown_hint_spec.rb b/spec/features/issues/filtered_search/dropdown_hint_spec.rb
index 096756f19cc..46c8132c888 100644
--- a/spec/features/issues/filtered_search/dropdown_hint_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_hint_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dropdown hint', :js do
+describe "Dropdown hint", :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :public) }
let!(:user) { create(:user) }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_hint) { '#js-dropdown-hint' }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_hint) { "#js-dropdown-hint" }
def click_hint(text)
- find('#js-dropdown-hint .filter-dropdown .filter-dropdown-item', text: text).click
+ find("#js-dropdown-hint .filter-dropdown .filter-dropdown-item", text: text).click
end
before do
@@ -18,236 +18,236 @@ describe 'Dropdown hint', :js do
create(:merge_request, source_project: project, target_project: project)
end
- context 'when user not logged in' do
+ context "when user not logged in" do
before do
visit project_issues_path(project)
end
- it 'does not exist my-reaction dropdown item' do
+ it "does not exist my-reaction dropdown item" do
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).not_to have_content('my-reaction')
+ expect(page).not_to have_content("my-reaction")
end
end
- context 'when user logged in' do
+ context "when user logged in" do
before do
sign_in(user)
visit project_issues_path(project)
end
- describe 'behavior' do
+ describe "behavior" do
before do
expect(page).to have_css(js_dropdown_hint, visible: false)
filtered_search.click
end
- it 'opens when the search bar is first focused' do
+ it "opens when the search bar is first focused" do
expect(page).to have_css(js_dropdown_hint, visible: true)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).to have_css(js_dropdown_hint, visible: false)
end
end
- describe 'filtering' do
- it 'does not filter `Press Enter or click to search`' do
- filtered_search.set('randomtext')
+ describe "filtering" do
+ it "does not filter `Press Enter or click to search`" do
+ filtered_search.set("randomtext")
hint_dropdown = find(js_dropdown_hint)
- expect(hint_dropdown).to have_content('Press Enter or click to search')
- expect(hint_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 0)
+ expect(hint_dropdown).to have_content("Press Enter or click to search")
+ expect(hint_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 0)
end
- it 'filters with text' do
- filtered_search.set('a')
+ it "filters with text" do
+ filtered_search.set("a")
- expect(find(js_dropdown_hint)).to have_selector('.filter-dropdown .filter-dropdown-item', count: 5)
+ expect(find(js_dropdown_hint)).to have_selector(".filter-dropdown .filter-dropdown-item", count: 5)
end
end
- describe 'selecting from dropdown with no input' do
+ describe "selecting from dropdown with no input" do
before do
filtered_search.click
end
- it 'opens the author dropdown when you click on author' do
- click_hint('author')
+ it "opens the author dropdown when you click on author" do
+ click_hint("author")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-author', visible: true)
- expect_tokens([{ name: 'author' }])
+ expect(page).to have_css("#js-dropdown-author", visible: true)
+ expect_tokens([{name: "author"}])
expect_filtered_search_input_empty
end
- it 'opens the assignee dropdown when you click on assignee' do
- click_hint('assignee')
+ it "opens the assignee dropdown when you click on assignee" do
+ click_hint("assignee")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-assignee', visible: true)
- expect_tokens([{ name: 'assignee' }])
+ expect(page).to have_css("#js-dropdown-assignee", visible: true)
+ expect_tokens([{name: "assignee"}])
expect_filtered_search_input_empty
end
- it 'opens the milestone dropdown when you click on milestone' do
- click_hint('milestone')
+ it "opens the milestone dropdown when you click on milestone" do
+ click_hint("milestone")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-milestone', visible: true)
- expect_tokens([{ name: 'milestone' }])
+ expect(page).to have_css("#js-dropdown-milestone", visible: true)
+ expect_tokens([{name: "milestone"}])
expect_filtered_search_input_empty
end
- it 'opens the label dropdown when you click on label' do
- click_hint('label')
+ it "opens the label dropdown when you click on label" do
+ click_hint("label")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-label', visible: true)
- expect_tokens([{ name: 'label' }])
+ expect(page).to have_css("#js-dropdown-label", visible: true)
+ expect_tokens([{name: "label"}])
expect_filtered_search_input_empty
end
- it 'opens the emoji dropdown when you click on my-reaction' do
- click_hint('my-reaction')
+ it "opens the emoji dropdown when you click on my-reaction" do
+ click_hint("my-reaction")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-my-reaction', visible: true)
- expect_tokens([{ name: 'my-reaction' }])
+ expect(page).to have_css("#js-dropdown-my-reaction", visible: true)
+ expect_tokens([{name: "my-reaction"}])
expect_filtered_search_input_empty
end
- it 'opens the yes-no dropdown when you click on confidential' do
- click_hint('confidential')
+ it "opens the yes-no dropdown when you click on confidential" do
+ click_hint("confidential")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-confidential', visible: true)
- expect_tokens([{ name: 'confidential' }])
+ expect(page).to have_css("#js-dropdown-confidential", visible: true)
+ expect_tokens([{name: "confidential"}])
expect_filtered_search_input_empty
end
end
- describe 'selecting from dropdown with some input' do
- it 'opens the author dropdown when you click on author' do
- filtered_search.set('auth')
- click_hint('author')
+ describe "selecting from dropdown with some input" do
+ it "opens the author dropdown when you click on author" do
+ filtered_search.set("auth")
+ click_hint("author")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-author', visible: true)
- expect_tokens([{ name: 'author' }])
+ expect(page).to have_css("#js-dropdown-author", visible: true)
+ expect_tokens([{name: "author"}])
expect_filtered_search_input_empty
end
- it 'opens the assignee dropdown when you click on assignee' do
- filtered_search.set('assign')
- click_hint('assignee')
+ it "opens the assignee dropdown when you click on assignee" do
+ filtered_search.set("assign")
+ click_hint("assignee")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-assignee', visible: true)
- expect_tokens([{ name: 'assignee' }])
+ expect(page).to have_css("#js-dropdown-assignee", visible: true)
+ expect_tokens([{name: "assignee"}])
expect_filtered_search_input_empty
end
- it 'opens the milestone dropdown when you click on milestone' do
- filtered_search.set('mile')
- click_hint('milestone')
+ it "opens the milestone dropdown when you click on milestone" do
+ filtered_search.set("mile")
+ click_hint("milestone")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-milestone', visible: true)
- expect_tokens([{ name: 'milestone' }])
+ expect(page).to have_css("#js-dropdown-milestone", visible: true)
+ expect_tokens([{name: "milestone"}])
expect_filtered_search_input_empty
end
- it 'opens the label dropdown when you click on label' do
- filtered_search.set('lab')
- click_hint('label')
+ it "opens the label dropdown when you click on label" do
+ filtered_search.set("lab")
+ click_hint("label")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-label', visible: true)
- expect_tokens([{ name: 'label' }])
+ expect(page).to have_css("#js-dropdown-label", visible: true)
+ expect_tokens([{name: "label"}])
expect_filtered_search_input_empty
end
- it 'opens the emoji dropdown when you click on my-reaction' do
- filtered_search.set('my')
- click_hint('my-reaction')
+ it "opens the emoji dropdown when you click on my-reaction" do
+ filtered_search.set("my")
+ click_hint("my-reaction")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-my-reaction', visible: true)
- expect_tokens([{ name: 'my-reaction' }])
+ expect(page).to have_css("#js-dropdown-my-reaction", visible: true)
+ expect_tokens([{name: "my-reaction"}])
expect_filtered_search_input_empty
end
end
- describe 'reselecting from dropdown' do
- it 'reuses existing author text' do
- filtered_search.send_keys('author:')
+ describe "reselecting from dropdown" do
+ it "reuses existing author text" do
+ filtered_search.send_keys("author:")
filtered_search.send_keys(:backspace)
filtered_search.send_keys(:backspace)
- click_hint('author')
+ click_hint("author")
- expect_tokens([{ name: 'author' }])
+ expect_tokens([{name: "author"}])
expect_filtered_search_input_empty
end
- it 'reuses existing assignee text' do
- filtered_search.send_keys('assignee:')
+ it "reuses existing assignee text" do
+ filtered_search.send_keys("assignee:")
filtered_search.send_keys(:backspace)
filtered_search.send_keys(:backspace)
- click_hint('assignee')
+ click_hint("assignee")
- expect_tokens([{ name: 'assignee' }])
+ expect_tokens([{name: "assignee"}])
expect_filtered_search_input_empty
end
- it 'reuses existing milestone text' do
- filtered_search.send_keys('milestone:')
+ it "reuses existing milestone text" do
+ filtered_search.send_keys("milestone:")
filtered_search.send_keys(:backspace)
filtered_search.send_keys(:backspace)
- click_hint('milestone')
+ click_hint("milestone")
- expect_tokens([{ name: 'milestone' }])
+ expect_tokens([{name: "milestone"}])
expect_filtered_search_input_empty
end
- it 'reuses existing label text' do
- filtered_search.send_keys('label:')
+ it "reuses existing label text" do
+ filtered_search.send_keys("label:")
filtered_search.send_keys(:backspace)
filtered_search.send_keys(:backspace)
- click_hint('label')
+ click_hint("label")
- expect_tokens([{ name: 'label' }])
+ expect_tokens([{name: "label"}])
expect_filtered_search_input_empty
end
- it 'reuses existing emoji text' do
- filtered_search.send_keys('my-reaction:')
+ it "reuses existing emoji text" do
+ filtered_search.send_keys("my-reaction:")
filtered_search.send_keys(:backspace)
filtered_search.send_keys(:backspace)
- click_hint('my-reaction')
+ click_hint("my-reaction")
- expect_tokens([{ name: 'my-reaction' }])
+ expect_tokens([{name: "my-reaction"}])
expect_filtered_search_input_empty
end
end
end
- context 'merge request page' do
+ context "merge request page" do
before do
sign_in(user)
visit project_merge_requests_path(project)
filtered_search.click
end
- it 'shows the WIP menu item and opens the WIP options dropdown' do
- click_hint('wip')
+ it "shows the WIP menu item and opens the WIP options dropdown" do
+ click_hint("wip")
expect(page).to have_css(js_dropdown_hint, visible: false)
- expect(page).to have_css('#js-dropdown-wip', visible: true)
- expect_tokens([{ name: 'wip' }])
+ expect(page).to have_css("#js-dropdown-wip", visible: true)
+ expect_tokens([{name: "wip"}])
expect_filtered_search_input_empty
end
end
diff --git a/spec/features/issues/filtered_search/dropdown_label_spec.rb b/spec/features/issues/filtered_search/dropdown_label_spec.rb
index f502061dfce..a0ba60ac42f 100644
--- a/spec/features/issues/filtered_search/dropdown_label_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_label_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Dropdown label', :js do
+describe "Dropdown label", :js do
include FilteredSearchHelpers
let(:project) { create(:project) }
let(:user) { create(:user) }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_label) { '#js-dropdown-label' }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_label) { "#js-dropdown-label" }
let(:filter_dropdown) { find("#{js_dropdown_label} .filter-dropdown") }
- shared_context 'with labels' do
- let!(:bug_label) { create(:label, project: project, title: 'bug-label') }
- let!(:uppercase_label) { create(:label, project: project, title: 'BUG-LABEL') }
- let!(:two_words_label) { create(:label, project: project, title: 'High Priority') }
+ shared_context "with labels" do
+ let!(:bug_label) { create(:label, project: project, title: "bug-label") }
+ let!(:uppercase_label) { create(:label, project: project, title: "BUG-LABEL") }
+ let!(:two_words_label) { create(:label, project: project, title: "High Priority") }
let!(:wont_fix_label) { create(:label, project: project, title: 'Won"t Fix') }
- let!(:wont_fix_single_label) { create(:label, project: project, title: 'Won\'t Fix') }
- let!(:special_label) { create(:label, project: project, title: '!@#$%^+&*()') }
- let!(:long_label) { create(:label, project: project, title: 'this is a very long title this is a very long title this is a very long title this is a very long title this is a very long title') }
+ let!(:wont_fix_single_label) { create(:label, project: project, title: "Won't Fix") }
+ let!(:special_label) { create(:label, project: project, title: "!@\#$%^+&*()") }
+ let!(:long_label) { create(:label, project: project, title: "this is a very long title this is a very long title this is a very long title this is a very long title this is a very long title") }
end
def search_for_label(label)
@@ -25,11 +25,11 @@ describe 'Dropdown label', :js do
end
def click_label(text)
- filter_dropdown.find('.filter-dropdown-item', text: text).click
+ filter_dropdown.find(".filter-dropdown-item", text: text).click
end
def clear_search_field
- find('.filtered-search-box .clear-search').click
+ find(".filtered-search-box .clear-search").click
end
before do
@@ -40,9 +40,9 @@ describe 'Dropdown label', :js do
visit project_issues_path(project)
end
- describe 'keyboard navigation' do
- it 'selects label' do
- bug_label = create(:label, project: project, title: 'bug-label')
+ describe "keyboard navigation" do
+ it "selects label" do
+ bug_label = create(:label, project: project, title: "bug-label")
init_label_search
# navigate to the bug_label option and selects it
@@ -53,131 +53,131 @@ describe 'Dropdown label', :js do
end
end
- describe 'behavior' do
- it 'opens when the search bar has label:' do
- filtered_search.set('label:')
+ describe "behavior" do
+ it "opens when the search bar has label:" do
+ filtered_search.set("label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).not_to have_css(js_dropdown_label)
end
- it 'shows loading indicator when opened and hides it when loaded' do
+ it "shows loading indicator when opened and hides it when loaded" do
slow_requests do
- filtered_search.set('label:')
+ filtered_search.set("label:")
expect(page).to have_css("#{js_dropdown_label} .filter-dropdown-loading", visible: true)
end
- expect(find(js_dropdown_label)).not_to have_css('.filter-dropdown-loading')
+ expect(find(js_dropdown_label)).not_to have_css(".filter-dropdown-loading")
end
- it 'loads all the labels when opened' do
- bug_label = create(:label, project: project, title: 'bug-label')
- filtered_search.set('label:')
+ it "loads all the labels when opened" do
+ bug_label = create(:label, project: project, title: "bug-label")
+ filtered_search.set("label:")
expect(filter_dropdown).to have_content(bug_label.title)
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
end
- describe 'filtering' do
- include_context 'with labels'
+ describe "filtering" do
+ include_context "with labels"
before do
init_label_search
end
- it 'filters by case-insensitive name with or without symbol' do
- filtered_search.send_keys('b')
+ it "filters by case-insensitive name with or without symbol" do
+ filtered_search.send_keys("b")
- expect(filter_dropdown.find('.filter-dropdown-item', text: bug_label.title)).to be_visible
- expect(filter_dropdown.find('.filter-dropdown-item', text: uppercase_label.title)).to be_visible
+ expect(filter_dropdown.find(".filter-dropdown-item", text: bug_label.title)).to be_visible
+ expect(filter_dropdown.find(".filter-dropdown-item", text: uppercase_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 2)
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 2)
clear_search_field
init_label_search
- filtered_search.send_keys('~bu')
+ filtered_search.send_keys("~bu")
- expect(filter_dropdown.find('.filter-dropdown-item', text: bug_label.title)).to be_visible
- expect(filter_dropdown.find('.filter-dropdown-item', text: uppercase_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 2)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: bug_label.title)).to be_visible
+ expect(filter_dropdown.find(".filter-dropdown-item", text: uppercase_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 2)
end
- it 'filters by multiple words with or without symbol' do
- filtered_search.send_keys('Hig')
+ it "filters by multiple words with or without symbol" do
+ filtered_search.send_keys("Hig")
- expect(filter_dropdown.find('.filter-dropdown-item', text: two_words_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: two_words_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
clear_search_field
init_label_search
- filtered_search.send_keys('~Hig')
+ filtered_search.send_keys("~Hig")
- expect(filter_dropdown.find('.filter-dropdown-item', text: two_words_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: two_words_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
- it 'filters by multiple words containing single quotes with or without symbol' do
- filtered_search.send_keys('won\'t')
+ it "filters by multiple words containing single quotes with or without symbol" do
+ filtered_search.send_keys("won't")
- expect(filter_dropdown.find('.filter-dropdown-item', text: wont_fix_single_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: wont_fix_single_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
clear_search_field
init_label_search
- filtered_search.send_keys('~won\'t')
+ filtered_search.send_keys("~won't")
- expect(filter_dropdown.find('.filter-dropdown-item', text: wont_fix_single_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: wont_fix_single_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
- it 'filters by multiple words containing double quotes with or without symbol' do
+ it "filters by multiple words containing double quotes with or without symbol" do
filtered_search.send_keys('won"t')
- expect(filter_dropdown.find('.filter-dropdown-item', text: wont_fix_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: wont_fix_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
clear_search_field
init_label_search
filtered_search.send_keys('~won"t')
- expect(filter_dropdown.find('.filter-dropdown-item', text: wont_fix_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: wont_fix_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
- it 'filters by special characters with or without symbol' do
- filtered_search.send_keys('^+')
+ it "filters by special characters with or without symbol" do
+ filtered_search.send_keys("^+")
- expect(filter_dropdown.find('.filter-dropdown-item', text: special_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: special_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
clear_search_field
init_label_search
- filtered_search.send_keys('~^+')
+ filtered_search.send_keys("~^+")
- expect(filter_dropdown.find('.filter-dropdown-item', text: special_label.title)).to be_visible
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown.find(".filter-dropdown-item", text: special_label.title)).to be_visible
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
end
- describe 'selecting from dropdown' do
- include_context 'with labels'
+ describe "selecting from dropdown" do
+ include_context "with labels"
before do
init_label_search
end
- it 'fills in the label name when the label has not been filled' do
+ it "fills in the label name when the label has not been filled" do
click_label(bug_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -185,8 +185,8 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name when the label is partially filled' do
- filtered_search.send_keys('bu')
+ it "fills in the label name when the label is partially filled" do
+ filtered_search.send_keys("bu")
click_label(bug_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -194,7 +194,7 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name that contains multiple words' do
+ it "fills in the label name that contains multiple words" do
click_label(two_words_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -202,7 +202,7 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name that contains multiple words and is very long' do
+ it "fills in the label name that contains multiple words and is very long" do
click_label(long_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -210,7 +210,7 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name that contains double quotes' do
+ it "fills in the label name that contains double quotes" do
click_label(wont_fix_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -218,7 +218,7 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name with the correct capitalization' do
+ it "fills in the label name with the correct capitalization" do
click_label(uppercase_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -226,7 +226,7 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'fills in the label name with special characters' do
+ it "fills in the label name with special characters" do
click_label(special_label.title)
expect(page).not_to have_css(js_dropdown_label)
@@ -234,73 +234,73 @@ describe 'Dropdown label', :js do
expect_filtered_search_input_empty
end
- it 'selects `no label`' do
- find("#{js_dropdown_label} .filter-dropdown-item", text: 'None').click
+ it "selects `no label`" do
+ find("#{js_dropdown_label} .filter-dropdown-item", text: "None").click
expect(page).not_to have_css(js_dropdown_label)
- expect_tokens([label_token('None', false)])
+ expect_tokens([label_token("None", false)])
expect_filtered_search_input_empty
end
- it 'selects `any label`' do
- find("#{js_dropdown_label} .filter-dropdown-item", text: 'Any').click
+ it "selects `any label`" do
+ find("#{js_dropdown_label} .filter-dropdown-item", text: "Any").click
expect(page).not_to have_css(js_dropdown_label)
- expect_tokens([label_token('Any', false)])
+ expect_tokens([label_token("Any", false)])
expect_filtered_search_input_empty
end
end
- describe 'input has existing content' do
- it 'opens label dropdown with existing search term' do
- filtered_search.set('searchTerm label:')
+ describe "input has existing content" do
+ it "opens label dropdown with existing search term" do
+ filtered_search.set("searchTerm label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'opens label dropdown with existing author' do
- filtered_search.set('author:@person label:')
+ it "opens label dropdown with existing author" do
+ filtered_search.set("author:@person label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'opens label dropdown with existing assignee' do
- filtered_search.set('assignee:@person label:')
+ it "opens label dropdown with existing assignee" do
+ filtered_search.set("assignee:@person label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'opens label dropdown with existing label' do
- filtered_search.set('label:~urgent label:')
+ it "opens label dropdown with existing label" do
+ filtered_search.set("label:~urgent label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'opens label dropdown with existing milestone' do
- filtered_search.set('milestone:%v2.0 label:')
+ it "opens label dropdown with existing milestone" do
+ filtered_search.set("milestone:%v2.0 label:")
expect(page).to have_css(js_dropdown_label)
end
- it 'opens label dropdown with existing my-reaction' do
- filtered_search.set('my-reaction:star label:')
+ it "opens label dropdown with existing my-reaction" do
+ filtered_search.set("my-reaction:star label:")
expect(page).to have_css(js_dropdown_label)
end
end
- describe 'caching requests' do
- it 'caches requests after the first load' do
- create(:label, project: project, title: 'bug-label')
+ describe "caching requests" do
+ it "caches requests after the first load" do
+ create(:label, project: project, title: "bug-label")
init_label_search
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
create(:label, project: project)
clear_search_field
init_label_search
- expect(filter_dropdown).to have_selector('.filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown-item", count: 1)
end
end
end
diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
index b330eafe1d1..c692faa00d4 100644
--- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
+++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb
@@ -1,31 +1,31 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Dropdown milestone', :js do
+describe "Dropdown milestone", :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user) }
- let!(:milestone) { create(:milestone, title: 'v1.0', project: project) }
- let!(:uppercase_milestone) { create(:milestone, title: 'CAP_MILESTONE', project: project) }
- let!(:two_words_milestone) { create(:milestone, title: 'Future Plan', project: project) }
+ let!(:milestone) { create(:milestone, title: "v1.0", project: project) }
+ let!(:uppercase_milestone) { create(:milestone, title: "CAP_MILESTONE", project: project) }
+ let!(:two_words_milestone) { create(:milestone, title: "Future Plan", project: project) }
let!(:wont_fix_milestone) { create(:milestone, title: 'Won"t Fix', project: project) }
- let!(:special_milestone) { create(:milestone, title: '!@#$%^&*(+)', project: project) }
- let!(:long_milestone) { create(:milestone, title: 'this is a very long title this is a very long title this is a very long title this is a very long title this is a very long title', project: project) }
+ let!(:special_milestone) { create(:milestone, title: "!@\#$%^&*(+)", project: project) }
+ let!(:long_milestone) { create(:milestone, title: "this is a very long title this is a very long title this is a very long title this is a very long title this is a very long title", project: project) }
- let(:filtered_search) { find('.filtered-search') }
- let(:js_dropdown_milestone) { '#js-dropdown-milestone' }
+ let(:filtered_search) { find(".filtered-search") }
+ let(:js_dropdown_milestone) { "#js-dropdown-milestone" }
let(:filter_dropdown) { find("#{js_dropdown_milestone} .filter-dropdown") }
def dropdown_milestone_size
- filter_dropdown.all('.filter-dropdown-item').size
+ filter_dropdown.all(".filter-dropdown-item").size
end
def click_milestone(text)
- find('#js-dropdown-milestone .filter-dropdown .filter-dropdown-item', text: text).click
+ find("#js-dropdown-milestone .filter-dropdown .filter-dropdown-item", text: text).click
end
def click_static_milestone(text)
- find('#js-dropdown-milestone .filter-dropdown-item', text: text).click
+ find("#js-dropdown-milestone .filter-dropdown-item", text: text).click
end
before do
@@ -36,43 +36,43 @@ describe 'Dropdown milestone', :js do
visit project_issues_path(project)
end
- describe 'behavior' do
- it 'opens when the search bar has milestone:' do
- filtered_search.set('milestone:')
+ describe "behavior" do
+ it "opens when the search bar has milestone:" do
+ filtered_search.set("milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'closes when the search bar is unfocused' do
- find('body').click
+ it "closes when the search bar is unfocused" do
+ find("body").click
expect(page).to have_css(js_dropdown_milestone, visible: false)
end
- it 'should show loading indicator when opened' do
+ it "should show loading indicator when opened" do
slow_requests do
- filtered_search.set('milestone:')
+ filtered_search.set("milestone:")
- expect(page).to have_css('#js-dropdown-milestone .filter-dropdown-loading', visible: true)
+ expect(page).to have_css("#js-dropdown-milestone .filter-dropdown-loading", visible: true)
end
end
- it 'should hide loading indicator when loaded' do
- filtered_search.set('milestone:')
+ it "should hide loading indicator when loaded" do
+ filtered_search.set("milestone:")
- expect(find(js_dropdown_milestone)).not_to have_css('.filter-dropdown-loading')
+ expect(find(js_dropdown_milestone)).not_to have_css(".filter-dropdown-loading")
end
- it 'should load all the milestones when opened' do
- filtered_search.set('milestone:')
+ it "should load all the milestones when opened" do
+ filtered_search.set("milestone:")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 6)
end
end
- describe 'filtering' do
+ describe "filtering" do
before do
- filtered_search.set('milestone:')
+ filtered_search.set("milestone:")
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(milestone.title)
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(uppercase_milestone.title)
@@ -82,46 +82,46 @@ describe 'Dropdown milestone', :js do
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(long_milestone.title)
end
- it 'filters by name' do
- filtered_search.send_keys('v1')
+ it "filters by name" do
+ filtered_search.send_keys("v1")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'filters by case insensitive name' do
- filtered_search.send_keys('V1')
+ it "filters by case insensitive name" do
+ filtered_search.send_keys("V1")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'filters by name with symbol' do
- filtered_search.send_keys('%v1')
+ it "filters by name with symbol" do
+ filtered_search.send_keys("%v1")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'filters by case insensitive name with symbol' do
- filtered_search.send_keys('%V1')
+ it "filters by case insensitive name with symbol" do
+ filtered_search.send_keys("%V1")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'filters by special characters' do
- filtered_search.send_keys('(+')
+ it "filters by special characters" do
+ filtered_search.send_keys("(+")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'filters by special characters with symbol' do
- filtered_search.send_keys('%(+')
+ it "filters by special characters with symbol" do
+ filtered_search.send_keys("%(+")
- expect(filter_dropdown).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(filter_dropdown).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
end
- describe 'selecting from dropdown' do
+ describe "selecting from dropdown" do
before do
- filtered_search.set('milestone:')
+ filtered_search.set("milestone:")
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(milestone.title)
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(uppercase_milestone.title)
@@ -131,7 +131,7 @@ describe 'Dropdown milestone', :js do
expect(find("#{js_dropdown_milestone} .filter-dropdown")).to have_content(long_milestone.title)
end
- it 'fills in the milestone name when the milestone has not been filled' do
+ it "fills in the milestone name when the milestone has not been filled" do
click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -139,8 +139,8 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name when the milestone is partially filled' do
- filtered_search.send_keys('v')
+ it "fills in the milestone name when the milestone is partially filled" do
+ filtered_search.send_keys("v")
click_milestone(milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -148,7 +148,7 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name that contains multiple words' do
+ it "fills in the milestone name that contains multiple words" do
click_milestone(two_words_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -156,7 +156,7 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name that contains multiple words and is very long' do
+ it "fills in the milestone name that contains multiple words and is very long" do
click_milestone(long_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -164,7 +164,7 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name that contains double quotes' do
+ it "fills in the milestone name that contains double quotes" do
click_milestone(wont_fix_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -172,7 +172,7 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name with the correct capitalization' do
+ it "fills in the milestone name with the correct capitalization" do
click_milestone(uppercase_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -180,7 +180,7 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'fills in the milestone name with special characters' do
+ it "fills in the milestone name with special characters" do
click_milestone(special_milestone.title)
expect(page).to have_css(js_dropdown_milestone, visible: false)
@@ -188,87 +188,87 @@ describe 'Dropdown milestone', :js do
expect_filtered_search_input_empty
end
- it 'selects `no milestone`' do
- click_static_milestone('None')
+ it "selects `no milestone`" do
+ click_static_milestone("None")
expect(page).to have_css(js_dropdown_milestone, visible: false)
- expect_tokens([milestone_token('None', false)])
+ expect_tokens([milestone_token("None", false)])
expect_filtered_search_input_empty
end
- it 'selects `any milestone`' do
- click_static_milestone('Any')
+ it "selects `any milestone`" do
+ click_static_milestone("Any")
expect(page).to have_css(js_dropdown_milestone, visible: false)
- expect_tokens([milestone_token('Any', false)])
+ expect_tokens([milestone_token("Any", false)])
expect_filtered_search_input_empty
end
- it 'selects `upcoming milestone`' do
- click_static_milestone('Upcoming')
+ it "selects `upcoming milestone`" do
+ click_static_milestone("Upcoming")
expect(page).to have_css(js_dropdown_milestone, visible: false)
- expect_tokens([milestone_token('Upcoming', false)])
+ expect_tokens([milestone_token("Upcoming", false)])
expect_filtered_search_input_empty
end
- it 'selects `started milestones`' do
- click_static_milestone('Started')
+ it "selects `started milestones`" do
+ click_static_milestone("Started")
expect(page).to have_css(js_dropdown_milestone, visible: false)
- expect_tokens([milestone_token('Started', false)])
+ expect_tokens([milestone_token("Started", false)])
expect_filtered_search_input_empty
end
end
- describe 'input has existing content' do
- it 'opens milestone dropdown with existing search term' do
- filtered_search.set('searchTerm milestone:')
+ describe "input has existing content" do
+ it "opens milestone dropdown with existing search term" do
+ filtered_search.set("searchTerm milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'opens milestone dropdown with existing author' do
- filtered_search.set('author:@john milestone:')
+ it "opens milestone dropdown with existing author" do
+ filtered_search.set("author:@john milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'opens milestone dropdown with existing assignee' do
- filtered_search.set('assignee:@john milestone:')
+ it "opens milestone dropdown with existing assignee" do
+ filtered_search.set("assignee:@john milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'opens milestone dropdown with existing label' do
- filtered_search.set('label:~important milestone:')
+ it "opens milestone dropdown with existing label" do
+ filtered_search.set("label:~important milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'opens milestone dropdown with existing milestone' do
- filtered_search.set('milestone:%100 milestone:')
+ it "opens milestone dropdown with existing milestone" do
+ filtered_search.set("milestone:%100 milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
- it 'opens milestone dropdown with existing my-reaction' do
- filtered_search.set('my-reaction:star milestone:')
+ it "opens milestone dropdown with existing my-reaction" do
+ filtered_search.set("my-reaction:star milestone:")
expect(page).to have_css(js_dropdown_milestone, visible: true)
end
end
- describe 'caching requests' do
- it 'caches requests after the first load' do
- filtered_search.set('milestone:')
+ describe "caching requests" do
+ it "caches requests after the first load" do
+ filtered_search.set("milestone:")
initial_size = dropdown_milestone_size
expect(initial_size).to be > 0
create(:milestone, project: project)
- find('.filtered-search-box .clear-search').click
- filtered_search.set('milestone:')
+ find(".filtered-search-box .clear-search").click
+ filtered_search.set("milestone:")
expect(dropdown_milestone_size).to eq(initial_size)
end
diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb
index fa8e5cb0ca9..a54a12d631d 100644
--- a/spec/features/issues/filtered_search/filter_issues_spec.rb
+++ b/spec/features/issues/filtered_search/filter_issues_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Filter issues', :js do
+describe "Filter issues", :js do
include FilteredSearchHelpers
let(:project) { create(:project) }
@@ -9,17 +9,17 @@ describe 'Filter issues', :js do
#
# When the name is longer, the filtered search input can end up scrolling
# horizontally, and PhantomJS can't handle it.
- let(:user) { create(:user, name: 'Ann') }
- let(:user2) { create(:user, name: 'jane') }
+ let(:user) { create(:user, name: "Ann") }
+ let(:user2) { create(:user, name: "jane") }
- let!(:bug_label) { create(:label, project: project, title: 'bug') }
- let!(:caps_sensitive_label) { create(:label, project: project, title: 'CaPs') }
+ let!(:bug_label) { create(:label, project: project, title: "bug") }
+ let!(:caps_sensitive_label) { create(:label, project: project, title: "CaPs") }
let!(:multiple_words_label) { create(:label, project: project, title: "Two words") }
let!(:milestone) { create(:milestone, title: "8", project: project, start_date: 2.days.ago) }
def expect_no_issues_list
- page.within '.issues-list' do
- expect(page).to have_no_selector('.issue')
+ page.within ".issues-list" do
+ expect(page).to have_no_selector(".issue")
end
end
@@ -62,8 +62,8 @@ describe 'Filter issues', :js do
visit project_issues_path(project)
end
- it 'filters by all available tokens' do
- search_term = 'issue'
+ it "filters by all available tokens" do
+ search_term = "issue"
input_filtered_search("assignee:@#{user.username} author:@#{user.username} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} #{search_term}")
@@ -73,15 +73,15 @@ describe 'Filter issues', :js do
assignee_token(user.name),
author_token(user.name),
label_token(caps_sensitive_label.title),
- milestone_token(milestone.title)
+ milestone_token(milestone.title),
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
- describe 'filter issues by author' do
- context 'only author' do
- it 'filters issues by searched author' do
+ describe "filter issues by author" do
+ context "only author" do
+ it "filters issues by searched author" do
input_filtered_search("author:@#{user.username}")
wait_for_requests
@@ -93,9 +93,9 @@ describe 'Filter issues', :js do
end
end
- describe 'filter issues by assignee' do
- context 'only assignee' do
- it 'filters issues by searched assignee' do
+ describe "filter issues by assignee" do
+ context "only assignee" do
+ it "filters issues by searched assignee" do
input_filtered_search("assignee:@#{user.username}")
wait_for_requests
@@ -105,26 +105,26 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'filters issues by no assignee' do
- input_filtered_search('assignee:none')
+ it "filters issues by no assignee" do
+ input_filtered_search("assignee:none")
- expect_tokens([assignee_token('None')])
+ expect_tokens([assignee_token("None")])
expect_issues_list_count(3)
expect_filtered_search_input_empty
end
- it 'filters issues by invalid assignee' do
- skip('to be tested, issue #26546')
+ it "filters issues by invalid assignee" do
+ skip("to be tested, issue #26546")
end
- it 'filters issues by multiple assignees' do
+ it "filters issues by multiple assignees" do
create(:issue, project: project, author: user, assignees: [user2, user])
input_filtered_search("assignee:@#{user.username} assignee:@#{user2.username}")
expect_tokens([
assignee_token(user.name),
- assignee_token(user2.name)
+ assignee_token(user2.name),
])
expect_issues_list_count(1)
@@ -133,9 +133,9 @@ describe 'Filter issues', :js do
end
end
- describe 'filter issues by label' do
- context 'only label' do
- it 'filters issues by searched label' do
+ describe "filter issues by label" do
+ context "only label" do
+ it "filters issues by searched label" do
input_filtered_search("label:~#{bug_label.title}")
expect_tokens([label_token(bug_label.title)])
@@ -143,26 +143,26 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'filters issues by no label' do
- input_filtered_search('label:none')
+ it "filters issues by no label" do
+ input_filtered_search("label:none")
- expect_tokens([label_token('None', false)])
+ expect_tokens([label_token("None", false)])
expect_issues_list_count(4)
expect_filtered_search_input_empty
end
- it 'filters issues by multiple labels' do
+ it "filters issues by multiple labels" do
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title}")
expect_tokens([
label_token(bug_label.title),
- label_token(caps_sensitive_label.title)
+ label_token(caps_sensitive_label.title),
])
expect_issues_list_count(1)
expect_filtered_search_input_empty
end
- it 'filters issues by label containing special characters' do
+ it "filters issues by label containing special characters" do
special_label = create(:label, project: project, title: '!@#{$%^&*()-+[]<>?/:{}|\}')
special_issue = create(:issue, title: "Issue with special character label", project: project)
special_issue.labels << special_label
@@ -174,8 +174,8 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'does not show issues for unused labels' do
- new_label = create(:label, project: project, title: 'new_label')
+ it "does not show issues for unused labels" do
+ new_label = create(:label, project: project, title: "new_label")
input_filtered_search("label:~#{new_label.title}")
@@ -185,8 +185,8 @@ describe 'Filter issues', :js do
end
end
- context 'label with multiple words' do
- it 'special characters' do
+ context "label with multiple words" do
+ it "special characters" do
special_multiple_label = create(:label, project: project, title: "Utmost |mp0rt@nce")
special_multiple_issue = create(:issue, title: "Issue with special character multiple words label", project: project)
special_multiple_issue.labels << special_multiple_label
@@ -202,7 +202,7 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'single quotes' do
+ it "single quotes" do
input_filtered_search("label:~'#{multiple_words_label.title}'")
expect_issues_list_count(1)
@@ -210,7 +210,7 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'double quotes' do
+ it "double quotes" do
input_filtered_search("label:~\"#{multiple_words_label.title}\"")
expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
@@ -218,7 +218,7 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'single quotes containing double quotes' do
+ it "single quotes containing double quotes" do
double_quotes_label = create(:label, project: project, title: 'won"t fix')
double_quotes_label_issue = create(:issue, title: "Issue with double quotes label", project: project)
double_quotes_label_issue.labels << double_quotes_label
@@ -230,7 +230,7 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'double quotes containing single quotes' do
+ it "double quotes containing single quotes" do
single_quotes_label = create(:label, project: project, title: "won't fix")
single_quotes_label_issue = create(:issue, title: "Issue with single quotes label", project: project)
single_quotes_label_issue.labels << single_quotes_label
@@ -243,9 +243,9 @@ describe 'Filter issues', :js do
end
end
- context 'multiple labels with other filters' do
- it 'filters issues by searched label, label2, author, assignee, milestone and text' do
- search_term = 'bug'
+ context "multiple labels with other filters" do
+ it "filters issues by searched label, label2, author, assignee, milestone and text" do
+ search_term = "bug"
input_filtered_search("label:~#{bug_label.title} label:~#{caps_sensitive_label.title} author:@#{user.username} assignee:@#{user.username} milestone:%#{milestone.title} #{search_term}")
@@ -256,16 +256,16 @@ describe 'Filter issues', :js do
label_token(caps_sensitive_label.title),
author_token(user.name),
assignee_token(user.name),
- milestone_token(milestone.title)
+ milestone_token(milestone.title),
])
expect_issues_list_count(1)
expect_filtered_search_input(search_term)
end
end
- context 'issue label clicked' do
- it 'filters and displays in search bar' do
- find('.issues-list .issue .issuable-main-info .issuable-info a .badge', text: multiple_words_label.title).click
+ context "issue label clicked" do
+ it "filters and displays in search bar" do
+ find(".issues-list .issue .issuable-main-info .issuable-info a .badge", text: multiple_words_label.title).click
expect_issues_list_count(1)
expect_tokens([label_token("\"#{multiple_words_label.title}\"")])
@@ -274,9 +274,9 @@ describe 'Filter issues', :js do
end
end
- describe 'filter issues by milestone' do
- context 'only milestone' do
- it 'filters issues by searched milestone' do
+ describe "filter issues by milestone" do
+ context "only milestone" do
+ it "filters issues by searched milestone" do
input_filtered_search("milestone:%#{milestone.title}")
expect_tokens([milestone_token(milestone.title)])
@@ -284,35 +284,35 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'filters issues by no milestone' do
+ it "filters issues by no milestone" do
input_filtered_search("milestone:none")
- expect_tokens([milestone_token('None', false)])
+ expect_tokens([milestone_token("None", false)])
expect_issues_list_count(3)
expect_filtered_search_input_empty
end
- it 'filters issues by upcoming milestones' do
+ it "filters issues by upcoming milestones" do
create(:milestone, project: project, due_date: 1.month.from_now) do |future_milestone|
create(:issue, project: project, milestone: future_milestone, author: user)
end
input_filtered_search("milestone:upcoming")
- expect_tokens([milestone_token('Upcoming', false)])
+ expect_tokens([milestone_token("Upcoming", false)])
expect_issues_list_count(1)
expect_filtered_search_input_empty
end
- it 'filters issues by started milestones' do
+ it "filters issues by started milestones" do
input_filtered_search("milestone:started")
- expect_tokens([milestone_token('Started', false)])
+ expect_tokens([milestone_token("Started", false)])
expect_issues_list_count(5)
expect_filtered_search_input_empty
end
- it 'filters issues by milestone containing special characters' do
+ it "filters issues by milestone containing special characters" do
special_milestone = create(:milestone, title: '!@\#{$%^&*()}', project: project)
create(:issue, project: project, milestone: special_milestone)
@@ -323,8 +323,8 @@ describe 'Filter issues', :js do
expect_filtered_search_input_empty
end
- it 'does not show issues for unused milestones' do
- new_milestone = create(:milestone, title: 'new', project: project)
+ it "does not show issues for unused milestones" do
+ new_milestone = create(:milestone, title: "new", project: project)
input_filtered_search("milestone:%#{new_milestone.title}")
@@ -335,33 +335,33 @@ describe 'Filter issues', :js do
end
end
- describe 'filter issues by text' do
- context 'only text' do
- it 'filters issues by searched text' do
- search = 'Bug'
+ describe "filter issues by text" do
+ context "only text" do
+ it "filters issues by searched text" do
+ search = "Bug"
input_filtered_search(search)
expect_issues_list_count(4)
expect_filtered_search_input(search)
end
- it 'filters issues by multiple searched text' do
- search = 'Bug report'
+ it "filters issues by multiple searched text" do
+ search = "Bug report"
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
- it 'filters issues by case insensitive searched text' do
- search = 'bug report'
+ it "filters issues by case insensitive searched text" do
+ search = "bug report"
input_filtered_search(search)
expect_issues_list_count(3)
expect_filtered_search_input(search)
end
- it 'filters issues by searched text containing single quotes' do
+ it "filters issues by searched text containing single quotes" do
issue = create(:issue, project: project, author: user, title: "issue with 'single quotes'")
search = "'single quotes'"
@@ -372,7 +372,7 @@ describe 'Filter issues', :js do
expect(page).to have_content(issue.title)
end
- it 'filters issues by searched text containing double quotes' do
+ it "filters issues by searched text containing double quotes" do
issue = create(:issue, project: project, author: user, title: "issue with \"double quotes\"")
search = '"double quotes"'
@@ -383,7 +383,7 @@ describe 'Filter issues', :js do
expect(page).to have_content(issue.title)
end
- it 'filters issues by searched text containing special characters' do
+ it "filters issues by searched text containing special characters" do
issue = create(:issue, project: project, author: user, title: "issue with !@\#{$%^&*()-+")
search = '!@#{$%^&*()-+'
@@ -394,8 +394,8 @@ describe 'Filter issues', :js do
expect(page).to have_content(issue.title)
end
- it 'does not show any issues' do
- search = 'testing'
+ it "does not show any issues" do
+ search = "testing"
input_filtered_search(search)
expect_no_issues_list
@@ -403,77 +403,77 @@ describe 'Filter issues', :js do
end
end
- context 'searched text with other filters' do
- it 'filters issues by searched text, author, text, assignee, text, label1, text, label2, text, milestone and text' do
+ context "searched text with other filters" do
+ it "filters issues by searched text, author, text, assignee, text, label1, text, label2, text, milestone and text" do
input_filtered_search("bug author:@#{user.username} report label:~#{bug_label.title} label:~#{caps_sensitive_label.title} milestone:%#{milestone.title} foo")
expect_issues_list_count(1)
- expect_filtered_search_input('bug report foo')
+ expect_filtered_search_input("bug report foo")
end
end
- context 'sorting' do
- it 'sorts by created date' do
+ context "sorting" do
+ it "sorts by created date" do
new_issue = create(:issue,
- title: '3 days ago',
+ title: "3 days ago",
project: project,
author: user,
created_at: 3.days.ago)
create(:issue,
- title: '5 days ago',
+ title: "5 days ago",
project: project,
author: user,
created_at: 5.days.ago)
- input_filtered_search('days ago')
+ input_filtered_search("days ago")
expect_issues_list_count(2)
- sort_toggle = find('.filter-dropdown-container .dropdown')
+ sort_toggle = find(".filter-dropdown-container .dropdown")
sort_toggle.click
- find('.filter-dropdown-container .dropdown-menu li a', text: 'Created date').click
+ find(".filter-dropdown-container .dropdown-menu li a", text: "Created date").click
wait_for_requests
- expect(find('.issues-list .issue:first-of-type .issue-title-text a')).to have_content(new_issue.title)
+ expect(find(".issues-list .issue:first-of-type .issue-title-text a")).to have_content(new_issue.title)
end
end
end
- describe 'switching issue states' do
- let!(:closed_issue) { create(:issue, :closed, project: project, title: 'closed bug') }
+ describe "switching issue states" do
+ let!(:closed_issue) { create(:issue, :closed, project: project, title: "closed bug") }
before do
- input_filtered_search('bug')
+ input_filtered_search("bug")
# This ensures that the search is performed
expect_issues_list_count(4, 1)
end
- it 'maintains filter' do
+ it "maintains filter" do
# Closed
find('.issues-state-filters [data-state="closed"]').click
wait_for_requests
- expect(page).to have_selector('.issues-list .issue', count: 1)
+ expect(page).to have_selector(".issues-list .issue", count: 1)
expect(page).to have_link(closed_issue.title)
# Opened
find('.issues-state-filters [data-state="opened"]').click
wait_for_requests
- expect(page).to have_selector('.issues-list .issue', count: 4)
+ expect(page).to have_selector(".issues-list .issue", count: 4)
# All
find('.issues-state-filters [data-state="all"]').click
wait_for_requests
- expect(page).to have_selector('.issues-list .issue', count: 5)
+ expect(page).to have_selector(".issues-list .issue", count: 5)
end
end
- describe 'RSS feeds' do
+ describe "RSS feeds" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
@@ -481,19 +481,19 @@ describe 'Filter issues', :js do
group.add_developer(user)
end
- shared_examples 'updates atom feed link' do |type|
+ shared_examples "updates atom feed link" do |type|
it "for #{type}" do
visit path
- link = find_link('Subscribe to RSS feed')
+ link = find_link("Subscribe to RSS feed")
params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
expected = {
- 'feed_token' => [user.feed_token],
- 'milestone_title' => [milestone.title],
- 'assignee_id' => [user.id.to_s]
+ "feed_token" => [user.feed_token],
+ "milestone_title" => [milestone.title],
+ "assignee_id" => [user.id.to_s],
}
expect(params).to include(expected)
@@ -501,48 +501,48 @@ describe 'Filter issues', :js do
end
end
- it_behaves_like 'updates atom feed link', :project do
+ it_behaves_like "updates atom feed link", :project do
let(:path) { project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id) }
end
- it_behaves_like 'updates atom feed link', :group do
+ it_behaves_like "updates atom feed link", :group do
let(:path) { issues_group_path(group, milestone_title: milestone.title, assignee_id: user.id) }
end
- it 'updates atom feed link for group issues' do
+ it "updates atom feed link for group issues" do
visit issues_group_path(group, milestone_title: milestone.title, assignee_id: user.id)
link = find('.nav-controls a[title="Subscribe to RSS feed"]', visible: false)
params = CGI.parse(URI.parse(link[:href]).query)
auto_discovery_link = find('link[type="application/atom+xml"]', visible: false)
auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query)
- expect(params).to include('feed_token' => [user.feed_token])
- expect(params).to include('milestone_title' => [milestone.title])
- expect(params).to include('assignee_id' => [user.id.to_s])
- expect(auto_discovery_params).to include('feed_token' => [user.feed_token])
- expect(auto_discovery_params).to include('milestone_title' => [milestone.title])
- expect(auto_discovery_params).to include('assignee_id' => [user.id.to_s])
+ expect(params).to include("feed_token" => [user.feed_token])
+ expect(params).to include("milestone_title" => [milestone.title])
+ expect(params).to include("assignee_id" => [user.id.to_s])
+ expect(auto_discovery_params).to include("feed_token" => [user.feed_token])
+ expect(auto_discovery_params).to include("milestone_title" => [milestone.title])
+ expect(auto_discovery_params).to include("assignee_id" => [user.id.to_s])
end
end
- context 'URL has a trailing slash' do
+ context "URL has a trailing slash" do
before do
visit "#{project_issues_path(project)}/"
end
- it 'milestone dropdown loads milestones' do
+ it "milestone dropdown loads milestones" do
input_filtered_search("milestone:", submit: false)
- within('#js-dropdown-milestone') do
- expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ within("#js-dropdown-milestone") do
+ expect(page).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
end
end
- it 'label dropdown load labels' do
+ it "label dropdown load labels" do
input_filtered_search("label:", submit: false)
- within('#js-dropdown-label') do
- expect(page).to have_selector('.filter-dropdown .filter-dropdown-item', count: 3)
+ within("#js-dropdown-label") do
+ expect(page).to have_selector(".filter-dropdown .filter-dropdown-item", count: 3)
end
end
end
diff --git a/spec/features/issues/filtered_search/recent_searches_spec.rb b/spec/features/issues/filtered_search/recent_searches_spec.rb
index 41b9ada988a..b7929d31903 100644
--- a/spec/features/issues/filtered_search/recent_searches_spec.rb
+++ b/spec/features/issues/filtered_search/recent_searches_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Recent searches', :js do
+describe "Recent searches", :js do
include FilteredSearchHelpers
let(:project_1) { create(:project, :public) }
@@ -13,7 +13,7 @@ describe 'Recent searches', :js do
create(:issue, project: project_2)
# Visit any fast-loading page so we can clear local storage without a DOM exception
- visit '/404'
+ visit "/404"
remove_recent_searches
end
@@ -21,85 +21,85 @@ describe 'Recent searches', :js do
Capybara.ignore_hidden_elements = true
end
- it 'searching adds to recent searches' do
+ it "searching adds to recent searches" do
visit project_issues_path(project_1)
- input_filtered_search('foo', submit: true)
- input_filtered_search('bar', submit: true)
+ input_filtered_search("foo", submit: true)
+ input_filtered_search("bar", submit: true)
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ items = all(".filtered-search-history-dropdown-item", visible: false, count: 2)
- expect(items[0].text).to eq('bar')
- expect(items[1].text).to eq('foo')
+ expect(items[0].text).to eq("bar")
+ expect(items[1].text).to eq("foo")
end
- it 'visiting URL with search params adds to recent searches' do
- visit project_issues_path(project_1, label_name: 'foo', search: 'bar')
- visit project_issues_path(project_1, label_name: 'qux', search: 'garply')
+ it "visiting URL with search params adds to recent searches" do
+ visit project_issues_path(project_1, label_name: "foo", search: "bar")
+ visit project_issues_path(project_1, label_name: "qux", search: "garply")
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ items = all(".filtered-search-history-dropdown-item", visible: false, count: 2)
- expect(items[0].text).to eq('label: ~qux garply')
- expect(items[1].text).to eq('label: ~foo bar')
+ expect(items[0].text).to eq("label: ~qux garply")
+ expect(items[1].text).to eq("label: ~foo bar")
end
- it 'saved recent searches are restored last on the list' do
+ it "saved recent searches are restored last on the list" do
set_recent_searches(project_1_local_storage_key, '["saved1", "saved2"]')
- visit project_issues_path(project_1, search: 'foo')
+ visit project_issues_path(project_1, search: "foo")
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 3)
+ items = all(".filtered-search-history-dropdown-item", visible: false, count: 3)
- expect(items[0].text).to eq('foo')
- expect(items[1].text).to eq('saved1')
- expect(items[2].text).to eq('saved2')
+ expect(items[0].text).to eq("foo")
+ expect(items[1].text).to eq("saved1")
+ expect(items[2].text).to eq("saved2")
end
- it 'searches are scoped to projects' do
+ it "searches are scoped to projects" do
visit project_issues_path(project_1)
- input_filtered_search('foo', submit: true)
- input_filtered_search('bar', submit: true)
+ input_filtered_search("foo", submit: true)
+ input_filtered_search("bar", submit: true)
visit project_issues_path(project_2)
- input_filtered_search('more', submit: true)
- input_filtered_search('things', submit: true)
+ input_filtered_search("more", submit: true)
+ input_filtered_search("things", submit: true)
- items = all('.filtered-search-history-dropdown-item', visible: false, count: 2)
+ items = all(".filtered-search-history-dropdown-item", visible: false, count: 2)
- expect(items[0].text).to eq('things')
- expect(items[1].text).to eq('more')
+ expect(items[0].text).to eq("things")
+ expect(items[1].text).to eq("more")
end
- it 'clicking item fills search input' do
+ it "clicking item fills search input" do
set_recent_searches(project_1_local_storage_key, '["foo", "bar"]')
visit project_issues_path(project_1)
- find('.filtered-search-history-dropdown-toggle-button').click
- all('.filtered-search-history-dropdown-item', count: 2)[0].click
- wait_for_filtered_search('foo')
+ find(".filtered-search-history-dropdown-toggle-button").click
+ all(".filtered-search-history-dropdown-item", count: 2)[0].click
+ wait_for_filtered_search("foo")
- expect(find('.filtered-search').value.strip).to eq('foo')
+ expect(find(".filtered-search").value.strip).to eq("foo")
end
- it 'clear recent searches button, clears recent searches' do
+ it "clear recent searches button, clears recent searches" do
set_recent_searches(project_1_local_storage_key, '["foo"]')
visit project_issues_path(project_1)
- find('.filtered-search-history-dropdown-toggle-button').click
- all('.filtered-search-history-dropdown-item', count: 1)
+ find(".filtered-search-history-dropdown-toggle-button").click
+ all(".filtered-search-history-dropdown-item", count: 1)
- find('.filtered-search-history-clear-button').click
- items_after = all('.filtered-search-history-dropdown-item', count: 0)
+ find(".filtered-search-history-clear-button").click
+ items_after = all(".filtered-search-history-dropdown-item", count: 0)
expect(items_after.count).to eq(0)
end
- it 'shows flash error when failed to parse saved history' do
- set_recent_searches(project_1_local_storage_key, 'fail')
+ it "shows flash error when failed to parse saved history" do
+ set_recent_searches(project_1_local_storage_key, "fail")
visit project_issues_path(project_1)
- expect(find('.flash-alert')).to have_text('An error occurred while parsing recent searches')
+ expect(find(".flash-alert")).to have_text("An error occurred while parsing recent searches")
end
end
diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb
index da23aea1fc9..976c9f002a1 100644
--- a/spec/features/issues/filtered_search/search_bar_spec.rb
+++ b/spec/features/issues/filtered_search/search_bar_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Search bar', :js do
+describe "Search bar", :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
let!(:user) { create(:user) }
- let(:filtered_search) { find('.filtered-search') }
+ let(:filtered_search) { find(".filtered-search") }
before do
project.add_maintainer(user)
@@ -17,19 +17,19 @@ describe 'Search bar', :js do
def get_left_style(style)
left_style = /left:\s\d*[.]\d*px/.match(style)
- left_style.to_s.gsub('left: ', '').to_f
+ left_style.to_s.gsub("left: ", "").to_f
end
- describe 'keyboard navigation' do
- it 'makes item active' do
+ describe "keyboard navigation" do
+ it "makes item active" do
filtered_search.native.send_keys(:down)
- page.within '#js-dropdown-hint' do
- expect(page).to have_selector('.droplab-item-active')
+ page.within "#js-dropdown-hint" do
+ expect(page).to have_selector(".droplab-item-active")
end
end
- it 'selects item' do
+ it "selects item" do
filtered_search.native.send_keys(:down, :down, :enter)
expect_tokens([author_token])
@@ -37,71 +37,71 @@ describe 'Search bar', :js do
end
end
- describe 'clear search button' do
- it 'clears text' do
- search_text = 'search_text'
+ describe "clear search button" do
+ it "clears text" do
+ search_text = "search_text"
filtered_search.set(search_text)
expect(filtered_search.value).to eq(search_text)
- find('.filtered-search-box .clear-search').click
+ find(".filtered-search-box .clear-search").click
- expect(filtered_search.value).to eq('')
+ expect(filtered_search.value).to eq("")
end
- it 'hides by default' do
- expect(page).to have_css('.clear-search', visible: false)
+ it "hides by default" do
+ expect(page).to have_css(".clear-search", visible: false)
end
- it 'hides after clicked' do
- filtered_search.set('a')
- find('.filtered-search-box .clear-search').click
+ it "hides after clicked" do
+ filtered_search.set("a")
+ find(".filtered-search-box .clear-search").click
- expect(page).to have_css('.clear-search', visible: false)
+ expect(page).to have_css(".clear-search", visible: false)
end
- it 'hides when there is no text' do
- filtered_search.set('a')
- filtered_search.set('')
+ it "hides when there is no text" do
+ filtered_search.set("a")
+ filtered_search.set("")
- expect(page).to have_css('.clear-search', visible: false)
+ expect(page).to have_css(".clear-search", visible: false)
end
- it 'shows when there is text' do
- filtered_search.set('a')
+ it "shows when there is text" do
+ filtered_search.set("a")
- expect(page).to have_css('.clear-search', visible: true)
+ expect(page).to have_css(".clear-search", visible: true)
end
- it 'resets the dropdown hint filter' do
+ it "resets the dropdown hint filter" do
filtered_search.click
- original_size = page.all('#js-dropdown-hint .filter-dropdown .filter-dropdown-item').size
+ original_size = page.all("#js-dropdown-hint .filter-dropdown .filter-dropdown-item").size
- filtered_search.set('author')
+ filtered_search.set("author")
- expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 1)
+ expect(find("#js-dropdown-hint")).to have_selector(".filter-dropdown .filter-dropdown-item", count: 1)
- find('.filtered-search-box .clear-search').click
+ find(".filtered-search-box .clear-search").click
filtered_search.click
- expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: original_size)
+ expect(find("#js-dropdown-hint")).to have_selector(".filter-dropdown .filter-dropdown-item", count: original_size)
end
- it 'resets the dropdown filters', :quarantine do
+ it "resets the dropdown filters", :quarantine do
filtered_search.click
- hint_offset = get_left_style(find('#js-dropdown-hint')['style'])
+ hint_offset = get_left_style(find("#js-dropdown-hint")["style"])
- filtered_search.set('a')
+ filtered_search.set("a")
- filtered_search.set('author:')
+ filtered_search.set("author:")
- find('#js-dropdown-hint', visible: false)
+ find("#js-dropdown-hint", visible: false)
- find('.filtered-search-box .clear-search').click
+ find(".filtered-search-box .clear-search").click
filtered_search.click
- expect(find('#js-dropdown-hint')).to have_selector('.filter-dropdown .filter-dropdown-item', count: 6)
- expect(get_left_style(find('#js-dropdown-hint')['style'])).to eq(hint_offset)
+ expect(find("#js-dropdown-hint")).to have_selector(".filter-dropdown .filter-dropdown-item", count: 6)
+ expect(get_left_style(find("#js-dropdown-hint")["style"])).to eq(hint_offset)
end
end
end
diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb
index 9fd661d80ae..c1d5db067fb 100644
--- a/spec/features/issues/filtered_search/visual_tokens_spec.rb
+++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Visual tokens', :js do
+describe "Visual tokens", :js do
include FilteredSearchHelpers
let!(:project) { create(:project) }
- let!(:user) { create(:user, name: 'administrator', username: 'root') }
- let!(:user_rock) { create(:user, name: 'The Rock', username: 'rock') }
- let!(:milestone_nine) { create(:milestone, title: '9.0', project: project) }
- let!(:milestone_ten) { create(:milestone, title: '10.0', project: project) }
- let!(:label) { create(:label, project: project, title: 'abc') }
- let!(:cc_label) { create(:label, project: project, title: 'Community Contribution') }
-
- let(:filtered_search) { find('.filtered-search') }
+ let!(:user) { create(:user, name: "administrator", username: "root") }
+ let!(:user_rock) { create(:user, name: "The Rock", username: "rock") }
+ let!(:milestone_nine) { create(:milestone, title: "9.0", project: project) }
+ let!(:milestone_ten) { create(:milestone, title: "10.0", project: project) }
+ let!(:label) { create(:label, project: project, title: "abc") }
+ let!(:cc_label) { create(:label, project: project, title: "Community Contribution") }
+
+ let(:filtered_search) { find(".filtered-search") }
let(:filter_author_dropdown) { find("#js-dropdown-author .filter-dropdown") }
let(:filter_assignee_dropdown) { find("#js-dropdown-assignee .filter-dropdown") }
let(:filter_milestone_dropdown) { find("#js-dropdown-milestone .filter-dropdown") }
@@ -27,307 +27,307 @@ describe 'Visual tokens', :js do
sign_in(user)
create(:issue, project: project)
- set_cookie('sidebar_collapsed', 'true')
+ set_cookie("sidebar_collapsed", "true")
visit project_issues_path(project)
end
- describe 'editing author token' do
+ describe "editing author token" do
before do
- input_filtered_search('author:@root assignee:none', submit: false)
- first('.tokens-container .filtered-search-token').click
+ input_filtered_search("author:@root assignee:none", submit: false)
+ first(".tokens-container .filtered-search-token").click
end
- it 'opens author dropdown' do
- expect(page).to have_css('#js-dropdown-author', visible: true)
+ it "opens author dropdown" do
+ expect(page).to have_css("#js-dropdown-author", visible: true)
end
- it 'makes value editable' do
- expect_filtered_search_input('@root')
+ it "makes value editable" do
+ expect_filtered_search_input("@root")
end
- it 'filters value' do
+ it "filters value" do
filtered_search.send_keys(:backspace)
- expect(page).to have_css('#js-dropdown-author .filter-dropdown .filter-dropdown-item', count: 1)
+ expect(page).to have_css("#js-dropdown-author .filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'ends editing mode when document is clicked' do
- find('#content-body').click
+ it "ends editing mode when document is clicked" do
+ find("#content-body").click
expect_filtered_search_input_empty
- expect(page).to have_css('#js-dropdown-author', visible: false)
+ expect(page).to have_css("#js-dropdown-author", visible: false)
end
- describe 'selecting different author from dropdown' do
+ describe "selecting different author from dropdown" do
before do
- filter_author_dropdown.find('.filter-dropdown-item .dropdown-light-content', text: "@#{user_rock.username}").click
+ filter_author_dropdown.find(".filter-dropdown-item .dropdown-light-content", text: "@#{user_rock.username}").click
end
- it 'changes value in visual token' do
+ it "changes value in visual token" do
wait_for_requests
- expect(first('.tokens-container .filtered-search-token .value').text).to eq("#{user_rock.name}")
+ expect(first(".tokens-container .filtered-search-token .value").text).to eq(user_rock.name.to_s)
end
- it 'moves input to the right' do
+ it "moves input to the right" do
expect(is_input_focused).to eq(true)
end
end
end
- describe 'editing assignee token' do
+ describe "editing assignee token" do
before do
- input_filtered_search('assignee:@root author:none', submit: false)
- first('.tokens-container .filtered-search-token').double_click
+ input_filtered_search("assignee:@root author:none", submit: false)
+ first(".tokens-container .filtered-search-token").double_click
end
- it 'opens assignee dropdown' do
- expect(page).to have_css('#js-dropdown-assignee', visible: true)
+ it "opens assignee dropdown" do
+ expect(page).to have_css("#js-dropdown-assignee", visible: true)
end
- it 'makes value editable' do
- expect_filtered_search_input('@root')
+ it "makes value editable" do
+ expect_filtered_search_input("@root")
end
- it 'filters value' do
+ it "filters value" do
filtered_search.send_keys(:backspace)
- expect(page).to have_css('#js-dropdown-assignee .filter-dropdown .filter-dropdown-item', count: 1)
+ expect(page).to have_css("#js-dropdown-assignee .filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'ends editing mode when document is clicked' do
- find('#content-body').click
+ it "ends editing mode when document is clicked" do
+ find("#content-body").click
expect_filtered_search_input_empty
- expect(page).to have_css('#js-dropdown-assignee', visible: false)
+ expect(page).to have_css("#js-dropdown-assignee", visible: false)
end
- describe 'selecting static option from dropdown' do
+ describe "selecting static option from dropdown" do
before do
- find("#js-dropdown-assignee").find('.filter-dropdown-item', text: 'None').click
+ find("#js-dropdown-assignee").find(".filter-dropdown-item", text: "None").click
end
- it 'changes value in visual token' do
- expect(first('.tokens-container .filtered-search-token .value').text).to eq('None')
+ it "changes value in visual token" do
+ expect(first(".tokens-container .filtered-search-token .value").text).to eq("None")
end
- it 'moves input to the right' do
+ it "moves input to the right" do
expect(is_input_focused).to eq(true)
end
end
end
- describe 'editing milestone token' do
+ describe "editing milestone token" do
before do
- input_filtered_search('milestone:%10.0 author:none', submit: false)
- first('.tokens-container .filtered-search-token').click
- first('#js-dropdown-milestone .filter-dropdown .filter-dropdown-item')
+ input_filtered_search("milestone:%10.0 author:none", submit: false)
+ first(".tokens-container .filtered-search-token").click
+ first("#js-dropdown-milestone .filter-dropdown .filter-dropdown-item")
end
- it 'opens milestone dropdown' do
- expect(filter_milestone_dropdown.find('.filter-dropdown-item', text: milestone_ten.title)).to be_visible
- expect(filter_milestone_dropdown.find('.filter-dropdown-item', text: milestone_nine.title)).to be_visible
- expect(page).to have_css('#js-dropdown-milestone', visible: true)
+ it "opens milestone dropdown" do
+ expect(filter_milestone_dropdown.find(".filter-dropdown-item", text: milestone_ten.title)).to be_visible
+ expect(filter_milestone_dropdown.find(".filter-dropdown-item", text: milestone_nine.title)).to be_visible
+ expect(page).to have_css("#js-dropdown-milestone", visible: true)
end
- it 'selects static option from dropdown' do
- find("#js-dropdown-milestone").find('.filter-dropdown-item', text: 'Upcoming').click
+ it "selects static option from dropdown" do
+ find("#js-dropdown-milestone").find(".filter-dropdown-item", text: "Upcoming").click
- expect(first('.tokens-container .filtered-search-token .value').text).to eq('Upcoming')
+ expect(first(".tokens-container .filtered-search-token .value").text).to eq("Upcoming")
expect(is_input_focused).to eq(true)
end
- it 'makes value editable' do
- expect_filtered_search_input('%10.0')
+ it "makes value editable" do
+ expect_filtered_search_input("%10.0")
end
- it 'filters value' do
+ it "filters value" do
filtered_search.send_keys(:backspace)
- expect(page).to have_css('#js-dropdown-milestone .filter-dropdown .filter-dropdown-item', count: 1)
+ expect(page).to have_css("#js-dropdown-milestone .filter-dropdown .filter-dropdown-item", count: 1)
end
- it 'ends editing mode when document is clicked' do
- find('#content-body').click
+ it "ends editing mode when document is clicked" do
+ find("#content-body").click
expect_filtered_search_input_empty
- expect(page).to have_css('#js-dropdown-milestone', visible: false)
+ expect(page).to have_css("#js-dropdown-milestone", visible: false)
end
end
- describe 'editing label token' do
+ describe "editing label token" do
before do
input_filtered_search("label:~#{label.title} author:none", submit: false)
- first('.tokens-container .filtered-search-token').double_click
- first('#js-dropdown-label .filter-dropdown .filter-dropdown-item')
+ first(".tokens-container .filtered-search-token").double_click
+ first("#js-dropdown-label .filter-dropdown .filter-dropdown-item")
end
- it 'opens label dropdown' do
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: label.title)).to be_visible
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: cc_label.title)).to be_visible
- expect(page).to have_css('#js-dropdown-label', visible: true)
+ it "opens label dropdown" do
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: label.title)).to be_visible
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: cc_label.title)).to be_visible
+ expect(page).to have_css("#js-dropdown-label", visible: true)
end
- it 'selects option from dropdown' do
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: label.title)).to be_visible
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: cc_label.title)).to be_visible
+ it "selects option from dropdown" do
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: label.title)).to be_visible
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: cc_label.title)).to be_visible
- find("#js-dropdown-label").find('.filter-dropdown-item', text: cc_label.title).click
+ find("#js-dropdown-label").find(".filter-dropdown-item", text: cc_label.title).click
- expect(first('.tokens-container .filtered-search-token .value').text).to eq("~\"#{cc_label.title}\"")
+ expect(first(".tokens-container .filtered-search-token .value").text).to eq("~\"#{cc_label.title}\"")
expect(is_input_focused).to eq(true)
end
- it 'makes value editable' do
+ it "makes value editable" do
expect_filtered_search_input("~#{label.title}")
end
- it 'filters value' do
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: label.title)).to be_visible
- expect(filter_label_dropdown.find('.filter-dropdown-item', text: cc_label.title)).to be_visible
+ it "filters value" do
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: label.title)).to be_visible
+ expect(filter_label_dropdown.find(".filter-dropdown-item", text: cc_label.title)).to be_visible
filtered_search.send_keys(:backspace)
- filter_label_dropdown.find('.filter-dropdown-item')
+ filter_label_dropdown.find(".filter-dropdown-item")
- expect(page.all('#js-dropdown-label .filter-dropdown .filter-dropdown-item').size).to eq(1)
+ expect(page.all("#js-dropdown-label .filter-dropdown .filter-dropdown-item").size).to eq(1)
end
- it 'ends editing mode when document is clicked' do
- find('#content-body').click
+ it "ends editing mode when document is clicked" do
+ find("#content-body").click
expect_filtered_search_input_empty
- expect(page).to have_css('#js-dropdown-label', visible: false)
+ expect(page).to have_css("#js-dropdown-label", visible: false)
end
- it 'ends editing mode when scroll container is clicked' do
- find('.scroll-container').click
+ it "ends editing mode when scroll container is clicked" do
+ find(".scroll-container").click
expect_filtered_search_input_empty
- expect(page).to have_css('#js-dropdown-label', visible: false)
+ expect(page).to have_css("#js-dropdown-label", visible: false)
end
end
- describe 'editing multiple tokens' do
+ describe "editing multiple tokens" do
before do
- input_filtered_search('author:@root assignee:none', submit: false)
- first('.tokens-container .filtered-search-token').double_click
+ input_filtered_search("author:@root assignee:none", submit: false)
+ first(".tokens-container .filtered-search-token").double_click
end
- it 'opens author dropdown' do
- expect(page).to have_css('#js-dropdown-author', visible: true)
+ it "opens author dropdown" do
+ expect(page).to have_css("#js-dropdown-author", visible: true)
end
- it 'opens assignee dropdown' do
- find('.tokens-container .filtered-search-token', text: 'Assignee').double_click
- expect(page).to have_css('#js-dropdown-assignee', visible: true)
+ it "opens assignee dropdown" do
+ find(".tokens-container .filtered-search-token", text: "Assignee").double_click
+ expect(page).to have_css("#js-dropdown-assignee", visible: true)
end
end
- describe 'editing a search term while editing another filter token' do
+ describe "editing a search term while editing another filter token" do
before do
- input_filtered_search('author assignee:', submit: false)
- first('.tokens-container .filtered-search-term').double_click
+ input_filtered_search("author assignee:", submit: false)
+ first(".tokens-container .filtered-search-term").double_click
end
- it 'opens hint dropdown' do
- expect(page).to have_css('#js-dropdown-hint', visible: true)
+ it "opens hint dropdown" do
+ expect(page).to have_css("#js-dropdown-hint", visible: true)
end
- it 'opens author dropdown' do
- find('#js-dropdown-hint .filter-dropdown .filter-dropdown-item', text: 'author').click
+ it "opens author dropdown" do
+ find("#js-dropdown-hint .filter-dropdown .filter-dropdown-item", text: "author").click
- expect(page).to have_css('#js-dropdown-author', visible: true)
+ expect(page).to have_css("#js-dropdown-author", visible: true)
end
end
- describe 'add new token after editing existing token' do
+ describe "add new token after editing existing token" do
before do
- input_filtered_search('author:@root assignee:none', submit: false)
- first('.tokens-container .filtered-search-token').double_click
- filtered_search.send_keys(' ')
+ input_filtered_search("author:@root assignee:none", submit: false)
+ first(".tokens-container .filtered-search-token").double_click
+ filtered_search.send_keys(" ")
end
- describe 'opens dropdowns' do
- it 'opens hint dropdown' do
- expect(page).to have_css('#js-dropdown-hint', visible: true)
+ describe "opens dropdowns" do
+ it "opens hint dropdown" do
+ expect(page).to have_css("#js-dropdown-hint", visible: true)
end
- it 'opens author dropdown' do
- filtered_search.send_keys('author:')
- expect(page).to have_css('#js-dropdown-author', visible: true)
+ it "opens author dropdown" do
+ filtered_search.send_keys("author:")
+ expect(page).to have_css("#js-dropdown-author", visible: true)
end
- it 'opens assignee dropdown' do
- filtered_search.send_keys('assignee:')
- expect(page).to have_css('#js-dropdown-assignee', visible: true)
+ it "opens assignee dropdown" do
+ filtered_search.send_keys("assignee:")
+ expect(page).to have_css("#js-dropdown-assignee", visible: true)
end
- it 'opens milestone dropdown' do
- filtered_search.send_keys('milestone:')
- expect(page).to have_css('#js-dropdown-milestone', visible: true)
+ it "opens milestone dropdown" do
+ filtered_search.send_keys("milestone:")
+ expect(page).to have_css("#js-dropdown-milestone", visible: true)
end
- it 'opens label dropdown' do
- filtered_search.send_keys('label:')
- expect(page).to have_css('#js-dropdown-label', visible: true)
+ it "opens label dropdown" do
+ filtered_search.send_keys("label:")
+ expect(page).to have_css("#js-dropdown-label", visible: true)
end
end
- describe 'creates visual tokens' do
- it 'creates author token' do
- filtered_search.send_keys('author:@thomas ')
- token = page.all('.tokens-container .filtered-search-token')[1]
+ describe "creates visual tokens" do
+ it "creates author token" do
+ filtered_search.send_keys("author:@thomas ")
+ token = page.all(".tokens-container .filtered-search-token")[1]
- expect(token.find('.name').text).to eq('Author')
- expect(token.find('.value').text).to eq('@thomas')
+ expect(token.find(".name").text).to eq("Author")
+ expect(token.find(".value").text).to eq("@thomas")
end
- it 'creates assignee token' do
- filtered_search.send_keys('assignee:@thomas ')
- token = page.all('.tokens-container .filtered-search-token')[1]
+ it "creates assignee token" do
+ filtered_search.send_keys("assignee:@thomas ")
+ token = page.all(".tokens-container .filtered-search-token")[1]
- expect(token.find('.name').text).to eq('Assignee')
- expect(token.find('.value').text).to eq('@thomas')
+ expect(token.find(".name").text).to eq("Assignee")
+ expect(token.find(".value").text).to eq("@thomas")
end
- it 'creates milestone token' do
- filtered_search.send_keys('milestone:none ')
- token = page.all('.tokens-container .filtered-search-token')[1]
+ it "creates milestone token" do
+ filtered_search.send_keys("milestone:none ")
+ token = page.all(".tokens-container .filtered-search-token")[1]
- expect(token.find('.name').text).to eq('Milestone')
- expect(token.find('.value').text).to eq('none')
+ expect(token.find(".name").text).to eq("Milestone")
+ expect(token.find(".value").text).to eq("none")
end
- it 'creates label token' do
- filtered_search.send_keys('label:~Backend ')
- token = page.all('.tokens-container .filtered-search-token')[1]
+ it "creates label token" do
+ filtered_search.send_keys("label:~Backend ")
+ token = page.all(".tokens-container .filtered-search-token")[1]
- expect(token.find('.name').text).to eq('Label')
- expect(token.find('.value').text).to eq('~Backend')
+ expect(token.find(".name").text).to eq("Label")
+ expect(token.find(".value").text).to eq("~Backend")
end
end
- it 'does not tokenize incomplete token' do
- filtered_search.send_keys('author:')
+ it "does not tokenize incomplete token" do
+ filtered_search.send_keys("author:")
- find('body').click
- token = page.all('.tokens-container .js-visual-token')[1]
+ find("body").click
+ token = page.all(".tokens-container .js-visual-token")[1]
expect_filtered_search_input_empty
- expect(token.find('.name').text).to eq('Author')
+ expect(token.find(".name").text).to eq("Author")
end
end
- describe 'search using incomplete visual tokens' do
+ describe "search using incomplete visual tokens" do
before do
- input_filtered_search('author:@root assignee:none', extra_space: false)
+ input_filtered_search("author:@root assignee:none", extra_space: false)
end
- it 'tokenizes the search term to complete visual token' do
+ it "tokenizes the search term to complete visual token" do
expect_tokens([
author_token(user.name),
- assignee_token('None')
+ assignee_token("None"),
])
end
end
diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb
index f2e4c5779df..10c15d26963 100644
--- a/spec/features/issues/form_spec.rb
+++ b/spec/features/issues/form_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New/edit issue', :js do
+describe "New/edit issue", :js do
include ActionView::Helpers::JavaScriptHelper
include FormHelper
@@ -18,12 +18,12 @@ describe 'New/edit issue', :js do
sign_in(user)
end
- context 'new issue' do
+ context "new issue" do
before do
visit new_project_issue_path(project)
end
- describe 'shorten users API pagination limit' do
+ describe "shorten users API pagination limit" do
before do
# Using `allow_any_instance_of`/`and_wrap_original`, `original` would
# somehow refer to the very block we defined to _wrap_ that method, instead of
@@ -40,282 +40,282 @@ describe 'New/edit issue', :js do
visit new_project_issue_path(project)
- click_button 'Unassigned'
+ click_button "Unassigned"
wait_for_requests
end
- it 'should display selected users even if they are not part of the original API call' do
- find('.dropdown-input-field').native.send_keys user2.name
+ it "should display selected users even if they are not part of the original API call" do
+ find(".dropdown-input-field").native.send_keys user2.name
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
expect(page).to have_content user2.name
click_link user2.name
end
- find('.js-assignee-search').click
- find('.js-dropdown-input-clear').click
+ find(".js-assignee-search").click
+ find(".js-dropdown-input-clear").click
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
expect(page).to have_content user.name
- expect(find('.dropdown-menu-user a.is-active').first(:xpath, '..')['data-user-id']).to eq(user2.id.to_s)
+ expect(find(".dropdown-menu-user a.is-active").first(:xpath, "..")["data-user-id"]).to eq(user2.id.to_s)
end
end
end
- describe 'single assignee' do
+ describe "single assignee" do
before do
- click_button 'Unassigned'
+ click_button "Unassigned"
wait_for_requests
end
- it 'unselects other assignees when unassigned is selected' do
- page.within '.dropdown-menu-user' do
+ it "unselects other assignees when unassigned is selected" do
+ page.within ".dropdown-menu-user" do
click_link user2.name
end
click_button user2.name
- page.within '.dropdown-menu-user' do
- click_link 'Unassigned'
+ page.within ".dropdown-menu-user" do
+ click_link "Unassigned"
end
- expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match('0')
+ expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match("0")
end
- it 'toggles assign to me when current user is selected and unselected' do
- page.within '.dropdown-menu-user' do
+ it "toggles assign to me when current user is selected and unselected" do
+ page.within ".dropdown-menu-user" do
click_link user.name
end
- expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
+ expect(find("a", text: "Assign to me", visible: false)).not_to be_visible
click_button user.name
- page.within('.dropdown-menu-user') do
+ page.within(".dropdown-menu-user") do
click_link user.name
end
- expect(page.find('.dropdown-menu-user', visible: false)).not_to be_visible
+ expect(page.find(".dropdown-menu-user", visible: false)).not_to be_visible
end
end
- it 'allows user to create new issue' do
- fill_in 'issue_title', with: 'title'
- fill_in 'issue_description', with: 'title'
+ it "allows user to create new issue" do
+ fill_in "issue_title", with: "title"
+ fill_in "issue_description", with: "title"
- expect(find('a', text: 'Assign to me')).to be_visible
- click_button 'Unassigned'
+ expect(find("a", text: "Assign to me")).to be_visible
+ click_button "Unassigned"
wait_for_requests
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
click_link user2.name
end
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user2.id.to_s)
- page.within '.js-assignee-search' do
+ page.within ".js-assignee-search" do
expect(page).to have_content user2.name
end
- expect(find('a', text: 'Assign to me')).to be_visible
+ expect(find("a", text: "Assign to me")).to be_visible
- click_link 'Assign to me'
+ click_link "Assign to me"
assignee_ids = page.all('input[name="issue[assignee_ids][]"]', visible: false)
expect(assignee_ids[0].value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
+ page.within ".js-assignee-search" do
expect(page).to have_content user.name
end
- expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
+ expect(find("a", text: "Assign to me", visible: false)).not_to be_visible
- click_button 'Milestone'
- page.within '.issue-milestone' do
+ click_button "Milestone"
+ page.within ".issue-milestone" do
click_link milestone.title
end
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
+ page.within ".js-milestone-select" do
expect(page).to have_content milestone.title
end
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
+ click_button "Labels"
+ page.within ".dropdown-menu-labels" do
click_link label.title
click_link label2.title
end
- find('.js-issuable-form-dropdown.js-label-select').click
+ find(".js-issuable-form-dropdown.js-label-select").click
- page.within '.js-label-select' do
+ page.within ".js-label-select" do
expect(page).to have_content label.title
end
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- click_button 'Submit issue'
+ click_button "Submit issue"
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
+ page.within ".issuable-sidebar" do
+ page.within ".assignee" do
expect(page).to have_content "Assignee"
end
- page.within '.milestone' do
+ page.within ".milestone" do
expect(page).to have_content milestone.title
end
- page.within '.labels' do
+ page.within ".labels" do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
end
- page.within '.breadcrumbs' do
- issue = Issue.find_by(title: 'title')
+ page.within ".breadcrumbs" do
+ issue = Issue.find_by(title: "title")
expect(page).to have_text("Issues #{issue.to_reference}")
end
end
- it 'correctly updates the dropdown toggle when removing a label' do
- click_button 'Labels'
+ it "correctly updates the dropdown toggle when removing a label" do
+ click_button "Labels"
- page.within '.dropdown-menu-labels' do
+ page.within ".dropdown-menu-labels" do
click_link label.title
end
- expect(find('.js-label-select')).to have_content(label.title)
+ expect(find(".js-label-select")).to have_content(label.title)
- page.within '.dropdown-menu-labels' do
+ page.within ".dropdown-menu-labels" do
click_link label.title
end
- expect(find('.js-label-select')).to have_content('Labels')
+ expect(find(".js-label-select")).to have_content("Labels")
end
- it 'clears label search input field when a label is selected' do
- click_button 'Labels'
+ it "clears label search input field when a label is selected" do
+ click_button "Labels"
- page.within '.dropdown-menu-labels' do
+ page.within ".dropdown-menu-labels" do
search_field = find('input[type="search"]')
search_field.set(label2.title)
click_link label2.title
- expect(search_field.value).to eq ''
+ expect(search_field.value).to eq ""
end
end
- it 'correctly updates the selected user when changing assignee' do
- click_button 'Unassigned'
+ it "correctly updates the selected user when changing assignee" do
+ click_button "Unassigned"
wait_for_requests
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
click_link user.name
end
- expect(find('.js-assignee-search')).to have_content(user.name)
+ expect(find(".js-assignee-search")).to have_content(user.name)
click_button user.name
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
click_link user2.name
end
- expect(find('.js-assignee-search')).to have_content(user2.name)
+ expect(find(".js-assignee-search")).to have_content(user2.name)
end
- it 'description has autocomplete' do
- find('#issue_description').native.send_keys('')
- fill_in 'issue_description', with: '@'
+ it "description has autocomplete" do
+ find("#issue_description").native.send_keys("")
+ fill_in "issue_description", with: "@"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
- describe 'milestone' do
+ describe "milestone" do
let!(:milestone) { create(:milestone, title: '">&lt;img src=x onerror=alert(document.domain)&gt;', project: project) }
- it 'escapes milestone' do
- click_button 'Milestone'
+ it "escapes milestone" do
+ click_button "Milestone"
- page.within '.issue-milestone' do
+ page.within ".issue-milestone" do
click_link milestone.title
end
- page.within '.js-milestone-select' do
+ page.within ".js-milestone-select" do
expect(page).to have_content milestone.title
- expect(page).not_to have_selector 'img'
+ expect(page).not_to have_selector "img"
end
end
end
end
- context 'edit issue' do
+ context "edit issue" do
before do
visit edit_project_issue_path(project, issue)
end
- it 'allows user to update issue' do
+ it "allows user to update issue" do
expect(find('input[name="issue[assignee_ids][]"]', visible: false).value).to match(user.id.to_s)
expect(find('input[name="issue[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- expect(find('a', text: 'Assign to me', visible: false)).not_to be_visible
+ expect(find("a", text: "Assign to me", visible: false)).not_to be_visible
- page.within '.js-user-search' do
+ page.within ".js-user-search" do
expect(page).to have_content user.name
end
- page.within '.js-milestone-select' do
+ page.within ".js-milestone-select" do
expect(page).to have_content milestone.title
end
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
+ click_button "Labels"
+ page.within ".dropdown-menu-labels" do
click_link label.title
click_link label2.title
end
- page.within '.js-label-select' do
+ page.within ".js-label-select" do
expect(page).to have_content label.title
end
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="issue[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- click_button 'Save changes'
+ click_button "Save changes"
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
+ page.within ".issuable-sidebar" do
+ page.within ".assignee" do
expect(page).to have_content user.name
end
- page.within '.milestone' do
+ page.within ".milestone" do
expect(page).to have_content milestone.title
end
- page.within '.labels' do
+ page.within ".labels" do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
end
end
- it 'description has autocomplete' do
- find('#issue_description').native.send_keys('')
- fill_in 'issue_description', with: '@'
+ it "description has autocomplete" do
+ find("#issue_description").native.send_keys("")
+ fill_in "issue_description", with: "@"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
end
- context 'inline edit' do
+ context "inline edit" do
before do
visit project_issue_path(project, issue)
end
- it 'opens inline edit form with shortcut' do
- find('body').send_keys('e')
+ it "opens inline edit form with shortcut" do
+ find("body").send_keys("e")
- expect(page).to have_selector('.detail-page-description form')
+ expect(page).to have_selector(".detail-page-description form")
end
end
- describe 'sub-group project' do
+ describe "sub-group project" do
let(:group) { create(:group) }
let(:nested_group_1) { create(:group, parent: group) }
let(:sub_group_project) { create(:project, group: nested_group_1) }
@@ -326,22 +326,22 @@ describe 'New/edit issue', :js do
visit new_project_issue_path(sub_group_project)
end
- it 'creates project label from dropdown' do
- click_button 'Labels'
+ it "creates project label from dropdown" do
+ click_button "Labels"
- click_link 'Create project label'
+ click_link "Create project label"
- page.within '.dropdown-new-label' do
- fill_in 'new_label_name', with: 'test label'
- first('.suggest-colors-dropdown a').click
+ page.within ".dropdown-new-label" do
+ fill_in "new_label_name", with: "test label"
+ first(".suggest-colors-dropdown a").click
- click_button 'Create'
+ click_button "Create"
wait_for_requests
end
- page.within '.dropdown-menu-labels' do
- expect(page).to have_link 'test label'
+ page.within ".dropdown-menu-labels" do
+ expect(page).to have_link "test label"
end
end
end
diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb
index 8eb413bdd8d..a1ad66a3c82 100644
--- a/spec/features/issues/gfm_autocomplete_spec.rb
+++ b/spec/features/issues/gfm_autocomplete_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'GFM autocomplete', :js do
- let(:issue_xss_title) { 'This will execute alert<img src=x onerror=alert(2)&lt;img src=x onerror=alert(1)&gt;' }
- let(:user_xss_title) { 'eve <img src=x onerror=alert(2)&lt;img src=x onerror=alert(1)&gt;' }
+describe "GFM autocomplete", :js do
+ let(:issue_xss_title) { "This will execute alert<img src=x onerror=alert(2)&lt;img src=x onerror=alert(1)&gt;" }
+ let(:user_xss_title) { "eve <img src=x onerror=alert(2)&lt;img src=x onerror=alert(1)&gt;" }
let(:label_xss_title) { 'alert label &lt;img src=x onerror="alert(\'Hello xss\');" a'}
let(:milestone_xss_title) { 'alert milestone &lt;img src=x onerror="alert(\'Hello xss\');" a' }
- let(:user_xss) { create(:user, name: user_xss_title, username: 'xss.user') }
- let(:user) { create(:user, name: '💃speciąl someone💃', username: 'someone.special') }
+ let(:user_xss) { create(:user, name: user_xss_title, username: "xss.user") }
+ let(:user) { create(:user, name: "💃speciąl someone💃", username: "someone.special") }
let(:project) { create(:project) }
- let(:label) { create(:label, project: project, title: 'special+') }
+ let(:label) { create(:label, project: project, title: "special+") }
let(:issue) { create(:issue, project: project) }
before do
@@ -22,328 +22,328 @@ describe 'GFM autocomplete', :js do
wait_for_requests
end
- it 'updates issue description with GFM reference' do
- find('.js-issuable-edit').click
+ it "updates issue description with GFM reference" do
+ find(".js-issuable-edit").click
- simulate_input('#issue-description', "@#{user.name[0...3]}")
+ simulate_input("#issue-description", "@#{user.name[0...3]}")
wait_for_requests
- find('.atwho-view .cur').click
+ find(".atwho-view .cur").click
- click_button 'Save changes'
+ click_button "Save changes"
wait_for_requests
- expect(find('.description')).to have_content(user.to_reference)
+ expect(find(".description")).to have_content(user.to_reference)
end
- it 'opens autocomplete menu when field starts with text' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('@')
+ it "opens autocomplete menu when field starts with text" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("@")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
end
- it 'opens autocomplete menu for Issues when field starts with text with item escaping HTML characters' do
+ it "opens autocomplete menu for Issues when field starts with text with item escaping HTML characters" do
create(:issue, project: project, title: issue_xss_title)
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('#')
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("#")
end
wait_for_requests
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
- page.within '.atwho-container #at-view-issues' do
- expect(page.all('li').first.text).to include(issue_xss_title)
+ page.within ".atwho-container #at-view-issues" do
+ expect(page.all("li").first.text).to include(issue_xss_title)
end
end
- it 'opens autocomplete menu for Username when field starts with text with item escaping HTML characters' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('@ev')
+ it "opens autocomplete menu for Username when field starts with text with item escaping HTML characters" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("@ev")
end
wait_for_requests
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
- page.within '.atwho-container #at-view-users' do
- expect(find('li').text).to have_content(user_xss.username)
+ page.within ".atwho-container #at-view-users" do
+ expect(find("li").text).to have_content(user_xss.username)
end
end
- it 'opens autocomplete menu for Milestone when field starts with text with item escaping HTML characters' do
+ it "opens autocomplete menu for Milestone when field starts with text with item escaping HTML characters" do
create(:milestone, project: project, title: milestone_xss_title)
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('%')
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("%")
end
wait_for_requests
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
- page.within '.atwho-container #at-view-milestones' do
- expect(find('li').text).to have_content('alert milestone')
+ page.within ".atwho-container #at-view-milestones" do
+ expect(find("li").text).to have_content("alert milestone")
end
end
- it 'doesnt open autocomplete menu character is prefixed with text' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('testing')
- find('#note-body').native.send_keys('@')
+ it "doesnt open autocomplete menu character is prefixed with text" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("testing")
+ find("#note-body").native.send_keys("@")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
- it 'doesnt select the first item for non-assignee dropdowns' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys(':')
+ it "doesnt select the first item for non-assignee dropdowns" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys(":")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
wait_for_requests
- expect(find('#at-view-58')).not_to have_selector('.cur:first-of-type')
+ expect(find("#at-view-58")).not_to have_selector(".cur:first-of-type")
end
it 'does not open autocomplete menu when ":" is prefixed by a number and letters' do
- note = find('#note-body')
+ note = find("#note-body")
# Number.
- page.within '.timeline-content-form' do
- note.native.send_keys('7:')
+ page.within ".timeline-content-form" do
+ note.native.send_keys("7:")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
# ASCII letter.
- page.within '.timeline-content-form' do
- note.set('')
- note.native.send_keys('w:')
+ page.within ".timeline-content-form" do
+ note.set("")
+ note.native.send_keys("w:")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
# Non-ASCII letter.
- page.within '.timeline-content-form' do
- note.set('')
- note.native.send_keys('Ё:')
+ page.within ".timeline-content-form" do
+ note.set("")
+ note.native.send_keys("Ё:")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
- it 'selects the first item for assignee dropdowns' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('@')
+ it "selects the first item for assignee dropdowns" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("@")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
wait_for_requests
- expect(find('#at-view-users')).to have_selector('.cur:first-of-type')
+ expect(find("#at-view-users")).to have_selector(".cur:first-of-type")
end
- it 'includes items for assignee dropdowns with non-ASCII characters in name' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('')
- simulate_input('#note-body', "@#{user.name[0...8]}")
+ it "includes items for assignee dropdowns with non-ASCII characters in name" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("")
+ simulate_input("#note-body", "@#{user.name[0...8]}")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
wait_for_requests
- expect(find('#at-view-users')).to have_content(user.name)
+ expect(find("#at-view-users")).to have_content(user.name)
end
- it 'selects the first item for non-assignee dropdowns if a query is entered' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys(':1')
+ it "selects the first item for non-assignee dropdowns if a query is entered" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys(":1")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
wait_for_requests
- expect(find('#at-view-58')).to have_selector('.cur:first-of-type')
+ expect(find("#at-view-58")).to have_selector(".cur:first-of-type")
end
- context 'if a selected value has special characters' do
- it 'wraps the result in double quotes' do
- note = find('#note-body')
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys('')
- simulate_input('#note-body', "~#{label.title[0]}")
+ context "if a selected value has special characters" do
+ it "wraps the result in double quotes" do
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("")
+ simulate_input("#note-body", "~#{label.title[0]}")
end
- label_item = find('.atwho-view li', text: label.title)
+ label_item = find(".atwho-view li", text: label.title)
expect_to_wrap(true, label_item, note, label.title)
end
it "shows dropdown after a new line" do
- note = find('#note-body')
- page.within '.timeline-content-form' do
- note.native.send_keys('test')
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
+ note.native.send_keys("test")
note.native.send_keys(:enter)
note.native.send_keys(:enter)
- note.native.send_keys('@')
+ note.native.send_keys("@")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
end
it "does not show dropdown when preceded with a special character" do
- note = find('#note-body')
- page.within '.timeline-content-form' do
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
note.native.send_keys("@")
end
- expect(page).to have_selector('.atwho-container')
+ expect(page).to have_selector(".atwho-container")
- page.within '.timeline-content-form' do
+ page.within ".timeline-content-form" do
note.native.send_keys("@")
end
- expect(page).to have_selector('.atwho-container', visible: false)
+ expect(page).to have_selector(".atwho-container", visible: false)
end
it "does not throw an error if no labels exist" do
- note = find('#note-body')
- page.within '.timeline-content-form' do
- note.native.send_keys('~')
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
+ note.native.send_keys("~")
end
- expect(page).to have_selector('.atwho-container', visible: false)
+ expect(page).to have_selector(".atwho-container", visible: false)
end
- it 'doesn\'t wrap for assignee values' do
- note = find('#note-body')
- page.within '.timeline-content-form' do
+ it "doesn't wrap for assignee values" do
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
note.native.send_keys("@#{user.username[0]}")
end
- user_item = find('.atwho-view li', text: user.username)
+ user_item = find(".atwho-view li", text: user.username)
expect_to_wrap(false, user_item, note, user.username)
end
- it 'doesn\'t wrap for emoji values' do
- note = find('#note-body')
- page.within '.timeline-content-form' do
+ it "doesn't wrap for emoji values" do
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
note.native.send_keys(":cartwheel_")
end
- emoji_item = find('.atwho-view li', text: 'cartwheel_tone1')
+ emoji_item = find(".atwho-view li", text: "cartwheel_tone1")
- expect_to_wrap(false, emoji_item, note, 'cartwheel_tone1')
+ expect_to_wrap(false, emoji_item, note, "cartwheel_tone1")
end
- it 'doesn\'t open autocomplete after non-word character' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys("@#{user.username[0..2]}!")
+ it "doesn't open autocomplete after non-word character" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("@#{user.username[0..2]}!")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
- it 'doesn\'t open autocomplete if there is no space before' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys("hello:#{user.username[0..2]}")
+ it "doesn't open autocomplete if there is no space before" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys("hello:#{user.username[0..2]}")
end
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
- it 'triggers autocomplete after selecting a quick action' do
- note = find('#note-body')
- page.within '.timeline-content-form' do
- note.native.send_keys('/as')
+ it "triggers autocomplete after selecting a quick action" do
+ note = find("#note-body")
+ page.within ".timeline-content-form" do
+ note.native.send_keys("/as")
end
- find('.atwho-view li', text: '/assign')
+ find(".atwho-view li", text: "/assign")
note.native.send_keys(:tab)
- user_item = find('.atwho-view li', text: user.username)
+ user_item = find(".atwho-view li", text: user.username)
expect(user_item).to have_content(user.username)
end
end
- context 'labels' do
- it 'opens autocomplete menu for Labels when field starts with text with item escaping HTML characters' do
+ context "labels" do
+ it "opens autocomplete menu for Labels when field starts with text with item escaping HTML characters" do
create(:label, project: project, title: label_xss_title)
- note = find('#note-body')
+ note = find("#note-body")
# It should show all the labels on "~".
- type(note, '~')
+ type(note, "~")
wait_for_requests
- page.within '.atwho-container #at-view-labels' do
- expect(find('.atwho-view-ul').text).to have_content('alert label')
+ page.within ".atwho-container #at-view-labels" do
+ expect(find(".atwho-view-ul").text).to have_content("alert label")
end
end
end
- shared_examples 'autocomplete suggestions' do
- it 'suggests objects correctly' do
- page.within '.timeline-content-form' do
- find('#note-body').native.send_keys(object.class.reference_prefix)
+ shared_examples "autocomplete suggestions" do
+ it "suggests objects correctly" do
+ page.within ".timeline-content-form" do
+ find("#note-body").native.send_keys(object.class.reference_prefix)
end
- page.within '.atwho-container' do
+ page.within ".atwho-container" do
expect(page).to have_content(object.title)
- find('ul li').click
+ find("ul li").click
end
- expect(find('.new-note #note-body').value).to include(expected_body)
+ expect(find(".new-note #note-body").value).to include(expected_body)
end
end
- context 'issues' do
+ context "issues" do
let(:object) { issue }
let(:expected_body) { object.to_reference }
- it_behaves_like 'autocomplete suggestions'
+ it_behaves_like "autocomplete suggestions"
end
- context 'merge requests' do
+ context "merge requests" do
let(:object) { create(:merge_request, source_project: project) }
let(:expected_body) { object.to_reference }
- it_behaves_like 'autocomplete suggestions'
+ it_behaves_like "autocomplete suggestions"
end
- context 'project snippets' do
- let!(:object) { create(:project_snippet, project: project, title: 'code snippet') }
+ context "project snippets" do
+ let!(:object) { create(:project_snippet, project: project, title: "code snippet") }
let(:expected_body) { object.to_reference }
- it_behaves_like 'autocomplete suggestions'
+ it_behaves_like "autocomplete suggestions"
end
- context 'label' do
+ context "label" do
let!(:object) { label }
let(:expected_body) { object.title }
- it_behaves_like 'autocomplete suggestions'
+ it_behaves_like "autocomplete suggestions"
end
- context 'milestone' do
+ context "milestone" do
let!(:object) { create(:milestone, project: project) }
let(:expected_body) { object.to_reference }
- it_behaves_like 'autocomplete suggestions'
+ it_behaves_like "autocomplete suggestions"
end
private
@@ -362,14 +362,14 @@ describe 'GFM autocomplete', :js do
end
def expect_labels(shown: nil, not_shown: nil)
- page.within('.atwho-container') do
+ page.within(".atwho-container") do
if shown
- expect(page).to have_selector('.atwho-view li', count: shown.size)
+ expect(page).to have_selector(".atwho-view li", count: shown.size)
shown.each { |label| expect(page).to have_content(label.title) }
end
if not_shown
- expect(page).not_to have_selector('.atwho-view li') unless shown
+ expect(page).not_to have_selector(".atwho-view li") unless shown
not_shown.each { |label| expect(page).not_to have_content(label.title) }
end
end
@@ -378,8 +378,8 @@ describe 'GFM autocomplete', :js do
# `note` is a textarea where the given text should be typed.
# We don't want to find it each time this function gets called.
def type(note, text)
- page.within('.timeline-content-form') do
- note.set('')
+ page.within(".timeline-content-form") do
+ note.set("")
note.native.send_keys(text)
end
end
diff --git a/spec/features/issues/group_label_sidebar_spec.rb b/spec/features/issues/group_label_sidebar_spec.rb
index 9c10f78f67a..668fdfce53d 100644
--- a/spec/features/issues/group_label_sidebar_spec.rb
+++ b/spec/features/issues/group_label_sidebar_spec.rb
@@ -1,16 +1,16 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Group label on issue' do
- it 'renders link to the project issues page' do
+describe "Group label on issue" do
+ it "renders link to the project issues page" do
group = create(:group)
project = create(:project, :public, namespace: group)
- feature = create(:group_label, group: group, title: 'feature')
+ feature = create(:group_label, group: group, title: "feature")
issue = create(:labeled_issue, project: project, labels: [feature])
label_link = project_issues_path(project, label_name: [feature.name])
visit project_issue_path(project, issue)
- link = find('.issuable-show-labels a')
+ link = find(".issuable-show-labels a")
expect(link[:href]).to eq(label_link)
end
diff --git a/spec/features/issues/issue_detail_spec.rb b/spec/features/issues/issue_detail_spec.rb
index 76bc93e9766..3b1a2af6911 100644
--- a/spec/features/issues/issue_detail_spec.rb
+++ b/spec/features/issues/issue_detail_spec.rb
@@ -1,24 +1,24 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Detail', :js do
+describe "Issue Detail", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, author: user) }
- context 'when user displays the issue' do
+ context "when user displays the issue" do
before do
visit project_issue_path(project, issue)
wait_for_requests
end
- it 'shows the issue' do
- page.within('.issuable-details') do
- expect(find('h2')).to have_content(issue.title)
+ it "shows the issue" do
+ page.within(".issuable-details") do
+ expect(find("h2")).to have_content(issue.title)
end
end
end
- context 'when issue description has xss snippet' do
+ context "when issue description has xss snippet" do
before do
issue.update!(description: '![xss" onload=alert(1);//](a)')
sign_in(user)
@@ -26,24 +26,24 @@ describe 'Issue Detail', :js do
wait_for_requests
end
- it 'should encode the description to prevent xss issues' do
- page.within('.issuable-details .detail-page-description') do
- expect(page).to have_selector('img', count: 1)
- expect(find('img')['onerror']).to be_nil
- expect(find('img')['src']).to end_with('/a')
+ it "should encode the description to prevent xss issues" do
+ page.within(".issuable-details .detail-page-description") do
+ expect(page).to have_selector("img", count: 1)
+ expect(find("img")["onerror"]).to be_nil
+ expect(find("img")["src"]).to end_with("/a")
end
end
end
- context 'when edited by a user who is later deleted' do
+ context "when edited by a user who is later deleted" do
before do
sign_in(user)
visit project_issue_path(project, issue)
wait_for_requests
- page.find('.js-issuable-edit').click
- fill_in 'issuable-title', with: 'issue title'
- click_button 'Save'
+ page.find(".js-issuable-edit").click
+ fill_in "issuable-title", with: "issue title"
+ click_button "Save"
wait_for_requests
Users::DestroyService.new(user).execute(user)
@@ -51,9 +51,9 @@ describe 'Issue Detail', :js do
visit project_issue_path(project, issue)
end
- it 'shows the issue' do
- page.within('.issuable-details') do
- expect(find('h2')).to have_content(issue.reload.title)
+ it "shows the issue" do
+ page.within(".issuable-details") do
+ expect(find("h2")).to have_content(issue.reload.title)
end
end
end
diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb
index 3050f23c130..6a00c6f0f4b 100644
--- a/spec/features/issues/issue_sidebar_spec.rb
+++ b/spec/features/issues/issue_sidebar_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue Sidebar' do
+describe "Issue Sidebar" do
include MobileHelpers
let(:group) { create(:group, :nested) }
let(:project) { create(:project, :public, namespace: group) }
let!(:user) { create(:user)}
- let!(:label) { create(:label, project: project, title: 'bug') }
+ let!(:label) { create(:label, project: project, title: "bug") }
let(:issue) { create(:labeled_issue, project: project, labels: [label]) }
let!(:xss_label) { create(:label, project: project, title: '&lt;script&gt;alert("xss");&lt;&#x2F;script&gt;') }
@@ -14,7 +14,7 @@ describe 'Issue Sidebar' do
sign_in(user)
end
- context 'assignee', :js do
+ context "assignee", :js do
let(:user2) { create(:user) }
let(:issue2) { create(:issue, project: project, author: user2) }
@@ -22,20 +22,20 @@ describe 'Issue Sidebar' do
project.add_developer(user)
visit_issue(project, issue2)
- find('.block.assignee .edit-link').click
+ find(".block.assignee .edit-link").click
wait_for_requests
end
- it 'shows author in assignee dropdown' do
- page.within '.dropdown-menu-user' do
+ it "shows author in assignee dropdown" do
+ page.within ".dropdown-menu-user" do
expect(page).to have_content(user2.name)
end
end
- it 'shows author when filtering assignee dropdown' do
- page.within '.dropdown-menu-user' do
- find('.dropdown-input-field').native.send_keys user2.name
+ it "shows author when filtering assignee dropdown" do
+ page.within ".dropdown-menu-user" do
+ find(".dropdown-input-field").native.send_keys user2.name
sleep 1 # Required to wait for end of input delay
wait_for_requests
@@ -44,48 +44,48 @@ describe 'Issue Sidebar' do
end
end
- it 'assigns yourself' do
- find('.block.assignee .dropdown-menu-toggle').click
+ it "assigns yourself" do
+ find(".block.assignee .dropdown-menu-toggle").click
- click_button 'assign yourself'
+ click_button "assign yourself"
wait_for_requests
- find('.block.assignee .edit-link').click
+ find(".block.assignee .edit-link").click
- page.within '.dropdown-menu-user' do
- expect(page.find('.dropdown-header')).to be_visible
- expect(page.find('.dropdown-menu-user-link.is-active')).to have_content(user.name)
+ page.within ".dropdown-menu-user" do
+ expect(page.find(".dropdown-header")).to be_visible
+ expect(page.find(".dropdown-menu-user-link.is-active")).to have_content(user.name)
end
end
- it 'keeps your filtered term after filtering and dismissing the dropdown' do
- find('.dropdown-input-field').native.send_keys user2.name
+ it "keeps your filtered term after filtering and dismissing the dropdown" do
+ find(".dropdown-input-field").native.send_keys user2.name
wait_for_requests
- page.within '.dropdown-menu-user' do
- expect(page).not_to have_content 'Unassigned'
+ page.within ".dropdown-menu-user" do
+ expect(page).not_to have_content "Unassigned"
click_link user2.name
end
- find('.js-right-sidebar').click
- find('.block.assignee .edit-link').click
+ find(".js-right-sidebar").click
+ find(".block.assignee .edit-link").click
- expect(page.all('.dropdown-menu-user li').length).to eq(1)
- expect(find('.dropdown-input-field').value).to eq(user2.name)
+ expect(page.all(".dropdown-menu-user li").length).to eq(1)
+ expect(find(".dropdown-input-field").value).to eq(user2.name)
end
end
- context 'as a allowed user' do
+ context "as a allowed user" do
before do
project.add_developer(user)
visit_issue(project, issue)
end
- context 'sidebar', :js do
- it 'changes size when the screen size is smaller' do
- sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
+ context "sidebar", :js do
+ it "changes size when the screen size is smaller" do
+ sidebar_selector = "aside.right-sidebar.right-sidebar-collapsed"
# Resize the window
resize_screen_sm
# Make sure the sidebar is collapsed
@@ -101,86 +101,86 @@ describe 'Issue Sidebar' do
open_issue_sidebar
end
- it 'escapes XSS when viewing issue labels' do
- page.within('.block.labels') do
- find('.edit-link').click
+ it "escapes XSS when viewing issue labels" do
+ page.within(".block.labels") do
+ find(".edit-link").click
expect(page).to have_content '<script>alert("xss");</script>'
end
end
end
- context 'editing issue labels', :js do
+ context "editing issue labels", :js do
before do
issue.update(labels: [label])
- page.within('.block.labels') do
- find('.edit-link').click
+ page.within(".block.labels") do
+ find(".edit-link").click
end
end
- it 'shows the current set of labels' do
- page.within('.issuable-show-labels') do
+ it "shows the current set of labels" do
+ page.within(".issuable-show-labels") do
expect(page).to have_content label.title
end
end
- it 'shows option to create a project label' do
- page.within('.block.labels') do
- expect(page).to have_content 'Create project'
+ it "shows option to create a project label" do
+ page.within(".block.labels") do
+ expect(page).to have_content "Create project"
end
end
- context 'creating a project label', :js do
+ context "creating a project label", :js do
before do
- page.within('.block.labels') do
- click_link 'Create project'
+ page.within(".block.labels") do
+ click_link "Create project"
end
end
it 'shows dropdown switches to "create label" section' do
- page.within('.block.labels') do
- expect(page).to have_content 'Create project label'
+ page.within(".block.labels") do
+ expect(page).to have_content "Create project label"
end
end
- it 'adds new label' do
- page.within('.block.labels') do
- fill_in 'new_label_name', with: 'wontfix'
- page.find('.suggest-colors a', match: :first).click
- page.find('button', text: 'Create').click
+ it "adds new label" do
+ page.within(".block.labels") do
+ fill_in "new_label_name", with: "wontfix"
+ page.find(".suggest-colors a", match: :first).click
+ page.find("button", text: "Create").click
- page.within('.dropdown-page-one') do
- expect(page).to have_content 'wontfix'
+ page.within(".dropdown-page-one") do
+ expect(page).to have_content "wontfix"
end
end
end
- it 'shows error message if label title is taken' do
- page.within('.block.labels') do
- fill_in 'new_label_name', with: label.title
- page.find('.suggest-colors a', match: :first).click
- page.find('button', text: 'Create').click
+ it "shows error message if label title is taken" do
+ page.within(".block.labels") do
+ fill_in "new_label_name", with: label.title
+ page.find(".suggest-colors a", match: :first).click
+ page.find("button", text: "Create").click
- page.within('.dropdown-page-two') do
- expect(page).to have_content 'Title has already been taken'
+ page.within(".dropdown-page-two") do
+ expect(page).to have_content "Title has already been taken"
end
end
end
end
end
- context 'interacting with collapsed sidebar', :js do
- collapsed_sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
- expanded_sidebar_selector = 'aside.right-sidebar.right-sidebar-expanded'
- confidentiality_sidebar_block = '.block.confidentiality'
- lock_sidebar_block = '.block.lock'
- collapsed_sidebar_block_icon = '.sidebar-collapsed-icon'
+ context "interacting with collapsed sidebar", :js do
+ collapsed_sidebar_selector = "aside.right-sidebar.right-sidebar-collapsed"
+ expanded_sidebar_selector = "aside.right-sidebar.right-sidebar-expanded"
+ confidentiality_sidebar_block = ".block.confidentiality"
+ lock_sidebar_block = ".block.lock"
+ collapsed_sidebar_block_icon = ".sidebar-collapsed-icon"
before do
resize_screen_sm
end
- it 'confidentiality block expands then collapses sidebar' do
+ it "confidentiality block expands then collapses sidebar" do
expect(page).to have_css(collapsed_sidebar_selector)
page.within(confidentiality_sidebar_block) do
@@ -190,13 +190,13 @@ describe 'Issue Sidebar' do
expect(page).to have_css(expanded_sidebar_selector)
page.within(confidentiality_sidebar_block) do
- page.find('button', text: 'Cancel').click
+ page.find("button", text: "Cancel").click
end
expect(page).to have_css(collapsed_sidebar_selector)
end
- it 'lock block expands then collapses sidebar' do
+ it "lock block expands then collapses sidebar" do
expect(page).to have_css(collapsed_sidebar_selector)
page.within(lock_sidebar_block) do
@@ -206,7 +206,7 @@ describe 'Issue Sidebar' do
expect(page).to have_css(expanded_sidebar_selector)
page.within(lock_sidebar_block) do
- page.find('button', text: 'Cancel').click
+ page.find("button", text: "Cancel").click
end
expect(page).to have_css(collapsed_sidebar_selector)
@@ -214,14 +214,14 @@ describe 'Issue Sidebar' do
end
end
- context 'as a guest' do
+ context "as a guest" do
before do
project.add_guest(user)
visit_issue(project, issue)
end
- it 'does not have a option to edit labels' do
- expect(page).not_to have_selector('.block.labels .edit-link')
+ it "does not have a option to edit labels" do
+ expect(page).not_to have_selector(".block.labels .edit-link")
end
end
@@ -230,7 +230,7 @@ describe 'Issue Sidebar' do
end
def open_issue_sidebar
- find('aside.right-sidebar.right-sidebar-collapsed .js-sidebar-toggle').click
- find('aside.right-sidebar.right-sidebar-expanded')
+ find("aside.right-sidebar.right-sidebar-collapsed .js-sidebar-toggle").click
+ find("aside.right-sidebar.right-sidebar-expanded")
end
end
diff --git a/spec/features/issues/keyboard_shortcut_spec.rb b/spec/features/issues/keyboard_shortcut_spec.rb
index 961de9d3d25..13ea3dc8843 100644
--- a/spec/features/issues/keyboard_shortcut_spec.rb
+++ b/spec/features/issues/keyboard_shortcut_spec.rb
@@ -1,8 +1,8 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issues shortcut', :js do
- context 'New Issue shortcut' do
- context 'issues are enabled' do
+describe "Issues shortcut", :js do
+ context "New Issue shortcut" do
+ context "issues are enabled" do
let(:project) { create(:project) }
before do
@@ -11,13 +11,13 @@ describe 'Issues shortcut', :js do
visit project_path(project)
end
- it 'takes user to the new issue page' do
- find('body').native.send_keys('i')
- expect(page).to have_selector('#new_issue')
+ it "takes user to the new issue page" do
+ find("body").native.send_keys("i")
+ expect(page).to have_selector("#new_issue")
end
end
- context 'issues are not enabled' do
+ context "issues are not enabled" do
let(:project) { create(:project, :issues_disabled) }
before do
@@ -26,8 +26,8 @@ describe 'Issues shortcut', :js do
visit project_path(project)
end
- it 'does not take user to the new issue page' do
- find('body').native.send_keys('i')
+ it "does not take user to the new issue page" do
+ find("body").native.send_keys("i")
expect(page).to have_selector("body[data-page='projects:show']")
end
diff --git a/spec/features/issues/markdown_toolbar_spec.rb b/spec/features/issues/markdown_toolbar_spec.rb
index 042ecdb172a..4c2f018a562 100644
--- a/spec/features/issues/markdown_toolbar_spec.rb
+++ b/spec/features/issues/markdown_toolbar_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issue markdown toolbar', :js do
+describe "Issue markdown toolbar", :js do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
@@ -12,28 +12,28 @@ describe 'Issue markdown toolbar', :js do
end
it "doesn't include first new line when adding bold" do
- find('#note-body').native.send_keys('test')
- find('#note-body').native.send_key(:enter)
- find('#note-body').native.send_keys('bold')
+ find("#note-body").native.send_keys("test")
+ find("#note-body").native.send_key(:enter)
+ find("#note-body").native.send_keys("bold")
- find('.js-main-target-form #note-body')
+ find(".js-main-target-form #note-body")
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 9)')
- first('.toolbar-btn').click
+ first(".toolbar-btn").click
- expect(find('#note-body')[:value]).to eq("test\n**bold**\n")
+ expect(find("#note-body")[:value]).to eq("test\n**bold**\n")
end
it "doesn't include first new line when adding underline" do
- find('#note-body').native.send_keys('test')
- find('#note-body').native.send_key(:enter)
- find('#note-body').native.send_keys('underline')
+ find("#note-body").native.send_keys("test")
+ find("#note-body").native.send_key(:enter)
+ find("#note-body").native.send_keys("underline")
- find('.js-main-target-form #note-body')
+ find(".js-main-target-form #note-body")
page.evaluate_script('document.querySelectorAll(".js-main-target-form #note-body")[0].setSelectionRange(4, 50)')
- find('.toolbar-btn:nth-child(2)').click
+ find(".toolbar-btn:nth-child(2)").click
- expect(find('#note-body')[:value]).to eq("test\n*underline*\n")
+ expect(find("#note-body")[:value]).to eq("test\n*underline*\n")
end
end
diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb
index 2abc50b04e4..f86eb1f8451 100644
--- a/spec/features/issues/move_spec.rb
+++ b/spec/features/issues/move_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'issue move to another project' do
+describe "issue move to another project" do
let(:user) { create(:user) }
let(:old_project) { create(:project, :repository) }
- let(:text) { 'Some issue description' }
+ let(:text) { "Some issue description" }
let(:issue) do
create(:issue, description: text, project: old_project, author: user)
@@ -13,19 +13,19 @@ describe 'issue move to another project' do
sign_in(user)
end
- context 'user does not have permission to move issue' do
+ context "user does not have permission to move issue" do
before do
old_project.add_guest(user)
visit issue_path(issue)
end
- it 'moving issue to another project not allowed' do
- expect(page).to have_no_selector('.js-sidebar-move-issue-block')
+ it "moving issue to another project not allowed" do
+ expect(page).to have_no_selector(".js-sidebar-move-issue-block")
end
end
- context 'user has permission to move issue' do
+ context "user has permission to move issue" do
let!(:mr) { create(:merge_request, source_project: old_project) }
let(:new_project) { create(:project) }
let(:new_project_search) { create(:project) }
@@ -39,11 +39,11 @@ describe 'issue move to another project' do
visit issue_path(issue)
end
- it 'moving issue to another project', :js do
- find('.js-move-issue').click
+ it "moving issue to another project", :js do
+ find(".js-move-issue").click
wait_for_requests
- all('.js-move-issue-dropdown-item')[0].click
- find('.js-move-issue-confirmation-button').click
+ all(".js-move-issue-dropdown-item")[0].click
+ find(".js-move-issue-confirmation-button").click
expect(page).to have_content("Text with #{cross_reference}#{mr.to_reference}")
expect(page).to have_content("moved from #{cross_reference}#{issue.to_reference}")
@@ -51,45 +51,45 @@ describe 'issue move to another project' do
expect(page.current_path).to include project_path(new_project)
end
- it 'searching project dropdown', :js do
+ it "searching project dropdown", :js do
new_project_search.add_reporter(user)
- find('.js-move-issue').click
+ find(".js-move-issue").click
wait_for_requests
- page.within '.js-sidebar-move-issue-block' do
- fill_in('sidebar-move-issue-dropdown-search', with: new_project_search.name)
+ page.within ".js-sidebar-move-issue-block" do
+ fill_in("sidebar-move-issue-dropdown-search", with: new_project_search.name)
expect(page).to have_content(new_project_search.name)
expect(page).not_to have_content(new_project.name)
end
end
- context 'user does not have permission to move the issue to a project', :js do
+ context "user does not have permission to move the issue to a project", :js do
let!(:private_project) { create(:project, :private) }
let(:another_project) { create(:project) }
before do
another_project.add_guest(user)
end
- it 'browsing projects in projects select' do
- find('.js-move-issue').click
+ it "browsing projects in projects select" do
+ find(".js-move-issue").click
wait_for_requests
- page.within '.js-sidebar-move-issue-block' do
+ page.within ".js-sidebar-move-issue-block" do
expect(page).to have_content new_project.full_name
end
end
end
- context 'issue has been already moved' do
+ context "issue has been already moved" do
let(:new_issue) { create(:issue, project: new_project) }
let(:issue) do
create(:issue, project: old_project, author: user, moved_to: new_issue)
end
- it 'user wants to move issue that has already been moved' do
- expect(page).to have_no_selector('#move_to_project_id')
+ it "user wants to move issue that has already been moved" do
+ expect(page).to have_no_selector("#move_to_project_id")
end
end
end
diff --git a/spec/features/issues/note_polling_spec.rb b/spec/features/issues/note_polling_spec.rb
index 3cd7ce6dada..d3125fca2d7 100644
--- a/spec/features/issues/note_polling_spec.rb
+++ b/spec/features/issues/note_polling_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Issue notes polling', :js do
+describe "Issue notes polling", :js do
include NoteInteractionHelpers
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
- describe 'creates' do
+ describe "creates" do
before do
visit project_issue_path(project, issue)
end
- it 'displays the new comment' do
- note = create(:note, noteable: issue, project: project, note: 'Looks good!')
+ it "displays the new comment" do
+ note = create(:note, noteable: issue, project: project, note: "Looks good!")
wait_for_requests
- expect(page).to have_selector("#note_#{note.id}", text: 'Looks good!')
+ expect(page).to have_selector("#note_#{note.id}", text: "Looks good!")
end
end
- describe 'updates' do
- context 'when from own user' do
+ describe "updates" do
+ context "when from own user" do
let(:user) { create(:user) }
let(:note_text) { "Hello World" }
let(:updated_text) { "Bye World" }
@@ -31,7 +31,7 @@ describe 'Issue notes polling', :js do
visit project_issue_path(project, issue)
end
- it 'displays the updated content' do
+ it "displays the updated content" do
expect(page).to have_selector("#note_#{existing_note.id}", text: note_text)
update_note(existing_note, updated_text)
@@ -39,7 +39,7 @@ describe 'Issue notes polling', :js do
expect(page).to have_selector("#note_#{existing_note.id}", text: updated_text)
end
- it 'when editing but have not changed anything, and an update comes in, show warning and does not update the note' do
+ it "when editing but have not changed anything, and an update comes in, show warning and does not update the note" do
click_edit_action(existing_note)
expect(page).to have_field("note[note]", with: note_text)
@@ -50,7 +50,7 @@ describe 'Issue notes polling', :js do
expect(page).to have_selector(".alert")
end
- it 'when editing but you changed some things, an update comes in, and you press cancel, show the updated content' do
+ it "when editing but you changed some things, an update comes in, and you press cancel, show the updated content" do
click_edit_action(existing_note)
expect(page).to have_field("note[note]", with: note_text)
@@ -63,7 +63,7 @@ describe 'Issue notes polling', :js do
end
end
- context 'when from another user' do
+ context "when from another user" do
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:note_text) { "Hello World" }
@@ -75,7 +75,7 @@ describe 'Issue notes polling', :js do
visit project_issue_path(project, issue)
end
- it 'displays the updated content' do
+ it "displays the updated content" do
expect(page).to have_selector("#note_#{existing_note.id}", text: note_text)
update_note(existing_note, updated_text)
@@ -84,7 +84,7 @@ describe 'Issue notes polling', :js do
end
end
- context 'system notes' do
+ context "system notes" do
let(:user) { create(:user) }
let(:note_text) { "Some system note" }
let!(:system_note) { create(:system_note, noteable: issue, project: project, author: user, note: note_text) }
@@ -94,7 +94,7 @@ describe 'Issue notes polling', :js do
visit project_issue_path(project, issue)
end
- it 'shows the system note' do
+ it "shows the system note" do
expect(page).to have_selector("#note_#{system_note.id}", text: note_text)
end
end
@@ -108,6 +108,6 @@ describe 'Issue notes polling', :js do
def click_edit_action(note)
note_element = find("#note_#{note.id}")
- note_element.find('.js-note-edit').click
+ note_element.find(".js-note-edit").click
end
end
diff --git a/spec/features/issues/notes_on_issues_spec.rb b/spec/features/issues/notes_on_issues_spec.rb
index fed77453cbb..41d67ce8a5b 100644
--- a/spec/features/issues/notes_on_issues_spec.rb
+++ b/spec/features/issues/notes_on_issues_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Create notes on issues', :js do
+describe "Create notes on issues", :js do
let(:user) { create(:user) }
def submit_comment(text)
- fill_in 'note[note]', with: text
- click_button 'Comment'
+ fill_in "note[note]", with: text
+ click_button "Comment"
wait_for_requests
end
- shared_examples 'notes with reference' do
+ shared_examples "notes with reference" do
let(:issue) { create(:issue, project: project) }
let(:note_text) { "Check #{mention.to_reference}" }
@@ -21,64 +21,64 @@ describe 'Create notes on issues', :js do
submit_comment(note_text)
end
- it 'creates a note with reference and cross references the issue' do
- page.within('div#notes li.note div.note-text') do
+ it "creates a note with reference and cross references the issue" do
+ page.within("div#notes li.note div.note-text") do
expect(page).to have_content(note_text)
- expect(page.find('a')).to have_content(mention.to_reference)
+ expect(page.find("a")).to have_content(mention.to_reference)
end
- find('div#notes li.note div.note-text a').click
+ find("div#notes li.note div.note-text a").click
- page.within('div#notes li.note .system-note-message') do
- expect(page).to have_content('mentioned in issue')
- expect(page.find('a')).to have_content(issue.to_reference)
+ page.within("div#notes li.note .system-note-message") do
+ expect(page).to have_content("mentioned in issue")
+ expect(page.find("a")).to have_content(issue.to_reference)
end
end
end
- context 'mentioning issue on a private project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning issue on a private project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :private) }
let(:mention) { create(:issue, project: project) }
end
end
- context 'mentioning issue on an internal project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning issue on an internal project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :internal) }
let(:mention) { create(:issue, project: project) }
end
end
- context 'mentioning issue on a public project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning issue on a public project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :public) }
let(:mention) { create(:issue, project: project) }
end
end
- context 'mentioning merge request on a private project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning merge request on a private project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :private, :repository) }
let(:mention) { create(:merge_request, source_project: project) }
end
end
- context 'mentioning merge request on an internal project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning merge request on an internal project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :internal, :repository) }
let(:mention) { create(:merge_request, source_project: project) }
end
end
- context 'mentioning merge request on a public project' do
- it_behaves_like 'notes with reference' do
+ context "mentioning merge request on a public project" do
+ it_behaves_like "notes with reference" do
let(:project) { create(:project, :public, :repository) }
let(:mention) { create(:merge_request, source_project: project) }
end
end
- it 'highlights the current user in a comment' do
+ it "highlights the current user in a comment" do
project = create(:project)
issue = create(:issue, project: project)
project.add_developer(user)
@@ -87,6 +87,6 @@ describe 'Create notes on issues', :js do
visit project_issue_path(project, issue)
submit_comment("@#{user.username} note to self")
- expect(page).to have_selector '.gfm-project_member.current-user', text: user.username
+ expect(page).to have_selector ".gfm-project_member.current-user", text: user.username
end
end
diff --git a/spec/features/issues/resource_label_events_spec.rb b/spec/features/issues/resource_label_events_spec.rb
index 3d380c183ec..c214d1cf6c8 100644
--- a/spec/features/issues/resource_label_events_spec.rb
+++ b/spec/features/issues/resource_label_events_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'List issue resource label events', :js do
+describe "List issue resource label events", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, author: user) }
- let!(:label) { create(:label, project: project, title: 'foo') }
+ let!(:label) { create(:label, project: project, title: "foo") }
let!(:user_status) { create(:user_status, user: user) }
- context 'when user displays the issue' do
- let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue, note: 'some note') }
+ context "when user displays the issue" do
+ let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue, note: "some note") }
let!(:event) { create(:resource_label_event, user: user, issue: issue, label: label) }
before do
@@ -18,35 +18,35 @@ describe 'List issue resource label events', :js do
wait_for_requests
end
- it 'shows both notes and resource label events' do
- page.within('#notes') do
- expect(find("#note_#{note.id}")).to have_content 'some note'
- expect(find("#note_#{event.discussion_id}")).to have_content 'added foo label'
+ it "shows both notes and resource label events" do
+ page.within("#notes") do
+ expect(find("#note_#{note.id}")).to have_content "some note"
+ expect(find("#note_#{event.discussion_id}")).to have_content "added foo label"
end
end
- it 'shows the user status on the system note for the label' do
+ it "shows the user status on the system note for the label" do
page.within("#note_#{event.discussion_id}") do
expect(page).to show_user_status user_status
end
end
end
- context 'when user adds label to the issue' do
+ context "when user adds label to the issue" do
def toggle_labels(labels)
- page.within '.labels' do
- click_link 'Edit'
+ page.within ".labels" do
+ click_link "Edit"
wait_for_requests
labels.each { |label| click_link label }
- click_link 'Edit'
+ click_link "Edit"
wait_for_requests
end
end
before do
- create(:label, project: project, title: 'bar')
+ create(:label, project: project, title: "bar")
project.add_developer(user)
sign_in(user)
@@ -54,13 +54,13 @@ describe 'List issue resource label events', :js do
wait_for_requests
end
- it 'shows add note for newly added labels' do
- toggle_labels(%w(foo bar))
+ it "shows add note for newly added labels" do
+ toggle_labels(%w[foo bar])
visit project_issue_path(project, issue)
wait_for_requests
- page.within('#notes') do
- expect(page).to have_content 'added bar foo labels'
+ page.within("#notes") do
+ expect(page).to have_content "added bar foo labels"
end
end
end
diff --git a/spec/features/issues/rss_spec.rb b/spec/features/issues/rss_spec.rb
index 0e1383cd607..a6146511043 100644
--- a/spec/features/issues/rss_spec.rb
+++ b/spec/features/issues/rss_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Issues RSS' do
+describe "Project Issues RSS" do
let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_issues_path(project) }
@@ -8,7 +8,7 @@ describe 'Project Issues RSS' do
create(:issue, project: project)
end
- context 'when signed in' do
+ context "when signed in" do
let(:user) { create(:user) }
before do
@@ -21,7 +21,7 @@ describe 'Project Issues RSS' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb
index 7cce45ff206..47ff0845e25 100644
--- a/spec/features/issues/spam_issues_spec.rb
+++ b/spec/features/issues/spam_issues_spec.rb
@@ -1,66 +1,66 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New issue', :js do
+describe "New issue", :js do
include StubENV
let(:project) { create(:project, :public) }
let(:user) { create(:user)}
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
Gitlab::CurrentSettings.update!(
akismet_enabled: true,
- akismet_api_key: 'testkey',
+ akismet_api_key: "testkey",
recaptcha_enabled: true,
- recaptcha_site_key: 'test site key',
- recaptcha_private_key: 'test private key'
+ recaptcha_site_key: "test site key",
+ recaptcha_private_key: "test private key"
)
project.add_maintainer(user)
sign_in(user)
end
- context 'when identified as a spam' do
+ context "when identified as a spam" do
before do
WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200)
visit new_project_issue_path(project)
end
- it 'creates an issue after solving reCaptcha' do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
+ it "creates an issue after solving reCaptcha" do
+ fill_in "issue_title", with: "issue title"
+ fill_in "issue_description", with: "issue description"
- click_button 'Submit issue'
+ click_button "Submit issue"
# it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha
# recaptcha verification is skipped in test environment and it always returns true
- expect(page).not_to have_content('issue title')
- expect(page).to have_css('.recaptcha')
+ expect(page).not_to have_content("issue title")
+ expect(page).to have_css(".recaptcha")
- click_button 'Submit issue'
+ click_button "Submit issue"
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
+ expect(page.find(".issue-details h2.title")).to have_content("issue title")
+ expect(page.find(".issue-details .description")).to have_content("issue description")
end
end
- context 'when not identified as a spam' do
+ context "when not identified as a spam" do
before do
- WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200)
+ WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "false", status: 200)
visit new_project_issue_path(project)
end
- it 'creates an issue' do
- fill_in 'issue_title', with: 'issue title'
- fill_in 'issue_description', with: 'issue description'
+ it "creates an issue" do
+ fill_in "issue_title", with: "issue title"
+ fill_in "issue_description", with: "issue description"
- click_button 'Submit issue'
+ click_button "Submit issue"
- expect(page.find('.issue-details h2.title')).to have_content('issue title')
- expect(page.find('.issue-details .description')).to have_content('issue description')
+ expect(page.find(".issue-details h2.title")).to have_content("issue title")
+ expect(page.find(".issue-details .description")).to have_content("issue description")
end
end
end
diff --git a/spec/features/issues/todo_spec.rb b/spec/features/issues/todo_spec.rb
index 0114178b9be..ff5e489672c 100644
--- a/spec/features/issues/todo_spec.rb
+++ b/spec/features/issues/todo_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Manually create a todo item from issue', :js do
+describe "Manually create a todo item from issue", :js do
let!(:project) { create(:project) }
let!(:issue) { create(:issue, project: project) }
let!(:user) { create(:user)}
@@ -11,33 +11,33 @@ describe 'Manually create a todo item from issue', :js do
visit project_issue_path(project, issue)
end
- it 'creates todo when clicking button' do
- page.within '.issuable-sidebar' do
- click_button 'Add todo'
- expect(page).to have_content 'Mark todo as done'
+ it "creates todo when clicking button" do
+ page.within ".issuable-sidebar" do
+ click_button "Add todo"
+ expect(page).to have_content "Mark todo as done"
end
- page.within '.header-content .todos-count' do
- expect(page).to have_content '1'
+ page.within ".header-content .todos-count" do
+ expect(page).to have_content "1"
end
visit project_issue_path(project, issue)
- page.within '.header-content .todos-count' do
- expect(page).to have_content '1'
+ page.within ".header-content .todos-count" do
+ expect(page).to have_content "1"
end
end
- it 'marks a todo as done' do
- page.within '.issuable-sidebar' do
- click_button 'Add todo'
- click_button 'Mark todo as done'
+ it "marks a todo as done" do
+ page.within ".issuable-sidebar" do
+ click_button "Add todo"
+ click_button "Mark todo as done"
end
- expect(page).to have_selector('.todos-count', visible: false)
+ expect(page).to have_selector(".todos-count", visible: false)
visit project_issue_path(project, issue)
- expect(page).to have_selector('.todos-count', visible: false)
+ expect(page).to have_selector(".todos-count", visible: false)
end
end
diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb
index fd8629ae504..74955831f95 100644
--- a/spec/features/issues/update_issues_spec.rb
+++ b/spec/features/issues/update_issues_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Multiple issue updating from issues#index', :js do
+describe "Multiple issue updating from issues#index", :js do
let!(:project) { create(:project) }
let!(:issue) { create(:issue, project: project) }
let!(:user) { create(:user)}
@@ -10,93 +10,93 @@ describe 'Multiple issue updating from issues#index', :js do
sign_in(user)
end
- context 'status' do
- it 'sets to closed' do
+ context "status" do
+ it "sets to closed" do
visit project_issues_path(project)
- click_button 'Edit issues'
- find('#check-all-issues').click
- find('.js-issue-status').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
+ find(".js-issue-status").click
- find('.dropdown-menu-status a', text: 'Closed').click
+ find(".dropdown-menu-status a", text: "Closed").click
click_update_issues_button
- expect(page).to have_selector('.issue', count: 0)
+ expect(page).to have_selector(".issue", count: 0)
end
- it 'sets to open' do
+ it "sets to open" do
create_closed
- visit project_issues_path(project, state: 'closed')
+ visit project_issues_path(project, state: "closed")
- click_button 'Edit issues'
- find('#check-all-issues').click
- find('.js-issue-status').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
+ find(".js-issue-status").click
- find('.dropdown-menu-status a', text: 'Open').click
+ find(".dropdown-menu-status a", text: "Open").click
click_update_issues_button
- expect(page).to have_selector('.issue', count: 0)
+ expect(page).to have_selector(".issue", count: 0)
end
end
- context 'assignee' do
- it 'updates to current user' do
+ context "assignee" do
+ it "updates to current user" do
visit project_issues_path(project)
- click_button 'Edit issues'
- find('#check-all-issues').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
click_update_assignee_button
- find('.dropdown-menu-user-link', text: user.username).click
+ find(".dropdown-menu-user-link", text: user.username).click
click_update_issues_button
- page.within('.issue .controls') do
- expect(find('.author-link')["title"]).to have_content(user.name)
+ page.within(".issue .controls") do
+ expect(find(".author-link")["title"]).to have_content(user.name)
end
end
- it 'updates to unassigned' do
+ it "updates to unassigned" do
create_assigned
visit project_issues_path(project)
- click_button 'Edit issues'
- find('#check-all-issues').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
click_update_assignee_button
- click_link 'Unassigned'
+ click_link "Unassigned"
click_update_issues_button
- expect(find('.issue:first-child .controls')).not_to have_css('.author-link')
+ expect(find(".issue:first-child .controls")).not_to have_css(".author-link")
end
end
- context 'milestone' do
+ context "milestone" do
let!(:milestone) { create(:milestone, project: project) }
- it 'updates milestone' do
+ it "updates milestone" do
visit project_issues_path(project)
- click_button 'Edit issues'
- find('#check-all-issues').click
- find('.issues-bulk-update .js-milestone-select').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
+ find(".issues-bulk-update .js-milestone-select").click
- find('.dropdown-menu-milestone a', text: milestone.title).click
+ find(".dropdown-menu-milestone a", text: milestone.title).click
click_update_issues_button
- expect(find('.issue')).to have_content milestone.title
+ expect(find(".issue")).to have_content milestone.title
end
- it 'sets to no milestone' do
+ it "sets to no milestone" do
create_with_milestone
visit project_issues_path(project)
- expect(first('.issue')).to have_content milestone.title
+ expect(first(".issue")).to have_content milestone.title
- click_button 'Edit issues'
- find('#check-all-issues').click
- find('.issues-bulk-update .js-milestone-select').click
+ click_button "Edit issues"
+ find("#check-all-issues").click
+ find(".issues-bulk-update .js-milestone-select").click
- find('.dropdown-menu-milestone a', text: "No Milestone").click
+ find(".dropdown-menu-milestone a", text: "No Milestone").click
click_update_issues_button
- expect(find('.issue:first-child')).not_to have_content milestone.title
+ expect(find(".issue:first-child")).not_to have_content milestone.title
end
end
@@ -113,12 +113,12 @@ describe 'Multiple issue updating from issues#index', :js do
end
def click_update_assignee_button
- find('.js-update-assignee').click
+ find(".js-update-assignee").click
wait_for_requests
end
def click_update_issues_button
- find('.update-selected-issues').click
+ find(".update-selected-issues").click
wait_for_requests
end
end
diff --git a/spec/features/issues/user_comments_on_issue_spec.rb b/spec/features/issues/user_comments_on_issue_spec.rb
index b4b9a589ba3..474cf210ff7 100644
--- a/spec/features/issues/user_comments_on_issue_spec.rb
+++ b/spec/features/issues/user_comments_on_issue_spec.rb
@@ -38,7 +38,7 @@ describe "User comments on issue", :js do
wait_for_requests
- expect(page.find('pre code').text).to eq code_block_content
+ expect(page.find("pre code").text).to eq code_block_content
end
it "does not render html content in mermaid" do
@@ -50,7 +50,7 @@ describe "User comments on issue", :js do
wait_for_requests
- expect(page.find('svg.mermaid')).to have_content html_content
+ expect(page.find("svg.mermaid")).to have_content html_content
end
end
@@ -75,12 +75,12 @@ describe "User comments on issue", :js do
page.within(".current-note-edit-form") do
fill_in("note[note]", with: comment)
- find('textarea').send_keys [:control, :shift, 'p']
- expect(page).to have_selector('.current-note-edit-form .md-preview-holder')
- expect(page.find('.current-note-edit-form .md-preview-holder p')).to have_content(comment)
+ find("textarea").send_keys [:control, :shift, "p"]
+ expect(page).to have_selector(".current-note-edit-form .md-preview-holder")
+ expect(page.find(".current-note-edit-form .md-preview-holder p")).to have_content(comment)
end
- expect(page).to have_selector('.new-note .note-textarea')
+ expect(page).to have_selector(".new-note .note-textarea")
page.within(".current-note-edit-form") do
click_button("Save comment")
diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
index 693ad89069c..330a5c36967 100644
--- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
+++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb
@@ -1,72 +1,72 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User creates branch and merge request on issue page', :js do
+describe "User creates branch and merge request on issue page", :js do
let(:user) { create(:user) }
let!(:project) { create(:project, :repository) }
- let(:issue) { create(:issue, project: project, title: 'Cherry-Coloured Funk') }
+ let(:issue) { create(:issue, project: project, title: "Cherry-Coloured Funk") }
- context 'when signed out' do
+ context "when signed out" do
before do
visit project_issue_path(project, issue)
end
it "doesn't show 'Create merge request' button" do
- expect(page).not_to have_selector('.create-mr-dropdown-wrap')
+ expect(page).not_to have_selector(".create-mr-dropdown-wrap")
end
end
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in(user)
end
- context 'when interacting with the dropdown' do
+ context "when interacting with the dropdown" do
before do
visit project_issue_path(project, issue)
end
# In order to improve tests performance, all UI checks are placed in this test.
- it 'shows elements' do
- button_create_merge_request = find('.js-create-merge-request')
- button_toggle_dropdown = find('.create-mr-dropdown-wrap .dropdown-toggle')
+ it "shows elements" do
+ button_create_merge_request = find(".js-create-merge-request")
+ button_toggle_dropdown = find(".create-mr-dropdown-wrap .dropdown-toggle")
button_toggle_dropdown.click
- dropdown = find('.create-merge-request-dropdown-menu')
+ dropdown = find(".create-merge-request-dropdown-menu")
page.within(dropdown) do
- button_create_target = find('.js-create-target')
- input_branch_name = find('.js-branch-name')
- input_source = find('.js-ref')
+ button_create_target = find(".js-create-target")
+ input_branch_name = find(".js-branch-name")
+ input_source = find(".js-ref")
li_create_branch = find("li[data-value='create-branch']")
li_create_merge_request = find("li[data-value='create-mr']")
# Test that all elements are presented.
- expect(page).to have_content('Create merge request and branch')
- expect(page).to have_content('Create branch')
- expect(page).to have_content('Branch name')
- expect(page).to have_content('Source (branch or tag)')
- expect(page).to have_button('Create merge request')
- expect(page).to have_selector('.js-branch-name:focus')
+ expect(page).to have_content("Create merge request and branch")
+ expect(page).to have_content("Create branch")
+ expect(page).to have_content("Branch name")
+ expect(page).to have_content("Source (branch or tag)")
+ expect(page).to have_button("Create merge request")
+ expect(page).to have_selector(".js-branch-name:focus")
test_selection_mark(li_create_branch, li_create_merge_request, button_create_target, button_create_merge_request)
test_branch_name_checking(input_branch_name)
test_source_checking(input_source)
# The button inside dropdown should be disabled if any errors occurred.
- expect(page).to have_button('Create branch', disabled: true)
+ expect(page).to have_button("Create branch", disabled: true)
end
# The top level button should be disabled if any errors occurred.
- expect(page).to have_button('Create branch', disabled: true)
+ expect(page).to have_button("Create branch", disabled: true)
end
- context 'when branch name is auto-generated' do
- it 'creates a merge request' do
+ context "when branch name is auto-generated" do
+ it "creates a merge request" do
perform_enqueued_jobs do
- select_dropdown_option('create-mr')
+ select_dropdown_option("create-mr")
expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"')
expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first))
@@ -77,28 +77,28 @@ describe 'User creates branch and merge request on issue page', :js do
visit project_issue_path(project, issue)
expect(page).to have_content("created merge request !1 to address this issue")
- expect(page).to have_content('mentioned in merge request !1')
+ expect(page).to have_content("mentioned in merge request !1")
end
- it 'creates a branch' do
- select_dropdown_option('create-branch')
+ it "creates a branch" do
+ select_dropdown_option("create-branch")
wait_for_requests
- expect(page).to have_selector('.dropdown-toggle-text ', text: '1-cherry-coloured-funk')
- expect(current_path).to eq project_tree_path(project, '1-cherry-coloured-funk')
+ expect(page).to have_selector(".dropdown-toggle-text ", text: "1-cherry-coloured-funk")
+ expect(current_path).to eq project_tree_path(project, "1-cherry-coloured-funk")
end
end
- context 'when branch name is custom' do
- let(:branch_name) { 'custom-branch-name' }
+ context "when branch name is custom" do
+ let(:branch_name) { "custom-branch-name" }
- it 'creates a merge request' do
+ it "creates a merge request" do
perform_enqueued_jobs do
- select_dropdown_option('create-mr', branch_name)
+ select_dropdown_option("create-mr", branch_name)
expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"')
- expect(page).to have_content('Request to merge custom-branch-name into')
+ expect(page).to have_content("Request to merge custom-branch-name into")
expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first))
wait_for_requests
@@ -107,15 +107,15 @@ describe 'User creates branch and merge request on issue page', :js do
visit project_issue_path(project, issue)
expect(page).to have_content("created merge request !1 to address this issue")
- expect(page).to have_content('mentioned in merge request !1')
+ expect(page).to have_content("mentioned in merge request !1")
end
- it 'creates a branch' do
- select_dropdown_option('create-branch', branch_name)
+ it "creates a branch" do
+ select_dropdown_option("create-branch", branch_name)
wait_for_requests
- expect(page).to have_selector('.dropdown-toggle-text ', text: branch_name)
+ expect(page).to have_selector(".dropdown-toggle-text ", text: branch_name)
expect(current_path).to eq project_tree_path(project, branch_name)
end
end
@@ -138,33 +138,33 @@ describe 'User creates branch and merge request on issue page', :js do
visit project_issue_path(project, issue)
end
- it 'disables the create branch button' do
- expect(page).to have_css('.create-mr-dropdown-wrap .unavailable:not(.hidden)')
- expect(page).to have_css('.create-mr-dropdown-wrap .available.hidden', visible: false)
+ it "disables the create branch button" do
+ expect(page).to have_css(".create-mr-dropdown-wrap .unavailable:not(.hidden)")
+ expect(page).to have_css(".create-mr-dropdown-wrap .available.hidden", visible: false)
expect(page).to have_content /Related merge requests/
end
end
- context 'when merge requests are disabled' do
+ context "when merge requests are disabled" do
before do
project.project_feature.update(merge_requests_access_level: 0)
visit project_issue_path(project, issue)
end
- it 'shows only create branch button' do
- expect(page).not_to have_button('Create merge request')
- expect(page).to have_button('Create branch')
+ it "shows only create branch button" do
+ expect(page).not_to have_button("Create merge request")
+ expect(page).to have_button("Create branch")
end
end
- context 'when issue is confidential' do
+ context "when issue is confidential" do
let(:issue) { create(:issue, :confidential, project: project) }
- it 'disables the create branch button' do
+ it "disables the create branch button" do
visit project_issue_path(project, issue)
- expect(page).not_to have_css('.create-mr-dropdown-wrap')
+ expect(page).not_to have_css(".create-mr-dropdown-wrap")
end
end
end
@@ -172,11 +172,11 @@ describe 'User creates branch and merge request on issue page', :js do
private
def select_dropdown_option(option, branch_name = nil)
- find('.create-mr-dropdown-wrap .dropdown-toggle').click
+ find(".create-mr-dropdown-wrap .dropdown-toggle").click
find("li[data-value='#{option}']").click
if branch_name
- find('.js-branch-name').set(branch_name)
+ find(".js-branch-name").set(branch_name)
# Javascript debounces AJAX calls.
# So we have to wait until AJAX requests are started.
@@ -187,57 +187,57 @@ describe 'User creates branch and merge request on issue page', :js do
wait_for_requests
end
- find('.js-create-merge-request').click
+ find(".js-create-merge-request").click
end
def test_branch_name_checking(input_branch_name)
expect(input_branch_name.value).to eq(issue.to_branch_name)
- input_branch_name.set('new-branch-name')
- branch_name_message = find('.js-branch-message')
+ input_branch_name.set("new-branch-name")
+ branch_name_message = find(".js-branch-message")
- expect(branch_name_message).to have_text('Checking branch name availability…')
+ expect(branch_name_message).to have_text("Checking branch name availability…")
wait_for_requests
- expect(branch_name_message).to have_text('Branch name is available')
+ expect(branch_name_message).to have_text("Branch name is available")
input_branch_name.set(project.default_branch)
- expect(branch_name_message).to have_text('Checking branch name availability…')
+ expect(branch_name_message).to have_text("Checking branch name availability…")
wait_for_requests
- expect(branch_name_message).to have_text('Branch is already taken')
+ expect(branch_name_message).to have_text("Branch is already taken")
end
def test_selection_mark(li_create_branch, li_create_merge_request, button_create_target, button_create_merge_request)
page.within(li_create_merge_request) do
- expect(page).to have_css('i.fa.fa-check')
- expect(button_create_target).to have_text('Create merge request')
- expect(button_create_merge_request).to have_text('Create merge request')
+ expect(page).to have_css("i.fa.fa-check")
+ expect(button_create_target).to have_text("Create merge request")
+ expect(button_create_merge_request).to have_text("Create merge request")
end
li_create_branch.click
page.within(li_create_branch) do
- expect(page).to have_css('i.fa.fa-check')
- expect(button_create_target).to have_text('Create branch')
- expect(button_create_merge_request).to have_text('Create branch')
+ expect(page).to have_css("i.fa.fa-check")
+ expect(button_create_target).to have_text("Create branch")
+ expect(button_create_merge_request).to have_text("Create branch")
end
end
def test_source_checking(input_source)
expect(input_source.value).to eq(project.default_branch)
- input_source.set('mas') # Intentionally entered first 3 letters of `master` to check autocomplete feature later.
- source_message = find('.js-ref-message')
+ input_source.set("mas") # Intentionally entered first 3 letters of `master` to check autocomplete feature later.
+ source_message = find(".js-ref-message")
- expect(source_message).to have_text('Checking source availability…')
+ expect(source_message).to have_text("Checking source availability…")
wait_for_requests
- expect(source_message).to have_text('Source is not available')
+ expect(source_message).to have_text("Source is not available")
# JavaScript gets refs started with `mas` (entered above) and places the first match.
# User sees `mas` in black color (the part he entered) and the `ter` in gray color (a hint).
diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb
index e60486f6dcb..9aab338fe4c 100644
--- a/spec/features/issues/user_creates_issue_spec.rb
+++ b/spec/features/issues/user_creates_issue_spec.rb
@@ -17,25 +17,25 @@ describe "User creates issue" do
it "creates issue", :js do
page.within(".issue-form") do
expect(page).to have_no_content("Assign to")
- .and have_no_content("Labels")
- .and have_no_content("Milestone")
+ .and have_no_content("Labels")
+ .and have_no_content("Milestone")
- expect(page.find('#issue_title')['placeholder']).to eq 'Title'
- expect(page.find('#issue_description')['placeholder']).to eq 'Write a comment or drag your files here…'
+ expect(page.find("#issue_title")["placeholder"]).to eq "Title"
+ expect(page.find("#issue_description")["placeholder"]).to eq "Write a comment or drag your files here…"
end
issue_title = "500 error on profile"
fill_in("Title", with: issue_title)
- first('.js-md').click
- first('.qa-issuable-form-description').native.send_keys('Description')
+ first(".js-md").click
+ first(".qa-issuable-form-description").native.send_keys("Description")
click_button("Submit issue")
expect(page).to have_content(issue_title)
.and have_content(user.name)
.and have_content(project.name)
- expect(page).to have_selector('strong', text: 'Description')
+ expect(page).to have_selector("strong", text: "Description")
end
end
@@ -70,7 +70,7 @@ describe "User creates issue" do
end
context "with labels" do
- let(:label_titles) { %w(bug feature enhancement) }
+ let(:label_titles) { %w[bug feature enhancement] }
before do
label_titles.each do |title|
diff --git a/spec/features/issues/user_interacts_with_awards_spec.rb b/spec/features/issues/user_interacts_with_awards_spec.rb
index afa425c2cec..dcf9c194e53 100644
--- a/spec/features/issues/user_interacts_with_awards_spec.rb
+++ b/spec/features/issues/user_interacts_with_awards_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User interacts with awards' do
+describe "User interacts with awards" do
let(:user) { create(:user) }
- describe 'User interacts with awards in an issue', :js do
+ describe "User interacts with awards in an issue", :js do
let(:issue) { create(:issue, project: project)}
let(:project) { create(:project) }
@@ -14,116 +14,116 @@ describe 'User interacts with awards' do
visit(project_issue_path(project, issue))
end
- it 'toggles the thumbsup award emoji' do
- page.within('.awards') do
- thumbsup = page.first('.award-control')
+ it "toggles the thumbsup award emoji" do
+ page.within(".awards") do
+ thumbsup = page.first(".award-control")
thumbsup.click
thumbsup.hover
- expect(page).to have_selector('.js-emoji-btn')
+ expect(page).to have_selector(".js-emoji-btn")
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
- expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
+ expect(page.find(".js-emoji-btn.active .js-counter")).to have_content("1")
- thumbsup = page.first('.award-control')
+ thumbsup = page.first(".award-control")
thumbsup.click
thumbsup.hover
- expect(page).to have_selector('.award-control.js-emoji-btn')
- expect(page.all('.award-control.js-emoji-btn').size).to eq(2)
+ expect(page).to have_selector(".award-control.js-emoji-btn")
+ expect(page.all(".award-control.js-emoji-btn").size).to eq(2)
- page.all('.award-control.js-emoji-btn').each do |element|
- expect(element['title']).to eq('')
+ page.all(".award-control.js-emoji-btn").each do |element|
+ expect(element["title"]).to eq("")
end
- expect(page.all('.award-control .js-counter')).to all(have_content('0'))
+ expect(page.all(".award-control .js-counter")).to all(have_content("0"))
- thumbsup = page.first('.award-control')
+ thumbsup = page.first(".award-control")
thumbsup.click
thumbsup.hover
- expect(page).to have_selector('.js-emoji-btn')
+ expect(page).to have_selector(".js-emoji-btn")
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
- expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
+ expect(page.find(".js-emoji-btn.active .js-counter")).to have_content("1")
end
end
- it 'toggles a custom award emoji' do
- page.within('.awards') do
- page.find('.js-add-award').click
+ it "toggles a custom award emoji" do
+ page.within(".awards") do
+ page.find(".js-add-award").click
end
- page.find('.emoji-menu.is-visible')
+ page.find(".emoji-menu.is-visible")
- expect(page).to have_selector('.js-emoji-menu-search')
+ expect(page).to have_selector(".js-emoji-menu-search")
expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
- page.within('.emoji-menu-content') do
- emoji_button = page.first('.js-emoji-btn')
+ page.within(".emoji-menu-content") do
+ emoji_button = page.first(".js-emoji-btn")
emoji_button.hover
emoji_button.click
end
- page.within('.awards') do
- expect(page).to have_selector('.js-emoji-btn')
- expect(page.find('.js-emoji-btn.active .js-counter')).to have_content('1')
+ page.within(".awards") do
+ expect(page).to have_selector(".js-emoji-btn")
+ expect(page.find(".js-emoji-btn.active .js-counter")).to have_content("1")
expect(page).to have_css(".js-emoji-btn.active[data-original-title='You']")
- expect do
- page.find('.js-emoji-btn.active').click
+ expect {
+ page.find(".js-emoji-btn.active").click
wait_for_requests
- end.to change { page.all('.award-control.js-emoji-btn').size }.from(3).to(2)
+ }.to change { page.all(".award-control.js-emoji-btn").size }.from(3).to(2)
end
end
- it 'shows the list of award emoji categories' do
- page.within('.awards') do
- page.find('.js-add-award').click
+ it "shows the list of award emoji categories" do
+ page.within(".awards") do
+ page.find(".js-add-award").click
end
- page.find('.emoji-menu.is-visible')
+ page.find(".emoji-menu.is-visible")
- expect(page).to have_selector('.js-emoji-menu-search')
+ expect(page).to have_selector(".js-emoji-menu-search")
expect(page.evaluate_script("document.activeElement.classList.contains('js-emoji-menu-search')")).to eq(true)
- fill_in('emoji-menu-search', with: 'hand')
+ fill_in("emoji-menu-search", with: "hand")
- page.within('.emoji-menu-content') do
+ page.within(".emoji-menu-content") do
expect(page).to have_selector('[data-name="raised_hand"]')
end
end
- it 'adds an award emoji by a comment' do
- page.within('.js-main-target-form') do
- fill_in('note[note]', with: ':smile:')
+ it "adds an award emoji by a comment" do
+ page.within(".js-main-target-form") do
+ fill_in("note[note]", with: ":smile:")
- click_button('Comment')
+ click_button("Comment")
end
- expect(page).to have_emoji('smile')
+ expect(page).to have_emoji("smile")
end
- context 'when a project is archived' do
+ context "when a project is archived" do
let(:project) { create(:project, :archived) }
- it 'hides the add award button' do
- page.within('.awards') do
- expect(page).not_to have_css('.js-add-award')
+ it "hides the add award button" do
+ page.within(".awards") do
+ expect(page).not_to have_css(".js-add-award")
end
end
end
- context 'User interacts with awards on a note' do
+ context "User interacts with awards on a note" do
let!(:note) { create(:note, noteable: issue, project: issue.project) }
- let!(:award_emoji) { create(:award_emoji, awardable: note, name: '100') }
+ let!(:award_emoji) { create(:award_emoji, awardable: note, name: "100") }
- it 'shows the award on the note' do
- page.within('.note-awards') do
- expect(page).to have_emoji('100')
+ it "shows the award on the note" do
+ page.within(".note-awards") do
+ expect(page).to have_emoji("100")
end
end
- it 'allows adding a vote to an award' do
- page.within('.note-awards') do
+ it "allows adding a vote to an award" do
+ page.within(".note-awards") do
find('gl-emoji[data-name="100"]').click
end
wait_for_requests
@@ -131,36 +131,36 @@ describe 'User interacts with awards' do
expect(note.reload.award_emoji.size).to eq(2)
end
- it 'allows adding a new emoji' do
- page.within('.note-actions') do
- find('a.js-add-award').click
+ it "allows adding a new emoji" do
+ page.within(".note-actions") do
+ find("a.js-add-award").click
end
- page.within('.emoji-menu-content') do
+ page.within(".emoji-menu-content") do
find('gl-emoji[data-name="8ball"]').click
end
wait_for_requests
- page.within('.note-awards') do
- expect(page).to have_emoji('8ball')
+ page.within(".note-awards") do
+ expect(page).to have_emoji("8ball")
end
expect(note.reload.award_emoji.size).to eq(2)
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :archived) }
- it 'hides the buttons for adding new emoji' do
- page.within('.note-awards') do
- expect(page).not_to have_css('.award-menu-holder')
+ it "hides the buttons for adding new emoji" do
+ page.within(".note-awards") do
+ expect(page).not_to have_css(".award-menu-holder")
end
- page.within('.note-actions') do
- expect(page).not_to have_css('a.js-add-award')
+ page.within(".note-actions") do
+ expect(page).not_to have_css("a.js-add-award")
end
end
- it 'does not allow toggling existing emoji' do
- page.within('.note-awards') do
+ it "does not allow toggling existing emoji" do
+ page.within(".note-awards") do
find('gl-emoji[data-name="100"]').click
end
wait_for_requests
@@ -171,83 +171,83 @@ describe 'User interacts with awards' do
end
end
- describe 'User interacts with awards on an issue', :js do
+ describe "User interacts with awards on an issue", :js do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
- describe 'logged in' do
+ describe "logged in" do
before do
sign_in(user)
visit project_issue_path(project, issue)
wait_for_requests
end
- it 'adds award to issue' do
- first('.js-emoji-btn').click
+ 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'
+ expect(page).to have_selector(".js-emoji-btn.active")
+ expect(first(".js-emoji-btn")).to have_content "1"
visit project_issue_path(project, issue)
- expect(first('.js-emoji-btn')).to have_content '1'
+ expect(first(".js-emoji-btn")).to have_content "1"
end
- it 'removes award from issue' do
- first('.js-emoji-btn').click
- find('.js-emoji-btn.active').click
+ 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'
+ expect(first(".js-emoji-btn")).to have_content "0"
visit project_issue_path(project, issue)
- expect(first('.js-emoji-btn')).to have_content '0'
+ expect(first(".js-emoji-btn")).to have_content "0"
end
- it 'only has one menu on the page' do
- first('.js-add-award').click
+ it "only has one menu on the page" do
+ first(".js-add-award").click
- expect(page).to have_selector('.emoji-menu', count: 1)
+ expect(page).to have_selector(".emoji-menu", count: 1)
end
end
- describe 'logged out' do
+ describe "logged out" do
before do
visit project_issue_path(project, issue)
wait_for_requests
end
- it 'does not see award menu button' do
- expect(page).not_to have_selector('.js-award-holder')
+ it "does not see award menu button" do
+ expect(page).not_to have_selector(".js-award-holder")
end
end
end
- describe 'Awards Emoji' do
+ describe "Awards Emoji" do
let!(:project) { create(:project, :public) }
let(:issue) { create(:issue, assignees: [user], project: project) }
- context 'authorized user' do
+ context "authorized user" do
before do
project.add_maintainer(user)
sign_in(user)
end
- describe 'visiting an issue with a legacy award emoji that is not valid anymore' do
+ describe "visiting an issue with a legacy award emoji that is not valid anymore" do
before do
# The `heart_tip` emoji is not valid anymore so we need to skip validation
- issue.award_emoji.build(user: user, name: 'heart_tip').save!(validate: false)
+ issue.award_emoji.build(user: user, name: "heart_tip").save!(validate: false)
visit project_issue_path(project, issue)
wait_for_requests
end
# Regression test: https://gitlab.com/gitlab-org/gitlab-ce/issues/29529
- it 'does not shows a 500 page', :js do
+ it "does not shows a 500 page", :js do
expect(page).to have_text(issue.title)
end
end
- describe 'Click award emoji from issue#show' do
+ describe "Click award emoji from issue#show" do
let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") }
before do
@@ -255,39 +255,39 @@ describe 'User interacts with awards' do
wait_for_requests
end
- context 'click the thumbsdown emoji' do
- it 'increments the thumbsdown emoji', :js do
+ context "click the thumbsdown emoji" do
+ it "increments the thumbsdown emoji", :js do
find('[data-name="thumbsdown"]').click
wait_for_requests
expect(thumbsdown_emoji).to have_text("1")
end
- it 'decrements the thumbsup emoji', :js do
+ it "decrements the thumbsup emoji", :js do
expect(thumbsup_emoji).to have_text("0")
end
end
- it 'toggles the smiley emoji on a note', :js do
+ it "toggles the smiley emoji on a note", :js do
toggle_smiley_emoji(true)
- within('.note-body') do
+ within(".note-body") do
expect(find(emoji_counter)).to have_text("1")
end
toggle_smiley_emoji(false)
- within('.note-body') do
+ within(".note-body") do
expect(page).not_to have_selector(emoji_counter)
end
end
- context 'execute /award quick action' do
- it 'toggles the emoji award on noteable', :js do
- execute_quick_action('/award :100:')
+ context "execute /award quick action" do
+ it "toggles the emoji award on noteable", :js do
+ execute_quick_action("/award :100:")
expect(find(noteable_award_counter)).to have_text("1")
- execute_quick_action('/award :100:')
+ execute_quick_action("/award :100:")
expect(page).not_to have_selector(noteable_award_counter)
end
@@ -295,20 +295,20 @@ describe 'User interacts with awards' do
end
end
- context 'unauthorized user', :js do
+ context "unauthorized user", :js do
before do
visit project_issue_path(project, issue)
end
- it 'has disabled emoji button' do
- expect(first('.award-control')[:class]).to have_text('disabled')
+ it "has disabled emoji button" do
+ expect(first(".award-control")[:class]).to have_text("disabled")
end
end
def execute_quick_action(cmd)
- within('.js-main-target-form') do
- fill_in 'note[note]', with: cmd
- click_button 'Comment'
+ within(".js-main-target-form") do
+ fill_in "note[note]", with: cmd
+ click_button "Comment"
end
wait_for_requests
@@ -323,7 +323,7 @@ describe 'User interacts with awards' do
end
def emoji_counter
- 'span.js-counter'
+ "span.js-counter"
end
def noteable_award_counter
@@ -331,8 +331,8 @@ describe 'User interacts with awards' do
end
def toggle_smiley_emoji(status)
- within('.note') do
- find('.note-emoji-button').click
+ within(".note") do
+ find(".note-emoji-button").click
end
if !status
diff --git a/spec/features/issues/user_sees_breadcrumb_links_spec.rb b/spec/features/issues/user_sees_breadcrumb_links_spec.rb
index 43369f7609f..f584d7ce4d0 100644
--- a/spec/features/issues/user_sees_breadcrumb_links_spec.rb
+++ b/spec/features/issues/user_sees_breadcrumb_links_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New issue breadcrumb' do
+describe "New issue breadcrumb" do
let(:project) { create(:project) }
let(:user) { project.creator }
@@ -9,10 +9,10 @@ describe 'New issue breadcrumb' do
visit(new_project_issue_path(project))
end
- it 'displays link to project issues and new issue' do
- page.within '.breadcrumbs' do
- expect(find_link('Issues')[:href]).to end_with(project_issues_path(project))
- expect(find_link('New')[:href]).to end_with(new_project_issue_path(project))
+ it "displays link to project issues and new issue" do
+ page.within ".breadcrumbs" do
+ expect(find_link("Issues")[:href]).to end_with(project_issues_path(project))
+ expect(find_link("New")[:href]).to end_with(new_project_issue_path(project))
end
end
end
diff --git a/spec/features/issues/user_sorts_issues_spec.rb b/spec/features/issues/user_sorts_issues_spec.rb
index eebd2d57cca..195cf344322 100644
--- a/spec/features/issues/user_sorts_issues_spec.rb
+++ b/spec/features/issues/user_sorts_issues_spec.rb
@@ -19,30 +19,30 @@ describe "User sorts issues" do
visit(project_issues_path(project))
end
- it 'keeps the sort option' do
- find('.filter-dropdown-container .dropdown').click
+ it "keeps the sort option" do
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
- click_link('Milestone')
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
+ click_link("Milestone")
end
visit(issues_dashboard_path(assignee_username: user.username))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
visit(project_issues_path(project))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
visit(issues_group_path(group))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
end
it "sorts by popularity" do
- find('.filter-dropdown-container .dropdown').click
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
click_link("Popularity")
end
diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb
index 27cffdc5f8b..223ff259423 100644
--- a/spec/features/issues/user_uses_quick_actions_spec.rb
+++ b/spec/features/issues/user_uses_quick_actions_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Issues > User uses quick actions', :js do
+describe "Issues > User uses quick actions", :js do
include Spec::Support::Helpers::Features::NotesHelpers
- it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do
+ it_behaves_like "issuable record that supports quick actions in its description and notes", :issue do
let(:issuable) { create(:issue, project: project) }
end
- describe 'issue-only commands' do
+ describe "issue-only commands" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
@@ -21,25 +21,25 @@ describe 'Issues > User uses quick actions', :js do
wait_for_requests
end
- describe 'time tracking' do
+ describe "time tracking" do
let(:issue) { create(:issue, project: project) }
before do
visit project_issue_path(project, issue)
end
- it_behaves_like 'issuable time tracker'
+ it_behaves_like "issuable time tracker"
end
- describe 'adding a due date from note' do
+ describe "adding a due date from note" do
let(:issue) { create(:issue, project: project) }
- context 'when the current user can update the due date' do
- it 'does not create a note, and sets the due date accordingly' do
+ context "when the current user can update the due date" do
+ it "does not create a note, and sets the due date accordingly" do
add_note("/due 2016-08-28")
- expect(page).not_to have_content '/due 2016-08-28'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/due 2016-08-28"
+ expect(page).to have_content "Commands applied"
issue.reload
@@ -47,7 +47,7 @@ describe 'Issues > User uses quick actions', :js do
end
end
- context 'when the current user cannot update the due date' do
+ context "when the current user cannot update the due date" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
@@ -56,10 +56,10 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'does not create a note, and sets the due date accordingly' do
+ it "does not create a note, and sets the due date accordingly" do
add_note("/due 2016-08-28")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
issue.reload
@@ -68,17 +68,17 @@ describe 'Issues > User uses quick actions', :js do
end
end
- describe 'removing a due date from note' do
+ describe "removing a due date from note" do
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
- context 'when the current user can update the due date' do
- it 'does not create a note, and removes the due date accordingly' do
+ context "when the current user can update the due date" do
+ it "does not create a note, and removes the due date accordingly" do
expect(issue.due_date).to eq Date.new(2016, 8, 28)
add_note("/remove_due_date")
- expect(page).not_to have_content '/remove_due_date'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/remove_due_date"
+ expect(page).to have_content "Commands applied"
issue.reload
@@ -86,7 +86,7 @@ describe 'Issues > User uses quick actions', :js do
end
end
- context 'when the current user cannot update the due date' do
+ context "when the current user cannot update the due date" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
@@ -95,10 +95,10 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'does not create a note, and sets the due date accordingly' do
+ it "does not create a note, and sets the due date accordingly" do
add_note("/remove_due_date")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
issue.reload
@@ -107,33 +107,33 @@ describe 'Issues > User uses quick actions', :js do
end
end
- describe 'toggling the WIP prefix from the title from note' do
+ describe "toggling the WIP prefix from the title from note" do
let(:issue) { create(:issue, project: project) }
- it 'does not recognize the command nor create a note' do
+ it "does not recognize the command nor create a note" do
add_note("/wip")
- expect(page).not_to have_content '/wip'
+ expect(page).not_to have_content "/wip"
end
end
- describe 'mark issue as duplicate' do
+ describe "mark issue as duplicate" do
let(:issue) { create(:issue, project: project) }
let(:original_issue) { create(:issue, project: project) }
- context 'when the current user can update issues' do
- it 'does not create a note, and marks the issue as a duplicate' do
+ context "when the current user can update issues" do
+ it "does not create a note, and marks the issue as a duplicate" do
add_note("/duplicate ##{original_issue.to_reference}")
expect(page).not_to have_content "/duplicate #{original_issue.to_reference}"
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(page).to have_content "marked this issue as a duplicate of #{original_issue.to_reference}"
expect(issue.reload).to be_closed
end
end
- context 'when the current user cannot update the issue' do
+ context "when the current user cannot update the issue" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
@@ -142,10 +142,10 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'does not create a note, and does not mark the issue as a duplicate' do
+ it "does not create a note, and does not mark the issue as a duplicate" do
add_note("/duplicate ##{original_issue.to_reference}")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}"
expect(issue.reload).to be_open
@@ -153,23 +153,23 @@ describe 'Issues > User uses quick actions', :js do
end
end
- describe 'make issue confidential' do
+ describe "make issue confidential" do
let(:issue) { create(:issue, project: project) }
let(:original_issue) { create(:issue, project: project) }
- context 'when the current user can update issues' do
- it 'does not create a note, and marks the issue as confidential' do
+ context "when the current user can update issues" do
+ it "does not create a note, and marks the issue as confidential" do
add_note("/confidential")
expect(page).not_to have_content "/confidential"
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(page).to have_content "made the issue confidential"
expect(issue.reload).to be_confidential
end
end
- context 'when the current user cannot update the issue' do
+ context "when the current user cannot update the issue" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
@@ -178,10 +178,10 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'does not create a note, and does not mark the issue as confidential' do
+ it "does not create a note, and does not mark the issue as confidential" do
add_note("/confidential")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(page).not_to have_content "made the issue confidential"
expect(issue.reload).not_to be_confidential
@@ -189,10 +189,10 @@ describe 'Issues > User uses quick actions', :js do
end
end
- describe 'move the issue to another project' do
+ describe "move the issue to another project" do
let(:issue) { create(:issue, project: project) }
- context 'when the project is valid' do
+ context "when the project is valid" do
let(:target_project) { create(:project, :public) }
before do
@@ -202,19 +202,19 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'moves the issue' do
+ it "moves the issue" do
add_note("/move #{target_project.full_path}")
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(issue.reload).to be_closed
visit project_issue_path(target_project, issue)
- expect(page).to have_content 'Issues 1'
+ expect(page).to have_content "Issues 1"
end
end
- context 'when the project is valid but the user not authorized' do
+ context "when the project is valid but the user not authorized" do
let(:project_unauthorized) { create(:project, :public) }
before do
@@ -223,39 +223,39 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'does not move the issue' do
+ it "does not move the issue" do
add_note("/move #{project_unauthorized.full_path}")
wait_for_requests
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(issue.reload).to be_open
end
end
- context 'when the project is invalid' do
+ context "when the project is invalid" do
before do
gitlab_sign_out
sign_in(user)
visit project_issue_path(project, issue)
end
- it 'does not move the issue' do
+ it "does not move the issue" do
add_note("/move not/valid")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(issue.reload).to be_open
end
end
- context 'when the user issues multiple commands' do
+ context "when the user issues multiple commands" do
let(:target_project) { create(:project, :public) }
- let(:milestone) { create(:milestone, title: '1.0', project: project) }
- let(:target_milestone) { create(:milestone, title: '1.0', project: target_project) }
- let(:bug) { create(:label, project: project, title: 'bug') }
- let(:wontfix) { create(:label, project: project, title: 'wontfix') }
- let(:bug_target) { create(:label, project: target_project, title: 'bug') }
- let(:wontfix_target) { create(:label, project: target_project, title: 'wontfix') }
+ let(:milestone) { create(:milestone, title: "1.0", project: project) }
+ let(:target_milestone) { create(:milestone, title: "1.0", project: target_project) }
+ let(:bug) { create(:label, project: project, title: "bug") }
+ let(:wontfix) { create(:label, project: project, title: "wontfix") }
+ let(:bug_target) { create(:label, project: target_project, title: "bug") }
+ let(:wontfix_target) { create(:label, project: target_project, title: "wontfix") }
before do
target_project.add_maintainer(user)
@@ -264,57 +264,57 @@ describe 'Issues > User uses quick actions', :js do
visit project_issue_path(project, issue)
end
- it 'applies the commands to both issues and moves the issue' do
+ it "applies the commands to both issues and moves the issue" do
add_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}")
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(issue.reload).to be_closed
visit project_issue_path(target_project, issue)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content '1.0'
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "1.0"
visit project_issue_path(project, issue)
- expect(page).to have_content 'Closed'
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content '1.0'
+ expect(page).to have_content "Closed"
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "1.0"
end
- it 'moves the issue and applies the commands to both issues' do
+ it "moves the issue and applies the commands to both issues" do
add_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"")
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(issue.reload).to be_closed
visit project_issue_path(target_project, issue)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content '1.0'
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "1.0"
visit project_issue_path(project, issue)
- expect(page).to have_content 'Closed'
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content '1.0'
+ expect(page).to have_content "Closed"
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "1.0"
end
end
end
- describe 'create a merge request starting from an issue' do
+ describe "create a merge request starting from an issue" do
let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project) }
def expect_mr_quickaction(success)
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
if success
- expect(page).to have_content 'created merge request'
+ expect(page).to have_content "created merge request"
else
- expect(page).not_to have_content 'created merge request'
+ expect(page).not_to have_content "created merge request"
end
end
@@ -334,7 +334,7 @@ describe 'Issues > User uses quick actions', :js do
expect_mr_quickaction(false)
end
- it 'creates a new merge request using issue iid and title as branch name when the branch name is empty' do
+ it "creates a new merge request using issue iid and title as branch name when the branch name is empty" do
add_note("/create_merge_request")
wait_for_requests
@@ -345,11 +345,11 @@ describe 'Issues > User uses quick actions', :js do
expect(created_mr.source_branch).to eq(issue.to_branch_name)
visit project_merge_request_path(project, created_mr)
- expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
+ expect(page).to have_content %(WIP: Resolve "#{issue.title}")
end
- it 'creates a merge request using the given branch name' do
- branch_name = '1-feature'
+ it "creates a merge request using the given branch name" do
+ branch_name = "1-feature"
add_note("/create_merge_request #{branch_name}")
expect_mr_quickaction(true)
@@ -358,7 +358,7 @@ describe 'Issues > User uses quick actions', :js do
expect(created_mr.source_branch).to eq(branch_name)
visit project_merge_request_path(project, created_mr)
- expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
+ expect(page).to have_content %(WIP: Resolve "#{issue.title}")
end
end
end
diff --git a/spec/features/issues/user_views_issue_spec.rb b/spec/features/issues/user_views_issue_spec.rb
index 330b6f0e77a..7efaa3f95da 100644
--- a/spec/features/issues/user_views_issue_spec.rb
+++ b/spec/features/issues/user_views_issue_spec.rb
@@ -14,35 +14,35 @@ describe "User views issue" do
it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") }
- it 'shows the merge request and issue actions', :aggregate_failures do
- expect(page).to have_link('New issue')
- expect(page).to have_button('Create merge request')
- expect(page).to have_link('Close issue')
+ it "shows the merge request and issue actions", :aggregate_failures do
+ expect(page).to have_link("New issue")
+ expect(page).to have_button("Create merge request")
+ expect(page).to have_link("Close issue")
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :public, :archived) }
- it 'hides the merge request and issue actions', :aggregate_failures do
- expect(page).not_to have_link('New issue')
- expect(page).not_to have_button('Create merge request')
- expect(page).not_to have_link('Close issue')
+ it "hides the merge request and issue actions", :aggregate_failures do
+ expect(page).not_to have_link("New issue")
+ expect(page).not_to have_button("Create merge request")
+ expect(page).not_to have_link("Close issue")
end
end
- describe 'user status' do
+ describe "user status" do
subject { visit(project_issue_path(project, issue)) }
- describe 'showing status of the author of the issue' do
- it_behaves_like 'showing user status' do
+ describe "showing status of the author of the issue" do
+ it_behaves_like "showing user status" do
let(:user_with_status) { issue.author }
end
end
- describe 'showing status of a user who commented on an issue', :js do
+ describe "showing status of a user who commented on an issue", :js do
let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { create(:user) }
end
end
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index 406e80e91aa..014b57f3d3e 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Issues' do
+describe "Issues" do
include DropzoneHelper
include IssueHelpers
include SortingHelper
@@ -8,32 +8,32 @@ describe 'Issues' do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
- shared_examples_for 'empty state with filters' do
- it 'user sees empty state with filters' do
+ shared_examples_for "empty state with filters" do
+ it "user sees empty state with filters" do
create(:issue, author: user, project: project)
visit project_issues_path(project, milestone_title: "1.0")
- expect(page).to have_content('Sorry, your filter produced no results')
- expect(page).to have_content('To widen your search, change or remove filters above')
+ expect(page).to have_content("Sorry, your filter produced no results")
+ expect(page).to have_content("To widen your search, change or remove filters above")
end
end
- describe 'while user is signed out' do
- describe 'empty state' do
- it 'user sees empty state' do
+ describe "while user is signed out" do
+ describe "empty state" do
+ it "user sees empty state" do
visit project_issues_path(project)
- expect(page).to have_content('Register / Sign In')
- expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project.')
- expect(page).to have_content('You can register or sign in to create issues for this project.')
+ expect(page).to have_content("Register / Sign In")
+ expect(page).to have_content("The Issue Tracker is the place to add things that need to be improved or solved in a project.")
+ expect(page).to have_content("You can register or sign in to create issues for this project.")
end
- it_behaves_like 'empty state with filters'
+ it_behaves_like "empty state with filters"
end
end
- describe 'while user is signed in' do
+ describe "while user is signed in" do
before do
sign_in(user)
user2 = create(:user)
@@ -42,164 +42,164 @@ describe 'Issues' do
project.add_developer(user2)
end
- describe 'empty state' do
- it 'user sees empty state' do
+ describe "empty state" do
+ it "user sees empty state" do
visit project_issues_path(project)
- expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project')
- expect(page).to have_content('Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.')
- expect(page).to have_content('New issue')
+ expect(page).to have_content("The Issue Tracker is the place to add things that need to be improved or solved in a project")
+ expect(page).to have_content("Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.")
+ expect(page).to have_content("New issue")
end
- it_behaves_like 'empty state with filters'
+ it_behaves_like "empty state with filters"
end
- describe 'Edit issue' do
+ describe "Edit issue" do
let!(:issue) do
create(:issue,
- author: user,
- assignees: [user],
- project: project)
+ author: user,
+ assignees: [user],
+ project: project)
end
before do
visit edit_project_issue_path(project, issue)
- find('.js-zen-enter').click
+ find(".js-zen-enter").click
end
- it 'opens new issue popup' do
+ it "opens new issue popup" do
expect(page).to have_content("Issue ##{issue.iid}")
end
end
- describe 'Editing issue assignee' do
+ describe "Editing issue assignee" do
let!(:issue) do
create(:issue,
- author: user,
- assignees: [user],
- project: project)
+ author: user,
+ assignees: [user],
+ project: project)
end
- it 'allows user to select unassigned', :js do
+ it "allows user to select unassigned", :js do
visit edit_project_issue_path(project, issue)
expect(page).to have_content "Assignee #{user.name}"
- first('.js-user-search').click
- click_link 'Unassigned'
+ first(".js-user-search").click
+ click_link "Unassigned"
- click_button 'Save changes'
+ click_button "Save changes"
- page.within('.assignee') do
- expect(page).to have_content 'No assignee - assign yourself'
+ page.within(".assignee") do
+ expect(page).to have_content "No assignee - assign yourself"
end
expect(issue.reload.assignees).to be_empty
end
end
- describe 'due date', :js do
- context 'on new form' do
+ describe "due date", :js do
+ context "on new form" do
before do
visit new_project_issue_path(project)
end
- it 'saves with due date' do
+ it "saves with due date" do
date = Date.today.at_beginning_of_month
- fill_in 'issue_title', with: 'bug 345'
- fill_in 'issue_description', with: 'bug description'
- find('#issuable-due-date').click
+ fill_in "issue_title", with: "bug 345"
+ fill_in "issue_description", with: "bug description"
+ find("#issuable-due-date").click
- page.within '.pika-single' do
+ page.within ".pika-single" do
click_button date.day
end
- expect(find('#issuable-due-date').value).to eq date.to_s
+ expect(find("#issuable-due-date").value).to eq date.to_s
- click_button 'Submit issue'
+ click_button "Submit issue"
- page.within '.issuable-sidebar' do
+ page.within ".issuable-sidebar" do
expect(page).to have_content date.to_s(:medium)
end
end
end
- context 'on edit form' do
+ context "on edit form" do
let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) }
before do
visit edit_project_issue_path(project, issue)
end
- it 'saves 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
+ expect(find("#issuable-due-date").value).to eq date.to_s
date = date.tomorrow
- fill_in 'issue_title', with: 'bug 345'
- fill_in 'issue_description', with: 'bug description'
- find('#issuable-due-date').click
+ fill_in "issue_title", with: "bug 345"
+ fill_in "issue_description", with: "bug description"
+ find("#issuable-due-date").click
- page.within '.pika-single' do
+ page.within ".pika-single" do
click_button date.day
end
- expect(find('#issuable-due-date').value).to eq date.to_s
+ expect(find("#issuable-due-date").value).to eq date.to_s
- click_button 'Save changes'
+ click_button "Save changes"
- page.within '.issuable-sidebar' do
+ page.within ".issuable-sidebar" do
expect(page).to have_content date.to_s(:medium)
end
end
- it 'warns about version conflict' do
+ it "warns about version conflict" do
issue.update(title: "New title")
- fill_in 'issue_title', with: 'bug 345'
- fill_in 'issue_description', with: 'bug description'
+ fill_in "issue_title", with: "bug 345"
+ fill_in "issue_description", with: "bug description"
- click_button 'Save changes'
+ click_button "Save changes"
- expect(page).to have_content 'Someone edited the issue the same time you did'
+ expect(page).to have_content "Someone edited the issue the same time you did"
end
end
end
- describe 'Issue info' do
- it 'links to current issue in breadcrubs' do
+ describe "Issue info" do
+ it "links to current issue in breadcrubs" do
issue = create(:issue, project: project)
visit project_issue_path(project, issue)
- expect(find('.breadcrumbs-sub-title a')[:href]).to end_with(issue_path(issue))
+ expect(find(".breadcrumbs-sub-title a")[:href]).to end_with(issue_path(issue))
end
- it 'excludes award_emoji from comment count' do
- issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar')
+ it "excludes award_emoji from comment count" do
+ issue = create(:issue, author: user, assignees: [user], project: project, title: "foobar")
create(:award_emoji, awardable: issue)
visit project_issues_path(project, assignee_id: user.id)
- expect(page).to have_content 'foobar'
- expect(page.all('.no-comments').first.text).to eq "0"
+ expect(page).to have_content "foobar"
+ expect(page.all(".no-comments").first.text).to eq "0"
end
end
- describe 'Filter issue' do
+ describe "Filter issue" do
before do
- %w(foobar barbaz gitlab).each do |title|
+ %w[foobar barbaz gitlab].each do |title|
create(:issue,
- author: user,
- assignees: [user],
- project: project,
- title: title)
+ author: user,
+ assignees: [user],
+ project: project,
+ title: title)
end
- @issue = Issue.find_by(title: 'foobar')
+ @issue = Issue.find_by(title: "foobar")
@issue.milestone = create(:milestone, project: project)
@issue.assignees = []
@issue.save
@@ -207,24 +207,24 @@ describe 'Issues' do
let(:issue) { @issue }
- it 'allows filtering by issues with no specified assignee' do
+ it "allows filtering by issues with no specified assignee" do
visit project_issues_path(project, assignee_id: IssuableFinder::NONE)
- expect(page).to have_content 'foobar'
- expect(page).not_to have_content 'barbaz'
- expect(page).not_to have_content 'gitlab'
+ expect(page).to have_content "foobar"
+ expect(page).not_to have_content "barbaz"
+ expect(page).not_to have_content "gitlab"
end
- it 'allows filtering by a specified assignee' do
+ it "allows filtering by a specified assignee" do
visit project_issues_path(project, assignee_id: user.id)
- expect(page).not_to have_content 'foobar'
- expect(page).to have_content 'barbaz'
- expect(page).to have_content 'gitlab'
+ expect(page).not_to have_content "foobar"
+ expect(page).to have_content "barbaz"
+ expect(page).to have_content "gitlab"
end
end
- describe 'filter issue' do
+ describe "filter issue" do
titles = %w[foo bar baz]
titles.each_with_index do |title, index|
let!(title.to_sym) do
@@ -233,145 +233,145 @@ describe 'Issues' do
created_at: Time.now - (index * 60))
end
end
- let(:newer_due_milestone) { create(:milestone, due_date: '2013-12-11') }
- let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') }
+ let(:newer_due_milestone) { create(:milestone, due_date: "2013-12-11") }
+ let(:later_due_milestone) { create(:milestone, due_date: "2013-12-12") }
- it 'sorts by newest' do
+ it "sorts by newest" do
visit project_issues_path(project, sort: sort_value_created_date)
- expect(first_issue).to include('foo')
- expect(last_issue).to include('baz')
+ expect(first_issue).to include("foo")
+ expect(last_issue).to include("baz")
end
- it 'sorts by most recently updated' do
+ it "sorts by most recently updated" do
baz.updated_at = Time.now + 100
baz.save
visit project_issues_path(project, sort: sort_value_recently_updated)
- expect(first_issue).to include('baz')
+ expect(first_issue).to include("baz")
end
- describe 'sorting by due date' do
+ describe "sorting by due date" do
before do
foo.update(due_date: 1.day.from_now)
bar.update(due_date: 6.days.from_now)
end
- it 'sorts by due date' do
+ it "sorts by due date" do
visit project_issues_path(project, sort: sort_value_due_date)
- expect(first_issue).to include('foo')
+ expect(first_issue).to include("foo")
end
- it 'sorts by due date by excluding nil due dates' do
+ it "sorts by due date by excluding nil due dates" do
bar.update(due_date: nil)
visit project_issues_path(project, sort: sort_value_due_date)
- expect(first_issue).to include('foo')
+ expect(first_issue).to include("foo")
end
- context 'with a filter on labels' do
+ context "with a filter on labels" do
let(:label) { create(:label, project: project) }
before do
create(:label_link, label: label, target: foo)
end
- it 'sorts by least recently due date by excluding nil due dates' do
+ it "sorts by least recently due date by excluding nil due dates" do
bar.update(due_date: nil)
visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later)
- expect(first_issue).to include('foo')
+ expect(first_issue).to include("foo")
end
end
end
- describe 'filtering by due date' do
+ describe "filtering by due date" do
before do
foo.update(due_date: 1.day.from_now)
bar.update(due_date: 6.days.from_now)
end
- it 'filters by none' do
+ it "filters by none" do
visit project_issues_path(project, due_date: Issue::NoDueDate.name)
- page.within '.issues-holder' do
- expect(page).not_to have_content('foo')
- expect(page).not_to have_content('bar')
- expect(page).to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).not_to have_content("foo")
+ expect(page).not_to have_content("bar")
+ expect(page).to have_content("baz")
end
end
- it 'filters by any' do
+ it "filters by any" do
visit project_issues_path(project, due_date: Issue::AnyDueDate.name)
- page.within '.issues-holder' do
- expect(page).to have_content('foo')
- expect(page).to have_content('bar')
- expect(page).to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).to have_content("foo")
+ expect(page).to have_content("bar")
+ expect(page).to have_content("baz")
end
end
- it 'filters by due this week' do
+ it "filters by due this week" do
foo.update(due_date: Date.today.beginning_of_week + 2.days)
bar.update(due_date: Date.today.end_of_week)
baz.update(due_date: Date.today - 8.days)
visit project_issues_path(project, due_date: Issue::DueThisWeek.name)
- page.within '.issues-holder' do
- expect(page).to have_content('foo')
- expect(page).to have_content('bar')
- expect(page).not_to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).to have_content("foo")
+ expect(page).to have_content("bar")
+ expect(page).not_to have_content("baz")
end
end
- it 'filters by due this month' do
+ it "filters by due this month" do
foo.update(due_date: Date.today.beginning_of_month + 2.days)
bar.update(due_date: Date.today.end_of_month)
baz.update(due_date: Date.today - 50.days)
visit project_issues_path(project, due_date: Issue::DueThisMonth.name)
- page.within '.issues-holder' do
- expect(page).to have_content('foo')
- expect(page).to have_content('bar')
- expect(page).not_to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).to have_content("foo")
+ expect(page).to have_content("bar")
+ expect(page).not_to have_content("baz")
end
end
- it 'filters by overdue' do
+ it "filters by overdue" do
foo.update(due_date: Date.today + 2.days)
bar.update(due_date: Date.today + 20.days)
baz.update(due_date: Date.yesterday)
visit project_issues_path(project, due_date: Issue::Overdue.name)
- page.within '.issues-holder' do
- expect(page).not_to have_content('foo')
- expect(page).not_to have_content('bar')
- expect(page).to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).not_to have_content("foo")
+ expect(page).not_to have_content("bar")
+ expect(page).to have_content("baz")
end
end
- it 'filters by due next month and previous two weeks' do
+ it "filters by due next month and previous two weeks" do
foo.update(due_date: Date.today - 4.weeks)
bar.update(due_date: (Date.today + 2.months).beginning_of_month)
baz.update(due_date: Date.yesterday)
visit project_issues_path(project, due_date: Issue::DueNextMonthAndPreviousTwoWeeks.name)
- page.within '.issues-holder' do
- expect(page).not_to have_content('foo')
- expect(page).not_to have_content('bar')
- expect(page).to have_content('baz')
+ page.within ".issues-holder" do
+ expect(page).not_to have_content("foo")
+ expect(page).not_to have_content("bar")
+ expect(page).to have_content("baz")
end
end
end
- describe 'sorting by milestone' do
+ describe "sorting by milestone" do
before do
foo.milestone = newer_due_milestone
foo.save
@@ -379,15 +379,15 @@ describe 'Issues' do
bar.save
end
- it 'sorts by milestone' do
+ it "sorts by milestone" do
visit project_issues_path(project, sort: sort_value_milestone)
- expect(first_issue).to include('foo')
- expect(last_issue).to include('baz')
+ expect(first_issue).to include("foo")
+ expect(last_issue).to include("baz")
end
end
- describe 'combine filter and sort' do
+ describe "combine filter and sort" do
let(:user2) { create(:user) }
before do
@@ -397,17 +397,17 @@ describe 'Issues' do
bar.save
end
- it 'sorts with a filter applied' do
+ it "sorts with a filter applied" do
visit project_issues_path(project, sort: sort_value_created_date, assignee_id: user2.id)
- expect(first_issue).to include('foo')
- expect(last_issue).to include('bar')
- expect(page).not_to have_content('baz')
+ expect(first_issue).to include("foo")
+ expect(last_issue).to include("bar")
+ expect(page).not_to have_content("baz")
end
end
end
- describe 'when I want to reset my incoming email token' do
+ describe "when I want to reset my incoming email token" do
let(:project1) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, project: project1) }
@@ -417,23 +417,23 @@ describe 'Issues' do
visit namespace_project_issues_path(user.namespace, project1)
end
- it 'changes incoming email address token', :js do
- find('.issuable-email-modal-btn').click
- previous_token = find('input#issuable_email').value
- find('.incoming-email-token-reset').click
+ it "changes incoming email address token", :js do
+ find(".issuable-email-modal-btn").click
+ previous_token = find("input#issuable_email").value
+ find(".incoming-email-token-reset").click
wait_for_requests
- expect(page).to have_no_field('issuable_email', with: previous_token)
- new_token = project1.new_issuable_address(user.reload, 'issue')
+ expect(page).to have_no_field("issuable_email", with: previous_token)
+ new_token = project1.new_issuable_address(user.reload, "issue")
expect(page).to have_field(
- 'issuable_email',
+ "issuable_email",
with: new_token
)
end
end
- describe 'update labels from issue#show', :js do
+ describe "update labels from issue#show", :js do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
let!(:label) { create(:label, project: project) }
@@ -441,31 +441,31 @@ describe 'Issues' do
visit project_issue_path(project, issue)
end
- it 'will not send ajax request when no data is changed' do
- page.within '.labels' do
- click_link 'Edit'
+ it "will not send ajax request when no data is changed" do
+ page.within ".labels" do
+ click_link "Edit"
- find('.dropdown-menu-close', match: :first).click
+ find(".dropdown-menu-close", match: :first).click
- expect(page).not_to have_selector('.block-loading')
+ expect(page).not_to have_selector(".block-loading")
end
end
end
- describe 'update assignee from issue#show' do
+ describe "update assignee from issue#show" do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
- context 'by authorized user' do
- it 'allows user to select unassigned', :js do
+ context "by authorized user" do
+ it "allows user to select unassigned", :js do
visit project_issue_path(project, issue)
- page.within('.assignee') do
- expect(page).to have_content "#{user.name}"
+ page.within(".assignee") do
+ expect(page).to have_content user.name.to_s
- click_link 'Edit'
- click_link 'Unassigned'
- first('.title').click
- expect(page).to have_content 'No assignee'
+ click_link "Edit"
+ click_link "Unassigned"
+ first(".title").click
+ expect(page).to have_content "No assignee"
end
# wait_for_requests does not work with vue-resource at the moment
@@ -474,57 +474,57 @@ describe 'Issues' do
expect(issue.reload.assignees).to be_empty
end
- it 'allows user to select an assignee', :js do
+ it "allows user to select an assignee", :js do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
- page.within('.assignee') do
+ page.within(".assignee") do
expect(page).to have_content "No assignee"
end
- page.within '.assignee' do
- click_link 'Edit'
+ page.within ".assignee" do
+ click_link "Edit"
end
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
click_link user.name
end
- page.within('.assignee') do
+ page.within(".assignee") do
expect(page).to have_content user.name
end
end
- it 'allows user to unselect themselves', :js do
+ it "allows user to unselect themselves", :js do
issue2 = create(:issue, project: project, author: user)
visit project_issue_path(project, issue2)
- page.within '.assignee' do
- click_link 'Edit'
+ page.within ".assignee" do
+ click_link "Edit"
click_link user.name
- page.within '.value .author' do
+ page.within ".value .author" do
expect(page).to have_content user.name
end
- click_link 'Edit'
+ click_link "Edit"
click_link user.name
- page.within '.value .assign-yourself' do
+ page.within ".value .assign-yourself" do
expect(page).to have_content "No assignee"
end
end
end
end
- context 'by unauthorized user' do
+ context "by unauthorized user" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
- it 'shows assignee text', :js do
+ it "shows assignee text", :js do
sign_out(:user)
sign_in(guest)
@@ -534,51 +534,51 @@ describe 'Issues' do
end
end
- describe 'update milestone from issue#show' do
+ describe "update milestone from issue#show" do
let!(:issue) { create(:issue, project: project, author: user) }
let!(:milestone) { create(:milestone, project: project) }
- context 'by authorized user' do
- it 'allows user to select unassigned', :js do
+ context "by authorized user" do
+ it "allows user to select unassigned", :js do
visit project_issue_path(project, issue)
- page.within('.milestone') do
+ page.within(".milestone") do
expect(page).to have_content "None"
end
- find('.block.milestone .edit-link').click
+ find(".block.milestone .edit-link").click
sleep 2 # wait for ajax stuff to complete
- first('.dropdown-content li').click
+ first(".dropdown-content li").click
sleep 2
- page.within('.milestone') do
- expect(page).to have_content 'None'
+ page.within(".milestone") do
+ expect(page).to have_content "None"
end
expect(issue.reload.milestone).to be_nil
end
- it 'allows user to de-select milestone', :js do
+ it "allows user to de-select milestone", :js do
visit project_issue_path(project, issue)
- page.within('.milestone') do
- click_link 'Edit'
+ page.within(".milestone") do
+ click_link "Edit"
click_link milestone.title
- page.within '.value' do
+ page.within ".value" do
expect(page).to have_content milestone.title
end
- click_link 'Edit'
+ click_link "Edit"
click_link milestone.title
- page.within '.value' do
- expect(page).to have_content 'None'
+ page.within ".value" do
+ expect(page).to have_content "None"
end
end
end
end
- context 'by unauthorized user' do
+ context "by unauthorized user" do
let(:guest) { create(:user) }
before do
@@ -587,7 +587,7 @@ describe 'Issues' do
issue.save
end
- it 'shows milestone text', :js do
+ it "shows milestone text", :js do
sign_out(:user)
sign_in(guest)
@@ -597,19 +597,19 @@ describe 'Issues' do
end
end
- describe 'new issue' do
+ describe "new issue" do
let!(:issue) { create(:issue, project: project) }
- context 'by unauthenticated user' do
+ context "by unauthenticated user" do
before do
sign_out(:user)
end
- it 'redirects to signin then back to new issue after signin' do
+ it "redirects to signin then back to new issue after signin" do
visit project_issues_path(project)
- page.within '.nav-controls' do
- click_link 'New issue'
+ page.within ".nav-controls" do
+ click_link "New issue"
end
expect(current_path).to eq new_user_session_path
@@ -620,84 +620,85 @@ describe 'Issues' do
end
end
- it 'clears local storage after creating a new issue', :js do
+ it "clears local storage after creating a new issue", :js do
2.times do
visit new_project_issue_path(project)
wait_for_requests
- expect(page).to have_field('Title', with: '')
+ expect(page).to have_field("Title", with: "")
- fill_in 'issue_title', with: 'bug 345'
- fill_in 'issue_description', with: 'bug description'
+ fill_in "issue_title", with: "bug 345"
+ fill_in "issue_description", with: "bug description"
- click_button 'Submit issue'
+ click_button "Submit issue"
end
end
- context 'dropzone upload file', :js do
+ context "dropzone upload file", :js do
before do
visit new_project_issue_path(project)
end
- it 'uploads file when dragging into textarea' do
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ it "uploads file when dragging into textarea" do
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
- expect(page.find_field("issue_description").value).to have_content 'banana_sample'
+ expect(page.find_field("issue_description").value).to have_content "banana_sample"
end
it "doesn't add double newline to end of a single attachment markdown" do
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
expect(page.find_field("issue_description").value).not_to match /\n\n$/
end
it "cancels a file upload correctly" do
slow_requests do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")], 0, false)
- click_button 'Cancel'
+ click_button "Cancel"
end
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_button('Cancel')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_button("Cancel")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
end
- context 'form filled by URL parameters' do
+ context "form filled by URL parameters" do
let(:project) { create(:project, :public, :repository) }
before do
project.repository.create_file(
user,
- '.gitlab/issue_templates/bug.md',
+ ".gitlab/issue_templates/bug.md",
'this is a test "bug" template',
- message: 'added issue template',
- branch_name: 'master')
+ message: "added issue template",
+ branch_name: "master"
+ )
- visit new_project_issue_path(project, issuable_template: 'bug')
+ visit new_project_issue_path(project, issuable_template: "bug")
end
- it 'fills in template' do
- expect(find('.js-issuable-selector .dropdown-toggle-text')).to have_content('bug')
+ it "fills in template" do
+ expect(find(".js-issuable-selector .dropdown-toggle-text")).to have_content("bug")
end
end
- context 'suggestions', :js do
- it 'displays list of related issues' do
- create(:issue, project: project, title: 'test issue')
+ context "suggestions", :js do
+ it "displays list of related issues" do
+ create(:issue, project: project, title: "test issue")
visit new_project_issue_path(project)
- fill_in 'issue_title', with: issue.title
+ fill_in "issue_title", with: issue.title
- expect(page).to have_selector('.suggestion-item', count: 1)
+ expect(page).to have_selector(".suggestion-item", count: 1)
end
end
end
- describe 'new issue by email' do
- shared_examples 'show the email in the modal' do
+ describe "new issue by email" do
+ shared_examples "show the email in the modal" do
let(:issue) { create(:issue, project: project) }
before do
@@ -705,77 +706,77 @@ describe 'Issues' do
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
visit project_issues_path(project)
- click_button('Email a new issue')
+ click_button("Email a new issue")
end
- it 'click the button to show modal for the new email' do
- page.within '#issuable-email-modal' do
- email = project.new_issuable_address(user, 'issue')
+ it "click the button to show modal for the new email" do
+ page.within "#issuable-email-modal" do
+ email = project.new_issuable_address(user, "issue")
expect(page).to have_selector("input[value='#{email}']")
end
end
end
- context 'with existing issues' do
+ context "with existing issues" do
let!(:issue) { create(:issue, project: project, author: user) }
- it_behaves_like 'show the email in the modal'
+ it_behaves_like "show the email in the modal"
end
- context 'without existing issues' do
- it_behaves_like 'show the email in the modal'
+ context "without existing issues" do
+ it_behaves_like "show the email in the modal"
end
end
- describe 'due date' do
- context 'update due on issue#show', :js do
+ describe "due date" do
+ context "update due on issue#show", :js do
let(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
before do
visit project_issue_path(project, issue)
end
- it 'adds due date to issue' do
+ it "adds due date to issue" do
date = Date.today.at_beginning_of_month + 2.days
- page.within '.due_date' do
- click_link 'Edit'
+ page.within ".due_date" do
+ click_link "Edit"
- page.within '.pika-single' do
+ page.within ".pika-single" do
click_button date.day
end
wait_for_requests
- expect(find('.value').text).to have_content date.strftime('%b %-d, %Y')
+ expect(find(".value").text).to have_content date.strftime("%b %-d, %Y")
end
end
- it 'removes due date from issue' do
+ it "removes due date from issue" do
date = Date.today.at_beginning_of_month + 2.days
- page.within '.due_date' do
- click_link 'Edit'
+ page.within ".due_date" do
+ click_link "Edit"
- page.within '.pika-single' do
+ page.within ".pika-single" do
click_button date.day
end
wait_for_requests
- expect(page).to have_no_content 'No due date'
+ expect(page).to have_no_content "No due date"
- click_link 'remove due date'
- expect(page).to have_content 'No due date'
+ click_link "remove due date"
+ expect(page).to have_content "No due date"
end
end
end
end
- describe 'title issue#show', :js do
- it 'updates the title', :js do
- issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title')
+ describe "title issue#show", :js do
+ it "updates the title", :js do
+ issue = create(:issue, author: user, assignees: [user], project: project, title: "new title")
visit project_issue_path(project, issue)
@@ -788,28 +789,28 @@ describe 'Issues' do
end
end
- describe 'confidential issue#show', :js do
- it 'shows confidential sibebar information as confidential and can be turned off' do
+ describe "confidential issue#show", :js do
+ it "shows confidential sibebar information as confidential and can be turned off" do
issue = create(:issue, :confidential, project: project)
visit project_issue_path(project, issue)
- expect(page).to have_css('.issuable-note-warning')
- expect(find('.issuable-sidebar-item.confidentiality')).to have_css('.is-active')
- expect(find('.issuable-sidebar-item.confidentiality')).not_to have_css('.not-active')
+ expect(page).to have_css(".issuable-note-warning")
+ expect(find(".issuable-sidebar-item.confidentiality")).to have_css(".is-active")
+ expect(find(".issuable-sidebar-item.confidentiality")).not_to have_css(".not-active")
- find('.confidential-edit').click
- expect(page).to have_css('.sidebar-item-warning-message')
+ find(".confidential-edit").click
+ expect(page).to have_css(".sidebar-item-warning-message")
- within('.sidebar-item-warning-message') do
- find('.btn-close').click
+ within(".sidebar-item-warning-message") do
+ find(".btn-close").click
end
wait_for_requests
visit project_issue_path(project, issue)
- expect(page).not_to have_css('.is-active')
+ expect(page).not_to have_css(".is-active")
end
end
end
diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb
index 7c31e67a7fa..075cb4f9409 100644
--- a/spec/features/labels_hierarchy_spec.rb
+++ b/spec/features/labels_hierarchy_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Labels Hierarchy', :js, :nested_groups do
+describe "Labels Hierarchy", :js, :nested_groups do
include FilteredSearchHelpers
let!(:user) { create(:user) }
@@ -9,10 +9,10 @@ describe 'Labels Hierarchy', :js, :nested_groups do
let!(:child) { create(:group, parent: parent) }
let!(:project_1) { create(:project, namespace: parent) }
- let!(:grandparent_group_label) { create(:group_label, group: grandparent, title: 'Label_1') }
- let!(:parent_group_label) { create(:group_label, group: parent, title: 'Label_2') }
- let!(:child_group_label) { create(:group_label, group: child, title: 'Label_3') }
- let!(:project_label_1) { create(:label, project: project_1, title: 'Label_4') }
+ let!(:grandparent_group_label) { create(:group_label, group: grandparent, title: "Label_1") }
+ let!(:parent_group_label) { create(:group_label, group: parent, title: "Label_2") }
+ let!(:child_group_label) { create(:group_label, group: child, title: "Label_3") }
+ let!(:project_label_1) { create(:label, project: project_1, title: "Label_4") }
before do
grandparent.add_owner(user)
@@ -20,165 +20,165 @@ describe 'Labels Hierarchy', :js, :nested_groups do
sign_in(user)
end
- shared_examples 'assigning labels from sidebar' do
- it 'can assign all ancestors labels' do
+ shared_examples "assigning labels from sidebar" do
+ it "can assign all ancestors labels" do
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
- page.within('.block.labels') do
- find('.edit-link').click
+ page.within(".block.labels") do
+ find(".edit-link").click
end
wait_for_requests
- find('a.label-item', text: label.title).click
- find('.dropdown-menu-close-icon').click
+ find("a.label-item", text: label.title).click
+ find(".dropdown-menu-close-icon").click
wait_for_requests
- expect(page).to have_selector('.badge', text: label.title)
+ expect(page).to have_selector(".badge", text: label.title)
end
end
- it 'does not find child group labels on dropdown' do
- page.within('.block.labels') do
- find('.edit-link').click
+ it "does not find child group labels on dropdown" do
+ page.within(".block.labels") do
+ find(".edit-link").click
end
wait_for_requests
- expect(page).not_to have_selector('.badge', text: child_group_label.title)
+ expect(page).not_to have_selector(".badge", text: child_group_label.title)
end
end
- shared_examples 'filtering by ancestor labels for projects' do |board = false|
- it 'filters by ancestor labels' do
+ shared_examples "filtering by ancestor labels for projects" do |board = false|
+ it "filters by ancestor labels" do
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
select_label_on_dropdown(label.title)
wait_for_requests
if board
- expect(page).to have_selector('.board-card-title') do |card|
- expect(card).to have_selector('a', text: labeled_issue.title)
+ expect(page).to have_selector(".board-card-title") do |card|
+ expect(card).to have_selector("a", text: labeled_issue.title)
end
else
expect_issues_list_count(1)
- expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
+ expect(page).to have_selector("span.issue-title-text", text: labeled_issue.title)
end
end
end
- it 'does not filter by descendant group labels' do
+ it "does not filter by descendant group labels" do
filtered_search.set("label:")
wait_for_requests
- expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
+ expect(page).not_to have_selector(".btn-link", text: child_group_label.title)
end
end
- shared_examples 'filtering by ancestor labels for groups' do |board = false|
+ shared_examples "filtering by ancestor labels for groups" do |board = false|
let(:project_2) { create(:project, namespace: parent) }
- let!(:project_label_2) { create(:label, project: project_2, title: 'Label_4') }
+ let!(:project_label_2) { create(:label, project: project_2, title: "Label_4") }
let(:project_3) { create(:project, namespace: child) }
- let!(:group_label_3) { create(:group_label, group: child, title: 'Label_5') }
- let!(:project_label_3) { create(:label, project: project_3, title: 'Label_6') }
+ let!(:group_label_3) { create(:group_label, group: child, title: "Label_5") }
+ let!(:project_label_3) { create(:label, project: project_3, title: "Label_6") }
let!(:labeled_issue_2) { create(:labeled_issue, project: project_2, labels: [grandparent_group_label, parent_group_label, project_label_2]) }
let!(:labeled_issue_3) { create(:labeled_issue, project: project_3, labels: [grandparent_group_label, parent_group_label, group_label_3]) }
let!(:issue_2) { create(:issue, project: project_2) }
- it 'filters by ancestors and current group labels' do
+ it "filters by ancestors and current group labels" do
[grandparent_group_label, parent_group_label].each do |label|
select_label_on_dropdown(label.title)
wait_for_requests
if board
- expect(page).to have_selector('.board-card-title') do |card|
- expect(card).to have_selector('a', text: labeled_issue.title)
+ expect(page).to have_selector(".board-card-title") do |card|
+ expect(card).to have_selector("a", text: labeled_issue.title)
end
- expect(page).to have_selector('.board-card-title') do |card|
- expect(card).to have_selector('a', text: labeled_issue_2.title)
+ expect(page).to have_selector(".board-card-title") do |card|
+ expect(card).to have_selector("a", text: labeled_issue_2.title)
end
else
expect_issues_list_count(3)
- expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title)
- expect(page).to have_selector('span.issue-title-text', text: labeled_issue_2.title)
- expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
+ expect(page).to have_selector("span.issue-title-text", text: labeled_issue.title)
+ expect(page).to have_selector("span.issue-title-text", text: labeled_issue_2.title)
+ expect(page).to have_selector("span.issue-title-text", text: labeled_issue_3.title)
end
end
end
- it 'filters by descendant group labels' do
+ it "filters by descendant group labels" do
wait_for_requests
select_label_on_dropdown(group_label_3.title)
if board
- expect(page).to have_selector('.board-card-title') do |card|
- expect(card).not_to have_selector('a', text: labeled_issue_2.title)
+ expect(page).to have_selector(".board-card-title") do |card|
+ expect(card).not_to have_selector("a", text: labeled_issue_2.title)
end
- expect(page).to have_selector('.board-card-title') do |card|
- expect(card).to have_selector('a', text: labeled_issue_3.title)
+ expect(page).to have_selector(".board-card-title") do |card|
+ expect(card).to have_selector("a", text: labeled_issue_3.title)
end
else
expect_issues_list_count(1)
- expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title)
+ expect(page).to have_selector("span.issue-title-text", text: labeled_issue_3.title)
end
end
- it 'does not filter by descendant group project labels' do
+ it "does not filter by descendant group project labels" do
filtered_search.set("label:")
wait_for_requests
- expect(page).not_to have_selector('.btn-link', text: project_label_3.title)
+ expect(page).not_to have_selector(".btn-link", text: project_label_3.title)
end
end
- context 'when creating new issuable' do
+ context "when creating new issuable" do
before do
visit new_project_issue_path(project_1)
end
- it 'should be able to assign ancestor group labels' do
- fill_in 'issue_title', with: 'new created issue'
- fill_in 'issue_description', with: 'new issue description'
+ it "should be able to assign ancestor group labels" do
+ fill_in "issue_title", with: "new created issue"
+ fill_in "issue_description", with: "new issue description"
find(".js-label-select").click
wait_for_requests
- find('a.label-item', text: grandparent_group_label.title).click
- find('a.label-item', text: parent_group_label.title).click
- find('a.label-item', text: project_label_1.title).click
+ find("a.label-item", text: grandparent_group_label.title).click
+ find("a.label-item", text: parent_group_label.title).click
+ find("a.label-item", text: project_label_1.title).click
- find('.btn-success').click
+ find(".btn-success").click
- expect(page.find('.issue-details h2.title')).to have_content('new created issue')
- expect(page).to have_selector('span.badge', text: grandparent_group_label.title)
- expect(page).to have_selector('span.badge', text: parent_group_label.title)
- expect(page).to have_selector('span.badge', text: project_label_1.title)
+ expect(page.find(".issue-details h2.title")).to have_content("new created issue")
+ expect(page).to have_selector("span.badge", text: grandparent_group_label.title)
+ expect(page).to have_selector("span.badge", text: parent_group_label.title)
+ expect(page).to have_selector("span.badge", text: project_label_1.title)
end
end
- context 'issuable sidebar' do
+ context "issuable sidebar" do
let!(:issue) { create(:issue, project: project_1) }
- context 'on issue sidebar' do
+ context "on issue sidebar" do
before do
project_1.add_developer(user)
visit project_issue_path(project_1, issue)
end
- it_behaves_like 'assigning labels from sidebar'
+ it_behaves_like "assigning labels from sidebar"
end
- context 'on project board issue sidebar' do
+ context "on project board issue sidebar" do
let(:board) { create(:board, project: project_1) }
before do
@@ -188,13 +188,13 @@ describe 'Labels Hierarchy', :js, :nested_groups do
wait_for_requests
- find('.board-card').click
+ find(".board-card").click
end
- it_behaves_like 'assigning labels from sidebar'
+ it_behaves_like "assigning labels from sidebar"
end
- context 'on group board issue sidebar' do
+ context "on group board issue sidebar" do
let(:board) { create(:board, group: parent) }
before do
@@ -204,44 +204,44 @@ describe 'Labels Hierarchy', :js, :nested_groups do
wait_for_requests
- find('.board-card').click
+ find(".board-card").click
end
- it_behaves_like 'assigning labels from sidebar'
+ it_behaves_like "assigning labels from sidebar"
end
end
- context 'issuable filtering' do
+ context "issuable filtering" do
let!(:labeled_issue) { create(:labeled_issue, project: project_1, labels: [grandparent_group_label, parent_group_label, project_label_1]) }
let!(:issue) { create(:issue, project: project_1) }
- context 'on project issuable list' do
+ context "on project issuable list" do
before do
project_1.add_developer(user)
visit project_issues_path(project_1)
end
- it_behaves_like 'filtering by ancestor labels for projects'
+ it_behaves_like "filtering by ancestor labels for projects"
- it 'does not filter by descendant group labels' do
+ it "does not filter by descendant group labels" do
filtered_search.set("label:")
wait_for_requests
- expect(page).not_to have_selector('.btn-link', text: child_group_label.title)
+ expect(page).not_to have_selector(".btn-link", text: child_group_label.title)
end
end
- context 'on group issuable list' do
+ context "on group issuable list" do
before do
visit issues_group_path(parent)
end
- it_behaves_like 'filtering by ancestor labels for groups'
+ it_behaves_like "filtering by ancestor labels for groups"
end
- context 'on project boards filter' do
+ context "on project boards filter" do
let(:board) { create(:board, project: project_1) }
before do
@@ -250,10 +250,10 @@ describe 'Labels Hierarchy', :js, :nested_groups do
visit project_board_path(project_1, board)
end
- it_behaves_like 'filtering by ancestor labels for projects', true
+ it_behaves_like "filtering by ancestor labels for projects", true
end
- context 'on group boards filter' do
+ context "on group boards filter" do
let(:board) { create(:board, group: parent) }
before do
@@ -262,57 +262,57 @@ describe 'Labels Hierarchy', :js, :nested_groups do
visit group_board_path(parent, board)
end
- it_behaves_like 'filtering by ancestor labels for groups', true
+ it_behaves_like "filtering by ancestor labels for groups", true
end
end
- context 'creating boards lists' do
- context 'on project boards' do
+ context "creating boards lists" do
+ context "on project boards" do
let(:board) { create(:board, project: project_1) }
before do
project_1.add_developer(user)
visit project_board_path(project_1, board)
- find('.js-new-board-list').click
+ find(".js-new-board-list").click
wait_for_requests
end
- it 'creates lists from all ancestor labels' do
+ it "creates lists from all ancestor labels" do
[grandparent_group_label, parent_group_label, project_label_1].each do |label|
- find('a', text: label.title).click
+ find("a", text: label.title).click
end
wait_for_requests
- expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
- expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
- expect(page).to have_selector('.board-title-text', text: project_label_1.title)
+ expect(page).to have_selector(".board-title-text", text: grandparent_group_label.title)
+ expect(page).to have_selector(".board-title-text", text: parent_group_label.title)
+ expect(page).to have_selector(".board-title-text", text: project_label_1.title)
end
end
- context 'on group boards' do
+ context "on group boards" do
let(:board) { create(:board, group: parent) }
before do
parent.add_developer(user)
visit group_board_path(parent, board)
- find('.js-new-board-list').click
+ find(".js-new-board-list").click
wait_for_requests
end
- it 'creates lists from all ancestor group labels' do
+ it "creates lists from all ancestor group labels" do
[grandparent_group_label, parent_group_label].each do |label|
- find('a', text: label.title).click
+ find("a", text: label.title).click
end
wait_for_requests
- expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title)
- expect(page).to have_selector('.board-title-text', text: parent_group_label.title)
+ expect(page).to have_selector(".board-title-text", text: grandparent_group_label.title)
+ expect(page).to have_selector(".board-title-text", text: parent_group_label.title)
end
- it 'does not create lists from descendant groups' do
- expect(page).not_to have_selector('a', text: child_group_label.title)
+ it "does not create lists from descendant groups" do
+ expect(page).not_to have_selector("a", text: child_group_label.title)
end
end
end
diff --git a/spec/features/markdown/copy_as_gfm_spec.rb b/spec/features/markdown/copy_as_gfm_spec.rb
index 60ddb02da2c..4a881a203bd 100644
--- a/spec/features/markdown/copy_as_gfm_spec.rb
+++ b/spec/features/markdown/copy_as_gfm_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Copy as GFM', :js do
+describe "Copy as GFM", :js do
include MarkupHelper
include RepoHelpers
include ActionView::Helpers::JavaScriptHelper
@@ -9,7 +9,7 @@ describe 'Copy as GFM', :js do
sign_in(create(:admin))
end
- describe 'Copying rendered GFM' do
+ describe "Copying rendered GFM" do
before do
@feat = MarkdownFeature.new
@@ -25,16 +25,14 @@ describe 'Copy as GFM', :js do
# by verifying (`html_to_gfm(gfm_to_html(gfm)) == gfm`) for a number of examples of GFM for every filter, using the `verify` helper.
# These are all in a single `it` for performance reasons.
- it 'works', :aggregate_failures do
+ it "works", :aggregate_failures do
verify(
- 'nesting',
-
- '> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**'
+ "nesting",
+ "> 1. [x] **[$`2 + 2`$ {-=-}{+=+} 2^2 ~~:thumbsup:~~](http://google.com)**"
)
verify(
- 'a real world example from the gitlab-ce README',
-
+ "a real world example from the gitlab-ce README",
<<~GFM
# GitLab
@@ -68,8 +66,8 @@ describe 'Copy as GFM', :js do
GFM
)
- aggregate_failures('an accidentally selected empty element') do
- gfm = '# Heading1'
+ aggregate_failures("an accidentally selected empty element") do
+ gfm = "# Heading1"
html = <<~HTML
<h1>Heading1</h1>
@@ -85,8 +83,8 @@ describe 'Copy as GFM', :js do
expect(output_gfm.strip).to eq(gfm.strip)
end
- aggregate_failures('an accidentally selected other element') do
- gfm = 'Test comment with **Markdown!**'
+ aggregate_failures("an accidentally selected other element") do
+ gfm = "Test comment with **Markdown!**"
html = <<~HTML
<li class="note">
@@ -105,21 +103,18 @@ describe 'Copy as GFM', :js do
end
verify(
- 'InlineDiffFilter',
-
- '{-Deleted text-}',
- '{+Added text+}'
+ "InlineDiffFilter",
+ "{-Deleted text-}",
+ "{+Added text+}"
)
verify(
- 'TaskListFilter',
-
+ "TaskListFilter",
<<~GFM,
* [ ] Unchecked task
* [x] Checked task
GFM
-
<<~GFM
1. [ ] Unchecked ordered task
@@ -128,8 +123,7 @@ describe 'Copy as GFM', :js do
)
verify(
- 'ReferenceFilter',
-
+ "ReferenceFilter",
# issue reference
@feat.issue.to_reference,
# full issue reference
@@ -137,22 +131,20 @@ describe 'Copy as GFM', :js do
# issue URL
project_issue_url(@project, @feat.issue),
# issue URL with note anchor
- project_issue_url(@project, @feat.issue, anchor: 'note_123'),
+ project_issue_url(@project, @feat.issue, anchor: "note_123"),
# issue link
"[Issue](#{project_issue_url(@project, @feat.issue)})",
# issue link with note anchor
- "[Issue](#{project_issue_url(@project, @feat.issue, anchor: 'note_123')})"
+ "[Issue](#{project_issue_url(@project, @feat.issue, anchor: "note_123")})"
)
verify(
- 'AutolinkFilter',
-
- 'https://example.com'
+ "AutolinkFilter",
+ "https://example.com"
)
verify(
- 'TableOfContentsFilter',
-
+ "TableOfContentsFilter",
<<~GFM,
[[_TOC_]]
@@ -160,34 +152,28 @@ describe 'Copy as GFM', :js do
## Heading 2
GFM
-
pipeline: :wiki,
project_wiki: @project.wiki
)
verify(
- 'EmojiFilter',
-
- ':thumbsup:'
+ "EmojiFilter",
+ ":thumbsup:"
)
verify(
- 'ImageLinkFilter',
-
- '![Image](https://example.com/image.png)'
+ "ImageLinkFilter",
+ "![Image](https://example.com/image.png)"
)
verify(
- 'VideoLinkFilter',
-
- '![Video](https://example.com/video.mp4)'
+ "VideoLinkFilter",
+ "![Video](https://example.com/video.mp4)"
)
verify(
- 'MathFilter: math as converted from GFM to HTML',
-
+ "MathFilter: math as converted from GFM to HTML",
'$`c = \pm\sqrt{a^2 + b^2}`$',
-
# math block
<<~GFM
```math
@@ -196,7 +182,7 @@ describe 'Copy as GFM', :js do
GFM
)
- aggregate_failures('MathFilter: math as transformed from HTML to KaTeX') do
+ aggregate_failures("MathFilter: math as transformed from HTML to KaTeX") do
gfm = '$`c = \pm\sqrt{a^2 + b^2}`$'
html = <<~HTML
@@ -308,8 +294,7 @@ describe 'Copy as GFM', :js do
end
verify(
- 'MermaidFilter: mermaid as converted from GFM to HTML',
-
+ "MermaidFilter: mermaid as converted from GFM to HTML",
<<~GFM
```mermaid
graph TD;
@@ -318,7 +303,7 @@ describe 'Copy as GFM', :js do
GFM
)
- aggregate_failures('MermaidFilter: mermaid as transformed from HTML to SVG') do
+ aggregate_failures("MermaidFilter: mermaid as transformed from HTML to SVG") do
gfm = <<~GFM
```mermaid
graph TD;
@@ -403,8 +388,7 @@ describe 'Copy as GFM', :js do
end
verify(
- 'SuggestionFilter: suggestion as converted from GFM to HTML',
-
+ "SuggestionFilter: suggestion as converted from GFM to HTML",
<<~GFM
```suggestion
New
@@ -413,7 +397,7 @@ describe 'Copy as GFM', :js do
GFM
)
- aggregate_failures('SuggestionFilter: suggestion as transformed from HTML to Vue component') do
+ aggregate_failures("SuggestionFilter: suggestion as transformed from HTML to Vue component") do
gfm = <<~GFM
```suggestion
New
@@ -465,50 +449,38 @@ describe 'Copy as GFM', :js do
end
verify(
- 'SanitizationFilter',
-
+ "SanitizationFilter",
<<~GFM
- <sub>sub</sub>
-
- <dl>
- <dt>dt</dt>
- <dt>dt</dt>
- <dd>dd</dd>
- <dd>dd</dd>
-
- <dt>dt</dt>
- <dt>dt</dt>
- <dd>dd</dd>
- <dd>dd</dd>
- </dl>
-
- <kbd>kbd</kbd>
-
- <q>q</q>
-
- <samp>samp</samp>
-
- <var>var</var>
-
- <abbr title="HyperText &quot;Markup&quot; Language">HTML</abbr>
-
- <details>
- <summary>summary></summary>
-
- details
- </details>
+ <sub>sub</sub>
+ <dl>
+ <dt>dt</dt>
+ <dt>dt</dt>
+ <dd>dd</dd>
+ <dd>dd</dd>
+ <dt>dt</dt>
+ <dt>dt</dt>
+ <dd>dd</dd>
+ <dd>dd</dd>
+ </dl>
+ <kbd>kbd</kbd>
+ <q>q</q>
+ <samp>samp</samp>
+ <var>var</var>
+ <abbr title="HyperText &quot;Markup&quot; Language">HTML</abbr>
+ <details>
+ <summary>summary></summary>
+ details
+ </details>
GFM
)
verify(
- 'SanitizationFilter',
-
+ "SanitizationFilter",
<<~GFM,
```
Plain text
```
GFM
-
<<~GFM,
```ruby
def foo
@@ -516,7 +488,6 @@ describe 'Copy as GFM', :js do
end
```
GFM
-
<<~GFM
Foo
@@ -527,28 +498,20 @@ describe 'Copy as GFM', :js do
)
verify(
- 'MarkdownFilter',
-
+ "MarkdownFilter",
"Line with two spaces at the end \nto insert a linebreak",
-
- '`code`',
- '`` code with ` ticks ``',
-
- '> Quote',
-
+ "`code`",
+ "`` code with ` ticks ``",
+ "> Quote",
# multiline quote
<<~GFM,
> Multiline Quote
>
> With multiple paragraphs
GFM
-
- '![Image](https://example.com/image.png)',
-
- '# Heading with no anchor link',
-
- '[Link](https://example.com)',
-
+ "![Image](https://example.com/image.png)",
+ "# Heading with no anchor link",
+ "[Link](https://example.com)",
<<~GFM,
* List item
@@ -575,7 +538,6 @@ describe 'Copy as GFM', :js do
> Blockquote
GFM
-
<<~GFM,
1. Ordered list item
@@ -602,22 +564,16 @@ describe 'Copy as GFM', :js do
---
GFM
-
- '# Heading',
- '## Heading',
- '### Heading',
- '#### Heading',
- '##### Heading',
- '###### Heading',
-
- '**Bold**',
-
- '*Italics*',
-
- '~~Strikethrough~~',
-
- '---',
-
+ "# Heading",
+ "## Heading",
+ "### Heading",
+ "#### Heading",
+ "##### Heading",
+ "###### Heading",
+ "**Bold**",
+ "*Italics*",
+ "~~Strikethrough~~",
+ "---",
# table
<<~GFM,
| Centered | Right | Left |
@@ -643,7 +599,7 @@ describe 'Copy as GFM', :js do
aggregate_failures(label) do
gfms.each do |gfm|
- html = gfm_to_html(gfm, markdown_options).gsub(/\A&#x000A;|&#x000A;\z/, '')
+ html = gfm_to_html(gfm, markdown_options).gsub(/\A&#x000A;|&#x000A;\z/, "")
output_gfm = html_to_gfm(html)
expect(output_gfm.strip).to eq(gfm.strip)
end
@@ -656,73 +612,66 @@ describe 'Copy as GFM', :js do
end
end
- describe 'Copying code' do
+ describe "Copying code" do
let(:project) { create(:project, :repository) }
- context 'from a diff' do
- shared_examples 'copying code from a diff' do
- context 'selecting one word of text' do
- it 'copies as inline code' do
+ context "from a diff" do
+ shared_examples "copying code from a diff" do
+ context "selecting one word of text" do
+ it "copies as inline code" do
verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"] .line .no',
-
- '`RuntimeError`',
-
+ "`RuntimeError`",
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
)
end
end
- context 'selecting one line of text' do
- it 'copies as inline code' do
+ context "selecting one line of text" do
+ it "copies as inline code" do
verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]',
-
'`raise RuntimeError, "System commands must be given as an array of strings"`',
-
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
)
end
end
- context 'selecting multiple lines of text' do
- it 'copies as a code block' do
+ context "selecting multiple lines of text" do
+ it "copies as a code block" do
verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
-
<<~GFM,
```ruby
raise RuntimeError, "System commands must be given as an array of strings"
end
```
GFM
-
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'
)
end
end
end
- context 'inline diff' do
+ context "inline diff" do
before do
- visit project_commit_path(project, sample_commit.id, view: 'inline')
+ visit project_commit_path(project, sample_commit.id, view: "inline")
end
- it_behaves_like 'copying code from a diff'
+ it_behaves_like "copying code from a diff"
end
- context 'parallel diff' do
+ context "parallel diff" do
before do
- visit project_commit_path(project, sample_commit.id, view: 'parallel')
+ visit project_commit_path(project, sample_commit.id, view: "parallel")
end
- it_behaves_like 'copying code from a diff'
+ it_behaves_like "copying code from a diff"
- context 'selecting code on the left' do
- it 'copies as a code block' do
+ context "selecting code on the left" do
+ it "copies as a code block" do
verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
-
<<~GFM,
```ruby
unless cmd.is_a?(Array)
@@ -730,17 +679,15 @@ describe 'Copy as GFM', :js do
end
```
GFM
-
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].left-side'
)
end
end
- context 'selecting code on the right' do
- it 'copies as a code block' do
+ context "selecting code on the right" do
+ it "copies as a code block" do
verify(
'[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"], [id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_10"]',
-
<<~GFM,
```ruby
unless cmd.is_a?(Array)
@@ -748,7 +695,6 @@ describe 'Copy as GFM', :js do
end
```
GFM
-
target: '[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_8_8"].right-side'
)
end
@@ -756,37 +702,34 @@ describe 'Copy as GFM', :js do
end
end
- context 'from a blob' do
+ context "from a blob" do
before do
- visit project_blob_path(project, File.join('master', 'files/ruby/popen.rb'))
+ visit project_blob_path(project, File.join("master", "files/ruby/popen.rb"))
wait_for_requests
end
- context 'selecting one word of text' do
- it 'copies as inline code' do
+ context "selecting one word of text" do
+ it "copies as inline code" do
verify(
'.line[id="LC9"] .no',
-
- '`RuntimeError`'
+ "`RuntimeError`"
)
end
end
- context 'selecting one line of text' do
- it 'copies as inline code' do
+ context "selecting one line of text" do
+ it "copies as inline code" do
verify(
'.line[id="LC9"]',
-
'`raise RuntimeError, "System commands must be given as an array of strings"`'
)
end
end
- context 'selecting multiple lines of text' do
- it 'copies as a code block' do
+ context "selecting multiple lines of text" do
+ it "copies as a code block" do
verify(
'.line[id="LC9"], .line[id="LC10"]',
-
<<~GFM,
```ruby
raise RuntimeError, "System commands must be given as an array of strings"
@@ -798,37 +741,34 @@ describe 'Copy as GFM', :js do
end
end
- context 'from a GFM code block' do
+ context "from a GFM code block" do
before do
- visit project_blob_path(project, File.join('markdown', 'doc/api/users.md'))
+ visit project_blob_path(project, File.join("markdown", "doc/api/users.md"))
wait_for_requests
end
- context 'selecting one word of text' do
- it 'copies as inline code' do
+ context "selecting one word of text" do
+ it "copies as inline code" do
verify(
'.line[id="LC27"] .s2',
-
'`"bio"`'
)
end
end
- context 'selecting one line of text' do
- it 'copies as inline code' do
+ context "selecting one line of text" do
+ it "copies as inline code" do
verify(
'.line[id="LC27"]',
-
'`"bio": null,`'
)
end
end
- context 'selecting multiple lines of text' do
- it 'copies as a code block with the correct language' do
+ context "selecting multiple lines of text" do
+ it "copies as a code block with the correct language" do
verify(
'.line[id="LC27"], .line[id="LC28"]',
-
<<~GFM,
```json
"bio": null,
@@ -842,7 +782,7 @@ describe 'Copy as GFM', :js do
def verify(selector, gfm, target: nil)
html = html_for_selector(selector)
- output_gfm = html_to_gfm(html, 'transformCodeSelection', target: target)
+ output_gfm = html_to_gfm(html, "transformCodeSelection", target: target)
wait_for_requests
expect(output_gfm.strip).to eq(gfm.strip)
end
@@ -859,7 +799,7 @@ describe 'Copy as GFM', :js do
page.evaluate_script(js)
end
- def html_to_gfm(html, transformer = 'transformGFMSelection', target: nil)
+ def html_to_gfm(html, transformer = "transformGFMSelection", target: nil)
js = <<~JS
(function(html) {
// Setting it off so the import already starts
@@ -889,8 +829,8 @@ describe 'Copy as GFM', :js do
JS
page.execute_script(js)
- loop until page.evaluate_script('window.gfmCopytestRes !== null')
+ loop until page.evaluate_script("window.gfmCopytestRes !== null")
- page.evaluate_script('window.gfmCopytestRes')
+ page.evaluate_script("window.gfmCopytestRes")
end
end
diff --git a/spec/features/markdown/gitlab_flavored_markdown_spec.rb b/spec/features/markdown/gitlab_flavored_markdown_spec.rb
index 6997ca48427..7109e87a67d 100644
--- a/spec/features/markdown/gitlab_flavored_markdown_spec.rb
+++ b/spec/features/markdown/gitlab_flavored_markdown_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe "GitLab Flavored Markdown" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:fred) do
- create(:user, name: 'fred') do |user|
+ create(:user, name: "fred") do |user|
project.add_maintainer(user)
end
end
@@ -25,7 +25,7 @@ describe "GitLab Flavored Markdown" do
end
it "renders title in commits#index" do
- visit project_commits_path(project, 'master', limit: 1)
+ visit project_commits_path(project, "master", limit: 1)
expect(page).to have_link(issue.to_reference)
end
@@ -52,15 +52,15 @@ describe "GitLab Flavored Markdown" do
describe "for issues", :js do
before do
@other_issue = create(:issue,
- author: user,
- assignees: [user],
- project: project)
+ author: user,
+ assignees: [user],
+ project: project)
@issue = create(:issue,
- author: user,
- assignees: [user],
- project: project,
- title: "fix #{@other_issue.to_reference}",
- description: "ask #{fred.to_reference} for details")
+ author: user,
+ assignees: [user],
+ project: project,
+ title: "fix #{@other_issue.to_reference}",
+ description: "ask #{fred.to_reference} for details")
@note = create(:note_on_issue, noteable: @issue, project: @issue.project, note: "Hello world")
end
@@ -107,9 +107,9 @@ describe "GitLab Flavored Markdown" do
describe "for milestones" do
before do
@milestone = create(:milestone,
- project: project,
- title: "fix #{issue.to_reference}",
- description: "ask #{fred.to_reference} for details")
+ project: project,
+ title: "fix #{issue.to_reference}",
+ description: "ask #{fred.to_reference} for details")
end
it "renders title in milestones#index" do
diff --git a/spec/features/markdown/markdown_spec.rb b/spec/features/markdown/markdown_spec.rb
index 8815643ca96..bc915b93417 100644
--- a/spec/features/markdown/markdown_spec.rb
+++ b/spec/features/markdown/markdown_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'erb'
+require "spec_helper"
+require "erb"
# This feature spec is intended to be a comprehensive exercising of all of
# GitLab's non-standard Markdown parsing and the integration thereof.
@@ -24,7 +24,7 @@ require 'erb'
#
# See the MarkdownFeature class for setup details.
-describe 'GitLab Markdown', :aggregate_failures do
+describe "GitLab Markdown", :aggregate_failures do
include Capybara::Node::Matchers
include MarkupHelper
include MarkdownMatchers
@@ -32,8 +32,8 @@ describe 'GitLab Markdown', :aggregate_failures do
# Sometimes it can be useful to see the parsed output of the Markdown document
# for debugging. Call this method to write the output to
# `tmp/capybara/<filename>.html`.
- def write_markdown(filename = 'markdown_spec')
- File.open(Rails.root.join("tmp/capybara/#{filename}.html"), 'w') do |file|
+ def write_markdown(filename = "markdown_spec")
+ File.open(Rails.root.join("tmp/capybara/#{filename}.html"), "w") do |file|
file.puts @html
end
end
@@ -43,103 +43,103 @@ describe 'GitLab Markdown', :aggregate_failures do
end
# Shared behavior that all pipelines should exhibit
- shared_examples 'all pipelines' do
- it 'includes extensions' do
- aggregate_failures 'does not parse emphasis inside of words' do
- expect(doc.to_html).not_to match('foo<em>bar</em>baz')
+ shared_examples "all pipelines" do
+ it "includes extensions" do
+ aggregate_failures "does not parse emphasis inside of words" do
+ expect(doc.to_html).not_to match("foo<em>bar</em>baz")
end
- aggregate_failures 'parses table Markdown' do
+ aggregate_failures "parses table Markdown" do
expect(doc).to have_selector('th:contains("Header")')
expect(doc).to have_selector('th:contains("Row")')
expect(doc).to have_selector('th:contains("Example")')
end
- aggregate_failures 'allows Markdown in tables' do
+ aggregate_failures "allows Markdown in tables" do
expect(doc.at_css('td:contains("Baz")').children.to_html)
- .to eq '<strong>Baz</strong>'
+ .to eq "<strong>Baz</strong>"
end
- aggregate_failures 'parses fenced code blocks' do
- expect(doc).to have_selector('pre.code.highlight.js-syntax-highlight.c')
- expect(doc).to have_selector('pre.code.highlight.js-syntax-highlight.python')
+ aggregate_failures "parses fenced code blocks" do
+ expect(doc).to have_selector("pre.code.highlight.js-syntax-highlight.c")
+ expect(doc).to have_selector("pre.code.highlight.js-syntax-highlight.python")
end
- aggregate_failures 'parses mermaid code block' do
- expect(doc).to have_selector('pre[lang=mermaid] > code.js-render-mermaid')
+ aggregate_failures "parses mermaid code block" do
+ expect(doc).to have_selector("pre[lang=mermaid] > code.js-render-mermaid")
end
- aggregate_failures 'parses strikethroughs' do
+ aggregate_failures "parses strikethroughs" do
expect(doc).to have_selector(%{del:contains("and this text doesn't")})
end
end
- it 'includes SanitizationFilter' do
- aggregate_failures 'permits b elements' do
+ it "includes SanitizationFilter" do
+ aggregate_failures "permits b elements" do
expect(doc).to have_selector('b:contains("b tag")')
end
- aggregate_failures 'permits em elements' do
+ aggregate_failures "permits em elements" do
expect(doc).to have_selector('em:contains("em tag")')
end
- aggregate_failures 'permits code elements' do
+ aggregate_failures "permits code elements" do
expect(doc).to have_selector('code:contains("code tag")')
end
- aggregate_failures 'permits kbd elements' do
+ aggregate_failures "permits kbd elements" do
expect(doc).to have_selector('kbd:contains("s")')
end
- aggregate_failures 'permits strike elements' do
- expect(doc).to have_selector('strike:contains(Emoji)')
+ aggregate_failures "permits strike elements" do
+ expect(doc).to have_selector("strike:contains(Emoji)")
end
- aggregate_failures 'permits img elements' do
+ aggregate_failures "permits img elements" do
expect(doc).to have_selector('img[data-src*="smile.png"]')
end
- aggregate_failures 'permits br elements' do
- expect(doc).to have_selector('br')
+ aggregate_failures "permits br elements" do
+ expect(doc).to have_selector("br")
end
- aggregate_failures 'permits hr elements' do
- expect(doc).to have_selector('hr')
+ aggregate_failures "permits hr elements" do
+ expect(doc).to have_selector("hr")
end
- aggregate_failures 'permits span elements' do
+ aggregate_failures "permits span elements" do
expect(doc).to have_selector('span:contains("span tag")')
end
- aggregate_failures 'permits details elements' do
+ aggregate_failures "permits details elements" do
expect(doc).to have_selector('details:contains("Hiding the details")')
end
- aggregate_failures 'permits summary elements' do
+ aggregate_failures "permits summary elements" do
expect(doc).to have_selector('details summary:contains("collapsible")')
end
- aggregate_failures 'permits align attribute in th elements' do
- expect(doc.at_css('th:contains("Header")')['align']).to eq 'center'
- expect(doc.at_css('th:contains("Row")')['align']).to eq 'right'
- expect(doc.at_css('th:contains("Example")')['align']).to eq 'left'
+ aggregate_failures "permits align attribute in th elements" do
+ expect(doc.at_css('th:contains("Header")')["align"]).to eq "center"
+ expect(doc.at_css('th:contains("Row")')["align"]).to eq "right"
+ expect(doc.at_css('th:contains("Example")')["align"]).to eq "left"
end
- aggregate_failures 'permits align attribute in td elements' do
- expect(doc.at_css('td:contains("Foo")')['align']).to eq 'center'
- expect(doc.at_css('td:contains("Bar")')['align']).to eq 'right'
- expect(doc.at_css('td:contains("Baz")')['align']).to eq 'left'
+ aggregate_failures "permits align attribute in td elements" do
+ expect(doc.at_css('td:contains("Foo")')["align"]).to eq "center"
+ expect(doc.at_css('td:contains("Bar")')["align"]).to eq "right"
+ expect(doc.at_css('td:contains("Baz")')["align"]).to eq "left"
end
- aggregate_failures 'permits superscript elements' do
- expect(doc).to have_selector('sup', count: 2)
+ aggregate_failures "permits superscript elements" do
+ expect(doc).to have_selector("sup", count: 2)
end
- aggregate_failures 'permits subscript elements' do
- expect(doc).to have_selector('sub', count: 3)
+ aggregate_failures "permits subscript elements" do
+ expect(doc).to have_selector("sub", count: 3)
end
- aggregate_failures 'removes `rel` attribute from links' do
+ aggregate_failures "removes `rel` attribute from links" do
expect(doc).not_to have_selector('a[rel="bookmark"]')
end
@@ -148,52 +148,52 @@ describe 'GitLab Markdown', :aggregate_failures do
end
end
- describe 'Escaping' do
- it 'escapes non-tag angle brackets' do
- table = doc.css('table').last.at_css('tbody')
- expect(table.at_xpath('.//tr[1]/td[3]').inner_html).to eq '1 &lt; 3 &amp; 5'
+ describe "Escaping" do
+ it "escapes non-tag angle brackets" do
+ table = doc.css("table").last.at_css("tbody")
+ expect(table.at_xpath(".//tr[1]/td[3]").inner_html).to eq "1 &lt; 3 &amp; 5"
end
end
- describe 'Edge Cases' do
- it 'allows markup inside link elements' do
+ describe "Edge Cases" do
+ it "allows markup inside link elements" do
aggregate_failures do
expect(doc.at_css('a[href="#link-emphasis"]').to_html)
- .to eq %{<a href="#link-emphasis"><em>text</em></a>}
+ .to eq %(<a href="#link-emphasis"><em>text</em></a>)
expect(doc.at_css('a[href="#link-strong"]').to_html)
- .to eq %{<a href="#link-strong"><strong>text</strong></a>}
+ .to eq %(<a href="#link-strong"><strong>text</strong></a>)
expect(doc.at_css('a[href="#link-code"]').to_html)
- .to eq %{<a href="#link-code"><code>text</code></a>}
+ .to eq %(<a href="#link-code"><code>text</code></a>)
end
end
end
- it 'includes ExternalLinkFilter' do
- aggregate_failures 'adds nofollow to external link' do
+ it "includes ExternalLinkFilter" do
+ aggregate_failures "adds nofollow to external link" do
link = doc.at_css('a:contains("Google")')
- expect(link.attr('rel')).to include('nofollow')
+ expect(link.attr("rel")).to include("nofollow")
end
- aggregate_failures 'adds noreferrer to external link' do
+ aggregate_failures "adds noreferrer to external link" do
link = doc.at_css('a:contains("Google")')
- expect(link.attr('rel')).to include('noreferrer')
+ expect(link.attr("rel")).to include("noreferrer")
end
- aggregate_failures 'adds _blank to target attribute for external links' do
+ aggregate_failures "adds _blank to target attribute for external links" do
link = doc.at_css('a:contains("Google")')
- expect(link.attr('target')).to match('_blank')
+ expect(link.attr("target")).to match("_blank")
end
- aggregate_failures 'ignores internal link' do
+ aggregate_failures "ignores internal link" do
link = doc.at_css('a:contains("GitLab Root")')
- expect(link.attr('rel')).not_to match 'nofollow'
- expect(link.attr('target')).not_to match '_blank'
+ expect(link.attr("rel")).not_to match "nofollow"
+ expect(link.attr("target")).not_to match "_blank"
end
end
end
@@ -206,31 +206,31 @@ describe 'GitLab Markdown', :aggregate_failures do
@group = @feat.group
end
- context 'default pipeline' do
+ context "default pipeline" do
before do
@html = markdown(@feat.raw_markdown)
end
- it_behaves_like 'all pipelines'
+ it_behaves_like "all pipelines"
- it 'includes custom filters' do
- aggregate_failures 'RelativeLinkFilter' do
+ it "includes custom filters" do
+ aggregate_failures "RelativeLinkFilter" do
expect(doc).to parse_relative_links
end
- aggregate_failures 'EmojiFilter' do
+ aggregate_failures "EmojiFilter" do
expect(doc).to parse_emoji
end
- aggregate_failures 'TableOfContentsFilter' do
+ aggregate_failures "TableOfContentsFilter" do
expect(doc).to create_header_links
end
- aggregate_failures 'AutolinkFilter' do
+ aggregate_failures "AutolinkFilter" do
expect(doc).to create_autolinks
end
- aggregate_failures 'all reference filters' do
+ aggregate_failures "all reference filters" do
expect(doc).to reference_users
expect(doc).to reference_issues
expect(doc).to reference_merge_requests
@@ -241,57 +241,57 @@ describe 'GitLab Markdown', :aggregate_failures do
expect(doc).to reference_milestones
end
- aggregate_failures 'TaskListFilter' do
+ aggregate_failures "TaskListFilter" do
expect(doc).to parse_task_lists
end
- aggregate_failures 'InlineDiffFilter' do
+ aggregate_failures "InlineDiffFilter" do
expect(doc).to parse_inline_diffs
end
- aggregate_failures 'VideoLinkFilter' do
+ aggregate_failures "VideoLinkFilter" do
expect(doc).to parse_video_links
end
- aggregate_failures 'ColorFilter' do
+ aggregate_failures "ColorFilter" do
expect(doc).to parse_colors
end
end
end
- context 'wiki pipeline' do
+ context "wiki pipeline" do
before do
@project_wiki = @feat.project_wiki
@project_wiki_page = @feat.project_wiki_page
- path = 'images/example.jpg'
+ path = "images/example.jpg"
gitaly_wiki_file = Gitlab::GitalyClient::WikiFile.new(path: path)
expect(@project_wiki).to receive(:find_file).with(path).and_return(Gitlab::Git::WikiFile.new(gitaly_wiki_file))
- allow(@project_wiki).to receive(:wiki_base_path) { '/namespace1/gitlabhq/wikis' }
+ allow(@project_wiki).to receive(:wiki_base_path) { "/namespace1/gitlabhq/wikis" }
- @html = markdown(@feat.raw_markdown, { pipeline: :wiki, project_wiki: @project_wiki, page_slug: @project_wiki_page.slug })
+ @html = markdown(@feat.raw_markdown, {pipeline: :wiki, project_wiki: @project_wiki, page_slug: @project_wiki_page.slug})
end
- it_behaves_like 'all pipelines'
+ it_behaves_like "all pipelines"
- it 'includes custom filters' do
- aggregate_failures 'RelativeLinkFilter' do
+ it "includes custom filters" do
+ aggregate_failures "RelativeLinkFilter" do
expect(doc).not_to parse_relative_links
end
- aggregate_failures 'EmojiFilter' do
+ aggregate_failures "EmojiFilter" do
expect(doc).to parse_emoji
end
- aggregate_failures 'TableOfContentsFilter' do
+ aggregate_failures "TableOfContentsFilter" do
expect(doc).to create_header_links
end
- aggregate_failures 'AutolinkFilter' do
+ aggregate_failures "AutolinkFilter" do
expect(doc).to create_autolinks
end
- aggregate_failures 'all reference filters' do
+ aggregate_failures "all reference filters" do
expect(doc).to reference_users
expect(doc).to reference_issues
expect(doc).to reference_merge_requests
@@ -302,23 +302,23 @@ describe 'GitLab Markdown', :aggregate_failures do
expect(doc).to reference_milestones
end
- aggregate_failures 'TaskListFilter' do
+ aggregate_failures "TaskListFilter" do
expect(doc).to parse_task_lists
end
- aggregate_failures 'GollumTagsFilter' do
+ aggregate_failures "GollumTagsFilter" do
expect(doc).to parse_gollum_tags
end
- aggregate_failures 'InlineDiffFilter' do
+ aggregate_failures "InlineDiffFilter" do
expect(doc).to parse_inline_diffs
end
- aggregate_failures 'VideoLinkFilter' do
+ aggregate_failures "VideoLinkFilter" do
expect(doc).to parse_video_links
end
- aggregate_failures 'ColorFilter' do
+ aggregate_failures "ColorFilter" do
expect(doc).to parse_colors
end
end
diff --git a/spec/features/markdown/math_spec.rb b/spec/features/markdown/math_spec.rb
index 16ad0d456be..a5e56cb7628 100644
--- a/spec/features/markdown/math_spec.rb
+++ b/spec/features/markdown/math_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Math rendering', :js do
+describe "Math rendering", :js do
let!(:project) { create(:project, :public) }
- it 'renders inline and display math correctly' do
+ it "renders inline and display math correctly" do
description = <<~MATH
This math is inline $`a^2+b^2=c^2`$.
@@ -17,11 +17,11 @@ describe 'Math rendering', :js do
visit project_issue_path(project, issue)
- expect(page).to have_selector('.katex .mord.mathdefault', text: 'b')
- expect(page).to have_selector('.katex-display .mord.mathdefault', text: 'b')
+ expect(page).to have_selector(".katex .mord.mathdefault", text: "b")
+ expect(page).to have_selector(".katex-display .mord.mathdefault", text: "b")
end
- it 'only renders non XSS links' do
+ it "only renders non XSS links" do
description = <<~MATH
This link is valid $`\\href{javascript:alert('xss');}{xss}`$.
@@ -32,7 +32,7 @@ describe 'Math rendering', :js do
visit project_issue_path(project, issue)
- expect(page).to have_selector('.katex-error', text: "\href{javascript:alert('xss');}{xss}")
- expect(page).to have_selector('.katex-html a', text: 'Gitlab')
+ expect(page).to have_selector(".katex-error", text: "\href{javascript:alert('xss');}{xss}")
+ expect(page).to have_selector(".katex-html a", text: "Gitlab")
end
end
diff --git a/spec/features/markdown/mermaid_spec.rb b/spec/features/markdown/mermaid_spec.rb
index 7008b361394..477f134835b 100644
--- a/spec/features/markdown/mermaid_spec.rb
+++ b/spec/features/markdown/mermaid_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Mermaid rendering', :js do
- it 'renders Mermaid diagrams correctly' do
+describe "Mermaid rendering", :js do
+ it "renders Mermaid diagrams correctly" do
description = <<~MERMAID
```mermaid
graph TD;
@@ -18,7 +18,7 @@ describe 'Mermaid rendering', :js do
visit project_issue_path(project, issue)
%w[A B C D].each do |label|
- expect(page).to have_selector('svg text', text: label)
+ expect(page).to have_selector("svg text", text: label)
end
end
end
diff --git a/spec/features/merge_request/maintainer_edits_fork_spec.rb b/spec/features/merge_request/maintainer_edits_fork_spec.rb
index aead98dae23..bfe01148282 100644
--- a/spec/features/merge_request/maintainer_edits_fork_spec.rb
+++ b/spec/features/merge_request/maintainer_edits_fork_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'a maintainer edits files on a source-branch of an MR from a fork', :js do
+describe "a maintainer edits files on a source-branch of an MR from a fork", :js do
include ProjectForksHelper
- let(:user) { create(:user, username: 'the-maintainer') }
+ let(:user) { create(:user, username: "the-maintainer") }
let(:target_project) { create(:project, :public, :repository) }
- let(:author) { create(:user, username: 'mr-authoring-machine') }
+ let(:author) { create(:user, username: "mr-authoring-machine") }
let(:source_project) { fork_project(target_project, author, repository: true) }
let(:merge_request) do
create(:merge_request,
- source_project: source_project,
- target_project: target_project,
- source_branch: 'fix',
- target_branch: 'master',
- author: author,
- allow_collaboration: true)
+ source_project: source_project,
+ target_project: target_project,
+ source_branch: "fix",
+ target_branch: "master",
+ author: author,
+ allow_collaboration: true)
end
before do
@@ -24,23 +24,23 @@ describe 'a maintainer edits files on a source-branch of an MR from a fork', :js
sign_in(user)
visit project_merge_request_path(target_project, merge_request)
- click_link 'Changes'
+ click_link "Changes"
wait_for_requests
- first('.js-file-title').click_link 'Edit'
+ first(".js-file-title").click_link "Edit"
wait_for_requests
end
- it 'mentions commits will go to the source branch' do
- expect(page).to have_content('Your changes can be committed to fix because a merge request is open.')
+ it "mentions commits will go to the source branch" do
+ expect(page).to have_content("Your changes can be committed to fix because a merge request is open.")
end
- it 'allows committing to the source branch' do
- find('.ace_text-input', visible: false).send_keys('Updated the readme')
+ it "allows committing to the source branch" do
+ find(".ace_text-input", visible: false).send_keys("Updated the readme")
- click_button 'Commit changes'
+ click_button "Commit changes"
wait_for_requests
- expect(page).to have_content('Your changes have been successfully committed')
- expect(page).to have_content('Updated the readme')
+ expect(page).to have_content("Your changes have been successfully committed")
+ expect(page).to have_content("Updated the readme")
end
end
diff --git a/spec/features/merge_request/user_accepts_merge_request_spec.rb b/spec/features/merge_request/user_accepts_merge_request_spec.rb
index 5fa23dbb998..02f9c8d37a5 100644
--- a/spec/features/merge_request/user_accepts_merge_request_spec.rb
+++ b/spec/features/merge_request/user_accepts_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User accepts a merge request', :js do
+describe "User accepts a merge request", :js do
let(:merge_request) { create(:merge_request, :with_diffs, :simple, source_project: project) }
let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) }
@@ -10,26 +10,26 @@ describe 'User accepts a merge request', :js do
sign_in(user)
end
- it 'presents merged merge request content' do
+ it "presents merged merge request content" do
visit(merge_request_path(merge_request))
- click_button('Merge')
+ click_button("Merge")
expect(page).to have_content("The changes were merged into #{merge_request.target_branch} with \
#{merge_request.short_merge_commit_sha}")
end
- context 'with removing the source branch' do
+ context "with removing the source branch" do
before do
visit(merge_request_path(merge_request))
end
- it 'accepts a merge request' do
- check('Delete source branch')
- click_button('Merge')
+ it "accepts a merge request" do
+ check("Delete source branch")
+ click_button("Merge")
- expect(page).to have_content('The changes were merged into')
- expect(page).not_to have_selector('.js-remove-branch-button')
+ expect(page).to have_content("The changes were merged into")
+ expect(page).not_to have_selector(".js-remove-branch-button")
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run.
@@ -37,16 +37,16 @@ describe 'User accepts a merge request', :js do
end
end
- context 'without removing the source branch' do
+ context "without removing the source branch" do
before do
visit(merge_request_path(merge_request))
end
- it 'accepts a merge request' do
- click_button('Merge')
+ it "accepts a merge request" do
+ click_button("Merge")
- expect(page).to have_content('The changes were merged into')
- expect(page).to have_selector('.js-remove-branch-button')
+ expect(page).to have_content("The changes were merged into")
+ expect(page).to have_selector(".js-remove-branch-button")
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
@@ -54,17 +54,17 @@ describe 'User accepts a merge request', :js do
end
end
- context 'when a URL has an anchor' do
+ context "when a URL has an anchor" do
before do
- visit(merge_request_path(merge_request, anchor: 'note_123'))
+ visit(merge_request_path(merge_request, anchor: "note_123"))
end
- it 'accepts a merge request' do
- check('Delete source branch')
- click_button('Merge')
+ it "accepts a merge request" do
+ check("Delete source branch")
+ click_button("Merge")
- expect(page).to have_content('The changes were merged into')
- expect(page).not_to have_selector('.js-remove-branch-button')
+ expect(page).to have_content("The changes were merged into")
+ expect(page).not_to have_selector(".js-remove-branch-button")
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
@@ -72,21 +72,21 @@ describe 'User accepts a merge request', :js do
end
end
- context 'when modifying the merge commit message' do
+ context "when modifying the merge commit message" do
before do
merge_request.mark_as_mergeable
visit(merge_request_path(merge_request))
end
- it 'accepts a merge request' do
- find('.js-mr-widget-commits-count').click
- fill_in('merge-message-edit', with: 'wow such merge')
+ it "accepts a merge request" do
+ find(".js-mr-widget-commits-count").click
+ fill_in("merge-message-edit", with: "wow such merge")
- click_button('Merge')
+ click_button("Merge")
- page.within('.status-box') do
- expect(page).to have_content('Merged')
+ page.within(".status-box") do
+ expect(page).to have_content("Merged")
end
end
end
diff --git a/spec/features/merge_request/user_allows_commits_from_memebers_who_can_merge_spec.rb b/spec/features/merge_request/user_allows_commits_from_memebers_who_can_merge_spec.rb
index 0ccab5b2fac..3b28608e968 100644
--- a/spec/features/merge_request/user_allows_commits_from_memebers_who_can_merge_spec.rb
+++ b/spec/features/merge_request/user_allows_commits_from_memebers_who_can_merge_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'create a merge request, allowing commits from members who can merge to the target branch', :js do
+describe "create a merge request, allowing commits from members who can merge to the target branch", :js do
include ProjectForksHelper
let(:user) { create(:user) }
let(:target_project) { create(:project, :public, :repository) }
@@ -12,62 +12,63 @@ describe 'create a merge request, allowing commits from members who can merge to
merge_request: {
source_project_id: source_project.id,
target_project_id: target_project.id,
- source_branch: 'fix',
- target_branch: 'master'
- })
+ source_branch: "fix",
+ target_branch: "master",
+ }
+ )
end
before do
sign_in(user)
end
- it 'allows setting possible' do
+ it "allows setting possible" do
visit_new_merge_request
- check 'Allow commits from members who can merge to the target branch'
+ check "Allow commits from members who can merge to the target branch"
- click_button 'Submit merge request'
+ click_button "Submit merge request"
wait_for_requests
- expect(page).to have_content('Allows commits from members who can merge to the target branch')
+ expect(page).to have_content("Allows commits from members who can merge to the target branch")
end
- it 'shows a message when one of the projects is private' do
+ it "shows a message when one of the projects is private" do
source_project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
visit_new_merge_request
- expect(page).to have_content('Not available for private projects')
+ expect(page).to have_content("Not available for private projects")
end
- it 'shows a message when the source branch is protected' do
- create(:protected_branch, project: source_project, name: 'fix')
+ it "shows a message when the source branch is protected" do
+ create(:protected_branch, project: source_project, name: "fix")
visit_new_merge_request
- expect(page).to have_content('Not available for protected branches')
+ expect(page).to have_content("Not available for protected branches")
end
- context 'when the merge request is being created within the same project' do
+ context "when the merge request is being created within the same project" do
let(:source_project) { target_project }
- it 'hides the checkbox if the merge request is being created within the same project' do
+ it "hides the checkbox if the merge request is being created within the same project" do
target_project.add_developer(user)
visit_new_merge_request
- expect(page).not_to have_content('Allows commits from members who can merge to the target branch')
+ expect(page).not_to have_content("Allows commits from members who can merge to the target branch")
end
end
- context 'when a member who can merge tries to edit the option' do
+ context "when a member who can merge tries to edit the option" do
let(:member) { create(:user) }
let(:merge_request) do
create(:merge_request,
- source_project: source_project,
- target_project: target_project,
- source_branch: 'fixes')
+ source_project: source_project,
+ target_project: target_project,
+ source_branch: "fixes")
end
before do
@@ -76,10 +77,10 @@ describe 'create a merge request, allowing commits from members who can merge to
sign_in(member)
end
- it 'it hides the option from members' do
+ it "it hides the option from members" do
visit edit_project_merge_request_path(target_project, merge_request)
- expect(page).not_to have_content('Allows commits from members who can merge to the target branch')
+ expect(page).not_to have_content("Allows commits from members who can merge to the target branch")
end
end
end
diff --git a/spec/features/merge_request/user_assigns_themselves_spec.rb b/spec/features/merge_request/user_assigns_themselves_spec.rb
index 41cc7cef777..0865182024f 100644
--- a/spec/features/merge_request/user_assigns_themselves_spec.rb
+++ b/spec/features/merge_request/user_assigns_themselves_spec.rb
@@ -1,49 +1,49 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User assigns themselves' do
+describe "Merge request > User assigns themselves" do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue1.to_reference} and #{issue2.to_reference}") }
- context 'logged in as a member of the project' do
+ context "logged in as a member of the project" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'updates related issues', :js do
- click_link 'Assign yourself to these issues'
+ it "updates related issues", :js do
+ click_link "Assign yourself to these issues"
- expect(page).to have_content '2 issues have been assigned to you'
+ expect(page).to have_content "2 issues have been assigned to you"
end
- it 'returns user to the merge request', :js do
- click_link 'Assign yourself to these issues'
+ it "returns user to the merge request", :js do
+ click_link "Assign yourself to these issues"
expect(page).to have_content merge_request.description
end
- context 'when related issues are already assigned' do
+ context "when related issues are already assigned" do
before do
[issue1, issue2].each { |issue| issue.update!(assignees: [user]) }
end
- it 'does not display if related issues are already assigned' do
- expect(page).not_to have_content 'Assign yourself'
+ it "does not display if related issues are already assigned" do
+ expect(page).not_to have_content "Assign yourself"
end
end
end
- context 'logged in as a non-member of the project' do
+ context "logged in as a non-member of the project" do
before do
sign_in(create(:user))
visit project_merge_request_path(project, merge_request)
end
- it 'does not show assignment link' do
- expect(page).not_to have_content 'Assign yourself'
+ it "does not show assignment link" do
+ expect(page).not_to have_content "Assign yourself"
end
end
end
diff --git a/spec/features/merge_request/user_awards_emoji_spec.rb b/spec/features/merge_request/user_awards_emoji_spec.rb
index 93376bc8ce0..29cee97ad5b 100644
--- a/spec/features/merge_request/user_awards_emoji_spec.rb
+++ b/spec/features/merge_request/user_awards_emoji_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User awards emoji', :js do
+describe "Merge request > User awards emoji", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project, author: create(:user)) }
let!(:note) { create(:note, noteable: merge_request, project: merge_request.project) }
- describe 'logged in' do
+ describe "logged in" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
@@ -14,56 +14,56 @@ describe 'Merge request > User awards emoji', :js do
wait_for_requests
end
- 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'
+ 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"
visit project_merge_request_path(project, merge_request)
- expect(first('.js-emoji-btn')).to have_content '1'
+ expect(first(".js-emoji-btn")).to have_content "1"
end
- 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'
+ 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"
visit project_merge_request_path(project, merge_request)
- expect(first('.js-emoji-btn')).to have_content '0'
+ expect(first(".js-emoji-btn")).to have_content "0"
end
- it 'has only one menu on the page' do
- first('.js-add-award').click
- expect(page).to have_selector('.emoji-menu')
+ it "has only one menu on the page" do
+ first(".js-add-award").click
+ expect(page).to have_selector(".emoji-menu")
- expect(page).to have_selector('.emoji-menu', count: 1)
+ expect(page).to have_selector(".emoji-menu", count: 1)
end
- it 'adds awards to note' do
- first('.js-note-emoji').click
- first('.emoji-menu .js-emoji-btn').click
+ it "adds awards to note" do
+ first(".js-note-emoji").click
+ first(".emoji-menu .js-emoji-btn").click
wait_for_requests
- expect(page).to have_selector('.js-awards-block')
+ expect(page).to have_selector(".js-awards-block")
end
- describe 'the project is archived' do
+ describe "the project is archived" do
let(:project) { create(:project, :public, :repository, :archived) }
- it 'does not see award menu button' do
- expect(page).not_to have_selector('.js-award-holder')
+ it "does not see award menu button" do
+ expect(page).not_to have_selector(".js-award-holder")
end
end
end
- describe 'logged out' do
+ describe "logged out" do
before do
visit project_merge_request_path(project, merge_request)
end
- it 'does not see award menu button' do
- expect(page).not_to have_selector('.js-award-holder')
+ it "does not see award menu button" do
+ expect(page).not_to have_selector(".js-award-holder")
end
end
end
diff --git a/spec/features/merge_request/user_closes_merge_request_spec.rb b/spec/features/merge_request/user_closes_merge_request_spec.rb
index 2d12d690151..a09258232f7 100644
--- a/spec/features/merge_request/user_closes_merge_request_spec.rb
+++ b/spec/features/merge_request/user_closes_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User closes a merge requests', :js do
+describe "User closes a merge requests", :js do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) }
@@ -12,10 +12,10 @@ describe 'User closes a merge requests', :js do
visit(merge_request_path(merge_request))
end
- it 'closes a merge request' do
- click_link('Close merge request', match: :first)
+ it "closes a merge request" do
+ click_link("Close merge request", match: :first)
expect(page).to have_content(merge_request.title)
- expect(page).to have_content('Closed by')
+ expect(page).to have_content("Closed by")
end
end
diff --git a/spec/features/merge_request/user_comments_on_commit_spec.rb b/spec/features/merge_request/user_comments_on_commit_spec.rb
index 8ea358bcc70..bc0479317a9 100644
--- a/spec/features/merge_request/user_comments_on_commit_spec.rb
+++ b/spec/features/merge_request/user_comments_on_commit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User comments on a commit', :js do
+describe "User comments on a commit", :js do
include MergeRequestDiffHelpers
include RepoHelpers
@@ -15,5 +15,5 @@ describe 'User comments on a commit', :js do
visit(project_commit_path(project, sample_commit.id))
end
- include_examples 'comment on merge request file'
+ include_examples "comment on merge request file"
end
diff --git a/spec/features/merge_request/user_comments_on_diff_spec.rb b/spec/features/merge_request/user_comments_on_diff_spec.rb
index eb4b2cf5bd0..6850389b223 100644
--- a/spec/features/merge_request/user_comments_on_diff_spec.rb
+++ b/spec/features/merge_request/user_comments_on_diff_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User comments on a diff', :js do
+describe "User comments on a diff", :js do
include MergeRequestDiffHelpers
include RepoHelpers
let(:project) { create(:project, :repository) }
let(:merge_request) do
- create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
+ create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: "merge-test")
end
let(:user) { create(:user) }
@@ -17,157 +17,157 @@ describe 'User comments on a diff', :js do
visit(diffs_project_merge_request_path(project, merge_request))
end
- context 'when viewing comments' do
- context 'when toggling inline comments' do
- context 'in a single file' do
- it 'hides a comment' do
+ context "when viewing comments" do
+ context "when toggling inline comments" do
+ context "in a single file" do
+ it "hides a comment" do
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: 'Line is wrong')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "Line is wrong")
+ click_button("Comment")
end
- page.within('.diff-files-holder > div:nth-child(3)') do
- expect(page).to have_content('Line is wrong')
+ page.within(".diff-files-holder > div:nth-child(3)") do
+ expect(page).to have_content("Line is wrong")
- find('.js-btn-vue-toggle-comments').click
+ find(".js-btn-vue-toggle-comments").click
- expect(page).not_to have_content('Line is wrong')
+ expect(page).not_to have_content("Line is wrong")
end
end
end
- context 'in multiple files' do
- it 'toggles comments' do
+ context "in multiple files" do
+ it "toggles comments" do
click_diff_line(find("[id='#{sample_compare.changes[0][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: 'Line is correct')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "Line is correct")
+ click_button("Comment")
end
wait_for_requests
- page.within('.diff-files-holder > div:nth-child(2) .note-body > .note-text') do
- expect(page).to have_content('Line is correct')
+ page.within(".diff-files-holder > div:nth-child(2) .note-body > .note-text") do
+ expect(page).to have_content("Line is correct")
end
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: 'Line is wrong')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "Line is wrong")
+ click_button("Comment")
end
wait_for_requests
# Hide the comment.
- page.within('.diff-files-holder > div:nth-child(3)') do
- find('.js-btn-vue-toggle-comments').click
+ page.within(".diff-files-holder > div:nth-child(3)") do
+ find(".js-btn-vue-toggle-comments").click
- expect(page).not_to have_content('Line is wrong')
+ expect(page).not_to have_content("Line is wrong")
end
# At this moment a user should see only one comment.
# The other one should be hidden.
- page.within('.diff-files-holder > div:nth-child(2) .note-body > .note-text') do
- expect(page).to have_content('Line is correct')
+ page.within(".diff-files-holder > div:nth-child(2) .note-body > .note-text") do
+ expect(page).to have_content("Line is correct")
end
# Show the comment.
- page.within('.diff-files-holder > div:nth-child(3)') do
- find('.js-btn-vue-toggle-comments').click
+ page.within(".diff-files-holder > div:nth-child(3)") do
+ find(".js-btn-vue-toggle-comments").click
end
# Now both the comments should be shown.
- page.within('.diff-files-holder > div:nth-child(3) .note-body > .note-text') do
- expect(page).to have_content('Line is wrong')
+ page.within(".diff-files-holder > div:nth-child(3) .note-body > .note-text") do
+ expect(page).to have_content("Line is wrong")
end
- page.within('.diff-files-holder > div:nth-child(2) .note-body > .note-text') do
- expect(page).to have_content('Line is correct')
+ page.within(".diff-files-holder > div:nth-child(2) .note-body > .note-text") do
+ expect(page).to have_content("Line is correct")
end
# Check the same comments in the side-by-side view.
execute_script("window.scrollTo(0,0);")
- find('.js-show-diff-settings').click
- click_button 'Side-by-side'
+ find(".js-show-diff-settings").click
+ click_button "Side-by-side"
wait_for_requests
- page.within('.diff-files-holder > div:nth-child(3) .parallel .note-body > .note-text') do
- expect(page).to have_content('Line is wrong')
+ page.within(".diff-files-holder > div:nth-child(3) .parallel .note-body > .note-text") do
+ expect(page).to have_content("Line is wrong")
end
- page.within('.diff-files-holder > div:nth-child(2) .parallel .note-body > .note-text') do
- expect(page).to have_content('Line is correct')
+ page.within(".diff-files-holder > div:nth-child(2) .parallel .note-body > .note-text") do
+ expect(page).to have_content("Line is correct")
end
end
end
end
end
- context 'when adding comments' do
- include_examples 'comment on merge request file'
+ context "when adding comments" do
+ include_examples "comment on merge request file"
end
- context 'when editing comments' do
- it 'edits a comment' do
+ context "when editing comments" do
+ it "edits a comment" do
click_diff_line(find("[id='#{sample_commit.line_code}']"))
- page.within('.js-discussion-note-form') do
- fill_in(:note_note, with: 'Line is wrong')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in(:note_note, with: "Line is wrong")
+ click_button("Comment")
end
- page.within('.diff-file:nth-of-type(5) .discussion .note') do
- find('.js-note-edit').click
+ page.within(".diff-file:nth-of-type(5) .discussion .note") do
+ find(".js-note-edit").click
- page.within('.current-note-edit-form') do
- fill_in('note_note', with: 'Typo, please fix')
- click_button('Save comment')
+ page.within(".current-note-edit-form") do
+ fill_in("note_note", with: "Typo, please fix")
+ click_button("Save comment")
end
- expect(page).not_to have_button('Save comment', disabled: true)
+ expect(page).not_to have_button("Save comment", disabled: true)
end
- page.within('.diff-file:nth-of-type(5) .discussion .note') do
- expect(page).to have_content('Typo, please fix').and have_no_content('Line is wrong')
+ page.within(".diff-file:nth-of-type(5) .discussion .note") do
+ expect(page).to have_content("Typo, please fix").and have_no_content("Line is wrong")
end
end
end
- context 'when deleting comments' do
- it 'deletes a comment' do
+ context "when deleting comments" do
+ it "deletes a comment" do
click_diff_line(find("[id='#{sample_commit.line_code}']"))
- page.within('.js-discussion-note-form') do
- fill_in(:note_note, with: 'Line is wrong')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in(:note_note, with: "Line is wrong")
+ click_button("Comment")
end
- page.within('.notes-tab .badge') do
- expect(page).to have_content('1')
+ page.within(".notes-tab .badge") do
+ expect(page).to have_content("1")
end
- page.within('.diff-file:nth-of-type(5) .discussion .note') do
- find('.more-actions').click
- find('.more-actions .dropdown-menu li', match: :first)
+ page.within(".diff-file:nth-of-type(5) .discussion .note") do
+ find(".more-actions").click
+ find(".more-actions .dropdown-menu li", match: :first)
- accept_confirm { find('.js-note-delete').click }
+ accept_confirm { find(".js-note-delete").click }
end
- page.within('.merge-request-tabs') do
- find('.notes-tab').click
+ page.within(".merge-request-tabs") do
+ find(".notes-tab").click
end
wait_for_requests
- expect(page).not_to have_css('.notes .discussion')
+ expect(page).not_to have_css(".notes .discussion")
- page.within('.notes-tab .badge') do
- expect(page).to have_content('0')
+ page.within(".notes-tab .badge") do
+ expect(page).to have_content("0")
end
end
end
diff --git a/spec/features/merge_request/user_comments_on_merge_request_spec.rb b/spec/features/merge_request/user_comments_on_merge_request_spec.rb
index 69bdab85d81..e95afb8dac7 100644
--- a/spec/features/merge_request/user_comments_on_merge_request_spec.rb
+++ b/spec/features/merge_request/user_comments_on_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User comments on a merge request', :js do
+describe "User comments on a merge request", :js do
include RepoHelpers
let(:project) { create(:project, :repository) }
@@ -14,36 +14,36 @@ describe 'User comments on a merge request', :js do
visit(merge_request_path(merge_request))
end
- it 'adds a comment' do
- page.within('.js-main-target-form') do
- fill_in('note[note]', with: '# Comment with a header')
- click_button('Comment')
+ it "adds a comment" do
+ page.within(".js-main-target-form") do
+ fill_in("note[note]", with: "# Comment with a header")
+ click_button("Comment")
end
wait_for_requests
- page.within('.note') do
- expect(page).to have_content('Comment with a header')
- expect(page).not_to have_css('#comment-with-a-header')
+ page.within(".note") do
+ expect(page).to have_content("Comment with a header")
+ expect(page).not_to have_css("#comment-with-a-header")
end
end
- it 'loads new comment' do
+ it "loads new comment" do
# Add new comment in background in order to check
# if it's going to be loaded automatically for current user.
- create(:diff_note_on_merge_request, project: project, noteable: merge_request, author: user, note: 'Line is wrong')
+ create(:diff_note_on_merge_request, project: project, noteable: merge_request, author: user, note: "Line is wrong")
# Trigger a refresh of notes.
execute_script("$(document).trigger('visibilitychange');")
wait_for_requests
- page.within('.notes .discussion') do
+ page.within(".notes .discussion") do
expect(page).to have_content("#{user.name} #{user.to_reference} started a discussion")
expect(page).to have_content(sample_commit.line_code_path)
- expect(page).to have_content('Line is wrong')
+ expect(page).to have_content("Line is wrong")
end
- page.within('.notes-tab .badge') do
- expect(page).to have_content('1')
+ page.within(".notes-tab .badge") do
+ expect(page).to have_content("1")
end
end
end
diff --git a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
index c837a6752f9..67d0e9fcdbc 100644
--- a/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_creates_image_diff_notes_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Merge request > User creates image diff notes', :js do
+describe "Merge request > User creates image diff notes", :js do
include NoteInteractionHelpers
let(:project) { create(:project, :public, :repository) }
@@ -11,39 +11,39 @@ describe 'Merge request > User creates image diff notes', :js do
# Stub helper to return any blob file as image from public app folder.
# This is necessary to run this specs since we don't display repo images in capybara.
- allow_any_instance_of(DiffHelper).to receive(:diff_file_blob_raw_url).and_return('/apple-touch-icon.png')
- allow_any_instance_of(DiffHelper).to receive(:diff_file_old_blob_raw_url).and_return('/favicon.png')
+ allow_any_instance_of(DiffHelper).to receive(:diff_file_blob_raw_url).and_return("/apple-touch-icon.png")
+ allow_any_instance_of(DiffHelper).to receive(:diff_file_old_blob_raw_url).and_return("/favicon.png")
end
- context 'create commit diff notes' do
- commit_id = '2f63565e7aac07bcdadb654e253078b727143ec4'
+ context "create commit diff notes" do
+ commit_id = "2f63565e7aac07bcdadb654e253078b727143ec4"
- describe 'create a new diff note' do
+ describe "create a new diff note" do
before do
visit project_commit_path(project, commit_id)
create_image_diff_note
end
- it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes' do
- indicator = find('.js-image-badge')
- badge = find('.image-diff-avatar-link .badge')
+ it "shows indicator and avatar badges, and allows collapsing/expanding the discussion notes" do
+ indicator = find(".js-image-badge")
+ badge = find(".image-diff-avatar-link .badge")
- expect(indicator).to have_content('1')
- expect(badge).to have_content('1')
+ expect(indicator).to have_content("1")
+ expect(badge).to have_content("1")
- find('.js-diff-notes-toggle').click
+ find(".js-diff-notes-toggle").click
- expect(page).not_to have_content('image diff test comment')
+ expect(page).not_to have_content("image diff test comment")
- find('.js-diff-notes-toggle').click
+ find(".js-diff-notes-toggle").click
- expect(page).to have_content('image diff test comment')
+ expect(page).to have_content("image diff test comment")
end
end
- describe 'render commit diff notes' do
+ describe "render commit diff notes" do
let(:path) { "files/images/6049019_460s.jpg" }
- let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
+ let(:commit) { project.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
let(:note1_position) do
Gitlab::Diff::Position.new(
@@ -71,24 +71,24 @@ describe 'Merge request > User creates image diff notes', :js do
)
end
- let!(:note1) { create(:diff_note_on_commit, commit_id: commit.id, project: project, position: note1_position, note: 'my note 1') }
- let!(:note2) { create(:diff_note_on_commit, commit_id: commit.id, project: project, position: note2_position, note: 'my note 2') }
+ let!(:note1) { create(:diff_note_on_commit, commit_id: commit.id, project: project, position: note1_position, note: "my note 1") }
+ let!(:note2) { create(:diff_note_on_commit, commit_id: commit.id, project: project, position: note2_position, note: "my note 2") }
before do
visit project_commit_path(project, commit.id)
wait_for_requests
end
- it 'render diff indicators within the image diff frame, diff notes, and avatar badge numbers' do
- expect(page).to have_css('.js-image-badge', count: 2)
- expect(page).to have_css('.diff-content .note', count: 2)
- expect(page).to have_css('.image-diff-avatar-link', text: 1)
- expect(page).to have_css('.image-diff-avatar-link', text: 2)
+ it "render diff indicators within the image diff frame, diff notes, and avatar badge numbers" do
+ expect(page).to have_css(".js-image-badge", count: 2)
+ expect(page).to have_css(".diff-content .note", count: 2)
+ expect(page).to have_css(".image-diff-avatar-link", text: 1)
+ expect(page).to have_css(".image-diff-avatar-link", text: 2)
end
end
end
- %w(inline parallel).each do |view|
+ %w[inline parallel].each do |view|
context "#{view} view" do
let(:position) do
Gitlab::Diff::Position.new(
@@ -105,7 +105,7 @@ describe 'Merge request > User creates image diff notes', :js do
let!(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position) }
- shared_examples 'creates image diff note' do
+ shared_examples "creates image diff note" do
before do
visit diffs_project_merge_request_path(project, merge_request, view: view)
wait_for_requests
@@ -113,54 +113,54 @@ describe 'Merge request > User creates image diff notes', :js do
create_image_diff_note
end
- it 'shows indicator and avatar badges, and allows collapsing/expanding the discussion notes' do
- indicator = find('.js-image-badge', match: :first)
- badge = find('.user-avatar-link .badge', match: :first)
+ it "shows indicator and avatar badges, and allows collapsing/expanding the discussion notes" do
+ indicator = find(".js-image-badge", match: :first)
+ badge = find(".user-avatar-link .badge", match: :first)
- expect(indicator).to have_content('1')
- expect(badge).to have_content('1')
+ expect(indicator).to have_content("1")
+ expect(badge).to have_content("1")
- page.all('.js-diff-notes-toggle')[0].click
- page.all('.js-diff-notes-toggle')[1].click
+ page.all(".js-diff-notes-toggle")[0].click
+ page.all(".js-diff-notes-toggle")[1].click
- expect(page).not_to have_content('image diff test comment')
+ expect(page).not_to have_content("image diff test comment")
- page.all('.js-diff-notes-toggle')[0].click
- page.all('.js-diff-notes-toggle')[1].click
+ page.all(".js-diff-notes-toggle")[0].click
+ page.all(".js-diff-notes-toggle")[1].click
- expect(page).to have_content('image diff test comment')
+ expect(page).to have_content("image diff test comment")
end
end
- context 'when images are not stored in LFS' do
+ context "when images are not stored in LFS" do
let(:merge_request) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, author: user) }
- let(:path) { 'files/images/ee_repo_logo.png' }
+ let(:path) { "files/images/ee_repo_logo.png" }
- it_behaves_like 'creates image diff note'
+ it_behaves_like "creates image diff note"
end
- context 'when images are stored in LFS' do
- let(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: 'png-lfs', target_branch: 'master', author: user) }
- let(:path) { 'files/images/logo-black.png' }
+ context "when images are stored in LFS" do
+ let(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: "png-lfs", target_branch: "master", author: user) }
+ let(:path) { "files/images/logo-black.png" }
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
end
- it 'shows lfs badges' do
+ it "shows lfs badges" do
visit diffs_project_merge_request_path(project, merge_request, view: view)
wait_for_requests
- expect(page.all('.diff-file span.label-lfs', visible: :all)).not_to be_empty
+ expect(page.all(".diff-file span.label-lfs", visible: :all)).not_to be_empty
end
- it_behaves_like 'creates image diff note'
+ it_behaves_like "creates image diff note"
end
end
end
- describe 'discussion tab polling' do
+ describe "discussion tab polling" do
let(:merge_request) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, author: user) }
let(:path) { "files/images/ee_repo_logo.png" }
@@ -181,39 +181,39 @@ describe 'Merge request > User creates image diff notes', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'render diff indicators within the image frame' do
+ it "render diff indicators within the image frame" do
diff_note = create(:diff_note_on_merge_request, project: project, noteable: merge_request, position: position)
wait_for_requests
- expect(page).to have_selector('.image-comment-badge')
+ expect(page).to have_selector(".image-comment-badge")
expect(page).to have_content(diff_note.note)
end
end
- describe 'image view modes' do
+ describe "image view modes" do
before do
- visit project_commit_path(project, '2f63565e7aac07bcdadb654e253078b727143ec4')
+ visit project_commit_path(project, "2f63565e7aac07bcdadb654e253078b727143ec4")
end
- it 'resizes image in onion skin view mode' do
- find('.view-modes-menu .onion-skin').click
+ it "resizes image in onion skin view mode" do
+ find(".view-modes-menu .onion-skin").click
- expect(find('.onion-skin-frame')['style']).to match('width: 228px; height: 240px;')
+ expect(find(".onion-skin-frame")["style"]).to match("width: 228px; height: 240px;")
end
- it 'resets onion skin view mode opacity when toggling between view modes' do
- find('.view-modes-menu .onion-skin').click
+ it "resets onion skin view mode opacity when toggling between view modes" do
+ find(".view-modes-menu .onion-skin").click
# Simulate dragging onion-skin slider
- drag_and_drop_by(find('.dragger'), -30, 0)
+ drag_and_drop_by(find(".dragger"), -30, 0)
- expect(find('.onion-skin-frame .frame.added', visible: false)['style']).not_to match('opacity: 1;')
+ expect(find(".onion-skin-frame .frame.added", visible: false)["style"]).not_to match("opacity: 1;")
- find('.view-modes-menu .swipe').click
- find('.view-modes-menu .onion-skin').click
+ find(".view-modes-menu .swipe").click
+ find(".view-modes-menu .onion-skin").click
- expect(find('.onion-skin-frame .frame.added', visible: false)['style']).to match('opacity: 1;')
+ expect(find(".onion-skin-frame .frame.added", visible: false)["style"]).to match("opacity: 1;")
end
end
@@ -222,14 +222,14 @@ describe 'Merge request > User creates image diff notes', :js do
end
def create_image_diff_note
- expand_text = 'Click to expand it.'
- page.all('a', text: expand_text).each do |element|
+ expand_text = "Click to expand it."
+ page.all("a", text: expand_text).each do |element|
element.click
end
- find('.js-add-image-diff-note-button', match: :first).click
- find('.diff-content .note-textarea').native.send_keys('image diff test comment')
- click_button 'Comment'
+ find(".js-add-image-diff-note-button", match: :first).click
+ find(".diff-content .note-textarea").native.send_keys("image diff test comment")
+ click_button "Comment"
wait_for_requests
end
end
diff --git a/spec/features/merge_request/user_creates_merge_request_spec.rb b/spec/features/merge_request/user_creates_merge_request_spec.rb
index ea2bb1503bb..652f4df4a94 100644
--- a/spec/features/merge_request/user_creates_merge_request_spec.rb
+++ b/spec/features/merge_request/user_creates_merge_request_spec.rb
@@ -74,8 +74,8 @@ describe "User creates a merge request", :js do
page.within(".dropdown-menu-user") do
expect(page).to have_content("Unassigned")
- .and have_content(user.name)
- .and have_content(project.users.first.name)
+ .and have_content(user.name)
+ .and have_content(project.users.first.name)
end
click_button("Submit merge request")
diff --git a/spec/features/merge_request/user_creates_mr_spec.rb b/spec/features/merge_request/user_creates_mr_spec.rb
index c169a68cd1c..b2b0ee727b6 100644
--- a/spec/features/merge_request/user_creates_mr_spec.rb
+++ b/spec/features/merge_request/user_creates_mr_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User creates MR' do
- it_behaves_like 'a creatable merge request'
+describe "Merge request > User creates MR" do
+ it_behaves_like "a creatable merge request"
- context 'from a forked project' do
+ context "from a forked project" do
include ProjectForksHelper
let(:canonical_project) { create(:project, :public, :repository) }
@@ -14,22 +14,22 @@ describe 'Merge request > User creates MR' do
namespace: user.namespace)
end
- context 'to canonical project' do
- it_behaves_like 'a creatable merge request'
+ context "to canonical project" do
+ it_behaves_like "a creatable merge request"
end
- context 'to another forked project' do
+ context "to another forked project" do
let(:target_project) do
fork_project(canonical_project, user,
repository: true,
namespace: user.namespace)
end
- it_behaves_like 'a creatable merge request'
+ it_behaves_like "a creatable merge request"
end
end
- context 'source project', :js do
+ context "source project", :js do
let(:user) { create(:user) }
let(:target_project) { create(:project, :public, :repository) }
let(:source_project) { target_project }
@@ -42,15 +42,16 @@ describe 'Merge request > User creates MR' do
target_project,
merge_request: {
source_project_id: source_project.id,
- target_project_id: target_project.id
- })
+ target_project_id: target_project.id,
+ }
+ )
end
- it 'filters source project' do
- find('.js-source-project').click
- find('.dropdown-source-project input').set('source')
+ it "filters source project" do
+ find(".js-source-project").click
+ find(".dropdown-source-project input").set("source")
- expect(find('.dropdown-source-project .dropdown-content')).not_to have_content(source_project.name)
+ expect(find(".dropdown-source-project .dropdown-content")).not_to have_content(source_project.name)
end
end
end
diff --git a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
index c6b11fce388..853b466eb7a 100644
--- a/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
+++ b/spec/features/merge_request/user_customizes_merge_commit_message_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request < User customizes merge commit message', :js do
+describe "Merge request < User customizes merge commit message", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
@@ -13,13 +13,13 @@ describe 'Merge request < User customizes merge commit message', :js do
description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}"
)
end
- let(:textbox) { page.find(:css, '#merge-message-edit', visible: false) }
+ let(:textbox) { page.find(:css, "#merge-message-edit", visible: false) }
let(:default_message) do
[
"Merge branch 'feature' into 'master'",
merge_request.title,
"Closes #{issue_1.to_reference} and #{issue_2.to_reference}",
- "See merge request #{merge_request.to_reference(full: true)}"
+ "See merge request #{merge_request.to_reference(full: true)}",
].join("\n\n")
end
let(:message_with_description) do
@@ -27,7 +27,7 @@ describe 'Merge request < User customizes merge commit message', :js do
"Merge branch 'feature' into 'master'",
merge_request.title,
merge_request.description,
- "See merge request #{merge_request.to_reference(full: true)}"
+ "See merge request #{merge_request.to_reference(full: true)}",
].join("\n\n")
end
@@ -37,17 +37,17 @@ describe 'Merge request < User customizes merge commit message', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'toggles commit message between message with description and without description' do
- expect(page).not_to have_selector('#merge-message-edit')
- first('.js-mr-widget-commits-count').click
+ it "toggles commit message between message with description and without description" do
+ expect(page).not_to have_selector("#merge-message-edit")
+ first(".js-mr-widget-commits-count").click
expect(textbox).to be_visible
expect(textbox.value).to eq(default_message)
- check('Include merge request description')
+ check("Include merge request description")
expect(textbox.value).to eq(message_with_description)
- uncheck('Include merge request description')
+ uncheck("Include merge request description")
expect(textbox.value).to eq(default_message)
end
diff --git a/spec/features/merge_request/user_edits_merge_request_spec.rb b/spec/features/merge_request/user_edits_merge_request_spec.rb
index 7de0f9daac6..65c175c85d3 100644
--- a/spec/features/merge_request/user_edits_merge_request_spec.rb
+++ b/spec/features/merge_request/user_edits_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User edits a merge request', :js do
+describe "User edits a merge request", :js do
include Select2Helper
let(:project) { create(:project, :repository) }
@@ -14,11 +14,11 @@ describe 'User edits a merge request', :js do
visit(edit_project_merge_request_path(project, merge_request))
end
- it 'changes the target branch' do
- expect(page).to have_content('Target branch')
+ it "changes the target branch" do
+ expect(page).to have_content("Target branch")
- select2('merge-test', from: '#merge_request_target_branch')
- click_button('Save changes')
+ select2("merge-test", from: "#merge_request_target_branch")
+ click_button("Save changes")
expect(page).to have_content("Request to merge #{merge_request.source_branch} into merge-test")
expect(page).to have_content("changed target branch from #{merge_request.target_branch} to merge-test")
diff --git a/spec/features/merge_request/user_edits_mr_spec.rb b/spec/features/merge_request/user_edits_mr_spec.rb
index 3152707136c..6a3b298037d 100644
--- a/spec/features/merge_request/user_edits_mr_spec.rb
+++ b/spec/features/merge_request/user_edits_mr_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User edits MR' do
+describe "Merge request > User edits MR" do
include ProjectForksHelper
- it_behaves_like 'an editable merge request'
+ it_behaves_like "an editable merge request"
- context 'for a forked project' do
- it_behaves_like 'an editable merge request' do
+ context "for a forked project" do
+ it_behaves_like "an editable merge request" do
let(:source_project) { fork_project(target_project, nil, repository: true) }
end
end
diff --git a/spec/features/merge_request/user_expands_diff_spec.rb b/spec/features/merge_request/user_expands_diff_spec.rb
index 3560b8d90bb..a950b977813 100644
--- a/spec/features/merge_request/user_expands_diff_spec.rb
+++ b/spec/features/merge_request/user_expands_diff_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User expands diff', :js do
+describe "User expands diff", :js do
let(:project) { create(:project, :public, :repository) }
- let(:merge_request) { create(:merge_request, source_branch: 'expand-collapse-files', source_project: project, target_project: project) }
+ let(:merge_request) { create(:merge_request, source_branch: "expand-collapse-files", source_project: project, target_project: project) }
before do
allow(Gitlab::Git::Diff).to receive(:size_limit).and_return(100.kilobytes)
@@ -13,14 +13,14 @@ describe 'User expands diff', :js do
wait_for_requests
end
- it 'allows user to expand diff' do
+ it "allows user to expand diff" do
page.within find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
- click_link 'Click to expand it.'
+ click_link "Click to expand it."
wait_for_requests
- expect(page).not_to have_content('Click to expand it.')
- expect(page).to have_selector('.code')
+ expect(page).not_to have_content("Click to expand it.")
+ expect(page).to have_selector(".code")
end
end
end
diff --git a/spec/features/merge_request/user_locks_discussion_spec.rb b/spec/features/merge_request/user_locks_discussion_spec.rb
index 76c759ab8d3..821f41c69c5 100644
--- a/spec/features/merge_request/user_locks_discussion_spec.rb
+++ b/spec/features/merge_request/user_locks_discussion_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User locks discussion', :js do
+describe "Merge request > User locks discussion", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -9,39 +9,39 @@ describe 'Merge request > User locks discussion', :js do
sign_in(user)
end
- context 'when the discussion is locked' do
+ context "when the discussion is locked" do
before do
merge_request.update_attribute(:discussion_locked, true)
end
- context 'when a user is a team member' do
+ context "when a user is a team member" do
before do
project.add_developer(user)
visit project_merge_request_path(project, merge_request)
end
- it 'the user can create a comment' do
- page.within('.issuable-discussion #notes .js-main-target-form') do
- fill_in 'note[note]', with: 'Some new comment'
- click_button 'Comment'
+ it "the user can create a comment" do
+ page.within(".issuable-discussion #notes .js-main-target-form") do
+ fill_in "note[note]", with: "Some new comment"
+ click_button "Comment"
end
wait_for_requests
- expect(find('.issuable-discussion #notes')).to have_content('Some new comment')
+ expect(find(".issuable-discussion #notes")).to have_content("Some new comment")
end
end
- context 'when a user is not a team member' do
+ context "when a user is not a team member" do
before do
visit project_merge_request_path(project, merge_request)
end
- it 'the user can not create a comment' do
- page.within('.js-vue-notes-event') do
- expect(page).not_to have_selector('js-main-target-form')
- expect(page.find('.issuable-note-warning'))
- .to have_content('This merge request is locked. Only project members can comment.')
+ it "the user can not create a comment" do
+ page.within(".js-vue-notes-event") do
+ expect(page).not_to have_selector("js-main-target-form")
+ expect(page.find(".issuable-note-warning"))
+ .to have_content("This merge request is locked. Only project members can comment.")
end
end
end
diff --git a/spec/features/merge_request/user_manages_subscription_spec.rb b/spec/features/merge_request/user_manages_subscription_spec.rb
index 68a835e7f77..a9ba5c0d23f 100644
--- a/spec/features/merge_request/user_manages_subscription_spec.rb
+++ b/spec/features/merge_request/user_manages_subscription_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User manages subscription', :js do
+describe "User manages subscription", :js do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) }
@@ -12,19 +12,19 @@ describe 'User manages subscription', :js do
visit(merge_request_path(merge_request))
end
- it 'toggles subscription' do
- page.within('.js-issuable-subscribe-button') do
- expect(page).to have_css 'button:not(.is-checked)'
- find('button:not(.is-checked)').click
+ it "toggles subscription" do
+ page.within(".js-issuable-subscribe-button") do
+ expect(page).to have_css "button:not(.is-checked)"
+ find("button:not(.is-checked)").click
wait_for_requests
- expect(page).to have_css 'button.is-checked'
- find('button.is-checked').click
+ expect(page).to have_css "button.is-checked"
+ find("button.is-checked").click
wait_for_requests
- expect(page).to have_css 'button:not(.is-checked)'
+ expect(page).to have_css "button:not(.is-checked)"
end
end
end
diff --git a/spec/features/merge_request/user_merges_immediately_spec.rb b/spec/features/merge_request/user_merges_immediately_spec.rb
index 84636ae355c..e341c853f27 100644
--- a/spec/features/merge_request/user_merges_immediately_spec.rb
+++ b/spec/features/merge_request/user_merges_immediately_spec.rb
@@ -1,22 +1,22 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge requests > User merges immediately', :js do
+describe "Merge requests > User merges immediately", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let!(:merge_request) do
create(:merge_request_with_diffs, source_project: project,
author: user,
- title: 'Bug NS-04',
+ title: "Bug NS-04",
head_pipeline: pipeline,
source_branch: pipeline.ref)
end
let(:pipeline) do
create(:ci_pipeline, project: project,
- ref: 'master',
- sha: project.repository.commit('master').id)
+ ref: "master",
+ sha: project.repository.commit("master").id)
end
- context 'when there is active pipeline for merge request' do
+ context "when there is active pipeline for merge request" do
before do
create(:ci_build, pipeline: pipeline)
project.add_maintainer(user)
@@ -24,16 +24,16 @@ describe 'Merge requests > User merges immediately', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'enables merge immediately' do
+ it "enables merge immediately" do
wait_for_requests
- page.within '.mr-widget-body' do
- find('.dropdown-toggle').click
+ page.within ".mr-widget-body" do
+ find(".dropdown-toggle").click
Sidekiq::Testing.fake! do
- click_link 'Merge immediately'
+ click_link "Merge immediately"
- expect(find('.accept-merge-request.btn-info')).to have_content('Merge in progress')
+ expect(find(".accept-merge-request.btn-info")).to have_content("Merge in progress")
wait_for_requests
end
diff --git a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb
index 8372b61f872..b82d17444a8 100644
--- a/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb
+++ b/spec/features/merge_request/user_merges_only_if_pipeline_succeeds_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User merges only if pipeline succeeds', :js do
+describe "Merge request > User merges only if pipeline succeeds", :js do
let(:merge_request) { create(:merge_request_with_diffs) }
let(:project) { merge_request.target_project }
@@ -9,135 +9,135 @@ describe 'Merge request > User merges only if pipeline succeeds', :js do
sign_in(merge_request.author)
end
- context 'project does not have CI enabled' do
- it 'allows MR to be merged' do
+ context "project does not have CI enabled" do
+ it "allows MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge'
+ expect(page).to have_button "Merge"
end
end
- context 'when project has CI enabled' do
+ context "when project has CI enabled" do
let!(:pipeline) do
create(:ci_empty_pipeline,
- project: project,
- sha: merge_request.diff_head_sha,
- ref: merge_request.source_branch,
- status: status, head_pipeline_of: merge_request)
+ project: project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch,
+ status: status, head_pipeline_of: merge_request)
end
- context 'when merge requests can only be merged if the pipeline succeeds' do
+ context "when merge requests can only be merged if the pipeline succeeds" do
before do
project.update_attribute(:only_allow_merge_if_pipeline_succeeds, true)
end
- context 'when CI is running' do
+ context "when CI is running" do
let(:status) { :running }
- it 'does not allow to merge immediately' do
+ it "does not allow to merge immediately" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge when pipeline succeeds'
- expect(page).not_to have_button '.js-merge-moment'
+ expect(page).to have_button "Merge when pipeline succeeds"
+ expect(page).not_to have_button ".js-merge-moment"
end
end
- context 'when CI failed' do
+ context "when CI failed" do
let(:status) { :failed }
- it 'does not allow MR to be merged' do
+ it "does not allow MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_css('button[disabled="disabled"]', text: 'Merge')
- expect(page).to have_content('Please retry the job or push a new commit to fix the failure')
+ expect(page).to have_css('button[disabled="disabled"]', text: "Merge")
+ expect(page).to have_content("Please retry the job or push a new commit to fix the failure")
end
end
- context 'when CI canceled' do
+ context "when CI canceled" do
let(:status) { :canceled }
- it 'does not allow MR to be merged' do
+ it "does not allow MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).not_to have_button 'Merge'
- expect(page).to have_content('Please retry the job or push a new commit to fix the failure')
+ expect(page).not_to have_button "Merge"
+ expect(page).to have_content("Please retry the job or push a new commit to fix the failure")
end
end
- context 'when CI succeeded' do
+ context "when CI succeeded" do
let(:status) { :success }
- it 'allows MR to be merged' do
+ it "allows MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge'
+ expect(page).to have_button "Merge"
end
end
- context 'when CI skipped' do
+ context "when CI skipped" do
let(:status) { :skipped }
- it 'allows MR to be merged' do
+ it "allows MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge'
+ expect(page).to have_button "Merge"
end
end
end
- context 'when merge requests can be merged when the build failed' do
+ context "when merge requests can be merged when the build failed" do
before do
project.update_attribute(:only_allow_merge_if_pipeline_succeeds, false)
end
- context 'when CI is running' do
+ context "when CI is running" do
let(:status) { :running }
- it 'allows MR to be merged immediately' do
+ it "allows MR to be merged immediately" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge when pipeline succeeds'
+ expect(page).to have_button "Merge when pipeline succeeds"
- page.find('.js-merge-moment').click
- expect(page).to have_content 'Merge immediately'
+ page.find(".js-merge-moment").click
+ expect(page).to have_content "Merge immediately"
end
end
- context 'when CI failed' do
+ context "when CI failed" do
let(:status) { :failed }
- it 'allows MR to be merged' do
+ it "allows MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge'
+ expect(page).to have_button "Merge"
end
end
- context 'when CI succeeded' do
+ context "when CI succeeded" do
let(:status) { :success }
- it 'allows MR to be merged' do
+ it "allows MR to be merged" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_button 'Merge'
+ expect(page).to have_button "Merge"
end
end
end
diff --git a/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb
index 6e54aa6006b..fd3b740f055 100644
--- a/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb
+++ b/spec/features/merge_request/user_merges_when_pipeline_succeeds_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User merges when pipeline succeeds', :js do
+describe "Merge request > User merges when pipeline succeeds", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) do
create(:merge_request_with_diffs, source_project: project,
author: user,
- title: 'Bug NS-04',
- merge_params: { force_remove_source_branch: '1' })
+ title: "Bug NS-04",
+ merge_params: {force_remove_source_branch: "1"})
end
let(:pipeline) do
create(:ci_pipeline, project: project,
@@ -20,16 +20,16 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
project.add_maintainer(user)
end
- context 'when there is active pipeline for merge request' do
+ context "when there is active pipeline for merge request" do
before do
create(:ci_build, pipeline: pipeline)
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- describe 'enabling Merge when pipeline succeeds' do
- shared_examples 'Merge when pipeline succeeds activator' do
- it 'activates the Merge when pipeline succeeds feature' do
+ describe "enabling Merge when pipeline succeeds" do
+ shared_examples "Merge when pipeline succeeds activator" do
+ it "activates the Merge when pipeline succeeds feature" do
click_button "Merge when pipeline succeeds"
expect(page).to have_content "Set by #{user.name} to be merged automatically when the pipeline succeeds"
@@ -41,10 +41,10 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
end
context "when enabled immediately" do
- it_behaves_like 'Merge when pipeline succeeds activator'
+ it_behaves_like "Merge when pipeline succeeds activator"
end
- context 'when enabled after pipeline status changed' do
+ context "when enabled after pipeline status changed" do
before do
pipeline.run!
@@ -55,43 +55,43 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
expect(page).to have_content "Pipeline ##{pipeline.id} running"
end
- it_behaves_like 'Merge when pipeline succeeds activator'
+ it_behaves_like "Merge when pipeline succeeds activator"
end
- context 'when enabled after it was previously canceled' do
+ context "when enabled after it was previously canceled" do
before do
click_button "Merge when pipeline succeeds"
click_link "Cancel automatic merge"
end
- it_behaves_like 'Merge when pipeline succeeds activator'
+ it_behaves_like "Merge when pipeline succeeds activator"
end
- context 'when it was enabled and then canceled' do
+ context "when it was enabled and then canceled" do
let(:merge_request) do
create(:merge_request_with_diffs,
- :merge_when_pipeline_succeeds,
- source_project: project,
- title: 'Bug NS-04',
- author: user,
- merge_user: user,
- merge_params: { force_remove_source_branch: '1' })
+ :merge_when_pipeline_succeeds,
+ source_project: project,
+ title: "Bug NS-04",
+ author: user,
+ merge_user: user,
+ merge_params: {force_remove_source_branch: "1"})
end
before do
click_link "Cancel automatic merge"
end
- it_behaves_like 'Merge when pipeline succeeds activator'
+ it_behaves_like "Merge when pipeline succeeds activator"
end
end
- describe 'enabling Merge when pipeline succeeds via dropdown' do
- it 'activates the Merge when pipeline succeeds feature' do
+ describe "enabling Merge when pipeline succeeds via dropdown" do
+ it "activates the Merge when pipeline succeeds feature" do
wait_for_requests
- find('.js-merge-moment').click
- click_link 'Merge when pipeline succeeds'
+ find(".js-merge-moment").click
+ click_link "Merge when pipeline succeeds"
expect(page).to have_content "Set by #{user.name} to be merged automatically when the pipeline succeeds"
expect(page).to have_content "The source branch will not be deleted"
@@ -100,12 +100,12 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
end
end
- context 'when merge when pipeline succeeds is enabled' do
+ context "when merge when pipeline succeeds is enabled" do
let(:merge_request) do
create(:merge_request_with_diffs, :simple, source_project: project,
author: user,
merge_user: user,
- title: 'MepMep',
+ title: "MepMep",
merge_when_pipeline_succeeds: true)
end
let!(:build) do
@@ -117,7 +117,7 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'allows to cancel the automatic merge' do
+ it "allows to cancel the automatic merge" do
click_link "Cancel automatic merge"
expect(page).to have_button "Merge when pipeline succeeds"
@@ -127,68 +127,68 @@ describe 'Merge request > User merges when pipeline succeeds', :js do
expect(page).to have_content "canceled the automatic merge"
end
- it 'allows to delete source branch' do
+ it "allows to delete source branch" do
click_link "Delete source branch"
expect(page).to have_content "The source branch will be deleted"
end
- context 'when pipeline succeeds' do
+ context "when pipeline succeeds" do
before do
build.success
refresh
end
- it 'merges merge request' do
- expect(page).to have_content 'The changes were merged'
+ it "merges merge request" do
+ expect(page).to have_content "The changes were merged"
expect(merge_request.reload).to be_merged
end
end
- context 'view merge request with MWPS enabled but automatically merge fails' do
+ context "view merge request with MWPS enabled but automatically merge fails" do
before do
merge_request.update(
merge_user: merge_request.author,
- merge_error: 'Something went wrong'
+ merge_error: "Something went wrong"
)
refresh
end
- it 'shows information about the merge error' do
+ it "shows information about the merge error" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- page.within('.mr-widget-body') do
- expect(page).to have_content('Something went wrong')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Something went wrong")
end
end
end
- context 'view merge request with MWPS enabled but automatically merge fails' do
+ context "view merge request with MWPS enabled but automatically merge fails" do
before do
merge_request.update(
merge_user: merge_request.author,
- merge_error: 'Something went wrong'
+ merge_error: "Something went wrong"
)
refresh
end
- it 'shows information about the merge error' do
+ it "shows information about the merge error" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- page.within('.mr-widget-body') do
- expect(page).to have_content('Something went wrong')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Something went wrong")
end
end
end
end
- context 'when pipeline is not active' do
- it 'does not allow to enable merge when pipeline succeeds' do
+ context "when pipeline is not active" do
+ it "does not allow to enable merge when pipeline succeeds" do
visit project_merge_request_path(project, merge_request)
- expect(page).not_to have_link 'Merge when pipeline succeeds'
+ expect(page).not_to have_link "Merge when pipeline succeeds"
end
end
end
diff --git a/spec/features/merge_request/user_posts_diff_notes_spec.rb b/spec/features/merge_request/user_posts_diff_notes_spec.rb
index 19edce1b562..2721f2a4b46 100644
--- a/spec/features/merge_request/user_posts_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_diff_notes_spec.rb
@@ -1,146 +1,146 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User posts diff notes', :js do
+describe "Merge request > User posts diff notes", :js do
include MergeRequestDiffHelpers
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.source_project }
let(:user) { project.creator }
- let(:comment_button_class) { '.add-diff-note' }
- let(:notes_holder_input_class) { 'js-temp-notes-holder' }
+ let(:comment_button_class) { ".add-diff-note" }
+ let(:notes_holder_input_class) { "js-temp-notes-holder" }
let(:notes_holder_input_xpath) { './following-sibling::*[contains(concat(" ", @class, " "), " notes_holder ")]' }
- let(:test_note_comment) { 'this is a test note!' }
+ let(:test_note_comment) { "this is a test note!" }
before do
- set_cookie('sidebar_collapsed', 'true')
+ set_cookie("sidebar_collapsed", "true")
project.add_developer(user)
sign_in(user)
end
- context 'when hovering over a parallel view diff file' do
+ context "when hovering over a parallel view diff file" do
before do
- visit diffs_project_merge_request_path(project, merge_request, view: 'parallel')
+ visit diffs_project_merge_request_path(project, merge_request, view: "parallel")
end
- context 'with an old line on the left and no line on the right' do
- it 'allows commenting on the left side' do
- should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, '..'), 'left')
+ context "with an old line on the left and no line on the right" do
+ it "allows commenting on the left side" do
+ should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, ".."), "left")
end
- it 'does not allow commenting on the right side' do
- should_not_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, '..'), 'right')
+ it "does not allow commenting on the right side" do
+ should_not_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_23_22"]').find(:xpath, ".."), "right")
end
end
- context 'with no line on the left and a new line on the right' do
- it 'does not allow commenting on the left side' do
- should_not_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'left')
+ context "with no line on the left and a new line on the right" do
+ it "does not allow commenting on the left side" do
+ should_not_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, ".."), "left")
end
- it 'allows commenting on the right side' do
- should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, '..'), 'right')
+ it "allows commenting on the right side" do
+ should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_15"]').find(:xpath, ".."), "right")
end
end
- context 'with an old line on the left and a new line on the right' do
- it 'allows commenting on the left side' do
- should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'left')
+ context "with an old line on the left and a new line on the right" do
+ it "allows commenting on the left side" do
+ should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, ".."), "left")
end
- it 'allows commenting on the right side' do
- should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, '..'), 'right')
+ it "allows commenting on the right side" do
+ should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_9_9"]').find(:xpath, ".."), "right")
end
end
- context 'with an unchanged line on the left and an unchanged line on the right' do
- it 'allows commenting on the left side' do
- should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'left')
+ context "with an unchanged line on the left and an unchanged line on the right" do
+ it "allows commenting on the left side" do
+ should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, ".."), "left")
end
- it 'allows commenting on the right side' do
- should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, '..'), 'right')
+ it "allows commenting on the right side" do
+ should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]', match: :first).find(:xpath, ".."), "right")
end
end
- context 'with a match line' do
- it 'does not allow commenting on the left side' do
- line_holder = find('.match', match: :first).find(:xpath, '..')
- should_not_allow_commenting(line_holder, 'left')
+ context "with a match line" do
+ it "does not allow commenting on the left side" do
+ line_holder = find(".match", match: :first).find(:xpath, "..")
+ should_not_allow_commenting(line_holder, "left")
end
- it 'does not allow commenting on the right side' do
- line_holder = find('.match', match: :first).find(:xpath, '..')
- should_not_allow_commenting(line_holder, 'right')
+ it "does not allow commenting on the right side" do
+ line_holder = find(".match", match: :first).find(:xpath, "..")
+ should_not_allow_commenting(line_holder, "right")
end
end
- context 'with an unfolded line' do
+ context "with an unfolded line" do
before do
- find('.js-unfold', match: :first).click
+ find(".js-unfold", match: :first).click
wait_for_requests
end
# The first `.js-unfold` unfolds upwards, therefore the first
# `.line_holder` will be an unfolded line.
- let(:line_holder) { first('#a5cc2925ca8258af241be7e5b0381edf30266302 .line_holder') }
+ let(:line_holder) { first("#a5cc2925ca8258af241be7e5b0381edf30266302 .line_holder") }
- it 'allows commenting on the left side' do
- should_allow_commenting(line_holder, 'left')
+ it "allows commenting on the left side" do
+ should_allow_commenting(line_holder, "left")
end
- it 'allows commenting on the right side' do
+ it "allows commenting on the right side" do
# Automatically shifts comment box to left side.
- should_allow_commenting(line_holder, 'right')
+ should_allow_commenting(line_holder, "right")
end
end
end
- context 'when hovering over an inline view diff file' do
+ context "when hovering over an inline view diff file" do
before do
- visit diffs_project_merge_request_path(project, merge_request, view: 'inline')
+ visit diffs_project_merge_request_path(project, merge_request, view: "inline")
end
- context 'after deleteing a note' do
- it 'allows commenting' do
+ context "after deleteing a note" do
+ it "allows commenting" do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
accept_confirm do
- first('button.more-actions-toggle').click
- first('.js-note-delete').click
+ first("button.more-actions-toggle").click
+ first(".js-note-delete").click
end
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
end
end
- context 'with a new line' do
- it 'allows commenting' do
+ context "with a new line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
end
end
- context 'with an old line' do
- it 'allows commenting' do
+ context "with an old line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'))
end
end
- context 'with an unchanged line' do
- it 'allows commenting' do
+ context "with an unchanged line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'))
end
end
- context 'with a match line' do
- it 'does not allow commenting' do
- should_not_allow_commenting(find('.match', match: :first))
+ context "with a match line" do
+ it "does not allow commenting" do
+ should_not_allow_commenting(find(".match", match: :first))
end
end
- context 'with an unfolded line' do
+ context "with an unfolded line" do
before do
- find('.js-unfold', match: :first).click
+ find(".js-unfold", match: :first).click
wait_for_requests
end
@@ -148,79 +148,79 @@ describe 'Merge request > User posts diff notes', :js do
# `.line_holder` will be an unfolded line.
let(:line_holder) { first('.line_holder[id="a5cc2925ca8258af241be7e5b0381edf30266302_1_1"]') }
- it 'allows commenting' do
+ it "allows commenting" do
should_allow_commenting line_holder
end
end
- context 'when hovering over a diff discussion' do
+ context "when hovering over a diff discussion" do
before do
- visit diffs_project_merge_request_path(project, merge_request, view: 'inline')
+ visit diffs_project_merge_request_path(project, merge_request, view: "inline")
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'))
visit project_merge_request_path(project, merge_request)
end
- it 'does not allow commenting' do
- should_not_allow_commenting(find('.line_holder', match: :first))
+ it "does not allow commenting" do
+ should_not_allow_commenting(find(".line_holder", match: :first))
end
end
end
- context 'when cancelling the comment addition' do
+ context "when cancelling the comment addition" do
before do
- visit diffs_project_merge_request_path(project, merge_request, view: 'inline')
+ visit diffs_project_merge_request_path(project, merge_request, view: "inline")
end
- context 'with a new line' do
- it 'allows dismissing a comment' do
+ context "with a new line" do
+ it "allows dismissing a comment" do
should_allow_dismissing_a_comment(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
end
end
end
- describe 'with multiple note forms' do
+ describe "with multiple note forms" do
before do
- visit diffs_project_merge_request_path(project, merge_request, view: 'inline')
+ visit diffs_project_merge_request_path(project, merge_request, view: "inline")
click_diff_line(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
click_diff_line(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'))
end
- describe 'posting a note' do
- it 'adds as discussion' do
+ describe "posting a note" do
+ it "adds as discussion" do
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'), asset_form_reset: false)
- expect(page).to have_css('.notes_holder .note.note-discussion', count: 1)
- expect(page).to have_button('Reply...')
+ expect(page).to have_css(".notes_holder .note.note-discussion", count: 1)
+ expect(page).to have_button("Reply...")
end
end
end
- context 'when the MR only supports legacy diff notes' do
+ context "when the MR only supports legacy diff notes" do
before do
merge_request.merge_request_diff.update(start_commit_sha: nil)
- visit diffs_project_merge_request_path(project, merge_request, view: 'inline')
+ visit diffs_project_merge_request_path(project, merge_request, view: "inline")
end
- context 'with a new line' do
- it 'allows commenting' do
+ context "with a new line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]'))
end
end
- context 'with an old line' do
- it 'allows commenting' do
+ context "with an old line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]'))
end
end
- context 'with an unchanged line' do
- it 'allows commenting' do
+ context "with an unchanged line" do
+ it "allows commenting" do
should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]'))
end
end
- context 'with a match line' do
- it 'does not allow commenting' do
- should_not_allow_commenting(find('.match', match: :first))
+ context "with a match line" do
+ it "does not allow commenting" do
+ should_not_allow_commenting(find(".match", match: :first))
end
end
end
@@ -228,7 +228,7 @@ describe 'Merge request > User posts diff notes', :js do
def should_allow_commenting(line_holder, diff_side = nil, asset_form_reset: true)
write_comment_on_line(line_holder, diff_side)
- click_button 'Comment'
+ click_button "Comment"
wait_for_requests
@@ -238,7 +238,7 @@ describe 'Merge request > User posts diff notes', :js do
def should_allow_dismissing_a_comment(line_holder, diff_side = nil)
write_comment_on_line(line_holder, diff_side)
- find('.js-close-discussion-note-form').click
+ find(".js-close-discussion-note-form").click
assert_comment_dismissal(line_holder)
end
@@ -256,13 +256,13 @@ describe 'Merge request > User posts diff notes', :js do
expect(notes_holder_input[:class]).to include(notes_holder_input_class)
- notes_holder_input.fill_in 'note[note]', with: test_note_comment
+ notes_holder_input.fill_in "note[note]", with: test_note_comment
end
def assert_comment_persistence(line_holder, asset_form_reset:)
notes_holder_saved = line_holder.find(:xpath, notes_holder_input_xpath)
- expect(notes_holder_saved[:class]).not_to include('note-edit-form')
+ expect(notes_holder_saved[:class]).not_to include("note-edit-form")
expect(notes_holder_saved).to have_content test_note_comment
assert_form_is_reset if asset_form_reset
@@ -276,6 +276,6 @@ describe 'Merge request > User posts diff notes', :js do
end
def assert_form_is_reset
- expect(page).to have_no_css('.note-edit-form')
+ expect(page).to have_no_css(".note-edit-form")
end
end
diff --git a/spec/features/merge_request/user_posts_notes_spec.rb b/spec/features/merge_request/user_posts_notes_spec.rb
index 1bbcf455ac7..2fdc95ded69 100644
--- a/spec/features/merge_request/user_posts_notes_spec.rb
+++ b/spec/features/merge_request/user_posts_notes_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User posts notes', :js do
+describe "Merge request > User posts notes", :js do
include NoteInteractionHelpers
let(:project) { create(:project, :repository) }
@@ -21,176 +21,176 @@ describe 'Merge request > User posts notes', :js do
subject { page }
- describe 'the note form' do
- it 'is valid' do
- is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
- expect(find('.js-main-target-form')).to have_selector('button', text: 'Comment')
- page.within('.js-main-target-form') do
- expect(page).not_to have_button('Cancel')
+ describe "the note form" do
+ it "is valid" do
+ is_expected.to have_css(".js-main-target-form", visible: true, count: 1)
+ expect(find(".js-main-target-form")).to have_selector("button", text: "Comment")
+ page.within(".js-main-target-form") do
+ expect(page).not_to have_button("Cancel")
end
end
- describe 'with text' do
+ describe "with text" do
before do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: 'This is awesome'
+ page.within(".js-main-target-form") do
+ fill_in "note[note]", with: "This is awesome"
end
end
- 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)
+ 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)
end
end
end
end
- describe 'when posting a note' do
+ describe "when posting a note" do
before do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: 'This is awesome!'
- find('.js-md-preview-button').click
- click_button 'Comment'
+ page.within(".js-main-target-form") do
+ fill_in "note[note]", with: "This is awesome!"
+ find(".js-md-preview-button").click
+ click_button "Comment"
end
end
- it 'is added and form reset' do
- is_expected.to have_content('This is awesome!')
- page.within('.js-main-target-form') do
- expect(page).to have_no_field('note[note]', with: 'This is awesome!')
- expect(page).to have_css('.js-vue-md-preview', visible: :hidden)
+ it "is added and form reset" do
+ is_expected.to have_content("This is awesome!")
+ page.within(".js-main-target-form") do
+ expect(page).to have_no_field("note[note]", with: "This is awesome!")
+ expect(page).to have_css(".js-vue-md-preview", visible: :hidden)
end
wait_for_requests
- page.within('.js-main-target-form') do
- is_expected.to have_css('.js-note-text', visible: true)
+ page.within(".js-main-target-form") do
+ is_expected.to have_css(".js-note-text", visible: true)
end
end
- describe 'when reply_to_individual_notes feature flag is not set' do
+ describe "when reply_to_individual_notes feature flag is not set" do
before do
stub_feature_flags(reply_to_individual_notes: false)
visit project_merge_request_path(project, merge_request)
end
- it 'does not show a reply button' do
- expect(page).to have_no_selector('.js-reply-button')
+ it "does not show a reply button" do
+ expect(page).to have_no_selector(".js-reply-button")
end
end
- describe 'when reply_to_individual_notes feature flag is set' do
+ describe "when reply_to_individual_notes feature flag is set" do
before do
stub_feature_flags(reply_to_individual_notes: true)
visit project_merge_request_path(project, merge_request)
end
- it 'shows a reply button' do
- reply_button = find('.js-reply-button', match: :first)
+ it "shows a reply button" do
+ reply_button = find(".js-reply-button", match: :first)
- expect(reply_button).to have_selector('.ic-comment')
+ expect(reply_button).to have_selector(".ic-comment")
end
- it 'shows reply placeholder when clicking reply button' do
- reply_button = find('.js-reply-button', match: :first)
+ it "shows reply placeholder when clicking reply button" do
+ reply_button = find(".js-reply-button", match: :first)
reply_button.click
- expect(page).to have_selector('.discussion-reply-holder')
+ expect(page).to have_selector(".discussion-reply-holder")
end
end
end
- describe 'when previewing a note' do
- it 'shows the toolbar buttons when editing a note' do
- page.within('.js-main-target-form') do
- expect(page).to have_css('.md-header-toolbar.active')
+ describe "when previewing a note" do
+ it "shows the toolbar buttons when editing a note" do
+ page.within(".js-main-target-form") do
+ expect(page).to have_css(".md-header-toolbar.active")
end
end
- it 'hides the toolbar buttons when previewing a note' do
+ it "hides the toolbar buttons when previewing a note" do
wait_for_requests
- find('.js-md-preview-button').click
- page.within('.js-main-target-form') do
- expect(page).not_to have_css('.md-header-toolbar.active')
+ find(".js-md-preview-button").click
+ page.within(".js-main-target-form") do
+ expect(page).not_to have_css(".md-header-toolbar.active")
end
end
end
- describe 'when editing a note' do
- describe 'editing the note' do
+ describe "when editing a note" do
+ describe "editing the note" do
before do
- find('.note').hover
+ find(".note").hover
- find('.js-note-edit').click
+ find(".js-note-edit").click
end
- it 'shows 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
- expect(find(:css, '.note-body > .note-text', visible: false)).not_to be_visible
+ expect(find(".current-note-edit-form", visible: true)).to be_visible
+ expect(find(".note-edit-form", visible: true)).to be_visible
+ expect(find(:css, ".note-body > .note-text", visible: false)).not_to be_visible
end
end
- it 'resets the edit note form textarea with the original content of the note if cancelled' do
- within('.current-note-edit-form') do
- fill_in 'note[note]', with: 'Some new content'
- find('.btn-cancel').click
+ it "resets the edit note form textarea with the original content of the note if cancelled" do
+ within(".current-note-edit-form") do
+ fill_in "note[note]", with: "Some new content"
+ find(".btn-cancel").click
end
- expect(find('.js-note-text').text).to eq ''
+ expect(find(".js-note-text").text).to eq ""
end
- it 'allows using markdown buttons after saving a note and then trying to edit it again' do
- page.within('.current-note-edit-form') do
- fill_in 'note[note]', with: 'This is the new content'
- find('.btn-success').click
+ it "allows using markdown buttons after saving a note and then trying to edit it again" do
+ page.within(".current-note-edit-form") do
+ fill_in "note[note]", with: "This is the new content"
+ find(".btn-success").click
end
- find('.note').hover
+ find(".note").hover
wait_for_requests
- find('.js-note-edit').click
+ find(".js-note-edit").click
- page.within('.current-note-edit-form') do
- expect(find('#note_note').value).to eq('This is the new content')
- find('.js-md:first-child').click
- expect(find('#note_note').value).to eq('This is the new content****')
+ page.within(".current-note-edit-form") do
+ expect(find("#note_note").value).to eq("This is the new content")
+ find(".js-md:first-child").click
+ expect(find("#note_note").value).to eq("This is the new content****")
end
end
- it 'appends the edited at time to the note' do
- page.within('.current-note-edit-form') do
- fill_in 'note[note]', with: 'Some new content'
- find('.btn-success').click
+ it "appends the edited at time to the note" do
+ page.within(".current-note-edit-form") do
+ fill_in "note[note]", with: "Some new content"
+ find(".btn-success").click
end
page.within("#note_#{note.id}") do
- is_expected.to have_css('.note_edited_ago')
- expect(find('.note_edited_ago').text)
+ is_expected.to have_css(".note_edited_ago")
+ expect(find(".note_edited_ago").text)
.to match(/just now/)
end
end
end
- describe 'deleting attachment on legacy diff note' do
+ describe "deleting attachment on legacy diff note" do
before do
- find('.note').hover
+ find(".note").hover
- find('.js-note-edit').click
+ find(".js-note-edit").click
end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
- xit 'shows the delete link' do
- page.within('.note-attachment') do
- is_expected.to have_css('.js-note-attachment-delete')
+ xit "shows the delete link" do
+ page.within(".note-attachment") do
+ is_expected.to have_css(".js-note-attachment-delete")
end
end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
- xit 'removes the attachment div and resets the edit form' do
- accept_confirm { find('.js-note-attachment-delete').click }
- is_expected.not_to have_css('.note-attachment')
- is_expected.not_to have_css('.current-note-edit-form')
+ xit "removes the attachment div and resets the edit form" do
+ accept_confirm { find(".js-note-attachment-delete").click }
+ is_expected.not_to have_css(".note-attachment")
+ is_expected.not_to have_css(".current-note-edit-form")
wait_for_requests
end
end
diff --git a/spec/features/merge_request/user_reopens_merge_request_spec.rb b/spec/features/merge_request/user_reopens_merge_request_spec.rb
index 745b4537e72..472982803f0 100644
--- a/spec/features/merge_request/user_reopens_merge_request_spec.rb
+++ b/spec/features/merge_request/user_reopens_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User reopens a merge requests', :js do
+describe "User reopens a merge requests", :js do
let(:project) { create(:project, :public, :repository) }
let!(:merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) }
@@ -12,11 +12,11 @@ describe 'User reopens a merge requests', :js do
visit(merge_request_path(merge_request))
end
- it 'reopens a merge request' do
- click_link('Reopen merge request', match: :first)
+ it "reopens a merge request" do
+ click_link("Reopen merge request", match: :first)
- page.within('.status-box') do
- expect(page).to have_content('Open')
+ page.within(".status-box") do
+ expect(page).to have_content("Open")
end
end
end
diff --git a/spec/features/merge_request/user_resolves_conflicts_spec.rb b/spec/features/merge_request/user_resolves_conflicts_spec.rb
index 16c058ab6bd..48f591bab0f 100644
--- a/spec/features/merge_request/user_resolves_conflicts_spec.rb
+++ b/spec/features/merge_request/user_resolves_conflicts_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User resolves conflicts', :js do
+describe "Merge request > User resolves conflicts", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
@@ -10,114 +10,114 @@ describe 'Merge request > User resolves conflicts', :js do
end
def create_merge_request(source_branch)
- create(:merge_request, source_branch: source_branch, target_branch: 'conflict-start', source_project: project, merge_status: :unchecked) do |mr|
+ create(:merge_request, source_branch: source_branch, target_branch: "conflict-start", source_project: project, merge_status: :unchecked) do |mr|
mr.mark_as_unmergeable
end
end
shared_examples "conflicts are resolved in Interactive mode" do
- it 'conflicts are resolved in Interactive mode' do
- within find('.files-wrapper .diff-file', text: 'files/ruby/popen.rb') do
- click_button 'Use ours'
+ it "conflicts are resolved in Interactive mode" do
+ within find(".files-wrapper .diff-file", text: "files/ruby/popen.rb") do
+ click_button "Use ours"
end
- within find('.files-wrapper .diff-file', text: 'files/ruby/regex.rb') do
- all('button', text: 'Use ours').each do |button|
+ within find(".files-wrapper .diff-file", text: "files/ruby/regex.rb") do
+ all("button", text: "Use ours").each do |button|
button.send_keys(:return)
end
end
- find_button('Commit to source branch').send_keys(:return)
+ find_button("Commit to source branch").send_keys(:return)
- expect(page).to have_content('All merge conflicts were resolved')
+ expect(page).to have_content("All merge conflicts were resolved")
merge_request.reload_diff
wait_for_requests
- click_on 'Changes'
+ click_on "Changes"
wait_for_requests
- find('.js-toggle-tree-list').click
+ find(".js-toggle-tree-list").click
- within find('.diff-file', text: 'files/ruby/popen.rb') do
- expect(page).to have_selector('.line_content.new', text: "vars = { 'PWD' => path }")
- expect(page).to have_selector('.line_content.new', text: "options = { chdir: path }")
+ within find(".diff-file", text: "files/ruby/popen.rb") do
+ expect(page).to have_selector(".line_content.new", text: "vars = { 'PWD' => path }")
+ expect(page).to have_selector(".line_content.new", text: "options = { chdir: path }")
end
- within find('.diff-file', text: 'files/ruby/regex.rb') do
- expect(page).to have_selector('.line_content.new', text: "def username_regexp")
- expect(page).to have_selector('.line_content.new', text: "def project_name_regexp")
- expect(page).to have_selector('.line_content.new', text: "def path_regexp")
- expect(page).to have_selector('.line_content.new', text: "def archive_formats_regexp")
- expect(page).to have_selector('.line_content.new', text: "def git_reference_regexp")
- expect(page).to have_selector('.line_content.new', text: "def default_regexp")
+ within find(".diff-file", text: "files/ruby/regex.rb") do
+ expect(page).to have_selector(".line_content.new", text: "def username_regexp")
+ expect(page).to have_selector(".line_content.new", text: "def project_name_regexp")
+ expect(page).to have_selector(".line_content.new", text: "def path_regexp")
+ expect(page).to have_selector(".line_content.new", text: "def archive_formats_regexp")
+ expect(page).to have_selector(".line_content.new", text: "def git_reference_regexp")
+ expect(page).to have_selector(".line_content.new", text: "def default_regexp")
end
end
end
shared_examples "conflicts are resolved in Edit inline mode" do
- it 'conflicts are resolved in Edit inline mode' do
- expect(find('#conflicts')).to have_content('popen.rb')
+ it "conflicts are resolved in Edit inline mode" do
+ expect(find("#conflicts")).to have_content("popen.rb")
- within find('.files-wrapper .diff-file', text: 'files/ruby/popen.rb') do
- click_button 'Edit inline'
+ within find(".files-wrapper .diff-file", text: "files/ruby/popen.rb") do
+ click_button "Edit inline"
wait_for_requests
- find('.files-wrapper .diff-file pre')
+ find(".files-wrapper .diff-file pre")
execute_script('ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("One morning");')
end
- within find('.files-wrapper .diff-file', text: 'files/ruby/regex.rb') do
- click_button 'Edit inline'
+ within find(".files-wrapper .diff-file", text: "files/ruby/regex.rb") do
+ click_button "Edit inline"
wait_for_requests
- find('.files-wrapper .diff-file pre')
+ find(".files-wrapper .diff-file pre")
execute_script('ace.edit($(".files-wrapper .diff-file pre")[1]).setValue("Gregor Samsa woke from troubled dreams");')
end
- find_button('Commit to source branch').send_keys(:return)
+ find_button("Commit to source branch").send_keys(:return)
- expect(page).to have_content('All merge conflicts were resolved')
+ expect(page).to have_content("All merge conflicts were resolved")
merge_request.reload_diff
wait_for_requests
- click_on 'Changes'
+ click_on "Changes"
wait_for_requests
- expect(page).to have_content('One morning')
- expect(page).to have_content('Gregor Samsa woke from troubled dreams')
+ expect(page).to have_content("One morning")
+ expect(page).to have_content("Gregor Samsa woke from troubled dreams")
end
end
- context 'can be resolved in the UI' do
+ context "can be resolved in the UI" do
before do
project.add_developer(user)
sign_in(user)
end
- context 'the conflicts are resolvable' do
- let(:merge_request) { create_merge_request('conflict-resolvable') }
+ context "the conflicts are resolvable" do
+ let(:merge_request) { create_merge_request("conflict-resolvable") }
before do
visit project_merge_request_path(project, merge_request)
end
- it 'shows a link to the conflict resolution page' do
- expect(page).to have_link('conflicts', href: %r{/conflicts\Z})
+ it "shows a link to the conflict resolution page" do
+ expect(page).to have_link("conflicts", href: %r{/conflicts\Z})
end
- context 'in Inline view mode' do
+ context "in Inline view mode" do
before do
- click_link('conflicts', href: %r{/conflicts\Z})
+ click_link("conflicts", href: %r{/conflicts\Z})
end
include_examples "conflicts are resolved in Interactive mode"
include_examples "conflicts are resolved in Edit inline mode"
end
- context 'in Parallel view mode' do
+ context "in Parallel view mode" do
before do
- click_link('conflicts', href: %r{/conflicts\Z})
- click_button 'Side-by-side'
+ click_link("conflicts", href: %r{/conflicts\Z})
+ click_button "Side-by-side"
end
include_examples "conflicts are resolved in Interactive mode"
@@ -125,52 +125,52 @@ describe 'Merge request > User resolves conflicts', :js do
end
end
- context 'the conflict contain markers' do
- let(:merge_request) { create_merge_request('conflict-contains-conflict-markers') }
+ context "the conflict contain markers" do
+ let(:merge_request) { create_merge_request("conflict-contains-conflict-markers") }
before do
visit project_merge_request_path(project, merge_request)
- click_link('conflicts', href: %r{/conflicts\Z})
+ click_link("conflicts", href: %r{/conflicts\Z})
end
- it 'conflicts can not be resolved in Interactive mode' do
- within find('.files-wrapper .diff-file', text: 'files/markdown/ruby-style-guide.md') do
- expect(page).not_to have_content 'Interactive mode'
- expect(page).not_to have_content 'Edit inline'
+ it "conflicts can not be resolved in Interactive mode" do
+ within find(".files-wrapper .diff-file", text: "files/markdown/ruby-style-guide.md") do
+ expect(page).not_to have_content "Interactive mode"
+ expect(page).not_to have_content "Edit inline"
end
end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
- xit 'conflicts are resolved in Edit inline mode' do
- within find('.files-wrapper .diff-file', text: 'files/markdown/ruby-style-guide.md') do
+ xit "conflicts are resolved in Edit inline mode" do
+ within find(".files-wrapper .diff-file", text: "files/markdown/ruby-style-guide.md") do
wait_for_requests
- find('.files-wrapper .diff-file pre')
+ find(".files-wrapper .diff-file pre")
execute_script('ace.edit($(".files-wrapper .diff-file pre")[0]).setValue("Gregor Samsa woke from troubled dreams");')
end
- click_button 'Commit to source branch'
+ click_button "Commit to source branch"
- expect(page).to have_content('All merge conflicts were resolved')
+ expect(page).to have_content("All merge conflicts were resolved")
merge_request.reload_diff
wait_for_requests
- click_on 'Changes'
+ click_on "Changes"
wait_for_requests
- click_link 'Expand all'
+ click_link "Expand all"
wait_for_requests
- expect(page).to have_content('Gregor Samsa woke from troubled dreams')
+ expect(page).to have_content("Gregor Samsa woke from troubled dreams")
end
end
end
UNRESOLVABLE_CONFLICTS = {
- 'conflict-too-large' => 'when the conflicts contain a large file',
- 'conflict-binary-file' => 'when the conflicts contain a binary file',
- 'conflict-missing-side' => 'when the conflicts contain a file edited in one branch and deleted in another',
- 'conflict-non-utf8' => 'when the conflicts contain a non-UTF-8 file'
+ "conflict-too-large" => "when the conflicts contain a large file",
+ "conflict-binary-file" => "when the conflicts contain a binary file",
+ "conflict-missing-side" => "when the conflicts contain a file edited in one branch and deleted in another",
+ "conflict-non-utf8" => "when the conflicts contain a non-UTF-8 file",
}.freeze
UNRESOLVABLE_CONFLICTS.each do |source_branch, description|
@@ -183,15 +183,15 @@ describe 'Merge request > User resolves conflicts', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'does not show a link to the conflict resolution page' do
- expect(page).not_to have_link('conflicts', href: %r{/conflicts\Z})
+ it "does not show a link to the conflict resolution page" do
+ expect(page).not_to have_link("conflicts", href: %r{/conflicts\Z})
end
- it 'shows an error if the conflicts page is visited directly' do
- visit current_url + '/conflicts'
+ it "shows an error if the conflicts page is visited directly" do
+ visit current_url + "/conflicts"
wait_for_requests
- expect(find('#conflicts')).to have_content('Please try to resolve them locally.')
+ expect(find("#conflicts")).to have_content("Please try to resolve them locally.")
end
end
end
diff --git a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
index 08fa4a98feb..37bd6a5a158 100644
--- a/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
+++ b/spec/features/merge_request/user_resolves_diff_notes_and_discussions_resolve_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User resolves diff notes and discussions', :js do
+describe "Merge request > User resolves diff notes and discussions", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:guest) { create(:user) }
@@ -17,7 +17,7 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
)
end
- context 'no discussions' do
+ context "no discussions" do
before do
project.add_maintainer(user)
sign_in(user)
@@ -25,95 +25,95 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
visit_merge_request
end
- it 'displays no discussion resolved data' do
- expect(page).not_to have_content('discussion resolved')
- expect(page).not_to have_selector('.discussion-next-btn')
+ it "displays no discussion resolved data" do
+ expect(page).not_to have_content("discussion resolved")
+ expect(page).not_to have_selector(".discussion-next-btn")
end
end
- context 'as authorized user' do
+ context "as authorized user" do
before do
project.add_maintainer(user)
sign_in(user)
visit_merge_request
end
- context 'single discussion' do
- it 'shows text with how many discussions' do
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ context "single discussion" do
+ it "shows text with how many discussions" do
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- it 'allows user to mark a note as resolved' do
- page.within '.diff-content .note' do
- find('.line-resolve-btn').click
+ it "allows user to mark a note as resolved" do
+ page.within ".diff-content .note" do
+ find(".line-resolve-btn").click
- expect(page).to have_selector('.line-resolve-btn.is-active')
- expect(find('.line-resolve-btn')['aria-label']).to eq("Resolved by #{user.name}")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
+ expect(find(".line-resolve-btn")["aria-label"]).to eq("Resolved by #{user.name}")
end
- page.within '.diff-content' do
- expect(page).to have_selector('.btn', text: 'Unresolve discussion')
+ page.within ".diff-content" do
+ expect(page).to have_selector(".btn", text: "Unresolve discussion")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to mark discussion as resolved' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
+ it "allows user to mark discussion as resolved" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
end
- expect(page).to have_selector('.discussion-body', visible: false)
+ expect(page).to have_selector(".discussion-body", visible: false)
- page.within '.diff-content .note' do
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".diff-content .note" do
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to unresolve discussion' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
- click_button 'Unresolve discussion'
+ it "allows user to unresolve discussion" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
+ click_button "Unresolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- describe 'resolved discussion' do
+ describe "resolved discussion" do
before do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
end
visit_merge_request
end
- describe 'timeline view' do
- it 'hides when resolve discussion is clicked' do
- expect(page).to have_selector('.discussion-header')
- expect(page).not_to have_selector('.discussion-body')
+ describe "timeline view" do
+ it "hides when resolve discussion is clicked" do
+ expect(page).to have_selector(".discussion-header")
+ expect(page).not_to have_selector(".discussion-body")
end
- it 'shows resolved discussion when toggled' do
+ it "shows resolved discussion when toggled" do
find(".timeline-content .discussion[data-discussion-id='#{note.discussion_id}'] .discussion-toggle-button").click
expect(page.find(".line-holder-placeholder")).to be_visible
expect(page.find(".timeline-content #note_#{note.id}")).to be_visible
end
- it 'renders tables in lazy-loaded resolved diff dicussions' do
+ it "renders tables in lazy-loaded resolved diff dicussions" do
find(".timeline-content .discussion[data-discussion-id='#{note.discussion_id}'] .discussion-toggle-button").click
wait_for_requests
@@ -123,162 +123,162 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
end
end
- describe 'side-by-side view' do
+ describe "side-by-side view" do
before do
- page.within('.merge-request-tabs') { click_link 'Changes' }
- find('.js-show-diff-settings').click
- page.find('#parallel-diff-btn').click
+ page.within(".merge-request-tabs") { click_link "Changes" }
+ find(".js-show-diff-settings").click
+ page.find("#parallel-diff-btn").click
end
- it 'hides when resolve discussion is clicked' do
- expect(page).not_to have_selector('.diffs .diff-file .notes_holder')
+ it "hides when resolve discussion is clicked" do
+ expect(page).not_to have_selector(".diffs .diff-file .notes_holder")
end
- it 'shows resolved discussion when toggled' do
- find('.diff-comment-avatar-holders').click
+ it "shows resolved discussion when toggled" do
+ find(".diff-comment-avatar-holders").click
- expect(find('.diffs .diff-file .notes_holder')).to be_visible
+ expect(find(".diffs .diff-file .notes_holder")).to be_visible
end
end
- describe 'reply form' do
+ describe "reply form" do
before do
- click_button 'Toggle discussion'
+ click_button "Toggle discussion"
- page.within '.diff-content' do
- click_button 'Reply...'
+ page.within ".diff-content" do
+ click_button "Reply..."
end
end
- it 'allows user to comment' do
- page.within '.diff-content' do
- find('.js-note-text').set 'testing'
+ it "allows user to comment" do
+ page.within ".diff-content" do
+ find(".js-note-text").set "testing"
- click_button 'Comment'
+ click_button "Comment"
wait_for_requests
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
end
end
- it 'allows user to unresolve from reply form without a comment' do
- page.within '.diff-content' do
- click_button 'Unresolve discussion'
+ it "allows user to unresolve from reply form without a comment" do
+ page.within ".diff-content" do
+ click_button "Unresolve discussion"
wait_for_requests
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
- expect(page).not_to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
+ expect(page).not_to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to comment & unresolve discussion' do
- page.within '.diff-content' do
- find('.js-note-text').set 'testing'
+ it "allows user to comment & unresolve discussion" do
+ page.within ".diff-content" do
+ find(".js-note-text").set "testing"
- click_button 'Comment & unresolve discussion'
+ click_button "Comment & unresolve discussion"
wait_for_requests
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
end
end
- it 'allows user to resolve from reply form without a comment' do
- page.within '.diff-content' do
- click_button 'Reply...'
+ it "allows user to resolve from reply form without a comment" do
+ page.within ".diff-content" do
+ click_button "Reply..."
- click_button 'Resolve discussion'
+ click_button "Resolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to comment & resolve discussion' do
- page.within '.diff-content' do
- click_button 'Reply...'
+ it "allows user to comment & resolve discussion" do
+ page.within ".diff-content" do
+ click_button "Reply..."
- find('.js-note-text').set 'testing'
+ find(".js-note-text").set "testing"
- click_button 'Comment & resolve discussion'
+ click_button "Comment & resolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to quickly scroll to next unresolved discussion' do
- page.within '.line-resolve-all-container' do
- page.find('.discussion-next-btn').click
+ it "allows user to quickly scroll to next unresolved discussion" do
+ page.within ".line-resolve-all-container" do
+ page.find(".discussion-next-btn").click
end
expect(page.evaluate_script("window.pageYOffset")).to be > 0
end
- it 'hides jump to next button when all resolved' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
+ it "hides jump to next button when all resolved" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
end
- expect(page).to have_selector('.discussion-next-btn', visible: false)
+ expect(page).to have_selector(".discussion-next-btn", visible: false)
end
- it 'updates updated text after resolving note' do
- page.within '.diff-content .note' do
- resolve_button = find('.line-resolve-btn')
+ it "updates updated text after resolving note" do
+ page.within ".diff-content .note" do
+ resolve_button = find(".line-resolve-btn")
resolve_button.click
wait_for_requests
- expect(resolve_button['aria-label']).to eq("Resolved by #{user.name}")
+ expect(resolve_button["aria-label"]).to eq("Resolved by #{user.name}")
end
end
- it 'hides jump to next discussion button' do
- page.within '.discussion-reply-holder' do
- expect(page).not_to have_selector('.discussion-next-btn')
+ it "hides jump to next discussion button" do
+ page.within ".discussion-reply-holder" do
+ expect(page).not_to have_selector(".discussion-next-btn")
end
end
end
- context 'multiple notes' do
+ context "multiple notes" do
before do
create(:diff_note_on_merge_request, project: project, noteable: merge_request, in_reply_to: note)
visit_merge_request
end
- it 'does not mark discussion as resolved when resolving single note' do
+ it "does not mark discussion as resolved when resolving single note" do
page.within("#note_#{note.id}") do
- first('.line-resolve-btn').click
+ first(".line-resolve-btn").click
wait_for_requests
- expect(first('.line-resolve-btn')['aria-label']).to eq("Resolved by #{user.name}")
+ expect(first(".line-resolve-btn")["aria-label"]).to eq("Resolved by #{user.name}")
end
- expect(page).to have_content('Last updated')
+ expect(page).to have_content("Last updated")
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- it 'resolves discussion' do
- resolve_buttons = page.all('.note .line-resolve-btn', count: 2)
+ it "resolves discussion" do
+ resolve_buttons = page.all(".note .line-resolve-btn", count: 2)
resolve_buttons.each do |button|
button.click
end
@@ -286,289 +286,289 @@ describe 'Merge request > User resolves diff notes and discussions', :js do
wait_for_requests
resolve_buttons.each do |button|
- expect(button['aria-label']).to eq("Resolved by #{user.name}")
+ expect(button["aria-label"]).to eq("Resolved by #{user.name}")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
end
end
end
- context 'muliple discussions' do
+ context "muliple discussions" do
before do
create(:diff_note_on_merge_request, project: project, position: position, noteable: merge_request)
visit_merge_request
end
- it 'shows text with how many discussions' do
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/2 discussions resolved')
+ it "shows text with how many discussions" do
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/2 discussions resolved")
end
end
- it 'allows user to mark a single note as resolved' do
- click_button('Resolve discussion', match: :first)
+ it "allows user to mark a single note as resolved" do
+ click_button("Resolve discussion", match: :first)
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/2 discussions resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/2 discussions resolved")
end
end
- it 'allows user to mark all notes as resolved' do
- page.all('.note .line-resolve-btn', count: 2).each do |btn|
+ it "allows user to mark all notes as resolved" do
+ page.all(".note .line-resolve-btn", count: 2).each do |btn|
btn.click
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('2/2 discussions resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("2/2 discussions resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to mark all discussions as resolved' do
- page.all('.discussion-reply-holder', count: 2).each do |reply_holder|
+ it "allows user to mark all discussions as resolved" do
+ page.all(".discussion-reply-holder", count: 2).each do |reply_holder|
page.within reply_holder do
- click_button 'Resolve discussion'
+ click_button "Resolve discussion"
end
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('2/2 discussions resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("2/2 discussions resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to quickly scroll to next unresolved discussion' do
- page.within('.discussion-reply-holder', match: :first) do
- click_button 'Resolve discussion'
+ it "allows user to quickly scroll to next unresolved discussion" do
+ page.within(".discussion-reply-holder", match: :first) do
+ click_button "Resolve discussion"
end
- page.within '.line-resolve-all-container' do
- page.find('.discussion-next-btn').click
+ page.within ".line-resolve-all-container" do
+ page.find(".discussion-next-btn").click
end
expect(page.evaluate_script("window.pageYOffset")).to be > 0
end
- it 'updates updated text after resolving note' do
- page.within('.diff-content .note', match: :first) do
- resolve_button = find('.line-resolve-btn')
+ it "updates updated text after resolving note" do
+ page.within(".diff-content .note", match: :first) do
+ resolve_button = find(".line-resolve-btn")
resolve_button.click
wait_for_requests
- expect(resolve_button['aria-label']).to eq("Resolved by #{user.name}")
+ expect(resolve_button["aria-label"]).to eq("Resolved by #{user.name}")
end
end
- it 'shows jump to next discussion button except on last discussion' do
+ it "shows jump to next discussion button except on last discussion" do
wait_for_requests
- all_discussion_replies = page.all('.discussion-reply-holder')
+ all_discussion_replies = page.all(".discussion-reply-holder")
expect(all_discussion_replies.count).to eq(2)
- expect(all_discussion_replies.first.all('.discussion-next-btn').count).to eq(1)
- expect(all_discussion_replies.last.all('.discussion-next-btn').count).to eq(0)
+ expect(all_discussion_replies.first.all(".discussion-next-btn").count).to eq(1)
+ expect(all_discussion_replies.last.all(".discussion-next-btn").count).to eq(0)
end
- it 'displays next discussion even if hidden' do
- page.all('.note-discussion', count: 2).each do |discussion|
+ it "displays next discussion even if hidden" do
+ page.all(".note-discussion", count: 2).each do |discussion|
page.within discussion do
- click_button 'Toggle discussion'
+ click_button "Toggle discussion"
end
end
- page.within('.issuable-discussion #notes') do
- expect(page).not_to have_selector('.btn', text: 'Resolve discussion')
+ page.within(".issuable-discussion #notes") do
+ expect(page).not_to have_selector(".btn", text: "Resolve discussion")
end
- page.within '.line-resolve-all-container' do
- page.find('.discussion-next-btn').click
+ page.within ".line-resolve-all-container" do
+ page.find(".discussion-next-btn").click
end
- page.all('.note-discussion').first do
- expect(page.find('.discussion-with-resolve-btn')).to have_selector('.btn', text: 'Resolve discussion')
+ page.all(".note-discussion").first do
+ expect(page.find(".discussion-with-resolve-btn")).to have_selector(".btn", text: "Resolve discussion")
end
- page.all('.note-discussion').last do
- expect(page.find('.discussion-with-resolve-btn')).not.to have_selector('.btn', text: 'Resolve discussion')
+ page.all(".note-discussion").last do
+ expect(page.find(".discussion-with-resolve-btn")).not.to have_selector(".btn", text: "Resolve discussion")
end
end
end
- context 'changes tab' do
- it 'shows text with how many discussions' do
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ context "changes tab" do
+ it "shows text with how many discussions" do
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- it 'allows user to mark a note as resolved' do
- page.within '.diff-content .note' do
- find('.line-resolve-btn').click
+ it "allows user to mark a note as resolved" do
+ page.within ".diff-content .note" do
+ find(".line-resolve-btn").click
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
- page.within '.diff-content' do
- expect(page).to have_selector('.btn', text: 'Unresolve discussion')
+ page.within ".diff-content" do
+ expect(page).to have_selector(".btn", text: "Unresolve discussion")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to mark discussion as resolved' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
+ it "allows user to mark discussion as resolved" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
end
- page.within '.diff-content .note' do
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".diff-content .note" do
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to unresolve discussion' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
- click_button 'Unresolve discussion'
+ it "allows user to unresolve discussion" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
+ click_button "Unresolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- it 'allows user to comment & resolve discussion' do
- page.within '.diff-content' do
- click_button 'Reply...'
+ it "allows user to comment & resolve discussion" do
+ page.within ".diff-content" do
+ click_button "Reply..."
- find('.js-note-text').set 'testing'
+ find(".js-note-text").set "testing"
- click_button 'Comment & resolve discussion'
+ click_button "Comment & resolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
- it 'allows user to comment & unresolve discussion' do
- page.within '.diff-content' do
- click_button 'Resolve discussion'
+ it "allows user to comment & unresolve discussion" do
+ page.within ".diff-content" do
+ click_button "Resolve discussion"
- click_button 'Reply...'
+ click_button "Reply..."
- find('.js-note-text').set 'testing'
+ find(".js-note-text").set "testing"
- click_button 'Comment & unresolve discussion'
+ click_button "Comment & unresolve discussion"
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
end
end
- context 'as a guest' do
+ context "as a guest" do
before do
project.add_guest(guest)
sign_in(guest)
end
- context 'someone elses merge request' do
+ context "someone elses merge request" do
before do
visit_merge_request
end
- it 'does not allow user to mark note as resolved' do
- page.within '.diff-content .note' do
- expect(page).not_to have_selector('.line-resolve-btn')
+ it "does not allow user to mark note as resolved" do
+ page.within ".diff-content .note" do
+ expect(page).not_to have_selector(".line-resolve-btn")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
- it 'does not allow user to mark discussion as resolved' do
- page.within '.diff-content .note' do
- expect(page).not_to have_selector('.btn', text: 'Resolve discussion')
+ it "does not allow user to mark discussion as resolved" do
+ page.within ".diff-content .note" do
+ expect(page).not_to have_selector(".btn", text: "Resolve discussion")
end
end
end
- context 'guest users merge request' do
+ context "guest users merge request" do
let(:user) { guest }
before do
visit_merge_request
end
- it 'allows user to mark a note as resolved' do
- page.within '.diff-content .note' do
- find('.line-resolve-btn').click
+ it "allows user to mark a note as resolved" do
+ page.within ".diff-content .note" do
+ find(".line-resolve-btn").click
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
- page.within '.diff-content' do
- expect(page).to have_selector('.btn', text: 'Unresolve discussion')
+ page.within ".diff-content" do
+ expect(page).to have_selector(".btn", text: "Unresolve discussion")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('1/1 discussion resolved')
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("1/1 discussion resolved")
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
end
end
end
- context 'unauthorized user' do
- context 'no resolved comments' do
+ context "unauthorized user" do
+ context "no resolved comments" do
before do
visit_merge_request
end
- it 'does not allow user to mark note as resolved' do
- page.within '.diff-content .note' do
- expect(page).not_to have_selector('.line-resolve-btn')
+ it "does not allow user to mark note as resolved" do
+ page.within ".diff-content .note" do
+ expect(page).not_to have_selector(".line-resolve-btn")
end
- page.within '.line-resolve-all-container' do
- expect(page).to have_content('0/1 discussion resolved')
+ page.within ".line-resolve-all-container" do
+ expect(page).to have_content("0/1 discussion resolved")
end
end
end
- context 'resolved comment' do
+ context "resolved comment" do
before do
note.resolve!(user)
visit_merge_request
end
- it 'shows resolved icon' do
- expect(page).to have_content '1/1 discussion resolved'
+ it "shows resolved icon" do
+ expect(page).to have_content "1/1 discussion resolved"
- click_button 'Toggle discussion'
- expect(page).to have_selector('.line-resolve-btn.is-active')
+ click_button "Toggle discussion"
+ expect(page).to have_selector(".line-resolve-btn.is-active")
end
- it 'does not allow user to click resolve button' do
- expect(page).to have_selector('.line-resolve-btn.is-disabled')
- click_button 'Toggle discussion'
+ it "does not allow user to click resolve button" do
+ expect(page).to have_selector(".line-resolve-btn.is-disabled")
+ click_button "Toggle discussion"
- expect(page).to have_selector('.line-resolve-btn.is-disabled')
+ expect(page).to have_selector(".line-resolve-btn.is-disabled")
end
end
end
diff --git a/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb b/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb
index 777464ef841..91e161ed9e9 100644
--- a/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb
+++ b/spec/features/merge_request/user_resolves_outdated_diff_discussions_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Merge request > User resolves outdated diff discussions', :js do
+describe "Merge request > User resolves outdated diff discussions", :js do
let(:project) { create(:project, :repository, :public) }
let(:merge_request) do
- create(:merge_request, source_project: project, source_branch: 'csv', target_branch: 'master')
+ create(:merge_request, source_project: project, source_branch: "csv", target_branch: "master")
end
- let(:outdated_diff_refs) { project.commit('926c6595b263b2a40da6b17f3e3b7ea08344fad6').diff_refs }
+ let(:outdated_diff_refs) { project.commit("926c6595b263b2a40da6b17f3e3b7ea08344fad6").diff_refs }
let(:current_diff_refs) { merge_request.diff_refs }
let(:outdated_position) do
Gitlab::Diff::Position.new(
- old_path: 'files/csv/Book1.csv',
- new_path: 'files/csv/Book1.csv',
+ old_path: "files/csv/Book1.csv",
+ new_path: "files/csv/Book1.csv",
old_line: nil,
new_line: 9,
diff_refs: outdated_diff_refs
@@ -22,8 +22,8 @@ describe 'Merge request > User resolves outdated diff discussions', :js do
let(:current_position) do
Gitlab::Diff::Position.new(
- old_path: 'files/csv/Book1.csv',
- new_path: 'files/csv/Book1.csv',
+ old_path: "files/csv/Book1.csv",
+ new_path: "files/csv/Book1.csv",
old_line: nil,
new_line: 1,
diff_refs: current_diff_refs
@@ -32,23 +32,23 @@ describe 'Merge request > User resolves outdated diff discussions', :js do
let!(:outdated_discussion) do
create(:diff_note_on_merge_request,
- project: project,
- noteable: merge_request,
- position: outdated_position).to_discussion
+ project: project,
+ noteable: merge_request,
+ position: outdated_position).to_discussion
end
let!(:current_discussion) do
create(:diff_note_on_merge_request,
- noteable: merge_request,
- project: project,
- position: current_position).to_discussion
+ noteable: merge_request,
+ project: project,
+ position: current_position).to_discussion
end
before do
sign_in(merge_request.author)
end
- context 'when a discussion was resolved by a push' do
+ context "when a discussion was resolved by a push" do
before do
project.update!(resolve_outdated_diff_discussions: true)
@@ -61,17 +61,17 @@ describe 'Merge request > User resolves outdated diff discussions', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'shows that as automatically resolved' do
+ it "shows that as automatically resolved" do
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
- expect(page).not_to have_css('.discussion-body')
- expect(page).to have_content('Automatically resolved')
+ expect(page).not_to have_css(".discussion-body")
+ expect(page).to have_content("Automatically resolved")
end
end
- it 'does not show that for active discussions' do
+ it "does not show that for active discussions" do
within(".discussion[data-discussion-id='#{current_discussion.id}']") do
- expect(page).to have_css('.discussion-body', visible: true)
- expect(page).not_to have_content('Automatically resolved')
+ expect(page).to have_css(".discussion-body", visible: true)
+ expect(page).not_to have_content("Automatically resolved")
end
end
end
diff --git a/spec/features/merge_request/user_reverts_merge_request_spec.rb b/spec/features/merge_request/user_reverts_merge_request_spec.rb
index 67b6aefb2d8..2995e3c101e 100644
--- a/spec/features/merge_request/user_reverts_merge_request_spec.rb
+++ b/spec/features/merge_request/user_reverts_merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User reverts a merge request', :js do
+describe "User reverts a merge request", :js do
let(:merge_request) { create(:merge_request, :with_diffs, :simple, source_project: project) }
let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) }
@@ -11,59 +11,59 @@ describe 'User reverts a merge request', :js do
visit(merge_request_path(merge_request))
- click_button('Merge')
+ click_button("Merge")
wait_for_requests
visit(merge_request_path(merge_request))
end
- it 'reverts a merge request' do
+ it "reverts a merge request" do
find("a[href='#modal-revert-commit']").click
- page.within('#modal-revert-commit') do
- uncheck('create_merge_request')
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ uncheck("create_merge_request")
+ click_button("Revert")
end
- expect(page).to have_content('The merge request has been successfully reverted.')
+ expect(page).to have_content("The merge request has been successfully reverted.")
wait_for_requests
end
- it 'does not revert a merge request that was previously reverted' do
+ it "does not revert a merge request that was previously reverted" do
find("a[href='#modal-revert-commit']").click
- page.within('#modal-revert-commit') do
- uncheck('create_merge_request')
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ uncheck("create_merge_request")
+ click_button("Revert")
end
find("a[href='#modal-revert-commit']").click
- page.within('#modal-revert-commit') do
- uncheck('create_merge_request')
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ uncheck("create_merge_request")
+ click_button("Revert")
end
- expect(page).to have_content('Sorry, we cannot revert this merge request automatically.')
+ expect(page).to have_content("Sorry, we cannot revert this merge request automatically.")
end
- it 'reverts a merge request in a new merge request' do
+ it "reverts a merge request in a new merge request" do
find("a[href='#modal-revert-commit']").click
- page.within('#modal-revert-commit') do
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ click_button("Revert")
end
- expect(page).to have_content('The merge request has been successfully reverted. You can now submit a merge request to get this change into the original branch.')
+ expect(page).to have_content("The merge request has been successfully reverted. You can now submit a merge request to get this change into the original branch.")
end
- it 'cannot revert a merge requests for an archived project' do
+ it "cannot revert a merge requests for an archived project" do
project.update!(archived: true)
visit(merge_request_path(merge_request))
- expect(page).not_to have_link('Revert')
+ expect(page).not_to have_link("Revert")
end
end
diff --git a/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
index 8c2599615cb..70d4ba273d9 100644
--- a/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
+++ b/spec/features/merge_request/user_scrolls_to_note_on_load_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User scrolls to note on load', :js do
+describe "Merge request > User scrolls to note on load", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project, author: user) }
@@ -14,7 +14,7 @@ describe 'Merge request > User scrolls to note on load', :js do
page.current_window.resize_to(1000, 300)
end
- it 'scrolls note into view' do
+ it "scrolls note into view" do
visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}"
wait_for_requests
@@ -28,7 +28,7 @@ describe 'Merge request > User scrolls to note on load', :js do
expect(fragment_position_top).to be < (page_scroll_y + page_height)
end
- it 'renders un-collapsed notes with diff' do
+ it "renders un-collapsed notes with diff" do
page.current_window.resize_to(1000, 1000)
visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}"
@@ -36,22 +36,22 @@ describe 'Merge request > User scrolls to note on load', :js do
page.execute_script "window.scrollTo(0,0)"
note_element = find(fragment_id)
- note_container = note_element.ancestor('.js-discussion-container')
+ note_container = note_element.ancestor(".js-discussion-container")
expect(note_element.visible?).to eq true
page.within note_container do
- expect(page).not_to have_selector('.js-error-lazy-load-diff')
+ expect(page).not_to have_selector(".js-error-lazy-load-diff")
end
end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
- xit 'expands collapsed notes' do
+ xit "expands collapsed notes" do
visit "#{project_merge_request_path(project, merge_request)}#{collapsed_fragment_id}"
note_element = find(collapsed_fragment_id)
- note_container = note_element.ancestor('.timeline-content')
+ note_container = note_element.ancestor(".timeline-content")
expect(note_element.visible?).to eq true
- expect(note_container.find('.line_content.noteable_line.old', match: :first).visible?).to eq true
+ expect(note_container.find(".line_content.noteable_line.old", match: :first).visible?).to eq true
end
end
diff --git a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb
index b58c433bbfe..de1193b2b50 100644
--- a/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb
+++ b/spec/features/merge_request/user_sees_avatar_on_diff_notes_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees avatars on diff notes', :js do
+describe "Merge request > User sees avatars on diff notes", :js do
include NoteInteractionHelpers
let(:project) { create(:project, :public, :repository) }
@@ -22,153 +22,153 @@ describe 'Merge request > User sees avatars on diff notes', :js do
project.add_maintainer(user)
sign_in user
- set_cookie('sidebar_collapsed', 'true')
+ set_cookie("sidebar_collapsed", "true")
end
- context 'discussion tab' do
+ context "discussion tab" do
before do
visit project_merge_request_path(project, merge_request)
end
- it 'does not show avatars on discussion tab' do
- expect(page).not_to have_selector('.js-avatar-container')
- expect(page).not_to have_selector('.diff-comment-avatar-holders')
+ it "does not show avatars on discussion tab" do
+ expect(page).not_to have_selector(".js-avatar-container")
+ expect(page).not_to have_selector(".diff-comment-avatar-holders")
end
- it 'does not render avatars after commenting on discussion tab' do
- click_button 'Reply...'
+ it "does not render avatars after commenting on discussion tab" do
+ click_button "Reply..."
- page.within('.js-discussion-note-form') do
- find('.note-textarea').native.send_keys('Test comment')
+ page.within(".js-discussion-note-form") do
+ find(".note-textarea").native.send_keys("Test comment")
- click_button 'Comment'
+ click_button "Comment"
end
- expect(page).to have_content('Test comment')
- expect(page).not_to have_selector('.js-avatar-container')
- expect(page).not_to have_selector('.diff-comment-avatar-holders')
+ expect(page).to have_content("Test comment")
+ expect(page).not_to have_selector(".js-avatar-container")
+ expect(page).not_to have_selector(".diff-comment-avatar-holders")
end
end
- context 'commit view' do
+ context "commit view" do
before do
visit project_commit_path(project, merge_request.commits.first.id)
end
- it 'does not render avatar after commenting' do
- first('.diff-line-num').click
- find('.js-add-diff-note-button').click
+ it "does not render avatar after commenting" do
+ first(".diff-line-num").click
+ find(".js-add-diff-note-button").click
- page.within('.js-discussion-note-form') do
- find('.note-textarea').native.send_keys('test comment')
+ page.within(".js-discussion-note-form") do
+ find(".note-textarea").native.send_keys("test comment")
- click_button 'Comment'
+ click_button "Comment"
wait_for_requests
end
visit project_merge_request_path(project, merge_request)
- expect(page).to have_content('test comment')
- expect(page).not_to have_selector('.js-avatar-container')
- expect(page).not_to have_selector('.diff-comment-avatar-holders')
+ expect(page).to have_content("test comment")
+ expect(page).not_to have_selector(".js-avatar-container")
+ expect(page).not_to have_selector(".diff-comment-avatar-holders")
end
end
- %w(parallel).each do |view|
+ %w[parallel].each do |view|
context "#{view} view" do
before do
visit diffs_project_merge_request_path(project, merge_request, view: view)
wait_for_requests
- find('.js-toggle-tree-list').click
+ find(".js-toggle-tree-list").click
end
- it 'shows note avatar' do
+ it "shows note avatar" do
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
+ find(".diff-notes-collapse").send_keys(:return)
- expect(page).to have_selector('.js-diff-comment-avatar img', count: 1)
+ expect(page).to have_selector(".js-diff-comment-avatar img", count: 1)
end
end
- it 'shows comment on note avatar' do
+ it "shows comment on note avatar" do
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
- first('.js-diff-comment-avatar img').hover
+ find(".diff-notes-collapse").send_keys(:return)
+ first(".js-diff-comment-avatar img").hover
end
expect(page).to have_content "#{note.author.name}: #{note.note.truncate(17)}"
end
- it 'toggles comments when clicking avatar' do
+ it "toggles comments when clicking avatar" do
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
+ find(".diff-notes-collapse").send_keys(:return)
end
- expect(page).not_to have_selector('.notes_holder')
+ expect(page).not_to have_selector(".notes_holder")
page.within find_line(position.line_code(project.repository)) do
- first('.js-diff-comment-avatar img').click
+ first(".js-diff-comment-avatar img").click
end
- expect(page).to have_selector('.notes_holder')
+ expect(page).to have_selector(".notes_holder")
end
- it 'removes avatar when note is deleted' do
+ it "removes avatar when note is deleted" do
open_more_actions_dropdown(note)
page.within find(".note-row-#{note.id}") do
- accept_confirm { find('.js-note-delete').click }
+ accept_confirm { find(".js-note-delete").click }
end
wait_for_requests
page.within find_line(position.line_code(project.repository)) do
- expect(page).not_to have_selector('.js-diff-comment-avatar img')
+ expect(page).not_to have_selector(".js-diff-comment-avatar img")
end
end
- it 'adds avatar when commenting' do
- click_button 'Reply...'
+ it "adds avatar when commenting" do
+ click_button "Reply..."
- page.within '.js-discussion-note-form' do
- find('.js-note-text').native.send_keys('Test')
+ page.within ".js-discussion-note-form" do
+ find(".js-note-text").native.send_keys("Test")
- click_button 'Comment'
+ click_button "Comment"
wait_for_requests
end
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
+ find(".diff-notes-collapse").send_keys(:return)
- expect(page).to have_selector('.js-diff-comment-avatar img', count: 2)
+ expect(page).to have_selector(".js-diff-comment-avatar img", count: 2)
end
end
- it 'adds multiple comments' do
+ it "adds multiple comments" do
3.times do
- click_button 'Reply...'
+ click_button "Reply..."
- page.within '.js-discussion-note-form' do
- find('.js-note-text').native.send_keys('Test')
- find('.js-comment-button').click
+ page.within ".js-discussion-note-form" do
+ find(".js-note-text").native.send_keys("Test")
+ find(".js-comment-button").click
wait_for_requests
end
end
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
+ find(".diff-notes-collapse").send_keys(:return)
- expect(page).to have_selector('.js-diff-comment-avatar img', count: 3)
- expect(find('.diff-comments-more-count')).to have_content '+1'
+ expect(page).to have_selector(".js-diff-comment-avatar img", count: 3)
+ expect(find(".diff-comments-more-count")).to have_content "+1"
end
end
- context 'multiple comments' do
+ context "multiple comments" do
before do
create_list(:diff_note_on_merge_request, 3, project: project, noteable: merge_request, in_reply_to: note)
visit diffs_project_merge_request_path(project, merge_request, view: view)
@@ -176,11 +176,11 @@ describe 'Merge request > User sees avatars on diff notes', :js do
wait_for_requests
end
- it 'shows extra comment count' do
+ it "shows extra comment count" do
page.within find_line(position.line_code(project.repository)) do
- find('.diff-notes-collapse').send_keys(:return)
+ find(".diff-notes-collapse").send_keys(:return)
- expect(find('.diff-comments-more-count')).to have_content '+1'
+ expect(find(".diff-comments-more-count")).to have_content "+1"
end
end
end
@@ -189,7 +189,7 @@ describe 'Merge request > User sees avatars on diff notes', :js do
def find_line(line_code)
line = find("[id='#{line_code}']")
- line = line.find(:xpath, 'preceding-sibling::*[1][self::td]') if line.tag_name == 'td'
+ line = line.find(:xpath, "preceding-sibling::*[1][self::td]") if line.tag_name == "td"
line
end
end
diff --git a/spec/features/merge_request/user_sees_breadcrumb_links_spec.rb b/spec/features/merge_request/user_sees_breadcrumb_links_spec.rb
index 18d204da17a..a317a3913dd 100644
--- a/spec/features/merge_request/user_sees_breadcrumb_links_spec.rb
+++ b/spec/features/merge_request/user_sees_breadcrumb_links_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New merge request breadcrumb' do
+describe "New merge request breadcrumb" do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
@@ -9,10 +9,10 @@ describe 'New merge request breadcrumb' do
visit(project_new_merge_request_path(project))
end
- it 'displays link to project merge requests and new merge request' do
- page.within '.breadcrumbs' do
- expect(find_link('Merge Requests')[:href]).to end_with(project_merge_requests_path(project))
- expect(find_link('New')[:href]).to end_with(project_new_merge_request_path(project))
+ it "displays link to project merge requests and new merge request" do
+ page.within ".breadcrumbs" do
+ expect(find_link("Merge Requests")[:href]).to end_with(project_merge_requests_path(project))
+ expect(find_link("New")[:href]).to end_with(project_new_merge_request_path(project))
end
end
end
diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb
index 86086a58f18..e6981f7d7e0 100644
--- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb
+++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees check out branch modal', :js do
+describe "Merge request > User sees check out branch modal", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -9,16 +9,16 @@ describe 'Merge request > User sees check out branch modal', :js do
sign_in(user)
visit project_merge_request_path(project, merge_request)
wait_for_requests
- click_button('Check out branch')
+ click_button("Check out branch")
end
- it 'shows the check out branch modal' do
- expect(page).to have_content('Check out, review, and merge locally')
+ it "shows the check out branch modal" do
+ expect(page).to have_content("Check out, review, and merge locally")
end
- it 'closes the check out branch modal with escape keypress' do
- find('#modal_merge_info').send_keys(:escape)
+ it "closes the check out branch modal with escape keypress" do
+ find("#modal_merge_info").send_keys(:escape)
- expect(page).not_to have_content('Check out, review, and merge locally')
+ expect(page).not_to have_content("Check out, review, and merge locally")
end
end
diff --git a/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb b/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb
index aa499493dbe..e7c497e1436 100644
--- a/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb
+++ b/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User cherry-picks', :js do
+describe "Merge request > User cherry-picks", :js do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, namespace: group) }
let(:user) { project.creator }
@@ -11,7 +11,7 @@ describe 'Merge request > User cherry-picks', :js do
sign_in(user)
end
- context 'Viewing a merged merge request' do
+ context "Viewing a merged merge request" do
before do
service = MergeRequests::MergeService.new(project, user)
@@ -21,50 +21,50 @@ describe 'Merge request > User cherry-picks', :js do
end
# Fast-forward merge, or merged before GitLab 8.5.
- context 'without a merge commit' do
+ context "without a merge commit" do
before do
merge_request.merge_commit_sha = nil
merge_request.save
end
- it 'does not show a Cherry-pick button' do
+ it "does not show a Cherry-pick button" do
visit project_merge_request_path(project, merge_request)
- expect(page).not_to have_link 'Cherry-pick'
+ expect(page).not_to have_link "Cherry-pick"
end
end
- context 'with a merge commit' do
- it 'shows a Cherry-pick button' do
+ context "with a merge commit" do
+ it "shows a Cherry-pick button" do
visit project_merge_request_path(project, merge_request)
- expect(page).to have_link 'Cherry-pick'
+ expect(page).to have_link "Cherry-pick"
end
- it 'hides the cherry pick button for an archived project' do
+ it "hides the cherry pick button for an archived project" do
project.update!(archived: true)
visit project_merge_request_path(project, merge_request)
- expect(page).not_to have_link 'Cherry-pick'
+ expect(page).not_to have_link "Cherry-pick"
end
end
- context 'and seeing the cherry-pick modal' do
+ context "and seeing the cherry-pick modal" do
before do
visit project_merge_request_path(project, merge_request)
- click_link('Cherry-pick')
+ click_link("Cherry-pick")
end
- it 'shows the cherry-pick modal' do
- expect(page).to have_content('Cherry-pick this merge request')
+ it "shows the cherry-pick modal" do
+ expect(page).to have_content("Cherry-pick this merge request")
end
- it 'closes the cherry-pick modal with escape keypress' do
- find('#modal-cherry-pick-commit').send_keys(:escape)
+ it "closes the cherry-pick modal with escape keypress" do
+ find("#modal-cherry-pick-commit").send_keys(:escape)
- expect(page).not_to have_content('Start a new merge request with these changes')
+ expect(page).not_to have_content("Start a new merge request with these changes")
end
end
end
diff --git a/spec/features/merge_request/user_sees_closing_issues_message_spec.rb b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb
index d7c784b14c5..78f7cb221fb 100644
--- a/spec/features/merge_request/user_sees_closing_issues_message_spec.rb
+++ b/spec/features/merge_request/user_sees_closing_issues_message_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees closing issues message', :js do
+describe "Merge request > User sees closing issues message", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:issue_1) { create(:issue, project: project)}
@@ -14,8 +14,8 @@ describe 'Merge request > User sees closing issues message', :js do
title: merge_request_title
)
end
- let(:merge_request_description) { 'Merge Request Description' }
- let(:merge_request_title) { 'Merge Request Title' }
+ let(:merge_request_description) { "Merge Request Description" }
+ let(:merge_request_title) { "Merge Request Title" }
before do
project.add_maintainer(user)
@@ -24,51 +24,51 @@ describe 'Merge request > User sees closing issues message', :js do
wait_for_requests
end
- context 'closing issues but not mentioning any other issue' do
+ context "closing issues but not mentioning any other issue" do
let(:merge_request_description) { "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
- context 'mentioning issues but not closing them' do
+ context "mentioning issues but not closing them" do
let(:merge_request_description) { "Description\n\nRefers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Mentions #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
- context 'closing some issues in title and mentioning, but not closing, others' do
+ context "closing some issues in title and mentioning, but not closing, others" do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Closes #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}")
end
end
- context 'closing issues using title but not mentioning any other issue' do
+ context "closing issues using title but not mentioning any other issue" do
let(:merge_request_title) { "closing #{issue_1.to_reference}, #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Closes #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
- context 'mentioning issues using title but not closing them' do
+ context "mentioning issues using title but not closing them" do
let(:merge_request_title) { "Refers to #{issue_1.to_reference} and #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Mentions #{issue_1.to_reference} and #{issue_2.to_reference}")
end
end
- context 'closing some issues using title and mentioning, but not closing, others' do
+ context "closing some issues using title and mentioning, but not closing, others" do
let(:merge_request_title) { "closes #{issue_1.to_reference}\n\n refers to #{issue_2.to_reference}" }
- it 'does not display closing issue message' do
+ it "does not display closing issue message" do
expect(page).to have_content("Closes #{issue_1.to_reference}")
expect(page).to have_content("Mentions #{issue_2.to_reference}")
end
diff --git a/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb b/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb
index 46c21a2b155..cbcc49af7b2 100644
--- a/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb
+++ b/spec/features/merge_request/user_sees_deleted_target_branch_spec.rb
@@ -1,22 +1,22 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees deleted target branch', :js do
+describe "Merge request > User sees deleted target branch", :js do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
let(:user) { project.creator }
before do
project.add_maintainer(user)
- DeleteBranchService.new(project, user).execute('feature')
+ DeleteBranchService.new(project, user).execute("feature")
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'shows a message about missing target branch' do
- expect(page).to have_content('Target branch does not exist')
+ it "shows a message about missing target branch" do
+ expect(page).to have_content("Target branch does not exist")
end
- it 'does not show link to target branch' do
- expect(page).not_to have_selector('.mr-widget-body .js-branch-text a')
+ it "does not show link to target branch" do
+ expect(page).not_to have_selector(".mr-widget-body .js-branch-text a")
end
end
diff --git a/spec/features/merge_request/user_sees_deployment_widget_spec.rb b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
index fe8e0b07d39..68754472280 100644
--- a/spec/features/merge_request/user_sees_deployment_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_deployment_widget_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees deployment widget', :js do
- describe 'when merge request has associated environments' do
+describe "Merge request > User sees deployment widget", :js do
+ describe "when merge request has associated environments" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, :merged, source_project: project) }
@@ -18,91 +18,91 @@ describe 'Merge request > User sees deployment widget', :js do
sign_in(user)
end
- context 'when deployment succeeded' do
+ context "when deployment succeeded" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :succeed, environment: environment, sha: sha, ref: ref, deployable: build) }
- it 'displays that the environment is deployed' do
+ it "displays that the environment is deployed" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Deployed to #{environment.name}")
- expect(find('.js-deploy-time')['data-original-title']).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
+ expect(find(".js-deploy-time")["data-original-title"]).to eq(deployment.created_at.to_time.in_time_zone.to_s(:medium))
end
- context 'when a user created a new merge request with the same SHA' do
- let(:pipeline2) { create(:ci_pipeline_without_jobs, sha: sha, project: project, ref: 'new-patch-1') }
+ context "when a user created a new merge request with the same SHA" do
+ let(:pipeline2) { create(:ci_pipeline_without_jobs, sha: sha, project: project, ref: "new-patch-1") }
let(:build2) { create(:ci_build, :success, pipeline: pipeline2) }
let(:environment2) { create(:environment, project: project) }
- let!(:deployment2) { create(:deployment, environment: environment2, sha: sha, ref: 'new-patch-1', deployable: build2) }
+ let!(:deployment2) { create(:deployment, environment: environment2, sha: sha, ref: "new-patch-1", deployable: build2) }
- it 'displays one environment which is related to the pipeline' do
+ it "displays one environment which is related to the pipeline" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).to have_selector('.js-deployment-info', count: 1)
- expect(page).to have_content("#{environment.name}")
- expect(page).not_to have_content("#{environment2.name}")
+ expect(page).to have_selector(".js-deployment-info", count: 1)
+ expect(page).to have_content(environment.name.to_s)
+ expect(page).not_to have_content(environment2.name.to_s)
end
end
end
- context 'when deployment failed' do
+ context "when deployment failed" do
let(:build) { create(:ci_build, :failed, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :failed, environment: environment, sha: sha, ref: ref, deployable: build) }
- it 'displays that the deployment failed' do
+ it "displays that the deployment failed" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Failed to deploy to #{environment.name}")
- expect(page).not_to have_css('.js-deploy-time')
+ expect(page).not_to have_css(".js-deploy-time")
end
end
- context 'when deployment running' do
+ context "when deployment running" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :running, environment: environment, sha: sha, ref: ref, deployable: build) }
- it 'displays that the running deployment' do
+ it "displays that the running deployment" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Deploying to #{environment.name}")
- expect(page).not_to have_css('.js-deploy-time')
+ expect(page).not_to have_css(".js-deploy-time")
end
end
- context 'when deployment will happen' do
+ context "when deployment will happen" do
let(:build) { create(:ci_build, :created, pipeline: pipeline) }
let!(:deployment) { create(:deployment, environment: environment, sha: sha, ref: ref, deployable: build) }
- it 'displays that the environment name' do
+ it "displays that the environment name" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Will deploy to #{environment.name}")
- expect(page).not_to have_css('.js-deploy-time')
+ expect(page).not_to have_css(".js-deploy-time")
end
end
- context 'when deployment was cancelled' do
+ context "when deployment was cancelled" do
let(:build) { create(:ci_build, :canceled, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :canceled, environment: environment, sha: sha, ref: ref, deployable: build) }
- it 'displays that the environment name' do
+ it "displays that the environment name" do
visit project_merge_request_path(project, merge_request)
wait_for_requests
expect(page).to have_content("Failed to deploy to #{environment.name}")
- expect(page).not_to have_css('.js-deploy-time')
+ expect(page).not_to have_css(".js-deploy-time")
end
end
- context 'with stop action' do
+ context "with stop action" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :succeed, environment: environment, sha: sha, ref: ref, deployable: build) }
- let(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'close_app') }
+ let(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: "close_app") }
before do
deployment.update!(on_stop: manual.name)
@@ -110,17 +110,17 @@ describe 'Merge request > User sees deployment widget', :js do
wait_for_requests
end
- it 'does start build when stop button clicked' do
- accept_confirm { find('.js-stop-env').click }
+ it "does start build when stop button clicked" do
+ accept_confirm { find(".js-stop-env").click }
- expect(page).to have_content('close_app')
+ expect(page).to have_content("close_app")
end
- context 'for reporter' do
+ context "for reporter" do
let(:role) { :reporter }
- it 'does not show stop button' do
- expect(page).not_to have_selector('.js-stop-env')
+ it "does not show stop button" do
+ expect(page).not_to have_selector(".js-stop-env")
end
end
end
diff --git a/spec/features/merge_request/user_sees_diff_spec.rb b/spec/features/merge_request/user_sees_diff_spec.rb
index 04b07525919..79c0dbfbc73 100644
--- a/spec/features/merge_request/user_sees_diff_spec.rb
+++ b/spec/features/merge_request/user_sees_diff_spec.rb
@@ -1,14 +1,14 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees diff', :js do
+describe "Merge request > User sees diff", :js do
include ProjectForksHelper
include RepoHelpers
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
- context 'when linking to note' do
- describe 'with unresolved note' do
+ context "when linking to note" do
+ describe "with unresolved note" do
let(:note) { create :diff_note_on_merge_request, project: project, noteable: merge_request }
let(:fragment) { "#note_#{note.id}" }
@@ -16,12 +16,12 @@ describe 'Merge request > User sees diff', :js do
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
end
- it 'shows expanded note' do
+ it "shows expanded note" do
expect(page).to have_selector(fragment, visible: true)
end
end
- describe 'with resolved note' do
+ describe "with resolved note" do
let(:note) { create :diff_note_on_merge_request, :resolved, project: project, noteable: merge_request }
let(:fragment) { "#note_#{note.id}" }
@@ -29,27 +29,27 @@ describe 'Merge request > User sees diff', :js do
visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}"
end
- it 'shows expanded note' do
+ it "shows expanded note" do
expect(page).to have_selector(fragment, visible: true)
end
end
end
- context 'when merge request has overflow' do
- it 'displays warning' do
+ context "when merge request has overflow" do
+ it "displays warning" do
allow(Commit).to receive(:max_diff_options).and_return(max_files: 3)
allow_any_instance_of(DiffHelper).to receive(:render_overflow_warning?).and_return(true)
visit diffs_project_merge_request_path(project, merge_request)
- page.within('.alert') do
+ page.within(".alert") do
expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve
performance only 3 of 3+ files are displayed.")
end
end
end
- context 'when editing file' do
+ context "when editing file" do
let(:author_user) { create(:user) }
let(:user) { create(:user) }
let(:forked_project) { fork_project(project, author_user, repository: true) }
@@ -60,8 +60,8 @@ describe 'Merge request > User sees diff', :js do
forked_project.repository.after_import
end
- context 'as author' do
- it 'shows direct edit link' do
+ context "as author" do
+ it "shows direct edit link" do
sign_in(author_user)
visit diffs_project_merge_request_path(project, merge_request)
@@ -70,47 +70,47 @@ describe 'Merge request > User sees diff', :js do
end
end
- context 'as user who needs to fork' do
- it 'shows fork/cancel confirmation' do
+ context "as user who needs to fork" do
+ it "shows fork/cancel confirmation" do
sign_in(user)
visit diffs_project_merge_request_path(project, merge_request)
# Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax
find("[id=\"#{changelog_id}\"] .js-edit-blob").click
- expect(page).to have_selector('.js-fork-suggestion-button', count: 1)
- expect(page).to have_selector('.js-cancel-fork-suggestion-button', count: 1)
+ expect(page).to have_selector(".js-fork-suggestion-button", count: 1)
+ expect(page).to have_selector(".js-cancel-fork-suggestion-button", count: 1)
end
end
- context 'when file contains html' do
+ context "when file contains html" do
let(:current_user) { project.owner }
let(:branch_name) {"test_branch"}
- it 'escapes any HTML special characters in the diff chunk header' do
+ it "escapes any HTML special characters in the diff chunk header" do
file_content =
<<~CONTENT
- function foo<input> {
- let a = 1;
- let b = 2;
- let c = 3;
- let d = 3;
- }
- CONTENT
+ function foo<input> {
+ let a = 1;
+ let b = 2;
+ let c = 3;
+ let d = 3;
+ }
+ CONTENT
new_file_content =
<<~CONTENT
- function foo<input> {
- let a = 1;
- let b = 2;
- let c = 3;
- let x = 3;
- }
- CONTENT
+ function foo<input> {
+ let a = 1;
+ let b = 2;
+ let c = 3;
+ let x = 3;
+ }
+ CONTENT
- file_name = 'xss_file.rs'
+ file_name = "xss_file.rs"
- create_file('master', file_name, file_content)
+ create_file("master", file_name, file_content)
merge_request = create(:merge_request, source_project: project)
create_file(merge_request.source_branch, file_name, new_file_content)
@@ -123,44 +123,44 @@ describe 'Merge request > User sees diff', :js do
end
end
- context 'when file is stored in LFS' do
+ context "when file is stored in LFS" do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:current_user) { project.owner }
- context 'when LFS is enabled on the project' do
+ context "when LFS is enabled on the project" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
- create_file('master', file_name, project.repository.blob_at('master', 'files/lfs/lfs_object.iso').data)
+ create_file("master", file_name, project.repository.blob_at("master", "files/lfs/lfs_object.iso").data)
visit diffs_project_merge_request_path(project, merge_request)
end
- context 'when file is an image', :js do
- let(:file_name) { 'files/lfs/image.png' }
+ context "when file is an image", :js do
+ let(:file_name) { "files/lfs/image.png" }
- it 'shows an error message' do
- expect(page).not_to have_content('could not be displayed because it is stored in LFS')
+ it "shows an error message" do
+ expect(page).not_to have_content("could not be displayed because it is stored in LFS")
end
end
- context 'when file is not an image' do
- let(:file_name) { 'files/lfs/ruby.rb' }
+ context "when file is not an image" do
+ let(:file_name) { "files/lfs/ruby.rb" }
- it 'shows an error message' do
- expect(page).to have_content('This source diff could not be displayed because it is stored in LFS')
+ it "shows an error message" do
+ expect(page).to have_content("This source diff could not be displayed because it is stored in LFS")
end
end
end
- context 'when LFS is not enabled' do
+ context "when LFS is not enabled" do
before do
visit diffs_project_merge_request_path(project, merge_request)
end
- it 'displays the diff' do
- expect(page).to have_content('size 1575078')
+ it "displays the diff" do
+ expect(page).to have_content("size 1575078")
end
end
end
diff --git a/spec/features/merge_request/user_sees_discussions_spec.rb b/spec/features/merge_request/user_sees_discussions_spec.rb
index 57be1d06708..d0219dfe688 100644
--- a/spec/features/merge_request/user_sees_discussions_spec.rb
+++ b/spec/features/merge_request/user_sees_discussions_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees discussions', :js do
+describe "Merge request > User sees discussions", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -30,40 +30,40 @@ describe 'Merge request > User sees discussions', :js do
visit project_merge_request_path(project, merge_request)
end
- context 'active discussions' do
- it 'shows a link to the diff' do
+ context "active discussions" do
+ it "shows a link to the diff" do
within(".discussion[data-discussion-id='#{active_discussion.id}']") do
path = diffs_project_merge_request_path(project, merge_request, anchor: active_discussion.line_code)
- expect(page).to have_link('the diff', href: path)
+ expect(page).to have_link("the diff", href: path)
end
end
end
- context 'outdated discussions' do
- it 'shows a link to the outdated diff' do
+ context "outdated discussions" do
+ it "shows a link to the outdated diff" do
within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do
path = diffs_project_merge_request_path(project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code)
- expect(page).to have_link('an old version of the diff', href: path)
+ expect(page).to have_link("an old version of the diff", href: path)
end
end
end
end
- describe 'Commit comments displayed in MR context', :js do
- shared_examples 'a functional discussion' do
+ describe "Commit comments displayed in MR context", :js do
+ shared_examples "a functional discussion" do
let(:discussion_id) { note.discussion_id(merge_request) }
- it 'is displayed' do
+ it "is displayed" do
expect(page).to have_css(".discussion[data-discussion-id='#{discussion_id}']")
end
- it 'can be replied to' do
+ it "can be replied to" do
within(".discussion[data-discussion-id='#{discussion_id}']") do
- click_button 'Reply...'
- fill_in 'note[note]', with: 'Test!'
- click_button 'Comment'
+ click_button "Reply..."
+ fill_in "note[note]", with: "Test!"
+ click_button "Comment"
- expect(page).to have_css('.note', count: 2)
+ expect(page).to have_css(".note", count: 2)
end
end
end
@@ -79,20 +79,20 @@ describe 'Merge request > User sees discussions', :js do
# it_behaves_like 'a functional discussion'
# end
- context 'a commit diff comment' do
+ context "a commit diff comment" do
let(:note) { create(:diff_note_on_commit, project: project) }
- it_behaves_like 'a functional discussion'
+ it_behaves_like "a functional discussion"
- it 'displays correct header' do
+ it "displays correct header" do
expect(page).to have_content "started a discussion on commit #{note.commit_id[0...7]}"
end
end
- context 'a commit non-diff discussion' do
+ context "a commit non-diff discussion" do
let(:note) { create(:discussion_note_on_commit, project: project) }
- it 'displays correct header' do
+ it "displays correct header" do
page.within(find("#note_#{note.id}", match: :first)) do
refresh # Trigger a refresh of notes.
wait_for_requests
diff --git a/spec/features/merge_request/user_sees_empty_state_spec.rb b/spec/features/merge_request/user_sees_empty_state_spec.rb
index 012bfd6e458..1f7117d2821 100644
--- a/spec/features/merge_request/user_sees_empty_state_spec.rb
+++ b/spec/features/merge_request/user_sees_empty_state_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees empty state' do
+describe "Merge request > User sees empty state" do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
@@ -12,27 +12,27 @@ describe 'Merge request > User sees empty state' do
it 'shows an empty state and a "New merge request" button' do
visit project_merge_requests_path(project)
- expect(page).to have_selector('.empty-state')
- expect(page).to have_link 'New merge request', href: project_new_merge_request_path(project)
+ expect(page).to have_selector(".empty-state")
+ expect(page).to have_link "New merge request", href: project_new_merge_request_path(project)
end
- context 'if there are merge requests' do
+ context "if there are merge requests" do
before do
create(:merge_request, source_project: project)
end
- it 'does not show an empty state' do
+ it "does not show an empty state" do
visit project_merge_requests_path(project)
- expect(page).not_to have_selector('.empty-state')
+ expect(page).not_to have_selector(".empty-state")
end
- it 'shows empty state when filter results empty' do
+ it "shows empty state when filter results empty" do
visit project_merge_requests_path(project, milestone_title: "1.0")
- expect(page).to have_selector('.empty-state')
- expect(page).to have_content('Sorry, your filter produced no results')
- expect(page).to have_content('To widen your search, change or remove filters above')
+ expect(page).to have_selector(".empty-state")
+ expect(page).to have_content("Sorry, your filter produced no results")
+ expect(page).to have_content("To widen your search, change or remove filters above")
end
end
end
diff --git a/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb b/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb
index f6b771facf8..223ef0af121 100644
--- a/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_button_depending_on_unresolved_discussions_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees merge button depending on unresolved discussions', :js do
+describe "Merge request > User sees merge button depending on unresolved discussions", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
let!(:merge_request) { create(:merge_request_with_diff_notes, source_project: project, author: user) }
@@ -10,51 +10,51 @@ describe 'Merge request > User sees merge button depending on unresolved discuss
sign_in(user)
end
- context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
+ context "when project.only_allow_merge_if_all_discussions_are_resolved == true" do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, true)
visit project_merge_request_path(project, merge_request)
end
- context 'with unresolved discussions' do
- it 'does not allow to merge' do
- expect(page).not_to have_button 'Merge'
- expect(page).to have_content('There are unresolved discussions.')
+ context "with unresolved discussions" do
+ it "does not allow to merge" do
+ expect(page).not_to have_button "Merge"
+ expect(page).to have_content("There are unresolved discussions.")
end
end
- context 'with all discussions resolved' do
+ context "with all discussions resolved" do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
visit project_merge_request_path(project, merge_request)
end
- it 'allows MR to be merged' do
- expect(page).to have_button 'Merge'
+ it "allows MR to be merged" do
+ expect(page).to have_button "Merge"
end
end
end
- context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
+ context "when project.only_allow_merge_if_all_discussions_are_resolved == false" do
before do
project.update_column(:only_allow_merge_if_all_discussions_are_resolved, false)
visit project_merge_request_path(project, merge_request)
end
- context 'with unresolved discussions' do
- it 'does not allow to merge' do
- expect(page).to have_button 'Merge'
+ context "with unresolved discussions" do
+ it "does not allow to merge" do
+ expect(page).to have_button "Merge"
end
end
- context 'with all discussions resolved' do
+ context "with all discussions resolved" do
before do
merge_request.discussions.each { |d| d.resolve!(user) }
visit project_merge_request_path(project, merge_request)
end
- it 'allows MR to be merged' do
- expect(page).to have_button 'Merge'
+ it "allows MR to be merged" do
+ expect(page).to have_button "Merge"
end
end
end
diff --git a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb
index 7b473faa884..e0ed65e5e98 100644
--- a/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_request_pipelines_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees merge request pipelines', :js do
+describe "Merge request > User sees merge request pipelines", :js do
include ProjectForksHelper
include TestReportsHelper
@@ -12,16 +12,16 @@ describe 'Merge request > User sees merge request pipelines', :js do
let(:config) do
{
build: {
- script: 'build'
+ script: "build",
},
test: {
- script: 'test',
- only: ['merge_requests']
+ script: "test",
+ only: ["merge_requests"],
},
deploy: {
- script: 'deploy',
- except: ['merge_requests']
- }
+ script: "deploy",
+ except: ["merge_requests"],
+ },
}
end
@@ -33,194 +33,194 @@ describe 'Merge request > User sees merge request pipelines', :js do
sign_in(user)
end
- context 'when a user created a merge request in the parent project' do
+ context "when a user created a merge request in the parent project" do
let(:merge_request) do
create(:merge_request,
- source_project: project,
- target_project: project,
- source_branch: 'feature',
- target_branch: 'master')
+ source_project: project,
+ target_project: project,
+ source_branch: "feature",
+ target_branch: "master")
end
let!(:push_pipeline) do
- Ci::CreatePipelineService.new(project, user, ref: 'feature')
- .execute(:push)
+ Ci::CreatePipelineService.new(project, user, ref: "feature")
+ .execute(:push)
end
let!(:merge_request_pipeline) do
- Ci::CreatePipelineService.new(project, user, ref: 'feature')
- .execute(:merge_request, merge_request: merge_request)
+ Ci::CreatePipelineService.new(project, user, ref: "feature")
+ .execute(:merge_request, merge_request: merge_request)
end
before do
visit project_merge_request_path(project, merge_request)
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ page.within(".merge-request-tabs") do
+ click_link("Pipelines")
end
end
- it 'sees branch pipelines and merge request pipelines in correct order' do
- page.within('.ci-table') do
- expect(page).to have_selector('.ci-pending', count: 2)
- expect(first('.js-pipeline-url-link')).to have_content("##{merge_request_pipeline.id}")
+ it "sees branch pipelines and merge request pipelines in correct order" do
+ page.within(".ci-table") do
+ expect(page).to have_selector(".ci-pending", count: 2)
+ expect(first(".js-pipeline-url-link")).to have_content("##{merge_request_pipeline.id}")
end
end
- it 'sees the latest merge request pipeline as the head pipeline' do
- page.within('.ci-widget-content') do
+ it "sees the latest merge request pipeline as the head pipeline" do
+ page.within(".ci-widget-content") do
expect(page).to have_content("##{merge_request_pipeline.id}")
end
end
- context 'when a user updated a merge request in the parent project' do
+ context "when a user updated a merge request in the parent project" do
let!(:push_pipeline_2) do
- Ci::CreatePipelineService.new(project, user, ref: 'feature')
- .execute(:push)
+ Ci::CreatePipelineService.new(project, user, ref: "feature")
+ .execute(:push)
end
let!(:merge_request_pipeline_2) do
- Ci::CreatePipelineService.new(project, user, ref: 'feature')
- .execute(:merge_request, merge_request: merge_request)
+ Ci::CreatePipelineService.new(project, user, ref: "feature")
+ .execute(:merge_request, merge_request: merge_request)
end
before do
visit project_merge_request_path(project, merge_request)
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ page.within(".merge-request-tabs") do
+ click_link("Pipelines")
end
end
- it 'sees branch pipelines and merge request pipelines in correct order' do
- page.within('.ci-table') do
- expect(page).to have_selector('.ci-pending', count: 4)
+ it "sees branch pipelines and merge request pipelines in correct order" do
+ page.within(".ci-table") do
+ expect(page).to have_selector(".ci-pending", count: 4)
- expect(all('.js-pipeline-url-link')[0])
+ expect(all(".js-pipeline-url-link")[0])
.to have_content("##{merge_request_pipeline_2.id}")
- expect(all('.js-pipeline-url-link')[1])
+ expect(all(".js-pipeline-url-link")[1])
.to have_content("##{merge_request_pipeline.id}")
- expect(all('.js-pipeline-url-link')[2])
+ expect(all(".js-pipeline-url-link")[2])
.to have_content("##{push_pipeline_2.id}")
- expect(all('.js-pipeline-url-link')[3])
+ expect(all(".js-pipeline-url-link")[3])
.to have_content("##{push_pipeline.id}")
end
end
- it 'sees merge request tag for merge request pipelines' do
- page.within('.ci-table') do
- expect(all('.pipeline-tags')[0])
+ it "sees merge request tag for merge request pipelines" do
+ page.within(".ci-table") do
+ expect(all(".pipeline-tags")[0])
.to have_content("merge request")
- expect(all('.pipeline-tags')[1])
+ expect(all(".pipeline-tags")[1])
.to have_content("merge request")
- expect(all('.pipeline-tags')[2])
+ expect(all(".pipeline-tags")[2])
.not_to have_content("merge request")
- expect(all('.pipeline-tags')[3])
+ expect(all(".pipeline-tags")[3])
.not_to have_content("merge request")
end
end
- it 'sees the latest merge request pipeline as the head pipeline' do
- page.within('.ci-widget-content') do
+ it "sees the latest merge request pipeline as the head pipeline" do
+ page.within(".ci-widget-content") do
expect(page).to have_content("##{merge_request_pipeline_2.id}")
end
end
end
- context 'when a user merges a merge request in the parent project' do
+ context "when a user merges a merge request in the parent project" do
before do
- click_button 'Merge when pipeline succeeds'
+ click_button "Merge when pipeline succeeds"
wait_for_requests
end
- context 'when merge request pipeline is pending' do
- it 'waits the head pipeline' do
- expect(page).to have_content('to be merged automatically when the pipeline succeeds')
- expect(page).to have_link('Cancel automatic merge')
+ context "when merge request pipeline is pending" do
+ it "waits the head pipeline" do
+ expect(page).to have_content("to be merged automatically when the pipeline succeeds")
+ expect(page).to have_link("Cancel automatic merge")
end
end
- context 'when merge request pipeline succeeds' do
+ context "when merge request pipeline succeeds" do
before do
merge_request_pipeline.succeed!
wait_for_requests
end
- it 'merges the merge request' do
- expect(page).to have_content('Merged by')
- expect(page).to have_link('Revert')
+ it "merges the merge request" do
+ expect(page).to have_content("Merged by")
+ expect(page).to have_link("Revert")
end
end
- context 'when branch pipeline succeeds' do
+ context "when branch pipeline succeeds" do
before do
push_pipeline.succeed!
wait_for_requests
end
- it 'waits the head pipeline' do
- expect(page).to have_content('to be merged automatically when the pipeline succeeds')
- expect(page).to have_link('Cancel automatic merge')
+ it "waits the head pipeline" do
+ expect(page).to have_content("to be merged automatically when the pipeline succeeds")
+ expect(page).to have_link("Cancel automatic merge")
end
end
end
- context 'when there are no `merge_requests` keyword in .gitlab-ci.yml' do
+ context "when there are no `merge_requests` keyword in .gitlab-ci.yml" do
let(:config) do
{
build: {
- script: 'build'
+ script: "build",
},
test: {
- script: 'test'
+ script: "test",
},
deploy: {
- script: 'deploy'
- }
+ script: "deploy",
+ },
}
end
- it 'sees a branch pipeline in pipeline tab' do
- page.within('.ci-table') do
- expect(page).to have_selector('.ci-pending', count: 1)
- expect(first('.js-pipeline-url-link')).to have_content("##{push_pipeline.id}")
+ it "sees a branch pipeline in pipeline tab" do
+ page.within(".ci-table") do
+ expect(page).to have_selector(".ci-pending", count: 1)
+ expect(first(".js-pipeline-url-link")).to have_content("##{push_pipeline.id}")
end
end
- it 'sees the latest branch pipeline as the head pipeline' do
- page.within('.ci-widget-content') do
+ it "sees the latest branch pipeline as the head pipeline" do
+ page.within(".ci-widget-content") do
expect(page).to have_content("##{push_pipeline.id}")
end
end
end
end
- context 'when a user created a merge request from a forked project to the parent project' do
+ context "when a user created a merge request from a forked project to the parent project" do
let(:merge_request) do
create(:merge_request,
- source_project: forked_project,
- target_project: project,
- source_branch: 'feature',
- target_branch: 'master')
+ source_project: forked_project,
+ target_project: project,
+ source_branch: "feature",
+ target_branch: "master")
end
let!(:push_pipeline) do
- Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
- .execute(:push)
+ Ci::CreatePipelineService.new(forked_project, user2, ref: "feature")
+ .execute(:push)
end
let!(:merge_request_pipeline) do
- Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
- .execute(:merge_request, merge_request: merge_request)
+ Ci::CreatePipelineService.new(forked_project, user2, ref: "feature")
+ .execute(:merge_request, merge_request: merge_request)
end
let(:forked_project) { fork_project(project, user2, repository: true) }
@@ -231,133 +231,133 @@ describe 'Merge request > User sees merge request pipelines', :js do
visit project_merge_request_path(project, merge_request)
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ page.within(".merge-request-tabs") do
+ click_link("Pipelines")
end
end
- it 'sees branch pipelines and merge request pipelines in correct order' do
- page.within('.ci-table') do
- expect(page).to have_selector('.ci-pending', count: 2)
- expect(first('.js-pipeline-url-link')).to have_content("##{merge_request_pipeline.id}")
+ it "sees branch pipelines and merge request pipelines in correct order" do
+ page.within(".ci-table") do
+ expect(page).to have_selector(".ci-pending", count: 2)
+ expect(first(".js-pipeline-url-link")).to have_content("##{merge_request_pipeline.id}")
end
end
- it 'sees the latest merge request pipeline as the head pipeline' do
- page.within('.ci-widget-content') do
+ it "sees the latest merge request pipeline as the head pipeline" do
+ page.within(".ci-widget-content") do
expect(page).to have_content("##{merge_request_pipeline.id}")
end
end
- it 'sees pipeline list in forked project' do
+ it "sees pipeline list in forked project" do
visit project_pipelines_path(forked_project)
- expect(page).to have_selector('.ci-pending', count: 2)
+ expect(page).to have_selector(".ci-pending", count: 2)
end
- context 'when a user updated a merge request from a forked project to the parent project' do
+ context "when a user updated a merge request from a forked project to the parent project" do
let!(:push_pipeline_2) do
- Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
- .execute(:push)
+ Ci::CreatePipelineService.new(forked_project, user2, ref: "feature")
+ .execute(:push)
end
let!(:merge_request_pipeline_2) do
- Ci::CreatePipelineService.new(forked_project, user2, ref: 'feature')
- .execute(:merge_request, merge_request: merge_request)
+ Ci::CreatePipelineService.new(forked_project, user2, ref: "feature")
+ .execute(:merge_request, merge_request: merge_request)
end
before do
visit project_merge_request_path(project, merge_request)
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ page.within(".merge-request-tabs") do
+ click_link("Pipelines")
end
end
- it 'sees branch pipelines and merge request pipelines in correct order' do
- page.within('.ci-table') do
- expect(page).to have_selector('.ci-pending', count: 4)
+ it "sees branch pipelines and merge request pipelines in correct order" do
+ page.within(".ci-table") do
+ expect(page).to have_selector(".ci-pending", count: 4)
- expect(all('.js-pipeline-url-link')[0])
+ expect(all(".js-pipeline-url-link")[0])
.to have_content("##{merge_request_pipeline_2.id}")
- expect(all('.js-pipeline-url-link')[1])
+ expect(all(".js-pipeline-url-link")[1])
.to have_content("##{merge_request_pipeline.id}")
- expect(all('.js-pipeline-url-link')[2])
+ expect(all(".js-pipeline-url-link")[2])
.to have_content("##{push_pipeline_2.id}")
- expect(all('.js-pipeline-url-link')[3])
+ expect(all(".js-pipeline-url-link")[3])
.to have_content("##{push_pipeline.id}")
end
end
- it 'sees merge request tag for merge request pipelines' do
- page.within('.ci-table') do
- expect(all('.pipeline-tags')[0])
+ it "sees merge request tag for merge request pipelines" do
+ page.within(".ci-table") do
+ expect(all(".pipeline-tags")[0])
.to have_content("merge request")
- expect(all('.pipeline-tags')[1])
+ expect(all(".pipeline-tags")[1])
.to have_content("merge request")
- expect(all('.pipeline-tags')[2])
+ expect(all(".pipeline-tags")[2])
.not_to have_content("merge request")
- expect(all('.pipeline-tags')[3])
+ expect(all(".pipeline-tags")[3])
.not_to have_content("merge request")
end
end
- it 'sees the latest merge request pipeline as the head pipeline' do
- page.within('.ci-widget-content') do
+ it "sees the latest merge request pipeline as the head pipeline" do
+ page.within(".ci-widget-content") do
expect(page).to have_content("##{merge_request_pipeline_2.id}")
end
end
- it 'sees pipeline list in forked project' do
+ it "sees pipeline list in forked project" do
visit project_pipelines_path(forked_project)
- expect(page).to have_selector('.ci-pending', count: 4)
+ expect(page).to have_selector(".ci-pending", count: 4)
end
end
- context 'when a user merges a merge request from a forked project to the parent project' do
+ context "when a user merges a merge request from a forked project to the parent project" do
before do
- click_button 'Merge when pipeline succeeds'
+ click_button "Merge when pipeline succeeds"
wait_for_requests
end
- context 'when merge request pipeline is pending' do
- it 'waits the head pipeline' do
- expect(page).to have_content('to be merged automatically when the pipeline succeeds')
- expect(page).to have_link('Cancel automatic merge')
+ context "when merge request pipeline is pending" do
+ it "waits the head pipeline" do
+ expect(page).to have_content("to be merged automatically when the pipeline succeeds")
+ expect(page).to have_link("Cancel automatic merge")
end
end
- context 'when merge request pipeline succeeds' do
+ context "when merge request pipeline succeeds" do
before do
merge_request_pipeline.succeed!
wait_for_requests
end
- it 'merges the merge request' do
- expect(page).to have_content('Merged by')
- expect(page).to have_link('Revert')
+ it "merges the merge request" do
+ expect(page).to have_content("Merged by")
+ expect(page).to have_link("Revert")
end
end
- context 'when branch pipeline succeeds' do
+ context "when branch pipeline succeeds" do
before do
push_pipeline.succeed!
wait_for_requests
end
- it 'waits the head pipeline' do
- expect(page).to have_content('to be merged automatically when the pipeline succeeds')
- expect(page).to have_link('Cancel automatic merge')
+ it "waits the head pipeline" do
+ expect(page).to have_content("to be merged automatically when the pipeline succeeds")
+ expect(page).to have_link("Cancel automatic merge")
end
end
end
diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index afb978d7c45..f1f6f1142f4 100644
--- a/spec/features/merge_request/user_sees_merge_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees merge widget', :js do
+describe "Merge request > User sees merge widget", :js do
include ProjectForksHelper
include TestReportsHelper
@@ -16,40 +16,41 @@ describe 'Merge request > User sees merge widget', :js do
sign_in(user)
end
- context 'new merge request' do
+ context "new merge request" do
before do
visit project_new_merge_request_path(
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'feature',
- target_branch: 'master'
- })
+ source_branch: "feature",
+ target_branch: "master",
+ }
+ )
end
- it 'shows widget status after creating new merge request' do
- click_button 'Submit merge request'
+ it "shows widget status after creating new merge request" do
+ click_button "Submit merge request"
wait_for_requests
- expect(page).to have_selector('.accept-merge-request')
- expect(find('.accept-merge-request')['disabled']).not_to be(true)
+ expect(page).to have_selector(".accept-merge-request")
+ expect(find(".accept-merge-request")["disabled"]).not_to be(true)
end
end
- context 'view merge request' do
+ context "view merge request" do
let!(:environment) { create(:environment, project: project) }
let(:sha) { project.commit(merge_request.source_branch).sha }
- let(:pipeline) { create(:ci_pipeline_without_jobs, status: 'success', sha: sha, project: project, ref: merge_request.source_branch) }
+ let(:pipeline) { create(:ci_pipeline_without_jobs, status: "success", sha: sha, project: project, ref: merge_request.source_branch) }
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
let!(:deployment) do
create(:deployment, :succeed,
- environment: environment,
- ref: merge_request.source_branch,
- deployable: build,
- sha: sha)
+ environment: environment,
+ ref: merge_request.source_branch,
+ deployable: build,
+ sha: sha)
end
before do
@@ -57,59 +58,59 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'shows environments link' do
+ it "shows environments link" do
wait_for_requests
- page.within('.js-pre-deployment') do
+ page.within(".js-pre-deployment") do
expect(page).to have_content("Deployed to #{environment.name}")
- expect(find('.js-deploy-url')[:href]).to include(environment.formatted_external_url)
+ expect(find(".js-deploy-url")[:href]).to include(environment.formatted_external_url)
end
end
- it 'shows green accept merge request button' do
+ it "shows green accept merge request button" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- expect(page).to have_selector('.accept-merge-request')
- expect(find('.accept-merge-request')['disabled']).not_to be(true)
+ expect(page).to have_selector(".accept-merge-request")
+ expect(find(".accept-merge-request")["disabled"]).not_to be(true)
end
- it 'allows me to merge, see cherry-pick modal and load branches list' do
+ it "allows me to merge, see cherry-pick modal and load branches list" do
wait_for_requests
- click_button 'Merge'
+ click_button "Merge"
wait_for_requests
- click_link 'Cherry-pick'
- page.find('.js-project-refs-dropdown').click
+ click_link "Cherry-pick"
+ page.find(".js-project-refs-dropdown").click
wait_for_requests
- expect(page.all('.js-cherry-pick-form .dropdown-content li').size).to be > 1
+ expect(page.all(".js-cherry-pick-form .dropdown-content li").size).to be > 1
end
end
- context 'view merge request with external CI service' do
+ context "view merge request with external CI service" do
before do
create(:service, project: project,
active: true,
- type: 'CiService',
- category: 'ci')
+ type: "CiService",
+ category: "ci")
visit project_merge_request_path(project, merge_request)
end
- it 'has danger button while waiting for external CI status' do
+ it "has danger button while waiting for external CI status" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- expect(page).to have_selector('.accept-merge-request.btn-danger')
+ expect(page).to have_selector(".accept-merge-request.btn-danger")
end
end
- context 'view merge request with failed GitLab CI pipelines' do
+ context "view merge request with failed GitLab CI pipelines" do
before do
- commit_status = create(:commit_status, project: project, status: 'failed')
+ commit_status = create(:commit_status, project: project, status: "failed")
pipeline = create(:ci_pipeline, project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
- status: 'failed',
+ status: "failed",
statuses: [commit_status],
head_pipeline_of: merge_request)
create(:ci_build, :pending, pipeline: pipeline)
@@ -117,14 +118,14 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'has danger button when not succeeded' do
+ it "has danger button when not succeeded" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- expect(page).to have_selector('.accept-merge-request.btn-danger')
+ expect(page).to have_selector(".accept-merge-request.btn-danger")
end
end
- context 'when merge request is in the blocked pipeline state' do
+ context "when merge request is in the blocked pipeline state" do
before do
create(
:ci_pipeline,
@@ -132,26 +133,28 @@ describe 'Merge request > User sees merge widget', :js do
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
status: :manual,
- head_pipeline_of: merge_request)
+ head_pipeline_of: merge_request
+ )
visit project_merge_request_path(project, merge_request)
end
- it 'shows information about blocked pipeline' do
+ it "shows information about blocked pipeline" do
expect(page).to have_content("Pipeline blocked")
expect(page).to have_content(
- "The pipeline for this merge request requires a manual action")
- expect(page).to have_css('.ci-status-icon-manual')
+ "The pipeline for this merge request requires a manual action"
+ )
+ expect(page).to have_css(".ci-status-icon-manual")
end
end
- context 'view merge request with MWBS button' do
+ context "view merge request with MWBS button" do
before do
- commit_status = create(:commit_status, project: project, status: 'pending')
+ commit_status = create(:commit_status, project: project, status: "pending")
pipeline = create(:ci_pipeline, project: project,
sha: merge_request.diff_head_sha,
ref: merge_request.source_branch,
- status: 'pending',
+ status: "pending",
statuses: [commit_status],
head_pipeline_of: merge_request)
create(:ci_build, :pending, pipeline: pipeline)
@@ -159,14 +162,14 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'has info button when MWBS button' do
+ it "has info button when MWBS button" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- expect(page).to have_selector('.accept-merge-request.btn-info')
+ expect(page).to have_selector(".accept-merge-request.btn-info")
end
end
- context 'view merge request where project has CI set up but no CI status' do
+ context "view merge request where project has CI set up but no CI status" do
before do
pipeline = create(:ci_pipeline, project: project,
sha: merge_request.diff_head_sha,
@@ -176,7 +179,7 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'has pipeline error text' do
+ it "has pipeline error text" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
@@ -184,63 +187,63 @@ describe 'Merge request > User sees merge widget', :js do
end
end
- context 'view merge request in project with only-mwps setting enabled but no CI is set up' do
+ context "view merge request in project with only-mwps setting enabled but no CI is set up" do
before do
visit project_merge_request_path(project_only_mwps, merge_request_in_only_mwps_project)
end
- it 'should be allowed to merge' do
+ it "should be allowed to merge" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- expect(page).to have_selector('.accept-merge-request')
- expect(find('.accept-merge-request')['disabled']).not_to be(true)
+ expect(page).to have_selector(".accept-merge-request")
+ expect(find(".accept-merge-request")["disabled"]).not_to be(true)
end
end
- context 'view merge request with MWPS enabled but automatically merge fails' do
+ context "view merge request with MWPS enabled but automatically merge fails" do
before do
merge_request.update(
merge_when_pipeline_succeeds: true,
merge_user: merge_request.author,
- merge_error: 'Something went wrong'
+ merge_error: "Something went wrong"
)
visit project_merge_request_path(project, merge_request)
end
- it 'shows information about the merge error' do
+ it "shows information about the merge error" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- page.within('.mr-widget-body') do
- expect(page).to have_content('Something went wrong')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Something went wrong")
end
end
end
- context 'view merge request with MWPS enabled but automatically merge fails' do
+ context "view merge request with MWPS enabled but automatically merge fails" do
before do
merge_request.update(
merge_when_pipeline_succeeds: true,
merge_user: merge_request.author,
- merge_error: 'Something went wrong'
+ merge_error: "Something went wrong"
)
visit project_merge_request_path(project, merge_request)
end
- it 'shows information about the merge error' do
+ it "shows information about the merge error" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- page.within('.mr-widget-body') do
- expect(page).to have_content('Something went wrong')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Something went wrong")
end
end
end
- context 'view merge request where fast-forward merge is not possible' do
+ context "view merge request where fast-forward merge is not possible" do
before do
project.update(merge_requests_ff_only_enabled: true)
@@ -252,32 +255,32 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'shows information about the merge error' do
+ it "shows information about the merge error" do
# Wait for the `ci_status` and `merge_check` requests
wait_for_requests
- page.within('.mr-widget-body') do
- expect(page).to have_content('Fast-forward merge is not possible')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Fast-forward merge is not possible")
end
end
end
- context 'merge error' do
+ context "merge error" do
before do
allow_any_instance_of(Repository).to receive(:merge).and_return(false)
visit project_merge_request_path(project, merge_request)
end
- it 'updates the MR widget' do
- click_button 'Merge'
+ it "updates the MR widget" do
+ click_button "Merge"
- page.within('.mr-widget-body') do
- expect(page).to have_content('Conflicts detected during merge')
+ page.within(".mr-widget-body") do
+ expect(page).to have_content("Conflicts detected during merge")
end
end
end
- context 'user can merge into source project but cannot push to fork', :js do
+ context "user can merge into source project but cannot push to fork", :js do
let(:fork_project) { create(:project, :public, :repository) }
let(:user2) { create(:user) }
@@ -289,16 +292,16 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'user can merge into the source project' do
- expect(page).to have_button('Merge', disabled: false)
+ it "user can merge into the source project" do
+ expect(page).to have_button("Merge", disabled: false)
end
- it 'user cannot remove source branch' do
- expect(page).not_to have_field('remove-source-branch-input')
+ it "user cannot remove source branch" do
+ expect(page).not_to have_field("remove-source-branch-input")
end
end
- context 'user cannot merge project and cannot push to fork', :js do
+ context "user cannot merge project and cannot push to fork", :js do
let(:forked_project) { fork_project(project, nil, repository: true) }
let(:user2) { create(:user) }
@@ -309,37 +312,37 @@ describe 'Merge request > User sees merge widget', :js do
merge_request.update(
source_project: forked_project,
target_project: project,
- merge_params: { 'force_remove_source_branch' => '1' }
+ merge_params: {"force_remove_source_branch" => "1"}
)
visit project_merge_request_path(project, merge_request)
end
- it 'user cannot remove source branch' do
- expect(page).not_to have_field('remove-source-branch-input')
- expect(page).to have_content('Deletes source branch')
+ it "user cannot remove source branch" do
+ expect(page).not_to have_field("remove-source-branch-input")
+ expect(page).to have_content("Deletes source branch")
end
end
- context 'ongoing merge process' do
- it 'shows Merging state' do
+ context "ongoing merge process" do
+ it "shows Merging state" do
allow_any_instance_of(MergeRequest).to receive(:merge_ongoing?).and_return(true)
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page).not_to have_button('Merge')
- expect(page).to have_content('This merge request is in the process of being merged')
+ expect(page).not_to have_button("Merge")
+ expect(page).to have_content("This merge request is in the process of being merged")
end
end
- context 'when merge request has test reports' do
+ context "when merge request has test reports" do
let!(:head_pipeline) do
create(:ci_pipeline,
- :success,
- project: project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha)
+ :success,
+ project: project,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha)
end
let!(:build) { create(:ci_build, :success, pipeline: head_pipeline, project: project) }
@@ -348,20 +351,20 @@ describe 'Merge request > User sees merge widget', :js do
merge_request.update!(head_pipeline_id: head_pipeline.id)
end
- context 'when result has not been parsed yet' do
+ context "when result has not been parsed yet" do
let!(:job_artifact) { create(:ci_job_artifact, :junit, job: build, project: project) }
before do
visit project_merge_request_path(project, merge_request)
end
- it 'shows parsing status' do
- expect(page).to have_content('Test summary results are being parsed')
+ it "shows parsing status" do
+ expect(page).to have_content("Test summary results are being parsed")
end
end
- context 'when result has already been parsed' do
- context 'when JUnit xml is correctly formatted' do
+ context "when result has already been parsed" do
+ context "when JUnit xml is correctly formatted" do
let!(:job_artifact) { create(:ci_job_artifact, :junit, job: build, project: project) }
before do
@@ -370,12 +373,12 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'shows parsed results' do
- expect(page).to have_content('Test summary contained')
+ it "shows parsed results" do
+ expect(page).to have_content("Test summary contained")
end
end
- context 'when JUnit xml is corrupted' do
+ context "when JUnit xml is corrupted" do
let!(:job_artifact) { create(:ci_job_artifact, :junit_with_corrupted_data, job: build, project: project) }
before do
@@ -384,8 +387,8 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'shows the error state' do
- expect(page).to have_content('Test summary failed loading results')
+ it "shows the error state" do
+ expect(page).to have_content("Test summary failed loading results")
end
end
@@ -394,13 +397,13 @@ describe 'Merge request > User sees merge widget', :js do
end
end
- context 'when test reports have been parsed correctly' do
+ context "when test reports have been parsed correctly" do
let(:serialized_data) do
{
status: :parsed,
data: TestReportsComparerSerializer
.new(project: project)
- .represent(comparer)
+ .represent(comparer),
}
end
@@ -413,44 +416,44 @@ describe 'Merge request > User sees merge widget', :js do
visit project_merge_request_path(project, merge_request)
end
- context 'when a new failures exists' do
+ context "when a new failures exists" do
let(:base_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
end
let(:head_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
end
- it 'shows test reports summary which includes the new failure' do
+ it "shows test reports summary which includes the new failure" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
- expect(page).to have_content('Test summary contained 1 failed test result out of 2 total tests')
+ expect(page).to have_content("Test summary contained 1 failed test result out of 2 total tests")
within(".js-report-section-container") do
- expect(page).to have_content('rspec found no changed test results out of 1 total test')
- expect(page).to have_content('junit found 1 failed test result out of 1 total test')
- expect(page).to have_content('New')
- expect(page).to have_content('subtractTest')
+ expect(page).to have_content("rspec found no changed test results out of 1 total test")
+ expect(page).to have_content("junit found 1 failed test result out of 1 total test")
+ expect(page).to have_content("New")
+ expect(page).to have_content("subtractTest")
end
end
end
- context 'when user clicks the new failure' do
- it 'shows the test report detail' do
+ context "when user clicks the new failure" do
+ it "shows the test report detail" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
within(".js-report-section-container") do
- click_button 'subtractTest'
+ click_button "subtractTest"
- expect(page).to have_content('6.66')
+ expect(page).to have_content("6.66")
expect(page).to have_content(sample_java_failed_message)
end
end
@@ -458,44 +461,44 @@ describe 'Merge request > User sees merge widget', :js do
end
end
- context 'when an existing failure exists' do
+ context "when an existing failure exists" do
let(:base_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_failed)
- reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_failed)
+ reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
end
let(:head_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_failed)
- reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_failed)
+ reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
end
- it 'shows test reports summary which includes the existing failure' do
+ it "shows test reports summary which includes the existing failure" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
- expect(page).to have_content('Test summary contained 1 failed test result out of 2 total tests')
+ expect(page).to have_content("Test summary contained 1 failed test result out of 2 total tests")
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 1 failed test result out of 1 total test')
- expect(page).to have_content('junit found no changed test results out of 1 total test')
- expect(page).not_to have_content('New')
- expect(page).to have_content('Test#sum when a is 2 and b is 2 returns summary')
+ expect(page).to have_content("rspec found 1 failed test result out of 1 total test")
+ expect(page).to have_content("junit found no changed test results out of 1 total test")
+ expect(page).not_to have_content("New")
+ expect(page).to have_content("Test#sum when a is 2 and b is 2 returns summary")
end
end
end
- context 'when user clicks the existing failure' do
- it 'shows test report detail of it' do
+ context "when user clicks the existing failure" do
+ it "shows test report detail of it" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
within(".js-report-section-container") do
- click_button 'Test#sum when a is 2 and b is 2 returns summary'
+ click_button "Test#sum when a is 2 and b is 2 returns summary"
- expect(page).to have_content('2.22')
+ expect(page).to have_content("2.22")
expect(page).to have_content(sample_rspec_failed_message)
end
end
@@ -503,18 +506,18 @@ describe 'Merge request > User sees merge widget', :js do
end
end
- context 'when a resolved failure exists' do
+ context "when a resolved failure exists" do
let(:base_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
end
let(:head_reports) do
Gitlab::Ci::Reports::TestReports.new.tap do |reports|
- reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- reports.get_suite('junit').add_test_case(create_test_case_java_resolved)
+ reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ reports.get_suite("junit").add_test_case(create_test_case_java_resolved)
end
end
@@ -524,28 +527,28 @@ describe 'Merge request > User sees merge widget', :js do
end
end
- it 'shows test reports summary which includes the resolved failure' do
+ it "shows test reports summary which includes the resolved failure" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
- expect(page).to have_content('Test summary contained 1 fixed test result out of 2 total tests')
+ expect(page).to have_content("Test summary contained 1 fixed test result out of 2 total tests")
within(".js-report-section-container") do
- expect(page).to have_content('rspec found no changed test results out of 1 total test')
- expect(page).to have_content('junit found 1 fixed test result out of 1 total test')
- expect(page).to have_content('subtractTest')
+ expect(page).to have_content("rspec found no changed test results out of 1 total test")
+ expect(page).to have_content("junit found 1 fixed test result out of 1 total test")
+ expect(page).to have_content("subtractTest")
end
end
end
- context 'when user clicks the resolved failure' do
- it 'shows test report detail of it' do
+ context "when user clicks the resolved failure" do
+ it "shows test report detail of it" do
within(".js-reports-container") do
- click_button 'Expand'
+ click_button "Expand"
within(".js-report-section-container") do
- click_button 'subtractTest'
+ click_button "subtractTest"
- expect(page).to have_content('6.66')
+ expect(page).to have_content("6.66")
end
end
end
diff --git a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb
index 5188dc3625f..e6ad6381fc1 100644
--- a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb
+++ b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request < User sees mini pipeline graph', :js do
+describe "Merge request < User sees mini pipeline graph", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project, head_pipeline: pipeline) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: 'master', status: 'running', sha: project.commit.id) }
- let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test') }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: "master", status: "running", sha: project.commit.id) }
+ let(:build) { create(:ci_build, pipeline: pipeline, stage: "test") }
before do
build.run
- build.trace.set('hello')
+ build.trace.set("hello")
sign_in(user)
visit_merge_request
end
@@ -18,66 +18,66 @@ describe 'Merge request < User sees mini pipeline graph', :js do
visit project_merge_request_path(project, merge_request, format: format, serializer: serializer)
end
- it 'displays a mini pipeline graph' do
- expect(page).to have_selector('.mr-widget-pipeline-graph')
+ it "displays a mini pipeline graph" do
+ expect(page).to have_selector(".mr-widget-pipeline-graph")
end
- context 'as json' do
- let(:artifacts_file1) { fixture_file_upload(File.join('spec/fixtures/banana_sample.gif'), 'image/gif') }
- let(:artifacts_file2) { fixture_file_upload(File.join('spec/fixtures/dk.png'), 'image/png') }
+ context "as json" do
+ let(:artifacts_file1) { fixture_file_upload(File.join("spec/fixtures/banana_sample.gif"), "image/gif") }
+ let(:artifacts_file2) { fixture_file_upload(File.join("spec/fixtures/dk.png"), "image/png") }
before do
create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file1)
- create(:ci_build, :manual, pipeline: pipeline, when: 'manual')
+ create(:ci_build, :manual, pipeline: pipeline, when: "manual")
end
# TODO: https://gitlab.com/gitlab-org/gitlab-ce/issues/48034
- xit 'avoids repeated database queries' do
- before = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: 'widget') }
+ xit "avoids repeated database queries" do
+ before = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: "widget") }
create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file2)
- create(:ci_build, :manual, pipeline: pipeline, when: 'manual')
+ create(:ci_build, :manual, pipeline: pipeline, when: "manual")
- after = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: 'widget') }
+ after = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: "widget") }
expect(before.count).to eq(after.count)
expect(before.cached_count).to eq(after.cached_count)
end
end
- describe 'build list toggle' do
+ describe "build list toggle" do
let(:toggle) do
- find('.mini-pipeline-graph-dropdown-toggle')
- first('.mini-pipeline-graph-dropdown-toggle')
+ find(".mini-pipeline-graph-dropdown-toggle")
+ first(".mini-pipeline-graph-dropdown-toggle")
end
# Status icon button styles should update as described in
# https://gitlab.com/gitlab-org/gitlab-ce/issues/42769
- it 'has unique styles for default, :hover, :active, and :focus states' do
- find('.mini-pipeline-graph-dropdown-toggle')
+ it "has unique styles for default, :hover, :active, and :focus states" do
+ find(".mini-pipeline-graph-dropdown-toggle")
default_background_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('background-color');")
default_foreground_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible svg').css('fill');")
default_box_shadow = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('box-shadow');")
toggle.hover
- find('.mini-pipeline-graph-dropdown-toggle')
+ find(".mini-pipeline-graph-dropdown-toggle")
hover_background_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('background-color');")
hover_foreground_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible svg').css('fill');")
hover_box_shadow = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('box-shadow');")
page.driver.browser.action.click_and_hold(toggle.native).perform
- find('.mini-pipeline-graph-dropdown-toggle')
+ find(".mini-pipeline-graph-dropdown-toggle")
active_background_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('background-color');")
active_foreground_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible svg').css('fill');")
active_box_shadow = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('box-shadow');")
page.driver.browser.action.release(toggle.native)
- .move_by(100, 100)
- .perform
+ .move_by(100, 100)
+ .perform
- find('.mini-pipeline-graph-dropdown-toggle')
+ find(".mini-pipeline-graph-dropdown-toggle")
focus_background_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('background-color');")
focus_foreground_color = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible svg').css('fill');")
focus_box_shadow = evaluate_script("$('.mini-pipeline-graph-dropdown-toggle:visible').css('box-shadow');")
@@ -93,23 +93,23 @@ describe 'Merge request < User sees mini pipeline graph', :js do
expect(focus_background_color).to eq(hover_background_color)
expect(focus_foreground_color).to eq(hover_foreground_color)
- expect(default_box_shadow).to eq('none')
- expect(hover_box_shadow).to eq('none')
- expect(active_box_shadow).not_to eq('none')
- expect(focus_box_shadow).not_to eq('none')
+ expect(default_box_shadow).to eq("none")
+ expect(hover_box_shadow).to eq("none")
+ expect(active_box_shadow).not_to eq("none")
+ expect(focus_box_shadow).not_to eq("none")
end
- it 'shows tooltip when hovered' do
+ it "shows tooltip when hovered" do
toggle.hover
- expect(page).to have_selector('.tooltip')
+ expect(page).to have_selector(".tooltip")
end
end
- describe 'builds list menu' do
+ describe "builds list menu" do
let(:toggle) do
- find('.mini-pipeline-graph-dropdown-toggle')
- first('.mini-pipeline-graph-dropdown-toggle')
+ find(".mini-pipeline-graph-dropdown-toggle")
+ first(".mini-pipeline-graph-dropdown-toggle")
end
before do
@@ -117,39 +117,39 @@ describe 'Merge request < User sees mini pipeline graph', :js do
wait_for_requests
end
- it 'pens when toggle is clicked' do
- expect(toggle.find(:xpath, '..')).to have_selector('.mini-pipeline-graph-dropdown-menu')
+ it "pens when toggle is clicked" do
+ expect(toggle.find(:xpath, "..")).to have_selector(".mini-pipeline-graph-dropdown-menu")
end
- it 'closes when toggle is clicked again' do
+ it "closes when toggle is clicked again" do
toggle.click
- expect(toggle.find(:xpath, '..')).not_to have_selector('.mini-pipeline-graph-dropdown-menu')
+ expect(toggle.find(:xpath, "..")).not_to have_selector(".mini-pipeline-graph-dropdown-menu")
end
- it 'closes when clicking somewhere else' do
- find('body').click
+ it "closes when clicking somewhere else" do
+ find("body").click
- expect(toggle.find(:xpath, '..')).not_to have_selector('.mini-pipeline-graph-dropdown-menu')
+ expect(toggle.find(:xpath, "..")).not_to have_selector(".mini-pipeline-graph-dropdown-menu")
end
- describe 'build list build item' do
+ describe "build list build item" do
let(:build_item) do
- find('.mini-pipeline-graph-dropdown-item')
- first('.mini-pipeline-graph-dropdown-item')
+ find(".mini-pipeline-graph-dropdown-item")
+ first(".mini-pipeline-graph-dropdown-item")
end
- it 'visits the build page when clicked' do
+ it "visits the build page when clicked" do
build_item.click
- find('.build-page')
+ find(".build-page")
expect(current_path).to eql(project_job_path(project, build))
end
- it 'shows tooltip when hovered' do
+ it "shows tooltip when hovered" do
build_item.hover
- expect(page).to have_selector('.tooltip')
+ expect(page).to have_selector(".tooltip")
end
end
end
diff --git a/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb b/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb
index fc4a188d4a7..f49206671ee 100644
--- a/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb
+++ b/spec/features/merge_request/user_sees_mr_from_deleted_forked_project_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees MR from deleted forked project', :js do
+describe "Merge request > User sees MR from deleted forked project", :js do
include ProjectForksHelper
let(:project) { create(:project, :public, :repository) }
@@ -9,7 +9,7 @@ describe 'Merge request > User sees MR from deleted forked project', :js do
let!(:merge_request) do
create(:merge_request_with_diffs, source_project: forked_project,
target_project: project,
- description: 'Test merge request')
+ description: "Test merge request")
end
before do
@@ -19,8 +19,8 @@ describe 'Merge request > User sees MR from deleted forked project', :js do
visit project_merge_request_path(project, merge_request)
end
- it 'user can access merge request' do
- expect(page).to have_content 'Test merge request'
+ it "user can access merge request" do
+ expect(page).to have_content "Test merge request"
expect(page).to have_content "(removed):#{merge_request.source_branch}"
end
end
diff --git a/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb b/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb
index fd4175d5227..f5019a8e2c7 100644
--- a/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb
+++ b/spec/features/merge_request/user_sees_mr_with_deleted_source_branch_spec.rb
@@ -1,34 +1,34 @@
-require 'rails_helper'
+require "rails_helper"
# This test serves as a regression test for a bug that caused an error
# message to be shown by JavaScript when the source branch was deleted.
# Please do not remove ":js".
-describe 'Merge request > User sees MR with deleted source branch', :js do
+describe "Merge request > User sees MR with deleted source branch", :js do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:user) { project.creator }
before do
- merge_request.update!(source_branch: 'this-branch-does-not-exist')
+ merge_request.update!(source_branch: "this-branch-does-not-exist")
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'shows a message about missing source branch' do
- expect(page).to have_content('Source branch does not exist.')
+ it "shows a message about missing source branch" do
+ expect(page).to have_content("Source branch does not exist.")
end
- it 'still contains Discussion, Commits and Changes tabs' do
- within '.merge-request-details' do
- expect(page).to have_content('Discussion')
- expect(page).to have_content('Commits')
- expect(page).to have_content('Changes')
+ it "still contains Discussion, Commits and Changes tabs" do
+ within ".merge-request-details" do
+ expect(page).to have_content("Discussion")
+ expect(page).to have_content("Commits")
+ expect(page).to have_content("Changes")
end
- click_on 'Changes'
+ click_on "Changes"
wait_for_requests
- expect(page).to have_selector('.diffs.tab-pane .file-holder')
- expect(page).to have_content('Source branch does not exist.')
+ expect(page).to have_selector(".diffs.tab-pane .file-holder")
+ expect(page).to have_content("Source branch does not exist.")
end
end
diff --git a/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb
index a6118453540..61757d7c8c3 100644
--- a/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb
+++ b/spec/features/merge_request/user_sees_notes_from_forked_project_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees notes from forked project', :js do
+describe "Merge request > User sees notes from forked project", :js do
include ProjectForksHelper
let(:project) { create(:project, :public, :repository) }
@@ -9,29 +9,29 @@ describe 'Merge request > User sees notes from forked project', :js do
let!(:merge_request) do
create(:merge_request_with_diffs, source_project: forked_project,
target_project: project,
- description: 'Test merge request')
+ description: "Test merge request")
end
before do
- create(:note_on_commit, note: 'A commit comment',
+ create(:note_on_commit, note: "A commit comment",
project: forked_project,
commit_id: merge_request.commit_shas.first)
sign_in(user)
end
- it 'user can reply to the comment' do
+ it "user can reply to the comment" do
visit project_merge_request_path(project, merge_request)
- expect(page).to have_content('A commit comment')
+ expect(page).to have_content("A commit comment")
- page.within('.discussion-notes') do
- find('.btn-text-field').click
- find('#note_note').send_keys('A reply comment')
- find('.js-comment-button').click
+ page.within(".discussion-notes") do
+ find(".btn-text-field").click
+ find("#note_note").send_keys("A reply comment")
+ find(".js-comment-button").click
end
wait_for_requests
- expect(page).to have_content('A reply comment')
+ expect(page).to have_content("A reply comment")
end
end
diff --git a/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb
index 97093bbc2f6..de7dcd06a88 100644
--- a/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb
+++ b/spec/features/merge_request/user_sees_pipelines_from_forked_project_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees pipelines from forked project', :js do
+describe "Merge request > User sees pipelines from forked project", :js do
include ProjectForksHelper
let(:target_project) { create(:project, :public, :repository) }
@@ -9,27 +9,27 @@ describe 'Merge request > User sees pipelines from forked project', :js do
let!(:merge_request) do
create(:merge_request_with_diffs, source_project: forked_project,
target_project: target_project,
- description: 'Test merge request')
+ description: "Test merge request")
end
let(:pipeline) do
create(:ci_pipeline,
- project: forked_project,
- sha: merge_request.diff_head_sha,
- ref: merge_request.source_branch)
+ project: forked_project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch)
end
before do
- create(:ci_build, pipeline: pipeline, name: 'rspec')
- create(:ci_build, pipeline: pipeline, name: 'spinach')
+ create(:ci_build, pipeline: pipeline, name: "rspec")
+ create(:ci_build, pipeline: pipeline, name: "spinach")
sign_in(user)
visit project_merge_request_path(target_project, merge_request)
end
- it 'user visits a pipelines page' do
- page.within('.merge-request-tabs') { click_link 'Pipelines' }
+ it "user visits a pipelines page" do
+ page.within(".merge-request-tabs") { click_link "Pipelines" }
- page.within('.ci-table') do
+ page.within(".ci-table") do
expect(page).to have_content(pipeline.id)
end
end
diff --git a/spec/features/merge_request/user_sees_pipelines_spec.rb b/spec/features/merge_request/user_sees_pipelines_spec.rb
index 8faddee4daa..a9fa90939b0 100644
--- a/spec/features/merge_request/user_sees_pipelines_spec.rb
+++ b/spec/features/merge_request/user_sees_pipelines_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees pipelines', :js do
- describe 'pipeline tab' do
+describe "Merge request > User sees pipelines", :js do
+ describe "pipeline tab" do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.target_project }
let(:user) { project.creator }
@@ -11,61 +11,61 @@ describe 'Merge request > User sees pipelines', :js do
sign_in(user)
end
- context 'with pipelines' do
+ context "with pipelines" do
let!(:pipeline) do
create(:ci_empty_pipeline,
- project: merge_request.source_project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha)
+ project: merge_request.source_project,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha)
end
before do
merge_request.update_attribute(:head_pipeline_id, pipeline.id)
end
- it 'user visits merge request pipelines tab' do
+ it "user visits merge request pipelines tab" do
visit project_merge_request_path(project, merge_request)
- expect(page.find('.ci-widget')).to have_content('pending')
+ expect(page.find(".ci-widget")).to have_content("pending")
- page.within('.merge-request-tabs') do
- click_link('Pipelines')
+ page.within(".merge-request-tabs") do
+ click_link("Pipelines")
end
wait_for_requests
- expect(page).to have_selector('.stage-cell')
+ expect(page).to have_selector(".stage-cell")
end
- it 'pipeline sha does not equal last commit sha' do
- pipeline.update_attribute(:sha, '19e2e9b4ef76b422ce1154af39a91323ccc57434')
+ it "pipeline sha does not equal last commit sha" do
+ pipeline.update_attribute(:sha, "19e2e9b4ef76b422ce1154af39a91323ccc57434")
visit project_merge_request_path(project, merge_request)
wait_for_requests
- expect(page.find('.ci-widget')).to have_text("Could not retrieve the pipeline status. For troubleshooting steps, read the documentation.")
+ expect(page.find(".ci-widget")).to have_text("Could not retrieve the pipeline status. For troubleshooting steps, read the documentation.")
end
end
- context 'without pipelines' do
+ context "without pipelines" do
before do
visit project_merge_request_path(project, merge_request)
end
- it 'user visits merge request page' do
- page.within('.merge-request-tabs') do
- expect(page).to have_no_link('Pipelines')
+ it "user visits merge request page" do
+ page.within(".merge-request-tabs") do
+ expect(page).to have_no_link("Pipelines")
end
end
end
end
- describe 'race condition' do
+ describe "race condition" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- let(:build_push_data) { { ref: 'feature', checkout_sha: TestEnv::BRANCH_SHA['feature'] } }
+ let(:build_push_data) { {ref: "feature", checkout_sha: TestEnv::BRANCH_SHA["feature"]} }
let(:merge_request_params) do
- { "source_branch" => "feature", "source_project_id" => project.id,
- "target_branch" => "master", "target_project_id" => project.id, "title" => "A" }
+ {"source_branch" => "feature", "source_project_id" => project.id,
+ "target_branch" => "master", "target_project_id" => project.id, "title" => "A",}
end
before do
@@ -73,27 +73,27 @@ describe 'Merge request > User sees pipelines', :js do
sign_in user
end
- context 'when pipeline and merge request were created simultaneously' do
+ context "when pipeline and merge request were created simultaneously" do
before do
stub_ci_pipeline_to_return_yaml_file
threads = []
- threads << Thread.new do
+ threads << Thread.new {
@merge_request = MergeRequests::CreateService.new(project, user, merge_request_params).execute
- end
+ }
- threads << Thread.new do
+ threads << Thread.new {
@pipeline = Ci::CreatePipelineService.new(project, user, build_push_data).execute(:push)
- end
+ }
threads.each { |thr| thr.join }
end
- it 'user sees pipeline in merge request widget' do
+ it "user sees pipeline in merge request widget" do
visit project_merge_request_path(project, @merge_request)
- expect(page.find(".ci-widget")).to have_content(TestEnv::BRANCH_SHA['feature'])
+ expect(page.find(".ci-widget")).to have_content(TestEnv::BRANCH_SHA["feature"])
expect(page.find(".ci-widget")).to have_content("##{@pipeline.id}")
end
end
diff --git a/spec/features/merge_request/user_sees_system_notes_spec.rb b/spec/features/merge_request/user_sees_system_notes_spec.rb
index c6811d4161a..25a1d90eb44 100644
--- a/spec/features/merge_request/user_sees_system_notes_spec.rb
+++ b/spec/features/merge_request/user_sees_system_notes_spec.rb
@@ -1,31 +1,31 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees system notes', :js do
+describe "Merge request > User sees system notes", :js do
let(:public_project) { create(:project, :public, :repository) }
let(:private_project) { create(:project, :private, :repository) }
let(:user) { private_project.creator }
let(:issue) { create(:issue, project: private_project) }
- let(:merge_request) { create(:merge_request, source_project: public_project, source_branch: 'markdown') }
+ let(:merge_request) { create(:merge_request, source_project: public_project, source_branch: "markdown") }
let!(:note) { create(:note_on_merge_request, :system, noteable: merge_request, project: public_project, note: "mentioned in #{issue.to_reference(public_project)}") }
- context 'when logged-in as a member of the private project' do
+ context "when logged-in as a member of the private project" do
before do
private_project.add_developer(user)
sign_in(user)
end
- it 'shows the system note' do
+ it "shows the system note" do
visit project_merge_request_path(public_project, merge_request)
- expect(page).to have_css('.system-note')
+ expect(page).to have_css(".system-note")
end
end
- context 'when not logged-in' do
- it 'hides the system note' do
+ context "when not logged-in" do
+ it "hides the system note" do
visit project_merge_request_path(public_project, merge_request)
- expect(page).not_to have_css('.system-note')
+ expect(page).not_to have_css(".system-note")
end
end
end
diff --git a/spec/features/merge_request/user_sees_versions_spec.rb b/spec/features/merge_request/user_sees_versions_spec.rb
index aa91ade46ca..0fe6f971d53 100644
--- a/spec/features/merge_request/user_sees_versions_spec.rb
+++ b/spec/features/merge_request/user_sees_versions_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees versions', :js do
+describe "Merge request > User sees versions", :js do
let(:merge_request) { create(:merge_request, importing: true) }
let(:project) { merge_request.source_project }
let(:user) { project.creator }
- let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
let!(:params) { {} }
before do
@@ -15,7 +15,7 @@ describe 'Merge request > User sees versions', :js do
visit diffs_project_merge_request_path(project, merge_request, params)
end
- shared_examples 'allows commenting' do |file_id:, line_code:, comment:|
+ shared_examples "allows commenting" do |file_id:, line_code:, comment:|
it do
diff_file_selector = ".diff-file[id='#{file_id}']"
line_code = "#{file_id}_#{line_code}"
@@ -36,47 +36,47 @@ describe 'Merge request > User sees versions', :js do
end
end
- describe 'compare with the latest version' do
- it 'show the latest version of the diff' do
- page.within '.mr-version-dropdown' do
- expect(page).to have_content 'latest version'
+ describe "compare with the latest version" do
+ it "show the latest version of the diff" do
+ page.within ".mr-version-dropdown" do
+ expect(page).to have_content "latest version"
end
- expect(page).to have_content '8 Files'
+ expect(page).to have_content "8 Files"
end
- it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '1_1',
- comment: 'Typo, please fix.'
+ it_behaves_like "allows commenting",
+ file_id: "7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44",
+ line_code: "1_1",
+ comment: "Typo, please fix."
end
- describe 'switch between versions' do
+ describe "switch between versions" do
before do
- page.within '.mr-version-dropdown' do
- find('.btn-default').click
- click_link 'version 1'
+ page.within ".mr-version-dropdown" do
+ find(".btn-default").click
+ click_link "version 1"
end
# Wait for the page to load
- page.within '.mr-version-dropdown' do
- expect(page).to have_content 'version 1'
+ page.within ".mr-version-dropdown" do
+ expect(page).to have_content "version 1"
end
end
- it 'shows the commit SHAs for every version in the dropdown' do
- page.within '.mr-version-dropdown' do
- find('.btn-default').click
+ it "shows the commit SHAs for every version in the dropdown" do
+ page.within ".mr-version-dropdown" do
+ find(".btn-default").click
- page.within('.dropdown-content') do
+ page.within(".dropdown-content") do
shas = merge_request.merge_request_diffs.map { |diff| Commit.truncate_sha(diff.head_commit_sha) }
shas.each { |sha| expect(page).to have_content(sha) }
end
end
end
- it 'shows comments that were last relevant at that version' do
- expect(page).to have_content '5 Files'
+ it "shows comments that were last relevant at that version" do
+ expect(page).to have_content "5 Files"
position = Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -94,41 +94,41 @@ describe 'Merge request > User sees versions', :js do
expect(page).to have_css(".diffs .notes[data-discussion-id='#{outdated_diff_note.discussion_id}']")
end
- it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '2_2',
- comment: 'Typo, please fix.'
+ it_behaves_like "allows commenting",
+ file_id: "7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44",
+ line_code: "2_2",
+ comment: "Typo, please fix."
end
- describe 'compare with older version' do
+ describe "compare with older version" do
before do
- page.within '.mr-version-compare-dropdown' do
- find('.btn-default').click
- click_link 'version 1'
+ page.within ".mr-version-compare-dropdown" do
+ find(".btn-default").click
+ click_link "version 1"
end
# Wait for the page to load
- page.within '.mr-version-compare-dropdown' do
- expect(page).to have_content 'version 1'
+ page.within ".mr-version-compare-dropdown" do
+ expect(page).to have_content "version 1"
end
end
- it 'has a path with comparison context and shows comments that were last relevant at that version' do
+ it "has a path with comparison context and shows comments that were last relevant at that version" do
expect(page).to have_current_path diffs_project_merge_request_path(
project,
merge_request.iid,
diff_id: merge_request_diff3.id,
- start_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
+ start_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
)
- expect(page).to have_content '4 Files'
+ expect(page).to have_content "4 Files"
- additions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition')
- .ancestor('.diff-stats-group').text
- deletions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion')
- .ancestor('.diff-stats-group').text
+ additions_content = page.find(".diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition")
+ .ancestor(".diff-stats-group").text
+ deletions_content = page.find(".diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion")
+ .ancestor(".diff-stats-group").text
- expect(additions_content).to eq '15'
- expect(deletions_content).to eq '6'
+ expect(additions_content).to eq "15"
+ expect(deletions_content).to eq "6"
position = Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -147,95 +147,95 @@ describe 'Merge request > User sees versions', :js do
expect(page).to have_css(".diffs .notes[data-discussion-id='#{outdated_diff_note.discussion_id}']")
end
- it 'show diff between new and old version' do
- additions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition')
- .ancestor('.diff-stats-group').text
- deletions_content = page.find('.diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion')
- .ancestor('.diff-stats-group').text
+ it "show diff between new and old version" do
+ additions_content = page.find(".diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-addition")
+ .ancestor(".diff-stats-group").text
+ deletions_content = page.find(".diff-stats.is-compare-versions-header .diff-stats-group svg.ic-file-deletion")
+ .ancestor(".diff-stats-group").text
- expect(page).to have_content '4 Files'
- expect(additions_content).to eq '15'
- expect(deletions_content).to eq '6'
+ expect(page).to have_content "4 Files"
+ expect(additions_content).to eq "15"
+ expect(deletions_content).to eq "6"
end
it 'returns to latest version when "Show latest version" button is clicked' do
- click_link 'Show latest version'
- page.within '.mr-version-dropdown' do
- expect(page).to have_content 'latest version'
+ click_link "Show latest version"
+ page.within ".mr-version-dropdown" do
+ expect(page).to have_content "latest version"
end
- expect(page).to have_content '8 Files'
+ expect(page).to have_content "8 Files"
end
- it_behaves_like 'allows commenting',
- file_id: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44',
- line_code: '4_4',
- comment: 'Typo, please fix.'
+ it_behaves_like "allows commenting",
+ file_id: "7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44",
+ line_code: "4_4",
+ comment: "Typo, please fix."
end
- describe 'compare with same version' do
+ describe "compare with same version" do
before do
- page.within '.mr-version-compare-dropdown' do
- find('.btn-default').click
- click_link 'version 1'
+ page.within ".mr-version-compare-dropdown" do
+ find(".btn-default").click
+ click_link "version 1"
end
end
- it 'has 0 chages between versions' do
- page.within '.mr-version-compare-dropdown' do
- expect(find('.dropdown-menu-toggle')).to have_content 'version 1'
+ it "has 0 chages between versions" do
+ page.within ".mr-version-compare-dropdown" do
+ expect(find(".dropdown-menu-toggle")).to have_content "version 1"
end
- page.within '.mr-version-dropdown' do
- find('.btn-default').click
- click_link 'version 1'
+ page.within ".mr-version-dropdown" do
+ find(".btn-default").click
+ click_link "version 1"
end
- expect(page).to have_content '0 Files'
+ expect(page).to have_content "0 Files"
end
end
- describe 'compare with newer version' do
+ describe "compare with newer version" do
before do
- page.within '.mr-version-compare-dropdown' do
- find('.btn-default').click
- click_link 'version 2'
+ page.within ".mr-version-compare-dropdown" do
+ find(".btn-default").click
+ click_link "version 2"
end
end
- it 'sets the compared versions to be the same' do
- page.within '.mr-version-compare-dropdown' do
- expect(find('.dropdown-menu-toggle')).to have_content 'version 2'
+ it "sets the compared versions to be the same" do
+ page.within ".mr-version-compare-dropdown" do
+ expect(find(".dropdown-menu-toggle")).to have_content "version 2"
end
- page.within '.mr-version-dropdown' do
- find('.btn-default').click
- click_link 'version 1'
+ page.within ".mr-version-dropdown" do
+ find(".btn-default").click
+ click_link "version 1"
end
- page.within '.mr-version-compare-dropdown' do
- expect(page).to have_content 'version 1'
+ page.within ".mr-version-compare-dropdown" do
+ expect(page).to have_content "version 1"
end
- expect(page).to have_content '0 Files'
+ expect(page).to have_content "0 Files"
end
end
- describe 'scoped in a commit' do
- let(:params) { { commit_id: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d' } }
+ describe "scoped in a commit" do
+ let(:params) { {commit_id: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"} }
before do
wait_for_requests
end
- it 'should only show diffs from the commit' do
- diff_commit_ids = find_all('.diff-file [data-commit-id]').map {|diff| diff['data-commit-id']}
+ it "should only show diffs from the commit" do
+ diff_commit_ids = find_all(".diff-file [data-commit-id]").map {|diff| diff["data-commit-id"]}
expect(diff_commit_ids).not_to be_empty
expect(diff_commit_ids).to all(eq(params[:commit_id]))
end
- it_behaves_like 'allows commenting',
- file_id: '2f6fcd96b88b36ce98c38da085c795a27d92a3dd',
- line_code: '6_6',
- comment: 'Typo, please fix.'
+ it_behaves_like "allows commenting",
+ file_id: "2f6fcd96b88b36ce98c38da085c795a27d92a3dd",
+ line_code: "6_6",
+ comment: "Typo, please fix."
end
end
diff --git a/spec/features/merge_request/user_sees_wip_help_message_spec.rb b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
index 92cc73ddf1f..158e7e75981 100644
--- a/spec/features/merge_request/user_sees_wip_help_message_spec.rb
+++ b/spec/features/merge_request/user_sees_wip_help_message_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees WIP help message' do
+describe "Merge request > User sees WIP help message" do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
@@ -9,39 +9,41 @@ describe 'Merge request > User sees WIP help message' do
sign_in(user)
end
- context 'with WIP commits' do
- it 'shows a specific WIP hint' do
+ context "with WIP commits" do
+ it "shows a specific WIP hint" do
visit project_new_merge_request_path(
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'wip',
- target_branch: 'master'
- })
+ source_branch: "wip",
+ target_branch: "master",
+ }
+ )
within_wip_explanation do
expect(page).to have_text(
- 'It looks like you have some WIP commits in this branch'
+ "It looks like you have some WIP commits in this branch"
)
end
end
end
- context 'without WIP commits' do
- it 'shows the regular WIP message' do
+ context "without WIP commits" do
+ it "shows the regular WIP message" do
visit project_new_merge_request_path(
project,
merge_request: {
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'fix',
- target_branch: 'master'
- })
+ source_branch: "fix",
+ target_branch: "master",
+ }
+ )
within_wip_explanation do
expect(page).not_to have_text(
- 'It looks like you have some WIP commits in this branch'
+ "It looks like you have some WIP commits in this branch"
)
expect(page).to have_text(
"Start the title with WIP: to prevent a Work In Progress merge \
@@ -52,7 +54,7 @@ request from being merged before it's ready"
end
def within_wip_explanation(&block)
- page.within '.js-no-wip-explanation' do
+ page.within ".js-no-wip-explanation" do
yield
end
end
diff --git a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
index ae41cf90576..770ae5c2481 100644
--- a/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
+++ b/spec/features/merge_request/user_selects_branches_for_new_mr_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User selects branches for new MR', :js do
+describe "Merge request > User selects branches for new MR", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
def select_source_branch(branch_name)
- find('.js-source-branch', match: :first).click
- find('.js-source-branch-dropdown .dropdown-input-field').native.send_keys branch_name
- find('.js-source-branch-dropdown .dropdown-content a', text: branch_name, match: :first).click
+ find(".js-source-branch", match: :first).click
+ find(".js-source-branch-dropdown .dropdown-input-field").native.send_keys branch_name
+ find(".js-source-branch-dropdown .dropdown-content a", text: branch_name, match: :first).click
end
before do
@@ -15,41 +15,41 @@ describe 'Merge request > User selects branches for new MR', :js do
sign_in(user)
end
- it 'selects the source branch sha when a tag with the same name exists' do
+ it "selects the source branch sha when a tag with the same name exists" do
visit project_merge_requests_path(project)
- page.within '.content' do
- click_link 'New merge request'
+ page.within ".content" do
+ click_link "New merge request"
end
- expect(page).to have_content('Source branch')
- expect(page).to have_content('Target branch')
+ expect(page).to have_content("Source branch")
+ expect(page).to have_content("Target branch")
- first('.js-source-branch').click
- find('.js-source-branch-dropdown .dropdown-content a', match: :first).click
+ first(".js-source-branch").click
+ find(".js-source-branch-dropdown .dropdown-content a", match: :first).click
expect(page).to have_content "b83d6e3"
end
- it 'selects the target branch sha when a tag with the same name exists' do
+ it "selects the target branch sha when a tag with the same name exists" do
visit project_merge_requests_path(project)
- page.within '.content' do
- click_link 'New merge request'
+ page.within ".content" do
+ click_link "New merge request"
end
- expect(page).to have_content('Source branch')
- expect(page).to have_content('Target branch')
+ expect(page).to have_content("Source branch")
+ expect(page).to have_content("Target branch")
- first('.js-target-branch').click
- find('.js-target-branch-dropdown .dropdown-content a', text: 'v1.1.0', match: :first).click
+ first(".js-target-branch").click
+ find(".js-target-branch-dropdown .dropdown-content a", text: "v1.1.0", match: :first).click
expect(page).to have_content "b83d6e3"
end
- it 'generates a diff for an orphaned branch' do
+ it "generates a diff for an orphaned branch" do
visit project_new_merge_request_path(project)
- select_source_branch('orphaned-branch')
+ select_source_branch("orphaned-branch")
click_button "Compare branches"
click_link "Changes"
@@ -62,85 +62,85 @@ describe 'Merge request > User selects branches for new MR', :js do
click_button "Check out branch"
- expect(page).to have_content 'git checkout -b orphaned-branch origin/orphaned-branch'
+ expect(page).to have_content "git checkout -b orphaned-branch origin/orphaned-branch"
end
- it 'allows filtering multiple dropdowns' do
+ it "allows filtering multiple dropdowns" do
visit project_new_merge_request_path(project)
- first('.js-source-branch').click
+ first(".js-source-branch").click
- page.within '.js-source-branch-dropdown' do
- input = find('.dropdown-input-field')
+ page.within ".js-source-branch-dropdown" do
+ input = find(".dropdown-input-field")
input.click
- input.send_keys('orphaned-branch')
+ input.send_keys("orphaned-branch")
- expect(page).to have_css('.dropdown-content li', count: 1)
+ expect(page).to have_css(".dropdown-content li", count: 1)
end
- first('.js-target-branch').click
+ first(".js-target-branch").click
- find('.js-target-branch-dropdown .dropdown-content li', match: :first)
- target_items = all('.js-target-branch-dropdown .dropdown-content li')
+ find(".js-target-branch-dropdown .dropdown-content li", match: :first)
+ target_items = all(".js-target-branch-dropdown .dropdown-content li")
expect(target_items.count).to be > 1
end
- context 'when target project cannot be viewed by the current user' do
- it 'does not leak the private project name & namespace' do
+ context "when target project cannot be viewed by the current user" do
+ it "does not leak the private project name & namespace" do
private_project = create(:project, :private, :repository)
- visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id })
+ visit project_new_merge_request_path(project, merge_request: {target_project_id: private_project.id})
expect(page).not_to have_content private_project.full_path
expect(page).to have_content project.full_path
end
end
- context 'when source project cannot be viewed by the current user' do
- it 'does not leak the private project name & namespace' do
+ context "when source project cannot be viewed by the current user" do
+ it "does not leak the private project name & namespace" do
private_project = create(:project, :private, :repository)
- visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id })
+ visit project_new_merge_request_path(project, merge_request: {source_project_id: private_project.id})
expect(page).not_to have_content private_project.full_path
expect(page).to have_content project.full_path
end
end
- it 'populates source branch button' do
- visit project_new_merge_request_path(project, change_branches: true, merge_request: { target_branch: 'master', source_branch: 'fix' })
+ it "populates source branch button" do
+ visit project_new_merge_request_path(project, change_branches: true, merge_request: {target_branch: "master", source_branch: "fix"})
- expect(find('.js-source-branch')).to have_content('fix')
+ expect(find(".js-source-branch")).to have_content("fix")
end
- it 'allows to change the diff view' do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'fix' })
+ it "allows to change the diff view" do
+ visit project_new_merge_request_path(project, merge_request: {target_branch: "master", source_branch: "fix"})
- click_link 'Changes'
+ click_link "Changes"
- expect(page).to have_css('a.btn.active', text: 'Inline')
- expect(page).not_to have_css('a.btn.active', text: 'Side-by-side')
+ expect(page).to have_css("a.btn.active", text: "Inline")
+ expect(page).not_to have_css("a.btn.active", text: "Side-by-side")
- click_link 'Side-by-side'
+ click_link "Side-by-side"
- within '.merge-request' do
- expect(page).not_to have_css('a.btn.active', text: 'Inline')
- expect(page).to have_css('a.btn.active', text: 'Side-by-side')
+ within ".merge-request" do
+ expect(page).not_to have_css("a.btn.active", text: "Inline")
+ expect(page).to have_css("a.btn.active", text: "Side-by-side")
end
end
- it 'does not allow non-existing branches' do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' })
+ it "does not allow non-existing branches" do
+ visit project_new_merge_request_path(project, merge_request: {target_branch: "non-exist-target", source_branch: "non-exist-source"})
- expect(page).to have_content('The form contains the following errors')
+ expect(page).to have_content("The form contains the following errors")
expect(page).to have_content('Source branch "non-exist-source" does not exist')
expect(page).to have_content('Target branch "non-exist-target" does not exist')
end
- context 'when a branch contains commits that both delete and add the same image' do
- it 'renders the diff successfully' do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'deleted-image-test' })
+ context "when a branch contains commits that both delete and add the same image" do
+ it "renders the diff successfully" do
+ visit project_new_merge_request_path(project, merge_request: {target_branch: "master", source_branch: "deleted-image-test"})
click_link "Changes"
@@ -149,37 +149,38 @@ describe 'Merge request > User selects branches for new MR', :js do
end
# Isolates a regression (see #24627)
- it 'does not show error messages on initial form' do
+ it "does not show error messages on initial form" do
visit project_new_merge_request_path(project)
- expect(page).not_to have_selector('#error_explanation')
- expect(page).not_to have_content('The form contains the following error')
+ expect(page).not_to have_selector("#error_explanation")
+ expect(page).not_to have_content("The form contains the following error")
end
- context 'when a new merge request has a pipeline' do
+ context "when a new merge request has a pipeline" do
let!(:pipeline) do
- create(:ci_pipeline, sha: project.commit('fix').id,
- ref: 'fix',
+ create(:ci_pipeline, sha: project.commit("fix").id,
+ ref: "fix",
project: project)
end
- it 'shows pipelines for a new merge request' do
+ it "shows pipelines for a new merge request" do
visit project_new_merge_request_path(
project,
- merge_request: { target_branch: 'master', source_branch: 'fix' })
+ merge_request: {target_branch: "master", source_branch: "fix"}
+ )
- page.within('.merge-request') do
- click_link 'Pipelines'
+ page.within(".merge-request") do
+ click_link "Pipelines"
expect(page).to have_content "##{pipeline.id}"
end
end
end
- context 'with special characters in branch names' do
- it 'escapes quotes in branch names' do
+ context "with special characters in branch names" do
+ it "escapes quotes in branch names" do
special_branch_name = '"with-quotes"'
CreateBranchService.new(project, user)
- .execute(special_branch_name, 'add-pdf-file')
+ .execute(special_branch_name, "add-pdf-file")
visit project_new_merge_request_path(project)
select_source_branch(special_branch_name)
@@ -188,10 +189,10 @@ describe 'Merge request > User selects branches for new MR', :js do
expect(source_branch_input.value).to eq special_branch_name
end
- it 'does not escape unicode in branch names' do
- special_branch_name = 'ʕ•ᴥ•ʔ'
+ it "does not escape unicode in branch names" do
+ special_branch_name = "ʕ•ᴥ•ʔ"
CreateBranchService.new(project, user)
- .execute(special_branch_name, 'add-pdf-file')
+ .execute(special_branch_name, "add-pdf-file")
visit project_new_merge_request_path(project)
select_source_branch(special_branch_name)
diff --git a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
index c19e299097e..80f50fbdcf1 100644
--- a/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
+++ b/spec/features/merge_request/user_suggests_changes_on_diff_spec.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'User comments on a diff', :js do
+describe "User comments on a diff", :js do
include MergeRequestDiffHelpers
include RepoHelpers
let(:project) { create(:project, :repository) }
let(:merge_request) do
- create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
+ create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: "merge-test")
end
let(:user) { create(:user) }
@@ -19,66 +19,66 @@ describe 'User comments on a diff', :js do
visit(diffs_project_merge_request_path(project, merge_request))
end
- context 'single suggestion note' do
- it 'suggestion is presented' do
+ context "single suggestion note" do
+ it "suggestion is presented" do
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: "```suggestion\n# change to a comment\n```")
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "```suggestion\n# change to a comment\n```")
+ click_button("Comment")
end
wait_for_requests
- page.within('.diff-discussions') do
- expect(page).to have_button('Apply suggestion')
- expect(page).to have_content('Suggested change')
- expect(page).to have_content(' url = https://github.com/gitlabhq/gitlab-shell.git')
- expect(page).to have_content('# change to a comment')
+ page.within(".diff-discussions") do
+ expect(page).to have_button("Apply suggestion")
+ expect(page).to have_content("Suggested change")
+ expect(page).to have_content("\turl = https://github.com/gitlabhq/gitlab-shell.git")
+ expect(page).to have_content("# change to a comment")
end
end
- it 'suggestion is appliable' do
+ it "suggestion is appliable" do
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: "```suggestion\n# change to a comment\n```")
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "```suggestion\n# change to a comment\n```")
+ click_button("Comment")
end
wait_for_requests
- page.within('.diff-discussions') do
- expect(page).not_to have_content('Applied')
+ page.within(".diff-discussions") do
+ expect(page).not_to have_content("Applied")
- click_button('Apply suggestion')
+ click_button("Apply suggestion")
wait_for_requests
- expect(page).to have_content('Applied')
+ expect(page).to have_content("Applied")
end
end
end
- context 'multiple suggestions in a single note' do
- it 'suggestions are presented' do
+ context "multiple suggestions in a single note" do
+ it "suggestions are presented" do
click_diff_line(find("[id='#{sample_compare.changes[1][:line_code]}']"))
- page.within('.js-discussion-note-form') do
- fill_in('note_note', with: "```suggestion\n# change to a comment\n```\n```suggestion\n# or that\n```")
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in("note_note", with: "```suggestion\n# change to a comment\n```\n```suggestion\n# or that\n```")
+ click_button("Comment")
end
wait_for_requests
- page.within('.diff-discussions') do
- suggestion_1 = page.all(:css, '.md-suggestion-diff')[0]
- suggestion_2 = page.all(:css, '.md-suggestion-diff')[1]
+ page.within(".diff-discussions") do
+ suggestion_1 = page.all(:css, ".md-suggestion-diff")[0]
+ suggestion_2 = page.all(:css, ".md-suggestion-diff")[1]
- expect(suggestion_1).to have_content(' url = https://github.com/gitlabhq/gitlab-shell.git')
- expect(suggestion_1).to have_content('# change to a comment')
+ expect(suggestion_1).to have_content("\turl = https://github.com/gitlabhq/gitlab-shell.git")
+ expect(suggestion_1).to have_content("# change to a comment")
- expect(suggestion_2).to have_content(' url = https://github.com/gitlabhq/gitlab-shell.git')
- expect(suggestion_2).to have_content('# or that')
+ expect(suggestion_2).to have_content("\turl = https://github.com/gitlabhq/gitlab-shell.git")
+ expect(suggestion_2).to have_content("# or that")
end
end
end
diff --git a/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb b/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb
index 0decdfe3a14..b20e7f94722 100644
--- a/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb
+++ b/spec/features/merge_request/user_toggles_whitespace_changes_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User toggles whitespace changes', :js do
+describe "Merge request > User toggles whitespace changes", :js do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
let(:user) { project.creator }
@@ -10,22 +10,22 @@ describe 'Merge request > User toggles whitespace changes', :js do
sign_in(user)
visit diffs_project_merge_request_path(project, merge_request)
- find('.js-show-diff-settings').click
+ find(".js-show-diff-settings").click
end
- it 'has a button to toggle whitespace changes' do
- expect(page).to have_content 'Show whitespace changes'
+ it "has a button to toggle whitespace changes" do
+ expect(page).to have_content "Show whitespace changes"
end
describe 'clicking "Hide whitespace changes" button' do
it 'toggles the "Hide whitespace changes" button' do
- find('#show-whitespace').click
+ find("#show-whitespace").click
visit diffs_project_merge_request_path(project, merge_request)
- find('.js-show-diff-settings').click
+ find(".js-show-diff-settings").click
- expect(find('#show-whitespace')).to be_checked
+ expect(find("#show-whitespace")).to be_checked
end
end
end
diff --git a/spec/features/merge_request/user_tries_to_access_private_repository_through_new_mr_spec.rb b/spec/features/merge_request/user_tries_to_access_private_repository_through_new_mr_spec.rb
index 9318b5f1ebb..ecb12aa5830 100644
--- a/spec/features/merge_request/user_tries_to_access_private_repository_through_new_mr_spec.rb
+++ b/spec/features/merge_request/user_tries_to_access_private_repository_through_new_mr_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Merge Request > Tries to access private repo of public project' do
+describe "Merge Request > Tries to access private repo of public project" do
let(:current_user) { create(:user) }
let(:private_project) do
create(:project, :public, :repository,
- path: 'nothing-to-see-here',
- name: 'nothing to see here',
- repository_access_level: ProjectFeature::PRIVATE)
+ path: "nothing-to-see-here",
+ name: "nothing to see here",
+ repository_access_level: ProjectFeature::PRIVATE)
end
let(:owned_project) do
create(:project, :public, :repository,
- namespace: current_user.namespace,
- creator: current_user)
+ namespace: current_user.namespace,
+ creator: current_user)
end
- context 'when the user enters the querystring info for the other project' do
+ context "when the user enters the querystring info for the other project" do
let(:mr_path) do
project_new_merge_request_diffs_path(
owned_project,
merge_request: {
source_project_id: private_project.id,
- source_branch: 'feature'
+ source_branch: "feature",
}
)
end
@@ -31,7 +31,7 @@ describe 'Merge Request > Tries to access private repo of public project' do
end
it "does not mention the project the user can't see the repo of" do
- expect(page).not_to have_content('nothing-to-see-here')
+ expect(page).not_to have_content("nothing-to-see-here")
end
end
end
diff --git a/spec/features/merge_request/user_uses_quick_actions_spec.rb b/spec/features/merge_request/user_uses_quick_actions_spec.rb
index b81478a481f..01a61f7af30 100644
--- a/spec/features/merge_request/user_uses_quick_actions_spec.rb
+++ b/spec/features/merge_request/user_uses_quick_actions_spec.rb
@@ -1,169 +1,169 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User uses quick actions', :js do
+describe "Merge request > User uses quick actions", :js do
include Spec::Support::Helpers::Features::NotesHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:guest) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project) }
- let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
+ let!(:milestone) { create(:milestone, project: project, title: "ASAP") }
- it_behaves_like 'issuable record that supports quick actions in its description and notes', :merge_request do
+ it_behaves_like "issuable record that supports quick actions in its description and notes", :merge_request do
let(:issuable) { create(:merge_request, source_project: project) }
- let(:new_url_opts) { { merge_request: { source_branch: 'feature', target_branch: 'master' } } }
+ let(:new_url_opts) { {merge_request: {source_branch: "feature", target_branch: "master"}} }
end
- describe 'merge-request-only commands' do
+ describe "merge-request-only commands" do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
- let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
+ let!(:milestone) { create(:milestone, project: project, title: "ASAP") }
before do
project.add_maintainer(user)
end
- describe 'time tracking' do
+ describe "time tracking" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it_behaves_like 'issuable time tracker'
+ it_behaves_like "issuable time tracker"
end
- describe 'toggling the WIP prefix in the title from note' do
- context 'when the current user can toggle the WIP prefix' do
+ describe "toggling the WIP prefix in the title from note" do
+ context "when the current user can toggle the WIP prefix" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'adds the WIP: prefix to the title' do
+ it "adds the WIP: prefix to the title" do
add_note("/wip")
- expect(page).not_to have_content '/wip'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/wip"
+ expect(page).to have_content "Commands applied"
expect(merge_request.reload.work_in_progress?).to eq true
end
- it 'removes the WIP: prefix from the title' do
+ it "removes the WIP: prefix from the title" do
merge_request.title = merge_request.wip_title
merge_request.save
add_note("/wip")
- expect(page).not_to have_content '/wip'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/wip"
+ expect(page).to have_content "Commands applied"
expect(merge_request.reload.work_in_progress?).to eq false
end
end
- context 'when the current user cannot toggle the WIP prefix' do
+ context "when the current user cannot toggle the WIP prefix" do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
- it 'does not change the WIP prefix' do
+ it "does not change the WIP prefix" do
add_note("/wip")
- expect(page).not_to have_content '/wip'
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "/wip"
+ expect(page).not_to have_content "Commands applied"
expect(merge_request.reload.work_in_progress?).to eq false
end
end
end
- describe 'merging the MR from the note' do
- context 'when the current user can merge the MR' do
+ describe "merging the MR from the note" do
+ context "when the current user can merge the MR" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'merges the MR' do
+ it "merges the MR" do
add_note("/merge")
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
expect(merge_request.reload).to be_merged
end
end
- context 'when the head diff changes in the meanwhile' do
+ context "when the head diff changes in the meanwhile" do
before do
- merge_request.source_branch = 'another_branch'
+ merge_request.source_branch = "another_branch"
merge_request.save
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'does not merge the MR' do
+ it "does not merge the MR" do
add_note("/merge")
- expect(page).not_to have_content 'Your commands have been executed!'
+ expect(page).not_to have_content "Your commands have been executed!"
expect(merge_request.reload).not_to be_merged
end
end
- context 'when the current user cannot merge the MR' do
+ context "when the current user cannot merge the MR" do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
- it 'does not merge the MR' do
+ it "does not merge the MR" do
add_note("/merge")
- expect(page).not_to have_content 'Your commands have been executed!'
+ expect(page).not_to have_content "Your commands have been executed!"
expect(merge_request.reload).not_to be_merged
end
end
end
- describe 'adding a due date from note' do
+ describe "adding a due date from note" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'does not recognize the command nor create a note' do
- add_note('/due 2016-08-28')
+ it "does not recognize the command nor create a note" do
+ add_note("/due 2016-08-28")
- expect(page).not_to have_content '/due 2016-08-28'
+ expect(page).not_to have_content "/due 2016-08-28"
end
end
- describe '/target_branch command in merge request' do
+ describe "/target_branch command in merge request" do
let(:another_project) { create(:project, :public, :repository) }
- let(:new_url_opts) { { merge_request: { source_branch: 'feature' } } }
+ let(:new_url_opts) { {merge_request: {source_branch: "feature"}} }
before do
another_project.add_maintainer(user)
sign_in(user)
end
- it 'changes target_branch in new merge_request' do
+ it "changes target_branch in new merge_request" do
visit project_new_merge_request_path(another_project, new_url_opts)
- fill_in "merge_request_title", with: 'My brand new feature'
+ fill_in "merge_request_title", with: "My brand new feature"
fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:"
click_button "Submit merge request"
merge_request = another_project.merge_requests.first
expect(merge_request.description).to eq "le feature \nFeature description:"
- expect(merge_request.target_branch).to eq 'fix'
+ expect(merge_request.target_branch).to eq "fix"
end
- it 'does not change target branch when merge request is edited' do
+ it "does not change target branch when merge request is edited" do
new_merge_request = create(:merge_request, source_project: another_project)
visit edit_project_merge_request_path(another_project, new_merge_request)
@@ -171,51 +171,51 @@ describe 'Merge request > User uses quick actions', :js do
click_button "Save changes"
new_merge_request = another_project.merge_requests.first
- expect(new_merge_request.description).to include('/target_branch')
- expect(new_merge_request.target_branch).not_to eq('fix')
+ expect(new_merge_request.description).to include("/target_branch")
+ expect(new_merge_request.target_branch).not_to eq("fix")
end
end
- describe '/target_branch command from note' do
- context 'when the current user can change target branch' do
+ describe "/target_branch command from note" do
+ context "when the current user can change target branch" do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
- it 'changes target branch from a note' do
+ it "changes target branch from a note" do
add_note("message start \n/target_branch merge-test\n message end.")
wait_for_requests
- expect(page).not_to have_content('/target_branch')
- expect(page).to have_content('message start')
- expect(page).to have_content('message end.')
+ expect(page).not_to have_content("/target_branch")
+ expect(page).to have_content("message start")
+ expect(page).to have_content("message end.")
- expect(merge_request.reload.target_branch).to eq 'merge-test'
+ expect(merge_request.reload.target_branch).to eq "merge-test"
end
- it 'does not fail when target branch does not exists' do
- add_note('/target_branch totally_not_existing_branch')
+ it "does not fail when target branch does not exists" do
+ add_note("/target_branch totally_not_existing_branch")
- expect(page).not_to have_content('/target_branch')
+ expect(page).not_to have_content("/target_branch")
- expect(merge_request.target_branch).to eq 'feature'
+ expect(merge_request.target_branch).to eq "feature"
end
end
- context 'when current user can not change target branch' do
+ context "when current user can not change target branch" do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
- it 'does not change target branch' do
- add_note('/target_branch merge-test')
+ it "does not change target branch" do
+ add_note("/target_branch merge-test")
- expect(page).not_to have_content '/target_branch merge-test'
+ expect(page).not_to have_content "/target_branch merge-test"
- expect(merge_request.target_branch).to eq 'feature'
+ expect(merge_request.target_branch).to eq "feature"
end
end
end
diff --git a/spec/features/merge_request/user_views_diffs_spec.rb b/spec/features/merge_request/user_views_diffs_spec.rb
index 0434db04113..aa126f85251 100644
--- a/spec/features/merge_request/user_views_diffs_spec.rb
+++ b/spec/features/merge_request/user_views_diffs_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views diffs', :js do
+describe "User views diffs", :js do
let(:merge_request) do
- create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
+ create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: "merge-test")
end
let(:project) { create(:project, :public, :repository) }
@@ -11,54 +11,54 @@ describe 'User views diffs', :js do
wait_for_requests
- find('.js-toggle-tree-list').click
+ find(".js-toggle-tree-list").click
end
- shared_examples 'unfold diffs' do
- it 'unfolds diffs' do
- first('.js-unfold').click
+ shared_examples "unfold diffs" do
+ it "unfolds diffs" do
+ first(".js-unfold").click
- expect(find('.file-holder[id="a5cc2925ca8258af241be7e5b0381edf30266302"] .text-file')).to have_content('.bundle')
+ expect(find('.file-holder[id="a5cc2925ca8258af241be7e5b0381edf30266302"] .text-file')).to have_content(".bundle")
end
end
- it 'shows diffs' do
- find('.js-show-diff-settings').click
+ it "shows diffs" do
+ find(".js-show-diff-settings").click
- expect(page).to have_css('.tab-content #diffs.active')
- expect(page).to have_css('#parallel-diff-btn', count: 1)
- expect(page).to have_css('#inline-diff-btn', count: 1)
+ expect(page).to have_css(".tab-content #diffs.active")
+ expect(page).to have_css("#parallel-diff-btn", count: 1)
+ expect(page).to have_css("#inline-diff-btn", count: 1)
end
- it 'hides loading spinner after load' do
- expect(page).not_to have_selector('.mr-loading-status .loading', visible: true)
+ it "hides loading spinner after load" do
+ expect(page).not_to have_selector(".mr-loading-status .loading", visible: true)
end
- context 'when in the inline view' do
- include_examples 'unfold diffs'
+ context "when in the inline view" do
+ include_examples "unfold diffs"
end
- context 'when in the side-by-side view' do
+ context "when in the side-by-side view" do
before do
- find('.js-show-diff-settings').click
+ find(".js-show-diff-settings").click
- click_button 'Side-by-side'
+ click_button "Side-by-side"
wait_for_requests
end
- it 'shows diffs in parallel' do
- expect(page).to have_css('.parallel')
+ it "shows diffs in parallel" do
+ expect(page).to have_css(".parallel")
end
- it 'toggles container class' do
- expect(page).not_to have_css('.content-wrapper > .container-fluid.container-limited')
+ it "toggles container class" do
+ expect(page).not_to have_css(".content-wrapper > .container-fluid.container-limited")
- click_link 'Commits'
+ click_link "Commits"
- expect(page).to have_css('.content-wrapper > .container-fluid.container-limited')
+ expect(page).to have_css(".content-wrapper > .container-fluid.container-limited")
end
- include_examples 'unfold diffs'
+ include_examples "unfold diffs"
end
end
diff --git a/spec/features/merge_request/user_views_open_merge_request_spec.rb b/spec/features/merge_request/user_views_open_merge_request_spec.rb
index 71022c6bb08..4f190f16528 100644
--- a/spec/features/merge_request/user_views_open_merge_request_spec.rb
+++ b/spec/features/merge_request/user_views_open_merge_request_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views an open merge request' do
+describe "User views an open merge request" do
let(:merge_request) do
- create(:merge_request, source_project: project, target_project: project, description: '# Description header')
+ create(:merge_request, source_project: project, target_project: project, description: "# Description header")
end
- context 'when a merge request does not have repository' do
+ context "when a merge request does not have repository" do
let(:project) { create(:project, :public, :repository) }
before do
visit(merge_request_path(merge_request))
end
- it 'renders both the title and the description' do
- node = find('.wiki h1 a#user-content-description-header')
- expect(node[:href]).to end_with('#description-header')
+ it "renders both the title and the description" do
+ node = find(".wiki h1 a#user-content-description-header")
+ expect(node[:href]).to end_with("#description-header")
# Work around a weird Capybara behavior where calling `parent` on a node
# returns the whole document, not the node's actual parent element
@@ -24,10 +24,10 @@ describe 'User views an open merge request' do
end
end
- context 'when a merge request has repository', :js do
+ context "when a merge request has repository", :js do
let(:project) { create(:project, :public, :repository) }
- context 'when rendering description preview' do
+ context "when rendering description preview" do
let(:user) { create(:user) }
before do
@@ -37,53 +37,53 @@ describe 'User views an open merge request' do
visit(edit_project_merge_request_path(project, merge_request))
end
- it 'renders empty description preview' do
- find('.gfm-form').fill_in(:merge_request_description, with: '')
+ it "renders empty description preview" do
+ find(".gfm-form").fill_in(:merge_request_description, with: "")
- page.within('.gfm-form') do
- click_button('Preview')
+ page.within(".gfm-form") do
+ click_button("Preview")
- expect(find('.js-md-preview')).to have_content('Nothing to preview.')
+ expect(find(".js-md-preview")).to have_content("Nothing to preview.")
end
end
- it 'renders description preview' do
- find('.gfm-form').fill_in(:merge_request_description, with: ':+1: Nice')
+ it "renders description preview" do
+ find(".gfm-form").fill_in(:merge_request_description, with: ":+1: Nice")
- page.within('.gfm-form') do
- click_button('Preview')
+ page.within(".gfm-form") do
+ click_button("Preview")
- expect(find('.js-md-preview')).to have_css('gl-emoji')
+ expect(find(".js-md-preview")).to have_css("gl-emoji")
end
- expect(find('.gfm-form')).to have_css('.js-md-preview').and have_button('Write')
- expect(find('#merge_request_description', visible: false)).not_to be_visible
+ expect(find(".gfm-form")).to have_css(".js-md-preview").and have_button("Write")
+ expect(find("#merge_request_description", visible: false)).not_to be_visible
end
end
- context 'when the branch is rebased on the target' do
+ context "when the branch is rebased on the target" do
let(:merge_request) { create(:merge_request, :rebased, source_project: project, target_project: project) }
before do
visit(merge_request_path(merge_request))
end
- it 'does not show diverged commits count' do
- page.within('.mr-source-target') do
+ it "does not show diverged commits count" do
+ page.within(".mr-source-target") do
expect(page).not_to have_content(/([0-9]+ commit[s]? behind)/)
end
end
end
- context 'when the branch is diverged on the target' do
+ context "when the branch is diverged on the target" do
let(:merge_request) { create(:merge_request, :diverged, source_project: project, target_project: project) }
before do
visit(merge_request_path(merge_request))
end
- it 'shows diverged commits count' do
- page.within('.mr-source-target') do
+ it "shows diverged commits count" do
+ page.within(".mr-source-target") do
expect(page).to have_content(/([0-9]+ commits behind)/)
end
end
diff --git a/spec/features/merge_request/user_views_user_status_on_merge_request_spec.rb b/spec/features/merge_request/user_views_user_status_on_merge_request_spec.rb
index 78d9c6c6db1..ba184862cb9 100644
--- a/spec/features/merge_request/user_views_user_status_on_merge_request_spec.rb
+++ b/spec/features/merge_request/user_views_user_status_on_merge_request_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Project > Merge request > View user status' do
+describe "Project > Merge request > View user status" do
let(:project) { create(:project, :public, :repository) }
let(:merge_request) do
create(:merge_request, source_project: project, target_project: project, author: create(:user))
@@ -10,25 +10,25 @@ describe 'Project > Merge request > View user status' do
subject { visit merge_request_path(merge_request) }
- describe 'the status of the merge request author' do
- it_behaves_like 'showing user status' do
+ describe "the status of the merge request author" do
+ it_behaves_like "showing user status" do
let(:user_with_status) { merge_request.author }
end
end
- context 'for notes', :js do
- describe 'the status of the author of a note on a merge request' do
+ context "for notes", :js do
+ describe "the status of the author of a note on a merge request" do
let(:note) { create(:note, noteable: merge_request, project: project, author: create(:user)) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { note.author }
end
end
- describe 'the status of the author of a diff note on a merge request' do
+ describe "the status of the author of a diff note on a merge request" do
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, author: create(:user)) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { note.author }
end
end
diff --git a/spec/features/merge_requests/filters_generic_behavior_spec.rb b/spec/features/merge_requests/filters_generic_behavior_spec.rb
index 0e7fac6b409..01fed709ebd 100644
--- a/spec/features/merge_requests/filters_generic_behavior_spec.rb
+++ b/spec/features/merge_requests/filters_generic_behavior_spec.rb
@@ -1,14 +1,14 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge Requests > Filters generic behavior', :js do
+describe "Merge Requests > Filters generic behavior", :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
- let(:bug) { create(:label, project: project, title: 'bug') }
- let(:open_mr) { create(:merge_request, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1') }
- let(:merged_mr) { create(:merge_request, :merged, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2') }
- let(:closed_mr) { create(:merge_request, :closed, title: 'Feature', source_project: project, target_project: project, source_branch: 'improve/awesome') }
+ let(:bug) { create(:label, project: project, title: "bug") }
+ let(:open_mr) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "bugfix1") }
+ let(:merged_mr) { create(:merge_request, :merged, title: "Bugfix2", source_project: project, target_project: project, source_branch: "bugfix2") }
+ let(:closed_mr) { create(:merge_request, :closed, title: "Feature", source_project: project, target_project: project, source_branch: "improve/awesome") }
before do
open_mr.labels << bug
@@ -19,62 +19,62 @@ describe 'Merge Requests > Filters generic behavior', :js do
visit project_merge_requests_path(project)
end
- context 'when filtered by a label' do
+ context "when filtered by a label" do
before do
- input_filtered_search('label:~bug')
+ input_filtered_search("label:~bug")
end
- describe 'state tabs' do
- it 'does not change when state tabs are clicked' do
+ describe "state tabs" do
+ it "does not change when state tabs are clicked" do
expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
- expect(page).to have_content 'Bugfix1'
- expect(page).not_to have_content 'Bugfix2'
- expect(page).not_to have_content 'Feature'
+ expect(page).to have_content "Bugfix1"
+ expect(page).not_to have_content "Bugfix2"
+ expect(page).not_to have_content "Feature"
find('.issues-state-filters [data-state="merged"]').click
expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
- expect(page).not_to have_content 'Bugfix1'
- expect(page).to have_content 'Bugfix2'
- expect(page).not_to have_content 'Feature'
+ expect(page).not_to have_content "Bugfix1"
+ expect(page).to have_content "Bugfix2"
+ expect(page).not_to have_content "Feature"
find('.issues-state-filters [data-state="closed"]').click
expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
- expect(page).not_to have_content 'Bugfix1'
- expect(page).not_to have_content 'Bugfix2'
- expect(page).to have_content 'Feature'
+ expect(page).not_to have_content "Bugfix1"
+ expect(page).not_to have_content "Bugfix2"
+ expect(page).to have_content "Feature"
find('.issues-state-filters [data-state="all"]').click
expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
- expect(page).to have_content 'Bugfix1'
- expect(page).to have_content 'Bugfix2'
- expect(page).to have_content 'Feature'
+ expect(page).to have_content "Bugfix1"
+ expect(page).to have_content "Bugfix2"
+ expect(page).to have_content "Feature"
end
end
- describe 'clear button' do
- it 'allows user to remove filtered labels' do
- first('.clear-search').click
+ describe "clear button" do
+ it "allows user to remove filtered labels" do
+ first(".clear-search").click
filtered_search.send_keys(:enter)
expect(page).to have_issuable_counts(open: 1, merged: 1, closed: 1, all: 3)
- expect(page).to have_content 'Bugfix1'
- expect(page).not_to have_content 'Bugfix2'
- expect(page).not_to have_content 'Feature'
+ expect(page).to have_content "Bugfix1"
+ expect(page).not_to have_content "Bugfix2"
+ expect(page).not_to have_content "Feature"
end
end
end
- context 'filter dropdown' do
- it 'filters by label name' do
+ context "filter dropdown" do
+ it "filters by label name" do
init_label_search
- filtered_search.send_keys('~bug')
+ filtered_search.send_keys("~bug")
- page.within '.filter-dropdown' do
- expect(page).not_to have_content 'enhancement'
- expect(page).to have_content 'bug'
+ page.within ".filter-dropdown" do
+ expect(page).not_to have_content "enhancement"
+ expect(page).to have_content "bug"
end
end
end
diff --git a/spec/features/merge_requests/user_filters_by_assignees_spec.rb b/spec/features/merge_requests/user_filters_by_assignees_spec.rb
index d6c770c93f1..8ac348597bc 100644
--- a/spec/features/merge_requests/user_filters_by_assignees_spec.rb
+++ b/spec/features/merge_requests/user_filters_by_assignees_spec.rb
@@ -1,36 +1,36 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge Requests > User filters by assignees', :js do
+describe "Merge Requests > User filters by assignees", :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
before do
- create(:merge_request, assignee: user, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1')
- create(:merge_request, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2')
+ create(:merge_request, assignee: user, title: "Bugfix1", source_project: project, target_project: project, source_branch: "bugfix1")
+ create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "bugfix2")
sign_in(user)
visit project_merge_requests_path(project)
end
- context 'filtering by assignee:none' do
- it 'applies the filter' do
- input_filtered_search('assignee:none')
+ context "filtering by assignee:none" do
+ it "applies the filter" do
+ input_filtered_search("assignee:none")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).not_to have_content 'Bugfix1'
- expect(page).to have_content 'Bugfix2'
+ expect(page).not_to have_content "Bugfix1"
+ expect(page).to have_content "Bugfix2"
end
end
- context 'filtering by assignee:@username' do
- it 'applies the filter' do
+ context "filtering by assignee:@username" do
+ it "applies the filter" do
input_filtered_search("assignee:@#{user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content 'Bugfix1'
- expect(page).not_to have_content 'Bugfix2'
+ expect(page).to have_content "Bugfix1"
+ expect(page).not_to have_content "Bugfix2"
end
end
end
diff --git a/spec/features/merge_requests/user_filters_by_labels_spec.rb b/spec/features/merge_requests/user_filters_by_labels_spec.rb
index 08d741af93d..b15813cf1f2 100644
--- a/spec/features/merge_requests/user_filters_by_labels_spec.rb
+++ b/spec/features/merge_requests/user_filters_by_labels_spec.rb
@@ -1,16 +1,16 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge Requests > User filters by labels', :js do
+describe "Merge Requests > User filters by labels", :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
- let(:mr1) { create(:merge_request, title: 'Bugfix1', source_project: project, target_project: project, source_branch: 'bugfix1') }
- let(:mr2) { create(:merge_request, title: 'Bugfix2', source_project: project, target_project: project, source_branch: 'bugfix2') }
+ let(:mr1) { create(:merge_request, title: "Bugfix1", source_project: project, target_project: project, source_branch: "bugfix1") }
+ let(:mr2) { create(:merge_request, title: "Bugfix2", source_project: project, target_project: project, source_branch: "bugfix2") }
before do
- bug_label = create(:label, project: project, title: 'bug')
- enhancement_label = create(:label, project: project, title: 'enhancement')
+ bug_label = create(:label, project: project, title: "bug")
+ enhancement_label = create(:label, project: project, title: "enhancement")
mr1.labels << bug_label
mr2.labels << bug_label << enhancement_label
@@ -18,32 +18,32 @@ describe 'Merge Requests > User filters by labels', :js do
visit project_merge_requests_path(project)
end
- context 'filtering by label:none' do
- it 'applies the filter' do
- input_filtered_search('label:none')
+ context "filtering by label:none" do
+ it "applies the filter" do
+ input_filtered_search("label:none")
expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
- expect(page).not_to have_content 'Bugfix1'
- expect(page).not_to have_content 'Bugfix2'
+ expect(page).not_to have_content "Bugfix1"
+ expect(page).not_to have_content "Bugfix2"
end
end
- context 'filtering by label:~enhancement' do
- it 'applies the filter' do
- input_filtered_search('label:~enhancement')
+ context "filtering by label:~enhancement" do
+ it "applies the filter" do
+ input_filtered_search("label:~enhancement")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content 'Bugfix2'
- expect(page).not_to have_content 'Bugfix1'
+ expect(page).to have_content "Bugfix2"
+ expect(page).not_to have_content "Bugfix1"
end
end
- context 'filtering by label:~enhancement and label:~bug' do
- it 'applies the filters' do
- input_filtered_search('label:~bug label:~enhancement')
+ context "filtering by label:~enhancement and label:~bug" do
+ it "applies the filters" do
+ input_filtered_search("label:~bug label:~enhancement")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content 'Bugfix2'
+ expect(page).to have_content "Bugfix2"
end
end
end
diff --git a/spec/features/merge_requests/user_filters_by_milestones_spec.rb b/spec/features/merge_requests/user_filters_by_milestones_spec.rb
index 727a236d980..be0ab073f62 100644
--- a/spec/features/merge_requests/user_filters_by_milestones_spec.rb
+++ b/spec/features/merge_requests/user_filters_by_milestones_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge Requests > User filters by milestones', :js do
+describe "Merge Requests > User filters by milestones", :js do
include FilteredSearchHelpers
let(:project) { create(:project, :public, :repository) }
@@ -15,47 +15,47 @@ describe 'Merge Requests > User filters by milestones', :js do
visit project_merge_requests_path(project)
end
- it 'filters by no milestone' do
- input_filtered_search('milestone:none')
+ it "filters by no milestone" do
+ input_filtered_search("milestone:none")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
+ expect(page).to have_css(".merge-request", count: 1)
end
- it 'filters by a specific milestone' do
+ it "filters by a specific milestone" do
input_filtered_search("milestone:%'#{milestone.title}'")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
+ expect(page).to have_css(".merge-request", count: 1)
end
- describe 'filters by upcoming milestone' do
- it 'does not show merge requests with no expiry' do
- input_filtered_search('milestone:upcoming')
+ describe "filters by upcoming milestone" do
+ it "does not show merge requests with no expiry" do
+ input_filtered_search("milestone:upcoming")
expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
- expect(page).to have_css('.merge-request', count: 0)
+ expect(page).to have_css(".merge-request", count: 0)
end
- context 'with an upcoming milestone' do
+ context "with an upcoming milestone" do
let(:milestone) { create(:milestone, project: project, due_date: Date.tomorrow) }
- it 'shows merge requests' do
- input_filtered_search('milestone:upcoming')
+ it "shows merge requests" do
+ input_filtered_search("milestone:upcoming")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_css('.merge-request', count: 1)
+ expect(page).to have_css(".merge-request", count: 1)
end
end
- context 'with a due milestone' do
+ context "with a due milestone" do
let(:milestone) { create(:milestone, project: project, due_date: Date.yesterday) }
- it 'does not show any merge requests' do
- input_filtered_search('milestone:upcoming')
+ it "does not show any merge requests" do
+ input_filtered_search("milestone:upcoming")
expect(page).to have_issuable_counts(open: 0, closed: 0, all: 0)
- expect(page).to have_css('.merge-request', count: 0)
+ expect(page).to have_css(".merge-request", count: 0)
end
end
end
diff --git a/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb b/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb
index 1615899a047..19a8774be22 100644
--- a/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb
+++ b/spec/features/merge_requests/user_filters_by_multiple_criteria_spec.rb
@@ -1,38 +1,38 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge requests > User filters by multiple criteria', :js do
+describe "Merge requests > User filters by multiple criteria", :js do
include FilteredSearchHelpers
let!(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
- let!(:milestone) { create(:milestone, title: 'v1.1', project: project) }
+ let!(:milestone) { create(:milestone, title: "v1.1", project: project) }
let!(:wontfix) { create(:label, project: project, title: "Won't fix") }
before do
sign_in(user)
- mr = create(:merge_request, title: 'Bugfix2', author: user, assignee: user, source_project: project, target_project: project, milestone: milestone)
+ mr = create(:merge_request, title: "Bugfix2", author: user, assignee: user, source_project: project, target_project: project, milestone: milestone)
mr.labels << wontfix
visit project_merge_requests_path(project)
end
describe 'filtering by label:~"Won\'t fix" and assignee:~bug' do
- it 'applies the filters' do
+ it "applies the filters" do
input_filtered_search("label:~\"Won't fix\" assignee:@#{user.username}")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content 'Bugfix2'
+ expect(page).to have_content "Bugfix2"
expect_filtered_search_input_empty
end
end
- describe 'filtering by text, author, assignee, milestone, and label' do
- it 'filters by text, author, assignee, milestone, and label' do
+ describe "filtering by text, author, assignee, milestone, and label" do
+ it "filters by text, author, assignee, milestone, and label" do
input_filtered_search_keys("author:@#{user.username} assignee:@#{user.username} milestone:%\"v1.1\" label:~\"Won't fix\" Bug")
expect(page).to have_issuable_counts(open: 1, closed: 0, all: 1)
- expect(page).to have_content 'Bugfix2'
- expect_filtered_search_input('Bug')
+ expect(page).to have_content "Bugfix2"
+ expect_filtered_search_input("Bug")
end
end
end
diff --git a/spec/features/merge_requests/user_lists_merge_requests_spec.rb b/spec/features/merge_requests/user_lists_merge_requests_spec.rb
index ef7ae490b0f..f5a4838e582 100644
--- a/spec/features/merge_requests/user_lists_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_lists_merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge requests > User lists merge requests' do
+describe "Merge requests > User lists merge requests" do
include MergeRequestHelpers
include SortingHelper
@@ -9,82 +9,82 @@ describe 'Merge requests > User lists merge requests' do
before do
@fix = create(:merge_request,
- title: 'fix',
- source_project: project,
- source_branch: 'fix',
- assignee: user,
- milestone: create(:milestone, due_date: '2013-12-11'),
- created_at: 1.minute.ago,
- updated_at: 1.minute.ago)
+ title: "fix",
+ source_project: project,
+ source_branch: "fix",
+ assignee: user,
+ milestone: create(:milestone, due_date: "2013-12-11"),
+ created_at: 1.minute.ago,
+ updated_at: 1.minute.ago)
create(:merge_request,
- title: 'markdown',
- source_project: project,
- source_branch: 'markdown',
- assignee: user,
- milestone: create(:milestone, due_date: '2013-12-12'),
- created_at: 2.minutes.ago,
- updated_at: 2.minutes.ago)
+ title: "markdown",
+ source_project: project,
+ source_branch: "markdown",
+ assignee: user,
+ milestone: create(:milestone, due_date: "2013-12-12"),
+ created_at: 2.minutes.ago,
+ updated_at: 2.minutes.ago)
create(:merge_request,
- title: 'merge-test',
- source_project: project,
- source_branch: 'merge-test',
- created_at: 3.minutes.ago,
- updated_at: 10.seconds.ago)
+ title: "merge-test",
+ source_project: project,
+ source_branch: "merge-test",
+ created_at: 3.minutes.ago,
+ updated_at: 10.seconds.ago)
end
- it 'filters on no assignee' do
+ it "filters on no assignee" do
visit_merge_requests(project, assignee_id: IssuableFinder::NONE)
expect(current_path).to eq(project_merge_requests_path(project))
- expect(page).to have_content 'merge-test'
- expect(page).not_to have_content 'fix'
- expect(page).not_to have_content 'markdown'
+ expect(page).to have_content "merge-test"
+ expect(page).not_to have_content "fix"
+ expect(page).not_to have_content "markdown"
expect(count_merge_requests).to eq(1)
end
- it 'filters on a specific assignee' do
+ it "filters on a specific assignee" do
visit_merge_requests(project, assignee_id: user.id)
- expect(page).not_to have_content 'merge-test'
- expect(page).to have_content 'fix'
- expect(page).to have_content 'markdown'
+ expect(page).not_to have_content "merge-test"
+ expect(page).to have_content "fix"
+ expect(page).to have_content "markdown"
expect(count_merge_requests).to eq(2)
end
- it 'sorts by newest' do
+ it "sorts by newest" do
visit_merge_requests(project, sort: sort_value_created_date)
- expect(first_merge_request).to include('fix')
- expect(last_merge_request).to include('merge-test')
+ expect(first_merge_request).to include("fix")
+ expect(last_merge_request).to include("merge-test")
expect(count_merge_requests).to eq(3)
end
- it 'sorts by last updated' do
+ it "sorts by last updated" do
visit_merge_requests(project, sort: sort_value_recently_updated)
- expect(first_merge_request).to include('merge-test')
+ expect(first_merge_request).to include("merge-test")
expect(count_merge_requests).to eq(3)
end
- it 'sorts by milestone' do
+ it "sorts by milestone" do
visit_merge_requests(project, sort: sort_value_milestone)
- expect(first_merge_request).to include('fix')
+ expect(first_merge_request).to include("fix")
expect(count_merge_requests).to eq(3)
end
- it 'filters on one label and sorts by due date' do
+ it "filters on one label and sorts by due date" do
label = create(:label, project: project)
create(:label_link, label: label, target: @fix)
visit_merge_requests(project, label_name: [label.name],
sort: sort_value_due_date)
- expect(first_merge_request).to include('fix')
+ expect(first_merge_request).to include("fix")
expect(count_merge_requests).to eq(1)
end
- context 'while filtering on two labels' do
+ context "while filtering on two labels" do
let(:label) { create(:label, project: project) }
let(:label2) { create(:label, project: project) }
@@ -93,36 +93,36 @@ describe 'Merge requests > User lists merge requests' do
create(:label_link, label: label2, target: @fix)
end
- it 'sorts by due date' do
+ it "sorts by due date" do
visit_merge_requests(project, label_name: [label.name, label2.name],
sort: sort_value_due_date)
- expect(first_merge_request).to include('fix')
+ expect(first_merge_request).to include("fix")
expect(count_merge_requests).to eq(1)
end
- context 'filter on assignee and' do
- it 'sorts by due soon' do
+ context "filter on assignee and" do
+ it "sorts by due soon" do
visit_merge_requests(project, label_name: [label.name, label2.name],
assignee_id: user.id,
sort: sort_value_due_date)
- expect(first_merge_request).to include('fix')
+ expect(first_merge_request).to include("fix")
expect(count_merge_requests).to eq(1)
end
- it 'sorts by recently due milestone' do
+ it "sorts by recently due milestone" do
visit project_merge_requests_path(project,
label_name: [label.name, label2.name],
assignee_id: user.id,
sort: sort_value_milestone)
- expect(first_merge_request).to include('fix')
+ expect(first_merge_request).to include("fix")
end
end
end
def count_merge_requests
- page.all('ul.mr-list > li').count
+ page.all("ul.mr-list > li").count
end
end
diff --git a/spec/features/merge_requests/user_mass_updates_spec.rb b/spec/features/merge_requests/user_mass_updates_spec.rb
index e535c7e5811..920562d50a7 100644
--- a/spec/features/merge_requests/user_mass_updates_spec.rb
+++ b/spec/features/merge_requests/user_mass_updates_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge requests > User mass updates', :js do
+describe "Merge requests > User mass updates", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
@@ -10,108 +10,108 @@ describe 'Merge requests > User mass updates', :js do
sign_in(user)
end
- context 'status' do
- describe 'close merge request' do
+ context "status" do
+ describe "close merge request" do
before do
visit project_merge_requests_path(project)
end
- it 'closes merge request' do
- change_status('Closed')
+ it "closes merge request" do
+ change_status("Closed")
- expect(page).to have_selector('.merge-request', count: 0)
+ expect(page).to have_selector(".merge-request", count: 0)
end
end
- describe 'reopen merge request' do
+ describe "reopen merge request" do
before do
merge_request.close
- visit project_merge_requests_path(project, state: 'closed')
+ visit project_merge_requests_path(project, state: "closed")
end
- it 'reopens merge request' do
- change_status('Open')
+ it "reopens merge request" do
+ change_status("Open")
- expect(page).to have_selector('.merge-request', count: 0)
+ expect(page).to have_selector(".merge-request", count: 0)
end
end
end
- context 'assignee' do
- describe 'set assignee' do
+ context "assignee" do
+ describe "set assignee" do
before do
visit project_merge_requests_path(project)
end
- it 'updates merge request with assignee' do
+ it "updates merge request with assignee" do
change_assignee(user.name)
- page.within('.merge-request .controls') do
- expect(find('.author-link')["title"]).to have_content(user.name)
+ page.within(".merge-request .controls") do
+ expect(find(".author-link")["title"]).to have_content(user.name)
end
end
end
- describe 'remove assignee' do
+ describe "remove assignee" do
before do
merge_request.assignee = user
merge_request.save
visit project_merge_requests_path(project)
end
- it 'removes assignee from the merge request' do
- change_assignee('Unassigned')
+ it "removes assignee from the merge request" do
+ change_assignee("Unassigned")
- expect(find('.merge-request .controls')).not_to have_css('.author-link')
+ expect(find(".merge-request .controls")).not_to have_css(".author-link")
end
end
end
- context 'milestone' do
+ context "milestone" do
let(:milestone) { create(:milestone, project: project) }
- describe 'set milestone' do
+ describe "set milestone" do
before do
visit project_merge_requests_path(project)
end
- it 'updates merge request with milestone' do
+ it "updates merge request with milestone" do
change_milestone(milestone.title)
- expect(find('.merge-request')).to have_content milestone.title
+ expect(find(".merge-request")).to have_content milestone.title
end
end
- describe 'unset milestone' do
+ describe "unset milestone" do
before do
merge_request.milestone = milestone
merge_request.save
visit project_merge_requests_path(project)
end
- it 'removes milestone from the merge request' do
+ it "removes milestone from the merge request" do
change_milestone("No Milestone")
- expect(find('.merge-request')).not_to have_content milestone.title
+ expect(find(".merge-request")).not_to have_content milestone.title
end
end
end
def change_status(text)
- click_button 'Edit merge requests'
- find('#check-all-issues').click
- find('.js-issue-status').click
- find('.dropdown-menu-status a', text: text).click
+ click_button "Edit merge requests"
+ find("#check-all-issues").click
+ find(".js-issue-status").click
+ find(".dropdown-menu-status a", text: text).click
click_update_merge_requests_button
end
def change_assignee(text)
- click_button 'Edit merge requests'
- find('#check-all-issues').click
- find('.js-update-assignee').click
+ click_button "Edit merge requests"
+ find("#check-all-issues").click
+ find(".js-update-assignee").click
wait_for_requests
- page.within '.dropdown-menu-user' do
+ page.within ".dropdown-menu-user" do
click_link text
end
@@ -119,15 +119,15 @@ describe 'Merge requests > User mass updates', :js do
end
def change_milestone(text)
- click_button 'Edit merge requests'
- find('#check-all-issues').click
- find('.issues-bulk-update .js-milestone-select').click
- find('.dropdown-menu-milestone a', text: text).click
+ click_button "Edit merge requests"
+ find("#check-all-issues").click
+ find(".issues-bulk-update .js-milestone-select").click
+ find(".dropdown-menu-milestone a", text: text).click
click_update_merge_requests_button
end
def click_update_merge_requests_button
- find('.update-selected-issues').click
+ find(".update-selected-issues").click
wait_for_requests
end
end
diff --git a/spec/features/merge_requests/user_sorts_merge_requests_spec.rb b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb
index fa887110c13..a597699d88b 100644
--- a/spec/features/merge_requests/user_sorts_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_sorts_merge_requests_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User sorts merge requests' do
+describe "User sorts merge requests" do
include CookieHelper
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:merge_request2) do
- create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: 'merge-test')
+ create(:merge_request_with_diffs, source_project: project, target_project: project, source_branch: "merge-test")
end
set(:user) { create(:user) }
set(:group) { create(:group) }
@@ -18,49 +18,49 @@ describe 'User sorts merge requests' do
visit(project_merge_requests_path(project))
end
- it 'keeps the sort option' do
- find('.filter-dropdown-container .dropdown').click
+ it "keeps the sort option" do
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
- click_link('Milestone')
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
+ click_link("Milestone")
end
visit(merge_requests_dashboard_path(assignee_username: user.username))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
visit(project_merge_requests_path(project))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
visit(merge_requests_group_path(group))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
end
- it 'fallbacks to issuable_sort cookie key when remembering the sorting option' do
- set_cookie('issuable_sort', 'milestone')
+ it "fallbacks to issuable_sort cookie key when remembering the sorting option" do
+ set_cookie("issuable_sort", "milestone")
visit(merge_requests_dashboard_path(assignee_username: user.username))
- expect(find('.issues-filters a.is-active')).to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).to have_content("Milestone")
end
- it 'separates remember sorting with issues' do
+ it "separates remember sorting with issues" do
create(:issue, project: project)
- find('.filter-dropdown-container .dropdown').click
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
- click_link('Milestone')
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
+ click_link("Milestone")
end
visit(project_issues_path(project))
- expect(find('.issues-filters a.is-active')).not_to have_content('Milestone')
+ expect(find(".issues-filters a.is-active")).not_to have_content("Milestone")
end
- context 'when merge requests have awards' do
+ context "when merge requests have awards" do
before do
create_list(:award_emoji, 2, awardable: merge_request)
create(:award_emoji, :downvote, awardable: merge_request)
@@ -69,22 +69,22 @@ describe 'User sorts merge requests' do
create_list(:award_emoji, 2, :downvote, awardable: merge_request2)
end
- it 'sorts by popularity' do
- find('.filter-dropdown-container .dropdown').click
+ it "sorts by popularity" do
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
- click_link('Popularity')
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
+ click_link("Popularity")
end
- page.within('.mr-list') do
- page.within('li.merge-request:nth-child(1)') do
+ page.within(".mr-list") do
+ page.within("li.merge-request:nth-child(1)") do
expect(page).to have_content(merge_request.title)
- expect(page).to have_content('2 1')
+ expect(page).to have_content("2 1")
end
- page.within('li.merge-request:nth-child(2)') do
+ page.within("li.merge-request:nth-child(2)") do
expect(page).to have_content(merge_request2.title)
- expect(page).to have_content('1 2')
+ expect(page).to have_content("1 2")
end
end
end
diff --git a/spec/features/merge_requests/user_squashes_merge_request_spec.rb b/spec/features/merge_requests/user_squashes_merge_request_spec.rb
index bf9c55cf22c..dd46e853f75 100644
--- a/spec/features/merge_requests/user_squashes_merge_request_spec.rb
+++ b/spec/features/merge_requests/user_squashes_merge_request_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User squashes a merge request', :js do
+describe "User squashes a merge request", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:source_branch) { 'csv' }
+ let(:source_branch) { "csv" }
- let!(:original_head) { project.repository.commit('master') }
+ let!(:original_head) { project.repository.commit("master") }
- shared_examples 'squash' do
- it 'squashes the commits into a single commit, and adds a merge commit' do
- expect(page).to have_content('Merged')
+ shared_examples "squash" do
+ it "squashes the commits into a single commit, and adds a merge commit" do
+ expect(page).to have_content("Merged")
- latest_master_commits = project.repository.commits_between(original_head.sha, 'master').map(&:raw)
+ latest_master_commits = project.repository.commits_between(original_head.sha, "master").map(&:raw)
squash_commit = an_object_having_attributes(sha: a_string_matching(/\h{40}/),
message: a_string_starting_with(project.merge_requests.first.default_squash_commit_message),
@@ -28,18 +28,18 @@ describe 'User squashes a merge request', :js do
end
end
- shared_examples 'no squash' do
- it 'accepts the merge request without squashing' do
- expect(page).to have_content('Merged')
+ shared_examples "no squash" do
+ it "accepts the merge request without squashing" do
+ expect(page).to have_content("Merged")
expect(project.repository).to be_merged_to_root_ref(source_branch)
end
end
def accept_mr
- expect(page).to have_button('Merge')
+ expect(page).to have_button("Merge")
- uncheck 'Delete source branch'
- click_on 'Merge'
+ uncheck "Delete source branch"
+ click_on "Merge"
end
before do
@@ -51,74 +51,74 @@ describe 'User squashes a merge request', :js do
sign_in user
end
- context 'when the MR has only one commit' do
+ context "when the MR has only one commit" do
before do
- merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: 'master', target_branch: 'branch-merged')
+ merge_request = create(:merge_request, source_project: project, target_project: project, source_branch: "master", target_branch: "branch-merged")
visit project_merge_request_path(project, merge_request)
end
- it 'does not show the squash checkbox' do
- expect(page).not_to have_field('squash')
+ it "does not show the squash checkbox" do
+ expect(page).not_to have_field("squash")
end
end
- context 'when squash is enabled on merge request creation' do
+ context "when squash is enabled on merge request creation" do
before do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: source_branch })
- check 'merge_request[squash]'
- click_on 'Submit merge request'
+ visit project_new_merge_request_path(project, merge_request: {target_branch: "master", source_branch: source_branch})
+ check "merge_request[squash]"
+ click_on "Submit merge request"
wait_for_requests
end
- it 'shows the squash checkbox as checked' do
- expect(page).to have_checked_field('squash')
+ it "shows the squash checkbox as checked" do
+ expect(page).to have_checked_field("squash")
end
- context 'when accepting with squash checked' do
+ context "when accepting with squash checked" do
before do
accept_mr
end
- include_examples 'squash'
+ include_examples "squash"
end
- context 'when accepting and unchecking squash' do
+ context "when accepting and unchecking squash" do
before do
- uncheck 'squash'
+ uncheck "squash"
accept_mr
end
- include_examples 'no squash'
+ include_examples "no squash"
end
end
- context 'when squash is not enabled on merge request creation' do
+ context "when squash is not enabled on merge request creation" do
before do
- visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: source_branch })
- click_on 'Submit merge request'
+ visit project_new_merge_request_path(project, merge_request: {target_branch: "master", source_branch: source_branch})
+ click_on "Submit merge request"
wait_for_requests
end
- it 'shows the squash checkbox as unchecked' do
- expect(page).to have_unchecked_field('squash')
+ it "shows the squash checkbox as unchecked" do
+ expect(page).to have_unchecked_field("squash")
end
- context 'when accepting and checking squash' do
+ context "when accepting and checking squash" do
before do
- check 'squash'
+ check "squash"
accept_mr
end
- include_examples 'squash'
+ include_examples "squash"
end
- context 'when accepting with squash unchecked' do
+ context "when accepting with squash unchecked" do
before do
accept_mr
end
- include_examples 'no squash'
+ include_examples "no squash"
end
end
end
diff --git a/spec/features/merge_requests/user_views_all_merge_requests_spec.rb b/spec/features/merge_requests/user_views_all_merge_requests_spec.rb
index 6c695bd7aa9..c5cbfb192f1 100644
--- a/spec/features/merge_requests/user_views_all_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_views_all_merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views all merge requests' do
+describe "User views all merge requests" do
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:project) { create(:project, :public) }
@@ -9,7 +9,7 @@ describe 'User views all merge requests' do
visit(project_merge_requests_path(project, state: :all))
end
- it 'shows all merge requests' do
+ it "shows all merge requests" do
expect(page).to have_content(merge_request.title).and have_content(closed_merge_request.title)
end
end
diff --git a/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb b/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb
index 853809fe87a..8064f512c31 100644
--- a/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_views_closed_merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views closed merge requests' do
+describe "User views closed merge requests" do
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:project) { create(:project, :public) }
@@ -9,7 +9,7 @@ describe 'User views closed merge requests' do
visit(project_merge_requests_path(project, state: :closed))
end
- it 'shows closed merge requests' do
+ it "shows closed merge requests" do
expect(page).to have_content(closed_merge_request.title).and have_no_content(merge_request.title)
end
end
diff --git a/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb b/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb
index eb012694f1e..517e32000e1 100644
--- a/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_views_merged_merge_requests_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views merged merge requests' do
+describe "User views merged merge requests" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:merged_merge_request) { create(:merged_merge_request, source_project: project, target_project: project) }
let(:project) { create(:project, :public) }
@@ -9,7 +9,7 @@ describe 'User views merged merge requests' do
visit(project_merge_requests_path(project, state: :merged))
end
- it 'shows merged merge requests' do
+ it "shows merged merge requests" do
expect(page).to have_content(merged_merge_request.title).and have_no_content(merge_request.title)
end
end
diff --git a/spec/features/merge_requests/user_views_open_merge_requests_spec.rb b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb
index 115e548b691..7c091ed3758 100644
--- a/spec/features/merge_requests/user_views_open_merge_requests_spec.rb
+++ b/spec/features/merge_requests/user_views_open_merge_requests_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views open merge requests' do
+describe "User views open merge requests" do
set(:user) { create(:user) }
- shared_examples_for 'shows merge requests' do
- it 'shows merge requests' do
+ shared_examples_for "shows merge requests" do
+ it "shows merge requests" do
expect(page).to have_content(project.name).and have_content(merge_request.source_project.name)
end
end
- context 'when project is public' do
+ context "when project is public" do
set(:project) { create(:project, :public, :repository) }
- context 'when not signed in' do
+ context "when not signed in" do
context "when the target branch is the project's default branch" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:closed_merge_request) { create(:closed_merge_request, source_project: project, target_project: project) }
@@ -21,15 +21,15 @@ describe 'User views open merge requests' do
visit(project_merge_requests_path(project))
end
- include_examples 'shows merge requests'
+ include_examples "shows merge requests"
- it 'shows open merge requests' do
+ it "shows open merge requests" do
expect(page).to have_content(merge_request.title).and have_no_content(closed_merge_request.title)
end
- it 'does not show target branch name' do
+ it "does not show target branch name" do
expect(page).to have_content(merge_request.title)
- expect(find('.issuable-info')).not_to have_content(project.default_branch)
+ expect(find(".issuable-info")).not_to have_content(project.default_branch)
end
end
@@ -38,27 +38,27 @@ describe 'User views open merge requests' do
create(:merge_request,
source_project: project,
target_project: project,
- source_branch: 'fix',
- target_branch: 'feature_conflict')
+ source_branch: "fix",
+ target_branch: "feature_conflict")
end
before do
visit(project_merge_requests_path(project))
end
- it 'shows target branch name' do
+ it "shows target branch name" do
expect(page).to have_content(merge_request.target_branch)
end
end
- context 'when a merge request has pipelines' do
+ context "when a merge request has pipelines" do
let!(:build) { create :ci_build, pipeline: pipeline }
let(:merge_request) do
create(:merge_request_with_diffs,
- source_project: project,
- target_project: project,
- source_branch: 'merge-test')
+ source_project: project,
+ target_project: project,
+ source_branch: "merge-test")
end
let(:pipeline) do
@@ -75,15 +75,15 @@ describe 'User views open merge requests' do
visit(project_merge_requests_path(project))
end
- it 'shows pipeline status' do
- page.within('.mr-list') do
- expect(page).to have_link('Pipeline: pending')
+ it "shows pipeline status" do
+ page.within(".mr-list") do
+ expect(page).to have_link("Pipeline: pending")
end
end
end
end
- context 'when signed in' do
+ context "when signed in" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do
@@ -93,27 +93,27 @@ describe 'User views open merge requests' do
visit(project_merge_requests_path(project))
end
- include_examples 'shows merge requests'
+ include_examples "shows merge requests"
- it 'shows the new merge request button' do
- expect(page).to have_link('New merge request')
+ it "shows the new merge request button" do
+ expect(page).to have_link("New merge request")
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :public, :repository, :archived) }
- it 'hides the new merge request button' do
- expect(page).not_to have_link('New merge request')
+ it "hides the new merge request button" do
+ expect(page).not_to have_link("New merge request")
end
end
end
end
- context 'when project is internal' do
+ context "when project is internal" do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
set(:project) { create(:project, :internal, :repository) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in(user)
@@ -121,7 +121,7 @@ describe 'User views open merge requests' do
visit(project_merge_requests_path(project))
end
- include_examples 'shows merge requests'
+ include_examples "shows merge requests"
end
end
end
diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb
index 6e349395017..3a13a649602 100644
--- a/spec/features/milestone_spec.rb
+++ b/spec/features/milestone_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Milestone' do
+describe "Milestone" do
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, namespace: group) }
let(:user) { create(:user) }
@@ -11,75 +11,75 @@ describe 'Milestone' do
sign_in(user)
end
- describe 'Create a milestone' do
- it 'shows an informative message for a new milestone' do
+ describe "Create a milestone" do
+ it "shows an informative message for a new milestone" do
visit new_project_milestone_path(project)
- page.within '.milestone-form' do
- fill_in "milestone_title", with: '8.7'
- fill_in "milestone_start_date", with: '2016-11-16'
- fill_in "milestone_due_date", with: '2016-12-16'
+ page.within ".milestone-form" do
+ fill_in "milestone_title", with: "8.7"
+ fill_in "milestone_start_date", with: "2016-11-16"
+ fill_in "milestone_due_date", with: "2016-12-16"
end
find('input[name="commit"]').click
- expect(find('.alert-success')).to have_content('Assign some issues to this milestone.')
- expect(page).to have_content('Nov 16, 2016–Dec 16, 2016')
+ expect(find(".alert-success")).to have_content("Assign some issues to this milestone.")
+ expect(page).to have_content("Nov 16, 2016–Dec 16, 2016")
end
end
- describe 'Open a milestone with closed issues' do
- it 'shows an informative message' do
+ describe "Open a milestone with closed issues" do
+ it "shows an informative message" do
milestone = create(:milestone, project: project, title: 8.7)
create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed")
visit project_milestone_path(project, milestone)
- expect(find('.alert-success')).to have_content('All issues for this milestone are closed. You may close this milestone now.')
+ expect(find(".alert-success")).to have_content("All issues for this milestone are closed. You may close this milestone now.")
end
end
- describe 'Open a project milestone with an existing title' do
- it 'displays validation message when there is a project milestone with same title' do
+ describe "Open a project milestone with an existing title" do
+ it "displays validation message when there is a project milestone with same title" do
milestone = create(:milestone, project: project, title: 8.7)
visit new_project_milestone_path(project)
- page.within '.milestone-form' do
+ page.within ".milestone-form" do
fill_in "milestone_title", with: milestone.title
end
find('input[name="commit"]').click
- expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.')
+ expect(find(".alert-danger")).to have_content("already being used for another group or project milestone.")
end
- it 'displays validation message when there is a group milestone with same title' do
+ it "displays validation message when there is a group milestone with same title" do
milestone = create(:milestone, project_id: nil, group: project.group, title: 8.7)
visit new_group_milestone_path(project.group)
- page.within '.milestone-form' do
+ page.within ".milestone-form" do
fill_in "milestone_title", with: milestone.title
end
find('input[name="commit"]').click
- expect(find('.alert-danger')).to have_content('already being used for another group or project milestone.')
+ expect(find(".alert-danger")).to have_content("already being used for another group or project milestone.")
end
end
- describe 'Open a milestone', :js do
- it 'shows total issue time spent correctly when no time has been logged' do
+ describe "Open a milestone", :js do
+ it "shows total issue time spent correctly when no time has been logged" do
milestone = create(:milestone, project: project, title: 8.7)
visit project_milestone_path(project, milestone)
wait_for_requests
- page.within('.time-tracking-no-tracking-pane') do
- expect(page).to have_content 'No estimate or time spent'
+ page.within(".time-tracking-no-tracking-pane") do
+ expect(page).to have_content "No estimate or time spent"
end
end
- it 'shows total issue time spent' do
+ it "shows total issue time spent" do
milestone = create(:milestone, project: project, title: 8.7)
issue1 = create(:issue, project: project, milestone: milestone)
issue2 = create(:issue, project: project, milestone: milestone)
@@ -92,34 +92,34 @@ describe 'Milestone' do
wait_for_requests
- page.within('.time-tracking-spend-only-pane') do
- expect(page).to have_content 'Spent: 3h'
+ page.within(".time-tracking-spend-only-pane") do
+ expect(page).to have_content "Spent: 3h"
end
end
end
- describe 'Deleting a milestone' do
+ describe "Deleting a milestone" do
it "The delete milestone button does not show for unauthorized users" do
create(:milestone, project: project, title: 8.7)
sign_out(user)
visit group_milestones_path(group)
- expect(page).to have_selector('.js-delete-milestone-button', count: 0)
+ expect(page).to have_selector(".js-delete-milestone-button", count: 0)
end
end
- describe 'deprecation popover', :js do
- it 'opens deprecation popover' do
+ describe "deprecation popover", :js do
+ it "opens deprecation popover" do
milestone = create(:milestone, project: project)
visit group_milestone_path(group, milestone, title: milestone.title)
- expect(page).to have_selector('.milestone-deprecation-message')
+ expect(page).to have_selector(".milestone-deprecation-message")
- find('.milestone-deprecation-message .js-popover-link').click
+ find(".milestone-deprecation-message .js-popover-link").click
- expect(page).to have_selector('.popover')
+ expect(page).to have_selector(".popover")
end
end
end
diff --git a/spec/features/milestones/user_promotes_milestone_spec.rb b/spec/features/milestones/user_promotes_milestone_spec.rb
index df1bc502134..377ceec7db1 100644
--- a/spec/features/milestones/user_promotes_milestone_spec.rb
+++ b/spec/features/milestones/user_promotes_milestone_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User promotes milestone' do
+describe "User promotes milestone" do
set(:group) { create(:group) }
set(:user) { create(:user) }
set(:project) { create(:project, namespace: group) }
set(:milestone) { create(:milestone, project: project) }
- context 'when user can admin group milestones' do
+ context "when user can admin group milestones" do
before do
group.add_developer(user)
sign_in(user)
@@ -14,11 +14,11 @@ describe 'User promotes milestone' do
end
it "shows milestone promote button" do
- expect(page).to have_selector('.js-promote-project-milestone-button')
+ expect(page).to have_selector(".js-promote-project-milestone-button")
end
end
- context 'when user cannot admin group milestones' do
+ context "when user cannot admin group milestones" do
before do
project.add_developer(user)
sign_in(user)
@@ -26,7 +26,7 @@ describe 'User promotes milestone' do
end
it "does not show milestone promote button" do
- expect(page).not_to have_selector('.js-promote-project-milestone-button')
+ expect(page).not_to have_selector(".js-promote-project-milestone-button")
end
end
end
diff --git a/spec/features/milestones/user_sees_breadcrumb_links_spec.rb b/spec/features/milestones/user_sees_breadcrumb_links_spec.rb
index d3906ea73bd..837c5a8a583 100644
--- a/spec/features/milestones/user_sees_breadcrumb_links_spec.rb
+++ b/spec/features/milestones/user_sees_breadcrumb_links_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New project milestone breadcrumb' do
+describe "New project milestone breadcrumb" do
let(:project) { create(:project) }
let(:milestone) { create(:milestone, project: project) }
let(:user) { project.creator }
@@ -10,10 +10,10 @@ describe 'New project milestone breadcrumb' do
visit(new_project_milestone_path(project))
end
- it 'displays link to project milestones and new project milestone' do
- page.within '.breadcrumbs' do
- expect(find_link('Milestones')[:href]).to end_with(project_milestones_path(project))
- expect(find_link('New')[:href]).to end_with(new_project_milestone_path(project))
+ it "displays link to project milestones and new project milestone" do
+ page.within ".breadcrumbs" do
+ expect(find_link("Milestones")[:href]).to end_with(project_milestones_path(project))
+ expect(find_link("New")[:href]).to end_with(new_project_milestone_path(project))
end
end
end
diff --git a/spec/features/milestones/user_views_milestone_spec.rb b/spec/features/milestones/user_views_milestone_spec.rb
index 83d8e2ff9e9..371eb2e89bd 100644
--- a/spec/features/milestones/user_views_milestone_spec.rb
+++ b/spec/features/milestones/user_views_milestone_spec.rb
@@ -12,7 +12,7 @@ describe "User views milestone" do
end
it "avoids N+1 database queries" do
- ISSUE_PARAMS = { project: project, assignees: [user], author: user, milestone: milestone, labels: labels }.freeze
+ ISSUE_PARAMS = {project: project, assignees: [user], author: user, milestone: milestone, labels: labels}.freeze
create(:labeled_issue, ISSUE_PARAMS)
diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb
index f4105730402..328d83be9ce 100644
--- a/spec/features/oauth_login_spec.rb
+++ b/spec/features/oauth_login_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'OAuth Login', :js, :allow_forgery_protection do
+describe "OAuth Login", :js, :allow_forgery_protection do
include DeviseHelpers
def enter_code(code)
- fill_in 'user_otp_attempt', with: code
- click_button 'Verify code'
+ fill_in "user_otp_attempt", with: code
+ click_button "Verify code"
end
def stub_omniauth_config(provider)
@@ -14,14 +14,14 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
end
providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2,
- :facebook, :cas3, :auth0, :authentiq]
+ :facebook, :cas3, :auth0, :authentiq,]
before(:all) do
# The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost`
# here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and
# anything after it) from the request URI.
@omniauth_config_full_host = OmniAuth.config.full_host
- OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') }
+ OmniAuth.config.full_host = ->(request) { request["REQUEST_URI"].sub(/#{request['REQUEST_PATH']}.*/, "") }
end
after(:all) do
@@ -35,7 +35,7 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
providers.each do |provider|
context "when the user logs in using the #{provider} provider" do
- let(:uid) { 'my-uid' }
+ let(:uid) { "my-uid" }
let(:remember_me) { false }
let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider.to_s) }
let(:two_factor_user) { create(:omniauth_user, :two_factor, extern_uid: uid, provider: provider.to_s) }
@@ -44,18 +44,18 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
stub_omniauth_config(provider)
end
- context 'when two-factor authentication is disabled' do
- it 'logs the user in' do
+ context "when two-factor authentication is disabled" do
+ it "logs the user in" do
login_with_provider(provider)
expect(current_path).to eq root_path
end
end
- context 'when two-factor authentication is enabled' do
+ context "when two-factor authentication is enabled" do
let(:user) { two_factor_user }
- it 'logs the user in' do
+ it "logs the user in" do
login_with_provider(provider, enter_two_factor: true)
expect(current_path).to eq root_path
@@ -65,8 +65,8 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
context 'when "remember me" is checked' do
let(:remember_me) { true }
- context 'when two-factor authentication is disabled' do
- it 'remembers the user after a browser restart' do
+ context "when two-factor authentication is disabled" do
+ it "remembers the user after a browser restart" do
login_with_provider(provider)
clear_browser_session
@@ -76,10 +76,10 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
end
end
- context 'when two-factor authentication is enabled' do
+ context "when two-factor authentication is enabled" do
let(:user) { two_factor_user }
- it 'remembers the user after a browser restart' do
+ it "remembers the user after a browser restart" do
login_with_provider(provider, enter_two_factor: true)
clear_browser_session
@@ -91,8 +91,8 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
end
context 'when "remember me" is not checked' do
- context 'when two-factor authentication is disabled' do
- it 'does not remember the user after a browser restart' do
+ context "when two-factor authentication is disabled" do
+ it "does not remember the user after a browser restart" do
login_with_provider(provider)
clear_browser_session
@@ -102,10 +102,10 @@ describe 'OAuth Login', :js, :allow_forgery_protection do
end
end
- context 'when two-factor authentication is enabled' do
+ context "when two-factor authentication is enabled" do
let(:user) { two_factor_user }
- it 'does not remember the user after a browser restart' do
+ it "does not remember the user after a browser restart" do
login_with_provider(provider, enter_two_factor: true)
clear_browser_session
diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb
index 134731a4639..55e9d2f1a5e 100644
--- a/spec/features/participants_autocomplete_spec.rb
+++ b/spec/features/participants_autocomplete_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Member autocomplete', :js do
+describe "Member autocomplete", :js do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:author) { create(:user) }
@@ -13,33 +13,33 @@ describe 'Member autocomplete', :js do
shared_examples "open suggestions when typing @" do |resource_name|
before do
- page.within('.new-note') do
- if resource_name == 'commit'
- find('#note_note').send_keys('@')
+ page.within(".new-note") do
+ if resource_name == "commit"
+ find("#note_note").send_keys("@")
else
- find('#note-body').send_keys('@')
+ find("#note-body").send_keys("@")
end
end
end
- it 'suggests noteable author and note author' do
- page.within('.atwho-view', visible: true) do
+ it "suggests noteable author and note author" do
+ page.within(".atwho-view", visible: true) do
expect(page).to have_content(author.username)
expect(page).to have_content(note.author.username)
end
end
end
- context 'adding a new note on a Issue' do
+ context "adding a new note on a Issue" do
let(:noteable) { create(:issue, author: author, project: project) }
before do
visit project_issue_path(project, noteable)
end
- include_examples "open suggestions when typing @", 'issue'
+ include_examples "open suggestions when typing @", "issue"
end
- context 'adding a new note on a Merge Request' do
+ context "adding a new note on a Merge Request" do
let(:project) { create(:project, :public, :repository) }
let(:noteable) do
create(:merge_request, source_project: project,
@@ -49,10 +49,10 @@ describe 'Member autocomplete', :js do
visit project_merge_request_path(project, noteable)
end
- include_examples "open suggestions when typing @", 'merge_request'
+ include_examples "open suggestions when typing @", "merge_request"
end
- context 'adding a new note on a Commit' do
+ context "adding a new note on a Commit" do
let(:project) { create(:project, :public, :repository) }
let(:noteable) { project.commit }
let(:note) { create(:note_on_commit, project: project, commit_id: project.commit.id) }
@@ -64,6 +64,6 @@ describe 'Member autocomplete', :js do
visit project_commit_path(project, noteable)
end
- include_examples "open suggestions when typing @", 'commit'
+ include_examples "open suggestions when typing @", "commit"
end
end
diff --git a/spec/features/password_reset_spec.rb b/spec/features/password_reset_spec.rb
index dcc63dff9f5..edd0ce76445 100644
--- a/spec/features/password_reset_spec.rb
+++ b/spec/features/password_reset_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Password reset' do
- describe 'throttling' do
- it 'sends reset instructions when not previously sent' do
+describe "Password reset" do
+ describe "throttling" do
+ it "sends reset instructions when not previously sent" do
user = create(:user)
forgot_password(user)
- expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
+ expect(page).to have_content(I18n.t("devise.passwords.send_paranoid_instructions"))
expect(current_path).to eq new_user_session_path
expect(user.recently_sent_password_reset?).to be_truthy
end
- it 'sends reset instructions when previously sent more than a minute ago' do
+ it "sends reset instructions when previously sent more than a minute ago" do
user = create(:user)
user.send_reset_password_instructions
user.update_attribute(:reset_password_sent_at, 5.minutes.ago)
expect { forgot_password(user) }.to change { user.reset_password_sent_at }
- expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
+ expect(page).to have_content(I18n.t("devise.passwords.send_paranoid_instructions"))
expect(current_path).to eq new_user_session_path
end
- it 'throttles multiple resets in a short timespan' do
+ it "throttles multiple resets in a short timespan" do
user = create(:user)
user.send_reset_password_instructions
# Reload because PG handles datetime less precisely than Ruby/Rails
user.reload
expect { forgot_password(user) }.not_to change { user.reset_password_sent_at }
- expect(page).to have_content(I18n.t('devise.passwords.send_paranoid_instructions'))
+ expect(page).to have_content(I18n.t("devise.passwords.send_paranoid_instructions"))
expect(current_path).to eq new_user_session_path
end
end
- describe 'Changing password while logged in' do
- it 'updates the password' do
+ describe "Changing password while logged in" do
+ it "updates the password" do
user = create(:user)
token = user.send_reset_password_instructions
@@ -42,21 +42,21 @@ describe 'Password reset' do
visit(edit_user_password_path(reset_password_token: token))
- fill_in 'New password', with: 'hello1234'
- fill_in 'Confirm new password', with: 'hello1234'
+ fill_in "New password", with: "hello1234"
+ fill_in "Confirm new password", with: "hello1234"
- click_button 'Change your password'
+ click_button "Change your password"
- expect(page).to have_content(I18n.t('devise.passwords.updated_not_active'))
+ expect(page).to have_content(I18n.t("devise.passwords.updated_not_active"))
expect(current_path).to eq new_user_session_path
end
end
def forgot_password(user)
visit root_path
- click_on 'Forgot your password?'
- fill_in 'Email', with: user.email
- click_button 'Reset password'
+ click_on "Forgot your password?"
+ fill_in "Email", with: user.email
+ click_button "Reset password"
user.reload
end
end
diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb
index 2e0753c3bfb..967795d81ad 100644
--- a/spec/features/profile_spec.rb
+++ b/spec/features/profile_spec.rb
@@ -1,111 +1,111 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Profile account page', :js do
+describe "Profile account page", :js do
let(:user) { create(:user) }
before do
sign_in(user)
end
- describe 'when I delete my account' do
+ describe "when I delete my account" do
before do
visit profile_account_path
end
- it { expect(page).to have_content('Delete account') }
+ it { expect(page).to have_content("Delete account") }
- it 'does not immediately delete the account' do
- click_button 'Delete account'
+ it "does not immediately delete the account" do
+ click_button "Delete account"
expect(User.exists?(user.id)).to be_truthy
end
- it 'deletes user', :js do
- click_button 'Delete account'
+ it "deletes user", :js do
+ click_button "Delete account"
- fill_in 'password', with: '12345678'
+ fill_in "password", with: "12345678"
- page.within '.modal' do
- click_button 'Delete account'
+ page.within ".modal" do
+ click_button "Delete account"
end
- expect(page).to have_content('Account scheduled for removal')
+ expect(page).to have_content("Account scheduled for removal")
expect(User.exists?(user.id)).to be_falsy
end
- it 'shows invalid password flash message', :js do
- click_button 'Delete account'
+ it "shows invalid password flash message", :js do
+ click_button "Delete account"
- fill_in 'password', with: 'testing123'
+ fill_in "password", with: "testing123"
- page.within '.modal' do
- click_button 'Delete account'
+ page.within ".modal" do
+ click_button "Delete account"
end
- expect(page).to have_content('Invalid password')
+ expect(page).to have_content("Invalid password")
end
- it 'does not show delete button when user owns a group' do
+ it "does not show delete button when user owns a group" do
group = create(:group)
group.add_owner(user)
visit profile_account_path
- expect(page).not_to have_button('Delete account')
+ expect(page).not_to have_button("Delete account")
expect(page).to have_content("Your account is currently an owner in these groups: #{group.name}")
end
end
- describe 'when I reset feed token' do
+ describe "when I reset feed token" do
before do
visit profile_personal_access_tokens_path
end
- it 'resets feed token' do
- within('.feed-token-reset') do
+ it "resets feed token" do
+ within(".feed-token-reset") do
previous_token = find("#feed_token").value
- accept_confirm { click_link('reset it') }
+ accept_confirm { click_link("reset it") }
- expect(find('#feed_token').value).not_to eq(previous_token)
+ expect(find("#feed_token").value).not_to eq(previous_token)
end
- expect(page).to have_content 'Feed token was successfully reset'
+ expect(page).to have_content "Feed token was successfully reset"
end
end
- describe 'when I reset incoming email token' do
+ describe "when I reset incoming email token" do
before do
allow(Gitlab.config.incoming_email).to receive(:enabled).and_return(true)
visit profile_personal_access_tokens_path
end
- it 'resets incoming email token' do
- within('.incoming-email-token-reset') do
- previous_token = find('#incoming_email_token').value
+ it "resets incoming email token" do
+ within(".incoming-email-token-reset") do
+ previous_token = find("#incoming_email_token").value
- accept_confirm { click_link('reset it') }
+ accept_confirm { click_link("reset it") }
- expect(find('#incoming_email_token').value).not_to eq(previous_token)
+ expect(find("#incoming_email_token").value).not_to eq(previous_token)
end
end
end
- describe 'when I change my username' do
+ describe "when I change my username" do
before do
visit profile_account_path
end
- it 'changes my username' do
- fill_in 'username-change-input', with: 'new-username'
+ it "changes my username" do
+ fill_in "username-change-input", with: "new-username"
page.find('[data-target="#username-change-confirmation-modal"]').click
- page.within('.modal') do
- find('.js-modal-primary-action').click
+ page.within(".modal") do
+ find(".js-modal-primary-action").click
end
- expect(page).to have_content('new-username')
+ expect(page).to have_content("new-username")
end
end
end
diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb
index 90d0e9bb77c..af0aac0a939 100644
--- a/spec/features/profiles/account_spec.rb
+++ b/spec/features/profiles/account_spec.rb
@@ -1,32 +1,32 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > Account', :js do
- let(:user) { create(:user, username: 'foo') }
+describe "Profile > Account", :js do
+ let(:user) { create(:user, username: "foo") }
before do
sign_in(user)
end
- describe 'Change username' do
- let(:new_username) { 'bar' }
+ describe "Change username" do
+ let(:new_username) { "bar" }
let(:new_user_path) { "/#{new_username}" }
let(:old_user_path) { "/#{user.username}" }
- it 'the user is accessible via the new path' do
+ it "the user is accessible via the new path" do
update_username(new_username)
visit new_user_path
expect(current_path).to eq(new_user_path)
- expect(find('.user-info')).to have_content(new_username)
+ expect(find(".user-info")).to have_content(new_username)
end
- it 'the old user path redirects to the new path' do
+ it "the old user path redirects to the new path" do
update_username(new_username)
visit old_user_path
expect(current_path).to eq(new_user_path)
- expect(find('.user-info')).to have_content(new_username)
+ expect(find(".user-info")).to have_content(new_username)
end
- context 'with a project' do
+ context "with a project" do
let!(:project) { create(:project, namespace: user.namespace) }
let(:new_project_path) { "/#{new_username}/#{project.path}" }
let(:old_project_path) { "/#{user.username}/#{project.path}" }
@@ -39,18 +39,18 @@ describe 'Profile > Account', :js do
TestEnv.clean_test_path
end
- it 'the project is accessible via the new path' do
+ it "the project is accessible via the new path" do
update_username(new_username)
visit new_project_path
expect(current_path).to eq(new_project_path)
- expect(find('.breadcrumbs-sub-title')).to have_content('Details')
+ expect(find(".breadcrumbs-sub-title")).to have_content("Details")
end
- it 'the old project path redirects to the new path' do
+ it "the old project path redirects to the new path" do
update_username(new_username)
visit old_project_path
expect(current_path).to eq(new_project_path)
- expect(find('.breadcrumbs-sub-title')).to have_content('Details')
+ expect(find(".breadcrumbs-sub-title")).to have_content("Details")
end
end
end
@@ -60,12 +60,12 @@ def update_username(new_username)
allow(user.namespace).to receive(:move_dir)
visit profile_account_path
- fill_in 'username-change-input', with: new_username
+ fill_in "username-change-input", with: new_username
page.find('[data-target="#username-change-confirmation-modal"]').click
- page.within('.modal') do
- find('.js-modal-primary-action').click
+ page.within(".modal") do
+ find(".js-modal-primary-action").click
end
wait_for_requests
diff --git a/spec/features/profiles/active_sessions_spec.rb b/spec/features/profiles/active_sessions_spec.rb
index d3050760c06..b02d61e8720 100644
--- a/spec/features/profiles/active_sessions_spec.rb
+++ b/spec/features/profiles/active_sessions_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
+describe "Profile > Active Sessions", :clean_gitlab_redis_shared_state do
let(:user) do
create(:user).tap do |user|
user.current_sign_in_at = Time.current
@@ -8,20 +8,20 @@ describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
end
around do |example|
- Timecop.freeze(Time.zone.parse('2018-03-12 09:06')) do
+ Timecop.freeze(Time.zone.parse("2018-03-12 09:06")) do
example.run
end
end
- it 'User sees their active sessions' do
+ it "User sees their active sessions" do
Capybara::Session.new(:session1)
Capybara::Session.new(:session2)
# note: headers can only be set on the non-js (aka. rack-test) driver
using_session :session1 do
Capybara.page.driver.header(
- 'User-Agent',
- 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0'
+ "User-Agent",
+ "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0"
)
gitlab_sign_in(user)
@@ -30,8 +30,8 @@ describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
# set an additional session on another device
using_session :session2 do
Capybara.page.driver.header(
- 'User-Agent',
- 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]'
+ "User-Agent",
+ "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]"
)
gitlab_sign_in(user)
@@ -41,26 +41,26 @@ describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
visit profile_active_sessions_path
expect(page).to have_content(
- '127.0.0.1 ' \
- 'This is your current session ' \
- 'Firefox on Ubuntu ' \
- 'Signed in on 12 Mar 09:06'
+ "127.0.0.1 " \
+ "This is your current session " \
+ "Firefox on Ubuntu " \
+ "Signed in on 12 Mar 09:06"
)
expect(page).to have_selector '[title="Desktop"]', count: 1
expect(page).to have_content(
- '127.0.0.1 ' \
- 'Last accessed on 12 Mar 09:06 ' \
- 'Mobile Safari on iOS ' \
- 'Signed in on 12 Mar 09:06'
+ "127.0.0.1 " \
+ "Last accessed on 12 Mar 09:06 " \
+ "Mobile Safari on iOS " \
+ "Signed in on 12 Mar 09:06"
)
expect(page).to have_selector '[title="Smartphone"]', count: 1
end
end
- it 'User can revoke a session', :js, :redis_session_store do
+ it "User can revoke a session", :js, :redis_session_store do
Capybara::Session.new(:session1)
Capybara::Session.new(:session2)
@@ -73,17 +73,17 @@ describe 'Profile > Active Sessions', :clean_gitlab_redis_shared_state do
gitlab_sign_in(user)
visit profile_active_sessions_path
- expect(page).to have_link('Revoke', count: 1)
+ expect(page).to have_link("Revoke", count: 1)
- accept_confirm { click_on 'Revoke' }
+ accept_confirm { click_on "Revoke" }
- expect(page).not_to have_link('Revoke')
+ expect(page).not_to have_link("Revoke")
end
using_session :session2 do
visit profile_active_sessions_path
- expect(page).to have_content('You need to sign in or sign up before continuing.')
+ expect(page).to have_content("You need to sign in or sign up before continuing.")
end
end
end
diff --git a/spec/features/profiles/chat_names_spec.rb b/spec/features/profiles/chat_names_spec.rb
index c72069f6262..1db91920bd5 100644
--- a/spec/features/profiles/chat_names_spec.rb
+++ b/spec/features/profiles/chat_names_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > Chat' do
+describe "Profile > Chat" do
let(:user) { create(:user) }
let(:service) { create(:service) }
@@ -8,9 +8,9 @@ describe 'Profile > Chat' do
sign_in(user)
end
- describe 'uses authorization link' do
+ describe "uses authorization link" do
let(:params) do
- { team_id: 'T00', team_domain: 'my_chat_team', user_id: 'U01', user_name: 'my_chat_user' }
+ {team_id: "T00", team_domain: "my_chat_team", user_id: "U01", user_name: "my_chat_user"}
end
let!(:authorize_url) { ChatNames::AuthorizeUserService.new(service, params).execute }
let(:authorize_path) { URI.parse(authorize_url).request_uri }
@@ -19,36 +19,36 @@ describe 'Profile > Chat' do
visit authorize_path
end
- context 'clicks authorize' do
+ context "clicks authorize" do
before do
- click_button 'Authorize'
+ click_button "Authorize"
end
- it 'goes to list of chat names and see chat account' do
+ it "goes to list of chat names and see chat account" do
expect(page.current_path).to eq(profile_chat_names_path)
- expect(page).to have_content('my_chat_team')
- expect(page).to have_content('my_chat_user')
+ expect(page).to have_content("my_chat_team")
+ expect(page).to have_content("my_chat_user")
end
- it 'second use of link is denied' do
+ it "second use of link is denied" do
visit authorize_path
expect(page).to have_gitlab_http_status(:not_found)
end
end
- context 'clicks deny' do
+ context "clicks deny" do
before do
- click_button 'Deny'
+ click_button "Deny"
end
- it 'goes to list of chat names and do not see chat account' do
+ it "goes to list of chat names and do not see chat account" do
expect(page.current_path).to eq(profile_chat_names_path)
- expect(page).not_to have_content('my_chat_team')
- expect(page).not_to have_content('my_chat_user')
+ expect(page).not_to have_content("my_chat_team")
+ expect(page).not_to have_content("my_chat_user")
end
- it 'second use of link is denied' do
+ it "second use of link is denied" do
visit authorize_path
expect(page).to have_gitlab_http_status(:not_found)
@@ -56,20 +56,20 @@ describe 'Profile > Chat' do
end
end
- describe 'visits chat accounts' do
+ describe "visits chat accounts" do
let!(:chat_name) { create(:chat_name, user: user, service: service) }
before do
visit profile_chat_names_path
end
- it 'sees chat user' do
+ it "sees chat user" do
expect(page).to have_content(chat_name.team_domain)
expect(page).to have_content(chat_name.chat_name)
end
- it 'removes chat account' do
- click_link 'Remove'
+ it "removes chat account" do
+ click_link "Remove"
expect(page).to have_content("You don't have any active chat names.")
end
diff --git a/spec/features/profiles/emails_spec.rb b/spec/features/profiles/emails_spec.rb
index bc6d54b5ed7..673da3a96ff 100644
--- a/spec/features/profiles/emails_spec.rb
+++ b/spec/features/profiles/emails_spec.rb
@@ -1,47 +1,47 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > Emails' do
+describe "Profile > Emails" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- describe 'User adds an email' do
+ describe "User adds an email" do
before do
visit profile_emails_path
end
- it 'saves the new email' do
- fill_in('Email', with: 'my@email.com')
- click_button('Add email address')
+ it "saves the new email" do
+ fill_in("Email", with: "my@email.com")
+ click_button("Add email address")
- expect(page).to have_content('my@email.com Unverified')
+ expect(page).to have_content("my@email.com Unverified")
expect(page).to have_content("#{user.email} Verified")
- expect(page).to have_content('Resend confirmation email')
+ expect(page).to have_content("Resend confirmation email")
end
- it 'does not add a duplicate email' do
- fill_in('Email', with: user.email)
- click_button('Add email address')
+ it "does not add a duplicate email" do
+ fill_in("Email", with: user.email)
+ click_button("Add email address")
email = user.emails.find_by(email: user.email)
expect(email).to be_nil
- expect(page).to have_content('Email has already been taken')
+ expect(page).to have_content("Email has already been taken")
end
end
- it 'User removes email' do
- user.emails.create(email: 'my@email.com')
+ it "User removes email" do
+ user.emails.create(email: "my@email.com")
visit profile_emails_path
expect(page).to have_content("my@email.com")
- click_link('Remove')
+ click_link("Remove")
expect(page).not_to have_content("my@email.com")
end
- it 'User confirms email' do
- email = user.emails.create(email: 'my@email.com')
+ it "User confirms email" do
+ email = user.emails.create(email: "my@email.com")
visit profile_emails_path
expect(page).to have_content("#{email.email} Unverified")
@@ -52,20 +52,20 @@ describe 'Profile > Emails' do
expect(page).to have_content("#{email.email} Verified")
end
- it 'User re-sends confirmation email' do
- email = user.emails.create(email: 'my@email.com')
+ it "User re-sends confirmation email" do
+ email = user.emails.create(email: "my@email.com")
visit profile_emails_path
expect { click_link("Resend confirmation email") }.to change { ActionMailer::Base.deliveries.size }
expect(page).to have_content("Confirmation email sent to #{email.email}")
end
- it 'old unconfirmed emails show Send Confirmation button' do
- email = user.emails.create(email: 'my@email.com')
+ it "old unconfirmed emails show Send Confirmation button" do
+ email = user.emails.create(email: "my@email.com")
email.update_attribute(:confirmation_sent_at, nil)
visit profile_emails_path
- expect(page).not_to have_content('Resend confirmation email')
- expect(page).to have_content('Send confirmation email')
+ expect(page).not_to have_content("Resend confirmation email")
+ expect(page).to have_content("Send confirmation email")
end
end
diff --git a/spec/features/profiles/gpg_keys_spec.rb b/spec/features/profiles/gpg_keys_spec.rb
index ec3ec795b63..56619b62068 100644
--- a/spec/features/profiles/gpg_keys_spec.rb
+++ b/spec/features/profiles/gpg_keys_spec.rb
@@ -1,31 +1,31 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > GPG Keys' do
+describe "Profile > GPG Keys" do
let(:user) { create(:user, email: GpgHelpers::User2.emails.first) }
before do
sign_in(user)
end
- describe 'User adds a key' do
+ describe "User adds a key" do
before do
visit profile_gpg_keys_path
end
- it 'saves the new key' do
- fill_in('Key', with: GpgHelpers::User2.public_key)
- click_button('Add key')
+ it "saves the new key" do
+ fill_in("Key", with: GpgHelpers::User2.public_key)
+ click_button("Add key")
- expect(page).to have_content('bette.cartwright@example.com Verified')
- expect(page).to have_content('bette.cartwright@example.net Unverified')
+ expect(page).to have_content("bette.cartwright@example.com Verified")
+ expect(page).to have_content("bette.cartwright@example.net Unverified")
expect(page).to have_content(GpgHelpers::User2.fingerprint)
end
- it 'with multiple subkeys' do
- fill_in('Key', with: GpgHelpers::User3.public_key)
- click_button('Add key')
+ it "with multiple subkeys" do
+ fill_in("Key", with: GpgHelpers::User3.public_key)
+ click_button("Add key")
- expect(page).to have_content('john.doe@example.com Unverified')
+ expect(page).to have_content("john.doe@example.com Unverified")
expect(page).to have_content(GpgHelpers::User3.fingerprint)
GpgHelpers::User3.subkey_fingerprints.each do |fingerprint|
@@ -34,36 +34,36 @@ describe 'Profile > GPG Keys' do
end
end
- it 'User sees their key' do
+ it "User sees their key" do
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
visit profile_gpg_keys_path
- expect(page).to have_content('bette.cartwright@example.com Verified')
- expect(page).to have_content('bette.cartwright@example.net Unverified')
+ expect(page).to have_content("bette.cartwright@example.com Verified")
+ expect(page).to have_content("bette.cartwright@example.net Unverified")
expect(page).to have_content(GpgHelpers::User2.fingerprint)
end
- it 'User removes a key via the key index' do
+ it "User removes a key via the key index" do
create(:gpg_key, user: user, key: GpgHelpers::User2.public_key)
visit profile_gpg_keys_path
- click_link('Remove')
+ click_link("Remove")
- expect(page).to have_content('Your GPG keys (0)')
+ expect(page).to have_content("Your GPG keys (0)")
end
- it 'User revokes a key via the key index' do
+ it "User revokes a key via the key index" do
gpg_key = create :gpg_key, user: user, key: GpgHelpers::User2.public_key
gpg_signature = create :gpg_signature, gpg_key: gpg_key, verification_status: :verified
visit profile_gpg_keys_path
- click_link('Revoke')
+ click_link("Revoke")
- expect(page).to have_content('Your GPG keys (0)')
+ expect(page).to have_content("Your GPG keys (0)")
expect(gpg_signature.reload).to have_attributes(
- verification_status: 'unknown_key',
+ verification_status: "unknown_key",
gpg_key: nil
)
end
diff --git a/spec/features/profiles/keys_spec.rb b/spec/features/profiles/keys_spec.rb
index e6586fc8a0a..8d7ef72c61d 100644
--- a/spec/features/profiles/keys_spec.rb
+++ b/spec/features/profiles/keys_spec.rb
@@ -1,89 +1,89 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Profile > SSH Keys' do
+describe "Profile > SSH Keys" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- describe 'User adds a key' do
+ describe "User adds a key" do
before do
visit profile_keys_path
end
- it 'auto-populates the title', :js do
- fill_in('Key', with: attributes_for(:key).fetch(:key))
+ it "auto-populates the title", :js do
+ fill_in("Key", with: attributes_for(:key).fetch(:key))
expect(page).to have_field("Title", with: "dummy@gitlab.com")
end
- it 'saves the new key' do
+ it "saves the new key" do
attrs = attributes_for(:key)
- fill_in('Key', with: attrs[:key])
- fill_in('Title', with: attrs[:title])
- click_button('Add key')
+ fill_in("Key", with: attrs[:key])
+ fill_in("Title", with: attrs[:title])
+ click_button("Add key")
expect(page).to have_content("Title: #{attrs[:title]}")
expect(page).to have_content(attrs[:key])
- expect(find('.breadcrumbs-sub-title')).to have_link(attrs[:title])
+ expect(find(".breadcrumbs-sub-title")).to have_link(attrs[:title])
end
- it 'shows a confirmable warning if the key does not start with ssh-' do
+ it "shows a confirmable warning if the key does not start with ssh-" do
attrs = attributes_for(:key)
- fill_in('Key', with: 'invalid-key')
- fill_in('Title', with: attrs[:title])
- click_button('Add key')
+ fill_in("Key", with: "invalid-key")
+ fill_in("Title", with: attrs[:title])
+ click_button("Add key")
- expect(page).to have_selector('.js-add-ssh-key-validation-warning')
+ expect(page).to have_selector(".js-add-ssh-key-validation-warning")
- find('.js-add-ssh-key-validation-confirm-submit').click
+ find(".js-add-ssh-key-validation-confirm-submit").click
- expect(page).to have_content('Key is invalid')
+ expect(page).to have_content("Key is invalid")
end
- context 'when only DSA and ECDSA keys are allowed' do
+ context "when only DSA and ECDSA keys are allowed" do
before do
forbidden = ApplicationSetting::FORBIDDEN_KEY_VALUE
stub_application_setting(rsa_key_restriction: forbidden, ed25519_key_restriction: forbidden)
end
- it 'shows a validation error' do
+ it "shows a validation error" do
attrs = attributes_for(:key)
- fill_in('Key', with: attrs[:key])
- fill_in('Title', with: attrs[:title])
- click_button('Add key')
+ fill_in("Key", with: attrs[:key])
+ fill_in("Title", with: attrs[:title])
+ click_button("Add key")
- expect(page).to have_content('Key type is forbidden. Must be DSA or ECDSA')
+ expect(page).to have_content("Key type is forbidden. Must be DSA or ECDSA")
end
end
end
- it 'User sees their keys' do
+ it "User sees their keys" do
key = create(:key, user: user)
visit profile_keys_path
expect(page).to have_content(key.title)
end
- it 'User removes a key via the key index' do
+ it "User removes a key via the key index" do
create(:key, user: user)
visit profile_keys_path
- click_link('Remove')
+ click_link("Remove")
- expect(page).to have_content('Your SSH keys (0)')
+ expect(page).to have_content("Your SSH keys (0)")
end
- it 'User removes a key via its details page' do
+ it "User removes a key via its details page" do
key = create(:key, user: user)
visit profile_key_path(key)
- click_link('Remove')
+ click_link("Remove")
- expect(page).to have_content('Your SSH keys (0)')
+ expect(page).to have_content("Your SSH keys (0)")
end
end
diff --git a/spec/features/profiles/oauth_applications_spec.rb b/spec/features/profiles/oauth_applications_spec.rb
index 7d204f89fba..092f621a735 100644
--- a/spec/features/profiles/oauth_applications_spec.rb
+++ b/spec/features/profiles/oauth_applications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Profile > Applications' do
+describe "Profile > Applications" do
let(:user) { create(:user) }
let(:application) { create(:oauth_application, owner: user) }
@@ -8,40 +8,40 @@ describe 'Profile > Applications' do
sign_in(user)
end
- describe 'User manages applications', :js do
- it 'views an application' do
+ describe "User manages applications", :js do
+ it "views an application" do
visit oauth_application_path(application)
expect(page).to have_content("Application: #{application.name}")
- expect(find('.breadcrumbs-sub-title')).to have_link(application.name)
+ expect(find(".breadcrumbs-sub-title")).to have_link(application.name)
end
- it 'deletes an application' do
+ it "deletes an application" do
create(:oauth_application, owner: user)
visit oauth_applications_path
- page.within('.oauth-applications') do
- expect(page).to have_content('Your applications (1)')
- accept_confirm { click_button 'Destroy' }
+ page.within(".oauth-applications") do
+ expect(page).to have_content("Your applications (1)")
+ accept_confirm { click_button "Destroy" }
end
- expect(page).to have_content('The application was deleted successfully')
- expect(page).to have_content('Your applications (0)')
- expect(page).to have_content('Authorized applications (0)')
+ expect(page).to have_content("The application was deleted successfully")
+ expect(page).to have_content("Your applications (0)")
+ expect(page).to have_content("Authorized applications (0)")
end
- it 'deletes an authorized application' do
+ it "deletes an authorized application" do
create(:oauth_access_token, resource_owner: user)
visit oauth_applications_path
- page.within('.oauth-authorized-applications') do
- expect(page).to have_content('Authorized applications (1)')
- accept_confirm { click_button 'Revoke' }
+ page.within(".oauth-authorized-applications") do
+ expect(page).to have_content("Authorized applications (1)")
+ accept_confirm { click_button "Revoke" }
end
- expect(page).to have_content('The application was revoked access.')
- expect(page).to have_content('Your applications (0)')
- expect(page).to have_content('Authorized applications (0)')
+ expect(page).to have_content("The application was revoked access.")
+ expect(page).to have_content("Your applications (0)")
+ expect(page).to have_content("Authorized applications (0)")
end
end
end
diff --git a/spec/features/profiles/password_spec.rb b/spec/features/profiles/password_spec.rb
index 5e3569e4beb..0bb3833092d 100644
--- a/spec/features/profiles/password_spec.rb
+++ b/spec/features/profiles/password_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Profile > Password' do
+describe "Profile > Password" do
let(:user) { create(:user) }
def fill_passwords(password, confirmation)
- fill_in 'New password', with: password
- fill_in 'Password confirmation', with: confirmation
+ fill_in "New password", with: password
+ fill_in "Password confirmation", with: confirmation
- click_button 'Save password'
+ click_button "Save password"
end
- context 'Password authentication enabled' do
+ context "Password authentication enabled" do
let(:user) { create(:user, password_automatically_set: true) }
before do
@@ -18,44 +18,44 @@ describe 'Profile > Password' do
visit edit_profile_password_path
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')
+ 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
+ page.within(".alert-danger") do
expect(page).to have_content("Password confirmation doesn't match Password")
end
end
- it 'does not contain the current password field after an error' do
- fill_passwords('mypassword', 'mypassword2')
+ it "does not contain the current password field after an error" do
+ fill_passwords("mypassword", "mypassword2")
- expect(page).to have_no_field('user[current_password]')
+ 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')
+ 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')
+ page.within(".flash-notice") do
+ expect(page).to have_content("Password was successfully updated. Please login with it")
end
end
end
end
end
- context 'Password authentication unavailable' do
+ context "Password authentication unavailable" do
before do
gitlab_sign_in(user)
end
- context 'Regular user' do
+ context "Regular user" do
let(:user) { create(:user) }
- it 'renders 404 when password authentication is disabled for the web interface and Git' do
+ it "renders 404 when password authentication is disabled for the web interface and Git" do
stub_application_setting(password_authentication_enabled_for_web: false)
stub_application_setting(password_authentication_enabled_for_git: false)
@@ -65,10 +65,10 @@ describe 'Profile > Password' do
end
end
- context 'LDAP user' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain') }
+ context "LDAP user" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain") }
- it 'renders 404' do
+ it "renders 404" do
visit edit_profile_password_path
expect(page).to have_gitlab_http_status(404)
@@ -76,44 +76,44 @@ describe 'Profile > Password' do
end
end
- context 'Change passowrd' do
+ context "Change passowrd" do
before do
sign_in(user)
visit(edit_profile_password_path)
end
- it 'does not change user passowrd without old one' do
- page.within '.update-password' do
- fill_passwords('22233344', '22233344')
+ it "does not change user passowrd without old one" do
+ page.within ".update-password" do
+ fill_passwords("22233344", "22233344")
end
- page.within '.flash-container' do
- expect(page).to have_content 'You must provide a valid current password'
+ page.within ".flash-container" do
+ expect(page).to have_content "You must provide a valid current password"
end
end
- it 'does not change password with invalid old password' do
- page.within '.update-password' do
- fill_in 'user_current_password', with: 'invalid'
- fill_passwords('password', 'confirmation')
+ it "does not change password with invalid old password" do
+ page.within ".update-password" do
+ fill_in "user_current_password", with: "invalid"
+ fill_passwords("password", "confirmation")
end
- page.within '.flash-container' do
- expect(page).to have_content 'You must provide a valid current password'
+ page.within ".flash-container" do
+ expect(page).to have_content "You must provide a valid current password"
end
end
- it 'changes user password' do
- page.within '.update-password' do
+ it "changes user password" do
+ page.within ".update-password" do
fill_in "user_current_password", with: user.password
- fill_passwords('22233344', '22233344')
+ fill_passwords("22233344", "22233344")
end
expect(current_path).to eq new_user_session_path
end
end
- context 'when password is expired' do
+ context "when password is expired" do
before do
sign_in(user)
@@ -122,21 +122,21 @@ describe 'Profile > Password' do
expect(user.ldap_user?).to eq false
end
- it 'needs change user password' do
+ it "needs change user password" do
visit edit_profile_password_path
expect(current_path).to eq new_profile_password_path
fill_in :user_current_password, with: user.password
- fill_in :user_password, with: '12345678'
- fill_in :user_password_confirmation, with: '12345678'
- click_button 'Set new password'
+ fill_in :user_password, with: "12345678"
+ fill_in :user_password_confirmation, with: "12345678"
+ click_button "Set new password"
expect(current_path).to eq new_user_session_path
end
- context 'when global require_two_factor_authentication is enabled' do
- it 'needs change user password' do
+ context "when global require_two_factor_authentication is enabled" do
+ it "needs change user password" do
stub_application_setting(require_two_factor_authentication: true)
visit profile_path
diff --git a/spec/features/profiles/personal_access_tokens_spec.rb b/spec/features/profiles/personal_access_tokens_spec.rb
index dee213a11d4..2745ff7b57c 100644
--- a/spec/features/profiles/personal_access_tokens_spec.rb
+++ b/spec/features/profiles/personal_access_tokens_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Profile > Personal Access Tokens', :js do
+describe "Profile > Personal Access Tokens", :js do
let(:user) { create(:user) }
def active_personal_access_tokens
@@ -28,7 +28,7 @@ describe 'Profile > Personal Access Tokens', :js do
describe "token creation" do
it "allows creation of a personal access token" do
- name = 'My PAT'
+ name = "My PAT"
visit profile_personal_access_tokens_path
fill_in "Name", with: name
@@ -45,9 +45,9 @@ describe 'Profile > Personal Access Tokens', :js do
click_on "Create personal access token"
expect(active_personal_access_tokens).to have_text(name)
- expect(active_personal_access_tokens).to have_text('In')
- expect(active_personal_access_tokens).to have_text('api')
- expect(active_personal_access_tokens).to have_text('read_user')
+ expect(active_personal_access_tokens).to have_text("In")
+ expect(active_personal_access_tokens).to have_text("api")
+ expect(active_personal_access_tokens).to have_text("read_user")
expect(created_personal_access_token).not_to be_empty
end
@@ -55,7 +55,7 @@ describe 'Profile > Personal Access Tokens', :js do
it "displays an error message" do
disallow_personal_access_token_saves!
visit profile_personal_access_tokens_path
- fill_in "Name", with: 'My PAT'
+ fill_in "Name", with: "My PAT"
expect { click_on "Create personal access token" }.not_to change { PersonalAccessToken.count }
expect(page).to have_content("Name cannot be nil")
@@ -64,11 +64,11 @@ describe 'Profile > Personal Access Tokens', :js do
end
end
- describe 'active tokens' do
+ describe "active tokens" do
let!(:impersonation_token) { create(:personal_access_token, :impersonation, user: user) }
let!(:personal_access_token) { create(:personal_access_token, user: user) }
- it 'only shows personal access tokens' do
+ it "only shows personal access tokens" do
visit profile_personal_access_tokens_path
expect(active_personal_access_tokens).to have_text(personal_access_token.name)
diff --git a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb
index f618bc330ea..d69c6c6a529 100644
--- a/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb
+++ b/spec/features/profiles/user_changes_notified_of_own_activity_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Profile > Notifications > User changes notified_of_own_activity setting', :js do
+describe "Profile > Notifications > User changes notified_of_own_activity setting", :js do
let(:user) { create(:user) }
before do
sign_in(user)
end
- it 'User opts into receiving notifications about their own activity' do
+ it "User opts into receiving notifications about their own activity" do
visit profile_notifications_path
- expect(page).not_to have_checked_field('user[notified_of_own_activity]')
+ expect(page).not_to have_checked_field("user[notified_of_own_activity]")
- check 'user[notified_of_own_activity]'
+ check "user[notified_of_own_activity]"
- expect(page).to have_content('Notification settings saved')
- expect(page).to have_checked_field('user[notified_of_own_activity]')
+ expect(page).to have_content("Notification settings saved")
+ expect(page).to have_checked_field("user[notified_of_own_activity]")
end
- it 'User opts out of receiving notifications about their own activity' do
+ it "User opts out of receiving notifications about their own activity" do
user.update!(notified_of_own_activity: true)
visit profile_notifications_path
- expect(page).to have_checked_field('user[notified_of_own_activity]')
+ expect(page).to have_checked_field("user[notified_of_own_activity]")
- uncheck 'user[notified_of_own_activity]'
+ uncheck "user[notified_of_own_activity]"
- expect(page).to have_content('Notification settings saved')
- expect(page).not_to have_checked_field('user[notified_of_own_activity]')
+ expect(page).to have_content("Notification settings saved")
+ expect(page).not_to have_checked_field("user[notified_of_own_activity]")
end
end
diff --git a/spec/features/profiles/user_edit_profile_spec.rb b/spec/features/profiles/user_edit_profile_spec.rb
index b43711f6ef6..06de2b73b1b 100644
--- a/spec/features/profiles/user_edit_profile_spec.rb
+++ b/spec/features/profiles/user_edit_profile_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User edit profile' do
+describe "User edit profile" do
let(:user) { create(:user) }
before do
@@ -9,172 +9,172 @@ describe 'User edit profile' do
end
def submit_settings
- click_button 'Update profile settings'
+ click_button "Update profile settings"
wait_for_requests if respond_to?(:wait_for_requests)
end
- it 'changes user profile' do
- fill_in 'user_skype', with: 'testskype'
- fill_in 'user_linkedin', with: 'testlinkedin'
- fill_in 'user_twitter', with: 'testtwitter'
- fill_in 'user_website_url', with: 'testurl'
- fill_in 'user_location', with: 'Ukraine'
- fill_in 'user_bio', with: 'I <3 GitLab'
- fill_in 'user_organization', with: 'GitLab'
+ it "changes user profile" do
+ fill_in "user_skype", with: "testskype"
+ fill_in "user_linkedin", with: "testlinkedin"
+ fill_in "user_twitter", with: "testtwitter"
+ fill_in "user_website_url", with: "testurl"
+ fill_in "user_location", with: "Ukraine"
+ fill_in "user_bio", with: "I <3 GitLab"
+ fill_in "user_organization", with: "GitLab"
submit_settings
expect(user.reload).to have_attributes(
- skype: 'testskype',
- linkedin: 'testlinkedin',
- twitter: 'testtwitter',
- website_url: 'testurl',
- bio: 'I <3 GitLab',
- organization: 'GitLab'
+ skype: "testskype",
+ linkedin: "testlinkedin",
+ twitter: "testtwitter",
+ website_url: "testurl",
+ bio: "I <3 GitLab",
+ organization: "GitLab"
)
- expect(find('#user_location').value).to eq 'Ukraine'
- expect(page).to have_content('Profile was successfully updated')
+ expect(find("#user_location").value).to eq "Ukraine"
+ expect(page).to have_content("Profile was successfully updated")
end
- it 'shows an error if the full name contains an emoji', :js do
- simulate_input('#user_name', 'Martin 😀')
+ it "shows an error if the full name contains an emoji", :js do
+ simulate_input("#user_name", "Martin 😀")
submit_settings
- page.within('.qa-full-name') do
- expect(page).to have_css '.gl-field-error-outline'
- expect(find('.gl-field-error')).not_to have_selector('.hidden')
- expect(find('.gl-field-error')).to have_content('Using emojis in names seems fun, but please try to set a status message instead')
+ page.within(".qa-full-name") do
+ expect(page).to have_css ".gl-field-error-outline"
+ expect(find(".gl-field-error")).not_to have_selector(".hidden")
+ expect(find(".gl-field-error")).to have_content("Using emojis in names seems fun, but please try to set a status message instead")
end
end
- context 'user avatar' do
+ context "user avatar" do
before do
- attach_file(:user_avatar, Rails.root.join('spec', 'fixtures', 'banana_sample.gif'))
+ attach_file(:user_avatar, Rails.root.join("spec", "fixtures", "banana_sample.gif"))
submit_settings
end
- it 'changes user avatar' do
- expect(page).to have_link('Remove avatar')
+ it "changes user avatar" do
+ expect(page).to have_link("Remove avatar")
user.reload
expect(user.avatar).to be_instance_of AvatarUploader
expect(user.avatar.url).to eq "/uploads/-/system/user/avatar/#{user.id}/banana_sample.gif"
end
- it 'removes user avatar' do
- click_link 'Remove avatar'
+ it "removes user avatar" do
+ click_link "Remove avatar"
user.reload
expect(user.avatar?).to eq false
- expect(page).not_to have_link('Remove avatar')
- expect(page).to have_link('gravatar.com')
+ expect(page).not_to have_link("Remove avatar")
+ expect(page).to have_link("gravatar.com")
end
end
- context 'user status', :js do
+ context "user status", :js do
def visit_user
visit user_path(user)
wait_for_requests
end
def select_emoji(emoji_name, is_modal = false)
- emoji_menu_class = is_modal ? '.js-modal-status-emoji-menu' : '.js-status-emoji-menu'
- toggle_button = find('.js-toggle-emoji-menu')
+ emoji_menu_class = is_modal ? ".js-modal-status-emoji-menu" : ".js-status-emoji-menu"
+ toggle_button = find(".js-toggle-emoji-menu")
toggle_button.click
- emoji_button = find(%Q{#{emoji_menu_class} .js-emoji-btn gl-emoji[data-name="#{emoji_name}"]})
+ emoji_button = find(%(#{emoji_menu_class} .js-emoji-btn gl-emoji[data-name="#{emoji_name}"]))
emoji_button.click
end
- context 'profile edit form' do
- it 'shows the user status form' do
- expect(page).to have_content('Current status')
+ context "profile edit form" do
+ it "shows the user status form" do
+ expect(page).to have_content("Current status")
end
- it 'adds emoji to user status' do
- emoji = 'biohazard'
+ it "adds emoji to user status" do
+ emoji = "biohazard"
select_emoji(emoji)
submit_settings
visit_user
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(emoji)
end
end
- it 'adds message to user status' do
- message = 'I have something to say'
- fill_in 'js-status-message-field', with: message
+ it "adds message to user status" do
+ message = "I have something to say"
+ fill_in "js-status-message-field", with: message
submit_settings
visit_user
- within('.cover-status') do
- expect(page).to have_emoji('speech_balloon')
+ within(".cover-status") do
+ expect(page).to have_emoji("speech_balloon")
expect(page).to have_content message
end
end
- it 'adds message and emoji to user status' do
- emoji = 'tanabata_tree'
- message = 'Playing outside'
+ it "adds message and emoji to user status" do
+ emoji = "tanabata_tree"
+ message = "Playing outside"
select_emoji(emoji)
- fill_in 'js-status-message-field', with: message
+ fill_in "js-status-message-field", with: message
submit_settings
visit_user
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(emoji)
expect(page).to have_content message
end
end
- it 'clears the user status' do
- user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
+ it "clears the user status" do
+ user_status = create(:user_status, user: user, message: "Eating bread", emoji: "stuffed_flatbread")
visit_user
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(user_status.emoji)
expect(page).to have_content user_status.message
end
visit(profile_path)
- click_button 'js-clear-user-status-button'
+ click_button "js-clear-user-status-button"
submit_settings
visit_user
- expect(page).not_to have_selector '.cover-status'
+ expect(page).not_to have_selector ".cover-status"
end
- it 'displays a default emoji if only message is entered' do
- message = 'a status without emoji'
- fill_in 'js-status-message-field', with: message
+ it "displays a default emoji if only message is entered" do
+ message = "a status without emoji"
+ fill_in "js-status-message-field", with: message
- within('.js-toggle-emoji-menu') do
- expect(page).to have_emoji('speech_balloon')
+ within(".js-toggle-emoji-menu") do
+ expect(page).to have_emoji("speech_balloon")
end
end
end
- context 'user menu' do
+ context "user menu" do
let(:issue) { create(:issue, project: project)}
let(:project) { create(:project) }
def open_user_status_modal
- find('.header-user-dropdown-toggle').click
+ find(".header-user-dropdown-toggle").click
page.within ".header-user" do
- click_button 'Set status'
+ click_button "Set status"
end
end
def set_user_status_in_modal
page.within "#set-user-status-modal" do
- click_button 'Set status'
+ click_button "Set status"
end
wait_for_requests
end
@@ -184,146 +184,146 @@ describe 'User edit profile' do
end
it 'shows the "Set status" menu item in the user menu' do
- find('.header-user-dropdown-toggle').click
+ find(".header-user-dropdown-toggle").click
page.within ".header-user" do
- expect(page).to have_content('Set status')
+ expect(page).to have_content("Set status")
end
end
it 'shows the "Edit status" menu item in the user menu' do
- user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
+ user_status = create(:user_status, user: user, message: "Eating bread", emoji: "stuffed_flatbread")
visit root_path(user)
- find('.header-user-dropdown-toggle').click
+ find(".header-user-dropdown-toggle").click
page.within ".header-user" do
expect(page).to have_emoji(user_status.emoji)
expect(page).to have_content user_status.message
- expect(page).to have_content('Edit status')
+ expect(page).to have_content("Edit status")
end
end
- it 'shows user status modal' do
+ it "shows user status modal" do
open_user_status_modal
- expect(page.find('#set-user-status-modal')).to be_visible
- expect(page).to have_content('Set a status')
+ expect(page.find("#set-user-status-modal")).to be_visible
+ expect(page).to have_content("Set a status")
end
- it 'adds emoji to user status' do
- emoji = 'biohazard'
+ it "adds emoji to user status" do
+ emoji = "biohazard"
open_user_status_modal
select_emoji(emoji, true)
set_user_status_in_modal
visit_user
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(emoji)
end
end
- it 'does not update the awards panel emoji' do
+ it "does not update the awards panel emoji" do
project.add_maintainer(user)
visit(project_issue_path(project, issue))
- emoji = 'biohazard'
+ emoji = "biohazard"
open_user_status_modal
select_emoji(emoji, true)
- expect(page.all('.award-control .js-counter')).to all(have_content('0'))
+ expect(page.all(".award-control .js-counter")).to all(have_content("0"))
end
- it 'adds message to user status' do
- message = 'I have something to say'
+ it "adds message to user status" do
+ message = "I have something to say"
open_user_status_modal
- find('.js-status-message-field').native.send_keys(message)
+ find(".js-status-message-field").native.send_keys(message)
set_user_status_in_modal
visit_user
- within('.cover-status') do
- expect(page).to have_emoji('speech_balloon')
+ within(".cover-status") do
+ expect(page).to have_emoji("speech_balloon")
expect(page).to have_content message
end
end
- it 'adds message and emoji to user status' do
- emoji = 'tanabata_tree'
- message = 'Playing outside'
+ it "adds message and emoji to user status" do
+ emoji = "tanabata_tree"
+ message = "Playing outside"
open_user_status_modal
select_emoji(emoji, true)
- find('.js-status-message-field').native.send_keys(message)
+ find(".js-status-message-field").native.send_keys(message)
set_user_status_in_modal
visit_user
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(emoji)
expect(page).to have_content message
end
end
it 'clears the user status with the "X" button' do
- user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
+ user_status = create(:user_status, user: user, message: "Eating bread", emoji: "stuffed_flatbread")
visit_user
wait_for_requests
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(user_status.emoji)
expect(page).to have_content user_status.message
end
- find('.header-user-dropdown-toggle').click
+ find(".header-user-dropdown-toggle").click
page.within ".header-user" do
- click_button 'Edit status'
+ click_button "Edit status"
end
- find('.js-clear-user-status-button').click
+ find(".js-clear-user-status-button").click
set_user_status_in_modal
visit_user
wait_for_requests
- expect(page).not_to have_selector '.cover-status'
+ expect(page).not_to have_selector ".cover-status"
end
it 'clears the user status with the "Remove status" button' do
- user_status = create(:user_status, user: user, message: 'Eating bread', emoji: 'stuffed_flatbread')
+ user_status = create(:user_status, user: user, message: "Eating bread", emoji: "stuffed_flatbread")
visit_user
wait_for_requests
- within('.cover-status') do
+ within(".cover-status") do
expect(page).to have_emoji(user_status.emoji)
expect(page).to have_content user_status.message
end
- find('.header-user-dropdown-toggle').click
+ find(".header-user-dropdown-toggle").click
page.within ".header-user" do
- click_button 'Edit status'
+ click_button "Edit status"
end
page.within "#set-user-status-modal" do
- click_button 'Remove status'
+ click_button "Remove status"
end
visit_user
- expect(page).not_to have_selector '.cover-status'
+ expect(page).not_to have_selector ".cover-status"
end
- it 'displays a default emoji if only message is entered' do
- message = 'a status without emoji'
+ it "displays a default emoji if only message is entered" do
+ message = "a status without emoji"
open_user_status_modal
- find('.js-status-message-field').native.send_keys(message)
+ find(".js-status-message-field").native.send_keys(message)
- within('.js-toggle-emoji-menu') do
- expect(page).to have_emoji('speech_balloon')
+ within(".js-toggle-emoji-menu") do
+ expect(page).to have_emoji("speech_balloon")
end
end
end
diff --git a/spec/features/profiles/user_manages_applications_spec.rb b/spec/features/profiles/user_manages_applications_spec.rb
index 34aaab240cc..620983920be 100644
--- a/spec/features/profiles/user_manages_applications_spec.rb
+++ b/spec/features/profiles/user_manages_applications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User manages applications' do
+describe "User manages applications" do
let(:user) { create(:user) }
before do
@@ -8,32 +8,32 @@ describe 'User manages applications' do
visit applications_profile_path
end
- it 'manages applications' do
- expect(page).to have_content 'Add new application'
+ it "manages applications" do
+ expect(page).to have_content "Add new application"
- fill_in :doorkeeper_application_name, with: 'test'
- fill_in :doorkeeper_application_redirect_uri, with: 'https://test.com'
- click_on 'Save application'
+ fill_in :doorkeeper_application_name, with: "test"
+ fill_in :doorkeeper_application_redirect_uri, with: "https://test.com"
+ click_on "Save application"
- expect(page).to have_content 'Application: test'
- expect(page).to have_content 'Application ID'
- expect(page).to have_content 'Secret'
+ expect(page).to have_content "Application: test"
+ expect(page).to have_content "Application ID"
+ expect(page).to have_content "Secret"
- click_on 'Edit'
+ click_on "Edit"
- expect(page).to have_content 'Edit application'
- fill_in :doorkeeper_application_name, with: 'test_changed'
- click_on 'Save application'
+ expect(page).to have_content "Edit application"
+ fill_in :doorkeeper_application_name, with: "test_changed"
+ click_on "Save application"
- expect(page).to have_content 'test_changed'
- expect(page).to have_content 'Application ID'
- expect(page).to have_content 'Secret'
+ expect(page).to have_content "test_changed"
+ expect(page).to have_content "Application ID"
+ expect(page).to have_content "Secret"
visit applications_profile_path
- page.within '.oauth-applications' do
- click_on 'Destroy'
+ page.within ".oauth-applications" do
+ click_on "Destroy"
end
- expect(page.find('.oauth-applications')).not_to have_content 'test_changed'
+ expect(page.find(".oauth-applications")).not_to have_content "test_changed"
end
end
diff --git a/spec/features/profiles/user_manages_emails_spec.rb b/spec/features/profiles/user_manages_emails_spec.rb
index 7283c76eb54..6cf9f05fce0 100644
--- a/spec/features/profiles/user_manages_emails_spec.rb
+++ b/spec/features/profiles/user_manages_emails_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User manages emails' do
+describe "User manages emails" do
let(:user) { create(:user) }
before do
@@ -17,14 +17,14 @@ describe 'User manages emails' do
end
end
- it 'adds an email' do
- fill_in('email_email', with: 'my@email.com')
- click_button('Add')
+ it "adds an email" do
+ fill_in("email_email", with: "my@email.com")
+ click_button("Add")
- email = user.emails.find_by(email: 'my@email.com')
+ email = user.emails.find_by(email: "my@email.com")
expect(email).not_to be_nil
- expect(page).to have_content('my@email.com')
+ expect(page).to have_content("my@email.com")
expect(page).to have_content(user.email)
user.emails.each do |email|
@@ -32,9 +32,9 @@ describe 'User manages emails' do
end
end
- it 'does not add a duplicate email' do
- fill_in('email_email', with: user.email)
- click_button('Add')
+ it "does not add a duplicate email" do
+ fill_in("email_email", with: user.email)
+ click_button("Add")
email = user.emails.find_by(email: user.email)
@@ -46,14 +46,14 @@ describe 'User manages emails' do
end
end
- it 'removes an email' do
- fill_in('email_email', with: 'my@email.com')
- click_button('Add')
+ it "removes an email" do
+ fill_in("email_email", with: "my@email.com")
+ click_button("Add")
- email = user.emails.find_by(email: 'my@email.com')
+ email = user.emails.find_by(email: "my@email.com")
expect(email).not_to be_nil
- expect(page).to have_content('my@email.com')
+ expect(page).to have_content("my@email.com")
expect(page).to have_content(user.email)
user.emails.each do |email|
@@ -61,14 +61,14 @@ describe 'User manages emails' do
end
# There should be only one remove button at this time
- click_link('Remove')
+ click_link("Remove")
# Force these to reload as they have been cached
user.emails.reload
- email = user.emails.find_by(email: 'my@email.com')
+ email = user.emails.find_by(email: "my@email.com")
expect(email).to be_nil
- expect(page).not_to have_content('my@email.com')
+ expect(page).not_to have_content("my@email.com")
expect(page).to have_content(user.email)
user.emails.each do |email|
diff --git a/spec/features/profiles/user_visits_notifications_tab_spec.rb b/spec/features/profiles/user_visits_notifications_tab_spec.rb
index db797bb586f..db1d173a19c 100644
--- a/spec/features/profiles/user_visits_notifications_tab_spec.rb
+++ b/spec/features/profiles/user_visits_notifications_tab_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits the notifications tab', :js do
+describe "User visits the notifications tab", :js do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,12 +10,12 @@ describe 'User visits the notifications tab', :js do
visit(profile_notifications_path)
end
- it 'changes the project notifications setting' do
- expect(page).to have_content('Notifications')
+ it "changes the project notifications setting" do
+ expect(page).to have_content("Notifications")
- first('#notifications-button').click
- click_link('On mention')
+ first("#notifications-button").click
+ click_link("On mention")
- expect(page).to have_selector('#notifications-button', text: 'On mention')
+ expect(page).to have_selector("#notifications-button", text: "On mention")
end
end
diff --git a/spec/features/profiles/user_visits_profile_account_page_spec.rb b/spec/features/profiles/user_visits_profile_account_page_spec.rb
index a8c08a680d7..51df5373e94 100644
--- a/spec/features/profiles/user_visits_profile_account_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_account_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits the profile account page' do
+describe "User visits the profile account page" do
let(:user) { create(:user) }
before do
@@ -9,7 +9,7 @@ describe 'User visits the profile account page' do
visit(profile_account_path)
end
- it 'shows correct menu item' do
- expect(page).to have_active_navigation('Account')
+ it "shows correct menu item" do
+ expect(page).to have_active_navigation("Account")
end
end
diff --git a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb
index 0f419c3c2c0..74aac11ea20 100644
--- a/spec/features/profiles/user_visits_profile_authentication_log_spec.rb
+++ b/spec/features/profiles/user_visits_profile_authentication_log_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits the authentication log' do
+describe "User visits the authentication log" do
let(:user) { create(:user) }
- context 'when user signed in' do
+ context "when user signed in" do
before do
sign_in(user)
end
- it 'shows correct menu item' do
+ it "shows correct menu item" do
visit(audit_log_profile_path)
- expect(page).to have_active_navigation('Authentication log')
+ expect(page).to have_active_navigation("Authentication log")
end
end
- context 'when user has activity' do
+ context "when user has activity" do
before do
create(:closed_issue_event, author: user)
gitlab_sign_in(user)
end
- it 'shows user activity' do
+ it "shows user activity" do
visit(audit_log_profile_path)
- expect(page).to have_content 'Signed in with standard authentication'
+ expect(page).to have_content "Signed in with standard authentication"
end
end
end
diff --git a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
index 9909bfb5904..ab02ac9132d 100644
--- a/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_preferences_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits the profile preferences page' do
+describe "User visits the profile preferences page" do
include Select2Helper
let(:user) { create(:user) }
@@ -11,71 +11,71 @@ describe 'User visits the profile preferences page' do
visit(profile_preferences_path)
end
- it 'shows correct menu item' do
- expect(page).to have_active_navigation('Preferences')
+ it "shows correct menu item" do
+ expect(page).to have_active_navigation("Preferences")
end
- describe 'User changes their syntax highlighting theme', :js do
- it 'creates a flash message' do
- choose 'user_color_scheme_id_5'
+ describe "User changes their syntax highlighting theme", :js do
+ it "creates a flash message" do
+ choose "user_color_scheme_id_5"
wait_for_requests
expect_preferences_saved_message
end
- it 'updates their preference' do
- choose 'user_color_scheme_id_5'
+ it "updates their preference" do
+ choose "user_color_scheme_id_5"
wait_for_requests
refresh
- expect(page).to have_checked_field('user_color_scheme_id_5')
+ expect(page).to have_checked_field("user_color_scheme_id_5")
end
end
- describe 'User changes their default dashboard', :js do
- it 'creates a flash message' do
- select 'Starred Projects', from: 'user_dashboard'
- click_button 'Save'
+ describe "User changes their default dashboard", :js do
+ it "creates a flash message" do
+ select "Starred Projects", from: "user_dashboard"
+ click_button "Save"
wait_for_requests
expect_preferences_saved_message
end
- it 'updates their preference' do
- select 'Starred Projects', from: 'user_dashboard'
- click_button 'Save'
+ it "updates their preference" do
+ select "Starred Projects", from: "user_dashboard"
+ click_button "Save"
wait_for_requests
- find('#logo').click
+ find("#logo").click
expect(page).to have_content("You don't have starred projects yet")
expect(page.current_path).to eq starred_dashboard_projects_path
- find('.shortcuts-activity').click
+ find(".shortcuts-activity").click
expect(page).not_to have_content("You don't have starred projects yet")
expect(page.current_path).to eq dashboard_projects_path
end
end
- describe 'User changes their language', :js do
- it 'creates a flash message' do
- select2('en', from: '#user_preferred_language')
- click_button 'Save'
+ describe "User changes their language", :js do
+ it "creates a flash message" do
+ select2("en", from: "#user_preferred_language")
+ click_button "Save"
wait_for_requests
expect_preferences_saved_message
end
- it 'updates their preference' do
+ it "updates their preference" do
wait_for_requests
- select2('eo', from: '#user_preferred_language')
- click_button 'Save'
+ select2("eo", from: "#user_preferred_language")
+ click_button "Save"
wait_for_requests
refresh
@@ -85,8 +85,8 @@ describe 'User visits the profile preferences page' do
end
def expect_preferences_saved_message
- page.within('.flash-container') do
- expect(page).to have_content('Preferences saved.')
+ page.within(".flash-container") do
+ expect(page).to have_content("Preferences saved.")
end
end
end
diff --git a/spec/features/profiles/user_visits_profile_spec.rb b/spec/features/profiles/user_visits_profile_spec.rb
index 2dc4547b2d8..13337f5afa6 100644
--- a/spec/features/profiles/user_visits_profile_spec.rb
+++ b/spec/features/profiles/user_visits_profile_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits their profile' do
+describe "User visits their profile" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- it 'shows correct menu item' do
+ it "shows correct menu item" do
visit(profile_path)
- expect(page).to have_active_navigation('Profile')
+ expect(page).to have_active_navigation("Profile")
end
- it 'shows profile info' do
+ it "shows profile info" do
visit(profile_path)
expect(page).to have_content "This information will appear on your profile"
end
- context 'when user has groups' do
+ context "when user has groups" do
let(:group) do
create :group do |group|
group.add_owner(user)
@@ -34,14 +34,14 @@ describe 'User visits their profile' do
end
def click_on_profile_picture
- find(:css, '.header-user-dropdown-toggle').click
+ find(:css, ".header-user-dropdown-toggle").click
page.within ".header-user" do
click_link "Profile"
end
end
- it 'shows user groups', :js do
+ it "shows user groups", :js do
visit(profile_path)
click_on_profile_picture
diff --git a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
index 685bf44619d..fea5d53337c 100644
--- a/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
+++ b/spec/features/profiles/user_visits_profile_ssh_keys_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User visits the profile SSH keys page' do
+describe "User visits the profile SSH keys page" do
let(:user) { create(:user) }
before do
@@ -9,7 +9,7 @@ describe 'User visits the profile SSH keys page' do
visit(profile_keys_path)
end
- it 'shows correct menu item' do
- expect(page).to have_active_navigation('SSH Keys')
+ it "shows correct menu item" do
+ expect(page).to have_active_navigation("SSH Keys")
end
end
diff --git a/spec/features/project_variables_spec.rb b/spec/features/project_variables_spec.rb
index 6bdf5df1036..c726a20f4aa 100644
--- a/spec/features/project_variables_spec.rb
+++ b/spec/features/project_variables_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project variables', :js do
+describe "Project variables", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:variable) { create(:ci_variable, key: 'test_key', value: 'test_value') }
+ let(:variable) { create(:ci_variable, key: "test_key", value: "test_value") }
let(:page_path) { project_settings_ci_cd_path(project) }
before do
@@ -14,5 +14,5 @@ describe 'Project variables', :js do
visit page_path
end
- it_behaves_like 'variable list'
+ it_behaves_like "variable list"
end
diff --git a/spec/features/projects/activity/rss_spec.rb b/spec/features/projects/activity/rss_spec.rb
index 411134e7b8e..5950460de23 100644
--- a/spec/features/projects/activity/rss_spec.rb
+++ b/spec/features/projects/activity/rss_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Activity RSS' do
+describe "Project Activity RSS" do
let(:project) { create(:project, :public) }
let(:user) { project.owner }
let(:path) { activity_project_path(project) }
@@ -9,7 +9,7 @@ describe 'Project Activity RSS' do
create(:issue, project: project)
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(project.owner)
visit path
@@ -18,7 +18,7 @@ describe 'Project Activity RSS' do
it_behaves_like "it has an RSS button with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/projects/activity/user_sees_activity_spec.rb b/spec/features/projects/activity/user_sees_activity_spec.rb
index bb4b2abc3c7..8dbacf8dca0 100644
--- a/spec/features/projects/activity/user_sees_activity_spec.rb
+++ b/spec/features/projects/activity/user_sees_activity_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Activity > User sees activity' do
+describe "Projects > Activity > User sees activity" do
let(:project) { create(:project, :repository, :public) }
let(:user) { project.creator }
let(:issue) { create(:issue, project: project) }
@@ -9,21 +9,21 @@ describe 'Projects > Activity > User sees activity' do
create(:event, :created, project: project, target: issue, author: user)
event = create(:push_event, project: project, author: user)
create(:push_event_payload,
- event: event,
- action: :created,
- commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f',
- ref: 'fix',
- commit_count: 1)
+ event: event,
+ action: :created,
+ commit_to: "6d394385cf567f80a8fd85055db1ab4c5295806f",
+ ref: "fix",
+ commit_count: 1)
end
- it 'shows the last push in the activity page', :js do
+ it "shows the last push in the activity page", :js do
visit activity_project_path(project)
expect(page).to have_content "#{user.name} #{user.to_reference} pushed new branch fix"
end
it 'allows to filter event with the "event_filter=issue" URL param', :js do
- visit activity_project_path(project, event_filter: 'issue')
+ visit activity_project_path(project, event_filter: "issue")
expect(page).not_to have_content "#{user.name} #{user.to_reference} pushed new branch fix"
expect(page).to have_content "#{user.name} #{user.to_reference} opened issue #{issue.to_reference}"
diff --git a/spec/features/projects/activity/user_sees_private_activity_spec.rb b/spec/features/projects/activity/user_sees_private_activity_spec.rb
index 61ec2ce9d29..51c7fb003af 100644
--- a/spec/features/projects/activity/user_sees_private_activity_spec.rb
+++ b/spec/features/projects/activity/user_sees_private_activity_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project > Activity > User sees private activity', :js do
+describe "Project > Activity > User sees private activity", :js do
let(:project) { create(:project, :public) }
let(:author) { create(:user) }
let(:user) { create(:user) }
@@ -13,21 +13,21 @@ describe 'Project > Activity > User sees private activity', :js do
create(:event, :created, project: project, target: issue, author: author)
end
- it 'shows the activity to a logged-in user with permissions' do
+ it "shows the activity to a logged-in user with permissions" do
sign_in(author)
visit activity_project_path(project)
expect(page).to have_content(message)
end
- it 'hides the activity from a logged-in user without permissions' do
+ it "hides the activity from a logged-in user without permissions" do
sign_in(user)
visit activity_project_path(project)
expect(page).not_to have_content(message)
end
- it 'hides the activity from an anonymous user' do
+ it "hides the activity from an anonymous user" do
visit activity_project_path(project)
expect(page).not_to have_content(message)
diff --git a/spec/features/projects/actve_tabs_spec.rb b/spec/features/projects/actve_tabs_spec.rb
index 7c6110c533b..8d41c8bb6d6 100644
--- a/spec/features/projects/actve_tabs_spec.rb
+++ b/spec/features/projects/actve_tabs_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project active tab' do
+describe "Project active tab" do
let(:user) { create :user }
let(:project) { create(:project, :repository) }
@@ -10,128 +10,128 @@ describe 'Project active tab' do
end
def click_tab(title)
- page.within '.sidebar-top-level-items > .active' do
+ page.within ".sidebar-top-level-items > .active" do
click_link(title)
end
end
- shared_examples 'page has active tab' do |title|
+ shared_examples "page has active tab" do |title|
it "activates #{title} tab" do
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
- expect(find('.sidebar-top-level-items > li.active')).to have_content(title)
+ expect(page).to have_selector(".sidebar-top-level-items > li.active", count: 1)
+ expect(find(".sidebar-top-level-items > li.active")).to have_content(title)
end
end
- shared_examples 'page has active sub tab' do |title|
+ shared_examples "page has active sub tab" do |title|
it "activates #{title} sub tab" do
- expect(page).to have_selector('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)', count: 1)
- expect(find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)'))
+ expect(page).to have_selector(".sidebar-sub-level-items > li.active:not(.fly-out-top-item)", count: 1)
+ expect(find(".sidebar-sub-level-items > li.active:not(.fly-out-top-item)"))
.to have_content(title)
end
end
- context 'on project Home' do
+ context "on project Home" do
before do
visit project_path(project)
end
- it_behaves_like 'page has active tab', 'Project'
- it_behaves_like 'page has active sub tab', 'Details'
+ it_behaves_like "page has active tab", "Project"
+ it_behaves_like "page has active sub tab", "Details"
- context 'on project Home/Activity' do
+ context "on project Home/Activity" do
before do
- click_tab('Activity')
+ click_tab("Activity")
end
- it_behaves_like 'page has active tab', 'Project'
- it_behaves_like 'page has active sub tab', 'Activity'
+ it_behaves_like "page has active tab", "Project"
+ it_behaves_like "page has active sub tab", "Activity"
end
end
- context 'on project Repository' do
+ context "on project Repository" do
before do
root_ref = project.repository.root_ref
visit project_tree_path(project, root_ref)
end
- it_behaves_like 'page has active tab', 'Repository'
+ it_behaves_like "page has active tab", "Repository"
- %w(Files Commits Graph Compare Charts Branches Tags).each do |sub_menu|
+ %w[Files Commits Graph Compare Charts Branches Tags].each do |sub_menu|
context "on project Repository/#{sub_menu}" do
before do
click_tab(sub_menu)
end
- it_behaves_like 'page has active tab', 'Repository'
- it_behaves_like 'page has active sub tab', sub_menu
+ it_behaves_like "page has active tab", "Repository"
+ it_behaves_like "page has active sub tab", sub_menu
end
end
end
- context 'on project Issues' do
+ context "on project Issues" do
before do
visit project_issues_path(project)
end
- it_behaves_like 'page has active tab', 'Issues'
+ it_behaves_like "page has active tab", "Issues"
- %w(Milestones Labels).each do |sub_menu|
+ %w[Milestones Labels].each do |sub_menu|
context "on project Issues/#{sub_menu}" do
before do
click_tab(sub_menu)
end
- it_behaves_like 'page has active tab', 'Issues'
- it_behaves_like 'page has active sub tab', sub_menu
+ it_behaves_like "page has active tab", "Issues"
+ it_behaves_like "page has active sub tab", sub_menu
end
end
end
- context 'on project Merge Requests' do
+ context "on project Merge Requests" do
before do
visit project_merge_requests_path(project)
end
- it_behaves_like 'page has active tab', 'Merge Requests'
+ it_behaves_like "page has active tab", "Merge Requests"
end
- context 'on project Wiki' do
+ context "on project Wiki" do
before do
visit project_wiki_path(project, :home)
end
- it_behaves_like 'page has active tab', 'Wiki'
+ it_behaves_like "page has active tab", "Wiki"
end
- context 'on project Members' do
+ context "on project Members" do
before do
visit project_project_members_path(project)
end
- it_behaves_like 'page has active tab', 'Members'
+ it_behaves_like "page has active tab", "Members"
end
- context 'on project Settings' do
+ context "on project Settings" do
before do
visit edit_project_path(project)
end
- context 'on project Settings/Integrations' do
+ context "on project Settings/Integrations" do
before do
- click_tab('Integrations')
+ click_tab("Integrations")
end
- it_behaves_like 'page has active tab', 'Settings'
- it_behaves_like 'page has active sub tab', 'Integrations'
+ it_behaves_like "page has active tab", "Settings"
+ it_behaves_like "page has active sub tab", "Integrations"
end
- context 'on project Settings/Repository' do
+ context "on project Settings/Repository" do
before do
- click_tab('Repository')
+ click_tab("Repository")
end
- it_behaves_like 'page has active tab', 'Settings'
- it_behaves_like 'page has active sub tab', 'Repository'
+ it_behaves_like "page has active tab", "Settings"
+ it_behaves_like "page has active sub tab", "Repository"
end
end
end
diff --git a/spec/features/projects/artifacts/file_spec.rb b/spec/features/projects/artifacts/file_spec.rb
index 993d0040434..dc22340b30e 100644
--- a/spec/features/projects/artifacts/file_spec.rb
+++ b/spec/features/projects/artifacts/file_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Artifact file', :js do
+describe "Artifact file", :js do
let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
@@ -13,61 +13,61 @@ describe 'Artifact file', :js do
file_project_job_artifacts_path(project, build, path)
end
- context 'Text file' do
+ context "Text file" do
before do
- visit_file('other_artifacts_0.1.2/doc_sample.txt')
+ visit_file("other_artifacts_0.1.2/doc_sample.txt")
wait_for_requests
end
- it 'displays an error' do
+ it "displays an error" do
aggregate_failures do
# shows an error message
- expect(page).to have_content('The source could not be displayed because it is stored as a job artifact. You can download it instead.')
+ expect(page).to have_content("The source could not be displayed because it is stored as a job artifact. You can download it instead.")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'JPG file' do
+ context "JPG file" do
before do
- visit_file('rails_sample.jpg')
+ visit_file("rails_sample.jpg")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows rendered image
- expect(page).to have_selector('.image_file img')
+ expect(page).to have_selector(".image_file img")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'when visiting old URL' do
+ context "when visiting old URL" do
let(:file_url) do
- file_path('other_artifacts_0.1.2/doc_sample.txt')
+ file_path("other_artifacts_0.1.2/doc_sample.txt")
end
before do
- visit file_url.sub('/-/jobs', '/builds')
+ visit file_url.sub("/-/jobs", "/builds")
end
it "redirects to new URL" do
diff --git a/spec/features/projects/artifacts/raw_spec.rb b/spec/features/projects/artifacts/raw_spec.rb
index d8ee9adda6b..0537eea623b 100644
--- a/spec/features/projects/artifacts/raw_spec.rb
+++ b/spec/features/projects/artifacts/raw_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Raw artifact', :js do
+describe "Raw artifact", :js do
let(:project) { create(:project, :public) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
@@ -9,13 +9,13 @@ describe 'Raw artifact', :js do
raw_project_job_artifacts_path(project, job, path)
end
- context 'when visiting old URL' do
+ context "when visiting old URL" do
let(:raw_url) do
- raw_path('other_artifacts_0.1.2/doc_sample.txt')
+ raw_path("other_artifacts_0.1.2/doc_sample.txt")
end
before do
- visit raw_url.sub('/-/jobs', '/builds')
+ visit raw_url.sub("/-/jobs", "/builds")
end
it "redirects to new URL" do
diff --git a/spec/features/projects/artifacts/user_browses_artifacts_spec.rb b/spec/features/projects/artifacts/user_browses_artifacts_spec.rb
index 5f630c9ffa4..391a800a17b 100644
--- a/spec/features/projects/artifacts/user_browses_artifacts_spec.rb
+++ b/spec/features/projects/artifacts/user_browses_artifacts_spec.rb
@@ -24,9 +24,9 @@ describe "User browses artifacts" do
page.within(".tree-table") do
expect(page).to have_no_content("..")
- .and have_content("other_artifacts_0.1.2")
- .and have_content("ci_artifacts.txt 27 Bytes")
- .and have_content("rails_sample.jpg 34.4 KB")
+ .and have_content("other_artifacts_0.1.2")
+ .and have_content("ci_artifacts.txt 27 Bytes")
+ .and have_content("rails_sample.jpg 34.4 KB")
end
page.within(".build-header") do
@@ -78,7 +78,7 @@ describe "User browses artifacts" do
expect(link[:target]).to eq("_blank")
expect(link[:rel]).to include("noopener").and include("noreferrer")
expect(page).to have_link("doc_sample.txt", href: file_project_job_artifacts_path(project, job, path: txt_entry.blob.path))
- .and have_selector(".js-artifact-tree-external-icon")
+ .and have_selector(".js-artifact-tree-external-icon")
page.within(".tree-table") do
expect(page).to have_content("..").and have_content("another-subdirectory")
diff --git a/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb
index 5cb015e80be..3be0d7b77c3 100644
--- a/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb
+++ b/spec/features/projects/artifacts/user_downloads_artifacts_spec.rb
@@ -7,9 +7,9 @@ describe "User downloads artifacts" do
shared_examples "downloading" do
it "downloads the zip" do
- expect(page.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"})
- expect(page.response_headers['Content-Transfer-Encoding']).to eq("binary")
- expect(page.response_headers['Content-Type']).to eq("application/zip")
+ expect(page.response_headers["Content-Disposition"]).to eq(%(attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"))
+ expect(page.response_headers["Content-Transfer-Encoding"]).to eq("binary")
+ expect(page.response_headers["Content-Type"]).to eq("application/zip")
expect(page.source.b).to eq(job.artifacts_file.file.read.b)
end
end
diff --git a/spec/features/projects/badges/coverage_spec.rb b/spec/features/projects/badges/coverage_spec.rb
index 8522ea747fa..3ee5e4b7fa1 100644
--- a/spec/features/projects/badges/coverage_spec.rb
+++ b/spec/features/projects/badges/coverage_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'test coverage badge' do
+describe "test coverage badge" do
let!(:user) { create(:user) }
let!(:project) { create(:project, :private) }
- context 'when user has access to view badge' do
+ context "when user has access to view badge" do
before do
project.add_developer(user)
sign_in(user)
end
- it 'user requests coverage badge image for pipeline' do
+ it "user requests coverage badge image for pipeline" do
create_pipeline do |pipeline|
- create_build(pipeline, coverage: 100, name: 'test:1')
- create_build(pipeline, coverage: 90, name: 'test:2')
+ create_build(pipeline, coverage: 100, name: "test:1")
+ create_build(pipeline, coverage: 90, name: "test:2")
end
show_test_coverage_badge
- expect_coverage_badge('95.00%')
+ expect_coverage_badge("95.00%")
end
- it 'user requests coverage badge for specific job' do
+ it "user requests coverage badge for specific job" do
create_pipeline do |pipeline|
- create_build(pipeline, coverage: 50, name: 'test:1')
- create_build(pipeline, coverage: 50, name: 'test:2')
- create_build(pipeline, coverage: 85, name: 'coverage')
+ create_build(pipeline, coverage: 50, name: "test:1")
+ create_build(pipeline, coverage: 50, name: "test:2")
+ create_build(pipeline, coverage: 85, name: "coverage")
end
- show_test_coverage_badge(job: 'coverage')
+ show_test_coverage_badge(job: "coverage")
- expect_coverage_badge('85.00%')
+ expect_coverage_badge("85.00%")
end
- it 'user requests coverage badge for pipeline without coverage' do
+ it "user requests coverage badge for pipeline without coverage" do
create_pipeline do |pipeline|
- create_build(pipeline, coverage: nil, name: 'test')
+ create_build(pipeline, coverage: nil, name: "test")
end
show_test_coverage_badge
- expect_coverage_badge('unknown')
+ expect_coverage_badge("unknown")
end
end
- context 'when user does not have access to view badge' do
+ context "when user does not have access to view badge" do
before do
sign_in(user)
end
- it 'user requests test coverage badge image' do
+ it "user requests test coverage badge image" do
show_test_coverage_badge
expect(page).to have_gitlab_http_status(404)
@@ -57,7 +57,7 @@ describe 'test coverage badge' do
end
def create_pipeline
- opts = { project: project }
+ opts = {project: project}
create(:ci_pipeline, opts).tap do |pipeline|
yield pipeline
@@ -66,7 +66,7 @@ describe 'test coverage badge' do
end
def create_build(pipeline, coverage:, name:)
- opts = { pipeline: pipeline, coverage: coverage, name: name }
+ opts = {pipeline: pipeline, coverage: coverage, name: name}
create(:ci_build, :success, opts)
end
@@ -77,7 +77,7 @@ describe 'test coverage badge' do
def expect_coverage_badge(coverage)
svg = Nokogiri::XML.parse(page.body)
- expect(page.response_headers['Content-Type']).to include('image/svg+xml')
- expect(svg.at(%Q{text:contains("#{coverage}")})).to be_truthy
+ expect(page.response_headers["Content-Type"]).to include("image/svg+xml")
+ expect(svg.at(%{text:contains("#{coverage}")})).to be_truthy
end
end
diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb
index e30b908c60d..c545f3777df 100644
--- a/spec/features/projects/badges/list_spec.rb
+++ b/spec/features/projects/badges/list_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'list of badges' do
+describe "list of badges" do
before do
user = create(:user)
project = create(:project, :repository)
@@ -9,45 +9,45 @@ describe 'list of badges' do
visit project_settings_ci_cd_path(project)
end
- it 'user wants to see build status badge' do
- page.within('.pipeline-status') do
- expect(page).to have_content 'pipeline status'
- expect(page).to have_content 'Markdown'
- expect(page).to have_content 'HTML'
- expect(page).to have_content 'AsciiDoc'
- expect(page).to have_css('.highlight', count: 3)
+ it "user wants to see build status badge" do
+ page.within(".pipeline-status") do
+ expect(page).to have_content "pipeline status"
+ expect(page).to have_content "Markdown"
+ expect(page).to have_content "HTML"
+ expect(page).to have_content "AsciiDoc"
+ expect(page).to have_css(".highlight", count: 3)
expect(page).to have_xpath("//img[@alt='pipeline status']")
- page.within('.highlight', match: :first) do
- expect(page).to have_content 'badges/master/pipeline.svg'
+ page.within(".highlight", match: :first) do
+ expect(page).to have_content "badges/master/pipeline.svg"
end
end
end
- it 'user wants to see coverage report badge' do
- page.within('.coverage-report') do
- expect(page).to have_content 'coverage report'
- expect(page).to have_content 'Markdown'
- expect(page).to have_content 'HTML'
- expect(page).to have_content 'AsciiDoc'
- expect(page).to have_css('.highlight', count: 3)
+ it "user wants to see coverage report badge" do
+ page.within(".coverage-report") do
+ expect(page).to have_content "coverage report"
+ expect(page).to have_content "Markdown"
+ expect(page).to have_content "HTML"
+ expect(page).to have_content "AsciiDoc"
+ expect(page).to have_css(".highlight", count: 3)
expect(page).to have_xpath("//img[@alt='coverage report']")
- page.within('.highlight', match: :first) do
- expect(page).to have_content 'badges/master/coverage.svg'
+ page.within(".highlight", match: :first) do
+ expect(page).to have_content "badges/master/coverage.svg"
end
end
end
- it 'user changes current ref of build status badge', :js do
- page.within('.pipeline-status') do
- first('.js-project-refs-dropdown').click
+ it "user changes current ref of build status badge", :js do
+ page.within(".pipeline-status") do
+ first(".js-project-refs-dropdown").click
- page.within '.project-refs-form' do
- click_link 'improve/awesome'
+ page.within ".project-refs-form" do
+ click_link "improve/awesome"
end
- expect(page).to have_content 'badges/improve/awesome/pipeline.svg'
+ expect(page).to have_content "badges/improve/awesome/pipeline.svg"
end
end
end
diff --git a/spec/features/projects/badges/pipeline_badge_spec.rb b/spec/features/projects/badges/pipeline_badge_spec.rb
index dee81898928..c30b8dee6db 100644
--- a/spec/features/projects/badges/pipeline_badge_spec.rb
+++ b/spec/features/projects/badges/pipeline_badge_spec.rb
@@ -1,70 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Pipeline Badge' do
+describe "Pipeline Badge" do
set(:project) { create(:project, :repository, :public) }
let(:ref) { project.default_branch }
# this can't be tested in the controller, as it bypasses the rails router
# and constructs a route based on the controller being tested
# Keep around until 10.0, see gitlab-org/gitlab-ce#35307
- context 'when the deprecated badge is requested' do
- it 'displays the badge' do
+ context "when the deprecated badge is requested" do
+ it "displays the badge" do
visit build_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
end
end
- context 'when the project has a pipeline' do
+ context "when the project has a pipeline" do
let!(:pipeline) { create(:ci_empty_pipeline, project: project, ref: ref, sha: project.commit(ref).sha) }
let!(:job) { create(:ci_build, pipeline: pipeline) }
- context 'when the pipeline was successful' do
- it 'displays so on the badge' do
+ context "when the pipeline was successful" do
+ it "displays so on the badge" do
job.success
visit pipeline_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
- expect_badge('passed')
+ expect_badge("passed")
end
end
- context 'when the pipeline failed' do
- it 'shows displays so on the badge' do
+ context "when the pipeline failed" do
+ it "shows displays so on the badge" do
job.drop
visit pipeline_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
- expect_badge('failed')
+ expect_badge("failed")
end
end
- context 'when the pipeline is running' do
- it 'shows displays so on the badge' do
- create(:ci_build, pipeline: pipeline, name: 'second build', status_event: 'run')
+ context "when the pipeline is running" do
+ it "shows displays so on the badge" do
+ create(:ci_build, pipeline: pipeline, name: "second build", status_event: "run")
visit pipeline_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
- expect_badge('running')
+ expect_badge("running")
end
end
- context 'when a new pipeline is created' do
- it 'shows a fresh badge' do
+ context "when a new pipeline is created" do
+ it "shows a fresh badge" do
visit pipeline_project_badges_path(project, ref: ref, format: :svg)
expect(page.status_code).to eq(200)
- expect(page.response_headers['Cache-Control']).to include 'no-cache'
+ expect(page.response_headers["Cache-Control"]).to include "no-cache"
end
end
def expect_badge(status)
svg = Nokogiri::XML.parse(page.body)
- expect(page.response_headers['Content-Type']).to include('image/svg+xml')
- expect(svg.at(%Q{text:contains("#{status}")})).to be_truthy
+ expect(page.response_headers["Content-Type"]).to include("image/svg+xml")
+ expect(svg.at(%{text:contains("#{status}")})).to be_truthy
end
end
end
diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
index 96f514f4f04..775c32a4b60 100644
--- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
+++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb
@@ -1,96 +1,96 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Blob button line permalinks (BlobLinePermalinkUpdater)', :js do
+describe "Blob button line permalinks (BlobLinePermalinkUpdater)", :js do
include TreeHelper
let(:project) { create(:project, :public, :repository) }
- let(:path) { 'CHANGELOG' }
+ let(:path) { "CHANGELOG" }
let(:sha) { project.repository.commit.sha }
- describe 'On a file(blob)' do
+ describe "On a file(blob)" do
def get_absolute_url(path = "")
"http://#{page.server.host}:#{page.server.port}#{path}"
end
def visit_blob(fragment = nil)
- visit project_blob_path(project, tree_join('master', path), anchor: fragment)
+ visit project_blob_path(project, tree_join("master", path), anchor: fragment)
end
describe 'Click "Permalink" button' do
- it 'works with no initial line number fragment hash' do
+ it "works with no initial line number fragment hash" do
visit_blob
- expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path))))
+ expect(find(".js-data-file-blob-permalink-url")["href"]).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path))))
end
- it 'maintains intitial fragment hash' do
+ it "maintains intitial fragment hash" do
fragment = "L3"
visit_blob(fragment)
- expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)))
+ expect(find(".js-data-file-blob-permalink-url")["href"]).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)))
end
- it 'changes fragment hash if line number clicked' do
+ it "changes fragment hash if line number clicked" do
ending_fragment = "L5"
visit_blob
- find('#L3').click
+ find("#L3").click
find("##{ending_fragment}").click
- expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
+ expect(find(".js-data-file-blob-permalink-url")["href"]).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
- it 'with initial fragment hash, changes fragment hash if line number clicked' do
+ it "with initial fragment hash, changes fragment hash if line number clicked" do
fragment = "L1"
ending_fragment = "L5"
visit_blob(fragment)
- find('#L3').click
+ find("#L3").click
find("##{ending_fragment}").click
- expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
+ expect(find(".js-data-file-blob-permalink-url")["href"]).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment)))
end
end
describe 'Click "Blame" button' do
- it 'works with no initial line number fragment hash' do
+ it "works with no initial line number fragment hash" do
visit_blob
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path))))
+ expect(find(".js-blob-blame-link")["href"]).to eq(get_absolute_url(project_blame_path(project, tree_join("master", path))))
end
- it 'maintains intitial fragment hash' do
+ it "maintains intitial fragment hash" do
fragment = "L3"
visit_blob(fragment)
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: fragment)))
+ expect(find(".js-blob-blame-link")["href"]).to eq(get_absolute_url(project_blame_path(project, tree_join("master", path), anchor: fragment)))
end
- it 'changes fragment hash if line number clicked' do
+ it "changes fragment hash if line number clicked" do
ending_fragment = "L5"
visit_blob
- find('#L3').click
+ find("#L3").click
find("##{ending_fragment}").click
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
+ expect(find(".js-blob-blame-link")["href"]).to eq(get_absolute_url(project_blame_path(project, tree_join("master", path), anchor: ending_fragment)))
end
- it 'with initial fragment hash, changes fragment hash if line number clicked' do
+ it "with initial fragment hash, changes fragment hash if line number clicked" do
fragment = "L1"
ending_fragment = "L5"
visit_blob(fragment)
- find('#L3').click
+ find("#L3").click
find("##{ending_fragment}").click
- expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment)))
+ expect(find(".js-blob-blame-link")["href"]).to eq(get_absolute_url(project_blame_path(project, tree_join("master", path), anchor: ending_fragment)))
end
end
end
diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb
index 3edcc7ac2cd..ca75314700d 100644
--- a/spec/features/projects/blobs/blob_show_spec.rb
+++ b/spec/features/projects/blobs/blob_show_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'File blob', :js do
+describe "File blob", :js do
include MobileHelpers
let(:project) { create(:project, :public, :repository) }
- def visit_blob(path, anchor: nil, ref: 'master')
+ def visit_blob(path, anchor: nil, ref: "master")
visit project_blob_path(project, File.join(ref, path), anchor: anchor)
wait_for_requests
end
- context 'Ruby file' do
+ context "Ruby file" do
before do
- visit_blob('files/ruby/popen.rb')
+ visit_blob("files/ruby/popen.rb")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows highlighted Ruby code
expect(page).to have_css(".js-syntax-highlight")
expect(page).to have_content("require 'fileutils'")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
end
end
- it 'displays file actions on all screen sizes' do
- file_actions_selector = '.file-actions'
+ it "displays file actions on all screen sizes" do
+ file_actions_selector = ".file-actions"
resize_screen_sm
expect(page).to have_selector(file_actions_selector, visible: true)
@@ -46,15 +46,15 @@ describe 'File blob', :js do
end
end
- context 'Markdown file' do
- context 'visiting directly' do
+ context "Markdown file" do
+ context "visiting directly" do
before do
- visit_blob('files/markdown/ruby-style-guide.md')
+ visit_blob("files/markdown/ruby-style-guide.md")
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
@@ -64,24 +64,24 @@ describe 'File blob', :js do
expect(page).to have_link("PEP-8")
# shows a viewer switcher
- expect(page).to have_selector('.js-blob-viewer-switcher')
+ expect(page).to have_selector(".js-blob-viewer-switcher")
# shows a disabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
+ expect(page).to have_selector(".js-copy-blob-source-btn.disabled")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
end
end
- context 'switching to the simple viewer' do
+ context "switching to the simple viewer" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=simple]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=simple]").click
wait_for_requests
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
@@ -92,79 +92,79 @@ describe 'File blob', :js do
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
- context 'switching to the rich viewer again' do
+ context "switching to the rich viewer again" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=rich]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=rich]").click
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
end
- context 'visiting with a line number anchor' do
+ context "visiting with a line number anchor" do
before do
- visit_blob('files/markdown/ruby-style-guide.md', anchor: 'L1')
+ visit_blob("files/markdown/ruby-style-guide.md", anchor: "L1")
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false)
# highlights the line in question
- expect(page).to have_selector('#LC1.hll')
+ expect(page).to have_selector("#LC1.hll")
# shows highlighted Markdown code
expect(page).to have_css(".js-syntax-highlight")
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
- context 'Markdown rendering' do
+ context "Markdown rendering" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add RedCarpet and CommonMark Markdown ",
- file_path: 'files/commonmark/file.md',
+ file_path: "files/commonmark/file.md",
file_content: "1. one\n - sublist\n"
).execute
end
- context 'when rendering default markdown' do
+ context "when rendering default markdown" do
before do
- visit_blob('files/commonmark/file.md')
+ visit_blob("files/commonmark/file.md")
wait_for_requests
end
- it 'renders using CommonMark' do
+ it "renders using CommonMark" do
aggregate_failures do
expect(page).to have_content("sublist")
expect(page).not_to have_xpath("//ol//li//ul")
@@ -173,261 +173,261 @@ describe 'File blob', :js do
end
end
- context 'Markdown file (stored in LFS)' do
+ context "Markdown file (stored in LFS)" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add Markdown in LFS",
- file_path: 'files/lfs/file.md',
- file_content: project.repository.blob_at('master', 'files/lfs/lfs_object.iso').data
+ file_path: "files/lfs/file.md",
+ file_content: project.repository.blob_at("master", "files/lfs/lfs_object.iso").data
).execute
end
- context 'when LFS is enabled on the project' do
+ context "when LFS is enabled on the project" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
- visit_blob('files/lfs/file.md')
+ visit_blob("files/lfs/file.md")
wait_for_requests
end
- it 'displays an error' do
+ it "displays an error" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows an error message
- expect(page).to have_content('The rendered file could not be displayed because it is stored in LFS. You can download it instead.')
+ expect(page).to have_content("The rendered file could not be displayed because it is stored in LFS. You can download it instead.")
# shows a viewer switcher
- expect(page).to have_selector('.js-blob-viewer-switcher')
+ expect(page).to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
- context 'switching to the simple viewer' do
+ context "switching to the simple viewer" do
before do
- find('.js-blob-viewer-switcher .js-blob-viewer-switch-btn[data-viewer=simple]').click
+ find(".js-blob-viewer-switcher .js-blob-viewer-switch-btn[data-viewer=simple]").click
wait_for_requests
end
- it 'displays an error' do
+ it "displays an error" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false)
# shows an error message
- expect(page).to have_content('The source could not be displayed because it is stored in LFS. You can download it instead.')
+ expect(page).to have_content("The source could not be displayed because it is stored in LFS. You can download it instead.")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
end
end
end
end
- context 'when LFS is disabled on the project' do
+ context "when LFS is disabled on the project" do
before do
- visit_blob('files/lfs/file.md')
+ visit_blob("files/lfs/file.md")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows text
- expect(page).to have_content('size 1575078')
+ expect(page).to have_content("size 1575078")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
end
end
end
end
- context 'PDF file' do
+ context "PDF file" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add PDF",
- file_path: 'files/test.pdf',
- file_content: project.repository.blob_at('add-pdf-file', 'files/pdf/test.pdf').data
+ file_path: "files/test.pdf",
+ file_content: project.repository.blob_at("add-pdf-file", "files/pdf/test.pdf").data
).execute
- visit_blob('files/test.pdf')
+ visit_blob("files/test.pdf")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows rendered PDF
- expect(page).to have_selector('.js-pdf-viewer')
+ expect(page).to have_selector(".js-pdf-viewer")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'ISO file (stored in LFS)' do
- context 'when LFS is enabled on the project' do
+ context "ISO file (stored in LFS)" do
+ context "when LFS is enabled on the project" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
- visit_blob('files/lfs/lfs_object.iso')
+ visit_blob("files/lfs/lfs_object.iso")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows a download link
- expect(page).to have_link('Download (1.5 MB)')
+ expect(page).to have_link("Download (1.5 MB)")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'when LFS is disabled on the project' do
+ context "when LFS is disabled on the project" do
before do
- visit_blob('files/lfs/lfs_object.iso')
+ visit_blob("files/lfs/lfs_object.iso")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows text
- expect(page).to have_content('size 1575078')
+ expect(page).to have_content("size 1575078")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
end
end
end
end
- context 'ZIP file' do
+ context "ZIP file" do
before do
- visit_blob('Gemfile.zip')
+ visit_blob("Gemfile.zip")
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows a download link
- expect(page).to have_link('Download (2.11 KB)')
+ expect(page).to have_link("Download (2.11 KB)")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'empty file' do
+ context "empty file" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add empty file",
- file_path: 'files/empty.md',
- file_content: ''
+ file_path: "files/empty.md",
+ file_content: ""
).execute
- visit_blob('files/empty.md')
+ visit_blob("files/empty.md")
wait_for_requests
end
- it 'displays an error' do
+ it "displays an error" do
aggregate_failures do
# shows an error message
- expect(page).to have_content('Empty file')
+ expect(page).to have_content("Empty file")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# does not show a copy button
- expect(page).not_to have_selector('.js-copy-blob-source-btn')
+ expect(page).not_to have_selector(".js-copy-blob-source-btn")
# does not show a download or raw button
- expect(page).not_to have_link('Download')
- expect(page).not_to have_link('Open raw')
+ expect(page).not_to have_link("Download")
+ expect(page).not_to have_link("Open raw")
end
end
end
- context 'binary file that appears to be text in the first 1024 bytes' do
+ context "binary file that appears to be text in the first 1024 bytes" do
before do
- visit_blob('encoding/binary-1.bin', ref: 'binary-encoding')
+ visit_blob("encoding/binary-1.bin", ref: "binary-encoding")
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows a download link
- expect(page).to have_link('Download (23.8 KB)')
+ expect(page).to have_link("Download (23.8 KB)")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# The specs below verify an arguably incorrect result, but since we only
# learn that the file is not actually text once the text viewer content
@@ -439,53 +439,53 @@ describe 'File blob', :js do
# as expected.
# shows an enabled copy button, incorrectly
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button, incorrectly
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
end
end
end
- context '.gitlab-ci.yml' do
+ context ".gitlab-ci.yml" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add .gitlab-ci.yml",
- file_path: '.gitlab-ci.yml',
- file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ file_path: ".gitlab-ci.yml",
+ file_content: File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
).execute
- visit_blob('.gitlab-ci.yml')
+ visit_blob(".gitlab-ci.yml")
end
- it 'displays an auxiliary viewer' do
+ it "displays an auxiliary viewer" do
aggregate_failures do
# shows that configuration is valid
- expect(page).to have_content('This GitLab CI configuration is valid.')
+ expect(page).to have_content("This GitLab CI configuration is valid.")
# shows a learn more link
- expect(page).to have_link('Learn more')
+ expect(page).to have_link("Learn more")
end
end
end
- context '.gitlab/route-map.yml' do
+ context ".gitlab/route-map.yml" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add .gitlab/route-map.yml",
- file_path: '.gitlab/route-map.yml',
+ file_path: ".gitlab/route-map.yml",
file_content: <<-MAP.strip_heredoc
# Team data
- source: 'data/team.yml'
@@ -493,47 +493,47 @@ describe 'File blob', :js do
MAP
).execute
- visit_blob('.gitlab/route-map.yml')
+ visit_blob(".gitlab/route-map.yml")
end
- it 'displays an auxiliary viewer' do
+ it "displays an auxiliary viewer" do
aggregate_failures do
# shows that map is valid
- expect(page).to have_content('This Route Map is valid.')
+ expect(page).to have_content("This Route Map is valid.")
# shows a learn more link
- expect(page).to have_link('Learn more')
+ expect(page).to have_link("Learn more")
end
end
end
- context 'LICENSE' do
+ context "LICENSE" do
before do
- visit_blob('LICENSE')
+ visit_blob("LICENSE")
end
- it 'displays an auxiliary viewer' do
+ it "displays an auxiliary viewer" do
aggregate_failures do
# shows license
- expect(page).to have_content('This project is licensed under the MIT License.')
+ expect(page).to have_content("This project is licensed under the MIT License.")
# shows a learn more link
- expect(page).to have_link('Learn more', href: 'http://choosealicense.com/licenses/mit/')
+ expect(page).to have_link("Learn more", href: "http://choosealicense.com/licenses/mit/")
end
end
end
- context '*.gemspec' do
+ context "*.gemspec" do
before do
project.add_maintainer(project.creator)
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add activerecord.gemspec",
- file_path: 'activerecord.gemspec',
+ file_path: "activerecord.gemspec",
file_content: <<-SPEC.strip_heredoc
Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
@@ -542,74 +542,74 @@ describe 'File blob', :js do
SPEC
).execute
- visit_blob('activerecord.gemspec')
+ visit_blob("activerecord.gemspec")
end
- it 'displays an auxiliary viewer' do
+ it "displays an auxiliary viewer" do
aggregate_failures do
# shows names of dependency manager and package
- expect(page).to have_content('This project manages its dependencies using RubyGems and defines a gem named activerecord.')
+ expect(page).to have_content("This project manages its dependencies using RubyGems and defines a gem named activerecord.")
# shows a link to the gem
- expect(page).to have_link('activerecord', href: 'https://rubygems.org/gems/activerecord')
+ expect(page).to have_link("activerecord", href: "https://rubygems.org/gems/activerecord")
# shows a learn more link
- expect(page).to have_link('Learn more', href: 'https://rubygems.org/')
+ expect(page).to have_link("Learn more", href: "https://rubygems.org/")
end
end
end
- context 'realtime pipelines' do
+ context "realtime pipelines" do
before do
Files::CreateService.new(
project,
project.creator,
- start_branch: 'feature',
- branch_name: 'feature',
+ start_branch: "feature",
+ branch_name: "feature",
commit_message: "Add ruby file",
- file_path: 'files/ruby/test.rb',
+ file_path: "files/ruby/test.rb",
file_content: "# Awesome content"
).execute
- create(:ci_pipeline, status: 'running', project: project, ref: 'feature', sha: project.commit('feature').sha)
- visit_blob('files/ruby/test.rb', ref: 'feature')
+ create(:ci_pipeline, status: "running", project: project, ref: "feature", sha: project.commit("feature").sha)
+ visit_blob("files/ruby/test.rb", ref: "feature")
end
- it 'should show the realtime pipeline status' do
- page.within('.commit-actions') do
- expect(page).to have_css('.ci-status-icon')
- expect(page).to have_css('.ci-status-icon-running')
- expect(page).to have_css('.js-ci-status-icon-running')
+ it "should show the realtime pipeline status" do
+ page.within(".commit-actions") do
+ expect(page).to have_css(".ci-status-icon")
+ expect(page).to have_css(".ci-status-icon-running")
+ expect(page).to have_css(".js-ci-status-icon-running")
end
end
end
- context 'for subgroups' do
+ context "for subgroups" do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, :public, :repository, group: subgroup) }
- it 'renders tree table without errors' do
- visit_blob('README.md')
+ it "renders tree table without errors" do
+ visit_blob("README.md")
- expect(page).to have_selector('.file-content')
- expect(page).not_to have_selector('.flash-alert')
+ expect(page).to have_selector(".file-content")
+ expect(page).not_to have_selector(".flash-alert")
end
- it 'displays a GPG badge' do
- visit_blob('CONTRIBUTING.md', ref: '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ it "displays a GPG badge" do
+ visit_blob("CONTRIBUTING.md", ref: "33f3729a45c02fc67d00adb1b8bca394b0e761d9")
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
- context 'on signed merge commit' do
- it 'displays a GPG badge' do
- visit_blob('conflicting-file.md', ref: '6101e87e575de14b38b4e1ce180519a813671e10')
+ context "on signed merge commit" do
+ it "displays a GPG badge" do
+ visit_blob("conflicting-file.md", ref: "6101e87e575de14b38b4e1ce180519a813671e10")
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
end
diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb
index 828f6f9921e..efddbb98025 100644
--- a/spec/features/projects/blobs/edit_spec.rb
+++ b/spec/features/projects/blobs/edit_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Editing file blob', :js do
+describe "Editing file blob", :js do
include TreeHelper
let(:project) { create(:project, :public, :repository) }
- let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master') }
- let(:branch) { 'master' }
+ let(:merge_request) { create(:merge_request, source_project: project, source_branch: "feature", target_branch: "master") }
+ let(:branch) { "master" }
let(:file_path) { project.repository.ls_files(project.repository.root_ref)[1] }
- let(:readme_file_path) { 'README.md' }
+ let(:readme_file_path) { "README.md" }
before do
stub_feature_flags(web_ide_default: false)
end
- context 'as a developer' do
+ context "as a developer" do
let(:user) { create(:user) }
let(:role) { :developer }
@@ -24,61 +24,61 @@ describe 'Editing file blob', :js do
def edit_and_commit(commit_changes: true)
wait_for_requests
- find('.js-edit-blob').click
+ find(".js-edit-blob").click
fill_editor(content: "class NextFeature\\nend\\n")
if commit_changes
- click_button 'Commit changes'
+ click_button "Commit changes"
end
end
def fill_editor(content: "class NextFeature\\nend\\n")
wait_for_requests
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('#{content}')")
end
- context 'from MR diff' do
+ context "from MR diff" do
before do
visit diffs_project_merge_request_path(project, merge_request)
edit_and_commit
end
- it 'returns me to the mr' do
+ it "returns me to the mr" do
expect(page).to have_content(merge_request.title)
end
end
- context 'from blob file path' do
+ context "from blob file path" do
before do
visit project_blob_path(project, tree_join(branch, file_path))
end
- it 'updates content' do
+ it "updates content" do
edit_and_commit
- expect(page).to have_content 'successfully committed'
- expect(page).to have_content 'NextFeature'
+ expect(page).to have_content "successfully committed"
+ expect(page).to have_content "NextFeature"
end
- it 'previews content' do
+ it "previews content" do
edit_and_commit(commit_changes: false)
- click_link 'Preview changes'
+ click_link "Preview changes"
wait_for_requests
- old_line_count = page.all('.line_holder.old').size
- new_line_count = page.all('.line_holder.new').size
+ old_line_count = page.all(".line_holder.old").size
+ new_line_count = page.all(".line_holder.new").size
expect(old_line_count).to be > 0
expect(new_line_count).to be > 0
end
end
- context 'when rendering the preview' do
- it 'renders content with CommonMark' do
+ context "when rendering the preview" do
+ it "renders content with CommonMark" do
visit project_edit_blob_path(project, tree_join(branch, readme_file_path))
fill_editor(content: "1. one\\n - sublist\\n")
- click_link 'Preview'
+ click_link "Preview"
wait_for_requests
# the above generates two separate lists (not embedded) in CommonMark
@@ -88,9 +88,9 @@ describe 'Editing file blob', :js do
end
end
- context 'visit blob edit' do
- context 'redirects to sign in and returns' do
- context 'as developer' do
+ context "visit blob edit" do
+ context "redirects to sign in and returns" do
+ context "as developer" do
let(:user) { create(:user) }
before do
@@ -98,7 +98,7 @@ describe 'Editing file blob', :js do
visit project_edit_blob_path(project, tree_join(branch, file_path))
end
- it 'redirects to sign in and returns' do
+ it "redirects to sign in and returns" do
expect(page).to have_current_path(new_user_session_path)
gitlab_sign_in(user)
@@ -107,14 +107,14 @@ describe 'Editing file blob', :js do
end
end
- context 'as guest' do
+ context "as guest" do
let(:user) { create(:user) }
before do
visit project_edit_blob_path(project, tree_join(branch, file_path))
end
- it 'redirects to sign in and returns' do
+ it "redirects to sign in and returns" do
expect(page).to have_current_path(new_user_session_path)
gitlab_sign_in(user)
@@ -124,40 +124,40 @@ describe 'Editing file blob', :js do
end
end
- context 'as developer' do
+ context "as developer" do
let(:user) { create(:user) }
- let(:protected_branch) { 'protected-branch' }
+ let(:protected_branch) { "protected-branch" }
before do
project.add_developer(user)
- project.repository.add_branch(user, protected_branch, 'master')
+ project.repository.add_branch(user, protected_branch, "master")
create(:protected_branch, project: project, name: protected_branch)
sign_in(user)
end
- context 'on some branch' do
+ context "on some branch" do
before do
visit project_edit_blob_path(project, tree_join(branch, file_path))
end
- it 'shows blob editor with same branch' do
+ it "shows blob editor with same branch" do
expect(page).to have_current_path(project_edit_blob_path(project, tree_join(branch, file_path)))
- expect(find('.js-branch-name').value).to eq(branch)
+ expect(find(".js-branch-name").value).to eq(branch)
end
end
- context 'with protected branch' do
+ context "with protected branch" do
before do
visit project_edit_blob_path(project, tree_join(protected_branch, file_path))
end
- it 'shows blob editor with patch branch' do
- expect(find('.js-branch-name').value).to eq('patch-1')
+ it "shows blob editor with patch branch" do
+ expect(find(".js-branch-name").value).to eq("patch-1")
end
end
end
- context 'as maintainer' do
+ context "as maintainer" do
let(:user) { create(:user) }
before do
@@ -166,9 +166,9 @@ describe 'Editing file blob', :js do
visit project_edit_blob_path(project, tree_join(branch, file_path))
end
- it 'shows blob editor with same branch' do
+ it "shows blob editor with same branch" do
expect(page).to have_current_path(project_edit_blob_path(project, tree_join(branch, file_path)))
- expect(find('.js-branch-name').value).to eq(branch)
+ expect(find(".js-branch-name").value).to eq(branch)
end
end
end
diff --git a/spec/features/projects/blobs/shortcuts_blob_spec.rb b/spec/features/projects/blobs/shortcuts_blob_spec.rb
index 3925de6cfb9..2a28dab9d63 100644
--- a/spec/features/projects/blobs/shortcuts_blob_spec.rb
+++ b/spec/features/projects/blobs/shortcuts_blob_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Blob shortcuts', :js do
+describe "Blob shortcuts", :js do
include TreeHelper
let(:project) { create(:project, :public, :repository) }
let(:path) { project.repository.ls_files(project.repository.root_ref)[0] }
let(:sha) { project.repository.commit.sha }
- describe 'On a file(blob)', :js do
+ describe "On a file(blob)", :js do
def get_absolute_url(path = "")
"http://#{page.server.host}:#{page.server.port}#{path}"
end
def visit_blob(fragment = nil)
- visit project_blob_path(project, tree_join('master', path), anchor: fragment)
+ visit project_blob_path(project, tree_join("master", path), anchor: fragment)
end
describe 'pressing "y"' do
- it 'redirects to permalink with commit sha' do
+ it "redirects to permalink with commit sha" do
visit_blob
wait_for_requests
- find('body').native.send_key('y')
+ find("body").native.send_key("y")
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path))), url: true)
end
- it 'maintains fragment hash when redirecting' do
+ it "maintains fragment hash when redirecting" do
fragment = "L1"
visit_blob(fragment)
wait_for_requests
- find('body').native.send_key('y')
+ find("body").native.send_key("y")
expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)), url: true)
end
diff --git a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb
index 8a0b92190dd..250857d7586 100644
--- a/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb
+++ b/spec/features/projects/blobs/user_creates_new_blob_in_new_project_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User creates blob in new project', :js do
+describe "User creates blob in new project", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :empty_repo) }
- shared_examples 'creating a file' do
+ shared_examples "creating a file" do
before do
sign_in(user)
visit project_path(project)
end
- it 'allows the user to add a new file' do
- click_link 'New file'
+ it "allows the user to add a new file" do
+ click_link "New file"
- find('#editor')
+ find("#editor")
execute_script('ace.edit("editor").setValue("Hello world")')
- fill_in(:file_name, with: 'dummy-file')
+ fill_in(:file_name, with: "dummy-file")
- click_button('Commit changes')
+ click_button("Commit changes")
- expect(page).to have_content('The file has been successfully created')
+ expect(page).to have_content("The file has been successfully created")
end
end
- describe 'as a maintainer' do
+ describe "as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'creating a file'
+ it_behaves_like "creating a file"
end
- describe 'as an admin' do
+ describe "as an admin" do
let(:user) { create(:user, :admin) }
- it_behaves_like 'creating a file'
+ it_behaves_like "creating a file"
end
- describe 'as a developer' do
+ describe "as a developer" do
before do
project.add_developer(user)
sign_in(user)
visit project_path(project)
end
- it 'does not allow pushing to the default branch' do
- expect(page).not_to have_content('New file')
+ it "does not allow pushing to the default branch" do
+ expect(page).not_to have_content("New file")
end
end
end
diff --git a/spec/features/projects/branches/download_buttons_spec.rb b/spec/features/projects/branches/download_buttons_spec.rb
index c8dc72a34ec..f189789cf48 100644
--- a/spec/features/projects/branches/download_buttons_spec.rb
+++ b/spec/features/projects/branches/download_buttons_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Download buttons in branches page' do
+describe "Download buttons in branches page" do
let(:user) { create(:user) }
let(:role) { :developer }
- let(:status) { 'success' }
+ let(:status) { "success" }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit('binary-encoding').sha,
- ref: 'binary-encoding', # make sure the branch is in the 1st page!
- status: status)
+ project: project,
+ sha: project.commit("binary-encoding").sha,
+ ref: "binary-encoding", # make sure the branch is in the 1st page!
+ status: status)
end
let!(:build) do
create(:ci_build, :success, :artifacts,
- pipeline: pipeline,
- status: pipeline.status,
- name: 'build')
+ pipeline: pipeline,
+ status: pipeline.status,
+ name: "build")
end
before do
@@ -26,14 +26,14 @@ describe 'Download buttons in branches page' do
project.add_role(user, role)
end
- describe 'when checking branches' do
- context 'with artifacts' do
+ describe "when checking branches" do
+ context "with artifacts" do
before do
- visit project_branches_filtered_path(project, state: 'all', search: 'binary-encoding')
+ visit project_branches_filtered_path(project, state: "all", search: "binary-encoding")
end
- it 'shows download artifacts button' do
- href = latest_succeeded_project_artifacts_path(project, 'binary-encoding/download', job: 'build')
+ it "shows download artifacts button" do
+ href = latest_succeeded_project_artifacts_path(project, "binary-encoding/download", job: "build")
expect(page).to have_link "Download '#{build.name}'", href: href
end
diff --git a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
index 0faf73db7da..ab912da5798 100644
--- a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
+++ b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'New Branch Ref Dropdown', :js do
+describe "New Branch Ref Dropdown", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
- let(:toggle) { find('.create-from .dropdown-menu-toggle') }
+ let(:toggle) { find(".create-from .dropdown-menu-toggle") }
before do
project.add_maintainer(user)
@@ -12,37 +12,37 @@ describe 'New Branch Ref Dropdown', :js do
visit new_project_branch_path(project)
end
- it 'filters a list of branches and tags' do
+ it "filters a list of branches and tags" do
toggle.click
- filter_by('v1.0.0')
+ filter_by("v1.0.0")
expect(items_count).to be(1)
- filter_by('video')
+ filter_by("video")
expect(items_count).to be(1)
- find('.create-from .dropdown-content li').click
+ find(".create-from .dropdown-content li").click
- expect(toggle).to have_content 'video'
+ expect(toggle).to have_content "video"
end
- it 'accepts a manually entered commit SHA' do
+ it "accepts a manually entered commit SHA" do
toggle.click
- filter_by('somecommitsha')
+ filter_by("somecommitsha")
- find('.create-from input[type=search]').send_keys(:enter)
+ find(".create-from input[type=search]").send_keys(:enter)
- expect(toggle).to have_content 'somecommitsha'
+ expect(toggle).to have_content "somecommitsha"
end
def items_count
- all('.create-from .dropdown-content li').length
+ all(".create-from .dropdown-content li").length
end
def filter_by(filter_text)
- fill_in 'Filter by Git revision', with: filter_text
+ fill_in "Filter by Git revision", with: filter_text
end
end
diff --git a/spec/features/projects/branches/user_views_branches_spec.rb b/spec/features/projects/branches/user_views_branches_spec.rb
index 777d30fdffd..1ba3477edd8 100644
--- a/spec/features/projects/branches/user_views_branches_spec.rb
+++ b/spec/features/projects/branches/user_views_branches_spec.rb
@@ -16,7 +16,7 @@ describe "User views branches" do
it "shows branches" do
expect(page).to have_content("Branches").and have_content("master")
- expect(page.all(".graph-side")).to all( have_content(/\d+/) )
+ expect(page.all(".graph-side")).to all(have_content(/\d+/))
end
end
diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb
index ee71c843b80..de3ac248faf 100644
--- a/spec/features/projects/branches_spec.rb
+++ b/spec/features/projects/branches_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Branches' do
+describe "Branches" do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:repository) { project.repository }
- context 'logged in as developer' do
+ context "logged in as developer" do
before do
sign_in(user)
project.add_developer(user)
end
- context 'on the projects with 6 active branches and 4 stale branches' do
+ context "on the projects with 6 active branches and 4 stale branches" do
let(:project) { create(:project, :public, :empty_repo) }
let(:repository) { project.repository }
let(:threshold) { Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD }
@@ -27,93 +27,93 @@ describe 'Branches' do
end
end
- describe 'Overview page of the branches' do
- it 'shows the first 5 active branches and the first 4 stale branches sorted by last updated' do
+ describe "Overview page of the branches" do
+ it "shows the first 5 active branches and the first 4 stale branches sorted by last updated" do
visit project_branches_path(project)
- expect(page).to have_content(sorted_branches(repository, count: 5, sort_by: :updated_desc, state: 'active'))
- expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: 'stale'))
+ expect(page).to have_content(sorted_branches(repository, count: 5, sort_by: :updated_desc, state: "active"))
+ expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: "stale"))
- expect(page).to have_link('Show more active branches', href: project_branches_filtered_path(project, state: 'active'))
- expect(page).not_to have_content('Show more stale branches')
+ expect(page).to have_link("Show more active branches", href: project_branches_filtered_path(project, state: "active"))
+ expect(page).not_to have_content("Show more stale branches")
end
end
- describe 'Active branches page' do
- it 'shows 6 active branches sorted by last updated' do
- visit project_branches_filtered_path(project, state: 'active')
+ describe "Active branches page" do
+ it "shows 6 active branches sorted by last updated" do
+ visit project_branches_filtered_path(project, state: "active")
- expect(page).to have_content(sorted_branches(repository, count: 6, sort_by: :updated_desc, state: 'active'))
+ expect(page).to have_content(sorted_branches(repository, count: 6, sort_by: :updated_desc, state: "active"))
end
end
- describe 'Stale branches page' do
- it 'shows 4 active branches sorted by last updated' do
- visit project_branches_filtered_path(project, state: 'stale')
+ describe "Stale branches page" do
+ it "shows 4 active branches sorted by last updated" do
+ visit project_branches_filtered_path(project, state: "stale")
- expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: 'stale'))
+ expect(page).to have_content(sorted_branches(repository, count: 4, sort_by: :updated_desc, state: "stale"))
end
end
- describe 'All branches page' do
- it 'shows 10 branches sorted by last updated' do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "All branches page" do
+ it "shows 10 branches sorted by last updated" do
+ visit project_branches_filtered_path(project, state: "all")
expect(page).to have_content(sorted_branches(repository, count: 10, sort_by: :updated_desc))
end
end
- context 'with branches over more than one page' do
+ context "with branches over more than one page" do
before do
allow(Kaminari.config).to receive(:default_per_page).and_return(5)
end
- it 'shows only default_per_page active branches sorted by last updated' do
- visit project_branches_filtered_path(project, state: 'active')
+ it "shows only default_per_page active branches sorted by last updated" do
+ visit project_branches_filtered_path(project, state: "active")
- expect(page).to have_content(sorted_branches(repository, count: Kaminari.config.default_per_page, sort_by: :updated_desc, state: 'active'))
+ expect(page).to have_content(sorted_branches(repository, count: Kaminari.config.default_per_page, sort_by: :updated_desc, state: "active"))
end
- it 'shows only default_per_page branches sorted by last updated on All branches' do
- visit project_branches_filtered_path(project, state: 'all')
+ it "shows only default_per_page branches sorted by last updated on All branches" do
+ visit project_branches_filtered_path(project, state: "all")
expect(page).to have_content(sorted_branches(repository, count: Kaminari.config.default_per_page, sort_by: :updated_desc))
end
end
end
- describe 'Find branches' do
- it 'shows filtered branches', :js do
+ describe "Find branches" do
+ it "shows filtered branches", :js do
visit project_branches_path(project)
- fill_in 'branch-search', with: 'fix'
- find('#branch-search').native.send_keys(:enter)
+ fill_in "branch-search", with: "fix"
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_content('fix')
- expect(find('.all-branches')).to have_selector('li', count: 1)
+ expect(page).to have_content("fix")
+ expect(find(".all-branches")).to have_selector("li", count: 1)
end
end
- describe 'Delete unprotected branch on Overview' do
- it 'removes branch after confirmation', :js do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "Delete unprotected branch on Overview" do
+ it "removes branch after confirmation", :js do
+ visit project_branches_filtered_path(project, state: "all")
- expect(all('.all-branches').last).to have_selector('li', count: 20)
- accept_confirm { find('.js-branch-add-pdf-text-binary .btn-remove').click }
+ expect(all(".all-branches").last).to have_selector("li", count: 20)
+ accept_confirm { find(".js-branch-add-pdf-text-binary .btn-remove").click }
- expect(all('.all-branches').last).to have_selector('li', count: 19)
+ expect(all(".all-branches").last).to have_selector("li", count: 19)
end
end
- describe 'All branches page' do
- it 'shows all the branches sorted by last updated by default' do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "All branches page" do
+ it "shows all the branches sorted by last updated by default" do
+ visit project_branches_filtered_path(project, state: "all")
expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :updated_desc))
end
- it 'sorts the branches by name' do
- visit project_branches_filtered_path(project, state: 'all')
+ it "sorts the branches by name" do
+ visit project_branches_filtered_path(project, state: "all")
click_button "Last updated" # Open sorting dropdown
click_link "Name"
@@ -121,8 +121,8 @@ describe 'Branches' do
expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :name))
end
- it 'sorts the branches by oldest updated' do
- visit project_branches_filtered_path(project, state: 'all')
+ it "sorts the branches by oldest updated" do
+ visit project_branches_filtered_path(project, state: "all")
click_button "Last updated" # Open sorting dropdown
click_link "Oldest updated"
@@ -130,149 +130,149 @@ describe 'Branches' do
expect(page).to have_content(sorted_branches(repository, count: 20, sort_by: :updated_asc))
end
- it 'avoids a N+1 query in branches index' do
+ it "avoids a N+1 query in branches index" do
control_count = ActiveRecord::QueryRecorder.new { visit project_branches_path(project) }.count
- %w(one two three four five).each { |ref| repository.add_branch(user, ref, 'master') }
+ %w[one two three four five].each { |ref| repository.add_branch(user, ref, "master") }
- expect { visit project_branches_filtered_path(project, state: 'all') }.not_to exceed_query_limit(control_count)
+ expect { visit project_branches_filtered_path(project, state: "all") }.not_to exceed_query_limit(control_count)
end
end
- describe 'Find branches on All branches' do
- it 'shows filtered branches', :js do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "Find branches on All branches" do
+ it "shows filtered branches", :js do
+ visit project_branches_filtered_path(project, state: "all")
- fill_in 'branch-search', with: 'fix'
- find('#branch-search').native.send_keys(:enter)
+ fill_in "branch-search", with: "fix"
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_content('fix')
- expect(find('.all-branches')).to have_selector('li', count: 1)
+ expect(page).to have_content("fix")
+ expect(find(".all-branches")).to have_selector("li", count: 1)
end
end
- describe 'Delete unprotected branch on All branches' do
- it 'removes branch after confirmation', :js do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "Delete unprotected branch on All branches" do
+ it "removes branch after confirmation", :js do
+ visit project_branches_filtered_path(project, state: "all")
- fill_in 'branch-search', with: 'fix'
+ fill_in "branch-search", with: "fix"
- find('#branch-search').native.send_keys(:enter)
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_content('fix')
- expect(find('.all-branches')).to have_selector('li', count: 1)
- accept_confirm { find('.js-branch-fix .btn-remove').click }
+ expect(page).to have_content("fix")
+ expect(find(".all-branches")).to have_selector("li", count: 1)
+ accept_confirm { find(".js-branch-fix .btn-remove").click }
- expect(page).not_to have_content('fix')
- expect(find('.all-branches')).to have_selector('li', count: 0)
+ expect(page).not_to have_content("fix")
+ expect(find(".all-branches")).to have_selector("li", count: 0)
end
end
- context 'on project with 0 branch' do
+ context "on project with 0 branch" do
let(:project) { create(:project, :public, :empty_repo) }
let(:repository) { project.repository }
- describe '0 branches on Overview' do
- it 'shows warning' do
+ describe "0 branches on Overview" do
+ it "shows warning" do
visit project_branches_path(project)
- expect(page).not_to have_selector('.all-branches')
+ expect(page).not_to have_selector(".all-branches")
end
end
end
end
- context 'logged in as maintainer' do
+ context "logged in as maintainer" do
before do
sign_in(user)
project.add_maintainer(user)
end
- describe 'Initial branches page' do
- it 'shows description for admin' do
- visit project_branches_filtered_path(project, state: 'all')
+ describe "Initial branches page" do
+ it "shows description for admin" do
+ visit project_branches_filtered_path(project, state: "all")
expect(page).to have_content("Protected branches can be managed in project settings")
end
end
- it 'shows the merge request button' do
+ it "shows the merge request button" do
visit project_branches_path(project)
- page.within first('.all-branches li') do
- expect(page).to have_content 'Merge request'
+ page.within first(".all-branches li") do
+ expect(page).to have_content "Merge request"
end
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :public, :repository, :archived) }
- it 'does not show the merge request button when the project is archived' do
+ it "does not show the merge request button when the project is archived" do
visit project_branches_path(project)
- page.within first('.all-branches li') do
- expect(page).not_to have_content 'Merge request'
+ page.within first(".all-branches li") do
+ expect(page).not_to have_content "Merge request"
end
end
end
end
- context 'logged out' do
+ context "logged out" do
before do
visit project_branches_path(project)
end
- it 'does not show merge request button' do
- page.within first('.all-branches li') do
- expect(page).not_to have_content 'Merge request'
+ it "does not show merge request button" do
+ page.within first(".all-branches li") do
+ expect(page).not_to have_content "Merge request"
end
end
end
- describe 'comparing branches' do
+ describe "comparing branches" do
before do
sign_in(user)
project.add_developer(user)
end
- shared_examples 'compares branches' do
- it 'compares branches' do
+ shared_examples "compares branches" do
+ it "compares branches" do
visit project_branches_path(project)
- page.within first('.all-branches li') do
- click_link 'Compare'
+ page.within first(".all-branches li") do
+ click_link "Compare"
end
- expect(page).to have_content 'Commits'
- expect(page).to have_link 'Create merge request'
+ expect(page).to have_content "Commits"
+ expect(page).to have_link "Create merge request"
end
end
- context 'on a read-only instance' do
+ context "on a read-only instance" do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
- it_behaves_like 'compares branches'
+ it_behaves_like "compares branches"
end
- context 'on a read-write instance' do
- it_behaves_like 'compares branches'
+ context "on a read-write instance" do
+ it_behaves_like "compares branches"
end
end
def sorted_branches(repository, count:, sort_by:, state: nil)
branches = repository.branches_sorted_by(sort_by)
- branches = branches.select { |b| state == 'active' ? b.active? : b.stale? } if state
+ branches = branches.select { |b| state == "active" ? b.active? : b.stale? } if state
sorted_branches =
- branches.first(count).map do |branch|
+ branches.first(count).map { |branch|
Regexp.escape(branch.name)
- end
+ }
- Regexp.new(sorted_branches.join('.*'))
+ Regexp.new(sorted_branches.join(".*"))
end
- def create_file(message: 'message', branch_name:)
- repository.create_file(user, generate(:branch), 'content', message: message, branch_name: branch_name)
+ def create_file(message: "message", branch_name:)
+ repository.create_file(user, generate(:branch), "content", message: message, branch_name: branch_name)
end
end
diff --git a/spec/features/projects/ci/lint_spec.rb b/spec/features/projects/ci/lint_spec.rb
index 313950072e7..4a0bcb452ed 100644
--- a/spec/features/projects/ci/lint_spec.rb
+++ b/spec/features/projects/ci/lint_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CI Lint', :js do
+describe "CI Lint", :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -9,65 +9,65 @@ describe 'CI Lint', :js do
sign_in(user)
visit project_ci_lint_path(project)
- find('#ci-editor')
+ find("#ci-editor")
execute_script("ace.edit('ci-editor').setValue(#{yaml_content.to_json});")
# Ace editor updates a hidden textarea and it happens asynchronously
- wait_for('YAML content') do
- find('.ace_content').text.present?
+ wait_for("YAML content") do
+ find(".ace_content").text.present?
end
end
- describe 'YAML parsing' do
+ describe "YAML parsing" do
before do
- click_on 'Validate'
+ click_on "Validate"
end
- context 'YAML is correct' do
+ context "YAML is correct" do
let(:yaml_content) do
- File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
end
- it 'parses Yaml' do
+ it "parses Yaml" do
within "table" do
- expect(page).to have_content('Job - rspec')
- expect(page).to have_content('Job - spinach')
- expect(page).to have_content('Deploy Job - staging')
- expect(page).to have_content('Deploy Job - production')
+ expect(page).to have_content("Job - rspec")
+ expect(page).to have_content("Job - spinach")
+ expect(page).to have_content("Deploy Job - staging")
+ expect(page).to have_content("Deploy Job - production")
end
end
end
- context 'YAML is incorrect' do
- let(:yaml_content) { 'value: cannot have :' }
+ context "YAML is incorrect" do
+ let(:yaml_content) { "value: cannot have :" }
- it 'displays information about an error' do
- expect(page).to have_content('Status: syntax is incorrect')
- expect(page).to have_selector('.ace_content', text: yaml_content)
+ it "displays information about an error" do
+ expect(page).to have_content("Status: syntax is incorrect")
+ expect(page).to have_selector(".ace_content", text: yaml_content)
end
end
- describe 'YAML revalidate' do
- let(:yaml_content) { 'my yaml content' }
+ describe "YAML revalidate" do
+ let(:yaml_content) { "my yaml content" }
- it 'loads previous YAML content after validation' do
- expect(page).to have_field('content', with: 'my yaml content', visible: false, type: 'textarea')
+ it "loads previous YAML content after validation" do
+ expect(page).to have_field("content", with: "my yaml content", visible: false, type: "textarea")
end
end
end
- describe 'YAML clearing' do
+ describe "YAML clearing" do
before do
- click_on 'Clear'
+ click_on "Clear"
end
- context 'YAML is present' do
+ context "YAML is present" do
let(:yaml_content) do
- File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
end
- it 'YAML content is cleared' do
- expect(page).to have_field('content', with: '', visible: false, type: 'textarea')
+ it "YAML content is cleared" do
+ expect(page).to have_field("content", with: "", visible: false, type: "textarea")
end
end
end
diff --git a/spec/features/projects/clusters/applications_spec.rb b/spec/features/projects/clusters/applications_spec.rb
index 2c8d014c36d..7b06166e5c4 100644
--- a/spec/features/projects/clusters/applications_spec.rb
+++ b/spec/features/projects/clusters/applications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Clusters Applications', :js do
+describe "Clusters Applications", :js do
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) }
@@ -11,94 +11,94 @@ describe 'Clusters Applications', :js do
sign_in(user)
end
- describe 'Installing applications' do
+ describe "Installing applications" do
before do
visit project_cluster_path(project, cluster)
end
- context 'when cluster is being created' do
+ context "when cluster is being created" do
let(:cluster) { create(:cluster, :providing_by_gcp, projects: [project])}
- it 'user is unable to install applications' do
- page.within('.js-cluster-application-row-helm') do
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
+ it "user is unable to install applications" do
+ page.within(".js-cluster-application-row-helm") do
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to eq("true")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Install")
end
end
end
- context 'when cluster is created' do
+ context "when cluster is created" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])}
- it 'user can install applications' do
- page.within('.js-cluster-application-row-helm') do
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to be_nil
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Install')
+ it "user can install applications" do
+ page.within(".js-cluster-application-row-helm") do
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to be_nil
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Install")
end
end
- context 'when user installs Helm' do
+ context "when user installs Helm" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
- page.within('.js-cluster-application-row-helm') do
- page.find(:css, '.js-cluster-application-install-button').click
+ page.within(".js-cluster-application-row-helm") do
+ page.find(:css, ".js-cluster-application-install-button").click
end
end
- it 'they see status transition' do
- page.within('.js-cluster-application-row-helm') do
+ it "they see status transition" do
+ page.within(".js-cluster-application-row-helm") do
# FE sends request and gets the response, then the buttons is "Installing"
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to eq("true")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
wait_until_helm_created!
Clusters::Cluster.last.application_helm.make_installing!
# FE starts polling and update the buttons to "Installing"
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to eq("true")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
Clusters::Cluster.last.application_helm.make_installed!
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed')
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to eq("true")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installed")
end
- expect(page).to have_content('Helm Tiller was successfully installed on your Kubernetes cluster')
+ expect(page).to have_content("Helm Tiller was successfully installed on your Kubernetes cluster")
end
end
- context 'when user installs Knative' do
+ context "when user installs Knative" do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
- context 'on an abac cluster' do
+ context "on an abac cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :rbac_disabled, projects: [project])}
- it 'should show info block and not be installable' do
- page.within('.js-cluster-application-row-knative') do
- expect(page).to have_css('.bs-callout-info')
- expect(page.find(:css, '.js-cluster-application-install-button')['disabled']).to eq('true')
+ it "should show info block and not be installable" do
+ page.within(".js-cluster-application-row-knative") do
+ expect(page).to have_css(".bs-callout-info")
+ expect(page.find(:css, ".js-cluster-application-install-button")["disabled"]).to eq("true")
end
end
end
- context 'on an rbac cluster' do
+ context "on an rbac cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project])}
- it 'should not show callout block and be installable' do
- page.within('.js-cluster-application-row-knative') do
- expect(page).not_to have_css('.bs-callout-info')
- expect(page).to have_css('.js-cluster-application-install-button:not([disabled])')
+ it "should not show callout block and be installable" do
+ page.within(".js-cluster-application-row-knative") do
+ expect(page).not_to have_css(".bs-callout-info")
+ expect(page).to have_css(".js-cluster-application-install-button:not([disabled])")
end
end
end
end
- context 'when user installs Cert Manager' do
+ context "when user installs Cert Manager" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
@@ -106,38 +106,38 @@ describe 'Clusters Applications', :js do
create(:clusters_applications_helm, :installed, cluster: cluster)
- page.within('.js-cluster-application-row-cert_manager') do
- click_button 'Install'
+ page.within(".js-cluster-application-row-cert_manager") do
+ click_button "Install"
end
end
- it 'shows status transition' do
+ it "shows status transition" do
def email_form_value
- page.find('.js-email').value
+ page.find(".js-email").value
end
- page.within('.js-cluster-application-row-cert_manager') do
+ page.within(".js-cluster-application-row-cert_manager") do
expect(email_form_value).to eq(cluster.user.email)
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
- page.find('.js-email').set("new_email@example.org")
+ page.find(".js-email").set("new_email@example.org")
Clusters::Cluster.last.application_cert_manager.make_installing!
- expect(email_form_value).to eq('new_email@example.org')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
+ expect(email_form_value).to eq("new_email@example.org")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
Clusters::Cluster.last.application_cert_manager.make_installed!
- expect(email_form_value).to eq('new_email@example.org')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed')
+ expect(email_form_value).to eq("new_email@example.org")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installed")
end
- expect(page).to have_content('Cert-Manager was successfully installed on your Kubernetes cluster')
+ expect(page).to have_content("Cert-Manager was successfully installed on your Kubernetes cluster")
end
end
- context 'when user installs Ingress' do
- context 'when user installs application: Ingress' do
+ context "when user installs Ingress" do
+ context "when user installs application: Ingress" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
@@ -145,40 +145,40 @@ describe 'Clusters Applications', :js do
create(:clusters_applications_helm, :installed, cluster: cluster)
- page.within('.js-cluster-application-row-ingress') do
- expect(page).to have_css('.js-cluster-application-install-button:not([disabled])')
- page.find(:css, '.js-cluster-application-install-button').click
+ page.within(".js-cluster-application-row-ingress") do
+ expect(page).to have_css(".js-cluster-application-install-button:not([disabled])")
+ page.find(:css, ".js-cluster-application-install-button").click
end
end
- it 'they see status transition' do
- page.within('.js-cluster-application-row-ingress') do
+ it "they see status transition" do
+ page.within(".js-cluster-application-row-ingress") do
# FE sends request and gets the response, then the buttons is "Installing"
- expect(page).to have_css('.js-cluster-application-install-button[disabled]')
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
+ expect(page).to have_css(".js-cluster-application-install-button[disabled]")
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
Clusters::Cluster.last.application_ingress.make_installing!
# FE starts polling and update the buttons to "Installing"
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installing')
- expect(page).to have_css('.js-cluster-application-install-button[disabled]')
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installing")
+ expect(page).to have_css(".js-cluster-application-install-button[disabled]")
# The application becomes installed but we keep waiting for external IP address
Clusters::Cluster.last.application_ingress.make_installed!
- expect(page).to have_css('.js-cluster-application-install-button', exact_text: 'Installed')
- expect(page).to have_css('.js-cluster-application-install-button[disabled]')
- expect(page).to have_selector('.js-no-ip-message')
- expect(page.find('.js-ip-address').value).to eq('?')
+ expect(page).to have_css(".js-cluster-application-install-button", exact_text: "Installed")
+ expect(page).to have_css(".js-cluster-application-install-button[disabled]")
+ expect(page).to have_selector(".js-no-ip-message")
+ expect(page.find(".js-ip-address").value).to eq("?")
# We receive the external IP address and display
- Clusters::Cluster.last.application_ingress.update!(external_ip: '192.168.1.100')
+ Clusters::Cluster.last.application_ingress.update!(external_ip: "192.168.1.100")
- expect(page).not_to have_selector('.js-no-ip-message')
- expect(page.find('.js-ip-address').value).to eq('192.168.1.100')
+ expect(page).not_to have_selector(".js-no-ip-message")
+ expect(page.find(".js-ip-address").value).to eq("192.168.1.100")
end
- expect(page).to have_content('Ingress was successfully installed on your Kubernetes cluster')
+ expect(page).to have_content("Ingress was successfully installed on your Kubernetes cluster")
end
end
end
diff --git a/spec/features/projects/clusters/gcp_spec.rb b/spec/features/projects/clusters/gcp_spec.rb
index 9322e29d744..a916299a925 100644
--- a/spec/features/projects/clusters/gcp_spec.rb
+++ b/spec/features/projects/clusters/gcp_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Gcp Cluster', :js do
+describe "Gcp Cluster", :js do
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) }
@@ -12,33 +12,33 @@ describe 'Gcp Cluster', :js do
allow(Projects::ClustersController).to receive(:STATUS_POLLING_INTERVAL) { 100 }
end
- context 'when user has signed with Google' do
- let(:project_id) { 'test-project-1234' }
+ context "when user has signed with Google" do
+ let(:project_id) { "test-project-1234" }
before do
allow_any_instance_of(Projects::ClustersController)
- .to receive(:token_in_session).and_return('token')
+ .to receive(:token_in_session).and_return("token")
allow_any_instance_of(Projects::ClustersController)
.to receive(:expires_at_in_session).and_return(1.hour.since.to_i.to_s)
end
- context 'when user does not have a cluster and visits cluster index page' do
+ context "when user does not have a cluster and visits cluster index page" do
before do
visit project_clusters_path(project)
- click_link 'Add Kubernetes cluster'
- click_link 'Create new Cluster on GKE'
+ click_link "Add Kubernetes cluster"
+ click_link "Create new Cluster on GKE"
end
- context 'when user filled form with valid parameters' do
- subject { click_button 'Create Kubernetes cluster' }
+ context "when user filled form with valid parameters" do
+ subject { click_button "Create Kubernetes cluster" }
before do
allow_any_instance_of(GoogleApi::CloudPlatform::Client)
.to receive(:projects_zones_clusters_create) do
OpenStruct.new(
- self_link: 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123',
- status: 'RUNNING'
+ self_link: "projects/gcp-project-12345/zones/us-central1-a/operations/ope-123",
+ status: "RUNNING"
)
end
@@ -50,168 +50,168 @@ describe 'Gcp Cluster', :js do
execute_script('document.querySelector(".js-gcp-zone-dropdown input").setAttribute("type", "text")')
execute_script('document.querySelector(".js-gcp-machine-type-dropdown input").setAttribute("type", "text")')
- fill_in 'cluster[name]', with: 'dev-cluster'
- fill_in 'cluster[provider_gcp_attributes][gcp_project_id]', with: 'gcp-project-123'
- fill_in 'cluster[provider_gcp_attributes][zone]', with: 'us-central1-a'
- fill_in 'cluster[provider_gcp_attributes][machine_type]', with: 'n1-standard-2'
+ fill_in "cluster[name]", with: "dev-cluster"
+ fill_in "cluster[provider_gcp_attributes][gcp_project_id]", with: "gcp-project-123"
+ fill_in "cluster[provider_gcp_attributes][zone]", with: "us-central1-a"
+ fill_in "cluster[provider_gcp_attributes][machine_type]", with: "n1-standard-2"
end
- it 'users sees a form with the GCP token' do
+ it "users sees a form with the GCP token" do
expect(page).to have_selector(:css, 'form[data-token="token"]')
end
- it 'user sees a cluster details page and creation status' do
+ it "user sees a cluster details page and creation status" do
subject
- expect(page).to have_content('Kubernetes cluster is being created on Google Kubernetes Engine...')
+ expect(page).to have_content("Kubernetes cluster is being created on Google Kubernetes Engine...")
Clusters::Cluster.last.provider.make_created!
- expect(page).to have_content('Kubernetes cluster was successfully created on Google Kubernetes Engine')
+ expect(page).to have_content("Kubernetes cluster was successfully created on Google Kubernetes Engine")
end
- it 'user sees a error if something wrong during creation' do
+ it "user sees a error if something wrong during creation" do
subject
- expect(page).to have_content('Kubernetes cluster is being created on Google Kubernetes Engine...')
+ expect(page).to have_content("Kubernetes cluster is being created on Google Kubernetes Engine...")
- Clusters::Cluster.last.provider.make_errored!('Something wrong!')
+ Clusters::Cluster.last.provider.make_errored!("Something wrong!")
- expect(page).to have_content('Something wrong!')
+ expect(page).to have_content("Something wrong!")
end
- it 'user sees RBAC is enabled by default' do
- expect(page).to have_checked_field('RBAC-enabled cluster')
+ it "user sees RBAC is enabled by default" do
+ expect(page).to have_checked_field("RBAC-enabled cluster")
end
end
- context 'when user filled form with invalid parameters' do
+ context "when user filled form with invalid parameters" do
before do
execute_script('document.querySelector(".js-gke-cluster-creation-submit").removeAttribute("disabled")')
- click_button 'Create Kubernetes cluster'
+ click_button "Create Kubernetes cluster"
end
- it 'user sees a validation error' do
- expect(page).to have_css('#error_explanation')
+ it "user sees a validation error" do
+ expect(page).to have_css("#error_explanation")
end
end
end
- context 'when user does have a cluster and visits cluster page' do
+ context "when user does have a cluster and visits cluster page" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
before do
visit project_cluster_path(project, cluster)
end
- it 'user sees a cluster details page' do
- expect(page).to have_button('Save changes')
- expect(page.find(:css, '.cluster-name').value).to eq(cluster.name)
+ it "user sees a cluster details page" do
+ expect(page).to have_button("Save changes")
+ expect(page.find(:css, ".cluster-name").value).to eq(cluster.name)
end
- context 'when user disables the cluster' do
+ context "when user disables the cluster" do
before do
- page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
- page.within('#cluster-integration') { click_button 'Save changes' }
+ page.find(:css, ".js-cluster-enable-toggle-area .js-project-feature-toggle").click
+ page.within("#cluster-integration") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
end
end
- context 'when user changes cluster parameters' do
+ context "when user changes cluster parameters" do
before do
allow(ClusterConfigureWorker).to receive(:perform_async)
- fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
- page.within('#js-cluster-details') { click_button 'Save changes' }
+ fill_in "cluster_platform_kubernetes_attributes_namespace", with: "my-namespace"
+ page.within("#js-cluster-details") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
- expect(cluster.reload.platform_kubernetes.namespace).to eq('my-namespace')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
+ expect(cluster.reload.platform_kubernetes.namespace).to eq("my-namespace")
end
end
- context 'when user destroy the cluster' do
+ context "when user destroy the cluster" do
before do
page.accept_confirm do
- click_link 'Remove integration'
+ click_link "Remove integration"
end
end
- it 'user sees creation form with the successful message' do
- expect(page).to have_content('Kubernetes cluster integration was successfully removed.')
- expect(page).to have_link('Add Kubernetes cluster')
+ it "user sees creation form with the successful message" do
+ expect(page).to have_content("Kubernetes cluster integration was successfully removed.")
+ expect(page).to have_link("Add Kubernetes cluster")
end
end
end
end
- context 'when user has not signed with Google' do
+ context "when user has not signed with Google" do
before do
visit project_clusters_path(project)
- click_link 'Add Kubernetes cluster'
- click_link 'Create new Cluster on GKE'
+ click_link "Add Kubernetes cluster"
+ click_link "Create new Cluster on GKE"
end
- it 'user sees a login page' do
- expect(page).to have_css('.signin-with-google')
- expect(page).to have_link('Google account')
+ it "user sees a login page" do
+ expect(page).to have_css(".signin-with-google")
+ expect(page).to have_link("Google account")
end
end
- context 'when a user cannot edit the environment scope' do
+ context "when a user cannot edit the environment scope" do
before do
visit project_clusters_path(project)
- click_link 'Add Kubernetes cluster'
- click_link 'Add existing cluster'
+ click_link "Add Kubernetes cluster"
+ click_link "Add existing cluster"
end
it 'user does not see the "Environment scope" field' do
- expect(page).not_to have_css('#cluster_environment_scope')
+ expect(page).not_to have_css("#cluster_environment_scope")
end
end
- context 'when user has not dismissed GCP signup offer' do
+ context "when user has not dismissed GCP signup offer" do
before do
visit project_clusters_path(project)
end
- it 'user sees offer on cluster index page' do
- expect(page).to have_css('.gcp-signup-offer')
+ it "user sees offer on cluster index page" do
+ expect(page).to have_css(".gcp-signup-offer")
end
- it 'user sees offer on cluster create page' do
- click_link 'Add Kubernetes cluster'
+ it "user sees offer on cluster create page" do
+ click_link "Add Kubernetes cluster"
- expect(page).to have_css('.gcp-signup-offer')
+ expect(page).to have_css(".gcp-signup-offer")
end
- it 'user sees offer on cluster GCP login page' do
- click_link 'Add Kubernetes cluster'
- click_link 'Create new Cluster on GKE'
+ it "user sees offer on cluster GCP login page" do
+ click_link "Add Kubernetes cluster"
+ click_link "Create new Cluster on GKE"
- expect(page).to have_css('.gcp-signup-offer')
+ expect(page).to have_css(".gcp-signup-offer")
end
end
- context 'when user has dismissed GCP signup offer' do
+ context "when user has dismissed GCP signup offer" do
before do
visit project_clusters_path(project)
end
- it 'user does not see offer after dismissing' do
- expect(page).to have_css('.gcp-signup-offer')
+ it "user does not see offer after dismissing" do
+ expect(page).to have_css(".gcp-signup-offer")
- find('.gcp-signup-offer .close').click
+ find(".gcp-signup-offer .close").click
wait_for_requests
- click_link 'Add Kubernetes cluster'
+ click_link "Add Kubernetes cluster"
- expect(page).not_to have_css('.gcp-signup-offer')
+ expect(page).not_to have_css(".gcp-signup-offer")
end
end
end
diff --git a/spec/features/projects/clusters/interchangeability_spec.rb b/spec/features/projects/clusters/interchangeability_spec.rb
index 0033e12b6b1..9264c61924c 100644
--- a/spec/features/projects/clusters/interchangeability_spec.rb
+++ b/spec/features/projects/clusters/interchangeability_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Interchangeability between KubernetesService and Platform::Kubernetes' do
+describe "Interchangeability between KubernetesService and Platform::Kubernetes" do
EXCEPT_METHODS = %i[test title description help fields initialize_properties namespace namespace= api_url api_url= deprecated? deprecation_message].freeze
EXCEPT_METHODS_GREP_V = %w[_touched? _changed? _was].freeze
- it 'Clusters::Platform::Kubernetes covers core interfaces in KubernetesService' do
+ it "Clusters::Platform::Kubernetes covers core interfaces in KubernetesService" do
expected_interfaces = KubernetesService.instance_methods(false)
- expected_interfaces = expected_interfaces - EXCEPT_METHODS
+ expected_interfaces -= EXCEPT_METHODS
EXCEPT_METHODS_GREP_V.each do |g|
expected_interfaces = expected_interfaces.grep_v(/#{Regexp.escape(g)}\z/)
end
diff --git a/spec/features/projects/clusters/user_spec.rb b/spec/features/projects/clusters/user_spec.rb
index 1f2f7592d8b..51252856849 100644
--- a/spec/features/projects/clusters/user_spec.rb
+++ b/spec/features/projects/clusters/user_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User Cluster', :js do
+describe "User Cluster", :js do
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) }
@@ -14,96 +14,96 @@ describe 'User Cluster', :js do
allow_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute)
end
- context 'when user does not have a cluster and visits cluster index page' do
+ context "when user does not have a cluster and visits cluster index page" do
before do
visit project_clusters_path(project)
- click_link 'Add Kubernetes cluster'
- click_link 'Add existing cluster'
+ click_link "Add Kubernetes cluster"
+ click_link "Add existing cluster"
end
- context 'when user filled form with valid parameters' do
+ context "when user filled form with valid parameters" do
before do
- fill_in 'cluster_name', with: 'dev-cluster'
- fill_in 'cluster_platform_kubernetes_attributes_api_url', with: 'http://example.com'
- fill_in 'cluster_platform_kubernetes_attributes_token', with: 'my-token'
+ fill_in "cluster_name", with: "dev-cluster"
+ fill_in "cluster_platform_kubernetes_attributes_api_url", with: "http://example.com"
+ fill_in "cluster_platform_kubernetes_attributes_token", with: "my-token"
end
- subject { click_button 'Add Kubernetes cluster' }
+ subject { click_button "Add Kubernetes cluster" }
- it 'user sees a cluster details page' do
+ it "user sees a cluster details page" do
subject
- expect(page).to have_content('Kubernetes cluster integration')
- expect(page.find_field('cluster[name]').value).to eq('dev-cluster')
- expect(page.find_field('cluster[platform_kubernetes_attributes][api_url]').value)
- .to have_content('http://example.com')
- expect(page.find_field('cluster[platform_kubernetes_attributes][token]').value)
- .to have_content('my-token')
+ expect(page).to have_content("Kubernetes cluster integration")
+ expect(page.find_field("cluster[name]").value).to eq("dev-cluster")
+ expect(page.find_field("cluster[platform_kubernetes_attributes][api_url]").value)
+ .to have_content("http://example.com")
+ expect(page.find_field("cluster[platform_kubernetes_attributes][token]").value)
+ .to have_content("my-token")
end
- it 'user sees RBAC is enabled by default' do
- expect(page).to have_checked_field('RBAC-enabled cluster')
+ it "user sees RBAC is enabled by default" do
+ expect(page).to have_checked_field("RBAC-enabled cluster")
end
end
- context 'when user filled form with invalid parameters' do
+ context "when user filled form with invalid parameters" do
before do
- click_button 'Add Kubernetes cluster'
+ click_button "Add Kubernetes cluster"
end
- it 'user sees a validation error' do
- expect(page).to have_css('#error_explanation')
+ it "user sees a validation error" do
+ expect(page).to have_css("#error_explanation")
end
end
end
- context 'when user does have a cluster and visits cluster page' do
+ context "when user does have a cluster and visits cluster page" do
let(:cluster) { create(:cluster, :provided_by_user, projects: [project]) }
before do
visit project_cluster_path(project, cluster)
end
- it 'user sees a cluster details page' do
- expect(page).to have_button('Save changes')
+ it "user sees a cluster details page" do
+ expect(page).to have_button("Save changes")
end
- context 'when user disables the cluster' do
+ context "when user disables the cluster" do
before do
- page.find(:css, '.js-cluster-enable-toggle-area .js-project-feature-toggle').click
- page.within('#cluster-integration') { click_button 'Save changes' }
+ page.find(:css, ".js-cluster-enable-toggle-area .js-project-feature-toggle").click
+ page.within("#cluster-integration") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
end
end
- context 'when user changes cluster parameters' do
+ context "when user changes cluster parameters" do
before do
- fill_in 'cluster_name', with: 'my-dev-cluster'
- fill_in 'cluster_platform_kubernetes_attributes_namespace', with: 'my-namespace'
- page.within('#js-cluster-details') { click_button 'Save changes' }
+ fill_in "cluster_name", with: "my-dev-cluster"
+ fill_in "cluster_platform_kubernetes_attributes_namespace", with: "my-namespace"
+ page.within("#js-cluster-details") { click_button "Save changes" }
end
- it 'user sees the successful message' do
- expect(page).to have_content('Kubernetes cluster was successfully updated.')
- expect(cluster.reload.name).to eq('my-dev-cluster')
- expect(cluster.reload.platform_kubernetes.namespace).to eq('my-namespace')
+ it "user sees the successful message" do
+ expect(page).to have_content("Kubernetes cluster was successfully updated.")
+ expect(cluster.reload.name).to eq("my-dev-cluster")
+ expect(cluster.reload.platform_kubernetes.namespace).to eq("my-namespace")
end
end
- context 'when user destroy the cluster' do
+ context "when user destroy the cluster" do
before do
page.accept_confirm do
- click_link 'Remove integration'
+ click_link "Remove integration"
end
end
- it 'user sees creation form with the successful message' do
- expect(page).to have_content('Kubernetes cluster integration was successfully removed.')
- expect(page).to have_link('Add Kubernetes cluster')
+ it "user sees creation form with the successful message" do
+ expect(page).to have_content("Kubernetes cluster integration was successfully removed.")
+ expect(page).to have_link("Add Kubernetes cluster")
end
end
end
diff --git a/spec/features/projects/clusters_spec.rb b/spec/features/projects/clusters_spec.rb
index a85e7333ba8..2638d200386 100644
--- a/spec/features/projects/clusters_spec.rb
+++ b/spec/features/projects/clusters_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Clusters', :js do
+describe "Clusters", :js do
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) }
@@ -11,18 +11,18 @@ describe 'Clusters', :js do
gitlab_sign_in(user)
end
- context 'when user does not have a cluster and visits cluster index page' do
+ context "when user does not have a cluster and visits cluster index page" do
before do
visit project_clusters_path(project)
end
- it 'sees empty state' do
- expect(page).to have_link('Add Kubernetes cluster')
- expect(page).to have_selector('.empty-state')
+ it "sees empty state" do
+ expect(page).to have_link("Add Kubernetes cluster")
+ expect(page).to have_selector(".empty-state")
end
end
- context 'when user has a cluster and visits cluster index page' do
+ context "when user has a cluster and visits cluster index page" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
@@ -30,34 +30,34 @@ describe 'Clusters', :js do
visit project_clusters_path(project)
end
- it 'user sees a table with one cluster' do
+ it "user sees a table with one cluster" do
# One is the header row, the other the cluster row
- expect(page).to have_selector('.gl-responsive-table-row', count: 2)
+ expect(page).to have_selector(".gl-responsive-table-row", count: 2)
end
- context 'when user clicks on a cluster' do
+ context "when user clicks on a cluster" do
before do
click_link cluster.name
end
- it 'user sees a cluster details page' do
- expect(page).to have_button('Save')
- expect(page.find(:css, '.cluster-name').value).to eq(cluster.name)
+ it "user sees a cluster details page" do
+ expect(page).to have_button("Save")
+ expect(page.find(:css, ".cluster-name").value).to eq(cluster.name)
end
end
end
- context 'when user has not signed in Google' do
+ context "when user has not signed in Google" do
before do
visit project_clusters_path(project)
- click_link 'Add Kubernetes cluster'
- click_link 'Create new Cluster on GKE'
+ click_link "Add Kubernetes cluster"
+ click_link "Create new Cluster on GKE"
end
- it 'user sees a login page' do
- expect(page).to have_css('.signin-with-google')
- expect(page).to have_link('Google account')
+ it "user sees a login page" do
+ expect(page).to have_css(".signin-with-google")
+ expect(page).to have_link("Google account")
end
end
end
diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb
index d72476f36a9..c9d53bb80a2 100644
--- a/spec/features/projects/commit/builds_spec.rb
+++ b/spec/features/projects/commit/builds_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'project commit pipelines', :js do
+describe "project commit pipelines", :js do
let(:project) { create(:project, :repository) }
before do
@@ -9,17 +9,17 @@ describe 'project commit pipelines', :js do
sign_in(user)
end
- context 'when no builds triggered yet' do
+ context "when no builds triggered yet" do
before do
create(:ci_pipeline, project: project,
sha: project.commit.sha,
- ref: 'master')
+ ref: "master")
end
- it 'user views commit pipelines page' do
+ it "user views commit pipelines page" do
visit pipelines_project_commit_path(project, project.commit.sha)
- page.within('.table-holder') do
+ page.within(".table-holder") do
expect(page).to have_content project.ci_pipelines[0].id # pipeline ids
end
end
diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb
index acfb582dba9..83e3b846d16 100644
--- a/spec/features/projects/commit/cherry_pick_spec.rb
+++ b/spec/features/projects/commit/cherry_pick_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Cherry-pick Commits' do
+describe "Cherry-pick Commits" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :repository, namespace: group) }
- let(:master_pickable_commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
- let(:master_pickable_merge) { project.commit('e56497bb5f03a90a51293fc6d516788730953899') }
+ let(:master_pickable_commit) { project.commit("7d3b0f7cff5f37573aea97cebfd5692ea1689924") }
+ let(:master_pickable_merge) { project.commit("e56497bb5f03a90a51293fc6d516788730953899") }
before do
sign_in(user)
@@ -16,48 +16,48 @@ describe 'Cherry-pick Commits' do
context "I cherry-pick a commit" do
it do
find("a[href='#modal-cherry-pick-commit']").click
- expect(page).not_to have_content('v1.0.0') # Only branches, not tags
- page.within('#modal-cherry-pick-commit') do
- uncheck 'create_merge_request'
- click_button 'Cherry-pick'
+ expect(page).not_to have_content("v1.0.0") # Only branches, not tags
+ page.within("#modal-cherry-pick-commit") do
+ uncheck "create_merge_request"
+ click_button "Cherry-pick"
end
- expect(page).to have_content('The commit has been successfully cherry-picked into master.')
+ expect(page).to have_content("The commit has been successfully cherry-picked into master.")
end
end
context "I cherry-pick a merge commit" do
it do
find("a[href='#modal-cherry-pick-commit']").click
- page.within('#modal-cherry-pick-commit') do
- uncheck 'create_merge_request'
- click_button 'Cherry-pick'
+ page.within("#modal-cherry-pick-commit") do
+ uncheck "create_merge_request"
+ click_button "Cherry-pick"
end
- expect(page).to have_content('The commit has been successfully cherry-picked into master.')
+ expect(page).to have_content("The commit has been successfully cherry-picked into master.")
end
end
context "I cherry-pick a commit that was previously cherry-picked" do
it do
find("a[href='#modal-cherry-pick-commit']").click
- page.within('#modal-cherry-pick-commit') do
- uncheck 'create_merge_request'
- click_button 'Cherry-pick'
+ page.within("#modal-cherry-pick-commit") do
+ uncheck "create_merge_request"
+ click_button "Cherry-pick"
end
visit project_commit_path(project, master_pickable_commit.id)
find("a[href='#modal-cherry-pick-commit']").click
- page.within('#modal-cherry-pick-commit') do
- uncheck 'create_merge_request'
- click_button 'Cherry-pick'
+ page.within("#modal-cherry-pick-commit") do
+ uncheck "create_merge_request"
+ click_button "Cherry-pick"
end
- expect(page).to have_content('Sorry, we cannot cherry-pick this commit automatically.')
+ expect(page).to have_content("Sorry, we cannot cherry-pick this commit automatically.")
end
end
context "I cherry-pick a commit in a new merge request" do
it do
find("a[href='#modal-cherry-pick-commit']").click
- page.within('#modal-cherry-pick-commit') do
- click_button 'Cherry-pick'
+ page.within("#modal-cherry-pick-commit") do
+ click_button "Cherry-pick"
end
expect(page).to have_content("The commit has been successfully cherry-picked into cherry-pick-#{master_pickable_commit.short_id}. You can now submit a merge request to get this change into the original branch.")
expect(page).to have_content("From cherry-pick-#{master_pickable_commit.short_id} into master")
@@ -66,35 +66,35 @@ describe 'Cherry-pick Commits' do
context "I cherry-pick a commit from a different branch", :js do
it do
- find('.header-action-buttons a.dropdown-toggle').click
+ find(".header-action-buttons a.dropdown-toggle").click
find(:css, "a[href='#modal-cherry-pick-commit']").click
- page.within('#modal-cherry-pick-commit') do
- click_button 'master'
+ page.within("#modal-cherry-pick-commit") do
+ click_button "master"
end
wait_for_requests
- page.within('#modal-cherry-pick-commit .dropdown-menu') do
- find('.dropdown-input input').set('feature')
+ page.within("#modal-cherry-pick-commit .dropdown-menu") do
+ find(".dropdown-input input").set("feature")
wait_for_requests
click_link "feature"
end
- page.within('#modal-cherry-pick-commit') do
- uncheck 'create_merge_request'
- click_button 'Cherry-pick'
+ page.within("#modal-cherry-pick-commit") do
+ uncheck "create_merge_request"
+ click_button "Cherry-pick"
end
- expect(page).to have_content('The commit has been successfully cherry-picked into feature.')
+ expect(page).to have_content("The commit has been successfully cherry-picked into feature.")
end
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :repository, :archived, namespace: group) }
- it 'does not show the cherry-pick link' do
- find('.header-action-buttons a.dropdown-toggle').click
+ it "does not show the cherry-pick link" do
+ find(".header-action-buttons a.dropdown-toggle").click
expect(page).not_to have_text("Cherry-pick")
expect(page).not_to have_css("a[href='#modal-cherry-pick-commit']")
diff --git a/spec/features/projects/commit/comments/user_adds_comment_spec.rb b/spec/features/projects/commit/comments/user_adds_comment_spec.rb
index 29442a58ea4..a574f200219 100644
--- a/spec/features/projects/commit/comments/user_adds_comment_spec.rb
+++ b/spec/features/projects/commit/comments/user_adds_comment_spec.rb
@@ -62,7 +62,7 @@ describe "User adds a comment on a commit", :js do
click_diff_line(sample_commit.line_code)
expect(page).to have_css(".js-temp-notes-holder form.new-note")
- .and have_css(".js-close-discussion-note-form", text: "Cancel")
+ .and have_css(".js-close-discussion-note-form", text: "Cancel")
# The `Cancel` button closes the current form. The page should not have any open forms after that.
find(".js-close-discussion-note-form").click
@@ -84,7 +84,7 @@ describe "User adds a comment on a commit", :js do
click_diff_line(sample_commit.del_line_code)
expect(page).to have_field("note[note]", with: "#{comment_text} :smile:")
- .and have_field("note[note]", with: "")
+ .and have_field("note[note]", with: "")
# Test Preview feature for both forms.
page.within("form[data-line-code='#{sample_commit.line_code}']") do
@@ -98,14 +98,14 @@ describe "User adds a comment on a commit", :js do
end
expect(page).to have_css(".js-md-preview", visible: true, count: 2)
- .and have_content(comment_text)
- .and have_content(another_comment_text)
- .and have_xpath("//gl-emoji[@data-name='smile']")
+ .and have_content(comment_text)
+ .and have_content(another_comment_text)
+ .and have_xpath("//gl-emoji[@data-name='smile']")
# Test UI elements, then submit.
page.within("form[data-line-code='#{sample_commit.line_code}']") do
expect(find(".js-note-text", visible: false).text).to eq("")
- expect(page).to have_css('.js-md-write-button')
+ expect(page).to have_css(".js-md-write-button")
click_button("Comment")
end
@@ -164,7 +164,7 @@ describe "User adds a comment on a commit", :js do
end
def click_parallel_diff_line(line)
- find(".line_holder.parallel td[id='#{line}']").find(:xpath, 'preceding-sibling::*[1][self::td]').hover
+ find(".line_holder.parallel td[id='#{line}']").find(:xpath, "preceding-sibling::*[1][self::td]").hover
find(".line_holder.parallel button[data-line-code='#{line}']").click
end
end
diff --git a/spec/features/projects/commit/diff_notes_spec.rb b/spec/features/projects/commit/diff_notes_spec.rb
index e2aefa35fad..a825452391d 100644
--- a/spec/features/projects/commit/diff_notes_spec.rb
+++ b/spec/features/projects/commit/diff_notes_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Commit diff', :js do
+describe "Commit diff", :js do
include RepoHelpers
let(:user) { create(:user) }
@@ -11,24 +11,24 @@ describe 'Commit diff', :js do
sign_in user
end
- %w(inline parallel).each do |view|
+ %w[inline parallel].each do |view|
context "#{view} view" do
before do
visit project_commit_path(project, sample_commit.id, view: view)
end
it "adds comment to diff" do
- diff_line_num = first('.diff-line-num.new')
+ diff_line_num = first(".diff-line-num.new")
diff_line_num.hover
- diff_line_num.find('.js-add-diff-note-button').click
+ diff_line_num.find(".js-add-diff-note-button").click
- page.within(first('.diff-viewer')) do
- find('.js-note-text').set 'test comment'
+ page.within(first(".diff-viewer")) do
+ find(".js-note-text").set "test comment"
- click_button 'Comment'
+ click_button "Comment"
- expect(page).to have_content('test comment')
+ expect(page).to have_content("test comment")
end
end
end
diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb
index 19f6ebf2c1a..1a7d0851c51 100644
--- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb
+++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb
@@ -1,36 +1,36 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Mini Pipeline Graph in Commit View', :js do
+describe "Mini Pipeline Graph in Commit View", :js do
let(:project) { create(:project, :public, :repository) }
- context 'when commit has pipelines' do
+ context "when commit has pipelines" do
let(:pipeline) do
create(:ci_empty_pipeline,
- project: project,
- ref: project.default_branch,
- sha: project.commit.sha)
+ project: project,
+ ref: project.default_branch,
+ sha: project.commit.sha)
end
let(:build) { create(:ci_build, pipeline: pipeline) }
- it 'display icon with status' do
+ it "display icon with status" do
build.run
visit project_commit_path(project, project.commit.id)
- expect(page).to have_selector('.ci-status-icon-running')
+ expect(page).to have_selector(".ci-status-icon-running")
end
- it 'displays a mini pipeline graph' do
+ it "displays a mini pipeline graph" do
build.run
visit project_commit_path(project, project.commit.id)
- expect(page).to have_selector('.mr-widget-pipeline-graph')
+ expect(page).to have_selector(".mr-widget-pipeline-graph")
- first('.mini-pipeline-graph-dropdown-toggle').click
+ first(".mini-pipeline-graph-dropdown-toggle").click
wait_for_requests
- page.within '.js-builds-dropdown-list' do
- expect(page).to have_selector('.ci-status-icon-running')
+ page.within ".js-builds-dropdown-list" do
+ expect(page).to have_selector(".ci-status-icon-running")
expect(page).to have_content(build.stage)
end
@@ -38,13 +38,13 @@ describe 'Mini Pipeline Graph in Commit View', :js do
end
end
- context 'when commit does not have pipelines' do
+ context "when commit does not have pipelines" do
before do
visit project_commit_path(project, project.commit.id)
end
- it 'should not display a mini pipeline graph' do
- expect(page).not_to have_selector('.mr-widget-pipeline-graph')
+ it "should not display a mini pipeline graph" do
+ expect(page).not_to have_selector(".mr-widget-pipeline-graph")
end
end
end
diff --git a/spec/features/projects/commit/user_reverts_commit_spec.rb b/spec/features/projects/commit/user_reverts_commit_spec.rb
index 42844a03ea6..dbec97b11be 100644
--- a/spec/features/projects/commit/user_reverts_commit_spec.rb
+++ b/spec/features/projects/commit/user_reverts_commit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User reverts a commit', :js do
+describe "User reverts a commit", :js do
include RepoHelpers
let(:project) { create(:project, :repository, namespace: user.namespace) }
@@ -13,61 +13,61 @@ describe 'User reverts a commit', :js do
end
def click_revert
- find('.header-action-buttons .dropdown').click
+ find(".header-action-buttons .dropdown").click
find('a[href="#modal-revert-commit"]').click
end
- context 'without creating a new merge request' do
+ context "without creating a new merge request" do
before do
click_revert
- page.within('#modal-revert-commit') do
- uncheck('create_merge_request')
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ uncheck("create_merge_request")
+ click_button("Revert")
end
end
- it 'reverts a commit' do
- expect(page).to have_content('The commit has been successfully reverted.')
+ it "reverts a commit" do
+ expect(page).to have_content("The commit has been successfully reverted.")
end
- it 'does not revert a previously reverted commit' do
+ it "does not revert a previously reverted commit" do
# Visit the comment again once it was reverted.
visit project_commit_path(project, sample_commit.id)
- find('.header-action-buttons .dropdown').click
+ find(".header-action-buttons .dropdown").click
find('a[href="#modal-revert-commit"]').click
- page.within('#modal-revert-commit') do
- uncheck('create_merge_request')
- click_button('Revert')
+ page.within("#modal-revert-commit") do
+ uncheck("create_merge_request")
+ click_button("Revert")
end
- expect(page).to have_content('Sorry, we cannot revert this commit automatically.')
+ expect(page).to have_content("Sorry, we cannot revert this commit automatically.")
end
end
- context 'with creating a new merge request' do
+ context "with creating a new merge request" do
before do
click_revert
end
- it 'reverts a commit' do
- page.within('#modal-revert-commit') do
- click_button('Revert')
+ it "reverts a commit" do
+ page.within("#modal-revert-commit") do
+ click_button("Revert")
end
- expect(page).to have_content('The commit has been successfully reverted. You can now submit a merge request to get this change into the original branch.')
+ expect(page).to have_content("The commit has been successfully reverted. You can now submit a merge request to get this change into the original branch.")
expect(page).to have_content("From revert-#{Commit.truncate_sha(sample_commit.id)} into master")
end
end
- context 'when the project is archived' do
+ context "when the project is archived" do
let(:project) { create(:project, :repository, :archived, namespace: user.namespace) }
- it 'does not show the revert link' do
- find('.header-action-buttons .dropdown').click
+ it "does not show the revert link" do
+ find(".header-action-buttons .dropdown").click
- expect(page).not_to have_link('Revert')
+ expect(page).not_to have_link("Revert")
end
end
end
diff --git a/spec/features/projects/commit/user_views_user_status_on_commit_spec.rb b/spec/features/projects/commit/user_views_user_status_on_commit_spec.rb
index e78b7f7ae08..a54d4064a19 100644
--- a/spec/features/projects/commit/user_views_user_status_on_commit_spec.rb
+++ b/spec/features/projects/commit/user_views_user_status_on_commit_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Project > Commit > View user status' do
+describe "Project > Commit > View user status" do
include RepoHelpers
set(:project) { create(:project, :repository) }
@@ -16,24 +16,24 @@ describe 'Project > Commit > View user status' do
subject { visit(project_commit_path(project, sample_commit.id)) }
- describe 'status for the commit author' do
- it_behaves_like 'showing user status' do
+ describe "status for the commit author" do
+ it_behaves_like "showing user status" do
let(:user_with_status) { commit_author }
end
end
- describe 'status for a comment on the commit' do
+ describe "status for a comment on the commit" do
let(:note) { create(:note, :on_commit, project: project) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { note.author }
end
end
- describe 'status for a diff note on the commit' do
+ describe "status for a diff note on the commit" do
let(:note) { create(:diff_note_on_commit, project: project) }
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { note.author }
end
end
diff --git a/spec/features/projects/commits/rss_spec.rb b/spec/features/projects/commits/rss_spec.rb
index cfc2637f1b2..a14420b3e0b 100644
--- a/spec/features/projects/commits/rss_spec.rb
+++ b/spec/features/projects/commits/rss_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Commits RSS' do
+describe "Project Commits RSS" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_commits_path(project, :master) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in(user)
@@ -16,7 +16,7 @@ describe 'Project Commits RSS' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/projects/commits/user_browses_commits_spec.rb b/spec/features/projects/commits/user_browses_commits_spec.rb
index 574a8aefd63..11ea96efb3d 100644
--- a/spec/features/projects/commits/user_browses_commits_spec.rb
+++ b/spec/features/projects/commits/user_browses_commits_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User browses commits' do
+describe "User browses commits" do
include RepoHelpers
let(:user) { create(:user) }
@@ -10,44 +10,44 @@ describe 'User browses commits' do
sign_in(user)
end
- it 'renders commit' do
+ it "renders commit" do
visit project_commit_path(project, sample_commit.id)
expect(page).to have_content(sample_commit.message)
.and have_content("Showing #{sample_commit.files_changed_count} changed files")
- .and have_content('Side-by-side')
+ .and have_content("Side-by-side")
end
- it 'fill commit sha when click new tag from commit page' do
+ it "fill commit sha when click new tag from commit page" do
visit project_commit_path(project, sample_commit.id)
- click_link 'Tag'
+ click_link "Tag"
expect(page).to have_selector("input[value='#{sample_commit.id}']", visible: false)
end
- it 'renders inline diff button when click side-by-side diff button' do
+ it "renders inline diff button when click side-by-side diff button" do
visit project_commit_path(project, sample_commit.id)
- find('#parallel-diff-btn').click
+ find("#parallel-diff-btn").click
- expect(page).to have_content 'Inline'
+ expect(page).to have_content "Inline"
end
- it 'renders breadcrumbs on specific commit path' do
- visit project_commits_path(project, project.repository.root_ref + '/files/ruby/regex.rb', limit: 5)
+ it "renders breadcrumbs on specific commit path" do
+ visit project_commits_path(project, project.repository.root_ref + "/files/ruby/regex.rb", limit: 5)
- expect(page).to have_selector('ul.breadcrumb')
- .and have_selector('ul.breadcrumb a', count: 4)
+ expect(page).to have_selector("ul.breadcrumb")
+ .and have_selector("ul.breadcrumb a", count: 4)
end
- it 'renders diff links to both the previous and current image' do
+ it "renders diff links to both the previous and current image" do
visit project_commit_path(project, sample_image_commit.id)
- links = page.all('.file-actions a')
- expect(links[0]['href']).to match %r{blob/#{sample_image_commit.old_blob_id}}
- expect(links[1]['href']).to match %r{blob/#{sample_image_commit.new_blob_id}}
+ links = page.all(".file-actions a")
+ expect(links[0]["href"]).to match %r{blob/#{sample_image_commit.old_blob_id}}
+ expect(links[1]["href"]).to match %r{blob/#{sample_image_commit.new_blob_id}}
end
- context 'when commit has ci status' do
+ context "when commit has ci status" do
let(:pipeline) { create(:ci_pipeline, project: project, sha: sample_commit.id) }
before do
@@ -55,19 +55,19 @@ describe 'User browses commits' do
create(:ci_build, pipeline: pipeline)
- allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return('')
+ allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return("")
end
- it 'renders commit ci info' do
+ it "renders commit ci info" do
visit project_commit_path(project, sample_commit.id)
expect(page).to have_content "Pipeline ##{pipeline.id} pending"
end
end
- context 'primary email' do
- it 'finds a commit by a primary email' do
- user = create(:user, email: 'dmitriy.zaporozhets@gmail.com')
+ context "primary email" do
+ it "finds a commit by a primary email" do
+ user = create(:user, email: "dmitriy.zaporozhets@gmail.com")
visit(project_commit_path(project, sample_commit.id))
@@ -75,12 +75,12 @@ describe 'User browses commits' do
end
end
- context 'secondary email' do
- it 'finds a commit by a secondary email' do
+ context "secondary email" do
+ it "finds a commit by a secondary email" do
user =
- create(:user) do |user|
- create(:email, { user: user, email: 'dmitriy.zaporozhets@gmail.com' })
- end
+ create(:user) { |user|
+ create(:email, {user: user, email: "dmitriy.zaporozhets@gmail.com"})
+ }
visit(project_commit_path(project, sample_commit.parent_id))
@@ -88,70 +88,70 @@ describe 'User browses commits' do
end
end
- context 'when the blob does not exist' do
+ context "when the blob does not exist" do
let(:commit) { create(:commit, project: project) }
- it 'shows a blank label' do
+ it "shows a blank label" do
allow_any_instance_of(Gitlab::Diff::File).to receive(:blob).and_return(nil)
allow_any_instance_of(Gitlab::Diff::File).to receive(:binary?).and_return(true)
visit(project_commit_path(project, commit))
- expect(find('.diff-file-changes', visible: false)).to have_content('No file name available')
+ expect(find(".diff-file-changes", visible: false)).to have_content("No file name available")
end
end
- describe 'commits list' do
+ describe "commits list" do
let(:visit_commits_page) do
visit project_commits_path(project, project.repository.root_ref, limit: 5)
end
- it 'searches commit', :js do
+ it "searches commit", :js do
visit_commits_page
- fill_in 'commits-search', with: 'submodules'
+ fill_in "commits-search", with: "submodules"
- expect(page).to have_content 'More submodules'
- expect(page).not_to have_content 'Change some files'
+ expect(page).to have_content "More submodules"
+ expect(page).not_to have_content "Change some files"
end
- it 'renders commits atom feed' do
+ it "renders commits atom feed" do
visit_commits_page
- click_link('Commits feed')
+ click_link("Commits feed")
commit = project.repository.commit
- expect(response_headers['Content-Type']).to have_content("application/atom+xml")
- expect(body).to have_selector('title', text: "#{project.name}:master commits")
- .and have_selector('author email', text: commit.author_email)
- .and have_selector('entry summary', text: commit.description[0..10].delete("\r\n"))
+ expect(response_headers["Content-Type"]).to have_content("application/atom+xml")
+ expect(body).to have_selector("title", text: "#{project.name}:master commits")
+ .and have_selector("author email", text: commit.author_email)
+ .and have_selector("entry summary", text: commit.description[0..10].delete("\r\n"))
end
- context 'when a commit links to a confidential issue' do
- let(:confidential_issue) { create(:issue, confidential: true, title: 'Secret issue!', project: project) }
+ context "when a commit links to a confidential issue" do
+ let(:confidential_issue) { create(:issue, confidential: true, title: "Secret issue!", project: project) }
before do
- project.repository.create_file(user, 'dummy-file', 'dummy content',
- branch_name: 'feature',
- message: "Linking #{confidential_issue.to_reference}")
+ project.repository.create_file(user, "dummy-file", "dummy content",
+ branch_name: "feature",
+ message: "Linking #{confidential_issue.to_reference}")
end
- context 'when the user cannot see confidential issues but was cached with a link', :use_clean_rails_memory_store_fragment_caching do
- it 'does not render the confidential issue' do
- visit project_commits_path(project, 'feature')
+ context "when the user cannot see confidential issues but was cached with a link", :use_clean_rails_memory_store_fragment_caching do
+ it "does not render the confidential issue" do
+ visit project_commits_path(project, "feature")
sign_in(create(:user))
- visit project_commits_path(project, 'feature')
+ visit project_commits_path(project, "feature")
expect(page).not_to have_link(href: project_issue_path(project, confidential_issue))
end
end
end
- context 'master branch' do
+ context "master branch" do
before do
visit_commits_page
end
- it 'renders project commits' do
+ it "renders project commits" do
commit = project.repository.commit
expect(page).to have_content(project.name)
@@ -159,62 +159,62 @@ describe 'User browses commits' do
.and have_content(commit.short_id)
end
- it 'does not render create merge request button' do
- expect(page).not_to have_link 'Create merge request'
+ it "does not render create merge request button" do
+ expect(page).not_to have_link "Create merge request"
end
- context 'when click the compare tab' do
+ context "when click the compare tab" do
before do
- click_link('Compare')
+ click_link("Compare")
end
- it 'does not render create merge request button' do
- expect(page).not_to have_link 'Create merge request'
+ it "does not render create merge request button" do
+ expect(page).not_to have_link "Create merge request"
end
end
end
- context 'feature branch' do
+ context "feature branch" do
let(:visit_commits_page) do
- visit project_commits_path(project, 'feature')
+ visit project_commits_path(project, "feature")
end
- context 'when project does not have open merge requests' do
+ context "when project does not have open merge requests" do
before do
visit_commits_page
end
- it 'renders project commits' do
- commit = project.repository.commit('0b4bc9a')
+ it "renders project commits" do
+ commit = project.repository.commit("0b4bc9a")
expect(page).to have_content(project.name)
.and have_content(commit.message[0..12])
.and have_content(commit.short_id)
end
- it 'renders create merge request button' do
- expect(page).to have_link 'Create merge request'
+ it "renders create merge request button" do
+ expect(page).to have_link "Create merge request"
end
- context 'when click the compare tab' do
+ context "when click the compare tab" do
before do
- click_link('Compare')
+ click_link("Compare")
end
- it 'renders create merge request button' do
- expect(page).to have_link 'Create merge request'
+ it "renders create merge request button" do
+ expect(page).to have_link "Create merge request"
end
end
end
- context 'when project have open merge request' do
+ context "when project have open merge request" do
let!(:merge_request) do
create(
:merge_request,
- title: 'Feature',
+ title: "Feature",
source_project: project,
- source_branch: 'feature',
- target_branch: 'master',
+ source_branch: "feature",
+ target_branch: "master",
author: project.users.first
)
end
@@ -223,27 +223,27 @@ describe 'User browses commits' do
visit_commits_page
end
- it 'renders project commits' do
- commit = project.repository.commit('0b4bc9a')
+ it "renders project commits" do
+ commit = project.repository.commit("0b4bc9a")
expect(page).to have_content(project.name)
.and have_content(commit.message[0..12])
.and have_content(commit.short_id)
end
- it 'renders button to the merge request' do
- expect(page).not_to have_link 'Create merge request'
- expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
+ it "renders button to the merge request" do
+ expect(page).not_to have_link "Create merge request"
+ expect(page).to have_link "View open merge request", href: project_merge_request_path(project, merge_request)
end
- context 'when click the compare tab' do
+ context "when click the compare tab" do
before do
- click_link('Compare')
+ click_link("Compare")
end
- it 'renders button to the merge request' do
- expect(page).not_to have_link 'Create merge request'
- expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
+ it "renders button to the merge request" do
+ expect(page).not_to have_link "Create merge request"
+ expect(page).to have_link "View open merge request", href: project_merge_request_path(project, merge_request)
end
end
end
@@ -254,8 +254,8 @@ end
private
def check_author_link(email, author)
- author_link = find('.commit-author-link')
+ author_link = find(".commit-author-link")
- expect(author_link['href']).to eq(user_path(author))
- expect(find('.commit-author-name').text).to eq(author.name)
+ expect(author_link["href"]).to eq(user_path(author))
+ expect(find(".commit-author-name").text).to eq(author.name)
end
diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb
index 5f7cf68987e..895a6c8aa55 100644
--- a/spec/features/projects/compare_spec.rb
+++ b/spec/features/projects/compare_spec.rb
@@ -29,52 +29,52 @@ describe "Compare", :js do
click_button "Compare"
expect(page).to have_content "Commits"
- expect(page).to have_link 'Create merge request'
+ expect(page).to have_link "Create merge request"
end
- it 'renders additions info when click unfold diff' do
+ it "renders additions info when click unfold diff" do
visit project_compare_index_path(project)
- select_using_dropdown('from', RepoHelpers.sample_commit.parent_id, commit: true)
- select_using_dropdown('to', RepoHelpers.sample_commit.id, commit: true)
+ select_using_dropdown("from", RepoHelpers.sample_commit.parent_id, commit: true)
+ select_using_dropdown("to", RepoHelpers.sample_commit.id, commit: true)
- click_button 'Compare'
- expect(page).to have_content 'Commits (1)'
+ click_button "Compare"
+ expect(page).to have_content "Commits (1)"
expect(page).to have_content "Showing 2 changed files"
- diff = first('.js-unfold')
+ diff = first(".js-unfold")
diff.click
wait_for_requests
page.within diff.query_scope do
- expect(first('.new_line').text).not_to have_content "..."
+ expect(first(".new_line").text).not_to have_content "..."
end
end
- context 'when project have an open merge request' do
+ context "when project have an open merge request" do
let!(:merge_request) do
create(
:merge_request,
- title: 'Feature',
+ title: "Feature",
source_project: project,
- source_branch: 'feature',
- target_branch: 'master',
+ source_branch: "feature",
+ target_branch: "master",
author: project.users.first
)
end
- it 'compares branches' do
+ it "compares branches" do
visit project_compare_index_path(project)
- select_using_dropdown('from', 'master')
- select_using_dropdown('to', 'feature')
+ select_using_dropdown("from", "master")
+ select_using_dropdown("to", "feature")
- click_button 'Compare'
+ click_button "Compare"
- expect(page).to have_content 'Commits (1)'
- expect(page).to have_content 'Showing 1 changed file with 5 additions and 0 deletions'
- expect(page).to have_link 'View open merge request', href: project_merge_request_path(project, merge_request)
- expect(page).not_to have_link 'Create merge request'
+ expect(page).to have_content "Commits (1)"
+ expect(page).to have_content "Showing 1 changed file with 5 additions and 0 deletions"
+ expect(page).to have_link "View open merge request", href: project_merge_request_path(project, merge_request)
+ expect(page).not_to have_link "Create merge request"
end
end
@@ -88,16 +88,16 @@ describe "Compare", :js do
expect(find(".js-compare-from-dropdown .dropdown-content")).to have_selector("li", count: 3)
end
- context 'when commit has overflow', :js do
- it 'displays warning' do
+ context "when commit has overflow", :js do
+ it "displays warning" do
visit project_compare_index_path(project, from: "feature", to: "master")
allow(Commit).to receive(:max_diff_options).and_return(max_files: 3)
allow_any_instance_of(DiffHelper).to receive(:render_overflow_warning?).and_return(true)
- click_button('Compare')
+ click_button("Compare")
- page.within('.alert') do
+ page.within(".alert") do
expect(page).to have_text("Too many changes to show. To preserve performance only 3 of 3+ files are displayed.")
end
end
@@ -123,7 +123,7 @@ describe "Compare", :js do
dropdown = find(".js-compare-#{dropdown_type}-dropdown")
dropdown.find(".compare-dropdown-toggle").click
# find input before using to wait for the inputs visiblity
- dropdown.find('.dropdown-menu')
+ dropdown.find(".dropdown-menu")
dropdown.fill_in("Filter by Git revision", with: selection)
wait_for_requests
diff --git a/spec/features/projects/deploy_keys_spec.rb b/spec/features/projects/deploy_keys_spec.rb
index 1fa9babaff5..7e95b989194 100644
--- a/spec/features/projects/deploy_keys_spec.rb
+++ b/spec/features/projects/deploy_keys_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project deploy keys', :js do
+describe "Project deploy keys", :js do
let(:user) { create(:user) }
let(:project) { create(:project_empty_repo) }
@@ -9,22 +9,22 @@ describe 'Project deploy keys', :js do
sign_in(user)
end
- describe 'removing key' do
+ describe "removing key" do
before do
create(:deploy_keys_project, project: project)
end
- it 'removes association between project and deploy key' do
+ it "removes association between project and deploy key" do
visit project_settings_repository_path(project)
- page.within(find('.deploy-keys')) do
- expect(page).to have_selector('.deploy-key', count: 1)
+ page.within(find(".deploy-keys")) do
+ expect(page).to have_selector(".deploy-key", count: 1)
- accept_confirm { find('.ic-remove').click }
+ accept_confirm { find(".ic-remove").click }
wait_for_requests
- expect(page).to have_selector('.deploy-key', count: 0)
+ expect(page).to have_selector(".deploy-key", count: 0)
end
end
end
diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb
index df05625d105..7959ce1e5cb 100644
--- a/spec/features/projects/diffs/diff_show_spec.rb
+++ b/spec/features/projects/diffs/diff_show_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Diff file viewer', :js do
+describe "Diff file viewer", :js do
let(:project) { create(:project, :public, :repository) }
def visit_commit(sha, anchor: nil)
@@ -9,12 +9,12 @@ describe 'Diff file viewer', :js do
wait_for_requests
end
- context 'Ruby file' do
+ context "Ruby file" do
before do
- visit_commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
+ visit_commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d")
end
- it 'shows highlighted Ruby code' do
+ it "shows highlighted Ruby code" do
within('.diff-file[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd"]') do
expect(page).to have_css(".js-syntax-highlight")
expect(page).to have_content("def popen(cmd, path=nil)")
@@ -22,22 +22,22 @@ describe 'Diff file viewer', :js do
end
end
- context 'Ruby file (stored in LFS)' do
+ context "Ruby file (stored in LFS)" do
before do
project.add_maintainer(project.creator)
@commit_id = Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add Ruby file in LFS",
- file_path: 'files/lfs/ruby.rb',
- file_content: project.repository.blob_at('master', 'files/lfs/lfs_object.iso').data
+ file_path: "files/lfs/ruby.rb",
+ file_content: project.repository.blob_at("master", "files/lfs/lfs_object.iso").data
).execute[:result]
end
- context 'when LFS is enabled on the project' do
+ context "when LFS is enabled on the project" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
@@ -45,134 +45,134 @@ describe 'Diff file viewer', :js do
visit_commit(@commit_id)
end
- it 'shows an error message' do
- expect(page).to have_content('This source diff could not be displayed because it is stored in LFS. You can view the blob instead.')
+ it "shows an error message" do
+ expect(page).to have_content("This source diff could not be displayed because it is stored in LFS. You can view the blob instead.")
end
end
- context 'when LFS is disabled on the project' do
+ context "when LFS is disabled on the project" do
before do
visit_commit(@commit_id)
end
- it 'displays the diff' do
- expect(page).to have_content('size 1575078')
+ it "displays the diff" do
+ expect(page).to have_content("size 1575078")
end
end
end
- context 'Image file' do
- context 'Replaced' do
+ context "Image file" do
+ context "Replaced" do
before do
- visit_commit('2f63565e7aac07bcdadb654e253078b727143ec4')
+ visit_commit("2f63565e7aac07bcdadb654e253078b727143ec4")
end
- it 'shows a rendered image' do
+ it "shows a rendered image" do
within('.diff-file[id="e986451b8f7397b617dbb6fffcb5539328c56921"]') do
expect(page).to have_css('img[alt="files/images/6049019_460s.jpg"]')
end
end
- it 'shows view replaced and view file links' do
- expect(page.all('.file-actions a').length).to eq 2
- expect(page.all('.file-actions a')[0]).to have_content 'View replaced file @'
- expect(page.all('.file-actions a')[1]).to have_content 'View file @'
+ it "shows view replaced and view file links" do
+ expect(page.all(".file-actions a").length).to eq 2
+ expect(page.all(".file-actions a")[0]).to have_content "View replaced file @"
+ expect(page.all(".file-actions a")[1]).to have_content "View file @"
end
end
- context 'Added' do
+ context "Added" do
before do
- visit_commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ visit_commit("33f3729a45c02fc67d00adb1b8bca394b0e761d9")
end
- it 'shows view file link' do
- expect(page.all('.file-actions a').length).to eq 1
- expect(page.all('.file-actions a')[0]).to have_content 'View file @'
+ it "shows view file link" do
+ expect(page.all(".file-actions a").length).to eq 1
+ expect(page.all(".file-actions a")[0]).to have_content "View file @"
end
end
- context 'Deleted' do
+ context "Deleted" do
before do
- visit_commit('7fd7a459706ee87be6f855fd98ce8c552b15529a')
+ visit_commit("7fd7a459706ee87be6f855fd98ce8c552b15529a")
end
- it 'shows view file link' do
- expect(page.all('.file-actions a').length).to eq 1
- expect(page.all('.file-actions a')[0]).to have_content 'View file @'
+ it "shows view file link" do
+ expect(page.all(".file-actions a").length).to eq 1
+ expect(page.all(".file-actions a")[0]).to have_content "View file @"
end
end
end
- context 'ISO file (stored in LFS)' do
- context 'when LFS is enabled on the project' do
+ context "ISO file (stored in LFS)" do
+ context "when LFS is enabled on the project" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
project.update_attribute(:lfs_enabled, true)
- visit_commit('048721d90c449b244b7b4c53a9186b04330174ec')
+ visit_commit("048721d90c449b244b7b4c53a9186b04330174ec")
end
- it 'shows that file was added' do
- expect(page).to have_content('File added')
+ it "shows that file was added" do
+ expect(page).to have_content("File added")
end
end
- context 'when LFS is disabled on the project' do
+ context "when LFS is disabled on the project" do
before do
- visit_commit('048721d90c449b244b7b4c53a9186b04330174ec')
+ visit_commit("048721d90c449b244b7b4c53a9186b04330174ec")
end
- it 'displays the diff' do
- expect(page).to have_content('size 1575078')
+ it "displays the diff" do
+ expect(page).to have_content("size 1575078")
end
end
end
- context 'ZIP file' do
+ context "ZIP file" do
before do
- visit_commit('ae73cb07c9eeaf35924a10f713b364d32b2dd34f')
+ visit_commit("ae73cb07c9eeaf35924a10f713b364d32b2dd34f")
end
- it 'shows that file was added' do
- expect(page).to have_content('File added')
+ it "shows that file was added" do
+ expect(page).to have_content("File added")
end
end
- context 'renamed file' do
+ context "renamed file" do
before do
- visit_commit('6907208d755b60ebeacb2e9dfea74c92c3449a1f')
+ visit_commit("6907208d755b60ebeacb2e9dfea74c92c3449a1f")
end
- it 'shows the filename with diff highlight' do
- within('.file-header-content') do
- expect(page).to have_css('.idiff.left.right.deletion')
- expect(page).to have_content('files/js/commit.coffee')
+ it "shows the filename with diff highlight" do
+ within(".file-header-content") do
+ expect(page).to have_css(".idiff.left.right.deletion")
+ expect(page).to have_content("files/js/commit.coffee")
end
end
end
- context 'binary file that appears to be text in the first 1024 bytes' do
+ context "binary file that appears to be text in the first 1024 bytes" do
before do
# The file we're visiting is smaller than 10 KB and we want it collapsed
# so we need to disable the size increase feature.
stub_feature_flags(gitlab_git_diff_size_limit_increase: false)
- visit_commit('7b1cf4336b528e0f3d1d140ee50cafdbc703597c')
+ visit_commit("7b1cf4336b528e0f3d1d140ee50cafdbc703597c")
end
- it 'shows the diff is collapsed' do
- expect(page).to have_content('This diff is collapsed. Click to expand it.')
+ it "shows the diff is collapsed" do
+ expect(page).to have_content("This diff is collapsed. Click to expand it.")
end
- context 'expanding the diff' do
+ context "expanding the diff" do
before do
- click_button 'Click to expand it.'
+ click_button "Click to expand it."
wait_for_requests
end
- it 'shows there is no preview' do
- expect(page).to have_content('No preview for this file type')
+ it "shows there is no preview" do
+ expect(page).to have_content("No preview for this file type")
end
end
end
diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb
index edbab14f7c1..d160449cdf1 100644
--- a/spec/features/projects/environments/environment_metrics_spec.rb
+++ b/spec/features/projects/environments/environment_metrics_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Environment > Metrics' do
+describe "Environment > Metrics" do
include PrometheusHelpers
let(:user) { create(:user) }
@@ -23,11 +23,11 @@ describe 'Environment > Metrics' do
Timecop.freeze(current_time) { example.run }
end
- context 'with deployments and related deployable present' do
- it 'shows metrics' do
- click_link('See metrics')
+ context "with deployments and related deployable present" do
+ it "shows metrics" do
+ click_link("See metrics")
- expect(page).to have_css('div#prometheus-graphs')
+ expect(page).to have_css("div#prometheus-graphs")
end
end
diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb
index a8a3b6910fb..4ca38ff9f1c 100644
--- a/spec/features/projects/environments/environment_spec.rb
+++ b/spec/features/projects/environments/environment_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Environment' do
+describe "Environment" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
@@ -10,7 +10,7 @@ describe 'Environment' do
project.add_role(user, role)
end
- describe 'environment details page' do
+ describe "environment details page" do
let!(:environment) { create(:environment, project: project) }
let!(:permissions) { }
let!(:deployment) { }
@@ -20,30 +20,30 @@ describe 'Environment' do
visit_environment(environment)
end
- it 'shows environment name' do
+ it "shows environment name" do
expect(page).to have_content(environment.name)
end
- context 'without deployments' do
- it 'does not show deployments' do
- expect(page).to have_content('You don\'t have any deployments right now.')
+ context "without deployments" do
+ it "does not show deployments" do
+ expect(page).to have_content("You don't have any deployments right now.")
end
end
- context 'with deployments' do
- context 'when there is no related deployable' do
+ context "with deployments" do
+ context "when there is no related deployable" do
let(:deployment) do
create(:deployment, :success, environment: environment, deployable: nil)
end
- it 'does show deployment SHA' do
+ it "does show deployment SHA" do
expect(page).to have_link(deployment.short_sha)
- expect(page).not_to have_link('Re-deploy')
+ expect(page).not_to have_link("Re-deploy")
expect(page).not_to have_terminal_button
end
end
- context 'when there is a successful deployment' do
+ context "when there is a successful deployment" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
@@ -51,12 +51,12 @@ describe 'Environment' do
create(:deployment, :success, environment: environment, deployable: build)
end
- it 'does show deployments' do
+ it "does show deployments" do
expect(page).to have_link("#{build.name} (##{build.id})")
end
end
- context 'when there is a running deployment' do
+ context "when there is a running deployment" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
@@ -64,12 +64,12 @@ describe 'Environment' do
create(:deployment, :running, environment: environment, deployable: build)
end
- it 'does not show deployments' do
- expect(page).to have_content('You don\'t have any deployments right now.')
+ it "does not show deployments" do
+ expect(page).to have_content("You don't have any deployments right now.")
end
end
- context 'when there is a failed deployment' do
+ context "when there is a failed deployment" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
@@ -77,12 +77,12 @@ describe 'Environment' do
create(:deployment, :failed, environment: environment, deployable: build)
end
- it 'does not show deployments' do
- expect(page).to have_content('You don\'t have any deployments right now.')
+ it "does not show deployments" do
+ expect(page).to have_content("You don't have any deployments right now.")
end
end
- context 'with related deployable present' do
+ context "with related deployable present" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
@@ -90,43 +90,43 @@ describe 'Environment' do
create(:deployment, :success, environment: environment, deployable: build)
end
- it 'does show build name' do
+ it "does show build name" do
expect(page).to have_link("#{build.name} (##{build.id})")
- expect(page).not_to have_link('Re-deploy')
+ expect(page).not_to have_link("Re-deploy")
expect(page).not_to have_terminal_button
end
- context 'when user has ability to re-deploy' do
+ context "when user has ability to re-deploy" do
let(:permissions) do
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'does show re-deploy' do
- expect(page).to have_link('Re-deploy')
+ it "does show re-deploy" do
+ expect(page).to have_link("Re-deploy")
end
end
- context 'with manual action' do
+ context "with manual action" do
let(:action) do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'deploy to production', environment: environment.name)
+ name: "deploy to production", environment: environment.name)
end
- context 'when user has ability to trigger deployment' do
+ context "when user has ability to trigger deployment" do
let(:permissions) do
create(:protected_branch, :developers_can_merge,
- name: action.ref, project: project)
+ name: action.ref, project: project)
end
- it 'does show a play button' do
+ it "does show a play button" do
expect(page).to have_link(action.name.humanize)
end
- it 'does allow to play manual action', :js do
+ it "does allow to play manual action", :js do
expect(action).to be_manual
- find('button.dropdown').click
+ find("button.dropdown").click
expect { click_link(action.name.humanize) }
.not_to change { Ci::Pipeline.count }
@@ -138,32 +138,32 @@ describe 'Environment' do
end
end
- context 'when user has no ability to trigger a deployment' do
- it 'does not show a play button' do
+ context "when user has no ability to trigger a deployment" do
+ it "does not show a play button" do
expect(page).not_to have_link(action.name.humanize)
end
end
- context 'with external_url' do
- let(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') }
+ context "with external_url" do
+ let(:environment) { create(:environment, project: project, external_url: "https://git.gitlab.com") }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:deployment) { create(:deployment, :success, environment: environment, deployable: build) }
- it 'does show an external link button' do
+ it "does show an external link button" do
expect(page).to have_link(nil, href: environment.external_url)
end
end
- context 'with terminal' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- context 'for project maintainer' do
+ context "with terminal" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ context "for project maintainer" do
let(:role) { :maintainer }
- it 'it shows the terminal button' do
+ it "it shows the terminal button" do
expect(page).to have_terminal_button
end
- context 'web terminal', :js do
+ context "web terminal", :js do
before do
# Stub #terminals as it causes js-enabled feature specs to
# render the page incorrectly
@@ -176,85 +176,85 @@ describe 'Environment' do
visit terminal_project_environment_path(project, environment)
end
- it 'displays a web terminal' do
- expect(page).to have_selector('#terminal')
+ it "displays a web terminal" do
+ expect(page).to have_selector("#terminal")
expect(page).to have_link(nil, href: environment.external_url)
end
end
end
- context 'for developer' do
+ context "for developer" do
let(:role) { :developer }
- it 'does not show terminal button' do
+ it "does not show terminal button" do
expect(page).not_to have_terminal_button
end
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project, :test_repo) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'when environment is available' do
- context 'with stop action' do
+ context "when environment is available" do
+ context "with stop action" do
let(:action) do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'close_app')
+ name: "close_app")
end
let(:deployment) do
create(:deployment, :success,
- environment: environment,
- deployable: build,
- on_stop: 'close_app')
+ environment: environment,
+ deployable: build,
+ on_stop: "close_app")
end
- context 'when user has ability to stop environment' do
+ context "when user has ability to stop environment" do
let(:permissions) do
create(:protected_branch, :developers_can_merge,
- name: action.ref, project: project)
+ name: action.ref, project: project)
end
- it 'allows to stop environment', :js do
- click_button('Stop')
- click_button('Stop environment') # confirm modal
+ it "allows to stop environment", :js do
+ click_button("Stop")
+ click_button("Stop environment") # confirm modal
wait_for_all_requests
- expect(page).to have_content('close_app')
+ expect(page).to have_content("close_app")
end
end
- context 'when user has no ability to stop environment' do
- it 'does not allow to stop environment' do
- expect(page).not_to have_button('Stop')
+ context "when user has no ability to stop environment" do
+ it "does not allow to stop environment" do
+ expect(page).not_to have_button("Stop")
end
end
- context 'for reporter' do
+ context "for reporter" do
let(:role) { :reporter }
- it 'does not show stop button' do
- expect(page).not_to have_button('Stop')
+ it "does not show stop button" do
+ expect(page).not_to have_button("Stop")
end
end
end
end
- context 'when environment is stopped' do
+ context "when environment is stopped" do
let(:environment) { create(:environment, project: project, state: :stopped) }
- it 'does not show stop button' do
- expect(page).not_to have_button('Stop')
+ it "does not show stop button" do
+ expect(page).not_to have_button("Stop")
end
end
end
@@ -262,49 +262,49 @@ describe 'Environment' do
end
end
- describe 'environment folders', :js do
- context 'when folder name contains special charaters' do
+ describe "environment folders", :js do
+ context "when folder name contains special charaters" do
before do
create(:environment, project: project,
- name: 'staging-1.0/review',
+ name: "staging-1.0/review",
state: :available)
end
- it 'renders a correct environment folder' do
- reqs = inspect_requests do
- visit folder_project_environments_path(project, id: 'staging-1.0')
- end
+ it "renders a correct environment folder" do
+ reqs = inspect_requests {
+ visit folder_project_environments_path(project, id: "staging-1.0")
+ }
expect(reqs.first.status_code).to eq(200)
- expect(page).to have_content('Environments / staging-1.0')
+ expect(page).to have_content("Environments / staging-1.0")
end
end
end
- describe 'auto-close environment when branch is deleted' do
+ describe "auto-close environment when branch is deleted" do
let(:project) { create(:project, :repository) }
let!(:environment) do
create(:environment, :with_review_app, project: project,
- ref: 'feature')
+ ref: "feature")
end
- it 'user visits environment page' do
+ it "user visits environment page" do
visit_environment(environment)
- expect(page).to have_button('Stop')
+ expect(page).to have_button("Stop")
end
- it 'user deletes the branch with running environment' do
- visit project_branches_filtered_path(project, state: 'all', search: 'feature')
+ it "user deletes the branch with running environment" do
+ visit project_branches_filtered_path(project, state: "all", search: "feature")
- remove_branch_with_hooks(project, user, 'feature') do
- page.within('.js-branch-feature') { find('a.btn-remove').click }
+ remove_branch_with_hooks(project, user, "feature") do
+ page.within(".js-branch-feature") { find("a.btn-remove").click }
end
visit_environment(environment)
- expect(page).not_to have_button('Stop')
+ expect(page).not_to have_button("Stop")
end
##
@@ -314,7 +314,7 @@ describe 'Environment' do
params = {
oldrev: project.commit(branch).id,
newrev: Gitlab::Git::BLANK_SHA,
- ref: "refs/heads/#{branch}"
+ ref: "refs/heads/#{branch}",
}
yield
diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb
index 66c6545204b..c92670b16d4 100644
--- a/spec/features/projects/environments/environments_spec.rb
+++ b/spec/features/projects/environments/environments_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Environments page', :js do
+describe "Environments page", :js do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
@@ -11,439 +11,439 @@ describe 'Environments page', :js do
end
def stop_button_selector
- %q{button[data-original-title="Stop environment"]}
+ 'button[data-original-title="Stop environment"]'
end
- describe 'page tabs' do
+ describe "page tabs" do
it 'shows "Available" and "Stopped" tab with links' do
visit_environments(project)
- expect(page).to have_selector('.js-environments-tab-available')
- expect(page).to have_content('Available')
- expect(page).to have_selector('.js-environments-tab-stopped')
- expect(page).to have_content('Stopped')
+ expect(page).to have_selector(".js-environments-tab-available")
+ expect(page).to have_content("Available")
+ expect(page).to have_selector(".js-environments-tab-stopped")
+ expect(page).to have_content("Stopped")
end
- describe 'with one available environment' do
+ describe "with one available environment" do
before do
create(:environment, project: project, state: :available)
end
- describe 'in available tab page' do
- it 'should show one environment' do
- visit_environments(project, scope: 'available')
+ describe "in available tab page" do
+ it "should show one environment" do
+ visit_environments(project, scope: "available")
- expect(page).to have_css('.environments-container')
- expect(page.all('.environment-name').length).to eq(1)
+ expect(page).to have_css(".environments-container")
+ expect(page.all(".environment-name").length).to eq(1)
end
end
- describe 'with environments spanning multiple pages', :js do
+ describe "with environments spanning multiple pages", :js do
before do
allow(Kaminari.config).to receive(:default_per_page).and_return(3)
create_list(:environment, 4, project: project, state: :available)
end
- it 'should render second page of pipelines' do
- visit_environments(project, scope: 'available')
+ it "should render second page of pipelines" do
+ visit_environments(project, scope: "available")
- find('.js-next-button').click
+ find(".js-next-button").click
wait_for_requests
- expect(page).to have_selector('.gl-pagination .page', count: 2)
- expect(find('.gl-pagination .page-item.active .page-link').text).to eq("2")
+ expect(page).to have_selector(".gl-pagination .page", count: 2)
+ expect(find(".gl-pagination .page-item.active .page-link").text).to eq("2")
end
end
- describe 'in stopped tab page' do
- it 'should show no environments' do
- visit_environments(project, scope: 'stopped')
+ describe "in stopped tab page" do
+ it "should show no environments" do
+ visit_environments(project, scope: "stopped")
- expect(page).to have_css('.environments-container')
- expect(page).to have_content('You don\'t have any environments right now')
+ expect(page).to have_css(".environments-container")
+ expect(page).to have_content("You don't have any environments right now")
end
end
- context 'when cluster is not reachable' do
+ context "when cluster is not reachable" do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let!(:application_prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
before do
- allow_any_instance_of(Kubeclient::Client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
+ allow_any_instance_of(Kubeclient::Client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, "Unauthorized", nil))
end
- it 'should show one environment without error' do
- visit_environments(project, scope: 'available')
+ it "should show one environment without error" do
+ visit_environments(project, scope: "available")
- expect(page).to have_css('.environments-container')
- expect(page.all('.environment-name').length).to eq(1)
+ expect(page).to have_css(".environments-container")
+ expect(page.all(".environment-name").length).to eq(1)
end
end
end
- describe 'with one stopped environment' do
+ describe "with one stopped environment" do
before do
create(:environment, project: project, state: :stopped)
end
- describe 'in available tab page' do
- it 'should show no environments' do
- visit_environments(project, scope: 'available')
+ describe "in available tab page" do
+ it "should show no environments" do
+ visit_environments(project, scope: "available")
- expect(page).to have_css('.environments-container')
- expect(page).to have_content('You don\'t have any environments right now')
+ expect(page).to have_css(".environments-container")
+ expect(page).to have_content("You don't have any environments right now")
end
end
- describe 'in stopped tab page' do
- it 'should show one environment' do
- visit_environments(project, scope: 'stopped')
+ describe "in stopped tab page" do
+ it "should show one environment" do
+ visit_environments(project, scope: "stopped")
- expect(page).to have_css('.environments-container')
- expect(page.all('.environment-name').length).to eq(1)
+ expect(page).to have_css(".environments-container")
+ expect(page.all(".environment-name").length).to eq(1)
end
end
end
end
- context 'without environments' do
+ context "without environments" do
before do
visit_environments(project)
end
- it 'does not show environments and counters are set to zero' do
- expect(page).to have_content('You don\'t have any environments right now')
+ it "does not show environments and counters are set to zero" do
+ expect(page).to have_content("You don't have any environments right now")
- expect(page.find('.js-environments-tab-available .badge').text).to eq('0')
- expect(page.find('.js-environments-tab-stopped .badge').text).to eq('0')
+ expect(page.find(".js-environments-tab-available .badge").text).to eq("0")
+ expect(page.find(".js-environments-tab-stopped .badge").text).to eq("0")
end
end
- describe 'environments table' do
+ describe "environments table" do
let!(:environment) do
create(:environment, project: project, state: :available)
end
- context 'when there are no deployments' do
+ context "when there are no deployments" do
before do
visit_environments(project)
end
- it 'shows environments names and counters' do
+ it "shows environments names and counters" do
expect(page).to have_link(environment.name)
- expect(page.find('.js-environments-tab-available .badge').text).to eq('1')
- expect(page.find('.js-environments-tab-stopped .badge').text).to eq('0')
+ expect(page.find(".js-environments-tab-available .badge").text).to eq("1")
+ expect(page.find(".js-environments-tab-stopped .badge").text).to eq("0")
end
- it 'does not show deployments' do
- expect(page).to have_content('No deployments yet')
+ it "does not show deployments" do
+ expect(page).to have_content("No deployments yet")
end
- it 'does not show stip button when environment is not stoppable' do
+ it "does not show stip button when environment is not stoppable" do
expect(page).not_to have_selector(stop_button_selector)
end
end
- context 'when there are successful deployments' do
+ context "when there are successful deployments" do
let(:project) { create(:project, :repository) }
let!(:deployment) do
create(:deployment, :success,
- environment: environment,
- sha: project.commit.id)
+ environment: environment,
+ sha: project.commit.id)
end
- it 'shows deployment SHA and internal ID' do
+ it "shows deployment SHA and internal ID" do
visit_environments(project)
expect(page).to have_link(deployment.short_sha)
expect(page).to have_content(deployment.iid)
end
- context 'when builds and manual actions are present' do
+ context "when builds and manual actions are present" do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, pipeline: pipeline) }
let!(:action) do
- create(:ci_build, :manual, pipeline: pipeline, name: 'deploy to production')
+ create(:ci_build, :manual, pipeline: pipeline, name: "deploy to production")
end
let!(:deployment) do
create(:deployment, :success,
- environment: environment,
- deployable: build,
- sha: project.commit.id)
+ environment: environment,
+ deployable: build,
+ sha: project.commit.id)
end
before do
visit_environments(project)
end
- it 'shows a play button' do
- find('.js-environment-actions-dropdown').click
+ it "shows a play button" do
+ find(".js-environment-actions-dropdown").click
expect(page).to have_content(action.name.humanize)
end
- it 'allows to play a manual action', :js do
+ it "allows to play a manual action", :js do
expect(action).to be_manual
- find('.js-environment-actions-dropdown').click
+ find(".js-environment-actions-dropdown").click
expect(page).to have_content(action.name.humanize)
- expect { find('.js-manual-action-link').click }
+ expect { find(".js-manual-action-link").click }
.not_to change { Ci::Pipeline.count }
end
- it 'shows build name and id' do
+ it "shows build name and id" do
expect(page).to have_link("#{build.name} ##{build.id}")
end
- it 'shows a stop button' do
+ it "shows a stop button" do
expect(page).not_to have_selector(stop_button_selector)
end
- it 'does not show external link button' do
- expect(page).not_to have_css('external-url')
+ it "does not show external link button" do
+ expect(page).not_to have_css("external-url")
end
- it 'does not show terminal button' do
+ it "does not show terminal button" do
expect(page).not_to have_terminal_button
end
- context 'with external_url' do
- let(:environment) { create(:environment, project: project, external_url: 'https://git.gitlab.com') }
+ context "with external_url" do
+ let(:environment) { create(:environment, project: project, external_url: "https://git.gitlab.com") }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:deployment) { create(:deployment, :success, environment: environment, deployable: build) }
- it 'shows an external link button' do
+ it "shows an external link button" do
expect(page).to have_link(nil, href: environment.external_url)
end
end
- context 'with stop action' do
+ context "with stop action" do
let(:action) do
- create(:ci_build, :manual, pipeline: pipeline, name: 'close_app')
+ create(:ci_build, :manual, pipeline: pipeline, name: "close_app")
end
let(:deployment) do
create(:deployment, :success,
- environment: environment,
- deployable: build,
- on_stop: 'close_app')
+ environment: environment,
+ deployable: build,
+ on_stop: "close_app")
end
- it 'shows a stop button' do
+ it "shows a stop button" do
expect(page).to have_selector(stop_button_selector)
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
let(:role) { :reporter }
- it 'does not show stop button' do
+ it "does not show stop button" do
expect(page).not_to have_selector(stop_button_selector)
end
end
end
- context 'when kubernetes terminal is available' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- context 'for project maintainer' do
+ context "when kubernetes terminal is available" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ context "for project maintainer" do
let(:role) { :maintainer }
- it 'shows the terminal button' do
+ it "shows the terminal button" do
expect(page).to have_terminal_button
end
end
- context 'when user is a developer' do
+ context "when user is a developer" do
let(:role) { :developer }
- it 'does not show terminal button' do
+ it "does not show terminal button" do
expect(page).not_to have_terminal_button
end
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project, :test_repo) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [create(:project, :repository)]) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
end
- context 'when there is a delayed job' do
+ context "when there is a delayed job" do
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, pipeline: pipeline) }
let!(:delayed_job) do
create(:ci_build, :scheduled,
- pipeline: pipeline,
- name: 'delayed job',
- stage: 'test')
+ pipeline: pipeline,
+ name: "delayed job",
+ stage: "test")
end
let!(:deployment) do
create(:deployment,
- :success,
- environment: environment,
- deployable: build,
- sha: project.commit.id)
+ :success,
+ environment: environment,
+ deployable: build,
+ sha: project.commit.id)
end
before do
visit_environments(project)
end
- it 'has a dropdown for actionable jobs' do
- expect(page).to have_selector('.dropdown-new.btn.btn-default .ic-play')
+ it "has a dropdown for actionable jobs" do
+ expect(page).to have_selector(".dropdown-new.btn.btn-default .ic-play")
end
it "has link to the delayed job's action" do
- find('.js-environment-actions-dropdown').click
+ find(".js-environment-actions-dropdown").click
- expect(page).to have_button('Delayed job')
+ expect(page).to have_button("Delayed job")
expect(page).to have_content(/\d{2}:\d{2}:\d{2}/)
end
- context 'when delayed job is expired already' do
+ context "when delayed job is expired already" do
let!(:delayed_job) do
create(:ci_build, :expired_scheduled,
- pipeline: pipeline,
- name: 'delayed job',
- stage: 'test')
+ pipeline: pipeline,
+ name: "delayed job",
+ stage: "test")
end
it "shows 00:00:00 as the remaining time" do
- find('.js-environment-actions-dropdown').click
+ find(".js-environment-actions-dropdown").click
expect(page).to have_content("00:00:00")
end
end
- context 'when user played a delayed job immediately' do
+ context "when user played a delayed job immediately" do
before do
- find('.js-environment-actions-dropdown').click
- page.accept_confirm { click_button('Delayed job') }
+ find(".js-environment-actions-dropdown").click
+ page.accept_confirm { click_button("Delayed job") }
wait_for_requests
end
- it 'enqueues the delayed job', :js do
+ it "enqueues the delayed job", :js do
expect(delayed_job.reload).to be_pending
end
end
end
end
- context 'when there is a failed deployment' do
+ context "when there is a failed deployment" do
let(:project) { create(:project, :repository) }
let!(:deployment) do
create(:deployment, :failed,
- environment: environment,
- sha: project.commit.id)
+ environment: environment,
+ sha: project.commit.id)
end
- it 'does not show deployments' do
+ it "does not show deployments" do
visit_environments(project)
- expect(page).to have_content('No deployments yet')
+ expect(page).to have_content("No deployments yet")
end
end
end
- it 'does have a new environment button' do
+ it "does have a new environment button" do
visit_environments(project)
- expect(page).to have_link('New environment')
+ expect(page).to have_link("New environment")
end
- describe 'creating a new environment' do
+ describe "creating a new environment" do
before do
visit_environments(project)
end
- context 'user is a developer' do
+ context "user is a developer" do
let(:role) { :developer }
- it 'developer creates a new environment with a valid name' do
- within(".top-area") { click_link 'New environment' }
- fill_in('Name', with: 'production')
- click_on 'Save'
+ it "developer creates a new environment with a valid name" do
+ within(".top-area") { click_link "New environment" }
+ fill_in("Name", with: "production")
+ click_on "Save"
- expect(page).to have_content('production')
+ expect(page).to have_content("production")
end
- it 'developer creates a new environmetn with invalid name' do
- within(".top-area") { click_link 'New environment' }
- fill_in('Name', with: 'name,with,commas')
- click_on 'Save'
+ it "developer creates a new environmetn with invalid name" do
+ within(".top-area") { click_link "New environment" }
+ fill_in("Name", with: "name,with,commas")
+ click_on "Save"
- expect(page).to have_content('Name can contain only letters')
+ expect(page).to have_content("Name can contain only letters")
end
end
- context 'user is a reporter' do
+ context "user is a reporter" do
let(:role) { :reporter }
- it 'reporters tries to create a new environment' do
- expect(page).not_to have_link('New environment')
+ it "reporters tries to create a new environment" do
+ expect(page).not_to have_link("New environment")
end
end
end
- describe 'environments folders' do
+ describe "environments folders" do
before do
create(:environment, project: project,
- name: 'staging/review-1',
+ name: "staging/review-1",
state: :available)
create(:environment, project: project,
- name: 'staging/review-2',
+ name: "staging/review-2",
state: :available)
end
- it 'users unfurls an environment folder' do
+ it "users unfurls an environment folder" do
visit_environments(project)
- expect(page).not_to have_content 'review-1'
- expect(page).not_to have_content 'review-2'
- expect(page).to have_content 'staging 2'
+ expect(page).not_to have_content "review-1"
+ expect(page).not_to have_content "review-2"
+ expect(page).to have_content "staging 2"
- within('.folder-row') do
- find('.folder-name', text: 'staging').click
+ within(".folder-row") do
+ find(".folder-name", text: "staging").click
end
- expect(page).to have_content 'review-1'
- expect(page).to have_content 'review-2'
+ expect(page).to have_content "review-1"
+ expect(page).to have_content "review-2"
end
end
- describe 'environments folders view' do
+ describe "environments folders view" do
before do
create(:environment, project: project,
- name: 'staging.review/review-1',
+ name: "staging.review/review-1",
state: :available)
create(:environment, project: project,
- name: 'staging.review/review-2',
+ name: "staging.review/review-2",
state: :available)
end
- it 'user opens folder view' do
- visit folder_project_environments_path(project, 'staging.review')
+ it "user opens folder view" do
+ visit folder_project_environments_path(project, "staging.review")
wait_for_requests
- expect(page).to have_content('Environments / staging.review')
- expect(page).to have_content('review-1')
- expect(page).to have_content('review-2')
+ expect(page).to have_content("Environments / staging.review")
+ expect(page).to have_content("review-1")
+ expect(page).to have_content("review-2")
end
end
diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb
index ab16fdee883..429b1515068 100644
--- a/spec/features/projects/features_visibility_spec.rb
+++ b/spec/features/projects/features_visibility_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Edit Project Settings' do
+describe "Edit Project Settings" do
let(:member) { create(:user) }
let!(:project) { create(:project, :public, :repository) }
let!(:issue) { create(:issue, project: project) }
let(:non_member) { create(:user) }
- describe 'project features visibility selectors', :js do
+ describe "project features visibility selectors", :js do
before do
project.add_maintainer(member)
sign_in(member)
end
- tools = { builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests" }
+ tools = {builds: "pipelines", issues: "issues", wiki: "wiki", snippets: "snippets", merge_requests: "merge_requests"}
tools.each do |tool_name, shortcut_name|
describe "feature #{tool_name}" do
- it 'toggles visibility' do
+ it "toggles visibility" do
visit edit_project_path(project)
# disable by clicking toggle
toggle_feature_off("project[project_feature_attributes][#{tool_name}_access_level]")
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
find('input[value="Save changes"]').click
end
wait_for_requests
@@ -29,7 +29,7 @@ describe 'Edit Project Settings' do
# re-enable by clicking toggle again
toggle_feature_on("project[project_feature_attributes][#{tool_name}_access_level]")
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
find('input[value="Save changes"]').click
end
wait_for_requests
@@ -38,25 +38,25 @@ describe 'Edit Project Settings' do
end
end
- context 'When external issue tracker is enabled and issues enabled on project settings' do
- it 'does not hide issues tab' do
+ context "When external issue tracker is enabled and issues enabled on project settings" do
+ it "does not hide issues tab" do
allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(JiraService.new)
visit project_path(project)
- expect(page).to have_selector('.shortcuts-issues')
+ expect(page).to have_selector(".shortcuts-issues")
end
end
- context 'When external issue tracker is enabled and issues disabled on project settings' do
- it 'hides issues tab' do
+ context "When external issue tracker is enabled and issues disabled on project settings" do
+ it "hides issues tab" do
project.issues_enabled = false
project.save!
allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(JiraService.new)
visit project_path(project)
- expect(page).not_to have_selector('.shortcuts-issues')
+ expect(page).not_to have_selector(".shortcuts-issues")
end
end
@@ -77,7 +77,7 @@ describe 'Edit Project Settings' do
end
end
- describe 'project features visibility pages' do
+ describe "project features visibility pages" do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:job) { create(:ci_build, pipeline: pipeline) }
@@ -87,16 +87,16 @@ describe 'Edit Project Settings' do
issues: project_issues_path(project),
wiki: project_wiki_path(project, :home),
snippets: project_snippets_path(project),
- merge_requests: project_merge_requests_path(project)
+ merge_requests: project_merge_requests_path(project),
}
end
- context 'normal user' do
+ context "normal user" do
before do
sign_in(member)
end
- it 'renders 200 if tool is enabled' do
+ it "renders 200 if tool is enabled" do
tools.each do |method_name, url|
project.project_feature.update_attribute("#{method_name}_access_level", ProjectFeature::ENABLED)
visit url
@@ -104,7 +104,7 @@ describe 'Edit Project Settings' do
end
end
- it 'renders 404 if feature is disabled' do
+ it "renders 404 if feature is disabled" do
tools.each do |method_name, url|
project.project_feature.update_attribute("#{method_name}_access_level", ProjectFeature::DISABLED)
visit url
@@ -112,7 +112,7 @@ describe 'Edit Project Settings' do
end
end
- it 'renders 404 if feature is enabled only for team members' do
+ it "renders 404 if feature is enabled only for team members" do
project.team.truncate
tools.each do |method_name, url|
@@ -122,7 +122,7 @@ describe 'Edit Project Settings' do
end
end
- it 'renders 200 if user is member of group' do
+ it "renders 200 if user is member of group" do
group = create(:group)
project.group = group
project.save
@@ -137,13 +137,13 @@ describe 'Edit Project Settings' do
end
end
- context 'admin user' do
+ context "admin user" do
before do
non_member.update_attribute(:admin, true)
sign_in(non_member)
end
- it 'renders 404 if feature is disabled' do
+ it "renders 404 if feature is disabled" do
tools.each do |method_name, url|
project.project_feature.update_attribute("#{method_name}_access_level", ProjectFeature::DISABLED)
visit url
@@ -151,7 +151,7 @@ describe 'Edit Project Settings' do
end
end
- it 'renders 200 if feature is enabled only for team members' do
+ it "renders 200 if feature is enabled only for team members" do
project.team.truncate
tools.each do |method_name, url|
@@ -163,7 +163,7 @@ describe 'Edit Project Settings' do
end
end
- describe 'repository visibility', :js do
+ describe "repository visibility", :js do
before do
project.add_maintainer(member)
sign_in(member)
@@ -171,9 +171,9 @@ describe 'Edit Project Settings' do
end
it "disables repository related features" do
- toggle_feature_off('project[project_feature_attributes][repository_access_level]')
+ toggle_feature_off("project[project_feature_attributes][repository_access_level]")
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
click_button "Save changes"
end
@@ -181,11 +181,11 @@ describe 'Edit Project Settings' do
end
it "shows empty features project homepage" do
- toggle_feature_off('project[project_feature_attributes][repository_access_level]')
- toggle_feature_off('project[project_feature_attributes][issues_access_level]')
- toggle_feature_off('project[project_feature_attributes][wiki_access_level]')
+ toggle_feature_off("project[project_feature_attributes][repository_access_level]")
+ toggle_feature_off("project[project_feature_attributes][issues_access_level]")
+ toggle_feature_off("project[project_feature_attributes][wiki_access_level]")
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
click_button "Save changes"
end
wait_for_requests
@@ -196,11 +196,11 @@ describe 'Edit Project Settings' do
end
it "hides project activity tabs" do
- toggle_feature_off('project[project_feature_attributes][repository_access_level]')
- toggle_feature_off('project[project_feature_attributes][issues_access_level]')
- toggle_feature_off('project[project_feature_attributes][wiki_access_level]')
+ toggle_feature_off("project[project_feature_attributes][repository_access_level]")
+ toggle_feature_off("project[project_feature_attributes][issues_access_level]")
+ toggle_feature_off("project[project_feature_attributes][wiki_access_level]")
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
click_button "Save changes"
end
wait_for_requests
@@ -217,7 +217,7 @@ describe 'Edit Project Settings' do
# Regression spec for https://gitlab.com/gitlab-org/gitlab-ce/issues/25272
it "hides comments activity tab only on disabled issues, merge requests and repository" do
- toggle_feature_off('project[project_feature_attributes][issues_access_level]')
+ toggle_feature_off("project[project_feature_attributes][issues_access_level]")
save_changes_and_check_activity_tab do
expect(page).to have_content("Comments")
@@ -225,7 +225,7 @@ describe 'Edit Project Settings' do
visit edit_project_path(project)
- toggle_feature_off('project[project_feature_attributes][merge_requests_access_level]')
+ toggle_feature_off("project[project_feature_attributes][merge_requests_access_level]")
save_changes_and_check_activity_tab do
expect(page).to have_content("Comments")
@@ -233,7 +233,7 @@ describe 'Edit Project Settings' do
visit edit_project_path(project)
- toggle_feature_off('project[project_feature_attributes][repository_access_level]')
+ toggle_feature_off("project[project_feature_attributes][repository_access_level]")
save_changes_and_check_activity_tab do
expect(page).not_to have_content("Comments")
@@ -243,7 +243,7 @@ describe 'Edit Project Settings' do
end
def save_changes_and_check_activity_tab
- page.within('.sharing-permissions') do
+ page.within(".sharing-permissions") do
click_button "Save changes"
end
wait_for_requests
@@ -257,7 +257,7 @@ describe 'Edit Project Settings' do
end
# Regression spec for https://gitlab.com/gitlab-org/gitlab-ce/issues/24056
- describe 'project statistic visibility' do
+ describe "project statistic visibility" do
let!(:project) { create(:project, :private) }
before do
@@ -267,7 +267,7 @@ describe 'Edit Project Settings' do
end
it "does not show project statistic for guest" do
- expect(page).not_to have_selector('.project-stats')
+ expect(page).not_to have_selector(".project-stats")
end
end
diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb
index 004585f7c9e..5f399c5e5ea 100644
--- a/spec/features/projects/files/dockerfile_dropdown_spec.rb
+++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User wants to add a Dockerfile file' do
+describe "Projects > Files > User wants to add a Dockerfile file" do
before do
project = create(:project, :repository)
sign_in project.owner
- visit project_new_blob_path(project, 'master', file_name: 'Dockerfile')
+ visit project_new_blob_path(project, "master", file_name: "Dockerfile")
end
- it 'user can pick a Dockerfile file from the dropdown', :js do
- expect(page).to have_css('.dockerfile-selector')
+ it "user can pick a Dockerfile file from the dropdown", :js do
+ expect(page).to have_css(".dockerfile-selector")
- find('.js-dockerfile-selector').click
+ find(".js-dockerfile-selector").click
wait_for_requests
- within '.dockerfile-selector' do
- find('.dropdown-input-field').set('HTTPd')
- find('.dropdown-content li', text: 'HTTPd').click
+ within ".dockerfile-selector" do
+ find(".dropdown-input-field").set("HTTPd")
+ find(".dropdown-content li", text: "HTTPd").click
end
wait_for_requests
- expect(page).to have_css('.dockerfile-selector .dropdown-toggle-text', text: 'HTTPd')
- expect(page).to have_content('COPY ./ /usr/local/apache2/htdocs/')
+ expect(page).to have_css(".dockerfile-selector .dropdown-toggle-text", text: "HTTPd")
+ expect(page).to have_content("COPY ./ /usr/local/apache2/htdocs/")
end
end
diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb
index 03cb3530e2b..3ab99e4f09a 100644
--- a/spec/features/projects/files/download_buttons_spec.rb
+++ b/spec/features/projects/files/download_buttons_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Download buttons in files tree' do
+describe "Projects > Files > Download buttons in files tree" do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit.sha,
- ref: project.default_branch,
- status: 'success')
+ project: project,
+ sha: project.commit.sha,
+ ref: project.default_branch,
+ status: "success")
end
let!(:build) do
create(:ci_build, :success, :artifacts,
- pipeline: pipeline,
- status: pipeline.status,
- name: 'build')
+ pipeline: pipeline,
+ status: pipeline.status,
+ name: "build")
end
before do
@@ -26,9 +26,9 @@ describe 'Projects > Files > Download buttons in files tree' do
visit project_tree_path(project, project.default_branch)
end
- context 'with artifacts' do
- it 'shows download artifacts button' do
- href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
+ context "with artifacts" do
+ it "shows download artifacts button" do
+ href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: "build")
expect(page).to have_link "Download '#{build.name}'", href: href
end
diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
index 41af70d8ebc..67279b2b445 100644
--- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb
+++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User uses soft wrap whilst editing file', :js do
+describe "Projects > Files > User uses soft wrap whilst editing file", :js do
before do
project = create(:project, :repository)
user = project.owner
sign_in user
- visit project_new_blob_path(project, 'master', file_name: 'test_file-name')
- page.within('.file-editor.code') do
- find('.ace_text-input', visible: false).send_keys 'Touch water with paw then recoil in horror chase dog then
+ visit project_new_blob_path(project, "master", file_name: "test_file-name")
+ page.within(".file-editor.code") do
+ find(".ace_text-input", visible: false).send_keys 'Touch water with paw then recoil in horror chase dog then
run away chase the pig around the house eat owner\'s food, and knock
dish off table head butt cant eat out of my own dish. Cat is love, cat
is life rub face on everything poop on grasses so meow. Playing with
@@ -20,21 +20,21 @@ describe 'Projects > Files > User uses soft wrap whilst editing file', :js do
end
end
- let(:toggle_button) { find('.soft-wrap-toggle') }
+ let(:toggle_button) { find(".soft-wrap-toggle") }
it 'user clicks the "Soft wrap" button and then "No wrap" button' do
wrapped_content_width = get_content_width
toggle_button.click
- expect(toggle_button).to have_content 'No wrap'
+ expect(toggle_button).to have_content "No wrap"
unwrapped_content_width = get_content_width
expect(unwrapped_content_width).to be < wrapped_content_width
toggle_button.click
- expect(toggle_button).to have_content 'Soft wrap'
+ expect(toggle_button).to have_content "Soft wrap"
expect(get_content_width).to be > unwrapped_content_width
end
def get_content_width
- find('.ace_content')[:style].slice!(/width: \d+/).slice!(/\d+/).to_i
+ find(".ace_content")[:style].slice!(/width: \d+/).slice!(/\d+/).to_i
end
end
diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb
index 4074e67e2d2..23bdcb59bac 100644
--- a/spec/features/projects/files/editing_a_file_spec.rb
+++ b/spec/features/projects/files/editing_a_file_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User wants to edit a file' do
+describe "Projects > Files > User wants to edit a file" do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:commit_params) do
@@ -11,21 +11,21 @@ describe 'Projects > Files > User wants to edit a file' do
file_path: ".gitignore",
file_content: "First Update",
last_commit_sha: Gitlab::Git::Commit.last_for_path(project.repository, project.default_branch,
- ".gitignore").sha
+ ".gitignore").sha,
}
end
before do
sign_in user
visit project_edit_blob_path(project,
- File.join(project.default_branch, '.gitignore'))
+ File.join(project.default_branch, ".gitignore"))
end
- it 'file has been updated since the user opened the edit page' do
+ it "file has been updated since the user opened the edit page" do
Files::UpdateService.new(project, user, commit_params).execute
- click_button 'Commit changes'
+ click_button "Commit changes"
- expect(page).to have_content 'Someone edited the file the same time you did.'
+ expect(page).to have_content "Someone edited the file the same time you did."
end
end
diff --git a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
index b6dbf76bc9b..7a60fc6ca77 100644
--- a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
+++ b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User views files page' do
+describe "Projects > Files > User views files page" do
let(:project) { create(:forked_project_with_submodules) }
let(:user) { project.owner }
@@ -9,15 +9,15 @@ describe 'Projects > Files > User views files page' do
visit project_tree_path(project, project.repository.root_ref)
end
- it 'user sees folders and submodules sorted together, followed by files' do
- rows = all('td.tree-item-file-name').map(&:text)
+ it "user sees folders and submodules sorted together, followed by files" do
+ rows = all("td.tree-item-file-name").map(&:text)
tree = project.repository.tree
folders = tree.trees.map(&:name)
files = tree.blobs.map(&:name)
- submodules = tree.submodules.map do |submodule|
+ submodules = tree.submodules.map { |submodule|
submodule.name + " @ " + submodule.id[0..7]
- end
+ }
sorted_titles = (folders + submodules).sort + files
diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb
index cd0235f2b9e..cd1c397b233 100644
--- a/spec/features/projects/files/find_file_keyboard_spec.rb
+++ b/spec/features/projects/files/find_file_keyboard_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Find file keyboard shortcuts', :js do
+describe "Projects > Files > Find file keyboard shortcuts", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
@@ -12,28 +12,28 @@ describe 'Projects > Files > Find file keyboard shortcuts', :js do
wait_for_requests
end
- it 'opens file when pressing enter key' do
- fill_in 'file_find', with: 'CHANGELOG'
+ it "opens file when pressing enter key" do
+ fill_in "file_find", with: "CHANGELOG"
- find('#file_find').native.send_keys(:enter)
+ find("#file_find").native.send_keys(:enter)
- expect(page).to have_selector('.blob-content-holder')
+ expect(page).to have_selector(".blob-content-holder")
- page.within('.js-file-title') do
- expect(page).to have_content('CHANGELOG')
+ page.within(".js-file-title") do
+ expect(page).to have_content("CHANGELOG")
end
end
- it 'navigates files with arrow keys' do
- fill_in 'file_find', with: 'application.'
+ it "navigates files with arrow keys" do
+ fill_in "file_find", with: "application."
- find('#file_find').native.send_keys(:down)
- find('#file_find').native.send_keys(:enter)
+ find("#file_find").native.send_keys(:down)
+ find("#file_find").native.send_keys(:enter)
- expect(page).to have_selector('.blob-content-holder')
+ expect(page).to have_selector(".blob-content-holder")
- page.within('.js-file-title') do
- expect(page).to have_content('application.js')
+ page.within(".js-file-title") do
+ expect(page).to have_content("application.js")
end
end
end
diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb
index 9fa4c053a40..694f93bb634 100644
--- a/spec/features/projects/files/gitignore_dropdown_spec.rb
+++ b/spec/features/projects/files/gitignore_dropdown_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User wants to add a .gitignore file' do
+describe "Projects > Files > User wants to add a .gitignore file" do
before do
project = create(:project, :repository)
sign_in project.owner
- visit project_new_blob_path(project, 'master', file_name: '.gitignore')
+ visit project_new_blob_path(project, "master", file_name: ".gitignore")
end
- it 'user can pick a .gitignore file from the dropdown', :js do
- expect(page).to have_css('.gitignore-selector')
+ it "user can pick a .gitignore file from the dropdown", :js do
+ expect(page).to have_css(".gitignore-selector")
- find('.js-gitignore-selector').click
+ find(".js-gitignore-selector").click
wait_for_requests
- within '.gitignore-selector' do
- find('.dropdown-input-field').set('rails')
- find('.dropdown-content li', text: 'Rails').click
+ within ".gitignore-selector" do
+ find(".dropdown-input-field").set("rails")
+ find(".dropdown-content li", text: "Rails").click
end
wait_for_requests
- expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails')
- expect(page).to have_content('/.bundle')
- expect(page).to have_content('# Gemfile.lock, .ruby-version, .ruby-gemset')
+ expect(page).to have_css(".gitignore-selector .dropdown-toggle-text", text: "Rails")
+ expect(page).to have_content("/.bundle")
+ expect(page).to have_content("# Gemfile.lock, .ruby-version, .ruby-gemset")
end
end
diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
index 53aff183562..8f735fa19a9 100644
--- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
+++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do
+describe "Projects > Files > User wants to add a .gitlab-ci.yml file" do
before do
project = create(:project, :repository)
sign_in project.owner
- visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml')
+ visit project_new_blob_path(project, "master", file_name: ".gitlab-ci.yml")
end
- it 'user can pick a template from the dropdown', :js do
- expect(page).to have_css('.gitlab-ci-yml-selector')
+ it "user can pick a template from the dropdown", :js do
+ expect(page).to have_css(".gitlab-ci-yml-selector")
- find('.js-gitlab-ci-yml-selector').click
+ find(".js-gitlab-ci-yml-selector").click
wait_for_requests
- within '.gitlab-ci-yml-selector' do
- find('.dropdown-input-field').set('Jekyll')
- find('.dropdown-content li', text: 'Jekyll').click
+ within ".gitlab-ci-yml-selector" do
+ find(".dropdown-input-field").set("Jekyll")
+ find(".dropdown-content li", text: "Jekyll").click
end
wait_for_requests
- expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll')
- expect(page).to have_content('This file is a template, and might need editing before it works on your project')
- expect(page).to have_content('jekyll build -d test')
+ expect(page).to have_css(".gitlab-ci-yml-selector .dropdown-toggle-text", text: "Jekyll")
+ expect(page).to have_content("This file is a template, and might need editing before it works on your project")
+ expect(page).to have_content("jekyll build -d test")
end
end
diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb
index 6762460971f..caf495bc6c5 100644
--- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb
+++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb
@@ -1,67 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Project owner creates a license file', :js do
+describe "Projects > Files > Project owner creates a license file", :js do
let(:project) { create(:project, :repository) }
let(:project_maintainer) { project.owner }
before do
- project.repository.delete_file(project_maintainer, 'LICENSE',
- message: 'Remove LICENSE', branch_name: 'master')
+ project.repository.delete_file(project_maintainer, "LICENSE",
+ message: "Remove LICENSE", branch_name: "master")
sign_in(project_maintainer)
visit project_path(project)
end
- it 'project maintainer creates a license file manually from a template' do
+ it "project maintainer creates a license file manually from a template" do
visit project_tree_path(project, project.repository.root_ref)
- find('.add-to-tree').click
- click_link 'New file'
+ find(".add-to-tree").click
+ click_link "New file"
- fill_in :file_name, with: 'LICENSE'
+ fill_in :file_name, with: "LICENSE"
- expect(page).to have_selector('.license-selector')
+ expect(page).to have_selector(".license-selector")
- select_template('MIT License')
+ select_template("MIT License")
- file_content = first('.file-editor')
- expect(file_content).to have_content('MIT License')
+ file_content = first(".file-editor")
+ expect(file_content).to have_content("MIT License")
expect(file_content).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
- fill_in :commit_message, with: 'Add a LICENSE file', visible: true
- click_button 'Commit changes'
+ fill_in :commit_message, with: "Add a LICENSE file", visible: true
+ click_button "Commit changes"
expect(current_path).to eq(
- project_blob_path(project, 'master/LICENSE'))
- expect(page).to have_content('MIT License')
+ project_blob_path(project, "master/LICENSE")
+ )
+ expect(page).to have_content("MIT License")
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
end
it 'project maintainer creates a license file from the "Add license" link' do
- click_link 'Add license'
+ click_link "Add license"
- expect(page).to have_content('New file')
+ expect(page).to have_content("New file")
expect(current_path).to eq(
- project_new_blob_path(project, 'master'))
- expect(find('#file_name').value).to eq('LICENSE')
- expect(page).to have_selector('.license-selector')
+ project_new_blob_path(project, "master")
+ )
+ expect(find("#file_name").value).to eq("LICENSE")
+ expect(page).to have_selector(".license-selector")
- select_template('MIT License')
+ select_template("MIT License")
- file_content = first('.file-editor')
- expect(file_content).to have_content('MIT License')
+ file_content = first(".file-editor")
+ expect(file_content).to have_content("MIT License")
expect(file_content).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
- fill_in :commit_message, with: 'Add a LICENSE file', visible: true
- click_button 'Commit changes'
+ fill_in :commit_message, with: "Add a LICENSE file", visible: true
+ click_button "Commit changes"
expect(current_path).to eq(
- project_blob_path(project, 'master/LICENSE'))
- expect(page).to have_content('MIT License')
+ project_blob_path(project, "master/LICENSE")
+ )
+ expect(page).to have_content("MIT License")
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
end
def select_template(template)
- page.within('.js-license-selector-wrap') do
- click_button 'Apply a license template'
+ page.within(".js-license-selector-wrap") do
+ click_button "Apply a license template"
click_link template
wait_for_requests
end
diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
index 0b8474fb87a..bf9e62ff4eb 100644
--- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
+++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do
+describe "Projects > Files > Project owner sees a link to create a license file in empty project", :js do
let(:project) { create(:project_empty_repo) }
let(:project_maintainer) { project.owner }
@@ -8,34 +8,36 @@ describe 'Projects > Files > Project owner sees a link to create a license file
sign_in(project_maintainer)
end
- it 'project maintainer creates a license file from a template' do
+ it "project maintainer creates a license file from a template" do
visit project_path(project)
- click_on 'Add license'
- expect(page).to have_content('New file')
+ click_on "Add license"
+ expect(page).to have_content("New file")
expect(current_path).to eq(
- project_new_blob_path(project, 'master'))
- expect(find('#file_name').value).to eq('LICENSE')
- expect(page).to have_selector('.license-selector')
+ project_new_blob_path(project, "master")
+ )
+ expect(find("#file_name").value).to eq("LICENSE")
+ expect(page).to have_selector(".license-selector")
- select_template('MIT License')
+ select_template("MIT License")
- file_content = first('.file-editor')
- expect(file_content).to have_content('MIT License')
+ file_content = first(".file-editor")
+ expect(file_content).to have_content("MIT License")
expect(file_content).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
- fill_in :commit_message, with: 'Add a LICENSE file', visible: true
- click_button 'Commit changes'
+ fill_in :commit_message, with: "Add a LICENSE file", visible: true
+ click_button "Commit changes"
expect(current_path).to eq(
- project_blob_path(project, 'master/LICENSE'))
- expect(page).to have_content('MIT License')
+ project_blob_path(project, "master/LICENSE")
+ )
+ expect(page).to have_content("MIT License")
expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}")
end
def select_template(template)
- page.within('.js-license-selector-wrap') do
- click_button 'Apply a license template'
+ page.within(".js-license-selector-wrap") do
+ click_button "Apply a license template"
click_link template
wait_for_requests
end
diff --git a/spec/features/projects/files/template_selector_menu_spec.rb b/spec/features/projects/files/template_selector_menu_spec.rb
index 6b313824acd..1ad28833aef 100644
--- a/spec/features/projects/files/template_selector_menu_spec.rb
+++ b/spec/features/projects/files/template_selector_menu_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Template selector menu', :js do
+describe "Template selector menu", :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -9,45 +9,45 @@ describe 'Template selector menu', :js do
sign_in user
end
- context 'editing a non-matching file' do
+ context "editing a non-matching file" do
before do
- create_and_edit_file('README.md')
+ create_and_edit_file("README.md")
end
- it 'is not displayed' do
+ it "is not displayed" do
check_template_selector_menu_display(false)
end
- context 'user toggles preview' do
+ context "user toggles preview" do
before do
- click_link 'Preview'
+ click_link "Preview"
end
- it 'template selector menu is not displayed' do
+ it "template selector menu is not displayed" do
check_template_selector_menu_display(false)
- click_link 'Write'
+ click_link "Write"
check_template_selector_menu_display(false)
end
end
end
- context 'editing a matching file' do
+ context "editing a matching file" do
before do
- visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
+ visit project_edit_blob_path(project, File.join(project.default_branch, "LICENSE"))
end
- it 'is displayed' do
+ it "is displayed" do
check_template_selector_menu_display(true)
end
- context 'user toggles preview' do
+ context "user toggles preview" do
before do
- click_link 'Preview'
+ click_link "Preview"
end
- it 'template selector menu is hidden and shown correctly' do
+ it "template selector menu is hidden and shown correctly" do
check_template_selector_menu_display(false)
- click_link 'Write'
+ click_link "Write"
check_template_selector_menu_display(true)
end
end
@@ -56,11 +56,11 @@ end
def check_template_selector_menu_display(is_visible)
count = is_visible ? 1 : 0
- expect(page).to have_css('.template-selectors-menu', count: count)
+ expect(page).to have_css(".template-selectors-menu", count: count)
end
def create_and_edit_file(file_name)
- visit project_new_blob_path(project, 'master', file_name: file_name)
+ visit project_new_blob_path(project, "master", file_name: file_name)
click_button "Commit changes"
visit project_edit_blob_path(project, File.join(project.default_branch, file_name))
end
diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb
index 342a93b328f..2f54edb5eda 100644
--- a/spec/features/projects/files/template_type_dropdown_spec.rb
+++ b/spec/features/projects/files/template_type_dropdown_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Template type dropdown selector', :js do
+describe "Projects > Files > Template type dropdown selector", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
@@ -8,88 +8,88 @@ describe 'Projects > Files > Template type dropdown selector', :js do
sign_in user
end
- context 'editing a non-matching file' do
+ context "editing a non-matching file" do
before do
- create_and_edit_file('.random-file.js')
+ create_and_edit_file(".random-file.js")
end
- it 'not displayed' do
+ it "not displayed" do
check_type_selector_display(false)
end
- it 'selects every template type correctly' do
- fill_in 'file_path', with: '.gitignore'
+ it "selects every template type correctly" do
+ fill_in "file_path", with: ".gitignore"
try_selecting_all_types
end
- it 'updates toggle value when input matches' do
- fill_in 'file_path', with: '.gitignore'
- check_type_selector_toggle_text('.gitignore')
+ it "updates toggle value when input matches" do
+ fill_in "file_path", with: ".gitignore"
+ check_type_selector_toggle_text(".gitignore")
end
end
- context 'editing a matching file' do
+ context "editing a matching file" do
before do
- visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
+ visit project_edit_blob_path(project, File.join(project.default_branch, "LICENSE"))
end
- it 'displayed' do
+ it "displayed" do
check_type_selector_display(true)
end
- it 'is displayed when input matches' do
+ it "is displayed when input matches" do
check_type_selector_display(true)
end
- it 'selects every template type correctly' do
+ it "selects every template type correctly" do
try_selecting_all_types
end
- context 'user previews changes' do
+ context "user previews changes" do
before do
- click_link 'Preview changes'
+ click_link "Preview changes"
end
- it 'type selector is hidden and shown correctly' do
+ it "type selector is hidden and shown correctly" do
check_type_selector_display(false)
- click_link 'Write'
+ click_link "Write"
check_type_selector_display(true)
end
end
end
- context 'creating a matching file' do
+ context "creating a matching file" do
before do
- visit project_new_blob_path(project, 'master', file_name: '.gitignore')
+ visit project_new_blob_path(project, "master", file_name: ".gitignore")
end
- it 'is displayed' do
+ it "is displayed" do
check_type_selector_display(true)
end
- it 'toggle is set to the correct value' do
- check_type_selector_toggle_text('.gitignore')
+ it "toggle is set to the correct value" do
+ check_type_selector_toggle_text(".gitignore")
end
- it 'selects every template type correctly' do
+ it "selects every template type correctly" do
try_selecting_all_types
end
end
- context 'creating a file' do
+ context "creating a file" do
before do
visit project_new_blob_path(project, project.default_branch)
end
- it 'type selector is shown' do
+ it "type selector is shown" do
check_type_selector_display(true)
end
- it 'toggle is set to the proper value' do
- check_type_selector_toggle_text('Choose type')
+ it "toggle is set to the proper value" do
+ check_type_selector_toggle_text("Choose type")
end
- it 'selects every template type correctly' do
+ it "selects every template type correctly" do
try_selecting_all_types
end
end
@@ -97,14 +97,14 @@ end
def check_type_selector_display(is_visible)
count = is_visible ? 1 : 0
- expect(page).to have_css('.js-template-type-selector', count: count)
+ expect(page).to have_css(".js-template-type-selector", count: count)
end
def try_selecting_all_types
- try_selecting_template_type('LICENSE', 'Apply a license template')
- try_selecting_template_type('Dockerfile', 'Apply a Dockerfile template')
- try_selecting_template_type('.gitlab-ci.yml', 'Apply a GitLab CI Yaml template')
- try_selecting_template_type('.gitignore', 'Apply a .gitignore template')
+ try_selecting_template_type("LICENSE", "Apply a license template")
+ try_selecting_template_type("Dockerfile", "Apply a Dockerfile template")
+ try_selecting_template_type(".gitlab-ci.yml", "Apply a GitLab CI Yaml template")
+ try_selecting_template_type(".gitignore", "Apply a .gitignore template")
end
def try_selecting_template_type(template_type, selector_label)
@@ -114,8 +114,8 @@ def try_selecting_template_type(template_type, selector_label)
end
def select_template_type(template_type)
- find('.js-template-type-selector').click
- find('.dropdown-content li', text: template_type).click
+ find(".js-template-type-selector").click
+ find(".dropdown-content li", text: template_type).click
end
def check_template_selector_display(content)
@@ -123,12 +123,12 @@ def check_template_selector_display(content)
end
def check_type_selector_toggle_text(template_type)
- dropdown_toggle_button = find('.template-type-selector .dropdown-toggle-text')
+ dropdown_toggle_button = find(".template-type-selector .dropdown-toggle-text")
expect(dropdown_toggle_button).to have_content(template_type)
end
def create_and_edit_file(file_name)
- visit project_new_blob_path(project, 'master', file_name: file_name)
+ visit project_new_blob_path(project, "master", file_name: file_name)
click_button "Commit changes"
visit project_edit_blob_path(project, File.join(project.default_branch, file_name))
end
diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb
index fa785ed10ef..1fc526fcc94 100644
--- a/spec/features/projects/files/undo_template_spec.rb
+++ b/spec/features/projects/files/undo_template_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > Template Undo Button', :js do
+describe "Projects > Files > Template Undo Button", :js do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
@@ -8,26 +8,26 @@ describe 'Projects > Files > Template Undo Button', :js do
sign_in user
end
- context 'editing a matching file and applying a template' do
+ context "editing a matching file and applying a template" do
before do
visit project_edit_blob_path(project, File.join(project.default_branch, "LICENSE"))
- select_file_template('.js-license-selector', 'Apache License 2.0')
+ select_file_template(".js-license-selector", "Apache License 2.0")
end
- it 'reverts template application' do
- try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
+ it "reverts template application" do
+ try_template_undo("http://www.apache.org/licenses/", "Apply a license template")
end
end
- context 'creating a non-matching file' do
+ context "creating a non-matching file" do
before do
- visit project_new_blob_path(project, 'master')
- select_file_template_type('LICENSE')
- select_file_template('.js-license-selector', 'Apache License 2.0')
+ visit project_new_blob_path(project, "master")
+ select_file_template_type("LICENSE")
+ select_file_template(".js-license-selector", "Apache License 2.0")
end
- it 'reverts template application' do
- try_template_undo('http://www.apache.org/licenses/', 'Apply a license template')
+ it "reverts template application" do
+ try_template_undo("http://www.apache.org/licenses/", "Apply a license template")
end
end
end
@@ -43,23 +43,23 @@ def check_toggle_text_set(neutral_toggle_text)
end
def check_undo_button_display
- expect(page).to have_content('Template applied')
- expect(page).to have_css('.template-selectors-undo-menu .btn-info')
+ expect(page).to have_content("Template applied")
+ expect(page).to have_css(".template-selectors-undo-menu .btn-info")
end
def check_content_reverted(template_content)
- find('.template-selectors-undo-menu .btn-info').click
+ find(".template-selectors-undo-menu .btn-info").click
expect(page).not_to have_content(template_content)
- expect(find('.template-type-selector .dropdown-toggle-text')).to have_content
+ expect(find(".template-type-selector .dropdown-toggle-text")).to have_content
end
def select_file_template(template_selector_selector, template_name)
find(template_selector_selector).click
- find('.dropdown-content li', text: template_name).click
+ find(".dropdown-content li", text: template_name).click
wait_for_requests
end
def select_file_template_type(template_type)
- find('.js-template-type-selector').click
- find('.dropdown-content li', text: template_type).click
+ find(".js-template-type-selector").click
+ find(".dropdown-content li", text: template_type).click
end
diff --git a/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
index 2d67837763c..8632b6bca03 100644
--- a/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
+++ b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
# This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569
-describe 'Projects > Files > User browses a tree with a folder containing only a folder' do
+describe "Projects > Files > User browses a tree with a folder containing only a folder" do
let(:project) { create(:project, :empty_repo) }
let(:user) { project.owner }
@@ -9,12 +9,12 @@ describe 'Projects > Files > User browses a tree with a folder containing only a
# We need to disable the tree.flat_path provided by Gitaly to reproduce the issue
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false)
- project.repository.create_dir(user, 'foo/bar', branch_name: 'master', message: 'Add the foo/bar folder')
+ project.repository.create_dir(user, "foo/bar", branch_name: "master", message: "Add the foo/bar folder")
sign_in(user)
visit(project_tree_path(project, project.repository.root_ref))
end
- it 'shows the nested folder on a single row' do
- expect(page).to have_content('foo/bar')
+ it "shows the nested folder on a single row" do
+ expect(page).to have_content("foo/bar")
end
end
diff --git a/spec/features/projects/files/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb
index 66268355345..7fc11dcc3fa 100644
--- a/spec/features/projects/files/user_browses_files_spec.rb
+++ b/spec/features/projects/files/user_browses_files_spec.rb
@@ -34,8 +34,8 @@ describe "User browses files" do
it "shows files from a repository" do
expect(page).to have_content("VERSION")
- .and have_content(".gitignore")
- .and have_content("LICENSE")
+ .and have_content(".gitignore")
+ .and have_content("LICENSE")
end
it "shows the `Browse Directory` link" do
@@ -89,15 +89,15 @@ describe "User browses files" do
expect(current_path).to eq(project_tree_path(project, "markdown"))
expect(page).to have_content("README.md")
- .and have_content("CHANGELOG")
- .and have_content("Welcome to GitLab GitLab is a free project and repository management application")
- .and have_link("GitLab API doc")
- .and have_link("GitLab API website")
- .and have_link("Rake tasks")
- .and have_link("backup and restore procedure")
- .and have_link("GitLab API doc directory")
- .and have_link("Maintenance")
- .and have_header_with_correct_id_and_link(2, "Application details", "application-details")
+ .and have_content("CHANGELOG")
+ .and have_content("Welcome to GitLab GitLab is a free project and repository management application")
+ .and have_link("GitLab API doc")
+ .and have_link("GitLab API website")
+ .and have_link("Rake tasks")
+ .and have_link("backup and restore procedure")
+ .and have_link("GitLab API doc directory")
+ .and have_link("Maintenance")
+ .and have_header_with_correct_id_and_link(2, "Application details", "application-details")
end
it "shows correct content of file" do
@@ -105,10 +105,10 @@ describe "User browses files" do
expect(current_path).to eq(project_blob_path(project, "markdown/doc/api/README.md"))
expect(page).to have_content("All API requests require authentication")
- .and have_content("Contents")
- .and have_link("Users")
- .and have_link("Rake tasks")
- .and have_header_with_correct_id_and_link(1, "GitLab API", "gitlab-api")
+ .and have_content("Contents")
+ .and have_link("Users")
+ .and have_link("Rake tasks")
+ .and have_header_with_correct_id_and_link(1, "GitLab API", "gitlab-api")
click_link("Users")
@@ -227,8 +227,8 @@ describe "User browses files" do
click_link("Blame")
expect(page).to have_content("*.rb")
- .and have_content("Dmitriy Zaporozhets")
- .and have_content("Initial commit")
+ .and have_content("Dmitriy Zaporozhets")
+ .and have_content("Initial commit")
end
end
diff --git a/spec/features/projects/files/user_browses_lfs_files_spec.rb b/spec/features/projects/files/user_browses_lfs_files_spec.rb
index d56476adb05..77556ffb922 100644
--- a/spec/features/projects/files/user_browses_lfs_files_spec.rb
+++ b/spec/features/projects/files/user_browses_lfs_files_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User browses LFS files' do
+describe "Projects > Files > User browses LFS files" do
let(:project) { create(:project, :repository) }
let(:user) { project.owner }
@@ -8,51 +8,51 @@ describe 'Projects > Files > User browses LFS files' do
sign_in(user)
end
- context 'when LFS is disabled', :js do
+ context "when LFS is disabled", :js do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
- visit project_tree_path(project, 'lfs')
+ visit project_tree_path(project, "lfs")
wait_for_requests
end
- it 'is possible to see raw content of LFS pointer' do
- click_link 'files'
- click_link 'lfs'
- click_link 'lfs_object.iso'
+ it "is possible to see raw content of LFS pointer" do
+ click_link "files"
+ click_link "lfs"
+ click_link "lfs_object.iso"
- expect(page).to have_content 'version https://git-lfs.github.com/spec/v1'
- expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897'
- expect(page).to have_content 'size 1575078'
- expect(page).not_to have_content 'Download (1.5 MB)'
+ expect(page).to have_content "version https://git-lfs.github.com/spec/v1"
+ expect(page).to have_content "oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897"
+ expect(page).to have_content "size 1575078"
+ expect(page).not_to have_content "Download (1.5 MB)"
end
end
- context 'when LFS is enabled', :js do
+ context "when LFS is enabled", :js do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
- visit project_tree_path(project, 'lfs')
+ visit project_tree_path(project, "lfs")
wait_for_requests
end
- it 'shows an LFS object' do
- click_link('files')
- click_link('lfs')
- click_link('lfs_object.iso')
-
- expect(page).to have_content('Download (1.5 MB)')
- expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1')
- expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897')
- expect(page).not_to have_content('size 1575078')
-
- page.within('.content') do
- expect(page).to have_content('Delete')
- expect(page).to have_content('History')
- expect(page).to have_content('Permalink')
- expect(page).to have_content('Replace')
- expect(page).not_to have_content('Annotate')
- expect(page).not_to have_content('Blame')
- expect(page).not_to have_content('Edit')
- expect(page).to have_link('Download')
+ it "shows an LFS object" do
+ click_link("files")
+ click_link("lfs")
+ click_link("lfs_object.iso")
+
+ expect(page).to have_content("Download (1.5 MB)")
+ expect(page).not_to have_content("version https://git-lfs.github.com/spec/v1")
+ expect(page).not_to have_content("oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897")
+ expect(page).not_to have_content("size 1575078")
+
+ page.within(".content") do
+ expect(page).to have_content("Delete")
+ expect(page).to have_content("History")
+ expect(page).to have_content("Permalink")
+ expect(page).to have_content("Replace")
+ expect(page).not_to have_content("Annotate")
+ expect(page).not_to have_content("Blame")
+ expect(page).not_to have_content("Edit")
+ expect(page).to have_link("Download")
end
end
end
diff --git a/spec/features/projects/files/user_creates_directory_spec.rb b/spec/features/projects/files/user_creates_directory_spec.rb
index 847b5f0860f..614bb0f680d 100644
--- a/spec/features/projects/files/user_creates_directory_spec.rb
+++ b/spec/features/projects/files/user_creates_directory_spec.rb
@@ -1,83 +1,83 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User creates a directory', :js do
+describe "Projects > Files > User creates a directory", :js do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
end
let(:project) { create(:project, :repository) }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) }
before do
project.add_developer(user)
sign_in(user)
- visit project_tree_path(project, 'master')
+ visit project_tree_path(project, "master")
end
- context 'with default target branch' do
+ context "with default target branch" do
before do
- first('.add-to-tree').click
- click_link('New directory')
+ first(".add-to-tree").click
+ click_link("New directory")
end
- it 'creates the directory in the default branch' do
- fill_in(:dir_name, with: 'new_directory')
- click_button('Create directory')
+ it "creates the directory in the default branch" do
+ fill_in(:dir_name, with: "new_directory")
+ click_button("Create directory")
- expect(page).to have_content('master')
- expect(page).to have_content('The directory has been successfully created')
- expect(page).to have_content('new_directory')
+ expect(page).to have_content("master")
+ expect(page).to have_content("The directory has been successfully created")
+ expect(page).to have_content("new_directory")
end
- it 'does not create a directory with a name of already existed directory' do
- fill_in(:dir_name, with: 'files')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Create directory')
+ it "does not create a directory with a name of already existed directory" do
+ fill_in(:dir_name, with: "files")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Create directory")
- expect(page).to have_content('A directory with this name already exists')
- expect(current_path).to eq(project_tree_path(project, 'master'))
+ expect(page).to have_content("A directory with this name already exists")
+ expect(current_path).to eq(project_tree_path(project, "master"))
end
end
- context 'with a new target branch' do
+ context "with a new target branch" do
before do
- first('.add-to-tree').click
- click_link('New directory')
- fill_in(:dir_name, with: 'new_directory')
- fill_in(:branch_name, with: 'new-feature')
- click_button('Create directory')
+ first(".add-to-tree").click
+ click_link("New directory")
+ fill_in(:dir_name, with: "new_directory")
+ fill_in(:branch_name, with: "new-feature")
+ click_button("Create directory")
end
- it 'creates the directory in the new branch and redirect to the merge request' do
- expect(page).to have_content('new-feature')
- expect(page).to have_content('The directory has been successfully created')
- expect(page).to have_content('New Merge Request')
- expect(page).to have_content('From new-feature into master')
- expect(page).to have_content('Add new directory')
+ it "creates the directory in the new branch and redirect to the merge request" do
+ expect(page).to have_content("new-feature")
+ expect(page).to have_content("The directory has been successfully created")
+ expect(page).to have_content("New Merge Request")
+ expect(page).to have_content("From new-feature into master")
+ expect(page).to have_content("Add new directory")
expect(current_path).to eq(project_new_merge_request_path(project))
end
end
- context 'when an user does not have write access' do
+ context "when an user does not have write access" do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
end
- it 'creates a directory in a forked project' do
- find('.add-to-tree').click
- click_link('New directory')
+ it "creates a directory in a forked project" do
+ find(".add-to-tree").click
+ click_link("New directory")
expect(page).to have_content(fork_message)
- find('.add-to-tree').click
- click_link('New directory')
- fill_in(:dir_name, with: 'new_directory')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Create directory')
+ find(".add-to-tree").click
+ click_link("New directory")
+ fill_in(:dir_name, with: "new_directory")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Create directory")
fork = user.fork_of(project2.reload)
diff --git a/spec/features/projects/files/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb
index dd2964c2186..482f40c3ccc 100644
--- a/spec/features/projects/files/user_creates_files_spec.rb
+++ b/spec/features/projects/files/user_creates_files_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User creates files' do
+describe "Projects > Files > User creates files" do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
end
- let(:project) { create(:project, :repository, name: 'Shop') }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project) { create(:project, :repository, name: "Shop") }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) }
@@ -18,174 +18,174 @@ describe 'Projects > Files > User creates files' do
sign_in(user)
end
- context 'without committing a new file' do
- context 'when an user has write access' do
+ context "without committing a new file" do
+ context "when an user has write access" do
before do
visit(project_tree_path_root_ref)
end
- it 'opens new file page' do
- find('.add-to-tree').click
- click_link('New file')
+ it "opens new file page" do
+ find(".add-to-tree").click
+ click_link("New file")
- expect(page).to have_content('New file')
- expect(page).to have_content('Commit message')
+ expect(page).to have_content("New file")
+ expect(page).to have_content("Commit message")
end
end
- context 'when an user does not have write access' do
+ context "when an user does not have write access" do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
end
- it 'opens new file page on a forked project' do
- find('.add-to-tree').click
- click_link('New file')
+ it "opens new file page on a forked project" do
+ find(".add-to-tree").click
+ click_link("New file")
- expect(page).to have_selector('.file-editor')
+ expect(page).to have_selector(".file-editor")
expect(page).to have_content(fork_message)
- expect(page).to have_content('New file')
- expect(page).to have_content('Commit message')
+ expect(page).to have_content("New file")
+ expect(page).to have_content("Commit message")
end
end
end
- context 'with committing a new file' do
- context 'when an user has write access' do
+ context "with committing a new file" do
+ context "when an user has write access" do
before do
visit(project_tree_path_root_ref)
- find('.add-to-tree').click
- click_link('New file')
- expect(page).to have_selector('.file-editor')
+ find(".add-to-tree").click
+ click_link("New file")
+ expect(page).to have_selector(".file-editor")
end
def submit_new_file(options)
- file_name = find('#file_name')
- file_name.set options[:file_name] || 'README.md'
+ file_name = find("#file_name")
+ file_name.set options[:file_name] || "README.md"
- file_content = find('#file-content', visible: false)
- file_content.set options[:file_content] || 'Some content'
+ file_content = find("#file-content", visible: false)
+ file_content.set options[:file_content] || "Some content"
- click_button 'Commit changes'
+ click_button "Commit changes"
end
- it 'allows Chinese characters in file name' do
- submit_new_file(file_name: '测试.md')
- expect(page).to have_content 'The file has been successfully created.'
+ it "allows Chinese characters in file name" do
+ submit_new_file(file_name: "测试.md")
+ expect(page).to have_content "The file has been successfully created."
end
- it 'allows Chinese characters in directory name' do
- submit_new_file(file_name: '中文/测试.md')
- expect(page).to have_content 'The file has been successfully created'
+ it "allows Chinese characters in directory name" do
+ submit_new_file(file_name: "中文/测试.md")
+ expect(page).to have_content "The file has been successfully created"
end
- it 'does not allow directory traversal in file name' do
- submit_new_file(file_name: '../README.md')
- expect(page).to have_content 'Path cannot include directory traversal'
+ it "does not allow directory traversal in file name" do
+ submit_new_file(file_name: "../README.md")
+ expect(page).to have_content "Path cannot include directory traversal"
end
- it 'creates and commit a new file', :js do
- find('#editor')
+ it "creates and commit a new file", :js do
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:file_name, with: 'not_a_file.md')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:file_name, with: "not_a_file.md")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
- new_file_path = project_blob_path(project, 'master/not_a_file.md')
+ new_file_path = project_blob_path(project, "master/not_a_file.md")
expect(current_path).to eq(new_file_path)
wait_for_requests
- expect(page).to have_content('*.rbca')
+ expect(page).to have_content("*.rbca")
end
- it 'creates and commit a new file with new lines at the end of file', :js do
- find('#editor')
+ it "creates and commit a new file with new lines at the end of file", :js do
+ find("#editor")
execute_script('ace.edit("editor").setValue("Sample\n\n\n")')
- fill_in(:file_name, with: 'not_a_file.md')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:file_name, with: "not_a_file.md")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
- new_file_path = project_blob_path(project, 'master/not_a_file.md')
+ new_file_path = project_blob_path(project, "master/not_a_file.md")
expect(current_path).to eq(new_file_path)
- find('.js-edit-blob').click
+ find(".js-edit-blob").click
- find('#editor')
+ find("#editor")
expect(evaluate_script('ace.edit("editor").getValue()')).to eq("Sample\n\n\n")
end
- it 'creates and commit a new file with a directory name', :js do
- fill_in(:file_name, with: 'foo/bar/baz.txt')
+ it "creates and commit a new file with a directory name", :js do
+ fill_in(:file_name, with: "foo/bar/baz.txt")
- expect(page).to have_selector('.file-editor')
+ expect(page).to have_selector(".file-editor")
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
- expect(current_path).to eq(project_blob_path(project, 'master/foo/bar/baz.txt'))
+ expect(current_path).to eq(project_blob_path(project, "master/foo/bar/baz.txt"))
wait_for_requests
- expect(page).to have_content('*.rbca')
+ expect(page).to have_content("*.rbca")
end
- it 'creates and commit a new file specifying a new branch', :js do
- expect(page).to have_selector('.file-editor')
+ it "creates and commit a new file specifying a new branch", :js do
+ expect(page).to have_selector(".file-editor")
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:file_name, with: 'not_a_file.md')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- fill_in(:branch_name, with: 'new_branch_name', visible: true)
- click_button('Commit changes')
+ fill_in(:file_name, with: "not_a_file.md")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ fill_in(:branch_name, with: "new_branch_name", visible: true)
+ click_button("Commit changes")
expect(current_path).to eq(project_new_merge_request_path(project))
- click_link('Changes')
+ click_link("Changes")
wait_for_requests
- expect(page).to have_content('*.rbca')
+ expect(page).to have_content("*.rbca")
end
end
- context 'when an user does not have write access' do
+ context "when an user does not have write access" do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
- find('.add-to-tree').click
- click_link('New file')
+ find(".add-to-tree").click
+ click_link("New file")
end
- it 'shows a message saying the file will be committed in a fork' do
+ it "shows a message saying the file will be committed in a fork" do
message = "A new branch will be created in your fork and a new merge request will be started."
expect(page).to have_content(message)
end
- it 'creates and commit new file in forked project', :js do
- expect(page).to have_selector('.file-editor')
+ it "creates and commit new file in forked project", :js do
+ expect(page).to have_selector(".file-editor")
expect(page).to have_content
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:file_name, with: 'not_a_file.md')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:file_name, with: "not_a_file.md")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
fork = user.fork_of(project2.reload)
expect(current_path).to eq(project_new_merge_request_path(fork))
- expect(page).to have_content('New commit message')
+ expect(page).to have_content("New commit message")
end
end
end
diff --git a/spec/features/projects/files/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb
index 614b11fa5c8..aaf27c747d7 100644
--- a/spec/features/projects/files/user_deletes_files_spec.rb
+++ b/spec/features/projects/files/user_deletes_files_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User deletes files', :js do
+describe "Projects > Files > User deletes files", :js do
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
end
- let(:project) { create(:project, :repository, name: 'Shop') }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project) { create(:project, :repository, name: "Shop") }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) }
@@ -15,56 +15,56 @@ describe 'Projects > Files > User deletes files', :js do
sign_in(user)
end
- context 'when an user has write access' do
+ context "when an user has write access" do
before do
project.add_maintainer(user)
visit(project_tree_path_root_ref)
wait_for_requests
end
- it 'deletes the file', :js do
- click_link('.gitignore')
+ it "deletes the file", :js do
+ click_link(".gitignore")
- expect(page).to have_content('.gitignore')
+ expect(page).to have_content(".gitignore")
- click_on('Delete')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Delete file')
+ click_on("Delete")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Delete file")
- expect(current_path).to eq(project_tree_path(project, 'master/'))
- expect(page).not_to have_content('.gitignore')
+ expect(current_path).to eq(project_tree_path(project, "master/"))
+ expect(page).not_to have_content(".gitignore")
end
end
- context 'when an user does not have write access', :js do
+ context "when an user does not have write access", :js do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
wait_for_requests
end
- it 'deletes the file in a forked project', :js do
- click_link('.gitignore')
+ it "deletes the file in a forked project", :js do
+ click_link(".gitignore")
- expect(page).to have_content('.gitignore')
+ expect(page).to have_content(".gitignore")
- click_on('Delete')
+ click_on("Delete")
- expect(page).to have_link('Fork')
- expect(page).to have_button('Cancel')
+ expect(page).to have_link("Fork")
+ expect(page).to have_button("Cancel")
- click_link('Fork')
+ click_link("Fork")
expect(page).to have_content(fork_message)
- click_on('Delete')
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Delete file')
+ click_on("Delete")
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Delete file")
fork = user.fork_of(project2.reload)
expect(current_path).to eq(project_new_merge_request_path(fork))
- expect(page).to have_content('New commit message')
+ expect(page).to have_content("New commit message")
end
end
end
diff --git a/spec/features/projects/files/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb
index ec3930c26db..a6708ca9174 100644
--- a/spec/features/projects/files/user_edits_files_spec.rb
+++ b/spec/features/projects/files/user_edits_files_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User edits files', :js do
+describe "Projects > Files > User edits files", :js do
include ProjectForksHelper
- let(:project) { create(:project, :repository, name: 'Shop') }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project) { create(:project, :repository, name: "Shop") }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) }
@@ -14,146 +14,146 @@ describe 'Projects > Files > User edits files', :js do
sign_in(user)
end
- shared_examples 'unavailable for an archived project' do
- it 'does not show the edit link for an archived project', :js do
+ shared_examples "unavailable for an archived project" do
+ it "does not show the edit link for an archived project", :js do
project.update!(archived: true)
visit project_tree_path(project, project.repository.root_ref)
- click_link('.gitignore')
+ click_link(".gitignore")
- aggregate_failures 'available edit buttons' do
- expect(page).not_to have_text('Edit')
- expect(page).not_to have_text('Web IDE')
+ aggregate_failures "available edit buttons" do
+ expect(page).not_to have_text("Edit")
+ expect(page).not_to have_text("Web IDE")
- expect(page).not_to have_text('Replace')
- expect(page).not_to have_text('Delete')
+ expect(page).not_to have_text("Replace")
+ expect(page).not_to have_text("Delete")
end
end
end
- context 'when an user has write access', :js do
+ context "when an user has write access", :js do
before do
project.add_maintainer(user)
visit(project_tree_path_root_ref)
wait_for_requests
end
- it 'inserts a content of a file' do
- click_link('.gitignore')
- find('.js-edit-blob').click
- find('.file-editor', match: :first)
+ it "inserts a content of a file" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- expect(evaluate_script('ace.edit("editor").getValue()')).to eq('*.rbca')
+ expect(evaluate_script('ace.edit("editor").getValue()')).to eq("*.rbca")
end
- it 'does not show the edit link if a file is binary' do
- binary_file = File.join(project.repository.root_ref, 'files/images/logo-black.png')
+ it "does not show the edit link if a file is binary" do
+ binary_file = File.join(project.repository.root_ref, "files/images/logo-black.png")
visit(project_blob_path(project, binary_file))
wait_for_requests
- page.within '.content' do
- expect(page).not_to have_link('edit')
+ page.within ".content" do
+ expect(page).not_to have_link("edit")
end
end
- it 'commits an edited file' do
- click_link('.gitignore')
- find('.js-edit-blob').click
- find('.file-editor', match: :first)
+ it "commits an edited file" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
- expect(current_path).to eq(project_blob_path(project, 'master/.gitignore'))
+ expect(current_path).to eq(project_blob_path(project, "master/.gitignore"))
wait_for_requests
- expect(page).to have_content('*.rbca')
+ expect(page).to have_content("*.rbca")
end
- it 'commits an edited file to a new branch' do
- click_link('.gitignore')
- find('.js-edit-blob').click
+ it "commits an edited file to a new branch" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
- find('.file-editor', match: :first)
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:commit_message, with: 'New commit message', visible: true)
- fill_in(:branch_name, with: 'new_branch_name', visible: true)
- click_button('Commit changes')
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ fill_in(:branch_name, with: "new_branch_name", visible: true)
+ click_button("Commit changes")
expect(current_path).to eq(project_new_merge_request_path(project))
- click_link('Changes')
+ click_link("Changes")
- expect(page).to have_content('*.rbca')
+ expect(page).to have_content("*.rbca")
end
- it 'shows the diff of an edited file' do
- click_link('.gitignore')
- find('.js-edit-blob').click
- find('.file-editor', match: :first)
+ it "shows the diff of an edited file" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- click_link('Preview changes')
+ click_link("Preview changes")
- expect(page).to have_css('.line_holder.new')
+ expect(page).to have_css(".line_holder.new")
end
- it_behaves_like 'unavailable for an archived project'
+ it_behaves_like "unavailable for an archived project"
end
- context 'when an user does not have write access', :js do
+ context "when an user does not have write access", :js do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
wait_for_requests
end
- it 'inserts a content of a file in a forked project' do
- click_link('.gitignore')
- find('.js-edit-blob').click
+ it "inserts a content of a file in a forked project" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
- expect(page).to have_link('Fork')
- expect(page).to have_button('Cancel')
+ expect(page).to have_link("Fork")
+ expect(page).to have_button("Cancel")
- click_link('Fork')
+ click_link("Fork")
expect(page).to have_content(
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
)
- find('.file-editor', match: :first)
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- expect(evaluate_script('ace.edit("editor").getValue()')).to eq('*.rbca')
+ expect(evaluate_script('ace.edit("editor").getValue()')).to eq("*.rbca")
end
- it 'commits an edited file in a forked project' do
- click_link('.gitignore')
- find('.js-edit-blob').click
+ it "commits an edited file in a forked project" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
- expect(page).to have_link('Fork')
- expect(page).to have_button('Cancel')
+ expect(page).to have_link("Fork")
+ expect(page).to have_button("Cancel")
- click_link('Fork')
+ click_link("Fork")
- find('.file-editor', match: :first)
+ find(".file-editor", match: :first)
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:commit_message, with: 'New commit message', visible: true)
- click_button('Commit changes')
+ fill_in(:commit_message, with: "New commit message", visible: true)
+ click_button("Commit changes")
fork = user.fork_of(project2.reload)
@@ -161,27 +161,27 @@ describe 'Projects > Files > User edits files', :js do
wait_for_requests
- expect(page).to have_content('New commit message')
+ expect(page).to have_content("New commit message")
end
- context 'when the user already had a fork of the project', :js do
+ context "when the user already had a fork of the project", :js do
let!(:forked_project) { fork_project(project2, user, namespace: user.namespace, repository: true) }
before do
visit(project2_tree_path_root_ref)
wait_for_requests
end
- it 'links to the forked project for editing' do
- click_link('.gitignore')
- find('.js-edit-blob').click
+ it "links to the forked project for editing" do
+ click_link(".gitignore")
+ find(".js-edit-blob").click
- expect(page).not_to have_link('Fork')
- expect(page).not_to have_button('Cancel')
+ expect(page).not_to have_link("Fork")
+ expect(page).not_to have_button("Cancel")
- find('#editor')
+ find("#editor")
execute_script("ace.edit('editor').setValue('*.rbca')")
- fill_in(:commit_message, with: 'Another commit', visible: true)
- click_button('Commit changes')
+ fill_in(:commit_message, with: "Another commit", visible: true)
+ click_button("Commit changes")
fork = user.fork_of(project2)
@@ -189,12 +189,12 @@ describe 'Projects > Files > User edits files', :js do
wait_for_requests
- expect(page).to have_content('Another commit')
+ expect(page).to have_content("Another commit")
expect(page).to have_content("From #{forked_project.full_path}")
expect(page).to have_content("into #{project2.full_path}")
end
- it_behaves_like 'unavailable for an archived project' do
+ it_behaves_like "unavailable for an archived project" do
let(:project) { project2 }
end
end
diff --git a/spec/features/projects/files/user_find_file_spec.rb b/spec/features/projects/files/user_find_file_spec.rb
index e2d881b34d2..2bf88e7c35f 100644
--- a/spec/features/projects/files/user_find_file_spec.rb
+++ b/spec/features/projects/files/user_find_file_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User find project file' do
+describe "User find project file" do
let(:user) { create :user }
let(:project) { create :project, :repository }
@@ -12,55 +12,55 @@ describe 'User find project file' do
end
def active_main_tab
- find('.sidebar-top-level-items > li.active')
+ find(".sidebar-top-level-items > li.active")
end
def find_file(text)
- fill_in 'file_find', with: text
+ fill_in "file_find", with: text
end
- it 'navigates to find file by shortcut', :js do
- find('body').native.send_key('t')
+ it "navigates to find file by shortcut", :js do
+ find("body").native.send_key("t")
- expect(active_main_tab).to have_content('Repository')
- expect(page).to have_selector('.file-finder-holder', count: 1)
+ expect(active_main_tab).to have_content("Repository")
+ expect(page).to have_selector(".file-finder-holder", count: 1)
end
- it 'navigates to find file' do
- click_link 'Find file'
+ it "navigates to find file" do
+ click_link "Find file"
- expect(active_main_tab).to have_content('Repository')
- expect(page).to have_selector('.file-finder-holder', count: 1)
+ expect(active_main_tab).to have_content("Repository")
+ expect(page).to have_selector(".file-finder-holder", count: 1)
end
- it 'searches CHANGELOG file', :js do
- click_link 'Find file'
+ it "searches CHANGELOG file", :js do
+ click_link "Find file"
- find_file 'change'
+ find_file "change"
- expect(page).to have_content('CHANGELOG')
- expect(page).not_to have_content('.gitignore')
- expect(page).not_to have_content('VERSION')
+ expect(page).to have_content("CHANGELOG")
+ expect(page).not_to have_content(".gitignore")
+ expect(page).not_to have_content("VERSION")
end
- it 'does not find file when search not exist file', :js do
- click_link 'Find file'
+ it "does not find file when search not exist file", :js do
+ click_link "Find file"
- find_file 'asdfghjklqwertyuizxcvbnm'
+ find_file "asdfghjklqwertyuizxcvbnm"
- expect(page).not_to have_content('CHANGELOG')
- expect(page).not_to have_content('.gitignore')
- expect(page).not_to have_content('VERSION')
+ expect(page).not_to have_content("CHANGELOG")
+ expect(page).not_to have_content(".gitignore")
+ expect(page).not_to have_content("VERSION")
end
- it 'searches file by partially matches', :js do
- click_link 'Find file'
+ it "searches file by partially matches", :js do
+ click_link "Find file"
- find_file 'git'
+ find_file "git"
- expect(page).to have_content('.gitignore')
- expect(page).to have_content('.gitmodules')
- expect(page).not_to have_content('CHANGELOG')
- expect(page).not_to have_content('VERSION')
+ expect(page).to have_content(".gitignore")
+ expect(page).to have_content(".gitmodules")
+ expect(page).not_to have_content("CHANGELOG")
+ expect(page).not_to have_content("VERSION")
end
end
diff --git a/spec/features/projects/files/user_reads_pipeline_status_spec.rb b/spec/features/projects/files/user_reads_pipeline_status_spec.rb
index ff0aa933a3e..ef8f3b8bf60 100644
--- a/spec/features/projects/files/user_reads_pipeline_status_spec.rb
+++ b/spec/features/projects/files/user_reads_pipeline_status_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'user reads pipeline status', :js do
+describe "user reads pipeline status", :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- let(:v110_pipeline) { create_pipeline('v1.1.0', 'success') }
- let(:x110_pipeline) { create_pipeline('x1.1.0', 'failed') }
+ let(:v110_pipeline) { create_pipeline("v1.1.0", "success") }
+ let(:x110_pipeline) { create_pipeline("x1.1.0", "failed") }
before do
project.add_maintainer(user)
- project.repository.add_tag(user, 'x1.1.0', 'v1.1.0')
+ project.repository.add_tag(user, "x1.1.0", "v1.1.0")
v110_pipeline
x110_pipeline
sign_in(user)
end
- shared_examples 'visiting project tree' do
- it 'sees the correct pipeline status' do
+ shared_examples "visiting project tree" do
+ it "sees the correct pipeline status" do
visit project_tree_path(project, expected_pipeline.ref)
wait_for_requests
- page.within('.blob-commit-info') do
- expect(page).to have_link('', href: project_pipeline_path(project, expected_pipeline))
+ page.within(".blob-commit-info") do
+ expect(page).to have_link("", href: project_pipeline_path(project, expected_pipeline))
expect(page).to have_selector(".ci-status-icon-#{expected_pipeline.status}")
end
end
end
- it_behaves_like 'visiting project tree' do
+ it_behaves_like "visiting project tree" do
let(:expected_pipeline) { v110_pipeline }
end
- it_behaves_like 'visiting project tree' do
+ it_behaves_like "visiting project tree" do
let(:expected_pipeline) { x110_pipeline }
end
diff --git a/spec/features/projects/files/user_replaces_files_spec.rb b/spec/features/projects/files/user_replaces_files_spec.rb
index e3da28d73c3..912694e399d 100644
--- a/spec/features/projects/files/user_replaces_files_spec.rb
+++ b/spec/features/projects/files/user_replaces_files_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User replaces files', :js do
+describe "Projects > Files > User replaces files", :js do
include DropzoneHelper
let(:fork_message) do
"You're not allowed to make changes to this project directly. "\
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
end
- let(:project) { create(:project, :repository, name: 'Shop') }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project) { create(:project, :repository, name: "Shop") }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
let(:user) { create(:user) }
@@ -17,73 +17,73 @@ describe 'Projects > Files > User replaces files', :js do
sign_in(user)
end
- context 'when an user has write access' do
+ context "when an user has write access" do
before do
project.add_maintainer(user)
visit(project_tree_path_root_ref)
wait_for_requests
end
- it 'replaces an existed file with a new one' do
- click_link('.gitignore')
+ it "replaces an existed file with a new one" do
+ click_link(".gitignore")
- expect(page).to have_content('.gitignore')
+ expect(page).to have_content(".gitignore")
- click_on('Replace')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
+ click_on("Replace")
+ drop_in_dropzone(File.join(Rails.root, "spec", "fixtures", "doc_sample.txt"))
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'Replacement file commit message')
+ page.within("#modal-upload-blob") do
+ fill_in(:commit_message, with: "Replacement file commit message")
end
- click_button('Replace file')
+ click_button("Replace file")
- expect(page).to have_content('Lorem ipsum dolor sit amet')
- expect(page).to have_content('Sed ut perspiciatis unde omnis')
- expect(page).to have_content('Replacement file commit message')
+ expect(page).to have_content("Lorem ipsum dolor sit amet")
+ expect(page).to have_content("Sed ut perspiciatis unde omnis")
+ expect(page).to have_content("Replacement file commit message")
end
end
- context 'when an user does not have write access' do
+ context "when an user does not have write access" do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
wait_for_requests
end
- it 'replaces an existed file with a new one in a forked project' do
- click_link('.gitignore')
+ it "replaces an existed file with a new one in a forked project" do
+ click_link(".gitignore")
- expect(page).to have_content('.gitignore')
+ expect(page).to have_content(".gitignore")
- click_on('Replace')
+ click_on("Replace")
- expect(page).to have_link('Fork')
- expect(page).to have_button('Cancel')
+ expect(page).to have_link("Fork")
+ expect(page).to have_button("Cancel")
- click_link('Fork')
+ click_link("Fork")
expect(page).to have_content(fork_message)
- click_on('Replace')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
+ click_on("Replace")
+ drop_in_dropzone(File.join(Rails.root, "spec", "fixtures", "doc_sample.txt"))
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'Replacement file commit message')
+ page.within("#modal-upload-blob") do
+ fill_in(:commit_message, with: "Replacement file commit message")
end
- click_button('Replace file')
+ click_button("Replace file")
- expect(page).to have_content('Replacement file commit message')
+ expect(page).to have_content("Replacement file commit message")
fork = user.fork_of(project2.reload)
expect(current_path).to eq(project_new_merge_request_path(fork))
- click_link('Changes')
+ click_link("Changes")
- expect(page).to have_content('Lorem ipsum dolor sit amet')
- expect(page).to have_content('Sed ut perspiciatis unde omnis')
+ expect(page).to have_content("Lorem ipsum dolor sit amet")
+ expect(page).to have_content("Sed ut perspiciatis unde omnis")
end
end
end
diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb
index a90e4918fb1..2a67832e513 100644
--- a/spec/features/projects/files/user_searches_for_files_spec.rb
+++ b/spec/features/projects/files/user_searches_for_files_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User searches for files' do
+describe "Projects > Files > User searches for files" do
let(:user) { project.owner }
before do
sign_in(user)
end
- describe 'project main screen' do
- context 'when project is empty' do
+ describe "project main screen" do
+ context "when project is empty" do
let(:project) { create(:project) }
before do
visit project_path(project)
end
- it 'does not show any result' do
- fill_in('search', with: 'coffee')
- click_button('Go')
+ it "does not show any result" do
+ fill_in("search", with: "coffee")
+ click_button("Go")
expect(page).to have_content("We couldn't find any")
end
end
- context 'when project is not empty' do
+ context "when project is not empty" do
let(:project) { create(:project, :repository) }
before do
@@ -32,12 +32,12 @@ describe 'Projects > Files > User searches for files' do
end
it 'shows "Find file" button' do
- expect(page).to have_selector('.tree-controls .shortcuts-find-file')
+ expect(page).to have_selector(".tree-controls .shortcuts-find-file")
end
end
end
- describe 'project tree screen' do
+ describe "project tree screen" do
let(:project) { create(:project, :repository) }
before do
@@ -45,14 +45,14 @@ describe 'Projects > Files > User searches for files' do
visit project_tree_path(project, project.default_branch)
end
- it 'shows found files' do
- expect(page).to have_selector('.tree-controls .shortcuts-find-file')
+ it "shows found files" do
+ expect(page).to have_selector(".tree-controls .shortcuts-find-file")
- fill_in('search', with: 'coffee')
- click_button('Go')
+ fill_in("search", with: "coffee")
+ click_button("Go")
- expect(page).to have_content('coffee')
- expect(page).to have_content('CONTRIBUTING.md')
+ expect(page).to have_content("coffee")
+ expect(page).to have_content("CONTRIBUTING.md")
end
end
end
diff --git a/spec/features/projects/files/user_uploads_files_spec.rb b/spec/features/projects/files/user_uploads_files_spec.rb
index af3fc528a20..231c3b42b24 100644
--- a/spec/features/projects/files/user_uploads_files_spec.rb
+++ b/spec/features/projects/files/user_uploads_files_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Files > User uploads files' do
+describe "Projects > Files > User uploads files" do
include DropzoneHelper
let(:fork_message) do
@@ -8,8 +8,8 @@ describe 'Projects > Files > User uploads files' do
"A fork of this project has been created that you can make changes in, so you can submit a merge request."
end
let(:user) { create(:user) }
- let(:project) { create(:project, :repository, name: 'Shop', creator: user) }
- let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') }
+ let(:project) { create(:project, :repository, name: "Shop", creator: user) }
+ let(:project2) { create(:project, :repository, name: "Another Project", path: "another-project") }
let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) }
let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) }
@@ -18,88 +18,88 @@ describe 'Projects > Files > User uploads files' do
sign_in(user)
end
- context 'when an user has write access' do
+ context "when an user has write access" do
before do
visit(project_tree_path_root_ref)
end
- it 'uploads and commit a new text file', :js do
- find('.add-to-tree').click
- click_link('Upload file')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
+ it "uploads and commit a new text file", :js do
+ find(".add-to-tree").click
+ click_link("Upload file")
+ drop_in_dropzone(File.join(Rails.root, "spec", "fixtures", "doc_sample.txt"))
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'New commit message')
+ page.within("#modal-upload-blob") do
+ fill_in(:commit_message, with: "New commit message")
end
- fill_in(:branch_name, with: 'new_branch_name', visible: true)
- click_button('Upload file')
+ fill_in(:branch_name, with: "new_branch_name", visible: true)
+ click_button("Upload file")
- expect(page).to have_content('New commit message')
+ expect(page).to have_content("New commit message")
expect(current_path).to eq(project_new_merge_request_path(project))
- click_link('Changes')
- find("a[data-action='diffs']", text: 'Changes').click
+ click_link("Changes")
+ find("a[data-action='diffs']", text: "Changes").click
wait_for_requests
- expect(page).to have_content('Lorem ipsum dolor sit amet')
- expect(page).to have_content('Sed ut perspiciatis unde omnis')
+ expect(page).to have_content("Lorem ipsum dolor sit amet")
+ expect(page).to have_content("Sed ut perspiciatis unde omnis")
end
- it 'uploads and commit a new image file', :js do
- find('.add-to-tree').click
- click_link('Upload file')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg'))
+ it "uploads and commit a new image file", :js do
+ find(".add-to-tree").click
+ click_link("Upload file")
+ drop_in_dropzone(File.join(Rails.root, "spec", "fixtures", "logo_sample.svg"))
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'New commit message')
- fill_in(:branch_name, with: 'new_branch_name', visible: true)
- click_button('Upload file')
+ page.within("#modal-upload-blob") do
+ fill_in(:commit_message, with: "New commit message")
+ fill_in(:branch_name, with: "new_branch_name", visible: true)
+ click_button("Upload file")
end
wait_for_all_requests
- visit(project_blob_path(project, 'new_branch_name/logo_sample.svg'))
+ visit(project_blob_path(project, "new_branch_name/logo_sample.svg"))
- expect(page).to have_css('.file-content img')
+ expect(page).to have_css(".file-content img")
end
end
- context 'when an user does not have write access' do
+ context "when an user does not have write access" do
before do
project2.add_reporter(user)
visit(project2_tree_path_root_ref)
end
- it 'uploads and commit a new file to a forked project', :js do
- find('.add-to-tree').click
- click_link('Upload file')
+ it "uploads and commit a new file to a forked project", :js do
+ find(".add-to-tree").click
+ click_link("Upload file")
expect(page).to have_content(fork_message)
- find('.add-to-tree').click
- click_link('Upload file')
- drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt'))
+ find(".add-to-tree").click
+ click_link("Upload file")
+ drop_in_dropzone(File.join(Rails.root, "spec", "fixtures", "doc_sample.txt"))
- page.within('#modal-upload-blob') do
- fill_in(:commit_message, with: 'New commit message')
+ page.within("#modal-upload-blob") do
+ fill_in(:commit_message, with: "New commit message")
end
- click_button('Upload file')
+ click_button("Upload file")
- expect(page).to have_content('New commit message')
+ expect(page).to have_content("New commit message")
fork = user.fork_of(project2.reload)
expect(current_path).to eq(project_new_merge_request_path(fork))
- find("a[data-action='diffs']", text: 'Changes').click
+ find("a[data-action='diffs']", text: "Changes").click
wait_for_requests
- expect(page).to have_content('Lorem ipsum dolor sit amet')
- expect(page).to have_content('Sed ut perspiciatis unde omnis')
+ expect(page).to have_content("Lorem ipsum dolor sit amet")
+ expect(page).to have_content("Sed ut perspiciatis unde omnis")
end
end
end
diff --git a/spec/features/projects/fork_spec.rb b/spec/features/projects/fork_spec.rb
index 7c71b4c52e0..97ac54ac4cc 100644
--- a/spec/features/projects/fork_spec.rb
+++ b/spec/features/projects/fork_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project fork' do
+describe "Project fork" do
include ProjectForksHelper
let(:user) { create(:user) }
@@ -10,67 +10,67 @@ describe 'Project fork' do
sign_in user
end
- it 'allows user to fork project' do
+ it "allows user to fork project" do
visit project_path(project)
- expect(page).not_to have_css('a.disabled', text: 'Fork')
+ expect(page).not_to have_css("a.disabled", text: "Fork")
end
- it 'disables fork button when user has exceeded project limit' do
+ it "disables fork button when user has exceeded project limit" do
user.projects_limit = 0
user.save!
visit project_path(project)
- expect(page).to have_css('a.disabled', text: 'Fork')
+ expect(page).to have_css("a.disabled", text: "Fork")
end
- it 'forks the project' do
+ it "forks the project" do
visit project_path(project)
- click_link 'Fork'
+ click_link "Fork"
- page.within '.fork-thumbnail-container' do
+ page.within ".fork-thumbnail-container" do
click_link user.name
end
- expect(page).to have_content 'Forked from'
+ expect(page).to have_content "Forked from"
visit project_path(project)
expect(page).to have_content(/new merge request/i)
- page.within '.nav-sidebar' do
- first(:link, 'Merge Requests').click
+ page.within ".nav-sidebar" do
+ first(:link, "Merge Requests").click
end
expect(page).to have_content(/new merge request/i)
- page.within '#content-body' do
- click_link('New merge request')
+ page.within "#content-body" do
+ click_link("New merge request")
end
expect(current_path).to have_content(/#{user.namespace.name}/i)
end
- it 'shows avatars when Gravatar is disabled' do
+ it "shows avatars when Gravatar is disabled" do
stub_application_setting(gravatar_enabled: false)
visit project_path(project)
- click_link 'Fork'
+ click_link "Fork"
- page.within('.fork-thumbnail-container') do
- expect(page).to have_css('div.identicon')
+ page.within(".fork-thumbnail-container") do
+ expect(page).to have_css("div.identicon")
end
end
- it 'shows the forked project on the list' do
+ it "shows the forked project on the list" do
visit project_path(project)
- click_link 'Fork'
+ click_link "Fork"
- page.within '.fork-thumbnail-container' do
+ page.within ".fork-thumbnail-container" do
click_link user.name
end
@@ -78,42 +78,42 @@ describe 'Project fork' do
forked_project = user.fork_of(project.reload)
- page.within('.js-projects-list-holder') do
+ page.within(".js-projects-list-holder") do
expect(page).to have_content("#{forked_project.namespace.human_name} / #{forked_project.name}")
end
- forked_project.update!(path: 'test-crappy-path')
+ forked_project.update!(path: "test-crappy-path")
visit project_forks_path(project)
- page.within('.js-projects-list-holder') do
+ page.within(".js-projects-list-holder") do
expect(page).to have_content("#{forked_project.namespace.human_name} / #{forked_project.name}")
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:project) { create(:project, :repository) }
- let(:another_user) { create(:user, name: 'Mike') }
+ let(:another_user) { create(:user, name: "Mike") }
before do
project.add_reporter(user)
project.add_reporter(another_user)
end
- it 'renders private forks of the project' do
+ it "renders private forks of the project" do
visit project_path(project)
another_project_fork = Projects::ForkService.new(project, another_user).execute
- click_link 'Fork'
+ click_link "Fork"
- page.within '.fork-thumbnail-container' do
+ page.within ".fork-thumbnail-container" do
click_link user.name
end
visit project_forks_path(project)
- page.within('.js-projects-list-holder') do
+ page.within(".js-projects-list-holder") do
user_project_fork = user.fork_of(project.reload)
expect(page).to have_content("#{user_project_fork.namespace.human_name} / #{user_project_fork.name}")
end
@@ -123,17 +123,17 @@ describe 'Project fork' do
end
end
- context 'when the user already forked the project' do
+ context "when the user already forked the project" do
before do
create(:project, :repository, name: project.name, namespace: user.namespace)
end
- it 'renders error' do
+ it "renders error" do
visit project_path(project)
- click_link 'Fork'
+ click_link "Fork"
- page.within '.fork-thumbnail-container' do
+ page.within ".fork-thumbnail-container" do
click_link user.name
end
@@ -141,44 +141,44 @@ describe 'Project fork' do
end
end
- context 'maintainer in group' do
+ context "maintainer in group" do
let(:group) { create(:group) }
before do
group.add_maintainer(user)
end
- it 'allows user to fork project to group or to user namespace' do
+ it "allows user to fork project to group or to user namespace" do
visit project_path(project)
- expect(page).not_to have_css('a.disabled', text: 'Fork')
+ expect(page).not_to have_css("a.disabled", text: "Fork")
- click_link 'Fork'
+ click_link "Fork"
- expect(page).to have_css('.fork-thumbnail', count: 2)
- expect(page).not_to have_css('.fork-thumbnail.disabled')
+ expect(page).to have_css(".fork-thumbnail", count: 2)
+ expect(page).not_to have_css(".fork-thumbnail.disabled")
end
- it 'allows user to fork project to group and not user when exceeded project limit' do
+ it "allows user to fork project to group and not user when exceeded project limit" do
user.projects_limit = 0
user.save!
visit project_path(project)
- expect(page).not_to have_css('a.disabled', text: 'Fork')
+ expect(page).not_to have_css("a.disabled", text: "Fork")
- click_link 'Fork'
+ click_link "Fork"
- expect(page).to have_css('.fork-thumbnail', count: 2)
- expect(page).to have_css('.fork-thumbnail.disabled')
+ expect(page).to have_css(".fork-thumbnail", count: 2)
+ expect(page).to have_css(".fork-thumbnail.disabled")
end
- it 'links to the fork if the project was already forked within that namespace' do
+ it "links to the fork if the project was already forked within that namespace" do
forked_project = fork_project(project, user, namespace: group, repository: true)
visit new_project_fork_path(project)
- expect(page).to have_css('div.forked', text: group.full_name)
+ expect(page).to have_css("div.forked", text: group.full_name)
click_link group.full_name
diff --git a/spec/features/projects/gfm_autocomplete_load_spec.rb b/spec/features/projects/gfm_autocomplete_load_spec.rb
index 1c988726ae6..5872d3beedd 100644
--- a/spec/features/projects/gfm_autocomplete_load_spec.rb
+++ b/spec/features/projects/gfm_autocomplete_load_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'GFM autocomplete loading', :js do
+describe "GFM autocomplete loading", :js do
let(:project) { create(:project) }
before do
@@ -9,13 +9,13 @@ describe 'GFM autocomplete loading', :js do
visit project_path(project)
end
- it 'does not load on project#show' do
- expect(evaluate_script('gl.GfmAutoComplete')).to eq(nil)
+ it "does not load on project#show" do
+ expect(evaluate_script("gl.GfmAutoComplete")).to eq(nil)
end
- it 'loads on new issue page' do
+ it "loads on new issue page" do
visit new_project_issue_path(project)
- expect(evaluate_script('gl.GfmAutoComplete.dataSources')).not_to eq({})
+ expect(evaluate_script("gl.GfmAutoComplete.dataSources")).not_to eq({})
end
end
diff --git a/spec/features/projects/graph_spec.rb b/spec/features/projects/graph_spec.rb
index 9665f1755d6..dff9f0c8f7a 100644
--- a/spec/features/projects/graph_spec.rb
+++ b/spec/features/projects/graph_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Graph', :js do
+describe "Project Graph", :js do
let(:user) { create :user }
let(:project) { create(:project, :repository, namespace: user.namespace) }
- let(:branch_name) { 'master' }
+ let(:branch_name) { "master" }
before do
project.add_maintainer(user)
@@ -11,83 +11,83 @@ describe 'Project Graph', :js do
sign_in(user)
end
- shared_examples 'page should have commits graphs' do
- it 'renders commits' do
+ shared_examples "page should have commits graphs" do
+ it "renders commits" do
expect(page).to have_content("Commit statistics for #{branch_name}")
- expect(page).to have_content('Commits per day of month')
+ expect(page).to have_content("Commits per day of month")
end
end
- shared_examples 'page should have languages graphs' do
- it 'renders languages' do
+ shared_examples "page should have languages graphs" do
+ it "renders languages" do
expect(page).to have_content(/Ruby 66.* %/)
expect(page).to have_content(/JavaScript 22.* %/)
end
end
- it 'renders graphs' do
- visit project_graph_path(project, 'master')
+ it "renders graphs" do
+ visit project_graph_path(project, "master")
- expect(page).to have_selector('.stat-graph', visible: false)
+ expect(page).to have_selector(".stat-graph", visible: false)
end
- context 'commits graph' do
+ context "commits graph" do
before do
- visit commits_project_graph_path(project, 'master')
+ visit commits_project_graph_path(project, "master")
end
- it_behaves_like 'page should have commits graphs'
- it_behaves_like 'page should have languages graphs'
+ it_behaves_like "page should have commits graphs"
+ it_behaves_like "page should have languages graphs"
end
- context 'languages graph' do
+ context "languages graph" do
before do
- visit languages_project_graph_path(project, 'master')
+ visit languages_project_graph_path(project, "master")
end
- it_behaves_like 'page should have commits graphs'
- it_behaves_like 'page should have languages graphs'
+ it_behaves_like "page should have commits graphs"
+ it_behaves_like "page should have languages graphs"
end
- context 'charts graph' do
+ context "charts graph" do
before do
- visit charts_project_graph_path(project, 'master')
+ visit charts_project_graph_path(project, "master")
end
- it_behaves_like 'page should have commits graphs'
- it_behaves_like 'page should have languages graphs'
+ it_behaves_like "page should have commits graphs"
+ it_behaves_like "page should have languages graphs"
end
- context 'chart graph with HTML escaped branch name' do
- let(:branch_name) { '<h1>evil</h1>' }
+ context "chart graph with HTML escaped branch name" do
+ let(:branch_name) { "<h1>evil</h1>" }
before do
- project.repository.create_branch(branch_name, 'master')
+ project.repository.create_branch(branch_name, "master")
visit charts_project_graph_path(project, branch_name)
end
- it_behaves_like 'page should have commits graphs'
+ it_behaves_like "page should have commits graphs"
- it 'HTML escapes branch name' do
+ it "HTML escapes branch name" do
expect(page.body).to include("Commit statistics for <strong>#{ERB::Util.html_escape(branch_name)}</strong>")
expect(page.body).not_to include(branch_name)
end
end
- context 'when CI enabled' do
+ context "when CI enabled" do
before do
project.enable_ci
- visit ci_project_graph_path(project, 'master')
+ visit ci_project_graph_path(project, "master")
end
- it 'renders CI graphs' do
- expect(page).to have_content 'Overall'
- expect(page).to have_content 'Pipelines for last week'
- expect(page).to have_content 'Pipelines for last month'
- expect(page).to have_content 'Pipelines for last year'
- expect(page).to have_content 'Commit duration in minutes for last 30 commits'
+ it "renders CI graphs" do
+ expect(page).to have_content "Overall"
+ expect(page).to have_content "Pipelines for last week"
+ expect(page).to have_content "Pipelines for last month"
+ expect(page).to have_content "Pipelines for last year"
+ expect(page).to have_content "Commit duration in minutes for last 30 commits"
end
end
end
diff --git a/spec/features/projects/hook_logs/user_reads_log_spec.rb b/spec/features/projects/hook_logs/user_reads_log_spec.rb
index 086cd4b9f03..f62912880d5 100644
--- a/spec/features/projects/hook_logs/user_reads_log_spec.rb
+++ b/spec/features/projects/hook_logs/user_reads_log_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Hook logs' do
- let(:web_hook_log) { create(:web_hook_log, response_body: '<script>') }
+describe "Hook logs" do
+ let(:web_hook_log) { create(:web_hook_log, response_body: "<script>") }
let(:project) { web_hook_log.web_hook.project }
let(:user) { create(:user) }
@@ -11,11 +11,13 @@ describe 'Hook logs' do
sign_in(user)
end
- it 'user reads log without getting XSS' do
+ it "user reads log without getting XSS" do
visit(
project_hook_hook_log_path(
- project, web_hook_log.web_hook, web_hook_log))
+ project, web_hook_log.web_hook, web_hook_log
+ )
+ )
- expect(page).to have_content('<script>')
+ expect(page).to have_content("<script>")
end
end
diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb
index f76f9ba7577..92d286d8f0f 100644
--- a/spec/features/projects/import_export/export_file_spec.rb
+++ b/spec/features/projects/import_export/export_file_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
# Integration test that exports a file using the Import/Export feature
# It looks up for any sensitive word inside the JSON, so if a sensitive word is found
# we'll have to either include it adding the model that includes it to the +safe_list+
# or make sure the attribute is blacklisted in the +import_export.yml+ configuration
-describe 'Import/Export - project export integration test', :js do
+describe "Import/Export - project export integration test", :js do
include Select2Helper
include ExportFileHelper
@@ -16,10 +16,10 @@ describe 'Import/Export - project export integration test', :js do
let(:safe_list) do
{
token: [ProjectHook, Ci::Trigger, CommitStatus],
- key: [Project, Ci::Variable, :yaml_variables]
+ key: [Project, Ci::Variable, :yaml_variables],
}
end
- let(:safe_hashes) { { yaml_variables: %w[key value public] } }
+ let(:safe_hashes) { {yaml_variables: %w[key value public]} }
let(:project) { setup_project }
@@ -31,30 +31,30 @@ describe 'Import/Export - project export integration test', :js do
FileUtils.rm_rf(export_path, secure: true)
end
- context 'admin user' do
+ context "admin user" do
before do
sign_in(user)
end
- it 'exports a project successfully' do
+ it "exports a project successfully" do
visit edit_project_path(project)
- expect(page).to have_content('Export project')
+ expect(page).to have_content("Export project")
- find(:link, 'Export project').send_keys(:return)
+ find(:link, "Export project").send_keys(:return)
visit edit_project_path(project)
- expect(page).to have_content('Download export')
+ expect(page).to have_content("Download export")
- expect(file_permissions(project.export_path)).to eq(0700)
+ expect(file_permissions(project.export_path)).to eq(0o700)
- expect(project.export_file.path).to include('tar.gz')
+ expect(project.export_file.path).to include("tar.gz")
in_directory_with_expanded_export(project) do |exit_status, tmpdir|
expect(exit_status).to eq(0)
- project_json_path = File.join(tmpdir, 'project.json')
+ project_json_path = File.join(tmpdir, "project.json")
expect(File).to exist(project_json_path)
project_hash = JSON.parse(IO.read(project_json_path))
diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb
index 28ae90bc0de..6e40025e568 100644
--- a/spec/features/projects/import_export/import_file_spec.rb
+++ b/spec/features/projects/import_export/import_file_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Import/Export - project import integration test', :js do
+describe "Import/Export - project import integration test", :js do
include Select2Helper
include GitHelpers
let(:user) { create(:user) }
- let(:file) { File.join(Rails.root, 'spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
+ let(:file) { File.join(Rails.root, "spec", "features", "projects", "import_export", "test_project_export.tar.gz") }
let(:export_path) { "#{Dir.tmpdir}/import_file_spec" }
before do
@@ -18,27 +18,27 @@ describe 'Import/Export - project import integration test', :js do
FileUtils.rm_rf(export_path, secure: true)
end
- context 'when selecting the namespace' do
+ context "when selecting the namespace" do
let(:user) { create(:admin) }
let!(:namespace) { user.namespace }
let(:randomHex) { SecureRandom.hex }
- let(:project_name) { 'Test Project Name' + randomHex }
- let(:project_path) { 'test-project-name' + randomHex }
+ let(:project_name) { "Test Project Name" + randomHex }
+ let(:project_path) { "test-project-name" + randomHex }
- context 'prefilled the path' do
- it 'user imports an exported project successfully' do
+ context "prefilled the path" do
+ it "user imports an exported project successfully" do
visit new_project_path
- select2(namespace.id, from: '#project_namespace_id')
+ select2(namespace.id, from: "#project_namespace_id")
fill_in :project_name, with: project_name, visible: true
click_import_project_tab
- click_link 'GitLab export'
+ click_link "GitLab export"
- expect(page).to have_content('Import an exported GitLab project')
+ expect(page).to have_content("Import an exported GitLab project")
expect(URI.parse(current_url).query).to eq("namespace_id=#{namespace.id}&name=#{ERB::Util.url_encode(project_name)}&path=#{project_path}")
- attach_file('file', file)
- click_on 'Import project'
+ attach_file("file", file)
+ click_on "Import project"
expect(Project.count).to eq(1)
@@ -49,21 +49,21 @@ describe 'Import/Export - project import integration test', :js do
expect(project.merge_requests).not_to be_empty
expect(project_hook_exists?(project)).to be true
expect(wiki_exists?(project)).to be true
- expect(project.import_state.status).to eq('finished')
+ expect(project.import_state.status).to eq("finished")
end
end
- context 'path is not prefilled' do
- it 'user imports an exported project successfully' do
+ context "path is not prefilled" do
+ it "user imports an exported project successfully" do
visit new_project_path
click_import_project_tab
- click_link 'GitLab export'
+ click_link "GitLab export"
- fill_in :name, with: 'Test Project Name', visible: true
- fill_in :path, with: 'test-project-path', visible: true
- attach_file('file', file)
+ fill_in :name, with: "Test Project Name", visible: true
+ fill_in :path, with: "test-project-path", visible: true
+ attach_file("file", file)
- expect { click_on 'Import project' }.to change { Project.count }.by(1)
+ expect { click_on "Import project" }.to change { Project.count }.by(1)
project = Project.last
expect(project).not_to be_nil
@@ -72,20 +72,20 @@ describe 'Import/Export - project import integration test', :js do
end
end
- it 'invalid project' do
+ it "invalid project" do
project = create(:project, namespace: user.namespace)
visit new_project_path
- select2(user.namespace.id, from: '#project_namespace_id')
+ select2(user.namespace.id, from: "#project_namespace_id")
fill_in :project_name, with: project.name, visible: true
click_import_project_tab
- click_link 'GitLab export'
- attach_file('file', file)
- click_on 'Import project'
+ click_link "GitLab export"
+ attach_file("file", file)
+ click_on "Import project"
- page.within('.flash-container') do
- expect(page).to have_content('Project could not be imported')
+ page.within(".flash-container") do
+ expect(page).to have_content("Project could not be imported")
end
end
@@ -95,6 +95,6 @@ describe 'Import/Export - project import integration test', :js do
end
def click_import_project_tab
- find('#import-project-tab').click
+ find("#import-project-tab").click
end
end
diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb
index a57edc394f9..12264451426 100644
--- a/spec/features/projects/issuable_templates_spec.rb
+++ b/spec/features/projects/issuable_templates_spec.rb
@@ -1,117 +1,121 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'issuable templates', :js do
+describe "issuable templates", :js do
include ProjectForksHelper
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
- let(:issue_form_location) { '#content-body .issuable-details .detail-page-description' }
+ let(:issue_form_location) { "#content-body .issuable-details .detail-page-description" }
before do
project.add_maintainer(user)
sign_in user
end
- context 'user creates an issue using templates' do
+ context "user creates an issue using templates" do
let(:template_content) { 'this is a test "bug" template' }
- let(:longtemplate_content) { %Q(this\n\n\n\n\nis\n\n\n\n\na\n\n\n\n\nbug\n\n\n\n\ntemplate) }
+ let(:longtemplate_content) { %(this\n\n\n\n\nis\n\n\n\n\na\n\n\n\n\nbug\n\n\n\n\ntemplate) }
let(:issue) { create(:issue, author: user, assignees: [user], project: project) }
- let(:description_addition) { ' appending to description' }
+ let(:description_addition) { " appending to description" }
before do
project.repository.create_file(
user,
- '.gitlab/issue_templates/bug.md',
+ ".gitlab/issue_templates/bug.md",
template_content,
- message: 'added issue template',
- branch_name: 'master')
+ message: "added issue template",
+ branch_name: "master"
+ )
project.repository.create_file(
user,
- '.gitlab/issue_templates/test.md',
+ ".gitlab/issue_templates/test.md",
longtemplate_content,
- message: 'added issue template',
- branch_name: 'master')
+ message: "added issue template",
+ branch_name: "master"
+ )
visit project_issue_path project, issue
- page.find('.js-issuable-edit').click
- fill_in :'issuable-title', with: 'test issue title'
+ page.find(".js-issuable-edit").click
+ fill_in :'issuable-title', with: "test issue title"
end
it 'user selects "bug" template' do
- select_template 'bug'
+ select_template "bug"
wait_for_requests
assert_template(page_part: issue_form_location)
save_changes
end
it 'user selects "bug" template and then "no template"' do
- select_template 'bug'
+ select_template "bug"
wait_for_requests
- select_option 'No template'
- assert_template(expected_content: '', page_part: issue_form_location)
- save_changes('')
+ select_option "No template"
+ assert_template(expected_content: "", page_part: issue_form_location)
+ save_changes("")
end
it 'user selects "bug" template, edits description and then selects "reset template"' do
- select_template 'bug'
+ select_template "bug"
wait_for_requests
- find_field('issue-description').send_keys(description_addition)
+ find_field("issue-description").send_keys(description_addition)
assert_template(expected_content: template_content + description_addition, page_part: issue_form_location)
- select_option 'Reset template'
+ select_option "Reset template"
assert_template(page_part: issue_form_location)
save_changes
end
end
- context 'user creates an issue using templates, with a prior description' do
- let(:prior_description) { 'test issue description' }
+ context "user creates an issue using templates, with a prior description" do
+ let(:prior_description) { "test issue description" }
let(:template_content) { 'this is a test "bug" template' }
let(:issue) { create(:issue, author: user, assignees: [user], project: project) }
before do
project.repository.create_file(
user,
- '.gitlab/issue_templates/bug.md',
+ ".gitlab/issue_templates/bug.md",
template_content,
- message: 'added issue template',
- branch_name: 'master')
+ message: "added issue template",
+ branch_name: "master"
+ )
visit project_issue_path project, issue
- page.find('.js-issuable-edit').click
- fill_in :'issuable-title', with: 'test issue title'
+ page.find(".js-issuable-edit").click
+ fill_in :'issuable-title', with: "test issue title"
fill_in :'issue-description', with: prior_description
end
it 'user selects "bug" template' do
- select_template 'bug'
+ select_template "bug"
wait_for_requests
assert_template(page_part: issue_form_location)
save_changes
end
end
- context 'user creates a merge request using templates' do
+ context "user creates a merge request using templates" do
let(:template_content) { 'this is a test "feature-proposal" template' }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project) }
before do
project.repository.create_file(
user,
- '.gitlab/merge_request_templates/feature-proposal.md',
+ ".gitlab/merge_request_templates/feature-proposal.md",
template_content,
- message: 'added merge request template',
- branch_name: 'master')
+ message: "added merge request template",
+ branch_name: "master"
+ )
visit edit_project_merge_request_path project, merge_request
- fill_in :'merge_request[title]', with: 'test merge request title'
+ fill_in :'merge_request[title]', with: "test merge request title"
end
it 'user selects "feature-proposal" template' do
- select_template 'feature-proposal'
+ select_template "feature-proposal"
wait_for_requests
assert_template
save_changes
end
end
- context 'user creates a merge request from a forked project using templates' do
+ context "user creates a merge request from a forked project using templates" do
let(:template_content) { 'this is a test "feature-proposal" template' }
let(:fork_user) { create(:user) }
let(:forked_project) { fork_project(project, fork_user, repository: true) }
@@ -126,18 +130,19 @@ describe 'issuable templates', :js do
project.repository.create_file(
fork_user,
- '.gitlab/merge_request_templates/feature-proposal.md',
+ ".gitlab/merge_request_templates/feature-proposal.md",
template_content,
- message: 'added merge request template',
- branch_name: 'master')
+ message: "added merge request template",
+ branch_name: "master"
+ )
visit edit_project_merge_request_path project, merge_request
- fill_in :'merge_request[title]', with: 'test merge request title'
+ fill_in :'merge_request[title]', with: "test merge request title"
end
- context 'feature proposal template' do
- context 'template exists in target project' do
- it 'user selects template' do
- select_template 'feature-proposal'
+ context "feature proposal template" do
+ context "template exists in target project" do
+ it "user selects template" do
+ select_template "feature-proposal"
wait_for_requests
assert_template
save_changes
@@ -146,9 +151,9 @@ describe 'issuable templates', :js do
end
end
- def assert_template(expected_content: template_content, page_part: '#content-body')
+ def assert_template(expected_content: template_content, page_part: "#content-body")
page.within(page_part) do
- expect(find('textarea')['value']).to eq(expected_content)
+ expect(find("textarea")["value"]).to eq(expected_content)
end
end
@@ -158,14 +163,14 @@ describe 'issuable templates', :js do
end
def select_template(name)
- find('.js-issuable-selector').click
+ find(".js-issuable-selector").click
- find('.js-issuable-selector-wrap .dropdown-content a', text: name, match: :first).click
+ find(".js-issuable-selector-wrap .dropdown-content a", text: name, match: :first).click
end
def select_option(name)
- find('.js-issuable-selector').click
+ find(".js-issuable-selector").click
- find('.js-issuable-selector-wrap .dropdown-footer-list a', text: name, match: :first).click
+ find(".js-issuable-selector-wrap .dropdown-footer-list a", text: name, match: :first).click
end
end
diff --git a/spec/features/projects/jobs/permissions_spec.rb b/spec/features/projects/jobs/permissions_spec.rb
index 6ce37297a7e..c4ca40a31c5 100644
--- a/spec/features/projects/jobs/permissions_spec.rb
+++ b/spec/features/projects/jobs/permissions_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Jobs Permissions' do
+describe "Project Jobs Permissions" do
let(:user) { create(:user) }
- let(:group) { create(:group, name: 'some group') }
+ let(:group) { create(:group, name: "some group") }
let(:project) { create(:project, :repository, namespace: group) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: "master") }
let!(:job) { create(:ci_build, :running, :coverage, :trace_artifact, pipeline: pipeline) }
before do
@@ -13,8 +13,8 @@ describe 'Project Jobs Permissions' do
project.enable_ci
end
- describe 'jobs pages' do
- shared_examples 'recent job page details responds with status' do |status|
+ describe "jobs pages" do
+ shared_examples "recent job page details responds with status" do |status|
before do
visit project_job_path(project, job)
end
@@ -22,7 +22,7 @@ describe 'Project Jobs Permissions' do
it { expect(status_code).to eq(status) }
end
- shared_examples 'project jobs page responds with status' do |status|
+ shared_examples "project jobs page responds with status" do |status|
before do
visit project_jobs_path(project)
end
@@ -30,50 +30,50 @@ describe 'Project Jobs Permissions' do
it { expect(status_code).to eq(status) }
end
- context 'when public access for jobs is disabled' do
+ context "when public access for jobs is disabled" do
before do
project.update(public_builds: false)
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like 'recent job page details responds with status', 404
- it_behaves_like 'project jobs page responds with status', 404
+ it_behaves_like "recent job page details responds with status", 404
+ it_behaves_like "project jobs page responds with status", 404
end
- context 'when project is internal' do
+ context "when project is internal" do
before do
project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- it_behaves_like 'recent job page details responds with status', 404
- it_behaves_like 'project jobs page responds with status', 404
+ it_behaves_like "recent job page details responds with status", 404
+ it_behaves_like "project jobs page responds with status", 404
end
end
- context 'when public access for jobs is enabled' do
+ context "when public access for jobs is enabled" do
before do
project.update(public_builds: true)
end
- context 'when project is internal' do
+ context "when project is internal" do
before do
project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- it_behaves_like 'recent job page details responds with status', 200 do
- it 'renders job details', :js do
+ it_behaves_like "recent job page details responds with status", 200 do
+ it "renders job details", :js do
expect(page).to have_content "Job ##{job.id}"
- expect(page).to have_css '.js-build-trace'
+ expect(page).to have_css ".js-build-trace"
end
end
- it_behaves_like 'project jobs page responds with status', 200 do
- it 'renders job' do
- page.within('.build') do
+ it_behaves_like "project jobs page responds with status", 200 do
+ it "renders job" do
+ page.within(".build") do
expect(page).to have_content("##{job.id}")
.and have_content(job.sha[0..7])
.and have_content(job.ref)
@@ -85,42 +85,42 @@ describe 'Project Jobs Permissions' do
end
end
- describe 'artifacts page' do
- context 'when recent job has artifacts available' do
+ describe "artifacts page" do
+ context "when recent job has artifacts available" do
before do
- archive = fixture_file_upload('spec/fixtures/ci_build_artifacts.zip')
+ archive = fixture_file_upload("spec/fixtures/ci_build_artifacts.zip")
job.update(legacy_artifacts_file: archive)
end
- context 'when public access for jobs is disabled' do
+ context "when public access for jobs is disabled" do
before do
project.update(public_builds: false)
end
- context 'when user with guest role' do
+ context "when user with guest role" do
before do
project.add_guest(user)
end
- it 'responds with 404 status' do
+ it "responds with 404 status" do
visit download_project_job_artifacts_path(project, job)
expect(status_code).to eq(404)
end
end
- context 'when user with reporter role' do
+ context "when user with reporter role" do
before do
project.add_reporter(user)
end
- it 'starts download artifact' do
+ it "starts download artifact" do
visit download_project_job_artifacts_path(project, job)
expect(status_code).to eq(200)
- expect(page.response_headers['Content-Type']).to eq 'application/zip'
- expect(page.response_headers['Content-Transfer-Encoding']).to eq 'binary'
+ expect(page.response_headers["Content-Type"]).to eq "application/zip"
+ expect(page.response_headers["Content-Transfer-Encoding"]).to eq "binary"
end
end
end
diff --git a/spec/features/projects/jobs/user_browses_job_spec.rb b/spec/features/projects/jobs/user_browses_job_spec.rb
index 908c616f2fc..f169a3ef80d 100644
--- a/spec/features/projects/jobs/user_browses_job_spec.rb
+++ b/spec/features/projects/jobs/user_browses_job_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User browses a job', :js do
+describe "User browses a job", :js do
let(:user) { create(:user) }
let(:user_access_level) { :developer }
let(:project) { create(:project, :repository, namespace: user.namespace) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: "master") }
let!(:build) { create(:ci_build, :success, :trace_artifact, :coverage, pipeline: pipeline) }
before do
@@ -16,44 +16,44 @@ describe 'User browses a job', :js do
visit(project_job_path(project, build))
end
- it 'erases the job log', :js do
+ it "erases the job log", :js do
wait_for_requests
expect(page).to have_content("Job ##{build.id}")
- expect(page).to have_css('.js-build-trace')
+ expect(page).to have_css(".js-build-trace")
# scroll to the top of the page first
execute_script "window.scrollTo(0,0)"
- accept_confirm { find('.js-erase-link').click }
+ accept_confirm { find(".js-erase-link").click }
- expect(page).to have_no_css('.artifacts')
+ expect(page).to have_no_css(".artifacts")
expect(build).not_to have_trace
expect(build.artifacts_file.exists?).to be_falsy
expect(build.artifacts_metadata.exists?).to be_falsy
- expect(page).to have_content('Job has been erased')
+ expect(page).to have_content("Job has been erased")
end
- context 'with a failed job' do
+ context "with a failed job" do
let!(:build) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) }
- it 'displays the failure reason' do
+ it "displays the failure reason" do
wait_for_all_requests
- within('.builds-container') do
- build_link = first('.build-job > a')
- expect(build_link['data-original-title']).to eq('test - failed - (unknown failure)')
+ within(".builds-container") do
+ build_link = first(".build-job > a")
+ expect(build_link["data-original-title"]).to eq("test - failed - (unknown failure)")
end
end
end
- context 'when a failed job has been retried' do
+ context "when a failed job has been retried" do
let!(:build) { create(:ci_build, :failed, :retried, :trace_artifact, pipeline: pipeline) }
- it 'displays the failure reason and retried label' do
+ it "displays the failure reason and retried label" do
wait_for_all_requests
- within('.builds-container') do
- build_link = first('.build-job > a')
- expect(build_link['data-original-title']).to eq('test - failed - (unknown failure) (retried)')
+ within(".builds-container") do
+ build_link = first(".build-job > a")
+ expect(build_link["data-original-title"]).to eq("test - failed - (unknown failure) (retried)")
end
end
end
diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb
index ebc20d15d67..c9839b0b66b 100644
--- a/spec/features/projects/jobs/user_browses_jobs_spec.rb
+++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User browses jobs' do
+describe "User browses jobs" do
let!(:build) { create(:ci_build, :coverage, pipeline: pipeline) }
- let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') }
+ let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: "master") }
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:user) { create(:user) }
@@ -16,27 +16,27 @@ describe 'User browses jobs' do
visit(project_jobs_path(project))
end
- it 'shows the coverage' do
- page.within('td.coverage') do
- expect(page).to have_content('99.9%')
+ it "shows the coverage" do
+ page.within("td.coverage") do
+ expect(page).to have_content("99.9%")
end
end
it 'shows the "CI Lint" button' do
- page.within('.nav-controls') do
- ci_lint_tool_link = page.find_link('CI lint')
+ page.within(".nav-controls") do
+ ci_lint_tool_link = page.find_link("CI lint")
expect(ci_lint_tool_link[:href]).to end_with(project_ci_lint_path(project))
end
end
- context 'with a failed job' do
+ context "with a failed job" do
let!(:build) { create(:ci_build, :coverage, :failed, pipeline: pipeline) }
- it 'displays a tooltip with the failure reason' do
- page.within('.ci-table') do
- failed_job_link = page.find('.ci-failed')
- expect(failed_job_link[:title]).to eq('Failed - (unknown failure)')
+ it "displays a tooltip with the failure reason" do
+ page.within(".ci-table") do
+ failed_job_link = page.find(".ci-failed")
+ expect(failed_job_link[:title]).to eq("Failed - (unknown failure)")
end
end
end
diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb
index 65ce872363f..7a8a4dda025 100644
--- a/spec/features/projects/jobs_spec.rb
+++ b/spec/features/projects/jobs_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require 'tempfile'
+require "spec_helper"
+require "tempfile"
-describe 'Jobs', :clean_gitlab_redis_shared_state do
+describe "Jobs", :clean_gitlab_redis_shared_state do
let(:user) { create(:user) }
let(:user_access_level) { :developer }
let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
+ let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit("HEAD").sha) }
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
let(:job2) { create(:ci_build) }
let(:artifacts_file) do
- fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')
+ fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif")
end
before do
@@ -28,7 +28,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
it "shows Pending tab jobs" do
- expect(page).to have_selector('.nav-links li.active', text: 'Pending')
+ expect(page).to have_selector(".nav-links li.active", text: "Pending")
expect(page).to have_content job.short_sha
expect(page).to have_content job.ref
expect(page).to have_content job.name
@@ -42,7 +42,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
it "shows Running tab jobs" do
- expect(page).to have_selector('.nav-links li.active', text: 'Running')
+ expect(page).to have_selector(".nav-links li.active", text: "Running")
expect(page).to have_content job.short_sha
expect(page).to have_content job.ref
expect(page).to have_content job.name
@@ -56,8 +56,8 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
it "shows Finished tab jobs" do
- expect(page).to have_selector('.nav-links li.active', text: 'Finished')
- expect(page).to have_content 'No jobs to show'
+ expect(page).to have_selector(".nav-links li.active", text: "Finished")
+ expect(page).to have_content "No jobs to show"
end
end
@@ -68,7 +68,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
it "shows All tab jobs" do
- expect(page).to have_selector('.nav-links li.active', text: 'All')
+ expect(page).to have_selector(".nav-links li.active", text: "All")
expect(page).to have_content job.short_sha
expect(page).to have_content job.ref
expect(page).to have_content job.name
@@ -81,7 +81,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
before do
- visit jobs_url.sub('/-/jobs', '/builds')
+ visit jobs_url.sub("/-/jobs", "/builds")
end
it "redirects to new URL" do
@@ -94,18 +94,18 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
context "Job from project" do
let(:job) { create(:ci_build, :success, :trace_live, pipeline: pipeline) }
- it 'shows status name', :js do
+ it "shows status name", :js do
visit project_job_path(project, job)
wait_for_requests
- expect(page).to have_css('.ci-status.ci-success', text: 'passed')
+ expect(page).to have_css(".ci-status.ci-success", text: "passed")
end
- it 'shows commit`s data', :js do
- requests = inspect_requests do
+ it "shows commit`s data", :js do
+ requests = inspect_requests {
visit project_job_path(project, job)
- end
+ }
wait_for_requests
expect(requests.first.status_code).to eq(200)
@@ -113,71 +113,71 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
expect(page).to have_content pipeline.commit.title
end
- it 'shows active job', :js do
+ it "shows active job", :js do
visit project_job_path(project, job)
wait_for_requests
- expect(page).to have_selector('.build-job.active')
+ expect(page).to have_selector(".build-job.active")
end
end
- context 'sidebar', :js do
- let(:job) { create(:ci_build, :success, :trace_live, pipeline: pipeline, name: '<img src=x onerror=alert(document.domain)>') }
+ context "sidebar", :js do
+ let(:job) { create(:ci_build, :success, :trace_live, pipeline: pipeline, name: "<img src=x onerror=alert(document.domain)>") }
before do
visit project_job_path(project, job)
wait_for_requests
end
- it 'renders escaped tooltip name' do
- page.find('.active.build-job a').hover
- expect(page).to have_content('<img src=x onerror=alert(document.domain)> - passed')
+ it "renders escaped tooltip name" do
+ page.find(".active.build-job a").hover
+ expect(page).to have_content("<img src=x onerror=alert(document.domain)> - passed")
end
end
- context 'when job is not running', :js do
+ context "when job is not running", :js do
let(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'shows retry button' do
- expect(page).to have_link('Retry')
+ it "shows retry button" do
+ expect(page).to have_link("Retry")
end
- context 'if job passed' do
- it 'does not show New issue button' do
- expect(page).not_to have_link('New issue')
+ context "if job passed" do
+ it "does not show New issue button" do
+ expect(page).not_to have_link("New issue")
end
end
- context 'if job failed' do
+ context "if job failed" do
let(:job) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'shows New issue button' do
- expect(page).to have_link('New issue')
+ it "shows New issue button" do
+ expect(page).to have_link("New issue")
end
- it 'links to issues/new with the title and description filled in' do
+ it "links to issues/new with the title and description filled in" do
button_title = "Job Failed ##{job.id}"
job_url = project_job_url(project, job, host: page.server.host, port: page.server.port)
- options = { issue: { title: button_title, description: "Job [##{job.id}](#{job_url}) failed for #{job.sha}:\n" } }
+ options = {issue: {title: button_title, description: "Job [##{job.id}](#{job_url}) failed for #{job.sha}:\n"}}
href = new_project_issue_path(project, options)
- page.within('.build-sidebar') do
- expect(find('.js-new-issue')['href']).to include(href)
+ page.within(".build-sidebar") do
+ expect(find(".js-new-issue")["href"]).to include(href)
end
end
end
end
- context 'when job is running', :js do
+ context "when job is running", :js do
let(:job) { create(:ci_build, :running, pipeline: pipeline) }
let(:job_url) { project_job_path(project, job) }
@@ -186,9 +186,9 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
wait_for_requests
end
- context 'job is cancelable' do
- it 'shows cancel button' do
- click_link 'Cancel'
+ context "job is cancelable" do
+ it "shows cancel button" do
+ click_link "Cancel"
expect(page.current_path).to eq(job_url)
end
@@ -209,25 +209,25 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
end
- it 'has button to download artifacts' do
- expect(page).to have_content 'Download'
+ it "has button to download artifacts" do
+ expect(page).to have_content "Download"
end
- it 'downloads the zip file when user clicks the download button' do
- requests = inspect_requests do
- click_link 'Download'
- end
+ it "downloads the zip file when user clicks the download button" do
+ requests = inspect_requests {
+ click_link "Download"
+ }
artifact_request = requests.find { |req| req.url.match(%r{artifacts/download}) }
- expect(artifact_request.response_headers["Content-Disposition"]).to eq(%Q{attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"})
- expect(artifact_request.response_headers['Content-Transfer-Encoding']).to eq("binary")
- expect(artifact_request.response_headers['Content-Type']).to eq("image/gif")
+ expect(artifact_request.response_headers["Content-Disposition"]).to eq(%(attachment; filename*=UTF-8''#{job.artifacts_file.filename}; filename="#{job.artifacts_file.filename}"))
+ expect(artifact_request.response_headers["Content-Transfer-Encoding"]).to eq("binary")
+ expect(artifact_request.response_headers["Content-Type"]).to eq("image/gif")
expect(artifact_request.body).to eq(job.artifacts_file.file.read.b)
end
end
- context 'Artifacts expire date', :js do
+ context "Artifacts expire date", :js do
before do
job.update(legacy_artifacts_file: artifacts_file,
artifacts_expire_at: expire_at)
@@ -235,43 +235,43 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
end
- context 'no expire date defined' do
+ context "no expire date defined" do
let(:expire_at) { nil }
- it 'does not have the Keep button' do
- expect(page).not_to have_content 'Keep'
+ it "does not have the Keep button" do
+ expect(page).not_to have_content "Keep"
end
end
- context 'when expire date is defined' do
+ context "when expire date is defined" do
let(:expire_at) { Time.now + 7.days }
- context 'when user has ability to update job' do
- it 'keeps artifacts when keep button is clicked' do
- expect(page).to have_content 'The artifacts will be removed in'
+ context "when user has ability to update job" do
+ it "keeps artifacts when keep button is clicked" do
+ expect(page).to have_content "The artifacts will be removed in"
- click_link 'Keep'
+ click_link "Keep"
- expect(page).to have_no_link 'Keep'
- expect(page).to have_no_content 'The artifacts will be removed in'
+ expect(page).to have_no_link "Keep"
+ expect(page).to have_no_content "The artifacts will be removed in"
end
end
- context 'when user does not have ability to update job' do
+ context "when user does not have ability to update job" do
let(:user_access_level) { :guest }
- it 'does not have keep button' do
- expect(page).to have_no_link 'Keep'
+ it "does not have keep button" do
+ expect(page).to have_no_link "Keep"
end
end
end
- context 'when artifacts expired' do
+ context "when artifacts expired" do
let(:expire_at) { Time.now - 7.days }
- it 'does not have the Keep button' do
- expect(page).to have_content 'The artifacts were removed'
- expect(page).not_to have_link 'Keep'
+ it "does not have the Keep button" do
+ expect(page).to have_content "The artifacts were removed"
+ expect(page).not_to have_link "Keep"
end
end
end
@@ -282,7 +282,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
before do
- visit job_url.sub('/-/jobs', '/builds')
+ visit job_url.sub("/-/jobs", "/builds")
end
it "redirects to new URL" do
@@ -290,7 +290,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
end
- describe 'Raw trace', :js do
+ describe "Raw trace", :js do
before do
job.run!
@@ -299,158 +299,158 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
it do
wait_for_all_requests
- expect(page).to have_css('.js-raw-link-controller')
+ expect(page).to have_css(".js-raw-link-controller")
end
end
- describe 'HTML trace', :js do
+ describe "HTML trace", :js do
before do
job.run!
visit project_job_path(project, job)
end
- context 'when job has an initial trace' do
- it 'loads job trace' do
- expect(page).to have_content 'BUILD TRACE'
+ context "when job has an initial trace" do
+ it "loads job trace" do
+ expect(page).to have_content "BUILD TRACE"
- job.trace.write('a+b') do |stream|
- stream.append(' and more trace', 11)
+ job.trace.write("a+b") do |stream|
+ stream.append(" and more trace", 11)
end
- expect(page).to have_content 'BUILD TRACE and more trace'
+ expect(page).to have_content "BUILD TRACE and more trace"
end
end
end
- describe 'Variables' do
+ describe "Variables" do
let(:trigger_request) { create(:ci_trigger_request) }
let(:job) { create(:ci_build, pipeline: pipeline, trigger_request: trigger_request) }
- context 'when user is a maintainer' do
- shared_examples 'no reveal button variables behavior' do
- it 'renders a hidden value with no reveal values button', :js do
- expect(page).to have_content('Trigger token')
- expect(page).to have_content('Trigger variables')
+ context "when user is a maintainer" do
+ shared_examples "no reveal button variables behavior" do
+ it "renders a hidden value with no reveal values button", :js do
+ expect(page).to have_content("Trigger token")
+ expect(page).to have_content("Trigger variables")
- expect(page).not_to have_css('.js-reveal-variables')
+ expect(page).not_to have_css(".js-reveal-variables")
- expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1')
- expect(page).to have_selector('.js-build-value', text: '••••••')
+ expect(page).to have_selector(".js-build-variable", text: "TRIGGER_KEY_1")
+ expect(page).to have_selector(".js-build-value", text: "••••••")
end
end
- context 'when variables are stored in trigger_request' do
+ context "when variables are stored in trigger_request" do
before do
- trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } )
+ trigger_request.update_attribute(:variables, {"TRIGGER_KEY_1" => "TRIGGER_VALUE_1"})
visit project_job_path(project, job)
end
- it_behaves_like 'no reveal button variables behavior'
+ it_behaves_like "no reveal button variables behavior"
end
- context 'when variables are stored in pipeline_variables' do
+ context "when variables are stored in pipeline_variables" do
before do
- create(:ci_pipeline_variable, pipeline: pipeline, key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1")
visit project_job_path(project, job)
end
- it_behaves_like 'no reveal button variables behavior'
+ it_behaves_like "no reveal button variables behavior"
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- shared_examples 'reveal button variables behavior' do
- it 'renders a hidden value with a reveal values button', :js do
- expect(page).to have_content('Trigger token')
- expect(page).to have_content('Trigger variables')
+ shared_examples "reveal button variables behavior" do
+ it "renders a hidden value with a reveal values button", :js do
+ expect(page).to have_content("Trigger token")
+ expect(page).to have_content("Trigger variables")
- expect(page).to have_css('.js-reveal-variables')
+ expect(page).to have_css(".js-reveal-variables")
- expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1')
- expect(page).to have_selector('.js-build-value', text: '••••••')
+ expect(page).to have_selector(".js-build-variable", text: "TRIGGER_KEY_1")
+ expect(page).to have_selector(".js-build-value", text: "••••••")
end
- it 'reveals values on button click', :js do
- click_button 'Reveal values'
+ it "reveals values on button click", :js do
+ click_button "Reveal values"
- expect(page).to have_selector('.js-build-variable', text: 'TRIGGER_KEY_1')
- expect(page).to have_selector('.js-build-value', text: 'TRIGGER_VALUE_1')
+ expect(page).to have_selector(".js-build-variable", text: "TRIGGER_KEY_1")
+ expect(page).to have_selector(".js-build-value", text: "TRIGGER_VALUE_1")
end
end
- context 'when variables are stored in trigger_request' do
+ context "when variables are stored in trigger_request" do
before do
- trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } )
+ trigger_request.update_attribute(:variables, {"TRIGGER_KEY_1" => "TRIGGER_VALUE_1"})
visit project_job_path(project, job)
end
- it_behaves_like 'reveal button variables behavior'
+ it_behaves_like "reveal button variables behavior"
end
- context 'when variables are stored in pipeline_variables' do
+ context "when variables are stored in pipeline_variables" do
before do
- create(:ci_pipeline_variable, pipeline: pipeline, key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1")
visit project_job_path(project, job)
end
- it_behaves_like 'reveal button variables behavior'
+ it_behaves_like "reveal button variables behavior"
end
end
end
- context 'when job starts environment', :js do
- let(:environment) { create(:environment, name: 'production', project: project) }
+ context "when job starts environment", :js do
+ let(:environment) { create(:environment, name: "production", project: project) }
before do
visit project_job_path(project, build)
wait_for_requests
end
- context 'job is successful and has deployment' do
+ context "job is successful and has deployment" do
let(:build) { create(:ci_build, :success, :trace_live, environment: environment.name, pipeline: pipeline, deployment: deployment) }
let(:deployment) { create(:deployment, :success, environment: environment, project: environment.project) }
- it 'shows a link for the job' do
+ it "shows a link for the job" do
expect(page).to have_link environment.name
end
- it 'shows deployment message' do
- expect(page).to have_content 'This job is the most recent deployment'
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ it "shows deployment message" do
+ expect(page).to have_content "This job is the most recent deployment"
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
end
- context 'job is complete and not successful' do
+ context "job is complete and not successful" do
let(:build) { create(:ci_build, :failed, :trace_artifact, environment: environment.name, pipeline: pipeline) }
- it 'shows a link for the job' do
+ it "shows a link for the job" do
expect(page).to have_link environment.name
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
end
- context 'deployment still not finished' do
+ context "deployment still not finished" do
let(:build) { create(:ci_build, :running, environment: environment.name, pipeline: pipeline) }
- it 'shows a link to latest deployment' do
+ it "shows a link to latest deployment" do
expect(page).to have_link environment.name
- expect(page).to have_content 'This job is creating a deployment'
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ expect(page).to have_content "This job is creating a deployment"
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
end
end
- context 'when job stops environment', :js do
- let(:environment) { create(:environment, name: 'production', project: project) }
+ context "when job stops environment", :js do
+ let(:environment) { create(:environment, name: "production", project: project) }
let(:build) do
create(
:ci_build,
@@ -458,7 +458,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
:trace_live,
environment: environment.name,
pipeline: pipeline,
- options: { environment: { action: 'stop' } }
+ options: {environment: {action: "stop"}}
)
end
@@ -467,14 +467,14 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
wait_for_requests
end
- it 'does not show environment information banner' do
- expect(page).not_to have_selector('.js-environment-container')
- expect(page).not_to have_selector('.environment-information')
+ it "does not show environment information banner" do
+ expect(page).not_to have_selector(".js-environment-container")
+ expect(page).not_to have_selector(".environment-information")
expect(page).not_to have_text(environment.name)
end
end
- describe 'environment info in job view', :js do
+ describe "environment info in job view", :js do
before do
allow_any_instance_of(Ci::Build).to receive(:create_deployment)
@@ -482,106 +482,111 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
wait_for_requests
end
- context 'job with outdated deployment' do
- let(:job) { create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) }
- let(:second_build) { create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) }
- let(:environment) { create(:environment, name: 'staging', project: project) }
+ context "job with outdated deployment" do
+ let(:job) { create(:ci_build, :success, :trace_artifact, environment: "staging", pipeline: pipeline) }
+ let(:second_build) { create(:ci_build, :success, :trace_artifact, environment: "staging", pipeline: pipeline) }
+ let(:environment) { create(:environment, name: "staging", project: project) }
let!(:first_deployment) { create(:deployment, :success, environment: environment, deployable: job) }
let!(:second_deployment) { create(:deployment, :success, environment: environment, deployable: second_build) }
- it 'shows deployment message' do
- expected_text = 'This job is an out-of-date deployment ' \
+ it "shows deployment message" do
+ expected_text = "This job is an out-of-date deployment " \
"to staging. View the most recent deployment ##{second_deployment.iid}."
- expect(page).to have_css('.environment-information', text: expected_text)
+ expect(page).to have_css(".environment-information", text: expected_text)
end
- it 'renders a link to the most recent deployment' do
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
- expect(find('.js-job-deployment-link')['href']).to include(second_deployment.deployable.project.path, second_deployment.deployable_id.to_s)
+ it "renders a link to the most recent deployment" do
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
+ expect(find(".js-job-deployment-link")["href"]).to include(second_deployment.deployable.project.path, second_deployment.deployable_id.to_s)
end
end
- context 'job failed to deploy' do
- let(:job) { create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) }
- let!(:environment) { create(:environment, name: 'staging', project: project) }
+ context "job failed to deploy" do
+ let(:job) { create(:ci_build, :failed, :trace_artifact, environment: "staging", pipeline: pipeline) }
+ let!(:environment) { create(:environment, name: "staging", project: project) }
- it 'shows deployment message' do
- expected_text = 'The deployment of this job to staging did not succeed.'
+ it "shows deployment message" do
+ expected_text = "The deployment of this job to staging did not succeed."
- expect(page).to have_css('.environment-information', text: expected_text)
+ expect(page).to have_css(".environment-information", text: expected_text)
end
end
- context 'job will deploy' do
- let(:job) { create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) }
+ context "job will deploy" do
+ let(:job) { create(:ci_build, :running, :trace_live, environment: "staging", pipeline: pipeline) }
- context 'when environment exists' do
- let!(:environment) { create(:environment, name: 'staging', project: project) }
+ context "when environment exists" do
+ let!(:environment) { create(:environment, name: "staging", project: project) }
- it 'shows deployment message' do
- expected_text = 'This job is creating a deployment to staging'
+ it "shows deployment message" do
+ expected_text = "This job is creating a deployment to staging"
- expect(page).to have_css('.environment-information', text: expected_text)
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ expect(page).to have_css(".environment-information", text: expected_text)
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
- context 'when it has deployment' do
+ context "when it has deployment" do
let!(:deployment) { create(:deployment, :success, environment: environment) }
- it 'shows that deployment will be overwritten' do
- expected_text = 'This job is creating a deployment to staging'
+ it "shows that deployment will be overwritten" do
+ expected_text = "This job is creating a deployment to staging"
- expect(page).to have_css('.environment-information', text: expected_text)
- expect(page).to have_css('.environment-information', text: 'latest deployment')
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ expect(page).to have_css(".environment-information", text: expected_text)
+ expect(page).to have_css(".environment-information", text: "latest deployment")
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
end
end
- context 'when environment does not exist' do
- let!(:environment) { create(:environment, name: 'staging', project: project) }
+ context "when environment does not exist" do
+ let!(:environment) { create(:environment, name: "staging", project: project) }
- it 'shows deployment message' do
- expected_text = 'This job is creating a deployment to staging'
+ it "shows deployment message" do
+ expected_text = "This job is creating a deployment to staging"
expect(page).to have_css(
- '.environment-information', text: expected_text)
+ ".environment-information", text: expected_text
+ )
expect(page).not_to have_css(
- '.environment-information', text: 'latest deployment')
- expect(find('.js-environment-link')['href']).to match("environments/#{environment.id}")
+ ".environment-information", text: "latest deployment"
+ )
+ expect(find(".js-environment-link")["href"]).to match("environments/#{environment.id}")
end
end
end
- context 'job that failed to deploy and environment has not been created' do
- let(:job) { create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) }
- let!(:environment) { create(:environment, name: 'staging', project: project) }
+ context "job that failed to deploy and environment has not been created" do
+ let(:job) { create(:ci_build, :failed, :trace_artifact, environment: "staging", pipeline: pipeline) }
+ let!(:environment) { create(:environment, name: "staging", project: project) }
- it 'shows deployment message' do
- expected_text = 'The deployment of this job to staging did not succeed'
+ it "shows deployment message" do
+ expected_text = "The deployment of this job to staging did not succeed"
expect(page).to have_css(
- '.environment-information', text: expected_text)
+ ".environment-information", text: expected_text
+ )
end
end
- context 'job that will deploy and environment has not been created' do
- let(:job) { create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) }
- let!(:environment) { create(:environment, name: 'staging', project: project) }
+ context "job that will deploy and environment has not been created" do
+ let(:job) { create(:ci_build, :running, :trace_live, environment: "staging", pipeline: pipeline) }
+ let!(:environment) { create(:environment, name: "staging", project: project) }
- it 'shows deployment message' do
- expected_text = 'This job is creating a deployment to staging'
+ it "shows deployment message" do
+ expected_text = "This job is creating a deployment to staging"
expect(page).to have_css(
- '.environment-information', text: expected_text)
+ ".environment-information", text: expected_text
+ )
expect(page).not_to have_css(
- '.environment-information', text: 'latest deployment')
+ ".environment-information", text: "latest deployment"
+ )
end
end
end
- context 'Playable manual action' do
+ context "Playable manual action" do
let(:job) { create(:ci_build, :playable, pipeline: pipeline) }
before do
@@ -589,24 +594,24 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
end
- it 'shows manual action empty state', :js do
+ it "shows manual action empty state", :js do
expect(page).to have_content(job.detailed_status(user).illustration[:title])
- expect(page).to have_content('This job requires a manual action')
- expect(page).to have_content('This job depends on a user to trigger its process. Often they are used to deploy code to production environments')
- expect(page).to have_link('Trigger this manual action')
+ expect(page).to have_content("This job requires a manual action")
+ expect(page).to have_content("This job depends on a user to trigger its process. Often they are used to deploy code to production environments")
+ expect(page).to have_link("Trigger this manual action")
end
- it 'plays manual action and shows pending status', :js do
- click_link 'Trigger this manual action'
+ it "plays manual action and shows pending status", :js do
+ click_link "Trigger this manual action"
wait_for_requests
- expect(page).to have_content('This job has not started yet')
- expect(page).to have_content('This job is in pending state and is waiting to be picked by a runner')
- expect(page).to have_content('pending')
+ expect(page).to have_content("This job has not started yet")
+ expect(page).to have_content("This job is in pending state and is waiting to be picked by a runner")
+ expect(page).to have_content("pending")
end
end
- context 'Delayed job' do
+ context "Delayed job" do
let(:job) { create(:ci_build, :scheduled, pipeline: pipeline) }
before do
@@ -614,205 +619,205 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
end
- it 'shows delayed job', :js do
- expect(page).to have_content('This is a delayed job to run in')
+ it "shows delayed job", :js do
+ expect(page).to have_content("This is a delayed job to run in")
expect(page).to have_content("This job will automatically run after its timer finishes.")
- expect(page).to have_link('Unschedule job')
+ expect(page).to have_link("Unschedule job")
end
- it 'unschedules delayed job and shows manual action', :js do
- click_link 'Unschedule job'
+ it "unschedules delayed job and shows manual action", :js do
+ click_link "Unschedule job"
wait_for_requests
- expect(page).to have_content('This job requires a manual action')
- expect(page).to have_content('This job depends on a user to trigger its process. Often they are used to deploy code to production environments')
- expect(page).to have_link('Trigger this manual action')
+ expect(page).to have_content("This job requires a manual action")
+ expect(page).to have_content("This job depends on a user to trigger its process. Often they are used to deploy code to production environments")
+ expect(page).to have_link("Trigger this manual action")
end
end
- context 'Non triggered job' do
+ context "Non triggered job" do
let(:job) { create(:ci_build, :created, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'shows empty state', :js do
+ it "shows empty state", :js do
expect(page).to have_content(job.detailed_status(user).illustration[:title])
- expect(page).to have_content('This job has not been triggered yet')
- expect(page).to have_content('This job depends on upstream jobs that need to succeed in order for this job to be triggered')
+ expect(page).to have_content("This job has not been triggered yet")
+ expect(page).to have_content("This job depends on upstream jobs that need to succeed in order for this job to be triggered")
end
end
- context 'Pending job', :js do
+ context "Pending job", :js do
let(:job) { create(:ci_build, :pending, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'shows pending empty state' do
+ it "shows pending empty state" do
expect(page).to have_content(job.detailed_status(user).illustration[:title])
- expect(page).to have_content('This job has not started yet')
- expect(page).to have_content('This job is in pending state and is waiting to be picked by a runner')
+ expect(page).to have_content("This job has not started yet")
+ expect(page).to have_content("This job is in pending state and is waiting to be picked by a runner")
end
end
- context 'Canceled job', :js do
- context 'with log' do
+ context "Canceled job", :js do
+ context "with log" do
let(:job) { create(:ci_build, :canceled, :trace_artifact, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'renders job log' do
+ it "renders job log" do
wait_for_all_requests
- expect(page).to have_selector('.js-build-trace')
+ expect(page).to have_selector(".js-build-trace")
end
end
- context 'without log', :js do
+ context "without log", :js do
let(:job) { create(:ci_build, :canceled, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'renders empty state' do
+ it "renders empty state" do
expect(page).to have_content(job.detailed_status(user).illustration[:title])
- expect(page).not_to have_selector('.js-build-trace')
- expect(page).to have_content('This job has been canceled')
+ expect(page).not_to have_selector(".js-build-trace")
+ expect(page).to have_content("This job has been canceled")
end
end
end
- context 'Skipped job', :js do
+ context "Skipped job", :js do
let(:job) { create(:ci_build, :skipped, pipeline: pipeline) }
before do
visit project_job_path(project, job)
end
- it 'renders empty state' do
+ it "renders empty state" do
expect(page).to have_content(job.detailed_status(user).illustration[:title])
- expect(page).not_to have_selector('.js-build-trace')
- expect(page).to have_content('This job has been skipped')
+ expect(page).not_to have_selector(".js-build-trace")
+ expect(page).to have_content("This job has been skipped")
end
end
- context 'when job is failed but has no trace', :js do
+ context "when job is failed but has no trace", :js do
let(:job) { create(:ci_build, :failed, pipeline: pipeline) }
- it 'renders empty state' do
+ it "renders empty state" do
visit project_job_path(project, job)
expect(job).not_to have_trace
- expect(page).to have_content('This job does not have a trace.')
+ expect(page).to have_content("This job does not have a trace.")
end
end
- context 'with erased job', :js do
+ context "with erased job", :js do
let(:job) { create(:ci_build, :erased, pipeline: pipeline) }
- it 'renders erased job warning' do
+ it "renders erased job warning" do
visit project_job_path(project, job)
wait_for_requests
- page.within('.js-job-erased-block') do
- expect(page).to have_content('Job has been erased')
+ page.within(".js-job-erased-block") do
+ expect(page).to have_content("Job has been erased")
end
end
end
- context 'without erased job', :js do
+ context "without erased job", :js do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'does not render erased job warning' do
+ it "does not render erased job warning" do
visit project_job_path(project, job)
wait_for_requests
- expect(page).not_to have_css('.js-job-erased-block')
+ expect(page).not_to have_css(".js-job-erased-block")
end
end
- context 'on mobile', :js do
+ context "on mobile", :js do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'renders collapsed sidebar' do
+ it "renders collapsed sidebar" do
page.current_window.resize_to(600, 800)
visit project_job_path(project, job)
wait_for_requests
- expect(page).to have_css('.js-job-sidebar.right-sidebar-collapsed', visible: false)
- expect(page).not_to have_css('.js-job-sidebar.right-sidebar-expanded', visible: false)
+ expect(page).to have_css(".js-job-sidebar.right-sidebar-collapsed", visible: false)
+ expect(page).not_to have_css(".js-job-sidebar.right-sidebar-expanded", visible: false)
end
end
- context 'on desktop', :js do
+ context "on desktop", :js do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'renders expanded sidebar' do
+ it "renders expanded sidebar" do
visit project_job_path(project, job)
wait_for_requests
- expect(page).to have_css('.js-job-sidebar.right-sidebar-expanded')
- expect(page).not_to have_css('.js-job-sidebar.right-sidebar-collapsed')
+ expect(page).to have_css(".js-job-sidebar.right-sidebar-expanded")
+ expect(page).not_to have_css(".js-job-sidebar.right-sidebar-collapsed")
end
end
- context 'stuck', :js do
+ context "stuck", :js do
before do
visit project_job_path(project, job)
wait_for_requests
end
- context 'without active runners available' do
+ context "without active runners available" do
let(:runner) { create(:ci_runner, :instance, active: false) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
- it 'renders message about job being stuck because no runners are active' do
- expect(page).to have_css('.js-stuck-no-active-runner')
+ it "renders message about job being stuck because no runners are active" do
+ expect(page).to have_css(".js-stuck-no-active-runner")
expect(page).to have_content("This job is stuck because you don't have any active runners that can run this job.")
end
end
- context 'when available runners can not run specified tag' do
+ context "when available runners can not run specified tag" do
let(:runner) { create(:ci_runner, :instance, active: false) }
- let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner, tag_list: %w(docker linux)) }
+ let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner, tag_list: %w[docker linux]) }
- it 'renders message about job being stuck because of no runners with the specified tags' do
- expect(page).to have_css('.js-stuck-with-tags')
+ it "renders message about job being stuck because of no runners with the specified tags" do
+ expect(page).to have_css(".js-stuck-with-tags")
expect(page).to have_content("This job is stuck because you don't have any active runners online with any of these tags assigned to them:")
end
end
- context 'when runners are offline and build has tags' do
+ context "when runners are offline and build has tags" do
let(:runner) { create(:ci_runner, :instance, active: true) }
- let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner, tag_list: %w(docker linux)) }
+ let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner, tag_list: %w[docker linux]) }
- it 'renders message about job being stuck because of no runners with the specified tags' do
- expect(page).to have_css('.js-stuck-with-tags')
+ it "renders message about job being stuck because of no runners with the specified tags" do
+ expect(page).to have_css(".js-stuck-with-tags")
expect(page).to have_content("This job is stuck because you don't have any active runners online with any of these tags assigned to them:")
end
end
- context 'without any runners available' do
+ context "without any runners available" do
let(:job) { create(:ci_build, :pending, pipeline: pipeline) }
- it 'renders message about job being stuck because not runners are available' do
- expect(page).to have_css('.js-stuck-no-active-runner')
+ it "renders message about job being stuck because not runners are available" do
+ expect(page).to have_css(".js-stuck-no-active-runner")
expect(page).to have_content("This job is stuck because you don't have any active runners that can run this job.")
end
end
- context 'without available runners online' do
+ context "without available runners online" do
let(:runner) { create(:ci_runner, :instance, active: true) }
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner: runner) }
- it 'renders message about job being stuck because runners are offline' do
- expect(page).to have_css('.js-stuck-no-runners')
+ it "renders message about job being stuck because runners are offline" do
+ expect(page).to have_css(".js-stuck-no-runners")
expect(page).to have_content("This job is stuck because the project doesn't have any runners online assigned to it.")
end
end
@@ -824,11 +829,11 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
before do
job.run!
visit project_job_path(project, job)
- find('.js-cancel-job').click
+ find(".js-cancel-job").click
end
- it 'loads the page and shows all needed controls' do
- expect(page).to have_content 'Retry'
+ it "loads the page and shows all needed controls" do
+ expect(page).to have_content "Retry"
end
end
end
@@ -841,12 +846,12 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
wait_for_requests
- find('.js-retry-button').click
+ find(".js-retry-button").click
end
- it 'shows the right status and buttons' do
- page.within('aside.right-sidebar') do
- expect(page).to have_content 'Cancel'
+ it "shows the right status and buttons" do
+ page.within("aside.right-sidebar") do
+ expect(page).to have_content "Cancel"
end
end
end
@@ -862,9 +867,9 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
visit project_job_path(project, job)
end
- it 'does not show the Retry button' do
- page.within('aside.right-sidebar') do
- expect(page).not_to have_content 'Retry'
+ it "does not show the Retry button" do
+ page.within("aside.right-sidebar") do
+ expect(page).not_to have_content "Retry"
end
end
end
@@ -875,7 +880,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
job.update(legacy_artifacts_file: artifacts_file)
visit project_job_path(project, job)
- click_link 'Download'
+ click_link "Download"
end
context "Build from other project" do
@@ -884,58 +889,58 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
it do
- requests = inspect_requests do
+ requests = inspect_requests {
visit download_project_job_artifacts_path(project, job2)
- end
+ }
expect(requests.first.status_code).to eq(404)
end
end
end
- describe 'GET /:project/jobs/:id/raw', :js do
- context 'access source' do
- context 'job from project' do
- context 'when job is running' do
+ describe "GET /:project/jobs/:id/raw", :js do
+ context "access source" do
+ context "job from project" do
+ context "when job is running" do
before do
job.run!
end
- it 'sends the right headers' do
- requests = inspect_requests(inject_headers: { 'X-Sendfile-Type' => 'X-Sendfile' }) do
+ it "sends the right headers" do
+ requests = inspect_requests(inject_headers: {"X-Sendfile-Type" => "X-Sendfile"}) {
visit raw_project_job_path(project, job)
- end
+ }
expect(requests.first.status_code).to eq(200)
- expect(requests.first.response_headers['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(requests.first.response_headers['X-Sendfile']).to eq(job.trace.send(:current_path))
+ expect(requests.first.response_headers["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(requests.first.response_headers["X-Sendfile"]).to eq(job.trace.send(:current_path))
end
end
- context 'when job is complete' do
+ context "when job is complete" do
let(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) }
- it 'sends the right headers' do
- requests = inspect_requests(inject_headers: { 'X-Sendfile-Type' => 'X-Sendfile' }) do
+ it "sends the right headers" do
+ requests = inspect_requests(inject_headers: {"X-Sendfile-Type" => "X-Sendfile"}) {
visit raw_project_job_path(project, job)
- end
+ }
expect(requests.first.status_code).to eq(200)
- expect(requests.first.response_headers['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(requests.first.response_headers['X-Sendfile']).to eq(job.job_artifacts_trace.file.path)
+ expect(requests.first.response_headers["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(requests.first.response_headers["X-Sendfile"]).to eq(job.job_artifacts_trace.file.path)
end
end
end
- context 'job from other project' do
+ context "job from other project" do
before do
job2.run!
end
- it 'sends the right headers' do
- requests = inspect_requests(inject_headers: { 'X-Sendfile-Type' => 'X-Sendfile' }) do
+ it "sends the right headers" do
+ requests = inspect_requests(inject_headers: {"X-Sendfile-Type" => "X-Sendfile"}) {
visit raw_project_job_path(project, job2)
- end
+ }
expect(requests.first.status_code).to eq(404)
end
end
@@ -947,7 +952,7 @@ describe 'Jobs', :clean_gitlab_redis_shared_state do
end
before do
- visit raw_job_url.sub('/-/jobs', '/builds')
+ visit raw_job_url.sub("/-/jobs", "/builds")
end
it "redirects to new URL" do
diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
index 25417cf4955..0f21eae3368 100644
--- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
+++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Issue prioritization' do
+describe "Issue prioritization" do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
# Labels
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project, priority: 3) }
- let(:label_4) { create(:label, title: 'label_4', project: project, priority: 4) }
- let(:label_5) { create(:label, title: 'label_5', project: project) } # no priority
+ let(:label_1) { create(:label, title: "label_1", project: project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: project, priority: 2) }
+ let(:label_3) { create(:label, title: "label_3", project: project, priority: 3) }
+ let(:label_4) { create(:label, title: "label_4", project: project, priority: 4) }
+ let(:label_5) { create(:label, title: "label_5", project: project) } # no priority
# According to https://gitlab.com/gitlab-org/gitlab-ce/issues/14189#note_4360653
- context 'when issues have one label' do
- it 'Are sorted properly' do
+ context "when issues have one label" do
+ it "Are sorted properly" do
# Issues
- issue_1 = create(:issue, title: 'issue_1', project: project)
- issue_2 = create(:issue, title: 'issue_2', project: project)
- issue_3 = create(:issue, title: 'issue_3', project: project)
- issue_4 = create(:issue, title: 'issue_4', project: project)
- issue_5 = create(:issue, title: 'issue_5', project: project)
+ issue_1 = create(:issue, title: "issue_1", project: project)
+ issue_2 = create(:issue, title: "issue_2", project: project)
+ issue_3 = create(:issue, title: "issue_3", project: project)
+ issue_4 = create(:issue, title: "issue_4", project: project)
+ issue_5 = create(:issue, title: "issue_5", project: project)
# Assign labels to issues disorderly
issue_4.labels << label_1
@@ -29,30 +29,30 @@ describe 'Issue prioritization' do
issue_1.labels << label_5
sign_in user
- visit project_issues_path(project, sort: 'label_priority')
+ visit project_issues_path(project, sort: "label_priority")
# Ensure we are indicating that issues are sorted by priority
- expect(page).to have_selector('.dropdown', text: 'Label priority')
+ expect(page).to have_selector(".dropdown", text: "Label priority")
- page.within('.issues-holder') do
- issue_titles = all('.issues-list .issue-title-text').map(&:text)
+ page.within(".issues-holder") do
+ issue_titles = all(".issues-list .issue-title-text").map(&:text)
- expect(issue_titles).to eq(%w(issue_4 issue_3 issue_5 issue_2 issue_1))
+ expect(issue_titles).to eq(%w[issue_4 issue_3 issue_5 issue_2 issue_1])
end
end
end
- context 'when issues have multiple labels' do
- it 'Are sorted properly' do
+ context "when issues have multiple labels" do
+ it "Are sorted properly" do
# Issues
- issue_1 = create(:issue, title: 'issue_1', project: project)
- issue_2 = create(:issue, title: 'issue_2', project: project)
- issue_3 = create(:issue, title: 'issue_3', project: project)
- issue_4 = create(:issue, title: 'issue_4', project: project)
- issue_5 = create(:issue, title: 'issue_5', project: project)
- issue_6 = create(:issue, title: 'issue_6', project: project)
- issue_7 = create(:issue, title: 'issue_7', project: project)
- issue_8 = create(:issue, title: 'issue_8', project: project)
+ issue_1 = create(:issue, title: "issue_1", project: project)
+ issue_2 = create(:issue, title: "issue_2", project: project)
+ issue_3 = create(:issue, title: "issue_3", project: project)
+ issue_4 = create(:issue, title: "issue_4", project: project)
+ issue_5 = create(:issue, title: "issue_5", project: project)
+ issue_6 = create(:issue, title: "issue_6", project: project)
+ issue_7 = create(:issue, title: "issue_7", project: project)
+ issue_8 = create(:issue, title: "issue_8", project: project)
# Assign labels to issues disorderly
issue_5.labels << label_1 # 1
@@ -68,16 +68,16 @@ describe 'Issue prioritization' do
issue_6.labels << label_5 # 8 - No priority
sign_in user
- visit project_issues_path(project, sort: 'label_priority')
+ visit project_issues_path(project, sort: "label_priority")
- expect(page).to have_selector('.dropdown', text: 'Label priority')
+ expect(page).to have_selector(".dropdown", text: "Label priority")
- page.within('.issues-holder') do
- issue_titles = all('.issues-list .issue-title-text').map(&:text)
+ page.within(".issues-holder") do
+ issue_titles = all(".issues-list .issue-title-text").map(&:text)
- expect(issue_titles[0..1]).to contain_exactly('issue_5', 'issue_8')
- expect(issue_titles[2..4]).to contain_exactly('issue_1', 'issue_3', 'issue_7')
- expect(issue_titles[5..-1]).to eq(%w(issue_2 issue_4 issue_6))
+ expect(issue_titles[0..1]).to contain_exactly("issue_5", "issue_8")
+ expect(issue_titles[2..4]).to contain_exactly("issue_1", "issue_3", "issue_7")
+ expect(issue_titles[5..-1]).to eq(%w[issue_2 issue_4 issue_6])
end
end
end
diff --git a/spec/features/projects/labels/search_labels_spec.rb b/spec/features/projects/labels/search_labels_spec.rb
index 2d5a138c3cc..97cc99a90a4 100644
--- a/spec/features/projects/labels/search_labels_spec.rb
+++ b/spec/features/projects/labels/search_labels_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Search for labels', :js do
+describe "Search for labels", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let!(:label1) { create(:label, title: 'Foo', description: 'Lorem ipsum', project: project) }
- let!(:label2) { create(:label, title: 'Bar', description: 'Fusce consequat', project: project) }
+ let!(:label1) { create(:label, title: "Foo", description: "Lorem ipsum", project: project) }
+ let!(:label2) { create(:label, title: "Bar", description: "Fusce consequat", project: project) }
before do
project.add_maintainer(user)
@@ -15,9 +15,9 @@ describe 'Search for labels', :js do
visit project_labels_path(project)
end
- it 'searches for label by title' do
- fill_in 'label-search', with: 'Bar'
- find('#label-search').native.send_keys(:enter)
+ it "searches for label by title" do
+ fill_in "label-search", with: "Bar"
+ find("#label-search").native.send_keys(:enter)
expect(page).to have_content(label2.title)
expect(page).to have_content(label2.description)
@@ -25,9 +25,9 @@ describe 'Search for labels', :js do
expect(page).not_to have_content(label1.description)
end
- it 'searches for label by title' do
- fill_in 'label-search', with: 'Lorem'
- find('#label-search').native.send_keys(:enter)
+ it "searches for label by title" do
+ fill_in "label-search", with: "Lorem"
+ find("#label-search").native.send_keys(:enter)
expect(page).to have_content(label1.title)
expect(page).to have_content(label1.description)
@@ -35,43 +35,43 @@ describe 'Search for labels', :js do
expect(page).not_to have_content(label2.description)
end
- it 'shows nothing found message' do
- fill_in 'label-search', with: 'nonexistent'
- find('#label-search').native.send_keys(:enter)
+ it "shows nothing found message" do
+ fill_in "label-search", with: "nonexistent"
+ find("#label-search").native.send_keys(:enter)
- expect(page).to have_content('No labels with such name or description')
+ expect(page).to have_content("No labels with such name or description")
expect(page).not_to have_content(label1.title)
expect(page).not_to have_content(label1.description)
expect(page).not_to have_content(label2.title)
expect(page).not_to have_content(label2.description)
end
- context 'priority labels' do
+ context "priority labels" do
let!(:label_priority) { create(:label_priority, label: label1, project: project) }
- it 'searches for priority label' do
- fill_in 'label-search', with: 'Foo'
- find('#label-search').native.send_keys(:enter)
+ it "searches for priority label" do
+ fill_in "label-search", with: "Foo"
+ find("#label-search").native.send_keys(:enter)
- page.within('.prioritized-labels') do
+ page.within(".prioritized-labels") do
expect(page).to have_content(label1.title)
expect(page).to have_content(label1.description)
end
- page.within('.other-labels') do
- expect(page).to have_content('No other labels with such name or description')
+ page.within(".other-labels") do
+ expect(page).to have_content("No other labels with such name or description")
end
end
- it 'searches for other label' do
- fill_in 'label-search', with: 'Bar'
- find('#label-search').native.send_keys(:enter)
+ it "searches for other label" do
+ fill_in "label-search", with: "Bar"
+ find("#label-search").native.send_keys(:enter)
- page.within('.prioritized-labels') do
- expect(page).to have_content('No prioritised labels with such name or description')
+ page.within(".prioritized-labels") do
+ expect(page).to have_content("No prioritised labels with such name or description")
end
- page.within('.other-labels') do
+ page.within(".other-labels") do
expect(page).to have_content(label2.title)
expect(page).to have_content(label2.description)
end
diff --git a/spec/features/projects/labels/sort_labels_spec.rb b/spec/features/projects/labels/sort_labels_spec.rb
index 01c3f251173..ebf1ab01e80 100644
--- a/spec/features/projects/labels/sort_labels_spec.rb
+++ b/spec/features/projects/labels/sort_labels_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Sort labels', :js do
+describe "Sort labels", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let!(:label1) { create(:label, title: 'Foo', description: 'Lorem ipsum', project: project) }
- let!(:label2) { create(:label, title: 'Bar', description: 'Fusce consequat', project: project) }
+ let!(:label1) { create(:label, title: "Foo", description: "Lorem ipsum", project: project) }
+ let!(:label2) { create(:label, title: "Bar", description: "Fusce consequat", project: project) }
before do
project.add_maintainer(user)
@@ -15,34 +15,34 @@ describe 'Sort labels', :js do
visit project_labels_path(project)
end
- it 'sorts by title by default' do
- expect(page).to have_button('Name')
+ it "sorts by title by default" do
+ expect(page).to have_button("Name")
# assert default sorting
- within '.other-labels' do
- expect(page.all('.label-list-item').first.text).to include('Bar')
- expect(page.all('.label-list-item').last.text).to include('Foo')
+ within ".other-labels" do
+ expect(page.all(".label-list-item").first.text).to include("Bar")
+ expect(page.all(".label-list-item").last.text).to include("Foo")
end
end
- it 'sorts by date' do
- click_button 'Name'
+ it "sorts by date" do
+ click_button "Name"
- sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
+ sort_options = find("ul.dropdown-menu-sort li").all("a").collect(&:text)
- expect(sort_options[0]).to eq('Name')
- expect(sort_options[1]).to eq('Name, descending')
- expect(sort_options[2]).to eq('Last created')
- expect(sort_options[3]).to eq('Oldest created')
- expect(sort_options[4]).to eq('Last updated')
- expect(sort_options[5]).to eq('Oldest updated')
+ expect(sort_options[0]).to eq("Name")
+ expect(sort_options[1]).to eq("Name, descending")
+ expect(sort_options[2]).to eq("Last created")
+ expect(sort_options[3]).to eq("Oldest created")
+ expect(sort_options[4]).to eq("Last updated")
+ expect(sort_options[5]).to eq("Oldest updated")
- click_link 'Name, descending'
+ click_link "Name, descending"
# assert default sorting
- within '.other-labels' do
- expect(page.all('.label-list-item').first.text).to include('Foo')
- expect(page.all('.label-list-item').last.text).to include('Bar')
+ within ".other-labels" do
+ expect(page.all(".label-list-item").first.text).to include("Foo")
+ expect(page.all(".label-list-item").last.text).to include("Bar")
end
end
end
diff --git a/spec/features/projects/labels/subscription_spec.rb b/spec/features/projects/labels/subscription_spec.rb
index 49227eebf3d..3fc58da35e3 100644
--- a/spec/features/projects/labels/subscription_spec.rb
+++ b/spec/features/projects/labels/subscription_spec.rb
@@ -1,74 +1,74 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Labels subscription' do
+describe "Labels subscription" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let!(:bug) { create(:label, project: project, title: 'bug') }
- let!(:feature) { create(:group_label, group: group, title: 'feature') }
+ let!(:bug) { create(:label, project: project, title: "bug") }
+ let!(:feature) { create(:group_label, group: group, title: "feature") }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in user
end
- it 'users can subscribe/unsubscribe to labels', :js do
+ it "users can subscribe/unsubscribe to labels", :js do
visit project_labels_path(project)
- expect(page).to have_content('bug')
- expect(page).to have_content('feature')
+ expect(page).to have_content("bug")
+ expect(page).to have_content("feature")
within "#project_label_#{bug.id}" do
- expect(page).not_to have_button 'Unsubscribe'
+ expect(page).not_to have_button "Unsubscribe"
- click_button 'Subscribe'
+ click_button "Subscribe"
- expect(page).not_to have_button 'Subscribe'
- expect(page).to have_button 'Unsubscribe'
+ expect(page).not_to have_button "Subscribe"
+ expect(page).to have_button "Unsubscribe"
- click_button 'Unsubscribe'
+ click_button "Unsubscribe"
- expect(page).to have_button 'Subscribe'
- expect(page).not_to have_button 'Unsubscribe'
+ expect(page).to have_button "Subscribe"
+ expect(page).not_to have_button "Unsubscribe"
end
within "#group_label_#{feature.id}" do
- expect(page).not_to have_button 'Unsubscribe'
+ expect(page).not_to have_button "Unsubscribe"
- click_link_on_dropdown('Subscribe at group level')
+ click_link_on_dropdown("Subscribe at group level")
- expect(page).not_to have_selector('.dropdown-group-label')
- expect(page).to have_button 'Unsubscribe'
+ expect(page).not_to have_selector(".dropdown-group-label")
+ expect(page).to have_button "Unsubscribe"
- click_button 'Unsubscribe'
+ click_button "Unsubscribe"
- expect(page).to have_selector('.dropdown-group-label')
+ expect(page).to have_selector(".dropdown-group-label")
- click_link_on_dropdown('Subscribe at project level')
+ click_link_on_dropdown("Subscribe at project level")
- expect(page).not_to have_selector('.dropdown-group-label')
- expect(page).to have_button 'Unsubscribe'
+ expect(page).not_to have_selector(".dropdown-group-label")
+ expect(page).to have_button "Unsubscribe"
end
end
end
- context 'when not signed in' do
- it 'users can not subscribe/unsubscribe to labels' do
+ context "when not signed in" do
+ it "users can not subscribe/unsubscribe to labels" do
visit project_labels_path(project)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'feature'
- expect(page).not_to have_button('Subscribe')
- expect(page).not_to have_selector('.dropdown-group-label')
+ expect(page).to have_content "bug"
+ expect(page).to have_content "feature"
+ expect(page).not_to have_button("Subscribe")
+ expect(page).not_to have_selector(".dropdown-group-label")
end
end
def click_link_on_dropdown(text)
- find('.dropdown-group-label').click
+ find(".dropdown-group-label").click
- page.within('.dropdown-group-label') do
- find('.js-subscribe-button', text: text).click
+ page.within(".dropdown-group-label") do
+ find(".js-subscribe-button", text: text).click
end
end
end
diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb
index d36f043f880..db5f0a794a6 100644
--- a/spec/features/projects/labels/update_prioritization_spec.rb
+++ b/spec/features/projects/labels/update_prioritization_spec.rb
@@ -1,167 +1,167 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Prioritize labels' do
+describe "Prioritize labels" do
include DragTo
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let!(:bug) { create(:label, project: project, title: 'bug') }
- let!(:wontfix) { create(:label, project: project, title: 'wontfix') }
- let!(:feature) { create(:group_label, group: group, title: 'feature') }
+ let!(:bug) { create(:label, project: project, title: "bug") }
+ let!(:wontfix) { create(:label, project: project, title: "wontfix") }
+ let!(:feature) { create(:group_label, group: group, title: "feature") }
- context 'when user belongs to project team' do
+ context "when user belongs to project team" do
before do
project.add_developer(user)
sign_in user
end
- it 'user can prioritize a group label', :js do
+ it "user can prioritize a group label", :js do
visit project_labels_path(project)
- expect(page).to have_content('Star labels to start sorting by priority')
+ expect(page).to have_content("Star labels to start sorting by priority")
- page.within('.other-labels') do
- all('.js-toggle-priority')[1].click
+ page.within(".other-labels") do
+ all(".js-toggle-priority")[1].click
wait_for_requests
- expect(page).not_to have_content('feature')
+ expect(page).not_to have_content("feature")
end
- page.within('.prioritized-labels') do
- expect(page).not_to have_content('Star labels to start sorting by priority')
- expect(page).to have_content('feature')
+ page.within(".prioritized-labels") do
+ expect(page).not_to have_content("Star labels to start sorting by priority")
+ expect(page).to have_content("feature")
end
end
- it 'user can unprioritize a group label', :js do
+ it "user can unprioritize a group label", :js do
create(:label_priority, project: project, label: feature, priority: 1)
visit project_labels_path(project)
- page.within('.prioritized-labels') do
- expect(page).to have_content('feature')
+ page.within(".prioritized-labels") do
+ expect(page).to have_content("feature")
- first('.js-toggle-priority').click
+ first(".js-toggle-priority").click
wait_for_requests
- expect(page).not_to have_content('bug')
+ expect(page).not_to have_content("bug")
end
- page.within('.other-labels') do
- expect(page).to have_content('feature')
+ page.within(".other-labels") do
+ expect(page).to have_content("feature")
end
end
- it 'user can prioritize a project label', :js do
+ it "user can prioritize a project label", :js do
visit project_labels_path(project)
- expect(page).to have_content('Star labels to start sorting by priority')
+ expect(page).to have_content("Star labels to start sorting by priority")
- page.within('.other-labels') do
- first('.js-toggle-priority').click
+ page.within(".other-labels") do
+ first(".js-toggle-priority").click
wait_for_requests
- expect(page).not_to have_content('bug')
+ expect(page).not_to have_content("bug")
end
- page.within('.prioritized-labels') do
- expect(page).not_to have_content('Star labels to start sorting by priority')
- expect(page).to have_content('bug')
+ page.within(".prioritized-labels") do
+ expect(page).not_to have_content("Star labels to start sorting by priority")
+ expect(page).to have_content("bug")
end
end
- it 'user can unprioritize a project label', :js do
+ it "user can unprioritize a project label", :js do
create(:label_priority, project: project, label: bug, priority: 1)
visit project_labels_path(project)
- page.within('.prioritized-labels') do
- expect(page).to have_content('bug')
+ page.within(".prioritized-labels") do
+ expect(page).to have_content("bug")
- first('.js-toggle-priority').click
+ first(".js-toggle-priority").click
wait_for_requests
- expect(page).not_to have_content('bug')
+ expect(page).not_to have_content("bug")
end
- page.within('.other-labels') do
- expect(page).to have_content('bug')
- expect(page).to have_content('wontfix')
+ page.within(".other-labels") do
+ expect(page).to have_content("bug")
+ expect(page).to have_content("wontfix")
end
end
- it 'user can sort prioritized labels and persist across reloads', :js do
+ it "user can sort prioritized labels and persist across reloads", :js do
create(:label_priority, project: project, label: bug, priority: 1)
create(:label_priority, project: project, label: feature, priority: 2)
visit project_labels_path(project)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'feature'
- expect(page).to have_content 'wontfix'
+ expect(page).to have_content "bug"
+ expect(page).to have_content "feature"
+ expect(page).to have_content "wontfix"
# Sort labels
- drag_to(selector: '.label-list-item', from_index: 1, to_index: 2)
+ drag_to(selector: ".label-list-item", from_index: 1, to_index: 2)
- page.within('.prioritized-labels') do
- expect(first('.label-list-item')).to have_content('feature')
- expect(page.all('.label-list-item').last).to have_content('bug')
+ page.within(".prioritized-labels") do
+ expect(first(".label-list-item")).to have_content("feature")
+ expect(page.all(".label-list-item").last).to have_content("bug")
end
refresh
wait_for_requests
- page.within('.prioritized-labels') do
- expect(first('.label-list-item')).to have_content('feature')
- expect(page.all('.label-list-item').last).to have_content('bug')
+ page.within(".prioritized-labels") do
+ expect(first(".label-list-item")).to have_content("feature")
+ expect(page.all(".label-list-item").last).to have_content("bug")
end
end
- it 'user can see a primary button when there are only prioritized labels', :js do
+ it "user can see a primary button when there are only prioritized labels", :js do
visit project_labels_path(project)
- page.within('.other-labels') do
- all('.js-toggle-priority').each do |el|
+ page.within(".other-labels") do
+ all(".js-toggle-priority").each do |el|
el.click
end
wait_for_requests
end
- page.within('.top-area') do
- expect(page).to have_link('New label')
+ page.within(".top-area") do
+ expect(page).to have_link("New label")
end
end
- it 'shows a help message about prioritized labels' do
+ it "shows a help message about prioritized labels" do
visit project_labels_path(project)
- expect(page).to have_content 'Star a label'
+ expect(page).to have_content "Star a label"
end
end
- context 'as a guest' do
- it 'does not prioritize labels' do
+ context "as a guest" do
+ it "does not prioritize labels" do
guest = create(:user)
sign_in guest
visit project_labels_path(project)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content 'feature'
- expect(page).not_to have_css('.prioritized-labels')
- expect(page).not_to have_content 'Star a label'
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "feature"
+ expect(page).not_to have_css(".prioritized-labels")
+ expect(page).not_to have_content "Star a label"
end
end
- context 'as a non signed in user' do
- it 'does not prioritize labels' do
+ context "as a non signed in user" do
+ it "does not prioritize labels" do
visit project_labels_path(project)
- expect(page).to have_content 'bug'
- expect(page).to have_content 'wontfix'
- expect(page).to have_content 'feature'
- expect(page).not_to have_css('.prioritized-labels')
- expect(page).not_to have_content 'Star a label'
+ expect(page).to have_content "bug"
+ expect(page).to have_content "wontfix"
+ expect(page).to have_content "feature"
+ expect(page).not_to have_css(".prioritized-labels")
+ expect(page).not_to have_content "Star a label"
end
end
end
diff --git a/spec/features/projects/labels/user_removes_labels_spec.rb b/spec/features/projects/labels/user_removes_labels_spec.rb
index b0ce03a1c31..34e7fb762ff 100644
--- a/spec/features/projects/labels/user_removes_labels_spec.rb
+++ b/spec/features/projects/labels/user_removes_labels_spec.rb
@@ -19,7 +19,7 @@ describe "User removes labels" do
it "removes label" do
page.within(".other-labels") do
page.first(".label-list-item") do
- first('.js-label-options-dropdown').click
+ first(".js-label-options-dropdown").click
first(".remove-row").click
first(:link, "Delete label").click
end
@@ -41,7 +41,7 @@ describe "User removes labels" do
li = page.first(".label-list-item")
break unless li
- li.find('.js-label-options-dropdown').click
+ li.find(".js-label-options-dropdown").click
li.click_button("Delete")
click_link("Delete label")
end
diff --git a/spec/features/projects/labels/user_sees_breadcrumb_links_spec.rb b/spec/features/projects/labels/user_sees_breadcrumb_links_spec.rb
index 0c0501f438a..57c41e93b48 100644
--- a/spec/features/projects/labels/user_sees_breadcrumb_links_spec.rb
+++ b/spec/features/projects/labels/user_sees_breadcrumb_links_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New project label breadcrumb' do
+describe "New project label breadcrumb" do
let(:project) { create(:project) }
let(:user) { project.creator }
@@ -9,9 +9,9 @@ describe 'New project label breadcrumb' do
visit(project_labels_path(project))
end
- it 'displays link to project labels and new project label' do
- page.within '.breadcrumbs' do
- expect(find_link('Labels')[:href]).to end_with(project_labels_path(project))
+ it "displays link to project labels and new project label" do
+ page.within ".breadcrumbs" do
+ expect(find_link("Labels")[:href]).to end_with(project_labels_path(project))
end
end
end
diff --git a/spec/features/projects/labels/user_sees_links_to_issuables.rb b/spec/features/projects/labels/user_sees_links_to_issuables.rb
index c404fc8d66f..9cff41d1540 100644
--- a/spec/features/projects/labels/user_sees_links_to_issuables.rb
+++ b/spec/features/projects/labels/user_sees_links_to_issuables.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Labels > User sees links to issuables' do
+describe "Projects > Labels > User sees links to issuables" do
set(:user) { create(:user) }
before do
@@ -10,65 +10,65 @@ describe 'Projects > Labels > User sees links to issuables' do
visit project_labels_path(project)
end
- context 'with a project label' do
- let(:label) { create(:label, project: project, title: 'bug') }
+ context "with a project label" do
+ let(:label) { create(:label, project: project, title: "bug") }
- context 'when merge requests and issues are enabled for the project' do
+ context "when merge requests and issues are enabled for the project" do
let(:project) { create(:project, :public) }
- it 'shows links to MRs and issues' do
- expect(page).to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to MRs and issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
- context 'when issues are disabled for the project' do
+ context "when issues are disabled for the project" do
let(:project) { create(:project, :public, issues_access_level: ProjectFeature::DISABLED) }
- it 'shows links to MRs but not to issues' do
- expect(page).to have_link('view merge requests')
- expect(page).not_to have_link('view open issues')
+ it "shows links to MRs but not to issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).not_to have_link("view open issues")
end
end
- context 'when merge requests are disabled for the project' do
+ context "when merge requests are disabled for the project" do
let(:project) { create(:project, :public, merge_requests_access_level: ProjectFeature::DISABLED) }
- it 'shows links to issues but not to MRs' do
- expect(page).not_to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to issues but not to MRs" do
+ expect(page).not_to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
end
- context 'with a group label' do
+ context "with a group label" do
set(:group) { create(:group) }
- let(:label) { create(:group_label, group: group, title: 'bug') }
+ let(:label) { create(:group_label, group: group, title: "bug") }
- context 'when merge requests and issues are enabled for the project' do
+ context "when merge requests and issues are enabled for the project" do
let(:project) { create(:project, :public, namespace: group) }
- it 'shows links to MRs and issues' do
- expect(page).to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to MRs and issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
- context 'when issues are disabled for the project' do
+ context "when issues are disabled for the project" do
let(:project) { create(:project, :public, namespace: group, issues_access_level: ProjectFeature::DISABLED) }
- it 'shows links to MRs and issues' do
- expect(page).to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to MRs and issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
- context 'when merge requests are disabled for the project' do
+ context "when merge requests are disabled for the project" do
let(:project) { create(:project, :public, namespace: group, merge_requests_access_level: ProjectFeature::DISABLED) }
- it 'shows links to MRs and issues' do
- expect(page).to have_link('view merge requests')
- expect(page).to have_link('view open issues')
+ it "shows links to MRs and issues" do
+ expect(page).to have_link("view merge requests")
+ expect(page).to have_link("view open issues")
end
end
end
diff --git a/spec/features/projects/labels/user_views_labels_spec.rb b/spec/features/projects/labels/user_views_labels_spec.rb
index 2c8267764bd..9ef3974580f 100644
--- a/spec/features/projects/labels/user_views_labels_spec.rb
+++ b/spec/features/projects/labels/user_views_labels_spec.rb
@@ -18,7 +18,7 @@ describe "User views labels" do
end
it "shows all labels" do
- page.within('.other-labels .manage-labels-list') do
+ page.within(".other-labels .manage-labels-list") do
label_titles.each { |title| expect(page).to have_content(title) }
end
end
diff --git a/spec/features/projects/members/anonymous_user_sees_members_spec.rb b/spec/features/projects/members/anonymous_user_sees_members_spec.rb
index b3ed725f602..8fb29b17933 100644
--- a/spec/features/projects/members/anonymous_user_sees_members_spec.rb
+++ b/spec/features/projects/members/anonymous_user_sees_members_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Anonymous user sees members' do
+describe "Projects > Members > Anonymous user sees members" do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public) }
@@ -14,7 +14,8 @@ describe 'Projects > Members > Anonymous user sees members' do
visit project_project_members_path(project)
expect(current_path).to eq(
- project_project_members_path(project))
+ project_project_members_path(project)
+ )
expect(page).to have_content(user.name)
end
end
diff --git a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb
index 0ab29660189..4cfe868bb93 100644
--- a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb
+++ b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Group member cannot leave group project' do
+describe "Projects > Members > Group member cannot leave group project" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
@@ -12,6 +12,6 @@ describe 'Projects > Members > Group member cannot leave group project' do
end
it 'user does not see a "Leave project" link' do
- expect(page).not_to have_content 'Leave project'
+ expect(page).not_to have_content "Leave project"
end
end
diff --git a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb
index bb475ea95e5..a1e68fddb30 100644
--- a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb
+++ b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Group member cannot request access to his group project' do
+describe "Projects > Members > Group member cannot request access to his group project" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
- it 'owner does not see the request access button' do
+ it "owner does not see the request access button" do
group.add_owner(user)
login_and_visit_project_page(user)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'maintainer does not see the request access button' do
+ it "maintainer does not see the request access button" do
group.add_maintainer(user)
login_and_visit_project_page(user)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'developer does not see the request access button' do
+ it "developer does not see the request access button" do
group.add_developer(user)
login_and_visit_project_page(user)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'reporter does not see the request access button' do
+ it "reporter does not see the request access button" do
group.add_reporter(user)
login_and_visit_project_page(user)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'guest does not see the request access button' do
+ it "guest does not see the request access button" do
group.add_guest(user)
login_and_visit_project_page(user)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
def login_and_visit_project_page(user)
diff --git a/spec/features/projects/members/group_members_spec.rb b/spec/features/projects/members/group_members_spec.rb
index 0b2cd13b8ec..30829c4b4f0 100644
--- a/spec/features/projects/members/group_members_spec.rb
+++ b/spec/features/projects/members/group_members_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects members' do
+describe "Projects members" do
let(:user) { create(:user) }
let(:developer) { create(:user) }
let(:group) { create(:group, :public, :access_requestable) }
let(:project) { create(:project, :public, :access_requestable, creator: user, group: group) }
- let(:project_invitee) { create(:project_member, project: project, invite_token: '123', invite_email: 'test1@abc.com', user: nil) }
- let(:group_invitee) { create(:group_member, group: group, invite_token: '123', invite_email: 'test2@abc.com', user: nil) }
+ let(:project_invitee) { create(:project_member, project: project, invite_token: "123", invite_email: "test1@abc.com", user: nil) }
+ let(:group_invitee) { create(:group_member, group: group, invite_token: "123", invite_email: "test2@abc.com", user: nil) }
let(:project_requester) { create(:user) }
let(:group_requester) { create(:user) }
@@ -16,30 +16,30 @@ describe 'Projects members' do
sign_in(user)
end
- context 'with a group invitee' do
+ context "with a group invitee" do
before do
group_invitee
visit project_settings_members_path(project)
end
- it 'does not appear in the project members page' do
- page.within first('.content-list') do
- expect(page).not_to have_content('test2@abc.com')
+ it "does not appear in the project members page" do
+ page.within first(".content-list") do
+ expect(page).not_to have_content("test2@abc.com")
end
end
end
- context 'with a group and a project invitee' do
+ context "with a group and a project invitee" do
before do
group_invitee
project_invitee
visit project_settings_members_path(project)
end
- it 'shows the project invitee, the project developer, and the group owner' do
- page.within first('.content-list') do
- expect(page).to have_content('test1@abc.com')
- expect(page).not_to have_content('test2@abc.com')
+ it "shows the project invitee, the project developer, and the group owner" do
+ page.within first(".content-list") do
+ expect(page).to have_content("test1@abc.com")
+ expect(page).not_to have_content("test2@abc.com")
# Project developer
expect(page).to have_content(developer.name)
@@ -51,33 +51,33 @@ describe 'Projects members' do
end
end
- context 'with a group requester' do
+ context "with a group requester" do
before do
group.request_access(group_requester)
visit project_settings_members_path(project)
end
- it 'does not appear in the project members page' do
- page.within first('.content-list') do
+ it "does not appear in the project members page" do
+ page.within first(".content-list") do
expect(page).not_to have_content(group_requester.name)
end
end
end
- context 'with a group and a project requesters' do
+ context "with a group and a project requesters" do
before do
group.request_access(group_requester)
project.request_access(project_requester)
visit project_settings_members_path(project)
end
- it 'shows the project requester, the project developer, and the group owner' do
- page.within first('.content-list') do
+ it "shows the project requester, the project developer, and the group owner" do
+ page.within first(".content-list") do
expect(page).to have_content(project_requester.name)
expect(page).not_to have_content(group_requester.name)
end
- page.within all('.content-list').last do
+ page.within all(".content-list").last do
# Project developer
expect(page).to have_content(developer.name)
@@ -88,8 +88,8 @@ describe 'Projects members' do
end
end
- describe 'showing status of members' do
- it_behaves_like 'showing user status' do
+ describe "showing status of members" do
+ it_behaves_like "showing user status" do
let(:user_with_status) { developer }
subject { visit project_settings_members_path(project) }
diff --git a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb
index ea3894c92bd..b7a67199e2d 100644
--- a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb
+++ b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Group requester cannot request access to project', :js do
+describe "Projects > Members > Group requester cannot request access to project", :js do
let(:user) { create(:user) }
let(:owner) { create(:user) }
let(:group) { create(:group, :public, :access_requestable) }
@@ -10,12 +10,12 @@ describe 'Projects > Members > Group requester cannot request access to project'
group.add_owner(owner)
sign_in(user)
visit group_path(group)
- perform_enqueued_jobs { click_link 'Request Access' }
+ perform_enqueued_jobs { click_link "Request Access" }
visit project_path(project)
end
- it 'group requester does not see the request access / withdraw access request button' do
- expect(page).not_to have_content 'Request Access'
- expect(page).not_to have_content 'Withdraw Access Request'
+ it "group requester does not see the request access / withdraw access request button" do
+ expect(page).not_to have_content "Request Access"
+ expect(page).not_to have_content "Withdraw Access Request"
end
end
diff --git a/spec/features/projects/members/groups_with_access_list_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb
index c0b5d943e96..411b39d9984 100644
--- a/spec/features/projects/members/groups_with_access_list_spec.rb
+++ b/spec/features/projects/members/groups_with_access_list_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Groups with access list', :js do
+describe "Projects > Members > Groups with access list", :js do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public) }
@@ -13,58 +13,58 @@ describe 'Projects > Members > Groups with access list', :js do
visit project_settings_members_path(project)
end
- it 'updates group access level' do
+ it "updates group access level" do
click_button @group_link.human_access
- page.within '.dropdown-menu' do
- click_link 'Guest'
+ page.within ".dropdown-menu" do
+ click_link "Guest"
end
wait_for_requests
visit project_settings_members_path(project)
- expect(first('.group_member')).to have_content('Guest')
+ expect(first(".group_member")).to have_content("Guest")
end
- it 'updates expiry date' do
+ it "updates expiry date" do
tomorrow = Date.today + 3
fill_in "member_expires_at_#{group.id}", with: tomorrow.strftime("%F")
- find('body').click
+ find("body").click
wait_for_requests
- page.within(find('li.group_member')) do
- expect(page).to have_content('Expires in')
+ page.within(find("li.group_member")) do
+ expect(page).to have_content("Expires in")
end
end
- it 'deletes group link' do
- page.within(first('.group_member')) do
- accept_confirm { find('.btn-remove').click }
+ it "deletes group link" do
+ page.within(first(".group_member")) do
+ accept_confirm { find(".btn-remove").click }
end
wait_for_requests
- expect(page).not_to have_selector('.group_member')
+ expect(page).not_to have_selector(".group_member")
end
- context 'search in existing members (yes, this filters the groups list as well)' do
- it 'finds no results' do
- page.within '.member-search-form' do
- fill_in 'search', with: 'testing 123'
- find('.member-search-btn').click
+ context "search in existing members (yes, this filters the groups list as well)" do
+ it "finds no results" do
+ page.within ".member-search-form" do
+ fill_in "search", with: "testing 123"
+ find(".member-search-btn").click
end
- expect(page).not_to have_selector('.group_member')
+ expect(page).not_to have_selector(".group_member")
end
- it 'finds results' do
- page.within '.member-search-form' do
- fill_in 'search', with: group.name
- find('.member-search-btn').click
+ it "finds results" do
+ page.within ".member-search-form" do
+ fill_in "search", with: group.name
+ find(".member-search-btn").click
end
- expect(page).to have_selector('.group_member', count: 1)
+ expect(page).to have_selector(".group_member", count: 1)
end
end
end
diff --git a/spec/features/projects/members/invite_group_spec.rb b/spec/features/projects/members/invite_group_spec.rb
index fceead0b45e..e7b894f15ed 100644
--- a/spec/features/projects/members/invite_group_spec.rb
+++ b/spec/features/projects/members/invite_group_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project > Members > Invite group', :js do
+describe "Project > Members > Invite group", :js do
include Select2Helper
include ActionView::Helpers::DateHelper
let(:maintainer) { create(:user) }
- describe 'Share with group lock' do
- shared_examples 'the project can be shared with groups' do
+ describe "Share with group lock" do
+ shared_examples "the project can be shared with groups" do
it 'the "Invite group" tab exists' do
visit project_settings_members_path(project)
- expect(page).to have_selector('#invite-group-tab')
+ expect(page).to have_selector("#invite-group-tab")
end
end
- shared_examples 'the project cannot be shared with groups' do
+ shared_examples "the project cannot be shared with groups" do
it 'the "Invite group" tab does not exist' do
visit project_settings_members_path(project)
- expect(page).not_to have_selector('#invite-group-tab')
+ expect(page).not_to have_selector("#invite-group-tab")
end
end
- context 'for a project in a root group' do
+ context "for a project in a root group" do
let!(:group_to_share_with) { create(:group) }
let(:project) { create(:project, namespace: create(:group)) }
@@ -31,18 +31,18 @@ describe 'Project > Members > Invite group', :js do
end
context 'when the group has "Share with group lock" disabled' do
- it_behaves_like 'the project can be shared with groups'
+ it_behaves_like "the project can be shared with groups"
- it 'the project can be shared with another group' do
+ it "the project can be shared with another group" do
visit project_settings_members_path(project)
- click_on 'invite-group-tab'
+ click_on "invite-group-tab"
- select2 group_to_share_with.id, from: '#link_group_id'
- page.find('body').click
- find('.btn-success').click
+ select2 group_to_share_with.id, from: "#link_group_id"
+ page.find("body").click
+ find(".btn-success").click
- page.within('.project-members-groups') do
+ page.within(".project-members-groups") do
expect(page).to have_content(group_to_share_with.name)
end
end
@@ -53,11 +53,11 @@ describe 'Project > Members > Invite group', :js do
project.namespace.update_column(:share_with_group_lock, true)
end
- it_behaves_like 'the project cannot be shared with groups'
+ it_behaves_like "the project cannot be shared with groups"
end
end
- context 'for a project in a subgroup', :nested_groups do
+ context "for a project in a subgroup", :nested_groups do
let!(:group_to_share_with) { create(:group) }
let(:root_group) { create(:group) }
let(:subgroup) { create(:group, parent: root_group) }
@@ -70,7 +70,7 @@ describe 'Project > Members > Invite group', :js do
context 'when the root_group has "Share with group lock" disabled' do
context 'when the subgroup has "Share with group lock" disabled' do
- it_behaves_like 'the project can be shared with groups'
+ it_behaves_like "the project can be shared with groups"
end
context 'when the subgroup has "Share with group lock" enabled' do
@@ -78,7 +78,7 @@ describe 'Project > Members > Invite group', :js do
subgroup.update_column(:share_with_group_lock, true)
end
- it_behaves_like 'the project cannot be shared with groups'
+ it_behaves_like "the project cannot be shared with groups"
end
end
@@ -88,7 +88,7 @@ describe 'Project > Members > Invite group', :js do
end
context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do
- it_behaves_like 'the project can be shared with groups'
+ it_behaves_like "the project can be shared with groups"
end
context 'when the subgroup has "Share with group lock" enabled' do
@@ -96,13 +96,13 @@ describe 'Project > Members > Invite group', :js do
subgroup.update_column(:share_with_group_lock, true)
end
- it_behaves_like 'the project cannot be shared with groups'
+ it_behaves_like "the project cannot be shared with groups"
end
end
end
end
- describe 'setting an expiration date for a group link' do
+ describe "setting an expiration date for a group link" do
let(:project) { create(:project) }
let!(:group) { create(:group) }
@@ -116,28 +116,28 @@ describe 'Project > Members > Invite group', :js do
visit project_settings_members_path(project)
- click_on 'invite-group-tab'
+ click_on "invite-group-tab"
- select2 group.id, from: '#link_group_id'
+ select2 group.id, from: "#link_group_id"
- fill_in 'expires_at_groups', with: (Time.now + 4.5.days).strftime('%Y-%m-%d')
- click_on 'invite-group-tab'
- find('.btn-success').click
+ fill_in "expires_at_groups", with: (Time.now + 4.5.days).strftime("%Y-%m-%d")
+ click_on "invite-group-tab"
+ find(".btn-success").click
end
- it 'the group link shows the expiration time with a warning class' do
- page.within('.project-members-groups') do
+ it "the group link shows the expiration time with a warning class" do
+ page.within(".project-members-groups") do
# Using distance_of_time_in_words_to_now because it is not the same as
# subtraction, and this way avoids time zone issues as well
expires_in_text = distance_of_time_in_words_to_now(project.project_group_links.first.expires_at)
expect(page).to have_content(expires_in_text)
- expect(page).to have_selector('.text-warning')
+ expect(page).to have_selector(".text-warning")
end
end
end
- describe 'the groups dropdown' do
- context 'with multiple groups to choose from' do
+ describe "the groups dropdown" do
+ context "with multiple groups to choose from" do
let(:project) { create(:project) }
before do
@@ -149,24 +149,24 @@ describe 'Project > Members > Invite group', :js do
visit project_settings_members_path(project)
- click_link 'Invite group'
+ click_link "Invite group"
- find('.ajax-groups-select.select2-container')
+ find(".ajax-groups-select.select2-container")
- execute_script 'GROUP_SELECT_PER_PAGE = 1;'
- open_select2 '#link_group_id'
+ execute_script "GROUP_SELECT_PER_PAGE = 1;"
+ open_select2 "#link_group_id"
end
- it 'should infinitely scroll' do
- expect(find('.select2-drop .select2-results')).to have_selector('.select2-result', count: 1)
+ it "should infinitely scroll" do
+ expect(find(".select2-drop .select2-results")).to have_selector(".select2-result", count: 1)
- scroll_select2_to_bottom('.select2-drop .select2-results:visible')
+ scroll_select2_to_bottom(".select2-drop .select2-results:visible")
- expect(find('.select2-drop .select2-results')).to have_selector('.select2-result', count: 2)
+ expect(find(".select2-drop .select2-results")).to have_selector(".select2-result", count: 2)
end
end
- context 'for a project in a nested group' do
+ context "for a project in a nested group" do
let(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
let!(:group_to_share_with) { create(:group) }
@@ -179,13 +179,13 @@ describe 'Project > Members > Invite group', :js do
group_to_share_with.add_maintainer(maintainer)
end
- it 'the groups dropdown does not show ancestors', :nested_groups do
+ it "the groups dropdown does not show ancestors", :nested_groups do
visit project_settings_members_path(project)
- click_on 'invite-group-tab'
- click_link 'Search for a group'
+ click_on "invite-group-tab"
+ click_link "Search for a group"
- page.within '.select2-drop' do
+ page.within ".select2-drop" do
expect(page).to have_content(group_to_share_with.name)
expect(page).not_to have_content(group.name)
end
diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb
index cf309492808..676e283faa1 100644
--- a/spec/features/projects/members/list_spec.rb
+++ b/spec/features/projects/members/list_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project members list' do
+describe "Project members list" do
include Select2Helper
include Spec::Support::Helpers::Features::ListRowsHelpers
- let(:user1) { create(:user, name: 'John Doe') }
- let(:user2) { create(:user, name: 'Mary Jane') }
+ let(:user1) { create(:user, name: "John Doe") }
+ let(:user2) { create(:user, name: "Mary Jane") }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
@@ -14,7 +14,7 @@ describe 'Project members list' do
group.add_owner(user1)
end
- it 'show members from project and group' do
+ it "show members from project and group" do
project.add_developer(user2)
visit_members_page
@@ -23,7 +23,7 @@ describe 'Project members list' do
expect(second_row.text).to include(user2.name)
end
- it 'show user once if member of both group and project' do
+ it "show user once if member of both group and project" do
project.add_developer(user1)
visit_members_page
@@ -32,38 +32,38 @@ describe 'Project members list' do
expect(second_row).to be_blank
end
- it 'update user acess level', :js do
+ it "update user acess level", :js do
project.add_developer(user2)
visit_members_page
page.within(second_row) do
- click_button('Developer')
- click_link('Reporter')
+ click_button("Developer")
+ click_link("Reporter")
- expect(page).to have_button('Reporter')
+ expect(page).to have_button("Reporter")
end
end
- it 'add user to project', :js do
+ it "add user to project", :js do
visit_members_page
- add_user(user2.id, 'Reporter')
+ add_user(user2.id, "Reporter")
page.within(second_row) do
expect(page).to have_content(user2.name)
- expect(page).to have_button('Reporter')
+ expect(page).to have_button("Reporter")
end
end
- it 'remove user from project', :js do
+ it "remove user from project", :js do
other_user = create(:user)
project.add_developer(other_user)
visit_members_page
accept_confirm do
- find(:css, 'li.project_member', text: other_user.name).find(:css, 'a.btn-remove').click
+ find(:css, "li.project_member", text: other_user.name).find(:css, "a.btn-remove").click
end
wait_for_requests
@@ -72,15 +72,15 @@ describe 'Project members list' do
expect(project.users).not_to include(other_user)
end
- it 'invite user to project', :js do
+ it "invite user to project", :js do
visit_members_page
- add_user('test@example.com', 'Reporter')
+ add_user("test@example.com", "Reporter")
page.within(second_row) do
- expect(page).to have_content('test@example.com')
- expect(page).to have_content('Invited')
- expect(page).to have_button('Reporter')
+ expect(page).to have_content("test@example.com")
+ expect(page).to have_content("Invited")
+ expect(page).to have_button("Reporter")
end
end
diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb
index 26de6fb33fd..0a04fd40e69 100644
--- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb
+++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Maintainer adds member with expiration date', :js do
+describe "Projects > Members > Maintainer adds member with expiration date", :js do
include Select2Helper
include ActiveSupport::Testing::TimeHelpers
@@ -13,33 +13,33 @@ describe 'Projects > Members > Maintainer adds member with expiration date', :js
sign_in(maintainer)
end
- it 'expiration date is displayed in the members list' do
- travel_to Time.zone.parse('2016-08-06 08:00') do
+ it "expiration date is displayed in the members list" do
+ travel_to Time.zone.parse("2016-08-06 08:00") do
date = 4.days.from_now
visit project_project_members_path(project)
- page.within '.users-project-form' do
- select2(new_member.id, from: '#user_ids', multiple: true)
- fill_in 'expires_at', with: date.to_s(:medium) + "\n"
- click_on 'Add to project'
+ page.within ".users-project-form" do
+ select2(new_member.id, from: "#user_ids", multiple: true)
+ fill_in "expires_at", with: date.to_s(:medium) + "\n"
+ click_on "Add to project"
end
page.within "#project_member_#{new_member.project_members.first.id}" do
- expect(page).to have_content('Expires in 4 days')
+ expect(page).to have_content("Expires in 4 days")
end
end
end
- it 'change expiration date' do
- travel_to Time.zone.parse('2016-08-06 08:00') do
+ it "change expiration date" do
+ travel_to Time.zone.parse("2016-08-06 08:00") do
date = 3.days.from_now
project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_s(:medium))
visit project_project_members_path(project)
page.within "#project_member_#{new_member.project_members.first.id}" do
- find('.js-access-expiration-date').set date.to_s(:medium) + "\n"
+ find(".js-access-expiration-date").set date.to_s(:medium) + "\n"
wait_for_requests
- expect(page).to have_content('Expires in 3 days')
+ expect(page).to have_content("Expires in 3 days")
end
end
end
diff --git a/spec/features/projects/members/master_manages_access_requests_spec.rb b/spec/features/projects/members/master_manages_access_requests_spec.rb
index adc8202cde7..74942f4172b 100644
--- a/spec/features/projects/members/master_manages_access_requests_spec.rb
+++ b/spec/features/projects/members/master_manages_access_requests_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Maintainer manages access requests' do
- it_behaves_like 'Maintainer manages access requests' do
+describe "Projects > Members > Maintainer manages access requests" do
+ it_behaves_like "Maintainer manages access requests" do
let(:entity) { create(:project, :public, :access_requestable) }
let(:members_page_path) { project_project_members_path(entity) }
end
diff --git a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb
index f612ad8d551..1312f2bb1d8 100644
--- a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb
+++ b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Member cannot request access to his project' do
+describe "Projects > Members > Member cannot request access to his project" do
let(:member) { create(:user) }
let(:project) { create(:project) }
@@ -10,7 +10,7 @@ describe 'Projects > Members > Member cannot request access to his project' do
visit project_path(project)
end
- it 'member does not see the request access button' do
- expect(page).not_to have_content 'Request Access'
+ it "member does not see the request access button" do
+ expect(page).not_to have_content "Request Access"
end
end
diff --git a/spec/features/projects/members/member_leaves_project_spec.rb b/spec/features/projects/members/member_leaves_project_spec.rb
index 94b29de4686..a3785ea7abd 100644
--- a/spec/features/projects/members/member_leaves_project_spec.rb
+++ b/spec/features/projects/members/member_leaves_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Member leaves project' do
+describe "Projects > Members > Member leaves project" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -10,8 +10,8 @@ describe 'Projects > Members > Member leaves project' do
visit project_path(project)
end
- it 'user leaves project' do
- click_link 'Leave project'
+ it "user leaves project" do
+ click_link "Leave project"
expect(current_path).to eq(dashboard_projects_path)
expect(project.users.exists?(user.id)).to be_falsey
diff --git a/spec/features/projects/members/owner_cannot_leave_project_spec.rb b/spec/features/projects/members/owner_cannot_leave_project_spec.rb
index 0aa005adb4d..8bd08f75030 100644
--- a/spec/features/projects/members/owner_cannot_leave_project_spec.rb
+++ b/spec/features/projects/members/owner_cannot_leave_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Owner cannot leave project' do
+describe "Projects > Members > Owner cannot leave project" do
let(:project) { create(:project) }
before do
@@ -9,6 +9,6 @@ describe 'Projects > Members > Owner cannot leave project' do
end
it 'user does not see a "Leave project" link' do
- expect(page).not_to have_content 'Leave project'
+ expect(page).not_to have_content "Leave project"
end
end
diff --git a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb
index eb1b720af05..d9b400980e7 100644
--- a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb
+++ b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Owner cannot request access to his project' do
+describe "Projects > Members > Owner cannot request access to his project" do
let(:project) { create(:project) }
before do
@@ -8,7 +8,7 @@ describe 'Projects > Members > Owner cannot request access to his project' do
visit project_path(project)
end
- it 'owner does not see the request access button' do
- expect(page).not_to have_content 'Request Access'
+ it "owner does not see the request access button" do
+ expect(page).not_to have_content "Request Access"
end
end
diff --git a/spec/features/projects/members/sorting_spec.rb b/spec/features/projects/members/sorting_spec.rb
index 220775b514d..de3a2397b76 100644
--- a/spec/features/projects/members/sorting_spec.rb
+++ b/spec/features/projects/members/sorting_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > Sorting' do
- let(:maintainer) { create(:user, name: 'John Doe') }
- let(:developer) { create(:user, name: 'Mary Jane', last_sign_in_at: 5.days.ago) }
+describe "Projects > Members > Sorting" do
+ let(:maintainer) { create(:user, name: "John Doe") }
+ let(:developer) { create(:user, name: "Mary Jane", last_sign_in_at: 5.days.ago) }
let(:project) { create(:project, namespace: maintainer.namespace, creator: maintainer) }
before do
@@ -11,76 +11,76 @@ describe 'Projects > Members > Sorting' do
sign_in(maintainer)
end
- it 'sorts alphabetically by default' do
+ it "sorts alphabetically by default" do
visit_members_list(sort: nil)
expect(first_member).to include(maintainer.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, ascending")
end
- it 'sorts by access level ascending' do
+ it "sorts by access level ascending" do
visit_members_list(sort: :access_level_asc)
expect(first_member).to include(developer.name)
expect(second_member).to include(maintainer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Access level, ascending")
end
- it 'sorts by access level descending' do
+ it "sorts by access level descending" do
visit_members_list(sort: :access_level_desc)
expect(first_member).to include(maintainer.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Access level, descending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Access level, descending")
end
- it 'sorts by last joined' do
+ it "sorts by last joined" do
visit_members_list(sort: :last_joined)
expect(first_member).to include(maintainer.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Last joined')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Last joined")
end
- it 'sorts by oldest joined' do
+ it "sorts by oldest joined" do
visit_members_list(sort: :oldest_joined)
expect(first_member).to include(developer.name)
expect(second_member).to include(maintainer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest joined')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Oldest joined")
end
- it 'sorts by name ascending' do
+ it "sorts by name ascending" do
visit_members_list(sort: :name_asc)
expect(first_member).to include(maintainer.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, ascending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, ascending")
end
- it 'sorts by name descending' do
+ it "sorts by name descending" do
visit_members_list(sort: :name_desc)
expect(first_member).to include(developer.name)
expect(second_member).to include(maintainer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Name, descending')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Name, descending")
end
- it 'sorts by recent sign in', :clean_gitlab_redis_shared_state do
+ it "sorts by recent sign in", :clean_gitlab_redis_shared_state do
visit_members_list(sort: :recent_sign_in)
expect(first_member).to include(maintainer.name)
expect(second_member).to include(developer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Recent sign in')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Recent sign in")
end
- it 'sorts by oldest sign in', :clean_gitlab_redis_shared_state do
+ it "sorts by oldest sign in", :clean_gitlab_redis_shared_state do
visit_members_list(sort: :oldest_sign_in)
expect(first_member).to include(developer.name)
expect(second_member).to include(maintainer.name)
- expect(page).to have_css('.member-sort-dropdown .dropdown-toggle-text', text: 'Oldest sign in')
+ expect(page).to have_css(".member-sort-dropdown .dropdown-toggle-text", text: "Oldest sign in")
end
def visit_members_list(sort:)
@@ -88,10 +88,10 @@ describe 'Projects > Members > Sorting' do
end
def first_member
- page.all('ul.content-list > li').first.text
+ page.all("ul.content-list > li").first.text
end
def second_member
- page.all('ul.content-list > li').last.text
+ page.all("ul.content-list > li").last.text
end
end
diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb
index 50ba67f0ffc..0584389ee41 100644
--- a/spec/features/projects/members/user_requests_access_spec.rb
+++ b/spec/features/projects/members/user_requests_access_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Members > User requests access', :js do
+describe "Projects > Members > User requests access", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :access_requestable, :repository) }
let(:maintainer) { project.owner }
@@ -10,69 +10,69 @@ describe 'Projects > Members > User requests access', :js do
visit project_path(project)
end
- it 'request access feature is disabled' do
+ it "request access feature is disabled" do
project.update(request_access_enabled: false)
visit project_path(project)
- expect(page).not_to have_content 'Request Access'
+ expect(page).not_to have_content "Request Access"
end
- it 'user can request access to a project' do
- perform_enqueued_jobs { click_link 'Request Access' }
+ it "user can request access to a project" do
+ perform_enqueued_jobs { click_link "Request Access" }
expect(ActionMailer::Base.deliveries.last.to).to eq [maintainer.notification_email]
expect(ActionMailer::Base.deliveries.last.subject).to eq "Request to join the #{project.full_name} project"
expect(project.requesters.exists?(user_id: user)).to be_truthy
- expect(page).to have_content 'Your request for access has been queued for review.'
+ expect(page).to have_content "Your request for access has been queued for review."
- expect(page).to have_content 'Withdraw Access Request'
- expect(page).not_to have_content 'Leave Project'
+ expect(page).to have_content "Withdraw Access Request"
+ expect(page).not_to have_content "Leave Project"
end
- context 'code access is restricted' do
- it 'user can request access' do
+ context "code access is restricted" do
+ it "user can request access" do
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE,
builds_access_level: ProjectFeature::PRIVATE,
merge_requests_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
- expect(page).to have_content 'Request Access'
+ expect(page).to have_content "Request Access"
end
end
- it 'user is not listed in the project members page' do
- click_link 'Request Access'
+ it "user is not listed in the project members page" do
+ click_link "Request Access"
expect(project.requesters.exists?(user_id: user)).to be_truthy
- page.within('.nav-sidebar') do
- click_link('Members')
+ page.within(".nav-sidebar") do
+ click_link("Members")
end
- page.within('.content') do
+ page.within(".content") do
expect(page).not_to have_content(user.name)
end
end
- it 'user can withdraw its request for access' do
- click_link 'Request Access'
+ it "user can withdraw its request for access" do
+ click_link "Request Access"
expect(project.requesters.exists?(user_id: user)).to be_truthy
- accept_confirm { click_link 'Withdraw Access Request' }
+ accept_confirm { click_link "Withdraw Access Request" }
expect(project.requesters.exists?(user_id: user)).to be_falsey
- expect(page).to have_content 'Your access request to the project has been withdrawn.'
+ expect(page).to have_content "Your access request to the project has been withdrawn."
end
def open_project_settings_menu
- page.within('.layout-nav .nav-links') do
- click_link('Settings')
+ page.within(".layout-nav .nav-links") do
+ click_link("Settings")
end
- page.within('.sub-nav') do
- click_link('Members')
+ page.within(".sub-nav") do
+ click_link("Members")
end
end
end
diff --git a/spec/features/projects/merge_request_button_spec.rb b/spec/features/projects/merge_request_button_spec.rb
index 69561b4d733..c725673b62c 100644
--- a/spec/features/projects/merge_request_button_spec.rb
+++ b/spec/features/projects/merge_request_button_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Merge Request button' do
- shared_examples 'Merge request button only shown when allowed' do
+describe "Merge Request button" do
+ shared_examples "Merge request button only shown when allowed" do
let(:user) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:forked_project) { create(:project, :public, :repository, forked_from_project: project) }
- context 'not logged in' do
- it 'does not show Create merge request button' do
+ context "not logged in" do
+ it "does not show Create merge request button" do
visit url
expect(page).not_to have_link(label)
end
end
- context 'logged in as developer' do
+ context "logged in as developer" do
before do
sign_in(user)
project.add_developer(user)
end
- it 'shows Create merge request button' do
+ it "shows Create merge request button" do
href = project_new_merge_request_path(project,
- merge_request: { source_branch: 'feature',
- target_branch: 'master' })
+ merge_request: {source_branch: "feature",
+ target_branch: "master",})
visit url
- within('#content-body') do
+ within("#content-body") do
expect(page).to have_link(label, href: href)
end
end
- context 'merge requests are disabled' do
+ context "merge requests are disabled" do
before do
project.project_feature.update!(merge_requests_access_level: ProjectFeature::DISABLED)
end
- it 'does not show Create merge request button' do
+ it "does not show Create merge request button" do
visit url
- within('#content-body') do
+ within("#content-body") do
expect(page).not_to have_link(label)
end
end
end
- context 'when the project is archived' do
- it 'hides the link' do
+ context "when the project is archived" do
+ it "hides the link" do
project.update!(archived: true)
visit url
@@ -59,26 +59,26 @@ describe 'Merge Request button' do
end
end
- context 'logged in as non-member' do
+ context "logged in as non-member" do
before do
sign_in(user)
end
- it 'does not show Create merge request button' do
+ it "does not show Create merge request button" do
visit url
- within('#content-body') do
+ within("#content-body") do
expect(page).not_to have_link(label)
end
end
- context 'on own fork of project' do
+ context "on own fork of project" do
let(:user) { forked_project.owner }
- it 'shows Create merge request button' do
+ it "shows Create merge request button" do
href = project_new_merge_request_path(forked_project,
- merge_request: { source_branch: 'feature',
- target_branch: 'master' })
+ merge_request: {source_branch: "feature",
+ target_branch: "master",})
visit fork_url
@@ -90,27 +90,27 @@ describe 'Merge Request button' do
end
end
- context 'on branches page' do
- it_behaves_like 'Merge request button only shown when allowed' do
- let(:label) { 'Merge request' }
- let(:url) { project_branches_filtered_path(project, state: 'all', search: 'feature') }
- let(:fork_url) { project_branches_filtered_path(forked_project, state: 'all', search: 'feature') }
+ context "on branches page" do
+ it_behaves_like "Merge request button only shown when allowed" do
+ let(:label) { "Merge request" }
+ let(:url) { project_branches_filtered_path(project, state: "all", search: "feature") }
+ let(:fork_url) { project_branches_filtered_path(forked_project, state: "all", search: "feature") }
end
end
- context 'on compare page' do
- it_behaves_like 'Merge request button only shown when allowed' do
- let(:label) { 'Create merge request' }
- let(:url) { project_compare_path(project, from: 'master', to: 'feature') }
- let(:fork_url) { project_compare_path(forked_project, from: 'master', to: 'feature') }
+ context "on compare page" do
+ it_behaves_like "Merge request button only shown when allowed" do
+ let(:label) { "Create merge request" }
+ let(:url) { project_compare_path(project, from: "master", to: "feature") }
+ let(:fork_url) { project_compare_path(forked_project, from: "master", to: "feature") }
end
end
- context 'on commits page' do
- it_behaves_like 'Merge request button only shown when allowed' do
- let(:label) { 'Create merge request' }
- let(:url) { project_commits_path(project, 'feature') }
- let(:fork_url) { project_commits_path(forked_project, 'feature') }
+ context "on commits page" do
+ it_behaves_like "Merge request button only shown when allowed" do
+ let(:label) { "Create merge request" }
+ let(:url) { project_commits_path(project, "feature") }
+ let(:fork_url) { project_commits_path(forked_project, "feature") }
end
end
end
diff --git a/spec/features/projects/milestones/milestone_spec.rb b/spec/features/projects/milestones/milestone_spec.rb
index ff31092b910..38e10b79986 100644
--- a/spec/features/projects/milestones/milestone_spec.rb
+++ b/spec/features/projects/milestones/milestone_spec.rb
@@ -1,87 +1,87 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project milestone' do
+describe "Project milestone" do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
let(:milestone) { create(:milestone, project: project) }
before do
sign_in(user)
end
- context 'when project has enabled issues' do
+ context "when project has enabled issues" do
before do
visit project_milestone_path(project, milestone)
end
- it 'shows issues tab' do
- within('#content-body') do
- expect(page).to have_link 'Issues', href: '#tab-issues'
- expect(page).to have_selector '.nav-links li a.active', count: 1
- expect(find('.nav-links li a.active')).to have_content 'Issues'
+ it "shows issues tab" do
+ within("#content-body") do
+ expect(page).to have_link "Issues", href: "#tab-issues"
+ expect(page).to have_selector ".nav-links li a.active", count: 1
+ expect(find(".nav-links li a.active")).to have_content "Issues"
end
end
- it 'shows issues stats' do
- expect(find('.milestone-sidebar')).to have_content 'Issues 0'
+ it "shows issues stats" do
+ expect(find(".milestone-sidebar")).to have_content "Issues 0"
end
- it 'shows link to browse and add issues' do
- within('.milestone-sidebar') do
- expect(page).to have_link 'New issue'
- expect(page).to have_link 'Open: 0'
- expect(page).to have_link 'Closed: 0'
+ it "shows link to browse and add issues" do
+ within(".milestone-sidebar") do
+ expect(page).to have_link "New issue"
+ expect(page).to have_link "Open: 0"
+ expect(page).to have_link "Closed: 0"
end
end
end
- context 'when project has disabled issues' do
+ context "when project has disabled issues" do
before do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
visit project_milestone_path(project, milestone)
end
- it 'hides issues tab' do
- within('#content-body') do
- expect(page).not_to have_link 'Issues', href: '#tab-issues'
- expect(page).to have_selector '.nav-links li a.active', count: 1
- expect(find('.nav-links li a.active')).to have_content 'Merge Requests'
+ it "hides issues tab" do
+ within("#content-body") do
+ expect(page).not_to have_link "Issues", href: "#tab-issues"
+ expect(page).to have_selector ".nav-links li a.active", count: 1
+ expect(find(".nav-links li a.active")).to have_content "Merge Requests"
end
end
- it 'hides issues stats' do
- expect(find('.milestone-sidebar')).not_to have_content 'Issues 0'
+ it "hides issues stats" do
+ expect(find(".milestone-sidebar")).not_to have_content "Issues 0"
end
- it 'hides new issue button' do
- within('.milestone-sidebar') do
- expect(page).not_to have_link 'New issue'
+ it "hides new issue button" do
+ within(".milestone-sidebar") do
+ expect(page).not_to have_link "New issue"
end
end
- it 'does not show an informative message' do
- expect(page).not_to have_content('Assign some issues to this milestone.')
+ it "does not show an informative message" do
+ expect(page).not_to have_content("Assign some issues to this milestone.")
end
end
- context 'when project has an issue' do
+ context "when project has an issue" do
before do
create(:issue, project: project, milestone: milestone)
visit project_milestone_path(project, milestone)
end
- describe 'the collapsed sidebar' do
+ describe "the collapsed sidebar" do
before do
- find('.milestone-sidebar .gutter-toggle').click
+ find(".milestone-sidebar .gutter-toggle").click
end
- it 'shows the total MR and issue counts' do
- find('.milestone-sidebar .block', match: :first)
+ it "shows the total MR and issue counts" do
+ find(".milestone-sidebar .block", match: :first)
- aggregate_failures 'MR and issue blocks' do
- expect(find('.milestone-sidebar .block.issues')).to have_content 1
- expect(find('.milestone-sidebar .block.merge-requests')).to have_content 0
+ aggregate_failures "MR and issue blocks" do
+ expect(find(".milestone-sidebar .block.issues")).to have_content 1
+ expect(find(".milestone-sidebar .block.merge-requests")).to have_content 0
end
end
end
diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb
index dc711377e6e..e430ac6a713 100644
--- a/spec/features/projects/milestones/milestones_sorting_spec.rb
+++ b/spec/features/projects/milestones/milestones_sorting_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Milestones sorting', :js do
+describe "Milestones sorting", :js do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
before do
# Milestones
create(:milestone,
due_date: 10.days.from_now,
- created_at: 2.hours.ago,
+ created_at: 2.hours.ago,
title: "aaa", project: project)
create(:milestone,
due_date: 11.days.from_now,
- created_at: 1.hour.ago,
+ created_at: 1.hour.ago,
title: "bbb", project: project)
sign_in(user)
end
- it 'visit project milestones and sort by due_date_asc' do
+ it "visit project milestones and sort by due_date_asc" do
visit project_milestones_path(project)
- expect(page).to have_button('Due soon')
+ expect(page).to have_button("Due soon")
# assert default sorting
- within '.milestones' do
- expect(page.all('ul.content-list > li').first.text).to include('aaa')
- expect(page.all('ul.content-list > li').last.text).to include('bbb')
+ within ".milestones" do
+ expect(page.all("ul.content-list > li").first.text).to include("aaa")
+ expect(page.all("ul.content-list > li").last.text).to include("bbb")
end
- click_button 'Due soon'
+ click_button "Due soon"
- sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text)
+ sort_options = find("ul.dropdown-menu-sort li").all("a").collect(&:text)
- expect(sort_options[0]).to eq('Due soon')
- expect(sort_options[1]).to eq('Due later')
- expect(sort_options[2]).to eq('Start soon')
- expect(sort_options[3]).to eq('Start later')
- expect(sort_options[4]).to eq('Name, ascending')
- expect(sort_options[5]).to eq('Name, descending')
+ expect(sort_options[0]).to eq("Due soon")
+ expect(sort_options[1]).to eq("Due later")
+ expect(sort_options[2]).to eq("Start soon")
+ expect(sort_options[3]).to eq("Start later")
+ expect(sort_options[4]).to eq("Name, ascending")
+ expect(sort_options[5]).to eq("Name, descending")
- click_link 'Due later'
+ click_link "Due later"
- expect(page).to have_button('Due later')
+ expect(page).to have_button("Due later")
- within '.milestones' do
- expect(page.all('ul.content-list > li').first.text).to include('bbb')
- expect(page.all('ul.content-list > li').last.text).to include('aaa')
+ within ".milestones" do
+ expect(page.all("ul.content-list > li").first.text).to include("bbb")
+ expect(page.all("ul.content-list > li").last.text).to include("aaa")
end
end
end
diff --git a/spec/features/projects/milestones/new_spec.rb b/spec/features/projects/milestones/new_spec.rb
index 0b5ab547dce..ec52c512376 100644
--- a/spec/features/projects/milestones/new_spec.rb
+++ b/spec/features/projects/milestones/new_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Creating a new project milestone', :js do
+describe "Creating a new project milestone", :js do
let(:user) { create(:user) }
- let(:project) { create(:project, name: 'test', namespace: user.namespace) }
+ let(:project) { create(:project, name: "test", namespace: user.namespace) }
before do
login_as(user)
visit new_project_milestone_path(project)
end
- it 'description has emoji autocomplete' do
- find('#milestone_description').native.send_keys('')
- fill_in 'milestone_description', with: ':'
+ it "description has emoji autocomplete" do
+ find("#milestone_description").native.send_keys("")
+ fill_in "milestone_description", with: ":"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
end
diff --git a/spec/features/projects/milestones/user_interacts_with_labels_spec.rb b/spec/features/projects/milestones/user_interacts_with_labels_spec.rb
index a6d58be7b13..8c479e02a01 100644
--- a/spec/features/projects/milestones/user_interacts_with_labels_spec.rb
+++ b/spec/features/projects/milestones/user_interacts_with_labels_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User interacts with labels' do
+describe "User interacts with labels" do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- let(:milestone) { create(:milestone, project: project, title: 'v2.2', description: '# Description header') }
- let(:issue1) { create(:issue, project: project, title: 'Bugfix1', milestone: milestone) }
- let(:issue2) { create(:issue, project: project, title: 'Bugfix2', milestone: milestone) }
- let(:label_bug) { create(:label, project: project, title: 'bug') }
- let(:label_feature) { create(:label, project: project, title: 'feature') }
- let(:label_enhancement) { create(:label, project: project, title: 'enhancement') }
+ let(:milestone) { create(:milestone, project: project, title: "v2.2", description: "# Description header") }
+ let(:issue1) { create(:issue, project: project, title: "Bugfix1", milestone: milestone) }
+ let(:issue2) { create(:issue, project: project, title: "Bugfix2", milestone: milestone) }
+ let(:label_bug) { create(:label, project: project, title: "bug") }
+ let(:label_feature) { create(:label, project: project, title: "feature") }
+ let(:label_enhancement) { create(:label, project: project, title: "enhancement") }
before do
project.add_maintainer(user)
@@ -20,18 +20,18 @@ describe 'User interacts with labels' do
visit(project_milestones_path(project))
end
- it 'shows the list of labels', :js do
- click_link('v2.2')
+ it "shows the list of labels", :js do
+ click_link("v2.2")
- page.within('.nav-sidebar') do
+ page.within(".nav-sidebar") do
page.find(:xpath, "//a[@href='#tab-labels']").click
end
- expect(page).to have_selector('ul.manage-labels-list')
+ expect(page).to have_selector("ul.manage-labels-list")
wait_for_requests
- page.within('#tab-labels') do
+ page.within("#tab-labels") do
expect(page).to have_content(label_bug.title)
expect(page).to have_content(label_enhancement.title)
expect(page).to have_content(label_feature.title)
diff --git a/spec/features/projects/network_graph_spec.rb b/spec/features/projects/network_graph_spec.rb
index 9f9a7787093..90293179295 100644
--- a/spec/features/projects/network_graph_spec.rb
+++ b/spec/features/projects/network_graph_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Network Graph', :js do
+describe "Project Network Graph", :js do
let(:user) { create :user }
let(:project) { create :project, :repository, namespace: user.namespace }
@@ -11,97 +11,97 @@ describe 'Project Network Graph', :js do
allow(Network::Graph).to receive(:max_count).and_return(10)
end
- context 'when branch is master' do
+ context "when branch is master" do
def switch_ref_to(ref_name)
- first('.js-project-refs-dropdown').click
+ first(".js-project-refs-dropdown").click
- page.within '.project-refs-form' do
+ page.within ".project-refs-form" do
click_link ref_name
end
end
def click_show_only_selected_branch_checkbox
- find('#filter_ref').click
+ find("#filter_ref").click
end
before do
- visit project_network_path(project, 'master')
+ visit project_network_path(project, "master")
end
- it 'renders project network' do
+ it "renders project network" do
expect(page).to have_selector ".network-graph"
- expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
- page.within '.network-graph' do
- expect(page).to have_content 'master'
+ expect(page).to have_selector ".dropdown-menu-toggle", text: "master"
+ page.within ".network-graph" do
+ expect(page).to have_content "master"
end
end
- it 'switches ref to branch' do
- switch_ref_to('feature')
+ it "switches ref to branch" do
+ switch_ref_to("feature")
- expect(page).to have_selector '.dropdown-menu-toggle', text: 'feature'
- page.within '.network-graph' do
- expect(page).to have_content 'feature'
+ expect(page).to have_selector ".dropdown-menu-toggle", text: "feature"
+ page.within ".network-graph" do
+ expect(page).to have_content "feature"
end
end
- it 'switches ref to tag' do
- switch_ref_to('v1.0.0')
+ it "switches ref to tag" do
+ switch_ref_to("v1.0.0")
- expect(page).to have_selector '.dropdown-menu-toggle', text: 'v1.0.0'
- page.within '.network-graph' do
- expect(page).to have_content 'v1.0.0'
+ expect(page).to have_selector ".dropdown-menu-toggle", text: "v1.0.0"
+ page.within ".network-graph" do
+ expect(page).to have_content "v1.0.0"
end
end
it 'renders by commit sha of "v1.0.0"' do
page.within ".network-form" do
- fill_in 'extended_sha1', with: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9'
- find('button').click
+ fill_in "extended_sha1", with: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
+ find("button").click
end
expect(page).to have_selector ".network-graph"
- expect(page).to have_selector '.dropdown-menu-toggle', text: "master"
- page.within '.network-graph' do
- expect(page).to have_content 'v1.0.0'
+ expect(page).to have_selector ".dropdown-menu-toggle", text: "master"
+ page.within ".network-graph" do
+ expect(page).to have_content "v1.0.0"
end
end
- it 'filters select tag' do
- switch_ref_to('v1.0.0')
+ it "filters select tag" do
+ switch_ref_to("v1.0.0")
- expect(page).to have_css 'title', text: 'Graph · v1.0.0', visible: false
- page.within '.network-graph' do
- expect(page).to have_content 'Change some files'
+ expect(page).to have_css "title", text: "Graph · v1.0.0", visible: false
+ page.within ".network-graph" do
+ expect(page).to have_content "Change some files"
end
click_show_only_selected_branch_checkbox
- page.within '.network-graph' do
- expect(page).not_to have_content 'Change some files'
+ page.within ".network-graph" do
+ expect(page).not_to have_content "Change some files"
end
click_show_only_selected_branch_checkbox
- page.within '.network-graph' do
- expect(page).to have_content 'Change some files'
+ page.within ".network-graph" do
+ expect(page).to have_content "Change some files"
end
end
- it 'renders error message when sha commit not exists' do
+ it "renders error message when sha commit not exists" do
page.within ".network-form" do
- fill_in 'extended_sha1', with: ';'
- find('button').click
+ fill_in "extended_sha1", with: ";"
+ find("button").click
end
- expect(page).to have_selector '.flash-alert', text: "Git revision ';' does not exist."
+ expect(page).to have_selector ".flash-alert", text: "Git revision ';' does not exist."
end
end
- it 'renders project network with test branch' do
+ it "renders project network with test branch" do
visit project_network_path(project, "'test'")
- page.within '.network-graph' do
+ page.within ".network-graph" do
expect(page).to have_content "'test'"
end
end
diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb
index 75c72a68069..74e768a825a 100644
--- a/spec/features/projects/new_project_spec.rb
+++ b/spec/features/projects/new_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'New project' do
+describe "New project" do
include Select2Helper
let(:user) { create(:admin) }
@@ -12,43 +12,43 @@ describe 'New project' do
it 'shows "New project" page', :js do
visit new_project_path
- expect(page).to have_content('Project name')
- expect(page).to have_content('Project URL')
- expect(page).to have_content('Project slug')
+ expect(page).to have_content("Project name")
+ expect(page).to have_content("Project URL")
+ expect(page).to have_content("Project slug")
- find('#import-project-tab').click
+ find("#import-project-tab").click
- expect(page).to have_link('GitHub')
- expect(page).to have_link('Bitbucket')
- expect(page).to have_link('GitLab.com')
- expect(page).to have_link('Google Code')
- expect(page).to have_button('Repo by URL')
- expect(page).to have_link('GitLab export')
+ expect(page).to have_link("GitHub")
+ expect(page).to have_link("Bitbucket")
+ expect(page).to have_link("GitLab.com")
+ expect(page).to have_link("Google Code")
+ expect(page).to have_button("Repo by URL")
+ expect(page).to have_link("GitLab export")
end
- describe 'manifest import option' do
+ describe "manifest import option" do
before do
visit new_project_path
- find('#import-project-tab').click
+ find("#import-project-tab").click
end
- context 'when using postgres', :postgresql do
- it { expect(page).to have_link('Manifest file') }
+ context "when using postgres", :postgresql do
+ it { expect(page).to have_link("Manifest file") }
end
- context 'when using mysql', :mysql do
- it { expect(page).not_to have_link('Manifest file') }
+ context "when using mysql", :mysql do
+ it { expect(page).not_to have_link("Manifest file") }
end
end
- context 'Visibility level selector', :js do
+ context "Visibility level selector", :js do
Gitlab::VisibilityLevel.options.each do |key, level|
it "sets selector to #{key}" do
stub_application_setting(default_project_visibility: level)
visit new_project_path
- page.within('#blank-project-pane') do
+ page.within("#blank-project-pane") do
expect(find_field("project_visibility_level_#{level}")).to be_checked
end
end
@@ -57,61 +57,61 @@ describe 'New project' do
visit new_project_path
choose(s_(key))
- click_button('Create project')
- page.within('#blank-project-pane') do
+ click_button("Create project")
+ page.within("#blank-project-pane") do
expect(find_field("project_visibility_level_#{level}")).to be_checked
end
end
end
end
- context 'Readme selector' do
+ context "Readme selector" do
it 'shows the initialize with Readme checkbox on "Blank project" tab' do
visit new_project_path
- expect(page).to have_css('input#project_initialize_with_readme')
- expect(page).to have_content('Initialize repository with a README')
+ expect(page).to have_css("input#project_initialize_with_readme")
+ expect(page).to have_content("Initialize repository with a README")
end
it 'does not show the initialize with Readme checkbox on "Create from template" tab' do
visit new_project_path
- find('#create-from-template-pane').click
- first('.choose-template').click
+ find("#create-from-template-pane").click
+ first(".choose-template").click
- page.within '.project-fields-form' do
- expect(page).not_to have_css('input#project_initialize_with_readme')
- expect(page).not_to have_content('Initialize repository with a README')
+ page.within ".project-fields-form" do
+ expect(page).not_to have_css("input#project_initialize_with_readme")
+ expect(page).not_to have_content("Initialize repository with a README")
end
end
it 'does not show the initialize with Readme checkbox on "Import project" tab' do
visit new_project_path
- find('#import-project-tab').click
- first('.js-import-git-toggle-button').click
+ find("#import-project-tab").click
+ first(".js-import-git-toggle-button").click
- page.within '.toggle-import-form' do
- expect(page).not_to have_css('input#project_initialize_with_readme')
- expect(page).not_to have_content('Initialize repository with a README')
+ page.within ".toggle-import-form" do
+ expect(page).not_to have_css("input#project_initialize_with_readme")
+ expect(page).not_to have_content("Initialize repository with a README")
end
end
end
- context 'Namespace selector' do
- context 'with user namespace' do
+ context "Namespace selector" do
+ context "with user namespace" do
before do
visit new_project_path
end
- it 'selects the user namespace' do
- page.within('#blank-project-pane') do
- namespace = find('#project_namespace_id')
+ it "selects the user namespace" do
+ page.within("#blank-project-pane") do
+ namespace = find("#project_namespace_id")
expect(namespace.text).to eq user.username
end
end
end
- context 'with group namespace' do
+ context "with group namespace" do
let(:group) { create(:group, :private) }
before do
@@ -119,16 +119,16 @@ describe 'New project' do
visit new_project_path(namespace_id: group.id)
end
- it 'selects the group namespace' do
- page.within('#blank-project-pane') do
- namespace = find('#project_namespace_id option[selected]')
+ it "selects the group namespace" do
+ page.within("#blank-project-pane") do
+ namespace = find("#project_namespace_id option[selected]")
expect(namespace.text).to eq group.name
end
end
end
- context 'with subgroup namespace' do
+ context "with subgroup namespace" do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
@@ -137,16 +137,16 @@ describe 'New project' do
visit new_project_path(namespace_id: subgroup.id)
end
- it 'selects the group namespace' do
- page.within('#blank-project-pane') do
- namespace = find('#project_namespace_id option[selected]')
+ it "selects the group namespace" do
+ page.within("#blank-project-pane") do
+ namespace = find("#project_namespace_id option[selected]")
expect(namespace.text).to eq subgroup.full_path
end
end
end
- context 'when changing namespaces dynamically', :js do
+ context "when changing namespaces dynamically", :js do
let(:public_group) { create(:group, :public) }
let(:internal_group) { create(:group, :internal) }
let(:private_group) { create(:group, :private) }
@@ -158,23 +158,23 @@ describe 'New project' do
visit new_project_path(namespace_id: public_group.id)
end
- it 'enables the correct visibility options' do
- select2(user.namespace_id, from: '#project_namespace_id')
+ it "enables the correct visibility options" do
+ select2(user.namespace_id, from: "#project_namespace_id")
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
- select2(public_group.id, from: '#project_namespace_id')
+ select2(public_group.id, from: "#project_namespace_id")
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).not_to be_disabled
- select2(internal_group.id, from: '#project_namespace_id')
+ select2(internal_group.id, from: "#project_namespace_id")
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
- select2(private_group.id, from: '#project_namespace_id')
+ select2(private_group.id, from: "#project_namespace_id")
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PRIVATE}")).not_to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::INTERNAL}")).to be_disabled
expect(find("#project_visibility_level_#{Gitlab::VisibilityLevel::PUBLIC}")).to be_disabled
@@ -182,72 +182,72 @@ describe 'New project' do
end
end
- context 'Import project options', :js do
+ context "Import project options", :js do
before do
visit new_project_path
- find('#import-project-tab').click
+ find("#import-project-tab").click
end
context 'from git repository url, "Repo by URL"' do
before do
- first('.js-import-git-toggle-button').click
+ first(".js-import-git-toggle-button").click
end
- it 'does not autocomplete sensitive git repo URL' do
- autocomplete = find('#project_import_url')['autocomplete']
+ it "does not autocomplete sensitive git repo URL" do
+ autocomplete = find("#project_import_url")["autocomplete"]
- expect(autocomplete).to eq('off')
+ expect(autocomplete).to eq("off")
end
- it 'shows import instructions' do
- git_import_instructions = first('.js-toggle-content')
+ it "shows import instructions" do
+ git_import_instructions = first(".js-toggle-content")
expect(git_import_instructions).to be_visible
- expect(git_import_instructions).to have_content 'Git repository URL'
+ expect(git_import_instructions).to have_content "Git repository URL"
end
it 'keeps "Import project" tab open after form validation error' do
- collision_project = create(:project, name: 'test-name-collision', namespace: user.namespace)
+ collision_project = create(:project, name: "test-name-collision", namespace: user.namespace)
- fill_in 'project_import_url', with: collision_project.http_url_to_repo
- fill_in 'project_name', with: collision_project.name
+ fill_in "project_import_url", with: collision_project.http_url_to_repo
+ fill_in "project_name", with: collision_project.name
- click_on 'Create project'
+ click_on "Create project"
- expect(page).to have_css('#import-project-pane.active')
- expect(page).not_to have_css('.toggle-import-form.hide')
+ expect(page).to have_css("#import-project-pane.active")
+ expect(page).not_to have_css(".toggle-import-form.hide")
end
end
- context 'from GitHub' do
+ context "from GitHub" do
before do
- first('.js-import-github').click
+ first(".js-import-github").click
end
- it 'shows import instructions' do
- expect(page).to have_content('Import repositories from GitHub')
+ it "shows import instructions" do
+ expect(page).to have_content("Import repositories from GitHub")
expect(current_path).to eq new_import_github_path
end
end
- context 'from Google Code' do
+ context "from Google Code" do
before do
- first('.import_google_code').click
+ first(".import_google_code").click
end
- it 'shows import instructions' do
- expect(page).to have_content('Import projects from Google Code')
+ it "shows import instructions" do
+ expect(page).to have_content("Import projects from Google Code")
expect(current_path).to eq new_import_google_code_path
end
end
- context 'from manifest file', :postgresql do
+ context "from manifest file", :postgresql do
before do
- first('.import_manifest').click
+ first(".import_manifest").click
end
- it 'shows import instructions' do
- expect(page).to have_content('Manifest file import')
+ it "shows import instructions" do
+ expect(page).to have_content("Manifest file import")
expect(current_path).to eq new_import_manifest_path
end
end
diff --git a/spec/features/projects/pages_spec.rb b/spec/features/projects/pages_spec.rb
index f564ae34f11..30670acec1b 100644
--- a/spec/features/projects/pages_spec.rb
+++ b/spec/features/projects/pages_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Pages' do
+describe "Pages" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :maintainer }
@@ -13,157 +13,157 @@ describe 'Pages' do
sign_in(user)
end
- context 'when user is the owner' do
+ context "when user is the owner" do
before do
project.namespace.update(owner: user)
end
- context 'when pages deployed' do
+ context "when pages deployed" do
before do
allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
end
- it 'renders Access pages' do
+ it "renders Access pages" do
visit project_pages_path(project)
- expect(page).to have_content('Access pages')
+ expect(page).to have_content("Access pages")
end
- context 'when support for external domains is disabled' do
- it 'renders message that support is disabled' do
+ context "when support for external domains is disabled" do
+ it "renders message that support is disabled" do
visit project_pages_path(project)
- expect(page).to have_content('Support for domains and certificates is disabled')
+ expect(page).to have_content("Support for domains and certificates is disabled")
end
end
- context 'when pages are exposed on external HTTP address', :http_pages_enabled do
+ context "when pages are exposed on external HTTP address", :http_pages_enabled do
let(:project) { create(:project, pages_https_only: false) }
- shared_examples 'adds new domain' do
- it 'adds new domain' do
+ shared_examples "adds new domain" do
+ it "adds new domain" do
visit new_project_pages_domain_path(project)
- fill_in 'Domain', with: 'my.test.domain.com'
- click_button 'Create New Domain'
+ fill_in "Domain", with: "my.test.domain.com"
+ click_button "Create New Domain"
- expect(page).to have_content('my.test.domain.com')
+ expect(page).to have_content("my.test.domain.com")
end
end
- it 'allows to add new domain' do
+ it "allows to add new domain" do
visit project_pages_path(project)
- expect(page).to have_content('New Domain')
+ expect(page).to have_content("New Domain")
end
- it_behaves_like 'adds new domain'
+ it_behaves_like "adds new domain"
- context 'when project in group namespace' do
- it_behaves_like 'adds new domain' do
+ context "when project in group namespace" do
+ it_behaves_like "adds new domain" do
let(:group) { create :group }
let(:project) { create(:project, namespace: group, pages_https_only: false) }
end
end
- context 'when pages domain is added' do
+ context "when pages domain is added" do
before do
- create(:pages_domain, project: project, domain: 'my.test.domain.com')
+ create(:pages_domain, project: project, domain: "my.test.domain.com")
visit new_project_pages_domain_path(project)
end
- it 'renders certificates is disabled' do
- expect(page).to have_content('Support for custom certificates is disabled')
+ it "renders certificates is disabled" do
+ expect(page).to have_content("Support for custom certificates is disabled")
end
- it 'does not adds new domain and renders error message' do
- fill_in 'Domain', with: 'my.test.domain.com'
- click_button 'Create New Domain'
+ it "does not adds new domain and renders error message" do
+ fill_in "Domain", with: "my.test.domain.com"
+ click_button "Create New Domain"
- expect(page).to have_content('Domain has already been taken')
+ expect(page).to have_content("Domain has already been taken")
end
end
end
- context 'when pages are exposed on external HTTPS address', :https_pages_enabled do
+ context "when pages are exposed on external HTTPS address", :https_pages_enabled do
let(:certificate_pem) do
<<~PEM
- -----BEGIN CERTIFICATE-----
- MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
- LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
- MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
- gYkCgYEApL4J9L0ZxFJ1hI1LPIflAlAGvm6ZEvoT4qKU5Xf2JgU7/2geNR1qlNFa
- SvCc08Knupp5yTgmvyK/Xi09U0N82vvp4Zvr/diSc4A/RA6Mta6egLySNT438kdT
- nY2tR5feoTLwQpX0t4IMlwGQGT5h6Of2fKmDxzuwuyffcIHqLdsCAwEAAaNvMG0w
- DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxl9WSxBprB0z0ibJs3rXEk0+95AwCwYD
- VR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDAeBglghkgBhvhCAQ0EERYPeGNh
- IGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBBQUAA4GBAGC4T8SlFHK0yPSa+idGLQFQ
- joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
- 5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
- YHi2yesCrOvVXt+lgPTd
- -----END CERTIFICATE-----
+ -----BEGIN CERTIFICATE-----
+ MIICGzCCAYSgAwIBAgIBATANBgkqhkiG9w0BAQUFADAbMRkwFwYDVQQDExB0ZXN0
+ LWNlcnRpZmljYXRlMB4XDTE2MDIxMjE0MzIwMFoXDTIwMDQxMjE0MzIwMFowGzEZ
+ MBcGA1UEAxMQdGVzdC1jZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQEFAAOBjQAw
+ gYkCgYEApL4J9L0ZxFJ1hI1LPIflAlAGvm6ZEvoT4qKU5Xf2JgU7/2geNR1qlNFa
+ SvCc08Knupp5yTgmvyK/Xi09U0N82vvp4Zvr/diSc4A/RA6Mta6egLySNT438kdT
+ nY2tR5feoTLwQpX0t4IMlwGQGT5h6Of2fKmDxzuwuyffcIHqLdsCAwEAAaNvMG0w
+ DAYDVR0TAQH/BAIwADAdBgNVHQ4EFgQUxl9WSxBprB0z0ibJs3rXEk0+95AwCwYD
+ VR0PBAQDAgXgMBEGCWCGSAGG+EIBAQQEAwIGQDAeBglghkgBhvhCAQ0EERYPeGNh
+ IGNlcnRpZmljYXRlMA0GCSqGSIb3DQEBBQUAA4GBAGC4T8SlFHK0yPSa+idGLQFQ
+ joZp2JHYvNlTPkRJ/J4TcXxBTJmArcQgTIuNoBtC+0A/SwdK4MfTCUY4vNWNdese
+ 5A4K65Nb7Oh1AdQieTBHNXXCdyFsva9/ScfQGEl7p55a52jOPs0StPd7g64uvjlg
+ YHi2yesCrOvVXt+lgPTd
+ -----END CERTIFICATE-----
PEM
end
let(:certificate_key) do
<<~KEY
- -----BEGIN PRIVATE KEY-----
- MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
- SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
- PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
- kBk+Yejn9nypg8c7sLsn33CB6i3bAgMBAAECgYA2D26w80T7WZvazYr86BNMePpd
- j2mIAqx32KZHzt/lhh40J/SRtX9+Kl0Y7nBoRR5Ja9u/HkAIxNxLiUjwg9r6cpg/
- uITEF5nMt7lAk391BuI+7VOZZGbJDsq2ulPd6lO+C8Kq/PI/e4kXcIjeH6KwQsuR
- 5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
- AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
- EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
- Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
- m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
- EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
- 63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
- nNp/xedE1YxutQ==
- -----END PRIVATE KEY-----
+ -----BEGIN PRIVATE KEY-----
+ MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAKS+CfS9GcRSdYSN
+ SzyH5QJQBr5umRL6E+KilOV39iYFO/9oHjUdapTRWkrwnNPCp7qaeck4Jr8iv14t
+ PVNDfNr76eGb6/3YknOAP0QOjLWunoC8kjU+N/JHU52NrUeX3qEy8EKV9LeCDJcB
+ kBk+Yejn9nypg8c7sLsn33CB6i3bAgMBAAECgYA2D26w80T7WZvazYr86BNMePpd
+ j2mIAqx32KZHzt/lhh40J/SRtX9+Kl0Y7nBoRR5Ja9u/HkAIxNxLiUjwg9r6cpg/
+ uITEF5nMt7lAk391BuI+7VOZZGbJDsq2ulPd6lO+C8Kq/PI/e4kXcIjeH6KwQsuR
+ 5vrXfBZ3sQfflaiN4QJBANBt8JY2LIGQF8o89qwUpRL5vbnKQ4IzZ5+TOl4RLR7O
+ AQpJ81tGuINghO7aunctb6rrcKJrxmEH1whzComybrMCQQDKV49nOBudRBAIgG4K
+ EnLzsRKISUHMZSJiYTYnablof8cKw1JaQduw7zgrUlLwnroSaAGX88+Jw1f5n2Lh
+ Vlg5AkBDdUGnrDLtYBCDEQYZHblrkc7ZAeCllDOWjxUV+uMqlCv8A4Ey6omvY57C
+ m6I8DkWVAQx8VPtozhvHjUw80rZHAkB55HWHAM3h13axKG0htCt7klhPsZHpx6MH
+ EPjGlXIT+aW2XiPmK3ZlCDcWIenE+lmtbOpI159Wpk8BGXs/s/xBAkEAlAY3ymgx
+ 63BDJEwvOb2IaP8lDDxNsXx9XJNVvQbv5n15vNsLHbjslHfAhAbxnLQ1fLhUPqSi
+ nNp/xedE1YxutQ==
+ -----END PRIVATE KEY-----
KEY
end
- it 'adds new domain with certificate' do
+ it "adds new domain with certificate" do
visit new_project_pages_domain_path(project)
- fill_in 'Domain', with: 'my.test.domain.com'
- fill_in 'Certificate (PEM)', with: certificate_pem
- fill_in 'Key (PEM)', with: certificate_key
- click_button 'Create New Domain'
+ fill_in "Domain", with: "my.test.domain.com"
+ fill_in "Certificate (PEM)", with: certificate_pem
+ fill_in "Key (PEM)", with: certificate_key
+ click_button "Create New Domain"
- expect(page).to have_content('my.test.domain.com')
+ expect(page).to have_content("my.test.domain.com")
end
- describe 'updating the certificate for an existing domain' do
+ describe "updating the certificate for an existing domain" do
let!(:domain) do
create(:pages_domain, project: project)
end
- it 'allows the certificate to be updated' do
+ it "allows the certificate to be updated" do
visit project_pages_path(project)
- within('#content-body') { click_link 'Details' }
- click_link 'Edit'
- click_button 'Save Changes'
+ within("#content-body") { click_link "Details" }
+ click_link "Edit"
+ click_button "Save Changes"
- expect(page).to have_content('Domain was updated')
+ expect(page).to have_content("Domain was updated")
end
- context 'when the certificate is invalid' do
- it 'tells the user what the problem is' do
+ context "when the certificate is invalid" do
+ it "tells the user what the problem is" do
visit project_pages_path(project)
- within('#content-body') { click_link 'Details' }
- click_link 'Edit'
- fill_in 'Certificate (PEM)', with: 'invalid data'
- click_button 'Save Changes'
+ within("#content-body") { click_link "Details" }
+ click_link "Edit"
+ fill_in "Certificate (PEM)", with: "invalid data"
+ click_button "Save Changes"
- expect(page).to have_content('Certificate must be a valid PEM certificate')
- expect(page).to have_content('Certificate misses intermediates')
+ expect(page).to have_content("Certificate must be a valid PEM certificate")
+ expect(page).to have_content("Certificate misses intermediates")
expect(page).to have_content("Key doesn't match the certificate")
end
end
@@ -171,23 +171,23 @@ describe 'Pages' do
end
end
- it 'does not see anything to destroy' do
+ it "does not see anything to destroy" do
visit project_pages_path(project)
- expect(page).to have_content('Configure pages')
- expect(page).not_to have_link('Remove pages')
+ expect(page).to have_content("Configure pages")
+ expect(page).not_to have_link("Remove pages")
end
- describe 'project settings page' do
+ describe "project settings page" do
it 'renders "Pages" tab' do
visit edit_project_path(project)
- page.within '.nav-sidebar' do
- expect(page).to have_link('Pages')
+ page.within ".nav-sidebar" do
+ expect(page).to have_link("Pages")
end
end
- context 'when pages are disabled' do
+ context "when pages are disabled" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
end
@@ -195,87 +195,87 @@ describe 'Pages' do
it 'does not render "Pages" tab' do
visit edit_project_path(project)
- page.within '.nav-sidebar' do
- expect(page).not_to have_link('Pages')
+ page.within ".nav-sidebar" do
+ expect(page).not_to have_link("Pages")
end
end
end
end
end
- describe 'HTTPS settings', :js, :https_pages_enabled do
+ describe "HTTPS settings", :js, :https_pages_enabled do
before do
project.namespace.update(owner: user)
allow_any_instance_of(Project).to receive(:pages_deployed?) { true }
end
- it 'tries to change the setting' do
+ it "tries to change the setting" do
visit project_pages_path(project)
expect(page).to have_content("Force HTTPS (requires valid certificates)")
uncheck :project_pages_https_only
- click_button 'Save'
+ click_button "Save"
- expect(page).to have_text('Your changes have been saved')
- expect(page).not_to have_checked_field('project_pages_https_only')
+ expect(page).to have_text("Your changes have been saved")
+ expect(page).not_to have_checked_field("project_pages_https_only")
end
- context 'setting could not be updated' do
- let(:service) { instance_double('Projects::UpdateService') }
+ context "setting could not be updated" do
+ let(:service) { instance_double("Projects::UpdateService") }
before do
allow(Projects::UpdateService).to receive(:new).and_return(service)
allow(service).to receive(:execute).and_return(status: :error)
end
- it 'tries to change the setting' do
+ it "tries to change the setting" do
visit project_pages_path(project)
uncheck :project_pages_https_only
- click_button 'Save'
+ click_button "Save"
- expect(page).to have_text('Something went wrong on our end')
+ expect(page).to have_text("Something went wrong on our end")
end
end
- context 'non-HTTPS domain exists' do
+ context "non-HTTPS domain exists" do
let(:project) { create(:project, pages_https_only: false) }
before do
create(:pages_domain, :without_key, :without_certificate, project: project)
end
- it 'the setting is disabled' do
+ it "the setting is disabled" do
visit project_pages_path(project)
expect(page).to have_field(:project_pages_https_only, disabled: true)
- expect(page).not_to have_button('Save')
+ expect(page).not_to have_button("Save")
end
end
- context 'HTTPS pages are disabled', :https_pages_disabled do
- it 'the setting is unavailable' do
+ context "HTTPS pages are disabled", :https_pages_disabled do
+ it "the setting is unavailable" do
visit project_pages_path(project)
expect(page).not_to have_field(:project_pages_https_only)
- expect(page).not_to have_content('Force HTTPS (requires valid certificates)')
- expect(page).not_to have_button('Save')
+ expect(page).not_to have_content("Force HTTPS (requires valid certificates)")
+ expect(page).not_to have_button("Save")
end
end
end
- describe 'Remove page' do
+ describe "Remove page" do
let(:project) { create :project, :repository }
- context 'when pages are deployed' do
+ context "when pages are deployed" do
let(:pipeline) do
- commit_sha = project.commit('HEAD').sha
+ commit_sha = project.commit("HEAD").sha
project.ci_pipelines.create(
- ref: 'HEAD',
+ ref: "HEAD",
sha: commit_sha,
source: :push,
protected: false
@@ -287,9 +287,9 @@ describe 'Pages' do
:ci_build,
project: project,
pipeline: pipeline,
- ref: 'HEAD',
- legacy_artifacts_file: fixture_file_upload(File.join('spec/fixtures/pages.zip')),
- legacy_artifacts_metadata: fixture_file_upload(File.join('spec/fixtures/pages.zip.meta'))
+ ref: "HEAD",
+ legacy_artifacts_file: fixture_file_upload(File.join("spec/fixtures/pages.zip")),
+ legacy_artifacts_metadata: fixture_file_upload(File.join("spec/fixtures/pages.zip.meta"))
)
end
@@ -299,12 +299,12 @@ describe 'Pages' do
expect(project).to be_pages_deployed
end
- it 'removes the pages' do
+ it "removes the pages" do
visit project_pages_path(project)
- expect(page).to have_link('Remove pages')
+ expect(page).to have_link("Remove pages")
- click_link 'Remove pages'
+ click_link "Remove pages"
expect(project.pages_deployed?).to be_falsey
end
diff --git a/spec/features/projects/pipeline_schedules_spec.rb b/spec/features/projects/pipeline_schedules_spec.rb
index ee6b67b2188..bd0115b1f44 100644
--- a/spec/features/projects/pipeline_schedules_spec.rb
+++ b/spec/features/projects/pipeline_schedules_spec.rb
@@ -1,274 +1,274 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Pipeline Schedules', :js do
+describe "Pipeline Schedules", :js do
include PipelineSchedulesHelper
let!(:project) { create(:project, :repository) }
- let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) }
+ let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) }
let!(:pipeline) { create(:ci_pipeline, pipeline_schedule: pipeline_schedule) }
let(:scope) { nil }
let!(:user) { create(:user) }
- context 'logged in as maintainer' do
+ context "logged in as maintainer" do
before do
project.add_maintainer(user)
gitlab_sign_in(user)
end
- describe 'GET /projects/pipeline_schedules' do
+ describe "GET /projects/pipeline_schedules" do
before do
visit_pipelines_schedules
end
- describe 'The view' do
- it 'displays the required information description' do
- page.within('.pipeline-schedule-table-row') do
- expect(page).to have_content('pipeline schedule')
- expect(find(".next-run-cell time")['data-original-title'])
- .to include(pipeline_schedule.real_next_run.strftime('%b %-d, %Y'))
- expect(page).to have_link('master')
+ describe "The view" do
+ it "displays the required information description" do
+ page.within(".pipeline-schedule-table-row") do
+ expect(page).to have_content("pipeline schedule")
+ expect(find(".next-run-cell time")["data-original-title"])
+ .to include(pipeline_schedule.real_next_run.strftime("%b %-d, %Y"))
+ expect(page).to have_link("master")
expect(page).to have_link("##{pipeline.id}")
end
end
- it 'creates a new scheduled pipeline' do
- click_link 'New schedule'
+ it "creates a new scheduled pipeline" do
+ click_link "New schedule"
- expect(page).to have_content('Schedule a new pipeline')
+ expect(page).to have_content("Schedule a new pipeline")
end
- it 'changes ownership of the pipeline' do
- click_link 'Take ownership'
- page.within('.pipeline-schedule-table-row') do
- expect(page).not_to have_content('No owner')
- expect(page).to have_link('John Doe')
+ it "changes ownership of the pipeline" do
+ click_link "Take ownership"
+ page.within(".pipeline-schedule-table-row") do
+ expect(page).not_to have_content("No owner")
+ expect(page).to have_link("John Doe")
end
end
- it 'edits the pipeline' do
- page.within('.pipeline-schedule-table-row') do
- click_link 'Edit'
+ it "edits the pipeline" do
+ page.within(".pipeline-schedule-table-row") do
+ click_link "Edit"
end
- expect(page).to have_content('Edit Pipeline Schedule')
+ expect(page).to have_content("Edit Pipeline Schedule")
end
- it 'deletes the pipeline' do
- accept_confirm { click_link 'Delete' }
+ it "deletes the pipeline" do
+ accept_confirm { click_link "Delete" }
expect(page).not_to have_css(".pipeline-schedule-table-row")
end
end
- context 'when ref is nil' do
+ context "when ref is nil" do
before do
pipeline_schedule.update_attribute(:ref, nil)
visit_pipelines_schedules
end
- it 'shows a list of the pipeline schedules with empty ref column' do
- expect(first('.branch-name-cell').text).to eq('')
+ it "shows a list of the pipeline schedules with empty ref column" do
+ expect(first(".branch-name-cell").text).to eq("")
end
end
- context 'when ref is empty' do
+ context "when ref is empty" do
before do
- pipeline_schedule.update_attribute(:ref, '')
+ pipeline_schedule.update_attribute(:ref, "")
visit_pipelines_schedules
end
- it 'shows a list of the pipeline schedules with empty ref column' do
- expect(first('.branch-name-cell').text).to eq('')
+ it "shows a list of the pipeline schedules with empty ref column" do
+ expect(first(".branch-name-cell").text).to eq("")
end
end
end
- describe 'POST /projects/pipeline_schedules/new' do
+ describe "POST /projects/pipeline_schedules/new" do
before do
visit_new_pipeline_schedule
end
- it 'sets defaults for timezone and target branch' do
- expect(page).to have_button('master')
- expect(page).to have_button('UTC')
+ it "sets defaults for timezone and target branch" do
+ expect(page).to have_button("master")
+ expect(page).to have_button("UTC")
end
- it 'it creates a new scheduled pipeline' do
+ it "it creates a new scheduled pipeline" do
fill_in_schedule_form
save_pipeline_schedule
- expect(page).to have_content('my fancy description')
+ expect(page).to have_content("my fancy description")
end
- it 'it prevents an invalid form from being submitted' do
+ it "it prevents an invalid form from being submitted" do
save_pipeline_schedule
- expect(page).to have_content('This field is required')
+ expect(page).to have_content("This field is required")
end
end
- describe 'PATCH /projects/pipelines_schedules/:id/edit' do
+ describe "PATCH /projects/pipelines_schedules/:id/edit" do
before do
edit_pipeline_schedule
end
- it 'it displays existing properties' do
- description = find_field('schedule_description').value
- expect(description).to eq('pipeline schedule')
- expect(page).to have_button('master')
- expect(page).to have_button('UTC')
+ it "it displays existing properties" do
+ description = find_field("schedule_description").value
+ expect(description).to eq("pipeline schedule")
+ expect(page).to have_button("master")
+ expect(page).to have_button("UTC")
end
- it 'edits the scheduled pipeline' do
- fill_in 'schedule_description', with: 'my brand new description'
+ it "edits the scheduled pipeline" do
+ fill_in "schedule_description", with: "my brand new description"
save_pipeline_schedule
- expect(page).to have_content('my brand new description')
+ expect(page).to have_content("my brand new description")
end
- context 'when ref is nil' do
+ context "when ref is nil" do
before do
pipeline_schedule.update_attribute(:ref, nil)
edit_pipeline_schedule
end
- it 'shows the pipeline schedule with default ref' do
- page.within('.js-target-branch-dropdown') do
- expect(first('.dropdown-toggle-text').text).to eq('master')
+ it "shows the pipeline schedule with default ref" do
+ page.within(".js-target-branch-dropdown") do
+ expect(first(".dropdown-toggle-text").text).to eq("master")
end
end
end
- context 'when ref is empty' do
+ context "when ref is empty" do
before do
- pipeline_schedule.update_attribute(:ref, '')
+ pipeline_schedule.update_attribute(:ref, "")
edit_pipeline_schedule
end
- it 'shows the pipeline schedule with default ref' do
- page.within('.js-target-branch-dropdown') do
- expect(first('.dropdown-toggle-text').text).to eq('master')
+ it "shows the pipeline schedule with default ref" do
+ page.within(".js-target-branch-dropdown") do
+ expect(first(".dropdown-toggle-text").text).to eq("master")
end
end
end
end
- context 'when user creates a new pipeline schedule with variables' do
+ context "when user creates a new pipeline schedule with variables" do
before do
visit_pipelines_schedules
- click_link 'New schedule'
+ click_link "New schedule"
fill_in_schedule_form
- all('[name="schedule[variables_attributes][][key]"]')[0].set('AAA')
- all('[name="schedule[variables_attributes][][secret_value]"]')[0].set('AAA123')
- all('[name="schedule[variables_attributes][][key]"]')[1].set('BBB')
- all('[name="schedule[variables_attributes][][secret_value]"]')[1].set('BBB123')
+ all('[name="schedule[variables_attributes][][key]"]')[0].set("AAA")
+ all('[name="schedule[variables_attributes][][secret_value]"]')[0].set("AAA123")
+ all('[name="schedule[variables_attributes][][key]"]')[1].set("BBB")
+ all('[name="schedule[variables_attributes][][secret_value]"]')[1].set("BBB123")
save_pipeline_schedule
end
- it 'user sees the new variable in edit window' do
+ it "user sees the new variable in edit window" do
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- page.within('.ci-variable-list') do
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('AAA')
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('AAA123')
- expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-key").value).to eq('BBB')
- expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-value", visible: false).value).to eq('BBB123')
+ page.within(".ci-variable-list") do
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq("AAA")
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq("AAA123")
+ expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-key").value).to eq("BBB")
+ expect(find(".ci-variable-row:nth-child(2) .js-ci-variable-input-value", visible: false).value).to eq("BBB123")
end
end
end
- context 'when user edits a variable of a pipeline schedule' do
+ context "when user edits a variable of a pipeline schedule" do
before do
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
- create(:ci_pipeline_schedule_variable, key: 'AAA', value: 'AAA123', pipeline_schedule: pipeline_schedule)
+ create(:ci_pipeline_schedule_variable, key: "AAA", value: "AAA123", pipeline_schedule: pipeline_schedule)
end
visit_pipelines_schedules
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- find('.js-ci-variable-list-section .js-secret-value-reveal-button').click
- first('.js-ci-variable-input-key').set('foo')
- first('.js-ci-variable-input-value').set('bar')
- click_button 'Save pipeline schedule'
+ find(".js-ci-variable-list-section .js-secret-value-reveal-button").click
+ first(".js-ci-variable-input-key").set("foo")
+ first(".js-ci-variable-input-value").set("bar")
+ click_button "Save pipeline schedule"
end
- it 'user sees the updated variable in edit window' do
+ it "user sees the updated variable in edit window" do
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- page.within('.ci-variable-list') do
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('foo')
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('bar')
+ page.within(".ci-variable-list") do
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq("foo")
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq("bar")
end
end
end
- context 'when user removes a variable of a pipeline schedule' do
+ context "when user removes a variable of a pipeline schedule" do
before do
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
- create(:ci_pipeline_schedule_variable, key: 'AAA', value: 'AAA123', pipeline_schedule: pipeline_schedule)
+ create(:ci_pipeline_schedule_variable, key: "AAA", value: "AAA123", pipeline_schedule: pipeline_schedule)
end
visit_pipelines_schedules
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- find('.ci-variable-list .ci-variable-row-remove-button').click
- click_button 'Save pipeline schedule'
+ find(".ci-variable-list .ci-variable-row-remove-button").click
+ click_button "Save pipeline schedule"
end
- it 'user does not see the removed variable in edit window' do
+ it "user does not see the removed variable in edit window" do
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- page.within('.ci-variable-list') do
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq('')
- expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq('')
+ page.within(".ci-variable-list") do
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-key").value).to eq("")
+ expect(find(".ci-variable-row:nth-child(1) .js-ci-variable-input-value", visible: false).value).to eq("")
end
end
end
- context 'when active is true and next_run_at is NULL' do
+ context "when active is true and next_run_at is NULL" do
before do
create(:ci_pipeline_schedule, project: project, owner: user).tap do |pipeline_schedule|
pipeline_schedule.update_attribute(:cron, nil) # Consequently next_run_at will be nil
end
end
- it 'user edit and recover the problematic pipeline schedule' do
+ it "user edit and recover the problematic pipeline schedule" do
visit_pipelines_schedules
find(".content-list .pipeline-schedule-table-row:nth-child(1) .btn-group a[title='Edit']").click
- fill_in 'schedule_cron', with: '* 1 2 3 4'
- click_button 'Save pipeline schedule'
+ fill_in "schedule_cron", with: "* 1 2 3 4"
+ click_button "Save pipeline schedule"
- page.within('.pipeline-schedule-table-row:nth-child(1)') do
+ page.within(".pipeline-schedule-table-row:nth-child(1)") do
expect(page).to have_css(".next-run-cell time")
end
end
end
end
- context 'logged in as non-member' do
+ context "logged in as non-member" do
before do
gitlab_sign_in(user)
end
- describe 'GET /projects/pipeline_schedules' do
+ describe "GET /projects/pipeline_schedules" do
before do
visit_pipelines_schedules
end
- describe 'The view' do
- it 'does not show create schedule button' do
- expect(page).not_to have_link('New schedule')
+ describe "The view" do
+ it "does not show create schedule button" do
+ expect(page).not_to have_link("New schedule")
end
end
end
end
- context 'not logged in' do
- describe 'GET /projects/pipeline_schedules' do
+ context "not logged in" do
+ describe "GET /projects/pipeline_schedules" do
before do
visit_pipelines_schedules
end
- describe 'The view' do
- it 'does not show create schedule button' do
- expect(page).not_to have_link('New schedule')
+ describe "The view" do
+ it "does not show create schedule button" do
+ expect(page).not_to have_link("New schedule")
end
end
end
@@ -287,22 +287,22 @@ describe 'Pipeline Schedules', :js do
end
def select_timezone
- find('.js-timezone-dropdown').click
- click_link 'American Samoa'
+ find(".js-timezone-dropdown").click
+ click_link "American Samoa"
end
def select_target_branch
- find('.js-target-branch-dropdown').click
- click_link 'master'
+ find(".js-target-branch-dropdown").click
+ click_link "master"
end
def save_pipeline_schedule
- click_button 'Save pipeline schedule'
+ click_button "Save pipeline schedule"
end
def fill_in_schedule_form
- fill_in 'schedule_description', with: 'my fancy description'
- fill_in 'schedule_cron', with: '* 1 2 3 4'
+ fill_in "schedule_description", with: "my fancy description"
+ fill_in "schedule_cron", with: "* 1 2 3 4"
select_timezone
select_target_branch
diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb
index 72ef460d315..b6dbadfb1c5 100644
--- a/spec/features/projects/pipelines/pipeline_spec.rb
+++ b/spec/features/projects/pipelines/pipeline_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Pipeline', :js do
+describe "Pipeline", :js do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
@@ -10,619 +10,621 @@ describe 'Pipeline', :js do
project.add_role(user, role)
end
- shared_context 'pipeline builds' do
+ shared_context "pipeline builds" do
let!(:build_passed) do
create(:ci_build, :success,
- pipeline: pipeline, stage: 'build', name: 'build')
+ pipeline: pipeline, stage: "build", name: "build")
end
let!(:build_failed) do
create(:ci_build, :failed,
- pipeline: pipeline, stage: 'test', name: 'test')
+ pipeline: pipeline, stage: "test", name: "test")
end
let!(:build_running) do
create(:ci_build, :running,
- pipeline: pipeline, stage: 'deploy', name: 'deploy')
+ pipeline: pipeline, stage: "deploy", name: "deploy")
end
let!(:build_manual) do
create(:ci_build, :manual,
- pipeline: pipeline, stage: 'deploy', name: 'manual-build')
+ pipeline: pipeline, stage: "deploy", name: "manual-build")
end
let!(:build_scheduled) do
create(:ci_build, :scheduled,
- pipeline: pipeline, stage: 'deploy', name: 'delayed-job')
+ pipeline: pipeline, stage: "deploy", name: "delayed-job")
end
let!(:build_external) do
- create(:generic_commit_status, status: 'success',
+ create(:generic_commit_status, status: "success",
pipeline: pipeline,
- name: 'jenkins',
- stage: 'external',
- target_url: 'http://gitlab.com/status')
+ name: "jenkins",
+ stage: "external",
+ target_url: "http://gitlab.com/status")
end
end
- describe 'GET /:project/pipelines/:id' do
- include_context 'pipeline builds'
+ describe "GET /:project/pipelines/:id" do
+ include_context "pipeline builds"
let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: "master", sha: project.commit.id, user: user) }
before do
visit project_pipeline_path(project, pipeline)
end
- it 'shows the pipeline graph' do
- expect(page).to have_selector('.pipeline-visualization')
- expect(page).to have_content('Build')
- expect(page).to have_content('Test')
- expect(page).to have_content('Deploy')
- expect(page).to have_content('Retry')
- expect(page).to have_content('Cancel running')
+ it "shows the pipeline graph" do
+ expect(page).to have_selector(".pipeline-visualization")
+ expect(page).to have_content("Build")
+ expect(page).to have_content("Test")
+ expect(page).to have_content("Deploy")
+ expect(page).to have_content("Retry")
+ expect(page).to have_content("Cancel running")
end
- it 'shows Pipeline tab pane as active' do
- expect(page).to have_css('#js-tab-pipeline.active')
+ it "shows Pipeline tab pane as active" do
+ expect(page).to have_css("#js-tab-pipeline.active")
end
- it 'shows link to the pipeline ref' do
+ it "shows link to the pipeline ref" do
expect(page).to have_link(pipeline.ref)
end
- it_behaves_like 'showing user status' do
+ it_behaves_like "showing user status" do
let(:user_with_status) { pipeline.user }
subject { visit project_pipeline_path(project, pipeline) }
end
- describe 'pipeline graph' do
- context 'when pipeline has running builds' do
- it 'shows a running icon and a cancel action for the running build' do
- page.within('#ci-badge-deploy') do
- expect(page).to have_selector('.js-ci-status-icon-running')
- expect(page).to have_selector('.js-icon-cancel')
- expect(page).to have_content('deploy')
+ describe "pipeline graph" do
+ context "when pipeline has running builds" do
+ it "shows a running icon and a cancel action for the running build" do
+ page.within("#ci-badge-deploy") do
+ expect(page).to have_selector(".js-ci-status-icon-running")
+ expect(page).to have_selector(".js-icon-cancel")
+ expect(page).to have_content("deploy")
end
end
- it 'cancels the running build and shows retry button' do
- find('#ci-badge-deploy .ci-action-icon-container').click
+ it "cancels the running build and shows retry button" do
+ find("#ci-badge-deploy .ci-action-icon-container").click
- page.within('#ci-badge-deploy') do
- expect(page).to have_css('.js-icon-retry')
+ page.within("#ci-badge-deploy") do
+ expect(page).to have_css(".js-icon-retry")
end
end
end
- context 'when pipeline has successful builds' do
- it 'shows the success icon and a retry action for the successful build' do
- page.within('#ci-badge-build') do
- expect(page).to have_selector('.js-ci-status-icon-success')
- expect(page).to have_content('build')
+ context "when pipeline has successful builds" do
+ it "shows the success icon and a retry action for the successful build" do
+ page.within("#ci-badge-build") do
+ expect(page).to have_selector(".js-ci-status-icon-success")
+ expect(page).to have_content("build")
end
- page.within('#ci-badge-build .ci-action-icon-container.js-icon-retry') do
- expect(page).to have_selector('svg')
+ page.within("#ci-badge-build .ci-action-icon-container.js-icon-retry") do
+ expect(page).to have_selector("svg")
end
end
- it 'should be possible to retry the success job' do
- find('#ci-badge-build .ci-action-icon-container').click
+ it "should be possible to retry the success job" do
+ find("#ci-badge-build .ci-action-icon-container").click
- expect(page).not_to have_content('Retry job')
+ expect(page).not_to have_content("Retry job")
end
end
- context 'when pipeline has a delayed job' do
- it 'shows the scheduled icon and an unschedule action for the delayed job' do
- page.within('#ci-badge-delayed-job') do
- expect(page).to have_selector('.js-ci-status-icon-scheduled')
- expect(page).to have_content('delayed-job')
+ context "when pipeline has a delayed job" do
+ it "shows the scheduled icon and an unschedule action for the delayed job" do
+ page.within("#ci-badge-delayed-job") do
+ expect(page).to have_selector(".js-ci-status-icon-scheduled")
+ expect(page).to have_content("delayed-job")
end
- page.within('#ci-badge-delayed-job .ci-action-icon-container.js-icon-time-out') do
- expect(page).to have_selector('svg')
+ page.within("#ci-badge-delayed-job .ci-action-icon-container.js-icon-time-out") do
+ expect(page).to have_selector("svg")
end
end
- it 'unschedules the delayed job and shows play button as a manual job' do
- find('#ci-badge-delayed-job .ci-action-icon-container').click
+ it "unschedules the delayed job and shows play button as a manual job" do
+ find("#ci-badge-delayed-job .ci-action-icon-container").click
- page.within('#ci-badge-delayed-job') do
- expect(page).to have_css('.js-icon-play')
+ page.within("#ci-badge-delayed-job") do
+ expect(page).to have_css(".js-icon-play")
end
end
end
- context 'when pipeline has failed builds' do
- it 'shows the failed icon and a retry action for the failed build' do
- page.within('#ci-badge-test') do
- expect(page).to have_selector('.js-ci-status-icon-failed')
- expect(page).to have_content('test')
+ context "when pipeline has failed builds" do
+ it "shows the failed icon and a retry action for the failed build" do
+ page.within("#ci-badge-test") do
+ expect(page).to have_selector(".js-ci-status-icon-failed")
+ expect(page).to have_content("test")
end
- page.within('#ci-badge-test .ci-action-icon-container.js-icon-retry') do
- expect(page).to have_selector('svg')
+ page.within("#ci-badge-test .ci-action-icon-container.js-icon-retry") do
+ expect(page).to have_selector("svg")
end
end
- it 'should be possible to retry the failed build' do
- find('#ci-badge-test .ci-action-icon-container').click
+ it "should be possible to retry the failed build" do
+ find("#ci-badge-test .ci-action-icon-container").click
- expect(page).not_to have_content('Retry job')
+ expect(page).not_to have_content("Retry job")
end
- it 'should include the failure reason' do
- page.within('#ci-badge-test') do
- build_link = page.find('.js-pipeline-graph-job-link')
- expect(build_link['data-original-title']).to eq('test - failed - (unknown failure)')
+ it "should include the failure reason" do
+ page.within("#ci-badge-test") do
+ build_link = page.find(".js-pipeline-graph-job-link")
+ expect(build_link["data-original-title"]).to eq("test - failed - (unknown failure)")
end
end
end
- context 'when pipeline has manual jobs' do
- it 'shows the skipped icon and a play action for the manual build' do
- page.within('#ci-badge-manual-build') do
- expect(page).to have_selector('.js-ci-status-icon-manual')
- expect(page).to have_content('manual')
+ context "when pipeline has manual jobs" do
+ it "shows the skipped icon and a play action for the manual build" do
+ page.within("#ci-badge-manual-build") do
+ expect(page).to have_selector(".js-ci-status-icon-manual")
+ expect(page).to have_content("manual")
end
- page.within('#ci-badge-manual-build .ci-action-icon-container.js-icon-play') do
- expect(page).to have_selector('svg')
+ page.within("#ci-badge-manual-build .ci-action-icon-container.js-icon-play") do
+ expect(page).to have_selector("svg")
end
end
- it 'should be possible to play the manual job' do
- find('#ci-badge-manual-build .ci-action-icon-container').click
+ it "should be possible to play the manual job" do
+ find("#ci-badge-manual-build .ci-action-icon-container").click
- expect(page).not_to have_content('Play job')
+ expect(page).not_to have_content("Play job")
end
end
- context 'when pipeline has external job' do
- it 'shows the success icon and the generic comit status build' do
- expect(page).to have_selector('.js-ci-status-icon-success')
- expect(page).to have_content('jenkins')
- expect(page).to have_link('jenkins', href: 'http://gitlab.com/status')
+ context "when pipeline has external job" do
+ it "shows the success icon and the generic comit status build" do
+ expect(page).to have_selector(".js-ci-status-icon-success")
+ expect(page).to have_content("jenkins")
+ expect(page).to have_link("jenkins", href: "http://gitlab.com/status")
end
end
end
- context 'page tabs' do
- it 'shows Pipeline, Jobs and Failed Jobs tabs with link' do
- expect(page).to have_link('Pipeline')
- expect(page).to have_link('Jobs')
- expect(page).to have_link('Failed Jobs')
+ context "page tabs" do
+ it "shows Pipeline, Jobs and Failed Jobs tabs with link" do
+ expect(page).to have_link("Pipeline")
+ expect(page).to have_link("Jobs")
+ expect(page).to have_link("Failed Jobs")
end
- it 'shows counter in Jobs tab' do
- expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s)
+ it "shows counter in Jobs tab" do
+ expect(page.find(".js-builds-counter").text).to eq(pipeline.total_size.to_s)
end
- it 'shows Pipeline tab as active' do
- expect(page).to have_css('.js-pipeline-tab-link .active')
+ it "shows Pipeline tab as active" do
+ expect(page).to have_css(".js-pipeline-tab-link .active")
end
- context 'without permission to access builds' do
+ context "without permission to access builds" do
let(:project) { create(:project, :public, :repository, public_builds: false) }
let(:role) { :guest }
- it 'does not show failed jobs tab pane' do
- expect(page).to have_link('Pipeline')
- expect(page).not_to have_content('Failed Jobs')
+ it "does not show failed jobs tab pane" do
+ expect(page).to have_link("Pipeline")
+ expect(page).not_to have_content("Failed Jobs")
end
end
end
- context 'retrying jobs' do
- it { expect(page).not_to have_content('retried') }
+ context "retrying jobs" do
+ it { expect(page).not_to have_content("retried") }
- context 'when retrying' do
+ context "when retrying" do
before do
- find('.js-retry-button').click
+ find(".js-retry-button").click
end
- it { expect(page).not_to have_content('Retry') }
+ it { expect(page).not_to have_content("Retry") }
end
end
- context 'canceling jobs' do
- it { expect(page).not_to have_selector('.ci-canceled') }
+ context "canceling jobs" do
+ it { expect(page).not_to have_selector(".ci-canceled") }
- context 'when canceling' do
+ context "when canceling" do
before do
- click_on 'Cancel running'
+ click_on "Cancel running"
end
- it { expect(page).not_to have_content('Cancel running') }
+ it { expect(page).not_to have_content("Cancel running") }
end
end
- context 'when pipeline ref does not exist in repository anymore' do
+ context "when pipeline ref does not exist in repository anymore" do
let(:pipeline) do
create(:ci_empty_pipeline, project: project,
- ref: 'non-existent',
+ ref: "non-existent",
sha: project.commit.id,
user: user)
end
- it 'does not render link to the pipeline ref' do
+ it "does not render link to the pipeline ref" do
expect(page).not_to have_link(pipeline.ref)
expect(page).to have_content(pipeline.ref)
end
end
end
- context 'when user does not have access to read jobs' do
+ context "when user does not have access to read jobs" do
before do
project.update(public_builds: false)
end
- describe 'GET /:project/pipelines/:id' do
- include_context 'pipeline builds'
+ describe "GET /:project/pipelines/:id" do
+ include_context "pipeline builds"
let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) }
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: "master", sha: project.commit.id, user: user) }
before do
visit project_pipeline_path(project, pipeline)
end
- it 'shows the pipeline graph' do
- expect(page).to have_selector('.pipeline-visualization')
- expect(page).to have_content('Build')
- expect(page).to have_content('Test')
- expect(page).to have_content('Deploy')
- expect(page).to have_content('Retry')
- expect(page).to have_content('Cancel running')
+ it "shows the pipeline graph" do
+ expect(page).to have_selector(".pipeline-visualization")
+ expect(page).to have_content("Build")
+ expect(page).to have_content("Test")
+ expect(page).to have_content("Deploy")
+ expect(page).to have_content("Retry")
+ expect(page).to have_content("Cancel running")
end
- it 'should not link to job' do
- expect(page).not_to have_selector('.js-pipeline-graph-job-link')
+ it "should not link to job" do
+ expect(page).not_to have_selector(".js-pipeline-graph-job-link")
end
end
end
- context 'when a bridge job exists' do
- include_context 'pipeline builds'
+ context "when a bridge job exists" do
+ include_context "pipeline builds"
let(:project) { create(:project, :repository) }
let(:downstream) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline, project: project,
- ref: 'master',
+ ref: "master",
sha: project.commit.id,
user: user)
end
let!(:bridge) do
create(:ci_bridge, pipeline: pipeline,
- name: 'cross-build',
+ name: "cross-build",
user: user,
downstream: downstream)
end
- describe 'GET /:project/pipelines/:id' do
+ describe "GET /:project/pipelines/:id" do
before do
visit project_pipeline_path(project, pipeline)
end
- it 'shows the pipeline with a bridge job' do
- expect(page).to have_selector('.pipeline-visualization')
- expect(page).to have_content('cross-build')
+ it "shows the pipeline with a bridge job" do
+ expect(page).to have_selector(".pipeline-visualization")
+ expect(page).to have_content("cross-build")
end
end
- describe 'GET /:project/pipelines/:id/builds' do
+ describe "GET /:project/pipelines/:id/builds" do
before do
visit builds_project_pipeline_path(project, pipeline)
end
- it 'shows a bridge job on a list' do
- expect(page).to have_content('cross-build')
+ it "shows a bridge job on a list" do
+ expect(page).to have_content("cross-build")
expect(page).to have_content(bridge.id)
end
end
end
- describe 'GET /:project/pipelines/:id/builds' do
- include_context 'pipeline builds'
+ describe "GET /:project/pipelines/:id/builds" do
+ include_context "pipeline builds"
let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: "master", sha: project.commit.id) }
before do
visit builds_project_pipeline_path(project, pipeline)
end
- it 'shows a list of jobs' do
- expect(page).to have_content('Test')
+ it "shows a list of jobs" do
+ expect(page).to have_content("Test")
expect(page).to have_content(build_passed.id)
- expect(page).to have_content('Deploy')
+ expect(page).to have_content("Deploy")
expect(page).to have_content(build_failed.id)
expect(page).to have_content(build_running.id)
expect(page).to have_content(build_external.id)
- expect(page).to have_content('Retry')
- expect(page).to have_content('Cancel running')
- expect(page).to have_link('Play')
+ expect(page).to have_content("Retry")
+ expect(page).to have_content("Cancel running")
+ expect(page).to have_link("Play")
end
- it 'shows jobs tab pane as active' do
- expect(page).to have_css('#js-tab-builds.active')
+ it "shows jobs tab pane as active" do
+ expect(page).to have_css("#js-tab-builds.active")
end
- context 'page tabs' do
- it 'shows Pipeline and Jobs tabs with link' do
- expect(page).to have_link('Pipeline')
- expect(page).to have_link('Jobs')
+ context "page tabs" do
+ it "shows Pipeline and Jobs tabs with link" do
+ expect(page).to have_link("Pipeline")
+ expect(page).to have_link("Jobs")
end
- it 'shows counter in Jobs tab' do
- expect(page.find('.js-builds-counter').text).to eq(pipeline.total_size.to_s)
+ it "shows counter in Jobs tab" do
+ expect(page.find(".js-builds-counter").text).to eq(pipeline.total_size.to_s)
end
- it 'shows Jobs tab as active' do
- expect(page).to have_css('li.js-builds-tab-link .active')
+ it "shows Jobs tab as active" do
+ expect(page).to have_css("li.js-builds-tab-link .active")
end
end
- context 'retrying jobs' do
- it { expect(page).not_to have_content('retried') }
+ context "retrying jobs" do
+ it { expect(page).not_to have_content("retried") }
- context 'when retrying' do
+ context "when retrying" do
before do
- find('.js-retry-button').click
+ find(".js-retry-button").click
end
- it { expect(page).not_to have_content('Retry') }
+ it { expect(page).not_to have_content("Retry") }
end
end
- context 'canceling jobs' do
- it { expect(page).not_to have_selector('.ci-canceled') }
+ context "canceling jobs" do
+ it { expect(page).not_to have_selector(".ci-canceled") }
- context 'when canceling' do
+ context "when canceling" do
before do
- click_on 'Cancel running'
+ click_on "Cancel running"
end
- it { expect(page).not_to have_content('Cancel running') }
+ it { expect(page).not_to have_content("Cancel running") }
end
end
- context 'playing manual job' do
+ context "playing manual job" do
before do
- within '.pipeline-holder' do
- click_link('Play')
+ within ".pipeline-holder" do
+ click_link("Play")
end
end
it { expect(build_manual.reload).to be_pending }
end
- context 'when user unschedules a delayed job' do
+ context "when user unschedules a delayed job" do
before do
- within '.pipeline-holder' do
- click_link('Unschedule')
+ within ".pipeline-holder" do
+ click_link("Unschedule")
end
end
- it 'unschedules the delayed job and shows play button as a manual job' do
- expect(page).to have_content('Trigger this manual action')
+ it "unschedules the delayed job and shows play button as a manual job" do
+ expect(page).to have_content("Trigger this manual action")
end
end
- context 'failed jobs' do
- it 'displays a tooltip with the failure reason' do
- page.within('.ci-table') do
- failed_job_link = page.find('.ci-failed')
- expect(failed_job_link[:title]).to eq('Failed - (unknown failure)')
+ context "failed jobs" do
+ it "displays a tooltip with the failure reason" do
+ page.within(".ci-table") do
+ failed_job_link = page.find(".ci-failed")
+ expect(failed_job_link[:title]).to eq("Failed - (unknown failure)")
end
end
end
end
- describe 'GET /:project/pipelines/:id/failures' do
- let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: '1234') }
+ describe "GET /:project/pipelines/:id/failures" do
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: "master", sha: "1234") }
let(:pipeline_failures_page) { failures_project_pipeline_path(project, pipeline) }
let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline) }
subject { visit pipeline_failures_page }
- context 'with failed build' do
+ context "with failed build" do
before do
- failed_build.trace.set('4 examples, 1 failure')
+ failed_build.trace.set("4 examples, 1 failure")
end
- it 'shows jobs tab pane as active' do
+ it "shows jobs tab pane as active" do
subject
- expect(page).to have_content('Failed Jobs')
- expect(page).to have_css('#js-tab-failures.active')
+ expect(page).to have_content("Failed Jobs")
+ expect(page).to have_css("#js-tab-failures.active")
end
- it 'lists failed builds' do
+ it "lists failed builds" do
subject
expect(page).to have_content(failed_build.name)
expect(page).to have_content(failed_build.stage)
end
- it 'shows build failure logs' do
+ it "shows build failure logs" do
subject
- expect(page).to have_content('4 examples, 1 failure')
+ expect(page).to have_content("4 examples, 1 failure")
end
- it 'shows the failure reason' do
+ it "shows the failure reason" do
subject
- expect(page).to have_content('There is an unknown failure, please try again')
+ expect(page).to have_content("There is an unknown failure, please try again")
end
- context 'when user does not have permission to retry build' do
- it 'shows retry button for failed build' do
+ context "when user does not have permission to retry build" do
+ it "shows retry button for failed build" do
subject
- page.within(find('.build-failures', match: :first)) do
- expect(page).not_to have_link('Retry')
+ page.within(find(".build-failures", match: :first)) do
+ expect(page).not_to have_link("Retry")
end
end
end
- context 'when user does have permission to retry build' do
+ context "when user does have permission to retry build" do
before do
create(:protected_branch, :developers_can_merge,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- it 'shows retry button for failed build' do
+ it "shows retry button for failed build" do
subject
- page.within(find('.build-failures', match: :first)) do
- expect(page).to have_link('Retry')
+ page.within(find(".build-failures", match: :first)) do
+ expect(page).to have_link("Retry")
end
end
end
end
- context 'when missing build logs' do
- it 'shows jobs tab pane as active' do
+ context "when missing build logs" do
+ it "shows jobs tab pane as active" do
subject
- expect(page).to have_content('Failed Jobs')
- expect(page).to have_css('#js-tab-failures.active')
+ expect(page).to have_content("Failed Jobs")
+ expect(page).to have_css("#js-tab-failures.active")
end
- it 'lists failed builds' do
+ it "lists failed builds" do
subject
expect(page).to have_content(failed_build.name)
expect(page).to have_content(failed_build.stage)
end
- it 'does not show trace' do
+ it "does not show trace" do
subject
- expect(page).to have_content('No job trace')
+ expect(page).to have_content("No job trace")
end
end
- context 'without permission to access builds' do
+ context "without permission to access builds" do
let(:role) { :guest }
before do
project.update(public_builds: false)
end
- context 'when accessing failed jobs page' do
- it 'renders a 404 page' do
+ context "when accessing failed jobs page" do
+ it "renders a 404 page" do
requests = inspect_requests { subject }
- expect(page).to have_title('Not Found')
+ expect(page).to have_title("Not Found")
expect(requests.first.status_code).to eq(404)
end
end
end
- context 'without failures' do
+ context "without failures" do
before do
failed_build.update!(status: :success)
end
- it 'displays the pipeline graph' do
+ it "displays the pipeline graph" do
subject
expect(current_path).to eq(pipeline_path(pipeline))
- expect(page).not_to have_content('Failed Jobs')
- expect(page).to have_selector('.pipeline-visualization')
+ expect(page).not_to have_content("Failed Jobs")
+ expect(page).to have_selector(".pipeline-visualization")
end
end
end
- context 'when user sees pipeline flags in a pipeline detail page' do
+ context "when user sees pipeline flags in a pipeline detail page" do
let(:project) { create(:project, :repository) }
- context 'when pipeline is latest' do
- include_context 'pipeline builds'
+ context "when pipeline is latest" do
+ include_context "pipeline builds"
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- ref: 'master',
- sha: project.commit.id,
- user: user)
+ project: project,
+ ref: "master",
+ sha: project.commit.id,
+ user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
- it 'contains badge that indicates it is the latest build' do
- page.within(all('.well-segment')[1]) do
- expect(page).to have_content 'latest'
+ it "contains badge that indicates it is the latest build" do
+ page.within(all(".well-segment")[1]) do
+ expect(page).to have_content "latest"
end
end
end
- context 'when pipeline has configuration errors' do
- include_context 'pipeline builds'
+ context "when pipeline has configuration errors" do
+ include_context "pipeline builds"
let(:pipeline) do
create(:ci_pipeline,
- :invalid,
- project: project,
- ref: 'master',
- sha: project.commit.id,
- user: user)
+ :invalid,
+ project: project,
+ ref: "master",
+ sha: project.commit.id,
+ user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
- it 'contains badge that indicates errors' do
- page.within(all('.well-segment')[1]) do
- expect(page).to have_content 'yaml invalid'
+ it "contains badge that indicates errors" do
+ page.within(all(".well-segment")[1]) do
+ expect(page).to have_content "yaml invalid"
end
end
- it 'contains badge with tooltip which contains error' do
+ it "contains badge with tooltip which contains error" do
expect(pipeline).to have_yaml_errors
- page.within(all('.well-segment')[1]) do
+ page.within(all(".well-segment")[1]) do
expect(page).to have_selector(
- %Q{span[title="#{pipeline.yaml_errors}"]})
+ %(span[title="#{pipeline.yaml_errors}"])
+ )
end
end
- it 'contains badge that indicates failure reason' do
- expect(page).to have_content 'error'
+ it "contains badge that indicates failure reason" do
+ expect(page).to have_content "error"
end
- it 'contains badge with tooltip which contains failure reason' do
+ it "contains badge with tooltip which contains failure reason" do
expect(pipeline.failure_reason?).to eq true
- page.within(all('.well-segment')[1]) do
+ page.within(all(".well-segment")[1]) do
expect(page).to have_selector(
- %Q{span[title="#{pipeline.present.failure_reason}"]})
+ %(span[title="#{pipeline.present.failure_reason}"])
+ )
end
end
end
- context 'when pipeline is stuck' do
- include_context 'pipeline builds'
+ context "when pipeline is stuck" do
+ include_context "pipeline builds"
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- ref: 'master',
- sha: project.commit.id,
- user: user)
+ project: project,
+ ref: "master",
+ sha: project.commit.id,
+ user: user)
end
before do
@@ -630,65 +632,65 @@ describe 'Pipeline', :js do
visit project_pipeline_path(project, pipeline)
end
- it 'contains badge that indicates being stuck' do
- page.within(all('.well-segment')[1]) do
- expect(page).to have_content 'stuck'
+ it "contains badge that indicates being stuck" do
+ page.within(all(".well-segment")[1]) do
+ expect(page).to have_content "stuck"
end
end
end
- context 'when pipeline uses auto devops' do
- include_context 'pipeline builds'
+ context "when pipeline uses auto devops" do
+ include_context "pipeline builds"
- let(:project) { create(:project, :repository, auto_devops_attributes: { enabled: true }) }
+ let(:project) { create(:project, :repository, auto_devops_attributes: {enabled: true}) }
let(:pipeline) do
create(:ci_pipeline,
- :auto_devops_source,
- project: project,
- ref: 'master',
- sha: project.commit.id,
- user: user)
+ :auto_devops_source,
+ project: project,
+ ref: "master",
+ sha: project.commit.id,
+ user: user)
end
before do
visit project_pipeline_path(project, pipeline)
end
- it 'contains badge that indicates using auto devops' do
- page.within(all('.well-segment')[1]) do
- expect(page).to have_content 'Auto DevOps'
+ it "contains badge that indicates using auto devops" do
+ page.within(all(".well-segment")[1]) do
+ expect(page).to have_content "Auto DevOps"
end
end
end
- context 'when pipeline runs in a merge request context' do
- include_context 'pipeline builds'
+ context "when pipeline runs in a merge request context" do
+ include_context "pipeline builds"
let(:pipeline) do
create(:ci_pipeline,
- source: :merge_request,
- project: merge_request.source_project,
- ref: 'feature',
- sha: merge_request.diff_head_sha,
- user: user,
- merge_request: merge_request)
+ source: :merge_request,
+ project: merge_request.source_project,
+ ref: "feature",
+ sha: merge_request.diff_head_sha,
+ user: user,
+ merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
before do
visit project_pipeline_path(project, pipeline)
end
- it 'contains badge that indicates merge request pipeline' do
- page.within(all('.well-segment')[1]) do
- expect(page).to have_content 'merge request'
+ it "contains badge that indicates merge request pipeline" do
+ page.within(all(".well-segment")[1]) do
+ expect(page).to have_content "merge request"
end
end
end
diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb
index 88d7c9ef8bd..62bf6d627fe 100644
--- a/spec/features/projects/pipelines/pipelines_spec.rb
+++ b/spec/features/projects/pipelines/pipelines_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Pipelines', :js do
+describe "Pipelines", :js do
let(:project) { create(:project) }
- context 'when user is logged in' do
+ context "when user is logged in" do
let(:user) { create(:user) }
before do
sign_in(user)
project.add_developer(user)
- project.update!(auto_devops_attributes: { enabled: false })
+ project.update!(auto_devops_attributes: {enabled: false})
end
- describe 'GET /:project/pipelines' do
+ describe "GET /:project/pipelines" do
let(:project) { create(:project, :repository) }
let!(:pipeline) do
create(
:ci_empty_pipeline,
project: project,
- ref: 'master',
- status: 'running',
+ ref: "master",
+ status: "running",
sha: project.commit.id
)
end
- context 'scope' do
+ context "scope" do
before do
- create(:ci_empty_pipeline, status: 'pending', project: project, sha: project.commit.id, ref: 'master')
- create(:ci_empty_pipeline, status: 'running', project: project, sha: project.commit.id, ref: 'master')
- create(:ci_empty_pipeline, status: 'created', project: project, sha: project.commit.id, ref: 'master')
- create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master')
+ create(:ci_empty_pipeline, status: "pending", project: project, sha: project.commit.id, ref: "master")
+ create(:ci_empty_pipeline, status: "running", project: project, sha: project.commit.id, ref: "master")
+ create(:ci_empty_pipeline, status: "created", project: project, sha: project.commit.id, ref: "master")
+ create(:ci_empty_pipeline, status: "success", project: project, sha: project.commit.id, ref: "master")
end
[:all, :running, :pending, :finished, :branches].each do |scope|
@@ -39,77 +39,77 @@ describe 'Pipelines', :js do
visit_project_pipelines(scope: scope)
end
- it 'contains pipeline commit short SHA' do
+ it "contains pipeline commit short SHA" do
expect(page).to have_content(pipeline.short_sha)
end
- it 'contains branch name' do
+ it "contains branch name" do
expect(page).to have_content(pipeline.ref)
end
end
end
end
- context 'header tabs' do
+ context "header tabs" do
before do
visit project_pipelines_path(project)
wait_for_requests
end
- it 'shows a tab for All pipelines and count' do
- expect(page.find('.js-pipelines-tab-all').text).to include('All')
- expect(page.find('.js-pipelines-tab-all .badge').text).to include('1')
+ it "shows a tab for All pipelines and count" do
+ expect(page.find(".js-pipelines-tab-all").text).to include("All")
+ expect(page.find(".js-pipelines-tab-all .badge").text).to include("1")
end
- it 'shows a tab for Pending pipelines and count' do
- expect(page.find('.js-pipelines-tab-pending').text).to include('Pending')
- expect(page.find('.js-pipelines-tab-pending .badge').text).to include('0')
+ it "shows a tab for Pending pipelines and count" do
+ expect(page.find(".js-pipelines-tab-pending").text).to include("Pending")
+ expect(page.find(".js-pipelines-tab-pending .badge").text).to include("0")
end
- it 'shows a tab for Running pipelines and count' do
- expect(page.find('.js-pipelines-tab-running').text).to include('Running')
- expect(page.find('.js-pipelines-tab-running .badge').text).to include('1')
+ it "shows a tab for Running pipelines and count" do
+ expect(page.find(".js-pipelines-tab-running").text).to include("Running")
+ expect(page.find(".js-pipelines-tab-running .badge").text).to include("1")
end
- it 'shows a tab for Finished pipelines and count' do
- expect(page.find('.js-pipelines-tab-finished').text).to include('Finished')
- expect(page.find('.js-pipelines-tab-finished .badge').text).to include('0')
+ it "shows a tab for Finished pipelines and count" do
+ expect(page.find(".js-pipelines-tab-finished").text).to include("Finished")
+ expect(page.find(".js-pipelines-tab-finished .badge").text).to include("0")
end
- it 'shows a tab for Branches' do
- expect(page.find('.js-pipelines-tab-branches').text).to include('Branches')
+ it "shows a tab for Branches" do
+ expect(page.find(".js-pipelines-tab-branches").text).to include("Branches")
end
- it 'shows a tab for Tags' do
- expect(page.find('.js-pipelines-tab-tags').text).to include('Tags')
+ it "shows a tab for Tags" do
+ expect(page.find(".js-pipelines-tab-tags").text).to include("Tags")
end
- it 'updates content when tab is clicked' do
- page.find('.js-pipelines-tab-pending').click
+ it "updates content when tab is clicked" do
+ page.find(".js-pipelines-tab-pending").click
wait_for_requests
- expect(page).to have_content('There are currently no pending pipelines.')
+ expect(page).to have_content("There are currently no pending pipelines.")
end
end
- context 'navigation links' do
+ context "navigation links" do
before do
visit project_pipelines_path(project)
wait_for_requests
end
- it 'renders run pipeline link' do
- expect(page).to have_link('Run Pipeline')
+ it "renders run pipeline link" do
+ expect(page).to have_link("Run Pipeline")
end
- it 'renders ci lint link' do
- expect(page).to have_link('CI Lint')
+ it "renders ci lint link" do
+ expect(page).to have_link("CI Lint")
end
end
- context 'when pipeline is cancelable' do
+ context "when pipeline is cancelable" do
let!(:build) do
create(:ci_build, pipeline: pipeline,
- stage: 'test')
+ stage: "test")
end
before do
@@ -117,29 +117,29 @@ describe 'Pipelines', :js do
visit_project_pipelines
end
- it 'indicates that pipeline can be canceled' do
- expect(page).to have_selector('.js-pipelines-cancel-button')
- expect(page).to have_selector('.ci-running')
+ it "indicates that pipeline can be canceled" do
+ expect(page).to have_selector(".js-pipelines-cancel-button")
+ expect(page).to have_selector(".ci-running")
end
- context 'when canceling' do
+ context "when canceling" do
before do
- find('.js-pipelines-cancel-button').click
- find('.js-modal-primary-action').click
+ find(".js-pipelines-cancel-button").click
+ find(".js-modal-primary-action").click
wait_for_requests
end
- it 'indicated that pipelines was canceled' do
- expect(page).not_to have_selector('.js-pipelines-cancel-button')
- expect(page).to have_selector('.ci-canceled')
+ it "indicated that pipelines was canceled" do
+ expect(page).not_to have_selector(".js-pipelines-cancel-button")
+ expect(page).to have_selector(".ci-canceled")
end
end
end
- context 'when pipeline is retryable' do
+ context "when pipeline is retryable" do
let!(:build) do
create(:ci_build, pipeline: pipeline,
- stage: 'test')
+ stage: "test")
end
before do
@@ -147,25 +147,25 @@ describe 'Pipelines', :js do
visit_project_pipelines
end
- it 'indicates that pipeline can be retried' do
- expect(page).to have_selector('.js-pipelines-retry-button')
- expect(page).to have_selector('.ci-failed')
+ it "indicates that pipeline can be retried" do
+ expect(page).to have_selector(".js-pipelines-retry-button")
+ expect(page).to have_selector(".ci-failed")
end
- context 'when retrying' do
+ context "when retrying" do
before do
- find('.js-pipelines-retry-button').click
+ find(".js-pipelines-retry-button").click
wait_for_requests
end
- it 'shows running pipeline that is not retryable' do
- expect(page).not_to have_selector('.js-pipelines-retry-button')
- expect(page).to have_selector('.ci-running')
+ it "shows running pipeline that is not retryable" do
+ expect(page).not_to have_selector(".js-pipelines-retry-button")
+ expect(page).to have_selector(".ci-running")
end
end
end
- context 'when pipeline has configuration errors' do
+ context "when pipeline has configuration errors" do
let(:pipeline) do
create(:ci_pipeline, :invalid, project: project)
end
@@ -174,152 +174,154 @@ describe 'Pipelines', :js do
visit_project_pipelines
end
- it 'contains badge that indicates errors' do
- expect(page).to have_content 'yaml invalid'
+ it "contains badge that indicates errors" do
+ expect(page).to have_content "yaml invalid"
end
- it 'contains badge with tooltip which contains error' do
+ it "contains badge with tooltip which contains error" do
expect(pipeline).to have_yaml_errors
expect(page).to have_selector(
- %Q{span[data-original-title="#{pipeline.yaml_errors}"]})
+ %(span[data-original-title="#{pipeline.yaml_errors}"])
+ )
end
- it 'contains badge that indicates failure reason' do
- expect(page).to have_content 'error'
+ it "contains badge that indicates failure reason" do
+ expect(page).to have_content "error"
end
- it 'contains badge with tooltip which contains failure reason' do
+ it "contains badge with tooltip which contains failure reason" do
expect(pipeline.failure_reason?).to eq true
expect(page).to have_selector(
- %Q{span[data-original-title="#{pipeline.present.failure_reason}"]})
+ %(span[data-original-title="#{pipeline.present.failure_reason}"])
+ )
end
end
- context 'with manual actions' do
+ context "with manual actions" do
let!(:manual) do
create(:ci_build, :manual,
pipeline: pipeline,
- name: 'manual build',
- stage: 'test')
+ name: "manual build",
+ stage: "test")
end
before do
visit_project_pipelines
end
- it 'has a dropdown with play button' do
- expect(page).to have_selector('.dropdown-new.btn.btn-default .icon-play')
+ it "has a dropdown with play button" do
+ expect(page).to have_selector(".dropdown-new.btn.btn-default .icon-play")
end
- it 'has link to the manual action' do
- find('.js-pipeline-dropdown-manual-actions').click
+ it "has link to the manual action" do
+ find(".js-pipeline-dropdown-manual-actions").click
- expect(page).to have_button('manual build')
+ expect(page).to have_button("manual build")
end
- context 'when manual action was played' do
+ context "when manual action was played" do
before do
- find('.js-pipeline-dropdown-manual-actions').click
- click_button('manual build')
+ find(".js-pipeline-dropdown-manual-actions").click
+ click_button("manual build")
end
- it 'enqueues manual action job' do
- expect(page).to have_selector('.js-pipeline-dropdown-manual-actions:disabled')
+ it "enqueues manual action job" do
+ expect(page).to have_selector(".js-pipeline-dropdown-manual-actions:disabled")
end
end
end
- context 'when there is a delayed job' do
+ context "when there is a delayed job" do
let!(:delayed_job) do
create(:ci_build, :scheduled,
pipeline: pipeline,
- name: 'delayed job',
- stage: 'test')
+ name: "delayed job",
+ stage: "test")
end
before do
visit_project_pipelines
end
- it 'has a dropdown for actionable jobs' do
- expect(page).to have_selector('.dropdown-new.btn.btn-default .icon-play')
+ it "has a dropdown for actionable jobs" do
+ expect(page).to have_selector(".dropdown-new.btn.btn-default .icon-play")
end
it "has link to the delayed job's action" do
- find('.js-pipeline-dropdown-manual-actions').click
+ find(".js-pipeline-dropdown-manual-actions").click
time_diff = [0, delayed_job.scheduled_at - Time.now].max
- expect(page).to have_button('delayed job')
+ expect(page).to have_button("delayed job")
expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S"))
end
- context 'when delayed job is expired already' do
+ context "when delayed job is expired already" do
let!(:delayed_job) do
create(:ci_build, :expired_scheduled,
pipeline: pipeline,
- name: 'delayed job',
- stage: 'test')
+ name: "delayed job",
+ stage: "test")
end
it "shows 00:00:00 as the remaining time" do
- find('.js-pipeline-dropdown-manual-actions').click
+ find(".js-pipeline-dropdown-manual-actions").click
expect(page).to have_content("00:00:00")
end
end
- context 'when user played a delayed job immediately' do
+ context "when user played a delayed job immediately" do
before do
- find('.js-pipeline-dropdown-manual-actions').click
- page.accept_confirm { click_button('delayed job') }
+ find(".js-pipeline-dropdown-manual-actions").click
+ page.accept_confirm { click_button("delayed job") }
wait_for_requests
end
- it 'enqueues the delayed job', :js do
+ it "enqueues the delayed job", :js do
expect(delayed_job.reload).to be_pending
end
end
end
- context 'for generic statuses' do
- context 'when running' do
+ context "for generic statuses" do
+ context "when running" do
let!(:running) do
create(:generic_commit_status,
- status: 'running',
+ status: "running",
pipeline: pipeline,
- stage: 'test')
+ stage: "test")
end
before do
visit_project_pipelines
end
- it 'is cancelable' do
- expect(page).to have_selector('.js-pipelines-cancel-button')
+ it "is cancelable" do
+ expect(page).to have_selector(".js-pipelines-cancel-button")
end
- it 'has pipeline running' do
- expect(page).to have_selector('.ci-running')
+ it "has pipeline running" do
+ expect(page).to have_selector(".ci-running")
end
- context 'when canceling' do
+ context "when canceling" do
before do
- find('.js-pipelines-cancel-button').click
- find('.js-modal-primary-action').click
+ find(".js-pipelines-cancel-button").click
+ find(".js-modal-primary-action").click
end
- it 'indicates that pipeline was canceled' do
- expect(page).not_to have_selector('.js-pipelines-cancel-button')
- expect(page).to have_selector('.ci-canceled')
+ it "indicates that pipeline was canceled" do
+ expect(page).not_to have_selector(".js-pipelines-cancel-button")
+ expect(page).to have_selector(".ci-canceled")
end
end
end
- context 'when failed' do
+ context "when failed" do
let!(:status) do
create(:generic_commit_status, :pending,
pipeline: pipeline,
- stage: 'test')
+ stage: "test")
end
before do
@@ -327,216 +329,216 @@ describe 'Pipelines', :js do
visit_project_pipelines
end
- it 'is not retryable' do
- expect(page).not_to have_selector('.js-pipelines-retry-button')
+ it "is not retryable" do
+ expect(page).not_to have_selector(".js-pipelines-retry-button")
end
- it 'has failed pipeline' do
- expect(page).to have_selector('.ci-failed')
+ it "has failed pipeline" do
+ expect(page).to have_selector(".ci-failed")
end
end
end
- context 'downloadable pipelines' do
- context 'with artifacts' do
+ context "downloadable pipelines" do
+ context "with artifacts" do
let!(:with_artifacts) do
create(:ci_build, :artifacts, :success,
pipeline: pipeline,
- name: 'rspec tests',
- stage: 'test')
+ name: "rspec tests",
+ stage: "test")
end
before do
visit_project_pipelines
end
- it 'has artifats' do
- expect(page).to have_selector('.build-artifacts')
+ it "has artifats" do
+ expect(page).to have_selector(".build-artifacts")
end
- it 'has artifacts download dropdown' do
- find('.js-pipeline-dropdown-download').click
+ it "has artifacts download dropdown" do
+ find(".js-pipeline-dropdown-download").click
expect(page).to have_link(with_artifacts.name)
end
- it 'has download attribute on download links' do
- find('.js-pipeline-dropdown-download').click
- expect(page).to have_selector('a', text: 'Download')
- page.all('.build-artifacts a', text: 'Download').each do |link|
- expect(link[:download]).to eq ''
+ it "has download attribute on download links" do
+ find(".js-pipeline-dropdown-download").click
+ expect(page).to have_selector("a", text: "Download")
+ page.all(".build-artifacts a", text: "Download").each do |link|
+ expect(link[:download]).to eq ""
end
end
end
- context 'with artifacts expired' do
+ context "with artifacts expired" do
let!(:with_artifacts_expired) do
create(:ci_build, :expired, :success,
pipeline: pipeline,
- name: 'rspec',
- stage: 'test')
+ name: "rspec",
+ stage: "test")
end
before do
visit_project_pipelines
end
- it { expect(page).not_to have_selector('.build-artifacts') }
+ it { expect(page).not_to have_selector(".build-artifacts") }
end
- context 'without artifacts' do
+ context "without artifacts" do
let!(:without_artifacts) do
create(:ci_build, :success,
pipeline: pipeline,
- name: 'rspec',
- stage: 'test')
+ name: "rspec",
+ stage: "test")
end
before do
visit_project_pipelines
end
- it { expect(page).not_to have_selector('.build-artifacts') }
+ it { expect(page).not_to have_selector(".build-artifacts") }
end
- context 'with trace artifact' do
+ context "with trace artifact" do
before do
create(:ci_build, :success, :trace_artifact, pipeline: pipeline)
visit_project_pipelines
end
- it 'does not show trace artifact as artifacts' do
- expect(page).not_to have_selector('.build-artifacts')
+ it "does not show trace artifact as artifacts" do
+ expect(page).not_to have_selector(".build-artifacts")
end
end
end
- context 'mini pipeline graph' do
+ context "mini pipeline graph" do
let!(:build) do
create(:ci_build, :pending, pipeline: pipeline,
- stage: 'build',
- name: 'build')
+ stage: "build",
+ name: "build")
end
before do
visit_project_pipelines
end
- it 'should render a mini pipeline graph' do
- expect(page).to have_selector('.js-mini-pipeline-graph')
- expect(page).to have_selector('.js-builds-dropdown-button')
+ it "should render a mini pipeline graph" do
+ expect(page).to have_selector(".js-mini-pipeline-graph")
+ expect(page).to have_selector(".js-builds-dropdown-button")
end
- context 'when clicking a stage badge' do
- it 'should open a dropdown' do
- find('.js-builds-dropdown-button').click
+ context "when clicking a stage badge" do
+ it "should open a dropdown" do
+ find(".js-builds-dropdown-button").click
expect(page).to have_link build.name
end
- it 'should be possible to cancel pending build' do
- find('.js-builds-dropdown-button').click
- find('.js-ci-action').click
+ it "should be possible to cancel pending build" do
+ find(".js-builds-dropdown-button").click
+ find(".js-ci-action").click
wait_for_requests
expect(build.reload).to be_canceled
end
end
- context 'for a failed pipeline' do
+ context "for a failed pipeline" do
let!(:build) do
create(:ci_build, :failed, pipeline: pipeline,
- stage: 'build',
- name: 'build')
+ stage: "build",
+ name: "build")
end
- it 'should display the failure reason' do
- find('.js-builds-dropdown-button').click
+ it "should display the failure reason" do
+ find(".js-builds-dropdown-button").click
- within('.js-builds-dropdown-list') do
- build_element = page.find('.mini-pipeline-graph-dropdown-item')
- expect(build_element['data-original-title']).to eq('build - failed - (unknown failure)')
+ within(".js-builds-dropdown-list") do
+ build_element = page.find(".mini-pipeline-graph-dropdown-item")
+ expect(build_element["data-original-title"]).to eq("build - failed - (unknown failure)")
end
end
end
end
- context 'with pagination' do
+ context "with pagination" do
before do
allow(Ci::Pipeline).to receive(:default_per_page).and_return(1)
create(:ci_empty_pipeline, project: project)
end
- it 'should render pagination' do
+ it "should render pagination" do
visit project_pipelines_path(project)
wait_for_requests
- expect(page).to have_selector('.gl-pagination')
+ expect(page).to have_selector(".gl-pagination")
end
- it 'should render second page of pipelines' do
- visit project_pipelines_path(project, page: '2')
+ it "should render second page of pipelines" do
+ visit project_pipelines_path(project, page: "2")
wait_for_requests
- expect(page).to have_selector('.gl-pagination .page', count: 2)
+ expect(page).to have_selector(".gl-pagination .page", count: 2)
end
- it 'should show updated content' do
+ it "should show updated content" do
visit project_pipelines_path(project)
wait_for_requests
- page.find('.js-next-button .page-link').click
+ page.find(".js-next-button .page-link").click
- expect(page).to have_selector('.gl-pagination .page', count: 2)
+ expect(page).to have_selector(".gl-pagination .page", count: 2)
end
end
end
- describe 'GET /:project/pipelines/show' do
+ describe "GET /:project/pipelines/show" do
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_empty_pipeline,
- project: project,
- sha: project.commit.id,
- user: user)
+ project: project,
+ sha: project.commit.id,
+ user: user)
end
before do
- create_build('build', 0, 'build', :success)
- create_build('test', 1, 'rspec 0:2', :pending)
- create_build('test', 1, 'rspec 1:2', :running)
- create_build('test', 1, 'spinach 0:2', :created)
- create_build('test', 1, 'spinach 1:2', :created)
- create_build('test', 1, 'audit', :created)
- create_build('deploy', 2, 'production', :created)
+ create_build("build", 0, "build", :success)
+ create_build("test", 1, "rspec 0:2", :pending)
+ create_build("test", 1, "rspec 1:2", :running)
+ create_build("test", 1, "spinach 0:2", :created)
+ create_build("test", 1, "spinach 1:2", :created)
+ create_build("test", 1, "audit", :created)
+ create_build("deploy", 2, "production", :created)
- create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3)
+ create(:generic_commit_status, pipeline: pipeline, stage: "external", name: "jenkins", stage_idx: 3)
visit project_pipeline_path(project, pipeline)
wait_for_requests
end
- it 'shows a graph with grouped stages' do
- expect(page).to have_css('.js-pipeline-graph')
+ it "shows a graph with grouped stages" do
+ expect(page).to have_css(".js-pipeline-graph")
# header
expect(page).to have_text("##{pipeline.id}")
- expect(page).to have_selector(%Q(img[alt$="#{pipeline.user.name}'s avatar"]))
+ expect(page).to have_selector(%(img[alt$="#{pipeline.user.name}'s avatar"]))
expect(page).to have_link(pipeline.user.name, href: user_path(pipeline.user))
# stages
- expect(page).to have_text('Build')
- expect(page).to have_text('Test')
- expect(page).to have_text('Deploy')
- expect(page).to have_text('External')
+ expect(page).to have_text("Build")
+ expect(page).to have_text("Test")
+ expect(page).to have_text("Deploy")
+ expect(page).to have_text("External")
# builds
- expect(page).to have_text('rspec')
- expect(page).to have_text('spinach')
- expect(page).to have_text('rspec')
- expect(page).to have_text('production')
- expect(page).to have_text('jenkins')
+ expect(page).to have_text("rspec")
+ expect(page).to have_text("spinach")
+ expect(page).to have_text("rspec")
+ expect(page).to have_text("production")
+ expect(page).to have_text("jenkins")
end
def create_build(stage, stage_idx, name, status)
@@ -544,169 +546,169 @@ describe 'Pipelines', :js do
end
end
- describe 'POST /:project/pipelines' do
+ describe "POST /:project/pipelines" do
let(:project) { create(:project, :repository) }
before do
visit new_project_pipeline_path(project)
end
- context 'for valid commit', :js do
+ context "for valid commit", :js do
before do
click_button project.default_branch
- page.within '.dropdown-menu' do
- click_link 'master'
+ page.within ".dropdown-menu" do
+ click_link "master"
end
end
- context 'with gitlab-ci.yml' do
+ context "with gitlab-ci.yml" do
before do
stub_ci_pipeline_to_return_yaml_file
end
- it 'creates a new pipeline' do
- expect { click_on 'Create pipeline' }
+ it "creates a new pipeline" do
+ expect { click_on "Create pipeline" }
.to change { Ci::Pipeline.count }.by(1)
expect(Ci::Pipeline.last).to be_web
end
- context 'when variables are specified' do
- it 'creates a new pipeline with variables' do
- page.within '.ci-variable-row-body' do
+ context "when variables are specified" do
+ it "creates a new pipeline with variables" do
+ page.within ".ci-variable-row-body" do
fill_in "Input variable key", with: "key_name"
fill_in "Input variable value", with: "value"
end
- expect { click_on 'Create pipeline' }
+ expect { click_on "Create pipeline" }
.to change { Ci::Pipeline.count }.by(1)
expect(Ci::Pipeline.last.variables.map { |var| var.slice(:key, :secret_value) })
- .to eq [{ key: "key_name", secret_value: "value" }.with_indifferent_access]
+ .to eq [{key: "key_name", secret_value: "value"}.with_indifferent_access]
end
end
end
- context 'without gitlab-ci.yml' do
+ context "without gitlab-ci.yml" do
before do
- click_on 'Create pipeline'
+ click_on "Create pipeline"
end
- it { expect(page).to have_content('Missing .gitlab-ci.yml file') }
- it 'creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again' do
+ it { expect(page).to have_content("Missing .gitlab-ci.yml file") }
+ it "creates a pipeline after first request failed and a valid gitlab-ci.yml file is available when trying again" do
click_button project.default_branch
stub_ci_pipeline_to_return_yaml_file
- page.within '.dropdown-menu' do
- click_link 'master'
+ page.within ".dropdown-menu" do
+ click_link "master"
end
- expect { click_on 'Create pipeline' }
+ expect { click_on "Create pipeline" }
.to change { Ci::Pipeline.count }.by(1)
end
end
end
end
- describe 'Create pipelines' do
+ describe "Create pipelines" do
let(:project) { create(:project, :repository) }
before do
visit new_project_pipeline_path(project)
end
- describe 'new pipeline page' do
- it 'has field to add a new pipeline' do
- expect(page).to have_selector('.js-branch-select')
- expect(find('.js-branch-select')).to have_content project.default_branch
- expect(page).to have_content('Create for')
+ describe "new pipeline page" do
+ it "has field to add a new pipeline" do
+ expect(page).to have_selector(".js-branch-select")
+ expect(find(".js-branch-select")).to have_content project.default_branch
+ expect(page).to have_content("Create for")
end
end
- describe 'find pipelines' do
- it 'shows filtered pipelines', :js do
+ describe "find pipelines" do
+ it "shows filtered pipelines", :js do
click_button project.default_branch
- page.within '.dropdown-menu' do
- find('.dropdown-input-field').native.send_keys('fix')
+ page.within ".dropdown-menu" do
+ find(".dropdown-input-field").native.send_keys("fix")
- page.within '.dropdown-content' do
- expect(page).to have_content('fix')
+ page.within ".dropdown-content" do
+ expect(page).to have_content("fix")
end
end
end
end
end
- describe 'Reset runner caches' do
+ describe "Reset runner caches" do
let(:project) { create(:project, :repository) }
before do
- create(:ci_empty_pipeline, status: 'success', project: project, sha: project.commit.id, ref: 'master')
+ create(:ci_empty_pipeline, status: "success", project: project, sha: project.commit.id, ref: "master")
project.add_maintainer(user)
visit project_pipelines_path(project)
end
- it 'has a clear caches button' do
- expect(page).to have_button 'Clear Runner Caches'
+ it "has a clear caches button" do
+ expect(page).to have_button "Clear Runner Caches"
end
- describe 'user clicks the button' do
- context 'when project already has jobs_cache_index' do
+ describe "user clicks the button" do
+ context "when project already has jobs_cache_index" do
before do
project.update(jobs_cache_index: 1)
end
- it 'increments jobs_cache_index' do
- click_button 'Clear Runner Caches'
+ it "increments jobs_cache_index" do
+ click_button "Clear Runner Caches"
wait_for_requests
- expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.'
+ expect(page.find(".flash-notice")).to have_content "Project cache successfully reset."
end
end
- context 'when project does not have jobs_cache_index' do
- it 'sets jobs_cache_index to 1' do
- click_button 'Clear Runner Caches'
+ context "when project does not have jobs_cache_index" do
+ it "sets jobs_cache_index to 1" do
+ click_button "Clear Runner Caches"
wait_for_requests
- expect(page.find('.flash-notice')).to have_content 'Project cache successfully reset.'
+ expect(page.find(".flash-notice")).to have_content "Project cache successfully reset."
end
end
end
end
- describe 'Empty State' do
+ describe "Empty State" do
let(:project) { create(:project, :repository) }
before do
visit project_pipelines_path(project)
end
- it 'renders empty state' do
- expect(page).to have_content 'Build with confidence'
+ it "renders empty state" do
+ expect(page).to have_content "Build with confidence"
end
end
end
- context 'when user is not logged in' do
+ context "when user is not logged in" do
before do
- project.update!(auto_devops_attributes: { enabled: false })
+ project.update!(auto_devops_attributes: {enabled: false})
visit project_pipelines_path(project)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :public, :repository) }
- context 'without pipelines' do
- it { expect(page).to have_content 'This project is not currently set up to run pipelines.' }
+ context "without pipelines" do
+ it { expect(page).to have_content "This project is not currently set up to run pipelines." }
end
end
- context 'when project is private' do
+ context "when project is private" do
let(:project) { create(:project, :private, :repository) }
- it { expect(page).to have_content 'You need to sign in' }
+ it { expect(page).to have_content "You need to sign in" }
end
end
diff --git a/spec/features/projects/releases/user_views_releases_spec.rb b/spec/features/projects/releases/user_views_releases_spec.rb
index 317ffb6a2ff..99528b087af 100644
--- a/spec/features/projects/releases/user_views_releases_spec.rb
+++ b/spec/features/projects/releases/user_views_releases_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views releases', :js do
+describe "User views releases", :js do
let!(:project) { create(:project, :repository) }
- let!(:release) { create(:release, project: project ) }
+ let!(:release) { create(:release, project: project) }
let!(:user) { create(:user) }
before do
@@ -11,34 +11,34 @@ describe 'User views releases', :js do
gitlab_sign_in(user)
end
- it 'sees the release' do
+ it "sees the release" do
visit project_releases_path(project)
expect(page).to have_content(release.name)
expect(page).to have_content(release.tag)
end
- context 'when there is a link as an asset' do
- let!(:release_link) { create(:release_link, release: release, url: url ) }
+ context "when there is a link as an asset" do
+ let!(:release_link) { create(:release_link, release: release, url: url) }
let(:url) { "#{project.web_url}/-/jobs/1/artifacts/download" }
- it 'sees the link' do
+ it "sees the link" do
visit project_releases_path(project)
- page.within('.js-assets-list') do
+ page.within(".js-assets-list") do
expect(page).to have_link release_link.name, href: release_link.url
- expect(page).not_to have_content('(external source)')
+ expect(page).not_to have_content("(external source)")
end
end
- context 'when url points to external resource' do
- let(:url) { 'http://google.com/download' }
+ context "when url points to external resource" do
+ let(:url) { "http://google.com/download" }
- it 'sees that the link is external resource' do
+ it "sees that the link is external resource" do
visit project_releases_path(project)
- page.within('.js-assets-list') do
- expect(page).to have_content('(external source)')
+ page.within(".js-assets-list") do
+ expect(page).to have_content("(external source)")
end
end
end
diff --git a/spec/features/projects/remote_mirror_spec.rb b/spec/features/projects/remote_mirror_spec.rb
index 33e9b73efe8..8342a663f51 100644
--- a/spec/features/projects/remote_mirror_spec.rb
+++ b/spec/features/projects/remote_mirror_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project remote mirror', :feature do
+describe "Project remote mirror", :feature do
let(:project) { create(:project, :repository, :remote_mirror) }
let(:remote_mirror) { project.remote_mirrors.first }
let(:user) { create(:user) }
- describe 'On a project', :js do
+ describe "On a project", :js do
before do
project.add_maintainer(user)
sign_in user
end
- context 'when last_error is present but last_update_at is not' do
- it 'renders error message without timstamp' do
- remote_mirror.update(last_error: 'Some new error', last_update_at: nil)
+ context "when last_error is present but last_update_at is not" do
+ it "renders error message without timstamp" do
+ remote_mirror.update(last_error: "Some new error", last_update_at: nil)
visit project_mirror_path(project)
- expect_mirror_to_have_error_and_timeago('Never')
+ expect_mirror_to_have_error_and_timeago("Never")
end
end
- context 'when last_error and last_update_at are present' do
- it 'renders error message with timestamp' do
- remote_mirror.update(last_error: 'Some new error', last_update_at: Time.now - 5.minutes)
+ context "when last_error and last_update_at are present" do
+ it "renders error message with timestamp" do
+ remote_mirror.update(last_error: "Some new error", last_update_at: Time.now - 5.minutes)
visit project_mirror_path(project)
- expect_mirror_to_have_error_and_timeago('5 minutes ago')
+ expect_mirror_to_have_error_and_timeago("5 minutes ago")
end
end
def expect_mirror_to_have_error_and_timeago(timeago)
- row = first('.js-mirrors-table-body tr')
- expect(row).to have_content('Error')
+ row = first(".js-mirrors-table-body tr")
+ expect(row).to have_content("Error")
expect(row).to have_content(timeago)
end
end
diff --git a/spec/features/projects/serverless/functions_spec.rb b/spec/features/projects/serverless/functions_spec.rb
index aa71669de98..602605c55fe 100644
--- a/spec/features/projects/serverless/functions_spec.rb
+++ b/spec/features/projects/serverless/functions_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Functions', :js do
+describe "Functions", :js do
include KubernetesHelpers
let(:project) { create(:project) }
@@ -13,31 +13,31 @@ describe 'Functions', :js do
gitlab_sign_in(user)
end
- context 'when user does not have a cluster and visits the serverless page' do
+ context "when user does not have a cluster and visits the serverless page" do
before do
visit project_serverless_functions_path(project)
end
- it 'sees an empty state' do
- expect(page).to have_link('Install Knative')
- expect(page).to have_selector('.empty-state')
+ it "sees an empty state" do
+ expect(page).to have_link("Install Knative")
+ expect(page).to have_selector(".empty-state")
end
end
- context 'when the user does have a cluster and visits the serverless page' do
+ context "when the user does have a cluster and visits the serverless page" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
before do
visit project_serverless_functions_path(project)
end
- it 'sees an empty state' do
- expect(page).to have_link('Install Knative')
- expect(page).to have_selector('.empty-state')
+ it "sees an empty state" do
+ expect(page).to have_link("Install Knative")
+ expect(page).to have_selector(".empty-state")
end
end
- context 'when the user has a cluster and knative installed and visits the serverless page' do
+ context "when the user has a cluster and knative installed and visits the serverless page" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:service) { cluster.platform_kubernetes }
let(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) }
@@ -49,8 +49,8 @@ describe 'Functions', :js do
visit project_serverless_functions_path(project)
end
- it 'sees an empty listing of serverless functions' do
- expect(page).to have_selector('.gl-responsive-table-row')
+ it "sees an empty listing of serverless functions" do
+ expect(page).to have_selector(".gl-responsive-table-row")
end
end
end
diff --git a/spec/features/projects/services/disable_triggers_spec.rb b/spec/features/projects/services/disable_triggers_spec.rb
index 65b597da269..93da953774a 100644
--- a/spec/features/projects/services/disable_triggers_spec.rb
+++ b/spec/features/projects/services/disable_triggers_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Disable individual triggers' do
+describe "Disable individual triggers" do
let(:project) { create(:project) }
let(:user) { project.owner }
- let(:checkbox_selector) { 'input[type=checkbox][id$=_events]' }
+ let(:checkbox_selector) { "input[type=checkbox][id$=_events]" }
before do
sign_in(user)
@@ -13,10 +13,10 @@ describe 'Disable individual triggers' do
click_link(service_name)
end
- context 'service has multiple supported events' do
- let(:service_name) { 'JIRA' }
+ context "service has multiple supported events" do
+ let(:service_name) { "JIRA" }
- it 'shows trigger checkboxes' do
+ it "shows trigger checkboxes" do
event_count = JiraService.supported_events.count
expect(event_count).to be > 1
@@ -25,8 +25,8 @@ describe 'Disable individual triggers' do
end
end
- context 'services only has one supported event' do
- let(:service_name) { 'Asana' }
+ context "services only has one supported event" do
+ let(:service_name) { "Asana" }
it "doesn't show unnecessary Trigger checkboxes" do
expect(page).not_to have_content "Trigger"
diff --git a/spec/features/projects/services/user_activates_asana_spec.rb b/spec/features/projects/services/user_activates_asana_spec.rb
index c44e07dd3b4..105e8bad1fc 100644
--- a/spec/features/projects/services/user_activates_asana_spec.rb
+++ b/spec/features/projects/services/user_activates_asana_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Asana' do
+describe "User activates Asana" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,15 +10,15 @@ describe 'User activates Asana' do
visit(project_settings_integrations_path(project))
- click_link('Asana')
+ click_link("Asana")
end
- it 'activates service' do
- check('Active')
- fill_in('Api key', with: 'verySecret')
- fill_in('Restrict to branch', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Api key", with: "verySecret")
+ fill_in("Restrict to branch", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('Asana activated.')
+ expect(page).to have_content("Asana activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_assembla_spec.rb b/spec/features/projects/services/user_activates_assembla_spec.rb
index 9c3884a7c74..55f719e7751 100644
--- a/spec/features/projects/services/user_activates_assembla_spec.rb
+++ b/spec/features/projects/services/user_activates_assembla_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Assembla' do
+describe "User activates Assembla" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe 'User activates Assembla' do
visit(project_settings_integrations_path(project))
- click_link('Assembla')
+ click_link("Assembla")
end
- it 'activates service' do
- check('Active')
- fill_in('Token', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Token", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('Assembla activated.')
+ expect(page).to have_content("Assembla activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb b/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb
index 19573565265..69cf92efdb2 100644
--- a/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb
+++ b/spec/features/projects/services/user_activates_atlassian_bamboo_ci_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Atlassian Bamboo CI' do
+describe "User activates Atlassian Bamboo CI" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,22 +10,22 @@ describe 'User activates Atlassian Bamboo CI' do
visit(project_settings_integrations_path(project))
- click_link('Atlassian Bamboo CI')
+ click_link("Atlassian Bamboo CI")
end
- it 'activates service' do
- check('Active')
- fill_in('Bamboo url', with: 'http://bamboo.example.com')
- fill_in('Build key', with: 'KEY')
- fill_in('Username', with: 'user')
- fill_in('Password', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Bamboo url", with: "http://bamboo.example.com")
+ fill_in("Build key", with: "KEY")
+ fill_in("Username", with: "user")
+ fill_in("Password", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('Atlassian Bamboo CI activated.')
+ expect(page).to have_content("Atlassian Bamboo CI activated.")
# Password field should not be filled in.
- click_link('Atlassian Bamboo CI')
+ click_link("Atlassian Bamboo CI")
- expect(find_field('Enter new password').value).to be_nil
+ expect(find_field("Enter new password").value).to be_nil
end
end
diff --git a/spec/features/projects/services/user_activates_emails_on_push_spec.rb b/spec/features/projects/services/user_activates_emails_on_push_spec.rb
index cc55f7b2060..7904e7c4fec 100644
--- a/spec/features/projects/services/user_activates_emails_on_push_spec.rb
+++ b/spec/features/projects/services/user_activates_emails_on_push_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Emails on push' do
+describe "User activates Emails on push" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe 'User activates Emails on push' do
visit(project_settings_integrations_path(project))
- click_link('Emails on push')
+ click_link("Emails on push")
end
- it 'activates service' do
- check('Active')
- fill_in('Recipients', with: 'qa@company.name')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Recipients", with: "qa@company.name")
+ click_button("Save")
- expect(page).to have_content('Emails on push activated.')
+ expect(page).to have_content("Emails on push activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_flowdock_spec.rb b/spec/features/projects/services/user_activates_flowdock_spec.rb
index f981b7e9da9..abfe0477566 100644
--- a/spec/features/projects/services/user_activates_flowdock_spec.rb
+++ b/spec/features/projects/services/user_activates_flowdock_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Flowdock' do
+describe "User activates Flowdock" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe 'User activates Flowdock' do
visit(project_settings_integrations_path(project))
- click_link('Flowdock')
+ click_link("Flowdock")
end
- it 'activates service' do
- check('Active')
- fill_in('Token', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Token", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('Flowdock activated.')
+ expect(page).to have_content("Flowdock activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_irker_spec.rb b/spec/features/projects/services/user_activates_irker_spec.rb
index 4c8e321b411..3e258f05880 100644
--- a/spec/features/projects/services/user_activates_irker_spec.rb
+++ b/spec/features/projects/services/user_activates_irker_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Irker (IRC gateway)' do
+describe "User activates Irker (IRC gateway)" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,15 +10,15 @@ describe 'User activates Irker (IRC gateway)' do
visit(project_settings_integrations_path(project))
- click_link('Irker (IRC gateway)')
+ click_link("Irker (IRC gateway)")
end
- it 'activates service' do
- check('Active')
- check('Colorize messages')
- fill_in('Recipients', with: 'irc://chat.freenode.net/#commits')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ check("Colorize messages")
+ fill_in("Recipients", with: "irc://chat.freenode.net/#commits")
+ click_button("Save")
- expect(page).to have_content('Irker (IRC gateway) activated.')
+ expect(page).to have_content("Irker (IRC gateway) activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_issue_tracker_spec.rb b/spec/features/projects/services/user_activates_issue_tracker_spec.rb
index 74b9a2b20cd..730b793e14c 100644
--- a/spec/features/projects/services/user_activates_issue_tracker_spec.rb
+++ b/spec/features/projects/services/user_activates_issue_tracker_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates issue tracker', :js do
+describe "User activates issue tracker", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:url) { 'http://tracker.example.com' }
+ let(:url) { "http://tracker.example.com" }
def fill_short_form(active = true)
- check 'Active' if active
+ check "Active" if active
- fill_in 'service_project_url', with: url
- fill_in 'service_issues_url', with: "#{url}/:id"
+ fill_in "service_project_url", with: url
+ fill_in "service_issues_url", with: "#{url}/:id"
end
def fill_full_form(active = true)
fill_short_form(active)
- check 'Active' if active
+ check "Active" if active
- fill_in 'service_new_issue_url', with: url
+ fill_in "service_new_issue_url", with: url
end
before do
@@ -27,11 +27,11 @@ describe 'User activates issue tracker', :js do
visit project_settings_integrations_path(project)
end
- shared_examples 'external issue tracker activation' do |tracker:, skip_new_issue_url: false|
- describe 'user sets and activates the Service' do
- context 'when the connection test succeeds' do
+ shared_examples "external issue tracker activation" do |tracker:, skip_new_issue_url: false|
+ describe "user sets and activates the Service" do
+ context "when the connection test succeeds" do
before do
- stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })
+ stub_request(:head, url).to_return(headers: {"Content-Type" => "application/json"})
click_link(tracker)
@@ -41,24 +41,24 @@ describe 'User activates issue tracker', :js do
fill_full_form
end
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
end
- it 'activates the service' do
+ it "activates the service" do
expect(page).to have_content("#{tracker} activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'shows the link in the menu' do
- page.within('.nav-sidebar') do
+ it "shows the link in the menu" do
+ page.within(".nav-sidebar") do
expect(page).to have_link(tracker, href: url)
end
end
end
- context 'when the connection test fails' do
- it 'activates the service' do
+ context "when the connection test fails" do
+ it "activates the service" do
stub_request(:head, url).to_raise(HTTParty::Error)
click_link(tracker)
@@ -69,13 +69,13 @@ describe 'User activates issue tracker', :js do
fill_full_form
end
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
- expect(find('.flash-container-page')).to have_content 'Test failed.'
- expect(find('.flash-container-page')).to have_content 'Save anyway'
+ expect(find(".flash-container-page")).to have_content "Test failed."
+ expect(find(".flash-container-page")).to have_content "Save anyway"
- find('.flash-alert .flash-action').click
+ find(".flash-alert .flash-action").click
wait_for_requests
expect(page).to have_content("#{tracker} activated.")
@@ -84,7 +84,7 @@ describe 'User activates issue tracker', :js do
end
end
- describe 'user sets the service but keeps it disabled' do
+ describe "user sets the service but keeps it disabled" do
before do
click_link(tracker)
@@ -94,24 +94,24 @@ describe 'User activates issue tracker', :js do
fill_full_form(false)
end
- click_button('Save changes')
+ click_button("Save changes")
end
- it 'saves but does not activate the service' do
+ it "saves but does not activate the service" do
expect(page).to have_content("#{tracker} settings saved, but not activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'does not show the external tracker link in the menu' do
- page.within('.nav-sidebar') do
+ it "does not show the external tracker link in the menu" do
+ page.within(".nav-sidebar") do
expect(page).not_to have_link(tracker, href: url)
end
end
end
end
- it_behaves_like 'external issue tracker activation', tracker: 'Redmine'
- it_behaves_like 'external issue tracker activation', tracker: 'YouTrack', skip_new_issue_url: true
- it_behaves_like 'external issue tracker activation', tracker: 'Bugzilla'
- it_behaves_like 'external issue tracker activation', tracker: 'Custom Issue Tracker'
+ it_behaves_like "external issue tracker activation", tracker: "Redmine"
+ it_behaves_like "external issue tracker activation", tracker: "YouTrack", skip_new_issue_url: true
+ it_behaves_like "external issue tracker activation", tracker: "Bugzilla"
+ it_behaves_like "external issue tracker activation", tracker: "Custom Issue Tracker"
end
diff --git a/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb b/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb
index 28d83a8b961..d1e94cf8cd0 100644
--- a/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb
+++ b/spec/features/projects/services/user_activates_jetbrains_teamcity_ci_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates JetBrains TeamCity CI' do
+describe "User activates JetBrains TeamCity CI" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,17 +10,17 @@ describe 'User activates JetBrains TeamCity CI' do
visit(project_settings_integrations_path(project))
- click_link('JetBrains TeamCity CI')
+ click_link("JetBrains TeamCity CI")
end
- it 'activates service' do
- check('Active')
- fill_in('Teamcity url', with: 'http://teamcity.example.com')
- fill_in('Build type', with: 'GitlabTest_Build')
- fill_in('Username', with: 'user')
- fill_in('Password', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Teamcity url", with: "http://teamcity.example.com")
+ fill_in("Build type", with: "GitlabTest_Build")
+ fill_in("Username", with: "user")
+ fill_in("Password", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('JetBrains TeamCity CI activated.')
+ expect(page).to have_content("JetBrains TeamCity CI activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_jira_spec.rb b/spec/features/projects/services/user_activates_jira_spec.rb
index 08e1855d034..0acadc9a928 100644
--- a/spec/features/projects/services/user_activates_jira_spec.rb
+++ b/spec/features/projects/services/user_activates_jira_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Jira', :js do
+describe "User activates Jira", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:url) { 'http://jira.example.com' }
- let(:test_url) { 'http://jira.example.com/rest/api/2/serverInfo' }
+ let(:url) { "http://jira.example.com" }
+ let(:test_url) { "http://jira.example.com/rest/api/2/serverInfo" }
def fill_form(active = true)
- check 'Active' if active
+ check "Active" if active
- fill_in 'service_url', with: url
- fill_in 'service_username', with: 'username'
- fill_in 'service_password', with: 'password'
- fill_in 'service_jira_issue_transition_id', with: '25'
+ fill_in "service_url", with: url
+ fill_in "service_username", with: "username"
+ fill_in "service_password", with: "password"
+ fill_in "service_jira_issue_transition_id", with: "25"
end
before do
@@ -23,79 +23,79 @@ describe 'User activates Jira', :js do
visit project_settings_integrations_path(project)
end
- describe 'user sets and activates Jira Service' do
- context 'when Jira connection test succeeds' do
+ describe "user sets and activates Jira Service" do
+ context "when Jira connection test succeeds" do
before do
- server_info = { key: 'value' }.to_json
- WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password)).to_return(body: server_info)
+ server_info = {key: "value"}.to_json
+ WebMock.stub_request(:get, test_url).with(basic_auth: %w[username password]).to_return(body: server_info)
- click_link('JIRA')
+ click_link("JIRA")
fill_form
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
end
- it 'activates the JIRA service' do
- expect(page).to have_content('JIRA activated.')
+ it "activates the JIRA service" do
+ expect(page).to have_content("JIRA activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'shows the JIRA link in the menu' do
- page.within('.nav-sidebar') do
- expect(page).to have_link('JIRA', href: url)
+ it "shows the JIRA link in the menu" do
+ page.within(".nav-sidebar") do
+ expect(page).to have_link("JIRA", href: url)
end
end
end
- context 'when Jira connection test fails' do
- it 'shows errors when some required fields are not filled in' do
- click_link('JIRA')
+ context "when Jira connection test fails" do
+ it "shows errors when some required fields are not filled in" do
+ click_link("JIRA")
- check 'Active'
- fill_in 'service_password', with: 'password'
- click_button('Test settings and save changes')
+ check "Active"
+ fill_in "service_password", with: "password"
+ click_button("Test settings and save changes")
- page.within('.service-settings') do
- expect(page).to have_content('This field is required.')
+ page.within(".service-settings") do
+ expect(page).to have_content("This field is required.")
end
end
- it 'activates the JIRA service' do
- WebMock.stub_request(:get, test_url).with(basic_auth: %w(username password))
- .to_raise(JIRA::HTTPError.new(double(message: 'message')))
+ it "activates the JIRA service" do
+ WebMock.stub_request(:get, test_url).with(basic_auth: %w[username password])
+ .to_raise(JIRA::HTTPError.new(double(message: "message")))
- click_link('JIRA')
+ click_link("JIRA")
fill_form
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
- expect(find('.flash-container-page')).to have_content 'Test failed. message'
- expect(find('.flash-container-page')).to have_content 'Save anyway'
+ expect(find(".flash-container-page")).to have_content "Test failed. message"
+ expect(find(".flash-container-page")).to have_content "Save anyway"
- find('.flash-alert .flash-action').click
+ find(".flash-alert .flash-action").click
wait_for_requests
- expect(page).to have_content('JIRA activated.')
+ expect(page).to have_content("JIRA activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
end
end
- describe 'user sets Jira Service but keeps it disabled' do
+ describe "user sets Jira Service but keeps it disabled" do
before do
- click_link('JIRA')
+ click_link("JIRA")
fill_form(false)
- click_button('Save changes')
+ click_button("Save changes")
end
- it 'saves but does not activate the JIRA service' do
- expect(page).to have_content('JIRA settings saved, but not activated.')
+ it "saves but does not activate the JIRA service" do
+ expect(page).to have_content("JIRA settings saved, but not activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'does not show the JIRA link in the menu' do
- page.within('.nav-sidebar') do
- expect(page).not_to have_link('JIRA', href: url)
+ it "does not show the JIRA link in the menu" do
+ page.within(".nav-sidebar") do
+ expect(page).not_to have_link("JIRA", href: url)
end
end
end
diff --git a/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb b/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb
index 70f3a812ee9..e6bedbef4a2 100644
--- a/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb
+++ b/spec/features/projects/services/user_activates_mattermost_slash_command_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Set up Mattermost slash commands', :js do
+describe "Set up Mattermost slash commands", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:service) { project.create_mattermost_slash_commands_service }
@@ -13,126 +13,126 @@ describe 'Set up Mattermost slash commands', :js do
visit edit_project_service_path(project, service)
end
- describe 'user visits the mattermost slash command config page' do
- it 'shows a help message' do
+ describe "user visits the mattermost slash command config page" do
+ it "shows a help message" do
expect(page).to have_content("This service allows users to perform common")
end
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
+ it "shows a token placeholder" do
+ token_placeholder = find_field("service_token")["placeholder"]
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
+ expect(token_placeholder).to eq("XXxxXXxxXXxxXXxxXXxxXXxx")
end
- it 'redirects to the integrations page after saving but not activating' do
- token = ('a'..'z').to_a.join
+ it "redirects to the integrations page after saving but not activating" do
+ token = ("a".."z").to_a.join
- fill_in 'service_token', with: token
- click_on 'Save changes'
+ fill_in "service_token", with: token
+ click_on "Save changes"
expect(current_path).to eq(project_settings_integrations_path(project))
- expect(page).to have_content('Mattermost slash commands settings saved, but not activated.')
+ expect(page).to have_content("Mattermost slash commands settings saved, but not activated.")
end
- it 'redirects to the integrations page after activating' do
- token = ('a'..'z').to_a.join
+ it "redirects to the integrations page after activating" do
+ token = ("a".."z").to_a.join
- fill_in 'service_token', with: token
- check 'service_active'
- click_on 'Save changes'
+ fill_in "service_token", with: token
+ check "service_active"
+ click_on "Save changes"
expect(current_path).to eq(project_settings_integrations_path(project))
- expect(page).to have_content('Mattermost slash commands activated.')
+ expect(page).to have_content("Mattermost slash commands activated.")
end
- it 'shows the add to mattermost button' do
- expect(page).to have_link('Add to Mattermost')
+ it "shows the add to mattermost button" do
+ expect(page).to have_link("Add to Mattermost")
end
- it 'shows an explanation if user is a member of no teams' do
+ it "shows an explanation if user is a member of no teams" do
stub_teams(count: 0)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(page).to have_content('You aren’t a member of any team on the Mattermost instance')
- expect(page).to have_link('join a team', href: "#{Gitlab.config.mattermost.host}/select_team")
+ expect(page).to have_content("You aren’t a member of any team on the Mattermost instance")
+ expect(page).to have_link("join a team", href: "#{Gitlab.config.mattermost.host}/select_team")
end
- it 'shows an explanation if user is a member of 1 team' do
+ it "shows an explanation if user is a member of 1 team" do
stub_teams(count: 1)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(page).to have_content('The team where the slash commands will be used in')
- expect(page).to have_content('This is the only available team that you are a member of.')
+ expect(page).to have_content("The team where the slash commands will be used in")
+ expect(page).to have_content("This is the only available team that you are a member of.")
end
- it 'shows a disabled prefilled select if user is a member of 1 team' do
+ it "shows a disabled prefilled select if user is a member of 1 team" do
teams = stub_teams(count: 1)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- team_name = teams.first['display_name']
- select_element = find('#mattermost_team_id')
- selected_option = select_element.find('option[selected]')
+ team_name = teams.first["display_name"]
+ select_element = find("#mattermost_team_id")
+ selected_option = select_element.find("option[selected]")
- expect(select_element['disabled']).to eq("true")
+ expect(select_element["disabled"]).to eq("true")
expect(selected_option).to have_content(team_name.to_s)
end
- it 'has a hidden input for the prefilled value if user is a member of 1 team' do
+ it "has a hidden input for the prefilled value if user is a member of 1 team" do
teams = stub_teams(count: 1)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(find('input#mattermost_team_id', visible: false).value).to eq(teams.first['id'])
+ expect(find("input#mattermost_team_id", visible: false).value).to eq(teams.first["id"])
end
- it 'shows an explanation user is a member of multiple teams' do
+ it "shows an explanation user is a member of multiple teams" do
stub_teams(count: 2)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(page).to have_content('Select the team where the slash commands will be used in')
- expect(page).to have_content('The list shows all available teams that you are a member of.')
+ expect(page).to have_content("Select the team where the slash commands will be used in")
+ expect(page).to have_content("The list shows all available teams that you are a member of.")
end
- it 'shows a select with team options user is a member of multiple teams' do
+ it "shows a select with team options user is a member of multiple teams" do
stub_teams(count: 2)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- select_element = find('#mattermost_team_id')
+ select_element = find("#mattermost_team_id")
- expect(select_element['disabled']).to be_falsey
- expect(select_element.all('option').count).to eq(3)
+ expect(select_element["disabled"]).to be_falsey
+ expect(select_element.all("option").count).to eq(3)
end
- it 'shows an error alert with the error message if there is an error requesting teams' do
- allow_any_instance_of(MattermostSlashCommandsService).to receive(:list_teams) { [[], 'test mattermost error message'] }
+ it "shows an error alert with the error message if there is an error requesting teams" do
+ allow_any_instance_of(MattermostSlashCommandsService).to receive(:list_teams) { [[], "test mattermost error message"] }
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(page).to have_selector('.alert')
- expect(page).to have_content('test mattermost error message')
+ expect(page).to have_selector(".alert")
+ expect(page).to have_content("test mattermost error message")
end
- it 'enables the submit button if the required fields are provided', :js do
+ it "enables the submit button if the required fields are provided", :js do
stub_teams(count: 1)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- expect(find('input[type="submit"]')['disabled']).not_to eq("true")
+ expect(find('input[type="submit"]')["disabled"]).not_to eq("true")
end
- it 'disables the submit button if the required fields are not provided', :js do
+ it "disables the submit button if the required fields are not provided", :js do
stub_teams(count: 1)
- click_link 'Add to Mattermost'
+ click_link "Add to Mattermost"
- fill_in('mattermost_trigger', with: '')
+ fill_in("mattermost_trigger", with: "")
- expect(find('input[type="submit"]')['disabled']).to eq("true")
+ expect(find('input[type="submit"]')["disabled"]).to eq("true")
end
def stub_teams(count: 0)
@@ -147,32 +147,32 @@ describe 'Set up Mattermost slash commands', :js do
teams = []
count.times do |i|
- teams.push({ "id" => "x#{i}", "display_name" => "x#{i}-name" })
+ teams.push({"id" => "x#{i}", "display_name" => "x#{i}-name"})
end
teams
end
- describe 'mattermost service is not enabled' do
+ describe "mattermost service is not enabled" do
let(:mattermost_enabled) { false }
- it 'shows the correct trigger url' do
- value = find_field('request_url').value
+ it "shows the correct trigger url" do
+ value = find_field("request_url").value
expect(value).to match("api/v4/projects/#{project.id}/services/mattermost_slash_commands/trigger")
end
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
+ it "shows a token placeholder" do
+ token_placeholder = find_field("service_token")["placeholder"]
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
+ expect(token_placeholder).to eq("XXxxXXxxXXxxXXxxXXxxXXxx")
end
end
end
- describe 'stable logo url' do
- it 'shows a publicly available logo' do
- expect(File.exist?(Rails.root.join('public/slash-command-logo.png')))
+ describe "stable logo url" do
+ it "shows a publicly available logo" do
+ expect(File.exist?(Rails.root.join("public/slash-command-logo.png")))
end
end
end
diff --git a/spec/features/projects/services/user_activates_packagist_spec.rb b/spec/features/projects/services/user_activates_packagist_spec.rb
index 756e9b33c07..218ce398b7b 100644
--- a/spec/features/projects/services/user_activates_packagist_spec.rb
+++ b/spec/features/projects/services/user_activates_packagist_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Packagist' do
+describe "User activates Packagist" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,15 +10,15 @@ describe 'User activates Packagist' do
visit(project_settings_integrations_path(project))
- click_link('Packagist')
+ click_link("Packagist")
end
- it 'activates service' do
- check('Active')
- fill_in('Username', with: 'theUser')
- fill_in('Token', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Username", with: "theUser")
+ fill_in("Token", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('Packagist activated.')
+ expect(page).to have_content("Packagist activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_pivotaltracker_spec.rb b/spec/features/projects/services/user_activates_pivotaltracker_spec.rb
index 1d6b19e0b0c..cc9f5d2c15d 100644
--- a/spec/features/projects/services/user_activates_pivotaltracker_spec.rb
+++ b/spec/features/projects/services/user_activates_pivotaltracker_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates PivotalTracker' do
+describe "User activates PivotalTracker" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe 'User activates PivotalTracker' do
visit(project_settings_integrations_path(project))
- click_link('PivotalTracker')
+ click_link("PivotalTracker")
end
- it 'activates service' do
- check('Active')
- fill_in('Token', with: 'verySecret')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Token", with: "verySecret")
+ click_button("Save")
- expect(page).to have_content('PivotalTracker activated.')
+ expect(page).to have_content("PivotalTracker activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_prometheus_spec.rb b/spec/features/projects/services/user_activates_prometheus_spec.rb
index 61361c8a2e3..74a2f01d9b8 100644
--- a/spec/features/projects/services/user_activates_prometheus_spec.rb
+++ b/spec/features/projects/services/user_activates_prometheus_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Prometheus' do
+describe "User activates Prometheus" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe 'User activates Prometheus' do
visit(project_settings_integrations_path(project))
- click_link('Prometheus')
+ click_link("Prometheus")
end
- it 'activates service' do
- check('Active')
- fill_in('API URL', with: 'http://prometheus.example.com')
- click_button('Save changes')
+ it "activates service" do
+ check("Active")
+ fill_in("API URL", with: "http://prometheus.example.com")
+ click_button("Save changes")
- expect(page).to have_content('Prometheus activated.')
+ expect(page).to have_content("Prometheus activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_pushover_spec.rb b/spec/features/projects/services/user_activates_pushover_spec.rb
index 24612ee1457..b8e8856ca6b 100644
--- a/spec/features/projects/services/user_activates_pushover_spec.rb
+++ b/spec/features/projects/services/user_activates_pushover_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Pushover' do
+describe "User activates Pushover" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -10,18 +10,18 @@ describe 'User activates Pushover' do
visit(project_settings_integrations_path(project))
- click_link('Pushover')
+ click_link("Pushover")
end
- it 'activates service' do
- check('Active')
- fill_in('Api key', with: 'verySecret')
- fill_in('User key', with: 'verySecret')
- fill_in('Device', with: 'myDevice')
- select('High Priority', from: 'Priority')
- select('Bike', from: 'Sound')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Api key", with: "verySecret")
+ fill_in("User key", with: "verySecret")
+ fill_in("Device", with: "myDevice")
+ select("High Priority", from: "Priority")
+ select("Bike", from: "Sound")
+ click_button("Save")
- expect(page).to have_content('Pushover activated.')
+ expect(page).to have_content("Pushover activated.")
end
end
diff --git a/spec/features/projects/services/user_activates_slack_notifications_spec.rb b/spec/features/projects/services/user_activates_slack_notifications_spec.rb
index 24b5d5259db..afcdf68a320 100644
--- a/spec/features/projects/services/user_activates_slack_notifications_spec.rb
+++ b/spec/features/projects/services/user_activates_slack_notifications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates Slack notifications' do
+describe "User activates Slack notifications" do
let(:user) { create(:user) }
let(:service) { SlackService.new }
let(:project) { create(:project, slack_service: service) }
@@ -10,23 +10,23 @@ describe 'User activates Slack notifications' do
sign_in(user)
end
- context 'when service is not configured yet' do
+ context "when service is not configured yet" do
before do
visit(project_settings_integrations_path(project))
- click_link('Slack notifications')
+ click_link("Slack notifications")
end
- it 'activates service' do
- check('Active')
- fill_in('Webhook', with: 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685')
- click_button('Save')
+ it "activates service" do
+ check("Active")
+ fill_in("Webhook", with: "https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685")
+ click_button("Save")
- expect(page).to have_content('Slack notifications activated.')
+ expect(page).to have_content("Slack notifications activated.")
end
end
- context 'when service is already configured' do
+ context "when service is already configured" do
before do
service.fields
service.update(
@@ -36,19 +36,20 @@ describe 'User activates Slack notifications' do
note_channel: 4,
tag_push_channel: 5,
pipeline_channel: 6,
- wiki_page_channel: 7)
+ wiki_page_channel: 7
+ )
visit(edit_project_service_path(project, service))
end
- it 'filters events by channel' do
- expect(page.find_field('service_push_channel').value).to have_content('1')
- expect(page.find_field('service_issue_channel').value).to have_content('2')
- expect(page.find_field('service_merge_request_channel').value).to have_content('3')
- expect(page.find_field('service_note_channel').value).to have_content('4')
- expect(page.find_field('service_tag_push_channel').value).to have_content('5')
- expect(page.find_field('service_pipeline_channel').value).to have_content('6')
- expect(page.find_field('service_wiki_page_channel').value).to have_content('7')
+ it "filters events by channel" do
+ expect(page.find_field("service_push_channel").value).to have_content("1")
+ expect(page.find_field("service_issue_channel").value).to have_content("2")
+ expect(page.find_field("service_merge_request_channel").value).to have_content("3")
+ expect(page.find_field("service_note_channel").value).to have_content("4")
+ expect(page.find_field("service_tag_push_channel").value).to have_content("5")
+ expect(page.find_field("service_pipeline_channel").value).to have_content("6")
+ expect(page.find_field("service_wiki_page_channel").value).to have_content("7")
end
end
end
diff --git a/spec/features/projects/services/user_activates_slack_slash_command_spec.rb b/spec/features/projects/services/user_activates_slack_slash_command_spec.rb
index 08cfddf7993..00afa6f5b28 100644
--- a/spec/features/projects/services/user_activates_slack_slash_command_spec.rb
+++ b/spec/features/projects/services/user_activates_slack_slash_command_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Slack slash commands' do
+describe "Slack slash commands" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:service) { project.create_slack_slash_commands_service }
@@ -11,35 +11,35 @@ describe 'Slack slash commands' do
visit edit_project_service_path(project, service)
end
- it 'shows a token placeholder' do
- token_placeholder = find_field('service_token')['placeholder']
+ it "shows a token placeholder" do
+ token_placeholder = find_field("service_token")["placeholder"]
- expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
+ expect(token_placeholder).to eq("XXxxXXxxXXxxXXxxXXxxXXxx")
end
- it 'shows a help message' do
- expect(page).to have_content('This service allows users to perform common')
+ it "shows a help message" do
+ expect(page).to have_content("This service allows users to perform common")
end
- it 'redirects to the integrations page after saving but not activating' do
- fill_in 'service_token', with: 'token'
- click_on 'Save'
+ it "redirects to the integrations page after saving but not activating" do
+ fill_in "service_token", with: "token"
+ click_on "Save"
expect(current_path).to eq(project_settings_integrations_path(project))
- expect(page).to have_content('Slack slash commands settings saved, but not activated.')
+ expect(page).to have_content("Slack slash commands settings saved, but not activated.")
end
- it 'redirects to the integrations page after activating' do
- fill_in 'service_token', with: 'token'
- check 'service_active'
- click_on 'Save'
+ it "redirects to the integrations page after activating" do
+ fill_in "service_token", with: "token"
+ check "service_active"
+ click_on "Save"
expect(current_path).to eq(project_settings_integrations_path(project))
- expect(page).to have_content('Slack slash commands activated.')
+ expect(page).to have_content("Slack slash commands activated.")
end
- it 'shows the correct trigger url' do
- value = find_field('url').value
+ it "shows the correct trigger url" do
+ value = find_field("url").value
expect(value).to match("api/v4/projects/#{project.id}/services/slack_slash_commands/trigger")
end
end
diff --git a/spec/features/projects/services/user_activates_youtrack_spec.rb b/spec/features/projects/services/user_activates_youtrack_spec.rb
index bb6a030c1cf..01148e9adc2 100644
--- a/spec/features/projects/services/user_activates_youtrack_spec.rb
+++ b/spec/features/projects/services/user_activates_youtrack_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User activates issue tracker', :js do
+describe "User activates issue tracker", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:url) { 'http://tracker.example.com' }
+ let(:url) { "http://tracker.example.com" }
def fill_form(active = true)
- check 'Active' if active
+ check "Active" if active
- fill_in 'service_project_url', with: url
- fill_in 'service_issues_url', with: "#{url}/:id"
+ fill_in "service_project_url", with: url
+ fill_in "service_issues_url", with: "#{url}/:id"
end
before do
@@ -20,43 +20,43 @@ describe 'User activates issue tracker', :js do
visit project_settings_integrations_path(project)
end
- shared_examples 'external issue tracker activation' do |tracker:|
- describe 'user sets and activates the Service' do
- context 'when the connection test succeeds' do
+ shared_examples "external issue tracker activation" do |tracker:|
+ describe "user sets and activates the Service" do
+ context "when the connection test succeeds" do
before do
- stub_request(:head, url).to_return(headers: { 'Content-Type' => 'application/json' })
+ stub_request(:head, url).to_return(headers: {"Content-Type" => "application/json"})
click_link(tracker)
fill_form
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
end
- it 'activates the service' do
+ it "activates the service" do
expect(page).to have_content("#{tracker} activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'shows the link in the menu' do
- page.within('.nav-sidebar') do
+ it "shows the link in the menu" do
+ page.within(".nav-sidebar") do
expect(page).to have_link(tracker, href: url)
end
end
end
- context 'when the connection test fails' do
- it 'activates the service' do
+ context "when the connection test fails" do
+ it "activates the service" do
stub_request(:head, url).to_raise(HTTParty::Error)
click_link(tracker)
fill_form
- click_button('Test settings and save changes')
+ click_button("Test settings and save changes")
wait_for_requests
- expect(find('.flash-container-page')).to have_content 'Test failed.'
- expect(find('.flash-container-page')).to have_content 'Save anyway'
+ expect(find(".flash-container-page")).to have_content "Test failed."
+ expect(find(".flash-container-page")).to have_content "Save anyway"
- find('.flash-alert .flash-action').click
+ find(".flash-alert .flash-action").click
wait_for_requests
expect(page).to have_content("#{tracker} activated.")
@@ -65,25 +65,25 @@ describe 'User activates issue tracker', :js do
end
end
- describe 'user sets the service but keeps it disabled' do
+ describe "user sets the service but keeps it disabled" do
before do
click_link(tracker)
fill_form(false)
- click_button('Save changes')
+ click_button("Save changes")
end
- it 'saves but does not activate the service' do
+ it "saves but does not activate the service" do
expect(page).to have_content("#{tracker} settings saved, but not activated.")
expect(current_path).to eq(project_settings_integrations_path(project))
end
- it 'does not show the external tracker link in the menu' do
- page.within('.nav-sidebar') do
+ it "does not show the external tracker link in the menu" do
+ page.within(".nav-sidebar") do
expect(page).not_to have_link(tracker, href: url)
end
end
end
end
- it_behaves_like 'external issue tracker activation', tracker: 'YouTrack'
+ it_behaves_like "external issue tracker activation", tracker: "YouTrack"
end
diff --git a/spec/features/projects/services/user_views_services_spec.rb b/spec/features/projects/services/user_views_services_spec.rb
index b0a838a7d2b..f8725ec05d8 100644
--- a/spec/features/projects/services/user_views_services_spec.rb
+++ b/spec/features/projects/services/user_views_services_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views services' do
+describe "User views services" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -11,17 +11,17 @@ describe 'User views services' do
visit(project_settings_integrations_path(project))
end
- it 'shows the list of available services' do
- expect(page).to have_content('Project services')
- expect(page).to have_content('Campfire')
- expect(page).to have_content('Assembla')
- expect(page).to have_content('Pushover')
- expect(page).to have_content('Atlassian Bamboo')
- expect(page).to have_content('JetBrains TeamCity')
- expect(page).to have_content('Asana')
- expect(page).to have_content('Irker (IRC gateway)')
- expect(page).to have_content('Packagist')
- expect(page).to have_content('Mattermost')
- expect(page).to have_content('Slack')
+ it "shows the list of available services" do
+ expect(page).to have_content("Project services")
+ expect(page).to have_content("Campfire")
+ expect(page).to have_content("Assembla")
+ expect(page).to have_content("Pushover")
+ expect(page).to have_content("Atlassian Bamboo")
+ expect(page).to have_content("JetBrains TeamCity")
+ expect(page).to have_content("Asana")
+ expect(page).to have_content("Irker (IRC gateway)")
+ expect(page).to have_content("Packagist")
+ expect(page).to have_content("Mattermost")
+ expect(page).to have_content("Slack")
end
end
diff --git a/spec/features/projects/settings/forked_project_settings_spec.rb b/spec/features/projects/settings/forked_project_settings_spec.rb
index dc0278370aa..b56f5f5d582 100644
--- a/spec/features/projects/settings/forked_project_settings_spec.rb
+++ b/spec/features/projects/settings/forked_project_settings_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > For a forked project', :js do
+describe "Projects > Settings > For a forked project", :js do
include ProjectForksHelper
let(:user) { create(:user) }
let(:original_project) { create(:project) }
@@ -13,29 +13,29 @@ describe 'Projects > Settings > For a forked project', :js do
sign_in(user)
end
- shared_examples 'project settings for a forked projects' do
- it 'allows deleting the link to the forked project' do
+ shared_examples "project settings for a forked projects" do
+ it "allows deleting the link to the forked project" do
visit edit_project_path(forked_project)
- click_button 'Remove fork relationship'
+ click_button "Remove fork relationship"
wait_for_requests
- fill_in('confirm_name_input', with: forked_project.name)
- click_button('Confirm')
+ fill_in("confirm_name_input", with: forked_project.name)
+ click_button("Confirm")
- expect(page).to have_content('The fork relationship has been removed.')
+ expect(page).to have_content("The fork relationship has been removed.")
expect(forked_project.reload.forked?).to be_falsy
end
end
- it_behaves_like 'project settings for a forked projects'
+ it_behaves_like "project settings for a forked projects"
- context 'when the original project is deleted' do
+ context "when the original project is deleted" do
before do
original_project.destroy!
end
- it_behaves_like 'project settings for a forked projects'
+ it_behaves_like "project settings for a forked projects"
end
end
diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb
index 32959969f54..393fafe5c2d 100644
--- a/spec/features/projects/settings/integration_settings_spec.rb
+++ b/spec/features/projects/settings/integration_settings_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > Integration settings' do
+describe "Projects > Settings > Integration settings" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :developer }
@@ -11,129 +11,129 @@ describe 'Projects > Settings > Integration settings' do
project.add_role(user, role)
end
- context 'for developer' do
+ context "for developer" do
let(:role) { :developer }
- it 'to be disallowed to view' do
+ it "to be disallowed to view" do
visit integrations_path
expect(page.status_code).to eq(404)
end
end
- context 'for maintainer' do
+ context "for maintainer" do
let(:role) { :maintainer }
- context 'Webhooks' do
+ context "Webhooks" do
let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) }
let(:url) { generate(:url) }
- it 'show list of webhooks' do
+ it "show list of webhooks" do
hook
visit integrations_path
expect(page.status_code).to eq(200)
expect(page).to have_content(hook.url)
- expect(page).to have_content('SSL Verification: enabled')
- expect(page).to have_content('Push events')
- expect(page).to have_content('Tag push events')
- expect(page).to have_content('Issues events')
- expect(page).to have_content('Confidential issues events')
- expect(page).to have_content('Note events')
- expect(page).to have_content('Merge requests events')
- expect(page).to have_content('Pipeline events')
- expect(page).to have_content('Wiki page events')
+ expect(page).to have_content("SSL Verification: enabled")
+ expect(page).to have_content("Push events")
+ expect(page).to have_content("Tag push events")
+ expect(page).to have_content("Issues events")
+ expect(page).to have_content("Confidential issues events")
+ expect(page).to have_content("Note events")
+ expect(page).to have_content("Merge requests events")
+ expect(page).to have_content("Pipeline events")
+ expect(page).to have_content("Wiki page events")
end
- it 'create webhook' do
+ it "create webhook" do
visit integrations_path
- fill_in 'hook_url', with: url
- check 'Tag push events'
- fill_in 'hook_push_events_branch_filter', with: 'master'
- check 'Enable SSL verification'
- check 'Job events'
+ fill_in "hook_url", with: url
+ check "Tag push events"
+ fill_in "hook_push_events_branch_filter", with: "master"
+ check "Enable SSL verification"
+ check "Job events"
- click_button 'Add webhook'
+ click_button "Add webhook"
expect(page).to have_content(url)
- expect(page).to have_content('SSL Verification: enabled')
- expect(page).to have_content('Push events')
- expect(page).to have_content('Tag push events')
- expect(page).to have_content('Job events')
+ expect(page).to have_content("SSL Verification: enabled")
+ expect(page).to have_content("Push events")
+ expect(page).to have_content("Tag push events")
+ expect(page).to have_content("Job events")
end
- it 'edit existing webhook' do
+ it "edit existing webhook" do
hook
visit integrations_path
- click_link 'Edit'
- fill_in 'hook_url', with: url
- check 'Enable SSL verification'
- click_button 'Save changes'
+ click_link "Edit"
+ fill_in "hook_url", with: url
+ check "Enable SSL verification"
+ click_button "Save changes"
- expect(page).to have_content 'SSL Verification: enabled'
+ expect(page).to have_content "SSL Verification: enabled"
expect(page).to have_content(url)
end
- it 'test existing webhook', :js do
+ it "test existing webhook", :js do
WebMock.stub_request(:post, hook.url)
visit integrations_path
- find('.hook-test-button.dropdown').click
- click_link 'Push events'
+ find(".hook-test-button.dropdown").click
+ click_link "Push events"
expect(current_path).to eq(integrations_path)
end
- context 'remove existing webhook' do
- it 'from webhooks list page' do
+ context "remove existing webhook" do
+ it "from webhooks list page" do
hook
visit integrations_path
- expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
+ expect { click_link "Remove" }.to change(ProjectHook, :count).by(-1)
end
- it 'from webhook edit page' do
+ it "from webhook edit page" do
hook
visit integrations_path
- click_link 'Edit'
+ click_link "Edit"
- expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1)
+ expect { click_link "Remove" }.to change(ProjectHook, :count).by(-1)
end
end
end
- context 'Webhook logs' do
+ context "Webhook logs" do
let(:hook) { create(:project_hook, project: project) }
- let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') }
+ let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: "some error") }
- it 'show list of hook logs' do
+ it "show list of hook logs" do
hook_log
visit edit_project_hook_path(project, hook)
- expect(page).to have_content('Recent Deliveries')
+ expect(page).to have_content("Recent Deliveries")
expect(page).to have_content(hook_log.url)
end
- it 'show hook log details' do
+ it "show hook log details" do
hook_log
visit edit_project_hook_path(project, hook)
- click_link 'View details'
+ click_link "View details"
expect(page).to have_content("POST #{hook_log.url}")
expect(page).to have_content(hook_log.internal_error_message)
- expect(page).to have_content('Resend Request')
+ expect(page).to have_content("Resend Request")
end
- it 'retry hook log' do
+ it "retry hook log" do
WebMock.stub_request(:post, hook.url)
hook_log
visit edit_project_hook_path(project, hook)
- click_link 'View details'
- click_link 'Resend Request'
+ click_link "View details"
+ click_link "Resend Request"
expect(current_path).to eq(edit_project_hook_path(project, hook))
end
diff --git a/spec/features/projects/settings/lfs_settings_spec.rb b/spec/features/projects/settings/lfs_settings_spec.rb
index befb306b48d..941b129adbc 100644
--- a/spec/features/projects/settings/lfs_settings_spec.rb
+++ b/spec/features/projects/settings/lfs_settings_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Projects > Settings > LFS settings' do
+describe "Projects > Settings > LFS settings" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:role) { :maintainer }
- context 'LFS enabled setting' do
+ context "LFS enabled setting" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
@@ -13,13 +13,13 @@ describe 'Projects > Settings > LFS settings' do
project.add_role(user, role)
end
- context 'for maintainer' do
+ context "for maintainer" do
let(:role) { :maintainer }
- it 'displays the correct elements', :js do
+ it "displays the correct elements", :js do
visit edit_project_path(project)
- expect(page).to have_content('Git Large File Storage')
+ expect(page).to have_content("Git Large File Storage")
expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true)
end
end
diff --git a/spec/features/projects/settings/operations_settings_spec.rb b/spec/features/projects/settings/operations_settings_spec.rb
index 06290c67c70..97227f7ebea 100644
--- a/spec/features/projects/settings/operations_settings_spec.rb
+++ b/spec/features/projects/settings/operations_settings_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > For a forked project', :js do
+describe "Projects > Settings > For a forked project", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:role) { :maintainer }
@@ -12,8 +12,8 @@ describe 'Projects > Settings > For a forked project', :js do
project.add_role(user, role)
end
- describe 'Sidebar > Operations' do
- it 'renders the settings link in the sidebar' do
+ describe "Sidebar > Operations" do
+ it "renders the settings link in the sidebar" do
visit project_path(project)
wait_for_requests
diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb
index 4c85abe9971..c448049ccd3 100644
--- a/spec/features/projects/settings/pipelines_settings_spec.rb
+++ b/spec/features/projects/settings/pipelines_settings_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Projects > Settings > Pipelines settings" do
let(:project) { create(:project) }
@@ -10,128 +10,128 @@ describe "Projects > Settings > Pipelines settings" do
project.add_role(user, role)
end
- context 'for developer' do
+ context "for developer" do
let(:role) { :developer }
- it 'to be disallowed to view' do
+ it "to be disallowed to view" do
visit project_settings_ci_cd_path(project)
expect(page.status_code).to eq(404)
end
end
- context 'for maintainer' do
+ context "for maintainer" do
let(:role) { :maintainer }
- it 'be allowed to change' do
+ it "be allowed to change" do
visit project_settings_ci_cd_path(project)
- fill_in('Test coverage parsing', with: 'coverage_regex')
+ fill_in("Test coverage parsing", with: "coverage_regex")
- page.within '#js-general-pipeline-settings' do
- click_on 'Save changes'
+ page.within "#js-general-pipeline-settings" do
+ click_on "Save changes"
end
expect(page.status_code).to eq(200)
- page.within '#js-general-pipeline-settings' do
- expect(page).to have_button('Save changes', disabled: false)
+ page.within "#js-general-pipeline-settings" do
+ expect(page).to have_button("Save changes", disabled: false)
end
- expect(page).to have_field('Test coverage parsing', with: 'coverage_regex')
+ expect(page).to have_field("Test coverage parsing", with: "coverage_regex")
end
- it 'updates auto_cancel_pending_pipelines' do
+ it "updates auto_cancel_pending_pipelines" do
visit project_settings_ci_cd_path(project)
- page.check('Auto-cancel redundant, pending pipelines')
- page.within '#js-general-pipeline-settings' do
- click_on 'Save changes'
+ page.check("Auto-cancel redundant, pending pipelines")
+ page.within "#js-general-pipeline-settings" do
+ click_on "Save changes"
end
expect(page.status_code).to eq(200)
- page.within '#js-general-pipeline-settings' do
- expect(page).to have_button('Save changes', disabled: false)
+ page.within "#js-general-pipeline-settings" do
+ expect(page).to have_button("Save changes", disabled: false)
end
- checkbox = find_field('project_auto_cancel_pending_pipelines')
+ checkbox = find_field("project_auto_cancel_pending_pipelines")
expect(checkbox).to be_checked
end
- describe 'Auto DevOps' do
- context 'when auto devops is turned on instance-wide' do
+ describe "Auto DevOps" do
+ context "when auto devops is turned on instance-wide" do
before do
stub_application_setting(auto_devops_enabled: true)
end
- it 'auto devops is on by default and can be manually turned off' do
+ it "auto devops is on by default and can be manually turned off" do
visit project_settings_ci_cd_path(project)
- page.within '#autodevops-settings' do
- expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
- expect(page).to have_content('instance enabled')
- uncheck 'Default to Auto DevOps pipeline'
- click_on 'Save changes'
+ page.within "#autodevops-settings" do
+ expect(find_field("project_auto_devops_attributes_enabled")).to be_checked
+ expect(page).to have_content("instance enabled")
+ uncheck "Default to Auto DevOps pipeline"
+ click_on "Save changes"
end
expect(page.status_code).to eq(200)
expect(project.auto_devops).to be_present
expect(project.auto_devops).not_to be_enabled
- page.within '#autodevops-settings' do
- expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
- expect(page).not_to have_content('instance enabled')
+ page.within "#autodevops-settings" do
+ expect(find_field("project_auto_devops_attributes_enabled")).not_to be_checked
+ expect(page).not_to have_content("instance enabled")
end
end
end
- context 'when auto devops is not turned on instance-wide' do
+ context "when auto devops is not turned on instance-wide" do
before do
stub_application_setting(auto_devops_enabled: false)
end
- it 'auto devops is off by default and can be manually turned on' do
+ it "auto devops is off by default and can be manually turned on" do
visit project_settings_ci_cd_path(project)
- page.within '#autodevops-settings' do
- expect(page).not_to have_content('instance enabled')
- expect(find_field('project_auto_devops_attributes_enabled')).not_to be_checked
- check 'Default to Auto DevOps pipeline'
- click_on 'Save changes'
+ page.within "#autodevops-settings" do
+ expect(page).not_to have_content("instance enabled")
+ expect(find_field("project_auto_devops_attributes_enabled")).not_to be_checked
+ check "Default to Auto DevOps pipeline"
+ click_on "Save changes"
end
expect(page.status_code).to eq(200)
expect(project.auto_devops).to be_present
expect(project.auto_devops).to be_enabled
- page.within '#autodevops-settings' do
- expect(find_field('project_auto_devops_attributes_enabled')).to be_checked
- expect(page).not_to have_content('instance enabled')
+ page.within "#autodevops-settings" do
+ expect(find_field("project_auto_devops_attributes_enabled")).to be_checked
+ expect(page).not_to have_content("instance enabled")
end
end
end
end
- describe 'runners registration token' do
+ describe "runners registration token" do
let!(:token) { project.runners_token }
before do
visit project_settings_ci_cd_path(project)
end
- it 'has a registration token' do
- expect(page.find('#registration_token')).to have_content(token)
+ it "has a registration token" do
+ expect(page.find("#registration_token")).to have_content(token)
end
- describe 'reload registration token' do
- let(:page_token) { find('#registration_token').text }
+ describe "reload registration token" do
+ let(:page_token) { find("#registration_token").text }
before do
- click_button 'Reset runners registration token'
+ click_button "Reset runners registration token"
end
- it 'changes registration token' do
+ it "changes registration token" do
expect(page_token).not_to eq token
end
end
diff --git a/spec/features/projects/settings/project_badges_spec.rb b/spec/features/projects/settings/project_badges_spec.rb
index 42b5547d43b..da4ef3dcfcc 100644
--- a/spec/features/projects/settings/project_badges_spec.rb
+++ b/spec/features/projects/settings/project_badges_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Badges' do
+describe "Project Badges" do
include WaitForRequests
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
- let(:badge_link_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/commits/master'}
- let(:badge_image_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg'}
+ let(:badge_link_url) { "https://gitlab.com/gitlab-org/gitlab-ee/commits/master"}
+ let(:badge_image_url) { "https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg"}
let!(:project_badge) { create(:project_badge, project: project) }
let!(:group_badge) { create(:group_badge, group: group) }
@@ -18,106 +18,106 @@ describe 'Project Badges' do
visit(edit_project_path(project))
end
- it 'shows a list of badges', :js do
- page.within '.badge-settings' do
+ it "shows a list of badges", :js do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
expect(rows[0]).to have_content group_badge.link_url
expect(rows[1]).to have_content project_badge.link_url
end
end
- context 'adding a badge', :js do
- it 'user can preview a badge' do
- page.within '.badge-settings form' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
- within '#badge-preview' do
- expect(find('a')[:href]).to eq badge_link_url
- expect(find('a img')[:src]).to eq badge_image_url
+ context "adding a badge", :js do
+ it "user can preview a badge" do
+ page.within ".badge-settings form" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
+ within "#badge-preview" do
+ expect(find("a")[:href]).to eq badge_link_url
+ expect(find("a img")[:src]).to eq badge_image_url
end
end
end
it do
- page.within '.badge-settings' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
+ page.within ".badge-settings" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
- click_button 'Add badge'
+ click_button "Add badge"
wait_for_requests
- within '.card-body' do
- expect(find('a')[:href]).to eq badge_link_url
- expect(find('a img')[:src]).to eq badge_image_url
+ within ".card-body" do
+ expect(find("a")[:href]).to eq badge_link_url
+ expect(find("a img")[:src]).to eq badge_image_url
end
end
end
end
- context 'editing a badge', :js do
- it 'form is shown when clicking edit button in list' do
- page.within '.badge-settings' do
+ context "editing a badge", :js do
+ it "form is shown when clicking edit button in list" do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
rows[1].find('[aria-label="Edit"]').click
- within 'form' do
- expect(find('#badge-link-url').value).to eq project_badge.link_url
- expect(find('#badge-image-url').value).to eq project_badge.image_url
+ within "form" do
+ expect(find("#badge-link-url").value).to eq project_badge.link_url
+ expect(find("#badge-image-url").value).to eq project_badge.image_url
end
end
end
- it 'updates a badge when submitting the edit form' do
- page.within '.badge-settings' do
+ it "updates a badge when submitting the edit form" do
+ page.within ".badge-settings" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
rows[1].find('[aria-label="Edit"]').click
- within 'form' do
- fill_in 'badge-link-url', with: badge_link_url
- fill_in 'badge-image-url', with: badge_image_url
+ within "form" do
+ fill_in "badge-link-url", with: badge_link_url
+ fill_in "badge-image-url", with: badge_image_url
- click_button 'Save changes'
+ click_button "Save changes"
wait_for_requests
end
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
expect(rows[1]).to have_content badge_link_url
end
end
end
- context 'deleting a badge', :js do
+ context "deleting a badge", :js do
def click_delete_button(badge_row)
badge_row.find('[aria-label="Delete"]').click
end
- it 'shows a modal when deleting a badge' do
+ it "shows a modal when deleting a badge" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
click_delete_button(rows[1])
- expect(find('.modal .modal-title')).to have_content 'Delete badge?'
+ expect(find(".modal .modal-title")).to have_content "Delete badge?"
end
- it 'deletes a badge when confirming the modal' do
+ it "deletes a badge when confirming the modal" do
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 2
click_delete_button(rows[1])
- find('.modal .btn-danger').click
+ find(".modal .btn-danger").click
wait_for_requests
- rows = all('.card-body > div')
+ rows = all(".card-body > div")
expect(rows.length).to eq 1
expect(rows[0]).to have_content group_badge.link_url
end
diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb
index 1259ad45791..ada6f75e418 100644
--- a/spec/features/projects/settings/repository_settings_spec.rb
+++ b/spec/features/projects/settings/repository_settings_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > Repository settings' do
+describe "Projects > Settings > Repository settings" do
let(:project) { create(:project_empty_repo) }
let(:user) { create(:user) }
let(:role) { :developer }
@@ -10,90 +10,90 @@ describe 'Projects > Settings > Repository settings' do
sign_in(user)
end
- context 'for developer' do
+ context "for developer" do
let(:role) { :developer }
- it 'is not allowed to view' do
+ it "is not allowed to view" do
visit project_settings_repository_path(project)
expect(page.status_code).to eq(404)
end
end
- context 'for maintainer' do
+ context "for maintainer" do
let(:role) { :maintainer }
- context 'Deploy Keys', :js do
- let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) }
- let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) }
+ context "Deploy Keys", :js do
+ let(:private_deploy_key) { create(:deploy_key, title: "private_deploy_key", public: false) }
+ let(:public_deploy_key) { create(:another_deploy_key, title: "public_deploy_key", public: true) }
let(:new_ssh_key) { attributes_for(:key)[:key] }
- it 'get list of keys' do
+ it "get list of keys" do
project.deploy_keys << private_deploy_key
project.deploy_keys << public_deploy_key
visit project_settings_repository_path(project)
- expect(page).to have_content('private_deploy_key')
- expect(page).to have_content('public_deploy_key')
+ expect(page).to have_content("private_deploy_key")
+ expect(page).to have_content("public_deploy_key")
end
- it 'add a new deploy key' do
+ it "add a new deploy key" do
visit project_settings_repository_path(project)
- fill_in 'deploy_key_title', with: 'new_deploy_key'
- fill_in 'deploy_key_key', with: new_ssh_key
- check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
- click_button 'Add key'
+ fill_in "deploy_key_title", with: "new_deploy_key"
+ fill_in "deploy_key_key", with: new_ssh_key
+ check "deploy_key_deploy_keys_projects_attributes_0_can_push"
+ click_button "Add key"
- expect(page).to have_content('new_deploy_key')
- expect(page).to have_content('Write access allowed')
+ expect(page).to have_content("new_deploy_key")
+ expect(page).to have_content("Write access allowed")
end
- it 'edit an existing deploy key' do
+ it "edit an existing deploy key" do
project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project)
- find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click
+ find(".deploy-key", text: private_deploy_key.title).find(".ic-pencil").click
- fill_in 'deploy_key_title', with: 'updated_deploy_key'
- check 'deploy_key_deploy_keys_projects_attributes_0_can_push'
- click_button 'Save changes'
+ fill_in "deploy_key_title", with: "updated_deploy_key"
+ check "deploy_key_deploy_keys_projects_attributes_0_can_push"
+ click_button "Save changes"
- expect(page).to have_content('updated_deploy_key')
- expect(page).to have_content('Write access allowed')
+ expect(page).to have_content("updated_deploy_key")
+ expect(page).to have_content("Write access allowed")
end
- it 'edit a deploy key from projects user has access to' do
+ it "edit a deploy key from projects user has access to" do
project2 = create(:project_empty_repo)
project2.add_role(user, role)
project2.deploy_keys << private_deploy_key
visit project_settings_repository_path(project)
- find('.js-deployKeys-tab-available_project_keys').click
+ find(".js-deployKeys-tab-available_project_keys").click
- find('.deploy-key', text: private_deploy_key.title).find('.ic-pencil').click
+ find(".deploy-key", text: private_deploy_key.title).find(".ic-pencil").click
- fill_in 'deploy_key_title', with: 'updated_deploy_key'
- click_button 'Save changes'
+ fill_in "deploy_key_title", with: "updated_deploy_key"
+ click_button "Save changes"
- find('.js-deployKeys-tab-available_project_keys').click
+ find(".js-deployKeys-tab-available_project_keys").click
- expect(page).to have_content('updated_deploy_key')
+ expect(page).to have_content("updated_deploy_key")
end
- it 'remove an existing deploy key' do
+ it "remove an existing deploy key" do
project.deploy_keys << private_deploy_key
visit project_settings_repository_path(project)
- accept_confirm { find('.deploy-key', text: private_deploy_key.title).find('.ic-remove').click }
+ accept_confirm { find(".deploy-key", text: private_deploy_key.title).find(".ic-remove").click }
expect(page).not_to have_content(private_deploy_key.title)
end
end
- context 'Deploy tokens' do
+ context "Deploy tokens" do
let!(:deploy_token) { create(:deploy_token, projects: [project]) }
before do
@@ -101,26 +101,26 @@ describe 'Projects > Settings > Repository settings' do
visit project_settings_repository_path(project)
end
- it 'view deploy tokens' do
- within('.deploy-tokens') do
+ it "view deploy tokens" do
+ within(".deploy-tokens") do
expect(page).to have_content(deploy_token.name)
- expect(page).to have_content('read_repository')
- expect(page).to have_content('read_registry')
+ expect(page).to have_content("read_repository")
+ expect(page).to have_content("read_registry")
end
end
- it 'add a new deploy token' do
- fill_in 'deploy_token_name', with: 'new_deploy_key'
- fill_in 'deploy_token_expires_at', with: (Date.today + 1.month).to_s
- check 'deploy_token_read_repository'
- check 'deploy_token_read_registry'
- click_button 'Create deploy token'
+ it "add a new deploy token" do
+ fill_in "deploy_token_name", with: "new_deploy_key"
+ fill_in "deploy_token_expires_at", with: (Date.today + 1.month).to_s
+ check "deploy_token_read_repository"
+ check "deploy_token_read_registry"
+ click_button "Create deploy token"
- expect(page).to have_content('Your new project deploy token has been created')
+ expect(page).to have_content("Your new project deploy token has been created")
end
end
- context 'remote mirror settings' do
+ context "remote mirror settings" do
let(:user2) { create(:user) }
before do
@@ -129,64 +129,64 @@ describe 'Projects > Settings > Repository settings' do
visit project_settings_repository_path(project)
end
- it 'shows push mirror settings', :js do
- expect(page).to have_selector('#mirror_direction')
+ it "shows push mirror settings", :js do
+ expect(page).to have_selector("#mirror_direction")
end
- it 'creates a push mirror that mirrors all branches', :js do
- expect(find('.js-mirror-protected-hidden', visible: false).value).to eq('0')
+ it "creates a push mirror that mirrors all branches", :js do
+ expect(find(".js-mirror-protected-hidden", visible: false).value).to eq("0")
- fill_in 'url', with: 'ssh://user@localhost/project.git'
- select 'SSH public key', from: 'Authentication method'
+ fill_in "url", with: "ssh://user@localhost/project.git"
+ select "SSH public key", from: "Authentication method"
select_direction
Sidekiq::Testing.fake! do
- click_button 'Mirror repository'
+ click_button "Mirror repository"
end
project.reload
- expect(page).to have_content('Mirroring settings were successfully updated')
+ expect(page).to have_content("Mirroring settings were successfully updated")
expect(project.remote_mirrors.first.only_protected_branches).to eq(false)
end
- it 'creates a push mirror that only mirrors protected branches', :js do
- find('#only_protected_branches').click
+ it "creates a push mirror that only mirrors protected branches", :js do
+ find("#only_protected_branches").click
- expect(find('.js-mirror-protected-hidden', visible: false).value).to eq('1')
+ expect(find(".js-mirror-protected-hidden", visible: false).value).to eq("1")
- fill_in 'url', with: 'ssh://user@localhost/project.git'
- select 'SSH public key', from: 'Authentication method'
+ fill_in "url", with: "ssh://user@localhost/project.git"
+ select "SSH public key", from: "Authentication method"
select_direction
Sidekiq::Testing.fake! do
- click_button 'Mirror repository'
+ click_button "Mirror repository"
end
project.reload
- expect(page).to have_content('Mirroring settings were successfully updated')
+ expect(page).to have_content("Mirroring settings were successfully updated")
expect(project.remote_mirrors.first.only_protected_branches).to eq(true)
end
- it 'generates an SSH public key on submission', :js do
- fill_in 'url', with: 'ssh://user@localhost/project.git'
- select 'SSH public key', from: 'Authentication method'
+ it "generates an SSH public key on submission", :js do
+ fill_in "url", with: "ssh://user@localhost/project.git"
+ select "SSH public key", from: "Authentication method"
select_direction
Sidekiq::Testing.fake! do
- click_button 'Mirror repository'
+ click_button "Mirror repository"
end
- expect(page).to have_content('Mirroring settings were successfully updated')
+ expect(page).to have_content("Mirroring settings were successfully updated")
expect(page).to have_selector('[title="Copy SSH public key"]')
end
- def select_direction(direction = 'push')
- direction_select = find('#mirror_direction')
+ def select_direction(direction = "push")
+ direction_select = find("#mirror_direction")
# In CE, this select box is disabled, but in EE, it is enabled
if direction_select.disabled?
@@ -197,23 +197,23 @@ describe 'Projects > Settings > Repository settings' do
end
end
- context 'repository cleanup settings' do
- let(:object_map_file) { Rails.root.join('spec', 'fixtures', 'bfg_object_map.txt') }
+ context "repository cleanup settings" do
+ let(:object_map_file) { Rails.root.join("spec", "fixtures", "bfg_object_map.txt") }
- it 'uploads an object map file', :js do
+ it "uploads an object map file", :js do
visit project_settings_repository_path(project)
- expect(page).to have_content('Repository cleanup')
+ expect(page).to have_content("Repository cleanup")
- page.within('#cleanup') do
- attach_file('project[bfg_object_map]', object_map_file, visible: false)
+ page.within("#cleanup") do
+ attach_file("project[bfg_object_map]", object_map_file, visible: false)
Sidekiq::Testing.fake! do
- click_button 'Start cleanup'
+ click_button "Start cleanup"
end
end
- expect(page).to have_content('Repository cleanup has started')
+ expect(page).to have_content("Repository cleanup has started")
expect(RepositoryCleanupWorker.jobs.count).to eq(1)
end
end
diff --git a/spec/features/projects/settings/user_archives_project_spec.rb b/spec/features/projects/settings/user_archives_project_spec.rb
index 5008eab4d39..239b2acce78 100644
--- a/spec/features/projects/settings/user_archives_project_spec.rb
+++ b/spec/features/projects/settings/user_archives_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User archives a project' do
+describe "Projects > Settings > User archives a project" do
let(:user) { create(:user) }
before do
@@ -11,27 +11,27 @@ describe 'Projects > Settings > User archives a project' do
visit edit_project_path(project)
end
- context 'when a project is archived' do
+ context "when a project is archived" do
let(:project) { create(:project, :archived, namespace: user.namespace) }
- it 'unarchives a project' do
- expect(page).to have_content('Unarchive project')
+ it "unarchives a project" do
+ expect(page).to have_content("Unarchive project")
- click_link('Unarchive')
+ click_link("Unarchive")
- expect(page).not_to have_content('Archived project')
+ expect(page).not_to have_content("Archived project")
end
end
- context 'when a project is unarchived' do
+ context "when a project is unarchived" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- it 'archives a project' do
- expect(page).to have_content('Archive project')
+ it "archives a project" do
+ expect(page).to have_content("Archive project")
- click_link('Archive')
+ click_link("Archive")
- expect(page).to have_content('Archived')
+ expect(page).to have_content("Archived")
end
end
end
diff --git a/spec/features/projects/settings/user_changes_avatar_spec.rb b/spec/features/projects/settings/user_changes_avatar_spec.rb
index 64335163016..268b635cdb1 100644
--- a/spec/features/projects/settings/user_changes_avatar_spec.rb
+++ b/spec/features/projects/settings/user_changes_avatar_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User changes avatar' do
+describe "Projects > Settings > User changes avatar" do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
@@ -9,7 +9,7 @@ describe 'Projects > Settings > User changes avatar' do
sign_in(user)
end
- it 'saves the new avatar' do
+ it "saves the new avatar" do
expect(project.reload.avatar.url).to be_nil
save_avatar(project)
@@ -17,15 +17,15 @@ describe 'Projects > Settings > User changes avatar' do
expect(project.reload.avatar.url).to eq "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif"
end
- context 'with an avatar already set' do
+ context "with an avatar already set" do
before do
save_avatar(project)
end
- it 'is possible to remove the avatar' do
- click_link 'Remove avatar'
+ it "is possible to remove the avatar" do
+ click_link "Remove avatar"
- expect(page).not_to have_link('Remove avatar')
+ expect(page).not_to have_link("Remove avatar")
expect(project.reload.avatar.url).to be_nil
end
@@ -35,10 +35,10 @@ describe 'Projects > Settings > User changes avatar' do
visit edit_project_path(project)
attach_file(
:project_avatar,
- File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif')
+ File.join(Rails.root, "spec", "fixtures", "banana_sample.gif")
)
- page.within '.general-settings' do
- click_button 'Save changes'
+ page.within ".general-settings" do
+ click_button "Save changes"
end
end
end
diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb
index 7dc18601f50..5ff5d31e638 100644
--- a/spec/features/projects/settings/user_changes_default_branch_spec.rb
+++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User changes default branch' do
+describe "Projects > Settings > User changes default branch" do
include Select2Helper
let(:user) { create(:user) }
@@ -11,28 +11,28 @@ describe 'Projects > Settings > User changes default branch' do
visit project_settings_repository_path(project)
end
- context 'with normal project' do
+ context "with normal project" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- it 'allows to change the default branch', :js do
+ it "allows to change the default branch", :js do
# Otherwise, running JS may overwrite our change to project_default_branch
wait_for_requests
- select2('fix', from: '#project_default_branch')
+ select2("fix", from: "#project_default_branch")
- page.within '#default-branch-settings' do
- click_button 'Save changes'
+ page.within "#default-branch-settings" do
+ click_button "Save changes"
end
- expect(find('#project_default_branch', visible: false).value).to eq 'fix'
+ expect(find("#project_default_branch", visible: false).value).to eq "fix"
end
end
- context 'with empty project' do
+ context "with empty project" do
let(:project) { create(:project_empty_repo, namespace: user.namespace) }
- it 'does not show default branch selector' do
- expect(page).not_to have_selector('#project_default_branch')
+ it "does not show default branch selector" do
+ expect(page).not_to have_selector("#project_default_branch")
end
end
end
diff --git a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb
index ecfb49b9efe..1c28e83eb02 100644
--- a/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb
+++ b/spec/features/projects/settings/user_interacts_with_deploy_keys_spec.rb
@@ -57,7 +57,7 @@ describe "User interacts with deploy keys", :js do
visit(project_deploy_keys_path(project))
page.within(".deploy-keys") do
- find('.js-deployKeys-tab-available_project_keys').click
+ find(".js-deployKeys-tab-available_project_keys").click
expect(page).to have_content(deploy_key.title)
expect(find(".js-deployKeys-tab-available_project_keys .badge")).to have_content("1")
diff --git a/spec/features/projects/settings/user_manages_group_links_spec.rb b/spec/features/projects/settings/user_manages_group_links_spec.rb
index 676659b90c3..c983a93d675 100644
--- a/spec/features/projects/settings/user_manages_group_links_spec.rb
+++ b/spec/features/projects/settings/user_manages_group_links_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User manages group links' do
+describe "Projects > Settings > User manages group links" do
include Select2Helper
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- let(:group_ops) { create(:group, name: 'Ops') }
- let(:group_market) { create(:group, name: 'Market', path: 'market') }
+ let(:group_ops) { create(:group, name: "Ops") }
+ let(:group_market) { create(:group, name: "Market", path: "market") }
before do
project.add_maintainer(user)
@@ -19,23 +19,23 @@ describe 'Projects > Settings > User manages group links' do
visit(project_group_links_path(project))
end
- it 'shows a list of groups' do
- page.within('.project-members-groups') do
- expect(page).to have_content('Ops')
- expect(page).not_to have_content('Market')
+ it "shows a list of groups" do
+ page.within(".project-members-groups") do
+ expect(page).to have_content("Ops")
+ expect(page).not_to have_content("Market")
end
end
- it 'invites a group to a project', :js do
- click_link('Invite group')
+ it "invites a group to a project", :js do
+ click_link("Invite group")
- select2(group_market.id, from: '#link_group_id')
- select('Maintainer', from: 'link_group_access')
+ select2(group_market.id, from: "#link_group_id")
+ select("Maintainer", from: "link_group_access")
- click_button('Invite')
+ click_button("Invite")
- page.within('.project-members-groups') do
- expect(page).to have_content('Market')
+ page.within(".project-members-groups") do
+ expect(page).to have_content("Market")
end
end
end
diff --git a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
index 84de6858d5f..9f4d4e863e8 100644
--- a/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
+++ b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User manages merge request settings' do
+describe "Projects > Settings > User manages merge request settings" do
let(:user) { create(:user) }
- let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') }
+ let(:project) { create(:project, :public, namespace: user.namespace, path: "gitlab", name: "sample") }
before do
sign_in(user)
@@ -10,94 +10,94 @@ describe 'Projects > Settings > User manages merge request settings' do
end
it 'shows "Merge commit" strategy' do
- page.within '#js-merge-request-settings' do
- expect(page).to have_content 'Merge commit'
+ page.within "#js-merge-request-settings" do
+ expect(page).to have_content "Merge commit"
end
end
it 'shows "Merge commit with semi-linear history " strategy' do
- page.within '#js-merge-request-settings' do
- expect(page).to have_content 'Merge commit with semi-linear history'
+ page.within "#js-merge-request-settings" do
+ expect(page).to have_content "Merge commit with semi-linear history"
end
end
it 'shows "Fast-forward merge" strategy' do
- page.within '#js-merge-request-settings' do
- expect(page).to have_content 'Fast-forward merge'
+ page.within "#js-merge-request-settings" do
+ expect(page).to have_content "Fast-forward merge"
end
end
- context 'when Merge Request and Pipelines are initially enabled', :js do
- context 'when Pipelines are initially enabled' do
- it 'shows the Merge Requests settings' do
- expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ context "when Merge Request and Pipelines are initially enabled", :js do
+ context "when Pipelines are initially enabled" do
+ it "shows the Merge Requests settings" do
+ expect(page).to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).to have_content("Only allow merge requests to be merged if all discussions are resolved")
- within('.sharing-permissions-form') do
+ within(".sharing-permissions-form") do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end
- expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ expect(page).not_to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).not_to have_content("Only allow merge requests to be merged if all discussions are resolved")
end
end
- context 'when Pipelines are initially disabled', :js do
+ context "when Pipelines are initially disabled", :js do
before do
- project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED)
+ project.project_feature.update_attribute("builds_access_level", ProjectFeature::DISABLED)
visit edit_project_path(project)
end
- it 'shows the Merge Requests settings that do not depend on Builds feature' do
- expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ it "shows the Merge Requests settings that do not depend on Builds feature" do
+ expect(page).not_to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).to have_content("Only allow merge requests to be merged if all discussions are resolved")
- within('.sharing-permissions-form') do
+ within(".sharing-permissions-form") do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end
- expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ expect(page).to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).to have_content("Only allow merge requests to be merged if all discussions are resolved")
end
end
end
- context 'when Merge Request are initially disabled', :js do
+ context "when Merge Request are initially disabled", :js do
before do
- project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED)
+ project.project_feature.update_attribute("merge_requests_access_level", ProjectFeature::DISABLED)
visit edit_project_path(project)
end
- it 'does not show the Merge Requests settings' do
- expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ it "does not show the Merge Requests settings" do
+ expect(page).not_to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).not_to have_content("Only allow merge requests to be merged if all discussions are resolved")
- within('.sharing-permissions-form') do
+ within(".sharing-permissions-form") do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
find('input[value="Save changes"]').send_keys(:return)
end
- expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds')
- expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved')
+ expect(page).to have_content("Only allow merge requests to be merged if the pipeline succeeds")
+ expect(page).to have_content("Only allow merge requests to be merged if all discussions are resolved")
end
end
- describe 'Checkbox to enable merge request link', :js do
- it 'is initially checked' do
- checkbox = find_field('project_printing_merge_request_link_enabled')
+ describe "Checkbox to enable merge request link", :js do
+ it "is initially checked" do
+ checkbox = find_field("project_printing_merge_request_link_enabled")
expect(checkbox).to be_checked
end
- it 'when unchecked sets :printing_merge_request_link_enabled to false' do
- uncheck('project_printing_merge_request_link_enabled')
- within('.merge-request-settings-form') do
- click_on('Save changes')
+ it "when unchecked sets :printing_merge_request_link_enabled to false" do
+ uncheck("project_printing_merge_request_link_enabled")
+ within(".merge-request-settings-form") do
+ click_on("Save changes")
end
# Wait for save to complete and page to reload
- checkbox = find_field('project_printing_merge_request_link_enabled')
+ checkbox = find_field("project_printing_merge_request_link_enabled")
expect(checkbox).not_to be_checked
project.reload
diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb
index b8ca11d53f0..851fe5d8394 100644
--- a/spec/features/projects/settings/user_manages_project_members_spec.rb
+++ b/spec/features/projects/settings/user_manages_project_members_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User manages project members' do
- let(:group) { create(:group, name: 'OpenSource') }
+describe "Projects > Settings > User manages project members" do
+ let(:group) { create(:group, name: "OpenSource") }
let(:project) { create(:project) }
let(:project2) { create(:project) }
let(:user) { create(:user) }
- let(:user_dmitriy) { create(:user, name: 'Dmitriy') }
- let(:user_mike) { create(:user, name: 'Mike') }
+ let(:user_dmitriy) { create(:user, name: "Dmitriy") }
+ let(:user_mike) { create(:user, name: "Mike") }
before do
project.add_maintainer(user)
@@ -14,13 +14,13 @@ describe 'Projects > Settings > User manages project members' do
sign_in(user)
end
- it 'cancels a team member' do
+ it "cancels a team member" do
visit(project_project_members_path(project))
project_member = project.project_members.find_by(user_id: user_dmitriy.id)
page.within("#project_member_#{project_member.id}") do
- click_link('Remove user from project')
+ click_link("Remove user from project")
end
visit(project_project_members_path(project))
@@ -29,28 +29,28 @@ describe 'Projects > Settings > User manages project members' do
expect(page).not_to have_content(user_dmitriy.username)
end
- it 'imports a team from another project' do
+ it "imports a team from another project" do
project2.add_maintainer(user)
project2.add_reporter(user_mike)
visit(project_project_members_path(project))
- page.within('.users-project-form') do
- click_link('Import')
+ page.within(".users-project-form") do
+ click_link("Import")
end
- select(project2.full_name, from: 'source_project_id')
- click_button('Import')
+ select(project2.full_name, from: "source_project_id")
+ click_button("Import")
project_member = project.project_members.find_by(user_id: user_mike.id)
page.within("#project_member_#{project_member.id}") do
- expect(page).to have_content('Mike')
- expect(page).to have_content('Reporter')
+ expect(page).to have_content("Mike")
+ expect(page).to have_content("Reporter")
end
end
- it 'shows all members of project shared group' do
+ it "shows all members of project shared group" do
group.add_owner(user)
group.add_developer(user_dmitriy)
@@ -60,9 +60,9 @@ describe 'Projects > Settings > User manages project members' do
visit(project_project_members_path(project))
- page.within('.project-members-groups') do
- expect(page).to have_content('OpenSource')
- expect(first('.group_member')).to have_content('Maintainer')
+ page.within(".project-members-groups") do
+ expect(page).to have_content("OpenSource")
+ expect(first(".group_member")).to have_content("Maintainer")
end
end
end
diff --git a/spec/features/projects/settings/user_renames_a_project_spec.rb b/spec/features/projects/settings/user_renames_a_project_spec.rb
index 64c9af4b706..d348226ec0e 100644
--- a/spec/features/projects/settings/user_renames_a_project_spec.rb
+++ b/spec/features/projects/settings/user_renames_a_project_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User renames a project' do
+describe "Projects > Settings > User renames a project" do
let(:user) { create(:user) }
- let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') }
+ let(:project) { create(:project, namespace: user.namespace, path: "gitlab", name: "sample") }
before do
sign_in(user)
@@ -10,53 +10,53 @@ describe 'Projects > Settings > User renames a project' do
end
def rename_project(project, name: nil, path: nil)
- fill_in('project_name', with: name) if name
- fill_in('Path', with: path) if path
- click_button('Rename project')
+ fill_in("project_name", with: name) if name
+ fill_in("Path", with: path) if path
+ click_button("Rename project")
wait_for_edit_project_page_reload
project.reload
end
def wait_for_edit_project_page_reload
- expect(find('.project-edit-container')).to have_content('Rename repository')
+ expect(find(".project-edit-container")).to have_content("Rename repository")
end
- context 'with invalid characters' do
- it 'shows errors for invalid project path/name' do
- rename_project(project, name: 'foo&bar', path: 'foo&bar')
- expect(page).to have_field 'Project name', with: 'foo&bar'
- expect(page).to have_field 'Path', with: 'foo&bar'
+ context "with invalid characters" do
+ it "shows errors for invalid project path/name" do
+ rename_project(project, name: "foo&bar", path: "foo&bar")
+ expect(page).to have_field "Project name", with: "foo&bar"
+ expect(page).to have_field "Path", with: "foo&bar"
expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'"
end
end
- it 'shows a successful notice when the project is updated' do
- fill_in 'project_name_edit', with: 'hello world'
- page.within('.general-settings') do
- click_button 'Save changes'
+ it "shows a successful notice when the project is updated" do
+ fill_in "project_name_edit", with: "hello world"
+ page.within(".general-settings") do
+ click_button "Save changes"
end
expect(page).to have_content "Project 'hello world' was successfully updated."
end
- context 'when changing project name' do
- it 'renames the repository' do
- rename_project(project, name: 'bar')
- expect(find('.breadcrumbs')).to have_content(project.name)
+ context "when changing project name" do
+ it "renames the repository" do
+ rename_project(project, name: "bar")
+ expect(find(".breadcrumbs")).to have_content(project.name)
end
- context 'with emojis' do
- it 'shows error for invalid project name' do
- rename_project(project, name: '🚀 foo bar ☁️')
- expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️'
+ context "with emojis" do
+ it "shows error for invalid project name" do
+ rename_project(project, name: "🚀 foo bar ☁️")
+ expect(page).to have_field "Project name", with: "🚀 foo bar ☁️"
expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'."
end
end
end
- context 'when changing project path' do
- let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') }
+ context "when changing project path" do
+ let(:project) { create(:project, :repository, namespace: user.namespace, name: "gitlabhq") }
before(:context) do
TestEnv.clean_test_path
@@ -66,34 +66,34 @@ describe 'Projects > Settings > User renames a project' do
TestEnv.clean_test_path
end
- it 'the project is accessible via the new path' do
- rename_project(project, path: 'bar')
- new_path = namespace_project_path(project.namespace, 'bar')
+ it "the project is accessible via the new path" do
+ rename_project(project, path: "bar")
+ new_path = namespace_project_path(project.namespace, "bar")
visit new_path
expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
+ expect(find(".breadcrumbs")).to have_content(project.name)
end
- it 'the project is accessible via a redirect from the old path' do
+ it "the project is accessible via a redirect from the old path" do
old_path = project_path(project)
- rename_project(project, path: 'bar')
- new_path = namespace_project_path(project.namespace, 'bar')
+ rename_project(project, path: "bar")
+ new_path = namespace_project_path(project.namespace, "bar")
visit old_path
expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
+ expect(find(".breadcrumbs")).to have_content(project.name)
end
- context 'and a new project is added with the same path' do
- it 'overrides the redirect' do
+ context "and a new project is added with the same path" do
+ it "overrides the redirect" do
old_path = project_path(project)
- rename_project(project, path: 'bar')
- new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz')
+ rename_project(project, path: "bar")
+ new_project = create(:project, namespace: user.namespace, path: "gitlabhq", name: "quz")
visit old_path
expect(current_path).to eq(old_path)
- expect(find('.breadcrumbs')).to have_content(new_project.name)
+ expect(find(".breadcrumbs")).to have_content(new_project.name)
end
end
end
diff --git a/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb b/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb
index 069704a1305..33a110a979e 100644
--- a/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb
+++ b/spec/features/projects/settings/user_sees_revoke_deploy_token_modal_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Repository Settings > User sees revoke deploy token modal', :js do
+describe "Repository Settings > User sees revoke deploy token modal", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:role) { :developer }
@@ -10,16 +10,16 @@ describe 'Repository Settings > User sees revoke deploy token modal', :js do
project.add_role(user, role)
sign_in(user)
visit(project_settings_repository_path(project))
- click_link('Revoke')
+ click_link("Revoke")
end
- it 'shows the revoke deploy token modal' do
- expect(page).to have_content('You are about to revoke')
+ it "shows the revoke deploy token modal" do
+ expect(page).to have_content("You are about to revoke")
end
- it 'closes the revoke deploy token modal with escape keypress' do
- find('.modal.show').send_keys(:escape)
+ it "closes the revoke deploy token modal with escape keypress" do
+ find(".modal.show").send_keys(:escape)
- expect(page).not_to have_content('You are about to revoke')
+ expect(page).not_to have_content("You are about to revoke")
end
end
diff --git a/spec/features/projects/settings/user_tags_project_spec.rb b/spec/features/projects/settings/user_tags_project_spec.rb
index e3f06c042b9..7d60ee811cc 100644
--- a/spec/features/projects/settings/user_tags_project_spec.rb
+++ b/spec/features/projects/settings/user_tags_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User tags a project' do
+describe "Projects > Settings > User tags a project" do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -9,13 +9,13 @@ describe 'Projects > Settings > User tags a project' do
visit edit_project_path(project)
end
- it 'sets project topics' do
- fill_in 'Topics', with: 'topic1, topic2'
+ it "sets project topics" do
+ fill_in "Topics", with: "topic1, topic2"
- page.within '.general-settings' do
- click_button 'Save changes'
+ page.within ".general-settings" do
+ click_button "Save changes"
end
- expect(find_field('Topics').value).to eq 'topic1, topic2'
+ expect(find_field("Topics").value).to eq "topic1, topic2"
end
end
diff --git a/spec/features/projects/settings/user_transfers_a_project_spec.rb b/spec/features/projects/settings/user_transfers_a_project_spec.rb
index 2fdbc04fa62..007dbca11bd 100644
--- a/spec/features/projects/settings/user_transfers_a_project_spec.rb
+++ b/spec/features/projects/settings/user_transfers_a_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > User transfers a project', :js do
+describe "Projects > Settings > User transfers a project", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:group) { create(:group) }
@@ -13,29 +13,29 @@ describe 'Projects > Settings > User transfers a project', :js do
def transfer_project(project, group, confirm: true)
visit edit_project_path(project)
- page.within('.js-project-transfer-form') do
- page.find('.select2-container').click
+ page.within(".js-project-transfer-form") do
+ page.find(".select2-container").click
end
page.find("div[role='option']", text: group.full_name).click
- click_button('Transfer project')
+ click_button("Transfer project")
return unless confirm
- fill_in 'confirm_name_input', with: project.name
+ fill_in "confirm_name_input", with: project.name
- click_button 'Confirm'
+ click_button "Confirm"
wait_for_requests
end
- it 'focuses on the confirmation field' do
+ it "focuses on the confirmation field" do
transfer_project(project, group, confirm: false)
- expect(page).to have_selector '#confirm_name_input:focus'
+ expect(page).to have_selector "#confirm_name_input:focus"
end
- it 'allows transferring a project to a group' do
+ it "allows transferring a project to a group" do
old_path = project_path(project)
transfer_project(project, group)
new_path = namespace_project_path(group, project)
@@ -46,17 +46,17 @@ describe 'Projects > Settings > User transfers a project', :js do
wait_for_requests
expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
+ expect(find(".breadcrumbs")).to have_content(project.name)
visit old_path
wait_for_requests
expect(current_path).to eq(new_path)
- expect(find('.breadcrumbs')).to have_content(project.name)
+ expect(find(".breadcrumbs")).to have_content(project.name)
end
- context 'and a new project is added with the same path' do
- it 'overrides the redirect' do
+ context "and a new project is added with the same path" do
+ it "overrides the redirect" do
old_path = project_path(project)
project_path = project.path
transfer_project(project, group)
@@ -64,12 +64,12 @@ describe 'Projects > Settings > User transfers a project', :js do
visit old_path
expect(current_path).to eq(old_path)
- expect(find('.breadcrumbs')).to have_content(new_project.name)
+ expect(find(".breadcrumbs")).to have_content(new_project.name)
end
end
- context 'when nested groups are available', :nested_groups do
- it 'allows transferring a project to a subgroup' do
+ context "when nested groups are available", :nested_groups do
+ it "allows transferring a project to a subgroup" do
subgroup = create(:group, parent: group)
transfer_project(project, subgroup)
diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb
index 1fbc108697f..da01c35f81a 100644
--- a/spec/features/projects/settings/visibility_settings_spec.rb
+++ b/spec/features/projects/settings/visibility_settings_spec.rb
@@ -1,65 +1,65 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Settings > Visibility settings', :js do
+describe "Projects > Settings > Visibility settings", :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) }
- context 'as owner' do
+ context "as owner" do
before do
sign_in(user)
visit edit_project_path(project)
end
- it 'project visibility select is available' do
- visibility_select_container = find('.project-visibility-setting')
+ it "project visibility select is available" do
+ visibility_select_container = find(".project-visibility-setting")
- expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s
- expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
+ expect(visibility_select_container.find("select").value).to eq project.visibility_level.to_s
+ expect(visibility_select_container).to have_content "The project can be accessed by anyone, regardless of authentication."
end
- it 'project visibility description updates on change' do
- visibility_select_container = find('.project-visibility-setting')
- visibility_select = visibility_select_container.find('select')
- visibility_select.select('Private')
+ it "project visibility description updates on change" do
+ visibility_select_container = find(".project-visibility-setting")
+ visibility_select = visibility_select_container.find("select")
+ visibility_select.select("Private")
- expect(visibility_select.value).to eq '0'
- expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.'
+ expect(visibility_select.value).to eq "0"
+ expect(visibility_select_container).to have_content "Access must be granted explicitly to each user."
end
- context 'merge requests select' do
- it 'hides merge requests section' do
+ context "merge requests select" do
+ it "hides merge requests section" do
find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click
- expect(page).to have_selector('.merge-requests-feature', visible: false)
+ expect(page).to have_selector(".merge-requests-feature", visible: false)
end
- context 'given project with merge_requests_disabled access level' do
+ context "given project with merge_requests_disabled access level" do
let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) }
- it 'hides merge requests section' do
- expect(page).to have_selector('.merge-requests-feature', visible: false)
+ it "hides merge requests section" do
+ expect(page).to have_selector(".merge-requests-feature", visible: false)
end
end
end
- context 'builds select' do
- it 'hides builds select section' do
+ context "builds select" do
+ it "hides builds select section" do
find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click
- expect(page).to have_selector('.builds-feature', visible: false)
+ expect(page).to have_selector(".builds-feature", visible: false)
end
- context 'given project with builds_disabled access level' do
+ context "given project with builds_disabled access level" do
let(:project) { create(:project, :builds_disabled, namespace: user.namespace) }
- it 'hides builds select section' do
- expect(page).to have_selector('.builds-feature', visible: false)
+ it "hides builds select section" do
+ expect(page).to have_selector(".builds-feature", visible: false)
end
end
end
end
- context 'as maintainer' do
+ context "as maintainer" do
let(:maintainer_user) { create(:user) }
before do
@@ -68,11 +68,11 @@ describe 'Projects > Settings > Visibility settings', :js do
visit edit_project_path(project)
end
- it 'project visibility is locked' do
- visibility_select_container = find('.project-visibility-setting')
+ it "project visibility is locked" do
+ visibility_select_container = find(".project-visibility-setting")
expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled'
- expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.'
+ expect(visibility_select_container).to have_content "The project can be accessed by anyone, regardless of authentication."
end
end
end
diff --git a/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb
index 8ba91fe7fd7..989079d6d15 100644
--- a/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb
+++ b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Projects > Show > Developer views empty project instructions' do
+describe "Projects > Show > Developer views empty project instructions" do
let(:project) { create(:project, :empty_repo) }
let(:developer) { create(:user) }
diff --git a/spec/features/projects/show/download_buttons_spec.rb b/spec/features/projects/show/download_buttons_spec.rb
index 3a2dcc5aa55..df1ecb57f47 100644
--- a/spec/features/projects/show/download_buttons_spec.rb
+++ b/spec/features/projects/show/download_buttons_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > Download buttons' do
+describe "Projects > Show > Download buttons" do
let(:user) { create(:user) }
let(:role) { :developer }
- let(:status) { 'success' }
+ let(:status) { "success" }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit.sha,
- ref: project.default_branch,
- status: status)
+ project: project,
+ sha: project.commit.sha,
+ ref: project.default_branch,
+ status: status)
end
let!(:build) do
create(:ci_build, :success, :artifacts,
- pipeline: pipeline,
- status: pipeline.status,
- name: 'build')
+ pipeline: pipeline,
+ status: pipeline.status,
+ name: "build")
end
before do
@@ -26,22 +26,22 @@ describe 'Projects > Show > Download buttons' do
project.add_role(user, role)
end
- describe 'when checking project main page' do
- context 'with artifacts' do
+ describe "when checking project main page" do
+ context "with artifacts" do
before do
visit project_path(project)
end
- it 'shows download artifacts button' do
- href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build')
+ it "shows download artifacts button" do
+ href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: "build")
expect(page).to have_link "Download '#{build.name}'", href: href
end
- it 'download links have download attribute' do
- expect(page).to have_selector('a', text: 'Download')
- page.all('a', text: 'Download').each do |link|
- expect(link[:download]).to eq ''
+ it "download links have download attribute" do
+ expect(page).to have_selector("a", text: "Download")
+ page.all("a", text: "Download").each do |link|
+ expect(link[:download]).to eq ""
end
end
end
diff --git a/spec/features/projects/show/no_password_spec.rb b/spec/features/projects/show/no_password_spec.rb
index 8259d482fd9..f76ee814a81 100644
--- a/spec/features/projects/show/no_password_spec.rb
+++ b/spec/features/projects/show/no_password_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'No Password Alert' do
+describe "No Password Alert" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- context 'with internal auth enabled' do
+ context "with internal auth enabled" do
before do
sign_in(user)
visit project_path(project)
end
- context 'when user has a password' do
+ context "when user has a password" do
let(:user) { create(:user) }
- it 'shows no alert' do
+ it "shows no alert" do
expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account"
end
end
- context 'when user has password automatically set' do
+ context "when user has password automatically set" do
let(:user) { create(:user, password_automatically_set: true) }
- it 'shows a password alert' do
+ it "shows a password alert" do
expect(page).to have_content "You won't be able to pull or push project code via HTTP until you set a password on your account"
end
end
end
- context 'with internal auth disabled' do
- let(:user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'saml') }
+ context "with internal auth disabled" do
+ let(:user) { create(:omniauth_user, extern_uid: "my-uid", provider: "saml") }
before do
stub_application_setting(password_authentication_enabled_for_git?: false)
- stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config])
+ stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"], providers: [mock_saml_config])
end
- context 'when user has no personal access tokens' do
- it 'has a personal access token alert' do
- gitlab_sign_in_via('saml', user, 'my-uid')
+ context "when user has no personal access tokens" do
+ it "has a personal access token alert" do
+ gitlab_sign_in_via("saml", user, "my-uid")
visit project_path(project)
expect(page).to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account"
end
end
- context 'when user has a personal access token' do
- it 'shows no alert' do
+ context "when user has a personal access token" do
+ it "shows no alert" do
create(:personal_access_token, user: user)
- gitlab_sign_in_via('saml', user, 'my-uid')
+ gitlab_sign_in_via("saml", user, "my-uid")
visit project_path(project)
expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account"
@@ -54,7 +54,7 @@ describe 'No Password Alert' do
end
end
- context 'when user is ldap user' do
+ context "when user is ldap user" do
let(:user) { create(:omniauth_user, password_automatically_set: true) }
before do
@@ -62,7 +62,7 @@ describe 'No Password Alert' do
visit project_path(project)
end
- it 'shows no alert' do
+ it "shows no alert" do
expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you"
end
end
diff --git a/spec/features/projects/show/redirects_spec.rb b/spec/features/projects/show/redirects_spec.rb
index 8d41c547d77..34c088280a7 100644
--- a/spec/features/projects/show/redirects_spec.rb
+++ b/spec/features/projects/show/redirects_spec.rb
@@ -1,71 +1,71 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > Redirects' do
+describe "Projects > Show > Redirects" do
let(:user) { create :user }
let(:public_project) { create :project, :public }
let(:private_project) { create :project, :private }
before do
- allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com')
+ allow(Gitlab.config.gitlab).to receive(:host).and_return("www.example.com")
end
- it 'shows public project page' do
+ it "shows public project page" do
visit project_path(public_project)
- page.within '.breadcrumbs .breadcrumb-item-text' do
+ page.within ".breadcrumbs .breadcrumb-item-text" do
expect(page).to have_content(public_project.name)
end
end
- it 'redirects to sign in page when project is private' do
+ it "redirects to sign in page when project is private" do
visit project_path(private_project)
expect(current_path).to eq(new_user_session_path)
end
- it 'redirects to sign in page when project does not exist' do
+ it "redirects to sign in page when project does not exist" do
visit project_path(build(:project, :public))
expect(current_path).to eq(new_user_session_path)
end
- it 'redirects to public project page after signing in' do
+ it "redirects to public project page after signing in" do
visit project_path(public_project)
- first(:link, 'Sign in').click
+ first(:link, "Sign in").click
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: user.password
- click_button 'Sign in'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: user.password
+ click_button "Sign in"
expect(status_code).to eq(200)
expect(current_path).to eq("/#{public_project.full_path}")
end
- it 'redirects to private project page after sign in' do
+ it "redirects to private project page after sign in" do
visit project_path(private_project)
owner = private_project.owner
- fill_in 'user_login', with: owner.email
- fill_in 'user_password', with: owner.password
- click_button 'Sign in'
+ fill_in "user_login", with: owner.email
+ fill_in "user_password", with: owner.password
+ click_button "Sign in"
expect(status_code).to eq(200)
expect(current_path).to eq("/#{private_project.full_path}")
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- it 'returns 404 status when project does not exist' do
+ it "returns 404 status when project does not exist" do
visit project_path(build(:project, :public))
expect(status_code).to eq(404)
end
- it 'returns 404 when project is private' do
+ it "returns 404 when project is private" do
visit project_path(private_project)
expect(status_code).to eq(404)
diff --git a/spec/features/projects/show/rss_spec.rb b/spec/features/projects/show/rss_spec.rb
index 4d9135b9677..0cf98f72be0 100644
--- a/spec/features/projects/show/rss_spec.rb
+++ b/spec/features/projects/show/rss_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > RSS' do
+describe "Projects > Show > RSS" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_path(project) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in(user)
@@ -15,7 +15,7 @@ describe 'Projects > Show > RSS' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb b/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb
index baf715000a3..243c6b43e2b 100644
--- a/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb
+++ b/spec/features/projects/show/user_interacts_with_auto_devops_banner_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Project > Show > User interacts with auto devops implicitly enabled banner' do
+describe "Project > Show > User interacts with auto devops implicitly enabled banner" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -11,50 +11,50 @@ describe 'Project > Show > User interacts with auto devops implicitly enabled ba
sign_in(user)
end
- context 'when user does not have maintainer access' do
+ context "when user does not have maintainer access" do
let(:role) { :developer }
- context 'when AutoDevOps is implicitly enabled' do
- it 'does not display AutoDevOps implicitly enabled banner' do
- expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
+ context "when AutoDevOps is implicitly enabled" do
+ it "does not display AutoDevOps implicitly enabled banner" do
+ expect(page).not_to have_css(".auto-devops-implicitly-enabled-banner")
end
end
end
- context 'when user has mantainer access' do
+ context "when user has mantainer access" do
let(:role) { :maintainer }
- context 'when AutoDevOps is implicitly enabled' do
+ context "when AutoDevOps is implicitly enabled" do
before do
stub_application_setting(auto_devops_enabled: true)
visit project_path(project)
end
- it 'display AutoDevOps implicitly enabled banner' do
- expect(page).to have_css('.auto-devops-implicitly-enabled-banner')
+ it "display AutoDevOps implicitly enabled banner" do
+ expect(page).to have_css(".auto-devops-implicitly-enabled-banner")
end
- context 'when user dismisses the banner', :js do
- it 'does not display AutoDevOps implicitly enabled banner' do
- find('.hide-auto-devops-implicitly-enabled-banner').click
+ context "when user dismisses the banner", :js do
+ it "does not display AutoDevOps implicitly enabled banner" do
+ find(".hide-auto-devops-implicitly-enabled-banner").click
wait_for_requests
visit project_path(project)
- expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
+ expect(page).not_to have_css(".auto-devops-implicitly-enabled-banner")
end
end
end
- context 'when AutoDevOps is not implicitly enabled' do
+ context "when AutoDevOps is not implicitly enabled" do
before do
stub_application_setting(auto_devops_enabled: false)
visit project_path(project)
end
- it 'does not display AutoDevOps implicitly enabled banner' do
- expect(page).not_to have_css('.auto-devops-implicitly-enabled-banner')
+ it "does not display AutoDevOps implicitly enabled banner" do
+ expect(page).not_to have_css(".auto-devops-implicitly-enabled-banner")
end
end
end
diff --git a/spec/features/projects/show/user_interacts_with_stars_spec.rb b/spec/features/projects/show/user_interacts_with_stars_spec.rb
index ba28c0e1b8a..3f3fd92e3ee 100644
--- a/spec/features/projects/show/user_interacts_with_stars_spec.rb
+++ b/spec/features/projects/show/user_interacts_with_stars_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User interacts with project stars' do
+describe "Projects > Show > User interacts with project stars" do
let(:project) { create(:project, :public, :repository) }
- context 'when user is signed in', :js do
+ context "when user is signed in", :js do
let(:user) { create(:user) }
before do
@@ -11,26 +11,26 @@ describe 'Projects > Show > User interacts with project stars' do
visit(project_path(project))
end
- it 'toggles the star' do
- find('.star-btn').click
+ it "toggles the star" do
+ find(".star-btn").click
- expect(page).to have_css('.star-count', text: 1)
+ expect(page).to have_css(".star-count", text: 1)
- find('.star-btn').click
+ find(".star-btn").click
- expect(page).to have_css('.star-count', text: 0)
+ expect(page).to have_css(".star-count", text: 0)
end
end
- context 'when user is not signed in' do
+ context "when user is not signed in" do
before do
visit(project_path(project))
end
- it 'does not allow to star a project' do
- expect(page).not_to have_content('.toggle-star')
+ it "does not allow to star a project" do
+ expect(page).not_to have_content(".toggle-star")
- find('.star-btn').click
+ find(".star-btn").click
expect(current_path).to eq(new_user_session_path)
end
diff --git a/spec/features/projects/show/user_manages_notifications_spec.rb b/spec/features/projects/show/user_manages_notifications_spec.rb
index 88f3397608f..0edbcf4771b 100644
--- a/spec/features/projects/show/user_manages_notifications_spec.rb
+++ b/spec/features/projects/show/user_manages_notifications_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User manages notifications', :js do
+describe "Projects > Show > User manages notifications", :js do
let(:project) { create(:project, :public, :repository) }
before do
@@ -9,20 +9,20 @@ describe 'Projects > Show > User manages notifications', :js do
end
def click_notifications_button
- first('.notifications-btn').click
+ first(".notifications-btn").click
end
- it 'changes the notification setting' do
+ it "changes the notification setting" do
click_notifications_button
- click_link 'On mention'
+ click_link "On mention"
wait_for_requests
click_notifications_button
- expect(find('.update-notification.is-active')).to have_content('On mention')
+ expect(find(".update-notification.is-active")).to have_content("On mention")
end
- context 'custom notification settings' do
+ context "custom notification settings" do
let(:email_events) do
[
:new_note,
@@ -38,15 +38,15 @@ describe 'Projects > Show > User manages notifications', :js do
:reassign_merge_request,
:merge_merge_request,
:failed_pipeline,
- :success_pipeline
+ :success_pipeline,
]
end
- it 'shows notification settings checkbox' do
+ it "shows notification settings checkbox" do
click_notifications_button
page.find('a[data-notification-level="custom"]').click
- page.within('.custom-notifications-form') do
+ page.within(".custom-notifications-form") do
email_events.each do |event_name|
expect(page).to have_selector("input[name='notification_setting[#{event_name}]']")
end
diff --git a/spec/features/projects/show/user_sees_collaboration_links_spec.rb b/spec/features/projects/show/user_sees_collaboration_links_spec.rb
index 24777788248..f1be824bbea 100644
--- a/spec/features/projects/show/user_sees_collaboration_links_spec.rb
+++ b/spec/features/projects/show/user_sees_collaboration_links_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > Collaboration links' do
+describe "Projects > Show > Collaboration links" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -9,56 +9,56 @@ describe 'Projects > Show > Collaboration links' do
sign_in(user)
end
- it 'shows all the expected links' do
+ it "shows all the expected links" do
visit project_path(project)
# The navigation bar
- page.within('.header-new') do
- aggregate_failures 'dropdown links in the navigation bar' do
- expect(page).to have_link('New issue')
- expect(page).to have_link('New merge request')
- expect(page).to have_link('New snippet', href: new_project_snippet_path(project))
+ page.within(".header-new") do
+ aggregate_failures "dropdown links in the navigation bar" do
+ expect(page).to have_link("New issue")
+ expect(page).to have_link("New merge request")
+ expect(page).to have_link("New snippet", href: new_project_snippet_path(project))
end
end
# The dropdown above the tree
- page.within('.repo-breadcrumb') do
- aggregate_failures 'dropdown links above the repo tree' do
- expect(page).to have_link('New file')
- expect(page).to have_link('Upload file')
- expect(page).to have_link('New directory')
- expect(page).to have_link('New branch')
- expect(page).to have_link('New tag')
+ page.within(".repo-breadcrumb") do
+ aggregate_failures "dropdown links above the repo tree" do
+ expect(page).to have_link("New file")
+ expect(page).to have_link("Upload file")
+ expect(page).to have_link("New directory")
+ expect(page).to have_link("New branch")
+ expect(page).to have_link("New tag")
end
end
# The Web IDE
- expect(page).to have_link('Web IDE')
+ expect(page).to have_link("Web IDE")
end
- it 'hides the links when the project is archived' do
+ it "hides the links when the project is archived" do
project.update!(archived: true)
visit project_path(project)
- page.within('.header-new') do
- aggregate_failures 'dropdown links' do
- expect(page).not_to have_link('New issue')
- expect(page).not_to have_link('New merge request')
- expect(page).not_to have_link('New snippet', href: new_project_snippet_path(project))
+ page.within(".header-new") do
+ aggregate_failures "dropdown links" do
+ expect(page).not_to have_link("New issue")
+ expect(page).not_to have_link("New merge request")
+ expect(page).not_to have_link("New snippet", href: new_project_snippet_path(project))
end
end
- page.within('.repo-breadcrumb') do
- aggregate_failures 'dropdown links' do
- expect(page).not_to have_link('New file')
- expect(page).not_to have_link('Upload file')
- expect(page).not_to have_link('New directory')
- expect(page).not_to have_link('New branch')
- expect(page).not_to have_link('New tag')
+ page.within(".repo-breadcrumb") do
+ aggregate_failures "dropdown links" do
+ expect(page).not_to have_link("New file")
+ expect(page).not_to have_link("Upload file")
+ expect(page).not_to have_link("New directory")
+ expect(page).not_to have_link("New branch")
+ expect(page).not_to have_link("New tag")
end
end
- expect(page).not_to have_link('Web IDE')
+ expect(page).not_to have_link("Web IDE")
end
end
diff --git a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb
index d9d57298929..0bde1f13b26 100644
--- a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb
+++ b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User sees a deletion failure message' do
+describe "Projects > Show > User sees a deletion failure message" do
let(:project) { create(:project, :empty_repo, pending_delete: true) }
before do
sign_in(project.owner)
end
- it 'shows error message if deletion for project fails' do
+ it "shows error message if deletion for project fails" do
project.update(delete_error: "Something went wrong", pending_delete: false)
visit project_path(project)
- expect(page).to have_selector('.project-deletion-failed-message')
+ expect(page).to have_selector(".project-deletion-failed-message")
expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}")
end
end
diff --git a/spec/features/projects/show/user_sees_git_instructions_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb
index ffa80235083..ef84e8d0fe2 100644
--- a/spec/features/projects/show/user_sees_git_instructions_spec.rb
+++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User sees Git instructions' do
+describe "Projects > Show > User sees Git instructions" do
set(:user) { create(:user) }
- shared_examples_for 'redirects to the sign in page' do
- it 'redirects to the sign in page' do
+ shared_examples_for "redirects to the sign in page" do
+ it "redirects to the sign in page" do
expect(current_path).to eq(new_user_session_path)
end
end
- shared_examples_for 'shows details of empty project with no repo' do
- it 'shows Git command line instructions' do
- click_link 'Create empty repository'
+ shared_examples_for "shows details of empty project with no repo" do
+ it "shows Git command line instructions" do
+ click_link "Create empty repository"
- page.within '.empty_wrapper' do
- expect(page).to have_content('Command line instructions')
+ page.within ".empty_wrapper" do
+ expect(page).to have_content("Command line instructions")
end
end
end
- shared_examples_for 'shows details of empty project' do
+ shared_examples_for "shows details of empty project" do
let(:user_has_ssh_key) { false }
- it 'shows details' do
- expect(page).not_to have_content('Git global setup')
+ it "shows details" do
+ expect(page).not_to have_content("Git global setup")
- page.all(:css, '.git-empty .clone').each do |element|
+ page.all(:css, ".git-empty .clone").each do |element|
expect(element.text).to include(project.http_url_to_repo)
end
- expect(page).to have_field('http_project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
+ expect(page).to have_field("http_project_clone", with: project.http_url_to_repo) unless user_has_ssh_key
end
end
- shared_examples_for 'shows details of non empty project' do
+ shared_examples_for "shows details of non empty project" do
let(:user_has_ssh_key) { false }
- it 'shows details' do
- page.within('.breadcrumbs .breadcrumb-item-text') do
+ it "shows details" do
+ page.within(".breadcrumbs .breadcrumb-item-text") do
expect(page).to have_content(project.title)
end
- expect(page).to have_field('http_project_clone', with: project.http_url_to_repo) unless user_has_ssh_key
+ expect(page).to have_field("http_project_clone", with: project.http_url_to_repo) unless user_has_ssh_key
end
end
- context 'when project is public' do
- context 'when project has no repo' do
+ context "when project is public" do
+ context "when project has no repo" do
set(:project) { create(:project, :public) }
before do
@@ -54,83 +54,83 @@ describe 'Projects > Show > User sees Git instructions' do
visit project_path(project)
end
- include_examples 'shows details of empty project with no repo'
+ include_examples "shows details of empty project with no repo"
end
- context 'when project is empty' do
+ context "when project is empty" do
set(:project) { create(:project_empty_repo, :public) }
- context 'when not signed in' do
+ context "when not signed in" do
before do
visit(project_path(project))
end
- include_examples 'shows details of empty project'
+ include_examples "shows details of empty project"
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- context 'when user does not have ssh keys' do
+ context "when user does not have ssh keys" do
before do
visit(project_path(project))
end
- include_examples 'shows details of empty project'
+ include_examples "shows details of empty project"
end
- context 'when user has ssh keys' do
+ context "when user has ssh keys" do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
- include_examples 'shows details of empty project' do
+ include_examples "shows details of empty project" do
let(:user_has_ssh_key) { true }
end
end
end
end
- context 'when project is not empty' do
+ context "when project is not empty" do
set(:project) { create(:project, :public, :repository) }
before do
visit(project_path(project))
end
- context 'when not signed in' do
+ context "when not signed in" do
before do
- allow(Gitlab.config.gitlab).to receive(:host).and_return('www.example.com')
+ allow(Gitlab.config.gitlab).to receive(:host).and_return("www.example.com")
end
- include_examples 'shows details of non empty project'
+ include_examples "shows details of non empty project"
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
end
- context 'when user does not have ssh keys' do
+ context "when user does not have ssh keys" do
before do
visit(project_path(project))
end
- include_examples 'shows details of non empty project'
+ include_examples "shows details of non empty project"
end
- context 'when user has ssh keys' do
+ context "when user has ssh keys" do
before do
create(:personal_key, user: user)
visit(project_path(project))
end
- include_examples 'shows details of non empty project' do
+ include_examples "shows details of non empty project" do
let(:user_has_ssh_key) { true }
end
end
@@ -138,35 +138,35 @@ describe 'Projects > Show > User sees Git instructions' do
end
end
- context 'when project is internal' do
+ context "when project is internal" do
set(:project) { create(:project, :internal, :repository) }
- context 'when not signed in' do
+ context "when not signed in" do
before do
visit(project_path(project))
end
- include_examples 'redirects to the sign in page'
+ include_examples "redirects to the sign in page"
end
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
visit(project_path(project))
end
- include_examples 'shows details of non empty project'
+ include_examples "shows details of non empty project"
end
end
- context 'when project is private' do
+ context "when project is private" do
set(:project) { create(:project, :private) }
before do
visit(project_path(project))
end
- include_examples 'redirects to the sign in page'
+ include_examples "redirects to the sign in page"
end
end
diff --git a/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
index e277bfb8011..8b6b615533d 100644
--- a/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
+++ b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User sees last commit CI status' do
+describe "Projects > Show > User sees last commit CI status" do
set(:project) { create(:project, :repository, :public) }
- it 'shows the project README', :js do
+ it "shows the project README", :js do
project.enable_ci
- pipeline = create(:ci_pipeline, project: project, sha: project.commit.sha, ref: 'master')
+ pipeline = create(:ci_pipeline, project: project, sha: project.commit.sha, ref: "master")
pipeline.skip
visit project_path(project)
- page.within '.blob-commit-info' do
+ page.within ".blob-commit-info" do
expect(page).to have_content(project.commit.sha[0..6])
- expect(page).to have_link('Commit: skipped')
+ expect(page).to have_link("Commit: skipped")
end
end
end
diff --git a/spec/features/projects/show/user_sees_readme_spec.rb b/spec/features/projects/show/user_sees_readme_spec.rb
index d80606c1c23..009f315322b 100644
--- a/spec/features/projects/show/user_sees_readme_spec.rb
+++ b/spec/features/projects/show/user_sees_readme_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User sees README' do
+describe "Projects > Show > User sees README" do
set(:user) { create(:user) }
set(:project) { create(:project, :repository, :public) }
- it 'shows the project README', :js do
+ it "shows the project README", :js do
visit project_path(project)
wait_for_requests
- page.within('.readme-holder') do
- expect(page).to have_content 'testme'
+ page.within(".readme-holder") do
+ expect(page).to have_content "testme"
end
end
end
diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
index dcca1d388c7..21f80241340 100644
--- a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
+++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Show > User sees setup shortcut buttons' do
+describe "Projects > Show > User sees setup shortcut buttons" do
# For "New file", "Add license" functionality,
# see spec/features/projects/files/project_owner_creates_license_file_spec.rb
# see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb
@@ -9,34 +9,34 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
let(:user) { create(:user) }
- describe 'empty project' do
+ describe "empty project" do
let(:project) { create(:project, :public, :empty_repo) }
let(:presenter) { project.present(current_user: user) }
- describe 'as a normal user' do
+ describe "as a normal user" do
before do
sign_in(user)
visit project_path(project)
end
- it 'no Auto DevOps button if can not manage pipelines' do
- page.within('.project-buttons') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
+ it "no Auto DevOps button if can not manage pipelines" do
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Enable Auto DevOps")
+ expect(page).not_to have_link("Auto DevOps enabled")
end
end
it '"Auto DevOps enabled" button not linked' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_text('Auto DevOps enabled')
+ page.within(".project-buttons") do
+ expect(page).to have_text("Auto DevOps enabled")
end
end
end
- describe 'as a maintainer' do
+ describe "as a maintainer" do
before do
project.add_maintainer(user)
sign_in(user)
@@ -45,49 +45,49 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
it '"New file" button linked to new file page' do
- page.within('.project-buttons') do
- expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master'))
+ page.within(".project-buttons") do
+ expect(page).to have_link("New file", href: project_new_blob_path(project, project.default_branch || "master"))
end
end
it '"Add README" button linked to new file populated for a README' do
- page.within('.project-buttons') do
- expect(page).to have_link('Add README', href: presenter.add_readme_path)
+ page.within(".project-buttons") do
+ expect(page).to have_link("Add README", href: presenter.add_readme_path)
end
end
it '"Add license" button linked to new file populated for a license' do
- page.within('.project-stats') do
- expect(page).to have_link('Add license', href: presenter.add_license_path)
+ page.within(".project-stats") do
+ expect(page).to have_link("Add license", href: presenter.add_license_path)
end
end
- describe 'Auto DevOps button' do
- context 'when Auto DevOps is enabled' do
+ describe "Auto DevOps button" do
+ context "when Auto DevOps is enabled" do
it '"Auto DevOps enabled" anchor linked to settings page' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Auto DevOps enabled", href: project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
end
end
- context 'when Auto DevOps is not enabled' do
- let(:project) { create(:project, :public, :empty_repo, auto_devops_attributes: { enabled: false }) }
+ context "when Auto DevOps is not enabled" do
+ let(:project) { create(:project, :public, :empty_repo, auto_devops_attributes: {enabled: false}) }
it '"Enable Auto DevOps" button linked to settings page' do
- page.within('.project-buttons') do
- expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Enable Auto DevOps", href: project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
end
end
end
- describe 'Kubernetes cluster button' do
+ describe "Kubernetes cluster button" do
it '"Add Kubernetes cluster" button linked to clusters page' do
- page.within('.project-buttons') do
- expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Add Kubernetes cluster", href: new_project_cluster_path(project))
end
end
@@ -96,102 +96,102 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Kubernetes configured", href: project_cluster_path(project, cluster))
end
end
end
end
end
- describe 'populated project' do
+ describe "populated project" do
let(:project) { create(:project, :public, :repository) }
let(:presenter) { project.present(current_user: user) }
- describe 'as a normal user' do
+ describe "as a normal user" do
before do
sign_in(user)
visit project_path(project)
end
- context 'when Auto DevOps is enabled' do
+ context "when Auto DevOps is enabled" do
it '"Auto DevOps enabled" button not linked' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_text('Auto DevOps enabled')
+ page.within(".project-buttons") do
+ expect(page).to have_text("Auto DevOps enabled")
end
end
end
- context 'when Auto DevOps is not enabled' do
- let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
+ context "when Auto DevOps is not enabled" do
+ let(:project) { create(:project, :public, :repository, auto_devops_attributes: {enabled: false}) }
- it 'no Auto DevOps button if can not manage pipelines' do
- page.within('.project-buttons') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
+ it "no Auto DevOps button if can not manage pipelines" do
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Enable Auto DevOps")
+ expect(page).not_to have_link("Auto DevOps enabled")
end
end
- it 'no Kubernetes cluster button if can not manage clusters' do
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add Kubernetes cluster')
- expect(page).not_to have_link('Kubernetes configured')
+ it "no Kubernetes cluster button if can not manage clusters" do
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add Kubernetes cluster")
+ expect(page).not_to have_link("Kubernetes configured")
end
end
end
end
- describe 'as a maintainer' do
+ describe "as a maintainer" do
before do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false)
project.add_maintainer(user)
sign_in(user)
end
- context 'README button' do
+ context "README button" do
before do
allow(Project).to receive(:find_by_full_path)
- .with(project.full_path, follow_redirects: true)
- .and_return(project)
+ .with(project.full_path, follow_redirects: true)
+ .and_return(project)
end
- context 'when the project has a populated README' do
+ context "when the project has a populated README" do
it 'show the "README" anchor' do
visit project_path(project)
expect(project.repository.readme).not_to be_nil
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add README', href: presenter.add_readme_path)
- expect(page).to have_link('README', href: presenter.readme_path)
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add README", href: presenter.add_readme_path)
+ expect(page).to have_link("README", href: presenter.readme_path)
end
end
- context 'when the project has an empty README' do
+ context "when the project has an empty README" do
it 'show the "README" anchor' do
- allow(project.repository).to receive(:readme).and_return(fake_blob(path: 'README.md', data: '', size: 0))
+ allow(project.repository).to receive(:readme).and_return(fake_blob(path: "README.md", data: "", size: 0))
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add README', href: presenter.add_readme_path)
- expect(page).to have_link('README', href: presenter.readme_path)
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add README", href: presenter.add_readme_path)
+ expect(page).to have_link("README", href: presenter.readme_path)
end
end
end
end
- context 'when the project does not have a README' do
+ context "when the project does not have a README" do
it 'shows the "Add README" button' do
allow(project.repository).to receive(:readme).and_return(nil)
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Add README', href: presenter.add_readme_path)
+ page.within(".project-buttons") do
+ expect(page).to have_link("Add README", href: presenter.add_readme_path)
end
end
end
@@ -202,8 +202,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
expect(project.repository.changelog).not_to be_nil
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add CHANGELOG')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add CHANGELOG")
end
end
@@ -212,8 +212,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
expect(project.repository.license_blob).not_to be_nil
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add license')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add license")
end
end
@@ -222,32 +222,32 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
expect(project.repository.contribution_guide).not_to be_nil
- page.within('.project-buttons') do
- expect(page).not_to have_link('Add CONTRIBUTING')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Add CONTRIBUTING")
end
end
- describe 'GitLab CI configuration button' do
- context 'when Auto DevOps is enabled' do
+ describe "GitLab CI configuration button" do
+ context "when Auto DevOps is enabled" do
it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).not_to have_link('Set up CI/CD')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Set up CI/CD")
end
end
end
- context 'when Auto DevOps is not enabled' do
- let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
+ context "when Auto DevOps is not enabled" do
+ let(:project) { create(:project, :public, :repository, auto_devops_attributes: {enabled: false}) }
it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
visit project_path(project)
expect(project.repository.gitlab_ci_yml).to be_nil
- page.within('.project-buttons') do
- expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path)
+ page.within(".project-buttons") do
+ expect(page).to have_link("Set up CI/CD", href: presenter.add_ci_yml_path)
end
end
@@ -255,56 +255,56 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add .gitlab-ci.yml",
- file_path: '.gitlab-ci.yml',
- file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ file_path: ".gitlab-ci.yml",
+ file_content: File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).not_to have_link('Set up CI/CD')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Set up CI/CD")
end
end
end
end
- describe 'Auto DevOps button' do
- context 'when Auto DevOps is enabled' do
+ describe "Auto DevOps button" do
+ context "when Auto DevOps is enabled" do
it '"Auto DevOps enabled" anchor linked to settings page' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Auto DevOps enabled", href: project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
end
end
- context 'when Auto DevOps is not enabled' do
- let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
+ context "when Auto DevOps is not enabled" do
+ let(:project) { create(:project, :public, :repository, auto_devops_attributes: {enabled: false}) }
it '"Enable Auto DevOps" button linked to settings page' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Enable Auto DevOps", href: project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
end
- it 'no Auto DevOps button if Auto DevOps callout is shown' do
+ it "no Auto DevOps button if Auto DevOps callout is shown" do
allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true)
visit project_path(project)
- expect(page).to have_selector('.js-autodevops-banner')
+ expect(page).to have_selector(".js-autodevops-banner")
- page.within('.project-buttons') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Enable Auto DevOps")
+ expect(page).not_to have_link("Auto DevOps enabled")
end
end
@@ -312,31 +312,31 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
Files::CreateService.new(
project,
project.creator,
- start_branch: 'master',
- branch_name: 'master',
+ start_branch: "master",
+ branch_name: "master",
commit_message: "Add .gitlab-ci.yml",
- file_path: '.gitlab-ci.yml',
- file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ file_path: ".gitlab-ci.yml",
+ file_content: File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
).execute
expect(project.repository.gitlab_ci_yml).not_to be_nil
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).not_to have_link('Enable Auto DevOps')
- expect(page).not_to have_link('Auto DevOps enabled')
+ page.within(".project-buttons") do
+ expect(page).not_to have_link("Enable Auto DevOps")
+ expect(page).not_to have_link("Auto DevOps enabled")
end
end
end
end
- describe 'Kubernetes cluster button' do
+ describe "Kubernetes cluster button" do
it '"Add Kubernetes cluster" button linked to clusters page' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Add Kubernetes cluster", href: new_project_cluster_path(project))
end
end
@@ -345,8 +345,8 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
visit project_path(project)
- page.within('.project-buttons') do
- expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster))
+ page.within(".project-buttons") do
+ expect(page).to have_link("Kubernetes configured", href: project_cluster_path(project, cluster))
end
end
end
diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb
index 6d8a72dd6a3..91ce4bf48f0 100644
--- a/spec/features/projects/snippets/create_snippet_spec.rb
+++ b/spec/features/projects/snippets/create_snippet_spec.rb
@@ -1,86 +1,86 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Projects > Snippets > Create Snippet', :js do
+describe "Projects > Snippets > Create Snippet", :js do
include DropzoneHelper
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
def fill_form
- fill_in 'project_snippet_title', with: 'My Snippet Title'
- fill_in 'project_snippet_description', with: 'My Snippet **Description**'
- page.within('.file-editor') do
- find('.ace_text-input', visible: false).send_keys('Hello World!')
+ fill_in "project_snippet_title", with: "My Snippet Title"
+ fill_in "project_snippet_description", with: "My Snippet **Description**"
+ page.within(".file-editor") do
+ find(".ace_text-input", visible: false).send_keys("Hello World!")
end
end
- context 'when a user is authenticated' do
+ context "when a user is authenticated" do
before do
project.add_maintainer(user)
sign_in(user)
visit project_snippets_path(project)
- click_on('New snippet')
+ click_on("New snippet")
end
- it 'creates a new snippet' do
+ it "creates a new snippet" do
fill_form
- click_button('Create snippet')
+ click_button("Create snippet")
wait_for_requests
- expect(page).to have_content('My Snippet Title')
- expect(page).to have_content('Hello World!')
- page.within('.snippet-header .description') do
- expect(page).to have_content('My Snippet Description')
- expect(page).to have_selector('strong')
+ expect(page).to have_content("My Snippet Title")
+ expect(page).to have_content("Hello World!")
+ page.within(".snippet-header .description") do
+ expect(page).to have_content("My Snippet Description")
+ expect(page).to have_selector("strong")
end
end
- it 'uploads a file when dragging into textarea' do
+ it "uploads a file when dragging into textarea" do
fill_form
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
- expect(page.find_field("project_snippet_description").value).to have_content('banana_sample')
+ expect(page.find_field("project_snippet_description").value).to have_content("banana_sample")
- click_button('Create snippet')
+ click_button("Create snippet")
wait_for_requests
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/#{Regexp.escape(project.full_path) }/uploads/\h{32}/banana_sample\.gif\z})
end
- it 'creates a snippet when all reuiqred fields are filled in after validation failing' do
- fill_in 'project_snippet_title', with: 'My Snippet Title'
- click_button('Create snippet')
+ it "creates a snippet when all reuiqred fields are filled in after validation failing" do
+ fill_in "project_snippet_title", with: "My Snippet Title"
+ click_button("Create snippet")
- expect(page).to have_selector('#error_explanation')
+ expect(page).to have_selector("#error_explanation")
fill_form
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
find("input[value='Create snippet']").send_keys(:return)
wait_for_requests
- expect(page).to have_content('My Snippet Title')
- expect(page).to have_content('Hello World!')
- page.within('.snippet-header .description') do
- expect(page).to have_content('My Snippet Description')
- expect(page).to have_selector('strong')
+ expect(page).to have_content("My Snippet Title")
+ expect(page).to have_content("Hello World!")
+ page.within(".snippet-header .description") do
+ expect(page).to have_content("My Snippet Description")
+ expect(page).to have_selector("strong")
end
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/#{Regexp.escape(project.full_path) }/uploads/\h{32}/banana_sample\.gif\z})
end
end
- context 'when a user is not authenticated' do
- it 'shows a public snippet on the index page but not the New snippet button' do
+ context "when a user is not authenticated" do
+ it "shows a public snippet on the index page but not the New snippet button" do
snippet = create(:project_snippet, :public, project: project)
visit project_snippets_path(project)
expect(page).to have_content(snippet.title)
- expect(page).not_to have_content('New snippet')
+ expect(page).not_to have_content("New snippet")
end
end
end
diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb
index f3dc13fb52f..c7ef285f1f9 100644
--- a/spec/features/projects/snippets/show_spec.rb
+++ b/spec/features/projects/snippets/show_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Snippets > Project snippet', :js do
+describe "Projects > Snippets > Project snippet", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) }
@@ -10,9 +10,9 @@ describe 'Projects > Snippets > Project snippet', :js do
sign_in(user)
end
- context 'Ruby file' do
- let(:file_name) { 'popen.rb' }
- let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
+ context "Ruby file" do
+ let(:file_name) { "popen.rb" }
+ let(:content) { project.repository.blob_at("master", "files/ruby/popen.rb").data }
before do
visit project_snippet_path(project, snippet)
@@ -20,38 +20,38 @@ describe 'Projects > Snippets > Project snippet', :js do
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows highlighted Ruby code
expect(page).to have_content("require 'fileutils'")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'Markdown file' do
- let(:file_name) { 'ruby-style-guide.md' }
- let(:content) { project.repository.blob_at('master', 'files/markdown/ruby-style-guide.md').data }
+ context "Markdown file" do
+ let(:file_name) { "ruby-style-guide.md" }
+ let(:content) { project.repository.blob_at("master", "files/markdown/ruby-style-guide.md").data }
- context 'visiting directly' do
+ context "visiting directly" do
before do
visit project_snippet_path(project, snippet)
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
@@ -61,27 +61,27 @@ describe 'Projects > Snippets > Project snippet', :js do
expect(page).to have_link("PEP-8")
# shows a viewer switcher
- expect(page).to have_selector('.js-blob-viewer-switcher')
+ expect(page).to have_selector(".js-blob-viewer-switcher")
# shows a disabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
+ expect(page).to have_selector(".js-copy-blob-source-btn.disabled")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
- context 'switching to the simple viewer' do
+ context "switching to the simple viewer" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=simple]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=simple]").click
wait_for_requests
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
@@ -91,60 +91,60 @@ describe 'Projects > Snippets > Project snippet', :js do
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
- context 'switching to the rich viewer again' do
+ context "switching to the rich viewer again" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=rich]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=rich]").click
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
end
- context 'visiting with a line number anchor' do
+ context "visiting with a line number anchor" do
before do
- visit project_snippet_path(project, snippet, anchor: 'L1')
+ visit project_snippet_path(project, snippet, anchor: "L1")
wait_for_requests
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false)
# highlights the line in question
- expect(page).to have_selector('#LC1.hll')
+ expect(page).to have_selector("#LC1.hll")
# shows highlighted Markdown code
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
- it_behaves_like 'showing user status' do
- let(:file_name) { 'ruby-style-guide.md' }
- let(:content) { project.repository.blob_at('master', 'files/markdown/ruby-style-guide.md').data }
+ it_behaves_like "showing user status" do
+ let(:file_name) { "ruby-style-guide.md" }
+ let(:content) { project.repository.blob_at("master", "files/markdown/ruby-style-guide.md").data }
let(:user_with_status) { snippet.author }
diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
index 9c1ef78b0ca..b3447767d6c 100644
--- a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Snippets > User comments on a snippet', :js do
+describe "Projects > Snippets > User comments on a snippet", :js do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
@@ -12,26 +12,26 @@ describe 'Projects > Snippets > User comments on a snippet', :js do
visit(project_snippet_path(project, snippet))
end
- it 'leaves a comment on a snippet' do
- page.within('.js-main-target-form') do
- fill_in('note_note', with: 'Good snippet!')
- click_button('Comment')
+ it "leaves a comment on a snippet" do
+ page.within(".js-main-target-form") do
+ fill_in("note_note", with: "Good snippet!")
+ click_button("Comment")
end
wait_for_requests
- expect(page).to have_content('Good snippet!')
+ expect(page).to have_content("Good snippet!")
end
- it 'should have autocomplete' do
- find('#note_note').native.send_keys('')
- fill_in 'note[note]', with: '@'
+ it "should have autocomplete" do
+ find("#note_note").native.send_keys("")
+ fill_in "note[note]", with: "@"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
- it 'should have zen mode' do
- find('.js-zen-enter').click
- expect(page).to have_selector('.fullscreen')
+ it "should have zen mode" do
+ find(".js-zen-enter").click
+ expect(page).to have_selector(".fullscreen")
end
end
diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb
index 2bd8bb9d551..7c7adebb8da 100644
--- a/spec/features/projects/snippets/user_deletes_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Snippets > User deletes a snippet' do
+describe "Projects > Snippets > User deletes a snippet" do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
@@ -12,8 +12,8 @@ describe 'Projects > Snippets > User deletes a snippet' do
visit(project_snippet_path(project, snippet))
end
- it 'deletes a snippet' do
- first(:link, 'Delete').click
+ it "deletes a snippet" do
+ first(:link, "Delete").click
expect(page).not_to have_content(snippet.title)
end
diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb
index 33f77d55f89..33054fb3bb7 100644
--- a/spec/features/projects/snippets/user_updates_snippet_spec.rb
+++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Snippets > User updates a snippet' do
+describe "Projects > Snippets > User updates a snippet" do
let(:project) { create(:project) }
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let(:user) { create(:user) }
@@ -12,14 +12,14 @@ describe 'Projects > Snippets > User updates a snippet' do
visit(project_snippet_path(project, snippet))
end
- it 'updates a snippet' do
- page.within('.detail-page-header') do
- first(:link, 'Edit').click
+ it "updates a snippet" do
+ page.within(".detail-page-header") do
+ first(:link, "Edit").click
end
- fill_in('project_snippet_title', with: 'Snippet new title')
- click_button('Save')
+ fill_in("project_snippet_title", with: "Snippet new title")
+ click_button("Save")
- expect(page).to have_content('Snippet new title')
+ expect(page).to have_content("Snippet new title")
end
end
diff --git a/spec/features/projects/snippets/user_views_snippets_spec.rb b/spec/features/projects/snippets/user_views_snippets_spec.rb
index 1243db9d9f7..c35e5109c8b 100644
--- a/spec/features/projects/snippets/user_views_snippets_spec.rb
+++ b/spec/features/projects/snippets/user_views_snippets_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Snippets > User views snippets' do
+describe "Projects > Snippets > User views snippets" do
let(:project) { create(:project) }
let!(:project_snippet) { create(:project_snippet, project: project, author: user) }
let!(:snippet) { create(:snippet, author: user) }
@@ -14,7 +14,7 @@ describe 'Projects > Snippets > User views snippets' do
visit(project_snippets_path(project))
end
- context 'pagination' do
+ context "pagination" do
before do
create(:project_snippet, project: project, author: user)
allow(Snippet).to receive(:default_per_page).and_return(1)
@@ -22,10 +22,10 @@ describe 'Projects > Snippets > User views snippets' do
visit project_snippets_path(project)
end
- it_behaves_like 'paginated snippets'
+ it_behaves_like "paginated snippets"
end
- it 'shows snippets' do
+ it "shows snippets" do
expect(page).to have_content(project_snippet.title)
expect(page).not_to have_content(snippet.title)
end
diff --git a/spec/features/projects/sub_group_issuables_spec.rb b/spec/features/projects/sub_group_issuables_spec.rb
index 50e7e934cf6..f518750520a 100644
--- a/spec/features/projects/sub_group_issuables_spec.rb
+++ b/spec/features/projects/sub_group_issuables_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Subgroup Issuables', :js, :nested_groups do
- let!(:group) { create(:group, name: 'group') }
- let!(:subgroup) { create(:group, parent: group, name: 'subgroup') }
- let!(:project) { create(:project, namespace: subgroup, name: 'project') }
+describe "Subgroup Issuables", :js, :nested_groups do
+ let!(:group) { create(:group, name: "group") }
+ let!(:subgroup) { create(:group, parent: group, name: "subgroup") }
+ let!(:project) { create(:project, namespace: subgroup, name: "project") }
let(:user) { create(:user) }
before do
@@ -11,21 +11,21 @@ describe 'Subgroup Issuables', :js, :nested_groups do
sign_in user
end
- it 'shows the full subgroup title when issues index page is empty' do
+ it "shows the full subgroup title when issues index page is empty" do
visit project_issues_path(project)
expect_to_have_full_subgroup_title
end
- it 'shows the full subgroup title when merge requests index page is empty' do
+ it "shows the full subgroup title when merge requests index page is empty" do
visit project_merge_requests_path(project)
expect_to_have_full_subgroup_title
end
def expect_to_have_full_subgroup_title
- title = find('.breadcrumbs-links')
+ title = find(".breadcrumbs-links")
- expect(title).to have_content 'group subgroup project'
+ expect(title).to have_content "group subgroup project"
end
end
diff --git a/spec/features/projects/tags/download_buttons_spec.rb b/spec/features/projects/tags/download_buttons_spec.rb
index fbfd8cee7aa..04a09ffab83 100644
--- a/spec/features/projects/tags/download_buttons_spec.rb
+++ b/spec/features/projects/tags/download_buttons_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Download buttons in tags page' do
+describe "Download buttons in tags page" do
let(:user) { create(:user) }
let(:role) { :developer }
- let(:status) { 'success' }
- let(:tag) { 'v1.0.0' }
+ let(:status) { "success" }
+ let(:tag) { "v1.0.0" }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit(tag).sha,
- ref: tag,
- status: status)
+ project: project,
+ sha: project.commit(tag).sha,
+ ref: tag,
+ status: status)
end
let!(:build) do
create(:ci_build, :success, :artifacts,
- pipeline: pipeline,
- status: pipeline.status,
- name: 'build')
+ pipeline: pipeline,
+ status: pipeline.status,
+ name: "build")
end
before do
@@ -27,14 +27,14 @@ describe 'Download buttons in tags page' do
project.add_role(user, role)
end
- describe 'when checking tags' do
- context 'with artifacts' do
+ describe "when checking tags" do
+ context "with artifacts" do
before do
visit project_tags_path(project)
end
- it 'shows download artifacts button' do
- href = latest_succeeded_project_artifacts_path(project, "#{tag}/download", job: 'build')
+ it "shows download artifacts button" do
+ href = latest_succeeded_project_artifacts_path(project, "#{tag}/download", job: "build")
expect(page).to have_link "Download '#{build.name}'", href: href
end
diff --git a/spec/features/projects/tags/user_edits_tags_spec.rb b/spec/features/projects/tags/user_edits_tags_spec.rb
index ebb2844d17f..8504803b15a 100644
--- a/spec/features/projects/tags/user_edits_tags_spec.rb
+++ b/spec/features/projects/tags/user_edits_tags_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'Project > Tags', :js do
+describe "Project > Tags", :js do
include DropzoneHelper
let(:user) { create(:user) }
@@ -14,67 +14,67 @@ describe 'Project > Tags', :js do
project.add_role(user, role)
end
- describe 'when opening project tags' do
+ describe "when opening project tags" do
before do
visit project_tags_path(project)
end
- context 'page with tags list' do
- it 'shows tag name' do
- page.within first('.tags > .content-list > li') do
- expect(page.find('.row-main-content')).to have_content 'v1.1.0 Version 1.1.0'
+ context "page with tags list" do
+ it "shows tag name" do
+ page.within first(".tags > .content-list > li") do
+ expect(page.find(".row-main-content")).to have_content "v1.1.0 Version 1.1.0"
end
end
- it 'shows tag edit button' do
- page.within first('.tags > .content-list > li') do
- edit_btn = page.find('.row-fixed-content.controls a.btn-edit')
+ it "shows tag edit button" do
+ page.within first(".tags > .content-list > li") do
+ edit_btn = page.find(".row-fixed-content.controls a.btn-edit")
- expect(edit_btn['href']).to have_content '/tags/v1.1.0/release/edit'
+ expect(edit_btn["href"]).to have_content "/tags/v1.1.0/release/edit"
end
end
end
- context 'edit tag release notes' do
+ context "edit tag release notes" do
before do
- find('.tags > .content-list > li:first-child .row-fixed-content.controls a.btn-edit').click
+ find(".tags > .content-list > li:first-child .row-fixed-content.controls a.btn-edit").click
end
- it 'shows tag name header' do
- page.within('.content') do
- expect(page.find('.sub-header-block')).to have_content 'Release notes for tag v1.1.0'
+ it "shows tag name header" do
+ page.within(".content") do
+ expect(page.find(".sub-header-block")).to have_content "Release notes for tag v1.1.0"
end
end
- it 'shows release notes form' do
- page.within('.content') do
- expect(page).to have_selector('form.release-form')
+ it "shows release notes form" do
+ page.within(".content") do
+ expect(page).to have_selector("form.release-form")
end
end
- it 'toolbar buttons on release notes form are functional' do
- page.within('.content form.release-form') do
- note_textarea = page.find('.js-gfm-input')
+ it "toolbar buttons on release notes form are functional" do
+ page.within(".content form.release-form") do
+ note_textarea = page.find(".js-gfm-input")
# Click on Bold button
- page.find('.md-header-toolbar button.toolbar-btn:first-child').click
+ page.find(".md-header-toolbar button.toolbar-btn:first-child").click
- expect(note_textarea.value).to eq('****')
+ expect(note_textarea.value).to eq("****")
end
end
it 'release notes form shows "Attach a file" button', :js do
- page.within('.content form.release-form') do
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ page.within(".content form.release-form") do
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
end
it 'shows "Attaching a file" message on uploading 1 file', :js do
slow_requests do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")], 0, false)
- expect(page).to have_selector('.attaching-file-message', visible: true, text: 'Attaching a file -')
+ expect(page).to have_selector(".attaching-file-message", visible: true, text: "Attaching a file -")
end
end
end
diff --git a/spec/features/projects/tags/user_views_tags_spec.rb b/spec/features/projects/tags/user_views_tags_spec.rb
index f344b682715..0536ba1a674 100644
--- a/spec/features/projects/tags/user_views_tags_spec.rb
+++ b/spec/features/projects/tags/user_views_tags_spec.rb
@@ -1,9 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe 'User views tags', :feature do
- context 'rss' do
- shared_examples 'has access to the tags RSS feed' do
+require "spec_helper"
+
+describe "User views tags", :feature do
+ context "rss" do
+ shared_examples "has access to the tags RSS feed" do
it do
visit project_tags_path(project, format: :atom)
@@ -11,7 +12,7 @@ describe 'User views tags', :feature do
end
end
- shared_examples 'does not have access to the tags RSS feed' do
+ shared_examples "does not have access to the tags RSS feed" do
it do
visit project_tags_path(project, format: :atom)
@@ -19,10 +20,10 @@ describe 'User views tags', :feature do
end
end
- context 'when project public' do
+ context "when project public" do
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
- context 'when user signed in' do
+ context "when user signed in" do
let(:user) { create(:user) }
before do
@@ -33,24 +34,24 @@ describe 'User views tags', :feature do
it_behaves_like "it has an RSS button with current_user's feed token"
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
- it_behaves_like 'has access to the tags RSS feed'
+ it_behaves_like "has access to the tags RSS feed"
end
- context 'when user signed out' do
+ context "when user signed out" do
before do
visit project_tags_path(project)
end
- it_behaves_like 'it has an RSS button without a feed token'
- it_behaves_like 'an autodiscoverable RSS feed without a feed token'
- it_behaves_like 'has access to the tags RSS feed'
+ it_behaves_like "it has an RSS button without a feed token"
+ it_behaves_like "an autodiscoverable RSS feed without a feed token"
+ it_behaves_like "has access to the tags RSS feed"
end
end
- context 'when project is not public' do
+ context "when project is not public" do
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
- context 'when user signed in' do
+ context "when user signed in" do
let(:user) { create(:user) }
before do
@@ -58,11 +59,11 @@ describe 'User views tags', :feature do
sign_in(user)
end
- it_behaves_like 'has access to the tags RSS feed'
+ it_behaves_like "has access to the tags RSS feed"
end
- context 'when user signed out' do
- it_behaves_like 'does not have access to the tags RSS feed'
+ context "when user signed out" do
+ it_behaves_like "does not have access to the tags RSS feed"
end
end
end
diff --git a/spec/features/projects/tree/create_directory_spec.rb b/spec/features/projects/tree/create_directory_spec.rb
index 2cb2a23b7be..84e15b0ce70 100644
--- a/spec/features/projects/tree/create_directory_spec.rb
+++ b/spec/features/projects/tree/create_directory_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Multi-file editor new directory', :js do
+describe "Multi-file editor new directory", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -12,45 +12,45 @@ describe 'Multi-file editor new directory', :js do
wait_for_requests
- click_link('Web IDE')
+ click_link("Web IDE")
wait_for_requests
end
after do
- set_cookie('new_repo', 'false')
+ set_cookie("new_repo", "false")
end
- it 'creates directory in current directory' do
- all('.ide-tree-actions button').last.click
+ it "creates directory in current directory" do
+ all(".ide-tree-actions button").last.click
- page.within('.modal') do
- find('.form-control').set('folder name')
+ page.within(".modal") do
+ find(".form-control").set("folder name")
- click_button('Create directory')
+ click_button("Create directory")
end
- first('.ide-tree-actions button').click
+ first(".ide-tree-actions button").click
- page.within('.modal-dialog') do
- find('.form-control').set('file name')
+ page.within(".modal-dialog") do
+ find(".form-control").set("file name")
- click_button('Create file')
+ click_button("Create file")
end
wait_for_requests
- find('.js-ide-commit-mode').click
+ find(".js-ide-commit-mode").click
- find('.multi-file-commit-list-item').hover
- click_button 'Stage'
+ find(".multi-file-commit-list-item").hover
+ click_button "Stage"
- fill_in('commit-message', with: 'commit message ide')
+ fill_in("commit-message", with: "commit message ide")
- click_button('Commit')
+ click_button("Commit")
- find('.js-ide-edit-mode').click
+ find(".js-ide-edit-mode").click
- expect(page).to have_content('folder name')
+ expect(page).to have_content("folder name")
end
end
diff --git a/spec/features/projects/tree/create_file_spec.rb b/spec/features/projects/tree/create_file_spec.rb
index 9f5524da8e9..76272bb2203 100644
--- a/spec/features/projects/tree/create_file_spec.rb
+++ b/spec/features/projects/tree/create_file_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Multi-file editor new file', :js do
+describe "Multi-file editor new file", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -12,35 +12,35 @@ describe 'Multi-file editor new file', :js do
wait_for_requests
- click_link('Web IDE')
+ click_link("Web IDE")
wait_for_requests
end
after do
- set_cookie('new_repo', 'false')
+ set_cookie("new_repo", "false")
end
- it 'creates file in current directory' do
- first('.ide-tree-actions button').click
+ it "creates file in current directory" do
+ first(".ide-tree-actions button").click
- page.within('.modal') do
- find('.form-control').set('file name')
+ page.within(".modal") do
+ find(".form-control").set("file name")
- click_button('Create file')
+ click_button("Create file")
end
wait_for_requests
- find('.js-ide-commit-mode').click
+ find(".js-ide-commit-mode").click
- find('.multi-file-commit-list-item').hover
- click_button 'Stage'
+ find(".multi-file-commit-list-item").hover
+ click_button "Stage"
- fill_in('commit-message', with: 'commit message ide')
+ fill_in("commit-message", with: "commit message ide")
- click_button('Commit')
+ click_button("Commit")
- expect(page).to have_content('file name')
+ expect(page).to have_content("file name")
end
end
diff --git a/spec/features/projects/tree/rss_spec.rb b/spec/features/projects/tree/rss_spec.rb
index 022167d9c5f..c7876458203 100644
--- a/spec/features/projects/tree/rss_spec.rb
+++ b/spec/features/projects/tree/rss_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project Tree RSS' do
+describe "Project Tree RSS" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let(:path) { project_tree_path(project, :master) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_developer(user)
sign_in(user)
@@ -15,7 +15,7 @@ describe 'Project Tree RSS' do
it_behaves_like "an autodiscoverable RSS feed with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/projects/tree/tree_show_spec.rb b/spec/features/projects/tree/tree_show_spec.rb
index 45e81e1c040..7c74815b788 100644
--- a/spec/features/projects/tree/tree_show_spec.rb
+++ b/spec/features/projects/tree/tree_show_spec.rb
@@ -1,99 +1,99 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects tree', :js do
+describe "Projects tree", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
# This commit has a known state on the master branch of gitlab-test
- let(:test_sha) { '7975be0116940bf2ad4321f79d02a55c5f7779aa' }
+ let(:test_sha) { "7975be0116940bf2ad4321f79d02a55c5f7779aa" }
before do
project.add_maintainer(user)
sign_in(user)
end
- it 'renders tree table without errors' do
+ it "renders tree table without errors" do
visit project_tree_path(project, test_sha)
wait_for_requests
- expect(page).to have_selector('.tree-item')
- expect(page).to have_content('add tests for .gitattributes custom highlighting')
- expect(page).not_to have_selector('.flash-alert')
- expect(page).not_to have_selector('.label-lfs', text: 'LFS')
+ expect(page).to have_selector(".tree-item")
+ expect(page).to have_content("add tests for .gitattributes custom highlighting")
+ expect(page).not_to have_selector(".flash-alert")
+ expect(page).not_to have_selector(".label-lfs", text: "LFS")
end
- it 'renders tree table for a subtree without errors' do
- visit project_tree_path(project, File.join(test_sha, 'files'))
+ it "renders tree table for a subtree without errors" do
+ visit project_tree_path(project, File.join(test_sha, "files"))
wait_for_requests
- expect(page).to have_selector('.tree-item')
- expect(page).to have_content('add spaces in whitespace file')
- expect(page).not_to have_selector('.label-lfs', text: 'LFS')
- expect(page).not_to have_selector('.flash-alert')
+ expect(page).to have_selector(".tree-item")
+ expect(page).to have_content("add spaces in whitespace file")
+ expect(page).not_to have_selector(".label-lfs", text: "LFS")
+ expect(page).not_to have_selector(".flash-alert")
end
- context 'for signed commit' do
- it 'displays a GPG badge' do
- visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ context "for signed commit" do
+ it "displays a GPG badge" do
+ visit project_tree_path(project, "33f3729a45c02fc67d00adb1b8bca394b0e761d9")
wait_for_requests
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
- context 'on a directory that has not changed recently' do
- it 'displays a GPG badge' do
- tree_path = File.join('eee736adc74341c5d3e26cd0438bc697f26a7575', 'subdir')
+ context "on a directory that has not changed recently" do
+ it "displays a GPG badge" do
+ tree_path = File.join("eee736adc74341c5d3e26cd0438bc697f26a7575", "subdir")
visit project_tree_path(project, tree_path)
wait_for_requests
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
end
- context 'LFS' do
- it 'renders LFS badge on blob item' do
- visit project_tree_path(project, File.join('master', 'files/lfs'))
+ context "LFS" do
+ it "renders LFS badge on blob item" do
+ visit project_tree_path(project, File.join("master", "files/lfs"))
- expect(page).to have_selector('.label-lfs', text: 'LFS')
+ expect(page).to have_selector(".label-lfs", text: "LFS")
end
end
- context 'web IDE' do
- it 'opens folder in IDE' do
- visit project_tree_path(project, File.join('master', 'bar'))
+ context "web IDE" do
+ it "opens folder in IDE" do
+ visit project_tree_path(project, File.join("master", "bar"))
- click_link 'Web IDE'
+ click_link "Web IDE"
wait_for_requests
- find('.ide-file-list')
+ find(".ide-file-list")
wait_for_requests
- expect(page).to have_selector('.is-open', text: 'bar')
+ expect(page).to have_selector(".is-open", text: "bar")
end
end
- context 'for subgroups' do
+ context "for subgroups" do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, :repository, group: subgroup) }
- it 'renders tree table without errors' do
- visit project_tree_path(project, 'master')
+ it "renders tree table without errors" do
+ visit project_tree_path(project, "master")
wait_for_requests
- expect(page).to have_selector('.tree-item')
- expect(page).not_to have_selector('.flash-alert')
+ expect(page).to have_selector(".tree-item")
+ expect(page).not_to have_selector(".flash-alert")
end
- context 'for signed commit' do
- it 'displays a GPG badge' do
- visit project_tree_path(project, '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ context "for signed commit" do
+ it "displays a GPG badge" do
+ visit project_tree_path(project, "33f3729a45c02fc67d00adb1b8bca394b0e761d9")
wait_for_requests
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
end
diff --git a/spec/features/projects/tree/upload_file_spec.rb b/spec/features/projects/tree/upload_file_spec.rb
index dcf7d314f8e..a5e4c34da7c 100644
--- a/spec/features/projects/tree/upload_file_spec.rb
+++ b/spec/features/projects/tree/upload_file_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Multi-file editor upload file', :js do
+describe "Multi-file editor upload file", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:txt_file) { File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt') }
- let(:img_file) { File.join(Rails.root, 'spec', 'fixtures', 'dk.png') }
+ let(:txt_file) { File.join(Rails.root, "spec", "fixtures", "doc_sample.txt") }
+ let(:img_file) { File.join(Rails.root, "spec", "fixtures", "dk.png") }
before do
project.add_maintainer(user)
@@ -14,21 +14,21 @@ describe 'Multi-file editor upload file', :js do
wait_for_requests
- click_link('Web IDE')
+ click_link("Web IDE")
wait_for_requests
end
after do
- set_cookie('new_repo', 'false')
+ set_cookie("new_repo", "false")
end
- it 'uploads text file' do
+ it "uploads text file" do
# make the field visible so capybara can use it
execute_script('document.querySelector("#file-upload").classList.remove("hidden")')
- attach_file('file-upload', txt_file)
+ attach_file("file-upload", txt_file)
- expect(page).to have_selector('.multi-file-tab', text: 'doc_sample.txt')
- expect(find('.blob-editor-container .lines-content')['innerText']).to have_content(File.open(txt_file, &:readline))
+ expect(page).to have_selector(".multi-file-tab", text: "doc_sample.txt")
+ expect(find(".blob-editor-container .lines-content")["innerText"]).to have_content(File.open(txt_file, &:readline))
end
end
diff --git a/spec/features/projects/user_creates_project_spec.rb b/spec/features/projects/user_creates_project_spec.rb
index 8d7e2883b2a..cc882c8c295 100644
--- a/spec/features/projects/user_creates_project_spec.rb
+++ b/spec/features/projects/user_creates_project_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User creates a project', :js do
+describe "User creates a project", :js do
let(:user) { create(:user) }
before do
@@ -8,25 +8,25 @@ describe 'User creates a project', :js do
create(:personal_key, user: user)
end
- it 'creates a new project' do
+ it "creates a new project" do
visit(new_project_path)
- fill_in(:project_name, with: 'Empty')
+ fill_in(:project_name, with: "Empty")
- page.within('#content-body') do
- click_button('Create project')
+ page.within("#content-body") do
+ click_button("Create project")
end
project = Project.last
expect(current_path).to eq(project_path(project))
- expect(page).to have_content('Empty')
- expect(page).to have_content('git init')
- expect(page).to have_content('git remote')
+ expect(page).to have_content("Empty")
+ expect(page).to have_content("git init")
+ expect(page).to have_content("git remote")
expect(page).to have_content(project.url_to_repo)
end
- context 'in a subgroup they do not own', :nested_groups do
+ context "in a subgroup they do not own", :nested_groups do
let(:parent) { create(:group) }
let!(:subgroup) { create(:group, parent: parent) }
@@ -34,17 +34,17 @@ describe 'User creates a project', :js do
parent.add_owner(user)
end
- it 'creates a new project' do
+ it "creates a new project" do
visit(new_project_path)
- fill_in :project_name, with: 'A Subgroup Project'
- fill_in :project_path, with: 'a-subgroup-project'
+ fill_in :project_name, with: "A Subgroup Project"
+ fill_in :project_path, with: "a-subgroup-project"
- page.find('.js-select-namespace').click
+ page.find(".js-select-namespace").click
page.find("div[role='option']", text: subgroup.full_path).click
- page.within('#content-body') do
- click_button('Create project')
+ page.within("#content-body") do
+ click_button("Create project")
end
expect(page).to have_content("Project 'A Subgroup Project' was successfully created")
diff --git a/spec/features/projects/user_sees_sidebar_spec.rb b/spec/features/projects/user_sees_sidebar_spec.rb
index ee5734a9bf1..0b49e73cb60 100644
--- a/spec/features/projects/user_sees_sidebar_spec.rb
+++ b/spec/features/projects/user_sees_sidebar_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > User sees sidebar' do
+describe "Projects > User sees sidebar" do
let(:user) { create(:user) }
let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) }
- context 'as owner' do
+ context "as owner" do
before do
sign_in(user)
end
- context 'when snippets are disabled' do
+ context "when snippets are disabled" do
before do
- project.project_feature.update_attribute('snippets_access_level', ProjectFeature::DISABLED)
+ project.project_feature.update_attribute("snippets_access_level", ProjectFeature::DISABLED)
end
it 'does not display a "Snippets" link' do
visit project_path(project)
- within('.nav-sidebar') do
- expect(page).not_to have_content 'Snippets'
+ within(".nav-sidebar") do
+ expect(page).not_to have_content "Snippets"
end
end
end
end
- context 'as guest' do
+ context "as guest" do
let(:guest) { create(:user) }
before do
@@ -33,49 +33,49 @@ describe 'Projects > User sees sidebar' do
sign_in(guest)
end
- it 'shows allowed tabs only' do
+ it "shows allowed tabs only" do
visit project_path(project)
- within('.nav-sidebar') do
- expect(page).to have_content 'Project'
- expect(page).to have_content 'Issues'
- expect(page).to have_content 'Wiki'
+ within(".nav-sidebar") do
+ expect(page).to have_content "Project"
+ expect(page).to have_content "Issues"
+ expect(page).to have_content "Wiki"
- expect(page).not_to have_content 'Repository'
- expect(page).not_to have_content 'CI / CD'
- expect(page).not_to have_content 'Merge Requests'
- expect(page).not_to have_content 'Operations'
+ expect(page).not_to have_content "Repository"
+ expect(page).not_to have_content "CI / CD"
+ expect(page).not_to have_content "Merge Requests"
+ expect(page).not_to have_content "Operations"
end
end
- it 'shows build tab if builds are public' do
+ it "shows build tab if builds are public" do
project.public_builds = true
project.save
visit project_path(project)
- within('.nav-sidebar') do
- expect(page).to have_content 'CI / CD'
+ within(".nav-sidebar") do
+ expect(page).to have_content "CI / CD"
end
end
- it 'does not show fork button' do
+ it "does not show fork button" do
visit project_path(project)
- within('.count-buttons') do
- expect(page).not_to have_link 'Fork'
+ within(".count-buttons") do
+ expect(page).not_to have_link "Fork"
end
end
- it 'does not show clone path' do
+ it "does not show clone path" do
visit project_path(project)
- within('.project-repo-buttons') do
- expect(page).not_to have_selector '.project-clone-holder'
+ within(".project-repo-buttons") do
+ expect(page).not_to have_selector ".project-clone-holder"
end
end
- describe 'project landing page' do
+ describe "project landing page" do
before do
project.project_feature.update!(
issues_access_level: ProjectFeature::DISABLED,
@@ -83,35 +83,35 @@ describe 'Projects > User sees sidebar' do
)
end
- it 'does not show the project file list landing page' do
+ it "does not show the project file list landing page" do
visit project_path(project)
- expect(page).not_to have_selector '.project-stats'
- expect(page).not_to have_selector '.project-last-commit'
- expect(page).not_to have_selector '.project-show-files'
- expect(page).to have_selector '.project-show-customize_workflow'
+ expect(page).not_to have_selector ".project-stats"
+ expect(page).not_to have_selector ".project-last-commit"
+ expect(page).not_to have_selector ".project-show-files"
+ expect(page).to have_selector ".project-show-customize_workflow"
end
- it 'shows the customize workflow when issues and wiki are disabled' do
+ it "shows the customize workflow when issues and wiki are disabled" do
visit project_path(project)
- expect(page).to have_selector '.project-show-customize_workflow'
+ expect(page).to have_selector ".project-show-customize_workflow"
end
- it 'shows the wiki when enabled' do
+ it "shows the wiki when enabled" do
project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
- expect(page).to have_selector '.project-show-wiki'
+ expect(page).to have_selector ".project-show-wiki"
end
- it 'shows the issues when enabled' do
+ it "shows the issues when enabled" do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
visit project_path(project)
- expect(page).to have_selector '.issues-list'
+ expect(page).to have_selector ".issues-list"
end
end
end
diff --git a/spec/features/projects/user_uses_shortcuts_spec.rb b/spec/features/projects/user_uses_shortcuts_spec.rb
index 64f9a4fcd39..33032810cf6 100644
--- a/spec/features/projects/user_uses_shortcuts_spec.rb
+++ b/spec/features/projects/user_uses_shortcuts_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User uses shortcuts', :js do
+describe "User uses shortcuts", :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -13,145 +13,145 @@ describe 'User uses shortcuts', :js do
wait_for_requests
end
- context 'when navigating to the Project pages' do
- it 'redirects to the details page' do
+ context "when navigating to the Project pages" do
+ it "redirects to the details page" do
visit project_issues_path(project)
- find('body').native.send_key('g')
- find('body').native.send_key('p')
+ find("body").native.send_key("g")
+ find("body").native.send_key("p")
- expect(page).to have_active_navigation('Project')
- expect(page).to have_active_sub_navigation('Details')
+ expect(page).to have_active_navigation("Project")
+ expect(page).to have_active_sub_navigation("Details")
end
- it 'redirects to the activity page' do
- find('body').native.send_key('g')
- find('body').native.send_key('v')
+ it "redirects to the activity page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("v")
- expect(page).to have_active_navigation('Project')
- expect(page).to have_active_sub_navigation('Activity')
+ expect(page).to have_active_navigation("Project")
+ expect(page).to have_active_sub_navigation("Activity")
end
end
- context 'when navigating to the Repository pages' do
- it 'redirects to the repository files page' do
- find('body').native.send_key('g')
- find('body').native.send_key('f')
+ context "when navigating to the Repository pages" do
+ it "redirects to the repository files page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("f")
- expect(page).to have_active_navigation('Repository')
- expect(page).to have_active_sub_navigation('Files')
+ expect(page).to have_active_navigation("Repository")
+ expect(page).to have_active_sub_navigation("Files")
end
- it 'redirects to the repository commits page' do
- find('body').native.send_key('g')
- find('body').native.send_key('c')
+ it "redirects to the repository commits page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("c")
- expect(page).to have_active_navigation('Repository')
- expect(page).to have_active_sub_navigation('Commits')
+ expect(page).to have_active_navigation("Repository")
+ expect(page).to have_active_sub_navigation("Commits")
end
- it 'redirects to the repository graph page' do
- find('body').native.send_key('g')
- find('body').native.send_key('n')
+ it "redirects to the repository graph page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("n")
- expect(page).to have_active_navigation('Repository')
- expect(page).to have_active_sub_navigation('Graph')
+ expect(page).to have_active_navigation("Repository")
+ expect(page).to have_active_sub_navigation("Graph")
end
- it 'redirects to the repository charts page' do
- find('body').native.send_key('g')
- find('body').native.send_key('d')
+ it "redirects to the repository charts page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("d")
- expect(page).to have_active_navigation('Repository')
- expect(page).to have_active_sub_navigation('Charts')
+ expect(page).to have_active_navigation("Repository")
+ expect(page).to have_active_sub_navigation("Charts")
end
end
- context 'when navigating to the Issues pages' do
- it 'redirects to the issues list page' do
- find('body').native.send_key('g')
- find('body').native.send_key('i')
+ context "when navigating to the Issues pages" do
+ it "redirects to the issues list page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("i")
- expect(page).to have_active_navigation('Issues')
- expect(page).to have_active_sub_navigation('List')
+ expect(page).to have_active_navigation("Issues")
+ expect(page).to have_active_sub_navigation("List")
end
- it 'redirects to the issue board page' do
- find('body').native.send_key('g')
- find('body').native.send_key('b')
+ it "redirects to the issue board page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("b")
- expect(page).to have_active_navigation('Issues')
- expect(page).to have_active_sub_navigation('Board')
+ expect(page).to have_active_navigation("Issues")
+ expect(page).to have_active_sub_navigation("Board")
end
- it 'redirects to the new issue page' do
- find('body').native.send_key('i')
+ it "redirects to the new issue page" do
+ find("body").native.send_key("i")
expect(page).to have_content(project.title)
- expect(page).to have_content('New Issue')
+ expect(page).to have_content("New Issue")
end
end
- context 'when navigating to the Merge Requests pages' do
- it 'redirects to the merge requests page' do
- find('body').native.send_key('g')
- find('body').native.send_key('m')
+ context "when navigating to the Merge Requests pages" do
+ it "redirects to the merge requests page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("m")
- expect(page).to have_active_navigation('Merge Requests')
+ expect(page).to have_active_navigation("Merge Requests")
end
end
- context 'when navigating to the CI / CD pages' do
- it 'redirects to the Jobs page' do
- find('body').native.send_key('g')
- find('body').native.send_key('j')
+ context "when navigating to the CI / CD pages" do
+ it "redirects to the Jobs page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("j")
- expect(page).to have_active_navigation('CI / CD')
- expect(page).to have_active_sub_navigation('Jobs')
+ expect(page).to have_active_navigation("CI / CD")
+ expect(page).to have_active_sub_navigation("Jobs")
end
end
- context 'when navigating to the Operations pages' do
- it 'redirects to the Metrics page' do
- find('body').native.send_key('g')
- find('body').native.send_key('l')
+ context "when navigating to the Operations pages" do
+ it "redirects to the Metrics page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("l")
- expect(page).to have_active_navigation('Operations')
- expect(page).to have_active_sub_navigation('Metrics')
+ expect(page).to have_active_navigation("Operations")
+ expect(page).to have_active_sub_navigation("Metrics")
end
- it 'redirects to the Environments page' do
- find('body').native.send_key('g')
- find('body').native.send_key('e')
+ it "redirects to the Environments page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("e")
- expect(page).to have_active_navigation('Operations')
- expect(page).to have_active_sub_navigation('Environments')
+ expect(page).to have_active_navigation("Operations")
+ expect(page).to have_active_sub_navigation("Environments")
end
- it 'redirects to the Kubernetes page' do
- find('body').native.send_key('g')
- find('body').native.send_key('k')
+ it "redirects to the Kubernetes page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("k")
- expect(page).to have_active_navigation('Operations')
- expect(page).to have_active_sub_navigation('Kubernetes')
+ expect(page).to have_active_navigation("Operations")
+ expect(page).to have_active_sub_navigation("Kubernetes")
end
end
- context 'when navigating to the Snippets pages' do
- it 'redirects to the snippets page' do
- find('body').native.send_key('g')
- find('body').native.send_key('s')
+ context "when navigating to the Snippets pages" do
+ it "redirects to the snippets page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("s")
- expect(page).to have_active_navigation('Snippets')
+ expect(page).to have_active_navigation("Snippets")
end
end
- context 'when navigating to the Wiki pages' do
- it 'redirects to the wiki page' do
- find('body').native.send_key('g')
- find('body').native.send_key('w')
+ context "when navigating to the Wiki pages" do
+ it "redirects to the wiki page" do
+ find("body").native.send_key("g")
+ find("body").native.send_key("w")
- expect(page).to have_active_navigation('Wiki')
+ expect(page).to have_active_navigation("Wiki")
end
end
end
diff --git a/spec/features/projects/user_views_empty_project_spec.rb b/spec/features/projects/user_views_empty_project_spec.rb
index b7c0834d33a..db93566599b 100644
--- a/spec/features/projects/user_views_empty_project_spec.rb
+++ b/spec/features/projects/user_views_empty_project_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views an empty project' do
+describe "User views an empty project" do
let(:project) { create(:project, :empty_repo) }
let(:user) { create(:user) }
- shared_examples 'allowing push to default branch' do
+ shared_examples "allowing push to default branch" do
before do
sign_in(user)
visit project_path(project)
end
- it 'shows push-to-master instructions' do
- expect(page).to have_content('git push -u origin master')
+ it "shows push-to-master instructions" do
+ expect(page).to have_content("git push -u origin master")
end
end
- describe 'as a maintainer' do
+ describe "as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'allowing push to default branch'
+ it_behaves_like "allowing push to default branch"
end
- describe 'as an admin' do
+ describe "as an admin" do
let(:user) { create(:user, :admin) }
- it_behaves_like 'allowing push to default branch'
+ it_behaves_like "allowing push to default branch"
end
- describe 'as a developer' do
+ describe "as a developer" do
before do
project.add_developer(user)
sign_in(user)
visit project_path(project)
end
- it 'does not show push-to-master instructions' do
- expect(page).not_to have_content('git push -u origin master')
+ it "does not show push-to-master instructions" do
+ expect(page).not_to have_content("git push -u origin master")
end
end
end
diff --git a/spec/features/projects/view_on_env_spec.rb b/spec/features/projects/view_on_env_spec.rb
index 7bfcd46713e..a974e846d4e 100644
--- a/spec/features/projects/view_on_env_spec.rb
+++ b/spec/features/projects/view_on_env_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'View on environment', :js do
- let(:branch_name) { 'feature' }
- let(:file_path) { 'files/ruby/feature.rb' }
+describe "View on environment", :js do
+ let(:branch_name) { "feature" }
+ let(:file_path) { "files/ruby/feature.rb" }
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
@@ -10,7 +10,7 @@ describe 'View on environment', :js do
project.add_maintainer(user)
end
- context 'when the branch has a route map' do
+ context "when the branch has a route map" do
let(:route_map) do
<<-MAP.strip_heredoc
- source: /files/(.*)\\..*/
@@ -25,7 +25,7 @@ describe 'View on environment', :js do
start_branch: branch_name,
branch_name: branch_name,
commit_message: "Add .gitlab/route-map.yml",
- file_path: '.gitlab/route-map.yml',
+ file_path: ".gitlab/route-map.yml",
file_content: route_map
).execute
@@ -41,12 +41,12 @@ describe 'View on environment', :js do
).execute
end
- context 'and an active deployment' do
+ context "and an active deployment" do
let(:sha) { project.commit(branch_name).sha }
- let(:environment) { create(:environment, project: project, name: 'review/feature', external_url: 'http://feature.review.example.com') }
+ let(:environment) { create(:environment, project: project, name: "review/feature", external_url: "http://feature.review.example.com") }
let!(:deployment) { create(:deployment, :success, environment: environment, ref: branch_name, sha: sha) }
- context 'when visiting the diff of a merge request for the branch' do
+ context "when visiting the diff of a merge request for the branch" do
let(:merge_request) { create(:merge_request, :simple, source_project: project, source_branch: branch_name) }
before do
@@ -58,43 +58,43 @@ describe 'View on environment', :js do
end
it 'has a "View on env" button' do
- within '.diffs' do
- text = 'View on feature.review.example.com'
- url = 'http://feature.review.example.com/ruby/feature'
+ within ".diffs" do
+ text = "View on feature.review.example.com"
+ url = "http://feature.review.example.com/ruby/feature"
expect(page).to have_selector("a[data-original-title='#{text}'][href='#{url}']")
end
end
end
- context 'when visiting a comparison for the branch' do
+ context "when visiting a comparison for the branch" do
before do
sign_in(user)
- visit project_compare_path(project, from: 'master', to: branch_name)
+ visit project_compare_path(project, from: "master", to: branch_name)
wait_for_requests
end
it 'has a "View on env" button' do
- expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
+ expect(page).to have_link("View on feature.review.example.com", href: "http://feature.review.example.com/ruby/feature")
end
end
- context 'when visiting a comparison for the commit' do
+ context "when visiting a comparison for the commit" do
before do
sign_in(user)
- visit project_compare_path(project, from: 'master', to: sha)
+ visit project_compare_path(project, from: "master", to: sha)
wait_for_requests
end
it 'has a "View on env" button' do
- expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
+ expect(page).to have_link("View on feature.review.example.com", href: "http://feature.review.example.com/ruby/feature")
end
end
- context 'when visiting a blob on the branch' do
+ context "when visiting a blob on the branch" do
before do
sign_in(user)
@@ -104,11 +104,11 @@ describe 'View on environment', :js do
end
it 'has a "View on env" button' do
- expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
+ expect(page).to have_link("View on feature.review.example.com", href: "http://feature.review.example.com/ruby/feature")
end
end
- context 'when visiting a blob on the commit' do
+ context "when visiting a blob on the commit" do
before do
sign_in(user)
@@ -118,11 +118,11 @@ describe 'View on environment', :js do
end
it 'has a "View on env" button' do
- expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
+ expect(page).to have_link("View on feature.review.example.com", href: "http://feature.review.example.com/ruby/feature")
end
end
- context 'when visiting the commit' do
+ context "when visiting the commit" do
before do
sign_in(user)
@@ -132,7 +132,7 @@ describe 'View on environment', :js do
end
it 'has a "View on env" button' do
- expect(page).to have_link('View on feature.review.example.com', href: 'http://feature.review.example.com/ruby/feature')
+ expect(page).to have_link("View on feature.review.example.com", href: "http://feature.review.example.com/ruby/feature")
end
end
end
diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb
index 49058d1372a..33aa5d30d23 100644
--- a/spec/features/projects/wiki/markdown_preview_spec.rb
+++ b/spec/features/projects/wiki/markdown_preview_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Wiki > User previews markdown changes', :js do
+describe "Projects > Wiki > User previews markdown changes", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
- let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' }) }
+ let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: {title: "home", content: "[some link](other-page)"}) }
let(:wiki_content) do
- <<-HEREDOC
-[regular link](regular)
-[relative link 1](../relative)
-[relative link 2](./relative)
-[relative link 3](./e/f/relative)
-[spaced link](title with spaces)
+ <<~HEREDOC
+ [regular link](regular)
+ [relative link 1](../relative)
+ [relative link 2](./relative)
+ [relative link 3](./e/f/relative)
+ [spaced link](title with spaces)
HEREDOC
end
@@ -25,13 +25,13 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "while creating a new wiki page" do
context "when there are no spaces or hyphens in the page name" do
it "rewrites relative links as expected" do
- find('.add-new-wiki').click
- page.within '#modal-new-wiki' do
- fill_in :new_wiki_path, with: 'a/b/c/d'
- click_button 'Create page'
+ find(".add-new-wiki").click
+ page.within "#modal-new-wiki" do
+ fill_in :new_wiki_path, with: "a/b/c/d"
+ click_button "Create page"
end
- page.within '.wiki-form' do
+ page.within ".wiki-form" do
fill_in :wiki_content, with: wiki_content
click_on "Preview"
end
@@ -48,13 +48,13 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "when there are spaces in the page name" do
it "rewrites relative links as expected" do
- click_link 'New page'
- page.within '#modal-new-wiki' do
- fill_in :new_wiki_path, with: 'a page/b page/c page/d page'
- click_button 'Create page'
+ click_link "New page"
+ page.within "#modal-new-wiki" do
+ fill_in :new_wiki_path, with: "a page/b page/c page/d page"
+ click_button "Create page"
end
- page.within '.wiki-form' do
+ page.within ".wiki-form" do
fill_in :wiki_content, with: wiki_content
click_on "Preview"
end
@@ -71,13 +71,13 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "when there are hyphens in the page name" do
it "rewrites relative links as expected" do
- click_link 'New page'
- page.within '#modal-new-wiki' do
- fill_in :new_wiki_path, with: 'a-page/b-page/c-page/d-page'
- click_button 'Create page'
+ click_link "New page"
+ page.within "#modal-new-wiki" do
+ fill_in :new_wiki_path, with: "a-page/b-page/c-page/d-page"
+ click_button "Create page"
end
- page.within '.wiki-form' do
+ page.within ".wiki-form" do
fill_in :wiki_content, with: wiki_content
click_on "Preview"
end
@@ -95,23 +95,23 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "while editing a wiki page" do
def create_wiki_page(path)
- find('.add-new-wiki').click
+ find(".add-new-wiki").click
- page.within '#modal-new-wiki' do
+ page.within "#modal-new-wiki" do
fill_in :new_wiki_path, with: path
- click_button 'Create page'
+ click_button "Create page"
end
- page.within '.wiki-form' do
- fill_in :wiki_content, with: 'content'
+ page.within ".wiki-form" do
+ fill_in :wiki_content, with: "content"
click_on "Create page"
end
end
context "when there are no spaces or hyphens in the page name" do
it "rewrites relative links as expected" do
- create_wiki_page 'a/b/c/d'
- click_link 'Edit'
+ create_wiki_page "a/b/c/d"
+ click_link "Edit"
fill_in :wiki_content, with: wiki_content
click_on "Preview"
@@ -128,8 +128,8 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "when there are spaces in the page name" do
it "rewrites relative links as expected" do
- create_wiki_page 'a page/b page/c page/d page'
- click_link 'Edit'
+ create_wiki_page "a page/b page/c page/d page"
+ click_link "Edit"
fill_in :wiki_content, with: wiki_content
click_on "Preview"
@@ -146,8 +146,8 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
context "when there are hyphens in the page name" do
it "rewrites relative links as expected" do
- create_wiki_page 'a-page/b-page/c-page/d-page'
- click_link 'Edit'
+ create_wiki_page "a-page/b-page/c-page/d-page"
+ click_link "Edit"
fill_in :wiki_content, with: wiki_content
click_on "Preview"
@@ -162,10 +162,10 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
end
end
- context 'when rendering the preview' do
- it 'renders content with CommonMark' do
- create_wiki_page 'a-page/b-page/c-page/common-mark'
- click_link 'Edit'
+ context "when rendering the preview" do
+ it "renders content with CommonMark" do
+ create_wiki_page "a-page/b-page/c-page/common-mark"
+ click_link "Edit"
fill_in :wiki_content, with: "1. one\n - sublist\n"
click_on "Preview"
@@ -178,13 +178,13 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
end
it "does not linkify double brackets inside code blocks as expected" do
- click_link 'New page'
- page.within '#modal-new-wiki' do
- fill_in :new_wiki_path, with: 'linkify_test'
- click_button 'Create page'
+ click_link "New page"
+ page.within "#modal-new-wiki" do
+ fill_in :new_wiki_path, with: "linkify_test"
+ click_button "Create page"
end
- page.within '.wiki-form' do
+ page.within ".wiki-form" do
fill_in :wiki_content, with: <<-HEREDOC
`[[do_not_linkify]]`
```
@@ -196,7 +196,7 @@ describe 'Projects > Wiki > User previews markdown changes', :js do
expect(page).to have_content("do_not_linkify")
- expect(page.html).to include('[[do_not_linkify]]')
- expect(page.html).to include('[[also_do_not_linkify]]')
+ expect(page.html).to include("[[do_not_linkify]]")
+ expect(page.html).to include("[[also_do_not_linkify]]")
end
end
diff --git a/spec/features/projects/wiki/shortcuts_spec.rb b/spec/features/projects/wiki/shortcuts_spec.rb
index c01be1f14ed..d01a2f98a0f 100644
--- a/spec/features/projects/wiki/shortcuts_spec.rb
+++ b/spec/features/projects/wiki/shortcuts_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Wiki shortcuts', :js do
+describe "Wiki shortcuts", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
- let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' }) }
+ let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: {title: "home", content: "Home page"}) }
before do
sign_in(user)
@@ -11,8 +11,8 @@ describe 'Wiki shortcuts', :js do
end
it 'Visit edit wiki page using "e" keyboard shortcut' do
- find('body').native.send_key('e')
+ find("body").native.send_key("e")
- expect(find('.wiki-page-title')).to have_content('Edit Page')
+ expect(find(".wiki-page-title")).to have_content("Edit Page")
end
end
diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb
index b1a7f167977..464310d7ea0 100644
--- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb
+++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb
@@ -70,9 +70,9 @@ describe "User creates wiki page" do
expect(current_path).to eq(project_wiki_path(project, "home"))
expect(page).to have_content("test GitLab API doc Rake tasks Wiki header")
- .and have_content("Home")
- .and have_content("Last edited by #{user.name}")
- .and have_header_with_correct_id_and_link(1, "Wiki header", "wiki-header")
+ .and have_content("Home")
+ .and have_content("Last edited by #{user.name}")
+ .and have_header_with_correct_id_and_link(1, "Wiki header", "wiki-header")
click_link("test")
@@ -141,7 +141,7 @@ describe "User creates wiki page" do
end
end
- it_behaves_like 'wiki file attachments'
+ it_behaves_like "wiki file attachments"
end
context "in a group namespace", :js do
@@ -159,15 +159,15 @@ describe "User creates wiki page" do
end
expect(page).to have_content("Home")
- .and have_content("Last edited by #{user.name}")
- .and have_content("My awesome wiki!")
+ .and have_content("Last edited by #{user.name}")
+ .and have_content("My awesome wiki!")
end
end
end
context "when wiki is not empty", :js do
before do
- create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: 'Home page' })
+ create(:wiki_page, wiki: wiki, attrs: {title: "home", content: "Home page"})
visit(project_wikis_path(project))
end
@@ -195,8 +195,8 @@ describe "User creates wiki page" do
end
expect(page).to have_content("foo")
- .and have_content("Last edited by #{user.name}")
- .and have_content("My awesome wiki!")
+ .and have_content("Last edited by #{user.name}")
+ .and have_content("My awesome wiki!")
end
it "creates a page with spaces in the name" do
@@ -218,8 +218,8 @@ describe "User creates wiki page" do
end
expect(page).to have_content("Spaces in the name")
- .and have_content("Last edited by #{user.name}")
- .and have_content("My awesome wiki!")
+ .and have_content("Last edited by #{user.name}")
+ .and have_content("My awesome wiki!")
end
it "creates a page with hyphens in the name" do
@@ -241,8 +241,8 @@ describe "User creates wiki page" do
end
expect(page).to have_content("hyphens in the name")
- .and have_content("Last edited by #{user.name}")
- .and have_content("My awesome wiki!")
+ .and have_content("Last edited by #{user.name}")
+ .and have_content("My awesome wiki!")
end
end
@@ -288,38 +288,38 @@ describe "User creates wiki page" do
end
expect(page).to have_content("foo")
- .and have_content("Last edited by #{user.name}")
- .and have_content("My awesome wiki!")
+ .and have_content("Last edited by #{user.name}")
+ .and have_content("My awesome wiki!")
end
end
end
end
- describe 'sidebar feature' do
- context 'when there are some existing pages' do
+ describe "sidebar feature" do
+ context "when there are some existing pages" do
before do
- create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: 'home' })
- create(:wiki_page, wiki: wiki, attrs: { title: 'another', content: 'another' })
+ create(:wiki_page, wiki: wiki, attrs: {title: "home", content: "home"})
+ create(:wiki_page, wiki: wiki, attrs: {title: "another", content: "another"})
end
- it 'renders a default sidebar when there is no customized sidebar' do
+ it "renders a default sidebar when there is no customized sidebar" do
visit(project_wikis_path(project))
- expect(page).to have_content('another')
- expect(page).to have_content('More Pages')
+ expect(page).to have_content("another")
+ expect(page).to have_content("More Pages")
end
- context 'when there is a customized sidebar' do
+ context "when there is a customized sidebar" do
before do
- create(:wiki_page, wiki: wiki, attrs: { title: '_sidebar', content: 'My customized sidebar' })
+ create(:wiki_page, wiki: wiki, attrs: {title: "_sidebar", content: "My customized sidebar"})
end
- it 'renders my customized sidebar instead of the default one' do
+ it "renders my customized sidebar instead of the default one" do
visit(project_wikis_path(project))
- expect(page).to have_content('My customized sidebar')
- expect(page).to have_content('More Pages')
- expect(page).not_to have_content('Another')
+ expect(page).to have_content("My customized sidebar")
+ expect(page).to have_content("More Pages")
+ expect(page).not_to have_content("Another")
end
end
end
diff --git a/spec/features/projects/wiki/user_deletes_wiki_page_spec.rb b/spec/features/projects/wiki/user_deletes_wiki_page_spec.rb
index 18ccd31f3d0..26a0c0bf911 100644
--- a/spec/features/projects/wiki/user_deletes_wiki_page_spec.rb
+++ b/spec/features/projects/wiki/user_deletes_wiki_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User deletes wiki page', :js do
+describe "User deletes wiki page", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
let(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
@@ -10,11 +10,11 @@ describe 'User deletes wiki page', :js do
visit(project_wiki_path(project, wiki_page))
end
- it 'deletes a page' do
- click_on('Edit')
- click_on('Delete')
- find('.modal-footer .btn-danger').click
+ it "deletes a page" do
+ click_on("Edit")
+ click_on("Delete")
+ find(".modal-footer .btn-danger").click
- expect(page).to have_content('Page was successfully deleted')
+ expect(page).to have_content("Page was successfully deleted")
end
end
diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb
index db97d59e918..7f2986e68af 100644
--- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb
+++ b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Wiki > User views Git access wiki page' do
+describe "Projects > Wiki > User views Git access wiki page" do
let(:user) { create(:user) }
let(:project) { create(:project, :wiki_repo, :public) }
- let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' }) }
+ let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: {title: "home", content: "[some link](other-page)"}) }
before do
sign_in(user)
end
- it 'Visit Wiki Page Current Commit' do
+ it "Visit Wiki Page Current Commit" do
visit project_wiki_path(project, wiki_page)
- click_link 'Clone repository'
+ click_link "Clone repository"
expect(page).to have_text("Clone repository #{project.wiki.full_path}")
expect(page).to have_text(project.wiki.http_url_to_repo)
end
diff --git a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb
index dbf8af3e5bb..8fcd1d8523f 100644
--- a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb
+++ b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User updates wiki page' do
+describe "User updates wiki page" do
let(:user) { create(:user) }
before do
@@ -8,211 +8,211 @@ describe 'User updates wiki page' do
sign_in(user)
end
- context 'when wiki is empty' do
+ context "when wiki is empty" do
before do
visit(project_wikis_path(project))
click_link "Create your first page"
end
- context 'in a user namespace' do
+ context "in a user namespace" do
let(:project) { create(:project, :wiki_repo) }
- it 'redirects back to the home edit page' do
- page.within(:css, '.wiki-form .form-actions') do
- click_on('Cancel')
+ it "redirects back to the home edit page" do
+ page.within(:css, ".wiki-form .form-actions") do
+ click_on("Cancel")
end
expect(current_path).to eq project_wiki_path(project, :home)
end
- it 'updates a page that has a path', :js do
- fill_in(:wiki_title, with: 'one/two/three-test')
+ it "updates a page that has a path", :js do
+ fill_in(:wiki_title, with: "one/two/three-test")
- page.within '.wiki-form' do
- fill_in(:wiki_content, with: 'wiki content')
- click_on('Create page')
+ page.within ".wiki-form" do
+ fill_in(:wiki_content, with: "wiki content")
+ click_on("Create page")
end
- expect(current_path).to include('one/two/three-test')
- expect(find('.wiki-pages')).to have_content('three')
+ expect(current_path).to include("one/two/three-test")
+ expect(find(".wiki-pages")).to have_content("three")
- first(:link, text: 'three').click
+ first(:link, text: "three").click
- expect(find('.nav-text')).to have_content('three')
+ expect(find(".nav-text")).to have_content("three")
- click_on('Edit')
+ click_on("Edit")
- expect(current_path).to include('one/two/three-test')
- expect(page).to have_content('Edit Page')
+ expect(current_path).to include("one/two/three-test")
+ expect(page).to have_content("Edit Page")
- fill_in('Content', with: 'Updated Wiki Content')
- click_on('Save changes')
+ fill_in("Content", with: "Updated Wiki Content")
+ click_on("Save changes")
- expect(page).to have_content('Updated Wiki Content')
+ expect(page).to have_content("Updated Wiki Content")
end
- it_behaves_like 'wiki file attachments'
+ it_behaves_like "wiki file attachments"
end
end
- context 'when wiki is not empty' do
+ context "when wiki is not empty" do
let(:project_wiki) { create(:project_wiki, project: project, user: project.creator) }
- let!(:wiki_page) { create(:wiki_page, wiki: project_wiki, attrs: { title: 'home', content: 'Home page' }) }
+ let!(:wiki_page) { create(:wiki_page, wiki: project_wiki, attrs: {title: "home", content: "Home page"}) }
before do
visit(project_wikis_path(project))
- click_link('Edit')
+ click_link("Edit")
end
- context 'in a user namespace' do
+ context "in a user namespace" do
let(:project) { create(:project, :wiki_repo) }
- it 'updates a page' do
+ it "updates a page" do
# Commit message field should have correct value.
- expect(page).to have_field('wiki[message]', with: 'Update home')
+ expect(page).to have_field("wiki[message]", with: "Update home")
- fill_in(:wiki_content, with: 'My awesome wiki!')
- click_button('Save changes')
+ fill_in(:wiki_content, with: "My awesome wiki!")
+ click_button("Save changes")
- expect(page).to have_content('Home')
+ expect(page).to have_content("Home")
expect(page).to have_content("Last edited by #{user.name}")
- expect(page).to have_content('My awesome wiki!')
+ expect(page).to have_content("My awesome wiki!")
end
- it 'shows a validation error message' do
- fill_in(:wiki_content, with: '')
- click_button('Save changes')
+ it "shows a validation error message" do
+ fill_in(:wiki_content, with: "")
+ click_button("Save changes")
- expect(page).to have_selector('.wiki-form')
- expect(page).to have_content('Edit Page')
- expect(page).to have_content('The form contains the following error:')
+ expect(page).to have_selector(".wiki-form")
+ expect(page).to have_content("Edit Page")
+ expect(page).to have_content("The form contains the following error:")
expect(page).to have_content("Content can't be blank")
- expect(find('textarea#wiki_content').value).to eq('')
+ expect(find("textarea#wiki_content").value).to eq("")
end
- it 'shows the emoji autocompletion dropdown', :js do
- find('#wiki_content').native.send_keys('')
- fill_in(:wiki_content, with: ':')
+ it "shows the emoji autocompletion dropdown", :js do
+ find("#wiki_content").native.send_keys("")
+ fill_in(:wiki_content, with: ":")
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
- it 'shows the error message' do
- wiki_page.update(content: 'Update')
+ it "shows the error message" do
+ wiki_page.update(content: "Update")
- click_button('Save changes')
+ click_button("Save changes")
- expect(page).to have_content('Someone edited the page the same time you did.')
+ expect(page).to have_content("Someone edited the page the same time you did.")
end
- it 'updates a page' do
- fill_in('Content', with: 'Updated Wiki Content')
- click_on('Save changes')
+ it "updates a page" do
+ fill_in("Content", with: "Updated Wiki Content")
+ click_on("Save changes")
- expect(page).to have_content('Updated Wiki Content')
+ expect(page).to have_content("Updated Wiki Content")
end
- it 'cancels editing of a page' do
- page.within(:css, '.wiki-form .form-actions') do
- click_on('Cancel')
+ it "cancels editing of a page" do
+ page.within(:css, ".wiki-form .form-actions") do
+ click_on("Cancel")
end
expect(current_path).to eq(project_wiki_path(project, wiki_page))
end
- it_behaves_like 'wiki file attachments'
+ it_behaves_like "wiki file attachments"
end
- context 'in a group namespace' do
+ context "in a group namespace" do
let(:project) { create(:project, :wiki_repo, namespace: create(:group, :public)) }
- it 'updates a page' do
+ it "updates a page" do
# Commit message field should have correct value.
- expect(page).to have_field('wiki[message]', with: 'Update home')
+ expect(page).to have_field("wiki[message]", with: "Update home")
- fill_in(:wiki_content, with: 'My awesome wiki!')
+ fill_in(:wiki_content, with: "My awesome wiki!")
- click_button('Save changes')
+ click_button("Save changes")
- expect(page).to have_content('Home')
+ expect(page).to have_content("Home")
expect(page).to have_content("Last edited by #{user.name}")
- expect(page).to have_content('My awesome wiki!')
+ expect(page).to have_content("My awesome wiki!")
end
- it_behaves_like 'wiki file attachments'
+ it_behaves_like "wiki file attachments"
end
end
- context 'when the page is in a subdir' do
+ context "when the page is in a subdir" do
let!(:project) { create(:project, :wiki_repo) }
let(:project_wiki) { create(:project_wiki, project: project, user: project.creator) }
- let(:page_name) { 'page_name' }
+ let(:page_name) { "page_name" }
let(:page_dir) { "foo/bar/#{page_name}" }
- let!(:wiki_page) { create(:wiki_page, wiki: project_wiki, attrs: { title: page_dir, content: 'Home page' }) }
+ let!(:wiki_page) { create(:wiki_page, wiki: project_wiki, attrs: {title: page_dir, content: "Home page"}) }
before do
visit(project_wiki_edit_path(project, wiki_page))
end
- it 'moves the page to the root folder' do
+ it "moves the page to the root folder" do
fill_in(:wiki_title, with: "/#{page_name}")
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(project_wiki_path(project, page_name))
end
- it 'moves the page to other dir' do
+ it "moves the page to other dir" do
new_page_dir = "foo1/bar1/#{page_name}"
fill_in(:wiki_title, with: new_page_dir)
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(project_wiki_path(project, new_page_dir))
end
- it 'remains in the same place if title has not changed' do
+ it "remains in the same place if title has not changed" do
original_path = project_wiki_path(project, wiki_page)
fill_in(:wiki_title, with: page_name)
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(original_path)
end
- it 'can be moved to a different dir with a different name' do
+ it "can be moved to a different dir with a different name" do
new_page_dir = "foo1/bar1/new_page_name"
fill_in(:wiki_title, with: new_page_dir)
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(project_wiki_path(project, new_page_dir))
end
- it 'can be renamed and moved to the root folder' do
- new_name = 'new_page_name'
+ it "can be renamed and moved to the root folder" do
+ new_name = "new_page_name"
fill_in(:wiki_title, with: "/#{new_name}")
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(project_wiki_path(project, new_name))
end
- it 'squishes the title before creating the page' do
+ it "squishes the title before creating the page" do
new_page_dir = " foo1 / bar1 / #{page_name} "
fill_in(:wiki_title, with: new_page_dir)
- click_button('Save changes')
+ click_button("Save changes")
expect(current_path).to eq(project_wiki_path(project, "foo1/bar1/#{page_name}"))
end
- it_behaves_like 'wiki file attachments'
+ it_behaves_like "wiki file attachments"
end
end
diff --git a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb
index e94b3a9432b..2e641593bb6 100644
--- a/spec/features/projects/wiki/user_views_wiki_empty_spec.rb
+++ b/spec/features/projects/wiki/user_views_wiki_empty_spec.rb
@@ -1,60 +1,60 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views empty wiki' do
+describe "User views empty wiki" do
let(:user) { create(:user) }
- shared_examples 'empty wiki and accessible issues' do
+ shared_examples "empty wiki and accessible issues" do
it 'show "issue tracker" message' do
visit(project_wikis_path(project))
- element = page.find('.row.empty-state')
+ element = page.find(".row.empty-state")
- expect(element).to have_content('This project has no wiki pages')
+ expect(element).to have_content("This project has no wiki pages")
expect(element).to have_link("issue tracker", href: project_issues_path(project))
expect(element).to have_link("Suggest wiki improvement", href: new_project_issue_path(project))
end
end
- shared_examples 'empty wiki and non-accessible issues' do
+ shared_examples "empty wiki and non-accessible issues" do
it 'does not show "issue tracker" message' do
visit(project_wikis_path(project))
- element = page.find('.row.empty-state')
+ element = page.find(".row.empty-state")
- expect(element).to have_content('This project has no wiki pages')
- expect(element).to have_no_link('Suggest wiki improvement')
+ expect(element).to have_content("This project has no wiki pages")
+ expect(element).to have_no_link("Suggest wiki improvement")
end
end
- context 'when user is logged out and issue tracker is public' do
+ context "when user is logged out and issue tracker is public" do
let(:project) { create(:project, :public, :wiki_repo) }
- it_behaves_like 'empty wiki and accessible issues'
+ it_behaves_like "empty wiki and accessible issues"
end
- context 'when user is logged in and not a member' do
+ context "when user is logged in and not a member" do
let(:project) { create(:project, :public, :wiki_repo) }
before do
sign_in(user)
end
- it_behaves_like 'empty wiki and accessible issues'
+ it_behaves_like "empty wiki and accessible issues"
end
- context 'when issue tracker is private' do
+ context "when issue tracker is private" do
let(:project) { create(:project, :public, :wiki_repo, :issues_private) }
- it_behaves_like 'empty wiki and non-accessible issues'
+ it_behaves_like "empty wiki and non-accessible issues"
end
- context 'when issue tracker is disabled' do
+ context "when issue tracker is disabled" do
let(:project) { create(:project, :public, :wiki_repo, :issues_disabled) }
- it_behaves_like 'empty wiki and non-accessible issues'
+ it_behaves_like "empty wiki and non-accessible issues"
end
- context 'when user is logged in and a member' do
+ context "when user is logged in and a member" do
let(:project) { create(:project, :public, :wiki_repo) }
before do
@@ -65,11 +65,11 @@ describe 'User views empty wiki' do
it 'show "create first page" message' do
visit(project_wikis_path(project))
- element = page.find('.row.empty-state')
+ element = page.find(".row.empty-state")
- element.click_link 'Create your first page'
+ element.click_link "Create your first page"
- expect(page).to have_button('Create page')
+ expect(page).to have_button("Create page")
end
end
end
diff --git a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb
index fb0ebe22bf7..2ef074e9343 100644
--- a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb
+++ b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects > Wiki > User views wiki in project page' do
+describe "Projects > Wiki > User views wiki in project page" do
let(:user) { create(:user) }
before do
@@ -8,25 +8,25 @@ describe 'Projects > Wiki > User views wiki in project page' do
sign_in(user)
end
- context 'when repository is disabled for project' do
+ context "when repository is disabled for project" do
let(:project) do
create(:project,
- :wiki_repo,
- :repository_disabled,
- :merge_requests_disabled,
- :builds_disabled)
+ :wiki_repo,
+ :repository_disabled,
+ :merge_requests_disabled,
+ :builds_disabled)
end
- context 'when wiki homepage contains a link' do
+ context "when wiki homepage contains a link" do
before do
- create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: '[some link](other-page)' })
+ create(:wiki_page, wiki: project.wiki, attrs: {title: "home", content: "[some link](other-page)"})
end
- it 'displays the correct URL for the link' do
+ it "displays the correct URL for the link" do
visit project_path(project)
expect(page).to have_link(
- 'some link',
- href: project_wiki_path(project, 'other-page')
+ "some link",
+ href: project_wiki_path(project, "other-page")
)
end
end
diff --git a/spec/features/projects/wiki/user_views_wiki_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_page_spec.rb
index 6e28ec0d7b2..ad3e0137671 100644
--- a/spec/features/projects/wiki/user_views_wiki_page_spec.rb
+++ b/spec/features/projects/wiki/user_views_wiki_page_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User views a wiki page' do
+describe "User views a wiki page" do
include WikiHelpers
let(:user) { create(:user) }
let(:project) { create(:project, :wiki_repo, namespace: user.namespace) }
- let(:path) { 'image.png' }
+ let(:path) { "image.png" }
let(:wiki_page) do
create(:wiki_page,
- wiki: project.wiki,
- attrs: { title: 'home', content: "Look at this [image](#{path})\n\n ![alt text](#{path})" })
+ wiki: project.wiki,
+ attrs: {title: "home", content: "Look at this [image](#{path})\n\n ![alt text](#{path})"})
end
before do
@@ -17,119 +17,119 @@ describe 'User views a wiki page' do
sign_in(user)
end
- context 'when wiki is empty' do
+ context "when wiki is empty" do
before do
visit(project_wikis_path(project))
click_link "Create your first page"
- fill_in(:wiki_title, with: 'one/two/three-test')
+ fill_in(:wiki_title, with: "one/two/three-test")
- page.within('.wiki-form') do
- fill_in(:wiki_content, with: 'wiki content')
- click_on('Create page')
+ page.within(".wiki-form") do
+ fill_in(:wiki_content, with: "wiki content")
+ click_on("Create page")
end
end
- it 'shows the history of a page that has a path', :js do
- expect(current_path).to include('one/two/three-test')
+ it "shows the history of a page that has a path", :js do
+ expect(current_path).to include("one/two/three-test")
- first(:link, text: 'three').click
- click_on('Page history')
+ first(:link, text: "three").click
+ click_on("Page history")
- expect(current_path).to include('one/two/three-test')
+ expect(current_path).to include("one/two/three-test")
- page.within(:css, '.nav-text') do
- expect(page).to have_content('History')
+ page.within(:css, ".nav-text") do
+ expect(page).to have_content("History")
end
end
- it 'shows an old version of a page', :js do
- expect(current_path).to include('one/two/three-test')
- expect(find('.wiki-pages')).to have_content('three')
+ it "shows an old version of a page", :js do
+ expect(current_path).to include("one/two/three-test")
+ expect(find(".wiki-pages")).to have_content("three")
- first(:link, text: 'three').click
+ first(:link, text: "three").click
- expect(find('.nav-text')).to have_content('three')
+ expect(find(".nav-text")).to have_content("three")
- click_on('Edit')
+ click_on("Edit")
- expect(current_path).to include('one/two/three-test')
- expect(page).to have_content('Edit Page')
+ expect(current_path).to include("one/two/three-test")
+ expect(page).to have_content("Edit Page")
- fill_in('Content', with: 'Updated Wiki Content')
+ fill_in("Content", with: "Updated Wiki Content")
- click_on('Save changes')
- click_on('Page history')
+ click_on("Save changes")
+ click_on("Page history")
- page.within(:css, '.nav-text') do
- expect(page).to have_content('History')
+ page.within(:css, ".nav-text") do
+ expect(page).to have_content("History")
end
find('a[href*="?version_id"]')
end
end
- context 'when a page does not have history' do
+ context "when a page does not have history" do
before do
visit(project_wiki_path(project, wiki_page))
end
- it 'shows all the pages' do
+ it "shows all the pages" do
expect(page).to have_content(user.name)
- expect(find('.wiki-pages')).to have_content(wiki_page.title.capitalize)
+ expect(find(".wiki-pages")).to have_content(wiki_page.title.capitalize)
end
- context 'shows a file stored in a page' do
- let(:path) { upload_file_to_wiki(project, user, 'dk.png') }
+ context "shows a file stored in a page" do
+ let(:path) { upload_file_to_wiki(project, user, "dk.png") }
it do
expect(page).to have_xpath("//img[@data-src='#{project.wiki.wiki_base_path}/#{path}']")
- expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}")
+ expect(page).to have_link("image", href: "#{project.wiki.wiki_base_path}/#{path}")
- click_on('image')
+ click_on("image")
expect(current_path).to match("wikis/#{path}")
- expect(page).not_to have_xpath('/html') # Page should render the image which means there is no html involved
+ expect(page).not_to have_xpath("/html") # Page should render the image which means there is no html involved
end
end
- it 'shows the creation page if file does not exist' do
- expect(page).to have_link('image', href: "#{project.wiki.wiki_base_path}/#{path}")
+ it "shows the creation page if file does not exist" do
+ expect(page).to have_link("image", href: "#{project.wiki.wiki_base_path}/#{path}")
- click_on('image')
+ click_on("image")
expect(current_path).to match("wikis/#{path}")
- expect(page).to have_content('New Wiki Page')
- expect(page).to have_content('Create page')
+ expect(page).to have_content("New Wiki Page")
+ expect(page).to have_content("Create page")
end
end
- context 'when a page has history' do
+ context "when a page has history" do
before do
- wiki_page.update(message: 'updated home', content: 'updated [some link](other-page)')
+ wiki_page.update(message: "updated home", content: "updated [some link](other-page)")
end
- it 'shows the page history' do
+ it "shows the page history" do
visit(project_wiki_path(project, wiki_page))
- expect(page).to have_selector('a.btn', text: 'Edit')
+ expect(page).to have_selector("a.btn", text: "Edit")
- click_on('Page history')
+ click_on("Page history")
expect(page).to have_content(user.name)
expect(page).to have_content("#{user.username} created page: home")
- expect(page).to have_content('updated home')
+ expect(page).to have_content("updated home")
end
it 'does not show the "Edit" button' do
visit(project_wiki_path(project, wiki_page, version_id: wiki_page.versions.last.id))
- expect(page).not_to have_selector('a.btn', text: 'Edit')
+ expect(page).not_to have_selector("a.btn", text: "Edit")
end
end
- context 'when page has invalid content encoding' do
- let(:content) { 'whatever'.force_encoding('ISO-8859-1') }
+ context "when page has invalid content encoding" do
+ let(:content) { "whatever".force_encoding("ISO-8859-1") }
before do
allow(Gitlab::EncodingHelper).to receive(:encode!).and_return(content)
@@ -138,22 +138,22 @@ describe 'User views a wiki page' do
end
it 'does not show "Edit" button' do
- expect(page).not_to have_selector('a.btn', text: 'Edit')
+ expect(page).not_to have_selector("a.btn", text: "Edit")
end
- it 'shows error' do
- page.within(:css, '.flash-notice') do
- expect(page).to have_content('The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.')
+ it "shows error" do
+ page.within(:css, ".flash-notice") do
+ expect(page).to have_content("The content of this page is not encoded in UTF-8. Edits can only be made via the Git repository.")
end
end
end
- it 'opens a default wiki page', :js do
+ it "opens a default wiki page", :js do
visit(project_path(project))
- find('.shortcuts-wiki').click
+ find(".shortcuts-wiki").click
click_link "Create your first page"
- expect(page).to have_content('Home · Create Page')
+ expect(page).to have_content("Home · Create Page")
end
end
diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb
index dbf0d427976..a8c3d956ad6 100644
--- a/spec/features/projects_spec.rb
+++ b/spec/features/projects_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Project' do
+describe "Project" do
include ProjectForksHelper
include MobileHelpers
@@ -8,7 +8,7 @@ describe 'Project' do
stub_feature_flags(approval_rules: false)
end
- describe 'creating from template' do
+ describe "creating from template" do
let(:user) { create(:user) }
let(:template) { Gitlab::ProjectTemplate.find(:rails) }
@@ -18,11 +18,11 @@ describe 'Project' do
end
it "allows creation from templates", :js do
- find('#create-from-template-tab').click
+ find("#create-from-template-tab").click
find("label[for=#{template.name}]").click
fill_in("project_name", with: template.name)
- page.within '#content-body' do
+ page.within "#content-body" do
click_button "Create project"
end
@@ -30,7 +30,7 @@ describe 'Project' do
end
end
- describe 'shows tip about push to create git command' do
+ describe "shows tip about push to create git command" do
let(:user) { create(:user) }
before do
@@ -38,17 +38,17 @@ describe 'Project' do
visit new_project_path
end
- it 'shows the command in a popover', :js do
- page.within '.profile-settings-sidebar' do
- click_link 'Show command'
+ it "shows the command in a popover", :js do
+ page.within ".profile-settings-sidebar" do
+ click_link "Show command"
end
- expect(page).to have_css('.popover .push-to-create-popover #push_to_create_tip')
- expect(page).to have_content 'Private projects can be created in your personal namespace with:'
+ expect(page).to have_css(".popover .push-to-create-popover #push_to_create_tip")
+ expect(page).to have_content "Private projects can be created in your personal namespace with:"
end
end
- describe 'description' do
+ describe "description" do
let(:project) { create(:project, :repository) }
let(:path) { project_path(project) }
@@ -56,54 +56,54 @@ describe 'Project' do
sign_in(create(:admin))
end
- it 'parses Markdown' do
- project.update_attribute(:description, 'This is **my** project')
+ it "parses Markdown" do
+ project.update_attribute(:description, "This is **my** project")
visit path
- expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > strong')
+ expect(page).to have_css(".home-panel-description > .home-panel-description-markdown > p > strong")
end
- it 'passes through html-pipeline' do
- project.update_attribute(:description, 'This project is the :poop:')
+ it "passes through html-pipeline" do
+ project.update_attribute(:description, "This project is the :poop:")
visit path
- expect(page).to have_css('.home-panel-description > .home-panel-description-markdown > p > gl-emoji')
+ expect(page).to have_css(".home-panel-description > .home-panel-description-markdown > p > gl-emoji")
end
- it 'sanitizes unwanted tags' do
+ it "sanitizes unwanted tags" do
project.update_attribute(:description, "```\ncode\n```")
visit path
- expect(page).not_to have_css('.home-panel-description code')
+ expect(page).not_to have_css(".home-panel-description code")
end
- it 'permits `rel` attribute on links' do
- project.update_attribute(:description, 'https://google.com/')
+ it "permits `rel` attribute on links" do
+ project.update_attribute(:description, "https://google.com/")
visit path
- expect(page).to have_css('.home-panel-description a[rel]')
+ expect(page).to have_css(".home-panel-description a[rel]")
end
- context 'read more', :js do
- let(:read_more_selector) { '.read-more-container' }
- let(:read_more_trigger_selector) { '.home-panel-home-desc .js-read-more-trigger' }
+ context "read more", :js do
+ let(:read_more_selector) { ".read-more-container" }
+ let(:read_more_trigger_selector) { ".home-panel-home-desc .js-read-more-trigger" }
it 'does not display "read more" link on desktop breakpoint' do
- project.update_attribute(:description, 'This is **my** project')
+ project.update_attribute(:description, "This is **my** project")
visit path
expect(find(read_more_trigger_selector, visible: false)).not_to be_visible
end
it 'displays "read more" link on mobile breakpoint' do
- project.update_attribute(:description, 'This is **my** project')
+ project.update_attribute(:description, "This is **my** project")
visit path
resize_screen_xs
find(read_more_trigger_selector).click
- expect(page).to have_css('.home-panel-description .is-expanded')
+ expect(page).to have_css(".home-panel-description .is-expanded")
end
end
end
- describe 'project topics' do
+ describe "project topics" do
let(:project) { create(:project, :repository) }
let(:path) { project_path(project) }
@@ -112,29 +112,29 @@ describe 'Project' do
visit path
end
- it 'shows project topics' do
- project.update_attribute(:tag_list, 'topic1')
+ it "shows project topics" do
+ project.update_attribute(:tag_list, "topic1")
visit path
- expect(page).to have_css('.home-panel-topic-list')
- expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1'))
+ expect(page).to have_css(".home-panel-topic-list")
+ expect(page).to have_link("Topic1", href: explore_projects_path(tag: "topic1"))
end
- it 'shows up to 3 project tags' do
- project.update_attribute(:tag_list, 'topic1, topic2, topic3, topic4')
+ it "shows up to 3 project tags" do
+ project.update_attribute(:tag_list, "topic1, topic2, topic3, topic4")
visit path
- expect(page).to have_css('.home-panel-topic-list')
- expect(page).to have_link('Topic1', href: explore_projects_path(tag: 'topic1'))
- expect(page).to have_link('Topic2', href: explore_projects_path(tag: 'topic2'))
- expect(page).to have_link('Topic3', href: explore_projects_path(tag: 'topic3'))
- expect(page).to have_content('+ 1 more')
+ expect(page).to have_css(".home-panel-topic-list")
+ expect(page).to have_link("Topic1", href: explore_projects_path(tag: "topic1"))
+ expect(page).to have_link("Topic2", href: explore_projects_path(tag: "topic2"))
+ expect(page).to have_link("Topic3", href: explore_projects_path(tag: "topic3"))
+ expect(page).to have_content("+ 1 more")
end
end
- describe 'copy clone URL to clipboard', :js do
+ describe "copy clone URL to clipboard", :js do
let(:project) { create(:project, :repository) }
let(:path) { project_path(project) }
@@ -143,23 +143,23 @@ describe 'Project' do
visit path
end
- context 'desktop component' do
- it 'shows on md and larger breakpoints' do
- expect(find('.git-clone-holder')).to be_visible
- expect(find('.mobile-git-clone', visible: false)).not_to be_visible
+ context "desktop component" do
+ it "shows on md and larger breakpoints" do
+ expect(find(".git-clone-holder")).to be_visible
+ expect(find(".mobile-git-clone", visible: false)).not_to be_visible
end
end
- context 'mobile component' do
- it 'shows mobile component on sm and smaller breakpoints' do
+ context "mobile component" do
+ it "shows mobile component on sm and smaller breakpoints" do
resize_screen_xs
- expect(find('.mobile-git-clone')).to be_visible
- expect(find('.git-clone-holder', visible: false)).not_to be_visible
+ expect(find(".mobile-git-clone")).to be_visible
+ expect(find(".git-clone-holder", visible: false)).not_to be_visible
end
end
end
- describe 'remove forked relationship', :js do
+ describe "remove forked relationship", :js do
let(:user) { create(:user) }
let(:project) { fork_project(create(:project, :public), user, namespace_id: user.namespace) }
@@ -168,18 +168,18 @@ describe 'Project' do
visit edit_project_path(project)
end
- it 'removes fork' do
- expect(page).to have_content 'Remove fork relationship'
+ it "removes fork" do
+ expect(page).to have_content "Remove fork relationship"
- remove_with_confirm('Remove fork relationship', project.path)
+ remove_with_confirm("Remove fork relationship", project.path)
- expect(page).to have_content 'The fork relationship has been removed.'
+ expect(page).to have_content "The fork relationship has been removed."
expect(project.reload.forked?).to be_falsey
- expect(page).not_to have_content 'Remove fork relationship'
+ expect(page).not_to have_content "Remove fork relationship"
end
end
- describe 'showing information about source of a project fork' do
+ describe "showing information about source of a project fork" do
let(:user) { create(:user) }
let(:base_project) { create(:project, :public, :repository) }
let(:forked_project) { fork_project(base_project, user, repository: true) }
@@ -188,23 +188,23 @@ describe 'Project' do
sign_in user
end
- it 'shows a link to the source project when it is available' do
+ it "shows a link to the source project when it is available" do
visit project_path(forked_project)
- expect(page).to have_content('Forked from')
+ expect(page).to have_content("Forked from")
expect(page).to have_link(base_project.full_name)
end
- it 'does not contain fork network information for the root project' do
+ it "does not contain fork network information for the root project" do
forked_project
visit project_path(base_project)
- expect(page).not_to have_content('In fork network of')
- expect(page).not_to have_content('Forked from')
+ expect(page).not_to have_content("In fork network of")
+ expect(page).not_to have_content("Forked from")
end
- it 'shows the name of the deleted project when the source was deleted' do
+ it "shows the name of the deleted project when the source was deleted" do
forked_project
Projects::DestroyService.new(base_project, base_project.owner).execute
@@ -213,10 +213,10 @@ describe 'Project' do
expect(page).to have_content("Forked from #{base_project.full_name} (deleted)")
end
- context 'a fork of a fork' do
+ context "a fork of a fork" do
let(:fork_of_fork) { fork_project(forked_project, user, repository: true) }
- it 'links to the base project if the source project is removed' do
+ it "links to the base project if the source project is removed" do
fork_of_fork
Projects::DestroyService.new(forked_project, user).execute
@@ -228,7 +228,7 @@ describe 'Project' do
end
end
- describe 'when the project repository is disabled', :js do
+ describe "when the project repository is disabled", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository_disabled, :repository, namespace: user.namespace) }
@@ -238,14 +238,14 @@ describe 'Project' do
visit project_path(project)
end
- it 'does not show an error' do
+ it "does not show an error" do
wait_for_requests
- expect(page).not_to have_selector('.flash-alert')
+ expect(page).not_to have_selector(".flash-alert")
end
end
- describe 'removal', :js do
+ describe "removal", :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -255,14 +255,14 @@ describe 'Project' do
visit edit_project_path(project)
end
- it 'focuses on the confirmation field' do
- click_button 'Remove project'
+ it "focuses on the confirmation field" do
+ click_button "Remove project"
- expect(page).to have_selector '#confirm_name_input:focus'
+ expect(page).to have_selector "#confirm_name_input:focus"
end
- it 'removes a project' do
- expect { remove_with_confirm('Remove project', project.path) }.to change { Project.count }.by(-1)
+ it "removes a project" do
+ expect { remove_with_confirm("Remove project", project.path) }.to change { Project.count }.by(-1)
expect(page).to have_content "Project '#{project.full_name}' is in the process of being deleted."
expect(Project.all.count).to be_zero
expect(project.issues).to be_empty
@@ -270,8 +270,8 @@ describe 'Project' do
end
end
- describe 'tree view (default view is set to Files)' do
- let(:user) { create(:user, project_view: 'files') }
+ describe "tree view (default view is set to Files)" do
+ let(:user) { create(:user, project_view: "files") }
let(:project) { create(:forked_project_with_submodules) }
before do
@@ -280,70 +280,70 @@ describe 'Project' do
visit project_path(project)
end
- it 'has working links to files' do
- click_link('PROCESS.md')
+ it "has working links to files" do
+ click_link("PROCESS.md")
expect(page.status_code).to eq(200)
end
- it 'has working links to directories' do
- click_link('encoding')
+ it "has working links to directories" do
+ click_link("encoding")
expect(page.status_code).to eq(200)
end
- it 'has working links to submodules' do
- click_link('645f6c4c')
+ it "has working links to submodules" do
+ click_link("645f6c4c")
expect(page.status_code).to eq(200)
end
- context 'for signed commit on default branch', :js do
+ context "for signed commit on default branch", :js do
before do
- project.change_head('33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ project.change_head("33f3729a45c02fc67d00adb1b8bca394b0e761d9")
end
- it 'displays a GPG badge' do
+ it "displays a GPG badge" do
visit project_path(project)
wait_for_requests
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
- context 'for subgroups', :js, :nested_groups do
+ context "for subgroups", :js, :nested_groups do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
let(:project) { create(:project, :repository, group: subgroup) }
- it 'renders tree table without errors' do
+ it "renders tree table without errors" do
wait_for_requests
- expect(page).to have_selector('.tree-item')
- expect(page).not_to have_selector('.flash-alert')
+ expect(page).to have_selector(".tree-item")
+ expect(page).not_to have_selector(".flash-alert")
end
- context 'for signed commit' do
+ context "for signed commit" do
before do
repository = project.repository
- repository.write_ref("refs/heads/#{project.default_branch}", '33f3729a45c02fc67d00adb1b8bca394b0e761d9')
+ repository.write_ref("refs/heads/#{project.default_branch}", "33f3729a45c02fc67d00adb1b8bca394b0e761d9")
repository.expire_branches_cache
end
- it 'displays a GPG badge' do
+ it "displays a GPG badge" do
visit project_path(project)
wait_for_requests
- expect(page).not_to have_selector '.gpg-status-box.js-loading-gpg-badge'
- expect(page).to have_selector '.gpg-status-box.invalid'
+ expect(page).not_to have_selector ".gpg-status-box.js-loading-gpg-badge"
+ expect(page).to have_selector ".gpg-status-box.invalid"
end
end
end
end
- describe 'activity view' do
- let(:user) { create(:user, project_view: 'activity') }
+ describe "activity view" do
+ let(:user) { create(:user, project_view: "activity") }
let(:project) { create(:project, :repository) }
before do
@@ -352,30 +352,30 @@ describe 'Project' do
visit project_path(project)
end
- it 'loads activity', :js do
- expect(page).to have_selector('.event-item')
+ it "loads activity", :js do
+ expect(page).to have_selector(".event-item")
end
end
- context 'content is not cached after signing out', :js do
- let(:user) { create(:user, project_view: 'activity') }
+ context "content is not cached after signing out", :js do
+ let(:user) { create(:user, project_view: "activity") }
let(:project) { create(:project, :repository) }
- it 'does not load activity', :js do
+ it "does not load activity", :js do
project.add_maintainer(user)
sign_in(user)
visit project_path(project)
sign_out(user)
- page.evaluate_script('window.history.back()')
+ page.evaluate_script("window.history.back()")
- expect(page).not_to have_selector('.event-item')
+ expect(page).not_to have_selector(".event-item")
end
end
def remove_with_confirm(button_text, confirm_with)
click_button button_text
- fill_in 'confirm_name_input', with: confirm_with
- click_button 'Confirm'
+ fill_in "confirm_name_input", with: confirm_with
+ click_button "Confirm"
end
end
diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb
index 0aff916ec83..8e9ca595402 100644
--- a/spec/features/protected_branches_spec.rb
+++ b/spec/features/protected_branches_spec.rb
@@ -1,68 +1,68 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Protected Branches', :js do
+describe "Protected Branches", :js do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, :repository) }
- context 'logged in as developer' do
+ context "logged in as developer" do
before do
project.add_developer(user)
sign_in(user)
end
- describe 'Delete protected branch' do
+ describe "Delete protected branch" do
before do
- create(:protected_branch, project: project, name: 'fix')
+ create(:protected_branch, project: project, name: "fix")
expect(ProtectedBranch.count).to eq(1)
end
- it 'does not allow developer to removes protected branch' do
+ it "does not allow developer to removes protected branch" do
visit project_branches_path(project)
- fill_in 'branch-search', with: 'fix'
- find('#branch-search').native.send_keys(:enter)
+ fill_in "branch-search", with: "fix"
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_css('.btn-remove.disabled')
+ expect(page).to have_css(".btn-remove.disabled")
end
end
end
- context 'logged in as maintainer' do
+ context "logged in as maintainer" do
before do
project.add_maintainer(user)
sign_in(user)
end
- describe 'Delete protected branch' do
+ describe "Delete protected branch" do
before do
- create(:protected_branch, project: project, name: 'fix')
+ create(:protected_branch, project: project, name: "fix")
expect(ProtectedBranch.count).to eq(1)
end
- it 'removes branch after modal confirmation' do
+ it "removes branch after modal confirmation" do
visit project_branches_path(project)
- fill_in 'branch-search', with: 'fix'
- find('#branch-search').native.send_keys(:enter)
+ fill_in "branch-search", with: "fix"
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_content('fix')
- expect(find('.all-branches')).to have_selector('li', count: 1)
+ expect(page).to have_content("fix")
+ expect(find(".all-branches")).to have_selector("li", count: 1)
page.find('[data-target="#modal-delete-branch"]').click
- expect(page).to have_css('.js-delete-branch[disabled]')
- fill_in 'delete_branch_input', with: 'fix'
- click_link 'Delete protected branch'
+ expect(page).to have_css(".js-delete-branch[disabled]")
+ fill_in "delete_branch_input", with: "fix"
+ click_link "Delete protected branch"
- fill_in 'branch-search', with: 'fix'
- find('#branch-search').native.send_keys(:enter)
+ fill_in "branch-search", with: "fix"
+ find("#branch-search").native.send_keys(:enter)
- expect(page).to have_content('No branches to show')
+ expect(page).to have_content("No branches to show")
end
end
end
- context 'logged in as admin' do
+ context "logged in as admin" do
before do
sign_in(admin)
end
@@ -71,21 +71,21 @@ describe 'Protected Branches', :js do
it "allows creating explicit protected branches" do
visit project_protected_branches_path(project)
set_defaults
- set_protected_branch_name('some-branch')
+ set_protected_branch_name("some-branch")
click_on "Protect"
- within(".protected-branches-list") { expect(page).to have_content('some-branch') }
+ within(".protected-branches-list") { expect(page).to have_content("some-branch") }
expect(ProtectedBranch.count).to eq(1)
- expect(ProtectedBranch.last.name).to eq('some-branch')
+ expect(ProtectedBranch.last.name).to eq("some-branch")
end
it "displays the last commit on the matching branch if it exists" do
commit = create(:commit, project: project)
- project.repository.add_branch(admin, 'some-branch', commit.id)
+ project.repository.add_branch(admin, "some-branch", commit.id)
visit project_protected_branches_path(project)
set_defaults
- set_protected_branch_name('some-branch')
+ set_protected_branch_name("some-branch")
click_on "Protect"
within(".protected-branches-list") { expect(page).to have_content(commit.id[0..7]) }
@@ -94,10 +94,10 @@ describe 'Protected Branches', :js do
it "displays an error message if the named branch does not exist" do
visit project_protected_branches_path(project)
set_defaults
- set_protected_branch_name('some-branch')
+ set_protected_branch_name("some-branch")
click_on "Protect"
- within(".protected-branches-list") { expect(page).to have_content('branch was deleted') }
+ within(".protected-branches-list") { expect(page).to have_content("branch was deleted") }
end
end
@@ -105,21 +105,21 @@ describe 'Protected Branches', :js do
it "allows creating protected branches with a wildcard" do
visit project_protected_branches_path(project)
set_defaults
- set_protected_branch_name('*-stable')
+ set_protected_branch_name("*-stable")
click_on "Protect"
- within(".protected-branches-list") { expect(page).to have_content('*-stable') }
+ within(".protected-branches-list") { expect(page).to have_content("*-stable") }
expect(ProtectedBranch.count).to eq(1)
- expect(ProtectedBranch.last.name).to eq('*-stable')
+ expect(ProtectedBranch.last.name).to eq("*-stable")
end
it "displays the number of matching branches" do
- project.repository.add_branch(admin, 'production-stable', 'master')
- project.repository.add_branch(admin, 'staging-stable', 'master')
+ project.repository.add_branch(admin, "production-stable", "master")
+ project.repository.add_branch(admin, "staging-stable", "master")
visit project_protected_branches_path(project)
set_defaults
- set_protected_branch_name('*-stable')
+ set_protected_branch_name("*-stable")
click_on "Protect"
within(".protected-branches-list") do
@@ -129,12 +129,12 @@ describe 'Protected Branches', :js do
end
it "displays all the branches matching the wildcard" do
- project.repository.add_branch(admin, 'production-stable', 'master')
- project.repository.add_branch(admin, 'staging-stable', 'master')
- project.repository.add_branch(admin, 'development', 'master')
+ project.repository.add_branch(admin, "production-stable", "master")
+ project.repository.add_branch(admin, "staging-stable", "master")
+ project.repository.add_branch(admin, "development", "master")
visit project_protected_branches_path(project)
- set_protected_branch_name('*-stable')
+ set_protected_branch_name("*-stable")
set_defaults
click_on "Protect"
@@ -162,15 +162,15 @@ describe 'Protected Branches', :js do
def set_defaults
find(".js-allowed-to-merge").click
- within('.qa-allowed-to-merge-dropdown') do
+ within(".qa-allowed-to-merge-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
find(".js-allowed-to-push").click
- within('.qa-allowed-to-push-dropdown') do
+ within(".qa-allowed-to-push-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
end
end
diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb
index c8e92cd1c07..86327f41761 100644
--- a/spec/features/protected_tags_spec.rb
+++ b/spec/features/protected_tags_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Protected Tags', :js do
+describe "Protected Tags", :js do
let(:user) { create(:user, :admin) }
let(:project) { create(:project, :repository) }
@@ -12,26 +12,26 @@ describe 'Protected Tags', :js do
find(".js-protected-tag-select").click
find(".dropdown-input-field").set(tag_name)
click_on("Create wildcard #{tag_name}")
- find('.protected-tags-dropdown .dropdown-menu', visible: false)
+ find(".protected-tags-dropdown .dropdown-menu", visible: false)
end
describe "explicit protected tags" do
it "allows creating explicit protected tags" do
visit project_protected_tags_path(project)
- set_protected_tag_name('some-tag')
+ set_protected_tag_name("some-tag")
click_on "Protect"
- within(".protected-tags-list") { expect(page).to have_content('some-tag') }
+ within(".protected-tags-list") { expect(page).to have_content("some-tag") }
expect(ProtectedTag.count).to eq(1)
- expect(ProtectedTag.last.name).to eq('some-tag')
+ expect(ProtectedTag.last.name).to eq("some-tag")
end
it "displays the last commit on the matching tag if it exists" do
commit = create(:commit, project: project)
- project.repository.add_tag(user, 'some-tag', commit.id)
+ project.repository.add_tag(user, "some-tag", commit.id)
visit project_protected_tags_path(project)
- set_protected_tag_name('some-tag')
+ set_protected_tag_name("some-tag")
click_on "Protect"
within(".protected-tags-list") { expect(page).to have_content(commit.id[0..7]) }
@@ -39,30 +39,30 @@ describe 'Protected Tags', :js do
it "displays an error message if the named tag does not exist" do
visit project_protected_tags_path(project)
- set_protected_tag_name('some-tag')
+ set_protected_tag_name("some-tag")
click_on "Protect"
- within(".protected-tags-list") { expect(page).to have_content('tag was removed') }
+ within(".protected-tags-list") { expect(page).to have_content("tag was removed") }
end
end
describe "wildcard protected tags" do
it "allows creating protected tags with a wildcard" do
visit project_protected_tags_path(project)
- set_protected_tag_name('*-stable')
+ set_protected_tag_name("*-stable")
click_on "Protect"
- within(".protected-tags-list") { expect(page).to have_content('*-stable') }
+ within(".protected-tags-list") { expect(page).to have_content("*-stable") }
expect(ProtectedTag.count).to eq(1)
- expect(ProtectedTag.last.name).to eq('*-stable')
+ expect(ProtectedTag.last.name).to eq("*-stable")
end
it "displays the number of matching tags" do
- project.repository.add_tag(user, 'production-stable', 'master')
- project.repository.add_tag(user, 'staging-stable', 'master')
+ project.repository.add_tag(user, "production-stable", "master")
+ project.repository.add_tag(user, "staging-stable", "master")
visit project_protected_tags_path(project)
- set_protected_tag_name('*-stable')
+ set_protected_tag_name("*-stable")
click_on "Protect"
within(".protected-tags-list") do
@@ -72,12 +72,12 @@ describe 'Protected Tags', :js do
end
it "displays all the tags matching the wildcard" do
- project.repository.add_tag(user, 'production-stable', 'master')
- project.repository.add_tag(user, 'staging-stable', 'master')
- project.repository.add_tag(user, 'development', 'master')
+ project.repository.add_tag(user, "production-stable", "master")
+ project.repository.add_tag(user, "staging-stable", "master")
+ project.repository.add_tag(user, "development", "master")
visit project_protected_tags_path(project)
- set_protected_tag_name('*-stable')
+ set_protected_tag_name("*-stable")
click_on "Protect"
visit project_protected_tags_path(project)
diff --git a/spec/features/raven_js_spec.rb b/spec/features/raven_js_spec.rb
index b0923b451ee..14cdf57e2bb 100644
--- a/spec/features/raven_js_spec.rb
+++ b/spec/features/raven_js_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'RavenJS' do
- let(:raven_path) { '/raven.chunk.js' }
+describe "RavenJS" do
+ let(:raven_path) { "/raven.chunk.js" }
- it 'should not load raven if sentry is disabled' do
+ it "should not load raven if sentry is disabled" do
visit new_user_session_path
expect(has_requested_raven).to eq(false)
end
- it 'should load raven if sentry is enabled' do
- stub_application_setting(clientside_sentry_dsn: 'https://key@domain.com/id', clientside_sentry_enabled: true)
+ it "should load raven if sentry is enabled" do
+ stub_application_setting(clientside_sentry_dsn: "https://key@domain.com/id", clientside_sentry_enabled: true)
visit new_user_session_path
@@ -18,7 +18,7 @@ describe 'RavenJS' do
end
def has_requested_raven
- page.all('script', visible: false).one? do |elm|
+ page.all("script", visible: false).one? do |elm|
elm[:src] =~ /#{raven_path}$/
end
end
diff --git a/spec/features/read_only_spec.rb b/spec/features/read_only_spec.rb
index 8bfaf558466..6eaacda32c4 100644
--- a/spec/features/read_only_spec.rb
+++ b/spec/features/read_only_spec.rb
@@ -1,25 +1,25 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'read-only message' do
+describe "read-only message" do
set(:user) { create(:user) }
before do
sign_in(user)
end
- it 'shows read-only banner when database is read-only' do
+ it "shows read-only banner when database is read-only" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
visit root_dashboard_path
- expect(page).to have_content('You are on a read-only GitLab instance.')
+ expect(page).to have_content("You are on a read-only GitLab instance.")
end
- it 'does not show read-only banner when database is able to read-write' do
+ it "does not show read-only banner when database is able to read-write" do
allow(Gitlab::Database).to receive(:read_only?).and_return(false)
visit root_dashboard_path
- expect(page).not_to have_content('You are on a read-only GitLab instance.')
+ expect(page).not_to have_content("You are on a read-only GitLab instance.")
end
end
diff --git a/spec/features/reportable_note/commit_spec.rb b/spec/features/reportable_note/commit_spec.rb
index 54ebda9dcab..55891379878 100644
--- a/spec/features/reportable_note/commit_spec.rb
+++ b/spec/features/reportable_note/commit_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Reportable note on commit', :js do
+describe "Reportable note on commit", :js do
include RepoHelpers
let(:user) { create(:user) }
@@ -11,23 +11,23 @@ describe 'Reportable note on commit', :js do
sign_in(user)
end
- context 'a normal note' do
+ context "a normal note" do
let!(:note) { create(:note_on_commit, commit_id: sample_commit.id, project: project) }
before do
visit project_commit_path(project, sample_commit.id)
end
- it_behaves_like 'reportable note', 'commit'
+ it_behaves_like "reportable note", "commit"
end
- context 'a diff note' do
+ context "a diff note" do
let!(:note) { create(:diff_note_on_commit, commit_id: sample_commit.id, project: project) }
before do
visit project_commit_path(project, sample_commit.id)
end
- it_behaves_like 'reportable note', 'commit'
+ it_behaves_like "reportable note", "commit"
end
end
diff --git a/spec/features/reportable_note/issue_spec.rb b/spec/features/reportable_note/issue_spec.rb
index bce1f7a3780..3fb63d05ef4 100644
--- a/spec/features/reportable_note/issue_spec.rb
+++ b/spec/features/reportable_note/issue_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Reportable note on issue', :js do
+describe "Reportable note on issue", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
@@ -13,5 +13,5 @@ describe 'Reportable note on issue', :js do
visit project_issue_path(project, issue)
end
- it_behaves_like 'reportable note', 'issue'
+ it_behaves_like "reportable note", "issue"
end
diff --git a/spec/features/reportable_note/merge_request_spec.rb b/spec/features/reportable_note/merge_request_spec.rb
index d00324156c4..ecf876744aa 100644
--- a/spec/features/reportable_note/merge_request_spec.rb
+++ b/spec/features/reportable_note/merge_request_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Reportable note on merge request', :js do
+describe "Reportable note on merge request", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -12,15 +12,15 @@ describe 'Reportable note on merge request', :js do
visit project_merge_request_path(project, merge_request)
end
- context 'a normal note' do
+ context "a normal note" do
let!(:note) { create(:note_on_merge_request, noteable: merge_request, project: project) }
- it_behaves_like 'reportable note', 'merge_request'
+ it_behaves_like "reportable note", "merge_request"
end
- context 'a diff note' do
+ context "a diff note" do
let!(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
- it_behaves_like 'reportable note', 'merge_request'
+ it_behaves_like "reportable note", "merge_request"
end
end
diff --git a/spec/features/reportable_note/snippets_spec.rb b/spec/features/reportable_note/snippets_spec.rb
index 06218d9b286..28913ece01f 100644
--- a/spec/features/reportable_note/snippets_spec.rb
+++ b/spec/features/reportable_note/snippets_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Reportable note on snippets', :js do
+describe "Reportable note on snippets", :js do
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -9,7 +9,7 @@ describe 'Reportable note on snippets', :js do
sign_in(user)
end
- describe 'on project snippet' do
+ describe "on project snippet" do
let(:snippet) { create(:project_snippet, :public, project: project, author: user) }
let!(:note) { create(:note_on_project_snippet, noteable: snippet, project: project) }
@@ -17,6 +17,6 @@ describe 'Reportable note on snippets', :js do
visit project_snippet_path(project, snippet)
end
- it_behaves_like 'reportable note', 'snippet'
+ it_behaves_like "reportable note", "snippet"
end
end
diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb
index 6eae0be4b9f..4a767c9c414 100644
--- a/spec/features/runners_spec.rb
+++ b/spec/features/runners_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Runners' do
+describe "Runners" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- context 'when user opens runners page' do
+ context "when user opens runners page" do
let(:project) { create(:project) }
before do
project.add_maintainer(user)
end
- it 'user can see a button to install runners on kubernetes clusters' do
+ it "user can see a button to install runners on kubernetes clusters" do
visit project_runners_path(project)
- expect(page).to have_link('Install Runner on Kubernetes', href: project_clusters_path(project))
+ expect(page).to have_link("Install Runner on Kubernetes", href: project_clusters_path(project))
end
end
- context 'when a project has enabled shared_runners' do
+ context "when a project has enabled shared_runners" do
let(:project) { create(:project) }
before do
project.add_maintainer(user)
end
- context 'when a project_type runner is activated on the project' do
+ context "when a project_type runner is activated on the project" do
let!(:specific_runner) { create(:ci_runner, :project, projects: [project]) }
- it 'user sees the specific runner' do
+ it "user sees the specific runner" do
visit project_runners_path(project)
- within '.activated-specific-runners' do
+ within ".activated-specific-runners" do
expect(page).to have_content(specific_runner.display_name)
end
@@ -43,84 +43,84 @@ describe 'Runners' do
expect(page).to have_content(specific_runner.platform)
end
- it 'user can pause and resume the specific runner' do
+ it "user can pause and resume the specific runner" do
visit project_runners_path(project)
- within '.activated-specific-runners' do
- expect(page).to have_content('Pause')
+ within ".activated-specific-runners" do
+ expect(page).to have_content("Pause")
end
- click_on 'Pause'
+ click_on "Pause"
- within '.activated-specific-runners' do
- expect(page).to have_content('Resume')
+ within ".activated-specific-runners" do
+ expect(page).to have_content("Resume")
end
- click_on 'Resume'
+ click_on "Resume"
- within '.activated-specific-runners' do
- expect(page).to have_content('Pause')
+ within ".activated-specific-runners" do
+ expect(page).to have_content("Pause")
end
end
- it 'user removes an activated specific runner if this is last project for that runners' do
+ it "user removes an activated specific runner if this is last project for that runners" do
visit project_runners_path(project)
- within '.activated-specific-runners' do
- click_on 'Remove Runner'
+ within ".activated-specific-runners" do
+ click_on "Remove Runner"
end
expect(page).not_to have_content(specific_runner.display_name)
end
- it 'user edits the runner to be protected' do
+ it "user edits the runner to be protected" do
visit project_runners_path(project)
- within '.activated-specific-runners' do
- first('.edit-runner > a').click
+ within ".activated-specific-runners" do
+ first(".edit-runner > a").click
end
- expect(page.find_field('runner[access_level]')).not_to be_checked
+ expect(page.find_field("runner[access_level]")).not_to be_checked
- check 'runner_access_level'
- click_button 'Save changes'
+ check "runner_access_level"
+ click_button "Save changes"
- expect(page).to have_content 'Protected Yes'
+ expect(page).to have_content "Protected Yes"
end
- context 'when a runner has a tag' do
+ context "when a runner has a tag" do
before do
- specific_runner.update(tag_list: ['tag'])
+ specific_runner.update(tag_list: ["tag"])
end
- it 'user edits runner not to run untagged jobs' do
+ it "user edits runner not to run untagged jobs" do
visit project_runners_path(project)
- within '.activated-specific-runners' do
- first('.edit-runner > a').click
+ within ".activated-specific-runners" do
+ first(".edit-runner > a").click
end
- expect(page.find_field('runner[run_untagged]')).to be_checked
+ expect(page.find_field("runner[run_untagged]")).to be_checked
- uncheck 'runner_run_untagged'
- click_button 'Save changes'
+ uncheck "runner_run_untagged"
+ click_button "Save changes"
- expect(page).to have_content 'Can run untagged jobs No'
+ expect(page).to have_content "Can run untagged jobs No"
end
end
- context 'when a shared runner is activated on the project' do
+ context "when a shared runner is activated on the project" do
let!(:shared_runner) { create(:ci_runner, :instance) }
- it 'user sees CI/CD setting page' do
+ it "user sees CI/CD setting page" do
visit project_runners_path(project)
- expect(page.find('.available-shared-runners')).to have_content(shared_runner.display_name)
+ expect(page.find(".available-shared-runners")).to have_content(shared_runner.display_name)
end
end
end
- context 'when a specific runner exists in another project' do
+ context "when a specific runner exists in another project" do
let(:another_project) { create(:project) }
let!(:specific_runner) { create(:ci_runner, :project, projects: [another_project]) }
@@ -128,179 +128,179 @@ describe 'Runners' do
another_project.add_maintainer(user)
end
- it 'user enables and disables a specific runner' do
+ it "user enables and disables a specific runner" do
visit project_runners_path(project)
- within '.available-specific-runners' do
- click_on 'Enable for this project'
+ within ".available-specific-runners" do
+ click_on "Enable for this project"
end
- expect(page.find('.activated-specific-runners')).to have_content(specific_runner.display_name)
+ expect(page.find(".activated-specific-runners")).to have_content(specific_runner.display_name)
- within '.activated-specific-runners' do
- click_on 'Disable for this project'
+ within ".activated-specific-runners" do
+ click_on "Disable for this project"
end
- expect(page.find('.available-specific-runners')).to have_content(specific_runner.display_name)
+ expect(page.find(".available-specific-runners")).to have_content(specific_runner.display_name)
end
end
- context 'when application settings have shared_runners_text' do
- let(:shared_runners_text) { 'custom **shared** runners description' }
- let(:shared_runners_html) { 'custom shared runners description' }
+ context "when application settings have shared_runners_text" do
+ let(:shared_runners_text) { "custom **shared** runners description" }
+ let(:shared_runners_html) { "custom shared runners description" }
before do
stub_application_setting(shared_runners_text: shared_runners_text)
end
- it 'user sees shared runners description' do
+ it "user sees shared runners description" do
visit project_runners_path(project)
- expect(page.find('.shared-runners-description')).to have_content(shared_runners_html)
+ expect(page.find(".shared-runners-description")).to have_content(shared_runners_html)
end
end
end
- context 'when a project has disabled shared_runners' do
+ context "when a project has disabled shared_runners" do
let(:project) { create(:project, shared_runners_enabled: false) }
before do
project.add_maintainer(user)
end
- it 'user enables shared runners' do
+ it "user enables shared runners" do
visit project_runners_path(project)
- click_on 'Enable shared Runners'
+ click_on "Enable shared Runners"
- expect(page.find('.shared-runners-description')).to have_content('Disable shared Runners')
+ expect(page.find(".shared-runners-description")).to have_content("Disable shared Runners")
end
end
- context 'group runners in project settings' do
+ context "group runners in project settings" do
before do
project.add_maintainer(user)
end
let(:group) { create :group }
- context 'as project and group maintainer' do
+ context "as project and group maintainer" do
before do
group.add_maintainer(user)
end
- context 'project with a group but no group runner' do
+ context "project with a group but no group runner" do
let(:project) { create :project, group: group }
- it 'group runners are not available' do
+ it "group runners are not available" do
visit project_runners_path(project)
- expect(page).to have_content 'This group does not provide any group Runners yet'
+ expect(page).to have_content "This group does not provide any group Runners yet"
- expect(page).to have_content 'Group maintainers can register group runners in the Group CI/CD settings'
- expect(page).not_to have_content 'Ask your group maintainer to set up a group Runner'
+ expect(page).to have_content "Group maintainers can register group runners in the Group CI/CD settings"
+ expect(page).not_to have_content "Ask your group maintainer to set up a group Runner"
end
end
end
- context 'as project maintainer' do
- context 'project without a group' do
+ context "as project maintainer" do
+ context "project without a group" do
let(:project) { create :project }
- it 'group runners are not available' do
+ it "group runners are not available" do
visit project_runners_path(project)
- expect(page).to have_content 'This project does not belong to a group and can therefore not make use of group Runners.'
+ expect(page).to have_content "This project does not belong to a group and can therefore not make use of group Runners."
end
end
- context 'project with a group but no group runner' do
+ context "project with a group but no group runner" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
- it 'group runners are not available' do
+ it "group runners are not available" do
visit project_runners_path(project)
- expect(page).to have_content 'This group does not provide any group Runners yet.'
+ expect(page).to have_content "This group does not provide any group Runners yet."
- expect(page).not_to have_content 'Group maintainers can register group runners in the Group CI/CD settings'
- expect(page).to have_content 'Ask your group maintainer to set up a group Runner.'
+ expect(page).not_to have_content "Group maintainers can register group runners in the Group CI/CD settings"
+ expect(page).to have_content "Ask your group maintainer to set up a group Runner."
end
end
- context 'project with a group and a group runner' do
+ context "project with a group and a group runner" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
- let!(:ci_runner) { create(:ci_runner, :group, groups: [group], description: 'group-runner') }
+ let!(:ci_runner) { create(:ci_runner, :group, groups: [group], description: "group-runner") }
- it 'group runners are available' do
+ it "group runners are available" do
visit project_runners_path(project)
- expect(page).to have_content 'Available group Runners: 1'
- expect(page).to have_content 'group-runner'
+ expect(page).to have_content "Available group Runners: 1"
+ expect(page).to have_content "group-runner"
end
- it 'group runners may be disabled for a project' do
+ it "group runners may be disabled for a project" do
visit project_runners_path(project)
- click_on 'Disable group Runners'
+ click_on "Disable group Runners"
- expect(page).to have_content 'Enable group Runners'
+ expect(page).to have_content "Enable group Runners"
expect(project.reload.group_runners_enabled).to be false
- click_on 'Enable group Runners'
+ click_on "Enable group Runners"
- expect(page).to have_content 'Disable group Runners'
+ expect(page).to have_content "Disable group Runners"
expect(project.reload.group_runners_enabled).to be true
end
end
end
end
- context 'group runners in group settings' do
+ context "group runners in group settings" do
let(:group) { create(:group) }
before do
group.add_owner(user)
end
- context 'group with no runners' do
- it 'there are no runners displayed' do
+ context "group with no runners" do
+ it "there are no runners displayed" do
visit group_settings_ci_cd_path(group)
- expect(page).to have_content 'This group does not provide any group Runners yet'
+ expect(page).to have_content "This group does not provide any group Runners yet"
end
end
- context 'group with a runner' do
- let!(:runner) { create(:ci_runner, :group, groups: [group], description: 'group-runner') }
+ context "group with a runner" do
+ let!(:runner) { create(:ci_runner, :group, groups: [group], description: "group-runner") }
- it 'the runner is visible' do
+ it "the runner is visible" do
visit group_settings_ci_cd_path(group)
- expect(page).not_to have_content 'This group does not provide any group Runners yet'
- expect(page).to have_content 'Available group Runners: 1'
- expect(page).to have_content 'group-runner'
+ expect(page).not_to have_content "This group does not provide any group Runners yet"
+ expect(page).to have_content "Available group Runners: 1"
+ expect(page).to have_content "group-runner"
end
- it 'user can pause and resume the group runner' do
+ it "user can pause and resume the group runner" do
visit group_settings_ci_cd_path(group)
- expect(page).to have_content('Pause')
- expect(page).not_to have_content('Resume')
+ expect(page).to have_content("Pause")
+ expect(page).not_to have_content("Resume")
- click_on 'Pause'
+ click_on "Pause"
- expect(page).not_to have_content('Pause')
- expect(page).to have_content('Resume')
+ expect(page).not_to have_content("Pause")
+ expect(page).to have_content("Resume")
- click_on 'Resume'
+ click_on "Resume"
- expect(page).to have_content('Pause')
- expect(page).not_to have_content('Resume')
+ expect(page).to have_content("Pause")
+ expect(page).not_to have_content("Resume")
end
- it 'user can view runner details' do
+ it "user can view runner details" do
visit group_settings_ci_cd_path(group)
expect(page).to have_content(runner.display_name)
@@ -310,43 +310,43 @@ describe 'Runners' do
expect(page).to have_content(runner.platform)
end
- it 'user can remove a group runner' do
+ it "user can remove a group runner" do
visit group_settings_ci_cd_path(group)
- click_on 'Remove Runner'
+ click_on "Remove Runner"
expect(page).not_to have_content(runner.display_name)
end
- it 'user edits the runner to be protected' do
+ it "user edits the runner to be protected" do
visit group_settings_ci_cd_path(group)
- first('.edit-runner > a').click
+ first(".edit-runner > a").click
- expect(page.find_field('runner[access_level]')).not_to be_checked
+ expect(page.find_field("runner[access_level]")).not_to be_checked
- check 'runner_access_level'
- click_button 'Save changes'
+ check "runner_access_level"
+ click_button "Save changes"
- expect(page).to have_content 'Protected Yes'
+ expect(page).to have_content "Protected Yes"
end
- context 'when a runner has a tag' do
+ context "when a runner has a tag" do
before do
- runner.update(tag_list: ['tag'])
+ runner.update(tag_list: ["tag"])
end
- it 'user edits runner not to run untagged jobs' do
+ it "user edits runner not to run untagged jobs" do
visit group_settings_ci_cd_path(group)
- first('.edit-runner > a').click
+ first(".edit-runner > a").click
- expect(page.find_field('runner[run_untagged]')).to be_checked
+ expect(page.find_field("runner[run_untagged]")).to be_checked
- uncheck 'runner_run_untagged'
- click_button 'Save changes'
+ uncheck "runner_run_untagged"
+ click_button "Save changes"
- expect(page).to have_content 'Can run untagged jobs No'
+ expect(page).to have_content "Can run untagged jobs No"
end
end
end
diff --git a/spec/features/search/user_searches_for_code_spec.rb b/spec/features/search/user_searches_for_code_spec.rb
index ecec2f3e043..38ae36d3089 100644
--- a/spec/features/search/user_searches_for_code_spec.rb
+++ b/spec/features/search/user_searches_for_code_spec.rb
@@ -1,66 +1,66 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for code' do
+describe "User searches for code" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_maintainer(user)
sign_in(user)
end
- it 'finds a file' do
+ it "finds a file" do
visit(project_path(project))
- page.within('.search') do
- fill_in('search', with: 'application.js')
- click_button('Go')
+ page.within(".search") do
+ fill_in("search", with: "application.js")
+ click_button("Go")
end
- click_link('Code')
+ click_link("Code")
- expect(page).to have_selector('.file-content .code')
+ expect(page).to have_selector(".file-content .code")
expect(page).to have_selector("span.line[lang='javascript']")
end
- context 'when on a project page', :js do
+ context "when on a project page", :js do
before do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds code' do
- find('.js-search-project-dropdown').click
+ it "finds code" do
+ find(".js-search-project-dropdown").click
- page.within('.project-filter') do
+ page.within(".project-filter") do
click_link(project.full_name)
end
- fill_in('dashboard_search', with: 'rspec')
- find('.btn-search').click
+ fill_in("dashboard_search", with: "rspec")
+ find(".btn-search").click
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_content("Update capybara, rspec-rails, poltergeist to recent versions")
end
end
end
end
- context 'when signed out' do
+ context "when signed out" do
let(:project) { create(:project, :public, :repository) }
before do
visit(project_path(project))
end
- it 'finds code' do
- fill_in('search', with: 'rspec')
- click_button('Go')
+ it "finds code" do
+ fill_in("search", with: "rspec")
+ click_button("Go")
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_content("Update capybara, rspec-rails, poltergeist to recent versions")
end
end
end
diff --git a/spec/features/search/user_searches_for_comments_spec.rb b/spec/features/search/user_searches_for_comments_spec.rb
index c7c469a262c..eab0503a55e 100644
--- a/spec/features/search/user_searches_for_comments_spec.rb
+++ b/spec/features/search/user_searches_for_comments_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for comments' do
+describe "User searches for comments" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
@@ -11,35 +11,35 @@ describe 'User searches for comments' do
visit(project_path(project))
end
- context 'when a comment is in commits' do
- context 'when comment belongs to an invalid commit' do
- let(:comment) { create(:note_on_commit, author: user, project: project, commit_id: 12345678, note: 'Bug here') }
+ context "when a comment is in commits" do
+ context "when comment belongs to an invalid commit" do
+ let(:comment) { create(:note_on_commit, author: user, project: project, commit_id: 12345678, note: "Bug here") }
- it 'finds a commit' do
- page.within('.search') do
- fill_in('search', with: comment.note)
- click_button('Go')
+ it "finds a commit" do
+ page.within(".search") do
+ fill_in("search", with: comment.note)
+ click_button("Go")
end
- click_link('Comments')
+ click_link("Comments")
- expect(page).to have_text('Commit deleted')
- expect(page).to have_text('12345678')
+ expect(page).to have_text("Commit deleted")
+ expect(page).to have_text("12345678")
end
end
end
- context 'when a comment is in a snippet' do
- let(:snippet) { create(:project_snippet, :private, project: project, author: user, title: 'Some title') }
- let(:comment) { create(:note, noteable: snippet, author: user, note: 'Supercalifragilisticexpialidocious', project: project) }
+ context "when a comment is in a snippet" do
+ let(:snippet) { create(:project_snippet, :private, project: project, author: user, title: "Some title") }
+ let(:comment) { create(:note, noteable: snippet, author: user, note: "Supercalifragilisticexpialidocious", project: project) }
- it 'finds a snippet' do
- page.within('.search') do
- fill_in('search', with: comment.note)
- click_button('Go')
+ it "finds a snippet" do
+ page.within(".search") do
+ fill_in("search", with: comment.note)
+ click_button("Go")
end
- click_link('Comments')
+ click_link("Comments")
expect(page).to have_link(snippet.title)
end
diff --git a/spec/features/search/user_searches_for_commits_spec.rb b/spec/features/search/user_searches_for_commits_spec.rb
index 28cae444588..8c6dcbbdfaa 100644
--- a/spec/features/search/user_searches_for_commits_spec.rb
+++ b/spec/features/search/user_searches_for_commits_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for commits' do
+describe "User searches for commits" do
let(:project) { create(:project, :repository) }
- let(:sha) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
+ let(:sha) { "6d394385cf567f80a8fd85055db1ab4c5295806f" }
let(:user) { create(:user) }
before do
@@ -12,38 +12,38 @@ describe 'User searches for commits' do
visit(search_path(project_id: project.id))
end
- context 'when searching by SHA' do
- it 'finds a commit and redirects to its page' do
- fill_in('search', with: sha)
- click_button('Search')
+ context "when searching by SHA" do
+ it "finds a commit and redirects to its page" do
+ fill_in("search", with: sha)
+ click_button("Search")
expect(page).to have_current_path(project_commit_path(project, sha))
end
- it 'finds a commit in uppercase and redirects to its page' do
- fill_in('search', with: sha.upcase)
- click_button('Search')
+ it "finds a commit in uppercase and redirects to its page" do
+ fill_in("search", with: sha.upcase)
+ click_button("Search")
expect(page).to have_current_path(project_commit_path(project, sha))
end
end
- context 'when searching by message' do
- it 'finds a commit and holds on /search page' do
- create_commit('Message referencing another sha: "deadbeef"', project, user, 'master')
+ context "when searching by message" do
+ it "finds a commit and holds on /search page" do
+ create_commit('Message referencing another sha: "deadbeef"', project, user, "master")
- fill_in('search', with: 'deadbeef')
- click_button('Search')
+ fill_in("search", with: "deadbeef")
+ click_button("Search")
- expect(page).to have_current_path('/search', only_path: true)
+ expect(page).to have_current_path("/search", only_path: true)
end
- it 'finds multiple commits' do
- fill_in('search', with: 'See merge request')
- click_button('Search')
- click_link('Commits')
+ it "finds multiple commits" do
+ fill_in("search", with: "See merge request")
+ click_button("Search")
+ click_link("Commits")
- expect(page).to have_selector('.commit-row-description', count: 9)
+ expect(page).to have_selector(".commit-row-description", count: 9)
end
end
end
diff --git a/spec/features/search/user_searches_for_issues_spec.rb b/spec/features/search/user_searches_for_issues_spec.rb
index 4bff269f89e..5368e0f4133 100644
--- a/spec/features/search/user_searches_for_issues_spec.rb
+++ b/spec/features/search/user_searches_for_issues_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for issues', :js do
+describe "User searches for issues", :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- let!(:issue1) { create(:issue, title: 'Foo', project: project) }
- let!(:issue2) { create(:issue, title: 'Bar', project: project) }
+ let!(:issue1) { create(:issue, title: "Foo", project: project) }
+ let!(:issue2) { create(:issue, title: "Bar", project: project) }
- context 'when signed in' do
+ context "when signed in" do
before do
project.add_maintainer(user)
sign_in(user)
@@ -14,62 +14,62 @@ describe 'User searches for issues', :js do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds an issue' do
- fill_in('dashboard_search', with: issue1.title)
- find('.btn-search').click
+ it "finds an issue" do
+ fill_in("dashboard_search", with: issue1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Issues')
+ page.within(".search-filter") do
+ click_link("Issues")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(issue1.title).and have_no_link(issue2.title)
end
end
- context 'when on a project page' do
- it 'finds an issue' do
- find('.js-search-project-dropdown').click
+ context "when on a project page" do
+ it "finds an issue" do
+ find(".js-search-project-dropdown").click
- page.within('.project-filter') do
+ page.within(".project-filter") do
click_link(project.full_name)
end
- fill_in('dashboard_search', with: issue1.title)
- find('.btn-search').click
+ fill_in("dashboard_search", with: issue1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Issues')
+ page.within(".search-filter") do
+ click_link("Issues")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(issue1.title).and have_no_link(issue2.title)
end
end
end
end
- context 'when signed out' do
+ context "when signed out" do
let(:project) { create(:project, :public) }
before do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds an issue' do
- fill_in('dashboard_search', with: issue1.title)
- find('.btn-search').click
+ it "finds an issue" do
+ fill_in("dashboard_search", with: issue1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Issues')
+ page.within(".search-filter") do
+ click_link("Issues")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(issue1.title).and have_no_link(issue2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(issue1.title).and have_no_link(issue2.title)
end
end
end
diff --git a/spec/features/search/user_searches_for_merge_requests_spec.rb b/spec/features/search/user_searches_for_merge_requests_spec.rb
index 75d44e413cb..715b01c5fca 100644
--- a/spec/features/search/user_searches_for_merge_requests_spec.rb
+++ b/spec/features/search/user_searches_for_merge_requests_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for merge requests', :js do
+describe "User searches for merge requests", :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- let!(:merge_request1) { create(:merge_request, title: 'Foo', source_project: project, target_project: project) }
- let!(:merge_request2) { create(:merge_request, :simple, title: 'Bar', source_project: project, target_project: project) }
+ let!(:merge_request1) { create(:merge_request, title: "Foo", source_project: project, target_project: project) }
+ let!(:merge_request2) { create(:merge_request, :simple, title: "Bar", source_project: project, target_project: project) }
before do
project.add_maintainer(user)
@@ -13,38 +13,38 @@ describe 'User searches for merge requests', :js do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds a merge request' do
- fill_in('dashboard_search', with: merge_request1.title)
- find('.btn-search').click
+ it "finds a merge request" do
+ fill_in("dashboard_search", with: merge_request1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Merge requests')
+ page.within(".search-filter") do
+ click_link("Merge requests")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
end
end
- context 'when on a project page' do
- it 'finds a merge request' do
- find('.js-search-project-dropdown').click
+ context "when on a project page" do
+ it "finds a merge request" do
+ find(".js-search-project-dropdown").click
- page.within('.project-filter') do
+ page.within(".project-filter") do
click_link(project.full_name)
end
- fill_in('dashboard_search', with: merge_request1.title)
- find('.btn-search').click
+ fill_in("dashboard_search", with: merge_request1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Merge requests')
+ page.within(".search-filter") do
+ click_link("Merge requests")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
end
end
end
diff --git a/spec/features/search/user_searches_for_milestones_spec.rb b/spec/features/search/user_searches_for_milestones_spec.rb
index 7d52c4c8bcc..edac2f43152 100644
--- a/spec/features/search/user_searches_for_milestones_spec.rb
+++ b/spec/features/search/user_searches_for_milestones_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for milestones', :js do
+describe "User searches for milestones", :js do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- let!(:milestone1) { create(:milestone, title: 'Foo', project: project) }
- let!(:milestone2) { create(:milestone, title: 'Bar', project: project) }
+ let!(:milestone1) { create(:milestone, title: "Foo", project: project) }
+ let!(:milestone2) { create(:milestone, title: "Bar", project: project) }
before do
project.add_maintainer(user)
@@ -13,38 +13,38 @@ describe 'User searches for milestones', :js do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds a milestone' do
- fill_in('dashboard_search', with: milestone1.title)
- find('.btn-search').click
+ it "finds a milestone" do
+ fill_in("dashboard_search", with: milestone1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Milestones')
+ page.within(".search-filter") do
+ click_link("Milestones")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(milestone1.title).and have_no_link(milestone2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(milestone1.title).and have_no_link(milestone2.title)
end
end
- context 'when on a project page' do
- it 'finds a milestone' do
- find('.js-search-project-dropdown').click
+ context "when on a project page" do
+ it "finds a milestone" do
+ find(".js-search-project-dropdown").click
- page.within('.project-filter') do
+ page.within(".project-filter") do
click_link(project.full_name)
end
- fill_in('dashboard_search', with: milestone1.title)
- find('.btn-search').click
+ fill_in("dashboard_search", with: milestone1.title)
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Milestones')
+ page.within(".search-filter") do
+ click_link("Milestones")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(milestone1.title).and have_no_link(milestone2.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(milestone1.title).and have_no_link(milestone2.title)
end
end
end
diff --git a/spec/features/search/user_searches_for_projects_spec.rb b/spec/features/search/user_searches_for_projects_spec.rb
index 242e437e41c..b3817da2fd5 100644
--- a/spec/features/search/user_searches_for_projects_spec.rb
+++ b/spec/features/search/user_searches_for_projects_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for projects' do
- let!(:project) { create(:project, :public, name: 'Shop') }
+describe "User searches for projects" do
+ let!(:project) { create(:project, :public, name: "Shop") }
- context 'when signed out' do
- include_examples 'top right search form'
+ context "when signed out" do
+ include_examples "top right search form"
- it 'finds a project' do
+ it "finds a project" do
visit(search_path)
- fill_in('dashboard_search', with: project.name[0..3])
- click_button('Search')
+ fill_in("dashboard_search", with: project.name[0..3])
+ click_button("Search")
expect(page).to have_link(project.name)
end
- it 'preserves the group being searched in' do
+ it "preserves the group being searched in" do
visit(search_path(group_id: project.namespace.id))
- fill_in('search', with: 'foo')
- click_button('Search')
+ fill_in("search", with: "foo")
+ click_button("Search")
- expect(find('#group_id', visible: false).value).to eq(project.namespace.id.to_s)
+ expect(find("#group_id", visible: false).value).to eq(project.namespace.id.to_s)
end
- it 'preserves the project being searched in' do
+ it "preserves the project being searched in" do
visit(search_path(project_id: project.id))
- fill_in('search', with: 'foo')
- click_button('Search')
+ fill_in("search", with: "foo")
+ click_button("Search")
- expect(find('#project_id', visible: false).value).to eq(project.id.to_s)
+ expect(find("#project_id", visible: false).value).to eq(project.id.to_s)
end
end
end
diff --git a/spec/features/search/user_searches_for_wiki_pages_spec.rb b/spec/features/search/user_searches_for_wiki_pages_spec.rb
index 7225ca65492..a1fac140656 100644
--- a/spec/features/search/user_searches_for_wiki_pages_spec.rb
+++ b/spec/features/search/user_searches_for_wiki_pages_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User searches for wiki pages', :js do
+describe "User searches for wiki pages", :js do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
- let!(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: { title: 'test_wiki', content: 'Some Wiki content' }) }
+ let!(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: {title: "test_wiki", content: "Some Wiki content"}) }
before do
project.add_maintainer(user)
@@ -12,24 +12,24 @@ describe 'User searches for wiki pages', :js do
visit(search_path)
end
- include_examples 'top right search form'
+ include_examples "top right search form"
- it 'finds a page' do
- find('.js-search-project-dropdown').click
+ it "finds a page" do
+ find(".js-search-project-dropdown").click
- page.within('.project-filter') do
+ page.within(".project-filter") do
click_link(project.full_name)
end
- fill_in('dashboard_search', with: 'content')
- find('.btn-search').click
+ fill_in("dashboard_search", with: "content")
+ find(".btn-search").click
- page.within('.search-filter') do
- click_link('Wiki')
+ page.within(".search-filter") do
+ click_link("Wiki")
end
- page.within('.results') do
- expect(find(:css, '.search-results')).to have_link(wiki_page.title)
+ page.within(".results") do
+ expect(find(:css, ".search-results")).to have_link(wiki_page.title)
end
end
end
diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb
index 444de26733f..a33aff6d582 100644
--- a/spec/features/search/user_uses_header_search_field_spec.rb
+++ b/spec/features/search/user_uses_header_search_field_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User uses header search field' do
+describe "User uses header search field" do
include FilteredSearchHelpers
let(:project) { create(:project) }
@@ -11,124 +11,124 @@ describe 'User uses header search field' do
sign_in(user)
end
- context 'when user is in a global scope', :js do
+ context "when user is in a global scope", :js do
before do
visit(root_path)
- page.find('#search').click
+ page.find("#search").click
end
- context 'when clicking issues' do
- it 'shows assigned issues' do
- find('.search-input-container .dropdown-menu').click_link('Issues assigned to me')
+ context "when clicking issues" do
+ it "shows assigned issues" do
+ find(".search-input-container .dropdown-menu").click_link("Issues assigned to me")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
- it 'shows created issues' do
- find('.search-input-container .dropdown-menu').click_link("Issues I've created")
+ it "shows created issues" do
+ find(".search-input-container .dropdown-menu").click_link("Issues I've created")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
- context 'when clicking merge requests' do
+ context "when clicking merge requests" do
let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) }
- it 'shows assigned merge requests' do
- find('.search-input-container .dropdown-menu').click_link('Merge requests assigned to me')
+ it "shows assigned merge requests" do
+ find(".search-input-container .dropdown-menu").click_link("Merge requests assigned to me")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
- it 'shows created merge requests' do
- find('.search-input-container .dropdown-menu').click_link("Merge requests I've created")
+ it "shows created merge requests" do
+ find(".search-input-container .dropdown-menu").click_link("Merge requests I've created")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
end
- context 'when user is in a project scope' do
+ context "when user is in a project scope" do
before do
visit(project_path(project))
end
- it 'starts searching by pressing the enter key', :js do
- fill_in('search', with: 'gitlab')
- find('#search').native.send_keys(:enter)
+ it "starts searching by pressing the enter key", :js do
+ fill_in("search", with: "gitlab")
+ find("#search").native.send_keys(:enter)
- page.within('.breadcrumbs-sub-title') do
- expect(page).to have_content('Search')
+ page.within(".breadcrumbs-sub-title") do
+ expect(page).to have_content("Search")
end
end
- context 'when clicking the search field', :js do
+ context "when clicking the search field", :js do
before do
- page.find('#search').click
+ page.find("#search").click
end
- it 'shows category search dropdown' do
- expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i)
+ it "shows category search dropdown" do
+ expect(page).to have_selector(".dropdown-header", text: /#{project.name}/i)
end
- context 'when clicking issues' do
+ context "when clicking issues" do
let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
- it 'shows assigned issues' do
- find('.dropdown-menu').click_link('Issues assigned to me')
+ it "shows assigned issues" do
+ find(".dropdown-menu").click_link("Issues assigned to me")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
- it 'shows created issues' do
- find('.dropdown-menu').click_link("Issues I've created")
+ it "shows created issues" do
+ find(".dropdown-menu").click_link("Issues I've created")
- expect(page).to have_selector('.filtered-search')
+ expect(page).to have_selector(".filtered-search")
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
- context 'when clicking merge requests' do
+ context "when clicking merge requests" do
let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) }
- it 'shows assigned merge requests' do
- find('.dropdown-menu').click_link('Merge requests assigned to me')
+ it "shows assigned merge requests" do
+ find(".dropdown-menu").click_link("Merge requests assigned to me")
- expect(page).to have_selector('.merge-requests-holder')
+ expect(page).to have_selector(".merge-requests-holder")
expect_tokens([assignee_token(user.name)])
expect_filtered_search_input_empty
end
- it 'shows created merge requests' do
- find('.dropdown-menu').click_link("Merge requests I've created")
+ it "shows created merge requests" do
+ find(".dropdown-menu").click_link("Merge requests I've created")
- expect(page).to have_selector('.merge-requests-holder')
+ expect(page).to have_selector(".merge-requests-holder")
expect_tokens([author_token(user.name)])
expect_filtered_search_input_empty
end
end
end
- context 'when entering text into the search field', :js do
+ context "when entering text into the search field", :js do
before do
- page.within('.search-input-wrap') do
- fill_in('search', with: project.name[0..3])
+ page.within(".search-input-wrap") do
+ fill_in("search", with: project.name[0..3])
end
end
- it 'does not display the category search dropdown' do
- expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i)
+ it "does not display the category search dropdown" do
+ expect(page).not_to have_selector(".dropdown-header", text: /#{project.name}/i)
end
end
end
diff --git a/spec/features/search/user_uses_search_filters_spec.rb b/spec/features/search/user_uses_search_filters_spec.rb
index 0725ff178ac..f3238b7de76 100644
--- a/spec/features/search/user_uses_search_filters_spec.rb
+++ b/spec/features/search/user_uses_search_filters_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User uses search filters', :js do
+describe "User uses search filters", :js do
let(:group) { create(:group) }
let!(:group_project) { create(:project, group: group) }
let(:project) { create(:project, namespace: user.namespace) }
@@ -14,20 +14,20 @@ describe 'User uses search filters', :js do
visit(search_path)
end
- context 'when filtering by group' do
- it 'shows group projects' do
- find('.js-search-group-dropdown').click
+ context "when filtering by group" do
+ it "shows group projects" do
+ find(".js-search-group-dropdown").click
wait_for_requests
- page.within('.search-holder') do
+ page.within(".search-holder") do
click_link(group.name)
end
- expect(find('.js-search-group-dropdown')).to have_content(group.name)
+ expect(find(".js-search-group-dropdown")).to have_content(group.name)
- page.within('.project-filter') do
- find('.js-search-project-dropdown').click
+ page.within(".project-filter") do
+ find(".js-search-project-dropdown").click
wait_for_requests
@@ -36,17 +36,17 @@ describe 'User uses search filters', :js do
end
end
- context 'when filtering by project' do
- it 'shows a project' do
- page.within('.project-filter') do
- find('.js-search-project-dropdown').click
+ context "when filtering by project" do
+ it "shows a project" do
+ page.within(".project-filter") do
+ find(".js-search-project-dropdown").click
wait_for_requests
click_link(project.full_name)
end
- expect(find('.js-search-project-dropdown')).to have_content(project.full_name)
+ expect(find(".js-search-project-dropdown")).to have_content(project.full_name)
end
end
end
diff --git a/spec/features/security/admin_access_spec.rb b/spec/features/security/admin_access_spec.rb
index ff679034a36..35c39126e56 100644
--- a/spec/features/security/admin_access_spec.rb
+++ b/spec/features/security/admin_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Admin::Projects" do
include AccessMatchers
diff --git a/spec/features/security/dashboard_access_spec.rb b/spec/features/security/dashboard_access_spec.rb
index 07cddc92ac4..d4ce70b9619 100644
--- a/spec/features/security/dashboard_access_spec.rb
+++ b/spec/features/security/dashboard_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Dashboard access" do
include AccessMatchers
diff --git a/spec/features/security/group/internal_access_spec.rb b/spec/features/security/group/internal_access_spec.rb
index 51b32ba6c03..d63b30b2de3 100644
--- a/spec/features/security/group/internal_access_spec.rb
+++ b/spec/features/security/group/internal_access_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Internal Group access' do
+describe "Internal Group access" do
include AccessMatchers
let(:group) { create(:group, :internal) }
@@ -12,13 +12,13 @@ describe 'Internal Group access' do
end
describe "Group should be internal" do
- describe '#internal?' do
+ describe "#internal?" do
subject { group.internal? }
it { is_expected.to be_truthy }
end
end
- describe 'GET /groups/:path' do
+ describe "GET /groups/:path" do
subject { group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -33,7 +33,7 @@ describe 'Internal Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/issues' do
+ describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -48,7 +48,7 @@ describe 'Internal Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/merge_requests' do
+ describe "GET /groups/:path/merge_requests" do
let(:project) { create(:project, :internal, :repository, group: group) }
subject { merge_requests_group_path(group) }
@@ -64,7 +64,7 @@ describe 'Internal Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/group_members' do
+ describe "GET /groups/:path/group_members" do
subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -79,7 +79,7 @@ describe 'Internal Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/edit' do
+ describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
diff --git a/spec/features/security/group/private_access_spec.rb b/spec/features/security/group/private_access_spec.rb
index 4705cd12d23..64719894687 100644
--- a/spec/features/security/group/private_access_spec.rb
+++ b/spec/features/security/group/private_access_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Private Group access' do
+describe "Private Group access" do
include AccessMatchers
let(:group) { create(:group, :private) }
@@ -12,13 +12,13 @@ describe 'Private Group access' do
end
describe "Group should be private" do
- describe '#private?' do
+ describe "#private?" do
subject { group.private? }
it { is_expected.to be_truthy }
end
end
- describe 'GET /groups/:path' do
+ describe "GET /groups/:path" do
subject { group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -33,7 +33,7 @@ describe 'Private Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/issues' do
+ describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -48,7 +48,7 @@ describe 'Private Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/merge_requests' do
+ describe "GET /groups/:path/merge_requests" do
let(:project) { create(:project, :private, :repository, group: group) }
subject { merge_requests_group_path(group) }
@@ -64,7 +64,7 @@ describe 'Private Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/group_members' do
+ describe "GET /groups/:path/group_members" do
subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -79,7 +79,7 @@ describe 'Private Group access' do
it { is_expected.to be_denied_for(:visitor) }
end
- describe 'GET /groups/:path/edit' do
+ describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
diff --git a/spec/features/security/group/public_access_spec.rb b/spec/features/security/group/public_access_spec.rb
index 3a53c3c2bc7..a0023c68c97 100644
--- a/spec/features/security/group/public_access_spec.rb
+++ b/spec/features/security/group/public_access_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Public Group access' do
+describe "Public Group access" do
include AccessMatchers
let(:group) { create(:group, :public) }
@@ -12,13 +12,13 @@ describe 'Public Group access' do
end
describe "Group should be public" do
- describe '#public?' do
+ describe "#public?" do
subject { group.public? }
it { is_expected.to be_truthy }
end
end
- describe 'GET /groups/:path' do
+ describe "GET /groups/:path" do
subject { group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -33,7 +33,7 @@ describe 'Public Group access' do
it { is_expected.to be_allowed_for(:visitor) }
end
- describe 'GET /groups/:path/issues' do
+ describe "GET /groups/:path/issues" do
subject { issues_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -48,7 +48,7 @@ describe 'Public Group access' do
it { is_expected.to be_allowed_for(:visitor) }
end
- describe 'GET /groups/:path/merge_requests' do
+ describe "GET /groups/:path/merge_requests" do
let(:project) { create(:project, :public, :repository, group: group) }
subject { merge_requests_group_path(group) }
@@ -64,7 +64,7 @@ describe 'Public Group access' do
it { is_expected.to be_allowed_for(:visitor) }
end
- describe 'GET /groups/:path/group_members' do
+ describe "GET /groups/:path/group_members" do
subject { group_group_members_path(group) }
it { is_expected.to be_allowed_for(:admin) }
@@ -79,7 +79,7 @@ describe 'Public Group access' do
it { is_expected.to be_allowed_for(:visitor) }
end
- describe 'GET /groups/:path/edit' do
+ describe "GET /groups/:path/edit" do
subject { edit_group_path(group) }
it { is_expected.to be_allowed_for(:admin) }
diff --git a/spec/features/security/profile_access_spec.rb b/spec/features/security/profile_access_spec.rb
index a198e65046f..f900d43ce37 100644
--- a/spec/features/security/profile_access_spec.rb
+++ b/spec/features/security/profile_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Profile access" do
include AccessMatchers
diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb
index e23000fa676..e756c6ad76e 100644
--- a/spec/features/security/project/internal_access_spec.rb
+++ b/spec/features/security/project/internal_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Internal Project Access" do
include AccessMatchers
@@ -6,7 +6,7 @@ describe "Internal Project Access" do
set(:project) { create(:project, :internal, :repository) }
describe "Project should be internal" do
- describe '#internal?' do
+ describe "#internal?" do
subject { project.internal? }
it { is_expected.to be_truthy }
end
@@ -126,7 +126,7 @@ describe "Internal Project Access" do
describe "GET /:project_path/blob" do
let(:commit) { project.repository.commit }
- subject { project_blob_path(project, File.join(commit.id, '.gitignore')) }
+ subject { project_blob_path(project, File.join(commit.id, ".gitignore")) }
it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) }
@@ -407,12 +407,12 @@ describe "Internal Project Access" do
end
end
- describe 'GET /:project_path/builds/:id/trace' do
+ describe "GET /:project_path/builds/:id/trace" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
subject { trace_project_job_path(project, build.id) }
- context 'when allowed for public and internal' do
+ context "when allowed for public and internal" do
before do
project.update(public_builds: true)
end
@@ -428,7 +428,7 @@ describe "Internal Project Access" do
it { is_expected.to be_denied_for(:visitor) }
end
- context 'when disallowed for public and internal' do
+ context "when disallowed for public and internal" do
before do
project.update(public_builds: false)
end
@@ -521,7 +521,7 @@ describe "Internal Project Access" do
let(:container_repository) { create(:container_repository) }
before do
- stub_container_registry_tags(repository: :any, tags: ['latest'])
+ stub_container_registry_tags(repository: :any, tags: ["latest"])
stub_container_registry_config(enabled: true)
project.container_repositories << container_repository
end
diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb
index f380bc122a7..ce337822f44 100644
--- a/spec/features/security/project/private_access_spec.rb
+++ b/spec/features/security/project/private_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Private Project Access" do
include AccessMatchers
@@ -6,7 +6,7 @@ describe "Private Project Access" do
set(:project) { create(:project, :private, :repository, public_builds: false) }
describe "Project should be private" do
- describe '#private?' do
+ describe "#private?" do
subject { project.private? }
it { is_expected.to be_truthy }
end
@@ -126,7 +126,7 @@ describe "Private Project Access" do
describe "GET /:project_path/blob" do
let(:commit) { project.repository.commit }
- subject { project_blob_path(project, File.join(commit.id, '.gitignore'))}
+ subject { project_blob_path(project, File.join(commit.id, ".gitignore"))}
it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) }
@@ -289,7 +289,7 @@ describe "Private Project Access" do
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) }
- context 'when public builds is enabled' do
+ context "when public builds is enabled" do
before do
project.update(public_builds: true)
end
@@ -297,7 +297,7 @@ describe "Private Project Access" do
it { is_expected.to be_allowed_for(:guest).of(project) }
end
- context 'when public buils are disabled' do
+ context "when public buils are disabled" do
it { is_expected.to be_denied_for(:guest).of(project) }
end
end
@@ -316,7 +316,7 @@ describe "Private Project Access" do
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) }
- context 'when public builds is enabled' do
+ context "when public builds is enabled" do
before do
project.update(public_builds: true)
end
@@ -324,7 +324,7 @@ describe "Private Project Access" do
it { is_expected.to be_allowed_for(:guest).of(project) }
end
- context 'when public buils are disabled' do
+ context "when public buils are disabled" do
it { is_expected.to be_denied_for(:guest).of(project) }
end
end
@@ -342,7 +342,7 @@ describe "Private Project Access" do
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) }
- context 'when public builds is enabled' do
+ context "when public builds is enabled" do
before do
project.update(public_builds: true)
end
@@ -350,7 +350,7 @@ describe "Private Project Access" do
it { is_expected.to be_allowed_for(:guest).of(project) }
end
- context 'when public buils are disabled' do
+ context "when public buils are disabled" do
it { is_expected.to be_denied_for(:guest).of(project) }
end
end
@@ -370,7 +370,7 @@ describe "Private Project Access" do
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) }
- context 'when public builds is enabled' do
+ context "when public builds is enabled" do
before do
project.update(public_builds: true)
end
@@ -378,7 +378,7 @@ describe "Private Project Access" do
it { is_expected.to be_allowed_for(:guest).of(project) }
end
- context 'when public buils are disabled' do
+ context "when public buils are disabled" do
before do
project.public_builds = false
project.save
@@ -388,7 +388,7 @@ describe "Private Project Access" do
end
end
- describe 'GET /:project_path/builds/:id/trace' do
+ describe "GET /:project_path/builds/:id/trace" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
subject { trace_project_job_path(project, build.id) }
@@ -403,7 +403,7 @@ describe "Private Project Access" do
it { is_expected.to be_denied_for(:external) }
it { is_expected.to be_denied_for(:visitor) }
- context 'when public builds is enabled' do
+ context "when public builds is enabled" do
before do
project.update(public_builds: true)
end
@@ -411,7 +411,7 @@ describe "Private Project Access" do
it { is_expected.to be_allowed_for(:guest).of(project) }
end
- context 'when public builds is disabled' do
+ context "when public builds is disabled" do
before do
project.update(public_builds: false)
end
@@ -524,7 +524,7 @@ describe "Private Project Access" do
let(:container_repository) { create(:container_repository) }
before do
- stub_container_registry_tags(repository: :any, tags: ['latest'])
+ stub_container_registry_tags(repository: :any, tags: ["latest"])
stub_container_registry_config(enabled: true)
project.container_repositories << container_repository
end
diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb
index 57d56371719..ac4ba2c6ee9 100644
--- a/spec/features/security/project/public_access_spec.rb
+++ b/spec/features/security/project/public_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Public Project Access" do
include AccessMatchers
@@ -6,7 +6,7 @@ describe "Public Project Access" do
set(:project) { create(:project, :public, :repository) }
describe "Project should be public" do
- describe '#public?' do
+ describe "#public?" do
subject { project.public? }
it { is_expected.to be_truthy }
end
@@ -227,12 +227,12 @@ describe "Public Project Access" do
end
end
- describe 'GET /:project_path/builds/:id/trace' do
+ describe "GET /:project_path/builds/:id/trace" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
subject { trace_project_job_path(project, build.id) }
- context 'when allowed for public' do
+ context "when allowed for public" do
before do
project.update(public_builds: true)
end
@@ -248,7 +248,7 @@ describe "Public Project Access" do
it { is_expected.to be_allowed_for(:visitor) }
end
- context 'when disallowed for public' do
+ context "when disallowed for public" do
before do
project.update(public_builds: false)
end
@@ -340,7 +340,7 @@ describe "Public Project Access" do
describe "GET /:project_path/blob" do
let(:commit) { project.repository.commit }
- subject { project_blob_path(project, File.join(commit.id, '.gitignore')) }
+ subject { project_blob_path(project, File.join(commit.id, ".gitignore")) }
it { is_expected.to be_allowed_for(:admin) }
it { is_expected.to be_allowed_for(:owner).of(project) }
@@ -521,7 +521,7 @@ describe "Public Project Access" do
let(:container_repository) { create(:container_repository) }
before do
- stub_container_registry_tags(repository: :any, tags: ['latest'])
+ stub_container_registry_tags(repository: :any, tags: ["latest"])
stub_container_registry_config(enabled: true)
project.container_repositories << container_repository
end
diff --git a/spec/features/security/project/snippet/internal_access_spec.rb b/spec/features/security/project/snippet/internal_access_spec.rb
index 0c58fdf2f12..5370c2b7586 100644
--- a/spec/features/security/project/snippet/internal_access_spec.rb
+++ b/spec/features/security/project/snippet/internal_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Internal Project Snippets Access" do
include AccessMatchers
diff --git a/spec/features/security/project/snippet/private_access_spec.rb b/spec/features/security/project/snippet/private_access_spec.rb
index 420f1938763..34fee7fd08f 100644
--- a/spec/features/security/project/snippet/private_access_spec.rb
+++ b/spec/features/security/project/snippet/private_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Private Project Snippets Access" do
include AccessMatchers
diff --git a/spec/features/security/project/snippet/public_access_spec.rb b/spec/features/security/project/snippet/public_access_spec.rb
index 6c75902c6e9..b5d92a99148 100644
--- a/spec/features/security/project/snippet/public_access_spec.rb
+++ b/spec/features/security/project/snippet/public_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Public Project Snippets Access" do
include AccessMatchers
diff --git a/spec/features/signed_commits_spec.rb b/spec/features/signed_commits_spec.rb
index e2b3444272e..300dfee4322 100644
--- a/spec/features/signed_commits_spec.rb
+++ b/spec/features/signed_commits_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'GPG signed commits' do
+describe "GPG signed commits" do
let(:project) { create(:project, :public, :repository) }
- it 'changes from unverified to verified when the user changes his email to match the gpg key' do
+ it "changes from unverified to verified when the user changes his email to match the gpg key" do
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
- user = create(:user, email: 'unrelated.user@example.org')
+ user = create(:user, email: "unrelated.user@example.org")
perform_enqueued_jobs do
create :gpg_key, key: GpgHelpers::User1.public_key, user: user
@@ -15,8 +15,8 @@ describe 'GPG signed commits' do
visit project_commit_path(project, ref)
- expect(page).to have_link 'Unverified'
- expect(page).not_to have_link 'Verified'
+ expect(page).to have_link "Unverified"
+ expect(page).not_to have_link "Verified"
# user changes his email which makes the gpg key verified
perform_enqueued_jobs do
@@ -26,18 +26,18 @@ describe 'GPG signed commits' do
visit project_commit_path(project, ref)
- expect(page).not_to have_link 'Unverified'
- expect(page).to have_link 'Verified'
+ expect(page).not_to have_link "Unverified"
+ expect(page).to have_link "Verified"
end
- it 'changes from unverified to verified when the user adds the missing gpg key' do
+ it "changes from unverified to verified when the user adds the missing gpg key" do
ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA
user = create(:user, email: GpgHelpers::User1.emails.first)
visit project_commit_path(project, ref)
- expect(page).to have_link 'Unverified'
- expect(page).not_to have_link 'Verified'
+ expect(page).to have_link "Unverified"
+ expect(page).not_to have_link "Verified"
# user adds the gpg key which makes the signature valid
perform_enqueued_jobs do
@@ -46,13 +46,13 @@ describe 'GPG signed commits' do
visit project_commit_path(project, ref)
- expect(page).not_to have_link 'Unverified'
- expect(page).to have_link 'Verified'
+ expect(page).not_to have_link "Unverified"
+ expect(page).to have_link "Verified"
end
- context 'shows popover badges', :js do
+ context "shows popover badges", :js do
let(:user_1) do
- create :user, email: GpgHelpers::User1.emails.first, username: 'nannie.bernhard', name: 'Nannie Bernhard'
+ create :user, email: GpgHelpers::User1.emails.first, username: "nannie.bernhard", name: "Nannie Bernhard"
end
let(:user_1_key) do
@@ -62,7 +62,7 @@ describe 'GPG signed commits' do
end
let(:user_2) do
- create(:user, email: GpgHelpers::User2.emails.first, username: 'bette.cartwright', name: 'Bette Cartwright').tap do |user|
+ create(:user, email: GpgHelpers::User2.emails.first, username: "bette.cartwright", name: "Bette Cartwright").tap do |user|
# secondary, unverified email
create :email, user: user, email: GpgHelpers::User2.emails.last
end
@@ -74,58 +74,58 @@ describe 'GPG signed commits' do
end
end
- it 'unverified signature' do
+ it "unverified signature" do
visit project_commit_path(project, GpgHelpers::SIGNED_COMMIT_SHA)
- click_on 'Unverified'
+ click_on "Unverified"
- within '.popover' do
- expect(page).to have_content 'This commit was signed with an unverified signature.'
+ within ".popover" do
+ expect(page).to have_content "This commit was signed with an unverified signature."
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}"
end
end
- it 'unverified signature: user email does not match the committer email, but is the same user' do
+ it "unverified signature: user email does not match the committer email, but is the same user" do
user_2_key
visit project_commit_path(project, GpgHelpers::DIFFERING_EMAIL_SHA)
- click_on 'Unverified'
+ click_on "Unverified"
- within '.popover' do
- expect(page).to have_content 'This commit was signed with a verified signature, but the committer email is not verified to belong to the same user.'
- expect(page).to have_content 'Bette Cartwright'
- expect(page).to have_content '@bette.cartwright'
+ within ".popover" do
+ expect(page).to have_content "This commit was signed with a verified signature, but the committer email is not verified to belong to the same user."
+ expect(page).to have_content "Bette Cartwright"
+ expect(page).to have_content "@bette.cartwright"
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}"
end
end
- it 'unverified signature: user email does not match the committer email' do
+ it "unverified signature: user email does not match the committer email" do
user_2_key
visit project_commit_path(project, GpgHelpers::SIGNED_COMMIT_SHA)
- click_on 'Unverified'
+ click_on "Unverified"
- within '.popover' do
+ within ".popover" do
expect(page).to have_content "This commit was signed with a different user's verified signature."
- expect(page).to have_content 'Bette Cartwright'
- expect(page).to have_content '@bette.cartwright'
+ expect(page).to have_content "Bette Cartwright"
+ expect(page).to have_content "@bette.cartwright"
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User2.primary_keyid}"
end
end
- it 'verified and the gpg user has a gitlab profile' do
+ it "verified and the gpg user has a gitlab profile" do
user_1_key
visit project_commit_path(project, GpgHelpers::SIGNED_AND_AUTHORED_SHA)
- click_on 'Verified'
+ click_on "Verified"
- within '.popover' do
- expect(page).to have_content 'This commit was signed with a verified signature and the committer email is verified to belong to the same user.'
- expect(page).to have_content 'Nannie Bernhard'
- expect(page).to have_content '@nannie.bernhard'
+ within ".popover" do
+ expect(page).to have_content "This commit was signed with a verified signature and the committer email is verified to belong to the same user."
+ expect(page).to have_content "Nannie Bernhard"
+ expect(page).to have_content "@nannie.bernhard"
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}"
end
end
@@ -136,18 +136,18 @@ describe 'GPG signed commits' do
visit project_commit_path(project, GpgHelpers::SIGNED_AND_AUTHORED_SHA)
# wait for the signature to get generated
- expect(page).to have_link 'Verified'
+ expect(page).to have_link "Verified"
user_1.destroy!
refresh
- click_on 'Verified'
+ click_on "Verified"
- within '.popover' do
- expect(page).to have_content 'This commit was signed with a verified signature and the committer email is verified to belong to the same user.'
- expect(page).to have_content 'Nannie Bernhard'
- expect(page).to have_content 'nannie.bernhard@example.com'
+ within ".popover" do
+ expect(page).to have_content "This commit was signed with a verified signature and the committer email is verified to belong to the same user."
+ expect(page).to have_content "Nannie Bernhard"
+ expect(page).to have_content "nannie.bernhard@example.com"
expect(page).to have_content "GPG Key ID: #{GpgHelpers::User1.primary_keyid}"
end
end
diff --git a/spec/features/snippets/embedded_snippet_spec.rb b/spec/features/snippets/embedded_snippet_spec.rb
index ab661f6fc69..130f6bdcfbe 100644
--- a/spec/features/snippets/embedded_snippet_spec.rb
+++ b/spec/features/snippets/embedded_snippet_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Embedded Snippets' do
- let(:snippet) { create(:personal_snippet, :public, file_name: 'random_dir.rb', content: content) }
+describe "Embedded Snippets" do
+ let(:snippet) { create(:personal_snippet, :public, file_name: "random_dir.rb", content: content) }
let(:content) { "require 'fileutils'\nFileUtils.mkdir_p 'some/random_dir'\n" }
- it 'loads snippet', :js do
- script_url = "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}/#{snippet_path(snippet, format: 'js')}"
+ it "loads snippet", :js do
+ script_url = "http://#{Capybara.current_session.server.host}:#{Capybara.current_session.server.port}/#{snippet_path(snippet, format: "js")}"
embed_body = "<html><body><script src=\"#{script_url}\"></script></body></html>"
rack_app = proc do
- ['200', { 'Content-Type' => 'text/html' }, [embed_body]]
+ ["200", {"Content-Type" => "text/html"}, [embed_body]]
end
server = Capybara::Server.new(rack_app)
@@ -19,7 +19,7 @@ describe 'Embedded Snippets' do
expect(page).to have_content("random_dir.rb")
expect(page).to have_content("require 'fileutils'")
- expect(page).to have_link('Open raw')
- expect(page).to have_link('Download')
+ expect(page).to have_link("Open raw")
+ expect(page).to have_link("Download")
end
end
diff --git a/spec/features/snippets/explore_spec.rb b/spec/features/snippets/explore_spec.rb
index c08f25875f8..6669c5953f5 100644
--- a/spec/features/snippets/explore_spec.rb
+++ b/spec/features/snippets/explore_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Explore Snippets' do
+describe "Explore Snippets" do
let!(:public_snippet) { create(:personal_snippet, :public) }
let!(:internal_snippet) { create(:personal_snippet, :internal) }
let!(:private_snippet) { create(:personal_snippet, :private) }
- it 'User should see snippets that are not private' do
+ it "User should see snippets that are not private" do
sign_in create(:user)
visit explore_snippets_path
@@ -14,7 +14,7 @@ describe 'Explore Snippets' do
expect(page).not_to have_content(private_snippet.title)
end
- it 'External user should see only public snippets' do
+ it "External user should see only public snippets" do
sign_in create(:user, :external)
visit explore_snippets_path
@@ -23,7 +23,7 @@ describe 'Explore Snippets' do
expect(page).not_to have_content(private_snippet.title)
end
- it 'Not authenticated user should see only public snippets' do
+ it "Not authenticated user should see only public snippets" do
visit explore_snippets_path
expect(page).to have_content(public_snippet.title)
diff --git a/spec/features/snippets/internal_snippet_spec.rb b/spec/features/snippets/internal_snippet_spec.rb
index f6215b481dc..d267043165b 100644
--- a/spec/features/snippets/internal_snippet_spec.rb
+++ b/spec/features/snippets/internal_snippet_spec.rb
@@ -1,20 +1,20 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Internal Snippets', :js do
+describe "Internal Snippets", :js do
let(:internal_snippet) { create(:personal_snippet, :internal) }
- describe 'normal user' do
+ describe "normal user" do
before do
sign_in(create(:user))
end
- it 'sees internal snippets' do
+ it "sees internal snippets" do
visit snippet_path(internal_snippet)
expect(page).to have_content(internal_snippet.content)
end
- it 'sees raw internal snippets' do
+ it "sees raw internal snippets" do
visit raw_snippet_path(internal_snippet)
expect(page).to have_content(internal_snippet.content)
diff --git a/spec/features/snippets/notes_on_personal_snippets_spec.rb b/spec/features/snippets/notes_on_personal_snippets_spec.rb
index eeacaf5f72a..9ad5bea3f75 100644
--- a/spec/features/snippets/notes_on_personal_snippets_spec.rb
+++ b/spec/features/snippets/notes_on_personal_snippets_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Comments on personal snippets', :js do
+describe "Comments on personal snippets", :js do
include NoteInteractionHelpers
let!(:user) { create(:user) }
@@ -8,7 +8,7 @@ describe 'Comments on personal snippets', :js do
let!(:snippet_notes) do
[
create(:note_on_personal_snippet, noteable: snippet, author: user),
- create(:note_on_personal_snippet, noteable: snippet)
+ create(:note_on_personal_snippet, noteable: snippet),
]
end
let!(:other_note) { create(:note_on_personal_snippet) }
@@ -22,30 +22,30 @@ describe 'Comments on personal snippets', :js do
subject { page }
- context 'when viewing the snippet detail page' do
- it 'contains notes for a snippet with correct action icons' do
- expect(page).to have_selector('#notes-list li', count: 2)
+ context "when viewing the snippet detail page" do
+ it "contains notes for a snippet with correct action icons" do
+ expect(page).to have_selector("#notes-list li", count: 2)
open_more_actions_dropdown(snippet_notes[0])
# comment authored by current user
page.within("#notes-list li#note_#{snippet_notes[0].id}") do
expect(page).to have_content(snippet_notes[0].note)
- expect(page).to have_selector('.js-note-delete')
- expect(page).to have_selector('.note-emoji-button')
+ expect(page).to have_selector(".js-note-delete")
+ expect(page).to have_selector(".note-emoji-button")
end
- find('body').click # close dropdown
+ find("body").click # close dropdown
open_more_actions_dropdown(snippet_notes[1])
page.within("#notes-list li#note_#{snippet_notes[1].id}") do
expect(page).to have_content(snippet_notes[1].note)
- expect(page).not_to have_selector('.js-note-delete')
- expect(page).to have_selector('.note-emoji-button')
+ expect(page).not_to have_selector(".js-note-delete")
+ expect(page).to have_selector(".note-emoji-button")
end
end
- it 'shows the status of a note author' do
+ it "shows the status of a note author" do
status = create(:user_status, user: user)
visit snippet_path(snippet)
@@ -55,73 +55,73 @@ describe 'Comments on personal snippets', :js do
end
end
- context 'when submitting a note' do
- it 'shows a valid form' do
- is_expected.to have_css('.js-main-target-form', visible: true, count: 1)
- expect(find('.js-main-target-form .js-comment-button').value)
- .to eq('Comment')
+ context "when submitting a note" do
+ it "shows a valid form" do
+ is_expected.to have_css(".js-main-target-form", visible: true, count: 1)
+ expect(find(".js-main-target-form .js-comment-button").value)
+ .to eq("Comment")
- page.within('.js-main-target-form') do
- expect(page).not_to have_link('Cancel')
+ page.within(".js-main-target-form") do
+ expect(page).not_to have_link("Cancel")
end
end
- it 'previews a note' do
- fill_in 'note[note]', with: 'This is **awesome**!'
- find('.js-md-preview-button').click
+ it "previews a note" do
+ fill_in "note[note]", with: "This is **awesome**!"
+ find(".js-md-preview-button").click
- page.within('.new-note .md-preview') do
- expect(page).to have_content('This is awesome!')
- expect(page).to have_selector('strong')
+ page.within(".new-note .md-preview") do
+ expect(page).to have_content("This is awesome!")
+ expect(page).to have_selector("strong")
end
end
- it 'creates a note' do
- fill_in 'note[note]', with: 'This is **awesome**!'
- click_button 'Comment'
+ it "creates a note" do
+ fill_in "note[note]", with: "This is **awesome**!"
+ click_button "Comment"
- expect(find('div#notes')).to have_content('This is awesome!')
+ expect(find("div#notes")).to have_content("This is awesome!")
end
- it 'should not have autocomplete' do
+ it "should not have autocomplete" do
wait_for_requests
- find('#note_note').native.send_keys('')
- fill_in 'note[note]', with: '@'
+ find("#note_note").native.send_keys("")
+ fill_in "note[note]", with: "@"
wait_for_requests
# This selector probably won't be in place even if autocomplete was enabled
# but we want to make sure
- expect(page).not_to have_selector('.atwho-view')
+ expect(page).not_to have_selector(".atwho-view")
end
end
- context 'when editing a note' do
- it 'changes the text' do
- find('.js-note-edit').click
+ context "when editing a note" do
+ it "changes the text" do
+ find(".js-note-edit").click
- page.within('.current-note-edit-form') do
- fill_in 'note[note]', with: 'new content'
- find('.btn-success').click
+ page.within(".current-note-edit-form") do
+ fill_in "note[note]", with: "new content"
+ find(".btn-success").click
end
page.within("#notes-list li#note_#{snippet_notes[0].id}") do
- edited_text = find('.edited-text')
+ edited_text = find(".edited-text")
- expect(page).to have_css('.note_edited_ago')
- expect(page).to have_content('new content')
- expect(edited_text).to have_selector('.note_edited_ago')
+ expect(page).to have_css(".note_edited_ago")
+ expect(page).to have_content("new content")
+ expect(edited_text).to have_selector(".note_edited_ago")
end
end
end
- context 'when deleting a note' do
- it 'removes the note from the snippet detail page' do
+ context "when deleting a note" do
+ it "removes the note from the snippet detail page" do
open_more_actions_dropdown(snippet_notes[0])
page.within("#notes-list li#note_#{snippet_notes[0].id}") do
- accept_confirm { click_on 'Delete comment' }
+ accept_confirm { click_on "Delete comment" }
end
wait_for_requests
diff --git a/spec/features/snippets/public_snippets_spec.rb b/spec/features/snippets/public_snippets_spec.rb
index 71c72b98fad..d97287ba0f6 100644
--- a/spec/features/snippets/public_snippets_spec.rb
+++ b/spec/features/snippets/public_snippets_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Public Snippets', :js do
- it 'Unauthenticated user should see public snippets' do
+describe "Public Snippets", :js do
+ it "Unauthenticated user should see public snippets" do
public_snippet = create(:personal_snippet, :public)
visit snippet_path(public_snippet)
@@ -10,7 +10,7 @@ describe 'Public Snippets', :js do
expect(page).to have_content(public_snippet.content)
end
- it 'Unauthenticated user should see raw public snippets' do
+ it "Unauthenticated user should see raw public snippets" do
public_snippet = create(:personal_snippet, :public)
visit raw_snippet_path(public_snippet)
diff --git a/spec/features/snippets/search_snippets_spec.rb b/spec/features/snippets/search_snippets_spec.rb
index c137b0bcd96..bda91bb3f44 100644
--- a/spec/features/snippets/search_snippets_spec.rb
+++ b/spec/features/snippets/search_snippets_spec.rb
@@ -1,29 +1,29 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Search Snippets' do
- it 'User searches for snippets by title' do
- public_snippet = create(:personal_snippet, :public, title: 'Beginning and Middle')
- private_snippet = create(:personal_snippet, :private, title: 'Middle and End')
+describe "Search Snippets" do
+ it "User searches for snippets by title" do
+ public_snippet = create(:personal_snippet, :public, title: "Beginning and Middle")
+ private_snippet = create(:personal_snippet, :private, title: "Middle and End")
sign_in private_snippet.author
visit dashboard_snippets_path
- page.within '.search' do
- fill_in 'search', with: 'Middle'
- click_button 'Go'
+ page.within ".search" do
+ fill_in "search", with: "Middle"
+ click_button "Go"
end
- click_link 'Titles and Filenames'
+ click_link "Titles and Filenames"
expect(page).to have_link(public_snippet.title)
expect(page).to have_link(private_snippet.title)
end
- it 'User searches for snippet contents' do
+ it "User searches for snippet contents" do
create(:personal_snippet,
- :public,
- title: 'Many lined snippet',
- content: <<-CONTENT.strip_heredoc
+ :public,
+ title: "Many lined snippet",
+ content: <<-CONTENT.strip_heredoc
|line one
|line two
|line three
@@ -38,29 +38,29 @@ describe 'Search Snippets' do
|line twelve
|line thirteen
|line fourteen
- CONTENT
- )
+ CONTENT
+ )
sign_in create(:user)
visit dashboard_snippets_path
- page.within '.search' do
- fill_in 'search', with: 'line seven'
- click_button 'Go'
+ page.within ".search" do
+ fill_in "search", with: "line seven"
+ click_button "Go"
end
- expect(page).to have_content('line seven')
+ expect(page).to have_content("line seven")
# 3 lines before the matched line should be visible
- expect(page).to have_content('line six')
- expect(page).to have_content('line five')
- expect(page).to have_content('line four')
- expect(page).not_to have_content('line three')
+ expect(page).to have_content("line six")
+ expect(page).to have_content("line five")
+ expect(page).to have_content("line four")
+ expect(page).not_to have_content("line three")
# 3 lines after the matched line should be visible
- expect(page).to have_content('line eight')
- expect(page).to have_content('line nine')
- expect(page).to have_content('line ten')
- expect(page).not_to have_content('line eleven')
+ expect(page).to have_content("line eight")
+ expect(page).to have_content("line nine")
+ expect(page).to have_content("line ten")
+ expect(page).not_to have_content("line eleven")
end
end
diff --git a/spec/features/snippets/show_spec.rb b/spec/features/snippets/show_spec.rb
index 74fdfcf492e..86ab9561dbb 100644
--- a/spec/features/snippets/show_spec.rb
+++ b/spec/features/snippets/show_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Snippet', :js do
+describe "Snippet", :js do
let(:project) { create(:project, :repository) }
let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content) }
- context 'Ruby file' do
- let(:file_name) { 'popen.rb' }
- let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
+ context "Ruby file" do
+ let(:file_name) { "popen.rb" }
+ let(:content) { project.repository.blob_at("master", "files/ruby/popen.rb").data }
before do
visit snippet_path(snippet)
@@ -14,38 +14,38 @@ describe 'Snippet', :js do
wait_for_requests
end
- it 'displays the blob' do
+ it "displays the blob" do
aggregate_failures do
# shows highlighted Ruby code
expect(page).to have_content("require 'fileutils'")
# does not show a viewer switcher
- expect(page).not_to have_selector('.js-blob-viewer-switcher')
+ expect(page).not_to have_selector(".js-blob-viewer-switcher")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
end
- context 'Markdown file' do
- let(:file_name) { 'ruby-style-guide.md' }
- let(:content) { project.repository.blob_at('master', 'files/markdown/ruby-style-guide.md').data }
+ context "Markdown file" do
+ let(:file_name) { "ruby-style-guide.md" }
+ let(:content) { project.repository.blob_at("master", "files/markdown/ruby-style-guide.md").data }
- context 'visiting directly' do
+ context "visiting directly" do
before do
visit snippet_path(snippet)
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
@@ -55,40 +55,40 @@ describe 'Snippet', :js do
expect(page).to have_link("PEP-8")
# shows a viewer switcher
- expect(page).to have_selector('.js-blob-viewer-switcher')
+ expect(page).to have_selector(".js-blob-viewer-switcher")
# shows a disabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn.disabled')
+ expect(page).to have_selector(".js-copy-blob-source-btn.disabled")
# shows a raw button
- expect(page).to have_link('Open raw')
+ expect(page).to have_link("Open raw")
# shows a download button
- expect(page).to have_link('Download')
+ expect(page).to have_link("Download")
end
end
- context 'Markdown rendering' do
+ context "Markdown rendering" do
let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content) }
- let(:file_name) { 'test.md' }
+ let(:file_name) { "test.md" }
let(:content) { "1. one\n - sublist\n" }
- context 'when rendering default markdown' do
- it 'renders using CommonMark' do
+ context "when rendering default markdown" do
+ it "renders using CommonMark" do
expect(page).to have_content("sublist")
expect(page).not_to have_xpath("//ol//li//ul")
end
end
end
- context 'switching to the simple viewer' do
+ context "switching to the simple viewer" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=simple]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=simple]").click
wait_for_requests
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
@@ -98,60 +98,60 @@ describe 'Snippet', :js do
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
- context 'switching to the rich viewer again' do
+ context "switching to the rich viewer again" do
before do
- find('.js-blob-viewer-switch-btn[data-viewer=rich]').click
+ find(".js-blob-viewer-switch-btn[data-viewer=rich]").click
wait_for_requests
end
- it 'displays the blob using the rich viewer' do
+ it "displays the blob using the rich viewer" do
aggregate_failures do
# hides the simple viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]', visible: false)
expect(page).to have_selector('.blob-viewer[data-type="rich"]')
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
end
- context 'visiting with a line number anchor' do
+ context "visiting with a line number anchor" do
before do
- visit snippet_path(snippet, anchor: 'L1')
+ visit snippet_path(snippet, anchor: "L1")
wait_for_requests
end
- it 'displays the blob using the simple viewer' do
+ it "displays the blob using the simple viewer" do
aggregate_failures do
# hides the rich viewer
expect(page).to have_selector('.blob-viewer[data-type="simple"]')
expect(page).to have_selector('.blob-viewer[data-type="rich"]', visible: false)
# highlights the line in question
- expect(page).to have_selector('#LC1.hll')
+ expect(page).to have_selector("#LC1.hll")
# shows highlighted Markdown code
expect(page).to have_content("[PEP-8](http://www.python.org/dev/peps/pep-0008/)")
# shows an enabled copy button
- expect(page).to have_selector('.js-copy-blob-source-btn:not(.disabled)')
+ expect(page).to have_selector(".js-copy-blob-source-btn:not(.disabled)")
end
end
end
end
- it_behaves_like 'showing user status' do
- let(:file_name) { 'popen.rb' }
- let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data }
+ it_behaves_like "showing user status" do
+ let(:file_name) { "popen.rb" }
+ let(:content) { project.repository.blob_at("master", "files/ruby/popen.rb").data }
let(:user_with_status) { snippet.author }
subject { visit snippet_path(snippet) }
diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb
index 879c46d7c4e..3538afca07b 100644
--- a/spec/features/snippets/user_creates_snippet_spec.rb
+++ b/spec/features/snippets/user_creates_snippet_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User creates snippet', :js do
+describe "User creates snippet", :js do
include DropzoneHelper
let(:user) { create(:user) }
@@ -11,36 +11,36 @@ describe 'User creates snippet', :js do
end
def fill_form
- fill_in 'personal_snippet_title', with: 'My Snippet Title'
- fill_in 'personal_snippet_description', with: 'My Snippet **Description**'
- page.within('.file-editor') do
- find('.ace_text-input', visible: false).send_keys 'Hello World!'
+ fill_in "personal_snippet_title", with: "My Snippet Title"
+ fill_in "personal_snippet_description", with: "My Snippet **Description**"
+ page.within(".file-editor") do
+ find(".ace_text-input", visible: false).send_keys "Hello World!"
end
end
- it 'Authenticated user creates a snippet' do
+ it "Authenticated user creates a snippet" do
fill_form
- click_button('Create snippet')
+ click_button("Create snippet")
wait_for_requests
- expect(page).to have_content('My Snippet Title')
- page.within('.snippet-header .description') do
- expect(page).to have_content('My Snippet Description')
- expect(page).to have_selector('strong')
+ expect(page).to have_content("My Snippet Title")
+ page.within(".snippet-header .description") do
+ expect(page).to have_content("My Snippet Description")
+ expect(page).to have_selector("strong")
end
- expect(page).to have_content('Hello World!')
+ expect(page).to have_content("Hello World!")
end
- it 'previews a snippet with file' do
- fill_in 'personal_snippet_description', with: 'My Snippet'
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
- find('.js-md-preview-button').click
+ it "previews a snippet with file" do
+ fill_in "personal_snippet_description", with: "My Snippet"
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
+ find(".js-md-preview-button").click
- page.within('#new_personal_snippet .md-preview') do
- expect(page).to have_content('My Snippet')
+ page.within("#new_personal_snippet .md-preview") do
+ expect(page).to have_content("My Snippet")
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/uploads/-/system/temp/\h{32}/banana_sample\.gif\z})
reqs = inspect_requests { visit(link) }
@@ -48,60 +48,60 @@ describe 'User creates snippet', :js do
end
end
- it 'uploads a file when dragging into textarea' do
+ it "uploads a file when dragging into textarea" do
fill_form
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
- expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample')
+ expect(page.find_field("personal_snippet_description").value).to have_content("banana_sample")
- click_button('Create snippet')
+ click_button("Create snippet")
wait_for_requests
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/uploads/-/system/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z})
reqs = inspect_requests { visit(link) }
expect(reqs.first.status_code).to eq(200)
end
- it 'validation fails for the first time' do
- fill_in 'personal_snippet_title', with: 'My Snippet Title'
- click_button('Create snippet')
+ it "validation fails for the first time" do
+ fill_in "personal_snippet_title", with: "My Snippet Title"
+ click_button("Create snippet")
- expect(page).to have_selector('#error_explanation')
+ expect(page).to have_selector("#error_explanation")
fill_form
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
- click_button('Create snippet')
+ click_button("Create snippet")
wait_for_requests
- expect(page).to have_content('My Snippet Title')
- page.within('.snippet-header .description') do
- expect(page).to have_content('My Snippet Description')
- expect(page).to have_selector('strong')
+ expect(page).to have_content("My Snippet Title")
+ page.within(".snippet-header .description") do
+ expect(page).to have_content("My Snippet Description")
+ expect(page).to have_selector("strong")
end
- expect(page).to have_content('Hello World!')
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ expect(page).to have_content("Hello World!")
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/uploads/-/system/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z})
reqs = inspect_requests { visit(link) }
expect(reqs.first.status_code).to eq(200)
end
- it 'Authenticated user creates a snippet with + in filename' do
- fill_in 'personal_snippet_title', with: 'My Snippet Title'
- page.within('.file-editor') do
- find(:xpath, "//input[@id='personal_snippet_file_name']").set 'snippet+file+name'
- find('.ace_text-input', visible: false).send_keys 'Hello World!'
+ it "Authenticated user creates a snippet with + in filename" do
+ fill_in "personal_snippet_title", with: "My Snippet Title"
+ page.within(".file-editor") do
+ find(:xpath, "//input[@id='personal_snippet_file_name']").set "snippet+file+name"
+ find(".ace_text-input", visible: false).send_keys "Hello World!"
end
- click_button 'Create snippet'
+ click_button "Create snippet"
wait_for_requests
- expect(page).to have_content('My Snippet Title')
- expect(page).to have_content('snippet+file+name')
- expect(page).to have_content('Hello World!')
+ expect(page).to have_content("My Snippet Title")
+ expect(page).to have_content("snippet+file+name")
+ expect(page).to have_content("Hello World!")
end
end
diff --git a/spec/features/snippets/user_deletes_snippet_spec.rb b/spec/features/snippets/user_deletes_snippet_spec.rb
index 7bdccacb0fa..1eac9d9584e 100644
--- a/spec/features/snippets/user_deletes_snippet_spec.rb
+++ b/spec/features/snippets/user_deletes_snippet_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User deletes snippet' do
+describe "User deletes snippet" do
let(:user) { create(:user) }
let(:content) { 'puts "test"' }
let(:snippet) { create(:personal_snippet, :public, content: content, author: user) }
@@ -11,8 +11,8 @@ describe 'User deletes snippet' do
visit snippet_path(snippet)
end
- it 'deletes the snippet' do
- first(:link, 'Delete').click
+ it "deletes the snippet" do
+ first(:link, "Delete").click
expect(page).not_to have_content(snippet.title)
end
diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb
index 77f62990158..292d0ada4fc 100644
--- a/spec/features/snippets/user_edits_snippet_spec.rb
+++ b/spec/features/snippets/user_edits_snippet_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User edits snippet', :js do
+describe "User edits snippet", :js do
include DropzoneHelper
- let(:file_name) { 'test.rb' }
+ let(:file_name) { "test.rb" }
let(:content) { 'puts "test"' }
let(:user) { create(:user) }
@@ -16,40 +16,40 @@ describe 'User edits snippet', :js do
wait_for_requests
end
- it 'updates the snippet' do
- fill_in 'personal_snippet_title', with: 'New Snippet Title'
+ it "updates the snippet" do
+ fill_in "personal_snippet_title", with: "New Snippet Title"
- click_button('Save changes')
+ click_button("Save changes")
wait_for_requests
- expect(page).to have_content('New Snippet Title')
+ expect(page).to have_content("New Snippet Title")
end
- it 'updates the snippet with files attached' do
- dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
- expect(page.find_field('personal_snippet_description').value).to have_content('banana_sample')
+ it "updates the snippet with files attached" do
+ dropzone_file Rails.root.join("spec", "fixtures", "banana_sample.gif")
+ expect(page.find_field("personal_snippet_description").value).to have_content("banana_sample")
- click_button('Save changes')
+ click_button("Save changes")
wait_for_requests
- link = find('a.no-attachment-icon img[alt="banana_sample"]')['src']
+ link = find('a.no-attachment-icon img[alt="banana_sample"]')["src"]
expect(link).to match(%r{/uploads/-/system/personal_snippet/#{snippet.id}/\h{32}/banana_sample\.gif\z})
end
- it 'updates the snippet to make it internal' do
- choose 'Internal'
+ it "updates the snippet to make it internal" do
+ choose "Internal"
- click_button 'Save changes'
+ click_button "Save changes"
wait_for_requests
expect(page).to have_no_xpath("//i[@class='fa fa-lock']")
expect(page).to have_xpath("//i[@class='fa fa-shield']")
end
- it 'updates the snippet to make it public' do
- choose 'Public'
+ it "updates the snippet to make it public" do
+ choose "Public"
- click_button 'Save changes'
+ click_button "Save changes"
wait_for_requests
expect(page).to have_no_xpath("//i[@class='fa fa-lock']")
diff --git a/spec/features/snippets/user_sees_breadcrumb_links.rb b/spec/features/snippets/user_sees_breadcrumb_links.rb
index 696f2b93390..963b2a4cce4 100644
--- a/spec/features/snippets/user_sees_breadcrumb_links.rb
+++ b/spec/features/snippets/user_sees_breadcrumb_links.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'New user snippet breadcrumbs' do
+describe "New user snippet breadcrumbs" do
let(:user) { create(:user) }
before do
@@ -8,10 +8,10 @@ describe 'New user snippet breadcrumbs' do
visit new_snippet_path
end
- it 'display a link to user snippets and new user snippet pages' do
- page.within '.breadcrumbs' do
- expect(find_link('Snippets')[:href]).to end_with(dashboard_snippets_path)
- expect(find_link('New')[:href]).to end_with(new_snippet_path)
+ it "display a link to user snippets and new user snippet pages" do
+ page.within ".breadcrumbs" do
+ expect(find_link("Snippets")[:href]).to end_with(dashboard_snippets_path)
+ expect(find_link("New")[:href]).to end_with(new_snippet_path)
end
end
end
diff --git a/spec/features/snippets/user_snippets_spec.rb b/spec/features/snippets/user_snippets_spec.rb
index e3065a899cc..7119dd58118 100644
--- a/spec/features/snippets/user_snippets_spec.rb
+++ b/spec/features/snippets/user_snippets_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User Snippets' do
+describe "User Snippets" do
let(:author) { create(:user) }
let!(:public_snippet) { create(:personal_snippet, :public, author: author, title: "This is a public snippet") }
let!(:internal_snippet) { create(:personal_snippet, :internal, author: author, title: "This is an internal snippet") }
@@ -11,14 +11,14 @@ describe 'User Snippets' do
visit dashboard_snippets_path
end
- it 'View all of my snippets' do
+ it "View all of my snippets" do
expect(page).to have_content(public_snippet.title)
expect(page).to have_content(internal_snippet.title)
expect(page).to have_content(private_snippet.title)
end
- it 'View my public snippets' do
- page.within('.snippet-scope-menu') do
+ it "View my public snippets" do
+ page.within(".snippet-scope-menu") do
click_link "Public"
end
@@ -27,8 +27,8 @@ describe 'User Snippets' do
expect(page).not_to have_content(private_snippet.title)
end
- it 'View my internal snippets' do
- page.within('.snippet-scope-menu') do
+ it "View my internal snippets" do
+ page.within(".snippet-scope-menu") do
click_link "Internal"
end
@@ -37,8 +37,8 @@ describe 'User Snippets' do
expect(page).not_to have_content(private_snippet.title)
end
- it 'View my private snippets' do
- page.within('.snippet-scope-menu') do
+ it "View my private snippets" do
+ page.within(".snippet-scope-menu") do
click_link "Private"
end
diff --git a/spec/features/snippets_spec.rb b/spec/features/snippets_spec.rb
index 96c50f6c804..abd4260e0df 100644
--- a/spec/features/snippets_spec.rb
+++ b/spec/features/snippets_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Snippets' do
- context 'when the project has snippets' do
+describe "Snippets" do
+ context "when the project has snippets" do
let(:project) { create(:project, :public) }
let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) }
before do
@@ -9,6 +9,6 @@ describe 'Snippets' do
visit snippets_path(username: project.owner.username)
end
- it_behaves_like 'paginated snippets'
+ it_behaves_like "paginated snippets"
end
end
diff --git a/spec/features/tags/master_creates_tag_spec.rb b/spec/features/tags/master_creates_tag_spec.rb
index db2970f3340..c1ea7f01d82 100644
--- a/spec/features/tags/master_creates_tag_spec.rb
+++ b/spec/features/tags/master_creates_tag_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Maintainer creates tag' do
+describe "Maintainer creates tag" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
@@ -9,86 +9,88 @@ describe 'Maintainer creates tag' do
sign_in(user)
end
- context 'from tag list' do
+ context "from tag list" do
before do
visit project_tags_path(project)
end
- it 'with an invalid name displays an error' do
- create_tag_in_form(tag: 'v 1.0', ref: 'master')
+ it "with an invalid name displays an error" do
+ create_tag_in_form(tag: "v 1.0", ref: "master")
- expect(page).to have_content 'Tag name invalid'
+ expect(page).to have_content "Tag name invalid"
end
- it 'with an invalid reference displays an error' do
- create_tag_in_form(tag: 'v2.0', ref: 'foo')
+ it "with an invalid reference displays an error" do
+ create_tag_in_form(tag: "v2.0", ref: "foo")
- expect(page).to have_content 'Target foo is invalid'
+ expect(page).to have_content "Target foo is invalid"
end
- it 'that already exists displays an error' do
- create_tag_in_form(tag: 'v1.1.0', ref: 'master')
+ it "that already exists displays an error" do
+ create_tag_in_form(tag: "v1.1.0", ref: "master")
- expect(page).to have_content 'Tag v1.1.0 already exists'
+ expect(page).to have_content "Tag v1.1.0 already exists"
end
- it 'with multiline message displays the message in a <pre> block' do
- create_tag_in_form(tag: 'v3.0', ref: 'master', message: "Awesome tag message\n\n- hello\n- world")
+ it "with multiline message displays the message in a <pre> block" do
+ create_tag_in_form(tag: "v3.0", ref: "master", message: "Awesome tag message\n\n- hello\n- world")
expect(current_path).to eq(
- project_tag_path(project, 'v3.0'))
- expect(page).to have_content 'v3.0'
- page.within 'pre.wrap' do
+ project_tag_path(project, "v3.0")
+ )
+ expect(page).to have_content "v3.0"
+ page.within "pre.wrap" do
expect(page).to have_content "Awesome tag message\n\n- hello\n- world"
end
end
- it 'with multiline release notes parses the release note as Markdown' do
- create_tag_in_form(tag: 'v4.0', ref: 'master', desc: "Awesome release notes\n\n- hello\n- world")
+ it "with multiline release notes parses the release note as Markdown" do
+ create_tag_in_form(tag: "v4.0", ref: "master", desc: "Awesome release notes\n\n- hello\n- world")
expect(current_path).to eq(
- project_tag_path(project, 'v4.0'))
- expect(page).to have_content 'v4.0'
- page.within '.description' do
- expect(page).to have_content 'Awesome release notes'
- expect(page).to have_selector('ul li', count: 2)
+ project_tag_path(project, "v4.0")
+ )
+ expect(page).to have_content "v4.0"
+ page.within ".description" do
+ expect(page).to have_content "Awesome release notes"
+ expect(page).to have_selector("ul li", count: 2)
end
end
- it 'opens dropdown for ref', :js do
- click_link 'New tag'
- ref_row = find('.form-group:nth-of-type(2) .col-sm-10')
+ it "opens dropdown for ref", :js do
+ click_link "New tag"
+ ref_row = find(".form-group:nth-of-type(2) .col-sm-10")
page.within ref_row do
ref_input = find('[name="ref"]', visible: false)
- expect(ref_input.value).to eq 'master'
- expect(find('.dropdown-toggle-text')).to have_content 'master'
+ expect(ref_input.value).to eq "master"
+ expect(find(".dropdown-toggle-text")).to have_content "master"
- find('.js-branch-select').click
+ find(".js-branch-select").click
- expect(find('.dropdown-menu')).to have_content 'empty-branch'
+ expect(find(".dropdown-menu")).to have_content "empty-branch"
end
end
end
- context 'from new tag page' do
+ context "from new tag page" do
before do
visit new_project_tag_path(project)
end
- it 'description has emoji autocomplete', :js do
- find('#release_description').native.send_keys('')
- fill_in 'release_description', with: ':'
+ it "description has emoji autocomplete", :js do
+ find("#release_description").native.send_keys("")
+ fill_in "release_description", with: ":"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
end
def create_tag_in_form(tag:, ref:, message: nil, desc: nil)
- click_link 'New tag'
- fill_in 'tag_name', with: tag
- find('#ref', visible: false).set(ref)
- fill_in 'message', with: message unless message.nil?
- fill_in 'release_description', with: desc unless desc.nil?
- click_button 'Create tag'
+ click_link "New tag"
+ fill_in "tag_name", with: tag
+ find("#ref", visible: false).set(ref)
+ fill_in "message", with: message unless message.nil?
+ fill_in "release_description", with: desc unless desc.nil?
+ click_button "Create tag"
end
end
diff --git a/spec/features/tags/master_deletes_tag_spec.rb b/spec/features/tags/master_deletes_tag_spec.rb
index 8d567e925ef..18b2b2fc95b 100644
--- a/spec/features/tags/master_deletes_tag_spec.rb
+++ b/spec/features/tags/master_deletes_tag_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Maintainer deletes tag' do
+describe "Maintainer deletes tag" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
@@ -10,46 +10,48 @@ describe 'Maintainer deletes tag' do
visit project_tags_path(project)
end
- context 'from the tags list page', :js do
- it 'deletes the tag' do
- expect(page).to have_content 'v1.1.0'
+ context "from the tags list page", :js do
+ it "deletes the tag" do
+ expect(page).to have_content "v1.1.0"
delete_first_tag
- expect(page).not_to have_content 'v1.1.0'
+ expect(page).not_to have_content "v1.1.0"
end
end
- context 'from a specific tag page' do
- it 'deletes the tag' do
- click_on 'v1.0.0'
+ context "from a specific tag page" do
+ it "deletes the tag" do
+ click_on "v1.0.0"
expect(current_path).to eq(
- project_tag_path(project, 'v1.0.0'))
+ project_tag_path(project, "v1.0.0")
+ )
- click_on 'Delete tag'
+ click_on "Delete tag"
expect(current_path).to eq(
- project_tags_path(project))
- expect(page).not_to have_content 'v1.0.0'
+ project_tags_path(project)
+ )
+ expect(page).not_to have_content "v1.0.0"
end
end
- context 'when pre-receive hook fails', :js do
+ context "when pre-receive hook fails", :js do
before do
allow_any_instance_of(Gitlab::GitalyClient::OperationService).to receive(:rm_tag)
- .and_raise(Gitlab::Git::PreReceiveError, 'Do not delete tags')
+ .and_raise(Gitlab::Git::PreReceiveError, "Do not delete tags")
end
- it 'shows the error message' do
+ it "shows the error message" do
delete_first_tag
- expect(page).to have_content('Do not delete tags')
+ expect(page).to have_content("Do not delete tags")
end
end
def delete_first_tag
- page.within('.content') do
- accept_confirm { first('.btn-remove').click }
+ page.within(".content") do
+ accept_confirm { first(".btn-remove").click }
end
end
end
diff --git a/spec/features/tags/master_updates_tag_spec.rb b/spec/features/tags/master_updates_tag_spec.rb
index d8b5b3c4cc4..e2cec8bc304 100644
--- a/spec/features/tags/master_updates_tag_spec.rb
+++ b/spec/features/tags/master_updates_tag_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Maintainer updates tag' do
+describe "Maintainer updates tag" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
@@ -10,44 +10,46 @@ describe 'Maintainer updates tag' do
visit project_tags_path(project)
end
- context 'from the tags list page' do
- it 'updates the release notes' do
- page.within(first('.content-list .controls')) do
- click_link 'Edit release notes'
+ context "from the tags list page" do
+ it "updates the release notes" do
+ page.within(first(".content-list .controls")) do
+ click_link "Edit release notes"
end
- fill_in 'release_description', with: 'Awesome release notes'
- click_button 'Save changes'
+ fill_in "release_description", with: "Awesome release notes"
+ click_button "Save changes"
expect(current_path).to eq(
- project_tag_path(project, 'v1.1.0'))
- expect(page).to have_content 'v1.1.0'
- expect(page).to have_content 'Awesome release notes'
+ project_tag_path(project, "v1.1.0")
+ )
+ expect(page).to have_content "v1.1.0"
+ expect(page).to have_content "Awesome release notes"
end
- it 'description has emoji autocomplete', :js do
- page.within(first('.content-list .controls')) do
- click_link 'Edit release notes'
+ it "description has emoji autocomplete", :js do
+ page.within(first(".content-list .controls")) do
+ click_link "Edit release notes"
end
- find('#release_description').native.send_keys('')
- fill_in 'release_description', with: ':'
+ find("#release_description").native.send_keys("")
+ fill_in "release_description", with: ":"
- expect(page).to have_selector('.atwho-view')
+ expect(page).to have_selector(".atwho-view")
end
end
- context 'from a specific tag page' do
- it 'updates the release notes' do
- click_on 'v1.1.0'
- click_link 'Edit release notes'
- fill_in 'release_description', with: 'Awesome release notes'
- click_button 'Save changes'
+ context "from a specific tag page" do
+ it "updates the release notes" do
+ click_on "v1.1.0"
+ click_link "Edit release notes"
+ fill_in "release_description", with: "Awesome release notes"
+ click_button "Save changes"
expect(current_path).to eq(
- project_tag_path(project, 'v1.1.0'))
- expect(page).to have_content 'v1.1.0'
- expect(page).to have_content 'Awesome release notes'
+ project_tag_path(project, "v1.1.0")
+ )
+ expect(page).to have_content "v1.1.0"
+ expect(page).to have_content "Awesome release notes"
end
end
end
diff --git a/spec/features/tags/master_views_tags_spec.rb b/spec/features/tags/master_views_tags_spec.rb
index 36cfeb5ed84..1310d99c56c 100644
--- a/spec/features/tags/master_views_tags_spec.rb
+++ b/spec/features/tags/master_views_tags_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Maintainer views tags' do
+describe "Maintainer views tags" do
let(:user) { create(:user) }
before do
@@ -8,23 +8,23 @@ describe 'Maintainer views tags' do
sign_in(user)
end
- context 'when project has no tags' do
+ context "when project has no tags" do
let(:project) { create(:project_empty_repo) }
before do
visit project_path(project)
- click_on 'Add README'
- fill_in :commit_message, with: 'Add a README file', visible: true
- click_button 'Commit changes'
+ click_on "Add README"
+ fill_in :commit_message, with: "Add a README file", visible: true
+ click_button "Commit changes"
visit project_tags_path(project)
end
- it 'displays a specific message' do
- expect(page).to have_content 'Repository has no tags yet.'
+ it "displays a specific message" do
+ expect(page).to have_content "Repository has no tags yet."
end
end
- context 'when project has tags' do
+ context "when project has tags" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:repository) { project.repository }
@@ -32,50 +32,55 @@ describe 'Maintainer views tags' do
visit project_tags_path(project)
end
- it 'avoids a N+1 query in branches index' do
+ it "avoids a N+1 query in branches index" do
control_count = ActiveRecord::QueryRecorder.new { visit project_tags_path(project) }.count
- %w(one two three four five).each { |tag| repository.add_tag(user, tag, 'master', 'foo') }
+ %w[one two three four five].each { |tag| repository.add_tag(user, tag, "master", "foo") }
expect { visit project_tags_path(project) }.not_to exceed_query_limit(control_count)
end
- it 'views the tags list page' do
- expect(page).to have_content 'v1.0.0'
+ it "views the tags list page" do
+ expect(page).to have_content "v1.0.0"
end
- it 'views a specific tag page' do
- click_on 'v1.0.0'
+ it "views a specific tag page" do
+ click_on "v1.0.0"
expect(current_path).to eq(
- project_tag_path(project, 'v1.0.0'))
- expect(page).to have_content 'v1.0.0'
- expect(page).to have_content 'This tag has no release notes.'
+ project_tag_path(project, "v1.0.0")
+ )
+ expect(page).to have_content "v1.0.0"
+ expect(page).to have_content "This tag has no release notes."
end
- describe 'links on the tag page' do
- it 'has a button to browse files' do
- click_on 'v1.0.0'
+ describe "links on the tag page" do
+ it "has a button to browse files" do
+ click_on "v1.0.0"
expect(current_path).to eq(
- project_tag_path(project, 'v1.0.0'))
+ project_tag_path(project, "v1.0.0")
+ )
- click_on 'Browse files'
+ click_on "Browse files"
expect(current_path).to eq(
- project_tree_path(project, 'v1.0.0'))
+ project_tree_path(project, "v1.0.0")
+ )
end
- it 'has a button to browse commits' do
- click_on 'v1.0.0'
+ it "has a button to browse commits" do
+ click_on "v1.0.0"
expect(current_path).to eq(
- project_tag_path(project, 'v1.0.0'))
+ project_tag_path(project, "v1.0.0")
+ )
- click_on 'Browse commits'
+ click_on "Browse commits"
expect(current_path).to eq(
- project_commits_path(project, 'v1.0.0'))
+ project_commits_path(project, "v1.0.0")
+ )
end
end
end
diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb
index 6fe840dccf6..0a5d96f74f0 100644
--- a/spec/features/task_lists_spec.rb
+++ b/spec/features/task_lists_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Task Lists' do
+describe "Task Lists" do
include Warden::Test::Helpers
let(:project) { create(:project, :repository) }
@@ -62,28 +62,28 @@ describe 'Task Lists' do
visit project_issue_path(project, issue)
end
- describe 'for Issues' do
- describe 'multiple tasks', :js do
+ describe "for Issues" do
+ describe "multiple tasks", :js do
let!(:issue) { create(:issue, description: markdown, author: user, project: project) }
- it 'renders' do
+ it "renders" do
visit_issue(project, issue)
wait_for_requests
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 6)
- expect(page).to have_selector('ul input[checked]', count: 2)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 6)
+ expect(page).to have_selector("ul input[checked]", count: 2)
end
- it 'contains the required selectors' do
+ it "contains the required selectors" do
visit_issue(project, issue)
wait_for_requests
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
- expect(page).to have_selector('a.btn-close')
+ expect(page).to have_selector("a.btn-close")
end
- it 'is only editable by author' do
+ it "is only editable by author" do
visit_issue(project, issue)
wait_for_requests
@@ -97,44 +97,44 @@ describe 'Task Lists' do
expect(page).to have_selector(".wiki .task-list .task-list-item .task-list-item-checkbox")
end
- it 'provides a summary on Issues#index' do
+ it "provides a summary on Issues#index" do
visit project_issues_path(project)
expect(page).to have_content("2 of 6 tasks completed")
end
end
- describe 'single incomplete task', :js do
+ describe "single incomplete task", :js do
let!(:issue) { create(:issue, description: singleIncompleteMarkdown, author: user, project: project) }
- it 'renders' do
+ it "renders" do
visit_issue(project, issue)
wait_for_requests
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 1)
- expect(page).to have_selector('ul input[checked]', count: 0)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 1)
+ expect(page).to have_selector("ul input[checked]", count: 0)
end
- it 'provides a summary on Issues#index' do
+ it "provides a summary on Issues#index" do
visit project_issues_path(project)
expect(page).to have_content("0 of 1 task completed")
end
end
- describe 'single complete task', :js do
+ describe "single complete task", :js do
let!(:issue) { create(:issue, description: singleCompleteMarkdown, author: user, project: project) }
- it 'renders' do
+ it "renders" do
visit_issue(project, issue)
wait_for_requests
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 1)
- expect(page).to have_selector('ul input[checked]', count: 1)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 1)
+ expect(page).to have_selector("ul input[checked]", count: 1)
end
- it 'provides a summary on Issues#index' do
+ it "provides a summary on Issues#index" do
visit project_issues_path(project)
expect(page).to have_content("1 of 1 task completed")
@@ -142,147 +142,147 @@ describe 'Task Lists' do
end
end
- describe 'for Notes' do
+ describe "for Notes" do
let!(:issue) { create(:issue, author: user, project: project) }
- describe 'multiple tasks' do
+ describe "multiple tasks" do
let!(:note) do
create(:note, note: markdown, noteable: issue,
project: project, author: user)
end
- it 'renders for note body', :js do
+ it "renders for note body", :js do
visit_issue(project, issue)
- expect(page).to have_selector('.note ul.task-list', count: 1)
- expect(page).to have_selector('.note li.task-list-item', count: 6)
- expect(page).to have_selector('.note ul input[checked]', count: 2)
+ expect(page).to have_selector(".note ul.task-list", count: 1)
+ expect(page).to have_selector(".note li.task-list-item", count: 6)
+ expect(page).to have_selector(".note ul input[checked]", count: 2)
end
- it 'contains the required selectors', :js do
+ it "contains the required selectors", :js do
visit_issue(project, issue)
- expect(page).to have_selector('.note .js-task-list-container')
- expect(page).to have_selector('.note .js-task-list-container .task-list .task-list-item .task-list-item-checkbox')
+ expect(page).to have_selector(".note .js-task-list-container")
+ expect(page).to have_selector(".note .js-task-list-container .task-list .task-list-item .task-list-item-checkbox")
end
- it 'is only editable by author', :js do
+ it "is only editable by author", :js do
visit_issue(project, issue)
- expect(page).to have_selector('.js-task-list-container')
+ expect(page).to have_selector(".js-task-list-container")
gitlab_sign_out
gitlab_sign_in(user2)
visit current_path
- expect(page).not_to have_selector('.js-task-list-container')
+ expect(page).not_to have_selector(".js-task-list-container")
end
end
- describe 'single incomplete task' do
+ describe "single incomplete task" do
let!(:note) do
create(:note, note: singleIncompleteMarkdown, noteable: issue,
project: project, author: user)
end
- it 'renders for note body', :js do
+ it "renders for note body", :js do
visit_issue(project, issue)
- expect(page).to have_selector('.note ul.task-list', count: 1)
- expect(page).to have_selector('.note li.task-list-item', count: 1)
- expect(page).to have_selector('.note ul input[checked]', count: 0)
+ expect(page).to have_selector(".note ul.task-list", count: 1)
+ expect(page).to have_selector(".note li.task-list-item", count: 1)
+ expect(page).to have_selector(".note ul input[checked]", count: 0)
end
end
- describe 'single complete task' do
+ describe "single complete task" do
let!(:note) do
create(:note, note: singleCompleteMarkdown, noteable: issue,
project: project, author: user)
end
- it 'renders for note body', :js do
+ it "renders for note body", :js do
visit_issue(project, issue)
- expect(page).to have_selector('.note ul.task-list', count: 1)
- expect(page).to have_selector('.note li.task-list-item', count: 1)
- expect(page).to have_selector('.note ul input[checked]', count: 1)
+ expect(page).to have_selector(".note ul.task-list", count: 1)
+ expect(page).to have_selector(".note li.task-list-item", count: 1)
+ expect(page).to have_selector(".note ul input[checked]", count: 1)
end
end
end
- describe 'for Merge Requests' do
+ describe "for Merge Requests" do
def visit_merge_request(project, merge)
visit project_merge_request_path(project, merge)
end
- describe 'multiple tasks' do
+ describe "multiple tasks" do
let(:project) { create(:project, :repository) }
let!(:merge) { create(:merge_request, :simple, description: markdown, author: user, source_project: project) }
- it 'renders for description' do
+ it "renders for description" do
visit_merge_request(project, merge)
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 6)
- expect(page).to have_selector('ul input[checked]', count: 2)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 6)
+ expect(page).to have_selector("ul input[checked]", count: 2)
end
- it 'contains the required selectors' do
+ it "contains the required selectors" do
visit_merge_request(project, merge)
- container = '.detail-page-description .description.js-task-list-container'
+ container = ".detail-page-description .description.js-task-list-container"
expect(page).to have_selector(container)
expect(page).to have_selector("#{container} .wiki .task-list .task-list-item .task-list-item-checkbox")
expect(page).to have_selector("#{container} .js-task-list-field")
- expect(page).to have_selector('form.js-issuable-update')
- expect(page).to have_selector('a.btn-close')
+ expect(page).to have_selector("form.js-issuable-update")
+ expect(page).to have_selector("a.btn-close")
end
- it 'is only editable by author' do
+ it "is only editable by author" do
visit_merge_request(project, merge)
- expect(page).to have_selector('.js-task-list-container')
+ expect(page).to have_selector(".js-task-list-container")
logout(:user)
login_as(user2)
visit current_path
- expect(page).not_to have_selector('.js-task-list-container')
+ expect(page).not_to have_selector(".js-task-list-container")
end
- it 'provides a summary on MergeRequests#index' do
+ it "provides a summary on MergeRequests#index" do
visit project_merge_requests_path(project)
expect(page).to have_content("2 of 6 tasks completed")
end
end
- describe 'single incomplete task' do
+ describe "single incomplete task" do
let!(:merge) { create(:merge_request, :simple, description: singleIncompleteMarkdown, author: user, source_project: project) }
- it 'renders for description' do
+ it "renders for description" do
visit_merge_request(project, merge)
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 1)
- expect(page).to have_selector('ul input[checked]', count: 0)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 1)
+ expect(page).to have_selector("ul input[checked]", count: 0)
end
- it 'provides a summary on MergeRequests#index' do
+ it "provides a summary on MergeRequests#index" do
visit project_merge_requests_path(project)
expect(page).to have_content("0 of 1 task completed")
end
end
- describe 'single complete task' do
+ describe "single complete task" do
let!(:merge) { create(:merge_request, :simple, description: singleCompleteMarkdown, author: user, source_project: project) }
- it 'renders for description' do
+ it "renders for description" do
visit_merge_request(project, merge)
- expect(page).to have_selector('ul.task-list', count: 1)
- expect(page).to have_selector('li.task-list-item', count: 1)
- expect(page).to have_selector('ul input[checked]', count: 1)
+ expect(page).to have_selector("ul.task-list", count: 1)
+ expect(page).to have_selector("li.task-list-item", count: 1)
+ expect(page).to have_selector("ul input[checked]", count: 1)
end
- it 'provides a summary on MergeRequests#index' do
+ it "provides a summary on MergeRequests#index" do
visit project_merge_requests_path(project)
expect(page).to have_content("1 of 1 task completed")
end
diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb
index 919859c145a..dbe9b1bda97 100644
--- a/spec/features/triggers_spec.rb
+++ b/spec/features/triggers_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Triggers', :js do
- let(:trigger_title) { 'trigger desc' }
+describe "Triggers", :js do
+ let(:trigger_title) { "trigger desc" }
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:guest_user) { create(:user) }
@@ -17,51 +17,51 @@ describe 'Triggers', :js do
visit project_settings_ci_cd_path(@project)
end
- describe 'create trigger workflow' do
- it 'prevents adding new trigger with no description' do
- fill_in 'trigger_description', with: ''
- click_button 'Add trigger'
+ describe "create trigger workflow" do
+ it "prevents adding new trigger with no description" do
+ fill_in "trigger_description", with: ""
+ click_button "Add trigger"
# See if input has error due to empty value
- expect(page.find('form.gl-show-field-errors .gl-field-error')).to be_visible
+ expect(page.find("form.gl-show-field-errors .gl-field-error")).to be_visible
end
- it 'adds new trigger with description' do
- fill_in 'trigger_description', with: 'trigger desc'
- click_button 'Add trigger'
+ it "adds new trigger with description" do
+ fill_in "trigger_description", with: "trigger desc"
+ click_button "Add trigger"
# See if "trigger creation successful" message displayed and description and owner are correct
- expect(page.find('.flash-notice')).to have_content 'Trigger was created successfully.'
- expect(page.find('.triggers-list')).to have_content 'trigger desc'
- expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
+ expect(page.find(".flash-notice")).to have_content "Trigger was created successfully."
+ expect(page.find(".triggers-list")).to have_content "trigger desc"
+ expect(page.find(".triggers-list .trigger-owner")).to have_content user.name
end
end
- describe 'edit trigger workflow' do
- let(:new_trigger_title) { 'new trigger' }
+ describe "edit trigger workflow" do
+ let(:new_trigger_title) { "new trigger" }
- it 'click on edit trigger opens edit trigger page' do
+ it "click on edit trigger opens edit trigger page" do
create(:ci_trigger, owner: user, project: @project, description: trigger_title)
visit project_settings_ci_cd_path(@project)
# See if edit page has correct descrption
find('a[title="Edit"]').send_keys(:return)
- expect(page.find('#trigger_description').value).to have_content 'trigger desc'
+ expect(page.find("#trigger_description").value).to have_content "trigger desc"
end
- it 'edit trigger and save' do
+ it "edit trigger and save" do
create(:ci_trigger, owner: user, project: @project, description: trigger_title)
visit project_settings_ci_cd_path(@project)
# See if edit page opens, then fill in new description and save
find('a[title="Edit"]').send_keys(:return)
- fill_in 'trigger_description', with: new_trigger_title
- click_button 'Save trigger'
+ fill_in "trigger_description", with: new_trigger_title
+ click_button "Save trigger"
# See if "trigger updated successfully" message displayed and description and owner are correct
- expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.'
- expect(page.find('.triggers-list')).to have_content new_trigger_title
- expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
+ expect(page.find(".flash-notice")).to have_content "Trigger was successfully updated."
+ expect(page.find(".triggers-list")).to have_content new_trigger_title
+ expect(page.find(".triggers-list .trigger-owner")).to have_content user.name
end
it 'edit "legacy" trigger and save' do
@@ -71,13 +71,13 @@ describe 'Triggers', :js do
# See if the trigger can be edited and description is blank
find('a[title="Edit"]').send_keys(:return)
- expect(page.find('#trigger_description').value).to have_content ''
+ expect(page.find("#trigger_description").value).to have_content ""
# See if trigger can be updated with description and saved successfully
- fill_in 'trigger_description', with: new_trigger_title
- click_button 'Save trigger'
- expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.'
- expect(page.find('.triggers-list')).to have_content new_trigger_title
+ fill_in "trigger_description", with: new_trigger_title
+ click_button "Save trigger"
+ expect(page.find(".flash-notice")).to have_content "Trigger was successfully updated."
+ expect(page.find(".triggers-list")).to have_content new_trigger_title
end
end
@@ -88,19 +88,19 @@ describe 'Triggers', :js do
end
it 'button "Take ownership" has correct alert' do
- expected_alert = 'By taking ownership you will bind this trigger to your user account. With this the trigger will have access to all your projects as if it was you. Are you sure?'
- expect(page.find('a.btn-trigger-take-ownership')['data-confirm']).to eq expected_alert
+ expected_alert = "By taking ownership you will bind this trigger to your user account. With this the trigger will have access to all your projects as if it was you. Are you sure?"
+ expect(page.find("a.btn-trigger-take-ownership")["data-confirm"]).to eq expected_alert
end
- it 'take trigger ownership' do
+ it "take trigger ownership" do
# See if "Take ownership" on trigger works post trigger creation
page.accept_confirm do
first(:link, "Take ownership").send_keys(:return)
end
- expect(page.find('.flash-notice')).to have_content 'Trigger was re-assigned.'
- expect(page.find('.triggers-list')).to have_content trigger_title
- expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
+ expect(page.find(".flash-notice")).to have_content "Trigger was re-assigned."
+ expect(page.find(".triggers-list")).to have_content trigger_title
+ expect(page.find(".triggers-list .trigger-owner")).to have_content user.name
end
end
@@ -111,24 +111,24 @@ describe 'Triggers', :js do
end
it 'button "Revoke" has correct alert' do
- expected_alert = 'By revoking a trigger you will break any processes making use of it. Are you sure?'
- expect(page.find('a.btn-trigger-revoke')['data-confirm']).to eq expected_alert
+ expected_alert = "By revoking a trigger you will break any processes making use of it. Are you sure?"
+ expect(page.find("a.btn-trigger-revoke")["data-confirm"]).to eq expected_alert
end
- it 'revoke trigger' do
+ it "revoke trigger" do
# See if "Revoke" on trigger works post trigger creation
page.accept_confirm do
- find('a.btn-trigger-revoke').send_keys(:return)
+ find("a.btn-trigger-revoke").send_keys(:return)
end
- expect(page.find('.flash-notice')).to have_content 'Trigger removed'
- expect(page).to have_selector('p.settings-message.text-center.append-bottom-default')
+ expect(page.find(".flash-notice")).to have_content "Trigger removed"
+ expect(page).to have_selector("p.settings-message.text-center.append-bottom-default")
end
end
- describe 'show triggers workflow' do
- it 'contains trigger description placeholder' do
- expect(page.find('#trigger_description')['placeholder']).to eq 'Trigger description'
+ describe "show triggers workflow" do
+ it "contains trigger description placeholder" do
+ expect(page.find("#trigger_description")["placeholder"]).to eq "Trigger description"
end
it 'show "legacy" badge for legacy trigger' do
@@ -136,8 +136,8 @@ describe 'Triggers', :js do
visit project_settings_ci_cd_path(@project)
# See if trigger without owner (i.e. legacy) shows "legacy" badge and is editable
- expect(page.find('.triggers-list')).to have_content 'legacy'
- expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]')
+ expect(page.find(".triggers-list")).to have_content "legacy"
+ expect(page.find(".triggers-list")).to have_selector('a[title="Edit"]')
end
it 'show "invalid" badge for trigger with owner having insufficient permissions' do
@@ -145,8 +145,8 @@ describe 'Triggers', :js do
visit project_settings_ci_cd_path(@project)
# See if trigger without owner (i.e. legacy) shows "legacy" badge and is non-editable
- expect(page.find('.triggers-list')).to have_content 'invalid'
- expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]')
+ expect(page.find(".triggers-list")).to have_content "invalid"
+ expect(page.find(".triggers-list")).not_to have_selector('a[title="Edit"]')
end
it 'do not show "Edit" or full token for not owned trigger' do
@@ -155,12 +155,12 @@ describe 'Triggers', :js do
visit project_settings_ci_cd_path(@project)
# See if trigger not owned by current_user shows only first few token chars and doesn't have copy-to-clipboard button
- expect(page.find('.triggers-list')).to have_content(@project.triggers.first.token[0..3])
- expect(page.find('.triggers-list')).not_to have_selector('button.btn-clipboard')
+ expect(page.find(".triggers-list")).to have_content(@project.triggers.first.token[0..3])
+ expect(page.find(".triggers-list")).not_to have_selector("button.btn-clipboard")
# See if trigger owner name doesn't match with current_user and trigger is non-editable
- expect(page.find('.triggers-list .trigger-owner')).not_to have_content user.name
- expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]')
+ expect(page.find(".triggers-list .trigger-owner")).not_to have_content user.name
+ expect(page.find(".triggers-list")).not_to have_selector('a[title="Edit"]')
end
it 'show "Edit" and full token for owned trigger' do
@@ -168,12 +168,12 @@ describe 'Triggers', :js do
visit project_settings_ci_cd_path(@project)
# See if trigger shows full token and has copy-to-clipboard button
- expect(page.find('.triggers-list')).to have_content @project.triggers.first.token
- expect(page.find('.triggers-list')).to have_selector('button.btn-clipboard')
+ expect(page.find(".triggers-list")).to have_content @project.triggers.first.token
+ expect(page.find(".triggers-list")).to have_selector("button.btn-clipboard")
# See if trigger owner name matches with current_user and is editable
- expect(page.find('.triggers-list .trigger-owner')).to have_content user.name
- expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]')
+ expect(page.find(".triggers-list .trigger-owner")).to have_content user.name
+ expect(page.find(".triggers-list")).to have_selector('a[title="Edit"]')
end
end
end
diff --git a/spec/features/u2f_spec.rb b/spec/features/u2f_spec.rb
index ae9b65d1a39..a71124809ee 100644
--- a/spec/features/u2f_spec.rb
+++ b/spec/features/u2f_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
+describe "Using U2F (Universal 2nd Factor) Devices for Authentication", :js do
def manage_two_factor_authentication
- click_on 'Manage two-factor authentication'
+ click_on "Manage two-factor authentication"
expect(page).to have_content("Set up new U2F device")
wait_for_requests
end
- def register_u2f_device(u2f_device = nil, name: 'My device')
+ def register_u2f_device(u2f_device = nil, name: "My device")
u2f_device ||= FakeU2fDevice.new(page, name)
u2f_device.respond_to_u2f_registration
- click_on 'Set up new U2F device'
- expect(page).to have_content('Your device was successfully set up')
+ click_on "Set up new U2F device"
+ expect(page).to have_content("Your device was successfully set up")
fill_in "Pick a name", with: name
- click_on 'Register U2F device'
+ click_on "Register U2F device"
u2f_device
end
@@ -25,21 +25,21 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
user.update_attribute(:otp_required_for_login, true)
end
- describe 'when 2FA via OTP is disabled' do
+ describe "when 2FA via OTP is disabled" do
before do
user.update_attribute(:otp_required_for_login, false)
end
- it 'does not allow registering a new device' do
+ it "does not allow registering a new device" do
visit profile_account_path
- click_on 'Enable two-factor authentication'
+ click_on "Enable two-factor authentication"
- expect(page).to have_button('Set up new U2F device', disabled: true)
+ expect(page).to have_button("Set up new U2F device", disabled: true)
end
end
- describe 'when 2FA via OTP is enabled' do
- it 'allows registering a new device with a name' do
+ describe "when 2FA via OTP is enabled" do
+ it "allows registering a new device with a name" do
visit profile_account_path
manage_two_factor_authentication
expect(page).to have_content("You've already enabled two-factor authentication using one time password authenticators")
@@ -47,48 +47,48 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
u2f_device = register_u2f_device
expect(page).to have_content(u2f_device.name)
- expect(page).to have_content('Your U2F device was registered')
+ expect(page).to have_content("Your U2F device was registered")
end
- it 'allows registering more than one device' do
+ it "allows registering more than one device" do
visit profile_account_path
# First device
manage_two_factor_authentication
first_device = register_u2f_device
- expect(page).to have_content('Your U2F device was registered')
+ expect(page).to have_content("Your U2F device was registered")
# Second device
- second_device = register_u2f_device(name: 'My other device')
- expect(page).to have_content('Your U2F device was registered')
+ second_device = register_u2f_device(name: "My other device")
+ expect(page).to have_content("Your U2F device was registered")
expect(page).to have_content(first_device.name)
expect(page).to have_content(second_device.name)
expect(U2fRegistration.count).to eq(2)
end
- it 'allows deleting a device' do
+ it "allows deleting a device" do
visit profile_account_path
manage_two_factor_authentication
expect(page).to have_content("You've already enabled two-factor authentication using one time password authenticators")
first_u2f_device = register_u2f_device
- second_u2f_device = register_u2f_device(name: 'My other device')
+ second_u2f_device = register_u2f_device(name: "My other device")
accept_confirm { click_on "Delete", match: :first }
- expect(page).to have_content('Successfully deleted')
+ expect(page).to have_content("Successfully deleted")
expect(page.body).not_to match(first_u2f_device.name)
expect(page).to have_content(second_u2f_device.name)
end
end
- it 'allows the same device to be registered for multiple users' do
+ it "allows the same device to be registered for multiple users" do
# First user
visit profile_account_path
manage_two_factor_authentication
u2f_device = register_u2f_device
- expect(page).to have_content('Your U2F device was registered')
+ expect(page).to have_content("Your U2F device was registered")
gitlab_sign_out
# Second user
@@ -96,8 +96,8 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
user.update_attribute(:otp_required_for_login, true)
visit profile_account_path
manage_two_factor_authentication
- register_u2f_device(u2f_device, name: 'My other device')
- expect(page).to have_content('Your U2F device was registered')
+ register_u2f_device(u2f_device, name: "My other device")
+ expect(page).to have_content("Your U2F device was registered")
expect(U2fRegistration.count).to eq(2)
end
@@ -109,9 +109,9 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
# Have the "u2f device" respond with bad data
page.execute_script("u2f.register = function(_,_,_,callback) { callback('bad response'); };")
- click_on 'Set up new U2F device'
- expect(page).to have_content('Your device was successfully set up')
- click_on 'Register U2F device'
+ click_on "Set up new U2F device"
+ expect(page).to have_content("Your device was successfully set up")
+ click_on "Register U2F device"
expect(U2fRegistration.count).to eq(0)
expect(page).to have_content("The form contains the following error")
@@ -124,15 +124,15 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
# Failed registration
page.execute_script("u2f.register = function(_,_,_,callback) { callback('bad response'); };")
- click_on 'Set up new U2F device'
- expect(page).to have_content('Your device was successfully set up')
- click_on 'Register U2F device'
+ click_on "Set up new U2F device"
+ expect(page).to have_content("Your device was successfully set up")
+ click_on "Register U2F device"
expect(page).to have_content("The form contains the following error")
# Successful registration
register_u2f_device
- expect(page).to have_content('Your U2F device was registered')
+ expect(page).to have_content("Your U2F device was registered")
expect(U2fRegistration.count).to eq(1)
end
end
@@ -158,7 +158,7 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
@u2f_device.respond_to_u2f_authentication
- expect(page).to have_css('.sign-out-link', visible: false)
+ expect(page).to have_css(".sign-out-link", visible: false)
end
end
@@ -169,7 +169,7 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
@u2f_device.respond_to_u2f_authentication
- expect(page).to have_css('.sign-out-link', visible: false)
+ expect(page).to have_css(".sign-out-link", visible: false)
end
end
@@ -181,13 +181,13 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
current_user.update_attribute(:otp_required_for_login, true)
visit profile_account_path
manage_two_factor_authentication
- register_u2f_device(name: 'My other device')
+ register_u2f_device(name: "My other device")
gitlab_sign_out
# Try authenticating user with the old U2F device
gitlab_sign_in(current_user)
@u2f_device.respond_to_u2f_authentication
- expect(page).to have_content('Authentication via U2F device failed')
+ expect(page).to have_content("Authentication via U2F device failed")
end
end
@@ -205,18 +205,18 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
gitlab_sign_in(current_user)
@u2f_device.respond_to_u2f_authentication
- expect(page).to have_css('.sign-out-link', visible: false)
+ expect(page).to have_css(".sign-out-link", visible: false)
end
end
end
describe "when a given U2F device has not been registered" do
it "does not allow logging in with that particular device" do
- unregistered_device = FakeU2fDevice.new(page, 'My device')
+ unregistered_device = FakeU2fDevice.new(page, "My device")
gitlab_sign_in(user)
unregistered_device.respond_to_u2f_authentication
- expect(page).to have_content('Authentication via U2F device failed')
+ expect(page).to have_content("Authentication via U2F device failed")
end
end
@@ -232,7 +232,7 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
# Register second device
visit profile_two_factor_auth_path
expect(page).to have_content("Your U2F device needs to be set up.")
- second_device = register_u2f_device(name: 'My other device')
+ second_device = register_u2f_device(name: "My other device")
gitlab_sign_out
# Authenticate as both devices
@@ -240,7 +240,7 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
gitlab_sign_in(user)
device.respond_to_u2f_authentication
- expect(page).to have_css('.sign-out-link', visible: false)
+ expect(page).to have_css(".sign-out-link", visible: false)
gitlab_sign_out
end
@@ -261,21 +261,21 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
it "deletes u2f registrations" do
visit profile_two_factor_auth_path
- expect do
+ expect {
accept_confirm { click_on "Disable" }
- end.to change { U2fRegistration.count }.by(-1)
+ }.to change { U2fRegistration.count }.by(-1)
end
end
end
- describe 'fallback code authentication' do
+ describe "fallback code authentication" do
let(:user) { create(:user) }
def assert_fallback_ui(page)
- expect(page).to have_button('Verify code')
- expect(page).to have_css('#user_otp_attempt')
- expect(page).not_to have_link('Sign in via 2FA code')
- expect(page).not_to have_css('#js-authenticate-u2f')
+ expect(page).to have_button("Verify code")
+ expect(page).to have_css("#user_otp_attempt")
+ expect(page).not_to have_link("Sign in via 2FA code")
+ expect(page).not_to have_css("#js-authenticate-u2f")
end
before do
@@ -285,18 +285,18 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
visit profile_account_path
end
- describe 'when no u2f device is registered' do
+ describe "when no u2f device is registered" do
before do
gitlab_sign_out
gitlab_sign_in(user)
end
- it 'shows the fallback otp code UI' do
+ it "shows the fallback otp code UI" do
assert_fallback_ui(page)
end
end
- describe 'when a u2f device is registered' do
+ describe "when a u2f device is registered" do
before do
manage_two_factor_authentication
@u2f_device = register_u2f_device
@@ -304,10 +304,10 @@ describe 'Using U2F (Universal 2nd Factor) Devices for Authentication', :js do
gitlab_sign_in(user)
end
- it 'provides a button that shows the fallback otp code UI' do
- expect(page).to have_link('Sign in via 2FA code')
+ it "provides a button that shows the fallback otp code UI" do
+ expect(page).to have_link("Sign in via 2FA code")
- click_link('Sign in via 2FA code')
+ click_link("Sign in via 2FA code")
assert_fallback_ui(page)
end
diff --git a/spec/features/unsubscribe_links_spec.rb b/spec/features/unsubscribe_links_spec.rb
index 392d8e3e1c1..e3d21654e40 100644
--- a/spec/features/unsubscribe_links_spec.rb
+++ b/spec/features/unsubscribe_links_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Unsubscribe links' do
+describe "Unsubscribe links" do
include Warden::Test::Helpers
let(:recipient) { create(:user) }
let(:author) { create(:user) }
let(:project) { create(:project, :public) }
- let(:params) { { title: 'A bug!', description: 'Fix it!', assignees: [recipient] } }
+ let(:params) { {title: "A bug!", description: "Fix it!", assignees: [recipient]} }
let(:issue) { Issues::CreateService.new(project, author, params).execute }
let(:mail) { ActionMailer::Base.deliveries.last }
let(:body) { Capybara::Node::Simple.new(mail.default_part_body.to_s) }
- let(:header_link) { mail.header['List-Unsubscribe'].to_s[1..-2] } # Strip angle brackets
- let(:body_link) { body.find_link('unsubscribe')['href'] }
+ let(:header_link) { mail.header["List-Unsubscribe"].to_s[1..-2] } # Strip angle brackets
+ let(:body_link) { body.find_link("unsubscribe")["href"] }
before do
perform_enqueued_jobs { issue }
end
- context 'when logged out' do
- context 'when visiting the link from the body' do
- it 'shows the unsubscribe confirmation page and redirects to root path when confirming' do
+ context "when logged out" do
+ context "when visiting the link from the body" do
+ it "shows the unsubscribe confirmation page and redirects to root path when confirming" do
visit body_link
expect(current_path).to eq unsubscribe_sent_notification_path(SentNotification.last)
@@ -28,49 +28,49 @@ describe 'Unsubscribe links' do
expect(page).to have_text(%(Are you sure you want to unsubscribe from the issue: #{issue.title} (#{issue.to_reference})?))
expect(issue.subscribed?(recipient, project)).to be_truthy
- click_link 'Unsubscribe'
+ click_link "Unsubscribe"
expect(issue.subscribed?(recipient, project)).to be_falsey
expect(current_path).to eq new_user_session_path
end
- it 'shows the unsubscribe confirmation page and redirects to root path when canceling' do
+ it "shows the unsubscribe confirmation page and redirects to root path when canceling" do
visit body_link
expect(current_path).to eq unsubscribe_sent_notification_path(SentNotification.last)
expect(issue.subscribed?(recipient, project)).to be_truthy
- click_link 'Cancel'
+ click_link "Cancel"
expect(issue.subscribed?(recipient, project)).to be_truthy
expect(current_path).to eq new_user_session_path
end
end
- it 'unsubscribes from the issue when visiting the link from the header' do
+ it "unsubscribes from the issue when visiting the link from the header" do
visit header_link
- expect(page).to have_text('unsubscribed')
+ expect(page).to have_text("unsubscribed")
expect(issue.subscribed?(recipient, project)).to be_falsey
end
end
- context 'when logged in' do
+ context "when logged in" do
before do
sign_in(recipient)
end
- it 'unsubscribes from the issue when visiting the link from the email body' do
+ it "unsubscribes from the issue when visiting the link from the email body" do
visit body_link
- expect(page).to have_text('unsubscribed')
+ expect(page).to have_text("unsubscribed")
expect(issue.subscribed?(recipient, project)).to be_falsey
end
- it 'unsubscribes from the issue when visiting the link from the header' do
+ it "unsubscribes from the issue when visiting the link from the header" do
visit header_link
- expect(page).to have_text('unsubscribed')
+ expect(page).to have_text("unsubscribed")
expect(issue.subscribed?(recipient, project)).to be_falsey
end
end
diff --git a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb
index 72b53bae46a..9f5d46193cf 100644
--- a/spec/features/uploads/user_uploads_avatar_to_group_spec.rb
+++ b/spec/features/uploads/user_uploads_avatar_to_group_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User uploads avatar to group' do
- it 'they see the new avatar' do
+describe "User uploads avatar to group" do
+ it "they see the new avatar" do
user = create(:user)
group = create(:group)
group.add_owner(user)
@@ -9,18 +9,18 @@ describe 'User uploads avatar to group' do
visit edit_group_path(group)
attach_file(
- 'group_avatar',
- Rails.root.join('spec', 'fixtures', 'dk.png'),
+ "group_avatar",
+ Rails.root.join("spec", "fixtures", "dk.png"),
visible: false
)
- page.within('.gs-general') do
- click_button 'Save changes'
+ page.within(".gs-general") do
+ click_button "Save changes"
end
visit group_path(group)
- expect(page).to have_selector(%Q(img[data-src$="/uploads/-/system/group/avatar/#{group.id}/dk.png"]))
+ expect(page).to have_selector(%(img[data-src$="/uploads/-/system/group/avatar/#{group.id}/dk.png"]))
# Cheating here to verify something that isn't user-facing, but is important
expect(group.reload.avatar.file).to exist
diff --git a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
index 48f8b8bf77e..ed9dff3e846 100644
--- a/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
+++ b/spec/features/uploads/user_uploads_avatar_to_profile_spec.rb
@@ -1,35 +1,35 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User uploads avatar to profile' do
+describe "User uploads avatar to profile" do
let!(:user) { create(:user) }
- let(:avatar_file_path) { Rails.root.join('spec', 'fixtures', 'dk.png') }
+ let(:avatar_file_path) { Rails.root.join("spec", "fixtures", "dk.png") }
before do
sign_in user
visit profile_path
end
- it 'they see their new avatar on their profile' do
- attach_file('user_avatar', avatar_file_path, visible: false)
- click_button 'Update profile settings'
+ it "they see their new avatar on their profile" do
+ attach_file("user_avatar", avatar_file_path, visible: false)
+ click_button "Update profile settings"
visit user_path(user)
- expect(page).to have_selector(%Q(img[data-src$="/uploads/-/system/user/avatar/#{user.id}/dk.png?width=90"]))
+ expect(page).to have_selector(%(img[data-src$="/uploads/-/system/user/avatar/#{user.id}/dk.png?width=90"]))
# Cheating here to verify something that isn't user-facing, but is important
expect(user.reload.avatar.file).to exist
end
- it 'their new avatar is immediately visible in the header', :js do
- find('.js-user-avatar-input', visible: false).set(avatar_file_path)
+ it "their new avatar is immediately visible in the header", :js do
+ find(".js-user-avatar-input", visible: false).set(avatar_file_path)
- click_button 'Set new profile picture'
- click_button 'Update profile settings'
+ click_button "Set new profile picture"
+ click_button "Update profile settings"
wait_for_all_requests
- data_uri = find('.avatar-image .avatar')['src']
- expect(page.find('.header-user-avatar')['src']).to eq data_uri
+ data_uri = find(".avatar-image .avatar")["src"]
+ expect(page.find(".header-user-avatar")["src"]).to eq data_uri
end
end
diff --git a/spec/features/uploads/user_uploads_file_to_note_spec.rb b/spec/features/uploads/user_uploads_file_to_note_spec.rb
index 24a00c86b0a..c2945c03e32 100644
--- a/spec/features/uploads/user_uploads_file_to_note_spec.rb
+++ b/spec/features/uploads/user_uploads_file_to_note_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User uploads file to note' do
+describe "User uploads file to note" do
include DropzoneHelper
let(:user) { create(:user) }
@@ -13,70 +13,70 @@ describe 'User uploads file to note' do
wait_for_requests
end
- context 'before uploading' do
+ context "before uploading" do
it 'shows "Attach a file" button', :js do
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
end
- context 'uploading is in progress' do
+ context "uploading is in progress" do
it 'cancels uploading on clicking to "Cancel" button', :js do
slow_requests do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")], 0, false)
- click_button 'Cancel'
+ click_button "Cancel"
end
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_button('Cancel')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_button("Cancel")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
it 'shows "Attaching a file" message on uploading 1 file', :js do
slow_requests do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")], 0, false)
- expect(page).to have_selector('.attaching-file-message', visible: true, text: 'Attaching a file -')
+ expect(page).to have_selector(".attaching-file-message", visible: true, text: "Attaching a file -")
end
end
it 'shows "Attaching 2 files" message on uploading 2 file', :js do
slow_requests do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'video_sample.mp4'),
- Rails.root.join('spec', 'fixtures', 'dk.png')], 0, false)
+ dropzone_file([Rails.root.join("spec", "fixtures", "video_sample.mp4"),
+ Rails.root.join("spec", "fixtures", "dk.png"),], 0, false)
- expect(page).to have_selector('.attaching-file-message', visible: true, text: 'Attaching 2 files -')
+ expect(page).to have_selector(".attaching-file-message", visible: true, text: "Attaching 2 files -")
end
end
it 'shows error message, "retry" and "attach a new file" link a if file is too big', :js do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'video_sample.mp4')], 0.01)
+ dropzone_file([Rails.root.join("spec", "fixtures", "video_sample.mp4")], 0.01)
- error_text = 'File is too big (0.06MiB). Max filesize: 0.01MiB.'
+ error_text = "File is too big (0.06MiB). Max filesize: 0.01MiB."
- expect(page).to have_selector('.uploading-error-message', visible: true, text: error_text)
- expect(page).to have_selector('.retry-uploading-link', visible: true, text: 'Try again')
- expect(page).to have_selector('.attach-new-file', visible: true, text: 'attach a new file')
- expect(page).not_to have_button('Attach a file')
+ expect(page).to have_selector(".uploading-error-message", visible: true, text: error_text)
+ expect(page).to have_selector(".retry-uploading-link", visible: true, text: "Try again")
+ expect(page).to have_selector(".attach-new-file", visible: true, text: "attach a new file")
+ expect(page).not_to have_button("Attach a file")
end
end
- context 'uploading is complete' do
+ context "uploading is complete" do
it 'shows "Attach a file" button on uploading complete', :js do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')])
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")])
wait_for_requests
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
- it 'they see the attached file', :js do
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')])
- click_button 'Comment'
+ it "they see the attached file", :js do
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")])
+ click_button "Comment"
wait_for_requests
- expect(find('a.no-attachment-icon img[alt="dk"]')['src'])
+ expect(find('a.no-attachment-icon img[alt="dk"]')["src"])
.to match(%r{/#{project.full_path}/uploads/\h{32}/dk\.png$})
end
end
diff --git a/spec/features/usage_stats_consent_spec.rb b/spec/features/usage_stats_consent_spec.rb
index dd8f3179895..21d753ac4eb 100644
--- a/spec/features/usage_stats_consent_spec.rb
+++ b/spec/features/usage_stats_consent_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Usage stats consent' do
- context 'when signed in' do
+describe "Usage stats consent" do
+ context "when signed in" do
let(:user) { create(:admin, created_at: 8.days.ago) }
- let(:message) { 'To help improve GitLab, we would like to periodically collect usage information.' }
+ let(:message) { "To help improve GitLab, we would like to periodically collect usage information." }
before do
allow(user).to receive(:has_current_license?).and_return false
@@ -13,15 +13,15 @@ describe 'Usage stats consent' do
gitlab_sign_in(user)
end
- it 'hides the banner permanently when sets usage stats' do
+ it "hides the banner permanently when sets usage stats" do
visit root_dashboard_path
expect(page).to have_content(message)
- click_link 'Send usage data'
+ click_link "Send usage data"
expect(page).not_to have_content(message)
- expect(page).to have_content('Application settings saved successfully')
+ expect(page).to have_content("Application settings saved successfully")
gitlab_sign_out
gitlab_sign_in(user)
@@ -30,7 +30,7 @@ describe 'Usage stats consent' do
expect(page).not_to have_content(message)
end
- it 'shows banner on next session if user did not set usage stats' do
+ it "shows banner on next session if user did not set usage stats" do
visit root_dashboard_path
expect(page).to have_content(message)
diff --git a/spec/features/user_can_display_performance_bar_spec.rb b/spec/features/user_can_display_performance_bar_spec.rb
index e069c2fddd1..f61f36f871e 100644
--- a/spec/features/user_can_display_performance_bar_spec.rb
+++ b/spec/features/user_can_display_performance_bar_spec.rb
@@ -1,75 +1,75 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'User can display performance bar', :js do
- shared_examples 'performance bar cannot be displayed' do
- it 'does not show the performance bar by default' do
- expect(page).not_to have_css('#js-peek')
+describe "User can display performance bar", :js do
+ shared_examples "performance bar cannot be displayed" do
+ it "does not show the performance bar by default" do
+ expect(page).not_to have_css("#js-peek")
end
- context 'when user press `pb`' do
+ context "when user press `pb`" do
before do
- find('body').native.send_keys('pb')
+ find("body").native.send_keys("pb")
end
- it 'does not show the performance bar by default' do
- expect(page).not_to have_css('#js-peek')
+ it "does not show the performance bar by default" do
+ expect(page).not_to have_css("#js-peek")
end
end
end
- shared_examples 'performance bar can be displayed' do
- it 'does not show the performance bar by default' do
- expect(page).not_to have_css('#js-peek')
+ shared_examples "performance bar can be displayed" do
+ it "does not show the performance bar by default" do
+ expect(page).not_to have_css("#js-peek")
end
- context 'when user press `pb`' do
+ context "when user press `pb`" do
before do
- find('body').native.send_keys('pb')
+ find("body").native.send_keys("pb")
end
- it 'shows the performance bar' do
- expect(page).to have_css('#js-peek')
+ it "shows the performance bar" do
+ expect(page).to have_css("#js-peek")
end
end
end
- shared_examples 'performance bar is enabled by default in development' do
+ shared_examples "performance bar is enabled by default in development" do
before do
allow(Rails.env).to receive(:development?).and_return(true)
end
- it 'shows the performance bar by default' do
+ it "shows the performance bar by default" do
refresh # Because we're stubbing Rails.env after the 1st visit to root_path
- expect(page).to have_css('#js-peek')
+ expect(page).to have_css("#js-peek")
end
end
let(:group) { create(:group) }
- context 'when user is logged-out' do
+ context "when user is logged-out" do
before do
visit root_path
end
- context 'when the performance_bar feature is disabled' do
+ context "when the performance_bar feature is disabled" do
before do
stub_application_setting(performance_bar_allowed_group_id: nil)
end
- it_behaves_like 'performance bar cannot be displayed'
+ it_behaves_like "performance bar cannot be displayed"
end
- context 'when the performance_bar feature is enabled' do
+ context "when the performance_bar feature is enabled" do
before do
stub_application_setting(performance_bar_allowed_group_id: group.id)
end
- it_behaves_like 'performance bar cannot be displayed'
+ it_behaves_like "performance bar cannot be displayed"
end
end
- context 'when user is logged-in' do
+ context "when user is logged-in" do
before do
user = create(:user)
@@ -79,22 +79,22 @@ describe 'User can display performance bar', :js do
visit root_path
end
- context 'when the performance_bar feature is disabled' do
+ context "when the performance_bar feature is disabled" do
before do
stub_application_setting(performance_bar_allowed_group_id: nil)
end
- it_behaves_like 'performance bar cannot be displayed'
- it_behaves_like 'performance bar is enabled by default in development'
+ it_behaves_like "performance bar cannot be displayed"
+ it_behaves_like "performance bar is enabled by default in development"
end
- context 'when the performance_bar feature is enabled' do
+ context "when the performance_bar feature is enabled" do
before do
stub_application_setting(performance_bar_allowed_group_id: group.id)
end
- it_behaves_like 'performance bar is enabled by default in development'
- it_behaves_like 'performance bar can be displayed'
+ it_behaves_like "performance bar is enabled by default in development"
+ it_behaves_like "performance bar can be displayed"
end
end
end
diff --git a/spec/features/user_sees_revert_modal_spec.rb b/spec/features/user_sees_revert_modal_spec.rb
index 3b48ea4786d..5c3e54e7f23 100644
--- a/spec/features/user_sees_revert_modal_spec.rb
+++ b/spec/features/user_sees_revert_modal_spec.rb
@@ -1,6 +1,6 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'Merge request > User sees revert modal', :js do
+describe "Merge request > User sees revert modal", :js do
let(:project) { create(:project, :public, :repository) }
let(:user) { project.creator }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -8,21 +8,21 @@ describe 'Merge request > User sees revert modal', :js do
before do
sign_in(user)
visit(project_merge_request_path(project, merge_request))
- click_button('Merge')
+ click_button("Merge")
wait_for_requests
visit(merge_request_path(merge_request))
- click_link('Revert')
+ click_link("Revert")
end
- it 'shows the revert modal' do
- expect(page).to have_content('Revert this merge request')
+ it "shows the revert modal" do
+ expect(page).to have_content("Revert this merge request")
end
- it 'closes the revert modal with escape keypress' do
- find('#modal-revert-commit').send_keys(:escape)
+ it "closes the revert modal with escape keypress" do
+ find("#modal-revert-commit").send_keys(:escape)
- expect(page).not_to have_content('Revert this merge request')
+ expect(page).not_to have_content("Revert this merge request")
end
end
diff --git a/spec/features/users/active_sessions_spec.rb b/spec/features/users/active_sessions_spec.rb
index 25349b5d036..46020760c9c 100644
--- a/spec/features/users/active_sessions_spec.rb
+++ b/spec/features/users/active_sessions_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Active user sessions', :clean_gitlab_redis_shared_state do
- it 'Successful login adds a new active user login' do
- now = Time.zone.parse('2018-03-12 09:06')
+describe "Active user sessions", :clean_gitlab_redis_shared_state do
+ it "Successful login adds a new active user login" do
+ now = Time.zone.parse("2018-03-12 09:06")
Timecop.freeze(now) do
user = create(:user)
gitlab_sign_in(user)
@@ -17,44 +17,44 @@ describe 'Active user sessions', :clean_gitlab_redis_shared_state do
sessions = ActiveSession.list(user)
expect(sessions.first).to have_attributes(
- created_at: Time.zone.parse('2018-03-12 09:06'),
- updated_at: Time.zone.parse('2018-03-12 09:07')
+ created_at: Time.zone.parse("2018-03-12 09:06"),
+ updated_at: Time.zone.parse("2018-03-12 09:07")
)
end
end
end
- it 'Successful login cleans up obsolete entries' do
+ it "Successful login cleans up obsolete entries" do
user = create(:user)
Gitlab::Redis::SharedState.with do |redis|
- redis.sadd("session:lookup:user:gitlab:#{user.id}", '59822c7d9fcdfa03725eff41782ad97d')
+ redis.sadd("session:lookup:user:gitlab:#{user.id}", "59822c7d9fcdfa03725eff41782ad97d")
end
gitlab_sign_in(user)
Gitlab::Redis::SharedState.with do |redis|
- expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).not_to include '59822c7d9fcdfa03725eff41782ad97d'
+ expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).not_to include "59822c7d9fcdfa03725eff41782ad97d"
end
end
- it 'Sessionless login does not clean up obsolete entries' do
+ it "Sessionless login does not clean up obsolete entries" do
user = create(:user)
personal_access_token = create(:personal_access_token, user: user)
Gitlab::Redis::SharedState.with do |redis|
- redis.sadd("session:lookup:user:gitlab:#{user.id}", '59822c7d9fcdfa03725eff41782ad97d')
+ redis.sadd("session:lookup:user:gitlab:#{user.id}", "59822c7d9fcdfa03725eff41782ad97d")
end
visit user_path(user, :atom, private_token: personal_access_token.token)
expect(page.status_code).to eq 200
Gitlab::Redis::SharedState.with do |redis|
- expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).to include '59822c7d9fcdfa03725eff41782ad97d'
+ expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).to include "59822c7d9fcdfa03725eff41782ad97d"
end
end
- it 'Logout deletes the active user login' do
+ it "Logout deletes the active user login" do
user = create(:user)
gitlab_sign_in(user)
expect(current_path).to eq root_path
diff --git a/spec/features/users/add_email_to_existing_account.rb b/spec/features/users/add_email_to_existing_account.rb
index 4355f769429..0aaf7189ade 100644
--- a/spec/features/users/add_email_to_existing_account.rb
+++ b/spec/features/users/add_email_to_existing_account.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'AdditionalEmailToExistingAccount' do
- describe 'add secondary email associated with account' do
+describe "AdditionalEmailToExistingAccount" do
+ describe "add secondary email associated with account" do
let(:user) { create(:user) }
- it 'verifies confirmation of additional email' do
+ it "verifies confirmation of additional email" do
sign_in(user)
email = create(:email, user: user)
visit email_confirmation_path(confirmation_token: email.confirmation_token)
- expect(page).to have_content 'Your email address has been successfully confirmed.'
+ expect(page).to have_content "Your email address has been successfully confirmed."
end
end
end
diff --git a/spec/features/users/login_spec.rb b/spec/features/users/login_spec.rb
index ad856bd062e..238337b1a56 100644
--- a/spec/features/users/login_spec.rb
+++ b/spec/features/users/login_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Login' do
+describe "Login" do
include TermsHelper
include UserLoginHelper
@@ -8,8 +8,8 @@ describe 'Login' do
stub_authentication_activity_metrics(debug: true)
end
- describe 'password reset token after successful sign in' do
- it 'invalidates password reset token' do
+ describe "password reset token after successful sign in" do
+ it "invalidates password reset token" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -18,8 +18,8 @@ describe 'Login' do
expect(user.reset_password_token).to be_nil
visit new_user_password_path
- fill_in 'user_email', with: user.email
- click_button 'Reset password'
+ fill_in "user_email", with: user.email
+ click_button "Reset password"
user.reload
expect(user.reset_password_token).not_to be_nil
@@ -33,8 +33,8 @@ describe 'Login' do
end
end
- describe 'initial login after setup' do
- it 'allows the initial admin to create a password' do
+ describe "initial login after setup" do
+ it "allows the initial admin to create a password" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -45,30 +45,30 @@ describe 'Login' do
visit root_path
expect(current_path).to eq edit_user_password_path
- expect(page).to have_content('Please create a password for your new account.')
+ expect(page).to have_content("Please create a password for your new account.")
- fill_in 'user_password', with: 'password'
- fill_in 'user_password_confirmation', with: 'password'
- click_button 'Change your password'
+ fill_in "user_password", with: "password"
+ fill_in "user_password_confirmation", with: "password"
+ click_button "Change your password"
expect(current_path).to eq new_user_session_path
- expect(page).to have_content(I18n.t('devise.passwords.updated_not_active'))
+ expect(page).to have_content(I18n.t("devise.passwords.updated_not_active"))
- fill_in 'user_login', with: user.username
- fill_in 'user_password', with: 'password'
- click_button 'Sign in'
+ fill_in "user_login", with: user.username
+ fill_in "user_password", with: "password"
+ click_button "Sign in"
expect(current_path).to eq root_path
end
- it 'does not show flash messages when login page' do
+ it "does not show flash messages when login page" do
visit root_path
- expect(page).not_to have_content('You need to sign in or sign up before continuing.')
+ expect(page).not_to have_content("You need to sign in or sign up before continuing.")
end
end
- describe 'with a blocked account' do
- it 'prevents the user from logging in' do
+ describe "with a blocked account" do
+ it "prevents the user from logging in" do
expect(authentication_metrics)
.to increment(:user_blocked_counter)
.and increment(:user_unauthenticated_counter)
@@ -78,10 +78,10 @@ describe 'Login' do
gitlab_sign_in(user)
- expect(page).to have_content('Your account has been blocked.')
+ expect(page).to have_content("Your account has been blocked.")
end
- it 'does not update Devise trackable attributes', :clean_gitlab_redis_shared_state do
+ it "does not update Devise trackable attributes", :clean_gitlab_redis_shared_state do
expect(authentication_metrics)
.to increment(:user_blocked_counter)
.and increment(:user_unauthenticated_counter)
@@ -93,18 +93,18 @@ describe 'Login' do
end
end
- describe 'with the ghost user' do
- it 'disallows login' do
+ describe "with the ghost user" do
+ it "disallows login" do
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
.and increment(:user_password_invalid_counter)
gitlab_sign_in(User.ghost)
- expect(page).to have_content('Invalid Login or password.')
+ expect(page).to have_content("Invalid Login or password.")
end
- it 'does not update Devise trackable attributes', :clean_gitlab_redis_shared_state do
+ it "does not update Devise trackable attributes", :clean_gitlab_redis_shared_state do
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
.and increment(:user_password_invalid_counter)
@@ -114,19 +114,19 @@ describe 'Login' do
end
end
- describe 'with two-factor authentication' do
+ describe "with two-factor authentication" do
def enter_code(code)
- fill_in 'user_otp_attempt', with: code
- click_button 'Verify code'
+ fill_in "user_otp_attempt", with: code
+ click_button "Verify code"
end
- context 'with valid username/password' do
+ context "with valid username/password" do
let(:user) { create(:user, :two_factor) }
before do
gitlab_sign_in(user, remember: true)
- expect(page).to have_content('Two-Factor Authentication')
+ expect(page).to have_content("Two-Factor Authentication")
end
it 'does not show a "You are already signed in." error message' do
@@ -137,11 +137,11 @@ describe 'Login' do
enter_code(user.current_otp)
- expect(page).not_to have_content('You are already signed in.')
+ expect(page).not_to have_content("You are already signed in.")
end
- context 'using one-time code' do
- it 'allows login with valid code' do
+ context "using one-time code" do
+ it "allows login with valid code" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
@@ -152,36 +152,36 @@ describe 'Login' do
expect(current_path).to eq root_path
end
- it 'persists remember_me value via hidden field' do
- field = first('input#user_remember_me', visible: false)
+ it "persists remember_me value via hidden field" do
+ field = first("input#user_remember_me", visible: false)
- expect(field.value).to eq '1'
+ expect(field.value).to eq "1"
end
- it 'blocks login with invalid code' do
+ it "blocks login with invalid code" do
# TODO invalid 2FA code does not generate any events
# See gitlab-org/gitlab-ce#49785
- enter_code('foo')
+ enter_code("foo")
- expect(page).to have_content('Invalid two-factor code')
+ expect(page).to have_content("Invalid two-factor code")
end
- it 'allows login with invalid code, then valid code' do
+ it "allows login with invalid code, then valid code" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
.and increment(:user_two_factor_authenticated_counter)
- enter_code('foo')
- expect(page).to have_content('Invalid two-factor code')
+ enter_code("foo")
+ expect(page).to have_content("Invalid two-factor code")
enter_code(user.current_otp)
expect(current_path).to eq root_path
end
end
- context 'using backup code' do
+ context "using backup code" do
let(:codes) { user.generate_otp_backup_codes! }
before do
@@ -191,8 +191,8 @@ describe 'Login' do
user.save
end
- context 'with valid code' do
- it 'allows login' do
+ context "with valid code" do
+ it "allows login" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
@@ -203,7 +203,7 @@ describe 'Login' do
expect(current_path).to eq root_path
end
- it 'invalidates the used code' do
+ it "invalidates the used code" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
@@ -213,7 +213,7 @@ describe 'Login' do
.to change { user.reload.otp_backup_codes.size }.by(-1)
end
- it 'invalidates backup codes twice in a row' do
+ it "invalidates backup codes twice in a row" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter).twice
.and increment(:user_session_override_counter).twice
@@ -232,8 +232,8 @@ describe 'Login' do
end
end
- context 'with invalid code' do
- it 'blocks login' do
+ context "with invalid code" do
+ it "blocks login" do
# TODO, invalid two factor authentication does not increment
# metrics / counters, see gitlab-org/gitlab-ce#49785
@@ -244,31 +244,31 @@ describe 'Login' do
expect(user.reload.otp_backup_codes.size).to eq 9
enter_code(code)
- expect(page).to have_content('Invalid two-factor code.')
+ expect(page).to have_content("Invalid two-factor code.")
end
end
end
end
- context 'when logging in via OAuth' do
- let(:user) { create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml')}
+ context "when logging in via OAuth" do
+ let(:user) { create(:omniauth_user, :two_factor, extern_uid: "my-uid", provider: "saml")}
let(:mock_saml_response) do
- File.read('spec/fixtures/authentication/saml_response.xml')
+ File.read("spec/fixtures/authentication/saml_response.xml")
end
before do
- stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'],
+ stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"],
providers: [mock_saml_config_with_upstream_two_factor_authn_contexts])
end
- context 'when authn_context is worth two factors' do
+ context "when authn_context is worth two factors" do
let(:mock_saml_response) do
- File.read('spec/fixtures/authentication/saml_response.xml')
- .gsub('urn:oasis:names:tc:SAML:2.0:ac:classes:Password',
- 'urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS')
+ File.read("spec/fixtures/authentication/saml_response.xml")
+ .gsub("urn:oasis:names:tc:SAML:2.0:ac:classes:Password",
+ "urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS")
end
- it 'signs user in without prompting for second factor' do
+ it "signs user in without prompting for second factor" do
# TODO, OAuth authentication does not fire events,
# see gitlab-org/gitlab-ce#49786
@@ -278,13 +278,13 @@ describe 'Login' do
sign_in_using_saml!
- expect(page).not_to have_content('Two-Factor Authentication')
+ expect(page).not_to have_content("Two-Factor Authentication")
expect(current_path).to eq root_path
end
end
- context 'when two factor authentication is required' do
- it 'shows 2FA prompt after OAuth login' do
+ context "when two factor authentication is required" do
+ it "shows 2FA prompt after OAuth login" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
@@ -292,7 +292,7 @@ describe 'Login' do
sign_in_using_saml!
- expect(page).to have_content('Two-Factor Authentication')
+ expect(page).to have_content("Two-Factor Authentication")
enter_code(user.current_otp)
@@ -301,82 +301,82 @@ describe 'Login' do
end
def sign_in_using_saml!
- gitlab_sign_in_via('saml', user, 'my-uid', mock_saml_response)
+ gitlab_sign_in_via("saml", user, "my-uid", mock_saml_response)
end
end
end
- describe 'without two-factor authentication' do
- context 'with correct username and password' do
+ describe "without two-factor authentication" do
+ context "with correct username and password" do
let(:user) { create(:user) }
- it 'allows basic login' do
+ it "allows basic login" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq root_path
- expect(page).not_to have_content('You are already signed in.')
+ expect(page).not_to have_content("You are already signed in.")
end
end
- context 'with invalid username and password' do
- let(:user) { create(:user, password: 'not-the-default') }
+ context "with invalid username and password" do
+ let(:user) { create(:user, password: "not-the-default") }
- it 'blocks invalid login' do
+ it "blocks invalid login" do
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
.and increment(:user_password_invalid_counter)
gitlab_sign_in(user)
- expect(page).to have_content('Invalid Login or password.')
+ expect(page).to have_content("Invalid Login or password.")
end
end
end
- describe 'with required two-factor authentication enabled' do
+ describe "with required two-factor authentication enabled" do
let(:user) { create(:user) }
# TODO: otp_grace_period_started_at
- context 'global setting' do
+ context "global setting" do
before do
stub_application_setting(require_two_factor_authentication: true)
end
- context 'with grace period defined' do
+ context "with grace period defined" do
before do
stub_application_setting(two_factor_grace_period: 48)
end
- context 'within the grace period' do
- it 'redirects to two-factor configuration page' do
+ context "within the grace period" do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq profile_two_factor_auth_path
- expect(page).to have_content('The global settings require you to enable Two-Factor Authentication for your account. You need to do this before ')
+ expect(page).to have_content("The global settings require you to enable Two-Factor Authentication for your account. You need to do this before ")
end
- it 'allows skipping two-factor configuration', :js do
+ it "allows skipping two-factor configuration", :js do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq profile_two_factor_auth_path
- click_link 'Configure it later'
+ click_link "Configure it later"
expect(current_path).to eq root_path
end
end
- context 'after the grace period' do
+ context "after the grace period" do
let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) }
- it 'redirects to two-factor configuration page' do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -384,28 +384,28 @@ describe 'Login' do
expect(current_path).to eq profile_two_factor_auth_path
expect(page).to have_content(
- 'The global settings require you to enable Two-Factor Authentication for your account.'
+ "The global settings require you to enable Two-Factor Authentication for your account."
)
end
- it 'disallows skipping two-factor configuration', :js do
+ it "disallows skipping two-factor configuration", :js do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq profile_two_factor_auth_path
- expect(page).not_to have_link('Configure it later')
+ expect(page).not_to have_link("Configure it later")
end
end
end
- context 'without grace period defined' do
+ context "without grace period defined" do
before do
stub_application_setting(two_factor_grace_period: 0)
end
- it 'redirects to two-factor configuration page' do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -413,27 +413,27 @@ describe 'Login' do
expect(current_path).to eq profile_two_factor_auth_path
expect(page).to have_content(
- 'The global settings require you to enable Two-Factor Authentication for your account.'
+ "The global settings require you to enable Two-Factor Authentication for your account."
)
end
end
end
- context 'group setting' do
+ context "group setting" do
before do
- group1 = create :group, name: 'Group 1', require_two_factor_authentication: true
+ group1 = create :group, name: "Group 1", require_two_factor_authentication: true
group1.add_user(user, GroupMember::DEVELOPER)
- group2 = create :group, name: 'Group 2', require_two_factor_authentication: true
+ group2 = create :group, name: "Group 2", require_two_factor_authentication: true
group2.add_user(user, GroupMember::DEVELOPER)
end
- context 'with grace period defined' do
+ context "with grace period defined" do
before do
stub_application_setting(two_factor_grace_period: 48)
end
- context 'within the grace period' do
- it 'redirects to two-factor configuration page' do
+ context "within the grace period" do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -441,27 +441,28 @@ describe 'Login' do
expect(current_path).to eq profile_two_factor_auth_path
expect(page).to have_content(
- 'The group settings for Group 1 and Group 2 require you to enable ' \
- 'Two-Factor Authentication for your account. You need to do this ' \
- 'before ')
+ "The group settings for Group 1 and Group 2 require you to enable " \
+ "Two-Factor Authentication for your account. You need to do this " \
+ "before "
+ )
end
- it 'allows skipping two-factor configuration', :js do
+ it "allows skipping two-factor configuration", :js do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq profile_two_factor_auth_path
- click_link 'Configure it later'
+ click_link "Configure it later"
expect(current_path).to eq root_path
end
end
- context 'after the grace period' do
+ context "after the grace period" do
let(:user) { create(:user, otp_grace_period_started_at: 9999.hours.ago) }
- it 'redirects to two-factor configuration page' do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -469,29 +470,29 @@ describe 'Login' do
expect(current_path).to eq profile_two_factor_auth_path
expect(page).to have_content(
- 'The group settings for Group 1 and Group 2 require you to enable ' \
- 'Two-Factor Authentication for your account.'
+ "The group settings for Group 1 and Group 2 require you to enable " \
+ "Two-Factor Authentication for your account."
)
end
- it 'disallows skipping two-factor configuration', :js do
+ it "disallows skipping two-factor configuration", :js do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
gitlab_sign_in(user)
expect(current_path).to eq profile_two_factor_auth_path
- expect(page).not_to have_link('Configure it later')
+ expect(page).not_to have_link("Configure it later")
end
end
end
- context 'without grace period defined' do
+ context "without grace period defined" do
before do
stub_application_setting(two_factor_grace_period: 0)
end
- it 'redirects to two-factor configuration page' do
+ it "redirects to two-factor configuration page" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -499,83 +500,83 @@ describe 'Login' do
expect(current_path).to eq profile_two_factor_auth_path
expect(page).to have_content(
- 'The group settings for Group 1 and Group 2 require you to enable ' \
- 'Two-Factor Authentication for your account.'
+ "The group settings for Group 1 and Group 2 require you to enable " \
+ "Two-Factor Authentication for your account."
)
end
end
end
end
- describe 'UI tabs and panes' do
- context 'when no defaults are changed' do
- it 'correctly renders tabs and panes' do
+ describe "UI tabs and panes" do
+ context "when no defaults are changed" do
+ it "correctly renders tabs and panes" do
ensure_tab_pane_correctness
end
end
- context 'when signup is disabled' do
+ context "when signup is disabled" do
before do
stub_application_setting(signup_enabled: false)
end
- it 'correctly renders tabs and panes' do
+ it "correctly renders tabs and panes" do
ensure_tab_pane_correctness
end
end
- context 'when ldap is enabled' do
+ context "when ldap is enabled" do
before do
visit new_user_session_path
allow(page).to receive(:form_based_providers).and_return([:ldapmain])
allow(page).to receive(:ldap_enabled).and_return(true)
end
- it 'correctly renders tabs and panes' do
+ it "correctly renders tabs and panes" do
ensure_tab_pane_correctness(false)
end
end
- context 'when crowd is enabled' do
+ context "when crowd is enabled" do
before do
visit new_user_session_path
allow(page).to receive(:form_based_providers).and_return([:crowd])
allow(page).to receive(:crowd_enabled?).and_return(true)
end
- it 'correctly renders tabs and panes' do
+ it "correctly renders tabs and panes" do
ensure_tab_pane_correctness(false)
end
end
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
let(:user) { create(:user) }
before do
enforce_terms
end
- it 'asks to accept the terms on first login' do
+ it "asks to accept the terms on first login" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
visit new_user_session_path
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: '12345678'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
- click_button 'Sign in'
+ click_button "Sign in"
expect_to_be_on_terms_page
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(current_path).to eq(root_path)
- expect(page).not_to have_content('You are already signed in.')
+ expect(page).not_to have_content("You are already signed in.")
end
- it 'does not ask for terms when the user already accepted them' do
+ it "does not ask for terms when the user already accepted them" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
@@ -583,53 +584,53 @@ describe 'Login' do
visit new_user_session_path
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: '12345678'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
- click_button 'Sign in'
+ click_button "Sign in"
expect(current_path).to eq(root_path)
end
- context 'when 2FA is required for the user' do
+ context "when 2FA is required for the user" do
before do
group = create(:group, require_two_factor_authentication: true)
group.add_developer(user)
end
- context 'when the user did not enable 2FA' do
- it 'asks to set 2FA before asking to accept the terms' do
+ context "when the user did not enable 2FA" do
+ it "asks to set 2FA before asking to accept the terms" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
visit new_user_session_path
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: '12345678'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
- click_button 'Sign in'
+ click_button "Sign in"
expect_to_be_on_terms_page
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(current_path).to eq(profile_two_factor_auth_path)
- fill_in 'pin_code', with: user.reload.current_otp
+ fill_in "pin_code", with: user.reload.current_otp
- click_button 'Register with two-factor app'
- click_link 'Proceed'
+ click_button "Register with two-factor app"
+ click_link "Proceed"
expect(current_path).to eq(profile_account_path)
end
end
- context 'when the user already enabled 2FA' do
+ context "when the user already enabled 2FA" do
before do
user.update!(otp_required_for_login: true,
- otp_secret: User.generate_otp_secret(32))
+ otp_secret: User.generate_otp_secret(32))
end
- it 'asks the user to accept the terms' do
+ it "asks the user to accept the terms" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
@@ -637,74 +638,74 @@ describe 'Login' do
visit new_user_session_path
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: '12345678'
- click_button 'Sign in'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
+ click_button "Sign in"
- fill_in 'user_otp_attempt', with: user.reload.current_otp
- click_button 'Verify code'
+ fill_in "user_otp_attempt", with: user.reload.current_otp
+ click_button "Verify code"
expect_to_be_on_terms_page
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(current_path).to eq(root_path)
end
end
end
- context 'when the users password is expired' do
+ context "when the users password is expired" do
before do
- user.update!(password_expires_at: Time.parse('2018-05-08 11:29:46 UTC'))
+ user.update!(password_expires_at: Time.parse("2018-05-08 11:29:46 UTC"))
end
- it 'asks the user to accept the terms before setting a new password' do
+ it "asks the user to accept the terms before setting a new password" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
visit new_user_session_path
- fill_in 'user_login', with: user.email
- fill_in 'user_password', with: '12345678'
- click_button 'Sign in'
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
+ click_button "Sign in"
expect_to_be_on_terms_page
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(current_path).to eq(new_profile_password_path)
- fill_in 'user_current_password', with: '12345678'
- fill_in 'user_password', with: 'new password'
- fill_in 'user_password_confirmation', with: 'new password'
- click_button 'Set new password'
+ fill_in "user_current_password", with: "12345678"
+ fill_in "user_password", with: "new password"
+ fill_in "user_password_confirmation", with: "new password"
+ click_button "Set new password"
- expect(page).to have_content('Password successfully changed')
+ expect(page).to have_content("Password successfully changed")
end
end
- context 'when the user does not have an email configured' do
- let(:user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'saml', email: 'temp-email-for-oauth-user@gitlab.localhost') }
+ context "when the user does not have an email configured" do
+ let(:user) { create(:omniauth_user, extern_uid: "my-uid", provider: "saml", email: "temp-email-for-oauth-user@gitlab.localhost") }
before do
- stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config])
+ stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"], providers: [mock_saml_config])
end
- it 'asks the user to accept the terms before setting an email' do
+ it "asks the user to accept the terms before setting an email" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
.and increment(:user_session_override_counter)
- gitlab_sign_in_via('saml', user, 'my-uid')
+ gitlab_sign_in_via("saml", user, "my-uid")
expect_to_be_on_terms_page
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(current_path).to eq(profile_path)
- fill_in 'Email', with: 'hello@world.com'
+ fill_in "Email", with: "hello@world.com"
- click_button 'Update profile settings'
+ click_button "Update profile settings"
- expect(page).to have_content('Profile was successfully updated')
+ expect(page).to have_content("Profile was successfully updated")
end
end
end
diff --git a/spec/features/users/logout_spec.rb b/spec/features/users/logout_spec.rb
index 635729efa53..f68733b852e 100644
--- a/spec/features/users/logout_spec.rb
+++ b/spec/features/users/logout_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Logout/Sign out', :js do
+describe "Logout/Sign out", :js do
let(:user) { create(:user) }
before do
@@ -8,15 +8,15 @@ describe 'Logout/Sign out', :js do
visit root_path
end
- it 'sign out redirects to sign in page' do
+ it "sign out redirects to sign in page" do
gitlab_sign_out
expect(current_path).to eq new_user_session_path
end
- it 'sign out does not show signed out flash notice' do
+ it "sign out does not show signed out flash notice" do
gitlab_sign_out
- expect(page).not_to have_selector('.flash-notice')
+ expect(page).not_to have_selector(".flash-notice")
end
end
diff --git a/spec/features/users/overview_spec.rb b/spec/features/users/overview_spec.rb
index 3db9ae7a951..924186a8238 100644
--- a/spec/features/users/overview_spec.rb
+++ b/spec/features/users/overview_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Overview tab on a user profile', :js do
+describe "Overview tab on a user profile", :js do
let(:user) { create(:user) }
let(:contributed_project) { create(:project, :public, :repository) }
@@ -8,72 +8,72 @@ describe 'Overview tab on a user profile', :js do
event = create(:push_event, project: contributed_project, author: user)
create(:push_event_payload,
- event: event,
- commit_from: '11f9ac0a48b62cef25eedede4c1819964f08d5ce',
- commit_to: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
- commit_count: 3,
- ref: 'master')
+ event: event,
+ commit_from: "11f9ac0a48b62cef25eedede4c1819964f08d5ce",
+ commit_to: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
+ commit_count: 3,
+ ref: "master")
end
before do
sign_in user
end
- describe 'activities section' do
- shared_context 'visit overview tab' do
+ describe "activities section" do
+ shared_context "visit overview tab" do
before do
visit user.username
- page.find('.js-overview-tab a').click
+ page.find(".js-overview-tab a").click
wait_for_requests
end
end
- describe 'user has no activities' do
- include_context 'visit overview tab'
+ describe "user has no activities" do
+ include_context "visit overview tab"
- it 'does not show any entries in the list of activities' do
- page.within('.activities-block') do
- expect(page).to have_selector('.loading', visible: false)
- expect(page).to have_content('Join or create a group to start contributing by commenting on issues or submitting merge requests!')
- expect(page).not_to have_selector('.event-item')
+ it "does not show any entries in the list of activities" do
+ page.within(".activities-block") do
+ expect(page).to have_selector(".loading", visible: false)
+ expect(page).to have_content("Join or create a group to start contributing by commenting on issues or submitting merge requests!")
+ expect(page).not_to have_selector(".event-item")
end
end
- it 'does not show a link to the activity list' do
- expect(find('#js-overview .activities-block')).to have_selector('.js-view-all', visible: false)
+ it "does not show a link to the activity list" do
+ expect(find("#js-overview .activities-block")).to have_selector(".js-view-all", visible: false)
end
end
- describe 'user has 3 activities' do
+ describe "user has 3 activities" do
before do
3.times { push_code_contribution }
end
- include_context 'visit overview tab'
+ include_context "visit overview tab"
- it 'display 3 entries in the list of activities' do
- expect(find('#js-overview')).to have_selector('.event-item', count: 3)
+ it "display 3 entries in the list of activities" do
+ expect(find("#js-overview")).to have_selector(".event-item", count: 3)
end
end
- describe 'user has 11 activities' do
+ describe "user has 11 activities" do
before do
11.times { push_code_contribution }
end
- include_context 'visit overview tab'
+ include_context "visit overview tab"
- it 'displays 10 entries in the list of activities' do
- expect(find('#js-overview')).to have_selector('.event-item', count: 10)
+ it "displays 10 entries in the list of activities" do
+ expect(find("#js-overview")).to have_selector(".event-item", count: 10)
end
- it 'shows a link to the activity list' do
- expect(find('#js-overview .activities-block')).to have_selector('.js-view-all', visible: true)
+ it "shows a link to the activity list" do
+ expect(find("#js-overview .activities-block")).to have_selector(".js-view-all", visible: true)
end
- it 'links to the activity tab' do
- page.within('.activities-block') do
- find('.js-view-all').click
+ it "links to the activity tab" do
+ page.within(".activities-block") do
+ find(".js-view-all").click
wait_for_requests
expect(URI.parse(current_url).path).to eq("/users/#{user.username}/activity")
end
@@ -81,77 +81,77 @@ describe 'Overview tab on a user profile', :js do
end
end
- describe 'projects section' do
- shared_context 'visit overview tab' do
+ describe "projects section" do
+ shared_context "visit overview tab" do
before do
visit user.username
- page.find('.js-overview-tab a').click
+ page.find(".js-overview-tab a").click
wait_for_requests
end
end
- describe 'user has no personal projects' do
- include_context 'visit overview tab'
+ describe "user has no personal projects" do
+ include_context "visit overview tab"
- it 'it shows an empty project list with an info message' do
- page.within('.projects-block') do
- expect(page).to have_selector('.loading', visible: false)
- expect(page).to have_content('You haven\'t created any personal projects.')
- expect(page).not_to have_selector('.project-row')
+ it "it shows an empty project list with an info message" do
+ page.within(".projects-block") do
+ expect(page).to have_selector(".loading", visible: false)
+ expect(page).to have_content("You haven't created any personal projects.")
+ expect(page).not_to have_selector(".project-row")
end
end
- it 'does not show a link to the project list' do
- expect(find('#js-overview .projects-block')).to have_selector('.js-view-all', visible: false)
+ it "does not show a link to the project list" do
+ expect(find("#js-overview .projects-block")).to have_selector(".js-view-all", visible: false)
end
end
- describe 'user has a personal project' do
+ describe "user has a personal project" do
before do
create(:project, :private, namespace: user.namespace, creator: user) { |p| p.add_maintainer(user) }
end
- include_context 'visit overview tab'
+ include_context "visit overview tab"
- it 'it shows one entry in the list of projects' do
- page.within('.projects-block') do
- expect(page).to have_selector('.project-row', count: 1)
+ it "it shows one entry in the list of projects" do
+ page.within(".projects-block") do
+ expect(page).to have_selector(".project-row", count: 1)
end
end
- it 'shows a link to the project list' do
- expect(find('#js-overview .projects-block')).to have_selector('.js-view-all', visible: true)
+ it "shows a link to the project list" do
+ expect(find("#js-overview .projects-block")).to have_selector(".js-view-all", visible: true)
end
it 'shows projects in "compact mode"' do
- page.within('#js-overview .projects-block') do
- expect(find('.js-projects-list-holder')).to have_selector('.compact')
+ page.within("#js-overview .projects-block") do
+ expect(find(".js-projects-list-holder")).to have_selector(".compact")
end
end
end
- describe 'user has more than ten personal projects' do
+ describe "user has more than ten personal projects" do
before do
create_list(:project, 11, :private, namespace: user.namespace, creator: user) do |project|
project.add_maintainer(user)
end
end
- include_context 'visit overview tab'
+ include_context "visit overview tab"
- it 'it shows max. ten entries in the list of projects' do
- page.within('.projects-block') do
- expect(page).to have_selector('.project-row', count: 10)
+ it "it shows max. ten entries in the list of projects" do
+ page.within(".projects-block") do
+ expect(page).to have_selector(".project-row", count: 10)
end
end
- it 'shows a link to the project list' do
- expect(find('#js-overview .projects-block')).to have_selector('.js-view-all', visible: true)
+ it "shows a link to the project list" do
+ expect(find("#js-overview .projects-block")).to have_selector(".js-view-all", visible: true)
end
- it 'does not show pagination' do
- page.within('.projects-block') do
- expect(page).not_to have_selector('.gl-pagination')
+ it "does not show pagination" do
+ page.within(".projects-block") do
+ expect(page).not_to have_selector(".gl-pagination")
end
end
end
diff --git a/spec/features/users/rss_spec.rb b/spec/features/users/rss_spec.rb
index 9af4447056e..b6e5b8b2072 100644
--- a/spec/features/users/rss_spec.rb
+++ b/spec/features/users/rss_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User RSS' do
+describe "User RSS" do
let(:user) { create(:user) }
let(:path) { user_path(create(:user)) }
- context 'when signed in' do
+ context "when signed in" do
before do
sign_in(user)
visit path
@@ -13,7 +13,7 @@ describe 'User RSS' do
it_behaves_like "it has an RSS button with current_user's feed token"
end
- context 'when signed out' do
+ context "when signed out" do
before do
visit path
end
diff --git a/spec/features/users/show_spec.rb b/spec/features/users/show_spec.rb
index 86379164cf0..940b11c3c56 100644
--- a/spec/features/users/show_spec.rb
+++ b/spec/features/users/show_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'User page' do
+describe "User page" do
let(:user) { create(:user) }
- context 'with public profile' do
- it 'shows all the tabs' do
+ context "with public profile" do
+ it "shows all the tabs" do
visit(user_path(user))
- page.within '.nav-links' do
- expect(page).to have_link('Overview')
- expect(page).to have_link('Activity')
- expect(page).to have_link('Groups')
- expect(page).to have_link('Contributed projects')
- expect(page).to have_link('Personal projects')
- expect(page).to have_link('Snippets')
+ page.within ".nav-links" do
+ expect(page).to have_link("Overview")
+ expect(page).to have_link("Activity")
+ expect(page).to have_link("Groups")
+ expect(page).to have_link("Contributed projects")
+ expect(page).to have_link("Personal projects")
+ expect(page).to have_link("Snippets")
end
end
- it 'does not show private profile message' do
+ it "does not show private profile message" do
visit(user_path(user))
expect(page).not_to have_content("This user has a private profile")
end
end
- context 'with private profile' do
+ context "with private profile" do
let(:user) { create(:user, private_profile: true) }
- it 'shows no tab' do
+ it "shows no tab" do
visit(user_path(user))
expect(page).to have_css("div.profile-header")
expect(page).not_to have_css("ul.nav-links")
end
- it 'shows private profile message' do
+ it "shows private profile message" do
visit(user_path(user))
expect(page).to have_content("This user has a private profile")
end
- it 'shows own tabs' do
+ it "shows own tabs" do
sign_in(user)
visit(user_path(user))
- page.within '.nav-links' do
- expect(page).to have_link('Overview')
- expect(page).to have_link('Activity')
- expect(page).to have_link('Groups')
- expect(page).to have_link('Contributed projects')
- expect(page).to have_link('Personal projects')
- expect(page).to have_link('Snippets')
+ page.within ".nav-links" do
+ expect(page).to have_link("Overview")
+ expect(page).to have_link("Activity")
+ expect(page).to have_link("Groups")
+ expect(page).to have_link("Contributed projects")
+ expect(page).to have_link("Personal projects")
+ expect(page).to have_link("Snippets")
end
end
end
- it 'shows the status if there was one' do
+ it "shows the status if there was one" do
create(:user_status, user: user, message: "Working hard!")
visit(user_path(user))
@@ -63,26 +63,26 @@ describe 'User page' do
expect(page).to have_content("Working hard!")
end
- context 'signup disabled' do
- it 'shows the sign in link' do
+ context "signup disabled" do
+ it "shows the sign in link" do
stub_application_setting(signup_enabled: false)
visit(user_path(user))
- page.within '.navbar-nav' do
- expect(page).to have_link('Sign in')
+ page.within ".navbar-nav" do
+ expect(page).to have_link("Sign in")
end
end
end
- context 'signup enabled' do
- it 'shows the sign in and register link' do
+ context "signup enabled" do
+ it "shows the sign in and register link" do
stub_application_setting(signup_enabled: true)
visit(user_path(user))
- page.within '.navbar-nav' do
- expect(page).to have_link('Sign in / Register')
+ page.within ".navbar-nav" do
+ expect(page).to have_link("Sign in / Register")
end
end
end
diff --git a/spec/features/users/signup_spec.rb b/spec/features/users/signup_spec.rb
index 957c3cfc583..3c8230de5db 100644
--- a/spec/features/users/signup_spec.rb
+++ b/spec/features/users/signup_spec.rb
@@ -1,48 +1,48 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Signup' do
+describe "Signup" do
include TermsHelper
let(:new_user) { build_stubbed(:user) }
- describe 'username validation', :js do
+ describe "username validation", :js do
before do
visit root_path
- click_link 'Register'
+ click_link "Register"
end
- it 'does not show an error border if the username is available' do
- fill_in 'new_user_username', with: 'new-user'
+ it "does not show an error border if the username is available" do
+ fill_in "new_user_username", with: "new-user"
wait_for_requests
- expect(find('.username')).not_to have_css '.gl-field-error-outline'
+ expect(find(".username")).not_to have_css ".gl-field-error-outline"
end
- it 'does not show an error border if the username contains dots (.)' do
- fill_in 'new_user_username', with: 'new.user.username'
+ it "does not show an error border if the username contains dots (.)" do
+ fill_in "new_user_username", with: "new.user.username"
wait_for_requests
- expect(find('.username')).not_to have_css '.gl-field-error-outline'
+ expect(find(".username")).not_to have_css ".gl-field-error-outline"
end
- it 'shows an error border if the username already exists' do
+ it "shows an error border if the username already exists" do
existing_user = create(:user)
- fill_in 'new_user_username', with: existing_user.username
+ fill_in "new_user_username", with: existing_user.username
wait_for_requests
- expect(find('.username')).to have_css '.gl-field-error-outline'
+ expect(find(".username")).to have_css ".gl-field-error-outline"
end
- it 'shows an error border if the username contains special characters' do
- fill_in 'new_user_username', with: 'new$user!username'
+ it "shows an error border if the username contains special characters" do
+ fill_in "new_user_username", with: "new$user!username"
wait_for_requests
- expect(find('.username')).to have_css '.gl-field-error-outline'
+ expect(find(".username")).to have_css ".gl-field-error-outline"
end
- it 'shows an error message on submit if the username contains special characters' do
- fill_in 'new_user_username', with: 'new$user!username'
+ it "shows an error message on submit if the username contains special characters" do
+ fill_in "new_user_username", with: "new$user!username"
wait_for_requests
click_button "Register"
@@ -50,51 +50,51 @@ describe 'Signup' do
expect(page).to have_content("Please create a username with only alphanumeric characters.")
end
- it 'shows an error border if the username contains emojis' do
- simulate_input('#new_user_username', 'ehsan😀')
+ it "shows an error border if the username contains emojis" do
+ simulate_input("#new_user_username", "ehsan😀")
- expect(find('.username')).to have_css '.gl-field-error-outline'
+ expect(find(".username")).to have_css ".gl-field-error-outline"
end
- it 'shows an error message if the username contains emojis' do
- simulate_input('#new_user_username', 'ehsan😀')
+ it "shows an error message if the username contains emojis" do
+ simulate_input("#new_user_username", "ehsan😀")
expect(page).to have_content("Invalid input, please avoid emojis")
end
end
- describe 'user\'s full name validation', :js do
+ describe "user's full name validation", :js do
before do
visit root_path
- click_link 'Register'
- simulate_input('#new_user_name', 'Ehsan 🦋')
+ click_link "Register"
+ simulate_input("#new_user_name", "Ehsan 🦋")
end
- it 'shows an error border if the user\'s fullname contains an emoji' do
- expect(find('.name')).to have_css '.gl-field-error-outline'
+ it "shows an error border if the user's fullname contains an emoji" do
+ expect(find(".name")).to have_css ".gl-field-error-outline"
end
- it 'shows an error message if the username contains emojis' do
+ it "shows an error message if the username contains emojis" do
expect(page).to have_content("Invalid input, please avoid emojis")
end
end
- context 'with no errors' do
+ context "with no errors" do
context "when sending confirmation email" do
before do
stub_application_setting(send_user_confirmation_email: true)
end
- it 'creates the user account and sends a confirmation email' do
+ it "creates the user account and sends a confirmation email" do
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email
+ fill_in "new_user_password", with: new_user.password
- expect { click_button 'Register' }.to change { User.count }.by(1)
+ expect { click_button "Register" }.to change { User.count }.by(1)
expect(current_path).to eq users_almost_there_path
expect(page).to have_content("Please check your email to confirm your account")
@@ -105,11 +105,11 @@ describe 'Signup' do
it "creates the user successfully" do
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email.capitalize
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email.capitalize
+ fill_in "new_user_password", with: new_user.password
click_button "Register"
expect(current_path).to eq dashboard_projects_path
@@ -122,14 +122,14 @@ describe 'Signup' do
stub_application_setting(send_user_confirmation_email: false)
end
- it 'creates the user account and goes to dashboard' do
+ it "creates the user account and goes to dashboard" do
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email
+ fill_in "new_user_password", with: new_user.password
click_button "Register"
expect(current_path).to eq dashboard_projects_path
@@ -138,16 +138,16 @@ describe 'Signup' do
end
end
- context 'with errors' do
+ context "with errors" do
it "displays the errors" do
existing_user = create(:user)
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: existing_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: existing_user.email
+ fill_in "new_user_password", with: new_user.password
click_button "Register"
expect(current_path).to eq user_registration_path
@@ -156,15 +156,15 @@ describe 'Signup' do
expect(page).to have_content("Email confirmation doesn't match")
end
- it 'does not redisplay the password' do
+ it "does not redisplay the password" do
existing_user = create(:user)
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: existing_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: existing_user.email
+ fill_in "new_user_password", with: new_user.password
click_button "Register"
expect(current_path).to eq user_registration_path
@@ -172,34 +172,34 @@ describe 'Signup' do
end
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- it 'requires the user to check the checkbox' do
+ it "requires the user to check the checkbox" do
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email
+ fill_in "new_user_password", with: new_user.password
- click_button 'Register'
+ click_button "Register"
expect(current_path).to eq new_user_session_path
expect(page).to have_content(/you must accept our terms of service/i)
end
- it 'asks the user to accept terms before going to the dashboard' do
+ it "asks the user to accept terms before going to the dashboard" do
visit root_path
- fill_in 'new_user_name', with: new_user.name
- fill_in 'new_user_username', with: new_user.username
- fill_in 'new_user_email', with: new_user.email
- fill_in 'new_user_email_confirmation', with: new_user.email
- fill_in 'new_user_password', with: new_user.password
+ fill_in "new_user_name", with: new_user.name
+ fill_in "new_user_username", with: new_user.username
+ fill_in "new_user_email", with: new_user.email
+ fill_in "new_user_email_confirmation", with: new_user.email
+ fill_in "new_user_password", with: new_user.password
check :terms_opt_in
click_button "Register"
diff --git a/spec/features/users/snippets_spec.rb b/spec/features/users/snippets_spec.rb
index 8c697e33436..c18a5403f16 100644
--- a/spec/features/users/snippets_spec.rb
+++ b/spec/features/users/snippets_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Snippets tab on a user profile', :js do
- context 'when the user has snippets' do
+describe "Snippets tab on a user profile", :js do
+ context "when the user has snippets" do
let(:user) { create(:user) }
- context 'pagination' do
+ context "pagination" do
let!(:snippets) { create_list(:snippet, 2, :public, author: user) }
before do
allow(Snippet).to receive(:default_per_page).and_return(1)
visit user_path(user)
- page.within('.user-profile-nav') { click_link 'Snippets' }
+ page.within(".user-profile-nav") { click_link "Snippets" }
wait_for_requests
end
- it_behaves_like 'paginated snippets', remote: true
+ it_behaves_like "paginated snippets", remote: true
end
- context 'list content' do
+ context "list content" do
let!(:public_snippet) { create(:snippet, :public, author: user) }
let!(:internal_snippet) { create(:snippet, :internal, author: user) }
let!(:private_snippet) { create(:snippet, :private, author: user) }
let!(:other_snippet) { create(:snippet, :public) }
- it 'contains only internal and public snippets of a user when a user is logged in' do
+ it "contains only internal and public snippets of a user when a user is logged in" do
sign_in(create(:user))
visit user_path(user)
- page.within('.user-profile-nav') { click_link 'Snippets' }
+ page.within(".user-profile-nav") { click_link "Snippets" }
wait_for_requests
- expect(page).to have_selector('.snippet-row', count: 2)
+ expect(page).to have_selector(".snippet-row", count: 2)
expect(page).to have_content(public_snippet.title)
expect(page).to have_content(internal_snippet.title)
end
- it 'contains only public snippets of a user when a user is not logged in' do
+ it "contains only public snippets of a user when a user is not logged in" do
visit user_path(user)
- page.within('.user-profile-nav') { click_link 'Snippets' }
+ page.within(".user-profile-nav") { click_link "Snippets" }
wait_for_requests
- expect(page).to have_selector('.snippet-row', count: 1)
+ expect(page).to have_selector(".snippet-row", count: 1)
expect(page).to have_content(public_snippet.title)
end
end
diff --git a/spec/features/users/terms_spec.rb b/spec/features/users/terms_spec.rb
index 84df1016594..1601fb9b5ba 100644
--- a/spec/features/users/terms_spec.rb
+++ b/spec/features/users/terms_spec.rb
@@ -1,132 +1,132 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Users > Terms' do
+describe "Users > Terms" do
include TermsHelper
- let!(:term) { create(:term, terms: 'By accepting, you promise to be nice!') }
+ let!(:term) { create(:term, terms: "By accepting, you promise to be nice!") }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- it 'shows the terms' do
+ it "shows the terms" do
visit terms_path
- expect(page).to have_content('By accepting, you promise to be nice!')
+ expect(page).to have_content("By accepting, you promise to be nice!")
end
- it 'does not show buttons to accept, decline or sign out', :aggregate_failures do
+ it "does not show buttons to accept, decline or sign out", :aggregate_failures do
visit terms_path
- expect(page).not_to have_css('.footer-block')
- expect(page).not_to have_content('Accept terms')
- expect(page).not_to have_content('Decline and sign out')
- expect(page).not_to have_content('Continue')
+ expect(page).not_to have_css(".footer-block")
+ expect(page).not_to have_content("Accept terms")
+ expect(page).not_to have_content("Decline and sign out")
+ expect(page).not_to have_content("Continue")
end
- context 'when signed in' do
+ context "when signed in" do
let(:user) { create(:user) }
before do
sign_in(user)
end
- context 'declining the terms' do
- it 'returns the user to the app' do
+ context "declining the terms" do
+ it "returns the user to the app" do
visit terms_path
- click_button 'Decline and sign out'
+ click_button "Decline and sign out"
expect(page).not_to have_content(term.terms)
expect(user.reload.terms_accepted?).to be(false)
end
end
- context 'accepting the terms' do
- it 'returns the user to the app' do
+ context "accepting the terms" do
+ it "returns the user to the app" do
visit terms_path
- click_button 'Accept terms'
+ click_button "Accept terms"
expect(page).not_to have_content(term.terms)
expect(user.reload.terms_accepted?).to be(true)
end
end
- context 'when the user has already accepted the terms' do
+ context "when the user has already accepted the terms" do
before do
accept_terms(user)
end
- it 'allows the user to continue to the app' do
+ it "allows the user to continue to the app" do
visit terms_path
expect(page).to have_content "You have already accepted the Terms of Service as #{user.to_reference}"
- click_link 'Continue'
+ click_link "Continue"
expect(current_path).to eq(root_path)
end
end
- context 'terms were enforced while session is active', :js do
+ context "terms were enforced while session is active", :js do
let(:project) { create(:project) }
before do
project.add_developer(user)
end
- it 'redirects to terms and back to where the user was going' do
+ it "redirects to terms and back to where the user was going" do
visit project_path(project)
enforce_terms
- within('.nav-sidebar') do
- click_link 'Issues'
+ within(".nav-sidebar") do
+ click_link "Issues"
end
expect_to_be_on_terms_page
- click_button('Accept terms')
+ click_button("Accept terms")
expect(current_path).to eq(project_issues_path(project))
end
# Disabled until https://gitlab.com/gitlab-org/gitlab-ce/issues/37162 is solved properly
- xit 'redirects back to the page the user was trying to save' do
+ xit "redirects back to the page the user was trying to save" do
visit new_project_issue_path(project)
- fill_in :issue_title, with: 'Hello world, a new issue'
+ fill_in :issue_title, with: "Hello world, a new issue"
fill_in :issue_description, with: "We don't want to lose what the user typed"
enforce_terms
- click_button 'Submit issue'
+ click_button "Submit issue"
expect(current_path).to eq(terms_path)
- click_button('Accept terms')
+ click_button("Accept terms")
expect(current_path).to eq(new_project_issue_path(project))
- expect(find_field('issue_title').value).to eq('Hello world, a new issue')
- expect(find_field('issue_description').value).to eq("We don't want to lose what the user typed")
+ expect(find_field("issue_title").value).to eq("Hello world, a new issue")
+ expect(find_field("issue_description").value).to eq("We don't want to lose what the user typed")
end
end
- context 'when the terms are enforced' do
+ context "when the terms are enforced" do
before do
enforce_terms
end
- context 'signing out', :js do
- it 'allows the user to sign out without a response' do
+ context "signing out", :js do
+ it "allows the user to sign out without a response" do
visit terms_path
- find('.header-user-dropdown-toggle').click
- click_link('Sign out')
+ find(".header-user-dropdown-toggle").click
+ click_link("Sign out")
- expect(page).to have_content('Sign in')
- expect(page).to have_content('Register')
+ expect(page).to have_content("Sign in")
+ expect(page).to have_content("Register")
end
end
end
diff --git a/spec/features/users/user_browses_projects_on_user_page_spec.rb b/spec/features/users/user_browses_projects_on_user_page_spec.rb
index 6a9b281fb4c..08c56ef61c2 100644
--- a/spec/features/users/user_browses_projects_on_user_page_spec.rb
+++ b/spec/features/users/user_browses_projects_on_user_page_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Users > User browses projects on user page', :js do
+describe "Users > User browses projects on user page", :js do
let!(:user) { create :user }
let!(:private_project) do
- create :project, :private, name: 'private', namespace: user.namespace do |project|
+ create :project, :private, name: "private", namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
let!(:internal_project) do
- create :project, :internal, name: 'internal', namespace: user.namespace do |project|
+ create :project, :internal, name: "internal", namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
let!(:public_project) do
- create :project, :public, name: 'public', namespace: user.namespace do |project|
+ create :project, :public, name: "public", namespace: user.namespace do |project|
project.add_maintainer(user)
end
end
def click_nav_link(name)
- page.within '.nav-links' do
+ page.within ".nav-links" do
click_link name
end
end
- it 'hides loading spinner after load', :js do
+ it "hides loading spinner after load", :js do
visit user_path(user)
- click_nav_link('Personal projects')
+ click_nav_link("Personal projects")
wait_for_requests
- expect(page).not_to have_selector('.loading-status .loading', visible: true)
+ expect(page).not_to have_selector(".loading-status .loading", visible: true)
end
- it 'paginates projects', :js do
+ it "paginates projects", :js do
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since)
project2 = create(:project, namespace: user.namespace, updated_at: 1.minute.since)
allow(Project).to receive(:default_per_page).and_return(1)
sign_in(user)
visit user_path(user)
- click_nav_link('Personal projects')
+ click_nav_link("Personal projects")
wait_for_requests
expect(page).to have_content(project.name)
- click_link('Next')
+ click_link("Next")
expect(page).to have_content(project2.name)
end
- context 'when not signed in' do
- it 'renders user public project' do
+ context "when not signed in" do
+ it "renders user public project" do
visit user_path(user)
- click_nav_link('Personal projects')
+ click_nav_link("Personal projects")
- expect(page).to have_css('.tab-content #projects.active')
+ expect(page).to have_css(".tab-content #projects.active")
expect(title).to start_with(user.name)
expect(page).to have_content(public_project.name)
@@ -67,16 +67,16 @@ describe 'Users > User browses projects on user page', :js do
end
end
- context 'when signed in as another user' do
+ context "when signed in as another user" do
let(:another_user) { create :user }
before do
sign_in(another_user)
end
- it 'renders user public and internal projects' do
+ it "renders user public and internal projects" do
visit user_path(user)
- click_nav_link('Personal projects')
+ click_nav_link("Personal projects")
expect(title).to start_with(user.name)
@@ -86,15 +86,15 @@ describe 'Users > User browses projects on user page', :js do
end
end
- context 'when signed in as user' do
+ context "when signed in as user" do
before do
sign_in(user)
end
- describe 'personal projects' do
- it 'renders all user projects' do
+ describe "personal projects" do
+ it "renders all user projects" do
visit user_path(user)
- click_nav_link('Personal projects')
+ click_nav_link("Personal projects")
expect(title).to start_with(user.name)
expect(page).to have_content(private_project.name)
@@ -103,27 +103,27 @@ describe 'Users > User browses projects on user page', :js do
end
end
- describe 'contributed projects' do
- context 'when user has contributions' do
+ describe "contributed projects" do
+ context "when user has contributions" do
let(:contributed_project) do
create :project, :public, :empty_repo
end
before do
- Issues::CreateService.new(contributed_project, user, { title: 'Bug in old browser' }).execute
+ Issues::CreateService.new(contributed_project, user, {title: "Bug in old browser"}).execute
event = create(:push_event, project: contributed_project, author: user)
create(:push_event_payload, event: event, commit_count: 3)
end
- it 'renders contributed project' do
+ it "renders contributed project" do
visit user_path(user)
expect(title).to start_with(user.name)
- expect(page).to have_css('.js-contrib-calendar')
+ expect(page).to have_css(".js-contrib-calendar")
- click_nav_link('Contributed projects')
+ click_nav_link("Contributed projects")
- page.within '#contributed' do
+ page.within "#contributed" do
expect(page).to have_content(contributed_project.name)
end
end
diff --git a/spec/finders/access_requests_finder_spec.rb b/spec/finders/access_requests_finder_spec.rb
index 605777462bb..d29d7e4b6b4 100644
--- a/spec/finders/access_requests_finder_spec.rb
+++ b/spec/finders/access_requests_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AccessRequestsFinder do
let(:user) { create(:user) }
@@ -16,8 +16,8 @@ describe AccessRequestsFinder do
end
end
- shared_examples 'a finder returning access requesters' do |method_name|
- it 'returns access requesters' do
+ shared_examples "a finder returning access requesters" do |method_name|
+ it "returns access requesters" do
access_requesters = described_class.new(source).public_send(method_name, user)
expect(access_requesters.size).to eq(1)
@@ -26,67 +26,67 @@ describe AccessRequestsFinder do
end
end
- shared_examples 'a finder returning no results' do |method_name|
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a finder returning no results" do |method_name|
+ it "raises Gitlab::Access::AccessDeniedError" do
expect(described_class.new(source).public_send(method_name, user)).to be_empty
end
end
- shared_examples 'a finder raising Gitlab::Access::AccessDeniedError' do |method_name|
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a finder raising Gitlab::Access::AccessDeniedError" do |method_name|
+ it "raises Gitlab::Access::AccessDeniedError" do
expect { described_class.new(source).public_send(method_name, user) }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- describe '#execute' do
- context 'when current user cannot see project access requests' do
- it_behaves_like 'a finder returning no results', :execute do
+ describe "#execute" do
+ context "when current user cannot see project access requests" do
+ it_behaves_like "a finder returning no results", :execute do
let(:source) { project }
end
- it_behaves_like 'a finder returning no results', :execute do
+ it_behaves_like "a finder returning no results", :execute do
let(:source) { group }
end
end
- context 'when current user can see access requests' do
+ context "when current user can see access requests" do
before do
project.add_maintainer(user)
group.add_owner(user)
end
- it_behaves_like 'a finder returning access requesters', :execute do
+ it_behaves_like "a finder returning access requesters", :execute do
let(:source) { project }
end
- it_behaves_like 'a finder returning access requesters', :execute do
+ it_behaves_like "a finder returning access requesters", :execute do
let(:source) { group }
end
end
end
- describe '#execute!' do
- context 'when current user cannot see access requests' do
- it_behaves_like 'a finder raising Gitlab::Access::AccessDeniedError', :execute! do
+ describe "#execute!" do
+ context "when current user cannot see access requests" do
+ it_behaves_like "a finder raising Gitlab::Access::AccessDeniedError", :execute! do
let(:source) { project }
end
- it_behaves_like 'a finder raising Gitlab::Access::AccessDeniedError', :execute! do
+ it_behaves_like "a finder raising Gitlab::Access::AccessDeniedError", :execute! do
let(:source) { group }
end
end
- context 'when current user can see access requests' do
+ context "when current user can see access requests" do
before do
project.add_maintainer(user)
group.add_owner(user)
end
- it_behaves_like 'a finder returning access requesters', :execute! do
+ it_behaves_like "a finder returning access requesters", :execute! do
let(:source) { project }
end
- it_behaves_like 'a finder returning access requesters', :execute! do
+ it_behaves_like "a finder returning access requesters", :execute! do
let(:source) { group }
end
end
diff --git a/spec/finders/admin/projects_finder_spec.rb b/spec/finders/admin/projects_finder_spec.rb
index 44cc8debd04..c3df64b615a 100644
--- a/spec/finders/admin/projects_finder_spec.rb
+++ b/spec/finders/admin/projects_finder_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Admin::ProjectsFinder do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let!(:private_project) do
- create(:project, :private, name: 'A', path: 'A')
+ create(:project, :private, name: "A", path: "A")
end
let!(:internal_project) do
- create(:project, :internal, group: group, name: 'B', path: 'B')
+ create(:project, :internal, group: group, name: "B", path: "B")
end
let!(:public_project) do
- create(:project, :public, group: group, name: 'C', path: 'C')
+ create(:project, :public, group: group, name: "C", path: "C")
end
let!(:shared_project) do
- create(:project, :private, name: 'D', path: 'D')
+ create(:project, :private, name: "D", path: "D")
end
let(:params) { {} }
@@ -28,119 +28,119 @@ describe Admin::ProjectsFinder do
subject { finder.execute.to_a }
- context 'without a user' do
+ context "without a user" do
let(:current_user) { nil }
it { is_expected.to match_array([shared_project, public_project, internal_project, private_project]) }
end
- context 'with a user' do
+ context "with a user" do
it { is_expected.to match_array([shared_project, public_project, internal_project, private_project]) }
end
- context 'with pending delete project' do
+ context "with pending delete project" do
let!(:pending_delete_project) { create(:project, pending_delete: true) }
it { is_expected.not_to include(pending_delete_project) }
end
- context 'filter by namespace_id' do
+ context "filter by namespace_id" do
let(:namespace) { create(:namespace) }
let!(:project_in_namespace) { create(:project, namespace: namespace) }
- let(:params) { { namespace_id: namespace.id } }
+ let(:params) { {namespace_id: namespace.id} }
it { is_expected.to eq([project_in_namespace]) }
end
- context 'filter by visibility_level' do
+ context "filter by visibility_level" do
before do
private_project.add_maintainer(user)
end
- context 'private' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
+ context "private" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::PRIVATE} }
it { is_expected.to match_array([shared_project, private_project]) }
end
- context 'internal' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::INTERNAL } }
+ context "internal" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::INTERNAL} }
it { is_expected.to eq([internal_project]) }
end
- context 'public' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
+ context "public" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::PUBLIC} }
it { is_expected.to eq([public_project]) }
end
end
- context 'filter by push' do
+ context "filter by push" do
let(:pushed_event) { create(:event, :pushed) }
let!(:project_with_push) { pushed_event.project }
- let(:params) { { with_push: true } }
+ let(:params) { {with_push: true} }
it { is_expected.to eq([project_with_push]) }
end
- context 'filter by abandoned' do
+ context "filter by abandoned" do
before do
private_project.update(last_activity_at: Time.zone.now - 6.months - 1.minute)
end
- let(:params) { { abandoned: true } }
+ let(:params) { {abandoned: true} }
it { is_expected.to eq([private_project]) }
end
- context 'filter by last_repository_check_failed' do
+ context "filter by last_repository_check_failed" do
before do
private_project.update(last_repository_check_failed: true)
end
- let(:params) { { last_repository_check_failed: true } }
+ let(:params) { {last_repository_check_failed: true} }
it { is_expected.to eq([private_project]) }
end
- context 'filter by archived' do
- let!(:archived_project) { create(:project, :public, :archived, name: 'E', path: 'E') }
+ context "filter by archived" do
+ let!(:archived_project) { create(:project, :public, :archived, name: "E", path: "E") }
- context 'archived=false' do
- let(:params) { { archived: false } }
+ context "archived=false" do
+ let(:params) { {archived: false} }
it { is_expected.to match_array([shared_project, public_project, internal_project, private_project]) }
end
- context 'archived=true' do
- let(:params) { { archived: true } }
+ context "archived=true" do
+ let(:params) { {archived: true} }
it { is_expected.to match_array([archived_project, shared_project, public_project, internal_project, private_project]) }
end
- context 'archived=only' do
- let(:params) { { archived: 'only' } }
+ context "archived=only" do
+ let(:params) { {archived: "only"} }
it { is_expected.to eq([archived_project]) }
end
end
- context 'filter by personal' do
+ context "filter by personal" do
let!(:personal_project) { create(:project, namespace: user.namespace) }
- let(:params) { { personal: true } }
+ let(:params) { {personal: true} }
it { is_expected.to eq([personal_project]) }
end
- context 'filter by name' do
- let(:params) { { name: 'C' } }
+ context "filter by name" do
+ let(:params) { {name: "C"} }
it { is_expected.to match_array([public_project]) }
end
- context 'sorting' do
- let(:params) { { sort: 'name_asc' } }
+ context "sorting" do
+ let(:params) { {sort: "name_asc"} }
it { is_expected.to eq([private_project, internal_project, public_project, shared_project]) }
end
diff --git a/spec/finders/admin/runners_finder_spec.rb b/spec/finders/admin/runners_finder_spec.rb
index 94ccb398801..951a45dfc8e 100644
--- a/spec/finders/admin/runners_finder_spec.rb
+++ b/spec/finders/admin/runners_finder_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Admin::RunnersFinder do
- describe '#execute' do
- context 'with empty params' do
- it 'returns all runners' do
+ describe "#execute" do
+ context "with empty params" do
+ it "returns all runners" do
runner1 = create :ci_runner, active: true
runner2 = create :ci_runner, active: false
@@ -13,68 +13,68 @@ describe Admin::RunnersFinder do
end
end
- context 'filter by search term' do
- it 'calls Ci::Runner.search' do
- expect(Ci::Runner).to receive(:search).with('term').and_call_original
+ context "filter by search term" do
+ it "calls Ci::Runner.search" do
+ expect(Ci::Runner).to receive(:search).with("term").and_call_original
- described_class.new(params: { search: 'term' }).execute
+ described_class.new(params: {search: "term"}).execute
end
end
- context 'filter by status' do
- it 'calls the corresponding scope on Ci::Runner' do
+ context "filter by status" do
+ it "calls the corresponding scope on Ci::Runner" do
expect(Ci::Runner).to receive(:paused).and_call_original
- described_class.new(params: { status_status: 'paused' }).execute
+ described_class.new(params: {status_status: "paused"}).execute
end
end
- context 'filter by runner type' do
- it 'calls the corresponding scope on Ci::Runner' do
+ context "filter by runner type" do
+ it "calls the corresponding scope on Ci::Runner" do
expect(Ci::Runner).to receive(:project_type).and_call_original
- described_class.new(params: { type_type: 'project_type' }).execute
+ described_class.new(params: {type_type: "project_type"}).execute
end
end
- context 'filter by tag_name' do
- it 'calls the corresponding scope on Ci::Runner' do
+ context "filter by tag_name" do
+ it "calls the corresponding scope on Ci::Runner" do
expect(Ci::Runner).to receive(:tagged_with).with(%w[tag1 tag2]).and_call_original
- described_class.new(params: { tag_name: %w[tag1 tag2] }).execute
+ described_class.new(params: {tag_name: %w[tag1 tag2]}).execute
end
end
- context 'sort' do
- context 'without sort param' do
- it 'sorts by created_at' do
- runner1 = create :ci_runner, created_at: '2018-07-12 07:00'
- runner2 = create :ci_runner, created_at: '2018-07-12 08:00'
- runner3 = create :ci_runner, created_at: '2018-07-12 09:00'
+ context "sort" do
+ context "without sort param" do
+ it "sorts by created_at" do
+ runner1 = create :ci_runner, created_at: "2018-07-12 07:00"
+ runner2 = create :ci_runner, created_at: "2018-07-12 08:00"
+ runner3 = create :ci_runner, created_at: "2018-07-12 09:00"
expect(described_class.new(params: {}).execute).to eq [runner3, runner2, runner1]
end
end
- context 'with sort param' do
- it 'sorts by specified attribute' do
+ context "with sort param" do
+ it "sorts by specified attribute" do
runner1 = create :ci_runner, contacted_at: 1.minute.ago
runner2 = create :ci_runner, contacted_at: 3.minutes.ago
runner3 = create :ci_runner, contacted_at: 2.minutes.ago
- expect(described_class.new(params: { sort: 'contacted_asc' }).execute).to eq [runner2, runner3, runner1]
+ expect(described_class.new(params: {sort: "contacted_asc"}).execute).to eq [runner2, runner3, runner1]
end
end
end
- context 'paginate' do
- it 'returns the runners for the specified page' do
- stub_const('Admin::RunnersFinder::NUMBER_OF_RUNNERS_PER_PAGE', 1)
- runner1 = create :ci_runner, created_at: '2018-07-12 07:00'
- runner2 = create :ci_runner, created_at: '2018-07-12 08:00'
+ context "paginate" do
+ it "returns the runners for the specified page" do
+ stub_const("Admin::RunnersFinder::NUMBER_OF_RUNNERS_PER_PAGE", 1)
+ runner1 = create :ci_runner, created_at: "2018-07-12 07:00"
+ runner2 = create :ci_runner, created_at: "2018-07-12 08:00"
- expect(described_class.new(params: { page: 1 }).execute).to eq [runner2]
- expect(described_class.new(params: { page: 2 }).execute).to eq [runner1]
+ expect(described_class.new(params: {page: 1}).execute).to eq [runner2]
+ expect(described_class.new(params: {page: 2}).execute).to eq [runner1]
end
end
end
diff --git a/spec/finders/applications_finder_spec.rb b/spec/finders/applications_finder_spec.rb
index 14d6b35cc27..dd40899e21e 100644
--- a/spec/finders/applications_finder_spec.rb
+++ b/spec/finders/applications_finder_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ApplicationsFinder do
- let(:application1) { create(:application, name: 'some_application', owner: nil, redirect_uri: 'http://some_application.url', scopes: '') }
- let(:application2) { create(:application, name: 'another_application', owner: nil, redirect_uri: 'http://other_application.url', scopes: '') }
+ let(:application1) { create(:application, name: "some_application", owner: nil, redirect_uri: "http://some_application.url", scopes: "") }
+ let(:application2) { create(:application, name: "another_application", owner: nil, redirect_uri: "http://other_application.url", scopes: "") }
- describe '#execute' do
- it 'returns an array of applications' do
+ describe "#execute" do
+ it "returns an array of applications" do
found = described_class.new.execute
expect(found).to match_array([application1, application2])
end
- it 'returns the application by id' do
- params = { id: application1.id }
+ it "returns the application by id" do
+ params = {id: application1.id}
found = described_class.new(params).execute
expect(found).to match(application1)
diff --git a/spec/finders/autocomplete/acts_as_taggable_on/tags_finder_spec.rb b/spec/finders/autocomplete/acts_as_taggable_on/tags_finder_spec.rb
index 79d2f9cdb45..9e495ccc9c5 100644
--- a/spec/finders/autocomplete/acts_as_taggable_on/tags_finder_spec.rb
+++ b/spec/finders/autocomplete/acts_as_taggable_on/tags_finder_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Autocomplete::ActsAsTaggableOn::TagsFinder do
- describe '#execute' do
- context 'with empty params' do
- it 'returns all tags' do
- tag1 = ActsAsTaggableOn::Tag.create!(name: 'tag1')
- tag2 = ActsAsTaggableOn::Tag.create!(name: 'tag2')
+ describe "#execute" do
+ context "with empty params" do
+ it "returns all tags" do
+ tag1 = ActsAsTaggableOn::Tag.create!(name: "tag1")
+ tag2 = ActsAsTaggableOn::Tag.create!(name: "tag2")
tags = described_class.new(params: {}).execute
@@ -15,49 +15,49 @@ describe Autocomplete::ActsAsTaggableOn::TagsFinder do
end
end
- context 'filter by search' do
- context 'with an empty search term' do
- it 'returns an empty collection' do
- ActsAsTaggableOn::Tag.create!(name: 'tag1')
- ActsAsTaggableOn::Tag.create!(name: 'tag2')
+ context "filter by search" do
+ context "with an empty search term" do
+ it "returns an empty collection" do
+ ActsAsTaggableOn::Tag.create!(name: "tag1")
+ ActsAsTaggableOn::Tag.create!(name: "tag2")
- tags = described_class.new(params: { search: '' }).execute
+ tags = described_class.new(params: {search: ""}).execute
expect(tags).to be_empty
end
end
- context 'with a search containing 2 characters' do
- it 'returns the tag that strictly matches the search term' do
- tag1 = ActsAsTaggableOn::Tag.create!(name: 't1')
- ActsAsTaggableOn::Tag.create!(name: 't11')
+ context "with a search containing 2 characters" do
+ it "returns the tag that strictly matches the search term" do
+ tag1 = ActsAsTaggableOn::Tag.create!(name: "t1")
+ ActsAsTaggableOn::Tag.create!(name: "t11")
- tags = described_class.new(params: { search: 't1' }).execute
+ tags = described_class.new(params: {search: "t1"}).execute
expect(tags).to match_array [tag1]
end
end
- context 'with a search containing 3 characters' do
- it 'returns the tag that partially matches the search term' do
- tag1 = ActsAsTaggableOn::Tag.create!(name: 'tag1')
- tag2 = ActsAsTaggableOn::Tag.create!(name: 'tag11')
+ context "with a search containing 3 characters" do
+ it "returns the tag that partially matches the search term" do
+ tag1 = ActsAsTaggableOn::Tag.create!(name: "tag1")
+ tag2 = ActsAsTaggableOn::Tag.create!(name: "tag11")
- tags = described_class.new(params: { search: 'ag1' }).execute
+ tags = described_class.new(params: {search: "ag1"}).execute
expect(tags).to match_array [tag1, tag2]
end
end
end
- context 'limit' do
- it 'limits the result set by the limit constant' do
+ context "limit" do
+ it "limits the result set by the limit constant" do
stub_const("#{described_class}::LIMIT", 1)
- ActsAsTaggableOn::Tag.create!(name: 'tag1')
- ActsAsTaggableOn::Tag.create!(name: 'tag2')
+ ActsAsTaggableOn::Tag.create!(name: "tag1")
+ ActsAsTaggableOn::Tag.create!(name: "tag2")
- tags = described_class.new(params: { search: 'tag' }).execute
+ tags = described_class.new(params: {search: "tag"}).execute
expect(tags.count).to eq 1
end
diff --git a/spec/finders/autocomplete/group_finder_spec.rb b/spec/finders/autocomplete/group_finder_spec.rb
index d7cb2c3bbe2..1078cee63eb 100644
--- a/spec/finders/autocomplete/group_finder_spec.rb
+++ b/spec/finders/autocomplete/group_finder_spec.rb
@@ -1,53 +1,53 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Autocomplete::GroupFinder do
let(:user) { create(:user) }
- describe '#execute' do
- context 'with a project' do
- it 'returns nil' do
+ describe "#execute" do
+ context "with a project" do
+ it "returns nil" do
project = create(:project)
expect(described_class.new(user, project).execute).to be_nil
end
end
- context 'without a group ID' do
- it 'returns nil' do
+ context "without a group ID" do
+ it "returns nil" do
expect(described_class.new(user).execute).to be_nil
end
end
- context 'with an empty String as the group ID' do
- it 'returns nil' do
- expect(described_class.new(user, nil, group_id: '').execute).to be_nil
+ context "with an empty String as the group ID" do
+ it "returns nil" do
+ expect(described_class.new(user, nil, group_id: "").execute).to be_nil
end
end
- context 'without a project and with a group ID' do
- it 'raises ActiveRecord::RecordNotFound if the group does not exist' do
+ context "without a project and with a group ID" do
+ it "raises ActiveRecord::RecordNotFound if the group does not exist" do
finder = described_class.new(user, nil, group_id: 1)
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises ActiveRecord::RecordNotFound if the user can not read the group' do
+ it "raises ActiveRecord::RecordNotFound if the user can not read the group" do
group = create(:group, :private)
finder = described_class.new(user, nil, group_id: group.id)
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises ActiveRecord::RecordNotFound if an anonymous user can not read the group' do
+ it "raises ActiveRecord::RecordNotFound if an anonymous user can not read the group" do
group = create(:group, :private)
finder = described_class.new(nil, nil, group_id: group.id)
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'returns the group if it exists and is readable' do
+ it "returns the group if it exists and is readable" do
group = create(:group)
finder = described_class.new(user, nil, group_id: group.id)
diff --git a/spec/finders/autocomplete/move_to_project_finder_spec.rb b/spec/finders/autocomplete/move_to_project_finder_spec.rb
index c3bc410a7f6..7c65c2f1f79 100644
--- a/spec/finders/autocomplete/move_to_project_finder_spec.rb
+++ b/spec/finders/autocomplete/move_to_project_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Autocomplete::MoveToProjectFinder do
let(:user) { create(:user) }
@@ -10,9 +10,9 @@ describe Autocomplete::MoveToProjectFinder do
let(:developer_project) { create(:project) }
let(:maintainer_project) { create(:project) }
- describe '#execute' do
- context 'filter' do
- it 'does not return projects under Gitlab::Access::REPORTER' do
+ describe "#execute" do
+ context "filter" do
+ it "does not return projects under Gitlab::Access::REPORTER" do
guest_project.add_guest(user)
finder = described_class.new(user, project_id: project.id)
@@ -20,7 +20,7 @@ describe Autocomplete::MoveToProjectFinder do
expect(finder.execute).to be_empty
end
- it 'returns projects equal or above Gitlab::Access::REPORTER ordered by id in descending order' do
+ it "returns projects equal or above Gitlab::Access::REPORTER ordered by id in descending order" do
reporter_project.add_reporter(user)
developer_project.add_developer(user)
maintainer_project.add_maintainer(user)
@@ -30,7 +30,7 @@ describe Autocomplete::MoveToProjectFinder do
expect(finder.execute.to_a).to eq([maintainer_project, developer_project, reporter_project])
end
- it 'does not include the source project' do
+ it "does not include the source project" do
project.add_reporter(user)
finder = described_class.new(user, project_id: project.id)
@@ -38,7 +38,7 @@ describe Autocomplete::MoveToProjectFinder do
expect(finder.execute.to_a).to be_empty
end
- it 'does not return archived projects' do
+ it "does not return archived projects" do
reporter_project.add_reporter(user)
::Projects::UpdateService.new(reporter_project, user, archived: true).execute
other_reporter_project = create(:project)
@@ -49,7 +49,7 @@ describe Autocomplete::MoveToProjectFinder do
expect(finder.execute.to_a).to eq([other_reporter_project])
end
- it 'does not return projects for which issues are disabled' do
+ it "does not return projects for which issues are disabled" do
reporter_project.add_reporter(user)
reporter_project.update(issues_enabled: false)
other_reporter_project = create(:project)
@@ -60,12 +60,12 @@ describe Autocomplete::MoveToProjectFinder do
expect(finder.execute.to_a).to eq([other_reporter_project])
end
- it 'returns a page of projects ordered by id in descending order' do
+ it "returns a page of projects ordered by id in descending order" do
allow(Kaminari.config).to receive(:default_per_page).and_return(2)
- projects = create_list(:project, 2) do |project|
+ projects = create_list(:project, 2) { |project|
project.add_developer(user)
- end
+ }
finder = described_class.new(user, project_id: project.id)
page = finder.execute.to_a
@@ -74,7 +74,7 @@ describe Autocomplete::MoveToProjectFinder do
expect(page[0]).to eq(projects.last)
end
- it 'returns projects after the given offset id' do
+ it "returns projects after the given offset id" do
reporter_project.add_reporter(user)
developer_project.add_developer(user)
maintainer_project.add_maintainer(user)
@@ -90,18 +90,18 @@ describe Autocomplete::MoveToProjectFinder do
end
end
- context 'search' do
- it 'returns projects matching a search query' do
+ context "search" do
+ it "returns projects matching a search query" do
foo_project = create(:project)
foo_project.add_maintainer(user)
- wadus_project = create(:project, name: 'wadus')
+ wadus_project = create(:project, name: "wadus")
wadus_project.add_maintainer(user)
expect(described_class.new(user, project_id: project.id).execute.to_a)
.to eq([wadus_project, foo_project])
- expect(described_class.new(user, project_id: project.id, search: 'wadus').execute.to_a)
+ expect(described_class.new(user, project_id: project.id, search: "wadus").execute.to_a)
.to eq([wadus_project])
end
end
diff --git a/spec/finders/autocomplete/project_finder_spec.rb b/spec/finders/autocomplete/project_finder_spec.rb
index 207d0598c28..4b00e605505 100644
--- a/spec/finders/autocomplete/project_finder_spec.rb
+++ b/spec/finders/autocomplete/project_finder_spec.rb
@@ -1,31 +1,31 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Autocomplete::ProjectFinder do
let(:user) { create(:user) }
- describe '#execute' do
- context 'without a project ID' do
- it 'returns nil' do
+ describe "#execute" do
+ context "without a project ID" do
+ it "returns nil" do
expect(described_class.new(user).execute).to be_nil
end
end
- context 'with an empty String as the project ID' do
- it 'returns nil' do
- expect(described_class.new(user, project_id: '').execute).to be_nil
+ context "with an empty String as the project ID" do
+ it "returns nil" do
+ expect(described_class.new(user, project_id: "").execute).to be_nil
end
end
- context 'with a project ID' do
- it 'raises ActiveRecord::RecordNotFound if the project does not exist' do
+ context "with a project ID" do
+ it "raises ActiveRecord::RecordNotFound if the project does not exist" do
finder = described_class.new(user, project_id: 1)
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises ActiveRecord::RecordNotFound if the user can not read the project' do
+ it "raises ActiveRecord::RecordNotFound if the user can not read the project" do
project = create(:project, :private)
finder = described_class.new(user, project_id: project.id)
@@ -33,7 +33,7 @@ describe Autocomplete::ProjectFinder do
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises ActiveRecord::RecordNotFound if an anonymous user can not read the project' do
+ it "raises ActiveRecord::RecordNotFound if an anonymous user can not read the project" do
project = create(:project, :private)
finder = described_class.new(nil, project_id: project.id)
@@ -41,7 +41,7 @@ describe Autocomplete::ProjectFinder do
expect { finder.execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'returns the project if it exists and is readable' do
+ it "returns the project if it exists and is readable" do
project = create(:project, :private)
project.add_maintainer(user)
diff --git a/spec/finders/autocomplete/users_finder_spec.rb b/spec/finders/autocomplete/users_finder_spec.rb
index abd0d6b5185..720da0812cb 100644
--- a/spec/finders/autocomplete/users_finder_spec.rb
+++ b/spec/finders/autocomplete/users_finder_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Autocomplete::UsersFinder do
- describe '#execute' do
- let!(:user1) { create(:user, username: 'johndoe') }
- let!(:user2) { create(:user, :blocked, username: 'notsorandom') }
+ describe "#execute" do
+ let!(:user1) { create(:user, username: "johndoe") }
+ let!(:user2) { create(:user, :blocked, username: "notsorandom") }
let!(:external_user) { create(:user, :external) }
- let!(:omniauth_user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
+ let!(:omniauth_user) { create(:omniauth_user, provider: "twitter", extern_uid: "123456") }
let(:current_user) { create(:user) }
let(:params) { {} }
@@ -14,25 +14,25 @@ describe Autocomplete::UsersFinder do
subject { described_class.new(params: params, current_user: current_user, project: project, group: group).execute.to_a }
- context 'when current_user not passed or nil' do
+ context "when current_user not passed or nil" do
let(:current_user) { nil }
it { is_expected.to match_array([]) }
end
- context 'when project passed' do
+ context "when project passed" do
let(:project) { create(:project) }
it { is_expected.to match_array([project.owner]) }
- context 'when author_id passed' do
- let(:params) { { author_id: user2.id } }
+ context "when author_id passed" do
+ let(:params) { {author_id: user2.id} }
it { is_expected.to match_array([project.owner, user2]) }
end
end
- context 'when group passed and project not passed' do
+ context "when group passed and project not passed" do
let(:group) { create(:group, :public) }
before do
@@ -42,7 +42,7 @@ describe Autocomplete::UsersFinder do
it { is_expected.to match_array([user1]) }
end
- context 'when passed a subgroup', :nested_groups do
+ context "when passed a subgroup", :nested_groups do
let(:grandparent) { create(:group, :public) }
let(:parent) { create(:group, :public, parent: grandparent) }
let(:child) { create(:group, :public, parent: parent) }
@@ -52,59 +52,59 @@ describe Autocomplete::UsersFinder do
let!(:parent_user) { create(:group_member, :developer, group: parent).user }
let!(:child_user) { create(:group_member, :developer, group: child).user }
- it 'includes users from parent groups as well' do
+ it "includes users from parent groups as well" do
expect(subject).to match_array([grandparent_user, parent_user])
end
end
it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) }
- context 'when filtered by search' do
- let(:params) { { search: 'johndoe' } }
+ context "when filtered by search" do
+ let(:params) { {search: "johndoe"} }
it { is_expected.to match_array([user1]) }
end
- context 'when filtered by skip_users' do
- let(:params) { { skip_users: [omniauth_user.id, current_user.id] } }
+ context "when filtered by skip_users" do
+ let(:params) { {skip_users: [omniauth_user.id, current_user.id]} }
it { is_expected.to match_array([user1, external_user]) }
end
- context 'when todos exist' do
+ context "when todos exist" do
let!(:pending_todo1) { create(:todo, user: current_user, author: user1, state: :pending) }
let!(:pending_todo2) { create(:todo, user: external_user, author: omniauth_user, state: :pending) }
let!(:done_todo1) { create(:todo, user: current_user, author: external_user, state: :done) }
let!(:done_todo2) { create(:todo, user: user1, author: external_user, state: :done) }
- context 'when filtered by todo_filter without todo_state_filter' do
- let(:params) { { todo_filter: true } }
+ context "when filtered by todo_filter without todo_state_filter" do
+ let(:params) { {todo_filter: true} }
it { is_expected.to match_array([]) }
end
- context 'when filtered by todo_filter with pending todo_state_filter' do
- let(:params) { { todo_filter: true, todo_state_filter: 'pending' } }
+ context "when filtered by todo_filter with pending todo_state_filter" do
+ let(:params) { {todo_filter: true, todo_state_filter: "pending"} }
it { is_expected.to match_array([user1]) }
end
- context 'when filtered by todo_filter with done todo_state_filter' do
- let(:params) { { todo_filter: true, todo_state_filter: 'done' } }
+ context "when filtered by todo_filter with done todo_state_filter" do
+ let(:params) { {todo_filter: true, todo_state_filter: "done"} }
it { is_expected.to match_array([external_user]) }
end
end
- context 'when filtered by current_user' do
+ context "when filtered by current_user" do
let(:current_user) { user2 }
- let(:params) { { current_user: true } }
+ let(:params) { {current_user: true} }
it { is_expected.to match_array([user2, user1, external_user, omniauth_user]) }
end
- context 'when filtered by author_id' do
- let(:params) { { author_id: user2.id } }
+ context "when filtered by author_id" do
+ let(:params) { {author_id: user2.id} }
it { is_expected.to match_array([user2, user1, external_user, omniauth_user, current_user]) }
end
diff --git a/spec/finders/awarded_emoji_finder_spec.rb b/spec/finders/awarded_emoji_finder_spec.rb
index d4479df7418..952801323c5 100644
--- a/spec/finders/awarded_emoji_finder_spec.rb
+++ b/spec/finders/awarded_emoji_finder_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe AwardedEmojiFinder do
- describe '#execute' do
- it 'returns an Array containing the awarded emoji names' do
+ describe "#execute" do
+ it "returns an Array containing the awarded emoji names" do
user = create(:user)
- create(:award_emoji, user: user, name: 'thumbsup')
- create(:award_emoji, user: user, name: 'thumbsup')
- create(:award_emoji, user: user, name: 'thumbsdown')
+ create(:award_emoji, user: user, name: "thumbsup")
+ create(:award_emoji, user: user, name: "thumbsup")
+ create(:award_emoji, user: user, name: "thumbsdown")
awarded = described_class.new(user).execute
- expect(awarded).to eq([{ name: 'thumbsup' }, { name: 'thumbsdown' }])
+ expect(awarded).to eq([{name: "thumbsup"}, {name: "thumbsdown"}])
end
- it 'returns an empty Array when no user is given' do
+ it "returns an empty Array when no user is given" do
awarded = described_class.new.execute
expect(awarded).to be_empty
diff --git a/spec/finders/branches_finder_spec.rb b/spec/finders/branches_finder_spec.rb
index 7d164539d9a..081d1f3e75a 100644
--- a/spec/finders/branches_finder_spec.rb
+++ b/spec/finders/branches_finder_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe BranchesFinder do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- describe '#execute' do
- context 'sort only' do
- it 'sorts by name' do
+ describe "#execute" do
+ context "sort only" do
+ it "sorts by name" do
branches_finder = described_class.new(repository, {})
result = branches_finder.execute
@@ -15,48 +15,48 @@ describe BranchesFinder do
expect(result.first.name).to eq("'test'")
end
- it 'sorts by recently_updated' do
- branches_finder = described_class.new(repository, { sort: 'updated_desc' })
+ it "sorts by recently_updated" do
+ branches_finder = described_class.new(repository, {sort: "updated_desc"})
result = branches_finder.execute
- recently_updated_branch = repository.branches.max do |a, b|
+ recently_updated_branch = repository.branches.max { |a, b|
repository.commit(a.dereferenced_target).committed_date <=> repository.commit(b.dereferenced_target).committed_date
- end
+ }
expect(result.first.name).to eq(recently_updated_branch.name)
end
- it 'sorts by last_updated' do
- branches_finder = described_class.new(repository, { sort: 'updated_asc' })
+ it "sorts by last_updated" do
+ branches_finder = described_class.new(repository, {sort: "updated_asc"})
result = branches_finder.execute
- expect(result.first.name).to eq('feature')
+ expect(result.first.name).to eq("feature")
end
end
- context 'filter only' do
- it 'filters branches by name' do
- branches_finder = described_class.new(repository, { search: 'fix' })
+ context "filter only" do
+ it "filters branches by name" do
+ branches_finder = described_class.new(repository, {search: "fix"})
result = branches_finder.execute
- expect(result.first.name).to eq('fix')
+ expect(result.first.name).to eq("fix")
expect(result.count).to eq(1)
end
- it 'filters branches by name ignoring letter case' do
- branches_finder = described_class.new(repository, { search: 'FiX' })
+ it "filters branches by name ignoring letter case" do
+ branches_finder = described_class.new(repository, {search: "FiX"})
result = branches_finder.execute
- expect(result.first.name).to eq('fix')
+ expect(result.first.name).to eq("fix")
expect(result.count).to eq(1)
end
- it 'does not find any branch with that name' do
- branches_finder = described_class.new(repository, { search: 'random' })
+ it "does not find any branch with that name" do
+ branches_finder = described_class.new(repository, {search: "random"})
result = branches_finder.execute
@@ -64,55 +64,55 @@ describe BranchesFinder do
end
end
- context 'filter and sort' do
- it 'filters branches by name and sorts by recently_updated' do
- params = { sort: 'updated_desc', search: 'feat' }
+ context "filter and sort" do
+ it "filters branches by name and sorts by recently_updated" do
+ params = {sort: "updated_desc", search: "feat"}
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature_conflict')
+ expect(result.first.name).to eq("feature_conflict")
expect(result.count).to eq(2)
end
- it 'filters branches by name and sorts by recently_updated, with exact matches first' do
- params = { sort: 'updated_desc', search: 'feature' }
+ it "filters branches by name and sorts by recently_updated, with exact matches first" do
+ params = {sort: "updated_desc", search: "feature"}
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature')
- expect(result.second.name).to eq('feature_conflict')
+ expect(result.first.name).to eq("feature")
+ expect(result.second.name).to eq("feature_conflict")
expect(result.count).to eq(2)
end
- it 'filters branches by name and sorts by last_updated' do
- params = { sort: 'updated_asc', search: 'feature' }
+ it "filters branches by name and sorts by last_updated" do
+ params = {sort: "updated_asc", search: "feature"}
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature')
+ expect(result.first.name).to eq("feature")
expect(result.count).to eq(2)
end
- it 'filters branches by name that begins with' do
- params = { search: '^feature_' }
+ it "filters branches by name that begins with" do
+ params = {search: "^feature_"}
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature_conflict')
+ expect(result.first.name).to eq("feature_conflict")
expect(result.count).to eq(1)
end
- it 'filters branches by name that ends with' do
- params = { search: 'feature$' }
+ it "filters branches by name that ends with" do
+ params = {search: "feature$"}
branches_finder = described_class.new(repository, params)
result = branches_finder.execute
- expect(result.first.name).to eq('feature')
+ expect(result.first.name).to eq("feature")
expect(result.count).to eq(1)
end
end
diff --git a/spec/finders/cluster_ancestors_finder_spec.rb b/spec/finders/cluster_ancestors_finder_spec.rb
index 332086c42e2..76b99741b60 100644
--- a/spec/finders/cluster_ancestors_finder_spec.rb
+++ b/spec/finders/cluster_ancestors_finder_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe ClusterAncestorsFinder, '#execute' do
+describe ClusterAncestorsFinder, "#execute" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:user) { create(:user) }
@@ -17,18 +17,18 @@ describe ClusterAncestorsFinder, '#execute' do
subject { described_class.new(clusterable, user).execute }
- context 'for a project' do
+ context "for a project" do
let(:clusterable) { project }
before do
project.add_maintainer(user)
end
- it 'returns the project clusters followed by group clusters' do
+ it "returns the project clusters followed by group clusters" do
is_expected.to eq([project_cluster, group_cluster])
end
- context 'nested groups', :nested_groups do
+ context "nested groups", :nested_groups do
let(:group) { create(:group, parent: parent_group) }
let(:parent_group) { create(:group) }
@@ -36,32 +36,32 @@ describe ClusterAncestorsFinder, '#execute' do
create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [parent_group])
end
- it 'returns the project clusters followed by group clusters ordered ascending the hierarchy' do
+ it "returns the project clusters followed by group clusters ordered ascending the hierarchy" do
is_expected.to eq([project_cluster, group_cluster, parent_group_cluster])
end
end
end
- context 'user cannot read clusters for clusterable' do
+ context "user cannot read clusters for clusterable" do
let(:clusterable) { project }
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
- context 'for a group' do
+ context "for a group" do
let(:clusterable) { group }
before do
group.add_maintainer(user)
end
- it 'returns the list of group clusters' do
+ it "returns the list of group clusters" do
is_expected.to eq([group_cluster])
end
- context 'nested groups', :nested_groups do
+ context "nested groups", :nested_groups do
let(:group) { create(:group, parent: parent_group) }
let(:parent_group) { create(:group) }
@@ -69,7 +69,7 @@ describe ClusterAncestorsFinder, '#execute' do
create(:cluster, :provided_by_user, cluster_type: :group_type, groups: [parent_group])
end
- it 'returns the list of group clusters ordered ascending the hierarchy' do
+ it "returns the list of group clusters ordered ascending the hierarchy" do
is_expected.to eq([group_cluster, parent_group_cluster])
end
end
diff --git a/spec/finders/clusters_finder_spec.rb b/spec/finders/clusters_finder_spec.rb
index da529e0670f..e311035ec20 100644
--- a/spec/finders/clusters_finder_spec.rb
+++ b/spec/finders/clusters_finder_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe ClustersFinder do
let(:project) { create(:project) }
set(:user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
let(:enabled_cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:disabled_cluster) { create(:cluster, :disabled, :provided_by_gcp, :production_environment, projects: [project]) }
subject { described_class.new(project, user, scope).execute }
- context 'when scope is all' do
+ context "when scope is all" do
let(:scope) { :all }
it { is_expected.to match_array([enabled_cluster, disabled_cluster]) }
end
- context 'when scope is active' do
+ context "when scope is active" do
let(:scope) { :active }
it { is_expected.to match_array([enabled_cluster]) }
end
- context 'when scope is inactive' do
+ context "when scope is inactive" do
let(:scope) { :inactive }
it { is_expected.to match_array([disabled_cluster]) }
diff --git a/spec/finders/concerns/finder_methods_spec.rb b/spec/finders/concerns/finder_methods_spec.rb
index e074e53c2c5..9a9a3fa9cba 100644
--- a/spec/finders/concerns/finder_methods_spec.rb
+++ b/spec/finders/concerns/finder_methods_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe FinderMethods do
let(:finder_class) do
@@ -26,20 +26,20 @@ describe FinderMethods do
authorized_project.add_developer(user)
end
- describe '#find_by!' do
- it 'returns the project if the user has access' do
+ describe "#find_by!" do
+ it "returns the project if the user has access" do
expect(finder.find_by!(id: authorized_project.id)).to eq(authorized_project)
end
- it 'raises not found when the project is not found' do
+ it "raises not found when the project is not found" do
expect { finder.find_by!(id: 0) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises not found the user does not have access' do
+ it "raises not found the user does not have access" do
expect { finder.find_by!(id: unauthorized_project.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'ignores ordering' do
+ it "ignores ordering" do
# Memoise the finder result so we can add message expectations to it
relation = finder.execute
allow(finder).to receive(:execute).and_return(relation)
@@ -50,34 +50,34 @@ describe FinderMethods do
end
end
- describe '#find' do
- it 'returns the project if the user has access' do
+ describe "#find" do
+ it "returns the project if the user has access" do
expect(finder.find(authorized_project.id)).to eq(authorized_project)
end
- it 'raises not found when the project is not found' do
+ it "raises not found when the project is not found" do
expect { finder.find(0) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises not found the user does not have access' do
+ it "raises not found the user does not have access" do
expect { finder.find(unauthorized_project.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- describe '#find_by' do
- it 'returns the project if the user has access' do
+ describe "#find_by" do
+ it "returns the project if the user has access" do
expect(finder.find_by(id: authorized_project.id)).to eq(authorized_project)
end
- it 'returns nil when the project is not found' do
+ it "returns nil when the project is not found" do
expect(finder.find_by(id: 0)).to be_nil
end
- it 'returns nil when the user does not have access' do
+ it "returns nil when the user does not have access" do
expect(finder.find_by(id: unauthorized_project.id)).to be_nil
end
- it 'ignores ordering' do
+ it "ignores ordering" do
# Memoise the finder result so we can add message expectations to it
relation = finder.execute
allow(finder).to receive(:execute).and_return(relation)
diff --git a/spec/finders/concerns/finder_with_cross_project_access_spec.rb b/spec/finders/concerns/finder_with_cross_project_access_spec.rb
index f29acb521a8..0596497e6ca 100644
--- a/spec/finders/concerns/finder_with_cross_project_access_spec.rb
+++ b/spec/finders/concerns/finder_with_cross_project_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe FinderWithCrossProjectAccess do
let(:finder_class) do
@@ -33,68 +33,72 @@ describe FinderWithCrossProjectAccess do
expect(Ability).to receive(:allowed?).with(user, :read_issue, result).and_call_original
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :read_cross_project)
- .and_return(false)
+ .and_return(false)
end
- describe '#execute' do
- it 'returns a issue if the check is disabled' do
+ describe "#execute" do
+ it "returns a issue if the check is disabled" do
expect(finder).to receive(:requires_access?).and_return(false)
expect(finder.execute).to include(result)
end
- it 'returns an empty relation when the check is enabled' do
+ it "returns an empty relation when the check is enabled" do
expect(finder).to receive(:requires_access?).and_return(true)
expect(finder.execute).to be_empty
end
- it 'only queries once when check is enabled' do
+ it "only queries once when check is enabled" do
expect(finder).to receive(:requires_access?).and_return(true)
expect { finder.execute }.not_to exceed_query_limit(1)
end
- it 'only queries once when check is disabled' do
+ it "only queries once when check is disabled" do
expect(finder).to receive(:requires_access?).and_return(false)
expect { finder.execute }.not_to exceed_query_limit(1)
end
end
- describe '#find' do
- it 'checks the accessibility of the subject directly' do
+ describe "#find" do
+ it "checks the accessibility of the subject directly" do
expect_access_check_on_result
finder.find(result.id)
end
- it 'returns the issue' do
+ it "returns the issue" do
expect(finder.find(result.id)).to eq(result)
end
end
- describe '#find_by' do
- it 'checks the accessibility of the subject directly' do
+ describe "#find_by" do
+ it "checks the accessibility of the subject directly" do
expect_access_check_on_result
finder.find_by(id: result.id)
end
end
- describe '#find_by!' do
- it 'checks the accessibility of the subject directly' do
+ describe "#find_by!" do
+ it "checks the accessibility of the subject directly" do
expect_access_check_on_result
finder.find_by!(id: result.id)
end
- it 're-enables the check after the find failed' do
- finder.find_by!(id: 9999) rescue ActiveRecord::RecordNotFound
+ it "re-enables the check after the find failed" do
+ begin
+ finder.find_by!(id: 9999)
+ rescue
+ ActiveRecord::RecordNotFound
+ end
expect(finder.instance_variable_get(:@should_skip_cross_project_check))
.to eq(false)
@@ -102,21 +106,21 @@ describe FinderWithCrossProjectAccess do
end
end
- context 'when the user can read cross project' do
+ context "when the user can read cross project" do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :read_cross_project)
- .and_return(true)
+ .and_return(true)
end
- it 'returns the result' do
+ it "returns the result" do
expect(finder).not_to receive(:requires_access?)
expect(finder.execute).to include(result)
end
end
- context 'when specifying a model' do
+ context "when specifying a model" do
let(:finder_class) do
Class.new do
prepend FinderWithCrossProjectAccess
@@ -125,8 +129,8 @@ describe FinderWithCrossProjectAccess do
end
end
- context '.finder_model' do
- it 'is set correctly' do
+ context ".finder_model" do
+ it "is set correctly" do
expect(finder_class.finder_model).to eq(Project)
end
end
diff --git a/spec/finders/contributed_projects_finder_spec.rb b/spec/finders/contributed_projects_finder_spec.rb
index ee84fd067d4..b018fb954b2 100644
--- a/spec/finders/contributed_projects_finder_spec.rb
+++ b/spec/finders/contributed_projects_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ContributedProjectsFinder do
let(:source_user) { create(:user) }
@@ -20,20 +20,20 @@ describe ContributedProjectsFinder do
create(:push_event, project: internal_project, author: source_user)
end
- describe 'activity without a current user' do
+ describe "activity without a current user" do
subject { finder.execute }
it { is_expected.to match_array([public_project]) }
end
- describe 'activity with a current user' do
+ describe "activity with a current user" do
subject { finder.execute(current_user) }
it { is_expected.to match_array([private_project, internal_project, public_project]) }
end
- context 'user with private profile' do
- it 'does not return contributed projects' do
+ context "user with private profile" do
+ it "does not return contributed projects" do
private_user = create(:user, private_profile: true)
public_project.add_maintainer(private_user)
create(:push_event, project: public_project, author: private_user)
diff --git a/spec/finders/environments_finder_spec.rb b/spec/finders/environments_finder_spec.rb
index 25835bb4d94..cb042abc6d1 100644
--- a/spec/finders/environments_finder_spec.rb
+++ b/spec/finders/environments_finder_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentsFinder do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project, :repository) }
let(:user) { project.creator }
let(:environment) { create(:environment, project: project) }
@@ -10,98 +10,98 @@ describe EnvironmentsFinder do
project.add_maintainer(user)
end
- context 'tagged deployment' do
+ context "tagged deployment" do
before do
- create(:deployment, :success, environment: environment, ref: 'v1.1.0', tag: true, sha: project.commit.id)
+ create(:deployment, :success, environment: environment, ref: "v1.1.0", tag: true, sha: project.commit.id)
end
- it 'returns environment when with_tags is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit, with_tags: true).execute)
+ it "returns environment when with_tags is set" do
+ expect(described_class.new(project, user, ref: "master", commit: project.commit, with_tags: true).execute)
.to contain_exactly(environment)
end
- it 'does not return environment when no with_tags is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute)
+ it "does not return environment when no with_tags is set" do
+ expect(described_class.new(project, user, ref: "master", commit: project.commit).execute)
.to be_empty
end
- it 'does not return environment when commit is not part of deployment' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute)
+ it "does not return environment when commit is not part of deployment" do
+ expect(described_class.new(project, user, ref: "master", commit: project.commit("feature")).execute)
.to be_empty
end
end
- context 'branch deployment' do
+ context "branch deployment" do
before do
- create(:deployment, :success, environment: environment, ref: 'master', sha: project.commit.id)
+ create(:deployment, :success, environment: environment, ref: "master", sha: project.commit.id)
end
- it 'returns environment when ref is set' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit).execute)
+ it "returns environment when ref is set" do
+ expect(described_class.new(project, user, ref: "master", commit: project.commit).execute)
.to contain_exactly(environment)
end
- it 'does not environment when ref is different' do
- expect(described_class.new(project, user, ref: 'feature', commit: project.commit).execute)
+ it "does not environment when ref is different" do
+ expect(described_class.new(project, user, ref: "feature", commit: project.commit).execute)
.to be_empty
end
- it 'does not return environment when commit is not part of deployment' do
- expect(described_class.new(project, user, ref: 'master', commit: project.commit('feature')).execute)
+ it "does not return environment when commit is not part of deployment" do
+ expect(described_class.new(project, user, ref: "master", commit: project.commit("feature")).execute)
.to be_empty
end
- it 'returns environment when commit constraint is not set' do
- expect(described_class.new(project, user, ref: 'master').execute)
+ it "returns environment when commit constraint is not set" do
+ expect(described_class.new(project, user, ref: "master").execute)
.to contain_exactly(environment)
end
end
- context 'commit deployment' do
+ context "commit deployment" do
before do
- create(:deployment, :success, environment: environment, ref: 'master', sha: project.commit.id)
+ create(:deployment, :success, environment: environment, ref: "master", sha: project.commit.id)
end
- it 'returns environment' do
+ it "returns environment" do
expect(described_class.new(project, user, commit: project.commit).execute)
.to contain_exactly(environment)
end
end
- context 'recently updated' do
- context 'when last deployment to environment is the most recent one' do
+ context "recently updated" do
+ context "when last deployment to environment is the most recent one" do
before do
- create(:deployment, :success, environment: environment, ref: 'feature')
+ create(:deployment, :success, environment: environment, ref: "feature")
end
- it 'finds recently updated environment' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ it "finds recently updated environment" do
+ expect(described_class.new(project, user, ref: "feature", recently_updated: true).execute)
.to contain_exactly(environment)
end
end
- context 'when last deployment to environment is not the most recent' do
+ context "when last deployment to environment is not the most recent" do
before do
- create(:deployment, :success, environment: environment, ref: 'feature')
- create(:deployment, :success, environment: environment, ref: 'master')
+ create(:deployment, :success, environment: environment, ref: "feature")
+ create(:deployment, :success, environment: environment, ref: "master")
end
- it 'does not find environment' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ it "does not find environment" do
+ expect(described_class.new(project, user, ref: "feature", recently_updated: true).execute)
.to be_empty
end
end
- context 'when there are two environments that deploy to the same branch' do
+ context "when there are two environments that deploy to the same branch" do
let(:second_environment) { create(:environment, project: project) }
before do
- create(:deployment, :success, environment: environment, ref: 'feature')
- create(:deployment, :success, environment: second_environment, ref: 'feature')
+ create(:deployment, :success, environment: environment, ref: "feature")
+ create(:deployment, :success, environment: second_environment, ref: "feature")
end
- it 'finds both environments' do
- expect(described_class.new(project, user, ref: 'feature', recently_updated: true).execute)
+ it "finds both environments" do
+ expect(described_class.new(project, user, ref: "feature", recently_updated: true).execute)
.to contain_exactly(environment, second_environment)
end
end
diff --git a/spec/finders/events_finder_spec.rb b/spec/finders/events_finder_spec.rb
index 3bce46cc4d1..0dc30d497df 100644
--- a/spec/finders/events_finder_spec.rb
+++ b/spec/finders/events_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe EventsFinder do
let(:user) { create(:user) }
@@ -18,33 +18,33 @@ describe EventsFinder do
let(:confidential_issue) { create(:closed_issue, confidential: true, project: public_project, author: user) }
let!(:confidential_event) { create(:event, project: public_project, author: user, target: confidential_issue, action: Event::CLOSED) }
- context 'when targeting a user' do
- it 'returns events between specified dates filtered on action and type' do
- events = described_class.new(source: user, current_user: user, action: 'created', target_type: 'merge_request', after: Date.new(2017, 1, 1), before: Date.new(2017, 2, 1)).execute
+ context "when targeting a user" do
+ it "returns events between specified dates filtered on action and type" do
+ events = described_class.new(source: user, current_user: user, action: "created", target_type: "merge_request", after: Date.new(2017, 1, 1), before: Date.new(2017, 2, 1)).execute
expect(events).to eq([opened_merge_request_event])
end
- it 'does not return events the current_user does not have access to' do
+ it "does not return events the current_user does not have access to" do
events = described_class.new(source: user, current_user: other_user).execute
expect(events).not_to include(opened_merge_request_event)
end
- it 'does not include events on confidential issues the user does not have access to' do
+ it "does not include events on confidential issues the user does not have access to" do
events = described_class.new(source: user, current_user: other_user).execute
expect(events).not_to include(confidential_event)
end
- it 'includes confidential events user has access to' do
+ it "includes confidential events user has access to" do
public_project.add_developer(other_user)
events = described_class.new(source: user, current_user: other_user).execute
expect(events).to include(confidential_event)
end
- it 'returns nothing when the current user cannot read cross project' do
+ it "returns nothing when the current user cannot read cross project" do
expect(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
events = described_class.new(source: user, current_user: user).execute
@@ -53,14 +53,14 @@ describe EventsFinder do
end
end
- context 'when targeting a project' do
- it 'returns project events between specified dates filtered on action and type' do
- events = described_class.new(source: project1, current_user: user, action: 'closed', target_type: 'issue', after: Date.new(2016, 12, 1), before: Date.new(2017, 1, 1)).execute
+ context "when targeting a project" do
+ it "returns project events between specified dates filtered on action and type" do
+ events = described_class.new(source: project1, current_user: user, action: "closed", target_type: "issue", after: Date.new(2016, 12, 1), before: Date.new(2017, 1, 1)).execute
expect(events).to eq([closed_issue_event])
end
- it 'does not return events the current_user does not have access to' do
+ it "does not return events the current_user does not have access to" do
events = described_class.new(source: project2, current_user: other_user).execute
expect(events).to be_empty
diff --git a/spec/finders/fork_projects_finder_spec.rb b/spec/finders/fork_projects_finder_spec.rb
index b3fdffc3331..df1b39eb966 100644
--- a/spec/finders/fork_projects_finder_spec.rb
+++ b/spec/finders/fork_projects_finder_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe ForkProjectsFinder do
include ProjectForksHelper
let(:source_project) { create(:project, :public, :empty_repo) }
- let(:private_fork) { fork_project(source_project, nil, name: 'A') }
- let(:internal_fork) { fork_project(source_project, nil, name: 'B') }
- let(:public_fork) { fork_project(source_project, nil, name: 'C') }
+ let(:private_fork) { fork_project(source_project, nil, name: "A") }
+ let(:internal_fork) { fork_project(source_project, nil, name: "B") }
+ let(:public_fork) { fork_project(source_project, nil, name: "C") }
let(:non_member) { create(:user) }
let(:private_fork_member) { create(:user) }
@@ -18,24 +18,24 @@ describe ForkProjectsFinder do
internal_fork.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- describe '#execute' do
+ describe "#execute" do
let(:finder) { described_class.new(source_project, params: {}, current_user: current_user) }
subject { finder.execute }
- describe 'without a user' do
+ describe "without a user" do
let(:current_user) { nil }
it { is_expected.to eq([public_fork]) }
end
- describe 'with a user' do
+ describe "with a user" do
let(:current_user) { non_member }
it { is_expected.to eq([public_fork, internal_fork]) }
end
- describe 'with a member' do
+ describe "with a member" do
let(:current_user) { private_fork_member }
it { is_expected.to eq([public_fork, internal_fork, private_fork]) }
diff --git a/spec/finders/group_descendants_finder_spec.rb b/spec/finders/group_descendants_finder_spec.rb
index c28fd7cad11..be08a64a5b2 100644
--- a/spec/finders/group_descendants_finder_spec.rb
+++ b/spec/finders/group_descendants_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupDescendantsFinder do
let(:user) { create(:user) }
@@ -12,15 +12,15 @@ describe GroupDescendantsFinder do
group.add_owner(user)
end
- describe '#has_children?' do
- it 'is true when there are projects' do
+ describe "#has_children?" do
+ it "is true when there are projects" do
create(:project, namespace: group)
expect(finder.has_children?).to be_truthy
end
- context 'when there are subgroups', :nested_groups do
- it 'is true when there are projects' do
+ context "when there are subgroups", :nested_groups do
+ it "is true when there are projects" do
create(:group, parent: group)
expect(finder.has_children?).to be_truthy
@@ -28,17 +28,17 @@ describe GroupDescendantsFinder do
end
end
- describe '#execute' do
- it 'includes projects' do
+ describe "#execute" do
+ it "includes projects" do
project = create(:project, namespace: group)
expect(finder.execute).to contain_exactly(project)
end
- context 'when archived is `true`' do
- let(:params) { { archived: 'true' } }
+ context "when archived is `true`" do
+ let(:params) { {archived: "true"} }
- it 'includes archived projects' do
+ it "includes archived projects" do
archived_project = create(:project, namespace: group, archived: true)
project = create(:project, namespace: group)
@@ -46,10 +46,10 @@ describe GroupDescendantsFinder do
end
end
- context 'when archived is `only`' do
- let(:params) { { archived: 'only' } }
+ context "when archived is `only`" do
+ let(:params) { {archived: "only"} }
- it 'includes only archived projects' do
+ it "includes only archived projects" do
archived_project = create(:project, namespace: group, archived: true)
_project = create(:project, namespace: group)
@@ -57,66 +57,66 @@ describe GroupDescendantsFinder do
end
end
- it 'does not include archived projects' do
+ it "does not include archived projects" do
_archived_project = create(:project, :archived, namespace: group)
expect(finder.execute).to be_empty
end
- context 'with a filter' do
- let(:params) { { filter: 'test' } }
+ context "with a filter" do
+ let(:params) { {filter: "test"} }
- it 'includes only projects matching the filter' do
+ it "includes only projects matching the filter" do
_other_project = create(:project, namespace: group)
- matching_project = create(:project, namespace: group, name: 'testproject')
+ matching_project = create(:project, namespace: group, name: "testproject")
expect(finder.execute).to contain_exactly(matching_project)
end
end
- it 'sorts elements by latest created as default' do
+ it "sorts elements by latest created as default" do
project1 = create(:project, namespace: group, created_at: 1.hour.ago)
project2 = create(:project, namespace: group)
expect(subject.execute).to eq([project2, project1])
end
- context 'sorting by name' do
- let!(:project1) { create(:project, namespace: group, name: 'a', path: 'project-a') }
- let!(:project2) { create(:project, namespace: group, name: 'z', path: 'project-z') }
+ context "sorting by name" do
+ let!(:project1) { create(:project, namespace: group, name: "a", path: "project-a") }
+ let!(:project2) { create(:project, namespace: group, name: "z", path: "project-z") }
let(:params) do
{
- sort: 'name_asc'
+ sort: "name_asc",
}
end
- it 'sorts elements by name' do
+ it "sorts elements by name" do
expect(subject.execute).to eq(
[
project1,
- project2
+ project2,
]
)
end
- context 'with nested groups', :nested_groups do
- let!(:subgroup1) { create(:group, parent: group, name: 'a', path: 'sub-a') }
- let!(:subgroup2) { create(:group, parent: group, name: 'z', path: 'sub-z') }
+ context "with nested groups", :nested_groups do
+ let!(:subgroup1) { create(:group, parent: group, name: "a", path: "sub-a") }
+ let!(:subgroup2) { create(:group, parent: group, name: "z", path: "sub-z") }
- it 'sorts elements by name' do
+ it "sorts elements by name" do
expect(subject.execute).to eq(
[
subgroup1,
subgroup2,
project1,
- project2
+ project2,
]
)
end
end
end
- it 'does not include projects shared with the group' do
+ it "does not include projects shared with the group" do
project = create(:project, namespace: group)
other_project = create(:project)
other_project.project_group_links.create(group: group,
@@ -126,20 +126,20 @@ describe GroupDescendantsFinder do
end
end
- context 'with nested groups', :nested_groups do
+ context "with nested groups", :nested_groups do
let!(:project) { create(:project, namespace: group) }
let!(:subgroup) { create(:group, :private, parent: group) }
- describe '#execute' do
- it 'contains projects and subgroups' do
+ describe "#execute" do
+ it "contains projects and subgroups" do
expect(finder.execute).to contain_exactly(subgroup, project)
end
- it 'does not include subgroups the user does not have access to' do
+ it "does not include subgroups the user does not have access to" do
subgroup.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- public_subgroup = create(:group, :public, parent: group, path: 'public-group')
- other_subgroup = create(:group, :private, parent: group, path: 'visible-private-group')
+ public_subgroup = create(:group, :public, parent: group, path: "public-group")
+ other_subgroup = create(:group, :private, parent: group, path: "visible-private-group")
other_user = create(:user)
other_subgroup.add_developer(other_user)
@@ -148,7 +148,7 @@ describe GroupDescendantsFinder do
expect(finder.execute).to contain_exactly(public_subgroup, other_subgroup)
end
- it 'only includes public groups when no user is given' do
+ it "only includes public groups when no user is given" do
public_subgroup = create(:group, :public, parent: group)
_private_subgroup = create(:group, :private, parent: group)
@@ -157,31 +157,31 @@ describe GroupDescendantsFinder do
expect(finder.execute).to contain_exactly(public_subgroup)
end
- context 'when archived is `true`' do
- let(:params) { { archived: 'true' } }
+ context "when archived is `true`" do
+ let(:params) { {archived: "true"} }
- it 'includes archived projects in the count of subgroups' do
+ it "includes archived projects in the count of subgroups" do
create(:project, namespace: subgroup, archived: true)
expect(finder.execute.first.preloaded_project_count).to eq(1)
end
end
- context 'with a filter' do
- let(:params) { { filter: 'test' } }
+ context "with a filter" do
+ let(:params) { {filter: "test"} }
- it 'contains only matching projects and subgroups' do
- matching_project = create(:project, namespace: group, name: 'Testproject')
- matching_subgroup = create(:group, name: 'testgroup', parent: group)
+ it "contains only matching projects and subgroups" do
+ matching_project = create(:project, namespace: group, name: "Testproject")
+ matching_subgroup = create(:group, name: "testgroup", parent: group)
expect(finder.execute).to contain_exactly(matching_subgroup, matching_project)
end
- it 'does not include subgroups the user does not have access to' do
- _invisible_subgroup = create(:group, :private, parent: group, name: 'test1')
- other_subgroup = create(:group, :private, parent: group, name: 'test2')
- public_subgroup = create(:group, :public, parent: group, name: 'test3')
- other_subsubgroup = create(:group, :private, parent: other_subgroup, name: 'test4')
+ it "does not include subgroups the user does not have access to" do
+ _invisible_subgroup = create(:group, :private, parent: group, name: "test1")
+ other_subgroup = create(:group, :private, parent: group, name: "test2")
+ public_subgroup = create(:group, :public, parent: group, name: "test3")
+ other_subsubgroup = create(:group, :private, parent: other_subgroup, name: "test4")
other_user = create(:user)
other_subgroup.add_developer(other_user)
@@ -192,32 +192,32 @@ describe GroupDescendantsFinder do
expect(finder.execute).to contain_exactly(other_subgroup, public_subgroup, other_subsubgroup)
end
- context 'with matching children' do
- it 'includes a group that has a subgroup matching the query and its parent' do
- matching_subgroup = create(:group, :private, name: 'testgroup', parent: subgroup)
+ context "with matching children" do
+ it "includes a group that has a subgroup matching the query and its parent" do
+ matching_subgroup = create(:group, :private, name: "testgroup", parent: subgroup)
expect(finder.execute).to contain_exactly(subgroup, matching_subgroup)
end
- it 'includes the parent of a matching project' do
- matching_project = create(:project, namespace: subgroup, name: 'Testproject')
+ it "includes the parent of a matching project" do
+ matching_project = create(:project, namespace: subgroup, name: "Testproject")
expect(finder.execute).to contain_exactly(subgroup, matching_project)
end
- context 'with a small page size' do
- let(:params) { { filter: 'test', per_page: 1 } }
+ context "with a small page size" do
+ let(:params) { {filter: "test", per_page: 1} }
- it 'contains all the ancestors of a matching subgroup regardless the page size' do
+ it "contains all the ancestors of a matching subgroup regardless the page size" do
subgroup = create(:group, :private, parent: group)
- matching = create(:group, :private, name: 'testgroup', parent: subgroup)
+ matching = create(:group, :private, name: "testgroup", parent: subgroup)
expect(finder.execute).to contain_exactly(subgroup, matching)
end
end
- it 'does not include the parent itself' do
- group.update!(name: 'test')
+ it "does not include the parent itself" do
+ group.update!(name: "test")
expect(finder.execute).not_to include(group)
end
diff --git a/spec/finders/group_labels_finder_spec.rb b/spec/finders/group_labels_finder_spec.rb
index 7bdd312eff0..c40af861ec1 100644
--- a/spec/finders/group_labels_finder_spec.rb
+++ b/spec/finders/group_labels_finder_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe GroupLabelsFinder, '#execute' do
+describe GroupLabelsFinder, "#execute" do
let!(:group) { create(:group) }
let!(:user) { create(:user) }
- let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) }
- let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) }
+ let!(:label1) { create(:group_label, title: "Foo", description: "Lorem ipsum", group: group) }
+ let!(:label2) { create(:group_label, title: "Bar", description: "Fusce consequat", group: group) }
- it 'returns all group labels sorted by name if no params' do
+ it "returns all group labels sorted by name if no params" do
result = described_class.new(user, group).execute
expect(result.to_a).to match_array([label2, label1])
end
- it 'returns all group labels sorted by name desc' do
- result = described_class.new(user, group, sort: 'name_desc').execute
+ it "returns all group labels sorted by name desc" do
+ result = described_class.new(user, group, sort: "name_desc").execute
expect(result.to_a).to match_array([label2, label1])
end
- it 'returns group labels that match search' do
- result = described_class.new(user, group, search: 'Foo').execute
+ it "returns group labels that match search" do
+ result = described_class.new(user, group, search: "Foo").execute
expect(result.to_a).to match_array([label1])
end
- it 'returns group labels user subscribed to' do
+ it "returns group labels user subscribed to" do
label2.subscribe(user)
- result = described_class.new(user, group, subscribed: 'true').execute
+ result = described_class.new(user, group, subscribed: "true").execute
expect(result.to_a).to match_array([label2])
end
- it 'returns second page of labels' do
- result = described_class.new(user, group, page: '2').execute
+ it "returns second page of labels" do
+ result = described_class.new(user, group, page: "2").execute
expect(result.to_a).to match_array([])
end
diff --git a/spec/finders/group_members_finder_spec.rb b/spec/finders/group_members_finder_spec.rb
index 8975ea0f063..856e2599107 100644
--- a/spec/finders/group_members_finder_spec.rb
+++ b/spec/finders/group_members_finder_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe GroupMembersFinder, '#execute' do
+describe GroupMembersFinder, "#execute" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, :access_requestable, parent: group) }
let(:user1) { create(:user) }
@@ -8,7 +8,7 @@ describe GroupMembersFinder, '#execute' do
let(:user3) { create(:user) }
let(:user4) { create(:user) }
- it 'returns members for top-level group' do
+ it "returns members for top-level group" do
member1 = group.add_maintainer(user1)
member2 = group.add_maintainer(user2)
member3 = group.add_maintainer(user3)
@@ -18,7 +18,7 @@ describe GroupMembersFinder, '#execute' do
expect(result.to_a).to match_array([member3, member2, member1])
end
- it 'returns members for nested group', :nested_groups do
+ it "returns members for nested group", :nested_groups do
group.add_developer(user2)
nested_group.request_access(user4)
member1 = group.add_maintainer(user1)
@@ -30,7 +30,7 @@ describe GroupMembersFinder, '#execute' do
expect(result.to_a).to match_array([member1, member3, member4])
end
- it 'returns members for descendant groups if requested', :nested_groups do
+ it "returns members for descendant groups if requested", :nested_groups do
member1 = group.add_maintainer(user2)
member2 = group.add_maintainer(user1)
nested_group.add_maintainer(user2)
diff --git a/spec/finders/group_projects_finder_spec.rb b/spec/finders/group_projects_finder_spec.rb
index d6d95906f5e..e05ead88a9f 100644
--- a/spec/finders/group_projects_finder_spec.rb
+++ b/spec/finders/group_projects_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupProjectsFinder do
let(:group) { create(:group) }
@@ -8,13 +8,13 @@ describe GroupProjectsFinder do
let(:finder) { described_class.new(group: group, current_user: current_user, options: options) }
- let!(:public_project) { create(:project, :public, group: group, path: '1') }
- let!(:private_project) { create(:project, :private, group: group, path: '2') }
- let!(:shared_project_1) { create(:project, :public, path: '3') }
- let!(:shared_project_2) { create(:project, :private, path: '4') }
- let!(:shared_project_3) { create(:project, :internal, path: '5') }
- let!(:subgroup_project) { create(:project, :public, path: '6', group: subgroup) }
- let!(:subgroup_private_project) { create(:project, :private, path: '7', group: subgroup) }
+ let!(:public_project) { create(:project, :public, group: group, path: "1") }
+ let!(:private_project) { create(:project, :private, group: group, path: "2") }
+ let!(:shared_project_1) { create(:project, :public, path: "3") }
+ let!(:shared_project_2) { create(:project, :private, path: "4") }
+ let!(:shared_project_3) { create(:project, :internal, path: "5") }
+ let!(:subgroup_project) { create(:project, :public, path: "6", group: subgroup) }
+ let!(:subgroup_private_project) { create(:project, :private, path: "7", group: subgroup) }
before do
shared_project_1.project_group_links.create(group_access: Gitlab::Access::MAINTAINER, group: group)
@@ -24,21 +24,21 @@ describe GroupProjectsFinder do
subject { finder.execute }
- describe 'with a group member current user' do
+ describe "with a group member current user" do
before do
group.add_maintainer(current_user)
end
context "only shared" do
- let(:options) { { only_shared: true } }
+ let(:options) { {only_shared: true} }
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1]) }
end
context "only owned" do
- let(:options) { { only_owned: true } }
+ let(:options) { {only_owned: true} }
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -46,13 +46,13 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([private_project, public_project, subgroup_project, subgroup_private_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to match_array([private_project, public_project]) }
end
end
context "all" do
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -60,20 +60,20 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, private_project, public_project, subgroup_project, subgroup_private_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, private_project, public_project]) }
end
end
end
- describe 'without group member current_user' do
+ describe "without group member current_user" do
before do
shared_project_2.add_maintainer(current_user)
current_user.reload
end
context "only shared" do
- let(:options) { { only_shared: true } }
+ let(:options) { {only_shared: true} }
context "without external user" do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1]) }
@@ -89,7 +89,7 @@ describe GroupProjectsFinder do
end
context "only owned" do
- let(:options) { { only_owned: true } }
+ let(:options) { {only_owned: true} }
context "without external user" do
before do
@@ -97,7 +97,7 @@ describe GroupProjectsFinder do
subgroup_private_project.add_maintainer(current_user)
end
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -105,7 +105,7 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([private_project, public_project, subgroup_project, subgroup_private_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to match_array([private_project, public_project]) }
end
end
@@ -115,7 +115,7 @@ describe GroupProjectsFinder do
current_user.update(external: true)
end
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -123,14 +123,14 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([public_project, subgroup_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to eq([public_project]) }
end
end
end
context "all" do
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -138,7 +138,7 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, public_project, subgroup_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to match_array([shared_project_3, shared_project_2, shared_project_1, public_project]) }
end
end
@@ -146,15 +146,15 @@ describe GroupProjectsFinder do
describe "no user" do
context "only shared" do
- let(:options) { { only_shared: true } }
+ let(:options) { {only_shared: true} }
it { is_expected.to match_array([shared_project_3, shared_project_1]) }
end
context "only owned" do
- let(:options) { { only_owned: true } }
+ let(:options) { {only_owned: true} }
- context 'with subgroups projects', :nested_groups do
+ context "with subgroups projects", :nested_groups do
before do
options[:include_subgroups] = true
end
@@ -162,7 +162,7 @@ describe GroupProjectsFinder do
it { is_expected.to match_array([public_project, subgroup_project]) }
end
- context 'without subgroups projects' do
+ context "without subgroups projects" do
it { is_expected.to eq([public_project]) }
end
end
diff --git a/spec/finders/groups_finder_spec.rb b/spec/finders/groups_finder_spec.rb
index 367ca43bdfe..5c8bb8f344c 100644
--- a/spec/finders/groups_finder_spec.rb
+++ b/spec/finders/groups_finder_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupsFinder do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
- describe 'root level groups' do
+ describe "root level groups" do
using RSpec::Parameterized::TableSyntax
where(:user_type, :params, :results) do
- nil | { all_available: true } | %i(public_group user_public_group)
- nil | { all_available: false } | %i(public_group user_public_group)
- nil | {} | %i(public_group user_public_group)
-
- :regular | { all_available: true } | %i(public_group internal_group user_public_group user_internal_group
- user_private_group)
- :regular | { all_available: false } | %i(user_public_group user_internal_group user_private_group)
- :regular | {} | %i(public_group internal_group user_public_group user_internal_group user_private_group)
-
- :external | { all_available: true } | %i(public_group user_public_group user_internal_group user_private_group)
- :external | { all_available: false } | %i(user_public_group user_internal_group user_private_group)
- :external | {} | %i(public_group user_public_group user_internal_group user_private_group)
-
- :admin | { all_available: true } | %i(public_group internal_group private_group user_public_group
- user_internal_group user_private_group)
- :admin | { all_available: false } | %i(user_public_group user_internal_group user_private_group)
- :admin | {} | %i(public_group internal_group private_group user_public_group user_internal_group
- user_private_group)
+ nil | {all_available: true} | %i[public_group user_public_group]
+ nil | {all_available: false} | %i[public_group user_public_group]
+ nil | {} | %i[public_group user_public_group]
+
+ :regular | {all_available: true} | %i[public_group internal_group user_public_group user_internal_group
+ user_private_group]
+ :regular | {all_available: false} | %i[user_public_group user_internal_group user_private_group]
+ :regular | {} | %i[public_group internal_group user_public_group user_internal_group user_private_group]
+
+ :external | {all_available: true} | %i[public_group user_public_group user_internal_group user_private_group]
+ :external | {all_available: false} | %i[user_public_group user_internal_group user_private_group]
+ :external | {} | %i[public_group user_public_group user_internal_group user_private_group]
+
+ :admin | {all_available: true} | %i[public_group internal_group private_group user_public_group
+ user_internal_group user_private_group]
+ :admin | {all_available: false} | %i[user_public_group user_internal_group user_private_group]
+ :admin | {} | %i[public_group internal_group private_group user_public_group user_internal_group
+ user_private_group]
end
with_them do
@@ -34,13 +34,13 @@ describe GroupsFinder do
# The groups need to be created here, not with let syntax, and also compared by name and not ids
@groups = {
- private_group: create(:group, :private, name: 'private_group'),
- internal_group: create(:group, :internal, name: 'internal_group'),
- public_group: create(:group, :public, name: 'public_group'),
+ private_group: create(:group, :private, name: "private_group"),
+ internal_group: create(:group, :internal, name: "internal_group"),
+ public_group: create(:group, :public, name: "public_group"),
- user_private_group: create(:group, :private, name: 'user_private_group'),
- user_internal_group: create(:group, :internal, name: 'user_internal_group'),
- user_public_group: create(:group, :public, name: 'user_public_group')
+ user_private_group: create(:group, :private, name: "user_private_group"),
+ user_internal_group: create(:group, :internal, name: "user_internal_group"),
+ user_public_group: create(:group, :public, name: "user_public_group"),
}
if user_type
@@ -65,77 +65,77 @@ describe GroupsFinder do
end
end
- context 'subgroups', :nested_groups do
+ context "subgroups", :nested_groups do
let(:user) { create(:user) }
let!(:parent_group) { create(:group, :public) }
let!(:public_subgroup) { create(:group, :public, parent: parent_group) }
let!(:internal_subgroup) { create(:group, :internal, parent: parent_group) }
let!(:private_subgroup) { create(:group, :private, parent: parent_group) }
- context 'without a user' do
- it 'only returns parent and public subgroups' do
+ context "without a user" do
+ it "only returns parent and public subgroups" do
expect(described_class.new(nil).execute).to contain_exactly(parent_group, public_subgroup)
end
end
- context 'with a user' do
+ context "with a user" do
subject { described_class.new(user).execute }
- it 'returns parent, public, and internal subgroups' do
+ it "returns parent, public, and internal subgroups" do
is_expected.to contain_exactly(parent_group, public_subgroup, internal_subgroup)
end
- context 'being member' do
- it 'returns parent, public subgroups, internal subgroups, and private subgroups user is member of' do
+ context "being member" do
+ it "returns parent, public subgroups, internal subgroups, and private subgroups user is member of" do
private_subgroup.add_guest(user)
is_expected.to contain_exactly(parent_group, public_subgroup, internal_subgroup, private_subgroup)
end
end
- context 'parent group private' do
+ context "parent group private" do
before do
parent_group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end
- context 'being member of parent group' do
- it 'returns all subgroups' do
+ context "being member of parent group" do
+ it "returns all subgroups" do
parent_group.add_guest(user)
is_expected.to contain_exactly(parent_group, public_subgroup, internal_subgroup, private_subgroup)
end
end
- context 'authorized to private project' do
- context 'project one level deep' do
+ context "authorized to private project" do
+ context "project one level deep" do
let!(:subproject) { create(:project, :private, namespace: private_subgroup) }
before do
subproject.add_guest(user)
end
- it 'includes the subgroup of the project' do
+ it "includes the subgroup of the project" do
is_expected.to include(private_subgroup)
end
- it 'does not include private subgroups deeper down' do
+ it "does not include private subgroups deeper down" do
subsubgroup = create(:group, :private, parent: private_subgroup)
is_expected.not_to include(subsubgroup)
end
end
- context 'project two levels deep' do
+ context "project two levels deep" do
let!(:private_subsubgroup) { create(:group, :private, parent: private_subgroup) }
let!(:subsubproject) { create(:project, :private, namespace: private_subsubgroup) }
before do
subsubproject.add_guest(user)
end
- it 'returns all the ancestor groups' do
+ it "returns all the ancestor groups" do
is_expected.to include(private_subsubgroup, private_subgroup, parent_group)
end
- it 'returns the groups for a given parent' do
+ it "returns the groups for a given parent" do
expect(described_class.new(user, parent: parent_group).execute).to include(private_subgroup)
end
end
diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb
index 47e2548c3d6..f25ac2a47b6 100644
--- a/spec/finders/issues_finder_spec.rb
+++ b/spec/finders/issues_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IssuesFinder do
set(:user) { create(:user) }
@@ -10,20 +10,20 @@ describe IssuesFinder do
set(:project3) { create(:project, group: subgroup) }
set(:milestone) { create(:milestone, project: project1) }
set(:label) { create(:label, project: project2) }
- set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: 'gitlab', created_at: 1.week.ago, updated_at: 1.week.ago) }
- set(:issue2) { create(:issue, author: user, assignees: [user], project: project2, description: 'gitlab', created_at: 1.week.from_now, updated_at: 1.week.from_now) }
- set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: 'tanuki', description: 'tanuki', created_at: 2.weeks.from_now, updated_at: 2.weeks.from_now) }
+ set(:issue1) { create(:issue, author: user, assignees: [user], project: project1, milestone: milestone, title: "gitlab", created_at: 1.week.ago, updated_at: 1.week.ago) }
+ set(:issue2) { create(:issue, author: user, assignees: [user], project: project2, description: "gitlab", created_at: 1.week.from_now, updated_at: 1.week.from_now) }
+ set(:issue3) { create(:issue, author: user2, assignees: [user2], project: project2, title: "tanuki", description: "tanuki", created_at: 2.weeks.from_now, updated_at: 2.weeks.from_now) }
set(:issue4) { create(:issue, project: project3) }
- set(:award_emoji1) { create(:award_emoji, name: 'thumbsup', user: user, awardable: issue1) }
- set(:award_emoji2) { create(:award_emoji, name: 'thumbsup', user: user2, awardable: issue2) }
- set(:award_emoji3) { create(:award_emoji, name: 'thumbsdown', user: user, awardable: issue3) }
+ set(:award_emoji1) { create(:award_emoji, name: "thumbsup", user: user, awardable: issue1) }
+ set(:award_emoji2) { create(:award_emoji, name: "thumbsup", user: user2, awardable: issue2) }
+ set(:award_emoji3) { create(:award_emoji, name: "thumbsdown", user: user, awardable: issue3) }
- describe '#execute' do
- let!(:closed_issue) { create(:issue, author: user2, assignees: [user2], project: project2, state: 'closed') }
+ describe "#execute" do
+ let!(:closed_issue) { create(:issue, author: user2, assignees: [user2], project: project2, state: "closed") }
let!(:label_link) { create(:label_link, label: label, target: issue2) }
let(:search_user) { user }
let(:params) { {} }
- let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: 'opened')).execute }
+ let(:issues) { described_class.new(search_user, params.reverse_merge(scope: scope, state: "opened")).execute }
before(:context) do
project1.add_maintainer(user)
@@ -41,96 +41,96 @@ describe IssuesFinder do
award_emoji3
end
- context 'scope: all' do
- let(:scope) { 'all' }
+ context "scope: all" do
+ let(:scope) { "all" }
- it 'returns all issues' do
+ it "returns all issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
end
- context 'filtering by assignee ID' do
- let(:params) { { assignee_id: user.id } }
+ context "filtering by assignee ID" do
+ let(:params) { {assignee_id: user.id} }
- it 'returns issues assigned to that user' do
+ it "returns issues assigned to that user" do
expect(issues).to contain_exactly(issue1, issue2)
end
end
- context 'filtering by no assignee' do
- let(:params) { { assignee_id: 'None' } }
+ context "filtering by no assignee" do
+ let(:params) { {assignee_id: "None"} }
- it 'returns issues not assigned to any assignee' do
+ it "returns issues not assigned to any assignee" do
expect(issues).to contain_exactly(issue4)
end
- it 'returns issues not assigned to any assignee' do
+ it "returns issues not assigned to any assignee" do
params[:assignee_id] = 0
expect(issues).to contain_exactly(issue4)
end
- it 'returns issues not assigned to any assignee' do
- params[:assignee_id] = 'none'
+ it "returns issues not assigned to any assignee" do
+ params[:assignee_id] = "none"
expect(issues).to contain_exactly(issue4)
end
end
- context 'filtering by any assignee' do
- let(:params) { { assignee_id: 'Any' } }
+ context "filtering by any assignee" do
+ let(:params) { {assignee_id: "Any"} }
- it 'returns issues assigned to any assignee' do
+ it "returns issues assigned to any assignee" do
expect(issues).to contain_exactly(issue1, issue2, issue3)
end
- it 'returns issues assigned to any assignee' do
- params[:assignee_id] = 'any'
+ it "returns issues assigned to any assignee" do
+ params[:assignee_id] = "any"
expect(issues).to contain_exactly(issue1, issue2, issue3)
end
end
- context 'filtering by group_id' do
- let(:params) { { group_id: group.id } }
+ context "filtering by group_id" do
+ let(:params) { {group_id: group.id} }
- context 'when include_subgroup param not set' do
- it 'returns all group issues' do
+ context "when include_subgroup param not set" do
+ it "returns all group issues" do
expect(issues).to contain_exactly(issue1)
end
end
- context 'when include_subgroup param is true', :nested_groups do
+ context "when include_subgroup param is true", :nested_groups do
before do
params[:include_subgroups] = true
end
- it 'returns all group and subgroup issues' do
+ it "returns all group and subgroup issues" do
expect(issues).to contain_exactly(issue1, issue4)
end
end
end
- context 'filtering by author ID' do
- let(:params) { { author_id: user2.id } }
+ context "filtering by author ID" do
+ let(:params) { {author_id: user2.id} }
- it 'returns issues created by that user' do
+ it "returns issues created by that user" do
expect(issues).to contain_exactly(issue3)
end
end
- context 'filtering by milestone' do
- let(:params) { { milestone_title: milestone.title } }
+ context "filtering by milestone" do
+ let(:params) { {milestone_title: milestone.title} }
- it 'returns issues assigned to that milestone' do
+ it "returns issues assigned to that milestone" do
expect(issues).to contain_exactly(issue1)
end
end
- context 'filtering by group milestone' do
+ context "filtering by group milestone" do
let!(:group) { create(:group, :public) }
let(:group_milestone) { create(:milestone, group: group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- let(:params) { { milestone_title: group_milestone.title } }
+ let(:params) { {milestone_title: group_milestone.title} }
before do
project2.update(namespace: group)
@@ -138,41 +138,41 @@ describe IssuesFinder do
issue3.update(milestone: group_milestone)
end
- it 'returns issues assigned to that group milestone' do
+ it "returns issues assigned to that group milestone" do
expect(issues).to contain_exactly(issue2, issue3)
end
end
- context 'filtering by no milestone' do
- let(:params) { { milestone_title: 'None' } }
+ context "filtering by no milestone" do
+ let(:params) { {milestone_title: "None"} }
- it 'returns issues with no milestone' do
+ it "returns issues with no milestone" do
expect(issues).to contain_exactly(issue2, issue3, issue4)
end
- it 'returns issues with no milestone (deprecated)' do
+ it "returns issues with no milestone (deprecated)" do
params[:milestone_title] = Milestone::None.title
expect(issues).to contain_exactly(issue2, issue3, issue4)
end
end
- context 'filtering by any milestone' do
- let(:params) { { milestone_title: 'Any' } }
+ context "filtering by any milestone" do
+ let(:params) { {milestone_title: "Any"} }
- it 'returns issues with any assigned milestone' do
+ it "returns issues with any assigned milestone" do
expect(issues).to contain_exactly(issue1)
end
- it 'returns issues with any assigned milestone (deprecated)' do
+ it "returns issues with any assigned milestone (deprecated)" do
params[:milestone_title] = Milestone::Any.title
expect(issues).to contain_exactly(issue1)
end
end
- context 'filtering by upcoming milestone' do
- let(:params) { { milestone_title: Milestone::Upcoming.name } }
+ context "filtering by upcoming milestone" do
+ let(:params) { {milestone_title: Milestone::Upcoming.name} }
let!(:group) { create(:group, :public) }
let!(:group_member) { create(:group_member, group: group, user: user) }
@@ -190,11 +190,11 @@ describe IssuesFinder do
let(:milestones) do
[
create(:milestone, :closed, project: project_no_upcoming_milestones),
- create(:milestone, project: project_next_1_1, title: '1.1', due_date: two_days_from_now),
- create(:milestone, project: project_next_1_1, title: '8.9', due_date: ten_days_from_now),
- create(:milestone, project: project_next_8_8, title: '1.2', due_date: yesterday),
- create(:milestone, project: project_next_8_8, title: '8.8', due_date: tomorrow),
- create(:milestone, group: group, title: '9.9', due_date: tomorrow)
+ create(:milestone, project: project_next_1_1, title: "1.1", due_date: two_days_from_now),
+ create(:milestone, project: project_next_1_1, title: "8.9", due_date: ten_days_from_now),
+ create(:milestone, project: project_next_8_8, title: "1.2", due_date: yesterday),
+ create(:milestone, project: project_next_8_8, title: "8.8", due_date: tomorrow),
+ create(:milestone, group: group, title: "9.9", due_date: tomorrow),
]
end
@@ -204,14 +204,14 @@ describe IssuesFinder do
end
end
- it 'returns issues in the upcoming milestone for each project or group' do
- expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.1', '8.8', '9.9')
+ it "returns issues in the upcoming milestone for each project or group" do
+ expect(issues.map { |issue| issue.milestone.title }).to contain_exactly("1.1", "8.8", "9.9")
expect(issues.map { |issue| issue.milestone.due_date }).to contain_exactly(tomorrow, two_days_from_now, tomorrow)
end
end
- context 'filtering by started milestone' do
- let(:params) { { milestone_title: Milestone::Started.name } }
+ context "filtering by started milestone" do
+ let(:params) { {milestone_title: Milestone::Started.name} }
let(:project_no_started_milestones) { create(:project, :public) }
let(:project_started_1_and_2) { create(:project, :public) }
@@ -224,12 +224,12 @@ describe IssuesFinder do
let(:milestones) do
[
create(:milestone, project: project_no_started_milestones, start_date: tomorrow),
- create(:milestone, project: project_started_1_and_2, title: '1.0', start_date: two_days_ago),
- create(:milestone, project: project_started_1_and_2, title: '2.0', start_date: yesterday),
- create(:milestone, project: project_started_1_and_2, title: '3.0', start_date: tomorrow),
- create(:milestone, project: project_started_8, title: '7.0'),
- create(:milestone, project: project_started_8, title: '8.0', start_date: yesterday),
- create(:milestone, project: project_started_8, title: '9.0', start_date: tomorrow)
+ create(:milestone, project: project_started_1_and_2, title: "1.0", start_date: two_days_ago),
+ create(:milestone, project: project_started_1_and_2, title: "2.0", start_date: yesterday),
+ create(:milestone, project: project_started_1_and_2, title: "3.0", start_date: tomorrow),
+ create(:milestone, project: project_started_8, title: "7.0"),
+ create(:milestone, project: project_started_8, title: "8.0", start_date: yesterday),
+ create(:milestone, project: project_started_8, title: "9.0", start_date: tomorrow),
]
end
@@ -239,65 +239,65 @@ describe IssuesFinder do
end
end
- it 'returns issues in the started milestones for each project' do
- expect(issues.map { |issue| issue.milestone.title }).to contain_exactly('1.0', '2.0', '8.0')
+ it "returns issues in the started milestones for each project" do
+ expect(issues.map { |issue| issue.milestone.title }).to contain_exactly("1.0", "2.0", "8.0")
expect(issues.map { |issue| issue.milestone.start_date }).to contain_exactly(two_days_ago, yesterday, yesterday)
end
end
- context 'filtering by label' do
- let(:params) { { label_name: label.title } }
+ context "filtering by label" do
+ let(:params) { {label_name: label.title} }
- it 'returns issues with that label' do
+ it "returns issues with that label" do
expect(issues).to contain_exactly(issue2)
end
end
- context 'filtering by multiple labels' do
- let(:params) { { label_name: [label.title, label2.title].join(',') } }
+ context "filtering by multiple labels" do
+ let(:params) { {label_name: [label.title, label2.title].join(",")} }
let(:label2) { create(:label, project: project2) }
before do
create(:label_link, label: label2, target: issue2)
end
- it 'returns the unique issues with all those labels' do
+ it "returns the unique issues with all those labels" do
expect(issues).to contain_exactly(issue2)
end
end
- context 'filtering by a label that includes any or none in the title' do
- let(:params) { { label_name: [label.title, label2.title].join(',') } }
- let(:label) { create(:label, title: 'any foo', project: project2) }
- let(:label2) { create(:label, title: 'bar none', project: project2) }
+ context "filtering by a label that includes any or none in the title" do
+ let(:params) { {label_name: [label.title, label2.title].join(",")} }
+ let(:label) { create(:label, title: "any foo", project: project2) }
+ let(:label2) { create(:label, title: "bar none", project: project2) }
- it 'returns the unique issues with all those labels' do
+ it "returns the unique issues with all those labels" do
create(:label_link, label: label2, target: issue2)
expect(issues).to contain_exactly(issue2)
end
end
- context 'filtering by no label' do
- let(:params) { { label_name: described_class::FILTER_NONE } }
+ context "filtering by no label" do
+ let(:params) { {label_name: described_class::FILTER_NONE} }
- it 'returns issues with no labels' do
+ it "returns issues with no labels" do
expect(issues).to contain_exactly(issue1, issue3, issue4)
end
end
- context 'filtering by legacy No+Label' do
- let(:params) { { label_name: Label::NONE } }
+ context "filtering by legacy No+Label" do
+ let(:params) { {label_name: Label::NONE} }
- it 'returns issues with no labels' do
+ it "returns issues with no labels" do
expect(issues).to contain_exactly(issue1, issue3, issue4)
end
end
- context 'filtering by any label' do
- let(:params) { { label_name: described_class::FILTER_ANY } }
+ context "filtering by any label" do
+ let(:params) { {label_name: described_class::FILTER_ANY} }
- it 'returns issues that have one or more label' do
+ it "returns issues that have one or more label" do
2.times do
create(:label_link, label: create(:label, project: project2), target: issue3)
end
@@ -306,167 +306,167 @@ describe IssuesFinder do
end
end
- context 'filtering by issue term' do
- let(:params) { { search: 'git' } }
+ context "filtering by issue term" do
+ let(:params) { {search: "git"} }
- it 'returns issues with title and description match for search term' do
+ it "returns issues with title and description match for search term" do
expect(issues).to contain_exactly(issue1, issue2)
end
end
- context 'filtering by issue term in title' do
- let(:params) { { search: 'git', in: 'title' } }
+ context "filtering by issue term in title" do
+ let(:params) { {search: "git", in: "title"} }
- it 'returns issues with title match for search term' do
+ it "returns issues with title match for search term" do
expect(issues).to contain_exactly(issue1)
end
end
- context 'filtering by issues iids' do
- let(:params) { { iids: issue3.iid } }
+ context "filtering by issues iids" do
+ let(:params) { {iids: issue3.iid} }
- it 'returns issues with iids match' do
+ it "returns issues with iids match" do
expect(issues).to contain_exactly(issue3)
end
end
- context 'filtering by state' do
- context 'with opened' do
- let(:params) { { state: 'opened' } }
+ context "filtering by state" do
+ context "with opened" do
+ let(:params) { {state: "opened"} }
- it 'returns only opened issues' do
+ it "returns only opened issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
end
end
- context 'with closed' do
- let(:params) { { state: 'closed' } }
+ context "with closed" do
+ let(:params) { {state: "closed"} }
- it 'returns only closed issues' do
+ it "returns only closed issues" do
expect(issues).to contain_exactly(closed_issue)
end
end
- context 'with all' do
- let(:params) { { state: 'all' } }
+ context "with all" do
+ let(:params) { {state: "all"} }
- it 'returns all issues' do
+ it "returns all issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, closed_issue, issue4)
end
end
- context 'with invalid state' do
- let(:params) { { state: 'invalid_state' } }
+ context "with invalid state" do
+ let(:params) { {state: "invalid_state"} }
- it 'returns all issues' do
+ it "returns all issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, closed_issue, issue4)
end
end
end
- context 'filtering by created_at' do
- context 'through created_after' do
- let(:params) { { created_after: issue3.created_at } }
+ context "filtering by created_at" do
+ context "through created_after" do
+ let(:params) { {created_after: issue3.created_at} }
- it 'returns issues created on or after the given date' do
+ it "returns issues created on or after the given date" do
expect(issues).to contain_exactly(issue3)
end
end
- context 'through created_before' do
- let(:params) { { created_before: issue1.created_at } }
+ context "through created_before" do
+ let(:params) { {created_before: issue1.created_at} }
- it 'returns issues created on or before the given date' do
+ it "returns issues created on or before the given date" do
expect(issues).to contain_exactly(issue1)
end
end
- context 'through created_after and created_before' do
- let(:params) { { created_after: issue2.created_at, created_before: issue3.created_at } }
+ context "through created_after and created_before" do
+ let(:params) { {created_after: issue2.created_at, created_before: issue3.created_at} }
- it 'returns issues created between the given dates' do
+ it "returns issues created between the given dates" do
expect(issues).to contain_exactly(issue2, issue3)
end
end
end
- context 'filtering by updated_at' do
- context 'through updated_after' do
- let(:params) { { updated_after: issue3.updated_at } }
+ context "filtering by updated_at" do
+ context "through updated_after" do
+ let(:params) { {updated_after: issue3.updated_at} }
- it 'returns issues updated on or after the given date' do
+ it "returns issues updated on or after the given date" do
expect(issues).to contain_exactly(issue3)
end
end
- context 'through updated_before' do
- let(:params) { { updated_before: issue1.updated_at } }
+ context "through updated_before" do
+ let(:params) { {updated_before: issue1.updated_at} }
- it 'returns issues updated on or before the given date' do
+ it "returns issues updated on or before the given date" do
expect(issues).to contain_exactly(issue1)
end
end
- context 'through updated_after and updated_before' do
- let(:params) { { updated_after: issue2.updated_at, updated_before: issue3.updated_at } }
+ context "through updated_after and updated_before" do
+ let(:params) { {updated_after: issue2.updated_at, updated_before: issue3.updated_at} }
- it 'returns issues updated between the given dates' do
+ it "returns issues updated between the given dates" do
expect(issues).to contain_exactly(issue2, issue3)
end
end
end
- context 'filtering by closed_at' do
+ context "filtering by closed_at" do
let!(:closed_issue1) { create(:issue, project: project1, state: :closed, closed_at: 1.week.ago) }
let!(:closed_issue2) { create(:issue, project: project2, state: :closed, closed_at: 1.week.from_now) }
let!(:closed_issue3) { create(:issue, project: project2, state: :closed, closed_at: 2.weeks.from_now) }
- context 'through closed_after' do
- let(:params) { { state: :closed, closed_after: closed_issue3.closed_at } }
+ context "through closed_after" do
+ let(:params) { {state: :closed, closed_after: closed_issue3.closed_at} }
- it 'returns issues closed on or after the given date' do
+ it "returns issues closed on or after the given date" do
expect(issues).to contain_exactly(closed_issue3)
end
end
- context 'through closed_before' do
- let(:params) { { state: :closed, closed_before: closed_issue1.closed_at } }
+ context "through closed_before" do
+ let(:params) { {state: :closed, closed_before: closed_issue1.closed_at} }
- it 'returns issues closed on or before the given date' do
+ it "returns issues closed on or before the given date" do
expect(issues).to contain_exactly(closed_issue1)
end
end
- context 'through closed_after and closed_before' do
- let(:params) { { state: :closed, closed_after: closed_issue2.closed_at, closed_before: closed_issue3.closed_at } }
+ context "through closed_after and closed_before" do
+ let(:params) { {state: :closed, closed_after: closed_issue2.closed_at, closed_before: closed_issue3.closed_at} }
- it 'returns issues closed between the given dates' do
+ it "returns issues closed between the given dates" do
expect(issues).to contain_exactly(closed_issue2, closed_issue3)
end
end
end
- context 'filtering by reaction name' do
- context 'user searches by no reaction' do
- let(:params) { { my_reaction_emoji: 'None' } }
+ context "filtering by reaction name" do
+ context "user searches by no reaction" do
+ let(:params) { {my_reaction_emoji: "None"} }
- it 'returns issues that the user did not react to' do
+ it "returns issues that the user did not react to" do
expect(issues).to contain_exactly(issue2, issue4)
end
end
- context 'user searches by any reaction' do
- let(:params) { { my_reaction_emoji: 'Any' } }
+ context "user searches by any reaction" do
+ let(:params) { {my_reaction_emoji: "Any"} }
- it 'returns issues that the user reacted to' do
+ it "returns issues that the user reacted to" do
expect(issues).to contain_exactly(issue1, issue3)
end
end
context 'user searches by "thumbsup" reaction' do
- let(:params) { { my_reaction_emoji: 'thumbsup' } }
+ let(:params) { {my_reaction_emoji: "thumbsup"} }
- it 'returns issues that the user thumbsup to' do
+ it "returns issues that the user thumbsup to" do
expect(issues).to contain_exactly(issue1)
end
end
@@ -474,65 +474,65 @@ describe IssuesFinder do
context 'user2 searches by "thumbsup" reaction' do
let(:search_user) { user2 }
- let(:params) { { my_reaction_emoji: 'thumbsup' } }
+ let(:params) { {my_reaction_emoji: "thumbsup"} }
- it 'returns issues that the user2 thumbsup to' do
+ it "returns issues that the user2 thumbsup to" do
expect(issues).to contain_exactly(issue2)
end
end
context 'user searches by "thumbsdown" reaction' do
- let(:params) { { my_reaction_emoji: 'thumbsdown' } }
+ let(:params) { {my_reaction_emoji: "thumbsdown"} }
- it 'returns issues that the user thumbsdown to' do
+ it "returns issues that the user thumbsdown to" do
expect(issues).to contain_exactly(issue3)
end
end
end
- context 'filtering by confidential' do
+ context "filtering by confidential" do
set(:confidential_issue) { create(:issue, project: project1, confidential: true) }
- context 'no filtering' do
- it 'returns all issues' do
+ context "no filtering" do
+ it "returns all issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4, confidential_issue)
end
end
- context 'user filters confidential issues' do
- let(:params) { { confidential: true } }
+ context "user filters confidential issues" do
+ let(:params) { {confidential: true} }
- it 'returns only confdential issues' do
+ it "returns only confdential issues" do
expect(issues).to contain_exactly(confidential_issue)
end
end
- context 'user filters only public issues' do
- let(:params) { { confidential: false } }
+ context "user filters only public issues" do
+ let(:params) { {confidential: false} }
- it 'returns only confdential issues' do
+ it "returns only confdential issues" do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
end
end
end
- context 'when the user is unauthorized' do
+ context "when the user is unauthorized" do
let(:search_user) { nil }
- it 'returns no results' do
+ it "returns no results" do
expect(issues).to be_empty
end
end
- context 'when the user can see some, but not all, issues' do
+ context "when the user can see some, but not all, issues" do
let(:search_user) { user2 }
- it 'returns only issues they can see' do
+ it "returns only issues they can see" do
expect(issues).to contain_exactly(issue2, issue3)
end
end
- it 'finds issues user can access due to group' do
+ it "finds issues user can access due to group" do
group = create(:group)
project = create(:project, group: group)
issue = create(:issue, project: project)
@@ -542,23 +542,23 @@ describe IssuesFinder do
end
end
- context 'personal scope' do
- let(:scope) { 'assigned_to_me' }
+ context "personal scope" do
+ let(:scope) { "assigned_to_me" }
- it 'returns issue assigned to the user' do
+ it "returns issue assigned to the user" do
expect(issues).to contain_exactly(issue1, issue2)
end
- context 'filtering by project' do
- let(:params) { { project_id: project1.id } }
+ context "filtering by project" do
+ let(:params) { {project_id: project1.id} }
- it 'returns issues assigned to the user in that project' do
+ it "returns issues assigned to the user in that project" do
expect(issues).to contain_exactly(issue1)
end
end
end
- context 'when project restricts issues' do
+ context "when project restricts issues" do
let(:scope) { nil }
it "doesn't return team-only issues to non team members" do
@@ -578,131 +578,131 @@ describe IssuesFinder do
end
end
- describe '#row_count', :request_store do
- it 'returns the number of rows for the default state' do
+ describe "#row_count", :request_store do
+ it "returns the number of rows for the default state" do
finder = described_class.new(user)
expect(finder.row_count).to eq(5)
end
- it 'returns the number of rows for a given state' do
- finder = described_class.new(user, state: 'closed')
+ it "returns the number of rows for a given state" do
+ finder = described_class.new(user, state: "closed")
expect(finder.row_count).to be_zero
end
end
- describe '#with_confidentiality_access_check' do
+ describe "#with_confidentiality_access_check" do
let(:guest) { create(:user) }
set(:authorized_user) { create(:user) }
set(:project) { create(:project, namespace: authorized_user.namespace) }
set(:public_issue) { create(:issue, project: project) }
set(:confidential_issue) { create(:issue, project: project, confidential: true) }
- context 'when no project filter is given' do
+ context "when no project filter is given" do
let(:params) { {} }
- context 'for an anonymous user' do
+ context "for an anonymous user" do
subject { described_class.new(nil, params).with_confidentiality_access_check }
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
end
- context 'for a user without project membership' do
+ context "for a user without project membership" do
subject { described_class.new(user, params).with_confidentiality_access_check }
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
end
- context 'for a guest user' do
+ context "for a guest user" do
subject { described_class.new(guest, params).with_confidentiality_access_check }
before do
project.add_guest(guest)
end
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
end
- context 'for a project member with access to view confidential issues' do
+ context "for a project member with access to view confidential issues" do
subject { described_class.new(authorized_user, params).with_confidentiality_access_check }
- it 'returns all issues' do
+ it "returns all issues" do
expect(subject).to include(public_issue, confidential_issue)
end
end
end
- context 'when searching within a specific project' do
- let(:params) { { project_id: project.id } }
+ context "when searching within a specific project" do
+ let(:params) { {project_id: project.id} }
- context 'for an anonymous user' do
+ context "for an anonymous user" do
subject { described_class.new(nil, params).with_confidentiality_access_check }
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
- it 'does not filter by confidentiality' do
- expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything)
+ it "does not filter by confidentiality" do
+ expect(Issue).not_to receive(:where).with(a_string_matching("confidential"), anything)
subject
end
end
- context 'for a user without project membership' do
+ context "for a user without project membership" do
subject { described_class.new(user, params).with_confidentiality_access_check }
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
- it 'filters by confidentiality' do
- expect(Issue).to receive(:where).with(a_string_matching('confidential'), anything)
+ it "filters by confidentiality" do
+ expect(Issue).to receive(:where).with(a_string_matching("confidential"), anything)
subject
end
end
- context 'for a guest user' do
+ context "for a guest user" do
subject { described_class.new(guest, params).with_confidentiality_access_check }
before do
project.add_guest(guest)
end
- it 'returns only public issues' do
+ it "returns only public issues" do
expect(subject).to include(public_issue)
expect(subject).not_to include(confidential_issue)
end
- it 'filters by confidentiality' do
- expect(Issue).to receive(:where).with(a_string_matching('confidential'), anything)
+ it "filters by confidentiality" do
+ expect(Issue).to receive(:where).with(a_string_matching("confidential"), anything)
subject
end
end
- context 'for a project member with access to view confidential issues' do
+ context "for a project member with access to view confidential issues" do
subject { described_class.new(authorized_user, params).with_confidentiality_access_check }
- it 'returns all issues' do
+ it "returns all issues" do
expect(subject).to include(public_issue, confidential_issue)
end
- it 'does not filter by confidentiality' do
- expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything)
+ it "does not filter by confidentiality" do
+ expect(Issue).not_to receive(:where).with(a_string_matching("confidential"), anything)
subject
end
@@ -710,7 +710,7 @@ describe IssuesFinder do
end
end
- describe '#use_subquery_for_search?' do
+ describe "#use_subquery_for_search?" do
let(:finder) { described_class.new(nil, params) }
before do
@@ -718,56 +718,56 @@ describe IssuesFinder do
stub_feature_flags(use_subquery_for_group_issues_search: true)
end
- context 'when there is no search param' do
- let(:params) { { attempt_group_search_optimizations: true } }
+ context "when there is no search param" do
+ let(:params) { {attempt_group_search_optimizations: true} }
- it 'returns false' do
+ it "returns false" do
expect(finder.use_subquery_for_search?).to be_falsey
end
end
- context 'when the database is not Postgres' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when the database is not Postgres" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(finder.use_subquery_for_search?).to be_falsey
end
end
- context 'when the attempt_group_search_optimizations param is falsey' do
- let(:params) { { search: 'foo' } }
+ context "when the attempt_group_search_optimizations param is falsey" do
+ let(:params) { {search: "foo"} }
- it 'returns false' do
+ it "returns false" do
expect(finder.use_subquery_for_search?).to be_falsey
end
end
- context 'when the use_subquery_for_group_issues_search flag is disabled' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when the use_subquery_for_group_issues_search flag is disabled" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
before do
stub_feature_flags(use_subquery_for_group_issues_search: false)
end
- it 'returns false' do
+ it "returns false" do
expect(finder.use_subquery_for_search?).to be_falsey
end
end
- context 'when all conditions are met' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when all conditions are met" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
- it 'returns true' do
+ it "returns true" do
expect(finder.use_subquery_for_search?).to be_truthy
end
end
end
- describe '#use_cte_for_search?' do
+ describe "#use_cte_for_search?" do
let(:finder) { described_class.new(nil, params) }
before do
@@ -776,62 +776,62 @@ describe IssuesFinder do
stub_feature_flags(use_subquery_for_group_issues_search: false)
end
- context 'when there is no search param' do
- let(:params) { { attempt_group_search_optimizations: true } }
+ context "when there is no search param" do
+ let(:params) { {attempt_group_search_optimizations: true} }
- it 'returns false' do
+ it "returns false" do
expect(finder.use_cte_for_search?).to be_falsey
end
end
- context 'when the database is not Postgres' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when the database is not Postgres" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(finder.use_cte_for_search?).to be_falsey
end
end
- context 'when the attempt_group_search_optimizations param is falsey' do
- let(:params) { { search: 'foo' } }
+ context "when the attempt_group_search_optimizations param is falsey" do
+ let(:params) { {search: "foo"} }
- it 'returns false' do
+ it "returns false" do
expect(finder.use_cte_for_search?).to be_falsey
end
end
- context 'when the use_cte_for_group_issues_search flag is disabled' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when the use_cte_for_group_issues_search flag is disabled" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
before do
stub_feature_flags(use_cte_for_group_issues_search: false)
end
- it 'returns false' do
+ it "returns false" do
expect(finder.use_cte_for_search?).to be_falsey
end
end
- context 'when use_subquery_for_search? is true' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when use_subquery_for_search? is true" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
before do
stub_feature_flags(use_subquery_for_group_issues_search: true)
end
- it 'returns false' do
+ it "returns false" do
expect(finder.use_cte_for_search?).to be_falsey
end
end
- context 'when all conditions are met' do
- let(:params) { { search: 'foo', attempt_group_search_optimizations: true } }
+ context "when all conditions are met" do
+ let(:params) { {search: "foo", attempt_group_search_optimizations: true} }
- it 'returns true' do
+ it "returns true" do
expect(finder.use_cte_for_search?).to be_truthy
end
end
diff --git a/spec/finders/joined_groups_finder_spec.rb b/spec/finders/joined_groups_finder_spec.rb
index ae3e55f90f1..eef6f0e3eac 100644
--- a/spec/finders/joined_groups_finder_spec.rb
+++ b/spec/finders/joined_groups_finder_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe JoinedGroupsFinder do
- describe '#execute' do
+ describe "#execute" do
let!(:profile_owner) { create(:user) }
let!(:profile_visitor) { create(:user) }
@@ -13,12 +13,12 @@ describe JoinedGroupsFinder do
let!(:public_group_2) { create(:group, :public) }
let!(:finder) { described_class.new(profile_owner) }
- context 'without a user' do
+ context "without a user" do
before do
public_group.add_maintainer(profile_owner)
end
- it 'only shows public groups from profile owner' do
+ it "only shows public groups from profile owner" do
expect(finder.execute).to eq([public_group])
end
end
@@ -35,28 +35,28 @@ describe JoinedGroupsFinder do
private_group.add_developer(profile_visitor)
end
- it 'only shows groups where both users are authorized to see' do
+ it "only shows groups where both users are authorized to see" do
expect(finder.execute(profile_visitor)).to eq([public_group, internal_group, private_group])
end
end
- context 'if profile visitor is in one of the private group projects' do
+ context "if profile visitor is in one of the private group projects" do
before do
- project = create(:project, :private, group: private_group, name: 'B', path: 'B')
+ project = create(:project, :private, group: private_group, name: "B", path: "B")
project.add_user(profile_visitor, Gitlab::Access::DEVELOPER)
end
- it 'shows group' do
+ it "shows group" do
expect(finder.execute(profile_visitor)).to eq([public_group, internal_group, private_group])
end
end
- context 'external users' do
+ context "external users" do
before do
profile_visitor.update(external: true)
end
- context 'if not a member' do
+ context "if not a member" do
it "does not show internal groups" do
expect(finder.execute(profile_visitor)).to eq([public_group])
end
diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb
index 9abc52aa664..0a20e346d8e 100644
--- a/spec/finders/labels_finder_spec.rb
+++ b/spec/finders/labels_finder_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe LabelsFinder do
- describe '#execute' do
+ describe "#execute" do
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
let(:group_3) { create(:group) }
@@ -14,28 +14,28 @@ describe LabelsFinder do
let(:project_4) { create(:project, :public) }
let(:project_5) { create(:project, namespace: group_1) }
- let!(:project_label_1) { create(:label, project: project_1, title: 'Label 1', description: 'awesome label') }
- let!(:project_label_2) { create(:label, project: project_2, title: 'Label 2') }
- let!(:project_label_4) { create(:label, project: project_4, title: 'Label 4') }
- let!(:project_label_5) { create(:label, project: project_5, title: 'Label 5') }
+ let!(:project_label_1) { create(:label, project: project_1, title: "Label 1", description: "awesome label") }
+ let!(:project_label_2) { create(:label, project: project_2, title: "Label 2") }
+ let!(:project_label_4) { create(:label, project: project_4, title: "Label 4") }
+ let!(:project_label_5) { create(:label, project: project_5, title: "Label 5") }
- let!(:group_label_1) { create(:group_label, group: group_1, title: 'Label 1 (group)') }
- let!(:group_label_2) { create(:group_label, group: group_1, title: 'Group Label 2') }
- let!(:group_label_3) { create(:group_label, group: group_2, title: 'Group Label 3') }
- let!(:private_group_label_1) { create(:group_label, group: private_group_1, title: 'Private Group Label 1') }
- let!(:private_subgroup_label_1) { create(:group_label, group: private_subgroup_1, title: 'Private Sub Group Label 1') }
+ let!(:group_label_1) { create(:group_label, group: group_1, title: "Label 1 (group)") }
+ let!(:group_label_2) { create(:group_label, group: group_1, title: "Group Label 2") }
+ let!(:group_label_3) { create(:group_label, group: group_2, title: "Group Label 3") }
+ let!(:private_group_label_1) { create(:group_label, group: private_group_1, title: "Private Group Label 1") }
+ let!(:private_subgroup_label_1) { create(:group_label, group: private_subgroup_1, title: "Private Sub Group Label 1") }
let(:user) { create(:user) }
before do
- create(:label, project: project_3, title: 'Label 3')
- create(:group_label, group: group_3, title: 'Group Label 4')
+ create(:label, project: project_3, title: "Label 3")
+ create(:group_label, group: group_3, title: "Group Label 4")
project_1.add_developer(user)
end
- context 'with no filter' do
- it 'returns labels from projects the user have access' do
+ context "with no filter" do
+ it "returns labels from projects the user have access" do
group_2.add_developer(user)
finder = described_class.new(user)
@@ -43,7 +43,7 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2, group_label_3, project_label_1, group_label_1, project_label_2, project_label_4]
end
- it 'returns labels available if nil title is supplied' do
+ it "returns labels available if nil title is supplied" do
group_2.add_developer(user)
# params[:title] will return `nil` regardless whether it is specified
finder = described_class.new(user, title: nil)
@@ -52,8 +52,8 @@ describe LabelsFinder do
end
end
- context 'filtering by group_id' do
- it 'returns labels available for any non-archived project within the group' do
+ context "filtering by group_id" do
+ it "returns labels available for any non-archived project within the group" do
group_1.add_developer(user)
::Projects::UpdateService.new(project_1, user, archived: true).execute
finder = described_class.new(user, group_id: group_1.id)
@@ -61,8 +61,8 @@ describe LabelsFinder do
expect(finder.execute).to eq [group_label_2, group_label_1, project_label_5]
end
- context 'when only_group_labels is true' do
- it 'returns only group labels' do
+ context "when only_group_labels is true" do
+ it "returns only group labels" do
group_1.add_developer(user)
finder = described_class.new(user, group_id: group_1.id, only_group_labels: true)
@@ -71,17 +71,17 @@ describe LabelsFinder do
end
end
- context 'when group has no projects' do
+ context "when group has no projects" do
let(:empty_group) { create(:group) }
- let!(:empty_group_label_1) { create(:group_label, group: empty_group, title: 'Label 1 (empty group)') }
- let!(:empty_group_label_2) { create(:group_label, group: empty_group, title: 'Label 2 (empty group)') }
+ let!(:empty_group_label_1) { create(:group_label, group: empty_group, title: "Label 1 (empty group)") }
+ let!(:empty_group_label_2) { create(:group_label, group: empty_group, title: "Label 2 (empty group)") }
before do
empty_group.add_developer(user)
end
- context 'when only group labels is false' do
- it 'returns group labels' do
+ context "when only group labels is false" do
+ it "returns group labels" do
finder = described_class.new(user, group_id: empty_group.id)
expect(finder.execute).to eq [empty_group_label_1, empty_group_label_2]
@@ -89,8 +89,8 @@ describe LabelsFinder do
end
end
- context 'when including labels from group ancestors', :nested_groups do
- it 'returns labels from group and its ancestors' do
+ context "when including labels from group ancestors", :nested_groups do
+ it "returns labels from group and its ancestors" do
private_group_1.add_developer(user)
private_subgroup_1.add_developer(user)
@@ -99,7 +99,7 @@ describe LabelsFinder do
expect(finder.execute).to eq [private_group_label_1, private_subgroup_label_1]
end
- it 'ignores labels from groups which user can not read' do
+ it "ignores labels from groups which user can not read" do
private_subgroup_1.add_developer(user)
finder = described_class.new(user, group_id: private_subgroup_1.id, only_group_labels: true, include_ancestor_groups: true)
@@ -108,8 +108,8 @@ describe LabelsFinder do
end
end
- context 'when including labels from group descendants', :nested_groups do
- it 'returns labels from group and its descendants' do
+ context "when including labels from group descendants", :nested_groups do
+ it "returns labels from group and its descendants" do
private_group_1.add_developer(user)
private_subgroup_1.add_developer(user)
@@ -118,7 +118,7 @@ describe LabelsFinder do
expect(finder.execute).to eq [private_group_label_1, private_subgroup_label_1]
end
- it 'ignores labels from groups which user can not read' do
+ it "ignores labels from groups which user can not read" do
private_subgroup_1.add_developer(user)
finder = described_class.new(user, group_id: private_group_1.id, only_group_labels: true, include_descendant_groups: true)
@@ -128,29 +128,29 @@ describe LabelsFinder do
end
end
- context 'filtering by project_id', :nested_groups do
- context 'when include_ancestor_groups is true' do
- let!(:sub_project) { create(:project, namespace: private_subgroup_1 ) }
- let!(:project_label) { create(:label, project: sub_project, title: 'Label 5') }
+ context "filtering by project_id", :nested_groups do
+ context "when include_ancestor_groups is true" do
+ let!(:sub_project) { create(:project, namespace: private_subgroup_1) }
+ let!(:project_label) { create(:label, project: sub_project, title: "Label 5") }
let(:finder) { described_class.new(user, project_id: sub_project.id, include_ancestor_groups: true) }
before do
private_group_1.add_developer(user)
end
- it 'returns all ancestor labels' do
+ it "returns all ancestor labels" do
expect(finder.execute).to match_array([private_subgroup_label_1, private_group_label_1, project_label])
end
end
- it 'returns labels available for the project' do
+ it "returns labels available for the project" do
finder = described_class.new(user, project_id: project_1.id)
expect(finder.execute).to eq [group_label_2, project_label_1, group_label_1]
end
- context 'as an administrator' do
- it 'does not return labels from another project' do
+ context "as an administrator" do
+ it "does not return labels from another project" do
# Purposefully creating a project with _nothing_ associated to it
isolated_project = create(:project)
admin = create(:admin)
@@ -165,57 +165,57 @@ describe LabelsFinder do
end
end
- context 'filtering by title' do
- it 'returns label with that title' do
- finder = described_class.new(user, title: 'Group Label 2')
+ context "filtering by title" do
+ it "returns label with that title" do
+ finder = described_class.new(user, title: "Group Label 2")
expect(finder.execute).to eq [group_label_2]
end
- it 'returns label with title alias' do
- finder = described_class.new(user, name: 'Group Label 2')
+ it "returns label with title alias" do
+ finder = described_class.new(user, name: "Group Label 2")
expect(finder.execute).to eq [group_label_2]
end
- it 'returns no labels if empty title is supplied' do
+ it "returns no labels if empty title is supplied" do
finder = described_class.new(user, title: [])
expect(finder.execute).to be_empty
end
- it 'returns no labels if blank title is supplied' do
- finder = described_class.new(user, title: '')
+ it "returns no labels if blank title is supplied" do
+ finder = described_class.new(user, title: "")
expect(finder.execute).to be_empty
end
- it 'returns no labels if empty name is supplied' do
+ it "returns no labels if empty name is supplied" do
finder = described_class.new(user, name: [])
expect(finder.execute).to be_empty
end
end
- context 'search by title and description' do
- it 'returns labels with a partially matching title' do
- finder = described_class.new(user, search: '(group)')
+ context "search by title and description" do
+ it "returns labels with a partially matching title" do
+ finder = described_class.new(user, search: "(group)")
expect(finder.execute).to eq [group_label_1]
end
- it 'returns labels with a partially matching description' do
- finder = described_class.new(user, search: 'awesome')
+ it "returns labels with a partially matching description" do
+ finder = described_class.new(user, search: "awesome")
expect(finder.execute).to eq [project_label_1]
end
end
- context 'filter by subscription' do
- it 'returns labels user subscribed to' do
+ context "filter by subscription" do
+ it "returns labels user subscribed to" do
project_label_1.subscribe(user)
- finder = described_class.new(user, subscribed: 'true')
+ finder = described_class.new(user, subscribed: "true")
expect(finder.execute).to eq [project_label_1]
end
diff --git a/spec/finders/license_template_finder_spec.rb b/spec/finders/license_template_finder_spec.rb
index f6f40bf33cc..3ece868e354 100644
--- a/spec/finders/license_template_finder_spec.rb
+++ b/spec/finders/license_template_finder_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe LicenseTemplateFinder do
- describe '#execute' do
+ describe "#execute" do
subject(:result) { described_class.new(nil, params).execute }
let(:categories) { categorised_licenses.keys }
let(:categorised_licenses) { result.group_by(&:category) }
- context 'popular: true' do
- let(:params) { { popular: true } }
+ context "popular: true" do
+ let(:params) { {popular: true} }
- it 'only returns popular licenses' do
+ it "only returns popular licenses" do
expect(categories).to contain_exactly(:Popular)
expect(categorised_licenses[:Popular]).to be_present
end
end
- context 'popular: false' do
- let(:params) { { popular: false } }
+ context "popular: false" do
+ let(:params) { {popular: false} }
- it 'only returns unpopular licenses' do
+ it "only returns unpopular licenses" do
expect(categories).to contain_exactly(:Other)
expect(categorised_licenses[:Other]).to be_present
end
end
- context 'popular: nil' do
- let(:params) { { popular: nil } }
+ context "popular: nil" do
+ let(:params) { {popular: nil} }
- it 'returns all licenses known by the Licensee gem' do
+ it "returns all licenses known by the Licensee gem" do
from_licensee = Licensee::License.all.map { |l| l.key }
expect(result.map(&:key)).to match_array(from_licensee)
end
- it 'correctly copies all attributes' do
+ it "correctly copies all attributes" do
licensee = Licensee::License.all.first
found = result.find { |r| r.key == licensee.key }
diff --git a/spec/finders/members_finder_spec.rb b/spec/finders/members_finder_spec.rb
index db48f00cd74..a993b55b85a 100644
--- a/spec/finders/members_finder_spec.rb
+++ b/spec/finders/members_finder_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe MembersFinder, '#execute' do
+describe MembersFinder, "#execute" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, :access_requestable, parent: group) }
let(:project) { create(:project, namespace: nested_group) }
@@ -9,7 +9,7 @@ describe MembersFinder, '#execute' do
let(:user3) { create(:user) }
let(:user4) { create(:user) }
- it 'returns members for project and parent groups', :nested_groups do
+ it "returns members for project and parent groups", :nested_groups do
nested_group.request_access(user1)
member1 = group.add_maintainer(user2)
member2 = nested_group.add_maintainer(user3)
@@ -20,7 +20,7 @@ describe MembersFinder, '#execute' do
expect(result.to_a).to match_array([member1, member2, member3])
end
- it 'includes nested group members if asked', :nested_groups do
+ it "includes nested group members if asked", :nested_groups do
project = create(:project, namespace: group)
nested_group.request_access(user1)
member1 = group.add_maintainer(user2)
diff --git a/spec/finders/merge_request_target_project_finder_spec.rb b/spec/finders/merge_request_target_project_finder_spec.rb
index d26a75179de..5c319af965d 100644
--- a/spec/finders/merge_request_target_project_finder_spec.rb
+++ b/spec/finders/merge_request_target_project_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestTargetProjectFinder do
include ProjectForksHelper
@@ -6,51 +6,51 @@ describe MergeRequestTargetProjectFinder do
let(:user) { create(:user) }
subject(:finder) { described_class.new(current_user: user, source_project: forked_project) }
- shared_examples 'finding related projects' do
- it 'finds sibling projects and base project' do
+ shared_examples "finding related projects" do
+ it "finds sibling projects and base project" do
other_fork
expect(finder.execute).to contain_exactly(base_project, other_fork, forked_project)
end
- it 'does not include projects that have merge requests turned off' do
+ it "does not include projects that have merge requests turned off" do
other_fork.project_feature.update!(merge_requests_access_level: ProjectFeature::DISABLED)
base_project.project_feature.update!(merge_requests_access_level: ProjectFeature::DISABLED)
expect(finder.execute).to contain_exactly(forked_project)
end
- it 'does not contain archived projects' do
+ it "does not contain archived projects" do
base_project.update!(archived: true)
expect(finder.execute).to contain_exactly(other_fork, forked_project)
end
end
- context 'public projects' do
- let(:base_project) { create(:project, :public, path: 'base') }
+ context "public projects" do
+ let(:base_project) { create(:project, :public, path: "base") }
let(:forked_project) { fork_project(base_project) }
let(:other_fork) { fork_project(base_project) }
- it_behaves_like 'finding related projects'
+ it_behaves_like "finding related projects"
end
- context 'private projects' do
- let(:base_project) { create(:project, :private, path: 'base') }
+ context "private projects" do
+ let(:base_project) { create(:project, :private, path: "base") }
let(:forked_project) { fork_project(base_project, base_project.owner) }
let(:other_fork) { fork_project(base_project, base_project.owner) }
- context 'when the user is a member of all projects' do
+ context "when the user is a member of all projects" do
before do
base_project.add_developer(user)
forked_project.add_developer(user)
other_fork.add_developer(user)
end
- it_behaves_like 'finding related projects'
+ it_behaves_like "finding related projects"
end
- it 'only finds the projects the user is a member of' do
+ it "only finds the projects the user is a member of" do
other_fork.add_developer(user)
base_project.add_developer(user)
diff --git a/spec/finders/merge_requests_finder_spec.rb b/spec/finders/merge_requests_finder_spec.rb
index 107da08a0a9..e70dc45cc98 100644
--- a/spec/finders/merge_requests_finder_spec.rb
+++ b/spec/finders/merge_requests_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestsFinder do
include ProjectForksHelper
@@ -36,14 +36,14 @@ describe MergeRequestsFinder do
let(:project6) { create_project_without_n_plus_1(group: subgroup) }
let!(:merge_request1) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project1) }
- let!(:merge_request2) { create(:merge_request, :conflict, author: user, source_project: project2, target_project: project1, state: 'closed') }
- let!(:merge_request3) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, state: 'locked', title: 'thing WIP thing') }
- let!(:merge_request4) { create(:merge_request, :simple, author: user, source_project: project3, target_project: project3, title: 'WIP thing') }
- let!(:merge_request5) { create(:merge_request, :simple, author: user, source_project: project4, target_project: project4, title: '[WIP]') }
- let!(:merge_request6) { create(:merge_request, :simple, author: user, source_project: project5, target_project: project5, title: 'WIP: thing') }
- let!(:merge_request7) { create(:merge_request, :simple, author: user, source_project: project6, target_project: project6, title: 'wip thing') }
- let!(:merge_request8) { create(:merge_request, :simple, author: user, source_project: project1, target_project: project1, title: '[wip] thing') }
- let!(:merge_request9) { create(:merge_request, :simple, author: user, source_project: project1, target_project: project2, title: 'wip: thing') }
+ let!(:merge_request2) { create(:merge_request, :conflict, author: user, source_project: project2, target_project: project1, state: "closed") }
+ let!(:merge_request3) { create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, state: "locked", title: "thing WIP thing") }
+ let!(:merge_request4) { create(:merge_request, :simple, author: user, source_project: project3, target_project: project3, title: "WIP thing") }
+ let!(:merge_request5) { create(:merge_request, :simple, author: user, source_project: project4, target_project: project4, title: "[WIP]") }
+ let!(:merge_request6) { create(:merge_request, :simple, author: user, source_project: project5, target_project: project5, title: "WIP: thing") }
+ let!(:merge_request7) { create(:merge_request, :simple, author: user, source_project: project6, target_project: project6, title: "wip thing") }
+ let!(:merge_request8) { create(:merge_request, :simple, author: user, source_project: project1, target_project: project1, title: "[wip] thing") }
+ let!(:merge_request9) { create(:merge_request, :simple, author: user, source_project: project1, target_project: project2, title: "wip: thing") }
before do
project1.add_maintainer(user)
@@ -56,31 +56,31 @@ describe MergeRequestsFinder do
end
describe "#execute" do
- it 'filters by scope' do
- params = { scope: 'authored', state: 'opened' }
+ it "filters by scope" do
+ params = {scope: "authored", state: "opened"}
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(7)
end
- it 'filters by project' do
- params = { project_id: project1.id, scope: 'authored', state: 'opened' }
+ it "filters by project" do
+ params = {project_id: project1.id, scope: "authored", state: "opened"}
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(2)
end
- context 'filtering by group' do
- it 'includes all merge requests when user has access' do
- params = { group_id: group.id }
+ context "filtering by group" do
+ it "includes all merge requests when user has access" do
+ params = {group_id: group.id}
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(3)
end
- it 'excludes merge requests from projects the user does not have access to' do
+ it "excludes merge requests from projects the user does not have access to" do
private_project = create_project_without_n_plus_1(:private, group: group)
private_mr = create(:merge_request, :simple, author: user, source_project: private_project, target_project: private_project)
- params = { group_id: group.id }
+ params = {group_id: group.id}
private_project.add_guest(user)
merge_requests = described_class.new(user, params).execute
@@ -89,8 +89,8 @@ describe MergeRequestsFinder do
expect(merge_requests).not_to include(private_mr)
end
- it 'filters by group including subgroups', :nested_groups do
- params = { group_id: group.id, include_subgroups: true }
+ it "filters by group including subgroups", :nested_groups do
+ params = {group_id: group.id, include_subgroups: true}
merge_requests = described_class.new(user, params).execute
@@ -98,79 +98,79 @@ describe MergeRequestsFinder do
end
end
- it 'filters by non_archived' do
- params = { non_archived: true }
+ it "filters by non_archived" do
+ params = {non_archived: true}
merge_requests = described_class.new(user, params).execute
expect(merge_requests.size).to eq(8)
end
- it 'filters by iid' do
- params = { project_id: project1.id, iids: merge_request1.iid }
+ it "filters by iid" do
+ params = {project_id: project1.id, iids: merge_request1.iid}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request1)
end
- it 'filters by source branch' do
- params = { source_branch: merge_request2.source_branch }
+ it "filters by source branch" do
+ params = {source_branch: merge_request2.source_branch}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request2)
end
- it 'filters by target branch' do
- params = { target_branch: merge_request2.target_branch }
+ it "filters by target branch" do
+ params = {target_branch: merge_request2.target_branch}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request2)
end
- it 'filters by state' do
- params = { state: 'locked' }
+ it "filters by state" do
+ params = {state: "locked"}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request3)
end
- it 'filters by wip' do
- params = { wip: 'yes' }
+ it "filters by wip" do
+ params = {wip: "yes"}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request4, merge_request5, merge_request6, merge_request7, merge_request8, merge_request9)
end
- it 'filters by not wip' do
- params = { wip: 'no' }
+ it "filters by not wip" do
+ params = {wip: "no"}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request1, merge_request2, merge_request3)
end
- it 'returns all items if no valid wip param exists' do
- params = { wip: '' }
+ it "returns all items if no valid wip param exists" do
+ params = {wip: ""}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request1, merge_request2, merge_request3, merge_request4, merge_request5, merge_request6, merge_request7, merge_request8, merge_request9)
end
- it 'adds wip to scalar params' do
+ it "adds wip to scalar params" do
scalar_params = described_class.scalar_params
expect(scalar_params).to include(:wip, :assignee_id)
end
- context 'filtering by group milestone' do
+ context "filtering by group milestone" do
let!(:group) { create(:group, :public) }
let(:group_milestone) { create(:milestone, group: group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- let(:params) { { milestone_title: group_milestone.title } }
+ let(:params) { {milestone_title: group_milestone.title} }
before do
project2.update(namespace: group)
@@ -178,62 +178,62 @@ describe MergeRequestsFinder do
merge_request3.update(milestone: group_milestone)
end
- it 'returns issues assigned to that group milestone' do
+ it "returns issues assigned to that group milestone" do
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(merge_request2, merge_request3)
end
end
- context 'filtering by created_at/updated_at' do
+ context "filtering by created_at/updated_at" do
let(:new_project) { create(:project, forked_from_project: project1) }
let!(:new_merge_request) do
create(:merge_request,
- :simple,
- author: user,
- created_at: 1.week.from_now,
- updated_at: 1.week.from_now,
- source_project: new_project,
- target_project: new_project)
+ :simple,
+ author: user,
+ created_at: 1.week.from_now,
+ updated_at: 1.week.from_now,
+ source_project: new_project,
+ target_project: new_project)
end
let!(:old_merge_request) do
create(:merge_request,
- :simple,
- author: user,
- source_branch: 'feature_1',
- created_at: 1.week.ago,
- updated_at: 1.week.ago,
- source_project: new_project,
- target_project: new_project)
+ :simple,
+ author: user,
+ source_branch: "feature_1",
+ created_at: 1.week.ago,
+ updated_at: 1.week.ago,
+ source_project: new_project,
+ target_project: new_project)
end
before do
new_project.add_maintainer(user)
end
- it 'filters by created_after' do
- params = { project_id: new_project.id, created_after: new_merge_request.created_at }
+ it "filters by created_after" do
+ params = {project_id: new_project.id, created_after: new_merge_request.created_at}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(new_merge_request)
end
- it 'filters by created_before' do
- params = { project_id: new_project.id, created_before: old_merge_request.created_at }
+ it "filters by created_before" do
+ params = {project_id: new_project.id, created_before: old_merge_request.created_at}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(old_merge_request)
end
- it 'filters by created_after and created_before' do
+ it "filters by created_after and created_before" do
params = {
project_id: new_project.id,
created_after: old_merge_request.created_at,
- created_before: new_merge_request.created_at
+ created_before: new_merge_request.created_at,
}
merge_requests = described_class.new(user, params).execute
@@ -241,27 +241,27 @@ describe MergeRequestsFinder do
expect(merge_requests).to contain_exactly(old_merge_request, new_merge_request)
end
- it 'filters by updated_after' do
- params = { project_id: new_project.id, updated_after: new_merge_request.updated_at }
+ it "filters by updated_after" do
+ params = {project_id: new_project.id, updated_after: new_merge_request.updated_at}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(new_merge_request)
end
- it 'filters by updated_before' do
- params = { project_id: new_project.id, updated_before: old_merge_request.updated_at }
+ it "filters by updated_before" do
+ params = {project_id: new_project.id, updated_before: old_merge_request.updated_at}
merge_requests = described_class.new(user, params).execute
expect(merge_requests).to contain_exactly(old_merge_request)
end
- it 'filters by updated_after and updated_before' do
+ it "filters by updated_after and updated_before" do
params = {
project_id: new_project.id,
updated_after: old_merge_request.updated_at,
- updated_before: new_merge_request.updated_at
+ updated_before: new_merge_request.updated_at,
}
merge_requests = described_class.new(user, params).execute
@@ -271,15 +271,15 @@ describe MergeRequestsFinder do
end
end
- describe '#row_count', :request_store do
- it 'returns the number of rows for the default state' do
+ describe "#row_count", :request_store do
+ it "returns the number of rows for the default state" do
finder = described_class.new(user)
expect(finder.row_count).to eq(7)
end
- it 'returns the number of rows for a given state' do
- finder = described_class.new(user, state: 'closed')
+ it "returns the number of rows for a given state" do
+ finder = described_class.new(user, state: "closed")
expect(finder.row_count).to eq(1)
end
diff --git a/spec/finders/milestones_finder_spec.rb b/spec/finders/milestones_finder_spec.rb
index ecffbb9e197..24823b0a529 100644
--- a/spec/finders/milestones_finder_spec.rb
+++ b/spec/finders/milestones_finder_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe MilestonesFinder do
let(:group) { create(:group) }
let(:project_1) { create(:project, namespace: group) }
let(:project_2) { create(:project, namespace: group) }
- let!(:milestone_1) { create(:milestone, group: group, title: 'one test', due_date: Date.today) }
+ let!(:milestone_1) { create(:milestone, group: group, title: "one test", due_date: Date.today) }
let!(:milestone_2) { create(:milestone, group: group) }
- let!(:milestone_3) { create(:milestone, project: project_1, state: 'active', due_date: Date.tomorrow) }
- let!(:milestone_4) { create(:milestone, project: project_2, state: 'active') }
+ let!(:milestone_3) { create(:milestone, project: project_1, state: "active", due_date: Date.tomorrow) }
+ let!(:milestone_4) { create(:milestone, project: project_2, state: "active") }
- it 'it returns milestones for projects' do
- result = described_class.new(project_ids: [project_1.id, project_2.id], state: 'all').execute
+ it "it returns milestones for projects" do
+ result = described_class.new(project_ids: [project_1.id, project_2.id], state: "all").execute
expect(result).to contain_exactly(milestone_3, milestone_4)
end
- it 'returns milestones for groups' do
- result = described_class.new(group_ids: group.id, state: 'all').execute
+ it "returns milestones for groups" do
+ result = described_class.new(group_ids: group.id, state: "all").execute
expect(result).to contain_exactly(milestone_1, milestone_2)
end
- context 'milestones for groups and project' do
+ context "milestones for groups and project" do
let(:result) do
- described_class.new(project_ids: [project_1.id, project_2.id], group_ids: group.id, state: 'all').execute
+ described_class.new(project_ids: [project_1.id, project_2.id], group_ids: group.id, state: "all").execute
end
- it 'returns milestones for groups and projects' do
+ it "returns milestones for groups and projects" do
expect(result).to contain_exactly(milestone_1, milestone_2, milestone_3, milestone_4)
end
- it 'orders milestones by due date' do
+ it "orders milestones by due date" do
expect(result.first).to eq(milestone_1)
expect(result.second).to eq(milestone_3)
end
end
- context 'with filters' do
+ context "with filters" do
let(:params) do
{
project_ids: [project_1.id, project_2.id],
group_ids: group.id,
- state: 'all'
+ state: "all",
}
end
@@ -50,36 +50,36 @@ describe MilestonesFinder do
milestone_3.close
end
- it 'filters by active state' do
- params[:state] = 'active'
+ it "filters by active state" do
+ params[:state] = "active"
result = described_class.new(params).execute
expect(result).to contain_exactly(milestone_2, milestone_4)
end
- it 'filters by closed state' do
- params[:state] = 'closed'
+ it "filters by closed state" do
+ params[:state] = "closed"
result = described_class.new(params).execute
expect(result).to contain_exactly(milestone_1, milestone_3)
end
- it 'filters by title' do
- result = described_class.new(params.merge(title: 'one test')).execute
+ it "filters by title" do
+ result = described_class.new(params.merge(title: "one test")).execute
expect(result.to_a).to contain_exactly(milestone_1)
end
- it 'filters by search_title' do
- result = described_class.new(params.merge(search_title: 'one t')).execute
+ it "filters by search_title" do
+ result = described_class.new(params.merge(search_title: "one t")).execute
expect(result.to_a).to contain_exactly(milestone_1)
end
end
- describe '#find_by' do
- it 'finds a single milestone' do
- finder = described_class.new(project_ids: [project_1.id], state: 'all')
+ describe "#find_by" do
+ it "finds a single milestone" do
+ finder = described_class.new(project_ids: [project_1.id], state: "all")
expect(finder.find_by(iid: milestone_3.iid)).to eq(milestone_3)
end
diff --git a/spec/finders/notes_finder_spec.rb b/spec/finders/notes_finder_spec.rb
index 0a685152cf9..56f08e408d8 100644
--- a/spec/finders/notes_finder_spec.rb
+++ b/spec/finders/notes_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NotesFinder do
let(:user) { create :user }
@@ -8,12 +8,12 @@ describe NotesFinder do
project.add_maintainer(user)
end
- describe '#execute' do
- context 'when notes filter is present' do
+ describe "#execute" do
+ context "when notes filter is present" do
let!(:comment) { create(:note_on_issue, project: project) }
let!(:system_note) { create(:note_on_issue, project: project, system: true) }
- it 'returns only user notes when using only_comments filter' do
+ it "returns only user notes when using only_comments filter" do
finder = described_class.new(project, user, notes_filter: UserPreference::NOTES_FILTERS[:only_comments])
notes = finder.execute
@@ -21,7 +21,7 @@ describe NotesFinder do
expect(notes).to match_array(comment)
end
- it 'returns only system notes when using only_activity filters' do
+ it "returns only system notes when using only_activity filters" do
finder = described_class.new(project, user, notes_filter: UserPreference::NOTES_FILTERS[:only_activity])
notes = finder.execute
@@ -29,7 +29,7 @@ describe NotesFinder do
expect(notes).to match_array(system_note)
end
- it 'gets all notes' do
+ it "gets all notes" do
finder = described_class.new(project, user, notes_filter: UserPreference::NOTES_FILTERS[:all_activity])
notes = finder.execute
@@ -38,7 +38,7 @@ describe NotesFinder do
end
end
- it 'finds notes on merge requests' do
+ it "finds notes on merge requests" do
create(:note_on_merge_request, project: project)
notes = described_class.new(project, user).execute
@@ -46,7 +46,7 @@ describe NotesFinder do
expect(notes.count).to eq(1)
end
- it 'finds notes on snippets' do
+ it "finds notes on snippets" do
create(:note_on_project_snippet, project: project)
notes = described_class.new(project, user).execute
@@ -57,29 +57,29 @@ describe NotesFinder do
it "excludes notes on commits the author can't download" do
project = create(:project, :private, :repository)
note = create(:note_on_commit, project: project)
- params = { target_type: 'commit', target_id: note.noteable.id }
+ params = {target_type: "commit", target_id: note.noteable.id}
notes = described_class.new(project, create(:user), params).execute
expect(notes.count).to eq(0)
end
- it 'succeeds when no notes found' do
+ it "succeeds when no notes found" do
notes = described_class.new(project, create(:user)).execute
expect(notes.count).to eq(0)
end
- context 'on restricted projects' do
+ context "on restricted projects" do
let(:project) do
create(:project,
- :public,
- :issues_private,
- :snippets_private,
- :merge_requests_private)
+ :public,
+ :issues_private,
+ :snippets_private,
+ :merge_requests_private)
end
- it 'publicly excludes notes on merge requests' do
+ it "publicly excludes notes on merge requests" do
create(:note_on_merge_request, project: project)
notes = described_class.new(project, create(:user)).execute
@@ -87,7 +87,7 @@ describe NotesFinder do
expect(notes.count).to eq(0)
end
- it 'publicly excludes notes on issues' do
+ it "publicly excludes notes on issues" do
create(:note_on_issue, project: project)
notes = described_class.new(project, create(:user)).execute
@@ -95,7 +95,7 @@ describe NotesFinder do
expect(notes.count).to eq(0)
end
- it 'publicly excludes notes on snippets' do
+ it "publicly excludes notes on snippets" do
create(:note_on_project_snippet, project: project)
notes = described_class.new(project, create(:user)).execute
@@ -104,89 +104,89 @@ describe NotesFinder do
end
end
- context 'for target type' do
+ context "for target type" do
let(:project) { create(:project, :repository) }
let!(:note1) { create :note_on_issue, project: project }
let!(:note2) { create :note_on_commit, project: project }
- it 'finds only notes for the selected type' do
- notes = described_class.new(project, user, target_type: 'issue').execute
+ it "finds only notes for the selected type" do
+ notes = described_class.new(project, user, target_type: "issue").execute
expect(notes).to eq([note1])
end
end
- context 'for target' do
+ context "for target" do
let(:project) { create(:project, :repository) }
let(:note1) { create :note_on_commit, project: project }
let(:note2) { create :note_on_commit, project: project }
let(:commit) { note1.noteable }
- let(:params) { { target_id: commit.id, target_type: 'commit', last_fetched_at: 1.hour.ago.to_i } }
+ let(:params) { {target_id: commit.id, target_type: "commit", last_fetched_at: 1.hour.ago.to_i} }
before do
note1
note2
end
- it 'finds all notes' do
+ it "finds all notes" do
notes = described_class.new(project, user, params).execute
expect(notes.size).to eq(2)
end
- it 'finds notes on merge requests' do
+ it "finds notes on merge requests" do
note = create(:note_on_merge_request, project: project)
- params = { target_type: 'merge_request', target_id: note.noteable.id }
+ params = {target_type: "merge_request", target_id: note.noteable.id}
notes = described_class.new(project, user, params).execute
expect(notes).to include(note)
end
- it 'finds notes on snippets' do
+ it "finds notes on snippets" do
note = create(:note_on_project_snippet, project: project)
- params = { target_type: 'snippet', target_id: note.noteable.id }
+ params = {target_type: "snippet", target_id: note.noteable.id}
notes = described_class.new(project, user, params).execute
expect(notes.count).to eq(1)
end
- it 'finds notes on personal snippets' do
+ it "finds notes on personal snippets" do
note = create(:note_on_personal_snippet)
- params = { target_type: 'personal_snippet', target_id: note.noteable_id }
+ params = {target_type: "personal_snippet", target_id: note.noteable_id}
notes = described_class.new(project, user, params).execute
expect(notes.count).to eq(1)
end
- it 'raises an exception for an invalid target_type' do
- params[:target_type] = 'invalid'
+ it "raises an exception for an invalid target_type" do
+ params[:target_type] = "invalid"
expect { described_class.new(project, user, params).execute }.to raise_error("invalid target_type '#{params[:target_type]}'")
end
- it 'filters out old notes' do
+ it "filters out old notes" do
note2.update_attribute(:updated_at, 2.hours.ago)
notes = described_class.new(project, user, params).execute
expect(notes).to eq([note1])
end
- context 'confidential issue notes' do
+ context "confidential issue notes" do
let(:confidential_issue) { create(:issue, :confidential, project: project, author: user) }
let!(:confidential_note) { create(:note, noteable: confidential_issue, project: confidential_issue.project) }
- let(:params) { { target_id: confidential_issue.id, target_type: 'issue', last_fetched_at: 1.hour.ago.to_i } }
+ let(:params) { {target_id: confidential_issue.id, target_type: "issue", last_fetched_at: 1.hour.ago.to_i} }
- it 'returns notes if user can see the issue' do
+ it "returns notes if user can see the issue" do
expect(described_class.new(project, user, params).execute).to eq([confidential_note])
end
- it 'raises an error if user can not see the issue' do
+ it "raises an error if user can not see the issue" do
user = create(:user)
expect { described_class.new(project, user, params).execute }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises an error for project members with guest role' do
+ it "raises an error for project members with guest role" do
user = create(:user)
project.add_guest(user)
@@ -196,19 +196,19 @@ describe NotesFinder do
end
end
- describe '.search' do
+ describe ".search" do
let(:project) { create(:project, :public) }
- let(:note) { create(:note_on_issue, note: 'WoW', project: project) }
+ let(:note) { create(:note_on_issue, note: "WoW", project: project) }
- it 'returns notes with matching content' do
+ it "returns notes with matching content" do
expect(described_class.new(note.project, nil, search: note.note).execute).to eq([note])
end
- it 'returns notes with matching content regardless of the casing' do
- expect(described_class.new(note.project, nil, search: 'WOW').execute).to eq([note])
+ it "returns notes with matching content regardless of the casing" do
+ expect(described_class.new(note.project, nil, search: "WOW").execute).to eq([note])
end
- it 'returns commit notes user can access' do
+ it "returns commit notes user can access" do
note = create(:note_on_commit, project: project)
expect(described_class.new(note.project, create(:user), search: note.note).execute).to eq([note])
@@ -239,56 +239,56 @@ describe NotesFinder do
end
end
- context 'inlines SQL filters on subqueries for performance' do
+ context "inlines SQL filters on subqueries for performance" do
let(:sql) { described_class.new(note.project, nil, search: note.note).execute.to_sql }
let(:number_of_noteable_types) { 4 }
- specify 'project_id check' do
+ specify "project_id check" do
expect(sql.scan(/project_id/).count).to be >= (number_of_noteable_types + 2)
end
- specify 'search filter' do
+ specify "search filter" do
expect(sql.scan(/LIKE/).count).to be >= number_of_noteable_types
end
end
end
- describe '#target' do
+ describe "#target" do
subject { described_class.new(project, user, params) }
- context 'for a issue target' do
+ context "for a issue target" do
let(:issue) { create(:issue, project: project) }
- let(:params) { { target_type: 'issue', target_id: issue.id } }
+ let(:params) { {target_type: "issue", target_id: issue.id} }
- it 'returns the issue' do
+ it "returns the issue" do
expect(subject.target).to eq(issue)
end
end
- context 'for a merge request target' do
+ context "for a merge request target" do
let(:merge_request) { create(:merge_request, source_project: project) }
- let(:params) { { target_type: 'merge_request', target_id: merge_request.id } }
+ let(:params) { {target_type: "merge_request", target_id: merge_request.id} }
- it 'returns the merge_request' do
+ it "returns the merge_request" do
expect(subject.target).to eq(merge_request)
end
end
- context 'for a snippet target' do
+ context "for a snippet target" do
let(:snippet) { create(:project_snippet, project: project) }
- let(:params) { { target_type: 'snippet', target_id: snippet.id } }
+ let(:params) { {target_type: "snippet", target_id: snippet.id} }
- it 'returns the snippet' do
+ it "returns the snippet" do
expect(subject.target).to eq(snippet)
end
end
- context 'for a commit target' do
+ context "for a commit target" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
- let(:params) { { target_type: 'commit', target_id: commit.id } }
+ let(:params) { {target_type: "commit", target_id: commit.id} }
- it 'returns the commit' do
+ it "returns the commit" do
expect(subject.target).to eq(commit)
end
end
diff --git a/spec/finders/pending_todos_finder_spec.rb b/spec/finders/pending_todos_finder_spec.rb
index b41b1b46a93..d804b3ad900 100644
--- a/spec/finders/pending_todos_finder_spec.rb
+++ b/spec/finders/pending_todos_finder_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe PendingTodosFinder do
let(:user) { create(:user) }
- describe '#execute' do
- it 'returns only pending todos' do
+ describe "#execute" do
+ it "returns only pending todos" do
create(:todo, :done, user: user)
todo = create(:todo, :pending, user: user)
@@ -15,7 +15,7 @@ describe PendingTodosFinder do
expect(todos).to eq([todo])
end
- it 'supports retrieving of todos for a specific project' do
+ it "supports retrieving of todos for a specific project" do
project1 = create(:project)
project2 = create(:project)
@@ -27,7 +27,7 @@ describe PendingTodosFinder do
expect(todos).to eq([todo])
end
- it 'supports retrieving of todos for a specific todo target' do
+ it "supports retrieving of todos for a specific todo target" do
issue = create(:issue)
note = create(:note)
todo = create(:todo, :pending, user: user, target: issue)
@@ -39,7 +39,7 @@ describe PendingTodosFinder do
expect(todos).to eq([todo])
end
- it 'supports retrieving of todos for a specific target type' do
+ it "supports retrieving of todos for a specific target type" do
issue = create(:issue)
note = create(:note)
todo = create(:todo, :pending, user: user, target: issue)
@@ -51,11 +51,11 @@ describe PendingTodosFinder do
expect(todos).to eq([todo])
end
- it 'supports retrieving of todos for a specific commit ID' do
- create(:todo, :pending, user: user, commit_id: '456')
+ it "supports retrieving of todos for a specific commit ID" do
+ create(:todo, :pending, user: user, commit_id: "456")
- todo = create(:todo, :pending, user: user, commit_id: '123')
- todos = described_class.new(user, commit_id: '123').execute
+ todo = create(:todo, :pending, user: user, commit_id: "123")
+ todos = described_class.new(user, commit_id: "123").execute
expect(todos).to eq([todo])
end
diff --git a/spec/finders/personal_access_tokens_finder_spec.rb b/spec/finders/personal_access_tokens_finder_spec.rb
index 3e849c9a644..6e32451df0a 100644
--- a/spec/finders/personal_access_tokens_finder_spec.rb
+++ b/spec/finders/personal_access_tokens_finder_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe PersonalAccessTokensFinder do
def finder(options = {})
described_class.new(options)
end
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:params) { {} }
let!(:active_personal_access_token) { create(:personal_access_token, user: user) }
@@ -17,72 +17,72 @@ describe PersonalAccessTokensFinder do
subject { finder(params).execute }
- describe 'without user' do
+ describe "without user" do
it do
is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token,
revoked_personal_access_token, expired_personal_access_token,
revoked_impersonation_token, expired_impersonation_token)
end
- describe 'without impersonation' do
+ describe "without impersonation" do
before do
params[:impersonation] = false
end
it { is_expected.to contain_exactly(active_personal_access_token, revoked_personal_access_token, expired_personal_access_token) }
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_personal_access_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it { is_expected.to contain_exactly(revoked_personal_access_token, expired_personal_access_token) }
end
end
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
it { is_expected.to contain_exactly(active_impersonation_token, revoked_impersonation_token, expired_impersonation_token) }
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_impersonation_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it { is_expected.to contain_exactly(revoked_impersonation_token, expired_impersonation_token) }
end
end
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it do
@@ -91,12 +91,12 @@ describe PersonalAccessTokensFinder do
end
end
- describe 'with id' do
+ describe "with id" do
subject { finder(params).find_by_id(active_personal_access_token.id) }
it { is_expected.to eq(active_personal_access_token) }
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
@@ -105,12 +105,12 @@ describe PersonalAccessTokensFinder do
end
end
- describe 'with token' do
+ describe "with token" do
subject { finder(params).find_by_token(active_personal_access_token.token) }
it { is_expected.to eq(active_personal_access_token) }
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
@@ -120,7 +120,7 @@ describe PersonalAccessTokensFinder do
end
end
- describe 'with user' do
+ describe "with user" do
let(:user2) { create(:user) }
let!(:other_user_active_personal_access_token) { create(:personal_access_token, user: user2) }
let!(:other_user_expired_personal_access_token) { create(:personal_access_token, :expired, user: user2) }
@@ -139,65 +139,65 @@ describe PersonalAccessTokensFinder do
revoked_impersonation_token, expired_impersonation_token)
end
- describe 'without impersonation' do
+ describe "without impersonation" do
before do
params[:impersonation] = false
end
it { is_expected.to contain_exactly(active_personal_access_token, revoked_personal_access_token, expired_personal_access_token) }
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_personal_access_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it { is_expected.to contain_exactly(revoked_personal_access_token, expired_personal_access_token) }
end
end
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
it { is_expected.to contain_exactly(active_impersonation_token, revoked_impersonation_token, expired_impersonation_token) }
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_impersonation_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it { is_expected.to contain_exactly(revoked_impersonation_token, expired_impersonation_token) }
end
end
- describe 'with active state' do
+ describe "with active state" do
before do
- params[:state] = 'active'
+ params[:state] = "active"
end
it { is_expected.to contain_exactly(active_personal_access_token, active_impersonation_token) }
end
- describe 'with inactive state' do
+ describe "with inactive state" do
before do
- params[:state] = 'inactive'
+ params[:state] = "inactive"
end
it do
@@ -206,12 +206,12 @@ describe PersonalAccessTokensFinder do
end
end
- describe 'with id' do
+ describe "with id" do
subject { finder(params).find_by_id(active_personal_access_token.id) }
it { is_expected.to eq(active_personal_access_token) }
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
@@ -220,12 +220,12 @@ describe PersonalAccessTokensFinder do
end
end
- describe 'with token' do
+ describe "with token" do
subject { finder(params).find_by_token(active_personal_access_token.token) }
it { is_expected.to eq(active_personal_access_token) }
- describe 'with impersonation' do
+ describe "with impersonation" do
before do
params[:impersonation] = true
end
diff --git a/spec/finders/personal_projects_finder_spec.rb b/spec/finders/personal_projects_finder_spec.rb
index ef7dd0cd4a8..9452e2e07c5 100644
--- a/spec/finders/personal_projects_finder_spec.rb
+++ b/spec/finders/personal_projects_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PersonalProjectsFinder do
let(:source_user) { create(:user) }
@@ -9,31 +9,31 @@ describe PersonalProjectsFinder do
end
let!(:private_project) do
- create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep')
+ create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: "mepmep")
end
let!(:internal_project) do
- create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C')
+ create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: "C")
end
before do
private_project.add_developer(current_user)
end
- describe 'without a current user' do
+ describe "without a current user" do
subject { finder.execute }
it { is_expected.to eq([public_project]) }
end
- describe 'with a current user' do
+ describe "with a current user" do
subject { finder.execute(current_user) }
- context 'normal user' do
+ context "normal user" do
it { is_expected.to eq([public_project, internal_project, private_project]) }
end
- context 'external' do
+ context "external" do
before do
current_user.update(external: true)
end
diff --git a/spec/finders/pipeline_schedules_finder_spec.rb b/spec/finders/pipeline_schedules_finder_spec.rb
index 2fefa0280d1..327fffc34fd 100644
--- a/spec/finders/pipeline_schedules_finder_spec.rb
+++ b/spec/finders/pipeline_schedules_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineSchedulesFinder do
let(:project) { create(:project) }
@@ -9,29 +9,29 @@ describe PipelineSchedulesFinder do
subject { described_class.new(project).execute(params) }
describe "#execute" do
- context 'when the scope is nil' do
- let(:params) { { scope: nil } }
+ context "when the scope is nil" do
+ let(:params) { {scope: nil} }
- it 'selects all pipeline schedules' do
+ it "selects all pipeline schedules" do
expect(subject.count).to be(2)
expect(subject).to include(active_schedule, inactive_schedule)
end
end
- context 'when the scope is active' do
- let(:params) { { scope: 'active' } }
+ context "when the scope is active" do
+ let(:params) { {scope: "active"} }
- it 'selects only active pipelines' do
+ it "selects only active pipelines" do
expect(subject.count).to be(1)
expect(subject).to include(active_schedule)
expect(subject).not_to include(inactive_schedule)
end
end
- context 'when the scope is inactve' do
- let(:params) { { scope: 'inactive' } }
+ context "when the scope is inactve" do
+ let(:params) { {scope: "inactive"} }
- it 'selects only inactive pipelines' do
+ it "selects only inactive pipelines" do
expect(subject.count).to be(1)
expect(subject).not_to include(active_schedule)
expect(subject).to include(inactive_schedule)
diff --git a/spec/finders/pipelines_finder_spec.rb b/spec/finders/pipelines_finder_spec.rb
index c2c304589c9..9ec1328d639 100644
--- a/spec/finders/pipelines_finder_spec.rb
+++ b/spec/finders/pipelines_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelinesFinder do
let(:project) { create(:project, :public, :repository) }
@@ -7,55 +7,55 @@ describe PipelinesFinder do
subject { described_class.new(project, current_user, params).execute }
describe "#execute" do
- context 'when params is empty' do
+ context "when params is empty" do
let(:params) { {} }
let!(:pipelines) { create_list(:ci_pipeline, 2, project: project) }
- it 'returns all pipelines' do
+ it "returns all pipelines" do
is_expected.to match_array(pipelines)
end
end
%w[running pending].each do |target|
context "when scope is #{target}" do
- let(:params) { { scope: target } }
+ let(:params) { {scope: target} }
let!(:pipeline) { create(:ci_pipeline, project: project, status: target) }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
end
- context 'when scope is finished' do
- let(:params) { { scope: 'finished' } }
+ context "when scope is finished" do
+ let(:params) { {scope: "finished"} }
let!(:pipelines) do
- [create(:ci_pipeline, project: project, status: 'success'),
- create(:ci_pipeline, project: project, status: 'failed'),
- create(:ci_pipeline, project: project, status: 'canceled')]
+ [create(:ci_pipeline, project: project, status: "success"),
+ create(:ci_pipeline, project: project, status: "failed"),
+ create(:ci_pipeline, project: project, status: "canceled"),]
end
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to match_array(pipelines)
end
end
- context 'when scope is branches or tags' do
+ context "when scope is branches or tags" do
let!(:pipeline_branch) { create(:ci_pipeline, project: project) }
- let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) }
+ let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: "v1.0.0", tag: true) }
- context 'when scope is branches' do
- let(:params) { { scope: 'branches' } }
+ context "when scope is branches" do
+ let(:params) { {scope: "branches"} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline_branch])
end
end
- context 'when scope is tags' do
- let(:params) { { scope: 'tags' } }
+ context "when scope is tags" do
+ let(:params) { {scope: "tags"} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline_tag])
end
end
@@ -63,7 +63,7 @@ describe PipelinesFinder do
HasStatus::AVAILABLE_STATUSES.each do |target|
context "when status is #{target}" do
- let(:params) { { status: target } }
+ let(:params) { {status: target} }
let!(:pipeline) { create(:ci_pipeline, project: project, status: target) }
before do
@@ -71,177 +71,177 @@ describe PipelinesFinder do
create(:ci_pipeline, project: project, status: exception_status.first)
end
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
end
- context 'when ref is specified' do
+ context "when ref is specified" do
let!(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when ref exists' do
- let(:params) { { ref: 'master' } }
+ context "when ref exists" do
+ let(:params) { {ref: "master"} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
- context 'when ref does not exist' do
- let(:params) { { ref: 'invalid-ref' } }
+ context "when ref does not exist" do
+ let(:params) { {ref: "invalid-ref"} }
- it 'returns empty' do
+ it "returns empty" do
is_expected.to be_empty
end
end
end
- context 'when name is specified' do
+ context "when name is specified" do
let(:user) { create(:user) }
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
- context 'when name exists' do
- let(:params) { { name: user.name } }
+ context "when name exists" do
+ let(:params) { {name: user.name} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
- context 'when name does not exist' do
- let(:params) { { name: 'invalid-name' } }
+ context "when name does not exist" do
+ let(:params) { {name: "invalid-name"} }
- it 'returns empty' do
+ it "returns empty" do
is_expected.to be_empty
end
end
end
- context 'when username is specified' do
+ context "when username is specified" do
let(:user) { create(:user) }
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
- context 'when username exists' do
- let(:params) { { username: user.username } }
+ context "when username exists" do
+ let(:params) { {username: user.username} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
- context 'when username does not exist' do
- let(:params) { { username: 'invalid-username' } }
+ context "when username does not exist" do
+ let(:params) { {username: "invalid-username"} }
- it 'returns empty' do
+ it "returns empty" do
is_expected.to be_empty
end
end
end
- context 'when yaml_errors is specified' do
- let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') }
+ context "when yaml_errors is specified" do
+ let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: "Syntax error") }
let!(:pipeline2) { create(:ci_pipeline, project: project) }
- context 'when yaml_errors is true' do
- let(:params) { { yaml_errors: true } }
+ context "when yaml_errors is true" do
+ let(:params) { {yaml_errors: true} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline1])
end
end
- context 'when yaml_errors is false' do
- let(:params) { { yaml_errors: false } }
+ context "when yaml_errors is false" do
+ let(:params) { {yaml_errors: false} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline2])
end
end
- context 'when yaml_errors is invalid' do
- let(:params) { { yaml_errors: "invalid-yaml_errors" } }
+ context "when yaml_errors is invalid" do
+ let(:params) { {yaml_errors: "invalid-yaml_errors"} }
- it 'returns all pipelines' do
+ it "returns all pipelines" do
is_expected.to match_array([pipeline1, pipeline2])
end
end
end
- context 'when order_by and sort are specified' do
- context 'when order_by user_id' do
- let(:params) { { order_by: 'user_id', sort: 'asc' } }
+ context "when order_by and sort are specified" do
+ context "when order_by user_id" do
+ let(:params) { {order_by: "user_id", sort: "asc"} }
let!(:pipelines) { Array.new(2) { create(:ci_pipeline, project: project, user: create(:user)) } }
- it 'sorts as user_id: :asc' do
+ it "sorts as user_id: :asc" do
is_expected.to match_array(pipelines)
end
- context 'when sort is invalid' do
- let(:params) { { order_by: 'user_id', sort: 'invalid_sort' } }
+ context "when sort is invalid" do
+ let(:params) { {order_by: "user_id", sort: "invalid_sort"} }
- it 'sorts as user_id: :desc' do
+ it "sorts as user_id: :desc" do
is_expected.to eq(pipelines.sort_by { |p| -p.user.id })
end
end
end
- context 'when order_by is invalid' do
- let(:params) { { order_by: 'invalid_column', sort: 'asc' } }
+ context "when order_by is invalid" do
+ let(:params) { {order_by: "invalid_column", sort: "asc"} }
let!(:pipelines) { create_list(:ci_pipeline, 2, project: project) }
- it 'sorts as id: :asc' do
+ it "sorts as id: :asc" do
is_expected.to eq(pipelines.sort_by { |p| p.id })
end
end
- context 'when both are nil' do
- let(:params) { { order_by: nil, sort: nil } }
+ context "when both are nil" do
+ let(:params) { {order_by: nil, sort: nil} }
let!(:pipelines) { create_list(:ci_pipeline, 2, project: project) }
- it 'sorts as id: :desc' do
+ it "sorts as id: :desc" do
is_expected.to eq(pipelines.sort_by { |p| -p.id })
end
end
end
- context 'when sha is specified' do
- let!(:pipeline) { create(:ci_pipeline, project: project, sha: '97de212e80737a608d939f648d959671fb0a0142') }
+ context "when sha is specified" do
+ let!(:pipeline) { create(:ci_pipeline, project: project, sha: "97de212e80737a608d939f648d959671fb0a0142") }
- context 'when sha exists' do
- let(:params) { { sha: '97de212e80737a608d939f648d959671fb0a0142' } }
+ context "when sha exists" do
+ let(:params) { {sha: "97de212e80737a608d939f648d959671fb0a0142"} }
- it 'returns matched pipelines' do
+ it "returns matched pipelines" do
is_expected.to eq([pipeline])
end
end
- context 'when sha does not exist' do
- let(:params) { { sha: 'invalid-sha' } }
+ context "when sha does not exist" do
+ let(:params) { {sha: "invalid-sha"} }
- it 'returns empty' do
+ it "returns empty" do
is_expected.to be_empty
end
end
end
- context 'when the project has limited access to pipelines' do
+ context "when the project has limited access to pipelines" do
let(:project) { create(:project, :private, :repository) }
let(:current_user) { create(:user) }
let!(:pipelines) { create_list(:ci_pipeline, 2, project: project) }
- context 'when the user has access' do
+ context "when the user has access" do
before do
project.add_developer(current_user)
end
- it 'is expected to return pipelines' do
+ it "is expected to return pipelines" do
is_expected.to contain_exactly(*pipelines)
end
end
- context 'the user is not allowed to read pipelines' do
- it 'returns empty' do
+ context "the user is not allowed to read pipelines" do
+ it "returns empty" do
is_expected.to be_empty
end
end
diff --git a/spec/finders/projects/serverless/functions_finder_spec.rb b/spec/finders/projects/serverless/functions_finder_spec.rb
index 35279906854..cc32aad971b 100644
--- a/spec/finders/projects/serverless/functions_finder_spec.rb
+++ b/spec/finders/projects/serverless/functions_finder_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Serverless::FunctionsFinder do
include KubernetesHelpers
@@ -22,36 +22,36 @@ describe Projects::Serverless::FunctionsFinder do
project.add_maintainer(user)
end
- describe 'retrieve data from knative' do
- it 'does not have knative installed' do
+ describe "retrieve data from knative" do
+ it "does not have knative installed" do
expect(described_class.new(project.clusters).execute).to be_empty
end
- context 'has knative installed' do
+ context "has knative installed" do
let!(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) }
let(:finder) { described_class.new(project.clusters) }
- it 'there are no functions' do
+ it "there are no functions" do
expect(finder.execute).to be_empty
end
- it 'there are functions', :use_clean_rails_memory_store_caching do
+ it "there are functions", :use_clean_rails_memory_store_caching do
stub_kubeclient_service_pods
stub_reactive_cache(knative,
{
services: kube_knative_services_body(namespace: namespace.namespace, name: cluster.project.name)["items"],
- pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"]
+ pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"],
})
expect(finder.execute).not_to be_empty
end
- it 'has a function', :use_clean_rails_memory_store_caching do
+ it "has a function", :use_clean_rails_memory_store_caching do
stub_kubeclient_service_pods
stub_reactive_cache(knative,
{
services: kube_knative_services_body(namespace: namespace.namespace, name: cluster.project.name)["items"],
- pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"]
+ pods: kube_knative_pods_body(cluster.project.name, namespace.namespace)["items"],
})
result = finder.service(cluster.environment_scope, cluster.project.name)
@@ -61,17 +61,17 @@ describe Projects::Serverless::FunctionsFinder do
end
end
- describe 'verify if knative is installed' do
- context 'knative is not installed' do
- it 'does not have knative installed' do
+ describe "verify if knative is installed" do
+ context "knative is not installed" do
+ it "does not have knative installed" do
expect(described_class.new(project.clusters).installed?).to be false
end
end
- context 'knative is installed' do
+ context "knative is installed" do
let!(:knative) { create(:clusters_applications_knative, :installed, cluster: cluster) }
- it 'does have knative installed' do
+ it "does have knative installed" do
expect(described_class.new(project.clusters).installed?).to be true
end
end
diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb
index ac866e49fcd..362e7877e3c 100644
--- a/spec/finders/projects_finder_spec.rb
+++ b/spec/finders/projects_finder_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectsFinder do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:group) { create(:group, :public) }
let!(:private_project) do
- create(:project, :private, name: 'A', path: 'A')
+ create(:project, :private, name: "A", path: "A")
end
let!(:internal_project) do
- create(:project, :internal, group: group, name: 'B', path: 'B')
+ create(:project, :internal, group: group, name: "B", path: "B")
end
let!(:public_project) do
- create(:project, :public, group: group, name: 'C', path: 'C')
+ create(:project, :public, group: group, name: "C", path: "C")
end
let!(:shared_project) do
- create(:project, :private, name: 'D', path: 'D')
+ create(:project, :private, name: "D", path: "D")
end
let(:params) { {} }
@@ -28,18 +28,18 @@ describe ProjectsFinder do
subject { finder.execute }
- describe 'without a user' do
+ describe "without a user" do
let(:current_user) { nil }
it { is_expected.to eq([public_project]) }
end
- describe 'with a user' do
- describe 'without private projects' do
+ describe "with a user" do
+ describe "without private projects" do
it { is_expected.to match_array([public_project, internal_project]) }
end
- describe 'with private projects' do
+ describe "with private projects" do
before do
private_project.add_maintainer(user)
end
@@ -48,110 +48,110 @@ describe ProjectsFinder do
end
end
- describe 'with project_ids_relation' do
+ describe "with project_ids_relation" do
let(:project_ids_relation) { Project.where(id: internal_project.id) }
it { is_expected.to eq([internal_project]) }
end
- describe 'filter by visibility_level' do
+ describe "filter by visibility_level" do
before do
private_project.add_maintainer(user)
end
- context 'private' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::PRIVATE } }
+ context "private" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::PRIVATE} }
it { is_expected.to eq([private_project]) }
end
- context 'internal' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::INTERNAL } }
+ context "internal" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::INTERNAL} }
it { is_expected.to eq([internal_project]) }
end
- context 'public' do
- let(:params) { { visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
+ context "public" do
+ let(:params) { {visibility_level: Gitlab::VisibilityLevel::PUBLIC} }
it { is_expected.to eq([public_project]) }
end
end
- describe 'filter by tags' do
+ describe "filter by tags" do
before do
- public_project.tag_list.add('foo')
+ public_project.tag_list.add("foo")
public_project.save!
end
- let(:params) { { tag: 'foo' } }
+ let(:params) { {tag: "foo"} }
it { is_expected.to eq([public_project]) }
end
- describe 'filter by personal' do
+ describe "filter by personal" do
let!(:personal_project) { create(:project, namespace: user.namespace) }
- let(:params) { { personal: true } }
+ let(:params) { {personal: true} }
it { is_expected.to eq([personal_project]) }
end
- describe 'filter by search' do
- let(:params) { { search: 'C' } }
+ describe "filter by search" do
+ let(:params) { {search: "C"} }
it { is_expected.to eq([public_project]) }
end
- describe 'filter by name for backward compatibility' do
- let(:params) { { name: 'C' } }
+ describe "filter by name for backward compatibility" do
+ let(:params) { {name: "C"} }
it { is_expected.to eq([public_project]) }
end
- describe 'filter by archived' do
- let!(:archived_project) { create(:project, :public, :archived, name: 'E', path: 'E') }
+ describe "filter by archived" do
+ let!(:archived_project) { create(:project, :public, :archived, name: "E", path: "E") }
- context 'non_archived=true' do
- let(:params) { { non_archived: true } }
+ context "non_archived=true" do
+ let(:params) { {non_archived: true} }
it { is_expected.to match_array([public_project, internal_project]) }
end
- context 'non_archived=false' do
- let(:params) { { non_archived: false } }
+ context "non_archived=false" do
+ let(:params) { {non_archived: false} }
it { is_expected.to match_array([public_project, internal_project, archived_project]) }
end
- describe 'filter by archived only' do
- let(:params) { { archived: 'only' } }
+ describe "filter by archived only" do
+ let(:params) { {archived: "only"} }
it { is_expected.to eq([archived_project]) }
end
- describe 'filter by archived for backward compatibility' do
- let(:params) { { archived: false } }
+ describe "filter by archived for backward compatibility" do
+ let(:params) { {archived: false} }
it { is_expected.to match_array([public_project, internal_project]) }
end
end
- describe 'filter by trending' do
+ describe "filter by trending" do
let!(:trending_project) { create(:trending_project, project: public_project) }
- let(:params) { { trending: true } }
+ let(:params) { {trending: true} }
it { is_expected.to eq([public_project]) }
end
- describe 'filter by owned' do
- let(:params) { { owned: true } }
+ describe "filter by owned" do
+ let(:params) { {owned: true} }
let!(:owned_project) { create(:project, :private, namespace: current_user.namespace) }
it { is_expected.to eq([owned_project]) }
end
- describe 'filter by non_public' do
- let(:params) { { non_public: true } }
+ describe "filter by non_public" do
+ let(:params) { {non_public: true} }
before do
private_project.add_developer(current_user)
end
@@ -159,30 +159,30 @@ describe ProjectsFinder do
it { is_expected.to eq([private_project]) }
end
- describe 'filter by starred' do
- let(:params) { { starred: true } }
+ describe "filter by starred" do
+ let(:params) { {starred: true} }
before do
current_user.toggle_star(public_project)
end
it { is_expected.to eq([public_project]) }
- it 'returns only projects the user has access to' do
+ it "returns only projects the user has access to" do
current_user.toggle_star(private_project)
is_expected.to eq([public_project])
end
end
- describe 'filter by without_deleted' do
- let(:params) { { without_deleted: true } }
+ describe "filter by without_deleted" do
+ let(:params) { {without_deleted: true} }
let!(:pending_delete_project) { create(:project, :public, pending_delete: true) }
it { is_expected.to match_array([public_project, internal_project]) }
end
- describe 'sorting' do
- let(:params) { { sort: 'name_asc' } }
+ describe "sorting" do
+ let(:params) { {sort: "name_asc"} }
it { is_expected.to eq([internal_project, public_project]) }
end
diff --git a/spec/finders/releases_finder_spec.rb b/spec/finders/releases_finder_spec.rb
index 32ee15134a2..dd063a16634 100644
--- a/spec/finders/releases_finder_spec.rb
+++ b/spec/finders/releases_finder_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ReleasesFinder do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- let(:v1_0_0) { create(:release, project: project, tag: 'v1.0.0') }
- let(:v1_1_0) { create(:release, project: project, tag: 'v1.1.0') }
+ let(:v1_0_0) { create(:release, project: project, tag: "v1.0.0") }
+ let(:v1_1_0) { create(:release, project: project, tag: "v1.1.0") }
subject { described_class.new(project, user)}
@@ -16,21 +16,21 @@ describe ReleasesFinder do
v1_1_0.update_attribute(:created_at, 1.day.ago)
end
- describe '#execute' do
- context 'when the user is not part of the project' do
- it 'returns no releases' do
+ describe "#execute" do
+ context "when the user is not part of the project" do
+ it "returns no releases" do
releases = subject.execute
expect(releases).to be_empty
end
end
- context 'when the user is a project developer' do
+ context "when the user is a project developer" do
before do
project.add_developer(user)
end
- it 'sorts by creation date' do
+ it "sorts by creation date" do
releases = subject.execute
expect(releases).to be_present
diff --git a/spec/finders/runner_jobs_finder_spec.rb b/spec/finders/runner_jobs_finder_spec.rb
index 97304170c4e..ffa2773f9f6 100644
--- a/spec/finders/runner_jobs_finder_spec.rb
+++ b/spec/finders/runner_jobs_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RunnerJobsFinder do
let(:project) { create(:project) }
@@ -6,22 +6,22 @@ describe RunnerJobsFinder do
subject { described_class.new(runner, params).execute }
- describe '#execute' do
- context 'when params is empty' do
+ describe "#execute" do
+ context "when params is empty" do
let(:params) { {} }
let!(:job) { create(:ci_build, runner: runner, project: project) }
let!(:job1) { create(:ci_build, project: project) }
- it 'returns all jobs assigned to Runner' do
+ it "returns all jobs assigned to Runner" do
is_expected.to match_array(job)
is_expected.not_to match_array(job1)
end
end
- context 'when params contains status' do
+ context "when params contains status" do
HasStatus::AVAILABLE_STATUSES.each do |target_status|
context "when status is #{target_status}" do
- let(:params) { { status: target_status } }
+ let(:params) { {status: target_status} }
let!(:job) { create(:ci_build, runner: runner, project: project, status: target_status) }
before do
@@ -29,7 +29,7 @@ describe RunnerJobsFinder do
create(:ci_build, runner: runner, project: project, status: exception_status.first)
end
- it 'returns matched job' do
+ it "returns matched job" do
is_expected.to eq([job])
end
end
diff --git a/spec/finders/snippets_finder_spec.rb b/spec/finders/snippets_finder_spec.rb
index 134fb5f2c04..1d978b5aebf 100644
--- a/spec/finders/snippets_finder_spec.rb
+++ b/spec/finders/snippets_finder_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe SnippetsFinder do
include Gitlab::Allowable
using RSpec::Parameterized::TableSyntax
- describe '#initialize' do
- it 'raises ArgumentError when a project and author are given' do
+ describe "#initialize" do
+ it "raises ArgumentError when a project and author are given" do
user = build(:user)
project = build(:project)
@@ -14,7 +14,7 @@ describe SnippetsFinder do
end
end
- context 'filter by scope' do
+ context "filter by scope" do
let(:user) { create :user }
let!(:snippet1) { create(:personal_snippet, :private, author: user) }
let!(:snippet2) { create(:personal_snippet, :internal, author: user) }
@@ -48,7 +48,7 @@ describe SnippetsFinder do
end
end
- context 'filter by author' do
+ context "filter by author" do
let(:user) { create :user }
let(:user1) { create :user }
let!(:snippet1) { create(:personal_snippet, :private, author: user) }
@@ -96,7 +96,7 @@ describe SnippetsFinder do
expect(snippets).not_to include(snippet2, snippet1)
end
- it 'returns all snippets for an admin' do
+ it "returns all snippets for an admin" do
admin = create(:user, :admin)
snippets = described_class.new(admin, author: user).execute
@@ -104,7 +104,7 @@ describe SnippetsFinder do
end
end
- context 'filter by project' do
+ context "filter by project" do
let(:user) { create :user }
let(:group) { create :group, :public }
let(:project1) { create(:project, :public, group: group) }
@@ -165,7 +165,7 @@ describe SnippetsFinder do
expect(snippets).to include(@snippet1)
end
- it 'returns all snippets for an admin' do
+ it "returns all snippets for an admin" do
admin = create(:user, :admin)
snippets = described_class.new(admin, project: project1).execute
@@ -173,28 +173,28 @@ describe SnippetsFinder do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project, :public) }
let!(:project_snippet) { create(:project_snippet, :public, project: project) }
let!(:personal_snippet) { create(:personal_snippet, :public) }
let(:user) { create(:user) }
subject(:finder) { described_class.new(user) }
- it 'returns project- and personal snippets' do
+ it "returns project- and personal snippets" do
expect(finder.execute).to contain_exactly(project_snippet, personal_snippet)
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
before do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
end
- it 'returns only personal snippets when the user cannot read cross project' do
+ it "returns only personal snippets when the user cannot read cross project" do
expect(finder.execute).to contain_exactly(personal_snippet)
end
end
end
- it_behaves_like 'snippet visibility'
+ it_behaves_like "snippet visibility"
end
diff --git a/spec/finders/tags_finder_spec.rb b/spec/finders/tags_finder_spec.rb
index 460e278e2d3..1c43c847925 100644
--- a/spec/finders/tags_finder_spec.rb
+++ b/spec/finders/tags_finder_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe TagsFinder do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- describe '#execute' do
- context 'sort only' do
- it 'sorts by name' do
+ describe "#execute" do
+ context "sort only" do
+ it "sorts by name" do
tags_finder = described_class.new(repository, {})
result = tags_finder.execute
@@ -15,38 +15,38 @@ describe TagsFinder do
expect(result.first.name).to eq("v1.0.0")
end
- it 'sorts by recently_updated' do
- tags_finder = described_class.new(repository, { sort: 'updated_desc' })
+ it "sorts by recently_updated" do
+ tags_finder = described_class.new(repository, {sort: "updated_desc"})
result = tags_finder.execute
- recently_updated_tag = repository.tags.max do |a, b|
+ recently_updated_tag = repository.tags.max { |a, b|
repository.commit(a.dereferenced_target).committed_date <=> repository.commit(b.dereferenced_target).committed_date
- end
+ }
expect(result.first.name).to eq(recently_updated_tag.name)
end
- it 'sorts by last_updated' do
- tags_finder = described_class.new(repository, { sort: 'updated_asc' })
+ it "sorts by last_updated" do
+ tags_finder = described_class.new(repository, {sort: "updated_asc"})
result = tags_finder.execute
- expect(result.first.name).to eq('v1.0.0')
+ expect(result.first.name).to eq("v1.0.0")
end
end
- context 'filter only' do
- it 'filters tags by name' do
- tags_finder = described_class.new(repository, { search: '1.0.0' })
+ context "filter only" do
+ it "filters tags by name" do
+ tags_finder = described_class.new(repository, {search: "1.0.0"})
result = tags_finder.execute
- expect(result.first.name).to eq('v1.0.0')
+ expect(result.first.name).to eq("v1.0.0")
expect(result.count).to eq(1)
end
- it 'does not find any tags with that name' do
- tags_finder = described_class.new(repository, { search: 'hey' })
+ it "does not find any tags with that name" do
+ tags_finder = described_class.new(repository, {search: "hey"})
result = tags_finder.execute
@@ -54,24 +54,24 @@ describe TagsFinder do
end
end
- context 'filter and sort' do
- it 'filters tags by name and sorts by recently_updated' do
- params = { sort: 'updated_desc', search: 'v1' }
+ context "filter and sort" do
+ it "filters tags by name and sorts by recently_updated" do
+ params = {sort: "updated_desc", search: "v1"}
tags_finder = described_class.new(repository, params)
result = tags_finder.execute
- expect(result.first.name).to eq('v1.1.0')
+ expect(result.first.name).to eq("v1.1.0")
expect(result.count).to eq(2)
end
- it 'filters tags by name and sorts by last_updated' do
- params = { sort: 'updated_asc', search: 'v1' }
+ it "filters tags by name and sorts by last_updated" do
+ params = {sort: "updated_asc", search: "v1"}
tags_finder = described_class.new(repository, params)
result = tags_finder.execute
- expect(result.first.name).to eq('v1.0.0')
+ expect(result.first.name).to eq("v1.0.0")
expect(result.count).to eq(2)
end
end
diff --git a/spec/finders/template_finder_spec.rb b/spec/finders/template_finder_spec.rb
index 114af9461e0..e72259c2239 100644
--- a/spec/finders/template_finder_spec.rb
+++ b/spec/finders/template_finder_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe TemplateFinder do
using RSpec::Parameterized::TableSyntax
- describe '#build' do
+ describe "#build" do
let(:project) { build_stubbed(:project) }
where(:type, :expected_class) do
@@ -21,28 +21,28 @@ describe TemplateFinder do
end
end
- describe '#execute' do
+ describe "#execute" do
where(:type, :vendored_name) do
- :dockerfiles | 'Binary'
- :gitignores | 'Actionscript'
- :gitlab_ci_ymls | 'Android'
+ :dockerfiles | "Binary"
+ :gitignores | "Actionscript"
+ :gitlab_ci_ymls | "Android"
end
with_them do
- it 'returns all vendored templates when no name is specified' do
+ it "returns all vendored templates when no name is specified" do
result = described_class.new(type, nil).execute
expect(result).to include(have_attributes(name: vendored_name))
end
- it 'returns only the specified vendored template when a name is specified' do
+ it "returns only the specified vendored template when a name is specified" do
result = described_class.new(type, nil, name: vendored_name).execute
expect(result).to have_attributes(name: vendored_name)
end
- it 'returns nil when an unknown name is specified' do
- result = described_class.new(type, nil, name: 'unknown').execute
+ it "returns nil when an unknown name is specified" do
+ result = described_class.new(type, nil, name: "unknown").execute
expect(result).to be_nil
end
diff --git a/spec/finders/todos_finder_spec.rb b/spec/finders/todos_finder_spec.rb
index d4ed41d54f0..594eefc00b3 100644
--- a/spec/finders/todos_finder_spec.rb
+++ b/spec/finders/todos_finder_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosFinder do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
@@ -13,35 +13,35 @@ describe TodosFinder do
group.add_developer(user)
end
- describe '#execute' do
- context 'filtering' do
+ describe "#execute" do
+ context "filtering" do
let!(:todo1) { create(:todo, user: user, project: project, target: issue) }
let!(:todo2) { create(:todo, user: user, group: group, target: merge_request) }
- it 'returns correct todos when filtered by a project' do
- todos = finder.new(user, { project_id: project.id }).execute
+ it "returns correct todos when filtered by a project" do
+ todos = finder.new(user, {project_id: project.id}).execute
expect(todos).to match_array([todo1])
end
- it 'returns correct todos when filtered by a group' do
- todos = finder.new(user, { group_id: group.id }).execute
+ it "returns correct todos when filtered by a group" do
+ todos = finder.new(user, {group_id: group.id}).execute
expect(todos).to match_array([todo1, todo2])
end
- it 'returns correct todos when filtered by a type' do
- todos = finder.new(user, { type: 'Issue' }).execute
+ it "returns correct todos when filtered by a type" do
+ todos = finder.new(user, {type: "Issue"}).execute
expect(todos).to match_array([todo1])
end
- context 'with subgroups', :nested_groups do
+ context "with subgroups", :nested_groups do
let(:subgroup) { create(:group, parent: group) }
let!(:todo3) { create(:todo, user: user, group: subgroup, target: issue) }
- it 'returns todos from subgroups when filtered by a group' do
- todos = finder.new(user, { group_id: group.id }).execute
+ it "returns todos from subgroups when filtered by a group" do
+ todos = finder.new(user, {group_id: group.id}).execute
expect(todos).to match_array([todo1, todo2, todo3])
end
@@ -49,22 +49,22 @@ describe TodosFinder do
end
end
- describe '#sort' do
- context 'by date' do
+ describe "#sort" do
+ context "by date" do
let!(:todo1) { create(:todo, user: user, project: project) }
let!(:todo2) { create(:todo, user: user, project: project) }
let!(:todo3) { create(:todo, user: user, project: project) }
- it 'sorts with oldest created first' do
- todos = finder.new(user, { sort: 'id_asc' }).execute
+ it "sorts with oldest created first" do
+ todos = finder.new(user, {sort: "id_asc"}).execute
expect(todos.first).to eq(todo1)
expect(todos.second).to eq(todo2)
expect(todos.third).to eq(todo3)
end
- it 'sorts with newest created first' do
- todos = finder.new(user, { sort: 'id_desc' }).execute
+ it "sorts with newest created first" do
+ todos = finder.new(user, {sort: "id_desc"}).execute
expect(todos.first).to eq(todo3)
expect(todos.second).to eq(todo2)
@@ -75,15 +75,15 @@ describe TodosFinder do
it "sorts by priority" do
project_2 = create(:project)
- label_1 = create(:label, title: 'label_1', project: project, priority: 1)
- label_2 = create(:label, title: 'label_2', project: project, priority: 2)
- label_3 = create(:label, title: 'label_3', project: project, priority: 3)
- label_1_2 = create(:label, title: 'label_1', project: project_2, priority: 1)
+ label_1 = create(:label, title: "label_1", project: project, priority: 1)
+ label_2 = create(:label, title: "label_2", project: project, priority: 2)
+ label_3 = create(:label, title: "label_3", project: project, priority: 3)
+ label_1_2 = create(:label, title: "label_1", project: project_2, priority: 1)
- issue_1 = create(:issue, title: 'issue_1', project: project)
- issue_2 = create(:issue, title: 'issue_2', project: project)
- issue_3 = create(:issue, title: 'issue_3', project: project)
- issue_4 = create(:issue, title: 'issue_4', project: project)
+ issue_1 = create(:issue, title: "issue_1", project: project)
+ issue_2 = create(:issue, title: "issue_2", project: project)
+ issue_3 = create(:issue, title: "issue_3", project: project)
+ issue_4 = create(:issue, title: "issue_4", project: project)
merge_request_1 = create(:merge_request, source_project: project_2)
merge_request_1.labels << label_1_2
@@ -103,22 +103,22 @@ describe TodosFinder do
project_2.add_developer(user)
- todos = finder.new(user, { sort: 'priority' }).execute
+ todos = finder.new(user, {sort: "priority"}).execute
expect(todos).to eq([todo_3, todo_5, todo_4, todo_2, todo_1])
end
end
end
- describe '#any_for_target?' do
- it 'returns true if there are any todos for the given target' do
+ describe "#any_for_target?" do
+ it "returns true if there are any todos for the given target" do
todo = create(:todo, :pending)
finder = described_class.new(todo.user)
expect(finder.any_for_target?(todo.target)).to eq(true)
end
- it 'returns false if there are no todos for the given target' do
+ it "returns false if there are no todos for the given target" do
issue = create(:issue)
finder = described_class.new(issue.author)
diff --git a/spec/finders/user_finder_spec.rb b/spec/finders/user_finder_spec.rb
index 4771b878b8e..564c776869b 100644
--- a/spec/finders/user_finder_spec.rb
+++ b/spec/finders/user_finder_spec.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe UserFinder do
set(:user) { create(:user) }
- describe '#find_by_id' do
- context 'when the user exists' do
- it 'returns the user' do
+ describe "#find_by_id" do
+ context "when the user exists" do
+ it "returns the user" do
found = described_class.new(user.id).find_by_id
expect(found).to eq(user)
end
end
- context 'when the user exists (id as string)' do
- it 'returns the user' do
+ context "when the user exists (id as string)" do
+ it "returns the user" do
found = described_class.new(user.id.to_s).find_by_id
expect(found).to eq(user)
end
end
- context 'when the user does not exist' do
- it 'returns nil' do
+ context "when the user does not exist" do
+ it "returns nil" do
found = described_class.new(1).find_by_id
expect(found).to be_nil
@@ -31,17 +31,17 @@ describe UserFinder do
end
end
- describe '#find_by_username' do
- context 'when the user exists' do
- it 'returns the user' do
+ describe "#find_by_username" do
+ context "when the user exists" do
+ it "returns the user" do
found = described_class.new(user.username).find_by_username
expect(found).to eq(user)
end
end
- context 'when the user does not exist' do
- it 'returns nil' do
+ context "when the user does not exist" do
+ it "returns nil" do
found = described_class.new("non_existent_username").find_by_username
expect(found).to be_nil
@@ -49,41 +49,41 @@ describe UserFinder do
end
end
- describe '#find_by_id_or_username' do
- context 'when the user exists (id)' do
- it 'returns the user' do
+ describe "#find_by_id_or_username" do
+ context "when the user exists (id)" do
+ it "returns the user" do
found = described_class.new(user.id).find_by_id_or_username
expect(found).to eq(user)
end
end
- context 'when the user exists (id as string)' do
- it 'returns the user' do
+ context "when the user exists (id as string)" do
+ it "returns the user" do
found = described_class.new(user.id.to_s).find_by_id_or_username
expect(found).to eq(user)
end
end
- context 'when the user exists (username)' do
- it 'returns the user' do
+ context "when the user exists (username)" do
+ it "returns the user" do
found = described_class.new(user.username).find_by_id_or_username
expect(found).to eq(user)
end
end
- context 'when the user does not exist (username)' do
- it 'returns nil' do
+ context "when the user does not exist (username)" do
+ it "returns nil" do
found = described_class.new("non_existent_username").find_by_id_or_username
expect(found).to be_nil
end
end
- context 'when the user does not exist' do
- it 'returns nil' do
+ context "when the user does not exist" do
+ it "returns nil" do
found = described_class.new(1).find_by_id_or_username
expect(found).to be_nil
@@ -91,25 +91,25 @@ describe UserFinder do
end
end
- describe '#find_by_id!' do
- context 'when the user exists' do
- it 'returns the user' do
+ describe "#find_by_id!" do
+ context "when the user exists" do
+ it "returns the user" do
found = described_class.new(user.id).find_by_id!
expect(found).to eq(user)
end
end
- context 'when the user exists (id as string)' do
- it 'returns the user' do
+ context "when the user exists (id as string)" do
+ it "returns the user" do
found = described_class.new(user.id.to_s).find_by_id!
expect(found).to eq(user)
end
end
- context 'when the user does not exist' do
- it 'raises ActiveRecord::RecordNotFound' do
+ context "when the user does not exist" do
+ it "raises ActiveRecord::RecordNotFound" do
finder = described_class.new(1)
expect { finder.find_by_id! }.to raise_error(ActiveRecord::RecordNotFound)
@@ -117,17 +117,17 @@ describe UserFinder do
end
end
- describe '#find_by_username!' do
- context 'when the user exists' do
- it 'returns the user' do
+ describe "#find_by_username!" do
+ context "when the user exists" do
+ it "returns the user" do
found = described_class.new(user.username).find_by_username!
expect(found).to eq(user)
end
end
- context 'when the user does not exist' do
- it 'raises ActiveRecord::RecordNotFound' do
+ context "when the user does not exist" do
+ it "raises ActiveRecord::RecordNotFound" do
finder = described_class.new("non_existent_username")
expect { finder.find_by_username! }.to raise_error(ActiveRecord::RecordNotFound)
@@ -135,41 +135,41 @@ describe UserFinder do
end
end
- describe '#find_by_id_or_username!' do
- context 'when the user exists (id)' do
- it 'returns the user' do
+ describe "#find_by_id_or_username!" do
+ context "when the user exists (id)" do
+ it "returns the user" do
found = described_class.new(user.id).find_by_id_or_username!
expect(found).to eq(user)
end
end
- context 'when the user exists (id as string)' do
- it 'returns the user' do
+ context "when the user exists (id as string)" do
+ it "returns the user" do
found = described_class.new(user.id.to_s).find_by_id_or_username!
expect(found).to eq(user)
end
end
- context 'when the user exists (username)' do
- it 'returns the user' do
+ context "when the user exists (username)" do
+ it "returns the user" do
found = described_class.new(user.username).find_by_id_or_username!
expect(found).to eq(user)
end
end
- context 'when the user does not exist (username)' do
- it 'raises ActiveRecord::RecordNotFound' do
+ context "when the user does not exist (username)" do
+ it "raises ActiveRecord::RecordNotFound" do
finder = described_class.new("non_existent_username")
expect { finder.find_by_id_or_username! }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- context 'when the user does not exist' do
- it 'raises ActiveRecord::RecordNotFound' do
+ context "when the user does not exist" do
+ it "raises ActiveRecord::RecordNotFound" do
finder = described_class.new(1)
expect { finder.find_by_id_or_username! }.to raise_error(ActiveRecord::RecordNotFound)
diff --git a/spec/finders/user_recent_events_finder_spec.rb b/spec/finders/user_recent_events_finder_spec.rb
index 5ebceeb7586..0c544163483 100644
--- a/spec/finders/user_recent_events_finder_spec.rb
+++ b/spec/finders/user_recent_events_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UserRecentEventsFinder do
let(:current_user) { create(:user) }
@@ -12,15 +12,15 @@ describe UserRecentEventsFinder do
subject(:finder) { described_class.new(current_user, project_owner) }
- describe '#execute' do
- context 'when profile is public' do
- it 'returns all the events' do
+ describe "#execute" do
+ context "when profile is public" do
+ it "returns all the events" do
expect(finder.execute).to include(private_event, internal_event, public_event)
end
end
- context 'when profile is private' do
- it 'returns no event' do
+ context "when profile is private" do
+ it "returns no event" do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, project_owner).and_return(false)
@@ -28,7 +28,7 @@ describe UserRecentEventsFinder do
end
end
- it 'does not include the events if the user cannot read cross project' do
+ it "does not include the events if the user cannot read cross project" do
allow(Ability).to receive(:allowed?).and_call_original
expect(Ability).to receive(:allowed?).with(current_user, :read_cross_project) { false }
diff --git a/spec/finders/users_finder_spec.rb b/spec/finders/users_finder_spec.rb
index fecf97dc641..39029e5165f 100644
--- a/spec/finders/users_finder_spec.rb
+++ b/spec/finders/users_finder_spec.rb
@@ -1,101 +1,101 @@
-require 'spec_helper'
+require "spec_helper"
describe UsersFinder do
- describe '#execute' do
- let!(:user1) { create(:user, username: 'johndoe') }
- let!(:user2) { create(:user, :blocked, username: 'notsorandom') }
+ describe "#execute" do
+ let!(:user1) { create(:user, username: "johndoe") }
+ let!(:user2) { create(:user, :blocked, username: "notsorandom") }
let!(:external_user) { create(:user, :external) }
- let!(:omniauth_user) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
+ let!(:omniauth_user) { create(:omniauth_user, provider: "twitter", extern_uid: "123456") }
- context 'with a normal user' do
+ context "with a normal user" do
let(:user) { create(:user) }
- it 'returns all users' do
+ it "returns all users" do
users = described_class.new(user).execute
expect(users).to contain_exactly(user, user1, user2, omniauth_user)
end
- it 'filters by username' do
- users = described_class.new(user, username: 'johndoe').execute
+ it "filters by username" do
+ users = described_class.new(user, username: "johndoe").execute
expect(users).to contain_exactly(user1)
end
- it 'filters by username (case insensitive)' do
- users = described_class.new(user, username: 'joHNdoE').execute
+ it "filters by username (case insensitive)" do
+ users = described_class.new(user, username: "joHNdoE").execute
expect(users).to contain_exactly(user1)
end
- it 'filters by search' do
- users = described_class.new(user, search: 'orando').execute
+ it "filters by search" do
+ users = described_class.new(user, search: "orando").execute
expect(users).to contain_exactly(user2)
end
- it 'filters by blocked users' do
+ it "filters by blocked users" do
users = described_class.new(user, blocked: true).execute
expect(users).to contain_exactly(user2)
end
- it 'filters by active users' do
+ it "filters by active users" do
users = described_class.new(user, active: true).execute
expect(users).to contain_exactly(user, user1, omniauth_user)
end
- it 'returns no external users' do
+ it "returns no external users" do
users = described_class.new(user, external: true).execute
expect(users).to contain_exactly(user, user1, user2, omniauth_user)
end
- it 'filters by created_at' do
+ it "filters by created_at" do
filtered_user_before = create(:user, created_at: 3.days.ago)
filtered_user_after = create(:user, created_at: Time.now + 3.days)
users = described_class.new(user,
- created_after: 2.days.ago,
- created_before: Time.now + 2.days).execute
+ created_after: 2.days.ago,
+ created_before: Time.now + 2.days).execute
expect(users.map(&:username)).not_to include([filtered_user_before.username, filtered_user_after.username])
end
- it 'does not filter by custom attributes' do
+ it "does not filter by custom attributes" do
users = described_class.new(
user,
- custom_attributes: { foo: 'bar' }
+ custom_attributes: {foo: "bar"}
).execute
expect(users).to contain_exactly(user, user1, user2, omniauth_user)
end
end
- context 'with an admin user' do
+ context "with an admin user" do
let(:admin) { create(:admin) }
- it 'filters by external users' do
+ it "filters by external users" do
users = described_class.new(admin, external: true).execute
expect(users).to contain_exactly(external_user)
end
- it 'returns all users' do
+ it "returns all users" do
users = described_class.new(admin).execute
expect(users).to contain_exactly(admin, user1, user2, external_user, omniauth_user)
end
- it 'filters by custom attributes' do
- create :user_custom_attribute, user: user1, key: 'foo', value: 'foo'
- create :user_custom_attribute, user: user1, key: 'bar', value: 'bar'
- create :user_custom_attribute, user: user2, key: 'foo', value: 'foo'
+ it "filters by custom attributes" do
+ create :user_custom_attribute, user: user1, key: "foo", value: "foo"
+ create :user_custom_attribute, user: user1, key: "bar", value: "bar"
+ create :user_custom_attribute, user: user2, key: "foo", value: "foo"
users = described_class.new(
admin,
- custom_attributes: { foo: 'foo', bar: 'bar' }
+ custom_attributes: {foo: "foo", bar: "bar"}
).execute
expect(users).to contain_exactly(user1)
diff --git a/spec/finders/users_with_pending_todos_finder_spec.rb b/spec/finders/users_with_pending_todos_finder_spec.rb
index fa15355531c..e4e4762f4e7 100644
--- a/spec/finders/users_with_pending_todos_finder_spec.rb
+++ b/spec/finders/users_with_pending_todos_finder_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe UsersWithPendingTodosFinder do
- describe '#execute' do
- it 'returns the users for all pending todos of a target' do
+ describe "#execute" do
+ it "returns the users for all pending todos of a target" do
issue = create(:issue)
note = create(:note)
todo = create(:todo, :pending, target: issue)
diff --git a/spec/graphql/features/authorization_spec.rb b/spec/graphql/features/authorization_spec.rb
index a229d29afa6..5b42d06d41f 100644
--- a/spec/graphql/features/authorization_spec.rb
+++ b/spec/graphql/features/authorization_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Gitlab::Graphql::Authorization' do
+describe "Gitlab::Graphql::Authorization" do
set(:user) { create(:user) }
- let(:test_object) { double(name: 'My name') }
+ let(:test_object) { double(name: "My name") }
let(:object_type) { object_type_class }
let(:query_type) { query_type_class(object_type, test_object) }
let(:schema) { schema_class(query_type) }
@@ -13,52 +13,52 @@ describe 'Gitlab::Graphql::Authorization' do
let(:execute) do
schema.execute(
query_string,
- context: { current_user: user },
+ context: {current_user: user},
variables: {}
)
end
- let(:result) { execute['data'] }
+ let(:result) { execute["data"] }
before do
# By default, disallow all permissions.
allow(Ability).to receive(:allowed?).and_return(false)
end
- describe 'authorizing with a single permission' do
- let(:query_string) { '{ singlePermission() { name } }' }
+ describe "authorizing with a single permission" do
+ let(:query_string) { "{ singlePermission() { name } }" }
- subject { result['singlePermission'] }
+ subject { result["singlePermission"] }
- it 'should return the protected field when user has permission' do
+ it "should return the protected field when user has permission" do
permit(:foo)
- expect(subject['name']).to eq(test_object.name)
+ expect(subject["name"]).to eq(test_object.name)
end
- it 'should return nil when user is not authorized' do
+ it "should return nil when user is not authorized" do
expect(subject).to be_nil
end
end
- describe 'authorizing with an Array of permissions' do
- let(:query_string) { '{ permissionCollection() { name } }' }
+ describe "authorizing with an Array of permissions" do
+ let(:query_string) { "{ permissionCollection() { name } }" }
- subject { result['permissionCollection'] }
+ subject { result["permissionCollection"] }
- it 'should return the protected field when user has all permissions' do
+ it "should return the protected field when user has all permissions" do
permit(:foo, :bar)
- expect(subject['name']).to eq(test_object.name)
+ expect(subject["name"]).to eq(test_object.name)
end
- it 'should return nil when user only has one of the permissions' do
+ it "should return nil when user only has one of the permissions" do
permit(:foo)
expect(subject).to be_nil
end
- it 'should return nil when user only has none of the permissions' do
+ it "should return nil when user only has none of the permissions" do
expect(subject).to be_nil
end
end
@@ -73,7 +73,7 @@ describe 'Gitlab::Graphql::Authorization' do
def object_type_class
Class.new(Types::BaseObject) do
- graphql_name 'TestObject'
+ graphql_name "TestObject"
field :name, GraphQL::STRING_TYPE, null: true
end
@@ -81,7 +81,7 @@ describe 'Gitlab::Graphql::Authorization' do
def query_type_class(type, object)
Class.new(Types::BaseObject) do
- graphql_name 'TestQuery'
+ graphql_name "TestQuery"
field :single_permission, type,
null: true,
diff --git a/spec/graphql/gitlab_schema_spec.rb b/spec/graphql/gitlab_schema_spec.rb
index b9ddb427e85..d6b91a81289 100644
--- a/spec/graphql/gitlab_schema_spec.rb
+++ b/spec/graphql/gitlab_schema_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe GitlabSchema do
- it 'uses batch loading' do
+ it "uses batch loading" do
expect(field_instrumenters).to include(BatchLoader::GraphQL)
end
- it 'enables the preload instrumenter' do
+ it "enables the preload instrumenter" do
expect(field_instrumenters).to include(BatchLoader::GraphQL)
end
- it 'enables the authorization instrumenter' do
+ it "enables the authorization instrumenter" do
expect(field_instrumenters).to include(instance_of(::Gitlab::Graphql::Authorize::Instrumentation))
end
- it 'enables using presenters' do
+ it "enables using presenters" do
expect(field_instrumenters).to include(instance_of(::Gitlab::Graphql::Present::Instrumentation))
end
- it 'has the base mutation' do
+ it "has the base mutation" do
expect(described_class.mutation).to eq(::Types::MutationType.to_graphql)
end
- it 'has the base query' do
+ it "has the base query" do
expect(described_class.query).to eq(::Types::QueryType.to_graphql)
end
- it 'paginates active record relations using `Gitlab::Graphql::Connections::KeysetConnection`' do
+ it "paginates active record relations using `Gitlab::Graphql::Connections::KeysetConnection`" do
connection = GraphQL::Relay::BaseConnection::CONNECTION_IMPLEMENTATIONS[ActiveRecord::Relation.name]
expect(connection).to eq(Gitlab::Graphql::Connections::KeysetConnection)
diff --git a/spec/graphql/mutations/concerns/mutations/resolves_project_spec.rb b/spec/graphql/mutations/concerns/mutations/resolves_project_spec.rb
index 19f5a8907a2..4ab4198c06c 100644
--- a/spec/graphql/mutations/concerns/mutations/resolves_project_spec.rb
+++ b/spec/graphql/mutations/concerns/mutations/resolves_project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Mutations::ResolvesProject do
let(:mutation_class) do
@@ -10,7 +10,7 @@ describe Mutations::ResolvesProject do
let(:context) { double }
subject(:mutation) { mutation_class.new(object: nil, context: context) }
- it 'uses the ProjectsResolver to resolve projects by path' do
+ it "uses the ProjectsResolver to resolve projects by path" do
project = create(:project)
expect(Resolvers::ProjectResolver).to receive(:new).with(object: nil, context: context).and_call_original
diff --git a/spec/graphql/mutations/merge_requests/set_wip_spec.rb b/spec/graphql/mutations/merge_requests/set_wip_spec.rb
index e600abf3941..55f614f8235 100644
--- a/spec/graphql/mutations/merge_requests/set_wip_spec.rb
+++ b/spec/graphql/mutations/merge_requests/set_wip_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Mutations::MergeRequests::SetWip do
let(:merge_request) { create(:merge_request) }
let(:user) { create(:user) }
- subject(:mutation) { described_class.new(object: nil, context: { current_user: user }) }
+ subject(:mutation) { described_class.new(object: nil, context: {current_user: user}) }
- describe '#resolve' do
+ describe "#resolve" do
let(:wip) { true }
let(:mutated_merge_request) { subject[:merge_request] }
subject { mutation.resolve(project_path: merge_request.project.full_path, iid: merge_request.iid, wip: wip) }
- it 'raises an error if the resource is not accessible to the user' do
+ it "raises an error if the resource is not accessible to the user" do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
- context 'when the user can update the merge request' do
+ context "when the user can update the merge request" do
before do
merge_request.project.add_developer(user)
end
- it 'returns the merge request as a wip' do
+ it "returns the merge request as a wip" do
expect(mutated_merge_request).to eq(merge_request)
expect(mutated_merge_request).to be_work_in_progress
expect(subject[:errors]).to be_empty
end
- it 'returns errors merge request could not be updated' do
+ it "returns errors merge request could not be updated" do
# Make the merge request invalid
merge_request.allow_broken = true
merge_request.update!(source_project: nil)
@@ -33,16 +33,16 @@ describe Mutations::MergeRequests::SetWip do
expect(subject[:errors]).not_to be_empty
end
- context 'when passing wip as false' do
+ context "when passing wip as false" do
let(:wip) { false }
- it 'removes `wip` from the title' do
+ it "removes `wip` from the title" do
merge_request.update(title: "WIP: working on it")
expect(mutated_merge_request).not_to be_work_in_progress
end
- it 'does not do anything if the title did not start with wip' do
+ it "does not do anything if the title did not start with wip" do
expect(mutated_merge_request).not_to be_work_in_progress
end
end
diff --git a/spec/graphql/resolvers/base_resolver_spec.rb b/spec/graphql/resolvers/base_resolver_spec.rb
index e3a34762b62..7160237de64 100644
--- a/spec/graphql/resolvers/base_resolver_spec.rb
+++ b/spec/graphql/resolvers/base_resolver_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::BaseResolver do
include GraphqlHelpers
@@ -13,17 +13,17 @@ describe Resolvers::BaseResolver do
end
end
- describe '.single' do
- it 'returns a subclass from the resolver' do
+ describe ".single" do
+ it "returns a subclass from the resolver" do
expect(resolver.single.superclass).to eq(resolver)
end
- it 'returns the same subclass every time' do
+ it "returns the same subclass every time" do
expect(resolver.single.object_id).to eq(resolver.single.object_id)
end
- it 'returns a resolver that gives the first result from the original resolver' do
- result = resolve(resolver.single, args: { test: 1 })
+ it "returns a resolver that gives the first result from the original resolver" do
+ result = resolve(resolver.single, args: {test: 1})
expect(result).to eq(test: 1)
end
diff --git a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
index ea7159eacf9..c84e2e8b60c 100644
--- a/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
+++ b/spec/graphql/resolvers/concerns/resolves_pipelines_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ResolvesPipelines do
include GraphqlHelpers
@@ -17,8 +17,8 @@ describe ResolvesPipelines do
set(:project) { create(:project, :private) }
set(:pipeline) { create(:ci_pipeline, project: project) }
set(:failed_pipeline) { create(:ci_pipeline, :failed, project: project) }
- set(:ref_pipeline) { create(:ci_pipeline, project: project, ref: 'awesome-feature') }
- set(:sha_pipeline) { create(:ci_pipeline, project: project, sha: 'deadbeef') }
+ set(:ref_pipeline) { create(:ci_pipeline, project: project, ref: "awesome-feature") }
+ set(:sha_pipeline) { create(:ci_pipeline, project: project, sha: "deadbeef") }
before do
project.add_developer(current_user)
@@ -26,27 +26,27 @@ describe ResolvesPipelines do
it { is_expected.to have_graphql_arguments(:status, :ref, :sha) }
- it 'finds all pipelines' do
+ it "finds all pipelines" do
expect(resolve_pipelines).to contain_exactly(pipeline, failed_pipeline, ref_pipeline, sha_pipeline)
end
- it 'allows filtering by status' do
- expect(resolve_pipelines(status: 'failed')).to contain_exactly(failed_pipeline)
+ it "allows filtering by status" do
+ expect(resolve_pipelines(status: "failed")).to contain_exactly(failed_pipeline)
end
- it 'allows filtering by ref' do
- expect(resolve_pipelines(ref: 'awesome-feature')).to contain_exactly(ref_pipeline)
+ it "allows filtering by ref" do
+ expect(resolve_pipelines(ref: "awesome-feature")).to contain_exactly(ref_pipeline)
end
- it 'allows filtering by sha' do
- expect(resolve_pipelines(sha: 'deadbeef')).to contain_exactly(sha_pipeline)
+ it "allows filtering by sha" do
+ expect(resolve_pipelines(sha: "deadbeef")).to contain_exactly(sha_pipeline)
end
- it 'does not return any pipelines if the user does not have access' do
+ it "does not return any pipelines if the user does not have access" do
expect(resolve_pipelines({}, {})).to be_empty
end
- def resolve_pipelines(args = {}, context = { current_user: current_user })
+ def resolve_pipelines(args = {}, context = {current_user: current_user})
resolve(resolver, obj: project, args: args, ctx: context)
end
end
diff --git a/spec/graphql/resolvers/issues_resolver_spec.rb b/spec/graphql/resolvers/issues_resolver_spec.rb
index 5f9c180cbb7..7a0a8bcdc73 100644
--- a/spec/graphql/resolvers/issues_resolver_spec.rb
+++ b/spec/graphql/resolvers/issues_resolver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::IssuesResolver do
include GraphqlHelpers
@@ -6,7 +6,7 @@ describe Resolvers::IssuesResolver do
let(:current_user) { create(:user) }
set(:project) { create(:project) }
set(:issue1) { create(:issue, project: project, state: :opened, created_at: 3.hours.ago, updated_at: 3.hours.ago) }
- set(:issue2) { create(:issue, project: project, state: :closed, title: 'foo', created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
+ set(:issue2) { create(:issue, project: project, state: :closed, title: "foo", created_at: 1.hour.ago, updated_at: 1.hour.ago, closed_at: 1.hour.ago) }
set(:label1) { create(:label, project: project) }
set(:label2) { create(:label, project: project) }
@@ -17,62 +17,62 @@ describe Resolvers::IssuesResolver do
create(:label_link, label: label2, target: issue2)
end
- describe '#resolve' do
- it 'finds all issues' do
+ describe "#resolve" do
+ it "finds all issues" do
expect(resolve_issues).to contain_exactly(issue1, issue2)
end
- it 'filters by state' do
- expect(resolve_issues(state: 'opened')).to contain_exactly(issue1)
- expect(resolve_issues(state: 'closed')).to contain_exactly(issue2)
+ it "filters by state" do
+ expect(resolve_issues(state: "opened")).to contain_exactly(issue1)
+ expect(resolve_issues(state: "closed")).to contain_exactly(issue2)
end
- it 'filters by labels' do
+ it "filters by labels" do
expect(resolve_issues(label_name: [label1.title])).to contain_exactly(issue1, issue2)
expect(resolve_issues(label_name: [label1.title, label2.title])).to contain_exactly(issue2)
end
- describe 'filters by created_at' do
- it 'filters by created_before' do
+ describe "filters by created_at" do
+ it "filters by created_before" do
expect(resolve_issues(created_before: 2.hours.ago)).to contain_exactly(issue1)
end
- it 'filters by created_after' do
+ it "filters by created_after" do
expect(resolve_issues(created_after: 2.hours.ago)).to contain_exactly(issue2)
end
end
- describe 'filters by updated_at' do
- it 'filters by updated_before' do
+ describe "filters by updated_at" do
+ it "filters by updated_before" do
expect(resolve_issues(updated_before: 2.hours.ago)).to contain_exactly(issue1)
end
- it 'filters by updated_after' do
+ it "filters by updated_after" do
expect(resolve_issues(updated_after: 2.hours.ago)).to contain_exactly(issue2)
end
end
- describe 'filters by closed_at' do
+ describe "filters by closed_at" do
let!(:issue3) { create(:issue, project: project, state: :closed, closed_at: 3.hours.ago) }
- it 'filters by closed_before' do
+ it "filters by closed_before" do
expect(resolve_issues(closed_before: 2.hours.ago)).to contain_exactly(issue3)
end
- it 'filters by closed_after' do
+ it "filters by closed_after" do
expect(resolve_issues(closed_after: 2.hours.ago)).to contain_exactly(issue2)
end
end
- it 'searches issues' do
- expect(resolve_issues(search: 'foo')).to contain_exactly(issue2)
+ it "searches issues" do
+ expect(resolve_issues(search: "foo")).to contain_exactly(issue2)
end
- it 'sort issues' do
- expect(resolve_issues(sort: 'created_desc')).to eq [issue2, issue1]
+ it "sort issues" do
+ expect(resolve_issues(sort: "created_desc")).to eq [issue2, issue1]
end
- it 'returns issues user can see' do
+ it "returns issues user can see" do
project.add_guest(current_user)
create(:issue, confidential: true)
@@ -80,20 +80,20 @@ describe Resolvers::IssuesResolver do
expect(resolve_issues).to contain_exactly(issue1, issue2)
end
- it 'finds a specific issue with iid' do
+ it "finds a specific issue with iid" do
expect(resolve_issues(iid: issue1.iid)).to contain_exactly(issue1)
end
- it 'finds a specific issue with iids' do
+ it "finds a specific issue with iids" do
expect(resolve_issues(iids: issue1.iid)).to contain_exactly(issue1)
end
- it 'finds multiple issues with iids' do
+ it "finds multiple issues with iids" do
expect(resolve_issues(iids: [issue1.iid, issue2.iid]))
.to contain_exactly(issue1, issue2)
end
- it 'finds only the issues within the project we are looking at' do
+ it "finds only the issues within the project we are looking at" do
another_project = create(:project)
iids = [issue1, issue2].map(&:iid)
@@ -105,7 +105,7 @@ describe Resolvers::IssuesResolver do
end
end
- def resolve_issues(args = {}, context = { current_user: current_user })
+ def resolve_issues(args = {}, context = {current_user: current_user})
resolve(described_class, obj: project, args: args, ctx: context)
end
end
diff --git a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
index 09b17bf6fc9..69afd79ae60 100644
--- a/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
+++ b/spec/graphql/resolvers/merge_request_pipelines_resolver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::MergeRequestPipelinesResolver do
include GraphqlHelpers
@@ -21,10 +21,10 @@ describe Resolvers::MergeRequestPipelinesResolver do
end
def resolve_pipelines
- resolve(described_class, obj: merge_request, ctx: { current_user: current_user })
+ resolve(described_class, obj: merge_request, ctx: {current_user: current_user})
end
- it 'resolves only MRs for the passed merge request' do
+ it "resolves only MRs for the passed merge request" do
expect(resolve_pipelines).to contain_exactly(pipeline)
end
end
diff --git a/spec/graphql/resolvers/merge_requests_resolver_spec.rb b/spec/graphql/resolvers/merge_requests_resolver_spec.rb
index ab3c426b2cd..a8e0539ebd9 100644
--- a/spec/graphql/resolvers/merge_requests_resolver_spec.rb
+++ b/spec/graphql/resolvers/merge_requests_resolver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::MergeRequestsResolver do
include GraphqlHelpers
@@ -15,40 +15,40 @@ describe Resolvers::MergeRequestsResolver do
let(:other_iid) { other_merge_request.iid }
- describe '#resolve' do
- it 'batch-resolves by target project full path and individual IID' do
- result = batch(max_queries: 2) do
+ describe "#resolve" do
+ it "batch-resolves by target project full path and individual IID" do
+ result = batch(max_queries: 2) {
resolve_mr(project, iid: iid_1) + resolve_mr(project, iid: iid_2)
- end
+ }
expect(result).to contain_exactly(merge_request_1, merge_request_2)
end
- it 'batch-resolves by target project full path and IIDS' do
- result = batch(max_queries: 2) do
+ it "batch-resolves by target project full path and IIDS" do
+ result = batch(max_queries: 2) {
resolve_mr(project, iids: [iid_1, iid_2])
- end
+ }
expect(result).to contain_exactly(merge_request_1, merge_request_2)
end
- it 'can batch-resolve merge requests from different projects' do
- result = batch(max_queries: 3) do
+ it "can batch-resolve merge requests from different projects" do
+ result = batch(max_queries: 3) {
resolve_mr(project, iid: iid_1) +
resolve_mr(project, iid: iid_2) +
resolve_mr(other_project, iid: other_iid)
- end
+ }
expect(result).to contain_exactly(merge_request_1, merge_request_2, other_merge_request)
end
- it 'resolves an unknown iid to be empty' do
+ it "resolves an unknown iid to be empty" do
result = batch { resolve_mr(project, iid: -1) }
expect(result).to be_empty
end
- it 'resolves empty iids to be empty' do
+ it "resolves empty iids to be empty" do
result = batch { resolve_mr(project, iids: []) }
expect(result).to be_empty
diff --git a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
index 6862ae8a5ed..8ac87d524e4 100644
--- a/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
+++ b/spec/graphql/resolvers/project_pipelines_resolver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::ProjectPipelinesResolver do
include GraphqlHelpers
@@ -13,10 +13,10 @@ describe Resolvers::ProjectPipelinesResolver do
end
def resolve_pipelines
- resolve(described_class, obj: project, ctx: { current_user: current_user })
+ resolve(described_class, obj: project, ctx: {current_user: current_user})
end
- it 'resolves only MRs for the passed merge request' do
+ it "resolves only MRs for the passed merge request" do
expect(resolve_pipelines).to contain_exactly(pipeline)
end
end
diff --git a/spec/graphql/resolvers/project_resolver_spec.rb b/spec/graphql/resolvers/project_resolver_spec.rb
index d4990c6492c..449a22382db 100644
--- a/spec/graphql/resolvers/project_resolver_spec.rb
+++ b/spec/graphql/resolvers/project_resolver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Resolvers::ProjectResolver do
include GraphqlHelpers
@@ -8,25 +8,25 @@ describe Resolvers::ProjectResolver do
set(:other_project) { create(:project) }
- describe '#resolve' do
- it 'batch-resolves projects by full path' do
+ describe "#resolve" do
+ it "batch-resolves projects by full path" do
paths = [project1.full_path, project2.full_path]
- result = batch(max_queries: 1) do
+ result = batch(max_queries: 1) {
paths.map { |path| resolve_project(path) }
- end
+ }
expect(result).to contain_exactly(project1, project2)
end
- it 'resolves an unknown full_path to nil' do
- result = batch { resolve_project('unknown/project') }
+ it "resolves an unknown full_path to nil" do
+ result = batch { resolve_project("unknown/project") }
expect(result).to be_nil
end
end
def resolve_project(full_path)
- resolve(described_class, args: { full_path: full_path })
+ resolve(described_class, args: {full_path: full_path})
end
end
diff --git a/spec/graphql/types/ci/pipeline_type_spec.rb b/spec/graphql/types/ci/pipeline_type_spec.rb
index ec1c689a4be..474057a2e8a 100644
--- a/spec/graphql/types/ci/pipeline_type_spec.rb
+++ b/spec/graphql/types/ci/pipeline_type_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::Ci::PipelineType do
- it { expect(described_class.graphql_name).to eq('Pipeline') }
+ it { expect(described_class.graphql_name).to eq("Pipeline") }
it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Ci::Pipeline) }
end
diff --git a/spec/graphql/types/issuable_state_enum_spec.rb b/spec/graphql/types/issuable_state_enum_spec.rb
index 65a80fa4176..fee06c678f4 100644
--- a/spec/graphql/types/issuable_state_enum_spec.rb
+++ b/spec/graphql/types/issuable_state_enum_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['IssuableState'] do
- it { expect(described_class.graphql_name).to eq('IssuableState') }
+describe GitlabSchema.types["IssuableState"] do
+ it { expect(described_class.graphql_name).to eq("IssuableState") }
- it_behaves_like 'issuable state'
+ it_behaves_like "issuable state"
end
diff --git a/spec/graphql/types/issue_state_enum_spec.rb b/spec/graphql/types/issue_state_enum_spec.rb
index de19e6fc505..abdd1747d60 100644
--- a/spec/graphql/types/issue_state_enum_spec.rb
+++ b/spec/graphql/types/issue_state_enum_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['IssueState'] do
- it { expect(described_class.graphql_name).to eq('IssueState') }
+describe GitlabSchema.types["IssueState"] do
+ it { expect(described_class.graphql_name).to eq("IssueState") }
- it_behaves_like 'issuable state'
+ it_behaves_like "issuable state"
end
diff --git a/spec/graphql/types/issue_type_spec.rb b/spec/graphql/types/issue_type_spec.rb
index 63a07647a60..f0cb3836149 100644
--- a/spec/graphql/types/issue_type_spec.rb
+++ b/spec/graphql/types/issue_type_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['Issue'] do
+describe GitlabSchema.types["Issue"] do
it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Issue) }
- it { expect(described_class.graphql_name).to eq('Issue') }
+ it { expect(described_class.graphql_name).to eq("Issue") }
end
diff --git a/spec/graphql/types/merge_request_state_enum_spec.rb b/spec/graphql/types/merge_request_state_enum_spec.rb
index 626e33b18d3..8bb3d50e24e 100644
--- a/spec/graphql/types/merge_request_state_enum_spec.rb
+++ b/spec/graphql/types/merge_request_state_enum_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['MergeRequestState'] do
- it { expect(described_class.graphql_name).to eq('MergeRequestState') }
+describe GitlabSchema.types["MergeRequestState"] do
+ it { expect(described_class.graphql_name).to eq("MergeRequestState") }
- it_behaves_like 'issuable state'
+ it_behaves_like "issuable state"
- it 'exposes all the existing merge request states' do
- expect(described_class.values.keys).to include('merged')
+ it "exposes all the existing merge request states" do
+ expect(described_class.values.keys).to include("merged")
end
end
diff --git a/spec/graphql/types/merge_request_type_spec.rb b/spec/graphql/types/merge_request_type_spec.rb
index c369953e3ea..907cfe66acd 100644
--- a/spec/graphql/types/merge_request_type_spec.rb
+++ b/spec/graphql/types/merge_request_type_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['MergeRequest'] do
+describe GitlabSchema.types["MergeRequest"] do
it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) }
- describe 'head pipeline' do
- it 'has a head pipeline field' do
+ describe "head pipeline" do
+ it "has a head pipeline field" do
expect(described_class).to have_graphql_field(:head_pipeline)
end
- it 'authorizes the field' do
- expect(described_class.fields['headPipeline'])
+ it "authorizes the field" do
+ expect(described_class.fields["headPipeline"])
.to require_graphql_authorizations(:read_pipeline)
end
end
diff --git a/spec/graphql/types/mutation_type_spec.rb b/spec/graphql/types/mutation_type_spec.rb
index a67d83b1edf..2bb572a19ed 100644
--- a/spec/graphql/types/mutation_type_spec.rb
+++ b/spec/graphql/types/mutation_type_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Types::MutationType do
- it 'is expected to have the MergeRequestSetWip' do
+ it "is expected to have the MergeRequestSetWip" do
expect(described_class).to have_graphql_mutation(Mutations::MergeRequests::SetWip)
end
end
diff --git a/spec/graphql/types/permission_types/base_permission_type_spec.rb b/spec/graphql/types/permission_types/base_permission_type_spec.rb
index 0ee8b883d51..1ec7c0aa716 100644
--- a/spec/graphql/types/permission_types/base_permission_type_spec.rb
+++ b/spec/graphql/types/permission_types/base_permission_type_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::PermissionTypes::BasePermissionType do
- let(:permitable) { double('permittable') }
+ let(:permitable) { double("permittable") }
let(:current_user) { build(:user) }
- let(:context) { { current_user: current_user } }
+ let(:context) { {current_user: current_user} }
subject(:test_type) do
Class.new(described_class) do
- graphql_name 'TestClass'
+ graphql_name "TestClass"
- permission_field :do_stuff, resolve: -> (_, _, _) { true }
+ permission_field :do_stuff, resolve: ->(_, _, _) { true }
ability_field(:read_issue)
abilities :admin_issue
end
end
- describe '.permission_field' do
- it 'adds a field for the required permission' do
+ describe ".permission_field" do
+ it "adds a field for the required permission" do
is_expected.to have_graphql_field(:do_stuff)
end
end
- describe '.ability_field' do
- it 'adds a field for the required permission' do
+ describe ".ability_field" do
+ it "adds a field for the required permission" do
is_expected.to have_graphql_field(:read_issue)
end
- it 'does not add a resolver block if another resolving param is passed' do
+ it "does not add a resolver block if another resolving param is passed" do
expected_keywords = {
name: :resolve_using_hash,
hash_key: :the_key,
type: GraphQL::BOOLEAN_TYPE,
description: "custom description",
- null: false
+ null: false,
}
expect(test_type).to receive(:field).with(expected_keywords)
@@ -39,8 +39,8 @@ describe Types::PermissionTypes::BasePermissionType do
end
end
- describe '.abilities' do
- it 'adds a field for the passed permissions' do
+ describe ".abilities" do
+ it "adds a field for the passed permissions" do
is_expected.to have_graphql_field(:admin_issue)
end
end
diff --git a/spec/graphql/types/permission_types/issue_spec.rb b/spec/graphql/types/permission_types/issue_spec.rb
index c3f84629aa2..399eba23938 100644
--- a/spec/graphql/types/permission_types/issue_spec.rb
+++ b/spec/graphql/types/permission_types/issue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::PermissionTypes::Issue do
it do
expected_permissions = [
:read_issue, :admin_issue, :update_issue,
- :create_note, :reopen_issue
+ :create_note, :reopen_issue,
]
expect(described_class).to have_graphql_fields(expected_permissions)
diff --git a/spec/graphql/types/permission_types/merge_request_spec.rb b/spec/graphql/types/permission_types/merge_request_spec.rb
index e1026b01a74..3f0f6892b19 100644
--- a/spec/graphql/types/permission_types/merge_request_spec.rb
+++ b/spec/graphql/types/permission_types/merge_request_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::PermissionTypes::MergeRequest do
it do
expected_permissions = [
:read_merge_request, :admin_merge_request, :update_merge_request,
:create_note, :push_to_source_branch, :remove_source_branch,
- :cherry_pick_on_current_merge_request, :revert_on_current_merge_request
+ :cherry_pick_on_current_merge_request, :revert_on_current_merge_request,
]
expect(described_class).to have_graphql_fields(expected_permissions)
diff --git a/spec/graphql/types/permission_types/merge_request_type_spec.rb b/spec/graphql/types/permission_types/merge_request_type_spec.rb
index 6e57122867a..b7f2e45fe4b 100644
--- a/spec/graphql/types/permission_types/merge_request_type_spec.rb
+++ b/spec/graphql/types/permission_types/merge_request_type_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::MergeRequestType do
it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) }
diff --git a/spec/graphql/types/permission_types/project_spec.rb b/spec/graphql/types/permission_types/project_spec.rb
index 4288412eda3..03aaf3c7564 100644
--- a/spec/graphql/types/permission_types/project_spec.rb
+++ b/spec/graphql/types/permission_types/project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Types::PermissionTypes::Project do
it do
@@ -10,7 +10,7 @@ describe Types::PermissionTypes::Project do
:read_commit_status, :request_access, :create_pipeline, :create_pipeline_schedule,
:create_merge_request_from, :create_wiki, :push_code, :create_deployment, :push_to_delete_protected_branch,
:admin_wiki, :admin_project, :update_pages, :admin_remote_mirror, :create_label,
- :update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content
+ :update_wiki, :destroy_wiki, :create_pages, :destroy_pages, :read_pages_content,
]
expect(described_class).to have_graphql_fields(expected_permissions)
diff --git a/spec/graphql/types/project_type_spec.rb b/spec/graphql/types/project_type_spec.rb
index e8f1c84f8d6..40d48163d40 100644
--- a/spec/graphql/types/project_type_spec.rb
+++ b/spec/graphql/types/project_type_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['Project'] do
+describe GitlabSchema.types["Project"] do
it { expect(described_class).to expose_permissions_using(Types::PermissionTypes::Project) }
- it { expect(described_class.graphql_name).to eq('Project') }
+ it { expect(described_class.graphql_name).to eq("Project") }
- describe 'nested merge request' do
+ describe "nested merge request" do
it { expect(described_class).to have_graphql_field(:merge_requests) }
it { expect(described_class).to have_graphql_field(:merge_request) }
- it 'authorizes the merge request' do
- expect(described_class.fields['mergeRequest'])
+ it "authorizes the merge request" do
+ expect(described_class.fields["mergeRequest"])
.to require_graphql_authorizations(:read_merge_request)
end
- it 'authorizes the merge requests' do
- expect(described_class.fields['mergeRequests'])
+ it "authorizes the merge requests" do
+ expect(described_class.fields["mergeRequests"])
.to require_graphql_authorizations(:read_merge_request)
end
end
- describe 'nested issues' do
+ describe "nested issues" do
it { expect(described_class).to have_graphql_field(:issues) }
end
diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb
index e1df6f9811d..089aff91d94 100644
--- a/spec/graphql/types/query_type_spec.rb
+++ b/spec/graphql/types/query_type_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['Query'] do
- it 'is called Query' do
- expect(described_class.graphql_name).to eq('Query')
+describe GitlabSchema.types["Query"] do
+ it "is called Query" do
+ expect(described_class.graphql_name).to eq("Query")
end
it { is_expected.to have_graphql_fields(:project, :echo) }
- describe 'project field' do
- subject { described_class.fields['project'] }
+ describe "project field" do
+ subject { described_class.fields["project"] }
- it 'finds projects by full path' do
+ it "finds projects by full path" do
is_expected.to have_graphql_arguments(:full_path)
is_expected.to have_graphql_type(Types::ProjectType)
is_expected.to have_graphql_resolver(Resolvers::ProjectResolver)
end
- it 'authorizes with read_project' do
+ it "authorizes with read_project" do
is_expected.to require_graphql_authorizations(:read_project)
end
end
diff --git a/spec/graphql/types/time_type_spec.rb b/spec/graphql/types/time_type_spec.rb
index 4196d9d27d4..fa394e74a19 100644
--- a/spec/graphql/types/time_type_spec.rb
+++ b/spec/graphql/types/time_type_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe GitlabSchema.types['Time'] do
+describe GitlabSchema.types["Time"] do
let(:iso) { "2018-06-04T15:23:50+02:00" }
let(:time) { Time.parse(iso) }
- it { expect(described_class.graphql_name).to eq('Time') }
+ it { expect(described_class.graphql_name).to eq("Time") }
- it 'coerces Time object into ISO 8601' do
+ it "coerces Time object into ISO 8601" do
expect(described_class.coerce_isolated_result(time)).to eq(iso)
end
- it 'coerces an ISO-time into Time object' do
+ it "coerces an ISO-time into Time object" do
expect(described_class.coerce_isolated_input(iso)).to eq(time)
end
end
diff --git a/spec/helpers/appearances_helper_spec.rb b/spec/helpers/appearances_helper_spec.rb
index 8d717b968dd..b8d131dd47c 100644
--- a/spec/helpers/appearances_helper_spec.rb
+++ b/spec/helpers/appearances_helper_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe AppearancesHelper do
before do
@@ -8,15 +8,15 @@ describe AppearancesHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- describe '#header_message' do
- it 'returns nil when header message field is not set' do
+ describe "#header_message" do
+ it "returns nil when header message field is not set" do
create(:appearance)
expect(helper.header_message).to be_nil
end
- context 'when header message is set' do
- it 'includes current message' do
+ context "when header message is set" do
+ it "includes current message" do
message = "Foo bar"
create(:appearance, header_message: message)
@@ -25,15 +25,15 @@ describe AppearancesHelper do
end
end
- describe '#footer_message' do
- it 'returns nil when footer message field is not set' do
+ describe "#footer_message" do
+ it "returns nil when footer message field is not set" do
create(:appearance)
expect(helper.footer_message).to be_nil
end
- context 'when footer message is set' do
- it 'includes current message' do
+ context "when footer message is set" do
+ it "includes current message" do
message = "Foo bar"
create(:appearance, footer_message: message)
@@ -42,35 +42,35 @@ describe AppearancesHelper do
end
end
- describe '#brand_image' do
+ describe "#brand_image" do
let!(:appearance) { create(:appearance, :with_logo) }
- context 'when there is a logo' do
- it 'returns a path' do
- expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ context "when there is a logo" do
+ it "returns a path" do
+ expect(helper.brand_image).to match(%r{img data-src="/uploads/-/system/appearance/.*png})
end
end
- context 'when there is a logo but no associated upload' do
+ context "when there is a logo but no associated upload" do
before do
# Legacy attachments were not tracked in the uploads table
appearance.logo.upload.destroy
appearance.reload
end
- it 'falls back to using the original path' do
- expect(helper.brand_image).to match(%r(img data-src="/uploads/-/system/appearance/.*png))
+ it "falls back to using the original path" do
+ expect(helper.brand_image).to match(%r{img data-src="/uploads/-/system/appearance/.*png})
end
end
end
- describe '#brand_title' do
- it 'returns the default CE title when no appearance is present' do
+ describe "#brand_title" do
+ it "returns the default CE title when no appearance is present" do
allow(helper)
.to receive(:current_appearance)
- .and_return(nil)
+ .and_return(nil)
- expect(helper.brand_title).to eq('GitLab Community Edition')
+ expect(helper.brand_title).to eq("GitLab Community Edition")
end
end
end
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index b81249a1e29..2229490410f 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -1,40 +1,39 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe ApplicationHelper do
- describe 'current_controller?' do
+ describe "current_controller?" do
before do
- stub_controller_name('foo')
+ stub_controller_name("foo")
end
- it 'returns true when controller matches argument' do
+ it "returns true when controller matches argument" do
expect(helper.current_controller?(:foo)).to be_truthy
end
- it 'returns false when controller does not match argument' do
+ it "returns false when controller does not match argument" do
expect(helper.current_controller?(:bar)).to be_falsey
end
- it 'takes any number of arguments' do
+ it "takes any number of arguments" do
expect(helper.current_controller?(:baz, :bar)).to be_falsey
expect(helper.current_controller?(:baz, :bar, :foo)).to be_truthy
end
- context 'when namespaced' do
+ context "when namespaced" do
before do
- stub_controller_path('bar/foo')
+ stub_controller_path("bar/foo")
end
- it 'returns true when controller matches argument' do
+ it "returns true when controller matches argument" do
expect(helper.current_controller?(:foo)).to be_truthy
end
- it 'returns true when controller and namespace matches argument in path notation' do
- expect(helper.current_controller?('bar/foo')).to be_truthy
+ it "returns true when controller and namespace matches argument in path notation" do
+ expect(helper.current_controller?("bar/foo")).to be_truthy
end
- it 'returns false when namespace doesnt match' do
- expect(helper.current_controller?('foo/foo')).to be_falsey
+ it "returns false when namespace doesnt match" do
+ expect(helper.current_controller?("foo/foo")).to be_falsey
end
end
@@ -47,20 +46,20 @@ describe ApplicationHelper do
end
end
- describe 'current_action?' do
+ describe "current_action?" do
before do
- stub_action_name('foo')
+ stub_action_name("foo")
end
- it 'returns true when action matches' do
+ it "returns true when action matches" do
expect(helper.current_action?(:foo)).to be_truthy
end
- it 'returns false when action does not match' do
+ it "returns false when action does not match" do
expect(helper.current_action?(:bar)).to be_falsey
end
- it 'takes any number of arguments' do
+ it "takes any number of arguments" do
expect(helper.current_action?(:baz, :bar)).to be_falsey
expect(helper.current_action?(:baz, :bar, :foo)).to be_truthy
end
@@ -70,124 +69,124 @@ describe ApplicationHelper do
end
end
- describe 'simple_sanitize' do
+ describe "simple_sanitize" do
let(:a_tag) { '<a href="#">Foo</a>' }
- it 'allows the a tag' do
+ it "allows the a tag" do
expect(helper.simple_sanitize(a_tag)).to eq(a_tag)
end
- it 'allows the span tag' do
+ it "allows the span tag" do
input = '<span class="foo">Bar</span>'
expect(helper.simple_sanitize(input)).to eq(input)
end
- it 'disallows other tags' do
+ it "disallows other tags" do
input = "<strike><b>#{a_tag}</b></strike>"
expect(helper.simple_sanitize(input)).to eq(a_tag)
end
end
- describe 'time_ago_with_tooltip' do
+ describe "time_ago_with_tooltip" do
def element(*arguments)
- Time.zone = 'UTC'
- @time = Time.zone.parse('2015-07-02 08:23')
+ Time.zone = "UTC"
+ @time = Time.zone.parse("2015-07-02 08:23")
element = helper.time_ago_with_tooltip(@time, *arguments)
Nokogiri::HTML::DocumentFragment.parse(element).first_element_child
end
- it 'returns a time element' do
- expect(element.name).to eq 'time'
+ it "returns a time element" do
+ expect(element.name).to eq "time"
end
- it 'includes the date string' do
+ it "includes the date string" do
expect(element.text).to eq @time.strftime("%b %d, %Y")
end
- it 'has a datetime attribute' do
- expect(element.attr('datetime')).to eq '2015-07-02T08:23:00Z'
+ it "has a datetime attribute" do
+ expect(element.attr("datetime")).to eq "2015-07-02T08:23:00Z"
end
- it 'has a formatted title attribute' do
- expect(element.attr('title')).to eq 'Jul 2, 2015 8:23am'
+ it "has a formatted title attribute" do
+ expect(element.attr("title")).to eq "Jul 2, 2015 8:23am"
end
- it 'includes a default js-timeago class' do
- expect(element.attr('class')).to eq 'js-timeago'
+ it "includes a default js-timeago class" do
+ expect(element.attr("class")).to eq "js-timeago"
end
- it 'accepts a custom html_class' do
- expect(element(html_class: 'custom_class').attr('class')).to eq 'js-timeago custom_class'
+ it "accepts a custom html_class" do
+ expect(element(html_class: "custom_class").attr("class")).to eq "js-timeago custom_class"
end
- it 'accepts a custom tooltip placement' do
- expect(element(placement: 'bottom').attr('data-placement')).to eq 'bottom'
+ it "accepts a custom tooltip placement" do
+ expect(element(placement: "bottom").attr("data-placement")).to eq "bottom"
end
- it 'converts to Time' 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' do
- timeago_element = element(short_format: 'short')
+ it "add class for the short format" do
+ timeago_element = element(short_format: "short")
- expect(timeago_element.attr('class')).to eq 'js-short-timeago'
+ expect(timeago_element.attr("class")).to eq "js-short-timeago"
expect(timeago_element.next_element).to eq nil
end
end
- describe '#active_when' do
- it { expect(helper.active_when(true)).to eq('active') }
+ describe "#active_when" do
+ it { expect(helper.active_when(true)).to eq("active") }
it { expect(helper.active_when(false)).to eq(nil) }
end
- describe '#support_url' do
- context 'when alternate support url is specified' do
- let(:alternate_url) { 'http://company.example.com/getting-help' }
+ describe "#support_url" do
+ context "when alternate support url is specified" do
+ let(:alternate_url) { "http://company.example.com/getting-help" }
- it 'returns the alternate support url' do
+ it "returns the alternate support url" do
stub_application_setting(help_page_support_url: alternate_url)
expect(helper.support_url).to eq(alternate_url)
end
end
- context 'when alternate support url is not specified' do
- it 'builds the support url from the promo_url' do
- expect(helper.support_url).to eq(helper.promo_url + '/getting-help/')
+ context "when alternate support url is not specified" do
+ it "builds the support url from the promo_url" do
+ expect(helper.support_url).to eq(helper.promo_url + "/getting-help/")
end
end
end
- describe '#locale_path' do
- it 'returns the locale path with an `_`' do
- Gitlab::I18n.with_locale('pt-BR') do
- expect(helper.locale_path).to include('assets/locale/pt_BR/app')
+ describe "#locale_path" do
+ it "returns the locale path with an `_`" do
+ Gitlab::I18n.with_locale("pt-BR") do
+ expect(helper.locale_path).to include("assets/locale/pt_BR/app")
end
end
end
- describe '#client_class_list' do
- it 'returns string containing CSS classes representing client browser and platform' do
+ describe "#client_class_list" do
+ it "returns string containing CSS classes representing client browser and platform" do
class_list = helper.client_class_list
- expect(class_list).to eq('gl-browser-generic gl-platform-other')
+ expect(class_list).to eq("gl-browser-generic gl-platform-other")
end
end
- describe '#client_js_flags' do
- it 'returns map containing JS flags representing client browser and platform' do
+ describe "#client_js_flags" do
+ it "returns map containing JS flags representing client browser and platform" do
flags_list = helper.client_js_flags
expect(flags_list[:isGeneric]).to eq(true)
expect(flags_list[:isOther]).to eq(true)
end
end
- describe '#autocomplete_data_sources' do
+ describe "#autocomplete_data_sources" do
let(:project) { create(:project) }
let(:noteable_type) { Issue }
- it 'returns paths for autocomplete_sources_controller' do
+ it "returns paths for autocomplete_sources_controller" do
sources = helper.autocomplete_data_sources(project, noteable_type)
expect(sources.keys).to match_array([:members, :issues, :mergeRequests, :labels, :milestones, :commands, :snippets])
sources.keys.each do |key|
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb
index 705523f1110..bec7bbb7923 100644
--- a/spec/helpers/application_settings_helper_spec.rb
+++ b/spec/helpers/application_settings_helper_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ApplicationSettingsHelper do
- context 'when all protocols in use' do
+ context "when all protocols in use" do
before do
- stub_application_setting(enabled_git_access_protocol: '')
+ stub_application_setting(enabled_git_access_protocol: "")
end
it { expect(all_protocols_enabled?).to be_truthy }
@@ -13,9 +13,9 @@ describe ApplicationSettingsHelper do
it { expect(ssh_enabled?).to be_truthy }
end
- context 'when SSH is only in use' do
+ context "when SSH is only in use" do
before do
- stub_application_setting(enabled_git_access_protocol: 'ssh')
+ stub_application_setting(enabled_git_access_protocol: "ssh")
end
it { expect(all_protocols_enabled?).to be_falsey }
@@ -23,10 +23,10 @@ describe ApplicationSettingsHelper do
it { expect(ssh_enabled?).to be_truthy }
end
- shared_examples 'when HTTP protocol is in use' do |protocol|
+ shared_examples "when HTTP protocol is in use" do |protocol|
before do
allow(Gitlab.config.gitlab).to receive(:protocol).and_return(protocol)
- stub_application_setting(enabled_git_access_protocol: 'http')
+ stub_application_setting(enabled_git_access_protocol: "http")
end
it { expect(all_protocols_enabled?).to be_falsey }
@@ -34,6 +34,6 @@ describe ApplicationSettingsHelper do
it { expect(ssh_enabled?).to be_falsey }
end
- it_behaves_like 'when HTTP protocol is in use', 'https'
- it_behaves_like 'when HTTP protocol is in use', 'http'
+ it_behaves_like "when HTTP protocol is in use", "https"
+ it_behaves_like "when HTTP protocol is in use", "http"
end
diff --git a/spec/helpers/auth_helper_spec.rb b/spec/helpers/auth_helper_spec.rb
index f0c2e4768ec..04c69d80734 100644
--- a/spec/helpers/auth_helper_spec.rb
+++ b/spec/helpers/auth_helper_spec.rb
@@ -2,48 +2,48 @@ require "spec_helper"
describe AuthHelper do
describe "button_based_providers" do
- it 'returns all enabled providers from devise' do
+ it "returns all enabled providers from devise" do
allow(helper).to receive(:auth_providers) { [:twitter, :github] }
- expect(helper.button_based_providers).to include(*[:twitter, :github])
+ expect(helper.button_based_providers).to include(:twitter, :github)
end
- it 'does not return ldap provider' do
+ it "does not return ldap provider" do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] }
expect(helper.button_based_providers).to include(:twitter)
end
- it 'returns empty array' do
+ it "returns empty array" do
allow(helper).to receive(:auth_providers) { [] }
expect(helper.button_based_providers).to eq([])
end
end
describe "providers_for_base_controller" do
- it 'returns all enabled providers from devise' do
+ it "returns all enabled providers from devise" do
allow(helper).to receive(:auth_providers) { [:twitter, :github] }
- expect(helper.providers_for_base_controller).to include(*[:twitter, :github])
+ expect(helper.providers_for_base_controller).to include(:twitter, :github)
end
- it 'excludes ldap providers' do
+ it "excludes ldap providers" do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] }
expect(helper.providers_for_base_controller).not_to include(:ldapmain)
end
end
describe "form_based_providers" do
- it 'includes LDAP providers' do
+ it "includes LDAP providers" do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapmain] }
- expect(helper.form_based_providers).to eq %i(ldapmain)
+ expect(helper.form_based_providers).to eq %i[ldapmain]
end
- it 'includes crowd provider' do
+ it "includes crowd provider" do
allow(helper).to receive(:auth_providers) { [:twitter, :crowd] }
- expect(helper.form_based_providers).to eq %i(crowd)
+ expect(helper.form_based_providers).to eq %i[crowd]
end
end
- describe 'form_based_auth_provider_has_active_class?' do
- it 'selects main LDAP server' do
+ describe "form_based_auth_provider_has_active_class?" do
+ it "selects main LDAP server" do
allow(helper).to receive(:auth_providers) { [:twitter, :ldapprimary, :ldapsecondary, :kerberos] }
expect(helper.form_based_auth_provider_has_active_class?(:twitter)).to be(false)
expect(helper.form_based_auth_provider_has_active_class?(:ldapprimary)).to be(true)
@@ -52,44 +52,44 @@ describe AuthHelper do
end
end
- describe 'enabled_button_based_providers' do
+ describe "enabled_button_based_providers" do
before do
allow(helper).to receive(:auth_providers) { [:twitter, :github] }
end
- context 'all providers are enabled to sign in' do
- it 'returns all the enabled providers from settings' do
- expect(helper.enabled_button_based_providers).to include('twitter', 'github')
+ context "all providers are enabled to sign in" do
+ it "returns all the enabled providers from settings" do
+ expect(helper.enabled_button_based_providers).to include("twitter", "github")
end
end
- context 'GitHub OAuth sign in is disabled from application setting' do
+ context "GitHub OAuth sign in is disabled from application setting" do
it "doesn't return github as provider" do
stub_application_setting(
- disabled_oauth_sign_in_sources: ['github']
+ disabled_oauth_sign_in_sources: ["github"]
)
- expect(helper.enabled_button_based_providers).to include('twitter')
- expect(helper.enabled_button_based_providers).not_to include('github')
+ expect(helper.enabled_button_based_providers).to include("twitter")
+ expect(helper.enabled_button_based_providers).not_to include("github")
end
end
end
- describe 'button_based_providers_enabled?' do
+ describe "button_based_providers_enabled?" do
before do
allow(helper).to receive(:auth_providers) { [:twitter, :github] }
end
- context 'button based providers enabled' do
- it 'returns true' do
+ context "button based providers enabled" do
+ it "returns true" do
expect(helper.button_based_providers_enabled?).to be true
end
end
- context 'all the button based providers are disabled via application_setting' do
- it 'returns false' do
+ context "all the button based providers are disabled via application_setting" do
+ it "returns false" do
stub_application_setting(
- disabled_oauth_sign_in_sources: %w(github twitter)
+ disabled_oauth_sign_in_sources: %w[github twitter]
)
expect(helper.button_based_providers_enabled?).to be false
@@ -97,7 +97,7 @@ describe AuthHelper do
end
end
- describe 'unlink_allowed?' do
+ describe "unlink_allowed?" do
[:saml, :cas3].each do |provider|
it "returns true if the provider is #{provider}" do
expect(helper.unlink_allowed?(provider)).to be false
diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb
index 223e562238d..21ce44e40ba 100644
--- a/spec/helpers/auto_devops_helper_spec.rb
+++ b/spec/helpers/auto_devops_helper_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe AutoDevopsHelper do
set(:project) { create(:project) }
set(:user) { create(:user) }
- describe '.show_auto_devops_callout?' do
+ describe ".show_auto_devops_callout?" do
let(:allowed) { true }
before do
@@ -16,11 +16,11 @@ describe AutoDevopsHelper do
subject { helper.show_auto_devops_callout?(project) }
- context 'when auto devops is implicitly enabled' do
+ context "when auto devops is implicitly enabled" do
it { is_expected.to eq(false) }
end
- context 'when auto devops is not implicitly enabled' do
+ context "when auto devops is not implicitly enabled" do
before do
Gitlab::CurrentSettings.update!(auto_devops_enabled: false)
end
@@ -28,29 +28,29 @@ describe AutoDevopsHelper do
it { is_expected.to eq(true) }
end
- context 'when the banner is disabled by feature flag' do
- it 'allows the feature flag to disable' do
+ context "when the banner is disabled by feature flag" do
+ it "allows the feature flag to disable" do
Feature.get(:auto_devops_banner_disabled).enable
expect(subject).to be(false)
end
end
- context 'when dismissed' do
+ context "when dismissed" do
before do
- helper.request.cookies[:auto_devops_settings_dismissed] = 'true'
+ helper.request.cookies[:auto_devops_settings_dismissed] = "true"
end
it { is_expected.to eq(false) }
end
- context 'when user cannot admin project' do
+ context "when user cannot admin project" do
let(:allowed) { false }
it { is_expected.to eq(false) }
end
- context 'when auto devops is enabled system-wide' do
+ context "when auto devops is enabled system-wide" do
before do
stub_application_setting(auto_devops_enabled: true)
end
@@ -58,7 +58,7 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) }
end
- context 'when auto devops is explicitly enabled for project' do
+ context "when auto devops is explicitly enabled for project" do
before do
project.create_auto_devops!(enabled: true)
end
@@ -66,7 +66,7 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) }
end
- context 'when auto devops is explicitly disabled for project' do
+ context "when auto devops is explicitly disabled for project" do
before do
project.create_auto_devops!(enabled: false)
end
@@ -74,7 +74,7 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) }
end
- context 'when master contains a .gitlab-ci.yml file' do
+ context "when master contains a .gitlab-ci.yml file" do
before do
allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']")
end
@@ -82,7 +82,7 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) }
end
- context 'when another service is enabled' do
+ context "when another service is enabled" do
before do
create(:service, project: project, category: :ci, active: true)
end
diff --git a/spec/helpers/avatars_helper_spec.rb b/spec/helpers/avatars_helper_spec.rb
index aa0442ab847..122ee9dc476 100644
--- a/spec/helpers/avatars_helper_spec.rb
+++ b/spec/helpers/avatars_helper_spec.rb
@@ -1,87 +1,87 @@
-require 'rails_helper'
+require "rails_helper"
describe AvatarsHelper do
include UploadHelpers
let(:user) { create(:user) }
- describe '#project_icon & #group_icon' do
- shared_examples 'resource with a default avatar' do |source_type|
- it 'returns a default avatar div' do
+ describe "#project_icon & #group_icon" do
+ shared_examples "resource with a default avatar" do |source_type|
+ it "returns a default avatar div" do
expect(public_send("#{source_type}_icon", *helper_args))
.to match(%r{<div class="identicon bg\d+">F</div>})
end
end
- shared_examples 'resource with a custom avatar' do |source_type|
- it 'returns a custom avatar image' do
+ shared_examples "resource with a custom avatar" do |source_type|
+ it "returns a custom avatar image" do
expect(public_send("#{source_type}_icon", *helper_args))
.to eq "<img src=\"#{resource.avatar.url}\" alt=\"Banana sample\" />"
end
end
- context 'when providing a project' do
- it_behaves_like 'resource with a default avatar', 'project' do
- let(:resource) { create(:project, name: 'foo') }
+ context "when providing a project" do
+ it_behaves_like "resource with a default avatar", "project" do
+ let(:resource) { create(:project, name: "foo") }
let(:helper_args) { [resource] }
end
- it_behaves_like 'resource with a custom avatar', 'project' do
+ it_behaves_like "resource with a custom avatar", "project" do
let(:resource) { create(:project, :public, avatar: File.open(uploaded_image_temp_path)) }
let(:helper_args) { [resource] }
end
end
- context 'when providing a group' do
- it_behaves_like 'resource with a default avatar', 'group' do
- let(:resource) { create(:group, name: 'foo') }
+ context "when providing a group" do
+ it_behaves_like "resource with a default avatar", "group" do
+ let(:resource) { create(:group, name: "foo") }
let(:helper_args) { [resource] }
end
- it_behaves_like 'resource with a custom avatar', 'group' do
+ it_behaves_like "resource with a custom avatar", "group" do
let(:resource) { create(:group, avatar: File.open(uploaded_image_temp_path)) }
let(:helper_args) { [resource] }
end
end
end
- describe '#avatar_icon_for' do
- let!(:user) { create(:user, avatar: File.open(uploaded_image_temp_path), email: 'bar@example.com') }
- let(:email) { 'foo@example.com' }
+ describe "#avatar_icon_for" do
+ let!(:user) { create(:user, avatar: File.open(uploaded_image_temp_path), email: "bar@example.com") }
+ let(:email) { "foo@example.com" }
let!(:another_user) { create(:user, avatar: File.open(uploaded_image_temp_path), email: email) }
- it 'prefers the user to retrieve the avatar_url' do
+ it "prefers the user to retrieve the avatar_url" do
expect(helper.avatar_icon_for(user, email).to_s)
.to eq(user.avatar.url)
end
- it 'falls back to email lookup if no user given' do
+ it "falls back to email lookup if no user given" do
expect(helper.avatar_icon_for(nil, email).to_s)
.to eq(another_user.avatar.url)
end
end
- describe '#avatar_icon_for_email' do
+ describe "#avatar_icon_for_email" do
let(:user) { create(:user, avatar: File.open(uploaded_image_temp_path)) }
- context 'using an email' do
- context 'when there is a matching user' do
- it 'returns a relative URL for the avatar' do
+ context "using an email" do
+ context "when there is a matching user" do
+ it "returns a relative URL for the avatar" do
expect(helper.avatar_icon_for_email(user.email).to_s)
.to eq(user.avatar.url)
end
end
- context 'when no user exists for the email' do
- it 'calls gravatar_icon' do
- expect(helper).to receive(:gravatar_icon).with('foo@example.com', 20, 2)
+ context "when no user exists for the email" do
+ it "calls gravatar_icon" do
+ expect(helper).to receive(:gravatar_icon).with("foo@example.com", 20, 2)
- helper.avatar_icon_for_email('foo@example.com', 20, 2)
+ helper.avatar_icon_for_email("foo@example.com", 20, 2)
end
end
- context 'without an email passed' do
- it 'calls gravatar_icon' do
+ context "without an email passed" do
+ it "calls gravatar_icon" do
expect(helper).to receive(:gravatar_icon).with(nil, 20, 2)
helper.avatar_icon_for_email(nil, 20, 2)
@@ -90,18 +90,18 @@ describe AvatarsHelper do
end
end
- describe '#avatar_icon_for_user' do
+ describe "#avatar_icon_for_user" do
let(:user) { create(:user, avatar: File.open(uploaded_image_temp_path)) }
- context 'with a user object passed' do
- it 'returns a relative URL for the avatar' do
+ context "with a user object passed" do
+ it "returns a relative URL for the avatar" do
expect(helper.avatar_icon_for_user(user).to_s)
.to eq(user.avatar.url)
end
end
- context 'without a user object passed' do
- it 'calls gravatar_icon' do
+ context "without a user object passed" do
+ it "calls gravatar_icon" do
expect(helper).to receive(:gravatar_icon).with(nil, 20, 2)
helper.avatar_icon_for_user(nil, 20, 2)
@@ -109,71 +109,71 @@ describe AvatarsHelper do
end
end
- describe '#gravatar_icon' do
- let(:user_email) { 'user@email.com' }
+ describe "#gravatar_icon" do
+ let(:user_email) { "user@email.com" }
- context 'with Gravatar disabled' do
+ context "with Gravatar disabled" do
before do
stub_application_setting(gravatar_enabled?: false)
end
- it 'returns a generic avatar' do
- expect(helper.gravatar_icon(user_email)).to match_asset_path('no_avatar.png')
+ it "returns a generic avatar" do
+ expect(helper.gravatar_icon(user_email)).to match_asset_path("no_avatar.png")
end
end
- context 'with Gravatar enabled' do
+ context "with Gravatar enabled" do
before do
stub_application_setting(gravatar_enabled?: true)
end
- it 'returns a generic avatar when email is blank' do
- expect(helper.gravatar_icon('')).to match_asset_path('no_avatar.png')
+ it "returns a generic avatar when email is blank" do
+ expect(helper.gravatar_icon("")).to match_asset_path("no_avatar.png")
end
- it 'returns a valid Gravatar URL' do
+ it "returns a valid Gravatar URL" do
stub_config_setting(https: false)
expect(helper.gravatar_icon(user_email))
- .to match('https://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
+ .to match("https://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118")
end
- it 'uses HTTPs when configured' do
+ it "uses HTTPs when configured" do
stub_config_setting(https: true)
expect(helper.gravatar_icon(user_email))
- .to match('https://secure.gravatar.com')
+ .to match("https://secure.gravatar.com")
end
- it 'returns custom gravatar path when gravatar_url is set' do
- stub_gravatar_setting(plain_url: 'http://example.local/?s=%{size}&hash=%{hash}')
+ 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))
- .to eq('http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118')
+ .to eq("http://example.local/?s=40&hash=b58c6f14d292556214bd64909bcdb118")
end
- it 'accepts a custom size argument' do
- expect(helper.gravatar_icon(user_email, 64)).to include '?s=128'
+ it "accepts a custom size argument" do
+ expect(helper.gravatar_icon(user_email, 64)).to include "?s=128"
end
- it 'defaults size to 40@2x when given an invalid size' do
- expect(helper.gravatar_icon(user_email, nil)).to include '?s=80'
+ it "defaults size to 40@2x when given an invalid size" do
+ expect(helper.gravatar_icon(user_email, nil)).to include "?s=80"
end
- it 'accepts a scaling factor' do
- expect(helper.gravatar_icon(user_email, 40, 3)).to include '?s=120'
+ it "accepts a scaling factor" do
+ expect(helper.gravatar_icon(user_email, 40, 3)).to include "?s=120"
end
- it 'ignores case and surrounding whitespace' do
- normal = helper.gravatar_icon('foo@example.com')
- upcase = helper.gravatar_icon(' FOO@EXAMPLE.COM ')
+ it "ignores case and surrounding whitespace" do
+ normal = helper.gravatar_icon("foo@example.com")
+ upcase = helper.gravatar_icon(" FOO@EXAMPLE.COM ")
expect(normal).to eq upcase
end
end
end
- describe '#user_avatar' do
+ describe "#user_avatar" do
subject { helper.user_avatar(user: user) }
it "links to the user's profile" do
@@ -189,101 +189,101 @@ describe AvatarsHelper do
end
end
- describe '#user_avatar_without_link' do
- let(:options) { { user: user } }
+ describe "#user_avatar_without_link" do
+ let(:options) { {user: user} }
subject { helper.user_avatar_without_link(options) }
- it 'displays user avatar' do
+ it "displays user avatar" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: avatar_icon_for_user(user, 16),
- data: { container: 'body' },
- class: 'avatar s16 has-tooltip',
+ data: {container: "body"},
+ class: "avatar s16 has-tooltip",
title: user.name
)
end
- context 'with css_class parameter' do
- let(:options) { { user: user, css_class: '.cat-pics' } }
+ context "with css_class parameter" do
+ let(:options) { {user: user, css_class: ".cat-pics"} }
- it 'uses provided css_class' do
+ it "uses provided css_class" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: avatar_icon_for_user(user, 16),
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s16 #{options[:css_class]} has-tooltip",
title: user.name
)
end
end
- context 'with size parameter' do
- let(:options) { { user: user, size: 99 } }
+ context "with size parameter" do
+ let(:options) { {user: user, size: 99} }
- it 'uses provided size' do
+ it "uses provided size" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: avatar_icon_for_user(user, options[:size]),
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s#{options[:size]} has-tooltip",
title: user.name
)
end
end
- context 'with url parameter' do
- let(:options) { { user: user, url: '/over/the/rainbow.png' } }
+ context "with url parameter" do
+ let(:options) { {user: user, url: "/over/the/rainbow.png"} }
- it 'uses provided url' do
+ it "uses provided url" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: options[:url],
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s16 has-tooltip",
title: user.name
)
end
end
- context 'with lazy parameter' do
- let(:options) { { user: user, lazy: true } }
+ context "with lazy parameter" do
+ let(:options) { {user: user, lazy: true} }
- it 'adds `lazy` class to class list, sets `data-src` with avatar URL and `src` with placeholder image' do
+ it "adds `lazy` class to class list, sets `data-src` with avatar URL and `src` with placeholder image" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: LazyImageTagHelper.placeholder_image,
- data: { container: 'body', src: avatar_icon_for_user(user, 16) },
+ data: {container: "body", src: avatar_icon_for_user(user, 16)},
class: "avatar s16 has-tooltip lazy",
title: user.name
)
end
end
- context 'with has_tooltip parameter' do
- context 'with has_tooltip set to true' do
- let(:options) { { user: user, has_tooltip: true } }
+ context "with has_tooltip parameter" do
+ context "with has_tooltip set to true" do
+ let(:options) { {user: user, has_tooltip: true} }
- it 'adds has-tooltip' do
+ it "adds has-tooltip" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: avatar_icon_for_user(user, 16),
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s16 has-tooltip",
title: user.name
)
end
end
- context 'with has_tooltip set to false' do
- let(:options) { { user: user, has_tooltip: false } }
+ context "with has_tooltip set to false" do
+ let(:options) { {user: user, has_tooltip: false} }
- it 'does not add has-tooltip or data container' do
+ it "does not add has-tooltip or data container" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
@@ -295,30 +295,30 @@ describe AvatarsHelper do
end
end
- context 'with user_name parameter' do
- let(:options) { { user_name: 'Tinky Winky', user_email: 'no@f.un' } }
+ context "with user_name parameter" do
+ let(:options) { {user_name: "Tinky Winky", user_email: "no@f.un"} }
- context 'with user parameter' do
- let(:options) { { user: user, user_name: 'Tinky Winky' } }
+ context "with user parameter" do
+ let(:options) { {user: user, user_name: "Tinky Winky"} }
- it 'prefers user parameter' do
+ it "prefers user parameter" do
is_expected.to eq tag(
:img,
alt: "#{user.name}'s avatar",
src: avatar_icon_for_user(user, 16),
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s16 has-tooltip",
title: user.name
)
end
end
- it 'uses user_name and user_email parameter if user is not present' do
+ it "uses user_name and user_email parameter if user is not present" do
is_expected.to eq tag(
:img,
alt: "#{options[:user_name]}'s avatar",
src: avatar_icon_for_email(options[:user_email], 16),
- data: { container: 'body' },
+ data: {container: "body"},
class: "avatar s16 has-tooltip",
title: options[:user_name]
)
diff --git a/spec/helpers/award_emoji_helper_spec.rb b/spec/helpers/award_emoji_helper_spec.rb
index 035960ed96e..5ec08901b58 100644
--- a/spec/helpers/award_emoji_helper_spec.rb
+++ b/spec/helpers/award_emoji_helper_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe AwardEmojiHelper do
- describe '.toggle_award_url' do
- context 'note on personal snippet' do
+ describe ".toggle_award_url" do
+ context "note on personal snippet" do
let(:note) { create(:note_on_personal_snippet) }
- it 'returns correct url' do
+ it "returns correct url" do
expected_url = "/snippets/#{note.noteable.id}/notes/#{note.id}/toggle_award_emoji"
expect(helper.toggle_award_url(note)).to eq(expected_url)
end
end
- context 'note on project item' do
+ context "note on project item" do
let(:note) { create(:note_on_project_snippet) }
- it 'returns correct url' do
+ it "returns correct url" do
@project = note.noteable.project
expected_url = "/#{@project.namespace.path}/#{@project.path}/notes/#{note.id}/toggle_award_emoji"
@@ -24,20 +24,20 @@ describe AwardEmojiHelper do
end
end
- context 'personal snippet' do
+ context "personal snippet" do
let(:snippet) { create(:personal_snippet) }
- it 'returns correct url' do
+ it "returns correct url" do
expected_url = "/snippets/#{snippet.id}/toggle_award_emoji"
expect(helper.toggle_award_url(snippet)).to eq(expected_url)
end
end
- context 'merge request' do
+ context "merge request" do
let(:merge_request) { create(:merge_request) }
- it 'returns correct url' do
+ it "returns correct url" do
@project = merge_request.project
expected_url = "/#{@project.namespace.path}/#{@project.path}/merge_requests/#{merge_request.iid}/toggle_award_emoji"
@@ -46,10 +46,10 @@ describe AwardEmojiHelper do
end
end
- context 'issue' do
+ context "issue" do
let(:issue) { create(:issue) }
- it 'returns correct url' do
+ it "returns correct url" do
@project = issue.project
expected_url = "/#{@project.namespace.path}/#{@project.path}/issues/#{issue.iid}/toggle_award_emoji"
diff --git a/spec/helpers/blame_helper_spec.rb b/spec/helpers/blame_helper_spec.rb
index 722d21c566f..00003d912e1 100644
--- a/spec/helpers/blame_helper_spec.rb
+++ b/spec/helpers/blame_helper_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe BlameHelper do
- describe '#get_age_map_start_date' do
+ describe "#get_age_map_start_date" do
let(:dates) do
[Time.zone.local(2014, 3, 17, 0, 0, 0),
Time.zone.local(2011, 11, 2, 0, 0, 0),
Time.zone.local(2015, 7, 9, 0, 0, 0),
Time.zone.local(2013, 2, 24, 0, 0, 0),
- Time.zone.local(2010, 9, 22, 0, 0, 0)]
+ Time.zone.local(2010, 9, 22, 0, 0, 0),]
end
let(:blame_groups) do
[
- { commit: double(committed_date: dates[0]) },
- { commit: double(committed_date: dates[1]) },
- { commit: double(committed_date: dates[2]) }
+ {commit: double(committed_date: dates[0])},
+ {commit: double(committed_date: dates[1])},
+ {commit: double(committed_date: dates[2])},
]
end
- it 'returns the earliest date from a blame group' do
+ it "returns the earliest date from a blame group" do
project = double(created_at: dates[3])
duration = helper.age_map_duration(blame_groups, project)
@@ -25,7 +25,7 @@ describe BlameHelper do
expect(duration[:started_days_ago]).to eq((duration[:now] - dates[1]).to_i / 1.day)
end
- it 'returns the earliest date from a project' do
+ it "returns the earliest date from a project" do
project = double(created_at: dates[4])
duration = helper.age_map_duration(blame_groups, project)
@@ -34,32 +34,32 @@ describe BlameHelper do
end
end
- describe '#age_map_class' do
+ describe "#age_map_class" do
let(:date) { Time.zone.local(2014, 3, 17, 0, 0, 0) }
- let(:blame_groups) { [{ commit: double(committed_date: date) }] }
+ let(:blame_groups) { [{commit: double(committed_date: date)}] }
let(:duration) do
project = double(created_at: date)
helper.age_map_duration(blame_groups, project)
end
- it 'returns blame-commit-age-9 when oldest' do
- expect(helper.age_map_class(date, duration)).to eq 'blame-commit-age-9'
+ it "returns blame-commit-age-9 when oldest" do
+ expect(helper.age_map_class(date, duration)).to eq "blame-commit-age-9"
end
- it 'returns blame-commit-age-0 class when newest' do
- expect(helper.age_map_class(duration[:now], duration)).to eq 'blame-commit-age-0'
+ it "returns blame-commit-age-0 class when newest" do
+ expect(helper.age_map_class(duration[:now], duration)).to eq "blame-commit-age-0"
end
- context 'when called on the same day as project creation' do
+ context "when called on the same day as project creation" do
let(:same_day_duration) do
project = double(created_at: now)
helper.age_map_duration(today_blame_groups, project)
end
- let(:today_blame_groups) { [{ commit: double(committed_date: now) }] }
+ let(:today_blame_groups) { [{commit: double(committed_date: now)}] }
let(:now) { Time.zone.now }
- it 'returns blame-commit-age-0 class' do
- expect(helper.age_map_class(duration[:now], same_day_duration)).to eq 'blame-commit-age-0'
+ it "returns blame-commit-age-0 class" do
+ expect(helper.age_map_class(duration[:now], same_day_duration)).to eq "blame-commit-age-0"
end
end
end
diff --git a/spec/helpers/blob_helper_spec.rb b/spec/helpers/blob_helper_spec.rb
index 2bc3933809f..8be0a360b6d 100644
--- a/spec/helpers/blob_helper_spec.rb
+++ b/spec/helpers/blob_helper_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobHelper do
include TreeHelper
- describe '#highlight' do
- it 'wraps highlighted content' do
- expect(helper.highlight('test.rb', '52')).to eq(%q[<pre class="code highlight"><code><span id="LC1" class="line" lang="ruby"><span class="mi">52</span></span></code></pre>])
+ describe "#highlight" do
+ it "wraps highlighted content" do
+ expect(helper.highlight("test.rb", "52")).to eq('<pre class="code highlight"><code><span id="LC1" class="line" lang="ruby"><span class="mi">52</span></span></code></pre>')
end
- it 'handles plain version' do
- expect(helper.highlight('test.rb', '52', plain: true)).to eq(%q[<pre class="code highlight"><code><span id="LC1" class="line" lang="">52</span></code></pre>])
+ it "handles plain version" do
+ expect(helper.highlight("test.rb", "52", plain: true)).to eq('<pre class="code highlight"><code><span id="LC1" class="line" lang="">52</span></code></pre>')
end
end
describe "#sanitize_svg_data" do
- let(:input_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'unsanitized.svg') }
+ let(:input_svg_path) { File.join(Rails.root, "spec", "fixtures", "unsanitized.svg") }
let(:data) { File.read(input_svg_path) }
- let(:expected_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'sanitized.svg') }
+ let(:expected_svg_path) { File.join(Rails.root, "spec", "fixtures", "sanitized.svg") }
let(:expected) { File.read(expected_svg_path) }
- it 'retains essential elements' do
+ it "retains essential elements" do
expect(sanitize_svg_data(data)).to eq(expected)
end
end
describe "#edit_blob_link" do
- let(:namespace) { create(:namespace, name: 'gitlab' )}
+ let(:namespace) { create(:namespace, name: "gitlab")}
let(:project) { create(:project, :repository, namespace: namespace) }
before do
@@ -33,44 +33,44 @@ describe BlobHelper do
allow(self).to receive(:can_collaborate_with_project?).and_return(true)
end
- it 'verifies blob is text' do
+ it "verifies blob is text" do
expect(helper).not_to receive(:blob_text_viewable?)
- button = edit_blob_button(project, 'refs/heads/master', 'README.md')
+ button = edit_blob_button(project, "refs/heads/master", "README.md")
- expect(button).to start_with('<button')
+ expect(button).to start_with("<button")
end
- it 'uses the passed blob instead retrieve from repository' do
- blob = project.repository.blob_at('refs/heads/master', 'README.md')
+ it "uses the passed blob instead retrieve from repository" do
+ blob = project.repository.blob_at("refs/heads/master", "README.md")
expect(project.repository).not_to receive(:blob_at)
- edit_blob_button(project, 'refs/heads/master', 'README.md', blob: blob)
+ edit_blob_button(project, "refs/heads/master", "README.md", blob: blob)
end
- it 'returns a link with the proper route' do
+ it "returns a link with the proper route" do
stub_feature_flags(web_ide_default: false)
- link = edit_blob_button(project, 'master', 'README.md')
+ link = edit_blob_button(project, "master", "README.md")
- expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md")
+ expect(Capybara.string(link).find_link("Edit")[:href]).to eq("/#{project.full_path}/edit/master/README.md")
end
- it 'returns a link with a Web IDE route' do
- link = edit_blob_button(project, 'master', 'README.md')
+ it "returns a link with a Web IDE route" do
+ link = edit_blob_button(project, "master", "README.md")
- expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/-/ide/project/#{project.full_path}/edit/master/-/README.md")
+ expect(Capybara.string(link).find_link("Edit")[:href]).to eq("/-/ide/project/#{project.full_path}/edit/master/-/README.md")
end
- it 'returns a link with the passed link_opts on the expected route' do
+ it "returns a link with the passed link_opts on the expected route" do
stub_feature_flags(web_ide_default: false)
- link = edit_blob_button(project, 'master', 'README.md', link_opts: { mr_id: 10 })
+ link = edit_blob_button(project, "master", "README.md", link_opts: {mr_id: 10})
- expect(Capybara.string(link).find_link('Edit')[:href]).to eq("/#{project.full_path}/edit/master/README.md?mr_id=10")
+ expect(Capybara.string(link).find_link("Edit")[:href]).to eq("/#{project.full_path}/edit/master/README.md?mr_id=10")
end
end
- context 'viewer related' do
+ context "viewer related" do
include FakeBlobHelpers
let(:project) { build(:project, lfs_enabled: true) }
@@ -92,48 +92,48 @@ describe BlobHelper do
let(:viewer) { viewer_class.new(blob) }
let(:blob) { fake_blob }
- describe '#blob_render_error_reason' do
- context 'for error :too_large' do
- context 'when the blob size is larger than the absolute size limit' do
+ describe "#blob_render_error_reason" do
+ context "for error :too_large" do
+ context "when the blob size is larger than the absolute size limit" do
let(:blob) { fake_blob(size: 10.megabytes) }
- it 'returns an error message' do
- expect(helper.blob_render_error_reason(viewer)).to eq('it is larger than 5 MB')
+ it "returns an error message" do
+ expect(helper.blob_render_error_reason(viewer)).to eq("it is larger than 5 MB")
end
end
- context 'when the blob size is larger than the size limit' do
+ context "when the blob size is larger than the size limit" do
let(:blob) { fake_blob(size: 2.megabytes) }
- it 'returns an error message' do
- expect(helper.blob_render_error_reason(viewer)).to eq('it is larger than 1 MB')
+ it "returns an error message" do
+ expect(helper.blob_render_error_reason(viewer)).to eq("it is larger than 1 MB")
end
end
end
- context 'for error :server_side_but_stored_externally' do
+ context "for error :server_side_but_stored_externally" do
let(:blob) { fake_blob(lfs: true) }
- it 'returns an error message' do
- expect(helper.blob_render_error_reason(viewer)).to eq('it is stored in LFS')
+ it "returns an error message" do
+ expect(helper.blob_render_error_reason(viewer)).to eq("it is stored in LFS")
end
end
end
- describe '#blob_render_error_options' do
+ describe "#blob_render_error_options" do
before do
assign(:project, project)
assign(:blob, blob)
- assign(:id, File.join('master', blob.path))
+ assign(:id, File.join("master", blob.path))
- controller.params[:controller] = 'projects/blob'
- controller.params[:action] = 'show'
+ controller.params[:controller] = "projects/blob"
+ controller.params[:action] = "show"
controller.params[:namespace_id] = project.namespace.to_param
controller.params[:project_id] = project.to_param
- controller.params[:id] = File.join('master', blob.path)
+ controller.params[:id] = File.join("master", blob.path)
end
- context 'for error :collapsed' do
+ context "for error :collapsed" do
let(:blob) { fake_blob(size: 2.megabytes) }
it 'includes a "load it anyway" link' do
@@ -141,24 +141,24 @@ describe BlobHelper do
end
end
- context 'for error :too_large' do
+ context "for error :too_large" do
let(:blob) { fake_blob(size: 10.megabytes) }
it 'does not include a "load it anyway" link' do
expect(helper.blob_render_error_options(viewer)).not_to include(/load it anyway/)
end
- context 'when the viewer is rich' do
- context 'the blob is rendered as text' do
- let(:blob) { fake_blob(path: 'file.md', size: 2.megabytes) }
+ context "when the viewer is rich" do
+ context "the blob is rendered as text" do
+ let(:blob) { fake_blob(path: "file.md", size: 2.megabytes) }
it 'includes a "view the source" link' do
expect(helper.blob_render_error_options(viewer)).to include(/view the source/)
end
end
- context 'the blob is not rendered as text' do
- let(:blob) { fake_blob(path: 'file.pdf', binary: true, size: 2.megabytes) }
+ context "the blob is not rendered as text" do
+ let(:blob) { fake_blob(path: "file.pdf", binary: true, size: 2.megabytes) }
it 'does not include a "view the source" link' do
expect(helper.blob_render_error_options(viewer)).not_to include(/view the source/)
@@ -166,12 +166,12 @@ describe BlobHelper do
end
end
- context 'when the viewer is not rich' do
+ context "when the viewer is not rich" do
before do
viewer_class.type = :simple
end
- let(:blob) { fake_blob(path: 'file.md', size: 2.megabytes) }
+ let(:blob) { fake_blob(path: "file.md", size: 2.megabytes) }
it 'does not include a "view the source" link' do
expect(helper.blob_render_error_options(viewer)).not_to include(/view the source/)
@@ -183,8 +183,8 @@ describe BlobHelper do
end
end
- context 'for error :server_side_but_stored_externally' do
- let(:blob) { fake_blob(path: 'file.md', lfs: true) }
+ context "for error :server_side_but_stored_externally" do
+ let(:blob) { fake_blob(path: "file.md", lfs: true) }
it 'does not include a "load it anyway" link' do
expect(helper.blob_render_error_options(viewer)).not_to include(/load it anyway/)
@@ -201,7 +201,7 @@ describe BlobHelper do
end
end
- describe '#ide_edit_path' do
+ describe "#ide_edit_path" do
let(:project) { create(:project) }
around do |example|
@@ -213,19 +213,19 @@ describe BlobHelper do
end
end
- it 'returns full IDE path' do
+ it "returns full IDE path" do
Rails.application.routes.default_url_options[:script_name] = nil
expect(helper.ide_edit_path(project, "master", "")).to eq("/-/ide/project/#{project.namespace.path}/#{project.path}/edit/master")
end
- it 'returns full IDE path with second -' do
+ it "returns full IDE path with second -" do
Rails.application.routes.default_url_options[:script_name] = nil
expect(helper.ide_edit_path(project, "testing/slashes", "readme.md")).to eq("/-/ide/project/#{project.namespace.path}/#{project.path}/edit/testing/slashes/-/readme.md")
end
- it 'returns IDE path without relative_url_root' do
+ it "returns IDE path without relative_url_root" do
Rails.application.routes.default_url_options[:script_name] = "/gitlab"
expect(helper.ide_edit_path(project, "master", "")).to eq("/gitlab/-/ide/project/#{project.namespace.path}/#{project.path}/edit/master")
diff --git a/spec/helpers/boards_helper_spec.rb b/spec/helpers/boards_helper_spec.rb
index b22947911b9..a98caaba8a8 100644
--- a/spec/helpers/boards_helper_spec.rb
+++ b/spec/helpers/boards_helper_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe BoardsHelper do
- describe '#build_issue_link_base' do
- context 'project board' do
- it 'returns correct path for project board' do
+ describe "#build_issue_link_base" do
+ context "project board" do
+ it "returns correct path for project board" do
@project = create(:project)
@board = create(:board, project: @project)
@@ -11,25 +11,25 @@ describe BoardsHelper do
end
end
- context 'group board' do
- let(:base_group) { create(:group, path: 'base') }
+ context "group board" do
+ let(:base_group) { create(:group, path: "base") }
- it 'returns correct path for base group' do
+ it "returns correct path for base group" do
@board = create(:board, group: base_group)
- expect(build_issue_link_base).to eq('/base/:project_path/issues')
+ expect(build_issue_link_base).to eq("/base/:project_path/issues")
end
- it 'returns correct path for subgroup' do
- subgroup = create(:group, parent: base_group, path: 'sub')
+ it "returns correct path for subgroup" do
+ subgroup = create(:group, parent: base_group, path: "sub")
@board = create(:board, group: subgroup)
- expect(build_issue_link_base).to eq('/base/sub/:project_path/issues')
+ expect(build_issue_link_base).to eq("/base/sub/:project_path/issues")
end
end
end
- describe '#board_data' do
+ describe "#board_data" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
@@ -42,7 +42,7 @@ describe BoardsHelper do
allow(helper).to receive(:can?).with(user, :admin_list, project).and_return(true)
end
- it 'returns a board_lists_path as lists_endpoint' do
+ it "returns a board_lists_path as lists_endpoint" do
expect(helper.board_data[:lists_endpoint]).to eq(board_lists_path(board))
end
end
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb
index 9bec0f9f432..ebda6070b80 100644
--- a/spec/helpers/broadcast_messages_helper_spec.rb
+++ b/spec/helpers/broadcast_messages_helper_spec.rb
@@ -1,60 +1,60 @@
-require 'spec_helper'
+require "spec_helper"
describe BroadcastMessagesHelper do
- describe 'broadcast_message' do
- it 'returns nil when no current message' do
+ describe "broadcast_message" do
+ it "returns nil when no current message" do
expect(helper.broadcast_message(nil)).to be_nil
end
- it 'includes the current message' do
- current = BroadcastMessage.new(message: 'Current Message')
+ it "includes the current message" do
+ current = BroadcastMessage.new(message: "Current Message")
allow(helper).to receive(:broadcast_message_style).and_return(nil)
- expect(helper.broadcast_message(current)).to include 'Current Message'
+ expect(helper.broadcast_message(current)).to include "Current Message"
end
- it 'includes custom style' do
- current = BroadcastMessage.new(message: 'Current Message')
+ it "includes custom style" do
+ current = BroadcastMessage.new(message: "Current Message")
- allow(helper).to receive(:broadcast_message_style).and_return('foo')
+ allow(helper).to receive(:broadcast_message_style).and_return("foo")
expect(helper.broadcast_message(current)).to include 'style="foo"'
end
end
- describe 'broadcast_message_style' do
- it 'defaults to no style' do
+ describe "broadcast_message_style" do
+ it "defaults to no style" do
broadcast_message = spy
- expect(helper.broadcast_message_style(broadcast_message)).to eq ''
+ expect(helper.broadcast_message_style(broadcast_message)).to eq ""
end
- it 'allows custom style' do
- broadcast_message = double(color: '#f2dede', font: '#b94a48')
+ it "allows custom style" do
+ broadcast_message = double(color: "#f2dede", font: "#b94a48")
expect(helper.broadcast_message_style(broadcast_message))
- .to match('background-color: #f2dede; color: #b94a48')
+ .to match("background-color: #f2dede; color: #b94a48")
end
end
- describe 'broadcast_message_status' do
- it 'returns Active' do
+ describe "broadcast_message_status" do
+ it "returns Active" do
message = build(:broadcast_message)
- expect(helper.broadcast_message_status(message)).to eq 'Active'
+ expect(helper.broadcast_message_status(message)).to eq "Active"
end
- it 'returns Expired' do
+ it "returns Expired" do
message = build(:broadcast_message, :expired)
- expect(helper.broadcast_message_status(message)).to eq 'Expired'
+ expect(helper.broadcast_message_status(message)).to eq "Expired"
end
- it 'returns Pending' do
+ it "returns Pending" do
message = build(:broadcast_message, :future)
- expect(helper.broadcast_message_status(message)).to eq 'Pending'
+ expect(helper.broadcast_message_status(message)).to eq "Pending"
end
end
end
diff --git a/spec/helpers/button_helper_spec.rb b/spec/helpers/button_helper_spec.rb
index eebae1d7290..5a00d0b1c41 100644
--- a/spec/helpers/button_helper_spec.rb
+++ b/spec/helpers/button_helper_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe ButtonHelper do
- describe 'http_clone_button' do
+ describe "http_clone_button" do
let(:user) { create(:user) }
let(:project) { build_stubbed(:project) }
- let(:has_tooltip_class) { 'has-tooltip' }
+ let(:has_tooltip_class) { "has-tooltip" }
def element
element = helper.http_clone_button(project)
@@ -16,60 +16,60 @@ describe ButtonHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'with internal auth enabled' do
- context 'when user has a password' do
- it 'shows no tooltip' do
- expect(element.attr('class')).not_to include(has_tooltip_class)
+ context "with internal auth enabled" do
+ context "when user has a password" do
+ it "shows no tooltip" do
+ expect(element.attr("class")).not_to include(has_tooltip_class)
end
end
- context 'when user has password automatically set' do
+ context "when user has password automatically set" do
let(:user) { create(:user, password_automatically_set: true) }
- it 'shows the password text on the dropdown' do
- description = element.search('.dropdown-menu-inner-content').first
+ it "shows the password text on the dropdown" do
+ description = element.search(".dropdown-menu-inner-content").first
- expect(description.inner_text).to eq 'Set a password on your account to pull or push via HTTP.'
+ expect(description.inner_text).to eq "Set a password on your account to pull or push via HTTP."
end
end
end
- context 'with internal auth disabled' do
+ context "with internal auth disabled" do
before do
stub_application_setting(password_authentication_enabled_for_git?: false)
end
- context 'when user has no personal access tokens' do
- it 'has a personal access token text on the dropdown description' do
- description = element.search('.dropdown-menu-inner-content').first
+ context "when user has no personal access tokens" do
+ it "has a personal access token text on the dropdown description" do
+ description = element.search(".dropdown-menu-inner-content").first
- expect(description.inner_text).to eq 'Create a personal access token on your account to pull or push via HTTP.'
+ expect(description.inner_text).to eq "Create a personal access token on your account to pull or push via HTTP."
end
end
- context 'when user has personal access tokens' do
+ context "when user has personal access tokens" do
before do
create(:personal_access_token, user: user)
end
- it 'does not have a personal access token text on the dropdown description' do
- description = element.search('.dropdown-menu-inner-content').first
+ it "does not have a personal access token text on the dropdown description" do
+ description = element.search(".dropdown-menu-inner-content").first
expect(description).to be_nil
end
end
end
- context 'when user is ldap user' do
+ context "when user is ldap user" do
let(:user) { create(:omniauth_user, password_automatically_set: true) }
- it 'shows no tooltip' do
- expect(element.attr('class')).not_to include(has_tooltip_class)
+ it "shows no tooltip" do
+ expect(element.attr("class")).not_to include(has_tooltip_class)
end
end
end
- describe 'ssh_button' do
+ describe "ssh_button" do
let(:user) { create(:user) }
let(:project) { build_stubbed(:project) }
@@ -83,40 +83,40 @@ describe ButtonHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'without an ssh key on the user' do
- it 'shows a warning on the dropdown description' do
- description = element.search('.dropdown-menu-inner-content').first
+ context "without an ssh key on the user" do
+ it "shows a warning on the dropdown description" do
+ description = element.search(".dropdown-menu-inner-content").first
expect(description.inner_text).to eq "You won't be able to pull or push project code via SSH until you add an SSH key to your profile"
end
end
- context 'without an ssh key on the user and user_show_add_ssh_key_message unset' do
+ context "without an ssh key on the user and user_show_add_ssh_key_message unset" do
before do
stub_application_setting(user_show_add_ssh_key_message: false)
end
- it 'there is no warning on the dropdown description' do
- description = element.search('.dropdown-menu-inner-content').first
+ it "there is no warning on the dropdown description" do
+ description = element.search(".dropdown-menu-inner-content").first
expect(description).to be_nil
end
end
- context 'with an ssh key on the user' do
+ context "with an ssh key on the user" do
before do
create(:key, user: user)
end
- it 'there is no warning on the dropdown description' do
- description = element.search('.dropdown-menu-inner-content').first
+ it "there is no warning on the dropdown description" do
+ description = element.search(".dropdown-menu-inner-content").first
expect(description).to eq nil
end
end
end
- describe 'ssh and http clone buttons' do
+ describe "ssh and http clone buttons" do
let(:user) { create(:user) }
let(:project) { build_stubbed(:project) }
@@ -136,15 +136,15 @@ describe ButtonHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- it 'only shows the title of any of the clone buttons when append_link is false' do
- expect(http_button_element.text).to eq('HTTP')
- expect(http_button_element.search('.dropdown-menu-inner-content').first).to eq(nil)
- expect(ssh_button_element.text).to eq('SSH')
- expect(ssh_button_element.search('.dropdown-menu-inner-content').first).to eq(nil)
+ it "only shows the title of any of the clone buttons when append_link is false" do
+ expect(http_button_element.text).to eq("HTTP")
+ expect(http_button_element.search(".dropdown-menu-inner-content").first).to eq(nil)
+ expect(ssh_button_element.text).to eq("SSH")
+ expect(ssh_button_element.search(".dropdown-menu-inner-content").first).to eq(nil)
end
end
- describe 'clipboard_button' do
+ describe "clipboard_button" do
include IconsHelper
let(:user) { create(:user) }
@@ -159,52 +159,52 @@ describe ButtonHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'with default options' do
- context 'when no `text` attribute is not provided' do
- it 'shows copy to clipboard button with default configuration and no text set to copy' do
- expect(element.attr('class')).to eq('btn btn-clipboard btn-transparent')
- expect(element.attr('type')).to eq('button')
- expect(element.attr('aria-label')).to eq('Copy to clipboard')
- expect(element.attr('data-toggle')).to eq('tooltip')
- expect(element.attr('data-placement')).to eq('bottom')
- expect(element.attr('data-container')).to eq('body')
- expect(element.attr('data-clipboard-text')).to eq(nil)
+ context "with default options" do
+ context "when no `text` attribute is not provided" do
+ it "shows copy to clipboard button with default configuration and no text set to copy" do
+ expect(element.attr("class")).to eq("btn btn-clipboard btn-transparent")
+ expect(element.attr("type")).to eq("button")
+ expect(element.attr("aria-label")).to eq("Copy to clipboard")
+ expect(element.attr("data-toggle")).to eq("tooltip")
+ expect(element.attr("data-placement")).to eq("bottom")
+ expect(element.attr("data-container")).to eq("body")
+ expect(element.attr("data-clipboard-text")).to eq(nil)
expect(element.inner_text).to eq("")
- expect(element.to_html).to include sprite_icon('duplicate')
+ expect(element.to_html).to include sprite_icon("duplicate")
end
end
- context 'when `text` attribute is provided' do
- it 'shows copy to clipboard button with provided `text` to copy' do
- expect(element(text: 'Hello World!').attr('data-clipboard-text')).to eq('Hello World!')
+ context "when `text` attribute is provided" do
+ it "shows copy to clipboard button with provided `text` to copy" do
+ expect(element(text: "Hello World!").attr("data-clipboard-text")).to eq("Hello World!")
end
end
- context 'when `title` attribute is provided' do
- it 'shows copy to clipboard button with provided `title` as tooltip' do
- expect(element(title: 'Copy to my clipboard!').attr('aria-label')).to eq('Copy to my clipboard!')
+ context "when `title` attribute is provided" do
+ it "shows copy to clipboard button with provided `title` as tooltip" do
+ expect(element(title: "Copy to my clipboard!").attr("aria-label")).to eq("Copy to my clipboard!")
end
end
end
- context 'with `button_text` attribute provided' do
- it 'shows copy to clipboard button with provided `button_text` as button label' do
- expect(element(button_text: 'Copy text').inner_text).to eq('Copy text')
+ context "with `button_text` attribute provided" do
+ it "shows copy to clipboard button with provided `button_text` as button label" do
+ expect(element(button_text: "Copy text").inner_text).to eq("Copy text")
end
end
- context 'with `hide_tooltip` attribute provided' do
- it 'shows copy to clipboard button without tooltip support' do
- expect(element(hide_tooltip: true).attr('data-placement')).to eq(nil)
- expect(element(hide_tooltip: true).attr('data-toggle')).to eq(nil)
- expect(element(hide_tooltip: true).attr('data-container')).to eq(nil)
+ context "with `hide_tooltip` attribute provided" do
+ it "shows copy to clipboard button without tooltip support" do
+ expect(element(hide_tooltip: true).attr("data-placement")).to eq(nil)
+ expect(element(hide_tooltip: true).attr("data-toggle")).to eq(nil)
+ expect(element(hide_tooltip: true).attr("data-container")).to eq(nil)
end
end
- context 'with `hide_button_icon` attribute provided' do
- it 'shows copy to clipboard button without tooltip support' do
- expect(element(hide_button_icon: true).to_html).not_to include sprite_icon('duplicate')
+ context "with `hide_button_icon` attribute provided" do
+ it "shows copy to clipboard button without tooltip support" do
+ expect(element(hide_button_icon: true).to_html).not_to include sprite_icon("duplicate")
end
end
end
diff --git a/spec/helpers/calendar_helper_spec.rb b/spec/helpers/calendar_helper_spec.rb
index 828a9d9fea0..d85380c1e86 100644
--- a/spec/helpers/calendar_helper_spec.rb
+++ b/spec/helpers/calendar_helper_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe CalendarHelper do
- describe '#calendar_url_options' do
- context 'when signed in' do
+ describe "#calendar_url_options" do
+ context "when signed in" do
it "includes the current_user's feed_token" do
current_user = create(:user)
allow(helper).to receive(:current_user).and_return(current_user)
@@ -10,7 +10,7 @@ describe CalendarHelper do
end
end
- context 'when signed out' do
+ context "when signed out" do
it "does not have a feed_token" do
allow(helper).to receive(:current_user).and_return(nil)
expect(helper.calendar_url_options[:feed_token]).to be_nil
diff --git a/spec/helpers/ci_status_helper_spec.rb b/spec/helpers/ci_status_helper_spec.rb
index bc2422aba90..5967affbcf1 100644
--- a/spec/helpers/ci_status_helper_spec.rb
+++ b/spec/helpers/ci_status_helper_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe CiStatusHelper do
include IconsHelper
- let(:success_commit) { double("Ci::Pipeline", status: 'success') }
- let(:failed_commit) { double("Ci::Pipeline", status: 'failed') }
+ let(:success_commit) { double("Ci::Pipeline", status: "success") }
+ let(:failed_commit) { double("Ci::Pipeline", status: "failed") }
- describe '#ci_icon_for_status' do
- it 'renders to correct svg on success' do
- expect(helper.ci_icon_for_status('success').to_s)
- .to include 'status_success'
+ describe "#ci_icon_for_status" do
+ it "renders to correct svg on success" do
+ expect(helper.ci_icon_for_status("success").to_s)
+ .to include "status_success"
end
- it 'renders the correct svg on failure' do
- expect(helper.ci_icon_for_status('failed').to_s)
- .to include 'status_failed'
+ it "renders the correct svg on failure" do
+ expect(helper.ci_icon_for_status("failed").to_s)
+ .to include "status_failed"
end
end
- describe '#ci_text_for_status' do
- context 'when status is manual' do
- it 'changes the status to blocked' do
- expect(helper.ci_text_for_status('manual'))
- .to eq 'blocked'
+ describe "#ci_text_for_status" do
+ context "when status is manual" do
+ it "changes the status to blocked" do
+ expect(helper.ci_text_for_status("manual"))
+ .to eq "blocked"
end
end
- context 'when status is success' do
- it 'changes the status to passed' do
- expect(helper.ci_text_for_status('success'))
- .to eq 'passed'
+ context "when status is success" do
+ it "changes the status to passed" do
+ expect(helper.ci_text_for_status("success"))
+ .to eq "passed"
end
end
- context 'when status is something else' do
- it 'returns status unchanged' do
- expect(helper.ci_text_for_status('some-status'))
- .to eq 'some-status'
+ context "when status is something else" do
+ it "returns status unchanged" do
+ expect(helper.ci_text_for_status("some-status"))
+ .to eq "some-status"
end
end
end
@@ -47,7 +47,7 @@ describe CiStatusHelper do
build_stubbed(:project),
pipeline_info: {
sha: "123abc",
- status: "success"
+ status: "success",
}
)
expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success")
diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb
index 824b3ab4fc1..276644cf3c8 100644
--- a/spec/helpers/commits_helper_spec.rb
+++ b/spec/helpers/commits_helper_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
describe CommitsHelper do
- describe 'commit_author_link' do
- it 'escapes the author email' do
+ describe "commit_author_link" do
+ it "escapes the author email" do
commit = double(
author: nil,
- author_name: 'Persistent XSS',
+ author_name: "Persistent XSS",
author_email: 'my@email.com" onmouseover="alert(1)'
)
@@ -13,23 +13,23 @@ describe CommitsHelper do
.not_to include('onmouseover="alert(1)"')
end
- it 'escapes the author name' do
+ it "escapes the author name" do
user = build_stubbed(:user, name: 'Foo <script>alert("XSS")</script>')
- commit = double(author: user, author_name: '', author_email: '')
+ commit = double(author: user, author_name: "", author_email: "")
expect(helper.commit_author_link(commit))
- .to include('Foo &lt;script&gt;')
+ .to include("Foo &lt;script&gt;")
expect(helper.commit_author_link(commit, avatar: true))
- .to include('commit-author-name', 'js-user-link', 'Foo &lt;script&gt;')
+ .to include("commit-author-name", "js-user-link", "Foo &lt;script&gt;")
end
end
- describe 'commit_committer_link' do
- it 'escapes the committer email' do
+ describe "commit_committer_link" do
+ it "escapes the committer email" do
commit = double(
committer: nil,
- committer_name: 'Persistent XSS',
+ committer_name: "Persistent XSS",
committer_email: 'my@email.com" onmouseover="alert(1)'
)
@@ -37,34 +37,34 @@ describe CommitsHelper do
.not_to include('onmouseover="alert(1)"')
end
- it 'escapes the committer name' do
+ it "escapes the committer name" do
user = build_stubbed(:user, name: 'Foo <script>alert("XSS")</script>')
- commit = double(committer: user, committer_name: '', committer_email: '')
+ commit = double(committer: user, committer_name: "", committer_email: "")
expect(helper.commit_committer_link(commit))
- .to include('Foo &lt;script&gt;')
+ .to include("Foo &lt;script&gt;")
expect(helper.commit_committer_link(commit, avatar: true))
- .to include('commit-committer-name', 'Foo &lt;script&gt;')
+ .to include("commit-committer-name", "Foo &lt;script&gt;")
end
end
- describe '#view_on_environment_button' do
+ describe "#view_on_environment_button" do
let(:project) { create(:project) }
- let(:environment) { create(:environment, external_url: 'http://example.com') }
- let(:path) { 'source/file.html' }
+ let(:environment) { create(:environment, external_url: "http://example.com") }
+ let(:path) { "source/file.html" }
let(:sha) { RepoHelpers.sample_commit.id }
before do
- allow(environment).to receive(:external_url_for).with(path, sha).and_return('http://example.com/file.html')
+ allow(environment).to receive(:external_url_for).with(path, sha).and_return("http://example.com/file.html")
end
- it 'returns a link tag linking to the file in the environment' do
+ it "returns a link tag linking to the file in the environment" do
html = helper.view_on_environment_button(sha, path, environment)
- node = Nokogiri::HTML.parse(html).at_css('a')
+ node = Nokogiri::HTML.parse(html).at_css("a")
- expect(node[:title]).to eq('View on example.com')
- expect(node[:href]).to eq('http://example.com/file.html')
+ expect(node[:title]).to eq("View on example.com")
+ expect(node[:href]).to eq("http://example.com/file.html")
end
end
end
diff --git a/spec/helpers/components_helper_spec.rb b/spec/helpers/components_helper_spec.rb
index 94a59193be8..65ea8d8b337 100644
--- a/spec/helpers/components_helper_spec.rb
+++ b/spec/helpers/components_helper_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe ComponentsHelper do
- describe '#gitlab_workhorse_version' do
- context 'without a Gitlab-Workhorse header' do
- it 'shows the version from Gitlab::Workhorse.version' do
+ describe "#gitlab_workhorse_version" do
+ context "without a Gitlab-Workhorse header" do
+ it "shows the version from Gitlab::Workhorse.version" do
expect(helper.gitlab_workhorse_version).to eq Gitlab::Workhorse.version
end
end
- context 'with a Gitlab-Workhorse header' do
+ context "with a Gitlab-Workhorse header" do
before do
- helper.request.headers['Gitlab-Workhorse'] = '42.42.0-rc3'
+ helper.request.headers["Gitlab-Workhorse"] = "42.42.0-rc3"
end
- it 'shows the actual GitLab Workhorse version currently in use' do
- expect(helper.gitlab_workhorse_version).to eq '42.42.0'
+ it "shows the actual GitLab Workhorse version currently in use" do
+ expect(helper.gitlab_workhorse_version).to eq "42.42.0"
end
end
end
diff --git a/spec/helpers/dashboard_helper_spec.rb b/spec/helpers/dashboard_helper_spec.rb
index 7ba24ba2956..91a5ff8819e 100644
--- a/spec/helpers/dashboard_helper_spec.rb
+++ b/spec/helpers/dashboard_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DashboardHelper do
let(:user) { build(:user) }
@@ -8,14 +8,14 @@ describe DashboardHelper do
allow(helper).to receive(:can?) { true }
end
- describe '#dashboard_nav_links' do
- it 'has all the expected links by default' do
+ describe "#dashboard_nav_links" do
+ it "has all the expected links by default" do
menu_items = [:projects, :groups, :activity, :milestones, :snippets]
expect(helper.dashboard_nav_links).to contain_exactly(*menu_items)
end
- it 'does not contain cross project elements when the user cannot read cross project' do
+ it "does not contain cross project elements when the user cannot read cross project" do
expect(helper).to receive(:can?).with(user, :read_cross_project) { false }
expect(helper.dashboard_nav_links).not_to include(:activity, :milestones)
diff --git a/spec/helpers/defer_script_tag_helper_spec.rb b/spec/helpers/defer_script_tag_helper_spec.rb
index d10b6f134e4..4aa7a46ee06 100644
--- a/spec/helpers/defer_script_tag_helper_spec.rb
+++ b/spec/helpers/defer_script_tag_helper_spec.rb
@@ -1,11 +1,10 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe DeferScriptTagHelper do
- describe 'script tag' do
- script_url = 'test.js'
+ describe "script tag" do
+ script_url = "test.js"
- it 'returns an script tag with defer=true' do
+ it "returns an script tag with defer=true" do
expect(javascript_include_tag(script_url).to_s)
.to eq "<script src=\"/javascripts/#{script_url}\" defer=\"defer\"></script>"
end
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 5396243f44d..d6cb3dce92c 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffHelper do
include RepoHelpers
@@ -11,117 +11,117 @@ describe DiffHelper do
let(:diff_refs) { commit.diff_refs }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: diff_refs, repository: repository) }
- describe 'diff_view' do
- it 'uses the view param over the cookie' do
- controller.params[:view] = 'parallel'
- helper.request.cookies[:diff_view] = 'inline'
+ describe "diff_view" do
+ it "uses the view param over the cookie" do
+ controller.params[:view] = "parallel"
+ helper.request.cookies[:diff_view] = "inline"
expect(helper.diff_view).to eq :parallel
end
- it 'returns the default value when the view param is invalid' do
- controller.params[:view] = 'invalid'
+ it "returns the default value when the view param is invalid" do
+ controller.params[:view] = "invalid"
expect(helper.diff_view).to eq :inline
end
- it 'returns a valid value when cookie is set' do
- helper.request.cookies[:diff_view] = 'parallel'
+ it "returns a valid value when cookie is set" do
+ helper.request.cookies[:diff_view] = "parallel"
expect(helper.diff_view).to eq :parallel
end
- it 'returns the default value when cookie is invalid' do
- helper.request.cookies[:diff_view] = 'invalid'
+ it "returns the default value when cookie is invalid" do
+ helper.request.cookies[:diff_view] = "invalid"
expect(helper.diff_view).to eq :inline
end
- it 'returns the default value when cookie is nil' do
+ it "returns the default value when cookie is nil" do
expect(helper.request.cookies).to be_empty
expect(helper.diff_view).to eq :inline
end
end
- describe 'diff_options' do
- it 'returns no collapse false' do
+ describe "diff_options" do
+ it "returns no collapse false" do
expect(diff_options).to include(expanded: false)
end
- it 'returns no collapse true if expanded' do
- allow(controller).to receive(:params) { { expanded: true } }
+ it "returns no collapse true if expanded" do
+ allow(controller).to receive(:params) { {expanded: true} }
expect(diff_options).to include(expanded: true)
end
- it 'returns no collapse true if action name diff_for_path' do
- allow(controller).to receive(:action_name) { 'diff_for_path' }
+ 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(expanded: true)
end
- 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')
+ 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 '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')
+ 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 '#diff_line_content' do
- context 'when the line is empty' do
- it 'returns a non breaking space' do
- expect(diff_line_content(nil)).to eq('&nbsp;')
+ describe "#diff_line_content" do
+ context "when the line is empty" do
+ it "returns a non breaking space" do
+ expect(diff_line_content(nil)).to eq("&nbsp;")
end
- it 'returns an HTML-safe string' do
+ it "returns an HTML-safe string" do
expect(diff_line_content(nil)).to be_html_safe
end
end
- context 'when the line is not empty' do
- context 'when the line starts with +, -, or a space' do
- it 'strips the first character' do
- expect(diff_line_content('+new line')).to eq('new line')
- expect(diff_line_content('-new line')).to eq('new line')
- expect(diff_line_content(' new line')).to eq('new line')
+ context "when the line is not empty" do
+ context "when the line starts with +, -, or a space" do
+ it "strips the first character" do
+ expect(diff_line_content("+new line")).to eq("new line")
+ expect(diff_line_content("-new line")).to eq("new line")
+ expect(diff_line_content(" new line")).to eq("new line")
end
- context 'when the line is HTML-safe' do
- it 'returns an HTML-safe string' do
- expect(diff_line_content('+new line'.html_safe)).to be_html_safe
- expect(diff_line_content('-new line'.html_safe)).to be_html_safe
- expect(diff_line_content(' new line'.html_safe)).to be_html_safe
+ context "when the line is HTML-safe" do
+ it "returns an HTML-safe string" do
+ expect(diff_line_content("+new line".html_safe)).to be_html_safe
+ expect(diff_line_content("-new line".html_safe)).to be_html_safe
+ expect(diff_line_content(" new line".html_safe)).to be_html_safe
end
end
- context 'when the line is not HTML-safe' do
- it 'returns a non-HTML-safe string' do
- expect(diff_line_content('+new line')).not_to be_html_safe
- expect(diff_line_content('-new line')).not_to be_html_safe
- expect(diff_line_content(' new line')).not_to be_html_safe
+ context "when the line is not HTML-safe" do
+ it "returns a non-HTML-safe string" do
+ expect(diff_line_content("+new line")).not_to be_html_safe
+ expect(diff_line_content("-new line")).not_to be_html_safe
+ expect(diff_line_content(" new line")).not_to be_html_safe
end
end
end
- context 'when the line does not start with a +, -, or a space' do
- it 'returns the string' do
- expect(diff_line_content('@@ -6,12 +6,18 @@ module Popen')).to eq('@@ -6,12 +6,18 @@ module Popen')
+ context "when the line does not start with a +, -, or a space" do
+ it "returns the string" do
+ expect(diff_line_content("@@ -6,12 +6,18 @@ module Popen")).to eq("@@ -6,12 +6,18 @@ module Popen")
end
- context 'when the line is HTML-safe' do
- it 'returns an HTML-safe string' do
- expect(diff_line_content('@@ -6,12 +6,18 @@ module Popen'.html_safe)).to be_html_safe
+ context "when the line is HTML-safe" do
+ it "returns an HTML-safe string" do
+ expect(diff_line_content("@@ -6,12 +6,18 @@ module Popen".html_safe)).to be_html_safe
end
end
- context 'when the line is not HTML-safe' do
- it 'returns a non-HTML-safe string' do
- expect(diff_line_content('@@ -6,12 +6,18 @@ module Popen')).not_to be_html_safe
+ context "when the line is not HTML-safe" do
+ it "returns a non-HTML-safe string" do
+ expect(diff_line_content("@@ -6,12 +6,18 @@ module Popen")).not_to be_html_safe
end
end
end
@@ -129,139 +129,139 @@ describe DiffHelper do
end
describe "#mark_inline_diffs" do
- let(:old_line) { %{abc 'def'} }
- let(:new_line) { %{abc "def"} }
+ let(:old_line) { %(abc 'def') }
+ let(:new_line) { %(abc "def") }
it "returns strings with marked inline diffs" do
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">&#39;def&#39;</span>})
+ expect(marked_old_line).to eq('abc <span class="idiff left right deletion">&#39;def&#39;</span>')
expect(marked_old_line).to be_html_safe
- expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">&quot;def&quot;</span>})
+ expect(marked_new_line).to eq('abc <span class="idiff left right addition">&quot;def&quot;</span>')
expect(marked_new_line).to be_html_safe
end
- context 'when given HTML' do
- it 'sanitizes it' do
- old_line = %{test.txt}
+ context "when given HTML" do
+ it "sanitizes it" do
+ old_line = %(test.txt)
new_line = %{<img src=x onerror=alert(document.domain)>}
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{<span class="idiff left right deletion">test.txt</span>})
+ expect(marked_old_line).to eq('<span class="idiff left right deletion">test.txt</span>')
expect(marked_old_line).to be_html_safe
- expect(marked_new_line).to eq(%q{<span class="idiff left right addition">&lt;img src=x onerror=alert(document.domain)&gt;</span>})
+ expect(marked_new_line).to eq('<span class="idiff left right addition">&lt;img src=x onerror=alert(document.domain)&gt;</span>')
expect(marked_new_line).to be_html_safe
end
- it 'sanitizes the entire line, not just the changes' do
+ it "sanitizes the entire line, not just the changes" do
old_line = %{<img src=x onerror=alert(document.domain)>}
new_line = %{<img src=y onerror=alert(document.domain)>}
marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line)
- expect(marked_old_line).to eq(%q{&lt;img src=<span class="idiff left right deletion">x</span> onerror=alert(document.domain)&gt;})
+ expect(marked_old_line).to eq('&lt;img src=<span class="idiff left right deletion">x</span> onerror=alert(document.domain)&gt;')
expect(marked_old_line).to be_html_safe
- expect(marked_new_line).to eq(%q{&lt;img src=<span class="idiff left right addition">y</span> onerror=alert(document.domain)&gt;})
+ expect(marked_new_line).to eq('&lt;img src=<span class="idiff left right addition">y</span> onerror=alert(document.domain)&gt;')
expect(marked_new_line).to be_html_safe
end
end
end
- describe '#parallel_diff_discussions' do
- let(:discussion) { { 'abc_3_3' => 'comment' } }
- let(:diff_file) { double(line_code: 'abc_3_3') }
+ describe "#parallel_diff_discussions" do
+ let(:discussion) { {"abc_3_3" => "comment"} }
+ let(:diff_file) { double(line_code: "abc_3_3") }
before do
helper.instance_variable_set(:@grouped_diff_discussions, discussion)
end
- it 'does not put comments on nonewline lines' do
- left = Gitlab::Diff::Line.new('\\nonewline', 'old-nonewline', 3, 3, 3)
- right = Gitlab::Diff::Line.new('\\nonewline', 'new-nonewline', 3, 3, 3)
+ it "does not put comments on nonewline lines" do
+ left = Gitlab::Diff::Line.new('\\nonewline', "old-nonewline", 3, 3, 3)
+ right = Gitlab::Diff::Line.new('\\nonewline', "new-nonewline", 3, 3, 3)
result = helper.parallel_diff_discussions(left, right, diff_file)
expect(result).to eq([nil, nil])
end
- it 'puts comments on added lines' do
- left = Gitlab::Diff::Line.new('\\nonewline', 'old-nonewline', 3, 3, 3)
- right = Gitlab::Diff::Line.new('new line', 'new', 3, 3, 3)
+ it "puts comments on added lines" do
+ left = Gitlab::Diff::Line.new('\\nonewline', "old-nonewline", 3, 3, 3)
+ right = Gitlab::Diff::Line.new("new line", "new", 3, 3, 3)
result = helper.parallel_diff_discussions(left, right, diff_file)
- expect(result).to eq([nil, 'comment'])
+ expect(result).to eq([nil, "comment"])
end
- it 'puts comments on unchanged lines' do
- left = Gitlab::Diff::Line.new('unchanged line', nil, 3, 3, 3)
- right = Gitlab::Diff::Line.new('unchanged line', nil, 3, 3, 3)
+ it "puts comments on unchanged lines" do
+ left = Gitlab::Diff::Line.new("unchanged line", nil, 3, 3, 3)
+ right = Gitlab::Diff::Line.new("unchanged line", nil, 3, 3, 3)
result = helper.parallel_diff_discussions(left, right, diff_file)
- expect(result).to eq(['comment', nil])
+ expect(result).to eq(["comment", nil])
end
end
describe "#diff_match_line" do
let(:old_pos) { 40 }
let(:new_pos) { 50 }
- let(:text) { 'some_text' }
+ let(:text) { "some_text" }
it "generates 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: ''
+ 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 "allows 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
+ 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 "generates 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
+ 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 "allows 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)'
+ 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 "allows 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)'
+ 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
- context '#diff_file_path_text' do
- it 'returns full path by default' do
+ context "#diff_file_path_text" do
+ it "returns full path by default" do
expect(diff_file_path_text(diff_file)).to eq(diff_file.new_path)
end
- it 'returns truncated path' do
+ it "returns truncated path" do
expect(diff_file_path_text(diff_file, max: 10)).to eq("...open.rb")
end
end
diff --git a/spec/helpers/emails_helper_spec.rb b/spec/helpers/emails_helper_spec.rb
index 03b4c19ec22..7358cc0ebc5 100644
--- a/spec/helpers/emails_helper_spec.rb
+++ b/spec/helpers/emails_helper_spec.rb
@@ -1,94 +1,94 @@
-require 'spec_helper'
+require "spec_helper"
describe EmailsHelper do
- describe 'sanitize_name' do
- context 'when name contains a valid URL string' do
- it 'returns name with `.` replaced with `_` to prevent mail clients from auto-linking URLs' do
- expect(sanitize_name('https://about.gitlab.com')).to eq('https://about_gitlab_com')
- expect(sanitize_name('www.gitlab.com')).to eq('www_gitlab_com')
- expect(sanitize_name('//about.gitlab.com/handbook/security/#best-practices')).to eq('//about_gitlab_com/handbook/security/#best-practices')
+ describe "sanitize_name" do
+ context "when name contains a valid URL string" do
+ it "returns name with `.` replaced with `_` to prevent mail clients from auto-linking URLs" do
+ expect(sanitize_name("https://about.gitlab.com")).to eq("https://about_gitlab_com")
+ expect(sanitize_name("www.gitlab.com")).to eq("www_gitlab_com")
+ expect(sanitize_name("//about.gitlab.com/handbook/security/#best-practices")).to eq("//about_gitlab_com/handbook/security/#best-practices")
end
- it 'returns name as it is when it does not contain a URL' do
- expect(sanitize_name('Foo Bar')).to eq('Foo Bar')
+ it "returns name as it is when it does not contain a URL" do
+ expect(sanitize_name("Foo Bar")).to eq("Foo Bar")
end
end
end
- describe 'password_reset_token_valid_time' do
+ describe "password_reset_token_valid_time" do
def validate_time_string(time_limit, expected_string)
Devise.reset_password_within = time_limit
expect(password_reset_token_valid_time).to eq(expected_string)
end
- context 'when time limit is less than 2 hours' do
- it 'displays the time in hours using a singular unit' do
- validate_time_string(1.hour, '1 hour')
+ context "when time limit is less than 2 hours" 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 'displays the time in hours using a plural unit' do
- validate_time_string(2.hours, '2 hours')
+ context "when time limit is 2 or more hours" 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 'rounds down to the nearest hour' do
- validate_time_string(96.minutes, '1 hour')
+ context "when time limit contains fractions of an 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 'displays the time in days using a singular unit' do
- validate_time_string(24.hours, '1 day')
+ context "when time limit is 24 or more hours" 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 'displays the time in days using a plural unit' do
- validate_time_string(2.days, '2 days')
+ context "when time limit is 2 or more days" 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 'rounds down to the nearest day' do
- validate_time_string(57.hours, '2 days')
+ context "when time limit contains fractions of a day" do
+ it "rounds down to the nearest day" do
+ validate_time_string(57.hours, "2 days")
end
end
end
- describe '#header_logo' do
- context 'there is a brand item with a logo' do
- it 'returns the brand header logo' do
- appearance = create :appearance, header_logo: fixture_file_upload('spec/fixtures/dk.png')
+ describe "#header_logo" do
+ context "there is a brand item with a logo" do
+ it "returns the brand header logo" do
+ appearance = create :appearance, header_logo: fixture_file_upload("spec/fixtures/dk.png")
expect(header_logo).to eq(
- %{<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />}
+ %(<img style="height: 50px" src="/uploads/-/system/appearance/header_logo/#{appearance.id}/dk.png" alt="Dk" />)
)
end
end
- context 'there is a brand item without a logo' do
- it 'returns the default header logo' do
+ context "there is a brand item without a logo" do
+ it "returns the default header logo" do
create :appearance, header_logo: nil
expect(header_logo).to eq(
- %{<img alt="GitLab" src="/images/mailers/gitlab_header_logo.gif" width="55" height="50" />}
+ %(<img alt="GitLab" src="/images/mailers/gitlab_header_logo.gif" width="55" height="50" />)
)
end
end
- context 'there is no brand item' do
- it 'returns the default header logo' do
+ context "there is no brand item" do
+ it "returns the default header logo" do
expect(header_logo).to eq(
- %{<img alt="GitLab" src="/images/mailers/gitlab_header_logo.gif" width="55" height="50" />}
+ %(<img alt="GitLab" src="/images/mailers/gitlab_header_logo.gif" width="55" height="50" />)
)
end
end
end
- describe '#create_list_id_string' do
+ describe "#create_list_id_string" do
using RSpec::Parameterized::TableSyntax
where(:full_path, :list_id_path) do
@@ -108,7 +108,7 @@ describe EmailsHelper do
end
with_them do
- it 'ellipcizes different variants' do
+ it "ellipcizes different variants" do
project = double("project")
allow(project).to receive(:full_path).and_return(full_path)
allow(project).to receive(:id).and_return(12345)
@@ -122,7 +122,7 @@ describe EmailsHelper do
end
end
- describe 'Create realistic List-Id identifier' do
+ describe "Create realistic List-Id identifier" do
using RSpec::Parameterized::TableSyntax
where(:full_path, :list_id_path) do
@@ -131,7 +131,7 @@ describe EmailsHelper do
end
with_them do
- it 'Produces the right List-Id' do
+ it "Produces the right List-Id" do
project = double("project")
allow(project).to receive(:full_path).and_return(full_path)
allow(project).to receive(:id).and_return(12345)
@@ -143,22 +143,22 @@ describe EmailsHelper do
end
end
- describe 'header and footer messages' do
- context 'when email_header_and_footer_enabled is enabled' do
- it 'returns header and footer messages' do
- create :appearance, header_message: 'Foo', footer_message: 'Bar', email_header_and_footer_enabled: true
+ describe "header and footer messages" do
+ context "when email_header_and_footer_enabled is enabled" do
+ it "returns header and footer messages" do
+ create :appearance, header_message: "Foo", footer_message: "Bar", email_header_and_footer_enabled: true
aggregate_failures do
- expect(html_header_message).to eq(%{<div class="header-message" style=""><p>Foo</p></div>})
- expect(html_footer_message).to eq(%{<div class="footer-message" style=""><p>Bar</p></div>})
- expect(text_header_message).to eq('Foo')
- expect(text_footer_message).to eq('Bar')
+ expect(html_header_message).to eq(%(<div class="header-message" style=""><p>Foo</p></div>))
+ expect(html_footer_message).to eq(%(<div class="footer-message" style=""><p>Bar</p></div>))
+ expect(text_header_message).to eq("Foo")
+ expect(text_footer_message).to eq("Bar")
end
end
- context 'when header and footer messages are empty' do
- it 'returns nil' do
- create :appearance, header_message: '', footer_message: '', email_header_and_footer_enabled: true
+ context "when header and footer messages are empty" do
+ it "returns nil" do
+ create :appearance, header_message: "", footer_message: "", email_header_and_footer_enabled: true
aggregate_failures do
expect(html_header_message).to eq(nil)
@@ -169,8 +169,8 @@ describe EmailsHelper do
end
end
- context 'when header and footer messages are nil' do
- it 'returns nil' do
+ context "when header and footer messages are nil" do
+ it "returns nil" do
create :appearance, header_message: nil, footer_message: nil, email_header_and_footer_enabled: true
aggregate_failures do
@@ -183,9 +183,9 @@ describe EmailsHelper do
end
end
- context 'when email_header_and_footer_enabled is disabled' do
- it 'returns header and footer messages' do
- create :appearance, header_message: 'Foo', footer_message: 'Bar', email_header_and_footer_enabled: false
+ context "when email_header_and_footer_enabled is disabled" do
+ it "returns header and footer messages" do
+ create :appearance, header_message: "Foo", footer_message: "Bar", email_header_and_footer_enabled: false
aggregate_failures do
expect(html_header_message).to eq(nil)
diff --git a/spec/helpers/events_helper_spec.rb b/spec/helpers/events_helper_spec.rb
index 3d15306d4d2..4a2b46ea67a 100644
--- a/spec/helpers/events_helper_spec.rb
+++ b/spec/helpers/events_helper_spec.rb
@@ -1,83 +1,83 @@
-require 'spec_helper'
+require "spec_helper"
describe EventsHelper do
- describe '#event_commit_title' do
- let(:message) { 'foo & bar ' + 'A' * 70 + '\n' + 'B' * 80 }
+ describe "#event_commit_title" do
+ let(:message) { "foo & bar " + "A" * 70 + '\n' + "B" * 80 }
subject { helper.event_commit_title(message) }
- it 'returns the first line, truncated to 70 chars' do
+ it "returns the first line, truncated to 70 chars" do
is_expected.to eq(message[0..66] + "...")
end
- it 'is not html-safe' do
+ it "is not html-safe" do
is_expected.not_to be_a(ActiveSupport::SafeBuffer)
end
- it 'handles empty strings' do
+ it "handles empty strings" do
expect(helper.event_commit_title("")).to eq("")
end
- it 'handles nil values' do
- expect(helper.event_commit_title(nil)).to eq('')
+ it "handles nil values" do
+ expect(helper.event_commit_title(nil)).to eq("")
end
- it 'does not escape HTML entities' do
- expect(helper.event_commit_title('foo & bar')).to eq('foo & bar')
+ it "does not escape HTML entities" do
+ expect(helper.event_commit_title("foo & bar")).to eq("foo & bar")
end
end
- describe '#event_feed_url' do
+ describe "#event_feed_url" do
let(:event) { create(:event) }
let(:project) { create(:project, :public, :repository) }
- context 'issue' do
+ context "issue" do
before do
event.target = create(:issue)
end
- it 'returns the project issue url' do
+ it "returns the project issue url" do
expect(helper.event_feed_url(event)).to eq(project_issue_url(event.project, event.target))
end
- it 'contains the project issue IID link' do
+ it "contains the project issue IID link" do
expect(helper.event_feed_title(event)).to include("##{event.target.iid}")
end
end
- context 'merge request' do
+ context "merge request" do
before do
event.target = create(:merge_request)
end
- it 'returns the project merge request url' do
+ it "returns the project merge request url" do
expect(helper.event_feed_url(event)).to eq(project_merge_request_url(event.project, event.target))
end
- it 'contains the project merge request IID link' do
+ it "contains the project merge request IID link" do
expect(helper.event_feed_title(event)).to include("!#{event.target.iid}")
end
end
- it 'returns project commit url' do
+ it "returns project commit url" do
event.target = create(:note_on_commit, project: project)
expect(helper.event_feed_url(event)).to eq(project_commit_url(event.project, event.note_target))
end
- it 'returns event note target url' do
+ it "returns event note target url" do
event.target = create(:note)
expect(helper.event_feed_url(event)).to eq(event_note_target_url(event))
end
- it 'returns project url' do
+ it "returns project url" do
event.project = project
event.action = 1
expect(helper.event_feed_url(event)).to eq(project_url(event.project))
end
- it 'returns push event feed url' do
+ it "returns push event feed url" do
event = create(:push_event)
create(:push_event_payload, event: event, action: :pushed)
@@ -85,33 +85,33 @@ describe EventsHelper do
end
end
- describe '#event_note_target_url' do
+ describe "#event_note_target_url" do
let(:project) { create(:project, :public, :repository) }
let(:event) { create(:event, project: project) }
let(:project_base_url) { namespace_project_url(namespace_id: project.namespace, id: project) }
subject { helper.event_note_target_url(event) }
- it 'returns a commit note url' do
- event.target = create(:note_on_commit, note: '+1 from me')
+ it "returns a commit note url" do
+ event.target = create(:note_on_commit, note: "+1 from me")
expect(subject).to eq("#{project_base_url}/commit/#{event.target.commit_id}#note_#{event.target.id}")
end
- it 'returns a project snippet note url' do
- event.target = create(:note, :on_snippet, note: 'keep going')
+ it "returns a project snippet note url" do
+ event.target = create(:note, :on_snippet, note: "keep going")
expect(subject).to eq("#{project_base_url}/snippets/#{event.note_target.id}#note_#{event.target.id}")
end
- it 'returns a project issue url' do
- event.target = create(:note_on_issue, note: 'nice work')
+ it "returns a project issue url" do
+ event.target = create(:note_on_issue, note: "nice work")
expect(subject).to eq("#{project_base_url}/issues/#{event.note_target.iid}#note_#{event.target.id}")
end
- it 'returns a merge request url' do
- event.target = create(:note_on_merge_request, note: 'LGTM!')
+ it "returns a merge request url" do
+ event.target = create(:note_on_merge_request, note: "LGTM!")
expect(subject).to eq("#{project_base_url}/merge_requests/#{event.note_target.iid}#note_#{event.target.id}")
end
diff --git a/spec/helpers/explore_helper_spec.rb b/spec/helpers/explore_helper_spec.rb
index 12651d80e36..5c655782468 100644
--- a/spec/helpers/explore_helper_spec.rb
+++ b/spec/helpers/explore_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ExploreHelper do
let(:user) { build(:user) }
@@ -8,8 +8,8 @@ describe ExploreHelper do
allow(helper).to receive(:can?) { true }
end
- describe '#explore_nav_links' do
- it 'has all the expected links by default' do
+ describe "#explore_nav_links" do
+ it "has all the expected links by default" do
menu_items = [:projects, :groups, :snippets]
expect(helper.explore_nav_links).to contain_exactly(*menu_items)
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
index 18cf0031d5f..ebd22fb4520 100644
--- a/spec/helpers/form_helper_spec.rb
+++ b/spec/helpers/form_helper_spec.rb
@@ -1,39 +1,39 @@
-require 'rails_helper'
+require "rails_helper"
describe FormHelper do
- describe 'form_errors' do
- it 'returns nil when model has no errors' do
+ describe "form_errors" do
+ it "returns nil when model has no errors" do
model = double(errors: [])
expect(helper.form_errors(model)).to be_nil
end
- it 'renders an alert div' do
- model = double(errors: errors_stub('Error 1'))
+ it "renders an alert div" do
+ model = double(errors: errors_stub("Error 1"))
expect(helper.form_errors(model))
.to include('<div class="alert alert-danger" id="error_explanation">')
end
- it 'contains a summary message' do
- single_error = double(errors: errors_stub('A'))
- multi_errors = double(errors: errors_stub('A', 'B', 'C'))
+ it "contains a summary message" do
+ single_error = double(errors: errors_stub("A"))
+ multi_errors = double(errors: errors_stub("A", "B", "C"))
expect(helper.form_errors(single_error))
- .to include('<h4>The form contains the following error:')
+ .to include("<h4>The form contains the following error:")
expect(helper.form_errors(multi_errors))
- .to include('<h4>The form contains the following errors:')
+ .to include("<h4>The form contains the following errors:")
end
- it 'renders each message' do
- model = double(errors: errors_stub('Error 1', 'Error 2', 'Error 3'))
+ it "renders each message" do
+ model = double(errors: errors_stub("Error 1", "Error 2", "Error 3"))
errors = helper.form_errors(model)
aggregate_failures do
- expect(errors).to include('<li>Error 1</li>')
- expect(errors).to include('<li>Error 2</li>')
- expect(errors).to include('<li>Error 3</li>')
+ expect(errors).to include("<li>Error 1</li>")
+ expect(errors).to include("<li>Error 2</li>")
+ expect(errors).to include("<li>Error 3</li>")
end
end
diff --git a/spec/helpers/git_helper_spec.rb b/spec/helpers/git_helper_spec.rb
index 9b1ef1e05a2..b48872ec0b8 100644
--- a/spec/helpers/git_helper_spec.rb
+++ b/spec/helpers/git_helper_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe GitHelper do
- describe '#short_sha' do
- let(:short_sha) { helper.short_sha('d4e043f6c20749a3ab3f4b8e23f2a8979f4b9100') }
+ describe "#short_sha" do
+ let(:short_sha) { helper.short_sha("d4e043f6c20749a3ab3f4b8e23f2a8979f4b9100") }
- it { expect(short_sha).to eq('d4e043f6') }
+ it { expect(short_sha).to eq("d4e043f6") }
end
end
diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb
index 143b28728a3..14c22db97d0 100644
--- a/spec/helpers/gitlab_routing_helper_spec.rb
+++ b/spec/helpers/gitlab_routing_helper_spec.rb
@@ -1,104 +1,104 @@
-require 'spec_helper'
+require "spec_helper"
describe GitlabRoutingHelper do
let(:project) { build_stubbed(:project) }
let(:group) { build_stubbed(:group) }
- describe 'Project URL helpers' do
- describe '#project_member_path' do
+ describe "Project URL helpers" do
+ describe "#project_member_path" do
let(:project_member) { create(:project_member) }
it { expect(project_member_path(project_member)).to eq project_project_member_path(project_member.source, project_member) }
end
- describe '#request_access_project_members_path' do
+ describe "#request_access_project_members_path" do
it { expect(request_access_project_members_path(project)).to eq request_access_project_project_members_path(project) }
end
- describe '#leave_project_members_path' do
+ describe "#leave_project_members_path" do
it { expect(leave_project_members_path(project)).to eq leave_project_project_members_path(project) }
end
- describe '#approve_access_request_project_member_path' do
+ describe "#approve_access_request_project_member_path" do
let(:project_member) { create(:project_member) }
it { expect(approve_access_request_project_member_path(project_member)).to eq approve_access_request_project_project_member_path(project_member.source, project_member) }
end
- describe '#resend_invite_project_member_path' do
+ describe "#resend_invite_project_member_path" do
let(:project_member) { create(:project_member) }
it { expect(resend_invite_project_member_path(project_member)).to eq resend_invite_project_project_member_path(project_member.source, project_member) }
end
end
- describe 'Group URL helpers' do
- describe '#group_members_url' do
+ describe "Group URL helpers" do
+ describe "#group_members_url" do
it { expect(group_members_url(group)).to eq group_group_members_url(group) }
end
- describe '#group_member_path' do
+ describe "#group_member_path" do
let(:group_member) { create(:group_member) }
it { expect(group_member_path(group_member)).to eq group_group_member_path(group_member.source, group_member) }
end
- describe '#request_access_group_members_path' do
+ describe "#request_access_group_members_path" do
it { expect(request_access_group_members_path(group)).to eq request_access_group_group_members_path(group) }
end
- describe '#leave_group_members_path' do
+ describe "#leave_group_members_path" do
it { expect(leave_group_members_path(group)).to eq leave_group_group_members_path(group) }
end
- describe '#approve_access_request_group_member_path' do
+ describe "#approve_access_request_group_member_path" do
let(:group_member) { create(:group_member) }
it { expect(approve_access_request_group_member_path(group_member)).to eq approve_access_request_group_group_member_path(group_member.source, group_member) }
end
- describe '#resend_invite_group_member_path' do
+ describe "#resend_invite_group_member_path" do
let(:group_member) { create(:group_member) }
it { expect(resend_invite_group_member_path(group_member)).to eq resend_invite_group_group_member_path(group_member.source, group_member) }
end
end
- describe '#preview_markdown_path' do
+ describe "#preview_markdown_path" do
let(:project) { create(:project) }
- it 'returns group preview markdown path for a group parent' do
+ it "returns group preview markdown path for a group parent" do
group = create(:group)
expect(preview_markdown_path(group)).to eq("/groups/#{group.path}/preview_markdown")
end
- it 'returns project preview markdown path for a project parent' do
+ it "returns project preview markdown path for a project parent" do
expect(preview_markdown_path(project)).to eq("/#{project.full_path}/preview_markdown")
end
- it 'returns snippet preview markdown path for a personal snippet' do
+ it "returns snippet preview markdown path for a personal snippet" do
@snippet = create(:personal_snippet)
expect(preview_markdown_path(nil)).to eq("/snippets/preview_markdown")
end
- it 'returns project preview markdown path for a project snippet' do
+ it "returns project preview markdown path for a project snippet" do
@snippet = create(:project_snippet, project: project)
expect(preview_markdown_path(project)).to eq("/#{project.full_path}/preview_markdown")
end
end
- describe '#edit_milestone_path' do
- it 'returns group milestone edit path when given entity parent is a Group' do
+ describe "#edit_milestone_path" do
+ it "returns group milestone edit path when given entity parent is a Group" do
group = create(:group)
milestone = create(:milestone, group: group)
expect(edit_milestone_path(milestone)).to eq("/groups/#{group.path}/-/milestones/#{milestone.iid}/edit")
end
- it 'returns project milestone edit path when given entity parent is not a Group' do
+ it "returns project milestone edit path when given entity parent is not a Group" do
milestone = create(:milestone, group: nil)
expect(edit_milestone_path(milestone)).to eq("/#{milestone.project.full_path}/milestones/#{milestone.iid}/edit")
diff --git a/spec/helpers/graph_helper_spec.rb b/spec/helpers/graph_helper_spec.rb
index 1f8a38dc697..ba68674e657 100644
--- a/spec/helpers/graph_helper_spec.rb
+++ b/spec/helpers/graph_helper_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe GraphHelper do
- describe '#get_refs' do
+ describe "#get_refs" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit("master") }
- let(:graph) { Network::Graph.new(project, 'master', commit, '') }
+ let(:graph) { Network::Graph.new(project, "master", commit, "") }
- it 'filters our refs used by GitLab' do
- self.instance_variable_set(:@graph, graph)
+ it "filters our refs used by GitLab" do
+ instance_variable_set(:@graph, graph)
refs = refs(project.repository, commit)
- expect(refs).to match('master')
+ expect(refs).to match("master")
end
end
end
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb
index 540a8674ec2..b5b22174faf 100644
--- a/spec/helpers/groups_helper_spec.rb
+++ b/spec/helpers/groups_helper_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupsHelper do
include ApplicationHelper
- describe 'group_icon_url' do
- it 'returns an url for the avatar' do
- avatar_file_path = File.join('spec', 'fixtures', 'banana_sample.gif')
+ describe "group_icon_url" do
+ it "returns an url for the avatar" do
+ avatar_file_path = File.join("spec", "fixtures", "banana_sample.gif")
group = create(:group)
group.avatar = fixture_file_upload(avatar_file_path)
@@ -14,14 +14,14 @@ describe GroupsHelper do
.to match(group.avatar.url)
end
- it 'gives 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_url(group.path)).to match_asset_path('group_avatar.png')
+ expect(group_icon_url(group.path)).to match_asset_path("group_avatar.png")
end
end
- describe 'group_lfs_status' do
+ describe "group_lfs_status" do
let(:group) { create(:group) }
let!(:project) { create(:project, namespace_id: group.id) }
@@ -29,75 +29,75 @@ describe GroupsHelper do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
- context 'only one project in group' do
+ context "only one project in group" do
before do
group.update_attribute(:lfs_enabled, true)
end
- it 'returns all projects as enabled' do
- expect(group_lfs_status(group)).to include('Enabled for all projects')
+ it "returns all projects as enabled" do
+ expect(group_lfs_status(group)).to include("Enabled for all projects")
end
- it 'returns all projects as disabled' do
+ it "returns all projects as disabled" do
project.update_attribute(:lfs_enabled, false)
- expect(group_lfs_status(group)).to include('Enabled for 0 out of 1 project')
+ expect(group_lfs_status(group)).to include("Enabled for 0 out of 1 project")
end
end
- context 'more than one project in group' do
+ context "more than one project in group" do
before do
create(:project, namespace_id: group.id)
end
- context 'LFS enabled in group' do
+ context "LFS enabled in group" do
before do
group.update_attribute(:lfs_enabled, true)
end
- it 'returns both projects as enabled' do
- expect(group_lfs_status(group)).to include('Enabled for all projects')
+ it "returns both projects as enabled" do
+ expect(group_lfs_status(group)).to include("Enabled for all projects")
end
- it 'returns only one as enabled' do
+ it "returns only one as enabled" do
project.update_attribute(:lfs_enabled, false)
- expect(group_lfs_status(group)).to include('Enabled for 1 out of 2 projects')
+ expect(group_lfs_status(group)).to include("Enabled for 1 out of 2 projects")
end
end
- context 'LFS disabled in group' do
+ context "LFS disabled in group" do
before do
group.update_attribute(:lfs_enabled, false)
end
- it 'returns both projects as disabled' do
- expect(group_lfs_status(group)).to include('Disabled for all projects')
+ it "returns both projects as disabled" do
+ expect(group_lfs_status(group)).to include("Disabled for all projects")
end
- it 'returns only one as disabled' do
+ it "returns only one as disabled" do
project.update_attribute(:lfs_enabled, true)
- expect(group_lfs_status(group)).to include('Disabled for 1 out of 2 projects')
+ expect(group_lfs_status(group)).to include("Disabled for 1 out of 2 projects")
end
end
end
end
- describe 'group_title', :nested_groups do
+ describe "group_title", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- it 'outputs the groups in the correct order' do
+ it "outputs the groups in the correct order" do
expect(helper.group_title(very_deep_nested_group))
.to match(%r{<li style="text-indent: 16px;"><a.*>#{deep_nested_group.name}.*</li>.*<a.*>#{very_deep_nested_group.name}</a>}m)
end
end
# rubocop:disable Layout/SpaceBeforeComma
- describe '#share_with_group_lock_help_text', :nested_groups do
+ describe "#share_with_group_lock_help_text", :nested_groups do
let!(:root_group) { create(:group) }
let!(:subgroup) { create(:group, parent: root_group) }
let!(:sub_subgroup) { create(:group, parent: subgroup) }
@@ -109,20 +109,20 @@ describe GroupsHelper do
default_help: "This setting will be applied to all subgroups unless overridden by a group owner",
ancestor_locked_but_you_can_override: %r{This setting is applied on <a .+>.+</a>\. You can override the setting or .+},
ancestor_locked_so_ask_the_owner: /This setting is applied on .+\. To share projects in this group with another group, ask the owner to override the setting or remove the share with group lock from .+/,
- ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/
+ ancestor_locked_and_has_been_overridden: /This setting is applied on .+ and has been overridden on this subgroup/,
}
end
let(:possible_linked_ancestors) do
{
root_group: root_group,
- subgroup: subgroup
+ subgroup: subgroup,
}
end
let(:users) do
{
root_owner: root_owner,
sub_owner: sub_owner,
- sub_sub_owner: sub_sub_owner
+ sub_sub_owner: sub_sub_owner,
}
end
subject { helper.share_with_group_lock_help_text(sub_subgroup) }
@@ -152,7 +152,7 @@ describe GroupsHelper do
[true , true , false , :sub_sub_owner , :ancestor_locked_and_has_been_overridden , :root_group],
[true , true , true , :root_owner , :ancestor_locked_but_you_can_override , :root_group],
[true , true , true , :sub_owner , :ancestor_locked_so_ask_the_owner , :root_group],
- [true , true , true , :sub_sub_owner , :ancestor_locked_so_ask_the_owner , :root_group]
+ [true , true , true , :sub_sub_owner , :ancestor_locked_so_ask_the_owner , :root_group],
]
end
@@ -168,28 +168,28 @@ describe GroupsHelper do
allow(helper).to receive(:current_user).and_return(users[current_user])
allow(helper).to receive(:can?)
- .with(users[current_user], :change_share_with_group_lock, subgroup)
- .and_return(Ability.allowed?(users[current_user], :change_share_with_group_lock, subgroup))
+ .with(users[current_user], :change_share_with_group_lock, subgroup)
+ .and_return(Ability.allowed?(users[current_user], :change_share_with_group_lock, subgroup))
ancestor = possible_linked_ancestors[linked_ancestor]
if ancestor
allow(helper).to receive(:can?)
- .with(users[current_user], :read_group, ancestor)
- .and_return(Ability.allowed?(users[current_user], :read_group, ancestor))
+ .with(users[current_user], :read_group, ancestor)
+ .and_return(Ability.allowed?(users[current_user], :read_group, ancestor))
allow(helper).to receive(:can?)
- .with(users[current_user], :admin_group, ancestor)
- .and_return(Ability.allowed?(users[current_user], :admin_group, ancestor))
+ .with(users[current_user], :admin_group, ancestor)
+ .and_return(Ability.allowed?(users[current_user], :admin_group, ancestor))
end
end
- it 'has the correct help text with correct ancestor links' do
+ it "has the correct help text with correct ancestor links" do
expect(subject).to match(possible_help_texts[help_text])
expect(subject).to match(possible_linked_ancestors[linked_ancestor].name) unless help_text == :default_help
end
end
end
- describe '#group_sidebar_links' do
+ describe "#group_sidebar_links" do
let(:group) { create(:group, :public) }
let(:user) { create(:user) }
before do
@@ -199,25 +199,25 @@ describe GroupsHelper do
helper.instance_variable_set(:@group, group)
end
- it 'returns all the expected links' do
+ it "returns all the expected links" do
links = [
:overview, :activity, :issues, :labels, :milestones, :merge_requests,
- :group_members, :settings
+ :group_members, :settings,
]
expect(helper.group_sidebar_links).to include(*links)
end
- it 'includes settings when the user can admin the group' do
+ it "includes settings when the user can admin the group" do
expect(helper).to receive(:current_user) { user }
expect(helper).to receive(:can?).with(user, :admin_group, group) { false }
expect(helper.group_sidebar_links).not_to include(:settings)
end
- it 'excludes cross project features when the user cannot read cross project' do
+ it "excludes cross project features when the user cannot read cross project" do
cross_project_features = [:activity, :issues, :labels, :milestones,
- :merge_requests]
+ :merge_requests,]
allow(Ability).to receive(:allowed?).and_call_original
cross_project_features.each do |feature|
diff --git a/spec/helpers/hooks_helper_spec.rb b/spec/helpers/hooks_helper_spec.rb
index 2e21f1134b1..91cfd90875f 100644
--- a/spec/helpers/hooks_helper_spec.rb
+++ b/spec/helpers/hooks_helper_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe HooksHelper do
let(:project) { create(:project) }
let(:project_hook) { create(:project_hook, project: project) }
let(:system_hook) { create(:system_hook) }
- let(:trigger) { 'push_events' }
+ let(:trigger) { "push_events" }
- describe '#link_to_test_hook' do
- it 'returns project namespaced link' do
+ describe "#link_to_test_hook" do
+ it "returns project namespaced link" do
expect(helper.link_to_test_hook(project_hook, trigger))
.to include("href=\"#{test_project_hook_path(project, project_hook, trigger: trigger)}\"")
end
- it 'returns admin namespaced link' do
+ it "returns admin namespaced link" do
expect(helper.link_to_test_hook(system_hook, trigger))
.to include("href=\"#{test_admin_hook_path(system_hook, trigger: trigger)}\"")
end
diff --git a/spec/helpers/icons_helper_spec.rb b/spec/helpers/icons_helper_spec.rb
index 4b40d523287..f271cb984d2 100644
--- a/spec/helpers/icons_helper_spec.rb
+++ b/spec/helpers/icons_helper_spec.rb
@@ -1,77 +1,77 @@
-require 'spec_helper'
+require "spec_helper"
describe IconsHelper do
let(:icons_path) { ActionController::Base.helpers.image_path("icons.svg") }
- describe 'icon' do
- it 'returns aria-hidden by default' do
- star = icon('star')
+ describe "icon" do
+ it "returns aria-hidden by default" do
+ star = icon("star")
- expect(star['aria-hidden']).to eq 'aria-hidden'
+ expect(star["aria-hidden"]).to eq "aria-hidden"
end
- it 'does not return aria-hidden if aria-label is set' do
- up = icon('up', 'aria-label' => 'up')
+ it "does not return aria-hidden if aria-label is set" do
+ up = icon("up", "aria-label" => "up")
- expect(up['aria-hidden']).to be_nil
- expect(up['aria-label']).to eq 'aria-label'
+ expect(up["aria-hidden"]).to be_nil
+ expect(up["aria-label"]).to eq "aria-label"
end
end
- describe 'sprite_icon_path' do
- it 'returns relative path' do
+ describe "sprite_icon_path" do
+ it "returns relative path" do
expect(sprite_icon_path)
.to eq icons_path
end
- context 'when an asset_host is set in the config it will return an absolute local URL' do
- let(:asset_host) { 'http://assets' }
+ context "when an asset_host is set in the config it will return an absolute local URL" do
+ let(:asset_host) { "http://assets" }
before do
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
end
- it 'returns an absolute URL on that asset host' do
+ it "returns an absolute URL on that asset host" do
expect(sprite_icon_path)
.to eq ActionController::Base.helpers.image_path("icons.svg", host: Gitlab.config.gitlab.url)
end
end
end
- describe 'sprite_icon' do
- icon_name = 'clock'
+ describe "sprite_icon" do
+ icon_name = "clock"
- it 'returns svg icon html' do
+ it "returns svg icon html" do
expect(sprite_icon(icon_name).to_s)
.to eq "<svg><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
- it 'returns svg icon html + size classes' do
+ it "returns svg icon html + size classes" do
expect(sprite_icon(icon_name, size: 72).to_s)
.to eq "<svg class=\"s72\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
- it 'returns svg icon html + size classes + additional class' do
- expect(sprite_icon(icon_name, size: 72, css_class: 'icon-danger').to_s)
+ it "returns svg icon html + size classes + additional class" do
+ expect(sprite_icon(icon_name, size: 72, css_class: "icon-danger").to_s)
.to eq "<svg class=\"s72 icon-danger\"><use xlink:href=\"#{icons_path}##{icon_name}\"></use></svg>"
end
- describe 'non existing icon' do
- non_existing = 'non_existing_icon_sprite'
+ describe "non existing icon" do
+ non_existing = "non_existing_icon_sprite"
- it 'should raise in development mode' do
+ it "should raise in development mode" do
allow(Rails.env).to receive(:development?).and_return(true)
expect { sprite_icon(non_existing) }.to raise_error(ArgumentError, /is not a known icon/)
end
- it 'should raise in test mode' do
+ it "should raise in test mode" do
allow(Rails.env).to receive(:test?).and_return(true)
expect { sprite_icon(non_existing) }.to raise_error(ArgumentError, /is not a known icon/)
end
- it 'should not raise in production mode' do
+ it "should not raise in production mode" do
allow(Rails.env).to receive(:test?).and_return(false)
allow(Rails.env).to receive(:development?).and_return(false)
@@ -80,135 +80,135 @@ describe IconsHelper do
end
end
- describe 'audit icon' do
- it 'returns right icon name for standard auth' do
- icon_name = 'standard'
+ describe "audit icon" do
+ it "returns right icon name for standard auth" do
+ icon_name = "standard"
expect(audit_icon(icon_name).to_s)
- .to eq '<i class="fa fa-key"></i>'
+ .to eq '<i class="fa fa-key"></i>'
end
- it 'returns right icon name for two-factor auth' do
- icon_name = 'two-factor'
+ it "returns right icon name for two-factor auth" do
+ icon_name = "two-factor"
expect(audit_icon(icon_name).to_s)
- .to eq '<i class="fa fa-key"></i>'
+ .to eq '<i class="fa fa-key"></i>'
end
- it 'returns right icon name for google_oauth2 auth' do
- icon_name = 'google_oauth2'
+ it "returns right icon name for google_oauth2 auth" do
+ icon_name = "google_oauth2"
expect(audit_icon(icon_name).to_s)
- .to eq '<i class="fa fa-google"></i>'
+ .to eq '<i class="fa fa-google"></i>'
end
end
- describe 'file_type_icon_class' do
- it 'returns folder class' do
- expect(file_type_icon_class('folder', 0, 'folder_name')).to eq 'folder'
+ describe "file_type_icon_class" do
+ it "returns folder class" do
+ expect(file_type_icon_class("folder", 0, "folder_name")).to eq "folder"
end
- it 'returns share class' do
- expect(file_type_icon_class('file', '120000', 'link')).to eq 'share'
+ it "returns share class" do
+ expect(file_type_icon_class("file", "120000", "link")).to eq "share"
end
- it 'returns file-pdf-o class with .pdf' do
- expect(file_type_icon_class('file', 0, 'filename.pdf')).to eq 'file-pdf-o'
+ it "returns file-pdf-o class with .pdf" do
+ expect(file_type_icon_class("file", 0, "filename.pdf")).to eq "file-pdf-o"
end
- it 'returns file-image-o class with .jpg' do
- expect(file_type_icon_class('file', 0, 'filename.jpg')).to eq 'file-image-o'
+ it "returns file-image-o class with .jpg" do
+ expect(file_type_icon_class("file", 0, "filename.jpg")).to eq "file-image-o"
end
- it 'returns file-image-o class with .JPG' do
- expect(file_type_icon_class('file', 0, 'filename.JPG')).to eq 'file-image-o'
+ it "returns file-image-o class with .JPG" do
+ expect(file_type_icon_class("file", 0, "filename.JPG")).to eq "file-image-o"
end
- it 'returns file-image-o class with .png' do
- expect(file_type_icon_class('file', 0, 'filename.png')).to eq 'file-image-o'
+ it "returns file-image-o class with .png" do
+ expect(file_type_icon_class("file", 0, "filename.png")).to eq "file-image-o"
end
- it 'returns file-archive-o class with .tar' do
- expect(file_type_icon_class('file', 0, 'filename.tar')).to eq 'file-archive-o'
+ it "returns file-archive-o class with .tar" do
+ expect(file_type_icon_class("file", 0, "filename.tar")).to eq "file-archive-o"
end
- it 'returns file-archive-o class with .TAR' do
- expect(file_type_icon_class('file', 0, 'filename.TAR')).to eq 'file-archive-o'
+ it "returns file-archive-o class with .TAR" do
+ expect(file_type_icon_class("file", 0, "filename.TAR")).to eq "file-archive-o"
end
- it 'returns file-archive-o class with .tar.gz' do
- expect(file_type_icon_class('file', 0, 'filename.tar.gz')).to eq 'file-archive-o'
+ it "returns file-archive-o class with .tar.gz" do
+ expect(file_type_icon_class("file", 0, "filename.tar.gz")).to eq "file-archive-o"
end
- it 'returns file-audio-o class with .mp3' do
- expect(file_type_icon_class('file', 0, 'filename.mp3')).to eq 'file-audio-o'
+ it "returns file-audio-o class with .mp3" do
+ expect(file_type_icon_class("file", 0, "filename.mp3")).to eq "file-audio-o"
end
- it 'returns file-audio-o class with .MP3' do
- expect(file_type_icon_class('file', 0, 'filename.MP3')).to eq 'file-audio-o'
+ it "returns file-audio-o class with .MP3" do
+ expect(file_type_icon_class("file", 0, "filename.MP3")).to eq "file-audio-o"
end
- it 'returns file-audio-o class with .wav' do
- expect(file_type_icon_class('file', 0, 'filename.wav')).to eq 'file-audio-o'
+ it "returns file-audio-o class with .wav" do
+ expect(file_type_icon_class("file", 0, "filename.wav")).to eq "file-audio-o"
end
- it 'returns file-video-o class with .avi' do
- expect(file_type_icon_class('file', 0, 'filename.avi')).to eq 'file-video-o'
+ it "returns file-video-o class with .avi" do
+ expect(file_type_icon_class("file", 0, "filename.avi")).to eq "file-video-o"
end
- it 'returns file-video-o class with .AVI' do
- expect(file_type_icon_class('file', 0, 'filename.AVI')).to eq 'file-video-o'
+ it "returns file-video-o class with .AVI" do
+ expect(file_type_icon_class("file", 0, "filename.AVI")).to eq "file-video-o"
end
- it 'returns file-video-o class with .mp4' do
- expect(file_type_icon_class('file', 0, 'filename.mp4')).to eq 'file-video-o'
+ it "returns file-video-o class with .mp4" do
+ expect(file_type_icon_class("file", 0, "filename.mp4")).to eq "file-video-o"
end
- it 'returns file-word-o class with .doc' do
- expect(file_type_icon_class('file', 0, 'filename.doc')).to eq 'file-word-o'
+ it "returns file-word-o class with .doc" do
+ expect(file_type_icon_class("file", 0, "filename.doc")).to eq "file-word-o"
end
- it 'returns file-word-o class with .DOC' do
- expect(file_type_icon_class('file', 0, 'filename.DOC')).to eq 'file-word-o'
+ it "returns file-word-o class with .DOC" do
+ expect(file_type_icon_class("file", 0, "filename.DOC")).to eq "file-word-o"
end
- it 'returns file-word-o class with .docx' do
- expect(file_type_icon_class('file', 0, 'filename.docx')).to eq 'file-word-o'
+ it "returns file-word-o class with .docx" do
+ expect(file_type_icon_class("file", 0, "filename.docx")).to eq "file-word-o"
end
- it 'returns file-excel-o class with .xls' do
- expect(file_type_icon_class('file', 0, 'filename.xls')).to eq 'file-excel-o'
+ it "returns file-excel-o class with .xls" do
+ expect(file_type_icon_class("file", 0, "filename.xls")).to eq "file-excel-o"
end
- it 'returns file-excel-o class with .XLS' do
- expect(file_type_icon_class('file', 0, 'filename.XLS')).to eq 'file-excel-o'
+ it "returns file-excel-o class with .XLS" do
+ expect(file_type_icon_class("file", 0, "filename.XLS")).to eq "file-excel-o"
end
- it 'returns file-excel-o class with .xlsx' do
- expect(file_type_icon_class('file', 0, 'filename.xlsx')).to eq 'file-excel-o'
+ it "returns file-excel-o class with .xlsx" do
+ expect(file_type_icon_class("file", 0, "filename.xlsx")).to eq "file-excel-o"
end
- it 'returns file-excel-o class with .ppt' do
- expect(file_type_icon_class('file', 0, 'filename.ppt')).to eq 'file-powerpoint-o'
+ it "returns file-excel-o class with .ppt" do
+ expect(file_type_icon_class("file", 0, "filename.ppt")).to eq "file-powerpoint-o"
end
- it 'returns file-excel-o class with .PPT' do
- expect(file_type_icon_class('file', 0, 'filename.PPT')).to eq 'file-powerpoint-o'
+ it "returns file-excel-o class with .PPT" do
+ expect(file_type_icon_class("file", 0, "filename.PPT")).to eq "file-powerpoint-o"
end
- it 'returns file-excel-o class with .pptx' do
- expect(file_type_icon_class('file', 0, 'filename.pptx')).to eq 'file-powerpoint-o'
+ it "returns file-excel-o class with .pptx" do
+ expect(file_type_icon_class("file", 0, "filename.pptx")).to eq "file-powerpoint-o"
end
- it 'returns file-text-o class with .unknow' do
- expect(file_type_icon_class('file', 0, 'filename.unknow')).to eq 'file-text-o'
+ it "returns file-text-o class with .unknow" do
+ expect(file_type_icon_class("file", 0, "filename.unknow")).to eq "file-text-o"
end
- it 'returns file-text-o class with no extension' do
- expect(file_type_icon_class('file', 0, 'CHANGELOG')).to eq 'file-text-o'
+ it "returns file-text-o class with no extension" do
+ expect(file_type_icon_class("file", 0, "CHANGELOG")).to eq "file-text-o"
end
end
- describe '#external_snippet_icon' do
- it 'returns external snippet icon' do
- expect(external_snippet_icon('download').to_s)
+ describe "#external_snippet_icon" do
+ it "returns external snippet icon" do
+ expect(external_snippet_icon("download").to_s)
.to eq("<span class=\"gl-snippet-icon gl-snippet-icon-download\"></span>")
end
end
diff --git a/spec/helpers/import_helper_spec.rb b/spec/helpers/import_helper_spec.rb
index 6e8c13db9fe..406f8c53ae6 100644
--- a/spec/helpers/import_helper_spec.rb
+++ b/spec/helpers/import_helper_spec.rb
@@ -1,50 +1,50 @@
-require 'rails_helper'
+require "rails_helper"
describe ImportHelper do
- describe '#sanitize_project_name' do
- it 'removes leading tildes' do
- expect(helper.sanitize_project_name('~~root')).to eq('root')
+ describe "#sanitize_project_name" do
+ it "removes leading tildes" do
+ expect(helper.sanitize_project_name("~~root")).to eq("root")
end
- it 'removes whitespace' do
- expect(helper.sanitize_project_name('my test repo')).to eq('my-test-repo')
+ it "removes whitespace" do
+ expect(helper.sanitize_project_name("my test repo")).to eq("my-test-repo")
end
- it 'removes disallowed characters' do
- expect(helper.sanitize_project_name('Test&me$over*h_ere')).to eq('Test-me-over-h_ere')
+ it "removes disallowed characters" do
+ expect(helper.sanitize_project_name("Test&me$over*h_ere")).to eq("Test-me-over-h_ere")
end
end
- describe '#import_project_target' do
+ describe "#import_project_target" do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'when current user can create namespaces' do
- it 'returns project namespace' do
+ context "when current user can create namespaces" do
+ it "returns project namespace" do
user.update_attribute(:can_create_group, true)
- expect(helper.import_project_target('asd', 'vim')).to eq 'asd/vim'
+ expect(helper.import_project_target("asd", "vim")).to eq "asd/vim"
end
end
- context 'when current user can not create namespaces' do
+ context "when current user can not create namespaces" do
it "takes the current user's namespace" do
user.update_attribute(:can_create_group, false)
- expect(helper.import_project_target('asd', 'vim')).to eq "#{user.namespace_path}/vim"
+ expect(helper.import_project_target("asd", "vim")).to eq "#{user.namespace_path}/vim"
end
end
end
- describe '#provider_project_link_url' do
- let(:full_path) { '/repo/path' }
- let(:host_url) { 'http://provider.com/' }
+ describe "#provider_project_link_url" do
+ let(:full_path) { "/repo/path" }
+ let(:host_url) { "http://provider.com/" }
- it 'appends repo full path to provider host url' do
- expect(helper.provider_project_link_url(host_url, full_path)).to match('http://provider.com/repo/path')
+ it "appends repo full path to provider host url" do
+ expect(helper.provider_project_link_url(host_url, full_path)).to match("http://provider.com/repo/path")
end
end
end
diff --git a/spec/helpers/instance_configuration_helper_spec.rb b/spec/helpers/instance_configuration_helper_spec.rb
index 5d716b9191d..db7dd65da31 100644
--- a/spec/helpers/instance_configuration_helper_spec.rb
+++ b/spec/helpers/instance_configuration_helper_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
describe InstanceConfigurationHelper do
- describe '#instance_configuration_cell_html' do
- describe 'if not block is passed' do
- it 'returns the parameter if present' do
- expect(helper.instance_configuration_cell_html('gitlab')).to eq('gitlab')
+ describe "#instance_configuration_cell_html" do
+ describe "if not block is passed" do
+ it "returns the parameter if present" do
+ expect(helper.instance_configuration_cell_html("gitlab")).to eq("gitlab")
end
it 'returns "-" if the parameter is blank' do
- expect(helper.instance_configuration_cell_html(nil)).to eq('-')
- expect(helper.instance_configuration_cell_html('')).to eq('-')
+ expect(helper.instance_configuration_cell_html(nil)).to eq("-")
+ expect(helper.instance_configuration_cell_html("")).to eq("-")
end
end
- describe 'if a block is passed' do
+ describe "if a block is passed" do
let(:upcase_block) { ->(value) { value.upcase } }
- it 'returns the result of the block' do
- expect(helper.instance_configuration_cell_html('gitlab', &upcase_block)).to eq('GITLAB')
- expect(helper.instance_configuration_cell_html('gitlab') { |v| v.upcase }).to eq('GITLAB')
+ it "returns the result of the block" do
+ expect(helper.instance_configuration_cell_html("gitlab", &upcase_block)).to eq("GITLAB")
+ expect(helper.instance_configuration_cell_html("gitlab") { |v| v.upcase }).to eq("GITLAB")
end
it 'returns "-" if the parameter is blank' do
- expect(helper.instance_configuration_cell_html(nil, &upcase_block)).to eq('-')
- expect(helper.instance_configuration_cell_html(nil) { |v| v.upcase }).to eq('-')
- expect(helper.instance_configuration_cell_html('', &upcase_block)).to eq('-')
+ expect(helper.instance_configuration_cell_html(nil, &upcase_block)).to eq("-")
+ expect(helper.instance_configuration_cell_html(nil) { |v| v.upcase }).to eq("-")
+ expect(helper.instance_configuration_cell_html("", &upcase_block)).to eq("-")
end
end
- it 'boolean are valid values to display' do
+ it "boolean are valid values to display" do
expect(helper.instance_configuration_cell_html(true)).to eq(true)
expect(helper.instance_configuration_cell_html(false)).to eq(false)
end
end
- describe '#instance_configuration_human_size_cell' do
+ describe "#instance_configuration_human_size_cell" do
it 'returns "-" if the parameter is blank' do
- expect(helper.instance_configuration_human_size_cell(nil)).to eq('-')
- expect(helper.instance_configuration_human_size_cell('')).to eq('-')
+ expect(helper.instance_configuration_human_size_cell(nil)).to eq("-")
+ expect(helper.instance_configuration_human_size_cell("")).to eq("-")
end
- it 'accepts the value in bytes' do
- expect(helper.instance_configuration_human_size_cell(1024)).to eq('1 KB')
+ it "accepts the value in bytes" do
+ expect(helper.instance_configuration_human_size_cell(1024)).to eq("1 KB")
end
- it 'returns the value in human size readable format' do
- expect(helper.instance_configuration_human_size_cell(1048576)).to eq('1 MB')
+ it "returns the value in human size readable format" do
+ expect(helper.instance_configuration_human_size_cell(1048576)).to eq("1 MB")
end
end
end
diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb
index 8b82dea2524..0c191a3e99c 100644
--- a/spec/helpers/issuables_helper_spec.rb
+++ b/spec/helpers/issuables_helper_spec.rb
@@ -1,68 +1,68 @@
-require 'spec_helper'
+require "spec_helper"
describe IssuablesHelper do
let(:label) { build_stubbed(:label) }
let(:label2) { build_stubbed(:label) }
- describe '#users_dropdown_label' do
+ describe "#users_dropdown_label" do
let(:user) { build_stubbed(:user) }
let(:user2) { build_stubbed(:user) }
- it 'returns unassigned' do
- expect(users_dropdown_label([])).to eq('Unassigned')
+ it "returns unassigned" do
+ expect(users_dropdown_label([])).to eq("Unassigned")
end
- it 'returns selected user\'s name' do
+ it "returns selected user's name" do
expect(users_dropdown_label([user])).to eq(user.name)
end
- it 'returns selected user\'s name and counter' do
+ it "returns selected user's name and counter" do
expect(users_dropdown_label([user, user2])).to eq("#{user.name} + 1 more")
end
end
- describe '#group_dropdown_label' do
+ describe "#group_dropdown_label" do
let(:group) { create(:group) }
- let(:default) { 'default label' }
+ let(:default) { "default label" }
- it 'returns default group label when group_id is nil' do
- expect(group_dropdown_label(nil, default)).to eq('default label')
+ it "returns default group label when group_id is nil" do
+ expect(group_dropdown_label(nil, default)).to eq("default label")
end
it 'returns "any group" when group_id is 0' do
- expect(group_dropdown_label('0', default)).to eq('Any group')
+ expect(group_dropdown_label("0", default)).to eq("Any group")
end
- it 'returns group full path when a group was found for the provided id' do
+ it "returns group full path when a group was found for the provided id" do
expect(group_dropdown_label(group.id, default)).to eq(group.full_name)
end
- it 'returns default label when a group was not found for the provided id' do
- expect(group_dropdown_label(9999, default)).to eq('default label')
+ it "returns default label when a group was not found for the provided id" do
+ expect(group_dropdown_label(9999, default)).to eq("default label")
end
end
- describe '#issuable_labels_tooltip' do
+ describe "#issuable_labels_tooltip" do
let(:label_entity) { LabelEntity.represent(label).as_json }
let(:label2_entity) { LabelEntity.represent(label2).as_json }
- it 'returns label text with no labels' do
+ it "returns label text with no labels" do
expect(issuable_labels_tooltip([])).to eq("Labels")
end
- it 'returns label text with labels within max limit' do
+ it "returns label text with labels within max limit" do
expect(issuable_labels_tooltip([label_entity])).to eq(label[:title])
end
- it 'returns label text with labels exceeding max limit' do
+ it "returns label text with labels exceeding max limit" do
expect(issuable_labels_tooltip([label_entity, label2_entity], limit: 1)).to eq("#{label[:title]}, and 1 more")
end
end
- describe '#issuables_state_counter_text' do
+ describe "#issuables_state_counter_text" do
let(:user) { create(:user) }
- describe 'state text' do
+ describe "state text" do
before do
allow(helper).to receive(:issuables_count_for_state).and_return(42)
end
@@ -89,9 +89,9 @@ describe IssuablesHelper do
end
end
- describe '#issuable_reference' do
- context 'when show_full_reference truthy' do
- it 'display issuable full reference' do
+ describe "#issuable_reference" do
+ context "when show_full_reference truthy" do
+ it "display issuable full reference" do
assign(:show_full_reference, true)
issue = build_stubbed(:issue)
@@ -99,9 +99,9 @@ describe IssuablesHelper do
end
end
- context 'when show_full_reference falsey' do
- context 'when @group present' do
- it 'display issuable reference to @group' do
+ context "when show_full_reference falsey" do
+ context "when @group present" do
+ it "display issuable reference to @group" do
project = build_stubbed(:project)
assign(:show_full_reference, nil)
@@ -113,8 +113,8 @@ describe IssuablesHelper do
end
end
- context 'when @project present' do
- it 'display issuable reference to @project' do
+ context "when @project present" do
+ it "display issuable reference to @project" do
project = build_stubbed(:project)
assign(:show_full_reference, nil)
@@ -129,7 +129,7 @@ describe IssuablesHelper do
end
end
- describe '#updated_at_by' do
+ describe "#updated_at_by" do
let(:user) { create(:user) }
let(:unedited_issuable) { create(:issue) }
let(:edited_issuable) { create(:issue, last_edited_by: user, created_at: 3.days.ago, updated_at: 1.day.ago, last_edited_at: 2.days.ago) }
@@ -138,22 +138,22 @@ describe IssuablesHelper do
updatedAt: edited_issuable.last_edited_at.to_time.iso8601,
updatedBy: {
name: user.name,
- path: user_path(user)
- }
+ path: user_path(user),
+ },
}
end
it { expect(helper.updated_at_by(unedited_issuable)).to eq({}) }
it { expect(helper.updated_at_by(edited_issuable)).to eq(edited_updated_at_by) }
- context 'when updated by a deleted user' do
+ context "when updated by a deleted user" do
let(:edited_updated_at_by) do
{
updatedAt: edited_issuable.last_edited_at.to_time.iso8601,
updatedBy: {
name: User.ghost.name,
- path: user_path(User.ghost)
- }
+ path: user_path(User.ghost),
+ },
}
end
@@ -167,7 +167,7 @@ describe IssuablesHelper do
end
end
- describe '#issuable_initial_data' do
+ describe "#issuable_initial_data" do
let(:user) { create(:user) }
before do
@@ -176,8 +176,8 @@ describe IssuablesHelper do
stub_commonmark_sourcepos_disabled
end
- it 'returns the correct json for an issue' do
- issue = create(:issue, author: user, description: 'issue text')
+ it "returns the correct json for an issue" do
+ issue = create(:issue, author: user, description: "issue text")
@project = issue.project
expected_data = {
@@ -187,7 +187,7 @@ describe IssuablesHelper do
canDestroy: true,
issuableRef: "##{issue.iid}",
markdownPreviewPath: "/#{@project.full_path}/preview_markdown",
- markdownDocsPath: '/help/user/markdown',
+ markdownDocsPath: "/help/user/markdown",
issuableTemplates: [],
lockVersion: issue.lock_version,
projectPath: @project.path,
@@ -195,8 +195,8 @@ describe IssuablesHelper do
initialTitleHtml: issue.title,
initialTitleText: issue.title,
initialDescriptionHtml: '<p dir="auto">issue text</p>',
- initialDescriptionText: 'issue text',
- initialTaskStatus: '0 of 0 tasks completed'
+ initialDescriptionText: "issue text",
+ initialTaskStatus: "0 of 0 tasks completed",
}
expect(helper.issuable_initial_data(issue)).to eq(expected_data)
end
diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb
index 039143eb8d7..1b829842a3c 100644
--- a/spec/helpers/issues_helper_spec.rb
+++ b/spec/helpers/issues_helper_spec.rb
@@ -7,7 +7,7 @@ describe IssuesHelper do
describe "url_for_issue" do
let(:issues_url) { ext_project.external_issue_tracker.issues_url}
- let(:ext_expected) { issues_url.gsub(':id', issue.iid.to_s).gsub(':project_id', ext_project.id.to_s) }
+ 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 "returns internal path if used internal tracker" do
@@ -34,16 +34,16 @@ describe IssuesHelper do
expect(url_for_issue(issue.iid)).to eq ""
end
- it 'returns an empty string if issue_url is invalid' do
- expect(project).to receive_message_chain('issues_tracker.issue_url') { 'javascript:alert("foo");' }
+ it "returns an empty string if issue_url is invalid" do
+ expect(project).to receive_message_chain("issues_tracker.issue_url") { 'javascript:alert("foo");' }
- expect(url_for_issue(issue.iid, project)).to eq ''
+ expect(url_for_issue(issue.iid, project)).to eq ""
end
- it 'returns an empty string if issue_path is invalid' do
- expect(project).to receive_message_chain('issues_tracker.issue_path') { 'javascript:alert("foo");' }
+ it "returns an empty string if issue_path is invalid" do
+ expect(project).to receive_message_chain("issues_tracker.issue_path") { 'javascript:alert("foo");' }
- expect(url_for_issue(issue.iid, project, only_path: true)).to eq ''
+ expect(url_for_issue(issue.iid, project, only_path: true)).to eq ""
end
describe "when external tracker was enabled and then config removed" do
@@ -58,35 +58,35 @@ describe IssuesHelper do
end
end
- describe '#award_user_list' do
+ describe "#award_user_list" do
it "returns a comma-separated list of the first X users" do
- user = build_stubbed(:user, name: 'Joe')
+ user = build_stubbed(:user, name: "Joe")
awards = Array.new(3, build_stubbed(:award_emoji, user: user))
expect(award_user_list(awards, nil, limit: 3))
- .to eq('Joe, Joe, and Joe')
+ .to eq("Joe, Joe, and Joe")
end
it "displays the current user's name as 'You'" do
- user = build_stubbed(:user, name: 'Joe')
+ user = build_stubbed(:user, name: "Joe")
award = build_stubbed(:award_emoji, user: user)
- expect(award_user_list([award], user)).to eq('You')
- expect(award_user_list([award], nil)).to eq 'Joe'
+ expect(award_user_list([award], user)).to eq("You")
+ expect(award_user_list([award], nil)).to eq "Joe"
end
it "truncates lists" do
- user = build_stubbed(:user, name: 'Jane')
+ user = build_stubbed(:user, name: "Jane")
awards = Array.new(5, build_stubbed(:award_emoji, user: user))
expect(award_user_list(awards, nil, limit: 3))
- .to eq('Jane, Jane, Jane, and 2 more.')
+ .to eq("Jane, Jane, Jane, and 2 more.")
end
it "displays the current user in front of other users" do
current_user = build_stubbed(:user)
my_award = build_stubbed(:award_emoji, user: current_user)
- award = build_stubbed(:award_emoji, user: build_stubbed(:user, name: 'Jane'))
+ award = build_stubbed(:award_emoji, user: build_stubbed(:user, name: "Jane"))
awards = Array.new(5, award).push(my_award)
expect(award_user_list(awards, current_user, limit: 2))
@@ -94,7 +94,7 @@ describe IssuesHelper do
end
end
- describe '#award_state_class' do
+ describe "#award_state_class" do
let!(:upvote) { create(:award_emoji) }
let(:awardable) { upvote.awardable }
let(:user) { upvote.user }
@@ -127,8 +127,8 @@ describe IssuesHelper do
describe "awards_sort" do
it "sorts a hash so thumbsup and thumbsdown are always on top" do
- data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" }
- expect(awards_sort(data).keys).to eq(%w(thumbsup thumbsdown lifter))
+ data = {"thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value"}
+ expect(awards_sort(data).keys).to eq(%w[thumbsup thumbsdown lifter])
end
end
@@ -164,20 +164,20 @@ describe IssuesHelper do
end
end
- describe '#show_new_issue_link?' do
+ describe "#show_new_issue_link?" do
before do
allow(helper).to receive(:current_user)
end
- it 'is false when no project there is no project' do
+ it "is false when no project there is no project" do
expect(helper.show_new_issue_link?(nil)).to be_falsey
end
- it 'is true when there is a project and no logged in user' do
+ it "is true when there is a project and no logged in user" do
expect(helper.show_new_issue_link?(build(:project))).to be_truthy
end
- it 'is true when the current user does not have access to the project' do
+ it "is true when the current user does not have access to the project" do
project = build(:project)
allow(helper).to receive(:current_user).and_return(project.owner)
diff --git a/spec/helpers/labels_helper_spec.rb b/spec/helpers/labels_helper_spec.rb
index 012678db9c2..a0787584ae7 100644
--- a/spec/helpers/labels_helper_spec.rb
+++ b/spec/helpers/labels_helper_spec.rb
@@ -1,248 +1,248 @@
-require 'spec_helper'
+require "spec_helper"
describe LabelsHelper do
- describe '#show_label_issuables_link?' do
- shared_examples 'a valid response to show_label_issuables_link?' do |issuables_type, when_enabled = true, when_disabled = false|
+ describe "#show_label_issuables_link?" do
+ shared_examples "a valid response to show_label_issuables_link?" do |issuables_type, when_enabled = true, when_disabled = false|
let(:context_project) { project }
context "when asking for a #{issuables_type} link" do
subject { show_label_issuables_link?(label, issuables_type, project: context_project) }
context "when #{issuables_type} are enabled for the project" do
- let(:project) { create(:project, "#{issuables_type}_access_level": ProjectFeature::ENABLED) }
+ let(:project) { create(:project, :"#{issuables_type}_access_level" => ProjectFeature::ENABLED) }
it { is_expected.to be(when_enabled) }
end
context "when #{issuables_type} are disabled for the project" do
- let(:project) { create(:project, :public, "#{issuables_type}_access_level": ProjectFeature::DISABLED) }
+ let(:project) { create(:project, :public, :"#{issuables_type}_access_level" => ProjectFeature::DISABLED) }
it { is_expected.to be(when_disabled) }
end
end
end
- context 'with a project label' do
- let(:label) { create(:label, project: project, title: 'bug') }
+ context "with a project label" do
+ let(:label) { create(:label, project: project, title: "bug") }
- context 'when asking for an issue link' do
- it_behaves_like 'a valid response to show_label_issuables_link?', :issues
+ context "when asking for an issue link" do
+ it_behaves_like "a valid response to show_label_issuables_link?", :issues
end
- context 'when asking for a merge requests link' do
- it_behaves_like 'a valid response to show_label_issuables_link?', :merge_requests
+ context "when asking for a merge requests link" do
+ it_behaves_like "a valid response to show_label_issuables_link?", :merge_requests
end
end
- context 'with a group label' do
+ context "with a group label" do
set(:group) { create(:group) }
- let(:label) { create(:group_label, group: group, title: 'bug') }
+ let(:label) { create(:group_label, group: group, title: "bug") }
- context 'when asking for an issue link' do
- context 'in the context of a project' do
- it_behaves_like 'a valid response to show_label_issuables_link?', :issues, true, true
+ context "when asking for an issue link" do
+ context "in the context of a project" do
+ it_behaves_like "a valid response to show_label_issuables_link?", :issues, true, true
end
- context 'in the context of a group' do
+ context "in the context of a group" do
let(:context_project) { nil }
- it_behaves_like 'a valid response to show_label_issuables_link?', :issues, true, true
+ it_behaves_like "a valid response to show_label_issuables_link?", :issues, true, true
end
end
- context 'when asking for a merge requests link' do
- context 'in the context of a project' do
- it_behaves_like 'a valid response to show_label_issuables_link?', :merge_requests, true, true
+ context "when asking for a merge requests link" do
+ context "in the context of a project" do
+ it_behaves_like "a valid response to show_label_issuables_link?", :merge_requests, true, true
end
- context 'in the context of a group' do
+ context "in the context of a group" do
let(:context_project) { nil }
- it_behaves_like 'a valid response to show_label_issuables_link?', :merge_requests, true, true
+ it_behaves_like "a valid response to show_label_issuables_link?", :merge_requests, true, true
end
end
end
end
- describe 'link_to_label' do
+ describe "link_to_label" do
let(:project) { create(:project) }
let(:label) { create(:label, project: project) }
- context 'without subject' do
+ context "without subject" do
it "uses the label's project" do
expect(link_to_label(label)).to match %r{<a href="/#{label.project.full_path}/issues\?label_name%5B%5D=#{label.name}">.*</a>}
end
end
- context 'with a project as subject' do
- let(:namespace) { build(:namespace, name: 'foo3') }
- let(:another_project) { build(:project, namespace: namespace, name: 'bar3') }
+ context "with a project as subject" do
+ let(:namespace) { build(:namespace, name: "foo3") }
+ let(:another_project) { build(:project, namespace: namespace, name: "bar3") }
- it 'links to project issues page' do
+ it "links to project issues page" do
expect(link_to_label(label, subject: another_project)).to match %r{<a href="/foo3/bar3/issues\?label_name%5B%5D=#{label.name}">.*</a>}
end
end
- context 'with a group as subject' do
- let(:group) { build(:group, name: 'bar') }
+ context "with a group as subject" do
+ let(:group) { build(:group, name: "bar") }
- it 'links to group issues page' do
+ it "links to group issues page" do
expect(link_to_label(label, subject: group)).to match %r{<a href="/groups/bar/-/issues\?label_name%5B%5D=#{label.name}">.*</a>}
end
end
- context 'with a type argument' do
- ['issue', :issue, 'merge_request', :merge_request].each do |type|
+ context "with a type argument" do
+ ["issue", :issue, "merge_request", :merge_request].each do |type|
context "set to #{type}" do
- it 'links to correct page' do
+ it "links to correct page" do
expect(link_to_label(label, type: type)).to match %r{<a href="/#{label.project.full_path}/#{type.to_s.pluralize}\?label_name%5B%5D=#{label.name}">.*</a>}
end
end
end
end
- context 'with a tooltip argument' do
- context 'set to false' do
- it 'does not include the has-tooltip class' do
+ context "with a tooltip argument" do
+ context "set to false" do
+ it "does not include the has-tooltip class" do
expect(link_to_label(label, tooltip: false)).not_to match /has-tooltip/
end
end
end
- context 'with block' do
- it 'passes the block to link_to' do
- link = link_to_label(label) { 'Foo' }
- expect(link).to match('Foo')
+ context "with block" do
+ it "passes the block to link_to" do
+ link = link_to_label(label) { "Foo" }
+ expect(link).to match("Foo")
end
end
- context 'without block' do
- it 'uses render_colored_label as the link content' do
+ context "without block" do
+ it "uses render_colored_label as the link content" do
expect(self).to receive(:render_colored_label)
- .with(label, tooltip: true).and_return('Foo')
- expect(link_to_label(label)).to match('Foo')
+ .with(label, tooltip: true).and_return("Foo")
+ expect(link_to_label(label)).to match("Foo")
end
end
end
- describe 'text_color_for_bg' do
- it 'uses light text on dark backgrounds' do
- expect(text_color_for_bg('#222E2E')).to eq('#FFFFFF')
+ describe "text_color_for_bg" do
+ it "uses light text on dark backgrounds" do
+ expect(text_color_for_bg("#222E2E")).to eq("#FFFFFF")
end
- it 'uses dark text on light backgrounds' do
- expect(text_color_for_bg('#EEEEEE')).to eq('#333333')
+ it "uses dark text on light backgrounds" do
+ expect(text_color_for_bg("#EEEEEE")).to eq("#333333")
end
- it 'supports RGB triplets' do
- expect(text_color_for_bg('#FFF')).to eq '#333333'
- expect(text_color_for_bg('#000')).to eq '#FFFFFF'
+ it "supports RGB triplets" do
+ expect(text_color_for_bg("#FFF")).to eq "#333333"
+ expect(text_color_for_bg("#000")).to eq "#FFFFFF"
end
end
- describe 'create_label_title' do
+ describe "create_label_title" do
set(:group) { create(:group) }
- context 'with a group as subject' do
+ context "with a group as subject" do
it 'returns "Create group label"' do
- expect(create_label_title(group)).to eq 'Create group label'
+ expect(create_label_title(group)).to eq "Create group label"
end
end
- context 'with a project as subject' do
+ context "with a project as subject" do
set(:project) { create(:project, namespace: group) }
it 'returns "Create project label"' do
- expect(create_label_title(project)).to eq 'Create project label'
+ expect(create_label_title(project)).to eq "Create project label"
end
end
- context 'with no subject' do
+ context "with no subject" do
it 'returns "Create new label"' do
- expect(create_label_title(nil)).to eq 'Create new label'
+ expect(create_label_title(nil)).to eq "Create new label"
end
end
end
- describe 'manage_labels_title' do
+ describe "manage_labels_title" do
set(:group) { create(:group) }
- context 'with a group as subject' do
+ context "with a group as subject" do
it 'returns "Manage group labels"' do
- expect(manage_labels_title(group)).to eq 'Manage group labels'
+ expect(manage_labels_title(group)).to eq "Manage group labels"
end
end
- context 'with a project as subject' do
+ context "with a project as subject" do
set(:project) { create(:project, namespace: group) }
it 'returns "Manage project labels"' do
- expect(manage_labels_title(project)).to eq 'Manage project labels'
+ expect(manage_labels_title(project)).to eq "Manage project labels"
end
end
- context 'with no subject' do
+ context "with no subject" do
it 'returns "Manage labels"' do
- expect(manage_labels_title(nil)).to eq 'Manage labels'
+ expect(manage_labels_title(nil)).to eq "Manage labels"
end
end
end
- describe 'view_labels_title' do
+ describe "view_labels_title" do
set(:group) { create(:group) }
- context 'with a group as subject' do
+ context "with a group as subject" do
it 'returns "View group labels"' do
- expect(view_labels_title(group)).to eq 'View group labels'
+ expect(view_labels_title(group)).to eq "View group labels"
end
end
- context 'with a project as subject' do
+ context "with a project as subject" do
set(:project) { create(:project, namespace: group) }
it 'returns "View project labels"' do
- expect(view_labels_title(project)).to eq 'View project labels'
+ expect(view_labels_title(project)).to eq "View project labels"
end
end
- context 'with no subject' do
+ context "with no subject" do
it 'returns "View labels"' do
- expect(view_labels_title(nil)).to eq 'View labels'
+ expect(view_labels_title(nil)).to eq "View labels"
end
end
end
- describe 'labels_filter_path' do
+ describe "labels_filter_path" do
let(:group) { create(:group) }
let(:project) { create(:project) }
- it 'links to the dashboard labels page' do
+ it "links to the dashboard labels page" do
expect(labels_filter_path).to eq(dashboard_labels_path)
end
- it 'links to the group labels page' do
+ it "links to the group labels page" do
assign(:group, group)
expect(helper.labels_filter_path).to eq(group_labels_path(group))
end
- it 'links to the project labels page' do
+ it "links to the project labels page" do
assign(:project, project)
expect(helper.labels_filter_path).to eq(project_labels_path(project))
end
- it 'supports json format' do
+ it "supports json format" do
expect(labels_filter_path(format: :json)).to eq(dashboard_labels_path(format: :json))
end
end
- describe 'labels_sorted_by_title' do
- it 'sorts labels alphabetically' do
- label1 = double(:label, title: 'a')
- label2 = double(:label, title: 'B')
- label3 = double(:label, title: 'c')
- label4 = double(:label, title: 'D')
+ describe "labels_sorted_by_title" do
+ it "sorts labels alphabetically" do
+ label1 = double(:label, title: "a")
+ label2 = double(:label, title: "B")
+ label3 = double(:label, title: "c")
+ label4 = double(:label, title: "D")
labels = [label1, label2, label3, label4]
expect(labels_sorted_by_title(labels))
diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb
index c3956ba08fd..868a8b41c79 100644
--- a/spec/helpers/markup_helper_spec.rb
+++ b/spec/helpers/markup_helper_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe MarkupHelper do
let!(:project) { create(:project, :repository) }
- let(:user) { create(:user, username: 'gfm') }
+ let(:user) { create(:user, username: "gfm") }
let(:commit) { project.commit }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
@@ -45,28 +45,28 @@ describe MarkupHelper do
let(:second_project) { create(:project, :public) }
let(:second_issue) { create(:issue, project: second_project) }
- it 'links to the issue' do
+ it "links to the issue" do
expected = urls.project_issue_path(second_project, second_issue)
expect(markdown(actual, project: second_project)).to match(expected)
end
end
end
- describe '#markdown_field' do
+ describe "#markdown_field" do
let(:attribute) { :title }
- describe 'with already redacted attribute' do
- it 'returns the redacted attribute' do
- commit.redacted_title_html = 'commit title'
+ describe "with already redacted attribute" do
+ it "returns the redacted attribute" do
+ commit.redacted_title_html = "commit title"
expect(Banzai).not_to receive(:render_field)
- expect(helper.markdown_field(commit, attribute)).to eq('commit title')
+ expect(helper.markdown_field(commit, attribute)).to eq("commit title")
end
end
- describe 'without redacted attribute' do
- it 'renders the markdown value' do
+ describe "without redacted attribute" do
+ it "renders the markdown value" do
expect(Banzai).to receive(:render_field).with(commit, attribute, {}).and_call_original
helper.markdown_field(commit, attribute)
@@ -74,11 +74,11 @@ describe MarkupHelper do
end
end
- describe '#link_to_markdown_field' do
- let(:link) { '/commits/0a1b2c3d' }
+ describe "#link_to_markdown_field" do
+ let(:link) { "/commits/0a1b2c3d" }
let(:issues) { create_list(:issue, 2, project: project) }
- it 'handles references nested in links with all the text' do
+ it "handles references nested in links with all the text" do
allow(commit).to receive(:title).and_return("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real")
actual = helper.link_to_markdown_field(commit, :title, link)
@@ -88,34 +88,34 @@ describe MarkupHelper do
expect(doc.errors).to be_empty
# Leading commit link
- expect(doc.css('a')[0].attr('href')).to eq link
- expect(doc.css('a')[0].text).to eq 'This should finally fix '
+ expect(doc.css("a")[0].attr("href")).to eq link
+ expect(doc.css("a")[0].text).to eq "This should finally fix "
# First issue link
- expect(doc.css('a')[1].attr('href'))
+ expect(doc.css("a")[1].attr("href"))
.to eq urls.project_issue_path(project, issues[0])
- expect(doc.css('a')[1].text).to eq issues[0].to_reference
+ expect(doc.css("a")[1].text).to eq issues[0].to_reference
# Internal commit link
- expect(doc.css('a')[2].attr('href')).to eq link
- expect(doc.css('a')[2].text).to eq ' and '
+ expect(doc.css("a")[2].attr("href")).to eq link
+ expect(doc.css("a")[2].text).to eq " and "
# Second issue link
- expect(doc.css('a')[3].attr('href'))
+ expect(doc.css("a")[3].attr("href"))
.to eq urls.project_issue_path(project, issues[1])
- expect(doc.css('a')[3].text).to eq issues[1].to_reference
+ expect(doc.css("a")[3].text).to eq issues[1].to_reference
# Trailing commit link
- expect(doc.css('a')[4].attr('href')).to eq link
- expect(doc.css('a')[4].text).to eq ' for real'
+ expect(doc.css("a")[4].attr("href")).to eq link
+ expect(doc.css("a")[4].text).to eq " for real"
end
end
- describe '#link_to_markdown' do
- let(:link) { '/commits/0a1b2c3d' }
+ describe "#link_to_markdown" do
+ let(:link) { "/commits/0a1b2c3d" }
let(:issues) { create_list(:issue, 2, project: project) }
- it 'handles references nested in links with all the text' do
+ it "handles references nested in links with all the text" do
actual = helper.link_to_markdown("This should finally fix #{issues[0].to_reference} and #{issues[1].to_reference} for real", link)
doc = Nokogiri::HTML.parse(actual)
@@ -123,89 +123,89 @@ describe MarkupHelper do
expect(doc.errors).to be_empty
# Leading commit link
- expect(doc.css('a')[0].attr('href')).to eq link
- expect(doc.css('a')[0].text).to eq 'This should finally fix '
+ expect(doc.css("a")[0].attr("href")).to eq link
+ expect(doc.css("a")[0].text).to eq "This should finally fix "
# First issue link
- expect(doc.css('a')[1].attr('href'))
+ expect(doc.css("a")[1].attr("href"))
.to eq urls.project_issue_path(project, issues[0])
- expect(doc.css('a')[1].text).to eq issues[0].to_reference
+ expect(doc.css("a")[1].text).to eq issues[0].to_reference
# Internal commit link
- expect(doc.css('a')[2].attr('href')).to eq link
- expect(doc.css('a')[2].text).to eq ' and '
+ expect(doc.css("a")[2].attr("href")).to eq link
+ expect(doc.css("a")[2].text).to eq " and "
# Second issue link
- expect(doc.css('a')[3].attr('href'))
+ expect(doc.css("a")[3].attr("href"))
.to eq urls.project_issue_path(project, issues[1])
- expect(doc.css('a')[3].text).to eq issues[1].to_reference
+ expect(doc.css("a")[3].text).to eq issues[1].to_reference
# Trailing commit link
- expect(doc.css('a')[4].attr('href')).to eq link
- expect(doc.css('a')[4].text).to eq ' for real'
+ expect(doc.css("a")[4].attr("href")).to eq link
+ expect(doc.css("a")[4].text).to eq " for real"
end
- it 'forwards HTML options' do
- actual = helper.link_to_markdown("Fixed in #{commit.id}", link, class: 'foo')
+ it "forwards HTML options" do
+ actual = helper.link_to_markdown("Fixed in #{commit.id}", link, class: "foo")
doc = Nokogiri::HTML.parse(actual)
- expect(doc.css('a')).to satisfy do |v|
+ expect(doc.css("a")).to satisfy do |v|
# 'foo' gets added to all links
- v.all? { |a| a.attr('class').match(/foo$/) }
+ v.all? { |a| a.attr("class").match(/foo$/) }
end
end
it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see #{issues[0].to_reference}"
expect(helper.link_to_markdown(actual, link))
- .to match('&lt;h1&gt;test&lt;/h1&gt;')
+ .to match("&lt;h1&gt;test&lt;/h1&gt;")
end
- it 'ignores reference links when they are the entire body' do
+ it "ignores reference links when they are the entire body" do
text = issues[0].to_reference
- act = helper.link_to_markdown(text, '/foo')
- expect(act).to eq %Q(<a href="/foo">#{issues[0].to_reference}</a>)
+ act = helper.link_to_markdown(text, "/foo")
+ expect(act).to eq %(<a href="/foo">#{issues[0].to_reference}</a>)
end
- it 'replaces commit message with emoji to link' do
- actual = link_to_markdown(':book: Book', '/foo')
+ it "replaces commit message with emoji to link" do
+ actual = link_to_markdown(":book: Book", "/foo")
expect(actual)
.to eq '<gl-emoji title="open book" data-name="book" data-unicode-version="6.0">📖</gl-emoji><a href="/foo"> Book</a>'
end
end
- describe '#link_to_html' do
- it 'wraps the rendered content in a link' do
- link = '/commits/0a1b2c3d'
+ describe "#link_to_html" do
+ it "wraps the rendered content in a link" do
+ link = "/commits/0a1b2c3d"
issue = create(:issue, project: project)
rendered = helper.markdown("This should finally fix #{issue.to_reference} for real", pipeline: :single_line)
doc = Nokogiri::HTML.parse(rendered)
- expect(doc.css('a')[0].attr('href'))
+ expect(doc.css("a")[0].attr("href"))
.to eq urls.project_issue_path(project, issue)
- expect(doc.css('a')[0].text).to eq issue.to_reference
+ expect(doc.css("a")[0].text).to eq issue.to_reference
wrapped = helper.link_to_html(rendered, link)
doc = Nokogiri::HTML.parse(wrapped)
- expect(doc.css('a')[0].attr('href')).to eq link
- expect(doc.css('a')[0].text).to eq 'This should finally fix '
+ expect(doc.css("a")[0].attr("href")).to eq link
+ expect(doc.css("a")[0].text).to eq "This should finally fix "
end
end
- describe '#render_wiki_content' do
+ describe "#render_wiki_content" do
before do
- @wiki = double('WikiPage')
- allow(@wiki).to receive(:content).and_return('wiki content')
- allow(@wiki).to receive(:slug).and_return('nested/page')
+ @wiki = double("WikiPage")
+ allow(@wiki).to receive(:content).and_return("wiki content")
+ allow(@wiki).to receive(:slug).and_return("nested/page")
helper.instance_variable_set(:@project_wiki, @wiki)
end
it "uses Wiki pipeline for markdown files" do
allow(@wiki).to receive(:format).and_return(:markdown)
- expect(helper).to receive(:markdown_unsafe).with('wiki content',
+ expect(helper).to receive(:markdown_unsafe).with("wiki content",
pipeline: :wiki, project: project, project_wiki: @wiki, page_slug: "nested/page",
issuable_state_filter_enabled: true)
@@ -215,14 +215,14 @@ describe MarkupHelper do
it "uses Asciidoctor for asciidoc files" do
allow(@wiki).to receive(:format).and_return(:asciidoc)
- expect(helper).to receive(:asciidoc_unsafe).with('wiki content')
+ expect(helper).to receive(:asciidoc_unsafe).with("wiki content")
helper.render_wiki_content(@wiki)
end
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')
+ formatted_content_stub = double("formatted_content")
expect(formatted_content_stub).to receive(:html_safe)
allow(@wiki).to receive(:formatted_content).and_return(formatted_content_stub)
@@ -230,86 +230,86 @@ describe MarkupHelper do
end
end
- describe 'markup' do
- let(:content) { 'Noël' }
+ describe "markup" do
+ let(:content) { "Noël" }
- it 'preserves encoding' do
- expect(content.encoding.name).to eq('UTF-8')
- expect(helper.markup('foo.rst', content).encoding.name).to eq('UTF-8')
+ it "preserves encoding" do
+ expect(content.encoding.name).to eq("UTF-8")
+ expect(helper.markup("foo.rst", content).encoding.name).to eq("UTF-8")
end
- it 'delegates to #markdown_unsafe when file name corresponds to Markdown' do
- expect(helper).to receive(:gitlab_markdown?).with('foo.md').and_return(true)
- expect(helper).to receive(:markdown_unsafe).and_return('NOEL')
+ it "delegates to #markdown_unsafe when file name corresponds to Markdown" do
+ expect(helper).to receive(:gitlab_markdown?).with("foo.md").and_return(true)
+ expect(helper).to receive(:markdown_unsafe).and_return("NOEL")
- expect(helper.markup('foo.md', content)).to eq('NOEL')
+ expect(helper.markup("foo.md", content)).to eq("NOEL")
end
- it 'delegates to #asciidoc_unsafe when file name corresponds to AsciiDoc' do
- expect(helper).to receive(:asciidoc?).with('foo.adoc').and_return(true)
- expect(helper).to receive(:asciidoc_unsafe).and_return('NOEL')
+ it "delegates to #asciidoc_unsafe when file name corresponds to AsciiDoc" do
+ expect(helper).to receive(:asciidoc?).with("foo.adoc").and_return(true)
+ expect(helper).to receive(:asciidoc_unsafe).and_return("NOEL")
- expect(helper.markup('foo.adoc', content)).to eq('NOEL')
+ expect(helper.markup("foo.adoc", content)).to eq("NOEL")
end
- it 'uses passed in rendered content' do
+ it "uses passed in rendered content" do
expect(helper).not_to receive(:gitlab_markdown?)
expect(helper).not_to receive(:markdown_unsafe)
- expect(helper.markup('foo.md', content, rendered: '<p>NOEL</p>')).to eq('<p>NOEL</p>')
+ expect(helper.markup("foo.md", content, rendered: "<p>NOEL</p>")).to eq("<p>NOEL</p>")
end
- it 'defaults to CommonMark' do
- expect(helper.markup('foo.md', 'x^2')).to include('x^2')
+ it "defaults to CommonMark" do
+ expect(helper.markup("foo.md", "x^2")).to include("x^2")
end
end
- describe '#first_line_in_markdown' do
- shared_examples_for 'common markdown examples' do
+ describe "#first_line_in_markdown" do
+ shared_examples_for "common markdown examples" do
let(:project_base) { build(:project, :repository) }
- it 'displays inline code' do
- object = create_object('Text with `inline code`')
- expected = 'Text with <code>inline code</code>'
+ it "displays inline code" do
+ object = create_object("Text with `inline code`")
+ expected = "Text with <code>inline code</code>"
expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
- it 'truncates the text with multiple paragraphs' do
+ it "truncates the text with multiple paragraphs" do
object = create_object("Paragraph 1\n\nParagraph 2")
- expected = 'Paragraph 1...'
+ expected = "Paragraph 1..."
expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
- it 'displays the first line of a code block' do
+ it "displays the first line of a code block" do
object = create_object("```\nCode block\nwith two lines\n```")
expected = %r{<pre.+><code><span class="line">Code block\.\.\.</span>\n</code></pre>}
expect(first_line_in_markdown(object, attribute, 100, project: project)).to match(expected)
end
- it 'truncates a single long line of text' do
- text = 'The quick brown fox jumped over the lazy dog twice' # 50 chars
+ it "truncates a single long line of text" do
+ text = "The quick brown fox jumped over the lazy dog twice" # 50 chars
object = create_object(text * 4)
- expected = (text * 2).sub(/.{3}/, '...')
+ expected = (text * 2).sub(/.{3}/, "...")
expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected)
end
- it 'preserves a link href when link text is truncated' do
- text = 'The quick brown fox jumped over the lazy dog' # 44 chars
+ 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
+ link_url = "http://example.com/foo/bar/baz" # 30 chars
input << link_url
object = create_object(input)
- expected_link_text = 'http://example...</a>'
+ expected_link_text = "http://example...</a>"
expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(link_url)
expect(first_line_in_markdown(object, attribute, 150, project: project)).to match(expected_link_text)
end
- it 'preserves code color scheme' do
+ it "preserves code color scheme" do
object = create_object("```ruby\ndef test\n 'hello world'\nend\n```")
expected = "<pre class=\"code highlight js-syntax-highlight ruby\">" \
"<code><span class=\"line\"><span class=\"k\">def</span> <span class=\"nf\">test</span>...</span>\n" \
@@ -318,51 +318,51 @@ describe MarkupHelper do
expect(first_line_in_markdown(object, attribute, 150, project: project)).to eq(expected)
end
- context 'when images are allowed' do
- it 'preserves data-src for lazy images' do
+ context "when images are allowed" do
+ it "preserves data-src for lazy images" do
object = create_object("![ImageTest](/uploads/test.png)")
image_url = "data-src=\".*/uploads/test.png\""
text = first_line_in_markdown(object, attribute, 150, project: project, allow_images: true)
expect(text).to match(image_url)
- expect(text).to match('<a')
+ expect(text).to match("<a")
end
end
- context 'when images are not allowed' do
- it 'removes any images' do
+ context "when images are not allowed" do
+ it "removes any images" do
object = create_object("![ImageTest](/uploads/test.png)")
text = first_line_in_markdown(object, attribute, 150, project: project)
- expect(text).not_to match('<img')
- expect(text).not_to match('<a')
+ expect(text).not_to match("<img")
+ expect(text).not_to match("<a")
end
end
- context 'labels formatting' do
- let(:label_title) { 'this should be ~label_1' }
+ context "labels formatting" do
+ let(:label_title) { "this should be ~label_1" }
def create_and_format_label(project)
- create(:label, title: 'label_1', project: project)
+ create(:label, title: "label_1", project: project)
object = create_object(label_title, project: project)
first_line_in_markdown(object, attribute, 150, project: project)
end
- it 'preserves style attribute for a label that can be accessed by current_user' do
+ it "preserves style attribute for a label that can be accessed by current_user" do
project = create(:project, :public)
expect(create_and_format_label(project)).to match(/span class=.*style=.*/)
end
- it 'does not style a label that can not be accessed by current_user' do
+ it "does not style a label that can not be accessed by current_user" do
project = create(:project, :private)
expect(create_and_format_label(project)).to eq("<p>#{label_title}</p>")
end
end
- it 'truncates Markdown properly' do
+ it "truncates Markdown properly" do
object = create_object("@#{user.username}, can you look at this?\nHello world\n")
actual = first_line_in_markdown(object, attribute, 100, project: project)
@@ -372,14 +372,14 @@ describe MarkupHelper do
expect(doc.errors).to be_empty
# Leading user link
- expect(doc.css('a').length).to eq(1)
- expect(doc.css('a')[0].attr('href')).to eq user_path(user)
- expect(doc.css('a')[0].text).to eq "@#{user.username}"
+ expect(doc.css("a").length).to eq(1)
+ expect(doc.css("a")[0].attr("href")).to eq user_path(user)
+ expect(doc.css("a")[0].text).to eq "@#{user.username}"
expect(doc.content).to eq "@#{user.username}, can you look at this?..."
end
- it 'truncates Markdown with emoji properly' do
+ it "truncates Markdown with emoji properly" do
object = create_object("foo :wink:\nbar :grinning:")
actual = first_line_in_markdown(object, attribute, 100, project: project)
@@ -389,16 +389,16 @@ describe MarkupHelper do
# But also account for the 2 errors caused by the unknown `gl-emoji` elements
expect(doc.errors.length).to eq(2)
- expect(doc.css('gl-emoji').length).to eq(2)
- expect(doc.css('gl-emoji')[0].attr('data-name')).to eq 'wink'
- expect(doc.css('gl-emoji')[1].attr('data-name')).to eq 'grinning'
+ expect(doc.css("gl-emoji").length).to eq(2)
+ expect(doc.css("gl-emoji")[0].attr("data-name")).to eq "wink"
+ expect(doc.css("gl-emoji")[1].attr("data-name")).to eq "grinning"
expect(doc.content).to eq "foo 😉\nbar 😀"
end
end
- context 'when the asked attribute can be redacted' do
- include_examples 'common markdown examples' do
+ context "when the asked attribute can be redacted" do
+ include_examples "common markdown examples" do
let(:attribute) { :note }
def create_object(title, project: project_base)
build(:note, note: title, project: project)
@@ -406,8 +406,8 @@ describe MarkupHelper do
end
end
- context 'when the asked attribute can not be redacted' do
- include_examples 'common markdown examples' do
+ context "when the asked attribute can not be redacted" do
+ include_examples "common markdown examples" do
let(:attribute) { :body }
def create_object(title, project: project_base)
issue = build(:issue, title: title)
@@ -417,12 +417,12 @@ describe MarkupHelper do
end
end
- describe '#cross_project_reference' do
- it 'shows the full MR reference' do
+ describe "#cross_project_reference" do
+ it "shows the full MR reference" do
expect(helper.cross_project_reference(project, merge_request)).to include(project.full_path)
end
- it 'shows the full issue reference' do
+ it "shows the full issue reference" do
expect(helper.cross_project_reference(project, issue)).to include(project.full_path)
end
end
diff --git a/spec/helpers/members_helper_spec.rb b/spec/helpers/members_helper_spec.rb
index 908e8960f37..c684c5a9ad6 100644
--- a/spec/helpers/members_helper_spec.rb
+++ b/spec/helpers/members_helper_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe MembersHelper do
- describe '#remove_member_message' do
+ describe "#remove_member_message" do
let(:requester) { create(:user) }
let(:project) { create(:project, :public, :access_requestable) }
let(:project_member) { build(:project_member, project: project) }
@@ -22,7 +22,7 @@ describe MembersHelper do
it { expect(remove_member_message(group_member_request, user: requester)).to eq "Are you sure you want to withdraw your access request for the #{group.name} group?" }
end
- describe '#remove_member_title' do
+ describe "#remove_member_title" do
let(:requester) { create(:user) }
let(:project) { create(:project, :public, :access_requestable) }
let(:project_member) { build(:project_member, project: project) }
@@ -31,13 +31,13 @@ describe MembersHelper do
let(:group_member) { build(:group_member, group: group) }
let(:group_member_request) { group.request_access(requester) }
- it { expect(remove_member_title(project_member)).to eq 'Remove user from project' }
- it { expect(remove_member_title(project_member_request)).to eq 'Deny access request from project' }
- it { expect(remove_member_title(group_member)).to eq 'Remove user from group and any subresources' }
- it { expect(remove_member_title(group_member_request)).to eq 'Deny access request from group' }
+ it { expect(remove_member_title(project_member)).to eq "Remove user from project" }
+ it { expect(remove_member_title(project_member_request)).to eq "Deny access request from project" }
+ it { expect(remove_member_title(group_member)).to eq "Remove user from group and any subresources" }
+ it { expect(remove_member_title(group_member_request)).to eq "Deny access request from group" }
end
- describe '#leave_confirmation_message' do
+ describe "#leave_confirmation_message" do
let(:project) { build_stubbed(:project) }
let(:group) { build_stubbed(:group) }
let(:user) { build_stubbed(:user) }
diff --git a/spec/helpers/merge_requests_helper_spec.rb b/spec/helpers/merge_requests_helper_spec.rb
index 885204062fe..dd11bfea465 100644
--- a/spec/helpers/merge_requests_helper_spec.rb
+++ b/spec/helpers/merge_requests_helper_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestsHelper do
include ActionView::Helpers::UrlHelper
include ProjectForksHelper
- describe 'ci_build_details_path' do
+ describe "ci_build_details_path" do
let(:project) { create(:project) }
let(:merge_request) { MergeRequest.new }
let(:ci_service) { CiService.new }
@@ -14,25 +14,25 @@ describe MergeRequestsHelper do
allow(merge_request).to receive(:source_project).and_return(project)
allow(merge_request).to receive(:last_commit).and_return(last_commit)
allow(project).to receive(:ci_service).and_return(ci_service)
- allow(last_commit).to receive(:sha).and_return('12d65c')
+ allow(last_commit).to receive(:sha).and_return("12d65c")
end
- it 'does not include api credentials in a link' do
+ it "does not include api credentials in a link" do
allow(ci_service)
.to receive(:build_page).and_return("http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c")
expect(helper.ci_build_details_path(merge_request)).not_to match("secret")
end
end
- describe '#format_mr_branch_names' do
- describe 'within the same project' do
+ describe "#format_mr_branch_names" do
+ describe "within the same project" do
let(:merge_request) { create(:merge_request) }
subject { format_mr_branch_names(merge_request) }
it { is_expected.to eq([merge_request.source_branch, merge_request.target_branch]) }
end
- describe 'within different projects' do
+ describe "within different projects" do
let(:project) { create(:project) }
let(:forked_project) { fork_project(project) }
let(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project) }
@@ -44,16 +44,16 @@ describe MergeRequestsHelper do
end
end
- describe '#tab_link_for' do
+ describe "#tab_link_for" do
let(:merge_request) { create(:merge_request, :simple) }
- let(:options) { Hash.new }
+ let(:options) { {} }
- subject { tab_link_for(merge_request, :show, options) { 'Discussion' } }
+ subject { tab_link_for(merge_request, :show, options) { "Discussion" } }
- describe 'supports the :force_link option' do
- let(:options) { { force_link: true } }
+ describe "supports the :force_link option" do
+ let(:options) { {force_link: true} }
- it 'removes the data-toggle attributes' do
+ it "removes the data-toggle attributes" do
is_expected.not_to match(/data-toggle="tabvue"/)
end
end
diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb
index f5185cb2857..8b2ced3a526 100644
--- a/spec/helpers/milestones_helper_spec.rb
+++ b/spec/helpers/milestones_helper_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe MilestonesHelper do
- describe '#milestones_filter_dropdown_path' do
+ describe "#milestones_filter_dropdown_path" do
let(:project) { create(:project) }
let(:project2) { create(:project) }
let(:group) { create(:group) }
- context 'when @project present' do
- it 'returns project milestones JSON URL' do
+ context "when @project present" do
+ it "returns project milestones JSON URL" do
assign(:project, project)
expect(helper.milestones_filter_dropdown_path).to eq(project_milestones_path(project, :json))
end
end
- context 'when @target_project present' do
- it 'returns targeted project milestones JSON URL' do
+ context "when @target_project present" do
+ it "returns targeted project milestones JSON URL" do
assign(:target_project, project2)
expect(helper.milestones_filter_dropdown_path).to eq(project_milestones_path(project2, :json))
end
end
- context 'when @group present' do
- it 'returns group milestones JSON URL' do
+ context "when @group present" do
+ it "returns group milestones JSON URL" do
assign(:group, group)
expect(helper.milestones_filter_dropdown_path).to eq(group_milestones_path(group, :json))
end
end
- context 'when neither of @project/@target_project/@group present' do
- it 'returns dashboard milestones JSON URL' do
+ context "when neither of @project/@target_project/@group present" do
+ it "returns dashboard milestones JSON URL" do
expect(helper.milestones_filter_dropdown_path).to eq(dashboard_milestones_path(:json))
end
end
@@ -44,7 +44,7 @@ describe MilestonesHelper do
let(:yesterday) { Date.yesterday }
let(:tomorrow) { yesterday + 2 }
- let(:format) { '%b %-d, %Y' }
+ let(:format) { "%b %-d, %Y" }
let(:yesterday_formatted) { yesterday.strftime(format) }
let(:tomorrow_formatted) { tomorrow.strftime(format) }
@@ -56,12 +56,12 @@ describe MilestonesHelper do
it { expect(result_for(start_date: yesterday, due_date: tomorrow)).to eq("#{yesterday_formatted}–#{tomorrow_formatted}") }
end
- describe '#milestone_counts' do
+ describe "#milestone_counts" do
let(:project) { create(:project) }
let(:counts) { helper.milestone_counts(project.milestones) }
- context 'when there are milestones' do
- it 'returns the correct counts' do
+ context "when there are milestones" do
+ it "returns the correct counts" do
create_list(:active_milestone, 2, project: project)
create(:closed_milestone, project: project)
@@ -69,16 +69,16 @@ describe MilestonesHelper do
end
end
- context 'when there are only milestones of one type' do
- it 'returns the correct counts' do
+ context "when there are only milestones of one type" do
+ it "returns the correct counts" do
create_list(:active_milestone, 2, project: project)
expect(counts).to eq(opened: 2, closed: 0, all: 2)
end
end
- context 'when there are no milestones' do
- it 'returns the correct counts' do
+ context "when there are no milestones" do
+ it "returns the correct counts" do
expect(counts).to eq(opened: 0, closed: 0, all: 0)
end
end
diff --git a/spec/helpers/milestones_routing_helper_spec.rb b/spec/helpers/milestones_routing_helper_spec.rb
index dc13a43c2ab..89b7c2b792d 100644
--- a/spec/helpers/milestones_routing_helper_spec.rb
+++ b/spec/helpers/milestones_routing_helper_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe MilestonesRoutingHelper do
let(:project) { build_stubbed(:project) }
let(:group) { build_stubbed(:group) }
- describe '#milestone_path' do
- context 'for a group milestone' do
+ describe "#milestone_path" do
+ context "for a group milestone" do
let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) }
- it 'links to the group milestone page' do
+ it "links to the group milestone page" do
expect(milestone_path(milestone))
.to eq(group_milestone_path(group, milestone))
end
end
- context 'for a project milestone' do
+ context "for a project milestone" do
let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) }
- it 'links to the project milestone page' do
+ it "links to the project milestone page" do
expect(milestone_path(milestone))
.to eq(project_milestone_path(project, milestone))
end
end
end
- describe '#milestone_url' do
- context 'for a group milestone' do
+ describe "#milestone_url" do
+ context "for a group milestone" do
let(:milestone) { build_stubbed(:milestone, group: group, iid: 1) }
- it 'links to the group milestone page' do
+ it "links to the group milestone page" do
expect(milestone_url(milestone))
.to eq(group_milestone_url(group, milestone))
end
end
- context 'for a project milestone' do
+ context "for a project milestone" do
let(:milestone) { build_stubbed(:milestone, project: project, iid: 1) }
- it 'links to the project milestone page' do
+ it "links to the project milestone page" do
expect(milestone_url(milestone))
.to eq(project_milestone_url(project, milestone))
end
diff --git a/spec/helpers/namespaces_helper_spec.rb b/spec/helpers/namespaces_helper_spec.rb
index 7ccbdcd1332..a1d91363165 100644
--- a/spec/helpers/namespaces_helper_spec.rb
+++ b/spec/helpers/namespaces_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NamespacesHelper do
let!(:admin) { create(:admin) }
@@ -11,8 +11,8 @@ describe NamespacesHelper do
user_group.add_owner(user)
end
- describe '#namespaces_options' do
- it 'returns groups without being a member for admin' do
+ describe "#namespaces_options" do
+ it "returns groups without being a member for admin" do
allow(helper).to receive(:current_user).and_return(admin)
options = helper.namespaces_options(user_group.id, display_path: true, extra_group: user_group.id)
@@ -21,7 +21,7 @@ describe NamespacesHelper do
expect(options).to include(user_group.name)
end
- it 'returns only allowed namespaces for user' do
+ it "returns only allowed namespaces for user" do
allow(helper).to receive(:current_user).and_return(user)
options = helper.namespaces_options
@@ -31,7 +31,7 @@ describe NamespacesHelper do
expect(options).to include(user.name)
end
- it 'avoids duplicate groups when extra_group is used' do
+ it "avoids duplicate groups when extra_group is used" do
allow(helper).to receive(:current_user).and_return(admin)
options = helper.namespaces_options(user_group.id, display_path: true, extra_group: build(:group, name: admin_group.name))
@@ -40,7 +40,7 @@ describe NamespacesHelper do
expect(options).to include(admin_group.name)
end
- it 'selects existing group' do
+ it "selects existing group" do
allow(helper).to receive(:current_user).and_return(admin)
options = helper.namespaces_options(:extra_group, display_path: true, extra_group: user_group)
@@ -49,20 +49,20 @@ describe NamespacesHelper do
expect(options).to include(admin_group.name)
end
- it 'selects the new group by default' do
+ it "selects the new group by default" do
# Ensure we don't select a group with the same name
- create(:group, name: 'new-group', path: 'another-path')
+ create(:group, name: "new-group", path: "another-path")
allow(helper).to receive(:current_user).and_return(user)
- options = helper.namespaces_options(:extra_group, display_path: true, extra_group: build(:group, name: 'new-group', path: 'new-group'))
+ options = helper.namespaces_options(:extra_group, display_path: true, extra_group: build(:group, name: "new-group", path: "new-group"))
expect(options).to include(user_group.name)
expect(options).not_to include(admin_group.name)
expect(options).to include("selected=\"selected\" value=\"-1\"")
end
- it 'falls back to current user selection' do
+ it "falls back to current user selection" do
allow(helper).to receive(:current_user).and_return(user)
options = helper.namespaces_options(:extra_group, display_path: true, extra_group: build(:group, name: admin_group.name))
@@ -72,7 +72,7 @@ describe NamespacesHelper do
expect(options).to include("selected=\"selected\" value=\"#{user.namespace.id}\"")
end
- it 'returns only groups if groups_only option is true' do
+ it "returns only groups if groups_only option is true" do
allow(helper).to receive(:current_user).and_return(user)
options = helper.namespaces_options(nil, groups_only: true)
@@ -81,8 +81,8 @@ describe NamespacesHelper do
expect(options).to include(user_group.name)
end
- context 'when nested groups are available', :nested_groups do
- it 'includes groups nested in groups the user can administer' do
+ context "when nested groups are available", :nested_groups do
+ it "includes groups nested in groups the user can administer" do
allow(helper).to receive(:current_user).and_return(user)
child_group = create(:group, :private, parent: user_group)
@@ -91,15 +91,15 @@ describe NamespacesHelper do
expect(options).to include(child_group.name)
end
- it 'orders the groups correctly' do
+ it "orders the groups correctly" do
allow(helper).to receive(:current_user).and_return(user)
child_group = create(:group, :private, parent: user_group)
other_child = create(:group, :private, parent: user_group)
sub_child = create(:group, :private, parent: child_group)
expect(helper).to receive(:options_for_group)
- .with([user_group, child_group, sub_child, other_child], anything)
- .and_call_original
+ .with([user_group, child_group, sub_child, other_child], anything)
+ .and_call_original
allow(helper).to receive(:options_for_group).and_call_original
helper.namespaces_options
diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb
index e840c927d59..cfd677f8cbd 100644
--- a/spec/helpers/nav_helper_spec.rb
+++ b/spec/helpers/nav_helper_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe NavHelper do
- describe '#header_links' do
+ describe "#header_links" do
before do
allow(helper).to receive(:session) { {} }
end
- context 'when the user is logged in' do
+ context "when the user is logged in" do
let(:user) { build(:user) }
before do
@@ -14,28 +14,28 @@ describe NavHelper do
allow(helper).to receive(:can?) { true }
end
- it 'has all the expected links by default' do
+ it "has all the expected links by default" do
menu_items = [:user_dropdown, :search, :issues, :merge_requests, :todos]
expect(helper.header_links).to contain_exactly(*menu_items)
end
- it 'contains the impersonation link while impersonating' do
- expect(helper).to receive(:session) { { impersonator_id: 1 } }
+ it "contains the impersonation link while impersonating" do
+ expect(helper).to receive(:session) { {impersonator_id: 1} }
expect(helper.header_links).to include(:admin_impersonation)
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
before do
allow(helper).to receive(:can?).with(user, :read_cross_project) { false }
end
- it 'does not contain cross project elements when the user cannot read cross project' do
+ it "does not contain cross project elements when the user cannot read cross project" do
expect(helper.header_links).not_to include(:issues, :merge_requests, :todos, :search)
end
- it 'shows the search box when the user cannot read cross project and he is visiting a project' do
+ it "shows the search box when the user cannot read cross project and he is visiting a project" do
helper.instance_variable_set(:@project, create(:project))
expect(helper.header_links).to include(:search)
@@ -43,7 +43,7 @@ describe NavHelper do
end
end
- it 'returns only the sign in and search when the user is not logged in' do
+ it "returns only the sign in and search when the user is not logged in" do
allow(helper).to receive(:current_user).and_return(nil)
allow(helper).to receive(:can?).with(nil, :read_cross_project) { true }
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index 0715f34dafe..6d64ddf54fe 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -23,13 +23,13 @@ describe NotesHelper do
end
describe "#notes_max_access_for_users" do
- it 'returns access levels' do
+ it "returns access levels" do
expect(helper.note_max_access_for_user(owner_note)).to eq(Gitlab::Access::OWNER)
expect(helper.note_max_access_for_user(maintainer_note)).to eq(Gitlab::Access::MAINTAINER)
expect(helper.note_max_access_for_user(reporter_note)).to eq(Gitlab::Access::REPORTER)
end
- it 'handles access in different projects' do
+ it "handles access in different projects" do
second_project = create(:project)
second_project.add_reporter(maintainer)
other_note = create(:note, author: maintainer, project: second_project)
@@ -39,26 +39,26 @@ describe NotesHelper do
end
end
- describe '#discussion_path' do
+ describe "#discussion_path" do
let(:project) { create(:project, :repository) }
let(:anchor) { discussion.line_code }
- context 'for a merge request discusion' do
+ context "for a merge request discusion" do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
- let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
- context 'for a diff discussion' do
- context 'when the discussion is active' do
+ context "for a diff discussion" do
+ context "when the discussion is active" do
let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
- it 'returns the diff path with the line code' do
+ it "returns the diff path with the line code" do
expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code))
end
end
- context 'when the discussion is on an older merge request version' do
+ context "when the discussion is on an older merge request version" do
let(:position) do
Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -77,12 +77,12 @@ describe NotesHelper do
diff_note.save!
end
- it 'returns the diff version path with the line code' do
+ it "returns the diff version path with the line code" do
expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff1, anchor: discussion.line_code))
end
end
- context 'when the discussion is on a comparison between merge request versions' do
+ context "when the discussion is on a comparison between merge request versions" do
let(:position) do
Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -101,12 +101,12 @@ describe NotesHelper do
diff_note.save!
end
- it 'returns the diff version comparison path with the line code' do
+ it "returns the diff version comparison path with the line code" do
expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code))
end
end
- context 'when the discussion does not have a merge request version' do
+ context "when the discussion does not have a merge request version" do
let(:outdated_diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, diff_refs: project.commit(sample_commit.id).diff_refs) }
let(:discussion) { outdated_diff_note.to_discussion }
@@ -115,182 +115,182 @@ describe NotesHelper do
outdated_diff_note.save!
end
- it 'returns nil' do
+ it "returns nil" do
expect(helper.discussion_path(discussion)).to be_nil
end
end
end
- context 'for a legacy diff discussion' do
+ context "for a legacy diff discussion" do
let(:discussion) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
- context 'when the discussion is active' do
+ context "when the discussion is active" do
before do
allow(discussion).to receive(:active?).and_return(true)
end
- it 'returns the diff path with the line code' do
+ it "returns the diff path with the line code" do
expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code))
end
end
- context 'when the discussion is outdated' do
+ context "when the discussion is outdated" do
before do
allow(discussion).to receive(:active?).and_return(false)
end
- it 'returns nil' do
+ it "returns nil" do
expect(helper.discussion_path(discussion)).to be_nil
end
end
end
- context 'for a non-diff discussion' do
+ context "for a non-diff discussion" do
let(:discussion) { create(:discussion_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
- it 'returns nil' do
+ it "returns nil" do
expect(helper.discussion_path(discussion)).to be_nil
end
end
- context 'for a contextual commit discussion' do
+ context "for a contextual commit discussion" do
let(:commit) { merge_request.commits.last }
let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, commit_id: commit.id).to_discussion }
- it 'returns the merge request diff discussion scoped in the commit' do
+ it "returns the merge request diff discussion scoped in the commit" do
expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, commit_id: commit.id, anchor: anchor))
end
end
end
- context 'for a commit discussion' do
+ context "for a commit discussion" do
let(:commit) { discussion.noteable }
- context 'for a diff discussion' do
+ context "for a diff discussion" do
let(:discussion) { create(:diff_note_on_commit, project: project).to_discussion }
- it 'returns the commit path with the line code' do
+ it "returns the commit path with the line code" do
expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: anchor))
end
end
- context 'for a legacy diff discussion' do
+ context "for a legacy diff discussion" do
let(:discussion) { create(:legacy_diff_note_on_commit, project: project).to_discussion }
- it 'returns the commit path with the line code' do
+ it "returns the commit path with the line code" do
expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: anchor))
end
end
- context 'for a non-diff discussion' do
+ context "for a non-diff discussion" do
let(:discussion) { create(:discussion_note_on_commit, project: project).to_discussion }
- it 'returns the commit path with the note anchor' do
+ it "returns the commit path with the note anchor" do
expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: "note_#{discussion.first_note.id}"))
end
end
end
end
- describe '#notes_url' do
- it 'return snippet notes path for personal snippet' do
+ describe "#notes_url" do
+ it "return snippet notes path for personal snippet" do
@snippet = create(:personal_snippet)
expect(helper.notes_url).to eq("/snippets/#{@snippet.id}/notes")
end
- it 'return project notes path for project snippet' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "return project notes path for project snippet" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
@snippet = create(:project_snippet, project: @project)
@noteable = @snippet
expect(helper.notes_url).to eq("/nm/test/noteable/project_snippet/#{@noteable.id}/notes")
end
- it 'return project notes path for other noteables' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "return project notes path for other noteables" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
@noteable = create(:issue, project: @project)
expect(helper.notes_url).to eq("/nm/test/noteable/issue/#{@noteable.id}/notes")
end
end
- describe '#note_url' do
- it 'return snippet notes path for personal snippet' do
+ describe "#note_url" do
+ it "return snippet notes path for personal snippet" do
note = create(:note_on_personal_snippet)
expect(helper.note_url(note)).to eq("/snippets/#{note.noteable.id}/notes/#{note.id}")
end
- it 'return project notes path for project snippet' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "return project notes path for project snippet" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
note = create(:note_on_project_snippet, project: @project)
expect(helper.note_url(note)).to eq("/nm/test/notes/#{note.id}")
end
- it 'return project notes path for other noteables' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "return project notes path for other noteables" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
note = create(:note_on_issue, project: @project)
expect(helper.note_url(note)).to eq("/nm/test/notes/#{note.id}")
end
end
- describe '#form_resources' do
- it 'returns note for personal snippet' do
+ describe "#form_resources" do
+ it "returns note for personal snippet" do
@snippet = create(:personal_snippet)
@note = create(:note_on_personal_snippet)
expect(helper.form_resources).to eq([@note])
end
- it 'returns namespace, project and note for project snippet' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "returns namespace, project and note for project snippet" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
@snippet = create(:project_snippet, project: @project)
@note = create(:note_on_personal_snippet)
expect(helper.form_resources).to eq([@project.namespace, @project, @note])
end
- it 'returns namespace, project and note path for other noteables' do
- namespace = create(:namespace, path: 'nm')
- @project = create(:project, path: 'test', namespace: namespace)
+ it "returns namespace, project and note path for other noteables" do
+ namespace = create(:namespace, path: "nm")
+ @project = create(:project, path: "test", namespace: namespace)
@note = create(:note_on_issue, project: @project)
expect(helper.form_resources).to eq([@project.namespace, @project, @note])
end
end
- describe '#noteable_note_url' do
+ describe "#noteable_note_url" do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:note) { create(:note_on_issue, noteable: issue, project: project) }
- it 'returns the noteable url with an anchor to the note' do
+ it "returns the noteable url with an anchor to the note" do
expect(noteable_note_url(note)).to match("/#{project.namespace.path}/#{project.path}/issues/#{issue.iid}##{dom_id(note)}")
end
end
- describe '#discussion_resolved_intro' do
- context 'when the discussion was resolved by a push' do
+ describe "#discussion_resolved_intro" do
+ context "when the discussion was resolved by a push" do
let(:discussion) { double(:discussion, resolved_by_push?: true) }
it 'returns "Automatically resolved"' do
- expect(discussion_resolved_intro(discussion)).to eq('Automatically resolved')
+ expect(discussion_resolved_intro(discussion)).to eq("Automatically resolved")
end
end
- context 'when the discussion was not resolved by a push' do
+ context "when the discussion was not resolved by a push" do
let(:discussion) { double(:discussion, resolved_by_push?: false) }
it 'returns "Resolved"' do
- expect(discussion_resolved_intro(discussion)).to eq('Resolved')
+ expect(discussion_resolved_intro(discussion)).to eq("Resolved")
end
end
end
diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb
index 9ecaabc04ed..b6d615be3d0 100644
--- a/spec/helpers/notifications_helper_spec.rb
+++ b/spec/helpers/notifications_helper_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe NotificationsHelper do
- describe 'notification_icon' do
+ describe "notification_icon" do
it { expect(notification_icon(:disabled)).to match('class="fa fa-microphone-slash fa-fw"') }
it { expect(notification_icon(:participating)).to match('class="fa fa-volume-up fa-fw"') }
it { expect(notification_icon(:mention)).to match('class="fa fa-at fa-fw"') }
@@ -9,14 +9,14 @@ describe NotificationsHelper do
it { expect(notification_icon(:watch)).to match('class="fa fa-eye fa-fw"') }
end
- describe 'notification_title' do
- it { expect(notification_title(:watch)).to match('Watch') }
- it { expect(notification_title(:mention)).to match('On mention') }
- it { expect(notification_title(:global)).to match('Global') }
+ describe "notification_title" do
+ it { expect(notification_title(:watch)).to match("Watch") }
+ it { expect(notification_title(:mention)).to match("On mention") }
+ it { expect(notification_title(:global)).to match("Global") }
end
- describe '#notification_event_name' do
- it { expect(notification_event_name(:success_pipeline)).to match('Successful pipeline') }
- it { expect(notification_event_name(:failed_pipeline)).to match('Failed pipeline') }
+ describe "#notification_event_name" do
+ it { expect(notification_event_name(:success_pipeline)).to match("Successful pipeline") }
+ it { expect(notification_event_name(:failed_pipeline)).to match("Failed pipeline") }
end
end
diff --git a/spec/helpers/page_layout_helper_spec.rb b/spec/helpers/page_layout_helper_spec.rb
index cf98eed27f1..00823197b41 100644
--- a/spec/helpers/page_layout_helper_spec.rb
+++ b/spec/helpers/page_layout_helper_spec.rb
@@ -1,26 +1,26 @@
-require 'rails_helper'
+require "rails_helper"
describe PageLayoutHelper do
- describe 'page_description' do
- it 'defaults to nil' do
+ describe "page_description" do
+ it "defaults to nil" do
expect(helper.page_description).to eq nil
end
- it 'returns the last-pushed description' do
- helper.page_description('Foo')
- helper.page_description('Bar')
- helper.page_description('Baz')
+ it "returns the last-pushed description" do
+ helper.page_description("Foo")
+ helper.page_description("Bar")
+ helper.page_description("Baz")
- expect(helper.page_description).to eq 'Baz'
+ expect(helper.page_description).to eq "Baz"
end
- it 'squishes multiple newlines' do
+ it "squishes multiple newlines" do
helper.page_description("Foo\nBar\nBaz")
- expect(helper.page_description).to eq 'Foo Bar Baz'
+ expect(helper.page_description).to eq "Foo Bar Baz"
end
- it 'truncates' do
+ it "truncates" do
helper.page_description <<-LOREM.strip_heredoc
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis
@@ -30,81 +30,81 @@ describe PageLayoutHelper do
arcu.
LOREM
- expect(helper.page_description).to end_with 'quam felis,...'
+ expect(helper.page_description).to end_with "quam felis,..."
end
- it 'sanitizes all HTML' do
+ it "sanitizes all HTML" do
helper.page_description("<b>Bold</b> <h1>Header</h1>")
- expect(helper.page_description).to eq 'Bold Header'
+ expect(helper.page_description).to eq "Bold Header"
end
end
- describe 'page_image' do
- it 'defaults to the GitLab logo' do
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ describe "page_image" do
+ it "defaults to the GitLab logo" do
+ expect(helper.page_image).to match_asset_path "assets/gitlab_logo.png"
end
- %w(project user group).each do |type|
+ %w[project user group].each do |type|
context "with @#{type} assigned" do
it "uses #{type.titlecase} avatar if available" do
- object = double(avatar_url: 'http://example.com/uploads/-/system/avatar.png')
+ object = double(avatar_url: "http://example.com/uploads/-/system/avatar.png")
assign(type, object)
expect(helper.page_image).to eq object.avatar_url
end
- it 'falls back to the default when avatar_url is nil' do
+ it "falls back to the default when avatar_url is nil" do
object = double(avatar_url: nil)
assign(type, object)
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ expect(helper.page_image).to match_asset_path "assets/gitlab_logo.png"
end
end
context "with no assignments" do
- it 'falls back to the default' do
- expect(helper.page_image).to match_asset_path 'assets/gitlab_logo.png'
+ it "falls back to the default" do
+ expect(helper.page_image).to match_asset_path "assets/gitlab_logo.png"
end
end
end
end
- describe 'page_card_attributes' do
- it 'raises ArgumentError when given more than two attributes' do
- map = { foo: 'foo', bar: 'bar', baz: 'baz' }
+ describe "page_card_attributes" do
+ it "raises ArgumentError when given more than two attributes" do
+ map = {foo: "foo", bar: "bar", baz: "baz"}
expect { helper.page_card_attributes(map) }
.to raise_error(ArgumentError, /more than two attributes/)
end
- it 'rejects blank values' do
- map = { foo: 'foo', bar: '' }
+ it "rejects blank values" do
+ map = {foo: "foo", bar: ""}
helper.page_card_attributes(map)
- expect(helper.page_card_attributes).to eq({ foo: 'foo' })
+ expect(helper.page_card_attributes).to eq({foo: "foo"})
end
end
- describe 'page_card_meta_tags' do
- it 'returns the twitter:label and twitter:data tags' do
- allow(helper).to receive(:page_card_attributes).and_return(foo: 'bar')
+ describe "page_card_meta_tags" do
+ it "returns the twitter:label and twitter:data tags" do
+ allow(helper).to receive(:page_card_attributes).and_return(foo: "bar")
tags = helper.page_card_meta_tags
aggregate_failures do
- expect(tags).to include %q(<meta property="twitter:label1" content="foo" />)
- expect(tags).to include %q(<meta property="twitter:data1" content="bar" />)
+ expect(tags).to include '<meta property="twitter:label1" content="foo" />'
+ expect(tags).to include '<meta property="twitter:data1" content="bar" />'
end
end
- it 'escapes content' do
+ it "escapes content" do
allow(helper).to receive(:page_card_attributes)
- .and_return(foo: %q{foo" http-equiv="refresh}.html_safe)
+ .and_return(foo: 'foo" http-equiv="refresh'.html_safe)
tags = helper.page_card_meta_tags
- expect(tags).to include(%q{content="foo&quot; http-equiv=&quot;refresh"})
+ expect(tags).to include('content="foo&quot; http-equiv=&quot;refresh"')
end
end
end
diff --git a/spec/helpers/pagination_helper_spec.rb b/spec/helpers/pagination_helper_spec.rb
index e235475fb47..448cc768185 100644
--- a/spec/helpers/pagination_helper_spec.rb
+++ b/spec/helpers/pagination_helper_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe PaginationHelper do
- describe '#paginate_collection' do
+ describe "#paginate_collection" do
let(:collection) { User.all.page(1) }
- it 'paginates a collection without using a COUNT' do
+ it "paginates a collection without using a COUNT" do
without_count = collection.without_count
expect(helper).to receive(:paginate_without_count)
@@ -14,7 +14,7 @@ describe PaginationHelper do
helper.paginate_collection(without_count)
end
- it 'paginates a collection using a COUNT' do
+ it "paginates a collection using a COUNT" do
expect(helper).to receive(:paginate_with_count).and_call_original
helper.paginate_collection(collection)
diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb
index e0e8ebd0c3c..c0bc484accb 100644
--- a/spec/helpers/preferences_helper_spec.rb
+++ b/spec/helpers/preferences_helper_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe PreferencesHelper do
- describe '#dashboard_choices' do
+ describe "#dashboard_choices" do
let(:user) { build(:user) }
before do
@@ -9,75 +9,75 @@ describe PreferencesHelper do
allow(helper).to receive(:can?).and_return(false)
end
- it 'raises an exception when defined choices may be missing' do
- expect(User).to receive(:dashboards).and_return(foo: 'foo')
+ it "raises an exception when defined choices may be missing" do
+ expect(User).to receive(:dashboards).and_return(foo: "foo")
expect { helper.dashboard_choices }.to raise_error(RuntimeError)
end
- it 'raises an exception when defined choices may be using the wrong key' do
+ it "raises an exception when defined choices may be using the wrong key" do
dashboards = User.dashboards.dup
dashboards[:projects_changed] = dashboards.delete :projects
expect(User).to receive(:dashboards).and_return(dashboards)
expect { helper.dashboard_choices }.to raise_error(KeyError)
end
- it 'provides better option descriptions' do
+ it "provides better option descriptions" do
expect(helper.dashboard_choices).to match_array [
- ['Your Projects (default)', 'projects'],
- ['Starred Projects', 'stars'],
- ["Your Projects' Activity", 'project_activity'],
- ["Starred Projects' Activity", 'starred_project_activity'],
- ["Your Groups", 'groups'],
- ["Your Todos", 'todos'],
- ["Assigned Issues", 'issues'],
- ["Assigned Merge Requests", 'merge_requests']
+ ["Your Projects (default)", "projects"],
+ ["Starred Projects", "stars"],
+ ["Your Projects' Activity", "project_activity"],
+ ["Starred Projects' Activity", "starred_project_activity"],
+ ["Your Groups", "groups"],
+ ["Your Todos", "todos"],
+ ["Assigned Issues", "issues"],
+ ["Assigned Merge Requests", "merge_requests"],
]
end
end
- describe '#first_day_of_week_choices' do
- it 'returns Sunday and Monday as choices' do
+ describe "#first_day_of_week_choices" do
+ it "returns Sunday and Monday as choices" do
expect(helper.first_day_of_week_choices).to eq [
- ['Sunday', 0],
- ['Monday', 1]
+ ["Sunday", 0],
+ ["Monday", 1],
]
end
end
- describe '#first_day_of_week_choices_with_default' do
- it 'returns choices including system default' do
+ describe "#first_day_of_week_choices_with_default" do
+ it "returns choices including system default" do
expect(helper.first_day_of_week_choices_with_default).to eq [
- ['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1]
+ ["System default (Sunday)", nil], ["Sunday", 0], ["Monday", 1],
]
end
- it 'returns choices including system default set to Monday' do
+ it "returns choices including system default set to Monday" do
stub_application_setting(first_day_of_week: 1)
expect(helper.first_day_of_week_choices_with_default).to eq [
- ['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1]
+ ["System default (Monday)", nil], ["Sunday", 0], ["Monday", 1],
]
end
end
- describe '#user_application_theme' do
- context 'with a user' do
+ describe "#user_application_theme" do
+ context "with a user" do
it "returns user's theme's css_class" do
stub_user(theme_id: 3)
- expect(helper.user_application_theme).to eq 'ui-light'
+ expect(helper.user_application_theme).to eq "ui-light"
end
- it 'returns the default when id is invalid' do
+ it "returns the default when id is invalid" do
stub_user(theme_id: Gitlab::Themes.count + 5)
allow(Gitlab.config.gitlab).to receive(:default_theme).and_return(1)
- expect(helper.user_application_theme).to eq 'ui-indigo'
+ expect(helper.user_application_theme).to eq "ui-indigo"
end
end
- context 'without a user' do
- it 'returns the default theme' do
+ context "without a user" do
+ it "returns the default theme" do
stub_user
expect(helper.user_application_theme).to eq Gitlab::Themes.default.css_class
@@ -85,23 +85,23 @@ describe PreferencesHelper do
end
end
- describe '#user_color_scheme' do
- context 'with a user' do
+ describe "#user_color_scheme" do
+ context "with a user" do
it "returns user's scheme's css_class" do
allow(helper).to receive(:current_user)
.and_return(double(color_scheme_id: 3))
- expect(helper.user_color_scheme).to eq 'solarized-light'
+ expect(helper.user_color_scheme).to eq "solarized-light"
end
- it 'returns the default when id is invalid' do
+ it "returns the default when id is invalid" do
allow(helper).to receive(:current_user)
.and_return(double(color_scheme_id: Gitlab::ColorSchemes.count + 5))
end
end
- context 'without a user' do
- it 'returns the default theme' do
+ context "without a user" do
+ it "returns the default theme" do
stub_user
expect(helper.user_color_scheme)
@@ -110,8 +110,8 @@ describe PreferencesHelper do
end
end
- describe '#language_choices' do
- it 'returns an array of all available languages' do
+ describe "#language_choices" do
+ it "returns an array of all available languages" do
expect(helper.language_choices).to be_an(Array)
expect(helper.language_choices.map(&:second)).to eq(Gitlab::I18n.available_locales)
end
@@ -122,7 +122,7 @@ describe PreferencesHelper do
allow(helper).to receive(:current_user).and_return(nil)
else
allow(helper).to receive(:current_user)
- .and_return(double('user', messages))
+ .and_return(double("user", messages))
end
end
end
diff --git a/spec/helpers/profiles_helper_spec.rb b/spec/helpers/profiles_helper_spec.rb
index 8e336469c27..1ecb732f0b4 100644
--- a/spec/helpers/profiles_helper_spec.rb
+++ b/spec/helpers/profiles_helper_spec.rb
@@ -1,8 +1,8 @@
-require 'rails_helper'
+require "rails_helper"
describe ProfilesHelper do
- describe '#commit_email_select_options' do
- it 'returns an array with private commit email along with all the verified emails' do
+ describe "#commit_email_select_options" do
+ it "returns an array with private commit email along with all the verified emails" do
user = create(:user)
create(:email, user: user)
confirmed_email1 = create(:email, :confirmed, user: user)
@@ -14,28 +14,28 @@ describe ProfilesHelper do
["Use a private email - #{private_email}", Gitlab::PrivateCommitEmail::TOKEN],
user.email,
confirmed_email1.email,
- confirmed_email2.email
+ confirmed_email2.email,
]
expect(helper.commit_email_select_options(user)).to match_array(emails)
end
end
- describe '#selected_commit_email' do
+ describe "#selected_commit_email" do
let(:user) { create(:user) }
- it 'returns main email when commit email attribute is nil' do
+ it "returns main email when commit email attribute is nil" do
expect(helper.selected_commit_email(user)).to eq(user.email)
end
- it 'returns DB stored commit_email' do
+ it "returns DB stored commit_email" do
user.update(commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(helper.selected_commit_email(user)).to eq(Gitlab::PrivateCommitEmail::TOKEN)
end
end
- describe '#email_provider_label' do
+ describe "#email_provider_label" do
it "returns nil for users without external email" do
user = create(:user)
allow(helper).to receive(:current_user).and_return(user)
@@ -44,28 +44,28 @@ describe ProfilesHelper do
end
it "returns omniauth provider label for users with external attributes" do
- stub_omniauth_setting(sync_profile_from_provider: ['cas3'])
+ stub_omniauth_setting(sync_profile_from_provider: ["cas3"])
stub_omniauth_setting(sync_profile_attributes: true)
stub_cas_omniauth_provider
- cas_user = create(:omniauth_user, provider: 'cas3')
- cas_user.create_user_synced_attributes_metadata(provider: 'cas3', name_synced: true, email_synced: true, location_synced: true)
+ cas_user = create(:omniauth_user, provider: "cas3")
+ cas_user.create_user_synced_attributes_metadata(provider: "cas3", name_synced: true, email_synced: true, location_synced: true)
allow(helper).to receive(:current_user).and_return(cas_user)
- expect(helper.attribute_provider_label(:email)).to eq('CAS')
- expect(helper.attribute_provider_label(:name)).to eq('CAS')
- expect(helper.attribute_provider_label(:location)).to eq('CAS')
+ expect(helper.attribute_provider_label(:email)).to eq("CAS")
+ expect(helper.attribute_provider_label(:name)).to eq("CAS")
+ expect(helper.attribute_provider_label(:location)).to eq("CAS")
end
it "returns the correct omniauth provider label for users with some external attributes" do
- stub_omniauth_setting(sync_profile_from_provider: ['cas3'])
+ stub_omniauth_setting(sync_profile_from_provider: ["cas3"])
stub_omniauth_setting(sync_profile_attributes: true)
stub_cas_omniauth_provider
- cas_user = create(:omniauth_user, provider: 'cas3')
- cas_user.create_user_synced_attributes_metadata(provider: 'cas3', name_synced: false, email_synced: true, location_synced: false)
+ cas_user = create(:omniauth_user, provider: "cas3")
+ cas_user.create_user_synced_attributes_metadata(provider: "cas3", name_synced: false, email_synced: true, location_synced: false)
allow(helper).to receive(:current_user).and_return(cas_user)
expect(helper.attribute_provider_label(:name)).to be_nil
- expect(helper.attribute_provider_label(:email)).to eq('CAS')
+ expect(helper.attribute_provider_label(:email)).to eq("CAS")
expect(helper.attribute_provider_label(:location)).to be_nil
end
@@ -74,14 +74,14 @@ describe ProfilesHelper do
ldap_user.create_user_synced_attributes_metadata(email_synced: true)
allow(helper).to receive(:current_user).and_return(ldap_user)
- expect(helper.attribute_provider_label(:email)).to eq('LDAP')
+ expect(helper.attribute_provider_label(:email)).to eq("LDAP")
end
end
def stub_cas_omniauth_provider
provider = OpenStruct.new(
- 'name' => 'cas3',
- 'label' => 'CAS'
+ "name" => "cas3",
+ "label" => "CAS"
)
stub_omniauth_setting(providers: [provider])
diff --git a/spec/helpers/projects/error_tracking_helper_spec.rb b/spec/helpers/projects/error_tracking_helper_spec.rb
index 7516a636c93..436e6bac9fb 100644
--- a/spec/helpers/projects/error_tracking_helper_spec.rb
+++ b/spec/helpers/projects/error_tracking_helper_spec.rb
@@ -1,55 +1,55 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ErrorTrackingHelper do
include Gitlab::Routing.url_helpers
set(:project) { create(:project) }
- describe '#error_tracking_data' do
+ describe "#error_tracking_data" do
let(:setting_path) { project_settings_operations_path(project) }
let(:index_path) do
project_error_tracking_index_path(project, format: :json)
end
- context 'without error_tracking_setting' do
- it 'returns frontend configuration' do
+ context "without error_tracking_setting" do
+ it "returns frontend configuration" do
expect(error_tracking_data(project)).to eq(
- 'index-path' => index_path,
- 'enable-error-tracking-link' => setting_path,
- 'error-tracking-enabled' => 'false',
+ "index-path" => index_path,
+ "enable-error-tracking-link" => setting_path,
+ "error-tracking-enabled" => "false",
"illustration-path" => "/images/illustrations/cluster_popover.svg"
)
end
end
- context 'with error_tracking_setting' do
+ context "with error_tracking_setting" do
let(:error_tracking_setting) do
create(:project_error_tracking_setting, project: project)
end
- context 'when enabled' do
+ context "when enabled" do
before do
error_tracking_setting.update!(enabled: true)
end
- it 'show error tracking enabled' do
+ it "show error tracking enabled" do
expect(error_tracking_data(project)).to include(
- 'error-tracking-enabled' => 'true'
+ "error-tracking-enabled" => "true"
)
end
end
- context 'when disabled' do
+ context "when disabled" do
before do
error_tracking_setting.update!(enabled: false)
end
- it 'show error tracking not enabled' do
+ it "show error tracking not enabled" do
expect(error_tracking_data(project)).to include(
- 'error-tracking-enabled' => 'false'
+ "error-tracking-enabled" => "false"
)
end
end
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb
index 49895b0680b..5a1eed2af87 100644
--- a/spec/helpers/projects_helper_spec.rb
+++ b/spec/helpers/projects_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectsHelper do
include ProjectForksHelper
@@ -28,7 +28,7 @@ describe ProjectsHelper do
expect(helper.can_change_visibility_level?(project, user)).to be_truthy
end
- it 'allows visibility level to be changed if the project is forked' do
+ it "allows visibility level to be changed if the project is forked" do
allow(helper).to receive(:can?).with(user, :change_visibility_level, project) { true }
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
fork_project(project)
@@ -114,11 +114,11 @@ describe ProjectsHelper do
end
it "includes a version" do
- expect(helper.project_list_cache_key(project).last).to start_with('v')
+ expect(helper.project_list_cache_key(project).last).to start_with("v")
end
- it 'includes wether or not the user can read cross project' do
- expect(helper.project_list_cache_key(project)).to include('cross-project:true')
+ it "includes wether or not the user can read cross project" do
+ expect(helper.project_list_cache_key(project)).to include("cross-project:true")
end
it "includes the pipeline status when there is a status" do
@@ -128,37 +128,37 @@ describe ProjectsHelper do
end
it "includes the user max member access" do
- expect(helper.project_list_cache_key(project)).to include('access:40')
+ expect(helper.project_list_cache_key(project)).to include("access:40")
end
end
- describe '#load_pipeline_status' do
- it 'loads the pipeline status in batch' do
+ describe "#load_pipeline_status" do
+ it "loads the pipeline status in batch" do
project = build(:project)
helper.load_pipeline_status([project])
# Skip lazy loading of the `pipeline_status` attribute
- pipeline_status = project.instance_variable_get('@pipeline_status')
+ pipeline_status = project.instance_variable_get("@pipeline_status")
expect(pipeline_status).to be_a(Gitlab::Cache::Ci::ProjectPipelineStatus)
end
end
- describe '#show_no_ssh_key_message?' do
+ describe "#show_no_ssh_key_message?" do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'user has no keys' do
- it 'returns true' do
+ context "user has no keys" do
+ it "returns true" do
expect(helper.show_no_ssh_key_message?).to be_truthy
end
end
- context 'user has an ssh key' do
- it 'returns false' do
+ context "user has an ssh key" do
+ it "returns false" do
create(:personal_key, user: user)
expect(helper.show_no_ssh_key_message?).to be_falsey
@@ -166,37 +166,37 @@ describe ProjectsHelper do
end
end
- describe '#show_no_password_message?' do
+ describe "#show_no_password_message?" do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'user has password set' do
- it 'returns false' do
+ context "user has password set" do
+ it "returns false" do
expect(helper.show_no_password_message?).to be_falsey
end
end
- context 'user has hidden the message' do
- it 'returns false' do
+ context "user has hidden the message" do
+ it "returns false" do
allow(helper).to receive(:cookies).and_return(hide_no_password_message: true)
expect(helper.show_no_password_message?).to be_falsey
end
end
- context 'user requires a password for Git' do
- it 'returns true' do
+ context "user requires a password for Git" do
+ it "returns true" do
allow(user).to receive(:require_password_creation_for_git?).and_return(true)
expect(helper.show_no_password_message?).to be_truthy
end
end
- context 'user requires a personal access token for Git' do
- it 'returns true' do
+ context "user requires a personal access token for Git" do
+ it "returns true" do
allow(user).to receive(:require_password_creation_for_git?).and_return(false)
allow(user).to receive(:require_personal_access_token_creation_for_git_auth?).and_return(true)
@@ -205,23 +205,23 @@ describe ProjectsHelper do
end
end
- describe '#link_to_set_password' do
+ describe "#link_to_set_password" do
let(:user) { create(:user, password_automatically_set: true) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'password authentication is enabled for Git' do
- it 'returns link to set a password' do
+ context "password authentication is enabled for Git" do
+ it "returns link to set a password" do
stub_application_setting(password_authentication_enabled_for_git?: true)
expect(helper.link_to_set_password).to match %r{<a href="#{edit_profile_password_path}">set a password</a>}
end
end
- context 'password authentication is disabled for Git' do
- it 'returns link to create a personal access token' do
+ context "password authentication is disabled for Git" do
+ it "returns link to create a personal access token" do
stub_application_setting(password_authentication_enabled_for_git?: false)
expect(helper.link_to_set_password).to match %r{<a href="#{profile_personal_access_tokens_path}">create a personal access token</a>}
@@ -229,19 +229,19 @@ describe ProjectsHelper do
end
end
- describe '#link_to_project' do
- let(:group) { create(:group, name: 'group name with space') }
- let(:project) { create(:project, group: group, name: 'project name with space') }
+ describe "#link_to_project" do
+ let(:group) { create(:group, name: "group name with space") }
+ let(:project) { create(:project, group: group, name: "project name with space") }
subject { link_to_project(project) }
- it 'returns an HTML link to the project' do
+ it "returns an HTML link to the project" do
expect(subject).to match(%r{/#{group.full_path}/#{project.path}})
- expect(subject).to include('group name with space /')
- expect(subject).to include('project name with space')
+ expect(subject).to include("group name with space /")
+ expect(subject).to include("project name with space")
end
end
- describe '#link_to_member_avatar' do
+ describe "#link_to_member_avatar" do
let(:user) { build_stubbed(:user) }
let(:expected) { double }
@@ -249,32 +249,32 @@ describe ProjectsHelper do
expect(helper).to receive(:avatar_icon_for_user).with(user, 16).and_return(expected)
end
- it 'returns image tag for member avatar' do
- expect(helper).to receive(:image_tag).with(expected, { width: 16, class: ["avatar", "avatar-inline", "s16"], alt: "", "data-src" => anything })
+ it "returns image tag for member avatar" do
+ expect(helper).to receive(:image_tag).with(expected, {:width => 16, :class => ["avatar", "avatar-inline", "s16"], :alt => "", "data-src" => anything})
helper.link_to_member_avatar(user)
end
- it 'returns image tag with avatar class' do
- expect(helper).to receive(:image_tag).with(expected, { width: 16, class: ["avatar", "avatar-inline", "s16", "any-avatar-class"], alt: "", "data-src" => anything })
+ it "returns image tag with avatar class" do
+ expect(helper).to receive(:image_tag).with(expected, {:width => 16, :class => ["avatar", "avatar-inline", "s16", "any-avatar-class"], :alt => "", "data-src" => anything})
helper.link_to_member_avatar(user, avatar_class: "any-avatar-class")
end
end
- describe '#link_to_member' do
+ describe "#link_to_member" do
let(:group) { build_stubbed(:group) }
let(:project) { build_stubbed(:project, group: group) }
- let(:user) { build_stubbed(:user, name: '<h1>Administrator</h1>') }
+ let(:user) { build_stubbed(:user, name: "<h1>Administrator</h1>") }
- describe 'using the default options' do
- it 'returns an HTML link to the user' do
+ describe "using the default options" do
+ it "returns an HTML link to the user" do
link = helper.link_to_member(project, user)
expect(link).to match(%r{/#{user.username}})
end
- it 'HTML escapes the name of the user' do
+ it "HTML escapes the name of the user" do
link = helper.link_to_member(project, user)
expect(link).to include(ERB::Util.html_escape(user.name))
@@ -283,26 +283,26 @@ describe ProjectsHelper do
end
end
- describe 'default_clone_protocol' do
- context 'when user is not logged in and gitlab protocol is HTTP' do
- it 'returns HTTP' do
+ describe "default_clone_protocol" do
+ context "when user is not logged in and gitlab protocol is HTTP" do
+ it "returns HTTP" do
allow(helper).to receive(:current_user).and_return(nil)
- expect(helper.send(:default_clone_protocol)).to eq('http')
+ expect(helper.send(:default_clone_protocol)).to eq("http")
end
end
- context 'when user is not logged in and gitlab protocol is HTTPS' do
- it 'returns HTTPS' do
- stub_config_setting(protocol: 'https')
+ context "when user is not logged in and gitlab protocol is HTTPS" do
+ it "returns HTTPS" do
+ stub_config_setting(protocol: "https")
allow(helper).to receive(:current_user).and_return(nil)
- expect(helper.send(:default_clone_protocol)).to eq('https')
+ expect(helper.send(:default_clone_protocol)).to eq("https")
end
end
end
- describe '#last_push_event' do
+ describe "#last_push_event" do
let(:user) { double(:user, fork_of: nil) }
let(:project) { double(:project, id: 1) }
@@ -311,15 +311,15 @@ describe ProjectsHelper do
helper.instance_variable_set(:@project, project)
end
- context 'when there is no current_user' do
+ context "when there is no current_user" do
let(:user) { nil }
- it 'returns nil' do
+ it "returns nil" do
expect(helper.last_push_event).to eq(nil)
end
end
- it 'returns recent push on the current project' do
+ it "returns recent push on the current project" do
event = double(:event)
expect(user).to receive(:recent_push).with(project).and_return(event)
@@ -327,7 +327,7 @@ describe ProjectsHelper do
end
end
- describe '#get_project_nav_tabs' do
+ describe "#get_project_nav_tabs" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -339,7 +339,7 @@ describe ProjectsHelper do
helper.send(:get_project_nav_tabs, project, user)
end
- context 'when builds feature is enabled' do
+ context "when builds feature is enabled" do
before do
allow(project).to receive(:builds_enabled?).and_return(true)
end
@@ -349,18 +349,18 @@ describe ProjectsHelper do
end
end
- context 'when builds feature is disabled' do
+ context "when builds feature is disabled" do
before do
allow(project).to receive(:builds_enabled?).and_return(false)
end
- context 'when user has access to builds' do
+ context "when user has access to builds" do
it "does include pipelines tab" do
is_expected.to include(:pipelines)
end
end
- context 'when user does not have access to builds' do
+ context "when user does not have access to builds" do
before do
allow(helper).to receive(:can?) { false }
end
@@ -371,138 +371,138 @@ describe ProjectsHelper do
end
end
- context 'when project has external wiki' do
- it 'includes external wiki tab' do
- project.create_external_wiki_service(active: true, properties: { 'external_wiki_url' => 'https://gitlab.com' })
+ context "when project has external wiki" do
+ it "includes external wiki tab" do
+ project.create_external_wiki_service(active: true, properties: {"external_wiki_url" => "https://gitlab.com"})
is_expected.to include(:external_wiki)
end
end
- context 'when project does not have external wiki' do
- it 'does not include external wiki tab' do
+ context "when project does not have external wiki" do
+ it "does not include external wiki tab" do
expect(project.external_wiki).to be_nil
is_expected.not_to include(:external_wiki)
end
end
end
- describe '#show_projects' do
+ describe "#show_projects" do
let(:projects) do
create(:project)
Project.all
end
- it 'returns true when there are projects' do
+ it "returns true when there are projects" do
expect(helper.show_projects?(projects, {})).to eq(true)
end
- it 'returns true when there are no projects but a name is given' do
- expect(helper.show_projects?(Project.none, name: 'foo')).to eq(true)
+ it "returns true when there are no projects but a name is given" do
+ expect(helper.show_projects?(Project.none, name: "foo")).to eq(true)
end
- it 'returns true when there are no projects but personal is present' do
- expect(helper.show_projects?(Project.none, personal: 'true')).to eq(true)
+ it "returns true when there are no projects but personal is present" do
+ expect(helper.show_projects?(Project.none, personal: "true")).to eq(true)
end
- it 'returns false when there are no projects and there is no name' do
+ it "returns false when there are no projects and there is no name" do
expect(helper.show_projects?(Project.none, {})).to eq(false)
end
end
- describe('#push_to_create_project_command') do
- let(:user) { create(:user, username: 'john') }
+ describe("#push_to_create_project_command") do
+ let(:user) { create(:user, username: "john") }
- it 'returns the command to push to create project over HTTP' do
- allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enabled_git_access_protocol) { 'http' }
+ it "returns the command to push to create project over HTTP" do
+ allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enabled_git_access_protocol) { "http" }
- expect(helper.push_to_create_project_command(user)).to eq('git push --set-upstream http://test.host/john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)')
+ expect(helper.push_to_create_project_command(user)).to eq("git push --set-upstream http://test.host/john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)")
end
- it 'returns the command to push to create project over SSH' do
- allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enabled_git_access_protocol) { 'ssh' }
+ it "returns the command to push to create project over SSH" do
+ allow(Gitlab::CurrentSettings.current_application_settings).to receive(:enabled_git_access_protocol) { "ssh" }
- expect(helper.push_to_create_project_command(user)).to eq('git push --set-upstream git@localhost:john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)')
+ expect(helper.push_to_create_project_command(user)).to eq("git push --set-upstream git@localhost:john/$(git rev-parse --show-toplevel | xargs basename).git $(git rev-parse --abbrev-ref HEAD)")
end
end
- describe '#any_projects?' do
+ describe "#any_projects?" do
let!(:project) { create(:project) }
- it 'returns true when projects will be returned' do
+ it "returns true when projects will be returned" do
expect(helper.any_projects?(Project.all)).to eq(true)
end
- it 'returns false when no projects will be returned' do
+ it "returns false when no projects will be returned" do
expect(helper.any_projects?(Project.none)).to eq(false)
end
- it 'returns true when using a non-empty Array' do
+ it "returns true when using a non-empty Array" do
expect(helper.any_projects?([project])).to eq(true)
end
- it 'returns false when using an empty Array' do
+ it "returns false when using an empty Array" do
expect(helper.any_projects?([])).to eq(false)
end
- it 'only executes a single query when a LIMIT is applied' do
+ it "only executes a single query when a LIMIT is applied" do
relation = Project.limit(1)
- recorder = ActiveRecord::QueryRecorder.new do
+ recorder = ActiveRecord::QueryRecorder.new {
2.times do
helper.any_projects?(relation)
end
- end
+ }
expect(recorder.count).to eq(1)
end
end
- describe '#git_user_name' do
+ describe "#git_user_name" do
let(:user) { double(:user, name: 'John "A" Doe53') }
before do
allow(helper).to receive(:current_user).and_return(user)
end
- it 'parses quotes in name' do
+ it "parses quotes in name" do
expect(helper.send(:git_user_name)).to eq('John \"A\" Doe53')
end
end
- describe 'show_xcode_link' do
+ describe "show_xcode_link" do
let!(:project) { create(:project) }
- let(:mac_ua) { 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36' }
- let(:ios_ua) { 'Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3' }
+ let(:mac_ua) { "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36" }
+ let(:ios_ua) { "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3" }
- context 'when the repository is xcode compatible' do
+ context "when the repository is xcode compatible" do
before do
allow(project.repository).to receive(:xcode_project?).and_return(true)
end
- it 'returns false if the visitor is not using macos' do
+ it "returns false if the visitor is not using macos" do
allow(helper).to receive(:browser).and_return(Browser.new(ios_ua))
expect(helper.show_xcode_link?(project)).to eq(false)
end
- it 'returns true if the visitor is using macos' do
+ it "returns true if the visitor is using macos" do
allow(helper).to receive(:browser).and_return(Browser.new(mac_ua))
expect(helper.show_xcode_link?(project)).to eq(true)
end
end
- context 'when the repository is not xcode compatible' do
+ context "when the repository is not xcode compatible" do
before do
allow(project.repository).to receive(:xcode_project?).and_return(false)
end
- it 'returns false if the visitor is not using macos' do
+ it "returns false if the visitor is not using macos" do
allow(helper).to receive(:browser).and_return(Browser.new(ios_ua))
expect(helper.show_xcode_link?(project)).to eq(false)
end
- it 'returns false if the visitor is using macos' do
+ it "returns false if the visitor is using macos" do
allow(helper).to receive(:browser).and_return(Browser.new(mac_ua))
expect(helper.show_xcode_link?(project)).to eq(false)
@@ -510,10 +510,10 @@ describe ProjectsHelper do
end
end
- describe 'link_to_bfg' do
+ describe "link_to_bfg" do
subject { helper.link_to_bfg }
- it 'generates a hardcoded link to the BFG Repo-Cleaner' do
+ it "generates a hardcoded link to the BFG Repo-Cleaner" do
result = helper.link_to_bfg
doc = Nokogiri::HTML.fragment(result)
@@ -524,18 +524,18 @@ describe ProjectsHelper do
aggregate_failures do
expect(result).to be_html_safe
- expect(link.name).to eq('a')
- expect(link[:target]).to eq('_blank')
- expect(link[:rel]).to eq('noopener noreferrer')
- expect(link[:href]).to eq('https://rtyley.github.io/bfg-repo-cleaner/')
- expect(link.inner_html).to eq('BFG')
+ expect(link.name).to eq("a")
+ expect(link[:target]).to eq("_blank")
+ expect(link[:rel]).to eq("noopener noreferrer")
+ expect(link[:href]).to eq("https://rtyley.github.io/bfg-repo-cleaner/")
+ expect(link.inner_html).to eq("BFG")
expect(result).to be_html_safe
end
end
end
- describe '#explore_projects_tab?' do
+ describe "#explore_projects_tab?" do
subject { helper.explore_projects_tab? }
it 'returns true when on the "All" tab under "Explore projects"' do
@@ -563,89 +563,89 @@ describe ProjectsHelper do
end
end
- describe '#show_merge_request_count' do
- context 'when the feature flag is enabled' do
+ describe "#show_merge_request_count" do
+ context "when the feature flag is enabled" do
before do
stub_feature_flags(project_list_show_mr_count: true)
end
- it 'returns true if compact mode is disabled' do
+ it "returns true if compact mode is disabled" do
expect(helper.show_merge_request_count?).to be_truthy
end
- it 'returns false if compact mode is enabled' do
+ it "returns false if compact mode is enabled" do
expect(helper.show_merge_request_count?(compact_mode: true)).to be_falsey
end
end
- context 'when the feature flag is disabled' do
+ context "when the feature flag is disabled" do
before do
stub_feature_flags(project_list_show_mr_count: false)
end
- it 'always returns false' do
+ it "always returns false" do
expect(helper.show_merge_request_count?(disabled: false)).to be_falsy
expect(helper.show_merge_request_count?(disabled: true)).to be_falsy
end
end
- context 'disabled flag' do
+ context "disabled flag" do
before do
stub_feature_flags(project_list_show_mr_count: true)
end
- it 'returns false if disabled flag is true' do
+ it "returns false if disabled flag is true" do
expect(helper.show_merge_request_count?(disabled: true)).to be_falsey
end
- it 'returns true if disabled flag is false' do
+ it "returns true if disabled flag is false" do
expect(helper.show_merge_request_count?).to be_truthy
end
end
end
- describe '#show_issue_count?' do
- context 'when the feature flag is enabled' do
+ describe "#show_issue_count?" do
+ context "when the feature flag is enabled" do
before do
stub_feature_flags(project_list_show_issue_count: true)
end
- it 'returns true if compact mode is disabled' do
+ it "returns true if compact mode is disabled" do
expect(helper.show_issue_count?).to be_truthy
end
- it 'returns false if compact mode is enabled' do
+ it "returns false if compact mode is enabled" do
expect(helper.show_issue_count?(compact_mode: true)).to be_falsey
end
end
- context 'when the feature flag is disabled' do
+ context "when the feature flag is disabled" do
before do
stub_feature_flags(project_list_show_issue_count: false)
end
- it 'always returns false' do
+ it "always returns false" do
expect(helper.show_issue_count?(disabled: false)).to be_falsy
expect(helper.show_issue_count?(disabled: true)).to be_falsy
end
end
- context 'disabled flag' do
+ context "disabled flag" do
before do
stub_feature_flags(project_list_show_issue_count: true)
end
- it 'returns false if disabled flag is true' do
+ it "returns false if disabled flag is true" do
expect(helper.show_issue_count?(disabled: true)).to be_falsey
end
- it 'returns true if disabled flag is false' do
+ it "returns true if disabled flag is false" do
expect(helper.show_issue_count?).to be_truthy
end
end
end
- describe '#show_auto_devops_implicitly_enabled_banner?' do
+ describe "#show_auto_devops_implicitly_enabled_banner?" do
using RSpec::Parameterized::TableSyntax
let(:user) { create(:user) }
@@ -653,7 +653,7 @@ describe ProjectsHelper do
let(:feature_visibilities) do
{
enabled: ProjectFeature::ENABLED,
- disabled: ProjectFeature::DISABLED
+ disabled: ProjectFeature::DISABLED,
}
end
diff --git a/spec/helpers/rss_helper_spec.rb b/spec/helpers/rss_helper_spec.rb
index a7f9bdf07e4..fa68c8f403b 100644
--- a/spec/helpers/rss_helper_spec.rb
+++ b/spec/helpers/rss_helper_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe RssHelper do
- describe '#rss_url_options' do
- context 'when signed in' do
+ describe "#rss_url_options" do
+ context "when signed in" do
it "includes the current_user's feed_token" do
current_user = create(:user)
allow(helper).to receive(:current_user).and_return(current_user)
@@ -10,7 +10,7 @@ describe RssHelper do
end
end
- context 'when signed out' do
+ context "when signed out" do
it "does not have a feed_token" do
allow(helper).to receive(:current_user).and_return(nil)
expect(helper.rss_url_options[:feed_token]).to be_nil
diff --git a/spec/helpers/runners_helper_spec.rb b/spec/helpers/runners_helper_spec.rb
index bf00841fcb6..45c3ea4303c 100644
--- a/spec/helpers/runners_helper_spec.rb
+++ b/spec/helpers/runners_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RunnersHelper do
it "returns - not contacted yet" do
@@ -16,7 +16,7 @@ describe RunnersHelper do
expect(runner_status_icon(runner)).to include("Runner is online")
end
- describe '#runner_contacted_at' do
+ describe "#runner_contacted_at" do
let(:contacted_at_stored) { 1.hour.ago.change(usec: 0) }
let(:contacted_at_cached) { 1.second.ago.change(usec: 0) }
let(:runner) { create(:ci_runner, contacted_at: contacted_at_stored) }
@@ -25,28 +25,28 @@ describe RunnersHelper do
runner.cache_attributes(contacted_at: contacted_at_cached)
end
- context 'without sorting' do
- it 'returns cached value' do
+ context "without sorting" do
+ it "returns cached value" do
expect(runner_contacted_at(runner)).to eq(contacted_at_cached)
end
end
- context 'with sorting set to created_date' do
+ context "with sorting set to created_date" do
before do
- controller.params[:sort] = 'created_date'
+ controller.params[:sort] = "created_date"
end
- it 'returns cached value' do
+ it "returns cached value" do
expect(runner_contacted_at(runner)).to eq(contacted_at_cached)
end
end
- context 'with sorting set to contacted_asc' do
+ context "with sorting set to contacted_asc" do
before do
- controller.params[:sort] = 'contacted_asc'
+ controller.params[:sort] = "contacted_asc"
end
- it 'returns stored value' do
+ it "returns stored value" do
expect(runner_contacted_at(runner)).to eq(contacted_at_stored)
end
end
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index 9cff0291250..49aa7e1d08b 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SearchHelper do
# Override simple_sanitize for our testing purposes
@@ -6,7 +6,7 @@ describe SearchHelper do
str
end
- describe 'search_autocomplete_source' do
+ describe "search_autocomplete_source" do
context "with no current user" do
before do
allow(self).to receive(:current_user).and_return(nil)
@@ -46,8 +46,8 @@ describe SearchHelper do
end
it "includes nested group" do
- create(:group, :nested, name: 'foo').add_owner(user)
- expect(search_autocomplete_opts('foo').size).to eq(1)
+ create(:group, :nested, name: "foo").add_owner(user)
+ expect(search_autocomplete_opts("foo").size).to eq(1)
end
it "includes the user's projects" do
@@ -86,7 +86,7 @@ describe SearchHelper do
end
end
- context 'with an admin user' do
+ context "with an admin user" do
let(:admin) { create(:admin) }
before do
@@ -99,74 +99,74 @@ describe SearchHelper do
end
end
- describe 'search_filter_input_options' do
- context 'project' do
+ describe "search_filter_input_options" do
+ context "project" do
before do
@project = create(:project, :repository)
end
- it 'includes id with type' do
- expect(search_filter_input_options('type')[:id]).to eq('filtered-search-type')
+ it "includes id with type" do
+ expect(search_filter_input_options("type")[:id]).to eq("filtered-search-type")
end
- it 'includes project-id' do
- expect(search_filter_input_options('')[:data]['project-id']).to eq(@project.id)
+ it "includes project-id" do
+ expect(search_filter_input_options("")[:data]["project-id"]).to eq(@project.id)
end
- it 'includes project base-endpoint' do
- expect(search_filter_input_options('')[:data]['base-endpoint']).to eq(project_path(@project))
+ it "includes project base-endpoint" do
+ expect(search_filter_input_options("")[:data]["base-endpoint"]).to eq(project_path(@project))
end
- it 'includes autocomplete=off flag' do
- expect(search_filter_input_options('')[:autocomplete]).to eq('off')
+ it "includes autocomplete=off flag" do
+ expect(search_filter_input_options("")[:autocomplete]).to eq("off")
end
end
- context 'group' do
+ context "group" do
before do
- @group = create(:group, name: 'group')
+ @group = create(:group, name: "group")
end
- it 'does not includes project-id' do
- expect(search_filter_input_options('')[:data]['project-id']).to eq(nil)
+ it "does not includes project-id" do
+ expect(search_filter_input_options("")[:data]["project-id"]).to eq(nil)
end
- it 'includes group base-endpoint' do
- expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/groups#{group_path(@group)}")
+ it "includes group base-endpoint" do
+ expect(search_filter_input_options("")[:data]["base-endpoint"]).to eq("/groups#{group_path(@group)}")
end
end
- context 'dashboard' do
- it 'does not include group-id and project-id' do
- expect(search_filter_input_options('')[:data]['project-id']).to eq(nil)
- expect(search_filter_input_options('')[:data]['group-id']).to eq(nil)
+ context "dashboard" do
+ it "does not include group-id and project-id" do
+ expect(search_filter_input_options("")[:data]["project-id"]).to eq(nil)
+ expect(search_filter_input_options("")[:data]["group-id"]).to eq(nil)
end
- it 'includes dashboard base-endpoint' do
- expect(search_filter_input_options('')[:data]['base-endpoint']).to eq("/dashboard")
+ it "includes dashboard base-endpoint" do
+ expect(search_filter_input_options("")[:data]["base-endpoint"]).to eq("/dashboard")
end
end
end
- describe 'search_history_storage_prefix' do
- context 'project' do
- it 'returns project full_path' do
+ describe "search_history_storage_prefix" do
+ context "project" do
+ it "returns project full_path" do
@project = create(:project, :repository)
expect(search_history_storage_prefix).to eq(@project.full_path)
end
end
- context 'group' do
- it 'returns group full_path' do
- @group = create(:group, :nested, name: 'group-name')
+ context "group" do
+ it "returns group full_path" do
+ @group = create(:group, :nested, name: "group-name")
expect(search_history_storage_prefix).to eq(@group.full_path)
end
end
- context 'dashboard' do
- it 'returns dashboard' do
+ context "dashboard" do
+ it "returns dashboard" do
expect(search_history_storage_prefix).to eq("dashboard")
end
end
diff --git a/spec/helpers/sidekiq_helper_spec.rb b/spec/helpers/sidekiq_helper_spec.rb
index 117abc9c556..141c4b5350c 100644
--- a/spec/helpers/sidekiq_helper_spec.rb
+++ b/spec/helpers/sidekiq_helper_spec.rb
@@ -1,71 +1,71 @@
-require 'spec_helper'
+require "spec_helper"
describe SidekiqHelper do
- describe 'parse_sidekiq_ps' do
- it 'parses line with time' do
- line = '55137 10,0 2,1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
+ describe "parse_sidekiq_ps" do
+ it "parses line with time" do
+ line = "55137\t10,0\t2,1\tS+\t2:30pm\tsidekiq 4.1.4 gitlab [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["55137", "10,0", "2,1", "S+", "2:30pm", "sidekiq 4.1.4 gitlab [0 of 25 busy]"])
end
- it 'parses line with date' do
- line = '55137 10,0 2,1 S+ Aug 4 sidekiq 4.1.4 gitlab [0 of 25 busy] '
+ it "parses line with date" do
+ line = "55137\t10,0\t2,1\tS+\tAug 4\tsidekiq 4.1.4 gitlab [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 4', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["55137", "10,0", "2,1", "S+", "Aug 4", "sidekiq 4.1.4 gitlab [0 of 25 busy]"])
end
- it 'parses line with two digit date' do
- line = '55137 10,0 2,1 S+ Aug 04 sidekiq 4.1.4 gitlab [0 of 25 busy] '
+ it "parses line with two digit date" do
+ line = "55137\t10,0\t2,1\tS+\tAug 04\tsidekiq 4.1.4 gitlab [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['55137', '10,0', '2,1', 'S+', 'Aug 04', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["55137", "10,0", "2,1", "S+", "Aug 04", "sidekiq 4.1.4 gitlab [0 of 25 busy]"])
end
- it 'parses line with dot as float separator' do
- line = '55137 10.0 2.1 S+ 2:30pm sidekiq 4.1.4 gitlab [0 of 25 busy] '
+ it "parses line with dot as float separator" do
+ line = "55137\t10.0\t2.1\tS+\t2:30pm\tsidekiq 4.1.4 gitlab [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['55137', '10.0', '2.1', 'S+', '2:30pm', 'sidekiq 4.1.4 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["55137", "10.0", "2.1", "S+", "2:30pm", "sidekiq 4.1.4 gitlab [0 of 25 busy]"])
end
- it 'parses OSX output' do
- line = ' 1641 1.5 3.8 S+ 4:04PM sidekiq 4.2.1 gitlab [0 of 25 busy]'
+ it "parses OSX output" do
+ line = " 1641 1.5 3.8 S+ 4:04PM sidekiq 4.2.1 gitlab [0 of 25 busy]"
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['1641', '1.5', '3.8', 'S+', '4:04PM', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["1641", "1.5", "3.8", "S+", "4:04PM", "sidekiq 4.2.1 gitlab [0 of 25 busy]"])
end
- it 'parses Ubuntu output' do
+ it "parses Ubuntu output" do
# Ubuntu Linux 16.04 LTS / procps-3.3.10-4ubuntu2
- line = ' 938 1.4 2.5 Sl+ 21:23:21 sidekiq 4.2.1 gitlab [0 of 25 busy] '
+ line = " 938 1.4 2.5 Sl+ 21:23:21 sidekiq 4.2.1 gitlab [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['938', '1.4', '2.5', 'Sl+', '21:23:21', 'sidekiq 4.2.1 gitlab [0 of 25 busy]'])
+ expect(parts).to eq(["938", "1.4", "2.5", "Sl+", "21:23:21", "sidekiq 4.2.1 gitlab [0 of 25 busy]"])
end
- it 'parses Debian output' do
+ it "parses Debian output" do
# Debian Linux Wheezy/Jessie
- line = '17725 1.0 12.1 Ssl 19:20:15 sidekiq 4.2.1 gitlab-rails [0 of 25 busy] '
+ line = "17725 1.0 12.1 Ssl 19:20:15 sidekiq 4.2.1 gitlab-rails [0 of 25 busy] "
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['17725', '1.0', '12.1', 'Ssl', '19:20:15', 'sidekiq 4.2.1 gitlab-rails [0 of 25 busy]'])
+ expect(parts).to eq(["17725", "1.0", "12.1", "Ssl", "19:20:15", "sidekiq 4.2.1 gitlab-rails [0 of 25 busy]"])
end
- it 'parses OpenBSD output' do
+ it "parses OpenBSD output" do
# OpenBSD 6.1
- line = '49258 0.5 2.3 R/0 Fri10PM ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'
+ line = "49258 0.5 2.3 R/0 Fri10PM ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)"
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['49258', '0.5', '2.3', 'R/0', 'Fri10PM', 'ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)'])
+ expect(parts).to eq(["49258", "0.5", "2.3", "R/0", "Fri10PM", "ruby23: sidekiq 4.2.7 gitlab [0 of 25 busy] (ruby23)"])
end
- it 'does fail gracefully on line not matching the format' do
- line = '55137 10.0 2.1 S+ 2:30pm something'
+ it "does fail gracefully on line not matching the format" do
+ line = "55137\t10.0\t2.1\tS+\t2:30pm\tsomething"
parts = helper.parse_sidekiq_ps(line)
- expect(parts).to eq(['?', '?', '?', '?', '?', '?'])
+ expect(parts).to eq(["?", "?", "?", "?", "?", "?"])
end
end
end
diff --git a/spec/helpers/snippets_helper_spec.rb b/spec/helpers/snippets_helper_spec.rb
index ce5e037f88d..1051d001ff0 100644
--- a/spec/helpers/snippets_helper_spec.rb
+++ b/spec/helpers/snippets_helper_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe SnippetsHelper do
include IconsHelper
- describe '#embedded_snippet_raw_button' do
- it 'gives view raw button of embedded snippets for project snippets' do
+ describe "#embedded_snippet_raw_button" do
+ it "gives view raw button of embedded snippets for project snippets" do
@snippet = create(:project_snippet, :public)
- expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet)}\">#{external_snippet_icon('doc-code')}</a>")
+ expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet)}\">#{external_snippet_icon("doc-code")}</a>")
end
- it 'gives view raw button of embedded snippets for personal snippets' do
+ it "gives view raw button of embedded snippets for personal snippets" do
@snippet = create(:personal_snippet, :public)
- expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_snippet_url(@snippet)}\">#{external_snippet_icon('doc-code')}</a>")
+ expect(embedded_snippet_raw_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" rel=\"noopener noreferrer\" title=\"Open raw\" href=\"#{raw_snippet_url(@snippet)}\">#{external_snippet_icon("doc-code")}</a>")
end
end
- describe '#embedded_snippet_download_button' do
- it 'gives download button of embedded snippets for project snippets' do
+ describe "#embedded_snippet_download_button" do
+ it "gives download button of embedded snippets for project snippets" do
@snippet = create(:project_snippet, :public)
- expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet, inline: false)}\">#{external_snippet_icon('download')}</a>")
+ expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_project_snippet_url(@snippet.project, @snippet, inline: false)}\">#{external_snippet_icon("download")}</a>")
end
- it 'gives download button of embedded snippets for personal snippets' do
+ it "gives download button of embedded snippets for personal snippets" do
@snippet = create(:personal_snippet, :public)
- expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_snippet_url(@snippet, inline: false)}\">#{external_snippet_icon('download')}</a>")
+ expect(embedded_snippet_download_button.to_s).to eq("<a class=\"btn\" target=\"_blank\" title=\"Download\" rel=\"noopener noreferrer\" href=\"#{raw_snippet_url(@snippet, inline: false)}\">#{external_snippet_icon("download")}</a>")
end
end
end
diff --git a/spec/helpers/sorting_helper_spec.rb b/spec/helpers/sorting_helper_spec.rb
index f405268d198..27c83c9cb3b 100644
--- a/spec/helpers/sorting_helper_spec.rb
+++ b/spec/helpers/sorting_helper_spec.rb
@@ -1,47 +1,48 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe SortingHelper do
include ApplicationHelper
include IconsHelper
- describe '#issuable_sort_option_title' do
- it 'returns correct title for issuable_sort_option_overrides key' do
- expect(issuable_sort_option_title('created_asc')).to eq('Created date')
+ describe "#issuable_sort_option_title" do
+ it "returns correct title for issuable_sort_option_overrides key" do
+ expect(issuable_sort_option_title("created_asc")).to eq("Created date")
end
- it 'returns correct title for a valid sort value' do
- expect(issuable_sort_option_title('priority')).to eq('Priority')
+ it "returns correct title for a valid sort value" do
+ expect(issuable_sort_option_title("priority")).to eq("Priority")
end
- it 'returns nil for invalid sort value' do
- expect(issuable_sort_option_title('invalid_key')).to eq(nil)
+ it "returns nil for invalid sort value" do
+ expect(issuable_sort_option_title("invalid_key")).to eq(nil)
end
end
- describe '#issuable_sort_direction_button' do
+ describe "#issuable_sort_direction_button" do
before do
- allow(self).to receive(:request).and_return(double(path: 'http://test.com', query_parameters: { label_name: 'test_label' }))
+ allow(self).to receive(:request).and_return(double(path: "http://test.com", query_parameters: {label_name: "test_label"}))
end
- it 'keeps label filter param' do
- expect(issuable_sort_direction_button('created_date')).to include('label_name=test_label')
+ it "keeps label filter param" do
+ expect(issuable_sort_direction_button("created_date")).to include("label_name=test_label")
end
- it 'returns icon with sort-highest when sort is created_date' do
- expect(issuable_sort_direction_button('created_date')).to include('sort-highest')
+ it "returns icon with sort-highest when sort is created_date" do
+ expect(issuable_sort_direction_button("created_date")).to include("sort-highest")
end
- it 'returns icon with sort-lowest when sort is asc' do
- expect(issuable_sort_direction_button('created_asc')).to include('sort-lowest')
+ it "returns icon with sort-lowest when sort is asc" do
+ expect(issuable_sort_direction_button("created_asc")).to include("sort-lowest")
end
- it 'returns icon with sort-lowest when sorting by milestone' do
- expect(issuable_sort_direction_button('milestone')).to include('sort-lowest')
+ it "returns icon with sort-lowest when sorting by milestone" do
+ expect(issuable_sort_direction_button("milestone")).to include("sort-lowest")
end
- it 'returns icon with sort-lowest when sorting by due_date' do
- expect(issuable_sort_direction_button('due_date')).to include('sort-lowest')
+ it "returns icon with sort-lowest when sorting by due_date" do
+ expect(issuable_sort_direction_button("due_date")).to include("sort-lowest")
end
end
end
diff --git a/spec/helpers/submodule_helper_spec.rb b/spec/helpers/submodule_helper_spec.rb
index ea48c69e0ae..c0acd7411d4 100644
--- a/spec/helpers/submodule_helper_spec.rb
+++ b/spec/helpers/submodule_helper_spec.rb
@@ -1,167 +1,167 @@
-require 'spec_helper'
+require "spec_helper"
describe SubmoduleHelper do
include RepoHelpers
- describe 'submodule links' do
- let(:submodule_item) { double(id: 'hash', path: 'rack') }
+ describe "submodule links" do
+ let(:submodule_item) { double(id: "hash", path: "rack") }
let(:config) { Gitlab.config.gitlab }
let(:repo) { double }
before do
- self.instance_variable_set(:@repository, repo)
+ instance_variable_set(:@repository, repo)
end
- context 'submodule on self' do
+ context "submodule on self" do
before do
- allow(Gitlab.config.gitlab).to receive(:protocol).and_return('http') # set this just to be sure
+ allow(Gitlab.config.gitlab).to receive(:protocol).and_return("http") # set this just to be sure
end
- it 'detects 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')])
+ 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 'detects 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')])
+ 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 'detects 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')])
+ 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 'detects 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')])
+ 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 'works 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(:relative_url_root).and_return("/gitlab/root")
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
- stub_url(['http://', config.host, '/gitlab/root/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')])
+ stub_url(["http://", config.host, "/gitlab/root/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 'works with subgroups' do
+ it "works with subgroups" 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(:relative_url_root).and_return("/gitlab/root")
allow(Gitlab.config.gitlab).to receive(:url).and_return(Settings.send(:build_gitlab_url))
- stub_url(['http://', config.host, '/gitlab/root/gitlab-org/sub/gitlab-ce.git'].join(''))
- expect(submodule_links(submodule_item)).to eq([namespace_project_path('gitlab-org/sub', 'gitlab-ce'), namespace_project_tree_path('gitlab-org/sub', 'gitlab-ce', 'hash')])
+ stub_url(["http://", config.host, "/gitlab/root/gitlab-org/sub/gitlab-ce.git"].join(""))
+ expect(submodule_links(submodule_item)).to eq([namespace_project_path("gitlab-org/sub", "gitlab-ce"), namespace_project_tree_path("gitlab-org/sub", "gitlab-ce", "hash")])
end
end
- context 'submodule on github.com' 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'])
+ context "submodule on github.com" 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 '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'])
+ 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 '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'])
+ 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 'handles urls with no .git on the end' do
- stub_url('http://github.com/gitlab-org/gitlab-ce')
- expect(submodule_links(submodule_item)).to eq(['https://github.com/gitlab-org/gitlab-ce', 'https://github.com/gitlab-org/gitlab-ce/tree/hash'])
+ it "handles urls with no .git on the end" do
+ stub_url("http://github.com/gitlab-org/gitlab-ce")
+ 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 'returns original with non-standard url' do
- stub_url('http://github.com/another/gitlab-org/gitlab-ce.git')
+ it "returns original with non-standard url" do
+ stub_url("http://github.com/another/gitlab-org/gitlab-ce.git")
expect(submodule_links(submodule_item)).to eq([repo.submodule_url_for, nil])
end
end
- context 'in-repository submodule' do
+ context "in-repository submodule" do
let(:group) { create(:group, name: "Master Project", path: "master-project") }
let(:project) { create(:project, group: group) }
- it 'in-repository' do
+ it "in-repository" do
allow(repo).to receive(:project).and_return(project)
- stub_url('./')
+ stub_url("./")
expect(submodule_links(submodule_item)).to eq(["/master-project/#{project.path}", "/master-project/#{project.path}/tree/hash"])
end
end
- context 'submodule on gitlab.com' do
- it 'detects ssh' do
- stub_url('git@gitlab.com:gitlab-org/gitlab-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'])
+ context "submodule on gitlab.com" 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 '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'])
+ 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 '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'])
+ 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 'handles urls with no .git on the end' do
- stub_url('http://gitlab.com/gitlab-org/gitlab-ce')
- expect(submodule_links(submodule_item)).to eq(['https://gitlab.com/gitlab-org/gitlab-ce', 'https://gitlab.com/gitlab-org/gitlab-ce/tree/hash'])
+ it "handles urls with no .git on the end" do
+ stub_url("http://gitlab.com/gitlab-org/gitlab-ce")
+ 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 'handles urls with trailing whitespace' 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'])
+ it "handles urls with trailing whitespace" 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 'returns original with non-standard url' do
- stub_url('http://gitlab.com/another/gitlab-org/gitlab-ce.git')
+ it "returns original with non-standard url" do
+ stub_url("http://gitlab.com/another/gitlab-org/gitlab-ce.git")
expect(submodule_links(submodule_item)).to eq([repo.submodule_url_for, nil])
end
end
- context 'submodule on unsupported' do
- it 'sanitizes unsupported protocols' do
+ context "submodule on unsupported" do
+ it "sanitizes unsupported protocols" do
stub_url('javascript:alert("XSS");')
expect(helper.submodule_links(submodule_item)).to eq([nil, nil])
end
- it 'sanitizes unsupported protocols disguised as a repository URL' do
+ it "sanitizes unsupported protocols disguised as a repository URL" do
stub_url('javascript:alert("XSS");foo/bar.git')
expect(helper.submodule_links(submodule_item)).to eq([nil, nil])
end
- it 'sanitizes invalid URL with extended ASCII' do
- stub_url('é')
+ it "sanitizes invalid URL with extended ASCII" do
+ stub_url("é")
expect(helper.submodule_links(submodule_item)).to eq([nil, nil])
end
- it 'returns original' do
- stub_url('http://mygitserver.com/gitlab-org/gitlab-ce')
+ 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])
- stub_url('http://mygitserver.com/gitlab-org/gitlab-ce.git')
+ stub_url("http://mygitserver.com/gitlab-org/gitlab-ce.git")
expect(submodule_links(submodule_item)).to eq([repo.submodule_url_for, nil])
end
end
- context 'submodules with relative links' do
+ context "submodules with relative links" do
let(:group) { create(:group, name: "top group", path: "top-group") }
let(:project) { create(:project, group: group) }
let(:repo) { double(:repo, project: project) }
@@ -174,21 +174,21 @@ describe SubmoduleHelper do
expect(result).to eq([expected_path, "#{expected_path}/tree/#{submodule_item.id}"])
end
- it 'handles project under same group' do
- expect_relative_link_to_resolve_to('../test.git', "/#{group.path}/test")
+ it "handles project under same group" do
+ expect_relative_link_to_resolve_to("../test.git", "/#{group.path}/test")
end
- it 'handles trailing whitespace' do
- expect_relative_link_to_resolve_to('../test.git ', "/#{group.path}/test")
+ it "handles trailing whitespace" do
+ expect_relative_link_to_resolve_to("../test.git ", "/#{group.path}/test")
end
- it 'handles project under another top group' do
- expect_relative_link_to_resolve_to('../../baz/test.git ', "/baz/test")
+ it "handles project under another top group" do
+ expect_relative_link_to_resolve_to("../../baz/test.git ", "/baz/test")
end
- context 'repo path resolves to be located at root (namespace absent)' do
- it 'returns nil' do
- allow(repo).to receive(:submodule_url_for).and_return('../../test.git')
+ context "repo path resolves to be located at root (namespace absent)" do
+ it "returns nil" do
+ allow(repo).to receive(:submodule_url_for).and_return("../../test.git")
result = submodule_links(submodule_item)
@@ -196,9 +196,9 @@ describe SubmoduleHelper do
end
end
- context 'repo path resolves to be located underneath current project path' do
- it 'returns nil because it is not possible to have repo nested under another repo' do
- allow(repo).to receive(:submodule_url_for).and_return('./test.git')
+ context "repo path resolves to be located underneath current project path" do
+ it "returns nil because it is not possible to have repo nested under another repo" do
+ allow(repo).to receive(:submodule_url_for).and_return("./test.git")
result = submodule_links(submodule_item)
@@ -206,33 +206,33 @@ describe SubmoduleHelper do
end
end
- context 'subgroup' do
+ context "subgroup" do
let(:sub_group) { create(:group, parent: group, name: "sub group", path: "sub-group") }
let(:sub_project) { create(:project, group: sub_group) }
- context 'project in sub group' do
+ context "project in sub group" do
let(:project) { sub_project }
it "handles referencing ancestor group's project" do
- expect_relative_link_to_resolve_to('../../../top-group/test.git', "/#{group.path}/test")
+ expect_relative_link_to_resolve_to("../../../top-group/test.git", "/#{group.path}/test")
end
end
it "handles referencing descendent group's project" do
- expect_relative_link_to_resolve_to('../sub-group/test.git', "/top-group/sub-group/test")
+ expect_relative_link_to_resolve_to("../sub-group/test.git", "/top-group/sub-group/test")
end
it "handles referencing another top group's project" do
- expect_relative_link_to_resolve_to('../../frontend/css/test.git', "/frontend/css/test")
+ expect_relative_link_to_resolve_to("../../frontend/css/test.git", "/frontend/css/test")
end
end
- context 'personal project' do
+ context "personal project" do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
- it 'handles referencing another personal project' do
- expect_relative_link_to_resolve_to('../test.git', "/#{user.username}/test")
+ it "handles referencing another personal project" do
+ expect_relative_link_to_resolve_to("../test.git", "/#{user.username}/test")
end
end
end
diff --git a/spec/helpers/tab_helper_spec.rb b/spec/helpers/tab_helper_spec.rb
index 9abf63d4bd4..c33c51dcd6e 100644
--- a/spec/helpers/tab_helper_spec.rb
+++ b/spec/helpers/tab_helper_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe TabHelper do
include ApplicationHelper
- describe 'nav_link' do
+ describe "nav_link" do
before do
- allow(controller).to receive(:controller_name).and_return('foo')
- allow(self).to receive(:action_name).and_return('foo')
+ allow(controller).to receive(:controller_name).and_return("foo")
+ allow(self).to receive(:action_name).and_return("foo")
end
- context 'with the content of the li' do
+ context "with the content of the li" do
it "captures block output" do
expect(nav_link { "Testing Blocks" }).to match(/Testing Blocks/)
end
end
- context 'with controller param' do
+ context "with controller param" do
it "performs checks on the current controller" do
expect(nav_link(controller: :foo)).to match(/<li class="active">/)
expect(nav_link(controller: :bar)).not_to match(/active/)
expect(nav_link(controller: [:foo, :bar])).to match(/active/)
end
- context 'with action param' do
+ context "with action param" do
it "performs checks on both controller and action when both are present" do
expect(nav_link(controller: :bar, action: :foo)).not_to match(/active/)
expect(nav_link(controller: :foo, action: :bar)).not_to match(/active/)
@@ -30,27 +30,27 @@ describe TabHelper do
end
end
- context 'with namespace in path notation' do
+ context "with namespace in path notation" do
before do
- allow(controller).to receive(:controller_path).and_return('bar/foo')
+ allow(controller).to receive(:controller_path).and_return("bar/foo")
end
- it 'performs checks on both controller and namespace' do
- expect(nav_link(controller: 'foo/foo')).not_to match(/active/)
- expect(nav_link(controller: 'bar/foo')).to match(/active/)
+ it "performs checks on both controller and namespace" do
+ expect(nav_link(controller: "foo/foo")).not_to match(/active/)
+ expect(nav_link(controller: "bar/foo")).to match(/active/)
end
- context 'with action param' do
+ context "with action param" do
it "performs checks on both namespace, controller and action when they are all present" do
- expect(nav_link(controller: 'foo/foo', action: :foo)).not_to match(/active/)
- expect(nav_link(controller: 'bar/foo', action: :bar)).not_to match(/active/)
- expect(nav_link(controller: 'bar/foo', action: :foo)).to match(/active/)
+ expect(nav_link(controller: "foo/foo", action: :foo)).not_to match(/active/)
+ expect(nav_link(controller: "bar/foo", action: :bar)).not_to match(/active/)
+ expect(nav_link(controller: "bar/foo", action: :foo)).to match(/active/)
end
end
end
end
- context 'with action param' do
+ context "with action param" do
it "performs checks on the current action" do
expect(nav_link(action: :foo)).to match(/<li class="active">/)
expect(nav_link(action: :bar)).not_to match(/active/)
@@ -58,27 +58,27 @@ describe TabHelper do
end
end
- context 'with path param' do
+ context "with path param" do
it "accepts a path shorthand" do
- expect(nav_link(path: 'foo#bar')).not_to match(/active/)
- expect(nav_link(path: 'foo#foo')).to match(/active/)
+ expect(nav_link(path: "foo#bar")).not_to match(/active/)
+ expect(nav_link(path: "foo#foo")).to match(/active/)
end
- context 'with namespace' do
+ context "with namespace" do
before do
- allow(controller).to receive(:controller_path).and_return('bar/foo')
+ allow(controller).to receive(:controller_path).and_return("bar/foo")
end
- it 'accepts a path shorthand with namespace' do
- expect(nav_link(path: 'bar/foo#foo')).to match(/active/)
- expect(nav_link(path: 'foo/foo#foo')).not_to match(/active/)
+ it "accepts a path shorthand with namespace" do
+ expect(nav_link(path: "bar/foo#foo")).to match(/active/)
+ expect(nav_link(path: "foo/foo#foo")).not_to match(/active/)
end
end
end
it "passes extra html options to the list element" do
- expect(nav_link(action: :foo, html_options: { class: 'home' })).to match(/<li class="home active">/)
- expect(nav_link(html_options: { class: 'active' })).to match(/<li class="active">/)
+ expect(nav_link(action: :foo, html_options: {class: "home"})).to match(/<li class="home active">/)
+ expect(nav_link(html_options: {class: "active"})).to match(/<li class="active">/)
end
end
end
diff --git a/spec/helpers/time_helper_spec.rb b/spec/helpers/time_helper_spec.rb
index 8bf378549fe..af1e7476532 100644
--- a/spec/helpers/time_helper_spec.rb
+++ b/spec/helpers/time_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TimeHelper do
describe "#time_interval_in_words" do
@@ -10,7 +10,7 @@ describe TimeHelper do
120 => "2 minutes",
121 => "2 minutes and 1 second",
3721 => "62 minutes and 1 second",
- 0 => "0 seconds"
+ 0 => "0 seconds",
}
intervals_in_words.each do |interval, expectation|
diff --git a/spec/helpers/todos_helper_spec.rb b/spec/helpers/todos_helper_spec.rb
index 63806ef91f3..0a6e7af2d91 100644
--- a/spec/helpers/todos_helper_spec.rb
+++ b/spec/helpers/todos_helper_spec.rb
@@ -1,33 +1,33 @@
require "spec_helper"
describe TodosHelper do
- describe '#todos_count_format' do
- it 'shows fuzzy count for 100 or more items' do
- expect(helper.todos_count_format(100)).to eq '99+'
- expect(helper.todos_count_format(1000)).to eq '99+'
+ describe "#todos_count_format" do
+ it "shows fuzzy count for 100 or more items" do
+ expect(helper.todos_count_format(100)).to eq "99+"
+ expect(helper.todos_count_format(1000)).to eq "99+"
end
- it 'shows exact count for 99 or fewer items' do
- expect(helper.todos_count_format(99)).to eq '99'
- expect(helper.todos_count_format(50)).to eq '50'
- expect(helper.todos_count_format(1)).to eq '1'
+ it "shows exact count for 99 or fewer items" do
+ expect(helper.todos_count_format(99)).to eq "99"
+ expect(helper.todos_count_format(50)).to eq "50"
+ expect(helper.todos_count_format(1)).to eq "1"
end
end
- describe '#todo_projects_options' do
+ describe "#todo_projects_options" do
let(:projects) { create_list(:project, 3) }
let(:user) { create(:user) }
- it 'returns users authorised projects in json format' do
+ it "returns users authorised projects in json format" do
projects.first.add_developer(user)
projects.second.add_developer(user)
allow(helper).to receive(:current_user).and_return(user)
expected_results = [
- { 'id' => '', 'text' => 'Any Project' },
- { 'id' => projects.second.id, 'text' => projects.second.full_name },
- { 'id' => projects.first.id, 'text' => projects.first.full_name }
+ {"id" => "", "text" => "Any Project"},
+ {"id" => projects.second.id, "text" => projects.second.full_name},
+ {"id" => projects.first.id, "text" => projects.first.full_name},
]
expect(JSON.parse(helper.todo_projects_options)).to match_array(expected_results)
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
index 4a62e696cd9..7d1d6b3c895 100644
--- a/spec/helpers/tree_helper_spec.rb
+++ b/spec/helpers/tree_helper_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe TreeHelper do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- let(:sha) { 'c1c67abbaf91f624347bb3ae96eabe3a1b742478' }
+ let(:sha) { "c1c67abbaf91f624347bb3ae96eabe3a1b742478" }
def create_file(filename)
project.repository.create_file(
project.creator,
filename,
- 'test this',
+ "test this",
message: "Automatically created file #{filename}",
- branch_name: 'master'
+ branch_name: "master"
)
end
- describe '.render_tree' do
+ describe ".render_tree" do
before do
@id = sha
@path = ""
@@ -23,131 +23,131 @@ describe TreeHelper do
@lfs_blob_ids = []
end
- it 'displays all entries without a warning' do
- tree = repository.tree(sha, 'files')
+ it "displays all entries without a warning" do
+ tree = repository.tree(sha, "files")
html = render_tree(tree)
- expect(html).not_to have_selector('.tree-truncated-warning')
+ expect(html).not_to have_selector(".tree-truncated-warning")
end
- it 'truncates entries and adds a warning' do
- stub_const('TreeHelper::FILE_LIMIT', 1)
- tree = repository.tree(sha, 'files')
+ it "truncates entries and adds a warning" do
+ stub_const("TreeHelper::FILE_LIMIT", 1)
+ tree = repository.tree(sha, "files")
html = render_tree(tree)
- expect(html).to have_selector('.tree-truncated-warning', count: 1)
- expect(html).to have_selector('.tree-item-file-name', count: 1)
+ expect(html).to have_selector(".tree-truncated-warning", count: 1)
+ expect(html).to have_selector(".tree-item-file-name", count: 1)
end
end
- describe '.fast_project_blob_path' do
- it 'generates the same path as project_blob_path' do
- blob_path = repository.tree(sha, 'with space').entries.first.path
+ describe ".fast_project_blob_path" do
+ it "generates the same path as project_blob_path" do
+ blob_path = repository.tree(sha, "with space").entries.first.path
fast_path = fast_project_blob_path(project, blob_path)
std_path = project_blob_path(project, blob_path)
expect(fast_path).to eq(std_path)
end
- it 'generates the same path with encoded file names' do
- tree = repository.tree(sha, 'encoding')
- blob_path = tree.entries.find { |entry| entry.path == 'encoding/テスト.txt' }.path
+ it "generates the same path with encoded file names" do
+ tree = repository.tree(sha, "encoding")
+ blob_path = tree.entries.find { |entry| entry.path == "encoding/テスト.txt" }.path
fast_path = fast_project_blob_path(project, blob_path)
std_path = project_blob_path(project, blob_path)
expect(fast_path).to eq(std_path)
end
- it 'respects a configured relative URL' do
- allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root')
- blob_path = repository.tree(sha, '').entries.first.path
+ it "respects a configured relative URL" do
+ allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return("/gitlab/root")
+ blob_path = repository.tree(sha, "").entries.first.path
fast_path = fast_project_blob_path(project, blob_path)
- expect(fast_path).to start_with('/gitlab/root')
+ expect(fast_path).to start_with("/gitlab/root")
end
- it 'encodes files starting with #' do
- filename = '#test-file'
+ it "encodes files starting with #" do
+ filename = "#test-file"
create_file(filename)
fast_path = fast_project_blob_path(project, filename)
- expect(fast_path).to end_with('%23test-file')
+ expect(fast_path).to end_with("%23test-file")
end
end
- describe '.fast_project_tree_path' do
- let(:tree_path) { repository.tree(sha, 'with space').path }
+ describe ".fast_project_tree_path" do
+ let(:tree_path) { repository.tree(sha, "with space").path }
let(:fast_path) { fast_project_tree_path(project, tree_path) }
let(:std_path) { project_tree_path(project, tree_path) }
- it 'generates the same path as project_tree_path' do
+ it "generates the same path as project_tree_path" do
expect(fast_path).to eq(std_path)
end
- it 'respects a configured relative URL' do
- allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return('/gitlab/root')
+ it "respects a configured relative URL" do
+ allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return("/gitlab/root")
- expect(fast_path).to start_with('/gitlab/root')
+ expect(fast_path).to start_with("/gitlab/root")
end
- it 'encodes files starting with #' do
- filename = '#test-file'
+ it "encodes files starting with #" do
+ filename = "#test-file"
create_file(filename)
fast_path = fast_project_tree_path(project, filename)
- expect(fast_path).to end_with('%23test-file')
+ expect(fast_path).to end_with("%23test-file")
end
end
- describe 'flatten_tree' do
- let(:tree) { repository.tree(sha, 'files') }
- let(:root_path) { 'files' }
+ describe "flatten_tree" do
+ let(:tree) { repository.tree(sha, "files") }
+ let(:root_path) { "files" }
let(:tree_item) { tree.entries.find { |entry| entry.path == path } }
subject { flatten_tree(root_path, tree_item) }
context "on a directory containing more than one file/directory" do
- let(:path) { 'files/html' }
+ let(:path) { "files/html" }
it "returns the directory name" do
- expect(subject).to match('html')
+ expect(subject).to match("html")
end
end
context "on a directory containing only one directory" do
- let(:path) { 'files/flat' }
+ let(:path) { "files/flat" }
it "returns the flattened path" do
- expect(subject).to match('flat/path/correct')
+ expect(subject).to match("flat/path/correct")
end
context "with a nested root path" do
- let(:root_path) { 'files/flat' }
+ let(:root_path) { "files/flat" }
it "returns the flattened path with the root path suffix removed" do
- expect(subject).to match('path/correct')
+ expect(subject).to match("path/correct")
end
end
end
- context 'when the root path contains a plus character' do
- let(:root_path) { 'gtk/C++' }
- let(:tree_item) { double(flat_path: 'gtk/C++/glade') }
+ context "when the root path contains a plus character" do
+ let(:root_path) { "gtk/C++" }
+ let(:tree_item) { double(flat_path: "gtk/C++/glade") }
- it 'returns the flattened path' do
- expect(subject).to eq('glade')
+ it "returns the flattened path" do
+ expect(subject).to eq("glade")
end
end
end
- describe '#commit_in_single_accessible_branch' do
- it 'escapes HTML from the branch name' do
+ describe "#commit_in_single_accessible_branch" do
+ it "escapes HTML from the branch name" do
helper.instance_variable_set(:@branch_name, "<script>alert('escape me!');</script>")
- escaped_branch_name = '&lt;script&gt;alert(&#39;escape me!&#39;);&lt;/script&gt;'
+ escaped_branch_name = "&lt;script&gt;alert(&#39;escape me!&#39;);&lt;/script&gt;"
expect(helper.commit_in_single_accessible_branch).to include(escaped_branch_name)
end
diff --git a/spec/helpers/user_callouts_helper_spec.rb b/spec/helpers/user_callouts_helper_spec.rb
index 8fa479a4474..f24005ed7af 100644
--- a/spec/helpers/user_callouts_helper_spec.rb
+++ b/spec/helpers/user_callouts_helper_spec.rb
@@ -7,18 +7,18 @@ describe UserCalloutsHelper do
allow(helper).to receive(:current_user).and_return(user)
end
- describe '.show_gke_cluster_integration_callout?' do
+ describe ".show_gke_cluster_integration_callout?" do
let(:project) { create(:project) }
subject { helper.show_gke_cluster_integration_callout?(project) }
- context 'when user can create a cluster' do
+ context "when user can create a cluster" do
before do
allow(helper).to receive(:can?).with(anything, :create_cluster, anything)
.and_return(true)
end
- context 'when user has not dismissed' do
+ context "when user has not dismissed" do
before do
allow(helper).to receive(:user_dismissed?).and_return(false)
end
@@ -26,7 +26,7 @@ describe UserCalloutsHelper do
it { is_expected.to be true }
end
- context 'when user dismissed' do
+ context "when user dismissed" do
before do
allow(helper).to receive(:user_dismissed?).and_return(true)
end
@@ -35,7 +35,7 @@ describe UserCalloutsHelper do
end
end
- context 'when user can not create a cluster' do
+ context "when user can not create a cluster" do
before do
allow(helper).to receive(:can?).with(anything, :create_cluster, anything)
.and_return(false)
@@ -45,12 +45,12 @@ describe UserCalloutsHelper do
end
end
- describe '.render_flash_user_callout' do
- it 'renders the flash_user_callout partial' do
+ describe ".render_flash_user_callout" do
+ it "renders the flash_user_callout partial" do
expect(helper).to receive(:render)
- .with(/flash_user_callout/, flash_type: :warning, message: 'foo', feature_name: 'bar')
+ .with(/flash_user_callout/, flash_type: :warning, message: "foo", feature_name: "bar")
- helper.render_flash_user_callout(:warning, 'foo', 'bar')
+ helper.render_flash_user_callout(:warning, "foo", "bar")
end
end
end
diff --git a/spec/helpers/users_helper_spec.rb b/spec/helpers/users_helper_spec.rb
index f3649495493..201ce20d5c1 100644
--- a/spec/helpers/users_helper_spec.rb
+++ b/spec/helpers/users_helper_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
describe UsersHelper do
include TermsHelper
let(:user) { create(:user) }
- describe '#user_link' do
+ describe "#user_link" do
subject { helper.user_link(user) }
it "links to the user's profile" do
@@ -17,7 +17,7 @@ describe UsersHelper do
end
end
- describe '#profile_tabs' do
+ describe "#profile_tabs" do
subject(:tabs) { helper.profile_tabs }
before do
@@ -25,33 +25,33 @@ describe UsersHelper do
allow(helper).to receive(:can?).and_return(true)
end
- context 'with public profile' do
- it 'includes all the expected tabs' do
+ context "with public profile" do
+ it "includes all the expected tabs" do
expect(tabs).to include(:activity, :groups, :contributed, :projects, :snippets)
end
end
- context 'with private profile' do
+ context "with private profile" do
before do
allow(helper).to receive(:can?).with(user, :read_user_profile, nil).and_return(false)
end
- it 'is empty' do
+ it "is empty" do
expect(tabs).to be_empty
end
end
end
- describe '#user_internal_regex_data' do
+ describe "#user_internal_regex_data" do
using RSpec::Parameterized::TableSyntax
where(:user_default_external, :user_default_internal_regex, :result) do
- false | nil | { user_internal_regex_pattern: nil, user_internal_regex_options: nil }
- false | '' | { user_internal_regex_pattern: nil, user_internal_regex_options: nil }
- false | 'mockRegexPattern' | { user_internal_regex_pattern: nil, user_internal_regex_options: nil }
- true | nil | { user_internal_regex_pattern: nil, user_internal_regex_options: nil }
- true | '' | { user_internal_regex_pattern: nil, user_internal_regex_options: nil }
- true | 'mockRegexPattern' | { user_internal_regex_pattern: 'mockRegexPattern', user_internal_regex_options: 'i' }
+ false | nil | {user_internal_regex_pattern: nil, user_internal_regex_options: nil}
+ false | "" | {user_internal_regex_pattern: nil, user_internal_regex_options: nil}
+ false | "mockRegexPattern" | {user_internal_regex_pattern: nil, user_internal_regex_options: nil}
+ true | nil | {user_internal_regex_pattern: nil, user_internal_regex_options: nil}
+ true | "" | {user_internal_regex_pattern: nil, user_internal_regex_options: nil}
+ true | "mockRegexPattern" | {user_internal_regex_pattern: "mockRegexPattern", user_internal_regex_options: "i"}
end
with_them do
@@ -66,7 +66,7 @@ describe UsersHelper do
end
end
- describe '#current_user_menu_items' do
+ describe "#current_user_menu_items" do
subject(:items) { helper.current_user_menu_items }
before do
@@ -74,41 +74,41 @@ describe UsersHelper do
allow(helper).to receive(:can?).and_return(false)
end
- it 'includes all default items' do
+ it "includes all default items" do
expect(items).to include(:help, :sign_out)
end
- it 'includes the profile tab if the user can read themself' do
+ it "includes the profile tab if the user can read themself" do
expect(helper).to receive(:can?).with(user, :read_user, user) { true }
expect(items).to include(:profile)
end
- it 'includes the settings tab if the user can update themself' do
+ it "includes the settings tab if the user can update themself" do
expect(helper).to receive(:can?).with(user, :read_user, user) { true }
expect(items).to include(:profile)
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- it 'hides the profile and the settings tab' do
+ it "hides the profile and the settings tab" do
expect(items).not_to include(:settings, :profile, :help)
end
end
end
- describe '#user_badges_in_admin_section' do
+ describe "#user_badges_in_admin_section" do
before do
allow(helper).to receive(:current_user).and_return(user)
end
- context 'with a blocked user' do
+ context "with a blocked user" do
it "returns the blocked badge" do
- blocked_user = create(:user, state: 'blocked')
+ blocked_user = create(:user, state: "blocked")
badges = helper.user_badges_in_admin_section(blocked_user)
@@ -116,7 +116,7 @@ describe UsersHelper do
end
end
- context 'with an admin user' do
+ context "with an admin user" do
it "returns the admin badge" do
admin_user = create(:admin)
@@ -126,8 +126,8 @@ describe UsersHelper do
end
end
- context 'with an external user' do
- it 'returns the external badge' do
+ context "with an external user" do
+ it "returns the external badge" do
external_user = create(:user, external: true)
badges = helper.user_badges_in_admin_section(external_user)
@@ -136,7 +136,7 @@ describe UsersHelper do
end
end
- context 'with the current user' do
+ context "with the current user" do
it 'returns the "It\'s You" badge' do
badges = helper.user_badges_in_admin_section(user)
@@ -144,22 +144,22 @@ describe UsersHelper do
end
end
- context 'with an external blocked admin' do
- it 'returns the blocked, admin and external badges' do
- user = create(:admin, state: 'blocked', external: true)
+ context "with an external blocked admin" do
+ it "returns the blocked, admin and external badges" do
+ user = create(:admin, state: "blocked", external: true)
badges = helper.user_badges_in_admin_section(user)
expect(badges).to eq([
- { text: "Blocked", variant: "danger" },
- { text: "Admin", variant: "success" },
- { text: "External", variant: "secondary" }
+ {text: "Blocked", variant: "danger"},
+ {text: "Admin", variant: "success"},
+ {text: "External", variant: "secondary"},
])
end
end
- context 'get badges for normal user' do
- it 'returns no badges' do
+ context "get badges for normal user" do
+ it "returns no badges" do
user = create(:user)
badges = helper.user_badges_in_admin_section(user)
diff --git a/spec/helpers/version_check_helper_spec.rb b/spec/helpers/version_check_helper_spec.rb
index bfec7ad4bba..7f75da80cc0 100644
--- a/spec/helpers/version_check_helper_spec.rb
+++ b/spec/helpers/version_check_helper_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe VersionCheckHelper do
- describe '#version_status_badge' do
- it 'should return nil if not dev environment and not enabled' do
+ describe "#version_status_badge" do
+ it "should return nil if not dev environment and not enabled" do
allow(Rails.env).to receive(:production?) { false }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { false }
expect(helper.version_status_badge).to be(nil)
end
- context 'when production and enabled' do
+ context "when production and enabled" do
before do
allow(Rails.env).to receive(:production?) { true }
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:version_check_enabled) { true }
- allow(VersionCheck).to receive(:url) { 'https://version.host.com/check.svg?gitlab_info=xxx' }
+ allow(VersionCheck).to receive(:url) { "https://version.host.com/check.svg?gitlab_info=xxx" }
end
- it 'should return an image tag' do
- expect(helper.version_status_badge).to start_with('<img')
+ it "should return an image tag" do
+ expect(helper.version_status_badge).to start_with("<img")
end
- it 'should have a js prefixed css class' do
+ it "should have a js prefixed css class" do
expect(helper.version_status_badge)
.to match(/class="js-version-status-badge lazy"/)
end
- it 'should have a VersionCheck url as the src' do
+ it "should have a VersionCheck url as the src" do
expect(helper.version_status_badge)
- .to include(%{src="https://version.host.com/check.svg?gitlab_info=xxx"})
+ .to include(%(src="https://version.host.com/check.svg?gitlab_info=xxx"))
end
end
end
diff --git a/spec/helpers/visibility_level_helper_spec.rb b/spec/helpers/visibility_level_helper_spec.rb
index e565ac8c530..0afe544581d 100644
--- a/spec/helpers/visibility_level_helper_spec.rb
+++ b/spec/helpers/visibility_level_helper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe VisibilityLevelHelper do
include ProjectForksHelper
@@ -8,22 +8,22 @@ describe VisibilityLevelHelper do
let(:personal_snippet) { build(:personal_snippet) }
let(:project_snippet) { build(:project_snippet) }
- describe 'visibility_icon_description' do
- context 'used with a Project' do
- it 'delegates projects to #project_visibility_icon_description' do
+ describe "visibility_icon_description" do
+ context "used with a Project" do
+ it "delegates projects to #project_visibility_icon_description" do
expect(visibility_icon_description(project))
.to match /project/i
end
- context 'used with a ProjectPresenter' do
- it 'delegates projects to #project_visibility_icon_description' do
+ context "used with a ProjectPresenter" do
+ it "delegates projects to #project_visibility_icon_description" do
expect(visibility_icon_description(project.present))
.to match /project/i
end
end
- context 'used with a Group' do
- it 'delegates groups to #group_visibility_icon_description' do
+ context "used with a Group" do
+ it "delegates groups to #group_visibility_icon_description" do
expect(visibility_icon_description(group))
.to match /group/i
end
@@ -31,25 +31,25 @@ describe VisibilityLevelHelper do
end
end
- describe 'visibility_level_description' do
- context 'used with a Project' do
- it 'delegates projects to #project_visibility_level_description' do
+ describe "visibility_level_description" do
+ context "used with a Project" do
+ it "delegates projects to #project_visibility_level_description" do
expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project))
- .to match /project/i
+ .to match /project/i
end
end
- context 'used with a Group' do
- it 'delegates groups to #group_visibility_level_description' do
+ context "used with a Group" do
+ it "delegates groups to #group_visibility_level_description" do
expect(visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, group))
- .to match /group/i
+ .to match /group/i
end
end
- context 'called with a Snippet' do
- it 'delegates snippets to #snippet_visibility_level_description' do
+ context "called with a Snippet" do
+ it "delegates snippets to #snippet_visibility_level_description" do
expect(visibility_level_description(Gitlab::VisibilityLevel::INTERNAL, project_snippet))
- .to match /snippet/i
+ .to match /snippet/i
end
end
end
@@ -57,29 +57,29 @@ describe VisibilityLevelHelper do
describe "#project_visibility_level_description" do
it "describes private projects" do
expect(project_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE))
- .to eq "Project access must be granted explicitly to each user."
+ .to eq "Project access must be granted explicitly to each user."
end
it "describes public projects" do
expect(project_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC))
- .to eq "The project can be accessed without any authentication."
+ .to eq "The project can be accessed without any authentication."
end
end
describe "#snippet_visibility_level_description" do
- it 'describes visibility only for me' do
+ it "describes visibility only for me" do
expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, personal_snippet))
- .to eq "The snippet is visible only to me."
+ .to eq "The snippet is visible only to me."
end
- it 'describes visibility for project members' do
+ it "describes visibility for project members" do
expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE, project_snippet))
- .to eq "The snippet is visible only to project members."
+ .to eq "The snippet is visible only to project members."
end
- it 'defaults to personal snippet' do
+ it "defaults to personal snippet" do
expect(snippet_visibility_level_description(Gitlab::VisibilityLevel::PRIVATE))
- .to eq "The snippet is visible only to me."
+ .to eq "The snippet is visible only to me."
end
end
@@ -145,7 +145,7 @@ describe VisibilityLevelHelper do
describe "project" do
it "provides correct description for disabled levels" do
expect(disallowed_visibility_level?(project, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy
- expect(strip_tags disallowed_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, project))
+ expect(strip_tags(disallowed_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, project)))
.to include "the visibility of #{project.group.name} is internal"
end
end
@@ -157,7 +157,7 @@ describe VisibilityLevelHelper do
.to include "it contains projects with higher visibility", "it contains sub-groups with higher visibility"
expect(disallowed_visibility_level?(subgroup, Gitlab::VisibilityLevel::PUBLIC)).to be_truthy
- expect(strip_tags disallowed_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, subgroup))
+ expect(strip_tags(disallowed_visibility_level_description(Gitlab::VisibilityLevel::PUBLIC, subgroup)))
.to include "the visibility of #{group.name} is internal"
end
end
diff --git a/spec/helpers/wiki_helper_spec.rb b/spec/helpers/wiki_helper_spec.rb
index 92c6f27a867..d3922c3d2f6 100644
--- a/spec/helpers/wiki_helper_spec.rb
+++ b/spec/helpers/wiki_helper_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe WikiHelper do
- describe '#breadcrumb' do
- context 'when the page is at the root level' do
- it 'returns the capitalized page name' do
- slug = 'page-name'
+ describe "#breadcrumb" do
+ context "when the page is at the root level" do
+ it "returns the capitalized page name" do
+ slug = "page-name"
- expect(helper.breadcrumb(slug)).to eq('Page name')
+ expect(helper.breadcrumb(slug)).to eq("Page name")
end
end
- context 'when the page is inside a directory' do
- it 'returns the capitalized name of each directory and of the page itself' do
- slug = 'dir_1/page-name'
+ context "when the page is inside a directory" do
+ it "returns the capitalized name of each directory and of the page itself" do
+ slug = "dir_1/page-name"
- expect(helper.breadcrumb(slug)).to eq('Dir_1 / Page name')
+ expect(helper.breadcrumb(slug)).to eq("Dir_1 / Page name")
end
end
end
diff --git a/spec/initializers/6_validations_spec.rb b/spec/initializers/6_validations_spec.rb
index f96e5a2133f..f5be7cf83bd 100644
--- a/spec/initializers/6_validations_spec.rb
+++ b/spec/initializers/6_validations_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
-require_relative '../../config/initializers/6_validations.rb'
+require "spec_helper"
+require_relative "../../config/initializers/6_validations.rb"
-describe '6_validations' do
+describe "6_validations" do
before :all do
- FileUtils.mkdir_p('tmp/tests/paths/a/b/c/d')
- FileUtils.mkdir_p('tmp/tests/paths/a/b/c2')
- FileUtils.mkdir_p('tmp/tests/paths/a/b/d')
+ FileUtils.mkdir_p("tmp/tests/paths/a/b/c/d")
+ FileUtils.mkdir_p("tmp/tests/paths/a/b/c2")
+ FileUtils.mkdir_p("tmp/tests/paths/a/b/d")
end
after :all do
- FileUtils.rm_rf('tmp/tests/paths')
+ FileUtils.rm_rf("tmp/tests/paths")
end
- describe 'validate_storages_config' do
- context 'with correct settings' do
+ describe "validate_storages_config" do
+ context "with correct settings" do
before do
- mock_storages('foo' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/paths/a/b/c'), 'bar' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/paths/a/b/d'))
+ mock_storages("foo" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/paths/a/b/c"), "bar" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/paths/a/b/d"))
end
- it 'passes through' do
+ it "passes through" do
expect { validate_storages_config }.not_to raise_error
end
end
- context 'when one of the settings is incorrect' do
+ context "when one of the settings is incorrect" do
before do
- mock_storages('foo' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/paths/a/b/c', 'failure_count_threshold' => 'not a number'))
+ mock_storages("foo" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/paths/a/b/c", "failure_count_threshold" => "not a number"))
end
- it 'throws an error' do
+ it "throws an error" do
expect { validate_storages_config }.to raise_error(/failure_count_threshold/)
end
end
- context 'with invalid storage names' do
+ context "with invalid storage names" do
before do
- mock_storages('name with spaces' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/paths/a/b/c'))
+ mock_storages("name with spaces" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/paths/a/b/c"))
end
- it 'throws an error' do
+ it "throws an error" do
expect { validate_storages_config }.to raise_error('"name with spaces" is not a valid storage name. Please fix this in your gitlab.yml before starting GitLab.')
end
end
diff --git a/spec/initializers/active_record_locking_spec.rb b/spec/initializers/active_record_locking_spec.rb
index 5a16aef78e6..b18284deacf 100644
--- a/spec/initializers/active_record_locking_spec.rb
+++ b/spec/initializers/active_record_locking_spec.rb
@@ -1,44 +1,44 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'ActiveRecord locking' do
+describe "ActiveRecord locking" do
let(:issue) { create(:issue) }
- shared_examples 'locked model' do
+ shared_examples "locked model" do
before do
issue.update_column(:lock_version, start_lock_version)
end
- it 'can be updated' do
+ it "can be updated" do
issue.update(title: "New title")
expect(issue.reload.lock_version).to eq(new_lock_version)
end
- it 'can be deleted' do
+ it "can be deleted" do
expect { issue.destroy }.to change { Issue.count }.by(-1)
end
end
- context 'when lock_version is NULL' do
+ context "when lock_version is NULL" do
let(:start_lock_version) { nil }
let(:new_lock_version) { 1 }
- it_behaves_like 'locked model'
+ it_behaves_like "locked model"
end
- context 'when lock_version is 0' do
+ context "when lock_version is 0" do
let(:start_lock_version) { 0 }
let(:new_lock_version) { 1 }
- it_behaves_like 'locked model'
+ it_behaves_like "locked model"
end
- context 'when lock_version is 1' do
+ context "when lock_version is 1" do
let(:start_lock_version) { 1 }
let(:new_lock_version) { 2 }
- it_behaves_like 'locked model'
+ it_behaves_like "locked model"
end
end
diff --git a/spec/initializers/attr_encrypted_no_db_connection_spec.rb b/spec/initializers/attr_encrypted_no_db_connection_spec.rb
index 2da9f1cbd96..069a2d3ad8f 100644
--- a/spec/initializers/attr_encrypted_no_db_connection_spec.rb
+++ b/spec/initializers/attr_encrypted_no_db_connection_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'GitLab monkey-patches to AttrEncrypted' do
- describe '#attribute_instance_methods_as_symbols_available?' do
- it 'returns false' do
+describe "GitLab monkey-patches to AttrEncrypted" do
+ describe "#attribute_instance_methods_as_symbols_available?" do
+ it "returns false" do
expect(ActiveRecord::Base.__send__(:attribute_instance_methods_as_symbols_available?)).to be_falsy
end
- it 'does not define virtual attributes' do
- klass = Class.new(ActiveRecord::Base) do
+ it "does not define virtual attributes" do
+ klass = Class.new(ActiveRecord::Base) {
# We need some sort of table to work on
- self.table_name = 'projects'
+ self.table_name = "projects"
attr_encrypted :foo
- end
+ }
instance = klass.new
diff --git a/spec/initializers/direct_upload_support_spec.rb b/spec/initializers/direct_upload_support_spec.rb
index e51d404e030..fb1ab95aa32 100644
--- a/spec/initializers/direct_upload_support_spec.rb
+++ b/spec/initializers/direct_upload_support_spec.rb
@@ -1,88 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Direct upload support' do
+describe "Direct upload support" do
subject do
- load Rails.root.join('config/initializers/direct_upload_support.rb')
+ load Rails.root.join("config/initializers/direct_upload_support.rb")
end
where(:config_name) do
- %w(lfs artifacts uploads)
+ %w[lfs artifacts uploads]
end
with_them do
let(:connection) do
- { provider: provider }
+ {provider: provider}
end
let(:object_store) do
{
enabled: enabled,
direct_upload: direct_upload,
- connection: connection
+ connection: connection,
}
end
before do
allow(Gitlab.config).to receive_messages(to_settings(config_name => {
- object_store: object_store
+ object_store: object_store,
}))
end
- context 'when object storage is enabled' do
+ context "when object storage is enabled" do
let(:enabled) { true }
- context 'when direct upload is enabled' do
+ context "when direct upload is enabled" do
let(:direct_upload) { true }
- context 'when provider is AWS' do
- let(:provider) { 'AWS' }
+ context "when provider is AWS" do
+ let(:provider) { "AWS" }
- it 'succeeds' do
+ it "succeeds" do
expect { subject }.not_to raise_error
end
end
- context 'when provider is Google' do
- let(:provider) { 'Google' }
+ context "when provider is Google" do
+ let(:provider) { "Google" }
- it 'succeeds' do
+ it "succeeds" do
expect { subject }.not_to raise_error
end
end
- context 'when connection is empty' do
+ context "when connection is empty" do
let(:connection) { nil }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error /are supported as a object storage provider when 'direct_upload' is used/
end
end
- context 'when other provider is used' do
- let(:provider) { 'Rackspace' }
+ context "when other provider is used" do
+ let(:provider) { "Rackspace" }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error /are supported as a object storage provider when 'direct_upload' is used/
end
end
end
- context 'when direct upload is disabled' do
+ context "when direct upload is disabled" do
let(:direct_upload) { false }
- let(:provider) { 'AWS' }
+ let(:provider) { "AWS" }
- it 'succeeds' do
+ it "succeeds" do
expect { subject }.not_to raise_error
end
end
end
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
let(:enabled) { false }
let(:direct_upload) { false }
- let(:provider) { 'Rackspace' }
+ let(:provider) { "Rackspace" }
- it 'succeeds' do
+ it "succeeds" do
expect { subject }.not_to raise_error
end
end
diff --git a/spec/initializers/doorkeeper_spec.rb b/spec/initializers/doorkeeper_spec.rb
index 1a78196e33d..445d66990b5 100644
--- a/spec/initializers/doorkeeper_spec.rb
+++ b/spec/initializers/doorkeeper_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
-require_relative '../../config/initializers/doorkeeper'
+require "spec_helper"
+require_relative "../../config/initializers/doorkeeper"
describe Doorkeeper.configuration do
- describe '#default_scopes' do
- it 'matches Gitlab::Auth::DEFAULT_SCOPES' do
+ describe "#default_scopes" do
+ it "matches Gitlab::Auth::DEFAULT_SCOPES" do
expect(subject.default_scopes).to eq Gitlab::Auth::DEFAULT_SCOPES
end
end
- describe '#optional_scopes' do
- it 'matches Gitlab::Auth.optional_scopes' do
+ describe "#optional_scopes" do
+ it "matches Gitlab::Auth.optional_scopes" do
expect(subject.optional_scopes).to eq Gitlab::Auth.optional_scopes - Gitlab::Auth::REGISTRY_SCOPES
end
end
- describe '#resource_owner_authenticator' do
+ describe "#resource_owner_authenticator" do
subject { controller.instance_exec(&Doorkeeper.configuration.authenticate_resource_owner) }
let(:controller) { double }
@@ -22,49 +22,49 @@ describe Doorkeeper.configuration do
before do
allow(controller).to receive(:current_user).and_return(current_user)
allow(controller).to receive(:session).and_return({})
- allow(controller).to receive(:request).and_return(OpenStruct.new(fullpath: '/return-path'))
+ allow(controller).to receive(:request).and_return(OpenStruct.new(fullpath: "/return-path"))
allow(controller).to receive(:redirect_to)
- allow(controller).to receive(:new_user_session_url).and_return('/login')
+ allow(controller).to receive(:new_user_session_url).and_return("/login")
end
- context 'with a user present' do
+ context "with a user present" do
let(:current_user) { create(:user) }
- it 'returns the user' do
+ it "returns the user" do
expect(subject).to eq current_user
end
- it 'does not redirect' do
+ it "does not redirect" do
expect(controller).not_to receive(:redirect_to)
subject
end
- it 'does not store the return path' do
+ it "does not store the return path" do
subject
expect(controller.session).not_to include :user_return_to
end
end
- context 'without a user present' do
+ context "without a user present" do
let(:current_user) { nil }
# NOTE: this is required for doorkeeper-openid_connect
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to eq nil
end
- it 'redirects to the login form' do
- expect(controller).to receive(:redirect_to).with('/login')
+ it "redirects to the login form" do
+ expect(controller).to receive(:redirect_to).with("/login")
subject
end
- it 'stores the return path' do
+ it "stores the return path" do
subject
- expect(controller.session[:user_return_to]).to eq '/return-path'
+ expect(controller.session[:user_return_to]).to eq "/return-path"
end
end
end
diff --git a/spec/initializers/fog_google_https_private_urls_spec.rb b/spec/initializers/fog_google_https_private_urls_spec.rb
index 08346b71fee..529bb867bfa 100644
--- a/spec/initializers/fog_google_https_private_urls_spec.rb
+++ b/spec/initializers/fog_google_https_private_urls_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Fog::Storage::GoogleXML::File', :fog_requests do
+describe "Fog::Storage::GoogleXML::File", :fog_requests do
let(:storage) do
Fog.mock!
Fog::Storage.new(
@@ -11,14 +11,14 @@ describe 'Fog::Storage::GoogleXML::File', :fog_requests do
end
let(:file) do
- directory = storage.directories.create(key: 'data')
+ directory = storage.directories.create(key: "data")
directory.files.create(
- body: 'Hello World!',
- key: 'hello_world.txt'
+ body: "Hello World!",
+ key: "hello_world.txt"
)
end
- it 'delegates to #get_https_url' do
+ it "delegates to #get_https_url" do
expect(file.url(Time.now)).to start_with("https://")
end
end
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb
index 24d366731a2..968821e16a4 100644
--- a/spec/initializers/lograge_spec.rb
+++ b/spec/initializers/lograge_spec.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'lograge', type: :request do
- let(:headers) { { 'X-Request-ID' => 'new-correlation-id' } }
+describe "lograge", type: :request do
+ let(:headers) { {"X-Request-ID" => "new-correlation-id"} }
- context 'for API requests' do
+ context "for API requests" do
subject { get("/api/v4/endpoint", params: {}, headers: headers) }
- it 'logs to api_json log' do
+ it "logs to api_json log" do
# we assert receiving parameters by grape logger
expect_any_instance_of(Gitlab::GrapeLogging::Formatters::LogrageWithTimestamp).to receive(:call)
.with(anything, anything, anything, a_hash_including("correlation_id" => "new-correlation-id"))
@@ -18,10 +18,10 @@ describe 'lograge', type: :request do
end
end
- context 'for Controller requests' do
+ context "for Controller requests" do
subject { get("/", params: {}, headers: headers) }
- it 'logs to production_json log' do
+ it "logs to production_json log" do
# formatter receives a hash with correlation id
expect(Lograge.formatter).to receive(:call)
.with(a_hash_including("correlation_id" => "new-correlation-id"))
diff --git a/spec/initializers/secret_token_spec.rb b/spec/initializers/secret_token_spec.rb
index 6366be30079..1fa1e75d6b4 100644
--- a/spec/initializers/secret_token_spec.rb
+++ b/spec/initializers/secret_token_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
-require_relative '../../config/initializers/01_secret_token'
+require "spec_helper"
+require_relative "../../config/initializers/01_secret_token"
-describe 'create_tokens' do
+describe "create_tokens" do
include StubENV
let(:secrets) { ActiveSupport::OrderedOptions.new }
@@ -18,16 +18,16 @@ describe 'create_tokens' do
allow(self).to receive(:exit)
end
- context 'setting secret keys' do
- context 'when none of the secrets exist' do
+ context "setting secret keys" do
+ context "when none of the secrets exist" do
before do
- stub_env('SECRET_KEY_BASE', nil)
- allow(File).to receive(:exist?).with('.secret').and_return(false)
- allow(File).to receive(:exist?).with('config/secrets.yml').and_return(false)
+ stub_env("SECRET_KEY_BASE", nil)
+ allow(File).to receive(:exist?).with(".secret").and_return(false)
+ allow(File).to receive(:exist?).with("config/secrets.yml").and_return(false)
allow(self).to receive(:warn_missing_secret)
end
- it 'generates different hashes for secret_key_base, otp_key_base, and db_key_base' do
+ it "generates different hashes for secret_key_base, otp_key_base, and db_key_base" do
create_tokens
keys = secrets.values_at(:secret_key_base, :otp_key_base, :db_key_base)
@@ -36,7 +36,7 @@ describe 'create_tokens' do
expect(keys).to all(match(HEX_KEY))
end
- it 'generates an RSA key for openid_connect_signing_key' do
+ it "generates an RSA key for openid_connect_signing_key" do
create_tokens
keys = secrets.values_at(:openid_connect_signing_key)
@@ -45,171 +45,171 @@ describe 'create_tokens' do
expect(keys).to all(match(RSA_KEY))
end
- it 'warns about the secrets to add to secrets.yml' do
- expect(self).to receive(:warn_missing_secret).with('secret_key_base')
- expect(self).to receive(:warn_missing_secret).with('otp_key_base')
- expect(self).to receive(:warn_missing_secret).with('db_key_base')
- expect(self).to receive(:warn_missing_secret).with('openid_connect_signing_key')
+ it "warns about the secrets to add to secrets.yml" do
+ expect(self).to receive(:warn_missing_secret).with("secret_key_base")
+ expect(self).to receive(:warn_missing_secret).with("otp_key_base")
+ expect(self).to receive(:warn_missing_secret).with("db_key_base")
+ expect(self).to receive(:warn_missing_secret).with("openid_connect_signing_key")
create_tokens
end
- it 'writes the secrets to secrets.yml' do
- expect(File).to receive(:write).with('config/secrets.yml', any_args) do |filename, contents, options|
+ it "writes the secrets to secrets.yml" do
+ expect(File).to receive(:write).with("config/secrets.yml", any_args) do |filename, contents, options|
new_secrets = YAML.load(contents)[Rails.env]
- expect(new_secrets['secret_key_base']).to eq(secrets.secret_key_base)
- expect(new_secrets['otp_key_base']).to eq(secrets.otp_key_base)
- expect(new_secrets['db_key_base']).to eq(secrets.db_key_base)
- expect(new_secrets['openid_connect_signing_key']).to eq(secrets.openid_connect_signing_key)
+ expect(new_secrets["secret_key_base"]).to eq(secrets.secret_key_base)
+ expect(new_secrets["otp_key_base"]).to eq(secrets.otp_key_base)
+ expect(new_secrets["db_key_base"]).to eq(secrets.db_key_base)
+ expect(new_secrets["openid_connect_signing_key"]).to eq(secrets.openid_connect_signing_key)
end
create_tokens
end
- it 'does not write a .secret file' do
- expect(File).not_to receive(:write).with('.secret')
+ it "does not write a .secret file" do
+ expect(File).not_to receive(:write).with(".secret")
create_tokens
end
end
- context 'when the other secrets all exist' do
+ context "when the other secrets all exist" do
before do
- secrets.db_key_base = 'db_key_base'
- secrets.openid_connect_signing_key = 'openid_connect_signing_key'
+ secrets.db_key_base = "db_key_base"
+ secrets.openid_connect_signing_key = "openid_connect_signing_key"
- allow(File).to receive(:exist?).with('.secret').and_return(true)
- allow(File).to receive(:read).with('.secret').and_return('file_key')
+ allow(File).to receive(:exist?).with(".secret").and_return(true)
+ allow(File).to receive(:read).with(".secret").and_return("file_key")
end
- context 'when secret_key_base exists in the environment and secrets.yml' do
+ context "when secret_key_base exists in the environment and secrets.yml" do
before do
- stub_env('SECRET_KEY_BASE', 'env_key')
- secrets.secret_key_base = 'secret_key_base'
- secrets.otp_key_base = 'otp_key_base'
- secrets.openid_connect_signing_key = 'openid_connect_signing_key'
+ stub_env("SECRET_KEY_BASE", "env_key")
+ secrets.secret_key_base = "secret_key_base"
+ secrets.otp_key_base = "otp_key_base"
+ secrets.openid_connect_signing_key = "openid_connect_signing_key"
end
- it 'does not issue a warning' do
+ it "does not issue a warning" do
expect(self).not_to receive(:warn)
create_tokens
end
- it 'uses the environment variable' do
+ it "uses the environment variable" do
create_tokens
- expect(secrets.secret_key_base).to eq('env_key')
+ expect(secrets.secret_key_base).to eq("env_key")
end
- it 'does not update secrets.yml' do
+ it "does not update secrets.yml" do
expect(File).not_to receive(:write)
create_tokens
end
end
- context 'when secret_key_base and otp_key_base exist' do
+ context "when secret_key_base and otp_key_base exist" do
before do
- secrets.secret_key_base = 'secret_key_base'
- secrets.otp_key_base = 'otp_key_base'
- secrets.openid_connect_signing_key = 'openid_connect_signing_key'
+ secrets.secret_key_base = "secret_key_base"
+ secrets.otp_key_base = "otp_key_base"
+ secrets.openid_connect_signing_key = "openid_connect_signing_key"
end
- it 'does not write any files' do
+ it "does not write any files" do
expect(File).not_to receive(:write)
create_tokens
end
- it 'sets the keys to the values from the environment and secrets.yml' do
+ it "sets the keys to the values from the environment and secrets.yml" do
create_tokens
- expect(secrets.secret_key_base).to eq('secret_key_base')
- expect(secrets.otp_key_base).to eq('otp_key_base')
- expect(secrets.db_key_base).to eq('db_key_base')
- expect(secrets.openid_connect_signing_key).to eq('openid_connect_signing_key')
+ expect(secrets.secret_key_base).to eq("secret_key_base")
+ expect(secrets.otp_key_base).to eq("otp_key_base")
+ expect(secrets.db_key_base).to eq("db_key_base")
+ expect(secrets.openid_connect_signing_key).to eq("openid_connect_signing_key")
end
- it 'deletes the .secret file' do
- expect(File).to receive(:delete).with('.secret')
+ it "deletes the .secret file" do
+ expect(File).to receive(:delete).with(".secret")
create_tokens
end
end
- context 'when secret_key_base and otp_key_base do not exist' do
+ context "when secret_key_base and otp_key_base do not exist" do
before do
- allow(File).to receive(:exist?).with('config/secrets.yml').and_return(true)
- allow(YAML).to receive(:load_file).with('config/secrets.yml').and_return('test' => secrets.to_h.stringify_keys)
+ allow(File).to receive(:exist?).with("config/secrets.yml").and_return(true)
+ allow(YAML).to receive(:load_file).with("config/secrets.yml").and_return("test" => secrets.to_h.stringify_keys)
allow(self).to receive(:warn_missing_secret)
end
- it 'uses the file secret' do
+ it "uses the file secret" do
expect(File).to receive(:write) do |filename, contents, options|
new_secrets = YAML.load(contents)[Rails.env]
- expect(new_secrets['secret_key_base']).to eq('file_key')
- expect(new_secrets['otp_key_base']).to eq('file_key')
- expect(new_secrets['db_key_base']).to eq('db_key_base')
- expect(new_secrets['openid_connect_signing_key']).to eq('openid_connect_signing_key')
+ expect(new_secrets["secret_key_base"]).to eq("file_key")
+ expect(new_secrets["otp_key_base"]).to eq("file_key")
+ expect(new_secrets["db_key_base"]).to eq("db_key_base")
+ expect(new_secrets["openid_connect_signing_key"]).to eq("openid_connect_signing_key")
end
create_tokens
- expect(secrets.otp_key_base).to eq('file_key')
+ expect(secrets.otp_key_base).to eq("file_key")
end
- it 'keeps the other secrets as they were' do
+ it "keeps the other secrets as they were" do
create_tokens
- expect(secrets.db_key_base).to eq('db_key_base')
+ expect(secrets.db_key_base).to eq("db_key_base")
end
- it 'warns about the missing secrets' do
- expect(self).to receive(:warn_missing_secret).with('secret_key_base')
- expect(self).to receive(:warn_missing_secret).with('otp_key_base')
+ it "warns about the missing secrets" do
+ expect(self).to receive(:warn_missing_secret).with("secret_key_base")
+ expect(self).to receive(:warn_missing_secret).with("otp_key_base")
create_tokens
end
- it 'deletes the .secret file' do
- expect(File).to receive(:delete).with('.secret')
+ it "deletes the .secret file" do
+ expect(File).to receive(:delete).with(".secret")
create_tokens
end
end
end
- context 'when db_key_base is blank but exists in secrets.yml' do
+ context "when db_key_base is blank but exists in secrets.yml" do
before do
- secrets.otp_key_base = 'otp_key_base'
- secrets.secret_key_base = 'secret_key_base'
- yaml_secrets = secrets.to_h.stringify_keys.merge('db_key_base' => '<%= an_erb_expression %>')
+ secrets.otp_key_base = "otp_key_base"
+ secrets.secret_key_base = "secret_key_base"
+ yaml_secrets = secrets.to_h.stringify_keys.merge("db_key_base" => "<%= an_erb_expression %>")
- allow(File).to receive(:exist?).with('.secret').and_return(false)
- allow(File).to receive(:exist?).with('config/secrets.yml').and_return(true)
- allow(YAML).to receive(:load_file).with('config/secrets.yml').and_return('test' => yaml_secrets)
+ allow(File).to receive(:exist?).with(".secret").and_return(false)
+ allow(File).to receive(:exist?).with("config/secrets.yml").and_return(true)
+ allow(YAML).to receive(:load_file).with("config/secrets.yml").and_return("test" => yaml_secrets)
allow(self).to receive(:warn_missing_secret)
end
- it 'warns about updating db_key_base' do
- expect(self).to receive(:warn_missing_secret).with('db_key_base')
+ it "warns about updating db_key_base" do
+ expect(self).to receive(:warn_missing_secret).with("db_key_base")
create_tokens
end
- it 'warns about the blank value existing in secrets.yml and exits' do
+ it "warns about the blank value existing in secrets.yml and exits" do
expect(self).to receive(:warn) do |warning|
- expect(warning).to include('db_key_base')
- expect(warning).to include('<%= an_erb_expression %>')
+ expect(warning).to include("db_key_base")
+ expect(warning).to include("<%= an_erb_expression %>")
end
create_tokens
end
- it 'does not update secrets.yml' do
+ it "does not update secrets.yml" do
expect(self).to receive(:exit).with(1).and_call_original
expect(File).not_to receive(:write)
diff --git a/spec/initializers/settings_spec.rb b/spec/initializers/settings_spec.rb
index 57f5adbbc40..7d834a03aae 100644
--- a/spec/initializers/settings_spec.rb
+++ b/spec/initializers/settings_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
-require_relative '../../config/initializers/1_settings' unless defined?(Settings)
+require "spec_helper"
+require_relative "../../config/initializers/1_settings" unless defined?(Settings)
describe Settings do
- describe '#ldap' do
- it 'can be accessed with dot syntax all the way down' do
- expect(Gitlab.config.ldap.servers.main.label).to eq('ldap')
+ describe "#ldap" do
+ it "can be accessed with dot syntax all the way down" do
+ expect(Gitlab.config.ldap.servers.main.label).to eq("ldap")
end
# Specifically trying to cause this error discovered in EE when removing the
@@ -12,46 +12,46 @@ describe Settings do
#
# `undefined method `label' for #<Hash:0x007fbd18b59c08>`
#
- it 'can be accessed in a very specific way that breaks without reassigning each element with Settingslogic' do
- server_settings = Gitlab.config.ldap.servers['main']
- expect(server_settings.label).to eq('ldap')
+ it "can be accessed in a very specific way that breaks without reassigning each element with Settingslogic" do
+ server_settings = Gitlab.config.ldap.servers["main"]
+ expect(server_settings.label).to eq("ldap")
end
end
- describe '#host_without_www' do
- context 'URL with protocol' do
- it 'returns the host' do
- expect(described_class.host_without_www('http://foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('http://www.foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('http://secure.foo.com')).to eq 'secure.foo.com'
- expect(described_class.host_without_www('https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
+ describe "#host_without_www" do
+ context "URL with protocol" do
+ it "returns the host" do
+ expect(described_class.host_without_www("http://foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("http://www.foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("http://secure.foo.com")).to eq "secure.foo.com"
+ expect(described_class.host_without_www("https://www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon")).to eq "gravatar.com"
- expect(described_class.host_without_www('https://foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('https://www.foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('https://secure.foo.com')).to eq 'secure.foo.com'
- expect(described_class.host_without_www('https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'secure.gravatar.com'
+ expect(described_class.host_without_www("https://foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("https://www.foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("https://secure.foo.com")).to eq "secure.foo.com"
+ expect(described_class.host_without_www("https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon")).to eq "secure.gravatar.com"
end
end
- context 'URL without protocol' do
- it 'returns the host' do
- expect(described_class.host_without_www('foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('www.foo.com')).to eq 'foo.com'
- expect(described_class.host_without_www('secure.foo.com')).to eq 'secure.foo.com'
- expect(described_class.host_without_www('www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
+ context "URL without protocol" do
+ it "returns the host" do
+ expect(described_class.host_without_www("foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("www.foo.com")).to eq "foo.com"
+ expect(described_class.host_without_www("secure.foo.com")).to eq "secure.foo.com"
+ expect(described_class.host_without_www("www.gravatar.com/avatar/%{hash}?s=%{size}&d=identicon")).to eq "gravatar.com"
end
- context 'URL with user/port' do
- it 'returns the host' do
- expect(described_class.host_without_www('bob:pass@foo.com:8080')).to eq 'foo.com'
- expect(described_class.host_without_www('bob:pass@www.foo.com:8080')).to eq 'foo.com'
- expect(described_class.host_without_www('bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
- expect(described_class.host_without_www('bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
+ context "URL with user/port" do
+ it "returns the host" do
+ expect(described_class.host_without_www("bob:pass@foo.com:8080")).to eq "foo.com"
+ expect(described_class.host_without_www("bob:pass@www.foo.com:8080")).to eq "foo.com"
+ expect(described_class.host_without_www("bob:pass@secure.foo.com:8080")).to eq "secure.foo.com"
+ expect(described_class.host_without_www("bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon")).to eq "gravatar.com"
- expect(described_class.host_without_www('http://bob:pass@foo.com:8080')).to eq 'foo.com'
- expect(described_class.host_without_www('http://bob:pass@www.foo.com:8080')).to eq 'foo.com'
- expect(described_class.host_without_www('http://bob:pass@secure.foo.com:8080')).to eq 'secure.foo.com'
- expect(described_class.host_without_www('http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon')).to eq 'gravatar.com'
+ expect(described_class.host_without_www("http://bob:pass@foo.com:8080")).to eq "foo.com"
+ expect(described_class.host_without_www("http://bob:pass@www.foo.com:8080")).to eq "foo.com"
+ expect(described_class.host_without_www("http://bob:pass@secure.foo.com:8080")).to eq "secure.foo.com"
+ expect(described_class.host_without_www("http://bob:pass@www.gravatar.com:8080/avatar/%{hash}?s=%{size}&d=identicon")).to eq "gravatar.com"
end
end
end
diff --git a/spec/initializers/trusted_proxies_spec.rb b/spec/initializers/trusted_proxies_spec.rb
index 02a9446ad7b..40bf4aeb7ae 100644
--- a/spec/initializers/trusted_proxies_spec.rb
+++ b/spec/initializers/trusted_proxies_spec.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'trusted_proxies' do
- context 'with default config' do
+describe "trusted_proxies" do
+ context "with default config" do
before do
set_trusted_proxies([])
end
- it 'preserves private IPs' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '10.1.5.89')
- expect(request.remote_ip).to eq('10.1.5.89')
- expect(request.ip).to eq('10.1.5.89')
+ it "preserves private IPs" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "10.1.5.89")
+ expect(request.remote_ip).to eq("10.1.5.89")
+ expect(request.ip).to eq("10.1.5.89")
end
- it 'filters out localhost' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '1.1.1.1, 10.1.5.89, 127.0.0.1')
- expect(request.remote_ip).to eq('10.1.5.89')
- expect(request.ip).to eq('10.1.5.89')
+ it "filters out localhost" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "1.1.1.1, 10.1.5.89, 127.0.0.1")
+ expect(request.remote_ip).to eq("10.1.5.89")
+ expect(request.ip).to eq("10.1.5.89")
end
- it 'filters out bad values' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '(null), 10.1.5.89')
- expect(request.remote_ip).to eq('10.1.5.89')
- expect(request.ip).to eq('10.1.5.89')
+ it "filters out bad values" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "(null), 10.1.5.89")
+ expect(request.remote_ip).to eq("10.1.5.89")
+ expect(request.ip).to eq("10.1.5.89")
end
end
- context 'with private IP ranges added' do
+ context "with private IP ranges added" do
before do
set_trusted_proxies(["10.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"])
end
- it 'filters out private and local IPs' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '1.2.3.6, 1.1.1.1, 10.1.5.89, 127.0.0.1')
- expect(request.remote_ip).to eq('1.1.1.1')
- expect(request.ip).to eq('1.1.1.1')
+ it "filters out private and local IPs" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "1.2.3.6, 1.1.1.1, 10.1.5.89, 127.0.0.1")
+ expect(request.remote_ip).to eq("1.1.1.1")
+ expect(request.ip).to eq("1.1.1.1")
end
end
- context 'with proxy IP added' do
+ context "with proxy IP added" do
before do
set_trusted_proxies(["60.98.25.47"])
end
- it 'filters out proxy IP' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '1.2.3.6, 1.1.1.1, 60.98.25.47, 127.0.0.1')
- expect(request.remote_ip).to eq('1.1.1.1')
- expect(request.ip).to eq('1.1.1.1')
+ it "filters out proxy IP" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "1.2.3.6, 1.1.1.1, 60.98.25.47, 127.0.0.1")
+ expect(request.remote_ip).to eq("1.1.1.1")
+ expect(request.ip).to eq("1.1.1.1")
end
- it 'handles invalid ip addresses' do
- request = stub_request('HTTP_X_FORWARDED_FOR' => '(null), 1.1.1.1:12345, 1.1.1.1')
- expect(request.remote_ip).to eq('1.1.1.1')
- expect(request.ip).to eq('1.1.1.1')
+ it "handles invalid ip addresses" do
+ request = stub_request("HTTP_X_FORWARDED_FOR" => "(null), 1.1.1.1:12345, 1.1.1.1")
+ expect(request.remote_ip).to eq("1.1.1.1")
+ expect(request.ip).to eq("1.1.1.1")
end
end
@@ -61,7 +61,7 @@ describe 'trusted_proxies' do
end
def set_trusted_proxies(proxies = [])
- stub_config_setting('trusted_proxies' => proxies)
- load File.join(__dir__, '../../config/initializers/trusted_proxies.rb')
+ stub_config_setting("trusted_proxies" => proxies)
+ load File.join(__dir__, "../../config/initializers/trusted_proxies.rb")
end
end
diff --git a/spec/initializers/zz_metrics_spec.rb b/spec/initializers/zz_metrics_spec.rb
index 3eaccfe8d8b..d756eebbbe5 100644
--- a/spec/initializers/zz_metrics_spec.rb
+++ b/spec/initializers/zz_metrics_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'instrument_classes' do
+describe "instrument_classes" do
let(:config) { double(:config) }
let(:influx_sampler) { double(:influx_sampler) }
@@ -15,8 +15,8 @@ describe 'instrument_classes' do
allow(Gitlab::Application).to receive(:configure)
end
- it 'can autoload and instrument all files' do
- require_relative '../../config/initializers/zz_metrics'
+ it "can autoload and instrument all files" do
+ require_relative "../../config/initializers/zz_metrics"
expect { instrument_classes(config) }.not_to raise_error
end
end
diff --git a/spec/javascripts/fixtures/abuse_reports.rb b/spec/javascripts/fixtures/abuse_reports.rb
index 387858cba77..1f451db4076 100644
--- a/spec/javascripts/fixtures/abuse_reports.rb
+++ b/spec/javascripts/fixtures/abuse_reports.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
-describe Admin::AbuseReportsController, '(JavaScript fixtures)', type: :controller do
+describe Admin::AbuseReportsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
let!(:abuse_report) { create(:abuse_report) }
- let!(:abuse_report_with_short_message) { create(:abuse_report, message: 'SHORT MESSAGE') }
+ let!(:abuse_report_with_short_message) { create(:abuse_report, message: "SHORT MESSAGE") }
let!(:abuse_report_with_long_message) { create(:abuse_report, message: "LONG MESSAGE\n" * 50) }
render_views
before(:all) do
- clean_frontend_fixtures('abuse_reports/')
+ clean_frontend_fixtures("abuse_reports/")
end
before do
sign_in(admin)
end
- it 'abuse_reports/abuse_reports_list.html.raw' do |example|
+ it "abuse_reports/abuse_reports_list.html.raw" do |example|
get :index
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/admin_users.rb b/spec/javascripts/fixtures/admin_users.rb
index 9989ac4fff2..a94b49f92f4 100644
--- a/spec/javascripts/fixtures/admin_users.rb
+++ b/spec/javascripts/fixtures/admin_users.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
-describe Admin::UsersController, '(JavaScript fixtures)', type: :controller do
+describe Admin::UsersController, "(JavaScript fixtures)", type: :controller do
include StubENV
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(admin)
end
render_views
before(:all) do
- clean_frontend_fixtures('admin/users')
+ clean_frontend_fixtures("admin/users")
end
- it 'admin/users/new_with_internal_user_regex.html.raw' do |example|
+ it "admin/users/new_with_internal_user_regex.html.raw" do |example|
stub_application_setting(user_default_external: true)
stub_application_setting(user_default_internal_regex: '^(?:(?!\.ext@).)*$\r?')
diff --git a/spec/javascripts/fixtures/application_settings.rb b/spec/javascripts/fixtures/application_settings.rb
index a9d3043f73d..704c3b3ee24 100644
--- a/spec/javascripts/fixtures/application_settings.rb
+++ b/spec/javascripts/fixtures/application_settings.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
-describe Admin::ApplicationSettingsController, '(JavaScript fixtures)', type: :controller do
+describe Admin::ApplicationSettingsController, "(JavaScript fixtures)", type: :controller do
include StubENV
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'application-settings') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "application-settings") }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
sign_in(admin)
end
render_views
before(:all) do
- clean_frontend_fixtures('application_settings/')
+ clean_frontend_fixtures("application_settings/")
end
after do
remove_repository(project)
end
- it 'application_settings/accounts_and_limit.html.raw' do |example|
+ it "application_settings/accounts_and_limit.html.raw" do |example|
stub_application_setting(user_default_external: false)
get :show
diff --git a/spec/javascripts/fixtures/autocomplete_sources.rb b/spec/javascripts/fixtures/autocomplete_sources.rb
index c117fb7cd24..ef425f6abdd 100644
--- a/spec/javascripts/fixtures/autocomplete_sources.rb
+++ b/spec/javascripts/fixtures/autocomplete_sources.rb
@@ -1,38 +1,38 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe Projects::AutocompleteSourcesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::AutocompleteSourcesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
set(:admin) { create(:admin) }
- set(:group) { create(:group, name: 'frontend-fixtures') }
- set(:project) { create(:project, namespace: group, path: 'autocomplete-sources-project') }
+ set(:group) { create(:group, name: "frontend-fixtures") }
+ set(:project) { create(:project, namespace: group, path: "autocomplete-sources-project") }
set(:issue) { create(:issue, project: project) }
before(:all) do
- clean_frontend_fixtures('autocomplete_sources/')
+ clean_frontend_fixtures("autocomplete_sources/")
end
before do
sign_in(admin)
end
- it 'autocomplete_sources/labels.json' do |example|
- issue.labels << create(:label, project: project, title: 'bug')
- issue.labels << create(:label, project: project, title: 'critical')
+ it "autocomplete_sources/labels.json" do |example|
+ issue.labels << create(:label, project: project, title: "bug")
+ issue.labels << create(:label, project: project, title: "critical")
- create(:label, project: project, title: 'feature')
- create(:label, project: project, title: 'documentation')
+ create(:label, project: project, title: "feature")
+ create(:label, project: project, title: "documentation")
get :labels,
- format: :json,
- params: {
- namespace_id: group.path,
- project_id: project.path,
- type: issue.class.name,
- type_id: issue.id
- }
+ format: :json,
+ params: {
+ namespace_id: group.path,
+ project_id: project.path,
+ type: issue.class.name,
+ type_id: issue.id,
+ }
expect(response).to be_success
store_frontend_fixture(response, example.description)
diff --git a/spec/javascripts/fixtures/balsamiq.rb b/spec/javascripts/fixtures/balsamiq.rb
index 234e246119a..e545c51337c 100644
--- a/spec/javascripts/fixtures/balsamiq.rb
+++ b/spec/javascripts/fixtures/balsamiq.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Balsamiq file', '(JavaScript fixtures)', type: :controller do
+describe "Balsamiq file", "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'balsamiq-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "balsamiq-project") }
before(:all) do
- clean_frontend_fixtures('blob/balsamiq/')
+ clean_frontend_fixtures("blob/balsamiq/")
end
- it 'blob/balsamiq/test.bmpr' do |example|
- blob = project.repository.blob_at('b89b56d79', 'files/images/balsamiq.bmpr')
+ it "blob/balsamiq/test.bmpr" do |example|
+ blob = project.repository.blob_at("b89b56d79", "files/images/balsamiq.bmpr")
- store_frontend_fixture(blob.data.force_encoding('utf-8'), example.description)
+ store_frontend_fixture(blob.data.force_encoding("utf-8"), example.description)
end
end
diff --git a/spec/javascripts/fixtures/blob.rb b/spec/javascripts/fixtures/blob.rb
index cd66d98f92a..9da7dc97ea8 100644
--- a/spec/javascripts/fixtures/blob.rb
+++ b/spec/javascripts/fixtures/blob.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::BlobController, '(JavaScript fixtures)', type: :controller do
+describe Projects::BlobController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "branches-project") }
render_views
before(:all) do
- clean_frontend_fixtures('blob/')
+ clean_frontend_fixtures("blob/")
end
before do
sign_in(admin)
- allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
+ allow(SecureRandom).to receive(:hex).and_return("securerandomhex:thereisnospoon")
end
after do
remove_repository(project)
end
- it 'blob/show.html.raw' do |example|
+ it "blob/show.html.raw" do |example|
get(:show, params: {
namespace_id: project.namespace,
project_id: project,
- id: 'add-ipython-files/files/ipython/basic.ipynb'
+ id: "add-ipython-files/files/ipython/basic.ipynb",
})
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/boards.rb b/spec/javascripts/fixtures/boards.rb
index 1d675e008ba..4950be837cc 100644
--- a/spec/javascripts/fixtures/boards.rb
+++ b/spec/javascripts/fixtures/boards.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::BoardsController, '(JavaScript fixtures)', type: :controller do
+describe Projects::BoardsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'boards-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "boards-project") }
render_views
before(:all) do
- clean_frontend_fixtures('boards/')
+ clean_frontend_fixtures("boards/")
end
before do
sign_in(admin)
end
- it 'boards/show.html.raw' do |example|
+ it "boards/show.html.raw" do |example|
get(:index, params: {
namespace_id: project.namespace,
- project_id: project
+ project_id: project,
})
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/branches.rb b/spec/javascripts/fixtures/branches.rb
index 3cc713ef90f..b229d15f2bd 100644
--- a/spec/javascripts/fixtures/branches.rb
+++ b/spec/javascripts/fixtures/branches.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::BranchesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::BranchesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "branches-project") }
render_views
before(:all) do
- clean_frontend_fixtures('branches/')
+ clean_frontend_fixtures("branches/")
end
before do
@@ -21,10 +21,10 @@ describe Projects::BranchesController, '(JavaScript fixtures)', type: :controlle
remove_repository(project)
end
- it 'branches/new_branch.html.raw' do |example|
+ it "branches/new_branch.html.raw" do |example|
get :new, params: {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/clusters.rb b/spec/javascripts/fixtures/clusters.rb
index 69dbe54ffc2..26f38a48c12 100644
--- a/spec/javascripts/fixtures/clusters.rb
+++ b/spec/javascripts/fixtures/clusters.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::ClustersController, '(JavaScript fixtures)', type: :controller do
+describe Projects::ClustersController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
let(:project) { create(:project, :repository, namespace: namespace) }
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
render_views
before(:all) do
- clean_frontend_fixtures('clusters/')
+ clean_frontend_fixtures("clusters/")
end
before do
@@ -22,11 +22,11 @@ describe Projects::ClustersController, '(JavaScript fixtures)', type: :controlle
remove_repository(project)
end
- it 'clusters/show_cluster.html.raw' do |example|
+ it "clusters/show_cluster.html.raw" do |example|
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: cluster
+ id: cluster,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/commit.rb b/spec/javascripts/fixtures/commit.rb
index 295f13b34a4..f2b0ffdf781 100644
--- a/spec/javascripts/fixtures/commit.rb
+++ b/spec/javascripts/fixtures/commit.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::CommitController, '(JavaScript fixtures)', type: :controller do
+describe Projects::CommitController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
set(:project) { create(:project, :repository) }
@@ -10,20 +10,20 @@ describe Projects::CommitController, '(JavaScript fixtures)', type: :controller
render_views
before(:all) do
- clean_frontend_fixtures('commit/')
+ clean_frontend_fixtures("commit/")
end
before do
project.add_maintainer(user)
sign_in(user)
- allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
+ allow(SecureRandom).to receive(:hex).and_return("securerandomhex:thereisnospoon")
end
- it 'commit/show.html.raw' do |example|
+ it "commit/show.html.raw" do |example|
params = {
namespace_id: project.namespace,
project_id: project,
- id: commit.id
+ id: commit.id,
}
get :show, params: params
diff --git a/spec/javascripts/fixtures/deploy_keys.rb b/spec/javascripts/fixtures/deploy_keys.rb
index a333d9c0150..1b5df440202 100644
--- a/spec/javascripts/fixtures/deploy_keys.rb
+++ b/spec/javascripts/fixtures/deploy_keys.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :controller do
+describe Projects::DeployKeysController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'todos-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "todos-project") }
let(:project2) { create(:project, :internal)}
let(:project3) { create(:project, :internal)}
let(:project4) { create(:project, :internal)}
before(:all) do
- clean_frontend_fixtures('deploy_keys/')
+ clean_frontend_fixtures("deploy_keys/")
end
before do
@@ -24,10 +24,10 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control
render_views
- it 'deploy_keys/keys.json' do |example|
+ it "deploy_keys/keys.json" do |example|
create(:rsa_deploy_key_2048, public: true)
- project_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com')
- internal_key = create(:deploy_key, key: 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com')
+ project_key = create(:deploy_key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQCdMHEHyhRjbhEZVddFn6lTWdgEy5Q6Bz4nwGB76xWZI5YT/1WJOMEW+sL5zYd31kk7sd3FJ5L9ft8zWMWrr/iWXQikC2cqZK24H1xy+ZUmrRuJD4qGAaIVoyyzBL+avL+lF8J5lg6YSw8gwJY/lX64/vnJHUlWw2n5BF8IFOWhiw== dummy@gitlab.com")
+ internal_key = create(:deploy_key, key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDNd/UJWhPrpb+b/G5oL109y57yKuCxE+WUGJGYaj7WQKsYRJmLYh1mgjrl+KVyfsWpq4ylOxIfFSnN9xBBFN8mlb0Fma5DC7YsSsibJr3MZ19ZNBprwNcdogET7aW9I0In7Wu5f2KqI6e5W/spJHCy4JVxzVMUvk6Myab0LnJ2iQ== dummy@gitlab.com")
create(:deploy_keys_project, project: project, deploy_key: project_key)
create(:deploy_keys_project, project: project2, deploy_key: internal_key)
create(:deploy_keys_project, project: project3, deploy_key: project_key)
@@ -35,7 +35,7 @@ describe Projects::DeployKeysController, '(JavaScript fixtures)', type: :control
get :index, params: {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}, format: :json
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/groups.rb b/spec/javascripts/fixtures/groups.rb
index 03136f4e661..c591d33721b 100644
--- a/spec/javascripts/fixtures/groups.rb
+++ b/spec/javascripts/fixtures/groups.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Groups (JavaScript fixtures)', type: :controller do
+describe "Groups (JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:group) { create(:group, name: 'frontend-fixtures-group', runners_token: 'runnerstoken:intabulasreferre')}
+ let(:group) { create(:group, name: "frontend-fixtures-group", runners_token: "runnerstoken:intabulasreferre")}
render_views
before(:all) do
- clean_frontend_fixtures('groups/')
+ clean_frontend_fixtures("groups/")
end
before do
@@ -17,18 +17,18 @@ describe 'Groups (JavaScript fixtures)', type: :controller do
sign_in(admin)
end
- describe GroupsController, '(JavaScript fixtures)', type: :controller do
- it 'groups/edit.html.raw' do |example|
- get :edit, params: { id: group }
+ describe GroupsController, "(JavaScript fixtures)", type: :controller do
+ it "groups/edit.html.raw" do |example|
+ get :edit, params: {id: group}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
- describe Groups::Settings::CiCdController, '(JavaScript fixtures)', type: :controller do
- it 'groups/ci_cd_settings.html.raw' do |example|
- get :show, params: { group_id: group }
+ describe Groups::Settings::CiCdController, "(JavaScript fixtures)", type: :controller do
+ it "groups/ci_cd_settings.html.raw" do |example|
+ get :show, params: {group_id: group}
expect(response).to be_success
store_frontend_fixture(response, example.description)
diff --git a/spec/javascripts/fixtures/issues.rb b/spec/javascripts/fixtures/issues.rb
index 9b8e90c2a43..75f40b1d375 100644
--- a/spec/javascripts/fixtures/issues.rb
+++ b/spec/javascripts/fixtures/issues.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::IssuesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
- let(:admin) { create(:admin, feed_token: 'feedtoken:coldfeed') }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'issues-project') }
+ let(:admin) { create(:admin, feed_token: "feedtoken:coldfeed") }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "issues-project") }
render_views
before(:all) do
- clean_frontend_fixtures('issues/')
+ clean_frontend_fixtures("issues/")
end
before do
@@ -21,31 +21,31 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller
remove_repository(project)
end
- it 'issues/open-issue.html.raw' do |example|
+ it "issues/open-issue.html.raw" do |example|
render_issue(example.description, create(:issue, project: project))
end
- it 'issues/closed-issue.html.raw' do |example|
+ it "issues/closed-issue.html.raw" do |example|
render_issue(example.description, create(:closed_issue, project: project))
end
- it 'issues/issue-with-task-list.html.raw' do |example|
- issue = create(:issue, project: project, description: '- [ ] Task List Item')
+ it "issues/issue-with-task-list.html.raw" do |example|
+ issue = create(:issue, project: project, description: "- [ ] Task List Item")
render_issue(example.description, issue)
end
- it 'issues/issue_with_comment.html.raw' do |example|
+ it "issues/issue_with_comment.html.raw" do |example|
issue = create(:issue, project: project)
- create(:note, project: project, noteable: issue, note: '- [ ] Task List Item').save
+ create(:note, project: project, noteable: issue, note: "- [ ] Task List Item").save
render_issue(example.description, issue)
end
- it 'issues/issue_list.html.raw' do |example|
+ it "issues/issue_list.html.raw" do |example|
create(:issue, project: project)
get :index, params: {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
expect(response).to be_success
@@ -58,7 +58,7 @@ describe Projects::IssuesController, '(JavaScript fixtures)', type: :controller
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: issue.to_param
+ id: issue.to_param,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/jobs.rb b/spec/javascripts/fixtures/jobs.rb
index 433bb690a1c..5b31ddaaa8d 100644
--- a/spec/javascripts/fixtures/jobs.rb
+++ b/spec/javascripts/fixtures/jobs.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do
+describe Projects::JobsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'builds-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "builds-project") }
let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.id) }
- let!(:build_with_artifacts) { create(:ci_build, :success, :artifacts, :trace_artifact, pipeline: pipeline, stage: 'test', artifacts_expire_at: Time.now + 18.months) }
- let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline, stage: 'build') }
- let!(:pending_build) { create(:ci_build, :pending, pipeline: pipeline, stage: 'deploy') }
+ let!(:build_with_artifacts) { create(:ci_build, :success, :artifacts, :trace_artifact, pipeline: pipeline, stage: "test", artifacts_expire_at: Time.now + 18.months) }
+ let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline, stage: "build") }
+ let!(:pending_build) { create(:ci_build, :pending, pipeline: pipeline, stage: "deploy") }
let!(:delayed_job) do
create(:ci_build, :scheduled,
- pipeline: pipeline,
- name: 'delayed job',
- stage: 'test')
+ pipeline: pipeline,
+ name: "delayed job",
+ stage: "test")
end
render_views
before(:all) do
- clean_frontend_fixtures('builds/')
- clean_frontend_fixtures('jobs/')
+ clean_frontend_fixtures("builds/")
+ clean_frontend_fixtures("jobs/")
end
before do
@@ -32,22 +32,22 @@ describe Projects::JobsController, '(JavaScript fixtures)', type: :controller do
remove_repository(project)
end
- it 'builds/build-with-artifacts.html.raw' do |example|
+ it "builds/build-with-artifacts.html.raw" do |example|
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: build_with_artifacts.to_param
+ id: build_with_artifacts.to_param,
}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
- it 'jobs/delayed.json' do |example|
+ it "jobs/delayed.json" do |example|
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: delayed_job.to_param
+ id: delayed_job.to_param,
}, format: :json
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/labels.rb b/spec/javascripts/fixtures/labels.rb
index 9420194e675..ca2daed521e 100644
--- a/spec/javascripts/fixtures/labels.rb
+++ b/spec/javascripts/fixtures/labels.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Labels (JavaScript fixtures)' do
+describe "Labels (JavaScript fixtures)" do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:group) { create(:group, name: 'frontend-fixtures-group' )}
- let(:project) { create(:project_empty_repo, namespace: group, path: 'labels-project') }
+ let(:group) { create(:group, name: "frontend-fixtures-group")}
+ let(:project) { create(:project_empty_repo, namespace: group, path: "labels-project") }
- let!(:project_label_bug) { create(:label, project: project, title: 'bug', color: '#FF0000') }
- let!(:project_label_enhancement) { create(:label, project: project, title: 'enhancement', color: '#00FF00') }
- let!(:project_label_feature) { create(:label, project: project, title: 'feature', color: '#0000FF') }
+ let!(:project_label_bug) { create(:label, project: project, title: "bug", color: "#FF0000") }
+ let!(:project_label_enhancement) { create(:label, project: project, title: "enhancement", color: "#00FF00") }
+ let!(:project_label_feature) { create(:label, project: project, title: "feature", color: "#0000FF") }
- let!(:group_label_roses) { create(:group_label, group: group, title: 'roses', color: '#FF0000') }
- let!(:groub_label_space) { create(:group_label, group: group, title: 'some space', color: '#FFFFFF') }
- let!(:groub_label_violets) { create(:group_label, group: group, title: 'violets', color: '#0000FF') }
+ let!(:group_label_roses) { create(:group_label, group: group, title: "roses", color: "#FF0000") }
+ let!(:groub_label_space) { create(:group_label, group: group, title: "some space", color: "#FFFFFF") }
+ let!(:groub_label_violets) { create(:group_label, group: group, title: "violets", color: "#0000FF") }
before(:all) do
- clean_frontend_fixtures('labels/')
+ clean_frontend_fixtures("labels/")
end
after do
remove_repository(project)
end
- describe Groups::LabelsController, '(JavaScript fixtures)', type: :controller do
+ describe Groups::LabelsController, "(JavaScript fixtures)", type: :controller do
render_views
before do
sign_in(admin)
end
- it 'labels/group_labels.json' do |example|
+ it "labels/group_labels.json" do |example|
get :index, params: {
- group_id: group
- }, format: 'json'
+ group_id: group,
+ }, format: "json"
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
- describe Projects::LabelsController, '(JavaScript fixtures)', type: :controller do
+ describe Projects::LabelsController, "(JavaScript fixtures)", type: :controller do
render_views
before do
sign_in(admin)
end
- it 'labels/project_labels.json' do |example|
+ it "labels/project_labels.json" do |example|
get :index, params: {
namespace_id: group,
- project_id: project
- }, format: 'json'
+ project_id: project,
+ }, format: "json"
expect(response).to be_success
store_frontend_fixture(response, example.description)
diff --git a/spec/javascripts/fixtures/merge_requests.rb b/spec/javascripts/fixtures/merge_requests.rb
index eb37be87e1d..784c693578a 100644
--- a/spec/javascripts/fixtures/merge_requests.rb
+++ b/spec/javascripts/fixtures/merge_requests.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do
+describe Projects::MergeRequestsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
- let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "merge-requests-project") }
+ let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: "- [ ] Task List Item") }
let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) }
let(:pipeline) do
create(
@@ -30,31 +30,31 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
render_views
before(:all) do
- clean_frontend_fixtures('merge_requests/')
+ clean_frontend_fixtures("merge_requests/")
end
before do
sign_in(admin)
- allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
+ allow(Discussion).to receive(:build_discussion_id).and_return(["discussionid:ceterumcenseo"])
end
after do
remove_repository(project)
end
- it 'merge_requests/merge_request_of_current_user.html.raw' do |example|
+ it "merge_requests/merge_request_of_current_user.html.raw" do |example|
merge_request.update(author: admin)
render_merge_request(example.description, merge_request)
end
- it 'merge_requests/merge_request_with_task_list.html.raw' do |example|
+ it "merge_requests/merge_request_with_task_list.html.raw" do |example|
create(:ci_build, :pending, pipeline: pipeline)
render_merge_request(example.description, merge_request)
end
- it 'merge_requests/merged_merge_request.html.raw' do |example|
+ it "merge_requests/merged_merge_request.html.raw" do |example|
expect_next_instance_of(MergeRequest) do |merge_request|
allow(merge_request).to receive(:source_branch_exists?).and_return(true)
allow(merge_request).to receive(:can_remove_source_branch?).and_return(true)
@@ -62,35 +62,35 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
render_merge_request(example.description, merged_merge_request)
end
- it 'merge_requests/diff_comment.html.raw' do |example|
+ it "merge_requests/diff_comment.html.raw" do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
render_merge_request(example.description, merge_request)
end
- it 'merge_requests/merge_request_with_comment.html.raw' do |example|
- create(:note_on_merge_request, author: admin, project: project, noteable: merge_request, note: '- [ ] Task List Item')
+ it "merge_requests/merge_request_with_comment.html.raw" do |example|
+ create(:note_on_merge_request, author: admin, project: project, noteable: merge_request, note: "- [ ] Task List Item")
render_merge_request(example.description, merge_request)
end
- it 'merge_requests/discussions.json' do |example|
+ it "merge_requests/discussions.json" do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
render_discussions_json(merge_request, example.description)
end
- it 'merge_requests/diff_discussion.json' do |example|
+ it "merge_requests/diff_discussion.json" do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
render_discussions_json(merge_request, example.description)
end
- it 'merge_requests/resolved_diff_discussion.json' do |example|
+ it "merge_requests/resolved_diff_discussion.json" do |example|
note = create(:discussion_note_on_merge_request, :resolved, project: project, author: admin, position: position, noteable: merge_request)
create(:system_note, project: project, author: admin, noteable: merge_request, discussion_id: note.discussion.id)
render_discussions_json(merge_request, example.description)
end
- context 'with image diff' do
+ context "with image diff" do
let(:merge_request2) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, title: "Added images") }
let(:image_path) { "files/images/ee_repo_logo.png" }
let(:image_position) do
@@ -106,7 +106,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
)
end
- it 'merge_requests/image_diff_discussion.json' do |example|
+ it "merge_requests/image_diff_discussion.json" do |example|
create(:diff_note_on_merge_request, project: project, noteable: merge_request2, position: image_position)
render_discussions_json(merge_request2, example.description)
end
@@ -118,7 +118,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
get :discussions, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: merge_request.to_param
+ id: merge_request.to_param,
}, format: :json
store_frontend_fixture(response, fixture_file_name)
@@ -128,7 +128,7 @@ describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :cont
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: merge_request.to_param
+ id: merge_request.to_param,
}, format: :html
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/merge_requests_diffs.rb b/spec/javascripts/fixtures/merge_requests_diffs.rb
index 57462e74bb2..93a17675503 100644
--- a/spec/javascripts/fixtures/merge_requests_diffs.rb
+++ b/spec/javascripts/fixtures/merge_requests_diffs.rb
@@ -1,13 +1,12 @@
+require "spec_helper"
-require 'spec_helper'
-
-describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do
+describe Projects::MergeRequests::DiffsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
- let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "merge-requests-project") }
+ let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: "- [ ] Task List Item") }
let(:path) { "files/ruby/popen.rb" }
let(:selected_commit) { merge_request.all_commits[0] }
let(:position) do
@@ -23,7 +22,7 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type
render_views
before(:all) do
- clean_frontend_fixtures('merge_request_diffs/')
+ clean_frontend_fixtures("merge_request_diffs/")
end
before do
@@ -34,7 +33,7 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type
remove_repository(project)
end
- it 'merge_request_diffs/with_commit.json' do |example|
+ it "merge_request_diffs/with_commit.json" do |example|
# Create a user that matches the selected commit author
# This is so that the "author" information will be populated
create(:user, email: selected_commit.author_email, name: selected_commit.author_name)
@@ -42,27 +41,27 @@ describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type
render_merge_request(example.description, merge_request, commit_id: selected_commit.sha)
end
- it 'merge_request_diffs/inline_changes_tab_with_comments.json' do |example|
+ it "merge_request_diffs/inline_changes_tab_with_comments.json" do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
render_merge_request(example.description, merge_request)
end
- it 'merge_request_diffs/parallel_changes_tab_with_comments.json' do |example|
+ it "merge_request_diffs/parallel_changes_tab_with_comments.json" do |example|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
- render_merge_request(example.description, merge_request, view: 'parallel')
+ render_merge_request(example.description, merge_request, view: "parallel")
end
private
- def render_merge_request(fixture_file_name, merge_request, view: 'inline', **extra_params)
+ def render_merge_request(fixture_file_name, merge_request, view: "inline", **extra_params)
get :show, params: {
namespace_id: project.namespace.to_param,
project_id: project,
id: merge_request.to_param,
view: view,
- **extra_params
+ **extra_params,
}, format: :json
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/pdf.rb b/spec/javascripts/fixtures/pdf.rb
index ef9976b9fd3..5a60c1465a5 100644
--- a/spec/javascripts/fixtures/pdf.rb
+++ b/spec/javascripts/fixtures/pdf.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'PDF file', '(JavaScript fixtures)', type: :controller do
+describe "PDF file", "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'pdf-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "pdf-project") }
before(:all) do
- clean_frontend_fixtures('blob/pdf/')
+ clean_frontend_fixtures("blob/pdf/")
end
- it 'blob/pdf/test.pdf' do |example|
- blob = project.repository.blob_at('e774ebd33', 'files/pdf/test.pdf')
+ it "blob/pdf/test.pdf" do |example|
+ blob = project.repository.blob_at("e774ebd33", "files/pdf/test.pdf")
store_frontend_fixture(blob.data.force_encoding("utf-8"), example.description)
end
diff --git a/spec/javascripts/fixtures/pipeline_schedules.rb b/spec/javascripts/fixtures/pipeline_schedules.rb
index 05d79ec8de9..9a551e99ed6 100644
--- a/spec/javascripts/fixtures/pipeline_schedules.rb
+++ b/spec/javascripts/fixtures/pipeline_schedules.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::PipelineSchedulesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::PipelineSchedulesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
let(:project) { create(:project, :public, :repository) }
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: admin) }
let!(:pipeline_schedule_populated) { create(:ci_pipeline_schedule, project: project, owner: admin) }
- let!(:pipeline_schedule_variable1) { create(:ci_pipeline_schedule_variable, key: 'foo', value: 'foovalue', pipeline_schedule: pipeline_schedule_populated) }
- let!(:pipeline_schedule_variable2) { create(:ci_pipeline_schedule_variable, key: 'bar', value: 'barvalue', pipeline_schedule: pipeline_schedule_populated) }
+ let!(:pipeline_schedule_variable1) { create(:ci_pipeline_schedule_variable, key: "foo", value: "foovalue", pipeline_schedule: pipeline_schedule_populated) }
+ let!(:pipeline_schedule_variable2) { create(:ci_pipeline_schedule_variable, key: "bar", value: "barvalue", pipeline_schedule: pipeline_schedule_populated) }
render_views
before(:all) do
- clean_frontend_fixtures('pipeline_schedules/')
+ clean_frontend_fixtures("pipeline_schedules/")
end
before do
sign_in(admin)
end
- it 'pipeline_schedules/edit.html.raw' do |example|
+ it "pipeline_schedules/edit.html.raw" do |example|
get :edit, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: pipeline_schedule.id
+ id: pipeline_schedule.id,
}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
- it 'pipeline_schedules/edit_with_variables.html.raw' do |example|
+ it "pipeline_schedules/edit_with_variables.html.raw" do |example|
get :edit, params: {
namespace_id: project.namespace.to_param,
project_id: project,
- id: pipeline_schedule_populated.id
+ id: pipeline_schedule_populated.id,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/pipelines.rb b/spec/javascripts/fixtures/pipelines.rb
index 42b552e81c0..6081b5dfb59 100644
--- a/spec/javascripts/fixtures/pipelines.rb
+++ b/spec/javascripts/fixtures/pipelines.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::PipelinesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::PipelinesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'pipelines-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "pipelines-project") }
let(:commit) { create(:commit, project: project) }
let(:commit_without_author) { RepoHelpers.another_sample_commit }
let!(:user) { create(:user, email: commit.author_email) }
let!(:pipeline) { create(:ci_pipeline, project: project, sha: commit.id, user: user) }
let!(:pipeline_without_author) { create(:ci_pipeline, project: project, sha: commit_without_author.id) }
- let!(:pipeline_without_commit) { create(:ci_pipeline, project: project, sha: '0000') }
+ let!(:pipeline_without_commit) { create(:ci_pipeline, project: project, sha: "0000") }
render_views
before(:all) do
- clean_frontend_fixtures('pipelines/')
+ clean_frontend_fixtures("pipelines/")
end
before do
sign_in(admin)
end
- it 'pipelines/pipelines.json' do |example|
+ it "pipelines/pipelines.json" do |example|
get :index, params: {
namespace_id: namespace,
- project_id: project
+ project_id: project,
}, format: :json
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/projects.rb b/spec/javascripts/fixtures/projects.rb
index 85f02923804..ca7ef0c8375 100644
--- a/spec/javascripts/fixtures/projects.rb
+++ b/spec/javascripts/fixtures/projects.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Projects (JavaScript fixtures)', type: :controller do
+describe "Projects (JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
- runners_token = 'runnerstoken:intabulasreferre'
+ runners_token = "runnerstoken:intabulasreferre"
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, namespace: namespace, path: 'builds-project', runners_token: runners_token) }
- let(:project_with_repo) { create(:project, :repository, description: 'Code and stuff') }
- let(:project_variable_populated) { create(:project, namespace: namespace, path: 'builds-project2', runners_token: runners_token) }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, namespace: namespace, path: "builds-project", runners_token: runners_token) }
+ let(:project_with_repo) { create(:project, :repository, description: "Code and stuff") }
+ let(:project_variable_populated) { create(:project, namespace: namespace, path: "builds-project2", runners_token: runners_token) }
render_views
before(:all) do
- clean_frontend_fixtures('projects/')
+ clean_frontend_fixtures("projects/")
end
before do
project.add_maintainer(admin)
sign_in(admin)
- allow(SecureRandom).to receive(:hex).and_return('securerandomhex:thereisnospoon')
+ allow(SecureRandom).to receive(:hex).and_return("securerandomhex:thereisnospoon")
end
after do
remove_repository(project)
end
- describe ProjectsController, '(JavaScript fixtures)', type: :controller do
- it 'projects/dashboard.html.raw' do |example|
+ describe ProjectsController, "(JavaScript fixtures)", type: :controller do
+ it "projects/dashboard.html.raw" do |example|
get :show, params: {
namespace_id: project.namespace.to_param,
- id: project
+ id: project,
}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
- it 'projects/overview.html.raw' do |example|
+ it "projects/overview.html.raw" do |example|
get :show, params: {
namespace_id: project_with_repo.namespace.to_param,
- id: project_with_repo
+ id: project_with_repo,
}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
- it 'projects/edit.html.raw' do |example|
+ it "projects/edit.html.raw" do |example|
get :edit, params: {
namespace_id: project.namespace.to_param,
- id: project
+ id: project,
}
expect(response).to be_success
@@ -59,24 +59,24 @@ describe 'Projects (JavaScript fixtures)', type: :controller do
end
end
- describe Projects::Settings::CiCdController, '(JavaScript fixtures)', type: :controller do
- it 'projects/ci_cd_settings.html.raw' do |example|
+ describe Projects::Settings::CiCdController, "(JavaScript fixtures)", type: :controller do
+ it "projects/ci_cd_settings.html.raw" do |example|
get :show, params: {
namespace_id: project.namespace.to_param,
- project_id: project
+ project_id: project,
}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
- it 'projects/ci_cd_settings_with_variables.html.raw' do |example|
+ it "projects/ci_cd_settings_with_variables.html.raw" do |example|
create(:ci_variable, project: project_variable_populated)
create(:ci_variable, project: project_variable_populated)
get :show, params: {
namespace_id: project_variable_populated.namespace.to_param,
- project_id: project_variable_populated
+ project_id: project_variable_populated,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/prometheus_service.rb b/spec/javascripts/fixtures/prometheus_service.rb
index 746fbfd66dd..d97f98e99f6 100644
--- a/spec/javascripts/fixtures/prometheus_service.rb
+++ b/spec/javascripts/fixtures/prometheus_service.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::ServicesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "services-project") }
let!(:service) { create(:prometheus_service, project: project) }
render_views
before(:all) do
- clean_frontend_fixtures('services/prometheus')
+ clean_frontend_fixtures("services/prometheus")
end
before do
@@ -22,11 +22,11 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle
remove_repository(project)
end
- it 'services/prometheus/prometheus_service.html.raw' do |example|
+ it "services/prometheus/prometheus_service.html.raw" do |example|
get :edit, params: {
namespace_id: namespace,
project_id: project,
- id: service.to_param
+ id: service.to_param,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/raw.rb b/spec/javascripts/fixtures/raw.rb
index 82770beb39b..8308d90cdb0 100644
--- a/spec/javascripts/fixtures/raw.rb
+++ b/spec/javascripts/fixtures/raw.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Raw files', '(JavaScript fixtures)', type: :controller do
+describe "Raw files", "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'raw-project') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "raw-project") }
before(:all) do
- clean_frontend_fixtures('blob/notebook/')
+ clean_frontend_fixtures("blob/notebook/")
end
after do
remove_repository(project)
end
- it 'blob/notebook/basic.json' do |example|
- blob = project.repository.blob_at('6d85bb69', 'files/ipython/basic.ipynb')
+ it "blob/notebook/basic.json" do |example|
+ blob = project.repository.blob_at("6d85bb69", "files/ipython/basic.ipynb")
store_frontend_fixture(blob.data, example.description)
end
- it 'blob/notebook/worksheets.json' do |example|
- blob = project.repository.blob_at('6d85bb69', 'files/ipython/worksheets.ipynb')
+ it "blob/notebook/worksheets.json" do |example|
+ blob = project.repository.blob_at("6d85bb69", "files/ipython/worksheets.ipynb")
store_frontend_fixture(blob.data, example.description)
end
- it 'blob/notebook/math.json' do |example|
- blob = project.repository.blob_at('93ee732', 'files/ipython/math.ipynb')
+ it "blob/notebook/math.json" do |example|
+ blob = project.repository.blob_at("93ee732", "files/ipython/math.ipynb")
store_frontend_fixture(blob.data, example.description)
end
diff --git a/spec/javascripts/fixtures/search.rb b/spec/javascripts/fixtures/search.rb
index 703cd3d49fa..8450a36275b 100644
--- a/spec/javascripts/fixtures/search.rb
+++ b/spec/javascripts/fixtures/search.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe SearchController, '(JavaScript fixtures)', type: :controller do
+describe SearchController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
render_views
before(:all) do
- clean_frontend_fixtures('search/')
+ clean_frontend_fixtures("search/")
end
- it 'search/show.html.raw' do |example|
+ it "search/show.html.raw" do |example|
get :show
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/services.rb b/spec/javascripts/fixtures/services.rb
index 6ccd74a07ff..90b953cf39f 100644
--- a/spec/javascripts/fixtures/services.rb
+++ b/spec/javascripts/fixtures/services.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::ServicesController, '(JavaScript fixtures)', type: :controller do
+describe Projects::ServicesController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'services-project') }
- let!(:service) { create(:custom_issue_tracker_service, project: project, title: 'Custom Issue Tracker') }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "services-project") }
+ let!(:service) { create(:custom_issue_tracker_service, project: project, title: "Custom Issue Tracker") }
render_views
before(:all) do
- clean_frontend_fixtures('services/')
+ clean_frontend_fixtures("services/")
end
before do
@@ -22,11 +22,11 @@ describe Projects::ServicesController, '(JavaScript fixtures)', type: :controlle
remove_repository(project)
end
- it 'services/edit_service.html.raw' do |example|
+ it "services/edit_service.html.raw" do |example|
get :edit, params: {
namespace_id: namespace,
project_id: project,
- id: service.to_param
+ id: service.to_param,
}
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/sessions.rb b/spec/javascripts/fixtures/sessions.rb
index e90a58e8c54..5e0776a58d8 100644
--- a/spec/javascripts/fixtures/sessions.rb
+++ b/spec/javascripts/fixtures/sessions.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Sessions (JavaScript fixtures)' do
+describe "Sessions (JavaScript fixtures)" do
include JavaScriptFixturesHelpers
before(:all) do
- clean_frontend_fixtures('sessions/')
+ clean_frontend_fixtures("sessions/")
end
- describe SessionsController, '(JavaScript fixtures)', type: :controller do
+ describe SessionsController, "(JavaScript fixtures)", type: :controller do
include DeviseHelpers
render_views
@@ -16,7 +16,7 @@ describe 'Sessions (JavaScript fixtures)' do
set_devise_mapping(context: @request)
end
- it 'sessions/new.html.raw' do |example|
+ it "sessions/new.html.raw" do |example|
get :new
expect(response).to be_success
diff --git a/spec/javascripts/fixtures/snippet.rb b/spec/javascripts/fixtures/snippet.rb
index bcd6546f3df..4e53b1c1ace 100644
--- a/spec/javascripts/fixtures/snippet.rb
+++ b/spec/javascripts/fixtures/snippet.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe SnippetsController, '(JavaScript fixtures)', type: :controller do
+describe SnippetsController, "(JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project, :repository, namespace: namespace, path: 'branches-project') }
- let(:snippet) { create(:personal_snippet, title: 'snippet.md', content: '# snippet', file_name: 'snippet.md', author: admin) }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project, :repository, namespace: namespace, path: "branches-project") }
+ let(:snippet) { create(:personal_snippet, title: "snippet.md", content: "# snippet", file_name: "snippet.md", author: admin) }
render_views
before(:all) do
- clean_frontend_fixtures('snippets/')
+ clean_frontend_fixtures("snippets/")
end
before do
sign_in(admin)
- allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
+ allow(Discussion).to receive(:build_discussion_id).and_return(["discussionid:ceterumcenseo"])
end
after do
remove_repository(project)
end
- it 'snippets/show.html.raw' do |example|
- create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: '- [ ] Task List Item')
+ it "snippets/show.html.raw" do |example|
+ create(:discussion_note_on_snippet, noteable: snippet, project: project, author: admin, note: "- [ ] Task List Item")
- get(:show, params: { id: snippet.to_param })
+ get(:show, params: {id: snippet.to_param})
expect(response).to be_success
store_frontend_fixture(response, example.description)
diff --git a/spec/javascripts/fixtures/static_fixtures.rb b/spec/javascripts/fixtures/static_fixtures.rb
index 4569f16f0ca..e669d0d6a0b 100644
--- a/spec/javascripts/fixtures/static_fixtures.rb
+++ b/spec/javascripts/fixtures/static_fixtures.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
-describe ApplicationController, '(Static JavaScript fixtures)', type: :controller do
+describe ApplicationController, "(Static JavaScript fixtures)", type: :controller do
include JavaScriptFixturesHelpers
before(:all) do
- clean_frontend_fixtures('static/')
+ clean_frontend_fixtures("static/")
end
fixtures_path = File.expand_path(JavaScriptFixturesHelpers::FIXTURE_PATH, Rails.root)
- haml_fixtures = Dir.glob(File.expand_path('**/*.haml', fixtures_path)).map do |file_path|
- file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, '')
- end
+ haml_fixtures = Dir.glob(File.expand_path("**/*.haml", fixtures_path)).map { |file_path|
+ file_path.sub(/\A#{fixtures_path}#{File::SEPARATOR}/, "")
+ }
haml_fixtures.each do |template_file_name|
- it "static/#{template_file_name.sub(/\.haml\z/, '.raw')}" do |example|
+ it "static/#{template_file_name.sub(/\.haml\z/, ".raw")}" do |example|
fixture_file_name = example.description
rendered = render_template(template_file_name)
store_frontend_fixture(rendered, fixture_file_name)
diff --git a/spec/javascripts/fixtures/todos.rb b/spec/javascripts/fixtures/todos.rb
index b5f6620873b..31144192ac2 100644
--- a/spec/javascripts/fixtures/todos.rb
+++ b/spec/javascripts/fixtures/todos.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Todos (JavaScript fixtures)' do
+describe "Todos (JavaScript fixtures)" do
include JavaScriptFixturesHelpers
let(:admin) { create(:admin) }
- let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
- let(:project) { create(:project_empty_repo, namespace: namespace, path: 'todos-project') }
- let(:issue_1) { create(:issue, title: 'issue_1', project: project) }
+ let(:namespace) { create(:namespace, name: "frontend-fixtures")}
+ let(:project) { create(:project_empty_repo, namespace: namespace, path: "todos-project") }
+ let(:issue_1) { create(:issue, title: "issue_1", project: project) }
let!(:todo_1) { create(:todo, user: admin, project: project, target: issue_1, created_at: 5.hours.ago) }
- let(:issue_2) { create(:issue, title: 'issue_2', project: project) }
+ let(:issue_2) { create(:issue, title: "issue_2", project: project) }
let!(:todo_2) { create(:todo, :done, user: admin, project: project, target: issue_2, created_at: 50.hours.ago) }
before(:all) do
- clean_frontend_fixtures('todos/')
+ clean_frontend_fixtures("todos/")
end
after do
remove_repository(project)
end
- describe Dashboard::TodosController, '(JavaScript fixtures)', type: :controller do
+ describe Dashboard::TodosController, "(JavaScript fixtures)", type: :controller do
render_views
before do
sign_in(admin)
end
- it 'todos/todos.html.raw' do |example|
+ it "todos/todos.html.raw" do |example|
get :index
expect(response).to be_success
@@ -34,20 +34,20 @@ describe 'Todos (JavaScript fixtures)' do
end
end
- describe Projects::TodosController, '(JavaScript fixtures)', type: :controller do
+ describe Projects::TodosController, "(JavaScript fixtures)", type: :controller do
render_views
before do
sign_in(admin)
end
- it 'todos/todos.json' do |example|
+ it "todos/todos.json" do |example|
post :create, params: {
namespace_id: namespace,
project_id: project,
- issuable_type: 'issue',
- issuable_id: issue_2.id
- }, format: 'json'
+ issuable_type: "issue",
+ issuable_id: issue_2.id,
+ }, format: "json"
expect(response).to be_success
store_frontend_fixture(response, example.description)
diff --git a/spec/javascripts/fixtures/u2f.rb b/spec/javascripts/fixtures/u2f.rb
index 5cdbadef639..940e5e926b5 100644
--- a/spec/javascripts/fixtures/u2f.rb
+++ b/spec/javascripts/fixtures/u2f.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-context 'U2F' do
+context "U2F" do
include JavaScriptFixturesHelpers
- let(:user) { create(:user, :two_factor_via_u2f, otp_secret: 'otpsecret:coolkids') }
+ let(:user) { create(:user, :two_factor_via_u2f, otp_secret: "otpsecret:coolkids") }
before(:all) do
- clean_frontend_fixtures('u2f/')
+ clean_frontend_fixtures("u2f/")
end
- describe SessionsController, '(JavaScript fixtures)', type: :controller do
+ describe SessionsController, "(JavaScript fixtures)", type: :controller do
include DeviseHelpers
render_views
@@ -18,25 +18,25 @@ context 'U2F' do
set_devise_mapping(context: @request)
end
- it 'u2f/authenticate.html.raw' do |example|
+ it "u2f/authenticate.html.raw" do |example|
allow(controller).to receive(:find_user).and_return(user)
- post :create, params: { user: { login: user.username, password: user.password } }
+ post :create, params: {user: {login: user.username, password: user.password}}
expect(response).to be_success
store_frontend_fixture(response, example.description)
end
end
- describe Profiles::TwoFactorAuthsController, '(JavaScript fixtures)', type: :controller do
+ describe Profiles::TwoFactorAuthsController, "(JavaScript fixtures)", type: :controller do
render_views
before do
sign_in(user)
- allow_any_instance_of(Profiles::TwoFactorAuthsController).to receive(:build_qr_code).and_return('qrcode:blackandwhitesquares')
+ allow_any_instance_of(Profiles::TwoFactorAuthsController).to receive(:build_qr_code).and_return("qrcode:blackandwhitesquares")
end
- it 'u2f/register.html.raw' do |example|
+ it "u2f/register.html.raw" do |example|
get :show
expect(response).to be_success
diff --git a/spec/lib/after_commit_queue_spec.rb b/spec/lib/after_commit_queue_spec.rb
index 6e7c2ec2363..63ec91750da 100644
--- a/spec/lib/after_commit_queue_spec.rb
+++ b/spec/lib/after_commit_queue_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe AfterCommitQueue do
- it 'runs after transaction is committed' do
+ it "runs after transaction is committed" do
called = false
test_proc = proc { called = true }
diff --git a/spec/lib/api/api_spec.rb b/spec/lib/api/api_spec.rb
index ceef0b41e59..62686fb9792 100644
--- a/spec/lib/api/api_spec.rb
+++ b/spec/lib/api/api_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe API::API do
- describe '.prefix' do
- it 'has a prefix defined' do
+ describe ".prefix" do
+ it "has a prefix defined" do
expect(described_class.prefix).to eq :api
end
end
- describe '.version' do
- it 'uses most recent version of the API' do
- expect(described_class.version).to eq 'v4'
+ describe ".version" do
+ it "uses most recent version of the API" do
+ expect(described_class.version).to eq "v4"
end
end
- describe '.versions' do
- it 'returns all available versions' do
+ describe ".versions" do
+ it "returns all available versions" do
expect(described_class.versions).to eq %w[v3 v4]
end
end
diff --git a/spec/lib/api/helpers/custom_validators_spec.rb b/spec/lib/api/helpers/custom_validators_spec.rb
index 41e6fb47b11..efda9748aa5 100644
--- a/spec/lib/api/helpers/custom_validators_spec.rb
+++ b/spec/lib/api/helpers/custom_validators_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers::CustomValidators do
let(:scope) do
@@ -11,41 +11,41 @@ describe API::Helpers::CustomValidators do
describe API::Helpers::CustomValidators::Absence do
subject do
- described_class.new(['test'], {}, false, scope.new)
+ described_class.new(["test"], {}, false, scope.new)
end
- context 'empty param' do
- it 'does not raise a validation error' do
+ context "empty param" do
+ it "does not raise a validation error" do
expect_no_validation_error({})
end
end
- context 'invalid parameters' do
- it 'should raise a validation error' do
- expect_validation_error({ 'test' => 'some_value' })
+ context "invalid parameters" do
+ it "should raise a validation error" do
+ expect_validation_error({"test" => "some_value"})
end
end
end
describe API::Helpers::CustomValidators::IntegerNoneAny do
subject do
- described_class.new(['test'], {}, false, scope.new)
+ described_class.new(["test"], {}, false, scope.new)
end
- context 'valid parameters' do
- it 'does not raise a validation error' do
- expect_no_validation_error({ 'test' => 2 })
- expect_no_validation_error({ 'test' => 100 })
- expect_no_validation_error({ 'test' => 'None' })
- expect_no_validation_error({ 'test' => 'Any' })
- expect_no_validation_error({ 'test' => 'none' })
- expect_no_validation_error({ 'test' => 'any' })
+ context "valid parameters" do
+ it "does not raise a validation error" do
+ expect_no_validation_error({"test" => 2})
+ expect_no_validation_error({"test" => 100})
+ expect_no_validation_error({"test" => "None"})
+ expect_no_validation_error({"test" => "Any"})
+ expect_no_validation_error({"test" => "none"})
+ expect_no_validation_error({"test" => "any"})
end
end
- context 'invalid parameters' do
- it 'should raise a validation error' do
- expect_validation_error({ 'test' => 'some_other_string' })
+ context "invalid parameters" do
+ it "should raise a validation error" do
+ expect_validation_error({"test" => "some_other_string"})
end
end
end
@@ -59,6 +59,6 @@ describe API::Helpers::CustomValidators do
end
def validate_test_param!(params)
- subject.validate_param!('test', params)
+ subject.validate_param!("test", params)
end
end
diff --git a/spec/lib/api/helpers/pagination_spec.rb b/spec/lib/api/helpers/pagination_spec.rb
index 6e215ea1561..ca7650aaf34 100644
--- a/spec/lib/api/helpers/pagination_spec.rb
+++ b/spec/lib/api/helpers/pagination_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers::Pagination do
let(:resource) { Project.all }
@@ -9,13 +9,13 @@ describe API::Helpers::Pagination do
Class.new.include(described_class).new
end
- describe '#paginate (keyset pagination)' do
- let(:value) { spy('return value') }
+ describe "#paginate (keyset pagination)" do
+ let(:value) { spy("return value") }
let(:base_query) do
{
- pagination: 'keyset',
- foo: 'bar',
- bar: 'baz'
+ pagination: "keyset",
+ foo: "bar",
+ bar: "baz",
}
end
let(:query) { base_query }
@@ -26,31 +26,31 @@ describe API::Helpers::Pagination do
allow(subject).to receive(:request).and_return(double(url: "#{incoming_api_projects_url}?#{query.to_query}"))
end
- context 'when resource can be paginated' do
+ context "when resource can be paginated" do
let!(:projects) do
[
- create(:project, name: 'One'),
- create(:project, name: 'Two'),
- create(:project, name: 'Three')
+ create(:project, name: "One"),
+ create(:project, name: "Two"),
+ create(:project, name: "Three"),
].sort_by { |e| -e.id } # sort by id desc (this is the default sort order for the API)
end
- describe 'first page' do
+ describe "first page" do
let(:query) { base_query.merge(per_page: 2) }
- it 'returns appropriate amount of resources' do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 2
end
- it 'returns the first two records (by id desc)' do
+ it "returns the first two records (by id desc)" do
expect(subject.paginate(resource)).to eq(projects[0..1])
end
- it 'adds appropriate headers' do
- expect_header('X-Per-Page', '2')
- expect_header('X-Next-Page', "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[1].id).to_query}")
+ it "adds appropriate headers" do
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Next-Page", "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[1].id).to_query}")
- expect_header('Link', anything) do |_key, val|
+ expect_header("Link", anything) do |_key, val|
expect(val).to include('rel="next"')
end
@@ -58,22 +58,22 @@ describe API::Helpers::Pagination do
end
end
- describe 'second page' do
+ describe "second page" do
let(:query) { base_query.merge(per_page: 2, ks_prev_id: projects[1].id) }
- it 'returns appropriate amount of resources' do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 1
end
- it 'returns the third record' do
+ it "returns the third record" do
expect(subject.paginate(resource)).to eq(projects[2..2])
end
- it 'adds appropriate headers' do
- expect_header('X-Per-Page', '2')
- expect_header('X-Next-Page', "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[2].id).to_query}")
+ it "adds appropriate headers" do
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Next-Page", "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[2].id).to_query}")
- expect_header('Link', anything) do |_key, val|
+ expect_header("Link", anything) do |_key, val|
expect(val).to include('rel="next"')
end
@@ -81,27 +81,27 @@ describe API::Helpers::Pagination do
end
end
- describe 'third page' do
+ describe "third page" do
let(:query) { base_query.merge(per_page: 2, ks_prev_id: projects[2].id) }
- it 'returns appropriate amount of resources' do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 0
end
- it 'adds appropriate headers' do
- expect_header('X-Per-Page', '2')
- expect_no_header('X-Next-Page')
- expect(subject).not_to receive(:header).with('Link')
+ it "adds appropriate headers" do
+ expect_header("X-Per-Page", "2")
+ expect_no_header("X-Next-Page")
+ expect(subject).not_to receive(:header).with("Link")
subject.paginate(resource)
end
end
- context 'if order' do
- context 'is not present' do
+ context "if order" do
+ context "is not present" do
let(:query) { base_query.merge(per_page: 2) }
- it 'is not present it adds default order(:id) desc' do
+ it "is not present it adds default order(:id) desc" do
resource.order_values = []
paginated_relation = subject.paginate(resource)
@@ -114,17 +114,17 @@ describe API::Helpers::Pagination do
end
end
- context 'is present' do
+ context "is present" do
let(:resource) { Project.all.order(name: :desc) }
let!(:projects) do
[
- create(:project, name: 'One'),
- create(:project, name: 'Two'),
- create(:project, name: 'Three'),
- create(:project, name: 'Three'), # Note the duplicate name
- create(:project, name: 'Four'),
- create(:project, name: 'Five'),
- create(:project, name: 'Six')
+ create(:project, name: "One"),
+ create(:project, name: "Two"),
+ create(:project, name: "Three"),
+ create(:project, name: "Three"), # Note the duplicate name
+ create(:project, name: "Four"),
+ create(:project, name: "Five"),
+ create(:project, name: "Six"),
]
# if we sort this by name descending, id descending, this yields:
@@ -141,7 +141,7 @@ describe API::Helpers::Pagination do
# (key is the id)
end
- it 'also orders by primary key' do
+ it "also orders by primary key" do
paginated_relation = subject.paginate(resource)
expect(paginated_relation.order_values).to be_present
@@ -152,27 +152,27 @@ describe API::Helpers::Pagination do
expect(paginated_relation.order_values.second.expr.name).to eq :id
end
- it 'returns the right records (first page)' do
+ it "returns the right records (first page)" do
result = subject.paginate(resource)
expect(result.first).to eq(projects[1])
expect(result.second).to eq(projects[3])
end
- describe 'second page' do
+ describe "second page" do
let(:query) { base_query.merge(ks_prev_id: projects[3].id, ks_prev_name: projects[3].name, per_page: 2) }
- it 'returns the right records (second page)' do
+ it "returns the right records (second page)" do
result = subject.paginate(resource)
expect(result.first).to eq(projects[2])
expect(result.second).to eq(projects[6])
end
- it 'returns the right link to the next page' do
- expect_header('X-Per-Page', '2')
- expect_header('X-Next-Page', "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[6].id, ks_prev_name: projects[6].name).to_query}")
- expect_header('Link', anything) do |_key, val|
+ it "returns the right link to the next page" do
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Next-Page", "#{canonical_api_projects_url}?#{query.merge(ks_prev_id: projects[6].id, ks_prev_name: projects[6].name).to_query}")
+ expect_header("Link", anything) do |_key, val|
expect(val).to include('rel="next"')
end
@@ -180,10 +180,10 @@ describe API::Helpers::Pagination do
end
end
- describe 'third page' do
+ describe "third page" do
let(:query) { base_query.merge(ks_prev_id: projects[6].id, ks_prev_name: projects[6].name, per_page: 5) }
- it 'returns the right records (third page), note increased per_page' do
+ it "returns the right records (third page), note increased per_page" do
result = subject.paginate(resource)
expect(result.size).to eq(3)
@@ -197,9 +197,9 @@ describe API::Helpers::Pagination do
end
end
- describe '#paginate (default offset-based pagination)' do
- let(:value) { spy('return value') }
- let(:base_query) { { foo: 'bar', bar: 'baz' } }
+ describe "#paginate (default offset-based pagination)" do
+ let(:value) { spy("return value") }
+ let(:base_query) { {foo: "bar", bar: "baz"} }
let(:query) { base_query }
before do
@@ -208,25 +208,25 @@ describe API::Helpers::Pagination do
allow(subject).to receive(:request).and_return(double(url: "#{incoming_api_projects_url}?#{query.to_query}"))
end
- context 'when resource can be paginated' do
+ context "when resource can be paginated" do
before do
create_list(:project, 3)
end
- describe 'first page' do
- shared_examples 'response with pagination headers' do
- it 'adds appropriate headers' do
- expect_header('X-Total', '3')
- expect_header('X-Total-Pages', '2')
- expect_header('X-Per-Page', '2')
- expect_header('X-Page', '1')
- expect_header('X-Next-Page', '2')
- expect_header('X-Prev-Page', '')
-
- expect_header('Link', anything) do |_key, val|
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="last"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="next"))
+ describe "first page" do
+ shared_examples "response with pagination headers" do
+ it "adds appropriate headers" do
+ expect_header("X-Total", "3")
+ expect_header("X-Total-Pages", "2")
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Page", "1")
+ expect_header("X-Next-Page", "2")
+ expect_header("X-Prev-Page", "")
+
+ expect_header("Link", anything) do |_key, val|
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="last"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="next"))
expect(val).not_to include('rel="prev"')
end
@@ -234,64 +234,64 @@ describe API::Helpers::Pagination do
end
end
- shared_examples 'paginated response' do
- it 'returns appropriate amount of resources' do
+ shared_examples "paginated response" do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 2
end
- it 'executes only one SELECT COUNT query' do
+ it "executes only one SELECT COUNT query" do
expect { subject.paginate(resource) }.to make_queries_matching(/SELECT COUNT/, 1)
end
end
let(:query) { base_query.merge(page: 1, per_page: 2) }
- context 'when the api_kaminari_count_with_limit feature flag is unset' do
- it_behaves_like 'paginated response'
- it_behaves_like 'response with pagination headers'
+ context "when the api_kaminari_count_with_limit feature flag is unset" do
+ it_behaves_like "paginated response"
+ it_behaves_like "response with pagination headers"
end
- context 'when the api_kaminari_count_with_limit feature flag is disabled' do
+ context "when the api_kaminari_count_with_limit feature flag is disabled" do
before do
stub_feature_flags(api_kaminari_count_with_limit: false)
end
- it_behaves_like 'paginated response'
- it_behaves_like 'response with pagination headers'
+ it_behaves_like "paginated response"
+ it_behaves_like "response with pagination headers"
end
- context 'when the api_kaminari_count_with_limit feature flag is enabled' do
+ context "when the api_kaminari_count_with_limit feature flag is enabled" do
before do
stub_feature_flags(api_kaminari_count_with_limit: true)
end
- context 'when resources count is less than MAX_COUNT_LIMIT' do
+ context "when resources count is less than MAX_COUNT_LIMIT" do
before do
stub_const("::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT", 4)
end
- it_behaves_like 'paginated response'
- it_behaves_like 'response with pagination headers'
+ it_behaves_like "paginated response"
+ it_behaves_like "response with pagination headers"
end
- context 'when resources count is more than MAX_COUNT_LIMIT' do
+ context "when resources count is more than MAX_COUNT_LIMIT" do
before do
stub_const("::Kaminari::ActiveRecordRelationMethods::MAX_COUNT_LIMIT", 2)
end
- it_behaves_like 'paginated response'
+ it_behaves_like "paginated response"
- it 'does not return the X-Total and X-Total-Pages headers' do
- expect_no_header('X-Total')
- expect_no_header('X-Total-Pages')
- expect_header('X-Per-Page', '2')
- expect_header('X-Page', '1')
- expect_header('X-Next-Page', '2')
- expect_header('X-Prev-Page', '')
+ it "does not return the X-Total and X-Total-Pages headers" do
+ expect_no_header("X-Total")
+ expect_no_header("X-Total-Pages")
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Page", "1")
+ expect_header("X-Next-Page", "2")
+ expect_header("X-Prev-Page", "")
- expect_header('Link', anything) do |_key, val|
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="next"))
+ expect_header("Link", anything) do |_key, val|
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="next"))
expect(val).not_to include('rel="last"')
expect(val).not_to include('rel="prev"')
end
@@ -302,25 +302,25 @@ describe API::Helpers::Pagination do
end
end
- describe 'second page' do
+ describe "second page" do
let(:query) { base_query.merge(page: 2, per_page: 2) }
- it 'returns appropriate amount of resources' do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 1
end
- it 'adds appropriate headers' do
- expect_header('X-Total', '3')
- expect_header('X-Total-Pages', '2')
- expect_header('X-Per-Page', '2')
- expect_header('X-Page', '2')
- expect_header('X-Next-Page', '')
- expect_header('X-Prev-Page', '1')
-
- expect_header('Link', anything) do |_key, val|
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="last"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="prev"))
+ it "adds appropriate headers" do
+ expect_header("X-Total", "3")
+ expect_header("X-Total-Pages", "2")
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Page", "2")
+ expect_header("X-Next-Page", "")
+ expect_header("X-Prev-Page", "1")
+
+ expect_header("Link", anything) do |_key, val|
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 2).to_query}>; rel="last"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="prev"))
expect(val).not_to include('rel="next"')
end
@@ -328,8 +328,8 @@ describe API::Helpers::Pagination do
end
end
- context 'if order' do
- it 'is not present it adds default order(:id) if no order is present' do
+ context "if order" do
+ it "is not present it adds default order(:id) if no order is present" do
resource.order_values = []
paginated_relation = subject.paginate(resource)
@@ -340,7 +340,7 @@ describe API::Helpers::Pagination do
expect(paginated_relation.order_values.first.expr.name).to eq :id
end
- it 'is present it does not add anything' do
+ it "is present it does not add anything" do
paginated_relation = subject.paginate(resource.order(created_at: :desc))
expect(paginated_relation.order_values).to be_present
@@ -350,28 +350,28 @@ describe API::Helpers::Pagination do
end
end
- context 'when resource empty' do
- describe 'first page' do
+ context "when resource empty" do
+ describe "first page" do
let(:query) { base_query.merge(page: 1, per_page: 2) }
- it 'returns appropriate amount of resources' do
+ it "returns appropriate amount of resources" do
expect(subject.paginate(resource).count).to eq 0
end
- it 'adds appropriate headers' do
- expect_header('X-Total', '0')
- expect_header('X-Total-Pages', '1')
- expect_header('X-Per-Page', '2')
- expect_header('X-Page', '1')
- expect_header('X-Next-Page', '')
- expect_header('X-Prev-Page', '')
-
- expect_header('Link', anything) do |_key, val|
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
- expect(val).to include(%Q(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="last"))
+ it "adds appropriate headers" do
+ expect_header("X-Total", "0")
+ expect_header("X-Total-Pages", "1")
+ expect_header("X-Per-Page", "2")
+ expect_header("X-Page", "1")
+ expect_header("X-Next-Page", "")
+ expect_header("X-Prev-Page", "")
+
+ expect_header("Link", anything) do |_key, val|
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="first"))
+ expect(val).to include(%(<#{canonical_api_projects_url}?#{query.merge(page: 1).to_query}>; rel="last"))
expect(val).not_to include('rel="prev"')
expect(val).not_to include('rel="next"')
- expect(val).not_to include('page=0')
+ expect(val).not_to include("page=0")
end
subject.paginate(resource)
diff --git a/spec/lib/api/helpers/related_resources_helpers_spec.rb b/spec/lib/api/helpers/related_resources_helpers_spec.rb
index 66af7f81535..085d0819bd0 100644
--- a/spec/lib/api/helpers/related_resources_helpers_spec.rb
+++ b/spec/lib/api/helpers/related_resources_helpers_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers::RelatedResourcesHelpers do
subject(:helpers) do
Class.new.include(described_class).new
end
- describe '#expose_url' do
- let(:path) { '/api/v4/awesome_endpoint' }
+ describe "#expose_url" do
+ let(:path) { "/api/v4/awesome_endpoint" }
subject(:url) { helpers.expose_url(path) }
- def stub_default_url_options(protocol: 'http', host: 'example.com', port: nil, script_name: '')
+ def stub_default_url_options(protocol: "http", host: "example.com", port: nil, script_name: "")
expect(Gitlab::Application.routes).to receive(:default_url_options)
.and_return(protocol: protocol, host: host, port: port, script_name: script_name)
end
- it 'respects the protocol if it is HTTP' do
- stub_default_url_options(protocol: 'http')
+ it "respects the protocol if it is HTTP" do
+ stub_default_url_options(protocol: "http")
- is_expected.to start_with('http://')
+ is_expected.to start_with("http://")
end
- it 'respects the protocol if it is HTTPS' do
- stub_default_url_options(protocol: 'https')
+ it "respects the protocol if it is HTTPS" do
+ stub_default_url_options(protocol: "https")
- is_expected.to start_with('https://')
+ is_expected.to start_with("https://")
end
- it 'accepts port to be nil' do
+ it "accepts port to be nil" do
stub_default_url_options(port: nil)
- is_expected.to start_with('http://example.com/')
+ is_expected.to start_with("http://example.com/")
end
- it 'includes port if provided' do
+ it "includes port if provided" do
stub_default_url_options(port: 8080)
- is_expected.to start_with('http://example.com:8080/')
+ is_expected.to start_with("http://example.com:8080/")
end
- it 'includes the relative_url before the path if it is set' do
- stub_default_url_options(script_name: '/gitlab')
+ it "includes the relative_url before the path if it is set" do
+ stub_default_url_options(script_name: "/gitlab")
- is_expected.to start_with('http://example.com/gitlab/api/v4')
+ is_expected.to start_with("http://example.com/gitlab/api/v4")
end
- it 'includes the path after the host' do
+ it "includes the path after the host" do
stub_default_url_options
- is_expected.to start_with('http://example.com/api/v4')
+ is_expected.to start_with("http://example.com/api/v4")
end
end
end
diff --git a/spec/lib/api/helpers/version_spec.rb b/spec/lib/api/helpers/version_spec.rb
index 34006e0930b..d69dcf6a9d0 100644
--- a/spec/lib/api/helpers/version_spec.rb
+++ b/spec/lib/api/helpers/version_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers::Version do
- describe '.new' do
- it 'is possible to initialize it with existing API version' do
- expect(described_class.new('v4').to_s).to eq 'v4'
+ describe ".new" do
+ it "is possible to initialize it with existing API version" do
+ expect(described_class.new("v4").to_s).to eq "v4"
end
- it 'raises an error when unsupported API version is provided' do
- expect { described_class.new('v111') }.to raise_error ArgumentError
+ it "raises an error when unsupported API version is provided" do
+ expect { described_class.new("v111") }.to raise_error ArgumentError
end
end
- describe '#root_path' do
- it 'returns a root path of the API version' do
- expect(described_class.new('v4').root_path).to eq '/api/v4'
+ describe "#root_path" do
+ it "returns a root path of the API version" do
+ expect(described_class.new("v4").root_path).to eq "/api/v4"
end
end
- describe '#root_url' do
- it 'returns an URL for a root path for the API version' do
- expect(described_class.new('v4').root_url)
- .to eq 'http://localhost/api/v4'
+ describe "#root_url" do
+ it "returns an URL for a root path for the API version" do
+ expect(described_class.new("v4").root_url)
+ .to eq "http://localhost/api/v4"
end
end
end
diff --git a/spec/lib/api/helpers_spec.rb b/spec/lib/api/helpers_spec.rb
index 08165f147bb..e677b3910ee 100644
--- a/spec/lib/api/helpers_spec.rb
+++ b/spec/lib/api/helpers_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Helpers do
subject { Class.new.include(described_class).new }
- describe '#find_project' do
+ describe "#find_project" do
let(:project) { create(:project) }
- shared_examples 'project finder' do
- context 'when project exists' do
- it 'returns requested project' do
+ shared_examples "project finder" do
+ context "when project exists" do
+ it "returns requested project" do
expect(subject.find_project(existing_id)).to eq(project)
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.find_project(non_existing_id)).to be_nil
end
end
end
- context 'when ID is used as an argument' do
+ context "when ID is used as an argument" do
let(:existing_id) { project.id }
let(:non_existing_id) { (Project.maximum(:id) || 0) + 1 }
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
end
- context 'when PATH is used as an argument' do
+ context "when PATH is used as an argument" do
let(:existing_id) { project.full_path }
- let(:non_existing_id) { 'something/else' }
+ let(:non_existing_id) { "something/else" }
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
- context 'with an invalid PATH' do
- let(:non_existing_id) { 'undefined' } # path without slash
+ context "with an invalid PATH" do
+ let(:non_existing_id) { "undefined" } # path without slash
- it_behaves_like 'project finder'
+ it_behaves_like "project finder"
- it 'does not hit the database' do
+ it "does not hit the database" do
expect(Project).not_to receive(:find_by_full_path)
subject.find_project(non_existing_id)
@@ -45,64 +45,64 @@ describe API::Helpers do
end
end
- describe '#find_namespace' do
+ describe "#find_namespace" do
let(:namespace) { create(:namespace) }
- shared_examples 'namespace finder' do
- context 'when namespace exists' do
- it 'returns requested namespace' do
+ shared_examples "namespace finder" do
+ context "when namespace exists" do
+ it "returns requested namespace" do
expect(subject.find_namespace(existing_id)).to eq(namespace)
end
end
context "when namespace doesn't exists" do
- it 'returns nil' do
+ it "returns nil" do
expect(subject.find_namespace(non_existing_id)).to be_nil
end
end
end
- context 'when ID is used as an argument' do
+ context "when ID is used as an argument" do
let(:existing_id) { namespace.id }
let(:non_existing_id) { 9999 }
- it_behaves_like 'namespace finder'
+ it_behaves_like "namespace finder"
end
- context 'when PATH is used as an argument' do
+ context "when PATH is used as an argument" do
let(:existing_id) { namespace.path }
- let(:non_existing_id) { 'non-existing-path' }
+ let(:non_existing_id) { "non-existing-path" }
- it_behaves_like 'namespace finder'
+ it_behaves_like "namespace finder"
end
end
- shared_examples 'user namespace finder' do
+ shared_examples "user namespace finder" do
let(:user1) { create(:user) }
before do
allow(subject).to receive(:current_user).and_return(user1)
allow(subject).to receive(:header).and_return(nil)
- allow(subject).to receive(:not_found!).and_raise('404 Namespace not found')
+ allow(subject).to receive(:not_found!).and_raise("404 Namespace not found")
end
- context 'when namespace is group' do
+ context "when namespace is group" do
let(:namespace) { create(:group) }
- context 'when user has access to group' do
+ context "when user has access to group" do
before do
namespace.add_guest(user1)
namespace.save!
end
- it 'returns requested namespace' do
+ it "returns requested namespace" do
expect(namespace_finder).to eq(namespace)
end
end
context "when user doesn't have access to group" do
- it 'raises not found error' do
- expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found')
+ it "raises not found error" do
+ expect { namespace_finder }.to raise_error(RuntimeError, "404 Namespace not found")
end
end
end
@@ -110,48 +110,48 @@ describe API::Helpers do
context "when namespace is user's personal namespace" do
let(:namespace) { create(:namespace) }
- context 'when user owns the namespace' do
+ context "when user owns the namespace" do
before do
namespace.owner = user1
namespace.save!
end
- it 'returns requested namespace' do
+ it "returns requested namespace" do
expect(namespace_finder).to eq(namespace)
end
end
context "when user doesn't own the namespace" do
- it 'raises not found error' do
- expect { namespace_finder }.to raise_error(RuntimeError, '404 Namespace not found')
+ it "raises not found error" do
+ expect { namespace_finder }.to raise_error(RuntimeError, "404 Namespace not found")
end
end
end
end
- describe '#find_namespace!' do
+ describe "#find_namespace!" do
let(:namespace_finder) do
subject.find_namespace!(namespace.id)
end
- it_behaves_like 'user namespace finder'
+ it_behaves_like "user namespace finder"
end
- describe '#user_namespace' do
+ describe "#user_namespace" do
let(:namespace_finder) do
subject.user_namespace
end
before do
- allow(subject).to receive(:params).and_return({ id: namespace.id })
+ allow(subject).to receive(:params).and_return({id: namespace.id})
end
- it_behaves_like 'user namespace finder'
+ it_behaves_like "user namespace finder"
end
- describe '#send_git_blob' do
+ describe "#send_git_blob" do
let(:repository) { double }
- let(:blob) { double(name: 'foobar') }
+ let(:blob) { double(name: "foobar") }
let(:send_git_blob) do
subject.send(:send_git_blob, repository, blob)
@@ -164,22 +164,22 @@ describe API::Helpers do
allow(Gitlab::Workhorse).to receive(:send_git_blob)
end
- it 'sets Gitlab::Workhorse::DETECT_HEADER header' do
+ it "sets Gitlab::Workhorse::DETECT_HEADER header" do
expect(send_git_blob[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
- context 'content disposition' do
- context 'when blob name is null' do
+ context "content disposition" do
+ context "when blob name is null" do
let(:blob) { double(name: nil) }
- it 'returns only the disposition' do
- expect(send_git_blob['Content-Disposition']).to eq 'inline'
+ it "returns only the disposition" do
+ expect(send_git_blob["Content-Disposition"]).to eq "inline"
end
end
- context 'when blob name is not null' do
- it 'returns disposition with the blob name' do
- expect(send_git_blob['Content-Disposition']).to eq %q(inline; filename="foobar"; filename*=UTF-8''foobar)
+ context "when blob name is not null" do
+ it "returns disposition with the blob name" do
+ expect(send_git_blob["Content-Disposition"]).to eq %q(inline; filename="foobar"; filename*=UTF-8''foobar)
end
end
end
diff --git a/spec/lib/backup/files_spec.rb b/spec/lib/backup/files_spec.rb
index 63f2298357f..232d6a2c849 100644
--- a/spec/lib/backup/files_spec.rb
+++ b/spec/lib/backup/files_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Backup::Files do
let(:progress) { StringIO.new }
@@ -20,60 +20,60 @@ describe Backup::Files do
allow_any_instance_of(described_class).to receive(:progress).and_return(progress)
end
- describe '#restore' do
- subject { described_class.new('registry', '/var/gitlab-registry') }
+ describe "#restore" do
+ subject { described_class.new("registry", "/var/gitlab-registry") }
let(:timestamp) { Time.utc(2017, 3, 22) }
around do |example|
Timecop.freeze(timestamp) { example.run }
end
- describe 'folders with permission' do
+ describe "folders with permission" do
before do
allow(subject).to receive(:run_pipeline!).and_return(true)
allow(subject).to receive(:backup_existing_files).and_return(true)
allow(Dir).to receive(:glob).with("/var/gitlab-registry/*", File::FNM_DOTMATCH).and_return(["/var/gitlab-registry/.", "/var/gitlab-registry/..", "/var/gitlab-registry/sample1"])
end
- it 'moves all necessary files' do
+ it "moves all necessary files" do
allow(subject).to receive(:backup_existing_files).and_call_original
expect(FileUtils).to receive(:mv).with(["/var/gitlab-registry/sample1"], File.join(Gitlab.config.backup.path, "tmp", "registry.#{Time.now.to_i}"))
subject.restore
end
- it 'raises no errors' do
+ it "raises no errors" do
expect { subject.restore }.not_to raise_error
end
- it 'calls tar command with unlink' do
- expect(subject).to receive(:tar).and_return('blabla-tar')
+ it "calls tar command with unlink" do
+ expect(subject).to receive(:tar).and_return("blabla-tar")
- expect(subject).to receive(:run_pipeline!).with([%w(gzip -cd), %w(blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -)], any_args)
+ expect(subject).to receive(:run_pipeline!).with([%w[gzip -cd], %w[blabla-tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -]], any_args)
subject.restore
end
end
- describe 'folders without permissions' do
+ describe "folders without permissions" do
before do
allow(FileUtils).to receive(:mv).and_raise(Errno::EACCES)
allow(subject).to receive(:run_pipeline!).and_return(true)
end
- it 'shows error message' do
+ it "shows error message" do
expect(subject).to receive(:access_denied_error).with("/var/gitlab-registry")
subject.restore
end
end
- describe 'folders that are a mountpoint' do
+ describe "folders that are a mountpoint" do
before do
allow(FileUtils).to receive(:mv).and_raise(Errno::EBUSY)
allow(subject).to receive(:run_pipeline!).and_return(true)
end
- it 'shows error message' do
+ it "shows error message" do
expect(subject).to receive(:resource_busy_error).with("/var/gitlab-registry")
- .and_call_original
+ .and_call_original
expect { subject.restore }.to raise_error(/is a mountpoint/)
end
diff --git a/spec/lib/backup/manager_spec.rb b/spec/lib/backup/manager_spec.rb
index ae1c881e1f6..95193bf719d 100644
--- a/spec/lib/backup/manager_spec.rb
+++ b/spec/lib/backup/manager_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Backup::Manager do
include StubENV
@@ -19,19 +19,19 @@ describe Backup::Manager do
$progress = @old_progress # rubocop:disable Style/GlobalVars
end
- describe '#remove_old' do
+ describe "#remove_old" do
let(:files) do
[
- '1451606400_2016_01_01_1.2.3_gitlab_backup.tar',
- '1451520000_2015_12_31_4.5.6_gitlab_backup.tar',
- '1451520000_2015_12_31_4.5.6-pre_gitlab_backup.tar',
- '1451520000_2015_12_31_4.5.6-rc1_gitlab_backup.tar',
- '1451520000_2015_12_31_4.5.6-pre-ee_gitlab_backup.tar',
- '1451510000_2015_12_30_gitlab_backup.tar',
- '1450742400_2015_12_22_gitlab_backup.tar',
- '1449878400_gitlab_backup.tar',
- '1449014400_gitlab_backup.tar',
- 'manual_gitlab_backup.tar'
+ "1451606400_2016_01_01_1.2.3_gitlab_backup.tar",
+ "1451520000_2015_12_31_4.5.6_gitlab_backup.tar",
+ "1451520000_2015_12_31_4.5.6-pre_gitlab_backup.tar",
+ "1451520000_2015_12_31_4.5.6-rc1_gitlab_backup.tar",
+ "1451520000_2015_12_31_4.5.6-pre-ee_gitlab_backup.tar",
+ "1451510000_2015_12_30_gitlab_backup.tar",
+ "1450742400_2015_12_22_gitlab_backup.tar",
+ "1449878400_gitlab_backup.tar",
+ "1449014400_gitlab_backup.tar",
+ "manual_gitlab_backup.tar",
]
end
@@ -42,28 +42,28 @@ describe Backup::Manager do
allow(Time).to receive(:now).and_return(Time.utc(2016))
end
- context 'when keep_time is zero' do
+ context "when keep_time is zero" do
before do
allow(Gitlab.config.backup).to receive(:keep_time).and_return(0)
subject.remove_old
end
- it 'removes no files' do
+ it "removes no files" do
expect(FileUtils).not_to have_received(:rm)
end
- it 'prints a skipped message' do
- expect(progress).to have_received(:puts).with('skipping')
+ it "prints a skipped message" do
+ expect(progress).to have_received(:puts).with("skipping")
end
end
- context 'when no valid file is found' do
+ context "when no valid file is found" do
let(:files) do
[
- '14516064000_2016_01_01_1.2.3_gitlab_backup.tar',
- 'foo_1451520000_2015_12_31_4.5.6_gitlab_backup.tar',
- '1451520000_2015_12_31_4.5.6-foo_gitlab_backup.tar'
+ "14516064000_2016_01_01_1.2.3_gitlab_backup.tar",
+ "foo_1451520000_2015_12_31_4.5.6_gitlab_backup.tar",
+ "1451520000_2015_12_31_4.5.6-foo_gitlab_backup.tar",
]
end
@@ -73,16 +73,16 @@ describe Backup::Manager do
subject.remove_old
end
- it 'removes no files' do
+ it "removes no files" do
expect(FileUtils).not_to have_received(:rm)
end
- it 'prints a done message' do
- expect(progress).to have_received(:puts).with('done. (0 removed)')
+ it "prints a done message" do
+ expect(progress).to have_received(:puts).with("done. (0 removed)")
end
end
- context 'when there are no files older than keep_time' do
+ context "when there are no files older than keep_time" do
before do
# Set to 30 days
allow(Gitlab.config.backup).to receive(:keep_time).and_return(2592000)
@@ -90,16 +90,16 @@ describe Backup::Manager do
subject.remove_old
end
- it 'removes no files' do
+ it "removes no files" do
expect(FileUtils).not_to have_received(:rm)
end
- it 'prints a done message' do
- expect(progress).to have_received(:puts).with('done. (0 removed)')
+ it "prints a done message" do
+ expect(progress).to have_received(:puts).with("done. (0 removed)")
end
end
- context 'when keep_time is set to remove files' do
+ context "when keep_time is set to remove files" do
before do
# Set to 1 second
allow(Gitlab.config.backup).to receive(:keep_time).and_return(1)
@@ -107,40 +107,40 @@ describe Backup::Manager do
subject.remove_old
end
- it 'removes matching files with a human-readable versioned timestamp' do
+ it "removes matching files with a human-readable versioned timestamp" do
expect(FileUtils).to have_received(:rm).with(files[1])
expect(FileUtils).to have_received(:rm).with(files[2])
expect(FileUtils).to have_received(:rm).with(files[3])
end
- it 'removes matching files with a human-readable versioned timestamp with tagged EE' do
+ it "removes matching files with a human-readable versioned timestamp with tagged EE" do
expect(FileUtils).to have_received(:rm).with(files[4])
end
- it 'removes matching files with a human-readable non-versioned timestamp' do
+ it "removes matching files with a human-readable non-versioned timestamp" do
expect(FileUtils).to have_received(:rm).with(files[5])
expect(FileUtils).to have_received(:rm).with(files[6])
end
- it 'removes matching files without a human-readable timestamp' do
+ it "removes matching files without a human-readable timestamp" do
expect(FileUtils).to have_received(:rm).with(files[7])
expect(FileUtils).to have_received(:rm).with(files[8])
end
- it 'does not remove files that are not old enough' do
+ it "does not remove files that are not old enough" do
expect(FileUtils).not_to have_received(:rm).with(files[0])
end
- it 'does not remove non-matching files' do
+ it "does not remove non-matching files" do
expect(FileUtils).not_to have_received(:rm).with(files[9])
end
- it 'prints a done message' do
- expect(progress).to have_received(:puts).with('done. (8 removed)')
+ it "prints a done message" do
+ expect(progress).to have_received(:puts).with("done. (8 removed)")
end
end
- context 'when removing a file fails' do
+ context "when removing a file fails" do
let(:file) { files[1] }
let(:message) { "Permission denied @ unlink_internal - #{file}" }
@@ -151,7 +151,7 @@ describe Backup::Manager do
subject.remove_old
end
- it 'removes the remaining expected files' do
+ it "removes the remaining expected files" do
expect(FileUtils).to have_received(:rm).with(files[4])
expect(FileUtils).to have_received(:rm).with(files[5])
expect(FileUtils).to have_received(:rm).with(files[6])
@@ -159,98 +159,98 @@ describe Backup::Manager do
expect(FileUtils).to have_received(:rm).with(files[8])
end
- it 'sets the correct removed count' do
- expect(progress).to have_received(:puts).with('done. (7 removed)')
+ it "sets the correct removed count" do
+ expect(progress).to have_received(:puts).with("done. (7 removed)")
end
- it 'prints the error from file that could not be removed' do
+ it "prints the error from file that could not be removed" do
expect(progress).to have_received(:puts).with(a_string_matching(message))
end
end
end
- describe '#unpack' do
- context 'when there are no backup files in the directory' do
+ describe "#unpack" do
+ context "when there are no backup files in the directory" do
before do
allow(Dir).to receive(:glob).and_return([])
end
- it 'fails the operation and prints an error' do
+ it "fails the operation and prints an error" do
expect { subject.unpack }.to raise_error SystemExit
expect(progress).to have_received(:puts)
- .with(a_string_matching('No backups found'))
+ .with(a_string_matching("No backups found"))
end
end
- context 'when there are two backup files in the directory and BACKUP variable is not set' do
+ context "when there are two backup files in the directory and BACKUP variable is not set" do
before do
allow(Dir).to receive(:glob).and_return(
[
- '1451606400_2016_01_01_1.2.3_gitlab_backup.tar',
- '1451520000_2015_12_31_gitlab_backup.tar'
+ "1451606400_2016_01_01_1.2.3_gitlab_backup.tar",
+ "1451520000_2015_12_31_gitlab_backup.tar",
]
)
end
- it 'prints the list of available backups' do
+ it "prints the list of available backups" do
expect { subject.unpack }.to raise_error SystemExit
expect(progress).to have_received(:puts)
.with(a_string_matching('1451606400_2016_01_01_1.2.3\n 1451520000_2015_12_31'))
end
- it 'fails the operation and prints an error' do
+ it "fails the operation and prints an error" do
expect { subject.unpack }.to raise_error SystemExit
expect(progress).to have_received(:puts)
- .with(a_string_matching('Found more than one backup'))
+ .with(a_string_matching("Found more than one backup"))
end
end
- context 'when BACKUP variable is set to a non-existing file' do
+ context "when BACKUP variable is set to a non-existing file" do
before do
allow(Dir).to receive(:glob).and_return(
[
- '1451606400_2016_01_01_gitlab_backup.tar'
+ "1451606400_2016_01_01_gitlab_backup.tar",
]
)
allow(File).to receive(:exist?).and_return(false)
- stub_env('BACKUP', 'wrong')
+ stub_env("BACKUP", "wrong")
end
- it 'fails the operation and prints an error' do
+ it "fails the operation and prints an error" do
expect { subject.unpack }.to raise_error SystemExit
- expect(File).to have_received(:exist?).with('wrong_gitlab_backup.tar')
+ expect(File).to have_received(:exist?).with("wrong_gitlab_backup.tar")
expect(progress).to have_received(:puts)
- .with(a_string_matching('The backup file wrong_gitlab_backup.tar does not exist'))
+ .with(a_string_matching("The backup file wrong_gitlab_backup.tar does not exist"))
end
end
- context 'when BACKUP variable is set to a correct file' do
+ context "when BACKUP variable is set to a correct file" do
before do
allow(Dir).to receive(:glob).and_return(
[
- '1451606400_2016_01_01_1.2.3_gitlab_backup.tar'
+ "1451606400_2016_01_01_1.2.3_gitlab_backup.tar",
]
)
allow(File).to receive(:exist?).and_return(true)
allow(Kernel).to receive(:system).and_return(true)
allow(YAML).to receive(:load_file).and_return(gitlab_version: Gitlab::VERSION)
- stub_env('BACKUP', '1451606400_2016_01_01_1.2.3')
+ stub_env("BACKUP", "1451606400_2016_01_01_1.2.3")
end
- it 'unpacks the file' do
+ it "unpacks the file" do
subject.unpack
expect(Kernel).to have_received(:system)
.with("tar", "-xf", "1451606400_2016_01_01_1.2.3_gitlab_backup.tar")
- expect(progress).to have_received(:puts).with(a_string_matching('done'))
+ expect(progress).to have_received(:puts).with(a_string_matching("done"))
end
end
end
- describe '#upload' do
- let(:backup_file) { Tempfile.new('backup', Gitlab.config.backup.path) }
+ describe "#upload" do
+ let(:backup_file) { Tempfile.new("backup", Gitlab.config.backup.path) }
let(:backup_filename) { File.basename(backup_file.path) }
before do
@@ -259,15 +259,15 @@ describe Backup::Manager do
stub_backup_setting(
upload: {
connection: {
- provider: 'AWS',
- aws_access_key_id: 'id',
- aws_secret_access_key: 'secret'
+ provider: "AWS",
+ aws_access_key_id: "id",
+ aws_secret_access_key: "secret",
},
- remote_directory: 'directory',
+ remote_directory: "directory",
multipart_chunk_size: 104857600,
encryption: nil,
encryption_key: nil,
- storage_class: nil
+ storage_class: nil,
}
)
@@ -278,8 +278,8 @@ describe Backup::Manager do
connection.directories.create(key: Gitlab.config.backup.upload.remote_directory)
end
- context 'target path' do
- it 'uses the tar filename by default' do
+ context "target path" do
+ it "uses the tar filename by default" do
expect_any_instance_of(Fog::Collection).to receive(:create)
.with(hash_including(key: backup_filename))
.and_return(true)
@@ -289,8 +289,8 @@ describe Backup::Manager do
end
end
- it 'adds the DIRECTORY environment variable if present' do
- stub_env('DIRECTORY', 'daily')
+ it "adds the DIRECTORY environment variable if present" do
+ stub_env("DIRECTORY", "daily")
expect_any_instance_of(Fog::Collection).to receive(:create)
.with(hash_including(key: "daily/#{backup_filename}"))
diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb
index 5ace5c5b1a2..ce577cfd1da 100644
--- a/spec/lib/backup/repository_spec.rb
+++ b/spec/lib/backup/repository_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Backup::Repository do
let(:progress) { StringIO.new }
@@ -14,24 +14,24 @@ describe Backup::Repository do
allow_any_instance_of(described_class).to receive(:progress).and_return(progress)
end
- describe '#dump' do
- describe 'repo failure' do
+ describe "#dump" do
+ describe "repo failure" do
before do
- allow(Gitlab::Popen).to receive(:popen).and_return(['normal output', 0])
+ allow(Gitlab::Popen).to receive(:popen).and_return(["normal output", 0])
end
- it 'does not raise error' do
+ it "does not raise error" do
expect { subject.dump }.not_to raise_error
end
end
end
- describe '#restore' do
+ describe "#restore" do
let(:timestamp) { Time.utc(2017, 3, 22) }
let(:temp_dirs) do
Gitlab.config.repositories.storages.map do |name, storage|
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- File.join(storage.legacy_disk_path, '..', 'repositories.old.' + timestamp.to_i.to_s)
+ File.join(storage.legacy_disk_path, "..", "repositories.old." + timestamp.to_i.to_s)
end
end
end
@@ -44,23 +44,23 @@ describe Backup::Repository do
temp_dirs.each { |path| FileUtils.rm_rf(path) }
end
- describe 'command failure' do
+ describe "command failure" do
before do
allow_any_instance_of(Gitlab::Shell).to receive(:create_repository).and_return(false)
end
- context 'hashed storage' do
- it 'shows the appropriate error' do
+ context "hashed storage" do
+ it "shows the appropriate error" do
subject.restore
expect(progress).to have_received(:puts).with("[Failed] restoring #{project.full_path} repository")
end
end
- context 'legacy storage' do
+ context "legacy storage" do
let!(:project) { create(:project, :legacy_storage) }
- it 'shows the appropriate error' do
+ it "shows the appropriate error" do
subject.restore
expect(progress).to have_received(:puts).with("[Failed] restoring #{project.full_path} repository")
@@ -68,8 +68,8 @@ describe Backup::Repository do
end
end
- context 'restoring object pools' do
- it 'schedules restoring of the pool' do
+ context "restoring object pools" do
+ it "schedules restoring of the pool" do
pool_repository = create(:pool_repository, :failed)
pool_repository.delete_object_pool
@@ -82,7 +82,7 @@ describe Backup::Repository do
end
end
- describe '#prepare_directories', :seed_helper do
+ describe "#prepare_directories", :seed_helper do
before do
allow(FileUtils).to receive(:mkdir_p).and_call_original
allow(FileUtils).to receive(:mv).and_call_original
@@ -92,7 +92,7 @@ describe Backup::Repository do
ensure_seeds
end
- it' removes all repositories' do
+ it" removes all repositories" do
# Sanity check: there should be something for us to delete
expect(list_repositories).to include(File.join(SEED_STORAGE_PATH, TEST_REPO_PATH))
@@ -102,30 +102,30 @@ describe Backup::Repository do
end
def list_repositories
- Dir[File.join(SEED_STORAGE_PATH, '*.git')]
+ Dir[File.join(SEED_STORAGE_PATH, "*.git")]
end
end
- describe '#empty_repo?' do
- context 'for a wiki' do
+ describe "#empty_repo?" do
+ context "for a wiki" do
let(:wiki) { create(:project_wiki) }
- it 'invalidates the emptiness cache' do
+ it "invalidates the emptiness cache" do
expect(wiki.repository).to receive(:expire_emptiness_caches).once
subject.send(:empty_repo?, wiki)
end
- context 'wiki repo has content' do
+ context "wiki repo has content" do
let!(:wiki_page) { create(:wiki_page, wiki: wiki) }
- it 'returns true, regardless of bad cache value' do
+ it "returns true, regardless of bad cache value" do
expect(subject.send(:empty_repo?, wiki)).to be(false)
end
end
- context 'wiki repo does not have content' do
- it 'returns true, regardless of bad cache value' do
+ context "wiki repo does not have content" do
+ it "returns true, regardless of bad cache value" do
expect(subject.send(:empty_repo?, wiki)).to be_truthy
end
end
diff --git a/spec/lib/banzai/color_parser_spec.rb b/spec/lib/banzai/color_parser_spec.rb
index af2a8f215c1..127560d9319 100644
--- a/spec/lib/banzai/color_parser_spec.rb
+++ b/spec/lib/banzai/color_parser_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ColorParser do
- describe '.parse' do
- context 'HEX format' do
+ describe ".parse" do
+ context "HEX format" do
[
- '#abc', '#ABC',
- '#d2d2d2', '#D2D2D2',
- '#123a', '#123A',
- '#123456aa', '#123456AA'
+ "#abc", "#ABC",
+ "#d2d2d2", "#D2D2D2",
+ "#123a", "#123A",
+ "#123456aa", "#123456AA",
].each do |color|
it "parses the valid hex color #{color}" do
expect(subject.parse(color)).to eq(color)
@@ -15,10 +15,10 @@ describe Banzai::ColorParser do
end
[
- '#', '#1', '#12', '#12g', '#12G',
- '#12345', '#r2r2r2', '#R2R2R2', '#1234567',
- '# 123', '# 1234', '# 123456', '# 12345678',
- '#1 2 3', '#123 4', '#12 34 56', '#123456 78'
+ "#", "#1", "#12", "#12g", "#12G",
+ "#12345", "#r2r2r2", "#R2R2R2", "#1234567",
+ "# 123", "# 1234", "# 123456", "# 12345678",
+ "#1 2 3", "#123 4", "#12 34 56", "#123456 78",
].each do |color|
it "does not parse the invalid hex color #{color}" do
expect(subject.parse(color)).to be_nil
@@ -26,15 +26,15 @@ describe Banzai::ColorParser do
end
end
- context 'RGB format' do
+ context "RGB format" do
[
- 'rgb(0,0,0)', 'rgb(255,255,255)',
- 'rgb(0, 0, 0)', 'RGB(0,0,0)',
- 'rgb(0,0,0,0)', 'rgb(0,0,0,0.0)', 'rgb(0,0,0,.0)',
- 'rgb(0,0,0, 0)', 'rgb(0,0,0, 0.0)', 'rgb(0,0,0, .0)',
- 'rgb(0,0,0,1)', 'rgb(0,0,0,1.0)',
- 'rgba(0,0,0)', 'rgba(0,0,0,0)', 'RGBA(0,0,0)',
- 'rgb(0%,0%,0%)', 'rgba(0%,0%,0%,0%)'
+ "rgb(0,0,0)", "rgb(255,255,255)",
+ "rgb(0, 0, 0)", "RGB(0,0,0)",
+ "rgb(0,0,0,0)", "rgb(0,0,0,0.0)", "rgb(0,0,0,.0)",
+ "rgb(0,0,0, 0)", "rgb(0,0,0, 0.0)", "rgb(0,0,0, .0)",
+ "rgb(0,0,0,1)", "rgb(0,0,0,1.0)",
+ "rgba(0,0,0)", "rgba(0,0,0,0)", "RGBA(0,0,0)",
+ "rgb(0%,0%,0%)", "rgba(0%,0%,0%,0%)",
].each do |color|
it "parses the valid rgb color #{color}" do
expect(subject.parse(color)).to eq(color)
@@ -42,12 +42,12 @@ describe Banzai::ColorParser do
end
[
- 'FOOrgb(0,0,0)', 'rgb(0,0,0)BAR',
- 'rgb(0,0,-1)', 'rgb(0,0,-0)', 'rgb(0,0,256)',
- 'rgb(0,0,0,-0.1)', 'rgb(0,0,0,-0.0)', 'rgb(0,0,0,-.1)',
- 'rgb(0,0,0,1.1)', 'rgb(0,0,0,2)',
- 'rgba(0,0,0,)', 'rgba(0,0,0,0.)', 'rgba(0,0,0,1.)',
- 'rgb(0,0,0%)', 'rgb(101%,0%,0%)'
+ "FOOrgb(0,0,0)", "rgb(0,0,0)BAR",
+ "rgb(0,0,-1)", "rgb(0,0,-0)", "rgb(0,0,256)",
+ "rgb(0,0,0,-0.1)", "rgb(0,0,0,-0.0)", "rgb(0,0,0,-.1)",
+ "rgb(0,0,0,1.1)", "rgb(0,0,0,2)",
+ "rgba(0,0,0,)", "rgba(0,0,0,0.)", "rgba(0,0,0,1.)",
+ "rgb(0,0,0%)", "rgb(101%,0%,0%)",
].each do |color|
it "does not parse the invalid rgb color #{color}" do
expect(subject.parse(color)).to be_nil
@@ -55,18 +55,18 @@ describe Banzai::ColorParser do
end
end
- context 'HSL format' do
+ context "HSL format" do
[
- 'hsl(0,0%,0%)', 'hsl(0,100%,100%)',
- 'hsl(540,0%,0%)', 'hsl(-720,0%,0%)',
- 'hsl(0deg,0%,0%)', 'hsl(0DEG,0%,0%)',
- 'hsl(0, 0%, 0%)', 'HSL(0,0%,0%)',
- 'hsl(0,0%,0%,0)', 'hsl(0,0%,0%,0.0)', 'hsl(0,0%,0%,.0)',
- 'hsl(0,0%,0%, 0)', 'hsl(0,0%,0%, 0.0)', 'hsl(0,0%,0%, .0)',
- 'hsl(0,0%,0%,1)', 'hsl(0,0%,0%,1.0)',
- 'hsla(0,0%,0%)', 'hsla(0,0%,0%,0)', 'HSLA(0,0%,0%)',
- 'hsl(1rad,0%,0%)', 'hsl(1.1rad,0%,0%)', 'hsl(.1rad,0%,0%)',
- 'hsl(-1rad,0%,0%)', 'hsl(1RAD,0%,0%)'
+ "hsl(0,0%,0%)", "hsl(0,100%,100%)",
+ "hsl(540,0%,0%)", "hsl(-720,0%,0%)",
+ "hsl(0deg,0%,0%)", "hsl(0DEG,0%,0%)",
+ "hsl(0, 0%, 0%)", "HSL(0,0%,0%)",
+ "hsl(0,0%,0%,0)", "hsl(0,0%,0%,0.0)", "hsl(0,0%,0%,.0)",
+ "hsl(0,0%,0%, 0)", "hsl(0,0%,0%, 0.0)", "hsl(0,0%,0%, .0)",
+ "hsl(0,0%,0%,1)", "hsl(0,0%,0%,1.0)",
+ "hsla(0,0%,0%)", "hsla(0,0%,0%,0)", "HSLA(0,0%,0%)",
+ "hsl(1rad,0%,0%)", "hsl(1.1rad,0%,0%)", "hsl(.1rad,0%,0%)",
+ "hsl(-1rad,0%,0%)", "hsl(1RAD,0%,0%)",
].each do |color|
it "parses the valid hsl color #{color}" do
expect(subject.parse(color)).to eq(color)
@@ -74,12 +74,12 @@ describe Banzai::ColorParser do
end
[
- 'hsl(+0,0%,0%)', 'hsl(0,0,0%)', 'hsl(0,0%,0)', 'hsl(0 deg,0%,0%)',
- 'hsl(0,-0%,0%)', 'hsl(0,101%,0%)', 'hsl(0,-1%,0%)',
- 'hsl(0,0%,0%,-0.1)', 'hsl(0,0%,0%,-.1)',
- 'hsl(0,0%,0%,1.1)', 'hsl(0,0%,0%,2)',
- 'hsl(0,0%,0%,)', 'hsl(0,0%,0%,0.)', 'hsl(0,0%,0%,1.)',
- 'hsl(deg,0%,0%)', 'hsl(rad,0%,0%)'
+ "hsl(+0,0%,0%)", "hsl(0,0,0%)", "hsl(0,0%,0)", "hsl(0 deg,0%,0%)",
+ "hsl(0,-0%,0%)", "hsl(0,101%,0%)", "hsl(0,-1%,0%)",
+ "hsl(0,0%,0%,-0.1)", "hsl(0,0%,0%,-.1)",
+ "hsl(0,0%,0%,1.1)", "hsl(0,0%,0%,2)",
+ "hsl(0,0%,0%,)", "hsl(0,0%,0%,0.)", "hsl(0,0%,0%,1.)",
+ "hsl(deg,0%,0%)", "hsl(rad,0%,0%)",
].each do |color|
it "does not parse the invalid hsl color #{color}" do
expect(subject.parse(color)).to be_nil
diff --git a/spec/lib/banzai/commit_renderer_spec.rb b/spec/lib/banzai/commit_renderer_spec.rb
index 1f53657c59c..9abfc660c31 100644
--- a/spec/lib/banzai/commit_renderer_spec.rb
+++ b/spec/lib/banzai/commit_renderer_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::CommitRenderer do
- describe '.render' do
- it 'renders a commit description and title' do
+ describe ".render" do
+ it "renders a commit description and title" do
user = build(:user)
project = create(:project, :repository)
diff --git a/spec/lib/banzai/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb
index ba995e16be7..e4f9c5f748f 100644
--- a/spec/lib/banzai/cross_project_reference_spec.rb
+++ b/spec/lib/banzai/cross_project_reference_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::CrossProjectReference do
let(:including_class) { Class.new.include(described_class).new }
@@ -8,41 +8,41 @@ describe Banzai::CrossProjectReference do
allow(including_class).to receive(:parent_from_ref).and_call_original
end
- describe '#parent_from_ref' do
- context 'when no project was referenced' do
- it 'returns the project from context' do
+ describe "#parent_from_ref" do
+ context "when no project was referenced" do
+ it "returns the project from context" do
project = double
- allow(including_class).to receive(:context).and_return({ project: project })
+ allow(including_class).to receive(:context).and_return({project: project})
expect(including_class.parent_from_ref(nil)).to eq project
end
end
- context 'when no project was referenced in group context' do
- it 'returns the group from context' do
+ context "when no project was referenced in group context" do
+ it "returns the group from context" do
group = double
- allow(including_class).to receive(:context).and_return({ group: group })
+ allow(including_class).to receive(:context).and_return({group: group})
expect(including_class.parent_from_ref(nil)).to eq group
end
end
- context 'when referenced project does not exist' do
- it 'returns nil' do
- expect(including_class.parent_from_ref('invalid/reference')).to be_nil
+ context "when referenced project does not exist" do
+ it "returns nil" do
+ expect(including_class.parent_from_ref("invalid/reference")).to be_nil
end
end
- context 'when referenced project exists' do
- it 'returns the referenced project' do
- project2 = double('referenced project')
+ context "when referenced project exists" do
+ it "returns the referenced project" do
+ project2 = double("referenced project")
expect(Project).to receive(:find_by_full_path)
- .with('cross/reference').and_return(project2)
+ .with("cross/reference").and_return(project2)
- expect(including_class.parent_from_ref('cross/reference')).to eq project2
+ expect(including_class.parent_from_ref("cross/reference")).to eq project2
end
end
end
diff --git a/spec/lib/banzai/filter/absolute_link_filter_spec.rb b/spec/lib/banzai/filter/absolute_link_filter_spec.rb
index 50be551cd90..08d5d8a9244 100644
--- a/spec/lib/banzai/filter/absolute_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/absolute_link_filter_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::AbsoluteLinkFilter do
def filter(doc, context = {})
described_class.call(doc, context)
end
- context 'with html links' do
- context 'if only_path is false' do
+ context "with html links" do
+ context "if only_path is false" do
let(:only_path_context) do
- { only_path: false }
+ {only_path: false}
end
- let(:fake_url) { 'http://www.example.com' }
+ let(:fake_url) { "http://www.example.com" }
before do
allow(Gitlab.config.gitlab).to receive(:url).and_return(fake_url)
end
- context 'has the .gfm class' do
- it 'converts a relative url into absolute' do
- doc = filter(link('/foo', 'gfm'), only_path_context)
- expect(doc.at_css('a')['href']).to eq "#{fake_url}/foo"
+ context "has the .gfm class" do
+ it "converts a relative url into absolute" do
+ doc = filter(link("/foo", "gfm"), only_path_context)
+ expect(doc.at_css("a")["href"]).to eq "#{fake_url}/foo"
end
- it 'does not change the url if it already absolute' do
- doc = filter(link("#{fake_url}/foo", 'gfm'), only_path_context)
- expect(doc.at_css('a')['href']).to eq "#{fake_url}/foo"
+ it "does not change the url if it already absolute" do
+ doc = filter(link("#{fake_url}/foo", "gfm"), only_path_context)
+ expect(doc.at_css("a")["href"]).to eq "#{fake_url}/foo"
end
- context 'if relative_url_root is set' do
- it 'joins the url without doubling the path' do
+ context "if relative_url_root is set" do
+ it "joins the url without doubling the path" do
allow(Gitlab.config.gitlab).to receive(:url).and_return("#{fake_url}/gitlab/")
- doc = filter(link("/gitlab/foo", 'gfm'), only_path_context)
- expect(doc.at_css('a')['href']).to eq "#{fake_url}/gitlab/foo"
+ doc = filter(link("/gitlab/foo", "gfm"), only_path_context)
+ expect(doc.at_css("a")["href"]).to eq "#{fake_url}/gitlab/foo"
end
end
end
- context 'has not the .gfm class' do
- it 'does not convert a relative url into absolute' do
- doc = filter(link('/foo'), only_path_context)
- expect(doc.at_css('a')['href']).to eq '/foo'
+ context "has not the .gfm class" do
+ it "does not convert a relative url into absolute" do
+ doc = filter(link("/foo"), only_path_context)
+ expect(doc.at_css("a")["href"]).to eq "/foo"
end
end
end
- context 'if only_path is not false' do
- it 'does not convert a relative url into absolute' do
- expect(filter(link('/foo', 'gfm')).at_css('a')['href']).to eq '/foo'
- expect(filter(link('/foo')).at_css('a')['href']).to eq '/foo'
+ context "if only_path is not false" do
+ it "does not convert a relative url into absolute" do
+ expect(filter(link("/foo", "gfm")).at_css("a")["href"]).to eq "/foo"
+ expect(filter(link("/foo")).at_css("a")["href"]).to eq "/foo"
end
end
end
- def link(path, css_class = '')
+ def link(path, css_class = "")
%(<a class="#{css_class}" href="#{path}">example</a>)
end
end
diff --git a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb
index 1e82d18d056..459818e6016 100644
--- a/spec/lib/banzai/filter/abstract_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/abstract_reference_filter_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::AbstractReferenceFilter do
let(:project) { create(:project) }
- describe '#references_per_parent' do
- it 'returns a Hash containing references grouped per parent paths' do
+ describe "#references_per_parent" do
+ it "returns a Hash containing references grouped per parent paths" do
doc = Nokogiri::HTML.fragment("#1 #{project.full_path}#2")
filter = described_class.new(doc, project: project)
@@ -18,44 +18,44 @@ describe Banzai::Filter::AbstractReferenceFilter do
end
end
- describe '#parent_per_reference' do
- it 'returns a Hash containing projects grouped per parent paths' do
- doc = Nokogiri::HTML.fragment('')
+ describe "#parent_per_reference" do
+ it "returns a Hash containing projects grouped per parent paths" do
+ doc = Nokogiri::HTML.fragment("")
filter = described_class.new(doc, project: project)
expect(filter).to receive(:references_per_parent)
- .and_return({ project.full_path => Set.new(%w[1]) })
+ .and_return({project.full_path => Set.new(%w[1])})
expect(filter.parent_per_reference)
- .to eq({ project.full_path => project })
+ .to eq({project.full_path => project})
end
end
- describe '#find_for_paths' do
- let(:doc) { Nokogiri::HTML.fragment('') }
+ describe "#find_for_paths" do
+ let(:doc) { Nokogiri::HTML.fragment("") }
let(:filter) { described_class.new(doc, project: project) }
- context 'with RequestStore disabled' do
- it 'returns a list of Projects for a list of paths' do
+ context "with RequestStore disabled" do
+ it "returns a list of Projects for a list of paths" do
expect(filter.find_for_paths([project.full_path]))
.to eq([project])
end
it "return an empty array for paths that don't exist" do
- expect(filter.find_for_paths(['nonexistent/project']))
+ expect(filter.find_for_paths(["nonexistent/project"]))
.to eq([])
end
end
- context 'with RequestStore enabled', :request_store do
- it 'returns a list of Projects for a list of paths' do
+ context "with RequestStore enabled", :request_store do
+ it "returns a list of Projects for a list of paths" do
expect(filter.find_for_paths([project.full_path]))
.to eq([project])
end
context "when no project with that path exists" do
it "returns no value" do
- expect(filter.find_for_paths(['nonexistent/project']))
+ expect(filter.find_for_paths(["nonexistent/project"]))
.to eq([])
end
@@ -63,19 +63,19 @@ describe Banzai::Filter::AbstractReferenceFilter do
project_refs_cache = {}
allow(filter).to receive(:refs_cache).and_return(project_refs_cache)
- filter.find_for_paths(['nonexistent/project'])
+ filter.find_for_paths(["nonexistent/project"])
- expect(project_refs_cache).to eq({ 'nonexistent/project' => nil })
+ expect(project_refs_cache).to eq({"nonexistent/project" => nil})
end
- context 'when the project refs cache includes nil values' do
+ context "when the project refs cache includes nil values" do
before do
# adds { 'nonexistent/project' => nil } to cache
- filter.from_ref_cached('nonexistent/project')
+ filter.from_ref_cached("nonexistent/project")
end
it "return an empty array for paths that don't exist" do
- expect(filter.find_for_paths(['nonexistent/project']))
+ expect(filter.find_for_paths(["nonexistent/project"]))
.to eq([])
end
end
@@ -83,9 +83,9 @@ describe Banzai::Filter::AbstractReferenceFilter do
end
end
- describe '#current_parent_path' do
- it 'returns the path of the current parent' do
- doc = Nokogiri::HTML.fragment('')
+ describe "#current_parent_path" do
+ it "returns the path of the current parent" do
+ doc = Nokogiri::HTML.fragment("")
filter = described_class.new(doc, project: project)
expect(filter.current_parent_path).to eq(project.full_path)
diff --git a/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb
index 34f1657b6d3..abf0e63d512 100644
--- a/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb
+++ b/spec/lib/banzai/filter/ascii_doc_post_processing_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::AsciiDocPostProcessingFilter do
include FilterSpecHelper
@@ -9,7 +9,7 @@ describe Banzai::Filter::AsciiDocPostProcessingFilter do
end
it "keeps content when no data-math-style found" do
- result = filter('<pre>some code</pre><div data-math>and</div>').to_html
- expect(result).to eq('<pre>some code</pre><div data-math>and</div>')
+ result = filter("<pre>some code</pre><div data-math>and</div>").to_html
+ expect(result).to eq("<pre>some code</pre><div data-math>and</div>")
end
end
diff --git a/spec/lib/banzai/filter/autolink_filter_spec.rb b/spec/lib/banzai/filter/autolink_filter_spec.rb
index 4972c4b4bd2..4b95e0839f2 100644
--- a/spec/lib/banzai/filter/autolink_filter_spec.rb
+++ b/spec/lib/banzai/filter/autolink_filter_spec.rb
@@ -1,141 +1,141 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::AutolinkFilter do
include FilterSpecHelper
- let(:link) { 'http://about.gitlab.com/' }
+ let(:link) { "http://about.gitlab.com/" }
let(:quotes) { ['"', "'"] }
- it 'does nothing when :autolink is false' do
+ it "does nothing when :autolink is false" do
exp = act = link
expect(filter(act, autolink: false).to_html).to eq exp
end
- it 'does nothing with non-link text' do
- exp = act = 'This text contains no links to autolink'
+ it "does nothing with non-link text" do
+ exp = act = "This text contains no links to autolink"
expect(filter(act).to_html).to eq exp
end
- context 'Various schemes' do
- it 'autolinks http' do
+ context "Various schemes" do
+ it "autolinks http" do
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks https' do
- link = 'https://google.com/'
+ it "autolinks https" do
+ link = "https://google.com/"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks ftp' do
- link = 'ftp://ftp.us.debian.org/debian/'
+ it "autolinks ftp" do
+ link = "ftp://ftp.us.debian.org/debian/"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks short URLs' do
- link = 'http://localhost:3000/'
+ it "autolinks short URLs" do
+ link = "http://localhost:3000/"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks multiple URLs' do
- link1 = 'http://localhost:3000/'
- link2 = 'http://google.com/'
+ it "autolinks multiple URLs" do
+ link1 = "http://localhost:3000/"
+ link2 = "http://google.com/"
doc = filter("See #{link1} and #{link2}")
- found_links = doc.css('a')
+ found_links = doc.css("a")
expect(found_links.size).to eq(2)
expect(found_links[0].text).to eq(link1)
- expect(found_links[0]['href']).to eq(link1)
+ expect(found_links[0]["href"]).to eq(link1)
expect(found_links[1].text).to eq(link2)
- expect(found_links[1]['href']).to eq(link2)
+ expect(found_links[1]["href"]).to eq(link2)
end
- it 'accepts link_attr options' do
- doc = filter("See #{link}", link_attr: { class: 'custom' })
+ it "accepts link_attr options" do
+ doc = filter("See #{link}", link_attr: {class: "custom"})
- expect(doc.at_css('a')['class']).to eq 'custom'
+ expect(doc.at_css("a")["class"]).to eq "custom"
end
- it 'autolinks smb' do
- link = 'smb:///Volumes/shared/foo.pdf'
+ it "autolinks smb" do
+ link = "smb:///Volumes/shared/foo.pdf"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks multiple occurrences of smb' do
- link1 = 'smb:///Volumes/shared/foo.pdf'
- link2 = 'smb:///Volumes/shared/bar.pdf'
+ it "autolinks multiple occurrences of smb" do
+ link1 = "smb:///Volumes/shared/foo.pdf"
+ link2 = "smb:///Volumes/shared/bar.pdf"
doc = filter("See #{link1} and #{link2}")
- found_links = doc.css('a')
+ found_links = doc.css("a")
expect(found_links.size).to eq(2)
expect(found_links[0].text).to eq(link1)
- expect(found_links[0]['href']).to eq(link1)
+ expect(found_links[0]["href"]).to eq(link1)
expect(found_links[1].text).to eq(link2)
- expect(found_links[1]['href']).to eq(link2)
+ expect(found_links[1]["href"]).to eq(link2)
end
- it 'autolinks irc' do
- link = 'irc://irc.freenode.net/git'
+ it "autolinks irc" do
+ link = "irc://irc.freenode.net/git"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'autolinks rdar' do
- link = 'rdar://localhost.com/blah'
+ it "autolinks rdar" do
+ link = "rdar://localhost.com/blah"
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq link
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a").text).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
end
- it 'does not autolink javascript' do
- link = 'javascript://alert(document.cookie);'
+ it "does not autolink javascript" do
+ link = "javascript://alert(document.cookie);"
doc = filter("See #{link}")
- expect(doc.at_css('a')).to be_nil
+ expect(doc.at_css("a")).to be_nil
end
- it 'does not autolink bad URLs' do
- link = 'foo://23423:::asdf'
+ it "does not autolink bad URLs" do
+ link = "foo://23423:::asdf"
doc = filter("See #{link}")
expect(doc.to_s).to eq("See #{link}")
end
- it 'does not autolink bad URLs after we remove trailing punctuation' do
- link = 'http://]'
+ it "does not autolink bad URLs after we remove trailing punctuation" do
+ link = "http://]"
doc = filter("See #{link}")
expect(doc.to_s).to eq("See #{link}")
end
- it 'does not include trailing punctuation' do
- ['.', ', ok?', '...', '?', '!', ': is that ok?'].each do |trailing_punctuation|
+ it "does not include trailing punctuation" do
+ [".", ", ok?", "...", "?", "!", ": is that ok?"].each do |trailing_punctuation|
doc = filter("See #{link}#{trailing_punctuation}")
- expect(doc.at_css('a').text).to eq link
+ expect(doc.at_css("a").text).to eq link
end
end
- it 'includes trailing punctuation when part of a balanced pair' do
+ it "includes trailing punctuation when part of a balanced pair" do
described_class::PUNCTUATION_PAIRS.each do |close, open|
next if open.in?(quotes)
@@ -144,71 +144,71 @@ describe Banzai::Filter::AutolinkFilter do
unbalanced_link = "#{link}#{close}"
unbalanced_actual = filter("See #{unbalanced_link}...")
- expect(balanced_actual.at_css('a').text).to eq(balanced_link)
+ expect(balanced_actual.at_css("a").text).to eq(balanced_link)
expect(unescape(balanced_actual.to_html)).to eq(Rinku.auto_link("See #{balanced_link}..."))
- expect(unbalanced_actual.at_css('a').text).to eq(link)
+ expect(unbalanced_actual.at_css("a").text).to eq(link)
expect(unescape(unbalanced_actual.to_html)).to eq(Rinku.auto_link("See #{unbalanced_link}..."))
end
end
- it 'removes trailing quotes' do
+ it "removes trailing quotes" do
quotes.each do |quote|
balanced_link = "#{link}#{quote}abc#{quote}"
balanced_actual = filter("See #{balanced_link}...")
unbalanced_link = "#{link}#{quote}"
unbalanced_actual = filter("See #{unbalanced_link}...")
- expect(balanced_actual.at_css('a').text).to eq(balanced_link[0...-1])
+ expect(balanced_actual.at_css("a").text).to eq(balanced_link[0...-1])
expect(unescape(balanced_actual.to_html)).to eq(Rinku.auto_link("See #{balanced_link}..."))
- expect(unbalanced_actual.at_css('a').text).to eq(link)
+ expect(unbalanced_actual.at_css("a").text).to eq(link)
expect(unescape(unbalanced_actual.to_html)).to eq(Rinku.auto_link("See #{unbalanced_link}..."))
end
end
- it 'removes one closing punctuation mark when the punctuation in the link is unbalanced' do
+ it "removes one closing punctuation mark when the punctuation in the link is unbalanced" do
complicated_link = "(#{link}(a'b[c'd]))'"
- expected_complicated_link = %Q{(<a href="#{link}(a'b[c'd]))">#{link}(a'b[c'd]))</a>'}
+ expected_complicated_link = %{(<a href="#{link}(a'b[c'd]))">#{link}(a'b[c'd]))</a>'}
actual = unescape(filter(complicated_link).to_html)
expect(actual).to eq(Rinku.auto_link(complicated_link))
expect(actual).to eq(expected_complicated_link)
end
- it 'does not double-encode HTML entities' do
+ it "does not double-encode HTML entities" do
encoded_link = "#{link}?foo=bar&amp;baz=quux"
- expected_encoded_link = %Q{<a href="#{encoded_link}">#{encoded_link}</a>}
+ expected_encoded_link = %(<a href="#{encoded_link}">#{encoded_link}</a>)
actual = unescape(filter(encoded_link).to_html)
expect(actual).to eq(Rinku.auto_link(encoded_link))
expect(actual).to eq(expected_encoded_link)
end
- it 'does not include trailing HTML entities' do
+ it "does not include trailing HTML entities" do
doc = filter("See &lt;&lt;&lt;#{link}&gt;&gt;&gt;")
- expect(doc.at_css('a')['href']).to eq link
+ expect(doc.at_css("a")["href"]).to eq link
expect(doc.text).to eq "See <<<#{link}>>>"
end
- it 'accepts link_attr options' do
- doc = filter("See #{link}", link_attr: { class: 'custom' })
- expect(doc.at_css('a')['class']).to eq 'custom'
+ it "accepts link_attr options" do
+ doc = filter("See #{link}", link_attr: {class: "custom"})
+ expect(doc.at_css("a")["class"]).to eq "custom"
end
- it 'escapes RTLO and other characters' do
+ it "escapes RTLO and other characters" do
# rendered text looks like "http://example.com/evilexe.mp3"
evil_link = "#{link}evil\u202E3pm.exe"
- doc = filter("#{evil_link}")
+ doc = filter(evil_link.to_s)
- expect(doc.at_css('a')['href']).to eq "http://about.gitlab.com/evil%E2%80%AE3pm.exe"
+ expect(doc.at_css("a")["href"]).to eq "http://about.gitlab.com/evil%E2%80%AE3pm.exe"
end
- it 'encodes international domains' do
+ it "encodes international domains" do
link = "http://one😄two.com"
expected = "http://one%F0%9F%98%84two.com"
doc = filter(link)
- expect(doc.at_css('a')['href']).to eq expected
+ expect(doc.at_css("a")["href"]).to eq expected
end
described_class::IGNORE_PARENTS.each do |elem|
@@ -219,12 +219,12 @@ describe Banzai::Filter::AutolinkFilter do
end
end
- context 'when the link is inside a tag' do
+ context "when the link is inside a tag" do
%w[http rdar].each do |protocol|
it "renders text after the link correctly for #{protocol}" do
doc = filter(ERB::Util.html_escape_once("<#{protocol}://link><another>"))
- expect(doc.children.last.text).to include('<another>')
+ expect(doc.children.last.text).to include("<another>")
end
end
end
diff --git a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
index b645e49bd43..1a7e5cafd33 100644
--- a/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
+++ b/spec/lib/banzai/filter/blockquote_fence_filter_spec.rb
@@ -1,18 +1,18 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Filter::BlockquoteFenceFilter do
include FilterSpecHelper
- it 'converts blockquote fences to blockquote lines' do
- content = File.read(Rails.root.join('spec/fixtures/blockquote_fence_before.md'))
- expected = File.read(Rails.root.join('spec/fixtures/blockquote_fence_after.md'))
+ it "converts blockquote fences to blockquote lines" do
+ content = File.read(Rails.root.join("spec/fixtures/blockquote_fence_before.md"))
+ expected = File.read(Rails.root.join("spec/fixtures/blockquote_fence_after.md"))
output = filter(content)
expect(output).to eq(expected)
end
- it 'allows trailing whitespace on blockquote fence lines' do
+ it "allows trailing whitespace on blockquote fence lines" do
expect(filter(">>> \ntest\n>>> ")).to eq("> test")
end
end
diff --git a/spec/lib/banzai/filter/color_filter_spec.rb b/spec/lib/banzai/filter/color_filter_spec.rb
index a098b037510..975dca0c94c 100644
--- a/spec/lib/banzai/filter/color_filter_spec.rb
+++ b/spec/lib/banzai/filter/color_filter_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ColorFilter, lib: true do
include FilterSpecHelper
- let(:color) { '#F00' }
- let(:color_chip_selector) { 'code > span.gfm-color_chip > span' }
+ let(:color) { "#F00" }
+ let(:color_chip_selector) { "code > span.gfm-color_chip > span" }
- ['#123', '#1234', '#123456', '#12345678',
- 'rgb(0,0,0)', 'RGB(0, 0, 0)', 'rgba(0,0,0,1)', 'RGBA(0,0,0,0.7)',
- 'hsl(270,30%,50%)', 'HSLA(270, 30%, 50%, .7)'].each do |color|
+ ["#123", "#1234", "#123456", "#12345678",
+ "rgb(0,0,0)", "RGB(0, 0, 0)", "rgba(0,0,0,1)", "RGBA(0,0,0,0.7)",
+ "hsl(270,30%,50%)", "HSLA(270, 30%, 50%, .7)",].each do |color|
it "inserts color chip for supported color format #{color}" do
content = code_tag(color)
doc = filter(content)
color_chip = doc.at_css(color_chip_selector)
expect(color_chip.content).to be_empty
- expect(color_chip.parent[:class]).to eq 'gfm-color_chip'
+ expect(color_chip.parent[:class]).to eq "gfm-color_chip"
expect(color_chip[:style]).to eq "background-color: #{color};"
end
end
- it 'ignores valid color code without backticks(code tags)' do
+ it "ignores valid color code without backticks(code tags)" do
doc = filter(color)
- expect(doc.css('span.gfm-color_chip').size).to be_zero
+ expect(doc.css("span.gfm-color_chip").size).to be_zero
end
- it 'ignores valid color code with prepended space' do
- content = code_tag(' ' + color)
+ it "ignores valid color code with prepended space" do
+ content = code_tag(" " + color)
doc = filter(content)
expect(doc.css(color_chip_selector).size).to be_zero
end
- it 'ignores valid color code with appended space' do
- content = code_tag(color + ' ')
+ it "ignores valid color code with appended space" do
+ content = code_tag(color + " ")
doc = filter(content)
expect(doc.css(color_chip_selector).size).to be_zero
end
- it 'ignores valid color code surrounded by spaces' do
- content = code_tag(' ' + color + ' ')
+ it "ignores valid color code surrounded by spaces" do
+ content = code_tag(" " + color + " ")
doc = filter(content)
expect(doc.css(color_chip_selector).size).to be_zero
end
- it 'ignores invalid color code' do
- invalid_color = '#BAR'
+ it "ignores invalid color code" do
+ invalid_color = "#BAR"
content = code_tag(invalid_color)
doc = filter(content)
diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb
index 4daf6be1bb7..ad1f05ff2af 100644
--- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::CommitRangeReferenceFilter do
include FilterSpecHelper
@@ -10,53 +10,53 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
let(:range) { CommitRange.new("#{commit1.id}...#{commit2.id}", project) }
let(:range2) { CommitRange.new("#{commit1.id}..#{commit2.id}", project) }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Commit Range #{range.to_reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'internal reference' do
+ context "internal reference" do
let(:reference) { range.to_reference }
let(:reference2) { range2.to_reference }
- it 'links to a valid two-dot reference' do
+ it "links to a valid two-dot reference" do
doc = reference_filter("See #{reference2}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_compare_url(project, range2.to_param)
end
- it 'links to a valid three-dot reference' do
+ it "links to a valid three-dot reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_compare_url(project, range.to_param)
end
- it 'links to a valid short ID' do
+ it "links to a valid short ID" do
reference = "#{commit1.short_id}...#{commit2.id}"
reference2 = "#{commit1.id}...#{commit2.short_id}"
- exp = commit1.short_id + '...' + commit2.short_id
+ exp = commit1.short_id + "..." + commit2.short_id
- expect(reference_filter("See #{reference}").css('a').first.text).to eq exp
- expect(reference_filter("See #{reference2}").css('a').first.text).to eq exp
+ expect(reference_filter("See #{reference}").css("a").first.text).to eq exp
+ expect(reference_filter("See #{reference2}").css("a").first.text).to eq exp
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("See (#{reference}.)")
exp = Regexp.escape(range.reference_link_text)
expect(doc.to_html).to match(%r{\(<a.+>#{exp}</a>\.\)})
end
- it 'ignores invalid commit IDs' do
+ it "ignores invalid commit IDs" do
exp = act = "See #{commit1.id.reverse}...#{commit2.id}"
allow(project.repository).to receive(:commit).with(commit1.id.reverse)
@@ -64,66 +64,66 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
expect(reference_filter(act).to_html).to eq exp
end
- it 'includes no title attribute' do
+ it "includes no title attribute" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('title')).to eq ""
+ expect(doc.css("a").first.attr("title")).to eq ""
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-commit_range has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-commit_range has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-commit-range attribute' do
+ it "includes a data-commit-range attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-commit-range')
- expect(link.attr('data-commit-range')).to eq range.to_s
+ expect(link).to have_attribute("data-commit-range")
+ expect(link.attr("data-commit-range")).to eq range.to_s
end
- it 'supports an :only_path option' do
+ it "supports an :only_path option" do
doc = reference_filter("See #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.project_compare_url(project, from: commit1.id, to: commit2.id, only_path: true)
end
end
- context 'cross-project / cross-namespace complete reference' do
+ context "cross-project / cross-namespace complete reference" do
let(:project2) { create(:project, :public, :repository) }
let(:reference) { "#{project2.full_path}@#{commit1.id}...#{commit2.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_compare_url(project2, range.to_param)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eql("#{project2.full_path}@#{commit1.short_id}...#{commit2.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eql("Fixed (#{project2.full_path}@#{commit1.short_id}...#{commit2.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Fixed #{project2.full_path}@#{commit1.id.reverse}...#{commit2.id}"
expect(reference_filter(act).to_html).to eq exp
@@ -132,33 +132,33 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
end
end
- context 'cross-project / same-namespace complete reference' do
+ context "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, :repository, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, path: "same-namespace", namespace: namespace) }
let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_compare_url(project2, range.to_param)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eql("Fixed (#{project2.path}@#{commit1.short_id}...#{commit2.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Fixed #{project2.path}@#{commit1.id.reverse}...#{commit2.id}"
expect(reference_filter(act).to_html).to eq exp
@@ -167,33 +167,33 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
end
end
- context 'cross-project shorthand reference' do
+ context "cross-project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, :repository, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, path: "same-namespace", namespace: namespace) }
let(:reference) { "#{project2.path}@#{commit1.id}...#{commit2.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_compare_url(project2, range.to_param)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eql("#{project2.path}@#{commit1.short_id}...#{commit2.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eql("Fixed (#{project2.path}@#{commit1.short_id}...#{commit2.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Fixed #{project2.path}@#{commit1.id.reverse}...#{commit2.id}"
expect(reference_filter(act).to_html).to eq exp
@@ -202,31 +202,31 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
end
end
- context 'cross-project URL reference' do
+ context "cross-project URL reference" do
let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:range) { CommitRange.new("#{commit1.id}...master", project) }
- let(:reference) { urls.project_compare_url(project2, from: commit1.id, to: 'master') }
+ let(:reference) { urls.project_compare_url(project2, from: commit1.id, to: "master") }
before do
range.project = project2
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq reference
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference}.)")
exp = Regexp.escape(range.reference_link_text(project))
expect(doc.to_html).to match(%r{\(<a.+>#{exp}</a>\.\)})
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Fixed #{project2.to_reference}@#{commit1.id.reverse}...#{commit2.id}"
expect(reference_filter(act).to_html).to eq exp
@@ -235,19 +235,19 @@ describe Banzai::Filter::CommitRangeReferenceFilter do
end
end
- context 'group context' do
- let(:context) { { project: nil, group: create(:group) } }
+ context "group context" do
+ let(:context) { {project: nil, group: create(:group)} }
- it 'ignores internal references' do
+ it "ignores internal references" do
exp = act = "See #{range.to_reference}"
expect(reference_filter(act, context).to_html).to eq exp
end
- it 'links to a full-path reference' do
+ it "links to a full-path reference" do
reference = "#{project.full_path}@#{commit1.short_id}...#{commit2.short_id}"
- expect(reference_filter("See #{reference}", context).css('a').first.text).to eql(reference)
+ expect(reference_filter("See #{reference}", context).css("a").first.text).to eql(reference)
end
end
end
diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb
index d6c9e9e4b19..1e100665f7a 100644
--- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::CommitReferenceFilter do
include FilterSpecHelper
@@ -6,18 +6,18 @@ describe Banzai::Filter::CommitReferenceFilter do
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Commit #{commit.id}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'internal reference' do
+ context "internal reference" do
let(:reference) { commit.id }
# Let's test a variety of commit SHA sizes just to be paranoid
@@ -25,13 +25,13 @@ describe Banzai::Filter::CommitReferenceFilter do
it "links to a valid reference of #{size} characters" do
doc = reference_filter("See #{reference[0...size]}")
- expect(doc.css('a').first.text).to eq commit.short_id
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.text).to eq commit.short_id
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_commit_url(project, reference)
end
end
- it 'always uses the short ID as the link text' do
+ it "always uses the short ID as the link text" do
doc = reference_filter("See #{commit.id}")
expect(doc.text).to eq "See #{commit.short_id}"
@@ -39,57 +39,57 @@ describe Banzai::Filter::CommitReferenceFilter do
expect(doc.text).to eq "See #{commit.short_id}"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{commit.short_id}</a>\.\)})
end
- it 'ignores invalid commit IDs' do
+ it "ignores invalid commit IDs" do
invalid = invalidate_reference(reference)
exp = act = "See #{invalid}"
expect(reference_filter(act).to_html).to eq exp
end
- it 'includes a title attribute' do
+ it "includes a title attribute" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('title')).to eq commit.title
+ expect(doc.css("a").first.attr("title")).to eq commit.title
end
- it 'escapes the title attribute' do
- allow_any_instance_of(Commit).to receive(:title).and_return(%{"></a>whatever<a title="})
+ it "escapes the title attribute" do
+ allow_any_instance_of(Commit).to receive(:title).and_return(%("></a>whatever<a title="))
doc = reference_filter("See #{reference}")
expect(doc.text).to eq "See #{commit.short_id}"
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-commit has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-commit has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-commit attribute' do
+ it "includes a data-commit attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-commit')
- expect(link.attr('data-commit')).to eq commit.id
+ expect(link).to have_attribute("data-commit")
+ expect(link.attr("data-commit")).to eq commit.id
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("See #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.project_commit_url(project, reference, only_path: true)
end
@@ -97,161 +97,161 @@ describe Banzai::Filter::CommitReferenceFilter do
let(:noteable) { create(:merge_request, target_project: project, source_project: project) }
let(:commit) { noteable.commits.first }
- it 'handles merge request contextual commit references' do
+ it "handles merge request contextual commit references" do
url = urls.diffs_project_merge_request_url(project, noteable, commit_id: commit.id)
doc = reference_filter("See #{reference}", noteable: noteable)
- expect(doc.css('a').first[:href]).to eq(url)
+ expect(doc.css("a").first[:href]).to eq(url)
end
end
end
- context 'cross-project / cross-namespace complete reference' do
+ context "cross-project / cross-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit }
let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.full_path}@#{commit.short_id}")
+ expect(doc.css("a").first.text).to eql("#{project2.full_path}@#{commit.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text).to eql("See (#{project2.full_path}@#{commit.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Committed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project / same-namespace complete reference' do
+ context "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit }
let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}@#{commit.short_id}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}@#{commit.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text).to eql("See (#{project2.path}@#{commit.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Committed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project shorthand reference' do
+ context "cross-project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit }
let(:reference) { "#{project2.full_path}@#{commit.short_id}" }
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}@#{commit.short_id}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}@#{commit.short_id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text).to eql("See (#{project2.path}@#{commit.short_id}.)")
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
exp = act = "Committed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project URL reference' do
+ context "cross-project URL reference" do
let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit }
let(:reference) { urls.project_commit_url(project2, commit.id) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_commit_url(project2, commit.id)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{commit.reference_link_text(project)}</a>\.\)})
end
- it 'ignores invalid commit IDs on the referenced project' do
+ it "ignores invalid commit IDs on the referenced project" do
act = "Committed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to match(%r{<a.+>#{Regexp.escape(invalidate_reference(reference))}</a>})
end
end
- context 'URL reference for a commit patch' do
+ context "URL reference for a commit patch" do
let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, :repository, namespace: namespace) }
let(:commit) { project2.commit }
let(:link) { urls.project_commit_url(project2, commit.id) }
- let(:extension) { '.patch' }
+ let(:extension) { ".patch" }
let(:reference) { link + extension }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq reference
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See #{reference}")
expect(doc.text).to eq("See #{commit.reference_link_text(project)} (patch)")
end
- it 'does not link to patch when extension match is after the path' do
+ it "does not link to patch when extension match is after the path" do
invalidate_commit_reference = reference_filter("#{link}/builds.patch")
doc = reference_filter("See (#{invalidate_commit_reference})")
- expect(doc.css('a').first.attr('href')).to eq "#{link}/builds"
+ expect(doc.css("a").first.attr("href")).to eq "#{link}/builds"
expect(doc.text).to eq("See (#{commit.reference_link_text(project)} (builds).patch)")
end
end
- context 'group context' do
- let(:context) { { project: nil, group: create(:group) } }
+ context "group context" do
+ let(:context) { {project: nil, group: create(:group)} }
- it 'ignores internal references' do
+ it "ignores internal references" do
exp = act = "See #{commit.id}"
expect(reference_filter(act, context).to_html).to eq exp
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
act = "See #{project.full_path}@#{commit.id}"
- expect(reference_filter(act, context).css('a').first.text).to eql("#{project.full_path}@#{commit.short_id}")
+ expect(reference_filter(act, context).css("a").first.text).to eql("#{project.full_path}@#{commit.short_id}")
end
end
end
diff --git a/spec/lib/banzai/filter/commit_trailers_filter_spec.rb b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb
index 068cdc85a07..6c49825a949 100644
--- a/spec/lib/banzai/filter/commit_trailers_filter_spec.rb
+++ b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'ffaker'
+require "spec_helper"
+require "ffaker"
describe Banzai::Filter::CommitTrailersFilter do
include FilterSpecHelper
@@ -13,16 +13,16 @@ describe Banzai::Filter::CommitTrailersFilter do
let(:commit_message) { trailer_line(trailer, user.name, user.email) }
let(:commit_message_html) { commit_html(commit_message) }
- context 'detects' do
+ context "detects" do
let(:email) { FFaker::Internet.email }
- it 'trailers in the form of *-by and replace users with links' do
+ it "trailers in the form of *-by and replace users with links" do
doc = filter(commit_message_html)
expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
end
- it 'trailers prefixed with whitespaces' do
+ it "trailers prefixed with whitespaces" do
message_html = commit_html("\n\r #{commit_message}")
doc = filter(message_html)
@@ -30,7 +30,7 @@ describe Banzai::Filter::CommitTrailersFilter do
expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
end
- it 'GitLab users via a secondary email' do
+ it "GitLab users via a secondary email" do
_, message_html = build_commit_message(
trailer: trailer,
name: secondary_email.user.name,
@@ -47,9 +47,9 @@ describe Banzai::Filter::CommitTrailersFilter do
)
end
- context 'non GitLab users' do
- shared_examples 'mailto links' do
- it 'replaces them with mailto links' do
+ context "non GitLab users" do
+ shared_examples "mailto links" do
+ it "replaces them with mailto links" do
_, message_html = build_commit_message(
trailer: trailer,
name: FFaker::Name.name,
@@ -62,24 +62,24 @@ describe Banzai::Filter::CommitTrailersFilter do
end
end
- context 'when Gravatar is disabled' do
+ context "when Gravatar is disabled" do
before do
stub_application_setting(gravatar_enabled: false)
end
- it_behaves_like 'mailto links'
+ it_behaves_like "mailto links"
end
- context 'when Gravatar is enabled' do
+ context "when Gravatar is enabled" do
before do
stub_application_setting(gravatar_enabled: true)
end
- it_behaves_like 'mailto links'
+ it_behaves_like "mailto links"
end
end
- it 'multiple trailers in the same message' do
+ it "multiple trailers in the same message" do
different_trailer = "#{FFaker::Lorem.word}-by:"
message = commit_html %(
#{commit_message}
@@ -92,11 +92,11 @@ describe Banzai::Filter::CommitTrailersFilter do
expect_to_have_mailto_link_with_avatar(doc, email: email, trailer: different_trailer)
end
- context 'special names' do
+ context "special names" do
where(:name) do
[
- 'John S. Doe',
- 'L33t H@x0r'
+ "John S. Doe",
+ "L33t H@x0r",
]
end
@@ -118,33 +118,33 @@ describe Banzai::Filter::CommitTrailersFilter do
end
context "ignores" do
- it 'commit messages without trailers' do
+ it "commit messages without trailers" do
exp = message = commit_html(FFaker::Lorem.sentence)
doc = filter(message)
expect(doc.to_html).to match Regexp.escape(exp)
end
- it 'trailers that are inline the commit message body' do
+ it "trailers that are inline the commit message body" do
message = commit_html %(
#{FFaker::Lorem.sentence} #{commit_message} #{FFaker::Lorem.sentence}
)
doc = filter(message)
- expect(doc.css('a').size).to eq 0
+ expect(doc.css("a").size).to eq 0
end
end
context "structure" do
- it 'preserves the commit trailer structure' do
+ it "preserves the commit trailer structure" do
doc = filter(commit_message_html)
expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer)
expect(doc.text).to match Regexp.escape(commit_message)
end
- it 'preserves the original name used in the commit message' do
+ it "preserves the original name used in the commit message" do
message, message_html = build_commit_message(
trailer: trailer,
name: FFaker::Name.name,
@@ -157,7 +157,7 @@ describe Banzai::Filter::CommitTrailersFilter do
expect(doc.text).to match Regexp.escape(message)
end
- it 'preserves the original email used in the commit message' do
+ it "preserves the original email used in the commit message" do
message, message_html = build_commit_message(
trailer: trailer,
name: secondary_email.user.name,
@@ -175,7 +175,7 @@ describe Banzai::Filter::CommitTrailersFilter do
expect(doc.text).to match Regexp.escape(message)
end
- it 'only replaces trailer lines not the full commit message' do
+ it "only replaces trailer lines not the full commit message" do
commit_body = FFaker::Lorem.paragraph
message = commit_html %(
#{commit_body}
diff --git a/spec/lib/banzai/filter/emoji_filter_spec.rb b/spec/lib/banzai/filter/emoji_filter_spec.rb
index 85a4619e33d..aa66d35db07 100644
--- a/spec/lib/banzai/filter/emoji_filter_spec.rb
+++ b/spec/lib/banzai/filter/emoji_filter_spec.rb
@@ -1,103 +1,103 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::EmojiFilter do
include FilterSpecHelper
- it 'replaces supported name emoji' do
- doc = filter('<p>:heart:</p>')
- expect(doc.css('gl-emoji').first.text).to eq '❤'
+ it "replaces supported name emoji" do
+ doc = filter("<p>:heart:</p>")
+ expect(doc.css("gl-emoji").first.text).to eq "❤"
end
- it 'replaces supported unicode emoji' do
- doc = filter('<p>❤️</p>')
- expect(doc.css('gl-emoji').first.text).to eq '❤'
+ it "replaces supported unicode emoji" do
+ doc = filter("<p>❤️</p>")
+ expect(doc.css("gl-emoji").first.text).to eq "❤"
end
- it 'ignores unsupported emoji' do
- exp = act = '<p>:foo:</p>'
+ it "ignores unsupported emoji" do
+ exp = act = "<p>:foo:</p>"
doc = filter(act)
expect(doc.to_html).to match Regexp.escape(exp)
end
- it 'correctly encodes the URL' do
- doc = filter('<p>:+1:</p>')
- expect(doc.css('gl-emoji').first.text).to eq '👍'
+ it "correctly encodes the URL" do
+ doc = filter("<p>:+1:</p>")
+ expect(doc.css("gl-emoji").first.text).to eq "👍"
end
- it 'correctly encodes unicode to the URL' do
- doc = filter('<p>👍</p>')
- expect(doc.css('gl-emoji').first.text).to eq '👍'
+ it "correctly encodes unicode to the URL" do
+ doc = filter("<p>👍</p>")
+ expect(doc.css("gl-emoji").first.text).to eq "👍"
end
- it 'matches at the start of a string' do
- doc = filter(':+1:')
- expect(doc.css('gl-emoji').size).to eq 1
+ it "matches at the start of a string" do
+ doc = filter(":+1:")
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'unicode matches at the start of a string' do
+ it "unicode matches at the start of a string" do
doc = filter("'👍'")
- expect(doc.css('gl-emoji').size).to eq 1
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'matches at the end of a string' do
- doc = filter('This gets a :-1:')
- expect(doc.css('gl-emoji').size).to eq 1
+ it "matches at the end of a string" do
+ doc = filter("This gets a :-1:")
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'unicode matches at the end of a string' do
- doc = filter('This gets a 👍')
- expect(doc.css('gl-emoji').size).to eq 1
+ it "unicode matches at the end of a string" do
+ doc = filter("This gets a 👍")
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'matches with adjacent text' do
- doc = filter('+1 (:+1:)')
- expect(doc.css('gl-emoji').size).to eq 1
+ it "matches with adjacent text" do
+ doc = filter("+1 (:+1:)")
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'unicode matches with adjacent text' do
- doc = filter('+1 (👍)')
- expect(doc.css('gl-emoji').size).to eq 1
+ it "unicode matches with adjacent text" do
+ doc = filter("+1 (👍)")
+ expect(doc.css("gl-emoji").size).to eq 1
end
- it 'does not match multiple emoji in a row' do
- doc = filter(':see_no_evil::hear_no_evil::speak_no_evil:')
- expect(doc.css('gl-emoji').size).to eq 0
+ it "does not match multiple emoji in a row" do
+ doc = filter(":see_no_evil::hear_no_evil::speak_no_evil:")
+ expect(doc.css("gl-emoji").size).to eq 0
end
- it 'unicode matches multiple emoji in a row' do
+ it "unicode matches multiple emoji in a row" do
doc = filter("'🙈🙉🙊'")
- expect(doc.css('gl-emoji').size).to eq 3
+ expect(doc.css("gl-emoji").size).to eq 3
end
- it 'mixed matches multiple emoji in a row' do
+ it "mixed matches multiple emoji in a row" do
doc = filter("'🙈:see_no_evil:🙉:hear_no_evil:🙊:speak_no_evil:'")
- expect(doc.css('gl-emoji').size).to eq 6
+ expect(doc.css("gl-emoji").size).to eq 6
end
- it 'does not match emoji in a string' do
+ it "does not match emoji in a string" do
doc = filter("'2a00:a4c0:100::1'")
- expect(doc.css('gl-emoji').size).to eq 0
+ expect(doc.css("gl-emoji").size).to eq 0
end
- it 'has a data-name attribute' do
- doc = filter(':-1:')
- expect(doc.css('gl-emoji').first.attr('data-name')).to eq 'thumbsdown'
+ it "has a data-name attribute" do
+ doc = filter(":-1:")
+ expect(doc.css("gl-emoji").first.attr("data-name")).to eq "thumbsdown"
end
- it 'has a data-unicode-version attribute' do
- doc = filter(':-1:')
- expect(doc.css('gl-emoji').first.attr('data-unicode-version')).to eq '6.0'
+ it "has a data-unicode-version attribute" do
+ doc = filter(":-1:")
+ expect(doc.css("gl-emoji").first.attr("data-unicode-version")).to eq "6.0"
end
- it 'keeps whitespace intact' do
- doc = filter('This deserves a :+1:, big time.')
+ it "keeps whitespace intact" do
+ doc = filter("This deserves a :+1:, big time.")
expect(doc.to_html).to match(/^This deserves a <gl-emoji.+>, big time\.\z/)
end
- it 'unicode keeps whitespace intact' do
- doc = filter('This deserves a 🎱, big time.')
+ it "unicode keeps whitespace intact" do
+ doc = filter("This deserves a 🎱, big time.")
expect(doc.to_html).to match(/^This deserves a <gl-emoji.+>, big time\.\z/)
end
diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb
index 43222ddb5e2..5db9aff0b40 100644
--- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ExternalIssueReferenceFilter do
include FilterSpecHelper
@@ -8,13 +8,13 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
end
shared_examples_for "external issue tracker" do
- it_behaves_like 'a reference containing an element node'
+ it_behaves_like "a reference containing an element node"
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Issue #{reference}</#{elem}>"
@@ -22,79 +22,79 @@ describe Banzai::Filter::ExternalIssueReferenceFilter do
end
end
- it 'ignores valid references when using default tracker' do
+ it "ignores valid references when using default tracker" do
expect(project).to receive(:default_issues_tracker?).and_return(true)
exp = act = "Issue #{reference}"
expect(filter(act).to_html).to eq exp
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = filter("Issue #{reference}")
- issue_id = doc.css('a').first.attr("data-external-issue")
+ issue_id = doc.css("a").first.attr("data-external-issue")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue_id, project)
end
- it 'links to the external tracker' do
+ it "links to the external tracker" do
doc = filter("Issue #{reference}")
- link = doc.css('a').first.attr('href')
- issue_id = doc.css('a').first.attr("data-external-issue")
+ link = doc.css("a").first.attr("href")
+ issue_id = doc.css("a").first.attr("data-external-issue")
expect(link).to eq(helper.url_for_issue(issue_id, project))
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = filter("Issue (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{reference}</a>\.\)})
end
- it 'includes a title attribute' do
+ it "includes a title attribute" do
doc = filter("Issue #{reference}")
- expect(doc.css('a').first.attr('title')).to include("Issue in #{project.issues_tracker.title}")
+ expect(doc.css("a").first.attr("title")).to include("Issue in #{project.issues_tracker.title}")
end
- it 'escapes the title attribute' do
+ it "escapes the title attribute" do
allow(project.external_issue_tracker).to receive(:title)
- .and_return(%{"></a>whatever<a title="})
+ .and_return(%("></a>whatever<a title="))
doc = filter("Issue #{reference}")
expect(doc.text).to eq "Issue #{reference}"
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = filter("Issue #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = filter("Issue #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
- issue_id = doc.css('a').first["data-external-issue"]
+ link = doc.css("a").first.attr("href")
+ issue_id = doc.css("a").first["data-external-issue"]
expect(link).to eq helper.url_for_issue(issue_id, project, only_path: true)
end
- context 'with RequestStore enabled', :request_store do
+ context "with RequestStore enabled", :request_store do
let(:reference_filter) { HTML::Pipeline.new([described_class]) }
- it 'queries the collection on the first call' do
+ it "queries the collection on the first call" do
expect_any_instance_of(Project).to receive(:default_issues_tracker?).once.and_call_original
expect_any_instance_of(Project).to receive(:external_issue_reference_pattern).once.and_call_original
- not_cached = reference_filter.call("look for #{reference}", { project: project })
+ not_cached = reference_filter.call("look for #{reference}", {project: project})
expect_any_instance_of(Project).not_to receive(:default_issues_tracker?)
expect_any_instance_of(Project).not_to receive(:external_issue_reference_pattern)
- cached = reference_filter.call("look for #{reference}", { project: project })
+ cached = reference_filter.call("look for #{reference}", {project: project})
# Links must be the same
- expect(cached[:output].css('a').first[:href]).to eq(not_cached[:output].css('a').first[:href])
+ expect(cached[:output].css("a").first[:href]).to eq(not_cached[:output].css("a").first[:href])
end
end
end
diff --git a/spec/lib/banzai/filter/external_link_filter_spec.rb b/spec/lib/banzai/filter/external_link_filter_spec.rb
index 2acbe05f082..629f0f1973d 100644
--- a/spec/lib/banzai/filter/external_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/external_link_filter_spec.rb
@@ -1,177 +1,177 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'an external link with rel attribute' do
+shared_examples "an external link with rel attribute" do
it 'adds rel="nofollow" to external links' do
- expect(doc.at_css('a')).to have_attribute('rel')
- expect(doc.at_css('a')['rel']).to include 'nofollow'
+ expect(doc.at_css("a")).to have_attribute("rel")
+ expect(doc.at_css("a")["rel"]).to include "nofollow"
end
it 'adds rel="noreferrer" to external links' do
- expect(doc.at_css('a')).to have_attribute('rel')
- expect(doc.at_css('a')['rel']).to include 'noreferrer'
+ expect(doc.at_css("a")).to have_attribute("rel")
+ expect(doc.at_css("a")["rel"]).to include "noreferrer"
end
it 'adds rel="noopener" to external links' do
- expect(doc.at_css('a')).to have_attribute('rel')
- expect(doc.at_css('a')['rel']).to include 'noopener'
+ expect(doc.at_css("a")).to have_attribute("rel")
+ expect(doc.at_css("a")["rel"]).to include "noopener"
end
end
describe Banzai::Filter::ExternalLinkFilter do
include FilterSpecHelper
- it 'ignores elements without an href attribute' do
- exp = act = %q(<a id="ignored">Ignore Me</a>)
+ it "ignores elements without an href attribute" do
+ exp = act = '<a id="ignored">Ignore Me</a>'
expect(filter(act).to_html).to eq exp
end
- it 'ignores non-HTTP(S) links' do
- exp = act = %q(<a href="irc://irc.freenode.net/gitlab">IRC</a>)
+ it "ignores non-HTTP(S) links" do
+ exp = act = '<a href="irc://irc.freenode.net/gitlab">IRC</a>'
expect(filter(act).to_html).to eq exp
end
- it 'skips internal links' do
+ it "skips internal links" do
internal = Gitlab.config.gitlab.url
- exp = act = %Q(<a href="#{internal}/sign_in">Login</a>)
+ exp = act = %(<a href="#{internal}/sign_in">Login</a>)
expect(filter(act).to_html).to eq exp
end
- context 'for root links on document' do
- let(:doc) { filter %q(<a href="https://google.com/">Google</a>) }
+ context "for root links on document" do
+ let(:doc) { filter '<a href="https://google.com/">Google</a>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- context 'for nested links on document' do
- let(:doc) { filter %q(<p><a href="https://google.com/">Google</a></p>) }
+ context "for nested links on document" do
+ let(:doc) { filter '<p><a href="https://google.com/">Google</a></p>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- context 'for invalid urls' do
- it 'adds rel and target attributes to broken hrefs' do
+ context "for invalid urls" do
+ it "adds rel and target attributes to broken hrefs" do
doc = filter %q(<p><a href="don't crash on broken urls">Google</a></p>)
expected = %q(<p><a href="don't%20crash%20on%20broken%20urls" rel="nofollow noreferrer noopener" target="_blank">Google</a></p>)
expect(doc.to_html).to eq(expected)
end
- it 'adds rel and target to improperly formatted mailtos' do
- doc = filter %q(<p><a href="mailto://jblogs@example.com">Email</a></p>)
- expected = %q(<p><a href="mailto://jblogs@example.com" rel="nofollow noreferrer noopener" target="_blank">Email</a></p>)
+ it "adds rel and target to improperly formatted mailtos" do
+ doc = filter '<p><a href="mailto://jblogs@example.com">Email</a></p>'
+ expected = '<p><a href="mailto://jblogs@example.com" rel="nofollow noreferrer noopener" target="_blank">Email</a></p>'
expect(doc.to_html).to eq(expected)
end
- it 'adds rel and target to improperly formatted autolinks' do
- doc = filter %q(<p><a href="mailto://jblogs@example.com">mailto://jblogs@example.com</a></p>)
- expected = %q(<p><a href="mailto://jblogs@example.com" rel="nofollow noreferrer noopener" target="_blank">mailto://jblogs@example.com</a></p>)
+ it "adds rel and target to improperly formatted autolinks" do
+ doc = filter '<p><a href="mailto://jblogs@example.com">mailto://jblogs@example.com</a></p>'
+ expected = '<p><a href="mailto://jblogs@example.com" rel="nofollow noreferrer noopener" target="_blank">mailto://jblogs@example.com</a></p>'
expect(doc.to_html).to eq(expected)
end
end
- context 'for links with a username' do
- context 'with a valid username' do
- let(:doc) { filter %q(<a href="https://user@google.com/">Google</a>) }
+ context "for links with a username" do
+ context "with a valid username" do
+ let(:doc) { filter '<a href="https://user@google.com/">Google</a>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- context 'with an impersonated username' do
+ context "with an impersonated username" do
let(:internal) { Gitlab.config.gitlab.url }
- let(:doc) { filter %Q(<a href="https://#{internal}@example.com" target="_blank">Reverse Tabnabbing</a>) }
+ let(:doc) { filter %(<a href="https://#{internal}@example.com" target="_blank">Reverse Tabnabbing</a>) }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
end
- context 'for non-lowercase scheme links' do
- context 'with http' do
- let(:doc) { filter %q(<p><a href="httP://google.com/">Google</a></p>) }
+ context "for non-lowercase scheme links" do
+ context "with http" do
+ let(:doc) { filter '<p><a href="httP://google.com/">Google</a></p>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- context 'with https' do
- let(:doc) { filter %q(<p><a href="hTTpS://google.com/">Google</a></p>) }
+ context "with https" do
+ let(:doc) { filter '<p><a href="hTTpS://google.com/">Google</a></p>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- it 'skips internal links' do
+ it "skips internal links" do
internal_link = Gitlab.config.gitlab.url + "/sign_in"
- url = internal_link.gsub(/\Ahttp/, 'HtTp')
- act = %Q(<a href="#{url}">Login</a>)
- exp = %Q(<a href="#{internal_link}">Login</a>)
+ url = internal_link.gsub(/\Ahttp/, "HtTp")
+ act = %(<a href="#{url}">Login</a>)
+ exp = %(<a href="#{internal_link}">Login</a>)
expect(filter(act).to_html).to eq(exp)
end
- it 'skips relative links' do
- exp = act = %q(<a href="http_spec/foo.rb">Relative URL</a>)
+ it "skips relative links" do
+ exp = act = '<a href="http_spec/foo.rb">Relative URL</a>'
expect(filter(act).to_html).to eq(exp)
end
end
- context 'for protocol-relative links' do
- let(:doc) { filter %q(<p><a href="//google.com/">Google</a></p>) }
+ context "for protocol-relative links" do
+ let(:doc) { filter '<p><a href="//google.com/">Google</a></p>' }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
end
- context 'links with RTLO character' do
+ context "links with RTLO character" do
# In rendered text this looks like "http://example.com/evilexe.mp3"
- let(:doc) { filter %Q(<a href="http://example.com/evil%E2%80%AE3pm.exe">http://example.com/evil\u202E3pm.exe</a>) }
+ let(:doc) { filter %(<a href="http://example.com/evil%E2%80%AE3pm.exe">http://example.com/evil\u202E3pm.exe</a>) }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
- it 'escapes RTLO in link text' do
- expected = %q(http://example.com/evil%E2%80%AE3pm.exe</a>)
+ it "escapes RTLO in link text" do
+ expected = "http://example.com/evil%E2%80%AE3pm.exe</a>"
expect(doc.to_html).to include(expected)
end
- it 'does not mangle the link text' do
- doc = filter %Q(<a href="http://example.com">One<span>and</span>\u202Eexe.mp3</a>)
+ it "does not mangle the link text" do
+ doc = filter %(<a href="http://example.com">One<span>and</span>\u202Eexe.mp3</a>)
- expect(doc.to_html).to include('One<span>and</span>%E2%80%AEexe.mp3</a>')
+ expect(doc.to_html).to include("One<span>and</span>%E2%80%AEexe.mp3</a>")
end
end
- context 'for generated autolinks' do
- context 'with an IDN character' do
- let(:doc) { filter(%q(<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>)) }
- let(:doc_email) { filter(%q(<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>), emailable_links: true) }
+ context "for generated autolinks" do
+ context "with an IDN character" do
+ let(:doc) { filter('<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>') }
+ let(:doc_email) { filter('<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>', emailable_links: true) }
- it_behaves_like 'an external link with rel attribute'
+ it_behaves_like "an external link with rel attribute"
- it 'does not change the link text' do
- expect(doc.to_html).to include('http://exa😄mple.com</a>')
+ it "does not change the link text" do
+ expect(doc.to_html).to include("http://exa😄mple.com</a>")
end
- it 'uses punycode for emails' do
- expect(doc_email.to_html).to include('http://xn--example-6p25f.com/</a>')
+ it "uses punycode for emails" do
+ expect(doc_email.to_html).to include("http://xn--example-6p25f.com/</a>")
end
end
end
- context 'for links that look malicious' do
- context 'with an IDN character' do
- let(:doc) { filter %q(<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>) }
+ context "for links that look malicious" do
+ context "with an IDN character" do
+ let(:doc) { filter '<a href="http://exa%F0%9F%98%84mple.com">http://exa😄mple.com</a>' }
- it 'adds a toolip with punycode' do
- expect(doc.to_html).to include('http://exa😄mple.com</a>')
+ it "adds a toolip with punycode" do
+ expect(doc.to_html).to include("http://exa😄mple.com</a>")
expect(doc.to_html).to include('class="has-tooltip"')
expect(doc.to_html).to include('title="http://xn--example-6p25f.com/"')
end
end
- context 'with RTLO character' do
- let(:doc) { filter %q(<a href="http://example.com/evil%E2%80%AE3pm.exe">Evil Test</a>) }
+ context "with RTLO character" do
+ let(:doc) { filter '<a href="http://example.com/evil%E2%80%AE3pm.exe">Evil Test</a>' }
- it 'adds a toolip with punycode' do
- expect(doc.to_html).to include('Evil Test</a>')
+ it "adds a toolip with punycode" do
+ expect(doc.to_html).to include("Evil Test</a>")
expect(doc.to_html).to include('class="has-tooltip"')
expect(doc.to_html).to include('title="http://example.com/evil%E2%80%AE3pm.exe"')
end
diff --git a/spec/lib/banzai/filter/footnote_filter_spec.rb b/spec/lib/banzai/filter/footnote_filter_spec.rb
index c6dcb4e46fd..f5c97a2980e 100644
--- a/spec/lib/banzai/filter/footnote_filter_spec.rb
+++ b/spec/lib/banzai/filter/footnote_filter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::FootnoteFilter do
include FilterSpecHelper
@@ -38,12 +38,12 @@ describe Banzai::Filter::FootnoteFilter do
EOF
end
- context 'when footnotes exist' do
+ context "when footnotes exist" do
let(:doc) { filter(footnote) }
- let(:link_node) { doc.css('sup > a').first }
- let(:identifier) { link_node[:id].delete_prefix('fnref1-') }
+ let(:link_node) { doc.css("sup > a").first }
+ let(:identifier) { link_node[:id].delete_prefix("fnref1-") }
- it 'properly adds the necessary ids and classes' do
+ it "properly adds the necessary ids and classes" do
expect(doc.to_html).to eq filtered_footnote
end
end
diff --git a/spec/lib/banzai/filter/front_matter_filter_spec.rb b/spec/lib/banzai/filter/front_matter_filter_spec.rb
index 3071dc7cf21..dbc31eb274b 100644
--- a/spec/lib/banzai/filter/front_matter_filter_spec.rb
+++ b/spec/lib/banzai/filter/front_matter_filter_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Filter::FrontMatterFilter do
include FilterSpecHelper
- it 'allows for `encoding:` before the front matter' do
+ it "allows for `encoding:` before the front matter" do
content = <<~MD
# encoding: UTF-8
---
@@ -18,10 +18,10 @@ describe Banzai::Filter::FrontMatterFilter do
output = filter(content)
- expect(output).not_to match 'encoding'
+ expect(output).not_to match "encoding"
end
- it 'converts YAML front matter to a fenced code block' do
+ it "converts YAML front matter to a fenced code block" do
content = <<~MD
---
foo: :foo_symbol
@@ -36,12 +36,12 @@ describe Banzai::Filter::FrontMatterFilter do
output = filter(content)
aggregate_failures do
- expect(output).not_to include '---'
+ expect(output).not_to include "---"
expect(output).to include "```yaml\nfoo: :foo_symbol\n"
end
end
- it 'converts TOML frontmatter to a fenced code block' do
+ it "converts TOML frontmatter to a fenced code block" do
content = <<~MD
+++
foo = :foo_symbol
@@ -56,12 +56,12 @@ describe Banzai::Filter::FrontMatterFilter do
output = filter(content)
aggregate_failures do
- expect(output).not_to include '+++'
+ expect(output).not_to include "+++"
expect(output).to include "```toml\nfoo = :foo_symbol\n"
end
end
- it 'converts JSON front matter to a fenced code block' do
+ it "converts JSON front matter to a fenced code block" do
content = <<~MD
;;;
{
@@ -78,12 +78,12 @@ describe Banzai::Filter::FrontMatterFilter do
output = filter(content)
aggregate_failures do
- expect(output).not_to include ';;;'
+ expect(output).not_to include ";;;"
expect(output).to include "```json\n{\n \"foo\": \":foo_symbol\",\n"
end
end
- it 'converts arbitrary front matter to a fenced code block' do
+ it "converts arbitrary front matter to a fenced code block" do
content = <<~MD
---arbitrary
foo = :foo_symbol
@@ -98,13 +98,13 @@ describe Banzai::Filter::FrontMatterFilter do
output = filter(content)
aggregate_failures do
- expect(output).not_to include '---arbitrary'
+ expect(output).not_to include "---arbitrary"
expect(output).to include "```arbitrary\nfoo = :foo_symbol\n"
end
end
- context 'on content without front matter' do
- it 'returns the content unmodified' do
+ context "on content without front matter" do
+ it "returns the content unmodified" do
content = <<~MD
# This is some Markdown
@@ -115,8 +115,8 @@ describe Banzai::Filter::FrontMatterFilter do
end
end
- context 'on front matter without content' do
- it 'converts YAML front matter to a fenced code block' do
+ context "on front matter without content" do
+ it "converts YAML front matter to a fenced code block" do
content = <<~MD
---
foo: :foo_symbol
diff --git a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
index 0e178b859c4..d800ea1b920 100644
--- a/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
+++ b/spec/lib/banzai/filter/gollum_tags_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::GollumTagsFilter do
include FilterSpecHelper
@@ -7,110 +7,110 @@ describe Banzai::Filter::GollumTagsFilter do
let(:user) { double }
let(:project_wiki) { ProjectWiki.new(project, user) }
- describe 'validation' do
- it 'ensure that a :project_wiki key exists in context' do
+ describe "validation" do
+ it "ensure that a :project_wiki key exists in context" do
expect { filter("See [[images/image.jpg]]", {}) }.to raise_error ArgumentError, "Missing context keys for Banzai::Filter::GollumTagsFilter: :project_wiki"
end
end
- context 'linking internal images' do
- it 'creates img tag if image exists' do
- gollum_file_double = double('Gollum::File',
- mime_type: 'image/jpeg',
- name: 'images/image.jpg',
- path: 'images/image.jpg',
- raw_data: '')
+ context "linking internal images" do
+ it "creates img tag if image exists" do
+ gollum_file_double = double("Gollum::File",
+ mime_type: "image/jpeg",
+ name: "images/image.jpg",
+ path: "images/image.jpg",
+ raw_data: "")
wiki_file = Gitlab::Git::WikiFile.new(gollum_file_double)
- expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(wiki_file)
+ expect(project_wiki).to receive(:find_file).with("images/image.jpg").and_return(wiki_file)
- tag = '[[images/image.jpg]]'
+ tag = "[[images/image.jpg]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.at_css('img')['data-src']).to eq "#{project_wiki.wiki_base_path}/images/image.jpg"
+ expect(doc.at_css("img")["data-src"]).to eq "#{project_wiki.wiki_base_path}/images/image.jpg"
end
- it 'does not creates img tag if image does not exist' do
- expect(project_wiki).to receive(:find_file).with('images/image.jpg').and_return(nil)
+ it "does not creates img tag if image does not exist" do
+ expect(project_wiki).to receive(:find_file).with("images/image.jpg").and_return(nil)
- tag = '[[images/image.jpg]]'
+ tag = "[[images/image.jpg]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.css('img').size).to eq 0
+ expect(doc.css("img").size).to eq 0
end
end
- context 'linking external images' do
- it 'creates img tag for valid URL' do
- tag = '[[http://example.com/image.jpg]]'
+ context "linking external images" do
+ it "creates img tag for valid URL" do
+ tag = "[[http://example.com/image.jpg]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.at_css('img')['data-src']).to eq "http://example.com/image.jpg"
+ expect(doc.at_css("img")["data-src"]).to eq "http://example.com/image.jpg"
end
- it 'does not creates img tag for invalid URL' do
- tag = '[[http://example.com/image.pdf]]'
+ it "does not creates img tag for invalid URL" do
+ tag = "[[http://example.com/image.pdf]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.css('img').size).to eq 0
+ expect(doc.css("img").size).to eq 0
end
end
- context 'linking external resources' do
+ context "linking external resources" do
it "the created link's text will be equal to the resource's text" do
- tag = '[[http://example.com]]'
+ tag = "[[http://example.com]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.at_css('a').text).to eq 'http://example.com'
- expect(doc.at_css('a')['href']).to eq 'http://example.com'
+ expect(doc.at_css("a").text).to eq "http://example.com"
+ expect(doc.at_css("a")["href"]).to eq "http://example.com"
end
it "the created link's text will be link-text" do
- tag = '[[link-text|http://example.com/pdfs/gollum.pdf]]'
+ tag = "[[link-text|http://example.com/pdfs/gollum.pdf]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expect(doc.at_css('a').text).to eq 'link-text'
- expect(doc.at_css('a')['href']).to eq 'http://example.com/pdfs/gollum.pdf'
+ expect(doc.at_css("a").text).to eq "link-text"
+ expect(doc.at_css("a")["href"]).to eq "http://example.com/pdfs/gollum.pdf"
end
end
- context 'linking internal resources' do
+ context "linking internal resources" do
it "the created link's text includes the resource's text and wiki base path" do
- tag = '[[wiki-slug]]'
+ tag = "[[wiki-slug]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expected_path = ::File.join(project_wiki.wiki_base_path, 'wiki-slug')
+ expected_path = ::File.join(project_wiki.wiki_base_path, "wiki-slug")
- expect(doc.at_css('a').text).to eq 'wiki-slug'
- expect(doc.at_css('a')['href']).to eq expected_path
+ expect(doc.at_css("a").text).to eq "wiki-slug"
+ expect(doc.at_css("a")["href"]).to eq expected_path
end
it "the created link's text will be link-text" do
- tag = '[[link-text|wiki-slug]]'
+ tag = "[[link-text|wiki-slug]]"
doc = filter("See #{tag}", project_wiki: project_wiki)
- expected_path = ::File.join(project_wiki.wiki_base_path, 'wiki-slug')
+ expected_path = ::File.join(project_wiki.wiki_base_path, "wiki-slug")
- expect(doc.at_css('a').text).to eq 'link-text'
- expect(doc.at_css('a')['href']).to eq expected_path
+ expect(doc.at_css("a").text).to eq "link-text"
+ expect(doc.at_css("a")["href"]).to eq expected_path
end
it "inside back ticks will be exempt from linkification" do
- doc = filter('<code>[[link-in-backticks]]</code>', project_wiki: project_wiki)
+ doc = filter("<code>[[link-in-backticks]]</code>", project_wiki: project_wiki)
- expect(doc.at_css('code').text).to eq '[[link-in-backticks]]'
+ expect(doc.at_css("code").text).to eq "[[link-in-backticks]]"
end
end
- context 'table of contents' do
- it 'replaces [[<em>TOC</em>]] with ToC result' do
- doc = described_class.call("<p>[[<em>TOC</em>]]</p>", { project_wiki: project_wiki }, { toc: "FOO" })
+ context "table of contents" do
+ it "replaces [[<em>TOC</em>]] with ToC result" do
+ doc = described_class.call("<p>[[<em>TOC</em>]]</p>", {project_wiki: project_wiki}, {toc: "FOO"})
expect(doc.to_html).to eq("FOO")
end
- it 'handles an empty ToC result' do
+ it "handles an empty ToC result" do
input = "<p>[[<em>TOC</em>]]</p>"
doc = described_class.call(input, project_wiki: project_wiki)
- expect(doc.to_html).to eq ''
+ expect(doc.to_html).to eq ""
end
end
end
diff --git a/spec/lib/banzai/filter/html_entity_filter_spec.rb b/spec/lib/banzai/filter/html_entity_filter_spec.rb
index 1d98fc0d5db..70d756a1afc 100644
--- a/spec/lib/banzai/filter/html_entity_filter_spec.rb
+++ b/spec/lib/banzai/filter/html_entity_filter_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::HtmlEntityFilter do
include FilterSpecHelper
let(:unescaped) { 'foo <strike attr="foo">&&amp;&</strike>' }
- let(:escaped) { 'foo &lt;strike attr=&quot;foo&quot;&gt;&amp;&amp;amp;&amp;&lt;/strike&gt;' }
+ let(:escaped) { "foo &lt;strike attr=&quot;foo&quot;&gt;&amp;&amp;amp;&amp;&lt;/strike&gt;" }
- it 'converts common entities to their HTML-escaped equivalents' do
+ it "converts common entities to their HTML-escaped equivalents" do
output = filter(unescaped)
expect(output).to eq(escaped)
diff --git a/spec/lib/banzai/filter/image_lazy_load_filter_spec.rb b/spec/lib/banzai/filter/image_lazy_load_filter_spec.rb
index d06c5535309..79c1d684f32 100644
--- a/spec/lib/banzai/filter/image_lazy_load_filter_spec.rb
+++ b/spec/lib/banzai/filter/image_lazy_load_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ImageLazyLoadFilter do
include FilterSpecHelper
@@ -11,23 +11,23 @@ describe Banzai::Filter::ImageLazyLoadFilter do
%(<img src="#{path}" class="#{class_attr}"/>)
end
- it 'adds a class attribute' do
- doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
- expect(doc.at_css('img')['class']).to eq 'lazy'
+ it "adds a class attribute" do
+ doc = filter(image("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"))
+ expect(doc.at_css("img")["class"]).to eq "lazy"
end
- it 'appends to the current class attribute' do
- doc = filter(image_with_class('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg', 'test'))
- expect(doc.at_css('img')['class']).to eq 'test lazy'
+ it "appends to the current class attribute" do
+ doc = filter(image_with_class("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg", "test"))
+ expect(doc.at_css("img")["class"]).to eq "test lazy"
end
- it 'transforms the image src to a data-src' do
- doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
- expect(doc.at_css('img')['data-src']).to eq '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'
+ it "transforms the image src to a data-src" do
+ doc = filter(image("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"))
+ expect(doc.at_css("img")["data-src"]).to eq "/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"
end
- it 'works with external images' do
- doc = filter(image('https://i.imgur.com/DfssX9C.jpg'))
- expect(doc.at_css('img')['data-src']).to eq 'https://i.imgur.com/DfssX9C.jpg'
+ it "works with external images" do
+ doc = filter(image("https://i.imgur.com/DfssX9C.jpg"))
+ expect(doc.at_css("img")["data-src"]).to eq "https://i.imgur.com/DfssX9C.jpg"
end
end
diff --git a/spec/lib/banzai/filter/image_link_filter_spec.rb b/spec/lib/banzai/filter/image_link_filter_spec.rb
index c84b98eb225..705ec63b0fa 100644
--- a/spec/lib/banzai/filter/image_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/image_link_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ImageLinkFilter do
include FilterSpecHelper
@@ -7,23 +7,23 @@ describe Banzai::Filter::ImageLinkFilter do
%(<img src="#{path}" />)
end
- it 'wraps the image with a link to the image src' do
- doc = filter(image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg'))
- expect(doc.at_css('img')['src']).to eq doc.at_css('a')['href']
+ it "wraps the image with a link to the image src" do
+ doc = filter(image("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg"))
+ expect(doc.at_css("img")["src"]).to eq doc.at_css("a")["href"]
end
- it 'does not wrap a duplicate link' do
- doc = filter(%Q(<a href="/whatever">#{image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')}</a>))
+ it "does not wrap a duplicate link" do
+ doc = filter(%(<a href="/whatever">#{image("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg")}</a>))
expect(doc.to_html).to match %r{^<a href="/whatever"><img[^>]*></a>$}
end
- it 'works with external images' do
- doc = filter(image('https://i.imgur.com/DfssX9C.jpg'))
- expect(doc.at_css('img')['src']).to eq doc.at_css('a')['href']
+ it "works with external images" do
+ doc = filter(image("https://i.imgur.com/DfssX9C.jpg"))
+ expect(doc.at_css("img")["src"]).to eq doc.at_css("a")["href"]
end
- it 'works with inline images' do
- doc = filter(%Q(<p>test #{image('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg')} inline</p>))
+ it "works with inline images" do
+ doc = filter(%(<p>test #{image("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg")} inline</p>))
expect(doc.to_html).to match %r{^<p>test <a[^>]*><img[^>]*></a> inline</p>$}
end
end
diff --git a/spec/lib/banzai/filter/inline_diff_filter_spec.rb b/spec/lib/banzai/filter/inline_diff_filter_spec.rb
index 63c4ab61b86..7e2bab37c0c 100644
--- a/spec/lib/banzai/filter/inline_diff_filter_spec.rb
+++ b/spec/lib/banzai/filter/inline_diff_filter_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::InlineDiffFilter do
include FilterSpecHelper
- it 'adds inline diff span tags for deletions when using square brackets' do
+ it "adds inline diff span tags for deletions when using square brackets" do
doc = "START [-something deleted-] END"
expect(filter(doc).to_html).to eq('START <span class="idiff left right deletion">something deleted</span> END')
end
- it 'adds inline diff span tags for deletions when using curley braces' do
+ it "adds inline diff span tags for deletions when using curley braces" do
doc = "START {-something deleted-} END"
expect(filter(doc).to_html).to eq('START <span class="idiff left right deletion">something deleted</span> END')
end
- it 'does not add inline diff span tags when a closing tag is not provided' do
+ it "does not add inline diff span tags when a closing tag is not provided" do
doc = "START [- END"
expect(filter(doc).to_html).to eq(doc)
end
- it 'adds inline span tags for additions when using square brackets' do
+ it "adds inline span tags for additions when using square brackets" do
doc = "START [+something added+] END"
expect(filter(doc).to_html).to eq('START <span class="idiff left right addition">something added</span> END')
end
- it 'adds inline span tags for additions when using curley braces' do
+ it "adds inline span tags for additions when using curley braces" do
doc = "START {+something added+} END"
expect(filter(doc).to_html).to eq('START <span class="idiff left right addition">something added</span> END')
end
- it 'does not add inline diff span tags when a closing addition tag is not provided' do
+ it "does not add inline diff span tags when a closing addition tag is not provided" do
doc = "START {+ END"
expect(filter(doc).to_html).to eq(doc)
end
- it 'does not add inline diff span tags when the tags do not match' do
+ it "does not add inline diff span tags when the tags do not match" do
examples = [
"{+ additions +]",
"[+ additions +}",
"{- delletions -]",
- "[- delletions -}"
+ "[- delletions -}",
]
examples.each do |doc|
@@ -46,22 +46,22 @@ describe Banzai::Filter::InlineDiffFilter do
end
end
- it 'prevents user-land html being injected' do
+ it "prevents user-land html being injected" do
doc = "START {+&lt;script&gt;alert('I steal cookies')&lt;/script&gt;+} END"
expect(filter(doc).to_html).to eq("START <span class=\"idiff left right addition\">&lt;script&gt;alert('I steal cookies')&lt;/script&gt;</span> END")
end
- it 'preserves content inside pre tags' do
+ it "preserves content inside pre tags" do
doc = "<pre>START {+something added+} END</pre>"
expect(filter(doc).to_html).to eq(doc)
end
- it 'preserves content inside code tags' do
+ it "preserves content inside code tags" do
doc = "<code>START {+something added+} END</code>"
expect(filter(doc).to_html).to eq(doc)
end
- it 'preserves content inside tt tags' do
+ it "preserves content inside tt tags" do
doc = "<tt>START {+something added+} END</tt>"
expect(filter(doc).to_html).to eq(doc)
end
diff --git a/spec/lib/banzai/filter/issuable_state_filter_spec.rb b/spec/lib/banzai/filter/issuable_state_filter_spec.rb
index a5373517ac8..bba19ebb451 100644
--- a/spec/lib/banzai/filter/issuable_state_filter_spec.rb
+++ b/spec/lib/banzai/filter/issuable_state_filter_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::IssuableStateFilter do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper
let(:user) { create(:user) }
- let(:context) { { current_user: user, issuable_state_filter_enabled: true } }
+ let(:context) { {current_user: user, issuable_state_filter_enabled: true} }
let(:closed_issue) { create_issue(:closed) }
let(:project) { create(:project, :public) }
let(:group) { create(:group) }
let(:other_project) { create(:project, :public) }
def create_link(text, data)
- link_to(text, '', class: 'gfm has-tooltip', data: data)
+ link_to(text, "", class: "gfm has-tooltip", data: data)
end
def create_issue(state)
@@ -24,182 +24,182 @@ describe Banzai::Filter::IssuableStateFilter do
source_project: project, target_project: project)
end
- it 'ignores non-GFM links' do
+ it "ignores non-GFM links" do
html = %(See <a href="https://google.com/">Google</a>)
doc = filter(html, current_user: user)
- expect(doc.css('a').last.text).to eq('Google')
+ expect(doc.css("a").last.text).to eq("Google")
end
- it 'ignores non-issuable links' do
- link = create_link('text', project: project, reference_type: 'issue')
+ it "ignores non-issuable links" do
+ link = create_link("text", project: project, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq('text')
+ expect(doc.css("a").last.text).to eq("text")
end
- it 'ignores issuable links with empty content' do
- link = create_link('', issue: closed_issue.id, reference_type: 'issue')
+ it "ignores issuable links with empty content" do
+ link = create_link("", issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq('')
+ expect(doc.css("a").last.text).to eq("")
end
- it 'ignores issuable links with custom anchor' do
- link = create_link('something', issue: closed_issue.id, reference_type: 'issue')
+ it "ignores issuable links with custom anchor" do
+ link = create_link("something", issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq('something')
+ expect(doc.css("a").last.text).to eq("something")
end
- it 'ignores issuable links to specific comments' do
- link = create_link("#{closed_issue.to_reference} (comment 1)", issue: closed_issue.id, reference_type: 'issue')
+ it "ignores issuable links to specific comments" do
+ link = create_link("#{closed_issue.to_reference} (comment 1)", issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq("#{closed_issue.to_reference} (comment 1)")
+ expect(doc.css("a").last.text).to eq("#{closed_issue.to_reference} (comment 1)")
end
- it 'ignores merge request links to diffs tab' do
+ it "ignores merge request links to diffs tab" do
merge_request = create(:merge_request, :closed)
link = create_link(
"#{merge_request.to_reference} (diffs)",
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq("#{merge_request.to_reference} (diffs)")
+ expect(doc.css("a").last.text).to eq("#{merge_request.to_reference} (diffs)")
end
- it 'handles cross project references' do
- link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: 'issue')
+ it "handles cross project references" do
+ link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context.merge(project: other_project))
- expect(doc.css('a').last.text).to eq("#{closed_issue.to_reference(other_project)} (closed)")
+ expect(doc.css("a").last.text).to eq("#{closed_issue.to_reference(other_project)} (closed)")
end
- it 'handles references from group scopes' do
- link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: 'issue')
+ it "handles references from group scopes" do
+ link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context.merge(project: nil, group: group))
- expect(doc.css('a').last.text).to eq("#{closed_issue.to_reference(other_project)} (closed)")
+ expect(doc.css("a").last.text).to eq("#{closed_issue.to_reference(other_project)} (closed)")
end
- it 'skips cross project references if the user cannot read cross project' do
+ it "skips cross project references if the user cannot read cross project" do
expect(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
- link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: 'issue')
+ link = create_link(closed_issue.to_reference(other_project), issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context.merge(project: other_project))
- expect(doc.css('a').last.text).to eq("#{closed_issue.to_reference(other_project)}")
+ expect(doc.css("a").last.text).to eq(closed_issue.to_reference(other_project).to_s)
end
- it 'does not append state when filter is not enabled' do
- link = create_link('text', issue: closed_issue.id, reference_type: 'issue')
- context = { current_user: user }
+ it "does not append state when filter is not enabled" do
+ link = create_link("text", issue: closed_issue.id, reference_type: "issue")
+ context = {current_user: user}
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq('text')
+ expect(doc.css("a").last.text).to eq("text")
end
- context 'when project is in pending delete' do
+ context "when project is in pending delete" do
before do
project.update!(pending_delete: true)
end
- it 'does not append issue state' do
- link = create_link('text', issue: closed_issue.id, reference_type: 'issue')
+ it "does not append issue state" do
+ link = create_link("text", issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq('text')
+ expect(doc.css("a").last.text).to eq("text")
end
end
- context 'for issue references' do
- it 'ignores open issue references' do
+ context "for issue references" do
+ it "ignores open issue references" do
issue = create_issue(:opened)
- link = create_link(issue.to_reference, issue: issue.id, reference_type: 'issue')
+ link = create_link(issue.to_reference, issue: issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq(issue.to_reference)
+ expect(doc.css("a").last.text).to eq(issue.to_reference)
end
- it 'appends state to closed issue references' do
- link = create_link(closed_issue.to_reference, issue: closed_issue.id, reference_type: 'issue')
+ it "appends state to closed issue references" do
+ link = create_link(closed_issue.to_reference, issue: closed_issue.id, reference_type: "issue")
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq("#{closed_issue.to_reference} (closed)")
+ expect(doc.css("a").last.text).to eq("#{closed_issue.to_reference} (closed)")
end
end
- context 'for merge request references' do
- it 'ignores open merge request references' do
+ context "for merge request references" do
+ it "ignores open merge request references" do
merge_request = create_merge_request(:opened)
link = create_link(
merge_request.to_reference,
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq(merge_request.to_reference)
+ expect(doc.css("a").last.text).to eq(merge_request.to_reference)
end
- it 'ignores reopened merge request references' do
+ it "ignores reopened merge request references" do
merge_request = create_merge_request(:opened)
link = create_link(
merge_request.to_reference,
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq(merge_request.to_reference)
+ expect(doc.css("a").last.text).to eq(merge_request.to_reference)
end
- it 'ignores locked merge request references' do
+ it "ignores locked merge request references" do
merge_request = create_merge_request(:locked)
link = create_link(
merge_request.to_reference,
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq(merge_request.to_reference)
+ expect(doc.css("a").last.text).to eq(merge_request.to_reference)
end
- it 'appends state to closed merge request references' do
+ it "appends state to closed merge request references" do
merge_request = create_merge_request(:closed)
link = create_link(
merge_request.to_reference,
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq("#{merge_request.to_reference} (closed)")
+ expect(doc.css("a").last.text).to eq("#{merge_request.to_reference} (closed)")
end
- it 'appends state to merged merge request references' do
+ it "appends state to merged merge request references" do
merge_request = create_merge_request(:merged)
link = create_link(
merge_request.to_reference,
merge_request: merge_request.id,
- reference_type: 'merge_request'
+ reference_type: "merge_request"
)
doc = filter(link, context)
- expect(doc.css('a').last.text).to eq("#{merge_request.to_reference} (merged)")
+ expect(doc.css("a").last.text).to eq("#{merge_request.to_reference} (merged)")
end
end
end
diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb
index 914c4e2d823..73beca3a8e4 100644
--- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::IssueReferenceFilter do
include FilterSpecHelper
@@ -10,21 +10,21 @@ describe Banzai::Filter::IssueReferenceFilter do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Issue #{issue.to_reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'performance' do
+ describe "performance" do
let(:another_issue) { create(:issue, project: project) }
- it 'does not have a N+1 query problem' do
+ it "does not have a N+1 query problem" do
single_reference = "Issue #{issue.to_reference}"
multiple_references = "Issues #{issue.to_reference} and #{another_issue.to_reference}"
@@ -34,102 +34,102 @@ describe Banzai::Filter::IssueReferenceFilter do
end
end
- context 'internal reference' do
- it_behaves_like 'a reference containing an element node'
+ context "internal reference" do
+ it_behaves_like "a reference containing an element node"
let(:reference) { "##{issue.iid}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("Fixed #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eql("Fixed (#{reference}.)")
end
- it 'ignores invalid issue IDs' do
+ it "ignores invalid issue IDs" do
invalid = invalidate_reference(reference)
exp = act = "Fixed #{invalid}"
expect(reference_filter(act).to_html).to eq exp
end
- it 'includes a title attribute' do
+ it "includes a title attribute" do
doc = reference_filter("Issue #{reference}")
- expect(doc.css('a').first.attr('title')).to eq issue.title
+ expect(doc.css("a").first.attr("title")).to eq issue.title
end
- it 'escapes the title attribute' do
- issue.update_attribute(:title, %{"></a>whatever<a title="})
+ it "escapes the title attribute" do
+ issue.update_attribute(:title, %("></a>whatever<a title="))
doc = reference_filter("Issue #{reference}")
expect(doc.text).to eq "Issue #{reference}"
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Issue #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Issue #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-issue attribute' do
+ it "includes a data-issue attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-issue')
- expect(link.attr('data-issue')).to eq issue.id.to_s
+ expect(link).to have_attribute("data-issue")
+ expect(link.attr("data-issue")).to eq issue.id.to_s
end
- it 'includes a data-original attribute' do
+ it "includes a data-original attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-original')
- expect(link.attr('data-original')).to eq reference
+ expect(link).to have_attribute("data-original")
+ expect(link.attr("data-original")).to eq reference
end
- it 'does not escape the data-original attribute' do
- inner_html = 'element <code>node</code> inside'
- doc = reference_filter(%{<a href="#{reference}">#{inner_html}</a>})
- expect(doc.children.first.attr('data-original')).to eq inner_html
+ it "does not escape the data-original attribute" do
+ inner_html = "element <code>node</code> inside"
+ doc = reference_filter(%(<a href="#{reference}">#{inner_html}</a>))
+ expect(doc.children.first.attr("data-original")).to eq inner_html
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Issue #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq helper.url_for_issue(issue.iid, project, only_path: true)
end
- it 'does not process links containing issue numbers followed by text' do
+ it "does not process links containing issue numbers followed by text" do
href = "#{reference}st"
doc = reference_filter("<a href='#{href}'></a>")
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
expect(link).to eq(href)
end
end
- context 'cross-project / cross-namespace complete reference' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project / cross-namespace complete reference" do
+ it_behaves_like "a reference containing an element node"
let(:project2) { create(:project, :public) }
let(:issue) { create(:issue, project: project2) }
let(:reference) { "#{project2.full_path}##{issue.iid}" }
- it 'ignores valid references when cross-reference project uses external tracker' do
+ it "ignores valid references when cross-reference project uses external tracker" do
expect_any_instance_of(described_class).to receive(:find_object)
.with(project2, issue.iid)
.and_return(nil)
@@ -138,40 +138,40 @@ describe Banzai::Filter::IssueReferenceFilter do
expect(reference_filter(act).to_html).to eq exp
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project2)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.full_path}##{issue.iid}")
+ expect(doc.css("a").first.text).to eql("#{project2.full_path}##{issue.iid}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eq("Fixed (#{project2.full_path}##{issue.iid}.)")
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
- it 'ignores invalid issue IDs on the referenced project' do
+ it "ignores invalid issue IDs on the referenced project" do
exp = act = "Fixed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project / same-namespace complete reference' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project / same-namespace complete reference" do
+ it_behaves_like "a reference containing an element node"
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
@@ -179,7 +179,7 @@ describe Banzai::Filter::IssueReferenceFilter do
let(:issue) { create(:issue, project: project2) }
let(:reference) { "#{project2.full_path}##{issue.iid}" }
- it 'ignores valid references when cross-reference project uses external tracker' do
+ it "ignores valid references when cross-reference project uses external tracker" do
expect_any_instance_of(described_class).to receive(:find_object)
.with(project2, issue.iid)
.and_return(nil)
@@ -188,40 +188,40 @@ describe Banzai::Filter::IssueReferenceFilter do
expect(reference_filter(act).to_html).to eq exp
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project2)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}##{issue.iid}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}##{issue.iid}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eq("Fixed (#{project2.path}##{issue.iid}.)")
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
- it 'ignores invalid issue IDs on the referenced project' do
+ it "ignores invalid issue IDs on the referenced project" do
exp = act = "Fixed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project shorthand reference' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project shorthand reference" do
+ it_behaves_like "a reference containing an element node"
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
@@ -229,7 +229,7 @@ describe Banzai::Filter::IssueReferenceFilter do
let(:issue) { create(:issue, project: project2) }
let(:reference) { "#{project2.path}##{issue.iid}" }
- it 'ignores valid references when cross-reference project uses external tracker' do
+ it "ignores valid references when cross-reference project uses external tracker" do
expect_any_instance_of(described_class).to receive(:find_object)
.with(project2, issue.iid)
.and_return(nil)
@@ -238,136 +238,136 @@ describe Banzai::Filter::IssueReferenceFilter do
expect(reference_filter(act).to_html).to eq exp
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project2)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}##{issue.iid}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}##{issue.iid}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.text).to eq("Fixed (#{project2.path}##{issue.iid}.)")
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
- it 'ignores invalid issue IDs on the referenced project' do
+ it "ignores invalid issue IDs on the referenced project" do
exp = act = "Fixed #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project URL reference' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project URL reference" do
+ it_behaves_like "a reference containing an element node"
- let(:namespace) { create(:namespace, name: 'cross-reference') }
+ let(:namespace) { create(:namespace, name: "cross-reference") }
let(:project2) { create(:project, :public, namespace: namespace) }
let(:issue) { create(:issue, project: project2) }
let(:reference) { helper.url_for_issue(issue.iid, project2) + "#note_123" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq reference
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(issue.to_reference(project))} \(comment 123\)</a>\.\)})
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
end
- context 'cross-project reference in link href' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project reference in link href" do
+ it_behaves_like "a reference containing an element node"
- let(:namespace) { create(:namespace, name: 'cross-reference') }
+ let(:namespace) { create(:namespace, name: "cross-reference") }
let(:project2) { create(:project, :public, namespace: namespace) }
let(:issue) { create(:issue, project: project2) }
let(:reference) { issue.to_reference(project) }
- let(:reference_link) { %{<a href="#{reference}">Reference</a>} }
+ let(:reference_link) { %(<a href="#{reference}">Reference</a>) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference_link}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project2)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference_link}.)")
expect(doc.to_html).to match(%r{\(<a.+>Reference</a>\.\)})
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference_link}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
end
- context 'cross-project URL in link href' do
- it_behaves_like 'a reference containing an element node'
+ context "cross-project URL in link href" do
+ it_behaves_like "a reference containing an element node"
- let(:namespace) { create(:namespace, name: 'cross-reference') }
+ let(:namespace) { create(:namespace, name: "cross-reference") }
let(:project2) { create(:project, :public, namespace: namespace) }
let(:issue) { create(:issue, project: project2) }
- let(:reference) { "#{helper.url_for_issue(issue.iid, project2) + "#note_123"}" }
- let(:reference_link) { %{<a href="#{reference}">Reference</a>} }
+ let(:reference) { (helper.url_for_issue(issue.iid, project2) + "#note_123").to_s }
+ let(:reference_link) { %(<a href="#{reference}">Reference</a>) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference_link}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq helper.url_for_issue(issue.iid, project2) + "#note_123"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Fixed (#{reference_link}.)")
expect(doc.to_html).to match(%r{\(<a.+>Reference</a>\.\)})
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Fixed (#{reference_link}.)")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-issue has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-issue has-tooltip"
end
end
- context 'group context' do
+ context "group context" do
let(:group) { create(:group) }
- let(:context) { { project: nil, group: group } }
+ let(:context) { {project: nil, group: group} }
- it 'ignores shorthanded issue reference' do
+ it "ignores shorthanded issue reference" do
reference = "##{issue.iid}"
text = "Fixed #{reference}"
expect(reference_filter(text, context).to_html).to eq(text)
end
- it 'ignores valid references when cross-reference project uses external tracker' do
+ it "ignores valid references when cross-reference project uses external tracker" do
expect_any_instance_of(described_class).to receive(:find_object)
.with(project, issue.iid)
.and_return(nil)
@@ -378,91 +378,91 @@ describe Banzai::Filter::IssueReferenceFilter do
expect(reference_filter(text, context).to_html).to eq(text)
end
- it 'links to a valid reference for complete cross-reference' do
+ it "links to a valid reference for complete cross-reference" do
reference = "#{project.full_path}##{issue.iid}"
doc = reference_filter("See #{reference}", context)
- link = doc.css('a').first
- expect(link.attr('href')).to eq(helper.url_for_issue(issue.iid, project))
+ link = doc.css("a").first
+ expect(link.attr("href")).to eq(helper.url_for_issue(issue.iid, project))
expect(link.text).to include("#{project.full_path}##{issue.iid}")
end
- it 'ignores reference for shorthand cross-reference' do
+ it "ignores reference for shorthand cross-reference" do
reference = "#{project.path}##{issue.iid}"
text = "See #{reference}"
expect(reference_filter(text, context).to_html).to eq(text)
end
- it 'links to a valid reference for url cross-reference' do
+ it "links to a valid reference for url cross-reference" do
reference = helper.url_for_issue(issue.iid, project) + "#note_123"
doc = reference_filter("See #{reference}", context)
- link = doc.css('a').first
- expect(link.attr('href')).to eq(helper.url_for_issue(issue.iid, project) + "#note_123")
+ link = doc.css("a").first
+ expect(link.attr("href")).to eq(helper.url_for_issue(issue.iid, project) + "#note_123")
expect(link.text).to include("#{project.full_path}##{issue.iid}")
end
- it 'links to a valid reference for cross-reference in link href' do
- reference = "#{helper.url_for_issue(issue.iid, project) + "#note_123"}"
- reference_link = %{<a href="#{reference}">Reference</a>}
+ it "links to a valid reference for cross-reference in link href" do
+ reference = (helper.url_for_issue(issue.iid, project) + "#note_123").to_s
+ reference_link = %(<a href="#{reference}">Reference</a>)
doc = reference_filter("See #{reference_link}", context)
- link = doc.css('a').first
- expect(link.attr('href')).to eq(helper.url_for_issue(issue.iid, project) + "#note_123")
- expect(link.text).to include('Reference')
+ link = doc.css("a").first
+ expect(link.attr("href")).to eq(helper.url_for_issue(issue.iid, project) + "#note_123")
+ expect(link.text).to include("Reference")
end
- it 'links to a valid reference for issue reference in the link href' do
+ it "links to a valid reference for issue reference in the link href" do
reference = issue.to_reference(group)
- reference_link = %{<a href="#{reference}">Reference</a>}
+ reference_link = %(<a href="#{reference}">Reference</a>)
doc = reference_filter("See #{reference_link}", context)
- link = doc.css('a').first
- expect(link.attr('href')).to eq(helper.url_for_issue(issue.iid, project))
- expect(link.text).to include('Reference')
+ link = doc.css("a").first
+ expect(link.attr("href")).to eq(helper.url_for_issue(issue.iid, project))
+ expect(link.text).to include("Reference")
end
end
- describe '#records_per_parent' do
- context 'using an internal issue tracker' do
- it 'returns a Hash containing the issues per project' do
- doc = Nokogiri::HTML.fragment('')
+ describe "#records_per_parent" do
+ context "using an internal issue tracker" do
+ it "returns a Hash containing the issues per project" do
+ doc = Nokogiri::HTML.fragment("")
filter = described_class.new(doc, project: project)
expect(filter).to receive(:parent_per_reference)
- .and_return({ project.full_path => project })
+ .and_return({project.full_path => project})
expect(filter).to receive(:references_per_parent)
- .and_return({ project.full_path => Set.new([issue.iid]) })
+ .and_return({project.full_path => Set.new([issue.iid])})
expect(filter.records_per_parent)
- .to eq({ project => { issue.iid => issue } })
+ .to eq({project => {issue.iid => issue}})
end
end
end
- describe '.references_in' do
+ describe ".references_in" do
let(:merge_request) { create(:merge_request) }
- it 'yields valid references' do
- expect do |b|
+ it "yields valid references" do
+ expect { |b|
described_class.references_in(issue.to_reference, &b)
- end.to yield_with_args(issue.to_reference, issue.iid, nil, nil, MatchData)
+ }.to yield_with_args(issue.to_reference, issue.iid, nil, nil, MatchData)
end
it "doesn't yield invalid references" do
- expect do |b|
- described_class.references_in('#0', &b)
- end.not_to yield_control
+ expect { |b|
+ described_class.references_in("#0", &b)
+ }.not_to yield_control
end
it "doesn't yield unsupported references" do
- expect do |b|
+ expect { |b|
described_class.references_in(merge_request.to_reference, &b)
- end.not_to yield_control
+ }.not_to yield_control
end
end
end
diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb
index 108d7b43a26..642281d2f38 100644
--- a/spec/lib/banzai/filter/label_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb
@@ -1,161 +1,161 @@
-require 'spec_helper'
-require 'html/pipeline'
+require "spec_helper"
+require "html/pipeline"
describe Banzai::Filter::LabelReferenceFilter do
include FilterSpecHelper
- let(:project) { create(:project, :public, name: 'sample-project') }
+ let(:project) { create(:project, :public, name: "sample-project") }
let(:label) { create(:label, project: project) }
let(:reference) { label.to_reference }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Label #{reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Label #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-label has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-label has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Label #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-label attribute' do
+ it "includes a data-label attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-label')
- expect(link.attr('data-label')).to eq label.id.to_s
+ expect(link).to have_attribute("data-label")
+ expect(link.attr("data-label")).to eq label.id.to_s
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Label #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.project_issues_path(project, label_name: label.name)
end
- context 'project that does not exist referenced' do
- let(:result) { reference_filter('aaa/bbb~ccc') }
+ context "project that does not exist referenced" do
+ let(:result) { reference_filter("aaa/bbb~ccc") }
- it 'does not link reference' do
- expect(result.to_html).to eq 'aaa/bbb~ccc'
+ it "does not link reference" do
+ expect(result.to_html).to eq "aaa/bbb~ccc"
end
end
- describe 'label span element' do
- it 'includes default classes' do
+ describe "label span element" do
+ it "includes default classes" do
doc = reference_filter("Label #{reference}")
- expect(doc.css('a span').first.attr('class')).to eq 'badge color-label has-tooltip'
+ expect(doc.css("a span").first.attr("class")).to eq "badge color-label has-tooltip"
end
- it 'includes a style attribute' do
+ it "includes a style attribute" do
doc = reference_filter("Label #{reference}")
- expect(doc.css('a span').first.attr('style')).to match(/\Abackground-color: #\h{6}; color: #\h{6}\z/)
+ expect(doc.css("a span").first.attr("style")).to match(/\Abackground-color: #\h{6}; color: #\h{6}\z/)
end
end
- context 'Integer-based references' do
- it 'links to a valid reference' do
+ context "Integer-based references" do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)})
end
- it 'ignores invalid label IDs' do
+ it "ignores invalid label IDs" do
exp = act = "Label #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'String-based single-word references' do
- let(:label) { create(:label, name: 'gfm', project: project) }
+ context "String-based single-word references" do
+ let(:label) { create(:label, name: "gfm", project: project) }
let(:reference) { "#{Label.reference_prefix}#{label.name}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See gfm'
+ expect(doc.text).to eq "See gfm"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}).")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\)\.})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = "Label #{Label.reference_prefix}#{label.name.reverse}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'String-based single-word references that begin with a digit' do
- let(:label) { create(:label, name: '2fa', project: project) }
+ context "String-based single-word references that begin with a digit" do
+ let(:label) { create(:label, name: "2fa", project: project) }
let(:reference) { "#{Label.reference_prefix}#{label.name}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See 2fa'
+ expect(doc.text).to eq "See 2fa"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}).")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\)\.))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\)\.})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = "Label #{Label.reference_prefix}#{label.id}#{label.name.reverse}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'String-based single-word references with special characters' do
- let(:label) { create(:label, name: '?g.fm&', project: project) }
+ context "String-based single-word references with special characters" do
+ let(:label) { create(:label, name: "?g.fm&", project: project) }
let(:reference) { "#{Label.reference_prefix}#{label.name}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See ?g.fm&'
+ expect(doc.text).to eq "See ?g.fm&"
end
- it 'does not include trailing punctuation', :aggregate_failures do
- ['.', ', ok?', '...', '?', '!', ': is that ok?'].each do |trailing_punctuation|
+ it "does not include trailing punctuation", :aggregate_failures do
+ [".", ", ok?", "...", "?", "!", ": is that ok?"].each do |trailing_punctuation|
doc = filter("Label #{reference}#{trailing_punctuation}")
- expect(doc.to_html).to match(%r(<a.+><span.+>\?g\.fm&amp;</span></a>#{Regexp.escape(trailing_punctuation)}))
+ expect(doc.to_html).to match(%r{<a.+><span.+>\?g\.fm&amp;</span></a>#{Regexp.escape(trailing_punctuation)}})
end
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
act = "Label #{Label.reference_prefix}#{label.name.reverse}"
exp = "Label #{Label.reference_prefix}&amp;mf.g?"
@@ -163,72 +163,72 @@ describe Banzai::Filter::LabelReferenceFilter do
end
end
- context 'String-based multi-word references in quotes' do
- let(:label) { create(:label, name: 'gfm references', project: project) }
+ context "String-based multi-word references in quotes" do
+ let(:label) { create(:label, name: "gfm references", project: project) }
let(:reference) { label.to_reference(format: :name) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See gfm references'
+ expect(doc.text).to eq "See gfm references"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = %(Label #{Label.reference_prefix}"#{label.name.reverse}")
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'String-based multi-word references that begin with a digit' do
- let(:label) { create(:label, name: '2 factor authentication', project: project) }
+ context "String-based multi-word references that begin with a digit" do
+ let(:label) { create(:label, name: "2 factor authentication", project: project) }
let(:reference) { label.to_reference(format: :name) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See 2 factor authentication'
+ expect(doc.text).to eq "See 2 factor authentication"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{label.name}</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{label.name}</span></a>\.\)})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = "Label #{Label.reference_prefix}#{label.id}#{label.name.reverse}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'String-based multi-word references with special characters in quotes' do
- let(:label) { create(:label, name: 'g.fm & references?', project: project) }
+ context "String-based multi-word references with special characters in quotes" do
+ let(:label) { create(:label, name: "g.fm & references?", project: project) }
let(:reference) { label.to_reference(format: :name) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See g.fm & references?'
+ expect(doc.text).to eq "See g.fm & references?"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>g\.fm &amp; references\?</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>g\.fm &amp; references\?</span></a>\.\)})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
act = %(Label #{Label.reference_prefix}"#{label.name.reverse}")
exp = %(Label #{Label.reference_prefix}"?secnerefer &amp; mf.g\")
@@ -236,148 +236,148 @@ describe Banzai::Filter::LabelReferenceFilter do
end
end
- context 'References with html entities' do
- let!(:label) { create(:label, name: '&lt;html&gt;', project: project) }
+ context "References with html entities" do
+ let!(:label) { create(:label, name: "&lt;html&gt;", project: project) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter('See ~"&lt;html&gt;"')
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
- expect(doc.text).to eq 'See <html>'
+ expect(doc.text).to eq "See <html>"
end
- it 'ignores invalid label names and escapes entities' do
+ it "ignores invalid label names and escapes entities" do
act = %(Label #{Label.reference_prefix}"&lt;non valid&gt;")
expect(reference_filter(act).to_html).to eq act
end
end
- describe 'consecutive references' do
- let(:bug) { create(:label, name: 'bug', project: project) }
- let(:feature_proposal) { create(:label, name: 'feature proposal', project: project) }
- let(:technical_debt) { create(:label, name: 'technical debt', project: project) }
+ describe "consecutive references" do
+ let(:bug) { create(:label, name: "bug", project: project) }
+ let(:feature_proposal) { create(:label, name: "feature proposal", project: project) }
+ let(:technical_debt) { create(:label, name: "technical debt", project: project) }
let(:bug_reference) { "#{Label.reference_prefix}#{bug.name}" }
let(:feature_proposal_reference) { feature_proposal.to_reference(format: :name) }
let(:technical_debt_reference) { technical_debt.to_reference(format: :name) }
- context 'separated with a comma' do
+ context "separated with a comma" do
let(:references) { "#{bug_reference}, #{feature_proposal_reference}, #{technical_debt_reference}" }
- it 'links to valid references' do
+ it "links to valid references" do
doc = reference_filter("See #{references}")
- expect(doc.css('a').map { |a| a.attr('href') }).to match_array([
+ expect(doc.css("a").map { |a| a.attr("href") }).to match_array([
urls.project_issues_url(project, label_name: bug.name),
urls.project_issues_url(project, label_name: feature_proposal.name),
- urls.project_issues_url(project, label_name: technical_debt.name)
+ urls.project_issues_url(project, label_name: technical_debt.name),
])
- expect(doc.text).to eq 'See bug, feature proposal, technical debt'
+ expect(doc.text).to eq "See bug, feature proposal, technical debt"
end
end
- context 'separated with a space' do
+ context "separated with a space" do
let(:references) { "#{bug_reference} #{feature_proposal_reference} #{technical_debt_reference}" }
- it 'links to valid references' do
+ it "links to valid references" do
doc = reference_filter("See #{references}")
- expect(doc.css('a').map { |a| a.attr('href') }).to match_array([
+ expect(doc.css("a").map { |a| a.attr("href") }).to match_array([
urls.project_issues_url(project, label_name: bug.name),
urls.project_issues_url(project, label_name: feature_proposal.name),
- urls.project_issues_url(project, label_name: technical_debt.name)
+ urls.project_issues_url(project, label_name: technical_debt.name),
])
- expect(doc.text).to eq 'See bug feature proposal technical debt'
+ expect(doc.text).to eq "See bug feature proposal technical debt"
end
end
end
- describe 'edge cases' do
- it 'gracefully handles non-references matching the pattern' do
+ describe "edge cases" do
+ it "gracefully handles non-references matching the pattern" do
exp = act = '(format nil "~0f" 3.0) ; 3.0'
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'referencing a label in a link href' do
- let(:reference) { %Q{<a href="#{label.to_reference}">Label</a>} }
+ describe "referencing a label in a link href" do
+ let(:reference) { %(<a href="#{label.to_reference}">Label</a>) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: label.name)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+>Label</a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+>Label</a>\.\)})
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Label #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-label attribute' do
+ it "includes a data-label attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-label')
- expect(link.attr('data-label')).to eq label.id.to_s
+ expect(link).to have_attribute("data-label")
+ expect(link.attr("data-label")).to eq label.id.to_s
end
end
- describe 'group label references' do
+ describe "group label references" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let(:group_label) { create(:group_label, name: 'gfm references', group: group) }
+ let(:group_label) { create(:group_label, name: "gfm references", group: group) }
- context 'without project reference' do
+ context "without project reference" do
let(:reference) { group_label.to_reference(format: :name) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}", project: project)
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: group_label.name)
- expect(doc.text).to eq 'See gfm references'
+ expect(doc.text).to eq "See gfm references"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{group_label.name}</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{group_label.name}</span></a>\.\)})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = %(Label #{Label.reference_prefix}"#{group_label.name.reverse}")
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'with project reference' do
+ context "with project reference" do
let(:reference) { "#{project.to_reference}#{group_label.to_reference(format: :name)}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}", project: project)
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_issues_url(project, label_name: group_label.name)
expect(doc.text).to eq "See gfm references"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Label (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+><span.+>#{group_label.name}</span></a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+><span.+>#{group_label.name}</span></a>\.\)})
end
- it 'ignores invalid label names' do
+ it "ignores invalid label names" do
exp = act = %(Label #{project.to_reference}#{Label.reference_prefix}"#{group_label.name.reverse}")
expect(reference_filter(act).to_html).to eq exp
@@ -385,267 +385,267 @@ describe Banzai::Filter::LabelReferenceFilter do
end
end
- describe 'cross-project / cross-namespace complete reference' do
+ describe "cross-project / cross-namespace complete reference" do
let(:project2) { create(:project) }
- let(:label) { create(:label, project: project2, color: '#00ff00') }
+ let(:label) { create(:label, project: project2, color: "#00ff00") }
let(:reference) { "#{project2.full_path}~#{label.name}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'links to a valid reference' do
- expect(result.css('a').first.attr('href'))
+ it "links to a valid reference" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(project2, label_name: label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style')).to match /background-color: #00ff00/
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style")).to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text).to eq "#{label.name} in #{project2.full_name}"
+ it "has valid link text" do
+ expect(result.css("a").first.text).to eq "#{label.name} in #{project2.full_name}"
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text).to eq "See #{label.name} in #{project2.full_name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'cross-project / same-namespace complete reference' do
+ describe "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
let(:project2) { create(:project, namespace: namespace) }
- let(:label) { create(:label, project: project2, color: '#00ff00') }
+ let(:label) { create(:label, project: project2, color: "#00ff00") }
let(:reference) { "#{project2.full_path}~#{label.name}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'links to a valid reference' do
- expect(result.css('a').first.attr('href'))
+ it "links to a valid reference" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(project2, label_name: label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style')).to match /background-color: #00ff00/
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style")).to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text).to eq "#{label.name} in #{project2.name}"
+ it "has valid link text" do
+ expect(result.css("a").first.text).to eq "#{label.name} in #{project2.name}"
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text).to eq "See #{label.name} in #{project2.name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'cross-project shorthand reference' do
+ describe "cross-project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, namespace: namespace) }
let(:project2) { create(:project, namespace: namespace) }
- let(:label) { create(:label, project: project2, color: '#00ff00') }
+ let(:label) { create(:label, project: project2, color: "#00ff00") }
let(:reference) { "#{project2.path}~#{label.name}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'links to a valid reference' do
- expect(result.css('a').first.attr('href'))
+ it "links to a valid reference" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(project2, label_name: label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style"))
.to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text).to eq "#{label.name} in #{project2.name}"
+ it "has valid link text" do
+ expect(result.css("a").first.text).to eq "#{label.name} in #{project2.name}"
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text).to eq "See #{label.name} in #{project2.name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'cross group label references' do
+ describe "cross group label references" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
let(:another_group) { create(:group) }
let(:another_project) { create(:project, :public, namespace: another_group) }
- let(:group_label) { create(:group_label, group: another_group, color: '#00ff00') }
+ let(:group_label) { create(:group_label, group: another_group, color: "#00ff00") }
let(:reference) { "#{another_project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) }
- it 'points to referenced project issues page' do
- expect(result.css('a').first.attr('href'))
+ it "points to referenced project issues page" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(another_project, label_name: group_label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style"))
.to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text)
+ it "has valid link text" do
+ expect(result.css("a").first.text)
.to eq "#{group_label.name} in #{another_project.full_name}"
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text)
.to eq "See #{group_label.name} in #{another_project.full_name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'cross-project / same-group_label complete reference' do
+ describe "cross-project / same-group_label complete reference" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
let(:another_project) { create(:project, :public, namespace: group) }
- let(:group_label) { create(:group_label, group: group, color: '#00ff00') }
+ let(:group_label) { create(:group_label, group: group, color: "#00ff00") }
let(:reference) { "#{another_project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) }
- it 'points to referenced project issues page' do
- expect(result.css('a').first.attr('href'))
+ it "points to referenced project issues page" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(another_project, label_name: group_label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style"))
.to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text)
+ it "has valid link text" do
+ expect(result.css("a").first.text)
.to eq "#{group_label.name} in #{another_project.name}"
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text)
.to eq "See #{group_label.name} in #{another_project.name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'same project / same group_label complete reference' do
+ describe "same project / same group_label complete reference" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let(:group_label) { create(:group_label, group: group, color: '#00ff00') }
+ let(:group_label) { create(:group_label, group: group, color: "#00ff00") }
let(:reference) { "#{project.full_path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) }
- it 'points to referenced project issues page' do
- expect(result.css('a').first.attr('href'))
+ it "points to referenced project issues page" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(project, label_name: group_label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style"))
.to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text).to eq group_label.name
+ it "has valid link text" do
+ expect(result.css("a").first.text).to eq group_label.name
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text).to eq "See #{group_label.name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'same project / same group_label shorthand reference' do
+ describe "same project / same group_label shorthand reference" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let(:group_label) { create(:group_label, group: group, color: '#00ff00') }
+ let(:group_label) { create(:group_label, group: group, color: "#00ff00") }
let(:reference) { "#{project.path}~#{group_label.name}" }
let!(:result) { reference_filter("See #{reference}", project: project) }
- it 'points to referenced project issues page' do
- expect(result.css('a').first.attr('href'))
+ it "points to referenced project issues page" do
+ expect(result.css("a").first.attr("href"))
.to eq urls.project_issues_url(project, label_name: group_label.name)
end
- it 'has valid color' do
- expect(result.css('a span').first.attr('style'))
+ it "has valid color" do
+ expect(result.css("a span").first.attr("style"))
.to match /background-color: #00ff00/
end
- it 'has valid link text' do
- expect(result.css('a').first.text).to eq group_label.name
+ it "has valid link text" do
+ expect(result.css("a").first.text).to eq group_label.name
end
- it 'has valid text' do
+ it "has valid text" do
expect(result.text).to eq "See #{group_label.name}"
end
- it 'ignores invalid IDs on the referenced label' do
+ it "ignores invalid IDs on the referenced label" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'group context' do
- it 'points to the page defined in label_url_method' do
+ describe "group context" do
+ it "points to the page defined in label_url_method" do
group = create(:group)
label = create(:group_label, group: group)
reference = "~#{label.name}"
- result = reference_filter("See #{reference}", { project: nil, group: group, label_url_method: :group_url } )
+ result = reference_filter("See #{reference}", {project: nil, group: group, label_url_method: :group_url})
- expect(result.css('a').first.attr('href')).to eq(urls.group_url(group, label_name: label.name))
+ expect(result.css("a").first.attr("href")).to eq(urls.group_url(group, label_name: label.name))
end
- it 'finds labels also in ancestor groups' do
+ it "finds labels also in ancestor groups" do
group = create(:group)
label = create(:group_label, group: group)
subgroup = create(:group, parent: group)
reference = "~#{label.name}"
- result = reference_filter("See #{reference}", { project: nil, group: subgroup, label_url_method: :group_url } )
+ result = reference_filter("See #{reference}", {project: nil, group: subgroup, label_url_method: :group_url})
- expect(result.css('a').first.attr('href')).to eq(urls.group_url(subgroup, label_name: label.name))
+ expect(result.css("a").first.attr("href")).to eq(urls.group_url(subgroup, label_name: label.name))
end
- it 'points to referenced project issues page' do
+ it "points to referenced project issues page" do
project = create(:project)
label = create(:label, project: project)
reference = "#{project.full_path}~#{label.name}"
- result = reference_filter("See #{reference}", { project: nil, group: create(:group) } )
+ result = reference_filter("See #{reference}", {project: nil, group: create(:group)})
- expect(result.css('a').first.attr('href')).to eq(urls.project_issues_url(project, label_name: label.name))
- expect(result.css('a').first.text).to eq "#{label.name} in #{project.full_name}"
+ expect(result.css("a").first.attr("href")).to eq(urls.project_issues_url(project, label_name: label.name))
+ expect(result.css("a").first.text).to eq "#{label.name} in #{project.full_name}"
end
end
end
diff --git a/spec/lib/banzai/filter/markdown_filter_spec.rb b/spec/lib/banzai/filter/markdown_filter_spec.rb
index 83fcda29680..f3fe1a07963 100644
--- a/spec/lib/banzai/filter/markdown_filter_spec.rb
+++ b/spec/lib/banzai/filter/markdown_filter_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::MarkdownFilter do
include FilterSpecHelper
- describe 'markdown engine from context' do
- it 'defaults to CommonMark' do
- expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return('test')
+ describe "markdown engine from context" do
+ it "defaults to CommonMark" do
+ expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return("test")
- filter('test')
+ filter("test")
end
- it 'uses CommonMark' do
- expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return('test')
+ it "uses CommonMark" do
+ expect_any_instance_of(Banzai::Filter::MarkdownEngines::CommonMark).to receive(:render).and_return("test")
- filter('test', { markdown_engine: :common_mark })
+ filter("test", {markdown_engine: :common_mark})
end
end
- describe 'code block' do
- context 'using CommonMark' do
+ describe "code block" do
+ context "using CommonMark" do
before do
- stub_const('Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE', :common_mark)
+ stub_const("Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE", :common_mark)
end
- it 'adds language to lang attribute when specified' do
+ it "adds language to lang attribute when specified" do
result = filter("```html\nsome code\n```", no_sourcepos: true)
expect(result).to start_with('<pre><code lang="html">')
end
- it 'does not add language to lang attribute when not specified' do
+ it "does not add language to lang attribute when not specified" do
result = filter("```\nsome code\n```", no_sourcepos: true)
- expect(result).to start_with('<pre><code>')
+ expect(result).to start_with("<pre><code>")
end
- it 'works with utf8 chars in language' do
+ it "works with utf8 chars in language" do
result = filter("```日\nsome code\n```", no_sourcepos: true)
expect(result).to start_with('<pre><code lang="日">')
@@ -43,28 +43,28 @@ describe Banzai::Filter::MarkdownFilter do
end
end
- describe 'source line position' do
- context 'using CommonMark' do
+ describe "source line position" do
+ context "using CommonMark" do
before do
- stub_const('Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE', :common_mark)
+ stub_const("Banzai::Filter::MarkdownFilter::DEFAULT_ENGINE", :common_mark)
end
- it 'defaults to add data-sourcepos' do
- result = filter('test')
+ it "defaults to add data-sourcepos" do
+ result = filter("test")
expect(result).to eq '<p data-sourcepos="1:1-1:4">test</p>'
end
- it 'disables data-sourcepos' do
- result = filter('test', no_sourcepos: true)
+ it "disables data-sourcepos" do
+ result = filter("test", no_sourcepos: true)
- expect(result).to eq '<p>test</p>'
+ expect(result).to eq "<p>test</p>"
end
end
end
- describe 'footnotes in tables' do
- it 'processes footnotes in table cells' do
+ describe "footnotes in tables" do
+ it "processes footnotes in table cells" do
text = <<-MD.strip_heredoc
| Column1 |
| --------- |
@@ -75,7 +75,7 @@ describe Banzai::Filter::MarkdownFilter do
result = filter(text, no_sourcepos: true)
- expect(result).to include('<td>foot <sup')
+ expect(result).to include("<td>foot <sup")
expect(result).to include('<section class="footnotes">')
end
end
diff --git a/spec/lib/banzai/filter/math_filter_spec.rb b/spec/lib/banzai/filter/math_filter_spec.rb
index cade8cb409e..1cb732fad33 100644
--- a/spec/lib/banzai/filter/math_filter_spec.rb
+++ b/spec/lib/banzai/filter/math_filter_spec.rb
@@ -1,86 +1,86 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::MathFilter do
include FilterSpecHelper
- it 'leaves regular inline code unchanged' do
+ it "leaves regular inline code unchanged" do
input = "<code>2+2</code>"
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'removes surrounding dollar signs and adds class code, math and js-render-math' do
+ it "removes surrounding dollar signs and adds class code, math and js-render-math" do
doc = filter("$<code>2+2</code>$")
expect(doc.to_s).to eq '<code class="code math js-render-math" data-math-style="inline">2+2</code>'
end
- it 'only removes surrounding dollar signs' do
+ it "only removes surrounding dollar signs" do
doc = filter("test $<code>2+2</code>$ test")
- before = doc.xpath('descendant-or-self::text()[1]').first
- after = doc.xpath('descendant-or-self::text()[3]').first
+ before = doc.xpath("descendant-or-self::text()[1]").first
+ after = doc.xpath("descendant-or-self::text()[3]").first
- expect(before.to_s).to eq 'test '
- expect(after.to_s).to eq ' test'
+ expect(before.to_s).to eq "test "
+ expect(after.to_s).to eq " test"
end
- it 'only removes surrounding single dollar sign' do
+ it "only removes surrounding single dollar sign" do
doc = filter("test $$<code>2+2</code>$$ test")
- before = doc.xpath('descendant-or-self::text()[1]').first
- after = doc.xpath('descendant-or-self::text()[3]').first
+ before = doc.xpath("descendant-or-self::text()[1]").first
+ after = doc.xpath("descendant-or-self::text()[3]").first
- expect(before.to_s).to eq 'test $'
- expect(after.to_s).to eq '$ test'
+ expect(before.to_s).to eq "test $"
+ expect(after.to_s).to eq "$ test"
end
- it 'adds data-math-style inline attribute to inline math' do
- doc = filter('$<code>2+2</code>$')
- code = doc.xpath('descendant-or-self::code').first
+ it "adds data-math-style inline attribute to inline math" do
+ doc = filter("$<code>2+2</code>$")
+ code = doc.xpath("descendant-or-self::code").first
- expect(code['data-math-style']).to eq 'inline'
+ expect(code["data-math-style"]).to eq "inline"
end
- it 'adds class code and math to inline math' do
- doc = filter('$<code>2+2</code>$')
- code = doc.xpath('descendant-or-self::code').first
+ it "adds class code and math to inline math" do
+ doc = filter("$<code>2+2</code>$")
+ code = doc.xpath("descendant-or-self::code").first
expect(code[:class]).to include("code")
expect(code[:class]).to include("math")
end
- it 'adds js-render-math class to inline math' do
- doc = filter('$<code>2+2</code>$')
- code = doc.xpath('descendant-or-self::code').first
+ it "adds js-render-math class to inline math" do
+ doc = filter("$<code>2+2</code>$")
+ code = doc.xpath("descendant-or-self::code").first
expect(code[:class]).to include("js-render-math")
end
# Cases with faulty syntax. Should be a no-op
- it 'ignores cases with missing dolar sign at the end' do
+ it "ignores cases with missing dolar sign at the end" do
input = "test $<code>2+2</code> test"
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'ignores cases with missing dolar sign at the beginning' do
+ it "ignores cases with missing dolar sign at the beginning" do
input = "test <code>2+2</code>$ test"
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'ignores dollar signs if it is not adjacent' do
- input = '<p>We check strictly $<code>2+2</code> and <code>2+2</code>$ </p>'
+ it "ignores dollar signs if it is not adjacent" do
+ input = "<p>We check strictly $<code>2+2</code> and <code>2+2</code>$ </p>"
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'ignores dollar signs if they are inside another element' do
- input = '<p>We check strictly <em>$</em><code>2+2</code><em>$</em></p>'
+ it "ignores dollar signs if they are inside another element" do
+ input = "<p>We check strictly <em>$</em><code>2+2</code><em>$</em></p>"
doc = filter(input)
expect(doc.to_s).to eq input
@@ -88,40 +88,40 @@ describe Banzai::Filter::MathFilter do
# Display math
- it 'adds data-math-style display attribute to display math' do
+ it "adds data-math-style display attribute to display math" do
doc = filter('<pre class="code highlight js-syntax-highlight math" v-pre="true"><code>2+2</code></pre>')
- pre = doc.xpath('descendant-or-self::pre').first
+ pre = doc.xpath("descendant-or-self::pre").first
- expect(pre['data-math-style']).to eq 'display'
+ expect(pre["data-math-style"]).to eq "display"
end
- it 'adds js-render-math class to display math' do
+ it "adds js-render-math class to display math" do
doc = filter('<pre class="code highlight js-syntax-highlight math" v-pre="true"><code>2+2</code></pre>')
- pre = doc.xpath('descendant-or-self::pre').first
+ pre = doc.xpath("descendant-or-self::pre").first
expect(pre[:class]).to include("js-render-math")
end
- it 'ignores code blocks that are not math' do
+ it "ignores code blocks that are not math" do
input = '<pre class="code highlight js-syntax-highlight plaintext" v-pre="true"><code>2+2</code></pre>'
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'requires the pre to contain both code and math' do
+ it "requires the pre to contain both code and math" do
input = '<pre class="highlight js-syntax-highlight plaintext math" v-pre="true"><code>2+2</code></pre>'
doc = filter(input)
expect(doc.to_s).to eq input
end
- it 'dollar signs around to display math' do
+ it "dollar signs around to display math" do
doc = filter('$<pre class="code highlight js-syntax-highlight math" v-pre="true"><code>2+2</code></pre>$')
- before = doc.xpath('descendant-or-self::text()[1]').first
- after = doc.xpath('descendant-or-self::text()[3]').first
+ before = doc.xpath("descendant-or-self::text()[1]").first
+ after = doc.xpath("descendant-or-self::text()[3]").first
- expect(before.to_s).to eq '$'
- expect(after.to_s).to eq '$'
+ expect(before.to_s).to eq "$"
+ expect(after.to_s).to eq "$"
end
end
diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
index 55c41e55437..705220a7a82 100644
--- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::MergeRequestReferenceFilter do
include FilterSpecHelper
@@ -6,21 +6,21 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
let(:project) { create(:project, :public) }
let(:merge) { create(:merge_request, source_project: project) }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Merge #{merge.to_reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- describe 'performance' do
- let(:another_merge) { create(:merge_request, source_project: project, source_branch: 'fix') }
+ describe "performance" do
+ let(:another_merge) { create(:merge_request, source_project: project, source_branch: "fix") }
- it 'does not have a N+1 query problem' do
+ it "does not have a N+1 query problem" do
single_reference = "Merge request #{merge.to_reference}"
multiple_references = "Merge requests #{merge.to_reference} and #{another_merge.to_reference}"
@@ -30,206 +30,206 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
end
end
- context 'internal reference' do
+ context "internal reference" do
let(:reference) { merge.to_reference }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_merge_request_url(project, merge)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Merge (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(reference)}</a>\.\)})
end
- it 'ignores invalid merge IDs' do
+ it "ignores invalid merge IDs" do
exp = act = "Merge #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
- it 'ignores out-of-bounds merge request IDs on the referenced project' do
+ it "ignores out-of-bounds merge request IDs on the referenced project" do
exp = act = "Merge !#{Gitlab::Database::MAX_INT_VALUE + 1}"
expect(reference_filter(act).to_html).to eq exp
end
- it 'includes a title attribute' do
+ it "includes a title attribute" do
doc = reference_filter("Merge #{reference}")
- expect(doc.css('a').first.attr('title')).to eq merge.title
+ expect(doc.css("a").first.attr("title")).to eq merge.title
end
- it 'escapes the title attribute' do
- merge.update_attribute(:title, %{"></a>whatever<a title="})
+ it "escapes the title attribute" do
+ merge.update_attribute(:title, %("></a>whatever<a title="))
doc = reference_filter("Merge #{reference}")
expect(doc.text).to eq "Merge #{reference}"
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Merge #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-merge_request has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-merge_request has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Merge #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-merge-request attribute' do
+ it "includes a data-merge-request attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-merge-request')
- expect(link.attr('data-merge-request')).to eq merge.id.to_s
+ expect(link).to have_attribute("data-merge-request")
+ expect(link.attr("data-merge-request")).to eq merge.id.to_s
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Merge #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.project_merge_request_url(project, merge, only_path: true)
end
end
- context 'cross-project / cross-namespace complete reference' do
+ context "cross-project / cross-namespace complete reference" do
let(:project2) { create(:project, :public) }
let(:merge) { create(:merge_request, source_project: project2) }
let(:reference) { "#{project2.full_path}!#{merge.iid}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_merge_request_url(project2, merge)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Merge (#{reference}.)")
- expect(doc.css('a').first.text).to eq(reference)
+ expect(doc.css("a").first.text).to eq(reference)
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Merge (#{reference}.)")
expect(doc.text).to eq("Merge (#{reference}.)")
end
- it 'ignores invalid merge IDs on the referenced project' do
+ it "ignores invalid merge IDs on the referenced project" do
exp = act = "Merge #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project / same-namespace complete reference' do
+ context "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) }
let!(:merge) { create(:merge_request, source_project: project2) }
let(:reference) { "#{project2.full_path}!#{merge.iid}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_merge_request_url(project2, merge)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Merge (#{reference}.)")
- expect(doc.css('a').first.text).to eq("#{project2.path}!#{merge.iid}")
+ expect(doc.css("a").first.text).to eq("#{project2.path}!#{merge.iid}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Merge (#{reference}.)")
expect(doc.text).to eq("Merge (#{project2.path}!#{merge.iid}.)")
end
- it 'ignores invalid merge IDs on the referenced project' do
+ it "ignores invalid merge IDs on the referenced project" do
exp = act = "Merge #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project shorthand reference' do
+ context "cross-project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) }
let!(:merge) { create(:merge_request, source_project: project2) }
let(:reference) { "#{project2.path}!#{merge.iid}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_merge_request_url(project2, merge)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("Merge (#{reference}.)")
- expect(doc.css('a').first.text).to eq("#{project2.path}!#{merge.iid}")
+ expect(doc.css("a").first.text).to eq("#{project2.path}!#{merge.iid}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("Merge (#{reference}.)")
expect(doc.text).to eq("Merge (#{project2.path}!#{merge.iid}.)")
end
- it 'ignores invalid merge IDs on the referenced project' do
+ it "ignores invalid merge IDs on the referenced project" do
exp = act = "Merge #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'URL reference for a commit' do
+ context "URL reference for a commit" do
let(:mr) { create(:merge_request, :with_diffs) }
let(:reference) do
urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=#{mr.diff_head_sha}"
end
let(:commit) { mr.commits.find { |commit| commit.sha == mr.diff_head_sha } }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq reference
end
- it 'commit ref tag is valid' do
+ it "commit ref tag is valid" do
doc = reference_filter("See #{reference}")
- commit_ref_tag = doc.css('a').first.css('span.gfm.gfm-commit')
+ commit_ref_tag = doc.css("a").first.css("span.gfm.gfm-commit")
expect(commit_ref_tag.text).to eq(commit.short_id)
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See #{reference}")
expect(doc.text).to eq("See #{mr.to_reference(full: true)} (#{commit.short_id})")
end
- it 'has valid title attribute' do
+ it "has valid title attribute" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('title')).to eq(commit.title)
+ expect(doc.css("a").first.attr("title")).to eq(commit.title)
end
- it 'ignores invalid commit short_ids on link text' do
+ it "ignores invalid commit short_ids on link text" do
invalidate_commit_reference =
urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=12345678"
doc = reference_filter("See #{invalidate_commit_reference}")
@@ -238,32 +238,32 @@ describe Banzai::Filter::MergeRequestReferenceFilter do
end
end
- context 'cross-project URL reference' do
- let(:namespace) { create(:namespace, name: 'cross-reference') }
+ context "cross-project URL reference" do
+ let(:namespace) { create(:namespace, name: "cross-reference") }
let(:project2) { create(:project, :public, namespace: namespace) }
let(:merge) { create(:merge_request, source_project: project2, target_project: project2) }
- let(:reference) { urls.project_merge_request_url(project2, merge) + '/diffs#note_123' }
+ let(:reference) { urls.project_merge_request_url(project2, merge) + "/diffs#note_123" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq reference
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Merge (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(merge.to_reference(project))} \(diffs, comment 123\)</a>\.\)})
end
end
- context 'group context' do
- it 'links to a valid reference' do
+ context "group context" do
+ it "links to a valid reference" do
reference = "#{project.full_path}!#{merge.iid}"
- result = reference_filter("See #{reference}", { project: nil, group: create(:group) } )
+ result = reference_filter("See #{reference}", {project: nil, group: create(:group)})
- expect(result.css('a').first.attr('href')).to eq(urls.project_merge_request_url(project, merge))
+ expect(result.css("a").first.attr("href")).to eq(urls.project_merge_request_url(project, merge))
end
end
end
diff --git a/spec/lib/banzai/filter/mermaid_filter_spec.rb b/spec/lib/banzai/filter/mermaid_filter_spec.rb
index f6474c8936d..5e9e308f3b2 100644
--- a/spec/lib/banzai/filter/mermaid_filter_spec.rb
+++ b/spec/lib/banzai/filter/mermaid_filter_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::MermaidFilter do
include FilterSpecHelper
- it 'adds `js-render-mermaid` class to the `code` tag' do
+ it "adds `js-render-mermaid` class to the `code` tag" do
doc = filter("<pre class='code highlight js-syntax-highlight mermaid' lang='mermaid' v-pre='true'><code>graph TD;\n A--&gt;B;\n</code></pre>")
- result = doc.css('code').first
+ result = doc.css("code").first
- expect(result[:class]).to include('js-render-mermaid')
+ expect(result[:class]).to include("js-render-mermaid")
end
end
diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
index 4c94e4fdae0..193dfc786db 100644
--- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::MilestoneReferenceFilter do
include FilterSpecHelper
@@ -7,221 +7,221 @@ describe Banzai::Filter::MilestoneReferenceFilter do
let(:group) { create(:group, :public, parent: parent_group) }
let(:project) { create(:project, :public, group: group) }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- shared_examples 'reference parsing' do
- %w(pre code a style).each do |elem|
+ shared_examples "reference parsing" do
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>milestone #{reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Milestone #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-milestone has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-milestone has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Milestone #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-milestone attribute' do
+ it "includes a data-milestone attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-milestone')
- expect(link.attr('data-milestone')).to eq milestone.id.to_s
+ expect(link).to have_attribute("data-milestone")
+ expect(link.attr("data-milestone")).to eq milestone.id.to_s
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Milestone #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.milestone_path(milestone)
end
end
- shared_examples 'Integer-based references' do
- it 'links to a valid reference' do
+ shared_examples "Integer-based references" do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone)
+ expect(doc.css("a").first.attr("href")).to eq urls.milestone_url(milestone)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Milestone (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+>#{milestone.reference_link_text}</a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+>#{milestone.reference_link_text}</a>\.\)})
end
- it 'ignores invalid milestone IIDs' do
+ it "ignores invalid milestone IIDs" do
exp = act = "Milestone #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- shared_examples 'String-based single-word references' do
+ shared_examples "String-based single-word references" do
let(:reference) { "#{Milestone.reference_prefix}#{milestone.name}" }
before do
- milestone.update!(name: 'gfm')
+ milestone.update!(name: "gfm")
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone)
+ expect(doc.css("a").first.attr("href")).to eq urls.milestone_url(milestone)
expect(doc.text).to eq "See #{milestone.reference_link_text}"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Milestone (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+>#{milestone.reference_link_text}</a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+>#{milestone.reference_link_text}</a>\.\)})
end
- it 'ignores invalid milestone names' do
+ it "ignores invalid milestone names" do
exp = act = "Milestone #{Milestone.reference_prefix}#{milestone.name.reverse}"
expect(reference_filter(act).to_html).to eq exp
end
end
- shared_examples 'String-based multi-word references in quotes' do
+ shared_examples "String-based multi-word references in quotes" do
let(:reference) { milestone.to_reference(format: :name) }
before do
- milestone.update!(name: 'gfm references')
+ milestone.update!(name: "gfm references")
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone)
+ expect(doc.css("a").first.attr("href")).to eq urls.milestone_url(milestone)
expect(doc.text).to eq "See #{milestone.reference_link_text}"
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Milestone (#{reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+>#{milestone.reference_link_text}</a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+>#{milestone.reference_link_text}</a>\.\)})
end
- it 'ignores invalid milestone names' do
+ it "ignores invalid milestone names" do
exp = act = %(Milestone #{Milestone.reference_prefix}"#{milestone.name.reverse}")
expect(reference_filter(act).to_html).to eq exp
end
end
- shared_examples 'referencing a milestone in a link href' do
+ shared_examples "referencing a milestone in a link href" do
let(:unquoted_reference) { "#{Milestone.reference_prefix}#{milestone.name}" }
- let(:link_reference) { %Q{<a href="#{unquoted_reference}">Milestone</a>} }
+ let(:link_reference) { %(<a href="#{unquoted_reference}">Milestone</a>) }
before do
- milestone.update!(name: 'gfm')
+ milestone.update!(name: "gfm")
end
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{link_reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.milestone_url(milestone)
+ expect(doc.css("a").first.attr("href")).to eq urls.milestone_url(milestone)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Milestone (#{link_reference}.)")
- expect(doc.to_html).to match(%r(\(<a.+>Milestone</a>\.\)))
+ expect(doc.to_html).to match(%r{\(<a.+>Milestone</a>\.\)})
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Milestone #{link_reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-milestone attribute' do
+ it "includes a data-milestone attribute" do
doc = reference_filter("See #{link_reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-milestone')
- expect(link.attr('data-milestone')).to eq milestone.id.to_s
+ expect(link).to have_attribute("data-milestone")
+ expect(link.attr("data-milestone")).to eq milestone.id.to_s
end
end
- shared_examples 'linking to a milestone as the entire link' do
+ shared_examples "linking to a milestone as the entire link" do
let(:unquoted_reference) { "#{Milestone.reference_prefix}#{milestone.name}" }
let(:link) { urls.milestone_url(milestone) }
- let(:link_reference) { %Q{<a href="#{link}">#{link}</a>} }
+ let(:link_reference) { %(<a href="#{link}">#{link}</a>) }
- it 'replaces the link text with the milestone reference' do
+ it "replaces the link text with the milestone reference" do
doc = reference_filter("See #{link}")
- expect(doc.css('a').first.text).to eq(unquoted_reference)
+ expect(doc.css("a").first.text).to eq(unquoted_reference)
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Milestone #{link_reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-milestone attribute' do
+ it "includes a data-milestone attribute" do
doc = reference_filter("See #{link_reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-milestone')
- expect(link.attr('data-milestone')).to eq milestone.id.to_s
+ expect(link).to have_attribute("data-milestone")
+ expect(link.attr("data-milestone")).to eq milestone.id.to_s
end
end
- shared_examples 'cross-project / cross-namespace complete reference' do
+ shared_examples "cross-project / cross-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:another_project) { create(:project, :public, namespace: namespace) }
let(:milestone) { create(:milestone, project: another_project) }
let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'points to referenced project milestone page' do
- expect(result.css('a').first.attr('href')).to eq urls
+ it "points to referenced project milestone page" do
+ expect(result.css("a").first.attr("href")).to eq urls
.project_milestone_url(another_project, milestone)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq("#{milestone.reference_link_text} in #{another_project.full_path}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text)
.to eq("See (#{milestone.reference_link_text} in #{another_project.full_path}.)")
end
- it 'escapes the name attribute' do
- allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="})
+ it "escapes the name attribute" do
+ allow_any_instance_of(Milestone).to receive(:title).and_return(%("></a>whatever<a title="))
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq "#{milestone.reference_link_text} in #{another_project.full_path}"
end
end
- shared_examples 'cross-project / same-namespace complete reference' do
+ shared_examples "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:another_project) { create(:project, :public, namespace: namespace) }
@@ -229,36 +229,36 @@ describe Banzai::Filter::MilestoneReferenceFilter do
let(:reference) { "#{another_project.full_path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'points to referenced project milestone page' do
- expect(result.css('a').first.attr('href')).to eq urls
+ it "points to referenced project milestone page" do
+ expect(result.css("a").first.attr("href")).to eq urls
.project_milestone_url(another_project, milestone)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq("#{milestone.reference_link_text} in #{another_project.path}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text)
.to eq("See (#{milestone.reference_link_text} in #{another_project.path}.)")
end
- it 'escapes the name attribute' do
- allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="})
+ it "escapes the name attribute" do
+ allow_any_instance_of(Milestone).to receive(:title).and_return(%("></a>whatever<a title="))
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq "#{milestone.reference_link_text} in #{another_project.path}"
end
end
- shared_examples 'cross project shorthand reference' do
+ shared_examples "cross project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:another_project) { create(:project, :public, namespace: namespace) }
@@ -266,71 +266,71 @@ describe Banzai::Filter::MilestoneReferenceFilter do
let(:reference) { "#{another_project.path}%#{milestone.iid}" }
let!(:result) { reference_filter("See #{reference}") }
- it 'points to referenced project milestone page' do
- expect(result.css('a').first.attr('href')).to eq urls
+ it "points to referenced project milestone page" do
+ expect(result.css("a").first.attr("href")).to eq urls
.project_milestone_url(another_project, milestone)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq("#{milestone.reference_link_text} in #{another_project.path}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text)
.to eq("See (#{milestone.reference_link_text} in #{another_project.path}.)")
end
- it 'escapes the name attribute' do
- allow_any_instance_of(Milestone).to receive(:title).and_return(%{"></a>whatever<a title="})
+ it "escapes the name attribute" do
+ allow_any_instance_of(Milestone).to receive(:title).and_return(%("></a>whatever<a title="))
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.text)
+ expect(doc.css("a").first.text)
.to eq "#{milestone.reference_link_text} in #{another_project.path}"
end
end
- shared_context 'project milestones' do
+ shared_context "project milestones" do
let(:reference) { milestone.to_reference(format: :iid) }
- include_examples 'reference parsing'
+ include_examples "reference parsing"
- it_behaves_like 'Integer-based references'
- it_behaves_like 'String-based single-word references'
- it_behaves_like 'String-based multi-word references in quotes'
- it_behaves_like 'referencing a milestone in a link href'
- it_behaves_like 'cross-project / cross-namespace complete reference'
- it_behaves_like 'cross-project / same-namespace complete reference'
- it_behaves_like 'cross project shorthand reference'
+ it_behaves_like "Integer-based references"
+ it_behaves_like "String-based single-word references"
+ it_behaves_like "String-based multi-word references in quotes"
+ it_behaves_like "referencing a milestone in a link href"
+ it_behaves_like "cross-project / cross-namespace complete reference"
+ it_behaves_like "cross-project / same-namespace complete reference"
+ it_behaves_like "cross project shorthand reference"
end
- shared_context 'group milestones' do
+ shared_context "group milestones" do
let(:reference) { milestone.to_reference(format: :name) }
- include_examples 'reference parsing'
+ include_examples "reference parsing"
- it_behaves_like 'String-based single-word references'
- it_behaves_like 'String-based multi-word references in quotes'
- it_behaves_like 'referencing a milestone in a link href'
+ it_behaves_like "String-based single-word references"
+ it_behaves_like "String-based multi-word references in quotes"
+ it_behaves_like "referencing a milestone in a link href"
- it 'does not support references by IID' do
+ it "does not support references by IID" do
doc = reference_filter("See #{Milestone.reference_prefix}#{milestone.iid}")
- expect(doc.css('a')).to be_empty
+ expect(doc.css("a")).to be_empty
end
- it 'does not support references by link' do
+ it "does not support references by link" do
doc = reference_filter("See #{urls.milestone_url(milestone)}")
- expect(doc.css('a').first.text).to eq(urls.milestone_url(milestone))
+ expect(doc.css("a").first.text).to eq(urls.milestone_url(milestone))
end
- it 'does not support cross-project references' do
+ it "does not support cross-project references" do
another_group = create(:group)
another_project = create(:project, :public, group: group)
project_reference = another_project.to_reference(project)
@@ -339,58 +339,58 @@ describe Banzai::Filter::MilestoneReferenceFilter do
doc = reference_filter("See #{project_reference}#{reference}")
- expect(doc.css('a')).to be_empty
+ expect(doc.css("a")).to be_empty
end
- it 'supports parent group references', :nested_groups do
+ it "supports parent group references", :nested_groups do
milestone.update!(group: parent_group)
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.text).to eq(milestone.reference_link_text)
+ expect(doc.css("a").first.text).to eq(milestone.reference_link_text)
end
end
- context 'group context' do
+ context "group context" do
let(:group) { create(:group) }
- let(:context) { { project: nil, group: group } }
+ let(:context) { {project: nil, group: group} }
- context 'when project milestone' do
+ context "when project milestone" do
let(:milestone) { create(:milestone, project: project) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
reference = "#{project.full_path}%#{milestone.iid}"
result = reference_filter("See #{reference}", context)
- expect(result.css('a').first.attr('href')).to eq(urls.milestone_url(milestone))
+ expect(result.css("a").first.attr("href")).to eq(urls.milestone_url(milestone))
end
- it 'ignores internal references' do
+ it "ignores internal references" do
exp = act = "See %#{milestone.iid}"
expect(reference_filter(act, context).to_html).to eq exp
end
end
- context 'when group milestone' do
- let(:group_milestone) { create(:milestone, title: 'group_milestone', group: group) }
+ context "when group milestone" do
+ let(:group_milestone) { create(:milestone, title: "group_milestone", group: group) }
- context 'for subgroups', :nested_groups do
+ context "for subgroups", :nested_groups do
let(:sub_group) { create(:group, parent: group) }
- let(:sub_group_milestone) { create(:milestone, title: 'sub_group_milestone', group: sub_group) }
+ let(:sub_group_milestone) { create(:milestone, title: "sub_group_milestone", group: sub_group) }
- it 'links to a valid reference of subgroup and group milestones' do
+ it "links to a valid reference of subgroup and group milestones" do
[group_milestone, sub_group_milestone].each do |milestone|
reference = "%#{milestone.title}"
- result = reference_filter("See #{reference}", { project: nil, group: sub_group })
+ result = reference_filter("See #{reference}", {project: nil, group: sub_group})
- expect(result.css('a').first.attr('href')).to eq(urls.milestone_url(milestone))
+ expect(result.css("a").first.attr("href")).to eq(urls.milestone_url(milestone))
end
end
end
- it 'ignores internal references' do
+ it "ignores internal references" do
exp = act = "See %#{group_milestone.iid}"
expect(reference_filter(act, context).to_html).to eq exp
@@ -398,31 +398,31 @@ describe Banzai::Filter::MilestoneReferenceFilter do
end
end
- context 'when milestone is open' do
- context 'project milestones' do
+ context "when milestone is open" do
+ context "project milestones" do
let(:milestone) { create(:milestone, project: project) }
- include_context 'project milestones'
+ include_context "project milestones"
end
- context 'group milestones' do
+ context "group milestones" do
let(:milestone) { create(:milestone, group: group) }
- include_context 'group milestones'
+ include_context "group milestones"
end
end
- context 'when milestone is closed' do
- context 'project milestones' do
+ context "when milestone is closed" do
+ context "project milestones" do
let(:milestone) { create(:milestone, :closed, project: project) }
- include_context 'project milestones'
+ include_context "project milestones"
end
- context 'group milestones' do
+ context "group milestones" do
let(:milestone) { create(:milestone, :closed, group: group) }
- include_context 'group milestones'
+ include_context "group milestones"
end
end
end
diff --git a/spec/lib/banzai/filter/plantuml_filter_spec.rb b/spec/lib/banzai/filter/plantuml_filter_spec.rb
index 8235c411eb7..fe20661da97 100644
--- a/spec/lib/banzai/filter/plantuml_filter_spec.rb
+++ b/spec/lib/banzai/filter/plantuml_filter_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::PlantumlFilter do
include FilterSpecHelper
- it 'should replace plantuml pre tag with img tag' do
+ it "should replace plantuml pre tag with img tag" do
stub_application_setting(plantuml_enabled: true, plantuml_url: "http://localhost:8080")
input = '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>'
output = '<div class="imageblock"><div class="content"><img class="plantuml" src="http://localhost:8080/png/U9npoazIqBLJ24uiIbImKl18pSd91m0rkGMq"></div></div>'
@@ -12,7 +12,7 @@ describe Banzai::Filter::PlantumlFilter do
expect(doc.to_s).to eq output
end
- it 'should not replace plantuml pre tag with img tag if disabled' do
+ it "should not replace plantuml pre tag with img tag if disabled" do
stub_application_setting(plantuml_enabled: false)
input = '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>'
output = '<pre><code lang="plantuml">Bob -&gt; Sara : Hello</code></pre>'
@@ -21,7 +21,7 @@ describe Banzai::Filter::PlantumlFilter do
expect(doc.to_s).to eq output
end
- it 'should not replace plantuml pre tag with img tag if url is invalid' do
+ it "should not replace plantuml pre tag with img tag if url is invalid" do
stub_application_setting(plantuml_enabled: true, plantuml_url: "invalid")
input = '<pre><code lang="plantuml">Bob -> Sara : Hello</code></pre>'
output = '<div class="listingblock"><div class="content"><pre class="plantuml plantuml-error"> PlantUML Error: cannot connect to PlantUML server at "invalid"</pre></div></div>'
diff --git a/spec/lib/banzai/filter/project_reference_filter_spec.rb b/spec/lib/banzai/filter/project_reference_filter_spec.rb
index 69f9c1ae829..abd9b0c1a10 100644
--- a/spec/lib/banzai/filter/project_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/project_reference_filter_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ProjectReferenceFilter do
include FilterSpecHelper
def invalidate_reference(reference)
- "#{reference.reverse}"
+ reference.reverse.to_s
end
def get_reference(project)
@@ -18,70 +18,70 @@ describe Banzai::Filter::ProjectReferenceFilter do
let(:subject_name) { "project" }
let(:reference) { get_reference(project) }
- it_behaves_like 'user reference or project reference'
+ it_behaves_like "user reference or project reference"
- it 'ignores invalid projects' do
+ it "ignores invalid projects" do
exp = act = "Hey #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq(CGI.escapeHTML(exp))
end
- it 'fails fast for long invalid string' do
- expect do
+ it "fails fast for long invalid string" do
+ expect {
Timeout.timeout(5.seconds) { reference_filter("A" * 50000).to_html }
- end.not_to raise_error
+ }.not_to raise_error
end
- it 'allows references with text after the > character' do
+ it "allows references with text after the > character" do
doc = reference_filter("Hey #{reference}foo")
- expect(doc.css('a').first.attr('href')).to eq urls.project_url(subject)
+ expect(doc.css("a").first.attr("href")).to eq urls.project_url(subject)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Hey #{CGI.escapeHTML(reference)}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-project has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-project has-tooltip"
end
- context 'in group context' do
+ context "in group context" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:nested_group) { create(:group, :nested) }
let(:nested_project) { create(:project, group: nested_group) }
- it 'supports mentioning a project' do
+ it "supports mentioning a project" do
reference = get_reference(project)
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.project_url(project)
+ expect(doc.css("a").first.attr("href")).to eq urls.project_url(project)
end
- it 'supports mentioning a project in a nested group' do
+ it "supports mentioning a project in a nested group" do
reference = get_reference(nested_project)
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.project_url(nested_project)
+ expect(doc.css("a").first.attr("href")).to eq urls.project_url(nested_project)
end
end
- describe '#projects_hash' do
- it 'returns a Hash containing all Projects' do
+ describe "#projects_hash" do
+ it "returns a Hash containing all Projects" do
document = Nokogiri::HTML.fragment("<p>#{get_reference(project)}</p>")
filter = described_class.new(document, project: project)
- expect(filter.projects_hash).to eq({ project.full_path => project })
+ expect(filter.projects_hash).to eq({project.full_path => project})
end
end
- describe '#projects' do
- it 'returns the projects mentioned in a document' do
+ describe "#projects" do
+ it "returns the projects mentioned in a document" do
document = Nokogiri::HTML.fragment("<p>#{get_reference(project)}</p>")
filter = described_class.new(document, project: project)
diff --git a/spec/lib/banzai/filter/redactor_filter_spec.rb b/spec/lib/banzai/filter/redactor_filter_spec.rb
index 919825a6102..634395167f5 100644
--- a/spec/lib/banzai/filter/redactor_filter_spec.rb
+++ b/spec/lib/banzai/filter/redactor_filter_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::RedactorFilter do
include ActionView::Helpers::UrlHelper
include FilterSpecHelper
- it 'ignores non-GFM links' do
+ it "ignores non-GFM links" do
html = %(See <a href="https://google.com/">Google</a>)
doc = filter(html, current_user: build(:user))
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
def reference_link(data)
- link_to('text', '', class: 'gfm', data: data)
+ link_to("text", "", class: "gfm", data: data)
end
- it 'skips when the skip_redaction flag is set' do
+ it "skips when the skip_redaction flag is set" do
user = create(:user)
project = create(:project)
- link = reference_link(project: project.id, reference_type: 'test')
+ link = reference_link(project: project.id, reference_type: "test")
doc = filter(link, current_user: user, skip_redaction: true)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- context 'with data-project' do
+ context "with data-project" do
let(:parser_class) do
Class.new(Banzai::ReferenceParser::BaseParser) do
self.reference_type = :test
@@ -34,171 +34,171 @@ describe Banzai::Filter::RedactorFilter do
before do
allow(Banzai::ReferenceParser).to receive(:[])
- .with('test')
+ .with("test")
.and_return(parser_class)
end
- context 'valid projects' do
+ context "valid projects" do
before do
allow_any_instance_of(Banzai::ReferenceParser::BaseParser).to receive(:can_read_reference?).and_return(true)
end
- it 'allows permitted Project references' do
+ it "allows permitted Project references" do
user = create(:user)
project = create(:project)
project.add_maintainer(user)
- link = reference_link(project: project.id, reference_type: 'test')
+ link = reference_link(project: project.id, reference_type: "test")
doc = filter(link, current_user: user)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
end
- context 'invalid projects' do
+ context "invalid projects" do
before do
allow_any_instance_of(Banzai::ReferenceParser::BaseParser).to receive(:can_read_reference?).and_return(false)
end
- it 'removes unpermitted references' do
+ it "removes unpermitted references" do
user = create(:user)
project = create(:project)
- link = reference_link(project: project.id, reference_type: 'test')
+ link = reference_link(project: project.id, reference_type: "test")
doc = filter(link, current_user: user)
- expect(doc.css('a').length).to eq 0
+ expect(doc.css("a").length).to eq 0
end
- it 'handles invalid references' do
- link = reference_link(project: 12345, reference_type: 'test')
+ it "handles invalid references" do
+ link = reference_link(project: 12345, reference_type: "test")
expect { filter(link) }.not_to raise_error
end
end
end
- context 'with data-issue' do
- context 'for confidential issues' do
- it 'removes references for non project members' do
+ context "with data-issue" do
+ context "for confidential issues" do
+ it "removes references for non project members" do
non_member = create(:user)
project = create(:project, :public)
issue = create(:issue, :confidential, project: project)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: non_member)
- expect(doc.css('a').length).to eq 0
+ expect(doc.css("a").length).to eq 0
end
- it 'removes references for project members with guest role' do
+ it "removes references for project members with guest role" do
member = create(:user)
project = create(:project, :public)
project.add_guest(member)
issue = create(:issue, :confidential, project: project)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: member)
- expect(doc.css('a').length).to eq 0
+ expect(doc.css("a").length).to eq 0
end
- it 'allows references for author' do
+ it "allows references for author" do
author = create(:user)
project = create(:project, :public)
issue = create(:issue, :confidential, project: project, author: author)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: author)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'allows references for assignee' do
+ it "allows references for assignee" do
assignee = create(:user)
project = create(:project, :public)
issue = create(:issue, :confidential, project: project, assignees: [assignee])
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: assignee)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'allows references for project members' do
+ it "allows references for project members" do
member = create(:user)
project = create(:project, :public)
project.add_developer(member)
issue = create(:issue, :confidential, project: project)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: member)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'allows references for admin' do
+ it "allows references for admin" do
admin = create(:admin)
project = create(:project, :public)
issue = create(:issue, :confidential, project: project)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: admin)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
end
- it 'allows references for non confidential issues' do
+ it "allows references for non confidential issues" do
user = create(:user)
project = create(:project, :public)
issue = create(:issue, project: project)
- link = reference_link(project: project.id, issue: issue.id, reference_type: 'issue')
+ link = reference_link(project: project.id, issue: issue.id, reference_type: "issue")
doc = filter(link, current_user: user)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
end
context "for user references" do
- context 'with data-group' do
- it 'removes unpermitted Group references' do
+ context "with data-group" do
+ it "removes unpermitted Group references" do
user = create(:user)
group = create(:group, :private)
- link = reference_link(group: group.id, reference_type: 'user')
+ link = reference_link(group: group.id, reference_type: "user")
doc = filter(link, current_user: user)
- expect(doc.css('a').length).to eq 0
+ expect(doc.css("a").length).to eq 0
end
- it 'allows permitted Group references' do
+ it "allows permitted Group references" do
user = create(:user)
group = create(:group, :private)
group.add_developer(user)
- link = reference_link(group: group.id, reference_type: 'user')
+ link = reference_link(group: group.id, reference_type: "user")
doc = filter(link, current_user: user)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'handles invalid Group references' do
- link = reference_link(group: 12345, reference_type: 'user')
+ it "handles invalid Group references" do
+ link = reference_link(group: 12345, reference_type: "user")
expect { filter(link) }.not_to raise_error
end
end
- context 'with data-user' do
- it 'allows any User reference' do
+ context "with data-user" do
+ it "allows any User reference" do
user = create(:user)
- link = reference_link(user: user.id, reference_type: 'user')
+ link = reference_link(user: user.id, reference_type: "user")
doc = filter(link)
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
end
end
diff --git a/spec/lib/banzai/filter/reference_filter_spec.rb b/spec/lib/banzai/filter/reference_filter_spec.rb
index f96b6c83b0a..942cb6d8a4d 100644
--- a/spec/lib/banzai/filter/reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/reference_filter_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::ReferenceFilter do
let(:project) { build_stubbed(:project) }
- describe '#each_node' do
- it 'iterates over the nodes in a document' do
+ describe "#each_node" do
+ it "iterates over the nodes in a document" do
document = Nokogiri::HTML.fragment('<a href="foo">foo</a>')
filter = described_class.new(document, project: project)
@@ -12,7 +12,7 @@ describe Banzai::Filter::ReferenceFilter do
.to yield_with_args(an_instance_of(Nokogiri::XML::Element))
end
- it 'returns an Enumerator when no block is given' do
+ it "returns an Enumerator when no block is given" do
document = Nokogiri::HTML.fragment('<a href="foo">foo</a>')
filter = described_class.new(document, project: project)
@@ -26,16 +26,16 @@ describe Banzai::Filter::ReferenceFilter do
expect { |b| filter.each_node(&b) }.not_to yield_control
end
- it 'skips text nodes in pre elements' do
- document = Nokogiri::HTML.fragment('<pre>foo</pre>')
+ it "skips text nodes in pre elements" do
+ document = Nokogiri::HTML.fragment("<pre>foo</pre>")
filter = described_class.new(document, project: project)
expect { |b| filter.each_node(&b) }.not_to yield_control
end
end
- describe '#nodes' do
- it 'returns an Array of the HTML nodes' do
+ describe "#nodes" do
+ it "returns an Array of the HTML nodes" do
document = Nokogiri::HTML.fragment('<a href="foo">foo</a>')
filter = described_class.new(document, project: project)
diff --git a/spec/lib/banzai/filter/relative_link_filter_spec.rb b/spec/lib/banzai/filter/relative_link_filter_spec.rb
index dad0a5535c0..c8b50eb69a5 100644
--- a/spec/lib/banzai/filter/relative_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/relative_link_filter_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::RelativeLinkFilter do
def filter(doc, contexts = {})
contexts.reverse_merge!({
- commit: commit,
- project: project,
- group: group,
- project_wiki: project_wiki,
- ref: ref,
+ commit: commit,
+ project: project,
+ group: group,
+ project_wiki: project_wiki,
+ ref: ref,
requested_path: requested_path,
- only_path: only_path
+ only_path: only_path,
})
described_class.call(doc, contexts)
@@ -34,377 +34,377 @@ describe Banzai::Filter::RelativeLinkFilter do
let(:project) { create(:project, :repository) }
let(:group) { nil }
let(:project_path) { project.full_path }
- let(:ref) { 'markdown' }
+ let(:ref) { "markdown" }
let(:commit) { project.commit(ref) }
let(:project_wiki) { nil }
- let(:requested_path) { '/' }
+ let(:requested_path) { "/" }
let(:only_path) { true }
shared_examples :preserve_unchanged do
- it 'does not modify any relative URL in anchor' do
- doc = filter(link('README.md'))
- expect(doc.at_css('a')['href']).to eq 'README.md'
+ it "does not modify any relative URL in anchor" do
+ doc = filter(link("README.md"))
+ expect(doc.at_css("a")["href"]).to eq "README.md"
end
- it 'does not modify any relative URL in image' do
- doc = filter(image('files/images/logo-black.png'))
- expect(doc.at_css('img')['src']).to eq 'files/images/logo-black.png'
+ it "does not modify any relative URL in image" do
+ doc = filter(image("files/images/logo-black.png"))
+ expect(doc.at_css("img")["src"]).to eq "files/images/logo-black.png"
end
- it 'does not modify any relative URL in video' do
- doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
+ it "does not modify any relative URL in video" do
+ doc = filter(video("files/videos/intro.mp4"), commit: project.commit("video"), ref: "video")
- expect(doc.at_css('video')['src']).to eq 'files/videos/intro.mp4'
+ expect(doc.at_css("video")["src"]).to eq "files/videos/intro.mp4"
end
end
- context 'with a project_wiki' do
- let(:project_wiki) { double('ProjectWiki') }
+ context "with a project_wiki" do
+ let(:project_wiki) { double("ProjectWiki") }
include_examples :preserve_unchanged
end
- context 'without a repository' do
+ context "without a repository" do
let(:project) { create(:project) }
include_examples :preserve_unchanged
end
- context 'with an empty repository' do
+ context "with an empty repository" do
let(:project) { create(:project_empty_repo) }
include_examples :preserve_unchanged
end
- it 'does not raise an exception on invalid URIs' do
+ it "does not raise an exception on invalid URIs" do
act = link("://foo")
expect { filter(act) }.not_to raise_error
end
- it 'does not raise an exception with a garbled path' do
+ it "does not raise an exception with a garbled path" do
act = link("open(/var/tmp/):%20/location%0Afrom:%20/test")
expect { filter(act) }.not_to raise_error
end
- it 'does not raise an exception with a space in the path' do
+ it "does not raise an exception with a space in the path" do
act = link("/uploads/d18213acd3732630991986120e167e3d/Landscape_8.jpg \nBut here's some more unexpected text :smile:)")
expect { filter(act) }.not_to raise_error
end
- it 'ignores ref if commit is passed' do
- doc = filter(link('non/existent.file'), commit: project.commit('empty-branch') )
- expect(doc.at_css('a')['href'])
+ it "ignores ref if commit is passed" do
+ doc = filter(link("non/existent.file"), commit: project.commit("empty-branch"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/#{ref}/non/existent.file" # non-existent files have no leading blob/raw/tree
end
shared_examples :valid_repository do
- it 'rebuilds absolute URL for a file in the repo' do
- doc = filter(link('/doc/api/README.md'))
- expect(doc.at_css('a')['href'])
+ it "rebuilds absolute URL for a file in the repo" do
+ doc = filter(link("/doc/api/README.md"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
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'
+ 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'])
+ it "rebuilds relative URL for a file in the repo" do
+ doc = filter(link("doc/api/README.md"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
- it 'rebuilds relative URL for a file in the repo with leading ./' do
- doc = filter(link('./doc/api/README.md'))
- expect(doc.at_css('a')['href'])
+ it "rebuilds relative URL for a file in the repo with leading ./" do
+ doc = filter(link("./doc/api/README.md"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
- it 'rebuilds relative URL for a file in the repo up one directory' do
- relative_link = link('../api/README.md')
- doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md')
+ it "rebuilds relative URL for a file in the repo up one directory" do
+ relative_link = link("../api/README.md")
+ doc = filter(relative_link, requested_path: "doc/update/7.14-to-8.0.md")
- expect(doc.at_css('a')['href'])
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
- it 'rebuilds relative URL for a file in the repo up multiple directories' do
- relative_link = link('../../../api/README.md')
- doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md')
+ it "rebuilds relative URL for a file in the repo up multiple directories" do
+ relative_link = link("../../../api/README.md")
+ doc = filter(relative_link, requested_path: "doc/foo/bar/baz/README.md")
- expect(doc.at_css('a')['href'])
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
- it 'rebuilds relative URL for a file in the repository root' do
- relative_link = link('../README.md')
- doc = filter(relative_link, requested_path: 'doc/some-file.md')
+ it "rebuilds relative URL for a file in the repository root" do
+ relative_link = link("../README.md")
+ doc = filter(relative_link, requested_path: "doc/some-file.md")
- expect(doc.at_css('a')['href'])
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/README.md"
end
- it 'rebuilds relative URL for a file in the repo with an anchor' do
- doc = filter(link('README.md#section'))
- expect(doc.at_css('a')['href'])
+ it "rebuilds relative URL for a file in the repo with an anchor" do
+ doc = filter(link("README.md#section"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/blob/#{ref}/README.md#section"
end
- it 'rebuilds relative URL for a directory in the repo' do
- doc = filter(link('doc/api/'))
- expect(doc.at_css('a')['href'])
+ it "rebuilds relative URL for a directory in the repo" do
+ doc = filter(link("doc/api/"))
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/tree/#{ref}/doc/api"
end
- it 'rebuilds relative URL for an image in the repo' do
- doc = filter(image('files/images/logo-black.png'))
+ it "rebuilds relative URL for an image in the repo" do
+ doc = filter(image("files/images/logo-black.png"))
- expect(doc.at_css('img')['src'])
+ expect(doc.at_css("img")["src"])
.to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png"
end
- it 'rebuilds relative URL for link to an image in the repo' do
- doc = filter(link('files/images/logo-black.png'))
+ it "rebuilds relative URL for link to an image in the repo" do
+ doc = filter(link("files/images/logo-black.png"))
- expect(doc.at_css('a')['href'])
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/raw/#{ref}/files/images/logo-black.png"
end
- it 'rebuilds relative URL for a video in the repo' do
- doc = filter(video('files/videos/intro.mp4'), commit: project.commit('video'), ref: 'video')
+ it "rebuilds relative URL for a video in the repo" do
+ doc = filter(video("files/videos/intro.mp4"), commit: project.commit("video"), ref: "video")
- expect(doc.at_css('video')['src'])
+ expect(doc.at_css("video")["src"])
.to eq "/#{project_path}/raw/video/files/videos/intro.mp4"
end
- it 'does not modify relative URL with an anchor only' do
- doc = filter(link('#section-1'))
- expect(doc.at_css('a')['href']).to eq '#section-1'
+ it "does not modify relative URL with an anchor only" do
+ doc = filter(link("#section-1"))
+ expect(doc.at_css("a")["href"]).to eq "#section-1"
end
- it 'does not modify absolute URL' do
- doc = filter(link('http://example.com'))
- expect(doc.at_css('a')['href']).to eq 'http://example.com'
+ it "does not modify absolute URL" do
+ doc = filter(link("http://example.com"))
+ expect(doc.at_css("a")["href"]).to eq "http://example.com"
end
- it 'supports Unicode filenames' do
- path = 'files/images/한글.png'
+ it "supports Unicode filenames" do
+ path = "files/images/한글.png"
escaped = Addressable::URI.escape(path)
# Stub this method so the file doesn't actually need to be in the repo
allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw)
doc = filter(image(escaped))
- expect(doc.at_css('img')['src']).to eq "/#{project_path}/raw/#{Addressable::URI.escape(ref)}/#{escaped}"
+ expect(doc.at_css("img")["src"]).to eq "/#{project_path}/raw/#{Addressable::URI.escape(ref)}/#{escaped}"
end
- context 'when requested path is a file in the repo' do
- let(:requested_path) { 'doc/api/README.md' }
- it 'rebuilds URL relative to the containing directory' do
- doc = filter(link('users.md'))
- expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
+ context "when requested path is a file in the repo" do
+ let(:requested_path) { "doc/api/README.md" }
+ it "rebuilds URL relative to the containing directory" do
+ doc = filter(link("users.md"))
+ expect(doc.at_css("a")["href"]).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
end
end
- context 'when requested path is a directory in the repo' do
- let(:requested_path) { 'doc/api/' }
- it 'rebuilds URL relative to the directory' do
- doc = filter(link('users.md'))
- expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
+ context "when requested path is a directory in the repo" do
+ let(:requested_path) { "doc/api/" }
+ it "rebuilds URL relative to the directory" do
+ doc = filter(link("users.md"))
+ expect(doc.at_css("a")["href"]).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/doc/api/users.md"
end
end
- context 'when ref name contains percent sign' do
- let(:ref) { '100%branch' }
- let(:commit) { project.commit('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') }
- let(:requested_path) { 'foo/bar/' }
- it 'correctly escapes the ref' do
- doc = filter(link('.gitkeep'))
- expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep"
+ context "when ref name contains percent sign" do
+ let(:ref) { "100%branch" }
+ let(:commit) { project.commit("1b12f15a11fc6e62177bef08f47bc7b5ce50b141") }
+ let(:requested_path) { "foo/bar/" }
+ it "correctly escapes the ref" do
+ doc = filter(link(".gitkeep"))
+ expect(doc.at_css("a")["href"]).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/foo/bar/.gitkeep"
end
end
- context 'when ref name contains special chars' do
+ context "when ref name contains special chars" do
let(:ref) {'mark#\'@],+;-._/#@!$&()+down'}
- it 'correctly escapes the ref' do
+ it "correctly escapes the ref" do
# Addressable won't escape the '#', so we do this manually
- ref_escaped = 'mark%23\'@%5D,+;-._/%23@!$&()+down'
+ ref_escaped = "mark%23'@%5D,+;-._/%23@!$&()+down"
# Stub this method so the branch doesn't actually need to be in the repo
allow_any_instance_of(described_class).to receive(:uri_type).and_return(:raw)
- doc = filter(link('files/images/logo-black.png'))
+ doc = filter(link("files/images/logo-black.png"))
- expect(doc.at_css('a')['href'])
+ expect(doc.at_css("a")["href"])
.to eq "/#{project_path}/raw/#{ref_escaped}/files/images/logo-black.png"
end
end
- context 'when requested path is a directory with space in the repo' do
- let(:ref) { 'master' }
- let(:commit) { project.commit('38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e') }
- let(:requested_path) { 'with space/' }
- it 'does not escape the space twice' do
- doc = filter(link('README.md'))
- expect(doc.at_css('a')['href']).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md"
+ context "when requested path is a directory with space in the repo" do
+ let(:ref) { "master" }
+ let(:commit) { project.commit("38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e") }
+ let(:requested_path) { "with space/" }
+ it "does not escape the space twice" do
+ doc = filter(link("README.md"))
+ expect(doc.at_css("a")["href"]).to eq "/#{project_path}/blob/#{Addressable::URI.escape(ref)}/with%20space/README.md"
end
end
end
- context 'with a valid commit' do
+ context "with a valid commit" do
include_examples :valid_repository
end
- context 'with a valid ref' do
+ context "with a valid ref" do
let(:commit) { nil } # force filter to use ref instead of commit
include_examples :valid_repository
end
- context 'with a /upload/ URL' do
+ context "with a /upload/ URL" do
# not needed
let(:commit) { nil }
let(:ref) { nil }
let(:requested_path) { nil }
- let(:upload_path) { '/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg' }
+ let(:upload_path) { "/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" }
let(:relative_path) { "/#{project.full_path}#{upload_path}" }
- context 'to a project upload' do
- context 'with an absolute URL' do
+ context "to a project upload" do
+ context "with an absolute URL" do
let(:absolute_path) { Gitlab.config.gitlab.url + relative_path }
let(:only_path) { false }
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(link(upload_path))
- expect(doc.at_css('a')['href']).to eq(absolute_path)
+ expect(doc.at_css("a")["href"]).to eq(absolute_path)
end
end
- it 'rebuilds relative URL for a link' do
+ it "rebuilds relative URL for a link" do
doc = filter(link(upload_path))
- expect(doc.at_css('a')['href']).to eq(relative_path)
+ expect(doc.at_css("a")["href"]).to eq(relative_path)
doc = filter(nested(link(upload_path)))
- expect(doc.at_css('a')['href']).to eq(relative_path)
+ expect(doc.at_css("a")["href"]).to eq(relative_path)
end
- it 'rebuilds relative URL for an image' do
+ it "rebuilds relative URL for an image" do
doc = filter(image(upload_path))
- expect(doc.at_css('img')['src']).to eq(relative_path)
+ expect(doc.at_css("img")["src"]).to eq(relative_path)
doc = filter(nested(image(upload_path)))
- expect(doc.at_css('img')['src']).to eq(relative_path)
+ expect(doc.at_css("img")["src"]).to eq(relative_path)
end
- it 'does not modify absolute URL' do
- doc = filter(link('http://example.com'))
- expect(doc.at_css('a')['href']).to eq 'http://example.com'
+ it "does not modify absolute URL" do
+ doc = filter(link("http://example.com"))
+ expect(doc.at_css("a")["href"]).to eq "http://example.com"
end
- it 'supports unescaped Unicode filenames' do
- path = '/uploads/한글.png'
+ it "supports unescaped Unicode filenames" do
+ path = "/uploads/한글.png"
doc = filter(link(path))
- expect(doc.at_css('a')['href']).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png")
+ expect(doc.at_css("a")["href"]).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png")
end
- it 'supports escaped Unicode filenames' do
- path = '/uploads/한글.png'
+ it "supports escaped Unicode filenames" do
+ path = "/uploads/한글.png"
escaped = Addressable::URI.escape(path)
doc = filter(image(escaped))
- expect(doc.at_css('img')['src']).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png")
+ expect(doc.at_css("img")["src"]).to eq("/#{project.full_path}/uploads/%ED%95%9C%EA%B8%80.png")
end
end
- context 'to a group upload' do
- let(:upload_link) { link('/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg') }
+ context "to a group upload" do
+ let(:upload_link) { link("/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg") }
let(:group) { create(:group) }
let(:project) { nil }
let(:relative_path) { "/groups/#{group.full_path}/-/uploads/e90decf88d8f96fe9e1389afc2e4a91f/test.jpg" }
- context 'with an absolute URL' do
+ context "with an absolute URL" do
let(:absolute_path) { Gitlab.config.gitlab.url + relative_path }
let(:only_path) { false }
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(upload_link)
- expect(doc.at_css('a')['href']).to eq(absolute_path)
+ expect(doc.at_css("a")["href"]).to eq(absolute_path)
end
end
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(upload_link)
- expect(doc.at_css('a')['href']).to eq(relative_path)
+ expect(doc.at_css("a")["href"]).to eq(relative_path)
end
- it 'rewrites the link correctly for subgroup' do
+ it "rewrites the link correctly for subgroup" do
group.update!(parent: create(:group))
doc = filter(upload_link)
- expect(doc.at_css('a')['href']).to eq(relative_path)
+ expect(doc.at_css("a")["href"]).to eq(relative_path)
end
- it 'does not modify absolute URL' do
- doc = filter(link('http://example.com'))
+ it "does not modify absolute URL" do
+ doc = filter(link("http://example.com"))
- expect(doc.at_css('a')['href']).to eq 'http://example.com'
+ expect(doc.at_css("a")["href"]).to eq "http://example.com"
end
end
- context 'to a personal snippet' do
+ context "to a personal snippet" do
let(:group) { nil }
let(:project) { nil }
- let(:relative_path) { '/uploads/-/system/personal_snippet/6/674e4f07fbf0a7736c3439212896e51a/example.tar.gz' }
+ let(:relative_path) { "/uploads/-/system/personal_snippet/6/674e4f07fbf0a7736c3439212896e51a/example.tar.gz" }
- context 'with an absolute URL' do
+ context "with an absolute URL" do
let(:absolute_path) { Gitlab.config.gitlab.url + relative_path }
let(:only_path) { false }
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(link(relative_path))
- expect(doc.at_css('a')['href']).to eq(absolute_path)
+ expect(doc.at_css("a")["href"]).to eq(absolute_path)
end
end
- context 'with a relative URL root' do
- let(:gitlab_root) { '/gitlab' }
+ context "with a relative URL root" do
+ let(:gitlab_root) { "/gitlab" }
let(:absolute_path) { Gitlab.config.gitlab.url + gitlab_root + relative_path }
before do
stub_config_setting(relative_url_root: gitlab_root)
end
- context 'with an absolute URL' do
+ context "with an absolute URL" do
let(:only_path) { false }
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(link(relative_path))
- expect(doc.at_css('a')['href']).to eq(absolute_path)
+ expect(doc.at_css("a")["href"]).to eq(absolute_path)
end
end
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(link(relative_path))
- expect(doc.at_css('a')['href']).to eq(gitlab_root + relative_path)
+ expect(doc.at_css("a")["href"]).to eq(gitlab_root + relative_path)
end
end
- it 'rewrites the link correctly' do
+ it "rewrites the link correctly" do
doc = filter(link(relative_path))
- expect(doc.at_css('a')['href']).to eq(relative_path)
+ expect(doc.at_css("a")["href"]).to eq(relative_path)
end
- it 'does not modify absolute URL' do
- doc = filter(link('http://example.com'))
+ it "does not modify absolute URL" do
+ doc = filter(link("http://example.com"))
- expect(doc.at_css('a')['href']).to eq 'http://example.com'
+ expect(doc.at_css("a")["href"]).to eq "http://example.com"
end
end
end
diff --git a/spec/lib/banzai/filter/sanitization_filter_spec.rb b/spec/lib/banzai/filter/sanitization_filter_spec.rb
index f2a5d7b2c9f..ddaa0c6446e 100644
--- a/spec/lib/banzai/filter/sanitization_filter_spec.rb
+++ b/spec/lib/banzai/filter/sanitization_filter_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::SanitizationFilter do
include FilterSpecHelper
- describe 'default whitelist' do
- it 'sanitizes tags that are not whitelisted' do
- act = %q{<textarea>no inputs</textarea> and <blink>no blinks</blink>}
- exp = 'no inputs and no blinks'
+ describe "default whitelist" do
+ it "sanitizes tags that are not whitelisted" do
+ act = "<textarea>no inputs</textarea> and <blink>no blinks</blink>"
+ exp = "no inputs and no blinks"
expect(filter(act).to_html).to eq exp
end
- it 'sanitizes tag attributes' do
- act = %q{<a href="http://example.com/bar.html" onclick="bar">Text</a>}
- exp = %q{<a href="http://example.com/bar.html">Text</a>}
+ it "sanitizes tag attributes" do
+ act = '<a href="http://example.com/bar.html" onclick="bar">Text</a>'
+ exp = '<a href="http://example.com/bar.html">Text</a>'
expect(filter(act).to_html).to eq exp
end
- it 'sanitizes javascript in attributes' do
+ it "sanitizes javascript in attributes" do
act = %q(<a href="javascript:alert('foo')">Text</a>)
- exp = '<a>Text</a>'
+ exp = "<a>Text</a>"
expect(filter(act).to_html).to eq exp
end
- it 'sanitizes mixed-cased javascript in attributes' do
+ it "sanitizes mixed-cased javascript in attributes" do
act = %q(<a href="javaScript:alert('foo')">Text</a>)
- exp = '<a>Text</a>'
+ exp = "<a>Text</a>"
expect(filter(act).to_html).to eq exp
end
- it 'allows whitelisted HTML tags from the user' do
+ it "allows whitelisted HTML tags from the user" do
exp = act = "<dl>\n<dt>Term</dt>\n<dd>Definition</dd>\n</dl>"
expect(filter(act).to_html).to eq exp
end
- it 'sanitizes `class` attribute on any element' do
- act = %q{<strong class="foo">Strong</strong>}
- expect(filter(act).to_html).to eq %q{<strong>Strong</strong>}
+ it "sanitizes `class` attribute on any element" do
+ act = '<strong class="foo">Strong</strong>'
+ expect(filter(act).to_html).to eq "<strong>Strong</strong>"
end
- it 'sanitizes `id` attribute on any element' do
- act = %q{<em id="foo">Emphasis</em>}
- expect(filter(act).to_html).to eq %q{<em>Emphasis</em>}
+ it "sanitizes `id` attribute on any element" do
+ act = '<em id="foo">Emphasis</em>'
+ expect(filter(act).to_html).to eq "<em>Emphasis</em>"
end
end
- describe 'custom whitelist' do
- it 'customizes the whitelist only once' do
- instance = described_class.new('Foo')
+ describe "custom whitelist" do
+ it "customizes the whitelist only once" do
+ instance = described_class.new("Foo")
control_count = instance.whitelist[:transformers].size
3.times { instance.whitelist }
@@ -54,9 +54,9 @@ describe Banzai::Filter::SanitizationFilter do
expect(instance.whitelist[:transformers].size).to eq control_count
end
- it 'customizes the whitelist only once for different instances' do
- instance1 = described_class.new('Foo1')
- instance2 = described_class.new('Foo2')
+ it "customizes the whitelist only once for different instances" do
+ instance1 = described_class.new("Foo1")
+ instance2 = described_class.new("Foo2")
control_count = instance1.whitelist[:transformers].size
instance1.whitelist
@@ -66,32 +66,32 @@ describe Banzai::Filter::SanitizationFilter do
expect(instance2.whitelist[:transformers].size).to eq control_count
end
- it 'sanitizes `class` attribute from all elements' do
- act = %q{<pre class="code highlight white c"><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>}
- exp = %q{<pre><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>}
+ it "sanitizes `class` attribute from all elements" do
+ act = '<pre class="code highlight white c"><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>'
+ exp = '<pre><code>&lt;span class="k"&gt;def&lt;/span&gt;</code></pre>'
expect(filter(act).to_html).to eq exp
end
- it 'sanitizes `class` attribute from non-highlight spans' do
- act = %q{<span class="k">def</span>}
- expect(filter(act).to_html).to eq %q{<span>def</span>}
+ it "sanitizes `class` attribute from non-highlight spans" do
+ act = '<span class="k">def</span>'
+ expect(filter(act).to_html).to eq "<span>def</span>"
end
- it 'allows `text-align` property in `style` attribute on table elements' do
+ it "allows `text-align` property in `style` attribute on table elements" do
html = <<~HTML
- <table>
- <tr><th style="text-align: center">Head</th></tr>
- <tr><td style="text-align: right">Body</th></tr>
- </table>
+ <table>
+ <tr><th style="text-align: center">Head</th></tr>
+ <tr><td style="text-align: right">Body</th></tr>
+ </table>
HTML
doc = filter(html)
- expect(doc.at_css('th')['style']).to eq 'text-align: center'
- expect(doc.at_css('td')['style']).to eq 'text-align: right'
+ expect(doc.at_css("th")["style"]).to eq "text-align: center"
+ expect(doc.at_css("td")["style"]).to eq "text-align: right"
end
- it 'disallows other properties in `style` attribute on table elements' do
+ it "disallows other properties in `style` attribute on table elements" do
html = <<~HTML
<table>
<tr><th style="text-align: foo">Head</th></tr>
@@ -101,31 +101,31 @@ describe Banzai::Filter::SanitizationFilter do
doc = filter(html)
- expect(doc.at_css('th')['style']).to be_nil
- expect(doc.at_css('td')['style']).to eq 'text-align: center'
+ expect(doc.at_css("th")["style"]).to be_nil
+ expect(doc.at_css("td")["style"]).to eq "text-align: center"
end
- it 'disallows `text-align` property in `style` attribute on other elements' do
+ it "disallows `text-align` property in `style` attribute on other elements" do
html = <<~HTML
<div style="text-align: center">Text</div>
HTML
doc = filter(html)
- expect(doc.at_css('div')['style']).to be_nil
+ expect(doc.at_css("div")["style"]).to be_nil
end
- it 'allows `span` elements' do
- exp = act = %q{<span>Hello</span>}
+ it "allows `span` elements" do
+ exp = act = "<span>Hello</span>"
expect(filter(act).to_html).to eq exp
end
- it 'allows `abbr` elements' do
- exp = act = %q{<abbr title="HyperText Markup Language">HTML</abbr>}
+ it "allows `abbr` elements" do
+ exp = act = '<abbr title="HyperText Markup Language">HTML</abbr>'
expect(filter(act).to_html).to eq exp
end
- it 'disallows the `name` attribute globally, allows on `a`' do
+ it "disallows the `name` attribute globally, allows on `a`" do
html = <<~HTML
<img name="getElementById" src="">
<span name="foo" class="bar">Hi</span>
@@ -134,22 +134,22 @@ describe Banzai::Filter::SanitizationFilter do
doc = filter(html)
- expect(doc.at_css('img')).not_to have_attribute('name')
- expect(doc.at_css('span')).not_to have_attribute('name')
- expect(doc.at_css('a')).to have_attribute('name')
+ expect(doc.at_css("img")).not_to have_attribute("name")
+ expect(doc.at_css("span")).not_to have_attribute("name")
+ expect(doc.at_css("a")).to have_attribute("name")
end
- it 'allows `summary` elements' do
- exp = act = '<summary>summary line</summary>'
+ it "allows `summary` elements" do
+ exp = act = "<summary>summary line</summary>"
expect(filter(act).to_html).to eq exp
end
- it 'allows `details` elements' do
- exp = act = '<details>long text goes here</details>'
+ it "allows `details` elements" do
+ exp = act = "<details>long text goes here</details>"
expect(filter(act).to_html).to eq exp
end
- it 'allows `data-math-style` attribute on `code` and `pre` elements' do
+ it "allows `data-math-style` attribute on `code` and `pre` elements" do
html = <<-HTML
<pre class="code" data-math-style="inline">something</pre>
<code class="code" data-math-style="inline">something</code>
@@ -165,94 +165,94 @@ describe Banzai::Filter::SanitizationFilter do
expect(filter(html).to_html).to eq(output)
end
- it 'removes `rel` attribute from `a` elements' do
- act = %q{<a href="#" rel="nofollow">Link</a>}
- exp = %q{<a href="#">Link</a>}
+ it "removes `rel` attribute from `a` elements" do
+ act = '<a href="#" rel="nofollow">Link</a>'
+ exp = '<a href="#">Link</a>'
expect(filter(act).to_html).to eq exp
end
# Adapted from the Sanitize test suite: http://git.io/vczrM
protocols = {
- 'protocol-based JS injection: simple, no spaces' => {
- input: '<a href="javascript:alert(\'XSS\');">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: simple, no spaces" => {
+ input: '<a href="javascript:alert(\'XSS\');">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: simple, spaces before' => {
- input: '<a href="javascript :alert(\'XSS\');">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: simple, spaces before" => {
+ input: '<a href="javascript :alert(\'XSS\');">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: simple, spaces after' => {
- input: '<a href="javascript: alert(\'XSS\');">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: simple, spaces after" => {
+ input: '<a href="javascript: alert(\'XSS\');">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: simple, spaces before and after' => {
- input: '<a href="javascript : alert(\'XSS\');">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: simple, spaces before and after" => {
+ input: '<a href="javascript : alert(\'XSS\');">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: preceding colon' => {
- input: '<a href=":javascript:alert(\'XSS\');">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: preceding colon" => {
+ input: '<a href=":javascript:alert(\'XSS\');">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: UTF-8 encoding' => {
- input: '<a href="javascript&#58;">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: UTF-8 encoding" => {
+ input: '<a href="javascript&#58;">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: long UTF-8 encoding' => {
- input: '<a href="javascript&#0058;">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: long UTF-8 encoding" => {
+ input: '<a href="javascript&#0058;">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: long UTF-8 encoding without semicolons' => {
- input: '<a href=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: long UTF-8 encoding without semicolons" => {
+ input: "<a href=&#0000106&#0000097&#0000118&#0000097&#0000115&#0000099&#0000114&#0000105&#0000112&#0000116&#0000058&#0000097&#0000108&#0000101&#0000114&#0000116&#0000040&#0000039&#0000088&#0000083&#0000083&#0000039&#0000041>foo</a>",
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: hex encoding' => {
- input: '<a href="javascript&#x3A;">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: hex encoding" => {
+ input: '<a href="javascript&#x3A;">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: long hex encoding' => {
- input: '<a href="javascript&#x003A;">foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: long hex encoding" => {
+ input: '<a href="javascript&#x003A;">foo</a>',
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: hex encoding without semicolons' => {
- input: '<a href=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>foo</a>',
- output: '<a>foo</a>'
+ "protocol-based JS injection: hex encoding without semicolons" => {
+ input: "<a href=&#x6A&#x61&#x76&#x61&#x73&#x63&#x72&#x69&#x70&#x74&#x3A&#x61&#x6C&#x65&#x72&#x74&#x28&#x27&#x58&#x53&#x53&#x27&#x29>foo</a>",
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: null char' => {
- input: "<a href=java\0script:alert(\"XSS\")>foo</a>",
- output: '<a href="java"></a>'
+ "protocol-based JS injection: null char" => {
+ input: "<a href=java\0script:alert(\"XSS\")>foo</a>",
+ output: '<a href="java"></a>',
},
- 'protocol-based JS injection: invalid URL char' => {
+ "protocol-based JS injection: invalid URL char" => {
input: '<img src=java\script:alert("XSS")>',
- output: '<img>'
+ output: "<img>",
},
- 'protocol-based JS injection: Unicode' => {
- input: %Q(<a href="\u0001java\u0003script:alert('XSS')">foo</a>),
- output: '<a>foo</a>'
+ "protocol-based JS injection: Unicode" => {
+ input: %(<a href="\u0001java\u0003script:alert('XSS')">foo</a>),
+ output: "<a>foo</a>",
},
- 'protocol-based JS injection: spaces and entities' => {
- input: '<a href=" &#14; javascript:alert(\'XSS\');">foo</a>',
- output: '<a href="">foo</a>'
+ "protocol-based JS injection: spaces and entities" => {
+ input: '<a href=" &#14; javascript:alert(\'XSS\');">foo</a>',
+ output: '<a href="">foo</a>',
},
- 'protocol whitespace' => {
+ "protocol whitespace" => {
input: '<a href=" http://example.com/"></a>',
- output: '<a href="http://example.com/"></a>'
- }
+ output: '<a href="http://example.com/"></a>',
+ },
}
protocols.each do |name, data|
@@ -263,88 +263,88 @@ describe Banzai::Filter::SanitizationFilter do
end
end
- it 'disallows data links' do
+ it "disallows data links" do
input = '<a href="data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4K">XSS</a>'
output = filter(input)
- expect(output.to_html).to eq '<a>XSS</a>'
+ expect(output.to_html).to eq "<a>XSS</a>"
end
- it 'disallows vbscript links' do
+ it "disallows vbscript links" do
input = '<a href="vbscript:alert(document.domain)">XSS</a>'
output = filter(input)
- expect(output.to_html).to eq '<a>XSS</a>'
+ expect(output.to_html).to eq "<a>XSS</a>"
end
- it 'disallows invalid URIs' do
- expect(Addressable::URI).to receive(:parse).with('foo://example.com')
+ it "disallows invalid URIs" do
+ expect(Addressable::URI).to receive(:parse).with("foo://example.com")
.and_raise(Addressable::URI::InvalidURIError)
input = '<a href="foo://example.com">Foo</a>'
output = filter(input)
- expect(output.to_html).to eq '<a>Foo</a>'
+ expect(output.to_html).to eq "<a>Foo</a>"
end
- it 'allows non-standard anchor schemes' do
- exp = %q{<a href="irc://irc.freenode.net/git">IRC</a>}
+ it "allows non-standard anchor schemes" do
+ exp = '<a href="irc://irc.freenode.net/git">IRC</a>'
act = filter(exp)
expect(act.to_html).to eq exp
end
- it 'allows relative links' do
- exp = %q{<a href="foo/bar.md">foo/bar.md</a>}
+ it "allows relative links" do
+ exp = '<a href="foo/bar.md">foo/bar.md</a>'
act = filter(exp)
expect(act.to_html).to eq exp
end
- it 'allows the `data-sourcepos` attribute globally' do
- exp = %q{<p data-sourcepos="1:1-1:10">foo/bar.md</p>}
+ it "allows the `data-sourcepos` attribute globally" do
+ exp = '<p data-sourcepos="1:1-1:10">foo/bar.md</p>'
act = filter(exp)
expect(act.to_html).to eq exp
end
- describe 'footnotes' do
- it 'allows correct footnote id property on links' do
- exp = %q{<a href="#fn1" id="fnref1">foo/bar.md</a>}
+ describe "footnotes" do
+ it "allows correct footnote id property on links" do
+ exp = '<a href="#fn1" id="fnref1">foo/bar.md</a>'
act = filter(exp)
expect(act.to_html).to eq exp
end
- it 'allows correct footnote id property on li element' do
- exp = %q{<ol><li id="fn1">footnote</li></ol>}
+ it "allows correct footnote id property on li element" do
+ exp = '<ol><li id="fn1">footnote</li></ol>'
act = filter(exp)
expect(act.to_html).to eq exp
end
- it 'removes invalid id for footnote links' do
- exp = %q{<a href="#fn1">link</a>}
+ it "removes invalid id for footnote links" do
+ exp = '<a href="#fn1">link</a>'
%w[fnrefx test xfnref1].each do |id|
- act = filter(%Q{<a href="#fn1" id="#{id}">link</a>})
+ act = filter(%(<a href="#fn1" id="#{id}">link</a>))
expect(act.to_html).to eq exp
end
end
- it 'removes invalid id for footnote li' do
- exp = %q{<ol><li>footnote</li></ol>}
+ it "removes invalid id for footnote li" do
+ exp = "<ol><li>footnote</li></ol>"
%w[fnx test xfn1].each do |id|
- act = filter(%Q{<ol><li id="#{id}">footnote</li></ol>})
+ act = filter(%(<ol><li id="#{id}">footnote</li></ol>))
expect(act.to_html).to eq exp
end
end
- it 'allows footnotes numbered higher than 9' do
- exp = %q{<a href="#fn15" id="fnref15">link</a><ol><li id="fn15">footnote</li></ol>}
+ it "allows footnotes numbered higher than 9" do
+ exp = '<a href="#fn15" id="fnref15">link</a><ol><li id="fn15">footnote</li></ol>'
act = filter(exp)
expect(act.to_html).to eq exp
diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb
index 21cf092428d..86fec7a5efd 100644
--- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::SnippetReferenceFilter do
include FilterSpecHelper
@@ -7,211 +7,211 @@ describe Banzai::Filter::SnippetReferenceFilter do
let(:snippet) { create(:project_snippet, project: project) }
let(:reference) { snippet.to_reference }
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Snippet #{reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'internal reference' do
- it 'links to a valid reference' do
+ context "internal reference" do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls
+ expect(doc.css("a").first.attr("href")).to eq urls
.project_snippet_url(project, snippet)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Snippet (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(reference)}</a>\.\)})
end
- it 'ignores invalid snippet IDs' do
+ it "ignores invalid snippet IDs" do
exp = act = "Snippet #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
- it 'includes a title attribute' do
+ it "includes a title attribute" do
doc = reference_filter("Snippet #{reference}")
- expect(doc.css('a').first.attr('title')).to eq snippet.title
+ expect(doc.css("a").first.attr("title")).to eq snippet.title
end
- it 'escapes the title attribute' do
- snippet.update_attribute(:title, %{"></a>whatever<a title="})
+ it "escapes the title attribute" do
+ snippet.update_attribute(:title, %("></a>whatever<a title="))
doc = reference_filter("Snippet #{reference}")
expect(doc.text).to eq "Snippet #{reference}"
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Snippet #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-snippet has-tooltip'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-snippet has-tooltip"
end
- it 'includes a data-project attribute' do
+ it "includes a data-project attribute" do
doc = reference_filter("Snippet #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-project')
- expect(link.attr('data-project')).to eq project.id.to_s
+ expect(link).to have_attribute("data-project")
+ expect(link.attr("data-project")).to eq project.id.to_s
end
- it 'includes a data-snippet attribute' do
+ it "includes a data-snippet attribute" do
doc = reference_filter("See #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-snippet')
- expect(link.attr('data-snippet')).to eq snippet.id.to_s
+ expect(link).to have_attribute("data-snippet")
+ expect(link.attr("data-snippet")).to eq snippet.id.to_s
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Snippet #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.project_snippet_url(project, snippet, only_path: true)
end
end
- context 'cross-project / cross-namespace complete reference' do
+ context "cross-project / cross-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project2) { create(:project, :public, namespace: namespace) }
let!(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { "#{project2.full_path}$#{snippet.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_snippet_url(project2, snippet)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{reference}.)")
- expect(doc.css('a').first.text).to eql(reference)
+ expect(doc.css("a").first.text).to eql(reference)
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.text).to eql("See (#{reference}.)")
end
- it 'ignores invalid snippet IDs on the referenced project' do
+ it "ignores invalid snippet IDs on the referenced project" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project / same-namespace complete reference' do
+ context "cross-project / same-namespace complete reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) }
let!(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { "#{project2.full_path}$#{snippet.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_snippet_url(project2, snippet)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{project2.path}$#{snippet.id}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}$#{snippet.id}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}$#{snippet.id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{project2.path}$#{snippet.id}.)")
expect(doc.text).to eql("See (#{project2.path}$#{snippet.id}.)")
end
- it 'ignores invalid snippet IDs on the referenced project' do
+ it "ignores invalid snippet IDs on the referenced project" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project shorthand reference' do
+ context "cross-project shorthand reference" do
let(:namespace) { create(:namespace) }
let(:project) { create(:project, :public, namespace: namespace) }
let(:project2) { create(:project, :public, namespace: namespace) }
let!(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { "#{project2.path}$#{snippet.id}" }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_snippet_url(project2, snippet)
end
- it 'link has valid text' do
+ it "link has valid text" do
doc = reference_filter("See (#{project2.path}$#{snippet.id}.)")
- expect(doc.css('a').first.text).to eql("#{project2.path}$#{snippet.id}")
+ expect(doc.css("a").first.text).to eql("#{project2.path}$#{snippet.id}")
end
- it 'has valid text' do
+ it "has valid text" do
doc = reference_filter("See (#{project2.path}$#{snippet.id}.)")
expect(doc.text).to eql("See (#{project2.path}$#{snippet.id}.)")
end
- it 'ignores invalid snippet IDs on the referenced project' do
+ it "ignores invalid snippet IDs on the referenced project" do
exp = act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'cross-project URL reference' do
- let(:namespace) { create(:namespace, name: 'cross-reference') }
+ context "cross-project URL reference" do
+ let(:namespace) { create(:namespace, name: "cross-reference") }
let(:project2) { create(:project, :public, namespace: namespace) }
let(:snippet) { create(:project_snippet, project: project2) }
let(:reference) { urls.project_snippet_url(project2, snippet) }
- it 'links to a valid reference' do
+ it "links to a valid reference" do
doc = reference_filter("See #{reference}")
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_snippet_url(project2, snippet)
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("See (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{Regexp.escape(snippet.to_reference(project))}</a>\.\)})
end
- it 'ignores invalid snippet IDs on the referenced project' do
+ it "ignores invalid snippet IDs on the referenced project" do
act = "See #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to match(%r{<a.+>#{Regexp.escape(invalidate_reference(reference))}</a>})
end
end
- context 'group context' do
- it 'links to a valid reference' do
+ context "group context" do
+ it "links to a valid reference" do
reference = "#{project.full_path}$#{snippet.id}"
- result = reference_filter("See #{reference}", { project: nil, group: create(:group) } )
+ result = reference_filter("See #{reference}", {project: nil, group: create(:group)})
- expect(result.css('a').first.attr('href')).to eq(urls.project_snippet_url(project, snippet))
+ expect(result.css("a").first.attr("href")).to eq(urls.project_snippet_url(project, snippet))
end
- it 'ignores internal references' do
+ it "ignores internal references" do
exp = act = "See $#{snippet.id}"
expect(reference_filter(act, project: nil, group: create(:group)).to_html).to eq exp
diff --git a/spec/lib/banzai/filter/spaced_link_filter_spec.rb b/spec/lib/banzai/filter/spaced_link_filter_spec.rb
index 76d7644d76c..c81e5dd5360 100644
--- a/spec/lib/banzai/filter/spaced_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/spaced_link_filter_spec.rb
@@ -1,84 +1,84 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::SpacedLinkFilter do
include FilterSpecHelper
- let(:link) { '[example](page slug)' }
- let(:image) { '![example](img test.jpg)' }
+ let(:link) { "[example](page slug)" }
+ let(:image) { "![example](img test.jpg)" }
- context 'when a link is detected' do
- it 'converts slug with spaces to a link' do
+ context "when a link is detected" do
+ it "converts slug with spaces to a link" do
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq 'example'
- expect(doc.at_css('a')['href']).to eq 'page%20slug'
- expect(doc.at_css('a')['title']).to be_nil
- expect(doc.at_css('p')).to be_nil
+ expect(doc.at_css("a").text).to eq "example"
+ expect(doc.at_css("a")["href"]).to eq "page%20slug"
+ expect(doc.at_css("a")["title"]).to be_nil
+ expect(doc.at_css("p")).to be_nil
end
- it 'converts slug with spaces and a title to a link' do
+ it "converts slug with spaces and a title to a link" do
link = '[example](page slug "title")'
doc = filter("See #{link}")
- expect(doc.at_css('a').text).to eq 'example'
- expect(doc.at_css('a')['href']).to eq 'page%20slug'
- expect(doc.at_css('a')['title']).to eq 'title'
- expect(doc.at_css('p')).to be_nil
+ expect(doc.at_css("a").text).to eq "example"
+ expect(doc.at_css("a")["href"]).to eq "page%20slug"
+ expect(doc.at_css("a")["title"]).to eq "title"
+ expect(doc.at_css("p")).to be_nil
end
- it 'does nothing with empty text' do
- link = '[](page slug)'
+ it "does nothing with empty text" do
+ link = "[](page slug)"
doc = filter("See #{link}")
- expect(doc.at_css('a')).to be_nil
+ expect(doc.at_css("a")).to be_nil
end
- it 'does nothing with an empty slug' do
- link = '[example]()'
+ it "does nothing with an empty slug" do
+ link = "[example]()"
doc = filter("See #{link}")
- expect(doc.at_css('a')).to be_nil
+ expect(doc.at_css("a")).to be_nil
end
end
- context 'when an image is detected' do
- it 'converts slug with spaces to an iamge' do
+ context "when an image is detected" do
+ it "converts slug with spaces to an iamge" do
doc = filter("See #{image}")
- expect(doc.at_css('img')['src']).to eq 'img%20test.jpg'
- expect(doc.at_css('img')['alt']).to eq 'example'
- expect(doc.at_css('p')).to be_nil
+ expect(doc.at_css("img")["src"]).to eq "img%20test.jpg"
+ expect(doc.at_css("img")["alt"]).to eq "example"
+ expect(doc.at_css("p")).to be_nil
end
- it 'converts slug with spaces and a title to an image' do
+ it "converts slug with spaces and a title to an image" do
image = '![example](img test.jpg "title")'
doc = filter("See #{image}")
- expect(doc.at_css('img')['src']).to eq 'img%20test.jpg'
- expect(doc.at_css('img')['alt']).to eq 'example'
- expect(doc.at_css('img')['title']).to eq 'title'
- expect(doc.at_css('p')).to be_nil
+ expect(doc.at_css("img")["src"]).to eq "img%20test.jpg"
+ expect(doc.at_css("img")["alt"]).to eq "example"
+ expect(doc.at_css("img")["title"]).to eq "title"
+ expect(doc.at_css("p")).to be_nil
end
end
- it 'converts multiple URLs' do
- link1 = '[first](slug one)'
- link2 = '[second](http://example.com/slug two)'
+ it "converts multiple URLs" do
+ link1 = "[first](slug one)"
+ link2 = "[second](http://example.com/slug two)"
doc = filter("See #{link1} and #{image} and #{link2}")
- found_links = doc.css('a')
+ found_links = doc.css("a")
expect(found_links.size).to eq(2)
- expect(found_links[0].text).to eq 'first'
- expect(found_links[0]['href']).to eq 'slug%20one'
- expect(found_links[1].text).to eq 'second'
- expect(found_links[1]['href']).to eq 'http://example.com/slug%20two'
+ expect(found_links[0].text).to eq "first"
+ expect(found_links[0]["href"]).to eq "slug%20one"
+ expect(found_links[1].text).to eq "second"
+ expect(found_links[1]["href"]).to eq "http://example.com/slug%20two"
- found_images = doc.css('img')
+ found_images = doc.css("img")
expect(found_images.size).to eq(1)
- expect(found_images[0]['src']).to eq 'img%20test.jpg'
- expect(found_images[0]['alt']).to eq 'example'
+ expect(found_images[0]["src"]).to eq "img%20test.jpg"
+ expect(found_images[0]["alt"]).to eq "example"
end
described_class::IGNORE_PARENTS.each do |elem|
diff --git a/spec/lib/banzai/filter/suggestion_filter_spec.rb b/spec/lib/banzai/filter/suggestion_filter_spec.rb
index b13c90b54bd..416171c0025 100644
--- a/spec/lib/banzai/filter/suggestion_filter_spec.rb
+++ b/spec/lib/banzai/filter/suggestion_filter_spec.rb
@@ -1,25 +1,25 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::SuggestionFilter do
include FilterSpecHelper
let(:input) { "<pre class='code highlight js-syntax-highlight suggestion'><code>foo\n</code></pre>" }
let(:default_context) do
- { suggestions_filter_enabled: true }
+ {suggestions_filter_enabled: true}
end
- it 'includes `js-render-suggestion` class' do
+ it "includes `js-render-suggestion` class" do
doc = filter(input, default_context)
- result = doc.css('code').first
+ result = doc.css("code").first
- expect(result[:class]).to include('js-render-suggestion')
+ expect(result[:class]).to include("js-render-suggestion")
end
- it 'includes no `js-render-suggestion` when filter is disabled' do
+ it "includes no `js-render-suggestion` when filter is disabled" do
doc = filter(input)
- result = doc.css('code').first
+ result = doc.css("code").first
expect(result[:class]).to be_nil
end
diff --git a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb
index ef52c572898..c9d41c460c1 100644
--- a/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb
+++ b/spec/lib/banzai/filter/syntax_highlight_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::SyntaxHighlightFilter do
include FilterSpecHelper
@@ -16,7 +16,7 @@ describe Banzai::Filter::SyntaxHighlightFilter do
context "when no language is specified" do
it "highlights as plaintext" do
- result = filter('<pre><code>def fun end</code></pre>')
+ result = filter("<pre><code>def fun end</code></pre>")
expect(result.to_html).to eq('<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">def fun end</span></code></pre>')
end
@@ -45,12 +45,12 @@ describe Banzai::Filter::SyntaxHighlightFilter do
end
context "languages that should be passed through" do
- %w(math mermaid plantuml).each do |lang|
+ %w[math mermaid plantuml].each do |lang|
context "when #{lang} is specified" do
it "highlights as plaintext but with the correct language attribute and class" do
- result = filter(%{<pre><code lang="#{lang}">This is a test</code></pre>})
+ result = filter(%(<pre><code lang="#{lang}">This is a test</code></pre>))
- expect(result.to_html).to eq(%{<pre class="code highlight js-syntax-highlight #{lang}" lang="#{lang}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre>})
+ expect(result.to_html).to eq(%(<pre class="code highlight js-syntax-highlight #{lang}" lang="#{lang}" v-pre="true"><code><span id="LC1" class="line" lang="#{lang}">This is a test</span></code></pre>))
end
include_examples "XSS prevention", lang
@@ -78,9 +78,9 @@ describe Banzai::Filter::SyntaxHighlightFilter do
end
it "does not add highlighting classes" do
- result = filter('<pre><code>This is a test</code></pre>')
+ result = filter("<pre><code>This is a test</code></pre>")
- expect(result.to_html).to eq('<pre><code>This is a test</code></pre>')
+ expect(result.to_html).to eq("<pre><code>This is a test</code></pre>")
end
include_examples "XSS prevention", "ruby"
diff --git a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
index 7213cd58ea7..2b20bb99dee 100644
--- a/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
+++ b/spec/lib/banzai/filter/table_of_contents_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::TableOfContentsFilter do
include FilterSpecHelper
@@ -7,12 +7,12 @@ describe Banzai::Filter::TableOfContentsFilter do
"<h#{level}>#{text}</h#{level}>\n"
end
- it 'does nothing when :no_header_anchors is truthy' do
- exp = act = header(1, 'Header')
+ it "does nothing when :no_header_anchors is truthy" do
+ exp = act = header(1, "Header")
expect(filter(act, no_header_anchors: 1).to_html).to eq exp
end
- it 'does nothing with empty headers' do
+ it "does nothing with empty headers" do
exp = act = header(1, nil)
expect(filter(act).to_html).to eq exp
end
@@ -22,105 +22,105 @@ describe Banzai::Filter::TableOfContentsFilter do
html = header(i, "Header #{i}")
doc = filter(html)
- expect(doc.css("h#{i} a").first.attr('id')).to eq "user-content-header-#{i}"
+ expect(doc.css("h#{i} a").first.attr("id")).to eq "user-content-header-#{i}"
end
end
- describe 'anchor tag' do
- it 'has an `anchor` class' do
- doc = filter(header(1, 'Header'))
- expect(doc.css('h1 a').first.attr('class')).to eq 'anchor'
+ describe "anchor tag" do
+ it "has an `anchor` class" do
+ doc = filter(header(1, "Header"))
+ expect(doc.css("h1 a").first.attr("class")).to eq "anchor"
end
- it 'has a namespaced id' do
- doc = filter(header(1, 'Header'))
- expect(doc.css('h1 a').first.attr('id')).to eq 'user-content-header'
+ it "has a namespaced id" do
+ doc = filter(header(1, "Header"))
+ expect(doc.css("h1 a").first.attr("id")).to eq "user-content-header"
end
- it 'links to the non-namespaced id' do
- doc = filter(header(1, 'Header'))
- expect(doc.css('h1 a').first.attr('href')).to eq '#header'
+ it "links to the non-namespaced id" do
+ doc = filter(header(1, "Header"))
+ expect(doc.css("h1 a").first.attr("href")).to eq "#header"
end
- describe 'generated IDs' do
- it 'translates spaces to dashes' do
- doc = filter(header(1, 'This header has spaces in it'))
- expect(doc.css('h1 a').first.attr('href')).to eq '#this-header-has-spaces-in-it'
+ describe "generated IDs" do
+ it "translates spaces to dashes" do
+ doc = filter(header(1, "This header has spaces in it"))
+ expect(doc.css("h1 a").first.attr("href")).to eq "#this-header-has-spaces-in-it"
end
- it 'squeezes multiple spaces and dashes' do
- doc = filter(header(1, 'This---header is poorly-formatted'))
- expect(doc.css('h1 a').first.attr('href')).to eq '#this-header-is-poorly-formatted'
+ it "squeezes multiple spaces and dashes" do
+ doc = filter(header(1, "This---header is poorly-formatted"))
+ expect(doc.css("h1 a").first.attr("href")).to eq "#this-header-is-poorly-formatted"
end
- it 'removes punctuation' do
+ it "removes punctuation" do
doc = filter(header(1, "This, header! is, filled. with @ punctuation?"))
- expect(doc.css('h1 a').first.attr('href')).to eq '#this-header-is-filled-with-punctuation'
+ expect(doc.css("h1 a").first.attr("href")).to eq "#this-header-is-filled-with-punctuation"
end
- it 'appends a unique number to duplicates' do
- doc = filter(header(1, 'One') + header(2, 'One'))
+ it "appends a unique number to duplicates" do
+ doc = filter(header(1, "One") + header(2, "One"))
- expect(doc.css('h1 a').first.attr('href')).to eq '#one'
- expect(doc.css('h2 a').first.attr('href')).to eq '#one-1'
+ expect(doc.css("h1 a").first.attr("href")).to eq "#one"
+ expect(doc.css("h2 a").first.attr("href")).to eq "#one-1"
end
- it 'prepends a prefix to digits-only ids' do
+ it "prepends a prefix to digits-only ids" do
doc = filter(header(1, "123") + header(2, "1.0"))
- expect(doc.css('h1 a').first.attr('href')).to eq '#anchor-123'
- expect(doc.css('h2 a').first.attr('href')).to eq '#anchor-10'
+ expect(doc.css("h1 a").first.attr("href")).to eq "#anchor-123"
+ expect(doc.css("h2 a").first.attr("href")).to eq "#anchor-10"
end
- it 'supports Unicode' do
- doc = filter(header(1, '한글'))
- expect(doc.css('h1 a').first.attr('id')).to eq 'user-content-한글'
- expect(doc.css('h1 a').first.attr('href')).to eq '#한글'
+ it "supports Unicode" do
+ doc = filter(header(1, "한글"))
+ expect(doc.css("h1 a").first.attr("id")).to eq "user-content-한글"
+ expect(doc.css("h1 a").first.attr("href")).to eq "#한글"
end
end
end
- describe 'result' do
+ describe "result" do
def result(html)
HTML::Pipeline.new([described_class]).call(html)
end
- let(:results) { result(header(1, 'Header 1') + header(2, 'Header 2')) }
+ let(:results) { result(header(1, "Header 1") + header(2, "Header 2")) }
let(:doc) { Nokogiri::XML::DocumentFragment.parse(results[:toc]) }
- it 'is contained within a `ul` element' do
- expect(doc.children.first.name).to eq 'ul'
- expect(doc.children.first.attr('class')).to eq 'section-nav'
+ it "is contained within a `ul` element" do
+ expect(doc.children.first.name).to eq "ul"
+ expect(doc.children.first.attr("class")).to eq "section-nav"
end
- it 'contains an `li` element for each header' do
- expect(doc.css('li').length).to eq 2
+ it "contains an `li` element for each header" do
+ expect(doc.css("li").length).to eq 2
- links = doc.css('li a')
+ links = doc.css("li a")
- expect(links.first.attr('href')).to eq '#header-1'
- expect(links.first.text).to eq 'Header 1'
- expect(links.last.attr('href')).to eq '#header-2'
- expect(links.last.text).to eq 'Header 2'
+ expect(links.first.attr("href")).to eq "#header-1"
+ expect(links.first.text).to eq "Header 1"
+ expect(links.last.attr("href")).to eq "#header-2"
+ expect(links.last.text).to eq "Header 2"
end
- context 'table of contents nesting' do
+ context "table of contents nesting" do
let(:results) do
result(
- header(1, 'Header 1') <<
- header(2, 'Header 1-1') <<
- header(3, 'Header 1-1-1') <<
- header(2, 'Header 1-2') <<
- header(1, 'Header 2') <<
- header(2, 'Header 2-1')
+ header(1, "Header 1") <<
+ header(2, "Header 1-1") <<
+ header(3, "Header 1-1-1") <<
+ header(2, "Header 1-2") <<
+ header(1, "Header 2") <<
+ header(2, "Header 2-1")
)
end
- it 'keeps list levels regarding header levels' do
- items = doc.css('li')
+ it "keeps list levels regarding header levels" do
+ items = doc.css("li")
# Header 1
- expect(items[0].ancestors).to satisfy_none { |node| node.name == 'li' }
+ expect(items[0].ancestors).to satisfy_none { |node| node.name == "li" }
# Header 1-1
expect(items[1].ancestors).to include(items[0])
@@ -133,18 +133,18 @@ describe Banzai::Filter::TableOfContentsFilter do
expect(items[3].ancestors).not_to include(items[1])
# Header 2
- expect(items[4].ancestors).to satisfy_none { |node| node.name == 'li' }
+ expect(items[4].ancestors).to satisfy_none { |node| node.name == "li" }
# Header 2-1
expect(items[5].ancestors).to include(items[4])
end
end
- context 'header text contains escaped content' do
+ context "header text contains escaped content" do
let(:content) { '&lt;img src="x" onerror="alert(42)"&gt;' }
let(:results) { result(header(1, content)) }
- it 'outputs escaped content' do
+ it "outputs escaped content" do
expect(doc.inner_html).to include(content)
end
end
diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb
index 1e8a44b4549..8a153fd16b3 100644
--- a/spec/lib/banzai/filter/user_reference_filter_spec.rb
+++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::UserReferenceFilter do
include FilterSpecHelper
@@ -13,141 +13,141 @@ describe Banzai::Filter::UserReferenceFilter do
let(:subject_name) { "user" }
let(:reference) { get_reference(user) }
- it_behaves_like 'user reference or project reference'
+ it_behaves_like "user reference or project reference"
- it 'requires project context' do
- expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
+ it "requires project context" do
+ expect { described_class.call("") }.to raise_error(ArgumentError, /:project/)
end
- it 'ignores invalid users' do
+ it "ignores invalid users" do
exp = act = "Hey #{invalidate_reference(reference)}"
expect(reference_filter(act).to_html).to eq(exp)
end
- it 'ignores references with text before the @ sign' do
+ it "ignores references with text before the @ sign" do
exp = act = "Hey foo#{reference}"
expect(reference_filter(act).to_html).to eq(exp)
end
- %w(pre code a style).each do |elem|
+ %w[pre code a style].each do |elem|
it "ignores valid references contained inside '#{elem}' element" do
exp = act = "<#{elem}>Hey #{reference}</#{elem}>"
expect(reference_filter(act).to_html).to eq exp
end
end
- context 'mentioning @all' do
- it_behaves_like 'a reference containing an element node'
+ context "mentioning @all" do
+ it_behaves_like "a reference containing an element node"
- let(:reference) { User.reference_prefix + 'all' }
+ let(:reference) { User.reference_prefix + "all" }
before do
project.add_developer(project.creator)
end
- it 'supports a special @all mention' do
+ it "supports a special @all mention" do
project.add_developer(user)
doc = reference_filter("Hey #{reference}", author: user)
- expect(doc.css('a').length).to eq 1
- expect(doc.css('a').first.attr('href'))
+ expect(doc.css("a").length).to eq 1
+ expect(doc.css("a").first.attr("href"))
.to eq urls.project_url(project)
end
- it 'includes a data-author attribute when there is an author' do
+ it "includes a data-author attribute when there is an author" do
project.add_developer(user)
doc = reference_filter(reference, author: user)
- expect(doc.css('a').first.attr('data-author')).to eq(user.id.to_s)
+ expect(doc.css("a").first.attr("data-author")).to eq(user.id.to_s)
end
- it 'does not include a data-author attribute when there is no author' do
+ it "does not include a data-author attribute when there is no author" do
doc = reference_filter(reference)
- expect(doc.css('a').first.has_attribute?('data-author')).to eq(false)
+ expect(doc.css("a").first.has_attribute?("data-author")).to eq(false)
end
- it 'ignores reference to all when the user is not a project member' do
+ it "ignores reference to all when the user is not a project member" do
doc = reference_filter("Hey #{reference}", author: user)
- expect(doc.css('a').length).to eq 0
+ expect(doc.css("a").length).to eq 0
end
end
- context 'mentioning a group' do
- it_behaves_like 'a reference containing an element node'
+ context "mentioning a group" do
+ it_behaves_like "a reference containing an element node"
let(:group) { create(:group) }
let(:reference) { group.to_reference }
- it 'links to the Group' do
+ it "links to the Group" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.group_url(group)
+ expect(doc.css("a").first.attr("href")).to eq urls.group_url(group)
end
- it 'includes a data-group attribute' do
+ it "includes a data-group attribute" do
doc = reference_filter("Hey #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
- expect(link).to have_attribute('data-group')
- expect(link.attr('data-group')).to eq group.id.to_s
+ expect(link).to have_attribute("data-group")
+ expect(link.attr("data-group")).to eq group.id.to_s
end
end
- context 'mentioning a nested group' do
- it_behaves_like 'a reference containing an element node'
+ context "mentioning a nested group" do
+ it_behaves_like "a reference containing an element node"
let(:group) { create(:group, :nested) }
let(:reference) { group.to_reference }
- it 'links to the nested group' do
+ it "links to the nested group" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.group_url(group)
+ expect(doc.css("a").first.attr("href")).to eq urls.group_url(group)
end
- it 'has the full group name as a title' do
+ it "has the full group name as a title" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('title')).to eq group.full_name
+ expect(doc.css("a").first.attr("title")).to eq group.full_name
end
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Mention me (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>#{reference}</a>\.\)})
end
- it 'includes default classes' do
+ it "includes default classes" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('class')).to eq 'gfm gfm-project_member'
+ expect(doc.css("a").first.attr("class")).to eq "gfm gfm-project_member"
end
- context 'when a project is not specified' do
+ context "when a project is not specified" do
let(:project) { nil }
- it 'does not link a User' do
+ it "does not link a User" do
doc = reference_filter("Hey #{reference}")
- expect(doc).not_to include('a')
+ expect(doc).not_to include("a")
end
- context 'when skip_project_check set to true' do
- it 'links to a User' do
+ context "when skip_project_check set to true" do
+ it "links to a User" do
doc = reference_filter("Hey #{reference}", skip_project_check: true)
- expect(doc.css('a').first.attr('href')).to eq urls.user_url(user)
+ expect(doc.css("a").first.attr("href")).to eq urls.user_url(user)
end
- it 'does not link users using @all reference' do
+ it "does not link users using @all reference" do
doc = reference_filter("Hey #{User.reference_prefix}all", skip_project_check: true)
- expect(doc).not_to include('a')
+ expect(doc).not_to include("a")
end
end
end
- context 'in group context' do
+ context "in group context" do
let(:group) { create(:group) }
let(:group_member) { create(:user) }
@@ -155,43 +155,43 @@ describe Banzai::Filter::UserReferenceFilter do
group.add_developer(group_member)
end
- let(:context) { { author: group_member, project: nil, group: group } }
+ let(:context) { {author: group_member, project: nil, group: group} }
- it 'supports a special @all mention' do
- reference = User.reference_prefix + 'all'
+ it "supports a special @all mention" do
+ reference = User.reference_prefix + "all"
doc = reference_filter("Hey #{reference}", context)
- expect(doc.css('a').length).to eq(1)
- expect(doc.css('a').first.attr('href')).to eq urls.group_url(group)
+ expect(doc.css("a").length).to eq(1)
+ expect(doc.css("a").first.attr("href")).to eq urls.group_url(group)
end
- it 'supports mentioning a single user' do
+ it "supports mentioning a single user" do
reference = get_reference(group_member)
doc = reference_filter("Hey #{reference}", context)
- expect(doc.css('a').first.attr('href')).to eq urls.user_url(group_member)
+ expect(doc.css("a").first.attr("href")).to eq urls.user_url(group_member)
end
- it 'supports mentioning a group' do
+ it "supports mentioning a group" do
reference = group.to_reference
doc = reference_filter("Hey #{reference}", context)
- expect(doc.css('a').first.attr('href')).to eq urls.user_url(group)
+ expect(doc.css("a").first.attr("href")).to eq urls.user_url(group)
end
end
- describe '#namespaces' do
- it 'returns a Hash containing all Namespaces' do
+ describe "#namespaces" do
+ it "returns a Hash containing all Namespaces" do
document = Nokogiri::HTML.fragment("<p>#{get_reference(user)}</p>")
filter = described_class.new(document, project: project)
ns = user.namespace
- expect(filter.namespaces).to eq({ ns.path => ns })
+ expect(filter.namespaces).to eq({ns.path => ns})
end
end
- describe '#usernames' do
- it 'returns the usernames mentioned in a document' do
+ describe "#usernames" do
+ it "returns the usernames mentioned in a document" do
document = Nokogiri::HTML.fragment("<p>#{get_reference(user)}</p>")
filter = described_class.new(document, project: project)
diff --git a/spec/lib/banzai/filter/video_link_filter_spec.rb b/spec/lib/banzai/filter/video_link_filter_spec.rb
index 81dda0687f3..f179ed265a2 100644
--- a/spec/lib/banzai/filter/video_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/video_link_filter_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::VideoLinkFilter do
def filter(doc, contexts = {})
contexts.reverse_merge!({
- project: project
+ project: project,
})
described_class.call(doc, contexts)
@@ -15,36 +15,36 @@ describe Banzai::Filter::VideoLinkFilter do
let(:project) { create(:project, :repository) }
- context 'when the element src has a video extension' do
+ context "when the element src has a video extension" do
UploaderHelper::VIDEO_EXT.each do |ext|
it "replaces the image tag 'path/video.#{ext}' with a video tag" do
container = filter(link_to_image("/path/video.#{ext}")).children.first
- expect(container.name).to eq 'div'
- expect(container['class']).to eq 'video-container'
+ expect(container.name).to eq "div"
+ expect(container["class"]).to eq "video-container"
video, paragraph = container.children
- expect(video.name).to eq 'video'
- expect(video['src']).to eq "/path/video.#{ext}"
+ expect(video.name).to eq "video"
+ expect(video["src"]).to eq "/path/video.#{ext}"
- expect(paragraph.name).to eq 'p'
+ expect(paragraph.name).to eq "p"
link = paragraph.children.first
- expect(link.name).to eq 'a'
- expect(link['href']).to eq "/path/video.#{ext}"
- expect(link['target']).to eq '_blank'
+ expect(link.name).to eq "a"
+ expect(link["href"]).to eq "/path/video.#{ext}"
+ expect(link["target"]).to eq "_blank"
end
end
end
- context 'when the element src is an image' do
- it 'leaves the document unchanged' do
- element = filter(link_to_image('/path/my_image.jpg')).children.first
+ context "when the element src is an image" do
+ it "leaves the document unchanged" do
+ element = filter(link_to_image("/path/my_image.jpg")).children.first
- expect(element.name).to eq 'img'
- expect(element['src']).to eq '/path/my_image.jpg'
+ expect(element.name).to eq "img"
+ expect(element["src"]).to eq "/path/my_image.jpg"
end
end
end
diff --git a/spec/lib/banzai/filter/wiki_link_filter_spec.rb b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
index b9059b85fdc..efae6f1d1f6 100644
--- a/spec/lib/banzai/filter/wiki_link_filter_spec.rb
+++ b/spec/lib/banzai/filter/wiki_link_filter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Filter::WikiLinkFilter do
include FilterSpecHelper
@@ -12,21 +12,21 @@ describe Banzai::Filter::WikiLinkFilter do
it "doesn't rewrite absolute links" do
filtered_link = filter("<a href='http://example.com:8000/'>Link</a>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('href').value).to eq('http://example.com:8000/')
+ expect(filtered_link.attribute("href").value).to eq("http://example.com:8000/")
end
it "doesn't rewrite links to project uploads" do
filtered_link = filter("<a href='/uploads/a.test'>Link</a>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('href').value).to eq('/uploads/a.test')
+ expect(filtered_link.attribute("href").value).to eq("/uploads/a.test")
end
describe "when links point to the #{Wikis::CreateAttachmentService::ATTACHMENT_PATH} folder" do
context 'with an "a" html tag' do
- it 'rewrites links' do
+ it "rewrites links" do
filtered_link = filter("<a href='#{repository_upload_folder}/a.test'>Link</a>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('href').value).to eq("#{wiki.wiki_base_path}/#{repository_upload_folder}/a.test")
+ expect(filtered_link.attribute("href").value).to eq("#{wiki.wiki_base_path}/#{repository_upload_folder}/a.test")
end
end
@@ -34,28 +34,28 @@ describe Banzai::Filter::WikiLinkFilter do
let(:path) { "#{wiki.wiki_base_path}/#{repository_upload_folder}/a.jpg" }
context 'inside an "a" html tag' do
- it 'rewrites links' do
+ it "rewrites links" do
filtered_elements = filter("<a href='#{repository_upload_folder}/a.jpg'><img src='#{repository_upload_folder}/a.jpg'>example</img></a>", project_wiki: wiki)
- expect(filtered_elements.search('img').first.attribute('src').value).to eq(path)
- expect(filtered_elements.search('a').first.attribute('href').value).to eq(path)
+ expect(filtered_elements.search("img").first.attribute("src").value).to eq(path)
+ expect(filtered_elements.search("a").first.attribute("href").value).to eq(path)
end
end
context 'outside an "a" html tag' do
- it 'rewrites links' do
+ it "rewrites links" do
filtered_link = filter("<img src='#{repository_upload_folder}/a.jpg'>example</img>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('src').value).to eq(path)
+ expect(filtered_link.attribute("src").value).to eq(path)
end
end
end
context 'with "video" html tag' do
- it 'rewrites links' do
+ it "rewrites links" do
filtered_link = filter("<video src='#{repository_upload_folder}/a.mp4'></video>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('src').value).to eq("#{wiki.wiki_base_path}/#{repository_upload_folder}/a.mp4")
+ expect(filtered_link.attribute("src").value).to eq("#{wiki.wiki_base_path}/#{repository_upload_folder}/a.mp4")
end
end
end
@@ -67,7 +67,7 @@ describe Banzai::Filter::WikiLinkFilter do
it "doesn't rewrite invalid invalid_links like #{invalid_link}" do
filtered_link = filter("<a href='#{invalid_link}'>Link</a>", project_wiki: wiki).children[0]
- expect(filtered_link.attribute('href').value).to eq(invalid_link)
+ expect(filtered_link.attribute("href").value).to eq(invalid_link)
end
end
end
diff --git a/spec/lib/banzai/filter_array_spec.rb b/spec/lib/banzai/filter_array_spec.rb
index ea84005e7f8..8d91af43837 100644
--- a/spec/lib/banzai/filter_array_spec.rb
+++ b/spec/lib/banzai/filter_array_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::FilterArray do
- describe '#insert_after' do
- it 'inserts an element after a provided element' do
- filters = described_class.new(%w(a b c))
+ describe "#insert_after" do
+ it "inserts an element after a provided element" do
+ filters = described_class.new(%w[a b c])
- filters.insert_after('b', '1')
+ filters.insert_after("b", "1")
- expect(filters).to eq %w(a b 1 c)
+ expect(filters).to eq %w[a b 1 c]
end
- it 'inserts an element at the end when the provided element does not exist' do
- filters = described_class.new(%w(a b c))
+ it "inserts an element at the end when the provided element does not exist" do
+ filters = described_class.new(%w[a b c])
- filters.insert_after('d', '1')
+ filters.insert_after("d", "1")
- expect(filters).to eq %w(a b c 1)
+ expect(filters).to eq %w[a b c 1]
end
end
- describe '#insert_before' do
- it 'inserts an element before a provided element' do
- filters = described_class.new(%w(a b c))
+ describe "#insert_before" do
+ it "inserts an element before a provided element" do
+ filters = described_class.new(%w[a b c])
- filters.insert_before('b', '1')
+ filters.insert_before("b", "1")
- expect(filters).to eq %w(a 1 b c)
+ expect(filters).to eq %w[a 1 b c]
end
- it 'inserts an element at the beginning when the provided element does not exist' do
- filters = described_class.new(%w(a b c))
+ it "inserts an element at the beginning when the provided element does not exist" do
+ filters = described_class.new(%w[a b c])
- filters.insert_before('d', '1')
+ filters.insert_before("d", "1")
- expect(filters).to eq %w(1 a b c)
+ expect(filters).to eq %w[1 a b c]
end
end
end
diff --git a/spec/lib/banzai/issuable_extractor_spec.rb b/spec/lib/banzai/issuable_extractor_spec.rb
index f42951d9781..8656fb9c76a 100644
--- a/spec/lib/banzai/issuable_extractor_spec.rb
+++ b/spec/lib/banzai/issuable_extractor_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::IssuableExtractor do
let(:project) { create(:project) }
@@ -23,19 +23,19 @@ describe Banzai::IssuableExtractor do
).children[0]
end
- it 'returns instances of issuables for nodes with references' do
+ it "returns instances of issuables for nodes with references" do
result = extractor.extract([issue_link, merge_request_link])
expect(result).to eq(issue_link => issue, merge_request_link => merge_request)
end
- describe 'caching', :request_store do
- it 'saves records to cache' do
+ describe "caching", :request_store do
+ it "saves records to cache" do
extractor.extract([issue_link, merge_request_link])
- second_call_queries = ActiveRecord::QueryRecorder.new do
+ second_call_queries = ActiveRecord::QueryRecorder.new {
extractor.extract([issue_link, merge_request_link])
- end.count
+ }.count
expect(second_call_queries).to eq 0
end
diff --git a/spec/lib/banzai/object_renderer_spec.rb b/spec/lib/banzai/object_renderer_spec.rb
index 3b52f6666d0..f44e1a5216c 100644
--- a/spec/lib/banzai/object_renderer_spec.rb
+++ b/spec/lib/banzai/object_renderer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ObjectRenderer do
let(:project) { create(:project, :repository) }
@@ -7,39 +7,39 @@ describe Banzai::ObjectRenderer do
described_class.new(
default_project: project,
user: user,
- redaction_context: { custom_value: 'value' }
+ redaction_context: {custom_value: "value"}
)
end
- let(:object) { Note.new(note: 'hello', note_html: '<p dir="auto">hello</p>', cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION << 16) }
+ let(:object) { Note.new(note: "hello", note_html: '<p dir="auto">hello</p>', cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION << 16) }
- describe '#render' do
- context 'with cache' do
- it 'renders and redacts an Array of objects' do
+ describe "#render" do
+ context "with cache" do
+ it "renders and redacts an Array of objects" do
renderer.render([object], :note)
expect(object.redacted_note_html).to eq '<p dir="auto">hello</p>'
expect(object.user_visible_reference_count).to eq 0
end
- it 'calls Banzai::Redactor to perform redaction' do
+ it "calls Banzai::Redactor to perform redaction" do
expect_any_instance_of(Banzai::Redactor).to receive(:redact).and_call_original
renderer.render([object], :note)
end
- it 'retrieves field content using Banzai::Renderer.render_field' do
+ it "retrieves field content using Banzai::Renderer.render_field" do
expect(Banzai::Renderer).to receive(:render_field).with(object, :note, {}).and_call_original
renderer.render([object], :note)
end
- it 'passes context to PostProcessPipeline' do
+ it "passes context to PostProcessPipeline" do
another_user = create(:user)
another_project = create(:project)
object = Note.new(
- note: 'hello',
- note_html: 'hello',
+ note: "hello",
+ note_html: "hello",
author: another_user,
project: another_project
)
@@ -51,7 +51,7 @@ describe Banzai::ObjectRenderer do
current_user: user,
project: another_project,
author: another_user,
- custom_value: 'value'
+ custom_value: "value"
)
).and_call_original
@@ -59,22 +59,22 @@ describe Banzai::ObjectRenderer do
end
end
- context 'without cache' do
+ context "without cache" do
let(:commit) { project.commit }
- it 'renders and redacts an Array of objects' do
+ it "renders and redacts an Array of objects" do
renderer.render([commit], :title)
expect(commit.redacted_title_html).to eq("Merge branch 'branch-merged' into 'master'")
end
- it 'calls Banzai::Redactor to perform redaction' do
+ it "calls Banzai::Redactor to perform redaction" do
expect_any_instance_of(Banzai::Redactor).to receive(:redact).and_call_original
renderer.render([commit], :title)
end
- it 'retrieves field content using Banzai::Renderer.cacheless_render_field' do
+ it "retrieves field content using Banzai::Renderer.cacheless_render_field" do
expect(Banzai::Renderer).to receive(:cacheless_render_field).with(commit, :title, {}).and_call_original
renderer.render([commit], :title)
diff --git a/spec/lib/banzai/pipeline/description_pipeline_spec.rb b/spec/lib/banzai/pipeline/description_pipeline_spec.rb
index 77cb1954ea3..d0796152b5a 100644
--- a/spec/lib/banzai/pipeline/description_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/description_pipeline_spec.rb
@@ -1,10 +1,10 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Pipeline::DescriptionPipeline do
def parse(html)
# When we pass HTML to Redcarpet, it gets wrapped in `p` tags...
# ...except when we pass it pre-wrapped text. Rabble rabble.
- unwrap = !html.start_with?('<p ')
+ unwrap = !html.start_with?("<p ")
output = described_class.to_html(html, project: spy)
@@ -17,21 +17,21 @@ describe Banzai::Pipeline::DescriptionPipeline do
stub_commonmark_sourcepos_disabled
end
- it 'uses a limited whitelist' do
- doc = parse('# Description')
+ it "uses a limited whitelist" do
+ doc = parse("# Description")
- expect(doc.strip).to eq 'Description'
+ expect(doc.strip).to eq "Description"
end
- %w(pre code img ol ul li).each do |elem|
+ %w[pre code img ol ul li].each do |elem|
it "removes '#{elem}' elements" do
act = "<#{elem}>Description</#{elem}>"
- expect(parse(act).strip).to eq 'Description'
+ expect(parse(act).strip).to eq "Description"
end
end
- %w(b i strong em a ins del sup sub).each do |elem|
+ %w[b i strong em a ins del sup sub].each do |elem|
it "still allows '#{elem}' elements" do
exp = act = "<#{elem}>Description</#{elem}>"
diff --git a/spec/lib/banzai/pipeline/email_pipeline_spec.rb b/spec/lib/banzai/pipeline/email_pipeline_spec.rb
index b99161109eb..3a11e7cc7fb 100644
--- a/spec/lib/banzai/pipeline/email_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/email_pipeline_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Pipeline::EmailPipeline do
- describe '.filters' do
- it 'returns the expected type' do
+ describe ".filters" do
+ it "returns the expected type" do
expect(described_class.filters).to be_kind_of(Banzai::FilterArray)
end
- it 'excludes ImageLazyLoadFilter' do
+ it "excludes ImageLazyLoadFilter" do
expect(described_class.filters).not_to be_empty
expect(described_class.filters).not_to include(Banzai::Filter::ImageLazyLoadFilter)
end
- it 'shows punycode for autolinks' do
+ it "shows punycode for autolinks" do
examples = %W[
http://one😄two.com
http://\u0261itlab.com
@@ -19,9 +19,9 @@ describe Banzai::Pipeline::EmailPipeline do
examples.each do |markdown|
result = described_class.call(markdown, project: nil)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link.content).to include('http://xn--')
+ expect(link.content).to include("http://xn--")
end
end
end
diff --git a/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb b/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb
index 744df3e0b96..f264e275390 100644
--- a/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/emoji_pipeline_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Pipeline::EmojiPipeline do
def parse(text)
described_class.to_html(text, {})
end
- it 'replaces emoji' do
- expected_result = "Hello world #{Gitlab::Emoji.gl_emoji_tag('100')}"
+ it "replaces emoji" do
+ expected_result = "Hello world #{Gitlab::Emoji.gl_emoji_tag("100")}"
- expect(parse('Hello world :100:')).to eq(expected_result)
+ expect(parse("Hello world :100:")).to eq(expected_result)
end
- it 'filters out HTML tags' do
- expected_result = "Hello &lt;b&gt;world&lt;/b&gt; #{Gitlab::Emoji.gl_emoji_tag('100')}"
+ it "filters out HTML tags" do
+ expected_result = "Hello &lt;b&gt;world&lt;/b&gt; #{Gitlab::Emoji.gl_emoji_tag("100")}"
- expect(parse('Hello <b>world</b> :100:')).to eq(expected_result)
+ expect(parse("Hello <b>world</b> :100:")).to eq(expected_result)
end
end
diff --git a/spec/lib/banzai/pipeline/full_pipeline_spec.rb b/spec/lib/banzai/pipeline/full_pipeline_spec.rb
index 3d3aa64d630..4f814286754 100644
--- a/spec/lib/banzai/pipeline/full_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/full_pipeline_spec.rb
@@ -1,32 +1,32 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Pipeline::FullPipeline do
- describe 'References' do
+ describe "References" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
- it 'handles markdown inside a reference' do
+ it "handles markdown inside a reference" do
markdown = "[some `code` inside](#{issue.to_reference})"
result = described_class.call(markdown, project: project)
- link_content = result[:output].css('a').inner_html
- expect(link_content).to eq('some <code>code</code> inside')
+ link_content = result[:output].css("a").inner_html
+ expect(link_content).to eq("some <code>code</code> inside")
end
- it 'sanitizes reference HTML' do
- link_label = '<script>bad things</script>'
+ it "sanitizes reference HTML" do
+ link_label = "<script>bad things</script>"
markdown = "[#{link_label}](#{issue.to_reference})"
result = described_class.to_html(markdown, project: project)
expect(result).not_to include(link_label)
end
- it 'escapes the data-original attribute on a reference' do
- markdown = %Q{[">bad things](#{issue.to_reference})}
+ it "escapes the data-original attribute on a reference" do
+ markdown = %{[">bad things](#{issue.to_reference})}
result = described_class.to_html(markdown, project: project)
- expect(result).to include(%{data-original='\"&gt;bad things'})
+ expect(result).to include(%(data-original='\"&gt;bad things'))
end
end
- describe 'footnotes' do
+ describe "footnotes" do
let(:project) { create(:project, :public) }
let(:html) { described_class.to_html(footnote_markdown, project: project) }
let(:identifier) { html[/.*fnref1-(\d+).*/, 1] }
@@ -53,15 +53,15 @@ describe Banzai::Pipeline::FullPipeline do
EOF
end
- it 'properly adds the necessary ids and classes' do
+ it "properly adds the necessary ids and classes" do
stub_commonmark_sourcepos_disabled
expect(html.lines.map(&:strip).join("\n")).to eq filtered_footnote
end
end
- describe 'links are detected as malicious' do
- it 'has tooltips for malicious links' do
+ describe "links are detected as malicious" do
+ it "has tooltips for malicious links" do
examples = %W[
http://example.com/evil\u202E3pm.exe
[evilexe.mp3](http://example.com/evil\u202E3pm.exe)
@@ -75,13 +75,13 @@ describe Banzai::Pipeline::FullPipeline do
examples.each do |markdown|
result = described_class.call(markdown, project: nil)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link[:class]).to include('has-tooltip')
+ expect(link[:class]).to include("has-tooltip")
end
end
- it 'has no tooltips for safe links' do
+ it "has no tooltips for safe links" do
examples = %w[
http://example.com
[Safe-Test](http://example.com)
@@ -91,7 +91,7 @@ describe Banzai::Pipeline::FullPipeline do
examples.each do |markdown|
result = described_class.call(markdown, project: nil)[:output]
- link = result.css('a').first
+ link = result.css("a").first
expect(link[:class]).to be_nil
end
diff --git a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
index 91b0499375d..8714f9d12c9 100644
--- a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb
@@ -1,111 +1,111 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Pipeline::GfmPipeline do
- describe 'integration between parsing regular and external issue references' do
+ describe "integration between parsing regular and external issue references" do
let(:project) { create(:redmine_project, :public) }
- context 'when internal issue tracker is enabled' do
- context 'when shorthand pattern #ISSUE_ID is used' do
- it 'links an internal issue if it exists' do
+ context "when internal issue tracker is enabled" do
+ context "when shorthand pattern #ISSUE_ID is used" do
+ it "links an internal issue if it exists" do
issue = create(:issue, project: project)
markdown = issue.to_reference(project, full: true)
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq(
+ expect(link["href"]).to eq(
Gitlab::Routing.url_helpers.project_issue_path(project, issue)
)
end
- it 'does not link any issue if it does not exist on GitLab' do
- markdown = '#12'
+ it "does not link any issue if it does not exist on GitLab" do
+ markdown = "#12"
result = described_class.call(markdown, project: project)[:output]
- expect(result.css('a')).to be_empty
+ expect(result.css("a")).to be_empty
end
end
- it 'allows to use long external reference syntax for Redmine' do
- markdown = 'API_32-12'
+ it "allows to use long external reference syntax for Redmine" do
+ markdown = "API_32-12"
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq 'http://redmine/projects/project_name_in_redmine/issues/12'
+ expect(link["href"]).to eq "http://redmine/projects/project_name_in_redmine/issues/12"
end
- it 'parses cross-project references to regular issues' do
+ it "parses cross-project references to regular issues" do
other_project = create(:project, :public)
issue = create(:issue, project: other_project)
markdown = issue.to_reference(project, full: true)
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq(
+ expect(link["href"]).to eq(
Gitlab::Routing.url_helpers.project_issue_path(other_project, issue)
)
end
end
- context 'when internal issue tracker is disabled' do
+ context "when internal issue tracker is disabled" do
before do
project.issues_enabled = false
project.save!
end
- it 'allows to use shorthand external reference syntax for Redmine' do
- markdown = '#12'
+ it "allows to use shorthand external reference syntax for Redmine" do
+ markdown = "#12"
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq 'http://redmine/projects/project_name_in_redmine/issues/12'
+ expect(link["href"]).to eq "http://redmine/projects/project_name_in_redmine/issues/12"
end
- it 'allows to use long external reference syntax for Redmine' do
- markdown = 'API_32-12'
+ it "allows to use long external reference syntax for Redmine" do
+ markdown = "API_32-12"
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq 'http://redmine/projects/project_name_in_redmine/issues/12'
+ expect(link["href"]).to eq "http://redmine/projects/project_name_in_redmine/issues/12"
end
- it 'parses cross-project references to regular issues' do
+ it "parses cross-project references to regular issues" do
other_project = create(:project, :public)
issue = create(:issue, project: other_project)
markdown = issue.to_reference(project, full: true)
result = described_class.call(markdown, project: project)[:output]
- link = result.css('a').first
+ link = result.css("a").first
- expect(link['href']).to eq(
+ expect(link["href"]).to eq(
Gitlab::Routing.url_helpers.project_issue_path(other_project, issue)
)
end
end
end
- describe 'markdown link or image urls having spaces' do
+ describe "markdown link or image urls having spaces" do
let(:project) { create(:project, :public) }
- it 'rewrites links with spaces in url' do
+ it "rewrites links with spaces in url" do
markdown = "[Link to Page](page slug)"
output = described_class.to_html(markdown, project: project)
expect(output).to include("href=\"page%20slug\"")
end
- it 'rewrites images with spaces in url' do
+ it "rewrites images with spaces in url" do
markdown = "![My Image](test image.png)"
output = described_class.to_html(markdown, project: project)
expect(output).to include("src=\"test%20image.png\"")
end
- it 'sanitizes the fixed link' do
+ it "sanitizes the fixed link" do
markdown_xss = "[xss](javascript: alert%28document.domain%29)"
output = described_class.to_html(markdown_xss, project: project)
diff --git a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
index 64ca3ec345d..b0ee1bfc9e0 100644
--- a/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
+++ b/spec/lib/banzai/pipeline/wiki_pipeline_spec.rb
@@ -1,8 +1,8 @@
-require 'rails_helper'
+require "rails_helper"
describe Banzai::Pipeline::WikiPipeline do
- describe 'TableOfContents' do
- it 'replaces the tag with the TableOfContentsFilter result' do
+ describe "TableOfContents" do
+ it "replaces the tag with the TableOfContentsFilter result" do
markdown = <<-MD.strip_heredoc
[[_TOC_]]
@@ -14,13 +14,13 @@ describe Banzai::Pipeline::WikiPipeline do
result = described_class.call(markdown, project: spy, project_wiki: spy)
aggregate_failures do
- expect(result[:output].text).not_to include '[['
- expect(result[:output].text).not_to include 'TOC'
+ expect(result[:output].text).not_to include "[["
+ expect(result[:output].text).not_to include "TOC"
expect(result[:output].to_html).to include(result[:toc])
end
end
- it 'is case-sensitive' do
+ it "is case-sensitive" do
markdown = <<-MD.strip_heredoc
[[_toc_]]
@@ -31,10 +31,10 @@ describe Banzai::Pipeline::WikiPipeline do
output = described_class.to_html(markdown, project: spy, project_wiki: spy)
- expect(output).to include('[[<em>toc</em>]]')
+ expect(output).to include("[[<em>toc</em>]]")
end
- it 'handles an empty pipeline result' do
+ it "handles an empty pipeline result" do
# No Markdown headers in this doc, so `result[:toc]` will be empty
markdown = <<-MD.strip_heredoc
[[_TOC_]]
@@ -45,8 +45,8 @@ describe Banzai::Pipeline::WikiPipeline do
output = described_class.to_html(markdown, project: spy, project_wiki: spy)
aggregate_failures do
- expect(output).not_to include('<ul>')
- expect(output).not_to include('[[<em>TOC</em>]]')
+ expect(output).not_to include("<ul>")
+ expect(output).not_to include("[[<em>TOC</em>]]")
end
end
end
@@ -55,10 +55,10 @@ describe Banzai::Pipeline::WikiPipeline do
let(:namespace) { create(:namespace, name: "wiki_link_ns") }
let(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) }
let(:project_wiki) { ProjectWiki.new(project, double(:user)) }
- let(:page) { build(:wiki_page, wiki: project_wiki, page: OpenStruct.new(url_path: 'nested/twice/start-page')) }
+ let(:page) { build(:wiki_page, wiki: project_wiki, page: OpenStruct.new(url_path: "nested/twice/start-page")) }
- { "when GitLab is hosted at a root URL" => '/',
- "when GitLab is hosted at a relative URL" => '/nested/relative/gitlab' }.each do |test_name, relative_url_root|
+ {"when GitLab is hosted at a root URL" => "/",
+ "when GitLab is hosted at a relative URL" => "/nested/relative/gitlab",}.each do |test_name, relative_url_root|
context test_name do
before do
allow(Gitlab.config.gitlab).to receive(:relative_url_root).and_return(relative_url_root)
@@ -114,14 +114,14 @@ describe Banzai::Pipeline::WikiPipeline do
end
describe "when creating non-hierarchical links" do
- it 'rewrites non-file links to be at the scope of the wiki root' do
+ it "rewrites non-file links to be at the scope of the wiki root" do
markdown = "[Link to Page](page)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page\"")
end
- it 'rewrites non-file links (with spaces) to be at the scope of the wiki root' do
+ it "rewrites non-file links (with spaces) to be at the scope of the wiki root" do
markdown = "[Link to Page](page slug)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
@@ -135,15 +135,15 @@ describe Banzai::Pipeline::WikiPipeline do
expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/nested/twice/page.md\"")
end
- it 'rewrites links with anchor' do
- markdown = '[Link to Header](start-page#title)'
+ it "rewrites links with anchor" do
+ markdown = "[Link to Header](start-page#title)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/start-page#title\"")
end
- it 'rewrites links (with spaces) with anchor' do
- markdown = '[Link to Header](start page#title)'
+ it "rewrites links (with spaces) with anchor" do
+ markdown = "[Link to Header](start page#title)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/start%20page#title\"")
@@ -151,14 +151,14 @@ describe Banzai::Pipeline::WikiPipeline do
end
describe "when creating root links" do
- it 'rewrites non-file links to be at the scope of the wiki root' do
+ it "rewrites non-file links to be at the scope of the wiki root" do
markdown = "[Link to Page](/page)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
expect(output).to include("href=\"#{relative_url_root}/wiki_link_ns/wiki_link_project/wikis/page\"")
end
- it 'rewrites file links to be at the scope of the wiki root' do
+ it "rewrites file links to be at the scope of the wiki root" do
markdown = "[Link to Page](/page.md)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
@@ -179,20 +179,20 @@ describe Banzai::Pipeline::WikiPipeline do
end
end
- describe 'videos' do
+ describe "videos" do
let(:namespace) { create(:namespace, name: "wiki_link_ns") }
let(:project) { create(:project, :public, name: "wiki_link_project", namespace: namespace) }
let(:project_wiki) { ProjectWiki.new(project, double(:user)) }
- let(:page) { build(:wiki_page, wiki: project_wiki, page: OpenStruct.new(url_path: 'nested/twice/start-page')) }
+ let(:page) { build(:wiki_page, wiki: project_wiki, page: OpenStruct.new(url_path: "nested/twice/start-page")) }
- it 'generates video html structure' do
+ it "generates video html structure" do
markdown = "![video_file](video_file_name.mp4)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
expect(output).to include('<video src="/wiki_link_ns/wiki_link_project/wikis/nested/twice/video_file_name.mp4"')
end
- it 'rewrites and replaces video links names with white spaces to %20' do
+ it "rewrites and replaces video links names with white spaces to %20" do
markdown = "![video file](video file name.mp4)"
output = described_class.to_html(markdown, project: project, project_wiki: project_wiki, page_slug: page.slug)
diff --git a/spec/lib/banzai/querying_spec.rb b/spec/lib/banzai/querying_spec.rb
index 27da2a7439c..ea80c623c32 100644
--- a/spec/lib/banzai/querying_spec.rb
+++ b/spec/lib/banzai/querying_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Querying do
- describe '.css' do
- it 'optimizes queries for elements with classes' do
+ describe ".css" do
+ it "optimizes queries for elements with classes" do
document = double(:document)
expect(document).to receive(:xpath).with(/^descendant::a/)
- described_class.css(document, 'a.gfm')
+ described_class.css(document, "a.gfm")
end
end
end
diff --git a/spec/lib/banzai/redactor_spec.rb b/spec/lib/banzai/redactor_spec.rb
index aaeec953e4b..1acd84b3467 100644
--- a/spec/lib/banzai/redactor_spec.rb
+++ b/spec/lib/banzai/redactor_spec.rb
@@ -1,48 +1,48 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Redactor do
let(:user) { create(:user) }
let(:project) { build(:project) }
let(:redactor) { described_class.new(Banzai::RenderContext.new(project, user)) }
- describe '#redact' do
- context 'when reference not visible to user' do
+ describe "#redact" do
+ context "when reference not visible to user" do
before do
expect(redactor).to receive(:nodes_visible_to_user).and_return([])
end
- it 'redacts an array of documents' do
+ it "redacts an array of documents" do
doc1 = Nokogiri::HTML
- .fragment('<a class="gfm" data-reference-type="issue">foo</a>')
+ .fragment('<a class="gfm" data-reference-type="issue">foo</a>')
doc2 = Nokogiri::HTML
- .fragment('<a class="gfm" data-reference-type="issue">bar</a>')
+ .fragment('<a class="gfm" data-reference-type="issue">bar</a>')
redacted_data = redactor.redact([doc1, doc2])
expect(redacted_data.map { |data| data[:document] }).to eq([doc1, doc2])
expect(redacted_data.map { |data| data[:visible_reference_count] }).to eq([0, 0])
- expect(doc1.to_html).to eq('foo')
- expect(doc2.to_html).to eq('bar')
+ expect(doc1.to_html).to eq("foo")
+ expect(doc2.to_html).to eq("bar")
end
- it 'replaces redacted reference with inner HTML' do
+ it "replaces redacted reference with inner HTML" do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue'>foo</a>")
redactor.redact([doc])
- expect(doc.to_html).to eq('foo')
+ expect(doc.to_html).to eq("foo")
end
- context 'when data-original attribute provided' do
- let(:original_content) { '<code>foo</code>' }
- it 'replaces redacted reference with original content' do
+ context "when data-original attribute provided" do
+ let(:original_content) { "<code>foo</code>" }
+ it "replaces redacted reference with original content" do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-original='#{original_content}'>bar</a>")
redactor.redact([doc])
expect(doc.to_html).to eq(original_content)
end
end
- it 'returns <a> tag with original href if it is originally a link reference' do
- href = 'http://localhost:3000'
+ it "returns <a> tag with original href if it is originally a link reference" do
+ href = "http://localhost:3000"
doc = Nokogiri::HTML
.fragment("<a class='gfm' data-reference-type='issue' data-original=#{href} data-link-reference='true'>#{href}</a>")
@@ -52,7 +52,7 @@ describe Banzai::Redactor do
end
end
- context 'when project is in pending delete' do
+ context "when project is in pending delete" do
let!(:issue) { create(:issue, project: project) }
let(:redactor) { described_class.new(Banzai::RenderContext.new(project, user)) }
@@ -60,25 +60,25 @@ describe Banzai::Redactor do
project.update(pending_delete: true)
end
- it 'redacts an issue attached' do
+ it "redacts an issue attached" do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-issue='#{issue.id}'>foo</a>")
redactor.redact([doc])
- expect(doc.to_html).to eq('foo')
+ expect(doc.to_html).to eq("foo")
end
- it 'redacts an external issue' do
+ it "redacts an external issue" do
doc = Nokogiri::HTML.fragment("<a class='gfm' data-reference-type='issue' data-external-issue='#{issue.id}' data-project='#{project.id}'>foo</a>")
redactor.redact([doc])
- expect(doc.to_html).to eq('foo')
+ expect(doc.to_html).to eq("foo")
end
end
- context 'when reference visible to user' do
- it 'does not redact an array of documents' do
+ context "when reference visible to user" do
+ it "does not redact an array of documents" do
doc1_html = '<a class="gfm" data-reference-type="issue">foo</a>'
doc1 = Nokogiri::HTML.fragment(doc1_html)
@@ -98,20 +98,20 @@ describe Banzai::Redactor do
end
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
include ActionView::Helpers::UrlHelper
let(:project) { create(:project) }
let(:other_project) { create(:project, :public) }
def create_link(issuable)
type = issuable.class.name.underscore.downcase
- link_to(issuable.to_reference, '',
- class: 'gfm has-tooltip',
- title: issuable.title,
- data: {
- reference_type: type,
- "#{type}": issuable.id
- })
+ link_to(issuable.to_reference, "",
+ class: "gfm has-tooltip",
+ title: issuable.title,
+ data: {
+ :reference_type => type,
+ :"#{type}" => issuable.id,
+ })
end
before do
@@ -122,33 +122,33 @@ describe Banzai::Redactor do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
end
- it 'skips links to issues within the same project' do
+ it "skips links to issues within the same project" do
issue = create(:issue, project: project)
link = create_link(issue)
doc = Nokogiri::HTML.fragment(link)
redactor.redact([doc])
- result = doc.css('a').last
+ result = doc.css("a").last
- expect(result['class']).to include('has-tooltip')
- expect(result['title']).to eq(issue.title)
+ expect(result["class"]).to include("has-tooltip")
+ expect(result["title"]).to eq(issue.title)
end
- it 'removes info from a cross project reference' do
+ it "removes info from a cross project reference" do
issue = create(:issue, project: other_project)
link = create_link(issue)
doc = Nokogiri::HTML.fragment(link)
redactor.redact([doc])
- result = doc.css('a').last
+ result = doc.css("a").last
- expect(result['class']).not_to include('has-tooltip')
- expect(result['title']).to be_empty
+ expect(result["class"]).not_to include("has-tooltip")
+ expect(result["title"]).to be_empty
end
end
- describe '#redact_nodes' do
- it 'redacts an Array of nodes' do
+ describe "#redact_nodes" do
+ it "redacts an Array of nodes" do
doc = Nokogiri::HTML.fragment('<a href="foo">foo</a>')
node = doc.children[0]
@@ -156,14 +156,14 @@ describe Banzai::Redactor do
.with([node])
.and_return(Set.new)
- redactor.redact_document_nodes([{ document: doc, nodes: [node] }])
+ redactor.redact_document_nodes([{document: doc, nodes: [node]}])
- expect(doc.to_html).to eq('foo')
+ expect(doc.to_html).to eq("foo")
end
end
- describe '#nodes_visible_to_user' do
- it 'returns a Set containing the visible nodes' do
+ describe "#nodes_visible_to_user" do
+ it "returns a Set containing the visible nodes" do
doc = Nokogiri::HTML.fragment('<a data-reference-type="issue"></a>')
node = doc.children[0]
diff --git a/spec/lib/banzai/reference_parser/base_parser_spec.rb b/spec/lib/banzai/reference_parser/base_parser_spec.rb
index c6e9fc414a1..4d0a241bfbd 100644
--- a/spec/lib/banzai/reference_parser/base_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/base_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::BaseParser do
include ReferenceParserHelpers
@@ -8,15 +8,15 @@ describe Banzai::ReferenceParser::BaseParser do
let(:context) { Banzai::RenderContext.new(project, user) }
subject do
- klass = Class.new(described_class) do
+ klass = Class.new(described_class) {
self.reference_type = :foo
- end
+ }
klass.new(context)
end
- describe '.reference_type=' do
- it 'sets the reference type' do
+ describe ".reference_type=" do
+ it "sets the reference type" do
dummy = Class.new(described_class)
dummy.reference_type = :foo
@@ -24,12 +24,12 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#project_for_node' do
- it 'returns the Project for a node' do
- document = instance_double('document', fragment?: false)
- project = instance_double('project')
- object = instance_double('object', project: project)
- node = instance_double('node', document: document)
+ describe "#project_for_node" do
+ it "returns the Project for a node" do
+ document = instance_double("document", fragment?: false)
+ project = instance_double("project")
+ object = instance_double("object", project: project)
+ node = instance_double("node", document: document)
context.associate_document(document, object)
@@ -37,12 +37,12 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#nodes_visible_to_user' do
+ describe "#nodes_visible_to_user" do
let(:link) { empty_html_link }
- context 'when the link has a data-project attribute' do
- it 'checks if user can read the resource' do
- link['data-project'] = project.id.to_s
+ context "when the link has a data-project attribute" do
+ it "checks if user can read the resource" do
+ link["data-project"] = project.id.to_s
expect(subject).to receive(:can_read_reference?).with(user, project, link)
@@ -50,24 +50,24 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- context 'when the link does not have a data-project attribute' do
- it 'returns the nodes' do
+ context "when the link does not have a data-project attribute" do
+ it "returns the nodes" do
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
end
end
- describe '#nodes_user_can_reference' do
- it 'returns the nodes' do
+ describe "#nodes_user_can_reference" do
+ it "returns the nodes" do
link = double(:link)
expect(subject.nodes_user_can_reference(user, [link])).to eq([link])
end
end
- describe '#referenced_by' do
- context 'when references_relation is implemented' do
- it 'returns a collection of objects' do
+ describe "#referenced_by" do
+ context "when references_relation is implemented" do
+ it "returns a collection of objects" do
links = Nokogiri::HTML.fragment("<a data-foo='#{user.id}'></a>")
.children
@@ -76,8 +76,8 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- context 'when references_relation is not implemented' do
- it 'raises NotImplementedError' do
+ context "when references_relation is not implemented" do
+ it "raises NotImplementedError" do
links = Nokogiri::HTML.fragment('<a data-foo="1"></a>').children
expect { subject.referenced_by(links) }
@@ -86,97 +86,97 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#references_relation' do
- it 'raises NotImplementedError' do
+ describe "#references_relation" do
+ it "raises NotImplementedError" do
expect { subject.references_relation }.to raise_error(NotImplementedError)
end
end
- describe '#gather_attributes_per_project' do
- it 'returns a Hash containing attribute values per project' do
+ describe "#gather_attributes_per_project" do
+ it "returns a Hash containing attribute values per project" do
link = Nokogiri::HTML.fragment('<a data-project="1" data-foo="2"></a>')
.children[0]
- hash = subject.gather_attributes_per_project([link], 'data-foo')
+ hash = subject.gather_attributes_per_project([link], "data-foo")
expect(hash).to be_an_instance_of(Hash)
- expect(hash[1].to_a).to eq(['2'])
+ expect(hash[1].to_a).to eq(["2"])
end
end
- describe '#grouped_objects_for_nodes' do
- it 'returns a Hash grouping objects per node' do
+ describe "#grouped_objects_for_nodes" do
+ it "returns a Hash grouping objects per node" do
link = double(:link)
expect(link).to receive(:has_attribute?)
- .with('data-user')
+ .with("data-user")
.and_return(true)
expect(link).to receive(:attr)
- .with('data-user')
+ .with("data-user")
.and_return(user.id.to_s)
nodes = [link]
expect(subject).to receive(:unique_attribute_values)
- .with(nodes, 'data-user')
+ .with(nodes, "data-user")
.and_return([user.id.to_s])
- hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user')
+ hash = subject.grouped_objects_for_nodes(nodes, User, "data-user")
- expect(hash).to eq({ link => user })
+ expect(hash).to eq({link => user})
end
- it 'returns an empty Hash when entry does not exist in the database', :request_store do
+ it "returns an empty Hash when entry does not exist in the database", :request_store do
link = double(:link)
expect(link).to receive(:has_attribute?)
- .with('data-user')
- .and_return(true)
+ .with("data-user")
+ .and_return(true)
expect(link).to receive(:attr)
- .with('data-user')
- .and_return('1')
+ .with("data-user")
+ .and_return("1")
nodes = [link]
bad_id = user.id + 100
expect(subject).to receive(:unique_attribute_values)
- .with(nodes, 'data-user')
- .and_return([bad_id.to_s])
+ .with(nodes, "data-user")
+ .and_return([bad_id.to_s])
- hash = subject.grouped_objects_for_nodes(nodes, User, 'data-user')
+ hash = subject.grouped_objects_for_nodes(nodes, User, "data-user")
expect(hash).to eq({})
end
end
- describe '#unique_attribute_values' do
- it 'returns an Array of unique values' do
+ describe "#unique_attribute_values" do
+ it "returns an Array of unique values" do
link = double(:link)
expect(link).to receive(:has_attribute?)
- .with('data-foo')
+ .with("data-foo")
.twice
.and_return(true)
expect(link).to receive(:attr)
- .with('data-foo')
+ .with("data-foo")
.twice
- .and_return('1')
+ .and_return("1")
nodes = [link, link]
- expect(subject.unique_attribute_values(nodes, 'data-foo')).to eq(['1'])
+ expect(subject.unique_attribute_values(nodes, "data-foo")).to eq(["1"])
end
end
- describe '#process' do
- it 'gathers the references for every node matching the reference type' do
- dummy = Class.new(described_class) do
+ describe "#process" do
+ it "gathers the references for every node matching the reference type" do
+ dummy = Class.new(described_class) {
self.reference_type = :test
- end
+ }
instance = dummy.new(Banzai::RenderContext.new(project, user))
document = Nokogiri::HTML.fragment('<a class="gfm"></a><a class="gfm" data-reference-type="test"></a>')
@@ -189,10 +189,10 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#gather_references' do
+ describe "#gather_references" do
let(:link) { double(:link) }
- it 'does not process links a user can not reference' do
+ it "does not process links a user can not reference" do
expect(subject).to receive(:nodes_user_can_reference)
.with(user, [link])
.and_return([])
@@ -202,7 +202,7 @@ describe Banzai::ReferenceParser::BaseParser do
subject.gather_references([link])
end
- it 'does not process links a user can not see' do
+ it "does not process links a user can not see" do
expect(subject).to receive(:nodes_user_can_reference)
.with(user, [link])
.and_return([link])
@@ -216,7 +216,7 @@ describe Banzai::ReferenceParser::BaseParser do
subject.gather_references([link])
end
- it 'returns the references if a user can reference and see a link' do
+ it "returns the references if a user can reference and see a link" do
expect(subject).to receive(:nodes_user_can_reference)
.with(user, [link])
.and_return([link])
@@ -231,8 +231,8 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#can?' do
- it 'delegates the permissions check to the Ability class' do
+ describe "#can?" do
+ it "delegates the permissions check to the Ability class" do
user = double(:user)
expect(Ability).to receive(:allowed?)
@@ -242,16 +242,16 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#find_projects_for_hash_keys' do
- it 'returns a list of Projects' do
+ describe "#find_projects_for_hash_keys" do
+ it "returns a list of Projects" do
expect(subject.find_projects_for_hash_keys(project.id => project))
.to eq([project])
end
end
- describe '#collection_objects_for_ids' do
- context 'with RequestStore disabled' do
- it 'queries the collection directly' do
+ describe "#collection_objects_for_ids" do
+ context "with RequestStore disabled" do
+ it "queries the collection directly" do
collection = User.all
expect(collection).to receive(:where).twice.and_call_original
@@ -263,19 +263,19 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- context 'with RequestStore enabled', :request_store do
+ context "with RequestStore enabled", :request_store do
before do
cache = Hash.new { |hash, key| hash[key] = {} }
allow(subject).to receive(:collection_cache).and_return(cache)
end
- it 'queries the collection on the first call' do
+ it "queries the collection on the first call" do
expect(subject.collection_objects_for_ids(User, [user.id]))
.to eq([user])
end
- it 'does not query previously queried objects' do
+ it "does not query previously queried objects" do
collection = User.all
expect(collection).to receive(:where).once.and_call_original
@@ -286,14 +286,14 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- it 'casts String based IDs to Fixnums before querying objects' do
+ it "casts String based IDs to Fixnums before querying objects" do
2.times do
expect(subject.collection_objects_for_ids(User, [user.id.to_s]))
.to eq([user])
end
end
- it 'queries any additional objects after the first call' do
+ it "queries any additional objects after the first call" do
other_user = create(:user)
expect(subject.collection_objects_for_ids(User, [user.id]))
@@ -303,7 +303,7 @@ describe Banzai::ReferenceParser::BaseParser do
.to eq([user, other_user])
end
- it 'caches objects on a per collection class basis' do
+ it "caches objects on a per collection class basis" do
expect(subject.collection_objects_for_ids(User, [user.id]))
.to eq([user])
@@ -313,12 +313,12 @@ describe Banzai::ReferenceParser::BaseParser do
end
end
- describe '#collection_cache_key' do
- it 'returns the cache key for a Class' do
+ describe "#collection_cache_key" do
+ it "returns the cache key for a Class" do
expect(subject.collection_cache_key(Project)).to eq(Project)
end
- it 'returns the cache key for an ActiveRecord::Relation' do
+ it "returns the cache key for an ActiveRecord::Relation" do
expect(subject.collection_cache_key(Project.all)).to eq(Project)
end
end
diff --git a/spec/lib/banzai/reference_parser/commit_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_parser_spec.rb
index f558dea209f..83eb9fdf08b 100644
--- a/spec/lib/banzai/reference_parser/commit_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/commit_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::CommitParser do
include ReferenceParserHelpers
@@ -8,52 +8,52 @@ describe Banzai::ReferenceParser::CommitParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-commit'] = 123
+ link["data-commit"] = 123
end
it_behaves_like "referenced feature visibility", "repository"
end
end
- describe '#referenced_by' do
- context 'when the link has a data-project attribute' do
+ describe "#referenced_by" do
+ context "when the link has a data-project attribute" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- context 'when the link has a data-commit attribute' do
+ context "when the link has a data-commit attribute" do
before do
- link['data-commit'] = '123'
+ link["data-commit"] = "123"
end
- it 'returns an Array of commits' do
+ it "returns an Array of commits" do
commit = double(:commit)
allow_any_instance_of(Project).to receive(:valid_repo?)
.and_return(true)
expect(subject).to receive(:find_commits)
- .with(project, ['123'])
+ .with(project, ["123"])
.and_return([commit])
expect(subject.referenced_by([link])).to eq([commit])
end
- it 'returns an empty Array when the commit could not be found' do
+ it "returns an empty Array when the commit could not be found" do
allow_any_instance_of(Project).to receive(:valid_repo?)
.and_return(true)
expect(subject).to receive(:find_commits)
- .with(project, ['123'])
+ .with(project, ["123"])
.and_return([])
expect(subject.referenced_by([link])).to eq([])
end
- it 'skips projects without valid repositories' do
+ it "skips projects without valid repositories" do
allow_any_instance_of(Project).to receive(:valid_repo?)
.and_return(false)
@@ -61,8 +61,8 @@ describe Banzai::ReferenceParser::CommitParser do
end
end
- context 'when the link does not have a data-commit attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-commit attribute" do
+ it "returns an empty Array" do
allow_any_instance_of(Project).to receive(:valid_repo?)
.and_return(true)
@@ -71,8 +71,8 @@ describe Banzai::ReferenceParser::CommitParser do
end
end
- context 'when the link does not have a data-project attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-project attribute" do
+ it "returns an empty Array" do
allow_any_instance_of(Project).to receive(:valid_repo?)
.and_return(true)
@@ -81,47 +81,47 @@ describe Banzai::ReferenceParser::CommitParser do
end
end
- describe '#commit_ids_per_project' do
+ describe "#commit_ids_per_project" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- it 'returns a Hash containing commit IDs per project' do
- link['data-commit'] = '123'
+ it "returns a Hash containing commit IDs per project" do
+ link["data-commit"] = "123"
hash = subject.commit_ids_per_project([link])
expect(hash).to be_an_instance_of(Hash)
- expect(hash[project.id].to_a).to eq(['123'])
+ expect(hash[project.id].to_a).to eq(["123"])
end
- it 'does not add a project when the data-commit attribute is empty' do
+ it "does not add a project when the data-commit attribute is empty" do
hash = subject.commit_ids_per_project([link])
expect(hash).to be_empty
end
end
- describe '#find_commits' do
- it 'returns an Array of commit objects' do
+ describe "#find_commits" do
+ it "returns an Array of commit objects" do
commit = double(:commit)
- expect(project).to receive(:commit).with('123').and_return(commit)
+ expect(project).to receive(:commit).with("123").and_return(commit)
expect(project).to receive(:valid_repo?).and_return(true)
- expect(subject.find_commits(project, %w{123})).to eq([commit])
+ expect(subject.find_commits(project, %w[123])).to eq([commit])
end
- it 'skips commit IDs for which no commit could be found' do
- expect(project).to receive(:commit).with('123').and_return(nil)
+ it "skips commit IDs for which no commit could be found" do
+ expect(project).to receive(:commit).with("123").and_return(nil)
expect(project).to receive(:valid_repo?).and_return(true)
- expect(subject.find_commits(project, %w{123})).to eq([])
+ expect(subject.find_commits(project, %w[123])).to eq([])
end
end
- context 'when checking commits on another projects' do
+ context "when checking commits on another projects" do
let(:control_links) do
[commit_link]
end
@@ -133,9 +133,9 @@ describe Banzai::ReferenceParser::CommitParser do
def commit_link
project = create(:project, :repository, :public)
- Nokogiri::HTML.fragment(%Q{<a data-commit="#{project.commit.id}" data-project="#{project.id}"></a>}).children[0]
+ Nokogiri::HTML.fragment(%(<a data-commit="#{project.commit.id}" data-project="#{project.id}"></a>)).children[0]
end
- it_behaves_like 'no project N+1 queries'
+ it_behaves_like "no project N+1 queries"
end
end
diff --git a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
index ff3b82cc482..28d8a6ffa71 100644
--- a/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/commit_range_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::CommitRangeParser do
include ReferenceParserHelpers
@@ -8,128 +8,128 @@ describe Banzai::ReferenceParser::CommitRangeParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-commit-range'] = '123..456'
+ link["data-commit-range"] = "123..456"
end
it_behaves_like "referenced feature visibility", "repository"
end
end
- describe '#referenced_by' do
- context 'when the link has a data-project attribute' do
+ describe "#referenced_by" do
+ context "when the link has a data-project attribute" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- context 'when the link as a data-commit-range attribute' do
+ context "when the link as a data-commit-range attribute" do
before do
- link['data-commit-range'] = '123..456'
+ link["data-commit-range"] = "123..456"
end
- it 'returns an Array of commit ranges' do
+ it "returns an Array of commit ranges" do
range = double(:range)
expect(subject).to receive(:find_object)
- .with(project, '123..456')
+ .with(project, "123..456")
.and_return(range)
expect(subject.referenced_by([link])).to eq([range])
end
- it 'returns an empty Array when the commit range could not be found' do
+ it "returns an empty Array when the commit range could not be found" do
expect(subject).to receive(:find_object)
- .with(project, '123..456')
+ .with(project, "123..456")
.and_return(nil)
expect(subject.referenced_by([link])).to eq([])
end
end
- context 'when the link does not have a data-commit-range attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-commit-range attribute" do
+ it "returns an empty Array" do
expect(subject.referenced_by([link])).to eq([])
end
end
end
- context 'when the link does not have a data-project attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-project attribute" do
+ it "returns an empty Array" do
expect(subject.referenced_by([link])).to eq([])
end
end
end
- describe '#commit_range_ids_per_project' do
+ describe "#commit_range_ids_per_project" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- it 'returns a Hash containing range IDs per project' do
- link['data-commit-range'] = '123..456'
+ it "returns a Hash containing range IDs per project" do
+ link["data-commit-range"] = "123..456"
hash = subject.commit_range_ids_per_project([link])
expect(hash).to be_an_instance_of(Hash)
- expect(hash[project.id].to_a).to eq(['123..456'])
+ expect(hash[project.id].to_a).to eq(["123..456"])
end
- it 'does not add a project when the data-commit-range attribute is empty' do
+ it "does not add a project when the data-commit-range attribute is empty" do
hash = subject.commit_range_ids_per_project([link])
expect(hash).to be_empty
end
end
- describe '#find_ranges' do
- it 'returns an Array of range objects' do
+ describe "#find_ranges" do
+ it "returns an Array of range objects" do
range = double(:commit)
expect(subject).to receive(:find_object)
- .with(project, '123..456')
+ .with(project, "123..456")
.and_return(range)
- expect(subject.find_ranges(project, ['123..456'])).to eq([range])
+ expect(subject.find_ranges(project, ["123..456"])).to eq([range])
end
- it 'skips ranges that could not be found' do
+ it "skips ranges that could not be found" do
expect(subject).to receive(:find_object)
- .with(project, '123..456')
+ .with(project, "123..456")
.and_return(nil)
- expect(subject.find_ranges(project, ['123..456'])).to eq([])
+ expect(subject.find_ranges(project, ["123..456"])).to eq([])
end
end
- describe '#find_object' do
+ describe "#find_object" do
let(:range) { double(:range) }
- context 'when the range has valid commits' do
- it 'returns the commit range' do
+ context "when the range has valid commits" do
+ it "returns the commit range" do
expect(CommitRange).to receive(:new).and_return(range)
expect(range).to receive(:valid_commits?).and_return(true)
- expect(subject.find_object(project, '123..456')).to eq(range)
+ expect(subject.find_object(project, "123..456")).to eq(range)
end
end
- context 'when the range does not have any valid commits' do
- it 'returns nil' do
+ context "when the range does not have any valid commits" do
+ it "returns nil" do
expect(CommitRange).to receive(:new).and_return(range)
expect(range).to receive(:valid_commits?).and_return(false)
- expect(subject.find_object(project, '123..456')).to be_nil
+ expect(subject.find_object(project, "123..456")).to be_nil
end
end
- context 'group context' do
- it 'returns nil' do
+ context "group context" do
+ it "returns nil" do
group = create(:group)
- expect(subject.find_object(group, '123..456')).to be_nil
+ expect(subject.find_object(group, "123..456")).to be_nil
end
end
end
diff --git a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
index 1cb31e57114..e1ad649b1d2 100644
--- a/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/external_issue_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::ExternalIssueParser do
include ReferenceParserHelpers
@@ -8,10 +8,10 @@ describe Banzai::ReferenceParser::ExternalIssueParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-external-issue'] = 123
+ link["data-external-issue"] = 123
end
levels = [ProjectFeature::DISABLED, ProjectFeature::PRIVATE, ProjectFeature::ENABLED]
@@ -28,52 +28,52 @@ describe Banzai::ReferenceParser::ExternalIssueParser do
end
end
- describe '#referenced_by' do
- context 'when the link has a data-project attribute' do
+ describe "#referenced_by" do
+ context "when the link has a data-project attribute" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- context 'when the link has a data-external-issue attribute' do
- it 'returns an Array of ExternalIssue instances' do
- link['data-external-issue'] = '123'
+ context "when the link has a data-external-issue attribute" do
+ it "returns an Array of ExternalIssue instances" do
+ link["data-external-issue"] = "123"
refs = subject.referenced_by([link])
- expect(refs).to eq([ExternalIssue.new('123', project)])
+ expect(refs).to eq([ExternalIssue.new("123", project)])
end
end
- context 'when the link does not have a data-external-issue attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-external-issue attribute" do
+ it "returns an empty Array" do
expect(subject.referenced_by([link])).to eq([])
end
end
end
- context 'when the link does not have a data-project attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-project attribute" do
+ it "returns an empty Array" do
expect(subject.referenced_by([link])).to eq([])
end
end
end
- describe '#issue_ids_per_project' do
+ describe "#issue_ids_per_project" do
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
- it 'returns a Hash containing range IDs per project' do
- link['data-external-issue'] = '123'
+ it "returns a Hash containing range IDs per project" do
+ link["data-external-issue"] = "123"
hash = subject.issue_ids_per_project([link])
expect(hash).to be_an_instance_of(Hash)
- expect(hash[project.id].to_a).to eq(['123'])
+ expect(hash[project.id].to_a).to eq(["123"])
end
- it 'does not add a project when the data-external-issue attribute is empty' do
+ it "does not add a project when the data-external-issue attribute is empty" do
hash = subject.issue_ids_per_project([link])
expect(hash).to be_empty
diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb
index 77c2064caba..b92a7a408af 100644
--- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::IssueParser do
include ReferenceParserHelpers
@@ -9,31 +9,31 @@ describe Banzai::ReferenceParser::IssueParser do
let(:link) { empty_html_link }
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-issue'] = issue.id.to_s
+ link["data-issue"] = issue.id.to_s
end
it_behaves_like "referenced feature visibility", "issues"
- it 'returns the nodes when the user can read the issue' do
+ it "returns the nodes when the user can read the issue" do
expect(Ability).to receive(:issues_readable_by_user)
- .with([issue], user)
- .and_return([issue])
+ .with([issue], user)
+ .and_return([issue])
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
- it 'returns an empty Array when the user can not read the issue' do
+ it "returns an empty Array when the user can not read the issue" do
expect(Ability).to receive(:issues_readable_by_user)
- .with([issue], user)
- .and_return([])
+ .with([issue], user)
+ .and_return([])
expect(subject.nodes_visible_to_user(user, [link])).to eq([])
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
let(:issue) { create(:issue) }
before do
@@ -41,29 +41,29 @@ describe Banzai::ReferenceParser::IssueParser do
allow(Ability).to receive(:allowed?).with(user, :read_cross_project, :global) { false }
end
- it 'returns the nodes when the user can read the issue' do
+ it "returns the nodes when the user can read the issue" do
expect(Ability).to receive(:allowed?)
- .with(user, :read_issue_iid, issue)
- .and_return(true)
+ .with(user, :read_issue_iid, issue)
+ .and_return(true)
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
- it 'returns an empty Array when the user can not read the issue' do
+ it "returns an empty Array when the user can not read the issue" do
expect(Ability).to receive(:allowed?)
- .with(user, :read_issue_iid, issue)
- .and_return(false)
+ .with(user, :read_issue_iid, issue)
+ .and_return(false)
expect(subject.nodes_visible_to_user(user, [link])).to eq([])
end
- context 'when the issue is not cross project' do
+ context "when the issue is not cross project" do
let(:issue) { create(:issue, project: project) }
- it 'does not check `can_read_reference` if the issue is not cross project' do
+ it "does not check `can_read_reference` if the issue is not cross project" do
expect(Ability).to receive(:issues_readable_by_user)
- .with([issue], user)
- .and_return([])
+ .with([issue], user)
+ .and_return([])
expect(subject).not_to receive(:can_read_reference?).with(user, issue)
@@ -73,52 +73,52 @@ describe Banzai::ReferenceParser::IssueParser do
end
end
- context 'when the link does not have a data-issue attribute' do
- it 'returns an empty Array' do
+ context "when the link does not have a data-issue attribute" do
+ it "returns an empty Array" do
expect(subject.nodes_visible_to_user(user, [link])).to eq([])
end
end
end
- describe '#referenced_by' do
- context 'when the link has a data-issue attribute' do
- context 'using an existing issue ID' do
+ describe "#referenced_by" do
+ context "when the link has a data-issue attribute" do
+ context "using an existing issue ID" do
before do
- link['data-issue'] = issue.id.to_s
+ link["data-issue"] = issue.id.to_s
end
- it 'returns an Array of issues' do
+ it "returns an Array of issues" do
expect(subject.referenced_by([link])).to eq([issue])
end
- it 'returns an empty Array when the list of nodes is empty' do
+ it "returns an empty Array when the list of nodes is empty" do
expect(subject.referenced_by([link])).to eq([issue])
expect(subject.referenced_by([])).to eq([])
end
end
- context 'when issue with given ID does not exist' do
+ context "when issue with given ID does not exist" do
before do
- link['data-issue'] = '-1'
+ link["data-issue"] = "-1"
end
- it 'returns an empty Array' do
+ it "returns an empty Array" do
expect(subject.referenced_by([link])).to eq([])
end
end
end
end
- describe '#records_for_nodes' do
- it 'returns a Hash containing the issues for a list of nodes' do
- link['data-issue'] = issue.id.to_s
+ describe "#records_for_nodes" do
+ it "returns a Hash containing the issues for a list of nodes" do
+ link["data-issue"] = issue.id.to_s
nodes = [link]
- expect(subject.records_for_nodes(nodes)).to eq({ link => issue })
+ expect(subject.records_for_nodes(nodes)).to eq({link => issue})
end
end
- context 'when checking multiple merge requests on another project' do
+ context "when checking multiple merge requests on another project" do
let(:other_project) { create(:project, :public) }
let(:other_issue) { create(:issue, project: other_project) }
@@ -131,13 +131,13 @@ describe Banzai::ReferenceParser::IssueParser do
end
def issue_link(issue)
- Nokogiri::HTML.fragment(%Q{<a data-issue="#{issue.id}"></a>}).children[0]
+ Nokogiri::HTML.fragment(%(<a data-issue="#{issue.id}"></a>)).children[0]
end
before do
project.add_developer(user)
end
- it_behaves_like 'no N+1 queries'
+ it_behaves_like "no N+1 queries"
end
end
diff --git a/spec/lib/banzai/reference_parser/label_parser_spec.rb b/spec/lib/banzai/reference_parser/label_parser_spec.rb
index e4df2533821..cc5e1fb1928 100644
--- a/spec/lib/banzai/reference_parser/label_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/label_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::LabelParser do
include ReferenceParserHelpers
@@ -9,29 +9,29 @@ describe Banzai::ReferenceParser::LabelParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-label'] = label.id.to_s
+ link["data-label"] = label.id.to_s
end
it_behaves_like "referenced feature visibility", "issues", "merge_requests"
end
end
- describe '#referenced_by' do
- describe 'when the link has a data-label attribute' do
- context 'using an existing label ID' do
- it 'returns an Array of labels' do
- link['data-label'] = label.id.to_s
+ describe "#referenced_by" do
+ describe "when the link has a data-label attribute" do
+ context "using an existing label ID" do
+ it "returns an Array of labels" do
+ link["data-label"] = label.id.to_s
expect(subject.referenced_by([link])).to eq([label])
end
end
- context 'using a non-existing label ID' do
- it 'returns an empty Array' do
- link['data-label'] = ''
+ context "using a non-existing label ID" do
+ it "returns an empty Array" do
+ link["data-label"] = ""
expect(subject.referenced_by([link])).to eq([])
end
diff --git a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
index 5417b1f00be..f017ed12c2c 100644
--- a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::MergeRequestParser do
include ReferenceParserHelpers
@@ -9,30 +9,30 @@ describe Banzai::ReferenceParser::MergeRequestParser do
subject { described_class.new(Banzai::RenderContext.new(merge_request.target_project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
- link['data-merge-request'] = merge_request.id.to_s
+ link["data-merge-request"] = merge_request.id.to_s
end
it_behaves_like "referenced feature visibility", "merge_requests"
end
end
- describe '#referenced_by' do
- describe 'when the link has a data-merge-request attribute' do
- context 'using an existing merge request ID' do
- it 'returns an Array of merge requests' do
- link['data-merge-request'] = merge_request.id.to_s
+ describe "#referenced_by" do
+ describe "when the link has a data-merge-request attribute" do
+ context "using an existing merge request ID" do
+ it "returns an Array of merge requests" do
+ link["data-merge-request"] = merge_request.id.to_s
expect(subject.referenced_by([link])).to eq([merge_request])
end
end
- context 'using a non-existing merge request ID' do
- it 'returns an empty Array' do
- link['data-merge-request'] = ''
+ context "using a non-existing merge request ID" do
+ it "returns an empty Array" do
+ link["data-merge-request"] = ""
expect(subject.referenced_by([link])).to eq([])
end
@@ -40,7 +40,7 @@ describe Banzai::ReferenceParser::MergeRequestParser do
end
end
- context 'when checking multiple merge requests on another project' do
+ context "when checking multiple merge requests on another project" do
let(:other_project) { create(:project, :public) }
let(:other_merge_request) { create(:merge_request, source_project: other_project) }
@@ -53,13 +53,13 @@ describe Banzai::ReferenceParser::MergeRequestParser do
end
def merge_request_link(merge_request)
- Nokogiri::HTML.fragment(%Q{<a data-merge-request="#{merge_request.id}"></a>}).children[0]
+ Nokogiri::HTML.fragment(%(<a data-merge-request="#{merge_request.id}"></a>)).children[0]
end
before do
project.add_developer(user)
end
- it_behaves_like 'no N+1 queries'
+ it_behaves_like "no N+1 queries"
end
end
diff --git a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
index 751d042ffde..c58a7f24b39 100644
--- a/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/milestone_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::MilestoneParser do
include ReferenceParserHelpers
@@ -9,29 +9,29 @@ describe Banzai::ReferenceParser::MilestoneParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-issue attribute' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-issue attribute" do
before do
- link['data-milestone'] = milestone.id.to_s
+ link["data-milestone"] = milestone.id.to_s
end
it_behaves_like "referenced feature visibility", "issues", "merge_requests"
end
end
- describe '#referenced_by' do
- describe 'when the link has a data-milestone attribute' do
- context 'using an existing milestone ID' do
- it 'returns an Array of milestones' do
- link['data-milestone'] = milestone.id.to_s
+ describe "#referenced_by" do
+ describe "when the link has a data-milestone attribute" do
+ context "using an existing milestone ID" do
+ it "returns an Array of milestones" do
+ link["data-milestone"] = milestone.id.to_s
expect(subject.referenced_by([link])).to eq([milestone])
end
end
- context 'using a non-existing milestone ID' do
- it 'returns an empty Array' do
- link['data-milestone'] = ''
+ context "using a non-existing milestone ID" do
+ it "returns an empty Array" do
+ link["data-milestone"] = ""
expect(subject.referenced_by([link])).to eq([])
end
diff --git a/spec/lib/banzai/reference_parser/project_parser_spec.rb b/spec/lib/banzai/reference_parser/project_parser_spec.rb
index e4936aa9e57..1143728ff00 100644
--- a/spec/lib/banzai/reference_parser/project_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/project_parser_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::ProjectParser do
include ReferenceParserHelpers
@@ -10,37 +10,37 @@ describe Banzai::ReferenceParser::ProjectParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#referenced_by' do
- describe 'when the link has a data-project attribute' do
- context 'using an existing project ID' do
- it 'returns an Array of projects' do
- link['data-project'] = project.id.to_s
+ describe "#referenced_by" do
+ describe "when the link has a data-project attribute" do
+ context "using an existing project ID" do
+ it "returns an Array of projects" do
+ link["data-project"] = project.id.to_s
expect(subject.gather_references([link])).to eq([project])
end
end
- context 'using a non-existing project ID' do
- it 'returns an empty Array' do
- link['data-project'] = ''
+ context "using a non-existing project ID" do
+ it "returns an empty Array" do
+ link["data-project"] = ""
expect(subject.gather_references([link])).to eq([])
end
end
- context 'using a private project ID' do
- it 'returns an empty Array when unauthorized' do
+ context "using a private project ID" do
+ it "returns an empty Array when unauthorized" do
private_project = create(:project, :private)
- link['data-project'] = private_project.id.to_s
+ link["data-project"] = private_project.id.to_s
expect(subject.gather_references([link])).to eq([])
end
- it 'returns an Array when authorized' do
+ it "returns an Array when authorized" do
private_project = create(:project, :private, namespace: user.namespace)
- link['data-project'] = private_project.id.to_s
+ link["data-project"] = private_project.id.to_s
expect(subject.gather_references([link])).to eq([private_project])
end
diff --git a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
index d410bd4c164..749e5505c33 100644
--- a/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/snippet_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::SnippetParser do
include ReferenceParserHelpers
@@ -14,8 +14,8 @@ describe Banzai::ReferenceParser::SnippetParser do
def visible_references(snippet_visibility, user = nil)
snippet = create(:project_snippet, snippet_visibility, project: project)
- link['data-project'] = project.id.to_s
- link['data-snippet'] = snippet.id.to_s
+ link["data-project"] = project.id.to_s
+ link["data-snippet"] = snippet.id.to_s
subject.nodes_visible_to_user(user, [link])
end
@@ -24,191 +24,191 @@ describe Banzai::ReferenceParser::SnippetParser do
project.add_user(project_member, :developer)
end
- describe '#nodes_visible_to_user' do
- context 'when a project is public and the snippets feature is enabled for everyone' do
+ describe "#nodes_visible_to_user" do
+ context "when a project is public and the snippets feature is enabled for everyone" do
before do
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::ENABLED)
end
- it 'creates a reference for guest for a public snippet' do
+ it "creates a reference for guest for a public snippet" do
expect(visible_references(:public)).to eq([link])
end
- it 'creates a reference for a regular user for a public snippet' do
+ it "creates a reference for a regular user for a public snippet" do
expect(visible_references(:public, user)).to eq([link])
end
- it 'creates a reference for a regular user for an internal snippet' do
+ it "creates a reference for a regular user for an internal snippet" do
expect(visible_references(:internal, user)).to eq([link])
end
- it 'does not create a reference for an external user for an internal snippet' do
+ it "does not create a reference for an external user for an internal snippet" do
expect(visible_references(:internal, external_user)).to be_empty
end
- it 'creates a reference for a project member for a private snippet' do
+ it "creates a reference for a project member for a private snippet" do
expect(visible_references(:private, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for a private snippet' do
+ it "does not create a reference for a regular user for a private snippet" do
expect(visible_references(:private, user)).to be_empty
end
end
- context 'when a project is public and the snippets feature is enabled for project team members' do
+ context "when a project is public and the snippets feature is enabled for project team members" do
before do
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::PRIVATE)
end
- it 'creates a reference for a project member for a public snippet' do
+ it "creates a reference for a project member for a public snippet" do
expect(visible_references(:public, project_member)).to eq([link])
end
- it 'does not create a reference for guest for a public snippet' do
+ it "does not create a reference for guest for a public snippet" do
expect(visible_references(:public, nil)).to be_empty
end
- it 'does not create a reference for a regular user for a public snippet' do
+ it "does not create a reference for a regular user for a public snippet" do
expect(visible_references(:public, user)).to be_empty
end
- it 'creates a reference for a project member for an internal snippet' do
+ it "creates a reference for a project member for an internal snippet" do
expect(visible_references(:internal, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for an internal snippet' do
+ it "does not create a reference for a regular user for an internal snippet" do
expect(visible_references(:internal, user)).to be_empty
end
- it 'creates a reference for a project member for a private snippet' do
+ it "creates a reference for a project member for a private snippet" do
expect(visible_references(:private, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for a private snippet' do
+ it "does not create a reference for a regular user for a private snippet" do
expect(visible_references(:private, user)).to be_empty
end
end
- context 'when a project is internal and the snippets feature is enabled for everyone' do
+ context "when a project is internal and the snippets feature is enabled for everyone" do
before do
project.update_attribute(:visibility, Gitlab::VisibilityLevel::INTERNAL)
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::ENABLED)
end
- it 'does not create a reference for guest for a public snippet' do
+ it "does not create a reference for guest for a public snippet" do
expect(visible_references(:public)).to be_empty
end
- it 'does not create a reference for an external user for a public snippet' do
+ it "does not create a reference for an external user for a public snippet" do
expect(visible_references(:public, external_user)).to be_empty
end
- it 'creates a reference for a regular user for a public snippet' do
+ it "creates a reference for a regular user for a public snippet" do
expect(visible_references(:public, user)).to eq([link])
end
- it 'creates a reference for a regular user for an internal snippet' do
+ it "creates a reference for a regular user for an internal snippet" do
expect(visible_references(:internal, user)).to eq([link])
end
- it 'does not create a reference for an external user for an internal snippet' do
+ it "does not create a reference for an external user for an internal snippet" do
expect(visible_references(:internal, external_user)).to be_empty
end
- it 'creates a reference for a project member for a private snippet' do
+ it "creates a reference for a project member for a private snippet" do
expect(visible_references(:private, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for a private snippet' do
+ it "does not create a reference for a regular user for a private snippet" do
expect(visible_references(:private, user)).to be_empty
end
end
- context 'when a project is internal and the snippets feature is enabled for project team members' do
+ context "when a project is internal and the snippets feature is enabled for project team members" do
before do
project.update_attribute(:visibility, Gitlab::VisibilityLevel::INTERNAL)
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::PRIVATE)
end
- it 'creates a reference for a project member for a public snippet' do
+ it "creates a reference for a project member for a public snippet" do
expect(visible_references(:public, project_member)).to eq([link])
end
- it 'does not create a reference for guest for a public snippet' do
+ it "does not create a reference for guest for a public snippet" do
expect(visible_references(:public, nil)).to be_empty
end
- it 'does not create reference for a regular user for a public snippet' do
+ it "does not create reference for a regular user for a public snippet" do
expect(visible_references(:public, user)).to be_empty
end
- it 'creates a reference for a project member for an internal snippet' do
+ it "creates a reference for a project member for an internal snippet" do
expect(visible_references(:internal, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for an internal snippet' do
+ it "does not create a reference for a regular user for an internal snippet" do
expect(visible_references(:internal, user)).to be_empty
end
- it 'creates a reference for a project member for a private snippet' do
+ it "creates a reference for a project member for a private snippet" do
expect(visible_references(:private, project_member)).to eq([link])
end
- it 'does not create reference for a regular user for a private snippet' do
+ it "does not create reference for a regular user for a private snippet" do
expect(visible_references(:private, user)).to be_empty
end
end
- context 'when a project is private and the snippets feature is enabled for project team members' do
+ context "when a project is private and the snippets feature is enabled for project team members" do
before do
project.update_attribute(:visibility, Gitlab::VisibilityLevel::PRIVATE)
project.project_feature.update_attribute(:snippets_access_level, ProjectFeature::PRIVATE)
end
- it 'creates a reference for a project member for a public snippet' do
+ it "creates a reference for a project member for a public snippet" do
expect(visible_references(:public, project_member)).to eq([link])
end
- it 'does not create a reference for guest for a public snippet' do
+ it "does not create a reference for guest for a public snippet" do
expect(visible_references(:public, nil)).to be_empty
end
- it 'does not create a reference for a regular user for a public snippet' do
+ it "does not create a reference for a regular user for a public snippet" do
expect(visible_references(:public, user)).to be_empty
end
- it 'creates a reference for a project member for an internal snippet' do
+ it "creates a reference for a project member for an internal snippet" do
expect(visible_references(:internal, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for an internal snippet' do
+ it "does not create a reference for a regular user for an internal snippet" do
expect(visible_references(:internal, user)).to be_empty
end
- it 'creates a reference for a project member for a private snippet' do
+ it "creates a reference for a project member for a private snippet" do
expect(visible_references(:private, project_member)).to eq([link])
end
- it 'does not create a reference for a regular user for a private snippet' do
+ it "does not create a reference for a regular user for a private snippet" do
expect(visible_references(:private, user)).to be_empty
end
end
end
- describe '#referenced_by' do
+ describe "#referenced_by" do
let(:snippet) { create(:snippet, project: project) }
- describe 'when the link has a data-snippet attribute' do
- context 'using an existing snippet ID' do
- it 'returns an Array of snippets' do
- link['data-snippet'] = snippet.id.to_s
+ describe "when the link has a data-snippet attribute" do
+ context "using an existing snippet ID" do
+ it "returns an Array of snippets" do
+ link["data-snippet"] = snippet.id.to_s
expect(subject.referenced_by([link])).to eq([snippet])
end
end
- context 'using a non-existing snippet ID' do
- it 'returns an empty Array' do
- link['data-snippet'] = ''
+ context "using a non-existing snippet ID" do
+ it "returns an empty Array" do
+ link["data-snippet"] = ""
expect(subject.referenced_by([link])).to be_empty
end
diff --git a/spec/lib/banzai/reference_parser/user_parser_spec.rb b/spec/lib/banzai/reference_parser/user_parser_spec.rb
index 112447f098e..47512c7d793 100644
--- a/spec/lib/banzai/reference_parser/user_parser_spec.rb
+++ b/spec/lib/banzai/reference_parser/user_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::ReferenceParser::UserParser do
include ReferenceParserHelpers
@@ -9,57 +9,57 @@ describe Banzai::ReferenceParser::UserParser do
subject { described_class.new(Banzai::RenderContext.new(project, user)) }
let(:link) { empty_html_link }
- describe '#referenced_by' do
- context 'when the link has a data-group attribute' do
- context 'using an existing group ID' do
+ describe "#referenced_by" do
+ context "when the link has a data-group attribute" do
+ context "using an existing group ID" do
before do
- link['data-group'] = project.group.id.to_s
+ link["data-group"] = project.group.id.to_s
end
- it 'returns the users of the group' do
+ it "returns the users of the group" do
create(:group_member, group: group, user: user)
expect(subject.referenced_by([link])).to eq([user])
end
- it 'returns an empty Array when the group has no users' do
+ it "returns an empty Array when the group has no users" do
expect(subject.referenced_by([link])).to eq([])
end
end
- context 'using a non-existing group ID' do
- it 'returns an empty Array' do
- link['data-group'] = ''
+ context "using a non-existing group ID" do
+ it "returns an empty Array" do
+ link["data-group"] = ""
expect(subject.referenced_by([link])).to eq([])
end
end
end
- context 'when the link has a data-user attribute' do
- it 'returns an Array of users' do
- link['data-user'] = user.id.to_s
+ context "when the link has a data-user attribute" do
+ it "returns an Array of users" do
+ link["data-user"] = user.id.to_s
expect(subject.referenced_by([link])).to eq([user])
end
- context 'when RequestStore is active', :request_store do
+ context "when RequestStore is active", :request_store do
let(:other_user) { create(:user) }
- it 'does not return users from the first call in the second' do
- link['data-user'] = user.id.to_s
+ it "does not return users from the first call in the second" do
+ link["data-user"] = user.id.to_s
expect(subject.referenced_by([link])).to eq([user])
- link['data-user'] = other_user.id.to_s
+ link["data-user"] = other_user.id.to_s
expect(subject.referenced_by([link])).to eq([other_user])
end
end
end
- context 'when the link has a data-project attribute' do
- context 'using an existing project ID' do
+ context "when the link has a data-project attribute" do
+ context "using an existing project ID" do
let(:contributor) { create(:user) }
before do
@@ -67,8 +67,8 @@ describe Banzai::ReferenceParser::UserParser do
project.add_developer(contributor)
end
- it 'returns the members of a project' do
- link['data-project'] = project.id.to_s
+ it "returns the members of a project" do
+ link["data-project"] = project.id.to_s
# This uses an explicit sort to make sure this spec doesn't randomly
# fail when objects are returned in a different order.
@@ -78,9 +78,9 @@ describe Banzai::ReferenceParser::UserParser do
end
end
- context 'using a non-existing project ID' do
- it 'returns an empty Array' do
- link['data-project'] = ''
+ context "using a non-existing project ID" do
+ it "returns an empty Array" do
+ link["data-project"] = ""
expect(subject.referenced_by([link])).to eq([])
end
@@ -88,14 +88,14 @@ describe Banzai::ReferenceParser::UserParser do
end
end
- describe '#nodes_visible_to_user' do
- context 'when the link has a data-group attribute' do
- context 'using an existing group ID' do
+ describe "#nodes_visible_to_user" do
+ context "when the link has a data-group attribute" do
+ context "using an existing group ID" do
before do
- link['data-group'] = group.id.to_s
+ link["data-group"] = group.id.to_s
end
- it 'returns the nodes if the user can read the group' do
+ it "returns the nodes if the user can read the group" do
expect(Ability).to receive(:allowed?)
.with(user, :read_group, group)
.and_return(true)
@@ -103,7 +103,7 @@ describe Banzai::ReferenceParser::UserParser do
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
- it 'returns an empty Array if the user can not read the group' do
+ it "returns an empty Array if the user can not read the group" do
expect(Ability).to receive(:allowed?)
.with(user, :read_group, group)
.and_return(false)
@@ -112,10 +112,10 @@ describe Banzai::ReferenceParser::UserParser do
end
end
- context 'when the link does not have a data-group attribute' do
- context 'with a data-project attribute' do
- it 'returns the nodes if the attribute value equals the current project ID' do
- link['data-project'] = project.id.to_s
+ context "when the link does not have a data-group attribute" do
+ context "with a data-project attribute" do
+ it "returns the nodes if the attribute value equals the current project ID" do
+ link["data-project"] = project.id.to_s
# Ensure that we dont call for Ability.allowed?
# When project_id in the node is equal to current project ID
@@ -124,10 +124,10 @@ describe Banzai::ReferenceParser::UserParser do
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
- it 'returns the nodes if the user can read the project' do
+ it "returns the nodes if the user can read the project" do
other_project = create(:project, :public)
- link['data-project'] = other_project.id.to_s
+ link["data-project"] = other_project.id.to_s
expect(Ability).to receive(:allowed?)
.with(user, :read_project, other_project)
@@ -136,10 +136,10 @@ describe Banzai::ReferenceParser::UserParser do
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
- it 'returns an empty Array if the user can not read the project' do
+ it "returns an empty Array if the user can not read the project" do
other_project = create(:project, :public)
- link['data-project'] = other_project.id.to_s
+ link["data-project"] = other_project.id.to_s
expect(Ability).to receive(:allowed?)
.with(user, :read_project, other_project)
@@ -149,8 +149,8 @@ describe Banzai::ReferenceParser::UserParser do
end
end
- context 'without a data-project attribute' do
- it 'returns the nodes' do
+ context "without a data-project attribute" do
+ it "returns the nodes" do
expect(subject.nodes_visible_to_user(user, [link])).to eq([link])
end
end
@@ -158,55 +158,55 @@ describe Banzai::ReferenceParser::UserParser do
end
end
- describe '#nodes_user_can_reference' do
- context 'when the link has a data-author attribute' do
- it 'returns the nodes when the user is a member of the project' do
+ describe "#nodes_user_can_reference" do
+ context "when the link has a data-author attribute" do
+ it "returns the nodes when the user is a member of the project" do
other_project = create(:project)
other_project.add_developer(user)
- link['data-project'] = other_project.id.to_s
- link['data-author'] = user.id.to_s
+ link["data-project"] = other_project.id.to_s
+ link["data-author"] = user.id.to_s
expect(subject.nodes_user_can_reference(user, [link])).to eq([link])
end
- it 'returns an empty Array when the project could not be found' do
- link['data-project'] = ''
- link['data-author'] = user.id.to_s
+ it "returns an empty Array when the project could not be found" do
+ link["data-project"] = ""
+ link["data-author"] = user.id.to_s
expect(subject.nodes_user_can_reference(user, [link])).to eq([])
end
- it 'returns an empty Array when the user could not be found' do
+ it "returns an empty Array when the user could not be found" do
other_project = create(:project)
- link['data-project'] = other_project.id.to_s
- link['data-author'] = ''
+ link["data-project"] = other_project.id.to_s
+ link["data-author"] = ""
expect(subject.nodes_user_can_reference(user, [link])).to eq([])
end
- it 'returns an empty Array when the user is not a team member' do
+ it "returns an empty Array when the user is not a team member" do
other_project = create(:project)
- link['data-project'] = other_project.id.to_s
- link['data-author'] = user.id.to_s
+ link["data-project"] = other_project.id.to_s
+ link["data-author"] = user.id.to_s
expect(subject.nodes_user_can_reference(user, [link])).to eq([])
end
- it 'returns the nodes if the project attribute value equals the current project ID' do
+ it "returns the nodes if the project attribute value equals the current project ID" do
other_user = create(:user)
- link['data-project'] = project.id.to_s
- link['data-author'] = other_user.id.to_s
+ link["data-project"] = project.id.to_s
+ link["data-author"] = other_user.id.to_s
expect(subject.nodes_user_can_reference(user, [link])).to eq([link])
end
end
- context 'when the link does not have a data-author attribute' do
- it 'returns the nodes' do
+ context "when the link does not have a data-author attribute" do
+ it "returns the nodes" do
expect(subject.nodes_user_can_reference(user, [link])).to eq([link])
end
end
diff --git a/spec/lib/banzai/render_context_spec.rb b/spec/lib/banzai/render_context_spec.rb
index ad17db11613..667418b6074 100644
--- a/spec/lib/banzai/render_context_spec.rb
+++ b/spec/lib/banzai/render_context_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::RenderContext do
- let(:document) { Nokogiri::HTML.fragment('<p>hello</p>') }
+ let(:document) { Nokogiri::HTML.fragment("<p>hello</p>") }
- describe '#project_for_node' do
- it 'returns the default project if no associated project was found' do
- project = instance_double('project')
+ describe "#project_for_node" do
+ it "returns the default project if no associated project was found" do
+ project = instance_double("project")
context = described_class.new(project)
expect(context.project_for_node(document)).to eq(project)
end
- it 'returns the associated project if one was associated explicitly' do
- project = instance_double('project')
- obj = instance_double('object', project: project)
+ it "returns the associated project if one was associated explicitly" do
+ project = instance_double("project")
+ obj = instance_double("object", project: project)
context = described_class.new
context.associate_document(document, obj)
@@ -23,9 +23,9 @@ describe Banzai::RenderContext do
expect(context.project_for_node(document)).to eq(project)
end
- it 'returns the project associated with a DocumentFragment when using a node' do
- project = instance_double('project')
- obj = instance_double('object', project: project)
+ it "returns the project associated with a DocumentFragment when using a node" do
+ project = instance_double("project")
+ obj = instance_double("object", project: project)
context = described_class.new
node = document.children.first
diff --git a/spec/lib/banzai/renderer_spec.rb b/spec/lib/banzai/renderer_spec.rb
index 650cecfc778..e15ed417393 100644
--- a/spec/lib/banzai/renderer_spec.rb
+++ b/spec/lib/banzai/renderer_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
describe Banzai::Renderer do
def fake_object(fresh:)
- object = double('object')
+ object = double("object")
allow(object).to receive(:respond_to?).with(:cached_markdown_fields).and_return(true)
allow(object).to receive(:cached_html_up_to_date?).with(:field).and_return(fresh)
- allow(object).to receive(:cached_html_for).with(:field).and_return('field_html')
+ allow(object).to receive(:cached_html_for).with(:field).and_return("field_html")
object
end
- describe '#render_field' do
+ describe "#render_field" do
let(:renderer) { described_class }
- context 'without cache' do
+ context "without cache" do
let(:commit) { create(:project, :repository).commit }
- it 'returns cacheless render field' do
+ it "returns cacheless render field" do
expect(renderer).to receive(:cacheless_render_field).with(commit, :title, {})
renderer.render_field(commit, :title)
end
end
- context 'with cache' do
+ context "with cache" do
subject { renderer.render_field(object, :field) }
- context 'with a stale cache' do
+ context "with a stale cache" do
let(:object) { fake_object(fresh: false) }
- it 'caches and returns the result' do
+ it "caches and returns the result" do
expect(object).to receive(:refresh_markdown_cache!)
- is_expected.to eq('field_html')
+ is_expected.to eq("field_html")
end
it "skips database caching on a GitLab read-only instance" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(object).to receive(:refresh_markdown_cache!)
- is_expected.to eq('field_html')
+ is_expected.to eq("field_html")
end
end
- context 'with an up-to-date cache' do
+ context "with an up-to-date cache" do
let(:object) { fake_object(fresh: true) }
- it 'uses the cache' do
+ it "uses the cache" do
expect(object).to receive(:refresh_markdown_cache!).never
- is_expected.to eq('field_html')
+ is_expected.to eq("field_html")
end
end
end
diff --git a/spec/lib/banzai/suggestions_parser_spec.rb b/spec/lib/banzai/suggestions_parser_spec.rb
index 79658d710ce..5d36d02f08a 100644
--- a/spec/lib/banzai/suggestions_parser_spec.rb
+++ b/spec/lib/banzai/suggestions_parser_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Banzai::SuggestionsParser do
- describe '.parse' do
- it 'returns a list of suggestion contents' do
+ describe ".parse" do
+ it "returns a list of suggestion contents" do
markdown = <<-MARKDOWN.strip_heredoc
```suggestion
foo
@@ -26,7 +26,7 @@ describe Banzai::SuggestionsParser do
MARKDOWN
expect(described_class.parse(markdown)).to eq([" foo\n bar",
- " xpto\n baz"])
+ " xpto\n baz",])
end
end
end
diff --git a/spec/lib/bitbucket/collection_spec.rb b/spec/lib/bitbucket/collection_spec.rb
index 9008cb3e870..cdc86f710b5 100644
--- a/spec/lib/bitbucket/collection_spec.rb
+++ b/spec/lib/bitbucket/collection_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Emulates paginator. It returns 2 pages with results
class TestPaginator
@@ -19,6 +19,6 @@ describe Bitbucket::Collection do
it "iterates paginator" do
collection = described_class.new(TestPaginator.new)
- expect(collection.to_a).to match(%w(result_1_page_1 result_2_page_1 result_1_page_2 result_2_page_2))
+ expect(collection.to_a).to match(%w[result_1_page_1 result_2_page_1 result_1_page_2 result_2_page_2])
end
end
diff --git a/spec/lib/bitbucket/connection_spec.rb b/spec/lib/bitbucket/connection_spec.rb
index 14faeb231a9..c547a80485d 100644
--- a/spec/lib/bitbucket/connection_spec.rb
+++ b/spec/lib/bitbucket/connection_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Connection do
before do
- allow_any_instance_of(described_class).to receive(:provider).and_return(double(app_id: '', app_secret: ''))
+ allow_any_instance_of(described_class).to receive(:provider).and_return(double(app_id: "", app_secret: ""))
end
- describe '#get' do
- it 'calls OAuth2::AccessToken::get' do
+ describe "#get" do
+ it "calls OAuth2::AccessToken::get" do
expect_any_instance_of(OAuth2::AccessToken).to receive(:get).and_return(double(parsed: true))
connection = described_class.new({})
- connection.get('/users')
+ connection.get("/users")
end
end
- describe '#expired?' do
- it 'calls connection.expired?' do
+ describe "#expired?" do
+ it "calls connection.expired?" do
expect_any_instance_of(OAuth2::AccessToken).to receive(:expired?).and_return(true)
expect(described_class.new({}).expired?).to be_truthy
end
end
- describe '#refresh!' do
- it 'calls connection.refresh!' do
+ describe "#refresh!" do
+ it "calls connection.refresh!" do
response = double(token: nil, expires_at: nil, expires_in: nil, refresh_token: nil)
expect_any_instance_of(OAuth2::AccessToken).to receive(:refresh!).and_return(response)
diff --git a/spec/lib/bitbucket/page_spec.rb b/spec/lib/bitbucket/page_spec.rb
index 04d5a0470b1..11eca8849f7 100644
--- a/spec/lib/bitbucket/page_spec.rb
+++ b/spec/lib/bitbucket/page_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Page do
- let(:response) { { 'values' => [{ 'username' => 'Ben' }], 'pagelen' => 2, 'next' => '' } }
+ let(:response) { {"values" => [{"username" => "Ben"}], "pagelen" => 2, "next" => ""} }
before do
# Autoloading hack
Bitbucket::Representation::User.new({})
end
- describe '#items' do
- it 'returns collection of needed objects' do
+ describe "#items" do
+ it "returns collection of needed objects" do
page = described_class.new(response, :user)
expect(page.items.first).to be_a(Bitbucket::Representation::User)
@@ -17,34 +17,34 @@ describe Bitbucket::Page do
end
end
- describe '#attrs' do
- it 'returns attributes' do
+ describe "#attrs" do
+ it "returns attributes" do
page = described_class.new(response, :user)
expect(page.attrs.keys).to include(:pagelen, :next)
end
end
- describe '#next?' do
- it 'returns true' do
+ describe "#next?" do
+ it "returns true" do
page = described_class.new(response, :user)
expect(page.next?).to be_truthy
end
- it 'returns false' do
- response['next'] = nil
+ it "returns false" do
+ response["next"] = nil
page = described_class.new(response, :user)
expect(page.next?).to be_falsey
end
end
- describe '#next' do
- it 'returns next attribute' do
+ describe "#next" do
+ it "returns next attribute" do
page = described_class.new(response, :user)
- expect(page.next).to eq('')
+ expect(page.next).to eq("")
end
end
end
diff --git a/spec/lib/bitbucket/paginator_spec.rb b/spec/lib/bitbucket/paginator_spec.rb
index bdf10a5e2a2..f583e8a2f82 100644
--- a/spec/lib/bitbucket/paginator_spec.rb
+++ b/spec/lib/bitbucket/paginator_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Paginator do
- let(:last_page) { double(:page, next?: false, items: ['item_2']) }
- let(:first_page) { double(:page, next?: true, next: last_page, items: ['item_1']) }
+ let(:last_page) { double(:page, next?: false, items: ["item_2"]) }
+ let(:first_page) { double(:page, next?: true, next: last_page, items: ["item_1"]) }
- describe 'items' do
- it 'return items and raises StopIteration in the end' do
+ describe "items" do
+ it "return items and raises StopIteration in the end" do
paginator = described_class.new(nil, nil, nil)
allow(paginator).to receive(:fetch_next_page).and_return(first_page)
- expect(paginator.items).to match(['item_1'])
+ expect(paginator.items).to match(["item_1"])
allow(paginator).to receive(:fetch_next_page).and_return(last_page)
- expect(paginator.items).to match(['item_2'])
+ expect(paginator.items).to match(["item_2"])
allow(paginator).to receive(:fetch_next_page).and_return(nil)
expect { paginator.items }.to raise_error(StopIteration)
diff --git a/spec/lib/bitbucket/representation/comment_spec.rb b/spec/lib/bitbucket/representation/comment_spec.rb
index fec243a9f96..8d940c6a26b 100644
--- a/spec/lib/bitbucket/representation/comment_spec.rb
+++ b/spec/lib/bitbucket/representation/comment_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::Comment do
- describe '#author' do
- it { expect(described_class.new('user' => { 'username' => 'Ben' }).author).to eq('Ben') }
+ describe "#author" do
+ it { expect(described_class.new("user" => {"username" => "Ben"}).author).to eq("Ben") }
it { expect(described_class.new({}).author).to be_nil }
end
- describe '#note' do
- it { expect(described_class.new('content' => { 'raw' => 'Text' }).note).to eq('Text') }
+ describe "#note" do
+ it { expect(described_class.new("content" => {"raw" => "Text"}).note).to eq("Text") }
it { expect(described_class.new({}).note).to be_nil }
end
- describe '#created_at' do
- it { expect(described_class.new('created_on' => Date.today).created_at).to eq(Date.today) }
+ describe "#created_at" do
+ it { expect(described_class.new("created_on" => Date.today).created_at).to eq(Date.today) }
end
- describe '#updated_at' do
- it { expect(described_class.new('updated_on' => Date.today).updated_at).to eq(Date.today) }
- it { expect(described_class.new('created_on' => Date.today).updated_at).to eq(Date.today) }
+ describe "#updated_at" do
+ it { expect(described_class.new("updated_on" => Date.today).updated_at).to eq(Date.today) }
+ it { expect(described_class.new("created_on" => Date.today).updated_at).to eq(Date.today) }
end
end
diff --git a/spec/lib/bitbucket/representation/issue_spec.rb b/spec/lib/bitbucket/representation/issue_spec.rb
index 20f47224aa8..314b8733245 100644
--- a/spec/lib/bitbucket/representation/issue_spec.rb
+++ b/spec/lib/bitbucket/representation/issue_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::Issue do
- describe '#iid' do
- it { expect(described_class.new('id' => 1).iid).to eq(1) }
+ describe "#iid" do
+ it { expect(described_class.new("id" => 1).iid).to eq(1) }
end
- describe '#kind' do
- it { expect(described_class.new('kind' => 'bug').kind).to eq('bug') }
+ describe "#kind" do
+ it { expect(described_class.new("kind" => "bug").kind).to eq("bug") }
end
- describe '#milestone' do
- it { expect(described_class.new({ 'milestone' => { 'name' => '1.0' } }).milestone).to eq('1.0') }
+ describe "#milestone" do
+ it { expect(described_class.new({"milestone" => {"name" => "1.0"}}).milestone).to eq("1.0") }
it { expect(described_class.new({}).milestone).to be_nil }
end
- describe '#author' do
- it { expect(described_class.new({ 'reporter' => { 'username' => 'Ben' } }).author).to eq('Ben') }
+ describe "#author" do
+ it { expect(described_class.new({"reporter" => {"username" => "Ben"}}).author).to eq("Ben") }
it { expect(described_class.new({}).author).to be_nil }
end
- describe '#description' do
- it { expect(described_class.new({ 'content' => { 'raw' => 'Text' } }).description).to eq('Text') }
+ describe "#description" do
+ it { expect(described_class.new({"content" => {"raw" => "Text"}}).description).to eq("Text") }
it { expect(described_class.new({}).description).to be_nil }
end
- describe '#state' do
- it { expect(described_class.new({ 'state' => 'invalid' }).state).to eq('closed') }
- it { expect(described_class.new({ 'state' => 'wontfix' }).state).to eq('closed') }
- it { expect(described_class.new({ 'state' => 'resolved' }).state).to eq('closed') }
- it { expect(described_class.new({ 'state' => 'duplicate' }).state).to eq('closed') }
- it { expect(described_class.new({ 'state' => 'closed' }).state).to eq('closed') }
- it { expect(described_class.new({ 'state' => 'opened' }).state).to eq('opened') }
+ describe "#state" do
+ it { expect(described_class.new({"state" => "invalid"}).state).to eq("closed") }
+ it { expect(described_class.new({"state" => "wontfix"}).state).to eq("closed") }
+ it { expect(described_class.new({"state" => "resolved"}).state).to eq("closed") }
+ it { expect(described_class.new({"state" => "duplicate"}).state).to eq("closed") }
+ it { expect(described_class.new({"state" => "closed"}).state).to eq("closed") }
+ it { expect(described_class.new({"state" => "opened"}).state).to eq("opened") }
end
- describe '#title' do
- it { expect(described_class.new('title' => 'Issue').title).to eq('Issue') }
+ describe "#title" do
+ it { expect(described_class.new("title" => "Issue").title).to eq("Issue") }
end
- describe '#created_at' do
- it { expect(described_class.new('created_on' => Date.today).created_at).to eq(Date.today) }
+ describe "#created_at" do
+ it { expect(described_class.new("created_on" => Date.today).created_at).to eq(Date.today) }
end
- describe '#updated_at' do
- it { expect(described_class.new('edited_on' => Date.today).updated_at).to eq(Date.today) }
+ describe "#updated_at" do
+ it { expect(described_class.new("edited_on" => Date.today).updated_at).to eq(Date.today) }
end
end
diff --git a/spec/lib/bitbucket/representation/pull_request_comment_spec.rb b/spec/lib/bitbucket/representation/pull_request_comment_spec.rb
index 673dcf22ce8..9b9b70c713b 100644
--- a/spec/lib/bitbucket/representation/pull_request_comment_spec.rb
+++ b/spec/lib/bitbucket/representation/pull_request_comment_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::PullRequestComment do
- describe '#iid' do
- it { expect(described_class.new('id' => 1).iid).to eq(1) }
+ describe "#iid" do
+ it { expect(described_class.new("id" => 1).iid).to eq(1) }
end
- describe '#file_path' do
- it { expect(described_class.new('inline' => { 'path' => '/path' }).file_path).to eq('/path') }
+ describe "#file_path" do
+ it { expect(described_class.new("inline" => {"path" => "/path"}).file_path).to eq("/path") }
end
- describe '#old_pos' do
- it { expect(described_class.new('inline' => { 'from' => 3 }).old_pos).to eq(3) }
+ describe "#old_pos" do
+ it { expect(described_class.new("inline" => {"from" => 3}).old_pos).to eq(3) }
end
- describe '#new_pos' do
- it { expect(described_class.new('inline' => { 'to' => 3 }).new_pos).to eq(3) }
+ describe "#new_pos" do
+ it { expect(described_class.new("inline" => {"to" => 3}).new_pos).to eq(3) }
end
- describe '#parent_id' do
- it { expect(described_class.new({ 'parent' => { 'id' => 2 } }).parent_id).to eq(2) }
+ describe "#parent_id" do
+ it { expect(described_class.new({"parent" => {"id" => 2}}).parent_id).to eq(2) }
it { expect(described_class.new({}).parent_id).to be_nil }
end
- describe '#inline?' do
- it { expect(described_class.new('inline' => {}).inline?).to be_truthy }
+ describe "#inline?" do
+ it { expect(described_class.new("inline" => {}).inline?).to be_truthy }
it { expect(described_class.new({}).inline?).to be_falsey }
end
- describe '#has_parent?' do
- it { expect(described_class.new('parent' => {}).has_parent?).to be_truthy }
+ describe "#has_parent?" do
+ it { expect(described_class.new("parent" => {}).has_parent?).to be_truthy }
it { expect(described_class.new({}).has_parent?).to be_falsey }
end
end
diff --git a/spec/lib/bitbucket/representation/pull_request_spec.rb b/spec/lib/bitbucket/representation/pull_request_spec.rb
index 30453528be4..60e15f39c85 100644
--- a/spec/lib/bitbucket/representation/pull_request_spec.rb
+++ b/spec/lib/bitbucket/representation/pull_request_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::PullRequest do
- describe '#iid' do
- it { expect(described_class.new('id' => 1).iid).to eq(1) }
+ describe "#iid" do
+ it { expect(described_class.new("id" => 1).iid).to eq(1) }
end
- describe '#author' do
- it { expect(described_class.new({ 'author' => { 'username' => 'Ben' } }).author).to eq('Ben') }
+ describe "#author" do
+ it { expect(described_class.new({"author" => {"username" => "Ben"}}).author).to eq("Ben") }
it { expect(described_class.new({}).author).to be_nil }
end
- describe '#description' do
- it { expect(described_class.new({ 'description' => 'Text' }).description).to eq('Text') }
+ describe "#description" do
+ it { expect(described_class.new({"description" => "Text"}).description).to eq("Text") }
it { expect(described_class.new({}).description).to be_nil }
end
- describe '#state' do
- it { expect(described_class.new({ 'state' => 'MERGED' }).state).to eq('merged') }
- it { expect(described_class.new({ 'state' => 'DECLINED' }).state).to eq('closed') }
- it { expect(described_class.new({}).state).to eq('opened') }
+ describe "#state" do
+ it { expect(described_class.new({"state" => "MERGED"}).state).to eq("merged") }
+ it { expect(described_class.new({"state" => "DECLINED"}).state).to eq("closed") }
+ it { expect(described_class.new({}).state).to eq("opened") }
end
- describe '#title' do
- it { expect(described_class.new('title' => 'Issue').title).to eq('Issue') }
+ describe "#title" do
+ it { expect(described_class.new("title" => "Issue").title).to eq("Issue") }
end
- describe '#source_branch_name' do
- it { expect(described_class.new({ source: { branch: { name: 'feature' } } }.with_indifferent_access).source_branch_name).to eq('feature') }
- it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_name).to be_nil }
+ describe "#source_branch_name" do
+ it { expect(described_class.new({source: {branch: {name: "feature"}}}.with_indifferent_access).source_branch_name).to eq("feature") }
+ it { expect(described_class.new({source: {}}.with_indifferent_access).source_branch_name).to be_nil }
end
- describe '#source_branch_sha' do
- it { expect(described_class.new({ source: { commit: { hash: 'abcd123' } } }.with_indifferent_access).source_branch_sha).to eq('abcd123') }
- it { expect(described_class.new({ source: {} }.with_indifferent_access).source_branch_sha).to be_nil }
+ describe "#source_branch_sha" do
+ it { expect(described_class.new({source: {commit: {hash: "abcd123"}}}.with_indifferent_access).source_branch_sha).to eq("abcd123") }
+ it { expect(described_class.new({source: {}}.with_indifferent_access).source_branch_sha).to be_nil }
end
- describe '#target_branch_name' do
- it { expect(described_class.new({ destination: { branch: { name: 'master' } } }.with_indifferent_access).target_branch_name).to eq('master') }
- it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_name).to be_nil }
+ describe "#target_branch_name" do
+ it { expect(described_class.new({destination: {branch: {name: "master"}}}.with_indifferent_access).target_branch_name).to eq("master") }
+ it { expect(described_class.new({destination: {}}.with_indifferent_access).target_branch_name).to be_nil }
end
- describe '#target_branch_sha' do
- it { expect(described_class.new({ destination: { commit: { hash: 'abcd123' } } }.with_indifferent_access).target_branch_sha).to eq('abcd123') }
- it { expect(described_class.new({ destination: {} }.with_indifferent_access).target_branch_sha).to be_nil }
+ describe "#target_branch_sha" do
+ it { expect(described_class.new({destination: {commit: {hash: "abcd123"}}}.with_indifferent_access).target_branch_sha).to eq("abcd123") }
+ it { expect(described_class.new({destination: {}}.with_indifferent_access).target_branch_sha).to be_nil }
end
end
diff --git a/spec/lib/bitbucket/representation/repo_spec.rb b/spec/lib/bitbucket/representation/repo_spec.rb
index 405265cc669..a058de00d82 100644
--- a/spec/lib/bitbucket/representation/repo_spec.rb
+++ b/spec/lib/bitbucket/representation/repo_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::Repo do
- describe '#has_wiki?' do
- it { expect(described_class.new({ 'has_wiki' => false }).has_wiki?).to be_falsey }
- it { expect(described_class.new({ 'has_wiki' => true }).has_wiki?).to be_truthy }
+ describe "#has_wiki?" do
+ it { expect(described_class.new({"has_wiki" => false}).has_wiki?).to be_falsey }
+ it { expect(described_class.new({"has_wiki" => true}).has_wiki?).to be_truthy }
end
- describe '#name' do
- it { expect(described_class.new({ 'name' => 'test' }).name).to eq('test') }
+ describe "#name" do
+ it { expect(described_class.new({"name" => "test"}).name).to eq("test") }
end
- describe '#valid?' do
- it { expect(described_class.new({ 'scm' => 'hg' }).valid?).to be_falsey }
- it { expect(described_class.new({ 'scm' => 'git' }).valid?).to be_truthy }
+ describe "#valid?" do
+ it { expect(described_class.new({"scm" => "hg"}).valid?).to be_falsey }
+ it { expect(described_class.new({"scm" => "git"}).valid?).to be_truthy }
end
- describe '#full_name' do
- it { expect(described_class.new({ 'full_name' => 'test_full' }).full_name).to eq('test_full') }
+ describe "#full_name" do
+ it { expect(described_class.new({"full_name" => "test_full"}).full_name).to eq("test_full") }
end
- describe '#description' do
- it { expect(described_class.new({ 'description' => 'desc' }).description).to eq('desc') }
+ describe "#description" do
+ it { expect(described_class.new({"description" => "desc"}).description).to eq("desc") }
end
- describe '#issues_enabled?' do
- it { expect(described_class.new({ 'has_issues' => false }).issues_enabled?).to be_falsey }
- it { expect(described_class.new({ 'has_issues' => true }).issues_enabled?).to be_truthy }
+ describe "#issues_enabled?" do
+ it { expect(described_class.new({"has_issues" => false}).issues_enabled?).to be_falsey }
+ it { expect(described_class.new({"has_issues" => true}).issues_enabled?).to be_truthy }
end
- describe '#owner_and_slug' do
- it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner_and_slug).to eq(%w(ben test)) }
+ describe "#owner_and_slug" do
+ it { expect(described_class.new({"full_name" => "ben/test"}).owner_and_slug).to eq(%w[ben test]) }
end
- describe '#owner' do
- it { expect(described_class.new({ 'full_name' => 'ben/test' }).owner).to eq('ben') }
+ describe "#owner" do
+ it { expect(described_class.new({"full_name" => "ben/test"}).owner).to eq("ben") }
end
- describe '#slug' do
- it { expect(described_class.new({ 'full_name' => 'ben/test' }).slug).to eq('test') }
+ describe "#slug" do
+ it { expect(described_class.new({"full_name" => "ben/test"}).slug).to eq("test") }
end
- describe '#clone_url' do
- it 'builds url' do
- data = { 'links' => { 'clone' => [{ 'name' => 'https', 'href' => 'https://bibucket.org/test/test.git' }] } }
- expect(described_class.new(data).clone_url('abc')).to eq('https://x-token-auth:abc@bibucket.org/test/test.git')
+ describe "#clone_url" do
+ it "builds url" do
+ data = {"links" => {"clone" => [{"name" => "https", "href" => "https://bibucket.org/test/test.git"}]}}
+ expect(described_class.new(data).clone_url("abc")).to eq("https://x-token-auth:abc@bibucket.org/test/test.git")
end
end
end
diff --git a/spec/lib/bitbucket/representation/user_spec.rb b/spec/lib/bitbucket/representation/user_spec.rb
index f79ff4edb7b..906b1f0e0ee 100644
--- a/spec/lib/bitbucket/representation/user_spec.rb
+++ b/spec/lib/bitbucket/representation/user_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Bitbucket::Representation::User do
- describe '#username' do
- it 'returns correct value' do
- user = described_class.new('username' => 'Ben')
+ describe "#username" do
+ it "returns correct value" do
+ user = described_class.new("username" => "Ben")
- expect(user.username).to eq('Ben')
+ expect(user.username).to eq("Ben")
end
end
end
diff --git a/spec/lib/bitbucket_server/client_spec.rb b/spec/lib/bitbucket_server/client_spec.rb
index 4f0d57ca8a6..ec3405af210 100644
--- a/spec/lib/bitbucket_server/client_spec.rb
+++ b/spec/lib/bitbucket_server/client_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Client do
- let(:base_uri) { 'https://test:7990/stash/' }
- let(:options) { { base_uri: base_uri, user: 'bitbucket', password: 'mypassword' } }
- let(:project) { 'SOME-PROJECT' }
- let(:repo_slug) { 'my-repo' }
- let(:headers) { { "Content-Type" => "application/json" } }
+ let(:base_uri) { "https://test:7990/stash/" }
+ let(:options) { {base_uri: base_uri, user: "bitbucket", password: "mypassword"} }
+ let(:project) { "SOME-PROJECT" }
+ let(:repo_slug) { "my-repo" }
+ let(:headers) { {"Content-Type" => "application/json"} }
subject { described_class.new(options) }
- describe '#pull_requests' do
+ describe "#pull_requests" do
let(:path) { "/projects/#{project}/repos/#{repo_slug}/pull-requests?state=ALL" }
- it 'requests a collection' do
+ it "requests a collection" do
expect(BitbucketServer::Paginator).to receive(:new).with(anything, path, :pull_request, page_offset: 0, limit: nil)
subject.pull_requests(project, repo_slug)
end
end
- describe '#activities' do
+ describe "#activities" do
let(:path) { "/projects/#{project}/repos/#{repo_slug}/pull-requests/1/activities" }
- it 'requests a collection' do
+ it "requests a collection" do
expect(BitbucketServer::Paginator).to receive(:new).with(anything, path, :activity, page_offset: 0, limit: nil)
subject.activities(project, repo_slug, 1)
end
end
- describe '#repo' do
+ describe "#repo" do
let(:path) { "/projects/#{project}/repos/#{repo_slug}" }
let(:url) { "#{base_uri}rest/api/1.0/projects/SOME-PROJECT/repos/my-repo" }
- it 'requests a specific repository' do
- stub_request(:get, url).to_return(status: 200, headers: headers, body: '{}')
+ it "requests a specific repository" do
+ stub_request(:get, url).to_return(status: 200, headers: headers, body: "{}")
subject.repo(project, repo_slug)
@@ -42,28 +42,28 @@ describe BitbucketServer::Client do
end
end
- describe '#repos' do
+ describe "#repos" do
let(:path) { "/repos" }
- it 'requests a collection' do
+ it "requests a collection" do
expect(BitbucketServer::Paginator).to receive(:new).with(anything, path, :repo, page_offset: 0, limit: nil)
subject.repos
end
- it 'requests a collection with an offset and limit' do
+ it "requests a collection with an offset and limit" do
expect(BitbucketServer::Paginator).to receive(:new).with(anything, path, :repo, page_offset: 10, limit: 25)
subject.repos(page_offset: 10, limit: 25)
end
end
- describe '#create_branch' do
- let(:branch) { 'test-branch' }
- let(:sha) { '12345678' }
+ describe "#create_branch" do
+ let(:branch) { "test-branch" }
+ let(:sha) { "12345678" }
let(:url) { "#{base_uri}rest/api/1.0/projects/SOME-PROJECT/repos/my-repo/branches" }
- it 'requests Bitbucket to create a branch' do
+ it "requests Bitbucket to create a branch" do
stub_request(:post, url).to_return(status: 204, headers: headers, body: nil)
subject.create_branch(project, repo_slug, branch, sha)
@@ -72,12 +72,12 @@ describe BitbucketServer::Client do
end
end
- describe '#delete_branch' do
- let(:branch) { 'test-branch' }
- let(:sha) { '12345678' }
+ describe "#delete_branch" do
+ let(:branch) { "test-branch" }
+ let(:sha) { "12345678" }
let(:url) { "#{base_uri}rest/branch-utils/1.0/projects/SOME-PROJECT/repos/my-repo/branches" }
- it 'requests Bitbucket to create a branch' do
+ it "requests Bitbucket to create a branch" do
stub_request(:delete, url).to_return(status: 204, headers: headers, body: nil)
subject.delete_branch(project, repo_slug, branch, sha)
diff --git a/spec/lib/bitbucket_server/collection_spec.rb b/spec/lib/bitbucket_server/collection_spec.rb
index ddd02bac88a..a92345b7e19 100644
--- a/spec/lib/bitbucket_server/collection_spec.rb
+++ b/spec/lib/bitbucket_server/collection_spec.rb
@@ -1,28 +1,28 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Collection do
let(:connection) { instance_double(BitbucketServer::Connection) }
let(:page) { 1 }
- let(:paginator) { BitbucketServer::Paginator.new(connection, 'http://more-data', :pull_request, page_offset: page) }
+ let(:paginator) { BitbucketServer::Paginator.new(connection, "http://more-data", :pull_request, page_offset: page) }
subject { described_class.new(paginator) }
- describe '#current_page' do
- it 'returns 1' do
+ describe "#current_page" do
+ it "returns 1" do
expect(subject.current_page).to eq(1)
end
end
- describe '#prev_page' do
- it 'returns nil' do
+ describe "#prev_page" do
+ it "returns nil" do
expect(subject.prev_page).to be_nil
end
end
- describe '#next_page' do
- it 'returns 2' do
+ describe "#next_page" do
+ it "returns 2" do
expect(subject.next_page).to eq(2)
end
end
diff --git a/spec/lib/bitbucket_server/connection_spec.rb b/spec/lib/bitbucket_server/connection_spec.rb
index ab8a5b89608..ee1fe252b29 100644
--- a/spec/lib/bitbucket_server/connection_spec.rb
+++ b/spec/lib/bitbucket_server/connection_spec.rb
@@ -1,82 +1,82 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Connection do
- let(:options) { { base_uri: 'https://test:7990', user: 'bitbucket', password: 'mypassword' } }
- let(:payload) { { 'test' => 1 } }
- let(:headers) { { "Content-Type" => "application/json" } }
- let(:url) { 'https://test:7990/rest/api/1.0/test?something=1' }
+ let(:options) { {base_uri: "https://test:7990", user: "bitbucket", password: "mypassword"} }
+ let(:payload) { {"test" => 1} }
+ let(:headers) { {"Content-Type" => "application/json"} }
+ let(:url) { "https://test:7990/rest/api/1.0/test?something=1" }
subject { described_class.new(options) }
- describe '#get' do
- it 'returns JSON body' do
- WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_return(body: payload.to_json, status: 200, headers: headers)
+ describe "#get" do
+ it "returns JSON body" do
+ WebMock.stub_request(:get, url).with(headers: {"Accept" => "application/json"}).to_return(body: payload.to_json, status: 200, headers: headers)
- expect(subject.get(url, { something: 1 })).to eq(payload)
+ expect(subject.get(url, {something: 1})).to eq(payload)
end
- it 'throws an exception if the response is not 200' do
- WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_return(body: payload.to_json, status: 500, headers: headers)
+ it "throws an exception if the response is not 200" do
+ WebMock.stub_request(:get, url).with(headers: {"Accept" => "application/json"}).to_return(body: payload.to_json, status: 500, headers: headers)
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
- it 'throws an exception if the response is not JSON' do
- WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_return(body: 'bad data', status: 200, headers: headers)
+ it "throws an exception if the response is not JSON" do
+ WebMock.stub_request(:get, url).with(headers: {"Accept" => "application/json"}).to_return(body: "bad data", status: 200, headers: headers)
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
- it 'throws an exception upon a network error' do
- WebMock.stub_request(:get, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
+ it "throws an exception upon a network error" do
+ WebMock.stub_request(:get, url).with(headers: {"Accept" => "application/json"}).to_raise(OpenSSL::SSL::SSLError)
expect { subject.get(url) }.to raise_error(described_class::ConnectionError)
end
end
- describe '#post' do
- let(:headers) { { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }
+ describe "#post" do
+ let(:headers) { {"Accept" => "application/json", "Content-Type" => "application/json"} }
- it 'returns JSON body' do
+ it "returns JSON body" do
WebMock.stub_request(:post, url).with(headers: headers).to_return(body: payload.to_json, status: 200, headers: headers)
expect(subject.post(url, payload)).to eq(payload)
end
- it 'throws an exception if the response is not 200' do
+ it "throws an exception if the response is not 200" do
WebMock.stub_request(:post, url).with(headers: headers).to_return(body: payload.to_json, status: 500, headers: headers)
expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
end
- it 'throws an exception upon a network error' do
- WebMock.stub_request(:post, url).with(headers: { 'Accept' => 'application/json' }).to_raise(OpenSSL::SSL::SSLError)
+ it "throws an exception upon a network error" do
+ WebMock.stub_request(:post, url).with(headers: {"Accept" => "application/json"}).to_raise(OpenSSL::SSL::SSLError)
expect { subject.post(url, payload) }.to raise_error(described_class::ConnectionError)
end
end
- describe '#delete' do
- let(:headers) { { 'Accept' => 'application/json', 'Content-Type' => 'application/json' } }
+ describe "#delete" do
+ let(:headers) { {"Accept" => "application/json", "Content-Type" => "application/json"} }
- context 'branch API' do
- let(:branch_path) { '/projects/foo/repos/bar/branches' }
- let(:branch_url) { 'https://test:7990/rest/branch-utils/1.0/projects/foo/repos/bar/branches' }
+ context "branch API" do
+ let(:branch_path) { "/projects/foo/repos/bar/branches" }
+ let(:branch_url) { "https://test:7990/rest/branch-utils/1.0/projects/foo/repos/bar/branches" }
let(:path) { }
- it 'returns JSON body' do
+ it "returns JSON body" do
WebMock.stub_request(:delete, branch_url).with(headers: headers).to_return(body: payload.to_json, status: 200, headers: headers)
expect(subject.delete(:branches, branch_path, payload)).to eq(payload)
end
- it 'throws an exception if the response is not 200' do
+ it "throws an exception if the response is not 200" do
WebMock.stub_request(:delete, branch_url).with(headers: headers).to_return(body: payload.to_json, status: 500, headers: headers)
expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
end
- it 'throws an exception upon a network error' do
+ it "throws an exception upon a network error" do
WebMock.stub_request(:delete, branch_url).with(headers: headers).to_raise(OpenSSL::SSL::SSLError)
expect { subject.delete(:branches, branch_path, payload) }.to raise_error(described_class::ConnectionError)
diff --git a/spec/lib/bitbucket_server/page_spec.rb b/spec/lib/bitbucket_server/page_spec.rb
index cf419a9045b..2b962e9fd08 100644
--- a/spec/lib/bitbucket_server/page_spec.rb
+++ b/spec/lib/bitbucket_server/page_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Page do
- let(:response) { { 'values' => [{ 'description' => 'Test' }], 'isLastPage' => false, 'nextPageStart' => 2 } }
+ let(:response) { {"values" => [{"description" => "Test"}], "isLastPage" => false, "nextPageStart" => 2} }
before do
# Autoloading hack
BitbucketServer::Representation::PullRequest.new({})
end
- describe '#items' do
- it 'returns collection of needed objects' do
+ describe "#items" do
+ it "returns collection of needed objects" do
page = described_class.new(response, :pull_request)
expect(page.items.first).to be_a(BitbucketServer::Representation::PullRequest)
@@ -17,32 +17,32 @@ describe BitbucketServer::Page do
end
end
- describe '#attrs' do
- it 'returns attributes' do
+ describe "#attrs" do
+ it "returns attributes" do
page = described_class.new(response, :pull_request)
expect(page.attrs.keys).to include(:isLastPage, :nextPageStart)
end
end
- describe '#next?' do
- it 'returns true' do
+ describe "#next?" do
+ it "returns true" do
page = described_class.new(response, :pull_request)
expect(page.next?).to be_truthy
end
- it 'returns false' do
- response['isLastPage'] = true
- response.delete('nextPageStart')
+ it "returns false" do
+ response["isLastPage"] = true
+ response.delete("nextPageStart")
page = described_class.new(response, :pull_request)
expect(page.next?).to be_falsey
end
end
- describe '#next' do
- it 'returns next attribute' do
+ describe "#next" do
+ it "returns next attribute" do
page = described_class.new(response, :pull_request)
expect(page.next).to eq(2)
diff --git a/spec/lib/bitbucket_server/paginator_spec.rb b/spec/lib/bitbucket_server/paginator_spec.rb
index eadd7f68bfb..2a7a688f7ad 100644
--- a/spec/lib/bitbucket_server/paginator_spec.rb
+++ b/spec/lib/bitbucket_server/paginator_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Paginator do
- let(:last_page) { double(:page, next?: false, items: ['item_2']) }
- let(:first_page) { double(:page, next?: true, next: last_page, items: ['item_1']) }
+ let(:last_page) { double(:page, next?: false, items: ["item_2"]) }
+ let(:first_page) { double(:page, next?: true, next: last_page, items: ["item_1"]) }
let(:connection) { instance_double(BitbucketServer::Connection) }
- describe '#items' do
- let(:paginator) { described_class.new(connection, 'http://more-data', :pull_request) }
- let(:page_attrs) { { 'isLastPage' => false, 'nextPageStart' => 1 } }
+ describe "#items" do
+ let(:paginator) { described_class.new(connection, "http://more-data", :pull_request) }
+ let(:page_attrs) { {"isLastPage" => false, "nextPageStart" => 1} }
- it 'returns items and raises StopIteration in the end' do
+ it "returns items and raises StopIteration in the end" do
allow(paginator).to receive(:fetch_next_page).and_return(first_page)
- expect(paginator.items).to match(['item_1'])
+ expect(paginator.items).to match(["item_1"])
allow(paginator).to receive(:fetch_next_page).and_return(last_page)
- expect(paginator.items).to match(['item_2'])
+ expect(paginator.items).to match(["item_2"])
allow(paginator).to receive(:fetch_next_page).and_return(nil)
expect { paginator.items }.to raise_error(StopIteration)
end
- it 'obeys limits' do
- limited = described_class.new(connection, 'http://more-data', :pull_request, page_offset: 0, limit: 1)
+ it "obeys limits" do
+ limited = described_class.new(connection, "http://more-data", :pull_request, page_offset: 0, limit: 1)
allow(limited).to receive(:fetch_next_page).and_return(first_page)
expect(limited.has_next_page?).to be_truthy
- expect(limited.items).to match(['item_1'])
+ expect(limited.items).to match(["item_1"])
expect(limited.has_next_page?).to be_truthy
expect { limited.items }.to raise_error(StopIteration)
end
- it 'does not stop if limit is unspecified' do
+ it "does not stop if limit is unspecified" do
stub_const("BitbucketServer::Paginator::PAGE_LENGTH", 1)
- paginator = described_class.new(connection, 'http://more-data', :pull_request, page_offset: 0, limit: nil)
+ paginator = described_class.new(connection, "http://more-data", :pull_request, page_offset: 0, limit: nil)
allow(paginator).to receive(:fetch_next_page).and_return(first_page, last_page)
expect(paginator.has_next_page?).to be_truthy
- expect(paginator.items).to match(['item_1'])
+ expect(paginator.items).to match(["item_1"])
expect(paginator.has_next_page?).to be_truthy
- expect(paginator.items).to match(['item_2'])
+ expect(paginator.items).to match(["item_2"])
end
- it 'calls the connection with different offsets' do
- expect(connection).to receive(:get).with('http://more-data', start: 0, limit: BitbucketServer::Paginator::PAGE_LENGTH).and_return(page_attrs)
+ it "calls the connection with different offsets" do
+ expect(connection).to receive(:get).with("http://more-data", start: 0, limit: BitbucketServer::Paginator::PAGE_LENGTH).and_return(page_attrs)
expect(paginator.items).to eq([])
- expect(connection).to receive(:get).with('http://more-data', start: 1, limit: BitbucketServer::Paginator::PAGE_LENGTH).and_return({})
+ expect(connection).to receive(:get).with("http://more-data", start: 1, limit: BitbucketServer::Paginator::PAGE_LENGTH).and_return({})
expect(paginator.items).to eq([])
diff --git a/spec/lib/bitbucket_server/representation/activity_spec.rb b/spec/lib/bitbucket_server/representation/activity_spec.rb
index 15c50e40472..6f2026a9fba 100644
--- a/spec/lib/bitbucket_server/representation/activity_spec.rb
+++ b/spec/lib/bitbucket_server/representation/activity_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Representation::Activity do
- let(:activities) { JSON.parse(fixture_file('importers/bitbucket_server/activities.json'))['values'] }
+ let(:activities) { JSON.parse(fixture_file("importers/bitbucket_server/activities.json"))["values"] }
let(:inline_comment) { activities.first }
let(:comment) { activities[3] }
let(:merge_event) { activities[4] }
- describe 'regular comment' do
+ describe "regular comment" do
subject { described_class.new(comment) }
it { expect(subject.comment?).to be_truthy }
@@ -15,7 +15,7 @@ describe BitbucketServer::Representation::Activity do
it { expect(subject.created_at).to be_a(Time) }
end
- describe 'inline comment' do
+ describe "inline comment" do
subject { described_class.new(inline_comment) }
it { expect(subject.comment?).to be_truthy }
@@ -24,15 +24,15 @@ describe BitbucketServer::Representation::Activity do
it { expect(subject.created_at).to be_a(Time) }
end
- describe 'merge event' do
+ describe "merge event" do
subject { described_class.new(merge_event) }
it { expect(subject.comment?).to be_falsey }
it { expect(subject.inline_comment?).to be_falsey }
- it { expect(subject.committer_user).to eq('root') }
- it { expect(subject.committer_email).to eq('test.user@example.com') }
+ it { expect(subject.committer_user).to eq("root") }
+ it { expect(subject.committer_email).to eq("test.user@example.com") }
it { expect(subject.merge_timestamp).to be_a(Time) }
it { expect(subject.created_at).to be_a(Time) }
- it { expect(subject.merge_commit).to eq('839fa9a2d434eb697815b8fcafaecc51accfdbbc') }
+ it { expect(subject.merge_commit).to eq("839fa9a2d434eb697815b8fcafaecc51accfdbbc") }
end
end
diff --git a/spec/lib/bitbucket_server/representation/comment_spec.rb b/spec/lib/bitbucket_server/representation/comment_spec.rb
index 53a20a1d80a..149591601e8 100644
--- a/spec/lib/bitbucket_server/representation/comment_spec.rb
+++ b/spec/lib/bitbucket_server/representation/comment_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Representation::Comment do
- let(:activities) { JSON.parse(fixture_file('importers/bitbucket_server/activities.json'))['values'] }
+ let(:activities) { JSON.parse(fixture_file("importers/bitbucket_server/activities.json"))["values"] }
let(:comment) { activities.first }
subject { described_class.new(comment) }
- describe '#id' do
+ describe "#id" do
it { expect(subject.id).to eq(9) }
end
- describe '#author_username' do
- it { expect(subject.author_username).to eq('root' ) }
+ describe "#author_username" do
+ it { expect(subject.author_username).to eq("root") }
end
- describe '#author_email' do
- it { expect(subject.author_email).to eq('test.user@example.com' ) }
+ describe "#author_email" do
+ it { expect(subject.author_email).to eq("test.user@example.com") }
end
- describe '#note' do
- it { expect(subject.note).to eq('is this a new line?') }
+ describe "#note" do
+ it { expect(subject.note).to eq("is this a new line?") }
end
- describe '#created_at' do
+ describe "#created_at" do
it { expect(subject.created_at).to be_a(Time) }
end
- describe '#updated_at' do
+ describe "#updated_at" do
it { expect(subject.created_at).to be_a(Time) }
end
- describe '#comments' do
+ describe "#comments" do
it { expect(subject.comments.count).to eq(4) }
- it { expect(subject.comments).to all( be_a(described_class) ) }
+ it { expect(subject.comments).to all(be_a(described_class)) }
it { expect(subject.comments.map(&:note)).to match_array(["Hello world", "Ok", "hello", "hi"]) }
# The thread should look like:
@@ -42,7 +42,7 @@ describe BitbucketServer::Representation::Comment do
# -> Ok (third)
# -> Hi (fourth)
# -> hello (second)
- it 'comments have the right parent' do
+ it "comments have the right parent" do
first, second, third, fourth = subject.comments[0..4]
expect(subject.parent_comment).to be_nil
diff --git a/spec/lib/bitbucket_server/representation/pull_request_comment_spec.rb b/spec/lib/bitbucket_server/representation/pull_request_comment_spec.rb
index bd7e3597486..4dfab03287d 100644
--- a/spec/lib/bitbucket_server/representation/pull_request_comment_spec.rb
+++ b/spec/lib/bitbucket_server/representation/pull_request_comment_spec.rb
@@ -1,48 +1,48 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Representation::PullRequestComment do
- let(:activities) { JSON.parse(fixture_file('importers/bitbucket_server/activities.json'))['values'] }
+ let(:activities) { JSON.parse(fixture_file("importers/bitbucket_server/activities.json"))["values"] }
let(:comment) { activities.second }
subject { described_class.new(comment) }
- describe '#id' do
+ describe "#id" do
it { expect(subject.id).to eq(7) }
end
- describe '#from_sha' do
- it { expect(subject.from_sha).to eq('c5f4288162e2e6218180779c7f6ac1735bb56eab') }
+ describe "#from_sha" do
+ it { expect(subject.from_sha).to eq("c5f4288162e2e6218180779c7f6ac1735bb56eab") }
end
- describe '#to_sha' do
- it { expect(subject.to_sha).to eq('a4c2164330f2549f67c13f36a93884cf66e976be') }
+ describe "#to_sha" do
+ it { expect(subject.to_sha).to eq("a4c2164330f2549f67c13f36a93884cf66e976be") }
end
- describe '#to?' do
+ describe "#to?" do
it { expect(subject.to?).to be_falsey }
end
- describe '#from?' do
+ describe "#from?" do
it { expect(subject.from?).to be_truthy }
end
- describe '#added?' do
+ describe "#added?" do
it { expect(subject.added?).to be_falsey }
end
- describe '#removed?' do
+ describe "#removed?" do
it { expect(subject.removed?).to be_falsey }
end
- describe '#new_pos' do
+ describe "#new_pos" do
it { expect(subject.new_pos).to eq(11) }
end
- describe '#old_pos' do
+ describe "#old_pos" do
it { expect(subject.old_pos).to eq(9) }
end
- describe '#file_path' do
- it { expect(subject.file_path).to eq('CHANGELOG.md') }
+ describe "#file_path" do
+ it { expect(subject.file_path).to eq("CHANGELOG.md") }
end
end
diff --git a/spec/lib/bitbucket_server/representation/pull_request_spec.rb b/spec/lib/bitbucket_server/representation/pull_request_spec.rb
index 4b8afdb006b..4e964abe12f 100644
--- a/spec/lib/bitbucket_server/representation/pull_request_spec.rb
+++ b/spec/lib/bitbucket_server/representation/pull_request_spec.rb
@@ -1,79 +1,79 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Representation::PullRequest do
- let(:sample_data) { JSON.parse(fixture_file('importers/bitbucket_server/pull_request.json')) }
+ let(:sample_data) { JSON.parse(fixture_file("importers/bitbucket_server/pull_request.json")) }
subject { described_class.new(sample_data) }
- describe '#author' do
- it { expect(subject.author).to eq('root') }
+ describe "#author" do
+ it { expect(subject.author).to eq("root") }
end
- describe '#author_email' do
- it { expect(subject.author_email).to eq('joe.montana@49ers.com') }
+ describe "#author_email" do
+ it { expect(subject.author_email).to eq("joe.montana@49ers.com") }
end
- describe '#description' do
- it { expect(subject.description).to eq('Test') }
+ describe "#description" do
+ it { expect(subject.description).to eq("Test") }
end
- describe '#iid' do
+ describe "#iid" do
it { expect(subject.iid).to eq(7) }
end
- describe '#state' do
- it { expect(subject.state).to eq('merged') }
+ describe "#state" do
+ it { expect(subject.state).to eq("merged") }
- context 'declined pull requests' do
+ context "declined pull requests" do
before do
- sample_data['state'] = 'DECLINED'
+ sample_data["state"] = "DECLINED"
end
- it 'returns closed' do
- expect(subject.state).to eq('closed')
+ it "returns closed" do
+ expect(subject.state).to eq("closed")
end
end
- context 'open pull requests' do
+ context "open pull requests" do
before do
- sample_data['state'] = 'OPEN'
+ sample_data["state"] = "OPEN"
end
- it 'returns open' do
- expect(subject.state).to eq('opened')
+ it "returns open" do
+ expect(subject.state).to eq("opened")
end
end
end
- describe '#merged?' do
+ describe "#merged?" do
it { expect(subject.merged?).to be_truthy }
end
- describe '#created_at' do
- it { expect(subject.created_at.to_i).to eq(sample_data['createdDate'] / 1000) }
+ describe "#created_at" do
+ it { expect(subject.created_at.to_i).to eq(sample_data["createdDate"] / 1000) }
end
- describe '#updated_at' do
- it { expect(subject.updated_at.to_i).to eq(sample_data['updatedDate'] / 1000) }
+ describe "#updated_at" do
+ it { expect(subject.updated_at.to_i).to eq(sample_data["updatedDate"] / 1000) }
end
- describe '#title' do
- it { expect(subject.title).to eq('Added a new line') }
+ describe "#title" do
+ it { expect(subject.title).to eq("Added a new line") }
end
- describe '#source_branch_name' do
- it { expect(subject.source_branch_name).to eq('refs/heads/root/CODE_OF_CONDUCTmd-1530600625006') }
+ describe "#source_branch_name" do
+ it { expect(subject.source_branch_name).to eq("refs/heads/root/CODE_OF_CONDUCTmd-1530600625006") }
end
- describe '#source_branch_sha' do
- it { expect(subject.source_branch_sha).to eq('074e2b4dddc5b99df1bf9d4a3f66cfc15481fdc8') }
+ describe "#source_branch_sha" do
+ it { expect(subject.source_branch_sha).to eq("074e2b4dddc5b99df1bf9d4a3f66cfc15481fdc8") }
end
- describe '#target_branch_name' do
- it { expect(subject.target_branch_name).to eq('refs/heads/master') }
+ describe "#target_branch_name" do
+ it { expect(subject.target_branch_name).to eq("refs/heads/master") }
end
- describe '#target_branch_sha' do
- it { expect(subject.target_branch_sha).to eq('839fa9a2d434eb697815b8fcafaecc51accfdbbc') }
+ describe "#target_branch_sha" do
+ it { expect(subject.target_branch_sha).to eq("839fa9a2d434eb697815b8fcafaecc51accfdbbc") }
end
end
diff --git a/spec/lib/bitbucket_server/representation/repo_spec.rb b/spec/lib/bitbucket_server/representation/repo_spec.rb
index 3ac1030fbb0..7f116a36303 100644
--- a/spec/lib/bitbucket_server/representation/repo_spec.rb
+++ b/spec/lib/bitbucket_server/representation/repo_spec.rb
@@ -1,80 +1,80 @@
-require 'spec_helper'
+require "spec_helper"
describe BitbucketServer::Representation::Repo do
let(:sample_data) do
<<~DATA
- {
- "slug": "rouge",
- "id": 1,
- "name": "rouge",
- "scmId": "git",
- "state": "AVAILABLE",
- "statusMessage": "Available",
- "forkable": true,
- "project": {
- "key": "TEST",
+ {
+ "slug": "rouge",
"id": 1,
- "name": "test",
- "description": "Test",
+ "name": "rouge",
+ "scmId": "git",
+ "state": "AVAILABLE",
+ "statusMessage": "Available",
+ "forkable": true,
+ "project": {
+ "key": "TEST",
+ "id": 1,
+ "name": "test",
+ "description": "Test",
+ "public": false,
+ "type": "NORMAL",
+ "links": {
+ "self": [
+ {
+ "href": "http://localhost:7990/projects/TEST"
+ }
+ ]
+ }
+ },
"public": false,
- "type": "NORMAL",
"links": {
+ "clone": [
+ {
+ "href": "http://root@localhost:7990/scm/test/rouge.git",
+ "name": "http"
+ },
+ {
+ "href": "ssh://git@localhost:7999/test/rouge.git",
+ "name": "ssh"
+ }
+ ],
"self": [
{
- "href": "http://localhost:7990/projects/TEST"
+ "href": "http://localhost:7990/projects/TEST/repos/rouge/browse"
}
]
}
- },
- "public": false,
- "links": {
- "clone": [
- {
- "href": "http://root@localhost:7990/scm/test/rouge.git",
- "name": "http"
- },
- {
- "href": "ssh://git@localhost:7999/test/rouge.git",
- "name": "ssh"
- }
- ],
- "self": [
- {
- "href": "http://localhost:7990/projects/TEST/repos/rouge/browse"
- }
- ]
}
- }
DATA
end
subject { described_class.new(JSON.parse(sample_data)) }
- describe '#project_key' do
- it { expect(subject.project_key).to eq('TEST') }
+ describe "#project_key" do
+ it { expect(subject.project_key).to eq("TEST") }
end
- describe '#project_name' do
- it { expect(subject.project_name).to eq('test') }
+ describe "#project_name" do
+ it { expect(subject.project_name).to eq("test") }
end
- describe '#slug' do
- it { expect(subject.slug).to eq('rouge') }
+ describe "#slug" do
+ it { expect(subject.slug).to eq("rouge") }
end
- describe '#browse_url' do
- it { expect(subject.browse_url).to eq('http://localhost:7990/projects/TEST/repos/rouge/browse') }
+ describe "#browse_url" do
+ it { expect(subject.browse_url).to eq("http://localhost:7990/projects/TEST/repos/rouge/browse") }
end
- describe '#clone_url' do
- it { expect(subject.clone_url).to eq('http://root@localhost:7990/scm/test/rouge.git') }
+ describe "#clone_url" do
+ it { expect(subject.clone_url).to eq("http://root@localhost:7990/scm/test/rouge.git") }
end
- describe '#description' do
- it { expect(subject.description).to eq('Test') }
+ describe "#description" do
+ it { expect(subject.description).to eq("Test") }
end
- describe '#full_name' do
- it { expect(subject.full_name).to eq('test/rouge') }
+ describe "#full_name" do
+ it { expect(subject.full_name).to eq("test/rouge") }
end
end
diff --git a/spec/lib/constraints/feature_constrainer_spec.rb b/spec/lib/constraints/feature_constrainer_spec.rb
index 42efc164f81..c9b59aa9cb9 100644
--- a/spec/lib/constraints/feature_constrainer_spec.rb
+++ b/spec/lib/constraints/feature_constrainer_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Constraints::FeatureConstrainer do
- describe '#matches' do
- it 'calls Feature.enabled? with the correct arguments' do
+ describe "#matches" do
+ it "calls Feature.enabled? with the correct arguments" do
expect(Feature).to receive(:enabled?).with(:feature_name, "an object", default_enabled: true)
- described_class.new(:feature_name, "an object", default_enabled: true).matches?(double('request'))
+ described_class.new(:feature_name, "an object", default_enabled: true).matches?(double("request"))
end
end
end
diff --git a/spec/lib/constraints/group_url_constrainer_spec.rb b/spec/lib/constraints/group_url_constrainer_spec.rb
index ff295068ba9..59727718aea 100644
--- a/spec/lib/constraints/group_url_constrainer_spec.rb
+++ b/spec/lib/constraints/group_url_constrainer_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe Constraints::GroupUrlConstrainer do
- let!(:group) { create(:group, path: 'gitlab') }
+ let!(:group) { create(:group, path: "gitlab") }
- describe '#matches?' do
- context 'valid request' do
+ describe "#matches?" do
+ context "valid request" do
let(:request) { build_request(group.path) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'valid request for nested group' do
- let!(:nested_group) { create(:group, path: 'nested', parent: group) }
- let!(:request) { build_request('gitlab/nested') }
+ context "valid request for nested group" do
+ let!(:nested_group) { create(:group, path: "nested", parent: group) }
+ let!(:request) { build_request("gitlab/nested") }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'valid request for nested group with reserved top level name' do
- let!(:nested_group) { create(:group, path: 'api', parent: group) }
- let!(:request) { build_request('gitlab/api') }
+ context "valid request for nested group with reserved top level name" do
+ let!(:nested_group) { create(:group, path: "api", parent: group) }
+ let!(:request) { build_request("gitlab/api") }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'invalid request' do
- let(:request) { build_request('foo') }
+ context "invalid request" do
+ let(:request) { build_request("foo") }
it { expect(subject.matches?(request)).to be_falsey }
end
- context 'when the request matches a redirect route' do
- context 'for a root group' do
- let!(:redirect_route) { group.redirect_routes.create!(path: 'gitlabb') }
+ context "when the request matches a redirect route" do
+ context "for a root group" do
+ let!(:redirect_route) { group.redirect_routes.create!(path: "gitlabb") }
- context 'and is a GET request' do
+ context "and is a GET request" do
let(:request) { build_request(redirect_route.path) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'and is NOT a GET request' do
- let(:request) { build_request(redirect_route.path, 'POST') }
+ context "and is NOT a GET request" do
+ let(:request) { build_request(redirect_route.path, "POST") }
it { expect(subject.matches?(request)).to be_falsey }
end
end
- context 'for a nested group' do
- let!(:nested_group) { create(:group, path: 'nested', parent: group) }
- let!(:redirect_route) { nested_group.redirect_routes.create!(path: 'gitlabb/nested') }
+ context "for a nested group" do
+ let!(:nested_group) { create(:group, path: "nested", parent: group) }
+ let!(:redirect_route) { nested_group.redirect_routes.create!(path: "gitlabb/nested") }
let(:request) { build_request(redirect_route.path) }
it { expect(subject.matches?(request)).to be_truthy }
@@ -57,9 +57,9 @@ describe Constraints::GroupUrlConstrainer do
end
end
- def build_request(path, method = 'GET')
+ def build_request(path, method = "GET")
double(:request,
- 'get?': (method == 'GET'),
- params: { id: path })
+ 'get?': (method == "GET"),
+ params: {id: path})
end
end
diff --git a/spec/lib/constraints/project_url_constrainer_spec.rb b/spec/lib/constraints/project_url_constrainer_spec.rb
index c96e7ab8495..bb9d4189910 100644
--- a/spec/lib/constraints/project_url_constrainer_spec.rb
+++ b/spec/lib/constraints/project_url_constrainer_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe Constraints::ProjectUrlConstrainer do
let!(:project) { create(:project) }
let!(:namespace) { project.namespace }
- describe '#matches?' do
- context 'valid request' do
+ describe "#matches?" do
+ context "valid request" do
let(:request) { build_request(namespace.full_path, project.path) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'invalid request' do
+ context "invalid request" do
context "non-existing project" do
- let(:request) { build_request('foo', 'bar') }
+ let(:request) { build_request("foo", "bar") }
it { expect(subject.matches?(request)).to be_falsey }
end
context "project id ending with .git" do
- let(:request) { build_request(namespace.full_path, project.path + '.git') }
+ let(:request) { build_request(namespace.full_path, project.path + ".git") }
it { expect(subject.matches?(request)).to be_falsey }
end
end
- context 'when the request matches a redirect route' do
- let(:old_project_path) { 'old_project_path' }
+ context "when the request matches a redirect route" do
+ let(:old_project_path) { "old_project_path" }
let!(:redirect_route) { project.redirect_routes.create!(path: "#{namespace.full_path}/#{old_project_path}") }
- context 'and is a GET request' do
+ context "and is a GET request" do
let(:request) { build_request(namespace.full_path, old_project_path) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'and is NOT a GET request' do
- let(:request) { build_request(namespace.full_path, old_project_path, 'POST') }
+ context "and is NOT a GET request" do
+ let(:request) { build_request(namespace.full_path, old_project_path, "POST") }
it { expect(subject.matches?(request)).to be_falsey }
end
end
end
- def build_request(namespace, project, method = 'GET')
+ def build_request(namespace, project, method = "GET")
double(:request,
- 'get?': (method == 'GET'),
- params: { namespace_id: namespace, id: project })
+ 'get?': (method == "GET"),
+ params: {namespace_id: namespace, id: project})
end
end
diff --git a/spec/lib/constraints/user_url_constrainer_spec.rb b/spec/lib/constraints/user_url_constrainer_spec.rb
index e2c85bb27bb..d1cfd4da876 100644
--- a/spec/lib/constraints/user_url_constrainer_spec.rb
+++ b/spec/lib/constraints/user_url_constrainer_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Constraints::UserUrlConstrainer do
- let!(:user) { create(:user, username: 'dz') }
+ let!(:user) { create(:user, username: "dz") }
- describe '#matches?' do
- context 'valid request' do
+ describe "#matches?" do
+ context "valid request" do
let(:request) { build_request(user.username) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'invalid request' do
- let(:request) { build_request('foo') }
+ context "invalid request" do
+ let(:request) { build_request("foo") }
it { expect(subject.matches?(request)).to be_falsey }
end
- context 'when the request matches a redirect route' do
- let(:old_project_path) { 'old_project_path' }
- let!(:redirect_route) { user.namespace.redirect_routes.create!(path: 'foo') }
+ context "when the request matches a redirect route" do
+ let(:old_project_path) { "old_project_path" }
+ let!(:redirect_route) { user.namespace.redirect_routes.create!(path: "foo") }
- context 'and is a GET request' do
+ context "and is a GET request" do
let(:request) { build_request(redirect_route.path) }
it { expect(subject.matches?(request)).to be_truthy }
end
- context 'and is NOT a GET request' do
- let(:request) { build_request(redirect_route.path, 'POST') }
+ context "and is NOT a GET request" do
+ let(:request) { build_request(redirect_route.path, "POST") }
it { expect(subject.matches?(request)).to be_falsey }
end
end
end
- def build_request(username, method = 'GET')
+ def build_request(username, method = "GET")
double(:request,
- 'get?': (method == 'GET'),
- params: { username: username })
+ 'get?': (method == "GET"),
+ params: {username: username})
end
end
diff --git a/spec/lib/container_registry/blob_spec.rb b/spec/lib/container_registry/blob_spec.rb
index d3fff5bad42..153db65c74b 100644
--- a/spec/lib/container_registry/blob_spec.rb
+++ b/spec/lib/container_registry/blob_spec.rb
@@ -1,120 +1,123 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRegistry::Blob do
- let(:group) { create(:group, name: 'group') }
- let(:project) { create(:project, path: 'test', group: group) }
+ let(:group) { create(:group, name: "group") }
+ let(:project) { create(:project, path: "test", group: group) }
let(:repository) do
- create(:container_repository, name: 'image',
+ create(:container_repository, name: "image",
tags: %w[latest rc1],
project: project)
end
let(:config) do
- { 'digest' => 'sha256:0123456789012345',
- 'mediaType' => 'binary',
- 'size' => 1000 }
+ {"digest" => "sha256:0123456789012345",
+ "mediaType" => "binary",
+ "size" => 1000,}
end
let(:blob) { described_class.new(repository, config) }
before do
stub_container_registry_config(enabled: true,
- api_url: 'http://registry.gitlab',
- host_port: 'registry.gitlab')
+ api_url: "http://registry.gitlab",
+ host_port: "registry.gitlab")
end
it { expect(blob).to respond_to(:repository) }
it { expect(blob).to delegate_method(:registry).to(:repository) }
it { expect(blob).to delegate_method(:client).to(:repository) }
- describe '#path' do
- it 'returns a valid path to the blob' do
- expect(blob.path).to eq('group/test/image@sha256:0123456789012345')
+ describe "#path" do
+ it "returns a valid path to the blob" do
+ expect(blob.path).to eq("group/test/image@sha256:0123456789012345")
end
end
- describe '#digest' do
- it 'return correct digest value' do
- expect(blob.digest).to eq 'sha256:0123456789012345'
+ describe "#digest" do
+ it "return correct digest value" do
+ expect(blob.digest).to eq "sha256:0123456789012345"
end
end
- describe '#type' do
- it 'returns a correct type' do
- expect(blob.type).to eq 'binary'
+ describe "#type" do
+ it "returns a correct type" do
+ expect(blob.type).to eq "binary"
end
end
- describe '#revision' do
- it 'returns a correct blob SHA' do
- expect(blob.revision).to eq '0123456789012345'
+ describe "#revision" do
+ it "returns a correct blob SHA" do
+ expect(blob.revision).to eq "0123456789012345"
end
end
- describe '#short_revision' do
- it 'return a short SHA' do
- expect(blob.short_revision).to eq '012345678'
+ describe "#short_revision" do
+ it "return a short SHA" do
+ expect(blob.short_revision).to eq "012345678"
end
end
- describe '#delete' do
+ describe "#delete" do
before do
- stub_request(:delete, 'http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345')
+ stub_request(:delete, "http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345")
.to_return(status: 200)
end
- it 'returns true when blob has been successfully deleted' do
+ it "returns true when blob has been successfully deleted" do
expect(blob.delete).to be_truthy
end
end
- describe '#data' do
- context 'when locally stored' do
+ describe "#data" do
+ context "when locally stored" do
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345')
+ stub_request(:get, "http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345")
.to_return(
status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: '{"key":"value"}')
+ headers: {"Content-Type" => "application/json"},
+ body: '{"key":"value"}'
+ )
end
- it 'returns a correct blob data' do
+ it "returns a correct blob data" do
expect(blob.data).to eq '{"key":"value"}'
end
end
- context 'when externally stored' do
- let(:location) { 'http://external.com/blob/file' }
+ context "when externally stored" do
+ let(:location) { "http://external.com/blob/file" }
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345')
- .with(headers: { 'Authorization' => 'bearer token' })
+ stub_request(:get, "http://registry.gitlab/v2/group/test/image/blobs/sha256:0123456789012345")
+ .with(headers: {"Authorization" => "bearer token"})
.to_return(
status: 307,
- headers: { 'Location' => location })
+ headers: {"Location" => location}
+ )
end
- context 'for a valid address' do
+ context "for a valid address" do
before do
stub_request(:get, location)
- .with { |request| !request.headers.include?('Authorization') }
+ .with { |request| !request.headers.include?("Authorization") }
.to_return(
status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: '{"key":"value"}')
+ headers: {"Content-Type" => "application/json"},
+ body: '{"key":"value"}'
+ )
end
- it 'returns correct data' do
+ it "returns correct data" do
expect(blob.data).to eq '{"key":"value"}'
end
end
- context 'for invalid file' do
- let(:location) { 'file:///etc/passwd' }
+ context "for invalid file" do
+ let(:location) { "file:///etc/passwd" }
- it 'raises an error' do
- expect { blob.data }.to raise_error(ArgumentError, 'invalid address')
+ it "raises an error" do
+ expect { blob.data }.to raise_error(ArgumentError, "invalid address")
end
end
end
diff --git a/spec/lib/container_registry/client_spec.rb b/spec/lib/container_registry/client_spec.rb
index 3df33f48adb..63d2b041f79 100644
--- a/spec/lib/container_registry/client_spec.rb
+++ b/spec/lib/container_registry/client_spec.rb
@@ -1,39 +1,38 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe ContainerRegistry::Client do
- let(:token) { '12345' }
- let(:options) { { token: token } }
+ let(:token) { "12345" }
+ let(:options) { {token: token} }
let(:client) { described_class.new("http://container-registry", options) }
- describe '#blob' do
- it 'GET /v2/:name/blobs/:digest' do
+ describe "#blob" do
+ it "GET /v2/:name/blobs/:digest" do
stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345")
.with(headers: {
- 'Accept' => 'application/octet-stream',
- 'Authorization' => "bearer #{token}"
- })
+ "Accept" => "application/octet-stream",
+ "Authorization" => "bearer #{token}",
+ })
.to_return(status: 200, body: "Blob")
- expect(client.blob('group/test', 'sha256:0123456789012345')).to eq('Blob')
+ expect(client.blob("group/test", "sha256:0123456789012345")).to eq("Blob")
end
- it 'follows 307 redirect for GET /v2/:name/blobs/:digest' do
+ it "follows 307 redirect for GET /v2/:name/blobs/:digest" do
stub_request(:get, "http://container-registry/v2/group/test/blobs/sha256:0123456789012345")
.with(headers: {
- 'Accept' => 'application/octet-stream',
- 'Authorization' => "bearer #{token}"
- })
- .to_return(status: 307, body: "", headers: { Location: 'http://redirected' })
+ "Accept" => "application/octet-stream",
+ "Authorization" => "bearer #{token}",
+ })
+ .to_return(status: 307, body: "", headers: {Location: "http://redirected"})
# We should probably use hash_excluding here, but that requires an update to WebMock:
# https://github.com/bblimke/webmock/blob/master/lib/webmock/matchers/hash_excluding_matcher.rb
stub_request(:get, "http://redirected/")
- .with { |request| !request.headers.include?('Authorization') }
+ .with { |request| !request.headers.include?("Authorization") }
.to_return(status: 200, body: "Successfully redirected")
- response = client.blob('group/test', 'sha256:0123456789012345')
+ response = client.blob("group/test", "sha256:0123456789012345")
- expect(response).to eq('Successfully redirected')
+ expect(response).to eq("Successfully redirected")
end
end
end
diff --git a/spec/lib/container_registry/path_spec.rb b/spec/lib/container_registry/path_spec.rb
index 010deae822c..884f57a8bab 100644
--- a/spec/lib/container_registry/path_spec.rb
+++ b/spec/lib/container_registry/path_spec.rb
@@ -1,263 +1,263 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRegistry::Path do
subject { described_class.new(path) }
- describe '#components' do
- let(:path) { 'path/to/some/project' }
+ describe "#components" do
+ let(:path) { "path/to/some/project" }
- it 'splits components by a forward slash' do
+ it "splits components by a forward slash" do
expect(subject.components).to eq %w[path to some project]
end
end
- describe '#nodes' do
- context 'when repository path is valid' do
- let(:path) { 'path/to/some/project' }
+ describe "#nodes" do
+ context "when repository path is valid" do
+ let(:path) { "path/to/some/project" }
- it 'return all project path like node in reverse order' do
+ it "return all project path like node in reverse order" do
expect(subject.nodes).to eq %w[path/to/some/project
path/to/some
path/to]
end
end
- context 'when repository path is invalid' do
- let(:path) { '' }
+ context "when repository path is invalid" do
+ let(:path) { "" }
- it 'rasises en error' do
+ it "rasises en error" do
expect { subject.nodes }
.to raise_error described_class::InvalidRegistryPathError
end
end
end
- describe '#to_s' do
- context 'when path does not have uppercase characters' do
- let(:path) { 'some/image' }
+ describe "#to_s" do
+ context "when path does not have uppercase characters" do
+ let(:path) { "some/image" }
- it 'return a string with a repository path' do
- expect(subject.to_s).to eq 'some/image'
+ it "return a string with a repository path" do
+ expect(subject.to_s).to eq "some/image"
end
end
- context 'when path has uppercase characters' do
- let(:path) { 'SoMe/ImAgE' }
+ context "when path has uppercase characters" do
+ let(:path) { "SoMe/ImAgE" }
- it 'return a string with a repository path' do
- expect(subject.to_s).to eq 'some/image'
+ it "return a string with a repository path" do
+ expect(subject.to_s).to eq "some/image"
end
end
end
- describe '#valid?' do
- context 'when path has less than two components' do
- let(:path) { 'something/' }
+ describe "#valid?" do
+ context "when path has less than two components" do
+ let(:path) { "something/" }
it { is_expected.not_to be_valid }
end
- context 'when path has more than allowed number of components' do
- let(:path) { 'a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/r/s/t/u/w/y/z' }
+ context "when path has more than allowed number of components" do
+ let(:path) { "a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/r/s/t/u/w/y/z" }
it { is_expected.not_to be_valid }
end
- context 'when path has invalid characters' do
+ context "when path has invalid characters" do
let(:path) { 'some\path' }
it { is_expected.not_to be_valid }
end
- context 'when path has two or more components' do
- let(:path) { 'some/path' }
+ context "when path has two or more components" do
+ let(:path) { "some/path" }
it { is_expected.to be_valid }
end
- context 'when path is related to multi-level image' do
- let(:path) { 'some/path/my/image' }
+ context "when path is related to multi-level image" do
+ let(:path) { "some/path/my/image" }
it { is_expected.to be_valid }
end
- context 'when path contains uppercase letters' do
- let(:path) { 'Some/Registry' }
+ context "when path contains uppercase letters" do
+ let(:path) { "Some/Registry" }
it { is_expected.to be_valid }
end
- context 'when path contains double underscore' do
- let(:path) { 'my/repository__name' }
+ context "when path contains double underscore" do
+ let(:path) { "my/repository__name" }
it { is_expected.to be_valid }
end
- context 'when path contains invalid separator with dot' do
- let(:path) { 'some/registry-.name' }
+ context "when path contains invalid separator with dot" do
+ let(:path) { "some/registry-.name" }
it { is_expected.not_to be_valid }
end
- context 'when path contains invalid separator with underscore' do
- let(:path) { 'some/registry._name' }
+ context "when path contains invalid separator with underscore" do
+ let(:path) { "some/registry._name" }
it { is_expected.not_to be_valid }
end
end
- describe '#has_repository?' do
- context 'when project exists' do
+ describe "#has_repository?" do
+ context "when project exists" do
let(:project) { create(:project) }
let(:path) { "#{project.full_path}/my/image" }
- context 'when path already has matching repository' do
+ context "when path already has matching repository" do
before do
- create(:container_repository, project: project, name: 'my/image')
+ create(:container_repository, project: project, name: "my/image")
end
it { is_expected.to have_repository }
it { is_expected.to have_project }
end
- context 'when path does not have matching repository' do
+ context "when path does not have matching repository" do
it { is_expected.not_to have_repository }
it { is_expected.to have_project }
end
end
- context 'when project does not exist' do
- let(:path) { 'some/project/my/image' }
+ context "when project does not exist" do
+ let(:path) { "some/project/my/image" }
it { is_expected.not_to have_repository }
it { is_expected.not_to have_project }
end
end
- describe '#repository_project' do
- let(:group) { create(:group, path: 'some_group') }
+ describe "#repository_project" do
+ let(:group) { create(:group, path: "some_group") }
- context 'when project for given path exists' do
- let(:path) { 'some_group/some_project' }
+ context "when project for given path exists" do
+ let(:path) { "some_group/some_project" }
before do
- create(:project, group: group, name: 'some_project')
- create(:project, name: 'some_project')
+ create(:project, group: group, name: "some_project")
+ create(:project, name: "some_project")
end
- it 'returns a correct project' do
+ it "returns a correct project" do
expect(subject.repository_project.group).to eq group
end
end
- context 'when project for given path does not exist' do
- let(:path) { 'not/matching' }
+ context "when project for given path does not exist" do
+ let(:path) { "not/matching" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.repository_project).to be_nil
end
end
- context 'when matching multi-level path' do
+ context "when matching multi-level path" do
let(:project) do
- create(:project, group: group, name: 'some_project')
+ create(:project, group: group, name: "some_project")
end
- context 'when using the zero-level path' do
+ context "when using the zero-level path" do
let(:path) { project.full_path }
- it 'supports zero-level path' do
+ it "supports zero-level path" do
expect(subject.repository_project).to eq project
end
end
- context 'when using first-level path' do
+ context "when using first-level path" do
let(:path) { "#{project.full_path}/repository" }
- it 'supports first-level path' do
+ it "supports first-level path" do
expect(subject.repository_project).to eq project
end
end
- context 'when using second-level path' do
+ context "when using second-level path" do
let(:path) { "#{project.full_path}/repository/name" }
- it 'supports second-level path' do
+ it "supports second-level path" do
expect(subject.repository_project).to eq project
end
end
- context 'when using too deep nesting in the path' do
+ context "when using too deep nesting in the path" do
let(:path) { "#{project.full_path}/repository/name/invalid" }
- it 'does not support three-levels of nesting' do
+ it "does not support three-levels of nesting" do
expect(subject.repository_project).to be_nil
end
end
end
end
- describe '#repository_name' do
- context 'when project does not exist' do
- let(:path) { 'some/name' }
+ describe "#repository_name" do
+ context "when project does not exist" do
+ let(:path) { "some/name" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.repository_name).to be_nil
end
end
- context 'when project exists' do
- let(:group) { create(:group, path: 'Some_Group') }
+ context "when project exists" do
+ let(:group) { create(:group, path: "Some_Group") }
before do
- create(:project, group: group, name: 'some_project')
+ create(:project, group: group, name: "some_project")
end
- context 'when project path equal repository path' do
- let(:path) { 'some_group/some_project' }
+ context "when project path equal repository path" do
+ let(:path) { "some_group/some_project" }
- it 'returns an empty string' do
- expect(subject.repository_name).to eq ''
+ it "returns an empty string" do
+ expect(subject.repository_name).to eq ""
end
end
- context 'when repository path has one additional level' do
- let(:path) { 'some_group/some_project/repository' }
+ context "when repository path has one additional level" do
+ let(:path) { "some_group/some_project/repository" }
- it 'returns a correct repository name' do
- expect(subject.repository_name).to eq 'repository'
+ it "returns a correct repository name" do
+ expect(subject.repository_name).to eq "repository"
end
end
- context 'when repository path has two additional levels' do
- let(:path) { 'some_group/some_project/repository/image' }
+ context "when repository path has two additional levels" do
+ let(:path) { "some_group/some_project/repository/image" }
- it 'returns a correct repository name' do
- expect(subject.repository_name).to eq 'repository/image'
+ it "returns a correct repository name" do
+ expect(subject.repository_name).to eq "repository/image"
end
end
end
end
- describe '#project_path' do
- context 'when project does not exist' do
- let(:path) { 'some/name' }
+ describe "#project_path" do
+ context "when project does not exist" do
+ let(:path) { "some/name" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.project_path).to be_nil
end
end
- context 'when project with uppercase characters in path exists' do
- let(:path) { 'somegroup/myproject/my/image' }
- let(:group) { create(:group, path: 'SomeGroup') }
+ context "when project with uppercase characters in path exists" do
+ let(:path) { "somegroup/myproject/my/image" }
+ let(:group) { create(:group, path: "SomeGroup") }
before do
- create(:project, group: group, name: 'MyProject')
+ create(:project, group: group, name: "MyProject")
end
- it 'returns downcased project path' do
- expect(subject.project_path).to eq 'somegroup/myproject'
+ it "returns downcased project path" do
+ expect(subject.project_path).to eq "somegroup/myproject"
end
end
end
diff --git a/spec/lib/container_registry/registry_spec.rb b/spec/lib/container_registry/registry_spec.rb
index 4d6eea94bf0..7eb956cd522 100644
--- a/spec/lib/container_registry/registry_spec.rb
+++ b/spec/lib/container_registry/registry_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRegistry::Registry do
let(:path) { nil }
- let(:registry) { described_class.new('http://example.com', path: path) }
+ let(:registry) { described_class.new("http://example.com", path: path) }
subject { registry }
@@ -12,15 +12,15 @@ describe ContainerRegistry::Registry do
it { expect(subject).not_to be_nil }
- context '#path' do
+ context "#path" do
subject { registry.path }
- context 'path from URL' do
- it { is_expected.to eq('example.com') }
+ context "path from URL" do
+ it { is_expected.to eq("example.com") }
end
- context 'custom path' do
- let(:path) { 'registry.example.com' }
+ context "custom path" do
+ let(:path) { "registry.example.com" }
it { is_expected.to eq(path) }
end
diff --git a/spec/lib/container_registry/tag_spec.rb b/spec/lib/container_registry/tag_spec.rb
index cb4ae3be525..9d8861b74c9 100644
--- a/spec/lib/container_registry/tag_spec.rb
+++ b/spec/lib/container_registry/tag_spec.rb
@@ -1,93 +1,94 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRegistry::Tag do
- let(:group) { create(:group, name: 'group') }
- let(:project) { create(:project, path: 'test', group: group) }
+ let(:group) { create(:group, name: "group") }
+ let(:project) { create(:project, path: "test", group: group) }
let(:repository) do
- create(:container_repository, name: '', project: project)
+ create(:container_repository, name: "", project: project)
end
let(:headers) do
- { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' }
+ {"Accept" => "application/vnd.docker.distribution.manifest.v2+json"}
end
- let(:tag) { described_class.new(repository, 'tag') }
+ let(:tag) { described_class.new(repository, "tag") }
before do
stub_container_registry_config(enabled: true,
- api_url: 'http://registry.gitlab',
- host_port: 'registry.gitlab')
+ api_url: "http://registry.gitlab",
+ host_port: "registry.gitlab")
end
it { expect(tag).to respond_to(:repository) }
it { expect(tag).to delegate_method(:registry).to(:repository) }
it { expect(tag).to delegate_method(:client).to(:repository) }
- describe '#path' do
- context 'when tag belongs to zero-level repository' do
+ describe "#path" do
+ context "when tag belongs to zero-level repository" do
let(:repository) do
- create(:container_repository, name: '',
+ create(:container_repository, name: "",
tags: %w[rc1],
project: project)
end
- it 'returns path to the image' do
- expect(tag.path).to eq('group/test:tag')
+ it "returns path to the image" do
+ expect(tag.path).to eq("group/test:tag")
end
end
- context 'when tag belongs to first-level repository' do
+ context "when tag belongs to first-level repository" do
let(:repository) do
- create(:container_repository, name: 'my_image',
+ create(:container_repository, name: "my_image",
tags: %w[tag],
project: project)
end
- it 'returns path to the image' do
- expect(tag.path).to eq('group/test/my_image:tag')
+ it "returns path to the image" do
+ expect(tag.path).to eq("group/test/my_image:tag")
end
end
end
- describe '#location' do
- it 'returns a full location of the tag' do
+ describe "#location" do
+ it "returns a full location of the tag" do
expect(tag.location)
- .to eq 'registry.gitlab/group/test:tag'
+ .to eq "registry.gitlab/group/test:tag"
end
end
- context 'manifest processing' do
- context 'schema v1' do
+ context "manifest processing" do
+ context "schema v1" do
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag')
+ stub_request(:get, "http://registry.gitlab/v2/group/test/manifests/tag")
.with(headers: headers)
.to_return(
status: 200,
- body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest_1.json'),
- headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v1+prettyjws' })
+ body: File.read(Rails.root + "spec/fixtures/container_registry/tag_manifest_1.json"),
+ headers: {"Content-Type" => "application/vnd.docker.distribution.manifest.v1+prettyjws"}
+ )
end
- context '#layers' do
+ context "#layers" do
subject { tag.layers }
it { expect(subject.length).to eq(1) }
end
- context '#total_size' do
+ context "#total_size" do
subject { tag.total_size }
it { is_expected.to be_nil }
end
- context 'config processing' do
- context '#config' do
+ context "config processing" do
+ context "#config" do
subject { tag.config }
it { is_expected.to be_nil }
end
- context '#created_at' do
+ context "#created_at" do
subject { tag.created_at }
it { is_expected.to be_nil }
@@ -95,96 +96,100 @@ describe ContainerRegistry::Tag do
end
end
- context 'schema v2' do
+ context "schema v2" do
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/manifests/tag')
+ stub_request(:get, "http://registry.gitlab/v2/group/test/manifests/tag")
.with(headers: headers)
.to_return(
status: 200,
- body: File.read(Rails.root + 'spec/fixtures/container_registry/tag_manifest.json'),
- headers: { 'Content-Type' => 'application/vnd.docker.distribution.manifest.v2+json' })
+ body: File.read(Rails.root + "spec/fixtures/container_registry/tag_manifest.json"),
+ headers: {"Content-Type" => "application/vnd.docker.distribution.manifest.v2+json"}
+ )
end
- context '#layers' do
+ context "#layers" do
subject { tag.layers }
it { expect(subject.length).to eq(1) }
end
- context '#total_size' do
+ context "#total_size" do
subject { tag.total_size }
it { is_expected.to eq(2319870) }
end
- context 'config processing' do
- shared_examples 'a processable' do
- context '#config' do
+ context "config processing" do
+ shared_examples "a processable" do
+ context "#config" do
subject { tag.config }
it { is_expected.not_to be_nil }
end
- context '#created_at' do
+ context "#created_at" do
subject { tag.created_at }
it { is_expected.not_to be_nil }
end
end
- context 'when locally stored' do
+ context "when locally stored" do
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac')
- .with(headers: { 'Accept' => 'application/octet-stream' })
+ stub_request(:get, "http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac")
+ .with(headers: {"Accept" => "application/octet-stream"})
.to_return(
status: 200,
- body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json'))
+ body: File.read(Rails.root + "spec/fixtures/container_registry/config_blob.json")
+ )
end
- it_behaves_like 'a processable'
+ it_behaves_like "a processable"
end
- context 'when externally stored' do
+ context "when externally stored" do
before do
- stub_request(:get, 'http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac')
- .with(headers: { 'Accept' => 'application/octet-stream' })
+ stub_request(:get, "http://registry.gitlab/v2/group/test/blobs/sha256:d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac")
+ .with(headers: {"Accept" => "application/octet-stream"})
.to_return(
status: 307,
- headers: { 'Location' => 'http://external.com/blob/file' })
+ headers: {"Location" => "http://external.com/blob/file"}
+ )
- stub_request(:get, 'http://external.com/blob/file')
+ stub_request(:get, "http://external.com/blob/file")
.to_return(
status: 200,
- body: File.read(Rails.root + 'spec/fixtures/container_registry/config_blob.json'))
+ body: File.read(Rails.root + "spec/fixtures/container_registry/config_blob.json")
+ )
end
- it_behaves_like 'a processable'
+ it_behaves_like "a processable"
end
end
end
end
- context 'with stubbed digest' do
+ context "with stubbed digest" do
before do
- stub_request(:head, 'http://registry.gitlab/v2/group/test/manifests/tag')
+ stub_request(:head, "http://registry.gitlab/v2/group/test/manifests/tag")
.with(headers: headers)
- .to_return(status: 200, headers: { 'Docker-Content-Digest' => 'sha256:digest' })
+ .to_return(status: 200, headers: {"Docker-Content-Digest" => "sha256:digest"})
end
- describe '#digest' do
- it 'returns a correct tag digest' do
- expect(tag.digest).to eq 'sha256:digest'
+ describe "#digest" do
+ it "returns a correct tag digest" do
+ expect(tag.digest).to eq "sha256:digest"
end
end
- describe '#delete' do
+ describe "#delete" do
before do
- stub_request(:delete, 'http://registry.gitlab/v2/group/test/manifests/sha256:digest')
+ stub_request(:delete, "http://registry.gitlab/v2/group/test/manifests/sha256:digest")
.with(headers: headers)
.to_return(status: 200)
end
- it 'correctly deletes the tag' do
+ it "correctly deletes the tag" do
expect(tag.delete).to be_truthy
end
end
diff --git a/spec/lib/event_filter_spec.rb b/spec/lib/event_filter_spec.rb
index 30016da6828..c6edb5d3b6b 100644
--- a/spec/lib/event_filter_spec.rb
+++ b/spec/lib/event_filter_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe EventFilter do
- describe 'FILTERS' do
- it 'returns a definite list of filters' do
+ describe "FILTERS" do
+ it "returns a definite list of filters" do
expect(described_class::FILTERS).to eq(%w[all push merged issue comments team])
end
end
- describe '#filter' do
+ describe "#filter" do
it 'returns "all" if given filter is nil' do
expect(described_class.new(nil).filter).to eq(described_class::ALL)
end
it 'returns "all" if given filter is ""' do
- expect(described_class.new('').filter).to eq(described_class::ALL)
+ expect(described_class.new("").filter).to eq(described_class::ALL)
end
it 'returns "all" if given filter is "foo"' do
- expect(described_class.new('foo').filter).to eq('all')
+ expect(described_class.new("foo").filter).to eq("all")
end
end
- describe '#apply_filter' do
+ describe "#apply_filter" do
set(:public_project) { create(:project, :public) }
set(:push_event) { create(:push_event, project: public_project) }
@@ -39,7 +39,7 @@ describe EventFilter do
context 'with the "push" filter' do
let(:filter) { described_class::PUSH }
- it 'filters push events only' do
+ it "filters push events only" do
expect(filtered_events).to contain_exactly(push_event)
end
end
@@ -47,7 +47,7 @@ describe EventFilter do
context 'with the "merged" filter' do
let(:filter) { described_class::MERGED }
- it 'filters merged events only' do
+ it "filters merged events only" do
expect(filtered_events).to contain_exactly(merged_event)
end
end
@@ -55,7 +55,7 @@ describe EventFilter do
context 'with the "issue" filter' do
let(:filter) { described_class::ISSUE }
- it 'filters issue events only' do
+ it "filters issue events only" do
expect(filtered_events).to contain_exactly(created_event, updated_event, closed_event, reopened_event)
end
end
@@ -63,7 +63,7 @@ describe EventFilter do
context 'with the "comments" filter' do
let(:filter) { described_class::COMMENTS }
- it 'filters comment events only' do
+ it "filters comment events only" do
expect(filtered_events).to contain_exactly(comments_event)
end
end
@@ -71,7 +71,7 @@ describe EventFilter do
context 'with the "team" filter' do
let(:filter) { described_class::TEAM }
- it 'filters team events only' do
+ it "filters team events only" do
expect(filtered_events).to contain_exactly(joined_event, left_event)
end
end
@@ -79,40 +79,40 @@ describe EventFilter do
context 'with the "all" filter' do
let(:filter) { described_class::ALL }
- it 'returns all events' do
+ it "returns all events" do
expect(filtered_events).to eq(Event.all)
end
end
- context 'with an unknown filter' do
- let(:filter) { 'foo' }
+ context "with an unknown filter" do
+ let(:filter) { "foo" }
- it 'returns all events' do
+ it "returns all events" do
expect(filtered_events).to eq(Event.all)
end
end
- context 'with a nil filter' do
+ context "with a nil filter" do
let(:filter) { nil }
- it 'returns all events' do
+ it "returns all events" do
expect(filtered_events).to eq(Event.all)
end
end
end
- describe '#active?' do
+ describe "#active?" do
let(:event_filter) { described_class.new(described_class::TEAM) }
- it 'returns false if filter does not include the given key' do
- expect(event_filter.active?('foo')).to eq(false)
+ it "returns false if filter does not include the given key" do
+ expect(event_filter.active?("foo")).to eq(false)
end
- it 'returns false if the given key is nil' do
+ it "returns false if the given key is nil" do
expect(event_filter.active?(nil)).to eq(false)
end
- it 'returns true if filter does not include the given key' do
+ it "returns true if filter does not include the given key" do
expect(event_filter.active?(described_class::TEAM)).to eq(true)
end
end
diff --git a/spec/lib/expand_variables_spec.rb b/spec/lib/expand_variables_spec.rb
index 7faa0f31b68..aee2c0d0584 100644
--- a/spec/lib/expand_variables_spec.rb
+++ b/spec/lib/expand_variables_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe ExpandVariables do
- describe '#expand' do
+ describe "#expand" do
subject { described_class.expand(value, variables) }
tests = [
- { value: 'key',
- result: 'key',
- variables: [] },
- { value: 'key$variable',
- result: 'key',
- variables: [] },
- { value: 'key$variable',
- result: 'keyvalue',
- variables: [
- { key: 'variable', value: 'value' }
- ] },
- { value: 'key${variable}',
- result: 'keyvalue',
- variables: [
- { key: 'variable', value: 'value' }
- ] },
- { value: 'key$variable$variable2',
- result: 'keyvalueresult',
- variables: [
- { key: 'variable', value: 'value' },
- { key: 'variable2', value: 'result' }
- ] },
- { value: 'key${variable}${variable2}',
- result: 'keyvalueresult',
- variables: [
- { key: 'variable', value: 'value' },
- { key: 'variable2', value: 'result' }
- ] },
- { value: 'key$variable2$variable',
- result: 'keyresultvalue',
- variables: [
- { key: 'variable', value: 'value' },
- { key: 'variable2', value: 'result' }
- ] },
- { value: 'key${variable2}${variable}',
- result: 'keyresultvalue',
- variables: [
- { key: 'variable', value: 'value' },
- { key: 'variable2', value: 'result' }
- ] },
- { value: 'review/$CI_COMMIT_REF_NAME',
- result: 'review/feature/add-review-apps',
- variables: [
- { key: 'CI_COMMIT_REF_NAME', value: 'feature/add-review-apps' }
- ] }
+ {value: "key",
+ result: "key",
+ variables: [],},
+ {value: "key$variable",
+ result: "key",
+ variables: [],},
+ {value: "key$variable",
+ result: "keyvalue",
+ variables: [
+ {key: "variable", value: "value"},
+ ],},
+ {value: "key${variable}",
+ result: "keyvalue",
+ variables: [
+ {key: "variable", value: "value"},
+ ],},
+ {value: "key$variable$variable2",
+ result: "keyvalueresult",
+ variables: [
+ {key: "variable", value: "value"},
+ {key: "variable2", value: "result"},
+ ],},
+ {value: "key${variable}${variable2}",
+ result: "keyvalueresult",
+ variables: [
+ {key: "variable", value: "value"},
+ {key: "variable2", value: "result"},
+ ],},
+ {value: "key$variable2$variable",
+ result: "keyresultvalue",
+ variables: [
+ {key: "variable", value: "value"},
+ {key: "variable2", value: "result"},
+ ],},
+ {value: "key${variable2}${variable}",
+ result: "keyresultvalue",
+ variables: [
+ {key: "variable", value: "value"},
+ {key: "variable2", value: "result"},
+ ],},
+ {value: "review/$CI_COMMIT_REF_NAME",
+ result: "review/feature/add-review-apps",
+ variables: [
+ {key: "CI_COMMIT_REF_NAME", value: "feature/add-review-apps"},
+ ],},
]
tests.each do |test|
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb
index e0691aba600..e104e8745f2 100644
--- a/spec/lib/extracts_path_spec.rb
+++ b/spec/lib/extracts_path_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe ExtractsPath do
include described_class
include RepoHelpers
include Gitlab::Routing
- let(:project) { double('project') }
- let(:request) { double('request') }
+ let(:project) { double("project") }
+ let(:request) { double("request") }
before do
@project = project
- repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0',
- 'release/app', 'release/app/v1.0.0'])
+ repo = double(ref_names: ["master", "foo/bar/baz", "v1.0.0", "v2.0.0",
+ "release/app", "release/app/v1.0.0",])
allow(project).to receive(:repository).and_return(repo)
allow(project).to receive(:full_path)
- .and_return('gitlab/gitlab-ci')
+ .and_return("gitlab/gitlab-ci")
allow(request).to receive(:format=)
end
- describe '#assign_ref_vars' do
+ describe "#assign_ref_vars" do
let(:ref) { sample_commit[:id] }
- let(:params) { { path: sample_commit[:line_code_path], ref: ref } }
+ let(:params) { {path: sample_commit[:line_code_path], ref: ref} }
before do
@project = create(:project, :repository)
@@ -32,31 +32,31 @@ describe ExtractsPath do
expect(@logs_path).to eq("/#{@project.full_path}/refs/#{ref}/logs_tree/files/ruby/popen.rb")
end
- context 'ref contains %20' do
- let(:ref) { 'foo%20bar' }
+ context "ref contains %20" do
+ let(:ref) { "foo%20bar" }
- it 'is not converted to a space in @id' do
- @project.repository.add_branch(@project.owner, 'foo%20bar', 'master')
+ it "is not converted to a space in @id" do
+ @project.repository.add_branch(@project.owner, "foo%20bar", "master")
assign_ref_vars
- expect(@id).to start_with('foo%20bar/')
+ expect(@id).to start_with("foo%20bar/")
end
end
- context 'path contains space' do
- let(:params) { { path: 'with space', ref: '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' } }
+ context "path contains space" do
+ let(:params) { {path: "with space", ref: "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e"} }
- it 'is not converted to %20 in @path' do
+ it "is not converted to %20 in @path" do
assign_ref_vars
expect(@path).to eq(params[:path])
end
end
- context 'subclass overrides get_id' do
- it 'uses ref returned by get_id' do
- allow_any_instance_of(self.class).to receive(:get_id) { '38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e' }
+ context "subclass overrides get_id" do
+ it "uses ref returned by get_id" do
+ allow_any_instance_of(self.class).to receive(:get_id) { "38008cb17ce1466d8fec2dfa6f6ab8dcfe5cf49e" }
assign_ref_vars
@@ -64,71 +64,71 @@ describe ExtractsPath do
end
end
- context 'ref only exists without .atom suffix' do
- context 'with a path' do
- let(:params) { { ref: 'v1.0.0.atom', path: 'README.md' } }
+ context "ref only exists without .atom suffix" do
+ context "with a path" do
+ let(:params) { {ref: "v1.0.0.atom", path: "README.md"} }
- it 'renders a 404' do
+ it "renders a 404" do
expect(self).to receive(:render_404)
assign_ref_vars
end
end
- context 'without a path' do
- let(:params) { { ref: 'v1.0.0.atom' } }
+ context "without a path" do
+ let(:params) { {ref: "v1.0.0.atom"} }
before do
assign_ref_vars
end
- it 'sets the un-suffixed version as @ref' do
- expect(@ref).to eq('v1.0.0')
+ it "sets the un-suffixed version as @ref" do
+ expect(@ref).to eq("v1.0.0")
end
- it 'sets the request format to Atom' do
+ it "sets the request format to Atom" do
expect(request).to have_received(:format=).with(:atom)
end
end
end
- context 'ref exists with .atom suffix' do
- context 'with a path' do
- let(:params) { { ref: 'master.atom', path: 'README.md' } }
+ context "ref exists with .atom suffix" do
+ context "with a path" do
+ let(:params) { {ref: "master.atom", path: "README.md"} }
before do
repository = @project.repository
allow(repository).to receive(:commit).and_call_original
- allow(repository).to receive(:commit).with('master.atom').and_return(repository.commit('master'))
+ allow(repository).to receive(:commit).with("master.atom").and_return(repository.commit("master"))
assign_ref_vars
end
- it 'sets the suffixed version as @ref' do
- expect(@ref).to eq('master.atom')
+ it "sets the suffixed version as @ref" do
+ expect(@ref).to eq("master.atom")
end
- it 'does not change the request format' do
+ it "does not change the request format" do
expect(request).not_to have_received(:format=)
end
end
- context 'without a path' do
- let(:params) { { ref: 'master.atom' } }
+ context "without a path" do
+ let(:params) { {ref: "master.atom"} }
before do
repository = @project.repository
allow(repository).to receive(:commit).and_call_original
- allow(repository).to receive(:commit).with('master.atom').and_return(repository.commit('master'))
+ allow(repository).to receive(:commit).with("master.atom").and_return(repository.commit("master"))
end
- it 'sets the suffixed version as @ref' do
+ it "sets the suffixed version as @ref" do
assign_ref_vars
- expect(@ref).to eq('master.atom')
+ expect(@ref).to eq("master.atom")
end
- it 'does not change the request format' do
+ it "does not change the request format" do
expect(request).not_to receive(:format=)
assign_ref_vars
@@ -137,83 +137,85 @@ describe ExtractsPath do
end
end
- describe '#extract_ref' do
+ describe "#extract_ref" do
it "returns an empty pair when no @project is set" do
@project = nil
- expect(extract_ref('master/CHANGELOG')).to eq(['', ''])
+ expect(extract_ref("master/CHANGELOG")).to eq(["", ""])
end
context "without a path" do
it "extracts a valid branch" do
- expect(extract_ref('master')).to eq(['master', ''])
+ expect(extract_ref("master")).to eq(["master", ""])
end
it "extracts a valid tag" do
- expect(extract_ref('v2.0.0')).to eq(['v2.0.0', ''])
+ expect(extract_ref("v2.0.0")).to eq(["v2.0.0", ""])
end
it "extracts a valid commit ref without a path" do
- expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062')).to eq(
- ['f4b14494ef6abf3d144c28e4af0c20143383e062', '']
+ expect(extract_ref("f4b14494ef6abf3d144c28e4af0c20143383e062")).to eq(
+ ["f4b14494ef6abf3d144c28e4af0c20143383e062", ""]
)
end
it "falls back to a primitive split for an invalid ref" do
- expect(extract_ref('stable')).to eq(['stable', ''])
+ expect(extract_ref("stable")).to eq(["stable", ""])
end
it "extracts the longest matching ref" do
- expect(extract_ref('release/app/v1.0.0/README.md')).to eq(
- ['release/app/v1.0.0', 'README.md'])
+ expect(extract_ref("release/app/v1.0.0/README.md")).to eq(
+ ["release/app/v1.0.0", "README.md"]
+ )
end
end
context "with a path" do
it "extracts a valid branch" do
- expect(extract_ref('foo/bar/baz/CHANGELOG')).to eq(
- ['foo/bar/baz', 'CHANGELOG'])
+ expect(extract_ref("foo/bar/baz/CHANGELOG")).to eq(
+ ["foo/bar/baz", "CHANGELOG"]
+ )
end
it "extracts a valid tag" do
- expect(extract_ref('v2.0.0/CHANGELOG')).to eq(['v2.0.0', 'CHANGELOG'])
+ expect(extract_ref("v2.0.0/CHANGELOG")).to eq(["v2.0.0", "CHANGELOG"])
end
it "extracts a valid commit SHA" do
- expect(extract_ref('f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG')).to eq(
- %w(f4b14494ef6abf3d144c28e4af0c20143383e062 CHANGELOG)
+ expect(extract_ref("f4b14494ef6abf3d144c28e4af0c20143383e062/CHANGELOG")).to eq(
+ %w[f4b14494ef6abf3d144c28e4af0c20143383e062 CHANGELOG]
)
end
it "falls back to a primitive split for an invalid ref" do
- expect(extract_ref('stable/CHANGELOG')).to eq(%w(stable CHANGELOG))
+ expect(extract_ref("stable/CHANGELOG")).to eq(%w[stable CHANGELOG])
end
end
end
- describe '#extract_ref_without_atom' do
- it 'ignores any matching refs suffixed with atom' do
- expect(extract_ref_without_atom('master.atom')).to eq('master')
+ describe "#extract_ref_without_atom" do
+ it "ignores any matching refs suffixed with atom" do
+ expect(extract_ref_without_atom("master.atom")).to eq("master")
end
- it 'returns the longest matching ref' do
- expect(extract_ref_without_atom('release/app/v1.0.0.atom')).to eq('release/app/v1.0.0')
+ it "returns the longest matching ref" do
+ expect(extract_ref_without_atom("release/app/v1.0.0.atom")).to eq("release/app/v1.0.0")
end
- it 'returns nil if there are no matching refs' do
- expect(extract_ref_without_atom('foo.atom')).to eq(nil)
+ it "returns nil if there are no matching refs" do
+ expect(extract_ref_without_atom("foo.atom")).to eq(nil)
end
end
- describe '#lfs_blob_ids' do
- let(:tag) { @project.repository.add_tag(@project.owner, 'my-annotated-tag', 'master', 'test tag') }
+ describe "#lfs_blob_ids" do
+ let(:tag) { @project.repository.add_tag(@project.owner, "my-annotated-tag", "master", "test tag") }
let(:ref) { tag.target }
- let(:params) { { ref: ref, path: 'README.md' } }
+ let(:params) { {ref: ref, path: "README.md"} }
before do
@project = create(:project, :repository)
end
- it 'handles annotated tags' do
+ it "handles annotated tags" do
assign_ref_vars
expect(lfs_blob_ids).to eq([])
diff --git a/spec/lib/feature_spec.rb b/spec/lib/feature_spec.rb
index a7163048370..02e87205286 100644
--- a/spec/lib/feature_spec.rb
+++ b/spec/lib/feature_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Feature do
before do
@@ -8,11 +8,11 @@ describe Feature do
allow(described_class).to receive(:enabled?).and_call_original
end
- describe '.get' do
+ describe ".get" do
let(:feature) { double(:feature) }
- let(:key) { 'my_feature' }
+ let(:key) { "my_feature" }
- it 'returns the Flipper feature' do
+ it "returns the Flipper feature" do
expect_any_instance_of(Flipper::DSL).to receive(:feature).with(key)
.and_return(feature)
@@ -20,19 +20,19 @@ describe Feature do
end
end
- describe '.persisted_names' do
- it 'returns the names of the persisted features' do
- Feature::FlipperFeature.create!(key: 'foo')
+ describe ".persisted_names" do
+ it "returns the names of the persisted features" do
+ Feature::FlipperFeature.create!(key: "foo")
expect(described_class.persisted_names).to eq(%w[foo])
end
- it 'returns an empty Array when no features are presisted' do
+ it "returns an empty Array when no features are presisted" do
expect(described_class.persisted_names).to be_empty
end
- it 'caches the feature names when request store is active', :request_store do
- Feature::FlipperFeature.create!(key: 'foo')
+ it "caches the feature names when request store is active", :request_store do
+ Feature::FlipperFeature.create!(key: "foo")
expect(Feature::FlipperFeature)
.to receive(:feature_names)
@@ -45,18 +45,18 @@ describe Feature do
end
end
- describe '.persisted?' do
- context 'when the feature is persisted' do
- it 'returns true when feature name is a string' do
- Feature::FlipperFeature.create!(key: 'foo')
+ describe ".persisted?" do
+ context "when the feature is persisted" do
+ it "returns true when feature name is a string" do
+ Feature::FlipperFeature.create!(key: "foo")
- feature = double(:feature, name: 'foo')
+ feature = double(:feature, name: "foo")
expect(described_class.persisted?(feature)).to eq(true)
end
- it 'returns true when feature name is a symbol' do
- Feature::FlipperFeature.create!(key: 'foo')
+ it "returns true when feature name is a symbol" do
+ Feature::FlipperFeature.create!(key: "foo")
feature = double(:feature, name: :foo)
@@ -64,14 +64,14 @@ describe Feature do
end
end
- context 'when the feature is not persisted' do
- it 'returns false when feature name is a string' do
- feature = double(:feature, name: 'foo')
+ context "when the feature is not persisted" do
+ it "returns false when feature name is a string" do
+ feature = double(:feature, name: "foo")
expect(described_class.persisted?(feature)).to eq(false)
end
- it 'returns false when feature name is a symbol' do
+ it "returns false when feature name is a symbol" do
feature = double(:feature, name: :bar)
expect(described_class.persisted?(feature)).to eq(false)
@@ -79,10 +79,10 @@ describe Feature do
end
end
- describe '.all' do
+ describe ".all" do
let(:features) { Set.new }
- it 'returns the Flipper features as an array' do
+ it "returns the Flipper features as an array" do
expect_any_instance_of(Flipper::DSL).to receive(:features)
.and_return(features)
@@ -90,13 +90,13 @@ describe Feature do
end
end
- describe '.flipper' do
+ describe ".flipper" do
before do
described_class.instance_variable_set(:@flipper, nil)
end
- context 'when request store is inactive' do
- it 'memoizes the Flipper instance' do
+ context "when request store is inactive" do
+ it "memoizes the Flipper instance" do
expect(Flipper).to receive(:new).once.and_call_original
2.times do
@@ -105,8 +105,8 @@ describe Feature do
end
end
- context 'when request store is active', :request_store do
- it 'memoizes the Flipper instance' do
+ context "when request store is active", :request_store do
+ it "memoizes the Flipper instance" do
expect(Flipper).to receive(:new).once.and_call_original
described_class.flipper
@@ -116,67 +116,67 @@ describe Feature do
end
end
- describe '.enabled?' do
- it 'returns false for undefined feature' do
+ describe ".enabled?" do
+ it "returns false for undefined feature" do
expect(described_class.enabled?(:some_random_feature_flag)).to be_falsey
end
- it 'returns true for undefined feature with default_enabled' do
+ it "returns true for undefined feature with default_enabled" do
expect(described_class.enabled?(:some_random_feature_flag, default_enabled: true)).to be_truthy
end
- it 'returns false for existing disabled feature in the database' do
+ it "returns false for existing disabled feature in the database" do
described_class.disable(:disabled_feature_flag)
expect(described_class.enabled?(:disabled_feature_flag)).to be_falsey
end
- it 'returns true for existing enabled feature in the database' do
+ it "returns true for existing enabled feature in the database" do
described_class.enable(:enabled_feature_flag)
expect(described_class.enabled?(:enabled_feature_flag)).to be_truthy
end
- context 'with an individual actor' do
+ context "with an individual actor" do
CustomActor = Struct.new(:flipper_id)
- let(:actor) { CustomActor.new(flipper_id: 'CustomActor:5') }
- let(:another_actor) { CustomActor.new(flipper_id: 'CustomActor:10') }
+ let(:actor) { CustomActor.new(flipper_id: "CustomActor:5") }
+ let(:another_actor) { CustomActor.new(flipper_id: "CustomActor:10") }
before do
described_class.enable(:enabled_feature_flag, actor)
end
- it 'returns true when same actor is informed' do
+ it "returns true when same actor is informed" do
expect(described_class.enabled?(:enabled_feature_flag, actor)).to be_truthy
end
- it 'returns false when different actor is informed' do
+ it "returns false when different actor is informed" do
expect(described_class.enabled?(:enabled_feature_flag, another_actor)).to be_falsey
end
- it 'returns false when no actor is informed' do
+ it "returns false when no actor is informed" do
expect(described_class.enabled?(:enabled_feature_flag)).to be_falsey
end
end
end
- describe '.disable?' do
- it 'returns true for undefined feature' do
+ describe ".disable?" do
+ it "returns true for undefined feature" do
expect(described_class.disabled?(:some_random_feature_flag)).to be_truthy
end
- it 'returns false for undefined feature with default_enabled' do
+ it "returns false for undefined feature with default_enabled" do
expect(described_class.disabled?(:some_random_feature_flag, default_enabled: true)).to be_falsey
end
- it 'returns true for existing disabled feature in the database' do
+ it "returns true for existing disabled feature in the database" do
described_class.disable(:disabled_feature_flag)
expect(described_class.disabled?(:disabled_feature_flag)).to be_truthy
end
- it 'returns false for existing enabled feature in the database' do
+ it "returns false for existing enabled feature in the database" do
described_class.enable(:enabled_feature_flag)
expect(described_class.disabled?(:enabled_feature_flag)).to be_falsey
@@ -184,14 +184,14 @@ describe Feature do
end
describe Feature::Target do
- describe '#targets' do
+ describe "#targets" do
let(:project) { create(:project) }
let(:group) { create(:group) }
let(:user_name) { project.owner.username }
subject { described_class.new(user: user_name, project: project.full_path, group: group.full_path) }
- it 'returns all found targets' do
+ it "returns all found targets" do
expect(subject.targets).to be_an(Array)
expect(subject.targets).to eq([project.owner, project, group])
end
diff --git a/spec/lib/file_size_validator_spec.rb b/spec/lib/file_size_validator_spec.rb
index ebd907ecb7f..d5c39b5d8e5 100644
--- a/spec/lib/file_size_validator_spec.rb
+++ b/spec/lib/file_size_validator_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe FileSizeValidator do
let(:validator) { described_class.new(options) }
let(:note) { create(:note) }
let(:attachment) { AttachmentUploader.new(note) }
- describe 'options uses an integer' do
- let(:options) { { maximum: 10, attributes: { attachment: attachment } } }
+ describe "options uses an integer" do
+ let(:options) { {maximum: 10, attributes: {attachment: attachment}} }
- it 'attachment exceeds maximum limit' do
+ it "attachment exceeds maximum limit" do
allow(attachment).to receive(:size) { 100 }
validator.validate_each(note, :attachment, attachment)
expect(note.errors).to have_key(:attachment)
end
- it 'attachment under maximum limit' do
+ it "attachment under maximum limit" do
allow(attachment).to receive(:size) { 1 }
validator.validate_each(note, :attachment, attachment)
expect(note.errors).not_to have_key(:attachment)
end
end
- describe 'options uses a symbol' do
+ describe "options uses a symbol" do
let(:options) do
{
maximum: :max_attachment_size,
- attributes: { attachment: attachment }
+ attributes: {attachment: attachment},
}
end
@@ -33,13 +33,13 @@ describe FileSizeValidator do
expect(note).to receive(:max_attachment_size) { 10 }
end
- it 'attachment exceeds maximum limit' do
+ it "attachment exceeds maximum limit" do
allow(attachment).to receive(:size) { 100 }
validator.validate_each(note, :attachment, attachment)
expect(note.errors).to have_key(:attachment)
end
- it 'attachment under maximum limit' do
+ it "attachment under maximum limit" do
allow(attachment).to receive(:size) { 1 }
validator.validate_each(note, :attachment, attachment)
expect(note.errors).not_to have_key(:attachment)
diff --git a/spec/lib/forever_spec.rb b/spec/lib/forever_spec.rb
index 494c0561975..09d91590d22 100644
--- a/spec/lib/forever_spec.rb
+++ b/spec/lib/forever_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Forever do
- describe '.date' do
+ describe ".date" do
subject { described_class.date }
- context 'when using PostgreSQL' do
- it 'should return Postgresql future date' do
+ context "when using PostgreSQL" do
+ it "should return Postgresql future date" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(subject).to eq(described_class::POSTGRESQL_DATE)
end
end
- context 'when using MySQL' do
- it 'should return MySQL future date' do
+ context "when using MySQL" do
+ it "should return MySQL future date" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(subject).to eq(described_class::MYSQL_DATE)
diff --git a/spec/lib/gitaly/server_spec.rb b/spec/lib/gitaly/server_spec.rb
index 292ab870dad..b3337243fc4 100644
--- a/spec/lib/gitaly/server_spec.rb
+++ b/spec/lib/gitaly/server_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitaly::Server do
- let(:server) { described_class.new('default') }
+ let(:server) { described_class.new("default") }
- describe '.all' do
+ describe ".all" do
let(:storages) { Gitlab.config.repositories.storages }
- it 'includes all storages' do
+ it "includes all storages" do
expect(storages.count).to eq(described_class.all.count)
expect(storages.keys).to eq(described_class.all.map(&:storage))
end
@@ -19,41 +19,41 @@ describe Gitaly::Server do
it { is_expected.to respond_to(:up_to_date?) }
it { is_expected.to respond_to(:address) }
- describe 'readable?' do
- context 'when the storage is readable' do
- it 'returns true' do
+ describe "readable?" do
+ context "when the storage is readable" do
+ it "returns true" do
expect(server).to be_readable
end
end
- context 'when the storage is not readable', :broken_storage do
- it 'returns false' do
+ context "when the storage is not readable", :broken_storage do
+ it "returns false" do
expect(server).not_to be_readable
end
end
end
- describe 'writeable?' do
- context 'when the storage is writeable' do
- it 'returns true' do
+ describe "writeable?" do
+ context "when the storage is writeable" do
+ it "returns true" do
expect(server).to be_writeable
end
end
- context 'when the storage is not writeable', :broken_storage do
- it 'returns false' do
+ context "when the storage is not writeable", :broken_storage do
+ it "returns false" do
expect(server).not_to be_writeable
end
end
end
- describe 'request memoization' do
- context 'when requesting multiple properties', :request_store do
- it 'uses memoization for the info request' do
- expect do
+ describe "request memoization" do
+ context "when requesting multiple properties", :request_store do
+ it "uses memoization for the info request" do
+ expect {
subject.server_version
subject.up_to_date?
- end.to change { Gitlab::GitalyClient.get_request_count }.by(1)
+ }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end
end
diff --git a/spec/lib/gitlab/access/branch_protection_spec.rb b/spec/lib/gitlab/access/branch_protection_spec.rb
index 7f2979e8e28..7ddd8105b43 100644
--- a/spec/lib/gitlab/access/branch_protection_spec.rb
+++ b/spec/lib/gitlab/access/branch_protection_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Access::BranchProtection do
- describe '#any?' do
+ describe "#any?" do
using RSpec::Parameterized::TableSyntax
where(:level, :result) do
@@ -18,7 +18,7 @@ describe Gitlab::Access::BranchProtection do
end
end
- describe '#developer_can_push?' do
+ describe "#developer_can_push?" do
using RSpec::Parameterized::TableSyntax
where(:level, :result) do
@@ -35,7 +35,7 @@ describe Gitlab::Access::BranchProtection do
end
end
- describe '#developer_can_merge?' do
+ describe "#developer_can_merge?" do
using RSpec::Parameterized::TableSyntax
where(:level, :result) do
diff --git a/spec/lib/gitlab/action_rate_limiter_spec.rb b/spec/lib/gitlab/action_rate_limiter_spec.rb
index 542fc03e555..fc51aac7eed 100644
--- a/spec/lib/gitlab/action_rate_limiter_spec.rb
+++ b/spec/lib/gitlab/action_rate_limiter_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ActionRateLimiter do
- let(:redis) { double('redis') }
+ let(:redis) { double("redis") }
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:key) { [user, project] }
@@ -13,14 +13,14 @@ describe Gitlab::ActionRateLimiter do
allow(Gitlab::Redis::Cache).to receive(:with).and_yield(redis)
end
- it 'increases the throttle count and sets the expire time' do
+ it "increases the throttle count and sets the expire time" do
expect(redis).to receive(:incr).with(cache_key).and_return(1)
expect(redis).to receive(:expire).with(cache_key, 100)
expect(subject.throttled?(key, 1)).to be false
end
- it 'returns true if the key is throttled' do
+ it "returns true if the key is throttled" do
expect(redis).to receive(:incr).with(cache_key).and_return(2)
expect(redis).not_to receive(:expire)
diff --git a/spec/lib/gitlab/allowable_spec.rb b/spec/lib/gitlab/allowable_spec.rb
index 9d80d480b52..e4909eb3513 100644
--- a/spec/lib/gitlab/allowable_spec.rb
+++ b/spec/lib/gitlab/allowable_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Allowable do
subject do
Class.new.include(described_class).new
end
- describe '#can?' do
+ describe "#can?" do
let(:user) { create(:user) }
- context 'when user is allowed to do something' do
+ context "when user is allowed to do something" do
let(:project) { create(:project, :public) }
- it 'reports correct ability to perform action' do
+ it "reports correct ability to perform action" do
expect(subject.can?(user, :read_project, project)).to be true
end
end
- context 'when user is not allowed to do something' do
+ context "when user is not allowed to do something" do
let(:project) { create(:project, :private) }
- it 'reports correct ability to perform action' do
+ it "reports correct ability to perform action" do
expect(subject.can?(user, :read_project, project)).to be false
end
end
diff --git a/spec/lib/gitlab/app_logger_spec.rb b/spec/lib/gitlab/app_logger_spec.rb
index c86d30ce6df..75a9b5c6f98 100644
--- a/spec/lib/gitlab/app_logger_spec.rb
+++ b/spec/lib/gitlab/app_logger_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::AppLogger, :request_store do
subject { described_class }
- it 'builds a logger once' do
+ it "builds a logger once" do
expect(::Logger).to receive(:new).and_call_original
- subject.info('hello world')
- subject.error('hello again')
+ subject.info("hello world")
+ subject.error("hello again")
end
end
diff --git a/spec/lib/gitlab/asciidoc_spec.rb b/spec/lib/gitlab/asciidoc_spec.rb
index e1782cff81a..a0a93d55a09 100644
--- a/spec/lib/gitlab/asciidoc_spec.rb
+++ b/spec/lib/gitlab/asciidoc_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'nokogiri'
+require "spec_helper"
+require "nokogiri"
module Gitlab
describe Asciidoc do
- let(:input) { '<b>ascii</b>' }
+ let(:input) { "<b>ascii</b>" }
let(:context) { {} }
- let(:html) { 'H<sub>2</sub>O' }
+ let(:html) { "H<sub>2</sub>O" }
context "without project" do
before do
@@ -14,9 +14,9 @@ module Gitlab
it "converts the input using Asciidoctor and default options" do
expected_asciidoc_opts = {
- safe: :secure,
- backend: :gitlab_html5,
- attributes: described_class::DEFAULT_ADOC_ATTRS
+ safe: :secure,
+ backend: :gitlab_html5,
+ attributes: described_class::DEFAULT_ADOC_ATTRS,
}
expect(Asciidoctor).to receive(:convert)
@@ -28,9 +28,9 @@ module Gitlab
context "with asciidoc_opts" do
it "merges the options with default ones" do
expected_asciidoc_opts = {
- safe: :secure,
- backend: :gitlab_html5,
- attributes: described_class::DEFAULT_ADOC_ATTRS
+ safe: :secure,
+ backend: :gitlab_html5,
+ attributes: described_class::DEFAULT_ADOC_ATTRS,
}
expect(Asciidoctor).to receive(:convert)
@@ -42,18 +42,18 @@ module Gitlab
context "XSS" do
links = {
- 'links' => {
+ "links" => {
input: 'link:mylink"onmouseover="alert(1)[Click Here]',
- output: "<div>\n<p><a href=\"mylink\">Click Here</a></p>\n</div>"
+ output: "<div>\n<p><a href=\"mylink\">Click Here</a></p>\n</div>",
},
- 'images' => {
+ "images" => {
input: 'image:https://localhost.com/image.png[Alt text" onerror="alert(7)]',
- output: "<div>\n<p><span><img src=\"https://localhost.com/image.png\" alt='Alt text\" onerror=\"alert(7)'></span></p>\n</div>"
+ output: "<div>\n<p><span><img src=\"https://localhost.com/image.png\" alt='Alt text\" onerror=\"alert(7)'></span></p>\n</div>",
},
- 'pre' => {
+ "pre" => {
input: '```mypre"><script>alert(3)</script>',
- output: "<div>\n<div>\n<pre lang=\"mypre\">\"&gt;<code></code></pre>\n</div>\n</div>"
- }
+ output: "<div>\n<div>\n<pre lang=\"mypre\">\"&gt;<code></code></pre>\n</div>\n</div>",
+ },
}
links.each do |name, data|
@@ -63,16 +63,16 @@ module Gitlab
end
end
- context 'external links' do
- it 'adds the `rel` attribute to the link' do
- output = render('link:https://google.com[Google]', context)
+ context "external links" do
+ it "adds the `rel` attribute to the link" do
+ output = render("link:https://google.com[Google]", context)
expect(output).to include('rel="nofollow noreferrer noopener"')
end
end
- context 'LaTex code' do
- it 'adds class js-render-math to the output' do
+ context "LaTex code" do
+ it "adds class js-render-math to the output" do
input = <<~MD
:stem: latexmath
@@ -89,15 +89,15 @@ module Gitlab
++++
stem:[2+2] is 4
- MD
+ MD
expect(render(input, context)).to include('<pre data-math-style="display" class="code math js-render-math"><code>eta_x gamma</code></pre>')
expect(render(input, context)).to include('<p><code data-math-style="inline" class="code math js-render-math">2+2</code> is 4</p>')
end
end
- context 'outfilesuffix' do
- it 'defaults to adoc' do
+ context "outfilesuffix" do
+ it "defaults to adoc" do
output = render("Inter-document reference <<README.adoc#>>", context)
expect(output).to include("a href=\"README.adoc\"")
diff --git a/spec/lib/gitlab/auth/activity_spec.rb b/spec/lib/gitlab/auth/activity_spec.rb
index 07854cb1eba..7f6037a0419 100644
--- a/spec/lib/gitlab/auth/activity_spec.rb
+++ b/spec/lib/gitlab/auth/activity_spec.rb
@@ -1,29 +1,29 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Auth::Activity do
- describe '.each_counter' do
- it 'has all static counters defined' do
+ describe ".each_counter" do
+ it "has all static counters defined" do
described_class.each_counter do |counter|
expect(described_class).to respond_to(counter)
end
end
- it 'has all static incrementers defined' do
+ it "has all static incrementers defined" do
described_class.each_counter do |counter|
expect(described_class).to respond_to("#{counter}_increment!")
end
end
- it 'has all counters starting with `user_`' do
+ it "has all counters starting with `user_`" do
described_class.each_counter do |counter|
- expect(counter).to start_with('user_')
+ expect(counter).to start_with("user_")
end
end
- it 'yields counter method, name and description' do
+ it "yields counter method, name and description" do
described_class.each_counter do |method, name, description|
expect(method).to eq "#{name}_counter"
- expect(description).to start_with('Counter of')
+ expect(description).to start_with("Counter of")
end
end
end
diff --git a/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb b/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb
index f39863fdda1..7e0f260dee7 100644
--- a/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb
+++ b/spec/lib/gitlab/auth/blocked_user_tracker_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::BlockedUserTracker do
- describe '#log_blocked_user_activity!' do
- context 'when user is not blocked' do
- it 'does not log blocked user activity' do
+ describe "#log_blocked_user_activity!" do
+ context "when user is not blocked" do
+ it "does not log blocked user activity" do
expect_any_instance_of(SystemHooksService)
.not_to receive(:execute_hooks_for)
expect(Gitlab::AppLogger).not_to receive(:info)
user = create(:user)
- described_class.new(user, spy('auth')).log_activity!
+ described_class.new(user, spy("auth")).log_activity!
end
end
- context 'when user is not blocked' do
- it 'logs blocked user activity' do
+ context "when user is not blocked" do
+ it "logs blocked user activity" do
user = create(:user, :blocked)
expect_any_instance_of(SystemHooksService)
@@ -24,7 +24,7 @@ describe Gitlab::Auth::BlockedUserTracker do
expect(Gitlab::AppLogger).to receive(:info)
.with(/Failed login for blocked user/)
- described_class.new(user, spy('auth')).log_activity!
+ described_class.new(user, spy("auth")).log_activity!
end
end
end
diff --git a/spec/lib/gitlab/auth/ldap/access_spec.rb b/spec/lib/gitlab/auth/ldap/access_spec.rb
index 662f899180b..708d5ba2cca 100644
--- a/spec/lib/gitlab/auth/ldap/access_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::Access do
include LdapHelpers
@@ -7,7 +7,7 @@ describe Gitlab::Auth::LDAP::Access do
subject(:access) { described_class.new(user) }
- describe '.allowed?' do
+ describe ".allowed?" do
before do
allow(access).to receive(:update_user)
allow(access).to receive(:allowed?).and_return(true)
@@ -27,25 +27,25 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- describe '#allowed?' do
- context 'when the user cannot be found' do
+ describe "#allowed?" do
+ context "when the user cannot be found" do
before do
stub_ldap_person_find_by_dn(nil)
stub_ldap_person_find_by_email(user.email, nil)
end
- it 'returns false' do
+ it "returns false" do
expect(access.allowed?).to be_falsey
end
- it 'blocks user in GitLab' do
+ it "blocks user in GitLab" do
access.allowed?
expect(user).to be_blocked
expect(user).to be_ldap_blocked
end
- it 'logs the reason' do
+ it "logs the reason" do
expect(Gitlab::AppLogger).to receive(:info).with(
"LDAP account \"123456\" does not exist anymore, " \
"blocking GitLab user \"#{user.name}\" (#{user.email})"
@@ -55,28 +55,28 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'when the user is found' do
+ context "when the user is found" do
before do
stub_ldap_person_find_by_dn(Net::LDAP::Entry.new)
end
- context 'and the user is disabled via active directory' do
+ context "and the user is disabled via active directory" do
before do
allow(Gitlab::Auth::LDAP::Person).to receive(:disabled_via_active_directory?).and_return(true)
end
- it 'returns false' do
+ it "returns false" do
expect(access.allowed?).to be_falsey
end
- it 'blocks user in GitLab' do
+ it "blocks user in GitLab" do
access.allowed?
expect(user).to be_blocked
expect(user).to be_ldap_blocked
end
- it 'logs the reason' do
+ it "logs the reason" do
expect(Gitlab::AppLogger).to receive(:info).with(
"LDAP account \"123456\" is disabled in Active Directory, " \
"blocking GitLab user \"#{user.name}\" (#{user.email})"
@@ -86,19 +86,19 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'and has no disabled flag in active directory' do
+ context "and has no disabled flag in active directory" do
before do
allow(Gitlab::Auth::LDAP::Person).to receive(:disabled_via_active_directory?).and_return(false)
end
it { is_expected.to be_truthy }
- context 'when auto-created users are blocked' do
+ context "when auto-created users are blocked" do
before do
user.block
end
- it 'does not unblock user in GitLab' do
+ it "does not unblock user in GitLab" do
expect(access).not_to receive(:unblock_user)
access.allowed?
@@ -108,19 +108,19 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'when auto-created users are not blocked' do
+ context "when auto-created users are not blocked" do
before do
user.ldap_block
end
- it 'unblocks user in GitLab' do
+ it "unblocks user in GitLab" do
access.allowed?
expect(user).not_to be_blocked
expect(user).not_to be_ldap_blocked
end
- it 'logs the reason' do
+ it "logs the reason" do
expect(Gitlab::AppLogger).to receive(:info).with(
"LDAP account \"123456\" is not disabled anymore, " \
"unblocking GitLab user \"#{user.name}\" (#{user.email})"
@@ -131,34 +131,34 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'without ActiveDirectory enabled' do
+ context "without ActiveDirectory enabled" do
before do
allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true)
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive(:active_directory).and_return(false)
end
- it 'returns true' do
+ it "returns true" do
expect(access.allowed?).to be_truthy
end
- context 'when user cannot be found' do
+ context "when user cannot be found" do
before do
stub_ldap_person_find_by_dn(nil)
stub_ldap_person_find_by_email(user.email, nil)
end
- it 'returns false' do
+ it "returns false" do
expect(access.allowed?).to be_falsey
end
- it 'blocks user in GitLab' do
+ it "blocks user in GitLab" do
access.allowed?
expect(user).to be_blocked
expect(user).to be_ldap_blocked
end
- it 'logs the reason' do
+ it "logs the reason" do
expect(Gitlab::AppLogger).to receive(:info).with(
"LDAP account \"123456\" does not exist anymore, " \
"blocking GitLab user \"#{user.name}\" (#{user.email})"
@@ -168,19 +168,19 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'when user was previously ldap_blocked' do
+ context "when user was previously ldap_blocked" do
before do
user.ldap_block
end
- it 'unblocks the user if it exists' do
+ it "unblocks the user if it exists" do
access.allowed?
expect(user).not_to be_blocked
expect(user).not_to be_ldap_blocked
end
- it 'logs the reason' do
+ it "logs the reason" do
expect(Gitlab::AppLogger).to receive(:info).with(
"LDAP account \"123456\" is available again, " \
"unblocking GitLab user \"#{user.name}\" (#{user.email})"
@@ -192,18 +192,18 @@ describe Gitlab::Auth::LDAP::Access do
end
end
- context 'when the connection fails' do
+ context "when the connection fails" do
before do
raise_ldap_connection_error
end
- it 'does not block the user' do
+ it "does not block the user" do
access.allowed?
expect(user.ldap_blocked?).to be_falsey
end
- it 'denies access' do
+ it "denies access" do
expect(access.allowed?).to be_falsey
end
end
diff --git a/spec/lib/gitlab/auth/ldap/adapter_spec.rb b/spec/lib/gitlab/auth/ldap/adapter_spec.rb
index 3eeaf3862f6..8cf5a522887 100644
--- a/spec/lib/gitlab/auth/ldap/adapter_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/adapter_spec.rb
@@ -1,76 +1,76 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::Adapter do
include LdapHelpers
let(:ldap) { double(:ldap) }
- let(:adapter) { ldap_adapter('ldapmain', ldap) }
+ let(:adapter) { ldap_adapter("ldapmain", ldap) }
- describe '#users' do
+ describe "#users" do
before do
- stub_ldap_config(base: 'dc=example,dc=com')
+ stub_ldap_config(base: "dc=example,dc=com")
end
- it 'searches with the proper options when searching by uid' do
+ it "searches with the proper options when searching by uid" do
# Requires this expectation style to match the filter
expect(adapter).to receive(:ldap_search) do |arg|
- expect(arg[:filter].to_s).to eq('(uid=johndoe)')
- expect(arg[:base]).to eq('dc=example,dc=com')
+ expect(arg[:filter].to_s).to eq("(uid=johndoe)")
+ expect(arg[:base]).to eq("dc=example,dc=com")
expect(arg[:attributes]).to match(ldap_attributes)
end.and_return({})
- adapter.users('uid', 'johndoe')
+ adapter.users("uid", "johndoe")
end
- it 'searches with the proper options when searching by dn' do
+ it "searches with the proper options when searching by dn" do
expect(adapter).to receive(:ldap_search).with(
- base: 'uid=johndoe,ou=users,dc=example,dc=com',
+ base: "uid=johndoe,ou=users,dc=example,dc=com",
scope: Net::LDAP::SearchScope_BaseObject,
attributes: ldap_attributes,
filter: nil
).and_return({})
- adapter.users('dn', 'uid=johndoe,ou=users,dc=example,dc=com')
+ adapter.users("dn", "uid=johndoe,ou=users,dc=example,dc=com")
end
- it 'searches with the proper options when searching with a limit' do
+ it "searches with the proper options when searching with a limit" do
expect(adapter)
.to receive(:ldap_search).with(hash_including(size: 100)).and_return({})
- adapter.users('uid', 'johndoe', 100)
+ adapter.users("uid", "johndoe", 100)
end
- it 'returns an LDAP::Person if search returns a result' do
- entry = ldap_user_entry('johndoe')
+ it "returns an LDAP::Person if search returns a result" do
+ entry = ldap_user_entry("johndoe")
allow(adapter).to receive(:ldap_search).and_return([entry])
- results = adapter.users('uid', 'johndoe')
+ results = adapter.users("uid", "johndoe")
expect(results.size).to eq(1)
- expect(results.first.uid).to eq('johndoe')
+ expect(results.first.uid).to eq("johndoe")
end
- it 'returns empty array if search entry does not respond to uid' do
+ it "returns empty array if search entry does not respond to uid" do
entry = Net::LDAP::Entry.new
- entry['dn'] = user_dn('johndoe')
+ entry["dn"] = user_dn("johndoe")
allow(adapter).to receive(:ldap_search).and_return([entry])
- results = adapter.users('uid', 'johndoe')
+ results = adapter.users("uid", "johndoe")
expect(results).to be_empty
end
- it 'uses the right uid attribute when non-default' do
- stub_ldap_config(uid: 'sAMAccountName')
+ it "uses the right uid attribute when non-default" do
+ stub_ldap_config(uid: "sAMAccountName")
expect(adapter).to receive(:ldap_search).with(
hash_including(attributes: ldap_attributes)
).and_return({})
- adapter.users('sAMAccountName', 'johndoe')
+ adapter.users("sAMAccountName", "johndoe")
end
end
- describe '#dn_matches_filter?' do
+ describe "#dn_matches_filter?" do
subject { adapter.dn_matches_filter?(:dn, :filter) }
context "when the search result is non-empty" do
@@ -90,7 +90,7 @@ describe Gitlab::Auth::LDAP::Adapter do
end
end
- describe '#ldap_search' do
+ describe "#ldap_search" do
subject { adapter.ldap_search(base: :dn, filter: :filter) }
context "when the search is successful" do
@@ -115,7 +115,7 @@ describe Gitlab::Auth::LDAP::Adapter do
before do
allow(ldap).to receive_messages(
search: nil,
- get_operation_result: double(code: 1, message: 'some error')
+ get_operation_result: double(code: 1, message: "some error")
)
end
@@ -129,29 +129,30 @@ describe Gitlab::Auth::LDAP::Adapter do
allow(Rails.logger).to receive(:warn)
end
- context 'retries the operation' do
+ context "retries the operation" do
before do
stub_const("#{described_class}::MAX_SEARCH_RETRIES", 3)
end
- it 'as many times as MAX_SEARCH_RETRIES' do
+ it "as many times as MAX_SEARCH_RETRIES" do
expect(ldap).to receive(:search).exactly(3).times
expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError)
end
- context 'when no more retries' do
+ context "when no more retries" do
before do
stub_const("#{described_class}::MAX_SEARCH_RETRIES", 1)
end
- it 'raises the exception' do
+ it "raises the exception" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError)
end
- it 'logs the error' do
+ it "logs the error" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError)
expect(Rails.logger).to have_received(:warn).with(
- "LDAP search raised exception Net::LDAP::Error: some error")
+ "LDAP search raised exception Net::LDAP::Error: some error"
+ )
end
end
end
@@ -159,6 +160,6 @@ describe Gitlab::Auth::LDAP::Adapter do
end
def ldap_attributes
- Gitlab::Auth::LDAP::Person.ldap_attributes(Gitlab::Auth::LDAP::Config.new('ldapmain'))
+ Gitlab::Auth::LDAP::Person.ldap_attributes(Gitlab::Auth::LDAP::Config.new("ldapmain"))
end
end
diff --git a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
index 05541972f87..2ccb4638af3 100644
--- a/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/auth_hash_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::AuthHash do
include LdapHelpers
@@ -7,10 +7,10 @@ describe Gitlab::Auth::LDAP::AuthHash do
described_class.new(
OmniAuth::AuthHash.new(
uid: given_uid,
- provider: 'ldapmain',
+ provider: "ldapmain",
info: info,
extra: {
- raw_info: raw_info
+ raw_info: raw_info,
}
)
)
@@ -18,23 +18,23 @@ describe Gitlab::Auth::LDAP::AuthHash do
let(:info) do
{
- name: 'Smith, J.',
- email: 'johnsmith@example.com',
- nickname: '123456'
+ name: "Smith, J.",
+ email: "johnsmith@example.com",
+ nickname: "123456",
}
end
let(:raw_info) do
{
- uid: ['123456'],
- email: ['johnsmith@example.com'],
- cn: ['Smith, J.'],
- fullName: ['John Smith']
+ uid: ["123456"],
+ email: ["johnsmith@example.com"],
+ cn: ["Smith, J."],
+ fullName: ["John Smith"],
}
end
context "without overridden attributes" do
- let(:given_uid) { 'uid=John Smith,ou=People,dc=example,dc=com' }
+ let(:given_uid) { "uid=John Smith,ou=People,dc=example,dc=com" }
it "has the correct username" do
expect(auth_hash.username).to eq("123456")
@@ -46,12 +46,12 @@ describe Gitlab::Auth::LDAP::AuthHash do
end
context "with overridden attributes" do
- let(:given_uid) { 'uid=John Smith,ou=People,dc=example,dc=com' }
+ let(:given_uid) { "uid=John Smith,ou=People,dc=example,dc=com" }
let(:attributes) do
{
- 'username' => %w(mail email),
- 'name' => 'fullName'
+ "username" => %w[mail email],
+ "name" => "fullName",
}
end
@@ -68,42 +68,42 @@ describe Gitlab::Auth::LDAP::AuthHash do
end
end
- describe '#uid' do
- context 'when there is extraneous (but valid) whitespace' do
- let(:given_uid) { 'uid =john smith , ou = people, dc= example,dc =com' }
+ describe "#uid" do
+ context "when there is extraneous (but valid) whitespace" do
+ let(:given_uid) { "uid =john smith , ou = people, dc= example,dc =com" }
- it 'removes the extraneous whitespace' do
- expect(auth_hash.uid).to eq('uid=john smith,ou=people,dc=example,dc=com')
+ it "removes the extraneous whitespace" do
+ expect(auth_hash.uid).to eq("uid=john smith,ou=people,dc=example,dc=com")
end
end
- context 'when there are upper case characters' do
- let(:given_uid) { 'UID=John Smith,ou=People,dc=example,dc=com' }
+ context "when there are upper case characters" do
+ let(:given_uid) { "UID=John Smith,ou=People,dc=example,dc=com" }
- it 'downcases' do
- expect(auth_hash.uid).to eq('uid=john smith,ou=people,dc=example,dc=com')
+ it "downcases" do
+ expect(auth_hash.uid).to eq("uid=john smith,ou=people,dc=example,dc=com")
end
end
end
- describe '#username' do
- context 'if lowercase_usernames setting is' do
- let(:given_uid) { 'uid=John Smith,ou=People,dc=example,dc=com' }
+ describe "#username" do
+ context "if lowercase_usernames setting is" do
+ let(:given_uid) { "uid=John Smith,ou=People,dc=example,dc=com" }
before do
- raw_info[:uid] = ['JOHN']
+ raw_info[:uid] = ["JOHN"]
end
- it 'enabled the username attribute is lower cased' do
+ it "enabled the username attribute is lower cased" do
stub_ldap_config(lowercase_usernames: true)
- expect(auth_hash.username).to eq 'john'
+ expect(auth_hash.username).to eq "john"
end
- it 'disabled the username attribute is not lower cased' do
+ it "disabled the username attribute is not lower cased" do
stub_ldap_config(lowercase_usernames: false)
- expect(auth_hash.username).to eq 'JOHN'
+ expect(auth_hash.username).to eq "JOHN"
end
end
end
diff --git a/spec/lib/gitlab/auth/ldap/authentication_spec.rb b/spec/lib/gitlab/auth/ldap/authentication_spec.rb
index 111572d043b..0eeca3ba5a6 100644
--- a/spec/lib/gitlab/auth/ldap/authentication_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/authentication_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::Authentication do
- let(:dn) { 'uid=John Smith, ou=People, dc=example, dc=com' }
+ let(:dn) { "uid=John Smith, ou=People, dc=example, dc=com" }
let(:user) { create(:omniauth_user, extern_uid: Gitlab::Auth::LDAP::Person.normalize_dn(dn)) }
- let(:login) { 'john' }
- let(:password) { 'password' }
+ let(:login) { "john" }
+ let(:password) { "password" }
- describe 'login' do
+ describe "login" do
before do
allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true)
end
@@ -15,7 +15,7 @@ describe Gitlab::Auth::LDAP::Authentication do
expect(user).not_to be_nil
# try only to fake the LDAP call
- adapter = double('adapter', dn: dn).as_null_object
+ adapter = double("adapter", dn: dn).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
@@ -24,7 +24,7 @@ describe Gitlab::Auth::LDAP::Authentication do
it "is false if the user does not exist" do
# try only to fake the LDAP call
- adapter = double('adapter', dn: dn).as_null_object
+ adapter = double("adapter", dn: dn).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
@@ -35,7 +35,7 @@ describe Gitlab::Auth::LDAP::Authentication do
expect(user).not_to be_nil
# try only to fake the LDAP call
- adapter = double('adapter', bind_as: nil).as_null_object
+ adapter = double("adapter", bind_as: nil).as_null_object
allow_any_instance_of(described_class)
.to receive(:adapter).and_return(adapter)
@@ -48,11 +48,11 @@ describe Gitlab::Auth::LDAP::Authentication do
end
it "fails if no login is supplied" do
- expect(described_class.login('', password)).to be_falsey
+ expect(described_class.login("", password)).to be_falsey
end
it "fails if no password is supplied" do
- expect(described_class.login(login, '')).to be_falsey
+ expect(described_class.login(login, "")).to be_falsey
end
end
end
diff --git a/spec/lib/gitlab/auth/ldap/config_spec.rb b/spec/lib/gitlab/auth/ldap/config_spec.rb
index d3ab599d5a0..d87938a87c0 100644
--- a/spec/lib/gitlab/auth/ldap/config_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/config_spec.rb
@@ -1,151 +1,151 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::Config do
include LdapHelpers
- let(:config) { described_class.new('ldapmain') }
+ let(:config) { described_class.new("ldapmain") }
- describe '.servers' do
- it 'returns empty array if no server information is available' do
- allow(Gitlab.config).to receive(:ldap).and_return('enabled' => false)
+ describe ".servers" do
+ it "returns empty array if no server information is available" do
+ allow(Gitlab.config).to receive(:ldap).and_return("enabled" => false)
expect(described_class.servers).to eq []
end
end
- describe '#initialize' do
- it 'requires a provider' do
+ describe "#initialize" do
+ it "requires a provider" do
expect { described_class.new }.to raise_error ArgumentError
end
- it 'works' do
+ it "works" do
expect(config).to be_a described_class
end
- it 'raises an error if a unknown provider is used' do
- expect { described_class.new 'unknown' }.to raise_error(described_class::InvalidProvider)
+ it "raises an error if a unknown provider is used" do
+ expect { described_class.new "unknown" }.to raise_error(described_class::InvalidProvider)
end
end
- describe '#adapter_options' do
- it 'constructs basic options' do
+ describe "#adapter_options" do
+ it "constructs basic options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 386,
- 'encryption' => 'plain'
+ "host" => "ldap.example.com",
+ "port" => 386,
+ "encryption" => "plain",
}
)
expect(config.adapter_options).to eq(
- host: 'ldap.example.com',
+ host: "ldap.example.com",
port: 386,
encryption: nil
)
end
- it 'includes authentication options when auth is configured' do
+ it "includes authentication options when auth is configured" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true,
- 'bind_dn' => 'uid=admin,dc=example,dc=com',
- 'password' => 'super_secret'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
+ "bind_dn" => "uid=admin,dc=example,dc=com",
+ "password" => "super_secret",
}
)
expect(config.adapter_options).to include({
auth: {
method: :simple,
- username: 'uid=admin,dc=example,dc=com',
- password: 'super_secret'
- }
+ username: "uid=admin,dc=example,dc=com",
+ password: "super_secret",
+ },
})
end
- it 'sets encryption method to simple_tls when configured as simple_tls' do
+ it "sets encryption method to simple_tls when configured as simple_tls" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
}
)
- expect(config.adapter_options[:encryption]).to include({ method: :simple_tls })
+ expect(config.adapter_options[:encryption]).to include({method: :simple_tls})
end
- it 'sets encryption method to start_tls when configured as start_tls' do
+ it "sets encryption method to start_tls when configured as start_tls" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'start_tls'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "start_tls",
}
)
- expect(config.adapter_options[:encryption]).to include({ method: :start_tls })
+ expect(config.adapter_options[:encryption]).to include({method: :start_tls})
end
- context 'when verify_certificates is enabled' do
- it 'sets tls_options to OpenSSL defaults' do
+ context "when verify_certificates is enabled" do
+ it "sets tls_options to OpenSSL defaults" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
}
)
- expect(config.adapter_options[:encryption]).to include({ tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS })
+ expect(config.adapter_options[:encryption]).to include({tls_options: OpenSSL::SSL::SSLContext::DEFAULT_PARAMS})
end
end
- context 'when verify_certificates is disabled' do
- it 'sets verify_mode to OpenSSL VERIFY_NONE' do
+ context "when verify_certificates is disabled" do
+ it "sets verify_mode to OpenSSL VERIFY_NONE" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => false
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => false,
}
)
expect(config.adapter_options[:encryption]).to include({
tls_options: {
- verify_mode: OpenSSL::SSL::VERIFY_NONE
- }
+ verify_mode: OpenSSL::SSL::VERIFY_NONE,
+ },
})
end
end
- context 'when ca_file is specified' do
- it 'passes it through in tls_options' do
+ context "when ca_file is specified" do
+ it "passes it through in tls_options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'ca_file' => '/etc/ca.pem'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "ca_file" => "/etc/ca.pem",
}
)
- expect(config.adapter_options[:encryption][:tls_options]).to include({ ca_file: '/etc/ca.pem' })
+ expect(config.adapter_options[:encryption][:tls_options]).to include({ca_file: "/etc/ca.pem"})
end
end
- context 'when ca_file is a blank string' do
- it 'does not add the ca_file key to tls_options' do
+ context "when ca_file is a blank string" do
+ it "does not add the ca_file key to tls_options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'ca_file' => ' '
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "ca_file" => " ",
}
)
@@ -153,29 +153,29 @@ describe Gitlab::Auth::LDAP::Config do
end
end
- context 'when ssl_version is specified' do
- it 'passes it through in tls_options' do
+ context "when ssl_version is specified" do
+ it "passes it through in tls_options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'ssl_version' => 'TLSv1_2'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "ssl_version" => "TLSv1_2",
}
)
- expect(config.adapter_options[:encryption][:tls_options]).to include({ ssl_version: 'TLSv1_2' })
+ expect(config.adapter_options[:encryption][:tls_options]).to include({ssl_version: "TLSv1_2"})
end
end
- context 'when ssl_version is a blank string' do
- it 'does not add the ssl_version key to tls_options' do
+ context "when ssl_version is a blank string" do
+ it "does not add the ssl_version key to tls_options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'ssl_version' => ' '
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "ssl_version" => " ",
}
)
@@ -184,100 +184,100 @@ describe Gitlab::Auth::LDAP::Config do
end
end
- describe '#omniauth_options' do
- it 'constructs basic options' do
+ describe "#omniauth_options" do
+ it "constructs basic options" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 386,
- 'base' => 'ou=users,dc=example,dc=com',
- 'encryption' => 'plain',
- 'uid' => 'uid'
+ "host" => "ldap.example.com",
+ "port" => 386,
+ "base" => "ou=users,dc=example,dc=com",
+ "encryption" => "plain",
+ "uid" => "uid",
}
)
expect(config.omniauth_options).to include(
- host: 'ldap.example.com',
+ host: "ldap.example.com",
port: 386,
- base: 'ou=users,dc=example,dc=com',
- encryption: 'plain',
- filter: '(uid=%{username})'
+ base: "ou=users,dc=example,dc=com",
+ encryption: "plain",
+ filter: "(uid=%{username})"
)
expect(config.omniauth_options.keys).not_to include(:bind_dn, :password)
end
- it 'includes authentication options when auth is configured' do
+ it "includes authentication options when auth is configured" do
stub_ldap_config(
options: {
- 'uid' => 'sAMAccountName',
- 'user_filter' => '(memberOf=cn=group1,ou=groups,dc=example,dc=com)',
- 'bind_dn' => 'uid=admin,dc=example,dc=com',
- 'password' => 'super_secret'
+ "uid" => "sAMAccountName",
+ "user_filter" => "(memberOf=cn=group1,ou=groups,dc=example,dc=com)",
+ "bind_dn" => "uid=admin,dc=example,dc=com",
+ "password" => "super_secret",
}
)
expect(config.omniauth_options).to include(
- filter: '(&(sAMAccountName=%{username})(memberOf=cn=group1,ou=groups,dc=example,dc=com))',
- bind_dn: 'uid=admin,dc=example,dc=com',
- password: 'super_secret'
+ filter: "(&(sAMAccountName=%{username})(memberOf=cn=group1,ou=groups,dc=example,dc=com))",
+ bind_dn: "uid=admin,dc=example,dc=com",
+ password: "super_secret"
)
end
- context 'when verify_certificates is enabled' do
- it 'specifies disable_verify_certificates as false' do
+ context "when verify_certificates is enabled" do
+ it "specifies disable_verify_certificates as false" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
}
)
- expect(config.omniauth_options).to include({ disable_verify_certificates: false })
+ expect(config.omniauth_options).to include({disable_verify_certificates: false})
end
end
- context 'when verify_certificates is disabled' do
- it 'specifies disable_verify_certificates as true' do
+ context "when verify_certificates is disabled" do
+ it "specifies disable_verify_certificates as true" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => false
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => false,
}
)
- expect(config.omniauth_options).to include({ disable_verify_certificates: true })
+ expect(config.omniauth_options).to include({disable_verify_certificates: true})
end
end
- context 'when ca_file is present' do
- it 'passes it through' do
+ context "when ca_file is present" do
+ it "passes it through" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true,
- 'ca_file' => '/etc/ca.pem'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
+ "ca_file" => "/etc/ca.pem",
}
)
- expect(config.omniauth_options).to include({ ca_file: '/etc/ca.pem' })
+ expect(config.omniauth_options).to include({ca_file: "/etc/ca.pem"})
end
end
- context 'when ca_file is blank' do
- it 'does not include the ca_file option' do
+ context "when ca_file is blank" do
+ it "does not include the ca_file option" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true,
- 'ca_file' => ' '
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
+ "ca_file" => " ",
}
)
@@ -285,31 +285,31 @@ describe Gitlab::Auth::LDAP::Config do
end
end
- context 'when ssl_version is present' do
- it 'passes it through' do
+ context "when ssl_version is present" do
+ it "passes it through" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true,
- 'ssl_version' => 'TLSv1_2'
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
+ "ssl_version" => "TLSv1_2",
}
)
- expect(config.omniauth_options).to include({ ssl_version: 'TLSv1_2' })
+ expect(config.omniauth_options).to include({ssl_version: "TLSv1_2"})
end
end
- context 'when ssl_version is blank' do
- it 'does not include the ssl_version option' do
+ context "when ssl_version is blank" do
+ it "does not include the ssl_version option" do
stub_ldap_config(
options: {
- 'host' => 'ldap.example.com',
- 'port' => 686,
- 'encryption' => 'simple_tls',
- 'verify_certificates' => true,
- 'ssl_version' => ' '
+ "host" => "ldap.example.com",
+ "port" => 686,
+ "encryption" => "simple_tls",
+ "verify_certificates" => true,
+ "ssl_version" => " ",
}
)
@@ -318,89 +318,89 @@ describe Gitlab::Auth::LDAP::Config do
end
end
- describe '#has_auth?' do
- it 'is true when password is set' do
+ describe "#has_auth?" do
+ it "is true when password is set" do
stub_ldap_config(
options: {
- 'bind_dn' => 'uid=admin,dc=example,dc=com',
- 'password' => 'super_secret'
+ "bind_dn" => "uid=admin,dc=example,dc=com",
+ "password" => "super_secret",
}
)
expect(config.has_auth?).to be_truthy
end
- it 'is true when bind_dn is set and password is empty' do
+ it "is true when bind_dn is set and password is empty" do
stub_ldap_config(
options: {
- 'bind_dn' => 'uid=admin,dc=example,dc=com',
- 'password' => ''
+ "bind_dn" => "uid=admin,dc=example,dc=com",
+ "password" => "",
}
)
expect(config.has_auth?).to be_truthy
end
- it 'is false when password and bind_dn are not set' do
- stub_ldap_config(options: { 'bind_dn' => nil, 'password' => nil })
+ it "is false when password and bind_dn are not set" do
+ stub_ldap_config(options: {"bind_dn" => nil, "password" => nil})
expect(config.has_auth?).to be_falsey
end
end
- describe '#attributes' do
- it 'uses default attributes when no custom attributes are configured' do
+ describe "#attributes" do
+ it "uses default attributes when no custom attributes are configured" do
expect(config.attributes).to eq(config.default_attributes)
end
- it 'merges the configuration attributes with default attributes' do
+ it "merges the configuration attributes with default attributes" do
stub_ldap_config(
options: {
- 'attributes' => {
- 'username' => %w(sAMAccountName),
- 'email' => %w(userPrincipalName)
- }
+ "attributes" => {
+ "username" => %w[sAMAccountName],
+ "email" => %w[userPrincipalName],
+ },
}
)
expect(config.attributes).to include({
- 'username' => %w(sAMAccountName),
- 'email' => %w(userPrincipalName),
- 'name' => 'cn'
+ "username" => %w[sAMAccountName],
+ "email" => %w[userPrincipalName],
+ "name" => "cn",
})
end
end
- describe '#base' do
- context 'when the configured base is not normalized' do
- it 'returns the normalized base' do
- stub_ldap_config(options: { 'base' => 'DC=example, DC= com' })
+ describe "#base" do
+ context "when the configured base is not normalized" do
+ it "returns the normalized base" do
+ stub_ldap_config(options: {"base" => "DC=example, DC= com"})
- expect(config.base).to eq('dc=example,dc=com')
+ expect(config.base).to eq("dc=example,dc=com")
end
end
- context 'when the configured base is normalized' do
- it 'returns the base unaltered' do
- stub_ldap_config(options: { 'base' => 'dc=example,dc=com' })
+ context "when the configured base is normalized" do
+ it "returns the base unaltered" do
+ stub_ldap_config(options: {"base" => "dc=example,dc=com"})
- expect(config.base).to eq('dc=example,dc=com')
+ expect(config.base).to eq("dc=example,dc=com")
end
end
- context 'when the configured base is malformed' do
- it 'returns the base unaltered' do
- stub_ldap_config(options: { 'base' => 'invalid,dc=example,dc=com' })
+ context "when the configured base is malformed" do
+ it "returns the base unaltered" do
+ stub_ldap_config(options: {"base" => "invalid,dc=example,dc=com"})
- expect(config.base).to eq('invalid,dc=example,dc=com')
+ expect(config.base).to eq("invalid,dc=example,dc=com")
end
end
- context 'when the configured base is blank' do
- it 'returns the base unaltered' do
- stub_ldap_config(options: { 'base' => '' })
+ context "when the configured base is blank" do
+ it "returns the base unaltered" do
+ stub_ldap_config(options: {"base" => ""})
- expect(config.base).to eq('')
+ expect(config.base).to eq("")
end
end
end
diff --git a/spec/lib/gitlab/auth/ldap/dn_spec.rb b/spec/lib/gitlab/auth/ldap/dn_spec.rb
index f2983a02602..ee09be57657 100644
--- a/spec/lib/gitlab/auth/ldap/dn_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/dn_spec.rb
@@ -1,108 +1,108 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::DN do
using RSpec::Parameterized::TableSyntax
- describe '#normalize_value' do
+ describe "#normalize_value" do
subject { described_class.normalize_value(given) }
- it_behaves_like 'normalizes a DN attribute value'
+ it_behaves_like "normalizes a DN attribute value"
- context 'when the given DN is malformed' do
- context 'when ending with a comma' do
- let(:given) { 'John Smith,' }
+ context "when the given DN is malformed" do
+ context "when ending with a comma" do
+ let(:given) { "John Smith," }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'when given a BER encoded attribute value with a space in it' do
- let(:given) { '#aa aa' }
+ context "when given a BER encoded attribute value with a space in it" do
+ let(:given) { "#aa aa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"")
end
end
- context 'when given a BER encoded attribute value with a non-hex character in it' do
- let(:given) { '#aaXaaa' }
+ context "when given a BER encoded attribute value with a non-hex character in it" do
+ let(:given) { "#aaXaaa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"")
end
end
- context 'when given a BER encoded attribute value with a non-hex character in it' do
- let(:given) { '#aaaYaa' }
+ context "when given a BER encoded attribute value with a non-hex character in it" do
+ let(:given) { "#aaaYaa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"")
end
end
- context 'when given a hex pair with a non-hex character in it, inside double quotes' do
+ context "when given a hex pair with a non-hex character in it, inside double quotes" do
let(:given) { '"Sebasti\\cX\\a1n"' }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"")
end
end
- context 'with an open (as opposed to closed) double quote' do
+ context "with an open (as opposed to closed) double quote" do
let(:given) { '"James' }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'with an invalid escaped hex code' do
+ context "with an invalid escaped hex code" do
let(:given) { 'J\ames' }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"')
end
end
- context 'with a value ending with the escape character' do
+ context "with a value ending with the escape character" do
let(:given) { 'foo\\' }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
end
end
- describe '#to_normalized_s' do
+ describe "#to_normalized_s" do
subject { described_class.new(given).to_normalized_s }
- it_behaves_like 'normalizes a DN'
+ it_behaves_like "normalizes a DN"
- context 'when we do not support the given DN format' do
- context 'multivalued RDNs' do
- context 'without extraneous whitespace' do
- let(:given) { 'uid=john smith+telephonenumber=+1 555-555-5555,ou=people,dc=example,dc=com' }
+ context "when we do not support the given DN format" do
+ context "multivalued RDNs" do
+ context "without extraneous whitespace" do
+ let(:given) { "uid=john smith+telephonenumber=+1 555-555-5555,ou=people,dc=example,dc=com" }
- it 'raises UnsupportedError' do
+ it "raises UnsupportedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError)
end
end
- context 'with extraneous whitespace' do
- context 'around the phone number plus sign' do
- let(:given) { 'uid = John Smith + telephoneNumber = + 1 555-555-5555 , ou = People,dc=example,dc=com' }
+ context "with extraneous whitespace" do
+ context "around the phone number plus sign" do
+ let(:given) { "uid = John Smith + telephoneNumber = + 1 555-555-5555 , ou = People,dc=example,dc=com" }
- it 'raises UnsupportedError' do
+ it "raises UnsupportedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError)
end
end
- context 'not around the phone number plus sign' do
- let(:given) { 'uid = John Smith + telephoneNumber = +1 555-555-5555 , ou = People,dc=example,dc=com' }
+ context "not around the phone number plus sign" do
+ let(:given) { "uid = John Smith + telephoneNumber = +1 555-555-5555 , ou = People,dc=example,dc=com" }
- it 'raises UnsupportedError' do
+ it "raises UnsupportedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::UnsupportedError)
end
end
@@ -110,107 +110,107 @@ describe Gitlab::Auth::LDAP::DN do
end
end
- context 'when the given DN is malformed' do
- context 'when ending with a comma' do
- let(:given) { 'uid=John Smith,' }
+ context "when the given DN is malformed" do
+ context "when ending with a comma" do
+ let(:given) { "uid=John Smith," }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'when given a BER encoded attribute value with a space in it' do
- let(:given) { '0.9.2342.19200300.100.1.25=#aa aa' }
+ context "when given a BER encoded attribute value with a space in it" do
+ let(:given) { "0.9.2342.19200300.100.1.25=#aa aa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the end of an attribute value, but got \"a\"")
end
end
- context 'when given a BER encoded attribute value with a non-hex character in it' do
- let(:given) { '0.9.2342.19200300.100.1.25=#aaXaaa' }
+ context "when given a BER encoded attribute value with a non-hex character in it" do
+ let(:given) { "0.9.2342.19200300.100.1.25=#aaXaaa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the first character of a hex pair, but got \"X\"")
end
end
- context 'when given a BER encoded attribute value with a non-hex character in it' do
- let(:given) { '0.9.2342.19200300.100.1.25=#aaaYaa' }
+ context "when given a BER encoded attribute value with a non-hex character in it" do
+ let(:given) { "0.9.2342.19200300.100.1.25=#aaaYaa" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair, but got \"Y\"")
end
end
- context 'when given a hex pair with a non-hex character in it, inside double quotes' do
+ context "when given a hex pair with a non-hex character in it, inside double quotes" do
let(:given) { 'uid="Sebasti\\cX\\a1n"' }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "Expected the second character of a hex pair inside a double quoted value, but got \"X\"")
end
end
- context 'without a name value pair' do
- let(:given) { 'John' }
+ context "without a name value pair" do
+ let(:given) { "John" }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'with an open (as opposed to closed) double quote' do
+ context "with an open (as opposed to closed) double quote" do
let(:given) { 'cn="James' }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'with an invalid escaped hex code' do
+ context "with an invalid escaped hex code" do
let(:given) { 'cn=J\ames' }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Invalid escaped hex code "\am"')
end
end
- context 'with a value ending with the escape character' do
+ context "with a value ending with the escape character" do
let(:given) { 'cn=\\' }
- it 'raises MalformedError' do
- expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'DN string ended unexpectedly')
+ it "raises MalformedError" do
+ expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, "DN string ended unexpectedly")
end
end
- context 'with an invalid OID attribute type name' do
- let(:given) { '1.2.d=Value' }
+ context "with an invalid OID attribute type name" do
+ let(:given) { "1.2.d=Value" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN OID attribute type name character "d"')
end
end
- context 'with a period in a non-OID attribute type name' do
- let(:given) { 'd1.2=Value' }
+ context "with a period in a non-OID attribute type name" do
+ let(:given) { "d1.2=Value" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "."')
end
end
- context 'when starting with non-space, non-alphanumeric character' do
- let(:given) { ' -uid=John Smith' }
+ context "when starting with non-space, non-alphanumeric character" do
+ let(:given) { " -uid=John Smith" }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized first character of an RDN attribute type name "-"')
end
end
- context 'when given a UID with an escaped equal sign' do
+ context "when given a UID with an escaped equal sign" do
let(:given) { 'uid\\=john' }
- it 'raises MalformedError' do
+ it "raises MalformedError" do
expect { subject }.to raise_error(Gitlab::Auth::LDAP::DN::MalformedError, 'Unrecognized RDN attribute type name character "\\"')
end
end
diff --git a/spec/lib/gitlab/auth/ldap/person_spec.rb b/spec/lib/gitlab/auth/ldap/person_spec.rb
index 1527fe60fb9..74b15618b19 100644
--- a/spec/lib/gitlab/auth/ldap/person_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/person_spec.rb
@@ -1,154 +1,154 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::Person do
include LdapHelpers
- let(:entry) { ldap_user_entry('john.doe') }
+ let(:entry) { ldap_user_entry("john.doe") }
before do
stub_ldap_config(
options: {
- 'uid' => 'uid',
- 'attributes' => {
- 'name' => 'cn',
- 'email' => %w(mail email userPrincipalName),
- 'username' => username_attribute
- }
+ "uid" => "uid",
+ "attributes" => {
+ "name" => "cn",
+ "email" => %w[mail email userPrincipalName],
+ "username" => username_attribute,
+ },
}
)
end
- let(:username_attribute) { %w(uid sAMAccountName userid) }
+ let(:username_attribute) { %w[uid sAMAccountName userid] }
- describe '.normalize_dn' do
+ describe ".normalize_dn" do
subject { described_class.normalize_dn(given) }
- it_behaves_like 'normalizes a DN'
+ it_behaves_like "normalizes a DN"
- context 'with an exception during normalization' do
+ context "with an exception during normalization" do
let(:given) { 'John "Smith,' } # just something that will cause an exception
- it 'returns the given DN unmodified' do
+ it "returns the given DN unmodified" do
expect(subject).to eq(given)
end
end
end
- describe '.normalize_uid' do
+ describe ".normalize_uid" do
subject { described_class.normalize_uid(given) }
- it_behaves_like 'normalizes a DN attribute value'
+ it_behaves_like "normalizes a DN attribute value"
- context 'with an exception during normalization' do
+ context "with an exception during normalization" do
let(:given) { 'John "Smith,' } # just something that will cause an exception
- it 'returns the given UID unmodified' do
+ it "returns the given UID unmodified" do
expect(subject).to eq(given)
end
end
end
- describe '.ldap_attributes' do
- it 'returns a compact and unique array' do
+ describe ".ldap_attributes" do
+ it "returns a compact and unique array" do
stub_ldap_config(
options: {
- 'uid' => nil,
- 'attributes' => {
- 'name' => 'cn',
- 'email' => 'mail',
- 'username' => %w(uid mail memberof)
- }
+ "uid" => nil,
+ "attributes" => {
+ "name" => "cn",
+ "email" => "mail",
+ "username" => %w[uid mail memberof],
+ },
}
)
- config = Gitlab::Auth::LDAP::Config.new('ldapmain')
+ config = Gitlab::Auth::LDAP::Config.new("ldapmain")
ldap_attributes = described_class.ldap_attributes(config)
- expect(ldap_attributes).to match_array(%w(dn uid cn mail memberof))
+ expect(ldap_attributes).to match_array(%w[dn uid cn mail memberof])
end
end
- describe '#name' do
- it 'uses the configured name attribute and handles values as an array' do
- name = 'John Doe'
- entry['cn'] = [name]
- person = described_class.new(entry, 'ldapmain')
+ describe "#name" do
+ it "uses the configured name attribute and handles values as an array" do
+ name = "John Doe"
+ entry["cn"] = [name]
+ person = described_class.new(entry, "ldapmain")
expect(person.name).to eq(name)
end
end
- describe '#email' do
- it 'returns the value of mail, if present' do
- mail = 'john@example.com'
- entry['mail'] = mail
- person = described_class.new(entry, 'ldapmain')
+ describe "#email" do
+ it "returns the value of mail, if present" do
+ mail = "john@example.com"
+ entry["mail"] = mail
+ person = described_class.new(entry, "ldapmain")
expect(person.email).to eq([mail])
end
- it 'returns the value of userPrincipalName, if mail and email are not present' do
- user_principal_name = 'john.doe@example.com'
- entry['userPrincipalName'] = user_principal_name
- person = described_class.new(entry, 'ldapmain')
+ it "returns the value of userPrincipalName, if mail and email are not present" do
+ user_principal_name = "john.doe@example.com"
+ entry["userPrincipalName"] = user_principal_name
+ person = described_class.new(entry, "ldapmain")
expect(person.email).to eq([user_principal_name])
end
end
- describe '#username' do
- context 'with default uid username attribute' do
- let(:username_attribute) { 'uid' }
+ describe "#username" do
+ context "with default uid username attribute" do
+ let(:username_attribute) { "uid" }
- it 'returns the proper username value' do
- attr_value = 'johndoe'
+ it "returns the proper username value" do
+ attr_value = "johndoe"
entry[username_attribute] = attr_value
- person = described_class.new(entry, 'ldapmain')
+ person = described_class.new(entry, "ldapmain")
expect(person.username).to eq(attr_value)
end
end
- context 'with a different username attribute' do
- let(:username_attribute) { 'sAMAccountName' }
+ context "with a different username attribute" do
+ let(:username_attribute) { "sAMAccountName" }
- it 'returns the proper username value' do
- attr_value = 'johndoe'
+ it "returns the proper username value" do
+ attr_value = "johndoe"
entry[username_attribute] = attr_value
- person = described_class.new(entry, 'ldapmain')
+ person = described_class.new(entry, "ldapmain")
expect(person.username).to eq(attr_value)
end
end
- context 'with a non-standard username attribute' do
- let(:username_attribute) { 'mail' }
+ context "with a non-standard username attribute" do
+ let(:username_attribute) { "mail" }
- it 'returns the proper username value' do
- attr_value = 'john.doe@example.com'
+ it "returns the proper username value" do
+ attr_value = "john.doe@example.com"
entry[username_attribute] = attr_value
- person = described_class.new(entry, 'ldapmain')
+ person = described_class.new(entry, "ldapmain")
expect(person.username).to eq(attr_value)
end
end
- context 'if lowercase_usernames setting is' do
- let(:username_attribute) { 'uid' }
+ context "if lowercase_usernames setting is" do
+ let(:username_attribute) { "uid" }
before do
- entry[username_attribute] = 'JOHN'
- @person = described_class.new(entry, 'ldapmain')
+ entry[username_attribute] = "JOHN"
+ @person = described_class.new(entry, "ldapmain")
end
- it 'enabled the username attribute is lower cased' do
+ it "enabled the username attribute is lower cased" do
stub_ldap_config(lowercase_usernames: true)
- expect(@person.username).to eq 'john'
+ expect(@person.username).to eq "john"
end
- it 'disabled the username attribute is not lower cased' do
+ it "disabled the username attribute is not lower cased" do
stub_ldap_config(lowercase_usernames: false)
- expect(@person.username).to eq 'JOHN'
+ expect(@person.username).to eq "JOHN"
end
end
end
diff --git a/spec/lib/gitlab/auth/ldap/user_spec.rb b/spec/lib/gitlab/auth/ldap/user_spec.rb
index 44bb9d20e47..ae7b8164f1a 100644
--- a/spec/lib/gitlab/auth/ldap/user_spec.rb
+++ b/spec/lib/gitlab/auth/ldap/user_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::LDAP::User do
include LdapHelpers
@@ -7,105 +7,105 @@ describe Gitlab::Auth::LDAP::User do
let(:gl_user) { ldap_user.gl_user }
let(:info) do
{
- name: 'John',
- email: 'john@example.com',
- nickname: 'john'
+ name: "John",
+ email: "john@example.com",
+ nickname: "john",
}
end
let(:auth_hash) do
- OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info)
+ OmniAuth::AuthHash.new(uid: "uid=John Smith,ou=People,dc=example,dc=com", provider: "ldapmain", info: info)
end
let(:ldap_user_upper_case) { described_class.new(auth_hash_upper_case) }
let(:info_upper_case) do
{
- name: 'John',
- email: 'John@Example.com', # Email address has upper case chars
- nickname: 'john'
+ name: "John",
+ email: "John@Example.com", # Email address has upper case chars
+ nickname: "john",
}
end
let(:auth_hash_upper_case) do
- OmniAuth::AuthHash.new(uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain', info: info_upper_case)
+ OmniAuth::AuthHash.new(uid: "uid=John Smith,ou=People,dc=example,dc=com", provider: "ldapmain", info: info_upper_case)
end
- describe '#should_save?' do
+ describe "#should_save?" do
it "marks existing ldap user as changed" do
- create(:omniauth_user, extern_uid: 'uid=John Smith,ou=People,dc=example,dc=com', provider: 'ldapmain')
+ create(:omniauth_user, extern_uid: "uid=John Smith,ou=People,dc=example,dc=com", provider: "ldapmain")
expect(ldap_user.should_save?).to be_truthy
end
it "marks existing non-ldap user if the email matches as changed" do
- create(:user, email: 'john@example.com')
+ create(:user, email: "john@example.com")
expect(ldap_user.should_save?).to be_truthy
end
it "does not mark existing ldap user as changed" do
- create(:omniauth_user, email: 'john@example.com', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com', provider: 'ldapmain')
+ create(:omniauth_user, email: "john@example.com", extern_uid: "uid=john smith,ou=people,dc=example,dc=com", provider: "ldapmain")
expect(ldap_user.should_save?).to be_falsey
end
end
- describe '.find_by_uid_and_provider' do
- let(:dn) { 'CN=John Åström, CN=Users, DC=Example, DC=com' }
+ describe ".find_by_uid_and_provider" do
+ let(:dn) { "CN=John Åström, CN=Users, DC=Example, DC=com" }
- it 'retrieves the correct user' do
+ it "retrieves the correct user" do
special_info = {
- name: 'John Åström',
- email: 'john@example.com',
- nickname: 'jastrom'
+ name: "John Åström",
+ email: "john@example.com",
+ nickname: "jastrom",
}
- special_hash = OmniAuth::AuthHash.new(uid: dn, provider: 'ldapmain', info: special_info)
+ special_hash = OmniAuth::AuthHash.new(uid: dn, provider: "ldapmain", info: special_info)
special_chars_user = described_class.new(special_hash)
user = special_chars_user.save
- expect(described_class.find_by_uid_and_provider(dn, 'ldapmain')).to eq user
+ expect(described_class.find_by_uid_and_provider(dn, "ldapmain")).to eq user
end
end
- describe 'find or create' do
+ describe "find or create" do
it "finds the user if already existing" do
- create(:omniauth_user, extern_uid: 'uid=john smith,ou=people,dc=example,dc=com', provider: 'ldapmain')
+ create(:omniauth_user, extern_uid: "uid=john smith,ou=people,dc=example,dc=com", provider: "ldapmain")
expect { ldap_user.save }.not_to change { User.count }
end
it "connects to existing non-ldap user if the email matches" do
- existing_user = create(:omniauth_user, email: 'john@example.com', provider: "twitter")
+ existing_user = create(:omniauth_user, email: "john@example.com", provider: "twitter")
expect { ldap_user.save }.not_to change { User.count }
existing_user.reload
- expect(existing_user.ldap_identity.extern_uid).to eql 'uid=john smith,ou=people,dc=example,dc=com'
- expect(existing_user.ldap_identity.provider).to eql 'ldapmain'
+ expect(existing_user.ldap_identity.extern_uid).to eql "uid=john smith,ou=people,dc=example,dc=com"
+ expect(existing_user.ldap_identity.provider).to eql "ldapmain"
end
- it 'connects to existing ldap user if the extern_uid changes' do
- existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain')
+ it "connects to existing ldap user if the extern_uid changes" do
+ existing_user = create(:omniauth_user, email: "john@example.com", extern_uid: "old-uid", provider: "ldapmain")
expect { ldap_user.save }.not_to change { User.count }
existing_user.reload
- expect(existing_user.ldap_identity.extern_uid).to eql 'uid=john smith,ou=people,dc=example,dc=com'
- expect(existing_user.ldap_identity.provider).to eql 'ldapmain'
+ expect(existing_user.ldap_identity.extern_uid).to eql "uid=john smith,ou=people,dc=example,dc=com"
+ expect(existing_user.ldap_identity.provider).to eql "ldapmain"
expect(existing_user.id).to eql ldap_user.gl_user.id
end
- it 'connects to existing ldap user if the extern_uid changes and email address has upper case characters' do
- existing_user = create(:omniauth_user, email: 'john@example.com', extern_uid: 'old-uid', provider: 'ldapmain')
+ it "connects to existing ldap user if the extern_uid changes and email address has upper case characters" do
+ existing_user = create(:omniauth_user, email: "john@example.com", extern_uid: "old-uid", provider: "ldapmain")
expect { ldap_user_upper_case.save }.not_to change { User.count }
existing_user.reload
- expect(existing_user.ldap_identity.extern_uid).to eql 'uid=john smith,ou=people,dc=example,dc=com'
- expect(existing_user.ldap_identity.provider).to eql 'ldapmain'
+ expect(existing_user.ldap_identity.extern_uid).to eql "uid=john smith,ou=people,dc=example,dc=com"
+ expect(existing_user.ldap_identity.provider).to eql "ldapmain"
expect(existing_user.id).to eql ldap_user.gl_user.id
end
- it 'maintains an identity per provider' do
- existing_user = create(:omniauth_user, email: 'john@example.com', provider: 'twitter')
+ it "maintains an identity per provider" do
+ existing_user = create(:omniauth_user, email: "john@example.com", provider: "twitter")
expect(existing_user.identities.count).to be(1)
ldap_user.save
expect(ldap_user.gl_user.identities.count).to be(2)
# Expect that find_by provider only returns a single instance of an identity and not an Enumerable
- expect(ldap_user.gl_user.identities.find_by(provider: 'twitter')).to be_instance_of Identity
+ expect(ldap_user.gl_user.identities.find_by(provider: "twitter")).to be_instance_of Identity
expect(ldap_user.gl_user.identities.find_by(provider: auth_hash.provider)).to be_instance_of Identity
end
@@ -113,24 +113,24 @@ describe Gitlab::Auth::LDAP::User do
expect { ldap_user.save }.to change { User.count }.by(1)
end
- context 'when signup is disabled' do
+ context "when signup is disabled" do
before do
stub_application_setting signup_enabled: false
end
- it 'creates the user' do
+ it "creates the user" do
ldap_user.save
expect(gl_user).to be_persisted
end
end
- context 'when user confirmation email is enabled' do
+ context "when user confirmation email is enabled" do
before do
stub_application_setting send_user_confirmation_email: true
end
- it 'creates and confirms the user anyway' do
+ it "creates and confirms the user anyway" do
ldap_user.save
expect(gl_user).to be_persisted
@@ -139,7 +139,7 @@ describe Gitlab::Auth::LDAP::User do
end
end
- describe 'updating email' do
+ describe "updating email" do
context "when LDAP sets an email" do
it "has a real email" do
expect(ldap_user.gl_user.email).to eq(info[:email])
@@ -154,7 +154,7 @@ describe Gitlab::Auth::LDAP::User do
end
it "has synced attributes provider set to ldapmain" do
- expect(ldap_user.gl_user.user_synced_attributes_metadata.provider).to eql 'ldapmain'
+ expect(ldap_user.gl_user.user_synced_attributes_metadata.provider).to eql "ldapmain"
end
end
@@ -177,13 +177,13 @@ describe Gitlab::Auth::LDAP::User do
end
end
- describe 'blocking' do
+ describe "blocking" do
def configure_block(value)
stub_ldap_config(block_auto_created_users: value)
end
- context 'signup' do
- context 'dont block on create' do
+ context "signup" do
+ context "dont block on create" do
before do
configure_block(false)
end
@@ -195,7 +195,7 @@ describe Gitlab::Auth::LDAP::User do
end
end
- context 'block on create' do
+ context "block on create" do
before do
configure_block(true)
end
@@ -208,13 +208,13 @@ describe Gitlab::Auth::LDAP::User do
end
end
- context 'sign-in' do
+ context "sign-in" do
before do
ldap_user.save
ldap_user.gl_user.activate
end
- context 'dont block on create' do
+ context "dont block on create" do
before do
configure_block(false)
end
@@ -226,7 +226,7 @@ describe Gitlab::Auth::LDAP::User do
end
end
- context 'block on create' do
+ context "block on create" do
before do
configure_block(true)
end
diff --git a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb
index 40001cea22e..ecbdcc4e53d 100644
--- a/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/auth_hash_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::OAuth::AuthHash do
- let(:provider) { 'ldap'.freeze }
+ let(:provider) { "ldap".freeze }
let(:auth_hash) do
described_class.new(
OmniAuth::AuthHash.new(
@@ -17,7 +17,7 @@ describe Gitlab::Auth::OAuth::AuthHash do
end
let(:email_raw) { "onur.k\xC3\xBC\xC3\xA7\xC3\xBCk_ABC-123@example.net" }
let(:nickname_raw) { "ok\xC3\xBC\xC3\xA7\xC3\xBCk" }
- let(:first_name_raw) { 'Onur' }
+ let(:first_name_raw) { "Onur" }
let(:last_name_raw) { "K\xC3\xBC\xC3\xA7\xC3\xBCk" }
let(:name_raw) { "Onur K\xC3\xBC\xC3\xA7\xC3\xBCk" }
@@ -35,16 +35,16 @@ describe Gitlab::Auth::OAuth::AuthHash do
let(:info_hash) do
{
- email: email_ascii,
+ email: email_ascii,
first_name: first_name_ascii,
- last_name: last_name_ascii,
- name: name_ascii,
- nickname: nickname_ascii,
- uid: uid_ascii
+ last_name: last_name_ascii,
+ name: name_ascii,
+ nickname: nickname_ascii,
+ uid: uid_ascii,
}
end
- context 'defaults' do
+ context "defaults" do
it { expect(auth_hash.provider).to eq provider }
it { expect(auth_hash.uid).to eql uid_utf8 }
it { expect(auth_hash.email).to eql email_utf8 }
@@ -53,58 +53,58 @@ describe Gitlab::Auth::OAuth::AuthHash do
it { expect(auth_hash.password).not_to be_empty }
end
- context 'email not provided' do
+ context "email not provided" do
before do
info_hash.delete(:email)
end
- it 'generates a temp email' do
- expect( auth_hash.email).to start_with('temp-email-for-oauth')
+ it "generates a temp email" do
+ expect(auth_hash.email).to start_with("temp-email-for-oauth")
end
end
- context 'username not provided' do
+ context "username not provided" do
before do
info_hash.delete(:nickname)
end
- it 'takes the first part of the email as username' do
- expect(auth_hash.username).to eql 'onur.kucuk_ABC-123'
+ it "takes the first part of the email as username" do
+ expect(auth_hash.username).to eql "onur.kucuk_ABC-123"
end
end
- context 'name not provided' do
+ context "name not provided" do
before do
info_hash.delete(:name)
end
- it 'concats first and lastname as the name' do
+ it "concats first and lastname as the name" do
expect(auth_hash.name).to eql name_utf8
end
end
- context 'auth_hash constructed with ASCII-8BIT encoding' do
- it 'forces utf8 encoding on uid' do
+ context "auth_hash constructed with ASCII-8BIT encoding" do
+ it "forces utf8 encoding on uid" do
expect(auth_hash.uid.encoding).to eql Encoding::UTF_8
end
- it 'forces utf8 encoding on provider' do
+ it "forces utf8 encoding on provider" do
expect(auth_hash.provider.encoding).to eql Encoding::UTF_8
end
- it 'forces utf8 encoding on name' do
+ it "forces utf8 encoding on name" do
expect(auth_hash.name.encoding).to eql Encoding::UTF_8
end
- it 'forces utf8 encoding on username' do
+ it "forces utf8 encoding on username" do
expect(auth_hash.username.encoding).to eql Encoding::UTF_8
end
- it 'forces utf8 encoding on email' do
+ it "forces utf8 encoding on email" do
expect(auth_hash.email.encoding).to eql Encoding::UTF_8
end
- it 'forces utf8 encoding on password' do
+ it "forces utf8 encoding on password" do
expect(auth_hash.password.encoding).to eql Encoding::UTF_8
end
end
diff --git a/spec/lib/gitlab/auth/o_auth/identity_linker_spec.rb b/spec/lib/gitlab/auth/o_auth/identity_linker_spec.rb
index bf810d72f0e..158deca9034 100644
--- a/spec/lib/gitlab/auth/o_auth/identity_linker_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/identity_linker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::OAuth::IdentityLinker do
let(:user) { create(:user) }
- let(:provider) { 'twitter' }
+ let(:provider) { "twitter" }
let(:uid) { user.email }
- let(:oauth) { { 'provider' => provider, 'uid' => uid } }
+ let(:oauth) { {"provider" => provider, "uid" => uid} }
subject { described_class.new(user, oauth) }
- context 'linked identity exists' do
+ context "linked identity exists" do
let!(:identity) { user.identities.create!(provider: provider, extern_uid: uid) }
it "doesn't create new identity" do
@@ -22,7 +22,7 @@ describe Gitlab::Auth::OAuth::IdentityLinker do
end
end
- context 'identity already linked to different user' do
+ context "identity already linked to different user" do
let!(:identity) { create(:identity, provider: provider, extern_uid: uid) }
it "#changed? returns false" do
@@ -31,29 +31,29 @@ describe Gitlab::Auth::OAuth::IdentityLinker do
expect(subject).not_to be_changed
end
- it 'exposes error message' do
- expect(subject.error_message).to eq 'Extern uid has already been taken'
+ it "exposes error message" do
+ expect(subject.error_message).to eq "Extern uid has already been taken"
end
end
- context 'identity needs to be created' do
- it 'creates linked identity' do
+ context "identity needs to be created" do
+ it "creates linked identity" do
expect { subject.link }.to change { user.identities.count }
end
- it 'sets identity provider' do
+ it "sets identity provider" do
subject.link
expect(user.identities.last.provider).to eq provider
end
- it 'sets identity extern_uid' do
+ it "sets identity extern_uid" do
subject.link
expect(user.identities.last.extern_uid).to eq uid
end
- it 'sets #changed? to true' do
+ it "sets #changed? to true" do
subject.link
expect(subject).to be_changed
diff --git a/spec/lib/gitlab/auth/o_auth/provider_spec.rb b/spec/lib/gitlab/auth/o_auth/provider_spec.rb
index 80d702cf9dc..45a555c7846 100644
--- a/spec/lib/gitlab/auth/o_auth/provider_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/provider_spec.rb
@@ -1,82 +1,82 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::OAuth::Provider do
- describe '.enabled?' do
+ describe ".enabled?" do
before do
allow(described_class).to receive(:providers).and_return([:ldapmain, :google_oauth2])
end
- context 'when OmniAuth is disabled' do
+ context "when OmniAuth is disabled" do
before do
allow(Gitlab::Auth).to receive(:omniauth_enabled?).and_return(false)
end
- it 'allows database auth' do
- expect(described_class.enabled?('database')).to be_truthy
+ it "allows database auth" do
+ expect(described_class.enabled?("database")).to be_truthy
end
- it 'allows LDAP auth' do
- expect(described_class.enabled?('ldapmain')).to be_truthy
+ it "allows LDAP auth" do
+ expect(described_class.enabled?("ldapmain")).to be_truthy
end
- it 'does not allow other OmniAuth providers' do
- expect(described_class.enabled?('google_oauth2')).to be_falsey
+ it "does not allow other OmniAuth providers" do
+ expect(described_class.enabled?("google_oauth2")).to be_falsey
end
end
- context 'when OmniAuth is enabled' do
+ context "when OmniAuth is enabled" do
before do
allow(Gitlab::Auth).to receive(:omniauth_enabled?).and_return(true)
end
- it 'allows database auth' do
- expect(described_class.enabled?('database')).to be_truthy
+ it "allows database auth" do
+ expect(described_class.enabled?("database")).to be_truthy
end
- it 'allows LDAP auth' do
- expect(described_class.enabled?('ldapmain')).to be_truthy
+ it "allows LDAP auth" do
+ expect(described_class.enabled?("ldapmain")).to be_truthy
end
- it 'allows other OmniAuth providers' do
- expect(described_class.enabled?('google_oauth2')).to be_truthy
+ it "allows other OmniAuth providers" do
+ expect(described_class.enabled?("google_oauth2")).to be_truthy
end
end
end
- describe '#config_for' do
- context 'for an LDAP provider' do
- context 'when the provider exists' do
- it 'returns the config' do
- expect(described_class.config_for('ldapmain')).to be_a(Hash)
+ describe "#config_for" do
+ context "for an LDAP provider" do
+ context "when the provider exists" do
+ it "returns the config" do
+ expect(described_class.config_for("ldapmain")).to be_a(Hash)
end
end
- context 'when the provider does not exist' do
- it 'returns nil' do
- expect(described_class.config_for('ldapfoo')).to be_nil
+ context "when the provider does not exist" do
+ it "returns nil" do
+ expect(described_class.config_for("ldapfoo")).to be_nil
end
end
end
- context 'for an OmniAuth provider' do
+ context "for an OmniAuth provider" do
before do
provider = OpenStruct.new(
- name: 'google',
- app_id: 'asd123',
- app_secret: 'asd123'
+ name: "google",
+ app_id: "asd123",
+ app_secret: "asd123"
)
allow(Gitlab.config.omniauth).to receive(:providers).and_return([provider])
end
- context 'when the provider exists' do
- it 'returns the config' do
- expect(described_class.config_for('google')).to be_a(OpenStruct)
+ context "when the provider exists" do
+ it "returns the config" do
+ expect(described_class.config_for("google")).to be_a(OpenStruct)
end
end
- context 'when the provider does not exist' do
- it 'returns nil' do
- expect(described_class.config_for('foo')).to be_nil
+ context "when the provider does not exist" do
+ it "returns nil" do
+ expect(described_class.config_for("foo")).to be_nil
end
end
end
diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb
index dcbd12fe190..2ad6b412999 100644
--- a/spec/lib/gitlab/auth/o_auth/user_spec.rb
+++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::OAuth::User do
include LdapHelpers
let(:oauth_user) { described_class.new(auth_hash) }
let(:gl_user) { oauth_user.gl_user }
- let(:uid) { 'my-uid' }
- let(:dn) { 'uid=user1,ou=people,dc=example' }
- let(:provider) { 'my-provider' }
+ let(:uid) { "my-uid" }
+ let(:dn) { "uid=user1,ou=people,dc=example" }
+ let(:provider) { "my-provider" }
let(:auth_hash) { OmniAuth::AuthHash.new(uid: uid, provider: provider, info: info_hash) }
let(:info_hash) do
{
- nickname: '-john+gitlab-ETC%.git@gmail.com',
- name: 'John',
- email: 'john@mail.com',
+ nickname: "-john+gitlab-ETC%.git@gmail.com",
+ name: "John",
+ email: "john@mail.com",
address: {
- locality: 'locality',
- country: 'country'
- }
+ locality: "locality",
+ country: "country",
+ },
}
end
- let(:ldap_user) { Gitlab::Auth::LDAP::Person.new(Net::LDAP::Entry.new, 'ldapmain') }
+ let(:ldap_user) { Gitlab::Auth::LDAP::Person.new(Net::LDAP::Entry.new, "ldapmain") }
- describe '#persisted?' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "#persisted?" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
it "finds an existing user based on uid and provider (facebook)" do
- expect( oauth_user.persisted? ).to be_truthy
+ expect(oauth_user.persisted?).to be_truthy
end
- it 'returns false if user is not found in database' do
- allow(auth_hash).to receive(:uid).and_return('non-existing')
- expect( oauth_user.persisted? ).to be_falsey
+ it "returns false if user is not found in database" do
+ allow(auth_hash).to receive(:uid).and_return("non-existing")
+ expect(oauth_user.persisted?).to be_falsey
end
end
@@ -39,12 +39,12 @@ describe Gitlab::Auth::OAuth::User do
allow(Gitlab.config.omniauth).to receive_messages(messages)
end
- describe '#save' do
- let(:provider) { 'twitter' }
+ describe "#save" do
+ let(:provider) { "twitter" }
- describe 'when account exists on server' do
- it 'does not mark the user as external' do
- create(:omniauth_user, extern_uid: 'my-uid', provider: provider)
+ describe "when account exists on server" do
+ it "does not mark the user as external" do
+ create(:omniauth_user, extern_uid: "my-uid", provider: provider)
stub_omniauth_config(allow_single_sign_on: [provider], external_providers: [provider])
oauth_user.save
@@ -54,13 +54,13 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'signup' do
- context 'when signup is disabled' do
+ describe "signup" do
+ context "when signup is disabled" do
before do
stub_application_setting signup_enabled: false
end
- it 'creates the user' do
+ it "creates the user" do
stub_omniauth_config(allow_single_sign_on: [provider])
oauth_user.save
@@ -69,12 +69,12 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'when user confirmation email is enabled' do
+ context "when user confirmation email is enabled" do
before do
stub_application_setting send_user_confirmation_email: true
end
- it 'creates and confirms the user anyway' do
+ it "creates and confirms the user anyway" do
stub_omniauth_config(allow_single_sign_on: [provider])
oauth_user.save
@@ -84,7 +84,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- it 'marks user as having password_automatically_set' do
+ it "marks user as having password_automatically_set" do
stub_omniauth_config(allow_single_sign_on: [provider], external_providers: [provider])
oauth_user.save
@@ -93,9 +93,9 @@ describe Gitlab::Auth::OAuth::User do
expect(gl_user).to be_password_automatically_set
end
- shared_examples 'to verify compliance with allow_single_sign_on' do
- context 'provider is marked as external' do
- it 'marks user as external' do
+ shared_examples "to verify compliance with allow_single_sign_on" do
+ context "provider is marked as external" do
+ it "marks user as external" do
stub_omniauth_config(allow_single_sign_on: [provider], external_providers: [provider])
oauth_user.save
expect(gl_user).to be_valid
@@ -103,20 +103,20 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'provider was external, now has been removed' do
- it 'does not mark external user as internal' do
- create(:omniauth_user, extern_uid: 'my-uid', provider: provider, external: true)
- stub_omniauth_config(allow_single_sign_on: [provider], external_providers: ['facebook'])
+ context "provider was external, now has been removed" do
+ it "does not mark external user as internal" do
+ create(:omniauth_user, extern_uid: "my-uid", provider: provider, external: true)
+ stub_omniauth_config(allow_single_sign_on: [provider], external_providers: ["facebook"])
oauth_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_truthy
end
end
- context 'provider is not external' do
- context 'when adding a new OAuth identity' do
- it 'does not promote an external user to internal' do
- user = create(:user, email: 'john@mail.com', external: true)
+ context "provider is not external" do
+ context "when adding a new OAuth identity" 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)
oauth_user.save
@@ -126,7 +126,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'with new allow_single_sign_on enabled syntax' do
+ context "with new allow_single_sign_on enabled syntax" do
before do
stub_omniauth_config(allow_single_sign_on: [provider])
end
@@ -156,22 +156,22 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'with new allow_single_sign_on disabled syntax' do
+ context "with new allow_single_sign_on disabled syntax" do
before do
stub_omniauth_config(allow_single_sign_on: [])
end
- it 'throws an error' do
+ it "throws an error" do
expect { oauth_user.save }.to raise_error StandardError
end
end
- context 'with old allow_single_sign_on disabled (Default)' do
+ context "with old allow_single_sign_on disabled (Default)" do
before do
stub_omniauth_config(allow_single_sign_on: false)
end
- it 'throws an error' do
+ it "throws an error" do
expect { oauth_user.save }.to raise_error StandardError
end
end
@@ -200,14 +200,14 @@ describe Gitlab::Auth::OAuth::User do
context "and at least one LDAP provider is defined" do
before do
- stub_ldap_config(providers: %w(ldapmain))
+ stub_ldap_config(providers: %w[ldapmain])
end
context "and a corresponding LDAP person" do
before do
allow(ldap_user).to receive(:uid) { uid }
allow(ldap_user).to receive(:username) { uid }
- allow(ldap_user).to receive(:email) { ['johndoe@example.com', 'john2@example.com'] }
+ allow(ldap_user).to receive(:email) { ["johndoe@example.com", "john2@example.com"] }
allow(ldap_user).to receive(:dn) { dn }
end
@@ -221,13 +221,13 @@ describe Gitlab::Auth::OAuth::User do
it "creates a user with dual LDAP and omniauth identities" do
expect(gl_user).to be_valid
expect(gl_user.username).to eql uid
- expect(gl_user.email).to eql 'johndoe@example.com'
+ expect(gl_user.email).to eql "johndoe@example.com"
expect(gl_user.identities.length).to be 2
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
expect(identities_as_hash).to match_array(
[
- { provider: 'ldapmain', extern_uid: dn },
- { provider: 'twitter', extern_uid: uid }
+ {provider: "ldapmain", extern_uid: dn},
+ {provider: "twitter", extern_uid: uid},
]
)
end
@@ -241,51 +241,51 @@ describe Gitlab::Auth::OAuth::User do
end
it "has synced attributes provider set to ldapmain" do
- expect(gl_user.user_synced_attributes_metadata.provider).to eql 'ldapmain'
+ expect(gl_user.user_synced_attributes_metadata.provider).to eql "ldapmain"
end
end
context "and LDAP user has an account already" do
- let!(:existing_user) { create(:omniauth_user, email: 'john@example.com', extern_uid: dn, provider: 'ldapmain', username: 'john') }
+ let!(:existing_user) { create(:omniauth_user, email: "john@example.com", extern_uid: dn, provider: "ldapmain", username: "john") }
it "adds the omniauth identity to the LDAP account" do
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user)
oauth_user.save
expect(gl_user).to be_valid
- expect(gl_user.username).to eql 'john'
- expect(gl_user.email).to eql 'john@example.com'
+ expect(gl_user.username).to eql "john"
+ expect(gl_user.email).to eql "john@example.com"
expect(gl_user.identities.length).to be 2
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
expect(identities_as_hash).to match_array(
[
- { provider: 'ldapmain', extern_uid: dn },
- { provider: 'twitter', extern_uid: uid }
+ {provider: "ldapmain", extern_uid: dn},
+ {provider: "twitter", extern_uid: uid},
]
)
end
end
- context 'when an LDAP person is not found by uid' do
- it 'tries to find an LDAP person by email and adds the omniauth identity to the user' do
+ context "when an LDAP person is not found by uid" do
+ it "tries to find an LDAP person by email and adds the omniauth identity to the user" do
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(nil)
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).and_return(ldap_user)
oauth_user.save
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
expect(identities_as_hash).to match_array(result_identities(dn, uid))
end
- context 'when also not found by email' do
- it 'tries to find an LDAP person by DN and adds the omniauth identity to the user' do
+ context "when also not found by email" do
+ it "tries to find an LDAP person by DN and adds the omniauth identity to the user" do
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(nil)
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).and_return(nil)
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).and_return(ldap_user)
oauth_user.save
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
expect(identities_as_hash).to match_array(result_identities(dn, uid))
end
end
@@ -293,41 +293,41 @@ describe Gitlab::Auth::OAuth::User do
def result_identities(dn, uid)
[
- { provider: 'ldapmain', extern_uid: dn },
- { provider: 'twitter', extern_uid: uid }
+ {provider: "ldapmain", extern_uid: dn},
+ {provider: "twitter", extern_uid: uid},
]
end
- context 'when there is an LDAP connection error' do
+ context "when there is an LDAP connection error" do
before do
raise_ldap_connection_error
end
- it 'does not save the identity' do
+ it "does not save the identity" do
oauth_user.save
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
- expect(identities_as_hash).to match_array([{ provider: 'twitter', extern_uid: uid }])
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
+ expect(identities_as_hash).to match_array([{provider: "twitter", extern_uid: uid}])
end
end
end
- context 'and a corresponding LDAP person with a non-default username' do
+ context "and a corresponding LDAP person with a non-default username" do
before do
allow(ldap_user).to receive(:uid) { uid }
- allow(ldap_user).to receive(:username) { 'johndoe@example.com' }
- allow(ldap_user).to receive(:email) { %w(johndoe@example.com john2@example.com) }
+ allow(ldap_user).to receive(:username) { "johndoe@example.com" }
+ allow(ldap_user).to receive(:email) { %w[johndoe@example.com john2@example.com] }
allow(ldap_user).to receive(:dn) { dn }
end
- context 'and no account for the LDAP user' do
- it 'creates a user favoring the LDAP username and strips email domain' do
+ context "and no account for the LDAP user" do
+ it "creates a user favoring the LDAP username and strips email domain" do
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user)
oauth_user.save
expect(gl_user).to be_valid
- expect(gl_user.username).to eql 'johndoe'
+ expect(gl_user.username).to eql "johndoe"
end
end
end
@@ -343,15 +343,15 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'blocking' do
- let(:provider) { 'twitter' }
+ describe "blocking" do
+ let(:provider) { "twitter" }
before do
- stub_omniauth_config(allow_single_sign_on: ['twitter'])
+ stub_omniauth_config(allow_single_sign_on: ["twitter"])
end
- context 'signup with omniauth only' do
- context 'dont block on create' do
+ context "signup with omniauth only" do
+ context "dont block on create" do
before do
stub_omniauth_config(block_auto_created_users: false)
end
@@ -363,7 +363,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'block on create' do
+ context "block on create" do
before do
stub_omniauth_config(block_auto_created_users: true)
end
@@ -376,18 +376,18 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'signup with linked omniauth and LDAP account' do
+ context "signup with linked omniauth and LDAP account" do
before do
stub_omniauth_config(auto_link_ldap_user: true)
allow(ldap_user).to receive(:uid) { uid }
allow(ldap_user).to receive(:username) { uid }
- allow(ldap_user).to receive(:email) { ['johndoe@example.com', 'john2@example.com'] }
+ allow(ldap_user).to receive(:email) { ["johndoe@example.com", "john2@example.com"] }
allow(ldap_user).to receive(:dn) { dn }
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(ldap_user)
end
context "and no account for the LDAP user" do
- context 'dont block on create (LDAP)' do
+ context "dont block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
end
@@ -399,7 +399,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'block on create (LDAP)' do
+ context "block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
end
@@ -412,10 +412,10 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'and LDAP user has an account already' do
- let!(:existing_user) { create(:omniauth_user, email: 'john@example.com', extern_uid: dn, provider: 'ldapmain', username: 'john') }
+ context "and LDAP user has an account already" do
+ let!(:existing_user) { create(:omniauth_user, email: "john@example.com", extern_uid: dn, provider: "ldapmain", username: "john") }
- context 'dont block on create (LDAP)' do
+ context "dont block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
end
@@ -427,7 +427,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'block on create (LDAP)' do
+ context "block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
end
@@ -441,13 +441,13 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'sign-in' do
+ context "sign-in" do
before do
oauth_user.save
oauth_user.gl_user.activate
end
- context 'dont block on create' do
+ context "dont block on create" do
before do
stub_omniauth_config(block_auto_created_users: false)
end
@@ -459,7 +459,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'block on create' do
+ context "block on create" do
before do
stub_omniauth_config(block_auto_created_users: true)
end
@@ -471,7 +471,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'dont block on create (LDAP)' do
+ context "dont block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: false)
end
@@ -483,7 +483,7 @@ describe Gitlab::Auth::OAuth::User do
end
end
- context 'block on create (LDAP)' do
+ context "block on create (LDAP)" do
before do
allow_any_instance_of(Gitlab::Auth::LDAP::Config).to receive_messages(block_auto_created_users: true)
end
@@ -498,12 +498,12 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'ensure backwards compatibility with sync email from provider option' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "ensure backwards compatibility with sync email from provider option" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
before do
- stub_omniauth_config(sync_email_from_provider: 'my-provider')
- stub_omniauth_config(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_config(sync_email_from_provider: "my-provider")
+ stub_omniauth_config(sync_profile_from_provider: ["my-provider"])
end
context "when provider sets an email" do
@@ -520,7 +520,7 @@ describe Gitlab::Auth::OAuth::User do
end
it "has synced attributes provider set to my-provider" do
- expect(gl_user.user_synced_attributes_metadata.provider).to eql 'my-provider'
+ expect(gl_user.user_synced_attributes_metadata.provider).to eql "my-provider"
end
end
@@ -543,41 +543,41 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'generating username' do
- context 'when no collision with existing user' do
- it 'generates the username with no counter' do
- expect(gl_user.username).to eq('johngitlab-ETC')
+ describe "generating username" do
+ context "when no collision with existing user" do
+ it "generates the username with no counter" do
+ expect(gl_user.username).to eq("johngitlab-ETC")
end
end
- context 'when collision with existing user' do
- it 'generates the username with a counter' do
+ context "when collision with existing user" do
+ it "generates the username with a counter" do
oauth_user.save
- oauth_user2 = described_class.new(OmniAuth::AuthHash.new(uid: 'my-uid2', provider: provider, info: { nickname: 'johngitlab-ETC@othermail.com', email: 'john@othermail.com' }))
+ oauth_user2 = described_class.new(OmniAuth::AuthHash.new(uid: "my-uid2", provider: provider, info: {nickname: "johngitlab-ETC@othermail.com", email: "john@othermail.com"}))
- expect(oauth_user2.gl_user.username).to eq('johngitlab-ETC1')
+ expect(oauth_user2.gl_user.username).to eq("johngitlab-ETC1")
end
end
- context 'when username is a reserved word' do
+ context "when username is a reserved word" do
let(:info_hash) do
{
- nickname: 'admin@othermail.com',
- email: 'admin@othermail.com'
+ nickname: "admin@othermail.com",
+ email: "admin@othermail.com",
}
end
- it 'generates the username with a counter' do
- expect(gl_user.username).to eq('admin1')
+ it "generates the username with a counter" do
+ expect(gl_user.username).to eq("admin1")
end
end
end
- describe 'updating email with sync profile' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "updating email with sync profile" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
before do
- stub_omniauth_config(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_config(sync_profile_from_provider: ["my-provider"])
stub_omniauth_config(sync_profile_attributes: true)
end
@@ -595,7 +595,7 @@ describe Gitlab::Auth::OAuth::User do
end
it "has synced attributes provider set to my-provider" do
- expect(gl_user.user_synced_attributes_metadata.provider).to eql 'my-provider'
+ expect(gl_user.user_synced_attributes_metadata.provider).to eql "my-provider"
end
end
@@ -618,11 +618,11 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'updating name' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "updating name" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
before do
- stub_omniauth_setting(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_setting(sync_profile_from_provider: ["my-provider"])
stub_omniauth_setting(sync_profile_attributes: true)
end
@@ -644,17 +644,17 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'updating location' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "updating location" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
before do
- stub_omniauth_setting(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_setting(sync_profile_from_provider: ["my-provider"])
stub_omniauth_setting(sync_profile_attributes: true)
end
context "when provider sets a location" do
it "updates the user location" do
- expect(gl_user.location).to eq(info_hash[:address][:locality] + ', ' + info_hash[:address][:country])
+ expect(gl_user.location).to eq(info_hash[:address][:locality] + ", " + info_hash[:address][:country])
expect(gl_user.user_synced_attributes_metadata.location_synced).to be(true)
end
end
@@ -672,12 +672,12 @@ describe Gitlab::Auth::OAuth::User do
end
end
- describe 'updating user info' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe "updating user info" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
context "update all info" do
before do
- stub_omniauth_setting(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_setting(sync_profile_from_provider: ["my-provider"])
stub_omniauth_setting(sync_profile_attributes: true)
end
@@ -692,19 +692,19 @@ describe Gitlab::Auth::OAuth::User do
end
it "updates the user location" do
- expect(gl_user.location).to eq(info_hash[:address][:locality] + ', ' + info_hash[:address][:country])
+ expect(gl_user.location).to eq(info_hash[:address][:locality] + ", " + info_hash[:address][:country])
expect(gl_user.user_synced_attributes_metadata.location_synced).to be(true)
end
it "sets my-provider as the attributes provider" do
- expect(gl_user.user_synced_attributes_metadata.provider).to eql('my-provider')
+ expect(gl_user.user_synced_attributes_metadata.provider).to eql("my-provider")
end
end
context "update only requested info" do
before do
- stub_omniauth_setting(sync_profile_from_provider: ['my-provider'])
- stub_omniauth_setting(sync_profile_attributes: %w(name location))
+ stub_omniauth_setting(sync_profile_from_provider: ["my-provider"])
+ stub_omniauth_setting(sync_profile_attributes: %w[name location])
end
it "updates the user name" do
@@ -713,7 +713,7 @@ describe Gitlab::Auth::OAuth::User do
end
it "updates the user location" do
- expect(gl_user.location).to eq(info_hash[:address][:locality] + ', ' + info_hash[:address][:country])
+ expect(gl_user.location).to eq(info_hash[:address][:locality] + ", " + info_hash[:address][:country])
expect(gl_user.user_synced_attributes_metadata.location_synced).to be(true)
end
@@ -724,7 +724,7 @@ describe Gitlab::Auth::OAuth::User do
context "update default_scope" do
before do
- stub_omniauth_setting(sync_profile_from_provider: ['my-provider'])
+ stub_omniauth_setting(sync_profile_from_provider: ["my-provider"])
end
it "updates the user email" do
@@ -750,40 +750,40 @@ describe Gitlab::Auth::OAuth::User do
expect(gl_user.location).not_to eq(info_hash[:address][:country])
end
- it 'does not create associated user synced attributes metadata' do
+ it "does not create associated user synced attributes metadata" do
expect(gl_user.user_synced_attributes_metadata).to be_nil
end
end
end
- describe '.find_by_uid_and_provider' do
- let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
+ describe ".find_by_uid_and_provider" do
+ let!(:existing_user) { create(:omniauth_user, extern_uid: "my-uid", provider: "my-provider") }
- it 'normalizes extern_uid' do
- allow(oauth_user.auth_hash).to receive(:uid).and_return('MY-UID')
+ it "normalizes extern_uid" do
+ allow(oauth_user.auth_hash).to receive(:uid).and_return("MY-UID")
expect(oauth_user.find_user).to eql gl_user
end
end
- describe '#find_ldap_person' do
- context 'when LDAP connection fails' do
+ describe "#find_ldap_person" do
+ context "when LDAP connection fails" do
before do
raise_ldap_connection_error
end
- it 'returns nil' do
- adapter = Gitlab::Auth::LDAP::Adapter.new('ldapmain')
- hash = OmniAuth::AuthHash.new(uid: 'whatever', provider: 'ldapmain')
+ it "returns nil" do
+ adapter = Gitlab::Auth::LDAP::Adapter.new("ldapmain")
+ hash = OmniAuth::AuthHash.new(uid: "whatever", provider: "ldapmain")
expect(oauth_user.send(:find_ldap_person, hash, adapter)).to be_nil
end
end
end
- describe '#bypass_two_factor?' do
+ describe "#bypass_two_factor?" do
subject { oauth_user.bypass_two_factor? }
- it 'returns always false' do
+ it "returns always false" do
is_expected.to be_falsey
end
end
diff --git a/spec/lib/gitlab/auth/request_authenticator_spec.rb b/spec/lib/gitlab/auth/request_authenticator_spec.rb
index 3d979132880..af3dfa57a2d 100644
--- a/spec/lib/gitlab/auth/request_authenticator_spec.rb
+++ b/spec/lib/gitlab/auth/request_authenticator_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::RequestAuthenticator do
let(:env) do
{
- 'rack.input' => '',
- 'REQUEST_METHOD' => 'GET'
+ "rack.input" => "",
+ "REQUEST_METHOD" => "GET",
}
end
let(:request) { ActionDispatch::Request.new(env) }
subject { described_class.new(request) }
- describe '#user' do
+ describe "#user" do
let!(:sessionless_user) { build(:user) }
let!(:session_user) { build(:user) }
- it 'returns sessionless user first' do
+ it "returns sessionless user first" do
allow_any_instance_of(described_class).to receive(:find_sessionless_user).and_return(sessionless_user)
allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_return(session_user)
expect(subject.user([:api])).to eq sessionless_user
end
- it 'returns session user if no sessionless user found' do
+ it "returns session user if no sessionless user found" do
allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_return(session_user)
expect(subject.user([:api])).to eq session_user
end
- it 'returns nil if no user found' do
+ it "returns nil if no user found" do
expect(subject.user([:api])).to be_blank
end
- it 'bubbles up exceptions' do
+ it "bubbles up exceptions" do
allow_any_instance_of(described_class).to receive(:find_user_from_warden).and_raise(Gitlab::Auth::UnauthorizedError)
end
end
- describe '#find_sessionless_user' do
+ describe "#find_sessionless_user" do
let!(:access_token_user) { build(:user) }
let!(:feed_token_user) { build(:user) }
- it 'returns access_token user first' do
+ it "returns access_token user first" do
allow_any_instance_of(described_class).to receive(:find_user_from_web_access_token).and_return(access_token_user)
allow_any_instance_of(described_class).to receive(:find_user_from_feed_token).and_return(feed_token_user)
expect(subject.find_sessionless_user([:api])).to eq access_token_user
end
- it 'returns feed_token user if no access_token user found' do
+ it "returns feed_token user if no access_token user found" do
allow_any_instance_of(described_class).to receive(:find_user_from_feed_token).and_return(feed_token_user)
expect(subject.find_sessionless_user([:api])).to eq feed_token_user
end
- it 'returns nil if no user found' do
+ it "returns nil if no user found" do
expect(subject.find_sessionless_user([:api])).to be_blank
end
- it 'rescue Gitlab::Auth::AuthenticationError exceptions' do
+ it "rescue Gitlab::Auth::AuthenticationError exceptions" do
allow_any_instance_of(described_class).to receive(:find_user_from_web_access_token).and_raise(Gitlab::Auth::UnauthorizedError)
expect(subject.find_sessionless_user([:api])).to be_blank
diff --git a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb
index 3620e1afe25..0dc2dc76b16 100644
--- a/spec/lib/gitlab/auth/saml/auth_hash_spec.rb
+++ b/spec/lib/gitlab/auth/saml/auth_hash_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::Saml::AuthHash do
include LoginHelpers
- let(:raw_info_attr) { { 'groups' => %w(Developers Freelancers) } }
+ let(:raw_info_attr) { {"groups" => %w[Developers Freelancers]} }
subject(:saml_auth_hash) { described_class.new(omniauth_auth_hash) }
let(:info_hash) do
{
- name: 'John',
- email: 'john@mail.com'
+ name: "John",
+ email: "john@mail.com",
}
end
let(:omniauth_auth_hash) do
- OmniAuth::AuthHash.new(uid: 'my-uid',
- provider: 'saml',
+ OmniAuth::AuthHash.new(uid: "my-uid",
+ provider: "saml",
info: info_hash,
- extra: { raw_info: OneLogin::RubySaml::Attributes.new(raw_info_attr) } )
+ extra: {raw_info: OneLogin::RubySaml::Attributes.new(raw_info_attr)})
end
before do
- stub_saml_group_config(%w(Developers Freelancers Designers))
+ stub_saml_group_config(%w[Developers Freelancers Designers])
end
- describe '#groups' do
- it 'returns array of groups' do
- expect(saml_auth_hash.groups).to eq(%w(Developers Freelancers))
+ describe "#groups" do
+ it "returns array of groups" do
+ expect(saml_auth_hash.groups).to eq(%w[Developers Freelancers])
end
- context 'raw info hash attributes empty' do
+ context "raw info hash attributes empty" do
let(:raw_info_attr) { {} }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(saml_auth_hash.groups).to be_a(Array)
end
end
end
- describe '#authn_context' do
+ describe "#authn_context" do
let(:auth_hash_data) do
{
- provider: 'saml',
- uid: 'some_uid',
+ provider: "saml",
+ uid: "some_uid",
info:
{
- name: 'mockuser',
- email: 'mock@email.ch',
- image: 'mock_user_thumbnail_url'
+ name: "mockuser",
+ email: "mock@email.ch",
+ image: "mock_user_thumbnail_url",
},
credentials:
{
- token: 'mock_token',
- secret: 'mock_secret'
+ token: "mock_token",
+ secret: "mock_secret",
},
extra:
{
@@ -60,41 +60,41 @@ describe Gitlab::Auth::Saml::AuthHash do
{
info:
{
- name: 'mockuser',
- email: 'mock@email.ch',
- image: 'mock_user_thumbnail_url'
- }
- }
- }
+ name: "mockuser",
+ email: "mock@email.ch",
+ image: "mock_user_thumbnail_url",
+ },
+ },
+ },
}
end
subject(:saml_auth_hash) { described_class.new(OmniAuth::AuthHash.new(auth_hash_data)) }
- context 'with response_object' do
+ context "with response_object" do
before do
- auth_hash_data[:extra][:response_object] = { document:
- saml_xml(File.read('spec/fixtures/authentication/saml_response.xml')) }
+ auth_hash_data[:extra][:response_object] = {document:
+ saml_xml(File.read("spec/fixtures/authentication/saml_response.xml"))}
end
- it 'can extract authn_context' do
- expect(saml_auth_hash.authn_context).to eq 'urn:oasis:names:tc:SAML:2.0:ac:classes:Password'
+ it "can extract authn_context" do
+ expect(saml_auth_hash.authn_context).to eq "urn:oasis:names:tc:SAML:2.0:ac:classes:Password"
end
end
- context 'with SAML 2.0 response_object' do
+ context "with SAML 2.0 response_object" do
before do
- auth_hash_data[:extra][:response_object] = { document:
- saml_xml(File.read('spec/fixtures/authentication/saml2_response.xml')) }
+ auth_hash_data[:extra][:response_object] = {document:
+ saml_xml(File.read("spec/fixtures/authentication/saml2_response.xml"))}
end
- it 'can extract authn_context' do
- expect(saml_auth_hash.authn_context).to eq 'urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport'
+ it "can extract authn_context" do
+ expect(saml_auth_hash.authn_context).to eq "urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport"
end
end
- context 'without response_object' do
- it 'returns an empty string' do
+ context "without response_object" do
+ it "returns an empty string" do
expect(saml_auth_hash.authn_context).to be_nil
end
end
diff --git a/spec/lib/gitlab/auth/saml/identity_linker_spec.rb b/spec/lib/gitlab/auth/saml/identity_linker_spec.rb
index f3305d574cc..5d25745ae0d 100644
--- a/spec/lib/gitlab/auth/saml/identity_linker_spec.rb
+++ b/spec/lib/gitlab/auth/saml/identity_linker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::Saml::IdentityLinker do
let(:user) { create(:user) }
- let(:provider) { 'saml' }
+ let(:provider) { "saml" }
let(:uid) { user.email }
- let(:oauth) { { 'provider' => provider, 'uid' => uid } }
+ let(:oauth) { {"provider" => provider, "uid" => uid} }
subject { described_class.new(user, oauth) }
- context 'linked identity exists' do
+ context "linked identity exists" do
let!(:identity) { user.identities.create!(provider: provider, extern_uid: uid) }
it "doesn't create new identity" do
@@ -22,24 +22,24 @@ describe Gitlab::Auth::Saml::IdentityLinker do
end
end
- context 'identity needs to be created' do
- it 'creates linked identity' do
+ context "identity needs to be created" do
+ it "creates linked identity" do
expect { subject.link }.to change { user.identities.count }
end
- it 'sets identity provider' do
+ it "sets identity provider" do
subject.link
expect(user.identities.last.provider).to eq provider
end
- it 'sets identity extern_uid' do
+ it "sets identity extern_uid" do
subject.link
expect(user.identities.last.extern_uid).to eq uid
end
- it 'sets #changed? to true' do
+ it "sets #changed? to true" do
subject.link
expect(subject).to be_changed
diff --git a/spec/lib/gitlab/auth/saml/user_spec.rb b/spec/lib/gitlab/auth/saml/user_spec.rb
index c523f5e177f..dac981b1aa0 100644
--- a/spec/lib/gitlab/auth/saml/user_spec.rb
+++ b/spec/lib/gitlab/auth/saml/user_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::Saml::User do
include LdapHelpers
@@ -6,46 +6,46 @@ describe Gitlab::Auth::Saml::User do
let(:saml_user) { described_class.new(auth_hash) }
let(:gl_user) { saml_user.gl_user }
- let(:uid) { 'my-uid' }
- let(:dn) { 'uid=user1,ou=people,dc=example' }
- let(:provider) { 'saml' }
- let(:raw_info_attr) { { 'groups' => %w(Developers Freelancers Designers) } }
- let(:auth_hash) { OmniAuth::AuthHash.new(uid: uid, provider: provider, info: info_hash, extra: { raw_info: OneLogin::RubySaml::Attributes.new(raw_info_attr) }) }
+ let(:uid) { "my-uid" }
+ let(:dn) { "uid=user1,ou=people,dc=example" }
+ let(:provider) { "saml" }
+ let(:raw_info_attr) { {"groups" => %w[Developers Freelancers Designers]} }
+ let(:auth_hash) { OmniAuth::AuthHash.new(uid: uid, provider: provider, info: info_hash, extra: {raw_info: OneLogin::RubySaml::Attributes.new(raw_info_attr)}) }
let(:info_hash) do
{
- name: 'John',
- email: 'john@mail.com'
+ name: "John",
+ email: "john@mail.com",
}
end
- let(:ldap_user) { Gitlab::Auth::LDAP::Person.new(Net::LDAP::Entry.new, 'ldapmain') }
+ let(:ldap_user) { Gitlab::Auth::LDAP::Person.new(Net::LDAP::Entry.new, "ldapmain") }
- describe '#save' do
+ describe "#save" do
before do
stub_basic_saml_config
end
- describe 'account exists on server' do
+ describe "account exists on server" do
before do
- stub_omniauth_config({ allow_single_sign_on: ['saml'], auto_link_saml_user: true })
+ stub_omniauth_config({allow_single_sign_on: ["saml"], auto_link_saml_user: true})
end
- let!(:existing_user) { create(:user, email: 'john@mail.com', username: 'john') }
+ let!(:existing_user) { create(:user, email: "john@mail.com", username: "john") }
- context 'and should bind with SAML' do
- it 'adds the SAML identity to the existing user' do
+ context "and should bind with SAML" do
+ it "adds the SAML identity to the existing user" do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user).to eq existing_user
identity = gl_user.identities.first
expect(identity.extern_uid).to eql uid
- expect(identity.provider).to eql 'saml'
+ expect(identity.provider).to eql "saml"
end
end
- context 'external groups' do
- context 'are defined' do
- it 'marks the user as external' do
- stub_saml_group_config(%w(Freelancers))
+ context "external groups" do
+ context "are defined" do
+ it "marks the user as external" do
+ stub_saml_group_config(%w[Freelancers])
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_truthy
@@ -53,20 +53,20 @@ describe Gitlab::Auth::Saml::User do
end
before do
- stub_saml_group_config(%w(Interns))
+ stub_saml_group_config(%w[Interns])
end
- context 'are defined but the user does not belong there' do
- it 'does not mark the user as external' do
+ context "are defined but the user does not belong there" do
+ it "does not mark the user as external" do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_falsey
end
end
- context 'user was external, now should not be' do
- it 'makes user internal' do
- existing_user.update_attribute('external', true)
+ context "user was external, now should not be" do
+ it "makes user internal" do
+ existing_user.update_attribute("external", true)
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_falsey
@@ -75,57 +75,57 @@ describe Gitlab::Auth::Saml::User do
end
end
- describe 'no account exists on server' do
- shared_examples 'to verify compliance with allow_single_sign_on' do
- context 'with allow_single_sign_on enabled' do
+ describe "no account exists on server" do
+ shared_examples "to verify compliance with allow_single_sign_on" do
+ context "with allow_single_sign_on enabled" do
before do
- stub_omniauth_config(allow_single_sign_on: ['saml'])
+ stub_omniauth_config(allow_single_sign_on: ["saml"])
end
- it 'creates a user from SAML' do
+ it "creates a user from SAML" do
saml_user.save
expect(gl_user).to be_valid
identity = gl_user.identities.first
expect(identity.extern_uid).to eql uid
- expect(identity.provider).to eql 'saml'
+ expect(identity.provider).to eql "saml"
end
end
context 'with allow_single_sign_on default (["saml"])' do
before do
- stub_omniauth_config(allow_single_sign_on: ['saml'])
+ stub_omniauth_config(allow_single_sign_on: ["saml"])
end
- it 'does 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
+ context "with allow_single_sign_on disabled" do
before do
stub_omniauth_config(allow_single_sign_on: false)
end
- it 'throws an error' do
+ it "throws an error" do
expect { saml_user.save }.to raise_error StandardError
end
end
end
- context 'external groups' do
- context 'are defined' do
- it 'marks the user as external' do
- stub_saml_group_config(%w(Freelancers))
+ context "external groups" do
+ context "are defined" do
+ it "marks the user as external" do
+ stub_saml_group_config(%w[Freelancers])
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_truthy
end
end
- context 'are defined but the user does not belong there' do
- it 'does not mark the user as external' do
- stub_saml_group_config(%w(Interns))
+ context "are defined but the user does not belong there" do
+ it "does not mark the user as external" do
+ stub_saml_group_config(%w[Interns])
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_falsey
@@ -133,53 +133,53 @@ describe Gitlab::Auth::Saml::User do
end
end
- context 'with auto_link_ldap_user disabled (default)' do
+ context "with auto_link_ldap_user disabled (default)" do
before do
- stub_omniauth_config({ auto_link_ldap_user: false, auto_link_saml_user: false, allow_single_sign_on: ['saml'] })
+ stub_omniauth_config({auto_link_ldap_user: false, auto_link_saml_user: false, allow_single_sign_on: ["saml"]})
end
- include_examples 'to verify compliance with allow_single_sign_on'
+ include_examples "to verify compliance with allow_single_sign_on"
end
- context 'with auto_link_ldap_user enabled' do
+ context "with auto_link_ldap_user enabled" do
before do
- stub_omniauth_config({ auto_link_ldap_user: true, auto_link_saml_user: false })
+ stub_omniauth_config({auto_link_ldap_user: true, auto_link_saml_user: false})
end
- context 'and at least one LDAP provider is defined' do
+ context "and at least one LDAP provider is defined" do
before do
- stub_ldap_config(providers: %w(ldapmain))
+ stub_ldap_config(providers: %w[ldapmain])
end
- context 'and a corresponding LDAP person' do
- let(:adapter) { ldap_adapter('ldapmain') }
+ context "and a corresponding LDAP person" do
+ let(:adapter) { ldap_adapter("ldapmain") }
before do
allow(ldap_user).to receive(:uid) { uid }
allow(ldap_user).to receive(:username) { uid }
- allow(ldap_user).to receive(:email) { %w(john@mail.com john2@example.com) }
+ allow(ldap_user).to receive(:email) { %w[john@mail.com john2@example.com] }
allow(ldap_user).to receive(:dn) { dn }
allow(Gitlab::Auth::LDAP::Adapter).to receive(:new).and_return(adapter)
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).with(uid, adapter).and_return(ldap_user)
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).with(dn, adapter).and_return(ldap_user)
- allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).with('john@mail.com', adapter).and_return(ldap_user)
+ allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).with("john@mail.com", adapter).and_return(ldap_user)
end
- context 'and no account for the LDAP user' do
- it 'creates a user with dual LDAP and SAML identities' do
+ context "and no account for the LDAP user" do
+ it "creates a user with dual LDAP and SAML identities" do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user.username).to eql uid
- expect(gl_user.email).to eql 'john@mail.com'
+ expect(gl_user.email).to eql "john@mail.com"
expect(gl_user.identities.length).to be 2
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
- expect(identities_as_hash).to match_array([{ provider: 'ldapmain', extern_uid: dn },
- { provider: 'saml', extern_uid: uid }])
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
+ expect(identities_as_hash).to match_array([{provider: "ldapmain", extern_uid: dn},
+ {provider: "saml", extern_uid: uid},])
end
end
- context 'and LDAP user has an account already' do
+ context "and LDAP user has an account already" do
let(:auth_hash_base_attributes) do
{
uid: uid,
@@ -187,23 +187,23 @@ describe Gitlab::Auth::Saml::User do
info: info_hash,
extra: {
raw_info: OneLogin::RubySaml::Attributes.new(
- { 'groups' => %w(Developers Freelancers Designers) }
- )
- }
+ {"groups" => %w[Developers Freelancers Designers]}
+ ),
+ },
}
end
let(:auth_hash) { OmniAuth::AuthHash.new(auth_hash_base_attributes) }
- let(:uid_types) { %w(uid dn email) }
+ let(:uid_types) { %w[uid dn email] }
before do
create(:omniauth_user,
- email: 'john@mail.com',
- extern_uid: dn,
- provider: 'ldapmain',
- username: 'john')
+ email: "john@mail.com",
+ extern_uid: dn,
+ provider: "ldapmain",
+ username: "john")
end
- shared_examples 'find LDAP person' do |uid_type, uid|
+ shared_examples "find LDAP person" do |uid_type, uid|
let(:auth_hash) { OmniAuth::AuthHash.new(auth_hash_base_attributes.merge(uid: extern_uid)) }
before do
@@ -216,57 +216,57 @@ describe Gitlab::Auth::Saml::User do
allow(Gitlab::Auth::LDAP::Person).to receive(:"find_by_#{uid_type}").and_return(ldap_user)
end
- it 'adds the omniauth identity to the LDAP account' do
+ it "adds the omniauth identity to the LDAP account" do
identities = [
- { provider: 'ldapmain', extern_uid: dn },
- { provider: 'saml', extern_uid: extern_uid }
+ {provider: "ldapmain", extern_uid: dn},
+ {provider: "saml", extern_uid: extern_uid},
]
- identities_as_hash = gl_user.identities.map do |id|
- { provider: id.provider, extern_uid: id.extern_uid }
- end
+ identities_as_hash = gl_user.identities.map { |id|
+ {provider: id.provider, extern_uid: id.extern_uid}
+ }
saml_user.save
expect(gl_user).to be_valid
- expect(gl_user.username).to eql 'john'
- expect(gl_user.email).to eql 'john@mail.com'
+ expect(gl_user.username).to eql "john"
+ expect(gl_user.email).to eql "john@mail.com"
expect(gl_user.identities.length).to be 2
expect(identities_as_hash).to match_array(identities)
end
end
- context 'when uid is an uid' do
- it_behaves_like 'find LDAP person', 'uid' do
+ context "when uid is an uid" do
+ it_behaves_like "find LDAP person", "uid" do
let(:extern_uid) { uid }
end
end
- context 'when uid is a dn' do
- it_behaves_like 'find LDAP person', 'dn' do
+ context "when uid is a dn" do
+ it_behaves_like "find LDAP person", "dn" do
let(:extern_uid) { dn }
end
end
- context 'when uid is an email' do
- it_behaves_like 'find LDAP person', 'email' do
- let(:extern_uid) { 'john@mail.com' }
+ context "when uid is an email" do
+ it_behaves_like "find LDAP person", "email" do
+ let(:extern_uid) { "john@mail.com" }
end
end
- it 'adds the omniauth identity to the LDAP account' do
+ it "adds the omniauth identity to the LDAP account" do
saml_user.save
expect(gl_user).to be_valid
- expect(gl_user.username).to eql 'john'
- expect(gl_user.email).to eql 'john@mail.com'
+ expect(gl_user.username).to eql "john"
+ expect(gl_user.email).to eql "john@mail.com"
expect(gl_user.identities.length).to be 2
- identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
- expect(identities_as_hash).to match_array([{ provider: 'ldapmain', extern_uid: dn },
- { provider: 'saml', extern_uid: uid }])
+ identities_as_hash = gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
+ expect(identities_as_hash).to match_array([{provider: "ldapmain", extern_uid: dn},
+ {provider: "saml", extern_uid: uid},])
end
- it 'saves successfully on subsequent tries, when both identities are present' do
+ it "saves successfully on subsequent tries, when both identities are present" do
saml_user.save
local_saml_user = described_class.new(auth_hash)
local_saml_user.save
@@ -276,9 +276,9 @@ describe Gitlab::Auth::Saml::User do
end
end
- context 'user has SAML user, and wants to add their LDAP identity' do
- it 'adds the LDAP identity to the existing SAML user' do
- create(:omniauth_user, email: 'john@mail.com', extern_uid: dn, provider: 'saml', username: 'john')
+ context "user has SAML user, and wants to add their LDAP identity" do
+ it "adds the LDAP identity to the existing SAML user" do
+ create(:omniauth_user, email: "john@mail.com", extern_uid: dn, provider: "saml", username: "john")
allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).with(dn, adapter).and_return(ldap_user)
@@ -290,33 +290,33 @@ describe Gitlab::Auth::Saml::User do
expect(local_gl_user).to be_valid
expect(local_gl_user.identities.length).to be 2
- identities_as_hash = local_gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } }
- expect(identities_as_hash).to match_array([{ provider: 'ldapmain', extern_uid: dn },
- { provider: 'saml', extern_uid: dn }])
+ identities_as_hash = local_gl_user.identities.map { |id| {provider: id.provider, extern_uid: id.extern_uid} }
+ expect(identities_as_hash).to match_array([{provider: "ldapmain", extern_uid: dn},
+ {provider: "saml", extern_uid: dn},])
end
end
end
end
end
- context 'when signup is disabled' do
+ context "when signup is disabled" do
before do
stub_application_setting signup_enabled: false
end
- it 'creates the user' do
+ it "creates the user" do
saml_user.save
expect(gl_user).to be_persisted
end
end
- context 'when user confirmation email is enabled' do
+ context "when user confirmation email is enabled" do
before do
stub_application_setting send_user_confirmation_email: true
end
- it 'creates and confirms the user anyway' do
+ it "creates and confirms the user anyway" do
saml_user.save
expect(gl_user).to be_persisted
@@ -325,30 +325,30 @@ describe Gitlab::Auth::Saml::User do
end
end
- describe 'blocking' do
+ describe "blocking" do
before do
- stub_omniauth_config({ allow_single_sign_on: ['saml'], auto_link_saml_user: true })
+ stub_omniauth_config({allow_single_sign_on: ["saml"], auto_link_saml_user: true})
end
- context 'signup with SAML only' do
- context 'dont block on create' do
+ context "signup with SAML only" do
+ context "dont block on create" do
before do
stub_omniauth_config(block_auto_created_users: false)
end
- it 'does 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
end
end
- context 'block on create' do
+ context "block on create" do
before do
stub_omniauth_config(block_auto_created_users: true)
end
- it 'blocks user' do
+ it "blocks user" do
saml_user.save
expect(gl_user).to be_valid
expect(gl_user).to be_blocked
@@ -356,13 +356,13 @@ describe Gitlab::Auth::Saml::User do
end
end
- context 'sign-in' do
+ context "sign-in" do
before do
saml_user.save
saml_user.gl_user.activate
end
- context 'dont block on create' do
+ context "dont block on create" do
before do
stub_omniauth_config(block_auto_created_users: false)
end
@@ -374,7 +374,7 @@ describe Gitlab::Auth::Saml::User do
end
end
- context 'block on create' do
+ context "block on create" do
before do
stub_omniauth_config(block_auto_created_users: true)
end
@@ -389,54 +389,54 @@ describe Gitlab::Auth::Saml::User do
end
end
- describe '#find_user' do
- context 'raw info hash attributes empty' do
+ describe "#find_user" do
+ context "raw info hash attributes empty" do
let(:raw_info_attr) { {} }
- it 'does not mark user as external' do
- stub_saml_group_config(%w(Freelancers))
+ it "does not mark user as external" do
+ stub_saml_group_config(%w[Freelancers])
expect(saml_user.find_user.external).to be_falsy
end
end
end
- describe '#bypass_two_factor?' do
+ describe "#bypass_two_factor?" do
let(:saml_config) { mock_saml_config_with_upstream_two_factor_authn_contexts }
subject { saml_user.bypass_two_factor? }
- context 'with authn_contexts_worth_two_factors configured' do
+ context "with authn_contexts_worth_two_factors configured" do
before do
- stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config])
+ stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"], providers: [saml_config])
end
- it 'returns true when authn_context is worth two factors' do
- allow(saml_user.auth_hash).to receive(:authn_context).and_return('urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS')
+ it "returns true when authn_context is worth two factors" do
+ allow(saml_user.auth_hash).to receive(:authn_context).and_return("urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS")
is_expected.to be_truthy
end
- it 'returns false when authn_context is not worth two factors' do
- allow(saml_user.auth_hash).to receive(:authn_context).and_return('urn:oasis:names:tc:SAML:2.0:ac:classes:Password')
+ it "returns false when authn_context is not worth two factors" do
+ allow(saml_user.auth_hash).to receive(:authn_context).and_return("urn:oasis:names:tc:SAML:2.0:ac:classes:Password")
is_expected.to be_falsey
end
- it 'returns false when authn_context is blank' do
+ it "returns false when authn_context is blank" do
is_expected.to be_falsey
end
end
- context 'without auth_contexts_worth_two_factors_configured' do
+ context "without auth_contexts_worth_two_factors_configured" do
before do
- stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [mock_saml_config])
+ stub_omniauth_saml_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ["saml"], providers: [mock_saml_config])
end
- it 'returns false when authn_context is present' do
- allow(saml_user.auth_hash).to receive(:authn_context).and_return('urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS')
+ it "returns false when authn_context is present" do
+ allow(saml_user.auth_hash).to receive(:authn_context).and_return("urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS")
is_expected.to be_falsey
end
- it 'returns false when authn_context is blank' do
+ it "returns false when authn_context is blank" do
is_expected.to be_falsey
end
end
diff --git a/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb b/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
index 22708687a56..943020686fe 100644
--- a/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
+++ b/spec/lib/gitlab/auth/unique_ips_limiter_spec.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::UniqueIpsLimiter, :clean_gitlab_redis_shared_state do
- include_context 'unique ips sign in limit'
+ include_context "unique ips sign in limit"
let(:user) { create(:user) }
- describe '#count_unique_ips' do
- context 'non unique IPs' do
- it 'properly counts them' do
- expect(described_class.update_and_return_ips_count(user.id, 'ip1')).to eq(1)
- expect(described_class.update_and_return_ips_count(user.id, 'ip1')).to eq(1)
+ describe "#count_unique_ips" do
+ context "non unique IPs" do
+ it "properly counts them" do
+ expect(described_class.update_and_return_ips_count(user.id, "ip1")).to eq(1)
+ expect(described_class.update_and_return_ips_count(user.id, "ip1")).to eq(1)
end
end
- context 'unique IPs' do
- it 'properly counts them' do
- expect(described_class.update_and_return_ips_count(user.id, 'ip2')).to eq(1)
- expect(described_class.update_and_return_ips_count(user.id, 'ip3')).to eq(2)
+ context "unique IPs" do
+ it "properly counts them" do
+ expect(described_class.update_and_return_ips_count(user.id, "ip2")).to eq(1)
+ expect(described_class.update_and_return_ips_count(user.id, "ip3")).to eq(2)
end
end
- it 'resets count after specified time window' do
+ it "resets count after specified time window" do
Timecop.freeze do
- expect(described_class.update_and_return_ips_count(user.id, 'ip2')).to eq(1)
- expect(described_class.update_and_return_ips_count(user.id, 'ip3')).to eq(2)
+ expect(described_class.update_and_return_ips_count(user.id, "ip2")).to eq(1)
+ expect(described_class.update_and_return_ips_count(user.id, "ip3")).to eq(2)
Timecop.travel(Time.now.utc + described_class.config.unique_ips_limit_time_window) do
- expect(described_class.update_and_return_ips_count(user.id, 'ip4')).to eq(1)
- expect(described_class.update_and_return_ips_count(user.id, 'ip5')).to eq(2)
+ expect(described_class.update_and_return_ips_count(user.id, "ip4")).to eq(1)
+ expect(described_class.update_and_return_ips_count(user.id, "ip5")).to eq(2)
end
end
end
end
- describe '#limit_user!' do
- include_examples 'user login operation with unique ip limit' do
+ describe "#limit_user!" do
+ include_examples "user login operation with unique ip limit" do
def operation
described_class.limit_user! { user }
end
end
- context 'allow 2 unique ips' do
+ context "allow 2 unique ips" do
before do
Gitlab::CurrentSettings.current_application_settings.update!(unique_ips_limit_per_user: 2)
end
- it 'blocks user trying to login from third ip' do
- change_ip('ip1')
+ it "blocks user trying to login from third ip" do
+ change_ip("ip1")
expect(described_class.limit_user! { user }).to eq(user)
- change_ip('ip2')
+ change_ip("ip2")
expect(described_class.limit_user! { user }).to eq(user)
- change_ip('ip3')
+ change_ip("ip3")
expect { described_class.limit_user! { user } }.to raise_error(Gitlab::Auth::TooManyIps)
end
end
diff --git a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
index 002ce776be9..722cf19b530 100644
--- a/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
+++ b/spec/lib/gitlab/auth/user_access_denied_reason_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::UserAccessDeniedReason do
include TermsHelper
@@ -6,10 +6,10 @@ describe Gitlab::Auth::UserAccessDeniedReason do
let(:reason) { described_class.new(user) }
- describe '#rejection_message' do
+ describe "#rejection_message" do
subject { reason.rejection_message }
- context 'when a user is blocked' do
+ context "when a user is blocked" do
before do
user.block!
end
@@ -17,7 +17,7 @@ describe Gitlab::Auth::UserAccessDeniedReason do
it { is_expected.to match /blocked/ }
end
- context 'a user did not accept the enforced terms' do
+ context "a user did not accept the enforced terms" do
before do
enforce_terms
end
@@ -26,7 +26,7 @@ describe Gitlab::Auth::UserAccessDeniedReason do
it { is_expected.to include(user.username) }
end
- context 'when the user is internal' do
+ context "when the user is internal" do
let(:user) { User.ghost }
it { is_expected.to match /This action cannot be performed by internal users/ }
diff --git a/spec/lib/gitlab/auth/user_auth_finders_spec.rb b/spec/lib/gitlab/auth/user_auth_finders_spec.rb
index 1e2aebdc84b..dc9a6c48831 100644
--- a/spec/lib/gitlab/auth/user_auth_finders_spec.rb
+++ b/spec/lib/gitlab/auth/user_auth_finders_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth::UserAuthFinders do
include described_class
@@ -6,7 +6,7 @@ describe Gitlab::Auth::UserAuthFinders do
let(:user) { create(:user) }
let(:env) do
{
- 'rack.input' => ''
+ "rack.input" => "",
}
end
let(:request) { ActionDispatch::Request.new(env) }
@@ -15,84 +15,84 @@ describe Gitlab::Auth::UserAuthFinders do
request.update_param(key, value)
end
- describe '#find_user_from_warden' do
- context 'with CSRF token' do
+ describe "#find_user_from_warden" do
+ context "with CSRF token" do
before do
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(true)
end
- context 'with invalid credentials' do
- it 'returns nil' do
+ context "with invalid credentials" do
+ it "returns nil" do
expect(find_user_from_warden).to be_nil
end
end
- context 'with valid credentials' do
- it 'returns the user' do
- env['warden'] = double("warden", authenticate: user)
+ context "with valid credentials" do
+ it "returns the user" do
+ env["warden"] = double("warden", authenticate: user)
expect(find_user_from_warden).to eq user
end
end
end
- context 'without CSRF token' do
- it 'returns nil' do
+ context "without CSRF token" do
+ it "returns nil" do
allow(Gitlab::RequestForgeryProtection).to receive(:verified?).and_return(false)
- env['warden'] = double("warden", authenticate: user)
+ env["warden"] = double("warden", authenticate: user)
expect(find_user_from_warden).to be_nil
end
end
end
- describe '#find_user_from_feed_token' do
- context 'when the request format is atom' do
+ describe "#find_user_from_feed_token" do
+ context "when the request format is atom" do
before do
- env['SCRIPT_NAME'] = 'url.atom'
- env['HTTP_ACCEPT'] = 'application/atom+xml'
+ env["SCRIPT_NAME"] = "url.atom"
+ env["HTTP_ACCEPT"] = "application/atom+xml"
end
- context 'when feed_token param is provided' do
- it 'returns user if valid feed_token' do
+ context "when feed_token param is provided" do
+ it "returns user if valid feed_token" do
set_param(:feed_token, user.feed_token)
expect(find_user_from_feed_token(:rss)).to eq user
end
- it 'returns nil if feed_token is blank' do
+ it "returns nil if feed_token is blank" do
expect(find_user_from_feed_token(:rss)).to be_nil
end
- it 'returns exception if invalid feed_token' do
- set_param(:feed_token, 'invalid_token')
+ it "returns exception if invalid feed_token" do
+ set_param(:feed_token, "invalid_token")
expect { find_user_from_feed_token(:rss) }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
end
- context 'when rss_token param is provided' do
- it 'returns user if valid rssd_token' do
+ context "when rss_token param is provided" do
+ it "returns user if valid rssd_token" do
set_param(:rss_token, user.feed_token)
expect(find_user_from_feed_token(:rss)).to eq user
end
- it 'returns nil if rss_token is blank' do
+ it "returns nil if rss_token is blank" do
expect(find_user_from_feed_token(:rss)).to be_nil
end
- it 'returns exception if invalid rss_token' do
- set_param(:rss_token, 'invalid_token')
+ it "returns exception if invalid rss_token" do
+ set_param(:rss_token, "invalid_token")
expect { find_user_from_feed_token(:rss) }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
end
end
- context 'when the request format is not atom' do
- it 'returns nil' do
- env['SCRIPT_NAME'] = 'json'
+ context "when the request format is not atom" do
+ it "returns nil" do
+ env["SCRIPT_NAME"] = "json"
set_param(:feed_token, user.feed_token)
@@ -100,38 +100,38 @@ describe Gitlab::Auth::UserAuthFinders do
end
end
- context 'when the request format is empty' do
- it 'the method call does not modify the original value' do
- env['SCRIPT_NAME'] = 'url.atom'
+ context "when the request format is empty" do
+ it "the method call does not modify the original value" do
+ env["SCRIPT_NAME"] = "url.atom"
- env.delete('action_dispatch.request.formats')
+ env.delete("action_dispatch.request.formats")
find_user_from_feed_token(:rss)
- expect(env['action_dispatch.request.formats']).to be_nil
+ expect(env["action_dispatch.request.formats"]).to be_nil
end
end
end
- describe '#find_user_from_access_token' do
+ describe "#find_user_from_access_token" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
before do
- env['SCRIPT_NAME'] = 'url.atom'
+ env["SCRIPT_NAME"] = "url.atom"
end
- it 'returns nil if no access_token present' do
+ it "returns nil if no access_token present" do
expect(find_user_from_access_token).to be_nil
end
- context 'when validate_access_token! returns valid' do
- it 'returns user' do
+ context "when validate_access_token! returns valid" do
+ it "returns user" do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect(find_user_from_access_token).to eq user
end
- it 'returns exception if token has no user' do
+ it "returns exception if token has no user" do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
allow_any_instance_of(PersonalAccessToken).to receive(:user).and_return(nil)
@@ -140,156 +140,156 @@ describe Gitlab::Auth::UserAuthFinders do
end
end
- describe '#find_user_from_web_access_token' do
+ describe "#find_user_from_web_access_token" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
before do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
end
- it 'returns exception if token has no user' do
+ it "returns exception if token has no user" do
allow_any_instance_of(PersonalAccessToken).to receive(:user).and_return(nil)
expect { find_user_from_access_token }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
- context 'no feed or API requests' do
- it 'returns nil if the request is not RSS' do
+ context "no feed or API requests" do
+ it "returns nil if the request is not RSS" do
expect(find_user_from_web_access_token(:rss)).to be_nil
end
- it 'returns nil if the request is not ICS' do
+ it "returns nil if the request is not ICS" do
expect(find_user_from_web_access_token(:ics)).to be_nil
end
- it 'returns nil if the request is not API' do
+ it "returns nil if the request is not API" do
expect(find_user_from_web_access_token(:api)).to be_nil
end
end
- it 'returns the user for RSS requests' do
- env['SCRIPT_NAME'] = 'url.atom'
+ it "returns the user for RSS requests" do
+ env["SCRIPT_NAME"] = "url.atom"
expect(find_user_from_web_access_token(:rss)).to eq(user)
end
- it 'returns the user for ICS requests' do
- env['SCRIPT_NAME'] = 'url.ics'
+ it "returns the user for ICS requests" do
+ env["SCRIPT_NAME"] = "url.ics"
expect(find_user_from_web_access_token(:ics)).to eq(user)
end
- it 'returns the user for API requests' do
- env['SCRIPT_NAME'] = '/api/endpoint'
+ it "returns the user for API requests" do
+ env["SCRIPT_NAME"] = "/api/endpoint"
expect(find_user_from_web_access_token(:api)).to eq(user)
end
end
- describe '#find_personal_access_token' do
+ describe "#find_personal_access_token" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
before do
- env['SCRIPT_NAME'] = 'url.atom'
+ env["SCRIPT_NAME"] = "url.atom"
end
- context 'passed as header' do
- it 'returns token if valid personal_access_token' do
+ context "passed as header" do
+ it "returns token if valid personal_access_token" do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect(find_personal_access_token).to eq personal_access_token
end
end
- context 'passed as param' do
- it 'returns token if valid personal_access_token' do
+ context "passed as param" do
+ it "returns token if valid personal_access_token" do
set_param(Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_PARAM, personal_access_token.token)
expect(find_personal_access_token).to eq personal_access_token
end
end
- it 'returns nil if no personal_access_token' do
+ it "returns nil if no personal_access_token" do
expect(find_personal_access_token).to be_nil
end
- it 'returns exception if invalid personal_access_token' do
- env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = 'invalid_token'
+ it "returns exception if invalid personal_access_token" do
+ env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = "invalid_token"
expect { find_personal_access_token }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
end
- describe '#find_oauth_access_token' do
- let(:application) { Doorkeeper::Application.create!(name: 'MyApp', redirect_uri: 'https://app.com', owner: user) }
- let(:token) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: 'api') }
+ describe "#find_oauth_access_token" do
+ let(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
+ let(:token) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: "api") }
- context 'passed as header' do
- it 'returns token if valid oauth_access_token' do
- env['HTTP_AUTHORIZATION'] = "Bearer #{token.token}"
+ context "passed as header" do
+ it "returns token if valid oauth_access_token" do
+ env["HTTP_AUTHORIZATION"] = "Bearer #{token.token}"
expect(find_oauth_access_token.token).to eq token.token
end
end
- context 'passed as param' do
- it 'returns user if valid oauth_access_token' do
+ context "passed as param" do
+ it "returns user if valid oauth_access_token" do
set_param(:access_token, token.token)
expect(find_oauth_access_token.token).to eq token.token
end
end
- it 'returns nil if no oauth_access_token' do
+ it "returns nil if no oauth_access_token" do
expect(find_oauth_access_token).to be_nil
end
- it 'returns exception if invalid oauth_access_token' do
- env['HTTP_AUTHORIZATION'] = "Bearer invalid_token"
+ it "returns exception if invalid oauth_access_token" do
+ env["HTTP_AUTHORIZATION"] = "Bearer invalid_token"
expect { find_oauth_access_token }.to raise_error(Gitlab::Auth::UnauthorizedError)
end
end
- describe '#validate_access_token!' do
+ describe "#validate_access_token!" do
let(:personal_access_token) { create(:personal_access_token, user: user) }
- it 'returns nil if no access_token present' do
+ it "returns nil if no access_token present" do
expect(validate_access_token!).to be_nil
end
- context 'token is not valid' do
+ context "token is not valid" do
before do
allow_any_instance_of(described_class).to receive(:access_token).and_return(personal_access_token)
end
- it 'returns Gitlab::Auth::ExpiredError if token expired' do
+ it "returns Gitlab::Auth::ExpiredError if token expired" do
personal_access_token.expires_at = 1.day.ago
expect { validate_access_token! }.to raise_error(Gitlab::Auth::ExpiredError)
end
- it 'returns Gitlab::Auth::RevokedError if token revoked' do
+ it "returns Gitlab::Auth::RevokedError if token revoked" do
personal_access_token.revoke!
expect { validate_access_token! }.to raise_error(Gitlab::Auth::RevokedError)
end
- it 'returns Gitlab::Auth::InsufficientScopeError if invalid token scope' do
+ it "returns Gitlab::Auth::InsufficientScopeError if invalid token scope" do
expect { validate_access_token!(scopes: [:sudo]) }.to raise_error(Gitlab::Auth::InsufficientScopeError)
end
end
- context 'with impersonation token' do
+ context "with impersonation token" do
let(:personal_access_token) { create(:personal_access_token, :impersonation, user: user) }
- context 'when impersonation is disabled' do
+ context "when impersonation is disabled" do
before do
stub_config_setting(impersonation_enabled: false)
allow_any_instance_of(described_class).to receive(:access_token).and_return(personal_access_token)
end
- it 'returns Gitlab::Auth::ImpersonationDisabled' do
+ it "returns Gitlab::Auth::ImpersonationDisabled" do
expect { validate_access_token! }.to raise_error(Gitlab::Auth::ImpersonationDisabled)
end
end
diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb
index a4a6338961e..e0ec33e0355 100644
--- a/spec/lib/gitlab/auth_spec.rb
+++ b/spec/lib/gitlab/auth_spec.rb
@@ -1,371 +1,371 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Auth do
let(:gl_auth) { described_class }
- describe 'constants' do
- it 'API_SCOPES contains all scopes for API access' do
+ describe "constants" do
+ it "API_SCOPES contains all scopes for API access" do
expect(subject::API_SCOPES).to eq %i[api read_user sudo read_repository]
end
- it 'OPENID_SCOPES contains all scopes for OpenID Connect' do
+ it "OPENID_SCOPES contains all scopes for OpenID Connect" do
expect(subject::OPENID_SCOPES).to eq [:openid]
end
- it 'DEFAULT_SCOPES contains all default scopes' do
+ it "DEFAULT_SCOPES contains all default scopes" do
expect(subject::DEFAULT_SCOPES).to eq [:api]
end
- it 'optional_scopes contains all non-default scopes' do
+ it "optional_scopes contains all non-default scopes" do
stub_container_registry_config(enabled: true)
expect(subject.optional_scopes).to eq %i[read_user sudo read_repository read_registry openid profile email]
end
- context 'registry_scopes' do
- context 'when registry is disabled' do
+ context "registry_scopes" do
+ context "when registry is disabled" do
before do
stub_container_registry_config(enabled: false)
end
- it 'is empty' do
+ it "is empty" do
expect(subject.registry_scopes).to eq []
end
end
- context 'when registry is enabled' do
+ context "when registry is enabled" do
before do
stub_container_registry_config(enabled: true)
end
- it 'contains all registry related scopes' do
+ it "contains all registry related scopes" do
expect(subject.registry_scopes).to eq %i[read_registry]
end
end
end
end
- describe 'find_for_git_client' do
- context 'build token' do
- subject { gl_auth.find_for_git_client('gitlab-ci-token', build.token, project: project, ip: 'ip') }
+ describe "find_for_git_client" do
+ context "build token" do
+ subject { gl_auth.find_for_git_client("gitlab-ci-token", build.token, project: project, ip: "ip") }
- context 'for running build' do
+ context "for running build" do
let!(:build) { create(:ci_build, :running) }
let(:project) { build.project }
before do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: 'gitlab-ci-token')
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "gitlab-ci-token")
end
- it 'recognises user-less build' do
+ it "recognises user-less build" do
expect(subject).to eq(Gitlab::Auth::Result.new(nil, build.project, :ci, build_authentication_abilities))
end
- it 'recognises user token' do
+ it "recognises user token" do
build.update(user: create(:user))
expect(subject).to eq(Gitlab::Auth::Result.new(build.user, build.project, :build, build_authentication_abilities))
end
end
- (HasStatus::AVAILABLE_STATUSES - ['running']).each do |build_status|
+ (HasStatus::AVAILABLE_STATUSES - ["running"]).each do |build_status|
context "for #{build_status} build" do
let!(:build) { create(:ci_build, status: build_status) }
let(:project) { build.project }
before do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'gitlab-ci-token')
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "gitlab-ci-token")
end
- it 'denies authentication' do
+ it "denies authentication" do
expect(subject).to eq(Gitlab::Auth::Result.new)
end
end
end
end
- it 'recognizes other ci services' do
+ it "recognizes other ci services" do
project = create(:project)
project.create_drone_ci_service(active: true)
- project.drone_ci_service.update(token: 'token')
+ project.drone_ci_service.update(token: "token")
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: 'drone-ci-token')
- expect(gl_auth.find_for_git_client('drone-ci-token', 'token', project: project, ip: 'ip')).to eq(Gitlab::Auth::Result.new(nil, project, :ci, build_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "drone-ci-token")
+ expect(gl_auth.find_for_git_client("drone-ci-token", "token", project: project, ip: "ip")).to eq(Gitlab::Auth::Result.new(nil, project, :ci, build_authentication_abilities))
end
- it 'recognizes master passwords' do
- user = create(:user, password: 'password')
+ it "recognizes master passwords" do
+ user = create(:user, password: "password")
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: user.username)
- expect(gl_auth.find_for_git_client(user.username, 'password', project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: user.username)
+ expect(gl_auth.find_for_git_client(user.username, "password", project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
end
- include_examples 'user login operation with unique ip limit' do
- let(:user) { create(:user, password: 'password') }
+ include_examples "user login operation with unique ip limit" do
+ let(:user) { create(:user, password: "password") }
def operation
- expect(gl_auth.find_for_git_client(user.username, 'password', project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
+ expect(gl_auth.find_for_git_client(user.username, "password", project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
end
end
- context 'while using LFS authenticate' do
- it 'recognizes user lfs tokens' do
+ context "while using LFS authenticate" do
+ it "recognizes user lfs tokens" do
user = create(:user)
token = Gitlab::LfsToken.new(user).token
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: user.username)
- expect(gl_auth.find_for_git_client(user.username, token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(user, nil, :lfs_token, full_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: user.username)
+ expect(gl_auth.find_for_git_client(user.username, token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(user, nil, :lfs_token, full_authentication_abilities))
end
- it 'recognizes deploy key lfs tokens' do
+ it "recognizes deploy key lfs tokens" do
key = create(:deploy_key)
token = Gitlab::LfsToken.new(key).token
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: "lfs+deploy-key-#{key.id}")
- expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "lfs+deploy-key-#{key.id}")
+ expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_authentication_abilities))
end
- it 'does not try password auth before oauth' do
+ it "does not try password auth before oauth" do
user = create(:user)
token = Gitlab::LfsToken.new(user).token
expect(gl_auth).not_to receive(:find_with_user_password)
- gl_auth.find_for_git_client(user.username, token, project: nil, ip: 'ip')
+ gl_auth.find_for_git_client(user.username, token, project: nil, ip: "ip")
end
- it 'grants deploy key write permissions' do
+ it "grants deploy key write permissions" do
project = create(:project)
key = create(:deploy_key)
create(:deploy_keys_project, :write_access, deploy_key: key, project: project)
token = Gitlab::LfsToken.new(key).token
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: "lfs+deploy-key-#{key.id}")
- expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: project, ip: 'ip')).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_write_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "lfs+deploy-key-#{key.id}")
+ expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: project, ip: "ip")).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_write_authentication_abilities))
end
- it 'does not grant deploy key write permissions' do
+ it "does not grant deploy key write permissions" do
project = create(:project)
key = create(:deploy_key)
token = Gitlab::LfsToken.new(key).token
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: "lfs+deploy-key-#{key.id}")
- expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: project, ip: 'ip')).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "lfs+deploy-key-#{key.id}")
+ expect(gl_auth.find_for_git_client("lfs+deploy-key-#{key.id}", token, project: project, ip: "ip")).to eq(Gitlab::Auth::Result.new(key, nil, :lfs_deploy_token, read_authentication_abilities))
end
end
- context 'while using OAuth tokens as passwords' do
+ context "while using OAuth tokens as passwords" do
let(:user) { create(:user) }
- let(:token_w_api_scope) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: 'api') }
- let(:application) { Doorkeeper::Application.create!(name: 'MyApp', redirect_uri: 'https://app.com', owner: user) }
+ let(:token_w_api_scope) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: "api") }
+ let(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
- it 'succeeds for OAuth tokens with the `api` scope' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: 'oauth2')
- expect(gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(user, nil, :oauth, full_authentication_abilities))
+ it "succeeds for OAuth tokens with the `api` scope" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "oauth2")
+ expect(gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(user, nil, :oauth, full_authentication_abilities))
end
- it 'fails for OAuth tokens with other scopes' do
- token = Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: 'read_user')
+ it "fails for OAuth tokens with other scopes" do
+ token = Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: "read_user")
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'oauth2')
- expect(gl_auth.find_for_git_client("oauth2", token.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(nil, nil))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "oauth2")
+ expect(gl_auth.find_for_git_client("oauth2", token.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(nil, nil))
end
- it 'does not try password auth before oauth' do
+ it "does not try password auth before oauth" do
expect(gl_auth).not_to receive(:find_with_user_password)
- gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: 'ip')
+ gl_auth.find_for_git_client("oauth2", token_w_api_scope.token, project: nil, ip: "ip")
end
end
- context 'while using personal access tokens as passwords' do
- it 'succeeds for personal access tokens with the `api` scope' do
- personal_access_token = create(:personal_access_token, scopes: ['api'])
+ context "while using personal access tokens as passwords" do
+ it "succeeds for personal access tokens with the `api` scope" do
+ personal_access_token = create(:personal_access_token, scopes: ["api"])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: '')
- expect(gl_auth.find_for_git_client('', personal_access_token.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, full_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "")
+ expect(gl_auth.find_for_git_client("", personal_access_token.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, full_authentication_abilities))
end
- context 'when registry is enabled' do
+ context "when registry is enabled" do
before do
stub_container_registry_config(enabled: true)
end
- it 'succeeds for personal access tokens with the `read_registry` scope' do
- personal_access_token = create(:personal_access_token, scopes: ['read_registry'])
+ it "succeeds for personal access tokens with the `read_registry` scope" do
+ personal_access_token = create(:personal_access_token, scopes: ["read_registry"])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: '')
- expect(gl_auth.find_for_git_client('', personal_access_token.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, [:read_container_image]))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "")
+ expect(gl_auth.find_for_git_client("", personal_access_token.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, [:read_container_image]))
end
end
- it 'succeeds if it is an impersonation token' do
- impersonation_token = create(:personal_access_token, :impersonation, scopes: ['api'])
+ it "succeeds if it is an impersonation token" do
+ impersonation_token = create(:personal_access_token, :impersonation, scopes: ["api"])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: '')
- expect(gl_auth.find_for_git_client('', impersonation_token.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(impersonation_token.user, nil, :personal_access_token, full_authentication_abilities))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "")
+ expect(gl_auth.find_for_git_client("", impersonation_token.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(impersonation_token.user, nil, :personal_access_token, full_authentication_abilities))
end
- it 'limits abilities based on scope' do
+ it "limits abilities based on scope" do
personal_access_token = create(:personal_access_token, scopes: %w[read_user sudo])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: '')
- expect(gl_auth.find_for_git_client('', personal_access_token.token, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, []))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: "")
+ expect(gl_auth.find_for_git_client("", personal_access_token.token, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(personal_access_token.user, nil, :personal_access_token, []))
end
- it 'fails if password is nil' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: '')
- expect(gl_auth.find_for_git_client('', nil, project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new(nil, nil))
+ it "fails if password is nil" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "")
+ expect(gl_auth.find_for_git_client("", nil, project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new(nil, nil))
end
end
- context 'while using regular user and password' do
- it 'falls through lfs authentication' do
+ context "while using regular user and password" do
+ it "falls through lfs authentication" do
user = create(
:user,
- username: 'normal_user',
- password: 'my-secret'
+ username: "normal_user",
+ password: "my-secret"
)
- expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip'))
+ expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: "ip"))
.to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
end
- it 'fails through oauth authentication when the username is oauth2' do
+ it "fails through oauth authentication when the username is oauth2" do
user = create(
:user,
- username: 'oauth2',
- password: 'my-secret'
+ username: "oauth2",
+ password: "my-secret"
)
- expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: 'ip'))
+ expect(gl_auth.find_for_git_client(user.username, user.password, project: nil, ip: "ip"))
.to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities))
end
end
- it 'returns double nil for invalid credentials' do
- login = 'foo'
+ it "returns double nil for invalid credentials" do
+ login = "foo"
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, 'bar', project: nil, ip: 'ip')).to eq(Gitlab::Auth::Result.new)
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, "bar", project: nil, ip: "ip")).to eq(Gitlab::Auth::Result.new)
end
- it 'throws an error suggesting user create a PAT when internal auth is disabled' do
+ it "throws an error suggesting user create a PAT when internal auth is disabled" do
allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled_for_git?) { false }
- expect { gl_auth.find_for_git_client('foo', 'bar', project: nil, ip: 'ip') }.to raise_error(Gitlab::Auth::MissingPersonalAccessTokenError)
+ expect { gl_auth.find_for_git_client("foo", "bar", project: nil, ip: "ip") }.to raise_error(Gitlab::Auth::MissingPersonalAccessTokenError)
end
- context 'while using deploy tokens' do
+ context "while using deploy tokens" do
let(:project) { create(:project) }
let(:auth_failure) { Gitlab::Auth::Result.new(nil, nil) }
- context 'when the deploy token has read_repository as scope' do
+ context "when the deploy token has read_repository as scope" do
let(:deploy_token) { create(:deploy_token, read_registry: false, projects: [project]) }
let(:login) { deploy_token.username }
- it 'succeeds when login and token are valid' do
+ it "succeeds when login and token are valid" do
auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, [:download_code])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: login)
- expect(gl_auth.find_for_git_client(login, deploy_token.token, project: project, ip: 'ip'))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: login)
+ expect(gl_auth.find_for_git_client(login, deploy_token.token, project: project, ip: "ip"))
.to eq(auth_success)
end
- it 'fails when login is not valid' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'random_login')
- expect(gl_auth.find_for_git_client('random_login', deploy_token.token, project: project, ip: 'ip'))
+ it "fails when login is not valid" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "random_login")
+ expect(gl_auth.find_for_git_client("random_login", deploy_token.token, project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails when token is not valid' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, '123123', project: project, ip: 'ip'))
+ it "fails when token is not valid" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, "123123", project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token is nil' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, nil, project: project, ip: 'ip'))
+ it "fails if token is nil" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, nil, project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token is not related to project' do
+ it "fails if token is not related to project" do
another_deploy_token = create(:deploy_token)
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, another_deploy_token.token, project: project, ip: 'ip'))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, another_deploy_token.token, project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token has been revoked' do
+ it "fails if token has been revoked" do
deploy_token.revoke!
expect(deploy_token.revoked?).to be_truthy
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'deploy-token')
- expect(gl_auth.find_for_git_client('deploy-token', deploy_token.token, project: project, ip: 'ip'))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "deploy-token")
+ expect(gl_auth.find_for_git_client("deploy-token", deploy_token.token, project: project, ip: "ip"))
.to eq(auth_failure)
end
end
- context 'when the deploy token has read_registry as a scope' do
+ context "when the deploy token has read_registry as a scope" do
let(:deploy_token) { create(:deploy_token, read_repository: false, projects: [project]) }
let(:login) { deploy_token.username }
- context 'when registry enabled' do
+ context "when registry enabled" do
before do
stub_container_registry_config(enabled: true)
end
- it 'succeeds when login and token are valid' do
+ it "succeeds when login and token are valid" do
auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, [:read_container_image])
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: login)
- expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: 'ip'))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: true, login: login)
+ expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: "ip"))
.to eq(auth_success)
end
- it 'fails when login is not valid' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'random_login')
- expect(gl_auth.find_for_git_client('random_login', deploy_token.token, project: project, ip: 'ip'))
+ it "fails when login is not valid" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "random_login")
+ expect(gl_auth.find_for_git_client("random_login", deploy_token.token, project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails when token is not valid' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, '123123', project: project, ip: 'ip'))
+ it "fails when token is not valid" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, "123123", project: project, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token is nil' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, nil, project: nil, ip: 'ip'))
+ it "fails if token is nil" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, nil, project: nil, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token is not related to project' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, 'abcdef', project: nil, ip: 'ip'))
+ it "fails if token is not related to project" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, "abcdef", project: nil, ip: "ip"))
.to eq(auth_failure)
end
- it 'fails if token has been revoked' do
+ it "fails if token has been revoked" do
deploy_token.revoke!
expect(deploy_token.revoked?).to be_truthy
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'deploy-token')
- expect(gl_auth.find_for_git_client('deploy-token', deploy_token.token, project: nil, ip: 'ip'))
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: "deploy-token")
+ expect(gl_auth.find_for_git_client("deploy-token", deploy_token.token, project: nil, ip: "ip"))
.to eq(auth_failure)
end
end
- context 'when registry disabled' do
+ context "when registry disabled" do
before do
stub_container_registry_config(enabled: false)
end
- it 'fails when login and token are valid' do
- expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login)
- expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: 'ip'))
+ it "fails when login and token are valid" do
+ expect(gl_auth).to receive(:rate_limit!).with("ip", success: false, login: login)
+ expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: "ip"))
.to eq(auth_failure)
end
end
@@ -373,39 +373,39 @@ describe Gitlab::Auth do
end
end
- describe 'find_with_user_password' do
+ describe "find_with_user_password" do
let!(:user) do
create(:user,
username: username,
password: password,
password_confirmation: password)
end
- let(:username) { 'John' } # username isn't lowercase, test this
- let(:password) { 'my-secret' }
+ let(:username) { "John" } # username isn't lowercase, test this
+ let(:password) { "my-secret" }
it "finds user by valid login/password" do
- expect( gl_auth.find_with_user_password(username, password) ).to eql user
+ expect(gl_auth.find_with_user_password(username, password)).to eql user
end
- it 'finds 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 'finds 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 "does not find user with invalid password" do
- password = 'wrong'
- expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
+ password = "wrong"
+ expect(gl_auth.find_with_user_password(username, password)).not_to eql user
end
it "does not find user with invalid login" do
- user = 'wrong'
- expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
+ user = "wrong"
+ expect(gl_auth.find_with_user_password(username, password)).not_to eql user
end
- include_examples 'user login operation with unique ip limit' do
+ include_examples "user login operation with unique ip limit" do
def operation
expect(gl_auth.find_with_user_password(username, password)).to eq(user)
end
@@ -414,13 +414,13 @@ describe Gitlab::Auth do
it "does not find user in blocked state" do
user.block
- expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
+ expect(gl_auth.find_with_user_password(username, password)).not_to eql user
end
it "does not find user in ldap_blocked state" do
user.ldap_block
- expect( gl_auth.find_with_user_password(username, password) ).not_to eql user
+ expect(gl_auth.find_with_user_password(username, password)).not_to eql user
end
context "with ldap enabled" do
@@ -437,13 +437,13 @@ describe Gitlab::Auth do
it "does not find user by using ldap as fallback to for authentication" do
expect(Gitlab::Auth::LDAP::Authentication).to receive(:login).and_return(nil)
- expect(gl_auth.find_with_user_password('ldap_user', 'password')).to be_nil
+ expect(gl_auth.find_with_user_password("ldap_user", "password")).to be_nil
end
it "find new user by using ldap as fallback to for authentication" do
expect(Gitlab::Auth::LDAP::Authentication).to receive(:login).and_return(user)
- expect(gl_auth.find_with_user_password('ldap_user', 'password')).to eq(user)
+ expect(gl_auth.find_with_user_password("ldap_user", "password")).to eq(user)
end
end
@@ -475,7 +475,7 @@ describe Gitlab::Auth do
:read_project,
:build_download_code,
:build_read_container_image,
- :build_create_container_image
+ :build_create_container_image,
]
end
@@ -483,20 +483,20 @@ describe Gitlab::Auth do
[
:read_project,
:download_code,
- :read_container_image
+ :read_container_image,
]
end
def read_write_authentication_abilities
read_authentication_abilities + [
:push_code,
- :create_container_image
+ :create_container_image,
]
end
def full_authentication_abilities
read_write_authentication_abilities + [
- :admin_container_image
+ :admin_container_image,
]
end
end
diff --git a/spec/lib/gitlab/background_migration/add_merge_request_diff_commits_count_spec.rb b/spec/lib/gitlab/background_migration/add_merge_request_diff_commits_count_spec.rb
index c43ed72038e..2aaafa5fadf 100644
--- a/spec/lib/gitlab/background_migration/add_merge_request_diff_commits_count_spec.rb
+++ b/spec/lib/gitlab/background_migration/add_merge_request_diff_commits_count_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount, :migration, schema: 20180105212544 do
let(:projects_table) { table(:projects) }
@@ -6,50 +6,53 @@ describe Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount, :migratio
let(:merge_request_diffs_table) { table(:merge_request_diffs) }
let(:merge_request_diff_commits_table) { table(:merge_request_diff_commits) }
- let(:project) { projects_table.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') }
+ let(:project) { projects_table.create!(name: "gitlab", path: "gitlab-org/gitlab-ce") }
let(:merge_request) do
merge_requests_table.create!(target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
- source_branch: 'mr name',
- title: 'mr name')
+ source_branch: "mr name",
+ title: "mr name")
end
def create_diff!(name, commits: 0)
mr_diff = merge_request_diffs_table.create!(
- merge_request_id: merge_request.id)
+ merge_request_id: merge_request.id
+ )
commits.times do |i|
merge_request_diff_commits_table.create!(
merge_request_diff_id: mr_diff.id,
- relative_order: i, sha: i)
+ relative_order: i, sha: i
+ )
end
mr_diff
end
- describe '#perform' do
- it 'migrates diffs that have no commits' do
- diff = create_diff!('with_multiple_commits', commits: 0)
+ describe "#perform" do
+ it "migrates diffs that have no commits" do
+ diff = create_diff!("with_multiple_commits", commits: 0)
subject.perform(diff.id, diff.id)
expect(diff.reload.commits_count).to eq(0)
end
- it 'skips diffs that have commits_count already set' do
+ it "skips diffs that have commits_count already set" do
timestamp = 2.days.ago
diff = merge_request_diffs_table.create!(
merge_request_id: merge_request.id,
commits_count: 0,
- updated_at: timestamp)
+ updated_at: timestamp
+ )
subject.perform(diff.id, diff.id)
expect(diff.reload.updated_at).to be_within(1.second).of(timestamp)
end
- it 'migrates multiple diffs to the correct values' do
+ it "migrates multiple diffs to the correct values" do
diffs = Array.new(3).map.with_index { |_, i| create_diff!(i, commits: 3) }
subject.perform(diffs.first.id, diffs.last.id)
diff --git a/spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb b/spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb
index 877c061d11b..c20a9c33cfa 100644
--- a/spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb
+++ b/spec/lib/gitlab/background_migration/archive_legacy_traces_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 20180529152628 do
include TraceHelpers
@@ -9,17 +9,17 @@ describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 2
let(:job_artifacts) { table(:ci_job_artifacts) }
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
- @build = builds.create!(id: 1, project_id: 123, status: 'success', type: 'Ci::Build')
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1", namespace_id: 123)
+ @build = builds.create!(id: 1, project_id: 123, status: "success", type: "Ci::Build")
end
- context 'when trace file exsits at the right place' do
+ context "when trace file exsits at the right place" do
before do
- create_legacy_trace(@build, 'trace in file')
+ create_legacy_trace(@build, "trace in file")
end
- it 'correctly archive legacy traces' do
+ it "correctly archive legacy traces" do
expect(job_artifacts.count).to eq(0)
expect(File.exist?(legacy_trace_path(@build))).to be_truthy
@@ -27,24 +27,24 @@ describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 2
expect(job_artifacts.count).to eq(1)
expect(File.exist?(legacy_trace_path(@build))).to be_falsy
- expect(File.read(archived_trace_path(job_artifacts.first))).to eq('trace in file')
+ expect(File.read(archived_trace_path(job_artifacts.first))).to eq("trace in file")
end
end
- context 'when trace file does not exsits at the right place' do
- it 'does not raise errors nor create job artifact' do
+ context "when trace file does not exsits at the right place" do
+ it "does not raise errors nor create job artifact" do
expect { described_class.new.perform(1, 1) }.not_to raise_error
expect(job_artifacts.count).to eq(0)
end
end
- context 'when trace data exsits in database' do
+ context "when trace data exsits in database" do
before do
- create_legacy_trace_in_db(@build, 'trace in db')
+ create_legacy_trace_in_db(@build, "trace in db")
end
- it 'correctly archive legacy traces' do
+ it "correctly archive legacy traces" do
expect(job_artifacts.count).to eq(0)
expect(@build.read_attribute(:trace)).not_to be_empty
@@ -53,7 +53,7 @@ describe Gitlab::BackgroundMigration::ArchiveLegacyTraces, :migration, schema: 2
@build.reload
expect(job_artifacts.count).to eq(1)
expect(@build.read_attribute(:trace)).to be_nil
- expect(File.read(archived_trace_path(job_artifacts.first))).to eq('trace in db')
+ expect(File.read(archived_trace_path(job_artifacts.first))).to eq("trace in db")
end
end
end
diff --git a/spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb
index e802613490b..962aa326f3f 100644
--- a/spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb
+++ b/spec/lib/gitlab/background_migration/backfill_hashed_project_repositories_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::BackfillHashedProjectRepositories, :migration, schema: 20181130102132 do
- it_behaves_like 'backfill migration for project repositories', :hashed
+ it_behaves_like "backfill migration for project repositories", :hashed
end
diff --git a/spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb
index 947c99b860f..ed109a2447e 100644
--- a/spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb
+++ b/spec/lib/gitlab/background_migration/backfill_legacy_project_repositories_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::BackfillLegacyProjectRepositories, :migration, schema: 20181212171634 do
- it_behaves_like 'backfill migration for project repositories', :legacy
+ it_behaves_like "backfill migration for project repositories", :legacy
end
diff --git a/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb b/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb
index c66d7cd6148..6d048b5ec55 100644
--- a/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb
+++ b/spec/lib/gitlab/background_migration/backfill_project_fullpath_in_repo_config_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migration, schema: 20181010133639 do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
- let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
- let(:subgroup) { namespaces.create!(name: 'bar', path: 'bar', parent_id: group.id) }
+ let(:group) { namespaces.create!(name: "foo", path: "foo") }
+ let(:subgroup) { namespaces.create!(name: "bar", path: "bar", parent_id: group.id) }
describe described_class::Storage::HashedProject do
let(:project) { double(id: 555) }
subject(:project_storage) { described_class.new(project) }
- it 'has the correct disk_path' do
- expect(project_storage.disk_path).to eq('@hashed/91/a7/91a73fd806ab2c005c13b4dc19130a884e909dea3f72d46e30266fe1a1f588d8')
+ it "has the correct disk_path" do
+ expect(project_storage.disk_path).to eq("@hashed/91/a7/91a73fd806ab2c005c13b4dc19130a884e909dea3f72d46e30266fe1a1f588d8")
end
end
describe described_class::Storage::LegacyProject do
- let(:project) { double(full_path: 'this/is/the/full/path') }
+ let(:project) { double(full_path: "this/is/the/full/path") }
subject(:project_storage) { described_class.new(project) }
- it 'has the correct disk_path' do
- expect(project_storage.disk_path).to eq('this/is/the/full/path')
+ it "has the correct disk_path" do
+ expect(project_storage.disk_path).to eq("this/is/the/full/path")
end
end
describe described_class::Project do
- let(:project_record) { projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz') }
+ let(:project_record) { projects.create!(namespace_id: subgroup.id, name: "baz", path: "baz") }
subject(:project) { described_class.find(project_record.id) }
- describe '#full_path' do
- it 'returns path containing all parent namespaces' do
- expect(project.full_path).to eq('foo/bar/baz')
+ describe "#full_path" do
+ it "returns path containing all parent namespaces" do
+ expect(project.full_path).to eq("foo/bar/baz")
end
- it 'raises OrphanedNamespaceError when any parent namespace does not exist' do
+ it "raises OrphanedNamespaceError when any parent namespace does not exist" do
subgroup.update_attribute(:parent_id, namespaces.maximum(:id).succ)
expect { project.full_path }.to raise_error(Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig::OrphanedNamespaceError)
@@ -44,21 +44,21 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
end
describe described_class::Up do
- describe '#perform' do
+ describe "#perform" do
subject(:migrate) { described_class.new.perform(projects.minimum(:id), projects.maximum(:id)) }
- it 'asks the gitaly client to set config' do
- projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz')
- projects.create!(namespace_id: subgroup.id, name: 'buzz', path: 'buzz', storage_version: 1)
+ it "asks the gitaly client to set config" do
+ projects.create!(namespace_id: subgroup.id, name: "baz", path: "baz")
+ projects.create!(namespace_id: subgroup.id, name: "buzz", path: "buzz", storage_version: 1)
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |repository_service|
allow(repository_service).to receive(:cleanup)
- expect(repository_service).to receive(:set_config).with('gitlab.fullpath' => 'foo/bar/baz')
+ expect(repository_service).to receive(:set_config).with("gitlab.fullpath" => "foo/bar/baz")
end
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |repository_service|
allow(repository_service).to receive(:cleanup)
- expect(repository_service).to receive(:set_config).with('gitlab.fullpath' => 'foo/bar/buzz')
+ expect(repository_service).to receive(:set_config).with("gitlab.fullpath" => "foo/bar/buzz")
end
migrate
@@ -67,15 +67,15 @@ describe Gitlab::BackgroundMigration::BackfillProjectFullpathInRepoConfig, :migr
end
describe described_class::Down do
- describe '#perform' do
+ describe "#perform" do
subject(:migrate) { described_class.new.perform(projects.minimum(:id), projects.maximum(:id)) }
- it 'asks the gitaly client to set config' do
- projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz')
+ it "asks the gitaly client to set config" do
+ projects.create!(namespace_id: subgroup.id, name: "baz", path: "baz")
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |repository_service|
allow(repository_service).to receive(:cleanup)
- expect(repository_service).to receive(:delete_config).with(['gitlab.fullpath'])
+ expect(repository_service).to receive(:delete_config).with(["gitlab.fullpath"])
end
migrate
diff --git a/spec/lib/gitlab/background_migration/backfill_project_repositories_spec.rb b/spec/lib/gitlab/background_migration/backfill_project_repositories_spec.rb
index 510a0074554..76c535a3b41 100644
--- a/spec/lib/gitlab/background_migration/backfill_project_repositories_spec.rb
+++ b/spec/lib/gitlab/background_migration/backfill_project_repositories_spec.rb
@@ -1,60 +1,60 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::BackfillProjectRepositories do
- let(:group) { create(:group, name: 'foo', path: 'foo') }
+ let(:group) { create(:group, name: "foo", path: "foo") }
describe described_class::ShardFinder do
- let(:shard) { create(:shard, name: 'default') }
+ let(:shard) { create(:shard, name: "default") }
- describe '#find_shard_id' do
- it 'creates a new shard when it does not exist yet' do
- expect { subject.find_shard_id('other') }.to change(Shard, :count).by(1)
+ describe "#find_shard_id" do
+ it "creates a new shard when it does not exist yet" do
+ expect { subject.find_shard_id("other") }.to change(Shard, :count).by(1)
end
- it 'returns the shard when it exists' do
- other_shard = create(:shard, name: 'other')
+ it "returns the shard when it exists" do
+ other_shard = create(:shard, name: "other")
- shard_id = subject.find_shard_id('other')
+ shard_id = subject.find_shard_id("other")
expect(shard_id).to eq(other_shard.id)
end
- it 'only queries the database once to retrieve shards' do
- subject.find_shard_id('default')
+ it "only queries the database once to retrieve shards" do
+ subject.find_shard_id("default")
- expect { subject.find_shard_id('default') }.not_to exceed_query_limit(0)
+ expect { subject.find_shard_id("default") }.not_to exceed_query_limit(0)
end
end
end
describe described_class::Project do
- let!(:project_hashed_storage_1) { create(:project, name: 'foo', path: 'foo', namespace: group, storage_version: 1) }
- let!(:project_hashed_storage_2) { create(:project, name: 'bar', path: 'bar', namespace: group, storage_version: 2) }
- let!(:project_legacy_storage_3) { create(:project, name: 'baz', path: 'baz', namespace: group, storage_version: 0) }
- let!(:project_legacy_storage_4) { create(:project, name: 'zoo', path: 'zoo', namespace: group, storage_version: nil) }
- let!(:project_legacy_storage_5) { create(:project, name: 'test', path: 'test', namespace: group, storage_version: nil) }
-
- describe '.on_hashed_storage' do
- it 'finds projects with repository on hashed storage' do
+ let!(:project_hashed_storage_1) { create(:project, name: "foo", path: "foo", namespace: group, storage_version: 1) }
+ let!(:project_hashed_storage_2) { create(:project, name: "bar", path: "bar", namespace: group, storage_version: 2) }
+ let!(:project_legacy_storage_3) { create(:project, name: "baz", path: "baz", namespace: group, storage_version: 0) }
+ let!(:project_legacy_storage_4) { create(:project, name: "zoo", path: "zoo", namespace: group, storage_version: nil) }
+ let!(:project_legacy_storage_5) { create(:project, name: "test", path: "test", namespace: group, storage_version: nil) }
+
+ describe ".on_hashed_storage" do
+ it "finds projects with repository on hashed storage" do
projects = described_class.on_hashed_storage.pluck(:id)
expect(projects).to match_array([project_hashed_storage_1.id, project_hashed_storage_2.id])
end
end
- describe '.on_legacy_storage' do
- it 'finds projects with repository on legacy storage' do
+ describe ".on_legacy_storage" do
+ it "finds projects with repository on legacy storage" do
projects = described_class.on_legacy_storage.pluck(:id)
expect(projects).to match_array([project_legacy_storage_3.id, project_legacy_storage_4.id, project_legacy_storage_5.id])
end
end
- describe '.without_project_repository' do
- it 'finds projects which do not have a projects_repositories entry' do
+ describe ".without_project_repository" do
+ it "finds projects which do not have a projects_repositories entry" do
create(:project_repository, project: project_hashed_storage_1)
create(:project_repository, project: project_legacy_storage_3)
@@ -64,32 +64,32 @@ describe Gitlab::BackgroundMigration::BackfillProjectRepositories do
end
end
- describe '#disk_path' do
- context 'for projects on hashed storage' do
- it 'returns the correct disk_path' do
+ describe "#disk_path" do
+ context "for projects on hashed storage" do
+ it "returns the correct disk_path" do
project = described_class.find(project_hashed_storage_1.id)
expect(project.disk_path).to eq(project_hashed_storage_1.disk_path)
end
end
- context 'for projects on legacy storage' do
- it 'returns the correct disk_path' do
+ context "for projects on legacy storage" do
+ it "returns the correct disk_path" do
project = described_class.find(project_legacy_storage_3.id)
expect(project.disk_path).to eq(project_legacy_storage_3.disk_path)
end
- it 'returns the correct disk_path using the route entry' do
- project_legacy_storage_5.route.update(path: 'zoo/new-test')
+ it "returns the correct disk_path using the route entry" do
+ project_legacy_storage_5.route.update(path: "zoo/new-test")
project = described_class.find(project_legacy_storage_5.id)
- expect(project.disk_path).to eq('zoo/new-test')
+ expect(project.disk_path).to eq("zoo/new-test")
end
- it 'raises OrphanedNamespaceError when any parent namespace does not exist' do
+ it "raises OrphanedNamespaceError when any parent namespace does not exist" do
subgroup = create(:group, parent: group)
- project_orphaned_namespace = create(:project, name: 'baz', path: 'baz', namespace: subgroup, storage_version: nil)
+ project_orphaned_namespace = create(:project, name: "baz", path: "baz", namespace: subgroup, storage_version: nil)
subgroup.update_column(:parent_id, Namespace.maximum(:id).succ)
project = described_class.find(project_orphaned_namespace.id)
diff --git a/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb b/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb
index 5076996474f..fed5e1a5cfa 100644
--- a/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb
+++ b/spec/lib/gitlab/background_migration/create_fork_network_memberships_range_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migration, schema: 20170929131201 do
let(:migration) { described_class.new }
@@ -48,7 +48,7 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
migration.perform(1, 8)
end
- it 'creates a memberships for the direct forks' do
+ it "creates a memberships for the direct forks" do
base1_fork1_membership = fork_network_members.find_by(fork_network_id: fork_network1.id,
project_id: base1_fork1.id)
base1_fork2_membership = fork_network_members.find_by(fork_network_id: fork_network1.id,
@@ -64,7 +64,7 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
expect(base2_fork2_membership.forked_from_project_id).to eq(base2.id)
end
- it 'adds the fork network members for forks of forks' do
+ it "adds the fork network members for forks of forks" do
fork_of_fork_membership = fork_network_members.find_by(project_id: fork_of_fork.id,
fork_network_id: fork_network1.id)
fork_of_fork2_membership = fork_network_members.find_by(project_id: fork_of_fork2.id,
@@ -80,7 +80,7 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
expect(third_level_fork_membership.forked_from_project_id).to eq(second_level_fork.id)
end
- it 'reschedules itself when there are missing members' do
+ it "reschedules itself when there are missing members" do
allow(migration).to receive(:missing_members?).and_return(true)
expect(BackgroundMigrationWorker)
@@ -89,28 +89,28 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
migration.perform(1, 3)
end
- it 'can be repeated without effect' do
+ it "can be repeated without effect" do
expect { fork_network_members.count }.not_to change { migration.perform(1, 7) }
end
- it 'knows it is finished for this range' do
+ it "knows it is finished for this range" do
expect(migration.missing_members?(1, 8)).to be_falsy
end
- it 'does not miss members for forks of forks for which the root was deleted' do
+ it "does not miss members for forks of forks for which the root was deleted" do
forked_project_links.create(id: 9, forked_from_project_id: base1_fork1.id, forked_to_project_id: projects.create.id)
base1.destroy
expect(migration.missing_members?(7, 10)).to be_falsy
end
- context 'with more forks' do
+ context "with more forks" do
before do
forked_project_links.create(id: 9, forked_from_project_id: fork_of_fork.id, forked_to_project_id: projects.create.id)
forked_project_links.create(id: 10, forked_from_project_id: fork_of_fork.id, forked_to_project_id: projects.create.id)
end
- it 'only processes a single batch of links at a time' do
+ it "only processes a single batch of links at a time" do
expect(fork_network_members.count).to eq(10)
migration.perform(8, 10)
@@ -118,7 +118,7 @@ describe Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange, :migrat
expect(fork_network_members.count).to eq(12)
end
- it 'knows when not all memberships within a batch have been created' do
+ it "knows when not all memberships within a batch have been created" do
expect(migration.missing_members?(8, 10)).to be_truthy
end
end
diff --git a/spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb b/spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
index f974dc8fda2..d1c550ab58d 100644
--- a/spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
+++ b/spec/lib/gitlab/background_migration/create_gpg_key_subkeys_from_gpg_keys_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::CreateGpgKeySubkeysFromGpgKeys, :migration, schema: 20171005130944 do
- context 'when GpgKey exists' do
+ context "when GpgKey exists" do
let!(:gpg_key) { create(:gpg_key, key: GpgHelpers::User3.public_key) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
before do
GpgKeySubkey.destroy_all # rubocop: disable DestroyAll
end
- it 'generate the subkeys' do
- expect do
+ it "generate the subkeys" do
+ expect {
described_class.new.perform(gpg_key.id)
- end.to change { gpg_key.subkeys.count }.from(0).to(2)
+ }.to change { gpg_key.subkeys.count }.from(0).to(2)
end
- it 'schedules the signature update worker' do
+ it "schedules the signature update worker" do
expect(InvalidGpgSignatureUpdateWorker).to receive(:perform_async).with(gpg_key.id)
described_class.new.perform(gpg_key.id)
end
end
- context 'when GpgKey does not exist' do
- it 'does not do anything' do
+ context "when GpgKey does not exist" do
+ it "does not do anything" do
expect(Gitlab::Gpg).not_to receive(:subkeys_from_key)
expect(InvalidGpgSignatureUpdateWorker).not_to receive(:perform_async)
diff --git a/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb b/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb
index 9bae7e53b71..8066ac37498 100644
--- a/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb
+++ b/spec/lib/gitlab/background_migration/delete_conflicting_redirect_routes_range_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::DeleteConflictingRedirectRoutesRange, :migration, schema: 20170907170235 do
let!(:redirect_routes) { table(:redirect_routes) }
let!(:routes) { table(:routes) }
before do
- routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1')
- routes.create!(id: 2, source_id: 2, source_type: 'Namespace', path: 'foo2')
- routes.create!(id: 3, source_id: 3, source_type: 'Namespace', path: 'foo3')
- routes.create!(id: 4, source_id: 4, source_type: 'Namespace', path: 'foo4')
- routes.create!(id: 5, source_id: 5, source_type: 'Namespace', path: 'foo5')
+ routes.create!(id: 1, source_id: 1, source_type: "Namespace", path: "foo1")
+ routes.create!(id: 2, source_id: 2, source_type: "Namespace", path: "foo2")
+ routes.create!(id: 3, source_id: 3, source_type: "Namespace", path: "foo3")
+ routes.create!(id: 4, source_id: 4, source_type: "Namespace", path: "foo4")
+ routes.create!(id: 5, source_id: 5, source_type: "Namespace", path: "foo5")
# Valid redirects
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar2')
- redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'bar3')
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "bar")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "bar2")
+ redirect_routes.create!(source_id: 2, source_type: "Namespace", path: "bar3")
# Conflicting redirects
- redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'foo1')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo2')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo3')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo4')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo5')
+ redirect_routes.create!(source_id: 2, source_type: "Namespace", path: "foo1")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo2")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo3")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo4")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo5")
end
# No-op. See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252
- it 'NO-OP: does not delete any redirect_routes' do
+ it "NO-OP: does not delete any redirect_routes" do
expect(redirect_routes.count).to eq(8)
described_class.new.perform(1, 5)
diff --git a/spec/lib/gitlab/background_migration/delete_diff_files_spec.rb b/spec/lib/gitlab/background_migration/delete_diff_files_spec.rb
index 27281333348..2a29eb3e531 100644
--- a/spec/lib/gitlab/background_migration/delete_diff_files_spec.rb
+++ b/spec/lib/gitlab/background_migration/delete_diff_files_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::DeleteDiffFiles, :migration, :sidekiq, schema: 20180619121030 do
- describe '#perform' do
- context 'when diff files can be deleted' do
+ describe "#perform" do
+ context "when diff files can be deleted" do
let(:merge_request) { create(:merge_request, :merged) }
let!(:merge_request_diff) do
merge_request.create_merge_request_diff
@@ -14,19 +14,19 @@ describe Gitlab::BackgroundMigration::DeleteDiffFiles, :migration, :sidekiq, sch
described_class.new.perform(MergeRequestDiff.pluck(:id))
end
- it 'deletes all merge request diff files' do
+ it "deletes all merge request diff files" do
expect { perform }
.to change { merge_request_diff.merge_request_diff_files.count }
.from(20).to(0)
end
- it 'updates state to without_files' do
+ it "updates state to without_files" do
expect { perform }
.to change { merge_request_diff.reload.state }
- .from('collected').to('without_files')
+ .from("collected").to("without_files")
end
- it 'rollsback if something goes wrong' do
+ it "rollsback if something goes wrong" do
expect(described_class::MergeRequestDiffFile).to receive_message_chain(:where, :delete_all)
.and_raise
@@ -35,12 +35,12 @@ describe Gitlab::BackgroundMigration::DeleteDiffFiles, :migration, :sidekiq, sch
merge_request_diff.reload
- expect(merge_request_diff.state).to eq('collected')
+ expect(merge_request_diff.state).to eq("collected")
expect(merge_request_diff.merge_request_diff_files.count).to eq(20)
end
end
- it 'reschedules itself when should_wait_deadtuple_vacuum' do
+ it "reschedules itself when should_wait_deadtuple_vacuum" do
merge_request = create(:merge_request, :merged)
first_diff = merge_request.merge_request_diff
second_diff = merge_request.create_merge_request_diff
@@ -57,11 +57,11 @@ describe Gitlab::BackgroundMigration::DeleteDiffFiles, :migration, :sidekiq, sch
end
end
- describe '#should_wait_deadtuple_vacuum?' do
- it 'returns true when hitting merge_request_diff_files hits DEAD_TUPLES_THRESHOLD', :postgresql do
+ describe "#should_wait_deadtuple_vacuum?" do
+ it "returns true when hitting merge_request_diff_files hits DEAD_TUPLES_THRESHOLD", :postgresql do
worker = described_class.new
- threshold_query_result = [{ "n_dead_tup" => described_class::DEAD_TUPLES_THRESHOLD.to_s }]
- normal_query_result = [{ "n_dead_tup" => '3' }]
+ threshold_query_result = [{"n_dead_tup" => described_class::DEAD_TUPLES_THRESHOLD.to_s}]
+ normal_query_result = [{"n_dead_tup" => "3"}]
allow(worker)
.to receive(:execute_statement)
diff --git a/spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb b/spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb
index bc71a90605a..683b436ea36 100644
--- a/spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb
+++ b/spec/lib/gitlab/background_migration/deserialize_merge_request_diffs_and_commits_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :migration, schema: 20171114162227 do
@@ -7,9 +7,9 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
let(:merge_request_diffs) { table(:merge_request_diffs) }
let(:merge_requests) { table(:merge_requests) }
- describe '#perform' do
+ describe "#perform" do
let(:project) { create(:project, :repository) }
- let(:merge_request) { merge_requests.create!(iid: 1, target_project_id: project.id, source_project_id: project.id, target_branch: 'feature', source_branch: 'master').becomes(MergeRequest) }
+ let(:merge_request) { merge_requests.create!(iid: 1, target_project_id: project.id, source_project_id: project.id, target_branch: "feature", source_branch: "master").becomes(MergeRequest) }
let(:merge_request_diff) { MergeRequest.find(merge_request.id).create_merge_request_diff }
let(:updated_merge_request_diff) { MergeRequestDiff.find(merge_request_diff.id) }
let(:rugged) { rugged_repo(project.repository) }
@@ -33,7 +33,7 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
)
end
- shared_examples 'updated MR diff' do
+ shared_examples "updated MR diff" do
before do
convert_to_yaml(merge_request_diff.id, commits, diffs)
@@ -43,40 +43,40 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
subject.perform(merge_request_diff.id, merge_request_diff.id)
end
- it 'creates correct entries in the merge_request_diff_commits table' do
+ it "creates correct entries in the merge_request_diff_commits table" do
expect(updated_merge_request_diff.merge_request_diff_commits.count).to eq(expected_commits.count)
expect(updated_merge_request_diff.commits.map(&:to_hash)).to eq(expected_commits)
end
- it 'creates correct entries in the merge_request_diff_files table' do
+ it "creates correct entries in the merge_request_diff_files table" do
expect(updated_merge_request_diff.merge_request_diff_files.count).to eq(expected_diffs.count)
expect(diffs_to_hashes(updated_merge_request_diff.raw_diffs)).to eq(expected_diffs)
end
- it 'sets the st_commits and st_diffs columns to nil' do
+ it "sets the st_commits and st_diffs columns to nil" do
expect(updated_merge_request_diff.st_commits_before_type_cast).to be_nil
expect(updated_merge_request_diff.st_diffs_before_type_cast).to be_nil
end
end
- context 'when the diff IDs passed do not exist' do
- it 'does not raise' do
+ context "when the diff IDs passed do not exist" do
+ it "does not raise" do
expect { subject.perform(0, 0) }.not_to raise_exception
end
end
- context 'when the merge request diff has no serialised commits or diffs' do
+ context "when the merge request diff has no serialised commits or diffs" do
before do
merge_request_diff.update(st_commits: nil, st_diffs: nil)
end
- it 'does not raise' do
+ it "does not raise" do
expect { subject.perform(merge_request_diff.id, merge_request_diff.id) }
.not_to raise_exception
end
end
- context 'processing multiple merge request diffs' do
+ context "processing multiple merge request diffs" do
let(:start_id) { described_class::MergeRequestDiff.minimum(:id) }
let(:stop_id) { described_class::MergeRequestDiff.maximum(:id) }
@@ -90,57 +90,57 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
MergeRequestDiffFile.delete_all
end
- context 'when BUFFER_ROWS is exceeded' do
+ context "when BUFFER_ROWS is exceeded" do
before do
stub_const("#{described_class}::BUFFER_ROWS", 1)
allow(Gitlab::Database).to receive(:bulk_insert).and_call_original
end
- it 'inserts commit rows in chunks of BUFFER_ROWS' do
+ it "inserts commit rows in chunks of BUFFER_ROWS" do
# There are 29 commits in each diff, so we should have slices of 20 + 9 + 20 + 9.
stub_const("#{described_class}::BUFFER_ROWS", 20)
expect(Gitlab::Database).to receive(:bulk_insert)
- .with('merge_request_diff_commits', anything)
- .exactly(4)
- .times
- .and_call_original
+ .with("merge_request_diff_commits", anything)
+ .exactly(4)
+ .times
+ .and_call_original
subject.perform(start_id, stop_id)
end
- it 'inserts diff rows in chunks of DIFF_FILE_BUFFER_ROWS' do
+ it "inserts diff rows in chunks of DIFF_FILE_BUFFER_ROWS" do
# There are 20 files in each diff, so we should have slices of 20 + 20.
stub_const("#{described_class}::DIFF_FILE_BUFFER_ROWS", 20)
expect(Gitlab::Database).to receive(:bulk_insert)
- .with('merge_request_diff_files', anything)
- .exactly(2)
- .times
- .and_call_original
+ .with("merge_request_diff_files", anything)
+ .exactly(2)
+ .times
+ .and_call_original
subject.perform(start_id, stop_id)
end
end
- context 'when BUFFER_ROWS is not exceeded' do
- it 'only updates once' do
+ context "when BUFFER_ROWS is not exceeded" do
+ it "only updates once" do
expect(Gitlab::Database).to receive(:bulk_insert)
- .with('merge_request_diff_commits', anything)
- .once
- .and_call_original
+ .with("merge_request_diff_commits", anything)
+ .once
+ .and_call_original
expect(Gitlab::Database).to receive(:bulk_insert)
- .with('merge_request_diff_files', anything)
- .once
- .and_call_original
+ .with("merge_request_diff_files", anything)
+ .once
+ .and_call_original
subject.perform(start_id, stop_id)
end
end
- context 'when some rows were already inserted due to a previous failure' do
+ context "when some rows were already inserted due to a previous failure" do
before do
subject.perform(start_id, stop_id)
@@ -148,34 +148,32 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
convert_to_yaml(stop_id, updated_merge_request_diff.commits, diffs_to_hashes(updated_merge_request_diff.merge_request_diff_files))
end
- it 'does not raise' do
+ it "does not raise" do
expect { subject.perform(start_id, stop_id) }.not_to raise_exception
end
- it 'logs a message' do
+ it "logs a message" do
expect(Rails.logger).to receive(:info)
- .with(
- a_string_matching(described_class.name).and(matching([start_id, stop_id].inspect))
- )
- .twice
+ .with(
+ a_string_matching(described_class.name).and(matching([start_id, stop_id].inspect))
+ )
+ .twice
subject.perform(start_id, stop_id)
end
- it 'ends up with the correct rows' do
+ it "ends up with the correct rows" do
expect(updated_merge_request_diff.commits.count).to eq(29)
expect(updated_merge_request_diff.raw_diffs.count).to eq(20)
end
end
- context 'when the merge request diff update fails' do
+ context "when the merge request diff update fails" do
let(:exception) { ActiveRecord::RecordNotFound }
let(:perform_ignoring_exceptions) do
- begin
- subject.perform(start_id, stop_id)
- rescue described_class::Error
- end
+ subject.perform(start_id, stop_id)
+ rescue described_class::Error
end
before do
@@ -183,12 +181,12 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
.to receive(:update_all).and_raise(exception)
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.perform(start_id, stop_id) }
.to raise_exception(described_class::Error)
end
- it 'logs the error' do
+ it "logs the error" do
expect(Rails.logger).to receive(:info).with(
a_string_matching(described_class.name)
.and(matching([start_id, stop_id].inspect))
@@ -198,37 +196,37 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
perform_ignoring_exceptions
end
- it 'still adds diff commits' do
+ it "still adds diff commits" do
expect { perform_ignoring_exceptions }
.to change { MergeRequestDiffCommit.count }
end
- it 'still adds diff files' do
+ it "still adds diff files" do
expect { perform_ignoring_exceptions }
.to change { MergeRequestDiffFile.count }
end
end
end
- context 'when the merge request diff has valid commits and diffs' do
+ context "when the merge request diff has valid commits and diffs" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
let(:diffs) { diffs_to_hashes(merge_request_diff.merge_request_diff_files) }
let(:expected_diffs) { diffs }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diff has diffs but no commits' do
+ context "when the merge request diff has diffs but no commits" do
let(:commits) { nil }
let(:expected_commits) { [] }
let(:diffs) { diffs_to_hashes(merge_request_diff.merge_request_diff_files) }
let(:expected_diffs) { diffs }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs do not have too_large set' do
+ context "when the merge request diffs do not have too_large set" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
let(:expected_diffs) { diffs_to_hashes(merge_request_diff.merge_request_diff_files) }
@@ -237,10 +235,10 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
expected_diffs.map { |diff| diff.except(:too_large) }
end
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs do not have a_mode and b_mode set' do
+ context "when the merge request diffs do not have a_mode and b_mode set" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
let(:expected_diffs) { diffs_to_hashes(merge_request_diff.merge_request_diff_files) }
@@ -249,10 +247,10 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
expected_diffs.map { |diff| diff.except(:a_mode, :b_mode) }
end
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs have binary content' do
+ context "when the merge request diffs have binary content" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
let(:expected_diffs) { diffs }
@@ -265,58 +263,58 @@ describe Gitlab::BackgroundMigration::DeserializeMergeRequestDiffsAndCommits, :m
let(:diffs) do
[
{
- 'diff' => binary_string,
- 'new_path' => 'path',
- 'old_path' => 'path',
- 'a_mode' => '100644',
- 'b_mode' => '100644',
- 'new_file' => false,
- 'renamed_file' => false,
- 'deleted_file' => false,
- 'too_large' => false
- }
+ "diff" => binary_string,
+ "new_path" => "path",
+ "old_path" => "path",
+ "a_mode" => "100644",
+ "b_mode" => "100644",
+ "new_file" => false,
+ "renamed_file" => false,
+ "deleted_file" => false,
+ "too_large" => false,
+ },
]
end
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diff has commits, but no diffs' do
+ context "when the merge request diff has commits, but no diffs" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
let(:diffs) { [] }
let(:expected_diffs) { diffs }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs have invalid content' do
+ context "when the merge request diffs have invalid content" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:expected_commits) { commits }
- let(:diffs) { ['--broken-diff'] }
+ let(:diffs) { ["--broken-diff"] }
let(:expected_diffs) { [] }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs are Rugged::Patch instances' do
+ context "when the merge request diffs are Rugged::Patch instances" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:first_commit) { project.repository.commit(merge_request_diff.head_commit_sha) }
let(:expected_commits) { commits }
let(:diffs) { rugged_diff(first_commit.sha).patches }
let(:expected_diffs) { [] }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
- context 'when the merge request diffs are Rugged::Diff::Delta instances' do
+ context "when the merge request diffs are Rugged::Diff::Delta instances" do
let(:commits) { merge_request_diff.commits.map(&:to_hash) }
let(:first_commit) { project.repository.commit(merge_request_diff.head_commit_sha) }
let(:expected_commits) { commits }
let(:diffs) { rugged_diff(first_commit.sha).deltas }
let(:expected_diffs) { [] }
- include_examples 'updated MR diff'
+ include_examples "updated MR diff"
end
def rugged_diff(commit_sha)
diff --git a/spec/lib/gitlab/background_migration/digest_column_spec.rb b/spec/lib/gitlab/background_migration/digest_column_spec.rb
index a25dcb06005..d5a53d6e00d 100644
--- a/spec/lib/gitlab/background_migration/digest_column_spec.rb
+++ b/spec/lib/gitlab/background_migration/digest_column_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::DigestColumn, :migration, schema: 20180913142237 do
let(:personal_access_tokens) { table(:personal_access_tokens) }
@@ -8,38 +8,42 @@ describe Gitlab::BackgroundMigration::DigestColumn, :migration, schema: 20180913
subject { described_class.new }
- describe '#perform' do
- context 'token is not yet hashed' do
+ describe "#perform" do
+ context "token is not yet hashed" do
before do
- users.create(id: 1, email: 'user@example.com', projects_limit: 10)
- personal_access_tokens.create!(id: 1, user_id: 1, name: 'pat-01', token: 'token-01')
+ users.create(id: 1, email: "user@example.com", projects_limit: 10)
+ personal_access_tokens.create!(id: 1, user_id: 1, name: "pat-01", token: "token-01")
end
- it 'saves token digest' do
+ it "saves token digest" do
expect { subject.perform(PersonalAccessToken, :token, :token_digest, 1, 2) }.to(
- change { PersonalAccessToken.find(1).token_digest }.from(nil).to(Gitlab::CryptoHelper.sha256('token-01')))
+ change { PersonalAccessToken.find(1).token_digest }.from(nil).to(Gitlab::CryptoHelper.sha256("token-01"))
+ )
end
- it 'erases token' do
+ it "erases token" do
expect { subject.perform(PersonalAccessToken, :token, :token_digest, 1, 2) }.to(
- change { PersonalAccessToken.find(1).read_attribute(:token) }.from('token-01').to(nil))
+ change { PersonalAccessToken.find(1).read_attribute(:token) }.from("token-01").to(nil)
+ )
end
end
- context 'token is already hashed' do
+ context "token is already hashed" do
before do
- users.create(id: 1, email: 'user@example.com', projects_limit: 10)
- personal_access_tokens.create!(id: 1, user_id: 1, name: 'pat-01', token_digest: 'token-digest-01')
+ users.create(id: 1, email: "user@example.com", projects_limit: 10)
+ personal_access_tokens.create!(id: 1, user_id: 1, name: "pat-01", token_digest: "token-digest-01")
end
- it 'does not change existing token digest' do
+ it "does not change existing token digest" do
expect { subject.perform(PersonalAccessToken, :token, :token_digest, 1, 2) }.not_to(
- change { PersonalAccessToken.find(1).token_digest })
+ change { PersonalAccessToken.find(1).token_digest }
+ )
end
- it 'leaves token empty' do
+ it "leaves token empty" do
expect { subject.perform(PersonalAccessToken, :token, :token_digest, 1, 2) }.not_to(
- change { PersonalAccessToken.find(1).read_attribute(:token) }.from(nil))
+ change { PersonalAccessToken.find(1).read_attribute(:token) }.from(nil)
+ )
end
end
end
diff --git a/spec/lib/gitlab/background_migration/encrypt_columns_spec.rb b/spec/lib/gitlab/background_migration/encrypt_columns_spec.rb
index 1d9bac79dcd..d2448505a36 100644
--- a/spec/lib/gitlab/background_migration/encrypt_columns_spec.rb
+++ b/spec/lib/gitlab/background_migration/encrypt_columns_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 20180910115836 do
let(:model) { Gitlab::BackgroundMigration::Models::EncryptColumns::WebHook }
@@ -6,24 +6,24 @@ describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 201809
let(:plaintext_attrs) do
{
- 'encrypted_token' => nil,
- 'encrypted_url' => nil,
- 'token' => 'secret',
- 'url' => 'http://example.com?access_token=secret'
+ "encrypted_token" => nil,
+ "encrypted_url" => nil,
+ "token" => "secret",
+ "url" => "http://example.com?access_token=secret",
}
end
let(:encrypted_attrs) do
{
- 'encrypted_token' => be_present,
- 'encrypted_url' => be_present,
- 'token' => nil,
- 'url' => nil
+ "encrypted_token" => be_present,
+ "encrypted_url" => be_present,
+ "token" => nil,
+ "url" => nil,
}
end
- describe '#perform' do
- it 'encrypts columns for the specified range' do
+ describe "#perform" do
+ it "encrypts columns for the specified range" do
hooks = web_hooks.create([plaintext_attrs] * 5).sort_by(&:id)
# Encrypt all but the first and last rows
@@ -40,8 +40,8 @@ describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 201809
end
end
- it 'acquires an exclusive lock for the update' do
- relation = double('relation', each: nil)
+ it "acquires an exclusive lock for the update" do
+ relation = double("relation", each: nil)
expect(model).to receive(:where) { relation }
expect(relation).to receive(:lock) { relation }
@@ -49,12 +49,12 @@ describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 201809
subject.perform(model, [:token, :url], 1, 1)
end
- it 'skips already-encrypted columns' do
+ it "skips already-encrypted columns" do
values = {
- 'encrypted_token' => 'known encrypted token',
- 'encrypted_url' => 'known encrypted url',
- 'token' => 'token',
- 'url' => 'url'
+ "encrypted_token" => "known encrypted token",
+ "encrypted_url" => "known encrypted url",
+ "token" => "token",
+ "url" => "url",
}
hook = web_hooks.create(values)
@@ -66,29 +66,29 @@ describe Gitlab::BackgroundMigration::EncryptColumns, :migration, schema: 201809
expect(hook).to have_attributes(values)
end
- it 'reloads the model column information' do
+ it "reloads the model column information" do
expect(model).to receive(:reset_column_information).and_call_original
expect(model).to receive(:define_attribute_methods).and_call_original
subject.perform(model, [:token, :url], 1, 1)
end
- it 'fails if a source column is not present' do
- columns = model.columns.reject { |c| c.name == 'url' }
+ it "fails if a source column is not present" do
+ columns = model.columns.reject { |c| c.name == "url" }
allow(model).to receive(:columns) { columns }
- expect do
+ expect {
subject.perform(model, [:token, :url], 1, 1)
- end.to raise_error(/source column: url is missing/)
+ }.to raise_error(/source column: url is missing/)
end
- it 'fails if a destination column is not present' do
- columns = model.columns.reject { |c| c.name == 'encrypted_url' }
+ it "fails if a destination column is not present" do
+ columns = model.columns.reject { |c| c.name == "encrypted_url" }
allow(model).to receive(:columns) { columns }
- expect do
+ expect {
subject.perform(model, [:token, :url], 1, 1)
- end.to raise_error(/destination column: encrypted_url is missing/)
+ }.to raise_error(/destination column: encrypted_url is missing/)
end
end
end
diff --git a/spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb b/spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb
index 9d4921968b3..c22ce8ef071 100644
--- a/spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb
+++ b/spec/lib/gitlab/background_migration/encrypt_runners_tokens_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema: 20181121111200 do
let(:settings) { table(:application_settings) }
@@ -6,30 +6,30 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
let(:projects) { table(:projects) }
let(:runners) { table(:ci_runners) }
- context 'when migrating application settings' do
+ context "when migrating application settings" do
before do
- settings.create!(id: 1, runners_registration_token: 'plain-text-token1')
+ settings.create!(id: 1, runners_registration_token: "plain-text-token1")
end
- it 'migrates runners registration tokens' do
+ it "migrates runners registration tokens" do
migrate!(:settings, 1, 1)
encrypted_token = settings.first.runners_registration_token_encrypted
decrypted_token = ::Gitlab::CryptoHelper.aes256_gcm_decrypt(encrypted_token)
- expect(decrypted_token).to eq 'plain-text-token1'
- expect(settings.first.runners_registration_token).to eq 'plain-text-token1'
+ expect(decrypted_token).to eq "plain-text-token1"
+ expect(settings.first.runners_registration_token).to eq "plain-text-token1"
end
end
- context 'when migrating namespaces' do
+ context "when migrating namespaces" do
before do
- namespaces.create!(id: 11, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token1')
- namespaces.create!(id: 12, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token2')
- namespaces.create!(id: 22, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token3')
+ namespaces.create!(id: 11, name: "gitlab", path: "gitlab-org", runners_token: "my-token1")
+ namespaces.create!(id: 12, name: "gitlab", path: "gitlab-org", runners_token: "my-token2")
+ namespaces.create!(id: 22, name: "gitlab", path: "gitlab-org", runners_token: "my-token3")
end
- it 'migrates runners registration tokens' do
+ it "migrates runners registration tokens" do
migrate!(:namespace, 11, 22)
expect(namespaces.all.reload).to all(
@@ -38,15 +38,15 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
end
- context 'when migrating projects' do
+ context "when migrating projects" do
before do
- namespaces.create!(id: 11, name: 'gitlab', path: 'gitlab-org')
- projects.create!(id: 111, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token1')
- projects.create!(id: 114, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token2')
- projects.create!(id: 116, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token3')
+ namespaces.create!(id: 11, name: "gitlab", path: "gitlab-org")
+ projects.create!(id: 111, namespace_id: 11, name: "gitlab", path: "gitlab-ce", runners_token: "my-token1")
+ projects.create!(id: 114, namespace_id: 11, name: "gitlab", path: "gitlab-ce", runners_token: "my-token2")
+ projects.create!(id: 116, namespace_id: 11, name: "gitlab", path: "gitlab-ce", runners_token: "my-token3")
end
- it 'migrates runners registration tokens' do
+ it "migrates runners registration tokens" do
migrate!(:project, 111, 116)
expect(projects.all.reload).to all(
@@ -55,14 +55,14 @@ describe Gitlab::BackgroundMigration::EncryptRunnersTokens, :migration, schema:
end
end
- context 'when migrating runners' do
+ context "when migrating runners" do
before do
- runners.create!(id: 201, runner_type: 1, token: 'plain-text-token1')
- runners.create!(id: 202, runner_type: 1, token: 'plain-text-token2')
- runners.create!(id: 203, runner_type: 1, token: 'plain-text-token3')
+ runners.create!(id: 201, runner_type: 1, token: "plain-text-token1")
+ runners.create!(id: 202, runner_type: 1, token: "plain-text-token2")
+ runners.create!(id: 203, runner_type: 1, token: "plain-text-token3")
end
- it 'migrates runners communication tokens' do
+ it "migrates runners communication tokens" do
migrate!(:runner, 201, 203)
expect(runners.all.reload).to all(
diff --git a/spec/lib/gitlab/background_migration/fix_cross_project_label_links_spec.rb b/spec/lib/gitlab/background_migration/fix_cross_project_label_links_spec.rb
index 20af63bc6c8..0804a473a2e 100644
--- a/spec/lib/gitlab/background_migration/fix_cross_project_label_links_spec.rb
+++ b/spec/lib/gitlab/background_migration/fix_cross_project_label_links_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, schema: 20180702120647 do
let(:namespaces_table) { table(:namespaces) }
@@ -8,21 +8,21 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
let(:labels_table) { table(:labels) }
let(:label_links_table) { table(:label_links) }
- let!(:group1) { namespaces_table.create(id: 10, type: 'Group', name: 'group1', path: 'group1') }
- let!(:group2) { namespaces_table.create(id: 20, type: 'Group', name: 'group2', path: 'group2') }
+ let!(:group1) { namespaces_table.create(id: 10, type: "Group", name: "group1", path: "group1") }
+ let!(:group2) { namespaces_table.create(id: 20, type: "Group", name: "group2", path: "group2") }
- let!(:project1) { projects_table.create(id: 1, name: 'project1', path: 'group1/project1', namespace_id: 10) }
- let!(:project2) { projects_table.create(id: 3, name: 'project2', path: 'group1/project2', namespace_id: 20) }
+ let!(:project1) { projects_table.create(id: 1, name: "project1", path: "group1/project1", namespace_id: 10) }
+ let!(:project2) { projects_table.create(id: 3, name: "project2", path: "group1/project2", namespace_id: 20) }
- let!(:label1) { labels_table.create(id: 1, title: 'bug', color: 'red', group_id: 10, type: 'GroupLabel') }
- let!(:label2) { labels_table.create(id: 2, title: 'bug', color: 'red', group_id: 20, type: 'GroupLabel') }
+ let!(:label1) { labels_table.create(id: 1, title: "bug", color: "red", group_id: 10, type: "GroupLabel") }
+ let!(:label2) { labels_table.create(id: 2, title: "bug", color: "red", group_id: 20, type: "GroupLabel") }
def create_merge_request(id, project_id)
merge_requests_table.create(id: id,
target_project_id: project_id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project_id,
- source_branch: 'mr name',
+ source_branch: "mr name",
title: "mr name#{id}")
end
@@ -31,14 +31,14 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
end
def create_resource(target_type, id, project_id)
- target_type == 'Issue' ? create_issue(id, project_id) : create_merge_request(id, project_id)
+ target_type == "Issue" ? create_issue(id, project_id) : create_merge_request(id, project_id)
end
- shared_examples_for 'resource with cross-project labels' do
- it 'updates only cross-project label links which exist in the local project or group' do
+ shared_examples_for "resource with cross-project labels" do
+ it "updates only cross-project label links which exist in the local project or group" do
create_resource(target_type, 1, 1)
create_resource(target_type, 2, 3)
- labels_table.create(id: 3, title: 'bug', color: 'red', project_id: 3, type: 'ProjectLabel')
+ labels_table.create(id: 3, title: "bug", color: "red", project_id: 3, type: "ProjectLabel")
link = label_links_table.create(label_id: 2, target_type: target_type, target_id: 1)
link2 = label_links_table.create(label_id: 3, target_type: target_type, target_id: 2)
@@ -48,8 +48,8 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
expect(link2.reload.label_id).to eq(3)
end
- it 'ignores cross-project label links if label color is different' do
- labels_table.create(id: 3, title: 'bug', color: 'green', group_id: 20, type: 'GroupLabel')
+ it "ignores cross-project label links if label color is different" do
+ labels_table.create(id: 3, title: "bug", color: "green", group_id: 20, type: "GroupLabel")
create_resource(target_type, 1, 1)
link = label_links_table.create(label_id: 3, target_type: target_type, target_id: 1)
@@ -58,8 +58,8 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
expect(link.reload.label_id).to eq(3)
end
- it 'ignores cross-project label links if label name is different' do
- labels_table.create(id: 3, title: 'bug1', color: 'red', group_id: 20, type: 'GroupLabel')
+ it "ignores cross-project label links if label name is different" do
+ labels_table.create(id: 3, title: "bug1", color: "red", group_id: 20, type: "GroupLabel")
create_resource(target_type, 1, 1)
link = label_links_table.create(label_id: 3, target_type: target_type, target_id: 1)
@@ -68,15 +68,15 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
expect(link.reload.label_id).to eq(3)
end
- context 'with nested group' do
+ context "with nested group" do
before do
- namespaces_table.create(id: 11, type: 'Group', name: 'subgroup1', path: 'group1/subgroup1', parent_id: 10)
- projects_table.create(id: 2, name: 'subproject1', path: 'group1/subgroup1/subproject1', namespace_id: 11)
+ namespaces_table.create(id: 11, type: "Group", name: "subgroup1", path: "group1/subgroup1", parent_id: 10)
+ projects_table.create(id: 2, name: "subproject1", path: "group1/subgroup1/subproject1", namespace_id: 11)
create_resource(target_type, 1, 2)
end
- it 'ignores label links referencing ancestor group labels', :nested_groups do
- labels_table.create(id: 4, title: 'bug', color: 'red', project_id: 2, type: 'ProjectLabel')
+ it "ignores label links referencing ancestor group labels", :nested_groups do
+ labels_table.create(id: 4, title: "bug", color: "red", project_id: 2, type: "ProjectLabel")
label_links_table.create(label_id: 4, target_type: target_type, target_id: 1)
link = label_links_table.create(label_id: 1, target_type: target_type, target_id: 1)
@@ -85,7 +85,7 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
expect(link.reload.label_id).to eq(1)
end
- it 'checks also issues and MRs in subgroups', :nested_groups do
+ it "checks also issues and MRs in subgroups", :nested_groups do
link = label_links_table.create(label_id: 2, target_type: target_type, target_id: 1)
subject.perform(1, 100)
@@ -95,15 +95,15 @@ describe Gitlab::BackgroundMigration::FixCrossProjectLabelLinks, :migration, sch
end
end
- context 'resource is Issue' do
- it_behaves_like 'resource with cross-project labels' do
- let(:target_type) { 'Issue' }
+ context "resource is Issue" do
+ it_behaves_like "resource with cross-project labels" do
+ let(:target_type) { "Issue" }
end
end
- context 'resource is Merge Request' do
- it_behaves_like 'resource with cross-project labels' do
- let(:target_type) { 'MergeRequest' }
+ context "resource is Merge Request" do
+ it_behaves_like "resource with cross-project labels" do
+ let(:target_type) { "MergeRequest" }
end
end
end
diff --git a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
index 7c7e58d6bb7..f8efc1bbac7 100644
--- a/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_build_stage_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 20180212101928 do
let(:projects) { table(:projects) }
@@ -15,29 +15,29 @@ describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 201
failed: 4,
canceled: 5,
skipped: 6,
- manual: 7
+ manual: 7,
}
end
before do
- projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce')
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
+ projects.create!(id: 123, name: "gitlab", path: "gitlab-ce")
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
jobs.create!(id: 1, commit_id: 1, project_id: 123,
- stage_idx: 2, stage: 'build', status: :success)
+ stage_idx: 2, stage: "build", status: :success)
jobs.create!(id: 2, commit_id: 1, project_id: 123,
- stage_idx: 2, stage: 'build', status: :success)
+ stage_idx: 2, stage: "build", status: :success)
jobs.create!(id: 3, commit_id: 1, project_id: 123,
- stage_idx: 1, stage: 'test', status: :failed)
+ stage_idx: 1, stage: "test", status: :failed)
jobs.create!(id: 4, commit_id: 1, project_id: 123,
- stage_idx: 1, stage: 'test', status: :success)
+ stage_idx: 1, stage: "test", status: :success)
jobs.create!(id: 5, commit_id: 1, project_id: 123,
- stage_idx: 3, stage: 'deploy', status: :pending)
+ stage_idx: 3, stage: "deploy", status: :pending)
jobs.create!(id: 6, commit_id: 1, project_id: 123,
stage_idx: 3, stage: nil, status: :pending)
end
- it 'correctly migrates builds stages' do
+ it "correctly migrates builds stages" do
expect(stages.count).to be_zero
described_class.new.perform(1, 6)
@@ -48,10 +48,10 @@ describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 201
expect(jobs.find_by(stage_id: nil).id).to eq 6
expect(stages.all.pluck(:status)).to match_array [statuses[:success],
statuses[:failed],
- statuses[:pending]]
+ statuses[:pending],]
end
- it 'recovers from unique constraint violation only twice' do
+ it "recovers from unique constraint violation only twice" do
allow(described_class::Migratable::Stage)
.to receive(:find_by).and_return(nil)
@@ -62,17 +62,17 @@ describe Gitlab::BackgroundMigration::MigrateBuildStage, :migration, schema: 201
.to raise_error ActiveRecord::RecordNotUnique
end
- context 'when invalid class can be loaded due to single table inheritance' do
+ context "when invalid class can be loaded due to single table inheritance" do
let(:commit_status) do
jobs.create!(id: 7, commit_id: 1, project_id: 123, stage_idx: 4,
- stage: 'post-deploy', status: :failed)
+ stage: "post-deploy", status: :failed)
end
before do
- commit_status.update_column(:type, 'SomeClass')
+ commit_status.update_column(:type, "SomeClass")
end
- it 'does ignore single table inheritance type' do
+ it "does ignore single table inheritance type" do
expect { described_class.new.perform(1, 7) }.not_to raise_error
expect(jobs.find(7)).to have_attributes(stage_id: (a_value > 0))
end
diff --git a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
index 188969951a6..14622768d3e 100644
--- a/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_events_to_push_event_payloads_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event, :migration, schema: 20170608152748 do
- describe '#commit_title' do
- it 'returns nil when there are no commits' do
+ describe "#commit_title" do
+ it "returns nil when there are no commits" do
expect(described_class.new.commit_title).to be_nil
end
- it 'returns nil when there are commits without commit messages' do
+ it "returns nil when there are commits without commit messages" do
event = described_class.new
- allow(event).to receive(:commits).and_return([{ id: '123' }])
+ allow(event).to receive(:commits).and_return([{id: "123"}])
expect(event.commit_title).to be_nil
end
- it 'returns the commit message when it is less than 70 characters long' do
+ it "returns the commit message when it is less than 70 characters long" do
event = described_class.new
- allow(event).to receive(:commits).and_return([{ message: 'Hello world' }])
+ allow(event).to receive(:commits).and_return([{message: "Hello world"}])
- expect(event.commit_title).to eq('Hello world')
+ expect(event.commit_title).to eq("Hello world")
end
- it 'returns the first line of a commit message if multiple lines are present' do
+ it "returns the first line of a commit message if multiple lines are present" do
event = described_class.new
- allow(event).to receive(:commits).and_return([{ message: "Hello\n\nworld" }])
+ allow(event).to receive(:commits).and_return([{message: "Hello\n\nworld"}])
- expect(event.commit_title).to eq('Hello')
+ expect(event.commit_title).to eq("Hello")
end
- it 'truncates the commit to 70 characters when it is too long' do
+ it "truncates the commit to 70 characters when it is too long" do
event = described_class.new
- allow(event).to receive(:commits).and_return([{ message: 'a' * 100 }])
+ allow(event).to receive(:commits).and_return([{message: "a" * 100}])
- expect(event.commit_title).to eq(('a' * 67) + '...')
+ expect(event.commit_title).to eq(("a" * 67) + "...")
end
end
- describe '#commit_from_sha' do
- it 'returns nil when pushing to a new ref' do
+ describe "#commit_from_sha" do
+ it "returns nil when pushing to a new ref" do
event = described_class.new
allow(event).to receive(:create?).and_return(true)
@@ -49,18 +49,18 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event, :
expect(event.commit_from_sha).to be_nil
end
- it 'returns the ID of the first commit when pushing to an existing ref' do
+ it "returns the ID of the first commit when pushing to an existing ref" do
event = described_class.new
allow(event).to receive(:create?).and_return(false)
- allow(event).to receive(:data).and_return(before: '123')
+ allow(event).to receive(:data).and_return(before: "123")
- expect(event.commit_from_sha).to eq('123')
+ expect(event.commit_from_sha).to eq("123")
end
end
- describe '#commit_to_sha' do
- it 'returns nil when removing an existing ref' do
+ describe "#commit_to_sha" do
+ it "returns nil when removing an existing ref" do
event = described_class.new
allow(event).to receive(:remove?).and_return(true)
@@ -68,125 +68,125 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event, :
expect(event.commit_to_sha).to be_nil
end
- it 'returns the ID of the last commit when pushing to an existing ref' do
+ it "returns the ID of the last commit when pushing to an existing ref" do
event = described_class.new
allow(event).to receive(:remove?).and_return(false)
- allow(event).to receive(:data).and_return(after: '123')
+ allow(event).to receive(:data).and_return(after: "123")
- expect(event.commit_to_sha).to eq('123')
+ expect(event.commit_to_sha).to eq("123")
end
end
- describe '#data' do
- it 'returns the deserialized data' do
- event = described_class.new(data: { before: '123' })
+ describe "#data" do
+ it "returns the deserialized data" do
+ event = described_class.new(data: {before: "123"})
- expect(event.data).to eq(before: '123')
+ expect(event.data).to eq(before: "123")
end
- it 'returns an empty hash when no data is present' do
+ it "returns an empty hash when no data is present" do
event = described_class.new
expect(event.data).to eq({})
end
end
- describe '#commits' do
- it 'returns an Array of commits' do
- event = described_class.new(data: { commits: [{ id: '123' }] })
+ describe "#commits" do
+ it "returns an Array of commits" do
+ event = described_class.new(data: {commits: [{id: "123"}]})
- expect(event.commits).to eq([{ id: '123' }])
+ expect(event.commits).to eq([{id: "123"}])
end
- it 'returns an empty array when no data is present' do
+ it "returns an empty array when no data is present" do
event = described_class.new
expect(event.commits).to eq([])
end
end
- describe '#commit_count' do
- it 'returns the number of commits' do
- event = described_class.new(data: { total_commits_count: 2 })
+ describe "#commit_count" do
+ it "returns the number of commits" do
+ event = described_class.new(data: {total_commits_count: 2})
expect(event.commit_count).to eq(2)
end
- it 'returns 0 when no data is present' do
+ it "returns 0 when no data is present" do
event = described_class.new
expect(event.commit_count).to eq(0)
end
end
- describe '#ref' do
- it 'returns the name of the ref' do
- event = described_class.new(data: { ref: 'refs/heads/master' })
+ describe "#ref" do
+ it "returns the name of the ref" do
+ event = described_class.new(data: {ref: "refs/heads/master"})
- expect(event.ref).to eq('refs/heads/master')
+ expect(event.ref).to eq("refs/heads/master")
end
end
- describe '#trimmed_ref_name' do
- it 'returns the trimmed ref name for a branch' do
- event = described_class.new(data: { ref: 'refs/heads/master' })
+ describe "#trimmed_ref_name" do
+ it "returns the trimmed ref name for a branch" do
+ event = described_class.new(data: {ref: "refs/heads/master"})
- expect(event.trimmed_ref_name).to eq('master')
+ expect(event.trimmed_ref_name).to eq("master")
end
- it 'returns the trimmed ref name for a tag' do
- event = described_class.new(data: { ref: 'refs/tags/v1.2' })
+ it "returns the trimmed ref name for a tag" do
+ event = described_class.new(data: {ref: "refs/tags/v1.2"})
- expect(event.trimmed_ref_name).to eq('v1.2')
+ expect(event.trimmed_ref_name).to eq("v1.2")
end
end
- describe '#create?' do
- it 'returns true when creating a new ref' do
- event = described_class.new(data: { before: described_class::BLANK_REF })
+ describe "#create?" do
+ it "returns true when creating a new ref" do
+ event = described_class.new(data: {before: described_class::BLANK_REF})
expect(event.create?).to eq(true)
end
- it 'returns false when pushing to an existing ref' do
- event = described_class.new(data: { before: '123' })
+ it "returns false when pushing to an existing ref" do
+ event = described_class.new(data: {before: "123"})
expect(event.create?).to eq(false)
end
end
- describe '#remove?' do
- it 'returns true when removing an existing ref' do
- event = described_class.new(data: { after: described_class::BLANK_REF })
+ describe "#remove?" do
+ it "returns true when removing an existing ref" do
+ event = described_class.new(data: {after: described_class::BLANK_REF})
expect(event.remove?).to eq(true)
end
- it 'returns false when pushing to an existing ref' do
- event = described_class.new(data: { after: '123' })
+ it "returns false when pushing to an existing ref" do
+ event = described_class.new(data: {after: "123"})
expect(event.remove?).to eq(false)
end
end
- describe '#push_action' do
+ describe "#push_action" do
let(:event) { described_class.new }
- it 'returns :created when creating a new ref' do
+ it "returns :created when creating a new ref" do
allow(event).to receive(:create?).and_return(true)
expect(event.push_action).to eq(:created)
end
- it 'returns :removed when removing an existing ref' do
+ it "returns :removed when removing an existing ref" do
allow(event).to receive(:create?).and_return(false)
allow(event).to receive(:remove?).and_return(true)
expect(event.push_action).to eq(:removed)
end
- it 'returns :pushed when pushing to an existing ref' do
+ it "returns :pushed when pushing to an existing ref" do
allow(event).to receive(:create?).and_return(false)
allow(event).to receive(:remove?).and_return(false)
@@ -194,17 +194,17 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads::Event, :
end
end
- describe '#ref_type' do
+ describe "#ref_type" do
let(:event) { described_class.new }
- it 'returns :tag for a tag' do
- allow(event).to receive(:ref).and_return('refs/tags/1.2')
+ it "returns :tag for a tag" do
+ allow(event).to receive(:ref).and_return("refs/tags/1.2")
expect(event.ref_type).to eq(:tag)
end
- it 'returns :branch for a branch' do
- allow(event).to receive(:ref).and_return('refs/heads/1.2')
+ it "returns :branch for a branch" do
+ allow(event).to receive(:ref).and_return("refs/heads/1.2")
expect(event.ref_type).to eq(:branch)
end
@@ -218,7 +218,7 @@ end
describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migration, schema: 20170825154015 do
let(:user_class) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'users'
+ self.table_name = "users"
end
end
@@ -243,8 +243,8 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
)
end
- describe '#perform' do
- it 'returns if data should not be migrated' do
+ describe "#perform" do
+ it "returns if data should not be migrated" do
allow(migration).to receive(:migrate?).and_return(false)
expect(migration).not_to receive(:find_events)
@@ -252,9 +252,9 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
migration.perform(1, 10)
end
- it 'migrates the range of events if data is to be migrated' do
- event1 = create_push_event(project, author, { commits: [] })
- event2 = create_push_event(project, author, { commits: [] })
+ it "migrates the range of events if data is to be migrated" do
+ event1 = create_push_event(project, author, {commits: []})
+ event2 = create_push_event(project, author, {commits: []})
allow(migration).to receive(:migrate?).and_return(true)
@@ -264,8 +264,8 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#process_event' do
- it 'processes a regular event' do
+ describe "#process_event" do
+ it "processes a regular event" do
event = double(:event, push_event?: false)
expect(migration).to receive(:replicate_event)
@@ -274,7 +274,7 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
migration.process_event(event)
end
- it 'processes a push event' do
+ it "processes a push event" do
event = double(:event, push_event?: true)
expect(migration).to receive(:replicate_event)
@@ -283,11 +283,11 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
migration.process_event(event)
end
- it 'handles an error gracefully' do
- event1 = create_push_event(project, author, { commits: [] })
+ it "handles an error gracefully" do
+ event1 = create_push_event(project, author, {commits: []})
expect(migration).to receive(:replicate_event).and_call_original
- expect(migration).to receive(:create_push_event_payload).and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ expect(migration).to receive(:create_push_event_payload).and_raise(ActiveRecord::InvalidForeignKey, "invalid foreign key")
migration.process_event(event1)
@@ -295,13 +295,13 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#replicate_event' do
+ describe "#replicate_event" do
it 'replicates the event to the "events_for_migration" table' do
event = create_push_event(
project,
author,
- data: { commits: [] },
- title: 'bla'
+ data: {commits: []},
+ title: "bla"
)
attributes = event
@@ -315,14 +315,14 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#create_push_event_payload' do
+ describe "#create_push_event_payload" do
let(:push_data) do
{
commits: [],
- ref: 'refs/heads/master',
- before: '156e0e9adc587a383a7eeb5b21ddecb9044768a8',
- after: '0' * 40,
- total_commits_count: 1
+ ref: "refs/heads/master",
+ before: "156e0e9adc587a383a7eeb5b21ddecb9044768a8",
+ after: "0" * 40,
+ total_commits_count: 1,
}
end
@@ -337,14 +337,14 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
migration.replicate_event(event)
end
- it 'creates a push event payload for an event' do
+ it "creates a push event payload for an event" do
payload = migration.create_push_event_payload(event)
expect(PushEventPayload.count).to eq(1)
expect(payload.valid?).to eq(true)
end
- it 'does not create push event payloads for removed events' do
+ it "does not create push event payloads for removed events" do
allow(event).to receive(:id).and_return(-1)
expect { migration.create_push_event_payload(event) }.to raise_error(ActiveRecord::InvalidForeignKey)
@@ -352,7 +352,7 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
expect(PushEventPayload.count).to eq(0)
end
- it 'encodes and decodes the commit IDs from and to binary data' do
+ it "encodes and decodes the commit IDs from and to binary data" do
payload = migration.create_push_event_payload(event)
packed = migration.pack(push_data[:before])
@@ -361,11 +361,11 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#find_events' do
- it 'returns the events for the given ID range' do
- event1 = create_push_event(project, author, { commits: [] })
- event2 = create_push_event(project, author, { commits: [] })
- event3 = create_push_event(project, author, { commits: [] })
+ describe "#find_events" do
+ it "returns the events for the given ID range" do
+ event1 = create_push_event(project, author, {commits: []})
+ event2 = create_push_event(project, author, {commits: []})
+ event3 = create_push_event(project, author, {commits: []})
events = migration.find_events(event1.id, event2.id)
expect(events.length).to eq(2)
@@ -373,8 +373,8 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#migrate?' do
- it 'returns true when data should be migrated' do
+ describe "#migrate?" do
+ it "returns true when data should be migrated" do
allow(described_class::Event)
.to receive(:table_exists?).and_return(true)
@@ -418,14 +418,14 @@ describe Gitlab::BackgroundMigration::MigrateEventsToPushEventPayloads, :migrati
end
end
- describe '#pack' do
- it 'packs a SHA1 into a 20 byte binary string' do
- packed = migration.pack('156e0e9adc587a383a7eeb5b21ddecb9044768a8')
+ describe "#pack" do
+ it "packs a SHA1 into a 20 byte binary string" do
+ packed = migration.pack("156e0e9adc587a383a7eeb5b21ddecb9044768a8")
expect(packed.bytesize).to eq(20)
end
- it 'returns nil if the input value is nil' do
+ it "returns nil if the input value is nil" do
expect(migration.pack(nil)).to be_nil
end
end
diff --git a/spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb b/spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb
index 2d1505dacfe..8f6ab3a5f95 100644
--- a/spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_legacy_artifacts_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, :migration, schema: 20180816161409 do
let(:namespaces) { table(:namespaces) }
@@ -9,12 +9,12 @@ describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, :migration, schema
subject { described_class.new.perform(*range) }
- context 'when a pipeline exists' do
- let!(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
- let!(:project) { projects.create!(name: 'gitlab', path: 'gitlab-ce', namespace_id: namespace.id) }
- let!(:pipeline) { pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a') }
+ context "when a pipeline exists" do
+ let!(:namespace) { namespaces.create!(name: "gitlab", path: "gitlab-org") }
+ let!(:project) { projects.create!(name: "gitlab", path: "gitlab-ce", namespace_id: namespace.id) }
+ let!(:pipeline) { pipelines.create!(project_id: project.id, ref: "master", sha: "adf43c3a") }
- context 'when a legacy artifacts exists' do
+ context "when a legacy artifacts exists" do
let(:artifacts_expire_at) { 1.day.since.to_s }
let(:file_store) { ::ObjectStorage::Store::REMOTE }
@@ -24,130 +24,131 @@ describe Gitlab::BackgroundMigration::MigrateLegacyArtifacts, :migration, schema
project_id: project.id,
status: :success,
**artifacts_archive_attributes,
- **artifacts_metadata_attributes)
+ **artifacts_metadata_attributes
+ )
end
let(:artifacts_archive_attributes) do
{
- artifacts_file: 'archive.zip',
+ artifacts_file: "archive.zip",
artifacts_file_store: file_store,
artifacts_size: 123,
- artifacts_expire_at: artifacts_expire_at
+ artifacts_expire_at: artifacts_expire_at,
}
end
let(:artifacts_metadata_attributes) do
{
- artifacts_metadata: 'metadata.gz',
- artifacts_metadata_store: file_store
+ artifacts_metadata: "metadata.gz",
+ artifacts_metadata_store: file_store,
}
end
- it 'has legacy artifacts' do
- expect(jobs.pluck('artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at')).to eq([artifacts_archive_attributes.values])
- expect(jobs.pluck('artifacts_metadata, artifacts_metadata_store')).to eq([artifacts_metadata_attributes.values])
+ it "has legacy artifacts" do
+ expect(jobs.pluck("artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at")).to eq([artifacts_archive_attributes.values])
+ expect(jobs.pluck("artifacts_metadata, artifacts_metadata_store")).to eq([artifacts_metadata_attributes.values])
end
- it 'does not have new artifacts yet' do
+ it "does not have new artifacts yet" do
expect(job_artifacts.count).to be_zero
end
- context 'when the record exists inside of the range of a background migration' do
+ context "when the record exists inside of the range of a background migration" do
let(:range) { [job.id, job.id] }
- it 'migrates a legacy artifact to ci_job_artifacts table' do
+ it "migrates a legacy artifact to ci_job_artifacts table" do
expect { subject }.to change { job_artifacts.count }.by(2)
- expect(job_artifacts.order(:id).pluck('project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location'))
+ expect(job_artifacts.order(:id).pluck("project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location"))
.to eq([[project.id,
job.id,
described_class::ARCHIVE_FILE_TYPE,
file_store,
artifacts_archive_attributes[:artifacts_size],
artifacts_expire_at,
- 'archive.zip',
+ "archive.zip",
nil,
- described_class::LEGACY_PATH_FILE_LOCATION],
+ described_class::LEGACY_PATH_FILE_LOCATION,],
[project.id,
job.id,
described_class::METADATA_FILE_TYPE,
file_store,
nil,
artifacts_expire_at,
- 'metadata.gz',
+ "metadata.gz",
nil,
- described_class::LEGACY_PATH_FILE_LOCATION]])
+ described_class::LEGACY_PATH_FILE_LOCATION,],])
- expect(jobs.pluck('artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at')).to eq([[nil, nil, nil, artifacts_expire_at]])
- expect(jobs.pluck('artifacts_metadata, artifacts_metadata_store')).to eq([[nil, nil]])
+ expect(jobs.pluck("artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at")).to eq([[nil, nil, nil, artifacts_expire_at]])
+ expect(jobs.pluck("artifacts_metadata, artifacts_metadata_store")).to eq([[nil, nil]])
end
- context 'when file_store is nil' do
+ context "when file_store is nil" do
let(:file_store) { nil }
- it 'has nullified file_store in all legacy artifacts' do
- expect(jobs.pluck('artifacts_file_store, artifacts_metadata_store')).to eq([[nil, nil]])
+ it "has nullified file_store in all legacy artifacts" do
+ expect(jobs.pluck("artifacts_file_store, artifacts_metadata_store")).to eq([[nil, nil]])
end
- it 'fills file_store by the value of local file store' do
+ it "fills file_store by the value of local file store" do
subject
- expect(job_artifacts.pluck('file_store')).to all(eq(::ObjectStorage::Store::LOCAL))
+ expect(job_artifacts.pluck("file_store")).to all(eq(::ObjectStorage::Store::LOCAL))
end
end
- context 'when new artifacts has already existed' do
- context 'when only archive.zip existed' do
+ context "when new artifacts has already existed" do
+ context "when only archive.zip existed" do
before do
- job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::ARCHIVE_FILE_TYPE, size: 999, file: 'archive.zip')
+ job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::ARCHIVE_FILE_TYPE, size: 999, file: "archive.zip")
end
- it 'had archive.zip already' do
+ it "had archive.zip already" do
expect(job_artifacts.exists?(job_id: job.id, file_type: described_class::ARCHIVE_FILE_TYPE)).to be_truthy
end
- it 'migrates metadata' do
+ it "migrates metadata" do
expect { subject }.to change { job_artifacts.count }.by(1)
expect(job_artifacts.exists?(job_id: job.id, file_type: described_class::METADATA_FILE_TYPE)).to be_truthy
end
end
- context 'when both archive and metadata existed' do
+ context "when both archive and metadata existed" do
before do
- job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::ARCHIVE_FILE_TYPE, size: 999, file: 'archive.zip')
- job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::METADATA_FILE_TYPE, size: 999, file: 'metadata.zip')
+ job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::ARCHIVE_FILE_TYPE, size: 999, file: "archive.zip")
+ job_artifacts.create!(project_id: project.id, job_id: job.id, file_type: described_class::METADATA_FILE_TYPE, size: 999, file: "metadata.zip")
end
- it 'does not migrate' do
+ it "does not migrate" do
expect { subject }.not_to change { job_artifacts.count }
end
end
end
end
- context 'when the record exists outside of the range of a background migration' do
+ context "when the record exists outside of the range of a background migration" do
let(:range) { [job.id + 1, job.id + 1] }
- it 'does not migrate' do
+ it "does not migrate" do
expect { subject }.not_to change { job_artifacts.count }
end
end
end
- context 'when the job does not have legacy artifacts' do
+ context "when the job does not have legacy artifacts" do
let!(:job) { jobs.create!(commit_id: pipeline.id, project_id: project.id, status: :success) }
- it 'does not have the legacy artifacts in database' do
+ it "does not have the legacy artifacts in database" do
expect(jobs.count).to eq(1)
- expect(jobs.pluck('artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at')).to eq([[nil, nil, nil, nil]])
- expect(jobs.pluck('artifacts_metadata, artifacts_metadata_store')).to eq([[nil, nil]])
+ expect(jobs.pluck("artifacts_file, artifacts_file_store, artifacts_size, artifacts_expire_at")).to eq([[nil, nil, nil, nil]])
+ expect(jobs.pluck("artifacts_metadata, artifacts_metadata_store")).to eq([[nil, nil]])
end
- context 'when the record exists inside of the range of a background migration' do
+ context "when the record exists inside of the range of a background migration" do
let(:range) { [job.id, job.id] }
- it 'does not migrate' do
+ it "does not migrate" do
expect { subject }.not_to change { job_artifacts.count }
end
end
diff --git a/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
index f8107dd40b9..c5ae59e0969 100644
--- a/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_stage_index_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 20180420080616 do
let(:namespaces) { table(:namespaces) }
@@ -8,12 +8,12 @@ describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 201
let(:jobs) { table(:ci_builds) }
before do
- namespaces.create(id: 10, name: 'gitlab-org', path: 'gitlab-org')
- projects.create!(id: 11, namespace_id: 10, name: 'gitlab', path: 'gitlab')
- pipelines.create!(id: 12, project_id: 11, ref: 'master', sha: 'adf43c3a')
+ namespaces.create(id: 10, name: "gitlab-org", path: "gitlab-org")
+ projects.create!(id: 11, namespace_id: 10, name: "gitlab", path: "gitlab")
+ pipelines.create!(id: 12, project_id: 11, ref: "master", sha: "adf43c3a")
- stages.create(id: 100, project_id: 11, pipeline_id: 12, name: 'build')
- stages.create(id: 101, project_id: 11, pipeline_id: 12, name: 'test')
+ stages.create(id: 100, project_id: 11, pipeline_id: 12, name: "build")
+ stages.create(id: 101, project_id: 11, pipeline_id: 12, name: "test")
jobs.create!(id: 121, commit_id: 12, project_id: 11,
stage_idx: 2, stage_id: 100)
@@ -25,7 +25,7 @@ describe Gitlab::BackgroundMigration::MigrateStageIndex, :migration, schema: 201
stage_idx: 3, stage_id: 101)
end
- it 'correctly migrates stages indices' do
+ it "correctly migrates stages indices" do
expect(stages.all.pluck(:position)).to all(be_nil)
described_class.new.perform(100, 101)
diff --git a/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb b/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb
index 89b56906ed0..c03d41b524c 100644
--- a/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_stage_status_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20170711145320 do
let(:projects) { table(:projects) }
@@ -17,25 +17,25 @@ describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20
failed: 4,
canceled: 5,
skipped: 6,
- manual: 7
+ manual: 7,
}
end
before do
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1')
- pipelines.create!(id: 1, project_id: 1, ref: 'master', sha: 'adf43c3a')
- stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: 'test', status: nil)
- stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: 'deploy', status: nil)
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1")
+ pipelines.create!(id: 1, project_id: 1, ref: "master", sha: "adf43c3a")
+ stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: "test", status: nil)
+ stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: "deploy", status: nil)
end
- context 'when stage status is known' do
+ context "when stage status is known" do
before do
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'success')
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'running')
- create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'failed')
+ create_job(project: 1, pipeline: 1, stage: "test", status: "success")
+ create_job(project: 1, pipeline: 1, stage: "test", status: "running")
+ create_job(project: 1, pipeline: 1, stage: "deploy", status: "failed")
end
- it 'sets a correct stage status' do
+ it "sets a correct stage status" do
described_class.new.perform(1, 2)
expect(stages.first.status).to eq statuses[:running]
@@ -43,8 +43,8 @@ describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20
end
end
- context 'when stage status is not known' do
- it 'sets a skipped stage status' do
+ context "when stage status is not known" do
+ it "sets a skipped stage status" do
described_class.new.perform(1, 2)
expect(stages.first.status).to eq statuses[:skipped]
@@ -52,14 +52,14 @@ describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20
end
end
- context 'when stage status includes status of a retried job' do
+ context "when stage status includes status of a retried job" do
before do
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'canceled')
- create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'failed', retried: true)
- create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'success')
+ create_job(project: 1, pipeline: 1, stage: "test", status: "canceled")
+ create_job(project: 1, pipeline: 1, stage: "deploy", status: "failed", retried: true)
+ create_job(project: 1, pipeline: 1, stage: "deploy", status: "success")
end
- it 'sets a correct stage status' do
+ it "sets a correct stage status" do
described_class.new.perform(1, 2)
expect(stages.first.status).to eq statuses[:canceled]
@@ -67,14 +67,14 @@ describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20
end
end
- context 'when some job in the stage is blocked / manual' do
+ context "when some job in the stage is blocked / manual" do
before do
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'failed')
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'manual')
- create_job(project: 1, pipeline: 1, stage: 'deploy', status: 'success', when: 'manual')
+ create_job(project: 1, pipeline: 1, stage: "test", status: "failed")
+ create_job(project: 1, pipeline: 1, stage: "test", status: "manual")
+ create_job(project: 1, pipeline: 1, stage: "deploy", status: "success", when: "manual")
end
- it 'sets a correct stage status' do
+ it "sets a correct stage status" do
described_class.new.perform(1, 2)
expect(stages.first.status).to eq statuses[:manual]
@@ -83,7 +83,7 @@ describe Gitlab::BackgroundMigration::MigrateStageStatus, :migration, schema: 20
end
def create_job(project:, pipeline:, stage:, status:, **opts)
- stages = { test: 1, build: 2, deploy: 3 }
+ stages = {test: 1, build: 2, deploy: 3}
jobs.create!(project_id: project, commit_id: pipeline,
stage_idx: stages[stage.to_sym], stage: stage,
diff --git a/spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb b/spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb
index ea8bdd48e72..c031c390fdf 100644
--- a/spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb
+++ b/spec/lib/gitlab/background_migration/migrate_system_uploads_to_new_folder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::MigrateSystemUploadsToNewFolder, :delete do
@@ -8,13 +8,13 @@ describe Gitlab::BackgroundMigration::MigrateSystemUploadsToNewFolder, :delete d
allow(migration).to receive(:logger).and_return(Logger.new(nil))
end
- describe '#perform' do
- it 'renames the path of system-uploads' do
- upload = create(:upload, model: create(:project), path: 'uploads/system/project/avatar.jpg')
+ describe "#perform" do
+ it "renames the path of system-uploads" do
+ upload = create(:upload, model: create(:project), path: "uploads/system/project/avatar.jpg")
- migration.perform('uploads/system/', 'uploads/-/system/')
+ migration.perform("uploads/system/", "uploads/-/system/")
- expect(upload.reload.path).to eq('uploads/-/system/project/avatar.jpg')
+ expect(upload.reload.path).to eq("uploads/-/system/project/avatar.jpg")
end
end
end
diff --git a/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb b/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb
index 593486fc56c..a00bfa9926c 100644
--- a/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb
+++ b/spec/lib/gitlab/background_migration/move_personal_snippet_files_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::MovePersonalSnippetFiles do
- let(:test_dir) { File.join(Rails.root, 'tmp', 'tests', 'move_snippet_files_test') }
- let(:old_uploads_dir) { File.join('uploads', 'system', 'personal_snippet') }
- let(:new_uploads_dir) { File.join('uploads', '-', 'system', 'personal_snippet') }
+ let(:test_dir) { File.join(Rails.root, "tmp", "tests", "move_snippet_files_test") }
+ let(:old_uploads_dir) { File.join("uploads", "system", "personal_snippet") }
+ let(:new_uploads_dir) { File.join("uploads", "-", "system", "personal_snippet") }
let(:snippet) do
snippet = create(:personal_snippet)
create_upload_for_snippet(snippet)
@@ -18,17 +18,17 @@ describe Gitlab::BackgroundMigration::MovePersonalSnippetFiles do
allow(migration).to receive(:base_directory) { test_dir }
end
- describe '#perform' do
- it 'moves the file on the disk' do
- expected_path = File.join(test_dir, new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", 'upload.txt')
+ describe "#perform" do
+ it "moves the file on the disk" do
+ expected_path = File.join(test_dir, new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", "upload.txt")
migration.perform(old_uploads_dir, new_uploads_dir)
expect(File.exist?(expected_path)).to be_truthy
end
- it 'updates the markdown of the snippet' do
- expected_path = File.join(new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", 'upload.txt')
+ it "updates the markdown of the snippet" do
+ expected_path = File.join(new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", "upload.txt")
expected_markdown = "[an upload](#{expected_path})"
migration.perform(old_uploads_dir, new_uploads_dir)
@@ -36,8 +36,8 @@ describe Gitlab::BackgroundMigration::MovePersonalSnippetFiles do
expect(snippet.reload.description).to eq(expected_markdown)
end
- it 'updates the markdown of notes' do
- expected_path = File.join(new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", 'upload.txt')
+ it "updates the markdown of notes" do
+ expected_path = File.join(new_uploads_dir, snippet.id.to_s, "secret#{snippet.id}", "upload.txt")
expected_markdown = "with [an upload](#{expected_path})"
note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown_linking_file(snippet)}")
@@ -61,7 +61,7 @@ describe Gitlab::BackgroundMigration::MovePersonalSnippetFiles do
def path_for_file_in_snippet(snippet)
secret = "secret#{snippet.id}"
- filename = 'upload.txt'
+ filename = "upload.txt"
File.join(secret, filename)
end
diff --git a/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb b/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb
index dfbf1bb681a..7e6a1a91b40 100644
--- a/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb
+++ b/spec/lib/gitlab/background_migration/normalize_ldap_extern_uids_range_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::NormalizeLdapExternUidsRange, :migration, schema: 20170921101004 do
let!(:identities) { table(:identities) }
@@ -6,17 +6,17 @@ describe Gitlab::BackgroundMigration::NormalizeLdapExternUidsRange, :migration,
before do
# LDAP identities
(1..4).each do |i|
- identities.create!(id: i, provider: 'ldapmain', extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i)
+ identities.create!(id: i, provider: "ldapmain", extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i)
end
# Non-LDAP identity
- identities.create!(id: 5, provider: 'foo', extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5)
+ identities.create!(id: 5, provider: "foo", extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5)
# Another LDAP identity
- identities.create!(id: 6, provider: 'ldapmain', extern_uid: " uid = foo 6, ou = People, dc = example, dc = com ", user_id: 6)
+ identities.create!(id: 6, provider: "ldapmain", extern_uid: " uid = foo 6, ou = People, dc = example, dc = com ", user_id: 6)
end
- it 'normalizes the LDAP identities in the range' do
+ it "normalizes the LDAP identities in the range" do
described_class.new.perform(1, 3)
expect(identities.find(1).extern_uid).to eq("uid=foo 1,ou=people,dc=example,dc=com")
expect(identities.find(2).extern_uid).to eq("uid=foo 2,ou=people,dc=example,dc=com")
diff --git a/spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb b/spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb
index 812e0cc6947..7ea2506c781 100644
--- a/spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_cluster_kubernetes_namespace_table_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :migration, schema: 20181022173835 do
include MigrationHelpers::ClusterHelpers
@@ -18,8 +18,8 @@ describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :
create_cluster_project_list(10)
end
- shared_examples 'consistent kubernetes namespace attributes' do
- it 'should populate namespace and service account information' do
+ shared_examples "consistent kubernetes namespace attributes" do
+ it "should populate namespace and service account information" do
migration.perform
clusters_with_namespace.each do |cluster|
@@ -38,33 +38,33 @@ describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :
end
end
- context 'when no Clusters::Project has a Clusters::KubernetesNamespace' do
+ context "when no Clusters::Project has a Clusters::KubernetesNamespace" do
let(:cluster_projects) { cluster_projects_table.all }
- it 'should create a Clusters::KubernetesNamespace per Clusters::Project' do
- expect do
+ it "should create a Clusters::KubernetesNamespace per Clusters::Project" do
+ expect {
migration.perform
- end.to change(Clusters::KubernetesNamespace, :count).by(cluster_projects_table.count)
+ }.to change(Clusters::KubernetesNamespace, :count).by(cluster_projects_table.count)
end
- it_behaves_like 'consistent kubernetes namespace attributes' do
+ it_behaves_like "consistent kubernetes namespace attributes" do
let(:clusters_with_namespace) { clusters_table.all }
end
end
- context 'when every Clusters::Project has Clusters::KubernetesNamespace' do
+ context "when every Clusters::Project has Clusters::KubernetesNamespace" do
before do
create_kubernetes_namespace(clusters_table.all)
end
- it 'should not create any Clusters::KubernetesNamespace' do
- expect do
+ it "should not create any Clusters::KubernetesNamespace" do
+ expect {
migration.perform
- end.not_to change(Clusters::KubernetesNamespace, :count)
+ }.not_to change(Clusters::KubernetesNamespace, :count)
end
end
- context 'when only some Clusters::Project have Clusters::KubernetesNamespace related' do
+ context "when only some Clusters::Project have Clusters::KubernetesNamespace related" do
let(:with_kubernetes_namespace) { clusters_table.first(6) }
let(:with_no_kubernetes_namespace) { clusters_table.last(4) }
@@ -72,13 +72,13 @@ describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :
create_kubernetes_namespace(with_kubernetes_namespace)
end
- it 'creates limited number of Clusters::KubernetesNamespace' do
- expect do
+ it "creates limited number of Clusters::KubernetesNamespace" do
+ expect {
migration.perform
- end.to change(Clusters::KubernetesNamespace, :count).by(with_no_kubernetes_namespace.count)
+ }.to change(Clusters::KubernetesNamespace, :count).by(with_no_kubernetes_namespace.count)
end
- it 'should not modify clusters with Clusters::KubernetesNamespace' do
+ it "should not modify clusters with Clusters::KubernetesNamespace" do
migration.perform
with_kubernetes_namespace.each do |cluster|
@@ -87,7 +87,7 @@ describe Gitlab::BackgroundMigration::PopulateClusterKubernetesNamespaceTable, :
end
end
- it_behaves_like 'consistent kubernetes namespace attributes' do
+ it_behaves_like "consistent kubernetes namespace attributes" do
let(:clusters_with_namespace) { with_no_kubernetes_namespace }
end
end
diff --git a/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb b/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
index 3e009fed0f1..f859ef8082d 100644
--- a/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_external_pipeline_source_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::PopulateExternalPipelineSource, :migration, schema: 20180916011959 do
@@ -21,49 +21,49 @@ describe Gitlab::BackgroundMigration::PopulateExternalPipelineSource, :migration
subject { migration.perform(pipelines.min, pipelines.max) }
- shared_examples 'no changes' do
- it 'does not change the pipeline source' do
+ shared_examples "no changes" do
+ it "does not change the pipeline source" do
expect { subject }.not_to change { unknown_pipeline.reload.source }
end
end
- context 'when unknown pipeline is external' do
+ context "when unknown pipeline is external" do
before do
create(:generic_commit_status, pipeline: unknown_pipeline)
end
- it 'populates the pipeline source' do
+ it "populates the pipeline source" do
subject
- expect(unknown_pipeline.reload.source).to eq('external')
+ expect(unknown_pipeline.reload.source).to eq("external")
end
- it 'can be repeated without effect' do
+ it "can be repeated without effect" do
subject
expect { subject }.not_to change { unknown_pipeline.reload.source }
end
end
- context 'when unknown pipeline has just a build' do
+ context "when unknown pipeline has just a build" do
before do
create(:ci_build, pipeline: unknown_pipeline)
end
- it_behaves_like 'no changes'
+ it_behaves_like "no changes"
end
- context 'when unknown pipeline has no statuses' do
- it_behaves_like 'no changes'
+ context "when unknown pipeline has no statuses" do
+ it_behaves_like "no changes"
end
- context 'when unknown pipeline has a build and a status' do
+ context "when unknown pipeline has a build and a status" do
before do
create(:generic_commit_status, pipeline: unknown_pipeline)
create(:ci_build, pipeline: unknown_pipeline)
end
- it_behaves_like 'no changes'
+ it_behaves_like "no changes"
end
end
# rubocop:enable RSpec/FactoriesInMigrationSpecs
diff --git a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb b/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
index 8582af96199..e27ea6e93ae 100644
--- a/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_fork_networks_range_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, schema: 20170929131201 do
let(:migration) { described_class.new }
@@ -41,19 +41,19 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
migration.perform(1, 3)
end
- it 'it creates the fork network' do
+ it "it creates the fork network" do
expect(fork_network1).not_to be_nil
expect(fork_network2).not_to be_nil
end
- it 'does not create a fork network for a fork-of-fork' do
+ it "does not create a fork network for a fork-of-fork" do
# perfrom the entire batch
migration.perform(1, 5)
expect(fork_networks.find_by(root_project_id: base2_fork1.id)).to be_nil
end
- it 'creates memberships for the root of fork networks' do
+ it "creates memberships for the root of fork networks" do
base1_membership = fork_network_members.find_by(fork_network_id: fork_network1.id,
project_id: base1.id)
base2_membership = fork_network_members.find_by(fork_network_id: fork_network2.id,
@@ -63,7 +63,7 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
expect(base2_membership).not_to be_nil
end
- it 'creates a fork network for the fork of which the source was deleted' do
+ it "creates a fork network for the fork of which the source was deleted" do
fork = projects.create
forked_project_links.create(id: 6, forked_from_project_id: 99999, forked_to_project_id: fork.id)
@@ -74,7 +74,7 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
expect(fork_network_members.find_by(project_id: fork.id)).not_to be_nil
end
- it 'schedules a job for inserting memberships for forks-of-forks' do
+ it "schedules a job for inserting memberships for forks-of-forks" do
delay = Gitlab::BackgroundMigration::CreateForkNetworkMembershipsRange::RESCHEDULE_DELAY
expect(BackgroundMigrationWorker)
@@ -83,7 +83,7 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
migration.perform(1, 3)
end
- it 'only processes a single batch of links at a time' do
+ it "only processes a single batch of links at a time" do
expect(fork_networks.count).to eq(2)
migration.perform(3, 5)
@@ -91,7 +91,7 @@ describe Gitlab::BackgroundMigration::PopulateForkNetworksRange, :migration, sch
expect(fork_networks.count).to eq(3)
end
- it 'can be repeated without effect' do
+ it "can be repeated without effect" do
expect { migration.perform(1, 3) }.not_to change { fork_network_members.count }
end
end
diff --git a/spec/lib/gitlab/background_migration/populate_import_state_spec.rb b/spec/lib/gitlab/background_migration/populate_import_state_spec.rb
index fcb869022de..8f8ab520e74 100644
--- a/spec/lib/gitlab/background_migration/populate_import_state_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_import_state_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::PopulateImportState, :migration, schema: 20180502134117 do
let(:migration) { described_class.new }
@@ -7,15 +7,15 @@ describe Gitlab::BackgroundMigration::PopulateImportState, :migration, schema: 2
let(:import_state) { table(:project_mirror_data) }
before do
- namespaces.create(id: 1, name: 'gitlab-org', path: 'gitlab-org')
+ namespaces.create(id: 1, name: "gitlab-org", path: "gitlab-org")
- projects.create!(id: 1, namespace_id: 1, name: 'gitlab1',
- path: 'gitlab1', import_error: "foo", import_status: :started,
+ projects.create!(id: 1, namespace_id: 1, name: "gitlab1",
+ path: "gitlab1", import_error: "foo", import_status: :started,
import_url: generate(:url))
- projects.create!(id: 2, namespace_id: 1, name: 'gitlab2', path: 'gitlab2',
+ projects.create!(id: 2, namespace_id: 1, name: "gitlab2", path: "gitlab2",
import_status: :none, import_url: generate(:url))
- projects.create!(id: 3, namespace_id: 1, name: 'gitlab3',
- path: 'gitlab3', import_error: "bar", import_status: :failed,
+ projects.create!(id: 3, namespace_id: 1, name: "gitlab3",
+ path: "gitlab3", import_error: "bar", import_status: :failed,
import_url: generate(:url))
allow(BackgroundMigrationWorker).to receive(:perform_in)
@@ -24,9 +24,9 @@ describe Gitlab::BackgroundMigration::PopulateImportState, :migration, schema: 2
it "creates new import_state records with project's import data" do
expect(projects.where.not(import_status: :none).count).to eq(2)
- expect do
+ expect {
migration.perform(1, 3)
- end.to change { import_state.all.count }.from(0).to(2)
+ }.to change { import_state.all.count }.from(0).to(2)
expect(import_state.first.last_error).to eq("foo")
expect(import_state.last.last_error).to eq("bar")
diff --git a/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved_spec.rb b/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved_spec.rb
index d1d64574627..f7d7e2d38dc 100644
--- a/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_improved_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsDataImproved, :migration, schema: 20181204154019 do
let(:namespaces) { table(:namespaces) }
@@ -8,18 +8,18 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsDataI
let(:users) { table(:users) }
let(:events) { table(:events) }
- let(:user) { users.create!(email: 'test@example.com', projects_limit: 100, username: 'test') }
+ let(:user) { users.create!(email: "test@example.com", projects_limit: 100, username: "test") }
- let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
- let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') }
+ let(:namespace) { namespaces.create(name: "gitlab", path: "gitlab-org") }
+ let(:project) { projects.create(namespace_id: namespace.id, name: "foo") }
let(:merge_requests) { table(:merge_requests) }
def create_merge_request(id, params = {})
params.merge!(id: id,
target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
- source_branch: 'mr name',
+ source_branch: "mr name",
title: "mr name#{id}")
merge_requests.create(params)
@@ -29,14 +29,14 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsDataI
params.merge!(id: id,
project_id: project.id,
author_id: user.id,
- target_type: 'MergeRequest')
+ target_type: "MergeRequest")
events.create(params)
end
- describe '#perform' do
- it 'creates and updates closed and merged events' do
- timestamp = Time.new('2018-01-01 12:00:00').utc
+ describe "#perform" do
+ it "creates and updates closed and merged events" do
+ timestamp = Time.new("2018-01-01 12:00:00").utc
create_merge_request(1)
create_merge_request_event(1, target_id: 1, action: 3, updated_at: timestamp)
diff --git a/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb b/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb
index ff1bd9f7850..fbcc8b809d0 100644
--- a/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_merge_request_metrics_with_events_data_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
# rubocop:disable RSpec/FactoriesInMigrationSpecs
describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData, :migration, schema: 20171128214150 do
@@ -8,7 +8,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
.to receive(:commits_count=).and_return(nil)
end
- describe '#perform' do
+ describe "#perform" do
let(:mr_with_event) { create(:merge_request) }
let!(:merged_event) { create(:event, :merged, target: mr_with_event) }
let!(:closed_event) { create(:event, :closed, target: mr_with_event) }
@@ -18,7 +18,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
mr_with_event.metrics.destroy!
end
- it 'inserts metrics and updates closed and merged events' do
+ it "inserts metrics and updates closed and merged events" do
subject.perform(mr_with_event.id, mr_with_event.id)
mr_with_event.reload
@@ -29,7 +29,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
end
end
- describe '#insert_metrics_for_range' do
+ describe "#insert_metrics_for_range" do
let!(:mrs_without_metrics) { create_list(:merge_request, 3) }
let!(:mrs_with_metrics) { create_list(:merge_request, 2) }
@@ -38,7 +38,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
mrs_without_metrics.each { |m| m.metrics.destroy! }
end
- it 'inserts merge_request_metrics for merge_requests without one' do
+ it "inserts merge_request_metrics for merge_requests without one" do
expect { subject.insert_metrics_for_range(MergeRequest.first.id, MergeRequest.last.id) }
.to change(MergeRequest::Metrics, :count).from(2).to(5)
@@ -47,14 +47,14 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
end
end
- it 'does not inserts merge_request_metrics for MRs out of given range' do
+ it "does not inserts merge_request_metrics for MRs out of given range" do
expect { subject.insert_metrics_for_range(mrs_with_metrics.first.id, mrs_with_metrics.last.id) }
.not_to change(MergeRequest::Metrics, :count).from(2)
end
end
- describe '#update_metrics_with_events_data' do
- context 'closed events data update' do
+ describe "#update_metrics_with_events_data" do
+ context "closed events data update" do
let(:users) { create_list(:user, 3) }
let(:mrs_with_event) { create_list(:merge_request, 3) }
@@ -64,7 +64,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
create(:event, :closed, author: users.third, target: mrs_with_event.third)
end
- it 'migrates multiple MR metrics with closed event data' do
+ it "migrates multiple MR metrics with closed event data" do
mr_without_event = create(:merge_request)
create(:event, :merged)
@@ -83,7 +83,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
latest_closed_at: nil)
end
- it 'does not updates metrics out of given range' do
+ it "does not updates metrics out of given range" do
out_of_range_mr = create(:merge_request)
create(:event, :closed, author: users.last, target: out_of_range_mr)
@@ -93,7 +93,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
end
end
- context 'merged events data update' do
+ context "merged events data update" do
let(:users) { create_list(:user, 3) }
let(:mrs_with_event) { create_list(:merge_request, 3) }
@@ -103,7 +103,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
create(:event, :merged, author: users.third, target: mrs_with_event.third)
end
- it 'migrates multiple MR metrics with merged event data' do
+ it "migrates multiple MR metrics with merged event data" do
mr_without_event = create(:merge_request)
create(:event, :merged)
@@ -118,7 +118,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestMetricsWithEventsData,
expect(mr_without_event.metrics.reload).to have_attributes(merged_by_id: nil)
end
- it 'does not updates metrics out of given range' do
+ it "does not updates metrics out of given range" do
out_of_range_mr = create(:merge_request)
create(:event, :merged, author: users.last, target: out_of_range_mr)
diff --git a/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb b/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb
index 0cb753c5853..c5ee510257c 100644
--- a/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_merge_requests_latest_merge_request_diff_id_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::PopulateMergeRequestsLatestMergeRequestDiffId, :migration, schema: 20171026082505 do
let(:projects_table) { table(:projects) }
let(:merge_requests_table) { table(:merge_requests) }
let(:merge_request_diffs_table) { table(:merge_request_diffs) }
- let(:project) { projects_table.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') }
+ let(:project) { projects_table.create!(name: "gitlab", path: "gitlab-org/gitlab-ce") }
def create_mr!(name, diffs: 0)
merge_request =
merge_requests_table.create!(target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
source_branch: name,
title: name)
@@ -26,9 +26,9 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestsLatestMergeRequestDif
merge_request_diffs_table.where(merge_request_id: merge_request.id)
end
- describe '#perform' do
- it 'ignores MRs without diffs' do
- merge_request_without_diff = create_mr!('without_diff')
+ describe "#perform" do
+ it "ignores MRs without diffs" do
+ merge_request_without_diff = create_mr!("without_diff")
mr_id = merge_request_without_diff.id
expect(merge_request_without_diff.latest_merge_request_diff_id).to be_nil
@@ -37,8 +37,8 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestsLatestMergeRequestDif
.not_to change { merge_request_without_diff.reload.latest_merge_request_diff_id }
end
- it 'ignores MRs that have a diff ID already set' do
- merge_request_with_multiple_diffs = create_mr!('with_multiple_diffs', diffs: 3)
+ it "ignores MRs that have a diff ID already set" do
+ merge_request_with_multiple_diffs = create_mr!("with_multiple_diffs", diffs: 3)
diff_id = diffs_for(merge_request_with_multiple_diffs).minimum(:id)
mr_id = merge_request_with_multiple_diffs.id
@@ -48,7 +48,7 @@ describe Gitlab::BackgroundMigration::PopulateMergeRequestsLatestMergeRequestDif
.not_to change { merge_request_with_multiple_diffs.reload.latest_merge_request_diff_id }
end
- it 'migrates multiple MR diffs to the correct values' do
+ it "migrates multiple MR diffs to the correct values" do
merge_requests = Array.new(3).map.with_index { |_, i| create_mr!(i, diffs: 3) }
subject.perform(merge_requests.first.id, merge_requests.last.id)
diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_dependencies/untracked_file_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_dependencies/untracked_file_spec.rb
index c76adcbe2f5..b6972518e59 100644
--- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_dependencies/untracked_file_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_dependencies/untracked_file_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::UntrackedFile, :migration, schema: 20180208183958 do
@@ -14,51 +14,51 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::Untr
ensure_temporary_tracking_table_exists
end
- describe '#upload_path' do
+ describe "#upload_path" do
def assert_upload_path(file_path, expected_upload_path)
untracked_file = create_untracked_file(file_path)
expect(untracked_file.upload_path).to eq(expected_upload_path)
end
- context 'for an appearance logo file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/appearance/logo/1/some_logo.jpg', 'uploads/-/system/appearance/logo/1/some_logo.jpg')
+ context "for an appearance logo file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/appearance/logo/1/some_logo.jpg", "uploads/-/system/appearance/logo/1/some_logo.jpg")
end
end
- context 'for an appearance header_logo file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/appearance/header_logo/1/some_logo.jpg', 'uploads/-/system/appearance/header_logo/1/some_logo.jpg')
+ context "for an appearance header_logo file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/appearance/header_logo/1/some_logo.jpg", "uploads/-/system/appearance/header_logo/1/some_logo.jpg")
end
end
- context 'for a pre-Markdown Note attachment file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/note/attachment/1234/some_attachment.pdf', 'uploads/-/system/note/attachment/1234/some_attachment.pdf')
+ context "for a pre-Markdown Note attachment file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/note/attachment/1234/some_attachment.pdf", "uploads/-/system/note/attachment/1234/some_attachment.pdf")
end
end
- context 'for a user avatar file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/user/avatar/1234/avatar.jpg', 'uploads/-/system/user/avatar/1234/avatar.jpg')
+ context "for a user avatar file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/user/avatar/1234/avatar.jpg", "uploads/-/system/user/avatar/1234/avatar.jpg")
end
end
- context 'for a group avatar file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/group/avatar/1234/avatar.jpg', 'uploads/-/system/group/avatar/1234/avatar.jpg')
+ context "for a group avatar file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/group/avatar/1234/avatar.jpg", "uploads/-/system/group/avatar/1234/avatar.jpg")
end
end
- context 'for a project avatar file path' do
- it 'returns the file path relative to the CarrierWave root' do
- assert_upload_path('/-/system/project/avatar/1234/avatar.jpg', 'uploads/-/system/project/avatar/1234/avatar.jpg')
+ context "for a project avatar file path" do
+ it "returns the file path relative to the CarrierWave root" do
+ assert_upload_path("/-/system/project/avatar/1234/avatar.jpg", "uploads/-/system/project/avatar/1234/avatar.jpg")
end
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
- it 'returns the file path relative to the project directory in uploads' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
+ it "returns the file path relative to the project directory in uploads" do
project = create_project
random_hex = SecureRandom.hex
@@ -67,155 +67,155 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::Untr
end
end
- describe '#uploader' do
+ describe "#uploader" do
def assert_uploader(file_path, expected_uploader)
untracked_file = create_untracked_file(file_path)
expect(untracked_file.uploader).to eq(expected_uploader)
end
- context 'for an appearance logo file path' do
- it 'returns AttachmentUploader as a string' do
- assert_uploader('/-/system/appearance/logo/1/some_logo.jpg', 'AttachmentUploader')
+ context "for an appearance logo file path" do
+ it "returns AttachmentUploader as a string" do
+ assert_uploader("/-/system/appearance/logo/1/some_logo.jpg", "AttachmentUploader")
end
end
- context 'for an appearance header_logo file path' do
- it 'returns AttachmentUploader as a string' do
- assert_uploader('/-/system/appearance/header_logo/1/some_logo.jpg', 'AttachmentUploader')
+ context "for an appearance header_logo file path" do
+ it "returns AttachmentUploader as a string" do
+ assert_uploader("/-/system/appearance/header_logo/1/some_logo.jpg", "AttachmentUploader")
end
end
- context 'for a pre-Markdown Note attachment file path' do
- it 'returns AttachmentUploader as a string' do
- assert_uploader('/-/system/note/attachment/1234/some_attachment.pdf', 'AttachmentUploader')
+ context "for a pre-Markdown Note attachment file path" do
+ it "returns AttachmentUploader as a string" do
+ assert_uploader("/-/system/note/attachment/1234/some_attachment.pdf", "AttachmentUploader")
end
end
- context 'for a user avatar file path' do
- it 'returns AvatarUploader as a string' do
- assert_uploader('/-/system/user/avatar/1234/avatar.jpg', 'AvatarUploader')
+ context "for a user avatar file path" do
+ it "returns AvatarUploader as a string" do
+ assert_uploader("/-/system/user/avatar/1234/avatar.jpg", "AvatarUploader")
end
end
- context 'for a group avatar file path' do
- it 'returns AvatarUploader as a string' do
- assert_uploader('/-/system/group/avatar/1234/avatar.jpg', 'AvatarUploader')
+ context "for a group avatar file path" do
+ it "returns AvatarUploader as a string" do
+ assert_uploader("/-/system/group/avatar/1234/avatar.jpg", "AvatarUploader")
end
end
- context 'for a project avatar file path' do
- it 'returns AvatarUploader as a string' do
- assert_uploader('/-/system/project/avatar/1234/avatar.jpg', 'AvatarUploader')
+ context "for a project avatar file path" do
+ it "returns AvatarUploader as a string" do
+ assert_uploader("/-/system/project/avatar/1234/avatar.jpg", "AvatarUploader")
end
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
- it 'returns FileUploader as a string' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
+ it "returns FileUploader as a string" do
project = create_project
- assert_uploader("/#{get_full_path(project)}/#{SecureRandom.hex}/Some file.jpg", 'FileUploader')
+ assert_uploader("/#{get_full_path(project)}/#{SecureRandom.hex}/Some file.jpg", "FileUploader")
end
end
end
- describe '#model_type' do
+ describe "#model_type" do
def assert_model_type(file_path, expected_model_type)
untracked_file = create_untracked_file(file_path)
expect(untracked_file.model_type).to eq(expected_model_type)
end
- context 'for an appearance logo file path' do
- it 'returns Appearance as a string' do
- assert_model_type('/-/system/appearance/logo/1/some_logo.jpg', 'Appearance')
+ context "for an appearance logo file path" do
+ it "returns Appearance as a string" do
+ assert_model_type("/-/system/appearance/logo/1/some_logo.jpg", "Appearance")
end
end
- context 'for an appearance header_logo file path' do
- it 'returns Appearance as a string' do
- assert_model_type('/-/system/appearance/header_logo/1/some_logo.jpg', 'Appearance')
+ context "for an appearance header_logo file path" do
+ it "returns Appearance as a string" do
+ assert_model_type("/-/system/appearance/header_logo/1/some_logo.jpg", "Appearance")
end
end
- context 'for a pre-Markdown Note attachment file path' do
- it 'returns Note as a string' do
- assert_model_type('/-/system/note/attachment/1234/some_attachment.pdf', 'Note')
+ context "for a pre-Markdown Note attachment file path" do
+ it "returns Note as a string" do
+ assert_model_type("/-/system/note/attachment/1234/some_attachment.pdf", "Note")
end
end
- context 'for a user avatar file path' do
- it 'returns User as a string' do
- assert_model_type('/-/system/user/avatar/1234/avatar.jpg', 'User')
+ context "for a user avatar file path" do
+ it "returns User as a string" do
+ assert_model_type("/-/system/user/avatar/1234/avatar.jpg", "User")
end
end
- context 'for a group avatar file path' do
- it 'returns Namespace as a string' do
- assert_model_type('/-/system/group/avatar/1234/avatar.jpg', 'Namespace')
+ context "for a group avatar file path" do
+ it "returns Namespace as a string" do
+ assert_model_type("/-/system/group/avatar/1234/avatar.jpg", "Namespace")
end
end
- context 'for a project avatar file path' do
- it 'returns Project as a string' do
- assert_model_type('/-/system/project/avatar/1234/avatar.jpg', 'Project')
+ context "for a project avatar file path" do
+ it "returns Project as a string" do
+ assert_model_type("/-/system/project/avatar/1234/avatar.jpg", "Project")
end
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
- it 'returns Project as a string' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
+ it "returns Project as a string" do
project = create_project
- assert_model_type("/#{get_full_path(project)}/#{SecureRandom.hex}/Some file.jpg", 'Project')
+ assert_model_type("/#{get_full_path(project)}/#{SecureRandom.hex}/Some file.jpg", "Project")
end
end
end
- describe '#model_id' do
+ describe "#model_id" do
def assert_model_id(file_path, expected_model_id)
untracked_file = create_untracked_file(file_path)
expect(untracked_file.model_id).to eq(expected_model_id)
end
- context 'for an appearance logo file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/appearance/logo/1/some_logo.jpg', 1)
+ context "for an appearance logo file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/appearance/logo/1/some_logo.jpg", 1)
end
end
- context 'for an appearance header_logo file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/appearance/header_logo/1/some_logo.jpg', 1)
+ context "for an appearance header_logo file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/appearance/header_logo/1/some_logo.jpg", 1)
end
end
- context 'for a pre-Markdown Note attachment file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/note/attachment/1234/some_attachment.pdf', 1234)
+ context "for a pre-Markdown Note attachment file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/note/attachment/1234/some_attachment.pdf", 1234)
end
end
- context 'for a user avatar file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/user/avatar/1234/avatar.jpg', 1234)
+ context "for a user avatar file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/user/avatar/1234/avatar.jpg", 1234)
end
end
- context 'for a group avatar file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/group/avatar/1234/avatar.jpg', 1234)
+ context "for a group avatar file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/group/avatar/1234/avatar.jpg", 1234)
end
end
- context 'for a project avatar file path' do
- it 'returns the ID as a string' do
- assert_model_id('/-/system/project/avatar/1234/avatar.jpg', 1234)
+ context "for a project avatar file path" do
+ it "returns the ID as a string" do
+ assert_model_id("/-/system/project/avatar/1234/avatar.jpg", 1234)
end
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
- it 'returns the ID as a string' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
+ it "returns the ID as a string" do
project = create_project
assert_model_id("/#{get_full_path(project)}/#{SecureRandom.hex}/Some file.jpg", project.id)
@@ -223,34 +223,34 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploadsDependencies::Untr
end
end
- describe '#file_size' do
- context 'for an appearance logo file path' do
+ describe "#file_size" do
+ context "for an appearance logo file path" do
let(:appearance) { create_or_update_appearance(logo: true) }
- let(:untracked_file) { described_class.create!(path: get_uploads(appearance, 'Appearance').first.path) }
+ let(:untracked_file) { described_class.create!(path: get_uploads(appearance, "Appearance").first.path) }
- it 'returns the file size' do
+ it "returns the file size" do
expect(untracked_file.file_size).to eq(1062)
end
end
- context 'for a project avatar file path' do
+ context "for a project avatar file path" do
let(:project) { create_project(avatar: true) }
- let(:untracked_file) { described_class.create!(path: get_uploads(project, 'Project').first.path) }
+ let(:untracked_file) { described_class.create!(path: get_uploads(project, "Project").first.path) }
- it 'returns the file size' do
+ it "returns the file size" do
expect(untracked_file.file_size).to eq(1062)
end
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
let(:project) { create_project }
- let(:untracked_file) { create_untracked_file("/#{get_full_path(project)}/#{get_uploads(project, 'Project').first.path}") }
+ let(:untracked_file) { create_untracked_file("/#{get_full_path(project)}/#{get_uploads(project, "Project").first.path}") }
before do
add_markdown_attachment(project)
end
- it 'returns the file size' do
+ it "returns the file size" do
expect(untracked_file.file_size).to eq(1062)
end
end
diff --git a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
index 0dee683350f..ed9f895f1f3 100644
--- a/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
+++ b/spec/lib/gitlab/background_migration/populate_untracked_uploads_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migration, schema: 20180208183958 do
@@ -20,7 +20,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
uploads.delete_all
end
- context 'with untracked files and tracked files in untracked_files_for_uploads' do
+ context "with untracked files and tracked files in untracked_files_for_uploads" do
let!(:appearance) { create_or_update_appearance(logo: true, header_logo: true) }
let!(:user1) { create_user(avatar: true) }
let!(:user2) { create_user(avatar: true) }
@@ -32,98 +32,98 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
add_markdown_attachment(project2)
# File records created by PrepareUntrackedUploads
- untracked_files_for_uploads.create!(path: get_uploads(appearance, 'Appearance').first.path)
- untracked_files_for_uploads.create!(path: get_uploads(appearance, 'Appearance').last.path)
- untracked_files_for_uploads.create!(path: get_uploads(user1, 'User').first.path)
- untracked_files_for_uploads.create!(path: get_uploads(user2, 'User').first.path)
- untracked_files_for_uploads.create!(path: get_uploads(project1, 'Project').first.path)
- untracked_files_for_uploads.create!(path: get_uploads(project2, 'Project').first.path)
- untracked_files_for_uploads.create!(path: "#{legacy_project_uploads_dir(project1).sub("#{MigrationsHelpers::TrackUntrackedUploadsHelpers::PUBLIC_DIR}/", '')}/#{get_uploads(project1, 'Project').last.path}")
- untracked_files_for_uploads.create!(path: "#{legacy_project_uploads_dir(project2).sub("#{MigrationsHelpers::TrackUntrackedUploadsHelpers::PUBLIC_DIR}/", '')}/#{get_uploads(project2, 'Project').last.path}")
+ untracked_files_for_uploads.create!(path: get_uploads(appearance, "Appearance").first.path)
+ untracked_files_for_uploads.create!(path: get_uploads(appearance, "Appearance").last.path)
+ untracked_files_for_uploads.create!(path: get_uploads(user1, "User").first.path)
+ untracked_files_for_uploads.create!(path: get_uploads(user2, "User").first.path)
+ untracked_files_for_uploads.create!(path: get_uploads(project1, "Project").first.path)
+ untracked_files_for_uploads.create!(path: get_uploads(project2, "Project").first.path)
+ untracked_files_for_uploads.create!(path: "#{legacy_project_uploads_dir(project1).sub("#{MigrationsHelpers::TrackUntrackedUploadsHelpers::PUBLIC_DIR}/", "")}/#{get_uploads(project1, "Project").last.path}")
+ untracked_files_for_uploads.create!(path: "#{legacy_project_uploads_dir(project2).sub("#{MigrationsHelpers::TrackUntrackedUploadsHelpers::PUBLIC_DIR}/", "")}/#{get_uploads(project2, "Project").last.path}")
# Untrack 4 files
- get_uploads(user2, 'User').delete_all
- get_uploads(project2, 'Project').delete_all # 2 files: avatar and a Markdown upload
- get_uploads(appearance, 'Appearance').where("path like '%header_logo%'").delete_all
+ get_uploads(user2, "User").delete_all
+ get_uploads(project2, "Project").delete_all # 2 files: avatar and a Markdown upload
+ get_uploads(appearance, "Appearance").where("path like '%header_logo%'").delete_all
end
- it 'adds untracked files to the uploads table' do
- expect do
+ it "adds untracked files to the uploads table" do
+ expect {
subject.perform(1, untracked_files_for_uploads.reorder(:id).last.id)
- end.to change { uploads.count }.from(4).to(8)
+ }.to change { uploads.count }.from(4).to(8)
- expect(get_uploads(user2, 'User').count).to eq(1)
- expect(get_uploads(project2, 'Project').count).to eq(2)
- expect(get_uploads(appearance, 'Appearance').count).to eq(2)
+ expect(get_uploads(user2, "User").count).to eq(1)
+ expect(get_uploads(project2, "Project").count).to eq(2)
+ expect(get_uploads(appearance, "Appearance").count).to eq(2)
end
- it 'deletes rows after processing them' do
+ it "deletes rows after processing them" do
expect(subject).to receive(:drop_temp_table_if_finished) # Don't drop the table so we can look at it
- expect do
+ expect {
subject.perform(1, untracked_files_for_uploads.last.id)
- end.to change { untracked_files_for_uploads.count }.from(8).to(0)
+ }.to change { untracked_files_for_uploads.count }.from(8).to(0)
end
- it 'does not create duplicate uploads of already tracked files' do
+ it "does not create duplicate uploads of already tracked files" do
subject.perform(1, untracked_files_for_uploads.last.id)
- expect(get_uploads(user1, 'User').count).to eq(1)
- expect(get_uploads(project1, 'Project').count).to eq(2)
- expect(get_uploads(appearance, 'Appearance').count).to eq(2)
+ expect(get_uploads(user1, "User").count).to eq(1)
+ expect(get_uploads(project1, "Project").count).to eq(2)
+ expect(get_uploads(appearance, "Appearance").count).to eq(2)
end
- it 'uses the start and end batch ids [only 1st half]' do
+ it "uses the start and end batch ids [only 1st half]" do
ids = untracked_files_for_uploads.all.order(:id).pluck(:id)
start_id = ids[0]
end_id = ids[3]
- expect do
+ expect {
subject.perform(start_id, end_id)
- end.to change { uploads.count }.from(4).to(6)
+ }.to change { uploads.count }.from(4).to(6)
- expect(get_uploads(user1, 'User').count).to eq(1)
- expect(get_uploads(user2, 'User').count).to eq(1)
- expect(get_uploads(appearance, 'Appearance').count).to eq(2)
- expect(get_uploads(project1, 'Project').count).to eq(2)
- expect(get_uploads(project2, 'Project').count).to eq(0)
+ expect(get_uploads(user1, "User").count).to eq(1)
+ expect(get_uploads(user2, "User").count).to eq(1)
+ expect(get_uploads(appearance, "Appearance").count).to eq(2)
+ expect(get_uploads(project1, "Project").count).to eq(2)
+ expect(get_uploads(project2, "Project").count).to eq(0)
# Only 4 have been either confirmed or added to uploads
expect(untracked_files_for_uploads.count).to eq(4)
end
- it 'uses the start and end batch ids [only 2nd half]' do
+ it "uses the start and end batch ids [only 2nd half]" do
ids = untracked_files_for_uploads.all.order(:id).pluck(:id)
start_id = ids[4]
end_id = ids[7]
- expect do
+ expect {
subject.perform(start_id, end_id)
- end.to change { uploads.count }.from(4).to(6)
+ }.to change { uploads.count }.from(4).to(6)
- expect(get_uploads(user1, 'User').count).to eq(1)
- expect(get_uploads(user2, 'User').count).to eq(0)
- expect(get_uploads(appearance, 'Appearance').count).to eq(1)
- expect(get_uploads(project1, 'Project').count).to eq(2)
- expect(get_uploads(project2, 'Project').count).to eq(2)
+ expect(get_uploads(user1, "User").count).to eq(1)
+ expect(get_uploads(user2, "User").count).to eq(0)
+ expect(get_uploads(appearance, "Appearance").count).to eq(1)
+ expect(get_uploads(project1, "Project").count).to eq(2)
+ expect(get_uploads(project2, "Project").count).to eq(2)
# Only 4 have been either confirmed or added to uploads
expect(untracked_files_for_uploads.count).to eq(4)
end
- it 'does not drop the temporary tracking table after processing the batch, if there are still untracked rows' do
+ it "does not drop the temporary tracking table after processing the batch, if there are still untracked rows" do
subject.perform(1, untracked_files_for_uploads.last.id - 1)
expect(ActiveRecord::Base.connection.data_source_exists?(:untracked_files_for_uploads)).to be_truthy
end
- it 'drops the temporary tracking table after processing the batch, if there are no untracked rows left' do
+ it "drops the temporary tracking table after processing the batch, if there are no untracked rows left" do
expect(subject).to receive(:drop_temp_table_if_finished)
subject.perform(1, untracked_files_for_uploads.last.id)
end
- it 'does not block a whole batch because of one bad path' do
+ it "does not block a whole batch because of one bad path" do
untracked_files_for_uploads.create!(path: "#{Gitlab::BackgroundMigration::PrepareUntrackedUploads::RELATIVE_UPLOAD_DIR}/#{get_full_path(project2)}/._7d37bf4c747916390e596744117d5d1a")
expect(untracked_files_for_uploads.count).to eq(9)
expect(uploads.count).to eq(4)
@@ -134,7 +134,7 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
expect(uploads.count).to eq(8)
end
- it 'an unparseable path is shown in error output' do
+ it "an unparseable path is shown in error output" do
bad_path = "#{Gitlab::BackgroundMigration::PrepareUntrackedUploads::RELATIVE_UPLOAD_DIR}/#{get_full_path(project2)}/._7d37bf4c747916390e596744117d5d1a"
untracked_files_for_uploads.create!(path: bad_path)
@@ -144,87 +144,87 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
end
end
- context 'with no untracked files' do
- it 'does not add to the uploads table (and does not raise error)' do
- expect do
+ context "with no untracked files" do
+ it "does not add to the uploads table (and does not raise error)" do
+ expect {
subject.perform(1, 1000)
- end.not_to change { uploads.count }.from(0)
+ }.not_to change { uploads.count }.from(0)
end
end
- describe 'upload outcomes for each path pattern' do
- shared_examples_for 'non_markdown_file' do
- let!(:expected_upload_attrs) { model_uploads.first.attributes.slice('path', 'uploader', 'size', 'checksum') }
- let!(:untracked_file) { untracked_files_for_uploads.create!(path: expected_upload_attrs['path']) }
+ describe "upload outcomes for each path pattern" do
+ shared_examples_for "non_markdown_file" do
+ let!(:expected_upload_attrs) { model_uploads.first.attributes.slice("path", "uploader", "size", "checksum") }
+ let!(:untracked_file) { untracked_files_for_uploads.create!(path: expected_upload_attrs["path"]) }
before do
model_uploads.delete_all
end
- it 'creates an Upload record' do
- expect do
+ it "creates an Upload record" do
+ expect {
subject.perform(1, untracked_files_for_uploads.last.id)
- end.to change { model_uploads.count }.from(0).to(1)
+ }.to change { model_uploads.count }.from(0).to(1)
expect(model_uploads.first.attributes).to include(expected_upload_attrs)
end
end
- context 'for an appearance logo file path' do
+ context "for an appearance logo file path" do
let(:model) { create_or_update_appearance(logo: true) }
- let(:model_uploads) { get_uploads(model, 'Appearance') }
+ let(:model_uploads) { get_uploads(model, "Appearance") }
- it_behaves_like 'non_markdown_file'
+ it_behaves_like "non_markdown_file"
end
- context 'for an appearance header_logo file path' do
+ context "for an appearance header_logo file path" do
let(:model) { create_or_update_appearance(header_logo: true) }
- let(:model_uploads) { get_uploads(model, 'Appearance') }
+ let(:model_uploads) { get_uploads(model, "Appearance") }
- it_behaves_like 'non_markdown_file'
+ it_behaves_like "non_markdown_file"
end
- context 'for a pre-Markdown Note attachment file path' do
+ context "for a pre-Markdown Note attachment file path" do
let(:model) { create_note(attachment: true) }
- let!(:expected_upload_attrs) { get_uploads(model, 'Note').first.attributes.slice('path', 'uploader', 'size', 'checksum') }
- let!(:untracked_file) { untracked_files_for_uploads.create!(path: expected_upload_attrs['path']) }
+ let!(:expected_upload_attrs) { get_uploads(model, "Note").first.attributes.slice("path", "uploader", "size", "checksum") }
+ let!(:untracked_file) { untracked_files_for_uploads.create!(path: expected_upload_attrs["path"]) }
before do
- get_uploads(model, 'Note').delete_all
+ get_uploads(model, "Note").delete_all
end
# Can't use the shared example because Note doesn't have an `uploads` association
- it 'creates an Upload record' do
- expect do
+ it "creates an Upload record" do
+ expect {
subject.perform(1, untracked_files_for_uploads.last.id)
- end.to change { get_uploads(model, 'Note').count }.from(0).to(1)
+ }.to change { get_uploads(model, "Note").count }.from(0).to(1)
- expect(get_uploads(model, 'Note').first.attributes).to include(expected_upload_attrs)
+ expect(get_uploads(model, "Note").first.attributes).to include(expected_upload_attrs)
end
end
- context 'for a user avatar file path' do
+ context "for a user avatar file path" do
let(:model) { create_user(avatar: true) }
- let(:model_uploads) { get_uploads(model, 'User') }
+ let(:model_uploads) { get_uploads(model, "User") }
- it_behaves_like 'non_markdown_file'
+ it_behaves_like "non_markdown_file"
end
- context 'for a group avatar file path' do
+ context "for a group avatar file path" do
let(:model) { create_group(avatar: true) }
- let(:model_uploads) { get_uploads(model, 'Namespace') }
+ let(:model_uploads) { get_uploads(model, "Namespace") }
- it_behaves_like 'non_markdown_file'
+ it_behaves_like "non_markdown_file"
end
- context 'for a project avatar file path' do
+ context "for a project avatar file path" do
let(:model) { create_project(avatar: true) }
- let(:model_uploads) { get_uploads(model, 'Project') }
+ let(:model_uploads) { get_uploads(model, "Project") }
- it_behaves_like 'non_markdown_file'
+ it_behaves_like "non_markdown_file"
end
- context 'for a project Markdown attachment (notes, issues, MR descriptions) file path' do
+ context "for a project Markdown attachment (notes, issues, MR descriptions) file path" do
let(:model) { create_project }
before do
@@ -232,21 +232,21 @@ describe Gitlab::BackgroundMigration::PopulateUntrackedUploads, :sidekiq, :migra
add_markdown_attachment(model)
# Create the untracked_files_for_uploads record
- untracked_files_for_uploads.create!(path: "#{Gitlab::BackgroundMigration::PrepareUntrackedUploads::RELATIVE_UPLOAD_DIR}/#{get_full_path(model)}/#{get_uploads(model, 'Project').first.path}")
+ untracked_files_for_uploads.create!(path: "#{Gitlab::BackgroundMigration::PrepareUntrackedUploads::RELATIVE_UPLOAD_DIR}/#{get_full_path(model)}/#{get_uploads(model, "Project").first.path}")
# Save the expected upload attributes
- @expected_upload_attrs = get_uploads(model, 'Project').first.attributes.slice('path', 'uploader', 'size', 'checksum')
+ @expected_upload_attrs = get_uploads(model, "Project").first.attributes.slice("path", "uploader", "size", "checksum")
# Untrack the file
- get_uploads(model, 'Project').delete_all
+ get_uploads(model, "Project").delete_all
end
- it 'creates an Upload record' do
- expect do
+ it "creates an Upload record" do
+ expect {
subject.perform(1, untracked_files_for_uploads.last.id)
- end.to change { get_uploads(model, 'Project').count }.from(0).to(1)
+ }.to change { get_uploads(model, "Project").count }.from(0).to(1)
- expect(get_uploads(model, 'Project').first.attributes).to include(@expected_upload_attrs)
+ expect(get_uploads(model, "Project").first.attributes).to include(@expected_upload_attrs)
end
end
end
diff --git a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
index 35750d89c35..bddffed6dce 100644
--- a/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
+++ b/spec/lib/gitlab/background_migration/prepare_untracked_uploads_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Rollback DB to 10.5 (later than this was originally written for) because it still needs to work.
describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migration, schema: 20180208183958 do
@@ -19,8 +19,8 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
end
end
- shared_examples 'prepares the untracked_files_for_uploads table' do
- context 'when files were uploaded before and after hashed storage was enabled' do
+ shared_examples "prepares the untracked_files_for_uploads table" do
+ context "when files were uploaded before and after hashed storage was enabled" do
let!(:appearance) { create_or_update_appearance(logo: true, header_logo: true) }
let!(:user) { create_user(avatar: true) }
let!(:project1) { create_project(avatar: true) }
@@ -34,42 +34,42 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
add_markdown_attachment(project2, hashed_storage: true)
end
- it 'has a path field long enough for really long paths' do
+ it "has a path field long enough for really long paths" do
described_class.new.perform
- component = 'a' * 255
+ component = "a" * 255
long_path = [
- 'uploads',
+ "uploads",
component, # project.full_path
- component # filename
- ].flatten.join('/')
+ component, # filename
+ ].flatten.join("/")
record = untracked_files_for_uploads.create!(path: long_path)
expect(record.reload.path.size).to eq(519)
end
- it 'adds unhashed files to the untracked_files_for_uploads table' do
+ it "adds unhashed files to the untracked_files_for_uploads table" do
described_class.new.perform
expect(untracked_files_for_uploads.count).to eq(5)
end
- it 'adds files with paths relative to CarrierWave.root' do
+ it "adds files with paths relative to CarrierWave.root" do
described_class.new.perform
untracked_files_for_uploads.all.each do |file|
- expect(file.path.start_with?('uploads/')).to be_truthy
+ expect(file.path.start_with?("uploads/")).to be_truthy
end
end
- it 'does not add hashed files to the untracked_files_for_uploads table' do
+ it "does not add hashed files to the untracked_files_for_uploads table" do
described_class.new.perform
- hashed_file_path = get_uploads(project2, 'Project').where(uploader: 'FileUploader').first.path
+ hashed_file_path = get_uploads(project2, "Project").where(uploader: "FileUploader").first.path
expect(untracked_files_for_uploads.where("path like '%#{hashed_file_path}%'").exists?).to be_falsey
end
- it 'correctly schedules the follow-up background migration jobs' do
+ it "correctly schedules the follow-up background migration jobs" do
described_class.new.perform
ids = described_class::UntrackedFile.all.order(:id).pluck(:id)
@@ -78,22 +78,22 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
end
# E.g. from a previous failed run of this background migration
- context 'when there is existing data in untracked_files_for_uploads' do
+ context "when there is existing data in untracked_files_for_uploads" do
before do
described_class.new.perform
end
- it 'does not error or produce duplicates of existing data' do
- expect do
+ it "does not error or produce duplicates of existing data" do
+ expect {
described_class.new.perform
- end.not_to change { untracked_files_for_uploads.count }.from(5)
+ }.not_to change { untracked_files_for_uploads.count }.from(5)
end
end
# E.g. The installation is in use at the time of migration, and someone has
# just uploaded a file
- context 'when there are files in /uploads/tmp' do
- let(:tmp_file) { Rails.root.join(described_class::ABSOLUTE_UPLOAD_DIR, 'tmp', 'some_file.jpg') }
+ context "when there are files in /uploads/tmp" do
+ let(:tmp_file) { Rails.root.join(described_class::ABSOLUTE_UPLOAD_DIR, "tmp", "some_file.jpg") }
before do
FileUtils.mkdir(File.dirname(tmp_file))
@@ -104,20 +104,20 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
FileUtils.rm(tmp_file)
end
- it 'does not add files from /uploads/tmp' do
+ it "does not add files from /uploads/tmp" do
described_class.new.perform
expect(untracked_files_for_uploads.count).to eq(5)
end
end
- context 'when the last batch size exactly matches the max batch size' do
- it 'does not raise error' do
+ context "when the last batch size exactly matches the max batch size" do
+ it "does not raise error" do
stub_const("#{described_class}::FIND_BATCH_SIZE", 5)
- expect do
+ expect {
described_class.new.perform
- end.not_to raise_error
+ }.not_to raise_error
expect(untracked_files_for_uploads.count).to eq(5)
end
@@ -128,25 +128,25 @@ describe Gitlab::BackgroundMigration::PrepareUntrackedUploads, :sidekiq, :migrat
# If running on Postgres 9.2 (like on CI), this whole context is skipped
# since we're unable to use ON CONFLICT DO NOTHING or IGNORE.
context "test bulk insert with ON CONFLICT DO NOTHING or IGNORE", if: described_class.new.send(:can_bulk_insert_and_ignore_duplicates?) do
- it_behaves_like 'prepares the untracked_files_for_uploads table'
+ it_behaves_like "prepares the untracked_files_for_uploads table"
end
# If running on Postgres 9.2 (like on CI), the stubbed method has no effect.
#
# If running on Postgres 9.5+ or MySQL, then this context effectively tests
# the bulk insert functionality without ON CONFLICT DO NOTHING or IGNORE.
- context 'test bulk insert without ON CONFLICT DO NOTHING or IGNORE' do
+ context "test bulk insert without ON CONFLICT DO NOTHING or IGNORE" do
before do
allow_any_instance_of(described_class).to receive(:postgresql_pre_9_5?).and_return(true)
end
- it_behaves_like 'prepares the untracked_files_for_uploads table'
+ it_behaves_like "prepares the untracked_files_for_uploads table"
end
# Very new or lightly-used installations that are running this migration
# may not have an upload directory because they have no uploads.
- context 'when no files were ever uploaded' do
- it 'deletes the `untracked_files_for_uploads` table (and does not raise error)' do
+ context "when no files were ever uploaded" do
+ it "deletes the `untracked_files_for_uploads` table (and does not raise error)" do
background_migration = described_class.new
expect(background_migration).to receive(:drop_temp_table)
diff --git a/spec/lib/gitlab/background_migration/redact_links_spec.rb b/spec/lib/gitlab/background_migration/redact_links_spec.rb
index a40e68069cc..803f073b2c5 100644
--- a/spec/lib/gitlab/background_migration/redact_links_spec.rb
+++ b/spec/lib/gitlab/background_migration/redact_links_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::RedactLinks, :migration, schema: 20181014121030 do
let(:namespaces) { table(:namespaces) }
@@ -8,16 +8,16 @@ describe Gitlab::BackgroundMigration::RedactLinks, :migration, schema: 201810141
let(:snippets) { table(:snippets) }
let(:users) { table(:users) }
let(:merge_requests) { table(:merge_requests) }
- let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
- let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') }
- let(:user) { users.create!(email: 'test@example.com', projects_limit: 100, username: 'test') }
+ let(:namespace) { namespaces.create(name: "gitlab", path: "gitlab-org") }
+ let(:project) { projects.create(namespace_id: namespace.id, name: "foo") }
+ let(:user) { users.create!(email: "test@example.com", projects_limit: 100, username: "test") }
def create_merge_request(id, params)
params.merge!(id: id,
target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
- source_branch: 'mr name',
+ source_branch: "mr name",
title: "mr name#{id}")
merge_requests.create(params)
@@ -36,7 +36,8 @@ describe Gitlab::BackgroundMigration::RedactLinks, :migration, schema: 201810141
end
def create_snippet(id, params)
- params.merge!(id: id, author_id: user.id)
+ params[:id] = id
+ params[:author_id] = user.id
snippets.create(params)
end
@@ -45,18 +46,18 @@ describe Gitlab::BackgroundMigration::RedactLinks, :migration, schema: 201810141
send("create_#{model.name.underscore}", id, params)
end
- shared_examples_for 'redactable resource' do
- it 'updates only matching texts' do
- matching_text = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
- redacted_text = 'some text /sent_notifications/REDACTED/unsubscribe more text'
- create_resource(model, 1, { field => matching_text })
- create_resource(model, 2, { field => 'not matching text' })
- create_resource(model, 3, { field => matching_text })
- create_resource(model, 4, { field => redacted_text })
- create_resource(model, 5, { field => matching_text })
-
- expected = { field => 'some text /sent_notifications/REDACTED/unsubscribe more text',
- "#{field}_html" => nil }
+ shared_examples_for "redactable resource" do
+ it "updates only matching texts" do
+ matching_text = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
+ redacted_text = "some text /sent_notifications/REDACTED/unsubscribe more text"
+ create_resource(model, 1, {field => matching_text})
+ create_resource(model, 2, {field => "not matching text"})
+ create_resource(model, 3, {field => matching_text})
+ create_resource(model, 4, {field => redacted_text})
+ create_resource(model, 5, {field => matching_text})
+
+ expected = {field => "some text /sent_notifications/REDACTED/unsubscribe more text",
+ "#{field}_html" => nil,}
expect_any_instance_of("Gitlab::BackgroundMigration::RedactLinks::#{model}".constantize).to receive(:update_columns).with(expected).and_call_original
subject.perform(model, field, 2, 4)
@@ -66,29 +67,29 @@ describe Gitlab::BackgroundMigration::RedactLinks, :migration, schema: 201810141
end
end
- context 'resource is Issue' do
- it_behaves_like 'redactable resource' do
+ context "resource is Issue" do
+ it_behaves_like "redactable resource" do
let(:model) { Issue }
let(:field) { :description }
end
end
- context 'resource is Merge Request' do
- it_behaves_like 'redactable resource' do
+ context "resource is Merge Request" do
+ it_behaves_like "redactable resource" do
let(:model) { MergeRequest }
let(:field) { :description }
end
end
- context 'resource is Note' do
- it_behaves_like 'redactable resource' do
+ context "resource is Note" do
+ it_behaves_like "redactable resource" do
let(:model) { Note }
let(:field) { :note }
end
end
- context 'resource is Snippet' do
- it_behaves_like 'redactable resource' do
+ context "resource is Snippet" do
+ it_behaves_like "redactable resource" do
let(:model) { Snippet }
let(:field) { :description }
end
diff --git a/spec/lib/gitlab/background_migration/remove_restricted_todos_spec.rb b/spec/lib/gitlab/background_migration/remove_restricted_todos_spec.rb
index dae754112dc..d0636a05ac2 100644
--- a/spec/lib/gitlab/background_migration/remove_restricted_todos_spec.rb
+++ b/spec/lib/gitlab/background_migration/remove_restricted_todos_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema: 20180704204006 do
let(:projects) { table(:projects) }
@@ -11,15 +11,15 @@ describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema:
let(:project_authorizations) { table(:project_authorizations) }
let(:project_features) { table(:project_features) }
- let(:todo_params) { { author_id: 1, target_type: 'Issue', action: 1, state: :pending } }
+ let(:todo_params) { {author_id: 1, target_type: "Issue", action: 1, state: :pending} }
before do
- users.create(id: 1, email: 'user@example.com', projects_limit: 10)
- users.create(id: 2, email: 'reporter@example.com', projects_limit: 10)
- users.create(id: 3, email: 'guest@example.com', projects_limit: 10)
+ users.create(id: 1, email: "user@example.com", projects_limit: 10)
+ users.create(id: 2, email: "reporter@example.com", projects_limit: 10)
+ users.create(id: 3, email: "guest@example.com", projects_limit: 10)
- projects.create!(id: 1, name: 'project-1', path: 'project-1', visibility_level: 0, namespace_id: 1)
- projects.create!(id: 2, name: 'project-2', path: 'project-2', visibility_level: 0, namespace_id: 1)
+ projects.create!(id: 1, name: "project-1", path: "project-1", visibility_level: 0, namespace_id: 1)
+ projects.create!(id: 2, name: "project-2", path: "project-2", visibility_level: 0, namespace_id: 1)
issues.create(id: 1, project_id: 1)
issues.create(id: 2, project_id: 2)
@@ -35,13 +35,13 @@ describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema:
subject { described_class.new.perform(2, 5) }
- context 'when a project is private' do
- it 'removes todos of users without project access' do
+ context "when a project is private" do
+ it "removes todos of users without project access" do
expect { subject }.to change { Todo.count }.from(4).to(3)
end
- context 'with a confidential issue' do
- it 'removes todos of users without project access and guests for confidential issues' do
+ context "with a confidential issue" do
+ it "removes todos of users without project access and guests for confidential issues" do
issues.create(id: 3, project_id: 2, confidential: true)
issues.create(id: 4, project_id: 1, confidential: true) # not in the batch
todos.create(todo_params.merge(user_id: 3, project_id: 2, target_id: 3))
@@ -53,21 +53,21 @@ describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema:
end
end
- context 'when a project is public' do
+ context "when a project is public" do
before do
projects.find(2).update_attribute(:visibility_level, 20)
end
- context 'when all features have the same visibility as the project, no confidential issues' do
- it 'does not remove any todos' do
+ context "when all features have the same visibility as the project, no confidential issues" do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'with confidential issues' do
+ context "with confidential issues" do
before do
- users.create(id: 4, email: 'author@example.com', projects_limit: 10)
- users.create(id: 5, email: 'assignee@example.com', projects_limit: 10)
+ users.create(id: 4, email: "author@example.com", projects_limit: 10)
+ users.create(id: 5, email: "assignee@example.com", projects_limit: 10)
issues.create(id: 3, project_id: 2, confidential: true, author_id: 4)
assignees.create(user_id: 5, issue_id: 3)
@@ -78,44 +78,44 @@ describe Gitlab::BackgroundMigration::RemoveRestrictedTodos, :migration, schema:
todos.create(todo_params.merge(user_id: 5, project_id: 2, target_id: 3)) # conf issue assignee
end
- it 'removes confidential issue todos for non authorized users' do
+ it "removes confidential issue todos for non authorized users" do
expect { subject }.to change { Todo.count }.from(9).to(7)
end
end
- context 'features visibility restrictions' do
+ context "features visibility restrictions" do
before do
todo_params.merge!(project_id: 2, user_id: 1, target_id: 3)
- todos.create(todo_params.merge(user_id: 1, target_id: 3, target_type: 'MergeRequest'))
- todos.create(todo_params.merge(user_id: 1, target_id: 3, target_type: 'Commit'))
+ todos.create(todo_params.merge(user_id: 1, target_id: 3, target_type: "MergeRequest"))
+ todos.create(todo_params.merge(user_id: 1, target_id: 3, target_type: "Commit"))
end
- context 'when issues are restricted to project members' do
+ context "when issues are restricted to project members" do
before do
project_features.create(issues_access_level: 10, project_id: 2)
end
- it 'removes non members issue todos' do
+ it "removes non members issue todos" do
expect { subject }.to change { Todo.count }.from(6).to(5)
end
end
- context 'when merge requests are restricted to project members' do
+ context "when merge requests are restricted to project members" do
before do
project_features.create(merge_requests_access_level: 10, project_id: 2)
end
- it 'removes non members issue todos' do
+ it "removes non members issue todos" do
expect { subject }.to change { Todo.count }.from(6).to(5)
end
end
- context 'when repository and merge requests are restricted to project members' do
+ context "when repository and merge requests are restricted to project members" do
before do
project_features.create(repository_access_level: 10, merge_requests_access_level: 10, project_id: 2)
end
- it 'removes non members commit and merge requests todos' do
+ it "removes non members commit and merge requests todos" do
expect { subject }.to change { Todo.count }.from(6).to(4)
end
end
diff --git a/spec/lib/gitlab/background_migration/rollback_import_state_data_spec.rb b/spec/lib/gitlab/background_migration/rollback_import_state_data_spec.rb
index cef3b6e4568..68de80f88f2 100644
--- a/spec/lib/gitlab/background_migration/rollback_import_state_data_spec.rb
+++ b/spec/lib/gitlab/background_migration/rollback_import_state_data_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::RollbackImportStateData, :migration, schema: 20180502134117 do
let(:migration) { described_class.new }
@@ -7,10 +7,10 @@ describe Gitlab::BackgroundMigration::RollbackImportStateData, :migration, schem
let(:import_state) { table(:project_mirror_data) }
before do
- namespaces.create(id: 1, name: 'gitlab-org', path: 'gitlab-org')
+ namespaces.create(id: 1, name: "gitlab-org", path: "gitlab-org")
- projects.create!(id: 1, namespace_id: 1, name: 'gitlab1', import_url: generate(:url))
- projects.create!(id: 2, namespace_id: 1, name: 'gitlab2', path: 'gitlab2', import_url: generate(:url))
+ projects.create!(id: 1, namespace_id: 1, name: "gitlab1", import_url: generate(:url))
+ projects.create!(id: 2, namespace_id: 1, name: "gitlab2", path: "gitlab2", import_url: generate(:url))
import_state.create!(id: 1, project_id: 1, status: :started, last_error: "foo")
import_state.create!(id: 2, project_id: 2, status: :failed)
diff --git a/spec/lib/gitlab/background_migration/schedule_diff_files_deletion_spec.rb b/spec/lib/gitlab/background_migration/schedule_diff_files_deletion_spec.rb
index ec8ba0ce127..6b37a58d3c7 100644
--- a/spec/lib/gitlab/background_migration/schedule_diff_files_deletion_spec.rb
+++ b/spec/lib/gitlab/background_migration/schedule_diff_files_deletion_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::ScheduleDiffFilesDeletion, :migration, :sidekiq, schema: 20180619121030 do
- describe '#perform' do
+ describe "#perform" do
let(:merge_request_diffs) { table(:merge_request_diffs) }
let(:merge_requests) { table(:merge_requests) }
let(:namespaces) { table(:namespaces) }
@@ -10,23 +10,23 @@ describe Gitlab::BackgroundMigration::ScheduleDiffFilesDeletion, :migration, :si
before do
stub_const("#{described_class.name}::DIFF_BATCH_SIZE", 3)
- namespaces.create!(id: 1, name: 'gitlab', path: 'gitlab')
- projects.create!(id: 1, namespace_id: 1, name: 'gitlab', path: 'gitlab')
+ namespaces.create!(id: 1, name: "gitlab", path: "gitlab")
+ projects.create!(id: 1, namespace_id: 1, name: "gitlab", path: "gitlab")
- merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: 'feature', source_branch: 'master', state: 'merged')
+ merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: "feature", source_branch: "master", state: "merged")
- merge_request_diffs.create!(id: 1, merge_request_id: 1, state: 'collected')
- merge_request_diffs.create!(id: 2, merge_request_id: 1, state: 'empty')
- merge_request_diffs.create!(id: 3, merge_request_id: 1, state: 'without_files')
- merge_request_diffs.create!(id: 4, merge_request_id: 1, state: 'collected')
- merge_request_diffs.create!(id: 5, merge_request_id: 1, state: 'collected')
- merge_request_diffs.create!(id: 6, merge_request_id: 1, state: 'collected')
- merge_request_diffs.create!(id: 7, merge_request_id: 1, state: 'collected')
+ merge_request_diffs.create!(id: 1, merge_request_id: 1, state: "collected")
+ merge_request_diffs.create!(id: 2, merge_request_id: 1, state: "empty")
+ merge_request_diffs.create!(id: 3, merge_request_id: 1, state: "without_files")
+ merge_request_diffs.create!(id: 4, merge_request_id: 1, state: "collected")
+ merge_request_diffs.create!(id: 5, merge_request_id: 1, state: "collected")
+ merge_request_diffs.create!(id: 6, merge_request_id: 1, state: "collected")
+ merge_request_diffs.create!(id: 7, merge_request_id: 1, state: "collected")
merge_requests.update(1, latest_merge_request_diff_id: 7)
end
- it 'correctly schedules diff file deletion workers' do
+ it "correctly schedules diff file deletion workers" do
Sidekiq::Testing.fake! do
Timecop.freeze do
described_class.new.perform
diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb
index 6f3fb994f17..7c13d5c8d87 100644
--- a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb
+++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migration, schema: 20180122154930 do
let(:services) { table(:services) }
- describe '#perform' do
- it 'migrates services where note_events is true' do
+ describe "#perform" do
+ it "migrates services where note_events is true" do
service = services.create(confidential_note_events: nil, note_events: true)
subject.perform(service.id, service.id)
@@ -12,7 +12,7 @@ describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migr
expect(service.reload.confidential_note_events).to eq(true)
end
- it 'ignores services where note_events is false' do
+ it "ignores services where note_events is false" do
service = services.create(confidential_note_events: nil, note_events: false)
subject.perform(service.id, service.id)
@@ -20,7 +20,7 @@ describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migr
expect(service.reload.confidential_note_events).to eq(nil)
end
- it 'ignores services where confidential_note_events has already been set' do
+ it "ignores services where confidential_note_events has already been set" do
service = services.create(confidential_note_events: false, note_events: true)
subject.perform(service.id, service.id)
diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb
index 82b484b7d5b..c79a815ce51 100644
--- a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb
+++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migration, schema: 20180104131052 do
let(:web_hooks) { table(:web_hooks) }
- describe '#perform' do
- it 'migrates hooks where note_events is true' do
+ describe "#perform" do
+ it "migrates hooks where note_events is true" do
hook = web_hooks.create(confidential_note_events: nil, note_events: true)
subject.perform(hook.id, hook.id)
@@ -12,7 +12,7 @@ describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migr
expect(hook.reload.confidential_note_events).to eq(true)
end
- it 'ignores hooks where note_events is false' do
+ it "ignores hooks where note_events is false" do
hook = web_hooks.create(confidential_note_events: nil, note_events: false)
subject.perform(hook.id, hook.id)
@@ -20,7 +20,7 @@ describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migr
expect(hook.reload.confidential_note_events).to eq(nil)
end
- it 'ignores hooks where confidential_note_events has already been set' do
+ it "ignores hooks where confidential_note_events has already been set" do
hook = web_hooks.create(confidential_note_events: false, note_events: true)
subject.perform(hook.id, hook.id)
diff --git a/spec/lib/gitlab/background_migration_spec.rb b/spec/lib/gitlab/background_migration_spec.rb
index 7d3d8a949ef..f9e8d7ad844 100644
--- a/spec/lib/gitlab/background_migration_spec.rb
+++ b/spec/lib/gitlab/background_migration_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BackgroundMigration do
- describe '.queue' do
- it 'returns background migration worker queue' do
+ describe ".queue" do
+ it "returns background migration worker queue" do
expect(described_class.queue)
- .to eq BackgroundMigrationWorker.sidekiq_options['queue']
+ .to eq BackgroundMigrationWorker.sidekiq_options["queue"]
end
end
- describe '.steal' do
- context 'when there are enqueued jobs present' do
+ describe ".steal" do
+ context "when there are enqueued jobs present" do
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ [double(args: ["Foo", [10, 20]], queue: described_class.queue)]
end
before do
@@ -20,39 +20,39 @@ describe Gitlab::BackgroundMigration do
.and_return(queue)
end
- context 'when queue contains unprocessed jobs' do
- it 'steals jobs from a queue' do
+ context "when queue contains unprocessed jobs" do
+ it "steals jobs from a queue" do
expect(queue[0]).to receive(:delete).and_return(true)
expect(described_class).to receive(:perform)
- .with('Foo', [10, 20])
+ .with("Foo", [10, 20])
- described_class.steal('Foo')
+ described_class.steal("Foo")
end
- it 'does not steal job that has already been taken' do
+ it "does not steal job that has already been taken" do
expect(queue[0]).to receive(:delete).and_return(false)
expect(described_class).not_to receive(:perform)
- described_class.steal('Foo')
+ described_class.steal("Foo")
end
- it 'does not steal jobs for a different migration' do
+ it "does not steal jobs for a different migration" do
expect(described_class).not_to receive(:perform)
expect(queue[0]).not_to receive(:delete)
- described_class.steal('Bar')
+ described_class.steal("Bar")
end
end
- context 'when one of the jobs raises an error' do
+ context "when one of the jobs raises an error" do
let(:migration) { spy(:migration) }
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue),
- double(args: ['Foo', [20, 30]], queue: described_class.queue)]
+ [double(args: ["Foo", [10, 20]], queue: described_class.queue),
+ double(args: ["Foo", [20, 30]], queue: described_class.queue),]
end
before do
@@ -62,55 +62,55 @@ describe Gitlab::BackgroundMigration do
allow(queue[1]).to receive(:delete).and_return(true)
end
- it 'enqueues the migration again and re-raises the error' do
+ it "enqueues the migration again and re-raises the error" do
allow(migration).to receive(:perform).with(10, 20)
- .and_raise(Exception, 'Migration error').once
+ .and_raise(Exception, "Migration error").once
expect(BackgroundMigrationWorker).to receive(:perform_async)
- .with('Foo', [10, 20]).once
+ .with("Foo", [10, 20]).once
- expect { described_class.steal('Foo') }.to raise_error(Exception)
+ expect { described_class.steal("Foo") }.to raise_error(Exception)
end
end
end
- context 'when there are scheduled jobs present', :sidekiq, :redis do
- it 'steals all jobs from the scheduled sets' do
+ context "when there are scheduled jobs present", :sidekiq, :redis do
+ it "steals all jobs from the scheduled sets" do
Sidekiq::Testing.disable! do
- BackgroundMigrationWorker.perform_in(10.minutes, 'Object')
+ BackgroundMigrationWorker.perform_in(10.minutes, "Object")
expect(Sidekiq::ScheduledSet.new).to be_one
- expect(described_class).to receive(:perform).with('Object', any_args)
+ expect(described_class).to receive(:perform).with("Object", any_args)
- described_class.steal('Object')
+ described_class.steal("Object")
expect(Sidekiq::ScheduledSet.new).to be_none
end
end
end
- context 'when there are enqueued and scheduled jobs present', :sidekiq, :redis do
- it 'steals from the scheduled sets queue first' do
+ context "when there are enqueued and scheduled jobs present", :sidekiq, :redis do
+ it "steals from the scheduled sets queue first" do
Sidekiq::Testing.disable! do
expect(described_class).to receive(:perform)
- .with('Object', [1]).ordered
+ .with("Object", [1]).ordered
expect(described_class).to receive(:perform)
- .with('Object', [2]).ordered
+ .with("Object", [2]).ordered
- BackgroundMigrationWorker.perform_async('Object', [2])
- BackgroundMigrationWorker.perform_in(10.minutes, 'Object', [1])
+ BackgroundMigrationWorker.perform_async("Object", [2])
+ BackgroundMigrationWorker.perform_in(10.minutes, "Object", [1])
- described_class.steal('Object')
+ described_class.steal("Object")
end
end
end
- context 'when retry_dead_jobs is true', :sidekiq, :redis do
+ context "when retry_dead_jobs is true", :sidekiq, :redis do
let(:retry_queue) do
- [double(args: ['Object', [3]], queue: described_class.queue, delete: true)]
+ [double(args: ["Object", [3]], queue: described_class.queue, delete: true)]
end
let(:dead_queue) do
- [double(args: ['Object', [4]], queue: described_class.queue, delete: true)]
+ [double(args: ["Object", [4]], queue: described_class.queue, delete: true)]
end
before do
@@ -118,44 +118,44 @@ describe Gitlab::BackgroundMigration do
allow(Sidekiq::DeadSet).to receive(:new).and_return(dead_queue)
end
- it 'steals from the dead and retry queue' do
+ it "steals from the dead and retry queue" do
Sidekiq::Testing.disable! do
expect(described_class).to receive(:perform)
- .with('Object', [1]).ordered
+ .with("Object", [1]).ordered
expect(described_class).to receive(:perform)
- .with('Object', [2]).ordered
+ .with("Object", [2]).ordered
expect(described_class).to receive(:perform)
- .with('Object', [3]).ordered
+ .with("Object", [3]).ordered
expect(described_class).to receive(:perform)
- .with('Object', [4]).ordered
+ .with("Object", [4]).ordered
- BackgroundMigrationWorker.perform_async('Object', [2])
- BackgroundMigrationWorker.perform_in(10.minutes, 'Object', [1])
+ BackgroundMigrationWorker.perform_async("Object", [2])
+ BackgroundMigrationWorker.perform_in(10.minutes, "Object", [1])
- described_class.steal('Object', retry_dead_jobs: true)
+ described_class.steal("Object", retry_dead_jobs: true)
end
end
end
end
- describe '.perform' do
+ describe ".perform" do
let(:migration) { spy(:migration) }
before do
stub_const("#{described_class.name}::Foo", migration)
end
- it 'performs a background migration' do
+ it "performs a background migration" do
expect(migration).to receive(:perform).with(10, 20).once
- described_class.perform('Foo', [10, 20])
+ described_class.perform("Foo", [10, 20])
end
end
- describe '.exists?' do
- context 'when there are enqueued jobs present' do
+ describe ".exists?" do
+ context "when there are enqueued jobs present" do
let(:queue) do
- [double(args: ['Foo', [10, 20]], queue: described_class.queue)]
+ [double(args: ["Foo", [10, 20]], queue: described_class.queue)]
end
before do
@@ -164,19 +164,19 @@ describe Gitlab::BackgroundMigration do
.and_return(queue)
end
- it 'returns true if specific job exists' do
- expect(described_class.exists?('Foo')).to eq(true)
+ it "returns true if specific job exists" do
+ expect(described_class.exists?("Foo")).to eq(true)
end
- it 'returns false if specific job does not exist' do
- expect(described_class.exists?('Bar')).to eq(false)
+ it "returns false if specific job does not exist" do
+ expect(described_class.exists?("Bar")).to eq(false)
end
end
- context 'when there are scheduled jobs present', :sidekiq, :redis do
+ context "when there are scheduled jobs present", :sidekiq, :redis do
before do
Sidekiq::Testing.disable! do
- BackgroundMigrationWorker.perform_in(10.minutes, 'Foo')
+ BackgroundMigrationWorker.perform_in(10.minutes, "Foo")
expect(Sidekiq::ScheduledSet.new).to be_one
end
@@ -186,12 +186,12 @@ describe Gitlab::BackgroundMigration do
Sidekiq::ScheduledSet.new.clear
end
- it 'returns true if specific job exists' do
- expect(described_class.exists?('Foo')).to eq(true)
+ it "returns true if specific job exists" do
+ expect(described_class.exists?("Foo")).to eq(true)
end
- it 'returns false if specific job does not exist' do
- expect(described_class.exists?('Bar')).to eq(false)
+ it "returns false if specific job does not exist" do
+ expect(described_class.exists?("Bar")).to eq(false)
end
end
end
diff --git a/spec/lib/gitlab/badge/coverage/metadata_spec.rb b/spec/lib/gitlab/badge/coverage/metadata_spec.rb
index 74eaf7eaf8b..2464ddac461 100644
--- a/spec/lib/gitlab/badge/coverage/metadata_spec.rb
+++ b/spec/lib/gitlab/badge/coverage/metadata_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
-require 'lib/gitlab/badge/shared/metadata'
+require "spec_helper"
+require "lib/gitlab/badge/shared/metadata"
describe Gitlab::Badge::Coverage::Metadata do
let(:badge) do
- double(project: create(:project), ref: 'feature', job: 'test')
+ double(project: create(:project), ref: "feature", job: "test")
end
let(:metadata) { described_class.new(badge) }
- it_behaves_like 'badge metadata'
+ it_behaves_like "badge metadata"
- describe '#title' do
- it 'returns coverage report title' do
- expect(metadata.title).to eq 'coverage report'
+ describe "#title" do
+ it "returns coverage report title" do
+ expect(metadata.title).to eq "coverage report"
end
end
- describe '#image_url' do
- it 'returns valid url' do
- expect(metadata.image_url).to include 'badges/feature/coverage.svg'
+ describe "#image_url" do
+ it "returns valid url" do
+ expect(metadata.image_url).to include "badges/feature/coverage.svg"
end
end
- describe '#link_url' do
- it 'returns valid link' do
- expect(metadata.link_url).to include 'commits/feature'
+ describe "#link_url" do
+ it "returns valid link" do
+ expect(metadata.link_url).to include "commits/feature"
end
end
end
diff --git a/spec/lib/gitlab/badge/coverage/report_spec.rb b/spec/lib/gitlab/badge/coverage/report_spec.rb
index da789bf3705..0cb306030f8 100644
--- a/spec/lib/gitlab/badge/coverage/report_spec.rb
+++ b/spec/lib/gitlab/badge/coverage/report_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Badge::Coverage::Report do
let(:project) { create(:project, :repository) }
let(:job_name) { nil }
let(:badge) do
- described_class.new(project, 'master', job_name)
+ described_class.new(project, "master", job_name)
end
- describe '#entity' do
- it 'describes a coverage' do
- expect(badge.entity).to eq 'coverage'
+ describe "#entity" do
+ it "describes a coverage" do
+ expect(badge.entity).to eq "coverage"
end
end
- describe '#metadata' do
- it 'returns correct metadata' do
- expect(badge.metadata.image_url).to include 'coverage.svg'
+ describe "#metadata" do
+ it "returns correct metadata" do
+ expect(badge.metadata.image_url).to include "coverage.svg"
end
end
- describe '#template' do
- it 'returns correct template' do
- expect(badge.template.key_text).to eq 'coverage'
+ describe "#template" do
+ it "returns correct template" do
+ expect(badge.template.key_text).to eq "coverage"
end
end
- shared_examples 'unknown coverage report' do
- context 'particular job specified' do
- let(:job_name) { '' }
+ shared_examples "unknown coverage report" do
+ context "particular job specified" do
+ let(:job_name) { "" }
- it 'returns nil' do
+ it "returns nil" do
expect(badge.status).to be_nil
end
end
- context 'particular job not specified' do
+ context "particular job not specified" do
let(:job_name) { nil }
- it 'returns nil' do
+ it "returns nil" do
expect(badge.status).to be_nil
end
end
end
- context 'when latest successful pipeline exists' do
+ context "when latest successful pipeline exists" do
before do
create_pipeline do |pipeline|
- create(:ci_build, :success, pipeline: pipeline, name: 'first', coverage: 40)
+ create(:ci_build, :success, pipeline: pipeline, name: "first", coverage: 40)
create(:ci_build, :success, pipeline: pipeline, coverage: 60)
end
@@ -56,47 +56,47 @@ describe Gitlab::Badge::Coverage::Report do
end
end
- context 'when particular job specified' do
- let(:job_name) { 'first' }
+ context "when particular job specified" do
+ let(:job_name) { "first" }
- it 'returns coverage for the particular job' do
+ it "returns coverage for the particular job" do
expect(badge.status).to eq 40
end
end
- context 'when particular job not specified' do
- let(:job_name) { '' }
+ context "when particular job not specified" do
+ let(:job_name) { "" }
- it 'returns arithemetic mean for the pipeline' do
+ it "returns arithemetic mean for the pipeline" do
expect(badge.status).to eq 50
end
end
end
- context 'when only failed pipeline exists' do
+ context "when only failed pipeline exists" do
before do
create_pipeline do |pipeline|
create(:ci_build, :failed, pipeline: pipeline, coverage: 10)
end
end
- it_behaves_like 'unknown coverage report'
+ it_behaves_like "unknown coverage report"
- context 'particular job specified' do
- let(:job_name) { 'nonexistent' }
+ context "particular job specified" do
+ let(:job_name) { "nonexistent" }
- it 'retruns nil' do
+ it "retruns nil" do
expect(badge.status).to be_nil
end
end
end
- context 'pipeline does not exist' do
- it_behaves_like 'unknown coverage report'
+ context "pipeline does not exist" do
+ it_behaves_like "unknown coverage report"
end
def create_pipeline
- opts = { project: project, sha: project.commit.id, ref: 'master' }
+ opts = {project: project, sha: project.commit.id, ref: "master"}
create(:ci_pipeline, opts).tap do |pipeline|
yield pipeline
diff --git a/spec/lib/gitlab/badge/coverage/template_spec.rb b/spec/lib/gitlab/badge/coverage/template_spec.rb
index d9c21a22590..49acaa75b46 100644
--- a/spec/lib/gitlab/badge/coverage/template_spec.rb
+++ b/spec/lib/gitlab/badge/coverage/template_spec.rb
@@ -1,138 +1,138 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Badge::Coverage::Template do
- let(:badge) { double(entity: 'coverage', status: 90.00) }
+ let(:badge) { double(entity: "coverage", status: 90.00) }
let(:template) { described_class.new(badge) }
- describe '#key_text' do
- it 'is always says coverage' do
- expect(template.key_text).to eq 'coverage'
+ describe "#key_text" do
+ it "is always says coverage" do
+ expect(template.key_text).to eq "coverage"
end
end
- describe '#value_text' do
- context 'when coverage is known' do
- it 'returns coverage percentage' do
- expect(template.value_text).to eq '90.00%'
+ describe "#value_text" do
+ context "when coverage is known" do
+ it "returns coverage percentage" do
+ expect(template.value_text).to eq "90.00%"
end
end
- context 'when coverage is known to many digits' do
+ context "when coverage is known to many digits" do
before do
allow(badge).to receive(:status).and_return(92.349)
end
- it 'returns rounded coverage percentage' do
- expect(template.value_text).to eq '92.35%'
+ it "returns rounded coverage percentage" do
+ expect(template.value_text).to eq "92.35%"
end
end
- context 'when coverage is unknown' do
+ context "when coverage is unknown" do
before do
allow(badge).to receive(:status).and_return(nil)
end
- it 'returns string that says coverage is unknown' do
- expect(template.value_text).to eq 'unknown'
+ it "returns string that says coverage is unknown" do
+ expect(template.value_text).to eq "unknown"
end
end
end
- describe '#key_width' do
- it 'has a fixed key width' do
+ describe "#key_width" do
+ it "has a fixed key width" do
expect(template.key_width).to eq 62
end
end
- describe '#value_width' do
- context 'when coverage is known' do
- it 'is narrower when coverage is known' do
+ describe "#value_width" do
+ context "when coverage is known" do
+ it "is narrower when coverage is known" do
expect(template.value_width).to eq 54
end
end
- context 'when coverage is unknown' do
+ context "when coverage is unknown" do
before do
allow(badge).to receive(:status).and_return(nil)
end
- it 'is wider when coverage is unknown to fit text' do
+ it "is wider when coverage is unknown to fit text" do
expect(template.value_width).to eq 58
end
end
end
- describe '#key_color' do
- it 'always has the same color' do
- expect(template.key_color).to eq '#555'
+ describe "#key_color" do
+ it "always has the same color" do
+ expect(template.key_color).to eq "#555"
end
end
- describe '#value_color' do
- context 'when coverage is good' do
+ describe "#value_color" do
+ context "when coverage is good" do
before do
allow(badge).to receive(:status).and_return(98)
end
- it 'is green' do
- expect(template.value_color).to eq '#4c1'
+ it "is green" do
+ expect(template.value_color).to eq "#4c1"
end
end
- context 'when coverage is acceptable' do
+ context "when coverage is acceptable" do
before do
allow(badge).to receive(:status).and_return(90)
end
- it 'is green-orange' do
- expect(template.value_color).to eq '#a3c51c'
+ it "is green-orange" do
+ expect(template.value_color).to eq "#a3c51c"
end
end
- context 'when coverage is medium' do
+ context "when coverage is medium" do
before do
allow(badge).to receive(:status).and_return(75)
end
- it 'is orange-yellow' do
- expect(template.value_color).to eq '#dfb317'
+ it "is orange-yellow" do
+ expect(template.value_color).to eq "#dfb317"
end
end
- context 'when coverage is low' do
+ context "when coverage is low" do
before do
allow(badge).to receive(:status).and_return(50)
end
- it 'is red' do
- expect(template.value_color).to eq '#e05d44'
+ it "is red" do
+ expect(template.value_color).to eq "#e05d44"
end
end
- context 'when coverage is unknown' do
+ context "when coverage is unknown" do
before do
allow(badge).to receive(:status).and_return(nil)
end
- it 'is grey' do
- expect(template.value_color).to eq '#9f9f9f'
+ it "is grey" do
+ expect(template.value_color).to eq "#9f9f9f"
end
end
end
- describe '#width' do
- context 'when coverage is known' do
- it 'returns the key width plus value width' do
+ describe "#width" do
+ context "when coverage is known" do
+ it "returns the key width plus value width" do
expect(template.width).to eq 116
end
end
- context 'when coverage is unknown' do
+ context "when coverage is unknown" do
before do
allow(badge).to receive(:status).and_return(nil)
end
- it 'returns key width plus wider value width' do
+ it "returns key width plus wider value width" do
expect(template.width).to eq 120
end
end
diff --git a/spec/lib/gitlab/badge/pipeline/metadata_spec.rb b/spec/lib/gitlab/badge/pipeline/metadata_spec.rb
index 9032a8e9016..71948967b9a 100644
--- a/spec/lib/gitlab/badge/pipeline/metadata_spec.rb
+++ b/spec/lib/gitlab/badge/pipeline/metadata_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
-require 'lib/gitlab/badge/shared/metadata'
+require "spec_helper"
+require "lib/gitlab/badge/shared/metadata"
describe Gitlab::Badge::Pipeline::Metadata do
- let(:badge) { double(project: create(:project), ref: 'feature') }
+ let(:badge) { double(project: create(:project), ref: "feature") }
let(:metadata) { described_class.new(badge) }
- it_behaves_like 'badge metadata'
+ it_behaves_like "badge metadata"
- describe '#title' do
- it 'returns build status title' do
- expect(metadata.title).to eq 'pipeline status'
+ describe "#title" do
+ it "returns build status title" do
+ expect(metadata.title).to eq "pipeline status"
end
end
- describe '#image_url' do
- it 'returns valid url' do
- expect(metadata.image_url).to include 'badges/feature/pipeline.svg'
+ describe "#image_url" do
+ it "returns valid url" do
+ expect(metadata.image_url).to include "badges/feature/pipeline.svg"
end
end
- describe '#link_url' do
- it 'returns valid link' do
- expect(metadata.link_url).to include 'commits/feature'
+ describe "#link_url" do
+ it "returns valid link" do
+ expect(metadata.link_url).to include "commits/feature"
end
end
end
diff --git a/spec/lib/gitlab/badge/pipeline/status_spec.rb b/spec/lib/gitlab/badge/pipeline/status_spec.rb
index dc835375c66..8c603c5c432 100644
--- a/spec/lib/gitlab/badge/pipeline/status_spec.rb
+++ b/spec/lib/gitlab/badge/pipeline/status_spec.rb
@@ -1,70 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Badge::Pipeline::Status do
let(:project) { create(:project, :repository) }
let(:sha) { project.commit.sha }
- let(:branch) { 'master' }
+ let(:branch) { "master" }
let(:badge) { described_class.new(project, branch) }
- describe '#entity' do
- it 'always says pipeline' do
- expect(badge.entity).to eq 'pipeline'
+ describe "#entity" do
+ it "always says pipeline" do
+ expect(badge.entity).to eq "pipeline"
end
end
- describe '#template' do
- it 'returns badge template' do
- expect(badge.template.key_text).to eq 'pipeline'
+ describe "#template" do
+ it "returns badge template" do
+ expect(badge.template.key_text).to eq "pipeline"
end
end
- describe '#metadata' do
- it 'returns badge metadata' do
- expect(badge.metadata.image_url).to include 'badges/master/pipeline.svg'
+ describe "#metadata" do
+ it "returns badge metadata" do
+ expect(badge.metadata.image_url).to include "badges/master/pipeline.svg"
end
end
- context 'pipeline exists' do
+ context "pipeline exists" do
let!(:pipeline) { create_pipeline(project, sha, branch) }
- context 'pipeline success' do
+ context "pipeline success" do
before do
pipeline.success!
end
- describe '#status' do
- it 'is successful' do
- expect(badge.status).to eq 'success'
+ describe "#status" do
+ it "is successful" do
+ expect(badge.status).to eq "success"
end
end
end
- context 'pipeline failed' do
+ context "pipeline failed" do
before do
pipeline.drop!
end
- describe '#status' do
- it 'failed' do
- expect(badge.status).to eq 'failed'
+ describe "#status" do
+ it "failed" do
+ expect(badge.status).to eq "failed"
end
end
end
- context 'when outdated pipeline for given ref exists' do
+ context "when outdated pipeline for given ref exists" do
before do
pipeline.success!
- old_pipeline = create_pipeline(project, '11eeffdd', branch)
+ old_pipeline = create_pipeline(project, "11eeffdd", branch)
old_pipeline.drop!
end
- it 'does not take outdated pipeline into account' do
- expect(badge.status).to eq 'success'
+ it "does not take outdated pipeline into account" do
+ expect(badge.status).to eq "success"
end
end
- context 'when multiple pipelines exist for given sha' do
+ context "when multiple pipelines exist for given sha" do
before do
pipeline.drop!
@@ -72,26 +72,26 @@ describe Gitlab::Badge::Pipeline::Status do
new_pipeline.success!
end
- it 'does not take outdated pipeline into account' do
- expect(badge.status).to eq 'success'
+ it "does not take outdated pipeline into account" do
+ expect(badge.status).to eq "success"
end
end
end
- context 'build does not exist' do
- describe '#status' do
- it 'is unknown' do
- expect(badge.status).to eq 'unknown'
+ context "build does not exist" do
+ describe "#status" do
+ it "is unknown" do
+ expect(badge.status).to eq "unknown"
end
end
end
def create_pipeline(project, sha, branch)
pipeline = create(:ci_empty_pipeline,
- project: project,
- sha: sha,
- ref: branch)
+ project: project,
+ sha: sha,
+ ref: branch)
- create(:ci_build, pipeline: pipeline, stage: 'notify')
+ create(:ci_build, pipeline: pipeline, stage: "notify")
end
end
diff --git a/spec/lib/gitlab/badge/pipeline/template_spec.rb b/spec/lib/gitlab/badge/pipeline/template_spec.rb
index 20fa4f879c3..bfb98fadf71 100644
--- a/spec/lib/gitlab/badge/pipeline/template_spec.rb
+++ b/spec/lib/gitlab/badge/pipeline/template_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Badge::Pipeline::Template do
- let(:badge) { double(entity: 'pipeline', status: 'success') }
+ let(:badge) { double(entity: "pipeline", status: "success") }
let(:template) { described_class.new(badge) }
- describe '#key_text' do
- it 'is always says pipeline' do
- expect(template.key_text).to eq 'pipeline'
+ describe "#key_text" do
+ it "is always says pipeline" do
+ expect(template.key_text).to eq "pipeline"
end
end
- describe '#value_text' do
- it 'is status value' do
- expect(template.value_text).to eq 'passed'
+ describe "#value_text" do
+ it "is status value" do
+ expect(template.value_text).to eq "passed"
end
end
- describe 'widths and text anchors' do
- it 'has fixed width and text anchors' do
+ describe "widths and text anchors" do
+ it "has fixed width and text anchors" do
expect(template.width).to eq 116
expect(template.key_width).to eq 62
expect(template.value_width).to eq 54
@@ -26,56 +26,56 @@ describe Gitlab::Badge::Pipeline::Template do
end
end
- describe '#key_color' do
- it 'is always the same' do
- expect(template.key_color).to eq '#555'
+ describe "#key_color" do
+ it "is always the same" do
+ expect(template.key_color).to eq "#555"
end
end
- describe '#value_color' do
- context 'when status is success' do
- it 'has expected color' do
- expect(template.value_color).to eq '#4c1'
+ describe "#value_color" do
+ context "when status is success" do
+ it "has expected color" do
+ expect(template.value_color).to eq "#4c1"
end
end
- context 'when status is failed' do
+ context "when status is failed" do
before do
- allow(badge).to receive(:status).and_return('failed')
+ allow(badge).to receive(:status).and_return("failed")
end
- it 'has expected color' do
- expect(template.value_color).to eq '#e05d44'
+ it "has expected color" do
+ expect(template.value_color).to eq "#e05d44"
end
end
- context 'when status is running' do
+ context "when status is running" do
before do
- allow(badge).to receive(:status).and_return('running')
+ allow(badge).to receive(:status).and_return("running")
end
- it 'has expected color' do
- expect(template.value_color).to eq '#dfb317'
+ it "has expected color" do
+ expect(template.value_color).to eq "#dfb317"
end
end
- context 'when status is unknown' do
+ context "when status is unknown" do
before do
- allow(badge).to receive(:status).and_return('unknown')
+ allow(badge).to receive(:status).and_return("unknown")
end
- it 'has expected color' do
- expect(template.value_color).to eq '#9f9f9f'
+ it "has expected color" do
+ expect(template.value_color).to eq "#9f9f9f"
end
end
- context 'when status does not match any known statuses' do
+ context "when status does not match any known statuses" do
before do
- allow(badge).to receive(:status).and_return('invalid')
+ allow(badge).to receive(:status).and_return("invalid")
end
- it 'has expected color' do
- expect(template.value_color).to eq '#9f9f9f'
+ it "has expected color" do
+ expect(template.value_color).to eq "#9f9f9f"
end
end
end
diff --git a/spec/lib/gitlab/badge/shared/metadata.rb b/spec/lib/gitlab/badge/shared/metadata.rb
index 63c7ca5a915..32cb4d2c271 100644
--- a/spec/lib/gitlab/badge/shared/metadata.rb
+++ b/spec/lib/gitlab/badge/shared/metadata.rb
@@ -1,31 +1,31 @@
-shared_examples 'badge metadata' do
- describe '#to_html' do
+shared_examples "badge metadata" do
+ describe "#to_html" do
let(:html) { Nokogiri::HTML.parse(metadata.to_html) }
- let(:a_href) { html.at('a') }
+ let(:a_href) { html.at("a") }
- it 'points to link' do
+ it "points to link" do
expect(a_href[:href]).to eq metadata.link_url
end
- it 'contains clickable image' do
- expect(a_href.children.first.name).to eq 'img'
+ it "contains clickable image" do
+ expect(a_href.children.first.name).to eq "img"
end
end
- describe '#to_markdown' do
+ describe "#to_markdown" do
subject { metadata.to_markdown }
it { is_expected.to include metadata.image_url }
it { is_expected.to include metadata.link_url }
end
- describe '#to_asciidoc' do
+ describe "#to_asciidoc" do
subject { metadata.to_asciidoc }
it { is_expected.to include metadata.image_url }
it { is_expected.to include metadata.link_url }
- it { is_expected.to include 'image:' }
- it { is_expected.to include 'link=' }
- it { is_expected.to include 'title=' }
+ it { is_expected.to include "image:" }
+ it { is_expected.to include "link=" }
+ it { is_expected.to include "title=" }
end
end
diff --git a/spec/lib/gitlab/bare_repository_import/importer_spec.rb b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
index f4759b69538..a4f47e2d1d8 100644
--- a/spec/lib/gitlab/bare_repository_import/importer_spec.rb
+++ b/spec/lib/gitlab/bare_repository_import/importer_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
let!(:admin) { create(:admin) }
- let!(:base_dir) { Dir.mktmpdir + '/' }
+ let!(:base_dir) { Dir.mktmpdir + "/" }
let(:bare_repository) { Gitlab::BareRepositoryImport::Repository.new(base_dir, File.join(base_dir, "#{project_path}.git")) }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:source_project) { TEST_REPO_PATH }
@@ -19,9 +19,9 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
ensure_seeds
end
- shared_examples 'importing a repository' do
- describe '.execute' do
- it 'creates a project for a repository in storage' do
+ shared_examples "importing a repository" do
+ describe ".execute" do
+ it "creates a project for a repository in storage" do
FileUtils.mkdir_p(File.join(base_dir, "#{project_path}.git"))
fake_importer = double
@@ -31,8 +31,8 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
described_class.execute(base_dir)
end
- it 'skips wiki repos' do
- repo_dir = File.join(base_dir, 'the-group', 'the-project.wiki.git')
+ it "skips wiki repos" do
+ repo_dir = File.join(base_dir, "the-group", "the-project.wiki.git")
FileUtils.mkdir_p(File.join(repo_dir))
expect(described_class).to receive(:log).with(" * Skipping repo #{repo_dir}")
@@ -41,24 +41,24 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
described_class.execute(base_dir)
end
- context 'without admin users' do
+ context "without admin users" do
let(:admin) { nil }
- it 'raises an error' do
+ it "raises an error" do
expect { described_class.execute(base_dir) }.to raise_error(Gitlab::BareRepositoryImport::Importer::NoAdminError)
end
end
end
- describe '#create_project_if_needed' do
- it 'starts an import for a project that did not exist' do
+ describe "#create_project_if_needed" do
+ it "starts an import for a project that did not exist" do
expect(importer).to receive(:create_project)
importer.create_project_if_needed
end
- it 'skips importing when the project already exists' do
- project = create(:project, path: 'a-project', namespace: existing_group)
+ it "skips importing when the project already exists" do
+ project = create(:project, path: "a-project", namespace: existing_group)
expect(importer).not_to receive(:create_project)
expect(importer).to receive(:log).with(" * #{project.name} (#{project_path}) exists")
@@ -66,33 +66,33 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
importer.create_project_if_needed
end
- it 'creates a project with the correct path in the database' do
+ it "creates a project with the correct path in the database" do
importer.create_project_if_needed
expect(Project.find_by_full_path(project_path)).not_to be_nil
end
- it 'does not schedule an import' do
+ it "does not schedule an import" do
expect_any_instance_of(Project).not_to receive(:import_schedule)
importer.create_project_if_needed
end
- it 'creates the Git repo on disk' do
+ it "creates the Git repo on disk" do
prepare_repository("#{project_path}.git", source_project)
importer.create_project_if_needed
project = Project.find_by_full_path(project_path)
repo_path = "#{project.disk_path}.git"
- hook_path = File.join(repo_path, 'hooks')
+ hook_path = File.join(repo_path, "hooks")
expect(gitlab_shell.exists?(project.repository_storage, repo_path)).to be(true)
expect(gitlab_shell.exists?(project.repository_storage, hook_path)).to be(true)
end
- context 'hashed storage enabled' do
- it 'creates a project with the correct path in the database' do
+ context "hashed storage enabled" do
+ it "creates a project with the correct path in the database" do
stub_application_setting(hashed_storage_enabled: true)
importer.create_project_if_needed
@@ -103,51 +103,51 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
end
end
- context 'with subgroups', :nested_groups do
- let(:project_path) { 'a-group/a-sub-group/a-project' }
+ context "with subgroups", :nested_groups do
+ let(:project_path) { "a-group/a-sub-group/a-project" }
let(:existing_group) do
- group = create(:group, path: 'a-group')
- create(:group, path: 'a-sub-group', parent: group)
+ group = create(:group, path: "a-group")
+ create(:group, path: "a-sub-group", parent: group)
end
- it_behaves_like 'importing a repository'
+ it_behaves_like "importing a repository"
end
- context 'without subgroups' do
- let(:project_path) { 'a-group/a-project' }
- let(:existing_group) { create(:group, path: 'a-group') }
+ context "without subgroups" do
+ let(:project_path) { "a-group/a-project" }
+ let(:existing_group) { create(:group, path: "a-group") }
- it_behaves_like 'importing a repository'
+ it_behaves_like "importing a repository"
end
- context 'without groups' do
- let(:project_path) { 'a-project' }
+ context "without groups" do
+ let(:project_path) { "a-project" }
- it 'starts an import for a project that did not exist' do
+ it "starts an import for a project that did not exist" do
expect(importer).to receive(:create_project)
importer.create_project_if_needed
end
- it 'creates a project with the correct path in the database' do
+ it "creates a project with the correct path in the database" do
importer.create_project_if_needed
expect(Project.find_by_full_path("#{admin.full_path}/#{project_path}")).not_to be_nil
end
- it 'creates the Git repo in disk' do
+ it "creates the Git repo in disk" do
prepare_repository("#{project_path}.git", source_project)
importer.create_project_if_needed
project = Project.find_by_full_path("#{admin.full_path}/#{project_path}")
- expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + '.git')).to be(true)
- expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + '.wiki.git')).to be(true)
+ expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + ".git")).to be(true)
+ expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + ".wiki.git")).to be(true)
end
- context 'with a repository already on disk' do
+ context "with a repository already on disk" do
let!(:base_dir) { TestEnv.repos_path }
# This is a quick way to get a valid repository instead of copying an
# existing one. Since it's not persisted, the importer will try to
@@ -155,7 +155,7 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
let(:project) { build(:project, :legacy_storage, :repository) }
let(:project_path) { project.full_path }
- it 'moves an existing project to the correct path' do
+ it "moves an existing project to the correct path" do
original_commit_count = project.repository.commit_count
expect(importer).to receive(:create_project).and_call_original
@@ -167,37 +167,37 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
end
end
- context 'with Wiki' do
- let(:project_path) { 'a-group/a-project' }
- let(:existing_group) { create(:group, path: 'a-group') }
+ context "with Wiki" do
+ let(:project_path) { "a-group/a-project" }
+ let(:existing_group) { create(:group, path: "a-group") }
- it_behaves_like 'importing a repository'
+ it_behaves_like "importing a repository"
- it 'creates the Wiki git repo in disk' do
+ it "creates the Wiki git repo in disk" do
prepare_repository("#{project_path}.git", source_project)
prepare_repository("#{project_path}.wiki.git", source_project)
expect(Projects::CreateService).to receive(:new).with(admin, hash_including(skip_wiki: true,
- import_type: 'bare_repository')).and_call_original
+ import_type: "bare_repository")).and_call_original
importer.create_project_if_needed
project = Project.find_by_full_path(project_path)
- expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + '.wiki.git')).to be(true)
+ expect(gitlab_shell.exists?(project.repository_storage, project.disk_path + ".wiki.git")).to be(true)
end
end
- context 'when subgroups are not available' do
- let(:project_path) { 'a-group/a-sub-group/a-project' }
+ context "when subgroups are not available" do
+ let(:project_path) { "a-group/a-sub-group/a-project" }
before do
expect(Group).to receive(:supports_nested_objects?) { false }
end
- describe '#create_project_if_needed' do
- it 'raises an error' do
- expect { importer.create_project_if_needed }.to raise_error('Nested groups are not supported on MySQL')
+ describe "#create_project_if_needed" do
+ it "raises an error" do
+ expect { importer.create_project_if_needed }.to raise_error("Nested groups are not supported on MySQL")
end
end
end
@@ -207,8 +207,8 @@ describe Gitlab::BareRepositoryImport::Importer, :seed_helper do
return create_bare_repository(repo_path) unless source_project
- cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{source_project} #{repo_path})
+ cmd = %W[#{Gitlab.config.git.bin_path} clone --bare #{source_project} #{repo_path}]
- system(git_env, *cmd, chdir: SEED_STORAGE_PATH, out: '/dev/null', err: '/dev/null')
+ system(git_env, *cmd, chdir: SEED_STORAGE_PATH, out: "/dev/null", err: "/dev/null")
end
end
diff --git a/spec/lib/gitlab/bare_repository_import/repository_spec.rb b/spec/lib/gitlab/bare_repository_import/repository_spec.rb
index a07c5371134..0e90690329b 100644
--- a/spec/lib/gitlab/bare_repository_import/repository_spec.rb
+++ b/spec/lib/gitlab/bare_repository_import/repository_spec.rb
@@ -1,70 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
describe ::Gitlab::BareRepositoryImport::Repository do
- context 'legacy storage' do
- subject { described_class.new('/full/path/', '/full/path/to/repo.git') }
+ context "legacy storage" do
+ subject { described_class.new("/full/path/", "/full/path/to/repo.git") }
- it 'stores the repo path' do
- expect(subject.repo_path).to eq('/full/path/to/repo.git')
+ it "stores the repo path" do
+ expect(subject.repo_path).to eq("/full/path/to/repo.git")
end
- it 'stores the group path' do
- expect(subject.group_path).to eq('to')
+ it "stores the group path" do
+ expect(subject.group_path).to eq("to")
end
- it 'stores the project name' do
- expect(subject.project_name).to eq('repo')
+ it "stores the project name" do
+ expect(subject.project_name).to eq("repo")
end
- it 'stores the wiki path' do
- expect(subject.wiki_path).to eq('/full/path/to/repo.wiki.git')
+ it "stores the wiki path" do
+ expect(subject.wiki_path).to eq("/full/path/to/repo.wiki.git")
end
- describe '#processable?' do
- it 'returns false if it is a wiki' do
- subject = described_class.new('/full/path/', '/full/path/to/a/b/my.wiki.git')
+ describe "#processable?" do
+ it "returns false if it is a wiki" do
+ subject = described_class.new("/full/path/", "/full/path/to/a/b/my.wiki.git")
expect(subject).not_to be_processable
end
- it 'returns true if group path is missing' do
- subject = described_class.new('/full/path/', '/full/path/repo.git')
+ it "returns true if group path is missing" do
+ subject = described_class.new("/full/path/", "/full/path/repo.git")
expect(subject).to be_processable
end
- it 'returns true when group path and project name are present' do
+ it "returns true when group path and project name are present" do
expect(subject).to be_processable
end
end
- describe '#project_full_path' do
- it 'returns the project full path with trailing slash in the root path' do
- expect(subject.project_full_path).to eq('to/repo')
+ describe "#project_full_path" do
+ it "returns the project full path with trailing slash in the root path" do
+ expect(subject.project_full_path).to eq("to/repo")
end
- it 'returns the project full path with no trailing slash in the root path' do
- subject = described_class.new('/full/path', '/full/path/to/repo.git')
+ it "returns the project full path with no trailing slash in the root path" do
+ subject = described_class.new("/full/path", "/full/path/to/repo.git")
- expect(subject.project_full_path).to eq('to/repo')
+ expect(subject.project_full_path).to eq("to/repo")
end
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let(:gitlab_shell) { Gitlab::Shell.new }
- let(:repository_storage) { 'default' }
+ let(:repository_storage) { "default" }
let(:root_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
- let(:hash) { '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' }
+ let(:hash) { "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" }
let(:hashed_path) { "@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" }
let(:repo_path) { File.join(root_path, "#{hashed_path}.git") }
let(:wiki_path) { File.join(root_path, "#{hashed_path}.wiki.git") }
before do
- gitlab_shell.create_repository(repository_storage, hashed_path, 'group/project')
+ gitlab_shell.create_repository(repository_storage, hashed_path, "group/project")
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
repository = Rugged::Repository.new(repo_path)
- repository.config['gitlab.fullpath'] = 'to/repo'
+ repository.config["gitlab.fullpath"] = "to/repo"
end
end
@@ -74,50 +74,50 @@ describe ::Gitlab::BareRepositoryImport::Repository do
subject { described_class.new(root_path, repo_path) }
- it 'stores the repo path' do
+ it "stores the repo path" do
expect(subject.repo_path).to eq(repo_path)
end
- it 'stores the wiki path' do
+ it "stores the wiki path" do
expect(subject.wiki_path).to eq(wiki_path)
end
- it 'reads the group path from .git/config' do
- expect(subject.group_path).to eq('to')
+ it "reads the group path from .git/config" do
+ expect(subject.group_path).to eq("to")
end
- it 'reads the project name from .git/config' do
- expect(subject.project_name).to eq('repo')
+ it "reads the project name from .git/config" do
+ expect(subject.project_name).to eq("repo")
end
- describe '#processable?' do
- it 'returns false if it is a wiki' do
+ describe "#processable?" do
+ it "returns false if it is a wiki" do
subject = described_class.new(root_path, wiki_path)
expect(subject).not_to be_processable
end
- it 'returns false when group and project name are missing' do
+ it "returns false when group and project name are missing" do
repository = Rugged::Repository.new(repo_path)
- repository.config.delete('gitlab.fullpath')
+ repository.config.delete("gitlab.fullpath")
expect(subject).not_to be_processable
end
- it 'returns true when group path and project name are present' do
+ it "returns true when group path and project name are present" do
expect(subject).to be_processable
end
end
- describe '#project_full_path' do
- it 'returns the project full path with trailing slash in the root path' do
- expect(subject.project_full_path).to eq('to/repo')
+ describe "#project_full_path" do
+ it "returns the project full path with trailing slash in the root path" do
+ expect(subject.project_full_path).to eq("to/repo")
end
- it 'returns the project full path with no trailing slash in the root path' do
+ it "returns the project full path with no trailing slash in the root path" do
subject = described_class.new(root_path[0...-1], repo_path)
- expect(subject.project_full_path).to eq('to/repo')
+ expect(subject.project_full_path).to eq("to/repo")
end
end
end
diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
index c432cc223b9..f53fa621fc6 100644
--- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BitbucketImport::Importer do
include ImportSpecHelper
before do
- stub_omniauth_provider('bitbucket')
+ stub_omniauth_provider("bitbucket")
end
let(:statuses) do
@@ -15,19 +15,19 @@ describe Gitlab::BitbucketImport::Importer do
"invalid",
"duplicate",
"wontfix",
- "closed" # undocumented status
+ "closed", # undocumented status
]
end
let(:reporters) do
[
nil,
- { "username" => "reporter1" },
+ {"username" => "reporter1"},
nil,
- { "username" => "reporter2" },
- { "username" => "reporter1" },
+ {"username" => "reporter2"},
+ {"username" => "reporter1"},
nil,
- { "username" => "reporter3" }
+ {"username" => "reporter3"},
]
end
@@ -39,30 +39,30 @@ describe Gitlab::BitbucketImport::Importer do
id: index,
state: status,
title: "Issue #{index}",
- kind: 'bug',
+ kind: "bug",
content: {
- raw: "Some content to issue #{index}",
- markup: "markdown",
- html: "Some content to issue #{index}"
- }
+ raw: "Some content to issue #{index}",
+ markup: "markdown",
+ html: "Some content to issue #{index}",
+ },
}
end
reporters.map.with_index do |reporter, index|
- issues[index]['reporter'] = reporter
+ issues[index]["reporter"] = reporter
end
issues
end
- let(:project_identifier) { 'namespace/repo' }
+ let(:project_identifier) { "namespace/repo" }
let(:data) do
{
- 'bb_session' => {
- 'bitbucket_token' => "123456",
- 'bitbucket_refresh_token' => "secret"
- }
+ "bb_session" => {
+ "bitbucket_token" => "123456",
+ "bitbucket_refresh_token" => "secret",
+ },
}
end
@@ -72,7 +72,7 @@ describe Gitlab::BitbucketImport::Importer do
:repository,
import_source: project_identifier,
import_url: "https://bitbucket.org/#{project_identifier}.git",
- import_data_attributes: { credentials: data }
+ import_data_attributes: {credentials: data}
)
end
@@ -82,7 +82,7 @@ describe Gitlab::BitbucketImport::Importer do
let(:issues_statuses_sample_data) do
{
count: sample_issues_statuses.count,
- values: sample_issues_statuses
+ values: sample_issues_statuses,
}
end
@@ -94,7 +94,7 @@ describe Gitlab::BitbucketImport::Importer do
subject { described_class.new(project) }
- describe '#import_pull_requests' do
+ describe "#import_pull_requests" do
before do
allow(subject).to receive(:import_wiki)
allow(subject).to receive(:import_issues)
@@ -106,38 +106,41 @@ describe Gitlab::BitbucketImport::Importer do
source_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.source_branch,
target_branch_sha: sample.commits.first,
target_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.target_branch,
- title: 'This is a title',
- description: 'This is a test pull request',
- state: 'merged',
- author: 'other',
+ title: "This is a title",
+ description: "This is a test pull request",
+ state: "merged",
+ author: "other",
created_at: Time.now,
- updated_at: Time.now)
+ updated_at: Time.now
+ )
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
@inline_note = instance_double(
Bitbucket::Representation::PullRequestComment,
iid: 2,
- file_path: '.gitmodules',
+ file_path: ".gitmodules",
old_pos: nil,
new_pos: 4,
- note: 'Hello world',
- author: 'root',
+ note: "Hello world",
+ author: "root",
created_at: Time.now,
updated_at: Time.now,
inline?: true,
- has_parent?: false)
+ has_parent?: false
+ )
@reply = instance_double(
Bitbucket::Representation::PullRequestComment,
iid: 3,
- file_path: '.gitmodules',
- note: 'Hello world',
- author: 'root',
+ file_path: ".gitmodules",
+ note: "Hello world",
+ author: "root",
created_at: Time.now,
updated_at: Time.now,
inline?: true,
has_parent?: true,
- parent_id: 2)
+ parent_id: 2
+ )
comments = [@inline_note, @reply]
@@ -146,7 +149,7 @@ describe Gitlab::BitbucketImport::Importer do
allow(subject.client).to receive(:pull_request_comments).with(anything, pull_request.iid).and_return(comments)
end
- it 'imports threaded discussions' do
+ it "imports threaded discussions" do
expect { subject.execute }.to change { MergeRequest.count }.by(1)
merge_request = MergeRequest.first
@@ -164,7 +167,7 @@ describe Gitlab::BitbucketImport::Importer do
end
end
- context 'issues statuses' do
+ context "issues statuses" do
before do
# HACK: Bitbucket::Representation.const_get('Issue') seems to return ::Issue without this
Bitbucket::Representation::Issue.new({})
@@ -173,18 +176,18 @@ describe Gitlab::BitbucketImport::Importer do
:get,
"https://api.bitbucket.org/2.0/repositories/#{project_identifier}"
).to_return(status: 200,
- headers: { "Content-Type" => "application/json" },
- body: { has_issues: true, full_name: project_identifier }.to_json)
+ headers: {"Content-Type" => "application/json"},
+ body: {has_issues: true, full_name: project_identifier}.to_json)
stub_request(
:get,
"https://api.bitbucket.org/2.0/repositories/#{project_identifier}/issues?pagelen=50&sort=created_on"
).to_return(status: 200,
- headers: { "Content-Type" => "application/json" },
+ headers: {"Content-Type" => "application/json"},
body: issues_statuses_sample_data.to_json)
stub_request(:get, "https://api.bitbucket.org/2.0/repositories/namespace/repo?pagelen=50&sort=created_on")
- .with(headers: { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Authorization' => 'Bearer', 'User-Agent' => 'Faraday v0.9.2' })
+ .with(headers: {"Accept" => "*/*", "Accept-Encoding" => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "Authorization" => "Bearer", "User-Agent" => "Faraday v0.9.2"})
.to_return(status: 200, body: "", headers: {})
sample_issues_statuses.each_with_index do |issue, index|
@@ -193,8 +196,8 @@ describe Gitlab::BitbucketImport::Importer do
"https://api.bitbucket.org/2.0/repositories/#{project_identifier}/issues/#{issue[:id]}/comments?pagelen=50&sort=created_on"
).to_return(
status: 200,
- headers: { "Content-Type" => "application/json" },
- body: { author_info: { username: "username" }, utc_created_on: index }.to_json
+ headers: {"Content-Type" => "application/json"},
+ body: {author_info: {username: "username"}, utc_created_on: index}.to_json
)
end
@@ -202,11 +205,11 @@ describe Gitlab::BitbucketImport::Importer do
:get,
"https://api.bitbucket.org/2.0/repositories/#{project_identifier}/pullrequests?pagelen=50&sort=created_on&state=ALL"
).to_return(status: 200,
- headers: { "Content-Type" => "application/json" },
+ headers: {"Content-Type" => "application/json"},
body: {}.to_json)
end
- it 'maps statuses to open or closed' do
+ it "maps statuses to open or closed" do
allow(importer).to receive(:import_wiki)
importer.execute
@@ -215,8 +218,8 @@ describe Gitlab::BitbucketImport::Importer do
expect(project.issues.where(state: "opened").size).to eq(2)
end
- describe 'wiki import' do
- it 'is skipped when the wiki exists' do
+ describe "wiki import" do
+ it "is skipped when the wiki exists" do
expect(project.wiki).to receive(:repository_exists?) { true }
expect(importer.gitlab_shell).not_to receive(:import_wiki_repository)
@@ -225,7 +228,7 @@ describe Gitlab::BitbucketImport::Importer do
expect(importer.errors).to be_empty
end
- it 'imports to the project disk_path' do
+ it "imports to the project disk_path" do
expect(project.wiki).to receive(:repository_exists?) { false }
expect(importer.gitlab_shell).to receive(:import_wiki_repository)
@@ -235,16 +238,16 @@ describe Gitlab::BitbucketImport::Importer do
end
end
- describe 'issue import' do
- it 'maps reporters to anonymous if bitbucket reporter is nil' do
+ describe "issue import" do
+ it "maps reporters to anonymous if bitbucket reporter is nil" do
allow(importer).to receive(:import_wiki)
importer.execute
expect(project.issues.size).to eq(7)
- expect(project.issues.where("description LIKE ?", '%Anonymous%').size).to eq(3)
- expect(project.issues.where("description LIKE ?", '%reporter1%').size).to eq(2)
- expect(project.issues.where("description LIKE ?", '%reporter2%').size).to eq(1)
- expect(project.issues.where("description LIKE ?", '%reporter3%').size).to eq(1)
+ expect(project.issues.where("description LIKE ?", "%Anonymous%").size).to eq(3)
+ expect(project.issues.where("description LIKE ?", "%reporter1%").size).to eq(2)
+ expect(project.issues.where("description LIKE ?", "%reporter2%").size).to eq(1)
+ expect(project.issues.where("description LIKE ?", "%reporter3%").size).to eq(1)
expect(importer.errors).to be_empty
end
end
diff --git a/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb b/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
index e2bee22cf1f..1bcfcd0f9f4 100644
--- a/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/project_creator_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BitbucketImport::ProjectCreator do
let(:user) { create(:user) }
let(:repo) do
- double(name: 'Vim',
- slug: 'vim',
- description: 'Test repo',
+ double(name: "Vim",
+ slug: "vim",
+ description: "Test repo",
is_private: true,
owner: "asd",
- full_name: 'Vim repo',
+ full_name: "Vim repo",
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
- clone_url: 'http://bitbucket.org/asd/vim.git',
+ clone_url: "http://bitbucket.org/asd/vim.git",
has_wiki?: false)
end
let(:namespace) { create(:group) }
let(:token) { "asdasd12345" }
let(:secret) { "sekrettt" }
- let(:access_params) { { bitbucket_access_token: token, bitbucket_access_token_secret: secret } }
+ let(:access_params) { {bitbucket_access_token: token, bitbucket_access_token_secret: secret} }
before do
namespace.add_owner(user)
end
- it 'creates project' do
+ it "creates project" do
expect_next_instance_of(Project) do |project|
expect(project).to receive(:add_import_job)
end
- project_creator = described_class.new(repo, 'vim', namespace, user, access_params)
+ project_creator = described_class.new(repo, "vim", namespace, user, access_params)
project = project_creator.execute
expect(project.import_url).to eq("http://bitbucket.org/asd/vim.git")
diff --git a/spec/lib/gitlab/bitbucket_import/wiki_formatter_spec.rb b/spec/lib/gitlab/bitbucket_import/wiki_formatter_spec.rb
index 795fd069ab2..2eef2c7ed13 100644
--- a/spec/lib/gitlab/bitbucket_import/wiki_formatter_spec.rb
+++ b/spec/lib/gitlab/bitbucket_import/wiki_formatter_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BitbucketImport::WikiFormatter do
let(:project) do
create(:project,
- namespace: create(:namespace, path: 'gitlabhq'),
- import_url: 'https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git')
+ namespace: create(:namespace, path: "gitlabhq"),
+ import_url: "https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git")
end
subject(:wiki) { described_class.new(project) }
- describe '#disk_path' do
- it 'appends .wiki to disk path' do
+ describe "#disk_path" do
+ it "appends .wiki to disk path" do
expect(wiki.disk_path).to eq project.wiki.disk_path
end
end
- describe '#full_path' do
- it 'appends .wiki to project path' do
+ describe "#full_path" do
+ it "appends .wiki to project path" do
expect(wiki.full_path).to eq project.wiki.full_path
end
end
- describe '#import_url' do
- it 'returns URL of the wiki repository' do
- expect(wiki.import_url).to eq 'https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git/wiki'
+ describe "#import_url" do
+ it "returns URL of the wiki repository" do
+ expect(wiki.import_url).to eq "https://xxx@bitbucket.org/gitlabhq/sample.gitlabhq.git/wiki"
end
end
end
diff --git a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
index 1e90a2ef27f..c3c51ab53ff 100644
--- a/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
+++ b/spec/lib/gitlab/bitbucket_server_import/importer_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BitbucketServerImport::Importer do
include ImportSpecHelper
- let(:project) { create(:project, :repository, import_url: 'http://my-bitbucket') }
+ let(:project) { create(:project, :repository, import_url: "http://my-bitbucket") }
let(:now) { Time.now.utc.change(usec: 0) }
- let(:project_key) { 'TEST' }
- let(:repo_slug) { 'rouge' }
+ let(:project_key) { "TEST" }
+ let(:repo_slug) { "rouge" }
let(:sample) { RepoHelpers.sample_compare }
subject { described_class.new(project, recover_missing_commits: true) }
before do
data = project.create_or_update_import_data(
- data: { project_key: project_key, repo_slug: repo_slug },
- credentials: { base_uri: 'http://my-bitbucket', user: 'bitbucket', password: 'test' }
+ data: {project_key: project_key, repo_slug: repo_slug},
+ credentials: {base_uri: "http://my-bitbucket", user: "bitbucket", password: "test"}
)
data.save
project.save
end
- describe '#import_repository' do
- it 'adds a remote' do
+ describe "#import_repository" do
+ it "adds a remote" do
expect(subject).to receive(:import_pull_requests)
expect(subject).to receive(:delete_temp_branches)
expect(project.repository).to receive(:fetch_as_mirror)
- .with('http://bitbucket:test@my-bitbucket',
- refmap: [:heads, :tags, '+refs/pull-requests/*/to:refs/merge-requests/*/head'],
- remote_name: 'bitbucket_server')
+ .with("http://bitbucket:test@my-bitbucket",
+ refmap: [:heads, :tags, "+refs/pull-requests/*/to:refs/merge-requests/*/head"],
+ remote_name: "bitbucket_server")
subject.execute
end
- it 'raises a Gitlab::Shell exception in the fetch' do
+ it "raises a Gitlab::Shell exception in the fetch" do
expect(project.repository).to receive(:fetch_as_mirror).and_raise(Gitlab::Shell::Error)
expect { subject.execute }.to raise_error(Gitlab::Shell::Error)
end
- it 'raises an unhandled exception in the fetch' do
+ it "raises an unhandled exception in the fetch" do
expect(project.repository).to receive(:fetch_as_mirror).and_raise(RuntimeError)
expect { subject.execute }.to raise_error(RuntimeError)
end
end
- describe '#import_pull_requests' do
+ describe "#import_pull_requests" do
before do
allow(subject).to receive(:import_repository)
allow(subject).to receive(:delete_temp_branches)
@@ -58,14 +58,15 @@ describe Gitlab::BitbucketServerImport::Importer do
source_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.source_branch,
target_branch_sha: sample.commits.first,
target_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.target_branch,
- title: 'This is a title',
- description: 'This is a test pull request',
- state: 'merged',
- author: 'Test Author',
+ title: "This is a title",
+ description: "This is a test pull request",
+ state: "merged",
+ author: "Test Author",
author_email: project.owner.email,
created_at: Time.now,
updated_at: Time.now,
- merged?: true)
+ merged?: true
+ )
allow(subject.client).to receive(:pull_requests).and_return([pull_request])
@@ -75,28 +76,30 @@ describe Gitlab::BitbucketServerImport::Importer do
merge_event?: true,
committer_email: project.owner.email,
merge_timestamp: now,
- merge_commit: '12345678'
+ merge_commit: "12345678"
)
@pr_note = instance_double(
BitbucketServer::Representation::Comment,
- note: 'Hello world',
- author_email: 'unknown@gmail.com',
- author_username: 'The Flash',
+ note: "Hello world",
+ author_email: "unknown@gmail.com",
+ author_username: "The Flash",
comments: [],
created_at: now,
updated_at: now,
- parent_comment: nil)
+ parent_comment: nil
+ )
@pr_comment = instance_double(
BitbucketServer::Representation::Activity,
comment?: true,
inline_comment?: false,
merge_event?: false,
- comment: @pr_note)
+ comment: @pr_note
+ )
end
- it 'imports merge event' do
+ it "imports merge event" do
expect(subject.client).to receive(:activities).and_return([@merge_event])
expect { subject.execute }.to change { MergeRequest.count }.by(1)
@@ -104,10 +107,10 @@ describe Gitlab::BitbucketServerImport::Importer do
merge_request = MergeRequest.first
expect(merge_request.metrics.merged_by).to eq(project.owner)
expect(merge_request.metrics.merged_at).to eq(@merge_event.merge_timestamp)
- expect(merge_request.merge_commit_sha).to eq('12345678')
+ expect(merge_request.merge_commit_sha).to eq("12345678")
end
- it 'imports comments' do
+ it "imports comments" do
expect(subject.client).to receive(:activities).and_return([@pr_comment])
expect { subject.execute }.to change { MergeRequest.count }.by(1)
@@ -121,31 +124,33 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(note.updated_at).to eq(@pr_note.created_at)
end
- it 'imports threaded discussions' do
+ it "imports threaded discussions" do
reply = instance_double(
BitbucketServer::Representation::PullRequestComment,
- author_email: 'someuser@gitlab.com',
- author_username: 'Batman',
- note: 'I agree',
+ author_email: "someuser@gitlab.com",
+ author_username: "Batman",
+ note: "I agree",
created_at: now,
- updated_at: now)
+ updated_at: now
+ )
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
inline_note = instance_double(
BitbucketServer::Representation::PullRequestComment,
- file_type: 'ADDED',
+ file_type: "ADDED",
from_sha: sample.commits.first,
to_sha: sample.commits.last,
- file_path: '.gitmodules',
+ file_path: ".gitmodules",
old_pos: nil,
new_pos: 4,
- note: 'Hello world',
- author_email: 'unknown@gmail.com',
- author_username: 'Superman',
+ note: "Hello world",
+ author_email: "unknown@gmail.com",
+ author_username: "Superman",
comments: [reply],
created_at: now,
updated_at: now,
- parent_comment: nil)
+ parent_comment: nil
+ )
allow(reply).to receive(:parent_comment).and_return(inline_note)
@@ -154,7 +159,8 @@ describe Gitlab::BitbucketServerImport::Importer do
comment?: true,
inline_comment?: true,
merge_event?: false,
- comment: inline_note)
+ comment: inline_note
+ )
expect(subject.client).to receive(:activities).and_return([inline_comment])
@@ -166,7 +172,7 @@ describe Gitlab::BitbucketServerImport::Importer do
notes = merge_request.notes.order(:id).to_a
start_note = notes.first
- expect(start_note.type).to eq('DiffNote')
+ expect(start_note.type).to eq("DiffNote")
expect(start_note.note).to end_with(inline_note.note)
expect(start_note.created_at).to eq(inline_note.created_at)
expect(start_note.updated_at).to eq(inline_note.updated_at)
@@ -190,38 +196,41 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(reply_note.position.new_line).to eq(inline_note.new_pos)
end
- it 'falls back to comments if diff comments fail to validate' do
+ it "falls back to comments if diff comments fail to validate" do
reply = instance_double(
BitbucketServer::Representation::Comment,
- author_email: 'someuser@gitlab.com',
- author_username: 'Aquaman',
- note: 'I agree',
+ author_email: "someuser@gitlab.com",
+ author_username: "Aquaman",
+ note: "I agree",
created_at: now,
- updated_at: now)
+ updated_at: now
+ )
# https://gitlab.com/gitlab-org/gitlab-test/compare/c1acaa58bbcbc3eafe538cb8274ba387047b69f8...5937ac0a7beb003549fc5fd26fc247ad
inline_note = instance_double(
BitbucketServer::Representation::PullRequestComment,
- file_type: 'REMOVED',
+ file_type: "REMOVED",
from_sha: sample.commits.first,
to_sha: sample.commits.last,
- file_path: '.gitmodules',
+ file_path: ".gitmodules",
old_pos: 8,
new_pos: 9,
- note: 'This is a note with an invalid line position.',
+ note: "This is a note with an invalid line position.",
author_email: project.owner.email,
- author_username: 'Owner',
+ author_username: "Owner",
comments: [reply],
created_at: now,
updated_at: now,
- parent_comment: nil)
+ parent_comment: nil
+ )
inline_comment = instance_double(
BitbucketServer::Representation::Activity,
comment?: true,
inline_comment?: true,
merge_event?: false,
- comment: inline_note)
+ comment: inline_note
+ )
allow(reply).to receive(:parent_comment).and_return(inline_note)
@@ -233,12 +242,12 @@ describe Gitlab::BitbucketServerImport::Importer do
expect(merge_request.notes.count).to eq(2)
notes = merge_request.notes
- expect(notes.first.note).to start_with('*Comment on .gitmodules')
- expect(notes.second.note).to start_with('*Comment on .gitmodules')
+ expect(notes.first.note).to start_with("*Comment on .gitmodules")
+ expect(notes.second.note).to start_with("*Comment on .gitmodules")
end
end
- describe 'inaccessible branches' do
+ describe "inaccessible branches" do
let(:id) { 10 }
let(:temp_branch_from) { "gitlab/import/pull-request/#{id}/from" }
let(:temp_branch_to) { "gitlab/import/pull-request/#{id}/to" }
@@ -247,50 +256,51 @@ describe Gitlab::BitbucketServerImport::Importer do
pull_request = instance_double(
BitbucketServer::Representation::PullRequest,
iid: id,
- source_branch_sha: '12345678',
+ source_branch_sha: "12345678",
source_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.source_branch,
- target_branch_sha: '98765432',
+ target_branch_sha: "98765432",
target_branch_name: Gitlab::Git::BRANCH_REF_PREFIX + sample.target_branch,
- title: 'This is a title',
- description: 'This is a test pull request',
- state: 'merged',
- author: 'Test Author',
+ title: "This is a title",
+ description: "This is a test pull request",
+ state: "merged",
+ author: "Test Author",
author_email: project.owner.email,
created_at: Time.now,
updated_at: Time.now,
- merged?: true)
+ merged?: true
+ )
expect(subject.client).to receive(:pull_requests).and_return([pull_request])
expect(subject.client).to receive(:activities).and_return([])
expect(subject).to receive(:import_repository).twice
end
- it '#restore_branches' do
+ it "#restore_branches" do
expect(subject).to receive(:restore_branches).and_call_original
expect(subject).to receive(:delete_temp_branches)
expect(subject.client).to receive(:create_branch)
- .with(project_key, repo_slug,
- temp_branch_from,
- '12345678')
+ .with(project_key, repo_slug,
+ temp_branch_from,
+ "12345678")
expect(subject.client).to receive(:create_branch)
- .with(project_key, repo_slug,
- temp_branch_to,
- '98765432')
+ .with(project_key, repo_slug,
+ temp_branch_to,
+ "98765432")
expect { subject.execute }.to change { MergeRequest.count }.by(1)
end
- it '#delete_temp_branches' do
+ it "#delete_temp_branches" do
expect(subject.client).to receive(:create_branch).twice
expect(subject).to receive(:delete_temp_branches).and_call_original
expect(subject.client).to receive(:delete_branch)
- .with(project_key, repo_slug,
- temp_branch_from,
- '12345678')
+ .with(project_key, repo_slug,
+ temp_branch_from,
+ "12345678")
expect(subject.client).to receive(:delete_branch)
- .with(project_key, repo_slug,
- temp_branch_to,
- '98765432')
+ .with(project_key, repo_slug,
+ temp_branch_to,
+ "98765432")
expect(project.repository).to receive(:delete_branch).with(temp_branch_from)
expect(project.repository).to receive(:delete_branch).with(temp_branch_to)
diff --git a/spec/lib/gitlab/blame_spec.rb b/spec/lib/gitlab/blame_spec.rb
index 7cab04e9fc9..a1ef3978d1c 100644
--- a/spec/lib/gitlab/blame_spec.rb
+++ b/spec/lib/gitlab/blame_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Blame do
let(:project) { create(:project, :repository) }
- let(:path) { 'files/ruby/popen.rb' }
- let(:commit) { project.commit('master') }
+ let(:path) { "files/ruby/popen.rb" }
+ let(:commit) { project.commit("master") }
let(:blob) { project.repository.blob_at(commit.id, path) }
describe "#groups" do
let(:subject) { described_class.new(blob, commit).groups(highlight: false) }
- it 'groups lines properly' do
+ it "groups lines properly" do
expect(subject.count).to eq(18)
- expect(subject[0][:commit].sha).to eq('913c66a37b4a45b9769037c55c2d238bd0942d2e')
+ expect(subject[0][:commit].sha).to eq("913c66a37b4a45b9769037c55c2d238bd0942d2e")
expect(subject[0][:lines]).to eq(["require 'fileutils'", "require 'open3'", ""])
- expect(subject[1][:commit].sha).to eq('874797c3a73b60d2187ed6e2fcabd289ff75171e')
+ expect(subject[1][:commit].sha).to eq("874797c3a73b60d2187ed6e2fcabd289ff75171e")
expect(subject[1][:lines]).to eq(["module Popen", " extend self"])
- expect(subject[-1][:commit].sha).to eq('913c66a37b4a45b9769037c55c2d238bd0942d2e')
+ expect(subject[-1][:commit].sha).to eq("913c66a37b4a45b9769037c55c2d238bd0942d2e")
expect(subject[-1][:lines]).to eq([" end", "end"])
end
end
diff --git a/spec/lib/gitlab/blob_helper_spec.rb b/spec/lib/gitlab/blob_helper_spec.rb
index e057385b35f..facb5e091d9 100644
--- a/spec/lib/gitlab/blob_helper_spec.rb
+++ b/spec/lib/gitlab/blob_helper_spec.rb
@@ -1,124 +1,124 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BlobHelper do
include FakeBlobHelpers
let(:project) { create(:project) }
- let(:blob) { fake_blob(path: 'file.txt') }
- let(:large_blob) { fake_blob(path: 'test.pdf', size: 2.megabytes, binary: true) }
+ let(:blob) { fake_blob(path: "file.txt") }
+ let(:large_blob) { fake_blob(path: "test.pdf", size: 2.megabytes, binary: true) }
- describe '#extname' do
- it 'returns the extension' do
- expect(blob.extname).to eq('.txt')
+ describe "#extname" do
+ it "returns the extension" do
+ expect(blob.extname).to eq(".txt")
end
end
- describe '#known_extension?' do
- it 'returns true' do
+ describe "#known_extension?" do
+ it "returns true" do
expect(blob.known_extension?).to be_truthy
end
end
- describe '#viewable' do
- it 'returns true' do
+ describe "#viewable" do
+ it "returns true" do
expect(blob.viewable?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
expect(large_blob.viewable?).to be_falsey
end
end
- describe '#large?' do
- it 'returns false' do
+ describe "#large?" do
+ it "returns false" do
expect(blob.large?).to be_falsey
end
- it 'returns true' do
+ it "returns true" do
expect(large_blob.large?).to be_truthy
end
end
- describe '#binary?' do
- it 'returns true' do
+ describe "#binary?" do
+ it "returns true" do
expect(large_blob.binary?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
expect(blob.binary?).to be_falsey
end
end
- describe '#text?' do
- it 'returns true' do
+ describe "#text?" do
+ it "returns true" do
expect(blob.text_in_repo?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
expect(large_blob.text_in_repo?).to be_falsey
end
end
- describe '#image?' do
- it 'returns false' do
+ describe "#image?" do
+ it "returns false" do
expect(blob.image?).to be_falsey
end
end
- describe '#mime_type' do
- it 'returns text/plain' do
- expect(blob.mime_type).to eq('text/plain')
+ describe "#mime_type" do
+ it "returns text/plain" do
+ expect(blob.mime_type).to eq("text/plain")
end
- it 'returns application/pdf' do
- expect(large_blob.mime_type).to eq('application/pdf')
+ it "returns application/pdf" do
+ expect(large_blob.mime_type).to eq("application/pdf")
end
end
- describe '#binary_mime_type?' do
- it 'returns false' do
+ describe "#binary_mime_type?" do
+ it "returns false" do
expect(blob.binary_mime_type?).to be_falsey
end
end
- describe '#lines' do
- it 'returns the payload in an Array' do
- expect(blob.lines).to eq(['foo'])
+ describe "#lines" do
+ it "returns the payload in an Array" do
+ expect(blob.lines).to eq(["foo"])
end
end
- describe '#content_type' do
- it 'returns text/plain' do
- expect(blob.content_type).to eq('text/plain; charset=utf-8')
+ describe "#content_type" do
+ it "returns text/plain" do
+ expect(blob.content_type).to eq("text/plain; charset=utf-8")
end
- it 'returns text/plain' do
- expect(large_blob.content_type).to eq('application/pdf')
+ it "returns text/plain" do
+ expect(large_blob.content_type).to eq("application/pdf")
end
end
- describe '#encoded_newlines_re' do
- it 'returns a regular expression' do
+ describe "#encoded_newlines_re" do
+ it "returns a regular expression" do
expect(blob.encoded_newlines_re).to eq(/\r\n|\r|\n/)
end
end
- describe '#ruby_encoding' do
- it 'returns UTF-8' do
- expect(blob.ruby_encoding).to eq('UTF-8')
+ describe "#ruby_encoding" do
+ it "returns UTF-8" do
+ expect(blob.ruby_encoding).to eq("UTF-8")
end
end
- describe '#encoding' do
- it 'returns UTF-8' do
- expect(blob.ruby_encoding).to eq('UTF-8')
+ describe "#encoding" do
+ it "returns UTF-8" do
+ expect(blob.ruby_encoding).to eq("UTF-8")
end
end
- describe '#empty?' do
- it 'returns false' do
+ describe "#empty?" do
+ it "returns false" do
expect(blob.empty?).to be_falsey
end
end
diff --git a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb
index 1e969542975..2087b39e4bc 100644
--- a/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb
+++ b/spec/lib/gitlab/branch_push_merge_commit_analyzer_spec.rb
@@ -1,57 +1,57 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BranchPushMergeCommitAnalyzer do
let(:project) { create(:project, :repository) }
- let(:oldrev) { 'merge-commit-analyze-before' }
- let(:newrev) { 'merge-commit-analyze-after' }
+ let(:oldrev) { "merge-commit-analyze-before" }
+ let(:newrev) { "merge-commit-analyze-after" }
let(:commits) { project.repository.commits_between(oldrev, newrev).reverse }
subject { described_class.new(commits) }
- describe '#get_merge_commit' do
+ describe "#get_merge_commit" do
let(:expected_merge_commits) do
{
- '646ece5cfed840eca0a4feb21bcd6a81bb19bda3' => '646ece5cfed840eca0a4feb21bcd6a81bb19bda3',
- '29284d9bcc350bcae005872d0be6edd016e2efb5' => '29284d9bcc350bcae005872d0be6edd016e2efb5',
- '5f82584f0a907f3b30cfce5bb8df371454a90051' => '29284d9bcc350bcae005872d0be6edd016e2efb5',
- '8a994512e8c8f0dfcf22bb16df6e876be7a61036' => '29284d9bcc350bcae005872d0be6edd016e2efb5',
- '689600b91aabec706e657e38ea706ece1ee8268f' => '29284d9bcc350bcae005872d0be6edd016e2efb5',
- 'db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9' => 'db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9'
+ "646ece5cfed840eca0a4feb21bcd6a81bb19bda3" => "646ece5cfed840eca0a4feb21bcd6a81bb19bda3",
+ "29284d9bcc350bcae005872d0be6edd016e2efb5" => "29284d9bcc350bcae005872d0be6edd016e2efb5",
+ "5f82584f0a907f3b30cfce5bb8df371454a90051" => "29284d9bcc350bcae005872d0be6edd016e2efb5",
+ "8a994512e8c8f0dfcf22bb16df6e876be7a61036" => "29284d9bcc350bcae005872d0be6edd016e2efb5",
+ "689600b91aabec706e657e38ea706ece1ee8268f" => "29284d9bcc350bcae005872d0be6edd016e2efb5",
+ "db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9" => "db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9",
}
end
- it 'returns correct merge commit SHA for each commit' do
+ it "returns correct merge commit SHA for each commit" do
expected_merge_commits.each do |commit, merge_commit|
expect(subject.get_merge_commit(commit)).to eq(merge_commit)
end
end
- context 'when one parent has two children' do
- let(:oldrev) { '1adbdefe31288f3bbe4b614853de4908a0b6f792' }
- let(:newrev) { '5f82584f0a907f3b30cfce5bb8df371454a90051' }
+ context "when one parent has two children" do
+ let(:oldrev) { "1adbdefe31288f3bbe4b614853de4908a0b6f792" }
+ let(:newrev) { "5f82584f0a907f3b30cfce5bb8df371454a90051" }
let(:expected_merge_commits) do
{
- '5f82584f0a907f3b30cfce5bb8df371454a90051' => '5f82584f0a907f3b30cfce5bb8df371454a90051',
- '8a994512e8c8f0dfcf22bb16df6e876be7a61036' => '5f82584f0a907f3b30cfce5bb8df371454a90051',
- '689600b91aabec706e657e38ea706ece1ee8268f' => '689600b91aabec706e657e38ea706ece1ee8268f'
+ "5f82584f0a907f3b30cfce5bb8df371454a90051" => "5f82584f0a907f3b30cfce5bb8df371454a90051",
+ "8a994512e8c8f0dfcf22bb16df6e876be7a61036" => "5f82584f0a907f3b30cfce5bb8df371454a90051",
+ "689600b91aabec706e657e38ea706ece1ee8268f" => "689600b91aabec706e657e38ea706ece1ee8268f",
}
end
- it 'returns correct merge commit SHA for each commit' do
+ it "returns correct merge commit SHA for each commit" do
expected_merge_commits.each do |commit, merge_commit|
expect(subject.get_merge_commit(commit)).to eq(merge_commit)
end
end
end
- context 'when relevant_commit_ids is provided' do
- let(:relevant_commit_id) { '8a994512e8c8f0dfcf22bb16df6e876be7a61036' }
+ context "when relevant_commit_ids is provided" do
+ let(:relevant_commit_id) { "8a994512e8c8f0dfcf22bb16df6e876be7a61036" }
subject { described_class.new(commits, relevant_commit_ids: [relevant_commit_id]) }
- it 'returns correct merge commit' do
+ it "returns correct merge commit" do
expected_merge_commits.each do |commit, merge_commit|
subject = described_class.new(commits, relevant_commit_ids: [commit])
expect(subject.get_merge_commit(commit)).to eq(merge_commit)
diff --git a/spec/lib/gitlab/build_access_spec.rb b/spec/lib/gitlab/build_access_spec.rb
index 08f50bf4fac..fa758d21d01 100644
--- a/spec/lib/gitlab/build_access_spec.rb
+++ b/spec/lib/gitlab/build_access_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::BuildAccess do
let(:user) { create(:user) }
let(:project) { create(:project) }
- describe '#can_do_action' do
+ describe "#can_do_action" do
subject { described_class.new(user, project: project).can_do_action?(:download_code) }
- context 'when the user can do an action on the project but cannot access git' do
+ context "when the user can do an action on the project but cannot access git" do
before do
user.block!
project.add_developer(user)
@@ -16,7 +16,7 @@ describe Gitlab::BuildAccess do
it { is_expected.to be(true) }
end
- context 'when the user cannot do an action on the project' do
+ context "when the user cannot do an action on the project" do
it { is_expected.to be(false) }
end
end
diff --git a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
index 483c5ea9cff..de8b8721317 100644
--- a/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
+++ b/spec/lib/gitlab/cache/ci/project_pipeline_status_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
let!(:project) { create(:project, :repository) }
let(:pipeline_status) { described_class.new(project) }
let(:cache_key) { pipeline_status.cache_key }
- describe '.load_for_project' do
+ describe ".load_for_project" do
it "loads the status" do
expect_any_instance_of(described_class).to receive(:load_status)
@@ -13,22 +13,22 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
end
- describe 'loading in batches' do
- describe '.load_in_batch_for_projects' do
- it 'loads pipeline_status on projects' do
+ describe "loading in batches" do
+ describe ".load_in_batch_for_projects" do
+ it "loads pipeline_status on projects" do
described_class.load_in_batch_for_projects([project])
# Don't call the accessor that would lazy load the variable
- project_pipeline_status = project.instance_variable_get('@pipeline_status')
+ project_pipeline_status = project.instance_variable_get("@pipeline_status")
expect(project_pipeline_status).to be_a(described_class)
expect(project_pipeline_status).to be_loaded
end
- it 'loads 10 projects without hitting Gitaly call limit', :request_store do
- projects = Gitlab::GitalyClient.allow_n_plus_1_calls do
+ it "loads 10 projects without hitting Gitaly call limit", :request_store do
+ projects = Gitlab::GitalyClient.allow_n_plus_1_calls {
(1..10).map { create(:project, :repository) }
- end
+ }
Gitlab::GitalyClient.reset_counts
expect { described_class.load_in_batch_for_projects(projects) }.not_to raise_error
@@ -36,17 +36,17 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
end
- describe '.update_for_pipeline' do
- it 'refreshes the cache if nescessary' do
+ describe ".update_for_pipeline" do
+ it "refreshes the cache if nescessary" do
pipeline = build_stubbed(:ci_pipeline,
- sha: '123456', status: 'success', ref: 'master')
+ sha: "123456", status: "success", ref: "master")
fake_status = double
expect(described_class).to receive(:new)
- .with(pipeline.project,
- pipeline_info: {
- sha: '123456', status: 'success', ref: 'master'
- })
- .and_return(fake_status)
+ .with(pipeline.project,
+ pipeline_info: {
+ sha: "123456", status: "success", ref: "master",
+ })
+ .and_return(fake_status)
expect(fake_status).to receive(:store_in_cache_if_needed)
@@ -54,15 +54,15 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
end
- describe '#has_status?' do
+ describe "#has_status?" do
it "is false when the status wasn't loaded yet" do
expect(pipeline_status.has_status?).to be_falsy
end
- it 'is true when all status information was loaded' do
+ it "is true when all status information was loaded" do
fake_commit = double
- allow(fake_commit).to receive(:status).and_return('failed')
- allow(fake_commit).to receive(:sha).and_return('failed424d1b73bc0d3cb726eb7dc4ce17a4d48552f8c6')
+ allow(fake_commit).to receive(:status).and_return("failed")
+ allow(fake_commit).to receive(:sha).and_return("failed424d1b73bc0d3cb726eb7dc4ce17a4d48552f8c6")
allow(pipeline_status).to receive(:commit).and_return(fake_commit)
allow(pipeline_status).to receive(:has_cache?).and_return(false)
@@ -72,15 +72,15 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
end
- describe '#load_status' do
- it 'loads the status from the cache when there is one' do
+ describe "#load_status" do
+ it "loads the status from the cache when there is one" do
expect(pipeline_status).to receive(:has_cache?).and_return(true)
expect(pipeline_status).to receive(:load_from_cache)
pipeline_status.load_status
end
- it 'loads the status from the project commit when there is no cache' do
+ it "loads the status from the project commit when there is no cache" do
allow(pipeline_status).to receive(:has_cache?).and_return(false)
expect(pipeline_status).to receive(:load_from_project)
@@ -88,7 +88,7 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
pipeline_status.load_status
end
- it 'stores the status in the cache when it loading it from the project' do
+ it "stores the status in the cache when it loading it from the project" do
allow(pipeline_status).to receive(:has_cache?).and_return(false)
allow(pipeline_status).to receive(:load_from_project)
@@ -97,13 +97,13 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
pipeline_status.load_status
end
- it 'sets the state to loaded' do
+ it "sets the state to loaded" do
pipeline_status.load_status
expect(pipeline_status).to be_loaded
end
- it 'only loads the status once' do
+ it "only loads the status once" do
expect(pipeline_status).to receive(:has_cache?).and_return(true).exactly(1)
expect(pipeline_status).to receive(:load_from_cache).exactly(1)
@@ -115,10 +115,10 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
describe "#load_from_project", :clean_gitlab_redis_cache do
let!(:pipeline) { create(:ci_pipeline, :success, project: project, sha: project.commit.sha) }
- it 'reads the status from the pipeline for the commit' do
+ it "reads the status from the pipeline for the commit" do
pipeline_status.load_from_project
- expect(pipeline_status.status).to eq('success')
+ expect(pipeline_status.status).to eq("success")
expect(pipeline_status.sha).to eq(project.commit.sha)
expect(pipeline_status.ref).to eq(project.default_branch)
end
@@ -136,19 +136,19 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
describe "#store_in_cache", :clean_gitlab_redis_cache do
it "sets the object in caching" do
- pipeline_status.sha = '123456'
- pipeline_status.status = 'failed'
+ pipeline_status.sha = "123456"
+ pipeline_status.status = "failed"
pipeline_status.store_in_cache
read_sha, read_status = Gitlab::Redis::Cache.with { |redis| redis.hmget(cache_key, :sha, :status) }
- expect(read_sha).to eq('123456')
- expect(read_status).to eq('failed')
+ expect(read_sha).to eq("123456")
+ expect(read_status).to eq("failed")
end
end
- describe '#store_in_cache_if_needed', :clean_gitlab_redis_cache do
- it 'stores the state in the cache when the sha is the HEAD of the project' do
+ describe "#store_in_cache_if_needed", :clean_gitlab_redis_cache do
+ it "stores the state in the cache when the sha is the HEAD of the project" do
create(:ci_pipeline, :success, project: project, sha: project.commit.sha)
pipeline_status = described_class.load_for_project(project)
@@ -163,7 +163,7 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
it "doesn't store the status in redis_cache when the sha is not the head of the project" do
other_status = described_class.new(
project,
- pipeline_info: { sha: "123456", status: "failed" }
+ pipeline_info: {sha: "123456", status: "failed"}
)
other_status.store_in_cache_if_needed
@@ -177,13 +177,13 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
empty_project = create(:project)
Gitlab::Redis::Cache.with do |redis|
redis.mapped_hmset(cache_key,
- { sha: 'sha', status: 'pending', ref: 'master' })
+ {sha: "sha", status: "pending", ref: "master"})
end
other_status = described_class.new(empty_project,
- pipeline_info: {
- sha: "123456", status: "failed"
- })
+ pipeline_info: {
+ sha: "123456", status: "failed",
+ })
other_status.store_in_cache_if_needed
sha, status, ref = Gitlab::Redis::Cache.with { |redis| redis.hmget("projects/#{empty_project.id}/pipeline_status", :sha, :status, :ref) }
@@ -195,19 +195,19 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
describe "with a status in caching", :clean_gitlab_redis_cache do
- let(:status) { 'success' }
- let(:sha) { '424d1b73bc0d3cb726eb7dc4ce17a4d48552f8c6' }
- let(:ref) { 'master' }
+ let(:status) { "success" }
+ let(:sha) { "424d1b73bc0d3cb726eb7dc4ce17a4d48552f8c6" }
+ let(:ref) { "master" }
before do
Gitlab::Redis::Cache.with do |redis|
redis.mapped_hmset(cache_key,
- { sha: sha, status: status, ref: ref })
+ {sha: sha, status: status, ref: ref})
end
end
- describe '#load_from_cache' do
- it 'reads the status from redis_cache' do
+ describe "#load_from_cache" do
+ it "reads the status from redis_cache" do
pipeline_status.load_from_cache
expect(pipeline_status.sha).to eq(sha)
@@ -215,15 +215,15 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
expect(pipeline_status.ref).to eq(ref)
end
- context 'when status is empty string' do
+ context "when status is empty string" do
before do
Gitlab::Redis::Cache.with do |redis|
redis.mapped_hmset(cache_key,
- { sha: sha, status: '', ref: ref })
+ {sha: sha, status: "", ref: ref})
end
end
- it 'reads the status as nil' do
+ it "reads the status as nil" do
pipeline_status.load_from_cache
expect(pipeline_status.status).to eq(nil)
@@ -231,14 +231,14 @@ describe Gitlab::Cache::Ci::ProjectPipelineStatus, :clean_gitlab_redis_cache do
end
end
- describe '#has_cache?' do
- it 'knows the status is cached' do
+ describe "#has_cache?" do
+ it "knows the status is cached" do
expect(pipeline_status.has_cache?).to be_truthy
end
end
- describe '#delete_from_cache' do
- it 'deletes values from redis_cache' do
+ describe "#delete_from_cache" do
+ it "deletes values from redis_cache" do
pipeline_status.delete_from_cache
key_exists = Gitlab::Redis::Cache.with { |redis| redis.exists(cache_key) }
diff --git a/spec/lib/gitlab/cache/request_cache_spec.rb b/spec/lib/gitlab/cache/request_cache_spec.rb
index 5b82c216a13..935ac69888f 100644
--- a/spec/lib/gitlab/cache/request_cache_spec.rb
+++ b/spec/lib/gitlab/cache/request_cache_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Cache::RequestCache do
let(:klass) do
@@ -8,7 +8,7 @@ describe Gitlab::Cache::RequestCache do
attr_accessor :id, :name, :result, :extra
def self.name
- 'ExpensiveAlgorithm'
+ "ExpensiveAlgorithm"
end
def initialize(id, name, result, extra = nil)
@@ -33,62 +33,62 @@ describe Gitlab::Cache::RequestCache do
end
end
- let(:algorithm) { klass.new('id', 'name', []) }
+ let(:algorithm) { klass.new("id", "name", []) }
- shared_examples 'cache for the same instance' do
- it 'does not compute twice for the same argument' do
+ shared_examples "cache for the same instance" do
+ it "does not compute twice for the same argument" do
algorithm.compute(true)
result = algorithm.compute(true)
expect(result).to eq([true])
end
- it 'computes twice for the different argument' do
+ it "computes twice for the different argument" do
algorithm.compute(true)
result = algorithm.compute(false)
expect(result).to eq([true, false])
end
- it 'computes twice for the different class name' do
+ it "computes twice for the different class name" do
algorithm.compute(true)
- allow(klass).to receive(:name).and_return('CheapAlgo')
+ allow(klass).to receive(:name).and_return("CheapAlgo")
result = algorithm.compute(true)
expect(result).to eq([true, true])
end
- it 'computes twice for the different method' do
+ it "computes twice for the different method" do
algorithm.compute(true)
result = algorithm.repute(true)
expect(result).to eq([true, true])
end
- context 'when request_cache_key is provided' do
+ context "when request_cache_key is provided" do
before do
klass.request_cache_key do
[id, name]
end
end
- it 'computes twice for the different keys, id' do
+ it "computes twice for the different keys, id" do
algorithm.compute(true)
- algorithm.id = 'ad'
+ algorithm.id = "ad"
result = algorithm.compute(true)
expect(result).to eq([true, true])
end
- it 'computes twice for the different keys, name' do
+ it "computes twice for the different keys, name" do
algorithm.compute(true)
- algorithm.name = 'same'
+ algorithm.name = "same"
result = algorithm.compute(true)
expect(result).to eq([true, true])
end
- it 'uses extra method cache key if provided' do
+ it "uses extra method cache key if provided" do
algorithm.dispute(true) # miss
algorithm.extra = true
algorithm.dispute(true) # miss
@@ -99,17 +99,17 @@ describe Gitlab::Cache::RequestCache do
end
end
- context 'when RequestStore is active', :request_store do
- it_behaves_like 'cache for the same instance'
+ context "when RequestStore is active", :request_store do
+ it_behaves_like "cache for the same instance"
- it 'computes once for different instances when keys are the same' do
+ it "computes once for different instances when keys are the same" do
algorithm.compute(true)
- result = klass.new('id', 'name', algorithm.result).compute(true)
+ result = klass.new("id", "name", algorithm.result).compute(true)
expect(result).to eq([true])
end
- it 'computes twice if RequestStore starts over' do
+ it "computes twice if RequestStore starts over" do
algorithm.compute(true)
RequestStore.end!
RequestStore.clear!
@@ -120,12 +120,12 @@ describe Gitlab::Cache::RequestCache do
end
end
- context 'when RequestStore is inactive' do
- it_behaves_like 'cache for the same instance'
+ context "when RequestStore is inactive" do
+ it_behaves_like "cache for the same instance"
- it 'computes twice for different instances even if keys are the same' do
+ it "computes twice for different instances even if keys are the same" do
algorithm.compute(true)
- result = klass.new('id', 'name', algorithm.result).compute(true)
+ result = klass.new("id", "name", algorithm.result).compute(true)
expect(result).to eq([true, true])
end
diff --git a/spec/lib/gitlab/changes_list_spec.rb b/spec/lib/gitlab/changes_list_spec.rb
index 464508fcd73..3b9326580be 100644
--- a/spec/lib/gitlab/changes_list_spec.rb
+++ b/spec/lib/gitlab/changes_list_spec.rb
@@ -4,26 +4,26 @@ describe Gitlab::ChangesList do
let(:valid_changes_string) { "\n000000 570e7b2 refs/heads/my_branch\nd14d6c 6fd24d refs/heads/master" }
let(:invalid_changes) { 1 }
- context 'when changes is a valid string' do
+ context "when changes is a valid string" do
let(:changes_list) { described_class.new(valid_changes_string) }
- it 'splits elements by newline character' do
+ it "splits elements by newline character" do
expect(changes_list).to contain_exactly({
oldrev: "000000",
newrev: "570e7b2",
- ref: "refs/heads/my_branch"
+ ref: "refs/heads/my_branch",
}, {
oldrev: "d14d6c",
newrev: "6fd24d",
- ref: "refs/heads/master"
+ ref: "refs/heads/master",
})
end
- it 'behaves like a list' do
+ it "behaves like a list" do
expect(changes_list.first).to eq({
oldrev: "000000",
newrev: "570e7b2",
- ref: "refs/heads/my_branch"
+ ref: "refs/heads/my_branch",
})
end
end
diff --git a/spec/lib/gitlab/chat/command_spec.rb b/spec/lib/gitlab/chat/command_spec.rb
index 46d23ab2b62..9f3cb4e33c9 100644
--- a/spec/lib/gitlab/chat/command_spec.rb
+++ b/spec/lib/gitlab/chat/command_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat::Command do
let(:chat_name) { create(:chat_name) }
@@ -9,17 +9,17 @@ describe Gitlab::Chat::Command do
described_class.new(
project: project,
chat_name: chat_name,
- name: 'spinach',
- arguments: 'foo',
- channel: '123',
- response_url: 'http://example.com'
+ name: "spinach",
+ arguments: "foo",
+ channel: "123",
+ response_url: "http://example.com"
)
end
- describe '#try_create_pipeline' do
+ describe "#try_create_pipeline" do
let(:project) { create(:project) }
- it 'returns nil when the command is not valid' do
+ it "returns nil when the command is not valid" do
expect(command)
.to receive(:valid?)
.and_return(false)
@@ -27,7 +27,7 @@ describe Gitlab::Chat::Command do
expect(command.try_create_pipeline).to be_nil
end
- it 'tries to create the pipeline when a command is valid' do
+ it "tries to create the pipeline when a command is valid" do
expect(command)
.to receive(:valid?)
.and_return(true)
@@ -39,7 +39,7 @@ describe Gitlab::Chat::Command do
end
end
- describe '#create_pipeline' do
+ describe "#create_pipeline" do
let(:project) { create(:project, :test_repo) }
let(:pipeline) { command.create_pipeline }
@@ -49,29 +49,29 @@ describe Gitlab::Chat::Command do
project.add_developer(chat_name.user)
end
- it 'creates the pipeline' do
+ it "creates the pipeline" do
expect(pipeline).to be_persisted
end
- it 'creates the chat data for the pipeline' do
+ it "creates the chat data for the pipeline" do
expect(pipeline.chat_data).to be_an_instance_of(Ci::PipelineChatData)
end
- it 'stores the chat name ID in the chat data' do
+ it "stores the chat name ID in the chat data" do
expect(pipeline.chat_data.chat_name_id).to eq(chat_name.id)
end
- it 'stores the response URL in the chat data' do
- expect(pipeline.chat_data.response_url).to eq('http://example.com')
+ it "stores the response URL in the chat data" do
+ expect(pipeline.chat_data.response_url).to eq("http://example.com")
end
- it 'creates the environment variables for the pipeline' do
- vars = pipeline.variables.each_with_object({}) do |row, hash|
+ it "creates the environment variables for the pipeline" do
+ vars = pipeline.variables.each_with_object({}) { |row, hash|
hash[row.key] = row.value
- end
+ }
- expect(vars['CHAT_INPUT']).to eq('foo')
- expect(vars['CHAT_CHANNEL']).to eq('123')
+ expect(vars["CHAT_INPUT"]).to eq("foo")
+ expect(vars["CHAT_CHANNEL"]).to eq("123")
end
end
end
diff --git a/spec/lib/gitlab/chat/output_spec.rb b/spec/lib/gitlab/chat/output_spec.rb
index b179f9e9d0a..5b15c9c058a 100644
--- a/spec/lib/gitlab/chat/output_spec.rb
+++ b/spec/lib/gitlab/chat/output_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat::Output do
let(:build) do
@@ -9,8 +9,8 @@ describe Gitlab::Chat::Output do
let(:output) { described_class.new(build) }
- describe '#to_s' do
- it 'returns the build output as a String' do
+ describe "#to_s" do
+ it "returns the build output as a String" do
trace = Gitlab::Ci::Trace.new(build)
trace.set("echo hello\nhello")
@@ -23,36 +23,36 @@ describe Gitlab::Chat::Output do
.to receive(:read_offset_and_length)
.and_return([0, 13])
- expect(output.to_s).to eq('he')
+ expect(output.to_s).to eq("he")
end
end
- describe '#read_offset_and_length' do
- context 'without the chat_reply trace section' do
- it 'falls back to using the build_script trace section' do
+ describe "#read_offset_and_length" do
+ context "without the chat_reply trace section" do
+ it "falls back to using the build_script trace section" do
expect(output)
.to receive(:find_build_trace_section)
- .with('chat_reply')
+ .with("chat_reply")
.and_return(nil)
expect(output)
.to receive(:find_build_trace_section)
- .with('build_script')
- .and_return({ name: 'build_script', byte_start: 1, byte_end: 4 })
+ .with("build_script")
+ .and_return({name: "build_script", byte_start: 1, byte_end: 4})
expect(output.read_offset_and_length).to eq([1, 3])
end
end
- context 'without the build_script trace section' do
- it 'raises MissingBuildSectionError' do
+ context "without the build_script trace section" do
+ it "raises MissingBuildSectionError" do
expect { output.read_offset_and_length }
.to raise_error(described_class::MissingBuildSectionError)
end
end
- context 'with the chat_reply trace section' do
- it 'returns the read offset and length as an Array' do
+ context "with the chat_reply trace section" do
+ it "returns the read offset and length as an Array" do
trace = Gitlab::Ci::Trace.new(build)
allow(build)
@@ -61,41 +61,41 @@ describe Gitlab::Chat::Output do
allow(trace)
.to receive(:extract_sections)
- .and_return([{ name: 'chat_reply', byte_start: 1, byte_end: 4 }])
+ .and_return([{name: "chat_reply", byte_start: 1, byte_end: 4}])
expect(output.read_offset_and_length).to eq([1, 3])
end
end
end
- describe '#without_executed_command_line' do
- it 'returns the input without the first line' do
+ describe "#without_executed_command_line" do
+ it "returns the input without the first line" do
expect(output.without_executed_command_line("hello\nworld"))
- .to eq('world')
+ .to eq("world")
end
- it 'returns an empty String when the input is empty' do
- expect(output.without_executed_command_line('')).to eq('')
+ it "returns an empty String when the input is empty" do
+ expect(output.without_executed_command_line("")).to eq("")
end
- it 'returns an empty String when the input consits of a single newline' do
- expect(output.without_executed_command_line("\n")).to eq('')
+ it "returns an empty String when the input consits of a single newline" do
+ expect(output.without_executed_command_line("\n")).to eq("")
end
end
- describe '#find_build_trace_section' do
- it 'returns nil when no section could be found' do
- expect(output.find_build_trace_section('foo')).to be_nil
+ describe "#find_build_trace_section" do
+ it "returns nil when no section could be found" do
+ expect(output.find_build_trace_section("foo")).to be_nil
end
- it 'returns the trace section when it could be found' do
- section = { name: 'chat_reply', byte_start: 1, byte_end: 4 }
+ it "returns the trace section when it could be found" do
+ section = {name: "chat_reply", byte_start: 1, byte_end: 4}
allow(output)
.to receive(:trace_sections)
.and_return([section])
- expect(output.find_build_trace_section('chat_reply')).to eq(section)
+ expect(output.find_build_trace_section("chat_reply")).to eq(section)
end
end
end
diff --git a/spec/lib/gitlab/chat/responder/base_spec.rb b/spec/lib/gitlab/chat/responder/base_spec.rb
index 7fa9bad9d38..f39396e10f3 100644
--- a/spec/lib/gitlab/chat/responder/base_spec.rb
+++ b/spec/lib/gitlab/chat/responder/base_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat::Responder::Base do
let(:project) { double(:project) }
@@ -8,39 +8,39 @@ describe Gitlab::Chat::Responder::Base do
let(:build) { double(:build, pipeline: pipeline) }
let(:responder) { described_class.new(build) }
- describe '#pipeline' do
- it 'returns the pipeline' do
+ describe "#pipeline" do
+ it "returns the pipeline" do
expect(responder.pipeline).to eq(pipeline)
end
end
- describe '#project' do
- it 'returns the project' do
+ describe "#project" do
+ it "returns the project" do
expect(responder.project).to eq(project)
end
end
- describe '#success' do
- it 'raises NotImplementedError' do
+ describe "#success" do
+ it "raises NotImplementedError" do
expect { responder.success }.to raise_error(NotImplementedError)
end
end
- describe '#failure' do
- it 'raises NotImplementedError' do
+ describe "#failure" do
+ it "raises NotImplementedError" do
expect { responder.failure }.to raise_error(NotImplementedError)
end
end
- describe '#send_response' do
- it 'raises NotImplementedError' do
- expect { responder.send_response('hello') }
+ describe "#send_response" do
+ it "raises NotImplementedError" do
+ expect { responder.send_response("hello") }
.to raise_error(NotImplementedError)
end
end
- describe '#scheduled_output' do
- it 'raises NotImplementedError' do
+ describe "#scheduled_output" do
+ it "raises NotImplementedError" do
expect { responder.scheduled_output }
.to raise_error(NotImplementedError)
end
diff --git a/spec/lib/gitlab/chat/responder/slack_spec.rb b/spec/lib/gitlab/chat/responder/slack_spec.rb
index a1553232b32..41e2307f0a9 100644
--- a/spec/lib/gitlab/chat/responder/slack_spec.rb
+++ b/spec/lib/gitlab/chat/responder/slack_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat::Responder::Slack do
- let(:chat_name) { create(:chat_name, chat_id: 'U123') }
+ let(:chat_name) { create(:chat_name, chat_id: "U123") }
let(:pipeline) do
pipeline = create(:ci_pipeline)
pipeline.create_chat_data!(
- response_url: 'http://example.com',
+ response_url: "http://example.com",
chat_name_id: chat_name.id
)
@@ -19,43 +19,43 @@ describe Gitlab::Chat::Responder::Slack do
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:responder) { described_class.new(build) }
- describe '#send_response' do
- it 'sends a response back to Slack' do
+ describe "#send_response" do
+ it "sends a response back to Slack" do
expect(Gitlab::HTTP).to receive(:post).with(
- 'http://example.com',
- { headers: { Accept: 'application/json' }, body: 'hello'.to_json }
+ "http://example.com",
+ {headers: {Accept: "application/json"}, body: "hello".to_json}
)
- responder.send_response('hello')
+ responder.send_response("hello")
end
end
- describe '#success' do
- it 'returns the output for a successful build' do
+ describe "#success" do
+ it "returns the output for a successful build" do
expect(responder)
.to receive(:send_response)
.with(hash_including(text: /<@U123>:.+hello/, response_type: :in_channel))
- responder.success('hello')
+ responder.success("hello")
end
- it 'limits the output to a fixed size' do
+ it "limits the output to a fixed size" do
expect(responder)
.to receive(:send_response)
.with(hash_including(text: /The output is too large/))
- responder.success('a' * 4000)
+ responder.success("a" * 4000)
end
- it 'does not send a response if the output is empty' do
+ it "does not send a response if the output is empty" do
expect(responder).not_to receive(:send_response)
- responder.success('')
+ responder.success("")
end
end
- describe '#failure' do
- it 'returns the output for a failed build' do
+ describe "#failure" do
+ it "returns the output for a failed build" do
expect(responder).to receive(:send_response).with(
hash_including(
text: /<@U123>:.+Sorry, the build failed!/,
@@ -67,11 +67,11 @@ describe Gitlab::Chat::Responder::Slack do
end
end
- describe '#scheduled_output' do
- it 'returns the output for a scheduled build' do
+ describe "#scheduled_output" do
+ it "returns the output for a scheduled build" do
output = responder.scheduled_output
- expect(output).to eq({ text: '' })
+ expect(output).to eq({text: ""})
end
end
end
diff --git a/spec/lib/gitlab/chat/responder_spec.rb b/spec/lib/gitlab/chat/responder_spec.rb
index 9893689cba9..b409614d8d8 100644
--- a/spec/lib/gitlab/chat/responder_spec.rb
+++ b/spec/lib/gitlab/chat/responder_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat::Responder do
- describe '.responder_for' do
- context 'using a regular build' do
- it 'returns nil' do
+ describe ".responder_for" do
+ context "using a regular build" do
+ it "returns nil" do
build = create(:ci_build)
expect(described_class.responder_for(build)).to be_nil
end
end
- context 'using a chat build' do
- it 'returns the responder for the build' do
+ context "using a chat build" do
+ it "returns the responder for the build" do
pipeline = create(:ci_pipeline)
build = create(:ci_build, pipeline: pipeline)
service = double(:service, chat_responder: Gitlab::Chat::Responder::Slack)
diff --git a/spec/lib/gitlab/chat_name_token_spec.rb b/spec/lib/gitlab/chat_name_token_spec.rb
index 1e9fb9077fc..78d560ea248 100644
--- a/spec/lib/gitlab/chat_name_token_spec.rb
+++ b/spec/lib/gitlab/chat_name_token_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ChatNameToken do
- context 'when using unknown token' do
+ context "when using unknown token" do
let(:token) { }
subject { described_class.new(token).get }
- it 'returns empty data' do
+ it "returns empty data" do
is_expected.to be_nil
end
end
- context 'when storing data' do
- let(:data) { { key: 'value' } }
+ context "when storing data" do
+ let(:data) { {key: "value"} }
subject { described_class.new(@token) }
@@ -20,16 +20,16 @@ describe Gitlab::ChatNameToken do
@token = described_class.new.store!(data)
end
- it 'returns stored data' do
+ it "returns stored data" do
expect(subject.get).to eq(data)
end
- context 'and after deleting them' do
+ context "and after deleting them" do
before do
subject.delete
end
- it 'data are removed' do
+ it "data are removed" do
expect(subject.get).to be_nil
end
end
diff --git a/spec/lib/gitlab/chat_spec.rb b/spec/lib/gitlab/chat_spec.rb
index d61c4b36668..56ad5f7627c 100644
--- a/spec/lib/gitlab/chat_spec.rb
+++ b/spec/lib/gitlab/chat_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Chat, :use_clean_rails_memory_store_caching do
- describe '.available?' do
- it 'returns true when the chatops feature is available' do
+ describe ".available?" do
+ it "returns true when the chatops feature is available" do
allow(Feature)
.to receive(:enabled?)
.with(:chatops, default_enabled: true)
@@ -11,7 +11,7 @@ describe Gitlab::Chat, :use_clean_rails_memory_store_caching do
expect(described_class).to be_available
end
- it 'returns false when the chatops feature is not available' do
+ it "returns false when the chatops feature is not available" do
allow(Feature)
.to receive(:enabled?)
.with(:chatops, default_enabled: true)
diff --git a/spec/lib/gitlab/checks/branch_check_spec.rb b/spec/lib/gitlab/checks/branch_check_spec.rb
index 77366e91dca..13bb168c52a 100644
--- a/spec/lib/gitlab/checks/branch_check_spec.rb
+++ b/spec/lib/gitlab/checks/branch_check_spec.rb
@@ -1,86 +1,86 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::BranchCheck do
- include_context 'change access checks context'
+ include_context "change access checks context"
- describe '#validate!' do
- it 'does not raise any error' do
+ describe "#validate!" do
+ it "does not raise any error" do
expect { subject.validate! }.not_to raise_error
end
- context 'trying to delete the default branch' do
- let(:newrev) { '0000000000000000000000000000000000000000' }
- let(:ref) { 'refs/heads/master' }
+ context "trying to delete the default branch" do
+ let(:newrev) { "0000000000000000000000000000000000000000" }
+ let(:ref) { "refs/heads/master" }
- it 'raises an error' do
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'The default branch of a project cannot be deleted.')
+ it "raises an error" do
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "The default branch of a project cannot be deleted.")
end
end
- context 'protected branches check' do
+ context "protected branches check" do
before do
- allow(ProtectedBranch).to receive(:protected?).with(project, 'master').and_return(true)
- allow(ProtectedBranch).to receive(:protected?).with(project, 'feature').and_return(true)
+ allow(ProtectedBranch).to receive(:protected?).with(project, "master").and_return(true)
+ allow(ProtectedBranch).to receive(:protected?).with(project, "feature").and_return(true)
end
- it 'raises an error if the user is not allowed to do forced pushes to protected branches' do
+ it "raises an error if the user is not allowed to do forced pushes to protected branches" do
expect(Gitlab::Checks::ForcePush).to receive(:force_push?).and_return(true)
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to force push code to a protected branch on this project.')
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to force push code to a protected branch on this project.")
end
- it 'raises an error if the user is not allowed to merge to protected branches' do
+ it "raises an error if the user is not allowed to merge to protected branches" do
expect_any_instance_of(Gitlab::Checks::MatchingMergeRequest).to receive(:match?).and_return(true)
expect(user_access).to receive(:can_merge_to_branch?).and_return(false)
expect(user_access).to receive(:can_push_to_branch?).and_return(false)
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to merge code into protected branches on this project.')
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to merge code into protected branches on this project.")
end
- it 'raises an error if the user is not allowed to push to protected branches' do
+ it "raises an error if the user is not allowed to push to protected branches" do
expect(user_access).to receive(:can_push_to_branch?).and_return(false)
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to push code to protected branches on this project.')
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to push code to protected branches on this project.")
end
- context 'when project repository is empty' do
+ context "when project repository is empty" do
let(:project) { create(:project) }
- it 'raises an error if the user is not allowed to push to protected branches' do
+ it "raises an error if the user is not allowed to push to protected branches" do
expect(user_access).to receive(:can_push_to_branch?).and_return(false)
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /Ask a project Owner or Maintainer to create a default branch/)
end
end
- context 'branch deletion' do
- let(:newrev) { '0000000000000000000000000000000000000000' }
- let(:ref) { 'refs/heads/feature' }
+ context "branch deletion" do
+ let(:newrev) { "0000000000000000000000000000000000000000" }
+ let(:ref) { "refs/heads/feature" }
- context 'if the user is not allowed to delete protected branches' do
- it 'raises an error' do
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.')
+ context "if the user is not allowed to delete protected branches" do
+ it "raises an error" do
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to delete protected branches from this project. Only a project maintainer or owner can delete a protected branch.")
end
end
- context 'if the user is allowed to delete protected branches' do
+ context "if the user is allowed to delete protected branches" do
before do
project.add_maintainer(user)
end
- context 'through the web interface' do
- let(:protocol) { 'web' }
+ context "through the web interface" do
+ let(:protocol) { "web" }
- it 'allows branch deletion' do
+ it "allows branch deletion" do
expect { subject.validate! }.not_to raise_error
end
end
- context 'over SSH or HTTP' do
- it 'raises an error' do
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You can only delete protected branches using the web interface.')
+ context "over SSH or HTTP" do
+ it "raises an error" do
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You can only delete protected branches using the web interface.")
end
end
end
diff --git a/spec/lib/gitlab/checks/change_access_spec.rb b/spec/lib/gitlab/checks/change_access_spec.rb
index 45fb33e9e4a..67dc419c16e 100644
--- a/spec/lib/gitlab/checks/change_access_spec.rb
+++ b/spec/lib/gitlab/checks/change_access_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::ChangeAccess do
- describe '#exec' do
- include_context 'change access checks context'
+ describe "#exec" do
+ include_context "change access checks context"
subject { change_access }
- context 'without failed checks' do
+ context "without failed checks" do
it "doesn't raise an error" do
expect { subject.exec }.not_to raise_error
end
- it 'calls pushes checks' do
+ it "calls pushes checks" do
expect_any_instance_of(Gitlab::Checks::PushCheck).to receive(:validate!)
subject.exec
end
- it 'calls branches checks' do
+ it "calls branches checks" do
expect_any_instance_of(Gitlab::Checks::BranchCheck).to receive(:validate!)
subject.exec
end
- it 'calls tags checks' do
+ it "calls tags checks" do
expect_any_instance_of(Gitlab::Checks::TagCheck).to receive(:validate!)
subject.exec
end
- it 'calls lfs checks' do
+ it "calls lfs checks" do
expect_any_instance_of(Gitlab::Checks::LfsCheck).to receive(:validate!)
subject.exec
end
- it 'calls diff checks' do
+ it "calls diff checks" do
expect_any_instance_of(Gitlab::Checks::DiffCheck).to receive(:validate!)
subject.exec
end
end
- context 'when time limit was reached' do
- it 'raises a TimeoutError' do
+ context "when time limit was reached" do
+ it "raises a TimeoutError" do
logger = Gitlab::Checks::TimedLogger.new(start_time: timeout.ago, timeout: timeout)
access = described_class.new(changes,
- project: project,
- user_access: user_access,
- protocol: protocol,
- logger: logger)
+ project: project,
+ user_access: user_access,
+ protocol: protocol,
+ logger: logger)
expect { access.exec }.to raise_error(Gitlab::Checks::TimedLogger::TimeoutError)
end
diff --git a/spec/lib/gitlab/checks/diff_check_spec.rb b/spec/lib/gitlab/checks/diff_check_spec.rb
index a341dfa5636..df1d269a14a 100644
--- a/spec/lib/gitlab/checks/diff_check_spec.rb
+++ b/spec/lib/gitlab/checks/diff_check_spec.rb
@@ -1,26 +1,26 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::DiffCheck do
- include_context 'change access checks context'
+ include_context "change access checks context"
- describe '#validate!' do
+ describe "#validate!" do
let(:owner) { create(:user) }
- let!(:lock) { create(:lfs_file_lock, user: owner, project: project, path: 'README') }
+ let!(:lock) { create(:lfs_file_lock, user: owner, project: project, path: "README") }
before do
allow(project.repository).to receive(:new_commits).and_return(
- project.repository.commits_between('be93687618e4b132087f430a4d8fc3a609c9b77c', '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51')
+ project.repository.commits_between("be93687618e4b132087f430a4d8fc3a609c9b77c", "54fcc214b94e78d7a41a9a8fe6d87a5e59500e51")
)
end
- context 'with LFS not enabled' do
+ context "with LFS not enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(false)
end
- it 'skips the validation' do
+ it "skips the validation" do
expect(subject).not_to receive(:validate_diff)
expect(subject).not_to receive(:validate_file_paths)
@@ -28,18 +28,18 @@ describe Gitlab::Checks::DiffCheck do
end
end
- context 'with LFS enabled' do
+ context "with LFS enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- context 'when change is sent by a different user' do
- it 'raises an error if the user is not allowed to update the file' do
+ context "when change is sent by a different user" do
+ it "raises an error if the user is not allowed to update the file" do
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "The path 'README' is locked in Git LFS by #{lock.user.name}")
end
end
- context 'when change is sent by the author of the lock' do
+ context "when change is sent by the author of the lock" do
let(:user) { owner }
it "doesn't raise any error" do
@@ -48,7 +48,7 @@ describe Gitlab::Checks::DiffCheck do
end
end
- context 'commit diff validations' do
+ context "commit diff validations" do
before do
allow(subject).to receive(:validations_for_diff).and_return([lambda { |diff| return }])
@@ -57,24 +57,24 @@ describe Gitlab::Checks::DiffCheck do
subject.validate!
end
- context 'when request store is inactive' do
- it 'are run for every commit' do
+ context "when request store is inactive" do
+ it "are run for every commit" do
expect_any_instance_of(Commit).to receive(:raw_deltas).and_call_original
subject.validate!
end
end
- context 'when request store is active', :request_store do
- it 'are cached for every commit' do
+ context "when request store is active", :request_store do
+ it "are cached for every commit" do
expect_any_instance_of(Commit).not_to receive(:raw_deltas)
subject.validate!
end
- it 'are run for not cached commits' do
+ it "are run for not cached commits" do
allow(project.repository).to receive(:new_commits).and_return(
- project.repository.commits_between('be93687618e4b132087f430a4d8fc3a609c9b77c', 'a5391128b0ef5d21df5dd23d98557f4ef12fae20')
+ project.repository.commits_between("be93687618e4b132087f430a4d8fc3a609c9b77c", "a5391128b0ef5d21df5dd23d98557f4ef12fae20")
)
change_access.instance_variable_set(:@commits, project.repository.new_commits)
diff --git a/spec/lib/gitlab/checks/force_push_spec.rb b/spec/lib/gitlab/checks/force_push_spec.rb
index 0e0788ce974..074a3476fd7 100644
--- a/spec/lib/gitlab/checks/force_push_spec.rb
+++ b/spec/lib/gitlab/checks/force_push_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::ForcePush do
set(:project) { create(:project, :repository) }
- describe '.force_push?' do
- it 'returns false if the repo is empty' do
+ describe ".force_push?" do
+ it "returns false if the repo is empty" do
allow(project).to receive(:empty_repo?).and_return(true)
- expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(false)
+ expect(described_class.force_push?(project, "HEAD", "HEAD~")).to be(false)
end
- it 'checks if old rev is an anchestor' do
- expect(described_class.force_push?(project, 'HEAD', 'HEAD~')).to be(true)
+ it "checks if old rev is an anchestor" do
+ expect(described_class.force_push?(project, "HEAD", "HEAD~")).to be(true)
end
end
end
diff --git a/spec/lib/gitlab/checks/lfs_check_spec.rb b/spec/lib/gitlab/checks/lfs_check_spec.rb
index 35f8069c8a4..7d8eded2ce3 100644
--- a/spec/lib/gitlab/checks/lfs_check_spec.rb
+++ b/spec/lib/gitlab/checks/lfs_check_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::LfsCheck do
- include_context 'change access checks context'
+ include_context "change access checks context"
- let(:blob_object) { project.repository.blob_at_branch('lfs', 'files/lfs/lfs_object.iso') }
+ let(:blob_object) { project.repository.blob_at_branch("lfs", "files/lfs/lfs_object.iso") }
before do
allow_any_instance_of(Gitlab::Git::LfsChanges).to receive(:new_pointers) do
@@ -13,35 +13,35 @@ describe Gitlab::Checks::LfsCheck do
end
end
- describe '#validate!' do
- context 'with LFS not enabled' do
- it 'skips integrity check' do
+ describe "#validate!" do
+ context "with LFS not enabled" do
+ it "skips integrity check" do
expect_any_instance_of(Gitlab::Git::LfsChanges).not_to receive(:new_pointers)
subject.validate!
end
end
- context 'with LFS enabled' do
+ context "with LFS enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- context 'deletion' do
- let(:changes) { { oldrev: oldrev, ref: ref } }
+ context "deletion" do
+ let(:changes) { {oldrev: oldrev, ref: ref} }
- it 'skips integrity check' do
+ it "skips integrity check" do
expect(project.repository).not_to receive(:new_objects)
subject.validate!
end
end
- it 'fails if any LFS blobs are missing' do
+ it "fails if any LFS blobs are missing" do
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /LFS objects are missing/)
end
- it 'succeeds if LFS objects have already been uploaded' do
+ it "succeeds if LFS objects have already been uploaded" do
lfs_object = create(:lfs_object, oid: blob_object.lfs_oid)
create(:lfs_objects_project, project: project, lfs_object: lfs_object)
diff --git a/spec/lib/gitlab/checks/lfs_integrity_spec.rb b/spec/lib/gitlab/checks/lfs_integrity_spec.rb
index 887ea8fc1e0..2f50bc9f0bb 100644
--- a/spec/lib/gitlab/checks/lfs_integrity_spec.rb
+++ b/spec/lib/gitlab/checks/lfs_integrity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::LfsIntegrity do
include ProjectForksHelper
@@ -7,48 +7,48 @@ describe Gitlab::Checks::LfsIntegrity do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:newrev) do
- operations = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ operations = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
BareRepoOperations.new(repository.path)
- end
+ }
# Create a commit not pointed at by any ref to emulate being in the
# pre-receive hook so that `--not --all` returns some objects
- operations.commit_tree('8856a329dd38ca86dfb9ce5aa58a16d88cc119bd', "New LFS objects")
+ operations.commit_tree("8856a329dd38ca86dfb9ce5aa58a16d88cc119bd", "New LFS objects")
end
subject { described_class.new(project, newrev, time_left) }
- describe '#objects_missing?' do
- let(:blob_object) { repository.blob_at_branch('lfs', 'files/lfs/lfs_object.iso') }
+ describe "#objects_missing?" do
+ let(:blob_object) { repository.blob_at_branch("lfs", "files/lfs/lfs_object.iso") }
- context 'with LFS not enabled' do
- it 'skips integrity check' do
+ context "with LFS not enabled" do
+ it "skips integrity check" do
expect_any_instance_of(Gitlab::Git::LfsChanges).not_to receive(:new_pointers)
subject.objects_missing?
end
end
- context 'with LFS enabled' do
+ context "with LFS enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- context 'deletion' do
+ context "deletion" do
let(:newrev) { nil }
- it 'skips integrity check' do
+ it "skips integrity check" do
expect_any_instance_of(Gitlab::Git::LfsChanges).not_to receive(:new_pointers)
expect(subject.objects_missing?).to be_falsey
end
end
- it 'is true if any LFS blobs are missing' do
+ it "is true if any LFS blobs are missing" do
expect(subject.objects_missing?).to be_truthy
end
- it 'is false if LFS objects have already been uploaded' do
+ it "is false if LFS objects have already been uploaded" do
lfs_object = create(:lfs_object, oid: blob_object.lfs_oid)
create(:lfs_objects_project, project: project, lfs_object: lfs_object)
@@ -56,7 +56,7 @@ describe Gitlab::Checks::LfsIntegrity do
end
end
- context 'for forked project' do
+ context "for forked project" do
let(:parent_project) { create(:project, :repository) }
let(:project) { fork_project(parent_project, nil, repository: true) }
@@ -64,11 +64,11 @@ describe Gitlab::Checks::LfsIntegrity do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- it 'is true parent project is missing LFS objects' do
+ it "is true parent project is missing LFS objects" do
expect(subject.objects_missing?).to be_truthy
end
- it 'is false parent project already contains LFS objects for the fork' do
+ it "is false parent project already contains LFS objects for the fork" do
lfs_object = create(:lfs_object, oid: blob_object.lfs_oid)
create(:lfs_objects_project, project: parent_project, lfs_object: lfs_object)
diff --git a/spec/lib/gitlab/checks/project_created_spec.rb b/spec/lib/gitlab/checks/project_created_spec.rb
index ac02007e111..3dec1f1a9b7 100644
--- a/spec/lib/gitlab/checks/project_created_spec.rb
+++ b/spec/lib/gitlab/checks/project_created_spec.rb
@@ -1,44 +1,44 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Checks::ProjectCreated, :clean_gitlab_redis_shared_state do
let(:user) { create(:user) }
let(:project) { create(:project) }
- describe '.fetch_message' do
- context 'with a project created message queue' do
- let(:project_created) { described_class.new(project, user, 'http') }
+ describe ".fetch_message" do
+ context "with a project created message queue" do
+ let(:project_created) { described_class.new(project, user, "http") }
before do
project_created.add_message
end
- it 'returns project created message' do
+ it "returns project created message" do
expect(described_class.fetch_message(user.id, project.id)).to eq(project_created.message)
end
- it 'deletes the project created message from redis' do
+ it "deletes the project created message from redis" do
expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).not_to be_nil
described_class.fetch_message(user.id, project.id)
expect(Gitlab::Redis::SharedState.with { |redis| redis.get("project_created:#{user.id}:#{project.id}") }).to be_nil
end
end
- context 'with no project created message queue' do
- it 'returns nil' do
+ context "with no project created message queue" do
+ it "returns nil" do
expect(described_class.fetch_message(1, 2)).to be_nil
end
end
end
- describe '#add_message' do
- it 'queues a project created message' do
- project_created = described_class.new(project, user, 'http')
+ describe "#add_message" do
+ it "queues a project created message" do
+ project_created = described_class.new(project, user, "http")
- expect(project_created.add_message).to eq('OK')
+ expect(project_created.add_message).to eq("OK")
end
- it 'handles anonymous push' do
- project_created = described_class.new(nil, user, 'http')
+ it "handles anonymous push" do
+ project_created = described_class.new(nil, user, "http")
expect(project_created.add_message).to be_nil
end
diff --git a/spec/lib/gitlab/checks/project_moved_spec.rb b/spec/lib/gitlab/checks/project_moved_spec.rb
index 8e9386b1ba1..3c04ad49b07 100644
--- a/spec/lib/gitlab/checks/project_moved_spec.rb
+++ b/spec/lib/gitlab/checks/project_moved_spec.rb
@@ -1,20 +1,20 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
let(:user) { create(:user) }
let(:project) { create(:project) }
- describe '.fetch_message' do
- context 'with a redirect message queue' do
- it 'returns the redirect message' do
- project_moved = described_class.new(project, user, 'http', 'foo/bar')
+ describe ".fetch_message" do
+ context "with a redirect message queue" do
+ it "returns the redirect message" do
+ project_moved = described_class.new(project, user, "http", "foo/bar")
project_moved.add_message
expect(described_class.fetch_message(user.id, project.id)).to eq(project_moved.message)
end
- it 'deletes the redirect message from redis' do
- project_moved = described_class.new(project, user, 'http', 'foo/bar')
+ it "deletes the redirect message from redis" do
+ project_moved = described_class.new(project, user, "http", "foo/bar")
project_moved.add_message
expect(Gitlab::Redis::SharedState.with { |redis| redis.get("redirect_namespace:#{user.id}:#{project.id}") }).not_to be_nil
@@ -23,36 +23,34 @@ describe Gitlab::Checks::ProjectMoved, :clean_gitlab_redis_shared_state do
end
end
- context 'with no redirect message queue' do
- it 'returns nil' do
+ context "with no redirect message queue" do
+ it "returns nil" do
expect(described_class.fetch_message(1, 2)).to be_nil
end
end
end
- describe '#add_message' do
- it 'queues a redirect message' do
- project_moved = described_class.new(project, user, 'http', 'foo/bar')
+ describe "#add_message" do
+ it "queues a redirect message" do
+ project_moved = described_class.new(project, user, "http", "foo/bar")
expect(project_moved.add_message).to eq("OK")
end
- it 'handles anonymous clones' do
- project_moved = described_class.new(project, nil, 'http', 'foo/bar')
+ it "handles anonymous clones" do
+ project_moved = described_class.new(project, nil, "http", "foo/bar")
expect(project_moved.add_message).to eq(nil)
end
end
- describe '#message' do
- it 'returns a redirect message' do
- project_moved = described_class.new(project, user, 'http', 'foo/bar')
+ describe "#message" do
+ it "returns a redirect message" do
+ project_moved = described_class.new(project, user, "http", "foo/bar")
message = <<~MSG
- Project 'foo/bar' was moved to '#{project.full_path}'.
-
- Please update your Git remote:
-
- git remote set-url origin #{project.http_url_to_repo}
- MSG
+ Project 'foo/bar' was moved to '#{project.full_path}'.
+ Please update your Git remote:
+ git remote set-url origin #{project.http_url_to_repo}
+ MSG
expect(project_moved.message).to eq(message)
end
diff --git a/spec/lib/gitlab/checks/push_check_spec.rb b/spec/lib/gitlab/checks/push_check_spec.rb
index e1bd52d6c0b..2554a5d9759 100644
--- a/spec/lib/gitlab/checks/push_check_spec.rb
+++ b/spec/lib/gitlab/checks/push_check_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::PushCheck do
- include_context 'change access checks context'
+ include_context "change access checks context"
- describe '#validate!' do
- it 'does not raise any error' do
+ describe "#validate!" do
+ it "does not raise any error" do
expect { subject.validate! }.not_to raise_error
end
- context 'when the user is not allowed to push to the repo' do
- it 'raises an error' do
+ context "when the user is not allowed to push to the repo" do
+ it "raises an error" do
expect(user_access).to receive(:can_do_action?).with(:push_code).and_return(false)
- expect(project).to receive(:branch_allows_collaboration?).with(user_access.user, 'master').and_return(false)
+ expect(project).to receive(:branch_allows_collaboration?).with(user_access.user, "master").and_return(false)
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to push code to this project.')
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to push code to this project.")
end
end
end
diff --git a/spec/lib/gitlab/checks/tag_check_spec.rb b/spec/lib/gitlab/checks/tag_check_spec.rb
index b1258270611..bc7ae7242ce 100644
--- a/spec/lib/gitlab/checks/tag_check_spec.rb
+++ b/spec/lib/gitlab/checks/tag_check_spec.rb
@@ -1,60 +1,60 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::TagCheck do
- include_context 'change access checks context'
+ include_context "change access checks context"
- describe '#validate!' do
- let(:ref) { 'refs/tags/v1.0.0' }
+ describe "#validate!" do
+ let(:ref) { "refs/tags/v1.0.0" }
- it 'raises an error' do
+ it "raises an error" do
allow(user_access).to receive(:can_do_action?).with(:push_code).and_return(true)
expect(user_access).to receive(:can_do_action?).with(:admin_project).and_return(false)
- expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to change existing tags on this project.')
+ expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to change existing tags on this project.")
end
- context 'with protected tag' do
- let!(:protected_tag) { create(:protected_tag, project: project, name: 'v*') }
+ context "with protected tag" do
+ let!(:protected_tag) { create(:protected_tag, project: project, name: "v*") }
- context 'as maintainer' do
+ context "as maintainer" do
before do
project.add_maintainer(user)
end
- context 'deletion' do
- let(:oldrev) { 'be93687618e4b132087f430a4d8fc3a609c9b77c' }
- let(:newrev) { '0000000000000000000000000000000000000000' }
+ context "deletion" do
+ let(:oldrev) { "be93687618e4b132087f430a4d8fc3a609c9b77c" }
+ let(:newrev) { "0000000000000000000000000000000000000000" }
- it 'is prevented' do
+ it "is prevented" do
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /cannot be deleted/)
end
end
- context 'update' do
- let(:oldrev) { 'be93687618e4b132087f430a4d8fc3a609c9b77c' }
- let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
+ context "update" do
+ let(:oldrev) { "be93687618e4b132087f430a4d8fc3a609c9b77c" }
+ let(:newrev) { "54fcc214b94e78d7a41a9a8fe6d87a5e59500e51" }
- it 'is prevented' do
+ it "is prevented" do
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /cannot be updated/)
end
end
end
- context 'creation' do
- let(:oldrev) { '0000000000000000000000000000000000000000' }
- let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
- let(:ref) { 'refs/tags/v9.1.0' }
+ context "creation" do
+ let(:oldrev) { "0000000000000000000000000000000000000000" }
+ let(:newrev) { "54fcc214b94e78d7a41a9a8fe6d87a5e59500e51" }
+ let(:ref) { "refs/tags/v9.1.0" }
- it 'prevents creation below access level' do
+ it "prevents creation below access level" do
expect { subject.validate! }.to raise_error(Gitlab::GitAccess::UnauthorizedError, /allowed to create this tag as it is protected/)
end
- context 'when user has access' do
- let!(:protected_tag) { create(:protected_tag, :developers_can_create, project: project, name: 'v*') }
+ context "when user has access" do
+ let!(:protected_tag) { create(:protected_tag, :developers_can_create, project: project, name: "v*") }
- it 'allows tag creation' do
+ it "allows tag creation" do
expect { subject.validate! }.not_to raise_error
end
end
diff --git a/spec/lib/gitlab/checks/timed_logger_spec.rb b/spec/lib/gitlab/checks/timed_logger_spec.rb
index 0ed3940c038..c76fef3c3be 100644
--- a/spec/lib/gitlab/checks/timed_logger_spec.rb
+++ b/spec/lib/gitlab/checks/timed_logger_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Checks::TimedLogger do
let!(:timeout) { 50.seconds }
@@ -9,7 +9,7 @@ describe Gitlab::Checks::TimedLogger do
let!(:logger) { described_class.new(start_time: start, timeout: timeout) }
let!(:log_messages) do
{
- foo: "Foo message..."
+ foo: "Foo message...",
}
end
@@ -17,8 +17,8 @@ describe Gitlab::Checks::TimedLogger do
logger.append_message("Checking ref: #{ref}")
end
- describe '#log_timed' do
- it 'logs message' do
+ describe "#log_timed" do
+ it "logs message" do
Timecop.freeze(start + 30.seconds) do
logger.log_timed(log_messages[:foo], start) { bar_check }
end
@@ -26,26 +26,26 @@ describe Gitlab::Checks::TimedLogger do
expect(logger.full_message).to eq("Checking ref: bar\nFoo message... (30000.0ms)")
end
- context 'when time limit was reached' do
- it 'cancels action' do
+ context "when time limit was reached" do
+ it "cancels action" do
Timecop.freeze(start + 50.seconds) do
- expect do
+ expect {
logger.log_timed(log_messages[:foo], start) do
bar_check
end
- end.to raise_error(described_class::TimeoutError)
+ }.to raise_error(described_class::TimeoutError)
end
expect(logger.full_message).to eq("Checking ref: bar\nFoo message... (cancelled)")
end
- it 'cancels action with time elapsed if work was performed' do
+ it "cancels action with time elapsed if work was performed" do
Timecop.freeze(start + 30.seconds) do
- expect do
+ expect {
logger.log_timed(log_messages[:foo], start) do
grpc_check
end
- end.to raise_error(described_class::TimeoutError)
+ }.to raise_error(described_class::TimeoutError)
expect(logger.full_message).to eq("Checking ref: bar\nFoo message... (cancelled after 30000.0ms)")
end
diff --git a/spec/lib/gitlab/ci/ansi2html_spec.rb b/spec/lib/gitlab/ci/ansi2html_spec.rb
index 5a5c071c639..9894e5b49e5 100644
--- a/spec/lib/gitlab/ci/ansi2html_spec.rb
+++ b/spec/lib/gitlab/ci/ansi2html_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Ansi2html do
subject { described_class }
it "prints non-ansi as-is" do
- expect(convert_html("Hello")).to eq('Hello')
+ expect(convert_html("Hello")).to eq("Hello")
end
it "strips non-color-changing control sequences" do
- expect(convert_html("Hello \e[2Kworld")).to eq('Hello world')
+ expect(convert_html("Hello \e[2Kworld")).to eq("Hello world")
end
it "prints simply red" do
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Ansi2html do
end
it "ignores unsupported codes" do
- expect(convert_html("\e[51mHello\e[0m")).to eq('Hello')
+ expect(convert_html("\e[51mHello\e[0m")).to eq("Hello")
end
it "prints light red" do
@@ -137,19 +137,19 @@ describe Gitlab::Ci::Ansi2html do
end
it "prints &lt;" do
- expect(convert_html("<")).to eq('&lt;')
+ expect(convert_html("<")).to eq("&lt;")
end
it "replaces newlines with line break tags" do
- expect(convert_html("\n")).to eq('<br>')
+ expect(convert_html("\n")).to eq("<br>")
end
it "groups carriage returns with newlines" do
- expect(convert_html("\r\n")).to eq('<br>')
+ expect(convert_html("\r\n")).to eq("<br>")
end
describe "incremental update" do
- shared_examples 'stateable converter' do
+ shared_examples "stateable converter" do
let(:pass1_stream) { StringIO.new(pre_text) }
let(:pass2_stream) { StringIO.new(pre_text + text) }
let(:pass1) { subject.convert(pass1_stream) }
@@ -168,7 +168,7 @@ describe Gitlab::Ci::Ansi2html do
let(:text) { "\e[1mWorld" }
let(:html) { "<span class=\"term-bold\"></span><span class=\"term-bold\">World</span>" }
- it_behaves_like 'stateable converter'
+ it_behaves_like "stateable converter"
end
context "with split sequence" do
@@ -177,7 +177,7 @@ describe Gitlab::Ci::Ansi2html do
let(:text) { "Hello" }
let(:html) { "<span class=\"term-bold\">Hello</span>" }
- it_behaves_like 'stateable converter'
+ it_behaves_like "stateable converter"
end
context "with partial sequence" do
@@ -186,21 +186,21 @@ describe Gitlab::Ci::Ansi2html do
let(:text) { "[1m World" }
let(:html) { "<span class=\"term-bold\"> World</span>" }
- it_behaves_like 'stateable converter'
+ it_behaves_like "stateable converter"
end
- context 'with new line' do
+ context "with new line" do
let(:pre_text) { "Hello\r" }
let(:pre_html) { "Hello\r" }
let(:text) { "\nWorld" }
let(:html) { "<br>World" }
- it_behaves_like 'stateable converter'
+ it_behaves_like "stateable converter"
end
end
context "with section markers" do
- let(:section_name) { 'test_section' }
+ let(:section_name) { "test_section" }
let(:section_start_time) { Time.new(2017, 9, 20).utc }
let(:section_duration) { 3.seconds }
let(:section_end_time) { section_start_time + section_duration }
@@ -217,58 +217,58 @@ describe Gitlab::Ci::Ansi2html do
"#{section_end[0...-5]}</div>"
end
- shared_examples 'forbidden char in section_name' do
- it 'ignores sections' do
+ shared_examples "forbidden char in section_name" do
+ it "ignores sections" do
text = "#{section_start}Some text#{section_end}"
- html = text.gsub("\033[0K", '').gsub('<', '&lt;')
+ html = text.gsub("\033[0K", "").gsub("<", "&lt;")
expect(convert_html(text)).to eq(html)
end
end
- shared_examples 'a legit section' do
+ shared_examples "a legit section" do
let(:text) { "#{section_start}Some text#{section_end}" }
- it 'prints light red' do
+ it "prints light red" do
text = "#{section_start}\e[91mHello\e[0m\n#{section_end}"
- html = %{#{section_start_html}<span class="term-fg-l-red">Hello</span><br>#{section_end_html}}
+ html = %(#{section_start_html}<span class="term-fg-l-red">Hello</span><br>#{section_end_html})
expect(convert_html(text)).to eq(html)
end
- it 'begins with a section_start html marker' do
+ it "begins with a section_start html marker" do
expect(convert_html(text)).to start_with(section_start_html)
end
- it 'ends with a section_end html marker' do
+ it "ends with a section_end html marker" do
expect(convert_html(text)).to end_with(section_end_html)
end
end
- it_behaves_like 'a legit section'
+ it_behaves_like "a legit section"
- context 'section name includes $' do
- let(:section_name) { 'my_$ection'}
+ context "section name includes $" do
+ let(:section_name) { "my_$ection"}
- it_behaves_like 'forbidden char in section_name'
+ it_behaves_like "forbidden char in section_name"
end
- context 'section name includes <' do
- let(:section_name) { '<a_tag>'}
+ context "section name includes <" do
+ let(:section_name) { "<a_tag>"}
- it_behaves_like 'forbidden char in section_name'
+ it_behaves_like "forbidden char in section_name"
end
- context 'section name contains .-_' do
- let(:section_name) { 'a.Legit-SeCtIoN_namE' }
+ context "section name contains .-_" do
+ let(:section_name) { "a.Legit-SeCtIoN_namE" }
- it_behaves_like 'a legit section'
+ it_behaves_like "a legit section"
end
- it 'do not allow XSS injections' do
+ it "do not allow XSS injections" do
text = "#{section_start}section_end:1:2<script>alert('XSS Hack!');</script>#{section_end}"
- expect(convert_html(text)).not_to include('<script>')
+ expect(convert_html(text)).not_to include("<script>")
end
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb
index 987c6b37aaa..323db5c3e86 100644
--- a/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/adapters/gzip_stream_spec.rb
@@ -1,54 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Artifacts::Adapters::GzipStream do
- describe '#initialize' do
- context 'when stream is passed' do
- let(:stream) { File.open(expand_fixture_path('junit/junit.xml.gz'), 'rb') }
+ describe "#initialize" do
+ context "when stream is passed" do
+ let(:stream) { File.open(expand_fixture_path("junit/junit.xml.gz"), "rb") }
- it 'initialized' do
+ it "initialized" do
expect { described_class.new(stream) }.not_to raise_error
end
end
- context 'when stream is not passed' do
+ context "when stream is not passed" do
let(:stream) { nil }
- it 'raises an error' do
+ it "raises an error" do
expect { described_class.new(stream) }.to raise_error(described_class::InvalidStreamError)
end
end
end
- describe '#each_blob' do
+ describe "#each_blob" do
let(:adapter) { described_class.new(stream) }
- context 'when stream is gzip file' do
- context 'when gzip file contains one file' do
- let(:stream) { File.open(expand_fixture_path('junit/junit.xml.gz'), 'rb') }
+ context "when stream is gzip file" do
+ context "when gzip file contains one file" do
+ let(:stream) { File.open(expand_fixture_path("junit/junit.xml.gz"), "rb") }
- it 'iterates content and file_name' do
+ it "iterates content and file_name" do
expect { |b| adapter.each_blob(&b) }
- .to yield_with_args(fixture_file('junit/junit.xml'), 'rspec.xml')
+ .to yield_with_args(fixture_file("junit/junit.xml"), "rspec.xml")
end
end
- context 'when gzip file contains three files' do
- let(:stream) { File.open(expand_fixture_path('junit/junit_with_three_testsuites.xml.gz'), 'rb') }
+ context "when gzip file contains three files" do
+ let(:stream) { File.open(expand_fixture_path("junit/junit_with_three_testsuites.xml.gz"), "rb") }
- it 'iterates content and file_name' do
+ it "iterates content and file_name" do
expect { |b| adapter.each_blob(&b) }
.to yield_successive_args(
- [fixture_file('junit/junit_with_three_testsuites_1.xml'), 'rspec-3.xml'],
- [fixture_file('junit/junit_with_three_testsuites_2.xml'), 'rspec-1.xml'],
- [fixture_file('junit/junit_with_three_testsuites_3.xml'), 'rspec-2.xml'])
+ [fixture_file("junit/junit_with_three_testsuites_1.xml"), "rspec-3.xml"],
+ [fixture_file("junit/junit_with_three_testsuites_2.xml"), "rspec-1.xml"],
+ [fixture_file("junit/junit_with_three_testsuites_3.xml"), "rspec-2.xml"]
+ )
end
end
end
- context 'when stream is zip file' do
- let(:stream) { File.open(expand_fixture_path('ci_build_artifacts.zip'), 'rb') }
+ context "when stream is zip file" do
+ let(:stream) { File.open(expand_fixture_path("ci_build_artifacts.zip"), "rb") }
- it 'raises an error' do
+ it "raises an error" do
expect { |b| adapter.each_blob(&b) }.to raise_error(described_class::InvalidStreamError)
end
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb
index ec2dd724b45..c81bd93f935 100644
--- a/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/adapters/raw_stream_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Artifacts::Adapters::RawStream do
- describe '#initialize' do
- context 'when stream is passed' do
- let(:stream) { File.open(expand_fixture_path('junit/junit.xml'), 'rb') }
+ describe "#initialize" do
+ context "when stream is passed" do
+ let(:stream) { File.open(expand_fixture_path("junit/junit.xml"), "rb") }
- it 'initialized' do
+ it "initialized" do
expect { described_class.new(stream) }.not_to raise_error
end
end
- context 'when stream is not passed' do
+ context "when stream is not passed" do
let(:stream) { nil }
- it 'raises an error' do
+ it "raises an error" do
expect { described_class.new(stream) }.to raise_error(described_class::InvalidStreamError)
end
end
end
- describe '#each_blob' do
+ describe "#each_blob" do
let(:adapter) { described_class.new(stream) }
- context 'when file is not empty' do
- let(:stream) { File.open(expand_fixture_path('junit/junit.xml'), 'rb') }
+ context "when file is not empty" do
+ let(:stream) { File.open(expand_fixture_path("junit/junit.xml"), "rb") }
- it 'iterates content' do
+ it "iterates content" do
expect { |b| adapter.each_blob(&b) }
- .to yield_with_args(fixture_file('junit/junit.xml'), 'raw')
+ .to yield_with_args(fixture_file("junit/junit.xml"), "raw")
end
end
- context 'when file is empty' do
+ context "when file is empty" do
let(:stream) { Tempfile.new }
after do
stream.unlink
end
- it 'does not iterate content' do
+ it "does not iterate content" do
expect { |b| adapter.each_blob(&b) }
.not_to yield_control
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
index 3b905611467..de79603eed3 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata/entry_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
let(:entries) do
- { 'path/' => {},
- 'path/dir_1/' => {},
- 'path/dir_1/file_1' => { size: 10 },
- 'path/dir_1/file_b' => { size: 10 },
- 'path/dir_1/subdir/' => {},
- 'path/dir_1/subdir/subfile' => { size: 10 },
- 'path/second_dir' => {},
- 'path/second_dir/dir_3/file_2' => { size: 10 },
- 'path/second_dir/dir_3/file_3' => { size: 10 },
- 'another_directory/' => {},
- 'another_file' => {},
- '/file/with/absolute_path' => {} }
+ {"path/" => {},
+ "path/dir_1/" => {},
+ "path/dir_1/file_1" => {size: 10},
+ "path/dir_1/file_b" => {size: 10},
+ "path/dir_1/subdir/" => {},
+ "path/dir_1/subdir/subfile" => {size: 10},
+ "path/second_dir" => {},
+ "path/second_dir/dir_3/file_2" => {size: 10},
+ "path/second_dir/dir_3/file_3" => {size: 10},
+ "another_directory/" => {},
+ "another_file" => {},
+ "/file/with/absolute_path" => {},}
end
def path(example)
@@ -24,123 +24,123 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
described_class.new(path, entries)
end
- describe '/file/with/absolute_path', path: '/file/with/absolute_path' do
+ describe "/file/with/absolute_path", path: "/file/with/absolute_path" do
subject { |example| path(example) }
it { is_expected.to be_file }
it { is_expected.to have_parent }
- describe '#basename' do
+ describe "#basename" do
subject { |example| path(example).basename }
- it { is_expected.to eq 'absolute_path' }
+ it { is_expected.to eq "absolute_path" }
end
end
- describe 'path/dir_1/', path: 'path/dir_1/' do
+ describe "path/dir_1/", path: "path/dir_1/" do
subject { |example| path(example) }
it { is_expected.to have_parent }
it { is_expected.to be_directory }
- describe '#basename' do
+ describe "#basename" do
subject { |example| path(example).basename }
- it { is_expected.to eq 'dir_1/' }
+ it { is_expected.to eq "dir_1/" }
end
- describe '#name' do
+ describe "#name" do
subject { |example| path(example).name }
- it { is_expected.to eq 'dir_1' }
+ it { is_expected.to eq "dir_1" }
end
- describe '#parent' do
+ describe "#parent" do
subject { |example| path(example).parent }
- it { is_expected.to eq entry('path/') }
+ it { is_expected.to eq entry("path/") }
end
- describe '#children' do
+ describe "#children" do
subject { |example| path(example).children }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
- is_expected.to contain_exactly entry('path/dir_1/file_1'),
- entry('path/dir_1/file_b'),
- entry('path/dir_1/subdir/')
+ is_expected.to contain_exactly entry("path/dir_1/file_1"),
+ entry("path/dir_1/file_b"),
+ entry("path/dir_1/subdir/")
end
end
- describe '#files' do
+ describe "#files" do
subject { |example| path(example).files }
it { is_expected.to all(be_file) }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
- is_expected.to contain_exactly entry('path/dir_1/file_1'),
- entry('path/dir_1/file_b')
+ is_expected.to contain_exactly entry("path/dir_1/file_1"),
+ entry("path/dir_1/file_b")
end
end
- describe '#directories' do
- context 'without options' do
+ describe "#directories" do
+ context "without options" do
subject { |example| path(example).directories }
it { is_expected.to all(be_directory) }
- it { is_expected.to all(be_an_instance_of described_class) }
- it { is_expected.to contain_exactly entry('path/dir_1/subdir/') }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
+ it { is_expected.to contain_exactly entry("path/dir_1/subdir/") }
end
- context 'with option parent: true' do
+ context "with option parent: true" do
subject { |example| path(example).directories(parent: true) }
it { is_expected.to all(be_directory) }
- it { is_expected.to all(be_an_instance_of described_class) }
+ it { is_expected.to all(be_an_instance_of(described_class)) }
it do
- is_expected.to contain_exactly entry('path/dir_1/subdir/'),
- entry('path/')
+ is_expected.to contain_exactly entry("path/dir_1/subdir/"),
+ entry("path/")
end
end
- describe '#nodes' do
+ describe "#nodes" do
subject { |example| path(example).nodes }
it { is_expected.to eq 2 }
end
- describe '#exists?' do
+ describe "#exists?" do
subject { |example| path(example).exists? }
it { is_expected.to be true }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { |example| path(example).empty? }
it { is_expected.to be false }
end
- describe '#total_size' do
+ describe "#total_size" do
subject { |example| path(example).total_size }
it { is_expected.to eq(30) }
end
end
end
- describe 'empty path', path: '' do
+ describe "empty path", path: "" do
subject { |example| path(example) }
it { is_expected.not_to have_parent }
- describe '#children' do
+ describe "#children" do
subject { |example| path(example).children }
it { expect(subject.count).to eq 3 }
end
end
- describe 'path/dir_1/subdir/subfile', path: 'path/dir_1/subdir/subfile' do
- describe '#nodes' do
+ describe "path/dir_1/subdir/subfile", path: "path/dir_1/subdir/subfile" do
+ describe "#nodes" do
subject { |example| path(example).nodes }
it { is_expected.to eq 4 }
end
- describe '#blob' do
+ describe "#blob" do
let(:file_entry) { |example| path(example) }
subject { file_entry.blob }
- it 'returns a blob representing the entry data' do
+ it "returns a blob representing the entry data" do
expect(subject).to be_a(Blob)
expect(subject.path).to eq(file_entry.path)
expect(subject.size).to eq(file_entry.metadata[:size])
@@ -148,36 +148,36 @@ describe Gitlab::Ci::Build::Artifacts::Metadata::Entry do
end
end
- describe 'non-existent/', path: 'non-existent/' do
- describe '#empty?' do
+ describe "non-existent/", path: "non-existent/" do
+ describe "#empty?" do
subject { |example| path(example).empty? }
it { is_expected.to be true }
end
- describe '#exists?' do
+ describe "#exists?" do
subject { |example| path(example).exists? }
it { is_expected.to be false }
end
end
- describe 'another_directory/', path: 'another_directory/' do
- describe '#empty?' do
+ describe "another_directory/", path: "another_directory/" do
+ describe "#empty?" do
subject { |example| path(example).empty? }
it { is_expected.to be true }
end
end
- describe '#metadata' do
+ describe "#metadata" do
let(:entries) do
- { 'path/' => { name: '/path/' },
- 'path/file1' => { name: '/path/file1' },
- 'path/file2' => { name: '/path/file2' } }
+ {"path/" => {name: "/path/"},
+ "path/file1" => {name: "/path/file1"},
+ "path/file2" => {name: "/path/file2"},}
end
subject do
- described_class.new('path/file1', entries).metadata[:name]
+ described_class.new("path/file1", entries).metadata[:name]
end
- it { is_expected.to eq '/path/file1' }
+ it { is_expected.to eq "/path/file1" }
end
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
index a9a4af1f455..5bf4ebe5f9c 100644
--- a/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/metadata_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Artifacts::Metadata do
- def metadata(path = '', **opts)
+ def metadata(path = "", **opts)
described_class.new(metadata_file_stream, path, **opts)
end
let(:metadata_file_path) do
- Rails.root + 'spec/fixtures/ci_build_artifacts_metadata.gz'
+ Rails.root + "spec/fixtures/ci_build_artifacts_metadata.gz"
end
let(:metadata_file_stream) do
@@ -17,104 +17,104 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
metadata_file_stream&.close
end
- context 'metadata file exists' do
- describe '#find_entries! empty string' do
- subject { metadata('').find_entries! }
+ context "metadata file exists" do
+ describe "#find_entries! empty string" do
+ subject { metadata("").find_entries! }
- it 'matches correct paths' do
- expect(subject.keys).to contain_exactly 'ci_artifacts.txt',
- 'other_artifacts_0.1.2/',
- 'rails_sample.jpg',
- 'tests_encoding/'
+ it "matches correct paths" do
+ expect(subject.keys).to contain_exactly "ci_artifacts.txt",
+ "other_artifacts_0.1.2/",
+ "rails_sample.jpg",
+ "tests_encoding/"
end
- it 'matches metadata for every path' do
+ it "matches metadata for every path" do
expect(subject.keys.count).to eq 4
end
- it 'return Hashes for each metadata' do
+ it "return Hashes for each metadata" do
expect(subject.values).to all(be_kind_of(Hash))
end
end
- describe '#find_entries! other_artifacts_0.1.2/' do
- subject { metadata('other_artifacts_0.1.2/').find_entries! }
+ describe "#find_entries! other_artifacts_0.1.2/" do
+ subject { metadata("other_artifacts_0.1.2/").find_entries! }
- it 'matches correct paths' do
+ it "matches correct paths" do
expect(subject.keys)
- .to contain_exactly 'other_artifacts_0.1.2/',
- 'other_artifacts_0.1.2/doc_sample.txt',
- 'other_artifacts_0.1.2/another-subdirectory/'
+ .to contain_exactly "other_artifacts_0.1.2/",
+ "other_artifacts_0.1.2/doc_sample.txt",
+ "other_artifacts_0.1.2/another-subdirectory/"
end
end
- describe '#find_entries! other_artifacts_0.1.2/another-subdirectory/' do
- subject { metadata('other_artifacts_0.1.2/another-subdirectory/').find_entries! }
+ describe "#find_entries! other_artifacts_0.1.2/another-subdirectory/" do
+ subject { metadata("other_artifacts_0.1.2/another-subdirectory/").find_entries! }
- it 'matches correct paths' do
+ it "matches correct paths" do
expect(subject.keys)
- .to contain_exactly 'other_artifacts_0.1.2/another-subdirectory/',
- 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
- 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
+ .to contain_exactly "other_artifacts_0.1.2/another-subdirectory/",
+ "other_artifacts_0.1.2/another-subdirectory/empty_directory/",
+ "other_artifacts_0.1.2/another-subdirectory/banana_sample.gif"
end
end
- describe '#find_entries! recursively for other_artifacts_0.1.2/' do
- subject { metadata('other_artifacts_0.1.2/', recursive: true).find_entries! }
+ describe "#find_entries! recursively for other_artifacts_0.1.2/" do
+ subject { metadata("other_artifacts_0.1.2/", recursive: true).find_entries! }
- it 'matches correct paths' do
+ it "matches correct paths" do
expect(subject.keys)
- .to contain_exactly 'other_artifacts_0.1.2/',
- 'other_artifacts_0.1.2/doc_sample.txt',
- 'other_artifacts_0.1.2/another-subdirectory/',
- 'other_artifacts_0.1.2/another-subdirectory/empty_directory/',
- 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
+ .to contain_exactly "other_artifacts_0.1.2/",
+ "other_artifacts_0.1.2/doc_sample.txt",
+ "other_artifacts_0.1.2/another-subdirectory/",
+ "other_artifacts_0.1.2/another-subdirectory/empty_directory/",
+ "other_artifacts_0.1.2/another-subdirectory/banana_sample.gif"
end
end
- describe '#to_entry' do
- subject { metadata('').to_entry }
+ describe "#to_entry" do
+ subject { metadata("").to_entry }
it { is_expected.to be_an_instance_of(Gitlab::Ci::Build::Artifacts::Metadata::Entry) }
end
- describe '#full_version' do
- subject { metadata('').full_version }
- it { is_expected.to eq 'GitLab Build Artifacts Metadata 0.0.1' }
+ describe "#full_version" do
+ subject { metadata("").full_version }
+ it { is_expected.to eq "GitLab Build Artifacts Metadata 0.0.1" }
end
- describe '#version' do
- subject { metadata('').version }
- it { is_expected.to eq '0.0.1' }
+ describe "#version" do
+ subject { metadata("").version }
+ it { is_expected.to eq "0.0.1" }
end
- describe '#errors' do
- subject { metadata('').errors }
+ describe "#errors" do
+ subject { metadata("").errors }
it { is_expected.to eq({}) }
end
end
- context 'metadata file does not exist' do
+ context "metadata file does not exist" do
let(:metadata_file_path) { nil }
- describe '#find_entries!' do
- it 'raises error' do
+ describe "#find_entries!" do
+ it "raises error" do
expect { metadata.find_entries! }.to raise_error(described_class::InvalidStreamError, /Invalid stream/)
end
end
end
- context 'metadata file is invalid' do
- let(:metadata_file_path) { Rails.root + 'spec/fixtures/ci_build_artifacts.zip' }
+ context "metadata file is invalid" do
+ let(:metadata_file_path) { Rails.root + "spec/fixtures/ci_build_artifacts.zip" }
- describe '#find_entries!' do
- it 'raises error' do
+ describe "#find_entries!" do
+ it "raises error" do
expect { metadata.find_entries! }.to raise_error(described_class::InvalidStreamError, /not in gzip format/)
end
end
end
- context 'generated metadata' do
- let(:tmpfile) { Tempfile.new('test-metadata') }
+ context "generated metadata" do
+ let(:tmpfile) { Tempfile.new("test-metadata") }
let(:generator) { CiArtifactMetadataGenerator.new(tmpfile) }
let(:entry_count) { 5 }
@@ -132,11 +132,11 @@ describe Gitlab::Ci::Build::Artifacts::Metadata do
File.unlink(tmpfile.path)
end
- describe '#find_entries!' do
- it 'reads expected number of entries' do
+ describe "#find_entries!" do
+ it "reads expected number of entries" do
stream = File.open(tmpfile.path)
- metadata = described_class.new(stream, 'public', { recursive: true })
+ metadata = described_class.new(stream, "public", {recursive: true})
expect(metadata.find_entries!.count).to eq entry_count
end
diff --git a/spec/lib/gitlab/ci/build/artifacts/path_spec.rb b/spec/lib/gitlab/ci/build/artifacts/path_spec.rb
index 7bd6a2ead25..9396f3d6015 100644
--- a/spec/lib/gitlab/ci/build/artifacts/path_spec.rb
+++ b/spec/lib/gitlab/ci/build/artifacts/path_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Artifacts::Path do
- describe '#valid?' do
- context 'when path contains a zero character' do
- it 'is not valid' do
+ describe "#valid?" do
+ context "when path contains a zero character" do
+ it "is not valid" do
expect(described_class.new("something/\255")).not_to be_valid
end
end
- context 'when path is not utf8 string' do
- it 'is not valid' do
+ context "when path is not utf8 string" do
+ it "is not valid" do
expect(described_class.new("something/\0")).not_to be_valid
end
end
- context 'when path is valid' do
- it 'is valid' do
+ context "when path is valid" do
+ it "is valid" do
expect(described_class.new("some/file/path")).to be_valid
end
end
end
- describe '#directory?' do
- context 'when path ends with a directory indicator' do
- it 'is a directory' do
+ describe "#directory?" do
+ context "when path ends with a directory indicator" do
+ it "is a directory" do
expect(described_class.new("some/file/dir/")).to be_directory
end
end
- context 'when path does not end with a directory indicator' do
- it 'is not a directory' do
+ context "when path does not end with a directory indicator" do
+ it "is not a directory" do
expect(described_class.new("some/file")).not_to be_directory
end
end
end
- describe '#name' do
- it 'returns a base name' do
- expect(described_class.new("some/file").name).to eq 'file'
+ describe "#name" do
+ it "returns a base name" do
+ expect(described_class.new("some/file").name).to eq "file"
end
end
- describe '#nodes' do
- it 'returns number of path nodes' do
+ describe "#nodes" do
+ it "returns number of path nodes" do
expect(described_class.new("some/dir/file").nodes).to eq 2
end
end
- describe '#to_s' do
- context 'when path is valid' do
- it 'returns a string representation of a path' do
- expect(described_class.new('some/path').to_s).to eq 'some/path'
+ describe "#to_s" do
+ context "when path is valid" do
+ it "returns a string representation of a path" do
+ expect(described_class.new("some/path").to_s).to eq "some/path"
end
end
- context 'when path is invalid' do
- it 'raises an error' do
+ context "when path is invalid" do
+ it "raises an error" do
expect { described_class.new("invalid/\0").to_s }
.to raise_error ArgumentError
end
diff --git a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
index d53db05e5e6..02bd86ceee8 100644
--- a/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
+++ b/spec/lib/gitlab/ci/build/credentials/factory_spec.rb
@@ -1,36 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Credentials::Factory do
- let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
+ let(:build) { create(:ci_build, name: "spinach", stage: "test", stage_idx: 0) }
subject { described_class.new(build).create! }
class TestProvider
- def initialize(build); end
+ def initialize(build)
+ end
end
before do
allow_any_instance_of(described_class).to receive(:providers).and_return([TestProvider])
end
- context 'when provider is valid' do
+ context "when provider is valid" do
before do
allow_any_instance_of(TestProvider).to receive(:valid?).and_return(true)
end
- it 'generates an array of credentials objects' do
+ it "generates an array of credentials objects" do
is_expected.to be_kind_of(Array)
is_expected.not_to be_empty
expect(subject.first).to be_kind_of(TestProvider)
end
end
- context 'when provider is not valid' do
+ context "when provider is not valid" do
before do
allow_any_instance_of(TestProvider).to receive(:valid?).and_return(false)
end
- it 'generates an array without specific credential object' do
+ it "generates an array without specific credential object" do
is_expected.to be_kind_of(Array)
is_expected.to be_empty
end
diff --git a/spec/lib/gitlab/ci/build/credentials/registry_spec.rb b/spec/lib/gitlab/ci/build/credentials/registry_spec.rb
index c6054138cde..c549862491a 100644
--- a/spec/lib/gitlab/ci/build/credentials/registry_spec.rb
+++ b/spec/lib/gitlab/ci/build/credentials/registry_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Credentials::Registry do
- let(:build) { create(:ci_build, name: 'spinach', stage: 'test', stage_idx: 0) }
- let(:registry_url) { 'registry.example.com:5005' }
+ let(:build) { create(:ci_build, name: "spinach", stage: "test", stage_idx: 0) }
+ let(:registry_url) { "registry.example.com:5005" }
subject { described_class.new(build) }
@@ -10,19 +10,19 @@ describe Gitlab::Ci::Build::Credentials::Registry do
stub_container_registry_config(host_port: registry_url)
end
- it 'contains valid DockerRegistry credentials' do
+ it "contains valid DockerRegistry credentials" do
expect(subject).to be_kind_of(described_class)
- expect(subject.username).to eq 'gitlab-ci-token'
+ expect(subject.username).to eq "gitlab-ci-token"
expect(subject.password).to eq build.token
expect(subject.url).to eq registry_url
- expect(subject.type).to eq 'registry'
+ expect(subject.type).to eq "registry"
end
- describe '.valid?' do
+ describe ".valid?" do
subject { described_class.new(build).valid? }
- context 'when registry is enabled' do
+ context "when registry is enabled" do
before do
stub_container_registry_config(enabled: true)
end
@@ -30,7 +30,7 @@ describe Gitlab::Ci::Build::Credentials::Registry do
it { is_expected.to be_truthy }
end
- context 'when registry is disabled' do
+ context "when registry is disabled" do
before do
stub_container_registry_config(enabled: false)
end
diff --git a/spec/lib/gitlab/ci/build/image_spec.rb b/spec/lib/gitlab/ci/build/image_spec.rb
index 773a52cdfbc..2c0180719bf 100644
--- a/spec/lib/gitlab/ci/build/image_spec.rb
+++ b/spec/lib/gitlab/ci/build/image_spec.rb
@@ -1,90 +1,90 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Image do
let(:job) { create(:ci_build, :no_options) }
- describe '#from_image' do
+ describe "#from_image" do
subject { described_class.from_image(job) }
- context 'when image is defined in job' do
- let(:image_name) { 'ruby:2.1' }
- let(:job) { create(:ci_build, options: { image: image_name } ) }
+ context "when image is defined in job" do
+ let(:image_name) { "ruby:2.1" }
+ let(:job) { create(:ci_build, options: {image: image_name}) }
- context 'when image is defined as string' do
- it 'fabricates an object of the proper class' do
+ context "when image is defined as string" do
+ it "fabricates an object of the proper class" do
is_expected.to be_kind_of(described_class)
end
- it 'populates fabricated object with the proper name attribute' do
+ it "populates fabricated object with the proper name attribute" do
expect(subject.name).to eq(image_name)
end
end
- context 'when image is defined as hash' do
- let(:entrypoint) { '/bin/sh' }
- let(:job) { create(:ci_build, options: { image: { name: image_name, entrypoint: entrypoint } } ) }
+ context "when image is defined as hash" do
+ let(:entrypoint) { "/bin/sh" }
+ let(:job) { create(:ci_build, options: {image: {name: image_name, entrypoint: entrypoint}}) }
- it 'fabricates an object of the proper class' do
+ it "fabricates an object of the proper class" do
is_expected.to be_kind_of(described_class)
end
- it 'populates fabricated object with the proper attributes' do
+ it "populates fabricated object with the proper attributes" do
expect(subject.name).to eq(image_name)
expect(subject.entrypoint).to eq(entrypoint)
end
end
- context 'when image name is empty' do
- let(:image_name) { '' }
+ context "when image name is empty" do
+ let(:image_name) { "" }
- it 'does not fabricate an object' do
+ it "does not fabricate an object" do
is_expected.to be_nil
end
end
end
- context 'when image is not defined in job' do
- it 'does not fabricate an object' do
+ context "when image is not defined in job" do
+ it "does not fabricate an object" do
is_expected.to be_nil
end
end
end
- describe '#from_services' do
+ describe "#from_services" do
subject { described_class.from_services(job) }
- context 'when services are defined in job' do
- let(:service_image_name) { 'postgres' }
- let(:job) { create(:ci_build, options: { services: [service_image_name] }) }
+ context "when services are defined in job" do
+ let(:service_image_name) { "postgres" }
+ let(:job) { create(:ci_build, options: {services: [service_image_name]}) }
- context 'when service is defined as string' do
- it 'fabricates an non-empty array of objects' do
+ context "when service is defined as string" do
+ it "fabricates an non-empty array of objects" do
is_expected.to be_kind_of(Array)
is_expected.not_to be_empty
end
- it 'populates fabricated objects with the proper name attributes' do
+ it "populates fabricated objects with the proper name attributes" do
expect(subject.first).to be_kind_of(described_class)
expect(subject.first.name).to eq(service_image_name)
end
end
- context 'when service is defined as hash' do
- let(:service_entrypoint) { '/bin/sh' }
- let(:service_alias) { 'db' }
- let(:service_command) { 'sleep 30' }
+ context "when service is defined as hash" do
+ let(:service_entrypoint) { "/bin/sh" }
+ let(:service_alias) { "db" }
+ let(:service_command) { "sleep 30" }
let(:job) do
- create(:ci_build, options: { services: [{ name: service_image_name, entrypoint: service_entrypoint,
- alias: service_alias, command: service_command }] })
+ create(:ci_build, options: {services: [{name: service_image_name, entrypoint: service_entrypoint,
+ alias: service_alias, command: service_command,}]})
end
- it 'fabricates an non-empty array of objects' do
+ it "fabricates an non-empty array of objects" do
is_expected.to be_kind_of(Array)
is_expected.not_to be_empty
expect(subject.first).to be_kind_of(described_class)
end
- it 'populates fabricated objects with the proper attributes' do
+ it "populates fabricated objects with the proper attributes" do
expect(subject.first.name).to eq(service_image_name)
expect(subject.first.entrypoint).to eq(service_entrypoint)
expect(subject.first.alias).to eq(service_alias)
@@ -92,18 +92,18 @@ describe Gitlab::Ci::Build::Image do
end
end
- context 'when service image name is empty' do
- let(:service_image_name) { '' }
+ context "when service image name is empty" do
+ let(:service_image_name) { "" }
- it 'fabricates an empty array' do
+ it "fabricates an empty array" do
is_expected.to be_kind_of(Array)
is_expected.to be_empty
end
end
end
- context 'when services are not defined in job' do
- it 'fabricates an empty array' do
+ context "when services are not defined in job" do
+ it "fabricates an empty array" do
is_expected.to be_kind_of(Array)
is_expected.to be_empty
end
diff --git a/spec/lib/gitlab/ci/build/policy/changes_spec.rb b/spec/lib/gitlab/ci/build/policy/changes_spec.rb
index dc3329061d1..e4e3e0a4897 100644
--- a/spec/lib/gitlab/ci/build/policy/changes_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/changes_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Policy::Changes do
set(:project) { create(:project) }
- describe '#satisfied_by?' do
- describe 'paths matching' do
+ describe "#satisfied_by?" do
+ describe "paths matching" do
let(:pipeline) do
build(:ci_empty_pipeline, project: project,
- ref: 'master',
+ ref: "master",
source: :push,
- sha: '1234abcd',
- before_sha: '0123aabb')
+ sha: "1234abcd",
+ before_sha: "0123aabb")
end
let(:ci_build) do
- build(:ci_build, pipeline: pipeline, project: project, ref: 'master')
+ build(:ci_build, pipeline: pipeline, project: project, ref: "master")
end
- let(:seed) { double('build seed', to_resource: ci_build) }
+ let(:seed) { double("build seed", to_resource: ci_build) }
before do
allow(pipeline).to receive(:modified_paths) do
@@ -25,60 +25,60 @@ describe Gitlab::Ci::Build::Policy::Changes do
end
end
- it 'is satisfied by matching literal path' do
+ it "is satisfied by matching literal path" do
policy = described_class.new(%w[some/other_file.txt])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by matching simple pattern' do
+ it "is satisfied by matching simple pattern" do
policy = described_class.new(%w[some/*.txt])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by matching recusive pattern' do
+ it "is satisfied by matching recusive pattern" do
policy = described_class.new(%w[some/**/*.rb])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by matching a pattern with a dot' do
+ it "is satisfied by matching a pattern with a dot" do
policy = described_class.new(%w[some/*/file])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by matching a pattern with a glob' do
+ it "is satisfied by matching a pattern with a glob" do
policy = described_class.new(%w[some/**/*.{rb,txt}])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied when pattern does not match path' do
+ it "is not satisfied when pattern does not match path" do
policy = described_class.new(%w[some/*.rb])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied when pattern does not match' do
+ it "is not satisfied when pattern does not match" do
policy = described_class.new(%w[invalid/*.md])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- it 'is not satified when pattern with glob does not match' do
+ it "is not satified when pattern with glob does not match" do
policy = described_class.new(%w[invalid/*.{md,rake}])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- context 'when modified paths can not be evaluated' do
+ context "when modified paths can not be evaluated" do
before do
allow(pipeline).to receive(:modified_paths) { nil }
end
- it 'is always satisfied' do
+ it "is always satisfied" do
policy = described_class.new(%w[invalid/*])
expect(policy).to be_satisfied_by(pipeline, seed)
@@ -86,81 +86,81 @@ describe Gitlab::Ci::Build::Policy::Changes do
end
end
- describe 'gitaly integration' do
+ describe "gitaly integration" do
set(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_empty_pipeline, project: project,
- ref: 'master',
+ ref: "master",
source: :push,
- sha: '498214d',
- before_sha: '281d3a7')
+ sha: "498214d",
+ before_sha: "281d3a7")
end
let(:build) do
- create(:ci_build, pipeline: pipeline, project: project, ref: 'master')
+ create(:ci_build, pipeline: pipeline, project: project, ref: "master")
end
- let(:seed) { double('build seed', to_resource: build) }
+ let(:seed) { double("build seed", to_resource: build) }
- it 'is satisfied by changes introduced by a push' do
- policy = described_class.new(['with space/*.md'])
+ it "is satisfied by changes introduced by a push" do
+ policy = described_class.new(["with space/*.md"])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied by changes that are not in the push' do
+ it "is not satisfied by changes that are not in the push" do
policy = described_class.new(%w[files/js/commit.js])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
end
- context 'when branch is created' do
+ context "when branch is created" do
let(:pipeline) do
create(:ci_empty_pipeline, project: project,
- ref: 'feature',
+ ref: "feature",
source: source,
- sha: '0b4bc9a4',
+ sha: "0b4bc9a4",
before_sha: Gitlab::Git::BLANK_SHA,
merge_request: merge_request)
end
let(:ci_build) do
- build(:ci_build, pipeline: pipeline, project: project, ref: 'feature')
+ build(:ci_build, pipeline: pipeline, project: project, ref: "feature")
end
- let(:seed) { double('build seed', to_resource: ci_build) }
+ let(:seed) { double("build seed", to_resource: ci_build) }
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:source) { :merge_request }
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'is satified by changes in the merge request' do
+ it "is satified by changes in the merge request" do
policy = described_class.new(%w[files/ruby/feature.rb])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satified by changes not in the merge request' do
+ it "is not satified by changes not in the merge request" do
policy = described_class.new(%w[foo.rb])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
end
- context 'when source is push' do
+ context "when source is push" do
let(:source) { :push }
let(:merge_request) { nil }
- it 'is always satified' do
+ it "is always satified" do
policy = described_class.new(%w[foo.rb])
expect(policy).to be_satisfied_by(pipeline, seed)
diff --git a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
index 4884d5f8ba4..bef0425988e 100644
--- a/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/kubernetes_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Policy::Kubernetes do
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when kubernetes service is active' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'is satisfied by a kubernetes pipeline' do
- expect(described_class.new('active'))
+ context "when kubernetes service is active" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "is satisfied by a kubernetes pipeline" do
+ expect(described_class.new("active"))
.to be_satisfied_by(pipeline)
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'when kubernetes service is inactive' do
+ context "when kubernetes service is inactive" do
set(:project) { create(:project) }
- it 'is not satisfied by a pipeline without kubernetes available' do
- expect(described_class.new('active'))
+ it "is not satisfied by a pipeline without kubernetes available" do
+ expect(described_class.new("active"))
.not_to be_satisfied_by(pipeline)
end
end
- context 'when kubernetes policy is invalid' do
- it 'raises an error' do
- expect { described_class.new('unknown') }
+ context "when kubernetes policy is invalid" do
+ it "raises an error" do
+ expect { described_class.new("unknown") }
.to raise_error(described_class::UnknownPolicyError)
end
end
diff --git a/spec/lib/gitlab/ci/build/policy/refs_spec.rb b/spec/lib/gitlab/ci/build/policy/refs_spec.rb
index 553fc0fb9bf..c583572dfe2 100644
--- a/spec/lib/gitlab/ci/build/policy/refs_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/refs_spec.rb
@@ -1,85 +1,85 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Policy::Refs do
- describe '#satisfied_by?' do
- context 'when matching ref' do
- let(:pipeline) { build_stubbed(:ci_pipeline, ref: 'master') }
+ describe "#satisfied_by?" do
+ context "when matching ref" do
+ let(:pipeline) { build_stubbed(:ci_pipeline, ref: "master") }
- it 'is satisfied when pipeline branch matches' do
+ it "is satisfied when pipeline branch matches" do
expect(described_class.new(%w[master deploy]))
.to be_satisfied_by(pipeline)
end
- it 'is not satisfied when pipeline branch does not match' do
+ it "is not satisfied when pipeline branch does not match" do
expect(described_class.new(%w[feature fix]))
.not_to be_satisfied_by(pipeline)
end
end
- context 'when matching tags' do
- context 'when pipeline runs for a tag' do
+ context "when matching tags" do
+ context "when pipeline runs for a tag" do
let(:pipeline) do
- build_stubbed(:ci_pipeline, ref: 'feature', tag: true)
+ build_stubbed(:ci_pipeline, ref: "feature", tag: true)
end
- it 'is satisfied when tags matcher is specified' do
+ it "is satisfied when tags matcher is specified" do
expect(described_class.new(%w[master tags]))
.to be_satisfied_by(pipeline)
end
end
- context 'when pipeline is not created for a tag' do
+ context "when pipeline is not created for a tag" do
let(:pipeline) do
- build_stubbed(:ci_pipeline, ref: 'feature', tag: false)
+ build_stubbed(:ci_pipeline, ref: "feature", tag: false)
end
- it 'is not satisfied when tag match is specified' do
+ it "is not satisfied when tag match is specified" do
expect(described_class.new(%w[master tags]))
.not_to be_satisfied_by(pipeline)
end
end
end
- context 'when also matching a path' do
+ context "when also matching a path" do
let(:pipeline) do
- build_stubbed(:ci_pipeline, ref: 'master')
+ build_stubbed(:ci_pipeline, ref: "master")
end
- it 'is satisfied when provided patch matches specified one' do
+ it "is satisfied when provided patch matches specified one" do
expect(described_class.new(%W[master@#{pipeline.project_full_path}]))
.to be_satisfied_by(pipeline)
end
- it 'is not satisfied when path differs' do
+ it "is not satisfied when path differs" do
expect(described_class.new(%w[master@some/fork/repository]))
.not_to be_satisfied_by(pipeline)
end
end
- context 'when matching a source' do
+ context "when matching a source" do
let(:pipeline) { build_stubbed(:ci_pipeline, source: :push) }
- it 'is satisfied when provided source keyword matches' do
+ it "is satisfied when provided source keyword matches" do
expect(described_class.new(%w[pushes]))
.to be_satisfied_by(pipeline)
end
- it 'is not satisfied when provided source keyword does not match' do
+ it "is not satisfied when provided source keyword does not match" do
expect(described_class.new(%w[triggers]))
.not_to be_satisfied_by(pipeline)
end
end
- context 'when matching a ref by a regular expression' do
- let(:pipeline) { build_stubbed(:ci_pipeline, ref: 'docs-something') }
+ context "when matching a ref by a regular expression" do
+ let(:pipeline) { build_stubbed(:ci_pipeline, ref: "docs-something") }
- it 'is satisfied when regexp matches pipeline ref' do
- expect(described_class.new(['/docs-.*/']))
+ it "is satisfied when regexp matches pipeline ref" do
+ expect(described_class.new(["/docs-.*/"]))
.to be_satisfied_by(pipeline)
end
- it 'is not satisfied when regexp does not match pipeline ref' do
- expect(described_class.new(['/fix-.*/']))
+ it "is not satisfied when regexp does not match pipeline ref" do
+ expect(described_class.new(["/fix-.*/"]))
.not_to be_satisfied_by(pipeline)
end
end
diff --git a/spec/lib/gitlab/ci/build/policy/variables_spec.rb b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
index c2c0742efc3..7ff0191a3d8 100644
--- a/spec/lib/gitlab/ci/build/policy/variables_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy/variables_spec.rb
@@ -1,69 +1,69 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Policy::Variables do
set(:project) { create(:project) }
let(:pipeline) do
- build(:ci_empty_pipeline, project: project, ref: 'master', source: :push)
+ build(:ci_empty_pipeline, project: project, ref: "master", source: :push)
end
let(:ci_build) do
- build(:ci_build, pipeline: pipeline, project: project, ref: 'master')
+ build(:ci_build, pipeline: pipeline, project: project, ref: "master")
end
- let(:seed) { double('build seed', to_resource: ci_build) }
+ let(:seed) { double("build seed", to_resource: ci_build) }
before do
- pipeline.variables.build(key: 'CI_PROJECT_NAME', value: '')
+ pipeline.variables.build(key: "CI_PROJECT_NAME", value: "")
end
- describe '#satisfied_by?' do
- it 'is satisfied by at least one matching statement' do
- policy = described_class.new(['$CI_PROJECT_ID', '$UNDEFINED'])
+ describe "#satisfied_by?" do
+ it "is satisfied by at least one matching statement" do
+ policy = described_class.new(["$CI_PROJECT_ID", "$UNDEFINED"])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied by an overridden empty variable' do
- policy = described_class.new(['$CI_PROJECT_NAME'])
+ it "is not satisfied by an overridden empty variable" do
+ policy = described_class.new(["$CI_PROJECT_NAME"])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by a truthy pipeline expression' do
+ it "is satisfied by a truthy pipeline expression" do
policy = described_class.new([%($CI_PIPELINE_SOURCE == "push")])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied by a falsy pipeline expression' do
+ it "is not satisfied by a falsy pipeline expression" do
policy = described_class.new([%($CI_PIPELINE_SOURCE == "invalid source")])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- it 'is satisfied by a truthy expression using undefined variable' do
- policy = described_class.new(['$UNDEFINED == null'])
+ it "is satisfied by a truthy expression using undefined variable" do
+ policy = described_class.new(["$UNDEFINED == null"])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'is not satisfied by a falsy expression using undefined variable' do
- policy = described_class.new(['$UNDEFINED'])
+ it "is not satisfied by a falsy expression using undefined variable" do
+ policy = described_class.new(["$UNDEFINED"])
expect(policy).not_to be_satisfied_by(pipeline, seed)
end
- it 'allows to evaluate regular CI variables' do
- create(:ci_variable, project: project, key: 'SECRET', value: 'my secret')
+ it "allows to evaluate regular CI variables" do
+ create(:ci_variable, project: project, key: "SECRET", value: "my secret")
policy = described_class.new(["$SECRET == 'my secret'"])
expect(policy).to be_satisfied_by(pipeline, seed)
end
- it 'does not persist neither pipeline nor build' do
- described_class.new('$VAR').satisfied_by?(pipeline, seed)
+ it "does not persist neither pipeline nor build" do
+ described_class.new("$VAR").satisfied_by?(pipeline, seed)
expect(pipeline).not_to be_persisted
expect(seed.to_resource).not_to be_persisted
diff --git a/spec/lib/gitlab/ci/build/policy_spec.rb b/spec/lib/gitlab/ci/build/policy_spec.rb
index 20ee3dd3e89..e2ce66de0bc 100644
--- a/spec/lib/gitlab/ci/build/policy_spec.rb
+++ b/spec/lib/gitlab/ci/build/policy_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Policy do
- let(:policy) { spy('policy specification') }
+ let(:policy) { spy("policy specification") }
before do
stub_const("#{described_class}::Something", policy)
end
- describe '.fabricate' do
- context 'when policy exists' do
- it 'fabricates and initializes relevant policy' do
- specs = described_class.fabricate(something: 'some value')
+ describe ".fabricate" do
+ context "when policy exists" do
+ it "fabricates and initializes relevant policy" do
+ specs = described_class.fabricate(something: "some value")
expect(specs).to be_an Array
expect(specs).to be_one
- expect(policy).to have_received(:new).with('some value')
+ expect(policy).to have_received(:new).with("some value")
end
end
- context 'when some policies are not defined' do
- it 'gracefully skips unknown policies' do
- expect { described_class.fabricate(unknown: 'first') }
+ context "when some policies are not defined" do
+ it "gracefully skips unknown policies" do
+ expect { described_class.fabricate(unknown: "first") }
.to raise_error(NameError)
end
end
- context 'when passing a nil value as specs' do
- it 'returns an empty array' do
+ context "when passing a nil value as specs" do
+ it "returns an empty array" do
specs = described_class.fabricate(nil)
expect(specs).to be_an Array
diff --git a/spec/lib/gitlab/ci/build/step_spec.rb b/spec/lib/gitlab/ci/build/step_spec.rb
index e3136fc925e..4a9f84dcc0d 100644
--- a/spec/lib/gitlab/ci/build/step_spec.rb
+++ b/spec/lib/gitlab/ci/build/step_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Build::Step do
- describe '#from_commands' do
- shared_examples 'has correct script' do
+ describe "#from_commands" do
+ shared_examples "has correct script" do
subject { described_class.from_commands(job) }
before do
job.run!
end
- it 'fabricates an object' do
+ it "fabricates an object" do
expect(subject.name).to eq(:script)
expect(subject.script).to eq(script)
expect(subject.timeout).to eq(job.metadata_timeout)
- expect(subject.when).to eq('on_success')
+ expect(subject.when).to eq("on_success")
expect(subject.allow_failure).to be_falsey
end
end
- context 'when script option is specified' do
- it_behaves_like 'has correct script' do
- let(:job) { create(:ci_build, :no_options, options: { script: ["ls -la\necho aaa", "date"] }) }
- let(:script) { ["ls -la\necho aaa", 'date'] }
+ context "when script option is specified" do
+ it_behaves_like "has correct script" do
+ let(:job) { create(:ci_build, :no_options, options: {script: ["ls -la\necho aaa", "date"]}) }
+ let(:script) { ["ls -la\necho aaa", "date"] }
end
end
- context 'when before and script option is specified' do
- it_behaves_like 'has correct script' do
+ context "when before and script option is specified" do
+ it_behaves_like "has correct script" do
let(:job) do
create(:ci_build, options: {
before_script: ["ls -la\necho aaa"],
- script: ["date"]
+ script: ["date"],
})
end
- let(:script) { ["ls -la\necho aaa", 'date'] }
+ let(:script) { ["ls -la\necho aaa", "date"] }
end
end
end
- describe '#from_after_script' do
+ describe "#from_after_script" do
let(:job) { create(:ci_build) }
subject { described_class.from_after_script(job) }
@@ -48,20 +48,20 @@ describe Gitlab::Ci::Build::Step do
job.run!
end
- context 'when after_script is empty' do
- it 'doesn not fabricate an object' do
+ context "when after_script is empty" do
+ it "doesn not fabricate an object" do
is_expected.to be_nil
end
end
- context 'when after_script is not empty' do
- let(:job) { create(:ci_build, options: { script: ['bash'], after_script: ['ls -la', 'date'] }) }
+ context "when after_script is not empty" do
+ let(:job) { create(:ci_build, options: {script: ["bash"], after_script: ["ls -la", "date"]}) }
- it 'fabricates an object' do
+ it "fabricates an object" do
expect(subject.name).to eq(:after_script)
- expect(subject.script).to eq(['ls -la', 'date'])
+ expect(subject.script).to eq(["ls -la", "date"])
expect(subject.timeout).to eq(job.metadata_timeout)
- expect(subject.when).to eq('always')
+ expect(subject.when).to eq("always")
expect(subject.allow_failure).to be_truthy
end
end
diff --git a/spec/lib/gitlab/ci/charts_spec.rb b/spec/lib/gitlab/ci/charts_spec.rb
index 1668d3bbaac..e7b9549f429 100644
--- a/spec/lib/gitlab/ci/charts_spec.rb
+++ b/spec/lib/gitlab/ci/charts_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Charts do
context "yearchart" do
@@ -7,11 +7,11 @@ describe Gitlab::Ci::Charts do
subject { chart.to }
- it 'goes until the end of the current month (including the whole last day of the month)' do
+ it "goes until the end of the current month (including the whole last day of the month)" do
is_expected.to eq(Date.today.end_of_month.end_of_day)
end
- it 'starts at the beginning of the current year' do
+ it "starts at the beginning of the current year" do
expect(chart.from).to eq(chart.to.years_ago(1).beginning_of_month.beginning_of_day)
end
end
@@ -22,11 +22,11 @@ describe Gitlab::Ci::Charts do
subject { chart.to }
- it 'includes the whole current day' do
+ it "includes the whole current day" do
is_expected.to eq(Date.today.end_of_day)
end
- it 'starts one month ago' do
+ it "starts one month ago" do
expect(chart.from).to eq(1.month.ago.beginning_of_day)
end
end
@@ -37,11 +37,11 @@ describe Gitlab::Ci::Charts do
subject { chart.to }
- it 'includes the whole current day' do
+ it "includes the whole current day" do
is_expected.to eq(Date.today.end_of_day)
end
- it 'starts one week ago' do
+ it "starts one week ago" do
expect(chart.from).to eq(1.week.ago.beginning_of_day)
end
end
@@ -56,11 +56,11 @@ describe Gitlab::Ci::Charts do
create(:ci_empty_pipeline, project: project, duration: 120)
end
- it 'returns pipeline times in minutes' do
+ it "returns pipeline times in minutes" do
is_expected.to contain_exactly(2)
end
- it 'handles nil pipeline times' do
+ it "handles nil pipeline times" do
create(:ci_empty_pipeline, project: project, duration: nil)
is_expected.to contain_exactly(2, 0)
diff --git a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb
index bd1f2c92844..7af275e1869 100644
--- a/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/artifacts_spec.rb
@@ -1,59 +1,59 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Artifacts do
let(:entry) { described_class.new(config) }
- describe 'validation' do
- context 'when entry config value is correct' do
- let(:config) { { paths: %w[public/] } }
+ describe "validation" do
+ context "when entry config value is correct" do
+ let(:config) { {paths: %w[public/]} }
- describe '#value' do
- it 'returns artifacts configuration' do
+ describe "#value" do
+ it "returns artifacts configuration" do
expect(entry.value).to eq config
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
context "when value includes 'reports' keyword" do
- let(:config) { { paths: %w[public/], reports: { junit: 'junit.xml' } } }
+ let(:config) { {paths: %w[public/], reports: {junit: "junit.xml"}} }
- it 'returns general artifact and report-type artifacts configuration' do
+ it "returns general artifact and report-type artifacts configuration" do
expect(entry.value).to eq config
end
end
end
- context 'when entry value is not correct' do
- describe '#errors' do
- context 'when value of attribute is invalid' do
- let(:config) { { name: 10 } }
+ context "when entry value is not correct" do
+ describe "#errors" do
+ context "when value of attribute is invalid" do
+ let(:config) { {name: 10} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors)
- .to include 'artifacts name should be a string'
+ .to include "artifacts name should be a string"
end
end
- context 'when there is an unknown key present' do
- let(:config) { { test: 100 } }
+ context "when there is an unknown key present" do
+ let(:config) { {test: 100} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors)
- .to include 'artifacts config contains unknown keys: test'
+ .to include "artifacts config contains unknown keys: test"
end
end
context "when 'reports' keyword is not hash" do
- let(:config) { { paths: %w[public/], reports: 'junit.xml' } }
+ let(:config) { {paths: %w[public/], reports: "junit.xml"} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors)
- .to include 'artifacts reports should be a hash'
+ .to include "artifacts reports should be a hash"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/cache_spec.rb b/spec/lib/gitlab/ci/config/entry/cache_spec.rb
index 8f711e02f9b..f6af5ea8008 100644
--- a/spec/lib/gitlab/ci/config/entry/cache_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/cache_spec.rb
@@ -1,62 +1,62 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Cache do
subject(:entry) { described_class.new(config) }
- describe 'validations' do
+ describe "validations" do
before do
entry.compose!
end
- context 'when entry config value is correct' do
+ context "when entry config value is correct" do
let(:policy) { nil }
let(:config) do
- { key: 'some key',
- untracked: true,
- paths: ['some/path/'],
- policy: policy }
+ {key: "some key",
+ untracked: true,
+ paths: ["some/path/"],
+ policy: policy,}
end
- describe '#value' do
- it 'returns hash value' do
- expect(entry.value).to eq(key: 'some key', untracked: true, paths: ['some/path/'], policy: 'pull-push')
+ describe "#value" do
+ it "returns hash value" do
+ expect(entry.value).to eq(key: "some key", untracked: true, paths: ["some/path/"], policy: "pull-push")
end
end
- describe '#valid?' do
+ describe "#valid?" do
it { is_expected.to be_valid }
end
- context 'policy is pull-push' do
- let(:policy) { 'pull-push' }
+ context "policy is pull-push" do
+ let(:policy) { "pull-push" }
it { is_expected.to be_valid }
- it { expect(entry.value).to include(policy: 'pull-push') }
+ it { expect(entry.value).to include(policy: "pull-push") }
end
- context 'policy is push' do
- let(:policy) { 'push' }
+ context "policy is push" do
+ let(:policy) { "push" }
it { is_expected.to be_valid }
- it { expect(entry.value).to include(policy: 'push') }
+ it { expect(entry.value).to include(policy: "push") }
end
- context 'policy is pull' do
- let(:policy) { 'pull' }
+ context "policy is pull" do
+ let(:policy) { "pull" }
it { is_expected.to be_valid }
- it { expect(entry.value).to include(policy: 'pull') }
+ it { expect(entry.value).to include(policy: "pull") }
end
- context 'when key is missing' do
+ context "when key is missing" do
let(:config) do
- { untracked: true,
- paths: ['some/path/'] }
+ {untracked: true,
+ paths: ["some/path/"],}
end
- describe '#value' do
- it 'sets key with the default' do
+ describe "#value" do
+ it "sets key with the default" do
expect(entry.value[:key])
.to eq(Gitlab::Ci::Config::Entry::Key.default)
end
@@ -64,38 +64,38 @@ describe Gitlab::Ci::Config::Entry::Cache do
end
end
- context 'when entry value is not correct' do
- describe '#errors' do
+ context "when entry value is not correct" do
+ describe "#errors" do
subject { entry.errors }
- context 'when is not a hash' do
- let(:config) { 'ls' }
+ context "when is not a hash" do
+ let(:config) { "ls" }
- it 'reports errors with config value' do
- is_expected.to include 'cache config should be a hash'
+ it "reports errors with config value" do
+ is_expected.to include "cache config should be a hash"
end
end
- context 'when policy is unknown' do
- let(:config) { { policy: "unknown" } }
+ context "when policy is unknown" do
+ let(:config) { {policy: "unknown"} }
- it 'reports error' do
- is_expected.to include('cache policy should be pull-push, push, or pull')
+ it "reports error" do
+ is_expected.to include("cache policy should be pull-push, push, or pull")
end
end
- context 'when descendants are invalid' do
- let(:config) { { key: 1 } }
+ context "when descendants are invalid" do
+ let(:config) { {key: 1} }
- it 'reports error with descendants' do
- is_expected.to include 'key config should be a string or symbol'
+ it "reports error with descendants" do
+ is_expected.to include "key config should be a string or symbol"
end
end
- context 'when there is an unknown key present' do
- let(:config) { { invalid: true } }
+ context "when there is an unknown key present" do
+ let(:config) { {invalid: true} }
- it 'reports error with descendants' do
- is_expected.to include 'cache config contains unknown keys: invalid'
+ it "reports error with descendants" do
+ is_expected.to include "cache config contains unknown keys: invalid"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/commands_spec.rb b/spec/lib/gitlab/ci/config/entry/commands_spec.rb
index 8934aeb83db..96aa2413afa 100644
--- a/spec/lib/gitlab/ci/config/entry/commands_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/commands_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Commands do
let(:entry) { described_class.new(config) }
- context 'when entry config value is an array' do
- let(:config) { %w(ls pwd) }
+ context "when entry config value is an array" do
+ let(:config) { %w[ls pwd] }
- describe '#value' do
- it 'returns array of strings' do
+ describe "#value" do
+ it "returns array of strings" do
expect(entry.value).to eq config
end
end
- describe '#errors' do
- it 'does not append errors' do
+ describe "#errors" do
+ it "does not append errors" do
expect(entry.errors).to be_empty
end
end
end
- context 'when entry config value is a string' do
- let(:config) { 'ls' }
+ context "when entry config value is a string" do
+ let(:config) { "ls" }
- describe '#value' do
- it 'returns array with single element' do
- expect(entry.value).to eq ['ls']
+ describe "#value" do
+ it "returns array with single element" do
+ expect(entry.value).to eq ["ls"]
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not valid' do
+ context "when entry value is not valid" do
let(:config) { 1 }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'commands config should be an array of strings or a string'
+ .to include "commands config should be an array of strings or a string"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/coverage_spec.rb b/spec/lib/gitlab/ci/config/entry/coverage_spec.rb
index 4c6bd859552..a41410efa80 100644
--- a/spec/lib/gitlab/ci/config/entry/coverage_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/coverage_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Coverage do
let(:entry) { described_class.new(config) }
- describe 'validations' do
+ describe "validations" do
context "when entry config value doesn't have the surrounding '/'" do
let(:config) { 'Code coverage: \d+\.\d+' }
- describe '#errors' do
+ describe "#errors" do
subject { entry.errors }
it { is_expected.to include(/coverage config must be a regular expression/) }
end
- describe '#valid?' do
+ describe "#valid?" do
subject { entry }
it { is_expected.not_to be_valid }
end
@@ -21,31 +21,31 @@ describe Gitlab::Ci::Config::Entry::Coverage do
context "when entry config value has the surrounding '/'" do
let(:config) { '/Code coverage: \d+\.\d+/' }
- describe '#value' do
+ describe "#value" do
subject { entry.value }
it { is_expected.to eq(config[1...-1]) }
end
- describe '#errors' do
+ describe "#errors" do
subject { entry.errors }
it { is_expected.to be_empty }
end
- describe '#valid?' do
+ describe "#valid?" do
subject { entry }
it { is_expected.to be_valid }
end
end
- context 'when entry value is not valid' do
- let(:config) { '(malformed regexp' }
+ context "when entry value is not valid" do
+ let(:config) { "(malformed regexp" }
- describe '#errors' do
+ describe "#errors" do
subject { entry.errors }
it { is_expected.to include(/coverage config must be a regular expression/) }
end
- describe '#valid?' do
+ describe "#valid?" do
subject { entry }
it { is_expected.not_to be_valid }
end
diff --git a/spec/lib/gitlab/ci/config/entry/environment_spec.rb b/spec/lib/gitlab/ci/config/entry/environment_spec.rb
index 3c0007f4d57..1b5e2ac18e1 100644
--- a/spec/lib/gitlab/ci/config/entry/environment_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/environment_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Environment do
let(:entry) { described_class.new(config) }
@@ -7,192 +7,192 @@ describe Gitlab::Ci::Config::Entry::Environment do
entry.compose!
end
- context 'when configuration is a string' do
- let(:config) { 'production' }
+ context "when configuration is a string" do
+ let(:config) { "production" }
- describe '#string?' do
- it 'is string configuration' do
+ describe "#string?" do
+ it "is string configuration" do
expect(entry).to be_string
end
end
- describe '#hash?' do
- it 'is not hash configuration' do
+ describe "#hash?" do
+ it "is not hash configuration" do
expect(entry).not_to be_hash
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns valid hash' do
- expect(entry.value).to include(name: 'production')
+ describe "#value" do
+ it "returns valid hash" do
+ expect(entry.value).to include(name: "production")
end
end
- describe '#name' do
- it 'returns environment name' do
- expect(entry.name).to eq 'production'
+ describe "#name" do
+ it "returns environment name" do
+ expect(entry.name).to eq "production"
end
end
- describe '#url' do
- it 'returns environment url' do
+ describe "#url" do
+ it "returns environment url" do
expect(entry.url).to be_nil
end
end
end
- context 'when configuration is a hash' do
+ context "when configuration is a hash" do
let(:config) do
- { name: 'development', url: 'https://example.gitlab.com' }
+ {name: "development", url: "https://example.gitlab.com"}
end
- describe '#string?' do
- it 'is not string configuration' do
+ describe "#string?" do
+ it "is not string configuration" do
expect(entry).not_to be_string
end
end
- describe '#hash?' do
- it 'is hash configuration' do
+ describe "#hash?" do
+ it "is hash configuration" do
expect(entry).to be_hash
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns valid hash' do
+ describe "#value" do
+ it "returns valid hash" do
expect(entry.value).to eq config
end
end
- describe '#name' do
- it 'returns environment name' do
- expect(entry.name).to eq 'development'
+ describe "#name" do
+ it "returns environment name" do
+ expect(entry.name).to eq "development"
end
end
- describe '#url' do
- it 'returns environment url' do
- expect(entry.url).to eq 'https://example.gitlab.com'
+ describe "#url" do
+ it "returns environment url" do
+ expect(entry.url).to eq "https://example.gitlab.com"
end
end
end
- context 'when valid action is used' do
+ context "when valid action is used" do
let(:config) do
- { name: 'production',
- action: 'start' }
+ {name: "production",
+ action: "start",}
end
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'when invalid action is used' do
+ context "when invalid action is used" do
let(:config) do
- { name: 'production',
- action: 'invalid' }
+ {name: "production",
+ action: "invalid",}
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
- describe '#errors' do
- it 'contains error about invalid action' do
+ describe "#errors" do
+ it "contains error about invalid action" do
expect(entry.errors)
- .to include 'environment action should be start or stop'
+ .to include "environment action should be start or stop"
end
end
end
- context 'when on_stop is used' do
+ context "when on_stop is used" do
let(:config) do
- { name: 'production',
- on_stop: 'close_app' }
+ {name: "production",
+ on_stop: "close_app",}
end
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'when invalid on_stop is used' do
+ context "when invalid on_stop is used" do
let(:config) do
- { name: 'production',
- on_stop: false }
+ {name: "production",
+ on_stop: false,}
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
- describe '#errors' do
- it 'contains error about invalid action' do
+ describe "#errors" do
+ it "contains error about invalid action" do
expect(entry.errors)
- .to include 'environment on stop should be a string'
+ .to include "environment on stop should be a string"
end
end
end
- context 'when variables are used for environment' do
+ context "when variables are used for environment" do
let(:config) do
- { name: 'review/$CI_COMMIT_REF_NAME',
- url: 'https://$CI_COMMIT_REF_NAME.review.gitlab.com' }
+ {name: "review/$CI_COMMIT_REF_NAME",
+ url: "https://$CI_COMMIT_REF_NAME.review.gitlab.com",}
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when configuration is invalid' do
- context 'when configuration is an array' do
- let(:config) { ['env'] }
+ context "when configuration is invalid" do
+ context "when configuration is an array" do
+ let(:config) { ["env"] }
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
- describe '#errors' do
- it 'contains error about invalid type' do
+ describe "#errors" do
+ it "contains error about invalid type" do
expect(entry.errors)
- .to include 'environment config should be a hash or a string'
+ .to include "environment config should be a hash or a string"
end
end
end
- context 'when environment name is not present' do
- let(:config) { { url: 'https://example.gitlab.com' } }
+ context "when environment name is not present" do
+ let(:config) { {url: "https://example.gitlab.com"} }
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
- describe '#errors?' do
- it 'contains error about missing environment name' do
+ describe "#errors?" do
+ it "contains error about missing environment name" do
expect(entry.errors)
.to include "environment name can't be blank"
end
diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb
index e23efff18d5..cbc7318bde5 100644
--- a/spec/lib/gitlab/ci/config/entry/global_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Global do
let(:global) { described_class.new(hash) }
- describe '.nodes' do
- it 'returns a hash' do
+ describe ".nodes" do
+ it "returns a hash" do
expect(described_class.nodes).to be_a(Hash)
end
- context 'when filtering all the entry/node names' do
- it 'contains the expected node names' do
+ context "when filtering all the entry/node names" do
+ it "contains the expected node names" do
expect(described_class.nodes.keys)
.to match_array(%i[before_script image services
after_script variables stages
@@ -18,201 +18,201 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
- context 'when configuration is valid' do
- context 'when some entries defined' do
+ context "when configuration is valid" do
+ context "when some entries defined" do
let(:hash) do
- { before_script: %w(ls pwd),
- image: 'ruby:2.2',
- services: ['postgres:9.1', 'mysql:5.5'],
- variables: { VAR: 'value' },
- after_script: ['make clean'],
- stages: %w(build pages),
- cache: { key: 'k', untracked: true, paths: ['public/'] },
- rspec: { script: %w[rspec ls] },
- spinach: { before_script: [], variables: {}, script: 'spinach' } }
+ {before_script: %w[ls pwd],
+ image: "ruby:2.2",
+ services: ["postgres:9.1", "mysql:5.5"],
+ variables: {VAR: "value"},
+ after_script: ["make clean"],
+ stages: %w[build pages],
+ cache: {key: "k", untracked: true, paths: ["public/"]},
+ rspec: {script: %w[rspec ls]},
+ spinach: {before_script: [], variables: {}, script: "spinach"},}
end
- describe '#compose!' do
+ describe "#compose!" do
before do
global.compose!
end
- it 'creates nodes hash' do
+ it "creates nodes hash" do
expect(global.descendants).to be_an Array
end
- it 'creates node object for each entry' do
+ it "creates node object for each entry" do
expect(global.descendants.count).to eq 9
end
- it 'creates node object using valid class' do
+ it "creates node object using valid class" do
expect(global.descendants.first)
.to be_an_instance_of Gitlab::Ci::Config::Entry::Script
expect(global.descendants.second)
.to be_an_instance_of Gitlab::Ci::Config::Entry::Image
end
- it 'sets correct description for nodes' do
+ it "sets correct description for nodes" do
expect(global.descendants.first.description)
- .to eq 'Script that will be executed before each job.'
+ .to eq "Script that will be executed before each job."
expect(global.descendants.second.description)
- .to eq 'Docker image that will be used to execute jobs.'
+ .to eq "Docker image that will be used to execute jobs."
end
- describe '#leaf?' do
- it 'is not leaf' do
+ describe "#leaf?" do
+ it "is not leaf" do
expect(global).not_to be_leaf
end
end
end
- context 'when not composed' do
- describe '#before_script_value' do
- it 'returns nil' do
+ context "when not composed" do
+ describe "#before_script_value" do
+ it "returns nil" do
expect(global.before_script_value).to be nil
end
end
- describe '#leaf?' do
- it 'is leaf' do
+ describe "#leaf?" do
+ it "is leaf" do
expect(global).to be_leaf
end
end
end
- context 'when composed' do
+ context "when composed" do
before do
global.compose!
end
- describe '#errors' do
- it 'has no errors' do
+ describe "#errors" do
+ it "has no errors" do
expect(global.errors).to be_empty
end
end
- describe '#before_script_value' do
- it 'returns correct script' do
- expect(global.before_script_value).to eq %w(ls pwd)
+ describe "#before_script_value" do
+ it "returns correct script" do
+ expect(global.before_script_value).to eq %w[ls pwd]
end
end
- describe '#image_value' do
- it 'returns valid image' do
- expect(global.image_value).to eq(name: 'ruby:2.2')
+ describe "#image_value" do
+ it "returns valid image" do
+ expect(global.image_value).to eq(name: "ruby:2.2")
end
end
- describe '#services_value' do
- it 'returns array of services' do
- expect(global.services_value).to eq [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }]
+ describe "#services_value" do
+ it "returns array of services" do
+ expect(global.services_value).to eq [{name: "postgres:9.1"}, {name: "mysql:5.5"}]
end
end
- describe '#after_script_value' do
- it 'returns after script' do
- expect(global.after_script_value).to eq ['make clean']
+ describe "#after_script_value" do
+ it "returns after script" do
+ expect(global.after_script_value).to eq ["make clean"]
end
end
- describe '#variables_value' do
- it 'returns variables' do
- expect(global.variables_value).to eq('VAR' => 'value')
+ describe "#variables_value" do
+ it "returns variables" do
+ expect(global.variables_value).to eq("VAR" => "value")
end
end
- describe '#stages_value' do
- context 'when stages key defined' do
- it 'returns array of stages' do
+ describe "#stages_value" do
+ context "when stages key defined" do
+ it "returns array of stages" do
expect(global.stages_value).to eq %w[build pages]
end
end
- context 'when deprecated types key defined' do
+ context "when deprecated types key defined" do
let(:hash) do
- { types: %w(test deploy),
- rspec: { script: 'rspec' } }
+ {types: %w[test deploy],
+ rspec: {script: "rspec"},}
end
- it 'returns array of types as stages' do
+ it "returns array of types as stages" do
expect(global.stages_value).to eq %w[test deploy]
end
end
end
- describe '#cache_value' do
- it 'returns cache configuration' do
+ describe "#cache_value" do
+ it "returns cache configuration" do
expect(global.cache_value)
- .to eq(key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push')
+ .to eq(key: "k", untracked: true, paths: ["public/"], policy: "pull-push")
end
end
- describe '#jobs_value' do
- it 'returns jobs configuration' do
+ describe "#jobs_value" do
+ it "returns jobs configuration" do
expect(global.jobs_value).to eq(
- rspec: { name: :rspec,
- script: %w[rspec ls],
- before_script: %w(ls pwd),
- image: { name: 'ruby:2.2' },
- services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }],
- stage: 'test',
- cache: { key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push' },
- variables: { 'VAR' => 'value' },
- ignore: false,
- after_script: ['make clean'],
- only: { refs: %w[branches tags] } },
- spinach: { name: :spinach,
- before_script: [],
- script: %w[spinach],
- image: { name: 'ruby:2.2' },
- services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }],
- stage: 'test',
- cache: { key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push' },
- variables: {},
- ignore: false,
- after_script: ['make clean'],
- only: { refs: %w[branches tags] } }
+ rspec: {name: :rspec,
+ script: %w[rspec ls],
+ before_script: %w[ls pwd],
+ image: {name: "ruby:2.2"},
+ services: [{name: "postgres:9.1"}, {name: "mysql:5.5"}],
+ stage: "test",
+ cache: {key: "k", untracked: true, paths: ["public/"], policy: "pull-push"},
+ variables: {"VAR" => "value"},
+ ignore: false,
+ after_script: ["make clean"],
+ only: {refs: %w[branches tags]},},
+ spinach: {name: :spinach,
+ before_script: [],
+ script: %w[spinach],
+ image: {name: "ruby:2.2"},
+ services: [{name: "postgres:9.1"}, {name: "mysql:5.5"}],
+ stage: "test",
+ cache: {key: "k", untracked: true, paths: ["public/"], policy: "pull-push"},
+ variables: {},
+ ignore: false,
+ after_script: ["make clean"],
+ only: {refs: %w[branches tags]},}
)
end
end
end
end
- context 'when most of entires not defined' do
+ context "when most of entires not defined" do
before do
global.compose!
end
let(:hash) do
- { cache: { key: 'a' }, rspec: { script: %w[ls] } }
+ {cache: {key: "a"}, rspec: {script: %w[ls]}}
end
- describe '#nodes' do
- it 'instantizes all nodes' do
+ describe "#nodes" do
+ it "instantizes all nodes" do
expect(global.descendants.count).to eq 9
end
- it 'contains unspecified nodes' do
+ it "contains unspecified nodes" do
expect(global.descendants.first)
.not_to be_specified
end
end
- describe '#variables_value' do
- it 'returns default value for variables' do
+ describe "#variables_value" do
+ it "returns default value for variables" do
expect(global.variables_value).to eq({})
end
end
- describe '#stages_value' do
- it 'returns an array of default stages' do
+ describe "#stages_value" do
+ it "returns an array of default stages" do
expect(global.stages_value).to eq %w[build test deploy]
end
end
- describe '#cache_value' do
- it 'returns correct cache definition' do
- expect(global.cache_value).to eq(key: 'a', policy: 'pull-push')
+ describe "#cache_value" do
+ it "returns correct cache definition" do
+ expect(global.cache_value).to eq(key: "a", policy: "pull-push")
end
end
end
@@ -223,60 +223,60 @@ describe Gitlab::Ci::Config::Entry::Global do
# despite the fact, that key is present. See issue #18775 for more
# details.
#
- context 'when entires specified but not defined' do
+ context "when entires specified but not defined" do
before do
global.compose!
end
let(:hash) do
- { variables: nil, rspec: { script: 'rspec' } }
+ {variables: nil, rspec: {script: "rspec"}}
end
- describe '#variables_value' do
- it 'undefined entry returns a default value' do
+ describe "#variables_value" do
+ it "undefined entry returns a default value" do
expect(global.variables_value).to eq({})
end
end
end
end
- context 'when configuration is not valid' do
+ context "when configuration is not valid" do
before do
global.compose!
end
- context 'when before script is not an array' do
+ context "when before script is not an array" do
let(:hash) do
- { before_script: 'ls' }
+ {before_script: "ls"}
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(global).not_to be_valid
end
end
- describe '#errors' do
- it 'reports errors from child nodes' do
+ describe "#errors" do
+ it "reports errors from child nodes" do
expect(global.errors)
- .to include 'before_script config should be an array of strings'
+ .to include "before_script config should be an array of strings"
end
end
- describe '#before_script_value' do
- it 'returns nil' do
+ describe "#before_script_value" do
+ it "returns nil" do
expect(global.before_script_value).to be_nil
end
end
end
- context 'when job does not have commands' do
+ context "when job does not have commands" do
let(:hash) do
- { before_script: ['echo 123'], rspec: { stage: 'test' } }
+ {before_script: ["echo 123"], rspec: {stage: "test"}}
end
- describe '#errors' do
- it 'reports errors about missing script' do
+ describe "#errors" do
+ it "reports errors about missing script" do
expect(global.errors)
.to include "jobs:rspec script can't be blank"
end
@@ -284,47 +284,47 @@ describe Gitlab::Ci::Config::Entry::Global do
end
end
- context 'when value is not a hash' do
+ context "when value is not a hash" do
let(:hash) { [] }
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(global).not_to be_valid
end
end
- describe '#errors' do
- it 'returns error about invalid type' do
+ describe "#errors" do
+ it "returns error about invalid type" do
expect(global.errors.first).to match /should be a hash/
end
end
end
- describe '#specified?' do
- it 'is concrete entry that is defined' do
+ describe "#specified?" do
+ it "is concrete entry that is defined" do
expect(global.specified?).to be true
end
end
- describe '#[]' do
+ describe "#[]" do
before do
global.compose!
end
let(:hash) do
- { cache: { key: 'a' }, rspec: { script: 'ls' } }
+ {cache: {key: "a"}, rspec: {script: "ls"}}
end
- context 'when entry exists' do
- it 'returns correct entry' do
+ context "when entry exists" do
+ it "returns correct entry" do
expect(global[:cache])
.to be_an_instance_of Gitlab::Ci::Config::Entry::Cache
- expect(global[:jobs][:rspec][:script].value).to eq ['ls']
+ expect(global[:jobs][:rspec][:script].value).to eq ["ls"]
end
end
- context 'when entry does not exist' do
- it 'always return unspecified node' do
+ context "when entry does not exist" do
+ it "always return unspecified node" do
expect(global[:some][:unknown][:node])
.not_to be_specified
end
diff --git a/spec/lib/gitlab/ci/config/entry/hidden_spec.rb b/spec/lib/gitlab/ci/config/entry/hidden_spec.rb
index 459362761e6..6d3201cc5da 100644
--- a/spec/lib/gitlab/ci/config/entry/hidden_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/hidden_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Hidden do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is correct' do
+ describe "validations" do
+ context "when entry config value is correct" do
let(:config) { [:some, :array] }
- describe '#value' do
- it 'returns key value' do
+ describe "#value" do
+ it "returns key value" do
expect(entry.value).to eq [:some, :array]
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- context 'when config is empty' do
+ context "when entry value is not correct" do
+ context "when config is empty" do
let(:config) { {} }
- describe '#valid' do
- it 'is invalid' do
+ describe "#valid" do
+ it "is invalid" do
expect(entry).not_to be_valid
end
end
@@ -33,14 +33,14 @@ describe Gitlab::Ci::Config::Entry::Hidden do
end
end
- describe '#leaf?' do
- it 'is a leaf' do
+ describe "#leaf?" do
+ it "is a leaf" do
expect(entry).to be_leaf
end
end
- describe '#relevant?' do
- it 'is not a relevant entry' do
+ describe "#relevant?" do
+ it "is not a relevant entry" do
expect(entry).not_to be_relevant
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb
index 1a4d9ed5517..4f558cfaa4b 100644
--- a/spec/lib/gitlab/ci/config/entry/image_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb
@@ -1,105 +1,105 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Image do
let(:entry) { described_class.new(config) }
- context 'when configuration is a string' do
- let(:config) { 'ruby:2.2' }
+ context "when configuration is a string" do
+ let(:config) { "ruby:2.2" }
- describe '#value' do
- it 'returns image hash' do
- expect(entry.value).to eq({ name: 'ruby:2.2' })
+ describe "#value" do
+ it "returns image hash" do
+ expect(entry.value).to eq({name: "ruby:2.2"})
end
end
- describe '#errors' do
- it 'does not append errors' do
+ describe "#errors" do
+ it "does not append errors" do
expect(entry.errors).to be_empty
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#image' do
+ describe "#image" do
it "returns image's name" do
- expect(entry.name).to eq 'ruby:2.2'
+ expect(entry.name).to eq "ruby:2.2"
end
end
- describe '#entrypoint' do
+ describe "#entrypoint" do
it "returns image's entrypoint" do
expect(entry.entrypoint).to be_nil
end
end
end
- context 'when configuration is a hash' do
- let(:config) { { name: 'ruby:2.2', entrypoint: %w(/bin/sh run) } }
+ context "when configuration is a hash" do
+ let(:config) { {name: "ruby:2.2", entrypoint: %w[/bin/sh run]} }
- describe '#value' do
- it 'returns image hash' do
+ describe "#value" do
+ it "returns image hash" do
expect(entry.value).to eq(config)
end
end
- describe '#errors' do
- it 'does not append errors' do
+ describe "#errors" do
+ it "does not append errors" do
expect(entry.errors).to be_empty
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#image' do
+ describe "#image" do
it "returns image's name" do
- expect(entry.name).to eq 'ruby:2.2'
+ expect(entry.name).to eq "ruby:2.2"
end
end
- describe '#entrypoint' do
+ describe "#entrypoint" do
it "returns image's entrypoint" do
- expect(entry.entrypoint).to eq %w(/bin/sh run)
+ expect(entry.entrypoint).to eq %w[/bin/sh run]
end
end
end
- context 'when entry value is not correct' do
- let(:config) { ['ruby:2.2'] }
+ context "when entry value is not correct" do
+ let(:config) { ["ruby:2.2"] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'image config should be a hash or a string'
+ .to include "image config should be a hash or a string"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
end
- context 'when unexpected key is specified' do
- let(:config) { { name: 'ruby:2.2', non_existing: 'test' } }
+ context "when unexpected key is specified" do
+ let(:config) { {name: "ruby:2.2", non_existing: "test"} }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'image config contains unknown keys: non_existing'
+ .to include "image config contains unknown keys: non_existing"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb
index 0560eb42e4d..678b93eae17 100644
--- a/spec/lib/gitlab/ci/config/entry/job_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Job do
let(:entry) { described_class.new(config, name: :rspec) }
- describe '.nodes' do
- context 'when filtering all the entry/node names' do
+ describe ".nodes" do
+ context "when filtering all the entry/node names" do
subject { described_class.nodes.keys }
let(:result) do
@@ -17,343 +17,343 @@ describe Gitlab::Ci::Config::Entry::Job do
end
end
- describe 'validations' do
+ describe "validations" do
before do
entry.compose!
end
- context 'when entry config value is correct' do
- let(:config) { { script: 'rspec' } }
+ context "when entry config value is correct" do
+ let(:config) { {script: "rspec"} }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'when job name is empty' do
- let(:entry) { described_class.new(config, name: ''.to_sym) }
+ context "when job name is empty" do
+ let(:entry) { described_class.new(config, name: "".to_sym) }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors).to include "job name can't be blank"
end
end
- context 'when delayed job' do
- context 'when start_in is specified' do
- let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } }
+ context "when delayed job" do
+ context "when start_in is specified" do
+ let(:config) { {script: "echo", when: "delayed", start_in: "1 day"} }
it { expect(entry).to be_valid }
end
end
end
- context 'when entry value is not correct' do
- context 'incorrect config value type' do
- let(:config) { ['incorrect'] }
+ context "when entry value is not correct" do
+ context "incorrect config value type" do
+ let(:config) { ["incorrect"] }
- describe '#errors' do
- it 'reports error about a config type' do
+ describe "#errors" do
+ it "reports error about a config type" do
expect(entry.errors)
- .to include 'job config should be a hash'
+ .to include "job config should be a hash"
end
end
end
- context 'when config is empty' do
+ context "when config is empty" do
let(:config) { {} }
- describe '#valid' do
- it 'is invalid' do
+ describe "#valid" do
+ it "is invalid" do
expect(entry).not_to be_valid
end
end
end
- context 'when unknown keys detected' do
- let(:config) { { unknown: true } }
+ context "when unknown keys detected" do
+ let(:config) { {unknown: true} }
- describe '#valid' do
- it 'is not valid' do
+ describe "#valid" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
end
- context 'when script is not provided' do
- let(:config) { { stage: 'test' } }
+ context "when script is not provided" do
+ let(:config) { {stage: "test"} }
- it 'returns error about missing script entry' do
+ it "returns error about missing script entry" do
expect(entry).not_to be_valid
expect(entry.errors).to include "job script can't be blank"
end
end
- context 'when extends key is not a string' do
- let(:config) { { extends: 123 } }
+ context "when extends key is not a string" do
+ let(:config) { {extends: 123} }
- it 'returns error about wrong value type' do
+ it "returns error about wrong value type" do
expect(entry).not_to be_valid
expect(entry.errors).to include "job extends should be a string"
end
end
- context 'when parallel value is not correct' do
- context 'when it is not a numeric value' do
- let(:config) { { parallel: true } }
+ context "when parallel value is not correct" do
+ context "when it is not a numeric value" do
+ let(:config) { {parallel: true} }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job parallel is not a number'
+ expect(entry.errors).to include "job parallel is not a number"
end
end
- context 'when it is lower than two' do
- let(:config) { { parallel: 1 } }
+ context "when it is lower than two" do
+ let(:config) { {parallel: 1} }
- it 'returns error about value too low' do
+ it "returns error about value too low" do
expect(entry).not_to be_valid
expect(entry.errors)
- .to include 'job parallel must be greater than or equal to 2'
+ .to include "job parallel must be greater than or equal to 2"
end
end
- context 'when it is bigger than 50' do
- let(:config) { { parallel: 51 } }
+ context "when it is bigger than 50" do
+ let(:config) { {parallel: 51} }
- it 'returns error about value too high' do
+ it "returns error about value too high" do
expect(entry).not_to be_valid
expect(entry.errors)
- .to include 'job parallel must be less than or equal to 50'
+ .to include "job parallel must be less than or equal to 50"
end
end
- context 'when it is not an integer' do
- let(:config) { { parallel: 1.5 } }
+ context "when it is not an integer" do
+ let(:config) { {parallel: 1.5} }
- it 'returns error about wrong value' do
+ it "returns error about wrong value" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job parallel must be an integer'
+ expect(entry.errors).to include "job parallel must be an integer"
end
end
end
- context 'when delayed job' do
- context 'when start_in is specified' do
- let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } }
+ context "when delayed job" do
+ context "when start_in is specified" do
+ let(:config) { {script: "echo", when: "delayed", start_in: "1 day"} }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).to be_valid
end
end
- context 'when start_in is empty' do
- let(:config) { { when: 'delayed', start_in: nil } }
+ context "when start_in is empty" do
+ let(:config) { {when: "delayed", start_in: nil} }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in should be a duration'
+ expect(entry.errors).to include "job start in should be a duration"
end
end
- context 'when start_in is not formatted as a duration' do
- let(:config) { { when: 'delayed', start_in: 'test' } }
+ context "when start_in is not formatted as a duration" do
+ let(:config) { {when: "delayed", start_in: "test"} }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in should be a duration'
+ expect(entry.errors).to include "job start in should be a duration"
end
end
- context 'when start_in is longer than one day' do
- let(:config) { { when: 'delayed', start_in: '2 days' } }
+ context "when start_in is longer than one day" do
+ let(:config) { {when: "delayed", start_in: "2 days"} }
- it 'returns error about exceeding the limit' do
+ it "returns error about exceeding the limit" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in should not exceed the limit'
+ expect(entry.errors).to include "job start in should not exceed the limit"
end
end
end
- context 'when start_in specified without delayed specification' do
- let(:config) { { start_in: '1 day' } }
+ context "when start_in specified without delayed specification" do
+ let(:config) { {start_in: "1 day"} }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'job start in must be blank'
+ expect(entry.errors).to include "job start in must be blank"
end
end
end
end
- describe '#relevant?' do
- it 'is a relevant entry' do
- entry = described_class.new({ script: 'rspec' }, name: :rspec)
+ describe "#relevant?" do
+ it "is a relevant entry" do
+ entry = described_class.new({script: "rspec"}, name: :rspec)
expect(entry).to be_relevant
end
end
- describe '#compose!' do
- let(:unspecified) { double('unspecified', 'specified?' => false) }
+ describe "#compose!" do
+ let(:unspecified) { double("unspecified", "specified?" => false) }
let(:specified) do
- double('specified', 'specified?' => true, value: 'specified')
+ double("specified", "specified?" => true, :value => "specified")
end
- let(:deps) { double('deps', '[]' => unspecified) }
+ let(:deps) { double("deps", "[]" => unspecified) }
- context 'when job config overrides global config' do
+ context "when job config overrides global config" do
before do
entry.compose!(deps)
end
let(:config) do
- { script: 'rspec', image: 'some_image', cache: { key: 'test' } }
+ {script: "rspec", image: "some_image", cache: {key: "test"}}
end
- it 'overrides global config' do
- expect(entry[:image].value).to eq(name: 'some_image')
- expect(entry[:cache].value).to eq(key: 'test', policy: 'pull-push')
+ it "overrides global config" do
+ expect(entry[:image].value).to eq(name: "some_image")
+ expect(entry[:cache].value).to eq(key: "test", policy: "pull-push")
end
end
- context 'when job config does not override global config' do
+ context "when job config does not override global config" do
before do
- allow(deps).to receive('[]').with(:image).and_return(specified)
+ allow(deps).to receive("[]").with(:image).and_return(specified)
entry.compose!(deps)
end
- let(:config) { { script: 'ls', cache: { key: 'test' } } }
+ let(:config) { {script: "ls", cache: {key: "test"}} }
- it 'uses config from global entry' do
- expect(entry[:image].value).to eq 'specified'
- expect(entry[:cache].value).to eq(key: 'test', policy: 'pull-push')
+ it "uses config from global entry" do
+ expect(entry[:image].value).to eq "specified"
+ expect(entry[:cache].value).to eq(key: "test", policy: "pull-push")
end
end
end
- context 'when composed' do
+ context "when composed" do
before do
entry.compose!
end
- describe '#value' do
+ describe "#value" do
before do
entry.compose!
end
- context 'when entry is correct' do
+ context "when entry is correct" do
let(:config) do
- { before_script: %w[ls pwd],
- script: 'rspec',
- after_script: %w[cleanup] }
+ {before_script: %w[ls pwd],
+ script: "rspec",
+ after_script: %w[cleanup],}
end
- it 'returns correct value' do
+ it "returns correct value" do
expect(entry.value)
.to eq(name: :rspec,
before_script: %w[ls pwd],
script: %w[rspec],
- stage: 'test',
+ stage: "test",
ignore: false,
after_script: %w[cleanup],
- only: { refs: %w[branches tags] })
+ only: {refs: %w[branches tags]})
end
end
end
end
- describe '#manual_action?' do
- context 'when job is a manual action' do
- let(:config) { { script: 'deploy', when: 'manual' } }
+ describe "#manual_action?" do
+ context "when job is a manual action" do
+ let(:config) { {script: "deploy", when: "manual"} }
- it 'is a manual action' do
+ it "is a manual action" do
expect(entry).to be_manual_action
end
end
- context 'when job is not a manual action' do
- let(:config) { { script: 'deploy' } }
+ context "when job is not a manual action" do
+ let(:config) { {script: "deploy"} }
- it 'is not a manual action' do
+ it "is not a manual action" do
expect(entry).not_to be_manual_action
end
end
end
- describe '#delayed?' do
- context 'when job is a delayed' do
- let(:config) { { script: 'deploy', when: 'delayed' } }
+ describe "#delayed?" do
+ context "when job is a delayed" do
+ let(:config) { {script: "deploy", when: "delayed"} }
- it 'is a delayed' do
+ it "is a delayed" do
expect(entry).to be_delayed
end
end
- context 'when job is not a delayed' do
- let(:config) { { script: 'deploy' } }
+ context "when job is not a delayed" do
+ let(:config) { {script: "deploy"} }
- it 'is not a delayed' do
+ it "is not a delayed" do
expect(entry).not_to be_delayed
end
end
end
- describe '#ignored?' do
- context 'when job is a manual action' do
- context 'when it is not specified if job is allowed to fail' do
+ describe "#ignored?" do
+ context "when job is a manual action" do
+ context "when it is not specified if job is allowed to fail" do
let(:config) do
- { script: 'deploy', when: 'manual' }
+ {script: "deploy", when: "manual"}
end
- it 'is an ignored job' do
+ it "is an ignored job" do
expect(entry).to be_ignored
end
end
- context 'when job is allowed to fail' do
+ context "when job is allowed to fail" do
let(:config) do
- { script: 'deploy', when: 'manual', allow_failure: true }
+ {script: "deploy", when: "manual", allow_failure: true}
end
- it 'is an ignored job' do
+ it "is an ignored job" do
expect(entry).to be_ignored
end
end
- context 'when job is not allowed to fail' do
+ context "when job is not allowed to fail" do
let(:config) do
- { script: 'deploy', when: 'manual', allow_failure: false }
+ {script: "deploy", when: "manual", allow_failure: false}
end
- it 'is not an ignored job' do
+ it "is not an ignored job" do
expect(entry).not_to be_ignored
end
end
end
- context 'when job is not a manual action' do
- context 'when it is not specified if job is allowed to fail' do
- let(:config) { { script: 'deploy' } }
+ context "when job is not a manual action" do
+ context "when it is not specified if job is allowed to fail" do
+ let(:config) { {script: "deploy"} }
- it 'is not an ignored job' do
+ it "is not an ignored job" do
expect(entry).not_to be_ignored
end
end
- context 'when job is allowed to fail' do
- let(:config) { { script: 'deploy', allow_failure: true } }
+ context "when job is allowed to fail" do
+ let(:config) { {script: "deploy", allow_failure: true} }
- it 'is an ignored job' do
+ it "is an ignored job" do
expect(entry).to be_ignored
end
end
- context 'when job is not allowed to fail' do
- let(:config) { { script: 'deploy', allow_failure: false } }
+ context "when job is not allowed to fail" do
+ let(:config) { {script: "deploy", allow_failure: false} }
- it 'is not an ignored job' do
+ it "is not an ignored job" do
expect(entry).not_to be_ignored
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
index 271ee30df3c..4f9cc72ebcd 100644
--- a/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/jobs_spec.rb
@@ -1,83 +1,84 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Jobs do
let(:entry) { described_class.new(config) }
- describe 'validations' do
+ describe "validations" do
before do
entry.compose!
end
- context 'when entry config value is correct' do
- let(:config) { { rspec: { script: 'rspec' } } }
+ context "when entry config value is correct" do
+ let(:config) { {rspec: {script: "rspec"}} }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- describe '#errors' do
- context 'incorrect config value type' do
- let(:config) { ['incorrect'] }
+ context "when entry value is not correct" do
+ describe "#errors" do
+ context "incorrect config value type" do
+ let(:config) { ["incorrect"] }
- it 'returns error about incorrect type' do
+ it "returns error about incorrect type" do
expect(entry.errors)
- .to include 'jobs config should be a hash'
+ .to include "jobs config should be a hash"
end
end
- context 'when job is unspecified' do
- let(:config) { { rspec: nil } }
+ context "when job is unspecified" do
+ let(:config) { {rspec: nil} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors).to include "rspec config can't be blank"
end
end
- context 'when no visible jobs present' do
- let(:config) { { '.hidden'.to_sym => { script: [] } } }
+ context "when no visible jobs present" do
+ let(:config) { {".hidden".to_sym => {script: []}} }
- it 'returns error about no visible jobs defined' do
+ it "returns error about no visible jobs defined" do
expect(entry.errors)
- .to include 'jobs config should contain at least one visible job'
+ .to include "jobs config should contain at least one visible job"
end
end
end
end
end
- context 'when valid job entries composed' do
+ context "when valid job entries composed" do
before do
entry.compose!
end
let(:config) do
- { rspec: { script: 'rspec' },
- spinach: { script: 'spinach' },
- '.hidden'.to_sym => {} }
+ {:rspec => {script: "rspec"},
+ :spinach => {script: "spinach"},
+ ".hidden".to_sym => {},}
end
- describe '#value' do
- it 'returns key value' do
+ describe "#value" do
+ it "returns key value" do
expect(entry.value).to eq(
- rspec: { name: :rspec,
- script: %w[rspec],
- ignore: false,
- stage: 'test',
- only: { refs: %w[branches tags] } },
- spinach: { name: :spinach,
- script: %w[spinach],
- ignore: false,
- stage: 'test',
- only: { refs: %w[branches tags] } })
+ rspec: {name: :rspec,
+ script: %w[rspec],
+ ignore: false,
+ stage: "test",
+ only: {refs: %w[branches tags]},},
+ spinach: {name: :spinach,
+ script: %w[spinach],
+ ignore: false,
+ stage: "test",
+ only: {refs: %w[branches tags]},}
+ )
end
end
- describe '#descendants' do
- it 'creates valid descendant nodes' do
+ describe "#descendants" do
+ it "creates valid descendant nodes" do
expect(entry.descendants.count).to eq 3
expect(entry.descendants.first(2))
.to all(be_an_instance_of(Gitlab::Ci::Config::Entry::Job))
@@ -86,8 +87,8 @@ describe Gitlab::Ci::Config::Entry::Jobs do
end
end
- describe '#value' do
- it 'returns value of visible jobs only' do
+ describe "#value" do
+ it "returns value of visible jobs only" do
expect(entry.value.keys).to eq [:rspec, :spinach]
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/key_spec.rb b/spec/lib/gitlab/ci/config/entry/key_spec.rb
index 3cbf19bea8b..66128fab95d 100644
--- a/spec/lib/gitlab/ci/config/entry/key_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/key_spec.rb
@@ -1,102 +1,102 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Key do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- shared_examples 'key with slash' do
- it 'is invalid' do
+ describe "validations" do
+ shared_examples "key with slash" do
+ it "is invalid" do
expect(entry).not_to be_valid
end
- it 'reports errors with config value' do
+ it "reports errors with config value" do
expect(entry.errors).to include 'key config cannot contain the "/" character'
end
end
- shared_examples 'key with only dots' do
- it 'is invalid' do
+ shared_examples "key with only dots" do
+ it "is invalid" do
expect(entry).not_to be_valid
end
- it 'reports errors with config value' do
+ it "reports errors with config value" do
expect(entry.errors).to include 'key config cannot be "." or ".."'
end
end
- context 'when entry config value is correct' do
- let(:config) { 'test' }
+ context "when entry config value is correct" do
+ let(:config) { "test" }
- describe '#value' do
- it 'returns key value' do
- expect(entry.value).to eq 'test'
+ describe "#value" do
+ it "returns key value" do
+ expect(entry.value).to eq "test"
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- let(:config) { ['incorrect'] }
+ context "when entry value is not correct" do
+ let(:config) { ["incorrect"] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'key config should be a string or symbol'
+ .to include "key config should be a string or symbol"
end
end
end
- context 'when entry value contains slash' do
- let(:config) { 'key/with/some/slashes' }
+ context "when entry value contains slash" do
+ let(:config) { "key/with/some/slashes" }
- it_behaves_like 'key with slash'
+ it_behaves_like "key with slash"
end
- context 'when entry value contains URI encoded slash (%2F)' do
- let(:config) { 'key%2Fwith%2Fsome%2Fslashes' }
+ context "when entry value contains URI encoded slash (%2F)" do
+ let(:config) { "key%2Fwith%2Fsome%2Fslashes" }
- it_behaves_like 'key with slash'
+ it_behaves_like "key with slash"
end
- context 'when entry value is a dot' do
- let(:config) { '.' }
+ context "when entry value is a dot" do
+ let(:config) { "." }
- it_behaves_like 'key with only dots'
+ it_behaves_like "key with only dots"
end
- context 'when entry value is two dots' do
- let(:config) { '..' }
+ context "when entry value is two dots" do
+ let(:config) { ".." }
- it_behaves_like 'key with only dots'
+ it_behaves_like "key with only dots"
end
- context 'when entry value is a URI encoded dot (%2E)' do
- let(:config) { '%2e' }
+ context "when entry value is a URI encoded dot (%2E)" do
+ let(:config) { "%2e" }
- it_behaves_like 'key with only dots'
+ it_behaves_like "key with only dots"
end
- context 'when entry value is two URI encoded dots (%2E)' do
- let(:config) { '%2E%2e' }
+ context "when entry value is two URI encoded dots (%2E)" do
+ let(:config) { "%2E%2e" }
- it_behaves_like 'key with only dots'
+ it_behaves_like "key with only dots"
end
- context 'when entry value is one dot and one URI encoded dot' do
- let(:config) { '.%2e' }
+ context "when entry value is one dot and one URI encoded dot" do
+ let(:config) { ".%2e" }
- it_behaves_like 'key with only dots'
+ it_behaves_like "key with only dots"
end
end
- describe '.default' do
- it 'returns default key' do
- expect(described_class.default).to eq 'default'
+ describe ".default" do
+ it "returns default key" do
+ expect(described_class.default).to eq "default"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/paths_spec.rb b/spec/lib/gitlab/ci/config/entry/paths_spec.rb
index 1d9c5ddee9b..1664214cbb3 100644
--- a/spec/lib/gitlab/ci/config/entry/paths_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/paths_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Paths do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is valid' do
- let(:config) { ['some/file', 'some/path/'] }
+ describe "validations" do
+ context "when entry config value is valid" do
+ let(:config) { ["some/file", "some/path/"] }
- describe '#value' do
- it 'returns key value' do
+ describe "#value" do
+ it "returns key value" do
expect(entry.value).to eq config
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not valid' do
+ context "when entry value is not valid" do
let(:config) { [1] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'paths config should be an array of strings'
+ .to include "paths config should be an array of strings"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/policy_spec.rb b/spec/lib/gitlab/ci/config/entry/policy_spec.rb
index 1c987e13a9a..de15109d0f5 100644
--- a/spec/lib/gitlab/ci/config/entry/policy_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/policy_spec.rb
@@ -1,54 +1,54 @@
-require 'fast_spec_helper'
-require_dependency 'active_model'
+require "fast_spec_helper"
+require_dependency "active_model"
describe Gitlab::Ci::Config::Entry::Policy do
let(:entry) { described_class.new(config) }
- context 'when using simplified policy' do
- describe 'validations' do
- context 'when entry config value is valid' do
- context 'when config is a branch or tag name' do
+ context "when using simplified policy" do
+ describe "validations" do
+ context "when entry config value is valid" do
+ context "when config is a branch or tag name" do
let(:config) { %w[master feature/branch] }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns refs hash' do
+ describe "#value" do
+ it "returns refs hash" do
expect(entry.value).to eq(refs: config)
end
end
end
- context 'when config is a regexp' do
- let(:config) { ['/^issue-.*$/'] }
+ context "when config is a regexp" do
+ let(:config) { ["/^issue-.*$/"] }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when config is a special keyword' do
+ context "when config is a special keyword" do
let(:config) { %w[tags triggers branches] }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
end
- context 'when entry value is not valid' do
+ context "when entry value is not valid" do
let(:config) { [1] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
.to include /policy config should be an array of strings or regexps/
end
@@ -57,135 +57,135 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
- context 'when using complex policy' do
- context 'when specifying refs policy' do
- let(:config) { { refs: ['master'] } }
+ context "when using complex policy" do
+ context "when specifying refs policy" do
+ let(:config) { {refs: ["master"]} }
- it 'is a correct configuraton' do
+ it "is a correct configuraton" do
expect(entry).to be_valid
expect(entry.value).to eq(refs: %w[master])
end
end
- context 'when specifying kubernetes policy' do
- let(:config) { { kubernetes: 'active' } }
+ context "when specifying kubernetes policy" do
+ let(:config) { {kubernetes: "active"} }
- it 'is a correct configuraton' do
+ it "is a correct configuraton" do
expect(entry).to be_valid
- expect(entry.value).to eq(kubernetes: 'active')
+ expect(entry.value).to eq(kubernetes: "active")
end
end
- context 'when specifying invalid kubernetes policy' do
- let(:config) { { kubernetes: 'something' } }
+ context "when specifying invalid kubernetes policy" do
+ let(:config) { {kubernetes: "something"} }
- it 'reports an error about invalid policy' do
+ it "reports an error about invalid policy" do
expect(entry.errors).to include /unknown value: something/
end
end
- context 'when specifying valid variables expressions policy' do
- let(:config) { { variables: ['$VAR == null'] } }
+ context "when specifying valid variables expressions policy" do
+ let(:config) { {variables: ["$VAR == null"]} }
- it 'is a correct configuraton' do
+ it "is a correct configuraton" do
expect(entry).to be_valid
expect(entry.value).to eq(config)
end
end
- context 'when specifying variables expressions in invalid format' do
- let(:config) { { variables: '$MY_VAR' } }
+ context "when specifying variables expressions in invalid format" do
+ let(:config) { {variables: "$MY_VAR"} }
- it 'reports an error about invalid format' do
+ it "reports an error about invalid format" do
expect(entry.errors).to include /should be an array of strings/
end
end
- context 'when specifying invalid variables expressions statement' do
- let(:config) { { variables: ['$MY_VAR =='] } }
+ context "when specifying invalid variables expressions statement" do
+ let(:config) { {variables: ["$MY_VAR =="]} }
- it 'reports an error about invalid statement' do
+ it "reports an error about invalid statement" do
expect(entry.errors).to include /invalid expression syntax/
end
end
- context 'when specifying invalid variables expressions token' do
- let(:config) { { variables: ['$MY_VAR == 123'] } }
+ context "when specifying invalid variables expressions token" do
+ let(:config) { {variables: ["$MY_VAR == 123"]} }
- it 'reports an error about invalid expression' do
+ it "reports an error about invalid expression" do
expect(entry.errors).to include /invalid expression syntax/
end
end
- context 'when using invalid variables expressions regexp' do
- let(:config) { { variables: ['$MY_VAR =~ /some ( thing/'] } }
+ context "when using invalid variables expressions regexp" do
+ let(:config) { {variables: ["$MY_VAR =~ /some ( thing/"]} }
- it 'reports an error about invalid expression' do
+ it "reports an error about invalid expression" do
expect(entry.errors).to include /invalid expression syntax/
end
end
- context 'when specifying a valid changes policy' do
- let(:config) { { changes: %w[some/* paths/**/*.rb] } }
+ context "when specifying a valid changes policy" do
+ let(:config) { {changes: %w[some/* paths/**/*.rb]} }
- it 'is a correct configuraton' do
+ it "is a correct configuraton" do
expect(entry).to be_valid
expect(entry.value).to eq(config)
end
end
- context 'when changes policy is invalid' do
- let(:config) { { changes: [1, 2] } }
+ context "when changes policy is invalid" do
+ let(:config) { {changes: [1, 2]} }
- it 'returns errors' do
+ it "returns errors" do
expect(entry.errors).to include /changes should be an array of strings/
end
end
- context 'when specifying unknown policy' do
- let(:config) { { refs: ['master'], invalid: :something } }
+ context "when specifying unknown policy" do
+ let(:config) { {refs: ["master"], invalid: :something} }
- it 'returns error about invalid key' do
+ it "returns error about invalid key" do
expect(entry.errors).to include /unknown keys: invalid/
end
end
- context 'when policy is empty' do
+ context "when policy is empty" do
let(:config) { {} }
- it 'is not a valid configuration' do
+ it "is not a valid configuration" do
expect(entry.errors).to include /can't be blank/
end
end
end
- context 'when policy strategy does not match' do
- let(:config) { 'string strategy' }
+ context "when policy strategy does not match" do
+ let(:config) { "string strategy" }
- it 'returns information about errors' do
+ it "returns information about errors" do
expect(entry.errors)
.to include /has to be either an array of conditions or a hash/
end
end
- describe '#value' do
- context 'when default value has been provided' do
+ describe "#value" do
+ context "when default value has been provided" do
before do
- entry.default = { refs: %w[branches tags] }
+ entry.default = {refs: %w[branches tags]}
end
- context 'when user overrides default values' do
- let(:config) { { refs: %w[feature], variables: %w[$VARIABLE] } }
+ context "when user overrides default values" do
+ let(:config) { {refs: %w[feature], variables: %w[$VARIABLE]} }
- it 'does not include default values' do
+ it "does not include default values" do
expect(entry.value).to eq config
end
end
- context 'when default value has not been defined' do
- let(:config) { { variables: %w[$VARIABLE] } }
+ context "when default value has not been defined" do
+ let(:config) { {variables: %w[$VARIABLE]} }
- it 'includes default values' do
+ it "includes default values" do
expect(entry.value).to eq(refs: %w[branches tags],
variables: %w[$VARIABLE])
end
@@ -193,8 +193,8 @@ describe Gitlab::Ci::Config::Entry::Policy do
end
end
- describe '.default' do
- it 'does not have default policy' do
+ describe ".default" do
+ it "does not have default policy" do
expect(described_class.default).to be_nil
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/reports_spec.rb b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
index 38943138cbf..599e1efe9ee 100644
--- a/spec/lib/gitlab/ci/config/entry/reports_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/reports_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Reports do
let(:entry) { described_class.new(config) }
- describe 'validates ALLOWED_KEYS' do
+ describe "validates ALLOWED_KEYS" do
let(:artifact_file_types) { Ci::JobArtifact.file_types }
described_class::ALLOWED_KEYS.each do |keyword, _|
@@ -13,69 +13,69 @@ describe Gitlab::Ci::Config::Entry::Reports do
end
end
- describe 'validation' do
- context 'when entry config value is correct' do
+ describe "validation" do
+ context "when entry config value is correct" do
using RSpec::Parameterized::TableSyntax
- shared_examples 'a valid entry' do |keyword, file|
- describe '#value' do
- it 'returns artifacts configuration' do
- expect(entry.value).to eq({ "#{keyword}": [file] } )
+ shared_examples "a valid entry" do |keyword, file|
+ describe "#value" do
+ it "returns artifacts configuration" do
+ expect(entry.value).to eq({:"#{keyword}" => [file]})
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
where(:keyword, :file) do
- :junit | 'junit.xml'
- :codequality | 'gl-code-quality-report.json'
- :sast | 'gl-sast-report.json'
- :dependency_scanning | 'gl-dependency-scanning-report.json'
- :container_scanning | 'gl-container-scanning-report.json'
- :dast | 'gl-dast-report.json'
- :license_management | 'gl-license-management-report.json'
- :performance | 'performance.json'
+ :junit | "junit.xml"
+ :codequality | "gl-code-quality-report.json"
+ :sast | "gl-sast-report.json"
+ :dependency_scanning | "gl-dependency-scanning-report.json"
+ :container_scanning | "gl-container-scanning-report.json"
+ :dast | "gl-dast-report.json"
+ :license_management | "gl-license-management-report.json"
+ :performance | "performance.json"
end
with_them do
- context 'when value is an array' do
- let(:config) { { "#{keyword}": [file] } }
+ context "when value is an array" do
+ let(:config) { {:"#{keyword}" => [file]} }
- it_behaves_like 'a valid entry', params[:keyword], params[:file]
+ it_behaves_like "a valid entry", params[:keyword], params[:file]
end
- context 'when value is not array' do
- let(:config) { { "#{keyword}": file } }
+ context "when value is not array" do
+ let(:config) { {:"#{keyword}" => file} }
- it_behaves_like 'a valid entry', params[:keyword], params[:file]
+ it_behaves_like "a valid entry", params[:keyword], params[:file]
end
end
end
- context 'when entry value is not correct' do
- describe '#errors' do
- context 'when value of attribute is invalid' do
+ context "when entry value is not correct" do
+ describe "#errors" do
+ context "when value of attribute is invalid" do
where(key: described_class::ALLOWED_KEYS) do
- let(:config) { { "#{key}": 10 } }
+ let(:config) { {:"#{key}" => 10} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors)
.to include "reports #{key} should be an array of strings or a string"
end
end
end
- context 'when there is an unknown key present' do
- let(:config) { { codeclimate: 'codeclimate.json' } }
+ context "when there is an unknown key present" do
+ let(:config) { {codeclimate: "codeclimate.json"} }
- it 'reports error' do
+ it "reports error" do
expect(entry.errors)
- .to include 'reports config contains unknown keys: codeclimate'
+ .to include "reports config contains unknown keys: codeclimate"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/retry_spec.rb b/spec/lib/gitlab/ci/config/entry/retry_spec.rb
index 164a9ed4c3d..49d29e44647 100644
--- a/spec/lib/gitlab/ci/config/entry/retry_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/retry_spec.rb
@@ -1,88 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Retry do
let(:entry) { described_class.new(config) }
- shared_context 'when retry value is a numeric', :numeric do
+ shared_context "when retry value is a numeric", :numeric do
let(:config) { max }
let(:max) {}
end
- shared_context 'when retry value is a hash', :hash do
- let(:config) { { max: max, when: public_send(:when) }.compact }
+ shared_context "when retry value is a hash", :hash do
+ let(:config) { {max: max, when: public_send(:when)}.compact }
let(:when) {}
let(:max) {}
end
- describe '#value' do
+ describe "#value" do
subject(:value) { entry.value }
- context 'when retry value is a numeric', :numeric do
+ context "when retry value is a numeric", :numeric do
let(:max) { 2 }
- it 'is returned as a hash with max key' do
+ it "is returned as a hash with max key" do
expect(value).to eq(max: 2)
end
end
- context 'when retry value is a hash', :hash do
- context 'and `when` is a string' do
- let(:when) { 'unknown_failure' }
+ context "when retry value is a hash", :hash do
+ context "and `when` is a string" do
+ let(:when) { "unknown_failure" }
- it 'returns when wrapped in an array' do
- expect(value).to eq(when: ['unknown_failure'])
+ it "returns when wrapped in an array" do
+ expect(value).to eq(when: ["unknown_failure"])
end
end
- context 'and `when` is an array' do
+ context "and `when` is an array" do
let(:when) { %w[unknown_failure runner_system_failure] }
- it 'returns when as it was passed' do
+ it "returns when as it was passed" do
expect(value).to eq(when: %w[unknown_failure runner_system_failure])
end
end
end
end
- describe 'validation' do
- context 'when retry value is correct' do
- context 'when it is a numeric', :numeric do
+ describe "validation" do
+ context "when retry value is correct" do
+ context "when it is a numeric", :numeric do
let(:max) { 2 }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'when it is a hash', :hash do
- context 'with max' do
+ context "when it is a hash", :hash do
+ context "with max" do
let(:max) { 2 }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'with string when' do
- let(:when) { 'unknown_failure' }
+ context "with string when" do
+ let(:when) { "unknown_failure" }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'with string when always' do
- let(:when) { 'always' }
+ context "with string when always" do
+ let(:when) { "always" }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
- context 'with array when' do
+ context "with array when" do
let(:when) { %w[unknown_failure runner_system_failure] }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
@@ -93,21 +93,21 @@ describe Gitlab::Ci::Config::Entry::Retry do
# values are valid. If they are not it means the documentation and this
# array must be updated.
RETRY_WHEN_IN_DOCUMENTATION = %w[
- always
- unknown_failure
- script_failure
- api_failure
- stuck_or_timeout_failure
- runner_system_failure
- missing_dependency_failure
- runner_unsupported
+ always
+ unknown_failure
+ script_failure
+ api_failure
+ stuck_or_timeout_failure
+ runner_system_failure
+ missing_dependency_failure
+ runner_unsupported
].freeze
RETRY_WHEN_IN_DOCUMENTATION.each do |reason|
context "with when from documentation `#{reason}`" do
let(:when) { reason }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
@@ -117,7 +117,7 @@ describe Gitlab::Ci::Config::Entry::Retry do
context "with when from CommitStatus.failure_reasons `#{reason}`" do
let(:when) { reason }
- it 'is valid' do
+ it "is valid" do
expect(entry).to be_valid
end
end
@@ -125,109 +125,109 @@ describe Gitlab::Ci::Config::Entry::Retry do
end
end
- context 'when retry value is not correct' do
- context 'when it is not a numeric nor an array' do
+ context "when retry value is not correct" do
+ context "when it is not a numeric nor an array" do
let(:config) { true }
- it 'returns error about invalid type' do
+ it "returns error about invalid type" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry config has to be either an integer or a hash'
+ expect(entry.errors).to include "retry config has to be either an integer or a hash"
end
end
- context 'when it is a numeric', :numeric do
- context 'when it is lower than zero' do
+ context "when it is a numeric", :numeric do
+ context "when it is lower than zero" do
let(:max) { -1 }
- it 'returns error about value too low' do
+ it "returns error about value too low" do
expect(entry).not_to be_valid
expect(entry.errors)
- .to include 'retry config must be greater than or equal to 0'
+ .to include "retry config must be greater than or equal to 0"
end
end
- context 'when it is not an integer' do
+ context "when it is not an integer" do
let(:max) { 1.5 }
- it 'returns error about wrong value' do
+ it "returns error about wrong value" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry config has to be either an integer or a hash'
+ expect(entry.errors).to include "retry config has to be either an integer or a hash"
end
end
- context 'when the value is too high' do
+ context "when the value is too high" do
let(:max) { 10 }
- it 'returns error about value too high' do
+ it "returns error about value too high" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry config must be less than or equal to 2'
+ expect(entry.errors).to include "retry config must be less than or equal to 2"
end
end
end
- context 'when it is a hash', :hash do
- context 'with unknown keys' do
- let(:config) { { max: 2, unknown_key: :something, one_more: :key } }
+ context "when it is a hash", :hash do
+ context "with unknown keys" do
+ let(:config) { {max: 2, unknown_key: :something, one_more: :key} }
- it 'returns error about the unknown key' do
+ it "returns error about the unknown key" do
expect(entry).not_to be_valid
expect(entry.errors)
- .to include 'retry config contains unknown keys: unknown_key, one_more'
+ .to include "retry config contains unknown keys: unknown_key, one_more"
end
end
- context 'with max lower than zero' do
+ context "with max lower than zero" do
let(:max) { -1 }
- it 'returns error about value too low' do
+ it "returns error about value too low" do
expect(entry).not_to be_valid
expect(entry.errors)
- .to include 'retry max must be greater than or equal to 0'
+ .to include "retry max must be greater than or equal to 0"
end
end
- context 'with max not an integer' do
+ context "with max not an integer" do
let(:max) { 1.5 }
- it 'returns error about wrong value' do
+ it "returns error about wrong value" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry max must be an integer'
+ expect(entry.errors).to include "retry max must be an integer"
end
end
- context 'iwth max too high' do
+ context "iwth max too high" do
let(:max) { 10 }
- it 'returns error about value too high' do
+ it "returns error about value too high" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry max must be less than or equal to 2'
+ expect(entry.errors).to include "retry max must be less than or equal to 2"
end
end
- context 'with when in wrong format' do
+ context "with when in wrong format" do
let(:when) { true }
- it 'returns error about the wrong format' do
+ it "returns error about the wrong format" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry when should be an array of strings or a string'
+ expect(entry.errors).to include "retry when should be an array of strings or a string"
end
end
- context 'with an unknown when string' do
- let(:when) { 'unknown_reason' }
+ context "with an unknown when string" do
+ let(:when) { "unknown_reason" }
- it 'returns error about the wrong format' do
+ it "returns error about the wrong format" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry when is not included in the list'
+ expect(entry.errors).to include "retry when is not included in the list"
end
end
- context 'with an unknown failure reason in a when array' do
+ context "with an unknown failure reason in a when array" do
let(:when) { %w[unknown_reason runner_system_failure] }
- it 'returns error about the wrong format' do
+ it "returns error about the wrong format" do
expect(entry).not_to be_valid
- expect(entry.errors).to include 'retry when contains unknown values: unknown_reason'
+ expect(entry.errors).to include "retry when contains unknown values: unknown_reason"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/script_spec.rb b/spec/lib/gitlab/ci/config/entry/script_spec.rb
index 069eaa26422..dfd40a85a82 100644
--- a/spec/lib/gitlab/ci/config/entry/script_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/script_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Script do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is correct' do
- let(:config) { %w(ls pwd) }
+ describe "validations" do
+ context "when entry config value is correct" do
+ let(:config) { %w[ls pwd] }
- describe '#value' do
- it 'returns array of strings' do
+ describe "#value" do
+ it "returns array of strings" do
expect(entry.value).to eq config
end
end
- describe '#errors' do
- it 'does not append errors' do
+ describe "#errors" do
+ it "does not append errors" do
expect(entry.errors).to be_empty
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- let(:config) { 'ls' }
+ context "when entry value is not correct" do
+ let(:config) { "ls" }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'script config should be an array of strings'
+ .to include "script config should be an array of strings"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb
index 9ebf947a751..5be533c154c 100644
--- a/spec/lib/gitlab/ci/config/entry/service_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Service do
let(:entry) { described_class.new(config) }
@@ -7,111 +7,111 @@ describe Gitlab::Ci::Config::Entry::Service do
entry.compose!
end
- context 'when configuration is a string' do
- let(:config) { 'postgresql:9.5' }
+ context "when configuration is a string" do
+ let(:config) { "postgresql:9.5" }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns valid hash' do
- expect(entry.value).to include(name: 'postgresql:9.5')
+ describe "#value" do
+ it "returns valid hash" do
+ expect(entry.value).to include(name: "postgresql:9.5")
end
end
- describe '#image' do
+ describe "#image" do
it "returns service's image name" do
- expect(entry.name).to eq 'postgresql:9.5'
+ expect(entry.name).to eq "postgresql:9.5"
end
end
- describe '#alias' do
+ describe "#alias" do
it "returns service's alias" do
expect(entry.alias).to be_nil
end
end
- describe '#command' do
+ describe "#command" do
it "returns service's command" do
expect(entry.command).to be_nil
end
end
end
- context 'when configuration is a hash' do
+ context "when configuration is a hash" do
let(:config) do
- { name: 'postgresql:9.5', alias: 'db', command: %w(cmd run), entrypoint: %w(/bin/sh run) }
+ {name: "postgresql:9.5", alias: "db", command: %w[cmd run], entrypoint: %w[/bin/sh run]}
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns valid hash' do
+ describe "#value" do
+ it "returns valid hash" do
expect(entry.value).to eq config
end
end
- describe '#image' do
+ describe "#image" do
it "returns service's image name" do
- expect(entry.name).to eq 'postgresql:9.5'
+ expect(entry.name).to eq "postgresql:9.5"
end
end
- describe '#alias' do
+ describe "#alias" do
it "returns service's alias" do
- expect(entry.alias).to eq 'db'
+ expect(entry.alias).to eq "db"
end
end
- describe '#command' do
+ describe "#command" do
it "returns service's command" do
- expect(entry.command).to eq %w(cmd run)
+ expect(entry.command).to eq %w[cmd run]
end
end
- describe '#entrypoint' do
+ describe "#entrypoint" do
it "returns service's entrypoint" do
- expect(entry.entrypoint).to eq %w(/bin/sh run)
+ expect(entry.entrypoint).to eq %w[/bin/sh run]
end
end
end
- context 'when entry value is not correct' do
- let(:config) { ['postgresql:9.5'] }
+ context "when entry value is not correct" do
+ let(:config) { ["postgresql:9.5"] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'service config should be a hash or a string'
+ .to include "service config should be a hash or a string"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
end
- context 'when unexpected key is specified' do
- let(:config) { { name: 'postgresql:9.5', non_existing: 'test' } }
+ context "when unexpected key is specified" do
+ let(:config) { {name: "postgresql:9.5", non_existing: "test"} }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'service config contains unknown keys: non_existing'
+ .to include "service config contains unknown keys: non_existing"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/services_spec.rb b/spec/lib/gitlab/ci/config/entry/services_spec.rb
index 7c4319aee63..b2ba3e5129a 100644
--- a/spec/lib/gitlab/ci/config/entry/services_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/services_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Services do
let(:entry) { described_class.new(config) }
@@ -7,27 +7,27 @@ describe Gitlab::Ci::Config::Entry::Services do
entry.compose!
end
- context 'when configuration is valid' do
- let(:config) { ['postgresql:9.5', { name: 'postgresql:9.1', alias: 'postgres_old' }] }
+ context "when configuration is valid" do
+ let(:config) { ["postgresql:9.5", {name: "postgresql:9.1", alias: "postgres_old"}] }
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
- describe '#value' do
- it 'returns valid array' do
- expect(entry.value).to eq([{ name: 'postgresql:9.5' }, { name: 'postgresql:9.1', alias: 'postgres_old' }])
+ describe "#value" do
+ it "returns valid array" do
+ expect(entry.value).to eq([{name: "postgresql:9.5"}, {name: "postgresql:9.1", alias: "postgres_old"}])
end
end
end
- context 'when configuration is invalid' do
- let(:config) { 'postgresql:9.5' }
+ context "when configuration is invalid" do
+ let(:config) { "postgresql:9.5" }
- describe '#valid?' do
- it 'is invalid' do
+ describe "#valid?" do
+ it "is invalid" do
expect(entry).not_to be_valid
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/stage_spec.rb b/spec/lib/gitlab/ci/config/entry/stage_spec.rb
index 70c8a0a355a..16f5238159d 100644
--- a/spec/lib/gitlab/ci/config/entry/stage_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/stage_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Stage do
let(:stage) { described_class.new(config) }
- describe 'validations' do
- context 'when stage config value is correct' do
- let(:config) { 'build' }
+ describe "validations" do
+ context "when stage config value is correct" do
+ let(:config) { "build" }
- describe '#value' do
- it 'returns a stage key' do
+ describe "#value" do
+ it "returns a stage key" do
expect(stage.value).to eq config
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(stage).to be_valid
end
end
end
- context 'when value has a wrong type' do
- let(:config) { { test: true } }
+ context "when value has a wrong type" do
+ let(:config) { {test: true} }
- it 'reports errors about wrong type' do
+ it "reports errors about wrong type" do
expect(stage.errors)
- .to include 'stage config should be a string'
+ .to include "stage config should be a string"
end
end
end
- describe '.default' do
- it 'returns default stage' do
- expect(described_class.default).to eq 'test'
+ describe ".default" do
+ it "returns default stage" do
+ expect(described_class.default).to eq "test"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/stages_spec.rb b/spec/lib/gitlab/ci/config/entry/stages_spec.rb
index 182c8d867c7..e64c28e7840 100644
--- a/spec/lib/gitlab/ci/config/entry/stages_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/stages_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Stages do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is correct' do
+ describe "validations" do
+ context "when entry config value is correct" do
let(:config) { [:stage1, :stage2] }
- describe '#value' do
- it 'returns array of stages' do
+ describe "#value" do
+ it "returns array of stages" do
expect(entry.value).to eq config
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- let(:config) { { test: true } }
+ context "when entry value is not correct" do
+ let(:config) { {test: true} }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'stages config should be an array of strings'
+ .to include "stages config should be an array of strings"
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
end
end
- describe '.default' do
- it 'returns default stages' do
+ describe ".default" do
+ it "returns default stages" do
expect(described_class.default).to eq %w[build test deploy]
end
end
diff --git a/spec/lib/gitlab/ci/config/entry/variables_spec.rb b/spec/lib/gitlab/ci/config/entry/variables_spec.rb
index 84bfef9e8ad..98888bfd6da 100644
--- a/spec/lib/gitlab/ci/config/entry/variables_spec.rb
+++ b/spec/lib/gitlab/ci/config/entry/variables_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::Entry::Variables do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is correct' do
+ describe "validations" do
+ context "when entry config value is correct" do
let(:config) do
- { 'VARIABLE_1' => 'value 1', 'VARIABLE_2' => 'value 2' }
+ {"VARIABLE_1" => "value 1", "VARIABLE_2" => "value 2"}
end
- describe '#value' do
- it 'returns hash with key value strings' do
+ describe "#value" do
+ it "returns hash with key value strings" do
expect(entry.value).to eq config
end
- context 'with numeric keys and values in the config' do
- let(:config) { { 10 => 20 } }
+ context "with numeric keys and values in the config" do
+ let(:config) { {10 => 20} }
- it 'converts numeric key and numeric value into strings' do
- expect(entry.value).to eq('10' => '20')
+ it "converts numeric key and numeric value into strings" do
+ expect(entry.value).to eq("10" => "20")
end
end
end
- describe '#errors' do
- it 'does not append errors' do
+ describe "#errors" do
+ it "does not append errors" do
expect(entry.errors).to be_empty
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not correct' do
- let(:config) { [:VAR, 'test'] }
+ context "when entry value is not correct" do
+ let(:config) { [:VAR, "test"] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
.to include /should be a hash of key value pairs/
end
end
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(entry).not_to be_valid
end
end
diff --git a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb
index 0a148375d11..f6572cbaae4 100644
--- a/spec/lib/gitlab/ci/config/extendable/entry_spec.rb
+++ b/spec/lib/gitlab/ci/config/extendable/entry_spec.rb
@@ -1,190 +1,190 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Config::Extendable::Entry do
- describe '.new' do
- context 'when entry key is not included in the context hash' do
- it 'raises error' do
- expect { described_class.new(:test, something: 'something') }
- .to raise_error StandardError, 'Invalid entry key!'
+ describe ".new" do
+ context "when entry key is not included in the context hash" do
+ it "raises error" do
+ expect { described_class.new(:test, something: "something") }
+ .to raise_error StandardError, "Invalid entry key!"
end
end
end
- describe '#value' do
- it 'reads a hash value from the context' do
- entry = described_class.new(:test, test: 'something')
+ describe "#value" do
+ it "reads a hash value from the context" do
+ entry = described_class.new(:test, test: "something")
- expect(entry.value).to eq 'something'
+ expect(entry.value).to eq "something"
end
end
- describe '#extensible?' do
- context 'when entry has inheritance defined' do
- it 'is extensible' do
- entry = described_class.new(:test, test: { extends: 'something' })
+ describe "#extensible?" do
+ context "when entry has inheritance defined" do
+ it "is extensible" do
+ entry = described_class.new(:test, test: {extends: "something"})
expect(entry).to be_extensible
end
end
- context 'when entry does not have inheritance specified' do
- it 'is not extensible' do
- entry = described_class.new(:test, test: { script: 'something' })
+ context "when entry does not have inheritance specified" do
+ it "is not extensible" do
+ entry = described_class.new(:test, test: {script: "something"})
expect(entry).not_to be_extensible
end
end
- context 'when entry value is not a hash' do
- it 'is not extensible' do
- entry = described_class.new(:test, test: 'something')
+ context "when entry value is not a hash" do
+ it "is not extensible" do
+ entry = described_class.new(:test, test: "something")
expect(entry).not_to be_extensible
end
end
end
- describe '#extends_key' do
- context 'when entry is extensible' do
- it 'returns symbolized extends key value' do
- entry = described_class.new(:test, test: { extends: 'something' })
+ describe "#extends_key" do
+ context "when entry is extensible" do
+ it "returns symbolized extends key value" do
+ entry = described_class.new(:test, test: {extends: "something"})
expect(entry.extends_key).to eq :something
end
end
- context 'when entry is not extensible' do
- it 'returns nil' do
- entry = described_class.new(:test, test: 'something')
+ context "when entry is not extensible" do
+ it "returns nil" do
+ entry = described_class.new(:test, test: "something")
expect(entry.extends_key).to be_nil
end
end
end
- describe '#ancestors' do
+ describe "#ancestors" do
let(:parent) do
- described_class.new(:test, test: { extends: 'something' })
+ described_class.new(:test, test: {extends: "something"})
end
let(:child) do
- described_class.new(:job, { job: { script: 'something' } }, parent)
+ described_class.new(:job, {job: {script: "something"}}, parent)
end
- it 'returns ancestors keys' do
+ it "returns ancestors keys" do
expect(child.ancestors).to eq [:test]
end
end
- describe '#base_hash!' do
+ describe "#base_hash!" do
subject { described_class.new(:test, hash) }
- context 'when base hash is not extensible' do
+ context "when base hash is not extensible" do
let(:hash) do
{
- template: { script: 'rspec' },
- test: { extends: 'template' }
+ template: {script: "rspec"},
+ test: {extends: "template"},
}
end
- it 'returns unchanged base hash' do
- expect(subject.base_hash!).to eq(script: 'rspec')
+ it "returns unchanged base hash" do
+ expect(subject.base_hash!).to eq(script: "rspec")
end
end
- context 'when base hash is extensible too' do
+ context "when base hash is extensible too" do
let(:hash) do
{
- first: { script: 'rspec' },
- second: { extends: 'first' },
- test: { extends: 'second' }
+ first: {script: "rspec"},
+ second: {extends: "first"},
+ test: {extends: "second"},
}
end
- it 'extends the base hash first' do
- expect(subject.base_hash!).to eq(extends: 'first', script: 'rspec')
+ it "extends the base hash first" do
+ expect(subject.base_hash!).to eq(extends: "first", script: "rspec")
end
- it 'mutates original context' do
+ it "mutates original context" do
subject.base_hash!
- expect(hash.fetch(:second)).to eq(extends: 'first', script: 'rspec')
+ expect(hash.fetch(:second)).to eq(extends: "first", script: "rspec")
end
end
end
- describe '#extend!' do
+ describe "#extend!" do
subject { described_class.new(:test, hash) }
- context 'when extending a non-hash value' do
+ context "when extending a non-hash value" do
let(:hash) do
{
- first: 'my value',
- test: { extends: 'first' }
+ first: "my value",
+ test: {extends: "first"},
}
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.extend! }
.to raise_error(described_class::InvalidExtensionError,
- /invalid base hash/)
+ /invalid base hash/)
end
end
- context 'when extending unknown key' do
+ context "when extending unknown key" do
let(:hash) do
- { test: { extends: 'something' } }
+ {test: {extends: "something"}}
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.extend! }
.to raise_error(described_class::InvalidExtensionError,
- /unknown key/)
+ /unknown key/)
end
end
- context 'when extending a hash correctly' do
+ context "when extending a hash correctly" do
let(:hash) do
{
- first: { script: 'my value' },
- second: { extends: 'first' },
- test: { extends: 'second' }
+ first: {script: "my value"},
+ second: {extends: "first"},
+ test: {extends: "second"},
}
end
let(:result) do
{
- first: { script: 'my value' },
- second: { extends: 'first', script: 'my value' },
- test: { extends: 'second', script: 'my value' }
+ first: {script: "my value"},
+ second: {extends: "first", script: "my value"},
+ test: {extends: "second", script: "my value"},
}
end
- it 'returns extended part of the hash' do
+ it "returns extended part of the hash" do
expect(subject.extend!).to eq result[:test]
end
- it 'mutates original context' do
+ it "mutates original context" do
subject.extend!
expect(hash).to eq result
end
end
- context 'when hash is not extensible' do
+ context "when hash is not extensible" do
let(:hash) do
{
- first: { script: 'my value' },
- second: { extends: 'first' },
- test: { value: 'something' }
+ first: {script: "my value"},
+ second: {extends: "first"},
+ test: {value: "something"},
}
end
- it 'returns original key value' do
- expect(subject.extend!).to eq(value: 'something')
+ it "returns original key value" do
+ expect(subject.extend!).to eq(value: "something")
end
- it 'does not mutate orignal context' do
+ it "does not mutate orignal context" do
original = hash.deep_dup
subject.extend!
@@ -193,32 +193,32 @@ describe Gitlab::Ci::Config::Extendable::Entry do
end
end
- context 'when circular depenency gets detected' do
+ context "when circular depenency gets detected" do
let(:hash) do
- { test: { extends: 'test' } }
+ {test: {extends: "test"}}
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.extend! }
.to raise_error(described_class::CircularDependencyError,
- /circular dependency detected/)
+ /circular dependency detected/)
end
end
- context 'when nesting level is too deep' do
+ context "when nesting level is too deep" do
before do
stub_const("#{described_class}::MAX_NESTING_LEVELS", 0)
end
let(:hash) do
{
- first: { script: 'my value' },
- second: { extends: 'first' },
- test: { extends: 'second' }
+ first: {script: "my value"},
+ second: {extends: "first"},
+ test: {extends: "second"},
}
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.extend! }
.to raise_error(described_class::NestingTooDeepError)
end
diff --git a/spec/lib/gitlab/ci/config/extendable_spec.rb b/spec/lib/gitlab/ci/config/extendable_spec.rb
index 90213f6603d..5672bd68c5a 100644
--- a/spec/lib/gitlab/ci/config/extendable_spec.rb
+++ b/spec/lib/gitlab/ci/config/extendable_spec.rb
@@ -1,225 +1,225 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Config::Extendable do
subject { described_class.new(hash) }
- describe '#each' do
- context 'when there is extendable entry in the hash' do
+ describe "#each" do
+ context "when there is extendable entry in the hash" do
let(:test) do
- { extends: 'something', only: %w[master] }
+ {extends: "something", only: %w[master]}
end
let(:hash) do
- { something: { script: 'ls' }, test: test }
+ {something: {script: "ls"}, test: test}
end
- it 'yields control' do
+ it "yields control" do
expect { |b| subject.each(&b) }.to yield_control
end
end
end
- describe '#to_hash' do
- context 'when hash does not contain extensions' do
+ describe "#to_hash" do
+ context "when hash does not contain extensions" do
let(:hash) do
{
- test: { script: 'test' },
+ test: {script: "test"},
production: {
- script: 'deploy',
- only: { variables: %w[$SOMETHING] }
- }
+ script: "deploy",
+ only: {variables: %w[$SOMETHING]},
+ },
}
end
- it 'does not modify the hash' do
+ it "does not modify the hash" do
expect(subject.to_hash).to eq hash
end
end
- context 'when hash has a single simple extension' do
+ context "when hash has a single simple extension" do
let(:hash) do
{
something: {
- script: 'deploy',
- only: { variables: %w[$SOMETHING] }
+ script: "deploy",
+ only: {variables: %w[$SOMETHING]},
},
test: {
- extends: 'something',
- script: 'ls',
- only: { refs: %w[master] }
- }
+ extends: "something",
+ script: "ls",
+ only: {refs: %w[master]},
+ },
}
end
- it 'extends a hash with a deep reverse merge' do
+ it "extends a hash with a deep reverse merge" do
expect(subject.to_hash).to eq(
something: {
- script: 'deploy',
- only: { variables: %w[$SOMETHING] }
+ script: "deploy",
+ only: {variables: %w[$SOMETHING]},
},
test: {
- extends: 'something',
- script: 'ls',
+ extends: "something",
+ script: "ls",
only: {
refs: %w[master],
- variables: %w[$SOMETHING]
- }
+ variables: %w[$SOMETHING],
+ },
}
)
end
end
- context 'when a hash uses recursive extensions' do
+ context "when a hash uses recursive extensions" do
let(:hash) do
{
test: {
- extends: 'something',
- script: 'ls',
- only: { refs: %w[master] }
+ extends: "something",
+ script: "ls",
+ only: {refs: %w[master]},
},
build: {
- extends: 'something',
- stage: 'build'
+ extends: "something",
+ stage: "build",
},
deploy: {
- stage: 'deploy',
- extends: '.first'
+ stage: "deploy",
+ extends: ".first",
},
something: {
- extends: '.first',
- script: 'exec',
- only: { variables: %w[$SOMETHING] }
+ extends: ".first",
+ script: "exec",
+ only: {variables: %w[$SOMETHING]},
},
'.first': {
- script: 'run',
- only: { kubernetes: 'active' }
- }
+ script: "run",
+ only: {kubernetes: "active"},
+ },
}
end
- it 'extends a hash with a deep reverse merge' do
+ it "extends a hash with a deep reverse merge" do
expect(subject.to_hash).to eq(
'.first': {
- script: 'run',
- only: { kubernetes: 'active' }
+ script: "run",
+ only: {kubernetes: "active"},
},
something: {
- extends: '.first',
- script: 'exec',
+ extends: ".first",
+ script: "exec",
only: {
- kubernetes: 'active',
- variables: %w[$SOMETHING]
- }
+ kubernetes: "active",
+ variables: %w[$SOMETHING],
+ },
},
deploy: {
- script: 'run',
- stage: 'deploy',
- only: { kubernetes: 'active' },
- extends: '.first'
+ script: "run",
+ stage: "deploy",
+ only: {kubernetes: "active"},
+ extends: ".first",
},
build: {
- extends: 'something',
- script: 'exec',
- stage: 'build',
+ extends: "something",
+ script: "exec",
+ stage: "build",
only: {
- kubernetes: 'active',
- variables: %w[$SOMETHING]
- }
+ kubernetes: "active",
+ variables: %w[$SOMETHING],
+ },
},
test: {
- extends: 'something',
- script: 'ls',
+ extends: "something",
+ script: "ls",
only: {
refs: %w[master],
variables: %w[$SOMETHING],
- kubernetes: 'active'
- }
+ kubernetes: "active",
+ },
}
)
end
end
- context 'when nested circular dependecy has been detected' do
+ context "when nested circular dependecy has been detected" do
let(:hash) do
{
test: {
- extends: 'something',
- script: 'ls',
- only: { refs: %w[master] }
+ extends: "something",
+ script: "ls",
+ only: {refs: %w[master]},
},
something: {
- extends: '.first',
- script: 'deploy',
- only: { variables: %w[$SOMETHING] }
+ extends: ".first",
+ script: "deploy",
+ only: {variables: %w[$SOMETHING]},
},
'.first': {
- extends: 'something',
- script: 'run',
- only: { kubernetes: 'active' }
- }
+ extends: "something",
+ script: "run",
+ only: {kubernetes: "active"},
+ },
}
end
- it 'raises an error about circular dependency' do
+ it "raises an error about circular dependency" do
expect { subject.to_hash }
.to raise_error(described_class::Entry::CircularDependencyError)
end
end
- context 'when circular dependecy to self has been detected' do
+ context "when circular dependecy to self has been detected" do
let(:hash) do
{
test: {
- extends: 'test',
- script: 'ls',
- only: { refs: %w[master] }
- }
+ extends: "test",
+ script: "ls",
+ only: {refs: %w[master]},
+ },
}
end
- it 'raises an error about circular dependency' do
+ it "raises an error about circular dependency" do
expect { subject.to_hash }
.to raise_error(described_class::Entry::CircularDependencyError)
end
end
- context 'when invalid extends value is specified' do
+ context "when invalid extends value is specified" do
let(:hash) do
- { something: { extends: 1, script: 'ls' } }
+ {something: {extends: 1, script: "ls"}}
end
- it 'raises an error about invalid extension' do
+ it "raises an error about invalid extension" do
expect { subject.to_hash }
.to raise_error(described_class::Entry::InvalidExtensionError)
end
end
- context 'when extensible entry has non-hash inheritance defined' do
+ context "when extensible entry has non-hash inheritance defined" do
let(:hash) do
{
test: {
- extends: 'something',
- script: 'ls',
- only: { refs: %w[master] }
+ extends: "something",
+ script: "ls",
+ only: {refs: %w[master]},
},
- something: 'some text'
+ something: "some text",
}
end
- it 'raises an error about invalid base' do
+ it "raises an error about invalid base" do
expect { subject.to_hash }
.to raise_error(described_class::Entry::InvalidExtensionError)
end
diff --git a/spec/lib/gitlab/ci/config/external/file/base_spec.rb b/spec/lib/gitlab/ci/config/external/file/base_spec.rb
index 1a6b3587599..b0c5e6aa191 100644
--- a/spec/lib/gitlab/ci/config/external/file/base_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/base_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Config::External::File::Base do
- let(:context) { described_class::Context.new(nil, 'HEAD', nil) }
+ let(:context) { described_class::Context.new(nil, "HEAD", nil) }
let(:test_class) do
Class.new(described_class) do
@@ -19,61 +19,61 @@ describe Gitlab::Ci::Config::External::File::Base do
before do
allow_any_instance_of(test_class)
- .to receive(:content).and_return('key: value')
+ .to receive(:content).and_return("key: value")
end
- describe '#matching?' do
- context 'when a location is present' do
- let(:location) { 'some-location' }
+ describe "#matching?" do
+ context "when a location is present" do
+ let(:location) { "some-location" }
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_matching
end
end
- context 'with a location is missing' do
+ context "with a location is missing" do
let(:location) { nil }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
end
- describe '#valid?' do
- context 'when location is not a YAML file' do
- let(:location) { 'some/file.txt' }
+ describe "#valid?" do
+ context "when location is not a YAML file" do
+ let(:location) { "some/file.txt" }
it { is_expected.not_to be_valid }
end
- context 'when location has not a valid naming scheme' do
- let(:location) { 'some/file/.yml' }
+ context "when location has not a valid naming scheme" do
+ let(:location) { "some/file/.yml" }
it { is_expected.not_to be_valid }
end
- context 'when location is a valid .yml extension' do
- let(:location) { 'some/file/config.yml' }
+ context "when location is a valid .yml extension" do
+ let(:location) { "some/file/config.yml" }
it { is_expected.to be_valid }
end
- context 'when location is a valid .yaml extension' do
- let(:location) { 'some/file/config.yaml' }
+ context "when location is a valid .yaml extension" do
+ let(:location) { "some/file/config.yaml" }
it { is_expected.to be_valid }
end
- context 'when there are YAML syntax errors' do
- let(:location) { 'some/file/config.yml' }
+ context "when there are YAML syntax errors" do
+ let(:location) { "some/file/config.yml" }
before do
allow_any_instance_of(test_class)
- .to receive(:content).and_return('invalid_syntax')
+ .to receive(:content).and_return("invalid_syntax")
end
- it 'is not a valid file' do
+ it "is not a valid file" do
expect(subject).not_to be_valid
expect(subject.error_message).to match /does not have valid YAML syntax/
end
diff --git a/spec/lib/gitlab/ci/config/external/file/local_spec.rb b/spec/lib/gitlab/ci/config/external/file/local_spec.rb
index ff67a765da0..9418c6b8c45 100644
--- a/spec/lib/gitlab/ci/config/external/file/local_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/local_spec.rb
@@ -1,72 +1,72 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::File::Local do
set(:project) { create(:project, :repository) }
- let(:context) { described_class::Context.new(project, '12345', nil) }
- let(:params) { { local: location } }
+ let(:context) { described_class::Context.new(project, "12345", nil) }
+ let(:params) { {local: location} }
let(:local_file) { described_class.new(params, context) }
- describe '#matching?' do
- context 'when a local is specified' do
- let(:params) { { local: 'file' } }
+ describe "#matching?" do
+ context "when a local is specified" do
+ let(:params) { {local: "file"} }
- it 'should return true' do
+ it "should return true" do
expect(local_file).to be_matching
end
end
- context 'with a missing local' do
- let(:params) { { local: nil } }
+ context "with a missing local" do
+ let(:params) { {local: nil} }
- it 'should return false' do
+ it "should return false" do
expect(local_file).not_to be_matching
end
end
- context 'with a missing local key' do
+ context "with a missing local key" do
let(:params) { {} }
- it 'should return false' do
+ it "should return false" do
expect(local_file).not_to be_matching
end
end
end
- describe '#valid?' do
- context 'when is a valid local path' do
- let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' }
+ describe "#valid?" do
+ context "when is a valid local path" do
+ let(:location) { "/lib/gitlab/ci/templates/existent-file.yml" }
before do
allow_any_instance_of(described_class).to receive(:fetch_local_content).and_return("image: 'ruby2:2'")
end
- it 'should return true' do
+ it "should return true" do
expect(local_file.valid?).to be_truthy
end
end
- context 'when is not a valid local path' do
- let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' }
+ context "when is not a valid local path" do
+ let(:location) { "/lib/gitlab/ci/templates/non-existent-file.yml" }
- it 'should return false' do
+ it "should return false" do
expect(local_file.valid?).to be_falsy
end
end
- context 'when is not a yaml file' do
- let(:location) { '/config/application.rb' }
+ context "when is not a yaml file" do
+ let(:location) { "/config/application.rb" }
- it 'should return false' do
+ it "should return false" do
expect(local_file.valid?).to be_falsy
end
end
end
- describe '#content' do
- context 'with a valid file' do
+ describe "#content" do
+ context "with a valid file" do
let(:local_file_content) do
<<~HEREDOC
before_script:
@@ -76,30 +76,30 @@ describe Gitlab::Ci::Config::External::File::Local do
- bundle install --jobs $(nproc) "${FLAGS[@]}"
HEREDOC
end
- let(:location) { '/lib/gitlab/ci/templates/existent-file.yml' }
+ let(:location) { "/lib/gitlab/ci/templates/existent-file.yml" }
before do
allow_any_instance_of(described_class).to receive(:fetch_local_content).and_return(local_file_content)
end
- it 'should return the content of the file' do
+ it "should return the content of the file" do
expect(local_file.content).to eq(local_file_content)
end
end
- context 'with an invalid file' do
- let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' }
+ context "with an invalid file" do
+ let(:location) { "/lib/gitlab/ci/templates/non-existent-file.yml" }
- it 'should be nil' do
+ it "should be nil" do
expect(local_file.content).to be_nil
end
end
end
- describe '#error_message' do
- let(:location) { '/lib/gitlab/ci/templates/non-existent-file.yml' }
+ describe "#error_message" do
+ let(:location) { "/lib/gitlab/ci/templates/non-existent-file.yml" }
- it 'should return an error message' do
+ it "should return an error message" do
expect(local_file.error_message).to eq("Local file `#{location}` does not exist!")
end
end
diff --git a/spec/lib/gitlab/ci/config/external/file/project_spec.rb b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
index 11809adcaf6..e8d42fe5d80 100644
--- a/spec/lib/gitlab/ci/config/external/file/project_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/project_spec.rb
@@ -1,142 +1,142 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::File::Project do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
let(:context_user) { user }
- let(:context) { described_class::Context.new(nil, '12345', context_user) }
+ let(:context) { described_class::Context.new(nil, "12345", context_user) }
let(:subject) { described_class.new(params, context) }
before do
project.add_developer(user)
end
- describe '#matching?' do
- context 'when a file and project is specified' do
- let(:params) { { file: 'file.yml', project: 'project' } }
+ describe "#matching?" do
+ context "when a file and project is specified" do
+ let(:params) { {file: "file.yml", project: "project"} }
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_matching
end
end
- context 'with only file is specified' do
- let(:params) { { file: 'file.yml' } }
+ context "with only file is specified" do
+ let(:params) { {file: "file.yml"} }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
- context 'with only project is specified' do
- let(:params) { { project: 'project' } }
+ context "with only project is specified" do
+ let(:params) { {project: "project"} }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
- context 'with a missing local key' do
+ context "with a missing local key" do
let(:params) { {} }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
end
- describe '#valid?' do
- context 'when a valid path is used' do
+ describe "#valid?" do
+ context "when a valid path is used" do
let(:params) do
- { project: project.full_path, file: '/file.yml' }
+ {project: project.full_path, file: "/file.yml"}
end
let(:root_ref_sha) { project.repository.root_ref_sha }
before do
- stub_project_blob(root_ref_sha, '/file.yml') { 'image: ruby:2.1' }
+ stub_project_blob(root_ref_sha, "/file.yml") { "image: ruby:2.1" }
end
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_valid
end
- context 'when user does not have permission to access file' do
+ context "when user does not have permission to access file" do
let(:context_user) { create(:user) }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
expect(subject.error_message).to include("Project `#{project.full_path}` not found or access denied!")
end
end
end
- context 'when a valid path with custom ref is used' do
+ context "when a valid path with custom ref is used" do
let(:params) do
- { project: project.full_path, ref: 'master', file: '/file.yml' }
+ {project: project.full_path, ref: "master", file: "/file.yml"}
end
- let(:ref_sha) { project.commit('master').sha }
+ let(:ref_sha) { project.commit("master").sha }
before do
- stub_project_blob(ref_sha, '/file.yml') { 'image: ruby:2.1' }
+ stub_project_blob(ref_sha, "/file.yml") { "image: ruby:2.1" }
end
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_valid
end
end
- context 'when an empty file is used' do
+ context "when an empty file is used" do
let(:params) do
- { project: project.full_path, file: '/file.yml' }
+ {project: project.full_path, file: "/file.yml"}
end
let(:root_ref_sha) { project.repository.root_ref_sha }
before do
- stub_project_blob(root_ref_sha, '/file.yml') { '' }
+ stub_project_blob(root_ref_sha, "/file.yml") { "" }
end
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
expect(subject.error_message).to include("Project `#{project.full_path}` file `/file.yml` is empty!")
end
end
- context 'when non-existing ref is used' do
+ context "when non-existing ref is used" do
let(:params) do
- { project: project.full_path, ref: 'I-Do-Not-Exist', file: '/file.yml' }
+ {project: project.full_path, ref: "I-Do-Not-Exist", file: "/file.yml"}
end
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
expect(subject.error_message).to include("Project `#{project.full_path}` reference `I-Do-Not-Exist` does not exist!")
end
end
- context 'when non-existing file is requested' do
+ context "when non-existing file is requested" do
let(:params) do
- { project: project.full_path, file: '/invalid-file.yml' }
+ {project: project.full_path, file: "/invalid-file.yml"}
end
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
expect(subject.error_message).to include("Project `#{project.full_path}` file `/invalid-file.yml` does not exist!")
end
end
- context 'when file is not a yaml file' do
+ context "when file is not a yaml file" do
let(:params) do
- { project: project.full_path, file: '/invalid-file' }
+ {project: project.full_path, file: "/invalid-file"}
end
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
- expect(subject.error_message).to include('Included file `/invalid-file` does not have YAML extension!')
+ expect(subject.error_message).to include("Included file `/invalid-file` does not have YAML extension!")
end
end
end
@@ -146,6 +146,6 @@ describe Gitlab::Ci::Config::External::File::Project do
def stub_project_blob(ref, path)
allow_any_instance_of(Repository)
.to receive(:blob_data_at)
- .with(ref, path) { yield }
+ .with(ref, path) { yield }
end
end
diff --git a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
index 3e0fda9c308..a2ad6b0590e 100644
--- a/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/remote_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::File::Remote do
- let(:context) { described_class::Context.new(nil, '12345', nil) }
- let(:params) { { remote: location } }
+ let(:context) { described_class::Context.new(nil, "12345", nil) }
+ let(:params) { {remote: location} }
let(:remote_file) { described_class.new(params, context) }
- let(:location) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ let(:location) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
let(:remote_file_content) do
<<~HEREDOC
before_script:
@@ -17,115 +17,115 @@ describe Gitlab::Ci::Config::External::File::Remote do
HEREDOC
end
- describe '#matching?' do
- context 'when a remote is specified' do
- let(:params) { { remote: 'http://remote' } }
+ describe "#matching?" do
+ context "when a remote is specified" do
+ let(:params) { {remote: "http://remote"} }
- it 'should return true' do
+ it "should return true" do
expect(remote_file).to be_matching
end
end
- context 'with a missing remote' do
- let(:params) { { remote: nil } }
+ context "with a missing remote" do
+ let(:params) { {remote: nil} }
- it 'should return false' do
+ it "should return false" do
expect(remote_file).not_to be_matching
end
end
- context 'with a missing remote key' do
+ context "with a missing remote key" do
let(:params) { {} }
- it 'should return false' do
+ it "should return false" do
expect(remote_file).not_to be_matching
end
end
end
describe "#valid?" do
- context 'when is a valid remote url' do
+ context "when is a valid remote url" do
before do
WebMock.stub_request(:get, location).to_return(body: remote_file_content)
end
- it 'should return true' do
+ it "should return true" do
expect(remote_file.valid?).to be_truthy
end
end
- context 'with an irregular url' do
- let(:location) { 'not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ context "with an irregular url" do
+ let(:location) { "not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
- it 'should return false' do
+ it "should return false" do
expect(remote_file.valid?).to be_falsy
end
end
- context 'with a timeout' do
+ context "with a timeout" do
before do
allow(Gitlab::HTTP).to receive(:get).and_raise(Timeout::Error)
end
- it 'should be falsy' do
+ it "should be falsy" do
expect(remote_file.valid?).to be_falsy
end
end
- context 'when is not a yaml file' do
- let(:location) { 'https://asdasdasdaj48ggerexample.com' }
+ context "when is not a yaml file" do
+ let(:location) { "https://asdasdasdaj48ggerexample.com" }
- it 'should be falsy' do
+ it "should be falsy" do
expect(remote_file.valid?).to be_falsy
end
end
- context 'with an internal url' do
- let(:location) { 'http://localhost:8080' }
+ context "with an internal url" do
+ let(:location) { "http://localhost:8080" }
- it 'should be falsy' do
+ it "should be falsy" do
expect(remote_file.valid?).to be_falsy
end
end
end
describe "#content" do
- context 'with a valid remote file' do
+ context "with a valid remote file" do
before do
WebMock.stub_request(:get, location).to_return(body: remote_file_content)
end
- it 'should return the content of the file' do
+ it "should return the content of the file" do
expect(remote_file.content).to eql(remote_file_content)
end
end
- context 'with a timeout' do
+ context "with a timeout" do
before do
allow(Gitlab::HTTP).to receive(:get).and_raise(Timeout::Error)
end
- it 'should be falsy' do
+ it "should be falsy" do
expect(remote_file.content).to be_falsy
end
end
- context 'with an invalid remote url' do
- let(:location) { 'https://asdasdasdaj48ggerexample.com' }
+ context "with an invalid remote url" do
+ let(:location) { "https://asdasdasdaj48ggerexample.com" }
before do
- WebMock.stub_request(:get, location).to_raise(SocketError.new('Some HTTP error'))
+ WebMock.stub_request(:get, location).to_raise(SocketError.new("Some HTTP error"))
end
- it 'should be nil' do
+ it "should be nil" do
expect(remote_file.content).to be_nil
end
end
- context 'with an internal url' do
- let(:location) { 'http://localhost:8080' }
+ context "with an internal url" do
+ let(:location) { "http://localhost:8080" }
- it 'should be nil' do
+ it "should be nil" do
expect(remote_file.content).to be_nil
end
end
@@ -134,50 +134,50 @@ describe Gitlab::Ci::Config::External::File::Remote do
describe "#error_message" do
subject { remote_file.error_message }
- context 'when remote file location is not valid' do
- let(:location) { 'not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ context "when remote file location is not valid" do
+ let(:location) { "not-valid://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
- it 'returns an error message describing invalid address' do
+ it "returns an error message describing invalid address" do
expect(subject).to match /does not have a valid address!/
end
end
- context 'when timeout error has been raised' do
+ context "when timeout error has been raised" do
before do
WebMock.stub_request(:get, location).to_timeout
end
- it 'should returns error message about a timeout' do
+ it "should returns error message about a timeout" do
expect(subject).to match /could not be fetched because of a timeout error!/
end
end
- context 'when HTTP error has been raised' do
+ context "when HTTP error has been raised" do
before do
WebMock.stub_request(:get, location).to_raise(Gitlab::HTTP::Error)
end
- it 'should returns error message about a HTTP error' do
+ it "should returns error message about a HTTP error" do
expect(subject).to match /could not be fetched because of HTTP error!/
end
end
- context 'when response has 404 status' do
+ context "when response has 404 status" do
before do
WebMock.stub_request(:get, location).to_return(body: remote_file_content, status: 404)
end
- it 'should returns error message about a timeout' do
+ it "should returns error message about a timeout" do
expect(subject).to match /could not be fetched because of HTTP code `404` error!/
end
end
- context 'when the URL is blocked' do
- let(:location) { 'http://127.0.0.1/some/path/to/config.yaml' }
+ context "when the URL is blocked" do
+ let(:location) { "http://127.0.0.1/some/path/to/config.yaml" }
- it 'should include details about blocked URL' do
+ it "should include details about blocked URL" do
expect(subject).to eq "Remote file could not be fetched because URL '#{location}' " \
- 'is blocked: Requests to localhost are not allowed!'
+ "is blocked: Requests to localhost are not allowed!"
end
end
end
diff --git a/spec/lib/gitlab/ci/config/external/file/template_spec.rb b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
index 1fb5655309a..1b43d184b91 100644
--- a/spec/lib/gitlab/ci/config/external/file/template_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/file/template_spec.rb
@@ -1,91 +1,91 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::File::Template do
- let(:context) { described_class::Context.new(nil, '12345') }
- let(:template) { 'Auto-DevOps.gitlab-ci.yml' }
- let(:params) { { template: template } }
+ let(:context) { described_class::Context.new(nil, "12345") }
+ let(:template) { "Auto-DevOps.gitlab-ci.yml" }
+ let(:params) { {template: template} }
subject { described_class.new(params, context) }
- describe '#matching?' do
- context 'when a template is specified' do
- let(:params) { { template: 'some-template' } }
+ describe "#matching?" do
+ context "when a template is specified" do
+ let(:params) { {template: "some-template"} }
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_matching
end
end
- context 'with a missing template' do
- let(:params) { { template: nil } }
+ context "with a missing template" do
+ let(:params) { {template: nil} }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
- context 'with a missing template key' do
+ context "with a missing template key" do
let(:params) { {} }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_matching
end
end
end
describe "#valid?" do
- context 'when is a valid template name' do
- let(:template) { 'Auto-DevOps.gitlab-ci.yml' }
+ context "when is a valid template name" do
+ let(:template) { "Auto-DevOps.gitlab-ci.yml" }
- it 'should return true' do
+ it "should return true" do
expect(subject).to be_valid
end
end
- context 'with invalid template name' do
- let(:template) { 'Template.yml' }
+ context "with invalid template name" do
+ let(:template) { "Template.yml" }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
- expect(subject.error_message).to include('Template file `Template.yml` is not a valid location!')
+ expect(subject.error_message).to include("Template file `Template.yml` is not a valid location!")
end
end
- context 'with a non-existing template' do
- let(:template) { 'I-Do-Not-Have-This-Template.gitlab-ci.yml' }
+ context "with a non-existing template" do
+ let(:template) { "I-Do-Not-Have-This-Template.gitlab-ci.yml" }
- it 'should return false' do
+ it "should return false" do
expect(subject).not_to be_valid
- expect(subject.error_message).to include('Included file `I-Do-Not-Have-This-Template.gitlab-ci.yml` is empty or does not exist!')
+ expect(subject.error_message).to include("Included file `I-Do-Not-Have-This-Template.gitlab-ci.yml` is empty or does not exist!")
end
end
end
- describe '#template_name' do
+ describe "#template_name" do
let(:template_name) { subject.send(:template_name) }
- context 'when template does end with .gitlab-ci.yml' do
- let(:template) { 'my-template.gitlab-ci.yml' }
+ context "when template does end with .gitlab-ci.yml" do
+ let(:template) { "my-template.gitlab-ci.yml" }
- it 'returns template name' do
- expect(template_name).to eq('my-template')
+ it "returns template name" do
+ expect(template_name).to eq("my-template")
end
end
- context 'when template is nil' do
+ context "when template is nil" do
let(:template) { nil }
- it 'returns nil' do
+ it "returns nil" do
expect(template_name).to be_nil
end
end
- context 'when template does not end with .gitlab-ci.yml' do
- let(:template) { 'my-template' }
+ context "when template does not end with .gitlab-ci.yml" do
+ let(:template) { "my-template" }
- it 'returns nil' do
+ it "returns nil" do
expect(template_name).to be_nil
end
end
diff --git a/spec/lib/gitlab/ci/config/external/mapper_spec.rb b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
index 4cab4961b0f..bd284e20ffc 100644
--- a/spec/lib/gitlab/ci/config/external/mapper_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/mapper_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::Mapper do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
- let(:local_file) { '/lib/gitlab/ci/templates/non-existent-file.yml' }
- let(:remote_url) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
- let(:template_file) { 'Auto-DevOps.gitlab-ci.yml' }
+ let(:local_file) { "/lib/gitlab/ci/templates/non-existent-file.yml" }
+ let(:remote_url) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
+ let(:template_file) { "Auto-DevOps.gitlab-ci.yml" }
let(:file_content) do
<<~HEREDOC
- image: 'ruby:2.2'
+ image: 'ruby:2.2'
HEREDOC
end
@@ -20,76 +20,81 @@ describe Gitlab::Ci::Config::External::Mapper do
WebMock.stub_request(:get, remote_url).to_return(body: file_content)
end
- describe '#process' do
- subject { described_class.new(values, project: project, sha: '123456', user: user).process }
+ describe "#process" do
+ subject { described_class.new(values, project: project, sha: "123456", user: user).process }
context "when single 'include' keyword is defined" do
- context 'when the string is a local file' do
+ context "when the string is a local file" do
let(:values) do
- { include: local_file,
- image: 'ruby:2.2' }
+ {include: local_file,
+ image: "ruby:2.2",}
end
- it 'returns File instances' do
+ it "returns File instances" do
expect(subject).to contain_exactly(
- an_instance_of(Gitlab::Ci::Config::External::File::Local))
+ an_instance_of(Gitlab::Ci::Config::External::File::Local)
+ )
end
end
- context 'when the key is a local file hash' do
+ context "when the key is a local file hash" do
let(:values) do
- { include: { 'local' => local_file },
- image: 'ruby:2.2' }
+ {include: {"local" => local_file},
+ image: "ruby:2.2",}
end
- it 'returns File instances' do
+ it "returns File instances" do
expect(subject).to contain_exactly(
- an_instance_of(Gitlab::Ci::Config::External::File::Local))
+ an_instance_of(Gitlab::Ci::Config::External::File::Local)
+ )
end
end
- context 'when the string is a remote file' do
+ context "when the string is a remote file" do
let(:values) do
- { include: remote_url, image: 'ruby:2.2' }
+ {include: remote_url, image: "ruby:2.2"}
end
- it 'returns File instances' do
+ it "returns File instances" do
expect(subject).to contain_exactly(
- an_instance_of(Gitlab::Ci::Config::External::File::Remote))
+ an_instance_of(Gitlab::Ci::Config::External::File::Remote)
+ )
end
end
- context 'when the key is a remote file hash' do
+ context "when the key is a remote file hash" do
let(:values) do
- { include: { 'remote' => remote_url },
- image: 'ruby:2.2' }
+ {include: {"remote" => remote_url},
+ image: "ruby:2.2",}
end
- it 'returns File instances' do
+ it "returns File instances" do
expect(subject).to contain_exactly(
- an_instance_of(Gitlab::Ci::Config::External::File::Remote))
+ an_instance_of(Gitlab::Ci::Config::External::File::Remote)
+ )
end
end
- context 'when the key is a template file hash' do
+ context "when the key is a template file hash" do
let(:values) do
- { include: { 'template' => template_file },
- image: 'ruby:2.2' }
+ {include: {"template" => template_file},
+ image: "ruby:2.2",}
end
- it 'returns File instances' do
+ it "returns File instances" do
expect(subject).to contain_exactly(
- an_instance_of(Gitlab::Ci::Config::External::File::Template))
+ an_instance_of(Gitlab::Ci::Config::External::File::Template)
+ )
end
end
- context 'when the key is a hash of file and remote' do
+ context "when the key is a hash of file and remote" do
let(:values) do
- { include: { 'local' => local_file, 'remote' => remote_url },
- image: 'ruby:2.2' }
+ {include: {"local" => local_file, "remote" => remote_url},
+ image: "ruby:2.2",}
end
- it 'returns ambigious specification error' do
+ it "returns ambigious specification error" do
expect { subject }.to raise_error(described_class::AmbigiousSpecificationError)
end
end
@@ -97,11 +102,11 @@ describe Gitlab::Ci::Config::External::Mapper do
context "when 'include' is defined as an array" do
let(:values) do
- { include: [remote_url, local_file],
- image: 'ruby:2.2' }
+ {include: [remote_url, local_file],
+ image: "ruby:2.2",}
end
- it 'returns Files instances' do
+ it "returns Files instances" do
expect(subject).to all(respond_to(:valid?))
expect(subject).to all(respond_to(:content))
end
@@ -109,22 +114,22 @@ describe Gitlab::Ci::Config::External::Mapper do
context "when 'include' is defined as an array of hashes" do
let(:values) do
- { include: [{ remote: remote_url }, { local: local_file }],
- image: 'ruby:2.2' }
+ {include: [{remote: remote_url}, {local: local_file}],
+ image: "ruby:2.2",}
end
- it 'returns Files instances' do
+ it "returns Files instances" do
expect(subject).to all(respond_to(:valid?))
expect(subject).to all(respond_to(:content))
end
- context 'when it has ambigious match' do
+ context "when it has ambigious match" do
let(:values) do
- { include: [{ remote: remote_url, local: local_file }],
- image: 'ruby:2.2' }
+ {include: [{remote: remote_url, local: local_file}],
+ image: "ruby:2.2",}
end
- it 'returns ambigious specification error' do
+ it "returns ambigious specification error" do
expect { subject }.to raise_error(described_class::AmbigiousSpecificationError)
end
end
@@ -133,11 +138,11 @@ describe Gitlab::Ci::Config::External::Mapper do
context "when 'include' is not defined" do
let(:values) do
{
- image: 'ruby:2.2'
+ image: "ruby:2.2",
}
end
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(subject).to be_empty
end
end
diff --git a/spec/lib/gitlab/ci/config/external/processor_spec.rb b/spec/lib/gitlab/ci/config/external/processor_spec.rb
index 1ac58139b25..bbf4eb2ee73 100644
--- a/spec/lib/gitlab/ci/config/external/processor_spec.rb
+++ b/spec/lib/gitlab/ci/config/external/processor_spec.rb
@@ -1,30 +1,30 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config::External::Processor do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
- let(:processor) { described_class.new(values, project: project, sha: '12345', user: user) }
+ let(:processor) { described_class.new(values, project: project, sha: "12345", user: user) }
before do
project.add_developer(user)
end
describe "#perform" do
- context 'when no external files defined' do
- let(:values) { { image: 'ruby:2.2' } }
+ context "when no external files defined" do
+ let(:values) { {image: "ruby:2.2"} }
- it 'should return the same values' do
+ it "should return the same values" do
expect(processor.perform).to eq(values)
end
end
- context 'when an invalid local file is defined' do
- let(:values) { { include: '/lib/gitlab/ci/templates/non-existent-file.yml', image: 'ruby:2.2' } }
+ context "when an invalid local file is defined" do
+ let(:values) { {include: "/lib/gitlab/ci/templates/non-existent-file.yml", image: "ruby:2.2"} }
- it 'should raise an error' do
+ it "should raise an error" do
expect { processor.perform }.to raise_error(
described_class::IncludeError,
"Local file `/lib/gitlab/ci/templates/non-existent-file.yml` does not exist!"
@@ -32,15 +32,15 @@ describe Gitlab::Ci::Config::External::Processor do
end
end
- context 'when an invalid remote file is defined' do
- let(:remote_file) { 'http://doesntexist.com/.gitlab-ci-1.yml' }
- let(:values) { { include: remote_file, image: 'ruby:2.2' } }
+ context "when an invalid remote file is defined" do
+ let(:remote_file) { "http://doesntexist.com/.gitlab-ci-1.yml" }
+ let(:values) { {include: remote_file, image: "ruby:2.2"} }
before do
- WebMock.stub_request(:get, remote_file).to_raise(SocketError.new('Some HTTP error'))
+ WebMock.stub_request(:get, remote_file).to_raise(SocketError.new("Some HTTP error"))
end
- it 'should raise an error' do
+ it "should raise an error" do
expect { processor.perform }.to raise_error(
described_class::IncludeError,
"Remote file `#{remote_file}` could not be fetched because of a socket error!"
@@ -48,9 +48,9 @@ describe Gitlab::Ci::Config::External::Processor do
end
end
- context 'with a valid remote external file is defined' do
- let(:remote_file) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
- let(:values) { { include: remote_file, image: 'ruby:2.2' } }
+ context "with a valid remote external file is defined" do
+ let(:remote_file) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
+ let(:values) { {include: remote_file, image: "ruby:2.2"} }
let(:external_file_content) do
<<-HEREDOC
before_script:
@@ -73,7 +73,7 @@ describe Gitlab::Ci::Config::External::Processor do
WebMock.stub_request(:get, remote_file).to_return(body: external_file_content)
end
- it 'should append the file to the values' do
+ it "should append the file to the values" do
output = processor.perform
expect(output.keys).to match_array([:image, :before_script, :rspec, :rubocop])
end
@@ -83,8 +83,8 @@ describe Gitlab::Ci::Config::External::Processor do
end
end
- context 'with a valid local external file is defined' do
- let(:values) { { include: '/lib/gitlab/ci/templates/template.yml', image: 'ruby:2.2' } }
+ context "with a valid local external file is defined" do
+ let(:values) { {include: "/lib/gitlab/ci/templates/template.yml", image: "ruby:2.2"} }
let(:local_file_content) do
<<-HEREDOC
before_script:
@@ -100,7 +100,7 @@ describe Gitlab::Ci::Config::External::Processor do
.to receive(:fetch_local_content).and_return(local_file_content)
end
- it 'should append the file to the values' do
+ it "should append the file to the values" do
output = processor.perform
expect(output.keys).to match_array([:image, :before_script])
end
@@ -110,18 +110,18 @@ describe Gitlab::Ci::Config::External::Processor do
end
end
- context 'with multiple external files are defined' do
- let(:remote_file) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ context "with multiple external files are defined" do
+ let(:remote_file) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
let(:external_files) do
[
- '/spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml',
- remote_file
+ "/spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml",
+ remote_file,
]
end
let(:values) do
{
include: external_files,
- image: 'ruby:2.2'
+ image: "ruby:2.2",
}
end
@@ -135,7 +135,7 @@ describe Gitlab::Ci::Config::External::Processor do
end
before do
- local_file_content = File.read(Rails.root.join('spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml'))
+ local_file_content = File.read(Rails.root.join("spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml"))
allow_any_instance_of(Gitlab::Ci::Config::External::File::Local)
.to receive(:fetch_local_content).and_return(local_file_content)
@@ -143,7 +143,7 @@ describe Gitlab::Ci::Config::External::Processor do
WebMock.stub_request(:get, remote_file).to_return(body: remote_file_content)
end
- it 'should append the files to the values' do
+ it "should append the files to the values" do
expect(processor.perform.keys).to match_array([:image, :stages, :before_script, :rspec])
end
@@ -152,17 +152,17 @@ describe Gitlab::Ci::Config::External::Processor do
end
end
- context 'when external files are defined but not valid' do
- let(:values) { { include: '/lib/gitlab/ci/templates/template.yml', image: 'ruby:2.2' } }
+ context "when external files are defined but not valid" do
+ let(:values) { {include: "/lib/gitlab/ci/templates/template.yml", image: "ruby:2.2"} }
- let(:local_file_content) { 'invalid content file ////' }
+ let(:local_file_content) { "invalid content file ////" }
before do
allow_any_instance_of(Gitlab::Ci::Config::External::File::Local)
.to receive(:fetch_local_content).and_return(local_file_content)
end
- it 'should raise an error' do
+ it "should raise an error" do
expect { processor.perform }.to raise_error(
described_class::IncludeError,
"Included file `/lib/gitlab/ci/templates/template.yml` does not have valid YAML syntax!"
@@ -171,23 +171,23 @@ describe Gitlab::Ci::Config::External::Processor do
end
context "when both external files and values defined the same key" do
- let(:remote_file) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
+ let(:remote_file) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
let(:values) do
{
include: remote_file,
- image: 'ruby:2.2'
+ image: "ruby:2.2",
}
end
let(:remote_file_content) do
<<~HEREDOC
- image: php:5-fpm-alpine
+ image: php:5-fpm-alpine
HEREDOC
end
- it 'should take precedence' do
+ it "should take precedence" do
WebMock.stub_request(:get, remote_file).to_return(body: remote_file_content)
- expect(processor.perform[:image]).to eq('ruby:2.2')
+ expect(processor.perform[:image]).to eq("ruby:2.2")
end
end
end
diff --git a/spec/lib/gitlab/ci/config/normalizer_spec.rb b/spec/lib/gitlab/ci/config/normalizer_spec.rb
index cd880177170..566fee6c932 100644
--- a/spec/lib/gitlab/ci/config/normalizer_spec.rb
+++ b/spec/lib/gitlab/ci/config/normalizer_spec.rb
@@ -1,85 +1,85 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Config::Normalizer do
let(:job_name) { :rspec }
- let(:job_config) { { script: 'rspec', parallel: 5, name: 'rspec' } }
- let(:config) { { job_name => job_config } }
+ let(:job_config) { {script: "rspec", parallel: 5, name: "rspec"} }
+ let(:config) { {job_name => job_config} }
- describe '.normalize_jobs' do
+ describe ".normalize_jobs" do
subject { described_class.new(config).normalize_jobs }
- it 'does not have original job' do
+ it "does not have original job" do
is_expected.not_to include(job_name)
end
- it 'has parallelized jobs' do
+ it "has parallelized jobs" do
job_names = [:"rspec 1/5", :"rspec 2/5", :"rspec 3/5", :"rspec 4/5", :"rspec 5/5"]
is_expected.to include(*job_names)
end
- it 'sets job instance in options' do
+ it "sets job instance in options" do
expect(subject.values).to all(include(:instance))
end
- it 'parallelizes jobs with original config' do
+ it "parallelizes jobs with original config" do
original_config = config[job_name].except(:name)
configs = subject.values.map { |config| config.except(:name, :instance) }
expect(configs).to all(eq(original_config))
end
- context 'when the job is not parallelized' do
- let(:job_config) { { script: 'rspec', name: 'rspec' } }
+ context "when the job is not parallelized" do
+ let(:job_config) { {script: "rspec", name: "rspec"} }
- it 'returns the same hash' do
+ it "returns the same hash" do
is_expected.to eq(config)
end
end
- context 'when there is a job with a slash in it' do
+ context "when there is a job with a slash in it" do
let(:job_name) { :"rspec 35/2" }
- it 'properly parallelizes job names' do
+ it "properly parallelizes job names" do
job_names = [:"rspec 35/2 1/5", :"rspec 35/2 2/5", :"rspec 35/2 3/5", :"rspec 35/2 4/5", :"rspec 35/2 5/5"]
is_expected.to include(*job_names)
end
end
- context 'when jobs depend on parallelized jobs' do
- let(:config) { { job_name => job_config, other_job: { script: 'echo 1', dependencies: [job_name.to_s] } } }
+ context "when jobs depend on parallelized jobs" do
+ let(:config) { {job_name => job_config, :other_job => {script: "echo 1", dependencies: [job_name.to_s]}} }
- it 'parallelizes dependencies' do
+ it "parallelizes dependencies" do
job_names = ["rspec 1/5", "rspec 2/5", "rspec 3/5", "rspec 4/5", "rspec 5/5"]
expect(subject[:other_job][:dependencies]).to include(*job_names)
end
- it 'does not include original job name in dependencies' do
+ it "does not include original job name in dependencies" do
expect(subject[:other_job][:dependencies]).not_to include(job_name)
end
end
- context 'when there are dependencies which are both parallelized and not' do
+ context "when there are dependencies which are both parallelized and not" do
let(:config) do
{
job_name => job_config,
- other_job: { script: 'echo 1' },
- final_job: { script: 'echo 1', dependencies: [job_name.to_s, "other_job"] }
+ :other_job => {script: "echo 1"},
+ :final_job => {script: "echo 1", dependencies: [job_name.to_s, "other_job"]},
}
end
- it 'parallelizes dependencies' do
+ it "parallelizes dependencies" do
job_names = ["rspec 1/5", "rspec 2/5", "rspec 3/5", "rspec 4/5", "rspec 5/5"]
expect(subject[:final_job][:dependencies]).to include(*job_names)
end
- it 'includes the regular job in dependencies' do
- expect(subject[:final_job][:dependencies]).to include('other_job')
+ it "includes the regular job in dependencies" do
+ expect(subject[:final_job][:dependencies]).to include("other_job")
end
end
end
diff --git a/spec/lib/gitlab/ci/config_spec.rb b/spec/lib/gitlab/ci/config_spec.rb
index 18f255c1ab7..9a47c4367ab 100644
--- a/spec/lib/gitlab/ci/config_spec.rb
+++ b/spec/lib/gitlab/ci/config_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Config do
set(:user) { create(:user) }
@@ -7,7 +7,7 @@ describe Gitlab::Ci::Config do
described_class.new(yml, project: nil, sha: nil, user: nil)
end
- context 'when config is valid' do
+ context "when config is valid" do
let(:yml) do
<<-EOS
image: ruby:2.2
@@ -19,32 +19,32 @@ describe Gitlab::Ci::Config do
EOS
end
- describe '#to_hash' do
- it 'returns hash created from string' do
+ describe "#to_hash" do
+ it "returns hash created from string" do
hash = {
- image: 'ruby:2.2',
+ image: "ruby:2.2",
rspec: {
- script: ['gem install rspec',
- 'rspec']
- }
+ script: ["gem install rspec",
+ "rspec",],
+ },
}
expect(config.to_hash).to eq hash
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(config).to be_valid
end
- it 'has no errors' do
+ it "has no errors" do
expect(config.errors).to be_empty
end
end
end
end
- context 'when using extendable hash' do
+ context "when using extendable hash" do
let(:yml) do
<<-EOS
image: ruby:2.2
@@ -58,15 +58,15 @@ describe Gitlab::Ci::Config do
EOS
end
- it 'correctly extends the hash' do
+ it "correctly extends the hash" do
hash = {
- image: 'ruby:2.2',
- rspec: { script: 'rspec' },
+ image: "ruby:2.2",
+ rspec: {script: "rspec"},
test: {
- extends: 'rspec',
- image: 'ruby:alpine',
- script: 'rspec'
- }
+ extends: "rspec",
+ image: "ruby:alpine",
+ script: "rspec",
+ },
}
expect(config).to be_valid
@@ -74,12 +74,12 @@ describe Gitlab::Ci::Config do
end
end
- context 'when config is invalid' do
- context 'when yml is incorrect' do
- let(:yml) { '// invalid' }
+ context "when config is invalid" do
+ context "when yml is incorrect" do
+ let(:yml) { "// invalid" }
- describe '.new' do
- it 'raises error' do
+ describe ".new" do
+ it "raises error" do
expect { config }.to raise_error(
described_class::ConfigError,
/Invalid configuration format/
@@ -88,27 +88,27 @@ describe Gitlab::Ci::Config do
end
end
- context 'when config logic is incorrect' do
+ context "when config logic is incorrect" do
let(:yml) { 'before_script: "ls"' }
- describe '#valid?' do
- it 'is not valid' do
+ describe "#valid?" do
+ it "is not valid" do
expect(config).not_to be_valid
end
- it 'has errors' do
+ it "has errors" do
expect(config.errors).not_to be_empty
end
end
- describe '#errors' do
- it 'returns an array of strings' do
+ describe "#errors" do
+ it "returns an array of strings" do
expect(config.errors).to all(be_an_instance_of(String))
end
end
end
- context 'when invalid extended hash has been provided' do
+ context "when invalid extended hash has been provided" do
let(:yml) do
<<-EOS
test:
@@ -117,7 +117,7 @@ describe Gitlab::Ci::Config do
EOS
end
- it 'raises an error' do
+ it "raises an error" do
expect { config }.to raise_error(
described_class::ConfigError, /circular dependency detected/
)
@@ -127,17 +127,17 @@ describe Gitlab::Ci::Config do
context "when using 'include' directive" do
let(:project) { create(:project, :repository) }
- let(:remote_location) { 'https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml' }
- let(:local_location) { 'spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml' }
+ let(:remote_location) { "https://gitlab.com/gitlab-org/gitlab-ce/blob/1234/.gitlab-ci-1.yml" }
+ let(:local_location) { "spec/fixtures/gitlab/ci/external_files/.gitlab-ci-template-1.yml" }
let(:remote_file_content) do
<<~HEREDOC
- variables:
- AUTO_DEVOPS_DOMAIN: domain.example.com
- POSTGRES_USER: user
- POSTGRES_PASSWORD: testing-password
- POSTGRES_ENABLED: "true"
- POSTGRES_DB: $CI_ENVIRONMENT_SLUG
+ variables:
+ AUTO_DEVOPS_DOMAIN: domain.example.com
+ POSTGRES_USER: user
+ POSTGRES_PASSWORD: testing-password
+ POSTGRES_ENABLED: "true"
+ POSTGRES_DB: $CI_ENVIRONMENT_SLUG
HEREDOC
end
@@ -147,16 +147,15 @@ describe Gitlab::Ci::Config do
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{local_location}
- - #{remote_location}
-
- image: ruby:2.2
+ include:
+ - #{local_location}
+ - #{remote_location}
+ image: ruby:2.2
HEREDOC
end
let(:config) do
- described_class.new(gitlab_ci_yml, project: project, sha: '12345', user: user)
+ described_class.new(gitlab_ci_yml, project: project, sha: "12345", user: user)
end
before do
@@ -168,24 +167,24 @@ describe Gitlab::Ci::Config do
end
context "when gitlab_ci_yml has valid 'include' defined" do
- it 'should return a composed hash' do
+ it "should return a composed hash" do
before_script_values = [
"apt-get update -qq && apt-get install -y -qq sqlite3 libsqlite3-dev nodejs", "ruby -v",
"which ruby",
- "bundle install --jobs $(nproc) \"${FLAGS[@]}\""
+ "bundle install --jobs $(nproc) \"${FLAGS[@]}\"",
]
variables = {
AUTO_DEVOPS_DOMAIN: "domain.example.com",
POSTGRES_USER: "user",
POSTGRES_PASSWORD: "testing-password",
POSTGRES_ENABLED: "true",
- POSTGRES_DB: "$CI_ENVIRONMENT_SLUG"
+ POSTGRES_DB: "$CI_ENVIRONMENT_SLUG",
}
composed_hash = {
before_script: before_script_values,
image: "ruby:2.2",
- rspec: { script: ["bundle exec rspec"] },
- variables: variables
+ rspec: {script: ["bundle exec rspec"]},
+ variables: variables,
}
expect(config.to_hash).to eq(composed_hash)
@@ -199,7 +198,7 @@ describe Gitlab::Ci::Config do
HEREDOC
end
- it 'raises error YamlProcessor validationError' do
+ it "raises error YamlProcessor validationError" do
expect { config }.to raise_error(
described_class::ConfigError,
"Included file `invalid` does not have YAML extension!"
@@ -216,7 +215,7 @@ describe Gitlab::Ci::Config do
HEREDOC
end
- it 'raises error YamlProcessor validationError' do
+ it "raises error YamlProcessor validationError" do
expect { config }.to raise_error(
described_class::ConfigError,
'Include `{"remote":"http://url","local":"/local/file.yml"}` needs to match exactly one accessor!'
@@ -224,18 +223,18 @@ describe Gitlab::Ci::Config do
end
end
- describe 'external file version' do
- context 'when external local file SHA is defined' do
- it 'is using a defined value' do
+ describe "external file version" do
+ context "when external local file SHA is defined" do
+ it "is using a defined value" do
expect(project.repository).to receive(:blob_data_at)
- .with('eeff1122', local_location)
+ .with("eeff1122", local_location)
- described_class.new(gitlab_ci_yml, project: project, sha: 'eeff1122', user: user)
+ described_class.new(gitlab_ci_yml, project: project, sha: "eeff1122", user: user)
end
end
- context 'when external local file SHA is not defined' do
- it 'is using latest SHA on the default branch' do
+ context "when external local file SHA is not defined" do
+ it "is using latest SHA on the default branch" do
expect(project.repository).to receive(:root_ref_sha)
described_class.new(gitlab_ci_yml, project: project, sha: nil, user: user)
@@ -246,128 +245,123 @@ describe Gitlab::Ci::Config do
context "when both external files and gitlab_ci.yml defined the same key" do
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{remote_location}
-
- image: ruby:2.2
+ include:
+ - #{remote_location}
+ image: ruby:2.2
HEREDOC
end
let(:remote_file_content) do
<<~HEREDOC
- image: php:5-fpm-alpine
+ image: php:5-fpm-alpine
HEREDOC
end
- it 'should take precedence' do
- expect(config.to_hash).to eq({ image: 'ruby:2.2' })
+ it "should take precedence" do
+ expect(config.to_hash).to eq({image: "ruby:2.2"})
end
end
context "when both external files and gitlab_ci.yml define a dictionary of distinct variables" do
let(:remote_file_content) do
<<~HEREDOC
- variables:
- A: 'alpha'
- B: 'beta'
+ variables:
+ A: 'alpha'
+ B: 'beta'
HEREDOC
end
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{remote_location}
-
- variables:
- C: 'gamma'
- D: 'delta'
+ include:
+ - #{remote_location}
+ variables:
+ C: 'gamma'
+ D: 'delta'
HEREDOC
end
- it 'should merge the variables dictionaries' do
- expect(config.to_hash).to eq({ variables: { A: 'alpha', B: 'beta', C: 'gamma', D: 'delta' } })
+ it "should merge the variables dictionaries" do
+ expect(config.to_hash).to eq({variables: {A: "alpha", B: "beta", C: "gamma", D: "delta"}})
end
end
context "when both external files and gitlab_ci.yml define a dictionary of overlapping variables" do
let(:remote_file_content) do
<<~HEREDOC
- variables:
- A: 'alpha'
- B: 'beta'
- C: 'omnicron'
+ variables:
+ A: 'alpha'
+ B: 'beta'
+ C: 'omnicron'
HEREDOC
end
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{remote_location}
-
- variables:
- C: 'gamma'
- D: 'delta'
+ include:
+ - #{remote_location}
+ variables:
+ C: 'gamma'
+ D: 'delta'
HEREDOC
end
- it 'later declarations should take precedence' do
- expect(config.to_hash).to eq({ variables: { A: 'alpha', B: 'beta', C: 'gamma', D: 'delta' } })
+ it "later declarations should take precedence" do
+ expect(config.to_hash).to eq({variables: {A: "alpha", B: "beta", C: "gamma", D: "delta"}})
end
end
- context 'when both external files and gitlab_ci.yml define a job' do
+ context "when both external files and gitlab_ci.yml define a job" do
let(:remote_file_content) do
<<~HEREDOC
- job1:
- script:
- - echo 'hello from remote file'
+ job1:
+ script:
+ - echo 'hello from remote file'
HEREDOC
end
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{remote_location}
-
- job1:
- variables:
- VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
+ include:
+ - #{remote_location}
+ job1:
+ variables:
+ VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
HEREDOC
end
- it 'merges the jobs' do
+ it "merges the jobs" do
expect(config.to_hash).to eq({
job1: {
script: ["echo 'hello from remote file'"],
variables: {
- VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
- }
- }
+ VARIABLE_DEFINED_IN_MAIN_FILE: "some value",
+ },
+ },
})
end
- context 'when the script key is in both' do
+ context "when the script key is in both" do
let(:gitlab_ci_yml) do
<<~HEREDOC
- include:
- - #{remote_location}
-
- job1:
- script:
- - echo 'hello from main file'
- variables:
- VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
+ include:
+ - #{remote_location}
+ job1:
+ script:
+ - echo 'hello from main file'
+ variables:
+ VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
HEREDOC
end
- it 'uses the script from the gitlab_ci.yml' do
+ it "uses the script from the gitlab_ci.yml" do
expect(config.to_hash).to eq({
job1: {
script: ["echo 'hello from main file'"],
variables: {
- VARIABLE_DEFINED_IN_MAIN_FILE: 'some value'
- }
- }
+ VARIABLE_DEFINED_IN_MAIN_FILE: "some value",
+ },
+ },
})
end
end
diff --git a/spec/lib/gitlab/ci/cron_parser_spec.rb b/spec/lib/gitlab/ci/cron_parser_spec.rb
index 2a3f7807fdb..f08d3de130e 100644
--- a/spec/lib/gitlab/ci/cron_parser_spec.rb
+++ b/spec/lib/gitlab/ci/cron_parser_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::CronParser do
shared_examples_for "returns time in the future" do
it { is_expected.to be > Time.now }
end
- describe '#next_time_from' do
+ describe "#next_time_from" do
subject { described_class.new(cron, cron_timezone).next_time_from(Time.now) }
- context 'when cron and cron_timezone are valid' do
- context 'when specific time' do
- let(:cron) { '3 4 5 6 *' }
- let(:cron_timezone) { 'UTC' }
+ context "when cron and cron_timezone are valid" do
+ context "when specific time" do
+ let(:cron) { "3 4 5 6 *" }
+ let(:cron_timezone) { "UTC" }
it_behaves_like "returns time in the future"
- it 'returns exact time' do
+ it "returns exact time" do
expect(subject.min).to eq(3)
expect(subject.hour).to eq(4)
expect(subject.day).to eq(5)
@@ -23,24 +23,24 @@ describe Gitlab::Ci::CronParser do
end
end
- context 'when specific day of week' do
- let(:cron) { '* * * * 0' }
- let(:cron_timezone) { 'UTC' }
+ context "when specific day of week" do
+ let(:cron) { "* * * * 0" }
+ let(:cron_timezone) { "UTC" }
it_behaves_like "returns time in the future"
- it 'returns exact day of week' do
+ it "returns exact day of week" do
expect(subject.wday).to eq(0)
end
end
- context 'when slash used' do
- let(:cron) { '*/10 */6 */10 */10 *' }
- let(:cron_timezone) { 'UTC' }
+ context "when slash used" do
+ let(:cron) { "*/10 */6 */10 */10 *" }
+ let(:cron_timezone) { "UTC" }
it_behaves_like "returns time in the future"
- it 'returns specific time' do
+ it "returns specific time" do
expect(subject.min).to be_in([0, 10, 20, 30, 40, 50])
expect(subject.hour).to be_in([0, 6, 12, 18])
expect(subject.day).to be_in([1, 11, 21, 31])
@@ -48,45 +48,45 @@ describe Gitlab::Ci::CronParser do
end
end
- context 'when range used' do
- let(:cron) { '0,20,40 * 1-5 * *' }
- let(:cron_timezone) { 'UTC' }
+ context "when range used" do
+ let(:cron) { "0,20,40 * 1-5 * *" }
+ let(:cron_timezone) { "UTC" }
it_behaves_like "returns time in the future"
- it 'returns specific time' do
+ it "returns specific time" do
expect(subject.min).to be_in([0, 20, 40])
expect(subject.day).to be_in((1..5).to_a)
end
end
- context 'when cron_timezone is TZInfo format' do
+ context "when cron_timezone is TZInfo format" do
before do
allow(Time).to receive(:zone)
- .and_return(ActiveSupport::TimeZone['UTC'])
+ .and_return(ActiveSupport::TimeZone["UTC"])
end
let(:hour_in_utc) do
ActiveSupport::TimeZone[cron_timezone]
- .now.change(hour: 0).in_time_zone('UTC').hour
+ .now.change(hour: 0).in_time_zone("UTC").hour
end
- context 'when cron_timezone is US/Pacific' do
- let(:cron) { '* 0 * * *' }
- let(:cron_timezone) { 'US/Pacific' }
+ context "when cron_timezone is US/Pacific" do
+ let(:cron) { "* 0 * * *" }
+ let(:cron_timezone) { "US/Pacific" }
it_behaves_like "returns time in the future"
- context 'when PST (Pacific Standard Time)' do
- it 'converts time in server time zone' do
+ context "when PST (Pacific Standard Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 1, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
end
end
- context 'when PDT (Pacific Daylight Time)' do
- it 'converts time in server time zone' do
+ context "when PDT (Pacific Daylight Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 6, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
@@ -95,33 +95,33 @@ describe Gitlab::Ci::CronParser do
end
end
- context 'when cron_timezone is ActiveSupport::TimeZone format' do
+ context "when cron_timezone is ActiveSupport::TimeZone format" do
before do
allow(Time).to receive(:zone)
- .and_return(ActiveSupport::TimeZone['UTC'])
+ .and_return(ActiveSupport::TimeZone["UTC"])
end
let(:hour_in_utc) do
ActiveSupport::TimeZone[cron_timezone]
- .now.change(hour: 0).in_time_zone('UTC').hour
+ .now.change(hour: 0).in_time_zone("UTC").hour
end
- context 'when cron_timezone is Berlin' do
- let(:cron) { '* 0 * * *' }
- let(:cron_timezone) { 'Berlin' }
+ context "when cron_timezone is Berlin" do
+ let(:cron) { "* 0 * * *" }
+ let(:cron_timezone) { "Berlin" }
it_behaves_like "returns time in the future"
- context 'when CET (Central European Time)' do
- it 'converts time in server time zone' do
+ context "when CET (Central European Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 1, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
end
end
- context 'when CEST (Central European Summer Time)' do
- it 'converts time in server time zone' do
+ context "when CEST (Central European Summer Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 6, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
@@ -129,22 +129,22 @@ describe Gitlab::Ci::CronParser do
end
end
- context 'when cron_timezone is Eastern Time (US & Canada)' do
- let(:cron) { '* 0 * * *' }
- let(:cron_timezone) { 'Eastern Time (US & Canada)' }
+ context "when cron_timezone is Eastern Time (US & Canada)" do
+ let(:cron) { "* 0 * * *" }
+ let(:cron_timezone) { "Eastern Time (US & Canada)" }
it_behaves_like "returns time in the future"
- context 'when EST (Eastern Standard Time)' do
- it 'converts time in server time zone' do
+ context "when EST (Eastern Standard Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 1, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
end
end
- context 'when EDT (Eastern Daylight Time)' do
- it 'converts time in server time zone' do
+ context "when EDT (Eastern Daylight Time)" do
+ it "converts time in server time zone" do
Timecop.freeze(Time.utc(2017, 6, 1)) do
expect(subject.hour).to eq(hour_in_utc)
end
@@ -154,67 +154,67 @@ describe Gitlab::Ci::CronParser do
end
end
- context 'when cron and cron_timezone are invalid' do
- let(:cron) { 'invalid_cron' }
- let(:cron_timezone) { 'invalid_cron_timezone' }
+ context "when cron and cron_timezone are invalid" do
+ let(:cron) { "invalid_cron" }
+ let(:cron_timezone) { "invalid_cron_timezone" }
it { is_expected.to be_nil }
end
- context 'when cron syntax is quoted' do
+ context "when cron syntax is quoted" do
let(:cron) { "'0 * * * *'" }
- let(:cron_timezone) { 'UTC' }
+ let(:cron_timezone) { "UTC" }
it { expect(subject).to be_nil }
end
- context 'when cron syntax is rufus-scheduler syntax' do
- let(:cron) { 'every 3h' }
- let(:cron_timezone) { 'UTC' }
+ context "when cron syntax is rufus-scheduler syntax" do
+ let(:cron) { "every 3h" }
+ let(:cron_timezone) { "UTC" }
it { expect(subject).to be_nil }
end
end
- describe '#cron_valid?' do
+ describe "#cron_valid?" do
subject { described_class.new(cron, Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_TIME_ZONE).cron_valid? }
- context 'when cron is valid' do
- let(:cron) { '* * * * *' }
+ context "when cron is valid" do
+ let(:cron) { "* * * * *" }
it { is_expected.to eq(true) }
end
- context 'when cron is invalid' do
- let(:cron) { '*********' }
+ context "when cron is invalid" do
+ let(:cron) { "*********" }
it { is_expected.to eq(false) }
end
- context 'when cron syntax is quoted' do
+ context "when cron syntax is quoted" do
let(:cron) { "'0 * * * *'" }
it { is_expected.to eq(false) }
end
end
- describe '#cron_timezone_valid?' do
+ describe "#cron_timezone_valid?" do
subject { described_class.new(Gitlab::Ci::CronParser::VALID_SYNTAX_SAMPLE_CRON, cron_timezone).cron_timezone_valid? }
- context 'when cron is valid' do
- let(:cron_timezone) { 'Europe/Istanbul' }
+ context "when cron is valid" do
+ let(:cron_timezone) { "Europe/Istanbul" }
it { is_expected.to eq(true) }
end
- context 'when cron is invalid' do
- let(:cron_timezone) { 'Invalid-zone' }
+ context "when cron is invalid" do
+ let(:cron_timezone) { "Invalid-zone" }
it { is_expected.to eq(false) }
end
- context 'when cron_timezone is ActiveSupport::TimeZone format' do
- let(:cron_timezone) { 'Eastern Time (US & Canada)' }
+ context "when cron_timezone is ActiveSupport::TimeZone format" do
+ let(:cron_timezone) { "Eastern Time (US & Canada)" }
it { is_expected.to eq(true) }
end
diff --git a/spec/lib/gitlab/ci/mask_secret_spec.rb b/spec/lib/gitlab/ci/mask_secret_spec.rb
index 3789a142248..90074fac601 100644
--- a/spec/lib/gitlab/ci/mask_secret_spec.rb
+++ b/spec/lib/gitlab/ci/mask_secret_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::MaskSecret do
subject { described_class }
- describe '#mask' do
- it 'masks exact number of characters' do
- expect(mask('token', 'oke')).to eq('txxxn')
+ describe "#mask" do
+ it "masks exact number of characters" do
+ expect(mask("token", "oke")).to eq("txxxn")
end
- it 'masks multiple occurrences' do
- expect(mask('token token token', 'oke')).to eq('txxxn txxxn txxxn')
+ it "masks multiple occurrences" do
+ expect(mask("token token token", "oke")).to eq("txxxn txxxn txxxn")
end
- it 'does not mask if not found' do
- expect(mask('token', 'not')).to eq('token')
+ it "does not mask if not found" do
+ expect(mask("token", "not")).to eq("token")
end
- it 'does support null token' do
- expect(mask('token', nil)).to eq('token')
+ it "does support null token" do
+ expect(mask("token", nil)).to eq("token")
end
def mask(value, token)
diff --git a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
index a49402c7398..a2c7af46675 100644
--- a/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
+++ b/spec/lib/gitlab/ci/parsers/test/junit_spec.rb
@@ -1,42 +1,42 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Parsers::Test::Junit do
- describe '#parse!' do
+ describe "#parse!" do
subject { described_class.new.parse!(junit, test_suite) }
- let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new('rspec') }
+ let(:test_suite) { Gitlab::Ci::Reports::TestSuite.new("rspec") }
let(:test_cases) { flattened_test_cases(test_suite) }
- context 'when data is JUnit style XML' do
- context 'when there are no <testcases> in <testsuite>' do
+ context "when data is JUnit style XML" do
+ context "when there are no <testcases> in <testsuite>" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuite></testsuite>
EOF
end
- it 'ignores the case' do
+ it "ignores the case" do
expect { subject }.not_to raise_error
expect(test_cases.count).to eq(0)
end
end
- context 'when there are no <testcases> in <testsuites>' do
+ context "when there are no <testcases> in <testsuites>" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuites><testsuite /></testsuites>
EOF
end
- it 'ignores the case' do
+ it "ignores the case" do
expect { subject }.not_to raise_error
expect(test_cases.count).to eq(0)
end
end
- context 'when there is only one <testcase> in <testsuite>' do
+ context "when there is only one <testcase> in <testsuite>" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuite>
@@ -45,16 +45,16 @@ describe Gitlab::Ci::Parsers::Test::Junit do
EOF
end
- it 'parses XML and adds a test case to a suite' do
+ it "parses XML and adds a test case to a suite" do
expect { subject }.not_to raise_error
- expect(test_cases[0].classname).to eq('Calculator')
- expect(test_cases[0].name).to eq('sumTest1')
+ expect(test_cases[0].classname).to eq("Calculator")
+ expect(test_cases[0].name).to eq("sumTest1")
expect(test_cases[0].execution_time).to eq(0.01)
end
end
- context 'when there is only one <testsuite> in <testsuites>' do
+ context "when there is only one <testsuite> in <testsuites>" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuites>
@@ -65,16 +65,16 @@ describe Gitlab::Ci::Parsers::Test::Junit do
EOF
end
- it 'parses XML and adds a test case to a suite' do
+ it "parses XML and adds a test case to a suite" do
expect { subject }.not_to raise_error
- expect(test_cases[0].classname).to eq('Calculator')
- expect(test_cases[0].name).to eq('sumTest1')
+ expect(test_cases[0].classname).to eq("Calculator")
+ expect(test_cases[0].name).to eq("sumTest1")
expect(test_cases[0].execution_time).to eq(0.01)
end
end
- context 'PHPUnit' do
+ context "PHPUnit" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuites>
@@ -87,14 +87,14 @@ describe Gitlab::Ci::Parsers::Test::Junit do
EOF
end
- it 'parses XML and adds a test case to a suite' do
+ it "parses XML and adds a test case to a suite" do
expect { subject }.not_to raise_error
expect(test_cases.count).to eq(1)
end
end
- context 'when there are two test cases' do
+ context "when there are two test cases" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuite>
@@ -104,19 +104,19 @@ describe Gitlab::Ci::Parsers::Test::Junit do
EOF
end
- it 'parses XML and adds test cases to a suite' do
+ it "parses XML and adds test cases to a suite" do
expect { subject }.not_to raise_error
- expect(test_cases[0].classname).to eq('Calculator')
- expect(test_cases[0].name).to eq('sumTest1')
+ expect(test_cases[0].classname).to eq("Calculator")
+ expect(test_cases[0].name).to eq("sumTest1")
expect(test_cases[0].execution_time).to eq(0.01)
- expect(test_cases[1].classname).to eq('Calculator')
- expect(test_cases[1].name).to eq('sumTest2')
+ expect(test_cases[1].classname).to eq("Calculator")
+ expect(test_cases[1].name).to eq("sumTest2")
expect(test_cases[1].execution_time).to eq(0.02)
end
end
- context 'when there are two test suites' do
+ context "when there are two test suites" do
let(:junit) do
<<-EOF.strip_heredoc
<testsuites>
@@ -132,29 +132,29 @@ describe Gitlab::Ci::Parsers::Test::Junit do
EOF
end
- it 'parses XML and adds test cases to a suite' do
+ it "parses XML and adds test cases to a suite" do
expect { subject }.not_to raise_error
- expect(test_cases[0].classname).to eq('Calculator')
- expect(test_cases[0].name).to eq('sumTest1')
+ expect(test_cases[0].classname).to eq("Calculator")
+ expect(test_cases[0].name).to eq("sumTest1")
expect(test_cases[0].execution_time).to eq(0.01)
- expect(test_cases[1].classname).to eq('Calculator')
- expect(test_cases[1].name).to eq('sumTest2')
+ expect(test_cases[1].classname).to eq("Calculator")
+ expect(test_cases[1].name).to eq("sumTest2")
expect(test_cases[1].execution_time).to eq(0.02)
- expect(test_cases[2].classname).to eq('Statemachine')
- expect(test_cases[2].name).to eq('happy path')
+ expect(test_cases[2].classname).to eq("Statemachine")
+ expect(test_cases[2].name).to eq("happy path")
expect(test_cases[2].execution_time).to eq(100)
- expect(test_cases[3].classname).to eq('Statemachine')
- expect(test_cases[3].name).to eq('unhappy path')
+ expect(test_cases[3].classname).to eq("Statemachine")
+ expect(test_cases[3].name).to eq("unhappy path")
expect(test_cases[3].execution_time).to eq(200)
end
end
end
- context 'when data is not JUnit style XML' do
- let(:junit) { { testsuite: 'abc' }.to_json }
+ context "when data is not JUnit style XML" do
+ let(:junit) { {testsuite: "abc"}.to_json }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(described_class::JunitParserError)
end
end
@@ -162,11 +162,11 @@ describe Gitlab::Ci::Parsers::Test::Junit do
private
def flattened_test_cases(test_suite)
- test_suite.test_cases.map do |status, value|
+ test_suite.test_cases.map { |status, value|
value.map do |key, test_case|
test_case
end
- end.flatten
+ }.flatten
end
end
end
diff --git a/spec/lib/gitlab/ci/parsers_spec.rb b/spec/lib/gitlab/ci/parsers_spec.rb
index 4b647bffe59..326677df6f1 100644
--- a/spec/lib/gitlab/ci/parsers_spec.rb
+++ b/spec/lib/gitlab/ci/parsers_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Parsers do
- describe '.fabricate!' do
+ describe ".fabricate!" do
subject { described_class.fabricate!(file_type) }
- context 'when file_type exists' do
- let(:file_type) { 'junit' }
+ context "when file_type exists" do
+ let(:file_type) { "junit" }
- it 'fabricates the class' do
+ it "fabricates the class" do
is_expected.to be_a(described_class::Test::Junit)
end
end
- context 'when file_type does not exist' do
- let(:file_type) { 'undefined' }
+ context "when file_type does not exist" do
+ let(:file_type) { "undefined" }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(Gitlab::Ci::Parsers::ParserNotFoundError)
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
index c9d1d09a938..0e3e1fd9184 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/build_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Build do
set(:project) { create(:project, :repository) }
@@ -6,13 +6,13 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
let(:pipeline) { Ci::Pipeline.new }
let(:variables_attributes) do
- [{ key: 'first', secret_value: 'world' },
- { key: 'second', secret_value: 'second_world' }]
+ [{key: "first", secret_value: "world"},
+ {key: "second", secret_value: "second_world"},]
end
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
source: :push,
- origin_ref: 'master',
+ origin_ref: "master",
checkout_sha: project.commit.id,
after_sha: nil,
before_sha: nil,
@@ -21,7 +21,8 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
merge_request: nil,
project: project,
current_user: user,
- variables_attributes: variables_attributes)
+ variables_attributes: variables_attributes
+ )
end
let(:step) { described_class.new(pipeline, command) }
@@ -30,18 +31,18 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
stub_repository_ci_yaml_file(sha: anything)
end
- it 'never breaks the chain' do
+ it "never breaks the chain" do
step.perform!
expect(step.break?).to be false
end
- it 'fills pipeline object with data' do
+ it "fills pipeline object with data" do
step.perform!
expect(pipeline.sha).not_to be_empty
expect(pipeline.sha).to eq project.commit.id
- expect(pipeline.ref).to eq 'master'
+ expect(pipeline.ref).to eq "master"
expect(pipeline.tag).to be false
expect(pipeline.user).to eq user
expect(pipeline.project).to eq project
@@ -49,29 +50,29 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
.to eq variables_attributes.map(&:with_indifferent_access)
end
- it 'sets a valid config source' do
+ it "sets a valid config source" do
step.perform!
expect(pipeline.repository_source?).to be true
end
- it 'returns a valid pipeline' do
+ it "returns a valid pipeline" do
step.perform!
expect(pipeline).to be_valid
end
- it 'does not persist a pipeline' do
+ it "does not persist a pipeline" do
step.perform!
expect(pipeline).not_to be_persisted
end
- context 'when pipeline is running for a tag' do
+ context "when pipeline is running for a tag" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
source: :push,
- origin_ref: 'mytag',
+ origin_ref: "mytag",
checkout_sha: project.commit.id,
after_sha: nil,
before_sha: nil,
@@ -79,25 +80,26 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
schedule: nil,
merge_request: nil,
project: project,
- current_user: user)
+ current_user: user
+ )
end
before do
- allow_any_instance_of(Repository).to receive(:tag_exists?).with('mytag').and_return(true)
+ allow_any_instance_of(Repository).to receive(:tag_exists?).with("mytag").and_return(true)
step.perform!
end
- it 'correctly indicated that this is a tagged pipeline' do
+ it "correctly indicated that this is a tagged pipeline" do
expect(pipeline).to be_tag
end
end
- context 'when pipeline is running for a merge request' do
+ context "when pipeline is running for a merge request" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
source: :merge_request,
- origin_ref: 'feature',
+ origin_ref: "feature",
checkout_sha: project.commit.id,
after_sha: nil,
before_sha: nil,
@@ -107,7 +109,8 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
schedule: nil,
merge_request: merge_request,
project: project,
- current_user: user)
+ current_user: user
+ )
end
let(:merge_request) { build(:merge_request, target_project: project) }
@@ -116,12 +119,12 @@ describe Gitlab::Ci::Pipeline::Chain::Build do
step.perform!
end
- it 'correctly indicated that this is a merge request pipeline' do
+ it "correctly indicated that this is a merge request pipeline" do
expect(pipeline).to be_merge_request
expect(pipeline.merge_request).to eq(merge_request)
end
- it 'correctly sets souce sha and target sha to pipeline' do
+ it "correctly sets souce sha and target sha to pipeline" do
expect(pipeline.source_sha).to eq(merge_request.diff_head_sha)
expect(pipeline.target_sha).to eq(merge_request.target_branch_sha)
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
index dab0fb51bcc..165c1ae196e 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/command_spec.rb
@@ -1,167 +1,167 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Command do
set(:project) { create(:project, :repository) }
- describe '#initialize' do
+ describe "#initialize" do
subject do
- described_class.new(origin_ref: 'master')
+ described_class.new(origin_ref: "master")
end
- it 'properly initialises object from hash' do
- expect(subject.origin_ref).to eq('master')
+ it "properly initialises object from hash" do
+ expect(subject.origin_ref).to eq("master")
end
end
- context 'handling of origin_ref' do
+ context "handling of origin_ref" do
let(:command) { described_class.new(project: project, origin_ref: origin_ref) }
- describe '#branch_exists?' do
+ describe "#branch_exists?" do
subject { command.branch_exists? }
- context 'for existing branch' do
- let(:origin_ref) { 'master' }
+ context "for existing branch" do
+ let(:origin_ref) { "master" }
it { is_expected.to eq(true) }
end
- context 'for invalid branch' do
- let(:origin_ref) { 'something' }
+ context "for invalid branch" do
+ let(:origin_ref) { "something" }
it { is_expected.to eq(false) }
end
end
- describe '#tag_exists?' do
+ describe "#tag_exists?" do
subject { command.tag_exists? }
- context 'for existing ref' do
- let(:origin_ref) { 'v1.0.0' }
+ context "for existing ref" do
+ let(:origin_ref) { "v1.0.0" }
it { is_expected.to eq(true) }
end
- context 'for invalid ref' do
- let(:origin_ref) { 'something' }
+ context "for invalid ref" do
+ let(:origin_ref) { "something" }
it { is_expected.to eq(false) }
end
end
- describe '#ref' do
+ describe "#ref" do
subject { command.ref }
- context 'for regular ref' do
- let(:origin_ref) { 'master' }
+ context "for regular ref" do
+ let(:origin_ref) { "master" }
- it { is_expected.to eq('master') }
+ it { is_expected.to eq("master") }
end
- context 'for branch ref' do
- let(:origin_ref) { 'refs/heads/master' }
+ context "for branch ref" do
+ let(:origin_ref) { "refs/heads/master" }
- it { is_expected.to eq('master') }
+ it { is_expected.to eq("master") }
end
- context 'for tag ref' do
- let(:origin_ref) { 'refs/tags/1.0.0' }
+ context "for tag ref" do
+ let(:origin_ref) { "refs/tags/1.0.0" }
- it { is_expected.to eq('1.0.0') }
+ it { is_expected.to eq("1.0.0") }
end
- context 'for other refs' do
- let(:origin_ref) { 'refs/merge-requests/11/head' }
+ context "for other refs" do
+ let(:origin_ref) { "refs/merge-requests/11/head" }
- it { is_expected.to eq('refs/merge-requests/11/head') }
+ it { is_expected.to eq("refs/merge-requests/11/head") }
end
end
end
- describe '#sha' do
+ describe "#sha" do
subject { command.sha }
- context 'when invalid checkout_sha is specified' do
- let(:command) { described_class.new(project: project, checkout_sha: 'aaa') }
+ context "when invalid checkout_sha is specified" do
+ let(:command) { described_class.new(project: project, checkout_sha: "aaa") }
- it 'returns empty value' do
+ it "returns empty value" do
is_expected.to be_nil
end
end
- context 'when a valid checkout_sha is specified' do
+ context "when a valid checkout_sha is specified" do
let(:command) { described_class.new(project: project, checkout_sha: project.commit.id) }
- it 'returns checkout_sha' do
+ it "returns checkout_sha" do
is_expected.to eq(project.commit.id)
end
end
- context 'when a valid after_sha is specified' do
+ context "when a valid after_sha is specified" do
let(:command) { described_class.new(project: project, after_sha: project.commit.id) }
- it 'returns after_sha' do
+ it "returns after_sha" do
is_expected.to eq(project.commit.id)
end
end
- context 'when a valid origin_ref is specified' do
- let(:command) { described_class.new(project: project, origin_ref: 'HEAD') }
+ context "when a valid origin_ref is specified" do
+ let(:command) { described_class.new(project: project, origin_ref: "HEAD") }
- it 'returns SHA for given ref' do
+ it "returns SHA for given ref" do
is_expected.to eq(project.commit.id)
end
end
end
- describe '#origin_sha' do
+ describe "#origin_sha" do
subject { command.origin_sha }
- context 'when using checkout_sha and after_sha' do
- let(:command) { described_class.new(project: project, checkout_sha: 'aaa', after_sha: 'bbb') }
+ context "when using checkout_sha and after_sha" do
+ let(:command) { described_class.new(project: project, checkout_sha: "aaa", after_sha: "bbb") }
- it 'uses checkout_sha' do
- is_expected.to eq('aaa')
+ it "uses checkout_sha" do
+ is_expected.to eq("aaa")
end
end
- context 'when using after_sha only' do
- let(:command) { described_class.new(project: project, after_sha: 'bbb') }
+ context "when using after_sha only" do
+ let(:command) { described_class.new(project: project, after_sha: "bbb") }
- it 'uses after_sha' do
- is_expected.to eq('bbb')
+ it "uses after_sha" do
+ is_expected.to eq("bbb")
end
end
end
- describe '#before_sha' do
+ describe "#before_sha" do
subject { command.before_sha }
- context 'when using checkout_sha and before_sha' do
- let(:command) { described_class.new(project: project, checkout_sha: 'aaa', before_sha: 'bbb') }
+ context "when using checkout_sha and before_sha" do
+ let(:command) { described_class.new(project: project, checkout_sha: "aaa", before_sha: "bbb") }
- it 'uses before_sha' do
- is_expected.to eq('bbb')
+ it "uses before_sha" do
+ is_expected.to eq("bbb")
end
end
- context 'when using checkout_sha only' do
- let(:command) { described_class.new(project: project, checkout_sha: 'aaa') }
+ context "when using checkout_sha only" do
+ let(:command) { described_class.new(project: project, checkout_sha: "aaa") }
- it 'uses checkout_sha' do
- is_expected.to eq('aaa')
+ it "uses checkout_sha" do
+ is_expected.to eq("aaa")
end
end
- context 'when checkout_sha and before_sha are empty' do
+ context "when checkout_sha and before_sha are empty" do
let(:command) { described_class.new(project: project) }
- it 'uses BLANK_SHA' do
+ it "uses BLANK_SHA" do
is_expected.to eq(Gitlab::Git::BLANK_SHA)
end
end
end
- describe '#source_sha' do
+ describe "#source_sha" do
subject { command.source_sha }
let(:command) do
@@ -176,16 +176,16 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
let(:source_sha) { nil }
- context 'when source_sha is specified' do
- let(:source_sha) { 'abc' }
+ context "when source_sha is specified" do
+ let(:source_sha) { "abc" }
- it 'returns the specified value' do
- is_expected.to eq('abc')
+ it "returns the specified value" do
+ is_expected.to eq("abc")
end
end
end
- describe '#target_sha' do
+ describe "#target_sha" do
subject { command.target_sha }
let(:command) do
@@ -200,51 +200,51 @@ describe Gitlab::Ci::Pipeline::Chain::Command do
let(:target_sha) { nil }
- context 'when target_sha is specified' do
- let(:target_sha) { 'abc' }
+ context "when target_sha is specified" do
+ let(:target_sha) { "abc" }
- it 'returns the specified value' do
- is_expected.to eq('abc')
+ it "returns the specified value" do
+ is_expected.to eq("abc")
end
end
end
- describe '#protected_ref?' do
- let(:command) { described_class.new(project: project, origin_ref: 'my-branch') }
+ describe "#protected_ref?" do
+ let(:command) { described_class.new(project: project, origin_ref: "my-branch") }
subject { command.protected_ref? }
- context 'when a ref is protected' do
+ context "when a ref is protected" do
before do
- expect_any_instance_of(Project).to receive(:protected_for?).with('my-branch').and_return(true)
+ expect_any_instance_of(Project).to receive(:protected_for?).with("my-branch").and_return(true)
end
it { is_expected.to eq(true) }
end
- context 'when a ref is unprotected' do
+ context "when a ref is unprotected" do
before do
- expect_any_instance_of(Project).to receive(:protected_for?).with('my-branch').and_return(false)
+ expect_any_instance_of(Project).to receive(:protected_for?).with("my-branch").and_return(false)
end
it { is_expected.to eq(false) }
end
end
- describe '#ambiguous_ref' do
+ describe "#ambiguous_ref" do
let(:project) { create(:project, :repository) }
- let(:command) { described_class.new(project: project, origin_ref: 'ref') }
+ let(:command) { described_class.new(project: project, origin_ref: "ref") }
subject { command.ambiguous_ref? }
- context 'when ref is not ambiguous' do
+ context "when ref is not ambiguous" do
it { is_expected. to eq(false) }
end
- context 'when ref is ambiguous' do
+ context "when ref is ambiguous" do
before do
- project.repository.add_tag(project.creator, 'ref', 'master')
- project.repository.add_branch(project.creator, 'ref', 'master')
+ project.repository.add_tag(project.creator, "ref", "master")
+ project.repository.add_branch(project.creator, "ref", "master")
end
it { is_expected. to eq(true) }
diff --git a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
index 0edc3f315bb..c83570819a9 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/create_spec.rb
@@ -1,42 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Create do
set(:project) { create(:project) }
set(:user) { create(:user) }
let(:pipeline) do
- build(:ci_empty_pipeline, project: project, ref: 'master')
+ build(:ci_empty_pipeline, project: project, ref: "master")
end
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user)
+ project: project, current_user: user
+ )
end
let(:step) { described_class.new(pipeline, command) }
- context 'when pipeline is ready to be saved' do
+ context "when pipeline is ready to be saved" do
before do
- pipeline.stages.build(name: 'test', position: 0, project: project)
+ pipeline.stages.build(name: "test", position: 0, project: project)
step.perform!
end
- it 'saves a pipeline' do
+ it "saves a pipeline" do
expect(pipeline).to be_persisted
end
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(step.break?).to be false
end
- it 'creates stages' do
+ it "creates stages" do
expect(pipeline.reload.stages).to be_one
expect(pipeline.stages.first).to be_persisted
end
end
- context 'when pipeline has validation errors' do
+ context "when pipeline has validation errors" do
let(:pipeline) do
build(:ci_pipeline, project: project, ref: nil)
end
@@ -45,11 +46,11 @@ describe Gitlab::Ci::Pipeline::Chain::Create do
step.perform!
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'appends validation error' do
+ it "appends validation error" do
expect(pipeline.errors.to_a)
.to include /Failed to persist the pipeline/
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
index 0302e4090cf..b58aa4f4b7e 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Populate do
set(:project) { create(:project, :repository) }
@@ -6,7 +6,7 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
let(:pipeline) do
build(:ci_pipeline_with_one_job, project: project,
- ref: 'master',
+ ref: "master",
user: user)
end
@@ -14,47 +14,48 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
Gitlab::Ci::Pipeline::Chain::Command.new(
project: project,
current_user: user,
- origin_ref: 'master',
- seeds_block: nil)
+ origin_ref: "master",
+ seeds_block: nil
+ )
end
let(:step) { described_class.new(pipeline, command) }
- context 'when pipeline doesn not have seeds block' do
+ context "when pipeline doesn not have seeds block" do
before do
step.perform!
end
- it 'does not persist the pipeline' do
+ it "does not persist the pipeline" do
expect(pipeline).not_to be_persisted
end
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(step.break?).to be false
end
- it 'populates pipeline with stages' do
+ it "populates pipeline with stages" do
expect(pipeline.stages).to be_one
expect(pipeline.stages.first).not_to be_persisted
expect(pipeline.stages.first.builds).to be_one
expect(pipeline.stages.first.builds.first).not_to be_persisted
end
- it 'correctly assigns user' do
+ it "correctly assigns user" do
expect(pipeline.builds).to all(have_attributes(user: user))
end
- it 'has pipeline iid' do
+ it "has pipeline iid" do
expect(pipeline.iid).to be > 0
end
end
- context 'when pipeline is empty' do
+ context "when pipeline is empty" do
let(:config) do
- { rspec: {
- script: 'ls',
- only: ['something']
- } }
+ {rspec: {
+ script: "ls",
+ only: ["something"],
+ }}
end
let(:pipeline) do
@@ -65,38 +66,38 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
step.perform!
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'appends an error about missing stages' do
+ it "appends an error about missing stages" do
expect(pipeline.errors.to_a)
- .to include 'No stages / jobs for this pipeline.'
+ .to include "No stages / jobs for this pipeline."
end
- it 'wastes pipeline iid' do
+ it "wastes pipeline iid" do
expect(InternalId.ci_pipelines.where(project_id: project.id).last.last_value).to be > 0
end
end
- describe 'pipeline protect' do
+ describe "pipeline protect" do
subject { step.perform! }
- context 'when ref is protected' do
+ context "when ref is protected" do
before do
- allow(project).to receive(:protected_for?).with('master').and_return(true)
- allow(project).to receive(:protected_for?).with('refs/heads/master').and_return(true)
+ allow(project).to receive(:protected_for?).with("master").and_return(true)
+ allow(project).to receive(:protected_for?).with("refs/heads/master").and_return(true)
end
- it 'does not protect the pipeline' do
+ it "does not protect the pipeline" do
subject
expect(pipeline.protected).to eq(true)
end
end
- context 'when ref is not protected' do
- it 'does not protect the pipeline' do
+ context "when ref is not protected" do
+ it "does not protect the pipeline" do
subject
expect(pipeline.protected).to eq(false)
@@ -104,7 +105,7 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end
end
- context 'when pipeline has validation errors' do
+ context "when pipeline has validation errors" do
let(:pipeline) do
build(:ci_pipeline, project: project, ref: nil)
end
@@ -113,57 +114,58 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
step.perform!
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'appends validation error' do
+ it "appends validation error" do
expect(pipeline.errors.to_a)
- .to include 'Failed to build the pipeline!'
+ .to include "Failed to build the pipeline!"
end
- it 'wastes pipeline iid' do
+ it "wastes pipeline iid" do
expect(InternalId.ci_pipelines.where(project_id: project.id).last.last_value).to be > 0
end
end
- context 'when there is a seed blocks present' do
+ context "when there is a seed blocks present" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
project: project,
current_user: user,
- origin_ref: 'master',
- seeds_block: seeds_block)
+ origin_ref: "master",
+ seeds_block: seeds_block
+ )
end
- context 'when seeds block builds some resources' do
+ context "when seeds block builds some resources" do
let(:seeds_block) do
- ->(pipeline) { pipeline.variables.build(key: 'VAR', value: '123') }
+ ->(pipeline) { pipeline.variables.build(key: "VAR", value: "123") }
end
- it 'populates pipeline with resources described in the seeds block' do
+ it "populates pipeline with resources described in the seeds block" do
step.perform!
expect(pipeline).not_to be_persisted
expect(pipeline.variables).not_to be_empty
expect(pipeline.variables.first).not_to be_persisted
- expect(pipeline.variables.first.key).to eq 'VAR'
- expect(pipeline.variables.first.value).to eq '123'
+ expect(pipeline.variables.first.key).to eq "VAR"
+ expect(pipeline.variables.first.value).to eq "123"
end
- it 'has pipeline iid' do
+ it "has pipeline iid" do
step.perform!
expect(pipeline.iid).to be > 0
end
end
- context 'when seeds block tries to persist some resources' do
+ context "when seeds block tries to persist some resources" do
let(:seeds_block) do
- ->(pipeline) { pipeline.variables.create!(key: 'VAR', value: '123') }
+ ->(pipeline) { pipeline.variables.create!(key: "VAR", value: "123") }
end
- it 'wastes pipeline iid' do
+ it "wastes pipeline iid" do
expect { step.perform! }.to raise_error(ActiveRecord::RecordNotSaved)
last_iid = InternalId.ci_pipelines
@@ -175,45 +177,45 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do
end
end
- context 'when pipeline gets persisted during the process' do
+ context "when pipeline gets persisted during the process" do
let(:pipeline) { create(:ci_pipeline, project: project) }
- it 'raises error' do
+ it "raises error" do
expect { step.perform! }.to raise_error(described_class::PopulateError)
end
end
- context 'when variables policy is specified' do
- shared_examples_for 'a correct pipeline' do
- it 'populates pipeline according to used policies' do
+ context "when variables policy is specified" do
+ shared_examples_for "a correct pipeline" do
+ it "populates pipeline according to used policies" do
step.perform!
expect(pipeline.stages.size).to eq 1
expect(pipeline.stages.first.builds.size).to eq 1
- expect(pipeline.stages.first.builds.first.name).to eq 'rspec'
+ expect(pipeline.stages.first.builds.first.name).to eq "rspec"
end
end
- context 'when using only/except build policies' do
+ context "when using only/except build policies" do
let(:config) do
- { rspec: { script: 'rspec', stage: 'test', only: ['master'] },
- prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] } }
+ {rspec: {script: "rspec", stage: "test", only: ["master"]},
+ prod: {script: "cap prod", stage: "deploy", only: ["tags"]},}
end
let(:pipeline) do
- build(:ci_pipeline, ref: 'master', project: project, config: config)
+ build(:ci_pipeline, ref: "master", project: project, config: config)
end
- it_behaves_like 'a correct pipeline'
+ it_behaves_like "a correct pipeline"
- context 'when variables expression is specified' do
- context 'when pipeline iid is the subject' do
+ context "when variables expression is specified" do
+ context "when pipeline iid is the subject" do
let(:config) do
- { rspec: { script: 'rspec', only: { variables: ["$CI_PIPELINE_IID == '1'"] } },
- prod: { script: 'cap prod', only: { variables: ["$CI_PIPELINE_IID == '1000'"] } } }
+ {rspec: {script: "rspec", only: {variables: ["$CI_PIPELINE_IID == '1'"]}},
+ prod: {script: "cap prod", only: {variables: ["$CI_PIPELINE_IID == '1000'"]}},}
end
- it_behaves_like 'a correct pipeline'
+ it_behaves_like "a correct pipeline"
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
index 7c1c016b4bb..c2ba3d80029 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/remove_unwanted_chat_jobs_spec.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do
let(:project) { create(:project, :repository) }
let(:pipeline) do
- build(:ci_pipeline_with_one_job, project: project, ref: 'master')
+ build(:ci_pipeline_with_one_job, project: project, ref: "master")
end
let(:command) do
- double(:command, project: project, chat_data: { command: 'echo' })
+ double(:command, project: project, chat_data: {command: "echo"})
end
- describe '#perform!' do
- it 'removes unwanted jobs for chat pipelines' do
+ describe "#perform!" do
+ it "removes unwanted jobs for chat pipelines" do
allow(pipeline).to receive(:chat?).and_return(true)
pipeline.config_processor.jobs[:echo] = double(:job)
@@ -25,7 +25,7 @@ describe Gitlab::Ci::Pipeline::Chain::RemoveUnwantedChatJobs do
end
end
- it 'does not remove any jobs for non-chat pipelines' do
+ it "does not remove any jobs for non-chat pipelines" do
described_class.new(pipeline, command).perform!
expect(pipeline.config_processor.jobs.keys).to eq([:rspec])
diff --git a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
index eca23694a2b..d3971780282 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/sequence_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Sequence do
set(:project) { create(:project) }
@@ -6,20 +6,20 @@ describe Gitlab::Ci::Pipeline::Chain::Sequence do
let(:pipeline) { build_stubbed(:ci_pipeline) }
let(:command) { Gitlab::Ci::Pipeline::Chain::Command.new }
- let(:first_step) { spy('first step') }
- let(:second_step) { spy('second step') }
+ let(:first_step) { spy("first step") }
+ let(:second_step) { spy("second step") }
let(:sequence) { [first_step, second_step] }
subject do
described_class.new(pipeline, command, sequence)
end
- context 'when one of steps breaks the chain' do
+ context "when one of steps breaks the chain" do
before do
allow(first_step).to receive(:break?).and_return(true)
end
- it 'does not process the second step' do
+ it "does not process the second step" do
subject.build! do |pipeline, sequence|
expect(sequence).not_to be_complete
end
@@ -27,19 +27,19 @@ describe Gitlab::Ci::Pipeline::Chain::Sequence do
expect(second_step).not_to have_received(:perform!)
end
- it 'returns a pipeline object' do
+ it "returns a pipeline object" do
expect(subject.build!).to eq pipeline
end
end
- context 'when all chains are executed correctly' do
+ context "when all chains are executed correctly" do
before do
sequence.each do |step|
allow(step).to receive(:break?).and_return(false)
end
end
- it 'iterates through entire sequence' do
+ it "iterates through entire sequence" do
subject.build! do |pipeline, sequence|
expect(sequence).to be_complete
end
@@ -48,7 +48,7 @@ describe Gitlab::Ci::Pipeline::Chain::Sequence do
expect(second_step).to have_received(:perform!)
end
- it 'returns a pipeline object' do
+ it "returns a pipeline object" do
expect(subject.build!).to eq pipeline
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
index dc13cae961c..1bd861e7b29 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/skip_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Skip do
set(:project) { create(:project) }
@@ -10,59 +10,60 @@ describe Gitlab::Ci::Pipeline::Chain::Skip do
project: project,
current_user: user,
ignore_skip_ci: false,
- save_incompleted: true)
+ save_incompleted: true
+ )
end
let(:step) { described_class.new(pipeline, command) }
- context 'when pipeline has been skipped by a user' do
+ context "when pipeline has been skipped by a user" do
before do
allow(pipeline).to receive(:git_commit_message)
- .and_return('commit message [ci skip]')
+ .and_return("commit message [ci skip]")
step.perform!
end
- it 'should break the chain' do
+ it "should break the chain" do
expect(step.break?).to be true
end
- it 'skips the pipeline' do
+ it "skips the pipeline" do
expect(pipeline.reload).to be_skipped
end
end
- context 'when pipeline has not been skipped' do
+ context "when pipeline has not been skipped" do
before do
step.perform!
end
- it 'should not break the chain' do
+ it "should not break the chain" do
expect(step.break?).to be false
end
- it 'should not skip a pipeline chain' do
+ it "should not skip a pipeline chain" do
expect(pipeline.reload).not_to be_skipped
end
end
- context 'when [ci skip] should be ignored' do
+ context "when [ci skip] should be ignored" do
let(:command) do
- double('command', project: project,
+ double("command", project: project,
current_user: user,
ignore_skip_ci: true)
end
- it 'does not break the chain' do
+ it "does not break the chain" do
step.perform!
expect(step.break?).to be false
end
end
- context 'when pipeline should be skipped but not persisted' do
+ context "when pipeline should be skipped but not persisted" do
let(:command) do
- double('command', project: project,
+ double("command", project: project,
current_user: user,
ignore_skip_ci: false,
save_incompleted: false)
@@ -70,16 +71,16 @@ describe Gitlab::Ci::Pipeline::Chain::Skip do
before do
allow(pipeline).to receive(:git_commit_message)
- .and_return('commit message [ci skip]')
+ .and_return("commit message [ci skip]")
step.perform!
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'does not skip pipeline' do
+ it "does not skip pipeline" do
expect(pipeline.reload).not_to be_skipped
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
index 8ba56d73838..b2dff151ed1 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/abilities_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
set(:project) { create(:project, :repository) }
@@ -10,75 +10,76 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user, origin_ref: ref)
+ project: project, current_user: user, origin_ref: ref
+ )
end
let(:step) { described_class.new(pipeline, command) }
- let(:ref) { 'master' }
+ let(:ref) { "master" }
- context 'when users has no ability to run a pipeline' do
+ context "when users has no ability to run a pipeline" do
before do
step.perform!
end
- it 'adds an error about insufficient permissions' do
+ it "adds an error about insufficient permissions" do
expect(pipeline.errors.to_a)
.to include /Insufficient permissions/
end
- it 'breaks the pipeline builder chain' do
+ it "breaks the pipeline builder chain" do
expect(step.break?).to eq true
end
end
- context 'when user has ability to create a pipeline' do
+ context "when user has ability to create a pipeline" do
before do
project.add_developer(user)
step.perform!
end
- it 'does not invalidate the pipeline' do
+ it "does not invalidate the pipeline" do
expect(pipeline).to be_valid
end
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(step.break?).to eq false
end
end
- describe '#allowed_to_create?' do
+ describe "#allowed_to_create?" do
subject { step.allowed_to_create? }
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
it { is_expected.to be_truthy }
- context 'when the branch is protected' do
+ context "when the branch is protected" do
let!(:protected_branch) do
create(:protected_branch, project: project, name: ref)
end
it { is_expected.to be_falsey }
- context 'when developers are allowed to merge' do
+ context "when developers are allowed to merge" do
let!(:protected_branch) do
create(:protected_branch,
- :developers_can_merge,
- project: project,
- name: ref)
+ :developers_can_merge,
+ project: project,
+ name: ref)
end
it { is_expected.to be_truthy }
end
end
- context 'when the tag is protected' do
- let(:ref) { 'v1.0.0' }
+ context "when the tag is protected" do
+ let(:ref) { "v1.0.0" }
let!(:protected_tag) do
create(:protected_tag, project: project, name: ref)
@@ -86,12 +87,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
it { is_expected.to be_falsey }
- context 'when developers are allowed to create the tag' do
+ context "when developers are allowed to create the tag" do
let!(:protected_tag) do
create(:protected_tag,
- :developers_can_create,
- project: project,
- name: ref)
+ :developers_can_create,
+ project: project,
+ name: ref)
end
it { is_expected.to be_truthy }
@@ -99,14 +100,14 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
it { is_expected.to be_truthy }
- context 'when the branch is protected' do
+ context "when the branch is protected" do
let!(:protected_branch) do
create(:protected_branch, project: project, name: ref)
end
@@ -114,8 +115,8 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
it { is_expected.to be_truthy }
end
- context 'when the tag is protected' do
- let(:ref) { 'v1.0.0' }
+ context "when the tag is protected" do
+ let(:ref) { "v1.0.0" }
let!(:protected_tag) do
create(:protected_tag, project: project, name: ref)
@@ -123,12 +124,12 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
it { is_expected.to be_truthy }
- context 'when no one can create the tag' do
+ context "when no one can create the tag" do
let!(:protected_tag) do
create(:protected_tag,
- :no_one_can_create,
- project: project,
- name: ref)
+ :no_one_can_create,
+ project: project,
+ name: ref)
end
it { is_expected.to be_falsey }
@@ -136,7 +137,7 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Abilities do
end
end
- context 'when owner cannot create pipeline' do
+ context "when owner cannot create pipeline" do
it { is_expected.to be_falsey }
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
index 053bc421649..71fb137477c 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/config_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
set(:project) { create(:project, :repository) }
@@ -8,7 +8,8 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
Gitlab::Ci::Pipeline::Chain::Command.new(
project: project,
current_user: user,
- save_incompleted: true)
+ save_incompleted: true
+ )
end
let!(:step) { described_class.new(pipeline, command) }
@@ -17,97 +18,97 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
step.perform!
end
- context 'when pipeline has no YAML configuration' do
+ context "when pipeline has no YAML configuration" do
let(:pipeline) do
build_stubbed(:ci_pipeline, project: project)
end
- it 'appends errors about missing configuration' do
+ it "appends errors about missing configuration" do
expect(pipeline.errors.to_a)
- .to include 'Missing .gitlab-ci.yml file'
+ .to include "Missing .gitlab-ci.yml file"
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
end
- context 'when YAML configuration contains errors' do
+ context "when YAML configuration contains errors" do
let(:pipeline) do
- build(:ci_pipeline, project: project, config: 'invalid YAML')
+ build(:ci_pipeline, project: project, config: "invalid YAML")
end
- it 'appends errors about YAML errors' do
+ it "appends errors about YAML errors" do
expect(pipeline.errors.to_a)
- .to include 'Invalid configuration format'
+ .to include "Invalid configuration format"
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- context 'when saving incomplete pipeline is allowed' do
+ context "when saving incomplete pipeline is allowed" do
let(:command) do
- double('command', project: project,
+ double("command", project: project,
current_user: user,
save_incompleted: true)
end
- it 'fails the pipeline' do
+ it "fails the pipeline" do
expect(pipeline.reload).to be_failed
end
- it 'sets a config error failure reason' do
+ it "sets a config error failure reason" do
expect(pipeline.reload.config_error?).to eq true
end
end
- context 'when saving incomplete pipeline is not allowed' do
+ context "when saving incomplete pipeline is not allowed" do
let(:command) do
- double('command', project: project,
+ double("command", project: project,
current_user: user,
save_incompleted: false)
end
- it 'does not drop pipeline' do
+ it "does not drop pipeline" do
expect(pipeline).not_to be_failed
expect(pipeline).not_to be_persisted
end
end
end
- context 'when pipeline contains configuration validation errors' do
- let(:config) { { rspec: {} } }
+ context "when pipeline contains configuration validation errors" do
+ let(:config) { {rspec: {}} }
let(:pipeline) do
build(:ci_pipeline, project: project, config: config)
end
- it 'appends configuration validation errors to pipeline errors' do
+ it "appends configuration validation errors to pipeline errors" do
expect(pipeline.errors.to_a)
.to include "jobs:rspec config can't be blank"
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
end
- context 'when pipeline is correct and complete' do
+ context "when pipeline is correct and complete" do
let(:pipeline) do
build(:ci_pipeline_with_one_job, project: project)
end
- it 'does not invalidate the pipeline' do
+ it "does not invalidate the pipeline" do
expect(pipeline).to be_valid
end
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(step.break?).to be false
end
end
- context 'when pipeline source is merge request' do
+ context "when pipeline source is merge request" do
before do
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
@@ -121,17 +122,17 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Config do
let(:chain) { described_class.new(merge_request_pipeline, command).tap(&:perform!) }
context "when config contains 'merge_requests' keyword" do
- let(:config) { { rspec: { script: 'echo', only: ['merge_requests'] } } }
+ let(:config) { {rspec: {script: "echo", only: ["merge_requests"]}} }
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(chain).not_to be_break
end
end
context "when config contains 'merge_request' keyword" do
- let(:config) { { rspec: { script: 'echo', only: ['merge_request'] } } }
+ let(:config) { {rspec: {script: "echo", only: ["merge_request"]}} }
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(chain).not_to be_break
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
index a7cad423d09..830d847f06f 100644
--- a/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/chain/validate/repository_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do
set(:project) { create(:project, :repository) }
@@ -11,71 +11,75 @@ describe Gitlab::Ci::Pipeline::Chain::Validate::Repository do
step.perform!
end
- context 'when ref and sha exists' do
+ context "when ref and sha exists" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user, origin_ref: 'master', checkout_sha: project.commit.id)
+ project: project, current_user: user, origin_ref: "master", checkout_sha: project.commit.id
+ )
end
- it 'does not break the chain' do
+ it "does not break the chain" do
expect(step.break?).to be false
end
- it 'does not append pipeline errors' do
+ it "does not append pipeline errors" do
expect(pipeline.errors).to be_empty
end
end
- context 'when ref does not exist' do
+ context "when ref does not exist" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user, origin_ref: 'something')
+ project: project, current_user: user, origin_ref: "something"
+ )
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'adds an error about missing ref' do
+ it "adds an error about missing ref" do
expect(pipeline.errors.to_a)
- .to include 'Reference not found'
+ .to include "Reference not found"
end
end
- context 'when ref is ambiguous' do
+ context "when ref is ambiguous" do
let(:project) do
create(:project, :repository).tap do |proj|
- proj.repository.add_tag(user, 'master', 'master')
+ proj.repository.add_tag(user, "master", "master")
end
end
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user, origin_ref: 'master')
+ project: project, current_user: user, origin_ref: "master"
+ )
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'adds an error about missing ref' do
+ it "adds an error about missing ref" do
expect(pipeline.errors.to_a)
- .to include 'Ref is ambiguous'
+ .to include "Ref is ambiguous"
end
end
- context 'when does not have existing SHA set' do
+ context "when does not have existing SHA set" do
let(:command) do
Gitlab::Ci::Pipeline::Chain::Command.new(
- project: project, current_user: user, origin_ref: 'master', checkout_sha: 'something')
+ project: project, current_user: user, origin_ref: "master", checkout_sha: "something"
+ )
end
- it 'breaks the chain' do
+ it "breaks the chain" do
expect(step.break?).to be true
end
- it 'adds an error about missing SHA' do
+ it "adds an error about missing SHA" do
expect(pipeline.errors.to_a)
- .to include 'Commit not found'
+ .to include "Commit not found"
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/duration_spec.rb b/spec/lib/gitlab/ci/pipeline/duration_spec.rb
index 7c9836e2da6..eb3b1ee88b6 100644
--- a/spec/lib/gitlab/ci/pipeline/duration_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/duration_spec.rb
@@ -1,68 +1,68 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Duration do
let(:calculated_duration) { calculate(data) }
- shared_examples 'calculating duration' do
+ shared_examples "calculating duration" do
it do
expect(calculated_duration).to eq(duration)
end
end
- context 'test sample A' do
+ context "test sample A" do
let(:data) do
[[0, 1],
[1, 2],
[3, 4],
- [5, 6]]
+ [5, 6],]
end
let(:duration) { 4 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample B' do
+ context "test sample B" do
let(:data) do
[[0, 1],
[1, 2],
[2, 3],
[3, 4],
- [0, 4]]
+ [0, 4],]
end
let(:duration) { 4 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample C' do
+ context "test sample C" do
let(:data) do
[[0, 4],
[2, 6],
[5, 7],
- [8, 9]]
+ [8, 9],]
end
let(:duration) { 8 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample D' do
+ context "test sample D" do
let(:data) do
[[0, 1],
[2, 3],
[4, 5],
- [6, 7]]
+ [6, 7],]
end
let(:duration) { 4 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample E' do
+ context "test sample E" do
let(:data) do
[[0, 1],
[3, 9],
@@ -71,44 +71,44 @@ describe Gitlab::Ci::Pipeline::Duration do
[3, 8],
[4, 5],
[4, 7],
- [5, 8]]
+ [5, 8],]
end
let(:duration) { 7 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample F' do
+ context "test sample F" do
let(:data) do
[[1, 3],
[2, 4],
[2, 4],
[2, 4],
- [5, 8]]
+ [5, 8],]
end
let(:duration) { 6 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
- context 'test sample G' do
+ context "test sample G" do
let(:data) do
[[1, 3],
[2, 4],
- [6, 7]]
+ [6, 7],]
end
let(:duration) { 4 }
- it_behaves_like 'calculating duration'
+ it_behaves_like "calculating duration"
end
def calculate(data)
- periods = data.shuffle.map do |(first, last)|
+ periods = data.shuffle.map { |(first, last)|
described_class::Period.new(first, last)
- end
+ }
described_class.from_periods(periods.sort_by(&:first))
end
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb
index 019a2ed184d..de77fb4fa9c 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/equals_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::Equals do
- let(:left) { double('left') }
- let(:right) { double('right') }
+ let(:left) { double("left") }
+ let(:right) { double("right") }
- describe '.build' do
- it 'creates a new instance of the token' do
- expect(described_class.build('==', left, right))
+ describe ".build" do
+ it "creates a new instance of the token" do
+ expect(described_class.build("==", left, right))
.to be_a(described_class)
end
end
- describe '.type' do
- it 'is an operator' do
+ describe ".type" do
+ it "is an operator" do
expect(described_class.type).to eq :operator
end
end
- describe '#evaluate' do
- it 'returns false when left and right are not equal' do
+ describe "#evaluate" do
+ it "returns false when left and right are not equal" do
allow(left).to receive(:evaluate).and_return(1)
allow(right).to receive(:evaluate).and_return(2)
@@ -27,7 +27,7 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Equals do
expect(operator.evaluate(VARIABLE: 3)).to eq false
end
- it 'returns true when left and right are equal' do
+ it "returns true when left and right are equal" do
allow(left).to receive(:evaluate).and_return(1)
allow(right).to receive(:evaluate).and_return(1)
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
index 49e5af52f4d..1686f8a3e18 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/matches_spec.rb
@@ -1,55 +1,55 @@
-require 'fast_spec_helper'
-require_dependency 're2'
+require "fast_spec_helper"
+require_dependency "re2"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do
- let(:left) { double('left') }
- let(:right) { double('right') }
+ let(:left) { double("left") }
+ let(:right) { double("right") }
- describe '.build' do
- it 'creates a new instance of the token' do
- expect(described_class.build('=~', left, right))
+ describe ".build" do
+ it "creates a new instance of the token" do
+ expect(described_class.build("=~", left, right))
.to be_a(described_class)
end
end
- describe '.type' do
- it 'is an operator' do
+ describe ".type" do
+ it "is an operator" do
expect(described_class.type).to eq :operator
end
end
- describe '#evaluate' do
- it 'returns false when left and right do not match' do
- allow(left).to receive(:evaluate).and_return('my-string')
+ describe "#evaluate" do
+ it "returns false when left and right do not match" do
+ allow(left).to receive(:evaluate).and_return("my-string")
allow(right).to receive(:evaluate)
- .and_return(Gitlab::UntrustedRegexp.new('something'))
+ .and_return(Gitlab::UntrustedRegexp.new("something"))
operator = described_class.new(left, right)
expect(operator.evaluate).to eq false
end
- it 'returns true when left and right match' do
- allow(left).to receive(:evaluate).and_return('my-awesome-string')
+ it "returns true when left and right match" do
+ allow(left).to receive(:evaluate).and_return("my-awesome-string")
allow(right).to receive(:evaluate)
- .and_return(Gitlab::UntrustedRegexp.new('awesome.string$'))
+ .and_return(Gitlab::UntrustedRegexp.new("awesome.string$"))
operator = described_class.new(left, right)
expect(operator.evaluate).to eq true
end
- it 'supports matching against a nil value' do
+ it "supports matching against a nil value" do
allow(left).to receive(:evaluate).and_return(nil)
allow(right).to receive(:evaluate)
- .and_return(Gitlab::UntrustedRegexp.new('pattern'))
+ .and_return(Gitlab::UntrustedRegexp.new("pattern"))
operator = described_class.new(left, right)
expect(operator.evaluate).to eq false
end
- it 'supports multiline strings' do
+ it "supports multiline strings" do
allow(left).to receive(:evaluate).and_return <<~TEXT
My awesome contents
@@ -57,20 +57,20 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Matches do
TEXT
allow(right).to receive(:evaluate)
- .and_return(Gitlab::UntrustedRegexp.new('text-string'))
+ .and_return(Gitlab::UntrustedRegexp.new("text-string"))
operator = described_class.new(left, right)
expect(operator.evaluate).to eq true
end
- it 'supports regexp flags' do
+ it "supports regexp flags" do
allow(left).to receive(:evaluate).and_return <<~TEXT
My AWESOME content
TEXT
allow(right).to receive(:evaluate)
- .and_return(Gitlab::UntrustedRegexp.new('(?i)awesome'))
+ .and_return(Gitlab::UntrustedRegexp.new("(?i)awesome"))
operator = described_class.new(left, right)
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb
index b5a59929e11..25b50f532cd 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/null_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::Null do
- describe '.build' do
- it 'creates a new instance of the token' do
- expect(described_class.build('null'))
+ describe ".build" do
+ it "creates a new instance of the token" do
+ expect(described_class.build("null"))
.to be_a(described_class)
end
end
- describe '.type' do
- it 'is a value lexeme' do
+ describe ".type" do
+ it "is a value lexeme" do
expect(described_class.type).to eq :value
end
end
- describe '#evaluate' do
- it 'always evaluates to `nil`' do
- expect(described_class.new('null').evaluate).to be_nil
+ describe "#evaluate" do
+ it "always evaluates to `nil`" do
+ expect(described_class.new("null").evaluate).to be_nil
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
index 3ebc2e94727..9aabde21d59 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/pattern_spec.rb
@@ -1,46 +1,46 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do
- describe '.build' do
- it 'creates a new instance of the token' do
- expect(described_class.build('/.*/'))
+ describe ".build" do
+ it "creates a new instance of the token" do
+ expect(described_class.build("/.*/"))
.to be_a(described_class)
end
- it 'raises an error if pattern is invalid' do
- expect { described_class.build('/ some ( thin/i') }
+ it "raises an error if pattern is invalid" do
+ expect { described_class.build("/ some ( thin/i") }
.to raise_error(Gitlab::Ci::Pipeline::Expression::Lexer::SyntaxError)
end
end
- describe '.type' do
- it 'is a value lexeme' do
+ describe ".type" do
+ it "is a value lexeme" do
expect(described_class.type).to eq :value
end
end
- describe '.scan' do
- it 'correctly identifies a pattern token' do
- scanner = StringScanner.new('/pattern/')
+ describe ".scan" do
+ it "correctly identifies a pattern token" do
+ scanner = StringScanner.new("/pattern/")
token = described_class.scan(scanner)
expect(token).not_to be_nil
expect(token.build.evaluate)
- .to eq Gitlab::UntrustedRegexp.new('pattern')
+ .to eq Gitlab::UntrustedRegexp.new("pattern")
end
- it 'is a greedy scanner for regexp boundaries' do
- scanner = StringScanner.new('/some .* / pattern/')
+ it "is a greedy scanner for regexp boundaries" do
+ scanner = StringScanner.new("/some .* / pattern/")
token = described_class.scan(scanner)
expect(token).not_to be_nil
expect(token.build.evaluate)
- .to eq Gitlab::UntrustedRegexp.new('some .* / pattern')
+ .to eq Gitlab::UntrustedRegexp.new("some .* / pattern")
end
- it 'does not allow to use an empty pattern' do
+ it "does not allow to use an empty pattern" do
scanner = StringScanner.new(%(//))
token = described_class.scan(scanner)
@@ -48,28 +48,28 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do
expect(token).to be_nil
end
- it 'support single flag' do
- scanner = StringScanner.new('/pattern/i')
+ it "support single flag" do
+ scanner = StringScanner.new("/pattern/i")
token = described_class.scan(scanner)
expect(token).not_to be_nil
expect(token.build.evaluate)
- .to eq Gitlab::UntrustedRegexp.new('(?i)pattern')
+ .to eq Gitlab::UntrustedRegexp.new("(?i)pattern")
end
- it 'support multiple flags' do
- scanner = StringScanner.new('/pattern/im')
+ it "support multiple flags" do
+ scanner = StringScanner.new("/pattern/im")
token = described_class.scan(scanner)
expect(token).not_to be_nil
expect(token.build.evaluate)
- .to eq Gitlab::UntrustedRegexp.new('(?im)pattern')
+ .to eq Gitlab::UntrustedRegexp.new("(?im)pattern")
end
- it 'does not support arbitrary flags' do
- scanner = StringScanner.new('/pattern/x')
+ it "does not support arbitrary flags" do
+ scanner = StringScanner.new("/pattern/x")
token = described_class.scan(scanner)
@@ -77,17 +77,17 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::Pattern do
end
end
- describe '#evaluate' do
- it 'returns a regular expression' do
- regexp = described_class.new('/abc/')
+ describe "#evaluate" do
+ it "returns a regular expression" do
+ regexp = described_class.new("/abc/")
- expect(regexp.evaluate).to eq Gitlab::UntrustedRegexp.new('abc')
+ expect(regexp.evaluate).to eq Gitlab::UntrustedRegexp.new("abc")
end
- it 'raises error if evaluated regexp is not valid' do
+ it "raises error if evaluated regexp is not valid" do
allow(Gitlab::UntrustedRegexp).to receive(:valid?).and_return(true)
- regexp = described_class.new('/invalid ( .*/')
+ regexp = described_class.new("/invalid ( .*/")
expect { regexp.evaluate }
.to raise_error(Gitlab::Ci::Pipeline::Expression::RuntimeError)
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb
index f54ef492e6d..78925746554 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb
@@ -1,62 +1,62 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do
- describe '.build' do
- it 'creates a new instance of the token' do
+ describe ".build" do
+ it "creates a new instance of the token" do
expect(described_class.build('"my string"'))
.to be_a(described_class)
end
end
- describe '.type' do
- it 'is a value lexeme' do
+ describe ".type" do
+ it "is a value lexeme" do
expect(described_class.type).to eq :value
end
end
- describe '.scan' do
- context 'when using double quotes' do
- it 'correctly identifies string token' do
+ describe ".scan" do
+ context "when using double quotes" do
+ it "correctly identifies string token" do
scanner = StringScanner.new('"some string"')
token = described_class.scan(scanner)
expect(token).not_to be_nil
- expect(token.build.evaluate).to eq 'some string'
+ expect(token.build.evaluate).to eq "some string"
end
end
- context 'when using single quotes' do
- it 'correctly identifies string token' do
+ context "when using single quotes" do
+ it "correctly identifies string token" do
scanner = StringScanner.new("'some string 2'")
token = described_class.scan(scanner)
expect(token).not_to be_nil
- expect(token.build.evaluate).to eq 'some string 2'
+ expect(token.build.evaluate).to eq "some string 2"
end
end
- context 'when there are mixed quotes in the string' do
- it 'is a greedy scanner for double quotes' do
+ context "when there are mixed quotes in the string" do
+ it "is a greedy scanner for double quotes" do
scanner = StringScanner.new('"some string" "and another one"')
token = described_class.scan(scanner)
expect(token).not_to be_nil
- expect(token.build.evaluate).to eq 'some string'
+ expect(token.build.evaluate).to eq "some string"
end
- it 'is a greedy scanner for single quotes' do
+ it "is a greedy scanner for single quotes" do
scanner = StringScanner.new("'some string' 'and another one'")
token = described_class.scan(scanner)
expect(token).not_to be_nil
- expect(token.build.evaluate).to eq 'some string'
+ expect(token.build.evaluate).to eq "some string"
end
- it 'allows to use single quotes inside double quotes' do
+ it "allows to use single quotes inside double quotes" do
scanner = StringScanner.new(%("some ' string"))
token = described_class.scan(scanner)
@@ -65,7 +65,7 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do
expect(token.build.evaluate).to eq "some ' string"
end
- it 'allow to use double quotes inside single quotes' do
+ it "allow to use double quotes inside single quotes" do
scanner = StringScanner.new(%('some " string'))
token = described_class.scan(scanner)
@@ -74,35 +74,35 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do
expect(token.build.evaluate).to eq 'some " string'
end
- it 'allows to use an empty string inside single quotes' do
+ it "allows to use an empty string inside single quotes" do
scanner = StringScanner.new(%(''))
token = described_class.scan(scanner)
- expect(token.build.evaluate).to eq ''
+ expect(token.build.evaluate).to eq ""
end
- it 'allow to use an empty string inside double quotes' do
+ it "allow to use an empty string inside double quotes" do
scanner = StringScanner.new(%(""))
token = described_class.scan(scanner)
- expect(token.build.evaluate).to eq ''
+ expect(token.build.evaluate).to eq ""
end
end
end
- describe '#evaluate' do
- it 'returns string value if it is present' do
- string = described_class.new('my string')
+ describe "#evaluate" do
+ it "returns string value if it is present" do
+ string = described_class.new("my string")
- expect(string.evaluate).to eq 'my string'
+ expect(string.evaluate).to eq "my string"
end
- it 'returns an empty string if it is empty' do
- string = described_class.new('')
+ it "returns an empty string if it is empty" do
+ string = described_class.new("")
- expect(string.evaluate).to eq ''
+ expect(string.evaluate).to eq ""
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
index 599a5411881..1228151f2f1 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/variable_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexeme::Variable do
- describe '.build' do
- it 'creates a new instance of the token' do
- expect(described_class.build('$VARIABLE'))
+ describe ".build" do
+ it "creates a new instance of the token" do
+ expect(described_class.build("$VARIABLE"))
.to be_a(described_class)
end
end
- describe '.type' do
- it 'is a value lexeme' do
+ describe ".type" do
+ it "is a value lexeme" do
expect(described_class.type).to eq :value
end
end
- describe '#evaluate' do
- it 'returns variable value if it is defined' do
- variable = described_class.new('VARIABLE')
+ describe "#evaluate" do
+ it "returns variable value if it is defined" do
+ variable = described_class.new("VARIABLE")
- expect(variable.evaluate(VARIABLE: 'my variable'))
- .to eq 'my variable'
+ expect(variable.evaluate(VARIABLE: "my variable"))
+ .to eq "my variable"
end
- it 'allows to use a string as a variable key too' do
- variable = described_class.new('VARIABLE')
+ it "allows to use a string as a variable key too" do
+ variable = described_class.new("VARIABLE")
- expect(variable.evaluate('VARIABLE' => 'my variable'))
- .to eq 'my variable'
+ expect(variable.evaluate("VARIABLE" => "my variable"))
+ .to eq "my variable"
end
- it 'returns nil if it is not defined' do
- variable = described_class.new('VARIABLE')
+ it "returns nil if it is not defined" do
+ variable = described_class.new("VARIABLE")
- expect(variable.evaluate(OTHER: 'variable')).to be_nil
+ expect(variable.evaluate(OTHER: "variable")).to be_nil
end
- it 'returns an empty string if it is empty' do
- variable = described_class.new('VARIABLE')
+ it "returns an empty string if it is empty" do
+ variable = described_class.new("VARIABLE")
- expect(variable.evaluate(VARIABLE: '')).to eq ''
+ expect(variable.evaluate(VARIABLE: "")).to eq ""
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
index 3f11b3f7673..86132e54251 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/lexer_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Lexer do
let(:token_class) do
Gitlab::Ci::Pipeline::Expression::Token
end
- describe '#tokens' do
- it 'returns single value' do
- tokens = described_class.new('$VARIABLE').tokens
+ describe "#tokens" do
+ it "returns single value" do
+ tokens = described_class.new("$VARIABLE").tokens
expect(tokens).to be_one
expect(tokens).to all(be_an_instance_of(token_class))
end
- it 'does ignore whitespace characters' do
+ it "does ignore whitespace characters" do
tokens = described_class.new("\t$VARIABLE ").tokens
expect(tokens).to be_one
expect(tokens).to all(be_an_instance_of(token_class))
end
- it 'returns multiple values of the same token' do
+ it "returns multiple values of the same token" do
tokens = described_class.new("$VARIABLE1 $VARIABLE2").tokens
expect(tokens.size).to eq 2
expect(tokens).to all(be_an_instance_of(token_class))
end
- it 'returns multiple values with different tokens' do
+ it "returns multiple values with different tokens" do
tokens = described_class.new('$VARIABLE "text" "value"').tokens
expect(tokens.size).to eq 3
- expect(tokens.first.value).to eq '$VARIABLE'
+ expect(tokens.first.value).to eq "$VARIABLE"
expect(tokens.second.value).to eq '"text"'
expect(tokens.third.value).to eq '"value"'
end
- it 'returns tokens and operators' do
+ it "returns tokens and operators" do
tokens = described_class.new('$VARIABLE == "text"').tokens
expect(tokens.size).to eq 3
- expect(tokens.first.value).to eq '$VARIABLE'
- expect(tokens.second.value).to eq '=='
+ expect(tokens.first.value).to eq "$VARIABLE"
+ expect(tokens.second.value).to eq "=="
expect(tokens.third.value).to eq '"text"'
end
- it 'limits statement to specified amount of tokens' do
+ it "limits statement to specified amount of tokens" do
lexer = described_class.new("$V1 $V2 $V3 $V4", max_tokens: 3)
expect { lexer.tokens }
.to raise_error described_class::SyntaxError
end
- it 'raises syntax error in case of finding unknown tokens' do
- lexer = described_class.new('$V1 123 $V2')
+ it "raises syntax error in case of finding unknown tokens" do
+ lexer = described_class.new("$V1 123 $V2")
expect { lexer.tokens }
.to raise_error described_class::SyntaxError
end
end
- describe '#lexemes' do
- it 'returns an array of syntax lexemes' do
+ describe "#lexemes" do
+ it "returns an array of syntax lexemes" do
lexer = described_class.new('$VAR "text"')
expect(lexer.lexemes).to eq %w[variable string]
diff --git a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
index 2b78b1dd4a7..2faa33edd6e 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/parser_spec.rb
@@ -1,24 +1,24 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Parser do
- describe '#tree' do
- context 'when using operators' do
- it 'returns a reverse descent parse tree' do
+ describe "#tree" do
+ context "when using operators" do
+ it "returns a reverse descent parse tree" do
expect(described_class.seed('$VAR1 == "123" == $VAR2').tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Equals
end
end
- context 'when using a single token' do
- it 'returns a single token instance' do
- expect(described_class.seed('$VAR').tree)
+ context "when using a single token" do
+ it "returns a single token instance" do
+ expect(described_class.seed("$VAR").tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Variable
end
end
- context 'when expression is empty' do
- it 'returns a null token' do
- expect(described_class.seed('').tree)
+ context "when expression is empty" do
+ it "returns a null token" do
+ expect(described_class.seed("").tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Null
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
index 11e73294f18..6f1f1c371c5 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb
@@ -1,5 +1,5 @@
-require 'fast_spec_helper'
-require 'rspec-parameterized'
+require "fast_spec_helper"
+require "rspec-parameterized"
describe Gitlab::Ci::Pipeline::Expression::Statement do
subject do
@@ -7,74 +7,74 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
let(:variables) do
- { 'PRESENT_VARIABLE' => 'my variable',
- EMPTY_VARIABLE: '' }
+ {"PRESENT_VARIABLE" => "my variable",
+ :EMPTY_VARIABLE => "",}
end
- describe '.new' do
- context 'when variables are not provided' do
- it 'allows to properly initializes the statement' do
- statement = described_class.new('$PRESENT_VARIABLE')
+ describe ".new" do
+ context "when variables are not provided" do
+ it "allows to properly initializes the statement" do
+ statement = described_class.new("$PRESENT_VARIABLE")
expect(statement.evaluate).to be_nil
end
end
end
- describe '#parse_tree' do
- context 'when expression is empty' do
- let(:text) { '' }
+ describe "#parse_tree" do
+ context "when expression is empty" do
+ let(:text) { "" }
- it 'raises an error' do
+ it "raises an error" do
expect { subject.parse_tree }
.to raise_error described_class::StatementError
end
end
- context 'when expression grammar is incorrect' do
+ context "when expression grammar is incorrect" do
table = [
'$VAR "text"', # missing operator
'== "123"', # invalid left side
'"some string"', # only string provided
- '$VAR ==', # invalid right side
- 'null', # missing lexemes
- '' # empty statement
+ "$VAR ==", # invalid right side
+ "null", # missing lexemes
+ "", # empty statement
]
table.each do |syntax|
context "when expression grammar is #{syntax.inspect}" do
let(:text) { syntax }
- it 'raises a statement error exception' do
+ it "raises a statement error exception" do
expect { subject.parse_tree }
.to raise_error described_class::StatementError
end
- it 'is an invalid statement' do
+ it "is an invalid statement" do
expect(subject).not_to be_valid
end
end
end
end
- context 'when expression grammar is correct' do
- context 'when using an operator' do
+ context "when expression grammar is correct" do
+ context "when using an operator" do
let(:text) { '$VAR == "value"' }
- it 'returns a reverse descent parse tree' do
+ it "returns a reverse descent parse tree" do
expect(subject.parse_tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Equals
end
- it 'is a valid statement' do
+ it "is a valid statement" do
expect(subject).to be_valid
end
end
- context 'when using a single token' do
- let(:text) { '$PRESENT_VARIABLE' }
+ context "when using a single token" do
+ let(:text) { "$PRESENT_VARIABLE" }
- it 'returns a single token instance' do
+ it "returns a single token instance" do
expect(subject.parse_tree)
.to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Variable
end
@@ -82,20 +82,20 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
end
- describe '#evaluate' do
+ describe "#evaluate" do
using RSpec::Parameterized::TableSyntax
where(:expression, :value) do
'$PRESENT_VARIABLE == "my variable"' | true
'"my variable" == $PRESENT_VARIABLE' | true
- '$PRESENT_VARIABLE == null' | false
- '$EMPTY_VARIABLE == null' | false
+ "$PRESENT_VARIABLE == null" | false
+ "$EMPTY_VARIABLE == null" | false
'"" == $EMPTY_VARIABLE' | true
- '$EMPTY_VARIABLE' | ''
- '$UNDEFINED_VARIABLE == null' | true
- 'null == $UNDEFINED_VARIABLE' | true
- '$PRESENT_VARIABLE' | 'my variable'
- '$UNDEFINED_VARIABLE' | nil
+ "$EMPTY_VARIABLE" | ""
+ "$UNDEFINED_VARIABLE == null" | true
+ "null == $UNDEFINED_VARIABLE" | true
+ "$PRESENT_VARIABLE" | "my variable"
+ "$UNDEFINED_VARIABLE" | nil
"$PRESENT_VARIABLE =~ /var.*e$/" | true
"$PRESENT_VARIABLE =~ /^var.*/" | false
"$EMPTY_VARIABLE =~ /var.*/" | false
@@ -112,17 +112,17 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
end
- describe '#truthful?' do
+ describe "#truthful?" do
using RSpec::Parameterized::TableSyntax
where(:expression, :value) do
'$PRESENT_VARIABLE == "my variable"' | true
"$PRESENT_VARIABLE == 'no match'" | false
- '$UNDEFINED_VARIABLE == null' | true
- '$PRESENT_VARIABLE' | true
- '$UNDEFINED_VARIABLE' | false
- '$EMPTY_VARIABLE' | false
- '$INVALID = 1' | false
+ "$UNDEFINED_VARIABLE == null" | true
+ "$PRESENT_VARIABLE" | true
+ "$UNDEFINED_VARIABLE" | false
+ "$EMPTY_VARIABLE" | false
+ "$INVALID = 1" | false
"$PRESENT_VARIABLE =~ /var.*/" | true
"$UNDEFINED_VARIABLE =~ /var.*/" | false
end
@@ -135,10 +135,10 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do
end
end
- context 'when evaluating expression raises an error' do
- let(:text) { '$PRESENT_VARIABLE' }
+ context "when evaluating expression raises an error" do
+ let(:text) { "$PRESENT_VARIABLE" }
- it 'returns false' do
+ it "returns false" do
allow(subject).to receive(:evaluate)
.and_raise(described_class::StatementError)
diff --git a/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
index cedfe270f9d..986333d6792 100644
--- a/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/expression/token_spec.rb
@@ -1,45 +1,45 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Ci::Pipeline::Expression::Token do
- let(:value) { '$VARIABLE' }
+ let(:value) { "$VARIABLE" }
let(:lexeme) { Gitlab::Ci::Pipeline::Expression::Lexeme::Variable }
subject { described_class.new(value, lexeme) }
- describe '#value' do
- it 'returns raw token value' do
+ describe "#value" do
+ it "returns raw token value" do
expect(subject.value).to eq value
end
end
- describe '#lexeme' do
- it 'returns raw token lexeme' do
+ describe "#lexeme" do
+ it "returns raw token lexeme" do
expect(subject.lexeme).to eq lexeme
end
end
- describe '#build' do
- it 'delegates to lexeme after adding a value' do
+ describe "#build" do
+ it "delegates to lexeme after adding a value" do
expect(lexeme).to receive(:build)
- .with(value, 'some', 'args')
+ .with(value, "some", "args")
- subject.build('some', 'args')
+ subject.build("some", "args")
end
- it 'allows passing only required arguments' do
+ it "allows passing only required arguments" do
expect(subject.build).to be_an_instance_of(lexeme)
end
end
- describe '#type' do
- it 'delegates type query to the lexeme' do
+ describe "#type" do
+ it "delegates type query to the lexeme" do
expect(subject.type).to eq :value
end
end
- describe '#to_lexeme' do
- it 'returns raw lexeme syntax component name' do
- expect(subject.to_lexeme).to eq 'variable'
+ describe "#to_lexeme" do
+ it "returns raw lexeme syntax component name" do
+ expect(subject.to_lexeme).to eq "variable"
end
end
end
diff --git a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb
index 40dfd893465..382c4e6b3fb 100644
--- a/spec/lib/gitlab/ci/pipeline/preloader_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/preloader_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Preloader do
let(:stage) { double(:stage) }
@@ -10,15 +10,15 @@ describe Gitlab::Ci::Pipeline::Preloader do
double(:pipeline, commit: commit, stages: [stage])
end
- describe '.preload!' do
- context 'when preloading multiple commits' do
+ describe ".preload!" do
+ context "when preloading multiple commits" do
let(:project) { create(:project, :repository) }
- it 'preloads all commits once' do
+ it "preloads all commits once" do
expect(Commit).to receive(:decorate).once.and_call_original
- pipelines = [build_pipeline(ref: 'HEAD'),
- build_pipeline(ref: 'HEAD~1')]
+ pipelines = [build_pipeline(ref: "HEAD"),
+ build_pipeline(ref: "HEAD~1"),]
described_class.preload!(pipelines)
end
@@ -28,7 +28,7 @@ describe Gitlab::Ci::Pipeline::Preloader do
end
end
- it 'preloads commit authors and number of warnings' do
+ it "preloads commit authors and number of warnings" do
expect(commit).to receive(:lazy_author)
expect(pipeline).to receive(:number_of_warnings)
expect(stage).to receive(:number_of_warnings)
@@ -36,7 +36,7 @@ describe Gitlab::Ci::Pipeline::Preloader do
described_class.preload!([pipeline])
end
- it 'returns original collection' do
+ it "returns original collection" do
allow(commit).to receive(:lazy_author)
allow(pipeline).to receive(:number_of_warnings)
allow(stage).to receive(:number_of_warnings)
diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
index fae8add6453..ae976dede57 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
@@ -1,73 +1,73 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Seed::Build do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:attributes) do
- { name: 'rspec', ref: 'master' }
+ {name: "rspec", ref: "master"}
end
subject do
described_class.new(pipeline, attributes)
end
- describe '#attributes' do
- it 'returns hash attributes of a build' do
+ describe "#attributes" do
+ it "returns hash attributes of a build" do
expect(subject.attributes).to be_a Hash
expect(subject.attributes)
.to include(:name, :project, :ref)
end
end
- describe '#bridge?' do
- context 'when job is a bridge' do
+ describe "#bridge?" do
+ context "when job is a bridge" do
let(:attributes) do
- { name: 'rspec', ref: 'master', options: { trigger: 'my/project' } }
+ {name: "rspec", ref: "master", options: {trigger: "my/project"}}
end
it { is_expected.to be_bridge }
end
- context 'when trigger definition is empty' do
+ context "when trigger definition is empty" do
let(:attributes) do
- { name: 'rspec', ref: 'master', options: { trigger: '' } }
+ {name: "rspec", ref: "master", options: {trigger: ""}}
end
it { is_expected.not_to be_bridge }
end
- context 'when job is not a bridge' do
+ context "when job is not a bridge" do
it { is_expected.not_to be_bridge }
end
end
- describe '#to_resource' do
- context 'when job is not a bridge' do
- it 'returns a valid build resource' do
+ describe "#to_resource" do
+ context "when job is not a bridge" do
+ it "returns a valid build resource" do
expect(subject.to_resource).to be_a(::Ci::Build)
expect(subject.to_resource).to be_valid
end
end
- context 'when job is a bridge' do
+ context "when job is a bridge" do
let(:attributes) do
- { name: 'rspec', ref: 'master', options: { trigger: 'my/project' } }
+ {name: "rspec", ref: "master", options: {trigger: "my/project"}}
end
- it 'returns a valid bridge resource' do
+ it "returns a valid bridge resource" do
expect(subject.to_resource).to be_a(::Ci::Bridge)
expect(subject.to_resource).to be_valid
end
end
- it 'memoizes a resource object' do
+ it "memoizes a resource object" do
build = subject.to_resource
expect(build.object_id).to eq subject.to_resource.object_id
end
- it 'can not be persisted without explicit assignment' do
+ it "can not be persisted without explicit assignment" do
build = subject.to_resource
pipeline.save!
@@ -76,113 +76,113 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- describe 'applying only/except policies' do
- context 'when no branch policy is specified' do
- let(:attributes) { { name: 'rspec' } }
+ describe "applying only/except policies" do
+ context "when no branch policy is specified" do
+ let(:attributes) { {name: "rspec"} }
it { is_expected.to be_included }
end
- context 'when branch policy does not match' do
- context 'when using only' do
- let(:attributes) { { name: 'rspec', only: { refs: ['deploy'] } } }
+ context "when branch policy does not match" do
+ context "when using only" do
+ let(:attributes) { {name: "rspec", only: {refs: ["deploy"]}} }
it { is_expected.not_to be_included }
end
- context 'when using except' do
- let(:attributes) { { name: 'rspec', except: { refs: ['deploy'] } } }
+ context "when using except" do
+ let(:attributes) { {name: "rspec", except: {refs: ["deploy"]}} }
it { is_expected.to be_included }
end
end
- context 'when branch regexp policy does not match' do
- context 'when using only' do
- let(:attributes) { { name: 'rspec', only: { refs: ['/^deploy$/'] } } }
+ context "when branch regexp policy does not match" do
+ context "when using only" do
+ let(:attributes) { {name: "rspec", only: {refs: ["/^deploy$/"]}} }
it { is_expected.not_to be_included }
end
- context 'when using except' do
- let(:attributes) { { name: 'rspec', except: { refs: ['/^deploy$/'] } } }
+ context "when using except" do
+ let(:attributes) { {name: "rspec", except: {refs: ["/^deploy$/"]}} }
it { is_expected.to be_included }
end
end
- context 'when branch policy matches' do
- context 'when using only' do
- let(:attributes) { { name: 'rspec', only: { refs: %w[deploy master] } } }
+ context "when branch policy matches" do
+ context "when using only" do
+ let(:attributes) { {name: "rspec", only: {refs: %w[deploy master]}} }
it { is_expected.to be_included }
end
- context 'when using except' do
- let(:attributes) { { name: 'rspec', except: { refs: %w[deploy master] } } }
+ context "when using except" do
+ let(:attributes) { {name: "rspec", except: {refs: %w[deploy master]}} }
it { is_expected.not_to be_included }
end
end
- context 'when keyword policy matches' do
- context 'when using only' do
- let(:attributes) { { name: 'rspec', only: { refs: ['branches'] } } }
+ context "when keyword policy matches" do
+ context "when using only" do
+ let(:attributes) { {name: "rspec", only: {refs: ["branches"]}} }
it { is_expected.to be_included }
end
- context 'when using except' do
- let(:attributes) { { name: 'rspec', except: { refs: ['branches'] } } }
+ context "when using except" do
+ let(:attributes) { {name: "rspec", except: {refs: ["branches"]}} }
it { is_expected.not_to be_included }
end
end
- context 'when keyword policy does not match' do
- context 'when using only' do
- let(:attributes) { { name: 'rspec', only: { refs: ['tags'] } } }
+ context "when keyword policy does not match" do
+ context "when using only" do
+ let(:attributes) { {name: "rspec", only: {refs: ["tags"]}} }
it { is_expected.not_to be_included }
end
- context 'when using except' do
- let(:attributes) { { name: 'rspec', except: { refs: ['tags'] } } }
+ context "when using except" do
+ let(:attributes) { {name: "rspec", except: {refs: ["tags"]}} }
it { is_expected.to be_included }
end
end
- context 'when keywords and pipeline source policy matches' do
+ context "when keywords and pipeline source policy matches" do
possibilities = [%w[pushes push],
%w[web web],
%w[triggers trigger],
%w[schedules schedule],
%w[api api],
- %w[external external]]
+ %w[external external],]
- context 'when using only' do
+ context "when using only" do
possibilities.each do |keyword, source|
context "when using keyword `#{keyword}` and source `#{source}`" do
let(:pipeline) do
- build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
+ build(:ci_empty_pipeline, ref: "deploy", tag: false, source: source)
end
- let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
+ let(:attributes) { {name: "rspec", only: {refs: [keyword]}} }
it { is_expected.to be_included }
end
end
end
- context 'when using except' do
+ context "when using except" do
possibilities.each do |keyword, source|
context "when using keyword `#{keyword}` and source `#{source}`" do
let(:pipeline) do
- build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
+ build(:ci_empty_pipeline, ref: "deploy", tag: false, source: source)
end
- let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
+ let(:attributes) { {name: "rspec", except: {refs: [keyword]}} }
it { is_expected.not_to be_included }
end
@@ -190,36 +190,36 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- context 'when keywords and pipeline source does not match' do
+ context "when keywords and pipeline source does not match" do
possibilities = [%w[pushes web],
%w[web push],
%w[triggers schedule],
%w[schedules external],
%w[api trigger],
- %w[external api]]
+ %w[external api],]
- context 'when using only' do
+ context "when using only" do
possibilities.each do |keyword, source|
context "when using keyword `#{keyword}` and source `#{source}`" do
let(:pipeline) do
- build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
+ build(:ci_empty_pipeline, ref: "deploy", tag: false, source: source)
end
- let(:attributes) { { name: 'rspec', only: { refs: [keyword] } } }
+ let(:attributes) { {name: "rspec", only: {refs: [keyword]}} }
it { is_expected.not_to be_included }
end
end
end
- context 'when using except' do
+ context "when using except" do
possibilities.each do |keyword, source|
context "when using keyword `#{keyword}` and source `#{source}`" do
let(:pipeline) do
- build(:ci_empty_pipeline, ref: 'deploy', tag: false, source: source)
+ build(:ci_empty_pipeline, ref: "deploy", tag: false, source: source)
end
- let(:attributes) { { name: 'rspec', except: { refs: [keyword] } } }
+ let(:attributes) { {name: "rspec", except: {refs: [keyword]}} }
it { is_expected.to be_included }
end
@@ -227,36 +227,36 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
- context 'when repository path matches' do
- context 'when using only' do
+ context "when repository path matches" do
+ context "when using only" do
let(:attributes) do
- { name: 'rspec', only: { refs: ["branches@#{pipeline.project_full_path}"] } }
+ {name: "rspec", only: {refs: ["branches@#{pipeline.project_full_path}"]}}
end
it { is_expected.to be_included }
end
- context 'when using except' do
+ context "when using except" do
let(:attributes) do
- { name: 'rspec', except: { refs: ["branches@#{pipeline.project_full_path}"] } }
+ {name: "rspec", except: {refs: ["branches@#{pipeline.project_full_path}"]}}
end
it { is_expected.not_to be_included }
end
end
- context 'when repository path does not matches' do
- context 'when using only' do
+ context "when repository path does not matches" do
+ context "when using only" do
let(:attributes) do
- { name: 'rspec', only: { refs: ['branches@fork'] } }
+ {name: "rspec", only: {refs: ["branches@fork"]}}
end
it { is_expected.not_to be_included }
end
- context 'when using except' do
+ context "when using except" do
let(:attributes) do
- { name: 'rspec', except: { refs: ['branches@fork'] } }
+ {name: "rspec", except: {refs: ["branches@fork"]}}
end
it { is_expected.to be_included }
diff --git a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
index 493ca3cd7b5..b83607d3b18 100644
--- a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+++ b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
@@ -1,114 +1,114 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Pipeline::Seed::Stage do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:attributes) do
- { name: 'test',
- index: 0,
- builds: [{ name: 'rspec' },
- { name: 'spinach' },
- { name: 'deploy', only: { refs: ['feature'] } }] }
+ {name: "test",
+ index: 0,
+ builds: [{name: "rspec"},
+ {name: "spinach"},
+ {name: "deploy", only: {refs: ["feature"]}},],}
end
subject do
described_class.new(pipeline, attributes)
end
- describe '#size' do
- it 'returns a number of jobs in the stage' do
+ describe "#size" do
+ it "returns a number of jobs in the stage" do
expect(subject.size).to eq 2
end
end
- describe '#attributes' do
- it 'returns hash attributes of a stage' do
+ describe "#attributes" do
+ it "returns hash attributes of a stage" do
expect(subject.attributes).to be_a Hash
expect(subject.attributes)
.to include(:name, :position, :pipeline, :project)
end
end
- describe '#included?' do
- context 'when it contains builds seeds' do
+ describe "#included?" do
+ context "when it contains builds seeds" do
let(:attributes) do
- { name: 'test',
- index: 0,
- builds: [{ name: 'deploy', only: { refs: ['master'] } }] }
+ {name: "test",
+ index: 0,
+ builds: [{name: "deploy", only: {refs: ["master"]}}],}
end
it { is_expected.to be_included }
end
- context 'when it does not contain build seeds' do
+ context "when it does not contain build seeds" do
let(:attributes) do
- { name: 'test',
- index: 0,
- builds: [{ name: 'deploy', only: { refs: ['feature'] } }] }
+ {name: "test",
+ index: 0,
+ builds: [{name: "deploy", only: {refs: ["feature"]}}],}
end
it { is_expected.not_to be_included }
end
end
- describe '#seeds' do
- it 'returns build seeds' do
+ describe "#seeds" do
+ it "returns build seeds" do
expect(subject.seeds).to all(be_a Gitlab::Ci::Pipeline::Seed::Build)
end
- it 'returns build seeds including valid attributes' do
+ it "returns build seeds including valid attributes" do
expect(subject.seeds.size).to eq 2
- expect(subject.seeds.map(&:attributes)).to all(include(ref: 'master'))
+ expect(subject.seeds.map(&:attributes)).to all(include(ref: "master"))
expect(subject.seeds.map(&:attributes)).to all(include(tag: false))
expect(subject.seeds.map(&:attributes)).to all(include(project: pipeline.project))
end
- context 'when a legacy trigger exists' do
+ context "when a legacy trigger exists" do
before do
create(:ci_trigger_request, pipeline: pipeline)
end
- it 'returns build seeds including legacy trigger' do
+ it "returns build seeds including legacy trigger" do
expect(pipeline.legacy_trigger).not_to be_nil
expect(subject.seeds.map(&:attributes))
.to all(include(trigger_request: pipeline.legacy_trigger))
end
end
- context 'when a ref is protected' do
+ context "when a ref is protected" do
before do
allow_any_instance_of(Project).to receive(:protected_for?).and_return(true)
end
- it 'returns protected builds' do
+ it "returns protected builds" do
expect(subject.seeds.map(&:attributes)).to all(include(protected: true))
end
end
- context 'when a ref is not protected' do
+ context "when a ref is not protected" do
before do
allow_any_instance_of(Project).to receive(:protected_for?).and_return(false)
end
- it 'returns unprotected builds' do
+ it "returns unprotected builds" do
expect(subject.seeds.map(&:attributes)).to all(include(protected: false))
end
end
- it 'filters seeds using only/except policies' do
+ it "filters seeds using only/except policies" do
expect(subject.seeds.map(&:attributes)).to satisfy do |seeds|
- seeds.any? { |hash| hash.fetch(:name) == 'rspec' }
+ seeds.any? { |hash| hash.fetch(:name) == "rspec" }
end
expect(subject.seeds.map(&:attributes)).not_to satisfy do |seeds|
- seeds.any? { |hash| hash.fetch(:name) == 'deploy' }
+ seeds.any? { |hash| hash.fetch(:name) == "deploy" }
end
end
end
- describe '#to_resource' do
- it 'builds a valid stage object with all builds' do
+ describe "#to_resource" do
+ it "builds a valid stage object with all builds" do
subject.to_resource.save!
expect(pipeline.reload.stages.count).to eq 1
@@ -122,7 +122,7 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
.to all(satisfy { |stage| stage.project.present? })
end
- it 'can not be persisted without explicit pipeline assignment' do
+ it "can not be persisted without explicit pipeline assignment" do
stage = subject.to_resource
pipeline.save!
diff --git a/spec/lib/gitlab/ci/reports/test_case_spec.rb b/spec/lib/gitlab/ci/reports/test_case_spec.rb
index 6932f79f0ce..76d48b246b3 100644
--- a/spec/lib/gitlab/ci/reports/test_case_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_case_spec.rb
@@ -1,88 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Reports::TestCase do
- describe '#initialize' do
+ describe "#initialize" do
let(:test_case) { described_class.new(**params)}
- context 'when both classname and name are given' do
- context 'when test case is passed' do
+ context "when both classname and name are given" do
+ context "when test case is passed" do
let(:params) do
{
- name: 'test-1',
- classname: 'trace',
- file: 'spec/trace_spec.rb',
+ name: "test-1",
+ classname: "trace",
+ file: "spec/trace_spec.rb",
execution_time: 1.23,
status: described_class::STATUS_SUCCESS,
- system_output: nil
+ system_output: nil,
}
end
- it 'initializes an instance' do
+ it "initializes an instance" do
expect { test_case }.not_to raise_error
- expect(test_case.name).to eq('test-1')
- expect(test_case.classname).to eq('trace')
- expect(test_case.file).to eq('spec/trace_spec.rb')
+ expect(test_case.name).to eq("test-1")
+ expect(test_case.classname).to eq("trace")
+ expect(test_case.file).to eq("spec/trace_spec.rb")
expect(test_case.execution_time).to eq(1.23)
expect(test_case.status).to eq(described_class::STATUS_SUCCESS)
expect(test_case.system_output).to be_nil
end
end
- context 'when test case is failed' do
+ context "when test case is failed" do
let(:params) do
{
- name: 'test-1',
- classname: 'trace',
- file: 'spec/trace_spec.rb',
+ name: "test-1",
+ classname: "trace",
+ file: "spec/trace_spec.rb",
execution_time: 1.23,
status: described_class::STATUS_FAILED,
- system_output: "Failure/Error: is_expected.to eq(300) expected: 300 got: -100"
+ system_output: "Failure/Error: is_expected.to eq(300) expected: 300 got: -100",
}
end
- it 'initializes an instance' do
+ it "initializes an instance" do
expect { test_case }.not_to raise_error
- expect(test_case.name).to eq('test-1')
- expect(test_case.classname).to eq('trace')
- expect(test_case.file).to eq('spec/trace_spec.rb')
+ expect(test_case.name).to eq("test-1")
+ expect(test_case.classname).to eq("trace")
+ expect(test_case.file).to eq("spec/trace_spec.rb")
expect(test_case.execution_time).to eq(1.23)
expect(test_case.status).to eq(described_class::STATUS_FAILED)
expect(test_case.system_output)
- .to eq('Failure/Error: is_expected.to eq(300) expected: 300 got: -100')
+ .to eq("Failure/Error: is_expected.to eq(300) expected: 300 got: -100")
end
end
end
- context 'when classname is missing' do
+ context "when classname is missing" do
let(:params) do
{
- name: 'test-1',
- file: 'spec/trace_spec.rb',
+ name: "test-1",
+ file: "spec/trace_spec.rb",
execution_time: 1.23,
status: described_class::STATUS_SUCCESS,
- system_output: nil
+ system_output: nil,
}
end
- it 'raises an error' do
+ it "raises an error" do
expect { test_case }.to raise_error(ArgumentError)
end
end
- context 'when name is missing' do
+ context "when name is missing" do
let(:params) do
{
- classname: 'trace',
- file: 'spec/trace_spec.rb',
+ classname: "trace",
+ file: "spec/trace_spec.rb",
execution_time: 1.23,
status: described_class::STATUS_SUCCESS,
- system_output: nil
+ system_output: nil,
}
end
- it 'raises an error' do
+ it "raises an error" do
expect { test_case }.to raise_error(ArgumentError)
end
end
diff --git a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb
index 71c61e0345f..fce5e5f711b 100644
--- a/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_reports_comparer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Reports::TestReportsComparer do
include TestReportsHelper
@@ -7,73 +7,73 @@ describe Gitlab::Ci::Reports::TestReportsComparer do
let(:base_reports) { Gitlab::Ci::Reports::TestReports.new }
let(:head_reports) { Gitlab::Ci::Reports::TestReports.new }
- describe '#suite_comparers' do
+ describe "#suite_comparers" do
subject { comparer.suite_comparers }
- context 'when head and base reports include two test suites' do
+ context "when head and base reports include two test suites" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_success)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'returns test suite comparers with specified values' do
+ it "returns test suite comparers with specified values" do
expect(subject[0]).to be_a(Gitlab::Ci::Reports::TestSuiteComparer)
- expect(subject[0].name).to eq('rspec')
- expect(subject[0].head_suite).to eq(head_reports.get_suite('rspec'))
- expect(subject[0].base_suite).to eq(base_reports.get_suite('rspec'))
+ expect(subject[0].name).to eq("rspec")
+ expect(subject[0].head_suite).to eq(head_reports.get_suite("rspec"))
+ expect(subject[0].base_suite).to eq(base_reports.get_suite("rspec"))
expect(subject[1]).to be_a(Gitlab::Ci::Reports::TestSuiteComparer)
- expect(subject[1].name).to eq('junit')
- expect(subject[1].head_suite).to eq(head_reports.get_suite('junit'))
- expect(subject[1].base_suite).to eq(base_reports.get_suite('junit'))
+ expect(subject[1].name).to eq("junit")
+ expect(subject[1].head_suite).to eq(head_reports.get_suite("junit"))
+ expect(subject[1].base_suite).to eq(base_reports.get_suite("junit"))
end
end
end
- describe '#total_status' do
+ describe "#total_status" do
subject { comparer.total_status }
- context 'when all tests cases are success in head suites' do
+ context "when all tests cases are success in head suites" do
before do
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'returns the total status' do
+ it "returns the total status" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
end
- context 'when there is a failed test case in head suites' do
+ context "when there is a failed test case in head suites" do
before do
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'returns the total status in head suite' do
+ it "returns the total status in head suite" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
end
end
- describe '#total_count' do
+ describe "#total_count" do
subject { comparer.total_count }
before do
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'returns the total test counts in head suites' do
+ it "returns the total test counts in head suites" do
is_expected.to eq(2)
end
end
- describe '#resolved_count' do
+ describe "#resolved_count" do
subject { comparer.resolved_count }
- context 'when there is a resolved test case in head suites' do
+ context "when there is a resolved test case in head suites" do
let(:create_test_case_java_resolved) do
create_test_case_java_failed.tap do |test_case|
test_case.instance_variable_set("@status", Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
@@ -81,52 +81,52 @@ describe Gitlab::Ci::Reports::TestReportsComparer do
end
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_resolved)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_resolved)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(1)
end
end
- context 'when there are no resolved test cases in head suites' do
+ context "when there are no resolved test cases in head suites" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(0)
end
end
end
- describe '#failed_count' do
+ describe "#failed_count" do
subject { comparer.failed_count }
- context 'when there is a failed test case in head suites' do
+ context "when there is a failed test case in head suites" do
before do
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(1)
end
end
- context 'when there are no failed test cases in head suites' do
+ context "when there are no failed test cases in head suites" do
before do
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_rspec_success)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(0)
end
end
diff --git a/spec/lib/gitlab/ci/reports/test_reports_spec.rb b/spec/lib/gitlab/ci/reports/test_reports_spec.rb
index 74ff134b239..5ce4db3d18b 100644
--- a/spec/lib/gitlab/ci/reports/test_reports_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_reports_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Reports::TestReports do
include TestReportsHelper
let(:test_reports) { described_class.new }
- describe '#get_suite' do
+ describe "#get_suite" do
subject { test_reports.get_suite(suite_name) }
- context 'when suite name is rspec' do
- let(:suite_name) { 'rspec' }
+ context "when suite name is rspec" do
+ let(:suite_name) { "rspec" }
- it { expect(subject.name).to eq('rspec') }
+ it { expect(subject.name).to eq("rspec") }
- it 'initializes a new test suite and returns it' do
+ it "initializes a new test suite and returns it" do
expect(Gitlab::Ci::Reports::TestSuite).to receive(:new).and_call_original
is_expected.to be_a(Gitlab::Ci::Reports::TestSuite)
end
- context 'when suite name is already allocated' do
+ context "when suite name is already allocated" do
before do
subject
end
- it 'does not initialize a new test suite' do
+ it "does not initialize a new test suite" do
expect(Gitlab::Ci::Reports::TestSuite).not_to receive(:new)
is_expected.to be_a(Gitlab::Ci::Reports::TestSuite)
@@ -33,75 +33,75 @@ describe Gitlab::Ci::Reports::TestReports do
end
end
- describe '#total_time' do
+ describe "#total_time" do
subject { test_reports.total_time }
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'returns the total time' do
+ it "returns the total time" do
is_expected.to eq(6.66)
end
end
- describe '#total_count' do
+ describe "#total_count" do
subject { test_reports.total_count }
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'returns the total count' do
+ it "returns the total count" do
is_expected.to eq(2)
end
end
- describe '#total_status' do
+ describe "#total_status" do
subject { test_reports.total_status }
- context 'when all test cases succeeded' do
+ context "when all test cases succeeded" do
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'returns correct total status' do
+ it "returns correct total status" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
end
- context 'when there is a failed test case' do
+ context "when there is a failed test case" do
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'returns correct total status' do
+ it "returns correct total status" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
end
- context 'when there is a skipped test case' do
+ context "when there is a skipped test case" do
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_skipped)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_skipped)
end
- it 'returns correct total status' do
+ it "returns correct total status" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
end
- context 'when there is an error test case' do
+ context "when there is an error test case" do
before do
- test_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- test_reports.get_suite('junit').add_test_case(create_test_case_java_error)
+ test_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ test_reports.get_suite("junit").add_test_case(create_test_case_java_error)
end
- it 'returns correct total status' do
+ it "returns correct total status" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
end
@@ -113,17 +113,17 @@ describe Gitlab::Ci::Reports::TestReports do
context "when #{status_type} test case exists" do
before do
- test_reports.get_suite('rspec').add_test_case(public_send("create_test_case_rspec_#{status_type}"))
- test_reports.get_suite('junit').add_test_case(public_send("create_test_case_java_#{status_type}"))
+ test_reports.get_suite("rspec").add_test_case(public_send("create_test_case_rspec_#{status_type}"))
+ test_reports.get_suite("junit").add_test_case(public_send("create_test_case_java_#{status_type}"))
end
- it 'returns the count' do
+ it "returns the count" do
is_expected.to eq(2)
end
end
context "when #{status_type} test case do not exist" do
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be(0)
end
end
diff --git a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb
index 6ab16e5518d..384ce22e53f 100644
--- a/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_suite_comparer_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Reports::TestSuiteComparer do
include TestReportsHelper
let(:comparer) { described_class.new(name, base_suite, head_suite) }
- let(:name) { 'rpsec' }
+ let(:name) { "rpsec" }
let(:base_suite) { Gitlab::Ci::Reports::TestSuite.new(name) }
let(:head_suite) { Gitlab::Ci::Reports::TestSuite.new(name) }
let(:test_case_success) { create_test_case_rspec_success }
@@ -16,145 +16,145 @@ describe Gitlab::Ci::Reports::TestSuiteComparer do
end
end
- describe '#new_failures' do
+ describe "#new_failures" do
subject { comparer.new_failures }
- context 'when head sutie has a newly failed test case which does not exist in base' do
+ context "when head sutie has a newly failed test case which does not exist in base" do
before do
base_suite.add_test_case(test_case_success)
head_suite.add_test_case(test_case_failed)
end
- it 'returns the failed test case' do
+ it "returns the failed test case" do
is_expected.to eq([test_case_failed])
end
end
- context 'when head sutie still has a failed test case which failed in base' do
+ context "when head sutie still has a failed test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_failed)
end
- it 'does not return the failed test case' do
+ it "does not return the failed test case" do
is_expected.to be_empty
end
end
- context 'when head sutie has a success test case which failed in base' do
+ context "when head sutie has a success test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_resolved)
end
- it 'does not return the failed test case' do
+ it "does not return the failed test case" do
is_expected.to be_empty
end
end
end
- describe '#existing_failures' do
+ describe "#existing_failures" do
subject { comparer.existing_failures }
- context 'when head sutie has a newly failed test case which does not exist in base' do
+ context "when head sutie has a newly failed test case which does not exist in base" do
before do
base_suite.add_test_case(test_case_success)
head_suite.add_test_case(test_case_failed)
end
- it 'returns the failed test case' do
+ it "returns the failed test case" do
is_expected.to be_empty
end
end
- context 'when head sutie still has a failed test case which failed in base' do
+ context "when head sutie still has a failed test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_failed)
end
- it 'does not return the failed test case' do
+ it "does not return the failed test case" do
is_expected.to eq([test_case_failed])
end
end
- context 'when head sutie has a success test case which failed in base' do
+ context "when head sutie has a success test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_resolved)
end
- it 'does not return the failed test case' do
+ it "does not return the failed test case" do
is_expected.to be_empty
end
end
end
- describe '#resolved_failures' do
+ describe "#resolved_failures" do
subject { comparer.resolved_failures }
- context 'when head sutie has a newly failed test case which does not exist in base' do
+ context "when head sutie has a newly failed test case which does not exist in base" do
before do
base_suite.add_test_case(test_case_success)
head_suite.add_test_case(test_case_failed)
end
- it 'returns the failed test case' do
+ it "returns the failed test case" do
is_expected.to be_empty
end
- it 'returns the correct resolved count' do
+ it "returns the correct resolved count" do
expect(comparer.resolved_count).to eq(0)
end
end
- context 'when head sutie still has a failed test case which failed in base' do
+ context "when head sutie still has a failed test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_failed)
end
- it 'does not return the failed test case' do
+ it "does not return the failed test case" do
is_expected.to be_empty
end
- it 'returns the correct resolved count' do
+ it "returns the correct resolved count" do
expect(comparer.resolved_count).to eq(0)
end
end
- context 'when head sutie has a success test case which failed in base' do
+ context "when head sutie has a success test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_resolved)
end
- it 'does not return the resolved test case' do
+ it "does not return the resolved test case" do
is_expected.to eq([test_case_resolved])
end
- it 'returns the correct resolved count' do
+ it "returns the correct resolved count" do
expect(comparer.resolved_count).to eq(1)
end
end
end
- describe '#total_count' do
+ describe "#total_count" do
subject { comparer.total_count }
before do
head_suite.add_test_case(test_case_success)
end
- it 'returns the total test counts in head suite' do
+ it "returns the total test counts in head suite" do
is_expected.to eq(1)
end
end
- describe '#failed_count' do
+ describe "#failed_count" do
subject { comparer.failed_count }
- context 'when there are a new failure and an existing failure' do
+ context "when there are a new failure and an existing failure" do
let(:test_case_1_success) { create_test_case_rspec_success }
let(:test_case_2_failed) { create_test_case_rspec_failed }
@@ -171,53 +171,53 @@ describe Gitlab::Ci::Reports::TestSuiteComparer do
head_suite.add_test_case(test_case_2_failed)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(2)
end
end
- context 'when there is a new failure' do
+ context "when there is a new failure" do
before do
base_suite.add_test_case(test_case_success)
head_suite.add_test_case(test_case_failed)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(1)
end
end
- context 'when there is an existing failure' do
+ context "when there is an existing failure" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_failed)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
is_expected.to eq(1)
end
end
end
- describe '#total_status' do
+ describe "#total_status" do
subject { comparer.total_status }
- context 'when all test cases in head suite are success' do
+ context "when all test cases in head suite are success" do
before do
head_suite.add_test_case(test_case_success)
end
- it 'returns the total status in head suite' do
+ it "returns the total status in head suite" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
end
end
- context 'when there is a failed test case in head suite' do
+ context "when there is a failed test case in head suite" do
before do
head_suite.add_test_case(test_case_failed)
end
- it 'returns the total status in head suite' do
+ it "returns the total status in head suite" do
is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
end
end
diff --git a/spec/lib/gitlab/ci/reports/test_suite_spec.rb b/spec/lib/gitlab/ci/reports/test_suite_spec.rb
index cd34dbaf62f..e58ccdca0e6 100644
--- a/spec/lib/gitlab/ci/reports/test_suite_spec.rb
+++ b/spec/lib/gitlab/ci/reports/test_suite_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Reports::TestSuite do
include TestReportsHelper
- let(:test_suite) { described_class.new('Rspec') }
+ let(:test_suite) { described_class.new("Rspec") }
let(:test_case_success) { create_test_case_rspec_success }
let(:test_case_failed) { create_test_case_rspec_failed }
let(:test_case_skipped) { create_test_case_rspec_skipped }
let(:test_case_error) { create_test_case_rspec_error }
- it { expect(test_suite.name).to eq('Rspec') }
+ it { expect(test_suite.name).to eq("Rspec") }
- describe '#add_test_case' do
- context 'when status of the test case is success' do
- it 'stores data correctly' do
+ describe "#add_test_case" do
+ context "when status of the test case is success" do
+ it "stores data correctly" do
test_suite.add_test_case(test_case_success)
expect(test_suite.test_cases[test_case_success.status][test_case_success.key])
@@ -22,8 +22,8 @@ describe Gitlab::Ci::Reports::TestSuite do
end
end
- context 'when status of the test case is failed' do
- it 'stores data correctly' do
+ context "when status of the test case is failed" do
+ it "stores data correctly" do
test_suite.add_test_case(test_case_failed)
expect(test_suite.test_cases[test_case_failed.status][test_case_failed.key])
@@ -32,8 +32,8 @@ describe Gitlab::Ci::Reports::TestSuite do
end
end
- context 'when two test cases are added' do
- it 'sums up total time' do
+ context "when two test cases are added" do
+ it "sums up total time" do
test_suite.add_test_case(test_case_success)
test_suite.add_test_case(test_case_failed)
@@ -42,7 +42,7 @@ describe Gitlab::Ci::Reports::TestSuite do
end
end
- describe '#total_count' do
+ describe "#total_count" do
subject { test_suite.total_count }
before do
@@ -53,10 +53,10 @@ describe Gitlab::Ci::Reports::TestSuite do
it { is_expected.to eq(2) }
end
- describe '#total_status' do
+ describe "#total_status" do
subject { test_suite.total_status }
- context 'when all test cases succeeded' do
+ context "when all test cases succeeded" do
before do
test_suite.add_test_case(test_case_success)
end
@@ -64,7 +64,7 @@ describe Gitlab::Ci::Reports::TestSuite do
it { is_expected.to eq(Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS) }
end
- context 'when a test case failed' do
+ context "when a test case failed" do
before do
test_suite.add_test_case(test_case_success)
test_suite.add_test_case(test_case_failed)
@@ -76,20 +76,20 @@ describe Gitlab::Ci::Reports::TestSuite do
Gitlab::Ci::Reports::TestCase::STATUS_TYPES.each do |status_type|
describe "##{status_type}" do
- subject { test_suite.public_send("#{status_type}") }
+ subject { test_suite.public_send(status_type.to_s) }
context "when #{status_type} test case exists" do
before do
test_suite.add_test_case(public_send("test_case_#{status_type}"))
end
- it 'returns all success test cases' do
- is_expected.to eq( { public_send("test_case_#{status_type}").key => public_send("test_case_#{status_type}") })
+ it "returns all success test cases" do
+ is_expected.to eq({public_send("test_case_#{status_type}").key => public_send("test_case_#{status_type}")})
end
end
context "when #{status_type} test case do not exist" do
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
@@ -105,13 +105,13 @@ describe Gitlab::Ci::Reports::TestSuite do
test_suite.add_test_case(public_send("test_case_#{status_type}"))
end
- it 'returns the count' do
+ it "returns the count" do
is_expected.to eq(1)
end
end
context "when #{status_type} test case do not exist" do
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be(0)
end
end
diff --git a/spec/lib/gitlab/ci/status/build/action_spec.rb b/spec/lib/gitlab/ci/status/build/action_spec.rb
index bdec582b57b..e98083937e8 100644
--- a/spec/lib/gitlab/ci/status/build/action_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/action_spec.rb
@@ -1,66 +1,66 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Action do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject do
described_class.new(status)
end
- describe '#label' do
+ describe "#label" do
before do
- allow(status).to receive(:label).and_return('label')
+ allow(status).to receive(:label).and_return("label")
end
- context 'when status has action' do
+ context "when status has action" do
before do
allow(status).to receive(:has_action?).and_return(true)
end
- it 'does not append text' do
- expect(subject.label).to eq 'label'
+ it "does not append text" do
+ expect(subject.label).to eq "label"
end
end
- context 'when status does not have action' do
+ context "when status does not have action" do
before do
allow(status).to receive(:has_action?).and_return(false)
end
- it 'appends text about action not allowed' do
- expect(subject.label).to eq 'label (not allowed)'
+ it "appends text about action not allowed" do
+ expect(subject.label).to eq "label (not allowed)"
end
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is playable action' do
+ context "when build is playable action" do
let(:build) { create(:ci_build, :playable) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not playable action' do
+ context "when build is not playable action" do
let(:build) { create(:ci_build, :non_playable) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :non_playable) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- it 'returns the status' do
- expect(subject.badge_tooltip).to eq('created')
+ it "returns the status" do
+ expect(subject.badge_tooltip).to eq("created")
end
end
end
diff --git a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb
index 78d6fa65b5a..ab8f20f9b80 100644
--- a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb
@@ -1,70 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Cancelable do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject do
described_class.new(status)
end
- describe '#text' do
- it 'does not override status text' do
+ describe "#text" do
+ it "does not override status text" do
expect(status).to receive(:text)
subject.text
end
end
- describe '#icon' do
- it 'does not override status icon' do
+ describe "#icon" do
+ it "does not override status icon" do
expect(status).to receive(:icon)
subject.icon
end
end
- describe '#label' do
- it 'does not override status label' do
+ describe "#label" do
+ it "does not override status label" do
expect(status).to receive(:label)
subject.label
end
end
- describe '#group' do
- it 'does not override status group' do
+ describe "#group" do
+ it "does not override status group" do
expect(status).to receive(:group)
subject.group
end
end
- describe '#status_tooltip' do
- it 'does not override status status_tooltip' do
+ describe "#status_tooltip" do
+ it "does not override status status_tooltip" do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- it 'returns the status' do
- expect(subject.badge_tooltip).to eq('pending')
+ it "returns the status" do
+ expect(subject.badge_tooltip).to eq("pending")
end
end
- describe 'action details' do
+ describe "action details" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- describe '#has_action?' do
- context 'when user is allowed to update build' do
+ describe "#has_action?" do
+ context "when user is allowed to update build" do
before do
stub_not_protect_default_branch
@@ -74,45 +74,45 @@ describe Gitlab::Ci::Status::Build::Cancelable do
it { is_expected.to have_action }
end
- context 'when user is not allowed to update build' do
+ context "when user is not allowed to update build" do
it { is_expected.not_to have_action }
end
end
- describe '#action_path' do
+ describe "#action_path" do
it { expect(subject.action_path).to include "#{build.id}/cancel" }
end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'cancel' }
+ describe "#action_icon" do
+ it { expect(subject.action_icon).to eq "cancel" }
end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Cancel' }
+ describe "#action_title" do
+ it { expect(subject.action_title).to eq "Cancel" }
end
- describe '#action_button_title' do
- it { expect(subject.action_button_title).to eq 'Cancel this job' }
+ describe "#action_button_title" do
+ it { expect(subject.action_button_title).to eq "Cancel this job" }
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is cancelable' do
+ context "when build is cancelable" do
let(:build) do
create(:ci_build, :running)
end
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not cancelable' do
+ context "when build is not cancelable" do
let(:build) { create(:ci_build, :success) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/canceled_spec.rb b/spec/lib/gitlab/ci/status/build/canceled_spec.rb
index c6b5cc68770..2c88aa0f375 100644
--- a/spec/lib/gitlab/ci/status/build/canceled_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/canceled_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Canceled do
let(:user) { create(:user) }
subject do
- described_class.new(double('subject'))
+ described_class.new(double("subject"))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject {described_class.matches?(build, user) }
- context 'when build is canceled' do
+ context "when build is canceled" do
let(:build) { create(:ci_build, :canceled) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not canceled' do
+ context "when build is not canceled" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/common_spec.rb b/spec/lib/gitlab/ci/status/build/common_spec.rb
index ca3c66f0152..6e9b9c8eb62 100644
--- a/spec/lib/gitlab/ci/status/build/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/common_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Common do
let(:user) { create(:user) }
@@ -11,12 +11,12 @@ describe Gitlab::Ci::Status::Build::Common do
.extend(described_class)
end
- describe '#has_action?' do
+ describe "#has_action?" do
it { is_expected.not_to have_action }
end
- describe '#has_details?' do
- context 'when user has access to read build' do
+ describe "#has_details?" do
+ context "when user has access to read build" do
before do
project.add_developer(user)
end
@@ -24,7 +24,7 @@ describe Gitlab::Ci::Status::Build::Common do
it { is_expected.to have_details }
end
- context 'when user does not have access to read build' do
+ context "when user does not have access to read build" do
before do
project.update(public_builds: false)
end
@@ -33,14 +33,14 @@ describe Gitlab::Ci::Status::Build::Common do
end
end
- describe '#details_path' do
- it 'links to the build details page' do
+ describe "#details_path" do
+ it "links to the build details page" do
expect(subject.details_path).to include "jobs/#{build.id}"
end
end
- describe '#illustration' do
- it 'provides a fallback empty state illustration' do
+ describe "#illustration" do
+ it "provides a fallback empty state illustration" do
expect(subject.illustration).not_to be_empty
end
end
diff --git a/spec/lib/gitlab/ci/status/build/created_spec.rb b/spec/lib/gitlab/ci/status/build/created_spec.rb
index 8bdfe6ef7a2..3df8189cc02 100644
--- a/spec/lib/gitlab/ci/status/build/created_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/created_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Created do
let(:user) { create(:user) }
subject do
- described_class.new(double('subject'))
+ described_class.new(double("subject"))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title, :content) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject {described_class.matches?(build, user) }
- context 'when build is created' do
+ context "when build is created" do
let(:build) { create(:ci_build, :created) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not created' do
+ context "when build is not created" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/erased_spec.rb b/spec/lib/gitlab/ci/status/build/erased_spec.rb
index 0acd271e375..a76803b3f73 100644
--- a/spec/lib/gitlab/ci/status/build/erased_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/erased_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Erased do
let(:user) { create(:user) }
subject do
- described_class.new(double('subject'))
+ described_class.new(double("subject"))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is erased' do
+ context "when build is erased" do
let(:build) { create(:ci_build, :success, :erased) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not erased' do
+ context "when build is not erased" do
let(:build) { create(:ci_build, :success, :trace_artifact) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb
index b379b08ad62..bc8cf55b320 100644
--- a/spec/lib/gitlab/ci/status/build/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Factory do
let(:user) { create(:user) }
@@ -12,307 +12,307 @@ describe Gitlab::Ci::Status::Build::Factory do
project.add_developer(user)
end
- context 'when build is successful' do
+ context "when build is successful" do
let(:build) { create(:ci_build, :success, :trace_artifact) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Retryable]
end
- it 'fabricates a retryable build status' do
+ it "fabricates a retryable build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Retryable
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'passed'
- expect(status.icon).to eq 'status_success'
- expect(status.favicon).to eq 'favicon_status_success'
- expect(status.label).to eq 'passed'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "passed"
+ expect(status.icon).to eq "status_success"
+ expect(status.favicon).to eq "favicon_status_success"
+ expect(status.label).to eq "passed"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is erased' do
+ context "when build is erased" do
let(:build) { create(:ci_build, :success, :erased) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Erased,
- Gitlab::Ci::Status::Build::Retryable]
+ Gitlab::Ci::Status::Build::Retryable,]
end
- it 'fabricates a retryable build status' do
+ it "fabricates a retryable build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Retryable
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'passed'
- expect(status.icon).to eq 'status_success'
- expect(status.favicon).to eq 'favicon_status_success'
- expect(status.label).to eq 'passed'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "passed"
+ expect(status.icon).to eq "status_success"
+ expect(status.favicon).to eq "favicon_status_success"
+ expect(status.label).to eq "passed"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is failed' do
- context 'when build is not allowed to fail' do
+ context "when build is failed" do
+ context "when build is not allowed to fail" do
let(:build) { create(:ci_build, :failed) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Failed
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Retryable,
- Gitlab::Ci::Status::Build::Failed]
+ Gitlab::Ci::Status::Build::Failed,]
end
- it 'fabricates a failed build status' do
+ it "fabricates a failed build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Failed
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'failed'
- expect(status.icon).to eq 'status_failed'
- expect(status.favicon).to eq 'favicon_status_failed'
- expect(status.label).to eq 'failed'
- expect(status.status_tooltip).to eq 'failed - (unknown failure)'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "failed"
+ expect(status.icon).to eq "status_failed"
+ expect(status.favicon).to eq "favicon_status_failed"
+ expect(status.label).to eq "failed"
+ expect(status.status_tooltip).to eq "failed - (unknown failure)"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is allowed to fail' do
+ context "when build is allowed to fail" do
let(:build) { create(:ci_build, :failed, :allowed_to_fail, :trace_artifact) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Failed
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Retryable,
Gitlab::Ci::Status::Build::Failed,
- Gitlab::Ci::Status::Build::FailedAllowed]
+ Gitlab::Ci::Status::Build::FailedAllowed,]
end
- it 'fabricates a failed but allowed build status' do
+ it "fabricates a failed but allowed build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::FailedAllowed
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'failed'
- expect(status.icon).to eq 'status_warning'
- expect(status.favicon).to eq 'favicon_status_failed'
- expect(status.label).to eq 'failed (allowed to fail)'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "failed"
+ expect(status.icon).to eq "status_warning"
+ expect(status.favicon).to eq "favicon_status_failed"
+ expect(status.label).to eq "failed (allowed to fail)"
expect(status).to have_details
expect(status).to have_action
- expect(status.action_title).to include 'Retry'
- expect(status.action_path).to include 'retry'
+ expect(status.action_title).to include "Retry"
+ expect(status.action_path).to include "retry"
end
end
end
- context 'when build is a canceled' do
+ context "when build is a canceled" do
let(:build) { create(:ci_build, :canceled) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Canceled
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Canceled, Gitlab::Ci::Status::Build::Retryable]
end
- it 'fabricates a retryable build status' do
+ it "fabricates a retryable build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Retryable
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'canceled'
- expect(status.icon).to eq 'status_canceled'
- expect(status.favicon).to eq 'favicon_status_canceled'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "canceled"
+ expect(status.icon).to eq "status_canceled"
+ expect(status.favicon).to eq "favicon_status_canceled"
expect(status.illustration).to include(:image, :size, :title)
- expect(status.label).to eq 'canceled'
+ expect(status.label).to eq "canceled"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is running' do
+ context "when build is running" do
let(:build) { create(:ci_build, :running) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Running
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Cancelable]
end
- it 'fabricates a canceable build status' do
+ it "fabricates a canceable build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Cancelable
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'running'
- expect(status.icon).to eq 'status_running'
- expect(status.favicon).to eq 'favicon_status_running'
- expect(status.label).to eq 'running'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "running"
+ expect(status.icon).to eq "status_running"
+ expect(status.favicon).to eq "favicon_status_running"
+ expect(status.label).to eq "running"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is pending' do
+ context "when build is pending" do
let(:build) { create(:ci_build, :pending) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Pending
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Pending, Gitlab::Ci::Status::Build::Cancelable]
end
- it 'fabricates a cancelable build status' do
+ it "fabricates a cancelable build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Cancelable
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'pending'
- expect(status.icon).to eq 'status_pending'
- expect(status.favicon).to eq 'favicon_status_pending'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "pending"
+ expect(status.icon).to eq "status_pending"
+ expect(status.favicon).to eq "favicon_status_pending"
expect(status.illustration).to include(:image, :size, :title, :content)
- expect(status.label).to eq 'pending'
+ expect(status.label).to eq "pending"
expect(status).to have_details
expect(status).to have_action
end
end
- context 'when build is skipped' do
+ context "when build is skipped" do
let(:build) { create(:ci_build, :skipped) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Skipped
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses).to eq [Gitlab::Ci::Status::Build::Skipped]
end
- it 'fabricates a skipped build status' do
+ it "fabricates a skipped build status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Skipped
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'skipped'
- expect(status.icon).to eq 'status_skipped'
- expect(status.favicon).to eq 'favicon_status_skipped'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "skipped"
+ expect(status.icon).to eq "status_skipped"
+ expect(status.favicon).to eq "favicon_status_skipped"
expect(status.illustration).to include(:image, :size, :title)
- expect(status.label).to eq 'skipped'
+ expect(status.label).to eq "skipped"
expect(status).to have_details
expect(status).not_to have_action
end
end
- context 'when build is a manual action' do
- context 'when build is a play action' do
+ context "when build is a manual action" do
+ context "when build is a play action" do
let(:build) { create(:ci_build, :playable) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Manual
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Manual,
Gitlab::Ci::Status::Build::Play,
- Gitlab::Ci::Status::Build::Action]
+ Gitlab::Ci::Status::Build::Action,]
end
- it 'fabricates action detailed status' do
+ it "fabricates action detailed status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Action
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'manual'
- expect(status.group).to eq 'manual'
- expect(status.icon).to eq 'status_manual'
- expect(status.favicon).to eq 'favicon_status_manual'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "manual"
+ expect(status.group).to eq "manual"
+ expect(status.icon).to eq "status_manual"
+ expect(status.favicon).to eq "favicon_status_manual"
expect(status.illustration).to include(:image, :size, :title, :content)
- expect(status.label).to include 'manual play action'
+ expect(status.label).to include "manual play action"
expect(status).to have_details
- expect(status.action_path).to include 'play'
+ expect(status.action_path).to include "play"
end
- context 'when user has ability to play action' do
- it 'fabricates status that has action' do
+ context "when user has ability to play action" do
+ it "fabricates status that has action" do
expect(status).to have_action
end
end
- context 'when user does not have ability to play action' do
+ context "when user does not have ability to play action" do
before do
allow(build.project).to receive(:empty_repo?).and_return(false)
create(:protected_branch, :no_one_can_push,
- name: build.ref, project: build.project)
+ name: build.ref, project: build.project)
end
- it 'fabricates status that has no action' do
+ it "fabricates status that has no action" do
expect(status).not_to have_action
end
end
end
- context 'when build is an environment stop action' do
+ context "when build is an environment stop action" do
let(:build) { create(:ci_build, :playable, :teardown_environment) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Manual
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Manual,
Gitlab::Ci::Status::Build::Stop,
- Gitlab::Ci::Status::Build::Action]
+ Gitlab::Ci::Status::Build::Action,]
end
- it 'fabricates action detailed status' do
+ it "fabricates action detailed status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Action
end
- context 'when user is not allowed to execute manual action' do
+ context "when user is not allowed to execute manual action" do
before do
allow(build.project).to receive(:empty_repo?).and_return(false)
create(:protected_branch, :no_one_can_push,
- name: build.ref, project: build.project)
+ name: build.ref, project: build.project)
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'manual'
- expect(status.group).to eq 'manual'
- expect(status.icon).to eq 'status_manual'
- expect(status.favicon).to eq 'favicon_status_manual'
- expect(status.label).to eq 'manual stop action (not allowed)'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "manual"
+ expect(status.group).to eq "manual"
+ expect(status.icon).to eq "status_manual"
+ expect(status.favicon).to eq "favicon_status_manual"
+ expect(status.label).to eq "manual stop action (not allowed)"
expect(status).to have_details
expect(status).not_to have_action
end
@@ -320,50 +320,50 @@ describe Gitlab::Ci::Status::Build::Factory do
end
end
- context 'when build is a delayed action' do
+ context "when build is a delayed action" do
let(:build) { create(:ci_build, :scheduled) }
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Scheduled
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Build::Scheduled,
Gitlab::Ci::Status::Build::Unschedule,
- Gitlab::Ci::Status::Build::Action]
+ Gitlab::Ci::Status::Build::Action,]
end
- it 'fabricates action detailed status' do
+ it "fabricates action detailed status" do
expect(status).to be_a Gitlab::Ci::Status::Build::Action
end
- it 'fabricates status with correct details' do
- expect(status.text).to eq 'delayed'
- expect(status.group).to eq 'scheduled'
- expect(status.icon).to eq 'status_scheduled'
- expect(status.favicon).to eq 'favicon_status_scheduled'
+ it "fabricates status with correct details" do
+ expect(status.text).to eq "delayed"
+ expect(status.group).to eq "scheduled"
+ expect(status.icon).to eq "status_scheduled"
+ expect(status.favicon).to eq "favicon_status_scheduled"
expect(status.illustration).to include(:image, :size, :title, :content)
- expect(status.label).to include 'unschedule action'
+ expect(status.label).to include "unschedule action"
expect(status).to have_details
- expect(status.action_path).to include 'unschedule'
+ expect(status.action_path).to include "unschedule"
end
- context 'when user has ability to play action' do
- it 'fabricates status that has action' do
+ context "when user has ability to play action" do
+ it "fabricates status that has action" do
expect(status).to have_action
end
end
- context 'when user does not have ability to play action' do
+ context "when user does not have ability to play action" do
before do
allow(build.project).to receive(:empty_repo?).and_return(false)
create(:protected_branch, :no_one_can_push,
- name: build.ref, project: build.project)
+ name: build.ref, project: build.project)
end
- it 'fabricates status that has no action' do
+ it "fabricates status that has no action" do
expect(status).not_to have_action
end
end
diff --git a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb
index af03d5a1308..71c559b4488 100644
--- a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::FailedAllowed do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
let(:build) { create(:ci_build, :failed, :allowed_to_fail) }
subject do
described_class.new(status)
end
- describe '#text' do
- it 'does not override status text' do
+ describe "#text" do
+ it "does not override status text" do
expect(status).to receive(:text)
subject.text
end
end
- describe '#icon' do
- it 'returns a warning icon' do
- expect(subject.icon).to eq 'status_warning'
+ describe "#icon" do
+ it "returns a warning icon" do
+ expect(subject.icon).to eq "status_warning"
end
end
- describe '#label' do
- it 'returns information about failed but allowed to fail status' do
- expect(subject.label).to eq 'failed (allowed to fail)'
+ describe "#label" do
+ it "returns information about failed but allowed to fail status" do
+ expect(subject.label).to eq "failed (allowed to fail)"
end
end
- describe '#group' do
- it 'returns status failed with warnings status group' do
- expect(subject.group).to eq 'failed_with_warnings'
+ describe "#group" do
+ it "returns status failed with warnings status group" do
+ expect(subject.group).to eq "failed_with_warnings"
end
end
- describe 'action details' do
- describe '#has_action?' do
- it 'does not decorate action details' do
+ describe "action details" do
+ describe "#has_action?" do
+ it "does not decorate action details" do
expect(status).to receive(:has_action?)
subject.has_action?
end
end
- describe '#action_path' do
- it 'does not decorate action path' do
+ describe "#action_path" do
+ it "does not decorate action path" do
expect(status).to receive(:action_path)
subject.action_path
end
end
- describe '#action_icon' do
- it 'does not decorate action icon' do
+ describe "#action_icon" do
+ it "does not decorate action icon" do
expect(status).to receive(:action_icon)
subject.action_icon
end
end
- describe '#action_title' do
- it 'does not decorate action title' do
+ describe "#action_title" do
+ it "does not decorate action title" do
expect(status).to receive(:action_title)
subject.action_title
@@ -69,62 +69,62 @@ describe Gitlab::Ci::Status::Build::FailedAllowed do
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) }
let(:build_status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) }
let(:status) { described_class.new(build_status) }
- it 'does override badge_tooltip' do
- expect(status.badge_tooltip).to eq('failed - (unknown failure)')
+ it "does override badge_tooltip" do
+ expect(status.badge_tooltip).to eq("failed - (unknown failure)")
end
end
- describe '#status_tooltip' do
+ describe "#status_tooltip" do
let(:user) { create(:user) }
let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) }
let(:build_status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) }
let(:status) { described_class.new(build_status) }
- it 'does override status_tooltip' do
- expect(status.status_tooltip).to eq 'failed - (unknown failure) (allowed to fail)'
+ it "does override status_tooltip" do
+ expect(status.status_tooltip).to eq "failed - (unknown failure) (allowed to fail)"
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is failed' do
- context 'when build is allowed to fail' do
+ context "when build is failed" do
+ context "when build is allowed to fail" do
let(:build) { create(:ci_build, :failed, :allowed_to_fail) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not allowed to fail' do
+ context "when build is not allowed to fail" do
let(:build) { create(:ci_build, :failed) }
- it 'is not a correct match' do
+ it "is not a correct match" do
expect(subject).not_to be true
end
end
end
- context 'when build did not fail' do
- context 'when build is allowed to fail' do
+ context "when build did not fail" do
+ context "when build is allowed to fail" do
let(:build) { create(:ci_build, :success, :allowed_to_fail) }
- it 'is not a correct match' do
+ it "is not a correct match" do
expect(subject).not_to be true
end
end
- context 'when build is not allowed to fail' do
+ context "when build is not allowed to fail" do
let(:build) { create(:ci_build, :success) }
- it 'is not a correct match' do
+ it "is not a correct match" do
expect(subject).not_to be true
end
end
diff --git a/spec/lib/gitlab/ci/status/build/failed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_spec.rb
index e424270f7c5..0958f9f876e 100644
--- a/spec/lib/gitlab/ci/status/build/failed_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/failed_spec.rb
@@ -1,87 +1,87 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Failed do
let(:build) { create(:ci_build, :script_failure) }
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject { described_class.new(status) }
- describe '#text' do
- it 'does not override status text' do
+ describe "#text" do
+ it "does not override status text" do
expect(status).to receive(:text)
subject.text
end
end
- describe '#icon' do
- it 'does not override status icon' do
+ describe "#icon" do
+ it "does not override status icon" do
expect(status).to receive(:icon)
subject.icon
end
end
- describe '#group' do
- it 'does not override status group' do
+ describe "#group" do
+ it "does not override status group" do
expect(status).to receive(:group)
subject.group
end
end
- describe '#favicon' do
- it 'does not override status label' do
+ describe "#favicon" do
+ it "does not override status label" do
expect(status).to receive(:favicon)
subject.favicon
end
end
- describe '#label' do
- it 'does not override label' do
+ describe "#label" do
+ it "does not override label" do
expect(status).to receive(:label)
subject.label
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:status) { Gitlab::Ci::Status::Failed.new(build, user) }
- it 'does override badge_tooltip' do
- expect(subject.badge_tooltip).to eq 'failed - (script failure)'
+ it "does override badge_tooltip" do
+ expect(subject.badge_tooltip).to eq "failed - (script failure)"
end
end
- describe '#status_tooltip' do
+ describe "#status_tooltip" do
let(:user) { create(:user) }
let(:status) { Gitlab::Ci::Status::Failed.new(build, user) }
- it 'does override status_tooltip' do
- expect(subject.status_tooltip).to eq 'failed - (script failure)'
+ it "does override status_tooltip" do
+ expect(subject.status_tooltip).to eq "failed - (script failure)"
end
end
- describe '.matches?' do
- context 'with a failed build' do
- it 'returns true' do
+ describe ".matches?" do
+ context "with a failed build" do
+ it "returns true" do
expect(described_class.matches?(build, user)).to be_truthy
end
end
- context 'with any other type of build' do
+ context "with any other type of build" do
let(:build) { create(:ci_build, :success) }
- it 'returns false' do
+ it "returns false" do
expect(described_class.matches?(build, user)).to be_falsy
end
end
end
- describe 'covers all failure reasons' do
+ describe "covers all failure reasons" do
let(:status) { Gitlab::Ci::Status::Failed.new(build, user) }
let(:tooltip) { subject.status_tooltip }
@@ -97,9 +97,9 @@ describe Gitlab::Ci::Status::Build::Failed do
end
end
- context 'invalid failure message' do
+ context "invalid failure message" do
before do
- expect(build).to receive(:failure_reason) { 'invalid failure message' }
+ expect(build).to receive(:failure_reason) { "invalid failure message" }
end
it "is an invalid status" do
diff --git a/spec/lib/gitlab/ci/status/build/manual_spec.rb b/spec/lib/gitlab/ci/status/build/manual_spec.rb
index 6386296f992..7e831c0504d 100644
--- a/spec/lib/gitlab/ci/status/build/manual_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/manual_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Manual do
let(:user) { create(:user) }
@@ -8,25 +8,25 @@ describe Gitlab::Ci::Status::Build::Manual do
described_class.new(Gitlab::Ci::Status::Core.new(build, user))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title, :content) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject {described_class.matches?(build, user) }
- context 'when build is manual' do
+ context "when build is manual" do
let(:build) { create(:ci_build, :manual) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not manual' do
+ context "when build is not manual" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/pending_spec.rb b/spec/lib/gitlab/ci/status/build/pending_spec.rb
index 4cf70828e53..043cb310f3f 100644
--- a/spec/lib/gitlab/ci/status/build/pending_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/pending_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Pending do
let(:user) { create(:user) }
subject do
- described_class.new(double('subject'))
+ described_class.new(double("subject"))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title, :content) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject {described_class.matches?(build, user) }
- context 'when build is pending' do
+ context "when build is pending" do
let(:build) { create(:ci_build, :pending) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not pending' do
+ context "when build is not pending" do
let(:build) { create(:ci_build, :success) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/play_spec.rb b/spec/lib/gitlab/ci/status/build/play_spec.rb
index 02f8c4c114b..2a55dcb11a0 100644
--- a/spec/lib/gitlab/ci/status/build/play_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/play_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Play do
let(:user) { create(:user) }
@@ -8,100 +8,100 @@ describe Gitlab::Ci::Status::Build::Play do
subject { described_class.new(status) }
- describe '#label' do
- it 'has a label that says it is a manual action' do
- expect(subject.label).to eq 'manual play action'
+ describe "#label" do
+ it "has a label that says it is a manual action" do
+ expect(subject.label).to eq "manual play action"
end
end
- describe '#status_tooltip' do
- it 'does not override status status_tooltip' do
+ describe "#status_tooltip" do
+ it "does not override status status_tooltip" do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
- describe '#badge_tooltip' do
- it 'does not override status badge_tooltip' do
+ describe "#badge_tooltip" do
+ it "does not override status badge_tooltip" do
expect(status).to receive(:badge_tooltip)
subject.badge_tooltip
end
end
- describe '#has_action?' do
- context 'when user is allowed to update build' do
- context 'when user is allowed to trigger protected action' do
+ describe "#has_action?" do
+ context "when user is allowed to update build" do
+ context "when user is allowed to trigger protected action" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
it { is_expected.to have_action }
end
- context 'when user can not push to the branch' do
+ context "when user can not push to the branch" do
before do
build.project.add_developer(user)
create(:protected_branch, :maintainers_can_push,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
it { is_expected.not_to have_action }
end
end
- context 'when user is not allowed to update build' do
+ context "when user is not allowed to update build" do
it { is_expected.not_to have_action }
end
end
- describe '#action_path' do
+ describe "#action_path" do
it { expect(subject.action_path).to include "#{build.id}/play" }
end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'play' }
+ describe "#action_icon" do
+ it { expect(subject.action_icon).to eq "play" }
end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Play' }
+ describe "#action_title" do
+ it { expect(subject.action_title).to eq "Play" }
end
- describe '#action_button_title' do
- it { expect(subject.action_button_title).to eq 'Trigger this manual action' }
+ describe "#action_button_title" do
+ it { expect(subject.action_button_title).to eq "Trigger this manual action" }
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is playable' do
- context 'when build stops an environment' do
+ context "when build is playable" do
+ context "when build stops an environment" do
let(:build) do
create(:ci_build, :playable, :teardown_environment)
end
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
- context 'when build does not stop an environment' do
+ context "when build does not stop an environment" do
let(:build) { create(:ci_build, :playable) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
end
- context 'when build is not playable' do
+ context "when build is not playable" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/retried_spec.rb b/spec/lib/gitlab/ci/status/build/retried_spec.rb
index 76c2fb01e3f..1836f0fbef6 100644
--- a/spec/lib/gitlab/ci/status/build/retried_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/retried_spec.rb
@@ -1,93 +1,93 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Retried do
let(:build) { create(:ci_build, :retried) }
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject { described_class.new(status) }
- describe '#text' do
- it 'does not override status text' do
+ describe "#text" do
+ it "does not override status text" do
expect(status).to receive(:text)
subject.text
end
end
- describe '#icon' do
- it 'does not override status icon' do
+ describe "#icon" do
+ it "does not override status icon" do
expect(status).to receive(:icon)
subject.icon
end
end
- describe '#group' do
- it 'does not override status group' do
+ describe "#group" do
+ it "does not override status group" do
expect(status).to receive(:group)
subject.group
end
end
- describe '#favicon' do
- it 'does not override status label' do
+ describe "#favicon" do
+ it "does not override status label" do
expect(status).to receive(:favicon)
subject.favicon
end
end
- describe '#label' do
- it 'does not override status label' do
+ describe "#label" do
+ it "does not override status label" do
expect(status).to receive(:label)
subject.label
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :retried) }
let(:status) { Gitlab::Ci::Status::Success.new(build, user) }
- it 'returns status' do
- expect(status.badge_tooltip).to eq('pending')
+ it "returns status" do
+ expect(status.badge_tooltip).to eq("pending")
end
end
- describe '#status_tooltip' do
+ describe "#status_tooltip" do
let(:user) { create(:user) }
- context 'with a failed build' do
+ context "with a failed build" do
let(:build) { create(:ci_build, :failed, :retried) }
let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) }
let(:status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) }
- it 'does override status_tooltip' do
- expect(subject.status_tooltip).to eq 'failed - (unknown failure) (retried)'
+ it "does override status_tooltip" do
+ expect(subject.status_tooltip).to eq "failed - (unknown failure) (retried)"
end
end
- context 'with another build' do
+ context "with another build" do
let(:build) { create(:ci_build, :retried) }
let(:status) { Gitlab::Ci::Status::Success.new(build, user) }
- it 'does override status_tooltip' do
- expect(subject.status_tooltip).to eq 'passed (retried)'
+ it "does override status_tooltip" do
+ expect(subject.status_tooltip).to eq "passed (retried)"
end
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'with a retried build' do
+ context "with a retried build" do
it { is_expected.to be_truthy }
end
- context 'with a build that has not been retried' do
+ context "with a build that has not been retried" do
let(:build) { create(:ci_build, :success) }
it { is_expected.to be_falsy }
diff --git a/spec/lib/gitlab/ci/status/build/retryable_spec.rb b/spec/lib/gitlab/ci/status/build/retryable_spec.rb
index 84d98588f2d..5ae0dc7c38f 100644
--- a/spec/lib/gitlab/ci/status/build/retryable_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/retryable_spec.rb
@@ -1,70 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Retryable do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject do
described_class.new(status)
end
- describe '#text' do
- it 'does not override status text' do
+ describe "#text" do
+ it "does not override status text" do
expect(status).to receive(:text)
subject.text
end
end
- describe '#icon' do
- it 'does not override status icon' do
+ describe "#icon" do
+ it "does not override status icon" do
expect(status).to receive(:icon)
subject.icon
end
end
- describe '#label' do
- it 'does not override status label' do
+ describe "#label" do
+ it "does not override status label" do
expect(status).to receive(:label)
subject.label
end
end
- describe '#group' do
- it 'does not override status group' do
+ describe "#group" do
+ it "does not override status group" do
expect(status).to receive(:group)
subject.group
end
end
- describe '#status_tooltip' do
- it 'does not override status status_tooltip' do
+ describe "#status_tooltip" do
+ it "does not override status status_tooltip" do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- it 'does return status' do
- expect(status.badge_tooltip).to eq('pending')
+ it "does return status" do
+ expect(status.badge_tooltip).to eq("pending")
end
end
- describe 'action details' do
+ describe "action details" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- describe '#has_action?' do
- context 'when user is allowed to update build' do
+ describe "#has_action?" do
+ context "when user is allowed to update build" do
before do
stub_not_protect_default_branch
@@ -74,45 +74,45 @@ describe Gitlab::Ci::Status::Build::Retryable do
it { is_expected.to have_action }
end
- context 'when user is not allowed to update build' do
+ context "when user is not allowed to update build" do
it { is_expected.not_to have_action }
end
end
- describe '#action_path' do
+ describe "#action_path" do
it { expect(subject.action_path).to include "#{build.id}/retry" }
end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'retry' }
+ describe "#action_icon" do
+ it { expect(subject.action_icon).to eq "retry" }
end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Retry' }
+ describe "#action_title" do
+ it { expect(subject.action_title).to eq "Retry" }
end
- describe '#action_button_title' do
- it { expect(subject.action_button_title).to eq 'Retry this job' }
+ describe "#action_button_title" do
+ it { expect(subject.action_button_title).to eq "Retry this job" }
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is retryable' do
+ context "when build is retryable" do
let(:build) do
create(:ci_build, :success)
end
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not retryable' do
+ context "when build is not retryable" do
let(:build) { create(:ci_build, :running) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb b/spec/lib/gitlab/ci/status/build/scheduled_spec.rb
index 68b87fea75d..8300d61caf4 100644
--- a/spec/lib/gitlab/ci/status/build/scheduled_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/scheduled_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Scheduled do
let(:user) { create(:user) }
@@ -8,34 +8,34 @@ describe Gitlab::Ci::Status::Build::Scheduled do
subject { described_class.new(status) }
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title) }
end
- describe '#status_tooltip' do
+ describe "#status_tooltip" do
let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }
- it 'has a placeholder for the remaining time' do
- expect(subject.status_tooltip).to include('%{remainingTime}')
+ it "has a placeholder for the remaining time" do
+ expect(subject.status_tooltip).to include("%{remainingTime}")
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is scheduled and scheduled_at is present' do
+ context "when build is scheduled and scheduled_at is present" do
let(:build) { create(:ci_build, :expired_scheduled, project: project) }
it { is_expected.to be_truthy }
end
- context 'when build is scheduled' do
+ context "when build is scheduled" do
let(:build) { create(:ci_build, status: :scheduled, project: project) }
it { is_expected.to be_falsy }
end
- context 'when scheduled_at is present' do
+ context "when scheduled_at is present" do
let(:build) { create(:ci_build, scheduled_at: 1.minute.since, project: project) }
it { is_expected.to be_falsy }
diff --git a/spec/lib/gitlab/ci/status/build/skipped_spec.rb b/spec/lib/gitlab/ci/status/build/skipped_spec.rb
index 46f6933025a..cd5fda0acd4 100644
--- a/spec/lib/gitlab/ci/status/build/skipped_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/skipped_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Skipped do
let(:user) { create(:user) }
subject do
- described_class.new(double('subject'))
+ described_class.new(double("subject"))
end
- describe '#illustration' do
+ describe "#illustration" do
it { expect(subject.illustration).to include(:image, :size, :title) }
end
- describe '.matches?' do
+ describe ".matches?" do
subject {described_class.matches?(build, user) }
- context 'when build is skipped' do
+ context "when build is skipped" do
let(:build) { create(:ci_build, :skipped) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build is not skipped' do
+ context "when build is not skipped" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/build/stop_spec.rb b/spec/lib/gitlab/ci/status/build/stop_spec.rb
index 5b7534c96c1..57e97e617bf 100644
--- a/spec/lib/gitlab/ci/status/build/stop_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/stop_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Stop do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject do
described_class.new(status)
end
- describe '#label' do
- it { expect(subject.label).to eq 'manual stop action' }
+ describe "#label" do
+ it { expect(subject.label).to eq "manual stop action" }
end
- describe 'action details' do
+ describe "action details" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- describe '#has_action?' do
- context 'when user is allowed to update build' do
+ describe "#has_action?" do
+ context "when user is allowed to update build" do
before do
stub_not_protect_default_branch
@@ -28,74 +28,74 @@ describe Gitlab::Ci::Status::Build::Stop do
it { is_expected.to have_action }
end
- context 'when user is not allowed to update build' do
+ context "when user is not allowed to update build" do
it { is_expected.not_to have_action }
end
end
- describe '#action_path' do
+ describe "#action_path" do
it { expect(subject.action_path).to include "#{build.id}/play" }
end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'stop' }
+ describe "#action_icon" do
+ it { expect(subject.action_icon).to eq "stop" }
end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Stop' }
+ describe "#action_title" do
+ it { expect(subject.action_title).to eq "Stop" }
end
- describe '#action_button_title' do
- it { expect(subject.action_button_title).to eq 'Stop this environment' }
+ describe "#action_button_title" do
+ it { expect(subject.action_button_title).to eq "Stop this environment" }
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is playable' do
- context 'when build stops an environment' do
+ context "when build is playable" do
+ context "when build stops an environment" do
let(:build) do
create(:ci_build, :playable, :teardown_environment)
end
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build does not stop an environment' do
+ context "when build does not stop an environment" do
let(:build) { create(:ci_build, :playable) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
end
- context 'when build is not playable' do
+ context "when build is not playable" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
end
- describe '#status_tooltip' do
- it 'does not override status status_tooltip' do
+ describe "#status_tooltip" do
+ it "does not override status status_tooltip" do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :playable) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- it 'does not override status badge_tooltip' do
+ it "does not override status badge_tooltip" do
expect(status).to receive(:badge_tooltip)
subject.badge_tooltip
diff --git a/spec/lib/gitlab/ci/status/build/unschedule_spec.rb b/spec/lib/gitlab/ci/status/build/unschedule_spec.rb
index ed046d66ca5..47cd3ae7baa 100644
--- a/spec/lib/gitlab/ci/status/build/unschedule_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/unschedule_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Build::Unschedule do
- let(:status) { double('core status') }
- let(:user) { double('user') }
+ let(:status) { double("core status") }
+ let(:user) { double("user") }
subject do
described_class.new(status)
end
- describe '#label' do
- it { expect(subject.label).to eq 'unschedule action' }
+ describe "#label" do
+ it { expect(subject.label).to eq "unschedule action" }
end
- describe 'action details' do
+ describe "action details" do
let(:user) { create(:user) }
let(:build) { create(:ci_build) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- describe '#has_action?' do
- context 'when user is allowed to update build' do
+ describe "#has_action?" do
+ context "when user is allowed to update build" do
before do
stub_not_protect_default_branch
@@ -28,64 +28,64 @@ describe Gitlab::Ci::Status::Build::Unschedule do
it { is_expected.to have_action }
end
- context 'when user is not allowed to update build' do
+ context "when user is not allowed to update build" do
it { is_expected.not_to have_action }
end
end
- describe '#action_path' do
+ describe "#action_path" do
it { expect(subject.action_path).to include "#{build.id}/unschedule" }
end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'time-out' }
+ describe "#action_icon" do
+ it { expect(subject.action_icon).to eq "time-out" }
end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Unschedule' }
+ describe "#action_title" do
+ it { expect(subject.action_title).to eq "Unschedule" }
end
- describe '#action_button_title' do
- it { expect(subject.action_button_title).to eq 'Unschedule job' }
+ describe "#action_button_title" do
+ it { expect(subject.action_button_title).to eq "Unschedule job" }
end
end
- describe '.matches?' do
+ describe ".matches?" do
subject { described_class.matches?(build, user) }
- context 'when build is scheduled' do
- context 'when build unschedules an delayed job' do
+ context "when build is scheduled" do
+ context "when build unschedules an delayed job" do
let(:build) { create(:ci_build, :scheduled) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when build unschedules an normal job' do
+ context "when build unschedules an normal job" do
let(:build) { create(:ci_build) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
end
end
- describe '#status_tooltip' do
- it 'does not override status status_tooltip' do
+ describe "#status_tooltip" do
+ it "does not override status status_tooltip" do
expect(status).to receive(:status_tooltip)
subject.status_tooltip
end
end
- describe '#badge_tooltip' do
+ describe "#badge_tooltip" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :playable) }
let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
- it 'does not override status badge_tooltip' do
+ it "does not override status badge_tooltip" do
expect(status).to receive(:badge_tooltip)
subject.badge_tooltip
diff --git a/spec/lib/gitlab/ci/status/canceled_spec.rb b/spec/lib/gitlab/ci/status/canceled_spec.rb
index dc74d7e28c5..8cf8fa131cd 100644
--- a/spec/lib/gitlab/ci/status/canceled_spec.rb
+++ b/spec/lib/gitlab/ci/status/canceled_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Canceled do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'canceled' }
+ describe "#text" do
+ it { expect(subject.text).to eq "canceled" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'canceled' }
+ describe "#label" do
+ it { expect(subject.label).to eq "canceled" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_canceled' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_canceled" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_canceled' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_canceled" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'canceled' }
+ describe "#group" do
+ it { expect(subject.group).to eq "canceled" }
end
end
diff --git a/spec/lib/gitlab/ci/status/created_spec.rb b/spec/lib/gitlab/ci/status/created_spec.rb
index ce4333f2aca..c1cb69d8802 100644
--- a/spec/lib/gitlab/ci/status/created_spec.rb
+++ b/spec/lib/gitlab/ci/status/created_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Created do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'created' }
+ describe "#text" do
+ it { expect(subject.text).to eq "created" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'created' }
+ describe "#label" do
+ it { expect(subject.label).to eq "created" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_created' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_created" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_created' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_created" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'created' }
+ describe "#group" do
+ it { expect(subject.group).to eq "created" }
end
end
diff --git a/spec/lib/gitlab/ci/status/extended_spec.rb b/spec/lib/gitlab/ci/status/extended_spec.rb
index 6eacb07078b..4fb8b76d4f3 100644
--- a/spec/lib/gitlab/ci/status/extended_spec.rb
+++ b/spec/lib/gitlab/ci/status/extended_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Extended do
- it 'requires subclass to implement matcher' do
+ it "requires subclass to implement matcher" do
expect { described_class.matches?(double, double) }
.to raise_error(NotImplementedError)
end
diff --git a/spec/lib/gitlab/ci/status/external/common_spec.rb b/spec/lib/gitlab/ci/status/external/common_spec.rb
index 0d02c371a92..0fe398f04fc 100644
--- a/spec/lib/gitlab/ci/status/external/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/external/common_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::External::Common do
let(:user) { create(:user) }
let(:project) { external_status.project }
- let(:external_target_url) { 'http://example.gitlab.com/status' }
- let(:external_description) { 'my description' }
+ let(:external_target_url) { "http://example.gitlab.com/status" }
+ let(:external_description) { "my description" }
let(:external_status) do
create(:generic_commit_status, target_url: external_target_url, description: external_description)
@@ -16,34 +16,34 @@ describe Gitlab::Ci::Status::External::Common do
.extend(described_class)
end
- describe '#label' do
- it 'returns description' do
+ describe "#label" do
+ it "returns description" do
expect(subject.label).to eq external_description
end
- context 'when description is nil' do
+ context "when description is nil" do
let(:external_description) { nil }
- it 'uses core status label' do
- expect(subject.label).to eq('passed')
+ it "uses core status label" do
+ expect(subject.label).to eq("passed")
end
end
- context 'when description is empty string' do
- let(:external_description) { '' }
+ context "when description is empty string" do
+ let(:external_description) { "" }
- it 'uses core status label' do
- expect(subject.label).to eq('passed')
+ it "uses core status label" do
+ expect(subject.label).to eq("passed")
end
end
end
- describe '#has_action?' do
+ describe "#has_action?" do
it { is_expected.not_to have_action }
end
- describe '#has_details?' do
- context 'when user has access to read commit status' do
+ describe "#has_details?" do
+ context "when user has access to read commit status" do
before do
project.add_developer(user)
end
@@ -51,13 +51,13 @@ describe Gitlab::Ci::Status::External::Common do
it { is_expected.to have_details }
end
- context 'when user does not have access to read commit status' do
+ context "when user does not have access to read commit status" do
it { is_expected.not_to have_details }
end
end
- describe '#details_path' do
- it 'links to the external target URL' do
+ describe "#details_path" do
+ it "links to the external target URL" do
expect(subject.details_path).to eq external_target_url
end
end
diff --git a/spec/lib/gitlab/ci/status/external/factory_spec.rb b/spec/lib/gitlab/ci/status/external/factory_spec.rb
index 529d02a3e39..70be4b4e087 100644
--- a/spec/lib/gitlab/ci/status/external/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/external/factory_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::External::Factory do
let(:user) { create(:user) }
let(:project) { resource.project }
let(:status) { factory.fabricate! }
let(:factory) { described_class.new(resource, user) }
- let(:external_url) { 'http://gitlab.com/status' }
+ let(:external_url) { "http://gitlab.com/status" }
before do
project.add_developer(user)
end
- context 'when external status has a simple core status' do
+ context "when external status has a simple core status" do
HasStatus::AVAILABLE_STATUSES.each do |simple_status|
context "when core status is #{simple_status}" do
let(:resource) do
@@ -27,7 +27,7 @@ describe Gitlab::Ci::Status::External::Factory do
expect(status).to be_a expected_status
end
- it 'extends core status with common methods' do
+ it "extends core status with common methods" do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path).to eq external_url
diff --git a/spec/lib/gitlab/ci/status/factory_spec.rb b/spec/lib/gitlab/ci/status/factory_spec.rb
index bbf9c7c83a3..a866c392043 100644
--- a/spec/lib/gitlab/ci/status/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/factory_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Factory do
let(:user) { create(:user) }
let(:fabricated_status) { factory.fabricate! }
let(:factory) { described_class.new(resource, user) }
- context 'when object has a core status' do
+ context "when object has a core status" do
HasStatus::AVAILABLE_STATUSES.each do |simple_status|
context "when simple core status is #{simple_status}" do
- let(:resource) { double('resource', status: simple_status) }
+ let(:resource) { double("resource", status: simple_status) }
let(:expected_status) do
Gitlab::Ci::Status.const_get(simple_status.capitalize)
@@ -29,17 +29,17 @@ describe Gitlab::Ci::Status::Factory do
end
end
- context 'when resource supports multiple extended statuses' do
- let(:resource) { double('resource', status: :success) }
+ context "when resource supports multiple extended statuses" do
+ let(:resource) { double("resource", status: :success) }
let(:first_extended_status) do
Class.new(SimpleDelegator) do
def first_method
- 'first return value'
+ "first return value"
end
def second_method
- 'second return value'
+ "second return value"
end
def self.matches?(*)
@@ -51,11 +51,11 @@ describe Gitlab::Ci::Status::Factory do
let(:second_extended_status) do
Class.new(SimpleDelegator) do
def first_method
- 'decorated return value'
+ "decorated return value"
end
def third_method
- 'third return value'
+ "third return value"
end
def self.matches?(*)
@@ -64,72 +64,72 @@ describe Gitlab::Ci::Status::Factory do
end
end
- shared_examples 'compound decorator factory' do
- it 'fabricates compound decorator' do
- expect(fabricated_status.first_method).to eq 'decorated return value'
- expect(fabricated_status.second_method).to eq 'second return value'
- expect(fabricated_status.third_method).to eq 'third return value'
+ shared_examples "compound decorator factory" do
+ it "fabricates compound decorator" do
+ expect(fabricated_status.first_method).to eq "decorated return value"
+ expect(fabricated_status.second_method).to eq "second return value"
+ expect(fabricated_status.third_method).to eq "third return value"
end
- it 'delegates to core status' do
- expect(fabricated_status.text).to eq 'passed'
+ it "delegates to core status" do
+ expect(fabricated_status.text).to eq "passed"
end
- it 'latest matches status becomes a status name' do
+ it "latest matches status becomes a status name" do
expect(fabricated_status.class).to eq second_extended_status
end
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [first_extended_status, second_extended_status]
end
end
- context 'when exclusive statuses are matches' do
+ context "when exclusive statuses are matches" do
before do
allow(described_class).to receive(:extended_statuses)
.and_return([[first_extended_status, second_extended_status]])
end
- it 'does not fabricate compound decorator' do
- expect(fabricated_status.first_method).to eq 'first return value'
- expect(fabricated_status.second_method).to eq 'second return value'
+ it "does not fabricate compound decorator" do
+ expect(fabricated_status.first_method).to eq "first return value"
+ expect(fabricated_status.second_method).to eq "second return value"
expect(fabricated_status).not_to respond_to(:third_method)
end
- it 'delegates to core status' do
- expect(fabricated_status.text).to eq 'passed'
+ it "delegates to core status" do
+ expect(fabricated_status.text).to eq "passed"
end
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses).to eq [first_extended_status]
end
end
- context 'when exclusive statuses are not matched' do
+ context "when exclusive statuses are not matched" do
before do
allow(described_class).to receive(:extended_statuses)
.and_return([[first_extended_status], [second_extended_status]])
end
- it_behaves_like 'compound decorator factory'
+ it_behaves_like "compound decorator factory"
end
- context 'when using simplified status grouping' do
+ context "when using simplified status grouping" do
before do
allow(described_class).to receive(:extended_statuses)
.and_return([first_extended_status, second_extended_status])
end
- it_behaves_like 'compound decorator factory'
+ it_behaves_like "compound decorator factory"
end
end
end
diff --git a/spec/lib/gitlab/ci/status/failed_spec.rb b/spec/lib/gitlab/ci/status/failed_spec.rb
index a4a92117c7f..557108898df 100644
--- a/spec/lib/gitlab/ci/status/failed_spec.rb
+++ b/spec/lib/gitlab/ci/status/failed_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Failed do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'failed' }
+ describe "#text" do
+ it { expect(subject.text).to eq "failed" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'failed' }
+ describe "#label" do
+ it { expect(subject.label).to eq "failed" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_failed' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_failed" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_failed' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_failed" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'failed' }
+ describe "#group" do
+ it { expect(subject.group).to eq "failed" }
end
end
diff --git a/spec/lib/gitlab/ci/status/group/common_spec.rb b/spec/lib/gitlab/ci/status/group/common_spec.rb
index c0ca05881f5..c32f0e14604 100644
--- a/spec/lib/gitlab/ci/status/group/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/group/common_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Group::Common do
subject do
@@ -6,15 +6,15 @@ describe Gitlab::Ci::Status::Group::Common do
.extend(described_class)
end
- it 'does not have action' do
+ it "does not have action" do
expect(subject).not_to have_action
end
- it 'has details' do
+ it "has details" do
expect(subject).not_to have_details
end
- it 'has no details_path' do
+ it "has no details_path" do
expect(subject.details_path).to be_falsy
end
end
diff --git a/spec/lib/gitlab/ci/status/group/factory_spec.rb b/spec/lib/gitlab/ci/status/group/factory_spec.rb
index 0cd83123938..09c3c22e0a8 100644
--- a/spec/lib/gitlab/ci/status/group/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/group/factory_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Group::Factory do
- it 'inherits from the core factory' do
+ it "inherits from the core factory" do
expect(described_class)
.to be < Gitlab::Ci::Status::Factory
end
- it 'exposes group helpers' do
+ it "exposes group helpers" do
expect(described_class.common_helpers)
.to eq Gitlab::Ci::Status::Group::Common
end
diff --git a/spec/lib/gitlab/ci/status/manual_spec.rb b/spec/lib/gitlab/ci/status/manual_spec.rb
index 0463f2e1aff..945a07abc6f 100644
--- a/spec/lib/gitlab/ci/status/manual_spec.rb
+++ b/spec/lib/gitlab/ci/status/manual_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Manual do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'manual' }
+ describe "#text" do
+ it { expect(subject.text).to eq "manual" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'manual action' }
+ describe "#label" do
+ it { expect(subject.label).to eq "manual action" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_manual' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_manual" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_manual' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_manual" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'manual' }
+ describe "#group" do
+ it { expect(subject.group).to eq "manual" }
end
end
diff --git a/spec/lib/gitlab/ci/status/pending_spec.rb b/spec/lib/gitlab/ci/status/pending_spec.rb
index 0e25358dd8a..e49ad92e3fa 100644
--- a/spec/lib/gitlab/ci/status/pending_spec.rb
+++ b/spec/lib/gitlab/ci/status/pending_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Pending do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'pending' }
+ describe "#text" do
+ it { expect(subject.text).to eq "pending" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'pending' }
+ describe "#label" do
+ it { expect(subject.label).to eq "pending" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_pending' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_pending" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_pending' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_pending" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'pending' }
+ describe "#group" do
+ it { expect(subject.group).to eq "pending" }
end
end
diff --git a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb
index 1a2b952d374..17b4762fa41 100644
--- a/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/blocked_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Pipeline::Blocked do
- let(:pipeline) { double('pipeline') }
+ let(:pipeline) { double("pipeline") }
subject do
described_class.new(pipeline)
end
- describe '#text' do
- it 'overrides status text' do
- expect(subject.text).to eq 'blocked'
+ describe "#text" do
+ it "overrides status text" do
+ expect(subject.text).to eq "blocked"
end
end
- describe '#label' do
- it 'overrides status label' do
- expect(subject.label).to eq 'waiting for manual action'
+ describe "#label" do
+ it "overrides status label" do
+ expect(subject.label).to eq "waiting for manual action"
end
end
- describe '.matches?' do
- let(:user) { double('user') }
+ describe ".matches?" do
+ let(:user) { double("user") }
subject { described_class.matches?(pipeline, user) }
- context 'when pipeline is blocked' do
+ context "when pipeline is blocked" do
let(:pipeline) { create(:ci_pipeline, :blocked) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when pipeline is not blocked' do
+ context "when pipeline is not blocked" do
let(:pipeline) { create(:ci_pipeline, :success) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb
index 57df8325635..d6cdad23f5f 100644
--- a/spec/lib/gitlab/ci/status/pipeline/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/common_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Pipeline::Common do
let(:user) { create(:user) }
@@ -11,12 +11,12 @@ describe Gitlab::Ci::Status::Pipeline::Common do
.extend(described_class)
end
- describe '#has_action?' do
+ describe "#has_action?" do
it { is_expected.not_to have_action }
end
- describe '#has_details?' do
- context 'when user has access to read pipeline' do
+ describe "#has_details?" do
+ context "when user has access to read pipeline" do
before do
project.add_developer(user)
end
@@ -24,13 +24,13 @@ describe Gitlab::Ci::Status::Pipeline::Common do
it { is_expected.to have_details }
end
- context 'when user does not have access to read pipeline' do
+ context "when user does not have access to read pipeline" do
it { is_expected.not_to have_details }
end
end
- describe '#details_path' do
- it 'links to the pipeline details page' do
+ describe "#details_path" do
+ it "links to the pipeline details page" do
expect(subject.details_path)
.to include "pipelines/#{pipeline.id}"
end
diff --git a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb
index f89712d2b03..f6fea7053f9 100644
--- a/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/delayed_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Pipeline::Delayed do
- let(:pipeline) { double('pipeline') }
+ let(:pipeline) { double("pipeline") }
subject do
described_class.new(pipeline)
end
- describe '#text' do
- it 'overrides status text' do
- expect(subject.text).to eq 'delayed'
+ describe "#text" do
+ it "overrides status text" do
+ expect(subject.text).to eq "delayed"
end
end
- describe '#label' do
- it 'overrides status label' do
- expect(subject.label).to eq 'waiting for delayed job'
+ describe "#label" do
+ it "overrides status label" do
+ expect(subject.label).to eq "waiting for delayed job"
end
end
- describe '.matches?' do
- let(:user) { double('user') }
+ describe ".matches?" do
+ let(:user) { double("user") }
subject { described_class.matches?(pipeline, user) }
- context 'when pipeline is scheduled' do
+ context "when pipeline is scheduled" do
let(:pipeline) { create(:ci_pipeline, :scheduled) }
- it 'is a correct match' do
+ it "is a correct match" do
expect(subject).to be true
end
end
- context 'when pipeline is not scheduled' do
+ context "when pipeline is not scheduled" do
let(:pipeline) { create(:ci_pipeline, :success) }
- it 'does not match' do
+ it "does not match" do
expect(subject).to be false
end
end
diff --git a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
index 466087a0e31..ad5ef51f3e1 100644
--- a/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/pipeline/factory_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Pipeline::Factory do
let(:user) { create(:user) }
@@ -10,7 +10,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
project.add_developer(user)
end
- context 'when pipeline has a core status' do
+ context "when pipeline has a core status" do
(HasStatus::AVAILABLE_STATUSES - HasStatus::BLOCKED_STATUS).each do |simple_status|
context "when core status is #{simple_status}" do
let(:pipeline) { create(:ci_pipeline, status: simple_status) }
@@ -23,7 +23,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(factory.core_status).to be_a expected_status
end
- it 'does not match extended statuses' do
+ it "does not match extended statuses" do
expect(factory.extended_statuses).to be_empty
end
@@ -31,7 +31,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(status).to be_a expected_status
end
- it 'extends core status with common pipeline methods' do
+ it "extends core status with common pipeline methods" do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
@@ -48,12 +48,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
.to be_a Gitlab::Ci::Status::Manual
end
- it 'matches a correct extended statuses' do
+ it "matches a correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Blocked]
end
- it 'extends core status with common pipeline methods' do
+ it "extends core status with common pipeline methods" do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
@@ -69,12 +69,12 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
.to be_a Gitlab::Ci::Status::Scheduled
end
- it 'matches a correct extended statuses' do
+ it "matches a correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::Pipeline::Delayed]
end
- it 'extends core status with common pipeline methods' do
+ it "extends core status with common pipeline methods" do
expect(status).to have_details
expect(status).not_to have_action
expect(status.details_path)
@@ -83,7 +83,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
end
end
- context 'when pipeline has warnings' do
+ context "when pipeline has warnings" do
let(:pipeline) do
create(:ci_pipeline, status: :success)
end
@@ -92,11 +92,11 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline)
end
- it 'matches correct core status' do
+ it "matches correct core status" do
expect(factory.core_status).to be_a Gitlab::Ci::Status::Success
end
- it 'matches correct extended statuses' do
+ it "matches correct extended statuses" do
expect(factory.extended_statuses)
.to eq [Gitlab::Ci::Status::SuccessWarning]
end
@@ -105,7 +105,7 @@ describe Gitlab::Ci::Status::Pipeline::Factory do
expect(status).to be_a Gitlab::Ci::Status::SuccessWarning
end
- it 'extends core status with common pipeline method' do
+ it "extends core status with common pipeline method" do
expect(status).to have_details
expect(status.details_path).to include "pipelines/#{pipeline.id}"
end
diff --git a/spec/lib/gitlab/ci/status/running_spec.rb b/spec/lib/gitlab/ci/status/running_spec.rb
index 9c9d431bb5d..68a482fcc77 100644
--- a/spec/lib/gitlab/ci/status/running_spec.rb
+++ b/spec/lib/gitlab/ci/status/running_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Running do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'running' }
+ describe "#text" do
+ it { expect(subject.text).to eq "running" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'running' }
+ describe "#label" do
+ it { expect(subject.label).to eq "running" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_running' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_running" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_running' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_running" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'running' }
+ describe "#group" do
+ it { expect(subject.group).to eq "running" }
end
end
diff --git a/spec/lib/gitlab/ci/status/scheduled_spec.rb b/spec/lib/gitlab/ci/status/scheduled_spec.rb
index b8ca3caa1f7..ec79a146157 100644
--- a/spec/lib/gitlab/ci/status/scheduled_spec.rb
+++ b/spec/lib/gitlab/ci/status/scheduled_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Scheduled do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'delayed' }
+ describe "#text" do
+ it { expect(subject.text).to eq "delayed" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'delayed' }
+ describe "#label" do
+ it { expect(subject.label).to eq "delayed" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_scheduled' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_scheduled" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_scheduled' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_scheduled" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'scheduled' }
+ describe "#group" do
+ it { expect(subject.group).to eq "scheduled" }
end
end
diff --git a/spec/lib/gitlab/ci/status/skipped_spec.rb b/spec/lib/gitlab/ci/status/skipped_spec.rb
index 63694ca0ea6..ef560026305 100644
--- a/spec/lib/gitlab/ci/status/skipped_spec.rb
+++ b/spec/lib/gitlab/ci/status/skipped_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Skipped do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'skipped' }
+ describe "#text" do
+ it { expect(subject.text).to eq "skipped" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'skipped' }
+ describe "#label" do
+ it { expect(subject.label).to eq "skipped" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_skipped' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_skipped" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_skipped' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_skipped" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'skipped' }
+ describe "#group" do
+ it { expect(subject.group).to eq "skipped" }
end
end
diff --git a/spec/lib/gitlab/ci/status/stage/common_spec.rb b/spec/lib/gitlab/ci/status/stage/common_spec.rb
index bb2d0a2c75c..dfa810e055e 100644
--- a/spec/lib/gitlab/ci/status/stage/common_spec.rb
+++ b/spec/lib/gitlab/ci/status/stage/common_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Stage::Common do
let(:user) { create(:user) }
@@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Stage::Common do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:stage) do
- build(:ci_stage, pipeline: pipeline, name: 'test')
+ build(:ci_stage, pipeline: pipeline, name: "test")
end
subject do
@@ -14,29 +14,29 @@ describe Gitlab::Ci::Status::Stage::Common do
.new(stage, user).extend(described_class)
end
- it 'does not have action' do
+ it "does not have action" do
expect(subject).not_to have_action
end
- it 'links to the pipeline details page' do
+ it "links to the pipeline details page" do
expect(subject.details_path)
.to include "pipelines/#{pipeline.id}"
expect(subject.details_path)
.to include "##{stage.name}"
end
- context 'when user has permission to read pipeline' do
+ context "when user has permission to read pipeline" do
before do
project.add_maintainer(user)
end
- it 'has details' do
+ it "has details" do
expect(subject).to have_details
end
end
- context 'when user does not have permission to read pipeline' do
- it 'does not have details' do
+ context "when user does not have permission to read pipeline" do
+ it "does not have details" do
expect(subject).not_to have_details
end
end
diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb
index dee4f4efd1b..123af550136 100644
--- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Stage::Factory do
let(:user) { create(:user) }
@@ -6,7 +6,7 @@ describe Gitlab::Ci::Status::Stage::Factory do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:stage) do
- build(:ci_stage, pipeline: pipeline, name: 'test')
+ build(:ci_stage, pipeline: pipeline, name: "test")
end
subject do
@@ -21,21 +21,22 @@ describe Gitlab::Ci::Status::Stage::Factory do
project.add_developer(user)
end
- context 'when stage has a core status' do
+ context "when stage has a core status" do
HasStatus::AVAILABLE_STATUSES.each do |core_status|
context "when core status is #{core_status}" do
before do
- create(:ci_build, pipeline: pipeline, stage: 'test', status: core_status)
- create(:commit_status, pipeline: pipeline, stage: 'test', status: core_status)
- create(:ci_build, pipeline: pipeline, stage: 'build', status: :failed)
+ create(:ci_build, pipeline: pipeline, stage: "test", status: core_status)
+ create(:commit_status, pipeline: pipeline, stage: "test", status: core_status)
+ create(:ci_build, pipeline: pipeline, stage: "build", status: :failed)
end
it "fabricates a core status #{core_status}" do
expect(status).to be_a(
- Gitlab::Ci::Status.const_get(core_status.capitalize))
+ Gitlab::Ci::Status.const_get(core_status.capitalize)
+ )
end
- it 'extends core status with common stage methods' do
+ it "extends core status with common stage methods" do
expect(status).to have_details
expect(status.details_path).to include "pipelines/#{pipeline.id}"
expect(status.details_path).to include "##{stage.name}"
@@ -44,14 +45,14 @@ describe Gitlab::Ci::Status::Stage::Factory do
end
end
- context 'when stage has warnings' do
+ context "when stage has warnings" do
let(:stage) do
- build(:ci_stage, name: 'test', status: :success, pipeline: pipeline)
+ build(:ci_stage, name: "test", status: :success, pipeline: pipeline)
end
before do
create(:ci_build, :allowed_to_fail, :failed,
- stage: 'test', pipeline: stage.pipeline)
+ stage: "test", pipeline: stage.pipeline)
end
it 'fabricates extended "success with warnings" status' do
@@ -59,7 +60,7 @@ describe Gitlab::Ci::Status::Stage::Factory do
.to be_a Gitlab::Ci::Status::SuccessWarning
end
- it 'extends core status with common stage method' do
+ it "extends core status with common stage method" do
expect(status).to have_details
expect(status.details_path).to include "pipelines/#{pipeline.id}##{stage.name}"
end
diff --git a/spec/lib/gitlab/ci/status/success_spec.rb b/spec/lib/gitlab/ci/status/success_spec.rb
index 2f67df71c4f..31320b0bf79 100644
--- a/spec/lib/gitlab/ci/status/success_spec.rb
+++ b/spec/lib/gitlab/ci/status/success_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::Success do
subject do
- described_class.new(double('subject'), double('user'))
+ described_class.new(double("subject"), double("user"))
end
- describe '#text' do
- it { expect(subject.text).to eq 'passed' }
+ describe "#text" do
+ it { expect(subject.text).to eq "passed" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'passed' }
+ describe "#label" do
+ it { expect(subject.label).to eq "passed" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_success' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_success" }
end
- describe '#favicon' do
- it { expect(subject.favicon).to eq 'favicon_status_success' }
+ describe "#favicon" do
+ it { expect(subject.favicon).to eq "favicon_status_success" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'success' }
+ describe "#group" do
+ it { expect(subject.group).to eq "success" }
end
end
diff --git a/spec/lib/gitlab/ci/status/success_warning_spec.rb b/spec/lib/gitlab/ci/status/success_warning_spec.rb
index 6d05545d1d8..110ef17304d 100644
--- a/spec/lib/gitlab/ci/status/success_warning_spec.rb
+++ b/spec/lib/gitlab/ci/status/success_warning_spec.rb
@@ -1,74 +1,74 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Status::SuccessWarning do
- let(:status) { double('status') }
+ let(:status) { double("status") }
subject do
described_class.new(status)
end
- describe '#test' do
- it { expect(subject.text).to eq 'passed' }
+ describe "#test" do
+ it { expect(subject.text).to eq "passed" }
end
- describe '#label' do
- it { expect(subject.label).to eq 'passed with warnings' }
+ describe "#label" do
+ it { expect(subject.label).to eq "passed with warnings" }
end
- describe '#icon' do
- it { expect(subject.icon).to eq 'status_warning' }
+ describe "#icon" do
+ it { expect(subject.icon).to eq "status_warning" }
end
- describe '#group' do
- it { expect(subject.group).to eq 'success_with_warnings' }
+ describe "#group" do
+ it { expect(subject.group).to eq "success_with_warnings" }
end
- describe '.matches?' do
- let(:matchable) { double('matchable') }
+ describe ".matches?" do
+ let(:matchable) { double("matchable") }
- context 'when matchable subject is successful' do
+ context "when matchable subject is successful" do
before do
allow(matchable).to receive(:success?).and_return(true)
end
- context 'when matchable subject has warnings' do
+ context "when matchable subject has warnings" do
before do
allow(matchable).to receive(:has_warnings?).and_return(true)
end
- it 'is a correct match' do
+ it "is a correct match" do
expect(described_class.matches?(matchable, double)).to eq true
end
end
- context 'when matchable subject does not have warnings' do
+ context "when matchable subject does not have warnings" do
before do
allow(matchable).to receive(:has_warnings?).and_return(false)
end
- it 'does not match' do
+ it "does not match" do
expect(described_class.matches?(matchable, double)).to eq false
end
end
end
- context 'when matchable subject is not successful' do
+ context "when matchable subject is not successful" do
before do
allow(matchable).to receive(:success?).and_return(false)
end
- context 'when matchable subject has warnings' do
+ context "when matchable subject has warnings" do
before do
allow(matchable).to receive(:has_warnings?).and_return(true)
end
- it 'does not match' do
+ it "does not match" do
expect(described_class.matches?(matchable, double)).to eq false
end
end
- context 'when matchable subject does not have warnings' do
- it 'does not match' do
+ context "when matchable subject does not have warnings" do
+ it "does not match" do
expect(described_class.matches?(matchable, double)).to eq false
end
end
diff --git a/spec/lib/gitlab/ci/templates/templates_spec.rb b/spec/lib/gitlab/ci/templates/templates_spec.rb
index 0dd74399a47..35a58ccfa71 100644
--- a/spec/lib/gitlab/ci/templates/templates_spec.rb
+++ b/spec/lib/gitlab/ci/templates/templates_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe "CI YML Templates" do
Gitlab::Template::GitlabCiYmlTemplate.all.each do |template|
diff --git a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
index 546a9e7d0cc..fb9aeda458c 100644
--- a/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
+++ b/spec/lib/gitlab/ci/trace/chunked_io_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
include ChunkedIOHelpers
@@ -11,24 +11,24 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
context "#initialize" do
- context 'when a chunk exists' do
+ context "when a chunk exists" do
before do
- build.trace.set('ABC')
+ build.trace.set("ABC")
end
it { expect(chunked_io.size).to eq(3) }
end
- context 'when two chunks exist' do
+ context "when two chunks exist" do
before do
stub_buffer_size(4)
- build.trace.set('ABCDEF')
+ build.trace.set("ABCDEF")
end
it { expect(chunked_io.size).to eq(6) }
end
- context 'when no chunks exists' do
+ context "when no chunks exists" do
it { expect(chunked_io.size).to eq(0) }
end
end
@@ -40,26 +40,26 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
build.trace.set(sample_trace_raw)
end
- context 'when moves pos to end of the file' do
+ context "when moves pos to end of the file" do
let(:pos) { 0 }
let(:where) { IO::SEEK_END }
it { is_expected.to eq(sample_trace_raw.bytesize) }
end
- context 'when moves pos to middle of the file' do
+ context "when moves pos to middle of the file" do
let(:pos) { sample_trace_raw.bytesize / 2 }
let(:where) { IO::SEEK_SET }
it { is_expected.to eq(pos) }
end
- context 'when moves pos around' do
- it 'matches the result' do
+ context "when moves pos around" do
+ it "matches the result" do
expect(chunked_io.seek(0)).to eq(0)
expect(chunked_io.seek(100, IO::SEEK_CUR)).to eq(100)
expect { chunked_io.seek(sample_trace_raw.bytesize + 1, IO::SEEK_CUR) }
- .to raise_error('new position is outside of file')
+ .to raise_error("new position is outside of file")
end
end
end
@@ -71,7 +71,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
build.trace.set(sample_trace_raw)
end
- context 'when current pos is at end of the file' do
+ context "when current pos is at end of the file" do
before do
chunked_io.seek(sample_trace_raw.bytesize, IO::SEEK_SET)
end
@@ -79,7 +79,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
it { is_expected.to be_truthy }
end
- context 'when current pos is not at end of the file' do
+ context "when current pos is not at end of the file" do
before do
chunked_io.seek(0, IO::SEEK_SET)
end
@@ -91,25 +91,25 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
context "#each_line" do
let(:string_io) { StringIO.new(sample_trace_raw) }
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it 'yields lines' do
+ it "yields lines" do
expect { |b| chunked_io.each_line(&b) }
.to yield_successive_args(*string_io.each_line.to_a)
end
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it 'calls get_chunk only once' do
+ it "calls get_chunk only once" do
expect_any_instance_of(Gitlab::Ci::Trace::ChunkedIO)
.to receive(:current_chunk).once.and_call_original
@@ -117,14 +117,14 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when buffer consist of many empty lines' do
+ context "when buffer consist of many empty lines" do
let(:sample_trace_raw) { Array.new(10, " ").join("\n") }
before do
build.trace.set(sample_trace_raw)
end
- it 'yields lines' do
+ it "yields lines" do
expect { |b| chunked_io.each_line(&b) }
.to yield_successive_args(*string_io.each_line.to_a)
end
@@ -134,10 +134,10 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
context "#read" do
subject { chunked_io.read(length) }
- context 'when read the whole size' do
+ context "when read the whole size" do
let(:length) { nil }
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
@@ -146,7 +146,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
it { is_expected.to eq(sample_trace_raw) }
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
@@ -156,7 +156,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when chunk is missing data' do
+ context "when chunk is missing data" do
let(:length) { nil }
before do
@@ -164,87 +164,87 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
build.trace.set(sample_trace_raw)
# make second chunk to not have data
- build.trace_chunks.second.append('', 0)
+ build.trace_chunks.second.append("", 0)
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error described_class::FailedToGetChunkError
end
end
- context 'when read only first 100 bytes' do
+ context "when read only first 100 bytes" do
let(:length) { 100 }
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(sample_trace_raw.byteslice(0, length))
end
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(sample_trace_raw.byteslice(0, length))
end
end
end
- context 'when tries to read oversize' do
+ context "when tries to read oversize" do
let(:length) { sample_trace_raw.bytesize + 1000 }
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(sample_trace_raw)
end
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(sample_trace_raw)
end
end
end
- context 'when tries to read 0 bytes' do
+ context "when tries to read 0 bytes" do
let(:length) { 0 }
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to be_empty
end
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to be_empty
end
end
@@ -256,7 +256,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
let(:string_io) { StringIO.new(sample_trace_raw) }
- shared_examples 'all line matching' do
+ shared_examples "all line matching" do
it do
(0...sample_trace_raw.lines.count).each do
expect(chunked_io.readline).to eq(string_io.readline)
@@ -264,25 +264,25 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it_behaves_like 'all line matching'
+ it_behaves_like "all line matching"
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it_behaves_like 'all line matching'
+ it_behaves_like "all line matching"
end
- context 'when pos is at middle of the file' do
+ context "when pos is at middle of the file" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
@@ -291,27 +291,27 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
string_io.seek(string_io.size / 2)
end
- it 'reads from pos' do
+ it "reads from pos" do
expect(chunked_io.readline).to eq(string_io.readline)
end
end
- context 'when chunk is missing data' do
+ context "when chunk is missing data" do
let(:length) { nil }
before do
build.trace.set(sample_trace_raw)
# make first chunk to have invalid data
- build.trace_chunks.first.append('data', 0)
+ build.trace_chunks.first.append("data", 0)
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error described_class::FailedToGetChunkError
end
end
- context 'when utf-8 is being used' do
+ context "when utf-8 is being used" do
let(:sample_trace_raw) { sample_trace_raw_utf8.force_encoding(Encoding::BINARY) }
let(:sample_trace_raw_utf8) { "😺\n😺\n😺\n😺" }
@@ -321,13 +321,13 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
build.trace.set(sample_trace_raw_utf8)
end
- it 'has known length' do
+ it "has known length" do
expect(sample_trace_raw_utf8.bytesize).to eq(4 * 4 + 3 * 1)
expect(sample_trace_raw.bytesize).to eq(4 * 4 + 3 * 1)
expect(chunked_io.size).to eq(4 * 4 + 3 * 1)
end
- it_behaves_like 'all line matching'
+ it_behaves_like "all line matching"
end
end
@@ -336,8 +336,8 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
let(:data) { sample_trace_raw }
- context 'when data does not exist' do
- shared_examples 'writes a trace' do
+ context "when data does not exist" do
+ shared_examples "writes a trace" do
it do
is_expected.to eq(data.bytesize)
@@ -346,27 +346,27 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(data.bytesize / 2)
end
- it_behaves_like 'writes a trace'
+ it_behaves_like "writes a trace"
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(data.bytesize * 2)
end
- it_behaves_like 'writes a trace'
+ it_behaves_like "writes a trace"
end
end
- context 'when data already exists' do
- let(:exist_data) { 'exist data' }
+ context "when data already exists" do
+ let(:exist_data) { "exist data" }
- shared_examples 'appends a trace' do
+ shared_examples "appends a trace" do
it do
chunked_io.seek(0, IO::SEEK_END)
is_expected.to eq(data.bytesize)
@@ -376,22 +376,22 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(exist_data)
end
- it_behaves_like 'appends a trace'
+ it_behaves_like "appends a trace"
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(exist_data)
end
- it_behaves_like 'appends a trace'
+ it_behaves_like "appends a trace"
end
end
end
@@ -399,8 +399,8 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
context "#truncate" do
let(:offset) { 10 }
- context 'when data does not exist' do
- shared_examples 'truncates a trace' do
+ context "when data does not exist" do
+ shared_examples "truncates a trace" do
it do
chunked_io.truncate(offset)
@@ -409,22 +409,22 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
end
end
- context 'when buffer size is smaller than file size' do
+ context "when buffer size is smaller than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize / 2)
build.trace.set(sample_trace_raw)
end
- it_behaves_like 'truncates a trace'
+ it_behaves_like "truncates a trace"
end
- context 'when buffer size is larger than file size' do
+ context "when buffer size is larger than file size" do
before do
stub_buffer_size(sample_trace_raw.bytesize * 2)
build.trace.set(sample_trace_raw)
end
- it_behaves_like 'truncates a trace'
+ it_behaves_like "truncates a trace"
end
end
end
@@ -436,7 +436,7 @@ describe Gitlab::Ci::Trace::ChunkedIO, :clean_gitlab_redis_cache do
build.trace.set(sample_trace_raw)
end
- it 'deletes' do
+ it "deletes" do
expect { subject }.to change { chunked_io.size }
.from(sample_trace_raw.bytesize).to(0)
diff --git a/spec/lib/gitlab/ci/trace/section_parser_spec.rb b/spec/lib/gitlab/ci/trace/section_parser_spec.rb
index ca53ff87c6f..dd85d396362 100644
--- a/spec/lib/gitlab/ci/trace/section_parser_spec.rb
+++ b/spec/lib/gitlab/ci/trace/section_parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Trace::SectionParser do
def lines_with_pos(text)
@@ -18,45 +18,45 @@ describe Gitlab::Ci::Trace::SectionParser do
"section_start:#{start.to_i}:#{name}\r\033[0K#{text}section_end:#{end_.to_i}:#{name}\r\033[0K"
end
- let(:lines) { build_lines('') }
+ let(:lines) { build_lines("") }
subject { described_class.new(lines) }
- describe '#sections' do
+ describe "#sections" do
before do
subject.parse!
end
- context 'empty trace' do
- let(:lines) { build_lines('') }
+ context "empty trace" do
+ let(:lines) { build_lines("") }
it { expect(subject.sections).to be_empty }
end
- context 'with a sectionless trace' do
+ context "with a sectionless trace" do
let(:lines) { build_lines("line 1\nline 2\n") }
it { expect(subject.sections).to be_empty }
end
- context 'with trace markers' do
+ context "with trace markers" do
let(:start_time) { Time.new(2017, 10, 5).utc }
let(:section_b_duration) { 1.second }
- let(:section_a) { section('a', start_time, 0, 'a line') }
- let(:section_b) { section('b', start_time, section_b_duration, "another line\n") }
+ let(:section_a) { section("a", start_time, 0, "a line") }
+ let(:section_b) { section("b", start_time, section_b_duration, "another line\n") }
let(:lines) { build_lines(section_a + section_b) }
it { expect(subject.sections.size).to eq(2) }
- it { expect(subject.sections[1][:name]).to eq('b') }
+ it { expect(subject.sections[1][:name]).to eq("b") }
it { expect(subject.sections[1][:date_start]).to eq(start_time) }
it { expect(subject.sections[1][:date_end]).to eq(start_time + section_b_duration) }
end
end
- describe '#parse!' do
+ describe "#parse!" do
context 'multiple "section_" but no complete markers' do
- let(:lines) { build_lines('section_section_section_') }
+ let(:lines) { build_lines("section_section_section_") }
- it 'must find 3 possible section start but no complete sections' do
+ it "must find 3 possible section start but no complete sections" do
expect(subject).to receive(:find_next_marker).exactly(3).times.and_call_original
subject.parse!
@@ -65,12 +65,12 @@ describe Gitlab::Ci::Trace::SectionParser do
end
end
- context 'trace with UTF-8 chars' do
+ context "trace with UTF-8 chars" do
let(:line) { 'GitLab ❤️ 狸 (tanukis)\n' }
- let(:trace) { section('test_section', Time.new(2017, 10, 5).utc, 3.seconds, line) }
+ let(:trace) { section("test_section", Time.new(2017, 10, 5).utc, 3.seconds, line) }
let(:lines) { build_lines(trace) }
- it 'must handle correctly byte positioning' do
+ it "must handle correctly byte positioning" do
expect(subject).to receive(:find_next_marker).exactly(2).times.and_call_original
subject.parse!
diff --git a/spec/lib/gitlab/ci/trace/stream_spec.rb b/spec/lib/gitlab/ci/trace/stream_spec.rb
index 38626f728d7..10451e6fc48 100644
--- a/spec/lib/gitlab/ci/trace/stream_spec.rb
+++ b/spec/lib/gitlab/ci/trace/stream_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
set(:build) { create(:ci_build, :running) }
@@ -7,7 +7,7 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
stub_feature_flags(ci_enable_live_trace: true)
end
- describe 'delegates' do
+ describe "delegates" do
subject { described_class.new { nil } }
it { is_expected.to delegate_method(:close).to(:stream) }
@@ -19,37 +19,37 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
it { is_expected.to delegate_method(:valid?).to(:stream).as(:present?) }
end
- describe '#limit' do
- shared_examples_for 'limits' do
- it 'if size is larger we start from beginning' do
+ describe "#limit" do
+ shared_examples_for "limits" do
+ it "if size is larger we start from beginning" do
stream.limit(20)
expect(stream.tell).to eq(0)
end
- it 'if size is smaller we start from the end' do
+ it "if size is smaller we start from the end" do
stream.limit(2)
expect(stream.raw).to eq("8")
end
- context 'when the trace contains ANSI sequence and Unicode' do
+ context "when the trace contains ANSI sequence and Unicode" do
let(:stream) do
described_class.new do
- File.open(expand_fixture_path('trace/ansi-sequence-and-unicode'))
+ File.open(expand_fixture_path("trace/ansi-sequence-and-unicode"))
end
end
- it 'forwards to the next linefeed, case 1' do
+ it "forwards to the next linefeed, case 1" do
stream.limit(7)
result = stream.raw
- expect(result).to eq('')
+ expect(result).to eq("")
expect(result.encoding).to eq(Encoding.default_external)
end
- it 'forwards to the next linefeed, case 2' do
+ it "forwards to the next linefeed, case 2" do
stream.limit(29)
result = stream.raw
@@ -59,7 +59,7 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/30796
- it 'reads in binary, output as Encoding.default_external' do
+ it "reads in binary, output as Encoding.default_external" do
stream.limit(52)
result = stream.html
@@ -70,17 +70,17 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- context 'when stream is StringIO' do
+ context "when stream is StringIO" do
let(:stream) do
described_class.new do
StringIO.new((1..8).to_a.join("\n"))
end
end
- it_behaves_like 'limits'
+ it_behaves_like "limits"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
@@ -90,12 +90,12 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- it_behaves_like 'limits'
+ it_behaves_like "limits"
end
end
- describe '#append' do
- shared_examples_for 'appends' do
+ describe "#append" do
+ shared_examples_for "appends" do
it "truncates and append content" do
stream.append("89", 4)
stream.seek(0)
@@ -104,19 +104,19 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
expect(stream.raw).to eq("123489")
end
- it 'appends in binary mode' do
- '😺'.force_encoding('ASCII-8BIT').each_char.with_index do |byte, offset|
+ it "appends in binary mode" do
+ "😺".force_encoding("ASCII-8BIT").each_char.with_index do |byte, offset|
stream.append(byte, offset)
end
stream.seek(0)
expect(stream.size).to eq(4)
- expect(stream.raw).to eq('😺')
+ expect(stream.raw).to eq("😺")
end
end
- context 'when stream is Tempfile' do
+ context "when stream is Tempfile" do
let(:tempfile) { Tempfile.new }
let(:stream) do
@@ -131,25 +131,25 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
tempfile.unlink
end
- it_behaves_like 'appends'
+ it_behaves_like "appends"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
- chunked_io.write('12345678')
+ chunked_io.write("12345678")
chunked_io.seek(0, IO::SEEK_SET)
end
end
end
- it_behaves_like 'appends'
+ it_behaves_like "appends"
end
end
- describe '#set' do
- shared_examples_for 'sets' do
+ describe "#set" do
+ shared_examples_for "sets" do
before do
stream.set("8901")
end
@@ -162,54 +162,54 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- context 'when stream is StringIO' do
+ context "when stream is StringIO" do
let(:stream) do
described_class.new do
StringIO.new("12345678")
end
end
- it_behaves_like 'sets'
+ it_behaves_like "sets"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
- chunked_io.write('12345678')
+ chunked_io.write("12345678")
chunked_io.seek(0, IO::SEEK_SET)
end
end
end
- it_behaves_like 'sets'
+ it_behaves_like "sets"
end
end
- describe '#raw' do
- shared_examples_for 'sets' do
- it 'returns all contents if last_lines is not specified' do
+ describe "#raw" do
+ shared_examples_for "sets" do
+ it "returns all contents if last_lines is not specified" do
result = stream.raw
expect(result).to eq(lines.join)
expect(result.encoding).to eq(Encoding.default_external)
end
- context 'limit max lines' do
+ context "limit max lines" do
before do
# specifying BUFFER_SIZE forces to seek backwards
allow(described_class).to receive(:BUFFER_SIZE)
.and_return(2)
end
- it 'returns last few lines' do
+ it "returns last few lines" do
result = stream.raw(last_lines: 2)
expect(result).to eq(lines.last(2).join)
expect(result.encoding).to eq(Encoding.default_external)
end
- it 'returns everything if trying to get too many lines' do
+ it "returns everything if trying to get too many lines" do
result = stream.raw(last_lines: lines.size * 2)
expect(result).to eq(lines.join)
@@ -221,17 +221,17 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
let(:path) { __FILE__ }
let(:lines) { File.readlines(path) }
- context 'when stream is File' do
+ context "when stream is File" do
let(:stream) do
described_class.new do
File.open(path)
end
end
- it_behaves_like 'sets'
+ it_behaves_like "sets"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
@@ -241,19 +241,19 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- it_behaves_like 'sets'
+ it_behaves_like "sets"
end
end
- describe '#html_with_state' do
- shared_examples_for 'html_with_states' do
- it 'returns html content with state' do
+ describe "#html_with_state" do
+ shared_examples_for "html_with_states" do
+ it "returns html content with state" do
result = stream.html_with_state
expect(result.html).to eq("1234")
end
- context 'follow-up state' do
+ context "follow-up state" do
let!(:last_result) { stream.html_with_state }
before do
@@ -271,7 +271,7 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- context 'when stream is StringIO' do
+ context "when stream is StringIO" do
let(:data_stream) do
StringIO.new("1234")
end
@@ -280,10 +280,10 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
described_class.new { data_stream }
end
- it_behaves_like 'html_with_states'
+ it_behaves_like "html_with_states"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:data_stream) do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
chunked_io.write("1234")
@@ -295,12 +295,12 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
described_class.new { data_stream }
end
- it_behaves_like 'html_with_states'
+ it_behaves_like "html_with_states"
end
end
- describe '#html' do
- shared_examples_for 'htmls' do
+ describe "#html" do
+ shared_examples_for "htmls" do
it "returns html" do
expect(stream.html).to eq("12<br>34<br>56")
end
@@ -310,17 +310,17 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- context 'when stream is StringIO' do
+ context "when stream is StringIO" do
let(:stream) do
described_class.new do
StringIO.new("12\n34\n56")
end
end
- it_behaves_like 'htmls'
+ it_behaves_like "htmls"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
@@ -330,34 +330,34 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- it_behaves_like 'htmls'
+ it_behaves_like "htmls"
end
end
- describe '#extract_coverage' do
- shared_examples_for 'extract_coverages' do
- context 'valid content & regex' do
- let(:data) { 'Coverage 1033 / 1051 LOC (98.29%) covered' }
+ describe "#extract_coverage" do
+ shared_examples_for "extract_coverages" do
+ context "valid content & regex" do
+ let(:data) { "Coverage 1033 / 1051 LOC (98.29%) covered" }
let(:regex) { '\(\d+.\d+\%\) covered' }
it { is_expected.to eq("98.29") }
end
- context 'valid content & bad regex' do
+ context "valid content & bad regex" do
let(:data) { 'Coverage 1033 / 1051 LOC (98.29%) covered\n' }
- let(:regex) { 'very covered' }
+ let(:regex) { "very covered" }
it { is_expected.to be_nil }
end
- context 'no coverage content & regex' do
- let(:data) { 'No coverage for today :sad:' }
+ context "no coverage content & regex" do
+ let(:data) { "No coverage for today :sad:" }
let(:regex) { '\(\d+.\d+\%\) covered' }
it { is_expected.to be_nil }
end
- context 'multiple results in content & regex' do
+ context "multiple results in content & regex" do
let(:data) do
<<~HEREDOC
(98.39%) covered
@@ -367,95 +367,95 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
let(:regex) { '\(\d+.\d+\%\) covered' }
- it 'returns the last matched coverage' do
+ it "returns the last matched coverage" do
is_expected.to eq("98.29")
end
end
- context 'when BUFFER_SIZE is smaller than stream.size' do
+ context "when BUFFER_SIZE is smaller than stream.size" do
let(:data) { 'Coverage 1033 / 1051 LOC (98.29%) covered\n' }
let(:regex) { '\(\d+.\d+\%\) covered' }
before do
- stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', 5)
+ stub_const("Gitlab::Ci::Trace::Stream::BUFFER_SIZE", 5)
end
it { is_expected.to eq("98.29") }
end
- context 'when regex is multi-byte char' do
+ context "when regex is multi-byte char" do
let(:data) { '95.0 ゴッドファット\n' }
let(:regex) { '\d+\.\d+ ゴッドファット' }
before do
- stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', 5)
+ stub_const("Gitlab::Ci::Trace::Stream::BUFFER_SIZE", 5)
end
- it { is_expected.to eq('95.0') }
+ it { is_expected.to eq("95.0") }
end
- context 'when BUFFER_SIZE is equal to stream.size' do
+ context "when BUFFER_SIZE is equal to stream.size" do
let(:data) { 'Coverage 1033 / 1051 LOC (98.29%) covered\n' }
let(:regex) { '\(\d+.\d+\%\) covered' }
before do
- stub_const('Gitlab::Ci::Trace::Stream::BUFFER_SIZE', data.length)
+ stub_const("Gitlab::Ci::Trace::Stream::BUFFER_SIZE", data.length)
end
it { is_expected.to eq("98.29") }
end
- context 'using a regex capture' do
- let(:data) { 'TOTAL 9926 3489 65%' }
+ context "using a regex capture" do
+ let(:data) { "TOTAL 9926 3489 65%" }
let(:regex) { 'TOTAL\s+\d+\s+\d+\s+(\d{1,3}\%)' }
it { is_expected.to eq("65") }
end
- context 'malicious regexp' do
+ context "malicious regexp" do
let(:data) { malicious_text }
let(:regex) { malicious_regexp }
- include_examples 'malicious regexp'
+ include_examples "malicious regexp"
end
- context 'multi-line data with rooted regexp' do
+ context "multi-line data with rooted regexp" do
let(:data) { "\n65%\n" }
let(:regex) { '^(\d+)\%$' }
- it { is_expected.to eq('65') }
+ it { is_expected.to eq("65") }
end
- context 'long line' do
- let(:data) { 'a' * 80000 + '100%' + 'a' * 80000 }
+ context "long line" do
+ let(:data) { "a" * 80000 + "100%" + "a" * 80000 }
let(:regex) { '\d+\%' }
- it { is_expected.to eq('100') }
+ it { is_expected.to eq("100") }
end
- context 'many lines' do
+ context "many lines" do
let(:data) { "foo\n" * 80000 + "100%\n" + "foo\n" * 80000 }
let(:regex) { '\d+\%' }
- it { is_expected.to eq('100') }
+ it { is_expected.to eq("100") }
end
- context 'empty regex' do
- let(:data) { 'foo' }
- let(:regex) { '' }
+ context "empty regex" do
+ let(:data) { "foo" }
+ let(:regex) { "" }
- it 'skips processing' do
+ it "skips processing" do
expect(stream).not_to receive(:read)
is_expected.to be_nil
end
end
- context 'nil regex' do
- let(:data) { 'foo' }
+ context "nil regex" do
+ let(:data) { "foo" }
let(:regex) { nil }
- it 'skips processing' do
+ it "skips processing" do
expect(stream).not_to receive(:read)
is_expected.to be_nil
@@ -465,17 +465,17 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
subject { stream.extract_coverage(regex) }
- context 'when stream is StringIO' do
+ context "when stream is StringIO" do
let(:stream) do
described_class.new do
StringIO.new(data)
end
end
- it_behaves_like 'extract_coverages'
+ it_behaves_like "extract_coverages"
end
- context 'when stream is ChunkedIO' do
+ context "when stream is ChunkedIO" do
let(:stream) do
described_class.new do
Gitlab::Ci::Trace::ChunkedIO.new(build).tap do |chunked_io|
@@ -485,7 +485,7 @@ describe Gitlab::Ci::Trace::Stream, :clean_gitlab_redis_cache do
end
end
- it_behaves_like 'extract_coverages'
+ it_behaves_like "extract_coverages"
end
end
end
diff --git a/spec/lib/gitlab/ci/trace_spec.rb b/spec/lib/gitlab/ci/trace_spec.rb
index d6510649dba..45effa0367a 100644
--- a/spec/lib/gitlab/ci/trace_spec.rb
+++ b/spec/lib/gitlab/ci/trace_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state do
let(:build) { create(:ci_build) }
@@ -9,19 +9,19 @@ describe Gitlab::Ci::Trace, :clean_gitlab_redis_shared_state do
it { expect(trace).to delegate_method(:old_trace).to(:job) }
end
- context 'when live trace feature is disabled' do
+ context "when live trace feature is disabled" do
before do
stub_feature_flags(ci_enable_live_trace: false)
end
- it_behaves_like 'trace with disabled live trace feature'
+ it_behaves_like "trace with disabled live trace feature"
end
- context 'when live trace feature is enabled' do
+ context "when live trace feature is enabled" do
before do
stub_feature_flags(ci_enable_live_trace: true)
end
- it_behaves_like 'trace with enabled live trace feature'
+ it_behaves_like "trace with enabled live trace feature"
end
end
diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
index 3ff2fe18c15..9a0ea23ab9f 100644
--- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb
+++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb
@@ -1,97 +1,97 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Variables::Collection::Item do
- let(:variable_key) { 'VAR' }
- let(:variable_value) { 'something' }
+ let(:variable_key) { "VAR" }
+ let(:variable_value) { "something" }
let(:expected_value) { variable_value }
let(:variable) do
- { key: variable_key, value: variable_value, public: true, masked: false }
+ {key: variable_key, value: variable_value, public: true, masked: false}
end
- describe '.new' do
- context 'when unknown keyword is specified' do
- it 'raises error' do
- expect { described_class.new(key: variable_key, value: 'abc', files: true) }
- .to raise_error ArgumentError, 'unknown keyword: files'
+ describe ".new" do
+ context "when unknown keyword is specified" do
+ it "raises error" do
+ expect { described_class.new(key: variable_key, value: "abc", files: true) }
+ .to raise_error ArgumentError, "unknown keyword: files"
end
end
- context 'when required keywords are not specified' do
- it 'raises error' do
+ context "when required keywords are not specified" do
+ it "raises error" do
expect { described_class.new(key: variable_key) }
- .to raise_error ArgumentError, 'missing keyword: value'
+ .to raise_error ArgumentError, "missing keyword: value"
end
end
- shared_examples 'creates variable' do
+ shared_examples "creates variable" do
subject { described_class.new(key: variable_key, value: variable_value) }
- it 'saves given value' do
+ it "saves given value" do
expect(subject[:key]).to eq variable_key
expect(subject[:value]).to eq expected_value
end
end
- shared_examples 'raises error for invalid type' do
+ shared_examples "raises error for invalid type" do
it do
expect { described_class.new(key: variable_key, value: variable_value) }
.to raise_error ArgumentError, /`#{variable_key}` must be of type String or nil value, while it was:/
end
end
- it_behaves_like 'creates variable'
+ it_behaves_like "creates variable"
context "when it's nil" do
let(:variable_value) { nil }
let(:expected_value) { nil }
- it_behaves_like 'creates variable'
+ it_behaves_like "creates variable"
end
context "when it's an empty string" do
- let(:variable_value) { '' }
- let(:expected_value) { '' }
+ let(:variable_value) { "" }
+ let(:expected_value) { "" }
- it_behaves_like 'creates variable'
+ it_behaves_like "creates variable"
end
- context 'when provided value is not a string' do
+ context "when provided value is not a string" do
[1, false, [], {}, Object.new].each do |val|
context "when it's #{val}" do
let(:variable_value) { val }
- it_behaves_like 'raises error for invalid type'
+ it_behaves_like "raises error for invalid type"
end
end
end
end
- describe '.fabricate' do
- it 'supports using a hash' do
+ describe ".fabricate" do
+ it "supports using a hash" do
resource = described_class.fabricate(variable)
expect(resource).to be_a(described_class)
expect(resource).to eq variable
end
- it 'supports using a hash with stringified values' do
- variable = { 'key' => 'VARIABLE', 'value' => 'my value' }
+ it "supports using a hash with stringified values" do
+ variable = {"key" => "VARIABLE", "value" => "my value"}
resource = described_class.fabricate(variable)
- expect(resource).to eq(key: 'VARIABLE', value: 'my value')
+ expect(resource).to eq(key: "VARIABLE", value: "my value")
end
- it 'supports using an active record resource' do
- variable = create(:ci_variable, key: 'CI_VAR', value: '123')
+ it "supports using an active record resource" do
+ variable = create(:ci_variable, key: "CI_VAR", value: "123")
resource = described_class.fabricate(variable)
expect(resource).to be_a(described_class)
- expect(resource).to eq(key: 'CI_VAR', value: '123', public: false, masked: false)
+ expect(resource).to eq(key: "CI_VAR", value: "123", public: false, masked: false)
end
- it 'supports using another collection item' do
+ it "supports using another collection item" do
item = described_class.new(**variable)
resource = described_class.fabricate(item)
@@ -102,23 +102,23 @@ describe Gitlab::Ci::Variables::Collection::Item do
end
end
- describe '#==' do
- it 'compares a hash representation of a variable' do
+ describe "#==" do
+ it "compares a hash representation of a variable" do
expect(described_class.new(**variable) == variable).to be true
end
end
- describe '#[]' do
- it 'behaves like a hash accessor' do
+ describe "#[]" do
+ it "behaves like a hash accessor" do
item = described_class.new(**variable)
- expect(item[:key]).to eq 'VAR'
+ expect(item[:key]).to eq "VAR"
end
end
- describe '#to_runner_variable' do
- context 'when variable is not a file-related' do
- it 'returns a runner-compatible hash representation' do
+ describe "#to_runner_variable" do
+ context "when variable is not a file-related" do
+ it "returns a runner-compatible hash representation" do
runner_variable = described_class
.new(**variable)
.to_runner_variable
@@ -127,28 +127,28 @@ describe Gitlab::Ci::Variables::Collection::Item do
end
end
- context 'when variable is file-related' do
- it 'appends file description component' do
+ context "when variable is file-related" do
+ it "appends file description component" do
runner_variable = described_class
- .new(key: 'VAR', value: 'value', file: true)
+ .new(key: "VAR", value: "value", file: true)
.to_runner_variable
expect(runner_variable)
- .to eq(key: 'VAR', value: 'value', public: true, file: true, masked: false)
+ .to eq(key: "VAR", value: "value", public: true, file: true, masked: false)
end
end
- context 'when variable masking is disabled' do
+ context "when variable masking is disabled" do
before do
stub_feature_flags(variable_masking: false)
end
- it 'does not expose the masked field to the runner' do
+ it "does not expose the masked field to the runner" do
runner_variable = described_class
- .new(key: 'VAR', value: 'value', masked: true)
+ .new(key: "VAR", value: "value", masked: true)
.to_runner_variable
- expect(runner_variable).to eq(key: 'VAR', value: 'value', public: true)
+ expect(runner_variable).to eq(key: "VAR", value: "value", public: true)
end
end
end
diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb
index edb209c0cf4..42a2f3cb2d3 100644
--- a/spec/lib/gitlab/ci/variables/collection_spec.rb
+++ b/spec/lib/gitlab/ci/variables/collection_spec.rb
@@ -1,114 +1,114 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Ci::Variables::Collection do
- describe '.new' do
- it 'can be initialized with an array' do
- variable = { key: 'VAR', value: 'value', public: true, masked: false }
+ describe ".new" do
+ it "can be initialized with an array" do
+ variable = {key: "VAR", value: "value", public: true, masked: false}
collection = described_class.new([variable])
expect(collection.first.to_runner_variable).to eq variable
end
- it 'can be initialized without an argument' do
+ it "can be initialized without an argument" do
expect(subject).to be_none
end
end
- describe '#append' do
- it 'appends a hash' do
- subject.append(key: 'VARIABLE', value: 'something')
+ describe "#append" do
+ it "appends a hash" do
+ subject.append(key: "VARIABLE", value: "something")
expect(subject).to be_one
end
- it 'appends a Ci::Variable' do
+ it "appends a Ci::Variable" do
subject.append(build(:ci_variable))
expect(subject).to be_one
end
- it 'appends an internal resource' do
- collection = described_class.new([{ key: 'TEST', value: '1' }])
+ it "appends an internal resource" do
+ collection = described_class.new([{key: "TEST", value: "1"}])
subject.append(collection.first)
expect(subject).to be_one
end
- it 'returns self' do
- expect(subject.append(key: 'VAR', value: 'test'))
+ it "returns self" do
+ expect(subject.append(key: "VAR", value: "test"))
.to eq subject
end
end
- describe '#concat' do
- it 'appends all elements from an array' do
- collection = described_class.new([{ key: 'VAR_1', value: '1' }])
- variables = [{ key: 'VAR_2', value: '2' }, { key: 'VAR_3', value: '3' }]
+ describe "#concat" do
+ it "appends all elements from an array" do
+ collection = described_class.new([{key: "VAR_1", value: "1"}])
+ variables = [{key: "VAR_2", value: "2"}, {key: "VAR_3", value: "3"}]
collection.concat(variables)
- expect(collection).to include(key: 'VAR_1', value: '1', public: true)
- expect(collection).to include(key: 'VAR_2', value: '2', public: true)
- expect(collection).to include(key: 'VAR_3', value: '3', public: true)
+ expect(collection).to include(key: "VAR_1", value: "1", public: true)
+ expect(collection).to include(key: "VAR_2", value: "2", public: true)
+ expect(collection).to include(key: "VAR_3", value: "3", public: true)
end
- it 'appends all elements from other collection' do
- collection = described_class.new([{ key: 'VAR_1', value: '1' }])
- additional = described_class.new([{ key: 'VAR_2', value: '2' },
- { key: 'VAR_3', value: '3' }])
+ it "appends all elements from other collection" do
+ collection = described_class.new([{key: "VAR_1", value: "1"}])
+ additional = described_class.new([{key: "VAR_2", value: "2"},
+ {key: "VAR_3", value: "3"},])
collection.concat(additional)
- expect(collection).to include(key: 'VAR_1', value: '1', public: true)
- expect(collection).to include(key: 'VAR_2', value: '2', public: true)
- expect(collection).to include(key: 'VAR_3', value: '3', public: true)
+ expect(collection).to include(key: "VAR_1", value: "1", public: true)
+ expect(collection).to include(key: "VAR_2", value: "2", public: true)
+ expect(collection).to include(key: "VAR_3", value: "3", public: true)
end
- it 'returns self' do
- expect(subject.concat([key: 'VAR', value: 'test']))
+ it "returns self" do
+ expect(subject.concat([key: "VAR", value: "test"]))
.to eq subject
end
end
- describe '#+' do
- it 'makes it possible to combine with an array' do
- collection = described_class.new([{ key: 'TEST', value: '1' }])
- variables = [{ key: 'TEST', value: 'something' }]
+ describe "#+" do
+ it "makes it possible to combine with an array" do
+ collection = described_class.new([{key: "TEST", value: "1"}])
+ variables = [{key: "TEST", value: "something"}]
expect((collection + variables).count).to eq 2
end
- it 'makes it possible to combine with another collection' do
- collection = described_class.new([{ key: 'TEST', value: '1' }])
- other = described_class.new([{ key: 'TEST', value: '2' }])
+ it "makes it possible to combine with another collection" do
+ collection = described_class.new([{key: "TEST", value: "1"}])
+ other = described_class.new([{key: "TEST", value: "2"}])
expect((collection + other).count).to eq 2
end
end
- describe '#to_runner_variables' do
- it 'creates an array of hashes in a runner-compatible format' do
- collection = described_class.new([{ key: 'TEST', value: '1' }])
+ describe "#to_runner_variables" do
+ it "creates an array of hashes in a runner-compatible format" do
+ collection = described_class.new([{key: "TEST", value: "1"}])
expect(collection.to_runner_variables)
- .to eq [{ key: 'TEST', value: '1', public: true, masked: false }]
+ .to eq [{key: "TEST", value: "1", public: true, masked: false}]
end
end
- describe '#to_hash' do
- it 'returns regular hash in valid order without duplicates' do
+ describe "#to_hash" do
+ it "returns regular hash in valid order without duplicates" do
collection = described_class.new
- .append(key: 'TEST1', value: 'test-1')
- .append(key: 'TEST2', value: 'test-2')
- .append(key: 'TEST1', value: 'test-3')
+ .append(key: "TEST1", value: "test-1")
+ .append(key: "TEST2", value: "test-2")
+ .append(key: "TEST1", value: "test-3")
- expect(collection.to_hash).to eq('TEST1' => 'test-3',
- 'TEST2' => 'test-2')
+ expect(collection.to_hash).to eq("TEST1" => "test-3",
+ "TEST2" => "test-2")
- expect(collection.to_hash).to include(TEST1: 'test-3')
- expect(collection.to_hash).not_to include(TEST1: 'test-1')
+ expect(collection.to_hash).to include(TEST1: "test-3")
+ expect(collection.to_hash).not_to include(TEST1: "test-1")
end
end
end
diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb
index 29638ef47c5..b89ef004af3 100644
--- a/spec/lib/gitlab/ci/yaml_processor_spec.rb
+++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb
@@ -1,243 +1,243 @@
-require 'spec_helper'
+require "spec_helper"
module Gitlab
module Ci
describe YamlProcessor do
subject { described_class.new(config, user: nil) }
- describe '#build_attributes' do
+ describe "#build_attributes" do
subject { described_class.new(config, user: nil).build_attributes(:rspec) }
- describe 'attributes list' do
+ describe "attributes list" do
let(:config) do
YAML.dump(
- before_script: ['pwd'],
- rspec: { script: 'rspec' }
+ before_script: ["pwd"],
+ rspec: {script: "rspec"}
)
end
- it 'returns valid build attributes' do
+ it "returns valid build attributes" do
expect(subject).to eq({
stage: "test",
stage_idx: 1,
name: "rspec",
options: {
before_script: ["pwd"],
- script: ["rspec"]
+ script: ["rspec"],
},
allow_failure: false,
when: "on_success",
- yaml_variables: []
+ yaml_variables: [],
})
end
end
- describe 'coverage entry' do
- describe 'code coverage regexp' do
+ describe "coverage entry" do
+ describe "code coverage regexp" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec',
- coverage: '/Code coverage: \d+\.\d+/' })
+ YAML.dump(rspec: {script: "rspec",
+ coverage: '/Code coverage: \d+\.\d+/',})
end
- it 'includes coverage regexp in build attributes' do
+ it "includes coverage regexp in build attributes" do
expect(subject)
.to include(coverage_regex: 'Code coverage: \d+\.\d+')
end
end
end
- describe 'retry entry' do
- context 'when retry count is specified' do
+ describe "retry entry" do
+ context "when retry count is specified" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec', retry: { max: 1 } })
+ YAML.dump(rspec: {script: "rspec", retry: {max: 1}})
end
- it 'includes retry count in build options attribute' do
- expect(subject[:options]).to include(retry: { max: 1 })
+ it "includes retry count in build options attribute" do
+ expect(subject[:options]).to include(retry: {max: 1})
end
end
- context 'when retry count is not specified' do
+ context "when retry count is not specified" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec' })
+ YAML.dump(rspec: {script: "rspec"})
end
- it 'does not persist retry count in the database' do
+ it "does not persist retry count in the database" do
expect(subject[:options]).not_to have_key(:retry)
end
end
end
- describe 'allow failure entry' do
- context 'when job is a manual action' do
- context 'when allow_failure is defined' do
+ describe "allow failure entry" do
+ context "when job is a manual action" do
+ context "when allow_failure is defined" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec',
- when: 'manual',
- allow_failure: false })
+ YAML.dump(rspec: {script: "rspec",
+ when: "manual",
+ allow_failure: false,})
end
- it 'is not allowed to fail' do
+ it "is not allowed to fail" do
expect(subject[:allow_failure]).to be false
end
end
- context 'when allow_failure is not defined' do
+ context "when allow_failure is not defined" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec',
- when: 'manual' })
+ YAML.dump(rspec: {script: "rspec",
+ when: "manual",})
end
- it 'is allowed to fail' do
+ it "is allowed to fail" do
expect(subject[:allow_failure]).to be true
end
end
end
- context 'when job is not a manual action' do
- context 'when allow_failure is defined' do
+ context "when job is not a manual action" do
+ context "when allow_failure is defined" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec',
- allow_failure: false })
+ YAML.dump(rspec: {script: "rspec",
+ allow_failure: false,})
end
- it 'is not allowed to fail' do
+ it "is not allowed to fail" do
expect(subject[:allow_failure]).to be false
end
end
- context 'when allow_failure is not defined' do
+ context "when allow_failure is not defined" do
let(:config) do
- YAML.dump(rspec: { script: 'rspec' })
+ YAML.dump(rspec: {script: "rspec"})
end
- it 'is not allowed to fail' do
+ it "is not allowed to fail" do
expect(subject[:allow_failure]).to be false
end
end
end
end
- describe 'delayed job entry' do
- context 'when delayed is defined' do
+ describe "delayed job entry" do
+ context "when delayed is defined" do
let(:config) do
- YAML.dump(rspec: { script: 'rollout 10%',
- when: 'delayed',
- start_in: '1 day' })
+ YAML.dump(rspec: {script: "rollout 10%",
+ when: "delayed",
+ start_in: "1 day",})
end
- it 'has the attributes' do
- expect(subject[:when]).to eq 'delayed'
- expect(subject[:options][:start_in]).to eq '1 day'
+ it "has the attributes" do
+ expect(subject[:when]).to eq "delayed"
+ expect(subject[:options][:start_in]).to eq "1 day"
end
end
end
end
- describe '#stages_attributes' do
+ describe "#stages_attributes" do
let(:config) do
YAML.dump(
- rspec: { script: 'rspec', stage: 'test', only: ['branches'] },
- prod: { script: 'cap prod', stage: 'deploy', only: ['tags'] }
+ rspec: {script: "rspec", stage: "test", only: ["branches"]},
+ prod: {script: "cap prod", stage: "deploy", only: ["tags"]}
)
end
let(:attributes) do
- [{ name: "build",
- index: 0,
- builds: [] },
- { name: "test",
- index: 1,
- builds:
- [{ stage_idx: 1,
- stage: "test",
- name: "rspec",
- allow_failure: false,
- when: "on_success",
- yaml_variables: [],
- options: { script: ["rspec"] },
- only: { refs: ["branches"] },
- except: {} }] },
- { name: "deploy",
- index: 2,
- builds:
- [{ stage_idx: 2,
- stage: "deploy",
- name: "prod",
- allow_failure: false,
- when: "on_success",
- yaml_variables: [],
- options: { script: ["cap prod"] },
- only: { refs: ["tags"] },
- except: {} }] }]
- end
-
- it 'returns stages seed attributes' do
+ [{name: "build",
+ index: 0,
+ builds: [],},
+ {name: "test",
+ index: 1,
+ builds:
+ [{stage_idx: 1,
+ stage: "test",
+ name: "rspec",
+ allow_failure: false,
+ when: "on_success",
+ yaml_variables: [],
+ options: {script: ["rspec"]},
+ only: {refs: ["branches"]},
+ except: {},}],},
+ {name: "deploy",
+ index: 2,
+ builds:
+ [{stage_idx: 2,
+ stage: "deploy",
+ name: "prod",
+ allow_failure: false,
+ when: "on_success",
+ yaml_variables: [],
+ options: {script: ["cap prod"]},
+ only: {refs: ["tags"]},
+ except: {},}],},]
+ end
+
+ it "returns stages seed attributes" do
expect(subject.stages_attributes).to eq attributes
end
end
- describe 'only / except policies validations' do
- context 'when `only` has an invalid value' do
- let(:config) { { rspec: { script: "rspec", type: "test", only: only } } }
+ describe "only / except policies validations" do
+ context "when `only` has an invalid value" do
+ let(:config) { {rspec: {script: "rspec", type: "test", only: only}} }
let(:processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)) }
- context 'when it is integer' do
+ context "when it is integer" do
let(:only) { 1 }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:only has to be either an array of conditions or a hash')
+ "jobs:rspec:only has to be either an array of conditions or a hash")
end
end
- context 'when it is an array of integers' do
+ context "when it is an array of integers" do
let(:only) { [1, 1] }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:only config should be an array of strings or regexps')
+ "jobs:rspec:only config should be an array of strings or regexps")
end
end
- context 'when it is invalid regex' do
+ context "when it is invalid regex" do
let(:only) { ["/*invalid/"] }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:only config should be an array of strings or regexps')
+ "jobs:rspec:only config should be an array of strings or regexps")
end
end
end
- context 'when `except` has an invalid value' do
- let(:config) { { rspec: { script: "rspec", except: except } } }
+ context "when `except` has an invalid value" do
+ let(:config) { {rspec: {script: "rspec", except: except}} }
let(:processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)) }
- context 'when it is integer' do
+ context "when it is integer" do
let(:except) { 1 }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:except has to be either an array of conditions or a hash')
+ "jobs:rspec:except has to be either an array of conditions or a hash")
end
end
- context 'when it is an array of integers' do
+ context "when it is an array of integers" do
let(:except) { [1, 1] }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:except config should be an array of strings or regexps')
+ "jobs:rspec:except config should be an array of strings or regexps")
end
end
- context 'when it is invalid regex' do
+ context "when it is invalid regex" do
let(:except) { ["/*invalid/"] }
it do
expect { processor }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:except config should be an array of strings or regexps')
+ "jobs:rspec:except config should be an array of strings or regexps")
end
end
end
@@ -247,14 +247,14 @@ module Gitlab
let(:config_data) { YAML.dump(config) }
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config_data) }
- subject { config_processor.stage_builds_attributes('test').first }
+ subject { config_processor.stage_builds_attributes("test").first }
describe "before_script" do
context "in global context" do
let(:config) do
{
before_script: ["global script"],
- test: { script: ["script"] }
+ test: {script: ["script"]},
}
end
@@ -267,7 +267,7 @@ module Gitlab
let(:config) do
{
before_script: ["global script"],
- test: { before_script: ["local script"], script: ["script"] }
+ test: {before_script: ["local script"], script: ["script"]},
}
end
@@ -280,7 +280,7 @@ module Gitlab
describe "script" do
let(:config) do
{
- test: { script: ["script"] }
+ test: {script: ["script"]},
}
end
@@ -294,7 +294,7 @@ module Gitlab
let(:config) do
{
after_script: ["after_script"],
- test: { script: ["script"] }
+ test: {script: ["script"]},
}
end
@@ -307,7 +307,7 @@ module Gitlab
let(:config) do
{
after_script: ["local after_script"],
- test: { after_script: ["local after_script"], script: ["script"] }
+ test: {after_script: ["local after_script"], script: ["script"]},
}
end
@@ -321,12 +321,12 @@ module Gitlab
describe "Image and service handling" do
context "when extended docker configuration is used" do
it "returns image and service when defined" do
- config = YAML.dump({ image: { name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"] },
- services: ["mysql", { name: "docker:dind", alias: "docker",
- entrypoint: ["/usr/local/bin/init", "run"],
- command: ["/usr/local/bin/init", "run"] }],
- before_script: ["pwd"],
- rspec: { script: "rspec" } })
+ config = YAML.dump({image: {name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"]},
+ services: ["mysql", {name: "docker:dind", alias: "docker",
+ entrypoint: ["/usr/local/bin/init", "run"],
+ command: ["/usr/local/bin/init", "run"],},],
+ before_script: ["pwd"],
+ rspec: {script: "rspec"},})
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -338,26 +338,26 @@ module Gitlab
options: {
before_script: ["pwd"],
script: ["rspec"],
- image: { name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"] },
- services: [{ name: "mysql" },
- { name: "docker:dind", alias: "docker", entrypoint: ["/usr/local/bin/init", "run"],
- command: ["/usr/local/bin/init", "run"] }]
+ image: {name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"]},
+ services: [{name: "mysql"},
+ {name: "docker:dind", alias: "docker", entrypoint: ["/usr/local/bin/init", "run"],
+ command: ["/usr/local/bin/init", "run"],},],
},
allow_failure: false,
when: "on_success",
- yaml_variables: []
+ yaml_variables: [],
})
end
it "returns image and service when overridden for job" do
- config = YAML.dump({ image: "ruby:2.1",
- services: ["mysql"],
- before_script: ["pwd"],
- rspec: { image: { name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"] },
- services: [{ name: "postgresql", alias: "db-pg",
- entrypoint: ["/usr/local/bin/init", "run"],
- command: ["/usr/local/bin/init", "run"] }, "docker:dind"],
- script: "rspec" } })
+ config = YAML.dump({image: "ruby:2.1",
+ services: ["mysql"],
+ before_script: ["pwd"],
+ rspec: {image: {name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"]},
+ services: [{name: "postgresql", alias: "db-pg",
+ entrypoint: ["/usr/local/bin/init", "run"],
+ command: ["/usr/local/bin/init", "run"],}, "docker:dind",],
+ script: "rspec",},})
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -369,24 +369,24 @@ module Gitlab
options: {
before_script: ["pwd"],
script: ["rspec"],
- image: { name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"] },
- services: [{ name: "postgresql", alias: "db-pg", entrypoint: ["/usr/local/bin/init", "run"],
- command: ["/usr/local/bin/init", "run"] },
- { name: "docker:dind" }]
+ image: {name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"]},
+ services: [{name: "postgresql", alias: "db-pg", entrypoint: ["/usr/local/bin/init", "run"],
+ command: ["/usr/local/bin/init", "run"],},
+ {name: "docker:dind"},],
},
allow_failure: false,
when: "on_success",
- yaml_variables: []
+ yaml_variables: [],
})
end
end
context "when etended docker configuration is not used" do
it "returns image and service when defined" do
- config = YAML.dump({ image: "ruby:2.1",
- services: ["mysql", "docker:dind"],
- before_script: ["pwd"],
- rspec: { script: "rspec" } })
+ config = YAML.dump({image: "ruby:2.1",
+ services: ["mysql", "docker:dind"],
+ before_script: ["pwd"],
+ rspec: {script: "rspec"},})
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -398,20 +398,20 @@ module Gitlab
options: {
before_script: ["pwd"],
script: ["rspec"],
- image: { name: "ruby:2.1" },
- services: [{ name: "mysql" }, { name: "docker:dind" }]
+ image: {name: "ruby:2.1"},
+ services: [{name: "mysql"}, {name: "docker:dind"}],
},
allow_failure: false,
when: "on_success",
- yaml_variables: []
+ yaml_variables: [],
})
end
it "returns image and service when overridden for job" do
- config = YAML.dump({ image: "ruby:2.1",
- services: ["mysql"],
- before_script: ["pwd"],
- rspec: { image: "ruby:2.5", services: ["postgresql", "docker:dind"], script: "rspec" } })
+ config = YAML.dump({image: "ruby:2.1",
+ services: ["mysql"],
+ before_script: ["pwd"],
+ rspec: {image: "ruby:2.5", services: ["postgresql", "docker:dind"], script: "rspec"},})
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -423,106 +423,106 @@ module Gitlab
options: {
before_script: ["pwd"],
script: ["rspec"],
- image: { name: "ruby:2.5" },
- services: [{ name: "postgresql" }, { name: "docker:dind" }]
+ image: {name: "ruby:2.5"},
+ services: [{name: "postgresql"}, {name: "docker:dind"}],
},
allow_failure: false,
when: "on_success",
- yaml_variables: []
+ yaml_variables: [],
})
end
end
end
- describe 'Variables' do
+ describe "Variables" do
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)) }
subject { config_processor.builds.first[:yaml_variables] }
- context 'when global variables are defined' do
+ context "when global variables are defined" do
let(:variables) do
- { 'VAR1' => 'value1', 'VAR2' => 'value2' }
+ {"VAR1" => "value1", "VAR2" => "value2"}
end
let(:config) do
{
variables: variables,
- before_script: ['pwd'],
- rspec: { script: 'rspec' }
+ before_script: ["pwd"],
+ rspec: {script: "rspec"},
}
end
- it 'returns global variables' do
+ it "returns global variables" do
expect(subject).to contain_exactly(
- { key: 'VAR1', value: 'value1', public: true },
- { key: 'VAR2', value: 'value2', public: true }
+ {key: "VAR1", value: "value1", public: true},
+ {key: "VAR2", value: "value2", public: true}
)
end
end
- context 'when job and global variables are defined' do
+ context "when job and global variables are defined" do
let(:global_variables) do
- { 'VAR1' => 'global1', 'VAR3' => 'global3' }
+ {"VAR1" => "global1", "VAR3" => "global3"}
end
let(:job_variables) do
- { 'VAR1' => 'value1', 'VAR2' => 'value2' }
+ {"VAR1" => "value1", "VAR2" => "value2"}
end
let(:config) do
{
- before_script: ['pwd'],
+ before_script: ["pwd"],
variables: global_variables,
- rspec: { script: 'rspec', variables: job_variables }
+ rspec: {script: "rspec", variables: job_variables},
}
end
- it 'returns all unique variables' do
+ it "returns all unique variables" do
expect(subject).to contain_exactly(
- { key: 'VAR3', value: 'global3', public: true },
- { key: 'VAR1', value: 'value1', public: true },
- { key: 'VAR2', value: 'value2', public: true }
+ {key: "VAR3", value: "global3", public: true},
+ {key: "VAR1", value: "value1", public: true},
+ {key: "VAR2", value: "value2", public: true}
)
end
end
- context 'when job variables are defined' do
+ context "when job variables are defined" do
let(:config) do
{
- before_script: ['pwd'],
- rspec: { script: 'rspec', variables: variables }
+ before_script: ["pwd"],
+ rspec: {script: "rspec", variables: variables},
}
end
- context 'when syntax is correct' do
+ context "when syntax is correct" do
let(:variables) do
- { 'VAR1' => 'value1', 'VAR2' => 'value2' }
+ {"VAR1" => "value1", "VAR2" => "value2"}
end
- it 'returns job variables' do
+ it "returns job variables" do
expect(subject).to contain_exactly(
- { key: 'VAR1', value: 'value1', public: true },
- { key: 'VAR2', value: 'value2', public: true }
+ {key: "VAR1", value: "value1", public: true},
+ {key: "VAR2", value: "value2", public: true}
)
end
end
- context 'when syntax is incorrect' do
- context 'when variables defined but invalid' do
+ context "when syntax is incorrect" do
+ context "when variables defined but invalid" do
let(:variables) do
- %w(VAR1 value1 VAR2 value2)
+ %w[VAR1 value1 VAR2 value2]
end
- it 'raises error' do
+ it "raises error" do
expect { subject }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- /jobs:rspec:variables config should be a hash of key value pairs/)
+ /jobs:rspec:variables config should be a hash of key value pairs/)
end
end
- context 'when variables key defined but value not specified' do
+ context "when variables key defined but value not specified" do
let(:variables) do
nil
end
- it 'returns empty array' do
+ it "returns empty array" do
##
# When variables config is empty, we assume this is a valid
# configuration, see issue #18775
@@ -534,27 +534,27 @@ module Gitlab
end
end
- context 'when job variables are not defined' do
+ context "when job variables are not defined" do
let(:config) do
{
- before_script: ['pwd'],
- rspec: { script: 'rspec' }
+ before_script: ["pwd"],
+ rspec: {script: "rspec"},
}
end
- it 'returns empty array' do
+ it "returns empty array" do
expect(subject).to be_an_instance_of(Array)
expect(subject).to be_empty
end
end
end
- context 'when using `extends`' do
+ context "when using `extends`" do
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) }
subject { config_processor.builds.first }
- context 'when using simple `extends`' do
+ context "when using simple `extends`" do
let(:config) do
<<~YAML
.template:
@@ -566,14 +566,14 @@ module Gitlab
YAML
end
- it 'correctly extends rspec job' do
+ it "correctly extends rspec job" do
expect(config_processor.builds).to be_one
- expect(subject.dig(:options, :script)).to eq %w(test)
- expect(subject.dig(:options, :image, :name)).to eq 'ruby:alpine'
+ expect(subject.dig(:options, :script)).to eq %w[test]
+ expect(subject.dig(:options, :image, :name)).to eq "ruby:alpine"
end
end
- context 'when using recursive `extends`' do
+ context "when using recursive `extends`" do
let(:config) do
<<~YAML
rspec:
@@ -592,12 +592,12 @@ module Gitlab
YAML
end
- it 'correctly extends rspec job' do
+ it "correctly extends rspec job" do
expect(config_processor.builds).to be_one
expect(subject.dig(:options, :before_script)).to eq ["bundle install"]
- expect(subject.dig(:options, :script)).to eq %w(rspec)
- expect(subject.dig(:options, :image, :name)).to eq 'image:test'
- expect(subject.dig(:when)).to eq 'always'
+ expect(subject.dig(:options, :script)).to eq %w[rspec]
+ expect(subject.dig(:options, :image, :name)).to eq "image:test"
+ expect(subject.dig(:when)).to eq "always"
end
end
end
@@ -608,7 +608,7 @@ module Gitlab
let(:config) do
{
include: include_content,
- rspec: { script: "test" }
+ rspec: {script: "test"},
}
end
@@ -624,7 +624,7 @@ module Gitlab
end
context "when an array of wrong keyed object is provided" do
- let(:include_content) { [{ yolo: "/local.gitlab-ci.yml" }] }
+ let(:include_content) { [{yolo: "/local.gitlab-ci.yml"}] }
it "returns a validation error" do
expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
@@ -634,9 +634,9 @@ module Gitlab
context "when an array of mixed typed objects is provided" do
let(:include_content) do
[
- 'https://gitlab.com/awesome-project/raw/master/.before-script-template.yml',
- '/templates/.after-script-template.yml',
- { template: 'Auto-DevOps.gitlab-ci.yml' }
+ "https://gitlab.com/awesome-project/raw/master/.before-script-template.yml",
+ "/templates/.after-script-template.yml",
+ {template: "Auto-DevOps.gitlab-ci.yml"},
]
end
@@ -646,7 +646,7 @@ module Gitlab
end
context "when the include type is incorrect" do
- let(:include_content) { { name: "/local.gitlab-ci.yml" } }
+ let(:include_content) { {name: "/local.gitlab-ci.yml"} }
it "returns an invalid configuration error" do
expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
@@ -657,12 +657,12 @@ module Gitlab
context "when validating a ci config file within a project" do
let(:include_content) { "/local.gitlab-ci.yml" }
let(:project) { create(:project, :repository) }
- let(:opts) { { project: project, sha: project.commit.sha } }
+ let(:opts) { {project: project, sha: project.commit.sha} }
context "when the included internal file is present" do
before do
expect(project.repository).to receive(:blob_data_at)
- .and_return(YAML.dump({ job1: { script: 'hello' } }))
+ .and_return(YAML.dump({job1: {script: "hello"}}))
end
it "does not return an error" do
@@ -682,11 +682,11 @@ module Gitlab
end
describe "When" do
- %w(on_success on_failure always).each do |when_state|
+ %w[on_success on_failure always].each do |when_state|
it "returns #{when_state} when defined" do
config = YAML.dump({
- rspec: { script: "rspec", when: when_state }
- })
+ rspec: {script: "rspec", when: when_state},
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
builds = config_processor.stage_builds_attributes("test")
@@ -697,54 +697,55 @@ module Gitlab
end
end
- describe 'Parallel' do
- context 'when job is parallelized' do
+ describe "Parallel" do
+ context "when job is parallelized" do
let(:parallel) { 5 }
let(:config) do
- YAML.dump(rspec: { script: 'rspec',
- parallel: parallel })
+ YAML.dump(rspec: {script: "rspec",
+ parallel: parallel,})
end
- it 'returns parallelized jobs' do
+ it "returns parallelized jobs" do
config_processor = Gitlab::Ci::YamlProcessor.new(config)
- builds = config_processor.stage_builds_attributes('test')
+ builds = config_processor.stage_builds_attributes("test")
build_options = builds.map { |build| build[:options] }
expect(builds.size).to eq(5)
expect(build_options).to all(include(:instance, parallel: parallel))
end
- it 'does not have the original job' do
+ it "does not have the original job" do
config_processor = Gitlab::Ci::YamlProcessor.new(config)
- builds = config_processor.stage_builds_attributes('test')
+ builds = config_processor.stage_builds_attributes("test")
expect(builds).not_to include(:rspec)
end
end
end
- describe 'cache' do
- context 'when cache definition has unknown keys' do
- it 'raises relevant validation error' do
+ describe "cache" do
+ context "when cache definition has unknown keys" do
+ it "raises relevant validation error" do
config = YAML.dump(
- { cache: { untracked: true, invalid: 'key' },
- rspec: { script: 'rspec' } })
+ {cache: {untracked: true, invalid: "key"},
+ rspec: {script: "rspec"},}
+ )
expect { Gitlab::Ci::YamlProcessor.new(config) }.to raise_error(
Gitlab::Ci::YamlProcessor::ValidationError,
- 'cache config contains unknown keys: invalid'
+ "cache config contains unknown keys: invalid"
)
end
end
it "returns cache when defined globally" do
config = YAML.dump({
- cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'key' },
- rspec: {
- script: "rspec"
- }
- })
+ cache: {paths: ["logs/", "binaries/"], untracked: true, key: "key"},
+ rspec: {
+ script: "rspec",
+ },
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -752,18 +753,18 @@ module Gitlab
expect(config_processor.stage_builds_attributes("test").first[:options][:cache]).to eq(
paths: ["logs/", "binaries/"],
untracked: true,
- key: 'key',
- policy: 'pull-push'
+ key: "key",
+ policy: "pull-push"
)
end
it "returns cache when defined in a job" do
config = YAML.dump({
- rspec: {
- cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'key' },
- script: "rspec"
- }
- })
+ rspec: {
+ cache: {paths: ["logs/", "binaries/"], untracked: true, key: "key"},
+ script: "rspec",
+ },
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -771,19 +772,19 @@ module Gitlab
expect(config_processor.stage_builds_attributes("test").first[:options][:cache]).to eq(
paths: ["logs/", "binaries/"],
untracked: true,
- key: 'key',
- policy: 'pull-push'
+ key: "key",
+ policy: "pull-push"
)
end
it "overwrite cache when defined for a job and globally" do
config = YAML.dump({
- cache: { paths: ["logs/", "binaries/"], untracked: true, key: 'global' },
- rspec: {
- script: "rspec",
- cache: { paths: ["test/"], untracked: false, key: 'local' }
- }
- })
+ cache: {paths: ["logs/", "binaries/"], untracked: true, key: "global"},
+ rspec: {
+ script: "rspec",
+ cache: {paths: ["test/"], untracked: false, key: "local"},
+ },
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -791,8 +792,8 @@ module Gitlab
expect(config_processor.stage_builds_attributes("test").first[:options][:cache]).to eq(
paths: ["test/"],
untracked: false,
- key: 'local',
- policy: 'pull-push'
+ key: "local",
+ policy: "pull-push"
)
end
end
@@ -800,19 +801,19 @@ module Gitlab
describe "Artifacts" do
it "returns artifacts when defined" do
config = YAML.dump({
- image: "ruby:2.1",
- services: ["mysql"],
- before_script: ["pwd"],
- rspec: {
- artifacts: {
- paths: ["logs/", "binaries/"],
- untracked: true,
- name: "custom_name",
- expire_in: "7d"
- },
- script: "rspec"
- }
- })
+ image: "ruby:2.1",
+ services: ["mysql"],
+ before_script: ["pwd"],
+ rspec: {
+ artifacts: {
+ paths: ["logs/", "binaries/"],
+ untracked: true,
+ name: "custom_name",
+ expire_in: "7d",
+ },
+ script: "rspec",
+ },
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
@@ -824,29 +825,29 @@ module Gitlab
options: {
before_script: ["pwd"],
script: ["rspec"],
- image: { name: "ruby:2.1" },
- services: [{ name: "mysql" }],
+ image: {name: "ruby:2.1"},
+ services: [{name: "mysql"}],
artifacts: {
name: "custom_name",
paths: ["logs/", "binaries/"],
untracked: true,
- expire_in: "7d"
- }
+ expire_in: "7d",
+ },
},
when: "on_success",
allow_failure: false,
- yaml_variables: []
+ yaml_variables: [],
})
end
%w[on_success on_failure always].each do |when_state|
it "returns artifacts for when #{when_state} defined" do
config = YAML.dump({
- rspec: {
- script: "rspec",
- artifacts: { paths: ["logs/", "binaries/"], when: when_state }
- }
- })
+ rspec: {
+ script: "rspec",
+ artifacts: {paths: ["logs/", "binaries/"], when: when_state},
+ },
+ })
config_processor = Gitlab::Ci::YamlProcessor.new(config)
builds = config_processor.stage_builds_attributes("test")
@@ -857,45 +858,45 @@ module Gitlab
end
end
- describe '#environment' do
+ describe "#environment" do
let(:config) do
{
- deploy_to_production: { stage: 'deploy', script: 'test', environment: environment }
+ deploy_to_production: {stage: "deploy", script: "test", environment: environment},
}
end
let(:processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)) }
- let(:builds) { processor.stage_builds_attributes('deploy') }
+ let(:builds) { processor.stage_builds_attributes("deploy") }
- context 'when a production environment is specified' do
- let(:environment) { 'production' }
+ context "when a production environment is specified" do
+ let(:environment) { "production" }
- it 'does return production' do
+ it "does return production" do
expect(builds.size).to eq(1)
expect(builds.first[:environment]).to eq(environment)
- expect(builds.first[:options]).to include(environment: { name: environment, action: "start" })
+ expect(builds.first[:options]).to include(environment: {name: environment, action: "start"})
end
end
- context 'when hash is specified' do
+ context "when hash is specified" do
let(:environment) do
- { name: 'production',
- url: 'http://production.gitlab.com' }
+ {name: "production",
+ url: "http://production.gitlab.com",}
end
- it 'does return production and URL' do
+ it "does return production and URL" do
expect(builds.size).to eq(1)
expect(builds.first[:environment]).to eq(environment[:name])
expect(builds.first[:options]).to include(environment: environment)
end
- context 'the url has a port as variable' do
+ context "the url has a port as variable" do
let(:environment) do
- { name: 'production',
- url: 'http://production.gitlab.com:$PORT' }
+ {name: "production",
+ url: "http://production.gitlab.com:$PORT",}
end
- it 'allows a variable for the port' do
+ it "allows a variable for the port" do
expect(builds.size).to eq(1)
expect(builds.first[:environment]).to eq(environment[:name])
expect(builds.first[:options]).to include(environment: environment)
@@ -903,74 +904,75 @@ module Gitlab
end
end
- context 'when no environment is specified' do
+ context "when no environment is specified" do
let(:environment) { nil }
- it 'does return nil environment' do
+ it "does return nil environment" do
expect(builds.size).to eq(1)
expect(builds.first[:environment]).to be_nil
end
end
- context 'is not a string' do
+ context "is not a string" do
let(:environment) { 1 }
- it 'raises error' do
+ it "raises error" do
expect { builds }.to raise_error(
- 'jobs:deploy_to_production:environment config should be a hash or a string')
+ "jobs:deploy_to_production:environment config should be a hash or a string"
+ )
end
end
- context 'is not a valid string' do
- let(:environment) { 'production:staging' }
+ context "is not a valid string" do
+ let(:environment) { "production:staging" }
- it 'raises error' do
+ it "raises error" do
expect { builds }.to raise_error("jobs:deploy_to_production:environment name #{Gitlab::Regex.environment_name_regex_message}")
end
end
- context 'when on_stop is specified' do
- let(:review) { { stage: 'deploy', script: 'test', environment: { name: 'review', on_stop: 'close_review' } } }
- let(:config) { { review: review, close_review: close_review }.compact }
+ context "when on_stop is specified" do
+ let(:review) { {stage: "deploy", script: "test", environment: {name: "review", on_stop: "close_review"}} }
+ let(:config) { {review: review, close_review: close_review}.compact }
- context 'with matching job' do
- let(:close_review) { { stage: 'deploy', script: 'test', environment: { name: 'review', action: 'stop' } } }
+ context "with matching job" do
+ let(:close_review) { {stage: "deploy", script: "test", environment: {name: "review", action: "stop"}} }
- it 'does return a list of builds' do
+ it "does return a list of builds" do
expect(builds.size).to eq(2)
- expect(builds.first[:environment]).to eq('review')
+ expect(builds.first[:environment]).to eq("review")
end
end
- context 'without matching job' do
+ context "without matching job" do
let(:close_review) { nil }
- it 'raises error' do
- expect { builds }.to raise_error('review job: on_stop job close_review is not defined')
+ it "raises error" do
+ expect { builds }.to raise_error("review job: on_stop job close_review is not defined")
end
end
- context 'with close job without environment' do
- let(:close_review) { { stage: 'deploy', script: 'test' } }
+ context "with close job without environment" do
+ let(:close_review) { {stage: "deploy", script: "test"} }
- it 'raises error' do
- expect { builds }.to raise_error('review job: on_stop job close_review does not have environment defined')
+ it "raises error" do
+ expect { builds }.to raise_error("review job: on_stop job close_review does not have environment defined")
end
end
- context 'with close job for different environment' do
- let(:close_review) { { stage: 'deploy', script: 'test', environment: 'production' } }
+ context "with close job for different environment" do
+ let(:close_review) { {stage: "deploy", script: "test", environment: "production"} }
- it 'raises error' do
- expect { builds }.to raise_error('review job: on_stop job close_review have different environment name')
+ it "raises error" do
+ expect { builds }.to raise_error("review job: on_stop job close_review have different environment name")
end
end
- context 'with close job without stop action' do
- let(:close_review) { { stage: 'deploy', script: 'test', environment: { name: 'review' } } }
+ context "with close job without stop action" do
+ let(:close_review) { {stage: "deploy", script: "test", environment: {name: "review"}} }
- it 'raises error' do
- expect { builds }.to raise_error('review job: on_stop job close_review needs to have action stop defined')
+ it "raises error" do
+ expect { builds }.to raise_error("review job: on_stop job close_review needs to have action stop defined")
end
end
end
@@ -979,44 +981,44 @@ module Gitlab
describe "Dependencies" do
let(:config) do
{
- build1: { stage: 'build', script: 'test' },
- build2: { stage: 'build', script: 'test' },
- test1: { stage: 'test', script: 'test', dependencies: dependencies },
- test2: { stage: 'test', script: 'test' },
- deploy: { stage: 'test', script: 'test' }
+ build1: {stage: "build", script: "test"},
+ build2: {stage: "build", script: "test"},
+ test1: {stage: "test", script: "test", dependencies: dependencies},
+ test2: {stage: "test", script: "test"},
+ deploy: {stage: "test", script: "test"},
}
end
subject { Gitlab::Ci::YamlProcessor.new(YAML.dump(config)) }
- context 'no dependencies' do
+ context "no dependencies" do
let(:dependencies) { }
it { expect { subject }.not_to raise_error }
end
- context 'dependencies to builds' do
- let(:dependencies) { %w(build1 build2) }
+ context "dependencies to builds" do
+ let(:dependencies) { %w[build1 build2] }
it { expect { subject }.not_to raise_error }
end
- context 'dependencies to builds defined as symbols' do
+ context "dependencies to builds defined as symbols" do
let(:dependencies) { [:build1, :build2] }
it { expect { subject }.not_to raise_error }
end
- context 'undefined dependency' do
- let(:dependencies) { ['undefined'] }
+ context "undefined dependency" do
+ let(:dependencies) { ["undefined"] }
- it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'test1 job: undefined dependency: undefined') }
+ it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "test1 job: undefined dependency: undefined") }
end
- context 'dependencies to deploy' do
- let(:dependencies) { ['deploy'] }
+ context "dependencies to deploy" do
+ let(:dependencies) { ["deploy"] }
- it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, 'test1 job: dependency deploy is not defined in prior stages') }
+ it { expect { subject }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "test1 job: dependency deploy is not defined in prior stages") }
end
end
@@ -1024,7 +1026,7 @@ module Gitlab
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) }
subject { config_processor.stage_builds_attributes("test") }
- shared_examples 'hidden_job_handling' do
+ shared_examples "hidden_job_handling" do
it "doesn't create jobs that start with dot" do
expect(subject.size).to eq(1)
expect(subject.first).to eq({
@@ -1032,35 +1034,35 @@ module Gitlab
stage_idx: 1,
name: "normal_job",
options: {
- script: ["test"]
+ script: ["test"],
},
when: "on_success",
allow_failure: false,
- yaml_variables: []
+ yaml_variables: [],
})
end
end
- context 'when hidden job have a script definition' do
+ context "when hidden job have a script definition" do
let(:config) do
YAML.dump({
- '.hidden_job' => { image: 'ruby:2.1', script: 'test' },
- 'normal_job' => { script: 'test' }
- })
+ ".hidden_job" => {image: "ruby:2.1", script: "test"},
+ "normal_job" => {script: "test"},
+ })
end
- it_behaves_like 'hidden_job_handling'
+ it_behaves_like "hidden_job_handling"
end
context "when hidden job doesn't have a script definition" do
let(:config) do
YAML.dump({
- '.hidden_job' => { image: 'ruby:2.1' },
- 'normal_job' => { script: 'test' }
- })
+ ".hidden_job" => {image: "ruby:2.1"},
+ "normal_job" => {script: "test"},
+ })
end
- it_behaves_like 'hidden_job_handling'
+ it_behaves_like "hidden_job_handling"
end
end
@@ -1068,7 +1070,7 @@ module Gitlab
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(config) }
subject { config_processor.stage_builds_attributes("build") }
- shared_examples 'job_templates_handling' do
+ shared_examples "job_templates_handling" do
it "is correctly supported for jobs" do
expect(subject.size).to eq(2)
expect(subject.first).to eq({
@@ -1076,384 +1078,379 @@ module Gitlab
stage_idx: 0,
name: "job1",
options: {
- script: ["execute-script-for-job"]
+ script: ["execute-script-for-job"],
},
when: "on_success",
allow_failure: false,
- yaml_variables: []
+ yaml_variables: [],
})
expect(subject.second).to eq({
stage: "build",
stage_idx: 0,
name: "job2",
options: {
- script: ["execute-script-for-job"]
+ script: ["execute-script-for-job"],
},
when: "on_success",
allow_failure: false,
- yaml_variables: []
+ yaml_variables: [],
})
end
end
- context 'when template is a job' do
+ context "when template is a job" do
let(:config) do
<<~EOT
- job1: &JOBTMPL
- stage: build
- script: execute-script-for-job
-
- job2: *JOBTMPL
+ job1: &JOBTMPL
+ stage: build
+ script: execute-script-for-job
+ job2: *JOBTMPL
EOT
end
- it_behaves_like 'job_templates_handling'
+ it_behaves_like "job_templates_handling"
end
- context 'when template is a hidden job' do
+ context "when template is a hidden job" do
let(:config) do
<<~EOT
- .template: &JOBTMPL
- stage: build
- script: execute-script-for-job
-
- job1: *JOBTMPL
-
- job2: *JOBTMPL
+ .template: &JOBTMPL
+ stage: build
+ script: execute-script-for-job
+ job1: *JOBTMPL
+ job2: *JOBTMPL
EOT
end
- it_behaves_like 'job_templates_handling'
+ it_behaves_like "job_templates_handling"
end
- context 'when job adds its own keys to a template definition' do
+ context "when job adds its own keys to a template definition" do
let(:config) do
<<~EOT
- .template: &JOBTMPL
- stage: build
-
- job1:
- <<: *JOBTMPL
- script: execute-script-for-job
-
- job2:
- <<: *JOBTMPL
- script: execute-script-for-job
+ .template: &JOBTMPL
+ stage: build
+ job1:
+ <<: *JOBTMPL
+ script: execute-script-for-job
+ job2:
+ <<: *JOBTMPL
+ script: execute-script-for-job
EOT
end
- it_behaves_like 'job_templates_handling'
+ it_behaves_like "job_templates_handling"
end
end
describe "Error handling" do
it "fails to parse YAML" do
- expect do
+ expect {
Gitlab::Ci::YamlProcessor.new("invalid: yaml: test")
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
end
it "indicates that object is invalid" do
- expect do
+ expect {
Gitlab::Ci::YamlProcessor.new("invalid_yaml")
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError)
end
it "returns errors if tags parameter is invalid" do
- config = YAML.dump({ rspec: { script: "test", tags: "mysql" } })
- expect do
+ config = YAML.dump({rspec: {script: "test", tags: "mysql"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec tags should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec tags should be an array of strings")
end
it "returns errors if before_script parameter is invalid" do
- config = YAML.dump({ before_script: "bundle update", rspec: { script: "test" } })
- expect do
+ config = YAML.dump({before_script: "bundle update", rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "before_script config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "before_script config should be an array of strings")
end
it "returns errors if job before_script parameter is not an array of strings" do
- config = YAML.dump({ rspec: { script: "test", before_script: [10, "test"] } })
- expect do
+ config = YAML.dump({rspec: {script: "test", before_script: [10, "test"]}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:before_script config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:before_script config should be an array of strings")
end
it "returns errors if after_script parameter is invalid" do
- config = YAML.dump({ after_script: "bundle update", rspec: { script: "test" } })
- expect do
+ config = YAML.dump({after_script: "bundle update", rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "after_script config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "after_script config should be an array of strings")
end
it "returns errors if job after_script parameter is not an array of strings" do
- config = YAML.dump({ rspec: { script: "test", after_script: [10, "test"] } })
- expect do
+ config = YAML.dump({rspec: {script: "test", after_script: [10, "test"]}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:after_script config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:after_script config should be an array of strings")
end
it "returns errors if image parameter is invalid" do
- config = YAML.dump({ image: ["test"], rspec: { script: "test" } })
- expect do
+ config = YAML.dump({image: ["test"], rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "image config should be a hash or a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "image config should be a hash or a string")
end
it "returns errors if job name is blank" do
- config = YAML.dump({ '' => { script: "test" } })
- expect do
+ config = YAML.dump({"" => {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:job name can't be blank")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:job name can't be blank")
end
it "returns errors if job name is non-string" do
- config = YAML.dump({ 10 => { script: "test" } })
- expect do
+ config = YAML.dump({10 => {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:10 name should be a symbol")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:10 name should be a symbol")
end
it "returns errors if job image parameter is invalid" do
- config = YAML.dump({ rspec: { script: "test", image: ["test"] } })
- expect do
+ config = YAML.dump({rspec: {script: "test", image: ["test"]}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:image config should be a hash or a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:image config should be a hash or a string")
end
it "returns errors if services parameter is not an array" do
- config = YAML.dump({ services: "test", rspec: { script: "test" } })
- expect do
+ config = YAML.dump({services: "test", rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "services config should be a array")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "services config should be a array")
end
it "returns errors if services parameter is not an array of strings" do
- config = YAML.dump({ services: [10, "test"], rspec: { script: "test" } })
- expect do
+ config = YAML.dump({services: [10, "test"], rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "service config should be a hash or a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "service config should be a hash or a string")
end
it "returns errors if job services parameter is not an array" do
- config = YAML.dump({ rspec: { script: "test", services: "test" } })
- expect do
+ config = YAML.dump({rspec: {script: "test", services: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:services config should be a array")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:services config should be a array")
end
it "returns errors if job services parameter is not an array of strings" do
- config = YAML.dump({ rspec: { script: "test", services: [10, "test"] } })
- expect do
+ config = YAML.dump({rspec: {script: "test", services: [10, "test"]}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "service config should be a hash or a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "service config should be a hash or a string")
end
it "returns error if job configuration is invalid" do
- config = YAML.dump({ extra: "bundle update" })
- expect do
+ config = YAML.dump({extra: "bundle update"})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:extra config should be a hash")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:extra config should be a hash")
end
it "returns errors if services configuration is not correct" do
- config = YAML.dump({ extra: { script: 'rspec', services: "test" } })
- expect do
+ config = YAML.dump({extra: {script: "rspec", services: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:extra:services config should be a array")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:extra:services config should be a array")
end
it "returns errors if there are no jobs defined" do
- config = YAML.dump({ before_script: ["bundle update"] })
- expect do
+ config = YAML.dump({before_script: ["bundle update"]})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs config should contain at least one visible job")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs config should contain at least one visible job")
end
it "returns errors if there are no visible jobs defined" do
- config = YAML.dump({ before_script: ["bundle update"], '.hidden'.to_sym => { script: 'ls' } })
- expect do
+ config = YAML.dump({:before_script => ["bundle update"], ".hidden".to_sym => {script: "ls"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs config should contain at least one visible job")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs config should contain at least one visible job")
end
it "returns errors if job allow_failure parameter is not an boolean" do
- config = YAML.dump({ rspec: { script: "test", allow_failure: "string" } })
- expect do
+ config = YAML.dump({rspec: {script: "test", allow_failure: "string"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec allow failure should be a boolean value")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec allow failure should be a boolean value")
end
it "returns errors if job stage is not a string" do
- config = YAML.dump({ rspec: { script: "test", type: 1 } })
- expect do
+ config = YAML.dump({rspec: {script: "test", type: 1}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:type config should be a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:type config should be a string")
end
it "returns errors if job stage is not a pre-defined stage" do
- config = YAML.dump({ rspec: { script: "test", type: "acceptance" } })
- expect do
+ config = YAML.dump({rspec: {script: "test", type: "acceptance"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "rspec job: stage parameter should be build, test, deploy")
end
it "returns errors if job stage is not a defined stage" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", type: "acceptance" } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", type: "acceptance"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "rspec job: stage parameter should be build, test")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "rspec job: stage parameter should be build, test")
end
it "returns errors if stages is not an array" do
- config = YAML.dump({ stages: "test", rspec: { script: "test" } })
- expect do
+ config = YAML.dump({stages: "test", rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "stages config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "stages config should be an array of strings")
end
it "returns errors if stages is not an array of strings" do
- config = YAML.dump({ stages: [true, "test"], rspec: { script: "test" } })
- expect do
+ config = YAML.dump({stages: [true, "test"], rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "stages config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "stages config should be an array of strings")
end
it "returns errors if variables is not a map" do
- config = YAML.dump({ variables: "test", rspec: { script: "test" } })
- expect do
+ config = YAML.dump({variables: "test", rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "variables config should be a hash of key value pairs")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "variables config should be a hash of key value pairs")
end
it "returns errors if variables is not a map of key-value strings" do
- config = YAML.dump({ variables: { test: false }, rspec: { script: "test" } })
- expect do
+ config = YAML.dump({variables: {test: false}, rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "variables config should be a hash of key value pairs")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "variables config should be a hash of key value pairs")
end
it "returns errors if job when is not on_success, on_failure or always" do
- config = YAML.dump({ rspec: { script: "test", when: 1 } })
- expect do
+ config = YAML.dump({rspec: {script: "test", when: 1}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec when should be on_success, on_failure, always, manual or delayed")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec when should be on_success, on_failure, always, manual or delayed")
end
it "returns errors if job artifacts:name is not an a string" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { name: 1 } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {name: 1}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts name should be a string")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts name should be a string")
end
it "returns errors if job artifacts:when is not an a predefined value" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { when: 1 } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {when: 1}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts when should be on_success, on_failure or always")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts when should be on_success, on_failure or always")
end
it "returns errors if job artifacts:expire_in is not an a string" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { expire_in: 1 } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {expire_in: 1}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
end
it "returns errors if job artifacts:expire_in is not an a valid duration" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { expire_in: "7 elephants" } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {expire_in: "7 elephants"}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts expire in should be a duration")
end
it "returns errors if job artifacts:untracked is not an array of strings" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { untracked: "string" } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {untracked: "string"}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts untracked should be a boolean value")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts untracked should be a boolean value")
end
it "returns errors if job artifacts:paths is not an array of strings" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", artifacts: { paths: "string" } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", artifacts: {paths: "string"}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts paths should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:artifacts paths should be an array of strings")
end
it "returns errors if cache:untracked is not an array of strings" do
- config = YAML.dump({ cache: { untracked: "string" }, rspec: { script: "test" } })
- expect do
+ config = YAML.dump({cache: {untracked: "string"}, rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:untracked config should be a boolean value")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:untracked config should be a boolean value")
end
it "returns errors if cache:paths is not an array of strings" do
- config = YAML.dump({ cache: { paths: "string" }, rspec: { script: "test" } })
- expect do
+ config = YAML.dump({cache: {paths: "string"}, rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:paths config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:paths config should be an array of strings")
end
it "returns errors if cache:key is not a string" do
- config = YAML.dump({ cache: { key: 1 }, rspec: { script: "test" } })
- expect do
+ config = YAML.dump({cache: {key: 1}, rspec: {script: "test"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:key config should be a string or symbol")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "cache:key config should be a string or symbol")
end
it "returns errors if job cache:key is not an a string" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { key: 1 } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", cache: {key: 1}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:key config should be a string or symbol")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:key config should be a string or symbol")
end
it "returns errors if job cache:untracked is not an array of strings" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { untracked: "string" } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", cache: {untracked: "string"}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:untracked config should be a boolean value")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:untracked config should be a boolean value")
end
it "returns errors if job cache:paths is not an array of strings" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", cache: { paths: "string" } } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", cache: {paths: "string"}}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:paths config should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec:cache:paths config should be an array of strings")
end
it "returns errors if job dependencies is not an array of strings" do
- config = YAML.dump({ types: %w(build test), rspec: { script: "test", dependencies: "string" } })
- expect do
+ config = YAML.dump({types: %w[build test], rspec: {script: "test", dependencies: "string"}})
+ expect {
Gitlab::Ci::YamlProcessor.new(config)
- end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings")
+ }.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings")
end
- it 'returns errors if pipeline variables expression policy is invalid' do
- config = YAML.dump({ rspec: { script: 'test', only: { variables: ['== null'] } } })
+ it "returns errors if pipeline variables expression policy is invalid" do
+ config = YAML.dump({rspec: {script: "test", only: {variables: ["== null"]}}})
expect { Gitlab::Ci::YamlProcessor.new(config) }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:only variables invalid expression syntax')
+ "jobs:rspec:only variables invalid expression syntax")
end
- it 'returns errors if pipeline changes policy is invalid' do
- config = YAML.dump({ rspec: { script: 'test', only: { changes: [1] } } })
+ it "returns errors if pipeline changes policy is invalid" do
+ config = YAML.dump({rspec: {script: "test", only: {changes: [1]}}})
expect { Gitlab::Ci::YamlProcessor.new(config) }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'jobs:rspec:only changes should be an array of strings')
+ "jobs:rspec:only changes should be an array of strings")
end
- it 'returns errors if extended hash configuration is invalid' do
- config = YAML.dump({ rspec: { extends: 'something', script: 'test' } })
+ it "returns errors if extended hash configuration is invalid" do
+ config = YAML.dump({rspec: {extends: "something", script: "test"}})
expect { Gitlab::Ci::YamlProcessor.new(config) }
.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError,
- 'rspec: unknown key in `extends`')
+ "rspec: unknown key in `extends`")
end
end
@@ -1467,25 +1464,25 @@ module Gitlab
end
context "when the tags parameter is invalid" do
- let(:content) { YAML.dump({ rspec: { script: "test", tags: "mysql" } }) }
+ let(:content) { YAML.dump({rspec: {script: "test", tags: "mysql"}}) }
it { is_expected.to eq "jobs:rspec tags should be an array of strings" }
end
context "when YAML content is empty" do
- let(:content) { '' }
+ let(:content) { "" }
it { is_expected.to eq "Please provide content of .gitlab-ci.yml" }
end
- context 'when the YAML contains an unknown alias' do
- let(:content) { 'steps: *bad_alias' }
+ context "when the YAML contains an unknown alias" do
+ let(:content) { "steps: *bad_alias" }
it { is_expected.to eq "Unknown alias: bad_alias" }
end
context "when the YAML is valid" do
- let(:content) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
+ let(:content) { File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml")) }
it { is_expected.to be_nil }
end
diff --git a/spec/lib/gitlab/ci_access_spec.rb b/spec/lib/gitlab/ci_access_spec.rb
index 75b90e76083..a35c2243934 100644
--- a/spec/lib/gitlab/ci_access_spec.rb
+++ b/spec/lib/gitlab/ci_access_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CiAccess do
let(:access) { described_class.new }
- describe '#can_do_action?' do
- context 'when action is :build_download_code' do
+ describe "#can_do_action?" do
+ context "when action is :build_download_code" do
it { expect(access.can_do_action?(:build_download_code)).to be_truthy }
end
- context 'when action is not :build_download_code' do
+ context "when action is not :build_download_code" do
it { expect(access.can_do_action?(:download_code)).to be_falsey }
end
end
diff --git a/spec/lib/gitlab/cleanup/project_uploads_spec.rb b/spec/lib/gitlab/cleanup/project_uploads_spec.rb
index bf130b8fabd..4be132910e0 100644
--- a/spec/lib/gitlab/cleanup/project_uploads_spec.rb
+++ b/spec/lib/gitlab/cleanup/project_uploads_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Cleanup::ProjectUploads do
subject { described_class.new(logger: logger) }
@@ -11,19 +11,19 @@ describe Gitlab::Cleanup::ProjectUploads do
allow(logger).to receive(:debug).at_least(1).times
end
- describe '#run!' do
- shared_examples_for 'moves the file' do
- shared_examples_for 'a real run' do
+ describe "#run!" do
+ shared_examples_for "moves the file" do
+ shared_examples_for "a real run" do
let(:args) { [dry_run: false] }
- it 'moves the file to its proper location' do
+ it "moves the file to its proper location" do
subject.run!(*args)
expect(File.exist?(path)).to be_falsey
expect(File.exist?(new_path)).to be_truthy
end
- it 'logs action as done' do
+ it "logs action as done" do
expect(logger).to receive(:info).with("Looking for orphaned project uploads to clean up...")
expect(logger).to receive(:info).with("Did #{action}")
@@ -31,15 +31,15 @@ describe Gitlab::Cleanup::ProjectUploads do
end
end
- shared_examples_for 'a dry run' do
- it 'does not move the file' do
+ shared_examples_for "a dry run" do
+ it "does not move the file" do
subject.run!(*args)
expect(File.exist?(path)).to be_truthy
expect(File.exist?(new_path)).to be_falsey
end
- it 'logs action as able to be done' do
+ it "logs action as able to be done" do
expect(logger).to receive(:info).with("Looking for orphaned project uploads to clean up. Dry run...")
expect(logger).to receive(:info).with("Can #{action}")
@@ -47,87 +47,87 @@ describe Gitlab::Cleanup::ProjectUploads do
end
end
- context 'when dry_run is false' do
+ context "when dry_run is false" do
let(:args) { [dry_run: false] }
- it_behaves_like 'a real run'
+ it_behaves_like "a real run"
end
- context 'when dry_run is nil' do
+ context "when dry_run is nil" do
let(:args) { [dry_run: nil] }
- it_behaves_like 'a real run'
+ it_behaves_like "a real run"
end
- context 'when dry_run is true' do
+ context "when dry_run is true" do
let(:args) { [dry_run: true] }
- it_behaves_like 'a dry run'
+ it_behaves_like "a dry run"
end
- context 'with dry_run not specified' do
+ context "with dry_run not specified" do
let(:args) { [] }
- it_behaves_like 'a dry run'
+ it_behaves_like "a dry run"
end
end
- shared_examples_for 'moves the file to lost and found' do
+ shared_examples_for "moves the file to lost and found" do
let(:action) { "move to lost and found #{path} -> #{new_path}" }
- it_behaves_like 'moves the file'
+ it_behaves_like "moves the file"
end
- shared_examples_for 'fixes the file' do
+ shared_examples_for "fixes the file" do
let(:action) { "fix #{path} -> #{new_path}" }
- it_behaves_like 'moves the file'
+ it_behaves_like "moves the file"
end
- context 'orphaned project upload file' do
- context 'when an upload record matching the secret and filename is found' do
- context 'when the project is still in legacy storage' do
+ context "orphaned project upload file" do
+ context "when an upload record matching the secret and filename is found" do
+ context "when the project is still in legacy storage" do
let(:orphaned) { create(:upload, :issuable_upload, :with_file, model: create(:project, :legacy_storage)) }
let(:new_path) { orphaned.absolute_path }
- let(:path) { File.join(FileUploader.root, 'some', 'wrong', 'location', orphaned.path) }
+ let(:path) { File.join(FileUploader.root, "some", "wrong", "location", orphaned.path) }
before do
FileUtils.mkdir_p(File.dirname(path))
FileUtils.mv(new_path, path)
end
- it_behaves_like 'fixes the file'
+ it_behaves_like "fixes the file"
end
- context 'when the project was moved to hashed storage' do
+ context "when the project was moved to hashed storage" do
let(:orphaned) { create(:upload, :issuable_upload, :with_file) }
let(:new_path) { orphaned.absolute_path }
- let(:path) { File.join(FileUploader.root, 'some', 'wrong', 'location', orphaned.path) }
+ let(:path) { File.join(FileUploader.root, "some", "wrong", "location", orphaned.path) }
before do
FileUtils.mkdir_p(File.dirname(path))
FileUtils.mv(new_path, path)
end
- it_behaves_like 'fixes the file'
+ it_behaves_like "fixes the file"
end
- context 'when the project is missing (the upload *record* is an orphan)' do
+ context "when the project is missing (the upload *record* is an orphan)" do
let(:orphaned) { create(:upload, :issuable_upload, :with_file, model: build(:project, :legacy_storage)) }
let!(:path) { orphaned.absolute_path }
- let!(:new_path) { File.join(FileUploader.root, '-', 'project-lost-found', orphaned.model.full_path, orphaned.path) }
+ let!(:new_path) { File.join(FileUploader.root, "-", "project-lost-found", orphaned.model.full_path, orphaned.path) }
before do
orphaned.model.delete
end
- it_behaves_like 'moves the file to lost and found'
+ it_behaves_like "moves the file to lost and found"
end
# We will probably want to add logic (Reschedule background upload) to
# cover Case 2 in https://gitlab.com/gitlab-org/gitlab-ce/issues/46535#note_75355104
- context 'when the file should be in object storage' do
- context 'when the file otherwise has the correct local path' do
+ context "when the file should be in object storage" do
+ context "when the file otherwise has the correct local path" do
let!(:orphaned) { create(:upload, :issuable_upload, :object_storage, model: build(:project, :legacy_storage)) }
let!(:path) { File.join(FileUploader.root, orphaned.model.full_path, orphaned.path) }
@@ -138,7 +138,7 @@ describe Gitlab::Cleanup::ProjectUploads do
FileUtils.touch(path)
end
- it 'does not move the file' do
+ it "does not move the file" do
expect(File.exist?(path)).to be_truthy
subject.run!(dry_run: false)
@@ -149,10 +149,10 @@ describe Gitlab::Cleanup::ProjectUploads do
# E.g. the upload file was orphaned, and then uploads were migrated to
# object storage
- context 'when the file has the wrong local path' do
+ context "when the file has the wrong local path" do
let!(:orphaned) { create(:upload, :issuable_upload, :object_storage, model: build(:project, :legacy_storage)) }
- let!(:path) { File.join(FileUploader.root, 'wrong', orphaned.path) }
- let!(:new_path) { File.join(FileUploader.root, '-', 'project-lost-found', 'wrong', orphaned.path) }
+ let!(:path) { File.join(FileUploader.root, "wrong", orphaned.path) }
+ let!(:new_path) { File.join(FileUploader.root, "-", "project-lost-found", "wrong", orphaned.path) }
before do
stub_uploads_object_storage(FileUploader)
@@ -161,28 +161,28 @@ describe Gitlab::Cleanup::ProjectUploads do
FileUtils.touch(path)
end
- it_behaves_like 'moves the file to lost and found'
+ it_behaves_like "moves the file to lost and found"
end
end
end
- context 'when a matching upload record can not be found' do
- context 'when the file path fits the known pattern' do
+ context "when a matching upload record can not be found" do
+ context "when the file path fits the known pattern" do
let!(:orphaned) { create(:upload, :issuable_upload, :with_file, model: build(:project, :legacy_storage)) }
let!(:path) { orphaned.absolute_path }
- let!(:new_path) { File.join(FileUploader.root, '-', 'project-lost-found', orphaned.model.full_path, orphaned.path) }
+ let!(:new_path) { File.join(FileUploader.root, "-", "project-lost-found", orphaned.model.full_path, orphaned.path) }
before do
orphaned.delete
end
- it_behaves_like 'moves the file to lost and found'
+ it_behaves_like "moves the file to lost and found"
end
- context 'when the file path does not fit the known pattern' do
- let!(:invalid_path) { File.join('group', 'file.jpg') }
+ context "when the file path does not fit the known pattern" do
+ let!(:invalid_path) { File.join("group", "file.jpg") }
let!(:path) { File.join(FileUploader.root, invalid_path) }
- let!(:new_path) { File.join(FileUploader.root, '-', 'project-lost-found', invalid_path) }
+ let!(:new_path) { File.join(FileUploader.root, "-", "project-lost-found", invalid_path) }
before do
FileUtils.mkdir_p(File.dirname(path))
@@ -193,13 +193,13 @@ describe Gitlab::Cleanup::ProjectUploads do
File.delete(path) if File.exist?(path)
end
- it_behaves_like 'moves the file to lost and found'
+ it_behaves_like "moves the file to lost and found"
end
end
end
- context 'non-orphaned project upload file' do
- it 'does not move the file' do
+ context "non-orphaned project upload file" do
+ it "does not move the file" do
tracked = create(:upload, :issuable_upload, :with_file, model: build(:project, :legacy_storage))
tracked_path = tracked.absolute_path
@@ -212,19 +212,19 @@ describe Gitlab::Cleanup::ProjectUploads do
end
end
- context 'ignorable cases' do
+ context "ignorable cases" do
# Because we aren't concerned about these, and can save a lot of
# processing time by ignoring them. If we wish to cleanup hashed storage
# directories, it should simply require removing this test and modifying
# the find command.
- context 'when the file is already in hashed storage' do
+ context "when the file is already in hashed storage" do
let(:project) { create(:project) }
before do
expect(logger).not_to receive(:info).with(/move|fix/i)
end
- it 'does not move even an orphan file' do
+ it "does not move even an orphan file" do
orphaned = create(:upload, :issuable_upload, :with_file, model: project)
path = orphaned.absolute_path
orphaned.delete
@@ -237,7 +237,7 @@ describe Gitlab::Cleanup::ProjectUploads do
end
end
- it 'does not move any non-project (FileUploader) uploads' do
+ it "does not move any non-project (FileUploader) uploads" do
paths = []
orphaned1 = create(:upload, :personal_snippet_upload, :with_file)
orphaned2 = create(:upload, :namespace_upload, :with_file)
@@ -261,8 +261,8 @@ describe Gitlab::Cleanup::ProjectUploads do
end
end
- it 'does not move any uploads in tmp (which would interfere with ongoing upload activity)' do
- path = File.join(FileUploader.root, 'tmp', 'foo.jpg')
+ it "does not move any uploads in tmp (which would interfere with ongoing upload activity)" do
+ path = File.join(FileUploader.root, "tmp", "foo.jpg")
FileUtils.mkdir_p(File.dirname(path))
FileUtils.touch(path)
diff --git a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb
index 35642cd6e50..722a26121ac 100644
--- a/spec/lib/gitlab/cleanup/remote_uploads_spec.rb
+++ b/spec/lib/gitlab/cleanup/remote_uploads_spec.rb
@@ -1,22 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Gitlab::Cleanup::RemoteUploads do
- context 'when object_storage is enabled' do
+ context "when object_storage is enabled" do
let(:connection) { double }
let(:directory) { double }
let!(:uploads) do
[
- create(:upload, path: 'dir/file1', store: ObjectStorage::Store::REMOTE),
- create(:upload, path: 'dir/file2', store: ObjectStorage::Store::LOCAL)
+ create(:upload, path: "dir/file1", store: ObjectStorage::Store::REMOTE),
+ create(:upload, path: "dir/file2", store: ObjectStorage::Store::LOCAL),
]
end
let(:remote_files) do
[
- double(key: 'dir/file1'),
- double(key: 'dir/file2'),
- double(key: 'dir/file3'),
- double(key: 'lost_and_found/dir/file3')
+ double(key: "dir/file1"),
+ double(key: "dir/file2"),
+ double(key: "dir/file3"),
+ double(key: "lost_and_found/dir/file3"),
]
end
@@ -29,10 +30,10 @@ describe Gitlab::Cleanup::RemoteUploads do
expect(directory).to receive(:files).and_return(remote_files)
end
- context 'when dry_run is set to false' do
+ context "when dry_run is set to false" do
subject { described_class.new.run!(dry_run: false) }
- it 'moves files that are not in uploads table' do
+ it "moves files that are not in uploads table" do
expect(remote_files[0]).not_to receive(:copy)
expect(remote_files[0]).not_to receive(:destroy)
expect(remote_files[1]).to receive(:copy)
@@ -46,10 +47,10 @@ describe Gitlab::Cleanup::RemoteUploads do
end
end
- context 'when dry_run is set to true' do
+ context "when dry_run is set to true" do
subject { described_class.new.run!(dry_run: true) }
- it 'does not move filese' do
+ it "does not move filese" do
expect(remote_files[0]).not_to receive(:copy)
expect(remote_files[0]).not_to receive(:destroy)
expect(remote_files[1]).not_to receive(:copy)
@@ -64,8 +65,8 @@ describe Gitlab::Cleanup::RemoteUploads do
end
end
- context 'when object_storage is not enabled' do
- it 'does not connect to any storage' do
+ context "when object_storage is not enabled" do
+ it "does not connect to any storage" do
expect(::Fog::Storage).not_to receive(:new)
subject
diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb
index 44568f2a653..7a2fd25b539 100644
--- a/spec/lib/gitlab/closing_issue_extractor_spec.rb
+++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ClosingIssueExtractor do
let(:project) { create(:project) }
@@ -19,7 +19,7 @@ describe Gitlab::ClosingIssueExtractor do
end
describe "#closed_by_message" do
- context 'with a single reference' do
+ context "with a single reference" do
it do
message = "Awesome commit (Closes #{reference})"
expect(subject.closed_by_message(message)).to eq([issue])
@@ -295,9 +295,9 @@ describe Gitlab::ClosingIssueExtractor do
expect(subject.closed_by_message(message)).to eq([issue])
end
- context 'with an external issue tracker reference' do
- it 'extracts the referenced issue' do
- jira_project = create(:jira_project, name: 'JIRA_EXT1')
+ context "with an external issue tracker reference" do
+ it "extracts the referenced issue" do
+ jira_project = create(:jira_project, name: "JIRA_EXT1")
jira_project.add_maintainer(jira_project.creator)
jira_issue = ExternalIssue.new("#{jira_project.name}-1", project: jira_project)
closing_issue_extractor = described_class.new(jira_project, jira_project.creator)
@@ -345,95 +345,95 @@ describe Gitlab::ClosingIssueExtractor do
end
end
- context 'with multiple references' do
+ context "with multiple references" do
let(:other_issue) { create(:issue, project: project) }
let(:third_issue) { create(:issue, project: project) }
let(:reference2) { other_issue.to_reference }
let(:reference3) { third_issue.to_reference }
- it 'fetches issues in single line message' do
+ it "fetches issues in single line message" do
message = "Closes #{reference} and fix #{reference2}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue])
+ .to match_array([issue, other_issue])
end
- it 'fetches comma-separated issues references in single line message' do
+ it "fetches comma-separated issues references in single line message" do
message = "Closes #{reference}, closes #{reference2}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue])
+ .to match_array([issue, other_issue])
end
- it 'fetches comma-separated issues numbers in single line message' do
+ it "fetches comma-separated issues numbers in single line message" do
message = "Closes #{reference}, #{reference2} and #{reference3}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
- it 'allows oxford commas (comma before and) when referencing multiple issues' do
+ it "allows oxford commas (comma before and) when referencing multiple issues" do
message = "Closes #{reference}, #{reference2}, and #{reference3}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
- it 'allows spaces before commas when referencing multiple issues' do
+ it "allows spaces before commas when referencing multiple issues" do
message = "Closes #{reference} , #{reference2} , and #{reference3}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
- it 'allows non-comma-separated issue numbers in single line message' do
+ it "allows non-comma-separated issue numbers in single line message" do
message = "Closes #{reference} #{reference2} #{reference3}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
- it 'allows mixed comma-separated and non-comma-separated issue numbers in single line message' do
+ it "allows mixed comma-separated and non-comma-separated issue numbers in single line message" do
message = "Closes #{reference}, #{reference2} and #{reference3}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
- it 'fetches issues in multi-line message' do
+ it "fetches issues in multi-line message" do
message = "Awesome commit (closes #{reference})\nAlso fixes #{reference2}"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue])
+ .to match_array([issue, other_issue])
end
- it 'fetches issues in hybrid message' do
+ it "fetches issues in hybrid message" do
message = "Awesome commit (closes #{reference})\n"\
"Also fixing issues #{reference2}, #{reference3} and #4"
expect(subject.closed_by_message(message))
- .to match_array([issue, other_issue, third_issue])
+ .to match_array([issue, other_issue, third_issue])
end
it "fetches cross-project references" do
message = "Closes #{reference} and #{cross_reference}"
expect(subject.closed_by_message(message))
- .to match_array([issue, issue2])
+ .to match_array([issue, issue2])
end
it "fetches cross-project URL references" do
message = "Closes #{urls.project_issue_url(issue2.project, issue2)}, #{reference} and #{urls.project_issue_url(other_issue.project, other_issue)}"
expect(subject.closed_by_message(message))
- .to match_array([issue, issue2, other_issue])
+ .to match_array([issue, issue2, other_issue])
end
it "ignores invalid cross-project URL references" do
message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)} and #{reference}"
expect(subject.closed_by_message(message))
- .to match_array([issue])
+ .to match_array([issue])
end
end
end
diff --git a/spec/lib/gitlab/color_schemes_spec.rb b/spec/lib/gitlab/color_schemes_spec.rb
index c7be45dbcd3..f57ed628601 100644
--- a/spec/lib/gitlab/color_schemes_spec.rb
+++ b/spec/lib/gitlab/color_schemes_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ColorSchemes do
- describe '.body_classes' do
- it 'returns a space-separated list of class names' do
+ describe ".body_classes" do
+ it "returns a space-separated list of class names" do
css = described_class.body_classes
- expect(css).to include('white')
- expect(css).to include(' solarized-light ')
- expect(css).to include(' monokai')
+ expect(css).to include("white")
+ expect(css).to include(" solarized-light ")
+ expect(css).to include(" monokai")
end
end
- describe '.by_id' do
- it 'returns a scheme by its ID' do
- expect(described_class.by_id(1).name).to eq 'White'
- expect(described_class.by_id(4).name).to eq 'Solarized Dark'
+ describe ".by_id" do
+ it "returns a scheme by its ID" do
+ expect(described_class.by_id(1).name).to eq "White"
+ expect(described_class.by_id(4).name).to eq "Solarized Dark"
end
end
- describe '.default' do
- it 'returns the default scheme' do
+ describe ".default" do
+ it "returns the default scheme" do
expect(described_class.default.id).to eq 1
end
end
- describe '.each' do
- it 'passes the block to the SCHEMES Array' do
+ describe ".each" do
+ it "passes the block to the SCHEMES Array" do
ids = []
described_class.each { |scheme| ids << scheme.id }
expect(ids).not_to be_empty
end
end
- describe '.for_user' do
- it 'returns default when user is nil' do
+ describe ".for_user" do
+ it "returns default when user is nil" do
expect(described_class.for_user(nil).id).to eq 1
end
diff --git a/spec/lib/gitlab/config/entry/attributable_spec.rb b/spec/lib/gitlab/config/entry/attributable_spec.rb
index abb4fff3ad7..ae5f6161982 100644
--- a/spec/lib/gitlab/config/entry/attributable_spec.rb
+++ b/spec/lib/gitlab/config/entry/attributable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Attributable do
let(:node) do
@@ -15,46 +15,46 @@ describe Gitlab::Config::Entry::Attributable do
end
end
- context 'when config is a hash' do
+ context "when config is a hash" do
before do
allow(instance)
.to receive(:config)
- .and_return({ name: 'some name', test: 'some test' })
+ .and_return({name: "some name", test: "some test"})
end
- it 'returns the value of config' do
- expect(instance.name).to eq 'some name'
- expect(instance.test).to eq 'some test'
+ it "returns the value of config" do
+ expect(instance.name).to eq "some name"
+ expect(instance.test).to eq "some test"
end
- it 'returns no method error for unknown attributes' do
+ it "returns no method error for unknown attributes" do
expect { instance.unknown }.to raise_error(NoMethodError)
end
end
- context 'when config is not a hash' do
+ context "when config is not a hash" do
before do
allow(instance)
.to receive(:config)
- .and_return('some test')
+ .and_return("some test")
end
- it 'returns nil' do
+ it "returns nil" do
expect(instance.test).to be_nil
end
end
- context 'when method is already defined in a superclass' do
- it 'raises an error' do
- expectation = expect do
+ context "when method is already defined in a superclass" do
+ it "raises an error" do
+ expectation = expect {
Class.new(String) do
include Gitlab::Config::Entry::Attributable
attributes :length
end
- end
+ }
- expectation.to raise_error(ArgumentError, 'Method already defined!')
+ expectation.to raise_error(ArgumentError, "Method already defined!")
end
end
end
diff --git a/spec/lib/gitlab/config/entry/boolean_spec.rb b/spec/lib/gitlab/config/entry/boolean_spec.rb
index 1b7a3f850ec..7d32f2e1d06 100644
--- a/spec/lib/gitlab/config/entry/boolean_spec.rb
+++ b/spec/lib/gitlab/config/entry/boolean_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Boolean do
let(:entry) { described_class.new(config) }
- describe 'validations' do
- context 'when entry config value is valid' do
+ describe "validations" do
+ context "when entry config value is valid" do
let(:config) { false }
- describe '#value' do
- it 'returns key value' do
+ describe "#value" do
+ it "returns key value" do
expect(entry.value).to eq false
end
end
- describe '#valid?' do
- it 'is valid' do
+ describe "#valid?" do
+ it "is valid" do
expect(entry).to be_valid
end
end
end
- context 'when entry value is not valid' do
- let(:config) { ['incorrect'] }
+ context "when entry value is not valid" do
+ let(:config) { ["incorrect"] }
- describe '#errors' do
- it 'saves errors' do
+ describe "#errors" do
+ it "saves errors" do
expect(entry.errors)
- .to include 'boolean config should be a boolean value'
+ .to include "boolean config should be a boolean value"
end
end
end
diff --git a/spec/lib/gitlab/config/entry/configurable_spec.rb b/spec/lib/gitlab/config/entry/configurable_spec.rb
index 37e38e49c0d..db6f94204cb 100644
--- a/spec/lib/gitlab/config/entry/configurable_spec.rb
+++ b/spec/lib/gitlab/config/entry/configurable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Configurable do
let(:entry) do
@@ -11,44 +11,44 @@ describe Gitlab::Config::Entry::Configurable do
allow(entry).to receive(:default)
end
- describe 'validations' do
- context 'when entry is a hash' do
- let(:instance) { entry.new(key: 'value') }
+ describe "validations" do
+ context "when entry is a hash" do
+ let(:instance) { entry.new(key: "value") }
- it 'correctly validates an instance' do
+ it "correctly validates an instance" do
expect(instance).to be_valid
end
end
- context 'when entry is not a hash' do
- let(:instance) { entry.new('ls') }
+ context "when entry is not a hash" do
+ let(:instance) { entry.new("ls") }
- it 'invalidates the instance' do
+ it "invalidates the instance" do
expect(instance).not_to be_valid
end
end
end
- describe 'configured entries' do
- let(:entry_class) { double('entry_class', default: nil) }
+ describe "configured entries" do
+ let(:entry_class) { double("entry_class", default: nil) }
before do
entry.class_exec(entry_class) do |entry_class|
- entry :object, entry_class, description: 'test object'
+ entry :object, entry_class, description: "test object"
end
end
- describe '.nodes' do
- it 'has valid nodes' do
+ describe ".nodes" do
+ it "has valid nodes" do
expect(entry.nodes).to include :object
end
- it 'creates a node factory' do
+ it "creates a node factory" do
expect(entry.nodes[:object])
.to be_an_instance_of Gitlab::Config::Entry::Factory
end
- it 'returns a duplicated factory object' do
+ it "returns a duplicated factory object" do
first_factory = entry.nodes[:object]
second_factory = entry.nodes[:object]
diff --git a/spec/lib/gitlab/config/entry/factory_spec.rb b/spec/lib/gitlab/config/entry/factory_spec.rb
index c29d17eaee3..9bbce6642ff 100644
--- a/spec/lib/gitlab/config/entry/factory_spec.rb
+++ b/spec/lib/gitlab/config/entry/factory_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Factory do
- describe '#create!' do
+ describe "#create!" do
class Script < Gitlab::Config::Entry::Node
include Gitlab::Config::Entry::Validatable
@@ -13,44 +13,44 @@ describe Gitlab::Config::Entry::Factory do
let(:entry) { Script }
let(:factory) { described_class.new(entry) }
- context 'when setting a concrete value' do
- it 'creates entry with valid value' do
+ context "when setting a concrete value" do
+ it "creates entry with valid value" do
entry = factory
- .value(%w(ls pwd))
+ .value(%w[ls pwd])
.create!
- expect(entry.value).to eq %w(ls pwd)
+ expect(entry.value).to eq %w[ls pwd]
end
- context 'when setting description' do
- it 'creates entry with description' do
+ context "when setting description" do
+ it "creates entry with description" do
entry = factory
- .value(%w(ls pwd))
- .with(description: 'test description')
+ .value(%w[ls pwd])
+ .with(description: "test description")
.create!
- expect(entry.value).to eq %w(ls pwd)
- expect(entry.description).to eq 'test description'
+ expect(entry.value).to eq %w[ls pwd]
+ expect(entry.description).to eq "test description"
end
end
- context 'when setting key' do
- it 'creates entry with custom key' do
+ context "when setting key" do
+ it "creates entry with custom key" do
entry = factory
- .value(%w(ls pwd))
- .with(key: 'test key')
+ .value(%w[ls pwd])
+ .with(key: "test key")
.create!
- expect(entry.key).to eq 'test key'
+ expect(entry.key).to eq "test key"
end
end
- context 'when setting a parent' do
+ context "when setting a parent" do
let(:object) { Object.new }
- it 'creates entry with valid parent' do
+ it "creates entry with valid parent" do
entry = factory
- .value('ls')
+ .value("ls")
.with(parent: object)
.create!
@@ -59,16 +59,16 @@ describe Gitlab::Config::Entry::Factory do
end
end
- context 'when not setting a value' do
- it 'raises error' do
+ context "when not setting a value" do
+ it "raises error" do
expect { factory.create! }.to raise_error(
Gitlab::Config::Entry::Factory::InvalidFactory
)
end
end
- context 'when creating entry with nil value' do
- it 'creates an unspecified entry' do
+ context "when creating entry with nil value" do
+ it "creates an unspecified entry" do
entry = factory
.value(nil)
.create!
@@ -78,17 +78,17 @@ describe Gitlab::Config::Entry::Factory do
end
end
- context 'when passing metadata' do
- let(:entry) { spy('entry') }
+ context "when passing metadata" do
+ let(:entry) { spy("entry") }
- it 'passes metadata as a parameter' do
+ it "passes metadata as a parameter" do
factory
- .value('some value')
- .metadata(some: 'hash')
+ .value("some value")
+ .metadata(some: "hash")
.create!
expect(entry).to have_received(:new)
- .with('some value', { some: 'hash' })
+ .with("some value", {some: "hash"})
end
end
end
diff --git a/spec/lib/gitlab/config/entry/simplifiable_spec.rb b/spec/lib/gitlab/config/entry/simplifiable_spec.rb
index bc8387ada67..3fa02e4fa1f 100644
--- a/spec/lib/gitlab/config/entry/simplifiable_spec.rb
+++ b/spec/lib/gitlab/config/entry/simplifiable_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Simplifiable do
- describe '.strategy' do
+ describe ".strategy" do
let(:entry) do
Class.new(described_class) do
- strategy :Something, if: -> { 'condition' }
- strategy :DifferentOne, if: -> { 'condition' }
+ strategy :Something, if: -> { "condition" }
+ strategy :DifferentOne, if: -> { "condition" }
end
end
- it 'defines entry strategies' do
+ it "defines entry strategies" do
expect(entry.strategies.size).to eq 2
expect(entry.strategies.map(&:name))
.to eq %i[Something DifferentOne]
end
end
- describe 'setting strategy by a condition' do
- let(:first) { double('first strategy') }
- let(:second) { double('second strategy') }
- let(:unknown) { double('unknown strategy') }
+ describe "setting strategy by a condition" do
+ let(:first) { double("first strategy") }
+ let(:second) { double("second strategy") }
+ let(:unknown) { double("unknown strategy") }
before do
stub_const("#{described_class.name}::Something", first)
@@ -27,61 +27,61 @@ describe Gitlab::Config::Entry::Simplifiable do
stub_const("#{described_class.name}::UnknownStrategy", unknown)
end
- context 'when first strategy should be used' do
+ context "when first strategy should be used" do
let(:entry) do
Class.new(described_class) do
- strategy :Something, if: -> (arg) { arg == 'something' }
- strategy :DifferentOne, if: -> (*) { false }
+ strategy :Something, if: ->(arg) { arg == "something" }
+ strategy :DifferentOne, if: ->(*) { false }
end
end
- it 'attemps to load a first strategy' do
- expect(first).to receive(:new).with('something', anything)
+ it "attemps to load a first strategy" do
+ expect(first).to receive(:new).with("something", anything)
- entry.new('something')
+ entry.new("something")
end
end
- context 'when second strategy should be used' do
+ context "when second strategy should be used" do
let(:entry) do
Class.new(described_class) do
- strategy :Something, if: -> (arg) { arg == 'something' }
- strategy :DifferentOne, if: -> (arg) { arg == 'test' }
+ strategy :Something, if: ->(arg) { arg == "something" }
+ strategy :DifferentOne, if: ->(arg) { arg == "test" }
end
end
- it 'attemps to load a second strategy' do
- expect(second).to receive(:new).with('test', anything)
+ it "attemps to load a second strategy" do
+ expect(second).to receive(:new).with("test", anything)
- entry.new('test')
+ entry.new("test")
end
end
- context 'when neither one is a valid strategy' do
+ context "when neither one is a valid strategy" do
let(:entry) do
Class.new(described_class) do
- strategy :Something, if: -> (*) { false }
- strategy :DifferentOne, if: -> (*) { false }
+ strategy :Something, if: ->(*) { false }
+ strategy :DifferentOne, if: ->(*) { false }
end
end
- it 'instantiates an unknown strategy' do
- expect(unknown).to receive(:new).with('test', anything)
+ it "instantiates an unknown strategy" do
+ expect(unknown).to receive(:new).with("test", anything)
- entry.new('test')
+ entry.new("test")
end
end
end
- context 'when a unknown strategy class is not defined' do
+ context "when a unknown strategy class is not defined" do
let(:entry) do
Class.new(described_class) do
- strategy :String, if: -> (*) { true }
+ strategy :String, if: ->(*) { true }
end
end
- it 'raises an error when being initialized' do
- expect { entry.new('something') }
+ it "raises an error when being initialized" do
+ expect { entry.new("something") }
.to raise_error ArgumentError, /UndefinedStrategy not available!/
end
end
diff --git a/spec/lib/gitlab/config/entry/undefined_spec.rb b/spec/lib/gitlab/config/entry/undefined_spec.rb
index 48f9d276c95..4e1dcb3aaa8 100644
--- a/spec/lib/gitlab/config/entry/undefined_spec.rb
+++ b/spec/lib/gitlab/config/entry/undefined_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Undefined do
let(:entry) { described_class.new }
- describe '#leaf?' do
- it 'is leaf node' do
+ describe "#leaf?" do
+ it "is leaf node" do
expect(entry).to be_leaf
end
end
- describe '#valid?' do
- it 'is always valid' do
+ describe "#valid?" do
+ it "is always valid" do
expect(entry).to be_valid
end
end
- describe '#errors' do
- it 'is does not contain errors' do
+ describe "#errors" do
+ it "is does not contain errors" do
expect(entry.errors).to be_empty
end
end
- describe '#value' do
- it 'returns nil' do
+ describe "#value" do
+ it "returns nil" do
expect(entry.value).to eq nil
end
end
- describe '#relevant?' do
- it 'is not relevant' do
+ describe "#relevant?" do
+ it "is not relevant" do
expect(entry.relevant?).to eq false
end
end
- describe '#specified?' do
- it 'is not defined' do
+ describe "#specified?" do
+ it "is not defined" do
expect(entry.specified?).to eq false
end
end
diff --git a/spec/lib/gitlab/config/entry/unspecified_spec.rb b/spec/lib/gitlab/config/entry/unspecified_spec.rb
index 64421824a12..f06a2baa3be 100644
--- a/spec/lib/gitlab/config/entry/unspecified_spec.rb
+++ b/spec/lib/gitlab/config/entry/unspecified_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Unspecified do
let(:unspecified) { described_class.new(entry) }
- let(:entry) { spy('Entry') }
+ let(:entry) { spy("Entry") }
- describe '#valid?' do
- it 'delegates method to entry' do
+ describe "#valid?" do
+ it "delegates method to entry" do
expect(unspecified.valid?).to eq entry
end
end
- describe '#errors' do
- it 'delegates method to entry' do
+ describe "#errors" do
+ it "delegates method to entry" do
expect(unspecified.errors).to eq entry
end
end
- describe '#value' do
- it 'delegates method to entry' do
+ describe "#value" do
+ it "delegates method to entry" do
expect(unspecified.value).to eq entry
end
end
- describe '#specified?' do
- it 'is always false' do
+ describe "#specified?" do
+ it "is always false" do
allow(entry).to receive(:specified?).and_return(true)
expect(unspecified.specified?).to be false
diff --git a/spec/lib/gitlab/config/entry/validatable_spec.rb b/spec/lib/gitlab/config/entry/validatable_spec.rb
index 5a8f9766d23..57c62c338db 100644
--- a/spec/lib/gitlab/config/entry/validatable_spec.rb
+++ b/spec/lib/gitlab/config/entry/validatable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Validatable do
let(:entry) do
@@ -7,7 +7,7 @@ describe Gitlab::Config::Entry::Validatable do
end
end
- describe '.validator' do
+ describe ".validator" do
before do
entry.class_eval do
attr_accessor :test_attribute
@@ -18,34 +18,34 @@ describe Gitlab::Config::Entry::Validatable do
end
end
- it 'returns validator' do
+ it "returns validator" do
expect(entry.validator.superclass)
.to be Gitlab::Config::Entry::Validator
end
- it 'returns only one validator to mitigate leaks' do
+ it "returns only one validator to mitigate leaks" do
expect { entry.validator }.not_to change { entry.validator }
end
- context 'when validating entry instance' do
- let(:entry_instance) { entry.new('something') }
+ context "when validating entry instance" do
+ let(:entry_instance) { entry.new("something") }
- context 'when attribute is valid' do
+ context "when attribute is valid" do
before do
- entry_instance.test_attribute = 'valid'
+ entry_instance.test_attribute = "valid"
end
- it 'instance of validator is valid' do
+ it "instance of validator is valid" do
expect(entry.validator.new(entry_instance)).to be_valid
end
end
- context 'when attribute is not valid' do
+ context "when attribute is not valid" do
before do
entry_instance.test_attribute = nil
end
- it 'instance of validator is invalid' do
+ it "instance of validator is invalid" do
expect(entry.validator.new(entry_instance)).to be_invalid
end
end
diff --git a/spec/lib/gitlab/config/entry/validator_spec.rb b/spec/lib/gitlab/config/entry/validator_spec.rb
index efa16c4265c..ba0c8c0ff5a 100644
--- a/spec/lib/gitlab/config/entry/validator_spec.rb
+++ b/spec/lib/gitlab/config/entry/validator_spec.rb
@@ -1,50 +1,50 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Entry::Validator do
let(:validator) { Class.new(described_class) }
let(:validator_instance) { validator.new(node) }
- let(:node) { spy('node') }
+ let(:node) { spy("node") }
before do
- allow(node).to receive(:key).and_return('node')
+ allow(node).to receive(:key).and_return("node")
allow(node).to receive(:ancestors).and_return([])
end
- describe 'delegated validator' do
+ describe "delegated validator" do
before do
validator.class_eval do
validates :test_attribute, presence: true
end
end
- context 'when node is valid' do
+ context "when node is valid" do
before do
- allow(node).to receive(:test_attribute).and_return('valid value')
+ allow(node).to receive(:test_attribute).and_return("valid value")
end
- it 'validates attribute in node' do
+ it "validates attribute in node" do
expect(node).to receive(:test_attribute)
expect(validator_instance).to be_valid
end
- it 'returns no errors' do
+ it "returns no errors" do
validator_instance.validate
expect(validator_instance.messages).to be_empty
end
end
- context 'when node is invalid' do
+ context "when node is invalid" do
before do
allow(node).to receive(:test_attribute).and_return(nil)
end
- it 'validates attribute in node' do
+ it "validates attribute in node" do
expect(node).to receive(:test_attribute)
expect(validator_instance).to be_invalid
end
- it 'returns errors' do
+ it "returns errors" do
validator_instance.validate
expect(validator_instance.messages)
diff --git a/spec/lib/gitlab/config/loader/yaml_spec.rb b/spec/lib/gitlab/config/loader/yaml_spec.rb
index 44c9a3896a8..e868aadc0b2 100644
--- a/spec/lib/gitlab/config/loader/yaml_spec.rb
+++ b/spec/lib/gitlab/config/loader/yaml_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Config::Loader::Yaml do
let(:loader) { described_class.new(yml) }
- context 'when yaml syntax is correct' do
- let(:yml) { 'image: ruby:2.2' }
+ context "when yaml syntax is correct" do
+ let(:yml) { "image: ruby:2.2" }
- describe '#valid?' do
- it 'returns true' do
+ describe "#valid?" do
+ it "returns true" do
expect(loader.valid?).to be true
end
end
- describe '#load!' do
- it 'returns a valid hash' do
- expect(loader.load!).to eq(image: 'ruby:2.2')
+ describe "#load!" do
+ it "returns a valid hash" do
+ expect(loader.load!).to eq(image: "ruby:2.2")
end
end
end
- context 'when yaml syntax is incorrect' do
- let(:yml) { '// incorrect' }
+ context "when yaml syntax is incorrect" do
+ let(:yml) { "// incorrect" }
- describe '#valid?' do
- it 'returns false' do
+ describe "#valid?" do
+ it "returns false" do
expect(loader.valid?).to be false
end
end
- describe '#load!' do
- it 'raises error' do
+ describe "#load!" do
+ it "raises error" do
expect { loader.load! }.to raise_error(
Gitlab::Config::Loader::FormatError,
- 'Invalid configuration format'
+ "Invalid configuration format"
)
end
end
end
- context 'when there is an unknown alias' do
- let(:yml) { 'steps: *bad_alias' }
+ context "when there is an unknown alias" do
+ let(:yml) { "steps: *bad_alias" }
- describe '#initialize' do
- it 'raises FormatError' do
- expect { loader }.to raise_error(Gitlab::Config::Loader::FormatError, 'Unknown alias: bad_alias')
+ describe "#initialize" do
+ it "raises FormatError" do
+ expect { loader }.to raise_error(Gitlab::Config::Loader::FormatError, "Unknown alias: bad_alias")
end
end
end
- context 'when yaml config is empty' do
- let(:yml) { '' }
+ context "when yaml config is empty" do
+ let(:yml) { "" }
- describe '#valid?' do
- it 'returns false' do
+ describe "#valid?" do
+ it "returns false" do
expect(loader.valid?).to be false
end
end
diff --git a/spec/lib/gitlab/conflict/file_collection_spec.rb b/spec/lib/gitlab/conflict/file_collection_spec.rb
index c93912db411..5a95df50803 100644
--- a/spec/lib/gitlab/conflict/file_collection_spec.rb
+++ b/spec/lib/gitlab/conflict/file_collection_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Conflict::FileCollection do
- let(:merge_request) { create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start') }
+ let(:merge_request) { create(:merge_request, source_branch: "conflict-resolvable", target_branch: "conflict-start") }
let(:file_collection) { described_class.new(merge_request) }
- describe '#files' do
- it 'returns an array of Conflict::Files' do
+ describe "#files" do
+ it "returns an array of Conflict::Files" do
expect(file_collection.files).to all(be_an_instance_of(Gitlab::Conflict::File))
end
end
- describe '#cache' do
- it 'specifies a custom namespace with the merge request commit ids' do
+ describe "#cache" do
+ it "specifies a custom namespace with the merge request commit ids" do
our_commit = merge_request.source_branch_head.raw
their_commit = merge_request.target_branch_head.raw
custom_namespace = "#{our_commit.id}:#{their_commit.id}"
@@ -20,8 +20,8 @@ describe Gitlab::Conflict::FileCollection do
end
end
- describe '#can_be_resolved_in_ui?' do
- it 'returns true if conflicts for this collection can be resolved in the UI' do
+ describe "#can_be_resolved_in_ui?" do
+ it "returns true if conflicts for this collection can be resolved in the UI" do
expect(file_collection.can_be_resolved_in_ui?).to be true
end
@@ -31,7 +31,7 @@ describe Gitlab::Conflict::FileCollection do
expect(file_collection.can_be_resolved_in_ui?).to be false
end
- it 'caches the result' do
+ it "caches the result" do
expect(file_collection).to receive(:files).twice.and_call_original
expect(file_collection.can_be_resolved_in_ui?).to be true
@@ -42,15 +42,15 @@ describe Gitlab::Conflict::FileCollection do
end
end
- describe '#default_commit_message' do
- it 'matches the format of the git CLI commit message' do
- expect(file_collection.default_commit_message).to eq(<<EOM.chomp)
-Merge branch 'conflict-start' into 'conflict-resolvable'
+ describe "#default_commit_message" do
+ it "matches the format of the git CLI commit message" do
+ expect(file_collection.default_commit_message).to eq(<<~EOM.chomp)
+ Merge branch 'conflict-start' into 'conflict-resolvable'
-# Conflicts:
-# files/ruby/popen.rb
-# files/ruby/regex.rb
-EOM
+ # Conflicts:
+ # files/ruby/popen.rb
+ # files/ruby/regex.rb
+ EOM
end
end
end
diff --git a/spec/lib/gitlab/conflict/file_spec.rb b/spec/lib/gitlab/conflict/file_spec.rb
index a955ce54e85..609fa3dc00d 100644
--- a/spec/lib/gitlab/conflict/file_spec.rb
+++ b/spec/lib/gitlab/conflict/file_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Conflict::File do
include GitHelpers
@@ -6,54 +6,54 @@ describe Gitlab::Conflict::File do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:rugged) { rugged_repo(repository) }
- let(:their_commit) { rugged.branches['conflict-start'].target }
- let(:our_commit) { rugged.branches['conflict-resolvable'].target }
- let(:merge_request) { create(:merge_request, source_branch: 'conflict-resolvable', target_branch: 'conflict-start', source_project: project) }
+ let(:their_commit) { rugged.branches["conflict-start"].target }
+ let(:our_commit) { rugged.branches["conflict-resolvable"].target }
+ let(:merge_request) { create(:merge_request, source_branch: "conflict-resolvable", target_branch: "conflict-start", source_project: project) }
let(:index) { rugged.merge_commits(our_commit, their_commit) }
let(:rugged_conflict) { index.conflicts.last }
- let(:raw_conflict_content) { index.merge_file('files/ruby/regex.rb')[:data] }
+ let(:raw_conflict_content) { index.merge_file("files/ruby/regex.rb")[:data] }
let(:raw_conflict_file) { Gitlab::Git::Conflict::File.new(repository, our_commit.oid, rugged_conflict, raw_conflict_content) }
let(:conflict_file) { described_class.new(raw_conflict_file, merge_request: merge_request) }
- describe '#resolve_lines' do
+ describe "#resolve_lines" do
let(:section_keys) { conflict_file.sections.map { |section| section[:id] }.compact }
- context 'when resolving everything to the same side' do
- let(:resolution_hash) { section_keys.map { |key| [key, 'head'] }.to_h }
+ context "when resolving everything to the same side" do
+ let(:resolution_hash) { section_keys.map { |key| [key, "head"] }.to_h }
let(:resolved_lines) { conflict_file.resolve_lines(resolution_hash) }
- let(:expected_lines) { conflict_file.lines.reject { |line| line.type == 'old' } }
+ let(:expected_lines) { conflict_file.lines.reject { |line| line.type == "old" } }
- it 'has the correct number of lines' do
+ it "has the correct number of lines" do
expect(resolved_lines.length).to eq(expected_lines.length)
end
- it 'has content matching the chosen lines' do
+ it "has content matching the chosen lines" do
expect(resolved_lines.map(&:text)).to eq(expected_lines.map(&:text))
end
end
- context 'with mixed resolutions' do
+ context "with mixed resolutions" do
let(:resolution_hash) do
- section_keys.map.with_index { |key, i| [key, i.even? ? 'head' : 'origin'] }.to_h
+ section_keys.map.with_index { |key, i| [key, i.even? ? "head" : "origin"] }.to_h
end
let(:resolved_lines) { conflict_file.resolve_lines(resolution_hash) }
- it 'has the correct number of lines' do
- file_lines = conflict_file.lines.reject { |line| line.type == 'new' }
+ it "has the correct number of lines" do
+ file_lines = conflict_file.lines.reject { |line| line.type == "new" }
expect(resolved_lines.length).to eq(file_lines.length)
end
- it 'returns a file containing only the chosen parts of the resolved sections' do
- expect(resolved_lines.chunk { |line| line.type || 'both' }.map(&:first))
- .to eq(%w(both new both old both new both))
+ it "returns a file containing only the chosen parts of the resolved sections" do
+ expect(resolved_lines.chunk { |line| line.type || "both" }.map(&:first))
+ .to eq(%w[both new both old both new both])
end
end
- it 'raises ResolutionError when passed a hash without resolutions for all sections' do
+ it "raises ResolutionError when passed a hash without resolutions for all sections" do
empty_hash = section_keys.map { |key| [key, nil] }.to_h
- invalid_hash = section_keys.map { |key| [key, 'invalid'] }.to_h
+ invalid_hash = section_keys.map { |key| [key, "invalid"] }.to_h
expect { conflict_file.resolve_lines({}) }
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
@@ -66,18 +66,18 @@ describe Gitlab::Conflict::File do
end
end
- describe '#highlight_lines!' do
+ describe "#highlight_lines!" do
def html_to_text(html)
CGI.unescapeHTML(ActionView::Base.full_sanitizer.sanitize(html)).delete("\n")
end
- it 'is called implicitly when rich_text is accessed on a line' do
+ it "is called implicitly when rich_text is accessed on a line" do
expect(conflict_file).to receive(:highlight_lines!).once.and_call_original
conflict_file.lines.each(&:rich_text)
end
- it 'sets the rich_text of the lines matching the text content' do
+ it "sets the rich_text of the lines matching the text content" do
conflict_file.lines.each do |line|
expect(line.text).to eq(html_to_text(line.rich_text))
end
@@ -85,14 +85,14 @@ describe Gitlab::Conflict::File do
# This spec will break if Rouge's highlighting changes, but we need to
# ensure that the lines are actually highlighted.
- it 'highlights the lines correctly' do
+ it "highlights the lines correctly" do
expect(conflict_file.lines.first.rich_text)
.to eq("<span id=\"LC1\" class=\"line\" lang=\"ruby\"><span class=\"k\">module</span> <span class=\"nn\">Gitlab</span></span>\n")
end
end
- describe '#sections' do
- it 'only inserts match lines when there is a gap between sections' do
+ describe "#sections" do
+ it "only inserts match lines when there is a gap between sections" do
conflict_file.sections.each_with_index do |section, i|
previous_line_number = 0
current_line_number = section[:lines].map(&:old_line).compact.min
@@ -102,39 +102,39 @@ describe Gitlab::Conflict::File do
end
if current_line_number == previous_line_number + 1
- expect(section[:lines].first.type).not_to eq('match')
+ expect(section[:lines].first.type).not_to eq("match")
else
- expect(section[:lines].first.type).to eq('match')
+ expect(section[:lines].first.type).to eq("match")
expect(section[:lines].first.text).to match(/\A@@ -#{current_line_number},\d+ \+\d+,\d+ @@ module Gitlab\Z/)
end
end
end
- it 'sets conflict to false for sections with only unchanged lines' do
+ it "sets conflict to false for sections with only unchanged lines" do
conflict_file.sections.reject { |section| section[:conflict] }.each do |section|
- without_match = section[:lines].reject { |line| line.type == 'match' }
+ without_match = section[:lines].reject { |line| line.type == "match" }
expect(without_match).to all(have_attributes(type: nil))
end
end
- it 'only includes a maximum of CONTEXT_LINES (plus an optional match line) in context sections' do
+ it "only includes a maximum of CONTEXT_LINES (plus an optional match line) in context sections" do
conflict_file.sections.reject { |section| section[:conflict] }.each do |section|
- without_match = section[:lines].reject { |line| line.type == 'match' }
+ without_match = section[:lines].reject { |line| line.type == "match" }
expect(without_match.length).to be <= Gitlab::Conflict::File::CONTEXT_LINES * 2
end
end
- it 'sets conflict to true for sections with only changed lines' do
+ it "sets conflict to true for sections with only changed lines" do
conflict_file.sections.select { |section| section[:conflict] }.each do |section|
section[:lines].each do |line|
- expect(line.type).to be_in(%w(new old))
+ expect(line.type).to be_in(%w[new old])
end
end
end
- it 'adds unique IDs to conflict sections, and not to other sections' do
+ it "adds unique IDs to conflict sections, and not to other sections" do
section_ids = []
conflict_file.sections.each do |section|
@@ -149,100 +149,100 @@ describe Gitlab::Conflict::File do
expect(section_ids.uniq).to eq(section_ids)
end
- context 'with an example file' do
+ context "with an example file" do
let(:raw_conflict_content) do
- <<FILE
- # Ensure there is no match line header here
- def username_regexp
- default_regexp
- end
-
-<<<<<<< files/ruby/regex.rb
-def project_name_regexp
- /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/
-end
-
-def name_regexp
- /\A[a-zA-Z0-9_\-\. ]*\z/
-=======
-def project_name_regex
- %r{\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z}
-end
-
-def name_regex
- %r{\A[a-zA-Z0-9_\-\. ]*\z}
->>>>>>> files/ruby/regex.rb
-end
-
-# Some extra lines
-# To force a match line
-# To be created
-
-def path_regexp
- default_regexp
-end
-
-<<<<<<< files/ruby/regex.rb
-def archive_formats_regexp
- /(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
-=======
-def archive_formats_regex
- %r{(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)}
->>>>>>> files/ruby/regex.rb
-end
-
-def git_reference_regexp
- # Valid git ref regexp, see:
- # https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
- %r{
- (?!
- (?# doesn't begins with)
- \/| (?# rule #6)
- (?# doesn't contain)
- .*(?:
- [\/.]\.| (?# rule #1,3)
- \/\/| (?# rule #6)
- @\{| (?# rule #8)
- \\ (?# rule #9)
- )
- )
- [^\000-\040\177~^:?*\[]+ (?# rule #4-5)
- (?# doesn't end with)
- (?<!\.lock) (?# rule #1)
- (?<![\/.]) (?# rule #6-7)
- }x
-end
-
-protected
-
-<<<<<<< files/ruby/regex.rb
-def default_regexp
- /\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
-=======
-def default_regex
- %r{\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z}
->>>>>>> files/ruby/regex.rb
-end
-FILE
+ <<~FILE
+ # Ensure there is no match line header here
+ def username_regexp
+ default_regexp
+ end
+
+ <<<<<<< files/ruby/regex.rb
+ def project_name_regexp
+ /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/
+ end
+
+ def name_regexp
+ /\A[a-zA-Z0-9_\-\. ]*\z/
+ =======
+ def project_name_regex
+ %r{\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z}
+ end
+
+ def name_regex
+ %r{\A[a-zA-Z0-9_\-\. ]*\z}
+ >>>>>>> files/ruby/regex.rb
+ end
+
+ # Some extra lines
+ # To force a match line
+ # To be created
+
+ def path_regexp
+ default_regexp
+ end
+
+ <<<<<<< files/ruby/regex.rb
+ def archive_formats_regexp
+ /(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
+ =======
+ def archive_formats_regex
+ %r{(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)}
+ >>>>>>> files/ruby/regex.rb
+ end
+
+ def git_reference_regexp
+ # Valid git ref regexp, see:
+ # https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
+ %r{
+ (?!
+ (?# doesn't begins with)
+ \/| (?# rule #6)
+ (?# doesn't contain)
+ .*(?:
+ [\/.]\.| (?# rule #1,3)
+ \/\/| (?# rule #6)
+ @\{| (?# rule #8)
+ \\ (?# rule #9)
+ )
+ )
+ [^\000-\040\177~^:?*\[]+ (?# rule #4-5)
+ (?# doesn't end with)
+ (?<!\.lock) (?# rule #1)
+ (?<![\/.]) (?# rule #6-7)
+ }x
+ end
+
+ protected
+
+ <<<<<<< files/ruby/regex.rb
+ def default_regexp
+ /\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
+ =======
+ def default_regex
+ %r{\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z}
+ >>>>>>> files/ruby/regex.rb
+ end
+ FILE
end
let(:sections) { conflict_file.sections }
- it 'sets the correct match line headers' do
- expect(sections[0][:lines].first).to have_attributes(type: 'match', text: '@@ -3,14 +3,14 @@')
- expect(sections[3][:lines].first).to have_attributes(type: 'match', text: '@@ -19,26 +19,26 @@ def path_regexp')
- expect(sections[6][:lines].first).to have_attributes(type: 'match', text: '@@ -47,52 +47,52 @@ end')
+ it "sets the correct match line headers" do
+ expect(sections[0][:lines].first).to have_attributes(type: "match", text: "@@ -3,14 +3,14 @@")
+ expect(sections[3][:lines].first).to have_attributes(type: "match", text: "@@ -19,26 +19,26 @@ def path_regexp")
+ expect(sections[6][:lines].first).to have_attributes(type: "match", text: "@@ -47,52 +47,52 @@ end")
end
- it 'does not add match lines where they are not needed' do
- expect(sections[1][:lines].first.type).not_to eq('match')
- expect(sections[2][:lines].first.type).not_to eq('match')
- expect(sections[4][:lines].first.type).not_to eq('match')
- expect(sections[5][:lines].first.type).not_to eq('match')
- expect(sections[7][:lines].first.type).not_to eq('match')
+ it "does not add match lines where they are not needed" do
+ expect(sections[1][:lines].first.type).not_to eq("match")
+ expect(sections[2][:lines].first.type).not_to eq("match")
+ expect(sections[4][:lines].first.type).not_to eq("match")
+ expect(sections[5][:lines].first.type).not_to eq("match")
+ expect(sections[7][:lines].first.type).not_to eq("match")
end
- it 'creates context sections of the correct length' do
+ it "creates context sections of the correct length" do
expect(sections[0][:lines].reject(&:type).length).to eq(3)
expect(sections[2][:lines].reject(&:type).length).to eq(3)
expect(sections[3][:lines].reject(&:type).length).to eq(3)
@@ -253,18 +253,18 @@ FILE
end
end
- describe '#as_json' do
- it 'includes the blob path for the file' do
+ describe "#as_json" do
+ it "includes the blob path for the file" do
expect(conflict_file.as_json[:blob_path])
.to eq("/#{project.full_path}/blob/#{our_commit.oid}/files/ruby/regex.rb")
end
- it 'includes the blob icon for the file' do
- expect(conflict_file.as_json[:blob_icon]).to eq('file-text-o')
+ it "includes the blob icon for the file" do
+ expect(conflict_file.as_json[:blob_icon]).to eq("file-text-o")
end
- context 'with the full_content option passed' do
- it 'includes the full content of the conflict' do
+ context "with the full_content option passed" do
+ it "includes the full content of the conflict" do
expect(conflict_file.as_json(full_content: true)).to have_key(:content)
end
end
diff --git a/spec/lib/gitlab/contributions_calendar_spec.rb b/spec/lib/gitlab/contributions_calendar_spec.rb
index b7924302014..6184dbcfdce 100644
--- a/spec/lib/gitlab/contributions_calendar_spec.rb
+++ b/spec/lib/gitlab/contributions_calendar_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ContributionsCalendar do
let(:contributor) { create(:user) }
@@ -53,7 +53,7 @@ describe Gitlab::ContributionsCalendar do
)
end
- describe '#activity_dates' do
+ describe "#activity_dates" do
it "returns a hash of date => count" do
create_event(public_project, last_week)
create_event(public_project, last_week)
@@ -97,26 +97,26 @@ describe Gitlab::ContributionsCalendar do
end
it "renders correct event counts within the UTC timezone" do
- Time.use_zone('UTC') do
+ Time.use_zone("UTC") do
expect(calendar.activity_dates).to eq(today => 5)
end
end
it "renders correct event counts within the Sydney timezone" do
- Time.use_zone('Sydney') do
+ Time.use_zone("Sydney") do
expect(calendar.activity_dates).to eq(today => 3, tomorrow => 2)
end
end
it "renders correct event counts within the US Central timezone" do
- Time.use_zone('Central Time (US & Canada)') do
+ Time.use_zone("Central Time (US & Canada)") do
expect(calendar.activity_dates).to eq(yesterday => 2, today => 3)
end
end
end
end
- describe '#events_by_date' do
+ describe "#events_by_date" do
it "returns all events for a given date" do
e1 = create_event(public_project, today)
e2 = create_event(public_project, today)
@@ -135,13 +135,13 @@ describe Gitlab::ContributionsCalendar do
expect(calendar(contributor).events_by_date(today)).to contain_exactly(e1, e2, e3)
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
before do
allow(Ability).to receive(:allowed?).and_call_original
expect(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
end
- it 'does not return any events' do
+ it "does not return any events" do
create_event(public_project, today)
expect(calendar(user).events_by_date(today)).to be_empty
@@ -149,13 +149,13 @@ describe Gitlab::ContributionsCalendar do
end
end
- describe '#starting_year' do
+ describe "#starting_year" do
it "should be the start of last year" do
expect(calendar.starting_year).to eq(last_year.year)
end
end
- describe '#starting_month' do
+ describe "#starting_month" do
it "should be the start of this month" do
expect(calendar.starting_month).to eq(today.month)
end
diff --git a/spec/lib/gitlab/correlation_id_spec.rb b/spec/lib/gitlab/correlation_id_spec.rb
index 584d1f48386..8d84898120b 100644
--- a/spec/lib/gitlab/correlation_id_spec.rb
+++ b/spec/lib/gitlab/correlation_id_spec.rb
@@ -1,56 +1,56 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::CorrelationId do
- describe '.use_id' do
- it 'yields when executed' do
- expect { |blk| described_class.use_id('id', &blk) }.to yield_control
+ describe ".use_id" do
+ it "yields when executed" do
+ expect { |blk| described_class.use_id("id", &blk) }.to yield_control
end
- it 'stacks correlation ids' do
- described_class.use_id('id1') do
- described_class.use_id('id2') do |current_id|
- expect(current_id).to eq('id2')
+ it "stacks correlation ids" do
+ described_class.use_id("id1") do
+ described_class.use_id("id2") do |current_id|
+ expect(current_id).to eq("id2")
end
end
end
- it 'for missing correlation id it generates random one' do
- described_class.use_id('id1') do
+ it "for missing correlation id it generates random one" do
+ described_class.use_id("id1") do
described_class.use_id(nil) do |current_id|
expect(current_id).not_to be_empty
- expect(current_id).not_to eq('id1')
+ expect(current_id).not_to eq("id1")
end
end
end
end
- describe '.current_id' do
+ describe ".current_id" do
subject { described_class.current_id }
- it 'returns last correlation id' do
- described_class.use_id('id1') do
- described_class.use_id('id2') do
- is_expected.to eq('id2')
+ it "returns last correlation id" do
+ described_class.use_id("id1") do
+ described_class.use_id("id2") do
+ is_expected.to eq("id2")
end
end
end
end
- describe '.current_or_new_id' do
+ describe ".current_or_new_id" do
subject { described_class.current_or_new_id }
- context 'when correlation id is set' do
- it 'returns last correlation id' do
- described_class.use_id('id1') do
- is_expected.to eq('id1')
+ context "when correlation id is set" do
+ it "returns last correlation id" do
+ described_class.use_id("id1") do
+ is_expected.to eq("id1")
end
end
end
- context 'when correlation id is missing' do
- it 'returns a new correlation id' do
+ context "when correlation id is missing" do
+ it "returns a new correlation id" do
expect(described_class).to receive(:new_id)
.and_call_original
@@ -59,17 +59,17 @@ describe Gitlab::CorrelationId do
end
end
- describe '.ids' do
+ describe ".ids" do
subject { described_class.send(:ids) }
- it 'returns empty list if not correlation is used' do
+ it "returns empty list if not correlation is used" do
is_expected.to be_empty
end
- it 'returns list if correlation ids are used' do
- described_class.use_id('id1') do
- described_class.use_id('id2') do
- is_expected.to eq(%w(id1 id2))
+ it "returns list if correlation ids are used" do
+ described_class.use_id("id1") do
+ described_class.use_id("id2") do
+ is_expected.to eq(%w[id1 id2])
end
end
end
diff --git a/spec/lib/gitlab/cross_project_access/check_collection_spec.rb b/spec/lib/gitlab/cross_project_access/check_collection_spec.rb
index a9e7575240e..61f1a5e257f 100644
--- a/spec/lib/gitlab/cross_project_access/check_collection_spec.rb
+++ b/spec/lib/gitlab/cross_project_access/check_collection_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CrossProjectAccess::CheckCollection do
subject(:collection) { described_class.new }
- describe '#add_collection' do
- it 'merges the checks of 2 collections' do
- initial_check = double('check')
+ describe "#add_collection" do
+ it "merges the checks of 2 collections" do
+ initial_check = double("check")
collection.add_check(initial_check)
other_collection = described_class.new
- other_check = double('other_check')
+ other_check = double("other_check")
other_collection.add_check(other_check)
- shared_check = double('shared check')
+ shared_check = double("shared check")
other_collection.add_check(shared_check)
collection.add_check(shared_check)
@@ -22,7 +22,7 @@ describe Gitlab::CrossProjectAccess::CheckCollection do
end
end
- describe '#should_run?' do
+ describe "#should_run?" do
def fake_check(run, skip)
check = double("Check: run=#{run} - skip={skip}")
allow(check).to receive(:should_run?).and_return(run)
@@ -32,7 +32,7 @@ describe Gitlab::CrossProjectAccess::CheckCollection do
check
end
- it 'returns true if one of the check says it should run' do
+ it "returns true if one of the check says it should run" do
check = fake_check(true, false)
other_check = fake_check(false, false)
@@ -42,7 +42,7 @@ describe Gitlab::CrossProjectAccess::CheckCollection do
expect(collection.should_run?(double)).to be_truthy
end
- it 'returns false if one of the check says it should be skipped' do
+ it "returns false if one of the check says it should be skipped" do
check = fake_check(true, false)
other_check = fake_check(false, true)
diff --git a/spec/lib/gitlab/cross_project_access/check_info_spec.rb b/spec/lib/gitlab/cross_project_access/check_info_spec.rb
index ea7393a7006..820905bbad3 100644
--- a/spec/lib/gitlab/cross_project_access/check_info_spec.rb
+++ b/spec/lib/gitlab/cross_project_access/check_info_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CrossProjectAccess::CheckInfo do
let(:dummy_controller) { double }
before do
- allow(dummy_controller).to receive(:action_name).and_return('index')
+ allow(dummy_controller).to receive(:action_name).and_return("index")
end
- describe '#should_run?' do
- it 'runs when an action is defined' do
- info = described_class.new({ index: true }, nil, nil, false)
+ describe "#should_run?" do
+ it "runs when an action is defined" do
+ info = described_class.new({index: true}, nil, nil, false)
expect(info.should_run?(dummy_controller)).to be_truthy
end
- it 'runs when the action is missing' do
+ it "runs when the action is missing" do
info = described_class.new({}, nil, nil, false)
expect(info.should_run?(dummy_controller)).to be_truthy
end
- it 'does not run when the action is excluded' do
- info = described_class.new({ index: false }, nil, nil, false)
+ it "does not run when the action is excluded" do
+ info = described_class.new({index: false}, nil, nil, false)
expect(info.should_run?(dummy_controller)).to be_falsy
end
- it 'runs when the `if` conditional is true' do
+ it "runs when the `if` conditional is true" do
info = described_class.new({}, -> { true }, nil, false)
expect(info.should_run?(dummy_controller)).to be_truthy
end
- it 'does not run when the if condition is false' do
+ it "does not run when the if condition is false" do
info = described_class.new({}, -> { false }, nil, false)
expect(info.should_run?(dummy_controller)).to be_falsy
end
- it 'does not run when the `unless` check is true' do
+ it "does not run when the `unless` check is true" do
info = described_class.new({}, nil, -> { true }, false)
expect(info.should_run?(dummy_controller)).to be_falsy
end
- it 'runs when the `unless` check is false' do
+ it "runs when the `unless` check is false" do
info = described_class.new({}, nil, -> { false }, false)
expect(info.should_run?(dummy_controller)).to be_truthy
end
- it 'returns the opposite of #should_skip? when the check is a skip' do
+ it "returns the opposite of #should_skip? when the check is a skip" do
info = described_class.new({}, nil, nil, true)
expect(info).to receive(:should_skip?).with(dummy_controller).and_return(false)
@@ -58,50 +58,50 @@ describe Gitlab::CrossProjectAccess::CheckInfo do
end
end
- describe '#should_skip?' do
- it 'skips when an action is defined' do
- info = described_class.new({ index: true }, nil, nil, true)
+ describe "#should_skip?" do
+ it "skips when an action is defined" do
+ info = described_class.new({index: true}, nil, nil, true)
expect(info.should_skip?(dummy_controller)).to be_truthy
end
- it 'does not skip when the action is not defined' do
+ it "does not skip when the action is not defined" do
info = described_class.new({}, nil, nil, true)
expect(info.should_skip?(dummy_controller)).to be_falsy
end
- it 'does not skip when the action is excluded' do
- info = described_class.new({ index: false }, nil, nil, true)
+ it "does not skip when the action is excluded" do
+ info = described_class.new({index: false}, nil, nil, true)
expect(info.should_skip?(dummy_controller)).to be_falsy
end
- it 'skips when the `if` conditional is true' do
- info = described_class.new({ index: true }, -> { true }, nil, true)
+ it "skips when the `if` conditional is true" do
+ info = described_class.new({index: true}, -> { true }, nil, true)
expect(info.should_skip?(dummy_controller)).to be_truthy
end
- it 'does not skip the `if` conditional is false' do
- info = described_class.new({ index: true }, -> { false }, nil, true)
+ it "does not skip the `if` conditional is false" do
+ info = described_class.new({index: true}, -> { false }, nil, true)
expect(info.should_skip?(dummy_controller)).to be_falsy
end
- it 'does not skip when the `unless` check is true' do
- info = described_class.new({ index: true }, nil, -> { true }, true)
+ it "does not skip when the `unless` check is true" do
+ info = described_class.new({index: true}, nil, -> { true }, true)
expect(info.should_skip?(dummy_controller)).to be_falsy
end
- it 'skips when `unless` check is false' do
- info = described_class.new({ index: true }, nil, -> { false }, true)
+ it "skips when `unless` check is false" do
+ info = described_class.new({index: true}, nil, -> { false }, true)
expect(info.should_skip?(dummy_controller)).to be_truthy
end
- it 'returns the opposite of #should_run? when the check is not a skip' do
+ it "returns the opposite of #should_run? when the check is not a skip" do
info = described_class.new({}, nil, nil, false)
expect(info).to receive(:should_run?).with(dummy_controller).and_return(false)
diff --git a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb
index 5349685e633..8449ce9c297 100644
--- a/spec/lib/gitlab/cross_project_access/class_methods_spec.rb
+++ b/spec/lib/gitlab/cross_project_access/class_methods_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CrossProjectAccess::ClassMethods do
let(:dummy_class) do
@@ -8,35 +8,35 @@ describe Gitlab::CrossProjectAccess::ClassMethods do
end
let(:dummy_proc) { lambda { false } }
- describe '#requires_cross_project_access' do
- it 'creates a correct check when a hash is passed' do
+ describe "#requires_cross_project_access" do
+ it "creates a correct check when a hash is passed" do
expect(Gitlab::CrossProjectAccess)
.to receive(:add_check).with(dummy_class,
- actions: { hello: true, world: false },
- positive_condition: dummy_proc,
- negative_condition: dummy_proc)
+ actions: {hello: true, world: false},
+ positive_condition: dummy_proc,
+ negative_condition: dummy_proc)
dummy_class.requires_cross_project_access(
hello: true, world: false, if: dummy_proc, unless: dummy_proc
)
end
- it 'creates a correct check when an array is passed' do
+ it "creates a correct check when an array is passed" do
expect(Gitlab::CrossProjectAccess)
.to receive(:add_check).with(dummy_class,
- actions: { hello: true, world: true },
- positive_condition: nil,
- negative_condition: nil)
+ actions: {hello: true, world: true},
+ positive_condition: nil,
+ negative_condition: nil)
dummy_class.requires_cross_project_access(:hello, :world)
end
- it 'creates a correct check when an array and a hash is passed' do
+ it "creates a correct check when an array and a hash is passed" do
expect(Gitlab::CrossProjectAccess)
.to receive(:add_check).with(dummy_class,
- actions: { hello: true, world: true },
- positive_condition: dummy_proc,
- negative_condition: dummy_proc)
+ actions: {hello: true, world: true},
+ positive_condition: dummy_proc,
+ negative_condition: dummy_proc)
dummy_class.requires_cross_project_access(
:hello, :world, if: dummy_proc, unless: dummy_proc
diff --git a/spec/lib/gitlab/cross_project_access_spec.rb b/spec/lib/gitlab/cross_project_access_spec.rb
index 614b0473c7e..99e81e2c1e1 100644
--- a/spec/lib/gitlab/cross_project_access_spec.rb
+++ b/spec/lib/gitlab/cross_project_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CrossProjectAccess do
let(:super_class) { Class.new }
@@ -9,30 +9,30 @@ describe Gitlab::CrossProjectAccess do
allow(described_class).to receive(:instance).and_return(current_instance)
end
- describe '#add_check' do
- it 'keeps track of the properties to check' do
- expect do
+ describe "#add_check" do
+ it "keeps track of the properties to check" do
+ expect {
described_class.add_check(super_class,
- actions: { index: true },
- positive_condition: -> { true },
- negative_condition: -> { false })
- end.to change { described_class.checks.size }.by(1)
+ actions: {index: true},
+ positive_condition: -> { true },
+ negative_condition: -> { false })
+ }.to change { described_class.checks.size }.by(1)
end
- it 'builds the check correctly' do
+ it "builds the check correctly" do
check_collection = described_class.add_check(super_class,
- actions: { index: true },
- positive_condition: -> { 'positive' },
- negative_condition: -> { 'negative' })
+ actions: {index: true},
+ positive_condition: -> { "positive" },
+ negative_condition: -> { "negative" })
check = check_collection.checks.first
expect(check.actions).to eq(index: true)
- expect(check.positive_condition.call).to eq('positive')
- expect(check.negative_condition.call).to eq('negative')
+ expect(check.positive_condition.call).to eq("positive")
+ expect(check.negative_condition.call).to eq("negative")
end
- it 'merges the checks of a parent class into existing checks of a subclass' do
+ it "merges the checks of a parent class into existing checks of a subclass" do
subclass_collection = described_class.add_check(descendant_class)
expect(subclass_collection).to receive(:add_collection).and_call_original
@@ -40,7 +40,7 @@ describe Gitlab::CrossProjectAccess do
described_class.add_check(super_class)
end
- it 'merges the existing checks of a superclass into the checks of a subclass' do
+ it "merges the existing checks of a superclass into the checks of a subclass" do
super_collection = described_class.add_check(super_class)
descendant_collection = described_class.add_check(descendant_class)
@@ -48,33 +48,33 @@ describe Gitlab::CrossProjectAccess do
end
end
- describe '#find_check' do
- it 'returns a check when it was defined for a superclass' do
+ describe "#find_check" do
+ it "returns a check when it was defined for a superclass" do
expected_check = described_class.add_check(super_class,
- actions: { index: true },
- positive_condition: -> { 'positive' },
- negative_condition: -> { 'negative' })
+ actions: {index: true},
+ positive_condition: -> { "positive" },
+ negative_condition: -> { "negative" })
expect(described_class.find_check(descendant_class.new))
.to eq(expected_check)
end
- it 'caches the result for a subclass' do
+ it "caches the result for a subclass" do
described_class.add_check(super_class,
- actions: { index: true },
- positive_condition: -> { 'positive' },
- negative_condition: -> { 'negative' })
+ actions: {index: true},
+ positive_condition: -> { "positive" },
+ negative_condition: -> { "negative" })
expect(described_class.instance).to receive(:closest_parent).once.and_call_original
2.times { described_class.find_check(descendant_class.new) }
end
- it 'returns the checks for the closest class if there are more checks available' do
+ it "returns the checks for the closest class if there are more checks available" do
described_class.add_check(super_class,
- actions: { index: true })
+ actions: {index: true})
expected_check = described_class.add_check(descendant_class,
- actions: { index: true, show: false })
+ actions: {index: true, show: false})
check = described_class.find_check(descendant_class.new)
diff --git a/spec/lib/gitlab/crypto_helper_spec.rb b/spec/lib/gitlab/crypto_helper_spec.rb
index 05cc6cf15de..5666a50fc40 100644
--- a/spec/lib/gitlab/crypto_helper_spec.rb
+++ b/spec/lib/gitlab/crypto_helper_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CryptoHelper do
- describe '.sha256' do
- it 'generates SHA256 digest Base46 encoded' do
- digest = described_class.sha256('some-value')
+ describe ".sha256" do
+ it "generates SHA256 digest Base46 encoded" do
+ digest = described_class.sha256("some-value")
expect(digest).to match %r{\A[A-Za-z0-9+/=]+\z}
expect(digest).to eq digest.strip
end
end
- describe '.aes256_gcm_encrypt' do
- it 'is Base64 encoded string without new line character' do
- encrypted = described_class.aes256_gcm_encrypt('some-value')
+ describe ".aes256_gcm_encrypt" do
+ it "is Base64 encoded string without new line character" do
+ encrypted = described_class.aes256_gcm_encrypt("some-value")
expect(encrypted).to match %r{\A[A-Za-z0-9+/=]+\z}
expect(encrypted).not_to include "\n"
end
end
- describe '.aes256_gcm_decrypt' do
- let(:encrypted) { described_class.aes256_gcm_encrypt('some-value') }
+ describe ".aes256_gcm_decrypt" do
+ let(:encrypted) { described_class.aes256_gcm_encrypt("some-value") }
- it 'correctly decrypts encrypted string' do
+ it "correctly decrypts encrypted string" do
decrypted = described_class.aes256_gcm_decrypt(encrypted)
- expect(decrypted).to eq 'some-value'
+ expect(decrypted).to eq "some-value"
end
- it 'decrypts a value when it ends with a new line character' do
+ it "decrypts a value when it ends with a new line character" do
decrypted = described_class.aes256_gcm_decrypt(encrypted + "\n")
- expect(decrypted).to eq 'some-value'
+ expect(decrypted).to eq "some-value"
end
end
end
diff --git a/spec/lib/gitlab/current_settings_spec.rb b/spec/lib/gitlab/current_settings_spec.rb
index 17d5eae24f5..6cdf11c5261 100644
--- a/spec/lib/gitlab/current_settings_spec.rb
+++ b/spec/lib/gitlab/current_settings_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CurrentSettings do
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- shared_context 'with settings in cache' do
+ shared_context "with settings in cache" do
before do
create(:application_setting)
described_class.current_application_settings # warm the cache
end
end
- describe '#current_application_settings', :use_clean_rails_memory_store_caching do
- it 'allows keys to be called directly' do
+ describe "#current_application_settings", :use_clean_rails_memory_store_caching do
+ it "allows keys to be called directly" do
db_settings = create(:application_setting,
- home_page_url: 'http://mydomain.com',
+ home_page_url: "http://mydomain.com",
signup_enabled: false)
expect(described_class.home_page_url).to eq(db_settings.home_page_url)
@@ -26,10 +26,10 @@ describe Gitlab::CurrentSettings do
context 'when ENV["IN_MEMORY_APPLICATION_SETTINGS"] is true' do
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'true')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "true")
end
- it 'returns an in-memory ApplicationSetting object' do
+ it "returns an in-memory ApplicationSetting object" do
expect(ApplicationSetting).not_to receive(:current)
expect(described_class.current_application_settings).to be_a(ApplicationSetting)
@@ -37,16 +37,16 @@ describe Gitlab::CurrentSettings do
end
end
- context 'with DB unavailable' do
- context 'and settings in cache' do
- include_context 'with settings in cache'
+ context "with DB unavailable" do
+ context "and settings in cache" do
+ include_context "with settings in cache"
- it 'fetches the settings from cache without issuing any query' do
+ it "fetches the settings from cache without issuing any query" do
expect(ActiveRecord::QueryRecorder.new { described_class.current_application_settings }.count).to eq(0)
end
end
- context 'and no settings in cache' do
+ context "and no settings in cache" do
before do
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(false)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
@@ -54,17 +54,17 @@ describe Gitlab::CurrentSettings do
expect(ApplicationSetting).not_to receive(:current)
end
- it 'returns a FakeApplicationSettings object' do
+ it "returns a FakeApplicationSettings object" do
expect(described_class.current_application_settings).to be_a(Gitlab::FakeApplicationSettings)
end
- it 'does not issue any query' do
+ it "does not issue any query" do
expect(ActiveRecord::QueryRecorder.new { described_class.current_application_settings }.count).to eq(0)
end
end
end
- context 'with DB available' do
+ context "with DB available" do
# This method returns the ::ApplicationSetting.defaults hash
# but with respect of custom attribute accessors of ApplicationSetting model
def settings_from_defaults
@@ -72,10 +72,10 @@ describe Gitlab::CurrentSettings do
ar_wrapped_defaults.slice(*::ApplicationSetting.defaults.keys)
end
- context 'and settings in cache' do
- include_context 'with settings in cache'
+ context "and settings in cache" do
+ include_context "with settings in cache"
- it 'fetches the settings from cache' do
+ it "fetches the settings from cache" do
# For some reason, `allow(described_class).to receive(:connect_to_db?).and_return(true)` causes issues
# during the initialization phase of the test suite, so instead let's mock the internals of it
expect(ActiveRecord::Base.connection).not_to receive(:active?)
@@ -85,21 +85,21 @@ describe Gitlab::CurrentSettings do
end
end
- context 'and no settings in cache' do
+ context "and no settings in cache" do
before do
allow(ActiveRecord::Base.connection).to receive(:active?).and_return(true)
- allow(ActiveRecord::Base.connection).to receive(:cached_table_exists?).with('application_settings').and_return(true)
+ allow(ActiveRecord::Base.connection).to receive(:cached_table_exists?).with("application_settings").and_return(true)
end
- context 'with RequestStore enabled', :request_store do
- it 'fetches the settings from DB only once' do
+ context "with RequestStore enabled", :request_store do
+ it "fetches the settings from DB only once" do
described_class.current_application_settings # warm the cache
expect(ActiveRecord::QueryRecorder.new { described_class.current_application_settings }.count).to eq(0)
end
end
- it 'creates default ApplicationSettings if none are present' do
+ it "creates default ApplicationSettings if none are present" do
settings = described_class.current_application_settings
expect(settings).to be_a(ApplicationSetting)
@@ -107,61 +107,61 @@ describe Gitlab::CurrentSettings do
expect(settings).to have_attributes(settings_from_defaults)
end
- context 'with pending migrations' do
+ context "with pending migrations" do
before do
expect(ActiveRecord::Migrator).to receive(:needs_migration?).and_return(true)
end
- shared_examples 'a non-persisted ApplicationSetting object' do
+ shared_examples "a non-persisted ApplicationSetting object" do
let(:current_settings) { described_class.current_application_settings }
- it 'returns a non-persisted ApplicationSetting object' do
+ it "returns a non-persisted ApplicationSetting object" do
expect(current_settings).to be_a(ApplicationSetting)
expect(current_settings).not_to be_persisted
end
- it 'uses the default value from ApplicationSetting.defaults' do
+ it "uses the default value from ApplicationSetting.defaults" do
expect(current_settings.signup_enabled).to eq(ApplicationSetting.defaults[:signup_enabled])
end
- it 'uses the default value from custom ApplicationSetting accessors' do
+ it "uses the default value from custom ApplicationSetting accessors" do
expect(current_settings.commit_email_hostname).to eq(ApplicationSetting.default_commit_email_hostname)
end
- it 'responds to predicate methods' do
+ it "responds to predicate methods" do
expect(current_settings.signup_enabled?).to eq(current_settings.signup_enabled)
end
end
- context 'with no ApplicationSetting DB record' do
- it_behaves_like 'a non-persisted ApplicationSetting object'
+ context "with no ApplicationSetting DB record" do
+ it_behaves_like "a non-persisted ApplicationSetting object"
end
- context 'with an existing ApplicationSetting DB record' do
- let!(:db_settings) { ApplicationSetting.build_from_defaults(home_page_url: 'http://mydomain.com').save! && ApplicationSetting.last }
+ context "with an existing ApplicationSetting DB record" do
+ let!(:db_settings) { ApplicationSetting.build_from_defaults(home_page_url: "http://mydomain.com").save! && ApplicationSetting.last }
let(:current_settings) { described_class.current_application_settings }
- it_behaves_like 'a non-persisted ApplicationSetting object'
+ it_behaves_like "a non-persisted ApplicationSetting object"
- it 'uses the value from the DB attribute if present and not overridden by an accessor' do
+ it "uses the value from the DB attribute if present and not overridden by an accessor" do
expect(current_settings.home_page_url).to eq(db_settings.home_page_url)
end
end
end
- context 'when ApplicationSettings.current is present' do
- it 'returns the existing application settings' do
+ context "when ApplicationSettings.current is present" do
+ it "returns the existing application settings" do
expect(ApplicationSetting).to receive(:current).and_return(:current_settings)
expect(described_class.current_application_settings).to eq(:current_settings)
end
end
- context 'when the application_settings table does not exist' do
- it 'returns a FakeApplicationSettings object' do
+ context "when the application_settings table does not exist" do
+ it "returns a FakeApplicationSettings object" do
expect(Gitlab::Database)
.to receive(:cached_table_exists?)
- .with('application_settings')
+ .with("application_settings")
.and_return(false)
expect(described_class.current_application_settings).to be_a(Gitlab::FakeApplicationSettings)
diff --git a/spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
index 8b07da11c5d..b7d875af88f 100644
--- a/spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/base_event_fetcher_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CycleAnalytics::BaseEventFetcher do
let(:max_events) { 2 }
@@ -7,9 +7,9 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do
let(:start_time_attrs) { Issue.arel_table[:created_at] }
let(:end_time_attrs) { [Issue::Metrics.arel_table[:first_associated_with_milestone_at]] }
let(:options) do
- { start_time_attrs: start_time_attrs,
- end_time_attrs: end_time_attrs,
- from: 30.days.ago }
+ {start_time_attrs: start_time_attrs,
+ end_time_attrs: end_time_attrs,
+ from: 30.days.ago,}
end
subject do
@@ -26,12 +26,12 @@ describe Gitlab::CycleAnalytics::BaseEventFetcher do
allow_any_instance_of(described_class)
.to receive(:allowed_ids).and_return(nil)
- stub_const('Gitlab::CycleAnalytics::BaseEventFetcher::MAX_EVENTS', max_events)
+ stub_const("Gitlab::CycleAnalytics::BaseEventFetcher::MAX_EVENTS", max_events)
setup_events(count: 3)
end
- it 'limits the rows to the max number' do
+ it "limits the rows to the max number" do
expect(subject.count).to eq(max_events)
end
diff --git a/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
index 0267e8c2f69..865f589078f 100644
--- a/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/code_event_fetcher_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::CodeEventFetcher do
let(:stage_name) { :code }
- it_behaves_like 'default query config' do
- it 'has a default order' do
+ it_behaves_like "default query config" do
+ it "has a default order" do
expect(event.order).not_to be_nil
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
index e8fc67acf05..4adb77b78ef 100644
--- a/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/code_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::CodeStage do
let(:stage_name) { :code }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb
index 397dd4e5d2c..c4b9809fe08 100644
--- a/spec/lib/gitlab/cycle_analytics/events_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'cycle analytics events' do
+describe "cycle analytics events" do
let(:project) { create(:project, :repository) }
let(:from_date) { 10.days.ago }
let(:user) { create(:user, :admin) }
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
let(:events) do
- CycleAnalytics.new(project, { from: from_date, current_user: user })[stage].events
+ CycleAnalytics.new(project, {from: from_date, current_user: user})[stage].events
end
before do
setup(context)
end
- describe '#issue_events' do
+ describe "#issue_events" do
let(:stage) { :issue }
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
- it 'has a title' do
+ it "has a title" do
expect(events.first[:title]).to eq(context.title)
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:url]).not_to be_nil
end
- it 'has an iid' do
+ it "has an iid" do
expect(events.first[:iid]).to eq(context.iid.to_s)
end
- it 'has a created_at timestamp' do
- expect(events.first[:created_at]).to end_with('ago')
+ it "has a created_at timestamp" do
+ expect(events.first[:created_at]).to end_with("ago")
end
it "has the author's URL" do
@@ -50,22 +50,22 @@ describe 'cycle analytics events' do
end
end
- describe '#plan_events' do
+ describe "#plan_events" do
let(:stage) { :plan }
- it 'has a title' do
+ it "has a title" do
expect(events.first[:title]).not_to be_nil
end
- it 'has a sha short ID' do
+ it "has a sha short ID" do
expect(events.first[:short_sha]).not_to be_nil
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:commit_url]).not_to be_nil
end
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
@@ -82,27 +82,27 @@ describe 'cycle analytics events' do
end
end
- describe '#code_events' do
+ describe "#code_events" do
let(:stage) { :code }
before do
create_commit_referencing_issue(context)
end
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
- it 'has a title' do
- expect(events.first[:title]).to eq('Awesome merge_request')
+ it "has a title" do
+ expect(events.first[:title]).to eq("Awesome merge_request")
end
- it 'has an iid' do
+ it "has an iid" do
expect(events.first[:iid]).to eq(context.iid.to_s)
end
- it 'has a created_at timestamp' do
- expect(events.first[:created_at]).to end_with('ago')
+ it "has a created_at timestamp" do
+ expect(events.first[:created_at]).to end_with("ago")
end
it "has the author's URL" do
@@ -118,17 +118,17 @@ describe 'cycle analytics events' do
end
end
- describe '#test_events' do
+ describe "#test_events" do
let(:stage) { :test }
let(:merge_request) { MergeRequest.first }
let!(:pipeline) do
create(:ci_pipeline,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha,
- project: project,
- head_pipeline_of: merge_request)
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha,
+ project: project,
+ head_pipeline_of: merge_request)
end
before do
@@ -139,68 +139,68 @@ describe 'cycle analytics events' do
pipeline.succeed!
end
- it 'has the name' do
+ it "has the name" do
expect(events.first[:name]).not_to be_nil
end
- it 'has the ID' do
+ it "has the ID" do
expect(events.first[:id]).not_to be_nil
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:url]).not_to be_nil
end
- it 'has the branch name' do
+ it "has the branch name" do
expect(events.first[:branch]).not_to be_nil
end
- it 'has the branch URL' do
+ it "has the branch URL" do
expect(events.first[:branch][:url]).not_to be_nil
end
- it 'has the short SHA' do
+ it "has the short SHA" do
expect(events.first[:short_sha]).not_to be_nil
end
- it 'has the commit URL' do
+ it "has the commit URL" do
expect(events.first[:commit_url]).not_to be_nil
end
- it 'has the date' do
+ it "has the date" do
expect(events.first[:date]).not_to be_nil
end
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
end
- describe '#review_events' do
+ describe "#review_events" do
let(:stage) { :review }
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
- it 'has a title' do
- expect(events.first[:title]).to eq('Awesome merge_request')
+ it "has a title" do
+ expect(events.first[:title]).to eq("Awesome merge_request")
end
- it 'has an iid' do
+ it "has an iid" do
expect(events.first[:iid]).to eq(context.iid.to_s)
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:url]).not_to be_nil
end
- it 'has a state' do
+ it "has a state" do
expect(events.first[:state]).not_to be_nil
end
- it 'has a created_at timestamp' do
+ it "has a created_at timestamp" do
expect(events.first[:created_at]).not_to be_nil
end
@@ -217,16 +217,16 @@ describe 'cycle analytics events' do
end
end
- describe '#staging_events' do
+ describe "#staging_events" do
let(:stage) { :staging }
let(:merge_request) { MergeRequest.first }
let!(:pipeline) do
create(:ci_pipeline,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha,
- project: project,
- head_pipeline_of: merge_request)
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha,
+ project: project,
+ head_pipeline_of: merge_request)
end
before do
@@ -240,39 +240,39 @@ describe 'cycle analytics events' do
deploy_master(user, project)
end
- it 'has the name' do
+ it "has the name" do
expect(events.first[:name]).not_to be_nil
end
- it 'has the ID' do
+ it "has the ID" do
expect(events.first[:id]).not_to be_nil
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:url]).not_to be_nil
end
- it 'has the branch name' do
+ it "has the branch name" do
expect(events.first[:branch]).not_to be_nil
end
- it 'has the branch URL' do
+ it "has the branch URL" do
expect(events.first[:branch][:url]).not_to be_nil
end
- it 'has the short SHA' do
+ it "has the short SHA" do
expect(events.first[:short_sha]).not_to be_nil
end
- it 'has the commit URL' do
+ it "has the commit URL" do
expect(events.first[:commit_url]).not_to be_nil
end
- it 'has the date' do
+ it "has the date" do
expect(events.first[:date]).not_to be_nil
end
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
@@ -289,7 +289,7 @@ describe 'cycle analytics events' do
end
end
- describe '#production_events' do
+ describe "#production_events" do
let(:stage) { :production }
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
@@ -298,24 +298,24 @@ describe 'cycle analytics events' do
deploy_master(user, project)
end
- it 'has the total time' do
+ it "has the total time" do
expect(events.first[:total_time]).not_to be_empty
end
- it 'has a title' do
+ it "has a title" do
expect(events.first[:title]).to eq(context.title)
end
- it 'has the URL' do
+ it "has the URL" do
expect(events.first[:url]).not_to be_nil
end
- it 'has an iid' do
+ it "has an iid" do
expect(events.first[:iid]).to eq(context.iid.to_s)
end
- it 'has a created_at timestamp' do
- expect(events.first[:created_at]).to end_with('ago')
+ it "has a created_at timestamp" do
+ expect(events.first[:created_at]).to end_with("ago")
end
it "has the author's URL" do
diff --git a/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
index fd9fa2fee49..01af6ab6cc8 100644
--- a/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/issue_event_fetcher_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::IssueEventFetcher do
let(:stage_name) { :issue }
- it_behaves_like 'default query config'
+ it_behaves_like "default query config"
end
diff --git a/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
index 3127f01989d..c5f6caa731b 100644
--- a/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/issue_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::IssueStage do
let(:stage_name) { :issue }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/permissions_spec.rb b/spec/lib/gitlab/cycle_analytics/permissions_spec.rb
index f670c7f6c75..6d875718f5c 100644
--- a/spec/lib/gitlab/cycle_analytics/permissions_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/permissions_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CycleAnalytics::Permissions do
let(:project) { create(:project, public_builds: false) }
@@ -6,121 +6,121 @@ describe Gitlab::CycleAnalytics::Permissions do
subject { described_class.get(user: user, project: project) }
- context 'user with no relation to the project' do
- it 'has no permissions to issue stage' do
+ context "user with no relation to the project" do
+ it "has no permissions to issue stage" do
expect(subject[:issue]).to eq(false)
end
- it 'has no permissions to test stage' do
+ it "has no permissions to test stage" do
expect(subject[:test]).to eq(false)
end
- it 'has no permissions to staging stage' do
+ it "has no permissions to staging stage" do
expect(subject[:staging]).to eq(false)
end
- it 'has no permissions to production stage' do
+ it "has no permissions to production stage" do
expect(subject[:production]).to eq(false)
end
- it 'has no permissions to code stage' do
+ it "has no permissions to code stage" do
expect(subject[:code]).to eq(false)
end
- it 'has no permissions to review stage' do
+ it "has no permissions to review stage" do
expect(subject[:review]).to eq(false)
end
- it 'has no permissions to plan stage' do
+ it "has no permissions to plan stage" do
expect(subject[:plan]).to eq(false)
end
end
- context 'user is maintainer' do
+ context "user is maintainer" do
before do
project.add_maintainer(user)
end
- it 'has permissions to issue stage' do
+ it "has permissions to issue stage" do
expect(subject[:issue]).to eq(true)
end
- it 'has permissions to test stage' do
+ it "has permissions to test stage" do
expect(subject[:test]).to eq(true)
end
- it 'has permissions to staging stage' do
+ it "has permissions to staging stage" do
expect(subject[:staging]).to eq(true)
end
- it 'has permissions to production stage' do
+ it "has permissions to production stage" do
expect(subject[:production]).to eq(true)
end
- it 'has permissions to code stage' do
+ it "has permissions to code stage" do
expect(subject[:code]).to eq(true)
end
- it 'has permissions to review stage' do
+ it "has permissions to review stage" do
expect(subject[:review]).to eq(true)
end
- it 'has permissions to plan stage' do
+ it "has permissions to plan stage" do
expect(subject[:plan]).to eq(true)
end
end
- context 'user has no build permissions' do
+ context "user has no build permissions" do
before do
project.add_guest(user)
end
- it 'has permissions to issue stage' do
+ it "has permissions to issue stage" do
expect(subject[:issue]).to eq(true)
end
- it 'has no permissions to test stage' do
+ it "has no permissions to test stage" do
expect(subject[:test]).to eq(false)
end
- it 'has no permissions to staging stage' do
+ it "has no permissions to staging stage" do
expect(subject[:staging]).to eq(false)
end
end
- context 'user has no merge request permissions' do
+ context "user has no merge request permissions" do
before do
project.add_guest(user)
end
- it 'has permissions to issue stage' do
+ it "has permissions to issue stage" do
expect(subject[:issue]).to eq(true)
end
- it 'has no permissions to code stage' do
+ it "has no permissions to code stage" do
expect(subject[:code]).to eq(false)
end
- it 'has no permissions to review stage' do
+ it "has no permissions to review stage" do
expect(subject[:review]).to eq(false)
end
end
- context 'user has no issue permissions' do
+ context "user has no issue permissions" do
before do
project.add_developer(user)
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
end
- it 'has permissions to code stage' do
+ it "has permissions to code stage" do
expect(subject[:code]).to eq(true)
end
- it 'has no permissions to issue stage' do
+ it "has no permissions to issue stage" do
expect(subject[:issue]).to eq(false)
end
- it 'has no permissions to production stage' do
+ it "has no permissions to production stage" do
expect(subject[:production]).to eq(false)
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
index 2e5dc5b5547..be7e5b8b060 100644
--- a/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/plan_event_fetcher_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::PlanEventFetcher do
let(:stage_name) { :plan }
- it_behaves_like 'default query config' do
- context 'no commits' do
- it 'does not blow up if there are no commits' do
+ it_behaves_like "default query config" do
+ context "no commits" do
+ it "does not blow up if there are no commits" do
allow(event).to receive(:event_result).and_return([{}])
expect { event.fetch }.not_to raise_error
diff --git a/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
index 4c715921ad6..d4ac00a236b 100644
--- a/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/plan_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::PlanStage do
let(:stage_name) { :plan }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
index 74001181305..ec2692a0a6d 100644
--- a/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/production_event_fetcher_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::ProductionEventFetcher do
let(:stage_name) { :production }
- it_behaves_like 'default query config'
+ it_behaves_like "default query config"
end
diff --git a/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
index 916684b81eb..6a991d1f4e8 100644
--- a/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/production_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::ProductionStage do
let(:stage_name) { :production }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
index 4f67c95ed4c..b1b403cf2c1 100644
--- a/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/review_event_fetcher_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::ReviewEventFetcher do
let(:stage_name) { :review }
- it_behaves_like 'default query config'
+ it_behaves_like "default query config"
end
diff --git a/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
index 1412c8dfa08..b6902e38710 100644
--- a/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/review_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::ReviewStage do
let(:stage_name) { :review }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
index c22d27f60d6..6cd785133d9 100644
--- a/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/shared_event_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'default query config' do
+shared_examples "default query config" do
let(:project) { create(:project) }
- let(:event) { described_class.new(project: project, stage: stage_name, options: { from: 1.day.ago }) }
+ let(:event) { described_class.new(project: project, stage: stage_name, options: {from: 1.day.ago}) }
- it 'has the stage attribute' do
+ it "has the stage attribute" do
expect(event.stage).not_to be_nil
end
- it 'has the projection attributes' do
+ it "has the projection attributes" do
expect(event.projections).not_to be_nil
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
index 08425acbfc8..4e8ca0706be 100644
--- a/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/shared_stage_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'base stage' do
+shared_examples "base stage" do
let(:stage) { described_class.new(project: double, options: {}) }
before do
@@ -8,23 +8,23 @@ shared_examples 'base stage' do
allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({})
end
- it 'has the median data value' do
+ it "has the median data value" do
expect(stage.as_json[:value]).not_to be_nil
end
- it 'has the median data stage' do
+ it "has the median data stage" do
expect(stage.as_json[:title]).not_to be_nil
end
- it 'has the median data description' do
+ it "has the median data description" do
expect(stage.as_json[:description]).not_to be_nil
end
- it 'has the title' do
+ it "has the title" do
expect(stage.title).to eq(stage_name.to_s.capitalize)
end
- it 'has the events' do
+ it "has the events" do
expect(stage.events).not_to be_nil
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
index f8009709ce2..91b630a0797 100644
--- a/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/stage_summary_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CycleAnalytics::StageSummary do
let(:project) { create(:project, :repository) }
@@ -23,20 +23,20 @@ describe Gitlab::CycleAnalytics::StageSummary do
describe "#commits" do
it "finds the number of commits created after the 'from date'" do
- Timecop.freeze(5.days.ago) { create_commit("Test message", project, user, 'master') }
- Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master') }
+ Timecop.freeze(5.days.ago) { create_commit("Test message", project, user, "master") }
+ Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, "master") }
expect(subject.second[:value]).to eq(1)
end
it "doesn't find commits from other projects" do
- Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project, :repository), user, 'master') }
+ Timecop.freeze(5.days.from_now) { create_commit("Test message", create(:project, :repository), user, "master") }
expect(subject.second[:value]).to eq(0)
end
it "finds a large (> 100) snumber of commits if present" do
- Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, 'master', count: 100) }
+ Timecop.freeze(5.days.from_now) { create_commit("Test message", project, user, "master", count: 100) }
expect(subject.second[:value]).to eq(100)
end
diff --git a/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
index bbc82496340..c143a090cc4 100644
--- a/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/staging_event_fetcher_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::StagingEventFetcher do
let(:stage_name) { :staging }
- it_behaves_like 'default query config' do
- it 'has a default order' do
+ it_behaves_like "default query config" do
+ it "has a default order" do
expect(event.order).not_to be_nil
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
index 8154b3ac701..6736172cfa5 100644
--- a/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/staging_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::StagingStage do
let(:stage_name) { :staging }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
index 6639fa54e0e..3732510fa57 100644
--- a/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/test_event_fetcher_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_event_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_event_spec"
describe Gitlab::CycleAnalytics::TestEventFetcher do
let(:stage_name) { :test }
- it_behaves_like 'default query config' do
- it 'has a default order' do
+ it_behaves_like "default query config" do
+ it "has a default order" do
expect(event.order).not_to be_nil
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb b/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
index eacde22cd56..1bf31023c3f 100644
--- a/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/test_stage_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'lib/gitlab/cycle_analytics/shared_stage_spec'
+require "spec_helper"
+require "lib/gitlab/cycle_analytics/shared_stage_spec"
describe Gitlab::CycleAnalytics::TestStage do
let(:stage_name) { :test }
- it_behaves_like 'base stage'
+ it_behaves_like "base stage"
end
diff --git a/spec/lib/gitlab/cycle_analytics/updater_spec.rb b/spec/lib/gitlab/cycle_analytics/updater_spec.rb
index eff54cd3692..0dfa5ecba94 100644
--- a/spec/lib/gitlab/cycle_analytics/updater_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/updater_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CycleAnalytics::Updater do
- describe 'updates authors' do
+ describe "updates authors" do
let(:user) { create(:user) }
- let(:events) { [{ 'author_id' => user.id }] }
+ let(:events) { [{"author_id" => user.id}] }
- it 'maps the correct user' do
- described_class.update!(events, from: 'author_id', to: 'author', klass: User)
+ it "maps the correct user" do
+ described_class.update!(events, from: "author_id", to: "author", klass: User)
- expect(events.first['author']).to eq(user)
+ expect(events.first["author"]).to eq(user)
end
end
- describe 'updates builds' do
+ describe "updates builds" do
let(:build) { create(:ci_build) }
- let(:events) { [{ 'id' => build.id }] }
+ let(:events) { [{"id" => build.id}] }
- it 'maps the correct build' do
- described_class.update!(events, from: 'id', to: 'build', klass: ::Ci::Build)
+ it "maps the correct build" do
+ described_class.update!(events, from: "id", to: "build", klass: ::Ci::Build)
- expect(events.first['build']).to eq(build)
+ expect(events.first["build"]).to eq(build)
end
end
end
diff --git a/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb b/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
index a785b17f682..6f565384fe8 100644
--- a/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/usage_data_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::CycleAnalytics::UsageData do
- describe '#to_json' do
+ describe "#to_json" do
before do
# Since git commits only have second precision, round up to the
# nearest second to ensure we have accurate median and standard
@@ -19,17 +19,17 @@ describe Gitlab::CycleAnalytics::UsageData do
milestone = create(:milestone, project: project)
mr = create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}")
- pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr)
+ pipeline = create(:ci_empty_pipeline, status: "created", project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr)
create_cycle(user, project, issue, mr, milestone, pipeline)
- deploy_master(user, project, environment: 'staging')
+ deploy_master(user, project, environment: "staging")
deploy_master(user, project)
end
end
end
- shared_examples 'a valid usage data result' do
- it 'returns the aggregated usage data of every selected project' do
+ shared_examples "a valid usage data result" do
+ it "returns the aggregated usage data of every selected project" do
result = subject.to_json
expect(result).to have_key(:avg_cycle_analytics)
@@ -48,92 +48,92 @@ describe Gitlab::CycleAnalytics::UsageData do
end
end
- context 'when using postgresql', :postgresql do
+ context "when using postgresql", :postgresql do
let(:expect_values_per_stage) do
{
issue: {
average: 5400,
sd: 2545,
- missing: 0
+ missing: 0,
},
plan: {
average: 1,
sd: 0,
- missing: 0
+ missing: 0,
},
code: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
test: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
review: {
average: 0,
sd: 0,
- missing: 0
+ missing: 0,
},
staging: {
average: 0,
sd: 0,
- missing: 0
+ missing: 0,
},
production: {
average: 5400,
sd: 2545,
- missing: 0
- }
+ missing: 0,
+ },
}
end
- it_behaves_like 'a valid usage data result'
+ it_behaves_like "a valid usage data result"
end
- context 'when using mysql', :mysql do
+ context "when using mysql", :mysql do
let(:expect_values_per_stage) do
{
issue: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
plan: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
code: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
test: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
review: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
staging: {
average: nil,
sd: 0,
- missing: 2
+ missing: 2,
},
production: {
average: nil,
sd: 0,
- missing: 2
- }
+ missing: 2,
+ },
}
end
- it_behaves_like 'a valid usage data result'
+ it_behaves_like "a valid usage data result"
end
end
end
diff --git a/spec/lib/gitlab/daemon_spec.rb b/spec/lib/gitlab/daemon_spec.rb
index 2bdb0dfc736..b55d61529e0 100644
--- a/spec/lib/gitlab/daemon_spec.rb
+++ b/spec/lib/gitlab/daemon_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Daemon do
subject { described_class.new }
@@ -8,7 +8,7 @@ describe Gitlab::Daemon do
allow(subject).to receive(:stop_working)
end
- describe '.instance' do
+ describe ".instance" do
before do
allow(Kernel).to receive(:at_exit)
end
@@ -17,36 +17,36 @@ describe Gitlab::Daemon do
described_class.instance_variable_set(:@instance, nil)
end
- it 'provides instance of Daemon' do
+ it "provides instance of Daemon" do
expect(described_class.instance).to be_instance_of(described_class)
end
- it 'subsequent invocations provide the same instance' do
+ it "subsequent invocations provide the same instance" do
expect(described_class.instance).to eq(described_class.instance)
end
- it 'creates at_exit hook when instance is created' do
+ it "creates at_exit hook when instance is created" do
expect(described_class.instance).not_to be_nil
expect(Kernel).to have_received(:at_exit)
end
end
- describe 'when Daemon is enabled' do
+ describe "when Daemon is enabled" do
before do
allow(subject).to receive(:enabled?).and_return(true)
end
- describe 'when Daemon is stopped' do
- describe '#start' do
- it 'starts the Daemon' do
+ describe "when Daemon is stopped" do
+ describe "#start" do
+ it "starts the Daemon" do
expect { subject.start.join }.to change { subject.thread? }.from(false).to(true)
expect(subject).to have_received(:start_working)
end
end
- describe '#stop' do
+ describe "#stop" do
it "doesn't shutdown stopped Daemon" do
expect { subject.stop }.not_to change { subject.thread? }
@@ -55,12 +55,12 @@ describe Gitlab::Daemon do
end
end
- describe 'when Daemon is running' do
+ describe "when Daemon is running" do
before do
subject.start.join
end
- describe '#start' do
+ describe "#start" do
it "doesn't start running Daemon" do
expect { subject.start.join }.not_to change { subject.thread? }
@@ -68,8 +68,8 @@ describe Gitlab::Daemon do
end
end
- describe '#stop' do
- it 'shutdowns Daemon' do
+ describe "#stop" do
+ it "shutdowns Daemon" do
expect { subject.stop }.to change { subject.thread? }.from(true).to(false)
expect(subject).to have_received(:stop_working)
@@ -78,12 +78,12 @@ describe Gitlab::Daemon do
end
end
- describe 'when Daemon is disabled' do
+ describe "when Daemon is disabled" do
before do
allow(subject).to receive(:enabled?).and_return(false)
end
- describe '#start' do
+ describe "#start" do
it "doesn't start working" do
expect(subject.start).to be_nil
expect { subject.start }.not_to change { subject.thread? }
@@ -92,7 +92,7 @@ describe Gitlab::Daemon do
end
end
- describe '#stop' do
+ describe "#stop" do
it "doesn't stop working" do
expect { subject.stop }.not_to change { subject.thread? }
diff --git a/spec/lib/gitlab/danger/helper_spec.rb b/spec/lib/gitlab/danger/helper_spec.rb
index 66cd8171c12..470b05c9d36 100644
--- a/spec/lib/gitlab/danger/helper_spec.rb
+++ b/spec/lib/gitlab/danger/helper_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
-require 'rspec-parameterized'
-require 'webmock/rspec'
+require "fast_spec_helper"
+require "rspec-parameterized"
+require "webmock/rspec"
-require 'gitlab/danger/helper'
+require "gitlab/danger/helper"
describe Gitlab::Danger::Helper do
using RSpec::Parameterized::TableSyntax
@@ -21,169 +21,169 @@ describe Gitlab::Danger::Helper do
let(:teammate_json) do
<<~JSON
- [
- {
- "username": "in-gitlab-ce",
- "name": "CE maintainer",
- "projects":{ "gitlab-ce": "maintainer backend" }
- },
- {
- "username": "in-gitlab-ee",
- "name": "EE reviewer",
- "projects":{ "gitlab-ee": "reviewer frontend" }
- }
- ]
+ [
+ {
+ "username": "in-gitlab-ce",
+ "name": "CE maintainer",
+ "projects":{ "gitlab-ce": "maintainer backend" }
+ },
+ {
+ "username": "in-gitlab-ee",
+ "name": "EE reviewer",
+ "projects":{ "gitlab-ee": "reviewer frontend" }
+ }
+ ]
JSON
end
let(:ce_teammate_matcher) do
satisfy do |teammate|
- teammate.username == 'in-gitlab-ce' &&
- teammate.name == 'CE maintainer' &&
- teammate.projects == { 'gitlab-ce' => 'maintainer backend' }
+ teammate.username == "in-gitlab-ce" &&
+ teammate.name == "CE maintainer" &&
+ teammate.projects == {"gitlab-ce" => "maintainer backend"}
end
end
let(:ee_teammate_matcher) do
satisfy do |teammate|
- teammate.username == 'in-gitlab-ee' &&
- teammate.name == 'EE reviewer' &&
- teammate.projects == { 'gitlab-ee' => 'reviewer frontend' }
+ teammate.username == "in-gitlab-ee" &&
+ teammate.name == "EE reviewer" &&
+ teammate.projects == {"gitlab-ee" => "reviewer frontend"}
end
end
- let(:fake_git) { double('fake-git') }
+ let(:fake_git) { double("fake-git") }
subject(:helper) { FakeDanger.new(git: fake_git) }
- describe '#all_changed_files' do
+ describe "#all_changed_files" do
subject { helper.all_changed_files }
- it 'interprets a list of changes from the danger git plugin' do
+ it "interprets a list of changes from the danger git plugin" do
expect(fake_git).to receive(:added_files) { %w[a b c.old] }
expect(fake_git).to receive(:modified_files) { %w[d e] }
expect(fake_git)
.to receive(:renamed_files)
.at_least(:once)
- .and_return([{ before: 'c.old', after: 'c.new' }])
+ .and_return([{before: "c.old", after: "c.new"}])
- is_expected.to contain_exactly('a', 'b', 'c.new', 'd', 'e')
+ is_expected.to contain_exactly("a", "b", "c.new", "d", "e")
end
end
- describe '#ee?' do
+ describe "#ee?" do
subject { helper.ee? }
- it 'returns true if CI_PROJECT_NAME if set to gitlab-ee' do
- stub_env('CI_PROJECT_NAME', 'gitlab-ee')
+ it "returns true if CI_PROJECT_NAME if set to gitlab-ee" do
+ stub_env("CI_PROJECT_NAME", "gitlab-ee")
expect(File).not_to receive(:exist?)
is_expected.to be_truthy
end
- it 'delegates to CHANGELOG-EE.md existence if CI_PROJECT_NAME is set to something else' do
- stub_env('CI_PROJECT_NAME', 'something else')
- expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { true }
+ it "delegates to CHANGELOG-EE.md existence if CI_PROJECT_NAME is set to something else" do
+ stub_env("CI_PROJECT_NAME", "something else")
+ expect(File).to receive(:exist?).with("../../CHANGELOG-EE.md") { true }
is_expected.to be_truthy
end
- it 'returns true if CHANGELOG-EE.md exists' do
- stub_env('CI_PROJECT_NAME', nil)
- expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { true }
+ it "returns true if CHANGELOG-EE.md exists" do
+ stub_env("CI_PROJECT_NAME", nil)
+ expect(File).to receive(:exist?).with("../../CHANGELOG-EE.md") { true }
is_expected.to be_truthy
end
it "returns false if CHANGELOG-EE.md doesn't exist" do
- stub_env('CI_PROJECT_NAME', nil)
- expect(File).to receive(:exist?).with('../../CHANGELOG-EE.md') { false }
+ stub_env("CI_PROJECT_NAME", nil)
+ expect(File).to receive(:exist?).with("../../CHANGELOG-EE.md") { false }
is_expected.to be_falsy
end
end
- describe '#project_name' do
+ describe "#project_name" do
subject { helper.project_name }
- it 'returns gitlab-ee if ee? returns true' do
+ it "returns gitlab-ee if ee? returns true" do
expect(helper).to receive(:ee?) { true }
- is_expected.to eq('gitlab-ee')
+ is_expected.to eq("gitlab-ee")
end
- it 'returns gitlab-ce if ee? returns false' do
+ it "returns gitlab-ce if ee? returns false" do
expect(helper).to receive(:ee?) { false }
- is_expected.to eq('gitlab-ce')
+ is_expected.to eq("gitlab-ce")
end
end
- describe '#team' do
+ describe "#team" do
subject(:team) { helper.team }
- context 'HTTP failure' do
+ context "HTTP failure" do
before do
WebMock
- .stub_request(:get, 'https://about.gitlab.com/roulette.json')
+ .stub_request(:get, "https://about.gitlab.com/roulette.json")
.to_return(status: 404)
end
- it 'raises a pretty error' do
+ it "raises a pretty error" do
expect { team }.to raise_error(/Failed to read/)
end
end
- context 'JSON failure' do
+ context "JSON failure" do
before do
WebMock
- .stub_request(:get, 'https://about.gitlab.com/roulette.json')
- .to_return(body: 'INVALID JSON')
+ .stub_request(:get, "https://about.gitlab.com/roulette.json")
+ .to_return(body: "INVALID JSON")
end
- it 'raises a pretty error' do
+ it "raises a pretty error" do
expect { team }.to raise_error(/Failed to parse/)
end
end
- context 'success' do
+ context "success" do
before do
WebMock
- .stub_request(:get, 'https://about.gitlab.com/roulette.json')
+ .stub_request(:get, "https://about.gitlab.com/roulette.json")
.to_return(body: teammate_json)
end
- it 'returns an array of teammates' do
+ it "returns an array of teammates" do
is_expected.to contain_exactly(ce_teammate_matcher, ee_teammate_matcher)
end
- it 'memoizes the result' do
+ it "memoizes the result" do
expect(team.object_id).to eq(helper.team.object_id)
end
end
end
- describe '#project_team' do
+ describe "#project_team" do
subject { helper.project_team }
before do
WebMock
- .stub_request(:get, 'https://about.gitlab.com/roulette.json')
+ .stub_request(:get, "https://about.gitlab.com/roulette.json")
.to_return(body: teammate_json)
end
- it 'filters team by project_name' do
+ it "filters team by project_name" do
expect(helper)
.to receive(:project_name)
.at_least(:once)
- .and_return('gitlab-ce')
+ .and_return("gitlab-ce")
is_expected.to contain_exactly(ce_teammate_matcher)
end
end
- describe '#changes_by_category' do
- it 'categorizes changed files' do
+ describe "#changes_by_category" do
+ it "categorizes changed files" do
expect(fake_git).to receive(:added_files) { %w[foo foo.md foo.rb foo.js db/foo qa/foo ee/changelogs/foo.yml] }
allow(fake_git).to receive(:modified_files) { [] }
allow(fake_git).to receive(:renamed_files) { [] }
@@ -200,80 +200,80 @@ describe Gitlab::Danger::Helper do
end
end
- describe '#category_for_file' do
+ describe "#category_for_file" do
where(:path, :expected_category) do
- 'doc/foo' | :docs
- 'CONTRIBUTING.md' | :docs
- 'LICENSE' | :docs
- 'MAINTENANCE.md' | :docs
- 'PHILOSOPHY.md' | :docs
- 'PROCESS.md' | :docs
- 'README.md' | :docs
-
- 'ee/doc/foo' | :unknown
- 'ee/README' | :unknown
-
- 'app/assets/foo' | :frontend
- 'app/views/foo' | :frontend
- 'public/foo' | :frontend
- 'spec/javascripts/foo' | :frontend
- 'spec/frontend/bar' | :frontend
- 'vendor/assets/foo' | :frontend
- 'jest.config.js' | :frontend
- 'package.json' | :frontend
- 'yarn.lock' | :frontend
-
- 'ee/app/assets/foo' | :frontend
- 'ee/app/views/foo' | :frontend
- 'ee/spec/javascripts/foo' | :frontend
- 'ee/spec/frontend/bar' | :frontend
-
- 'app/models/foo' | :backend
- 'bin/foo' | :backend
- 'config/foo' | :backend
- 'danger/foo' | :backend
- 'lib/foo' | :backend
- 'rubocop/foo' | :backend
- 'scripts/foo' | :backend
- 'spec/foo' | :backend
- 'spec/foo/bar' | :backend
-
- 'ee/app/foo' | :backend
- 'ee/bin/foo' | :backend
- 'ee/spec/foo' | :backend
- 'ee/spec/foo/bar' | :backend
-
- 'generator_templates/foo' | :backend
- 'vendor/languages.yml' | :backend
- 'vendor/licenses.csv' | :backend
-
- 'Dangerfile' | :backend
- 'Gemfile' | :backend
- 'Gemfile.lock' | :backend
- 'Procfile' | :backend
- 'Rakefile' | :backend
- '.gitlab-ci.yml' | :backend
- 'FOO_VERSION' | :backend
-
- 'ee/FOO_VERSION' | :unknown
-
- 'db/foo' | :database
- 'qa/foo' | :qa
-
- 'ee/db/foo' | :database
- 'ee/qa/foo' | :qa
-
- 'changelogs/foo' | :none
- 'ee/changelogs/foo' | :none
- 'locale/gitlab.pot' | :none
-
- 'FOO' | :unknown
- 'foo' | :unknown
-
- 'foo/bar.rb' | :backend
- 'foo/bar.js' | :frontend
- 'foo/bar.txt' | :docs
- 'foo/bar.md' | :docs
+ "doc/foo" | :docs
+ "CONTRIBUTING.md" | :docs
+ "LICENSE" | :docs
+ "MAINTENANCE.md" | :docs
+ "PHILOSOPHY.md" | :docs
+ "PROCESS.md" | :docs
+ "README.md" | :docs
+
+ "ee/doc/foo" | :unknown
+ "ee/README" | :unknown
+
+ "app/assets/foo" | :frontend
+ "app/views/foo" | :frontend
+ "public/foo" | :frontend
+ "spec/javascripts/foo" | :frontend
+ "spec/frontend/bar" | :frontend
+ "vendor/assets/foo" | :frontend
+ "jest.config.js" | :frontend
+ "package.json" | :frontend
+ "yarn.lock" | :frontend
+
+ "ee/app/assets/foo" | :frontend
+ "ee/app/views/foo" | :frontend
+ "ee/spec/javascripts/foo" | :frontend
+ "ee/spec/frontend/bar" | :frontend
+
+ "app/models/foo" | :backend
+ "bin/foo" | :backend
+ "config/foo" | :backend
+ "danger/foo" | :backend
+ "lib/foo" | :backend
+ "rubocop/foo" | :backend
+ "scripts/foo" | :backend
+ "spec/foo" | :backend
+ "spec/foo/bar" | :backend
+
+ "ee/app/foo" | :backend
+ "ee/bin/foo" | :backend
+ "ee/spec/foo" | :backend
+ "ee/spec/foo/bar" | :backend
+
+ "generator_templates/foo" | :backend
+ "vendor/languages.yml" | :backend
+ "vendor/licenses.csv" | :backend
+
+ "Dangerfile" | :backend
+ "Gemfile" | :backend
+ "Gemfile.lock" | :backend
+ "Procfile" | :backend
+ "Rakefile" | :backend
+ ".gitlab-ci.yml" | :backend
+ "FOO_VERSION" | :backend
+
+ "ee/FOO_VERSION" | :unknown
+
+ "db/foo" | :database
+ "qa/foo" | :qa
+
+ "ee/db/foo" | :database
+ "ee/qa/foo" | :qa
+
+ "changelogs/foo" | :none
+ "ee/changelogs/foo" | :none
+ "locale/gitlab.pot" | :none
+
+ "FOO" | :unknown
+ "foo" | :unknown
+
+ "foo/bar.rb" | :backend
+ "foo/bar.js" | :frontend
+ "foo/bar.txt" | :docs
+ "foo/bar.md" | :docs
end
with_them do
@@ -283,15 +283,15 @@ describe Gitlab::Danger::Helper do
end
end
- describe '#label_for_category' do
+ describe "#label_for_category" do
where(:category, :expected_label) do
- :backend | '~backend'
- :database | '~database'
- :docs | '~Documentation'
- :foo | '~foo'
- :frontend | '~frontend'
- :none | ''
- :qa | '~QA'
+ :backend | "~backend"
+ :database | "~database"
+ :docs | "~Documentation"
+ :foo | "~foo"
+ :frontend | "~frontend"
+ :none | ""
+ :qa | "~QA"
end
with_them do
diff --git a/spec/lib/gitlab/data_builder/build_spec.rb b/spec/lib/gitlab/data_builder/build_spec.rb
index 14fe196a986..69105d93a56 100644
--- a/spec/lib/gitlab/data_builder/build_spec.rb
+++ b/spec/lib/gitlab/data_builder/build_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DataBuilder::Build do
let(:build) { create(:ci_build) }
- describe '.build' do
+ describe ".build" do
let(:data) do
described_class.build(build)
end
@@ -19,27 +19,27 @@ describe Gitlab::DataBuilder::Build do
it { expect(data[:project_id]).to eq(build.project.id) }
it { expect(data[:project_name]).to eq(build.project.full_name) }
- context 'commit author_url' do
- context 'when no commit present' do
+ context "commit author_url" do
+ context "when no commit present" do
let(:build) { create(:ci_build) }
- it 'sets to mailing address of git_author_email' do
+ it "sets to mailing address of git_author_email" do
expect(data[:commit][:author_url]).to eq("mailto:#{build.pipeline.git_author_email}")
end
end
- context 'when commit present but has no author' do
+ context "when commit present but has no author" do
let(:build) { create(:ci_build, :with_commit) }
- it 'sets to mailing address of git_author_email' do
+ it "sets to mailing address of git_author_email" do
expect(data[:commit][:author_url]).to eq("mailto:#{build.pipeline.git_author_email}")
end
end
- context 'when commit and author are present' do
+ context "when commit and author are present" do
let(:build) { create(:ci_build, :with_commit_and_author) }
- it 'sets to GitLab user url' do
+ it "sets to GitLab user url" do
expect(data[:commit][:author_url]).to eq(Gitlab::Routing.url_helpers.user_url(username: build.commit.author.username))
end
end
diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb
index b236c1a9c49..4f0b107cd8c 100644
--- a/spec/lib/gitlab/data_builder/note_spec.rb
+++ b/spec/lib/gitlab/data_builder/note_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DataBuilder::Note do
let(:project) { create(:project, :repository) }
@@ -11,33 +11,33 @@ describe Gitlab::DataBuilder::Note do
expect(data[:object_attributes]).to have_key(:url)
expect(data[:object_attributes][:url])
.to eq(Gitlab::UrlBuilder.build(note))
- expect(data[:object_kind]).to eq('note')
+ expect(data[:object_kind]).to eq("note")
expect(data[:user]).to eq(user.hook_attrs)
end
- describe 'When asking for a note on commit' do
+ describe "When asking for a note on commit" do
let(:note) { create(:note_on_commit, project: project) }
- it 'returns the note and commit-specific data' do
+ it "returns the note and commit-specific data" do
expect(data).to have_key(:commit)
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
- describe 'When asking for a note on commit diff' do
+ describe "When asking for a note on commit diff" do
let(:note) { create(:diff_note_on_commit, project: project) }
- it 'returns the note and commit-specific data' do
+ it "returns the note and commit-specific data" do
expect(data).to have_key(:commit)
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
- describe 'When asking for a note on issue' do
+ describe "When asking for a note on issue" do
let(:issue) do
create(:issue, created_at: fixed_time, updated_at: fixed_time,
project: project)
@@ -47,27 +47,27 @@ describe Gitlab::DataBuilder::Note do
create(:note_on_issue, noteable: issue, project: project)
end
- it 'returns the note and issue-specific data' do
+ it "returns the note and issue-specific data" do
expect(data).to have_key(:issue)
- expect(data[:issue].except('updated_at'))
- .to eq(issue.reload.hook_attrs.except('updated_at'))
- expect(data[:issue]['updated_at'])
- .to be >= issue.hook_attrs['updated_at']
+ expect(data[:issue].except("updated_at"))
+ .to eq(issue.reload.hook_attrs.except("updated_at"))
+ expect(data[:issue]["updated_at"])
+ .to be >= issue.hook_attrs["updated_at"]
end
- context 'with confidential issue' do
+ context "with confidential issue" do
let(:issue) { create(:issue, project: project, confidential: true) }
- it 'sets event_type to confidential_note' do
- expect(data[:event_type]).to eq('confidential_note')
+ it "sets event_type to confidential_note" do
+ expect(data[:event_type]).to eq("confidential_note")
end
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
- describe 'When asking for a note on merge request' do
+ describe "When asking for a note on merge request" do
let(:merge_request) do
create(:merge_request, created_at: fixed_time,
updated_at: fixed_time,
@@ -79,19 +79,19 @@ describe Gitlab::DataBuilder::Note do
project: project)
end
- it 'returns the note and merge request data' do
+ it "returns the note and merge request data" do
expect(data).to have_key(:merge_request)
- expect(data[:merge_request].except('updated_at'))
- .to eq(merge_request.reload.hook_attrs.except('updated_at'))
- expect(data[:merge_request]['updated_at'])
- .to be >= merge_request.hook_attrs['updated_at']
+ expect(data[:merge_request].except("updated_at"))
+ .to eq(merge_request.reload.hook_attrs.except("updated_at"))
+ expect(data[:merge_request]["updated_at"])
+ .to be >= merge_request.hook_attrs["updated_at"]
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
- describe 'When asking for a note on merge request diff' do
+ describe "When asking for a note on merge request diff" do
let(:merge_request) do
create(:merge_request, created_at: fixed_time, updated_at: fixed_time,
source_project: project)
@@ -102,19 +102,19 @@ describe Gitlab::DataBuilder::Note do
project: project)
end
- it 'returns the note and merge request diff data' do
+ it "returns the note and merge request diff data" do
expect(data).to have_key(:merge_request)
- expect(data[:merge_request].except('updated_at'))
- .to eq(merge_request.reload.hook_attrs.except('updated_at'))
- expect(data[:merge_request]['updated_at'])
- .to be >= merge_request.hook_attrs['updated_at']
+ expect(data[:merge_request].except("updated_at"))
+ .to eq(merge_request.reload.hook_attrs.except("updated_at"))
+ expect(data[:merge_request]["updated_at"])
+ .to be >= merge_request.hook_attrs["updated_at"]
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
- describe 'When asking for a note on project snippet' do
+ describe "When asking for a note on project snippet" do
let!(:snippet) do
create(:project_snippet, created_at: fixed_time, updated_at: fixed_time,
project: project)
@@ -125,15 +125,15 @@ describe Gitlab::DataBuilder::Note do
project: project)
end
- it 'returns the note and project snippet data' do
+ it "returns the note and project snippet data" do
expect(data).to have_key(:snippet)
- expect(data[:snippet].except('updated_at'))
- .to eq(snippet.reload.hook_attrs.except('updated_at'))
- expect(data[:snippet]['updated_at'])
- .to be >= snippet.hook_attrs['updated_at']
+ expect(data[:snippet].except("updated_at"))
+ .to eq(snippet.reload.hook_attrs.except("updated_at"))
+ expect(data[:snippet]["updated_at"])
+ .to be >= snippet.hook_attrs["updated_at"]
end
- include_examples 'project hook data'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data"
+ include_examples "deprecated repository hook data"
end
end
diff --git a/spec/lib/gitlab/data_builder/pipeline_spec.rb b/spec/lib/gitlab/data_builder/pipeline_spec.rb
index 9ef987a0826..95bbceab9f1 100644
--- a/spec/lib/gitlab/data_builder/pipeline_spec.rb
+++ b/spec/lib/gitlab/data_builder/pipeline_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DataBuilder::Pipeline do
let(:user) { create(:user) }
@@ -6,49 +6,49 @@ describe Gitlab::DataBuilder::Pipeline do
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- status: 'success',
- sha: project.commit.sha,
- ref: project.default_branch)
+ project: project,
+ status: "success",
+ sha: project.commit.sha,
+ ref: project.default_branch)
end
let!(:build) { create(:ci_build, pipeline: pipeline) }
- describe '.build' do
+ describe ".build" do
let(:data) { described_class.build(pipeline) }
let(:attributes) { data[:object_attributes] }
let(:build_data) { data[:builds].first }
let(:project_data) { data[:project] }
- it 'has correct attributes' do
+ it "has correct attributes" do
expect(attributes).to be_a(Hash)
expect(attributes[:ref]).to eq(pipeline.ref)
expect(attributes[:sha]).to eq(pipeline.sha)
expect(attributes[:tag]).to eq(pipeline.tag)
expect(attributes[:id]).to eq(pipeline.id)
expect(attributes[:status]).to eq(pipeline.status)
- expect(attributes[:detailed_status]).to eq('passed')
+ expect(attributes[:detailed_status]).to eq("passed")
expect(build_data).to be_a(Hash)
expect(build_data[:id]).to eq(build.id)
expect(build_data[:status]).to eq(build.status)
expect(project_data).to eq(project.hook_attrs(backward: false))
end
- context 'pipeline without variables' do
- it 'has empty variables hash' do
+ context "pipeline without variables" do
+ it "has empty variables hash" do
expect(attributes[:variables]).to be_a(Array)
expect(attributes[:variables]).to be_empty
end
end
- context 'pipeline with variables' do
+ context "pipeline with variables" do
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:data) { described_class.build(pipeline) }
let(:attributes) { data[:object_attributes] }
- let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline, key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1') }
+ let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline, key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1") }
it { expect(attributes[:variables]).to be_a(Array) }
- it { expect(attributes[:variables]).to contain_exactly({ key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1' }) }
+ it { expect(attributes[:variables]).to contain_exactly({key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1"}) }
end
end
end
diff --git a/spec/lib/gitlab/data_builder/push_spec.rb b/spec/lib/gitlab/data_builder/push_spec.rb
index 0c4decc6518..1c457d066d7 100644
--- a/spec/lib/gitlab/data_builder/push_spec.rb
+++ b/spec/lib/gitlab/data_builder/push_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DataBuilder::Push do
let(:project) { create(:project, :repository) }
- let(:user) { build(:user, public_email: 'public-email@example.com') }
+ let(:user) { build(:user, public_email: "public-email@example.com") }
- describe '.build_sample' do
+ describe ".build_sample" do
let(:data) { described_class.build_sample(project, user) }
it { expect(data).to be_a(Hash) }
- it { expect(data[:before]).to eq('1b12f15a11fc6e62177bef08f47bc7b5ce50b141') }
- it { expect(data[:after]).to eq('b83d6e391c22777fca1ed3012fce84f633d7fed0') }
- it { expect(data[:ref]).to eq('refs/heads/master') }
+ it { expect(data[:before]).to eq("1b12f15a11fc6e62177bef08f47bc7b5ce50b141") }
+ it { expect(data[:after]).to eq("b83d6e391c22777fca1ed3012fce84f633d7fed0") }
+ it { expect(data[:ref]).to eq("refs/heads/master") }
it { expect(data[:commits].size).to eq(3) }
it { expect(data[:total_commits_count]).to eq(3) }
- it { expect(data[:commits].first[:added]).to eq(['bar/branch-test.txt']) }
+ it { expect(data[:commits].first[:added]).to eq(["bar/branch-test.txt"]) }
it { expect(data[:commits].first[:modified]).to eq([]) }
it { expect(data[:commits].first[:removed]).to eq([]) }
- include_examples 'project hook data with deprecateds'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data with deprecateds"
+ include_examples "deprecated repository hook data"
end
- describe '.build' do
+ describe ".build" do
let(:data) do
described_class.build(project, user, Gitlab::Git::BLANK_SHA,
- '8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b',
- 'refs/tags/v1.1.0')
+ "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b",
+ "refs/tags/v1.1.0")
end
it { expect(data).to be_a(Hash) }
it { expect(data[:before]).to eq(Gitlab::Git::BLANK_SHA) }
- it { expect(data[:checkout_sha]).to eq('5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
- it { expect(data[:after]).to eq('8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b') }
- it { expect(data[:ref]).to eq('refs/tags/v1.1.0') }
+ it { expect(data[:checkout_sha]).to eq("5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
+ it { expect(data[:after]).to eq("8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b") }
+ it { expect(data[:ref]).to eq("refs/tags/v1.1.0") }
it { expect(data[:user_id]).to eq(user.id) }
it { expect(data[:user_name]).to eq(user.name) }
it { expect(data[:user_username]).to eq(user.username) }
@@ -43,11 +43,11 @@ describe Gitlab::DataBuilder::Push do
it { expect(data[:commits]).to be_empty }
it { expect(data[:total_commits_count]).to be_zero }
- include_examples 'project hook data with deprecateds'
- include_examples 'deprecated repository hook data'
+ include_examples "project hook data with deprecateds"
+ include_examples "deprecated repository hook data"
- it 'does not raise an error when given nil commits' do
- expect { described_class.build(spy, spy, spy, spy, 'refs/tags/v1.1.0', nil) }
+ it "does not raise an error when given nil commits" do
+ expect { described_class.build(spy, spy, spy, spy, "refs/tags/v1.1.0", nil) }
.not_to raise_error
end
end
diff --git a/spec/lib/gitlab/data_builder/wiki_page_spec.rb b/spec/lib/gitlab/data_builder/wiki_page_spec.rb
index 9c8bdf4b032..17f828bd2e2 100644
--- a/spec/lib/gitlab/data_builder/wiki_page_spec.rb
+++ b/spec/lib/gitlab/data_builder/wiki_page_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DataBuilder::WikiPage do
set(:project) { create(:project, :repository, :wiki_repo) }
let(:wiki_page) { create(:wiki_page, wiki: project.wiki) }
let(:user) { create(:user) }
- describe '.build' do
- let(:data) { described_class.build(wiki_page, user, 'create') }
+ describe ".build" do
+ let(:data) { described_class.build(wiki_page, user, "create") }
it { expect(data).to be_a(Hash) }
- it { expect(data[:object_kind]).to eq('wiki_page') }
+ it { expect(data[:object_kind]).to eq("wiki_page") }
it { expect(data[:user]).to eq(user.hook_attrs) }
it { expect(data[:project]).to eq(project.hook_attrs) }
it { expect(data[:wiki]).to eq(project.wiki.hook_attrs) }
it { expect(data[:object_attributes]).to include(wiki_page.hook_attrs) }
it { expect(data[:object_attributes]).to include(url: Gitlab::UrlBuilder.build(wiki_page)) }
- it { expect(data[:object_attributes]).to include(action: 'create') }
+ it { expect(data[:object_attributes]).to include(action: "create") }
end
end
diff --git a/spec/lib/gitlab/database/count/exact_count_strategy_spec.rb b/spec/lib/gitlab/database/count/exact_count_strategy_spec.rb
index 3991c737a26..eb8a968d76e 100644
--- a/spec/lib/gitlab/database/count/exact_count_strategy_spec.rb
+++ b/spec/lib/gitlab/database/count/exact_count_strategy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Count::ExactCountStrategy do
before do
@@ -10,28 +10,28 @@ describe Gitlab::Database::Count::ExactCountStrategy do
subject { described_class.new(models).count }
- describe '#count' do
- it 'counts all models' do
+ describe "#count" do
+ it "counts all models" do
expect(models).to all(receive(:count).and_call_original)
- expect(subject).to eq({ Project => 3, Identity => 1 })
+ expect(subject).to eq({Project => 3, Identity => 1})
end
- it 'returns default value if count times out' do
- allow(models.first).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(''))
+ it "returns default value if count times out" do
+ allow(models.first).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(""))
expect(subject).to eq({})
end
end
- describe '.enabled?' do
- it 'is enabled for PostgreSQL' do
+ describe ".enabled?" do
+ it "is enabled for PostgreSQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(described_class.enabled?).to be_truthy
end
- it 'is enabled for MySQL' do
+ it "is enabled for MySQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(described_class.enabled?).to be_truthy
diff --git a/spec/lib/gitlab/database/count/reltuples_count_strategy_spec.rb b/spec/lib/gitlab/database/count/reltuples_count_strategy_spec.rb
index b44e8c5a110..1d0c37c0622 100644
--- a/spec/lib/gitlab/database/count/reltuples_count_strategy_spec.rb
+++ b/spec/lib/gitlab/database/count/reltuples_count_strategy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Count::ReltuplesCountStrategy do
before do
@@ -9,22 +9,22 @@ describe Gitlab::Database::Count::ReltuplesCountStrategy do
let(:models) { [Project, Identity] }
subject { described_class.new(models).count }
- describe '#count', :postgresql do
- context 'when reltuples is up to date' do
+ describe "#count", :postgresql do
+ context "when reltuples is up to date" do
before do
- ActiveRecord::Base.connection.execute('ANALYZE projects')
- ActiveRecord::Base.connection.execute('ANALYZE identities')
+ ActiveRecord::Base.connection.execute("ANALYZE projects")
+ ActiveRecord::Base.connection.execute("ANALYZE identities")
end
- it 'uses statistics to do the count' do
+ it "uses statistics to do the count" do
models.each { |model| expect(model).not_to receive(:count) }
- expect(subject).to eq({ Project => 3, Identity => 1 })
+ expect(subject).to eq({Project => 3, Identity => 1})
end
end
- context 'insufficient permissions' do
- it 'returns an empty hash' do
+ context "insufficient permissions" do
+ it "returns an empty hash" do
allow(ActiveRecord::Base).to receive(:transaction).and_raise(PG::InsufficientPrivilege)
expect(subject).to eq({})
@@ -32,14 +32,14 @@ describe Gitlab::Database::Count::ReltuplesCountStrategy do
end
end
- describe '.enabled?' do
- it 'is enabled for PostgreSQL' do
+ describe ".enabled?" do
+ it "is enabled for PostgreSQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(described_class.enabled?).to be_truthy
end
- it 'is disabled for MySQL' do
+ it "is disabled for MySQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(described_class.enabled?).to be_falsey
diff --git a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb
index 203f9344a41..7a237ba9840 100644
--- a/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb
+++ b/spec/lib/gitlab/database/count/tablesample_count_strategy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Count::TablesampleCountStrategy do
before do
@@ -11,24 +11,24 @@ describe Gitlab::Database::Count::TablesampleCountStrategy do
subject { strategy.count }
- describe '#count', :postgresql do
- let(:estimates) { { Project => threshold + 1, Identity => threshold - 1 } }
+ describe "#count", :postgresql do
+ let(:estimates) { {Project => threshold + 1, Identity => threshold - 1} }
let(:threshold) { Gitlab::Database::Count::TablesampleCountStrategy::EXACT_COUNT_THRESHOLD }
before do
allow(strategy).to receive(:size_estimates).with(check_statistics: false).and_return(estimates)
end
- context 'for tables with an estimated small size' do
- it 'performs an exact count' do
+ context "for tables with an estimated small size" do
+ it "performs an exact count" do
expect(Identity).to receive(:count).and_call_original
- expect(subject).to include({ Identity => 1 })
+ expect(subject).to include({Identity => 1})
end
end
- context 'for tables with an estimated large size' do
- it 'performs a tablesample count' do
+ context "for tables with an estimated large size" do
+ it "performs a tablesample count" do
expect(Project).not_to receive(:count)
result = subject
@@ -36,8 +36,8 @@ describe Gitlab::Database::Count::TablesampleCountStrategy do
end
end
- context 'insufficient permissions' do
- it 'returns an empty hash' do
+ context "insufficient permissions" do
+ it "returns an empty hash" do
allow(strategy).to receive(:size_estimates).and_raise(PG::InsufficientPrivilege)
expect(subject).to eq({})
@@ -45,18 +45,18 @@ describe Gitlab::Database::Count::TablesampleCountStrategy do
end
end
- describe '.enabled?' do
+ describe ".enabled?" do
before do
stub_feature_flags(tablesample_counts: true)
end
- it 'is enabled for PostgreSQL' do
+ it "is enabled for PostgreSQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(described_class.enabled?).to be_truthy
end
- it 'is disabled for MySQL' do
+ it "is disabled for MySQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(described_class.enabled?).to be_falsey
diff --git a/spec/lib/gitlab/database/count_spec.rb b/spec/lib/gitlab/database/count_spec.rb
index 1d096b8fa7c..0c6ee02c391 100644
--- a/spec/lib/gitlab/database/count_spec.rb
+++ b/spec/lib/gitlab/database/count_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Count do
before do
@@ -8,48 +8,48 @@ describe Gitlab::Database::Count do
let(:models) { [Project, Identity] }
- context '.approximate_counts' do
- context 'selecting strategies' do
- let(:strategies) { [double('s1', enabled?: true), double('s2', enabled?: false)] }
+ context ".approximate_counts" do
+ context "selecting strategies" do
+ let(:strategies) { [double("s1", enabled?: true), double("s2", enabled?: false)] }
- it 'uses only enabled strategies' do
- expect(strategies[0]).to receive(:new).and_return(double('strategy1', count: {}))
+ it "uses only enabled strategies" do
+ expect(strategies[0]).to receive(:new).and_return(double("strategy1", count: {}))
expect(strategies[1]).not_to receive(:new)
described_class.approximate_counts(models, strategies: strategies)
end
end
- context 'fallbacks' do
+ context "fallbacks" do
subject { described_class.approximate_counts(models, strategies: strategies) }
let(:strategies) do
[
- double('s1', enabled?: true, new: first_strategy),
- double('s2', enabled?: true, new: second_strategy)
+ double("s1", enabled?: true, new: first_strategy),
+ double("s2", enabled?: true, new: second_strategy),
]
end
- let(:first_strategy) { double('first strategy', count: {}) }
- let(:second_strategy) { double('second strategy', count: {}) }
+ let(:first_strategy) { double("first strategy", count: {}) }
+ let(:second_strategy) { double("second strategy", count: {}) }
- it 'gets results from first strategy' do
+ it "gets results from first strategy" do
expect(strategies[0]).to receive(:new).with(models).and_return(first_strategy)
expect(first_strategy).to receive(:count)
subject
end
- it 'gets more results from second strategy if some counts are missing' do
- expect(first_strategy).to receive(:count).and_return({ Project => 3 })
+ it "gets more results from second strategy if some counts are missing" do
+ expect(first_strategy).to receive(:count).and_return({Project => 3})
expect(strategies[1]).to receive(:new).with([Identity]).and_return(second_strategy)
- expect(second_strategy).to receive(:count).and_return({ Identity => 1 })
+ expect(second_strategy).to receive(:count).and_return({Identity => 1})
- expect(subject).to eq({ Project => 3, Identity => 1 })
+ expect(subject).to eq({Project => 3, Identity => 1})
end
- it 'does not get more results as soon as all counts are present' do
- expect(first_strategy).to receive(:count).and_return({ Project => 3, Identity => 1 })
+ it "does not get more results as soon as all counts are present" do
+ expect(first_strategy).to receive(:count).and_return({Project => 3, Identity => 1})
expect(strategies[1]).not_to receive(:new)
subject
diff --git a/spec/lib/gitlab/database/grant_spec.rb b/spec/lib/gitlab/database/grant_spec.rb
index 5ebf3f399b6..3f0d78da56c 100644
--- a/spec/lib/gitlab/database/grant_spec.rb
+++ b/spec/lib/gitlab/database/grant_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Grant do
- describe '.create_and_execute_trigger' do
- it 'returns true when the user can create and execute a trigger' do
+ describe ".create_and_execute_trigger" do
+ it "returns true when the user can create and execute a trigger" do
# We assume the DB/user is set up correctly so that triggers can be
# created, which is necessary anyway for other tests to work.
- expect(described_class.create_and_execute_trigger?('users')).to eq(true)
+ expect(described_class.create_and_execute_trigger?("users")).to eq(true)
end
- it 'returns false when the user can not create and/or execute a trigger', :postgresql do
+ it "returns false when the user can not create and/or execute a trigger", :postgresql do
# In case of MySQL the user may have SUPER permissions, making it
# impossible to have `false` returned when running tests; hence we only
# run these tests on PostgreSQL.
- expect(described_class.create_and_execute_trigger?('foo')).to eq(false)
+ expect(described_class.create_and_execute_trigger?("foo")).to eq(false)
end
end
end
diff --git a/spec/lib/gitlab/database/median_spec.rb b/spec/lib/gitlab/database/median_spec.rb
index 1b5e30089ce..29f21164353 100644
--- a/spec/lib/gitlab/database/median_spec.rb
+++ b/spec/lib/gitlab/database/median_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::Median do
let(:dummy_class) do
@@ -9,8 +9,8 @@ describe Gitlab::Database::Median do
subject(:median) { dummy_class.new }
- describe '#median_datetimes' do
- it 'raises NotSupportedError', :mysql do
+ describe "#median_datetimes" do
+ it "raises NotSupportedError", :mysql do
expect { median.median_datetimes(nil, nil, nil, :project_id) }.to raise_error(dummy_class::NotSupportedError, "partition_column is not supported for MySQL")
end
end
diff --git a/spec/lib/gitlab/database/migration_helpers_spec.rb b/spec/lib/gitlab/database/migration_helpers_spec.rb
index 4e83b27e4a5..0f97579be09 100644
--- a/spec/lib/gitlab/database/migration_helpers_spec.rb
+++ b/spec/lib/gitlab/database/migration_helpers_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::MigrationHelpers do
let(:model) do
@@ -9,89 +9,89 @@ describe Gitlab::Database::MigrationHelpers do
allow(model).to receive(:puts)
end
- describe '#add_timestamps_with_timezone' do
+ describe "#add_timestamps_with_timezone" do
before do
allow(model).to receive(:transaction_open?).and_return(false)
end
- context 'using PostgreSQL' do
+ context "using PostgreSQL" do
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
allow(model).to receive(:disable_statement_timeout)
end
it 'adds "created_at" and "updated_at" fields with the "datetime_with_timezone" data type' do
- expect(model).to receive(:add_column).with(:foo, :created_at, :datetime_with_timezone, { null: false })
- expect(model).to receive(:add_column).with(:foo, :updated_at, :datetime_with_timezone, { null: false })
+ expect(model).to receive(:add_column).with(:foo, :created_at, :datetime_with_timezone, {null: false})
+ expect(model).to receive(:add_column).with(:foo, :updated_at, :datetime_with_timezone, {null: false})
model.add_timestamps_with_timezone(:foo)
end
end
- context 'using MySQL' do
+ context "using MySQL" do
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
it 'adds "created_at" and "updated_at" fields with "datetime_with_timezone" data type' do
- expect(model).to receive(:add_column).with(:foo, :created_at, :datetime_with_timezone, { null: false })
- expect(model).to receive(:add_column).with(:foo, :updated_at, :datetime_with_timezone, { null: false })
+ expect(model).to receive(:add_column).with(:foo, :created_at, :datetime_with_timezone, {null: false})
+ expect(model).to receive(:add_column).with(:foo, :updated_at, :datetime_with_timezone, {null: false})
model.add_timestamps_with_timezone(:foo)
end
end
end
- describe '#add_concurrent_index' do
- context 'outside a transaction' do
+ describe "#add_concurrent_index" do
+ context "outside a transaction" do
before do
allow(model).to receive(:transaction_open?).and_return(false)
end
- context 'using PostgreSQL', :postgresql do
+ context "using PostgreSQL", :postgresql do
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
allow(model).to receive(:disable_statement_timeout).and_call_original
end
- it 'creates the index concurrently' do
+ it "creates the index concurrently" do
expect(model).to receive(:add_index)
.with(:users, :foo, algorithm: :concurrently)
model.add_concurrent_index(:users, :foo)
end
- it 'creates unique index concurrently' do
+ it "creates unique index concurrently" do
expect(model).to receive(:add_index)
- .with(:users, :foo, { algorithm: :concurrently, unique: true })
+ .with(:users, :foo, {algorithm: :concurrently, unique: true})
model.add_concurrent_index(:users, :foo, unique: true)
end
- it 'does nothing if the index exists already' do
+ it "does nothing if the index exists already" do
expect(model).to receive(:index_exists?)
- .with(:users, :foo, { algorithm: :concurrently, unique: true }).and_return(true)
+ .with(:users, :foo, {algorithm: :concurrently, unique: true}).and_return(true)
expect(model).not_to receive(:add_index)
model.add_concurrent_index(:users, :foo, unique: true)
end
end
- context 'using MySQL' do
+ context "using MySQL" do
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
- it 'creates a regular index' do
+ it "creates a regular index" do
expect(model).to receive(:add_index)
.with(:users, :foo, {})
model.add_concurrent_index(:users, :foo)
end
- it 'does nothing if the index exists already' do
+ it "does nothing if the index exists already" do
expect(model).to receive(:index_exists?)
- .with(:users, :foo, { unique: true }).and_return(true)
+ .with(:users, :foo, {unique: true}).and_return(true)
expect(model).not_to receive(:add_index)
model.add_concurrent_index(:users, :foo, unique: true)
@@ -99,8 +99,8 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'inside a transaction' do
- it 'raises RuntimeError' do
+ context "inside a transaction" do
+ it "raises RuntimeError" do
expect(model).to receive(:transaction_open?).and_return(true)
expect { model.add_concurrent_index(:users, :foo) }
@@ -109,49 +109,49 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#remove_concurrent_index' do
- context 'outside a transaction' do
+ describe "#remove_concurrent_index" do
+ context "outside a transaction" do
before do
allow(model).to receive(:transaction_open?).and_return(false)
allow(model).to receive(:index_exists?).and_return(true)
allow(model).to receive(:disable_statement_timeout).and_call_original
end
- context 'using PostgreSQL' do
+ context "using PostgreSQL" do
before do
allow(model).to receive(:supports_drop_index_concurrently?).and_return(true)
end
- describe 'by column name' do
- it 'removes the index concurrently' do
+ describe "by column name" do
+ it "removes the index concurrently" do
expect(model).to receive(:remove_index)
- .with(:users, { algorithm: :concurrently, column: :foo })
+ .with(:users, {algorithm: :concurrently, column: :foo})
model.remove_concurrent_index(:users, :foo)
end
- it 'does nothing if the index does not exist' do
+ it "does nothing if the index does not exist" do
expect(model).to receive(:index_exists?)
- .with(:users, :foo, { algorithm: :concurrently, unique: true }).and_return(false)
+ .with(:users, :foo, {algorithm: :concurrently, unique: true}).and_return(false)
expect(model).not_to receive(:remove_index)
model.remove_concurrent_index(:users, :foo, unique: true)
end
end
- describe 'by index name' do
+ describe "by index name" do
before do
allow(model).to receive(:index_exists_by_name?).with(:users, "index_x_by_y").and_return(true)
end
- it 'removes the index concurrently by index name' do
+ it "removes the index concurrently by index name" do
expect(model).to receive(:remove_index)
- .with(:users, { algorithm: :concurrently, name: "index_x_by_y" })
+ .with(:users, {algorithm: :concurrently, name: "index_x_by_y"})
model.remove_concurrent_index_by_name(:users, "index_x_by_y")
end
- it 'does nothing if the index does not exist' do
+ it "does nothing if the index does not exist" do
expect(model).to receive(:index_exists_by_name?).with(:users, "index_x_by_y").and_return(false)
expect(model).not_to receive(:remove_index)
@@ -160,20 +160,20 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'using MySQL' do
- it 'removes an index' do
+ context "using MySQL" do
+ it "removes an index" do
expect(Gitlab::Database).to receive(:postgresql?).and_return(false).twice
expect(model).to receive(:remove_index)
- .with(:users, { column: :foo })
+ .with(:users, {column: :foo})
model.remove_concurrent_index(:users, :foo)
end
end
end
- context 'inside a transaction' do
- it 'raises RuntimeError' do
+ context "inside a transaction" do
+ it "raises RuntimeError" do
expect(model).to receive(:transaction_open?).and_return(true)
expect { model.remove_concurrent_index(:users, :foo) }
@@ -182,39 +182,39 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#add_concurrent_foreign_key' do
+ describe "#add_concurrent_foreign_key" do
before do
allow(model).to receive(:foreign_key_exists?).and_return(false)
end
- context 'inside a transaction' do
- it 'raises an error' do
+ context "inside a transaction" do
+ it "raises an error" do
expect(model).to receive(:transaction_open?).and_return(true)
- expect do
+ expect {
model.add_concurrent_foreign_key(:projects, :users, column: :user_id)
- end.to raise_error(RuntimeError)
+ }.to raise_error(RuntimeError)
end
end
- context 'outside a transaction' do
+ context "outside a transaction" do
before do
allow(model).to receive(:transaction_open?).and_return(false)
end
- context 'using MySQL' do
+ context "using MySQL" do
before do
allow(Gitlab::Database).to receive(:mysql?).and_return(true)
end
- it 'creates a regular foreign key' do
+ it "creates a regular foreign key" do
expect(model).to receive(:add_foreign_key)
.with(:projects, :users, column: :user_id, on_delete: :cascade)
model.add_concurrent_foreign_key(:projects, :users, column: :user_id)
end
- it 'does not create a foreign key if it exists already' do
+ it "does not create a foreign key if it exists already" do
expect(model).to receive(:foreign_key_exists?).with(:projects, :users, column: :user_id).and_return(true)
expect(model).not_to receive(:add_foreign_key)
@@ -222,13 +222,13 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'using PostgreSQL' do
+ context "using PostgreSQL" do
before do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
allow(Gitlab::Database).to receive(:mysql?).and_return(false)
end
- it 'creates a concurrent foreign key and validates it' do
+ it "creates a concurrent foreign key and validates it" do
expect(model).to receive(:disable_statement_timeout).and_call_original
expect(model).to receive(:execute).with(/statement_timeout/)
expect(model).to receive(:execute).ordered.with(/NOT VALID/)
@@ -238,7 +238,7 @@ describe Gitlab::Database::MigrationHelpers do
model.add_concurrent_foreign_key(:projects, :users, column: :user_id)
end
- it 'appends a valid ON DELETE statement' do
+ it "appends a valid ON DELETE statement" do
expect(model).to receive(:disable_statement_timeout).and_call_original
expect(model).to receive(:execute).with(/statement_timeout/)
expect(model).to receive(:execute).with(/ON DELETE SET NULL/)
@@ -246,11 +246,11 @@ describe Gitlab::Database::MigrationHelpers do
expect(model).to receive(:execute).with(/RESET ALL/)
model.add_concurrent_foreign_key(:projects, :users,
- column: :user_id,
- on_delete: :nullify)
+ column: :user_id,
+ on_delete: :nullify)
end
- it 'does not create a foreign key if it exists already' do
+ it "does not create a foreign key if it exists already" do
expect(model).to receive(:foreign_key_exists?).with(:projects, :users, column: :user_id).and_return(true)
expect(model).not_to receive(:execute).with(/ADD CONSTRAINT/)
expect(model).to receive(:execute).with(/VALIDATE CONSTRAINT/)
@@ -261,107 +261,107 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#concurrent_foreign_key_name' do
- it 'returns the name for a foreign key' do
+ describe "#concurrent_foreign_key_name" do
+ it "returns the name for a foreign key" do
name = model.concurrent_foreign_key_name(:this_is_a_very_long_table_name,
- :with_a_very_long_column_name)
+ :with_a_very_long_column_name)
expect(name).to be_an_instance_of(String)
expect(name.length).to eq(13)
end
end
- describe '#foreign_key_exists?' do
+ describe "#foreign_key_exists?" do
before do
- key = ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(:projects, :users, { column: :non_standard_id })
+ key = ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(:projects, :users, {column: :non_standard_id})
allow(model).to receive(:foreign_keys).with(:projects).and_return([key])
end
- it 'finds existing foreign keys by column' do
+ it "finds existing foreign keys by column" do
expect(model.foreign_key_exists?(:projects, :users, column: :non_standard_id)).to be_truthy
end
- it 'finds existing foreign keys by target table only' do
+ it "finds existing foreign keys by target table only" do
expect(model.foreign_key_exists?(:projects, :users)).to be_truthy
end
- it 'compares by column name if given' do
+ it "compares by column name if given" do
expect(model.foreign_key_exists?(:projects, :users, column: :user_id)).to be_falsey
end
- it 'compares by target if no column given' do
+ it "compares by target if no column given" do
expect(model.foreign_key_exists?(:projects, :other_table)).to be_falsey
end
end
- describe '#disable_statement_timeout' do
- context 'using PostgreSQL' do
- it 'disables statement timeouts to current transaction only' do
+ describe "#disable_statement_timeout" do
+ context "using PostgreSQL" do
+ it "disables statement timeouts to current transaction only" do
expect(Gitlab::Database).to receive(:postgresql?).and_return(true)
- expect(model).to receive(:execute).with('SET LOCAL statement_timeout TO 0')
+ expect(model).to receive(:execute).with("SET LOCAL statement_timeout TO 0")
model.disable_statement_timeout
end
# this specs runs without an enclosing transaction (:delete truncation method for db_cleaner)
- context 'with real environment', :postgresql, :delete do
+ context "with real environment", :postgresql, :delete do
before do
model.execute("SET statement_timeout TO '20000'")
end
after do
- model.execute('RESET ALL')
+ model.execute("RESET ALL")
end
- it 'defines statement to 0 only for current transaction' do
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('20s')
+ it "defines statement to 0 only for current transaction" do
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("20s")
model.connection.transaction do
model.disable_statement_timeout
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('0')
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("0")
end
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('20s')
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("20s")
end
end
- context 'when passing a blocks' do
- it 'disables statement timeouts on session level and executes the block' do
+ context "when passing a blocks" do
+ it "disables statement timeouts on session level and executes the block" do
expect(Gitlab::Database).to receive(:postgresql?).and_return(true)
- expect(model).to receive(:execute).with('SET statement_timeout TO 0')
- expect(model).to receive(:execute).with('RESET ALL')
+ expect(model).to receive(:execute).with("SET statement_timeout TO 0")
+ expect(model).to receive(:execute).with("RESET ALL")
expect { |block| model.disable_statement_timeout(&block) }.to yield_control
end
# this specs runs without an enclosing transaction (:delete truncation method for db_cleaner)
- context 'with real environment', :postgresql, :delete do
+ context "with real environment", :postgresql, :delete do
before do
model.execute("SET statement_timeout TO '20000'")
end
after do
- model.execute('RESET ALL')
+ model.execute("RESET ALL")
end
- it 'defines statement to 0 for any code run inside the block' do
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('20s')
+ it "defines statement to 0 for any code run inside the block" do
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("20s")
model.disable_statement_timeout do
model.connection.transaction do
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('0')
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("0")
end
- expect(model.execute('SHOW statement_timeout').first['statement_timeout']).to eq('0')
+ expect(model.execute("SHOW statement_timeout").first["statement_timeout"]).to eq("0")
end
end
end
end
end
- context 'using MySQL' do
- it 'does nothing' do
+ context "using MySQL" do
+ it "does nothing" do
expect(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(model).not_to receive(:execute)
@@ -369,8 +369,8 @@ describe Gitlab::Database::MigrationHelpers do
model.disable_statement_timeout
end
- context 'when passing a blocks' do
- it 'executes the block of code' do
+ context "when passing a blocks" do
+ it "executes the block of code" do
expect(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(model).not_to receive(:execute)
@@ -381,72 +381,72 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#true_value' do
- context 'using PostgreSQL' do
+ describe "#true_value" do
+ context "using PostgreSQL" do
before do
expect(Gitlab::Database).to receive(:postgresql?).and_return(true)
end
- it 'returns the appropriate value' do
+ it "returns the appropriate value" do
expect(model.true_value).to eq("'t'")
end
end
- context 'using MySQL' do
+ context "using MySQL" do
before do
expect(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
- it 'returns the appropriate value' do
+ it "returns the appropriate value" do
expect(model.true_value).to eq(1)
end
end
end
- describe '#false_value' do
- context 'using PostgreSQL' do
+ describe "#false_value" do
+ context "using PostgreSQL" do
before do
expect(Gitlab::Database).to receive(:postgresql?).and_return(true)
end
- it 'returns the appropriate value' do
+ it "returns the appropriate value" do
expect(model.false_value).to eq("'f'")
end
end
- context 'using MySQL' do
+ context "using MySQL" do
before do
expect(Gitlab::Database).to receive(:postgresql?).and_return(false)
end
- it 'returns the appropriate value' do
+ it "returns the appropriate value" do
expect(model.false_value).to eq(0)
end
end
end
- describe '#update_column_in_batches' do
- context 'when running outside of a transaction' do
+ describe "#update_column_in_batches" do
+ context "when running outside of a transaction" do
before do
expect(model).to receive(:transaction_open?).and_return(false)
create_list(:project, 5)
end
- it 'updates all the rows in a table' do
- model.update_column_in_batches(:projects, :import_error, 'foo')
+ it "updates all the rows in a table" do
+ model.update_column_in_batches(:projects, :import_error, "foo")
- expect(Project.where(import_error: 'foo').count).to eq(5)
+ expect(Project.where(import_error: "foo").count).to eq(5)
end
- it 'updates boolean values correctly' do
+ it "updates boolean values correctly" do
model.update_column_in_batches(:projects, :archived, true)
expect(Project.where(archived: true).count).to eq(5)
end
- context 'when a block is supplied' do
- it 'yields an Arel table and query object to the supplied block' do
+ context "when a block is supplied" do
+ it "yields an Arel table and query object to the supplied block" do
first_id = Project.first.id
model.update_column_in_batches(:projects, :archived, true) do |t, query|
@@ -457,29 +457,29 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'when the value is Arel.sql (Arel::Nodes::SqlLiteral)' do
- it 'updates the value as a SQL expression' do
- model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1'))
+ context "when the value is Arel.sql (Arel::Nodes::SqlLiteral)" do
+ it "updates the value as a SQL expression" do
+ model.update_column_in_batches(:projects, :star_count, Arel.sql("1+1"))
expect(Project.sum(:star_count)).to eq(2 * Project.count)
end
end
end
- context 'when running inside the transaction' do
- it 'raises RuntimeError' do
+ context "when running inside the transaction" do
+ it "raises RuntimeError" do
expect(model).to receive(:transaction_open?).and_return(true)
- expect do
- model.update_column_in_batches(:projects, :star_count, Arel.sql('1+1'))
- end.to raise_error(RuntimeError)
+ expect {
+ model.update_column_in_batches(:projects, :star_count, Arel.sql("1+1"))
+ }.to raise_error(RuntimeError)
end
end
end
- describe '#add_column_with_default' do
- context 'outside of a transaction' do
- context 'when a column limit is not set' do
+ describe "#add_column_with_default" do
+ context "outside of a transaction" do
+ context "when a column limit is not set" do
before do
expect(model).to receive(:transaction_open?)
.and_return(false)
@@ -494,18 +494,18 @@ describe Gitlab::Database::MigrationHelpers do
.with(:projects, :foo, 10)
end
- it 'adds the column while allowing NULL values' do
+ it "adds the column while allowing NULL values" do
expect(model).to receive(:update_column_in_batches)
.with(:projects, :foo, 10)
expect(model).not_to receive(:change_column_null)
model.add_column_with_default(:projects, :foo, :integer,
- default: 10,
- allow_null: true)
+ default: 10,
+ allow_null: true)
end
- it 'adds the column while not allowing NULL values' do
+ it "adds the column while not allowing NULL values" do
expect(model).to receive(:update_column_in_batches)
.with(:projects, :foo, 10)
@@ -515,7 +515,7 @@ describe Gitlab::Database::MigrationHelpers do
model.add_column_with_default(:projects, :foo, :integer, default: 10)
end
- it 'removes the added column whenever updating the rows fails' do
+ it "removes the added column whenever updating the rows fails" do
expect(model).to receive(:update_column_in_batches)
.with(:projects, :foo, 10)
.and_raise(RuntimeError)
@@ -523,12 +523,12 @@ describe Gitlab::Database::MigrationHelpers do
expect(model).to receive(:remove_column)
.with(:projects, :foo)
- expect do
+ expect {
model.add_column_with_default(:projects, :foo, :integer, default: 10)
- end.to raise_error(RuntimeError)
+ }.to raise_error(RuntimeError)
end
- it 'removes the added column whenever changing a column NULL constraint fails' do
+ it "removes the added column whenever changing a column NULL constraint fails" do
expect(model).to receive(:change_column_null)
.with(:projects, :foo, false)
.and_raise(RuntimeError)
@@ -536,14 +536,14 @@ describe Gitlab::Database::MigrationHelpers do
expect(model).to receive(:remove_column)
.with(:projects, :foo)
- expect do
+ expect {
model.add_column_with_default(:projects, :foo, :integer, default: 10)
- end.to raise_error(RuntimeError)
+ }.to raise_error(RuntimeError)
end
end
- context 'when a column limit is set' do
- it 'adds the column with a limit' do
+ context "when a column limit is set" do
+ it "adds the column with a limit" do
allow(model).to receive(:transaction_open?).and_return(false)
allow(model).to receive(:transaction).and_yield
allow(model).to receive(:update_column_in_batches).with(:projects, :foo, 10)
@@ -558,20 +558,20 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'inside a transaction' do
- it 'raises RuntimeError' do
+ context "inside a transaction" do
+ it "raises RuntimeError" do
expect(model).to receive(:transaction_open?).and_return(true)
- expect do
+ expect {
model.add_column_with_default(:projects, :foo, :integer, default: 10)
- end.to raise_error(RuntimeError)
+ }.to raise_error(RuntimeError)
end
end
end
- describe '#rename_column_concurrently' do
- context 'in a transaction' do
- it 'raises RuntimeError' do
+ describe "#rename_column_concurrently" do
+ context "in a transaction" do
+ it "raises RuntimeError" do
allow(model).to receive(:transaction_open?).and_return(true)
expect { model.rename_column_concurrently(:users, :old, :new) }
@@ -579,15 +579,15 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'outside a transaction' do
+ context "outside a transaction" do
let(:old_column) do
double(:column,
- type: :integer,
- limit: 8,
- default: 0,
- null: false,
- precision: 5,
- scale: 1)
+ type: :integer,
+ limit: 8,
+ default: 0,
+ null: false,
+ precision: 5,
+ scale: 1)
end
let(:trigger_name) { model.rename_trigger_name(:users, :old, :new) }
@@ -602,20 +602,20 @@ describe Gitlab::Database::MigrationHelpers do
allow(model).to receive(:quote_table_name) { |name| name.to_s }
end
- context 'using MySQL' do
- it 'renames a column concurrently' do
+ context "using MySQL" do
+ it "renames a column concurrently" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(model).to receive(:check_trigger_permissions!).with(:users)
expect(model).to receive(:install_rename_triggers_for_mysql)
- .with(trigger_name, 'users', 'old', 'new')
+ .with(trigger_name, "users", "old", "new")
expect(model).to receive(:add_column)
.with(:users, :new, :integer,
- limit: old_column.limit,
- precision: old_column.precision,
- scale: old_column.scale)
+ limit: old_column.limit,
+ precision: old_column.precision,
+ scale: old_column.scale)
expect(model).to receive(:change_column_default)
.with(:users, :new, old_column.default)
@@ -631,20 +631,20 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'using PostgreSQL' do
- it 'renames a column concurrently' do
+ context "using PostgreSQL" do
+ it "renames a column concurrently" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(model).to receive(:check_trigger_permissions!).with(:users)
expect(model).to receive(:install_rename_triggers_for_postgresql)
- .with(trigger_name, 'users', 'old', 'new')
+ .with(trigger_name, "users", "old", "new")
expect(model).to receive(:add_column)
.with(:users, :new, :integer,
- limit: old_column.limit,
- precision: old_column.precision,
- scale: old_column.scale)
+ limit: old_column.limit,
+ precision: old_column.precision,
+ scale: old_column.scale)
expect(model).to receive(:change_column_default)
.with(:users, :new, old_column.default)
@@ -662,8 +662,8 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#cleanup_concurrent_column_rename' do
- it 'cleans up the renaming procedure for PostgreSQL' do
+ describe "#cleanup_concurrent_column_rename" do
+ it "cleans up the renaming procedure for PostgreSQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(true)
expect(model).to receive(:check_trigger_permissions!).with(:users)
@@ -676,7 +676,7 @@ describe Gitlab::Database::MigrationHelpers do
model.cleanup_concurrent_column_rename(:users, :old, :new)
end
- it 'cleans up the renaming procedure for MySQL' do
+ it "cleans up the renaming procedure for MySQL" do
allow(Gitlab::Database).to receive(:postgresql?).and_return(false)
expect(model).to receive(:check_trigger_permissions!).with(:users)
@@ -690,250 +690,250 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#change_column_type_concurrently' do
- it 'changes the column type' do
+ describe "#change_column_type_concurrently" do
+ it "changes the column type" do
expect(model).to receive(:rename_column_concurrently)
- .with('users', 'username', 'username_for_type_change', type: :text)
+ .with("users", "username", "username_for_type_change", type: :text)
- model.change_column_type_concurrently('users', 'username', :text)
+ model.change_column_type_concurrently("users", "username", :text)
end
end
- describe '#cleanup_concurrent_column_type_change' do
- it 'cleans up the type changing procedure' do
+ describe "#cleanup_concurrent_column_type_change" do
+ it "cleans up the type changing procedure" do
expect(model).to receive(:cleanup_concurrent_column_rename)
- .with('users', 'username', 'username_for_type_change')
+ .with("users", "username", "username_for_type_change")
expect(model).to receive(:rename_column)
- .with('users', 'username_for_type_change', 'username')
+ .with("users", "username_for_type_change", "username")
- model.cleanup_concurrent_column_type_change('users', 'username')
+ model.cleanup_concurrent_column_type_change("users", "username")
end
end
- describe '#install_rename_triggers_for_postgresql' do
- it 'installs the triggers for PostgreSQL' do
+ describe "#install_rename_triggers_for_postgresql" do
+ it "installs the triggers for PostgreSQL" do
expect(model).to receive(:execute)
.with(/CREATE OR REPLACE FUNCTION foo()/m)
expect(model).to receive(:execute)
.with(/CREATE TRIGGER foo/m)
- model.install_rename_triggers_for_postgresql('foo', :users, :old, :new)
+ model.install_rename_triggers_for_postgresql("foo", :users, :old, :new)
end
end
- describe '#install_rename_triggers_for_mysql' do
- it 'installs the triggers for MySQL' do
+ describe "#install_rename_triggers_for_mysql" do
+ it "installs the triggers for MySQL" do
expect(model).to receive(:execute)
.with(/CREATE TRIGGER foo_insert.+ON users/m)
expect(model).to receive(:execute)
.with(/CREATE TRIGGER foo_update.+ON users/m)
- model.install_rename_triggers_for_mysql('foo', :users, :old, :new)
+ model.install_rename_triggers_for_mysql("foo", :users, :old, :new)
end
end
- describe '#remove_rename_triggers_for_postgresql' do
- it 'removes the function and trigger' do
- expect(model).to receive(:execute).with('DROP TRIGGER IF EXISTS foo ON bar')
- expect(model).to receive(:execute).with('DROP FUNCTION IF EXISTS foo()')
+ describe "#remove_rename_triggers_for_postgresql" do
+ it "removes the function and trigger" do
+ expect(model).to receive(:execute).with("DROP TRIGGER IF EXISTS foo ON bar")
+ expect(model).to receive(:execute).with("DROP FUNCTION IF EXISTS foo()")
- model.remove_rename_triggers_for_postgresql('bar', 'foo')
+ model.remove_rename_triggers_for_postgresql("bar", "foo")
end
end
- describe '#remove_rename_triggers_for_mysql' do
- it 'removes the triggers' do
- expect(model).to receive(:execute).with('DROP TRIGGER IF EXISTS foo_insert')
- expect(model).to receive(:execute).with('DROP TRIGGER IF EXISTS foo_update')
+ describe "#remove_rename_triggers_for_mysql" do
+ it "removes the triggers" do
+ expect(model).to receive(:execute).with("DROP TRIGGER IF EXISTS foo_insert")
+ expect(model).to receive(:execute).with("DROP TRIGGER IF EXISTS foo_update")
- model.remove_rename_triggers_for_mysql('foo')
+ model.remove_rename_triggers_for_mysql("foo")
end
end
- describe '#rename_trigger_name' do
- it 'returns a String' do
+ describe "#rename_trigger_name" do
+ it "returns a String" do
expect(model.rename_trigger_name(:users, :foo, :bar))
.to match(/trigger_.{12}/)
end
end
- describe '#indexes_for' do
- it 'returns the indexes for a column' do
- idx1 = double(:idx, columns: %w(project_id))
- idx2 = double(:idx, columns: %w(user_id))
+ describe "#indexes_for" do
+ it "returns the indexes for a column" do
+ idx1 = double(:idx, columns: %w[project_id])
+ idx2 = double(:idx, columns: %w[user_id])
- allow(model).to receive(:indexes).with('table').and_return([idx1, idx2])
+ allow(model).to receive(:indexes).with("table").and_return([idx1, idx2])
- expect(model.indexes_for('table', :user_id)).to eq([idx2])
+ expect(model.indexes_for("table", :user_id)).to eq([idx2])
end
end
- describe '#foreign_keys_for' do
- it 'returns the foreign keys for a column' do
- fk1 = double(:fk, column: 'project_id')
- fk2 = double(:fk, column: 'user_id')
+ describe "#foreign_keys_for" do
+ it "returns the foreign keys for a column" do
+ fk1 = double(:fk, column: "project_id")
+ fk2 = double(:fk, column: "user_id")
- allow(model).to receive(:foreign_keys).with('table').and_return([fk1, fk2])
+ allow(model).to receive(:foreign_keys).with("table").and_return([fk1, fk2])
- expect(model.foreign_keys_for('table', :user_id)).to eq([fk2])
+ expect(model.foreign_keys_for("table", :user_id)).to eq([fk2])
end
end
- describe '#copy_indexes' do
- context 'using a regular index using a single column' do
- it 'copies the index' do
+ describe "#copy_indexes" do
+ context "using a regular index using a single column" do
+ it "copies the index" do
index = double(:index,
- columns: %w(project_id),
- name: 'index_on_issues_project_id',
- using: nil,
- where: nil,
- opclasses: {},
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id],
+ name: "index_on_issues_project_id",
+ using: nil,
+ where: nil,
+ opclasses: {},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect(model).to receive(:add_concurrent_index)
.with(:issues,
- %w(gl_project_id),
- unique: false,
- name: 'index_on_issues_gl_project_id',
- length: [],
- order: [])
+ %w[gl_project_id],
+ unique: false,
+ name: "index_on_issues_gl_project_id",
+ length: [],
+ order: [])
model.copy_indexes(:issues, :project_id, :gl_project_id)
end
end
- context 'using a regular index with multiple columns' do
- it 'copies the index' do
+ context "using a regular index with multiple columns" do
+ it "copies the index" do
index = double(:index,
- columns: %w(project_id foobar),
- name: 'index_on_issues_project_id_foobar',
- using: nil,
- where: nil,
- opclasses: {},
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id foobar],
+ name: "index_on_issues_project_id_foobar",
+ using: nil,
+ where: nil,
+ opclasses: {},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect(model).to receive(:add_concurrent_index)
.with(:issues,
- %w(gl_project_id foobar),
- unique: false,
- name: 'index_on_issues_gl_project_id_foobar',
- length: [],
- order: [])
+ %w[gl_project_id foobar],
+ unique: false,
+ name: "index_on_issues_gl_project_id_foobar",
+ length: [],
+ order: [])
model.copy_indexes(:issues, :project_id, :gl_project_id)
end
end
- context 'using an index with a WHERE clause' do
- it 'copies the index' do
+ context "using an index with a WHERE clause" do
+ it "copies the index" do
index = double(:index,
- columns: %w(project_id),
- name: 'index_on_issues_project_id',
- using: nil,
- where: 'foo',
- opclasses: {},
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id],
+ name: "index_on_issues_project_id",
+ using: nil,
+ where: "foo",
+ opclasses: {},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect(model).to receive(:add_concurrent_index)
.with(:issues,
- %w(gl_project_id),
- unique: false,
- name: 'index_on_issues_gl_project_id',
- length: [],
- order: [],
- where: 'foo')
+ %w[gl_project_id],
+ unique: false,
+ name: "index_on_issues_gl_project_id",
+ length: [],
+ order: [],
+ where: "foo")
model.copy_indexes(:issues, :project_id, :gl_project_id)
end
end
- context 'using an index with a USING clause' do
- it 'copies the index' do
+ context "using an index with a USING clause" do
+ it "copies the index" do
index = double(:index,
- columns: %w(project_id),
- name: 'index_on_issues_project_id',
- where: nil,
- using: 'foo',
- opclasses: {},
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id],
+ name: "index_on_issues_project_id",
+ where: nil,
+ using: "foo",
+ opclasses: {},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect(model).to receive(:add_concurrent_index)
.with(:issues,
- %w(gl_project_id),
- unique: false,
- name: 'index_on_issues_gl_project_id',
- length: [],
- order: [],
- using: 'foo')
+ %w[gl_project_id],
+ unique: false,
+ name: "index_on_issues_gl_project_id",
+ length: [],
+ order: [],
+ using: "foo")
model.copy_indexes(:issues, :project_id, :gl_project_id)
end
end
- context 'using an index with custom operator classes' do
- it 'copies the index' do
+ context "using an index with custom operator classes" do
+ it "copies the index" do
index = double(:index,
- columns: %w(project_id),
- name: 'index_on_issues_project_id',
- using: nil,
- where: nil,
- opclasses: { 'project_id' => 'bar' },
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id],
+ name: "index_on_issues_project_id",
+ using: nil,
+ where: nil,
+ opclasses: {"project_id" => "bar"},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect(model).to receive(:add_concurrent_index)
.with(:issues,
- %w(gl_project_id),
- unique: false,
- name: 'index_on_issues_gl_project_id',
- length: [],
- order: [],
- opclasses: { 'gl_project_id' => 'bar' })
+ %w[gl_project_id],
+ unique: false,
+ name: "index_on_issues_gl_project_id",
+ length: [],
+ order: [],
+ opclasses: {"gl_project_id" => "bar"})
model.copy_indexes(:issues, :project_id, :gl_project_id)
end
end
- describe 'using an index of which the name does not contain the source column' do
- it 'raises RuntimeError' do
+ describe "using an index of which the name does not contain the source column" do
+ it "raises RuntimeError" do
index = double(:index,
- columns: %w(project_id),
- name: 'index_foobar_index',
- using: nil,
- where: nil,
- opclasses: {},
- unique: false,
- lengths: [],
- orders: [])
-
- allow(model).to receive(:indexes_for).with(:issues, 'project_id')
+ columns: %w[project_id],
+ name: "index_foobar_index",
+ using: nil,
+ where: nil,
+ opclasses: {},
+ unique: false,
+ lengths: [],
+ orders: [])
+
+ allow(model).to receive(:indexes_for).with(:issues, "project_id")
.and_return([index])
expect { model.copy_indexes(:issues, :project_id, :gl_project_id) }
@@ -942,137 +942,137 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#copy_foreign_keys' do
- it 'copies foreign keys from one column to another' do
+ describe "#copy_foreign_keys" do
+ it "copies foreign keys from one column to another" do
fk = double(:fk,
- from_table: 'issues',
- to_table: 'projects',
- on_delete: :cascade)
+ from_table: "issues",
+ to_table: "projects",
+ on_delete: :cascade)
allow(model).to receive(:foreign_keys_for).with(:issues, :project_id)
.and_return([fk])
expect(model).to receive(:add_concurrent_foreign_key)
- .with('issues', 'projects', column: :gl_project_id, on_delete: :cascade)
+ .with("issues", "projects", column: :gl_project_id, on_delete: :cascade)
model.copy_foreign_keys(:issues, :project_id, :gl_project_id)
end
end
- describe '#column_for' do
- it 'returns a column object for an existing column' do
+ describe "#column_for" do
+ it "returns a column object for an existing column" do
column = model.column_for(:users, :id)
- expect(column.name).to eq('id')
+ expect(column.name).to eq("id")
end
- it 'returns nil when a column does not exist' do
+ it "returns nil when a column does not exist" do
expect(model.column_for(:users, :kittens)).to be_nil
end
end
- describe '#replace_sql' do
- context 'using postgres' do
+ describe "#replace_sql" do
+ context "using postgres" do
before do
allow(Gitlab::Database).to receive(:mysql?).and_return(false)
end
- it 'builds the sql with correct functions' do
+ it "builds the sql with correct functions" do
expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s)
- .to include('regexp_replace')
+ .to include("regexp_replace")
end
end
- context 'using mysql' do
+ context "using mysql" do
before do
allow(Gitlab::Database).to receive(:mysql?).and_return(true)
end
- it 'builds the sql with the correct functions' do
+ it "builds the sql with the correct functions" do
expect(model.replace_sql(Arel::Table.new(:users)[:first_name], "Alice", "Eve").to_s)
- .to include('locate', 'insert')
+ .to include("locate", "insert")
end
end
- describe 'results' do
- let!(:user) { create(:user, name: 'Kathy Alice Aliceson') }
+ describe "results" do
+ let!(:user) { create(:user, name: "Kathy Alice Aliceson") }
- it 'replaces the correct part of the string' do
+ it "replaces the correct part of the string" do
allow(model).to receive(:transaction_open?).and_return(false)
- query = model.replace_sql(Arel::Table.new(:users)[:name], 'Alice', 'Eve')
+ query = model.replace_sql(Arel::Table.new(:users)[:name], "Alice", "Eve")
model.update_column_in_batches(:users, :name, query)
- expect(user.reload.name).to eq('Kathy Eve Aliceson')
+ expect(user.reload.name).to eq("Kathy Eve Aliceson")
end
end
end
- describe 'sidekiq migration helpers', :sidekiq, :redis do
+ describe "sidekiq migration helpers", :sidekiq, :redis do
let(:worker) do
Class.new do
include Sidekiq::Worker
- sidekiq_options queue: 'test'
+ sidekiq_options queue: "test"
end
end
- describe '#sidekiq_queue_length' do
- context 'when queue is empty' do
- it 'returns zero' do
+ describe "#sidekiq_queue_length" do
+ context "when queue is empty" do
+ it "returns zero" do
Sidekiq::Testing.disable! do
- expect(model.sidekiq_queue_length('test')).to eq 0
+ expect(model.sidekiq_queue_length("test")).to eq 0
end
end
end
- context 'when queue contains jobs' do
- it 'returns correct size of the queue' do
+ context "when queue contains jobs" do
+ it "returns correct size of the queue" do
Sidekiq::Testing.disable! do
- worker.perform_async('Something', [1])
- worker.perform_async('Something', [2])
+ worker.perform_async("Something", [1])
+ worker.perform_async("Something", [2])
- expect(model.sidekiq_queue_length('test')).to eq 2
+ expect(model.sidekiq_queue_length("test")).to eq 2
end
end
end
end
- describe '#migrate_sidekiq_queue' do
- it 'migrates jobs from one sidekiq queue to another' do
+ describe "#migrate_sidekiq_queue" do
+ it "migrates jobs from one sidekiq queue to another" do
Sidekiq::Testing.disable! do
- worker.perform_async('Something', [1])
- worker.perform_async('Something', [2])
+ worker.perform_async("Something", [1])
+ worker.perform_async("Something", [2])
- expect(model.sidekiq_queue_length('test')).to eq 2
- expect(model.sidekiq_queue_length('new_test')).to eq 0
+ expect(model.sidekiq_queue_length("test")).to eq 2
+ expect(model.sidekiq_queue_length("new_test")).to eq 0
- model.sidekiq_queue_migrate('test', to: 'new_test')
+ model.sidekiq_queue_migrate("test", to: "new_test")
- expect(model.sidekiq_queue_length('test')).to eq 0
- expect(model.sidekiq_queue_length('new_test')).to eq 2
+ expect(model.sidekiq_queue_length("test")).to eq 0
+ expect(model.sidekiq_queue_length("new_test")).to eq 2
end
end
end
end
- describe '#check_trigger_permissions!' do
- it 'does nothing when the user has the correct permissions' do
- expect { model.check_trigger_permissions!('users') }
+ describe "#check_trigger_permissions!" do
+ it "does nothing when the user has the correct permissions" do
+ expect { model.check_trigger_permissions!("users") }
.not_to raise_error
end
- it 'raises RuntimeError when the user does not have the correct permissions' do
+ it "raises RuntimeError when the user does not have the correct permissions" do
allow(Gitlab::Database::Grant).to receive(:create_and_execute_trigger?)
- .with('kittens')
+ .with("kittens")
.and_return(false)
- expect { model.check_trigger_permissions!('kittens') }
+ expect { model.check_trigger_permissions!("kittens") }
.to raise_error(RuntimeError, /Your database user is not allowed/)
end
end
- describe '#bulk_queue_background_migration_jobs_by_range', :sidekiq do
- context 'when the model has an ID column' do
+ describe "#bulk_queue_background_migration_jobs_by_range", :sidekiq do
+ context "when the model has an ID column" do
let!(:id1) { create(:user).id }
let!(:id2) { create(:user).id }
let!(:id3) { create(:user).id }
@@ -1083,68 +1083,68 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'with enough rows to bulk queue jobs more than once' do
+ context "with enough rows to bulk queue jobs more than once" do
before do
- stub_const('Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE', 1)
+ stub_const("Gitlab::Database::MigrationHelpers::BACKGROUND_MIGRATION_JOB_BUFFER_SIZE", 1)
end
- it 'queues jobs correctly' do
+ it "queues jobs correctly" do
Sidekiq::Testing.fake! do
- model.bulk_queue_background_migration_jobs_by_range(User, 'FooJob', batch_size: 2)
+ model.bulk_queue_background_migration_jobs_by_range(User, "FooJob", batch_size: 2)
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq(['FooJob', [id1, id2]])
- expect(BackgroundMigrationWorker.jobs[1]['args']).to eq(['FooJob', [id3, id3]])
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq(["FooJob", [id1, id2]])
+ expect(BackgroundMigrationWorker.jobs[1]["args"]).to eq(["FooJob", [id3, id3]])
end
end
- it 'queues jobs in groups of buffer size 1' do
- expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([['FooJob', [id1, id2]]])
- expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([['FooJob', [id3, id3]]])
+ it "queues jobs in groups of buffer size 1" do
+ expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([["FooJob", [id1, id2]]])
+ expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([["FooJob", [id3, id3]]])
- model.bulk_queue_background_migration_jobs_by_range(User, 'FooJob', batch_size: 2)
+ model.bulk_queue_background_migration_jobs_by_range(User, "FooJob", batch_size: 2)
end
end
- context 'with not enough rows to bulk queue jobs more than once' do
- it 'queues jobs correctly' do
+ context "with not enough rows to bulk queue jobs more than once" do
+ it "queues jobs correctly" do
Sidekiq::Testing.fake! do
- model.bulk_queue_background_migration_jobs_by_range(User, 'FooJob', batch_size: 2)
+ model.bulk_queue_background_migration_jobs_by_range(User, "FooJob", batch_size: 2)
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq(['FooJob', [id1, id2]])
- expect(BackgroundMigrationWorker.jobs[1]['args']).to eq(['FooJob', [id3, id3]])
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq(["FooJob", [id1, id2]])
+ expect(BackgroundMigrationWorker.jobs[1]["args"]).to eq(["FooJob", [id3, id3]])
end
end
- it 'queues jobs in bulk all at once (big buffer size)' do
- expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([['FooJob', [id1, id2]],
- ['FooJob', [id3, id3]]])
+ it "queues jobs in bulk all at once (big buffer size)" do
+ expect(BackgroundMigrationWorker).to receive(:bulk_perform_async).with([["FooJob", [id1, id2]],
+ ["FooJob", [id3, id3]],])
- model.bulk_queue_background_migration_jobs_by_range(User, 'FooJob', batch_size: 2)
+ model.bulk_queue_background_migration_jobs_by_range(User, "FooJob", batch_size: 2)
end
end
- context 'without specifying batch_size' do
- it 'queues jobs correctly' do
+ context "without specifying batch_size" do
+ it "queues jobs correctly" do
Sidekiq::Testing.fake! do
- model.bulk_queue_background_migration_jobs_by_range(User, 'FooJob')
+ model.bulk_queue_background_migration_jobs_by_range(User, "FooJob")
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq(['FooJob', [id1, id3]])
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq(["FooJob", [id1, id3]])
end
end
end
end
context "when the model doesn't have an ID column" do
- it 'raises error (for now)' do
- expect do
- model.bulk_queue_background_migration_jobs_by_range(ProjectAuthorization, 'FooJob')
- end.to raise_error(StandardError, /does not have an ID/)
+ it "raises error (for now)" do
+ expect {
+ model.bulk_queue_background_migration_jobs_by_range(ProjectAuthorization, "FooJob")
+ }.to raise_error(StandardError, /does not have an ID/)
end
end
end
- describe '#queue_background_migration_jobs_by_range_at_intervals', :sidekiq do
- context 'when the model has an ID column' do
+ describe "#queue_background_migration_jobs_by_range_at_intervals", :sidekiq do
+ context "when the model has an ID column" do
let!(:id1) { create(:user).id }
let!(:id2) { create(:user).id }
let!(:id3) { create(:user).id }
@@ -1159,66 +1159,66 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- context 'with batch_size option' do
- it 'queues jobs correctly' do
+ context "with batch_size option" do
+ it "queues jobs correctly" do
Sidekiq::Testing.fake! do
- model.queue_background_migration_jobs_by_range_at_intervals(User, 'FooJob', 10.minutes, batch_size: 2)
+ model.queue_background_migration_jobs_by_range_at_intervals(User, "FooJob", 10.minutes, batch_size: 2)
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq(['FooJob', [id1, id2]])
- expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(10.minutes.from_now.to_f)
- expect(BackgroundMigrationWorker.jobs[1]['args']).to eq(['FooJob', [id3, id3]])
- expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(20.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq(["FooJob", [id1, id2]])
+ expect(BackgroundMigrationWorker.jobs[0]["at"]).to eq(10.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[1]["args"]).to eq(["FooJob", [id3, id3]])
+ expect(BackgroundMigrationWorker.jobs[1]["at"]).to eq(20.minutes.from_now.to_f)
end
end
end
- context 'without batch_size option' do
- it 'queues jobs correctly' do
+ context "without batch_size option" do
+ it "queues jobs correctly" do
Sidekiq::Testing.fake! do
- model.queue_background_migration_jobs_by_range_at_intervals(User, 'FooJob', 10.minutes)
+ model.queue_background_migration_jobs_by_range_at_intervals(User, "FooJob", 10.minutes)
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq(['FooJob', [id1, id3]])
- expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(10.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq(["FooJob", [id1, id3]])
+ expect(BackgroundMigrationWorker.jobs[0]["at"]).to eq(10.minutes.from_now.to_f)
end
end
end
end
context "when the model doesn't have an ID column" do
- it 'raises error (for now)' do
- expect do
- model.queue_background_migration_jobs_by_range_at_intervals(ProjectAuthorization, 'FooJob', 10.seconds)
- end.to raise_error(StandardError, /does not have an ID/)
+ it "raises error (for now)" do
+ expect {
+ model.queue_background_migration_jobs_by_range_at_intervals(ProjectAuthorization, "FooJob", 10.seconds)
+ }.to raise_error(StandardError, /does not have an ID/)
end
end
end
- describe '#change_column_type_using_background_migration' do
+ describe "#change_column_type_using_background_migration" do
let!(:issue) { create(:issue, :closed, closed_at: Time.zone.now) }
let(:issue_model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'issues'
+ self.table_name = "issues"
include EachBatch
end
end
- it 'changes the type of a column using a background migration' do
+ it "changes the type of a column using a background migration" do
expect(model)
.to receive(:add_column)
- .with('issues', 'closed_at_for_type_change', :datetime_with_timezone)
+ .with("issues", "closed_at_for_type_change", :datetime_with_timezone)
expect(model)
.to receive(:install_rename_triggers)
- .with('issues', :closed_at, 'closed_at_for_type_change')
+ .with("issues", :closed_at, "closed_at_for_type_change")
expect(BackgroundMigrationWorker)
.to receive(:perform_in)
.ordered
.with(
10.minutes,
- 'CopyColumn',
- ['issues', :closed_at, 'closed_at_for_type_change', issue.id, issue.id]
+ "CopyColumn",
+ ["issues", :closed_at, "closed_at_for_type_change", issue.id, issue.id]
)
expect(BackgroundMigrationWorker)
@@ -1226,19 +1226,19 @@ describe Gitlab::Database::MigrationHelpers do
.ordered
.with(
1.hour + 10.minutes,
- 'CleanupConcurrentTypeChange',
- ['issues', :closed_at, 'closed_at_for_type_change']
+ "CleanupConcurrentTypeChange",
+ ["issues", :closed_at, "closed_at_for_type_change"]
)
expect(Gitlab::BackgroundMigration)
.to receive(:steal)
.ordered
- .with('CopyColumn')
+ .with("CopyColumn")
expect(Gitlab::BackgroundMigration)
.to receive(:steal)
.ordered
- .with('CleanupConcurrentTypeChange')
+ .with("CleanupConcurrentTypeChange")
model.change_column_type_using_background_migration(
issue_model.all,
@@ -1248,14 +1248,14 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#rename_column_using_background_migration' do
+ describe "#rename_column_using_background_migration" do
let!(:issue) { create(:issue, :closed, closed_at: Time.zone.now) }
- it 'renames a column using a background migration' do
+ it "renames a column using a background migration" do
expect(model)
.to receive(:add_column)
.with(
- 'issues',
+ "issues",
:closed_at_timestamp,
:datetime_with_timezone,
limit: anything,
@@ -1265,15 +1265,15 @@ describe Gitlab::Database::MigrationHelpers do
expect(model)
.to receive(:install_rename_triggers)
- .with('issues', :closed_at, :closed_at_timestamp)
+ .with("issues", :closed_at, :closed_at_timestamp)
expect(BackgroundMigrationWorker)
.to receive(:perform_in)
.ordered
.with(
10.minutes,
- 'CopyColumn',
- ['issues', :closed_at, :closed_at_timestamp, issue.id, issue.id]
+ "CopyColumn",
+ ["issues", :closed_at, :closed_at_timestamp, issue.id, issue.id]
)
expect(BackgroundMigrationWorker)
@@ -1281,30 +1281,30 @@ describe Gitlab::Database::MigrationHelpers do
.ordered
.with(
1.hour + 10.minutes,
- 'CleanupConcurrentRename',
- ['issues', :closed_at, :closed_at_timestamp]
+ "CleanupConcurrentRename",
+ ["issues", :closed_at, :closed_at_timestamp]
)
expect(Gitlab::BackgroundMigration)
.to receive(:steal)
.ordered
- .with('CopyColumn')
+ .with("CopyColumn")
expect(Gitlab::BackgroundMigration)
.to receive(:steal)
.ordered
- .with('CleanupConcurrentRename')
+ .with("CleanupConcurrentRename")
model.rename_column_using_background_migration(
- 'issues',
+ "issues",
:closed_at,
:closed_at_timestamp
)
end
end
- describe '#perform_background_migration_inline?' do
- it 'returns true in a test environment' do
+ describe "#perform_background_migration_inline?" do
+ it "returns true in a test environment" do
allow(Rails.env)
.to receive(:test?)
.and_return(true)
@@ -1312,7 +1312,7 @@ describe Gitlab::Database::MigrationHelpers do
expect(model.perform_background_migration_inline?).to eq(true)
end
- it 'returns true in a development environment' do
+ it "returns true in a development environment" do
allow(Rails.env)
.to receive(:test?)
.and_return(false)
@@ -1324,7 +1324,7 @@ describe Gitlab::Database::MigrationHelpers do
expect(model.perform_background_migration_inline?).to eq(true)
end
- it 'returns false in a production environment' do
+ it "returns false in a production environment" do
allow(Rails.env)
.to receive(:test?)
.and_return(false)
@@ -1337,30 +1337,30 @@ describe Gitlab::Database::MigrationHelpers do
end
end
- describe '#index_exists_by_name?' do
- it 'returns true if an index exists' do
- expect(model.index_exists_by_name?(:projects, 'index_projects_on_path'))
+ describe "#index_exists_by_name?" do
+ it "returns true if an index exists" do
+ expect(model.index_exists_by_name?(:projects, "index_projects_on_path"))
.to be_truthy
end
- it 'returns false if the index does not exist' do
- expect(model.index_exists_by_name?(:projects, 'this_does_not_exist'))
+ it "returns false if the index does not exist" do
+ expect(model.index_exists_by_name?(:projects, "this_does_not_exist"))
.to be_falsy
end
- context 'when an index with a function exists', :postgresql do
+ context "when an index with a function exists", :postgresql do
before do
ActiveRecord::Base.connection.execute(
- 'CREATE INDEX test_index ON projects (LOWER(path));'
+ "CREATE INDEX test_index ON projects (LOWER(path));"
)
end
after do
- 'DROP INDEX IF EXISTS test_index;'
+ "DROP INDEX IF EXISTS test_index;"
end
- it 'returns true if an index exists' do
- expect(model.index_exists_by_name?(:projects, 'test_index'))
+ it "returns true if an index exists" do
+ expect(model.index_exists_by_name?(:projects, "test_index"))
.to be_truthy
end
end
diff --git a/spec/lib/gitlab/database/multi_threaded_migration_spec.rb b/spec/lib/gitlab/database/multi_threaded_migration_spec.rb
index 6c45f13bb5a..1f3f2f8ed10 100644
--- a/spec/lib/gitlab/database/multi_threaded_migration_spec.rb
+++ b/spec/lib/gitlab/database/multi_threaded_migration_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::MultiThreadedMigration do
let(:migration) do
Class.new { include Gitlab::Database::MultiThreadedMigration }.new
end
- describe '#connection' do
+ describe "#connection" do
after do
Thread.current[described_class::MULTI_THREAD_AR_CONNECTION] = nil
end
- it 'returns the thread-local connection if present' do
+ it "returns the thread-local connection if present" do
Thread.current[described_class::MULTI_THREAD_AR_CONNECTION] = 10
expect(migration.connection).to eq(10)
end
- it 'returns the global connection if no thread-local connection was set' do
+ it "returns the global connection if no thread-local connection was set" do
expect(migration.connection).to eq(ActiveRecord::Base.connection)
end
end
- describe '#with_multiple_threads' do
- it 'starts multiple threads and yields the supplied block in every thread' do
+ describe "#with_multiple_threads" do
+ it "starts multiple threads and yields the supplied block in every thread" do
output = Queue.new
migration.with_multiple_threads(2) do
- output << migration.connection.execute('SELECT 1')
+ output << migration.connection.execute("SELECT 1")
end
expect(output.size).to eq(2)
end
- it 'joins the threads when the join parameter is set' do
+ it "joins the threads when the join parameter is set" do
expect_any_instance_of(Thread).to receive(:join).and_call_original
migration.with_multiple_threads(1) { }
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
index 81419e51635..fc36b315999 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_base_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
- let(:subject) { described_class.new(['the-path'], migration) }
+ let(:subject) { described_class.new(["the-path"], migration) }
before do
allow(migration).to receive(:say)
@@ -28,49 +28,49 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
end
end
- describe '#remove_cached_html_for_projects' do
- let(:project) { create(:project, description_html: 'Project description') }
+ describe "#remove_cached_html_for_projects" do
+ let(:project) { create(:project, description_html: "Project description") }
- it 'removes description_html from projects' do
+ it "removes description_html from projects" do
subject.remove_cached_html_for_projects([project.id])
expect(project.reload.description_html).to be_nil
end
- it 'removes issue descriptions' do
- issue = create(:issue, project: project, description_html: 'Issue description')
+ it "removes issue descriptions" do
+ issue = create(:issue, project: project, description_html: "Issue description")
subject.remove_cached_html_for_projects([project.id])
expect(issue.reload.description_html).to be_nil
end
- it 'removes merge request descriptions' do
+ it "removes merge request descriptions" do
merge_request = create(:merge_request,
- source_project: project,
- target_project: project,
- description_html: 'MergeRequest description')
+ source_project: project,
+ target_project: project,
+ description_html: "MergeRequest description")
subject.remove_cached_html_for_projects([project.id])
expect(merge_request.reload.description_html).to be_nil
end
- it 'removes note html' do
+ it "removes note html" do
note = create(:note,
- project: project,
- noteable: create(:issue, project: project),
- note_html: 'note description')
+ project: project,
+ noteable: create(:issue, project: project),
+ note_html: "note description")
subject.remove_cached_html_for_projects([project.id])
expect(note.reload.note_html).to be_nil
end
- it 'removes milestone description' do
+ it "removes milestone description" do
milestone = create(:milestone,
- project: project,
- description_html: 'milestone description')
+ project: project,
+ description_html: "milestone description")
subject.remove_cached_html_for_projects([project.id])
@@ -78,9 +78,9 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
end
end
- describe '#rename_path_for_routable' do
- context 'for namespaces' do
- let(:namespace) { create(:namespace, path: 'the-path') }
+ describe "#rename_path_for_routable" do
+ context "for namespaces" do
+ let(:namespace) { create(:namespace, path: "the-path") }
it "renames namespaces called the-path" do
subject.rename_path_for_routable(migration_namespace(namespace))
@@ -101,20 +101,20 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
expect(project.route.reload.path).to eq("the-path0/project-path")
end
- it 'returns the old & the new path' do
+ it "returns the old & the new path" do
old_path, new_path = subject.rename_path_for_routable(migration_namespace(namespace))
- expect(old_path).to eq('the-path')
- expect(new_path).to eq('the-path0')
+ expect(old_path).to eq("the-path")
+ expect(new_path).to eq("the-path0")
end
it "doesn't rename routes that start with a similar name" do
- other_namespace = create(:namespace, path: 'the-path-but-not-really')
- project = create(:project, path: 'the-project', namespace: other_namespace)
+ other_namespace = create(:namespace, path: "the-path-but-not-really")
+ project = create(:project, path: "the-project", namespace: other_namespace)
subject.rename_path_for_routable(migration_namespace(namespace))
- expect(project.route.reload.path).to eq('the-path-but-not-really/the-project')
+ expect(project.route.reload.path).to eq("the-path-but-not-really/the-project")
end
context "the-path namespace -> subgroup -> the-path0 project" do
@@ -129,86 +129,86 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
end
end
- context 'for projects' do
- let(:parent) { create(:namespace, path: 'the-parent') }
- let(:project) { create(:project, path: 'the-path', namespace: parent) }
+ context "for projects" do
+ let(:parent) { create(:namespace, path: "the-parent") }
+ let(:project) { create(:project, path: "the-path", namespace: parent) }
- it 'renames the project called `the-path`' do
+ it "renames the project called `the-path`" do
subject.rename_path_for_routable(migration_project(project))
- expect(project.reload.path).to eq('the-path0')
+ expect(project.reload.path).to eq("the-path0")
end
- it 'renames the route for the project' do
+ it "renames the route for the project" do
subject.rename_path_for_routable(project)
- expect(project.reload.route.path).to eq('the-parent/the-path0')
+ expect(project.reload.route.path).to eq("the-parent/the-path0")
end
- it 'returns the old & new path' do
+ it "returns the old & new path" do
old_path, new_path = subject.rename_path_for_routable(migration_project(project))
- expect(old_path).to eq('the-parent/the-path')
- expect(new_path).to eq('the-parent/the-path0')
+ expect(old_path).to eq("the-parent/the-path")
+ expect(new_path).to eq("the-parent/the-path0")
end
end
end
- describe '#perform_rename' do
- describe 'for namespaces' do
- let(:namespace) { create(:namespace, path: 'the-path') }
- it 'renames the path' do
- subject.perform_rename(migration_namespace(namespace), 'the-path', 'renamed')
+ describe "#perform_rename" do
+ describe "for namespaces" do
+ let(:namespace) { create(:namespace, path: "the-path") }
+ it "renames the path" do
+ subject.perform_rename(migration_namespace(namespace), "the-path", "renamed")
- expect(namespace.reload.path).to eq('renamed')
+ expect(namespace.reload.path).to eq("renamed")
end
- it 'renames all the routes for the namespace' do
- child = create(:group, path: 'child', parent: namespace)
- project = create(:project, :repository, namespace: child, path: 'the-project')
- other_one = create(:namespace, path: 'the-path-is-similar')
+ it "renames all the routes for the namespace" do
+ child = create(:group, path: "child", parent: namespace)
+ project = create(:project, :repository, namespace: child, path: "the-project")
+ other_one = create(:namespace, path: "the-path-is-similar")
- subject.perform_rename(migration_namespace(namespace), 'the-path', 'renamed')
+ subject.perform_rename(migration_namespace(namespace), "the-path", "renamed")
- expect(namespace.reload.route.path).to eq('renamed')
- expect(child.reload.route.path).to eq('renamed/child')
- expect(project.reload.route.path).to eq('renamed/child/the-project')
- expect(other_one.reload.route.path).to eq('the-path-is-similar')
+ expect(namespace.reload.route.path).to eq("renamed")
+ expect(child.reload.route.path).to eq("renamed/child")
+ expect(project.reload.route.path).to eq("renamed/child/the-project")
+ expect(other_one.reload.route.path).to eq("the-path-is-similar")
end
end
end
- describe '#move_pages' do
- it 'moves the pages directory' do
+ describe "#move_pages" do
+ it "moves the pages directory" do
expect(subject).to receive(:move_folders)
- .with(TestEnv.pages_path, 'old-path', 'new-path')
+ .with(TestEnv.pages_path, "old-path", "new-path")
- subject.move_pages('old-path', 'new-path')
+ subject.move_pages("old-path", "new-path")
end
end
describe "#move_uploads" do
- let(:test_dir) { File.join(Rails.root, 'tmp', 'tests', 'rename_reserved_paths') }
- let(:uploads_dir) { File.join(test_dir, 'public', 'uploads') }
+ let(:test_dir) { File.join(Rails.root, "tmp", "tests", "rename_reserved_paths") }
+ let(:uploads_dir) { File.join(test_dir, "public", "uploads") }
- it 'moves subdirectories in the uploads folder' do
+ it "moves subdirectories in the uploads folder" do
expect(subject).to receive(:uploads_dir).and_return(uploads_dir)
- expect(subject).to receive(:move_folders).with(uploads_dir, 'old_path', 'new_path')
+ expect(subject).to receive(:move_folders).with(uploads_dir, "old_path", "new_path")
- subject.move_uploads('old_path', 'new_path')
+ subject.move_uploads("old_path", "new_path")
end
it "doesn't move uploads when they are stored in object storage" do
expect(subject).to receive(:file_storage?).and_return(false)
expect(subject).not_to receive(:move_folders)
- subject.move_uploads('old_path', 'new_path')
+ subject.move_uploads("old_path", "new_path")
end
end
- describe '#move_folders' do
- let(:test_dir) { File.join(Rails.root, 'tmp', 'tests', 'rename_reserved_paths') }
- let(:uploads_dir) { File.join(test_dir, 'public', 'uploads') }
+ describe "#move_folders" do
+ let(:test_dir) { File.join(Rails.root, "tmp", "tests", "rename_reserved_paths") }
+ let(:uploads_dir) { File.join(test_dir, "public", "uploads") }
before do
FileUtils.remove_dir(test_dir) if File.directory?(test_dir)
@@ -216,24 +216,24 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
allow(subject).to receive(:uploads_dir).and_return(uploads_dir)
end
- it 'moves a folder with files' do
- source = File.join(uploads_dir, 'parent-group', 'sub-group')
+ it "moves a folder with files" do
+ source = File.join(uploads_dir, "parent-group", "sub-group")
FileUtils.mkdir_p(source)
- destination = File.join(uploads_dir, 'parent-group', 'moved-group')
- FileUtils.touch(File.join(source, 'test.txt'))
- expected_file = File.join(destination, 'test.txt')
+ destination = File.join(uploads_dir, "parent-group", "moved-group")
+ FileUtils.touch(File.join(source, "test.txt"))
+ expected_file = File.join(destination, "test.txt")
- subject.move_folders(uploads_dir, File.join('parent-group', 'sub-group'), File.join('parent-group', 'moved-group'))
+ subject.move_folders(uploads_dir, File.join("parent-group", "sub-group"), File.join("parent-group", "moved-group"))
expect(File.exist?(expected_file)).to be(true)
end
end
- describe '#track_rename', :redis do
- it 'tracks a rename in redis' do
- key = 'rename:FakeRenameReservedPathMigrationV1:namespace'
+ describe "#track_rename", :redis do
+ it "tracks a rename in redis" do
+ key = "rename:FakeRenameReservedPathMigrationV1:namespace"
- subject.track_rename('namespace', 'path/to/namespace', 'path/to/renamed')
+ subject.track_rename("namespace", "path/to/namespace", "path/to/renamed")
old_path, new_path = [nil, nil]
Gitlab::Redis::SharedState.with do |redis|
@@ -241,31 +241,31 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
old_path, new_path = JSON.parse(rename_info)
end
- expect(old_path).to eq('path/to/namespace')
- expect(new_path).to eq('path/to/renamed')
+ expect(old_path).to eq("path/to/namespace")
+ expect(new_path).to eq("path/to/renamed")
end
end
- describe '#reverts_for_type', :redis do
- it 'yields for each tracked rename' do
- subject.track_rename('project', 'old_path', 'new_path')
- subject.track_rename('project', 'old_path2', 'new_path2')
- subject.track_rename('namespace', 'namespace_path', 'new_namespace_path')
+ describe "#reverts_for_type", :redis do
+ it "yields for each tracked rename" do
+ subject.track_rename("project", "old_path", "new_path")
+ subject.track_rename("project", "old_path2", "new_path2")
+ subject.track_rename("namespace", "namespace_path", "new_namespace_path")
- expect { |b| subject.reverts_for_type('project', &b) }
- .to yield_successive_args(%w(old_path2 new_path2), %w(old_path new_path))
- expect { |b| subject.reverts_for_type('namespace', &b) }
- .to yield_with_args('namespace_path', 'new_namespace_path')
+ expect { |b| subject.reverts_for_type("project", &b) }
+ .to yield_successive_args(%w[old_path2 new_path2], %w[old_path new_path])
+ expect { |b| subject.reverts_for_type("namespace", &b) }
+ .to yield_with_args("namespace_path", "new_namespace_path")
end
- it 'keeps the revert in redis if it failed' do
- subject.track_rename('project', 'old_path', 'new_path')
+ it "keeps the revert in redis if it failed" do
+ subject.track_rename("project", "old_path", "new_path")
- subject.reverts_for_type('project') do
- raise 'whatever happens, keep going!'
+ subject.reverts_for_type("project") do
+ raise "whatever happens, keep going!"
end
- key = 'rename:FakeRenameReservedPathMigrationV1:project'
+ key = "rename:FakeRenameReservedPathMigrationV1:project"
stored_renames = nil
rename_count = 0
Gitlab::Redis::SharedState.with do |redis|
@@ -274,7 +274,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameBase, :delete
end
expect(rename_count).to eq(1)
- expect(JSON.parse(stored_renames.first)).to eq(%w(old_path new_path))
+ expect(JSON.parse(stored_renames.first)).to eq(%w[old_path new_path])
end
end
end
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
index b6096d4faf6..f3acac93944 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_namespaces_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
- let(:subject) { described_class.new(['the-path'], migration) }
- let(:namespace) { create(:group, name: 'the-path') }
+ let(:subject) { described_class.new(["the-path"], migration) }
+ let(:namespace) { create(:group, name: "the-path") }
before do
allow(migration).to receive(:say)
@@ -15,110 +15,110 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
Namespace.find(namespace.id)
end
- describe '#namespaces_for_paths' do
- context 'nested namespaces' do
- let(:subject) { described_class.new(['parent/the-Path'], migration) }
+ describe "#namespaces_for_paths" do
+ context "nested namespaces" do
+ let(:subject) { described_class.new(["parent/the-Path"], migration) }
- it 'includes the namespace' do
- parent = create(:group, path: 'parent')
- child = create(:group, path: 'the-path', parent: parent)
+ it "includes the namespace" do
+ parent = create(:group, path: "parent")
+ child = create(:group, path: "the-path", parent: parent)
found_ids = subject.namespaces_for_paths(type: :child)
- .map(&:id)
+ .map(&:id)
expect(found_ids).to contain_exactly(child.id)
end
end
- context 'for child namespaces' do
- it 'only returns child namespaces with the correct path' do
- _root_namespace = create(:group, path: 'THE-path')
+ context "for child namespaces" do
+ it "only returns child namespaces with the correct path" do
+ _root_namespace = create(:group, path: "THE-path")
_other_path = create(:group,
- path: 'other',
- parent: create(:group))
+ path: "other",
+ parent: create(:group))
namespace = create(:group,
- path: 'the-path',
- parent: create(:group))
+ path: "the-path",
+ parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :child)
- .map(&:id)
+ .map(&:id)
expect(found_ids).to contain_exactly(namespace.id)
end
- it 'has no namespaces that look the same' do
- _root_namespace = create(:group, path: 'THE-path')
+ it "has no namespaces that look the same" do
+ _root_namespace = create(:group, path: "THE-path")
_similar_path = create(:group,
- path: 'not-really-the-path',
- parent: create(:group))
+ path: "not-really-the-path",
+ parent: create(:group))
namespace = create(:group,
- path: 'the-path',
- parent: create(:group))
+ path: "the-path",
+ parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :child)
- .map(&:id)
+ .map(&:id)
expect(found_ids).to contain_exactly(namespace.id)
end
end
- context 'for top levelnamespaces' do
- it 'only returns child namespaces with the correct path' do
- root_namespace = create(:group, path: 'the-path')
- _other_path = create(:group, path: 'other')
+ context "for top levelnamespaces" do
+ it "only returns child namespaces with the correct path" do
+ root_namespace = create(:group, path: "the-path")
+ _other_path = create(:group, path: "other")
_child_namespace = create(:group,
- path: 'the-path',
- parent: create(:group))
+ path: "the-path",
+ parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :top_level)
- .map(&:id)
+ .map(&:id)
expect(found_ids).to contain_exactly(root_namespace.id)
end
- it 'has no namespaces that just look the same' do
- root_namespace = create(:group, path: 'the-path')
- _similar_path = create(:group, path: 'not-really-the-path')
+ it "has no namespaces that just look the same" do
+ root_namespace = create(:group, path: "the-path")
+ _similar_path = create(:group, path: "not-really-the-path")
_child_namespace = create(:group,
- path: 'the-path',
- parent: create(:group))
+ path: "the-path",
+ parent: create(:group))
found_ids = subject.namespaces_for_paths(type: :top_level)
- .map(&:id)
+ .map(&:id)
expect(found_ids).to contain_exactly(root_namespace.id)
end
end
end
- describe '#move_repositories' do
- let(:namespace) { create(:group, name: 'hello-group') }
- it 'moves a project for a namespace' do
- create(:project, :repository, :legacy_storage, namespace: namespace, path: 'hello-project')
- expected_path = File.join(TestEnv.repos_path, 'bye-group', 'hello-project.git')
+ describe "#move_repositories" do
+ let(:namespace) { create(:group, name: "hello-group") }
+ it "moves a project for a namespace" do
+ create(:project, :repository, :legacy_storage, namespace: namespace, path: "hello-project")
+ expected_path = File.join(TestEnv.repos_path, "bye-group", "hello-project.git")
- subject.move_repositories(namespace, 'hello-group', 'bye-group')
+ subject.move_repositories(namespace, "hello-group", "bye-group")
expect(File.directory?(expected_path)).to be(true)
end
- it 'moves a namespace in a subdirectory correctly' do
- child_namespace = create(:group, name: 'sub-group', parent: namespace)
- create(:project, :repository, :legacy_storage, namespace: child_namespace, path: 'hello-project')
+ it "moves a namespace in a subdirectory correctly" do
+ child_namespace = create(:group, name: "sub-group", parent: namespace)
+ create(:project, :repository, :legacy_storage, namespace: child_namespace, path: "hello-project")
- expected_path = File.join(TestEnv.repos_path, 'hello-group', 'renamed-sub-group', 'hello-project.git')
+ expected_path = File.join(TestEnv.repos_path, "hello-group", "renamed-sub-group", "hello-project.git")
- subject.move_repositories(child_namespace, 'hello-group/sub-group', 'hello-group/renamed-sub-group')
+ subject.move_repositories(child_namespace, "hello-group/sub-group", "hello-group/renamed-sub-group")
expect(File.directory?(expected_path)).to be(true)
end
- it 'moves a parent namespace with subdirectories' do
- child_namespace = create(:group, name: 'sub-group', parent: namespace)
- create(:project, :repository, :legacy_storage, namespace: child_namespace, path: 'hello-project')
- expected_path = File.join(TestEnv.repos_path, 'renamed-group', 'sub-group', 'hello-project.git')
+ it "moves a parent namespace with subdirectories" do
+ child_namespace = create(:group, name: "sub-group", parent: namespace)
+ create(:project, :repository, :legacy_storage, namespace: child_namespace, path: "hello-project")
+ expected_path = File.join(TestEnv.repos_path, "renamed-group", "sub-group", "hello-project.git")
- subject.move_repositories(child_namespace, 'hello-group', 'renamed-group')
+ subject.move_repositories(child_namespace, "hello-group", "renamed-group")
expect(File.directory?(expected_path)).to be(true)
end
@@ -139,37 +139,37 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
end
describe "#rename_namespace" do
- it 'renames paths & routes for the namespace' do
+ it "renames paths & routes for the namespace" do
expect(subject).to receive(:rename_path_for_routable)
- .with(namespace)
- .and_call_original
+ .with(namespace)
+ .and_call_original
subject.rename_namespace(namespace)
- expect(namespace.reload.path).to eq('the-path0')
+ expect(namespace.reload.path).to eq("the-path0")
end
- it 'tracks the rename' do
+ it "tracks the rename" do
expect(subject).to receive(:track_rename)
- .with('namespace', 'the-path', 'the-path0')
+ .with("namespace", "the-path", "the-path0")
subject.rename_namespace(namespace)
end
- it 'renames things related to the namespace' do
+ it "renames things related to the namespace" do
expect(subject).to receive(:rename_namespace_dependencies)
- .with(namespace, 'the-path', 'the-path0')
+ .with(namespace, "the-path", "the-path0")
subject.rename_namespace(namespace)
end
end
- describe '#rename_namespace_dependencies' do
+ describe "#rename_namespace_dependencies" do
it "moves the repository for a project in the namespace" do
create(:project, :repository, :legacy_storage, namespace: namespace, path: "the-path-project")
expected_repo = File.join(TestEnv.repos_path, "the-path0", "the-path-project.git")
- subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(namespace, "the-path", "the-path0")
expect(File.directory?(expected_repo)).to be(true)
end
@@ -177,102 +177,102 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
it "moves the uploads for the namespace" do
expect(subject).to receive(:move_uploads).with("the-path", "the-path0")
- subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(namespace, "the-path", "the-path0")
end
it "moves the pages for the namespace" do
expect(subject).to receive(:move_pages).with("the-path", "the-path0")
- subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(namespace, "the-path", "the-path0")
end
- it 'invalidates the markdown cache of related projects' do
+ it "invalidates the markdown cache of related projects" do
project = create(:project, :legacy_storage, namespace: namespace, path: "the-path-project")
expect(subject).to receive(:remove_cached_html_for_projects).with([project.id])
- subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(namespace, "the-path", "the-path0")
end
it "doesn't rename users for other namespaces" do
expect(subject).not_to receive(:rename_user)
- subject.rename_namespace_dependencies(namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(namespace, "the-path", "the-path0")
end
- it 'renames the username of a namespace for a user' do
- user = create(:user, username: 'the-path')
+ it "renames the username of a namespace for a user" do
+ user = create(:user, username: "the-path")
- expect(subject).to receive(:rename_user).with('the-path', 'the-path0')
+ expect(subject).to receive(:rename_user).with("the-path", "the-path0")
- subject.rename_namespace_dependencies(user.namespace, 'the-path', 'the-path0')
+ subject.rename_namespace_dependencies(user.namespace, "the-path", "the-path0")
end
end
- describe '#rename_user' do
- it 'renames a username' do
+ describe "#rename_user" do
+ it "renames a username" do
subject = described_class.new([], migration)
- user = create(:user, username: 'broken')
+ user = create(:user, username: "broken")
- subject.rename_user('broken', 'broken0')
+ subject.rename_user("broken", "broken0")
- expect(user.reload.username).to eq('broken0')
+ expect(user.reload.username).to eq("broken0")
end
end
- describe '#rename_namespaces' do
- let!(:top_level_namespace) { create(:group, path: 'the-path') }
+ describe "#rename_namespaces" do
+ let!(:top_level_namespace) { create(:group, path: "the-path") }
let!(:child_namespace) do
- create(:group, path: 'the-path', parent: create(:group))
+ create(:group, path: "the-path", parent: create(:group))
end
- it 'renames top level namespaces the namespace' do
+ it "renames top level namespaces the namespace" do
expect(subject).to receive(:rename_namespace)
- .with(migration_namespace(top_level_namespace))
+ .with(migration_namespace(top_level_namespace))
subject.rename_namespaces(type: :top_level)
end
- it 'renames child namespaces' do
+ it "renames child namespaces" do
expect(subject).to receive(:rename_namespace)
- .with(migration_namespace(child_namespace))
+ .with(migration_namespace(child_namespace))
subject.rename_namespaces(type: :child)
end
end
- describe '#revert_renames', :redis do
- it 'renames the routes back to the previous values' do
- project = create(:project, :legacy_storage, :repository, path: 'a-project', namespace: namespace)
+ describe "#revert_renames", :redis do
+ it "renames the routes back to the previous values" do
+ project = create(:project, :legacy_storage, :repository, path: "a-project", namespace: namespace)
subject.rename_namespace(namespace)
expect(subject).to receive(:perform_rename)
- .with(
- kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Namespace),
- 'the-path0',
- 'the-path'
- ).and_call_original
+ .with(
+ kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Namespace),
+ "the-path0",
+ "the-path"
+ ).and_call_original
subject.revert_renames
- expect(namespace.reload.path).to eq('the-path')
- expect(namespace.reload.route.path).to eq('the-path')
- expect(project.reload.route.path).to eq('the-path/a-project')
+ expect(namespace.reload.path).to eq("the-path")
+ expect(namespace.reload.route.path).to eq("the-path")
+ expect(project.reload.route.path).to eq("the-path/a-project")
end
- it 'moves the repositories back to their original place' do
- project = create(:project, :repository, :legacy_storage, path: 'a-project', namespace: namespace)
+ it "moves the repositories back to their original place" do
+ project = create(:project, :repository, :legacy_storage, path: "a-project", namespace: namespace)
project.create_repository
subject.rename_namespace(namespace)
- expected_path = File.join(TestEnv.repos_path, 'the-path', 'a-project.git')
+ expected_path = File.join(TestEnv.repos_path, "the-path", "a-project.git")
expect(subject).to receive(:rename_namespace_dependencies)
- .with(
- kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Namespace),
- 'the-path0',
- 'the-path'
- ).and_call_original
+ .with(
+ kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Namespace),
+ "the-path0",
+ "the-path"
+ ).and_call_original
subject.revert_renames
@@ -281,7 +281,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameNamespaces, :
it "doesn't break when the namespace was renamed" do
subject.rename_namespace(namespace)
- namespace.update!(path: 'renamed-afterwards')
+ namespace.update!(path: "renamed-afterwards")
expect { subject.revert_renames }.not_to raise_error
end
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb
index d4d7a83921c..dd383a6d693 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1/rename_projects_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :delete do
let(:migration) { FakeRenameReservedPathMigrationV1.new }
- let(:subject) { described_class.new(['the-path'], migration) }
+ let(:subject) { described_class.new(["the-path"], migration) }
let(:project) do
create(:project,
- :legacy_storage,
- path: 'the-path',
- namespace: create(:namespace, path: 'known-parent' ))
+ :legacy_storage,
+ path: "the-path",
+ namespace: create(:namespace, path: "known-parent"))
end
before do
@@ -15,19 +15,19 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :de
TestEnv.clean_test_path
end
- describe '#projects_for_paths' do
- it 'searches using nested paths' do
- namespace = create(:namespace, path: 'hello')
- project = create(:project, :legacy_storage, path: 'THE-path', namespace: namespace)
+ describe "#projects_for_paths" do
+ it "searches using nested paths" do
+ namespace = create(:namespace, path: "hello")
+ project = create(:project, :legacy_storage, path: "THE-path", namespace: namespace)
- result_ids = described_class.new(['Hello/the-path'], migration)
- .projects_for_paths.map(&:id)
+ result_ids = described_class.new(["Hello/the-path"], migration)
+ .projects_for_paths.map(&:id)
expect(result_ids).to contain_exactly(project.id)
end
- it 'includes the correct projects' do
- project = create(:project, :legacy_storage, path: 'THE-path')
+ it "includes the correct projects" do
+ project = create(:project, :legacy_storage, path: "THE-path")
_other_project = create(:project, :legacy_storage)
result_ids = subject.projects_for_paths.map(&:id)
@@ -36,131 +36,131 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :de
end
end
- describe '#rename_projects' do
- let!(:projects) { create_list(:project, 2, :legacy_storage, path: 'the-path') }
+ describe "#rename_projects" do
+ let!(:projects) { create_list(:project, 2, :legacy_storage, path: "the-path") }
- it 'renames each project' do
+ it "renames each project" do
expect(subject).to receive(:rename_project).twice
subject.rename_projects
end
- it 'invalidates the markdown cache of related projects' do
+ it "invalidates the markdown cache of related projects" do
expect(subject).to receive(:remove_cached_html_for_projects)
- .with(projects.map(&:id))
+ .with(projects.map(&:id))
subject.rename_projects
end
end
- describe '#rename_project' do
- it 'renames path & route for the project' do
+ describe "#rename_project" do
+ it "renames path & route for the project" do
expect(subject).to receive(:rename_path_for_routable)
- .with(project)
- .and_call_original
+ .with(project)
+ .and_call_original
subject.rename_project(project)
- expect(project.reload.path).to eq('the-path0')
+ expect(project.reload.path).to eq("the-path0")
end
- it 'tracks the rename' do
+ it "tracks the rename" do
expect(subject).to receive(:track_rename)
- .with('project', 'known-parent/the-path', 'known-parent/the-path0')
+ .with("project", "known-parent/the-path", "known-parent/the-path0")
subject.rename_project(project)
end
- it 'renames the folders for the project' do
- expect(subject).to receive(:move_project_folders).with(project, 'known-parent/the-path', 'known-parent/the-path0')
+ it "renames the folders for the project" do
+ expect(subject).to receive(:move_project_folders).with(project, "known-parent/the-path", "known-parent/the-path0")
subject.rename_project(project)
end
end
- describe '#move_project_folders' do
- it 'moves the wiki & the repo' do
+ describe "#move_project_folders" do
+ it "moves the wiki & the repo" do
expect(subject).to receive(:move_repository)
- .with(project, 'known-parent/the-path.wiki', 'known-parent/the-path0.wiki')
+ .with(project, "known-parent/the-path.wiki", "known-parent/the-path0.wiki")
expect(subject).to receive(:move_repository)
- .with(project, 'known-parent/the-path', 'known-parent/the-path0')
+ .with(project, "known-parent/the-path", "known-parent/the-path0")
- subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
+ subject.move_project_folders(project, "known-parent/the-path", "known-parent/the-path0")
end
- it 'does not move the repositories when hashed storage is enabled' do
+ it "does not move the repositories when hashed storage is enabled" do
project.update!(storage_version: Project::HASHED_STORAGE_FEATURES[:repository])
expect(subject).not_to receive(:move_repository)
- subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
+ subject.move_project_folders(project, "known-parent/the-path", "known-parent/the-path0")
end
- it 'moves uploads' do
+ it "moves uploads" do
expect(subject).to receive(:move_uploads)
- .with('known-parent/the-path', 'known-parent/the-path0')
+ .with("known-parent/the-path", "known-parent/the-path0")
- subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
+ subject.move_project_folders(project, "known-parent/the-path", "known-parent/the-path0")
end
- it 'does not move uploads when hashed storage is enabled for attachments' do
+ it "does not move uploads when hashed storage is enabled for attachments" do
project.update!(storage_version: Project::HASHED_STORAGE_FEATURES[:attachments])
expect(subject).not_to receive(:move_uploads)
- subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
+ subject.move_project_folders(project, "known-parent/the-path", "known-parent/the-path0")
end
- it 'moves pages' do
+ it "moves pages" do
expect(subject).to receive(:move_pages)
- .with('known-parent/the-path', 'known-parent/the-path0')
+ .with("known-parent/the-path", "known-parent/the-path0")
- subject.move_project_folders(project, 'known-parent/the-path', 'known-parent/the-path0')
+ subject.move_project_folders(project, "known-parent/the-path", "known-parent/the-path0")
end
end
- describe '#move_repository' do
- let(:known_parent) { create(:namespace, path: 'known-parent') }
- let(:project) { create(:project, :repository, :legacy_storage, path: 'the-path', namespace: known_parent) }
+ describe "#move_repository" do
+ let(:known_parent) { create(:namespace, path: "known-parent") }
+ let(:project) { create(:project, :repository, :legacy_storage, path: "the-path", namespace: known_parent) }
- it 'moves the repository for a project' do
- expected_path = File.join(TestEnv.repos_path, 'known-parent', 'new-repo.git')
+ it "moves the repository for a project" do
+ expected_path = File.join(TestEnv.repos_path, "known-parent", "new-repo.git")
- subject.move_repository(project, 'known-parent/the-path', 'known-parent/new-repo')
+ subject.move_repository(project, "known-parent/the-path", "known-parent/new-repo")
expect(File.directory?(expected_path)).to be(true)
end
end
- describe '#revert_renames', :redis do
- it 'renames the routes back to the previous values' do
+ describe "#revert_renames", :redis do
+ it "renames the routes back to the previous values" do
subject.rename_project(project)
expect(subject).to receive(:perform_rename)
- .with(
- kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Project),
- 'known-parent/the-path0',
- 'known-parent/the-path'
- ).and_call_original
+ .with(
+ kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Project),
+ "known-parent/the-path0",
+ "known-parent/the-path"
+ ).and_call_original
subject.revert_renames
- expect(project.reload.path).to eq('the-path')
- expect(project.route.path).to eq('known-parent/the-path')
+ expect(project.reload.path).to eq("the-path")
+ expect(project.route.path).to eq("known-parent/the-path")
end
- it 'moves the repositories back to their original place' do
+ it "moves the repositories back to their original place" do
project.create_repository
subject.rename_project(project)
- expected_path = File.join(TestEnv.repos_path, 'known-parent', 'the-path.git')
+ expected_path = File.join(TestEnv.repos_path, "known-parent", "the-path.git")
expect(subject).to receive(:move_project_folders)
- .with(
- kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Project),
- 'known-parent/the-path0',
- 'known-parent/the-path'
- ).and_call_original
+ .with(
+ kind_of(Gitlab::Database::RenameReservedPathsMigration::V1::MigrationClasses::Project),
+ "known-parent/the-path0",
+ "known-parent/the-path"
+ ).and_call_original
subject.revert_renames
@@ -169,7 +169,7 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1::RenameProjects, :de
it "doesn't break when the project was renamed" do
subject.rename_project(project)
- project.update!(path: 'renamed-afterwards')
+ project.update!(path: "renamed-afterwards")
expect { subject.revert_renames }.not_to raise_error
end
diff --git a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
index 1d31f96159c..bd02c340547 100644
--- a/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
+++ b/spec/lib/gitlab/database/rename_reserved_paths_migration/v1_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'renames child namespaces' do |type|
- it 'renames namespaces' do
+shared_examples "renames child namespaces" do |type|
+ it "renames namespaces" do
rename_namespaces = double
expect(described_class::RenameNamespaces)
- .to receive(:new).with(['first-path', 'second-path'], subject)
- .and_return(rename_namespaces)
+ .to receive(:new).with(["first-path", "second-path"], subject)
+ .and_return(rename_namespaces)
expect(rename_namespaces).to receive(:rename_namespaces)
- .with(type: :child)
+ .with(type: :child)
- subject.rename_wildcard_paths(['first-path', 'second-path'])
+ subject.rename_wildcard_paths(["first-path", "second-path"])
end
end
@@ -20,54 +20,54 @@ describe Gitlab::Database::RenameReservedPathsMigration::V1, :delete do
allow(subject).to receive(:say)
end
- describe '#rename_child_paths' do
- it_behaves_like 'renames child namespaces'
+ describe "#rename_child_paths" do
+ it_behaves_like "renames child namespaces"
end
- describe '#rename_wildcard_paths' do
- it_behaves_like 'renames child namespaces'
+ describe "#rename_wildcard_paths" do
+ it_behaves_like "renames child namespaces"
- it 'should rename projects' do
+ it "should rename projects" do
rename_projects = double
expect(described_class::RenameProjects)
- .to receive(:new).with(['the-path'], subject)
- .and_return(rename_projects)
+ .to receive(:new).with(["the-path"], subject)
+ .and_return(rename_projects)
expect(rename_projects).to receive(:rename_projects)
- subject.rename_wildcard_paths(['the-path'])
+ subject.rename_wildcard_paths(["the-path"])
end
end
- describe '#rename_root_paths' do
- it 'should rename namespaces' do
+ describe "#rename_root_paths" do
+ it "should rename namespaces" do
rename_namespaces = double
expect(described_class::RenameNamespaces)
- .to receive(:new).with(['the-path'], subject)
- .and_return(rename_namespaces)
+ .to receive(:new).with(["the-path"], subject)
+ .and_return(rename_namespaces)
expect(rename_namespaces).to receive(:rename_namespaces)
- .with(type: :top_level)
+ .with(type: :top_level)
- subject.rename_root_paths('the-path')
+ subject.rename_root_paths("the-path")
end
end
- describe '#revert_renames' do
- it 'renames namespaces' do
+ describe "#revert_renames" do
+ it "renames namespaces" do
rename_namespaces = double
expect(described_class::RenameNamespaces)
.to receive(:new).with([], subject)
- .and_return(rename_namespaces)
+ .and_return(rename_namespaces)
expect(rename_namespaces).to receive(:revert_renames)
subject.revert_renames
end
- it 'renames projects' do
+ it "renames projects" do
rename_projects = double
expect(described_class::RenameProjects)
.to receive(:new).with([], subject)
- .and_return(rename_projects)
+ .and_return(rename_projects)
expect(rename_projects).to receive(:revert_renames)
subject.revert_renames
diff --git a/spec/lib/gitlab/database/sha_attribute_spec.rb b/spec/lib/gitlab/database/sha_attribute_spec.rb
index 778bfa2cc47..54d7bc6dbde 100644
--- a/spec/lib/gitlab/database/sha_attribute_spec.rb
+++ b/spec/lib/gitlab/database/sha_attribute_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database::ShaAttribute do
let(:sha) do
- '9a573a369a5bfbb9a4a36e98852c21af8a44ea8b'
+ "9a573a369a5bfbb9a4a36e98852c21af8a44ea8b"
end
let(:binary_sha) do
- [sha].pack('H*')
+ [sha].pack("H*")
end
let(:binary_from_db) do
@@ -19,14 +19,14 @@ describe Gitlab::Database::ShaAttribute do
let(:attribute) { described_class.new }
- describe '#deserialize' do
- it 'converts the binary SHA to a String' do
+ describe "#deserialize" do
+ it "converts the binary SHA to a String" do
expect(attribute.deserialize(binary_from_db)).to eq(sha)
end
end
- describe '#serialize' do
- it 'converts a SHA String to binary data' do
+ describe "#serialize" do
+ it "converts a SHA String to binary data" do
expect(attribute.serialize(sha).to_s).to eq(binary_sha)
end
end
diff --git a/spec/lib/gitlab/database/subquery_spec.rb b/spec/lib/gitlab/database/subquery_spec.rb
index 70380e02f16..81aae8bbb4c 100644
--- a/spec/lib/gitlab/database/subquery_spec.rb
+++ b/spec/lib/gitlab/database/subquery_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
RSpec.describe Gitlab::Database::Subquery do
- describe '.self_join' do
+ describe ".self_join" do
set(:project) { create(:project) }
- it 'allows you to delete_all rows with WHERE and LIMIT' do
+ it "allows you to delete_all rows with WHERE and LIMIT" do
events = create_list(:event, 8, project: project)
- expect do
- described_class.self_join(Event.where('id < ?', events[5]).recent.limit(2)).delete_all
- end.to change { Event.count }.by(-2)
+ expect {
+ described_class.self_join(Event.where("id < ?", events[5]).recent.limit(2)).delete_all
+ }.to change { Event.count }.by(-2)
end
end
end
diff --git a/spec/lib/gitlab/database_spec.rb b/spec/lib/gitlab/database_spec.rb
index 60106ee3c0b..369c7807252 100644
--- a/spec/lib/gitlab/database_spec.rb
+++ b/spec/lib/gitlab/database_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Database do
before do
- stub_const('MigrationTest', Class.new { include Gitlab::Database })
+ stub_const("MigrationTest", Class.new { include Gitlab::Database })
end
- describe '.config' do
- it 'returns a Hash' do
+ describe ".config" do
+ it "returns a Hash" do
expect(described_class.config).to be_an_instance_of(Hash)
end
end
- describe '.adapter_name' do
- it 'returns the name of the adapter' do
+ describe ".adapter_name" do
+ it "returns the name of the adapter" do
expect(described_class.adapter_name).to be_an_instance_of(String)
end
end
# These are just simple smoke tests to check if the methods work (regardless
# of what they may return).
- describe '.mysql?' do
+ describe ".mysql?" do
subject { described_class.mysql? }
it { is_expected.to satisfy { |val| val == true || val == false } }
end
- describe '.postgresql?' do
+ describe ".postgresql?" do
subject { described_class.postgresql? }
it { is_expected.to satisfy { |val| val == true || val == false } }
end
- describe '.version' do
+ describe ".version" do
around do |example|
described_class.instance_variable_set(:@version, nil)
example.run
@@ -43,7 +43,7 @@ describe Gitlab::Database do
allow(described_class).to receive(:database_version)
.and_return("5.7.12-standard")
- expect(described_class.version).to eq '5.7.12-standard'
+ expect(described_class.version).to eq "5.7.12-standard"
end
end
@@ -52,11 +52,11 @@ describe Gitlab::Database do
allow(described_class).to receive(:database_version)
.and_return("PostgreSQL 9.4.4 on x86_64-apple-darwin14.3.0")
- expect(described_class.version).to eq '9.4.4'
+ expect(described_class.version).to eq "9.4.4"
end
end
- it 'memoizes the result' do
+ it "memoizes the result" do
count = ActiveRecord::QueryRecorder
.new { 2.times { described_class.version } }
.count
@@ -65,183 +65,183 @@ describe Gitlab::Database do
end
end
- describe '.postgresql_9_or_less?' do
- it 'returns false when using MySQL' do
+ describe ".postgresql_9_or_less?" do
+ it "returns false when using MySQL" do
allow(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.postgresql_9_or_less?).to eq(false)
end
- it 'returns true when using PostgreSQL 9.6' do
+ it "returns true when using PostgreSQL 9.6" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.6')
+ allow(described_class).to receive(:version).and_return("9.6")
expect(described_class.postgresql_9_or_less?).to eq(true)
end
- it 'returns false when using PostgreSQL 10 or newer' do
+ it "returns false when using PostgreSQL 10 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('10')
+ allow(described_class).to receive(:version).and_return("10")
expect(described_class.postgresql_9_or_less?).to eq(false)
end
end
- describe '.join_lateral_supported?' do
- it 'returns false when using MySQL' do
+ describe ".join_lateral_supported?" do
+ it "returns false when using MySQL" do
allow(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.join_lateral_supported?).to eq(false)
end
- it 'returns false when using PostgreSQL 9.2' do
+ it "returns false when using PostgreSQL 9.2" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.2.1')
+ allow(described_class).to receive(:version).and_return("9.2.1")
expect(described_class.join_lateral_supported?).to eq(false)
end
- it 'returns true when using PostgreSQL 9.3.0 or newer' do
+ it "returns true when using PostgreSQL 9.3.0 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.3.0')
+ allow(described_class).to receive(:version).and_return("9.3.0")
expect(described_class.join_lateral_supported?).to eq(true)
end
end
- describe '.replication_slots_supported?' do
- it 'returns false when using MySQL' do
+ describe ".replication_slots_supported?" do
+ it "returns false when using MySQL" do
allow(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.replication_slots_supported?).to eq(false)
end
- it 'returns false when using PostgreSQL 9.3' do
+ it "returns false when using PostgreSQL 9.3" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.3.1')
+ allow(described_class).to receive(:version).and_return("9.3.1")
expect(described_class.replication_slots_supported?).to eq(false)
end
- it 'returns true when using PostgreSQL 9.4.0 or newer' do
+ it "returns true when using PostgreSQL 9.4.0 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.4.0')
+ allow(described_class).to receive(:version).and_return("9.4.0")
expect(described_class.replication_slots_supported?).to eq(true)
end
end
- describe '.pg_wal_lsn_diff' do
- it 'returns old name when using PostgreSQL 9.6' do
+ describe ".pg_wal_lsn_diff" do
+ it "returns old name when using PostgreSQL 9.6" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.6')
+ allow(described_class).to receive(:version).and_return("9.6")
- expect(described_class.pg_wal_lsn_diff).to eq('pg_xlog_location_diff')
+ expect(described_class.pg_wal_lsn_diff).to eq("pg_xlog_location_diff")
end
- it 'returns new name when using PostgreSQL 10 or newer' do
+ it "returns new name when using PostgreSQL 10 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('10')
+ allow(described_class).to receive(:version).and_return("10")
- expect(described_class.pg_wal_lsn_diff).to eq('pg_wal_lsn_diff')
+ expect(described_class.pg_wal_lsn_diff).to eq("pg_wal_lsn_diff")
end
end
- describe '.pg_current_wal_insert_lsn' do
- it 'returns old name when using PostgreSQL 9.6' do
+ describe ".pg_current_wal_insert_lsn" do
+ it "returns old name when using PostgreSQL 9.6" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.6')
+ allow(described_class).to receive(:version).and_return("9.6")
- expect(described_class.pg_current_wal_insert_lsn).to eq('pg_current_xlog_insert_location')
+ expect(described_class.pg_current_wal_insert_lsn).to eq("pg_current_xlog_insert_location")
end
- it 'returns new name when using PostgreSQL 10 or newer' do
+ it "returns new name when using PostgreSQL 10 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('10')
+ allow(described_class).to receive(:version).and_return("10")
- expect(described_class.pg_current_wal_insert_lsn).to eq('pg_current_wal_insert_lsn')
+ expect(described_class.pg_current_wal_insert_lsn).to eq("pg_current_wal_insert_lsn")
end
end
- describe '.pg_last_wal_receive_lsn' do
- it 'returns old name when using PostgreSQL 9.6' do
+ describe ".pg_last_wal_receive_lsn" do
+ it "returns old name when using PostgreSQL 9.6" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.6')
+ allow(described_class).to receive(:version).and_return("9.6")
- expect(described_class.pg_last_wal_receive_lsn).to eq('pg_last_xlog_receive_location')
+ expect(described_class.pg_last_wal_receive_lsn).to eq("pg_last_xlog_receive_location")
end
- it 'returns new name when using PostgreSQL 10 or newer' do
+ it "returns new name when using PostgreSQL 10 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('10')
+ allow(described_class).to receive(:version).and_return("10")
- expect(described_class.pg_last_wal_receive_lsn).to eq('pg_last_wal_receive_lsn')
+ expect(described_class.pg_last_wal_receive_lsn).to eq("pg_last_wal_receive_lsn")
end
end
- describe '.pg_last_wal_replay_lsn' do
- it 'returns old name when using PostgreSQL 9.6' do
+ describe ".pg_last_wal_replay_lsn" do
+ it "returns old name when using PostgreSQL 9.6" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('9.6')
+ allow(described_class).to receive(:version).and_return("9.6")
- expect(described_class.pg_last_wal_replay_lsn).to eq('pg_last_xlog_replay_location')
+ expect(described_class.pg_last_wal_replay_lsn).to eq("pg_last_xlog_replay_location")
end
- it 'returns new name when using PostgreSQL 10 or newer' do
+ it "returns new name when using PostgreSQL 10 or newer" do
allow(described_class).to receive(:postgresql?).and_return(true)
- allow(described_class).to receive(:version).and_return('10')
+ allow(described_class).to receive(:version).and_return("10")
- expect(described_class.pg_last_wal_replay_lsn).to eq('pg_last_wal_replay_lsn')
+ expect(described_class.pg_last_wal_replay_lsn).to eq("pg_last_wal_replay_lsn")
end
end
- describe '.nulls_last_order' do
- context 'when using PostgreSQL' do
+ describe ".nulls_last_order" do
+ context "when using PostgreSQL" do
before do
expect(described_class).to receive(:postgresql?).and_return(true)
end
- it { expect(described_class.nulls_last_order('column', 'ASC')).to eq 'column ASC NULLS LAST'}
- it { expect(described_class.nulls_last_order('column', 'DESC')).to eq 'column DESC NULLS LAST'}
+ it { expect(described_class.nulls_last_order("column", "ASC")).to eq "column ASC NULLS LAST"}
+ it { expect(described_class.nulls_last_order("column", "DESC")).to eq "column DESC NULLS LAST"}
end
- context 'when using MySQL' do
+ context "when using MySQL" do
before do
expect(described_class).to receive(:postgresql?).and_return(false)
end
- it { expect(described_class.nulls_last_order('column', 'ASC')).to eq 'column IS NULL, column ASC'}
- it { expect(described_class.nulls_last_order('column', 'DESC')).to eq 'column DESC'}
+ it { expect(described_class.nulls_last_order("column", "ASC")).to eq "column IS NULL, column ASC"}
+ it { expect(described_class.nulls_last_order("column", "DESC")).to eq "column DESC"}
end
end
- describe '.nulls_first_order' do
- context 'when using PostgreSQL' do
+ describe ".nulls_first_order" do
+ context "when using PostgreSQL" do
before do
expect(described_class).to receive(:postgresql?).and_return(true)
end
- it { expect(described_class.nulls_first_order('column', 'ASC')).to eq 'column ASC NULLS FIRST'}
- it { expect(described_class.nulls_first_order('column', 'DESC')).to eq 'column DESC NULLS FIRST'}
+ it { expect(described_class.nulls_first_order("column", "ASC")).to eq "column ASC NULLS FIRST"}
+ it { expect(described_class.nulls_first_order("column", "DESC")).to eq "column DESC NULLS FIRST"}
end
- context 'when using MySQL' do
+ context "when using MySQL" do
before do
expect(described_class).to receive(:postgresql?).and_return(false)
end
- it { expect(described_class.nulls_first_order('column', 'ASC')).to eq 'column ASC'}
- it { expect(described_class.nulls_first_order('column', 'DESC')).to eq 'column IS NULL, column DESC'}
+ it { expect(described_class.nulls_first_order("column", "ASC")).to eq "column ASC"}
+ it { expect(described_class.nulls_first_order("column", "DESC")).to eq "column IS NULL, column DESC"}
end
end
- describe '.with_connection_pool' do
- it 'creates a new connection pool and disconnect it after used' do
+ describe ".with_connection_pool" do
+ it "creates a new connection pool and disconnect it after used" do
closed_pool = nil
described_class.with_connection_pool(1) do |pool|
pool.with_connection do |connection|
- connection.execute('SELECT 1 AS value')
+ connection.execute("SELECT 1 AS value")
end
expect(pool).to be_connected
@@ -252,19 +252,19 @@ describe Gitlab::Database do
expect(closed_pool).not_to be_connected
end
- it 'disconnects the pool even an exception was raised' do
+ it "disconnects the pool even an exception was raised" do
error = Class.new(RuntimeError)
closed_pool = nil
begin
described_class.with_connection_pool(1) do |pool|
pool.with_connection do |connection|
- connection.execute('SELECT 1 AS value')
+ connection.execute("SELECT 1 AS value")
end
closed_pool = pool
- raise error.new('boom')
+ raise error.new("boom")
end
rescue error
end
@@ -273,7 +273,7 @@ describe Gitlab::Database do
end
end
- describe '.bulk_insert' do
+ describe ".bulk_insert" do
before do
allow(described_class).to receive(:connection).and_return(connection)
allow(connection).to receive(:quote_column_name, &:itself)
@@ -285,69 +285,69 @@ describe Gitlab::Database do
let(:rows) do
[
- { a: 1, b: 2, c: 3 },
- { c: 6, a: 4, b: 5 }
+ {a: 1, b: 2, c: 3},
+ {c: 6, a: 4, b: 5},
]
end
- it 'does nothing with empty rows' do
+ it "does nothing with empty rows" do
expect(connection).not_to receive(:execute)
- described_class.bulk_insert('test', [])
+ described_class.bulk_insert("test", [])
end
- it 'uses the ordering from the first row' do
+ it "uses the ordering from the first row" do
expect(connection).to receive(:execute) do |sql|
- expect(sql).to include('(1, 2, 3)')
- expect(sql).to include('(4, 5, 6)')
+ expect(sql).to include("(1, 2, 3)")
+ expect(sql).to include("(4, 5, 6)")
end
- described_class.bulk_insert('test', rows)
+ described_class.bulk_insert("test", rows)
end
- it 'quotes column names' do
+ it "quotes column names" do
expect(connection).to receive(:quote_column_name).with(:a)
expect(connection).to receive(:quote_column_name).with(:b)
expect(connection).to receive(:quote_column_name).with(:c)
- described_class.bulk_insert('test', rows)
+ described_class.bulk_insert("test", rows)
end
- it 'quotes values' do
+ it "quotes values" do
1.upto(6) do |i|
expect(connection).to receive(:quote).with(i)
end
- described_class.bulk_insert('test', rows)
+ described_class.bulk_insert("test", rows)
end
- it 'does not quote values of a column in the disable_quote option' do
+ it "does not quote values of a column in the disable_quote option" do
[1, 2, 4, 5].each do |i|
expect(connection).to receive(:quote).with(i)
end
- described_class.bulk_insert('test', rows, disable_quote: :c)
+ described_class.bulk_insert("test", rows, disable_quote: :c)
end
- it 'does not quote values of columns in the disable_quote option' do
+ it "does not quote values of columns in the disable_quote option" do
[2, 5].each do |i|
expect(connection).to receive(:quote).with(i)
end
- described_class.bulk_insert('test', rows, disable_quote: [:a, :c])
+ described_class.bulk_insert("test", rows, disable_quote: [:a, :c])
end
- it 'handles non-UTF-8 data' do
- expect { described_class.bulk_insert('test', [{ a: "\255" }]) }.not_to raise_error
+ it "handles non-UTF-8 data" do
+ expect { described_class.bulk_insert("test", [{a: "\255"}]) }.not_to raise_error
end
- context 'when using PostgreSQL' do
+ context "when using PostgreSQL" do
before do
allow(described_class).to receive(:mysql?).and_return(false)
end
- it 'allows the returning of the IDs of the inserted rows' do
- result = double(:result, values: [['10']])
+ it "allows the returning of the IDs of the inserted rows" do
+ result = double(:result, values: [["10"]])
expect(connection)
.to receive(:execute)
@@ -355,15 +355,15 @@ describe Gitlab::Database do
.and_return(result)
ids = described_class
- .bulk_insert('test', [{ number: 10 }], return_ids: true)
+ .bulk_insert("test", [{number: 10}], return_ids: true)
expect(ids).to eq([10])
end
end
end
- describe '.create_connection_pool' do
- it 'creates a new connection pool with specific pool size' do
+ describe ".create_connection_pool" do
+ it "creates a new connection pool with specific pool size" do
pool = described_class.create_connection_pool(5)
begin
@@ -376,19 +376,19 @@ describe Gitlab::Database do
end
end
- it 'allows setting of a custom hostname' do
- pool = described_class.create_connection_pool(5, '127.0.0.1')
+ it "allows setting of a custom hostname" do
+ pool = described_class.create_connection_pool(5, "127.0.0.1")
begin
- expect(pool.spec.config[:host]).to eq('127.0.0.1')
+ expect(pool.spec.config[:host]).to eq("127.0.0.1")
ensure
pool.disconnect!
end
end
end
- describe '.cached_column_exists?' do
- it 'only retrieves data once' do
+ describe ".cached_column_exists?" do
+ it "only retrieves data once" do
expect(ActiveRecord::Base.connection).to receive(:columns).once.and_call_original
2.times do
@@ -398,8 +398,8 @@ describe Gitlab::Database do
end
end
- describe '.cached_table_exists?' do
- it 'only retrieves data once per table' do
+ describe ".cached_table_exists?" do
+ it "only retrieves data once per table" do
expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:projects).once.and_call_original
expect(ActiveRecord::Base.connection).to receive(:data_source_exists?).with(:bogus_table_name).once.and_call_original
@@ -410,73 +410,73 @@ describe Gitlab::Database do
end
end
- describe '#true_value' do
- it 'returns correct value for PostgreSQL' do
+ describe "#true_value" do
+ it "returns correct value for PostgreSQL" do
expect(described_class).to receive(:postgresql?).and_return(true)
expect(described_class.true_value).to eq "'t'"
end
- it 'returns correct value for MySQL' do
+ it "returns correct value for MySQL" do
expect(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.true_value).to eq 1
end
end
- describe '#false_value' do
- it 'returns correct value for PostgreSQL' do
+ describe "#false_value" do
+ it "returns correct value for PostgreSQL" do
expect(described_class).to receive(:postgresql?).and_return(true)
expect(described_class.false_value).to eq "'f'"
end
- it 'returns correct value for MySQL' do
+ it "returns correct value for MySQL" do
expect(described_class).to receive(:postgresql?).and_return(false)
expect(described_class.false_value).to eq 0
end
end
- describe '.read_only?' do
- it 'returns false' do
+ describe ".read_only?" do
+ it "returns false" do
expect(described_class.read_only?).to be_falsey
end
end
- describe '.db_read_only?' do
- context 'when using PostgreSQL' do
+ describe ".db_read_only?" do
+ context "when using PostgreSQL" do
before do
allow(ActiveRecord::Base.connection).to receive(:execute).and_call_original
allow(described_class).to receive(:postgresql?).and_return(true)
end
- it 'detects a read only database' do
- allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "t" }])
+ it "detects a read only database" do
+ allow(ActiveRecord::Base.connection).to receive(:execute).with("SELECT pg_is_in_recovery()").and_return([{"pg_is_in_recovery" => "t"}])
expect(described_class.db_read_only?).to be_truthy
end
- it 'detects a read only database' do
- allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => true }])
+ it "detects a read only database" do
+ allow(ActiveRecord::Base.connection).to receive(:execute).with("SELECT pg_is_in_recovery()").and_return([{"pg_is_in_recovery" => true}])
expect(described_class.db_read_only?).to be_truthy
end
- it 'detects a read write database' do
- allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => "f" }])
+ it "detects a read write database" do
+ allow(ActiveRecord::Base.connection).to receive(:execute).with("SELECT pg_is_in_recovery()").and_return([{"pg_is_in_recovery" => "f"}])
expect(described_class.db_read_only?).to be_falsey
end
- it 'detects a read write database' do
- allow(ActiveRecord::Base.connection).to receive(:execute).with('SELECT pg_is_in_recovery()').and_return([{ "pg_is_in_recovery" => false }])
+ it "detects a read write database" do
+ allow(ActiveRecord::Base.connection).to receive(:execute).with("SELECT pg_is_in_recovery()").and_return([{"pg_is_in_recovery" => false}])
expect(described_class.db_read_only?).to be_falsey
end
end
- context 'when using MySQL' do
+ context "when using MySQL" do
before do
expect(described_class).to receive(:postgresql?).and_return(false)
end
@@ -485,23 +485,23 @@ describe Gitlab::Database do
end
end
- describe '#sanitize_timestamp' do
+ describe "#sanitize_timestamp" do
let(:max_timestamp) { Time.at((1 << 31) - 1) }
subject { described_class.sanitize_timestamp(timestamp) }
- context 'with a timestamp smaller than MAX_TIMESTAMP_VALUE' do
+ context "with a timestamp smaller than MAX_TIMESTAMP_VALUE" do
let(:timestamp) { max_timestamp - 10.years }
- it 'returns the given timestamp' do
+ it "returns the given timestamp" do
expect(subject).to eq(timestamp)
end
end
- context 'with a timestamp larger than MAX_TIMESTAMP_VALUE' do
+ context "with a timestamp larger than MAX_TIMESTAMP_VALUE" do
let(:timestamp) { max_timestamp + 1.second }
- it 'returns MAX_TIMESTAMP_VALUE' do
+ it "returns MAX_TIMESTAMP_VALUE" do
expect(subject).to eq(max_timestamp)
end
end
diff --git a/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb
index 3a93d5e1e97..ee16f8d0402 100644
--- a/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/cartfile_linker_spec.rb
@@ -1,21 +1,21 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::CartfileLinker do
- describe '.support?' do
- it 'supports Cartfile' do
- expect(described_class.support?('Cartfile')).to be_truthy
+ describe ".support?" do
+ it "supports Cartfile" do
+ expect(described_class.support?("Cartfile")).to be_truthy
end
- it 'supports Cartfile.private' do
- expect(described_class.support?('Cartfile.private')).to be_truthy
+ it "supports Cartfile.private" do
+ expect(described_class.support?("Cartfile.private")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('test.Cartfile')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("test.Cartfile")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "Cartfile" }
let(:file_content) do
@@ -52,23 +52,23 @@ describe Gitlab::DependencyLinker::CartfileLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links dependencies' do
- expect(subject).to include(link('ReactiveCocoa/ReactiveCocoa', 'https://github.com/ReactiveCocoa/ReactiveCocoa'))
- expect(subject).to include(link('Mantle/Mantle', 'https://github.com/Mantle/Mantle'))
- expect(subject).to include(link('jspahrsummers/libextobjc', 'https://github.com/jspahrsummers/libextobjc'))
- expect(subject).to include(link('jspahrsummers/xcconfigs', 'https://github.com/jspahrsummers/xcconfigs'))
+ it "links dependencies" do
+ expect(subject).to include(link("ReactiveCocoa/ReactiveCocoa", "https://github.com/ReactiveCocoa/ReactiveCocoa"))
+ expect(subject).to include(link("Mantle/Mantle", "https://github.com/Mantle/Mantle"))
+ expect(subject).to include(link("jspahrsummers/libextobjc", "https://github.com/jspahrsummers/libextobjc"))
+ expect(subject).to include(link("jspahrsummers/xcconfigs", "https://github.com/jspahrsummers/xcconfigs"))
end
- it 'links Git repos' do
- expect(subject).to include(link('https://enterprise.local/ghe/desktop/git-error-translations', 'https://enterprise.local/ghe/desktop/git-error-translations'))
- expect(subject).to include(link('https://enterprise.local/desktop/git-error-translations2.git', 'https://enterprise.local/desktop/git-error-translations2.git'))
+ it "links Git repos" do
+ expect(subject).to include(link("https://enterprise.local/ghe/desktop/git-error-translations", "https://enterprise.local/ghe/desktop/git-error-translations"))
+ expect(subject).to include(link("https://enterprise.local/desktop/git-error-translations2.git", "https://enterprise.local/desktop/git-error-translations2.git"))
end
- it 'links binary-only frameworks' do
- expect(subject).to include(link('https://my.domain.com/release/MyFramework.json', 'https://my.domain.com/release/MyFramework.json'))
+ it "links binary-only frameworks" do
+ expect(subject).to include(link("https://my.domain.com/release/MyFramework.json", "https://my.domain.com/release/MyFramework.json"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb
index 4d222564fd0..2fed51e0b9f 100644
--- a/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/composer_json_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::ComposerJsonLinker do
- describe '.support?' do
- it 'supports composer.json' do
- expect(described_class.support?('composer.json')).to be_truthy
+ describe ".support?" do
+ it "supports composer.json" do
+ expect(described_class.support?("composer.json")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('composer.json.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("composer.json.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "composer.json" }
let(:file_content) do
@@ -47,36 +47,36 @@ describe Gitlab::DependencyLinker::ComposerJsonLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the module name' do
- expect(subject).to include(link('laravel/laravel', 'https://packagist.org/packages/laravel/laravel'))
+ it "links the module name" do
+ expect(subject).to include(link("laravel/laravel", "https://packagist.org/packages/laravel/laravel"))
end
- it 'links the homepage' do
- expect(subject).to include(link('https://laravel.com/', 'https://laravel.com/'))
+ it "links the homepage" do
+ expect(subject).to include(link("https://laravel.com/", "https://laravel.com/"))
end
- it 'links the repository URL' do
- expect(subject).to include(link('https://github.com/laravel/laravel.git', 'https://github.com/laravel/laravel.git'))
+ it "links the repository URL" do
+ expect(subject).to include(link("https://github.com/laravel/laravel.git", "https://github.com/laravel/laravel.git"))
end
- it 'links the license' do
- expect(subject).to include(link('MIT', 'http://choosealicense.com/licenses/mit/'))
+ it "links the license" do
+ expect(subject).to include(link("MIT", "http://choosealicense.com/licenses/mit/"))
end
- it 'links dependencies' do
- expect(subject).to include(link('laravel/framework', 'https://packagist.org/packages/laravel/framework'))
- expect(subject).to include(link('fzaninotto/faker', 'https://packagist.org/packages/fzaninotto/faker'))
- expect(subject).to include(link('mockery/mockery', 'https://packagist.org/packages/mockery/mockery'))
- expect(subject).to include(link('phpunit/phpunit', 'https://packagist.org/packages/phpunit/phpunit'))
- expect(subject).to include(link('symfony/css-selector', 'https://packagist.org/packages/symfony/css-selector'))
- expect(subject).to include(link('symfony/dom-crawler', 'https://packagist.org/packages/symfony/dom-crawler'))
+ it "links dependencies" do
+ expect(subject).to include(link("laravel/framework", "https://packagist.org/packages/laravel/framework"))
+ expect(subject).to include(link("fzaninotto/faker", "https://packagist.org/packages/fzaninotto/faker"))
+ expect(subject).to include(link("mockery/mockery", "https://packagist.org/packages/mockery/mockery"))
+ expect(subject).to include(link("phpunit/phpunit", "https://packagist.org/packages/phpunit/phpunit"))
+ expect(subject).to include(link("symfony/css-selector", "https://packagist.org/packages/symfony/css-selector"))
+ expect(subject).to include(link("symfony/dom-crawler", "https://packagist.org/packages/symfony/dom-crawler"))
end
- it 'does not link core dependencies' do
- expect(subject).not_to include(link('php', 'https://packagist.org/packages/php'))
+ it "does not link core dependencies" do
+ expect(subject).not_to include(link("php", "https://packagist.org/packages/php"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb
index a97803b119e..209897cbcb5 100644
--- a/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/gemfile_linker_spec.rb
@@ -1,22 +1,22 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::GemfileLinker do
- describe '.support?' do
- it 'supports Gemfile' do
- expect(described_class.support?('Gemfile')).to be_truthy
+ describe ".support?" do
+ it "supports Gemfile" do
+ expect(described_class.support?("Gemfile")).to be_truthy
end
- it 'supports gems.rb' do
- expect(described_class.support?('gems.rb')).to be_truthy
+ it "supports gems.rb" do
+ expect(described_class.support?("gems.rb")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('Gemfile.lock')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("Gemfile.lock")).to be_falsey
end
end
- describe '#link' do
- let(:file_name) { 'Gemfile' }
+ describe "#link" do
+ let(:file_name) { "Gemfile" }
let(:file_content) do
<<-CONTENT.strip_heredoc
@@ -33,28 +33,28 @@ describe Gitlab::DependencyLinker::GemfileLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links sources' do
- expect(subject).to include(link('https://rubygems.org', 'https://rubygems.org'))
+ it "links sources" do
+ expect(subject).to include(link("https://rubygems.org", "https://rubygems.org"))
end
- it 'links dependencies' do
- expect(subject).to include(link('rails', 'https://rubygems.org/gems/rails'))
- expect(subject).to include(link('rails-deprecated_sanitizer', 'https://rubygems.org/gems/rails-deprecated_sanitizer'))
- expect(subject).to include(link('responders', 'https://rubygems.org/gems/responders'))
- expect(subject).to include(link('sprockets', 'https://rubygems.org/gems/sprockets'))
- expect(subject).to include(link('default_value_for', 'https://rubygems.org/gems/default_value_for'))
+ it "links dependencies" do
+ expect(subject).to include(link("rails", "https://rubygems.org/gems/rails"))
+ expect(subject).to include(link("rails-deprecated_sanitizer", "https://rubygems.org/gems/rails-deprecated_sanitizer"))
+ expect(subject).to include(link("responders", "https://rubygems.org/gems/responders"))
+ expect(subject).to include(link("sprockets", "https://rubygems.org/gems/sprockets"))
+ expect(subject).to include(link("default_value_for", "https://rubygems.org/gems/default_value_for"))
end
- it 'links GitHub repos' do
- expect(subject).to include(link('rails/rails', 'https://github.com/rails/rails'))
- expect(subject).to include(link('rails/responders', 'https://github.com/rails/responders'))
+ it "links GitHub repos" do
+ expect(subject).to include(link("rails/rails", "https://github.com/rails/rails"))
+ expect(subject).to include(link("rails/responders", "https://github.com/rails/responders"))
end
- it 'links Git repos' do
- expect(subject).to include(link('https://gitlab.example.com/gems/sprockets', 'https://gitlab.example.com/gems/sprockets'))
+ it "links Git repos" do
+ expect(subject).to include(link("https://gitlab.example.com/gems/sprockets", "https://gitlab.example.com/gems/sprockets"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb b/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb
index 24ad7d12f4c..3ad1ebd7e5c 100644
--- a/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/gemspec_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::GemspecLinker do
- describe '.support?' do
- it 'supports *.gemspec' do
- expect(described_class.support?('gitlab_git.gemspec')).to be_truthy
+ describe ".support?" do
+ it "supports *.gemspec" do
+ expect(described_class.support?("gitlab_git.gemspec")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('.gemspec.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?(".gemspec.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "gitlab_git.gemspec" }
let(:file_content) do
@@ -40,27 +40,27 @@ describe Gitlab::DependencyLinker::GemspecLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the gem name' do
- expect(subject).to include(link('gitlab_git', 'https://rubygems.org/gems/gitlab_git'))
+ it "links the gem name" do
+ expect(subject).to include(link("gitlab_git", "https://rubygems.org/gems/gitlab_git"))
end
- it 'links the license' do
- expect(subject).to include(link('MIT', 'http://choosealicense.com/licenses/mit/'))
+ it "links the license" do
+ expect(subject).to include(link("MIT", "http://choosealicense.com/licenses/mit/"))
end
- it 'links the homepage' do
- expect(subject).to include(link('https://gitlab.com/gitlab-org/gitlab_git', 'https://gitlab.com/gitlab-org/gitlab_git'))
+ it "links the homepage" do
+ expect(subject).to include(link("https://gitlab.com/gitlab-org/gitlab_git", "https://gitlab.com/gitlab-org/gitlab_git"))
end
- it 'links dependencies' do
- expect(subject).to include(link('github-linguist', 'https://rubygems.org/gems/github-linguist'))
- expect(subject).to include(link('activesupport', 'https://rubygems.org/gems/activesupport'))
- expect(subject).to include(link('rugged', 'https://rubygems.org/gems/rugged'))
- expect(subject).to include(link('charlock_holmes', 'https://rubygems.org/gems/charlock_holmes'))
- expect(subject).to include(link('listen', 'https://rubygems.org/gems/listen'))
+ it "links dependencies" do
+ expect(subject).to include(link("github-linguist", "https://rubygems.org/gems/github-linguist"))
+ expect(subject).to include(link("activesupport", "https://rubygems.org/gems/activesupport"))
+ expect(subject).to include(link("rugged", "https://rubygems.org/gems/rugged"))
+ expect(subject).to include(link("charlock_holmes", "https://rubygems.org/gems/charlock_holmes"))
+ expect(subject).to include(link("listen", "https://rubygems.org/gems/listen"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb
index ae5ad39ad11..aa9a0a7640b 100644
--- a/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/godeps_json_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::GodepsJsonLinker do
- describe '.support?' do
- it 'supports Godeps.json' do
- expect(described_class.support?('Godeps.json')).to be_truthy
+ describe ".support?" do
+ it "supports Godeps.json" do
+ expect(described_class.support?("Godeps.json")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('Godeps.json.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("Godeps.json.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "Godeps.json" }
let(:file_content) do
@@ -59,26 +59,26 @@ describe Gitlab::DependencyLinker::GodepsJsonLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the package name' do
- expect(subject).to include(link('gitlab.com/gitlab-org/gitlab-pages', 'https://gitlab.com/gitlab-org/gitlab-pages'))
+ it "links the package name" do
+ expect(subject).to include(link("gitlab.com/gitlab-org/gitlab-pages", "https://gitlab.com/gitlab-org/gitlab-pages"))
end
- it 'links GitHub repos' do
- expect(subject).to include(link('github.com/kardianos/osext', 'https://github.com/kardianos/osext'))
- expect(subject).to include(link('github.com/stretchr/testify/assert', 'https://github.com/stretchr/testify/tree/master/assert'))
- expect(subject).to include(link('github.com/stretchr/testify/require', 'https://github.com/stretchr/testify/tree/master/require'))
+ it "links GitHub repos" do
+ expect(subject).to include(link("github.com/kardianos/osext", "https://github.com/kardianos/osext"))
+ expect(subject).to include(link("github.com/stretchr/testify/assert", "https://github.com/stretchr/testify/tree/master/assert"))
+ expect(subject).to include(link("github.com/stretchr/testify/require", "https://github.com/stretchr/testify/tree/master/require"))
end
- it 'links GitLab projects' do
- expect(subject).to include(link('gitlab.com/group/project/path', 'https://gitlab.com/group/project/tree/master/path'))
- expect(subject).to include(link('gitlab.com/group/subgroup/project.git/path', 'https://gitlab.com/group/subgroup/project/tree/master/path'))
+ it "links GitLab projects" do
+ expect(subject).to include(link("gitlab.com/group/project/path", "https://gitlab.com/group/project/tree/master/path"))
+ expect(subject).to include(link("gitlab.com/group/subgroup/project.git/path", "https://gitlab.com/group/subgroup/project/tree/master/path"))
end
- it 'links Golang packages' do
- expect(subject).to include(link('golang.org/x/net/http2', 'https://godoc.org/golang.org/x/net/http2'))
+ it "links Golang packages" do
+ expect(subject).to include(link("golang.org/x/net/http2", "https://godoc.org/golang.org/x/net/http2"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb
index 1e8b72afb7b..e69e09568b4 100644
--- a/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/package_json_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::PackageJsonLinker do
- describe '.support?' do
- it 'supports package.json' do
- expect(described_class.support?('package.json')).to be_truthy
+ describe ".support?" do
+ it "supports package.json" do
+ expect(described_class.support?("package.json")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('package.json.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("package.json.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "package.json" }
let(:file_content) do
@@ -48,47 +48,47 @@ describe Gitlab::DependencyLinker::PackageJsonLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the module name' do
- expect(subject).to include(link('module-name', 'https://npmjs.com/package/module-name'))
+ it "links the module name" do
+ expect(subject).to include(link("module-name", "https://npmjs.com/package/module-name"))
end
- it 'links the homepage' do
- expect(subject).to include(link('https://github.com/vuejs/vue#readme', 'https://github.com/vuejs/vue#readme'))
+ it "links the homepage" do
+ expect(subject).to include(link("https://github.com/vuejs/vue#readme", "https://github.com/vuejs/vue#readme"))
end
- it 'links the repository URL' do
- expect(subject).to include(link('https://github.com/vuejs/vue.git', 'https://github.com/vuejs/vue.git'))
+ it "links the repository URL" do
+ expect(subject).to include(link("https://github.com/vuejs/vue.git", "https://github.com/vuejs/vue.git"))
end
- it 'links the license' do
- expect(subject).to include(link('MIT', 'http://choosealicense.com/licenses/mit/'))
+ it "links the license" do
+ expect(subject).to include(link("MIT", "http://choosealicense.com/licenses/mit/"))
end
- it 'links dependencies' do
- expect(subject).to include(link('primus', 'https://npmjs.com/package/primus'))
- expect(subject).to include(link('async', 'https://npmjs.com/package/async'))
- expect(subject).to include(link('express', 'https://npmjs.com/package/express'))
- expect(subject).to include(link('bigpipe', 'https://npmjs.com/package/bigpipe'))
- expect(subject).to include(link('plates', 'https://npmjs.com/package/plates'))
- expect(subject).to include(link('karma', 'https://npmjs.com/package/karma'))
- expect(subject).to include(link('vows', 'https://npmjs.com/package/vows'))
- expect(subject).to include(link('assume', 'https://npmjs.com/package/assume'))
- expect(subject).to include(link('pre-commit', 'https://npmjs.com/package/pre-commit'))
+ it "links dependencies" do
+ expect(subject).to include(link("primus", "https://npmjs.com/package/primus"))
+ expect(subject).to include(link("async", "https://npmjs.com/package/async"))
+ expect(subject).to include(link("express", "https://npmjs.com/package/express"))
+ expect(subject).to include(link("bigpipe", "https://npmjs.com/package/bigpipe"))
+ expect(subject).to include(link("plates", "https://npmjs.com/package/plates"))
+ expect(subject).to include(link("karma", "https://npmjs.com/package/karma"))
+ expect(subject).to include(link("vows", "https://npmjs.com/package/vows"))
+ expect(subject).to include(link("assume", "https://npmjs.com/package/assume"))
+ expect(subject).to include(link("pre-commit", "https://npmjs.com/package/pre-commit"))
end
- it 'links GitHub repos' do
- expect(subject).to include(link('bigpipe/pagelet', 'https://github.com/bigpipe/pagelet'))
+ it "links GitHub repos" do
+ expect(subject).to include(link("bigpipe/pagelet", "https://github.com/bigpipe/pagelet"))
end
- it 'links Git repos' do
- expect(subject).to include(link('https://github.com/flatiron/plates/tarball/master', 'https://github.com/flatiron/plates/tarball/master'))
+ it "links Git repos" do
+ expect(subject).to include(link("https://github.com/flatiron/plates/tarball/master", "https://github.com/flatiron/plates/tarball/master"))
end
- it 'does not link scripts with the same key as a package' do
- expect(subject).not_to include(link('karma start config/karma.config.js --single-run', 'https://github.com/karma start config/karma.config.js --single-run'))
+ it "does not link scripts with the same key as a package" do
+ expect(subject).not_to include(link("karma start config/karma.config.js --single-run", "https://github.com/karma start config/karma.config.js --single-run"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb
index cdfd7ad9826..7a7019f80c4 100644
--- a/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/podfile_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::PodfileLinker do
- describe '.support?' do
- it 'supports Podfile' do
- expect(described_class.support?('Podfile')).to be_truthy
+ describe ".support?" do
+ it "supports Podfile" do
+ expect(described_class.support?("Podfile")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('Podfile.lock')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("Podfile.lock")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "Podfile" }
let(:file_content) do
@@ -33,21 +33,21 @@ describe Gitlab::DependencyLinker::PodfileLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links sources' do
- expect(subject).to include(link('https://github.com/artsy/Specs.git', 'https://github.com/artsy/Specs.git'))
- expect(subject).to include(link('https://github.com/CocoaPods/Specs.git', 'https://github.com/CocoaPods/Specs.git'))
+ it "links sources" do
+ expect(subject).to include(link("https://github.com/artsy/Specs.git", "https://github.com/artsy/Specs.git"))
+ expect(subject).to include(link("https://github.com/CocoaPods/Specs.git", "https://github.com/CocoaPods/Specs.git"))
end
- it 'links packages' do
- expect(subject).to include(link('AFNetworking', 'https://cocoapods.org/pods/AFNetworking'))
- expect(subject).to include(link('Interstellar/Core', 'https://cocoapods.org/pods/Interstellar'))
+ it "links packages" do
+ expect(subject).to include(link("AFNetworking", "https://cocoapods.org/pods/AFNetworking"))
+ expect(subject).to include(link("Interstellar/Core", "https://cocoapods.org/pods/Interstellar"))
end
- it 'links Git repos' do
- expect(subject).to include(link('https://github.com/ashfurrow/Interstellar.git', 'https://github.com/ashfurrow/Interstellar.git'))
+ it "links Git repos" do
+ expect(subject).to include(link("https://github.com/ashfurrow/Interstellar.git", "https://github.com/ashfurrow/Interstellar.git"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
index d4a398c5948..44b99ecd47c 100644
--- a/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/podspec_json_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::PodspecJsonLinker do
- describe '.support?' do
- it 'supports *.podspec.json' do
- expect(described_class.support?('Reachability.podspec.json')).to be_truthy
+ describe ".support?" do
+ it "supports *.podspec.json" do
+ expect(described_class.support?("Reachability.podspec.json")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('.podspec.json.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?(".podspec.json.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "AFNetworking.podspec.json" }
let(:file_content) do
@@ -64,33 +64,33 @@ describe Gitlab::DependencyLinker::PodspecJsonLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the gem name' do
- expect(subject).to include(link('AFNetworking', 'https://cocoapods.org/pods/AFNetworking'))
+ it "links the gem name" do
+ expect(subject).to include(link("AFNetworking", "https://cocoapods.org/pods/AFNetworking"))
end
- it 'links the license' do
- expect(subject).to include(link('MIT', 'http://choosealicense.com/licenses/mit/'))
+ it "links the license" do
+ expect(subject).to include(link("MIT", "http://choosealicense.com/licenses/mit/"))
end
- it 'links the homepage' do
- expect(subject).to include(link('https://github.com/AFNetworking/AFNetworking', 'https://github.com/AFNetworking/AFNetworking'))
+ it "links the homepage" do
+ expect(subject).to include(link("https://github.com/AFNetworking/AFNetworking", "https://github.com/AFNetworking/AFNetworking"))
end
- it 'links the source URL' do
- expect(subject).to include(link('https://github.com/AFNetworking/AFNetworking.git', 'https://github.com/AFNetworking/AFNetworking.git'))
+ it "links the source URL" do
+ expect(subject).to include(link("https://github.com/AFNetworking/AFNetworking.git", "https://github.com/AFNetworking/AFNetworking.git"))
end
- it 'links dependencies' do
- expect(subject).to include(link('AFNetworking/Serialization', 'https://cocoapods.org/pods/AFNetworking'))
- expect(subject).to include(link('AFNetworking/Reachability', 'https://cocoapods.org/pods/AFNetworking'))
- expect(subject).to include(link('AFNetworking/Security', 'https://cocoapods.org/pods/AFNetworking'))
+ it "links dependencies" do
+ expect(subject).to include(link("AFNetworking/Serialization", "https://cocoapods.org/pods/AFNetworking"))
+ expect(subject).to include(link("AFNetworking/Reachability", "https://cocoapods.org/pods/AFNetworking"))
+ expect(subject).to include(link("AFNetworking/Security", "https://cocoapods.org/pods/AFNetworking"))
end
- it 'does not link subspec names' do
- expect(subject).not_to include(link('NSURLConnection', 'https://cocoapods.org/pods/NSURLConnection'))
+ it "does not link subspec names" do
+ expect(subject).not_to include(link("NSURLConnection", "https://cocoapods.org/pods/NSURLConnection"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb b/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
index ed60ab45955..30e7e809e87 100644
--- a/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/podspec_linker_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::PodspecLinker do
- describe '.support?' do
- it 'supports *.podspec' do
- expect(described_class.support?('Reachability.podspec')).to be_truthy
+ describe ".support?" do
+ it "supports *.podspec" do
+ expect(described_class.support?("Reachability.podspec")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('.podspec.example')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?(".podspec.example")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "Reachability.podspec" }
let(:file_content) do
@@ -39,31 +39,31 @@ describe Gitlab::DependencyLinker::PodspecLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links the gem name' do
- expect(subject).to include(link('Reachability', 'https://cocoapods.org/pods/Reachability'))
+ it "links the gem name" do
+ expect(subject).to include(link("Reachability", "https://cocoapods.org/pods/Reachability"))
end
- it 'links the license' do
- expect(subject).to include(link('GPL-3.0', 'http://choosealicense.com/licenses/gpl-3.0/'))
- expect(subject).to include(link('MIT', 'http://choosealicense.com/licenses/mit/'))
- expect(subject).to include(link('Apache-2.0', 'http://choosealicense.com/licenses/apache-2.0/'))
+ it "links the license" do
+ expect(subject).to include(link("GPL-3.0", "http://choosealicense.com/licenses/gpl-3.0/"))
+ expect(subject).to include(link("MIT", "http://choosealicense.com/licenses/mit/"))
+ expect(subject).to include(link("Apache-2.0", "http://choosealicense.com/licenses/apache-2.0/"))
end
- it 'links the homepage' do
- expect(subject).to include(link('https://github.com/tonymillion/Reachability', 'https://github.com/tonymillion/Reachability'))
+ it "links the homepage" do
+ expect(subject).to include(link("https://github.com/tonymillion/Reachability", "https://github.com/tonymillion/Reachability"))
end
- it 'links the source URL' do
- expect(subject).to include(link('https://github.com/tonymillion/Reachability.git', 'https://github.com/tonymillion/Reachability.git'))
+ it "links the source URL" do
+ expect(subject).to include(link("https://github.com/tonymillion/Reachability.git", "https://github.com/tonymillion/Reachability.git"))
end
- it 'links dependencies' do
- expect(subject).to include(link('AFNetworking', 'https://cocoapods.org/pods/AFNetworking'))
- expect(subject).to include(link('RestKit/CoreData', 'https://cocoapods.org/pods/RestKit'))
- expect(subject).to include(link('MBProgressHUD', 'https://cocoapods.org/pods/MBProgressHUD'))
+ it "links dependencies" do
+ expect(subject).to include(link("AFNetworking", "https://cocoapods.org/pods/AFNetworking"))
+ expect(subject).to include(link("RestKit/CoreData", "https://cocoapods.org/pods/RestKit"))
+ expect(subject).to include(link("MBProgressHUD", "https://cocoapods.org/pods/MBProgressHUD"))
end
end
end
diff --git a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb
index ef952b3abd5..bedba22222e 100644
--- a/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker/requirements_txt_linker_spec.rb
@@ -1,21 +1,21 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker::RequirementsTxtLinker do
- describe '.support?' do
- it 'supports requirements.txt' do
- expect(described_class.support?('requirements.txt')).to be_truthy
+ describe ".support?" do
+ it "supports requirements.txt" do
+ expect(described_class.support?("requirements.txt")).to be_truthy
end
- it 'supports doc-requirements.txt' do
- expect(described_class.support?('doc-requirements.txt')).to be_truthy
+ it "supports doc-requirements.txt" do
+ expect(described_class.support?("doc-requirements.txt")).to be_truthy
end
- it 'does not support other files' do
- expect(described_class.support?('requirements')).to be_falsey
+ it "does not support other files" do
+ expect(described_class.support?("requirements")).to be_falsey
end
end
- describe '#link' do
+ describe "#link" do
let(:file_name) { "requirements.txt" }
let(:file_content) do
@@ -62,33 +62,33 @@ describe Gitlab::DependencyLinker::RequirementsTxtLinker do
subject { Gitlab::Highlight.highlight(file_name, file_content) }
def link(name, url)
- %{<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>}
+ %(<a href="#{url}" rel="nofollow noreferrer noopener" target="_blank">#{name}</a>)
end
- it 'links dependencies' do
- expect(subject).to include(link('nose', 'https://pypi.python.org/pypi/nose'))
- expect(subject).to include(link('nose-cov', 'https://pypi.python.org/pypi/nose-cov'))
- expect(subject).to include(link('beautifulsoup4', 'https://pypi.python.org/pypi/beautifulsoup4'))
- expect(subject).to include(link('docopt', 'https://pypi.python.org/pypi/docopt'))
- expect(subject).to include(link('keyring', 'https://pypi.python.org/pypi/keyring'))
- expect(subject).to include(link('coverage', 'https://pypi.python.org/pypi/coverage'))
- expect(subject).to include(link('Mopidy-Dirble', 'https://pypi.python.org/pypi/Mopidy-Dirble'))
- expect(subject).to include(link('rejected', 'https://pypi.python.org/pypi/rejected'))
- expect(subject).to include(link('green', 'https://pypi.python.org/pypi/green'))
- expect(subject).to include(link('Jinja2', 'https://pypi.python.org/pypi/Jinja2'))
- expect(subject).to include(link('Pygments', 'https://pypi.python.org/pypi/Pygments'))
- expect(subject).to include(link('Sphinx', 'https://pypi.python.org/pypi/Sphinx'))
- expect(subject).to include(link('docutils', 'https://pypi.python.org/pypi/docutils'))
- expect(subject).to include(link('markupsafe', 'https://pypi.python.org/pypi/markupsafe'))
- expect(subject).to include(link('pytest', 'https://pypi.python.org/pypi/pytest'))
- expect(subject).to include(link('foop', 'https://pypi.python.org/pypi/foop'))
+ it "links dependencies" do
+ expect(subject).to include(link("nose", "https://pypi.python.org/pypi/nose"))
+ expect(subject).to include(link("nose-cov", "https://pypi.python.org/pypi/nose-cov"))
+ expect(subject).to include(link("beautifulsoup4", "https://pypi.python.org/pypi/beautifulsoup4"))
+ expect(subject).to include(link("docopt", "https://pypi.python.org/pypi/docopt"))
+ expect(subject).to include(link("keyring", "https://pypi.python.org/pypi/keyring"))
+ expect(subject).to include(link("coverage", "https://pypi.python.org/pypi/coverage"))
+ expect(subject).to include(link("Mopidy-Dirble", "https://pypi.python.org/pypi/Mopidy-Dirble"))
+ expect(subject).to include(link("rejected", "https://pypi.python.org/pypi/rejected"))
+ expect(subject).to include(link("green", "https://pypi.python.org/pypi/green"))
+ expect(subject).to include(link("Jinja2", "https://pypi.python.org/pypi/Jinja2"))
+ expect(subject).to include(link("Pygments", "https://pypi.python.org/pypi/Pygments"))
+ expect(subject).to include(link("Sphinx", "https://pypi.python.org/pypi/Sphinx"))
+ expect(subject).to include(link("docutils", "https://pypi.python.org/pypi/docutils"))
+ expect(subject).to include(link("markupsafe", "https://pypi.python.org/pypi/markupsafe"))
+ expect(subject).to include(link("pytest", "https://pypi.python.org/pypi/pytest"))
+ expect(subject).to include(link("foop", "https://pypi.python.org/pypi/foop"))
end
- it 'links URLs' do
- expect(subject).to include(link('http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl', 'http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl'))
+ it "links URLs" do
+ expect(subject).to include(link("http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl", "http://wxpython.org/Phoenix/snapshot-builds/wxPython_Phoenix-3.0.3.dev1820+49a8884-cp34-none-win_amd64.whl"))
end
- it 'does not contain link with a newline as package name' do
+ it "does not contain link with a newline as package name" do
expect(subject).not_to include(link("\n", "https://pypi.python.org/pypi/\n"))
end
end
diff --git a/spec/lib/gitlab/dependency_linker_spec.rb b/spec/lib/gitlab/dependency_linker_spec.rb
index 10d2f701298..9998d4b954f 100644
--- a/spec/lib/gitlab/dependency_linker_spec.rb
+++ b/spec/lib/gitlab/dependency_linker_spec.rb
@@ -1,81 +1,81 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::DependencyLinker do
- describe '.link' do
- it 'links using GemfileLinker' do
- blob_name = 'Gemfile'
+ describe ".link" do
+ it "links using GemfileLinker" do
+ blob_name = "Gemfile"
expect(described_class::GemfileLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using GemspecLinker' do
- blob_name = 'gitlab_git.gemspec'
+ it "links using GemspecLinker" do
+ blob_name = "gitlab_git.gemspec"
expect(described_class::GemspecLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using PackageJsonLinker' do
- blob_name = 'package.json'
+ it "links using PackageJsonLinker" do
+ blob_name = "package.json"
expect(described_class::PackageJsonLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using ComposerJsonLinker' do
- blob_name = 'composer.json'
+ it "links using ComposerJsonLinker" do
+ blob_name = "composer.json"
expect(described_class::ComposerJsonLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using PodfileLinker' do
- blob_name = 'Podfile'
+ it "links using PodfileLinker" do
+ blob_name = "Podfile"
expect(described_class::PodfileLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using PodspecLinker' do
- blob_name = 'Reachability.podspec'
+ it "links using PodspecLinker" do
+ blob_name = "Reachability.podspec"
expect(described_class::PodspecLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using PodspecJsonLinker' do
- blob_name = 'AFNetworking.podspec.json'
+ it "links using PodspecJsonLinker" do
+ blob_name = "AFNetworking.podspec.json"
expect(described_class::PodspecJsonLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using CartfileLinker' do
- blob_name = 'Cartfile'
+ it "links using CartfileLinker" do
+ blob_name = "Cartfile"
expect(described_class::CartfileLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using GodepsJsonLinker' do
- blob_name = 'Godeps.json'
+ it "links using GodepsJsonLinker" do
+ blob_name = "Godeps.json"
expect(described_class::GodepsJsonLinker).to receive(:link)
described_class.link(blob_name, nil, nil)
end
- it 'links using RequirementsTxtLinker' do
- blob_name = 'requirements.txt'
+ it "links using RequirementsTxtLinker" do
+ blob_name = "requirements.txt"
expect(described_class::RequirementsTxtLinker).to receive(:link)
diff --git a/spec/lib/gitlab/diff/diff_refs_spec.rb b/spec/lib/gitlab/diff/diff_refs_spec.rb
index f9bfb4c469e..ddbaa331338 100644
--- a/spec/lib/gitlab/diff/diff_refs_spec.rb
+++ b/spec/lib/gitlab/diff/diff_refs_spec.rb
@@ -1,112 +1,112 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::DiffRefs do
let(:project) { create(:project, :repository) }
- describe '#==' do
- let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
+ describe "#==" do
+ let(:commit) { project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863") }
subject { commit.diff_refs }
- context 'when shas are missing' do
+ context "when shas are missing" do
let(:other) { described_class.new(base_sha: subject.base_sha, start_sha: subject.start_sha, head_sha: nil) }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to eq(other)
end
end
- context 'when shas are equal' do
+ context "when shas are equal" do
let(:other) { described_class.new(base_sha: subject.base_sha, start_sha: subject.start_sha, head_sha: subject.head_sha) }
- it 'returns true' do
+ it "returns true" do
expect(subject).to eq(other)
end
end
- context 'when shas are unequal' do
+ context "when shas are unequal" do
let(:other) { described_class.new(base_sha: subject.base_sha, start_sha: subject.start_sha, head_sha: subject.head_sha.reverse) }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to eq(other)
end
end
- context 'when shas are truncated' do
- context 'when sha prefixes are too short' do
+ context "when shas are truncated" do
+ context "when sha prefixes are too short" do
let(:other) { described_class.new(base_sha: subject.base_sha[0, 4], start_sha: subject.start_sha[0, 4], head_sha: subject.head_sha[0, 4]) }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to eq(other)
end
end
- context 'when sha prefixes are equal' do
+ context "when sha prefixes are equal" do
let(:other) { described_class.new(base_sha: subject.base_sha[0, 10], start_sha: subject.start_sha[0, 10], head_sha: subject.head_sha[0, 10]) }
- it 'returns true' do
+ it "returns true" do
expect(subject).to eq(other)
end
end
- context 'when sha prefixes are unequal' do
+ context "when sha prefixes are unequal" do
let(:other) { described_class.new(base_sha: subject.base_sha[0, 10], start_sha: subject.start_sha[0, 10], head_sha: subject.head_sha[0, 10].reverse) }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to eq(other)
end
end
end
end
- describe '#compare_in' do
- context 'with diff refs for the initial commit' do
- let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
+ describe "#compare_in" do
+ context "with diff refs for the initial commit" do
+ let(:commit) { project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863") }
subject { commit.diff_refs }
- it 'returns an appropriate comparison' do
+ it "returns an appropriate comparison" do
compare = subject.compare_in(project)
expect(compare.diff_refs).to eq(subject)
end
end
- context 'with diff refs for a commit' do
- let(:commit) { project.commit('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ context "with diff refs for a commit" do
+ let(:commit) { project.commit("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
subject { commit.diff_refs }
- it 'returns an appropriate comparison' do
+ it "returns an appropriate comparison" do
compare = subject.compare_in(project)
expect(compare.diff_refs).to eq(subject)
end
end
- context 'with diff refs for a comparison through the base' do
+ context "with diff refs for a comparison through the base" do
subject do
described_class.new(
- start_sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9', # feature
- base_sha: 'ae73cb07c9eeaf35924a10f713b364d32b2dd34f',
- head_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a' # master
+ start_sha: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", # feature
+ base_sha: "ae73cb07c9eeaf35924a10f713b364d32b2dd34f",
+ head_sha: "e63f41fe459e62e1228fcef60d7189127aeba95a" # master
)
end
- it 'returns an appropriate comparison' do
+ it "returns an appropriate comparison" do
compare = subject.compare_in(project)
expect(compare.diff_refs).to eq(subject)
end
end
- context 'with diff refs for a straight comparison' do
+ context "with diff refs for a straight comparison" do
subject do
described_class.new(
- start_sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9', # feature
- base_sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9',
- head_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a' # master
+ start_sha: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", # feature
+ base_sha: "0b4bc9a49b562e85de7cc9e834518ea6828729b9",
+ head_sha: "e63f41fe459e62e1228fcef60d7189127aeba95a" # master
)
end
- it 'returns an appropriate comparison' do
+ it "returns an appropriate comparison" do
compare = subject.compare_in(project)
expect(compare.diff_refs).to eq(subject)
diff --git a/spec/lib/gitlab/diff/file_collection/commit_spec.rb b/spec/lib/gitlab/diff/file_collection/commit_spec.rb
index 34ed22b8941..b3884aaece3 100644
--- a/spec/lib/gitlab/diff/file_collection/commit_spec.rb
+++ b/spec/lib/gitlab/diff/file_collection/commit_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::FileCollection::Commit do
let(:project) { create(:project, :repository) }
- it_behaves_like 'diff statistics' do
+ it_behaves_like "diff statistics" do
let(:collection_default_args) do
- { diff_options: {} }
+ {diff_options: {}}
end
let(:diffable) { project.commit }
- let(:stub_path) { 'bar/branch-test.txt' }
+ let(:stub_path) { "bar/branch-test.txt" }
end
- it_behaves_like 'unfoldable diff' do
+ it_behaves_like "unfoldable diff" do
let(:diffable) { project.commit }
end
end
diff --git a/spec/lib/gitlab/diff/file_collection/compare_spec.rb b/spec/lib/gitlab/diff/file_collection/compare_spec.rb
index f330f299ac1..3ec84876faf 100644
--- a/spec/lib/gitlab/diff/file_collection/compare_spec.rb
+++ b/spec/lib/gitlab/diff/file_collection/compare_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::FileCollection::Compare do
include RepoHelpers
@@ -11,19 +11,19 @@ describe Gitlab::Diff::FileCollection::Compare do
let(:head_commit) { sample_commit }
let(:raw_compare) do
Gitlab::Git::Compare.new(project.repository.raw_repository,
- start_commit.id,
- head_commit.id)
+ start_commit.id,
+ head_commit.id)
end
- it_behaves_like 'diff statistics' do
+ it_behaves_like "diff statistics" do
let(:collection_default_args) do
{
project: diffable.project,
diff_options: {},
- diff_refs: diffable.diff_refs
+ diff_refs: diffable.diff_refs,
}
end
let(:diffable) { Compare.new(raw_compare, project) }
- let(:stub_path) { '.gitignore' }
+ let(:stub_path) { ".gitignore" }
end
end
diff --git a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
index 256166dbad3..2aa2639492f 100644
--- a/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
+++ b/spec/lib/gitlab/diff/file_collection/merge_request_diff_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::FileCollection::MergeRequestDiff do
let(:merge_request) { create(:merge_request) }
let(:subject) { described_class.new(merge_request.merge_request_diff, diff_options: nil) }
let(:diff_files) { subject.diff_files }
- describe '#diff_files' do
- it 'does not highlight binary files' do
+ describe "#diff_files" do
+ it "does not highlight binary files" do
allow_any_instance_of(Gitlab::Diff::File).to receive(:text?).and_return(false)
expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
@@ -14,7 +14,7 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
diff_files
end
- it 'does not highlight files marked as undiffable in .gitattributes' do
+ it "does not highlight files marked as undiffable in .gitattributes" do
allow_any_instance_of(Gitlab::Diff::File).to receive(:diffable?).and_return(false)
expect_any_instance_of(Gitlab::Diff::File).not_to receive(:highlighted_diff_lines)
@@ -23,28 +23,28 @@ describe Gitlab::Diff::FileCollection::MergeRequestDiff do
end
end
- it_behaves_like 'unfoldable diff' do
+ it_behaves_like "unfoldable diff" do
let(:diffable) { merge_request.merge_request_diff }
end
- it 'it uses a different cache key if diff line keys change' do
+ it "it uses a different cache key if diff line keys change" do
mr_diff = described_class.new(merge_request.merge_request_diff, diff_options: nil)
key = mr_diff.cache_key
- stub_const('Gitlab::Diff::Line::SERIALIZE_KEYS', [:foo])
+ stub_const("Gitlab::Diff::Line::SERIALIZE_KEYS", [:foo])
expect(mr_diff.cache_key).not_to eq(key)
end
- it_behaves_like 'diff statistics' do
+ it_behaves_like "diff statistics" do
let(:collection_default_args) do
- { diff_options: {} }
+ {diff_options: {}}
end
let(:diffable) { merge_request.merge_request_diff }
- let(:stub_path) { '.gitignore' }
+ let(:stub_path) { ".gitignore" }
end
- it 'returns a valid instance of a DiffCollection' do
+ it "returns a valid instance of a DiffCollection" do
expect(diff_files).to be_a(Gitlab::Git::DiffCollection)
end
end
diff --git a/spec/lib/gitlab/diff/file_spec.rb b/spec/lib/gitlab/diff/file_spec.rb
index 862590268ca..4ec65cdfd64 100644
--- a/spec/lib/gitlab/diff/file_spec.rb
+++ b/spec/lib/gitlab/diff/file_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::File do
include RepoHelpers
@@ -8,41 +8,41 @@ describe Gitlab::Diff::File do
let(:diff) { commit.raw_diffs.first }
let(:diff_file) { described_class.new(diff, diff_refs: commit.diff_refs, repository: project.repository) }
- describe '#diff_lines' do
+ describe "#diff_lines" do
let(:diff_lines) { diff_file.diff_lines }
it { expect(diff_lines.size).to eq(30) }
it { expect(diff_lines.first).to be_kind_of(Gitlab::Diff::Line) }
end
- describe '#highlighted_diff_lines' do
- it 'highlights the diff and memoises the result' do
+ describe "#highlighted_diff_lines" do
+ it "highlights the diff and memoises the result" do
expect(Gitlab::Diff::Highlight).to receive(:new)
- .with(diff_file, repository: project.repository)
- .once
- .and_call_original
+ .with(diff_file, repository: project.repository)
+ .once
+ .and_call_original
diff_file.highlighted_diff_lines
end
end
- describe '#diff_lines_for_serializer' do
- it 'includes bottom match line if not in the end' do
- expect(diff_file.diff_lines_for_serializer.last.type).to eq('match')
+ describe "#diff_lines_for_serializer" do
+ it "includes bottom match line if not in the end" do
+ expect(diff_file.diff_lines_for_serializer.last.type).to eq("match")
end
- context 'when deleted' do
- let(:commit) { project.commit('d59c60028b053793cecfb4022de34602e1a9218e') }
- let(:diff_file) { commit.diffs.diff_file_with_old_path('files/js/commit.js.coffee') }
+ context "when deleted" do
+ let(:commit) { project.commit("d59c60028b053793cecfb4022de34602e1a9218e") }
+ let(:diff_file) { commit.diffs.diff_file_with_old_path("files/js/commit.js.coffee") }
- it 'does not include bottom match line' do
- expect(diff_file.diff_lines_for_serializer.last.type).not_to eq('match')
+ it "does not include bottom match line" do
+ expect(diff_file.diff_lines_for_serializer.last.type).not_to eq("match")
end
end
end
- describe '#unfold_diff_lines' do
- let(:unfolded_lines) { double('expanded-lines') }
+ describe "#unfold_diff_lines" do
+ let(:unfolded_lines) { double("expanded-lines") }
let(:unfolder) { instance_double(Gitlab::Diff::LinesUnfolder) }
let(:position) { instance_double(Gitlab::Diff::Position, old_line: 10) }
@@ -50,181 +50,181 @@ describe Gitlab::Diff::File do
allow(Gitlab::Diff::LinesUnfolder).to receive(:new) { unfolder }
end
- context 'when unfold required' do
+ context "when unfold required" do
before do
allow(unfolder).to receive(:unfold_required?) { true }
allow(unfolder).to receive(:unfolded_diff_lines) { unfolded_lines }
end
- it 'changes @unfolded to true' do
+ it "changes @unfolded to true" do
diff_file.unfold_diff_lines(position)
expect(diff_file).to be_unfolded
end
- it 'updates @diff_lines' do
+ it "updates @diff_lines" do
diff_file.unfold_diff_lines(position)
expect(diff_file.diff_lines).to eq(unfolded_lines)
end
end
- context 'when unfold not required' do
+ context "when unfold not required" do
before do
allow(unfolder).to receive(:unfold_required?) { false }
end
- it 'keeps @unfolded false' do
+ it "keeps @unfolded false" do
diff_file.unfold_diff_lines(position)
expect(diff_file).not_to be_unfolded
end
- it 'does not update @diff_lines' do
+ it "does not update @diff_lines" do
expect { diff_file.unfold_diff_lines(position) }
.not_to change(diff_file, :diff_lines)
end
end
end
- describe '#mode_changed?' do
+ describe "#mode_changed?" do
it { expect(diff_file.mode_changed?).to be_falsey }
end
- describe '#too_large?' do
- it 'returns true for a file that is too large' do
+ describe "#too_large?" do
+ it "returns true for a file that is too large" do
expect(diff).to receive(:too_large?).and_return(true)
expect(diff_file.too_large?).to eq(true)
end
- it 'returns false for a file that is small enough' do
+ it "returns false for a file that is small enough" do
expect(diff).to receive(:too_large?).and_return(false)
expect(diff_file.too_large?).to eq(false)
end
end
- describe '#collapsed?' do
- it 'returns true for a file that is quite big' do
+ describe "#collapsed?" do
+ it "returns true for a file that is quite big" do
expect(diff).to receive(:collapsed?).and_return(true)
expect(diff_file.collapsed?).to eq(true)
end
- it 'returns false for a file that is small enough' do
+ it "returns false for a file that is small enough" do
expect(diff).to receive(:collapsed?).and_return(false)
expect(diff_file.collapsed?).to eq(false)
end
end
- describe '#old_blob' do
- it 'returns blob of commit of base commit' do
+ describe "#old_blob" do
+ it "returns blob of commit of base commit" do
old_data = diff_file.old_blob.data
expect(old_data).to include('raise "System commands must be given as an array of strings"')
end
end
- describe '#new_blob' do
- it 'returns blob of new commit' do
+ describe "#new_blob" do
+ it "returns blob of new commit" do
data = diff_file.new_blob.data
expect(data).to include('raise RuntimeError, "System commands must be given as an array of strings"')
end
end
- describe '#diffable?' do
- let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
+ describe "#diffable?" do
+ let(:commit) { project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863") }
let(:diffs) { commit.diffs }
before do
- info_dir_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- File.join(project.repository.path_to_repo, 'info')
- end
+ info_dir_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
+ File.join(project.repository.path_to_repo, "info")
+ }
FileUtils.mkdir(info_dir_path) unless File.exist?(info_dir_path)
- File.write(File.join(info_dir_path, 'attributes'), "*.md -diff\n")
+ File.write(File.join(info_dir_path, "attributes"), "*.md -diff\n")
end
it "returns true for files that do not have attributes" do
- diff_file = diffs.diff_file_with_new_path('LICENSE')
+ diff_file = diffs.diff_file_with_new_path("LICENSE")
expect(diff_file.diffable?).to be_truthy
end
it "returns false for files that have been marked as not being diffable in attributes" do
- diff_file = diffs.diff_file_with_new_path('README.md')
+ diff_file = diffs.diff_file_with_new_path("README.md")
expect(diff_file.diffable?).to be_falsey
end
end
- describe '#content_changed?' do
- context 'when created' do
- let(:commit) { project.commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ describe "#content_changed?" do
+ context "when created" do
+ let(:commit) { project.commit("33f3729a45c02fc67d00adb1b8bca394b0e761d9") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
- it 'returns false' do
+ it "returns false" do
expect(diff_file.content_changed?).to be_falsey
end
end
- context 'when deleted' do
- let(:commit) { project.commit('d59c60028b053793cecfb4022de34602e1a9218e') }
- let(:diff_file) { commit.diffs.diff_file_with_old_path('files/js/commit.js.coffee') }
+ context "when deleted" do
+ let(:commit) { project.commit("d59c60028b053793cecfb4022de34602e1a9218e") }
+ let(:diff_file) { commit.diffs.diff_file_with_old_path("files/js/commit.js.coffee") }
- it 'returns false' do
+ it "returns false" do
expect(diff_file.content_changed?).to be_falsey
end
end
- context 'when renamed' do
- let(:commit) { project.commit('94bb47ca1297b7b3731ff2a36923640991e9236f') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('CHANGELOG.md') }
+ context "when renamed" do
+ let(:commit) { project.commit("94bb47ca1297b7b3731ff2a36923640991e9236f") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("CHANGELOG.md") }
- it 'returns false' do
+ it "returns false" do
expect(diff_file.content_changed?).to be_falsey
end
end
- context 'when content changed' do
- context 'when binary' do
- let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ context "when content changed" do
+ context "when binary" do
+ let(:commit) { project.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
- context 'when the blobs are different' do
- it 'returns true' do
+ context "when the blobs are different" do
+ it "returns true" do
expect(diff_file.content_changed?).to be_truthy
end
end
- context 'when there are no diff refs' do
+ context "when there are no diff refs" do
before do
allow(diff_file).to receive(:diff_refs).and_return(nil)
end
- it 'returns false' do
+ it "returns false" do
expect(diff_file.content_changed?).to be_falsey
end
end
end
- context 'when not binary' do
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ context "when not binary" do
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
- context 'when the blobs are different' do
- it 'returns true' do
+ context "when the blobs are different" do
+ it "returns true" do
expect(diff_file.content_changed?).to be_truthy
end
end
- context 'when there are no diff refs' do
+ context "when there are no diff refs" do
before do
allow(diff_file).to receive(:diff_refs).and_return(nil)
end
- it 'returns true' do
+ it "returns true" do
expect(diff_file.content_changed?).to be_truthy
end
end
@@ -232,12 +232,12 @@ describe Gitlab::Diff::File do
end
end
- context 'diff file stats' do
+ context "diff file stats" do
let(:diff_file) do
described_class.new(diff,
- diff_refs: commit.diff_refs,
- repository: project.repository,
- stats: stats)
+ diff_refs: commit.diff_refs,
+ repository: project.repository,
+ stats: stats)
end
let(:raw_diff) do
@@ -255,19 +255,19 @@ describe Gitlab::Diff::File do
EOS
end
- describe '#added_lines' do
- context 'when stats argument given' do
+ describe "#added_lines" do
+ context "when stats argument given" do
let(:stats) { double(Gitaly::DiffStats, additions: 10, deletions: 15) }
- it 'returns added lines from stats' do
+ it "returns added lines from stats" do
expect(diff_file.added_lines).to eq(stats.additions)
end
end
- context 'when stats argument not given' do
+ context "when stats argument not given" do
let(:stats) { nil }
- it 'returns added lines by parsing raw diff' do
+ it "returns added lines by parsing raw diff" do
allow(diff_file).to receive(:raw_diff) { raw_diff }
expect(diff_file.added_lines).to eq(2)
@@ -275,19 +275,19 @@ describe Gitlab::Diff::File do
end
end
- describe '#removed_lines' do
- context 'when stats argument given' do
+ describe "#removed_lines" do
+ context "when stats argument given" do
let(:stats) { double(Gitaly::DiffStats, additions: 10, deletions: 15) }
- it 'returns removed lines from stats' do
+ it "returns removed lines from stats" do
expect(diff_file.removed_lines).to eq(stats.deletions)
end
end
- context 'when stats argument not given' do
+ context "when stats argument not given" do
let(:stats) { nil }
- it 'returns removed lines by parsing raw diff' do
+ it "returns removed lines by parsing raw diff" do
allow(diff_file).to receive(:raw_diff) { raw_diff }
expect(diff_file.removed_lines).to eq(1)
@@ -296,140 +296,140 @@ describe Gitlab::Diff::File do
end
end
- describe '#simple_viewer' do
- context 'when the file is not diffable' do
+ describe "#simple_viewer" do
+ context "when the file is not diffable" do
before do
allow(diff_file).to receive(:diffable?).and_return(false)
end
- it 'returns a Not Diffable viewer' do
+ it "returns a Not Diffable viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::NotDiffable)
end
end
- context 'when the content changed' do
- context 'when the file represented by the diff file is binary' do
+ context "when the content changed" do
+ context "when the file represented by the diff file is binary" do
before do
allow(diff_file).to receive(:binary?).and_return(true)
end
- it 'returns a No Preview viewer' do
+ it "returns a No Preview viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::NoPreview)
end
end
- context 'when the diff file old and new blob types are different' do
+ context "when the diff file old and new blob types are different" do
before do
allow(diff_file).to receive(:different_type?).and_return(true)
end
- it 'returns a No Preview viewer' do
+ it "returns a No Preview viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::NoPreview)
end
end
- context 'when the file represented by the diff file is text-based' do
- it 'returns a text viewer' do
+ context "when the file represented by the diff file is text-based" do
+ it "returns a text viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Text)
end
end
end
- context 'when created' do
- let(:commit) { project.commit('913c66a37b4a45b9769037c55c2d238bd0942d2e') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ context "when created" do
+ let(:commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
before do
allow(diff_file).to receive(:content_changed?).and_return(nil)
end
- context 'when the file represented by the diff file is binary' do
+ context "when the file represented by the diff file is binary" do
before do
allow(diff_file).to receive(:binary?).and_return(true)
end
- it 'returns an Added viewer' do
+ it "returns an Added viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Added)
end
end
- context 'when the diff file old and new blob types are different' do
+ context "when the diff file old and new blob types are different" do
before do
allow(diff_file).to receive(:different_type?).and_return(true)
end
- it 'returns an Added viewer' do
+ it "returns an Added viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Added)
end
end
- context 'when the file represented by the diff file is text-based' do
- it 'returns a text viewer' do
+ context "when the file represented by the diff file is text-based" do
+ it "returns a text viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Text)
end
end
end
- context 'when deleted' do
- let(:commit) { project.commit('d59c60028b053793cecfb4022de34602e1a9218e') }
- let(:diff_file) { commit.diffs.diff_file_with_old_path('files/js/commit.js.coffee') }
+ context "when deleted" do
+ let(:commit) { project.commit("d59c60028b053793cecfb4022de34602e1a9218e") }
+ let(:diff_file) { commit.diffs.diff_file_with_old_path("files/js/commit.js.coffee") }
before do
allow(diff_file).to receive(:content_changed?).and_return(nil)
end
- context 'when the file represented by the diff file is binary' do
+ context "when the file represented by the diff file is binary" do
before do
allow(diff_file).to receive(:binary?).and_return(true)
end
- it 'returns a Deleted viewer' do
+ it "returns a Deleted viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Deleted)
end
end
- context 'when the diff file old and new blob types are different' do
+ context "when the diff file old and new blob types are different" do
before do
allow(diff_file).to receive(:different_type?).and_return(true)
end
- it 'returns a Deleted viewer' do
+ it "returns a Deleted viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Deleted)
end
end
- context 'when the file represented by the diff file is text-based' do
- it 'returns a text viewer' do
+ context "when the file represented by the diff file is text-based" do
+ it "returns a text viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Text)
end
end
end
- context 'when renamed' do
- let(:commit) { project.commit('6907208d755b60ebeacb2e9dfea74c92c3449a1f') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/js/commit.coffee') }
+ context "when renamed" do
+ let(:commit) { project.commit("6907208d755b60ebeacb2e9dfea74c92c3449a1f") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/js/commit.coffee") }
before do
allow(diff_file).to receive(:content_changed?).and_return(nil)
end
- it 'returns a Renamed viewer' do
+ it "returns a Renamed viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::Renamed)
end
end
- context 'when mode changed' do
+ context "when mode changed" do
before do
allow(diff_file).to receive(:content_changed?).and_return(nil)
allow(diff_file).to receive(:mode_changed?).and_return(true)
end
- it 'returns a Mode Changed viewer' do
+ it "returns a Mode Changed viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::ModeChanged)
end
end
- context 'when no other conditions apply' do
+ context "when no other conditions apply" do
before do
allow(diff_file).to receive(:content_changed?).and_return(false)
allow(diff_file).to receive(:new_file?).and_return(false)
@@ -439,171 +439,171 @@ describe Gitlab::Diff::File do
allow(diff_file).to receive(:text?).and_return(false)
end
- it 'returns a No Preview viewer' do
+ it "returns a No Preview viewer" do
expect(diff_file.simple_viewer).to be_a(DiffViewer::NoPreview)
end
end
end
- describe '#rich_viewer' do
- let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ describe "#rich_viewer" do
+ let(:commit) { project.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
- context 'when the diff file has a matching viewer' do
- context 'when the diff file content did not change' do
+ context "when the diff file has a matching viewer" do
+ context "when the diff file content did not change" do
before do
allow(diff_file).to receive(:content_changed?).and_return(false)
end
- it 'returns nil' do
+ it "returns nil" do
expect(diff_file.rich_viewer).to be_nil
end
end
- context 'when the diff file is not diffable' do
+ context "when the diff file is not diffable" do
before do
allow(diff_file).to receive(:diffable?).and_return(false)
end
- it 'returns nil' do
+ it "returns nil" do
expect(diff_file.rich_viewer).to be_nil
end
end
- context 'when the diff file old and new blob types are different' do
+ context "when the diff file old and new blob types are different" do
before do
allow(diff_file).to receive(:different_type?).and_return(true)
end
- it 'returns nil' do
+ it "returns nil" do
expect(diff_file.rich_viewer).to be_nil
end
end
- context 'when the diff file has an external storage error' do
+ context "when the diff file has an external storage error" do
before do
allow(diff_file).to receive(:external_storage_error?).and_return(true)
end
- it 'returns nil' do
+ it "returns nil" do
expect(diff_file.rich_viewer).to be_nil
end
end
- context 'when everything is right' do
- it 'returns the viewer' do
+ context "when everything is right" do
+ it "returns the viewer" do
expect(diff_file.rich_viewer).to be_a(DiffViewer::Image)
end
end
end
- context 'when the diff file does not have a matching viewer' do
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ context "when the diff file does not have a matching viewer" do
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
- it 'returns nil' do
+ it "returns nil" do
expect(diff_file.rich_viewer).to be_nil
end
end
end
- describe '#rendered_as_text?' do
- context 'when the simple viewer is text-based' do
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ describe "#rendered_as_text?" do
+ context "when the simple viewer is text-based" do
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
- context 'when ignoring errors' do
- context 'when the viewer has render errors' do
+ context "when ignoring errors" do
+ context "when the viewer has render errors" do
before do
diff_file.diff.too_large!
end
- it 'returns true' do
+ it "returns true" do
expect(diff_file.rendered_as_text?).to be_truthy
end
end
context "when the viewer doesn't have render errors" do
- it 'returns true' do
+ it "returns true" do
expect(diff_file.rendered_as_text?).to be_truthy
end
end
end
- context 'when not ignoring errors' do
- context 'when the viewer has render errors' do
+ context "when not ignoring errors" do
+ context "when the viewer has render errors" do
before do
diff_file.diff.too_large!
end
- it 'returns false' do
+ it "returns false" do
expect(diff_file.rendered_as_text?(ignore_errors: false)).to be_falsey
end
end
context "when the viewer doesn't have render errors" do
- it 'returns true' do
+ it "returns true" do
expect(diff_file.rendered_as_text?(ignore_errors: false)).to be_truthy
end
end
end
end
- context 'when the simple viewer is binary' do
- let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ context "when the simple viewer is binary" do
+ let(:commit) { project.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
- it 'returns false' do
+ it "returns false" do
expect(diff_file.rendered_as_text?).to be_falsey
end
end
end
- context 'when neither blob exists' do
+ context "when neither blob exists" do
let(:blank_diff_refs) { Gitlab::Diff::DiffRefs.new(base_sha: Gitlab::Git::BLANK_SHA, head_sha: Gitlab::Git::BLANK_SHA) }
let(:diff_file) { described_class.new(diff, diff_refs: blank_diff_refs, repository: project.repository) }
- describe '#blob' do
- it 'returns a concrete nil so it can be used in boolean expressions' do
+ describe "#blob" do
+ it "returns a concrete nil so it can be used in boolean expressions" do
actual = diff_file.blob && true
expect(actual).to be_nil
end
end
- describe '#binary?' do
- it 'returns false' do
+ describe "#binary?" do
+ it "returns false" do
expect(diff_file).not_to be_binary
end
end
- describe '#size' do
- it 'returns zero' do
+ describe "#size" do
+ it "returns zero" do
expect(diff_file.size).to be_zero
end
end
- describe '#empty?' do
- it 'returns true' do
+ describe "#empty?" do
+ it "returns true" do
expect(diff_file.empty?).to be_truthy
end
end
- describe '#different_type?' do
- it 'returns false' do
+ describe "#different_type?" do
+ it "returns false" do
expect(diff_file).not_to be_different_type
end
end
- describe '#content_changed?' do
- it 'returns false' do
+ describe "#content_changed?" do
+ it "returns false" do
expect(diff_file).not_to be_content_changed
end
end
end
- describe '#diff_hunk' do
- context 'when first line is a match' do
+ describe "#diff_hunk" do
+ context "when first line is a match" do
let(:raw_diff) do
<<~EOS
--- a/files/ruby/popen.rb
@@ -618,7 +618,7 @@ describe Gitlab::Diff::File do
EOS
end
- it 'returns raw diff up to given line index' do
+ it "returns raw diff up to given line index" do
allow(diff_file).to receive(:raw_diff) { raw_diff }
diff_line = instance_double(Gitlab::Diff::Line, index: 4)
@@ -635,7 +635,7 @@ describe Gitlab::Diff::File do
end
end
- context 'when first line is not a match' do
+ context "when first line is not a match" do
let(:raw_diff) do
<<~EOS
@@ -1,4 +1,4 @@
@@ -650,7 +650,7 @@ describe Gitlab::Diff::File do
EOS
end
- it 'returns raw diff up to given line index' do
+ it "returns raw diff up to given line index" do
allow(diff_file).to receive(:raw_diff) { raw_diff }
diff_line = instance_double(Gitlab::Diff::Line, index: 5)
@@ -669,17 +669,17 @@ describe Gitlab::Diff::File do
end
end
- describe '#empty?' do
+ describe "#empty?" do
let(:project) do
create(:project, :custom_repo, files: {})
end
- let(:branch_name) { 'master' }
+ let(:branch_name) { "master" }
def create_file(file_name, content)
Files::CreateService.new(
project,
project.owner,
- commit_message: 'Update',
+ commit_message: "Update",
start_branch: branch_name,
branch_name: branch_name,
file_path: file_name,
@@ -693,7 +693,7 @@ describe Gitlab::Diff::File do
Files::UpdateService.new(
project,
project.owner,
- commit_message: 'Update',
+ commit_message: "Update",
start_branch: branch_name,
branch_name: branch_name,
file_path: file_name,
@@ -707,7 +707,7 @@ describe Gitlab::Diff::File do
Files::DeleteService.new(
project,
project.owner,
- commit_message: 'Update',
+ commit_message: "Update",
start_branch: branch_name,
branch_name: branch_name,
file_path: file_name
@@ -716,36 +716,36 @@ describe Gitlab::Diff::File do
project.commit(branch_name).diffs.diff_files.first
end
- context 'when empty file is created' do
- it 'returns true' do
- diff_file = create_file('empty.md', '')
+ context "when empty file is created" do
+ it "returns true" do
+ diff_file = create_file("empty.md", "")
expect(diff_file.empty?).to be_truthy
end
end
- context 'when empty file is deleted' do
- it 'returns true' do
- create_file('empty.md', '')
- diff_file = delete_file('empty.md')
+ context "when empty file is deleted" do
+ it "returns true" do
+ create_file("empty.md", "")
+ diff_file = delete_file("empty.md")
expect(diff_file.empty?).to be_truthy
end
end
- context 'when file with content is truncated' do
- it 'returns false' do
- create_file('with-content.md', 'file content')
- diff_file = update_file('with-content.md', '')
+ context "when file with content is truncated" do
+ it "returns false" do
+ create_file("with-content.md", "file content")
+ diff_file = update_file("with-content.md", "")
expect(diff_file.empty?).to be_falsey
end
end
- context 'when empty file has content added' do
- it 'returns false' do
- create_file('empty.md', '')
- diff_file = update_file('empty.md', 'new content')
+ context "when empty file has content added" do
+ it "returns false" do
+ create_file("empty.md", "")
+ diff_file = update_file("empty.md", "new content")
expect(diff_file.empty?).to be_falsey
end
diff --git a/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb b/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
index 2f99febe04e..d76b28a5c2a 100644
--- a/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
+++ b/spec/lib/gitlab/diff/formatters/image_formatter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::Formatters::ImageFormatter do
it_behaves_like "position formatter" do
@@ -7,9 +7,9 @@ describe Gitlab::Diff::Formatters::ImageFormatter do
base_sha: 123,
start_sha: 456,
head_sha: 789,
- old_path: 'old_image.png',
- new_path: 'new_image.png',
- position_type: 'image'
+ old_path: "old_image.png",
+ new_path: "new_image.png",
+ position_type: "image",
}
end
diff --git a/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb b/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
index 897dc917f6a..1be9ee5bada 100644
--- a/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
+++ b/spec/lib/gitlab/diff/formatters/text_formatter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::Formatters::TextFormatter do
let!(:base) do
@@ -6,8 +6,8 @@ describe Gitlab::Diff::Formatters::TextFormatter do
base_sha: 123,
start_sha: 456,
head_sha: 789,
- old_path: 'old_path.txt',
- new_path: 'new_path.txt'
+ old_path: "old_path.txt",
+ new_path: "new_path.txt",
}
end
@@ -24,19 +24,19 @@ describe Gitlab::Diff::Formatters::TextFormatter do
# Specific text formatter examples
let!(:formatter) { described_class.new(attrs) }
- describe '#line_age' do
+ describe "#line_age" do
subject { formatter.line_age }
- context ' when there is only new_line' do
+ context " when there is only new_line" do
let(:attrs) { base.merge(new_line: 1) }
- it { is_expected.to eq('new') }
+ it { is_expected.to eq("new") }
end
- context ' when there is only old_line' do
+ context " when there is only old_line" do
let(:attrs) { base.merge(old_line: 1) }
- it { is_expected.to eq('old') }
+ it { is_expected.to eq("old") }
end
end
end
diff --git a/spec/lib/gitlab/diff/highlight_cache_spec.rb b/spec/lib/gitlab/diff/highlight_cache_spec.rb
index bfcfed4231f..331f43b2efd 100644
--- a/spec/lib/gitlab/diff/highlight_cache_spec.rb
+++ b/spec/lib/gitlab/diff/highlight_cache_spec.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::HighlightCache do
let(:merge_request) { create(:merge_request_with_diffs) }
subject(:cache) { described_class.new(merge_request.diffs, backend: backend) }
- describe '#decorate' do
- let(:backend) { double('backend').as_null_object }
+ describe "#decorate" do
+ let(:backend) { double("backend").as_null_object }
# Manually creates a Diff::File object to avoid triggering the cache on
# the FileCollection::MergeRequestDiff
let(:diff_file) do
diffs = merge_request.diffs
- raw_diff = diffs.diffable.raw_diffs(diffs.diff_options.merge(paths: ['CHANGELOG'])).first
+ raw_diff = diffs.diffable.raw_diffs(diffs.diff_options.merge(paths: ["CHANGELOG"])).first
Gitlab::Diff::File.new(raw_diff,
- repository: diffs.project.repository,
- diff_refs: diffs.diff_refs,
- fallback_diff_refs: diffs.fallback_diff_refs)
+ repository: diffs.project.repository,
+ diff_refs: diffs.diff_refs,
+ fallback_diff_refs: diffs.fallback_diff_refs)
end
- it 'does not calculate highlighting when reading from cache' do
+ it "does not calculate highlighting when reading from cache" do
cache.write_if_empty
cache.decorate(diff_file)
@@ -30,14 +30,14 @@ describe Gitlab::Diff::HighlightCache do
diff_file.highlighted_diff_lines
end
- it 'assigns highlighted diff lines to the DiffFile' do
+ it "assigns highlighted diff lines to the DiffFile" do
cache.write_if_empty
cache.decorate(diff_file)
expect(diff_file.highlighted_diff_lines.size).to be > 5
end
- it 'submits a single reading from the cache' do
+ it "submits a single reading from the cache" do
cache.decorate(diff_file)
cache.decorate(diff_file)
@@ -45,23 +45,23 @@ describe Gitlab::Diff::HighlightCache do
end
end
- describe '#write_if_empty' do
- let(:backend) { double('backend', read: {}).as_null_object }
+ describe "#write_if_empty" do
+ let(:backend) { double("backend", read: {}).as_null_object }
- it 'submits a single writing to the cache' do
+ it "submits a single writing to the cache" do
cache.write_if_empty
cache.write_if_empty
expect(backend).to have_received(:write).with(cache.key,
- hash_including('CHANGELOG-false-false-false'),
- expires_in: 1.week).once
+ hash_including("CHANGELOG-false-false-false"),
+ expires_in: 1.week).once
end
end
- describe '#clear' do
- let(:backend) { double('backend').as_null_object }
+ describe "#clear" do
+ let(:backend) { double("backend").as_null_object }
- it 'clears cache' do
+ it "clears cache" do
cache.clear
expect(backend).to have_received(:delete).with(cache.key)
diff --git a/spec/lib/gitlab/diff/highlight_spec.rb b/spec/lib/gitlab/diff/highlight_spec.rb
index 5d0a603d11d..f5357c0a219 100644
--- a/spec/lib/gitlab/diff/highlight_spec.rb
+++ b/spec/lib/gitlab/diff/highlight_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::Highlight do
include RepoHelpers
@@ -8,7 +8,7 @@ describe Gitlab::Diff::Highlight do
let(:diff) { commit.raw_diffs.first }
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: project.repository) }
- shared_examples 'without inline diffs' do
+ shared_examples "without inline diffs" do
let(:code) { '<h2 onmouseover="alert(2)">Test</h2>' }
before do
@@ -16,50 +16,50 @@ describe Gitlab::Diff::Highlight do
allow_any_instance_of(Gitlab::Diff::Line).to receive(:text).and_return(code)
end
- it 'returns html escaped diff text' do
+ it "returns html escaped diff text" do
expect(subject[1].rich_text).to eq html_escape(code)
expect(subject[1].rich_text).to be_html_safe
end
end
- describe '#highlight' do
+ describe "#highlight" do
context "with a diff file" do
let(:subject) { described_class.new(diff_file, repository: project.repository).highlight }
- it 'returns Gitlab::Diff::Line elements' do
+ it "returns Gitlab::Diff::Line elements" do
expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line)
end
it 'does not modify "match" lines' do
- expect(subject[0].text).to eq('@@ -6,12 +6,18 @@ module Popen')
- expect(subject[22].text).to eq('@@ -19,6 +25,7 @@ module Popen')
+ expect(subject[0].text).to eq("@@ -6,12 +6,18 @@ module Popen")
+ expect(subject[22].text).to eq("@@ -19,6 +25,7 @@ module Popen")
end
- it 'highlights and marks unchanged lines' do
- code = %Q{ <span id="LC7" class="line" lang="ruby"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>\n}
+ it "highlights and marks unchanged lines" do
+ code = %{ <span id="LC7" class="line" lang="ruby"> <span class="k">def</span> <span class="nf">popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="kp">nil</span><span class="p">)</span></span>\n}
expect(subject[2].rich_text).to eq(code)
end
- it 'highlights and marks removed lines' do
- code = %Q{-<span id="LC9" class="line" lang="ruby"> <span class="k">raise</span> <span class="s2">"System commands must be given as an array of strings"</span></span>\n}
+ it "highlights and marks removed lines" do
+ code = %(-<span id="LC9" class="line" lang="ruby"> <span class="k">raise</span> <span class="s2">"System commands must be given as an array of strings"</span></span>\n)
expect(subject[4].rich_text).to eq(code)
end
- it 'highlights and marks added lines' do
- code = %Q{+<span id="LC9" class="line" lang="ruby"> <span class="k">raise</span> <span class="no"><span class="idiff left">RuntimeError</span></span><span class="p"><span class="idiff">,</span></span><span class="idiff right"> </span><span class="s2">"System commands must be given as an array of strings"</span></span>\n}
+ it "highlights and marks added lines" do
+ code = %(+<span id="LC9" class="line" lang="ruby"> <span class="k">raise</span> <span class="no"><span class="idiff left">RuntimeError</span></span><span class="p"><span class="idiff">,</span></span><span class="idiff right"> </span><span class="s2">"System commands must be given as an array of strings"</span></span>\n)
expect(subject[5].rich_text).to eq(code)
end
- context 'when no diff_refs' do
+ context "when no diff_refs" do
before do
allow(diff_file).to receive(:diff_refs).and_return(nil)
end
- context 'when no inline diffs' do
- it_behaves_like 'without inline diffs'
+ context "when no inline diffs" do
+ it_behaves_like "without inline diffs"
end
end
end
@@ -67,59 +67,59 @@ describe Gitlab::Diff::Highlight do
context "with diff lines" do
let(:subject) { described_class.new(diff_file.diff_lines, repository: project.repository).highlight }
- it 'returns Gitlab::Diff::Line elements' do
+ it "returns Gitlab::Diff::Line elements" do
expect(subject.first).to be_an_instance_of(Gitlab::Diff::Line)
end
it 'does not modify "match" lines' do
- expect(subject[0].text).to eq('@@ -6,12 +6,18 @@ module Popen')
- expect(subject[22].text).to eq('@@ -19,6 +25,7 @@ module Popen')
+ expect(subject[0].text).to eq("@@ -6,12 +6,18 @@ module Popen")
+ expect(subject[22].text).to eq("@@ -19,6 +25,7 @@ module Popen")
end
- it 'marks unchanged lines' do
- code = %q{ def popen(cmd, path=nil)}
+ it "marks unchanged lines" do
+ code = " def popen(cmd, path=nil)"
expect(subject[2].text).to eq(code)
expect(subject[2].text).not_to be_html_safe
end
- it 'marks removed lines' do
- code = %q{- raise "System commands must be given as an array of strings"}
+ it "marks removed lines" do
+ code = '- raise "System commands must be given as an array of strings"'
expect(subject[4].text).to eq(code)
expect(subject[4].text).not_to be_html_safe
end
- it 'marks added lines' do
- code = %q{+ raise <span class="idiff left right">RuntimeError, </span>&quot;System commands must be given as an array of strings&quot;}
+ it "marks added lines" do
+ code = '+ raise <span class="idiff left right">RuntimeError, </span>&quot;System commands must be given as an array of strings&quot;'
expect(subject[5].rich_text).to eq(code)
expect(subject[5].rich_text).to be_html_safe
end
- context 'when the inline diff marker has an invalid range' do
+ context "when the inline diff marker has an invalid range" do
before do
allow_any_instance_of(Gitlab::Diff::InlineDiffMarker).to receive(:mark).and_raise(RangeError)
end
- it 'keeps the original rich line' do
+ it "keeps the original rich line" do
allow(Gitlab::Sentry).to receive(:track_exception)
- code = %q{+ raise RuntimeError, "System commands must be given as an array of strings"}
+ code = '+ raise RuntimeError, "System commands must be given as an array of strings"'
expect(subject[5].text).to eq(code)
expect(subject[5].text).not_to be_html_safe
end
- it 'reports to Sentry if configured' do
+ it "reports to Sentry if configured" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original
expect { subject }. to raise_exception(RangeError)
end
end
- context 'when no inline diffs' do
- it_behaves_like 'without inline diffs'
+ context "when no inline diffs" do
+ it_behaves_like "without inline diffs"
end
end
end
diff --git a/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb b/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb
index 7e17437fa2a..215fed9878c 100644
--- a/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb
+++ b/spec/lib/gitlab/diff/inline_diff_markdown_marker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::InlineDiffMarkdownMarker do
- describe '#mark' do
+ describe "#mark" do
let(:raw) { "abc 'def'" }
let(:inline_diffs) { [2..5] }
let(:subject) { described_class.new(raw).mark(inline_diffs, mode: :deletion) }
- it 'does not escape html etities and marks the range' do
+ it "does not escape html etities and marks the range" do
expect(subject).to eq("ab{-c 'd-}ef'")
expect(subject).not_to be_html_safe
end
diff --git a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb
index 97e65318059..0142686ed54 100644
--- a/spec/lib/gitlab/diff/inline_diff_marker_spec.rb
+++ b/spec/lib/gitlab/diff/inline_diff_marker_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::InlineDiffMarker do
- describe '#mark' do
+ describe "#mark" do
let(:inline_diffs) { [2..5] }
let(:raw) { "abc 'def'" }
subject { described_class.new(raw, rich).mark(inline_diffs) }
context "when the rich text is html safe" do
- let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">&#39;def&#39;</span>}.html_safe }
+ let(:rich) { %(<span class="abc">abc</span><span class="space"> </span><span class="def">&#39;def&#39;</span>).html_safe }
- it 'marks the range' do
- expect(subject).to eq(%{<span class="abc">ab<span class="idiff left">c</span></span><span class="space"><span class="idiff"> </span></span><span class="def"><span class="idiff right">&#39;d</span>ef&#39;</span>})
+ it "marks the range" do
+ expect(subject).to eq(%(<span class="abc">ab<span class="idiff left">c</span></span><span class="space"><span class="idiff"> </span></span><span class="def"><span class="idiff right">&#39;d</span>ef&#39;</span>))
expect(subject).to be_html_safe
end
end
@@ -19,8 +19,8 @@ describe Gitlab::Diff::InlineDiffMarker do
context "when the text is not html safe" do
let(:rich) { "abc 'def' differs" }
- it 'marks the range' do
- expect(subject).to eq(%{ab<span class="idiff left right">c &#39;d</span>ef&#39; differs})
+ it "marks the range" do
+ expect(subject).to eq(%(ab<span class="idiff left right">c &#39;d</span>ef&#39; differs))
expect(subject).to be_html_safe
end
end
diff --git a/spec/lib/gitlab/diff/inline_diff_spec.rb b/spec/lib/gitlab/diff/inline_diff_spec.rb
index 0a41362f606..c1823f8a80e 100644
--- a/spec/lib/gitlab/diff/inline_diff_spec.rb
+++ b/spec/lib/gitlab/diff/inline_diff_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::InlineDiff do
- describe '.for_lines' do
+ describe ".for_lines" do
let(:diff) do
<<-EOF.strip_heredoc
class Test
@@ -20,7 +20,7 @@ describe Gitlab::Diff::InlineDiff do
let(:subject) { described_class.for_lines(diff.lines) }
- it 'finds all inline diffs' do
+ it "finds all inline diffs" do
expect(subject[0]).to be_nil
expect(subject[1]).to eq([25..27])
expect(subject[2]).to eq([25..28])
@@ -32,8 +32,8 @@ describe Gitlab::Diff::InlineDiff do
expect(subject[8]).to be_nil
end
- it 'can handle unchanged empty lines' do
- expect { described_class.for_lines(['- bar', '+ baz', '']) }.not_to raise_error
+ it "can handle unchanged empty lines" do
+ expect { described_class.for_lines(["- bar", "+ baz", ""]) }.not_to raise_error
end
end
diff --git a/spec/lib/gitlab/diff/line_mapper_spec.rb b/spec/lib/gitlab/diff/line_mapper_spec.rb
index 42750bf9ea1..e40eb79d9ce 100644
--- a/spec/lib/gitlab/diff/line_mapper_spec.rb
+++ b/spec/lib/gitlab/diff/line_mapper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::LineMapper do
include RepoHelpers
@@ -11,7 +11,7 @@ describe Gitlab::Diff::LineMapper do
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) }
subject { described_class.new(diff_file) }
- describe '#old_to_new' do
+ describe "#old_to_new" do
context "with a diff file" do
let(:mapping) do
{
@@ -52,11 +52,11 @@ describe Gitlab::Diff::LineMapper do
27 => 34,
28 => 35,
29 => 36,
- 30 => 37
+ 30 => 37,
}
end
- it 'returns the new line number for the old line number' do
+ it "returns the new line number for the old line number" do
mapping.each do |old_line, new_line|
expect(subject.old_to_new(old_line)).to eq(new_line)
end
@@ -72,7 +72,7 @@ describe Gitlab::Diff::LineMapper do
end
end
- describe '#new_to_old' do
+ describe "#new_to_old" do
context "with a diff file" do
let(:mapping) do
{
@@ -115,11 +115,11 @@ describe Gitlab::Diff::LineMapper do
34 => 27,
35 => 28,
36 => 29,
- 37 => 30
+ 37 => 30,
}
end
- it 'returns the old line number for the new line number' do
+ it "returns the old line number for the new line number" do
mapping.each do |new_line, old_line|
expect(subject.new_to_old(new_line)).to eq(old_line)
end
diff --git a/spec/lib/gitlab/diff/line_spec.rb b/spec/lib/gitlab/diff/line_spec.rb
index 76d411973c7..576b732c699 100644
--- a/spec/lib/gitlab/diff/line_spec.rb
+++ b/spec/lib/gitlab/diff/line_spec.rb
@@ -1,10 +1,10 @@
describe Gitlab::Diff::Line do
- describe '.init_from_hash' do
- it 'round-trips correctly with to_hash' do
- line = described_class.new('<input>', 'match', 0, 0, 1,
- parent_file: double(:file),
- line_code: double(:line_code),
- rich_text: '&lt;input&gt;')
+ describe ".init_from_hash" do
+ it "round-trips correctly with to_hash" do
+ line = described_class.new("<input>", "match", 0, 0, 1,
+ parent_file: double(:file),
+ line_code: double(:line_code),
+ rich_text: "&lt;input&gt;")
expect(described_class.init_from_hash(line.to_hash).to_hash)
.to eq(line.to_hash)
@@ -12,7 +12,7 @@ describe Gitlab::Diff::Line do
end
context "when setting rich text" do
- it 'escapes any HTML special characters in the diff chunk header' do
+ it "escapes any HTML special characters in the diff chunk header" do
subject = described_class.new("<input>", "", 0, 0, 0)
line = subject.as_json
diff --git a/spec/lib/gitlab/diff/lines_unfolder_spec.rb b/spec/lib/gitlab/diff/lines_unfolder_spec.rb
index 8a470e12d04..1e9423b6762 100644
--- a/spec/lib/gitlab/diff/lines_unfolder_spec.rb
+++ b/spec/lib/gitlab/diff/lines_unfolder_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::LinesUnfolder do
let(:raw_diff) do
@@ -210,19 +210,19 @@ describe Gitlab::Diff::LinesUnfolder do
subject { described_class.new(diff_file, position) }
- context 'position requires a middle expansion and new match lines' do
+ context "position requires a middle expansion and new match lines" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
head_sha: "1487062132228de836236c522fe52fed4980a46c",
old_path: "build-aux/flatpak/org.gnome.Nautilus.json",
new_path: "build-aux/flatpak/org.gnome.Nautilus.json",
- position_type: "text",
+ position_type: "text",
old_line: 43,
new_line: 40)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[40, 40, " \"config-opts\": [ \"--disable-introspection\" ],"],
[41, 41, " \"sources\": ["],
@@ -230,10 +230,10 @@ describe Gitlab::Diff::LinesUnfolder do
[43, 43, " \"type\": \"git\","],
[44, 44, " \"url\": \"https://git.gnome.org/browse/gexiv2\""],
[45, 45, " }"],
- [46, 46, " ]"]]
+ [46, 46, " ]"],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(7)
@@ -244,7 +244,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
[[7, 7, "@@ -7,9 +7,6 @@"],
[7, 7, " \"tags\": [\"devel\", \"development\", \"nightly\"],"],
@@ -292,10 +292,10 @@ describe Gitlab::Diff::LinesUnfolder do
[90, 83, "- ],"],
[91, 83, " \"sources\": ["],
[92, 84, " {"],
- [93, 85, " \"type\": \"git\","]]
+ [93, 85, " \"type\": \"git\","],]
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -305,13 +305,13 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
@@ -319,27 +319,27 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'position requires a middle expansion and no top match line' do
+ context "position requires a middle expansion and no top match line" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
head_sha: "1487062132228de836236c522fe52fed4980a46c",
old_path: "build-aux/flatpak/org.gnome.Nautilus.json",
new_path: "build-aux/flatpak/org.gnome.Nautilus.json",
- position_type: "text",
+ position_type: "text",
old_line: 16,
new_line: 17)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[16, 16, " \"--filesystem=xdg-run/dconf\", \"--filesystem=~/.config/dconf:ro\","],
[17, 17, " \"--talk-name=ca.desrt.dconf\", \"--env=DCONF_USER_CONFIG_DIR=.config/dconf\""],
[18, 18, " ],"],
- [19, 19, " \"cleanup\": [ \"/include\", \"/share/bash-completion\" ],"]]
+ [19, 19, " \"cleanup\": [ \"/include\", \"/share/bash-completion\" ],"],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(4)
@@ -350,7 +350,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
[[7, 7, "@@ -7,9 +7,6 @@"],
[7, 7, " \"tags\": [\"devel\", \"development\", \"nightly\"],"],
@@ -393,10 +393,10 @@ describe Gitlab::Diff::LinesUnfolder do
[90, 83, "- ],"],
[91, 83, " \"sources\": ["],
[92, 84, " {"],
- [93, 85, " \"type\": \"git\","]]
+ [93, 85, " \"type\": \"git\","],]
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -406,13 +406,13 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
@@ -420,27 +420,27 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'position requires a middle expansion and no bottom match line' do
+ context "position requires a middle expansion and no bottom match line" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
head_sha: "1487062132228de836236c522fe52fed4980a46c",
old_path: "build-aux/flatpak/org.gnome.Nautilus.json",
new_path: "build-aux/flatpak/org.gnome.Nautilus.json",
- position_type: "text",
+ position_type: "text",
old_line: 82,
new_line: 79)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[79, 79, " }"],
[80, 80, " ]"],
[81, 81, " },"],
- [82, 82, " {"]]
+ [82, 82, " {"],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(4)
@@ -451,7 +451,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
[[7, 7, "@@ -7,9 +7,6 @@"],
[7, 7, " \"tags\": [\"devel\", \"development\", \"nightly\"],"],
@@ -494,10 +494,10 @@ describe Gitlab::Diff::LinesUnfolder do
[90, 83, "- ],"],
[91, 83, " \"sources\": ["],
[92, 84, " {"],
- [93, 85, " \"type\": \"git\","]]
+ [93, 85, " \"type\": \"git\","],]
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -507,13 +507,13 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
@@ -521,7 +521,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'position requires a short top expansion' do
+ context "position requires a short top expansion" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
@@ -533,15 +533,15 @@ describe Gitlab::Diff::LinesUnfolder do
new_line: 6)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[3, 3, " \"runtime\": \"org.gnome.Platform\","],
[4, 4, " \"runtime-version\": \"master\","],
[5, 5, " \"sdk\": \"org.gnome.Sdk\","],
- [6, 6, " \"command\": \"nautilus\","]]
+ [6, 6, " \"command\": \"nautilus\","],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(4)
@@ -552,7 +552,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
# New match line
[[3, 3, "@@ -3,4+3,4 @@"],
@@ -592,10 +592,10 @@ describe Gitlab::Diff::LinesUnfolder do
[90, 83, "- ],"],
[91, 83, " \"sources\": ["],
[92, 84, " {"],
- [93, 85, " \"type\": \"git\","]]
+ [93, 85, " \"type\": \"git\","],]
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -605,13 +605,13 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
@@ -619,7 +619,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'position sits between two match lines (no expasion needed)' do
+ context "position sits between two match lines (no expasion needed)" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
@@ -631,14 +631,14 @@ describe Gitlab::Diff::LinesUnfolder do
new_line: 61)
end
- context 'diff lines' do
- it 'returns nil' do
+ context "diff lines" do
+ it "returns nil" do
expect(subject.unfolded_diff_lines).to be_nil
end
end
end
- context 'position requires bottom expansion and new match lines' do
+ context "position requires bottom expansion and new match lines" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
@@ -650,7 +650,7 @@ describe Gitlab::Diff::LinesUnfolder do
new_line: 99)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[104, 104, " \"sdk\": \"foo\","],
[105, 105, " \"command\": \"foo\","],
@@ -658,10 +658,10 @@ describe Gitlab::Diff::LinesUnfolder do
[107, 107, " \"desktop-file-name-prefix\": \"(Foo) \","],
[108, 108, " {"],
[109, 109, " \"buildsystem\": \"meson\","],
- [110, 110, " \"builddir\": true,"]]
+ [110, 110, " \"builddir\": true,"],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(7)
@@ -672,7 +672,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
[[7, 7, "@@ -7,9 +7,6 @@"],
[7, 7, " \"tags\": [\"devel\", \"development\", \"nightly\"],"],
@@ -715,11 +715,11 @@ describe Gitlab::Diff::LinesUnfolder do
[107, 99, " \"desktop-file-name-prefix\": \"(Foo) \","],
[108, 100, " {"],
[109, 101, " \"buildsystem\": \"meson\","],
- [110, 102, " \"builddir\": true,"]]
+ [110, 102, " \"builddir\": true,"],]
# end
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -729,20 +729,20 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
end
end
- context 'position requires bottom expansion and no new match line' do
+ context "position requires bottom expansion and no new match line" do
let(:position) do
Gitlab::Diff::Position.new(base_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
start_sha: "1c59dfa64afbea8c721bb09a06a9d326c952ea19",
@@ -754,16 +754,16 @@ describe Gitlab::Diff::LinesUnfolder do
new_line: 87)
end
- context 'blob lines' do
+ context "blob lines" do
let(:expected_blob_lines) do
[[94, 94, " \"url\": \"https://gitlab.gnome.org/GNOME/nautilus.git\""],
[95, 95, " }"],
[96, 96, " ]"],
[97, 97, " }"],
- [98, 98, " ]"]]
+ [98, 98, " ]"],]
end
- it 'returns the extracted blob lines correctly' do
+ it "returns the extracted blob lines correctly" do
extracted_lines = subject.blob_lines
expect(extracted_lines.size).to eq(5)
@@ -774,7 +774,7 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- context 'diff lines' do
+ context "diff lines" do
let(:expected_diff_lines) do
[[7, 7, "@@ -7,9 +7,6 @@"],
[7, 7, " \"tags\": [\"devel\", \"development\", \"nightly\"],"],
@@ -814,11 +814,11 @@ describe Gitlab::Diff::LinesUnfolder do
[95, 87, " }"],
[96, 88, " ]"],
[97, 89, " }"],
- [98, 90, " ]"]]
+ [98, 90, " ]"],]
# end
end
- it 'return merge of blob lines with diff lines correctly' do
+ it "return merge of blob lines with diff lines correctly" do
new_diff_lines = subject.unfolded_diff_lines
expected_diff_lines.each_with_index do |expected_line, i|
@@ -828,13 +828,13 @@ describe Gitlab::Diff::LinesUnfolder do
end
end
- it 'merged lines have correct line codes' do
+ it "merged lines have correct line codes" do
new_diff_lines = subject.unfolded_diff_lines
new_diff_lines.each_with_index do |line, i|
old_pos, new_pos = expected_diff_lines[i][0], expected_diff_lines[i][1]
- unless line.type == 'match'
+ unless line.type == "match"
expect(line.line_code).to eq(Gitlab::Git.diff_line_code(diff_file.file_path, new_pos, old_pos))
end
end
diff --git a/spec/lib/gitlab/diff/parallel_diff_spec.rb b/spec/lib/gitlab/diff/parallel_diff_spec.rb
index e9fc7be366a..e0e5827d779 100644
--- a/spec/lib/gitlab/diff/parallel_diff_spec.rb
+++ b/spec/lib/gitlab/diff/parallel_diff_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::ParallelDiff do
include RepoHelpers
@@ -11,48 +11,48 @@ describe Gitlab::Diff::ParallelDiff do
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: commit.diff_refs, repository: repository) }
subject { described_class.new(diff_file) }
- describe '#parallelize' do
- it 'returns an array of arrays containing the parsed diff' do
+ describe "#parallelize" do
+ it "returns an array of arrays containing the parsed diff" do
diff_lines = diff_file.highlighted_diff_lines
expected = [
# Unchanged lines
- { left: diff_lines[0], right: diff_lines[0] },
- { left: diff_lines[1], right: diff_lines[1] },
- { left: diff_lines[2], right: diff_lines[2] },
- { left: diff_lines[3], right: diff_lines[3] },
- { left: diff_lines[4], right: diff_lines[5] },
- { left: diff_lines[6], right: diff_lines[6] },
- { left: diff_lines[7], right: diff_lines[7] },
- { left: diff_lines[8], right: diff_lines[8] },
+ {left: diff_lines[0], right: diff_lines[0]},
+ {left: diff_lines[1], right: diff_lines[1]},
+ {left: diff_lines[2], right: diff_lines[2]},
+ {left: diff_lines[3], right: diff_lines[3]},
+ {left: diff_lines[4], right: diff_lines[5]},
+ {left: diff_lines[6], right: diff_lines[6]},
+ {left: diff_lines[7], right: diff_lines[7]},
+ {left: diff_lines[8], right: diff_lines[8]},
# Changed lines
- { left: diff_lines[9], right: diff_lines[11] },
- { left: diff_lines[10], right: diff_lines[12] },
+ {left: diff_lines[9], right: diff_lines[11]},
+ {left: diff_lines[10], right: diff_lines[12]},
# Added lines
- { left: nil, right: diff_lines[13] },
- { left: nil, right: diff_lines[14] },
- { left: nil, right: diff_lines[15] },
- { left: nil, right: diff_lines[16] },
- { left: nil, right: diff_lines[17] },
- { left: nil, right: diff_lines[18] },
+ {left: nil, right: diff_lines[13]},
+ {left: nil, right: diff_lines[14]},
+ {left: nil, right: diff_lines[15]},
+ {left: nil, right: diff_lines[16]},
+ {left: nil, right: diff_lines[17]},
+ {left: nil, right: diff_lines[18]},
# Unchanged lines
- { left: diff_lines[19], right: diff_lines[19] },
- { left: diff_lines[20], right: diff_lines[20] },
- { left: diff_lines[21], right: diff_lines[21] },
- { left: diff_lines[22], right: diff_lines[22] },
- { left: diff_lines[23], right: diff_lines[23] },
- { left: diff_lines[24], right: diff_lines[24] },
- { left: diff_lines[25], right: diff_lines[25] },
+ {left: diff_lines[19], right: diff_lines[19]},
+ {left: diff_lines[20], right: diff_lines[20]},
+ {left: diff_lines[21], right: diff_lines[21]},
+ {left: diff_lines[22], right: diff_lines[22]},
+ {left: diff_lines[23], right: diff_lines[23]},
+ {left: diff_lines[24], right: diff_lines[24]},
+ {left: diff_lines[25], right: diff_lines[25]},
# Added line
- { left: nil, right: diff_lines[26] },
+ {left: nil, right: diff_lines[26]},
# Unchanged lines
- { left: diff_lines[27], right: diff_lines[27] },
- { left: diff_lines[28], right: diff_lines[28] },
- { left: diff_lines[29], right: diff_lines[29] }
+ {left: diff_lines[27], right: diff_lines[27]},
+ {left: diff_lines[28], right: diff_lines[28]},
+ {left: diff_lines[29], right: diff_lines[29]},
]
expect(subject.parallelize).to eq(expected)
diff --git a/spec/lib/gitlab/diff/parser_spec.rb b/spec/lib/gitlab/diff/parser_spec.rb
index 80c8c189665..8a8134ade6b 100644
--- a/spec/lib/gitlab/diff/parser_spec.rb
+++ b/spec/lib/gitlab/diff/parser_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::Parser do
include RepoHelpers
@@ -8,42 +8,42 @@ describe Gitlab::Diff::Parser do
let(:diff) { commit.raw_diffs.first }
let(:parser) { described_class.new }
- describe '#parse' do
+ describe "#parse" do
let(:diff) do
- <<eos
---- a/files/ruby/popen.rb
-+++ b/files/ruby/popen.rb
-@@ -6,12 +6,18 @@ module Popen
-
- def popen(cmd, path=nil)
- unless cmd.is_a?(Array)
-- raise "System commands must be given as an array of strings"
-+ raise RuntimeError, "System commands must be given as an array of strings"
- end
-
- path ||= Dir.pwd
-- vars = { "PWD" => path }
-- options = { chdir: path }
-+
-+ vars = {
-+ "PWD" => path
-+ }
-+
-+ options = {
-+ chdir: path
-+ }
-
- unless File.directory?(path)
- FileUtils.mkdir_p(path)
-@@ -19,6 +25,7 @@ module Popen
-
- @cmd_output = ""
- @cmd_status = 0
-+
- Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
- @cmd_output << stdout.read
- @cmd_output << stderr.read
-eos
+ <<~eos
+ --- a/files/ruby/popen.rb
+ +++ b/files/ruby/popen.rb
+ @@ -6,12 +6,18 @@ module Popen
+
+ def popen(cmd, path=nil)
+ unless cmd.is_a?(Array)
+ - raise "System commands must be given as an array of strings"
+ + raise RuntimeError, "System commands must be given as an array of strings"
+ end
+
+ path ||= Dir.pwd
+ - vars = { "PWD" => path }
+ - options = { chdir: path }
+ +
+ + vars = {
+ + "PWD" => path
+ + }
+ +
+ + options = {
+ + chdir: path
+ + }
+
+ unless File.directory?(path)
+ FileUtils.mkdir_p(path)
+ @@ -19,6 +25,7 @@ module Popen
+
+ @cmd_output = ""
+ @cmd_status = 0
+ +
+ Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
+ @cmd_output << stdout.read
+ @cmd_output << stderr.read
+ eos
end
before do
@@ -52,41 +52,41 @@ eos
it { expect(@lines.size).to eq(30) }
- describe 'lines' do
- describe 'first line' do
+ describe "lines" do
+ describe "first line" do
let(:line) { @lines.first }
- it { expect(line.type).to eq('match') }
+ it { expect(line.type).to eq("match") }
it { expect(line.old_pos).to eq(6) }
it { expect(line.new_pos).to eq(6) }
- it { expect(line.text).to eq('@@ -6,12 +6,18 @@ module Popen') }
+ it { expect(line.text).to eq("@@ -6,12 +6,18 @@ module Popen") }
end
- describe 'removal line' do
+ describe "removal line" do
let(:line) { @lines[10] }
- it { expect(line.type).to eq('old') }
+ it { expect(line.type).to eq("old") }
it { expect(line.old_pos).to eq(14) }
it { expect(line.new_pos).to eq(13) }
- it { expect(line.text).to eq('- options = { chdir: path }') }
+ it { expect(line.text).to eq("- options = { chdir: path }") }
end
- describe 'addition line' do
+ describe "addition line" do
let(:line) { @lines[16] }
- it { expect(line.type).to eq('new') }
+ it { expect(line.type).to eq("new") }
it { expect(line.old_pos).to eq(15) }
it { expect(line.new_pos).to eq(18) }
- it { expect(line.text).to eq('+ options = {') }
+ it { expect(line.text).to eq("+ options = {") }
end
- describe 'unchanged line' do
+ describe "unchanged line" do
let(:line) { @lines.last }
it { expect(line.type).to eq(nil) }
it { expect(line.old_pos).to eq(24) }
it { expect(line.new_pos).to eq(31) }
- it { expect(line.text).to eq(' @cmd_output << stderr.read') }
+ it { expect(line.text).to eq(" @cmd_output << stderr.read") }
end
end
end
@@ -104,10 +104,10 @@ eos
END
lines = parser.parse(first_nonewline_diff.lines).to_a
- expect(lines[0].type).to eq('new')
- expect(lines[0].text).to eq('+ipsum')
- expect(lines[2].type).to eq('old')
- expect(lines[3].type).to eq('old-nonewline')
+ expect(lines[0].type).to eq("new")
+ expect(lines[0].text).to eq("+ipsum")
+ expect(lines[2].type).to eq("old")
+ expect(lines[3].type).to eq("old-nonewline")
expect(lines[1].old_pos).to eq(1)
expect(lines[1].new_pos).to eq(2)
end
@@ -126,25 +126,25 @@ eos
END
lines = parser.parse(both_nonewline_diff.lines).to_a
- expect(lines[0].type).to eq('old')
- expect(lines[1].type).to eq('old')
- expect(lines[2].type).to eq('old-nonewline')
- expect(lines[5].type).to eq('new-nonewline')
- expect(lines[3].text).to eq('+ipsum')
+ expect(lines[0].type).to eq("old")
+ expect(lines[1].type).to eq("old")
+ expect(lines[2].type).to eq("old-nonewline")
+ expect(lines[5].type).to eq("new-nonewline")
+ expect(lines[3].text).to eq("+ipsum")
expect(lines[3].old_pos).to eq(3)
expect(lines[3].new_pos).to eq(1)
- expect(lines[4].text).to eq('+lorem')
+ expect(lines[4].text).to eq("+lorem")
expect(lines[4].old_pos).to eq(3)
expect(lines[4].new_pos).to eq(2)
end
end
- context 'when lines is empty' do
+ context "when lines is empty" do
it { expect(parser.parse([])).to eq([]) }
it { expect(parser.parse(nil)).to eq([]) }
end
- describe 'tolerates special diff markers in a content' do
+ describe "tolerates special diff markers in a content" do
it "counts lines correctly" do
diff = <<~END
--- a/test
diff --git a/spec/lib/gitlab/diff/position_spec.rb b/spec/lib/gitlab/diff/position_spec.rb
index cc4faf6f10b..c0b836e1d2b 100644
--- a/spec/lib/gitlab/diff/position_spec.rb
+++ b/spec/lib/gitlab/diff/position_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::Position do
include RepoHelpers
@@ -16,7 +16,7 @@ describe Gitlab::Diff::Position do
height: 100,
x: 1,
y: 100,
- position_type: "image"
+ position_type: "image",
}
end
@@ -29,7 +29,7 @@ describe Gitlab::Diff::Position do
base_sha: nil,
head_sha: nil,
start_sha: nil,
- position_type: "text"
+ position_type: "text",
}
end
@@ -474,9 +474,9 @@ describe Gitlab::Diff::Position do
describe "position for a file in a straight comparison" do
let(:diff_refs) do
Gitlab::Diff::DiffRefs.new(
- start_sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9', # feature
- base_sha: '0b4bc9a49b562e85de7cc9e834518ea6828729b9',
- head_sha: 'e63f41fe459e62e1228fcef60d7189127aeba95a' # master
+ start_sha: "0b4bc9a49b562e85de7cc9e834518ea6828729b9", # feature
+ base_sha: "0b4bc9a49b562e85de7cc9e834518ea6828729b9",
+ head_sha: "e63f41fe459e62e1228fcef60d7189127aeba95a" # master
)
end
@@ -519,7 +519,7 @@ describe Gitlab::Diff::Position do
end
end
- describe '#==' do
+ describe "#==" do
let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
subject do
@@ -532,26 +532,26 @@ describe Gitlab::Diff::Position do
)
end
- context 'when positions are equal' do
+ context "when positions are equal" do
let(:other) { described_class.new(subject.to_h) }
- it 'returns true' do
+ it "returns true" do
expect(subject).to eq(other)
end
end
- context 'when positions are equal, except for truncated shas' do
+ context "when positions are equal, except for truncated shas" do
let(:other) { described_class.new(subject.to_h.merge(start_sha: subject.start_sha[0, 10])) }
- it 'returns true' do
+ it "returns true" do
expect(subject).to eq(other)
end
end
- context 'when positions are unequal' do
+ context "when positions are unequal" do
let(:other) { described_class.new(subject.to_h.merge(start_sha: subject.start_sha.reverse)) }
- it 'returns false' do
+ it "returns false" do
expect(subject).not_to eq(other)
end
end
@@ -588,7 +588,7 @@ describe Gitlab::Diff::Position do
end
it "works when nested under another hash" do
- expect(JSON.parse(JSON.generate(pos: diff_position))).to eq('pos' => args.stringify_keys)
+ expect(JSON.parse(JSON.generate(pos: diff_position))).to eq("pos" => args.stringify_keys)
end
end
diff --git a/spec/lib/gitlab/diff/position_tracer_spec.rb b/spec/lib/gitlab/diff/position_tracer_spec.rb
index 866550753a8..27e55e6be9d 100644
--- a/spec/lib/gitlab/diff/position_tracer_spec.rb
+++ b/spec/lib/gitlab/diff/position_tracer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Diff::PositionTracer do
# Douwe's diary New York City, 2016-06-28
@@ -1377,13 +1377,13 @@ describe Gitlab::Diff::PositionTracer do
let(:second_branch_name) { "#{branch_name}-2" }
def expect_new_positions(old_attrs, new_attrs)
- old_positions = old_attrs.map do |old_attrs|
+ old_positions = old_attrs.map { |old_attrs|
position(old_attrs)
- end
+ }
- new_positions = old_positions.map do |old_position|
+ new_positions = old_positions.map { |old_position|
position_tracer.trace(old_position)
- end
+ }
aggregate_failures do
new_positions.zip(new_attrs).each do |new_position, new_attrs|
@@ -1498,25 +1498,25 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 2 }, # C
- { old_path: file_name, old_line: 4 }, # - D
- { new_path: file_name, new_line: 3 }, # + DD
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 4 }, # E
- { old_path: file_name, new_path: file_name, old_line: 6, new_line: 5 }, # F
- { new_path: file_name, new_line: 6 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 2}, # C
+ {old_path: file_name, old_line: 4}, # - D
+ {new_path: file_name, new_line: 3}, # + DD
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 4}, # E
+ {old_path: file_name, new_path: file_name, old_line: 6, new_line: 5}, # F
+ {new_path: file_name, new_line: 6}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 },
- { old_path: file_name, old_line: 2 },
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 },
- { new_path: file_name, new_line: 4, change: true },
- { new_path: file_name, old_line: 3, change: true },
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 },
- { new_path: file_name, old_line: 5, change: true },
- { new_path: file_name, new_line: 7 }
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1},
+ {old_path: file_name, old_line: 2},
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3},
+ {new_path: file_name, new_line: 4, change: true},
+ {new_path: file_name, old_line: 3, change: true},
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5},
+ {new_path: file_name, old_line: 5, change: true},
+ {new_path: file_name, new_line: 7},
]
expect_new_positions(old_position_attrs, new_position_attrs)
@@ -1571,25 +1571,25 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 2 }, # C
- { old_path: file_name, old_line: 4 }, # - D
- { new_path: file_name, new_line: 3 }, # + DD
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 4 }, # E
- { old_path: file_name, new_path: file_name, old_line: 6, new_line: 5 }, # F
- { new_path: file_name, new_line: 6 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 2}, # C
+ {old_path: file_name, old_line: 4}, # - D
+ {new_path: file_name, new_line: 3}, # + DD
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 4}, # E
+ {old_path: file_name, new_path: file_name, old_line: 6, new_line: 5}, # F
+ {new_path: file_name, new_line: 6}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 },
- { old_path: file_name, old_line: 2 },
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 },
- { new_path: file_name, new_line: 4, change: true },
- { old_path: file_name, old_line: 3, change: true },
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 },
- { old_path: file_name, old_line: 5, change: true },
- { new_path: file_name, new_line: 7 }
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1},
+ {old_path: file_name, old_line: 2},
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3},
+ {new_path: file_name, new_line: 4, change: true},
+ {old_path: file_name, old_line: 3, change: true},
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5},
+ {old_path: file_name, old_line: 5, change: true},
+ {new_path: file_name, new_line: 7},
]
expect_new_positions(old_position_attrs, new_position_attrs)
@@ -1624,27 +1624,27 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 2 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 4 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 6 }, # + FF
- { new_path: file_name, new_line: 7 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 2}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 4}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 6}, # + FF
+ {new_path: file_name, new_line: 7}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 },
- { old_path: file_name, old_line: 2 },
- { old_path: file_name, old_line: 2, change: true },
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 2 },
- { old_path: file_name, old_line: 4, change: true },
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 4 },
- { new_path: file_name, new_line: 5, change: true },
- { old_path: file_name, old_line: 6, change: true },
- { new_path: file_name, new_line: 6 }
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1},
+ {old_path: file_name, old_line: 2},
+ {old_path: file_name, old_line: 2, change: true},
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 2},
+ {old_path: file_name, old_line: 4, change: true},
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 4},
+ {new_path: file_name, new_line: 5, change: true},
+ {old_path: file_name, old_line: 6, change: true},
+ {new_path: file_name, new_line: 6},
]
expect_new_positions(old_position_attrs, new_position_attrs)
@@ -1742,27 +1742,27 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 2 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 4 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 6 }, # + FF
- { new_path: file_name, new_line: 7 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 2}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 4}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 6}, # + FF
+ {new_path: file_name, new_line: 7}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 4 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 5 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 6 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 7 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 8 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 9 }, # + FF
- { new_path: file_name, new_line: 10 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 4}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 5}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 6}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 7}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 8}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 9}, # + FF
+ {new_path: file_name, new_line: 10}, # + G
]
expect_new_positions(old_position_attrs, new_position_attrs)
@@ -1811,27 +1811,27 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 2 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 4 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 6 }, # + FF
- { new_path: file_name, new_line: 7 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 2}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 4}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 6}, # + FF
+ {new_path: file_name, new_line: 7}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 4 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 5 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 6 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 7 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 8 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 9 }, # + FF
- { new_path: file_name, new_line: 10 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 4}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 5}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 6}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 7}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 8}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 9}, # + FF
+ {new_path: file_name, new_line: 10}, # + G
]
expect_new_positions(old_position_attrs, new_position_attrs)
@@ -1867,27 +1867,27 @@ describe Gitlab::Diff::PositionTracer do
it "returns the new positions" do
old_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 }, # A
- { old_path: file_name, old_line: 2 }, # - B
- { new_path: file_name, new_line: 2 }, # + BB
- { old_path: file_name, new_path: file_name, old_line: 3, new_line: 3 }, # C
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 4 }, # D
- { old_path: file_name, new_path: file_name, old_line: 5, new_line: 5 }, # E
- { old_path: file_name, old_line: 6 }, # - F
- { new_path: file_name, new_line: 6 }, # + FF
- { new_path: file_name, new_line: 7 }, # + G
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1}, # A
+ {old_path: file_name, old_line: 2}, # - B
+ {new_path: file_name, new_line: 2}, # + BB
+ {old_path: file_name, new_path: file_name, old_line: 3, new_line: 3}, # C
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 4}, # D
+ {old_path: file_name, new_path: file_name, old_line: 5, new_line: 5}, # E
+ {old_path: file_name, old_line: 6}, # - F
+ {new_path: file_name, new_line: 6}, # + FF
+ {new_path: file_name, new_line: 7}, # + G
]
new_position_attrs = [
- { old_path: file_name, new_path: file_name, old_line: 1, new_line: 1 },
- { old_path: file_name, old_line: 2, change: true },
- { new_path: file_name, new_line: 2 },
- { old_path: file_name, new_path: file_name, old_line: 2, new_line: 3 },
- { new_path: file_name, new_line: 4 },
- { old_path: file_name, new_path: file_name, old_line: 4, new_line: 5 },
- { old_path: file_name, old_line: 5 },
- { new_path: file_name, new_line: 6 },
- { new_path: file_name, new_line: 7 }
+ {old_path: file_name, new_path: file_name, old_line: 1, new_line: 1},
+ {old_path: file_name, old_line: 2, change: true},
+ {new_path: file_name, new_line: 2},
+ {old_path: file_name, new_path: file_name, old_line: 2, new_line: 3},
+ {new_path: file_name, new_line: 4},
+ {old_path: file_name, new_path: file_name, old_line: 4, new_line: 5},
+ {old_path: file_name, old_line: 5},
+ {new_path: file_name, new_line: 6},
+ {new_path: file_name, new_line: 7},
]
expect_new_positions(old_position_attrs, new_position_attrs)
diff --git a/spec/lib/gitlab/discussions_diff/file_collection_spec.rb b/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
index 0489206458b..f6489a3c829 100644
--- a/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
+++ b/spec/lib/gitlab/discussions_diff/file_collection_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DiscussionsDiff::FileCollection do
let(:merge_request) { create(:merge_request) }
@@ -11,38 +11,38 @@ describe Gitlab::DiscussionsDiff::FileCollection do
subject { described_class.new([note_diff_file_a, note_diff_file_b]) }
- describe '#load_highlight', :clean_gitlab_redis_shared_state do
- it 'writes uncached diffs highlight' do
+ describe "#load_highlight", :clean_gitlab_redis_shared_state do
+ it "writes uncached diffs highlight" do
file_a_caching_content = diff_note_a.diff_file.highlighted_diff_lines.map(&:to_hash)
file_b_caching_content = diff_note_b.diff_file.highlighted_diff_lines.map(&:to_hash)
expect(Gitlab::DiscussionsDiff::HighlightCache)
.to receive(:write_multiple)
- .with({ note_diff_file_a.id => file_a_caching_content,
- note_diff_file_b.id => file_b_caching_content })
+ .with({note_diff_file_a.id => file_a_caching_content,
+ note_diff_file_b.id => file_b_caching_content,})
.and_call_original
subject.load_highlight([note_diff_file_a.id, note_diff_file_b.id])
end
- it 'does not write cache for already cached file' do
+ it "does not write cache for already cached file" do
subject.load_highlight([note_diff_file_a.id])
file_b_caching_content = diff_note_b.diff_file.highlighted_diff_lines.map(&:to_hash)
expect(Gitlab::DiscussionsDiff::HighlightCache)
.to receive(:write_multiple)
- .with({ note_diff_file_b.id => file_b_caching_content })
+ .with({note_diff_file_b.id => file_b_caching_content})
.and_call_original
subject.load_highlight([note_diff_file_a.id, note_diff_file_b.id])
end
- it 'does not err when given ID does not exist in @collection' do
+ it "does not err when given ID does not exist in @collection" do
expect { subject.load_highlight([999]) }.not_to raise_error
end
- it 'loaded diff files have highlighted lines loaded' do
+ it "loaded diff files have highlighted lines loaded" do
subject.load_highlight([note_diff_file_a.id])
diff_file = subject.find_by_id(note_diff_file_a.id)
@@ -50,7 +50,7 @@ describe Gitlab::DiscussionsDiff::FileCollection do
expect(diff_file.highlight_loaded?).to be(true)
end
- it 'not loaded diff files does not have highlighted lines loaded' do
+ it "not loaded diff files does not have highlighted lines loaded" do
subject.load_highlight([note_diff_file_a.id])
diff_file = subject.find_by_id(note_diff_file_b.id)
diff --git a/spec/lib/gitlab/discussions_diff/highlight_cache_spec.rb b/spec/lib/gitlab/discussions_diff/highlight_cache_spec.rb
index fe26ebb8796..1f0574b0a10 100644
--- a/spec/lib/gitlab/discussions_diff/highlight_cache_spec.rb
+++ b/spec/lib/gitlab/discussions_diff/highlight_cache_spec.rb
@@ -1,31 +1,31 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DiscussionsDiff::HighlightCache, :clean_gitlab_redis_cache do
- describe '#write_multiple' do
- it 'sets multiple keys serializing content as JSON' do
+ describe "#write_multiple" do
+ it "sets multiple keys serializing content as JSON" do
mapping = {
3 => [
{
- text: 'foo',
- type: 'new',
+ text: "foo",
+ type: "new",
index: 2,
old_pos: 10,
new_pos: 11,
- line_code: 'xpto',
- rich_text: '<blips>blops</blips>'
+ line_code: "xpto",
+ rich_text: "<blips>blops</blips>",
},
{
- text: 'foo',
- type: 'new',
+ text: "foo",
+ type: "new",
index: 3,
old_pos: 11,
new_pos: 12,
- line_code: 'xpto',
- rich_text: '<blops>blips</blops>'
- }
- ]
+ line_code: "xpto",
+ rich_text: "<blops>blips</blops>",
+ },
+ ],
}
described_class.write_multiple(mapping)
@@ -39,29 +39,29 @@ describe Gitlab::DiscussionsDiff::HighlightCache, :clean_gitlab_redis_cache do
end
end
- describe '#read_multiple' do
- it 'reads multiple keys and serializes content into Gitlab::Diff::Line objects' do
+ describe "#read_multiple" do
+ it "reads multiple keys and serializes content into Gitlab::Diff::Line objects" do
mapping = {
3 => [
{
- text: 'foo',
- type: 'new',
+ text: "foo",
+ type: "new",
index: 2,
old_pos: 11,
new_pos: 12,
- line_code: 'xpto',
- rich_text: '<blips>blops</blips>'
+ line_code: "xpto",
+ rich_text: "<blips>blops</blips>",
},
{
- text: 'foo',
- type: 'new',
+ text: "foo",
+ type: "new",
index: 3,
old_pos: 10,
new_pos: 11,
- line_code: 'xpto',
- rich_text: '<blips>blops</blips>'
- }
- ]
+ line_code: "xpto",
+ rich_text: "<blips>blops</blips>",
+ },
+ ],
}
described_class.write_multiple(mapping)
@@ -73,19 +73,19 @@ describe Gitlab::DiscussionsDiff::HighlightCache, :clean_gitlab_redis_cache do
expect(found.first).to all(be_a(Gitlab::Diff::Line))
end
- it 'returns nil when cached key is not found' do
+ it "returns nil when cached key is not found" do
mapping = {
3 => [
{
- text: 'foo',
- type: 'new',
+ text: "foo",
+ type: "new",
index: 2,
old_pos: 11,
new_pos: 12,
- line_code: 'xpto',
- rich_text: '<blips>blops</blips>'
- }
- ]
+ line_code: "xpto",
+ rich_text: "<blips>blops</blips>",
+ },
+ ],
}
described_class.write_multiple(mapping)
diff --git a/spec/lib/gitlab/downtime_check/message_spec.rb b/spec/lib/gitlab/downtime_check/message_spec.rb
index a5a398abf78..ee20ea6c1e0 100644
--- a/spec/lib/gitlab/downtime_check/message_spec.rb
+++ b/spec/lib/gitlab/downtime_check/message_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DowntimeCheck::Message do
- describe '#to_s' do
- it 'returns an ANSI formatted String for an offline migration' do
- message = described_class.new('foo.rb', true, 'hello')
+ describe "#to_s" do
+ it "returns an ANSI formatted String for an offline migration" do
+ message = described_class.new("foo.rb", true, "hello")
expect(message.to_s).to eq("[\e[31moffline\e[0m]: foo.rb:\n\nhello\n\n")
end
- it 'returns an ANSI formatted String for an online migration' do
- message = described_class.new('foo.rb')
+ it "returns an ANSI formatted String for an online migration" do
+ message = described_class.new("foo.rb")
expect(message.to_s).to eq("[\e[32monline\e[0m]: foo.rb")
end
end
- describe '#reason?' do
- it 'returns false when no reason is specified' do
- message = described_class.new('foo.rb')
+ describe "#reason?" do
+ it "returns false when no reason is specified" do
+ message = described_class.new("foo.rb")
expect(message.reason?).to eq(false)
end
- it 'returns true when a reason is specified' do
- message = described_class.new('foo.rb', true, 'hello')
+ it "returns true when a reason is specified" do
+ message = described_class.new("foo.rb", true, "hello")
expect(message.reason?).to eq(true)
end
end
- describe '#reason' do
- it 'strips excessive whitespace from the returned String' do
- message = described_class.new('foo.rb', true, " hello\n world\n\n foo")
+ describe "#reason" do
+ it "strips excessive whitespace from the returned String" do
+ message = described_class.new("foo.rb", true, " hello\n world\n\n foo")
expect(message.reason).to eq("hello\nworld\n\nfoo")
end
diff --git a/spec/lib/gitlab/downtime_check_spec.rb b/spec/lib/gitlab/downtime_check_spec.rb
index 1f1e4e0216c..5570c4e2b72 100644
--- a/spec/lib/gitlab/downtime_check_spec.rb
+++ b/spec/lib/gitlab/downtime_check_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::DowntimeCheck do
subject { described_class.new }
- let(:path) { 'foo.rb' }
+ let(:path) { "foo.rb" }
- describe '#check' do
+ describe "#check" do
before do
expect(subject).to receive(:require).with(path)
end
- context 'when a migration does not specify if downtime is required' do
- it 'raises RuntimeError' do
+ context "when a migration does not specify if downtime is required" do
+ it "raises RuntimeError" do
expect(subject).to receive(:class_for_migration_file)
.with(path)
.and_return(Class.new)
@@ -20,10 +20,10 @@ describe Gitlab::DowntimeCheck do
end
end
- context 'when a migration requires downtime' do
- context 'when no reason is specified' do
- it 'raises RuntimeError' do
- stub_const('TestMigration::DOWNTIME', true)
+ context "when a migration requires downtime" do
+ context "when no reason is specified" do
+ it "raises RuntimeError" do
+ stub_const("TestMigration::DOWNTIME", true)
expect(subject).to receive(:class_for_migration_file)
.with(path)
@@ -34,10 +34,10 @@ describe Gitlab::DowntimeCheck do
end
end
- context 'when a reason is specified' do
- it 'returns an Array of messages' do
- stub_const('TestMigration::DOWNTIME', true)
- stub_const('TestMigration::DOWNTIME_REASON', 'foo')
+ context "when a reason is specified" do
+ it "returns an Array of messages" do
+ stub_const("TestMigration::DOWNTIME", true)
+ stub_const("TestMigration::DOWNTIME_REASON", "foo")
expect(subject).to receive(:class_for_migration_file)
.with(path)
@@ -52,16 +52,16 @@ describe Gitlab::DowntimeCheck do
expect(message.path).to eq(path)
expect(message.offline).to eq(true)
- expect(message.reason).to eq('foo')
+ expect(message.reason).to eq("foo")
end
end
end
end
- describe '#check_and_print' do
- it 'checks the migrations and prints the results to STDOUT' do
- stub_const('TestMigration::DOWNTIME', true)
- stub_const('TestMigration::DOWNTIME_REASON', 'foo')
+ describe "#check_and_print" do
+ it "checks the migrations and prints the results to STDOUT" do
+ stub_const("TestMigration::DOWNTIME", true)
+ stub_const("TestMigration::DOWNTIME_REASON", "foo")
expect(subject).to receive(:require).with(path)
@@ -75,37 +75,37 @@ describe Gitlab::DowntimeCheck do
end
end
- describe '#class_for_migration_file' do
- it 'returns the class for a migration file path' do
- expect(subject.class_for_migration_file('123_string.rb')).to eq(String)
+ describe "#class_for_migration_file" do
+ it "returns the class for a migration file path" do
+ expect(subject.class_for_migration_file("123_string.rb")).to eq(String)
end
end
- describe '#online?' do
- it 'returns true when a migration can be performed online' do
- stub_const('TestMigration::DOWNTIME', false)
+ describe "#online?" do
+ it "returns true when a migration can be performed online" do
+ stub_const("TestMigration::DOWNTIME", false)
expect(subject.online?(TestMigration)).to eq(true)
end
- it 'returns false when a migration can not be performed online' do
- stub_const('TestMigration::DOWNTIME', true)
+ it "returns false when a migration can not be performed online" do
+ stub_const("TestMigration::DOWNTIME", true)
expect(subject.online?(TestMigration)).to eq(false)
end
end
- describe '#downtime_reason' do
- context 'when a reason is defined' do
- it 'returns the downtime reason' do
- stub_const('TestMigration::DOWNTIME_REASON', 'hello')
+ describe "#downtime_reason" do
+ context "when a reason is defined" do
+ it "returns the downtime reason" do
+ stub_const("TestMigration::DOWNTIME_REASON", "hello")
- expect(subject.downtime_reason(TestMigration)).to eq('hello')
+ expect(subject.downtime_reason(TestMigration)).to eq("hello")
end
end
- context 'when a reason is not defined' do
- it 'returns nil' do
+ context "when a reason is not defined" do
+ it "returns nil" do
expect(subject.downtime_reason(Class.new)).to be_nil
end
end
diff --git a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb
index 48139c2f9dc..e5194240707 100644
--- a/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_issue_handler_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Handler::CreateIssueHandler do
include_context :email_shared_context
@@ -8,18 +8,18 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
before do
stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo")
- stub_config_setting(host: 'localhost')
+ stub_config_setting(host: "localhost")
end
- let(:email_raw) { email_fixture('emails/valid_new_issue.eml') }
- let(:namespace) { create(:namespace, path: 'gitlabhq') }
+ let(:email_raw) { email_fixture("emails/valid_new_issue.eml") }
+ let(:namespace) { create(:namespace, path: "gitlabhq") }
- let!(:project) { create(:project, :public, namespace: namespace, path: 'gitlabhq') }
+ let!(:project) { create(:project, :public, namespace: namespace, path: "gitlabhq") }
let!(:user) do
create(
:user,
- email: 'jake@adventuretime.ooo',
- incoming_email_token: 'auth_token'
+ email: "jake@adventuretime.ooo",
+ incoming_email_token: "auth_token"
)
end
@@ -38,7 +38,7 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
it "matches the legacy format" do
handler = described_class.new(mail, "h5bp/html5-boilerplate+#{user.incoming_email_token}")
- expect(handler.instance_variable_get(:@project_path)).to eq 'h5bp/html5-boilerplate'
+ expect(handler.instance_variable_get(:@project_path)).to eq "h5bp/html5-boilerplate"
expect(handler.instance_variable_get(:@incoming_email_token)).to eq user.incoming_email_token
expect(handler.can_handle?).to be_truthy
end
@@ -59,8 +59,8 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
issue = project.issues.last
expect(issue.author).to eq(user)
- expect(issue.title).to eq('New Issue by email')
- expect(issue.description).to include('reply by email')
+ expect(issue.title).to eq("New Issue by email")
+ expect(issue.description).to include("reply by email")
expect(issue.description).to include(markdown)
end
end
@@ -68,7 +68,7 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
it_behaves_like "a new issue"
context "creates a new issue with legacy email address" do
- let(:email_raw) { fixture_file('emails/valid_new_issue_legacy.eml') }
+ let(:email_raw) { fixture_file("emails/valid_new_issue_legacy.eml") }
it_behaves_like "a new issue"
end
@@ -81,8 +81,8 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
issue = project.issues.last
expect(issue.author).to eq(user)
- expect(issue.title).to eq('New Issue by email')
- expect(issue.description).to eq('')
+ expect(issue.title).to eq("New Issue by email")
+ expect(issue.description).to eq("")
end
end
@@ -94,9 +94,9 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
issue = project.issues.last
expect(issue.author).to eq(user)
- expect(issue.title).to eq('New Issue by email')
- expect(issue.description).to include('reply by email')
- expect(issue.description).to include('> this is a quote')
+ expect(issue.title).to eq("New Issue by email")
+ expect(issue.description).to include("reply by email")
+ expect(issue.description).to include("> this is a quote")
end
end
end
@@ -130,6 +130,6 @@ describe Gitlab::Email::Handler::CreateIssueHandler do
end
def email_fixture(path)
- fixture_file(path).gsub('project_id', project.project_id.to_s)
+ fixture_file(path).gsub("project_id", project.project_id.to_s)
end
end
diff --git a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
index 2fa86b2b46f..53dafb225c8 100644
--- a/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_merge_request_handler_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Handler::CreateMergeRequestHandler do
include_context :email_shared_context
@@ -8,22 +8,22 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
before do
stub_incoming_email_setting(enabled: true, address: "incoming+%{key}@appmail.adventuretime.ooo")
- stub_config_setting(host: 'localhost')
+ stub_config_setting(host: "localhost")
end
after do
TestEnv.clean_test_path
end
- let(:email_raw) { email_fixture('emails/valid_new_merge_request.eml') }
- let(:namespace) { create(:namespace, path: 'gitlabhq') }
+ let(:email_raw) { email_fixture("emails/valid_new_merge_request.eml") }
+ let(:namespace) { create(:namespace, path: "gitlabhq") }
- let!(:project) { create(:project, :public, :repository, namespace: namespace, path: 'gitlabhq') }
+ let!(:project) { create(:project, :public, :repository, namespace: namespace, path: "gitlabhq") }
let!(:user) do
create(
:user,
- email: 'jake@adventuretime.ooo',
- incoming_email_token: 'auth_token'
+ email: "jake@adventuretime.ooo",
+ incoming_email_token: "auth_token"
)
end
@@ -42,7 +42,7 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
it "matches the legacy format" do
handler = described_class.new(mail, "h5bp/html5-boilerplate+merge-request+#{user.incoming_email_token}")
- expect(handler.instance_variable_get(:@project_path)).to eq 'h5bp/html5-boilerplate'
+ expect(handler.instance_variable_get(:@project_path)).to eq "h5bp/html5-boilerplate"
expect(handler.instance_variable_get(:@incoming_email_token)).to eq user.incoming_email_token
expect(handler.can_handle?).to be_truthy
end
@@ -76,9 +76,9 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
merge_request = project.merge_requests.last
expect(merge_request.author).to eq(user)
- expect(merge_request.source_branch).to eq('feature')
- expect(merge_request.title).to eq('Feature added')
- expect(merge_request.description).to eq('Merge request description')
+ expect(merge_request.source_branch).to eq("feature")
+ expect(merge_request.title).to eq("Feature added")
+ expect(merge_request.description).to eq("Merge request description")
expect(merge_request.target_branch).to eq(project.default_branch)
end
end
@@ -86,7 +86,7 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
it_behaves_like "a new merge request"
context "creates a new merge request with legacy email address" do
- let(:email_raw) { fixture_file('emails/valid_new_merge_request_legacy.eml') }
+ let(:email_raw) { fixture_file("emails/valid_new_merge_request_legacy.eml") }
it_behaves_like "a new merge request"
end
@@ -126,74 +126,74 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
expect { receiver.execute }.to change { project.merge_requests.count }.by(1)
merge_request = project.merge_requests.last
- expect(merge_request.description).to eq('Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>')
+ expect(merge_request.description).to eq("Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>")
end
end
end
- context 'when the email contains patch attachments' do
+ context "when the email contains patch attachments" do
let(:email_raw) { email_fixture("emails/valid_merge_request_with_patch.eml") }
- it 'creates the source branch and applies the patches' do
+ it "creates the source branch and applies the patches" do
receiver.execute
- branch = project.repository.find_branch('new-branch-with-a-patch')
+ branch = project.repository.find_branch("new-branch-with-a-patch")
expect(branch).not_to be_nil
- expect(branch.dereferenced_target.message).to include('A commit from a patch')
+ expect(branch.dereferenced_target.message).to include("A commit from a patch")
end
- it 'creates the merge request' do
+ it "creates the merge request" do
expect { receiver.execute }
- .to change { project.merge_requests.where(source_branch: 'new-branch-with-a-patch').size }.by(1)
+ .to change { project.merge_requests.where(source_branch: "new-branch-with-a-patch").size }.by(1)
end
- it 'does not mention the patches in the created merge request' do
+ it "does not mention the patches in the created merge request" do
receiver.execute
- merge_request = project.merge_requests.find_by!(source_branch: 'new-branch-with-a-patch')
+ merge_request = project.merge_requests.find_by!(source_branch: "new-branch-with-a-patch")
- expect(merge_request.description).not_to include('0001-A-commit-from-a-patch.patch')
+ expect(merge_request.description).not_to include("0001-A-commit-from-a-patch.patch")
end
- context 'when the patch could not be applied' do
+ context "when the patch could not be applied" do
let(:email_raw) { email_fixture("emails/merge_request_with_conflicting_patch.eml") }
- it 'raises an error' do
+ it "raises an error" do
expect { receiver.execute }.to raise_error(Gitlab::Email::InvalidAttachment)
end
end
- context 'when specifying the target branch using quick actions' do
- let(:email_raw) { email_fixture('emails/merge_request_with_patch_and_target_branch.eml') }
+ context "when specifying the target branch using quick actions" do
+ let(:email_raw) { email_fixture("emails/merge_request_with_patch_and_target_branch.eml") }
- it 'creates the merge request with the correct target branch' do
+ it "creates the merge request with the correct target branch" do
receiver.execute
- merge_request = project.merge_requests.find_by!(source_branch: 'new-branch-with-a-patch')
+ merge_request = project.merge_requests.find_by!(source_branch: "new-branch-with-a-patch")
- expect(merge_request.target_branch).to eq('with-codeowners')
+ expect(merge_request.target_branch).to eq("with-codeowners")
end
- it 'based the merge request of the target_branch' do
+ it "based the merge request of the target_branch" do
receiver.execute
- merge_request = project.merge_requests.find_by!(source_branch: 'new-branch-with-a-patch')
+ merge_request = project.merge_requests.find_by!(source_branch: "new-branch-with-a-patch")
- expect(merge_request.diff_base_commit).to eq(project.repository.commit('with-codeowners'))
+ expect(merge_request.diff_base_commit).to eq(project.repository.commit("with-codeowners"))
end
end
end
end
- describe '#patch_attachments' do
- let(:email_raw) { email_fixture('emails/merge_request_multiple_patches.eml') }
+ describe "#patch_attachments" do
+ let(:email_raw) { email_fixture("emails/merge_request_multiple_patches.eml") }
let(:mail) { Mail::Message.new(email_raw) }
subject(:handler) { described_class.new(mail, mail_key) }
- it 'orders attachments ending in `.patch` by name' do
+ it "orders attachments ending in `.patch` by name" do
expected_filenames = ["0001-A-commit-from-a-patch.patch",
- "0002-This-does-not-apply-to-the-feature-branch.patch"]
+ "0002-This-does-not-apply-to-the-feature-branch.patch",]
attachments = handler.__send__(:patch_attachments).map(&:filename)
@@ -202,6 +202,6 @@ describe Gitlab::Email::Handler::CreateMergeRequestHandler do
end
def email_fixture(path)
- fixture_file(path).gsub('project_id', project.project_id.to_s)
+ fixture_file(path).gsub("project_id", project.project_id.to_s)
end
end
diff --git a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
index 50e473c459e..cdb143bb697 100644
--- a/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/create_note_handler_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Handler::CreateNoteHandler do
include_context :email_shared_context
@@ -8,10 +8,10 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
before do
stub_incoming_email_setting(enabled: true, address: "reply+%{key}@appmail.adventuretime.ooo")
- stub_config_setting(host: 'localhost')
+ stub_config_setting(host: "localhost")
end
- let(:email_raw) { fixture_file('emails/valid_reply.eml') }
+ let(:email_raw) { fixture_file("emails/valid_reply.eml") }
let(:project) { create(:project, :public, :repository) }
let(:user) { create(:user) }
let(:note) { create(:diff_note_on_merge_request, project: project) }
@@ -22,7 +22,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
end
context "when the recipient address doesn't include a mail key" do
- let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "") }
+ let(:email_raw) { fixture_file("emails/valid_reply.eml").gsub(mail_key, "") }
it "raises a UnknownIncomingEmail" do
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
@@ -30,7 +30,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
end
context "when no sent notification for the mail key could be found" do
- let(:email_raw) { fixture_file('emails/wrong_mail_key.eml') }
+ let(:email_raw) { fixture_file("emails/wrong_mail_key.eml") }
it "raises a SentNotificationNotFoundError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::SentNotificationNotFoundError)
@@ -56,21 +56,21 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
expect { receiver.execute }.to raise_error(Gitlab::Email::InvalidNoteError)
end
- context 'because the note was update commands only' do
+ context "because the note was update commands only" do
let!(:email_raw) { fixture_file("emails/update_commands_only_reply.eml") }
- context 'and current user cannot update noteable' do
- it 'raises a CommandsOnlyNoteError' do
+ context "and current user cannot update noteable" do
+ it "raises a CommandsOnlyNoteError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::InvalidNoteError)
end
end
- context 'and current user can update noteable' do
+ context "and current user can update noteable" do
before do
project.add_developer(user)
end
- it 'does not raise an error' do
+ it "does not raise an error" do
# One system note is created for the 'close' event
expect { receiver.execute }.to change { noteable.notes.count }.by(1)
@@ -80,11 +80,11 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
end
end
- context 'when the note contains quick actions' do
+ context "when the note contains quick actions" do
let!(:email_raw) { fixture_file("emails/commands_in_reply.eml") }
- context 'and current user cannot update the noteable' do
- it 'only executes the commands that the user can perform' do
+ context "and current user cannot update the noteable" do
+ it "only executes the commands that the user can perform" do
expect { receiver.execute }
.to change { noteable.notes.user.count }.by(1)
.and change { user.todos_pending_count }.from(0).to(1)
@@ -93,12 +93,12 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
end
end
- context 'and current user can update noteable' do
+ context "and current user can update noteable" do
before do
project.add_developer(user)
end
- it 'posts a note and updates the noteable' do
+ it "posts a note and updates the noteable" do
expect(TodoService.new.todo_exist?(noteable, user)).to be_falsy
expect { receiver.execute }
@@ -155,7 +155,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
it_behaves_like "checks permissions on noteable"
end
- shared_examples 'a reply to existing comment' do
+ shared_examples "a reply to existing comment" do
it "creates a comment" do
expect { receiver.execute }.to change { noteable.notes.count }.by(1)
new_note = noteable.notes.last
@@ -178,7 +178,7 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
setup_attachment
end
- it_behaves_like 'a reply to existing comment'
+ it_behaves_like "a reply to existing comment"
it "adds all attachments" do
receiver.execute
@@ -188,32 +188,32 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
expect(note.note).to include(markdown)
end
- context 'when sub-addressing is not supported' do
+ context "when sub-addressing is not supported" do
before do
stub_incoming_email_setting(enabled: true, address: nil)
end
- shared_examples 'an email that contains a mail key' do |header|
+ shared_examples "an email that contains a mail key" do |header|
it "fetches the mail key from the #{header} header and creates a comment" do
expect { receiver.execute }.to change { noteable.notes.count }.by(1)
new_note = noteable.notes.last
expect(new_note.author).to eq(sent_notification.recipient)
expect(new_note.position).to eq(note.position)
- expect(new_note.note).to include('I could not disagree more.')
+ expect(new_note.note).to include("I could not disagree more.")
end
end
- context 'mail key is in the References header' do
- let(:email_raw) { fixture_file('emails/reply_without_subaddressing_and_key_inside_references.eml') }
+ context "mail key is in the References header" do
+ let(:email_raw) { fixture_file("emails/reply_without_subaddressing_and_key_inside_references.eml") }
- it_behaves_like 'an email that contains a mail key', 'References'
+ it_behaves_like "an email that contains a mail key", "References"
end
- context 'mail key is in the References header with a comma' do
- let(:email_raw) { fixture_file('emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml') }
+ context "mail key is in the References header with a comma" do
+ let(:email_raw) { fixture_file("emails/reply_without_subaddressing_and_key_inside_references_with_a_comma.eml") }
- it_behaves_like 'an email that contains a mail key', 'References'
+ it_behaves_like "an email that contains a mail key", "References"
end
end
end
@@ -221,6 +221,6 @@ describe Gitlab::Email::Handler::CreateNoteHandler do
context "when note is not a discussion" do
let(:note) { create(:note_on_merge_request, project: project) }
- it_behaves_like 'a reply to existing comment'
+ it_behaves_like "a reply to existing comment"
end
end
diff --git a/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb b/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb
index dcddd00df59..a3f2c83c6bd 100644
--- a/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb
+++ b/spec/lib/gitlab/email/handler/unsubscribe_handler_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Handler::UnsubscribeHandler do
include_context :email_shared_context
before do
- stub_incoming_email_setting(enabled: true, address: 'reply+%{key}@appmail.adventuretime.ooo')
- stub_config_setting(host: 'localhost')
+ stub_incoming_email_setting(enabled: true, address: "reply+%{key}@appmail.adventuretime.ooo")
+ stub_config_setting(host: "localhost")
end
- let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "#{mail_key}#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX}") }
+ let(:email_raw) { fixture_file("emails/valid_reply.eml").gsub(mail_key, "#{mail_key}#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX}") }
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:noteable) { create(:issue, project: project) }
@@ -39,53 +39,53 @@ describe Gitlab::Email::Handler::UnsubscribeHandler do
end
end
- context 'when notification concerns a commit' do
+ context "when notification concerns a commit" do
let(:commit) { create(:commit, project: project) }
let!(:sent_notification) { SentNotification.record(commit, user.id, mail_key) }
- it 'handler does not raise an error' do
+ it "handler does not raise an error" do
expect { receiver.execute }.not_to raise_error
end
end
- context 'user is unsubscribed' do
- it 'leaves user unsubscribed' do
+ context "user is unsubscribed" do
+ it "leaves user unsubscribed" do
expect { receiver.execute }.not_to change { noteable.subscribed?(user) }.from(false)
end
end
- context 'user is subscribed' do
+ context "user is subscribed" do
before do
noteable.subscribe(user)
end
- it 'unsubscribes user from notable' do
+ it "unsubscribes user from notable" do
expect { receiver.execute }.to change { noteable.subscribed?(user) }.from(true).to(false)
end
- context 'when using old style unsubscribe link' do
- let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "#{mail_key}#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY}") }
+ context "when using old style unsubscribe link" do
+ let(:email_raw) { fixture_file("emails/valid_reply.eml").gsub(mail_key, "#{mail_key}#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY}") }
- it 'unsubscribes user from notable' do
+ it "unsubscribes user from notable" do
expect { receiver.execute }.to change { noteable.subscribed?(user) }.from(true).to(false)
end
end
end
- context 'when the noteable could not be found' do
+ context "when the noteable could not be found" do
before do
noteable.destroy
end
- it 'raises a NoteableNotFoundError' do
+ it "raises a NoteableNotFoundError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::NoteableNotFoundError)
end
end
- context 'when no sent notification for the mail key could be found' do
- let(:email_raw) { fixture_file('emails/wrong_mail_key.eml') }
+ context "when no sent notification for the mail key could be found" do
+ let(:email_raw) { fixture_file("emails/wrong_mail_key.eml") }
- it 'raises a SentNotificationNotFoundError' do
+ it "raises a SentNotificationNotFoundError" do
expect { receiver.execute }.to raise_error(Gitlab::Email::SentNotificationNotFoundError)
end
end
diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb
index d2920b08956..361b1aa1e3a 100644
--- a/spec/lib/gitlab/email/handler_spec.rb
+++ b/spec/lib/gitlab/email/handler_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Handler do
- describe '.for' do
- it 'picks issue handler if there is not merge request prefix' do
- expect(described_class.for('email', 'project+key')).to be_an_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
+ describe ".for" do
+ it "picks issue handler if there is not merge request prefix" do
+ expect(described_class.for("email", "project+key")).to be_an_instance_of(Gitlab::Email::Handler::CreateIssueHandler)
end
- it 'picks merge request handler if there is merge request key' do
- expect(described_class.for('email', 'project+merge-request+key')).to be_an_instance_of(Gitlab::Email::Handler::CreateMergeRequestHandler)
+ it "picks merge request handler if there is merge request key" do
+ expect(described_class.for("email", "project+merge-request+key")).to be_an_instance_of(Gitlab::Email::Handler::CreateMergeRequestHandler)
end
- it 'returns nil if no handler is found' do
- expect(described_class.for('email', '')).to be_nil
+ it "returns nil if no handler is found" do
+ expect(described_class.for("email", "")).to be_nil
end
end
- describe 'regexps are set properly' do
+ describe "regexps are set properly" do
let(:addresses) do
- %W(sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX} sent_notification_key path-to-project-123-user_email_token-merge-request path-to-project-123-user_email_token-issue) +
- %W(sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY} sent_notification_key path/to/project+merge-request+user_email_token path/to/project+user_email_token)
+ %W[sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX} sent_notification_key path-to-project-123-user_email_token-merge-request path-to-project-123-user_email_token-issue] +
+ %W[sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX_LEGACY} sent_notification_key path/to/project+merge-request+user_email_token path/to/project+user_email_token]
end
- it 'picks each handler at least once' do
- matched_handlers = addresses.map do |address|
- described_class.for('email', address).class
- end
+ it "picks each handler at least once" do
+ matched_handlers = addresses.map { |address|
+ described_class.for("email", address).class
+ }
expect(matched_handlers.uniq).to match_array(ce_handlers)
end
- it 'can pick exactly one handler for each address' do
+ it "can pick exactly one handler for each address" do
addresses.each do |address|
- matched_handlers = ce_handlers.select do |handler|
- handler.new('email', address).can_handle?
- end
+ matched_handlers = ce_handlers.select { |handler|
+ handler.new("email", address).can_handle?
+ }
expect(matched_handlers.count).to eq(1), "#{address} matches #{matched_handlers.count} handlers: #{matched_handlers}"
end
@@ -43,8 +43,8 @@ describe Gitlab::Email::Handler do
end
def ce_handlers
- @ce_handlers ||= Gitlab::Email::Handler.handlers.reject do |handler|
- handler.name.start_with?('Gitlab::Email::Handler::EE::')
- end
+ @ce_handlers ||= Gitlab::Email::Handler.handlers.reject { |handler|
+ handler.name.start_with?("Gitlab::Email::Handler::EE::")
+ }
end
end
diff --git a/spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb b/spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb
index ae61ece8029..c7fce95e57d 100644
--- a/spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb
+++ b/spec/lib/gitlab/email/hook/additional_headers_interceptor_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Hook::AdditionalHeadersInterceptor do
let(:mail) do
- ActionMailer::Base.mail(to: 'test@mail.com', from: 'info@mail.com', body: 'hello')
+ ActionMailer::Base.mail(to: "test@mail.com", from: "info@mail.com", body: "hello")
end
before do
mail.deliver_now
end
- it 'adds Auto-Submitted header' do
- expect(mail.header['To'].value).to eq('test@mail.com')
- expect(mail.header['From'].value).to eq('info@mail.com')
- expect(mail.header['Auto-Submitted'].value).to eq('auto-generated')
- expect(mail.header['X-Auto-Response-Suppress'].value).to eq('All')
+ it "adds Auto-Submitted header" do
+ expect(mail.header["To"].value).to eq("test@mail.com")
+ expect(mail.header["From"].value).to eq("info@mail.com")
+ expect(mail.header["Auto-Submitted"].value).to eq("auto-generated")
+ expect(mail.header["X-Auto-Response-Suppress"].value).to eq("All")
end
- context 'when the same mail object is sent twice' do
+ context "when the same mail object is sent twice" do
before do
mail.deliver_now
end
- it 'does not add the Auto-Submitted header twice' do
- expect(mail.header['Auto-Submitted'].value).to eq('auto-generated')
- expect(mail.header['X-Auto-Response-Suppress'].value).to eq('All')
+ it "does not add the Auto-Submitted header twice" do
+ expect(mail.header["Auto-Submitted"].value).to eq("auto-generated")
+ expect(mail.header["X-Auto-Response-Suppress"].value).to eq("All")
end
end
end
diff --git a/spec/lib/gitlab/email/hook/delivery_metrics_observer_spec.rb b/spec/lib/gitlab/email/hook/delivery_metrics_observer_spec.rb
index 4497d4002da..57681343ede 100644
--- a/spec/lib/gitlab/email/hook/delivery_metrics_observer_spec.rb
+++ b/spec/lib/gitlab/email/hook/delivery_metrics_observer_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Hook::DeliveryMetricsObserver do
let(:email) do
- ActionMailer::Base.mail(to: 'test@example.com',
- from: 'info@example.com',
- body: 'hello')
+ ActionMailer::Base.mail(to: "test@example.com",
+ from: "info@example.com",
+ body: "hello")
end
- context 'when email has been delivered' do
- it 'increments both email delivery metrics' do
+ context "when email has been delivered" do
+ it "increments both email delivery metrics" do
expect(described_class.delivery_attempts_counter).to receive(:increment)
expect(described_class.delivered_emails_counter).to receive(:increment)
@@ -16,20 +16,20 @@ describe Gitlab::Email::Hook::DeliveryMetricsObserver do
end
end
- context 'when email has not been delivered due to an error' do
+ context "when email has not been delivered due to an error" do
before do
allow(email.delivery_method).to receive(:deliver!)
- .and_raise(StandardError, 'Some SMTP error')
+ .and_raise(StandardError, "Some SMTP error")
end
- it 'increments only delivery attempt metric' do
+ it "increments only delivery attempt metric" do
expect(described_class.delivery_attempts_counter)
.to receive(:increment)
expect(described_class.delivered_emails_counter)
.not_to receive(:increment)
expect { email.deliver_now }
- .to raise_error(StandardError, 'Some SMTP error')
+ .to raise_error(StandardError, "Some SMTP error")
end
end
end
diff --git a/spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb b/spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb
index 91aa3bc7c2e..bb32bfb3ec1 100644
--- a/spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb
+++ b/spec/lib/gitlab/email/hook/disable_email_interceptor_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Hook::DisableEmailInterceptor do
before do
Mail.register_interceptor(described_class)
end
- it 'does 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/gitlab/email/message/repository_push_spec.rb b/spec/lib/gitlab/email/message/repository_push_spec.rb
index 0ec1f931037..6bcf719b7ed 100644
--- a/spec/lib/gitlab/email/message/repository_push_spec.rb
+++ b/spec/lib/gitlab/email/message/repository_push_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Message::RepositoryPush do
include RepoHelpers
- let!(:group) { create(:group, name: 'my_group') }
+ let!(:group) { create(:group, name: "my_group") }
let!(:project) { create(:project, :repository, namespace: group) }
- let!(:author) { create(:author, name: 'Author') }
+ let!(:author) { create(:author, name: "Author") }
let(:message) do
described_class.new(Notify, project.id, opts)
end
- context 'new commits have been pushed to repository' do
+ context "new commits have been pushed to repository" do
let(:opts) do
- { author_id: author.id, ref: 'master', action: :push, compare: compare,
- send_from_committer_email: true }
+ {author_id: author.id, ref: "master", action: :push, compare: compare,
+ send_from_committer_email: true,}
end
let(:raw_compare) do
Gitlab::Git::Compare.new(project.repository.raw_repository,
@@ -24,98 +24,98 @@ describe Gitlab::Email::Message::RepositoryPush do
Compare.decorate(raw_compare, project)
end
- describe '#project' do
+ describe "#project" do
subject { message.project }
it { is_expected.to eq project }
it { is_expected.to be_an_instance_of Project }
end
- describe '#project_namespace' do
+ describe "#project_namespace" do
subject { message.project_namespace }
it { is_expected.to eq group }
it { is_expected.to be_kind_of Namespace }
end
- describe '#project_name_with_namespace' do
+ describe "#project_name_with_namespace" do
subject { message.project_name_with_namespace }
it { is_expected.to eq "#{group.name} / #{project.path}" }
end
- describe '#author' do
+ describe "#author" do
subject { message.author }
it { is_expected.to eq author }
it { is_expected.to be_an_instance_of User }
end
- describe '#author_name' do
+ describe "#author_name" do
subject { message.author_name }
- it { is_expected.to eq 'Author' }
+ it { is_expected.to eq "Author" }
end
- describe '#commits' do
+ describe "#commits" do
subject { message.commits }
it { is_expected.to be_kind_of Array }
it { is_expected.to all(be_instance_of Commit) }
end
- describe '#diffs' do
+ describe "#diffs" do
subject { message.diffs }
- it { is_expected.to all(be_an_instance_of Gitlab::Diff::File) }
+ it { is_expected.to all(be_an_instance_of(Gitlab::Diff::File)) }
end
- describe '#diffs_count' do
+ describe "#diffs_count" do
subject { message.diffs_count }
it { is_expected.to eq raw_compare.diffs.size }
end
- describe '#compare' do
+ describe "#compare" do
subject { message.compare }
it { is_expected.to be_an_instance_of Compare }
end
- describe '#compare_timeout' do
+ describe "#compare_timeout" do
subject { message.compare_timeout }
it { is_expected.to eq raw_compare.diffs.overflow? }
end
- describe '#reverse_compare?' do
+ describe "#reverse_compare?" do
subject { message.reverse_compare? }
it { is_expected.to eq false }
end
- describe '#disable_diffs?' do
+ describe "#disable_diffs?" do
subject { message.disable_diffs? }
it { is_expected.to eq false }
end
- describe '#send_from_committer_email?' do
+ describe "#send_from_committer_email?" do
subject { message.send_from_committer_email? }
it { is_expected.to eq true }
end
- describe '#action_name' do
+ describe "#action_name" do
subject { message.action_name }
- it { is_expected.to eq 'pushed to' }
+ it { is_expected.to eq "pushed to" }
end
- describe '#ref_name' do
+ describe "#ref_name" do
subject { message.ref_name }
- it { is_expected.to eq 'master' }
+ it { is_expected.to eq "master" }
end
- describe '#ref_type' do
+ describe "#ref_type" do
subject { message.ref_type }
- it { is_expected.to eq 'branch' }
+ it { is_expected.to eq "branch" }
end
- describe '#target_url' do
+ describe "#target_url" do
subject { message.target_url }
- it { is_expected.to include 'compare' }
+ it { is_expected.to include "compare" }
it { is_expected.to include compare.commits.first.parents.first.id }
it { is_expected.to include compare.commits.last.id }
end
- describe '#subject' do
+ describe "#subject" do
subject { message.subject }
it { is_expected.to include "[Git][#{project.full_path}]" }
it { is_expected.to include "#{compare.commits.length} commits" }
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index 0af978eced3..a89dbb93aaa 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Email::Receiver do
include_context :email_shared_context
context "when the email contains a valid email address in a Delivered-To header" do
- let(:email_raw) { fixture_file('emails/forwarded_new_issue.eml') }
+ let(:email_raw) { fixture_file("emails/forwarded_new_issue.eml") }
let(:handler) { double(:handler) }
before do
@@ -15,14 +15,14 @@ describe Gitlab::Email::Receiver do
end
it "finds the mail key" do
- expect(Gitlab::Email::Handler).to receive(:for).with(an_instance_of(Mail::Message), 'gitlabhq/gitlabhq+auth_token').and_return(handler)
+ expect(Gitlab::Email::Handler).to receive(:for).with(an_instance_of(Mail::Message), "gitlabhq/gitlabhq+auth_token").and_return(handler)
receiver.execute
end
end
context "when we cannot find a capable handler" do
- let(:email_raw) { fixture_file('emails/valid_reply.eml').gsub(mail_key, "!!!") }
+ let(:email_raw) { fixture_file("emails/valid_reply.eml").gsub(mail_key, "!!!") }
it "raises an UnknownIncomingEmail error" do
expect { receiver.execute }.to raise_error(Gitlab::Email::UnknownIncomingEmail)
diff --git a/spec/lib/gitlab/email/reply_parser_spec.rb b/spec/lib/gitlab/email/reply_parser_spec.rb
index 376d3accd55..ee6e7e2b1fc 100644
--- a/spec/lib/gitlab/email/reply_parser_spec.rb
+++ b/spec/lib/gitlab/email/reply_parser_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
# Inspired in great part by Discourse's Email::Receiver
describe Gitlab::Email::ReplyParser do
- describe '#execute' do
+ describe "#execute" do
def test_parse_body(mail_string, params = {})
described_class.new(Mail::Message.new(mail_string), params).execute
end
@@ -214,7 +214,7 @@ describe Gitlab::Email::ReplyParser do
end
it "does not trim reply if trim_reply option is false" do
- expect(test_parse_body(fixture_file("emails/valid_new_issue_with_quote.eml"), { trim_reply: false }))
+ expect(test_parse_body(fixture_file("emails/valid_new_issue_with_quote.eml"), {trim_reply: false}))
.to eq(
<<-BODY.strip_heredoc.chomp
The reply by email functionality should be extended to allow creating a new issue by email.
diff --git a/spec/lib/gitlab/encoding_helper_spec.rb b/spec/lib/gitlab/encoding_helper_spec.rb
index 429816efec3..bbc2547d714 100644
--- a/spec/lib/gitlab/encoding_helper_spec.rb
+++ b/spec/lib/gitlab/encoding_helper_spec.rb
@@ -1,69 +1,69 @@
-# coding: utf-8
require "spec_helper"
describe Gitlab::EncodingHelper do
let(:ext_class) { Class.new { extend Gitlab::EncodingHelper } }
let(:binary_string) { File.read(Rails.root + "spec/fixtures/dk.png") }
- describe '#encode!' do
+ describe "#encode!" do
[
["nil", nil, nil],
["empty string", "".encode("ASCII-8BIT"), "".encode("UTF-8")],
["invalid utf-8 encoded string", "my bad string\xE5".force_encoding("UTF-8"), "my bad string"],
["frozen non-ascii string", "é".force_encoding("ASCII-8BIT").freeze, "é".encode("UTF-8")],
[
- 'leaves ascii only string as is',
- 'ascii only string',
- 'ascii only string'
+ "leaves ascii only string as is",
+ "ascii only string",
+ "ascii only string",
],
[
- 'leaves valid utf8 string as is',
- 'multibyte string №∑∉',
- 'multibyte string №∑∉'
+ "leaves valid utf8 string as is",
+ "multibyte string №∑∉",
+ "multibyte string №∑∉",
],
[
- 'removes invalid bytes from ASCII-8bit encoded multibyte string. This can occur when a git diff match line truncates in the middle of a multibyte character. This occurs after the second word in this example. The test string is as short as we can get while still triggering the error condition when not looking at `detect[:confidence]`.',
- "mu ns\xC3\n Lorem ipsum dolor sit amet, consectetur adipisicing ut\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg kia elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p\n {: .normal_pn}\n \n-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\n# *Lorem ipsum\xC3\xB9l\xC3\xB9l\xC3\xA0 dolor\xC3\xB9k\xC3\xB9 sit\xC3\xA8b\xC3\xA8 N\xC3\xA8 amet b\xC3\xA0d\xC3\xAC*\n+# *consectetur\xC3\xB9l\xC3\xB9l\xC3\xA0 adipisicing\xC3\xB9k\xC3\xB9 elit\xC3\xA8b\xC3\xA8 N\xC3\xA8 sed do\xC3\xA0d\xC3\xAC*{: .italic .smcaps}\n \n \xEF\x9B\xA1 eiusmod tempor incididunt, ut\xC3\xAAn\xC3\xB9 labore et dolore. Tw\xC4\x83nj\xC3\xAC magna aliqua. Ut enim ad minim veniam\n {: .normal}\n@@ -9,5 +9,5 @@ quis nostrud\xC3\xAAt\xC3\xB9 exercitiation ullamco laboris m\xC3\xB9s\xC3\xB9k\xC3\xB9abc\xC3\xB9 nisi ".force_encoding('ASCII-8BIT'),
- "mu ns\n Lorem ipsum dolor sit amet, consectetur adipisicing ut\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg kia elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p\n {: .normal_pn}\n \n-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\n# *Lorem ipsum\xC3\xB9l\xC3\xB9l\xC3\xA0 dolor\xC3\xB9k\xC3\xB9 sit\xC3\xA8b\xC3\xA8 N\xC3\xA8 amet b\xC3\xA0d\xC3\xAC*\n+# *consectetur\xC3\xB9l\xC3\xB9l\xC3\xA0 adipisicing\xC3\xB9k\xC3\xB9 elit\xC3\xA8b\xC3\xA8 N\xC3\xA8 sed do\xC3\xA0d\xC3\xAC*{: .italic .smcaps}\n \n \xEF\x9B\xA1 eiusmod tempor incididunt, ut\xC3\xAAn\xC3\xB9 labore et dolore. Tw\xC4\x83nj\xC3\xAC magna aliqua. Ut enim ad minim veniam\n {: .normal}\n@@ -9,5 +9,5 @@ quis nostrud\xC3\xAAt\xC3\xB9 exercitiation ullamco laboris m\xC3\xB9s\xC3\xB9k\xC3\xB9abc\xC3\xB9 nisi "
+ "removes invalid bytes from ASCII-8bit encoded multibyte string. This can occur when a git diff match line truncates in the middle of a multibyte character. This occurs after the second word in this example. The test string is as short as we can get while still triggering the error condition when not looking at `detect[:confidence]`.",
+ "mu ns\xC3\n Lorem ipsum dolor sit amet, consectetur adipisicing ut\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg kia elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p\n {: .normal_pn}\n \n-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\n# *Lorem ipsum\xC3\xB9l\xC3\xB9l\xC3\xA0 dolor\xC3\xB9k\xC3\xB9 sit\xC3\xA8b\xC3\xA8 N\xC3\xA8 amet b\xC3\xA0d\xC3\xAC*\n+# *consectetur\xC3\xB9l\xC3\xB9l\xC3\xA0 adipisicing\xC3\xB9k\xC3\xB9 elit\xC3\xA8b\xC3\xA8 N\xC3\xA8 sed do\xC3\xA0d\xC3\xAC*{: .italic .smcaps}\n \n \xEF\x9B\xA1 eiusmod tempor incididunt, ut\xC3\xAAn\xC3\xB9 labore et dolore. Tw\xC4\x83nj\xC3\xAC magna aliqua. Ut enim ad minim veniam\n {: .normal}\n@@ -9,5 +9,5 @@ quis nostrud\xC3\xAAt\xC3\xB9 exercitiation ullamco laboris m\xC3\xB9s\xC3\xB9k\xC3\xB9abc\xC3\xB9 nisi ".force_encoding("ASCII-8BIT"),
+ "mu ns\n Lorem ipsum dolor sit amet, consectetur adipisicing ut\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg kia elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non p\n {: .normal_pn}\n \n-Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in\n# *Lorem ipsum\xC3\xB9l\xC3\xB9l\xC3\xA0 dolor\xC3\xB9k\xC3\xB9 sit\xC3\xA8b\xC3\xA8 N\xC3\xA8 amet b\xC3\xA0d\xC3\xAC*\n+# *consectetur\xC3\xB9l\xC3\xB9l\xC3\xA0 adipisicing\xC3\xB9k\xC3\xB9 elit\xC3\xA8b\xC3\xA8 N\xC3\xA8 sed do\xC3\xA0d\xC3\xAC*{: .italic .smcaps}\n \n \xEF\x9B\xA1 eiusmod tempor incididunt, ut\xC3\xAAn\xC3\xB9 labore et dolore. Tw\xC4\x83nj\xC3\xAC magna aliqua. Ut enim ad minim veniam\n {: .normal}\n@@ -9,5 +9,5 @@ quis nostrud\xC3\xAAt\xC3\xB9 exercitiation ullamco laboris m\xC3\xB9s\xC3\xB9k\xC3\xB9abc\xC3\xB9 nisi ",
],
[
- 'string with detected encoding that is not supported in Ruby',
+ "string with detected encoding that is not supported in Ruby",
"\xFFe,i\xFF,\xB8oi,'\xB8,\xFF,-",
- "--broken encoding: IBM420_ltr"
- ]
+ "--broken encoding: IBM420_ltr",
+ ],
].each do |description, test_string, xpect|
it description do
expect(ext_class.encode!(test_string)).to eq(xpect)
end
end
- it 'leaves binary string as is' do
+ it "leaves binary string as is" do
expect(ext_class.encode!(binary_string)).to eq(binary_string)
end
- context 'with corrupted diff' do
+ context "with corrupted diff" do
let(:corrupted_diff) do
with_empty_bare_repository do |repo|
content = File.read(Rails.root.join(
- 'spec/fixtures/encoding/Japanese.md').to_s)
- commit_a = commit(repo, 'Japanese.md', content)
- commit_b = commit(repo, 'Japanese.md',
- content.sub('[TODO: Link]', '[現在作業中です: Link]'))
+ "spec/fixtures/encoding/Japanese.md"
+ ).to_s)
+ commit_a = commit(repo, "Japanese.md", content)
+ commit_b = commit(repo, "Japanese.md",
+ content.sub("[TODO: Link]", "[現在作業中です: Link]"))
repo.diff(commit_a, commit_b).each_line.map(&:content).join
end
end
let(:cleaned_diff) do
- corrupted_diff.dup.force_encoding('UTF-8')
- .encode!('UTF-8', invalid: :replace, replace: '')
+ corrupted_diff.dup.force_encoding("UTF-8")
+ .encode!("UTF-8", invalid: :replace, replace: "")
end
let(:encoded_diff) do
described_class.encode!(corrupted_diff.dup)
end
- it 'does not corrupt data but remove invalid characters' do
+ it "does not corrupt data but remove invalid characters" do
expect(encoded_diff).to eq(cleaned_diff)
end
@@ -73,8 +73,8 @@ describe Gitlab::EncodingHelper do
index.read_tree(repo.head.target.tree) unless repo.empty?
- index.add(path: path, oid: oid, mode: 0100644)
- user = { name: 'Test', email: 'test@example.com' }
+ index.add(path: path, oid: oid, mode: 0o100644)
+ user = {name: "Test", email: "test@example.com"}
Rugged::Commit.create(
repo,
@@ -83,13 +83,13 @@ describe Gitlab::EncodingHelper do
committer: user,
message: "Update #{path}",
parents: repo.empty? ? [] : [repo.head.target].compact,
- update_ref: 'HEAD'
+ update_ref: "HEAD"
)
end
end
end
- describe '#encode_utf8' do
+ describe "#encode_utf8" do
[
["nil", nil, nil],
["empty string", "".encode("ASCII-8BIT"), "".encode("UTF-8")],
@@ -97,37 +97,37 @@ describe Gitlab::EncodingHelper do
[
"encodes valid utf8 encoded string to utf8",
"λ, λ, λ".encode("UTF-8"),
- "λ, λ, λ".encode("UTF-8")
+ "λ, λ, λ".encode("UTF-8"),
],
[
"encodes valid ASCII-8BIT encoded string to utf8",
"ascii only".encode("ASCII-8BIT"),
- "ascii only".encode("UTF-8")
+ "ascii only".encode("UTF-8"),
],
[
"encodes valid ISO-8859-1 encoded string to utf8",
"Rüby ist eine Programmiersprache. Wir verlängern den text damit ICU die Sprache erkennen kann.".encode("ISO-8859-1", "UTF-8"),
- "Rüby ist eine Programmiersprache. Wir verlängern den text damit ICU die Sprache erkennen kann.".encode("UTF-8")
+ "Rüby ist eine Programmiersprache. Wir verlängern den text damit ICU die Sprache erkennen kann.".encode("UTF-8"),
],
[
# Test case from https://gitlab.com/gitlab-org/gitlab-ce/issues/39227
"Equifax branch name",
"refs/heads/Equifax".encode("UTF-8"),
- "refs/heads/Equifax".encode("UTF-8")
- ]
+ "refs/heads/Equifax".encode("UTF-8"),
+ ],
].each do |description, test_string, xpect|
it description do
r = ext_class.encode_utf8(test_string)
expect(r).to eq(xpect)
- expect(r.encoding.name).to eq('UTF-8') if xpect
+ expect(r.encoding.name).to eq("UTF-8") if xpect
end
end
- it 'returns empty string on conversion errors' do
- expect { ext_class.encode_utf8('') }.not_to raise_error
+ it "returns empty string on conversion errors" do
+ expect { ext_class.encode_utf8("") }.not_to raise_error
end
- context 'with strings that can be forcefully encoded into utf8' do
+ context "with strings that can be forcefully encoded into utf8" do
let(:test_string) do
"refs/heads/FixSymbolsTitleDropdown".encode("ASCII-8BIT")
end
@@ -141,33 +141,33 @@ describe Gitlab::EncodingHelper do
expect(CharlockHolmes::EncodingDetector).not_to receive(:detect)
expect(subject).to eq(expected_string)
- expect(subject.encoding.name).to eq('UTF-8')
+ expect(subject.encoding.name).to eq("UTF-8")
end
end
end
- describe '#clean' do
+ describe "#clean" do
[
[
- 'leaves ascii only string as is',
- 'ascii only string',
- 'ascii only string'
+ "leaves ascii only string as is",
+ "ascii only string",
+ "ascii only string",
],
[
- 'leaves valid utf8 string as is',
- 'multibyte string №∑∉',
- 'multibyte string №∑∉'
+ "leaves valid utf8 string as is",
+ "multibyte string №∑∉",
+ "multibyte string №∑∉",
],
[
- 'removes invalid bytes from ASCII-8bit encoded multibyte string.',
- "Lorem ipsum\xC3\n dolor sit amet, xy\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg".force_encoding('ASCII-8BIT'),
- "Lorem ipsum\n dolor sit amet, xyàyùabcdùefg"
+ "removes invalid bytes from ASCII-8bit encoded multibyte string.",
+ "Lorem ipsum\xC3\n dolor sit amet, xy\xC3\xA0y\xC3\xB9abcd\xC3\xB9efg".force_encoding("ASCII-8BIT"),
+ "Lorem ipsum\n dolor sit amet, xyàyùabcdùefg",
],
[
- 'handles UTF-16BE encoded strings',
- "\xFE\xFF\x00\x41".force_encoding('ASCII-8BIT'), # An "A" prepended with UTF-16 BOM
- "\xEF\xBB\xBFA" # An "A" prepended with UTF-8 BOM
- ]
+ "handles UTF-16BE encoded strings",
+ "\xFE\xFF\x00\x41".force_encoding("ASCII-8BIT"), # An "A" prepended with UTF-16 BOM
+ "\xEF\xBB\xBFA", # An "A" prepended with UTF-8 BOM
+ ],
].each do |description, test_string, xpect|
it description do
expect(ext_class.encode!(test_string)).to eq(xpect)
@@ -175,13 +175,13 @@ describe Gitlab::EncodingHelper do
end
end
- describe 'encode_binary' do
+ describe "encode_binary" do
[
[nil, ""],
["", ""],
[" ", " "],
- %w(a1 a1),
- ["编码", "\xE7\xBC\x96\xE7\xA0\x81".b]
+ %w[a1 a1],
+ ["编码", "\xE7\xBC\x96\xE7\xA0\x81".b],
].each do |input, result|
it "encodes #{input.inspect} to #{result.inspect}" do
expect(ext_class.encode_binary(input)).to eq(result)
@@ -189,14 +189,14 @@ describe Gitlab::EncodingHelper do
end
end
- describe '#binary_stringio' do
- it 'does not mutate the original string encoding' do
- test = 'my-test'
+ describe "#binary_stringio" do
+ it "does not mutate the original string encoding" do
+ test = "my-test"
io_stream = ext_class.binary_stringio(test)
- expect(io_stream.external_encoding.name).to eq('ASCII-8BIT')
- expect(test.encoding.name).to eq('UTF-8')
+ expect(io_stream.external_encoding.name).to eq("ASCII-8BIT")
+ expect(test.encoding.name).to eq("UTF-8")
end
end
end
diff --git a/spec/lib/gitlab/etag_caching/middleware_spec.rb b/spec/lib/gitlab/etag_caching/middleware_spec.rb
index 4a54d641b4e..8a57dab2a71 100644
--- a/spec/lib/gitlab/etag_caching/middleware_spec.rb
+++ b/spec/lib/gitlab/etag_caching/middleware_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::EtagCaching::Middleware do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
let(:app_status_code) { 200 }
let(:if_none_match) { nil }
- let(:enabled_path) { '/gitlab-org/gitlab-ce/noteable/issue/1/notes' }
+ let(:enabled_path) { "/gitlab-org/gitlab-ce/noteable/issue/1/notes" }
- context 'when ETag caching is not enabled for current route' do
- let(:path) { '/gitlab-org/gitlab-ce/tree/master/noteable/issue/1/notes' }
+ context "when ETag caching is not enabled for current route" do
+ let(:path) { "/gitlab-org/gitlab-ce/tree/master/noteable/issue/1/notes" }
before do
mock_app_response
end
- it 'does not add ETag header' do
+ it "does not add ETag header" do
_, headers, _ = middleware.call(build_request(path, if_none_match))
- expect(headers['ETag']).to be_nil
+ expect(headers["ETag"]).to be_nil
end
- it 'passes status code from app' do
+ it "passes status code from app" do
status, _, _ = middleware.call(build_request(path, if_none_match))
expect(status).to eq app_status_code
end
end
- context 'when there is no ETag in store for given resource' do
+ context "when there is no ETag in store for given resource" do
let(:path) { enabled_path }
before do
@@ -35,63 +35,63 @@ describe Gitlab::EtagCaching::Middleware do
mock_value_in_store(nil)
end
- it 'generates ETag' do
+ it "generates ETag" do
expect_any_instance_of(Gitlab::EtagCaching::Store)
- .to receive(:touch).and_return('123')
+ .to receive(:touch).and_return("123")
middleware.call(build_request(path, if_none_match))
end
- context 'when If-None-Match header was specified' do
+ context "when If-None-Match header was specified" do
let(:if_none_match) { 'W/"abc"' }
it 'tracks "etag_caching_key_not_found" event' do
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_middleware_used, endpoint: 'issue_notes')
+ .with(:etag_caching_middleware_used, endpoint: "issue_notes")
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_key_not_found, endpoint: 'issue_notes')
+ .with(:etag_caching_key_not_found, endpoint: "issue_notes")
middleware.call(build_request(path, if_none_match))
end
end
end
- context 'when there is ETag in store for given resource' do
+ context "when there is ETag in store for given resource" do
let(:path) { enabled_path }
before do
mock_app_response
- mock_value_in_store('123')
+ mock_value_in_store("123")
end
- it 'returns this value as header' do
+ it "returns this value as header" do
_, headers, _ = middleware.call(build_request(path, if_none_match))
- expect(headers['ETag']).to eq 'W/"123"'
+ expect(headers["ETag"]).to eq 'W/"123"'
end
end
- context 'when If-None-Match header matches ETag in store' do
+ context "when If-None-Match header matches ETag in store" do
let(:path) { enabled_path }
let(:if_none_match) { 'W/"123"' }
before do
- mock_value_in_store('123')
+ mock_value_in_store("123")
end
- it 'does not call app' do
+ it "does not call app" do
expect(app).not_to receive(:call)
middleware.call(build_request(path, if_none_match))
end
- it 'returns status code 304' do
+ it "returns status code 304" do
status, _, _ = middleware.call(build_request(path, if_none_match))
expect(status).to eq 304
end
- it 'returns empty body' do
+ it "returns empty body" do
_, _, body = middleware.call(build_request(path, if_none_match))
expect(body).to be_empty
@@ -99,20 +99,20 @@ describe Gitlab::EtagCaching::Middleware do
it 'tracks "etag_caching_cache_hit" event' do
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_middleware_used, endpoint: 'issue_notes')
+ .with(:etag_caching_middleware_used, endpoint: "issue_notes")
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_cache_hit, endpoint: 'issue_notes')
+ .with(:etag_caching_cache_hit, endpoint: "issue_notes")
middleware.call(build_request(path, if_none_match))
end
- context 'when polling is disabled' do
+ context "when polling is disabled" do
before do
allow(Gitlab::PollingInterval).to receive(:polling_enabled?)
.and_return(false)
end
- it 'returns status code 429' do
+ it "returns status code 429" do
status, _, _ = middleware.call(build_request(path, if_none_match))
expect(status).to eq 429
@@ -120,16 +120,16 @@ describe Gitlab::EtagCaching::Middleware do
end
end
- context 'when If-None-Match header does not match ETag in store' do
+ context "when If-None-Match header does not match ETag in store" do
let(:path) { enabled_path }
let(:if_none_match) { 'W/"abc"' }
before do
- mock_value_in_store('123')
+ mock_value_in_store("123")
end
- it 'calls app' do
- expect(app).to receive(:call).and_return([app_status_code, {}, ['body']])
+ it "calls app" do
+ expect(app).to receive(:call).and_return([app_status_code, {}, ["body"]])
middleware.call(build_request(path, if_none_match))
end
@@ -138,41 +138,41 @@ describe Gitlab::EtagCaching::Middleware do
mock_app_response
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_middleware_used, endpoint: 'issue_notes')
+ .with(:etag_caching_middleware_used, endpoint: "issue_notes")
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_resource_changed, endpoint: 'issue_notes')
+ .with(:etag_caching_resource_changed, endpoint: "issue_notes")
middleware.call(build_request(path, if_none_match))
end
end
- context 'when If-None-Match header is not specified' do
+ context "when If-None-Match header is not specified" do
let(:path) { enabled_path }
before do
- mock_value_in_store('123')
+ mock_value_in_store("123")
mock_app_response
end
it 'tracks "etag_caching_header_missing" event' do
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_middleware_used, endpoint: 'issue_notes')
+ .with(:etag_caching_middleware_used, endpoint: "issue_notes")
expect(Gitlab::Metrics).to receive(:add_event)
- .with(:etag_caching_header_missing, endpoint: 'issue_notes')
+ .with(:etag_caching_header_missing, endpoint: "issue_notes")
middleware.call(build_request(path, if_none_match))
end
end
- context 'when GitLab instance is using a relative URL' do
+ context "when GitLab instance is using a relative URL" do
before do
mock_app_response
end
- it 'uses full path as cache key' do
+ it "uses full path as cache key" do
env = {
- 'PATH_INFO' => enabled_path,
- 'SCRIPT_NAME' => '/relative-gitlab'
+ "PATH_INFO" => enabled_path,
+ "SCRIPT_NAME" => "/relative-gitlab",
}
expect_any_instance_of(Gitlab::EtagCaching::Store)
@@ -184,7 +184,7 @@ describe Gitlab::EtagCaching::Middleware do
end
def mock_app_response
- allow(app).to receive(:call).and_return([app_status_code, {}, ['body']])
+ allow(app).to receive(:call).and_return([app_status_code, {}, ["body"]])
end
def mock_value_in_store(value)
@@ -193,6 +193,6 @@ describe Gitlab::EtagCaching::Middleware do
end
def build_request(path, if_none_match)
- { 'PATH_INFO' => path, 'HTTP_IF_NONE_MATCH' => if_none_match }
+ {"PATH_INFO" => path, "HTTP_IF_NONE_MATCH" => if_none_match}
end
end
diff --git a/spec/lib/gitlab/etag_caching/router_spec.rb b/spec/lib/gitlab/etag_caching/router_spec.rb
index f69cb502ca6..69d7bcbb454 100644
--- a/spec/lib/gitlab/etag_caching/router_spec.rb
+++ b/spec/lib/gitlab/etag_caching/router_spec.rb
@@ -1,92 +1,92 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::EtagCaching::Router do
- it 'matches issue notes endpoint' do
+ it "matches issue notes endpoint" do
result = described_class.match(
- '/my-group/and-subgroup/here-comes-the-project/noteable/issue/1/notes'
+ "/my-group/and-subgroup/here-comes-the-project/noteable/issue/1/notes"
)
expect(result).to be_present
- expect(result.name).to eq 'issue_notes'
+ expect(result.name).to eq "issue_notes"
end
- it 'matches issue title endpoint' do
+ it "matches issue title endpoint" do
result = described_class.match(
- '/my-group/my-project/issues/123/realtime_changes'
+ "/my-group/my-project/issues/123/realtime_changes"
)
expect(result).to be_present
- expect(result.name).to eq 'issue_title'
+ expect(result.name).to eq "issue_title"
end
- it 'matches project pipelines endpoint' do
+ it "matches project pipelines endpoint" do
result = described_class.match(
- '/my-group/my-project/pipelines.json'
+ "/my-group/my-project/pipelines.json"
)
expect(result).to be_present
- expect(result.name).to eq 'project_pipelines'
+ expect(result.name).to eq "project_pipelines"
end
- it 'matches commit pipelines endpoint' do
+ it "matches commit pipelines endpoint" do
result = described_class.match(
- '/my-group/my-project/commit/aa8260d253a53f73f6c26c734c72fdd600f6e6d4/pipelines.json'
+ "/my-group/my-project/commit/aa8260d253a53f73f6c26c734c72fdd600f6e6d4/pipelines.json"
)
expect(result).to be_present
- expect(result.name).to eq 'commit_pipelines'
+ expect(result.name).to eq "commit_pipelines"
end
- it 'matches new merge request pipelines endpoint' do
+ it "matches new merge request pipelines endpoint" do
result = described_class.match(
- '/my-group/my-project/merge_requests/new.json'
+ "/my-group/my-project/merge_requests/new.json"
)
expect(result).to be_present
- expect(result.name).to eq 'new_merge_request_pipelines'
+ expect(result.name).to eq "new_merge_request_pipelines"
end
- it 'matches merge request pipelines endpoint' do
+ it "matches merge request pipelines endpoint" do
result = described_class.match(
- '/my-group/my-project/merge_requests/234/pipelines.json'
+ "/my-group/my-project/merge_requests/234/pipelines.json"
)
expect(result).to be_present
- expect(result.name).to eq 'merge_request_pipelines'
+ expect(result.name).to eq "merge_request_pipelines"
end
- it 'matches build endpoint' do
+ it "matches build endpoint" do
result = described_class.match(
- '/my-group/my-project/builds/234.json'
+ "/my-group/my-project/builds/234.json"
)
expect(result).to be_present
- expect(result.name).to eq 'project_build'
+ expect(result.name).to eq "project_build"
end
- it 'does not match blob with confusing name' do
+ it "does not match blob with confusing name" do
result = described_class.match(
- '/my-group/my-project/blob/master/pipelines.json'
+ "/my-group/my-project/blob/master/pipelines.json"
)
expect(result).to be_blank
end
- it 'matches the environments path' do
+ it "matches the environments path" do
result = described_class.match(
- '/my-group/my-project/environments.json'
+ "/my-group/my-project/environments.json"
)
expect(result).to be_present
- expect(result.name).to eq 'environments'
+ expect(result.name).to eq "environments"
end
- it 'matches pipeline#show endpoint' do
+ it "matches pipeline#show endpoint" do
result = described_class.match(
- '/my-group/my-project/pipelines/2.json'
+ "/my-group/my-project/pipelines/2.json"
)
expect(result).to be_present
- expect(result.name).to eq 'project_pipeline'
+ expect(result.name).to eq "project_pipeline"
end
end
diff --git a/spec/lib/gitlab/exclusive_lease_helpers_spec.rb b/spec/lib/gitlab/exclusive_lease_helpers_spec.rb
index 5107e1efbbd..8cb2fcf354c 100644
--- a/spec/lib/gitlab/exclusive_lease_helpers_spec.rb
+++ b/spec/lib/gitlab/exclusive_lease_helpers_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ExclusiveLeaseHelpers, :clean_gitlab_redis_shared_state do
include ::ExclusiveLeaseHelpers
@@ -6,77 +6,77 @@ describe Gitlab::ExclusiveLeaseHelpers, :clean_gitlab_redis_shared_state do
let(:class_instance) { (Class.new { include ::Gitlab::ExclusiveLeaseHelpers }).new }
let(:unique_key) { SecureRandom.hex(10) }
- describe '#in_lock' do
+ describe "#in_lock" do
subject { class_instance.in_lock(unique_key, **options) { } }
let(:options) { {} }
- context 'when unique key is not set' do
+ context "when unique key is not set" do
let(:unique_key) { }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error ArgumentError
end
end
- context 'when the lease is not obtained yet' do
+ context "when the lease is not obtained yet" do
before do
- stub_exclusive_lease(unique_key, 'uuid')
+ stub_exclusive_lease(unique_key, "uuid")
end
- it 'calls the given block' do
+ it "calls the given block" do
expect { |b| class_instance.in_lock(unique_key, &b) }.to yield_control.once
end
- it 'calls the given block continuously' do
+ it "calls the given block continuously" do
expect { |b| class_instance.in_lock(unique_key, &b) }.to yield_control.once
expect { |b| class_instance.in_lock(unique_key, &b) }.to yield_control.once
expect { |b| class_instance.in_lock(unique_key, &b) }.to yield_control.once
end
- it 'cancels the exclusive lease after the block' do
- expect_to_cancel_exclusive_lease(unique_key, 'uuid')
+ it "cancels the exclusive lease after the block" do
+ expect_to_cancel_exclusive_lease(unique_key, "uuid")
subject
end
end
- context 'when the lease is obtained already' do
+ context "when the lease is obtained already" do
let!(:lease) { stub_exclusive_lease_taken(unique_key) }
- it 'retries to obtain a lease and raises an error' do
+ it "retries to obtain a lease and raises an error" do
expect(lease).to receive(:try_obtain).exactly(11).times
- expect { subject }.to raise_error('Failed to obtain a lock')
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
- context 'when ttl is specified' do
- let(:options) { { ttl: 10.minutes } }
+ context "when ttl is specified" do
+ let(:options) { {ttl: 10.minutes} }
- it 'receives the specified argument' do
- expect(Gitlab::ExclusiveLease).to receive(:new).with(unique_key, { timeout: 10.minutes } )
+ it "receives the specified argument" do
+ expect(Gitlab::ExclusiveLease).to receive(:new).with(unique_key, {timeout: 10.minutes})
- expect { subject }.to raise_error('Failed to obtain a lock')
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
end
- context 'when retry count is specified' do
- let(:options) { { retries: 3 } }
+ context "when retry count is specified" do
+ let(:options) { {retries: 3} }
- it 'retries for the specified times' do
+ it "retries for the specified times" do
expect(lease).to receive(:try_obtain).exactly(4).times
- expect { subject }.to raise_error('Failed to obtain a lock')
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
end
- context 'when sleep second is specified' do
- let(:options) { { retries: 0, sleep_sec: 0.05.seconds } }
+ context "when sleep second is specified" do
+ let(:options) { {retries: 0, sleep_sec: 0.05.seconds} }
- it 'receives the specified argument' do
+ it "receives the specified argument" do
expect(class_instance).to receive(:sleep).with(0.05.seconds).once
- expect { subject }.to raise_error('Failed to obtain a lock')
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
end
end
diff --git a/spec/lib/gitlab/exclusive_lease_spec.rb b/spec/lib/gitlab/exclusive_lease_spec.rb
index aed7d8d81ce..c71cb85e7b3 100644
--- a/spec/lib/gitlab/exclusive_lease_spec.rb
+++ b/spec/lib/gitlab/exclusive_lease_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
let(:unique_key) { SecureRandom.hex(10) }
- describe '#try_obtain' do
- it 'cannot obtain twice before the lease has expired' do
+ describe "#try_obtain" do
+ it "cannot obtain twice before the lease has expired" do
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.try_obtain).to be_present
expect(lease.try_obtain).to eq(false)
end
- it 'can obtain after the lease has expired' do
+ it "can obtain after the lease has expired" do
timeout = 1
lease = described_class.new(unique_key, timeout: timeout)
lease.try_obtain # start the lease
@@ -19,48 +19,48 @@ describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
end
end
- describe '#renew' do
- it 'returns true when we have the existing lease' do
+ describe "#renew" do
+ it "returns true when we have the existing lease" do
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.try_obtain).to be_present
expect(lease.renew).to be_truthy
end
- it 'returns false when we dont have a lease' do
+ it "returns false when we dont have a lease" do
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.renew).to be_falsey
end
end
- describe '#exists?' do
- it 'returns true for an existing lease' do
+ describe "#exists?" do
+ it "returns true for an existing lease" do
lease = described_class.new(unique_key, timeout: 3600)
lease.try_obtain
expect(lease.exists?).to eq(true)
end
- it 'returns false for a lease that does not exist' do
+ it "returns false for a lease that does not exist" do
lease = described_class.new(unique_key, timeout: 3600)
expect(lease.exists?).to eq(false)
end
end
- describe '.get_uuid' do
- it 'gets the uuid if lease with the key associated exists' do
+ describe ".get_uuid" do
+ it "gets the uuid if lease with the key associated exists" do
uuid = described_class.new(unique_key, timeout: 3600).try_obtain
expect(described_class.get_uuid(unique_key)).to eq(uuid)
end
- it 'returns false if the lease does not exist' do
+ it "returns false if the lease does not exist" do
expect(described_class.get_uuid(unique_key)).to be false
end
end
- describe '.cancel' do
- it 'can cancel a lease' do
+ describe ".cancel" do
+ it "can cancel a lease" do
uuid = new_lease(unique_key)
expect(uuid).to be_present
expect(new_lease(unique_key)).to eq(false)
@@ -74,23 +74,23 @@ describe Gitlab::ExclusiveLease, :clean_gitlab_redis_shared_state do
end
end
- describe '#ttl' do
- it 'returns the TTL of the Redis key' do
- lease = described_class.new('kittens', timeout: 100)
+ describe "#ttl" do
+ it "returns the TTL of the Redis key" do
+ lease = described_class.new("kittens", timeout: 100)
lease.try_obtain
expect(lease.ttl <= 100).to eq(true)
end
- it 'returns nil when the lease does not exist' do
- lease = described_class.new('kittens', timeout: 10)
+ it "returns nil when the lease does not exist" do
+ lease = described_class.new("kittens", timeout: 10)
expect(lease.ttl).to be_nil
end
end
- describe '.reset_all!' do
- it 'removes all existing lease keys from redis' do
+ describe ".reset_all!" do
+ it "removes all existing lease keys from redis" do
uuid = described_class.new(unique_key, timeout: 3600).try_obtain
expect(described_class.get_uuid(unique_key)).to eq(uuid)
diff --git a/spec/lib/gitlab/fake_application_settings_spec.rb b/spec/lib/gitlab/fake_application_settings_spec.rb
index af12e13d36d..d454f3c966e 100644
--- a/spec/lib/gitlab/fake_application_settings_spec.rb
+++ b/spec/lib/gitlab/fake_application_settings_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::FakeApplicationSettings do
- let(:defaults) { { password_authentication_enabled_for_web: false, foobar: 'asdf', signup_enabled: true, 'test?' => 123 } }
+ let(:defaults) { {:password_authentication_enabled_for_web => false, :foobar => "asdf", :signup_enabled => true, "test?" => 123} }
subject { described_class.new(defaults) }
- it 'wraps OpenStruct variables properly' do
+ it "wraps OpenStruct variables properly" do
expect(subject.password_authentication_enabled_for_web).to be_falsey
expect(subject.signup_enabled).to be_truthy
- expect(subject.foobar).to eq('asdf')
+ expect(subject.foobar).to eq("asdf")
end
- it 'defines predicate methods' do
+ it "defines predicate methods" do
expect(subject.password_authentication_enabled_for_web?).to be_falsey
expect(subject.signup_enabled?).to be_truthy
end
- it 'predicate method changes when value is updated' do
+ it "predicate method changes when value is updated" do
subject.password_authentication_enabled_for_web = true
expect(subject.password_authentication_enabled_for_web?).to be_truthy
end
- it 'does not define a predicate method' do
+ it "does not define a predicate method" do
expect(subject.foobar?).to be_nil
end
- it 'does not override an existing predicate method' do
+ it "does not override an existing predicate method" do
expect(subject.test?).to eq(123)
end
end
diff --git a/spec/lib/gitlab/favicon_spec.rb b/spec/lib/gitlab/favicon_spec.rb
index 49a423191bb..67c27efea48 100644
--- a/spec/lib/gitlab/favicon_spec.rb
+++ b/spec/lib/gitlab/favicon_spec.rb
@@ -1,56 +1,56 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe Gitlab::Favicon, :request_store do
- describe '.main' do
- it 'defaults to favicon.png' do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
- expect(described_class.main).to match_asset_path '/assets/favicon.png'
+ describe ".main" do
+ it "defaults to favicon.png" do
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
+ expect(described_class.main).to match_asset_path "/assets/favicon.png"
end
- it 'has blue favicon for development' do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('development'))
- expect(described_class.main).to match_asset_path '/assets/favicon-blue.png'
+ it "has blue favicon for development" do
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("development"))
+ expect(described_class.main).to match_asset_path "/assets/favicon-blue.png"
end
- it 'has yellow favicon for canary' do
- stub_env('CANARY', 'true')
- expect(described_class.main).to match_asset_path 'favicon-yellow.png'
+ it "has yellow favicon for canary" do
+ stub_env("CANARY", "true")
+ expect(described_class.main).to match_asset_path "favicon-yellow.png"
end
- it 'uses the custom favicon if a favicon appearance is present' do
- create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
+ it "uses the custom favicon if a favicon appearance is present" do
+ create :appearance, favicon: fixture_file_upload("spec/fixtures/dk.png")
expect(described_class.main).to match %r{/uploads/-/system/appearance/favicon/\d+/dk.png}
end
- context 'asset host' do
+ context "asset host" do
before do
- allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new('production'))
+ allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new("production"))
end
- it 'returns a relative url when the asset host is not configured' do
+ it "returns a relative url when the asset host is not configured" do
expect(described_class.main).to match %r{^/assets/favicon-(?:\h+).png$}
end
- it 'returns a full url when the asset host is configured' do
- allow(ActionController::Base).to receive(:asset_host).and_return('http://assets.local')
+ it "returns a full url when the asset host is configured" do
+ allow(ActionController::Base).to receive(:asset_host).and_return("http://assets.local")
expect(described_class.main).to match %r{^http://localhost/assets/favicon-(?:\h+).png$}
end
end
end
- describe '.status_overlay' do
- subject { described_class.status_overlay('favicon_status_created') }
+ describe ".status_overlay" do
+ subject { described_class.status_overlay("favicon_status_created") }
- it 'returns the overlay for the status' do
- expect(subject).to match_asset_path '/assets/ci_favicons/favicon_status_created.png'
+ it "returns the overlay for the status" do
+ expect(subject).to match_asset_path "/assets/ci_favicons/favicon_status_created.png"
end
end
- describe '.available_status_names' do
+ describe ".available_status_names" do
subject { described_class.available_status_names }
- it 'returns the available status names' do
- expect(subject).to eq %w(
+ it "returns the available status names" do
+ expect(subject).to eq %w[
favicon_status_canceled
favicon_status_created
favicon_status_failed
@@ -62,7 +62,7 @@ RSpec.describe Gitlab::Favicon, :request_store do
favicon_status_skipped
favicon_status_success
favicon_status_warning
- )
+ ]
end
end
end
diff --git a/spec/lib/gitlab/file_detector_spec.rb b/spec/lib/gitlab/file_detector_spec.rb
index 4ba9094b24e..16c50a0bae8 100644
--- a/spec/lib/gitlab/file_detector_spec.rb
+++ b/spec/lib/gitlab/file_detector_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::FileDetector do
- describe '.types_in_paths' do
- it 'returns the file types for the given paths' do
- expect(described_class.types_in_paths(%w(README.md CHANGELOG VERSION VERSION)))
- .to eq(%i{readme changelog version})
+ describe ".types_in_paths" do
+ it "returns the file types for the given paths" do
+ expect(described_class.types_in_paths(%w[README.md CHANGELOG VERSION VERSION]))
+ .to eq(%i[readme changelog version])
end
- it 'does not include unrecognized file paths' do
- expect(described_class.types_in_paths(%w(README.md foo.txt)))
- .to eq(%i{readme})
+ it "does not include unrecognized file paths" do
+ expect(described_class.types_in_paths(%w[README.md foo.txt]))
+ .to eq(%i[readme])
end
end
- describe '.type_of' do
- it 'returns the type of a README file' do
+ describe ".type_of" do
+ it "returns the type of a README file" do
filenames = Gitlab::MarkupHelper::PLAIN_FILENAMES + Gitlab::MarkupHelper::PLAIN_FILENAMES.map(&:upcase)
extensions = Gitlab::MarkupHelper::EXTENSIONS + Gitlab::MarkupHelper::EXTENSIONS.map(&:upcase)
@@ -27,58 +27,58 @@ describe Gitlab::FileDetector do
end
end
- it 'returns nil for a README.rb file' do
- expect(described_class.type_of('README.rb')).to be_nil
+ it "returns nil for a README.rb file" do
+ expect(described_class.type_of("README.rb")).to be_nil
end
- it 'returns nil for a README file in a directory' do
- expect(described_class.type_of('foo/README.md')).to be_nil
+ it "returns nil for a README file in a directory" do
+ expect(described_class.type_of("foo/README.md")).to be_nil
end
- it 'returns the type of a changelog file' do
- %w(CHANGELOG HISTORY CHANGES NEWS).each do |file|
+ it "returns the type of a changelog file" do
+ %w[CHANGELOG HISTORY CHANGES NEWS].each do |file|
expect(described_class.type_of(file)).to eq(:changelog)
end
end
- it 'returns the type of a license file' do
- %w(LICENSE LICENCE COPYING UNLICENSE UNLICENCE).each do |file|
+ it "returns the type of a license file" do
+ %w[LICENSE LICENCE COPYING UNLICENSE UNLICENCE].each do |file|
expect(described_class.type_of(file)).to eq(:license)
end
end
- it 'returns nil for an UNCOPYING file' do
- expect(described_class.type_of('UNCOPYING')).to be_nil
+ it "returns nil for an UNCOPYING file" do
+ expect(described_class.type_of("UNCOPYING")).to be_nil
end
- it 'returns the type of a version file' do
- expect(described_class.type_of('VERSION')).to eq(:version)
+ it "returns the type of a version file" do
+ expect(described_class.type_of("VERSION")).to eq(:version)
end
- it 'returns the type of a .gitignore file' do
- expect(described_class.type_of('.gitignore')).to eq(:gitignore)
+ it "returns the type of a .gitignore file" do
+ expect(described_class.type_of(".gitignore")).to eq(:gitignore)
end
- it 'returns the type of a GitLab CI config file' do
- expect(described_class.type_of('.gitlab-ci.yml')).to eq(:gitlab_ci)
+ it "returns the type of a GitLab CI config file" do
+ expect(described_class.type_of(".gitlab-ci.yml")).to eq(:gitlab_ci)
end
- it 'returns the type of an avatar' do
- %w(logo.gif logo.png logo.jpg).each do |file|
+ it "returns the type of an avatar" do
+ %w[logo.gif logo.png logo.jpg].each do |file|
expect(described_class.type_of(file)).to eq(:avatar)
end
end
- it 'returns the type of an issue template' do
- expect(described_class.type_of('.gitlab/issue_templates/foo.md')).to eq(:issue_template)
+ it "returns the type of an issue template" do
+ expect(described_class.type_of(".gitlab/issue_templates/foo.md")).to eq(:issue_template)
end
- it 'returns the type of a merge request template' do
- expect(described_class.type_of('.gitlab/merge_request_templates/foo.md')).to eq(:merge_request_template)
+ it "returns the type of a merge request template" do
+ expect(described_class.type_of(".gitlab/merge_request_templates/foo.md")).to eq(:merge_request_template)
end
- it 'returns nil for an unknown file' do
- expect(described_class.type_of('foo.txt')).to be_nil
+ it "returns nil for an unknown file" do
+ expect(described_class.type_of("foo.txt")).to be_nil
end
end
end
diff --git a/spec/lib/gitlab/file_finder_spec.rb b/spec/lib/gitlab/file_finder_spec.rb
index b49c5817131..8941398cd65 100644
--- a/spec/lib/gitlab/file_finder_spec.rb
+++ b/spec/lib/gitlab/file_finder_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::FileFinder do
- describe '#find' do
+ describe "#find" do
let(:project) { create(:project, :public, :repository) }
subject { described_class.new(project, project.default_branch) }
- it_behaves_like 'file finder' do
- let(:expected_file_by_name) { 'files/images/wm.svg' }
- let(:expected_file_by_content) { 'CHANGELOG' }
+ it_behaves_like "file finder" do
+ let(:expected_file_by_name) { "files/images/wm.svg" }
+ let(:expected_file_by_content) { "CHANGELOG" }
end
- it 'filters by name' do
- results = subject.find('files filename:wm.svg')
+ it "filters by name" do
+ results = subject.find("files filename:wm.svg")
expect(results.count).to eq(1)
end
- it 'filters by path' do
- results = subject.find('white path:images')
+ it "filters by path" do
+ results = subject.find("white path:images")
expect(results.count).to eq(1)
end
- it 'filters by extension' do
- results = subject.find('files extension:svg')
+ it "filters by extension" do
+ results = subject.find("files extension:svg")
expect(results.count).to eq(1)
end
diff --git a/spec/lib/gitlab/file_markdown_link_builder_spec.rb b/spec/lib/gitlab/file_markdown_link_builder_spec.rb
index feb2776c5d0..7be6ab6b7b8 100644
--- a/spec/lib/gitlab/file_markdown_link_builder_spec.rb
+++ b/spec/lib/gitlab/file_markdown_link_builder_spec.rb
@@ -1,78 +1,79 @@
# frozen_string_literal: true
-require 'rails_helper'
+
+require "rails_helper"
describe Gitlab::FileMarkdownLinkBuilder do
let(:custom_class) do
- Class.new do
+ Class.new {
include Gitlab::FileMarkdownLinkBuilder
- end.new
+ }.new
end
before do
allow(custom_class).to receive(:filename).and_return(filename)
end
- describe 'markdown_link' do
+ describe "markdown_link" do
let(:url) { "/uploads/#{filename}"}
before do
allow(custom_class).to receive(:secure_url).and_return(url)
end
- context 'when file name has the character ]' do
- let(:filename) { 'd]k.png' }
+ context "when file name has the character ]" do
+ let(:filename) { "d]k.png" }
- it 'escapes the character' do
+ it "escapes the character" do
expect(custom_class.markdown_link).to eq '![d\\]k](/uploads/d]k.png)'
end
end
- context 'when file is an image or video' do
- let(:filename) { 'dk.png' }
+ context "when file is an image or video" do
+ let(:filename) { "dk.png" }
- it 'returns preview markdown link' do
- expect(custom_class.markdown_link).to eq '![dk](/uploads/dk.png)'
+ it "returns preview markdown link" do
+ expect(custom_class.markdown_link).to eq "![dk](/uploads/dk.png)"
end
end
- context 'when file is not an image or video' do
- let(:filename) { 'dk.zip' }
+ context "when file is not an image or video" do
+ let(:filename) { "dk.zip" }
- it 'returns markdown link' do
- expect(custom_class.markdown_link).to eq '[dk.zip](/uploads/dk.zip)'
+ it "returns markdown link" do
+ expect(custom_class.markdown_link).to eq "[dk.zip](/uploads/dk.zip)"
end
end
- context 'when file name is blank' do
+ context "when file name is blank" do
let(:filename) { nil }
- it 'returns nil' do
+ it "returns nil" do
expect(custom_class.markdown_link).to eq nil
end
end
end
- describe 'mardown_name' do
- context 'when file is an image or video' do
- let(:filename) { 'dk.png' }
+ describe "mardown_name" do
+ context "when file is an image or video" do
+ let(:filename) { "dk.png" }
- it 'retrieves the name without the extension' do
- expect(custom_class.markdown_name).to eq 'dk'
+ it "retrieves the name without the extension" do
+ expect(custom_class.markdown_name).to eq "dk"
end
end
- context 'when file is not an image or video' do
- let(:filename) { 'dk.zip' }
+ context "when file is not an image or video" do
+ let(:filename) { "dk.zip" }
- it 'retrieves the name with the extesion' do
- expect(custom_class.markdown_name).to eq 'dk.zip'
+ it "retrieves the name with the extesion" do
+ expect(custom_class.markdown_name).to eq "dk.zip"
end
end
- context 'when file name is blank' do
+ context "when file name is blank" do
let(:filename) { nil }
- it 'returns nil' do
+ it "returns nil" do
expect(custom_class.markdown_name).to eq nil
end
end
diff --git a/spec/lib/gitlab/file_type_detection_spec.rb b/spec/lib/gitlab/file_type_detection_spec.rb
index 5e9b8988cc8..6a0b06c2aee 100644
--- a/spec/lib/gitlab/file_type_detection_spec.rb
+++ b/spec/lib/gitlab/file_type_detection_spec.rb
@@ -1,43 +1,44 @@
# frozen_string_literal: true
-require 'rails_helper'
+
+require "rails_helper"
describe Gitlab::FileTypeDetection do
def upload_fixture(filename)
- fixture_file_upload(File.join('spec', 'fixtures', filename))
+ fixture_file_upload(File.join("spec", "fixtures", filename))
end
- describe '#image_or_video?' do
- context 'when class is an uploader' do
+ describe "#image_or_video?" do
+ context "when class is an uploader" do
let(:uploader) do
- example_uploader = Class.new(CarrierWave::Uploader::Base) do
+ example_uploader = Class.new(CarrierWave::Uploader::Base) {
include Gitlab::FileTypeDetection
storage :file
- end
+ }
example_uploader.new
end
- it 'returns true for an image file' do
- uploader.store!(upload_fixture('dk.png'))
+ it "returns true for an image file" do
+ uploader.store!(upload_fixture("dk.png"))
expect(uploader).to be_image_or_video
end
- it 'returns true for a video file' do
- uploader.store!(upload_fixture('video_sample.mp4'))
+ it "returns true for a video file" do
+ uploader.store!(upload_fixture("video_sample.mp4"))
expect(uploader).to be_image_or_video
end
- it 'returns false for other extensions' do
- uploader.store!(upload_fixture('doc_sample.txt'))
+ it "returns false for other extensions" do
+ uploader.store!(upload_fixture("doc_sample.txt"))
expect(uploader).not_to be_image_or_video
end
- it 'returns false if filename is blank' do
- uploader.store!(upload_fixture('dk.png'))
+ it "returns false if filename is blank" do
+ uploader.store!(upload_fixture("dk.png"))
allow(uploader).to receive(:filename).and_return(nil)
@@ -45,34 +46,34 @@ describe Gitlab::FileTypeDetection do
end
end
- context 'when class is a regular class' do
+ context "when class is a regular class" do
let(:custom_class) do
- custom_class = Class.new do
+ custom_class = Class.new {
include Gitlab::FileTypeDetection
- end
+ }
custom_class.new
end
- it 'returns true for an image file' do
- allow(custom_class).to receive(:filename).and_return('dk.png')
+ it "returns true for an image file" do
+ allow(custom_class).to receive(:filename).and_return("dk.png")
expect(custom_class).to be_image_or_video
end
- it 'returns true for a video file' do
- allow(custom_class).to receive(:filename).and_return('video_sample.mp4')
+ it "returns true for a video file" do
+ allow(custom_class).to receive(:filename).and_return("video_sample.mp4")
expect(custom_class).to be_image_or_video
end
- it 'returns false for other extensions' do
- allow(custom_class).to receive(:filename).and_return('doc_sample.txt')
+ it "returns false for other extensions" do
+ allow(custom_class).to receive(:filename).and_return("doc_sample.txt")
expect(custom_class).not_to be_image_or_video
end
- it 'returns false if filename is blank' do
+ it "returns false if filename is blank" do
allow(custom_class).to receive(:filename).and_return(nil)
expect(custom_class).not_to be_image_or_video
diff --git a/spec/lib/gitlab/fogbugz_import/client_spec.rb b/spec/lib/gitlab/fogbugz_import/client_spec.rb
index dcd1a2d9813..7f1418752a8 100644
--- a/spec/lib/gitlab/fogbugz_import/client_spec.rb
+++ b/spec/lib/gitlab/fogbugz_import/client_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::FogbugzImport::Client do
- let(:client) { described_class.new(uri: '', token: '') }
- let(:one_user) { { 'people' => { 'person' => { "ixPerson" => "2", "sFullName" => "James" } } } }
- let(:two_users) { { 'people' => { 'person' => [one_user, { "ixPerson" => "3" }] } } }
+ let(:client) { described_class.new(uri: "", token: "") }
+ let(:one_user) { {"people" => {"person" => {"ixPerson" => "2", "sFullName" => "James"}}} }
+ let(:two_users) { {"people" => {"person" => [one_user, {"ixPerson" => "3"}]}} }
- it 'retrieves user_map with one user' do
+ it "retrieves user_map with one user" do
stub_api(one_user)
expect(client.user_map.count).to eq(1)
end
- it 'retrieves user_map with two users' do
+ it "retrieves user_map with two users" do
stub_api(two_users)
expect(client.user_map.count).to eq(2)
diff --git a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb
index 4d2f08f95fc..7bc287134c8 100644
--- a/spec/lib/gitlab/gfm/reference_rewriter_spec.rb
+++ b/spec/lib/gitlab/gfm/reference_rewriter_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Gfm::ReferenceRewriter do
let(:group) { create(:group) }
- let(:old_project) { create(:project, name: 'old-project', group: group) }
- let(:new_project) { create(:project, name: 'new-project', group: group) }
+ let(:old_project) { create(:project, name: "old-project", group: group) }
+ let(:new_project) { create(:project, name: "new-project", group: group) }
let(:user) { create(:user) }
let(:old_project_ref) { old_project.to_reference(new_project) }
- let(:text) { 'some text' }
+ let(:text) { "some text" }
before do
old_project.add_reporter(user)
end
- describe '#rewrite' do
+ describe "#rewrite" do
subject do
described_class.new(text, old_project, user).rewrite(new_project)
end
- context 'multiple issues and merge requests referenced' do
+ context "multiple issues and merge requests referenced" do
let!(:issue_first) { create(:issue, project: old_project) }
let!(:issue_second) { create(:issue, project: old_project) }
let!(:merge_request) { create(:merge_request, source_project: old_project) }
- context 'plain text description' do
- let(:text) { 'Description that references #1, #2 and !1' }
+ context "plain text description" do
+ let(:text) { "Description that references #1, #2 and !1" }
it { is_expected.to include issue_first.to_reference(new_project) }
it { is_expected.to include issue_second.to_reference(new_project) }
it { is_expected.to include merge_request.to_reference(new_project) }
end
- context 'description with ignored elements' do
+ context "description with ignored elements" do
let(:text) do
"Hi. This references #1, but not `#2`\n" +
- '<pre>and not !1</pre>'
+ "<pre>and not !1</pre>"
end
it { is_expected.to include issue_first.to_reference(new_project) }
@@ -42,79 +42,79 @@ describe Gitlab::Gfm::ReferenceRewriter do
it { is_expected.not_to include merge_request.to_reference(new_project) }
end
- context 'rewrite ambigous references' do
- context 'url' do
- let(:url) { 'http://gitlab.com/#1' }
+ context "rewrite ambigous references" do
+ context "url" do
+ let(:url) { "http://gitlab.com/#1" }
let(:text) { "This references #1, but not #{url}" }
it { is_expected.to include url }
end
- context 'code' do
+ context "code" do
let(:text) { "#1, but not `[#1]`" }
it { is_expected.to eq "#{issue_first.to_reference(new_project)}, but not `[#1]`" }
end
- context 'code reverse' do
+ context "code reverse" do
let(:text) { "not `#1`, but #1" }
it { is_expected.to eq "not `#1`, but #{issue_first.to_reference(new_project)}" }
end
- context 'code in random order' do
+ context "code in random order" do
let(:text) { "#1, `#1`, #1, `#1`" }
let(:ref) { issue_first.to_reference(new_project) }
it { is_expected.to eq "#{ref}, `#1`, #{ref}, `#1`" }
end
- context 'description with project labels' do
- let!(:label) { create(:label, id: 123, name: 'test', project: old_project) }
+ context "description with project labels" do
+ let!(:label) { create(:label, id: 123, name: "test", project: old_project) }
- context 'label referenced by id' do
- let(:text) { '#1 and ~123' }
- it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} }
+ context "label referenced by id" do
+ let(:text) { "#1 and ~123" }
+ it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~123) }
end
- context 'label referenced by text' do
+ context "label referenced by text" do
let(:text) { '#1 and ~"test"' }
- it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~123} }
+ it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~123) }
end
end
- context 'description with group labels' do
+ context "description with group labels" do
let(:old_group) { create(:group) }
- let!(:group_label) { create(:group_label, id: 321, name: 'group label', group: old_group) }
+ let!(:group_label) { create(:group_label, id: 321, name: "group label", group: old_group) }
before do
old_project.update(namespace: old_group)
end
- context 'label referenced by id' do
- let(:text) { '#1 and ~321' }
- it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} }
+ context "label referenced by id" do
+ let(:text) { "#1 and ~321" }
+ it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~321) }
end
- context 'label referenced by text' do
+ context "label referenced by text" do
let(:text) { '#1 and ~"group label"' }
- it { is_expected.to eq %Q{#{old_project_ref}#1 and #{old_project_ref}~321} }
+ it { is_expected.to eq %(#{old_project_ref}#1 and #{old_project_ref}~321) }
end
end
end
end
- context 'reference contains project milestone' do
+ context "reference contains project milestone" do
let!(:milestone) do
- create(:milestone, title: '9.0', project: old_project)
+ create(:milestone, title: "9.0", project: old_project)
end
let(:text) { 'milestone: %"9.0"' }
- it { is_expected.to eq %Q[milestone: #{old_project_ref}%"9.0"] }
+ it { is_expected.to eq %(milestone: #{old_project_ref}%"9.0") }
end
- context 'when referring to group milestone' do
+ context "when referring to group milestone" do
let!(:milestone) do
- create(:milestone, title: '10.0', group: group)
+ create(:milestone, title: "10.0", group: group)
end
let(:text) { 'milestone %"10.0"' }
@@ -122,9 +122,9 @@ describe Gitlab::Gfm::ReferenceRewriter do
it { is_expected.to eq text }
end
- context 'when referable has a nil reference' do
+ context "when referable has a nil reference" do
before do
- create(:milestone, title: '9.0', project: old_project)
+ create(:milestone, title: "9.0", project: old_project)
allow_any_instance_of(Milestone)
.to receive(:to_reference)
@@ -133,10 +133,10 @@ describe Gitlab::Gfm::ReferenceRewriter do
let(:text) { 'milestone: %"9.0"' }
- it 'raises an error that should be fixed' do
+ it "raises an error that should be fixed" do
expect { subject }.to raise_error(
described_class::RewriteError,
- 'Unspecified reference detected for Milestone'
+ "Unspecified reference detected for Milestone"
)
end
end
diff --git a/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb b/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
index ef52a25f47e..81e0e38ad06 100644
--- a/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
+++ b/spec/lib/gitlab/gfm/uploads_rewriter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Gfm::UploadsRewriter do
let(:user) { create(:user) }
@@ -6,14 +6,14 @@ describe Gitlab::Gfm::UploadsRewriter do
let(:new_project) { create(:project) }
let(:rewriter) { described_class.new(text, old_project, user) }
- context 'text contains links to uploads' do
+ context "text contains links to uploads" do
let(:image_uploader) do
build(:file_uploader, project: old_project)
end
let(:zip_uploader) do
build(:file_uploader, project: old_project,
- fixture: 'ci_build_artifacts.zip')
+ fixture: "ci_build_artifacts.zip")
end
let(:text) do
@@ -21,7 +21,7 @@ describe Gitlab::Gfm::UploadsRewriter do
end
shared_examples "files are accessible" do
- describe '#rewrite' do
+ describe "#rewrite" do
let!(:new_text) { rewriter.rewrite(new_project) }
let(:old_files) { [image_uploader, zip_uploader] }
@@ -32,23 +32,23 @@ describe Gitlab::Gfm::UploadsRewriter do
let(:old_paths) { old_files.map(&:path) }
let(:new_paths) { new_files.map(&:path) }
- it 'rewrites content' do
+ it "rewrites content" do
expect(new_text).not_to eq text
expect(new_text.length).to eq text.length
end
- it 'copies files' do
+ it "copies files" do
expect(new_files).to all(exist)
expect(old_paths).not_to match_array new_paths
expect(old_paths).to all(include(old_project.disk_path))
expect(new_paths).to all(include(new_project.disk_path))
end
- it 'does not remove old files' do
+ it "does not remove old files" do
expect(old_files).to all(exist)
end
- it 'generates a new secret for each file' do
+ it "generates a new secret for each file" do
expect(new_paths).not_to include image_uploader.secret
expect(new_paths).not_to include zip_uploader.secret
end
@@ -71,12 +71,12 @@ describe Gitlab::Gfm::UploadsRewriter do
include_examples "files are accessible"
end
- describe '#needs_rewrite?' do
+ describe "#needs_rewrite?" do
subject { rewriter.needs_rewrite? }
it { is_expected.to eq true }
end
- describe '#files' do
+ describe "#files" do
subject { rewriter.files }
it { is_expected.to be_an(Array) }
end
diff --git a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
index 134bd5657e7..add0a61b5d2 100644
--- a/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_at_ref_parser_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::AttributesAtRefParser, :seed_helper do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- subject { described_class.new(repository, 'lfs') }
+ subject { described_class.new(repository, "lfs") }
- it 'loads .gitattributes blob' do
+ it "loads .gitattributes blob" do
repository.raw # Initialize repository in advance since this also checks attributes
- expected_filter = 'filter=lfs diff=lfs merge=lfs'
+ expected_filter = "filter=lfs diff=lfs merge=lfs"
receive_blob = receive(:new).with(a_string_including(expected_filter))
expect(Gitlab::Git::AttributesParser).to receive_blob.and_call_original
subject
end
- it 'handles missing blobs' do
- expect { described_class.new(repository, 'non-existent-branch') }.not_to raise_error
+ it "handles missing blobs" do
+ expect { described_class.new(repository, "non-existent-branch") }.not_to raise_error
end
- describe '#attributes' do
- it 'returns the attributes as a Hash' do
- expect(subject.attributes('test.lfs')['filter']).to eq('lfs')
+ describe "#attributes" do
+ it "returns the attributes as a Hash" do
+ expect(subject.attributes("test.lfs")["filter"]).to eq("lfs")
end
end
end
diff --git a/spec/lib/gitlab/git/attributes_parser_spec.rb b/spec/lib/gitlab/git/attributes_parser_spec.rb
index f431d4e2a53..be3e3754612 100644
--- a/spec/lib/gitlab/git/attributes_parser_spec.rb
+++ b/spec/lib/gitlab/git/attributes_parser_spec.rb
@@ -1,138 +1,138 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::AttributesParser, :seed_helper do
- let(:attributes_path) { File.join(SEED_STORAGE_PATH, 'with-git-attributes.git', 'info', 'attributes') }
+ let(:attributes_path) { File.join(SEED_STORAGE_PATH, "with-git-attributes.git", "info", "attributes") }
let(:data) { File.read(attributes_path) }
subject { described_class.new(data) }
- describe '#attributes' do
- context 'using a path with attributes' do
- it 'returns the attributes as a Hash' do
- expect(subject.attributes('test.txt')).to eq({ 'text' => true })
+ describe "#attributes" do
+ context "using a path with attributes" do
+ it "returns the attributes as a Hash" do
+ expect(subject.attributes("test.txt")).to eq({"text" => true})
end
- it 'returns a Hash containing multiple attributes' do
- expect(subject.attributes('test.sh'))
- .to eq({ 'eol' => 'lf', 'gitlab-language' => 'shell' })
+ it "returns a Hash containing multiple attributes" do
+ expect(subject.attributes("test.sh"))
+ .to eq({"eol" => "lf", "gitlab-language" => "shell"})
end
- it 'returns a Hash containing attributes for a file with multiple extensions' do
- expect(subject.attributes('test.haml.html'))
- .to eq({ 'gitlab-language' => 'haml' })
+ it "returns a Hash containing attributes for a file with multiple extensions" do
+ expect(subject.attributes("test.haml.html"))
+ .to eq({"gitlab-language" => "haml"})
end
- it 'returns a Hash containing attributes for a file in a directory' do
- expect(subject.attributes('foo/bar.txt')).to eq({ 'foo' => true })
+ it "returns a Hash containing attributes for a file in a directory" do
+ expect(subject.attributes("foo/bar.txt")).to eq({"foo" => true})
end
- it 'returns a Hash containing attributes with query string parameters' do
- expect(subject.attributes('foo.cgi'))
- .to eq({ 'key' => 'value?p1=v1&p2=v2' })
+ it "returns a Hash containing attributes with query string parameters" do
+ expect(subject.attributes("foo.cgi"))
+ .to eq({"key" => "value?p1=v1&p2=v2"})
end
- it 'returns a Hash containing the attributes for an absolute path' do
- expect(subject.attributes('/test.txt')).to eq({ 'text' => true })
+ it "returns a Hash containing the attributes for an absolute path" do
+ expect(subject.attributes("/test.txt")).to eq({"text" => true})
end
- it 'returns a Hash containing the attributes when a pattern is defined using an absolute path' do
+ it "returns a Hash containing the attributes when a pattern is defined using an absolute path" do
# When a path is given without a leading slash it should still match
# patterns defined with a leading slash.
- expect(subject.attributes('foo.png'))
- .to eq({ 'gitlab-language' => 'png' })
+ expect(subject.attributes("foo.png"))
+ .to eq({"gitlab-language" => "png"})
- expect(subject.attributes('/foo.png'))
- .to eq({ 'gitlab-language' => 'png' })
+ expect(subject.attributes("/foo.png"))
+ .to eq({"gitlab-language" => "png"})
end
- it 'returns an empty Hash for a defined path without attributes' do
- expect(subject.attributes('bla/bla.txt')).to eq({})
+ it "returns an empty Hash for a defined path without attributes" do
+ expect(subject.attributes("bla/bla.txt")).to eq({})
end
context 'when the "binary" option is set for a path' do
it 'returns true for the "binary" option' do
- expect(subject.attributes('test.binary')['binary']).to eq(true)
+ expect(subject.attributes("test.binary")["binary"]).to eq(true)
end
it 'returns false for the "diff" option' do
- expect(subject.attributes('test.binary')['diff']).to eq(false)
+ expect(subject.attributes("test.binary")["diff"]).to eq(false)
end
end
end
- context 'using a path without any attributes' do
- it 'returns an empty Hash' do
- expect(subject.attributes('test.foo')).to eq({})
+ context "using a path without any attributes" do
+ it "returns an empty Hash" do
+ expect(subject.attributes("test.foo")).to eq({})
end
end
- context 'when attributes data is nil' do
+ context "when attributes data is nil" do
let(:data) { nil }
- it 'returns an empty Hash' do
- expect(subject.attributes('test.foo')).to eq({})
+ it "returns an empty Hash" do
+ expect(subject.attributes("test.foo")).to eq({})
end
end
end
- describe '#patterns' do
- it 'parses a file with entries' do
+ describe "#patterns" do
+ it "parses a file with entries" do
expect(subject.patterns).to be_an_instance_of(Hash)
end
- it 'parses an entry that uses a tab to separate the pattern and attributes' do
- expect(subject.patterns[File.join('/', '*.md')])
- .to eq({ 'gitlab-language' => 'markdown' })
+ it "parses an entry that uses a tab to separate the pattern and attributes" do
+ expect(subject.patterns[File.join("/", "*.md")])
+ .to eq({"gitlab-language" => "markdown"})
end
- it 'stores patterns in reverse order' do
+ it "stores patterns in reverse order" do
first = subject.patterns.to_a[0]
- expect(first[0]).to eq(File.join('/', 'bla/bla.txt'))
+ expect(first[0]).to eq(File.join("/", "bla/bla.txt"))
end
# It's a bit hard to test for something _not_ being processed. As such we'll
# just test the number of entries.
- it 'ignores any comments and empty lines' do
+ it "ignores any comments and empty lines" do
expect(subject.patterns.length).to eq(12)
end
end
- describe '#parse_attributes' do
- it 'parses a boolean attribute' do
- expect(subject.parse_attributes('text')).to eq({ 'text' => true })
+ describe "#parse_attributes" do
+ it "parses a boolean attribute" do
+ expect(subject.parse_attributes("text")).to eq({"text" => true})
end
- it 'parses a negated boolean attribute' do
- expect(subject.parse_attributes('-text')).to eq({ 'text' => false })
+ it "parses a negated boolean attribute" do
+ expect(subject.parse_attributes("-text")).to eq({"text" => false})
end
- it 'parses a key-value pair' do
- expect(subject.parse_attributes('foo=bar')).to eq({ 'foo' => 'bar' })
+ it "parses a key-value pair" do
+ expect(subject.parse_attributes("foo=bar")).to eq({"foo" => "bar"})
end
- it 'parses multiple attributes' do
- input = 'boolean key=value -negated'
+ it "parses multiple attributes" do
+ input = "boolean key=value -negated"
expect(subject.parse_attributes(input))
- .to eq({ 'boolean' => true, 'key' => 'value', 'negated' => false })
+ .to eq({"boolean" => true, "key" => "value", "negated" => false})
end
- it 'parses attributes with query string parameters' do
- expect(subject.parse_attributes('foo=bar?baz=1'))
- .to eq({ 'foo' => 'bar?baz=1' })
+ it "parses attributes with query string parameters" do
+ expect(subject.parse_attributes("foo=bar?baz=1"))
+ .to eq({"foo" => "bar?baz=1"})
end
end
- describe '#each_line' do
- it 'iterates over every line in the attributes file' do
+ describe "#each_line" do
+ it "iterates over every line in the attributes file" do
args = [String] * 16 # the number of lines in the file
expect { |b| subject.each_line(&b) }.to yield_successive_args(*args)
end
- it 'does not yield when the attributes file has an unsupported encoding' do
- path = File.join(SEED_STORAGE_PATH, 'with-invalid-git-attributes.git', 'info', 'attributes')
+ it "does not yield when the attributes file has an unsupported encoding" do
+ path = File.join(SEED_STORAGE_PATH, "with-invalid-git-attributes.git", "info", "attributes")
attrs = described_class.new(File.read(path))
expect { |b| attrs.each_line(&b) }.not_to yield_control
diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb
index 0010c0304eb..da85da6237a 100644
--- a/spec/lib/gitlab/git/blame_spec.rb
+++ b/spec/lib/gitlab/git/blame_spec.rb
@@ -1,20 +1,19 @@
-# coding: utf-8
require "spec_helper"
describe Gitlab::Git::Blame, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:blame) do
Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md")
end
- describe 'blaming a file' do
+ describe "blaming a file" do
context "each count" do
it do
data = []
blame.each do |commit, line|
data << {
commit: commit,
- line: line
+ line: line,
}
end
@@ -30,12 +29,12 @@ describe Gitlab::Git::Blame, :seed_helper do
Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt")
end
- it 'converts to UTF-8' do
+ it "converts to UTF-8" do
data = []
blame.each do |commit, line|
data << {
commit: commit,
- line: line
+ line: line,
}
end
@@ -51,13 +50,13 @@ describe Gitlab::Git::Blame, :seed_helper do
Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt")
end
- it 'converts to UTF-8' do
+ it "converts to UTF-8" do
expect(CharlockHolmes::EncodingDetector).to receive(:detect).and_return(nil)
data = []
blame.each do |commit, line|
data << {
commit: commit,
- line: line
+ line: line,
}
end
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index a1b5cea88c0..4e876200554 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -1,43 +1,41 @@
-# encoding: utf-8
-
require "spec_helper"
describe Gitlab::Git::Blob, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:rugged) do
Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH))
end
- describe 'initialize' do
- let(:blob) { Gitlab::Git::Blob.new(name: 'test') }
+ describe "initialize" do
+ let(:blob) { Gitlab::Git::Blob.new(name: "test") }
- it 'handles nil data' do
- expect(blob.name).to eq('test')
+ it "handles nil data" do
+ expect(blob.name).to eq("test")
expect(blob.size).to eq(nil)
expect(blob.loaded_size).to eq(nil)
end
end
- describe '.find' do
- context 'nil path' do
+ describe ".find" do
+ context "nil path" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, nil) }
it { expect(blob).to eq(nil) }
end
- context 'utf-8 branch' do
- let(:blob) { Gitlab::Git::Blob.find(repository, 'Ääh-test-utf-8', "files/ruby/popen.rb")}
+ context "utf-8 branch" do
+ let(:blob) { Gitlab::Git::Blob.find(repository, "Ääh-test-utf-8", "files/ruby/popen.rb")}
it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) }
end
- context 'blank path' do
- let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, '') }
+ context "blank path" do
+ let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "") }
it { expect(blob).to eq(nil) }
end
- context 'file in subdir' do
+ context "file in subdir" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "files/ruby/popen.rb") }
it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) }
@@ -49,7 +47,7 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- context 'file in root' do
+ context "file in root" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, ".gitignore") }
it { expect(blob.id).to eq("dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82") }
@@ -62,7 +60,7 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob).not_to be_binary_in_repo }
end
- context 'file in root with leading slash' do
+ context "file in root with leading slash" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "/.gitignore") }
it { expect(blob.id).to eq("dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82") }
@@ -74,51 +72,51 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- context 'non-exist file' do
+ context "non-exist file" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "missing.rb") }
it { expect(blob).to be_nil }
end
- context 'six submodule' do
- let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, 'six') }
+ context "six submodule" do
+ let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "six") }
- it { expect(blob.id).to eq('409f37c4f05865e4fb208c771485f211a22c4c2d') }
- it { expect(blob.data).to eq('') }
+ it { expect(blob.id).to eq("409f37c4f05865e4fb208c771485f211a22c4c2d") }
+ it { expect(blob.data).to eq("") }
- it 'does not get messed up by load_all_data!' do
+ it "does not get messed up by load_all_data!" do
blob.load_all_data!(repository)
- expect(blob.data).to eq('')
+ expect(blob.data).to eq("")
end
- it 'does not mark the blob as binary' do
+ it "does not mark the blob as binary" do
expect(blob).not_to be_binary_in_repo
end
end
- context 'large file' do
- let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, 'files/images/6049019_460s.jpg') }
+ context "large file" do
+ let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "files/images/6049019_460s.jpg") }
let(:blob_size) { 111803 }
let(:stub_limit) { 1000 }
before do
- stub_const('Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE', stub_limit)
+ stub_const("Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE", stub_limit)
end
it { expect(blob.size).to eq(blob_size) }
it { expect(blob.data.length).to eq(stub_limit) }
- it 'check that this test is sane' do
+ it "check that this test is sane" do
# It only makes sense to test limiting if the blob is larger than the limit.
expect(blob.size).to be > Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE
end
- it 'can load all data' do
+ it "can load all data" do
blob.load_all_data!(repository)
expect(blob.data.length).to eq(blob_size)
end
- it 'marks the blob as binary' do
+ it "marks the blob as binary" do
expect(Gitlab::Git::Blob).to receive(:new)
.with(hash_including(binary: true))
.and_call_original
@@ -128,7 +126,7 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe '.raw' do
+ describe ".raw" do
let(:raw_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::RubyBlob::ID) }
let(:bad_blob) { Gitlab::Git::Blob.raw(repository, SeedRepo::BigCommit::ID) }
@@ -138,11 +136,11 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(raw_blob.truncated?).to be_falsey }
it { expect(bad_blob).to be_nil }
- context 'large file' do
- it 'limits the size of a large file' do
+ context "large file" do
+ it "limits the size of a large file" do
blob_size = Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE + 1
buffer = Array.new(blob_size, 0)
- rugged_blob = Rugged::Blob.from_buffer(rugged, buffer.join(''))
+ rugged_blob = Rugged::Blob.from_buffer(rugged, buffer.join(""))
blob = Gitlab::Git::Blob.raw(repository, rugged_blob)
expect(blob.size).to eq(blob_size)
@@ -155,9 +153,9 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- context 'when sha references a tree' do
- it 'returns nil' do
- tree = rugged.rev_parse('master^{tree}')
+ context "when sha references a tree" do
+ it "returns nil" do
+ tree = rugged.rev_parse("master^{tree}")
blob = Gitlab::Git::Blob.raw(repository, tree.oid)
@@ -166,11 +164,11 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe '.batch' do
+ describe ".batch" do
let(:blob_references) do
[
[SeedRepo::Commit::ID, "files/ruby/popen.rb"],
- [SeedRepo::Commit::ID, 'six']
+ [SeedRepo::Commit::ID, "six"],
]
end
@@ -178,7 +176,7 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(subject.size).to eq(blob_references.size) }
- context 'first blob' do
+ context "first blob" do
let(:blob) { subject[0] }
it { expect(blob.id).to eq(SeedRepo::RubyBlob::ID) }
@@ -190,39 +188,39 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- context 'second blob' do
+ context "second blob" do
let(:blob) { subject[1] }
- it { expect(blob.id).to eq('409f37c4f05865e4fb208c771485f211a22c4c2d') }
- it { expect(blob.data).to eq('') }
- it 'does not mark the blob as binary' do
+ it { expect(blob.id).to eq("409f37c4f05865e4fb208c771485f211a22c4c2d") }
+ it { expect(blob.data).to eq("") }
+ it "does not mark the blob as binary" do
expect(blob).not_to be_binary_in_repo
end
end
- context 'limiting' do
+ context "limiting" do
subject { described_class.batch(repository, blob_references, blob_size_limit: blob_size_limit) }
- context 'positive' do
+ context "positive" do
let(:blob_size_limit) { 10 }
it { expect(subject.first.data.size).to eq(10) }
end
- context 'zero' do
+ context "zero" do
let(:blob_size_limit) { 0 }
- it 'only loads the metadata' do
+ it "only loads the metadata" do
expect(subject.first.size).not_to be(0)
- expect(subject.first.data).to eq('')
+ expect(subject.first.data).to eq("")
end
end
- context 'negative' do
+ context "negative" do
let(:blob_size_limit) { -1 }
- it 'ignores MAX_DATA_DISPLAY_SIZE' do
- stub_const('Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE', 100)
+ it "ignores MAX_DATA_DISPLAY_SIZE" do
+ stub_const("Gitlab::Git::Blob::MAX_DATA_DISPLAY_SIZE", 100)
expect(subject.first.data.size).to eq(669)
end
@@ -230,17 +228,17 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe '.batch_metadata' do
+ describe ".batch_metadata" do
let(:blob_references) do
[
[SeedRepo::Commit::ID, "files/ruby/popen.rb"],
- [SeedRepo::Commit::ID, 'six']
+ [SeedRepo::Commit::ID, "six"],
]
end
subject { described_class.batch_metadata(repository, blob_references) }
- it 'returns an empty data attribute' do
+ it "returns an empty data attribute" do
first_blob, last_blob = subject
expect(first_blob.data).to be_blank
@@ -250,41 +248,41 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe '.batch_lfs_pointers' do
- let(:tree_object) { rugged.rev_parse('master^{tree}') }
+ describe ".batch_lfs_pointers" do
+ let(:tree_object) { rugged.rev_parse("master^{tree}") }
let(:non_lfs_blob) do
Gitlab::Git::Blob.find(
repository,
- 'master',
- 'README.md'
+ "master",
+ "README.md"
)
end
let(:lfs_blob) do
Gitlab::Git::Blob.find(
repository,
- '33bcff41c232a11727ac6d660bd4b0c2ba86d63d',
- 'files/lfs/image.jpg'
+ "33bcff41c232a11727ac6d660bd4b0c2ba86d63d",
+ "files/lfs/image.jpg"
)
end
- it 'returns a list of Gitlab::Git::Blob' do
+ it "returns a list of Gitlab::Git::Blob" do
blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id])
expect(blobs.count).to eq(1)
- expect(blobs).to all( be_a(Gitlab::Git::Blob) )
+ expect(blobs).to all(be_a(Gitlab::Git::Blob))
expect(blobs).to be_an(Array)
end
- it 'accepts blob IDs as a lazy enumerator' do
+ it "accepts blob IDs as a lazy enumerator" do
blobs = described_class.batch_lfs_pointers(repository, [lfs_blob.id].lazy)
expect(blobs.count).to eq(1)
- expect(blobs).to all( be_a(Gitlab::Git::Blob) )
+ expect(blobs).to all(be_a(Gitlab::Git::Blob))
end
- it 'handles empty list of IDs gracefully' do
+ it "handles empty list of IDs gracefully" do
blobs_1 = described_class.batch_lfs_pointers(repository, [].lazy)
blobs_2 = described_class.batch_lfs_pointers(repository, [])
@@ -292,19 +290,19 @@ describe Gitlab::Git::Blob, :seed_helper do
expect(blobs_2).to eq([])
end
- it 'silently ignores tree objects' do
+ it "silently ignores tree objects" do
blobs = described_class.batch_lfs_pointers(repository, [tree_object.oid])
expect(blobs).to eq([])
end
- it 'silently ignores non lfs objects' do
+ it "silently ignores non lfs objects" do
blobs = described_class.batch_lfs_pointers(repository, [non_lfs_blob.id])
expect(blobs).to eq([])
end
- it 'avoids loading large blobs into memory' do
+ it "avoids loading large blobs into memory" do
# This line could call `lookup` on `repository`, so do here before mocking.
non_lfs_blob_id = non_lfs_blob.id
@@ -314,8 +312,8 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe 'encoding' do
- context 'file with russian text' do
+ describe "encoding" do
+ context "file with russian text" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "encoding/russian.rb") }
it { expect(blob.name).to eq("russian.rb") }
@@ -327,7 +325,7 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100755") }
end
- context 'file with Chinese text' do
+ context "file with Chinese text" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::Commit::ID, "encoding/テスト.txt") }
it { expect(blob.name).to eq("テスト.txt") }
@@ -337,7 +335,7 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.truncated?).to be_falsey }
end
- context 'file with ISO-8859 text' do
+ context "file with ISO-8859 text" do
let(:blob) { Gitlab::Git::Blob.find(repository, SeedRepo::LastCommit::ID, "encoding/iso8859.txt") }
it { expect(blob.name).to eq("iso8859.txt") }
@@ -348,75 +346,75 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe 'mode' do
- context 'file regular' do
+ describe "mode" do
+ context "file regular" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6',
- 'files/ruby/regex.rb'
+ "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6",
+ "files/ruby/regex.rb"
)
end
- it { expect(blob.name).to eq('regex.rb') }
- it { expect(blob.path).to eq('files/ruby/regex.rb') }
+ it { expect(blob.name).to eq("regex.rb") }
+ it { expect(blob.path).to eq("files/ruby/regex.rb") }
it { expect(blob.size).to eq(1200) }
it { expect(blob.mode).to eq("100644") }
end
- context 'file binary' do
+ context "file binary" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6',
- 'files/executables/ls'
+ "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6",
+ "files/executables/ls"
)
end
- it { expect(blob.name).to eq('ls') }
- it { expect(blob.path).to eq('files/executables/ls') }
+ it { expect(blob.name).to eq("ls") }
+ it { expect(blob.path).to eq("files/executables/ls") }
it { expect(blob.size).to eq(110080) }
it { expect(blob.mode).to eq("100755") }
end
- context 'file symlink to regular' do
+ context "file symlink to regular" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6',
- 'files/links/ruby-style-guide.md'
+ "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6",
+ "files/links/ruby-style-guide.md"
)
end
- it { expect(blob.name).to eq('ruby-style-guide.md') }
- it { expect(blob.path).to eq('files/links/ruby-style-guide.md') }
+ it { expect(blob.name).to eq("ruby-style-guide.md") }
+ it { expect(blob.path).to eq("files/links/ruby-style-guide.md") }
it { expect(blob.size).to eq(31) }
it { expect(blob.mode).to eq("120000") }
end
- context 'file symlink to binary' do
+ context "file symlink to binary" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6',
- 'files/links/touch'
+ "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6",
+ "files/links/touch"
)
end
- it { expect(blob.name).to eq('touch') }
- it { expect(blob.path).to eq('files/links/touch') }
+ it { expect(blob.name).to eq("touch") }
+ it { expect(blob.path).to eq("files/links/touch") }
it { expect(blob.size).to eq(20) }
it { expect(blob.mode).to eq("120000") }
end
end
- describe 'lfs_pointers' do
- context 'file a valid lfs pointer' do
+ describe "lfs_pointers" do
+ context "file a valid lfs pointer" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- '33bcff41c232a11727ac6d660bd4b0c2ba86d63d',
- 'files/lfs/image.jpg'
+ "33bcff41c232a11727ac6d660bd4b0c2ba86d63d",
+ "files/lfs/image.jpg"
)
end
@@ -430,13 +428,13 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- describe 'file an invalid lfs pointer' do
- context 'with correct version header but incorrect size and oid' do
+ describe "file an invalid lfs pointer" do
+ context "with correct version header but incorrect size and oid" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- '33bcff41c232a11727ac6d660bd4b0c2ba86d63d',
- 'files/lfs/archive-invalid.tar'
+ "33bcff41c232a11727ac6d660bd4b0c2ba86d63d",
+ "files/lfs/archive-invalid.tar"
)
end
@@ -450,12 +448,12 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- context 'with correct version header and size but incorrect size and oid' do
+ context "with correct version header and size but incorrect size and oid" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- '33bcff41c232a11727ac6d660bd4b0c2ba86d63d',
- 'files/lfs/picture-invalid.png'
+ "33bcff41c232a11727ac6d660bd4b0c2ba86d63d",
+ "files/lfs/picture-invalid.png"
)
end
@@ -469,12 +467,12 @@ describe Gitlab::Git::Blob, :seed_helper do
it { expect(blob.mode).to eq("100644") }
end
- context 'with correct version header and size but invalid size and oid' do
+ context "with correct version header and size but invalid size and oid" do
let(:blob) do
Gitlab::Git::Blob.find(
repository,
- '33bcff41c232a11727ac6d660bd4b0c2ba86d63d',
- 'files/lfs/file-invalid.zip'
+ "33bcff41c232a11727ac6d660bd4b0c2ba86d63d",
+ "files/lfs/file-invalid.zip"
)
end
@@ -490,13 +488,13 @@ describe Gitlab::Git::Blob, :seed_helper do
end
end
- describe '#load_all_data!' do
- let(:full_data) { 'abcd' }
- let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abc') }
+ describe "#load_all_data!" do
+ let(:full_data) { "abcd" }
+ let(:blob) { Gitlab::Git::Blob.new(name: "test", size: 4, data: "abc") }
subject { blob.load_all_data!(repository) }
- it 'loads missing data' do
+ it "loads missing data" do
expect(repository.gitaly_blob_client).to receive(:get_blob)
.and_return(double(:response, data: full_data))
@@ -505,8 +503,8 @@ describe Gitlab::Git::Blob, :seed_helper do
expect(blob.data).to eq(full_data)
end
- context 'with a fully loaded blob' do
- let(:blob) { Gitlab::Git::Blob.new(name: 'test', size: 4, data: full_data) }
+ context "with a fully loaded blob" do
+ let(:blob) { Gitlab::Git::Blob.new(name: "test", size: 4, data: full_data) }
it "doesn't perform any loading" do
expect(repository.gitaly_blob_client).not_to receive(:get_blob)
diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb
index 0764e525ede..a707cf0a25f 100644
--- a/spec/lib/gitlab/git/branch_spec.rb
+++ b/spec/lib/gitlab/git/branch_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe Gitlab::Git::Branch, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:rugged) do
Rugged::Repository.new(File.join(TestEnv.repos_path, repository.relative_path))
end
@@ -10,7 +10,7 @@ describe Gitlab::Git::Branch, :seed_helper do
it { is_expected.to be_kind_of Array }
- describe '.find' do
+ describe ".find" do
subject { described_class.find(repository, branch) }
before do
@@ -18,10 +18,10 @@ describe Gitlab::Git::Branch, :seed_helper do
.and_call_original
end
- context 'when finding branch via branch name' do
- let(:branch) { 'master' }
+ context "when finding branch via branch name" do
+ let(:branch) { "master" }
- it 'returns a branch object' do
+ it "returns a branch object" do
expect(subject).to be_a(described_class)
expect(subject.name).to eq(branch)
@@ -29,11 +29,11 @@ describe Gitlab::Git::Branch, :seed_helper do
end
end
- context 'when the branch is already a branch' do
- let(:commit) { repository.commit('master') }
- let(:branch) { described_class.new(repository, 'master', commit.sha, commit) }
+ context "when the branch is already a branch" do
+ let(:commit) { repository.commit("master") }
+ let(:branch) { described_class.new(repository, "master", commit.sha, commit) }
- it 'returns a branch object' do
+ it "returns a branch object" do
expect(subject).to be_a(described_class)
expect(subject).to eq(branch)
@@ -42,29 +42,29 @@ describe Gitlab::Git::Branch, :seed_helper do
end
end
- describe '#size' do
+ describe "#size" do
subject { super().size }
it { is_expected.to eq(SeedRepo::Repo::BRANCHES.size) }
end
- describe 'first branch' do
+ describe "first branch" do
let(:branch) { repository.branches.first }
it { expect(branch.name).to eq(SeedRepo::Repo::BRANCHES.first) }
it { expect(branch.dereferenced_target.sha).to eq("0b4bc9a49b562e85de7cc9e834518ea6828729b9") }
end
- describe 'master branch' do
+ describe "master branch" do
let(:branch) do
- repository.branches.find { |branch| branch.name == 'master' }
+ repository.branches.find { |branch| branch.name == "master" }
end
it { expect(branch.dereferenced_target.sha).to eq(SeedRepo::LastCommit::ID) }
end
- context 'with active, stale and future branches' do
+ context "with active, stale and future branches" do
let(:repository) do
- Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project')
+ Gitlab::Git::Repository.new("default", TEST_MUTABLE_REPO_PATH, "", "group/project")
end
let(:user) { create(:user) }
@@ -76,11 +76,11 @@ describe Gitlab::Git::Branch, :seed_helper do
tree = parents.first.tree
{
- message: 'commit message',
+ message: "commit message",
author: committer,
committer: committer,
tree: tree,
- parents: parents
+ parents: parents,
}
end
let(:stale_sha) { Timecop.freeze(Gitlab::Git::Branch::STALE_BRANCH_THRESHOLD.ago - 5.days) { create_commit } }
@@ -88,33 +88,33 @@ describe Gitlab::Git::Branch, :seed_helper do
let(:future_sha) { Timecop.freeze(100.days.since) { create_commit } }
before do
- repository.create_branch('stale-1', stale_sha)
- repository.create_branch('active-1', active_sha)
- repository.create_branch('future-1', future_sha)
+ repository.create_branch("stale-1", stale_sha)
+ repository.create_branch("active-1", active_sha)
+ repository.create_branch("future-1", future_sha)
end
after do
ensure_seeds
end
- describe 'examine if the branch is active or stale' do
- let(:stale_branch) { repository.find_branch('stale-1') }
- let(:active_branch) { repository.find_branch('active-1') }
- let(:future_branch) { repository.find_branch('future-1') }
+ describe "examine if the branch is active or stale" do
+ let(:stale_branch) { repository.find_branch("stale-1") }
+ let(:active_branch) { repository.find_branch("active-1") }
+ let(:future_branch) { repository.find_branch("future-1") }
- describe '#active?' do
+ describe "#active?" do
it { expect(stale_branch.active?).to be_falsey }
it { expect(active_branch.active?).to be_truthy }
it { expect(future_branch.active?).to be_truthy }
end
- describe '#stale?' do
+ describe "#stale?" do
it { expect(stale_branch.stale?).to be_truthy }
it { expect(active_branch.stale?).to be_falsey }
it { expect(future_branch.stale?).to be_falsey }
end
- describe '#state' do
+ describe "#state" do
it { expect(stale_branch.state).to eq(:stale) }
it { expect(active_branch.state).to eq(:active) }
it { expect(future_branch.state).to eq(:active) }
diff --git a/spec/lib/gitlab/git/bundle_file_spec.rb b/spec/lib/gitlab/git/bundle_file_spec.rb
index ff7c981dadd..6551858c1cd 100644
--- a/spec/lib/gitlab/git/bundle_file_spec.rb
+++ b/spec/lib/gitlab/git/bundle_file_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::BundleFile do
- describe '.check!' do
+ describe ".check!" do
let(:valid_bundle) { Tempfile.new }
let(:valid_bundle_path) { valid_bundle.path }
- let(:invalid_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }
+ let(:invalid_bundle_path) { Rails.root.join("spec/fixtures/malicious.bundle") }
after do
valid_bundle.close!
end
- it 'returns nil for a valid bundle' do
+ it "returns nil for a valid bundle" do
valid_bundle.write("# v2 git bundle\nfoo bar baz\n")
valid_bundle.close
expect(described_class.check!(valid_bundle_path)).to be_nil
end
- it 'raises an exception for an invalid bundle' do
- expect do
+ it "raises an exception for an invalid bundle" do
+ expect {
described_class.check!(invalid_bundle_path)
- end.to raise_error(described_class::InvalidBundleError)
+ }.to raise_error(described_class::InvalidBundleError)
end
end
end
diff --git a/spec/lib/gitlab/git/commit_spec.rb b/spec/lib/gitlab/git/commit_spec.rb
index 2611ebed25b..f681356deb2 100644
--- a/spec/lib/gitlab/git/commit_spec.rb
+++ b/spec/lib/gitlab/git/commit_spec.rb
@@ -3,7 +3,7 @@ require "spec_helper"
describe Gitlab::Git::Commit, :seed_helper do
include GitHelpers
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:rugged_repo) do
Rugged::Repository.new(File.join(TestEnv.repos_path, TEST_REPO_PATH))
end
@@ -13,15 +13,15 @@ describe Gitlab::Git::Commit, :seed_helper do
describe "Commit info" do
before do
@committer = {
- email: 'mike@smith.com',
+ email: "mike@smith.com",
name: "Mike Smith",
- time: Time.now
+ time: Time.now,
}
@author = {
- email: 'john@smith.com',
+ email: "john@smith.com",
name: "John Smith",
- time: Time.now
+ time: Time.now,
}
@parents = [rugged_repo.head.target]
@@ -64,8 +64,8 @@ describe Gitlab::Git::Commit, :seed_helper do
end
describe "Commit info from gitaly commit" do
- let(:subject) { "My commit".force_encoding('ASCII-8BIT') }
- let(:body) { subject + "My body".force_encoding('ASCII-8BIT') }
+ let(:subject) { "My commit".force_encoding("ASCII-8BIT") }
+ let(:body) { subject + "My body".force_encoding("ASCII-8BIT") }
let(:body_size) { body.length }
let(:gitaly_commit) { build(:gitaly_commit, subject: subject, body: body, body_size: body_size) }
let(:id) { gitaly_commit.id }
@@ -84,35 +84,35 @@ describe Gitlab::Git::Commit, :seed_helper do
it { expect(commit.committer_email).to eq(committer.email) }
it { expect(commit.parent_ids).to eq(gitaly_commit.parent_ids) }
- context 'body_size != body.size' do
- let(:body) { "".force_encoding('ASCII-8BIT') }
+ context "body_size != body.size" do
+ let(:body) { "".force_encoding("ASCII-8BIT") }
- context 'zero body_size' do
+ context "zero body_size" do
it { expect(commit.safe_message).to eq(subject) }
end
- context 'body_size less than threshold' do
+ context "body_size less than threshold" do
let(:body_size) { 123 }
- it 'fetches commit message separately' do
+ it "fetches commit message separately" do
expect(described_class).to receive(:get_message).with(repository, id)
commit.safe_message
end
end
- context 'body_size greater than threshold' do
+ context "body_size greater than threshold" do
let(:body_size) { described_class::MAX_COMMIT_MESSAGE_DISPLAY_SIZE + 1 }
- it 'returns the suject plus a notice about message size' do
+ it "returns the suject plus a notice about message size" do
expect(commit.safe_message).to eq("My commit\n\n--commit message is too big")
end
end
end
end
- context 'Class methods' do
- describe '.find' do
+ context "Class methods" do
+ describe ".find" do
it "should return first head commit if without params" do
expect(described_class.last(repository).id).to eq(
rugged_repo.head.target.oid
@@ -128,7 +128,7 @@ describe Gitlab::Git::Commit, :seed_helper do
end
it "should return valid commit for tag" do
- expect(described_class.find(repository, 'v1.0.0').id).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9')
+ expect(described_class.find(repository, "v1.0.0").id).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9")
end
it "should return nil for non-commit ids" do
@@ -145,67 +145,67 @@ describe Gitlab::Git::Commit, :seed_helper do
expect(described_class.find(repository, "+123_4532530XYZ")).to be_nil
end
- context 'with broken repo' do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_BROKEN_REPO_PATH, '', 'group/project') }
+ context "with broken repo" do
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_BROKEN_REPO_PATH, "", "group/project") }
- it 'returns nil' do
+ it "returns nil" do
expect(described_class.find(repository, SeedRepo::Commit::ID)).to be_nil
end
end
end
- describe '.last_for_path' do
- context 'no path' do
- subject { described_class.last_for_path(repository, 'master') }
+ describe ".last_for_path" do
+ context "no path" do
+ subject { described_class.last_for_path(repository, "master") }
- describe '#id' do
+ describe "#id" do
subject { super().id }
it { is_expected.to eq(SeedRepo::LastCommit::ID) }
end
end
- context 'path' do
- subject { described_class.last_for_path(repository, 'master', 'files/ruby') }
+ context "path" do
+ subject { described_class.last_for_path(repository, "master", "files/ruby") }
- describe '#id' do
+ describe "#id" do
subject { super().id }
it { is_expected.to eq(SeedRepo::Commit::ID) }
end
end
- context 'ref + path' do
- subject { described_class.last_for_path(repository, SeedRepo::Commit::ID, 'encoding') }
+ context "ref + path" do
+ subject { described_class.last_for_path(repository, SeedRepo::Commit::ID, "encoding") }
- describe '#id' do
+ describe "#id" do
subject { super().id }
it { is_expected.to eq(SeedRepo::BigCommit::ID) }
end
end
end
- context 'path is empty string' do
+ context "path is empty string" do
subject do
commits = described_class.where(
repo: repository,
- ref: 'master',
- path: '',
+ ref: "master",
+ path: "",
limit: 10
)
commits.map { |c| c.id }
end
- it 'has 10 elements' do
+ it "has 10 elements" do
expect(subject.size).to eq(10)
end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end
- context 'path is nil' do
+ context "path is nil" do
subject do
commits = described_class.where(
repo: repository,
- ref: 'master',
+ ref: "master",
path: nil,
limit: 10
)
@@ -213,18 +213,18 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map { |c| c.id }
end
- it 'has 10 elements' do
+ it "has 10 elements" do
expect(subject.size).to eq(10)
end
it { is_expected.to include(SeedRepo::EmptyCommit::ID) }
end
- context 'ref is branch name' do
+ context "ref is branch name" do
subject do
commits = described_class.where(
repo: repository,
- ref: 'master',
- path: 'files',
+ ref: "master",
+ path: "files",
limit: 3,
offset: 1
)
@@ -232,19 +232,19 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map { |c| c.id }
end
- it 'has 3 elements' do
+ it "has 3 elements" do
expect(subject.size).to eq(3)
end
it { is_expected.to include("d14d6c0abdd253381df51a723d58691b2ee1ab08") }
it { is_expected.not_to include("eb49186cfa5c4338011f5f590fac11bd66c5c631") }
end
- context 'ref is commit id' do
+ context "ref is commit id" do
subject do
commits = described_class.where(
repo: repository,
ref: "874797c3a73b60d2187ed6e2fcabd289ff75171e",
- path: 'files',
+ path: "files",
limit: 3,
offset: 1
)
@@ -252,19 +252,19 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map { |c| c.id }
end
- it 'has 3 elements' do
+ it "has 3 elements" do
expect(subject.size).to eq(3)
end
it { is_expected.to include("2f63565e7aac07bcdadb654e253078b727143ec4") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end
- context 'ref is tag' do
+ context "ref is tag" do
subject do
commits = described_class.where(
repo: repository,
- ref: 'v1.0.0',
- path: 'files',
+ ref: "v1.0.0",
+ path: "files",
limit: 3,
offset: 1
)
@@ -272,55 +272,55 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map { |c| c.id }
end
- it 'has 3 elements' do
+ it "has 3 elements" do
expect(subject.size).to eq(3)
end
it { is_expected.to include("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
it { is_expected.not_to include(SeedRepo::Commit::ID) }
end
- describe '.between' do
+ describe ".between" do
subject do
commits = described_class.between(repository, SeedRepo::Commit::PARENT_ID, SeedRepo::Commit::ID)
commits.map { |c| c.id }
end
- it 'has 1 element' do
+ it "has 1 element" do
expect(subject.size).to eq(1)
end
it { is_expected.to include(SeedRepo::Commit::ID) }
it { is_expected.not_to include(SeedRepo::FirstCommit::ID) }
end
- describe '.shas_with_signatures' do
+ describe ".shas_with_signatures" do
let(:signed_shas) { %w[5937ac0a7beb003549fc5fd26fc247adbce4a52e 570e7b2abdd848b95f2f578043fc23bd6f6fd24d] }
let(:unsigned_shas) { %w[19e2e9b4ef76b422ce1154af39a91323ccc57434 c642fe9b8b9f28f9225d7ea953fe14e74748d53b] }
let(:first_signed_shas) { %w[5937ac0a7beb003549fc5fd26fc247adbce4a52e c642fe9b8b9f28f9225d7ea953fe14e74748d53b] }
- it 'has 2 signed shas' do
+ it "has 2 signed shas" do
ret = described_class.shas_with_signatures(repository, signed_shas)
expect(ret).to eq(signed_shas)
end
- it 'has 0 signed shas' do
+ it "has 0 signed shas" do
ret = described_class.shas_with_signatures(repository, unsigned_shas)
expect(ret).to eq([])
end
- it 'has 1 signed sha' do
+ it "has 1 signed sha" do
ret = described_class.shas_with_signatures(repository, first_signed_shas)
expect(ret).to contain_exactly(first_signed_shas.first)
end
end
- describe '.find_all' do
- it 'should return a return a collection of commits' do
+ describe ".find_all" do
+ it "should return a return a collection of commits" do
commits = described_class.find_all(repository)
- expect(commits).to all( be_a_kind_of(described_class) )
+ expect(commits).to all(be_a_kind_of(described_class))
end
- context 'max_count' do
+ context "max_count" do
subject do
commits = described_class.find_all(
repository,
@@ -330,11 +330,11 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map(&:id)
end
- it 'has 34 elements' do
+ it "has 34 elements" do
expect(subject.size).to eq(34)
end
- it 'includes the expected commits' do
+ it "includes the expected commits" do
expect(subject).to include(
SeedRepo::Commit::ID,
SeedRepo::Commit::PARENT_ID,
@@ -343,11 +343,11 @@ describe Gitlab::Git::Commit, :seed_helper do
end
end
- context 'ref + max_count + skip' do
+ context "ref + max_count + skip" do
subject do
commits = described_class.find_all(
repository,
- ref: 'master',
+ ref: "master",
max_count: 50,
skip: 1
)
@@ -355,20 +355,20 @@ describe Gitlab::Git::Commit, :seed_helper do
commits.map(&:id)
end
- it 'has 24 elements' do
+ it "has 24 elements" do
expect(subject.size).to eq(24)
end
- it 'includes the expected commits' do
+ it "includes the expected commits" do
expect(subject).to include(SeedRepo::Commit::ID, SeedRepo::FirstCommit::ID)
expect(subject).not_to include(SeedRepo::LastCommit::ID)
end
end
end
- describe '#batch_by_oid' do
- context 'when oids is empty' do
- it 'makes no Gitaly request' do
+ describe "#batch_by_oid" do
+ context "when oids is empty" do
+ it "makes no Gitaly request" do
expect(Gitlab::GitalyClient).not_to receive(:call)
described_class.batch_by_oid(repository, [])
@@ -376,11 +376,11 @@ describe Gitlab::Git::Commit, :seed_helper do
end
end
- shared_examples 'extracting commit signature' do
- context 'when the commit is signed' do
- let(:commit_id) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
+ shared_examples "extracting commit signature" do
+ context "when the commit is signed" do
+ let(:commit_id) { "0b4bc9a49b562e85de7cc9e834518ea6828729b9" }
- it 'returns signature and signed text' do
+ it "returns signature and signed text" do
signature, signed_text = subject
expected_signature = <<~SIGNATURE
@@ -417,38 +417,38 @@ describe Gitlab::Git::Commit, :seed_helper do
end
end
- context 'when the commit has no signature' do
- let(:commit_id) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' }
+ context "when the commit has no signature" do
+ let(:commit_id) { "4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to be_nil
end
end
- context 'when the commit cannot be found' do
+ context "when the commit cannot be found" do
let(:commit_id) { Gitlab::Git::BLANK_SHA }
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to be_nil
end
end
- context 'when the commit ID is invalid' do
- let(:commit_id) { '4b4918a572fa86f9771e5ba40fbd48e' }
+ context "when the commit ID is invalid" do
+ let(:commit_id) { "4b4918a572fa86f9771e5ba40fbd48e" }
- it 'raises ArgumentError' do
+ it "raises ArgumentError" do
expect { subject }.to raise_error(ArgumentError)
end
end
end
- describe '.extract_signature_lazily' do
- describe 'loading signatures in batch once' do
- it 'fetches signatures in batch once' do
+ describe ".extract_signature_lazily" do
+ describe "loading signatures in batch once" do
+ it "fetches signatures in batch once" do
commit_ids = %w[0b4bc9a49b562e85de7cc9e834518ea6828729b9 4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6]
- signatures = commit_ids.map do |commit_id|
+ signatures = commit_ids.map { |commit_id|
described_class.extract_signature_lazily(repository, commit_id)
- end
+ }
other_repository = double(:repository)
described_class.extract_signature_lazily(other_repository, commit_ids.first)
@@ -467,79 +467,79 @@ describe Gitlab::Git::Commit, :seed_helper do
subject { described_class.extract_signature_lazily(repository, commit_id).itself }
- it_behaves_like 'extracting commit signature'
+ it_behaves_like "extracting commit signature"
end
- describe '.extract_signature' do
+ describe ".extract_signature" do
subject { described_class.extract_signature(repository, commit_id) }
- it_behaves_like 'extracting commit signature'
+ it_behaves_like "extracting commit signature"
end
end
- skip 'move this test to gitaly-ruby' do
- describe '#init_from_rugged' do
+ skip "move this test to gitaly-ruby" do
+ describe "#init_from_rugged" do
let(:gitlab_commit) { described_class.new(repository, rugged_commit) }
subject { gitlab_commit }
- describe '#id' do
+ describe "#id" do
subject { super().id }
it { is_expected.to eq(SeedRepo::Commit::ID) }
end
end
end
- describe '#init_from_hash' do
+ describe "#init_from_hash" do
let(:commit) { described_class.new(repository, sample_commit_hash) }
subject { commit }
- describe '#id' do
+ describe "#id" do
subject { super().id }
it { is_expected.to eq(sample_commit_hash[:id])}
end
- describe '#message' do
+ describe "#message" do
subject { super().message }
it { is_expected.to eq(sample_commit_hash[:message])}
end
end
- describe '#stats' do
+ describe "#stats" do
subject { commit.stats }
- describe '#additions' do
+ describe "#additions" do
subject { super().additions }
it { is_expected.to eq(11) }
end
- describe '#deletions' do
+ describe "#deletions" do
subject { super().deletions }
it { is_expected.to eq(6) }
end
- describe '#total' do
+ describe "#total" do
subject { super().total }
it { is_expected.to eq(17) }
end
end
- describe '#has_zero_stats?' do
+ describe "#has_zero_stats?" do
it { expect(commit.has_zero_stats?).to eq(false) }
end
- describe '#to_hash' do
+ describe "#to_hash" do
let(:hash) { commit.to_hash }
subject { hash }
it { is_expected.to be_kind_of Hash }
- describe '#keys' do
+ describe "#keys" do
subject { super().keys.sort }
it { is_expected.to match(sample_commit_hash.keys.sort) }
end
end
- describe '#diffs' do
+ describe "#diffs" do
subject { commit.diffs }
it { is_expected.to be_kind_of Gitlab::Git::DiffCollection }
@@ -547,32 +547,32 @@ describe Gitlab::Git::Commit, :seed_helper do
it { expect(subject.first).to be_kind_of Gitlab::Git::Diff }
end
- describe '#ref_names' do
- let(:commit) { described_class.find(repository, 'master') }
+ describe "#ref_names" do
+ let(:commit) { described_class.find(repository, "master") }
subject { commit.ref_names(repository) }
- it 'has 2 element' do
+ it "has 2 element" do
expect(subject.size).to eq(2)
end
it { is_expected.to include("master") }
it { is_expected.not_to include("feature") }
end
- describe '.get_message' do
+ describe ".get_message" do
let(:commit_ids) { %w[6d394385cf567f80a8fd85055db1ab4c5295806f cfe32cf61b73a0d5e9f13e774abde7ff789b1660] }
subject do
commit_ids.map { |id| described_class.get_message(repository, id) }
end
- it 'gets commit messages' do
+ it "gets commit messages" do
expect(subject).to contain_exactly(
"Added contributing guide\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n",
"Add submodule\n\nSigned-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>\n"
)
end
- it 'gets messages in one batch', :request_store do
+ it "gets messages in one batch", :request_store do
expect { subject.map(&:itself) }.to change { Gitlab::GitalyClient.get_request_count }.by(1)
end
end
@@ -587,7 +587,7 @@ describe Gitlab::Git::Commit, :seed_helper do
committer_name: "Dmitriy Zaporozhets",
id: SeedRepo::Commit::ID,
message: "tree css fixes",
- parent_ids: ["874797c3a73b60d2187ed6e2fcabd289ff75171e"]
+ parent_ids: ["874797c3a73b60d2187ed6e2fcabd289ff75171e"],
}
end
end
diff --git a/spec/lib/gitlab/git/compare_spec.rb b/spec/lib/gitlab/git/compare_spec.rb
index 65dfb93d0db..1f4a55407c1 100644
--- a/spec/lib/gitlab/git/compare_spec.rb
+++ b/spec/lib/gitlab/git/compare_spec.rb
@@ -1,92 +1,92 @@
require "spec_helper"
describe Gitlab::Git::Compare, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: false) }
let(:compare_straight) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::Commit::ID, straight: true) }
- describe '#commits' do
+ describe "#commits" do
subject do
compare.commits.map(&:id)
end
- it 'has 8 elements' do
+ it "has 8 elements" do
expect(subject.size).to eq(8)
end
it { is_expected.to include(SeedRepo::Commit::PARENT_ID) }
it { is_expected.not_to include(SeedRepo::BigCommit::PARENT_ID) }
- context 'non-existing base ref' do
- let(:compare) { Gitlab::Git::Compare.new(repository, 'no-such-branch', SeedRepo::Commit::ID) }
+ context "non-existing base ref" do
+ let(:compare) { Gitlab::Git::Compare.new(repository, "no-such-branch", SeedRepo::Commit::ID) }
it { is_expected.to be_empty }
end
- context 'non-existing head ref' do
- let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, '1234567890') }
+ context "non-existing head ref" do
+ let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, "1234567890") }
it { is_expected.to be_empty }
end
- context 'base ref is equal to head ref' do
+ context "base ref is equal to head ref" do
let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) }
it { is_expected.to be_empty }
end
- context 'providing nil as base ref or head ref' do
+ context "providing nil as base ref or head ref" do
let(:compare) { Gitlab::Git::Compare.new(repository, nil, nil) }
it { is_expected.to be_empty }
end
end
- describe '#diffs' do
+ describe "#diffs" do
subject do
compare.diffs.map(&:new_path)
end
- it 'has 10 elements' do
+ it "has 10 elements" do
expect(subject.size).to eq(10)
end
- it { is_expected.to include('files/ruby/popen.rb') }
- it { is_expected.not_to include('LICENSE') }
+ it { is_expected.to include("files/ruby/popen.rb") }
+ it { is_expected.not_to include("LICENSE") }
- context 'non-existing base ref' do
- let(:compare) { Gitlab::Git::Compare.new(repository, 'no-such-branch', SeedRepo::Commit::ID) }
+ context "non-existing base ref" do
+ let(:compare) { Gitlab::Git::Compare.new(repository, "no-such-branch", SeedRepo::Commit::ID) }
it { is_expected.to be_empty }
end
- context 'non-existing head ref' do
- let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, '1234567890') }
+ context "non-existing head ref" do
+ let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, "1234567890") }
it { is_expected.to be_empty }
end
end
- describe '#same' do
+ describe "#same" do
subject do
compare.same
end
it { is_expected.to eq(false) }
- context 'base ref is equal to head ref' do
+ context "base ref is equal to head ref" do
let(:compare) { Gitlab::Git::Compare.new(repository, SeedRepo::BigCommit::ID, SeedRepo::BigCommit::ID) }
it { is_expected.to eq(true) }
end
end
- describe '#commits', 'straight compare' do
+ describe "#commits", "straight compare" do
subject do
compare_straight.commits.map(&:id)
end
- it 'has 8 elements' do
+ it "has 8 elements" do
expect(subject.size).to eq(8)
end
@@ -94,16 +94,16 @@ describe Gitlab::Git::Compare, :seed_helper do
it { is_expected.not_to include(SeedRepo::BigCommit::PARENT_ID) }
end
- describe '#diffs', 'straight compare' do
+ describe "#diffs", "straight compare" do
subject do
compare_straight.diffs.map(&:new_path)
end
- it 'has 10 elements' do
+ it "has 10 elements" do
expect(subject.size).to eq(10)
end
- it { is_expected.to include('files/ruby/popen.rb') }
- it { is_expected.not_to include('LICENSE') }
+ it { is_expected.to include("files/ruby/popen.rb") }
+ it { is_expected.not_to include("LICENSE") }
end
end
diff --git a/spec/lib/gitlab/git/conflict/file_spec.rb b/spec/lib/gitlab/git/conflict/file_spec.rb
index afed6c32af6..974f45f7db2 100644
--- a/spec/lib/gitlab/git/conflict/file_spec.rb
+++ b/spec/lib/gitlab/git/conflict/file_spec.rb
@@ -1,47 +1,46 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::Conflict::File do
- let(:conflict) { { theirs: { path: 'foo', mode: 33188 }, ours: { path: 'foo', mode: 33188 } } }
+ let(:conflict) { {theirs: {path: "foo", mode: 33188}, ours: {path: "foo", mode: 33188}} }
let(:invalid_content) { described_class.new(nil, nil, conflict, "a\xC4\xFC".force_encoding(Encoding::ASCII_8BIT)) }
let(:valid_content) { described_class.new(nil, nil, conflict, "Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) }
- describe '#lines' do
- context 'when the content contains non-UTF-8 characters' do
- it 'raises UnsupportedEncoding' do
+ describe "#lines" do
+ context "when the content contains non-UTF-8 characters" do
+ it "raises UnsupportedEncoding" do
expect { invalid_content.lines }
.to raise_error(described_class::UnsupportedEncoding)
end
end
- context 'when the content can be converted to UTF-8' do
- it 'sets lines to the lines' do
+ context "when the content can be converted to UTF-8" do
+ it "sets lines to the lines" do
expect(valid_content.lines).to eq([{
- full_line: 'España',
- type: nil,
- line_obj_index: 0,
- line_old: 1,
- line_new: 1
- }])
+ full_line: "España",
+ type: nil,
+ line_obj_index: 0,
+ line_old: 1,
+ line_new: 1,
+ }])
end
- it 'sets the type to text' do
- expect(valid_content.type).to eq('text')
+ it "sets the type to text" do
+ expect(valid_content.type).to eq("text")
end
end
end
- describe '#content' do
- context 'when the content contains non-UTF-8 characters' do
- it 'raises UnsupportedEncoding' do
+ describe "#content" do
+ context "when the content contains non-UTF-8 characters" do
+ it "raises UnsupportedEncoding" do
expect { invalid_content.content }
.to raise_error(described_class::UnsupportedEncoding)
end
end
- context 'when the content can be converted to UTF-8' do
- it 'returns a valid UTF-8 string' do
- expect(valid_content.content).to eq('España')
+ context "when the content can be converted to UTF-8" do
+ it "returns a valid UTF-8 string" do
+ expect(valid_content.content).to eq("España")
expect(valid_content.content).to be_valid_encoding
expect(valid_content.content.encoding).to eq(Encoding::UTF_8)
end
diff --git a/spec/lib/gitlab/git/conflict/parser_spec.rb b/spec/lib/gitlab/git/conflict/parser_spec.rb
index 29a1702a1c6..c185afab79d 100644
--- a/spec/lib/gitlab/git/conflict/parser_spec.rb
+++ b/spec/lib/gitlab/git/conflict/parser_spec.rb
@@ -1,213 +1,213 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::Conflict::Parser do
- describe '.parse' do
+ describe ".parse" do
def parse_text(text)
- described_class.parse(text, our_path: 'README.md', their_path: 'README.md')
+ described_class.parse(text, our_path: "README.md", their_path: "README.md")
end
- context 'when the file has valid conflicts' do
+ context "when the file has valid conflicts" do
let(:text) do
- <<CONFLICT
-module Gitlab
- module Regexp
- extend self
-
- def username_regexp
- default_regexp
- end
-
-<<<<<<< files/ruby/regex.rb
- def project_name_regexp
- /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/
- end
-
- def name_regexp
- /\A[a-zA-Z0-9_\-\. ]*\z/
-=======
- def project_name_regex
- %r{\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z}
- end
-
- def name_regex
- %r{\A[a-zA-Z0-9_\-\. ]*\z}
->>>>>>> files/ruby/regex.rb
- end
-
- def path_regexp
- default_regexp
- end
-
-<<<<<<< files/ruby/regex.rb
- def archive_formats_regexp
- /(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
-=======
- def archive_formats_regex
- %r{(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)}
->>>>>>> files/ruby/regex.rb
- end
-
- def git_reference_regexp
- # Valid git ref regexp, see:
- # https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
- %r{
- (?!
- (?# doesn't begins with)
- \/| (?# rule #6)
- (?# doesn't contain)
- .*(?:
- [\/.]\.| (?# rule #1,3)
- \/\/| (?# rule #6)
- @\{| (?# rule #8)
- \\ (?# rule #9)
- )
- )
- [^\000-\040\177~^:?*\[]+ (?# rule #4-5)
- (?# doesn't end with)
- (?<!\.lock) (?# rule #1)
- (?<![\/.]) (?# rule #6-7)
- }x
- end
-
- protected
-
-<<<<<<< files/ruby/regex.rb
- def default_regexp
- /\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
-=======
- def default_regex
- %r{\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z}
->>>>>>> files/ruby/regex.rb
- end
- end
-end
-CONFLICT
+ <<~CONFLICT
+ module Gitlab
+ module Regexp
+ extend self
+
+ def username_regexp
+ default_regexp
+ end
+
+ <<<<<<< files/ruby/regex.rb
+ def project_name_regexp
+ /\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z/
+ end
+
+ def name_regexp
+ /\A[a-zA-Z0-9_\-\. ]*\z/
+ =======
+ def project_name_regex
+ %r{\A[a-zA-Z0-9][a-zA-Z0-9_\-\. ]*\z}
+ end
+
+ def name_regex
+ %r{\A[a-zA-Z0-9_\-\. ]*\z}
+ >>>>>>> files/ruby/regex.rb
+ end
+
+ def path_regexp
+ default_regexp
+ end
+
+ <<<<<<< files/ruby/regex.rb
+ def archive_formats_regexp
+ /(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)/
+ =======
+ def archive_formats_regex
+ %r{(zip|tar|7z|tar\.gz|tgz|gz|tar\.bz2|tbz|tbz2|tb2|bz2)}
+ >>>>>>> files/ruby/regex.rb
+ end
+
+ def git_reference_regexp
+ # Valid git ref regexp, see:
+ # https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html
+ %r{
+ (?!
+ (?# doesn't begins with)
+ \/| (?# rule #6)
+ (?# doesn't contain)
+ .*(?:
+ [\/.]\.| (?# rule #1,3)
+ \/\/| (?# rule #6)
+ @\{| (?# rule #8)
+ \\ (?# rule #9)
+ )
+ )
+ [^\000-\040\177~^:?*\[]+ (?# rule #4-5)
+ (?# doesn't end with)
+ (?<!\.lock) (?# rule #1)
+ (?<![\/.]) (?# rule #6-7)
+ }x
+ end
+
+ protected
+
+ <<<<<<< files/ruby/regex.rb
+ def default_regexp
+ /\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z/
+ =======
+ def default_regex
+ %r{\A[.?]?[a-zA-Z0-9][a-zA-Z0-9_\-\.]*(?<!\.git)\z}
+ >>>>>>> files/ruby/regex.rb
+ end
+ end
+ end
+ CONFLICT
end
let(:lines) do
- described_class.parse(text, our_path: 'files/ruby/regex.rb', their_path: 'files/ruby/regex.rb')
+ described_class.parse(text, our_path: "files/ruby/regex.rb", their_path: "files/ruby/regex.rb")
end
let(:old_line_numbers) do
- lines.select { |line| line[:type] != 'new' }.map { |line| line[:line_old] }
+ lines.select { |line| line[:type] != "new" }.map { |line| line[:line_old] }
end
let(:new_line_numbers) do
- lines.select { |line| line[:type] != 'old' }.map { |line| line[:line_new] }
+ lines.select { |line| line[:type] != "old" }.map { |line| line[:line_new] }
end
let(:line_indexes) { lines.map { |line| line[:line_obj_index] } }
- it 'sets our lines as new lines' do
- expect(lines[8..13]).to all(include(type: 'new'))
- expect(lines[26..27]).to all(include(type: 'new'))
- expect(lines[56..57]).to all(include(type: 'new'))
+ it "sets our lines as new lines" do
+ expect(lines[8..13]).to all(include(type: "new"))
+ expect(lines[26..27]).to all(include(type: "new"))
+ expect(lines[56..57]).to all(include(type: "new"))
end
- it 'sets their lines as old lines' do
- expect(lines[14..19]).to all(include(type: 'old'))
- expect(lines[28..29]).to all(include(type: 'old'))
- expect(lines[58..59]).to all(include(type: 'old'))
+ it "sets their lines as old lines" do
+ expect(lines[14..19]).to all(include(type: "old"))
+ expect(lines[28..29]).to all(include(type: "old"))
+ expect(lines[58..59]).to all(include(type: "old"))
end
- it 'sets non-conflicted lines as both' do
+ it "sets non-conflicted lines as both" do
expect(lines[0..7]).to all(include(type: nil))
expect(lines[20..25]).to all(include(type: nil))
expect(lines[30..55]).to all(include(type: nil))
expect(lines[60..62]).to all(include(type: nil))
end
- it 'sets consecutive line numbers for line_obj_index, line_old, and line_new' do
+ it "sets consecutive line numbers for line_obj_index, line_old, and line_new" do
expect(line_indexes).to eq(0.upto(62).to_a)
expect(old_line_numbers).to eq(1.upto(53).to_a)
expect(new_line_numbers).to eq(1.upto(53).to_a)
end
end
- context 'when the file contents include conflict delimiters' do
- context 'when there is a non-start delimiter first' do
- it 'raises UnexpectedDelimiter when there is a middle delimiter first' do
- expect { parse_text('=======') }
+ context "when the file contents include conflict delimiters" do
+ context "when there is a non-start delimiter first" do
+ it "raises UnexpectedDelimiter when there is a middle delimiter first" do
+ expect { parse_text("=======") }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'raises UnexpectedDelimiter when there is an end delimiter first' do
- expect { parse_text('>>>>>>> README.md') }
+ it "raises UnexpectedDelimiter when there is an end delimiter first" do
+ expect { parse_text(">>>>>>> README.md") }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'does not raise when there is an end delimiter for a different path first' do
- expect { parse_text('>>>>>>> some-other-path.md') }
+ it "does not raise when there is an end delimiter for a different path first" do
+ expect { parse_text(">>>>>>> some-other-path.md") }
.not_to raise_error
end
end
- context 'when a start delimiter is followed by a non-middle delimiter' do
+ context "when a start delimiter is followed by a non-middle delimiter" do
let(:start_text) { "<<<<<<< README.md\n" }
let(:end_text) { "\n=======\n>>>>>>> README.md" }
- it 'raises UnexpectedDelimiter when it is followed by an end delimiter' do
- expect { parse_text(start_text + '>>>>>>> README.md' + end_text) }
+ it "raises UnexpectedDelimiter when it is followed by an end delimiter" do
+ expect { parse_text(start_text + ">>>>>>> README.md" + end_text) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'raises UnexpectedDelimiter when it is followed by another start delimiter' do
+ it "raises UnexpectedDelimiter when it is followed by another start delimiter" do
expect { parse_text(start_text + start_text + end_text) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'does not raise when it is followed by a start delimiter for a different path' do
- expect { parse_text(start_text + '>>>>>>> some-other-path.md' + end_text) }
+ it "does not raise when it is followed by a start delimiter for a different path" do
+ expect { parse_text(start_text + ">>>>>>> some-other-path.md" + end_text) }
.not_to raise_error
end
end
- context 'when a middle delimiter is followed by a non-end delimiter' do
+ context "when a middle delimiter is followed by a non-end delimiter" do
let(:start_text) { "<<<<<<< README.md\n=======\n" }
let(:end_text) { "\n>>>>>>> README.md" }
- it 'raises UnexpectedDelimiter when it is followed by another middle delimiter' do
- expect { parse_text(start_text + '=======' + end_text) }
+ it "raises UnexpectedDelimiter when it is followed by another middle delimiter" do
+ expect { parse_text(start_text + "=======" + end_text) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'raises UnexpectedDelimiter when it is followed by a start delimiter' do
+ it "raises UnexpectedDelimiter when it is followed by a start delimiter" do
expect { parse_text(start_text + start_text + end_text) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnexpectedDelimiter)
end
- it 'does not raise when it is followed by a start delimiter for another path' do
- expect { parse_text(start_text + '<<<<<<< some-other-path.md' + end_text) }
+ it "does not raise when it is followed by a start delimiter for another path" do
+ expect { parse_text(start_text + "<<<<<<< some-other-path.md" + end_text) }
.not_to raise_error
end
end
- it 'raises MissingEndDelimiter when there is no end delimiter at the end' do
+ it "raises MissingEndDelimiter when there is no end delimiter at the end" do
start_text = "<<<<<<< README.md\n=======\n"
expect { parse_text(start_text) }
.to raise_error(Gitlab::Git::Conflict::Parser::MissingEndDelimiter)
- expect { parse_text(start_text + '>>>>>>> some-other-path.md') }
+ expect { parse_text(start_text + ">>>>>>> some-other-path.md") }
.to raise_error(Gitlab::Git::Conflict::Parser::MissingEndDelimiter)
end
end
- context 'other file types' do
- it 'raises UnmergeableFile when lines is blank, indicating a binary file' do
- expect { parse_text('') }
+ context "other file types" do
+ it "raises UnmergeableFile when lines is blank, indicating a binary file" do
+ expect { parse_text("") }
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
expect { parse_text(nil) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
end
- it 'raises UnmergeableFile when the file is over 200 KB' do
- expect { parse_text('a' * 204801) }
+ it "raises UnmergeableFile when the file is over 200 KB" do
+ expect { parse_text("a" * 204801) }
.to raise_error(Gitlab::Git::Conflict::Parser::UnmergeableFile)
end
# All text from Rugged has an encoding of ASCII_8BIT, so force that in
# these strings.
- context 'when the file contains UTF-8 characters' do
- it 'does not raise' do
+ context "when the file contains UTF-8 characters" do
+ it "does not raise" do
expect { parse_text("Espa\xC3\xB1a".force_encoding(Encoding::ASCII_8BIT)) }
.not_to raise_error
end
diff --git a/spec/lib/gitlab/git/diff_collection_spec.rb b/spec/lib/gitlab/git/diff_collection_spec.rb
index 81658874be7..78877a796af 100644
--- a/spec/lib/gitlab/git/diff_collection_spec.rb
+++ b/spec/lib/gitlab/git/diff_collection_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::DiffCollection, :seed_helper do
subject do
@@ -19,22 +19,22 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
let(:limits) { true }
let(:expanded) { true }
- describe '#to_a' do
+ describe "#to_a" do
subject { super().to_a }
it { is_expected.to be_kind_of ::Array }
end
- describe '#decorate!' do
+ describe "#decorate!" do
let(:file_count) { 3 }
- it 'modifies the array in place' do
+ it "modifies the array in place" do
count = 0
subject.decorate! { |d| !d.nil? && count += 1 }
expect(subject.to_a).to eq([1, 2, 3])
expect(count).to eq(3)
end
- it 'avoids future iterator iterations' do
+ it "avoids future iterator iterations" do
subject.decorate! { |d| d unless d.nil? }
expect(iterator).not_to receive(:each)
@@ -43,59 +43,59 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
end
end
- context 'overflow handling' do
- context 'adding few enough files' do
+ context "overflow handling" do
+ context "adding few enough files" do
let(:file_count) { 3 }
- context 'and few enough lines' do
+ context "and few enough lines" do
let(:line_count) { 10 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('3') }
+ it { is_expected.to eq("3") }
end
- describe '#size' do
+ describe "#size" do
it { expect(subject.size).to eq(3) }
- it 'does not change after peeking' do
+ it "does not change after peeking" do
subject.any?
expect(subject.size).to eq(3)
end
end
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('3') }
+ it { is_expected.to eq("3") }
end
- describe '#size' do
+ describe "#size" do
it { expect(subject.size).to eq(3) }
- it 'does not change after peeking' do
+ it "does not change after peeking" do
subject.any?
expect(subject.size).to eq(3)
end
@@ -103,375 +103,375 @@ describe Gitlab::Git::DiffCollection, :seed_helper do
end
end
- context 'and too many lines' do
+ context "and too many lines" do
let(:line_count) { 1000 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('0+') }
+ it { is_expected.to eq("0+") }
end
it { expect(subject.size).to eq(0) }
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('3') }
+ it { is_expected.to eq("3") }
end
it { expect(subject.size).to eq(3) }
end
end
end
- context 'adding too many files' do
+ context "adding too many files" do
let(:file_count) { 11 }
- context 'and few enough lines' do
+ context "and few enough lines" do
let(:line_count) { 1 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('10+') }
+ it { is_expected.to eq("10+") }
end
it { expect(subject.size).to eq(10) }
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('11') }
+ it { is_expected.to eq("11") }
end
it { expect(subject.size).to eq(11) }
end
end
- context 'and too many lines' do
+ context "and too many lines" do
let(:line_count) { 30 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('3+') }
+ it { is_expected.to eq("3+") }
end
it { expect(subject.size).to eq(3) }
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('11') }
+ it { is_expected.to eq("11") }
end
it { expect(subject.size).to eq(11) }
end
end
end
- context 'adding exactly the maximum number of files' do
+ context "adding exactly the maximum number of files" do
let(:file_count) { 10 }
- context 'and few enough lines' do
+ context "and few enough lines" do
let(:line_count) { 1 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('10') }
+ it { is_expected.to eq("10") }
end
it { expect(subject.size).to eq(10) }
end
end
- context 'adding too many bytes' do
+ context "adding too many bytes" do
let(:file_count) { 10 }
let(:line_length) { 5200 }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_truthy }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('9+') }
+ it { is_expected.to eq("9+") }
end
it { expect(subject.size).to eq(9) }
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('10') }
+ it { is_expected.to eq("10") }
end
it { expect(subject.size).to eq(10) }
end
end
end
- describe 'empty collection' do
+ describe "empty collection" do
subject { Gitlab::Git::DiffCollection.new([]) }
- describe '#overflow?' do
+ describe "#overflow?" do
subject { super().overflow? }
it { is_expected.to be_falsey }
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_truthy }
end
- describe '#size' do
+ describe "#size" do
subject { super().size }
it { is_expected.to eq(0) }
end
- describe '#real_size' do
+ describe "#real_size" do
subject { super().real_size }
- it { is_expected.to eq('0')}
+ it { is_expected.to eq("0")}
end
end
- describe '#each' do
- context 'when diff are too large' do
+ describe "#each" do
+ context "when diff are too large" do
let(:collection) do
- Gitlab::Git::DiffCollection.new([{ diff: 'a' * 204800 }])
+ Gitlab::Git::DiffCollection.new([{diff: "a" * 204800}])
end
- it 'yields Diff instances even when they are too large' do
+ it "yields Diff instances even when they are too large" do
expect { |b| collection.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
end
- it 'prunes diffs that are too large' do
+ it "prunes diffs that are too large" do
diff = nil
collection.each do |d|
diff = d
end
- expect(diff.diff).to eq('')
+ expect(diff.diff).to eq("")
end
end
- context 'when diff is quite large will collapse by default' do
- let(:iterator) { [{ diff: 'a' * 20480 }] }
+ context "when diff is quite large will collapse by default" do
+ let(:iterator) { [{diff: "a" * 20480}] }
- context 'when no collapse is set' do
+ context "when no collapse is set" do
let(:expanded) { true }
- it 'yields Diff instances even when they are quite big' do
+ it "yields Diff instances even when they are quite big" do
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
end
- it 'does not prune diffs' do
+ it "does not prune diffs" do
diff = nil
subject.each do |d|
diff = d
end
- expect(diff.diff).not_to eq('')
+ expect(diff.diff).not_to eq("")
end
end
- context 'when no collapse is unset' do
+ context "when no collapse is unset" do
let(:expanded) { false }
- it 'yields Diff instances even when they are quite big' do
+ it "yields Diff instances even when they are quite big" do
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
end
- it 'prunes diffs that are quite big' do
+ it "prunes diffs that are quite big" do
diff = nil
subject.each do |d|
diff = d
end
- expect(diff.diff).to eq('')
+ expect(diff.diff).to eq("")
end
- context 'when go over safe limits on files' do
+ context "when go over safe limits on files" do
let(:iterator) { [fake_diff(1, 1)] * 4 }
before do
- stub_const('Gitlab::Git::DiffCollection::DEFAULT_LIMITS', { max_files: 2, max_lines: max_lines })
+ stub_const("Gitlab::Git::DiffCollection::DEFAULT_LIMITS", {max_files: 2, max_lines: max_lines})
end
- it 'prunes diffs by default even little ones' do
+ it "prunes diffs by default even little ones" do
subject.each_with_index do |d, i|
if i < 2
- expect(d.diff).not_to eq('')
+ expect(d.diff).not_to eq("")
else # 90 lines
- expect(d.diff).to eq('')
+ expect(d.diff).to eq("")
end
end
end
end
- context 'when go over safe limits on lines' do
+ context "when go over safe limits on lines" do
let(:iterator) do
[
fake_diff(1, 45),
fake_diff(1, 45),
fake_diff(1, 20480),
- fake_diff(1, 1)
+ fake_diff(1, 1),
]
end
before do
- stub_const('Gitlab::Git::DiffCollection::DEFAULT_LIMITS', { max_files: max_files, max_lines: 80 })
+ stub_const("Gitlab::Git::DiffCollection::DEFAULT_LIMITS", {max_files: max_files, max_lines: 80})
end
- it 'prunes diffs by default even little ones' do
+ it "prunes diffs by default even little ones" do
subject.each_with_index do |d, i|
if i < 2
- expect(d.diff).not_to eq('')
+ expect(d.diff).not_to eq("")
else # 90 lines
- expect(d.diff).to eq('')
+ expect(d.diff).to eq("")
end
end
end
end
- context 'when go over safe limits on bytes' do
+ context "when go over safe limits on bytes" do
let(:iterator) do
[
fake_diff(1, 45),
fake_diff(1, 45),
fake_diff(1, 20480),
- fake_diff(1, 1)
+ fake_diff(1, 1),
]
end
before do
- stub_const('Gitlab::Git::DiffCollection::DEFAULT_LIMITS', { max_files: max_files, max_lines: 80 })
+ stub_const("Gitlab::Git::DiffCollection::DEFAULT_LIMITS", {max_files: max_files, max_lines: 80})
end
- it 'prunes diffs by default even little ones' do
+ it "prunes diffs by default even little ones" do
subject.each_with_index do |d, i|
if i < 2
- expect(d.diff).not_to eq('')
+ expect(d.diff).not_to eq("")
else # > 80 bytes
- expect(d.diff).to eq('')
+ expect(d.diff).to eq("")
end
end
end
end
end
- context 'when limiting is disabled' do
+ context "when limiting is disabled" do
let(:limits) { false }
- it 'yields Diff instances even when they are quite big' do
+ it "yields Diff instances even when they are quite big" do
expect { |b| subject.each(&b) }
.to yield_with_args(an_instance_of(Gitlab::Git::Diff))
end
- it 'does not prune diffs' do
+ it "does not prune diffs" do
diff = nil
subject.each do |d|
diff = d
end
- expect(diff.diff).not_to eq('')
+ expect(diff.diff).not_to eq("")
end
end
end
end
def fake_diff(line_length, line_count)
- { 'diff' => "#{'a' * line_length}\n" * line_count }
+ {"diff" => "#{"a" * line_length}\n" * line_count}
end
class MutatingConstantIterator
diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb
index 1d22329b670..c016492a7ae 100644
--- a/spec/lib/gitlab/git/diff_spec.rb
+++ b/spec/lib/gitlab/git/diff_spec.rb
@@ -1,15 +1,15 @@
require "spec_helper"
describe Gitlab::Git::Diff, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:gitaly_diff) do
Gitlab::GitalyClient::Diff.new(
- from_path: '.gitmodules',
- to_path: '.gitmodules',
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '0792c58905eff3432b721f8c4a64363d8e28d9ae',
- to_id: 'efd587ccb47caf5f31fc954edb21f0a713d9ecc3',
+ from_path: ".gitmodules",
+ to_path: ".gitmodules",
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "0792c58905eff3432b721f8c4a64363d8e28d9ae",
+ to_id: "efd587ccb47caf5f31fc954edb21f0a713d9ecc3",
overflow_marker: false,
collapsed: false,
too_large: false,
@@ -31,32 +31,32 @@ describe Gitlab::Git::Diff, :seed_helper do
EOT
new_path: ".gitmodules",
old_path: ".gitmodules",
- a_mode: '100644',
- b_mode: '100644',
+ a_mode: "100644",
+ b_mode: "100644",
new_file: false,
renamed_file: false,
deleted_file: false,
- too_large: false
+ too_large: false,
}
end
- describe '.new' do
- context 'using a Hash' do
- context 'with a small diff' do
+ describe ".new" do
+ context "using a Hash" do
+ context "with a small diff" do
let(:diff) { described_class.new(@raw_diff_hash) }
- it 'initializes the diff' do
+ it "initializes the diff" do
expect(diff.to_hash).to eq(@raw_diff_hash)
end
- it 'does not prune the diff' do
+ it "does not prune the diff" do
expect(diff).not_to be_too_large
end
end
- context 'using a diff that is too large' do
- it 'prunes the diff' do
- diff = described_class.new(diff: 'a' * 204800)
+ context "using a diff that is too large" do
+ it "prunes the diff" do
+ diff = described_class.new(diff: "a" * 204800)
expect(diff.diff).to be_empty
expect(diff).to be_too_large
@@ -64,45 +64,45 @@ EOT
end
end
- context 'using a GitalyClient::Diff' do
+ context "using a GitalyClient::Diff" do
let(:gitaly_diff) do
Gitlab::GitalyClient::Diff.new(
to_path: ".gitmodules",
from_path: ".gitmodules",
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '357406f3075a57708d0163752905cc1576fceacc',
- to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0',
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "357406f3075a57708d0163752905cc1576fceacc",
+ to_id: "8e5177d718c561d36efde08bad36b43687ee6bf0",
patch: raw_patch
)
end
let(:diff) { described_class.new(gitaly_diff) }
- context 'with a small diff' do
+ context "with a small diff" do
let(:raw_patch) { @raw_diff_hash[:diff] }
- it 'initializes the diff' do
+ it "initializes the diff" do
expect(diff.to_hash).to eq(@raw_diff_hash)
end
- it 'does not prune the diff' do
+ it "does not prune the diff" do
expect(diff).not_to be_too_large
end
end
- context 'using a diff that is too large' do
- let(:raw_patch) { 'a' * 204800 }
+ context "using a diff that is too large" do
+ let(:raw_patch) { "a" * 204800 }
- it 'prunes the diff' do
+ it "prunes the diff" do
expect(diff.diff).to be_empty
expect(diff).to be_too_large
end
end
- context 'using a collapsable diff that is too large' do
- let(:raw_patch) { 'a' * 204800 }
+ context "using a collapsable diff that is too large" do
+ let(:raw_patch) { "a" * 204800 }
- it 'prunes the diff as a large diff instead of as a collapsed diff' do
+ it "prunes the diff as a large diff instead of as a collapsed diff" do
gitaly_diff.too_large = true
diff = described_class.new(gitaly_diff, expanded: false)
@@ -112,72 +112,72 @@ EOT
end
end
- context 'when the patch passed is not UTF-8-encoded' do
+ context "when the patch passed is not UTF-8-encoded" do
let(:raw_patch) { @raw_diff_hash[:diff].encode(Encoding::ASCII_8BIT) }
- it 'encodes diff patch to UTF-8' do
+ it "encodes diff patch to UTF-8" do
expect(diff.diff).to be_utf8
end
end
end
end
- describe 'straight diffs' do
- let(:options) { { straight: true } }
- let(:diffs) { described_class.between(repository, 'feature', 'master', options) }
+ describe "straight diffs" do
+ let(:options) { {straight: true} }
+ let(:diffs) { described_class.between(repository, "feature", "master", options) }
- it 'has the correct size' do
+ it "has the correct size" do
expect(diffs.size).to eq(24)
end
- context 'diff' do
- it 'is an instance of Diff' do
+ context "diff" do
+ it "is an instance of Diff" do
expect(diffs.first).to be_kind_of(described_class)
end
- it 'has the correct new_path' do
- expect(diffs.first.new_path).to eq('.DS_Store')
+ it "has the correct new_path" do
+ expect(diffs.first.new_path).to eq(".DS_Store")
end
- it 'has the correct diff' do
- expect(diffs.first.diff).to include('Binary files /dev/null and b/.DS_Store differ')
+ it "has the correct diff" do
+ expect(diffs.first.diff).to include("Binary files /dev/null and b/.DS_Store differ")
end
end
end
- describe '.between' do
- let(:diffs) { described_class.between(repository, 'feature', 'master') }
+ describe ".between" do
+ let(:diffs) { described_class.between(repository, "feature", "master") }
subject { diffs }
it { is_expected.to be_kind_of Gitlab::Git::DiffCollection }
- describe '#size' do
+ describe "#size" do
subject { super().size }
it { is_expected.to eq(1) }
end
- context 'diff' do
+ context "diff" do
subject { diffs.first }
it { is_expected.to be_kind_of described_class }
- describe '#new_path' do
+ describe "#new_path" do
subject { super().new_path }
- it { is_expected.to eq('files/ruby/feature.rb') }
+ it { is_expected.to eq("files/ruby/feature.rb") }
end
- describe '#diff' do
+ describe "#diff" do
subject { super().diff }
- it { is_expected.to include '+class Feature' }
+ it { is_expected.to include "+class Feature" }
end
end
end
- describe '.filter_diff_options' do
- let(:options) { { max_files: 100, invalid_opt: true } }
+ describe ".filter_diff_options" do
+ let(:options) { {max_files: 100, invalid_opt: true} }
context "without default options" do
let(:filtered_options) { described_class.filter_diff_options(options) }
@@ -189,7 +189,7 @@ EOT
context "with default options" do
let(:filtered_options) do
- default_options = { max_files: 5, bad_opt: 1, ignore_whitespace_change: true }
+ default_options = {max_files: 5, bad_opt: 1, ignore_whitespace_change: true}
described_class.filter_diff_options(options, default_options)
end
@@ -209,34 +209,34 @@ EOT
end
end
- describe '#json_safe_diff' do
+ describe "#json_safe_diff" do
let(:project) { create(:project, :repository) }
- it 'fake binary message when it detects binary' do
+ it "fake binary message when it detects binary" do
# Rugged will not detect this as binary, but we can fake it
diff_message = "Binary files files/images/icn-time-tracking.pdf and files/images/icn-time-tracking.pdf differ\n"
- binary_diff = described_class.between(project.repository, 'add-pdf-text-binary', 'add-pdf-text-binary^').first
+ binary_diff = described_class.between(project.repository, "add-pdf-text-binary", "add-pdf-text-binary^").first
expect(binary_diff.diff).not_to be_empty
expect(binary_diff.json_safe_diff).to eq(diff_message)
end
- it 'leave non-binary diffs as-is' do
+ it "leave non-binary diffs as-is" do
diff = described_class.new(gitaly_diff)
expect(diff.json_safe_diff).to eq(diff.diff)
end
end
- describe '#submodule?' do
+ describe "#submodule?" do
let(:gitaly_submodule_diff) do
Gitlab::GitalyClient::Diff.new(
- from_path: 'gitlab-grack',
- to_path: 'gitlab-grack',
+ from_path: "gitlab-grack",
+ to_path: "gitlab-grack",
old_mode: 0,
new_mode: 57344,
- from_id: '0000000000000000000000000000000000000000',
- to_id: '645f6c4c82fd3f5e06f67134450a570b795e55a6',
+ from_id: "0000000000000000000000000000000000000000",
+ to_id: "645f6c4c82fd3f5e06f67134450a570b795e55a6",
overflow_marker: false,
collapsed: false,
too_large: false,
@@ -248,29 +248,29 @@ EOT
it { expect(described_class.new(gitaly_submodule_diff).submodule?).to eq(true) }
end
- describe '#line_count' do
- it 'returns the correct number of lines' do
+ describe "#line_count" do
+ it "returns the correct number of lines" do
diff = described_class.new(gitaly_diff)
expect(diff.line_count).to eq(7)
end
end
- describe '#too_large?' do
- it 'returns true for a diff that is too large' do
- diff = described_class.new(diff: 'a' * 204800)
+ describe "#too_large?" do
+ it "returns true for a diff that is too large" do
+ diff = described_class.new(diff: "a" * 204800)
expect(diff.too_large?).to eq(true)
end
- it 'returns false for a diff that is small enough' do
- diff = described_class.new(diff: 'a')
+ it "returns false for a diff that is small enough" do
+ diff = described_class.new(diff: "a")
expect(diff.too_large?).to eq(false)
end
- it 'returns true for a diff that was explicitly marked as being too large' do
- diff = described_class.new(diff: 'a')
+ it "returns true for a diff that was explicitly marked as being too large" do
+ diff = described_class.new(diff: "a")
diff.too_large!
@@ -278,21 +278,21 @@ EOT
end
end
- describe '#collapsed?' do
- it 'returns false by default even on quite big diff' do
- diff = described_class.new(diff: 'a' * 20480)
+ describe "#collapsed?" do
+ it "returns false by default even on quite big diff" do
+ diff = described_class.new(diff: "a" * 20480)
expect(diff).not_to be_collapsed
end
- it 'returns false by default for a diff that is small enough' do
- diff = described_class.new(diff: 'a')
+ it "returns false by default for a diff that is small enough" do
+ diff = described_class.new(diff: "a")
expect(diff).not_to be_collapsed
end
- it 'returns true for a diff that was explicitly marked as being collapsed' do
- diff = described_class.new(diff: 'a')
+ it "returns true for a diff that was explicitly marked as being collapsed" do
+ diff = described_class.new(diff: "a")
diff.collapse!
@@ -300,27 +300,27 @@ EOT
end
end
- describe '#collapsed?' do
- it 'returns true for a diff that is quite large' do
- diff = described_class.new({ diff: 'a' * 20480 }, expanded: false)
+ describe "#collapsed?" do
+ it "returns true for a diff that is quite large" do
+ diff = described_class.new({diff: "a" * 20480}, expanded: false)
expect(diff).to be_collapsed
end
- it 'returns false for a diff that is small enough' do
- diff = described_class.new({ diff: 'a' }, expanded: false)
+ it "returns false for a diff that is small enough" do
+ diff = described_class.new({diff: "a"}, expanded: false)
expect(diff).not_to be_collapsed
end
end
- describe '#collapse!' do
- it 'prunes the diff' do
+ describe "#collapse!" do
+ it "prunes the diff" do
diff = described_class.new(diff: "foo\nbar")
diff.collapse!
- expect(diff.diff).to eq('')
+ expect(diff.diff).to eq("")
expect(diff.line_count).to eq(0)
end
end
diff --git a/spec/lib/gitlab/git/diff_stats_collection_spec.rb b/spec/lib/gitlab/git/diff_stats_collection_spec.rb
index b07690ef39c..7015763f09b 100644
--- a/spec/lib/gitlab/git/diff_stats_collection_spec.rb
+++ b/spec/lib/gitlab/git/diff_stats_collection_spec.rb
@@ -4,28 +4,28 @@ require "spec_helper"
describe Gitlab::Git::DiffStatsCollection do
let(:stats_a) do
- double(Gitaly::DiffStats, additions: 10, deletions: 15, path: 'foo')
+ double(Gitaly::DiffStats, additions: 10, deletions: 15, path: "foo")
end
let(:stats_b) do
- double(Gitaly::DiffStats, additions: 5, deletions: 1, path: 'bar')
+ double(Gitaly::DiffStats, additions: 5, deletions: 1, path: "bar")
end
let(:diff_stats) { [stats_a, stats_b] }
let(:collection) { described_class.new(diff_stats) }
- describe '#find_by_path' do
- it 'returns stats by path when found' do
- expect(collection.find_by_path('foo')).to eq(stats_a)
+ describe "#find_by_path" do
+ it "returns stats by path when found" do
+ expect(collection.find_by_path("foo")).to eq(stats_a)
end
- it 'returns nil when stats is not found by path' do
- expect(collection.find_by_path('no-file')).to be_nil
+ it "returns nil when stats is not found by path" do
+ expect(collection.find_by_path("no-file")).to be_nil
end
end
- describe '#paths' do
- it 'returns only modified paths' do
+ describe "#paths" do
+ it "returns only modified paths" do
expect(collection.paths).to eq %w[foo bar]
end
end
diff --git a/spec/lib/gitlab/git/gitmodules_parser_spec.rb b/spec/lib/gitlab/git/gitmodules_parser_spec.rb
index 6fd2b33486b..8c20368158f 100644
--- a/spec/lib/gitlab/git/gitmodules_parser_spec.rb
+++ b/spec/lib/gitlab/git/gitmodules_parser_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::GitmodulesParser do
- it 'should parse a .gitmodules file correctly' do
+ it "should parse a .gitmodules file correctly" do
data = <<~GITMODULES
[submodule "vendor/libgit2"]
path = vendor/libgit2
@@ -20,10 +20,10 @@ describe Gitlab::Git::GitmodulesParser do
modules = parser.parse
expect(modules).to eq({
- 'vendor/libgit2' => { 'name' => 'vendor/libgit2',
- 'url' => 'https://github.com/nodegit/libgit2.git' },
- 'new/path' => { 'name' => 'moved',
- 'url' => 'https://example.com/some/project' }
- })
+ "vendor/libgit2" => {"name" => "vendor/libgit2",
+ "url" => "https://github.com/nodegit/libgit2.git",},
+ "new/path" => {"name" => "moved",
+ "url" => "https://example.com/some/project",},
+ })
end
end
diff --git a/spec/lib/gitlab/git/hook_env_spec.rb b/spec/lib/gitlab/git/hook_env_spec.rb
index 5e49ea6da7a..eaa1e7f83a9 100644
--- a/spec/lib/gitlab/git/hook_env_spec.rb
+++ b/spec/lib/gitlab/git/hook_env_spec.rb
@@ -1,30 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::HookEnv do
- let(:gl_repository) { 'project-123' }
+ let(:gl_repository) { "project-123" }
describe ".set" do
- context 'with RequestStore disabled' do
- it 'does not store anything' do
- described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: 'foo')
+ context "with RequestStore disabled" do
+ it "does not store anything" do
+ described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: "foo")
expect(described_class.all(gl_repository)).to be_empty
end
end
- context 'with RequestStore enabled', :request_store do
- it 'whitelist some `GIT_*` variables and stores them using RequestStore' do
+ context "with RequestStore enabled", :request_store do
+ it "whitelist some `GIT_*` variables and stores them using RequestStore" do
described_class.set(
gl_repository,
- GIT_OBJECT_DIRECTORY_RELATIVE: 'foo',
- GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: 'bar',
- GIT_EXEC_PATH: 'baz',
- PATH: '~/.bin:/bin')
+ GIT_OBJECT_DIRECTORY_RELATIVE: "foo",
+ GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: "bar",
+ GIT_EXEC_PATH: "baz",
+ PATH: "~/.bin:/bin"
+ )
git_env = described_class.all(gl_repository)
- expect(git_env[:GIT_OBJECT_DIRECTORY_RELATIVE]).to eq('foo')
- expect(git_env[:GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE]).to eq('bar')
+ expect(git_env[:GIT_OBJECT_DIRECTORY_RELATIVE]).to eq("foo")
+ expect(git_env[:GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE]).to eq("bar")
expect(git_env[:GIT_EXEC_PATH]).to be_nil
expect(git_env[:PATH]).to be_nil
expect(git_env[:bar]).to be_nil
@@ -33,36 +34,37 @@ describe Gitlab::Git::HookEnv do
end
describe ".all" do
- context 'with RequestStore enabled', :request_store do
+ context "with RequestStore enabled", :request_store do
before do
described_class.set(
gl_repository,
- GIT_OBJECT_DIRECTORY_RELATIVE: 'foo',
- GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: ['bar'])
+ GIT_OBJECT_DIRECTORY_RELATIVE: "foo",
+ GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: ["bar"]
+ )
end
- it 'returns an env hash' do
+ it "returns an env hash" do
expect(described_class.all(gl_repository)).to eq({
- 'GIT_OBJECT_DIRECTORY_RELATIVE' => 'foo',
- 'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE' => ['bar']
+ "GIT_OBJECT_DIRECTORY_RELATIVE" => "foo",
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE" => ["bar"],
})
end
end
end
describe ".to_env_hash" do
- context 'with RequestStore enabled', :request_store do
+ context "with RequestStore enabled", :request_store do
using RSpec::Parameterized::TableSyntax
- let(:key) { 'GIT_OBJECT_DIRECTORY_RELATIVE' }
+ let(:key) { "GIT_OBJECT_DIRECTORY_RELATIVE" }
subject { described_class.to_env_hash(gl_repository) }
where(:input, :output) do
nil | nil
- 'foo' | 'foo'
- [] | ''
- ['foo'] | 'foo'
- %w[foo bar] | 'foo:bar'
+ "foo" | "foo"
+ [] | ""
+ ["foo"] | "foo"
+ %w[foo bar] | "foo:bar"
end
with_them do
@@ -70,39 +72,39 @@ describe Gitlab::Git::HookEnv do
described_class.set(gl_repository, key.to_sym => input)
end
- it 'puts the right value in the hash' do
+ it "puts the right value in the hash" do
if output
expect(subject.fetch(key)).to eq(output)
else
- expect(subject.has_key?(key)).to eq(false)
+ expect(subject.key?(key)).to eq(false)
end
end
end
end
end
- describe 'thread-safety' do
- context 'with RequestStore enabled', :request_store do
+ describe "thread-safety" do
+ context "with RequestStore enabled", :request_store do
before do
allow(RequestStore).to receive(:active?).and_return(true)
- described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: 'foo')
+ described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: "foo")
end
- it 'is thread-safe' do
- another_thread = Thread.new do
- described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: 'bar')
+ it "is thread-safe" do
+ another_thread = Thread.new {
+ described_class.set(gl_repository, GIT_OBJECT_DIRECTORY_RELATIVE: "bar")
Thread.stop
described_class.all(gl_repository)[:GIT_OBJECT_DIRECTORY_RELATIVE]
- end
+ }
# Ensure another_thread runs first
sleep 0.1 until another_thread.stop?
- expect(described_class.all(gl_repository)[:GIT_OBJECT_DIRECTORY_RELATIVE]).to eq('foo')
+ expect(described_class.all(gl_repository)[:GIT_OBJECT_DIRECTORY_RELATIVE]).to eq("foo")
another_thread.run
- expect(another_thread.value).to eq('bar')
+ expect(another_thread.value).to eq("bar")
end
end
end
diff --git a/spec/lib/gitlab/git/lfs_changes_spec.rb b/spec/lib/gitlab/git/lfs_changes_spec.rb
index d035df7e0c2..d62f0ec3bb2 100644
--- a/spec/lib/gitlab/git/lfs_changes_spec.rb
+++ b/spec/lib/gitlab/git/lfs_changes_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::LfsChanges do
set(:project) { create(:project, :repository) }
- let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
- let(:blob_object_id) { '0c304a93cb8430108629bbbcaa27db3343299bc0' }
+ let(:newrev) { "54fcc214b94e78d7a41a9a8fe6d87a5e59500e51" }
+ let(:blob_object_id) { "0c304a93cb8430108629bbbcaa27db3343299bc0" }
subject { described_class.new(project.repository, newrev) }
- describe '#new_pointers' do
- it 'filters new objects to find lfs pointers' do
+ describe "#new_pointers" do
+ it "filters new objects to find lfs pointers" do
expect(subject.new_pointers(not_in: []).first.id).to eq(blob_object_id)
end
- it 'limits new_objects using object_limit' do
+ it "limits new_objects using object_limit" do
expect(subject.new_pointers(object_limit: 1)).to eq([])
end
- it 'times out if given a small dynamic timeout' do
+ it "times out if given a small dynamic timeout" do
expect { subject.new_pointers(dynamic_timeout: 0.001) }.to raise_error(GRPC::DeadlineExceeded)
end
end
diff --git a/spec/lib/gitlab/git/lfs_pointer_file_spec.rb b/spec/lib/gitlab/git/lfs_pointer_file_spec.rb
index d7f76737f3f..47971dc6fbd 100644
--- a/spec/lib/gitlab/git/lfs_pointer_file_spec.rb
+++ b/spec/lib/gitlab/git/lfs_pointer_file_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::LfsPointerFile do
let(:data) { "1234\n" }
subject { described_class.new(data) }
- describe '#size' do
- it 'counts the bytes' do
+ describe "#size" do
+ it "counts the bytes" do
expect(subject.size).to eq 5
end
- it 'handles non ascii data' do
+ it "handles non ascii data" do
expect(described_class.new("ääää").size).to eq 8
end
end
- describe '#sha256' do
- it 'hashes the content correctly' do
- expect(subject.sha256).to eq 'a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4'
+ describe "#sha256" do
+ it "hashes the content correctly" do
+ expect(subject.sha256).to eq "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4"
end
end
- describe '#pointer' do
- it 'starts with the LFS version' do
- expect(subject.pointer).to start_with('version https://git-lfs.github.com/spec/v1')
+ describe "#pointer" do
+ it "starts with the LFS version" do
+ expect(subject.pointer).to start_with("version https://git-lfs.github.com/spec/v1")
end
- it 'includes sha256' do
+ it "includes sha256" do
expect(subject.pointer).to match(/^oid sha256:[0-9a-fA-F]{64}/)
end
- it 'ends with the size' do
+ it "ends with the size" do
expect(subject.pointer).to end_with("\nsize 5\n")
end
end
diff --git a/spec/lib/gitlab/git/merge_base_spec.rb b/spec/lib/gitlab/git/merge_base_spec.rb
index dbb4e3d0b3e..354b2a0983e 100644
--- a/spec/lib/gitlab/git/merge_base_spec.rb
+++ b/spec/lib/gitlab/git/merge_base_spec.rb
@@ -1,92 +1,92 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::MergeBase do
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject(:merge_base) { described_class.new(repository, refs) }
- shared_context 'existing refs with a merge base', :existing_refs do
+ shared_context "existing refs with a merge base", :existing_refs do
let(:refs) do
- %w(304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209)
+ %w[304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209]
end
end
- shared_context 'when passing a missing ref', :missing_ref do
+ shared_context "when passing a missing ref", :missing_ref do
let(:refs) do
- %w(304d257dcb821665ab5110318fc58a007bd104ed aaaa)
+ %w[304d257dcb821665ab5110318fc58a007bd104ed aaaa]
end
end
- shared_context 'when passing refs that do not have a common ancestor', :no_common_ancestor do
- let(:refs) { ['304d257dcb821665ab5110318fc58a007bd104ed', TestEnv::BRANCH_SHA['orphaned-branch']] }
+ shared_context "when passing refs that do not have a common ancestor", :no_common_ancestor do
+ let(:refs) { ["304d257dcb821665ab5110318fc58a007bd104ed", TestEnv::BRANCH_SHA["orphaned-branch"]] }
end
- describe '#sha' do
- context 'when the refs exist', :existing_refs do
- it 'returns the SHA of the merge base' do
+ describe "#sha" do
+ context "when the refs exist", :existing_refs do
+ it "returns the SHA of the merge base" do
expect(merge_base.sha).not_to be_nil
end
- it 'memoizes the result' do
+ it "memoizes the result" do
expect(repository).to receive(:merge_base).once.and_call_original
2.times { merge_base.sha }
end
end
- context 'when passing a missing ref', :missing_ref do
- it 'does not call merge_base on the repository but raises an error' do
+ context "when passing a missing ref", :missing_ref do
+ it "does not call merge_base on the repository but raises an error" do
expect(repository).not_to receive(:merge_base)
expect { merge_base.sha }.to raise_error(Gitlab::Git::UnknownRef)
end
end
- it 'returns `nil` when the refs do not have a common ancestor', :no_common_ancestor do
+ it "returns `nil` when the refs do not have a common ancestor", :no_common_ancestor do
expect(merge_base.sha).to be_nil
end
- it 'returns a merge base when passing 2 branch names' do
- merge_base = described_class.new(repository, %w(master feature))
+ it "returns a merge base when passing 2 branch names" do
+ merge_base = described_class.new(repository, %w[master feature])
expect(merge_base.sha).to be_present
end
- it 'returns a merge base when passing a tag name' do
- merge_base = described_class.new(repository, %w(master v1.0.0))
+ it "returns a merge base when passing a tag name" do
+ merge_base = described_class.new(repository, %w[master v1.0.0])
expect(merge_base.sha).to be_present
end
end
- describe '#commit' do
- context 'for existing refs with a merge base', :existing_refs do
- it 'finds the commit for the merge base' do
+ describe "#commit" do
+ context "for existing refs with a merge base", :existing_refs do
+ it "finds the commit for the merge base" do
expect(merge_base.commit).to be_a(Commit)
end
- it 'only looks up the commit once' do
+ it "only looks up the commit once" do
expect(repository).to receive(:commit_by).once.and_call_original
2.times { merge_base.commit }
end
end
- it 'does not try to find the commit when there is no sha', :no_common_ancestor do
+ it "does not try to find the commit when there is no sha", :no_common_ancestor do
expect(repository).not_to receive(:commit_by)
merge_base.commit
end
end
- describe '#unknown_refs', :missing_ref do
- it 'returns the refs passed that are not part of the repository' do
- expect(merge_base.unknown_refs).to contain_exactly('aaaa')
+ describe "#unknown_refs", :missing_ref do
+ it "returns the refs passed that are not part of the repository" do
+ expect(merge_base.unknown_refs).to contain_exactly("aaaa")
end
- it 'only looks up the commits once' do
+ it "only looks up the commits once" do
expect(merge_base).to receive(:commits_for_refs).once.and_call_original
2.times { merge_base.unknown_refs }
diff --git a/spec/lib/gitlab/git/object_pool_spec.rb b/spec/lib/gitlab/git/object_pool_spec.rb
index 0d5069568e1..2da921020ac 100644
--- a/spec/lib/gitlab/git/object_pool_spec.rb
+++ b/spec/lib/gitlab/git/object_pool_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::ObjectPool do
let(:pool_repository) { create(:pool_repository) }
@@ -8,71 +8,71 @@ describe Gitlab::Git::ObjectPool do
subject { pool_repository.object_pool }
- describe '#storage' do
+ describe "#storage" do
it "equals the pool repository's shard name" do
expect(subject.storage).not_to be_nil
expect(subject.storage).to eq(pool_repository.shard_name)
end
end
- describe '#create' do
+ describe "#create" do
before do
subject.create
end
context "when the pool doesn't exist yet" do
- it 'creates the pool' do
+ it "creates the pool" do
expect(subject.exists?).to be(true)
end
end
- context 'when the pool already exists' do
- it 'raises an FailedPrecondition' do
- expect do
+ context "when the pool already exists" do
+ it "raises an FailedPrecondition" do
+ expect {
subject.create
- end.to raise_error(GRPC::FailedPrecondition)
+ }.to raise_error(GRPC::FailedPrecondition)
end
end
end
- describe '#exists?' do
+ describe "#exists?" do
context "when the object pool doesn't exist" do
- it 'returns false' do
+ it "returns false" do
expect(subject.exists?).to be(false)
end
end
- context 'when the object pool exists' do
+ context "when the object pool exists" do
let(:pool) { create(:pool_repository, :ready) }
subject { pool.object_pool }
- it 'returns true' do
+ it "returns true" do
expect(subject.exists?).to be(true)
end
end
end
- describe '#link' do
+ describe "#link" do
let!(:pool_repository) { create(:pool_repository, :ready) }
- context 'when linked for the first time' do
- it 'sets a remote' do
- expect do
+ context "when linked for the first time" do
+ it "sets a remote" do
+ expect {
subject.link(source_repository)
- end.not_to raise_error
+ }.not_to raise_error
end
end
- context 'when the remote is already set' do
+ context "when the remote is already set" do
before do
subject.link(source_repository)
end
it "doesn't raise an error" do
- expect do
+ expect {
subject.link(source_repository)
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/lib/gitlab/git/patches/collection_spec.rb b/spec/lib/gitlab/git/patches/collection_spec.rb
index 080be141c59..e8be4ea3681 100644
--- a/spec/lib/gitlab/git/patches/collection_spec.rb
+++ b/spec/lib/gitlab/git/patches/collection_spec.rb
@@ -1,8 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Gitlab::Git::Patches::Collection do
- let(:patches_folder) { Rails.root.join('spec/fixtures/patchfiles') }
+ let(:patches_folder) { Rails.root.join("spec/fixtures/patchfiles") }
let(:patch_content1) do
File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch"))
end
@@ -12,14 +13,14 @@ describe Gitlab::Git::Patches::Collection do
subject(:collection) { described_class.new([patch_content1, patch_content2]) }
- describe '#size' do
- it 'combines the size of the patches' do
+ describe "#size" do
+ it "combines the size of the patches" do
expect(collection.size).to eq(549.bytes + 424.bytes)
end
end
- describe '#valid_size?' do
- it 'is not valid if the total size is bigger than 2MB' do
+ describe "#valid_size?" do
+ it "is not valid if the total size is bigger than 2MB" do
expect(collection).to receive(:size).and_return(2500.kilobytes)
expect(collection).not_to be_valid_size
diff --git a/spec/lib/gitlab/git/patches/commit_patches_spec.rb b/spec/lib/gitlab/git/patches/commit_patches_spec.rb
index 760112155ce..75eb6180baa 100644
--- a/spec/lib/gitlab/git/patches/commit_patches_spec.rb
+++ b/spec/lib/gitlab/git/patches/commit_patches_spec.rb
@@ -1,47 +1,48 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Gitlab::Git::Patches::CommitPatches do
- describe '#commit' do
+ describe "#commit" do
let(:patches) do
- patches_folder = Rails.root.join('spec/fixtures/patchfiles')
+ patches_folder = Rails.root.join("spec/fixtures/patchfiles")
content_1 = File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch"))
content_2 = File.read(File.join(patches_folder, "0001-A-commit-from-a-patch.patch"))
Gitlab::Git::Patches::Collection.new([content_1, content_2])
end
let(:user) { build(:user) }
- let(:branch_name) { 'branch-with-patches' }
+ let(:branch_name) { "branch-with-patches" }
let(:repository) { create(:project, :repository).repository }
subject(:commit_patches) do
described_class.new(user, repository, branch_name, patches)
end
- it 'applies the patches' do
+ it "applies the patches" do
new_rev = commit_patches.commit
expect(repository.commit(new_rev)).not_to be_nil
end
- it 'updates the branch cache' do
+ it "updates the branch cache" do
expect(repository).to receive(:after_create_branch)
commit_patches.commit
end
- context 'when the repository does not exist' do
+ context "when the repository does not exist" do
let(:repository) { create(:project).repository }
- it 'raises the correct error' do
+ it "raises the correct error" do
expect { commit_patches.commit }.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end
- context 'when the patch does not apply' do
- let(:branch_name) { 'feature' }
+ context "when the patch does not apply" do
+ let(:branch_name) { "feature" }
- it 'raises the correct error' do
+ it "raises the correct error" do
expect { commit_patches.commit }.to raise_error(Gitlab::Git::CommandError)
end
end
diff --git a/spec/lib/gitlab/git/patches/patch_spec.rb b/spec/lib/gitlab/git/patches/patch_spec.rb
index 7466e853b65..665ef5bd875 100644
--- a/spec/lib/gitlab/git/patches/patch_spec.rb
+++ b/spec/lib/gitlab/git/patches/patch_spec.rb
@@ -1,15 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Gitlab::Git::Patches::Patch do
- let(:patches_folder) { Rails.root.join('spec/fixtures/patchfiles') }
+ let(:patches_folder) { Rails.root.join("spec/fixtures/patchfiles") }
let(:patch_content) do
File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch"))
end
let(:patch) { described_class.new(patch_content) }
- describe '#size' do
- it 'is correct' do
+ describe "#size" do
+ it "is correct" do
expect(patch.size).to eq(549.bytes)
end
end
diff --git a/spec/lib/gitlab/git/pre_receive_error_spec.rb b/spec/lib/gitlab/git/pre_receive_error_spec.rb
index 1b8be62dec6..90adb8af288 100644
--- a/spec/lib/gitlab/git/pre_receive_error_spec.rb
+++ b/spec/lib/gitlab/git/pre_receive_error_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::PreReceiveError do
- it 'makes its message HTML-friendly' do
+ it "makes its message HTML-friendly" do
ex = described_class.new("hello\nworld\n")
- expect(ex.message).to eq('hello<br>world<br>')
+ expect(ex.message).to eq("hello<br>world<br>")
end
end
diff --git a/spec/lib/gitlab/git/push_spec.rb b/spec/lib/gitlab/git/push_spec.rb
index 566c8209504..efbf9a6a8a2 100644
--- a/spec/lib/gitlab/git/push_spec.rb
+++ b/spec/lib/gitlab/git/push_spec.rb
@@ -1,164 +1,164 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::Push do
set(:project) { create(:project, :repository) }
- let(:oldrev) { project.commit('HEAD~2').id }
+ let(:oldrev) { project.commit("HEAD~2").id }
let(:newrev) { project.commit.id }
- let(:ref) { 'refs/heads/some-branch' }
+ let(:ref) { "refs/heads/some-branch" }
subject { described_class.new(project, oldrev, newrev, ref) }
- describe '#branch_name' do
- context 'when it is a branch push' do
- let(:ref) { 'refs/heads/my-branch' }
+ describe "#branch_name" do
+ context "when it is a branch push" do
+ let(:ref) { "refs/heads/my-branch" }
- it 'returns branch name' do
- expect(subject.branch_name).to eq 'my-branch'
+ it "returns branch name" do
+ expect(subject.branch_name).to eq "my-branch"
end
end
- context 'when it is a tag push' do
- let(:ref) { 'refs/tags/my-branch' }
+ context "when it is a tag push" do
+ let(:ref) { "refs/tags/my-branch" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.branch_name).to be_nil
end
end
end
- describe '#branch_push?' do
- context 'when pushing a branch ref' do
- let(:ref) { 'refs/heads/my-branch' }
+ describe "#branch_push?" do
+ context "when pushing a branch ref" do
+ let(:ref) { "refs/heads/my-branch" }
it { is_expected.to be_branch_push }
end
- context 'when it is a tag push' do
- let(:ref) { 'refs/tags/my-tag' }
+ context "when it is a tag push" do
+ let(:ref) { "refs/tags/my-tag" }
it { is_expected.not_to be_branch_push }
end
end
- describe '#branch_updated?' do
- context 'when it is a branch push with correct old and new revisions' do
+ describe "#branch_updated?" do
+ context "when it is a branch push with correct old and new revisions" do
it { is_expected.to be_branch_updated }
end
- context 'when it is not a branch push' do
- let(:ref) { 'refs/tags/my-tag' }
+ context "when it is not a branch push" do
+ let(:ref) { "refs/tags/my-tag" }
it { is_expected.not_to be_branch_updated }
end
- context 'when old revision is blank' do
+ context "when old revision is blank" do
let(:oldrev) { Gitlab::Git::BLANK_SHA }
it { is_expected.not_to be_branch_updated }
end
- context 'when it is not a branch push' do
+ context "when it is not a branch push" do
let(:newrev) { Gitlab::Git::BLANK_SHA }
it { is_expected.not_to be_branch_updated }
end
- context 'when oldrev is nil' do
+ context "when oldrev is nil" do
let(:oldrev) { nil }
it { is_expected.not_to be_branch_updated }
end
end
- describe '#force_push?' do
- context 'when old revision is an ancestor of the new revision' do
- let(:oldrev) { 'HEAD~3' }
- let(:newrev) { 'HEAD~1' }
+ describe "#force_push?" do
+ context "when old revision is an ancestor of the new revision" do
+ let(:oldrev) { "HEAD~3" }
+ let(:newrev) { "HEAD~1" }
it { is_expected.not_to be_force_push }
end
- context 'when old revision is not an ancestor of the new revision' do
- let(:oldrev) { 'HEAD~3' }
- let(:newrev) { '123456' }
+ context "when old revision is not an ancestor of the new revision" do
+ let(:oldrev) { "HEAD~3" }
+ let(:newrev) { "123456" }
it { is_expected.to be_force_push }
end
end
- describe '#branch_added?' do
- context 'when old revision is defined' do
+ describe "#branch_added?" do
+ context "when old revision is defined" do
it { is_expected.not_to be_branch_added }
end
- context 'when old revision is not defined' do
+ context "when old revision is not defined" do
let(:oldrev) { Gitlab::Git::BLANK_SHA }
it { is_expected.to be_branch_added }
end
end
- describe '#branch_removed?' do
- context 'when new revision is defined' do
+ describe "#branch_removed?" do
+ context "when new revision is defined" do
it { is_expected.not_to be_branch_removed }
end
- context 'when new revision is not defined' do
+ context "when new revision is not defined" do
let(:newrev) { Gitlab::Git::BLANK_SHA }
it { is_expected.to be_branch_removed }
end
end
- describe '#modified_paths' do
- context 'when a push is a branch update' do
- let(:newrev) { '498214d' }
- let(:oldrev) { '281d3a7' }
+ describe "#modified_paths" do
+ context "when a push is a branch update" do
+ let(:newrev) { "498214d" }
+ let(:oldrev) { "281d3a7" }
- it 'returns modified paths' do
- expect(subject.modified_paths).to eq ['bar/branch-test.txt',
- 'files/js/commit.coffee',
- 'with space/README.md']
+ it "returns modified paths" do
+ expect(subject.modified_paths).to eq ["bar/branch-test.txt",
+ "files/js/commit.coffee",
+ "with space/README.md",]
end
end
- context 'when a push is not a branch update' do
+ context "when a push is not a branch update" do
let(:oldrev) { Gitlab::Git::BLANK_SHA }
- it 'raises an error' do
+ it "raises an error" do
expect { subject.modified_paths }.to raise_error(ArgumentError)
end
end
end
- describe '#oldrev' do
- context 'when a valid oldrev is provided' do
- it 'returns oldrev' do
+ describe "#oldrev" do
+ context "when a valid oldrev is provided" do
+ it "returns oldrev" do
expect(subject.oldrev).to eq oldrev
end
end
- context 'when a nil valud is provided' do
+ context "when a nil valud is provided" do
let(:oldrev) { nil }
- it 'returns blank SHA' do
+ it "returns blank SHA" do
expect(subject.oldrev).to eq Gitlab::Git::BLANK_SHA
end
end
end
- describe '#newrev' do
- context 'when valid newrev is provided' do
- it 'returns newrev' do
+ describe "#newrev" do
+ context "when valid newrev is provided" do
+ it "returns newrev" do
expect(subject.newrev).to eq newrev
end
end
- context 'when a nil valud is provided' do
+ context "when a nil valud is provided" do
let(:newrev) { nil }
- it 'returns blank SHA' do
+ it "returns blank SHA" do
expect(subject.newrev).to eq Gitlab::Git::BLANK_SHA
end
end
diff --git a/spec/lib/gitlab/git/raw_diff_change_spec.rb b/spec/lib/gitlab/git/raw_diff_change_spec.rb
index a0bb37fd84a..df62c8087ac 100644
--- a/spec/lib/gitlab/git/raw_diff_change_spec.rb
+++ b/spec/lib/gitlab/git/raw_diff_change_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::RawDiffChange do
let(:raw_change) { }
let(:change) { described_class.new(raw_change) }
- context 'bad input' do
- let(:raw_change) { 'foo' }
+ context "bad input" do
+ let(:raw_change) { "foo" }
- it 'does not set most of the attrs' do
- expect(change.blob_id).to eq('foo')
+ it "does not set most of the attrs" do
+ expect(change.blob_id).to eq("foo")
expect(change.operation).to eq(:unknown)
expect(change.old_path).to be_blank
expect(change.new_path).to be_blank
@@ -16,48 +16,48 @@ describe Gitlab::Git::RawDiffChange do
end
end
- context 'adding a file' do
- let(:raw_change) { '93e123ac8a3e6a0b600953d7598af629dec7b735 59 A bar/branch-test.txt' }
+ context "adding a file" do
+ let(:raw_change) { "93e123ac8a3e6a0b600953d7598af629dec7b735 59 A bar/branch-test.txt" }
- it 'initialize the proper attrs' do
+ it "initialize the proper attrs" do
expect(change.operation).to eq(:added)
expect(change.old_path).to be_blank
- expect(change.new_path).to eq('bar/branch-test.txt')
+ expect(change.new_path).to eq("bar/branch-test.txt")
expect(change.blob_id).to be_present
expect(change.blob_size).to be_present
end
end
- context 'renaming a file' do
+ context "renaming a file" do
let(:raw_change) { "85bc2f9753afd5f4fc5d7c75f74f8d526f26b4f3 107 R060\tfiles/js/commit.js.coffee\tfiles/js/commit.coffee" }
- it 'initialize the proper attrs' do
+ it "initialize the proper attrs" do
expect(change.operation).to eq(:renamed)
- expect(change.old_path).to eq('files/js/commit.js.coffee')
- expect(change.new_path).to eq('files/js/commit.coffee')
+ expect(change.old_path).to eq("files/js/commit.js.coffee")
+ expect(change.new_path).to eq("files/js/commit.coffee")
expect(change.blob_id).to be_present
expect(change.blob_size).to be_present
end
end
- context 'modifying a file' do
- let(:raw_change) { 'c60514b6d3d6bf4bec1030f70026e34dfbd69ad5 824 M README.md' }
+ context "modifying a file" do
+ let(:raw_change) { "c60514b6d3d6bf4bec1030f70026e34dfbd69ad5 824 M README.md" }
- it 'initialize the proper attrs' do
+ it "initialize the proper attrs" do
expect(change.operation).to eq(:modified)
- expect(change.old_path).to eq('README.md')
- expect(change.new_path).to eq('README.md')
+ expect(change.old_path).to eq("README.md")
+ expect(change.new_path).to eq("README.md")
expect(change.blob_id).to be_present
expect(change.blob_size).to be_present
end
end
- context 'deleting a file' do
- let(:raw_change) { '60d7a906c2fd9e4509aeb1187b98d0ea7ce827c9 15364 D files/.DS_Store' }
+ context "deleting a file" do
+ let(:raw_change) { "60d7a906c2fd9e4509aeb1187b98d0ea7ce827c9 15364 D files/.DS_Store" }
- it 'initialize the proper attrs' do
+ it "initialize the proper attrs" do
expect(change.operation).to eq(:deleted)
- expect(change.old_path).to eq('files/.DS_Store')
+ expect(change.old_path).to eq("files/.DS_Store")
expect(change.new_path).to be_nil
expect(change.blob_id).to be_present
expect(change.blob_size).to be_present
diff --git a/spec/lib/gitlab/git/remote_mirror_spec.rb b/spec/lib/gitlab/git/remote_mirror_spec.rb
index dc63eef7814..11d343f446a 100644
--- a/spec/lib/gitlab/git/remote_mirror_spec.rb
+++ b/spec/lib/gitlab/git/remote_mirror_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::RemoteMirror do
- describe '#update' do
+ describe "#update" do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- let(:ref_name) { 'foo' }
- let(:options) { { only_branches_matching: ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS' } }
+ let(:ref_name) { "foo" }
+ let(:options) { {only_branches_matching: ["master"], ssh_key: "KEY", known_hosts: "KNOWN HOSTS"} }
subject(:remote_mirror) { described_class.new(repository, ref_name, **options) }
- it 'delegates to the Gitaly client' do
+ it "delegates to the Gitaly client" do
expect(repository.gitaly_remote_client)
.to receive(:update_remote_mirror)
- .with(ref_name, ['master'], ssh_key: 'KEY', known_hosts: 'KNOWN HOSTS')
+ .with(ref_name, ["master"], ssh_key: "KEY", known_hosts: "KNOWN HOSTS")
remote_mirror.update
end
- it 'wraps gitaly errors' do
+ it "wraps gitaly errors" do
expect(repository.gitaly_remote_client)
.to receive(:update_remote_mirror)
.and_raise(StandardError)
diff --git a/spec/lib/gitlab/git/remote_repository_spec.rb b/spec/lib/gitlab/git/remote_repository_spec.rb
index e166628d4ca..8263b1542b3 100644
--- a/spec/lib/gitlab/git/remote_repository_spec.rb
+++ b/spec/lib/gitlab/git/remote_repository_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::RemoteRepository, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
subject { described_class.new(repository) }
- describe '#empty?' do
+ describe "#empty?" do
using RSpec::Parameterized::TableSyntax
where(:repository, :result) do
- Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') | false
- Gitlab::Git::Repository.new('default', 'does-not-exist.git', '', 'group/project') | true
+ Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") | false
+ Gitlab::Git::Repository.new("default", "does-not-exist.git", "", "group/project") | true
end
with_them do
@@ -17,22 +17,22 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do
end
end
- describe '#commit_id' do
- it 'returns an OID if the revision exists' do
- expect(subject.commit_id('v1.0.0')).to eq('6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9')
+ describe "#commit_id" do
+ it "returns an OID if the revision exists" do
+ expect(subject.commit_id("v1.0.0")).to eq("6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9")
end
- it 'is nil when the revision does not exist' do
- expect(subject.commit_id('does-not-exist')).to be_nil
+ it "is nil when the revision does not exist" do
+ expect(subject.commit_id("does-not-exist")).to be_nil
end
end
- describe '#branch_exists?' do
+ describe "#branch_exists?" do
using RSpec::Parameterized::TableSyntax
where(:branch, :result) do
- 'master' | true
- 'does-not-exist' | false
+ "master" | true
+ "does-not-exist" | false
end
with_them do
@@ -40,15 +40,15 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do
end
end
- describe '#same_repository?' do
+ describe "#same_repository?" do
using RSpec::Parameterized::TableSyntax
where(:other_repository, :result) do
repository | true
- Gitlab::Git::Repository.new(repository.storage, repository.relative_path, '', 'group/project') | true
- Gitlab::Git::Repository.new('broken', TEST_REPO_PATH, '', 'group/project') | false
- Gitlab::Git::Repository.new(repository.storage, 'wrong/relative-path.git', '', 'group/project') | false
- Gitlab::Git::Repository.new('broken', 'wrong/relative-path.git', '', 'group/project') | false
+ Gitlab::Git::Repository.new(repository.storage, repository.relative_path, "", "group/project") | true
+ Gitlab::Git::Repository.new("broken", TEST_REPO_PATH, "", "group/project") | false
+ Gitlab::Git::Repository.new(repository.storage, "wrong/relative-path.git", "", "group/project") | false
+ Gitlab::Git::Repository.new("broken", "wrong/relative-path.git", "", "group/project") | false
end
with_them do
@@ -56,12 +56,12 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do
end
end
- describe '#fetch_env' do
+ describe "#fetch_env" do
let(:remote_repository) { described_class.new(repository) }
let(:gitaly_client) { double(:gitaly_client) }
- let(:address) { 'fake-address' }
- let(:token) { 'fake-token' }
+ let(:address) { "fake-address" }
+ let(:token) { "fake-token" }
subject { remote_repository.fetch_env }
@@ -73,27 +73,27 @@ describe Gitlab::Git::RemoteRepository, :seed_helper do
end
it { expect(subject).to be_a(Hash) }
- it { expect(subject['GITALY_ADDRESS']).to eq(address) }
- it { expect(subject['GITALY_TOKEN']).to eq(token) }
- it { expect(subject['GITALY_WD']).to eq(Dir.pwd) }
+ it { expect(subject["GITALY_ADDRESS"]).to eq(address) }
+ it { expect(subject["GITALY_TOKEN"]).to eq(token) }
+ it { expect(subject["GITALY_WD"]).to eq(Dir.pwd) }
- it 'creates a plausible GIT_SSH_COMMAND' do
- git_ssh_command = subject['GIT_SSH_COMMAND']
+ it "creates a plausible GIT_SSH_COMMAND" do
+ git_ssh_command = subject["GIT_SSH_COMMAND"]
- expect(git_ssh_command).to start_with('/')
- expect(git_ssh_command).to end_with('/gitaly-ssh upload-pack')
+ expect(git_ssh_command).to start_with("/")
+ expect(git_ssh_command).to end_with("/gitaly-ssh upload-pack")
end
- it 'creates a plausible GITALY_PAYLOAD' do
- req = Gitaly::SSHUploadPackRequest.decode_json(subject['GITALY_PAYLOAD'])
+ it "creates a plausible GITALY_PAYLOAD" do
+ req = Gitaly::SSHUploadPackRequest.decode_json(subject["GITALY_PAYLOAD"])
expect(remote_repository.gitaly_repository).to eq(req.repository)
end
- context 'when the token is blank' do
- let(:token) { '' }
+ context "when the token is blank" do
+ let(:token) { "" }
- it { expect(subject.keys).not_to include('GITALY_TOKEN') }
+ it { expect(subject.keys).not_to include("GITALY_TOKEN") }
end
end
end
diff --git a/spec/lib/gitlab/git/repository_cleaner_spec.rb b/spec/lib/gitlab/git/repository_cleaner_spec.rb
index 7f9cc2bc9ec..a4d11f99f57 100644
--- a/spec/lib/gitlab/git/repository_cleaner_spec.rb
+++ b/spec/lib/gitlab/git/repository_cleaner_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::RepositoryCleaner do
include HttpIOHelpers
@@ -6,11 +6,11 @@ describe Gitlab::Git::RepositoryCleaner do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:head_sha) { repository.head_commit.id }
- let(:object_map_data) { "#{head_sha} #{'0' * 40}" }
+ let(:object_map_data) { "#{head_sha} #{"0" * 40}" }
subject(:cleaner) { described_class.new(repository.raw) }
- describe '#apply_bfg_object_map' do
+ describe "#apply_bfg_object_map" do
let(:clean_refs) { %W[refs/environments/1 refs/merge-requests/1 refs/keep-around/#{head_sha}] }
let(:keep_refs) { %w[refs/heads/_keep refs/tags/_keep] }
@@ -18,10 +18,10 @@ describe Gitlab::Git::RepositoryCleaner do
(clean_refs + keep_refs).each { |ref| repository.create_ref(head_sha, ref) }
end
- context 'from StringIO' do
+ context "from StringIO" do
let(:object_map) { StringIO.new(object_map_data) }
- it 'removes internal references' do
+ it "removes internal references" do
cleaner.apply_bfg_object_map(object_map)
aggregate_failures do
@@ -31,23 +31,21 @@ describe Gitlab::Git::RepositoryCleaner do
end
end
- context 'from Gitlab::HttpIO' do
- let(:url) { 'http://example.com/bfg_object_map.txt' }
+ context "from Gitlab::HttpIO" do
+ let(:url) { "http://example.com/bfg_object_map.txt" }
let(:tempfile) { Tempfile.new }
let(:object_map) { Gitlab::HttpIO.new(url, object_map_data.size) }
around do |example|
- begin
- tempfile.write(object_map_data)
- tempfile.close
+ tempfile.write(object_map_data)
+ tempfile.close
- example.run
- ensure
- tempfile.unlink
- end
+ example.run
+ ensure
+ tempfile.unlink
end
- it 'removes internal references' do
+ it "removes internal references" do
stub_remote_url_200(url, tempfile.path)
cleaner.apply_bfg_object_map(object_map)
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index e3dd02f1478..ffab1c16a09 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -1,46 +1,45 @@
-# coding: utf-8
require "spec_helper"
describe Gitlab::Git::Repository, :seed_helper do
include Gitlab::EncodingHelper
using RSpec::Parameterized::TableSyntax
- shared_examples 'wrapping gRPC errors' do |gitaly_client_class, gitaly_client_method|
- it 'wraps gRPC not found error' do
+ shared_examples "wrapping gRPC errors" do |gitaly_client_class, gitaly_client_method|
+ it "wraps gRPC not found error" do
expect_any_instance_of(gitaly_client_class).to receive(gitaly_client_method)
.and_raise(GRPC::NotFound)
expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository)
end
- it 'wraps gRPC unknown error' do
+ it "wraps gRPC unknown error" do
expect_any_instance_of(gitaly_client_class).to receive(gitaly_client_method)
.and_raise(GRPC::Unknown)
expect { subject }.to raise_error(Gitlab::Git::CommandError)
end
end
- let(:mutable_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project') }
+ let(:mutable_repository) { Gitlab::Git::Repository.new("default", TEST_MUTABLE_REPO_PATH, "", "group/project") }
let(:mutable_repository_path) { File.join(TestEnv.repos_path, mutable_repository.relative_path) }
let(:mutable_repository_rugged) { Rugged::Repository.new(mutable_repository_path) }
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:repository_path) { File.join(TestEnv.repos_path, repository.relative_path) }
let(:repository_rugged) { Rugged::Repository.new(repository_path) }
let(:storage_path) { TestEnv.repos_path }
let(:user) { build(:user) }
- describe '.create_hooks' do
- let(:repo_path) { File.join(storage_path, 'hook-test.git') }
- let(:hooks_dir) { File.join(repo_path, 'hooks') }
+ describe ".create_hooks" do
+ let(:repo_path) { File.join(storage_path, "hook-test.git") }
+ let(:hooks_dir) { File.join(repo_path, "hooks") }
let(:target_hooks_dir) { Gitlab::Shell.new.hooks_path }
- let(:existing_target) { File.join(repo_path, 'foobar') }
+ let(:existing_target) { File.join(repo_path, "foobar") }
before do
FileUtils.rm_rf(repo_path)
FileUtils.mkdir_p(repo_path)
end
- context 'hooks is a directory' do
- let(:existing_file) { File.join(hooks_dir, 'my-file') }
+ context "hooks is a directory" do
+ let(:existing_file) { File.join(hooks_dir, "my-file") }
before do
FileUtils.mkdir_p(hooks_dir)
@@ -52,7 +51,7 @@ describe Gitlab::Git::Repository, :seed_helper do
it { expect(Dir[File.join(repo_path, "hooks.old.*/my-file")].count).to eq(1) }
end
- context 'hooks is a valid symlink' do
+ context "hooks is a valid symlink" do
before do
FileUtils.mkdir_p existing_target
File.symlink(existing_target, hooks_dir)
@@ -62,7 +61,7 @@ describe Gitlab::Git::Repository, :seed_helper do
it { expect(File.readlink(hooks_dir)).to eq(target_hooks_dir) }
end
- context 'hooks is a broken symlink' do
+ context "hooks is a broken symlink" do
before do
FileUtils.rm_f(existing_target)
File.symlink(existing_target, hooks_dir)
@@ -80,215 +79,215 @@ describe Gitlab::Git::Repository, :seed_helper do
it { is_expected.to respond_to(:tags) }
end
- describe '#root_ref' do
- it 'returns UTF-8' do
+ describe "#root_ref" do
+ it "returns UTF-8" do
expect(repository.root_ref).to be_utf8
end
- it 'gets the branch name from GitalyClient' do
+ it "gets the branch name from GitalyClient" do
expect_any_instance_of(Gitlab::GitalyClient::RefService).to receive(:default_branch_name)
repository.root_ref
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :default_branch_name do
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RefService, :default_branch_name do
subject { repository.root_ref }
end
end
- describe '#branch_names' do
+ describe "#branch_names" do
subject { repository.branch_names }
- it 'has SeedRepo::Repo::BRANCHES.size elements' do
+ it "has SeedRepo::Repo::BRANCHES.size elements" do
expect(subject.size).to eq(SeedRepo::Repo::BRANCHES.size)
end
- it 'returns UTF-8' do
+ it "returns UTF-8" do
expect(subject.first).to be_utf8
end
it { is_expected.to include("master") }
it { is_expected.not_to include("branch-from-space") }
- it 'gets the branch names from GitalyClient' do
+ it "gets the branch names from GitalyClient" do
expect_any_instance_of(Gitlab::GitalyClient::RefService).to receive(:branch_names)
subject
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :branch_names
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RefService, :branch_names
end
- describe '#tag_names' do
+ describe "#tag_names" do
subject { repository.tag_names }
it { is_expected.to be_kind_of Array }
- it 'has SeedRepo::Repo::TAGS.size elements' do
+ it "has SeedRepo::Repo::TAGS.size elements" do
expect(subject.size).to eq(SeedRepo::Repo::TAGS.size)
end
- it 'returns UTF-8' do
+ it "returns UTF-8" do
expect(subject.first).to be_utf8
end
- describe '#last' do
+ describe "#last" do
subject { super().last }
it { is_expected.to eq("v1.2.1") }
end
it { is_expected.to include("v1.0.0") }
it { is_expected.not_to include("v5.0.0") }
- it 'gets the tag names from GitalyClient' do
+ it "gets the tag names from GitalyClient" do
expect_any_instance_of(Gitlab::GitalyClient::RefService).to receive(:tag_names)
subject
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :tag_names
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RefService, :tag_names
end
- describe '#archive_metadata' do
- let(:storage_path) { '/tmp' }
+ describe "#archive_metadata" do
+ let(:storage_path) { "/tmp" }
let(:cache_key) { File.join(repository.gl_repository, SeedRepo::LastCommit::ID) }
let(:append_sha) { true }
- let(:ref) { 'master' }
+ let(:ref) { "master" }
let(:format) { nil }
- let(:expected_extension) { 'tar.gz' }
+ let(:expected_extension) { "tar.gz" }
let(:expected_filename) { "#{expected_prefix}.#{expected_extension}" }
let(:expected_path) { File.join(storage_path, cache_key, expected_filename) }
let(:expected_prefix) { "gitlab-git-test-#{ref}-#{SeedRepo::LastCommit::ID}" }
- subject(:metadata) { repository.archive_metadata(ref, storage_path, 'gitlab-git-test', format, append_sha: append_sha) }
+ subject(:metadata) { repository.archive_metadata(ref, storage_path, "gitlab-git-test", format, append_sha: append_sha) }
- it 'sets CommitId to the commit SHA' do
- expect(metadata['CommitId']).to eq(SeedRepo::LastCommit::ID)
+ it "sets CommitId to the commit SHA" do
+ expect(metadata["CommitId"]).to eq(SeedRepo::LastCommit::ID)
end
- it 'sets ArchivePrefix to the expected prefix' do
- expect(metadata['ArchivePrefix']).to eq(expected_prefix)
+ it "sets ArchivePrefix to the expected prefix" do
+ expect(metadata["ArchivePrefix"]).to eq(expected_prefix)
end
- it 'sets ArchivePath to the expected globally-unique path' do
+ it "sets ArchivePath to the expected globally-unique path" do
# This is really important from a security perspective. Think carefully
# before changing it: https://gitlab.com/gitlab-org/gitlab-ce/issues/45689
expect(expected_path).to include(File.join(repository.gl_repository, SeedRepo::LastCommit::ID))
- expect(metadata['ArchivePath']).to eq(expected_path)
+ expect(metadata["ArchivePath"]).to eq(expected_path)
end
- context 'append_sha varies archive path and filename' do
+ context "append_sha varies archive path and filename" do
where(:append_sha, :ref, :expected_prefix) do
sha = SeedRepo::LastCommit::ID
- true | 'master' | "gitlab-git-test-master-#{sha}"
+ true | "master" | "gitlab-git-test-master-#{sha}"
true | sha | "gitlab-git-test-#{sha}-#{sha}"
- false | 'master' | "gitlab-git-test-master"
+ false | "master" | "gitlab-git-test-master"
false | sha | "gitlab-git-test-#{sha}"
- nil | 'master' | "gitlab-git-test-master-#{sha}"
+ nil | "master" | "gitlab-git-test-master-#{sha}"
nil | sha | "gitlab-git-test-#{sha}"
end
with_them do
- it { expect(metadata['ArchivePrefix']).to eq(expected_prefix) }
- it { expect(metadata['ArchivePath']).to eq(expected_path) }
+ it { expect(metadata["ArchivePrefix"]).to eq(expected_prefix) }
+ it { expect(metadata["ArchivePath"]).to eq(expected_path) }
end
end
- context 'format varies archive path and filename' do
+ context "format varies archive path and filename" do
where(:format, :expected_extension) do
- nil | 'tar.gz'
- 'madeup' | 'tar.gz'
- 'tbz2' | 'tar.bz2'
- 'zip' | 'zip'
+ nil | "tar.gz"
+ "madeup" | "tar.gz"
+ "tbz2" | "tar.bz2"
+ "zip" | "zip"
end
with_them do
- it { expect(metadata['ArchivePrefix']).to eq(expected_prefix) }
- it { expect(metadata['ArchivePath']).to eq(expected_path) }
+ it { expect(metadata["ArchivePrefix"]).to eq(expected_prefix) }
+ it { expect(metadata["ArchivePath"]).to eq(expected_path) }
end
end
end
- describe '#size' do
+ describe "#size" do
subject { repository.size }
it { is_expected.to be < 2 }
end
- describe '#empty?' do
+ describe "#empty?" do
it { expect(repository).not_to be_empty }
end
- describe '#ref_names' do
+ describe "#ref_names" do
let(:ref_names) { repository.ref_names }
subject { ref_names }
it { is_expected.to be_kind_of Array }
- describe '#first' do
+ describe "#first" do
subject { super().first }
- it { is_expected.to eq('feature') }
+ it { is_expected.to eq("feature") }
end
- describe '#last' do
+ describe "#last" do
subject { super().last }
- it { is_expected.to eq('v1.2.1') }
+ it { is_expected.to eq("v1.2.1") }
end
end
- describe '#submodule_url_for' do
- let(:ref) { 'master' }
+ describe "#submodule_url_for" do
+ let(:ref) { "master" }
def submodule_url(path)
repository.submodule_url_for(ref, path)
end
- it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') }
- it { expect(submodule_url('nested/six')).to eq('git://github.com/randx/six.git') }
- it { expect(submodule_url('deeper/nested/six')).to eq('git://github.com/randx/six.git') }
- it { expect(submodule_url('invalid/path')).to eq(nil) }
+ it { expect(submodule_url("six")).to eq("git://github.com/randx/six.git") }
+ it { expect(submodule_url("nested/six")).to eq("git://github.com/randx/six.git") }
+ it { expect(submodule_url("deeper/nested/six")).to eq("git://github.com/randx/six.git") }
+ it { expect(submodule_url("invalid/path")).to eq(nil) }
- context 'uncommitted submodule dir' do
- let(:ref) { 'fix-existing-submodule-dir' }
+ context "uncommitted submodule dir" do
+ let(:ref) { "fix-existing-submodule-dir" }
- it { expect(submodule_url('submodule-existing-dir')).to eq(nil) }
+ it { expect(submodule_url("submodule-existing-dir")).to eq(nil) }
end
- context 'tags' do
- let(:ref) { 'v1.2.1' }
+ context "tags" do
+ let(:ref) { "v1.2.1" }
- it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') }
+ it { expect(submodule_url("six")).to eq("git://github.com/randx/six.git") }
end
- context 'no .gitmodules at commit' do
- let(:ref) { '9596bc54a6f0c0c98248fe97077eb5ccf48a98d0' }
+ context "no .gitmodules at commit" do
+ let(:ref) { "9596bc54a6f0c0c98248fe97077eb5ccf48a98d0" }
- it { expect(submodule_url('six')).to eq(nil) }
+ it { expect(submodule_url("six")).to eq(nil) }
end
- context 'no gitlink entry' do
- let(:ref) { '6d39438' }
+ context "no gitlink entry" do
+ let(:ref) { "6d39438" }
- it { expect(submodule_url('six')).to eq(nil) }
+ it { expect(submodule_url("six")).to eq(nil) }
end
end
- describe '#commit_count' do
+ describe "#commit_count" do
it { expect(repository.commit_count("master")).to eq(25) }
it { expect(repository.commit_count("feature")).to eq(9) }
it { expect(repository.commit_count("does-not-exist")).to eq(0) }
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::CommitService, :commit_count do
- subject { repository.commit_count('master') }
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::CommitService, :commit_count do
+ subject { repository.commit_count("master") }
end
end
- describe '#diverging_commit_count' do
- it 'counts 0 for the same branch' do
- expect(repository.diverging_commit_count('master', 'master', max_count: 1000)).to eq([0, 0])
+ describe "#diverging_commit_count" do
+ it "counts 0 for the same branch" do
+ expect(repository.diverging_commit_count("master", "master", max_count: 1000)).to eq([0, 0])
end
- context 'max count does not truncate results' do
+ context "max count does not truncate results" do
where(:left, :right, :expected) do
1 | 1 | [1, 1]
4 | 4 | [4, 4]
@@ -300,26 +299,26 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
- repository.create_branch('left-branch', 'master')
- repository.create_branch('right-branch', 'master')
+ repository.create_branch("left-branch", "master")
+ repository.create_branch("right-branch", "master")
left.times do
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
+ new_commit_edit_new_file_on_branch(repository_rugged, "encoding/CHANGELOG", "left-branch", "some more content for a", "some stuff")
end
right.times do
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'right-branch', 'some more content for b', 'some stuff')
+ new_commit_edit_new_file_on_branch(repository_rugged, "encoding/CHANGELOG", "right-branch", "some more content for b", "some stuff")
end
end
after do
- repository.delete_branch('left-branch')
- repository.delete_branch('right-branch')
+ repository.delete_branch("left-branch")
+ repository.delete_branch("right-branch")
end
- it 'returns the correct count bounding at max_count' do
- branch_a_sha = repository_rugged.branches['left-branch'].target.oid
- branch_b_sha = repository_rugged.branches['right-branch'].target.oid
+ it "returns the correct count bounding at max_count" do
+ branch_a_sha = repository_rugged.branches["left-branch"].target.oid
+ branch_b_sha = repository_rugged.branches["right-branch"].target.oid
count = repository.diverging_commit_count(branch_a_sha, branch_b_sha, max_count: 1000)
@@ -328,7 +327,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'max count truncates results' do
+ context "max count truncates results" do
where(:left, :right, :max_count) do
1 | 1 | 1
4 | 4 | 4
@@ -340,26 +339,26 @@ describe Gitlab::Git::Repository, :seed_helper do
with_them do
before do
- repository.create_branch('left-branch', 'master')
- repository.create_branch('right-branch', 'master')
+ repository.create_branch("left-branch", "master")
+ repository.create_branch("right-branch", "master")
left.times do
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'left-branch', 'some more content for a', 'some stuff')
+ new_commit_edit_new_file_on_branch(repository_rugged, "encoding/CHANGELOG", "left-branch", "some more content for a", "some stuff")
end
right.times do
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'right-branch', 'some more content for b', 'some stuff')
+ new_commit_edit_new_file_on_branch(repository_rugged, "encoding/CHANGELOG", "right-branch", "some more content for b", "some stuff")
end
end
after do
- repository.delete_branch('left-branch')
- repository.delete_branch('right-branch')
+ repository.delete_branch("left-branch")
+ repository.delete_branch("right-branch")
end
- it 'returns the correct count bounding at max_count' do
- branch_a_sha = repository_rugged.branches['left-branch'].target.oid
- branch_b_sha = repository_rugged.branches['right-branch'].target.oid
+ it "returns the correct count bounding at max_count" do
+ branch_a_sha = repository_rugged.branches["left-branch"].target.oid
+ branch_b_sha = repository_rugged.branches["right-branch"].target.oid
results = repository.diverging_commit_count(branch_a_sha, branch_b_sha, max_count: max_count)
@@ -368,28 +367,28 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::CommitService, :diverging_commit_count do
- subject { repository.diverging_commit_count('master', 'master', max_count: 1000) }
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::CommitService, :diverging_commit_count do
+ subject { repository.diverging_commit_count("master", "master", max_count: 1000) }
end
end
- describe '#has_local_branches?' do
- context 'check for local branches' do
+ describe "#has_local_branches?" do
+ context "check for local branches" do
it { expect(repository.has_local_branches?).to eq(true) }
- context 'mutable' do
+ context "mutable" do
let(:repository) { mutable_repository }
after do
ensure_seeds
end
- it 'returns false when there are no branches' do
+ it "returns false when there are no branches" do
# Sanity check
expect(repository.has_local_branches?).to eq(true)
- FileUtils.rm_rf(File.join(repository_path, 'packed-refs'))
- heads_dir = File.join(repository_path, 'refs/heads')
+ FileUtils.rm_rf(File.join(repository_path, "packed-refs"))
+ heads_dir = File.join(repository_path, "refs/heads")
FileUtils.rm_rf(heads_dir)
FileUtils.mkdir_p(heads_dir)
@@ -398,8 +397,8 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'memoizes the value' do
- it 'returns true' do
+ context "memoizes the value" do
+ it "returns true" do
expect(repository).to receive(:uncached_has_local_branches?).once.and_call_original
2.times do
@@ -442,37 +441,37 @@ describe Gitlab::Git::Repository, :seed_helper do
end
it "should create a new branch" do
- expect(repository.create_branch('new_branch', 'master')).not_to be_nil
+ expect(repository.create_branch("new_branch", "master")).not_to be_nil
end
it "should create a new branch with the right name" do
- expect(repository.create_branch('another_branch', 'master').name).to eq('another_branch')
+ expect(repository.create_branch("another_branch", "master").name).to eq("another_branch")
end
it "should fail if we create an existing branch" do
- repository.create_branch('duplicated_branch', 'master')
- expect {repository.create_branch('duplicated_branch', 'master')}.to raise_error("Branch duplicated_branch already exists")
+ repository.create_branch("duplicated_branch", "master")
+ expect {repository.create_branch("duplicated_branch", "master")}.to raise_error("Branch duplicated_branch already exists")
end
it "should fail if we create a branch from a non existing ref" do
- expect {repository.create_branch('branch_based_in_wrong_ref', 'master_2_the_revenge')}.to raise_error("Invalid reference master_2_the_revenge")
+ expect {repository.create_branch("branch_based_in_wrong_ref", "master_2_the_revenge")}.to raise_error("Invalid reference master_2_the_revenge")
end
end
- describe '#delete_refs' do
+ describe "#delete_refs" do
let(:repository) { mutable_repository }
after do
ensure_seeds
end
- it 'deletes the ref' do
- repository.delete_refs('refs/heads/feature')
+ it "deletes the ref" do
+ repository.delete_refs("refs/heads/feature")
- expect(repository_rugged.references['refs/heads/feature']).to be_nil
+ expect(repository_rugged.references["refs/heads/feature"]).to be_nil
end
- it 'deletes all refs' do
+ it "deletes all refs" do
refs = %w[refs/heads/wip refs/tags/v1.1.0]
repository.delete_refs(*refs)
@@ -481,23 +480,23 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- it 'does not fail when deleting an empty list of refs' do
- expect { repository.delete_refs(*[]) }.not_to raise_error
+ it "does not fail when deleting an empty list of refs" do
+ expect { repository.delete_refs }.not_to raise_error
end
- it 'raises an error if it failed' do
+ it "raises an error if it failed" do
expect { repository.delete_refs('refs\heads\fix') }.to raise_error(Gitlab::Git::Repository::GitError)
end
end
- describe '#branch_names_contains_sha' do
+ describe "#branch_names_contains_sha" do
let(:head_id) { repository_rugged.head.target.oid }
let(:new_branch) { head_id }
- let(:utf8_branch) { 'branch-é' }
+ let(:utf8_branch) { "branch-é" }
before do
- repository.create_branch(new_branch, 'master')
- repository.create_branch(utf8_branch, 'master')
+ repository.create_branch(new_branch, "master")
+ repository.create_branch(utf8_branch, "master")
end
after do
@@ -505,8 +504,8 @@ describe Gitlab::Git::Repository, :seed_helper do
repository.delete_branch(utf8_branch)
end
- it 'displays that branch' do
- expect(repository.branch_names_contains_sha(head_id)).to include('master', new_branch, utf8_branch)
+ it "displays that branch" do
+ expect(repository.branch_names_contains_sha(head_id)).to include("master", new_branch, utf8_branch)
end
end
@@ -519,33 +518,33 @@ describe Gitlab::Git::Repository, :seed_helper do
expect(subject.values.flatten.size).to eq(expected_refs.size)
end
- it 'has valid commit ids as keys' do
- expect(subject.keys).to all( match(Commit::COMMIT_SHA_PATTERN) )
+ it "has valid commit ids as keys" do
+ expect(subject.keys).to all(match(Commit::COMMIT_SHA_PATTERN))
end
end
- describe '#fetch_repository_as_mirror' do
+ describe "#fetch_repository_as_mirror" do
let(:new_repository) do
- Gitlab::Git::Repository.new('default', 'my_project.git', '', 'group/project')
+ Gitlab::Git::Repository.new("default", "my_project.git", "", "group/project")
end
subject { new_repository.fetch_repository_as_mirror(repository) }
before do
- Gitlab::Shell.new.create_repository('default', 'my_project', 'group/project')
+ Gitlab::Shell.new.create_repository("default", "my_project", "group/project")
end
after do
- Gitlab::Shell.new.remove_repository('default', 'my_project')
+ Gitlab::Shell.new.remove_repository("default", "my_project")
end
- it 'fetches a repository as a mirror remote' do
+ it "fetches a repository as a mirror remote" do
subject
expect(refs(new_repository_path)).to eq(refs(repository_path))
end
- context 'with keep-around refs' do
+ context "with keep-around refs" do
let(:sha) { SeedRepo::Commit::ID }
let(:keep_around_ref) { "refs/keep-around/#{sha}" }
let(:tmp_ref) { "refs/tmp/#{SecureRandom.hex}" }
@@ -555,7 +554,7 @@ describe Gitlab::Git::Repository, :seed_helper do
repository_rugged.references.create(tmp_ref, sha, force: true)
end
- it 'includes the temporary and keep-around refs' do
+ it "includes the temporary and keep-around refs" do
subject
expect(refs(new_repository_path)).to include(keep_around_ref)
@@ -568,102 +567,102 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#fetch_remote' do
- it 'delegates to the gitaly RepositoryService' do
+ describe "#fetch_remote" do
+ it "delegates to the gitaly RepositoryService" do
ssh_auth = double(:ssh_auth)
expected_opts = {
ssh_auth: ssh_auth,
forced: true,
no_tags: true,
timeout: described_class::GITLAB_PROJECTS_TIMEOUT,
- prune: false
+ prune: false,
}
- expect(repository.gitaly_repository_client).to receive(:fetch_remote).with('remote-name', expected_opts)
+ expect(repository.gitaly_repository_client).to receive(:fetch_remote).with("remote-name", expected_opts)
- repository.fetch_remote('remote-name', ssh_auth: ssh_auth, forced: true, no_tags: true, prune: false)
+ repository.fetch_remote("remote-name", ssh_auth: ssh_auth, forced: true, no_tags: true, prune: false)
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RepositoryService, :fetch_remote do
- subject { repository.fetch_remote('remote-name') }
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RepositoryService, :fetch_remote do
+ subject { repository.fetch_remote("remote-name") }
end
end
- describe '#search_files_by_content' do
+ describe "#search_files_by_content" do
let(:repository) { mutable_repository }
let(:repository_rugged) { mutable_repository_rugged }
before do
- repository.create_branch('search-files-by-content-branch', 'master')
- new_commit_edit_new_file_on_branch(repository_rugged, 'encoding/CHANGELOG', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
- new_commit_edit_new_file_on_branch(repository_rugged, 'anotherfile', 'search-files-by-content-branch', 'committing something', 'search-files-by-content change')
+ repository.create_branch("search-files-by-content-branch", "master")
+ new_commit_edit_new_file_on_branch(repository_rugged, "encoding/CHANGELOG", "search-files-by-content-branch", "committing something", "search-files-by-content change")
+ new_commit_edit_new_file_on_branch(repository_rugged, "anotherfile", "search-files-by-content-branch", "committing something", "search-files-by-content change")
end
after do
ensure_seeds
end
- shared_examples 'search files by content' do
- it 'should have 2 items' do
+ shared_examples "search files by content" do
+ it "should have 2 items" do
expect(search_results.size).to eq(2)
end
- it 'should have the correct matching line' do
+ it "should have the correct matching line" do
expect(search_results).to contain_exactly("search-files-by-content-branch:encoding/CHANGELOG\u00001\u0000search-files-by-content change\n",
- "search-files-by-content-branch:anotherfile\u00001\u0000search-files-by-content change\n")
+ "search-files-by-content-branch:anotherfile\u00001\u0000search-files-by-content change\n")
end
end
- it_should_behave_like 'search files by content' do
+ it_should_behave_like "search files by content" do
let(:search_results) do
- repository.search_files_by_content('search-files-by-content', 'search-files-by-content-branch')
+ repository.search_files_by_content("search-files-by-content", "search-files-by-content-branch")
end
end
- it_should_behave_like 'search files by content' do
+ it_should_behave_like "search files by content" do
let(:search_results) do
repository.gitaly_repository_client.search_files_by_content(
- 'search-files-by-content-branch',
- 'search-files-by-content',
+ "search-files-by-content-branch",
+ "search-files-by-content",
chunked_response: false
)
end
end
end
- describe '#find_remote_root_ref' do
- it 'gets the remote root ref from GitalyClient' do
+ describe "#find_remote_root_ref" do
+ it "gets the remote root ref from GitalyClient" do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.to receive(:find_remote_root_ref).and_call_original
- expect(repository.find_remote_root_ref('origin')).to eq 'master'
+ expect(repository.find_remote_root_ref("origin")).to eq "master"
end
- it 'returns UTF-8' do
- expect(repository.find_remote_root_ref('origin')).to be_utf8
+ it "returns UTF-8" do
+ expect(repository.find_remote_root_ref("origin")).to be_utf8
end
- it 'returns nil when remote name is nil' do
+ it "returns nil when remote name is nil" do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref)
expect(repository.find_remote_root_ref(nil)).to be_nil
end
- it 'returns nil when remote name is empty' do
+ it "returns nil when remote name is empty" do
expect_any_instance_of(Gitlab::GitalyClient::RemoteService)
.not_to receive(:find_remote_root_ref)
- expect(repository.find_remote_root_ref('')).to be_nil
+ expect(repository.find_remote_root_ref("")).to be_nil
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RemoteService, :find_remote_root_ref do
- subject { repository.find_remote_root_ref('origin') }
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RemoteService, :find_remote_root_ref do
+ subject { repository.find_remote_root_ref("origin") }
end
end
describe "#log" do
- shared_examples 'repository log' do
+ shared_examples "repository log" do
let(:commit_with_old_name) do
Gitlab::Git::Commit.find(repository, @commit_with_old_name_id)
end
@@ -687,7 +686,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
context "where 'follow' == true" do
- let(:options) { { ref: "master", follow: true } }
+ let(:options) { {ref: "master", follow: true} }
context "and 'path' is a directory" do
it "does not follow renames" do
@@ -702,7 +701,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
context "and 'path' is a file that matches the new filename" do
- context 'without offset' do
+ context "without offset" do
it "follows renames" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG"))
@@ -714,7 +713,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=1' do
+ context "with offset=1" do
it "follows renames and skip the latest commit" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1))
@@ -726,7 +725,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=1', 'and limit=1' do
+ context "with offset=1", "and limit=1" do
it "follows renames, skip the latest commit and return only one commit" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1, limit: 1))
@@ -734,7 +733,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=1', 'and limit=2' do
+ context "with offset=1", "and limit=2" do
it "follows renames, skip the latest commit and return only two commits" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 1, limit: 2))
@@ -744,7 +743,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=2' do
+ context "with offset=2" do
it "follows renames and skip the latest commit" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2))
@@ -756,7 +755,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=2', 'and limit=1' do
+ context "with offset=2", "and limit=1" do
it "follows renames, skip the two latest commit and return only one commit" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2, limit: 1))
@@ -764,7 +763,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with offset=2', 'and limit=2' do
+ context "with offset=2", "and limit=2" do
it "follows renames, skip the two latest commit and return only one commit" do
log_commits = repository.log(options.merge(path: "encoding/CHANGELOG", offset: 2, limit: 2))
@@ -791,7 +790,7 @@ describe Gitlab::Git::Repository, :seed_helper do
context "unknown ref" do
it "returns an empty array" do
- log_commits = repository.log(options.merge(ref: 'unknown'))
+ log_commits = repository.log(options.merge(ref: "unknown"))
expect(log_commits).to eq([])
end
@@ -799,7 +798,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
context "where 'follow' == false" do
- options = { follow: false }
+ options = {follow: false}
context "and 'path' is a directory" do
let(:log_commits) do
@@ -849,7 +848,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
context "where provides 'after' timestamp" do
- options = { after: Time.iso8601('2014-03-03T20:15:01+00:00') }
+ options = {after: Time.iso8601("2014-03-03T20:15:01+00:00")}
it "should returns commits on or after that timestamp" do
commits = repository.log(options)
@@ -862,7 +861,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
context "where provides 'before' timestamp" do
- options = { before: Time.iso8601('2014-03-03T20:15:01+00:00') }
+ options = {before: Time.iso8601("2014-03-03T20:15:01+00:00")}
it "should returns commits on or before that timestamp" do
commits = repository.log(options)
@@ -874,8 +873,8 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'when multiple paths are provided' do
- let(:options) { { ref: 'master', path: ['PROCESS.md', 'README.md'] } }
+ context "when multiple paths are provided" do
+ let(:options) { {ref: "master", path: ["PROCESS.md", "README.md"]} }
def commit_files(commit)
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
@@ -885,7 +884,7 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- it 'only returns commits matching at least one path' do
+ it "only returns commits matching at least one path" do
commits = repository.log(options)
expect(commits.size).to be > 0
@@ -895,9 +894,9 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'limit validation' do
+ context "limit validation" do
where(:limit) do
- [0, nil, '', 'foo']
+ [0, nil, "", "foo"]
end
with_them do
@@ -905,70 +904,70 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with all' do
- it 'returns a list of commits' do
- commits = repository.log({ all: true, limit: 50 })
+ context "with all" do
+ it "returns a list of commits" do
+ commits = repository.log({all: true, limit: 50})
expect(commits.size).to eq(37)
end
end
end
- context 'when Gitaly find_commits feature is enabled' do
- it_behaves_like 'repository log'
+ context "when Gitaly find_commits feature is enabled" do
+ it_behaves_like "repository log"
end
end
- describe '#count_commits_between' do
- subject { repository.count_commits_between('feature', 'master') }
+ describe "#count_commits_between" do
+ subject { repository.count_commits_between("feature", "master") }
it { is_expected.to eq(17) }
end
- describe '#raw_changes_between' do
+ describe "#raw_changes_between" do
let(:old_rev) { }
let(:new_rev) { }
let(:changes) { repository.raw_changes_between(old_rev, new_rev) }
- context 'initial commit' do
+ context "initial commit" do
let(:old_rev) { Gitlab::Git::BLANK_SHA }
- let(:new_rev) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' }
+ let(:new_rev) { "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863" }
- it 'returns the changes' do
+ it "returns the changes" do
expect(changes).to be_present
expect(changes.size).to eq(3)
end
end
- context 'with an invalid rev' do
- let(:old_rev) { 'foo' }
- let(:new_rev) { 'bar' }
+ context "with an invalid rev" do
+ let(:old_rev) { "foo" }
+ let(:new_rev) { "bar" }
- it 'returns an error' do
+ it "returns an error" do
expect { changes }.to raise_error(Gitlab::Git::Repository::GitError)
end
end
- context 'with valid revs' do
- let(:old_rev) { 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6' }
- let(:new_rev) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' }
+ context "with valid revs" do
+ let(:old_rev) { "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6" }
+ let(:new_rev) { "4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6" }
- it 'returns the changes' do
+ it "returns the changes" do
expect(changes.size).to eq(9)
expect(changes.first.operation).to eq(:modified)
- expect(changes.first.new_path).to eq('.gitmodules')
+ expect(changes.first.new_path).to eq(".gitmodules")
expect(changes.last.operation).to eq(:added)
- expect(changes.last.new_path).to eq('files/lfs/picture-invalid.png')
+ expect(changes.last.new_path).to eq("files/lfs/picture-invalid.png")
end
end
end
- describe '#merge_base' do
+ describe "#merge_base" do
where(:from, :to, :result) do
- '570e7b2abdd848b95f2f578043fc23bd6f6fd24d' | '40f4a7a617393735a95a0bb67b08385bc1e7c66d' | '570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
- '40f4a7a617393735a95a0bb67b08385bc1e7c66d' | '570e7b2abdd848b95f2f578043fc23bd6f6fd24d' | '570e7b2abdd848b95f2f578043fc23bd6f6fd24d'
- '40f4a7a617393735a95a0bb67b08385bc1e7c66d' | 'foobar' | nil
- 'foobar' | '40f4a7a617393735a95a0bb67b08385bc1e7c66d' | nil
+ "570e7b2abdd848b95f2f578043fc23bd6f6fd24d" | "40f4a7a617393735a95a0bb67b08385bc1e7c66d" | "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
+ "40f4a7a617393735a95a0bb67b08385bc1e7c66d" | "570e7b2abdd848b95f2f578043fc23bd6f6fd24d" | "570e7b2abdd848b95f2f578043fc23bd6f6fd24d"
+ "40f4a7a617393735a95a0bb67b08385bc1e7c66d" | "foobar" | nil
+ "foobar" | "40f4a7a617393735a95a0bb67b08385bc1e7c66d" | nil
end
with_them do
@@ -976,63 +975,63 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#count_commits' do
- describe 'extended commit counting' do
- context 'with after timestamp' do
- it 'returns the number of commits after timestamp' do
- options = { ref: 'master', after: Time.iso8601('2013-03-03T20:15:01+00:00') }
+ describe "#count_commits" do
+ describe "extended commit counting" do
+ context "with after timestamp" do
+ it "returns the number of commits after timestamp" do
+ options = {ref: "master", after: Time.iso8601("2013-03-03T20:15:01+00:00")}
expect(repository.count_commits(options)).to eq(25)
end
end
- context 'with before timestamp' do
- it 'returns the number of commits before timestamp' do
- options = { ref: 'feature', before: Time.iso8601('2015-03-03T20:15:01+00:00') }
+ context "with before timestamp" do
+ it "returns the number of commits before timestamp" do
+ options = {ref: "feature", before: Time.iso8601("2015-03-03T20:15:01+00:00")}
expect(repository.count_commits(options)).to eq(9)
end
end
- context 'with max_count' do
- it 'returns the number of commits with path ' do
- options = { ref: 'master', max_count: 5 }
+ context "with max_count" do
+ it "returns the number of commits with path " do
+ options = {ref: "master", max_count: 5}
expect(repository.count_commits(options)).to eq(5)
end
end
- context 'with path' do
- it 'returns the number of commits with path ' do
- options = { ref: 'master', path: 'encoding' }
+ context "with path" do
+ it "returns the number of commits with path " do
+ options = {ref: "master", path: "encoding"}
expect(repository.count_commits(options)).to eq(2)
end
end
- context 'with option :from and option :to' do
- it 'returns the number of commits ahead for fix-mode..fix-blob-path' do
- options = { from: 'fix-mode', to: 'fix-blob-path' }
+ context "with option :from and option :to" do
+ it "returns the number of commits ahead for fix-mode..fix-blob-path" do
+ options = {from: "fix-mode", to: "fix-blob-path"}
expect(repository.count_commits(options)).to eq(2)
end
- it 'returns the number of commits ahead for fix-blob-path..fix-mode' do
- options = { from: 'fix-blob-path', to: 'fix-mode' }
+ it "returns the number of commits ahead for fix-blob-path..fix-mode" do
+ options = {from: "fix-blob-path", to: "fix-mode"}
expect(repository.count_commits(options)).to eq(1)
end
- context 'with option :left_right' do
- it 'returns the number of commits for fix-mode...fix-blob-path' do
- options = { from: 'fix-mode', to: 'fix-blob-path', left_right: true }
+ context "with option :left_right" do
+ it "returns the number of commits for fix-mode...fix-blob-path" do
+ options = {from: "fix-mode", to: "fix-blob-path", left_right: true}
expect(repository.count_commits(options)).to eq([1, 2])
end
- context 'with max_count' do
- it 'returns the number of commits with path ' do
- options = { from: 'fix-mode', to: 'fix-blob-path', left_right: true, max_count: 1 }
+ context "with max_count" do
+ it "returns the number of commits with path " do
+ options = {from: "fix-mode", to: "fix-blob-path", left_right: true, max_count: 1}
expect(repository.count_commits(options)).to eq([1, 1])
end
@@ -1040,9 +1039,9 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'with max_count' do
- it 'returns the number of commits up to the passed limit' do
- options = { ref: 'master', max_count: 10, after: Time.iso8601('2013-03-03T20:15:01+00:00') }
+ context "with max_count" do
+ it "returns the number of commits up to the passed limit" do
+ options = {ref: "master", max_count: 10, after: Time.iso8601("2013-03-03T20:15:01+00:00")}
expect(repository.count_commits(options)).to eq(10)
end
@@ -1050,13 +1049,13 @@ describe Gitlab::Git::Repository, :seed_helper do
context "with all" do
it "returns the number of commits in the whole repository" do
- options = { all: true }
+ options = {all: true}
expect(repository.count_commits(options)).to eq(34)
end
end
- context 'without all or ref being specified' do
+ context "without all or ref being specified" do
it "raises an ArgumentError" do
expect { repository.count_commits({}) }.to raise_error(ArgumentError)
end
@@ -1064,27 +1063,27 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#find_branch' do
- it 'should return a Branch for master' do
- branch = repository.find_branch('master')
+ describe "#find_branch" do
+ it "should return a Branch for master" do
+ branch = repository.find_branch("master")
expect(branch).to be_a_kind_of(Gitlab::Git::Branch)
- expect(branch.name).to eq('master')
+ expect(branch.name).to eq("master")
end
- it 'should handle non-existent branch' do
- branch = repository.find_branch('this-is-garbage')
+ it "should handle non-existent branch" do
+ branch = repository.find_branch("this-is-garbage")
expect(branch).to eq(nil)
end
end
- describe '#ref_name_for_sha' do
- let(:ref_path) { 'refs/heads' }
- let(:sha) { repository.find_branch('master').dereferenced_target.id }
- let(:ref_name) { 'refs/heads/master' }
+ describe "#ref_name_for_sha" do
+ let(:ref_path) { "refs/heads" }
+ let(:sha) { repository.find_branch("master").dereferenced_target.id }
+ let(:ref_name) { "refs/heads/master" }
- it 'returns the ref name for the given sha' do
+ it "returns the ref name for the given sha" do
expect(repository.ref_name_for_sha(ref_path, sha)).to eq(ref_name)
end
@@ -1101,80 +1100,80 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#branches' do
+ describe "#branches" do
subject { repository.branches }
- context 'with local and remote branches' do
+ context "with local and remote branches" do
let(:repository) { mutable_repository }
before do
- create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ create_remote_branch("joe", "remote_branch", "master")
+ repository.create_branch("local_branch", "master")
end
after do
ensure_seeds
end
- it 'returns the local and remote branches' do
- expect(subject.any? { |b| b.name == 'joe/remote_branch' }).to eq(true)
- expect(subject.any? { |b| b.name == 'local_branch' }).to eq(true)
+ it "returns the local and remote branches" do
+ expect(subject.any? { |b| b.name == "joe/remote_branch" }).to eq(true)
+ expect(subject.any? { |b| b.name == "local_branch" }).to eq(true)
end
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :branches
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RefService, :branches
end
- describe '#branch_count' do
- it 'returns the number of branches' do
+ describe "#branch_count" do
+ it "returns the number of branches" do
expect(repository.branch_count).to eq(11)
end
- context 'with local and remote branches' do
+ context "with local and remote branches" do
let(:repository) { mutable_repository }
before do
- create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ create_remote_branch("joe", "remote_branch", "master")
+ repository.create_branch("local_branch", "master")
end
after do
ensure_seeds
end
- it 'returns the count of local branches' do
+ it "returns the count of local branches" do
expect(repository.branch_count).to eq(repository.local_branches.count)
end
- context 'with Gitaly disabled' do
+ context "with Gitaly disabled" do
before do
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false)
end
- it 'returns the count of local branches' do
+ it "returns the count of local branches" do
expect(repository.branch_count).to eq(repository.local_branches.count)
end
end
end
end
- describe '#merged_branch_names' do
- context 'when branch names are passed' do
- it 'only returns the names we are asking' do
+ describe "#merged_branch_names" do
+ context "when branch names are passed" do
+ it "only returns the names we are asking" do
names = repository.merged_branch_names(%w[merge-test])
- expect(names).to contain_exactly('merge-test')
+ expect(names).to contain_exactly("merge-test")
end
- it 'does not return unmerged branch names' do
+ it "does not return unmerged branch names" do
names = repository.merged_branch_names(%w[feature])
expect(names).to be_empty
end
end
- context 'when no root ref is available' do
- it 'returns empty list' do
+ context "when no root ref is available" do
+ it "returns empty list" do
project = create(:project, :empty_repo)
names = project.repository.merged_branch_names(%w[feature])
@@ -1183,67 +1182,67 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'when no branch names are specified' do
+ context "when no branch names are specified" do
before do
- repository.create_branch('identical', 'master')
+ repository.create_branch("identical", "master")
end
after do
ensure_seeds
end
- it 'returns all merged branch names except for identical one' do
+ it "returns all merged branch names except for identical one" do
names = repository.merged_branch_names
- expect(names).to include('merge-test')
- expect(names).to include('fix-mode')
- expect(names).not_to include('feature')
- expect(names).not_to include('identical')
+ expect(names).to include("merge-test")
+ expect(names).to include("fix-mode")
+ expect(names).not_to include("feature")
+ expect(names).not_to include("identical")
end
end
end
- describe '#diff_stats' do
- let(:left_commit_id) { 'feature' }
- let(:right_commit_id) { 'master' }
+ describe "#diff_stats" do
+ let(:left_commit_id) { "feature" }
+ let(:right_commit_id) { "master" }
- it 'returns a DiffStatsCollection' do
+ it "returns a DiffStatsCollection" do
collection = repository.diff_stats(left_commit_id, right_commit_id)
expect(collection).to be_a(Gitlab::Git::DiffStatsCollection)
expect(collection).to be_a(Enumerable)
end
- it 'yields Gitaly::DiffStats objects' do
+ it "yields Gitaly::DiffStats objects" do
collection = repository.diff_stats(left_commit_id, right_commit_id)
expect(collection.to_a).to all(be_a(Gitaly::DiffStats))
end
- it 'returns no Gitaly::DiffStats when SHAs are invalid' do
- collection = repository.diff_stats('foo', 'bar')
+ it "returns no Gitaly::DiffStats when SHAs are invalid" do
+ collection = repository.diff_stats("foo", "bar")
expect(collection).to be_a(Gitlab::Git::DiffStatsCollection)
expect(collection).to be_a(Enumerable)
expect(collection.to_a).to be_empty
end
- it 'returns no Gitaly::DiffStats when there is a nil SHA' do
+ it "returns no Gitaly::DiffStats when there is a nil SHA" do
expect_any_instance_of(Gitlab::GitalyClient::CommitService)
.not_to receive(:diff_stats)
- collection = repository.diff_stats(nil, 'master')
+ collection = repository.diff_stats(nil, "master")
expect(collection).to be_a(Gitlab::Git::DiffStatsCollection)
expect(collection).to be_a(Enumerable)
expect(collection.to_a).to be_empty
end
- it 'returns no Gitaly::DiffStats when there is a BLANK_SHA' do
+ it "returns no Gitaly::DiffStats when there is a BLANK_SHA" do
expect_any_instance_of(Gitlab::GitalyClient::CommitService)
.not_to receive(:diff_stats)
- collection = repository.diff_stats(Gitlab::Git::BLANK_SHA, 'master')
+ collection = repository.diff_stats(Gitlab::Git::BLANK_SHA, "master")
expect(collection).to be_a(Gitlab::Git::DiffStatsCollection)
expect(collection).to be_a(Enumerable)
@@ -1277,12 +1276,12 @@ describe Gitlab::Git::Repository, :seed_helper do
end
it "returns valid utf-8 data" do
- expect(utf8_file_paths.map { |file| file.force_encoding('utf-8') }).to all(be_valid_encoding)
+ expect(utf8_file_paths.map { |file| file.force_encoding("utf-8") }).to all(be_valid_encoding)
end
end
describe "#copy_gitattributes" do
- let(:attributes_path) { File.join(SEED_STORAGE_PATH, TEST_REPO_PATH, 'info/attributes') }
+ let(:attributes_path) { File.join(SEED_STORAGE_PATH, TEST_REPO_PATH, "info/attributes") }
after do
FileUtils.rm_rf(attributes_path) if Dir.exist?(attributes_path)
@@ -1292,7 +1291,7 @@ describe Gitlab::Git::Repository, :seed_helper do
expect { repository.copy_gitattributes("invalid") }.to raise_error(Gitlab::Git::Repository::InvalidRef)
end
- context 'when forcing encoding issues' do
+ context "when forcing encoding issues" do
let(:branch_name) { "ʕ•ᴥ•ʔ" }
before do
@@ -1363,96 +1362,96 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#gitattribute' do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_GITATTRIBUTES_REPO_PATH, '', 'group/project') }
+ describe "#gitattribute" do
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_GITATTRIBUTES_REPO_PATH, "", "group/project") }
after do
ensure_seeds
end
- it 'returns matching language attribute' do
- expect(repository.gitattribute("custom-highlighting/test.gitlab-custom", 'gitlab-language')).to eq('ruby')
+ it "returns matching language attribute" do
+ expect(repository.gitattribute("custom-highlighting/test.gitlab-custom", "gitlab-language")).to eq("ruby")
end
- it 'returns matching language attribute with additional options' do
- expect(repository.gitattribute("custom-highlighting/test.gitlab-cgi", 'gitlab-language')).to eq('erb?parent=json')
+ it "returns matching language attribute with additional options" do
+ expect(repository.gitattribute("custom-highlighting/test.gitlab-cgi", "gitlab-language")).to eq("erb?parent=json")
end
- it 'returns nil if nothing matches' do
- expect(repository.gitattribute("report.xslt", 'gitlab-language')).to eq(nil)
+ it "returns nil if nothing matches" do
+ expect(repository.gitattribute("report.xslt", "gitlab-language")).to eq(nil)
end
- context 'without gitattributes file' do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ context "without gitattributes file" do
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
- it 'returns nil' do
- expect(repository.gitattribute("README.md", 'gitlab-language')).to eq(nil)
+ it "returns nil" do
+ expect(repository.gitattribute("README.md", "gitlab-language")).to eq(nil)
end
end
end
- describe '#ref_exists?' do
- it 'returns true for an existing tag' do
- expect(repository.ref_exists?('refs/heads/master')).to eq(true)
+ describe "#ref_exists?" do
+ it "returns true for an existing tag" do
+ expect(repository.ref_exists?("refs/heads/master")).to eq(true)
end
- it 'returns false for a non-existing tag' do
- expect(repository.ref_exists?('refs/tags/THIS_TAG_DOES_NOT_EXIST')).to eq(false)
+ it "returns false for a non-existing tag" do
+ expect(repository.ref_exists?("refs/tags/THIS_TAG_DOES_NOT_EXIST")).to eq(false)
end
- it 'raises an ArgumentError for an empty string' do
- expect { repository.ref_exists?('') }.to raise_error(ArgumentError)
+ it "raises an ArgumentError for an empty string" do
+ expect { repository.ref_exists?("") }.to raise_error(ArgumentError)
end
- it 'raises an ArgumentError for an invalid ref' do
- expect { repository.ref_exists?('INVALID') }.to raise_error(ArgumentError)
+ it "raises an ArgumentError for an invalid ref" do
+ expect { repository.ref_exists?("INVALID") }.to raise_error(ArgumentError)
end
end
- describe '#tag_exists?' do
- it 'returns true for an existing tag' do
+ describe "#tag_exists?" do
+ it "returns true for an existing tag" do
tag = repository.tag_names.first
expect(repository.tag_exists?(tag)).to eq(true)
end
- it 'returns false for a non-existing tag' do
- expect(repository.tag_exists?('v9000')).to eq(false)
+ it "returns false for a non-existing tag" do
+ expect(repository.tag_exists?("v9000")).to eq(false)
end
end
- describe '#branch_exists?' do
- it 'returns true for an existing branch' do
- expect(repository.branch_exists?('master')).to eq(true)
+ describe "#branch_exists?" do
+ it "returns true for an existing branch" do
+ expect(repository.branch_exists?("master")).to eq(true)
end
- it 'returns false for a non-existing branch' do
- expect(repository.branch_exists?('kittens')).to eq(false)
+ it "returns false for a non-existing branch" do
+ expect(repository.branch_exists?("kittens")).to eq(false)
end
- it 'returns false when using an invalid branch name' do
- expect(repository.branch_exists?('.bla')).to eq(false)
+ it "returns false when using an invalid branch name" do
+ expect(repository.branch_exists?(".bla")).to eq(false)
end
end
- describe '#local_branches' do
+ describe "#local_branches" do
let(:repository) { mutable_repository }
before do
- create_remote_branch('joe', 'remote_branch', 'master')
- repository.create_branch('local_branch', 'master')
+ create_remote_branch("joe", "remote_branch", "master")
+ repository.create_branch("local_branch", "master")
end
after do
ensure_seeds
end
- it 'returns the local branches' do
- expect(repository.local_branches.any? { |branch| branch.name == 'remote_branch' }).to eq(false)
- expect(repository.local_branches.any? { |branch| branch.name == 'local_branch' }).to eq(true)
+ it "returns the local branches" do
+ expect(repository.local_branches.any? { |branch| branch.name == "remote_branch" }).to eq(false)
+ expect(repository.local_branches.any? { |branch| branch.name == "local_branch" }).to eq(true)
end
- it 'returns a Branch with UTF-8 fields' do
+ it "returns a Branch with UTF-8 fields" do
branches = repository.local_branches.to_a
expect(branches.size).to be > 0
branches.each do |branch|
@@ -1461,25 +1460,25 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- it 'gets the branches from GitalyClient' do
+ it "gets the branches from GitalyClient" do
expect_any_instance_of(Gitlab::GitalyClient::RefService).to receive(:local_branches)
.and_return([])
repository.local_branches
end
- it_behaves_like 'wrapping gRPC errors', Gitlab::GitalyClient::RefService, :local_branches do
+ it_behaves_like "wrapping gRPC errors", Gitlab::GitalyClient::RefService, :local_branches do
subject { repository.local_branches }
end
end
- describe '#languages' do
- it 'returns exactly the expected results' do
- languages = repository.languages('4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6')
+ describe "#languages" do
+ it "returns exactly the expected results" do
+ languages = repository.languages("4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6")
expected_languages = [
- { value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
- { value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
- { value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26" },
- { value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" }
+ {value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516"},
+ {value: 22.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a"},
+ {value: 7.9, label: "HTML", color: "#e34c26", highlight: "#e34c26"},
+ {value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776"},
]
expect(languages.size).to eq(expected_languages.size)
@@ -1499,40 +1498,40 @@ describe Gitlab::Git::Repository, :seed_helper do
it "uses the repository's HEAD when no ref is passed" do
lang = repository.languages.first
- expect(lang[:label]).to eq('Ruby')
+ expect(lang[:label]).to eq("Ruby")
end
end
- describe '#license_short_name' do
+ describe "#license_short_name" do
subject { repository.license_short_name }
- context 'when no license file can be found' do
+ context "when no license file can be found" do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw_repository }
before do
- project.repository.delete_file(project.owner, 'LICENSE', message: 'remove license', branch_name: 'master')
+ project.repository.delete_file(project.owner, "LICENSE", message: "remove license", branch_name: "master")
end
it { is_expected.to be_nil }
end
- context 'when an mit license is found' do
- it { is_expected.to eq('mit') }
+ context "when an mit license is found" do
+ it { is_expected.to eq("mit") }
end
end
- describe '#fetch_source_branch!' do
- let(:local_ref) { 'refs/merge-requests/1/head' }
+ describe "#fetch_source_branch!" do
+ let(:local_ref) { "refs/merge-requests/1/head" }
let(:source_repository) { mutable_repository }
after do
ensure_seeds
end
- context 'when the branch exists' do
- context 'when the commit does not exist locally' do
- let(:source_branch) { 'new-branch-for-fetch-source-branch' }
+ context "when the branch exists" do
+ context "when the commit does not exist locally" do
+ let(:source_branch) { "new-branch-for-fetch-source-branch" }
let(:source_path) { File.join(TestEnv.repos_path, source_repository.relative_path) }
let(:source_rugged) { Rugged::Repository.new(source_path) }
let(:new_oid) { new_commit_edit_old_file(source_rugged).oid }
@@ -1541,17 +1540,17 @@ describe Gitlab::Git::Repository, :seed_helper do
source_rugged.branches.create(source_branch, new_oid)
end
- it 'writes the ref' do
+ it "writes the ref" do
expect(repository.fetch_source_branch!(source_repository, source_branch, local_ref)).to eq(true)
expect(repository.commit(local_ref).sha).to eq(new_oid)
end
end
- context 'when the commit exists locally' do
- let(:source_branch) { 'master' }
+ context "when the commit exists locally" do
+ let(:source_branch) { "master" }
let(:expected_oid) { SeedRepo::LastCommit::ID }
- it 'writes the ref' do
+ it "writes the ref" do
# Sanity check: the commit should already exist
expect(repository.commit(expected_oid)).not_to be_nil
@@ -1561,17 +1560,17 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'when the branch does not exist' do
- let(:source_branch) { 'definitely-not-master' }
+ context "when the branch does not exist" do
+ let(:source_branch) { "definitely-not-master" }
- it 'does not write the ref' do
+ it "does not write the ref" do
expect(repository.fetch_source_branch!(source_repository, source_branch, local_ref)).to eq(false)
expect(repository.commit(local_ref)).to be_nil
end
end
end
- describe '#rm_branch' do
+ describe "#rm_branch" do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw }
let(:branch_name) { "to-be-deleted-soon" }
@@ -1588,43 +1587,43 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#write_ref' do
- context 'validations' do
+ describe "#write_ref" do
+ context "validations" do
using RSpec::Parameterized::TableSyntax
where(:ref_path, :ref) do
- 'foo bar' | '123'
- 'foobar' | "12\x003"
+ "foo bar" | "123"
+ "foobar" | "12\x003"
end
with_them do
- it 'raises ArgumentError' do
+ it "raises ArgumentError" do
expect { repository.write_ref(ref_path, ref) }.to raise_error(ArgumentError)
end
end
end
- it 'writes the HEAD' do
- repository.write_ref('HEAD', 'refs/heads/feature')
+ it "writes the HEAD" do
+ repository.write_ref("HEAD", "refs/heads/feature")
- expect(repository.commit('HEAD')).to eq(repository.commit('feature'))
- expect(repository.root_ref).to eq('feature')
+ expect(repository.commit("HEAD")).to eq(repository.commit("feature"))
+ expect(repository.root_ref).to eq("feature")
end
- it 'writes other refs' do
- repository.write_ref('refs/heads/feature', SeedRepo::Commit::ID)
+ it "writes other refs" do
+ repository.write_ref("refs/heads/feature", SeedRepo::Commit::ID)
- expect(repository.commit('feature').sha).to eq(SeedRepo::Commit::ID)
+ expect(repository.commit("feature").sha).to eq(SeedRepo::Commit::ID)
end
end
- describe '#write_config' do
+ describe "#write_config" do
before do
repository_rugged.config["gitlab.fullpath"] = repository_path
end
- context 'is given a path' do
- it 'writes it to disk' do
+ context "is given a path" do
+ it "writes it to disk" do
repository.write_config(full_path: "not-the/real-path.git")
config = File.read(File.join(repository_path, "config"))
@@ -1634,8 +1633,8 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'it is given an empty path' do
- it 'does not write it to disk' do
+ context "it is given an empty path" do
+ it "does not write it to disk" do
repository.write_config(full_path: "")
config = File.read(File.join(repository_path, "config"))
@@ -1645,35 +1644,35 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- context 'repository does not exist' do
- it 'raises NoRepository and does not call Gitaly WriteConfig' do
- repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '', 'group/project')
+ context "repository does not exist" do
+ it "raises NoRepository and does not call Gitaly WriteConfig" do
+ repository = Gitlab::Git::Repository.new("default", "does/not/exist.git", "", "group/project")
expect(repository.gitaly_repository_client).not_to receive(:write_config)
- expect do
- repository.write_config(full_path: 'foo/bar.git')
- end.to raise_error(Gitlab::Git::Repository::NoRepository)
+ expect {
+ repository.write_config(full_path: "foo/bar.git")
+ }.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end
end
- describe '#set_config' do
+ describe "#set_config" do
let(:repository) { mutable_repository }
let(:entries) do
{
- 'test.foo1' => 'bla bla',
- 'test.foo2' => 1234,
- 'test.foo3' => true
+ "test.foo1" => "bla bla",
+ "test.foo2" => 1234,
+ "test.foo3" => true,
}
end
- it 'can set config settings' do
+ it "can set config settings" do
expect(repository.set_config(entries)).to be_nil
- expect(repository_rugged.config['test.foo1']).to eq('bla bla')
- expect(repository_rugged.config['test.foo2']).to eq('1234')
- expect(repository_rugged.config['test.foo3']).to eq('true')
+ expect(repository_rugged.config["test.foo1"]).to eq("bla bla")
+ expect(repository_rugged.config["test.foo2"]).to eq("1234")
+ expect(repository_rugged.config["test.foo3"]).to eq("true")
end
after do
@@ -1681,45 +1680,45 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#delete_config' do
+ describe "#delete_config" do
let(:repository) { mutable_repository }
let(:entries) do
{
- 'test.foo1' => 'bla bla',
- 'test.foo2' => 1234,
- 'test.foo3' => true
+ "test.foo1" => "bla bla",
+ "test.foo2" => 1234,
+ "test.foo3" => true,
}
end
- it 'can delete config settings' do
+ it "can delete config settings" do
entries.each do |key, value|
repository_rugged.config[key] = value
end
- expect(repository.delete_config(*%w[does.not.exist test.foo1 test.foo2])).to be_nil
+ expect(repository.delete_config("does.not.exist", "test.foo1", "test.foo2")).to be_nil
config_keys = repository_rugged.config.each_key.to_a
- expect(config_keys).not_to include('test.foo1')
- expect(config_keys).not_to include('test.foo2')
+ expect(config_keys).not_to include("test.foo1")
+ expect(config_keys).not_to include("test.foo2")
end
end
- describe '#merge_to_ref' do
+ describe "#merge_to_ref" do
let(:repository) { mutable_repository }
- let(:branch_head) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
- let(:left_sha) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
- let(:right_branch) { 'test-master' }
- let(:target_ref) { 'refs/merge-requests/999/merge' }
+ let(:branch_head) { "6d394385cf567f80a8fd85055db1ab4c5295806f" }
+ let(:left_sha) { "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" }
+ let(:right_branch) { "test-master" }
+ let(:target_ref) { "refs/merge-requests/999/merge" }
before do
repository.create_branch(right_branch, branch_head) unless repository.branch_exists?(right_branch)
end
def merge_to_ref
- repository.merge_to_ref(user, left_sha, right_branch, target_ref, 'Merge message')
+ repository.merge_to_ref(user, left_sha, right_branch, target_ref, "Merge message")
end
- it 'generates a commit in the target_ref' do
+ it "generates a commit in the target_ref" do
expect(repository.ref_exists?(target_ref)).to be(false)
commit_sha = merge_to_ref
@@ -1730,41 +1729,41 @@ describe Gitlab::Git::Repository, :seed_helper do
expect(ref_head.id).to eq(commit_sha)
end
- it 'does not change the right branch HEAD' do
+ it "does not change the right branch HEAD" do
expect { merge_to_ref }.not_to change { repository.find_branch(right_branch).target }
end
end
- describe '#merge' do
+ describe "#merge" do
let(:repository) { mutable_repository }
- let(:source_sha) { '913c66a37b4a45b9769037c55c2d238bd0942d2e' }
- let(:target_branch) { 'test-merge-target-branch' }
+ let(:source_sha) { "913c66a37b4a45b9769037c55c2d238bd0942d2e" }
+ let(:target_branch) { "test-merge-target-branch" }
before do
- repository.create_branch(target_branch, '6d394385cf567f80a8fd85055db1ab4c5295806f')
+ repository.create_branch(target_branch, "6d394385cf567f80a8fd85055db1ab4c5295806f")
end
after do
ensure_seeds
end
- it 'can perform a merge' do
+ it "can perform a merge" do
merge_commit_id = nil
- result = repository.merge(user, source_sha, target_branch, 'Test merge') do |commit_id|
+ result = repository.merge(user, source_sha, target_branch, "Test merge") { |commit_id|
merge_commit_id = commit_id
- end
+ }
expect(result.newrev).to eq(merge_commit_id)
expect(result.repo_created).to eq(false)
expect(result.branch_created).to eq(false)
end
- it 'returns nil if there was a concurrent branch update' do
- concurrent_update_id = '33f3729a45c02fc67d00adb1b8bca394b0e761d9'
- result = repository.merge(user, source_sha, target_branch, 'Test merge') do
+ it "returns nil if there was a concurrent branch update" do
+ concurrent_update_id = "33f3729a45c02fc67d00adb1b8bca394b0e761d9"
+ result = repository.merge(user, source_sha, target_branch, "Test merge") {
# This ref update should make the merge fail
repository.write_ref(Gitlab::Git::BRANCH_REF_PREFIX + target_branch, concurrent_update_id)
- end
+ }
# This 'nil' signals that the merge was not applied
expect(result).to be_nil
@@ -1774,11 +1773,11 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#ff_merge' do
+ describe "#ff_merge" do
let(:repository) { mutable_repository }
- let(:branch_head) { '6d394385cf567f80a8fd85055db1ab4c5295806f' }
- let(:source_sha) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
- let(:target_branch) { 'test-ff-target-branch' }
+ let(:branch_head) { "6d394385cf567f80a8fd85055db1ab4c5295806f" }
+ let(:source_sha) { "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" }
+ let(:target_branch) { "test-ff-target-branch" }
before do
repository.create_branch(target_branch, branch_head)
@@ -1790,8 +1789,8 @@ describe Gitlab::Git::Repository, :seed_helper do
subject { repository.ff_merge(user, source_sha, target_branch) }
- shared_examples '#ff_merge' do
- it 'performs a ff_merge' do
+ shared_examples "#ff_merge" do
+ it "performs a ff_merge" do
expect(subject.newrev).to eq(source_sha)
expect(subject.repo_created).to be(false)
expect(subject.branch_created).to be(false)
@@ -1799,24 +1798,24 @@ describe Gitlab::Git::Repository, :seed_helper do
expect(repository.commit(target_branch).id).to eq(source_sha)
end
- context 'with a non-existing target branch' do
- subject { repository.ff_merge(user, source_sha, 'this-isnt-real') }
+ context "with a non-existing target branch" do
+ subject { repository.ff_merge(user, source_sha, "this-isnt-real") }
- it 'throws an ArgumentError' do
+ it "throws an ArgumentError" do
expect { subject }.to raise_error(ArgumentError)
end
end
- context 'with a non-existing source commit' do
- let(:source_sha) { 'f001' }
+ context "with a non-existing source commit" do
+ let(:source_sha) { "f001" }
- it 'throws an ArgumentError' do
+ it "throws an ArgumentError" do
expect { subject }.to raise_error(ArgumentError)
end
end
- context 'when the source sha is not a descendant of the branch head' do
- let(:source_sha) { '1a0b36b3cdad1d2ee32457c102a8c0b7056fa863' }
+ context "when the source sha is not a descendant of the branch head" do
+ let(:source_sha) { "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863" }
it "doesn't perform the ff_merge" do
expect { subject }.to raise_error(Gitlab::Git::CommitError)
@@ -1834,10 +1833,10 @@ describe Gitlab::Git::Repository, :seed_helper do
subject
end
- it_behaves_like '#ff_merge'
+ it_behaves_like "#ff_merge"
end
- describe '#delete_all_refs_except' do
+ describe "#delete_all_refs_except" do
let(:repository) { mutable_repository }
before do
@@ -1851,8 +1850,8 @@ describe Gitlab::Git::Repository, :seed_helper do
ensure_seeds
end
- it 'deletes all refs except those with the specified prefixes' do
- repository.delete_all_refs_except(%w(refs/keep refs/also-keep refs/heads))
+ it "deletes all refs except those with the specified prefixes" do
+ repository.delete_all_refs_except(%w[refs/keep refs/also-keep refs/heads])
expect(repository.ref_exists?("refs/delete/a")).to be(false)
expect(repository.ref_exists?("refs/also-delete/b")).to be(false)
expect(repository.ref_exists?("refs/keep/c")).to be(true)
@@ -1861,19 +1860,19 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe 'remotes' do
+ describe "remotes" do
let(:repository) { mutable_repository }
- let(:remote_name) { 'my-remote' }
- let(:url) { 'http://my-repo.git' }
+ let(:remote_name) { "my-remote" }
+ let(:url) { "http://my-repo.git" }
after do
ensure_seeds
end
- describe '#add_remote' do
- let(:mirror_refmap) { '+refs/*:refs/*' }
+ describe "#add_remote" do
+ let(:mirror_refmap) { "+refs/*:refs/*" }
- it 'added the remote' do
+ it "added the remote" do
begin
repository_rugged.remotes.delete(remote_name)
rescue Rugged::ConfigError
@@ -1882,14 +1881,14 @@ describe Gitlab::Git::Repository, :seed_helper do
repository.add_remote(remote_name, url, mirror_refmap: mirror_refmap)
expect(repository_rugged.remotes[remote_name]).not_to be_nil
- expect(repository_rugged.config["remote.#{remote_name}.mirror"]).to eq('true')
- expect(repository_rugged.config["remote.#{remote_name}.prune"]).to eq('true')
+ expect(repository_rugged.config["remote.#{remote_name}.mirror"]).to eq("true")
+ expect(repository_rugged.config["remote.#{remote_name}.prune"]).to eq("true")
expect(repository_rugged.config["remote.#{remote_name}.fetch"]).to eq(mirror_refmap)
end
end
- describe '#remove_remote' do
- it 'removes the remote' do
+ describe "#remove_remote" do
+ it "removes the remote" do
repository_rugged.remotes.create(remote_name, url)
repository.remove_remote(remote_name)
@@ -1899,27 +1898,27 @@ describe Gitlab::Git::Repository, :seed_helper do
end
end
- describe '#bundle_to_disk' do
+ describe "#bundle_to_disk" do
let(:save_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
after do
FileUtils.rm_rf(save_path)
end
- it 'saves a bundle to disk' do
+ it "saves a bundle to disk" do
repository.bundle_to_disk(save_path)
success = system(
- *%W(#{Gitlab.config.git.bin_path} -C #{repository_path} bundle verify #{save_path}),
- [:out, :err] => '/dev/null'
+ Gitlab.config.git.bin_path.to_s, "-C", repository_path.to_s, "bundle", "verify", save_path.to_s,
+ [:out, :err] => "/dev/null"
)
expect(success).to be true
end
end
- describe '#create_from_bundle' do
+ describe "#create_from_bundle" do
let(:valid_bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
- let(:malicious_bundle_path) { Rails.root.join('spec/fixtures/malicious.bundle') }
+ let(:malicious_bundle_path) { Rails.root.join("spec/fixtures/malicious.bundle") }
let(:project) { create(:project) }
let(:imported_repo) { project.repository.raw }
@@ -1931,7 +1930,7 @@ describe Gitlab::Git::Repository, :seed_helper do
FileUtils.rm_rf(valid_bundle_path)
end
- it 'creates a repo from a bundle file' do
+ it "creates a repo from a bundle file" do
expect(imported_repo).not_to exist
result = imported_repo.create_from_bundle(valid_bundle_path)
@@ -1941,71 +1940,71 @@ describe Gitlab::Git::Repository, :seed_helper do
expect { imported_repo.fsck }.not_to raise_exception
end
- it 'creates a symlink to the global hooks dir' do
+ it "creates a symlink to the global hooks dir" do
imported_repo.create_from_bundle(valid_bundle_path)
- hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
+ hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, "hooks") }
expect(File.readlink(hooks_path)).to eq(Gitlab::Shell.new.hooks_path)
end
- it 'raises an error if the bundle is an attempted malicious payload' do
- expect do
+ it "raises an error if the bundle is an attempted malicious payload" do
+ expect {
imported_repo.create_from_bundle(malicious_bundle_path)
- end.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError)
+ }.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError)
end
end
- describe '#checksum' do
- it 'calculates the checksum for non-empty repo' do
- expect(repository.checksum).to eq '51d0a9662681f93e1fee547a6b7ba2bcaf716059'
+ describe "#checksum" do
+ it "calculates the checksum for non-empty repo" do
+ expect(repository.checksum).to eq "51d0a9662681f93e1fee547a6b7ba2bcaf716059"
end
- it 'returns 0000000000000000000000000000000000000000 for an empty repo' do
- FileUtils.rm_rf(File.join(storage_path, 'empty-repo.git'))
+ it "returns 0000000000000000000000000000000000000000 for an empty repo" do
+ FileUtils.rm_rf(File.join(storage_path, "empty-repo.git"))
- system(git_env, *%W(#{Gitlab.config.git.bin_path} init --bare empty-repo.git),
- chdir: storage_path,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "init", "--bare", "empty-repo.git",
+ chdir: storage_path,
+ out: "/dev/null",
+ err: "/dev/null")
- empty_repo = described_class.new('default', 'empty-repo.git', '', 'group/empty-repo')
+ empty_repo = described_class.new("default", "empty-repo.git", "", "group/empty-repo")
- expect(empty_repo.checksum).to eq '0000000000000000000000000000000000000000'
+ expect(empty_repo.checksum).to eq "0000000000000000000000000000000000000000"
end
- it 'raises Gitlab::Git::Repository::InvalidRepository error for non-valid git repo' do
- FileUtils.rm_rf(File.join(storage_path, 'non-valid.git'))
+ it "raises Gitlab::Git::Repository::InvalidRepository error for non-valid git repo" do
+ FileUtils.rm_rf(File.join(storage_path, "non-valid.git"))
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} non-valid.git),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "--bare", TEST_REPO_PATH.to_s, "non-valid.git",
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
- File.truncate(File.join(storage_path, 'non-valid.git/HEAD'), 0)
+ File.truncate(File.join(storage_path, "non-valid.git/HEAD"), 0)
- non_valid = described_class.new('default', 'non-valid.git', '', 'a/non-valid')
+ non_valid = described_class.new("default", "non-valid.git", "", "a/non-valid")
expect { non_valid.checksum }.to raise_error(Gitlab::Git::Repository::InvalidRepository)
end
- it 'raises Gitlab::Git::Repository::NoRepository error when there is no repo' do
- broken_repo = described_class.new('default', 'a/path.git', '', 'a/path')
+ it "raises Gitlab::Git::Repository::NoRepository error when there is no repo" do
+ broken_repo = described_class.new("default", "a/path.git", "", "a/path")
expect { broken_repo.checksum }.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end
- describe '#clean_stale_repository_files' do
- let(:worktree_path) { File.join(repository_path, 'worktrees', 'delete-me') }
+ describe "#clean_stale_repository_files" do
+ let(:worktree_path) { File.join(repository_path, "worktrees", "delete-me") }
- it 'cleans up the files' do
+ it "cleans up the files" do
create_worktree = %W[git -C #{repository_path} worktree add --detach #{worktree_path} master]
- raise 'preparation failed' unless system(*create_worktree, err: '/dev/null')
+ raise "preparation failed" unless system(*create_worktree, err: "/dev/null")
FileUtils.touch(worktree_path, mtime: Time.now - 8.hours)
# git rev-list --all will fail in git 2.16 if HEAD is pointing to a non-existent object,
# but the HEAD must be 40 characters long or git will ignore it.
- File.write(File.join(worktree_path, 'HEAD'), Gitlab::Git::BLANK_SHA)
+ File.write(File.join(worktree_path, "HEAD"), Gitlab::Git::BLANK_SHA)
# git 2.16 fails with "fatal: bad object HEAD"
expect(rev_list_all).to be false
@@ -2017,27 +2016,27 @@ describe Gitlab::Git::Repository, :seed_helper do
end
def rev_list_all
- system(*%W[git -C #{repository_path} rev-list --all], out: '/dev/null', err: '/dev/null')
+ system("git", "-C", repository_path.to_s, "rev-list", "--all", out: "/dev/null", err: "/dev/null")
end
- it 'increments a counter upon an error' do
+ it "increments a counter upon an error" do
expect(repository.gitaly_repository_client).to receive(:cleanup).and_raise(Gitlab::Git::CommandError)
counter = double(:counter)
expect(counter).to receive(:increment)
expect(Gitlab::Metrics).to receive(:counter).with(:failed_repository_cleanup_total,
- 'Number of failed repository cleanup events').and_return(counter)
+ "Number of failed repository cleanup events").and_return(counter)
repository.clean_stale_repository_files
end
end
- describe '#squash' do
- let(:squash_id) { '1' }
- let(:branch_name) { 'fix' }
- let(:start_sha) { '4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6' }
- let(:end_sha) { '12d65c8dd2b2676fa3ac47d955accc085a37a9c1' }
+ describe "#squash" do
+ let(:squash_id) { "1" }
+ let(:branch_name) { "fix" }
+ let(:start_sha) { "4b4918a572fa86f9771e5ba40fbd48e1eb03e2c6" }
+ let(:end_sha) { "12d65c8dd2b2676fa3ac47d955accc085a37a9c1" }
subject do
opts = {
@@ -2045,24 +2044,24 @@ describe Gitlab::Git::Repository, :seed_helper do
start_sha: start_sha,
end_sha: end_sha,
author: user,
- message: 'Squash commit message'
+ message: "Squash commit message",
}
repository.squash(user, squash_id, opts)
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
- skip 'sparse checkout' do
- let(:expected_files) { %w(files files/js files/js/application.js) }
+ skip "sparse checkout" do
+ let(:expected_files) { %w[files files/js files/js/application.js] }
- it 'checks out only the files in the diff' do
+ it "checks out only the files in the diff" do
allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args|
m.call(*args) do
worktree_path = args[0]
- files_pattern = File.join(worktree_path, '**', '*')
- expected = expected_files.map do |path|
+ files_pattern = File.join(worktree_path, "**", "*")
+ expected = expected_files.map { |path|
File.expand_path(path, worktree_path)
- end
+ }
expect(Dir[files_pattern]).to eq(expected)
end
@@ -2071,22 +2070,22 @@ describe Gitlab::Git::Repository, :seed_helper do
subject
end
- context 'when the diff contains a rename' do
+ context "when the diff contains a rename" do
let(:end_sha) { new_commit_move_file(repository_rugged).oid }
after do
# Erase our commits so other tests get the original repo
- repository_rugged.references.update('refs/heads/master', SeedRepo::LastCommit::ID)
+ repository_rugged.references.update("refs/heads/master", SeedRepo::LastCommit::ID)
end
- it 'does not include the renamed file in the sparse checkout' do
+ it "does not include the renamed file in the sparse checkout" do
allow(repository).to receive(:with_worktree).and_wrap_original do |m, *args|
m.call(*args) do
worktree_path = args[0]
- files_pattern = File.join(worktree_path, '**', '*')
+ files_pattern = File.join(worktree_path, "**", "*")
- expect(Dir[files_pattern]).not_to include('CHANGELOG')
- expect(Dir[files_pattern]).not_to include('encoding/CHANGELOG')
+ expect(Dir[files_pattern]).not_to include("CHANGELOG")
+ expect(Dir[files_pattern]).not_to include("encoding/CHANGELOG")
end
end
@@ -2096,28 +2095,28 @@ describe Gitlab::Git::Repository, :seed_helper do
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
- skip 'with an ASCII-8BIT diff' do
+ skip "with an ASCII-8BIT diff" do
let(:diff) { "diff --git a/README.md b/README.md\nindex faaf198..43c5edf 100644\n--- a/README.md\n+++ b/README.md\n@@ -1,4 +1,4 @@\n-testme\n+✓ testme\n ======\n \n Sample repo for testing gitlab features\n" }
- it 'applies a ASCII-8BIT diff' do
+ it "applies a ASCII-8BIT diff" do
allow(repository).to receive(:run_git!).and_call_original
- allow(repository).to receive(:run_git!).with(%W(diff --binary #{start_sha}...#{end_sha})).and_return(diff.force_encoding('ASCII-8BIT'))
+ allow(repository).to receive(:run_git!).with(%W[diff --binary #{start_sha}...#{end_sha}]).and_return(diff.force_encoding("ASCII-8BIT"))
expect(subject).to match(/\h{40}/)
end
end
# Should be ported to gitaly-ruby rspec suite https://gitlab.com/gitlab-org/gitaly/issues/1234
- skip 'with trailing whitespace in an invalid patch' do
+ skip "with trailing whitespace in an invalid patch" do
let(:diff) { "diff --git a/README.md b/README.md\nindex faaf198..43c5edf 100644\n--- a/README.md\n+++ b/README.md\n@@ -1,4 +1,4 @@\n-testme\n+ \n ====== \n \n Sample repo for testing gitlab features\n" }
- it 'does not include whitespace warnings in the error' do
+ it "does not include whitespace warnings in the error" do
allow(repository).to receive(:run_git!).and_call_original
- allow(repository).to receive(:run_git!).with(%W(diff --binary #{start_sha}...#{end_sha})).and_return(diff.force_encoding('ASCII-8BIT'))
+ allow(repository).to receive(:run_git!).with(%W[diff --binary #{start_sha}...#{end_sha}]).and_return(diff.force_encoding("ASCII-8BIT"))
expect { subject }.to raise_error do |error|
expect(error).to be_a(described_class::GitError)
- expect(error.message).not_to include('trailing whitespace')
+ expect(error.message).not_to include("trailing whitespace")
end
end
end
@@ -2135,12 +2134,12 @@ describe Gitlab::Git::Repository, :seed_helper do
options[:author] = {
email: "test@example.com",
name: "Test Author",
- time: Time.gm(2014, "mar", 3, 20, 15, 1)
+ time: Time.gm(2014, "mar", 3, 20, 15, 1),
}
options[:committer] = {
email: "test@example.com",
name: "Test Author",
- time: Time.gm(2014, "mar", 3, 20, 15, 1)
+ time: Time.gm(2014, "mar", 3, 20, 15, 1),
}
options[:message] ||= message
options[:parents] = repo.empty? ? [] : [target].compact
@@ -2155,7 +2154,7 @@ describe Gitlab::Git::Repository, :seed_helper do
oid = repo.write("I replaced the changelog with this text", :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
- index.add(path: "CHANGELOG", oid: oid, mode: 0100644)
+ index.add(path: "CHANGELOG", oid: oid, mode: 0o100644)
options = commit_options(
repo,
@@ -2175,7 +2174,7 @@ describe Gitlab::Git::Repository, :seed_helper do
oid = repo.write(text, :blob)
index = repo.index
index.read_tree(branch.target.tree)
- index.add(path: file_path, oid: oid, mode: 0100644)
+ index.add(path: file_path, oid: oid, mode: 0o100644)
options = commit_options(repo, index, branch.target, branch.canonical_name, commit_message)
sha = Rugged::Commit.create(repo, options)
repo.lookup(sha)
@@ -2196,7 +2195,7 @@ describe Gitlab::Git::Repository, :seed_helper do
oid = repo.write(file_content, :blob)
index = repo.index
index.read_tree(repo.head.target.tree)
- index.add(path: "encoding/CHANGELOG", oid: oid, mode: 0100644)
+ index.add(path: "encoding/CHANGELOG", oid: oid, mode: 0o100644)
index.remove("CHANGELOG")
options = commit_options(repo, index, repo.head.target, "HEAD", "Move CHANGELOG to encoding/")
diff --git a/spec/lib/gitlab/git/tag_spec.rb b/spec/lib/gitlab/git/tag_spec.rb
index 4c0291f64f0..8afdedc9358 100644
--- a/spec/lib/gitlab/git/tag_spec.rb
+++ b/spec/lib/gitlab/git/tag_spec.rb
@@ -1,10 +1,10 @@
require "spec_helper"
describe Gitlab::Git::Tag, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
- describe '#tags' do
- describe 'first tag' do
+ describe "#tags" do
+ describe "first tag" do
let(:tag) { repository.tags.first }
it { expect(tag.name).to eq("v1.0.0") }
@@ -13,7 +13,7 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(tag.message).to eq("Release") }
end
- describe 'last tag' do
+ describe "last tag" do
let(:tag) { repository.tags.last }
it { expect(tag.name).to eq("v1.2.1") }
@@ -25,19 +25,19 @@ describe Gitlab::Git::Tag, :seed_helper do
it { expect(repository.tags.size).to eq(SeedRepo::Repo::TAGS.size) }
end
- describe '.get_message' do
+ describe ".get_message" do
let(:tag_ids) { %w[f4e6814c3e4e7a0de82a9e7cd20c626cc963a2f8 8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b] }
subject do
tag_ids.map { |id| described_class.get_message(repository, id) }
end
- it 'gets tag messages' do
+ it "gets tag messages" do
expect(subject[0]).to eq("Release\n")
expect(subject[1]).to eq("Version 1.1.0\n")
end
- it 'gets messages in one batch', :request_store do
+ it "gets messages in one batch", :request_store do
other_repository = double(:repository)
described_class.get_message(other_repository, tag_ids.first)
@@ -45,25 +45,25 @@ describe Gitlab::Git::Tag, :seed_helper do
end
end
- describe 'tag into from Gitaly tag' do
- context 'message_size != message.size' do
- let(:gitaly_tag) { build(:gitaly_tag, message: ''.b, message_size: message_size) }
+ describe "tag into from Gitaly tag" do
+ context "message_size != message.size" do
+ let(:gitaly_tag) { build(:gitaly_tag, message: "".b, message_size: message_size) }
let(:tag) { described_class.new(repository, gitaly_tag) }
- context 'message_size less than threshold' do
+ context "message_size less than threshold" do
let(:message_size) { 123 }
- it 'fetches tag message separately' do
+ it "fetches tag message separately" do
expect(described_class).to receive(:get_message).with(repository, gitaly_tag.id)
tag.message
end
end
- context 'message_size greater than threshold' do
+ context "message_size greater than threshold" do
let(:message_size) { described_class::MAX_TAG_MESSAGE_DISPLAY_SIZE + 1 }
- it 'returns a notice about message size' do
+ it "returns a notice about message size" do
expect(tag.message).to eq("--tag message is too big")
end
end
diff --git a/spec/lib/gitlab/git/tree_spec.rb b/spec/lib/gitlab/git/tree_spec.rb
index 4a4d69490a3..3f19af5cc3a 100644
--- a/spec/lib/gitlab/git/tree_spec.rb
+++ b/spec/lib/gitlab/git/tree_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe Gitlab::Git::Tree, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
context :repo do
let(:tree) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID) }
@@ -12,76 +12,76 @@ describe Gitlab::Git::Tree, :seed_helper do
it { expect(tree.select(&:file?).size).to eq(10) }
it { expect(tree.select(&:submodule?).size).to eq(2) }
- describe '#dir?' do
+ describe "#dir?" do
let(:dir) { tree.select(&:dir?).first }
it { expect(dir).to be_kind_of Gitlab::Git::Tree }
- it { expect(dir.id).to eq('3c122d2b7830eca25235131070602575cf8b41a1') }
+ it { expect(dir.id).to eq("3c122d2b7830eca25235131070602575cf8b41a1") }
it { expect(dir.commit_id).to eq(SeedRepo::Commit::ID) }
- it { expect(dir.name).to eq('encoding') }
- it { expect(dir.path).to eq('encoding') }
- it { expect(dir.flat_path).to eq('encoding') }
- it { expect(dir.mode).to eq('40000') }
+ it { expect(dir.name).to eq("encoding") }
+ it { expect(dir.path).to eq("encoding") }
+ it { expect(dir.flat_path).to eq("encoding") }
+ it { expect(dir.mode).to eq("40000") }
context :subdir do
- let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files').first }
+ let(:subdir) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, "files").first }
it { expect(subdir).to be_kind_of Gitlab::Git::Tree }
- it { expect(subdir.id).to eq('a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba') }
+ it { expect(subdir.id).to eq("a1e8f8d745cc87e3a9248358d9352bb7f9a0aeba") }
it { expect(subdir.commit_id).to eq(SeedRepo::Commit::ID) }
- it { expect(subdir.name).to eq('html') }
- it { expect(subdir.path).to eq('files/html') }
- it { expect(subdir.flat_path).to eq('files/html') }
+ it { expect(subdir.name).to eq("html") }
+ it { expect(subdir.path).to eq("files/html") }
+ it { expect(subdir.flat_path).to eq("files/html") }
end
context :subdir_file do
- let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
+ let(:subdir_file) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, "files/ruby").first }
it { expect(subdir_file).to be_kind_of Gitlab::Git::Tree }
- it { expect(subdir_file.id).to eq('7e3e39ebb9b2bf433b4ad17313770fbe4051649c') }
+ it { expect(subdir_file.id).to eq("7e3e39ebb9b2bf433b4ad17313770fbe4051649c") }
it { expect(subdir_file.commit_id).to eq(SeedRepo::Commit::ID) }
- it { expect(subdir_file.name).to eq('popen.rb') }
- it { expect(subdir_file.path).to eq('files/ruby/popen.rb') }
- it { expect(subdir_file.flat_path).to eq('files/ruby/popen.rb') }
+ it { expect(subdir_file.name).to eq("popen.rb") }
+ it { expect(subdir_file.path).to eq("files/ruby/popen.rb") }
+ it { expect(subdir_file.flat_path).to eq("files/ruby/popen.rb") }
end
end
- describe '#file?' do
+ describe "#file?" do
let(:file) { tree.select(&:file?).first }
it { expect(file).to be_kind_of Gitlab::Git::Tree }
- it { expect(file.id).to eq('dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82') }
+ it { expect(file.id).to eq("dfaa3f97ca337e20154a98ac9d0be76ddd1fcc82") }
it { expect(file.commit_id).to eq(SeedRepo::Commit::ID) }
- it { expect(file.name).to eq('.gitignore') }
+ it { expect(file.name).to eq(".gitignore") }
end
- describe '#readme?' do
+ describe "#readme?" do
let(:file) { tree.select(&:readme?).first }
it { expect(file).to be_kind_of Gitlab::Git::Tree }
- it { expect(file.name).to eq('README.md') }
+ it { expect(file.name).to eq("README.md") }
end
- describe '#contributing?' do
+ describe "#contributing?" do
let(:file) { tree.select(&:contributing?).first }
it { expect(file).to be_kind_of Gitlab::Git::Tree }
- it { expect(file.name).to eq('CONTRIBUTING.md') }
+ it { expect(file.name).to eq("CONTRIBUTING.md") }
end
- describe '#submodule?' do
+ describe "#submodule?" do
let(:submodule) { tree.select(&:submodule?).first }
it { expect(submodule).to be_kind_of Gitlab::Git::Tree }
- it { expect(submodule.id).to eq('79bceae69cb5750d6567b223597999bfa91cb3b9') }
- it { expect(submodule.commit_id).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- it { expect(submodule.name).to eq('gitlab-shell') }
+ it { expect(submodule.id).to eq("79bceae69cb5750d6567b223597999bfa91cb3b9") }
+ it { expect(submodule.commit_id).to eq("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ it { expect(submodule.name).to eq("gitlab-shell") }
end
end
- describe '#where' do
- it 'returns an empty array when called with an invalid ref' do
- expect(described_class.where(repository, 'foobar-does-not-exist')).to eq([])
+ describe "#where" do
+ it "returns an empty array when called with an invalid ref" do
+ expect(described_class.where(repository, "foobar-does-not-exist")).to eq([])
end
end
end
diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb
index d9d338206f8..39c755d03ab 100644
--- a/spec/lib/gitlab/git/user_spec.rb
+++ b/spec/lib/gitlab/git/user_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::User do
- let(:username) { 'janedoe' }
- let(:name) { 'Jane Doé' }
- let(:email) { 'janedoé@example.com' }
- let(:gl_id) { 'user-123' }
+ let(:username) { "janedoe" }
+ let(:name) { "Jane Doé" }
+ let(:email) { "janedoé@example.com" }
+ let(:gl_id) { "user-123" }
let(:user) do
described_class.new(username, name, email, gl_id)
end
subject { described_class.new(username, name, email, gl_id) }
- describe '.from_gitaly' do
+ describe ".from_gitaly" do
let(:gitaly_user) do
Gitaly::User.new(gl_username: username, name: name.b, email: email.b, gl_id: gl_id)
end
@@ -21,23 +21,23 @@ describe Gitlab::Git::User do
it { expect(subject).to eq(user) }
end
- describe '.from_gitlab' do
- context 'when no commit_email has been set' do
- let(:user) { build(:user, email: 'alice@example.com', commit_email: nil) }
+ describe ".from_gitlab" do
+ context "when no commit_email has been set" do
+ let(:user) { build(:user, email: "alice@example.com", commit_email: nil) }
subject { described_class.from_gitlab(user) }
- it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-')) }
+ it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, "user-")) }
end
- context 'when commit_email has been set' do
- let(:user) { build(:user, email: 'alice@example.com', commit_email: 'bob@example.com') }
+ context "when commit_email has been set" do
+ let(:user) { build(:user, email: "alice@example.com", commit_email: "bob@example.com") }
subject { described_class.from_gitlab(user) }
- it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, 'user-')) }
+ it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, "user-")) }
end
end
- describe '#==' do
+ describe "#==" do
def eq_other(username, name, email, gl_id)
eq(described_class.new(username, name, email, gl_id))
end
@@ -45,16 +45,16 @@ describe Gitlab::Git::User do
it { expect(subject).to eq_other(username, name, email, gl_id) }
it { expect(subject).not_to eq_other(nil, nil, nil, nil) }
- it { expect(subject).not_to eq_other(username + 'x', name, email, gl_id) }
- it { expect(subject).not_to eq_other(username, name + 'x', email, gl_id) }
- it { expect(subject).not_to eq_other(username, name, email + 'x', gl_id) }
- it { expect(subject).not_to eq_other(username, name, email, gl_id + 'x') }
+ it { expect(subject).not_to eq_other(username + "x", name, email, gl_id) }
+ it { expect(subject).not_to eq_other(username, name + "x", email, gl_id) }
+ it { expect(subject).not_to eq_other(username, name, email + "x", gl_id) }
+ it { expect(subject).not_to eq_other(username, name, email, gl_id + "x") }
end
- describe '#to_gitaly' do
+ describe "#to_gitaly" do
subject { user.to_gitaly }
- it 'creates a Gitaly::User with the correct data' do
+ it "creates a Gitaly::User with the correct data" do
expect(subject).to be_a(Gitaly::User)
expect(subject.gl_username).to eq(username)
diff --git a/spec/lib/gitlab/git/util_spec.rb b/spec/lib/gitlab/git/util_spec.rb
index 88c871855df..06006195c70 100644
--- a/spec/lib/gitlab/git/util_spec.rb
+++ b/spec/lib/gitlab/git/util_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::Util do
- describe '#count_lines' do
+ describe "#count_lines" do
[
["", 0],
["foo", 1],
["foo\n", 1],
- ["foo\n\n", 2]
+ ["foo\n\n", 2],
].each do |string, line_count|
it "counts #{line_count} lines in #{string.inspect}" do
expect(described_class.count_lines(string)).to eq(line_count)
diff --git a/spec/lib/gitlab/git/wiki_spec.rb b/spec/lib/gitlab/git/wiki_spec.rb
index ded5d7576df..02cd617db3d 100644
--- a/spec/lib/gitlab/git/wiki_spec.rb
+++ b/spec/lib/gitlab/git/wiki_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::Wiki do
using RSpec::Parameterized::TableSyntax
@@ -9,79 +9,79 @@ describe Gitlab::Git::Wiki do
subject(:wiki) { project_wiki.wiki }
- describe '#pages' do
+ describe "#pages" do
before do
- create_page('page1', 'content')
- create_page('page2', 'content2')
+ create_page("page1", "content")
+ create_page("page2", "content2")
end
after do
- destroy_page('page1')
- destroy_page('page2')
+ destroy_page("page1")
+ destroy_page("page2")
end
- it 'returns all the pages' do
+ it "returns all the pages" do
expect(subject.pages.count).to eq(2)
- expect(subject.pages.first.title).to eq 'page1'
- expect(subject.pages.last.title).to eq 'page2'
+ expect(subject.pages.first.title).to eq "page1"
+ expect(subject.pages.last.title).to eq "page2"
end
- it 'returns only one page' do
+ it "returns only one page" do
pages = subject.pages(limit: 1)
expect(pages.count).to eq(1)
- expect(pages.first.title).to eq 'page1'
+ expect(pages.first.title).to eq "page1"
end
end
- describe '#page' do
+ describe "#page" do
before do
- create_page('page1', 'content')
- create_page('foo/page1', 'content foo/page1')
+ create_page("page1", "content")
+ create_page("foo/page1", "content foo/page1")
end
after do
- destroy_page('page1')
- destroy_page('page1', 'foo')
+ destroy_page("page1")
+ destroy_page("page1", "foo")
end
- it 'returns the right page' do
- expect(subject.page(title: 'page1', dir: '').url_path).to eq 'page1'
- expect(subject.page(title: 'page1', dir: 'foo').url_path).to eq 'foo/page1'
+ it "returns the right page" do
+ expect(subject.page(title: "page1", dir: "").url_path).to eq "page1"
+ expect(subject.page(title: "page1", dir: "foo").url_path).to eq "foo/page1"
end
end
- describe '#delete_page' do
+ describe "#delete_page" do
after do
- destroy_page('page1')
+ destroy_page("page1")
end
- it 'only removes the page with the same path' do
- create_page('page1', 'content')
- create_page('*', 'content')
+ it "only removes the page with the same path" do
+ create_page("page1", "content")
+ create_page("*", "content")
- subject.delete_page('*', commit_details('whatever'))
+ subject.delete_page("*", commit_details("whatever"))
expect(subject.pages.count).to eq 1
- expect(subject.pages.first.title).to eq 'page1'
+ expect(subject.pages.first.title).to eq "page1"
end
end
- describe '#preview_slug' do
+ describe "#preview_slug" do
where(:title, :format, :expected_slug) do
- 'The Best Thing' | :markdown | 'The-Best-Thing'
- 'The Best Thing' | :md | 'The-Best-Thing'
- 'The Best Thing' | :txt | 'The-Best-Thing'
- 'A Subject/Title Here' | :txt | 'A-Subject/Title-Here'
- 'A subject' | :txt | 'A-subject'
- 'A 1/B 2/C 3' | :txt | 'A-1/B-2/C-3'
- 'subject/title' | :txt | 'subject/title'
- 'subject/title.md' | :txt | 'subject/title.md'
- 'foo<bar>+baz' | :txt | 'foo-bar--baz'
- 'foo%2Fbar' | :txt | 'foo%2Fbar'
- '' | :markdown | '.md'
- '' | :md | '.md'
- '' | :txt | '.txt'
+ "The Best Thing" | :markdown | "The-Best-Thing"
+ "The Best Thing" | :md | "The-Best-Thing"
+ "The Best Thing" | :txt | "The-Best-Thing"
+ "A Subject/Title Here" | :txt | "A-Subject/Title-Here"
+ "A subject" | :txt | "A-subject"
+ "A 1/B 2/C 3" | :txt | "A-1/B-2/C-3"
+ "subject/title" | :txt | "subject/title"
+ "subject/title.md" | :txt | "subject/title.md"
+ "foo<bar>+baz" | :txt | "foo-bar--baz"
+ "foo%2Fbar" | :txt | "foo%2Fbar"
+ "" | :markdown | ".md"
+ "" | :md | ".md"
+ "" | :txt | ".txt"
end
with_them do
@@ -91,10 +91,10 @@ describe Gitlab::Git::Wiki do
it { is_expected.to eq(expected_slug) }
- it 'matches the slug generated by gitaly' do
- skip('Gitaly cannot generate a slug for an empty title') unless title.present?
+ it "matches the slug generated by gitaly" do
+ skip("Gitaly cannot generate a slug for an empty title") unless title.present?
- create_page(title, 'content', format: format)
+ create_page(title, "content", format: format)
gitaly_slug = wiki.pages.first.url_path
@@ -111,7 +111,7 @@ describe Gitlab::Git::Wiki do
Gitlab::Git::Wiki::CommitDetails.new(user.id, user.username, user.name, user.email, "created page #{name}")
end
- def destroy_page(title, dir = '')
+ def destroy_page(title, dir = "")
page = wiki.page(title: title, dir: dir)
project_wiki.delete_page(page, "test commit")
end
diff --git a/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
index bcf4814edb6..25dded68c1f 100644
--- a/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
+++ b/spec/lib/gitlab/git/wraps_gitaly_errors_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git::WrapsGitalyErrors do
subject(:wrapper) do
@@ -10,18 +10,18 @@ describe Gitlab::Git::WrapsGitalyErrors do
mapping = {
GRPC::NotFound => Gitlab::Git::Repository::NoRepository,
GRPC::InvalidArgument => ArgumentError,
- GRPC::BadStatus => Gitlab::Git::CommandError
+ GRPC::BadStatus => Gitlab::Git::CommandError,
}
mapping.each do |grpc_error, error|
it "wraps #{grpc_error} in a #{error}" do
- expect { wrapper.wrapped_gitaly_errors { raise grpc_error.new('wrapped') } }
+ expect { wrapper.wrapped_gitaly_errors { raise grpc_error.new("wrapped") } }
.to raise_error(error)
end
end
- it 'does not swallow other errors' do
- expect { wrapper.wrapped_gitaly_errors { raise 'raised' } }
+ it "does not swallow other errors" do
+ expect { wrapper.wrapped_gitaly_errors { raise "raised" } }
.to raise_error(RuntimeError)
end
end
diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb
index 634c370d211..dde54255f8d 100644
--- a/spec/lib/gitlab/git_access_spec.rb
+++ b/spec/lib/gitlab/git_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitAccess do
include TermsHelper
@@ -10,62 +10,62 @@ describe Gitlab::GitAccess do
let(:project) { create(:project, :repository) }
let(:project_path) { project.path }
let(:namespace_path) { project&.namespace&.path }
- let(:protocol) { 'ssh' }
+ let(:protocol) { "ssh" }
let(:authentication_abilities) { %i[read_project download_code push_code] }
let(:redirected_path) { nil }
let(:auth_result_type) { nil }
let(:changes) { Gitlab::GitAccess::ANY }
- let(:push_access_check) { access.check('git-receive-pack', changes) }
- let(:pull_access_check) { access.check('git-upload-pack', changes) }
+ let(:push_access_check) { access.check("git-receive-pack", changes) }
+ let(:pull_access_check) { access.check("git-upload-pack", changes) }
- describe '#check with single protocols allowed' do
+ describe "#check with single protocols allowed" do
def disable_protocol(protocol)
allow(Gitlab::ProtocolAccess).to receive(:allowed?).with(protocol).and_return(false)
end
- context 'ssh disabled' do
+ context "ssh disabled" do
before do
- disable_protocol('ssh')
+ disable_protocol("ssh")
end
- it 'blocks ssh git push and pull' do
+ it "blocks ssh git push and pull" do
aggregate_failures do
- expect { push_access_check }.to raise_unauthorized('Git access over SSH is not allowed')
- expect { pull_access_check }.to raise_unauthorized('Git access over SSH is not allowed')
+ expect { push_access_check }.to raise_unauthorized("Git access over SSH is not allowed")
+ expect { pull_access_check }.to raise_unauthorized("Git access over SSH is not allowed")
end
end
end
- context 'http disabled' do
- let(:protocol) { 'http' }
+ context "http disabled" do
+ let(:protocol) { "http" }
before do
- disable_protocol('http')
+ disable_protocol("http")
project.add_maintainer(user)
end
- it 'blocks http push and pull' do
+ it "blocks http push and pull" do
aggregate_failures do
- expect { push_access_check }.to raise_unauthorized('Git access over HTTP is not allowed')
- expect { pull_access_check }.to raise_unauthorized('Git access over HTTP is not allowed')
+ expect { push_access_check }.to raise_unauthorized("Git access over HTTP is not allowed")
+ expect { pull_access_check }.to raise_unauthorized("Git access over HTTP is not allowed")
end
end
- context 'when request is made from CI' do
+ context "when request is made from CI" do
let(:auth_result_type) { :build }
it "doesn't block http pull" do
aggregate_failures do
- expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed')
+ expect { pull_access_check }.not_to raise_unauthorized("Git access over HTTP is not allowed")
end
end
- context 'when legacy CI credentials are used' do
+ context "when legacy CI credentials are used" do
let(:auth_result_type) { :ci }
it "doesn't block http pull" do
aggregate_failures do
- expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed')
+ expect { pull_access_check }.not_to raise_unauthorized("Git access over HTTP is not allowed")
end
end
end
@@ -73,19 +73,19 @@ describe Gitlab::GitAccess do
end
end
- describe '#check_project_accessibility!' do
- context 'when the project exists' do
- context 'when actor exists' do
- context 'when actor is a DeployKey' do
+ describe "#check_project_accessibility!" do
+ context "when the project exists" do
+ context "when actor exists" do
+ context "when actor is a DeployKey" do
let(:deploy_key) { create(:deploy_key, user: user) }
let(:actor) { deploy_key }
- context 'when the DeployKey has access to the project' do
+ context "when the DeployKey has access to the project" do
before do
deploy_key.deploy_keys_projects.create(project: project, can_push: true)
end
- it 'allows push and pull access' do
+ it "allows push and pull access" do
aggregate_failures do
expect { push_access_check }.not_to raise_error
expect { pull_access_check }.not_to raise_error
@@ -93,7 +93,7 @@ describe Gitlab::GitAccess do
end
end
- context 'when the Deploykey does not have access to the project' do
+ context "when the Deploykey does not have access to the project" do
it 'blocks push and pull with "not found"' do
aggregate_failures do
expect { push_access_check }.to raise_not_found
@@ -103,13 +103,13 @@ describe Gitlab::GitAccess do
end
end
- context 'when actor is a User' do
- context 'when the User can read the project' do
+ context "when actor is a User" do
+ context "when the User can read the project" do
before do
project.add_maintainer(user)
end
- it 'allows push and pull access' do
+ it "allows push and pull access" do
aggregate_failures do
expect { pull_access_check }.not_to raise_error
expect { push_access_check }.not_to raise_error
@@ -117,7 +117,7 @@ describe Gitlab::GitAccess do
end
end
- context 'when the User cannot read the project' do
+ context "when the User cannot read the project" do
it 'blocks push and pull with "not found"' do
aggregate_failures do
expect { push_access_check }.to raise_not_found
@@ -128,11 +128,11 @@ describe Gitlab::GitAccess do
end
# For backwards compatibility
- context 'when actor is :ci' do
+ context "when actor is :ci" do
let(:actor) { :ci }
let(:authentication_abilities) { build_authentication_abilities }
- it 'allows pull access' do
+ it "allows pull access" do
expect { pull_access_check }.not_to raise_error
end
@@ -141,41 +141,41 @@ describe Gitlab::GitAccess do
end
end
- context 'when actor is DeployToken' do
+ context "when actor is DeployToken" do
let(:actor) { create(:deploy_token, projects: [project]) }
- context 'when DeployToken is active and belongs to project' do
- it 'allows pull access' do
+ context "when DeployToken is active and belongs to project" do
+ it "allows pull access" do
expect { pull_access_check }.not_to raise_error
end
- it 'blocks the push' do
+ it "blocks the push" do
expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:upload])
end
end
- context 'when DeployToken does not belong to project' do
+ context "when DeployToken does not belong to project" do
let(:another_project) { create(:project) }
let(:actor) { create(:deploy_token, projects: [another_project]) }
- it 'blocks pull access' do
+ it "blocks pull access" do
expect { pull_access_check }.to raise_not_found
end
- it 'blocks the push' do
+ it "blocks the push" do
expect { push_access_check }.to raise_not_found
end
end
end
end
- context 'when actor is nil' do
+ context "when actor is nil" do
let(:actor) { nil }
- context 'when guests can read the project' do
+ context "when guests can read the project" do
let(:project) { create(:project, :repository, :public) }
- it 'allows pull access' do
+ it "allows pull access" do
expect { pull_access_check }.not_to raise_error
end
@@ -184,7 +184,7 @@ describe Gitlab::GitAccess do
end
end
- context 'when guests cannot read the project' do
+ context "when guests cannot read the project" do
it 'blocks pulls with "not found"' do
expect { pull_access_check }.to raise_not_found
end
@@ -196,7 +196,7 @@ describe Gitlab::GitAccess do
end
end
- context 'when the project is nil' do
+ context "when the project is nil" do
let(:project) { nil }
let(:project_path) { "new-project" }
@@ -207,7 +207,7 @@ describe Gitlab::GitAccess do
end
end
- context 'when user is allowed to create project in namespace' do
+ context "when user is allowed to create project in namespace" do
let(:namespace_path) { user.namespace.path }
let(:access) do
described_class.new(actor, nil,
@@ -220,12 +220,12 @@ describe Gitlab::GitAccess do
expect { pull_access_check }.to raise_not_found
end
- it 'allows push access' do
+ it "allows push access" do
expect { push_access_check }.not_to raise_error
end
end
- context 'when user is not allowed to create project in namespace' do
+ context "when user is not allowed to create project in namespace" do
let(:user2) { create(:user) }
let(:namespace_path) { user2.namespace.path }
let(:access) do
@@ -245,29 +245,29 @@ describe Gitlab::GitAccess do
end
end
- shared_examples '#check with a key that is not valid' do
+ shared_examples "#check with a key that is not valid" do
before do
project.add_maintainer(user)
end
- context 'key is too small' do
+ context "key is too small" do
before do
stub_application_setting(rsa_key_restriction: 4096)
end
- it 'does not allow keys which are too small', :aggregate_failures do
+ it "does not allow keys which are too small", :aggregate_failures do
expect(actor).not_to be_valid
- expect { pull_access_check }.to raise_unauthorized('Your SSH key must be at least 4096 bits.')
- expect { push_access_check }.to raise_unauthorized('Your SSH key must be at least 4096 bits.')
+ expect { pull_access_check }.to raise_unauthorized("Your SSH key must be at least 4096 bits.")
+ expect { push_access_check }.to raise_unauthorized("Your SSH key must be at least 4096 bits.")
end
end
- context 'key type is not allowed' do
+ context "key type is not allowed" do
before do
stub_application_setting(rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE)
end
- it 'does not allow keys which are too small', :aggregate_failures do
+ it "does not allow keys which are too small", :aggregate_failures do
expect(actor).not_to be_valid
expect { pull_access_check }.to raise_unauthorized(/Your SSH key type is forbidden/)
expect { push_access_check }.to raise_unauthorized(/Your SSH key type is forbidden/)
@@ -275,22 +275,22 @@ describe Gitlab::GitAccess do
end
end
- it_behaves_like '#check with a key that is not valid' do
+ it_behaves_like "#check with a key that is not valid" do
let(:actor) { build(:rsa_key_2048, user: user) }
end
- it_behaves_like '#check with a key that is not valid' do
+ it_behaves_like "#check with a key that is not valid" do
let(:actor) { build(:rsa_deploy_key_2048, user: user) }
end
- shared_examples 'check_project_moved' do
- it 'enqueues a redirected message for pushing' do
+ shared_examples "check_project_moved" do
+ it "enqueues a redirected message for pushing" do
push_access_check
expect(Gitlab::Checks::ProjectMoved.fetch_message(user.id, project.id)).not_to be_nil
end
- it 'allows push and pull access' do
+ it "allows push and pull access" do
aggregate_failures do
expect { push_access_check }.not_to raise_error
expect { pull_access_check }.not_to raise_error
@@ -298,13 +298,13 @@ describe Gitlab::GitAccess do
end
end
- describe '#add_project_moved_message!', :clean_gitlab_redis_shared_state do
+ describe "#add_project_moved_message!", :clean_gitlab_redis_shared_state do
before do
project.add_maintainer(user)
end
- context 'when a redirect was not followed to find the project' do
- it 'allows push and pull access' do
+ context "when a redirect was not followed to find the project" do
+ it "allows push and pull access" do
aggregate_failures do
expect { push_access_check }.not_to raise_error
expect { pull_access_check }.not_to raise_error
@@ -312,108 +312,108 @@ describe Gitlab::GitAccess do
end
end
- context 'with a redirect and ssh protocol' do
- let(:redirected_path) { 'some/other-path' }
+ context "with a redirect and ssh protocol" do
+ let(:redirected_path) { "some/other-path" }
- it_behaves_like 'check_project_moved'
+ it_behaves_like "check_project_moved"
end
- context 'with a redirect and http protocol' do
- let(:redirected_path) { 'some/other-path' }
- let(:protocol) { 'http' }
+ context "with a redirect and http protocol" do
+ let(:redirected_path) { "some/other-path" }
+ let(:protocol) { "http" }
- it_behaves_like 'check_project_moved'
+ it_behaves_like "check_project_moved"
end
end
- describe '#check_authentication_abilities!' do
+ describe "#check_authentication_abilities!" do
before do
project.add_maintainer(user)
end
- context 'when download' do
+ context "when download" do
let(:authentication_abilities) { [] }
- it 'raises unauthorized with download error' do
+ it "raises unauthorized with download error" do
expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_download])
end
- context 'when authentication abilities include download code' do
+ context "when authentication abilities include download code" do
let(:authentication_abilities) { [:download_code] }
- it 'does not raise any errors' do
+ it "does not raise any errors" do
expect { pull_access_check }.not_to raise_error
end
end
- context 'when authentication abilities include build download code' do
+ context "when authentication abilities include build download code" do
let(:authentication_abilities) { [:build_download_code] }
- it 'does not raise any errors' do
+ it "does not raise any errors" do
expect { pull_access_check }.not_to raise_error
end
end
end
- context 'when upload' do
+ context "when upload" do
let(:authentication_abilities) { [] }
- it 'raises unauthorized with push error' do
+ it "raises unauthorized with push error" do
expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload])
end
- context 'when authentication abilities include push code' do
+ context "when authentication abilities include push code" do
let(:authentication_abilities) { [:push_code] }
- it 'does not raise any errors' do
+ it "does not raise any errors" do
expect { push_access_check }.not_to raise_error
end
end
end
end
- describe '#check_command_disabled!' do
+ describe "#check_command_disabled!" do
before do
project.add_maintainer(user)
end
- context 'over http' do
- let(:protocol) { 'http' }
+ context "over http" do
+ let(:protocol) { "http" }
- context 'when the git-upload-pack command is disabled in config' do
+ context "when the git-upload-pack command is disabled in config" do
before do
allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false)
end
- context 'when calling git-upload-pack' do
- it { expect { pull_access_check }.to raise_unauthorized('Pulling over HTTP is not allowed.') }
+ context "when calling git-upload-pack" do
+ it { expect { pull_access_check }.to raise_unauthorized("Pulling over HTTP is not allowed.") }
end
- context 'when calling git-receive-pack' do
+ context "when calling git-receive-pack" do
it { expect { push_access_check }.not_to raise_error }
end
end
- context 'when the git-receive-pack command is disabled in config' do
+ context "when the git-receive-pack command is disabled in config" do
before do
allow(Gitlab.config.gitlab_shell).to receive(:receive_pack).and_return(false)
end
- context 'when calling git-receive-pack' do
- it { expect { push_access_check }.to raise_unauthorized('Pushing over HTTP is not allowed.') }
+ context "when calling git-receive-pack" do
+ it { expect { push_access_check }.to raise_unauthorized("Pushing over HTTP is not allowed.") }
end
- context 'when calling git-upload-pack' do
+ context "when calling git-upload-pack" do
it { expect { pull_access_check }.not_to raise_error }
end
end
end
end
- describe '#check_db_accessibility!' do
- context 'when in a read-only GitLab instance' do
+ describe "#check_db_accessibility!" do
+ context "when in a read-only GitLab instance" do
before do
- create(:protected_branch, name: 'feature', project: project)
+ create(:protected_branch, name: "feature", project: project)
allow(Gitlab::Database).to receive(:read_only?) { true }
end
@@ -421,7 +421,7 @@ describe Gitlab::GitAccess do
end
end
- describe '#ensure_project_on_push!' do
+ describe "#ensure_project_on_push!" do
let(:access) do
described_class.new(actor, project,
protocol, authentication_abilities: authentication_abilities,
@@ -429,69 +429,69 @@ describe Gitlab::GitAccess do
redirected_path: redirected_path)
end
- context 'when push' do
- let(:cmd) { 'git-receive-pack' }
+ context "when push" do
+ let(:cmd) { "git-receive-pack" }
- context 'when project does not exist' do
+ context "when project does not exist" do
let(:project_path) { "nonexistent" }
let(:project) { nil }
- context 'when changes is _any' do
+ context "when changes is _any" do
let(:changes) { Gitlab::GitAccess::ANY }
- context 'when authentication abilities include push code' do
+ context "when authentication abilities include push code" do
let(:authentication_abilities) { [:push_code] }
- context 'when user can create project in namespace' do
+ context "when user can create project in namespace" do
let(:namespace_path) { user.namespace.path }
- it 'creates a new project' do
+ it "creates a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.to change { Project.count }.by(1)
end
end
- context 'when user cannot create project in namespace' do
+ context "when user cannot create project in namespace" do
let(:user2) { create(:user) }
let(:namespace_path) { user2.namespace.path }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
end
- context 'when authentication abilities do not include push code' do
+ context "when authentication abilities do not include push code" do
let(:authentication_abilities) { [] }
- context 'when user can create project in namespace' do
+ context "when user can create project in namespace" do
let(:namespace_path) { user.namespace.path }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
end
end
- context 'when check contains actual changes' do
+ context "when check contains actual changes" do
let(:changes) { "#{Gitlab::Git::BLANK_SHA} 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/new_branch" }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
end
- context 'when project exists' do
+ context "when project exists" do
let(:changes) { Gitlab::GitAccess::ANY }
let!(:project) { create(:project) }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
- context 'when deploy key is used' do
+ context "when deploy key is used" do
let(:key) { create(:deploy_key, user: user) }
let(:actor) { key }
let(:project_path) { "nonexistent" }
@@ -499,50 +499,50 @@ describe Gitlab::GitAccess do
let(:namespace_path) { user.namespace.path }
let(:changes) { Gitlab::GitAccess::ANY }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
end
- context 'when pull' do
- let(:cmd) { 'git-upload-pack' }
+ context "when pull" do
+ let(:cmd) { "git-upload-pack" }
let(:changes) { Gitlab::GitAccess::ANY }
- context 'when project does not exist' do
+ context "when project does not exist" do
let(:project_path) { "new-project" }
let(:namespace_path) { user.namespace.path }
let(:project) { nil }
- it 'does not create a new project' do
+ it "does not create a new project" do
expect { access.send(:ensure_project_on_push!, cmd, changes) }.not_to change { Project.count }
end
end
end
end
- describe '#check_download_access!' do
- it 'allows maintainers to pull' do
+ describe "#check_download_access!" do
+ it "allows maintainers to pull" do
project.add_maintainer(user)
expect { pull_access_check }.not_to raise_error
end
- it 'disallows guests to pull' do
+ it "disallows guests to pull" do
project.add_guest(user)
expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download])
end
- it 'disallows blocked users to pull' do
+ it "disallows blocked users to pull" do
project.add_maintainer(user)
user.block
- expect { pull_access_check }.to raise_unauthorized('Your account has been blocked.')
+ expect { pull_access_check }.to raise_unauthorized("Your account has been blocked.")
end
- context 'when the project repository does not exist' do
- it 'returns not found' do
+ context "when the project repository does not exist" do
+ it "returns not found" do
project.add_guest(user)
repo = project.repository
Gitlab::GitalyClient::StorageSettings.allow_disk_access { FileUtils.rm_rf(repo.path) }
@@ -550,29 +550,29 @@ describe Gitlab::GitAccess do
# Sanity check for rm_rf
expect(repo.exists?).to eq(false)
- expect { pull_access_check }.to raise_error(Gitlab::GitAccess::NotFoundError, 'A repository for this project does not exist yet.')
+ expect { pull_access_check }.to raise_error(Gitlab::GitAccess::NotFoundError, "A repository for this project does not exist yet.")
end
end
- describe 'without access to project' do
- context 'pull code' do
+ describe "without access to project" do
+ context "pull code" do
it { expect { pull_access_check }.to raise_not_found }
end
- context 'when project is public' do
+ context "when project is public" do
let(:public_project) { create(:project, :public, :repository) }
let(:project_path) { public_project.path }
let(:namespace_path) { public_project.namespace.path }
- let(:access) { described_class.new(nil, public_project, 'web', authentication_abilities: [:download_code], project_path: project_path, namespace_path: namespace_path) }
+ let(:access) { described_class.new(nil, public_project, "web", authentication_abilities: [:download_code], project_path: project_path, namespace_path: namespace_path) }
- context 'when repository is enabled' do
- it 'give access to download code' do
+ context "when repository is enabled" do
+ it "give access to download code" do
expect { pull_access_check }.not_to raise_error
end
end
- context 'when repository is disabled' do
- it 'does not give access to download code' do
+ context "when repository is disabled" do
+ it "does not give access to download code" do
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download])
@@ -581,12 +581,12 @@ describe Gitlab::GitAccess do
end
end
- describe 'deploy key permissions' do
+ describe "deploy key permissions" do
let(:key) { create(:deploy_key, user: user) }
let(:actor) { key }
- context 'pull code' do
- context 'when project is authorized' do
+ context "pull code" do
+ context "when project is authorized" do
before do
key.projects << project
end
@@ -594,20 +594,20 @@ describe Gitlab::GitAccess do
it { expect { pull_access_check }.not_to raise_error }
end
- context 'when unauthorized' do
- context 'from public project' do
+ context "when unauthorized" do
+ context "from public project" do
let(:project) { create(:project, :public, :repository) }
it { expect { pull_access_check }.not_to raise_error }
end
- context 'from internal project' do
+ context "from internal project" do
let(:project) { create(:project, :internal, :repository) }
it { expect { pull_access_check }.to raise_not_found }
end
- context 'from private project' do
+ context "from private project" do
let(:project) { create(:project, :private, :repository) }
it { expect { pull_access_check }.to raise_not_found }
@@ -616,12 +616,12 @@ describe Gitlab::GitAccess do
end
end
- describe 'deploy token permissions' do
+ describe "deploy token permissions" do
let(:deploy_token) { create(:deploy_token) }
let(:actor) { deploy_token }
- context 'pull code' do
- context 'when project is authorized' do
+ context "pull code" do
+ context "when project is authorized" do
before do
deploy_token.projects << project
end
@@ -629,20 +629,20 @@ describe Gitlab::GitAccess do
it { expect { pull_access_check }.not_to raise_error }
end
- context 'when unauthorized' do
- context 'from public project' do
+ context "when unauthorized" do
+ context "from public project" do
let(:project) { create(:project, :public, :repository) }
it { expect { pull_access_check }.not_to raise_error }
end
- context 'from internal project' do
+ context "from internal project" do
let(:project) { create(:project, :internal, :repository) }
it { expect { pull_access_check }.to raise_not_found }
end
- context 'from private project' do
+ context "from private project" do
let(:project) { create(:project, :private, :repository) }
it { expect { pull_access_check }.to raise_not_found }
@@ -651,74 +651,74 @@ describe Gitlab::GitAccess do
end
end
- describe 'build authentication_abilities permissions' do
+ describe "build authentication_abilities permissions" do
let(:authentication_abilities) { build_authentication_abilities }
- describe 'owner' do
+ describe "owner" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- context 'pull code' do
+ context "pull code" do
it { expect { pull_access_check }.not_to raise_error }
end
end
- describe 'reporter user' do
+ describe "reporter user" do
before do
project.add_reporter(user)
end
- context 'pull code' do
+ context "pull code" do
it { expect { pull_access_check }.not_to raise_error }
end
end
- describe 'admin user' do
+ describe "admin user" do
let(:user) { create(:admin) }
- context 'when member of the project' do
+ context "when member of the project" do
before do
project.add_reporter(user)
end
- context 'pull code' do
+ context "pull code" do
it { expect { pull_access_check }.not_to raise_error }
end
end
- context 'when is not member of the project' do
- context 'pull code' do
+ context "when is not member of the project" do
+ context "pull code" do
it { expect { pull_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:download]) }
end
end
end
- describe 'generic CI (build without a user)' do
+ describe "generic CI (build without a user)" do
let(:actor) { :ci }
- context 'pull code' do
+ context "pull code" do
it { expect { pull_access_check }.not_to raise_error }
end
end
end
end
- describe 'check LFS integrity' do
- let(:changes) { ['6f6d7e7ed 570e7b2ab refs/heads/master', '6f6d7e7ed 570e7b2ab refs/heads/feature'] }
+ describe "check LFS integrity" do
+ let(:changes) { ["6f6d7e7ed 570e7b2ab refs/heads/master", "6f6d7e7ed 570e7b2ab refs/heads/feature"] }
before do
project.add_developer(user)
end
- context 'when LFS is not enabled' do
- it 'does not run LFSIntegrity check' do
+ context "when LFS is not enabled" do
+ it "does not run LFSIntegrity check" do
expect(Gitlab::Checks::LfsIntegrity).not_to receive(:new)
push_access_check
end
end
- context 'when LFS is enabled' do
- it 'checks LFS integrity only for first change' do
+ context "when LFS is enabled" do
+ it "checks LFS integrity only for first change" do
allow(project).to receive(:lfs_enabled?).and_return(true)
expect_any_instance_of(Gitlab::Checks::LfsIntegrity).to receive(:objects_missing?).exactly(1).times
@@ -728,38 +728,39 @@ describe Gitlab::GitAccess do
end
end
- describe '#check_push_access!' do
- let(:unprotected_branch) { 'unprotected_branch' }
+ describe "#check_push_access!" do
+ let(:unprotected_branch) { "unprotected_branch" }
before do
merge_into_protected_branch
end
let(:changes) do
- { any: Gitlab::GitAccess::ANY,
- push_new_branch: "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/heads/wow",
- push_master: '6f6d7e7ed 570e7b2ab refs/heads/master',
- push_protected_branch: '6f6d7e7ed 570e7b2ab refs/heads/feature',
- push_remove_protected_branch: "570e7b2ab #{Gitlab::Git::BLANK_SHA} "\
- 'refs/heads/feature',
- push_tag: '6f6d7e7ed 570e7b2ab refs/tags/v1.0.0',
- push_new_tag: "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/tags/v7.8.9",
- push_all: ['6f6d7e7ed 570e7b2ab refs/heads/master', '6f6d7e7ed 570e7b2ab refs/heads/feature'],
- merge_into_protected_branch: "0b4bc9a #{merge_into_protected_branch} refs/heads/feature" }
+ {any: Gitlab::GitAccess::ANY,
+ push_new_branch: "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/heads/wow",
+ push_master: "6f6d7e7ed 570e7b2ab refs/heads/master",
+ push_protected_branch: "6f6d7e7ed 570e7b2ab refs/heads/feature",
+ push_remove_protected_branch: "570e7b2ab #{Gitlab::Git::BLANK_SHA} "\
+ "refs/heads/feature",
+ push_tag: "6f6d7e7ed 570e7b2ab refs/tags/v1.0.0",
+ push_new_tag: "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/tags/v7.8.9",
+ push_all: ["6f6d7e7ed 570e7b2ab refs/heads/master", "6f6d7e7ed 570e7b2ab refs/heads/feature"],
+ merge_into_protected_branch: "0b4bc9a #{merge_into_protected_branch} refs/heads/feature",}
end
def merge_into_protected_branch
@protected_branch_merge_commit ||= begin
- project.repository.add_branch(user, unprotected_branch, 'feature')
+ project.repository.add_branch(user, unprotected_branch, "feature")
rugged = rugged_repo(project.repository)
- target_branch = rugged.rev_parse('feature')
+ target_branch = rugged.rev_parse("feature")
source_branch = project.repository.create_file(
user,
- 'filename',
- 'This is the file content',
- message: 'This is a good commit message',
- branch_name: unprotected_branch)
- author = { email: "email@example.com", time: Time.now, name: "Example Git User" }
+ "filename",
+ "This is the file content",
+ message: "This is a good commit message",
+ branch_name: unprotected_branch
+ )
+ author = {email: "email@example.com", time: Time.now, name: "Example Git User"}
merge_index = rugged.merge_commits(target_branch, source_branch)
Rugged::Commit.create(rugged, author: author, committer: author, message: "commit message", parents: [target_branch, source_branch], tree: merge_index.write_tree(rugged))
@@ -810,7 +811,7 @@ describe Gitlab::GitAccess do
push_tag: true,
push_new_tag: true,
push_all: true,
- merge_into_protected_branch: true
+ merge_into_protected_branch: true,
},
maintainer: {
@@ -822,7 +823,7 @@ describe Gitlab::GitAccess do
push_tag: true,
push_new_tag: true,
push_all: true,
- merge_into_protected_branch: true
+ merge_into_protected_branch: true,
},
developer: {
@@ -834,7 +835,7 @@ describe Gitlab::GitAccess do
push_tag: false,
push_new_tag: true,
push_all: false,
- merge_into_protected_branch: false
+ merge_into_protected_branch: false,
},
reporter: {
@@ -846,7 +847,7 @@ describe Gitlab::GitAccess do
push_tag: false,
push_new_tag: false,
push_all: false,
- merge_into_protected_branch: false
+ merge_into_protected_branch: false,
},
guest: {
@@ -858,11 +859,11 @@ describe Gitlab::GitAccess do
push_tag: false,
push_new_tag: false,
push_all: false,
- merge_into_protected_branch: false
- }
+ merge_into_protected_branch: false,
+ },
}
- [%w(feature exact), ['feat*', 'wildcard']].each do |protected_branch_name, protected_branch_type|
+ [%w[feature exact], ["feat*", "wildcard"]].each do |protected_branch_name, protected_branch_type|
context do
let(:protected_branch) { create(:protected_branch, :maintainers_can_push, name: protected_branch_name, project: project) }
@@ -872,7 +873,7 @@ describe Gitlab::GitAccess do
context "when developers are allowed to push into the #{protected_branch_type} protected branch" do
let(:protected_branch) { create(:protected_branch, :developers_can_push, name: protected_branch_name, project: project) }
- run_permission_checks(permissions_matrix.deep_merge(developer: { push_protected_branch: true, push_all: true, merge_into_protected_branch: true }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {push_protected_branch: true, push_all: true, merge_into_protected_branch: true}))
end
context "developers are allowed to merge into the #{protected_branch_type} protected branch" do
@@ -881,23 +882,23 @@ describe Gitlab::GitAccess do
context "when a merge request exists for the given source/target branch" do
context "when the merge request is in progress" do
before do
- create(:merge_request, source_project: project, source_branch: unprotected_branch, target_branch: 'feature',
- state: 'locked', in_progress_merge_commit_sha: merge_into_protected_branch)
+ create(:merge_request, source_project: project, source_branch: unprotected_branch, target_branch: "feature",
+ state: "locked", in_progress_merge_commit_sha: merge_into_protected_branch)
end
- run_permission_checks(permissions_matrix.deep_merge(developer: { merge_into_protected_branch: true }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {merge_into_protected_branch: true}))
end
context "when the merge request is not in progress" do
before do
- create(:merge_request, source_project: project, source_branch: unprotected_branch, target_branch: 'feature', in_progress_merge_commit_sha: nil)
+ create(:merge_request, source_project: project, source_branch: unprotected_branch, target_branch: "feature", in_progress_merge_commit_sha: nil)
end
- run_permission_checks(permissions_matrix.deep_merge(developer: { merge_into_protected_branch: false }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {merge_into_protected_branch: false}))
end
context "when a merge request does not exist for the given source/target branch" do
- run_permission_checks(permissions_matrix.deep_merge(developer: { merge_into_protected_branch: false }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {merge_into_protected_branch: false}))
end
end
end
@@ -905,19 +906,19 @@ describe Gitlab::GitAccess do
context "when developers are allowed to push and merge into the #{protected_branch_type} protected branch" do
let(:protected_branch) { create(:protected_branch, :developers_can_merge, :developers_can_push, name: protected_branch_name, project: project) }
- run_permission_checks(permissions_matrix.deep_merge(developer: { push_protected_branch: true, push_all: true, merge_into_protected_branch: true }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {push_protected_branch: true, push_all: true, merge_into_protected_branch: true}))
end
context "when no one is allowed to push to the #{protected_branch_name} protected branch" do
let(:protected_branch) { build(:protected_branch, :no_one_can_push, name: protected_branch_name, project: project) }
- run_permission_checks(permissions_matrix.deep_merge(developer: { push_protected_branch: false, push_all: false, merge_into_protected_branch: false },
- maintainer: { push_protected_branch: false, push_all: false, merge_into_protected_branch: false },
- admin: { push_protected_branch: false, push_all: false, merge_into_protected_branch: false }))
+ run_permission_checks(permissions_matrix.deep_merge(developer: {push_protected_branch: false, push_all: false, merge_into_protected_branch: false},
+ maintainer: {push_protected_branch: false, push_all: false, merge_into_protected_branch: false},
+ admin: {push_protected_branch: false, push_all: false, merge_into_protected_branch: false}))
end
end
- context 'when pushing to a project' do
+ context "when pushing to a project" do
let(:project) { create(:project, :public, :repository) }
let(:changes) { "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/heads/wow" }
@@ -925,43 +926,43 @@ describe Gitlab::GitAccess do
project.add_developer(user)
end
- it 'cleans up the files' do
+ it "cleans up the files" do
expect(project.repository).to receive(:clean_stale_repository_files).and_call_original
expect { push_access_check }.not_to raise_error
end
- it 'avoids N+1 queries', :request_store do
+ it "avoids N+1 queries", :request_store do
# Run this once to establish a baseline. Cached queries should get
# cached, so that when we introduce another change we shouldn't see
# additional queries.
- access.check('git-receive-pack', changes)
+ access.check("git-receive-pack", changes)
- control_count = ActiveRecord::QueryRecorder.new do
- access.check('git-receive-pack', changes)
- end
+ control_count = ActiveRecord::QueryRecorder.new {
+ access.check("git-receive-pack", changes)
+ }
- changes = ['6f6d7e7ed 570e7b2ab refs/heads/master', '6f6d7e7ed 570e7b2ab refs/heads/feature']
+ changes = ["6f6d7e7ed 570e7b2ab refs/heads/master", "6f6d7e7ed 570e7b2ab refs/heads/feature"]
# There is still an N+1 query with protected branches
- expect { access.check('git-receive-pack', changes) }.not_to exceed_query_limit(control_count).with_threshold(1)
+ expect { access.check("git-receive-pack", changes) }.not_to exceed_query_limit(control_count).with_threshold(1)
end
- it 'raises TimeoutError when #check_single_change_access raises a timeout error' do
+ it "raises TimeoutError when #check_single_change_access raises a timeout error" do
message = "Push operation timed out\n\nTiming information for debugging purposes:\nRunning checks for ref: wow"
expect_next_instance_of(Gitlab::Checks::ChangeAccess) do |check|
expect(check).to receive(:exec).and_raise(Gitlab::Checks::TimedLogger::TimeoutError)
end
- expect { access.check('git-receive-pack', changes) }.to raise_error(described_class::TimeoutError, message)
+ expect { access.check("git-receive-pack", changes) }.to raise_error(described_class::TimeoutError, message)
end
end
end
- describe 'build authentication abilities' do
+ describe "build authentication abilities" do
let(:authentication_abilities) { build_authentication_abilities }
- context 'when project is authorized' do
+ context "when project is authorized" do
before do
project.add_reporter(user)
end
@@ -969,20 +970,20 @@ describe Gitlab::GitAccess do
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) }
end
- context 'when unauthorized' do
- context 'to public project' do
+ context "when unauthorized" do
+ context "to public project" do
let(:project) { create(:project, :public, :repository) }
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) }
end
- context 'to internal project' do
+ context "to internal project" do
let(:project) { create(:project, :internal, :repository) }
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) }
end
- context 'to private project' do
+ context "to private project" do
let(:project) { create(:project, :private, :repository) }
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) }
@@ -990,22 +991,22 @@ describe Gitlab::GitAccess do
end
end
- context 'when the repository is read only' do
+ context "when the repository is read only" do
let(:project) { create(:project, :repository, :read_only) }
- it 'denies push access' do
+ it "denies push access" do
project.add_maintainer(user)
- expect { push_access_check }.to raise_unauthorized('The repository is temporarily read-only. Please try again later.')
+ expect { push_access_check }.to raise_unauthorized("The repository is temporarily read-only. Please try again later.")
end
end
- describe 'deploy key permissions' do
+ describe "deploy key permissions" do
let(:key) { create(:deploy_key, user: user) }
let(:actor) { key }
- context 'when deploy_key can push' do
- context 'when project is authorized' do
+ context "when deploy_key can push" do
+ context "when project is authorized" do
before do
key.deploy_keys_projects.create(project: project, can_push: true)
end
@@ -1013,20 +1014,20 @@ describe Gitlab::GitAccess do
it { expect { push_access_check }.not_to raise_error }
end
- context 'when unauthorized' do
- context 'to public project' do
+ context "when unauthorized" do
+ context "to public project" do
let(:project) { create(:project, :public, :repository) }
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) }
end
- context 'to internal project' do
+ context "to internal project" do
let(:project) { create(:project, :internal, :repository) }
it { expect { push_access_check }.to raise_not_found }
end
- context 'to private project' do
+ context "to private project" do
let(:project) { create(:project, :private, :repository) }
it { expect { push_access_check }.to raise_not_found }
@@ -1034,8 +1035,8 @@ describe Gitlab::GitAccess do
end
end
- context 'when deploy_key cannot push' do
- context 'when project is authorized' do
+ context "when deploy_key cannot push" do
+ context "when project is authorized" do
before do
key.deploy_keys_projects.create(project: project, can_push: false)
end
@@ -1043,20 +1044,20 @@ describe Gitlab::GitAccess do
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) }
end
- context 'when unauthorized' do
- context 'to public project' do
+ context "when unauthorized" do
+ context "to public project" do
let(:project) { create(:project, :public, :repository) }
it { expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:deploy_key_upload]) }
end
- context 'to internal project' do
+ context "to internal project" do
let(:project) { create(:project, :internal, :repository) }
it { expect { push_access_check }.to raise_not_found }
end
- context 'to private project' do
+ context "to private project" do
let(:project) { create(:project, :private, :repository) }
it { expect { push_access_check }.to raise_not_found }
@@ -1065,24 +1066,24 @@ describe Gitlab::GitAccess do
end
end
- context 'terms are enforced' do
+ context "terms are enforced" do
before do
enforce_terms
end
- shared_examples 'access after accepting terms' do
+ shared_examples "access after accepting terms" do
let(:actions) do
[-> { pull_access_check },
- -> { push_access_check }]
+ -> { push_access_check },]
end
- it 'blocks access when the user did not accept terms', :aggregate_failures do
+ it "blocks access when the user did not accept terms", :aggregate_failures do
actions.each do |action|
expect { action.call }.to raise_unauthorized(/must accept the Terms of Service in order to perform this action/)
end
end
- it 'allows access when the user accepted the terms', :aggregate_failures do
+ it "allows access when the user accepted the terms", :aggregate_failures do
accept_terms(user)
actions.each do |action|
@@ -1091,55 +1092,55 @@ describe Gitlab::GitAccess do
end
end
- describe 'as an anonymous user to a public project' do
+ describe "as an anonymous user to a public project" do
let(:actor) { nil }
let(:project) { create(:project, :public, :repository) }
it { expect { pull_access_check }.not_to raise_error }
end
- describe 'as a guest to a public project' do
+ describe "as a guest to a public project" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'access after accepting terms' do
+ it_behaves_like "access after accepting terms" do
let(:actions) { [-> { pull_access_check }] }
end
end
- describe 'as a reporter to the project' do
+ describe "as a reporter to the project" do
before do
project.add_reporter(user)
end
- it_behaves_like 'access after accepting terms' do
+ it_behaves_like "access after accepting terms" do
let(:actions) { [-> { pull_access_check }] }
end
end
- describe 'as a developer of the project' do
+ describe "as a developer of the project" do
before do
project.add_developer(user)
end
- it_behaves_like 'access after accepting terms'
+ it_behaves_like "access after accepting terms"
end
- describe 'as a maintainer of the project' do
+ describe "as a maintainer of the project" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'access after accepting terms'
+ it_behaves_like "access after accepting terms"
end
- describe 'as an owner of the project' do
+ describe "as an owner of the project" do
let(:project) { create(:project, :repository, namespace: user.namespace) }
- it_behaves_like 'access after accepting terms'
+ it_behaves_like "access after accepting terms"
end
- describe 'when a ci build clones the project' do
- let(:protocol) { 'http' }
+ describe "when a ci build clones the project" do
+ let(:protocol) { "http" }
let(:authentication_abilities) { [:build_download_code] }
let(:auth_result_type) { :build }
@@ -1159,13 +1160,13 @@ describe Gitlab::GitAccess do
def access
described_class.new(actor, project, protocol,
- authentication_abilities: authentication_abilities,
- namespace_path: namespace_path, project_path: project_path,
- redirected_path: redirected_path, auth_result_type: auth_result_type)
+ authentication_abilities: authentication_abilities,
+ namespace_path: namespace_path, project_path: project_path,
+ redirected_path: redirected_path, auth_result_type: auth_result_type)
end
def push_changes(changes)
- access.check('git-receive-pack', changes)
+ access.check("git-receive-pack", changes)
end
def raise_unauthorized(message)
@@ -1179,7 +1180,7 @@ describe Gitlab::GitAccess do
def build_authentication_abilities
[
:read_project,
- :build_download_code
+ :build_download_code,
]
end
@@ -1187,7 +1188,7 @@ describe Gitlab::GitAccess do
[
:read_project,
:download_code,
- :push_code
+ :push_code,
]
end
end
diff --git a/spec/lib/gitlab/git_access_wiki_spec.rb b/spec/lib/gitlab/git_access_wiki_spec.rb
index 6ba65b56618..fe6e56881ea 100644
--- a/spec/lib/gitlab/git_access_wiki_spec.rb
+++ b/spec/lib/gitlab/git_access_wiki_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitAccessWiki do
- let(:access) { described_class.new(user, project, 'web', authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
+ let(:access) { described_class.new(user, project, "web", authentication_abilities: authentication_abilities, redirected_path: redirected_path) }
let(:project) { create(:project, :wiki_repo) }
let(:user) { create(:user) }
- let(:changes) { ['6f6d7e7ed 570e7b2ab refs/heads/master'] }
+ let(:changes) { ["6f6d7e7ed 570e7b2ab refs/heads/master"] }
let(:redirected_path) { nil }
let(:authentication_abilities) do
[
:read_project,
:download_code,
- :push_code
+ :push_code,
]
end
- describe '#push_access_check' do
- context 'when user can :create_wiki' do
+ describe "#push_access_check" do
+ context "when user can :create_wiki" do
before do
- create(:protected_branch, name: 'master', project: project)
+ create(:protected_branch, name: "master", project: project)
project.add_developer(user)
end
- subject { access.check('git-receive-pack', changes) }
+ subject { access.check("git-receive-pack", changes) }
it { expect { subject }.not_to raise_error }
- context 'when in a read-only GitLab instance' do
+ context "when in a read-only GitLab instance" do
before do
allow(Gitlab::Database).to receive(:read_only?) { true }
end
- it 'does not give access to upload wiki code' do
+ it "does not give access to upload wiki code" do
expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You can't push code to a read-only GitLab instance.")
end
end
end
end
- describe '#access_check_download!' do
- subject { access.check('git-upload-pack', Gitlab::GitAccess::ANY) }
+ describe "#access_check_download!" do
+ subject { access.check("git-upload-pack", Gitlab::GitAccess::ANY) }
before do
project.add_developer(user)
end
- context 'when wiki feature is enabled' do
- it 'give access to download wiki code' do
+ context "when wiki feature is enabled" do
+ it "give access to download wiki code" do
expect { subject }.not_to raise_error
end
- context 'when the wiki repository does not exist' do
- it 'returns not found' do
+ context "when the wiki repository does not exist" do
+ it "returns not found" do
wiki_repo = project.wiki.repository
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
FileUtils.rm_rf(wiki_repo.path)
@@ -59,16 +59,16 @@ describe Gitlab::GitAccessWiki do
# Sanity check for rm_rf
expect(wiki_repo.exists?).to eq(false)
- expect { subject }.to raise_error(Gitlab::GitAccess::NotFoundError, 'A repository for this project does not exist yet.')
+ expect { subject }.to raise_error(Gitlab::GitAccess::NotFoundError, "A repository for this project does not exist yet.")
end
end
end
- context 'when wiki feature is disabled' do
- it 'does not give access to download wiki code' do
+ context "when wiki feature is disabled" do
+ it "does not give access to download wiki code" do
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
- expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, 'You are not allowed to download code from this project.')
+ expect { subject }.to raise_error(Gitlab::GitAccess::UnauthorizedError, "You are not allowed to download code from this project.")
end
end
end
diff --git a/spec/lib/gitlab/git_ref_validator_spec.rb b/spec/lib/gitlab/git_ref_validator_spec.rb
index 3ab04a1c46d..35518813b0f 100644
--- a/spec/lib/gitlab/git_ref_validator_spec.rb
+++ b/spec/lib/gitlab/git_ref_validator_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitRefValidator do
- it { expect(described_class.validate('feature/new')).to be_truthy }
- it { expect(described_class.validate('implement_@all')).to be_truthy }
- it { expect(described_class.validate('my_new_feature')).to be_truthy }
- it { expect(described_class.validate('my-branch')).to be_truthy }
- it { expect(described_class.validate('#1')).to be_truthy }
- it { expect(described_class.validate('feature/refs/heads/foo')).to be_truthy }
- it { expect(described_class.validate('feature/~new/')).to be_falsey }
- it { expect(described_class.validate('feature/^new/')).to be_falsey }
- it { expect(described_class.validate('feature/:new/')).to be_falsey }
- it { expect(described_class.validate('feature/?new/')).to be_falsey }
- it { expect(described_class.validate('feature/*new/')).to be_falsey }
- it { expect(described_class.validate('feature/[new/')).to be_falsey }
- it { expect(described_class.validate('feature/new/')).to be_falsey }
- it { expect(described_class.validate('feature/new.')).to be_falsey }
+ it { expect(described_class.validate("feature/new")).to be_truthy }
+ it { expect(described_class.validate("implement_@all")).to be_truthy }
+ it { expect(described_class.validate("my_new_feature")).to be_truthy }
+ it { expect(described_class.validate("my-branch")).to be_truthy }
+ it { expect(described_class.validate("#1")).to be_truthy }
+ it { expect(described_class.validate("feature/refs/heads/foo")).to be_truthy }
+ it { expect(described_class.validate("feature/~new/")).to be_falsey }
+ it { expect(described_class.validate("feature/^new/")).to be_falsey }
+ it { expect(described_class.validate("feature/:new/")).to be_falsey }
+ it { expect(described_class.validate("feature/?new/")).to be_falsey }
+ it { expect(described_class.validate("feature/*new/")).to be_falsey }
+ it { expect(described_class.validate("feature/[new/")).to be_falsey }
+ it { expect(described_class.validate("feature/new/")).to be_falsey }
+ it { expect(described_class.validate("feature/new.")).to be_falsey }
it { expect(described_class.validate('feature\@{')).to be_falsey }
it { expect(described_class.validate('feature\new')).to be_falsey }
- it { expect(described_class.validate('feature//new')).to be_falsey }
- it { expect(described_class.validate('feature new')).to be_falsey }
- it { expect(described_class.validate('refs/heads/')).to be_falsey }
- it { expect(described_class.validate('refs/remotes/')).to be_falsey }
- it { expect(described_class.validate('refs/heads/feature')).to be_falsey }
- it { expect(described_class.validate('refs/remotes/origin')).to be_falsey }
- it { expect(described_class.validate('-')).to be_falsey }
- it { expect(described_class.validate('-branch')).to be_falsey }
- it { expect(described_class.validate('.tag')).to be_falsey }
- it { expect(described_class.validate('my branch')).to be_falsey }
+ it { expect(described_class.validate("feature//new")).to be_falsey }
+ it { expect(described_class.validate("feature new")).to be_falsey }
+ it { expect(described_class.validate("refs/heads/")).to be_falsey }
+ it { expect(described_class.validate("refs/remotes/")).to be_falsey }
+ it { expect(described_class.validate("refs/heads/feature")).to be_falsey }
+ it { expect(described_class.validate("refs/remotes/origin")).to be_falsey }
+ it { expect(described_class.validate("-")).to be_falsey }
+ it { expect(described_class.validate("-branch")).to be_falsey }
+ it { expect(described_class.validate(".tag")).to be_falsey }
+ it { expect(described_class.validate("my branch")).to be_falsey }
it { expect(described_class.validate("\xA0\u0000\xB0")).to be_falsey }
end
diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb
index ce15057dd7d..f73b524fa48 100644
--- a/spec/lib/gitlab/git_spec.rb
+++ b/spec/lib/gitlab/git_spec.rb
@@ -1,11 +1,10 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Git do
- let(:committer_email) { 'user@example.org' }
- let(:committer_name) { 'John Doe' }
+ let(:committer_email) { "user@example.org" }
+ let(:committer_name) { "John Doe" }
- describe 'committer_hash' do
+ describe "committer_hash" do
it "returns a hash containing the given email and name" do
committer_hash = described_class.committer_hash(email: committer_email, name: committer_name)
@@ -14,7 +13,7 @@ describe Gitlab::Git do
expect(committer_hash[:time]).to be_a(Time)
end
- context 'when email is nil' do
+ context "when email is nil" do
it "returns nil" do
committer_hash = described_class.committer_hash(email: nil, name: committer_name)
@@ -22,7 +21,7 @@ describe Gitlab::Git do
end
end
- context 'when name is nil' do
+ context "when name is nil" do
it "returns nil" do
committer_hash = described_class.committer_hash(email: committer_email, name: nil)
@@ -31,15 +30,15 @@ describe Gitlab::Git do
end
end
- describe '.ref_name' do
- it 'ensure ref is a valid UTF-8 string' do
+ describe ".ref_name" do
+ it "ensure ref is a valid UTF-8 string" do
utf8_invalid_ref = Gitlab::Git::BRANCH_REF_PREFIX + "an_invalid_ref_\xE5"
expect(described_class.ref_name(utf8_invalid_ref)).to eq("an_invalid_ref_å")
end
end
- describe '.shas_eql?' do
+ describe ".shas_eql?" do
using RSpec::Parameterized::TableSyntax
where(:sha1, :sha2, :result) do
@@ -52,13 +51,13 @@ describe Gitlab::Git do
[sha, short_sha, true],
[sha, sha.reverse, false],
[sha, too_short_sha, false],
- [sha, nil, false]
+ [sha, nil, false],
]
end
with_them do
it { expect(described_class.shas_eql?(sha1, sha2)).to eq(result) }
- it 'is commutative' do
+ it "is commutative" do
expect(described_class.shas_eql?(sha2, sha1)).to eq(result)
end
end
diff --git a/spec/lib/gitlab/gitaly_client/blob_service_spec.rb b/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
index a2770ef2fe4..bc105f3d89e 100644
--- a/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/blob_service_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::BlobService do
let(:project) { create(:project, :repository) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:repository) { project.repository }
let(:client) { described_class.new(repository) }
- describe '#get_new_lfs_pointers' do
- let(:revision) { 'master' }
+ describe "#get_new_lfs_pointers" do
+ let(:revision) { "master" }
let(:limit) { 5 }
- let(:not_in) { ['branch-a', 'branch-b'] }
+ let(:not_in) { ["branch-a", "branch-b"] }
let(:expected_params) do
- { revision: revision, limit: limit, not_in_refs: not_in, not_in_all: false }
+ {revision: revision, limit: limit, not_in_refs: not_in, not_in_all: false}
end
subject { client.get_new_lfs_pointers(revision, limit, not_in) }
- it 'sends a get_new_lfs_pointers message' do
+ it "sends a get_new_lfs_pointers message" do
expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_new_lfs_pointers)
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
@@ -26,13 +26,13 @@ describe Gitlab::GitalyClient::BlobService do
subject
end
- context 'with not_in = :all' do
+ context "with not_in = :all" do
let(:not_in) { :all }
let(:expected_params) do
- { revision: revision, limit: limit, not_in_refs: [], not_in_all: true }
+ {revision: revision, limit: limit, not_in_refs: [], not_in_all: true}
end
- it 'sends the correct message' do
+ it "sends the correct message" do
expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_new_lfs_pointers)
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
@@ -43,12 +43,12 @@ describe Gitlab::GitalyClient::BlobService do
end
end
- describe '#get_all_lfs_pointers' do
- let(:revision) { 'master' }
+ describe "#get_all_lfs_pointers" do
+ let(:revision) { "master" }
subject { client.get_all_lfs_pointers(revision) }
- it 'sends a get_all_lfs_pointers message' do
+ it "sends a get_all_lfs_pointers message" do
expect_any_instance_of(Gitaly::BlobService::Stub)
.to receive(:get_all_lfs_pointers)
.with(gitaly_request_with_params(revision: revision), kind_of(Hash))
diff --git a/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
index 742b2872c40..2d3d91559f9 100644
--- a/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/blobs_stitcher_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::BlobsStitcher do
- describe 'enumeration' do
- it 'combines segregated blob messages together' do
+ describe "enumeration" do
+ it "combines segregated blob messages together" do
messages = [
- OpenStruct.new(oid: 'abcdef1', path: 'path/to/file', size: 1642, revision: 'f00ba7', mode: 0100644, data: "first-line\n"),
- OpenStruct.new(oid: '', data: 'second-line'),
- OpenStruct.new(oid: '', data: '', revision: 'f00ba7', path: 'path/to/non-existent/file'),
- OpenStruct.new(oid: 'abcdef2', path: 'path/to/another-file', size: 2461, revision: 'f00ba8', mode: 0100644, data: "GIF87a\x90\x01".b)
+ OpenStruct.new(oid: "abcdef1", path: "path/to/file", size: 1642, revision: "f00ba7", mode: 0o100644, data: "first-line\n"),
+ OpenStruct.new(oid: "", data: "second-line"),
+ OpenStruct.new(oid: "", data: "", revision: "f00ba7", path: "path/to/non-existent/file"),
+ OpenStruct.new(oid: "abcdef2", path: "path/to/another-file", size: 2461, revision: "f00ba8", mode: 0o100644, data: "GIF87a\x90\x01".b),
]
blobs = described_class.new(messages).to_a
expect(blobs.size).to be(2)
- expect(blobs[0].id).to eq('abcdef1')
- expect(blobs[0].mode).to eq('100644')
- expect(blobs[0].name).to eq('file')
- expect(blobs[0].path).to eq('path/to/file')
+ expect(blobs[0].id).to eq("abcdef1")
+ expect(blobs[0].mode).to eq("100644")
+ expect(blobs[0].name).to eq("file")
+ expect(blobs[0].path).to eq("path/to/file")
expect(blobs[0].size).to eq(1642)
- expect(blobs[0].commit_id).to eq('f00ba7')
+ expect(blobs[0].commit_id).to eq("f00ba7")
expect(blobs[0].data).to eq("first-line\nsecond-line")
expect(blobs[0].binary_in_repo?).to be false
- expect(blobs[1].id).to eq('abcdef2')
- expect(blobs[1].mode).to eq('100644')
- expect(blobs[1].name).to eq('another-file')
- expect(blobs[1].path).to eq('path/to/another-file')
+ expect(blobs[1].id).to eq("abcdef2")
+ expect(blobs[1].mode).to eq("100644")
+ expect(blobs[1].name).to eq("another-file")
+ expect(blobs[1].path).to eq("path/to/another-file")
expect(blobs[1].size).to eq(2461)
- expect(blobs[1].commit_id).to eq('f00ba8')
+ expect(blobs[1].commit_id).to eq("f00ba8")
expect(blobs[1].data).to eq("GIF87a\x90\x01".b)
expect(blobs[1].binary_in_repo?).to be true
end
diff --git a/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb b/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
index 369deff732a..58fe7cc2a38 100644
--- a/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/cleanup_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::CleanupService do
let(:project) { create(:project) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:client) { described_class.new(project.repository) }
- describe '#apply_bfg_object_map' do
- it 'sends an apply_bfg_object_map message' do
+ describe "#apply_bfg_object_map" do
+ it "sends an apply_bfg_object_map message" do
expect_any_instance_of(Gitaly::CleanupService::Stub)
.to receive(:apply_bfg_object_map)
.with(kind_of(Enumerator), kind_of(Hash))
diff --git a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
index d7bd757149d..bbf88cd8a44 100644
--- a/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_service_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::CommitService do
let(:project) { create(:project, :repository) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:repository) { project.repository }
let(:repository_message) { repository.gitaly_repository }
- let(:revision) { '913c66a37b4a45b9769037c55c2d238bd0942d2e' }
+ let(:revision) { "913c66a37b4a45b9769037c55c2d238bd0942d2e" }
let(:commit) { project.commit(revision) }
let(:client) { described_class.new(repository) }
- describe '#diff_from_parent' do
- context 'when a commit has a parent' do
- it 'sends an RPC request with the parent ID as left commit' do
+ describe "#diff_from_parent" do
+ context "when a commit has a parent" do
+ it "sends an RPC request with the parent ID as left commit" do
request = Gitaly::CommitDiffRequest.new(
repository: repository_message,
- left_commit_id: 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660',
+ left_commit_id: "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
right_commit_id: commit.id,
collapse_diffs: false,
enforce_limits: true,
@@ -35,9 +35,9 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- context 'when a commit does not have a parent' do
- it 'sends an RPC request with empty tree ref as left commit' do
- initial_commit = project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863').raw
+ context "when a commit does not have a parent" do
+ it "sends an RPC request with empty tree ref as left commit" do
+ initial_commit = project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863").raw
request = Gitaly::CommitDiffRequest.new(
repository: repository_message,
left_commit_id: Gitlab::Git::EMPTY_TREE_ID,
@@ -60,23 +60,23 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- it 'returns a Gitlab::GitalyClient::DiffStitcher' do
+ it "returns a Gitlab::GitalyClient::DiffStitcher" do
ret = client.diff_from_parent(commit)
expect(ret).to be_kind_of(Gitlab::GitalyClient::DiffStitcher)
end
- it 'encodes paths correctly' do
- expect { client.diff_from_parent(commit, paths: ['encoding/test.txt', 'encoding/テスト.txt', nil]) }.not_to raise_error
+ it "encodes paths correctly" do
+ expect { client.diff_from_parent(commit, paths: ["encoding/test.txt", "encoding/テスト.txt", nil]) }.not_to raise_error
end
end
- describe '#commit_deltas' do
- context 'when a commit has a parent' do
- it 'sends an RPC request with the parent ID as left commit' do
+ describe "#commit_deltas" do
+ context "when a commit has a parent" do
+ it "sends an RPC request with the parent ID as left commit" do
request = Gitaly::CommitDeltaRequest.new(
repository: repository_message,
- left_commit_id: 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660',
+ left_commit_id: "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
right_commit_id: commit.id
)
@@ -86,9 +86,9 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- context 'when a commit does not have a parent' do
- it 'sends an RPC request with empty tree ref as left commit' do
- initial_commit = project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863')
+ context "when a commit does not have a parent" do
+ it "sends an RPC request with empty tree ref as left commit" do
+ initial_commit = project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863")
request = Gitaly::CommitDeltaRequest.new(
repository: repository_message,
left_commit_id: Gitlab::Git::EMPTY_TREE_ID,
@@ -102,11 +102,11 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#between' do
- let(:from) { 'master' }
+ describe "#between" do
+ let(:from) { "master" }
let(:to) { Gitlab::Git::EMPTY_TREE_ID }
- it 'sends an RPC request' do
+ it "sends an RPC request" do
request = Gitaly::CommitsBetweenRequest.new(
repository: repository_message, from: from, to: to
)
@@ -118,11 +118,11 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#diff_stats' do
- let(:left_commit_id) { 'master' }
- let(:right_commit_id) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
+ describe "#diff_stats" do
+ let(:left_commit_id) { "master" }
+ let(:right_commit_id) { "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" }
- it 'sends an RPC request' do
+ it "sends an RPC request" do
request = Gitaly::DiffStatsRequest.new(repository: repository_message,
left_commit_id: left_commit_id,
right_commit_id: right_commit_id)
@@ -134,10 +134,10 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#tree_entries' do
- let(:path) { '/' }
+ describe "#tree_entries" do
+ let(:path) { "/" }
- it 'sends a get_tree_entries message' do
+ it "sends a get_tree_entries message" do
expect_any_instance_of(Gitaly::CommitService::Stub)
.to receive(:get_tree_entries)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -146,11 +146,11 @@ describe Gitlab::GitalyClient::CommitService do
client.tree_entries(repository, revision, path, false)
end
- context 'with UTF-8 params strings' do
+ context "with UTF-8 params strings" do
let(:revision) { "branch\u011F" }
let(:path) { "foo/\u011F.txt" }
- it 'handles string encodings correctly' do
+ it "handles string encodings correctly" do
expect_any_instance_of(Gitaly::CommitService::Stub)
.to receive(:get_tree_entries)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -161,32 +161,32 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#commit_count' do
+ describe "#commit_count" do
before do
expect_any_instance_of(Gitaly::CommitService::Stub)
.to receive(:count_commits)
.with(gitaly_request_with_path(storage_name, relative_path),
- kind_of(Hash))
+ kind_of(Hash))
.and_return([])
end
- it 'sends a commit_count message' do
+ it "sends a commit_count message" do
client.commit_count(revision)
end
- context 'with UTF-8 params strings' do
+ context "with UTF-8 params strings" do
let(:revision) { "branch\u011F" }
let(:path) { "foo/\u011F.txt" }
- it 'handles string encodings correctly' do
+ it "handles string encodings correctly" do
client.commit_count(revision, path: path)
end
end
end
- describe '#find_commit' do
+ describe "#find_commit" do
let(:revision) { Gitlab::Git::EMPTY_TREE_ID }
- it 'sends an RPC request' do
+ it "sends an RPC request" do
request = Gitaly::FindCommitRequest.new(
repository: repository_message, revision: revision
)
@@ -197,26 +197,26 @@ describe Gitlab::GitalyClient::CommitService do
described_class.new(repository).find_commit(revision)
end
- describe 'caching', :request_store do
- let(:commit_dbl) { double(id: 'f01b' * 10) }
+ describe "caching", :request_store do
+ let(:commit_dbl) { double(id: "f01b" * 10) }
- context 'when passed revision is a branch name' do
- it 'calls Gitaly' do
+ context "when passed revision is a branch name" do
+ it "calls Gitaly" do
expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commit).twice.and_return(double(commit: commit_dbl))
commit = nil
- 2.times { commit = described_class.new(repository).find_commit('master') }
+ 2.times { commit = described_class.new(repository).find_commit("master") }
expect(commit).to eq(commit_dbl)
end
end
- context 'when passed revision is a commit ID' do
- it 'returns a cached commit' do
+ context "when passed revision is a commit ID" do
+ it "returns a cached commit" do
expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:find_commit).once.and_return(double(commit: commit_dbl))
commit = nil
- 2.times { commit = described_class.new(repository).find_commit('f01b' * 10) }
+ 2.times { commit = described_class.new(repository).find_commit("f01b" * 10) }
expect(commit).to eq(commit_dbl)
end
@@ -224,7 +224,7 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#patch' do
+ describe "#patch" do
let(:request) do
Gitaly::CommitPatchRequest.new(
repository: repository_message, revision: revision
@@ -234,14 +234,14 @@ describe Gitlab::GitalyClient::CommitService do
subject { described_class.new(repository).patch(revision) }
- it 'sends an RPC request' do
+ it "sends an RPC request" do
expect_any_instance_of(Gitaly::DiffService::Stub).to receive(:commit_patch)
.with(request, kind_of(Hash)).and_return([])
subject
end
- it 'concatenates the responses data' do
+ it "concatenates the responses data" do
allow_any_instance_of(Gitaly::DiffService::Stub).to receive(:commit_patch)
.with(request, kind_of(Hash)).and_return(response)
@@ -249,7 +249,7 @@ describe Gitlab::GitalyClient::CommitService do
end
end
- describe '#commit_stats' do
+ describe "#commit_stats" do
let(:request) do
Gitaly::CommitStatsRequest.new(
repository: repository_message, revision: revision
@@ -265,7 +265,7 @@ describe Gitlab::GitalyClient::CommitService do
subject { described_class.new(repository).commit_stats(revision) }
- it 'sends an RPC request' do
+ it "sends an RPC request" do
expect_any_instance_of(Gitaly::CommitService::Stub).to receive(:commit_stats)
.with(request, kind_of(Hash)).and_return(response)
diff --git a/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
index 1c933410bd5..0e1ed333e97 100644
--- a/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/conflict_files_stitcher_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::ConflictFilesStitcher do
- describe 'enumeration' do
- it 'combines segregated ConflictFile messages together' do
+ describe "enumeration" do
+ it "combines segregated ConflictFile messages together" do
target_project = create(:project, :repository)
target_repository = target_project.repository.raw
target_gitaly_repository = target_repository.gitaly_repository
- our_path_1 = 'our/path/1'
- their_path_1 = 'their/path/1'
- our_mode_1 = 0744
- commit_oid_1 = 'f00'
- content_1 = 'content of the first file'
+ our_path_1 = "our/path/1"
+ their_path_1 = "their/path/1"
+ our_mode_1 = 0o744
+ commit_oid_1 = "f00"
+ content_1 = "content of the first file"
- our_path_2 = 'our/path/2'
- their_path_2 = 'their/path/2'
- our_mode_2 = 0600
- commit_oid_2 = 'ba7'
- content_2 = 'content of the second file'
+ our_path_2 = "our/path/2"
+ their_path_2 = "their/path/2"
+ our_mode_2 = 0o600
+ commit_oid_2 = "ba7"
+ content_2 = "content of the second file"
header_1 = double(repository: target_gitaly_repository, commit_oid: commit_oid_1,
our_path: our_path_1, their_path: their_path_1, our_mode: our_mode_1)
@@ -29,7 +29,7 @@ describe Gitlab::GitalyClient::ConflictFilesStitcher do
double(files: [double(header: nil, content: content_1[6..-1])]),
double(files: [double(header: header_2)]),
double(files: [double(header: nil, content: content_2[0..5]), double(header: nil, content: content_2[6..10])]),
- double(files: [double(header: nil, content: content_2[11..-1])])
+ double(files: [double(header: nil, content: content_2[11..-1])]),
]
conflict_files = described_class.new(messages).to_a
diff --git a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb
index e4fe01a671f..bcac3fab9af 100644
--- a/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/conflicts_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::ConflictsService do
let(:project) { create(:project, :repository) }
@@ -6,13 +6,13 @@ describe Gitlab::GitalyClient::ConflictsService do
let(:source_repository) { project.repository.raw }
let(:target_repository) { target_project.repository.raw }
let(:target_gitaly_repository) { target_repository.gitaly_repository }
- let(:our_commit_oid) { 'f00' }
- let(:their_commit_oid) { 'f44' }
+ let(:our_commit_oid) { "f00" }
+ let(:their_commit_oid) { "f44" }
let(:client) do
described_class.new(target_repository, our_commit_oid, their_commit_oid)
end
- describe '#list_conflict_files' do
+ describe "#list_conflict_files" do
let(:request) do
Gitaly::ListConflictFilesRequest.new(
repository: target_gitaly_repository, our_commit_oid: our_commit_oid,
@@ -20,7 +20,7 @@ describe Gitlab::GitalyClient::ConflictsService do
)
end
- it 'sends an RPC request' do
+ it "sends an RPC request" do
expect_any_instance_of(Gitaly::ConflictsService::Stub).to receive(:list_conflict_files)
.with(request, kind_of(Hash)).and_return([].to_enum)
@@ -28,14 +28,14 @@ describe Gitlab::GitalyClient::ConflictsService do
end
end
- describe '#resolve_conflicts' do
+ describe "#resolve_conflicts" do
let(:user) { create(:user) }
let(:files) do
- [{ old_path: 'some/path', new_path: 'some/path', content: '' }]
+ [{old_path: "some/path", new_path: "some/path", content: ""}]
end
- let(:source_branch) { 'master' }
- let(:target_branch) { 'feature' }
- let(:commit_message) { 'Solving conflicts' }
+ let(:source_branch) { "master" }
+ let(:target_branch) { "feature" }
+ let(:commit_message) { "Solving conflicts" }
let(:resolution) do
Gitlab::Git::Conflict::Resolution.new(user, files, commit_message)
end
@@ -44,14 +44,14 @@ describe Gitlab::GitalyClient::ConflictsService do
client.resolve_conflicts(source_repository, resolution, source_branch, target_branch)
end
- it 'sends an RPC request' do
+ it "sends an RPC request" do
expect_any_instance_of(Gitaly::ConflictsService::Stub).to receive(:resolve_conflicts)
.with(kind_of(Enumerator), kind_of(Hash)).and_return(double(resolution_error: ""))
subject
end
- it 'raises a relevant exception if resolution_error is present' do
+ it "raises a relevant exception if resolution_error is present" do
expect_any_instance_of(Gitaly::ConflictsService::Stub).to receive(:resolve_conflicts)
.with(kind_of(Enumerator), kind_of(Hash)).and_return(double(resolution_error: "something happened"))
diff --git a/spec/lib/gitlab/gitaly_client/diff_spec.rb b/spec/lib/gitlab/gitaly_client/diff_spec.rb
index ec7ab2fdedb..50c826ae26a 100644
--- a/spec/lib/gitlab/gitaly_client/diff_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/diff_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::Diff do
let(:diff_fields) do
{
to_path: ".gitmodules",
from_path: ".gitmodules",
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '357406f3075a57708d0163752905cc1576fceacc',
- to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0',
- patch: 'a' * 100,
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "357406f3075a57708d0163752905cc1576fceacc",
+ to_id: "8e5177d718c561d36efde08bad36b43687ee6bf0",
+ patch: "a" * 100,
collapsed: false,
- too_large: false
+ too_large: false,
}
end
@@ -27,8 +27,8 @@ describe Gitlab::GitalyClient::Diff do
it { is_expected.to respond_to(:collapsed) }
it { is_expected.to respond_to(:too_large) }
- describe '#==' do
+ describe "#==" do
it { expect(subject).to eq(described_class.new(diff_fields)) }
- it { expect(subject).not_to eq(described_class.new(diff_fields.merge(patch: 'a'))) }
+ it { expect(subject).not_to eq(described_class.new(diff_fields.merge(patch: "a"))) }
end
end
diff --git a/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb b/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb
index cd3242b9326..80844946203 100644
--- a/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/diff_stitcher_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::DiffStitcher do
- describe 'enumeration' do
- it 'combines segregated diff messages together' do
+ describe "enumeration" do
+ it "combines segregated diff messages together" do
diff_1 = OpenStruct.new(
to_path: ".gitmodules",
from_path: ".gitmodules",
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '357406f3075a57708d0163752905cc1576fceacc',
- to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0',
- patch: 'a' * 100
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "357406f3075a57708d0163752905cc1576fceacc",
+ to_id: "8e5177d718c561d36efde08bad36b43687ee6bf0",
+ patch: "a" * 100
)
diff_2 = OpenStruct.new(
to_path: ".gitignore",
from_path: ".gitignore",
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '357406f3075a57708d0163752905cc1576fceacc',
- to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0',
- patch: 'a' * 200
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "357406f3075a57708d0163752905cc1576fceacc",
+ to_id: "8e5177d718c561d36efde08bad36b43687ee6bf0",
+ patch: "a" * 200
)
diff_3 = OpenStruct.new(
to_path: "README",
from_path: "README",
- old_mode: 0100644,
- new_mode: 0100644,
- from_id: '357406f3075a57708d0163752905cc1576fceacc',
- to_id: '8e5177d718c561d36efde08bad36b43687ee6bf0',
- patch: 'a' * 100
+ old_mode: 0o100644,
+ new_mode: 0o100644,
+ from_id: "357406f3075a57708d0163752905cc1576fceacc",
+ to_id: "8e5177d718c561d36efde08bad36b43687ee6bf0",
+ patch: "a" * 100
)
msg_1 = OpenStruct.new(diff_1.to_h.except(:patch))
@@ -50,7 +50,7 @@ describe Gitlab::GitalyClient::DiffStitcher do
expected_diffs = [
Gitlab::GitalyClient::Diff.new(diff_1.to_h),
Gitlab::GitalyClient::Diff.new(diff_2.to_h),
- Gitlab::GitalyClient::Diff.new(diff_3.to_h)
+ Gitlab::GitalyClient::Diff.new(diff_3.to_h),
]
expect(described_class.new(diff_msgs).to_a).to eq(expected_diffs)
diff --git a/spec/lib/gitlab/gitaly_client/health_check_service_spec.rb b/spec/lib/gitlab/gitaly_client/health_check_service_spec.rb
index 2c7e5eb5787..c7e119cd76d 100644
--- a/spec/lib/gitlab/gitaly_client/health_check_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/health_check_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::HealthCheckService do
let(:project) { create(:project) }
@@ -6,36 +6,38 @@ describe Gitlab::GitalyClient::HealthCheckService do
subject { described_class.new(storage_name) }
- describe '#check' do
- it 'successfully sends a health check request' do
+ describe "#check" do
+ it "successfully sends a health check request" do
expect(Gitlab::GitalyClient).to receive(:call).with(
storage_name,
:health_check,
:check,
instance_of(Grpc::Health::V1::HealthCheckRequest),
- timeout: Gitlab::GitalyClient.fast_timeout).and_call_original
+ timeout: Gitlab::GitalyClient.fast_timeout
+ ).and_call_original
- expect(subject.check).to eq({ success: true })
+ expect(subject.check).to eq({success: true})
end
- it 'receives an unsuccessful health check request' do
+ it "receives an unsuccessful health check request" do
expect_any_instance_of(Grpc::Health::V1::Health::Stub)
.to receive(:check)
.and_return(double(status: false))
- expect(subject.check).to eq({ success: false })
+ expect(subject.check).to eq({success: false})
end
- it 'gracefully handles gRPC error' do
+ it "gracefully handles gRPC error" do
expect(Gitlab::GitalyClient).to receive(:call).with(
storage_name,
:health_check,
:check,
instance_of(Grpc::Health::V1::HealthCheckRequest),
- timeout: Gitlab::GitalyClient.fast_timeout)
- .and_raise(GRPC::Unavailable.new('Connection refused'))
+ timeout: Gitlab::GitalyClient.fast_timeout
+ )
+ .and_raise(GRPC::Unavailable.new("Connection refused"))
- expect(subject.check).to eq({ success: false, message: '14:Connection refused' })
+ expect(subject.check).to eq({success: false, message: "14:Connection refused"})
end
end
end
diff --git a/spec/lib/gitlab/gitaly_client/notification_service_spec.rb b/spec/lib/gitlab/gitaly_client/notification_service_spec.rb
index ffc3a09be30..367749a229a 100644
--- a/spec/lib/gitlab/gitaly_client/notification_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/notification_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::NotificationService do
- describe '#post_receive' do
+ describe "#post_receive" do
let(:project) { create(:project) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
subject { described_class.new(project.repository) }
- it 'sends a post_receive message' do
+ it "sends a post_receive message" do
expect_any_instance_of(Gitaly::NotificationService::Stub)
.to receive(:post_receive).with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
diff --git a/spec/lib/gitlab/gitaly_client/object_pool_service_spec.rb b/spec/lib/gitlab/gitaly_client/object_pool_service_spec.rb
index 149b7ec5bb0..d1d08db4d0f 100644
--- a/spec/lib/gitlab/gitaly_client/object_pool_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/object_pool_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::ObjectPoolService do
let(:pool_repository) { create(:pool_repository) }
@@ -14,28 +14,28 @@ describe Gitlab::GitalyClient::ObjectPoolService do
subject.create(raw_repository)
end
- describe '#create' do
- it 'exists on disk' do
+ describe "#create" do
+ it "exists on disk" do
expect(object_pool.repository.exists?).to be(true)
end
- context 'when the pool already exists' do
- it 'returns an error' do
- expect do
+ context "when the pool already exists" do
+ it "returns an error" do
+ expect {
subject.create(raw_repository)
- end.to raise_error(GRPC::FailedPrecondition)
+ }.to raise_error(GRPC::FailedPrecondition)
end
end
end
- describe '#delete' do
- it 'removes the repository from disk' do
+ describe "#delete" do
+ it "removes the repository from disk" do
subject.delete
expect(object_pool.repository.exists?).to be(false)
end
- context 'when called twice' do
+ context "when called twice" do
it "doesn't raise an error" do
subject.delete
diff --git a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
index b37fe2686b6..6645359ac70 100644
--- a/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/operation_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::OperationService do
set(:project) { create(:project, :repository) }
@@ -7,9 +7,9 @@ describe Gitlab::GitalyClient::OperationService do
set(:user) { create(:user) }
let(:gitaly_user) { Gitlab::Git::User.from_gitlab(user).to_gitaly }
- describe '#user_create_branch' do
- let(:branch_name) { 'new' }
- let(:start_point) { 'master' }
+ describe "#user_create_branch" do
+ let(:branch_name) { "new" }
+ let(:start_point) { "master" }
let(:request) do
Gitaly::UserCreateBranchRequest.new(
repository: repository.gitaly_repository,
@@ -28,7 +28,7 @@ describe Gitlab::GitalyClient::OperationService do
subject { client.user_create_branch(branch_name, user, start_point) }
- it 'sends a user_create_branch message and returns a Gitlab::git::Branch' do
+ it "sends a user_create_branch message and returns a Gitlab::git::Branch" do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_create_branch).with(request, kind_of(Hash))
.and_return(response)
@@ -48,15 +48,16 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
expect { subject }.to raise_error(
- Gitlab::Git::PreReceiveError, "something failed")
+ Gitlab::Git::PreReceiveError, "something failed"
+ )
end
end
end
- describe '#user_update_branch' do
- let(:branch_name) { 'my-branch' }
- let(:newrev) { '01e' }
- let(:oldrev) { '01d' }
+ describe "#user_update_branch" do
+ let(:branch_name) { "my-branch" }
+ let(:newrev) { "01e" }
+ let(:oldrev) { "01d" }
let(:request) do
Gitaly::UserUpdateBranchRequest.new(
repository: repository.gitaly_repository,
@@ -70,7 +71,7 @@ describe Gitlab::GitalyClient::OperationService do
subject { client.user_update_branch(branch_name, user, newrev, oldrev) }
- it 'sends a user_update_branch message' do
+ it "sends a user_update_branch message" do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_update_branch).with(request, kind_of(Hash))
.and_return(response)
@@ -89,13 +90,14 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
expect { subject }.to raise_error(
- Gitlab::Git::PreReceiveError, "something failed")
+ Gitlab::Git::PreReceiveError, "something failed"
+ )
end
end
end
- describe '#user_delete_branch' do
- let(:branch_name) { 'my-branch' }
+ describe "#user_delete_branch" do
+ let(:branch_name) { "my-branch" }
let(:request) do
Gitaly::UserDeleteBranchRequest.new(
repository: repository.gitaly_repository,
@@ -107,7 +109,7 @@ describe Gitlab::GitalyClient::OperationService do
subject { client.user_delete_branch(branch_name, user) }
- it 'sends a user_delete_branch message' do
+ it "sends a user_delete_branch message" do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_delete_branch).with(request, kind_of(Hash))
.and_return(response)
@@ -126,14 +128,15 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
expect { subject }.to raise_error(
- Gitlab::Git::PreReceiveError, "something failed")
+ Gitlab::Git::PreReceiveError, "something failed"
+ )
end
end
end
- describe '#user_ff_branch' do
- let(:target_branch) { 'my-branch' }
- let(:source_sha) { 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660' }
+ describe "#user_ff_branch" do
+ let(:target_branch) { "my-branch" }
+ let(:source_sha) { "cfe32cf61b73a0d5e9f13e774abde7ff789b1660" }
let(:request) do
Gitaly::UserFFBranchRequest.new(
repository: repository.gitaly_repository,
@@ -159,62 +162,62 @@ describe Gitlab::GitalyClient::OperationService do
subject { client.user_ff_branch(user, source_sha, target_branch) }
- it 'sends a user_ff_branch message and returns a BranchUpdate object' do
+ it "sends a user_ff_branch message and returns a BranchUpdate object" do
expect(subject).to be_a(Gitlab::Git::OperationService::BranchUpdate)
expect(subject.newrev).to eq(source_sha)
expect(subject.repo_created).to be(false)
expect(subject.branch_created).to be(false)
end
- context 'when the response has no branch_update' do
+ context "when the response has no branch_update" do
let(:response) { Gitaly::UserFFBranchResponse.new }
it { expect(subject).to be_nil }
end
end
- shared_examples 'cherry pick and revert errors' do
- context 'when a pre_receive_error is present' do
+ shared_examples "cherry pick and revert errors" do
+ context "when a pre_receive_error is present" do
let(:response) { response_class.new(pre_receive_error: "something failed") }
- it 'raises a PreReceiveError' do
+ it "raises a PreReceiveError" do
expect { subject }.to raise_error(Gitlab::Git::PreReceiveError, "something failed")
end
end
- context 'when a commit_error is present' do
+ context "when a commit_error is present" do
let(:response) { response_class.new(commit_error: "something failed") }
- it 'raises a CommitError' do
+ it "raises a CommitError" do
expect { subject }.to raise_error(Gitlab::Git::CommitError, "something failed")
end
end
- context 'when a create_tree_error is present' do
+ context "when a create_tree_error is present" do
let(:response) { response_class.new(create_tree_error: "something failed") }
- it 'raises a CreateTreeError' do
+ it "raises a CreateTreeError" do
expect { subject }.to raise_error(Gitlab::Git::Repository::CreateTreeError, "something failed")
end
end
- context 'when branch_update is nil' do
+ context "when branch_update is nil" do
let(:response) { response_class.new }
it { expect(subject).to be_nil }
end
end
- describe '#user_cherry_pick' do
+ describe "#user_cherry_pick" do
let(:response_class) { Gitaly::UserCherryPickResponse }
subject do
client.user_cherry_pick(
user: user,
commit: repository.commit,
- branch_name: 'master',
- message: 'Cherry-pick message',
- start_branch_name: 'master',
+ branch_name: "master",
+ message: "Cherry-pick message",
+ start_branch_name: "master",
start_repository: repository
)
end
@@ -225,19 +228,19 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
end
- it_behaves_like 'cherry pick and revert errors'
+ it_behaves_like "cherry pick and revert errors"
end
- describe '#user_revert' do
+ describe "#user_revert" do
let(:response_class) { Gitaly::UserRevertResponse }
subject do
client.user_revert(
user: user,
commit: repository.commit,
- branch_name: 'master',
- message: 'Revert message',
- start_branch_name: 'master',
+ branch_name: "master",
+ message: "Revert message",
+ start_branch_name: "master",
start_repository: repository
)
end
@@ -248,15 +251,15 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
end
- it_behaves_like 'cherry pick and revert errors'
+ it_behaves_like "cherry pick and revert errors"
end
- describe '#user_squash' do
- let(:branch_name) { 'my-branch' }
- let(:squash_id) { '1' }
- let(:start_sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
- let(:end_sha) { '54cec5282aa9f21856362fe321c800c236a61615' }
- let(:commit_message) { 'Squash message' }
+ describe "#user_squash" do
+ let(:branch_name) { "my-branch" }
+ let(:squash_id) { "1" }
+ let(:start_sha) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
+ let(:end_sha) { "54cec5282aa9f21856362fe321c800c236a61615" }
+ let(:commit_message) { "Squash message" }
let(:request) do
Gitaly::UserSquashRequest.new(
repository: repository.gitaly_repository,
@@ -269,14 +272,14 @@ describe Gitlab::GitalyClient::OperationService do
commit_message: commit_message
)
end
- let(:squash_sha) { 'f00' }
+ let(:squash_sha) { "f00" }
let(:response) { Gitaly::UserSquashResponse.new(squash_sha: squash_sha) }
subject do
client.user_squash(user, squash_id, branch_name, start_sha, end_sha, user, commit_message)
end
- it 'sends a user_squash message and returns the squash sha' do
+ it "sends a user_squash message and returns the squash sha" do
expect_any_instance_of(Gitaly::OperationService::Stub)
.to receive(:user_squash).with(request, kind_of(Hash))
.and_return(response)
@@ -295,15 +298,17 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
expect { subject }.to raise_error(
- Gitlab::Git::Repository::GitError, "something failed")
+ Gitlab::Git::Repository::GitError, "something failed"
+ )
end
end
- describe '#user_commit_files' do
+ describe "#user_commit_files" do
subject do
client.user_commit_files(
- gitaly_user, 'my-branch', 'Commit files message', [], 'janedoe@example.com', 'Jane Doe',
- 'master', repository)
+ gitaly_user, "my-branch", "Commit files message", [], "janedoe@example.com", "Jane Doe",
+ "master", repository
+ )
end
before do
@@ -312,23 +317,23 @@ describe Gitlab::GitalyClient::OperationService do
.and_return(response)
end
- context 'when a pre_receive_error is present' do
+ context "when a pre_receive_error is present" do
let(:response) { Gitaly::UserCommitFilesResponse.new(pre_receive_error: "something failed") }
- it 'raises a PreReceiveError' do
+ it "raises a PreReceiveError" do
expect { subject }.to raise_error(Gitlab::Git::PreReceiveError, "something failed")
end
end
- context 'when an index_error is present' do
+ context "when an index_error is present" do
let(:response) { Gitaly::UserCommitFilesResponse.new(index_error: "something failed") }
- it 'raises a PreReceiveError' do
+ it "raises a PreReceiveError" do
expect { subject }.to raise_error(Gitlab::Git::Index::IndexError, "something failed")
end
end
- context 'when branch_update is nil' do
+ context "when branch_update is nil" do
let(:response) { Gitaly::UserCommitFilesResponse.new }
it { expect(subject).to be_nil }
@@ -336,34 +341,34 @@ describe Gitlab::GitalyClient::OperationService do
end
end
- describe '#user_commit_patches' do
- let(:patches_folder) { Rails.root.join('spec/fixtures/patchfiles') }
+ describe "#user_commit_patches" do
+ let(:patches_folder) { Rails.root.join("spec/fixtures/patchfiles") }
let(:patch_content) do
patch_names.map { |name| File.read(File.join(patches_folder, name)) }.join("\n")
end
- let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) }
- let(:branch_name) { 'branch-with-patches' }
+ let(:patch_names) { %w[0001-This-does-not-apply-to-the-feature-branch.patch] }
+ let(:branch_name) { "branch-with-patches" }
subject(:commit_patches) do
client.user_commit_patches(user, branch_name, patch_content)
end
- it 'applies the patch correctly' do
+ it "applies the patch correctly" do
branch_update = commit_patches
expect(branch_update).to be_branch_created
commit = repository.commit(branch_update.newrev)
- expect(commit.author_email).to eq('patchuser@gitlab.org')
+ expect(commit.author_email).to eq("patchuser@gitlab.org")
expect(commit.committer_email).to eq(user.email)
- expect(commit.message.chomp).to eq('This does not apply to the `feature` branch')
+ expect(commit.message.chomp).to eq("This does not apply to the `feature` branch")
end
- context 'when the patch could not be applied' do
- let(:patch_names) { %w(0001-This-does-not-apply-to-the-feature-branch.patch) }
- let(:branch_name) { 'feature' }
+ context "when the patch could not be applied" do
+ let(:patch_names) { %w[0001-This-does-not-apply-to-the-feature-branch.patch] }
+ let(:branch_name) { "feature" }
- it 'raises the correct error' do
+ it "raises the correct error" do
expect { commit_patches }.to raise_error(GRPC::FailedPrecondition)
end
end
diff --git a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
index 400d426c949..5d4faafbe32 100644
--- a/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/ref_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::RefService do
let(:project) { create(:project, :repository) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:repository) { project.repository }
let(:client) { described_class.new(repository) }
- describe '#branches' do
- it 'sends a find_all_branches message' do
+ describe "#branches" do
+ it "sends a find_all_branches message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_all_branches)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -18,11 +18,11 @@ describe Gitlab::GitalyClient::RefService do
end
end
- describe '#remote_branches' do
- let(:remote_name) { 'my_remote' }
+ describe "#remote_branches" do
+ let(:remote_name) { "my_remote" }
subject { client.remote_branches(remote_name) }
- it 'sends a find_all_remote_branches message' do
+ it "sends a find_all_remote_branches message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_all_remote_branches)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -31,14 +31,14 @@ describe Gitlab::GitalyClient::RefService do
subject
end
- it 'concantes and returns the response branches as Gitlab::Git::Branch objects' do
+ it "concantes and returns the response branches as Gitlab::Git::Branch objects" do
target_commits = create_list(:gitaly_commit, 4)
- response_branches = target_commits.each_with_index.map do |gitaly_commit, i|
+ response_branches = target_commits.each_with_index.map { |gitaly_commit, i|
Gitaly::Branch.new(name: "#{remote_name}/#{i}", target_commit: gitaly_commit)
- end
+ }
response = [
Gitaly::FindAllRemoteBranchesResponse.new(branches: response_branches[0, 2]),
- Gitaly::FindAllRemoteBranchesResponse.new(branches: response_branches[2, 2])
+ Gitaly::FindAllRemoteBranchesResponse.new(branches: response_branches[2, 2]),
]
expect_any_instance_of(Gitaly::RefService::Stub)
@@ -56,8 +56,8 @@ describe Gitlab::GitalyClient::RefService do
end
end
- describe '#branch_names' do
- it 'sends a find_all_branch_names message' do
+ describe "#branch_names" do
+ it "sends a find_all_branch_names message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_all_branch_names)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -67,8 +67,8 @@ describe Gitlab::GitalyClient::RefService do
end
end
- describe '#tag_names' do
- it 'sends a find_all_tag_names message' do
+ describe "#tag_names" do
+ it "sends a find_all_tag_names message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_all_tag_names)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -78,19 +78,19 @@ describe Gitlab::GitalyClient::RefService do
end
end
- describe '#default_branch_name' do
- it 'sends a find_default_branch_name message' do
+ describe "#default_branch_name" do
+ it "sends a find_default_branch_name message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_default_branch_name)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
- .and_return(double(name: 'foo'))
+ .and_return(double(name: "foo"))
client.default_branch_name
end
end
- describe '#local_branches' do
- it 'sends a find_local_branches message' do
+ describe "#local_branches" do
+ it "sends a find_local_branches message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_local_branches)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -99,58 +99,58 @@ describe Gitlab::GitalyClient::RefService do
client.local_branches
end
- it 'parses and sends the sort parameter' do
+ it "parses and sends the sort parameter" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_local_branches)
.with(gitaly_request_with_params(sort_by: :UPDATED_DESC), kind_of(Hash))
.and_return([])
- client.local_branches(sort_by: 'updated_desc')
+ client.local_branches(sort_by: "updated_desc")
end
- it 'translates known mismatches on sort param values' do
+ it "translates known mismatches on sort param values" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:find_local_branches)
.with(gitaly_request_with_params(sort_by: :NAME), kind_of(Hash))
.and_return([])
- client.local_branches(sort_by: 'name_asc')
+ client.local_branches(sort_by: "name_asc")
end
- it 'raises an argument error if an invalid sort_by parameter is passed' do
- expect { client.local_branches(sort_by: 'invalid_sort') }.to raise_error(ArgumentError)
+ it "raises an argument error if an invalid sort_by parameter is passed" do
+ expect { client.local_branches(sort_by: "invalid_sort") }.to raise_error(ArgumentError)
end
end
- describe '#find_ref_name', :seed_helper do
- subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') }
+ describe "#find_ref_name", :seed_helper do
+ subject { client.find_ref_name(SeedRepo::Commit::ID, "refs/heads/master") }
it { is_expected.to be_utf8 }
- it { is_expected.to eq('refs/heads/master') }
+ it { is_expected.to eq("refs/heads/master") }
end
- describe '#ref_exists?', :seed_helper do
- it 'finds the master branch ref' do
- expect(client.ref_exists?('refs/heads/master')).to eq(true)
+ describe "#ref_exists?", :seed_helper do
+ it "finds the master branch ref" do
+ expect(client.ref_exists?("refs/heads/master")).to eq(true)
end
- it 'returns false for an illegal tag name ref' do
- expect(client.ref_exists?('refs/tags/.this-tag-name-is-illegal')).to eq(false)
+ it "returns false for an illegal tag name ref" do
+ expect(client.ref_exists?("refs/tags/.this-tag-name-is-illegal")).to eq(false)
end
- it 'raises an argument error if the ref name parameter does not start with refs/' do
- expect { client.ref_exists?('reXXXXX') }.to raise_error(ArgumentError)
+ it "raises an argument error if the ref name parameter does not start with refs/" do
+ expect { client.ref_exists?("reXXXXX") }.to raise_error(ArgumentError)
end
end
- describe '#delete_refs' do
- let(:prefixes) { %w(refs/heads refs/keep-around) }
+ describe "#delete_refs" do
+ let(:prefixes) { %w[refs/heads refs/keep-around] }
- it 'sends a delete_refs message' do
+ it "sends a delete_refs message" do
expect_any_instance_of(Gitaly::RefService::Stub)
.to receive(:delete_refs)
.with(gitaly_request_with_params(except_with_prefix: prefixes), kind_of(Hash))
- .and_return(double('delete_refs_response', git_error: ""))
+ .and_return(double("delete_refs_response", git_error: ""))
client.delete_refs(except_with_prefixes: prefixes)
end
diff --git a/spec/lib/gitlab/gitaly_client/remote_service_spec.rb b/spec/lib/gitlab/gitaly_client/remote_service_spec.rb
index d5508dbff5d..112cc13f7fb 100644
--- a/spec/lib/gitlab/gitaly_client/remote_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/remote_service_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::RemoteService do
let(:project) { create(:project) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
- let(:remote_name) { 'my-remote' }
+ let(:relative_path) { project.disk_path + ".git" }
+ let(:remote_name) { "my-remote" }
let(:client) { described_class.new(project.repository) }
- describe '#add_remote' do
- let(:url) { 'http://my-repo.git' }
+ describe "#add_remote" do
+ let(:url) { "http://my-repo.git" }
let(:mirror_refmap) { :all_refs }
- it 'sends an add_remote message' do
+ it "sends an add_remote message" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:add_remote)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -21,8 +21,8 @@ describe Gitlab::GitalyClient::RemoteService do
end
end
- describe '#remove_remote' do
- it 'sends an remove_remote message and returns the result value' do
+ describe "#remove_remote" do
+ it "sends an remove_remote message and returns the result value" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:remove_remote)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -32,10 +32,10 @@ describe Gitlab::GitalyClient::RemoteService do
end
end
- describe '#fetch_internal_remote' do
- let(:remote_repository) { Gitlab::Git::Repository.new('default', TEST_MUTABLE_REPO_PATH, '', 'group/project') }
+ describe "#fetch_internal_remote" do
+ let(:remote_repository) { Gitlab::Git::Repository.new("default", TEST_MUTABLE_REPO_PATH, "", "group/project") }
- it 'sends an fetch_internal_remote message and returns the result value' do
+ it "sends an fetch_internal_remote message and returns the result value" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:fetch_internal_remote)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -45,33 +45,33 @@ describe Gitlab::GitalyClient::RemoteService do
end
end
- describe '#find_remote_root_ref' do
- it 'sends an find_remote_root_ref message and returns the root ref' do
+ describe "#find_remote_root_ref" do
+ it "sends an find_remote_root_ref message and returns the root ref" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
- .and_return(double(ref: 'master'))
+ .and_return(double(ref: "master"))
- expect(client.find_remote_root_ref('origin')).to eq 'master'
+ expect(client.find_remote_root_ref("origin")).to eq "master"
end
- it 'ensure ref is a valid UTF-8 string' do
+ it "ensure ref is a valid UTF-8 string" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(double(ref: "an_invalid_ref_\xE5"))
- expect(client.find_remote_root_ref('origin')).to eq "an_invalid_ref_å"
+ expect(client.find_remote_root_ref("origin")).to eq "an_invalid_ref_å"
end
end
- describe '#update_remote_mirror' do
- let(:ref_name) { 'remote_mirror_1' }
- let(:only_branches_matching) { ['my-branch', 'master'] }
- let(:ssh_key) { 'KEY' }
- let(:known_hosts) { 'KNOWN HOSTS' }
+ describe "#update_remote_mirror" do
+ let(:ref_name) { "remote_mirror_1" }
+ let(:only_branches_matching) { ["my-branch", "master"] }
+ let(:ssh_key) { "KEY" }
+ let(:known_hosts) { "KNOWN HOSTS" }
- it 'sends an update_remote_mirror message' do
+ it "sends an update_remote_mirror message" do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:update_remote_mirror)
.with(kind_of(Enumerator), kind_of(Hash))
@@ -81,11 +81,11 @@ describe Gitlab::GitalyClient::RemoteService do
end
end
- describe '.exists?' do
+ describe ".exists?" do
context "when the remote doesn't exist" do
- let(:url) { 'https://gitlab.com/gitlab-org/ik-besta-niet-of-ik-word-geplaagd.git' }
+ let(:url) { "https://gitlab.com/gitlab-org/ik-besta-niet-of-ik-word-geplaagd.git" }
- it 'returns false' do
+ it "returns false" do
expect(described_class.exists?(url)).to be(false)
end
end
diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
index 46ca2340389..67254942aff 100644
--- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::RepositoryService do
using RSpec::Parameterized::TableSyntax
let(:project) { create(:project) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:client) { described_class.new(project.repository) }
- describe '#exists?' do
- it 'sends a repository_exists message' do
+ describe "#exists?" do
+ it "sends a repository_exists message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:repository_exists)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -19,8 +19,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#cleanup' do
- it 'sends a cleanup message' do
+ describe "#cleanup" do
+ it "sends a cleanup message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:cleanup)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -29,8 +29,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#garbage_collect' do
- it 'sends a garbage_collect message' do
+ describe "#garbage_collect" do
+ it "sends a garbage_collect message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:garbage_collect)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -40,8 +40,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#repack_full' do
- it 'sends a repack_full message' do
+ describe "#repack_full" do
+ it "sends a repack_full message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:repack_full)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -51,8 +51,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#repack_incremental' do
- it 'sends a repack_incremental message' do
+ describe "#repack_incremental" do
+ it "sends a repack_incremental message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:repack_incremental)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -62,8 +62,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#repository_size' do
- it 'sends a repository_size message' do
+ describe "#repository_size" do
+ it "sends a repository_size message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:repository_size)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -73,10 +73,10 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#apply_gitattributes' do
- let(:revision) { 'master' }
+ describe "#apply_gitattributes" do
+ let(:revision) { "master" }
- it 'sends an apply_gitattributes message' do
+ it "sends an apply_gitattributes message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:apply_gitattributes)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -86,8 +86,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#info_attributes' do
- it 'reads the info attributes' do
+ describe "#info_attributes" do
+ it "reads the info attributes" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:get_info_attributes)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -97,8 +97,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#has_local_branches?' do
- it 'sends a has_local_branches message' do
+ describe "#has_local_branches?" do
+ it "sends a has_local_branches message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:has_local_branches)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -108,14 +108,14 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#fetch_remote' do
- let(:remote) { 'remote-name' }
+ describe "#fetch_remote" do
+ let(:remote) { "remote-name" }
- it 'sends a fetch_remote_request message' do
+ it "sends a fetch_remote_request message" do
expected_request = gitaly_request_with_params(
remote: remote,
- ssh_key: '',
- known_hosts: '',
+ ssh_key: "",
+ known_hosts: "",
force: false,
no_tags: false,
no_prune: false
@@ -129,16 +129,16 @@ describe Gitlab::GitalyClient::RepositoryService do
client.fetch_remote(remote, ssh_auth: nil, forced: false, no_tags: false, timeout: 1)
end
- context 'SSH auth' do
+ context "SSH auth" do
where(:ssh_mirror_url, :ssh_key_auth, :ssh_private_key, :ssh_known_hosts, :expected_params) do
- false | false | 'key' | 'known_hosts' | {}
- false | true | 'key' | 'known_hosts' | {}
- true | false | 'key' | 'known_hosts' | { known_hosts: 'known_hosts' }
- true | true | 'key' | 'known_hosts' | { ssh_key: 'key', known_hosts: 'known_hosts' }
- true | true | 'key' | nil | { ssh_key: 'key' }
- true | true | nil | 'known_hosts' | { known_hosts: 'known_hosts' }
+ false | false | "key" | "known_hosts" | {}
+ false | true | "key" | "known_hosts" | {}
+ true | false | "key" | "known_hosts" | {known_hosts: "known_hosts"}
+ true | true | "key" | "known_hosts" | {ssh_key: "key", known_hosts: "known_hosts"}
+ true | true | "key" | nil | {ssh_key: "key"}
+ true | true | nil | "known_hosts" | {known_hosts: "known_hosts"}
true | true | nil | nil | {}
- true | true | '' | '' | {}
+ true | true | "" | "" | {}
end
with_them do
@@ -155,11 +155,11 @@ describe Gitlab::GitalyClient::RepositoryService do
it do
expected_request = gitaly_request_with_params({
remote: remote,
- ssh_key: '',
- known_hosts: '',
+ ssh_key: "",
+ known_hosts: "",
force: false,
no_tags: false,
- no_prune: false
+ no_prune: false,
}.update(expected_params))
expect_any_instance_of(Gitaly::RepositoryService::Stub)
@@ -173,10 +173,10 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#rebase_in_progress?' do
+ describe "#rebase_in_progress?" do
let(:rebase_id) { 1 }
- it 'sends a repository_rebase_in_progress message' do
+ it "sends a repository_rebase_in_progress message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:is_rebase_in_progress)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -186,10 +186,10 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#squash_in_progress?' do
+ describe "#squash_in_progress?" do
let(:squash_id) { 1 }
- it 'sends a repository_squash_in_progress message' do
+ it "sends a repository_squash_in_progress message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:is_squash_in_progress)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -199,8 +199,8 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#calculate_checksum' do
- it 'sends a calculate_checksum message' do
+ describe "#calculate_checksum" do
+ it "sends a calculate_checksum message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:calculate_checksum)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -210,25 +210,25 @@ describe Gitlab::GitalyClient::RepositoryService do
end
end
- describe '#create_from_snapshot' do
- it 'sends a create_repository_from_snapshot message' do
+ describe "#create_from_snapshot" do
+ it "sends a create_repository_from_snapshot message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:create_repository_from_snapshot)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(double)
- client.create_from_snapshot('http://example.com?wiki=1', 'Custom xyz')
+ client.create_from_snapshot("http://example.com?wiki=1", "Custom xyz")
end
end
- describe '#raw_changes_between' do
- it 'sends a create_repository_from_snapshot message' do
+ describe "#raw_changes_between" do
+ it "sends a create_repository_from_snapshot message" do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:get_raw_changes)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(double)
- client.raw_changes_between('deadbeef', 'deadpork')
+ client.raw_changes_between("deadbeef", "deadpork")
end
end
end
diff --git a/spec/lib/gitlab/gitaly_client/storage_service_spec.rb b/spec/lib/gitlab/gitaly_client/storage_service_spec.rb
index 6c25e2d6ebd..458df5438ea 100644
--- a/spec/lib/gitlab/gitaly_client/storage_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/storage_service_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::StorageService do
- describe '#delete_all_repositories' do
+ describe "#delete_all_repositories" do
let!(:project) { create(:project, :repository) }
- it 'removes all repositories' do
+ it "removes all repositories" do
described_class.new(project.repository_storage).delete_all_repositories
expect(project.repository.exists?).to be(false)
diff --git a/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb b/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb
index c89913ec8e9..8e8a4040cb7 100644
--- a/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/storage_settings_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::StorageSettings do
describe "#initialize" do
- context 'when the storage contains no path' do
- it 'raises an error' do
- expect do
+ context "when the storage contains no path" do
+ it "raises an error" do
+ expect {
described_class.new("foo" => {})
- end.to raise_error(described_class::InvalidConfigurationError)
+ }.to raise_error(described_class::InvalidConfigurationError)
end
end
context "when the argument isn't a hash" do
- it 'raises an error' do
- expect do
+ it "raises an error" do
+ expect {
described_class.new("test")
- end.to raise_error("expected a Hash, got a String")
+ }.to raise_error("expected a Hash, got a String")
end
end
- context 'when the storage is valid' do
- it 'raises no error' do
- expect do
+ context "when the storage is valid" do
+ it "raises no error" do
+ expect {
described_class.new("path" => Rails.root)
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/lib/gitlab/gitaly_client/util_spec.rb b/spec/lib/gitlab/gitaly_client/util_spec.rb
index 78a5e195ad1..6f96a36dd0d 100644
--- a/spec/lib/gitlab/gitaly_client/util_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/util_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::Util do
- describe '.repository' do
- let(:repository_storage) { 'default' }
- let(:relative_path) { 'my/repo.git' }
- let(:gl_repository) { 'project-1' }
- let(:git_object_directory) { '.git/objects' }
- let(:git_alternate_object_directory) { ['/dir/one', '/dir/two'] }
- let(:gl_project_path) { 'namespace/myproject' }
+ describe ".repository" do
+ let(:repository_storage) { "default" }
+ let(:relative_path) { "my/repo.git" }
+ let(:gl_repository) { "project-1" }
+ let(:git_object_directory) { ".git/objects" }
+ let(:git_alternate_object_directory) { ["/dir/one", "/dir/two"] }
+ let(:gl_project_path) { "namespace/myproject" }
let(:git_env) do
{
- 'GIT_OBJECT_DIRECTORY_RELATIVE' => git_object_directory,
- 'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE' => git_alternate_object_directory
+ "GIT_OBJECT_DIRECTORY_RELATIVE" => git_object_directory,
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE" => git_alternate_object_directory,
}
end
@@ -19,7 +19,7 @@ describe Gitlab::GitalyClient::Util do
described_class.repository(repository_storage, relative_path, gl_repository, gl_project_path)
end
- it 'creates a Gitaly::Repository with the given data' do
+ it "creates a Gitaly::Repository with the given data" do
allow(Gitlab::Git::HookEnv).to receive(:all).with(gl_repository).and_return(git_env)
expect(subject).to be_a(Gitaly::Repository)
diff --git a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb
index d82c9c28da0..a764ea2ed39 100644
--- a/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/wiki_service_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitalyClient::WikiService do
let(:project) { create(:project) }
let(:storage_name) { project.repository_storage }
- let(:relative_path) { project.disk_path + '.git' }
+ let(:relative_path) { project.disk_path + ".git" }
let(:client) { described_class.new(project.repository) }
let(:commit) { create(:gitaly_commit) }
- let(:page_version) { Gitaly::WikiPageVersion.new(format: 'markdown', commit: commit) }
- let(:page_info) { { title: 'My Page', raw_data: 'a', version: page_version } }
+ let(:page_version) { Gitaly::WikiPageVersion.new(format: "markdown", commit: commit) }
+ let(:page_info) { {title: "My Page", raw_data: "a", version: page_version} }
- describe '#find_page' do
+ describe "#find_page" do
let(:response) do
[
Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(page_info)),
- Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(raw_data: 'b'))
+ Gitaly::WikiFindPageResponse.new(page: Gitaly::WikiPage.new(raw_data: "b")),
]
end
let(:wiki_page) { subject.first }
let(:wiki_page_version) { subject.last }
- subject { client.find_page(title: 'My Page', version: 'master', dir: '') }
+ subject { client.find_page(title: "My Page", version: "master", dir: "") }
- it 'sends a wiki_find_page message' do
+ it "sends a wiki_find_page message" do
expect_any_instance_of(Gitaly::WikiService::Stub)
.to receive(:wiki_find_page)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -30,15 +30,15 @@ describe Gitlab::GitalyClient::WikiService do
subject
end
- it 'concatenates the raw data and returns a pair of WikiPage and WikiPageVersion' do
+ it "concatenates the raw data and returns a pair of WikiPage and WikiPageVersion" do
expect_any_instance_of(Gitaly::WikiService::Stub)
.to receive(:wiki_find_page)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(response.each)
- expect(wiki_page.title).to eq('My Page')
- expect(wiki_page.raw_data).to eq('ab')
- expect(wiki_page_version.format).to eq('markdown')
+ expect(wiki_page.title).to eq("My Page")
+ expect(wiki_page.raw_data).to eq("ab")
+ expect(wiki_page_version.format).to eq("markdown")
expect(wiki_page.title).to be_utf8
expect(wiki_page.path).to be_utf8
@@ -46,16 +46,16 @@ describe Gitlab::GitalyClient::WikiService do
end
end
- describe '#get_all_pages' do
- let(:page_2_info) { { title: 'My Page 2', raw_data: 'c', version: page_version } }
+ describe "#get_all_pages" do
+ let(:page_2_info) { {title: "My Page 2", raw_data: "c", version: page_version} }
let(:response) do
[
Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(page_info)),
- Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(raw_data: 'b')),
+ Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(raw_data: "b")),
Gitaly::WikiGetAllPagesResponse.new(end_of_page: true),
Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(page_2_info)),
- Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(raw_data: 'd')),
- Gitaly::WikiGetAllPagesResponse.new(end_of_page: true)
+ Gitaly::WikiGetAllPagesResponse.new(page: Gitaly::WikiPage.new(raw_data: "d")),
+ Gitaly::WikiGetAllPagesResponse.new(end_of_page: true),
]
end
let(:wiki_page_1) { subject[0].first }
@@ -65,7 +65,7 @@ describe Gitlab::GitalyClient::WikiService do
subject { client.get_all_pages }
- it 'sends a wiki_get_all_pages message' do
+ it "sends a wiki_get_all_pages message" do
expect_any_instance_of(Gitaly::WikiService::Stub)
.to receive(:wiki_get_all_pages)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
@@ -74,7 +74,7 @@ describe Gitlab::GitalyClient::WikiService do
subject
end
- it 'sends a limit of 0 to wiki_get_all_pages' do
+ it "sends a limit of 0 to wiki_get_all_pages" do
expect_any_instance_of(Gitaly::WikiService::Stub)
.to receive(:wiki_get_all_pages)
.with(gitaly_request_with_params(limit: 0), kind_of(Hash))
@@ -83,29 +83,29 @@ describe Gitlab::GitalyClient::WikiService do
subject
end
- it 'concatenates the raw data and returns a pair of WikiPage and WikiPageVersion for each page' do
+ it "concatenates the raw data and returns a pair of WikiPage and WikiPageVersion for each page" do
expect_any_instance_of(Gitaly::WikiService::Stub)
.to receive(:wiki_get_all_pages)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.and_return(response.each)
expect(subject.size).to be(2)
- expect(wiki_page_1.title).to eq('My Page')
- expect(wiki_page_1.raw_data).to eq('ab')
- expect(wiki_page_1_version.format).to eq('markdown')
- expect(wiki_page_2.title).to eq('My Page 2')
- expect(wiki_page_2.raw_data).to eq('cd')
- expect(wiki_page_2_version.format).to eq('markdown')
+ expect(wiki_page_1.title).to eq("My Page")
+ expect(wiki_page_1.raw_data).to eq("ab")
+ expect(wiki_page_1_version.format).to eq("markdown")
+ expect(wiki_page_2.title).to eq("My Page 2")
+ expect(wiki_page_2.raw_data).to eq("cd")
+ expect(wiki_page_2_version.format).to eq("markdown")
end
- context 'with limits' do
+ context "with limits" do
subject { client.get_all_pages(limit: 1) }
- it 'sends a request with the limit' do
+ it "sends a request with the limit" do
expect_any_instance_of(Gitaly::WikiService::Stub)
- .to receive(:wiki_get_all_pages)
- .with(gitaly_request_with_params(limit: 1), kind_of(Hash))
- .and_return([].each)
+ .to receive(:wiki_get_all_pages)
+ .with(gitaly_request_with_params(limit: 1), kind_of(Hash))
+ .and_return([].each)
subject
end
diff --git a/spec/lib/gitlab/gitaly_client_spec.rb b/spec/lib/gitlab/gitaly_client_spec.rb
index cf12baf1a93..25ee913e813 100644
--- a/spec/lib/gitlab/gitaly_client_spec.rb
+++ b/spec/lib/gitlab/gitaly_client_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
# We stub Gitaly in `spec/support/gitaly.rb` for other tests. We don't want
# those stubs while testing the GitalyClient itself.
describe Gitlab::GitalyClient do
- let(:sample_cert) { Rails.root.join('spec/fixtures/clusters/sample_cert.pem').to_s }
+ let(:sample_cert) { Rails.root.join("spec/fixtures/clusters/sample_cert.pem").to_s }
before do
allow(described_class)
@@ -13,39 +13,40 @@ describe Gitlab::GitalyClient do
def stub_repos_storages(address)
allow(Gitlab.config.repositories).to receive(:storages).and_return({
- 'default' => { 'gitaly_address' => address }
+ "default" => {"gitaly_address" => address},
})
end
- describe '.stub_class' do
- it 'returns the gRPC health check stub' do
+ describe ".stub_class" do
+ it "returns the gRPC health check stub" do
expect(described_class.stub_class(:health_check)).to eq(::Grpc::Health::V1::Health::Stub)
end
- it 'returns a Gitaly stub' do
+ it "returns a Gitaly stub" do
expect(described_class.stub_class(:ref_service)).to eq(::Gitaly::RefService::Stub)
end
end
- describe '.stub_address' do
- it 'returns the same result after being called multiple times' do
- address = 'tcp://localhost:9876'
+ describe ".stub_address" do
+ it "returns the same result after being called multiple times" do
+ address = "tcp://localhost:9876"
stub_repos_storages address
2.times do
- expect(described_class.stub_address('default')).to eq('localhost:9876')
+ expect(described_class.stub_address("default")).to eq("localhost:9876")
end
end
end
- describe '.stub_certs' do
- it 'skips certificates if OpenSSLError is raised and report it' do
+ describe ".stub_certs" do
+ it "skips certificates if OpenSSLError is raised and report it" do
expect(Rails.logger).to receive(:error).at_least(:once)
expect(Gitlab::Sentry)
.to receive(:track_exception)
.with(
a_kind_of(OpenSSL::X509::CertificateError),
- extra: { cert_file: a_kind_of(String) }).at_least(:once)
+ extra: {cert_file: a_kind_of(String)}
+ ).at_least(:once)
expect(OpenSSL::X509::Certificate)
.to receive(:new)
@@ -54,169 +55,169 @@ describe Gitlab::GitalyClient do
expect(described_class.stub_certs).to be_a(String)
end
end
- describe '.stub_creds' do
- it 'returns :this_channel_is_insecure if unix' do
- address = 'unix:/tmp/gitaly.sock'
+ describe ".stub_creds" do
+ it "returns :this_channel_is_insecure if unix" do
+ address = "unix:/tmp/gitaly.sock"
stub_repos_storages address
- expect(described_class.stub_creds('default')).to eq(:this_channel_is_insecure)
+ expect(described_class.stub_creds("default")).to eq(:this_channel_is_insecure)
end
- it 'returns :this_channel_is_insecure if tcp' do
- address = 'tcp://localhost:9876'
+ it "returns :this_channel_is_insecure if tcp" do
+ address = "tcp://localhost:9876"
stub_repos_storages address
- expect(described_class.stub_creds('default')).to eq(:this_channel_is_insecure)
+ expect(described_class.stub_creds("default")).to eq(:this_channel_is_insecure)
end
- it 'returns Credentials object if tls' do
- address = 'tls://localhost:9876'
+ it "returns Credentials object if tls" do
+ address = "tls://localhost:9876"
stub_repos_storages address
- expect(described_class.stub_creds('default')).to be_a(GRPC::Core::ChannelCredentials)
+ expect(described_class.stub_creds("default")).to be_a(GRPC::Core::ChannelCredentials)
end
end
- describe '.stub' do
+ describe ".stub" do
# Notice that this is referring to gRPC "stubs", not rspec stubs
before do
described_class.clear_stubs!
end
- context 'when passed a UNIX socket address' do
- it 'passes the address as-is to GRPC' do
- address = 'unix:/tmp/gitaly.sock'
+ context "when passed a UNIX socket address" do
+ it "passes the address as-is to GRPC" do
+ address = "unix:/tmp/gitaly.sock"
stub_repos_storages address
expect(Gitaly::CommitService::Stub).to receive(:new).with(address, any_args)
- described_class.stub(:commit_service, 'default')
+ described_class.stub(:commit_service, "default")
end
end
- context 'when passed a TLS address' do
- it 'strips tls:// prefix before passing it to GRPC::Core::Channel initializer' do
- address = 'localhost:9876'
+ context "when passed a TLS address" do
+ it "strips tls:// prefix before passing it to GRPC::Core::Channel initializer" do
+ address = "localhost:9876"
prefixed_address = "tls://#{address}"
stub_repos_storages prefixed_address
expect(Gitaly::CommitService::Stub).to receive(:new).with(address, any_args)
- described_class.stub(:commit_service, 'default')
+ described_class.stub(:commit_service, "default")
end
end
- context 'when passed a TCP address' do
- it 'strips tcp:// prefix before passing it to GRPC::Core::Channel initializer' do
- address = 'localhost:9876'
+ context "when passed a TCP address" do
+ it "strips tcp:// prefix before passing it to GRPC::Core::Channel initializer" do
+ address = "localhost:9876"
prefixed_address = "tcp://#{address}"
stub_repos_storages prefixed_address
expect(Gitaly::CommitService::Stub).to receive(:new).with(address, any_args)
- described_class.stub(:commit_service, 'default')
+ described_class.stub(:commit_service, "default")
end
end
end
- describe '.connection_data' do
- it 'returns connection data' do
- address = 'tcp://localhost:9876'
+ describe ".connection_data" do
+ it "returns connection data" do
+ address = "tcp://localhost:9876"
stub_repos_storages address
- expect(described_class.connection_data('default')).to eq({ 'address' => address, 'token' => 'secret' })
+ expect(described_class.connection_data("default")).to eq({"address" => address, "token" => "secret"})
end
end
- describe 'allow_n_plus_1_calls' do
- context 'when RequestStore is enabled', :request_store do
- it 'returns the result of the allow_n_plus_1_calls block' do
+ describe "allow_n_plus_1_calls" do
+ context "when RequestStore is enabled", :request_store do
+ it "returns the result of the allow_n_plus_1_calls block" do
expect(described_class.allow_n_plus_1_calls { "result" }).to eq("result")
end
end
- context 'when RequestStore is not active' do
- it 'returns the result of the allow_n_plus_1_calls block' do
+ context "when RequestStore is not active" do
+ it "returns the result of the allow_n_plus_1_calls block" do
expect(described_class.allow_n_plus_1_calls { "something" }).to eq("something")
end
end
end
- describe 'enforce_gitaly_request_limits?' do
+ describe "enforce_gitaly_request_limits?" do
def call_gitaly(count = 1)
(1..count).each do
described_class.enforce_gitaly_request_limits(:test)
end
end
- context 'when RequestStore is enabled', :request_store do
- it 'allows up the maximum number of allowed calls' do
+ context "when RequestStore is enabled", :request_store do
+ it "allows up the maximum number of allowed calls" do
expect { call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS) }.not_to raise_error
end
- context 'when the maximum number of calls has been reached' do
+ context "when the maximum number of calls has been reached" do
before do
call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS)
end
- it 'fails on the next call' do
+ it "fails on the next call" do
expect { call_gitaly(1) }.to raise_error(Gitlab::GitalyClient::TooManyInvocationsError)
end
end
- it 'allows the maximum number of calls to be exceeded within an allow_n_plus_1_calls block' do
- expect do
+ it "allows the maximum number of calls to be exceeded within an allow_n_plus_1_calls block" do
+ expect {
described_class.allow_n_plus_1_calls do
call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS + 1)
end
- end.not_to raise_error
+ }.not_to raise_error
end
- context 'when the maximum number of calls has been reached within an allow_n_plus_1_calls block' do
+ context "when the maximum number of calls has been reached within an allow_n_plus_1_calls block" do
before do
described_class.allow_n_plus_1_calls do
call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS)
end
end
- it 'allows up to the maximum number of calls outside of an allow_n_plus_1_calls block' do
+ it "allows up to the maximum number of calls outside of an allow_n_plus_1_calls block" do
expect { call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS) }.not_to raise_error
end
- it 'does not allow the maximum number of calls to be exceeded outside of an allow_n_plus_1_calls block' do
+ it "does not allow the maximum number of calls to be exceeded outside of an allow_n_plus_1_calls block" do
expect { call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS + 1) }.to raise_error(Gitlab::GitalyClient::TooManyInvocationsError)
end
end
end
- context 'when RequestStore is not active' do
- it 'does not raise errors when the maximum number of allowed calls is exceeded' do
+ context "when RequestStore is not active" do
+ it "does not raise errors when the maximum number of allowed calls is exceeded" do
expect { call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS + 2) }.not_to raise_error
end
- it 'does not fail when the maximum number of calls is exceeded within an allow_n_plus_1_calls block' do
- expect do
+ it "does not fail when the maximum number of calls is exceeded within an allow_n_plus_1_calls block" do
+ expect {
described_class.allow_n_plus_1_calls do
call_gitaly(Gitlab::GitalyClient::MAXIMUM_GITALY_CALLS + 1)
end
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
- describe 'get_request_count' do
- context 'when RequestStore is enabled', :request_store do
- context 'when enforce_gitaly_request_limits is called outside of allow_n_plus_1_calls blocks' do
+ describe "get_request_count" do
+ context "when RequestStore is enabled", :request_store do
+ context "when enforce_gitaly_request_limits is called outside of allow_n_plus_1_calls blocks" do
before do
described_class.enforce_gitaly_request_limits(:call)
end
- it 'counts gitaly calls' do
+ it "counts gitaly calls" do
expect(described_class.get_request_count).to eq(1)
end
end
- context 'when enforce_gitaly_request_limits is called inside and outside of allow_n_plus_1_calls blocks' do
+ context "when enforce_gitaly_request_limits is called inside and outside of allow_n_plus_1_calls blocks" do
before do
described_class.enforce_gitaly_request_limits(:call)
described_class.allow_n_plus_1_calls do
@@ -224,57 +225,57 @@ describe Gitlab::GitalyClient do
end
end
- it 'counts gitaly calls' do
+ it "counts gitaly calls" do
expect(described_class.get_request_count).to eq(2)
end
end
- context 'when reset_counts is called' do
+ context "when reset_counts is called" do
before do
described_class.enforce_gitaly_request_limits(:call)
described_class.reset_counts
end
- it 'resets counts' do
+ it "resets counts" do
expect(described_class.get_request_count).to eq(0)
end
end
end
- context 'when RequestStore is not active' do
+ context "when RequestStore is not active" do
before do
described_class.enforce_gitaly_request_limits(:call)
end
- it 'returns zero' do
+ it "returns zero" do
expect(described_class.get_request_count).to eq(0)
end
end
end
- describe 'feature_enabled?' do
- let(:feature_name) { 'my_feature' }
+ describe "feature_enabled?" do
+ let(:feature_name) { "my_feature" }
let(:real_feature_name) { "gitaly_#{feature_name}" }
before do
allow(Feature).to receive(:enabled?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(Feature).to receive(:enabled?).with(real_feature_name)
expect(described_class.feature_enabled?(feature_name)).to be(false)
end
end
- describe 'timeouts' do
- context 'with default values' do
+ describe "timeouts" do
+ context "with default values" do
before do
stub_application_setting(gitaly_timeout_default: 55)
stub_application_setting(gitaly_timeout_medium: 30)
stub_application_setting(gitaly_timeout_fast: 10)
end
- it 'returns expected values' do
+ it "returns expected values" do
expect(described_class.default_timeout).to be(55)
expect(described_class.medium_timeout).to be(30)
expect(described_class.fast_timeout).to be(10)
@@ -282,15 +283,15 @@ describe Gitlab::GitalyClient do
end
end
- describe 'Peek Performance bar details' do
+ describe "Peek Performance bar details" do
let(:gitaly_server) { Gitaly::Server.all.first }
before do
Gitlab::SafeRequestStore[:peek_enabled] = true
end
- context 'when the request store is active', :request_store do
- it 'records call details if a RPC is called' do
+ context "when the request store is active", :request_store do
+ it "records call details if a RPC is called" do
gitaly_server.server_version
expect(described_class.list_call_details).not_to be_empty
@@ -298,8 +299,8 @@ describe Gitlab::GitalyClient do
end
end
- context 'when no request store is active' do
- it 'records nothing' do
+ context "when no request store is active" do
+ it "records nothing" do
gitaly_server.server_version
expect(described_class.list_call_details).to be_empty
diff --git a/spec/lib/gitlab/github_import/bulk_importing_spec.rb b/spec/lib/gitlab/github_import/bulk_importing_spec.rb
index 91229d9c7d4..9b16ce01ca4 100644
--- a/spec/lib/gitlab/github_import/bulk_importing_spec.rb
+++ b/spec/lib/gitlab/github_import/bulk_importing_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::BulkImporting do
let(:importer) do
Class.new { include(Gitlab::GithubImport::BulkImporting) }.new
end
- describe '#build_database_rows' do
- it 'returns an Array containing the rows to insert' do
- object = double(:object, title: 'Foo')
+ describe "#build_database_rows" do
+ it "returns an Array containing the rows to insert" do
+ object = double(:object, title: "Foo")
expect(importer)
.to receive(:build)
.with(object)
- .and_return({ title: 'Foo' })
+ .and_return({title: "Foo"})
expect(importer)
.to receive(:already_imported?)
@@ -21,11 +21,11 @@ describe Gitlab::GithubImport::BulkImporting do
enum = [[object, 1]].to_enum
- expect(importer.build_database_rows(enum)).to eq([{ title: 'Foo' }])
+ expect(importer.build_database_rows(enum)).to eq([{title: "Foo"}])
end
- it 'does not import objects that have already been imported' do
- object = double(:object, title: 'Foo')
+ it "does not import objects that have already been imported" do
+ object = double(:object, title: "Foo")
expect(importer)
.not_to receive(:build)
@@ -41,20 +41,20 @@ describe Gitlab::GithubImport::BulkImporting do
end
end
- describe '#bulk_insert' do
- it 'bulk inserts rows into the database' do
- rows = [{ title: 'Foo' }] * 10
- model = double(:model, table_name: 'kittens')
+ describe "#bulk_insert" do
+ it "bulk inserts rows into the database" do
+ rows = [{title: "Foo"}] * 10
+ model = double(:model, table_name: "kittens")
expect(Gitlab::Database)
.to receive(:bulk_insert)
.ordered
- .with('kittens', rows.first(5))
+ .with("kittens", rows.first(5))
expect(Gitlab::Database)
.to receive(:bulk_insert)
.ordered
- .with('kittens', rows.last(5))
+ .with("kittens", rows.last(5))
importer.bulk_insert(model, rows, batch_size: 5)
end
diff --git a/spec/lib/gitlab/github_import/caching_spec.rb b/spec/lib/gitlab/github_import/caching_spec.rb
index 70ecdc16da1..64b3b9e75a1 100644
--- a/spec/lib/gitlab/github_import/caching_spec.rb
+++ b/spec/lib/gitlab/github_import/caching_spec.rb
@@ -1,94 +1,94 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Caching, :clean_gitlab_redis_cache do
- describe '.read' do
- it 'reads a value from the cache' do
- described_class.write('foo', 'bar')
+ describe ".read" do
+ it "reads a value from the cache" do
+ described_class.write("foo", "bar")
- expect(described_class.read('foo')).to eq('bar')
+ expect(described_class.read("foo")).to eq("bar")
end
- it 'returns nil if the cache key does not exist' do
- expect(described_class.read('foo')).to be_nil
+ it "returns nil if the cache key does not exist" do
+ expect(described_class.read("foo")).to be_nil
end
- it 'refreshes the cache key if a value is present' do
- described_class.write('foo', 'bar')
+ it "refreshes the cache key if a value is present" do
+ described_class.write("foo", "bar")
redis = double(:redis)
- expect(redis).to receive(:get).with(/foo/).and_return('bar')
+ expect(redis).to receive(:get).with(/foo/).and_return("bar")
expect(redis).to receive(:expire).with(/foo/, described_class::TIMEOUT)
expect(Gitlab::Redis::Cache).to receive(:with).twice.and_yield(redis)
- described_class.read('foo')
+ described_class.read("foo")
end
- it 'does not refresh the cache key if a value is empty' do
- described_class.write('foo', nil)
+ it "does not refresh the cache key if a value is empty" do
+ described_class.write("foo", nil)
redis = double(:redis)
- expect(redis).to receive(:get).with(/foo/).and_return('')
+ expect(redis).to receive(:get).with(/foo/).and_return("")
expect(redis).not_to receive(:expire)
expect(Gitlab::Redis::Cache).to receive(:with).and_yield(redis)
- described_class.read('foo')
+ described_class.read("foo")
end
end
- describe '.read_integer' do
- it 'returns an Integer' do
- described_class.write('foo', '10')
+ describe ".read_integer" do
+ it "returns an Integer" do
+ described_class.write("foo", "10")
- expect(described_class.read_integer('foo')).to eq(10)
+ expect(described_class.read_integer("foo")).to eq(10)
end
- it 'returns nil if no value was found' do
- expect(described_class.read_integer('foo')).to be_nil
+ it "returns nil if no value was found" do
+ expect(described_class.read_integer("foo")).to be_nil
end
end
- describe '.write' do
- it 'writes a value to the cache and returns the written value' do
- expect(described_class.write('foo', 10)).to eq(10)
- expect(described_class.read('foo')).to eq('10')
+ describe ".write" do
+ it "writes a value to the cache and returns the written value" do
+ expect(described_class.write("foo", 10)).to eq(10)
+ expect(described_class.read("foo")).to eq("10")
end
end
- describe '.set_add' do
- it 'adds a value to a set' do
- described_class.set_add('foo', 10)
- described_class.set_add('foo', 10)
+ describe ".set_add" do
+ it "adds a value to a set" do
+ described_class.set_add("foo", 10)
+ described_class.set_add("foo", 10)
- key = described_class.cache_key_for('foo')
+ key = described_class.cache_key_for("foo")
values = Gitlab::Redis::Cache.with { |r| r.smembers(key) }
- expect(values).to eq(['10'])
+ expect(values).to eq(["10"])
end
end
- describe '.set_includes?' do
- it 'returns false when the key does not exist' do
- expect(described_class.set_includes?('foo', 10)).to eq(false)
+ describe ".set_includes?" do
+ it "returns false when the key does not exist" do
+ expect(described_class.set_includes?("foo", 10)).to eq(false)
end
- it 'returns false when the value is not present in the set' do
- described_class.set_add('foo', 10)
+ it "returns false when the value is not present in the set" do
+ described_class.set_add("foo", 10)
- expect(described_class.set_includes?('foo', 20)).to eq(false)
+ expect(described_class.set_includes?("foo", 20)).to eq(false)
end
- it 'returns true when the set includes the given value' do
- described_class.set_add('foo', 10)
+ it "returns true when the set includes the given value" do
+ described_class.set_add("foo", 10)
- expect(described_class.set_includes?('foo', 10)).to eq(true)
+ expect(described_class.set_includes?("foo", 10)).to eq(true)
end
end
- describe '.write_multiple' do
- it 'sets multiple keys' do
- mapping = { 'foo' => 10, 'bar' => 20 }
+ describe ".write_multiple" do
+ it "sets multiple keys" do
+ mapping = {"foo" => 10, "bar" => 20}
described_class.write_multiple(mapping)
@@ -101,14 +101,14 @@ describe Gitlab::GithubImport::Caching, :clean_gitlab_redis_cache do
end
end
- describe '.expire' do
- it 'sets the expiration time of a key' do
+ describe ".expire" do
+ it "sets the expiration time of a key" do
timeout = 1.hour.to_i
- described_class.write('foo', 'bar', timeout: 2.hours.to_i)
- described_class.expire('foo', timeout)
+ described_class.write("foo", "bar", timeout: 2.hours.to_i)
+ described_class.expire("foo", timeout)
- key = described_class.cache_key_for('foo')
+ key = described_class.cache_key_for("foo")
found_ttl = Gitlab::Redis::Cache.with { |r| r.ttl(key) }
expect(found_ttl).to be <= timeout
diff --git a/spec/lib/gitlab/github_import/client_spec.rb b/spec/lib/gitlab/github_import/client_spec.rb
index 5b2642d9473..023a98a53fb 100644
--- a/spec/lib/gitlab/github_import/client_spec.rb
+++ b/spec/lib/gitlab/github_import/client_spec.rb
@@ -1,80 +1,80 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Client do
- describe '#parallel?' do
- it 'returns true when the client is running in parallel mode' do
- client = described_class.new('foo', parallel: true)
+ describe "#parallel?" do
+ it "returns true when the client is running in parallel mode" do
+ client = described_class.new("foo", parallel: true)
expect(client).to be_parallel
end
- it 'returns false when the client is running in sequential mode' do
- client = described_class.new('foo', parallel: false)
+ it "returns false when the client is running in sequential mode" do
+ client = described_class.new("foo", parallel: false)
expect(client).not_to be_parallel
end
end
- describe '#user' do
- it 'returns the details for the given username' do
- client = described_class.new('foo')
+ describe "#user" do
+ it "returns the details for the given username" do
+ client = described_class.new("foo")
- expect(client.octokit).to receive(:user).with('foo')
+ expect(client.octokit).to receive(:user).with("foo")
expect(client).to receive(:with_rate_limit).and_yield
- client.user('foo')
+ client.user("foo")
end
end
- describe '#repository' do
- it 'returns the details of a repository' do
- client = described_class.new('foo')
+ describe "#repository" do
+ it "returns the details of a repository" do
+ client = described_class.new("foo")
- expect(client.octokit).to receive(:repo).with('foo/bar')
+ expect(client.octokit).to receive(:repo).with("foo/bar")
expect(client).to receive(:with_rate_limit).and_yield
- client.repository('foo/bar')
+ client.repository("foo/bar")
end
end
- describe '#labels' do
- it 'returns the labels' do
- client = described_class.new('foo')
+ describe "#labels" do
+ it "returns the labels" do
+ client = described_class.new("foo")
expect(client)
.to receive(:each_object)
- .with(:labels, 'foo/bar')
+ .with(:labels, "foo/bar")
- client.labels('foo/bar')
+ client.labels("foo/bar")
end
end
- describe '#milestones' do
- it 'returns the milestones' do
- client = described_class.new('foo')
+ describe "#milestones" do
+ it "returns the milestones" do
+ client = described_class.new("foo")
expect(client)
.to receive(:each_object)
- .with(:milestones, 'foo/bar')
+ .with(:milestones, "foo/bar")
- client.milestones('foo/bar')
+ client.milestones("foo/bar")
end
end
- describe '#releases' do
- it 'returns the releases' do
- client = described_class.new('foo')
+ describe "#releases" do
+ it "returns the releases" do
+ client = described_class.new("foo")
expect(client)
.to receive(:each_object)
- .with(:releases, 'foo/bar')
+ .with(:releases, "foo/bar")
- client.releases('foo/bar')
+ client.releases("foo/bar")
end
end
- describe '#each_page' do
- let(:client) { described_class.new('foo') }
+ describe "#each_page" do
+ let(:client) { described_class.new("foo") }
let(:object1) { double(:object1) }
let(:object2) { double(:object2) }
@@ -87,20 +87,20 @@ describe Gitlab::GithubImport::Client do
.to receive(:public_send)
.and_return([object1])
- response = double(:response, data: [object2], rels: { next: nil })
+ response = double(:response, data: [object2], rels: {next: nil})
next_page = double(:next_page, get: response)
allow(client.octokit)
.to receive(:last_response)
- .and_return(double(:last_response, rels: { next: next_page }))
+ .and_return(double(:last_response, rels: {next: next_page}))
end
- context 'without a block' do
- it 'returns an Enumerator' do
+ context "without a block" do
+ it "returns an Enumerator" do
expect(client.each_page(:foo)).to be_an_instance_of(Enumerator)
end
- it 'the returned Enumerator returns Page objects' do
+ it "the returned Enumerator returns Page objects" do
enum = client.each_page(:foo)
page1 = enum.next
@@ -117,8 +117,8 @@ describe Gitlab::GithubImport::Client do
end
end
- context 'with a block' do
- it 'yields every retrieved page to the supplied block' do
+ context "with a block" do
+ it "yields every retrieved page to the supplied block" do
pages = []
client.each_page(:foo) { |page| pages << page }
@@ -133,7 +133,7 @@ describe Gitlab::GithubImport::Client do
expect(pages[1].number).to eq(2)
end
- it 'starts at the given page' do
+ it "starts at the given page" do
pages = []
client.each_page(:foo, page: 2) { |page| pages << page }
@@ -144,23 +144,23 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#with_rate_limit' do
- let(:client) { described_class.new('foo') }
+ describe "#with_rate_limit" do
+ let(:client) { described_class.new("foo") }
- it 'yields the supplied block when enough requests remain' do
+ it "yields the supplied block when enough requests remain" do
expect(client).to receive(:requests_remaining?).and_return(true)
expect { |b| client.with_rate_limit(&b) }.to yield_control
end
- it 'waits before yielding if not enough requests remain' do
+ it "waits before yielding if not enough requests remain" do
expect(client).to receive(:requests_remaining?).and_return(false)
expect(client).to receive(:raise_or_wait_for_rate_limit)
expect { |b| client.with_rate_limit(&b) }.to yield_control
end
- it 'waits and retries the operation if all requests were consumed in the supplied block' do
+ it "waits and retries the operation if all requests were consumed in the supplied block" do
retries = 0
expect(client).to receive(:requests_remaining?).and_return(true)
@@ -176,7 +176,7 @@ describe Gitlab::GithubImport::Client do
expect(retries).to eq(1)
end
- it 'increments the request count counter' do
+ it "increments the request count counter" do
expect(client.request_count_counter)
.to receive(:increment)
.and_call_original
@@ -186,7 +186,7 @@ describe Gitlab::GithubImport::Client do
client.with_rate_limit { }
end
- it 'ignores rate limiting when disabled' do
+ it "ignores rate limiting when disabled" do
expect(client)
.to receive(:rate_limiting_enabled?)
.and_return(false)
@@ -198,32 +198,32 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#requests_remaining?' do
- let(:client) { described_class.new('foo') }
+ describe "#requests_remaining?" do
+ let(:client) { described_class.new("foo") }
- it 'returns true if enough requests remain' do
+ it "returns true if enough requests remain" do
expect(client).to receive(:remaining_requests).and_return(9000)
expect(client.requests_remaining?).to eq(true)
end
- it 'returns false if not enough requests remain' do
+ it "returns false if not enough requests remain" do
expect(client).to receive(:remaining_requests).and_return(1)
expect(client.requests_remaining?).to eq(false)
end
end
- describe '#raise_or_wait_for_rate_limit' do
- it 'raises RateLimitError when running in parallel mode' do
- client = described_class.new('foo', parallel: true)
+ describe "#raise_or_wait_for_rate_limit" do
+ it "raises RateLimitError when running in parallel mode" do
+ client = described_class.new("foo", parallel: true)
expect { client.raise_or_wait_for_rate_limit }
.to raise_error(Gitlab::GithubImport::RateLimitError)
end
- it 'sleeps when running in sequential mode' do
- client = described_class.new('foo', parallel: false)
+ it "sleeps when running in sequential mode" do
+ client = described_class.new("foo", parallel: false)
expect(client).to receive(:rate_limit_resets_in).and_return(1)
expect(client).to receive(:sleep).with(1)
@@ -231,8 +231,8 @@ describe Gitlab::GithubImport::Client do
client.raise_or_wait_for_rate_limit
end
- it 'increments the rate limit counter' do
- client = described_class.new('foo', parallel: false)
+ it "increments the rate limit counter" do
+ client = described_class.new("foo", parallel: false)
expect(client)
.to receive(:rate_limit_resets_in)
@@ -250,9 +250,9 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#remaining_requests' do
- it 'returns the number of remaining requests' do
- client = described_class.new('foo')
+ describe "#remaining_requests" do
+ it "returns the number of remaining requests" do
+ client = described_class.new("foo")
rate_limit = double(remaining: 1)
expect(client.octokit).to receive(:rate_limit).and_return(rate_limit)
@@ -260,9 +260,9 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#rate_limit_resets_in' do
- it 'returns the number of seconds after which the rate limit is reset' do
- client = described_class.new('foo')
+ describe "#rate_limit_resets_in" do
+ it "returns the number of seconds after which the rate limit is reset" do
+ client = described_class.new("foo")
rate_limit = double(resets_in: 1)
expect(client.octokit).to receive(:rate_limit).and_return(rate_limit)
@@ -271,22 +271,22 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#api_endpoint' do
- let(:client) { described_class.new('foo') }
+ describe "#api_endpoint" do
+ let(:client) { described_class.new("foo") }
- context 'without a custom endpoint configured in Omniauth' do
- it 'returns the default API endpoint' do
+ context "without a custom endpoint configured in Omniauth" do
+ it "returns the default API endpoint" do
expect(client)
.to receive(:custom_api_endpoint)
.and_return(nil)
- expect(client.api_endpoint).to eq('https://api.github.com')
+ expect(client.api_endpoint).to eq("https://api.github.com")
end
end
- context 'with a custom endpoint configured in Omniauth' do
- it 'returns the custom endpoint' do
- endpoint = 'https://github.kittens.com'
+ context "with a custom endpoint configured in Omniauth" do
+ it "returns the custom endpoint" do
+ endpoint = "https://github.kittens.com"
expect(client)
.to receive(:custom_api_endpoint)
@@ -297,11 +297,11 @@ describe Gitlab::GithubImport::Client do
end
end
- describe '#custom_api_endpoint' do
- let(:client) { described_class.new('foo') }
+ describe "#custom_api_endpoint" do
+ let(:client) { described_class.new("foo") }
- context 'without a custom endpoint' do
- it 'returns nil' do
+ context "without a custom endpoint" do
+ it "returns nil" do
expect(client)
.to receive(:github_omniauth_provider)
.and_return({})
@@ -310,32 +310,32 @@ describe Gitlab::GithubImport::Client do
end
end
- context 'with a custom endpoint' do
- it 'returns the API endpoint' do
- endpoint = 'https://github.kittens.com'
+ context "with a custom endpoint" do
+ it "returns the API endpoint" do
+ endpoint = "https://github.kittens.com"
expect(client)
.to receive(:github_omniauth_provider)
- .and_return({ 'args' => { 'client_options' => { 'site' => endpoint } } })
+ .and_return({"args" => {"client_options" => {"site" => endpoint}}})
expect(client.custom_api_endpoint).to eq(endpoint)
end
end
end
- describe '#default_api_endpoint' do
- it 'returns the default API endpoint' do
- client = described_class.new('foo')
+ describe "#default_api_endpoint" do
+ it "returns the default API endpoint" do
+ client = described_class.new("foo")
- expect(client.default_api_endpoint).to eq('https://api.github.com')
+ expect(client.default_api_endpoint).to eq("https://api.github.com")
end
end
- describe '#verify_ssl' do
- let(:client) { described_class.new('foo') }
+ describe "#verify_ssl" do
+ let(:client) { described_class.new("foo") }
- context 'without a custom configuration' do
- it 'returns true' do
+ context "without a custom configuration" do
+ it "returns true" do
expect(client)
.to receive(:github_omniauth_provider)
.and_return({})
@@ -344,18 +344,18 @@ describe Gitlab::GithubImport::Client do
end
end
- context 'with a custom configuration' do
- it 'returns the configured value' do
+ context "with a custom configuration" do
+ it "returns the configured value" do
expect(client.verify_ssl).to eq(false)
end
end
end
- describe '#github_omniauth_provider' do
- let(:client) { described_class.new('foo') }
+ describe "#github_omniauth_provider" do
+ let(:client) { described_class.new("foo") }
- context 'without a configured provider' do
- it 'returns an empty Hash' do
+ context "without a configured provider" do
+ it "returns an empty Hash" do
expect(Gitlab.config.omniauth)
.to receive(:providers)
.and_return([])
@@ -364,27 +364,27 @@ describe Gitlab::GithubImport::Client do
end
end
- context 'with a configured provider' do
- it 'returns the provider details as a Hash' do
+ context "with a configured provider" do
+ it "returns the provider details as a Hash" do
hash = client.github_omniauth_provider
- expect(hash['name']).to eq('github')
- expect(hash['url']).to eq('https://github.com/')
+ expect(hash["name"]).to eq("github")
+ expect(hash["url"]).to eq("https://github.com/")
end
end
end
- describe '#rate_limiting_enabled?' do
- let(:client) { described_class.new('foo') }
+ describe "#rate_limiting_enabled?" do
+ let(:client) { described_class.new("foo") }
- it 'returns true when using GitHub.com' do
+ it "returns true when using GitHub.com" do
expect(client.rate_limiting_enabled?).to eq(true)
end
- it 'returns false for GitHub enterprise installations' do
+ it "returns false for GitHub enterprise installations" do
expect(client)
.to receive(:api_endpoint)
- .and_return('https://github.kittens.com/')
+ .and_return("https://github.kittens.com/")
expect(client.rate_limiting_enabled?).to eq(false)
end
diff --git a/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
index 1568c657a1e..423d4d03afe 100644
--- a/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/diff_note_importer_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::DiffNoteImporter do
let(:project) { create(:project) }
let(:client) { double(:client) }
let(:user) { create(:user) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:hunk) do
@@ -15,14 +15,14 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
let(:note) do
Gitlab::GithubImport::Representation::DiffNote.new(
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: 1,
- commit_id: '123abc',
- file_path: 'README.md',
+ commit_id: "123abc",
+ file_path: "README.md",
diff_hunk: hunk,
author: Gitlab::GithubImport::Representation::User
.new(id: user.id, login: user.username),
- note: 'Hello',
+ note: "Hello",
created_at: created_at,
updated_at: updated_at,
github_id: 1
@@ -31,16 +31,16 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
let(:importer) { described_class.new(note, project, client) }
- describe '#execute' do
- context 'when the merge request no longer exists' do
- it 'does not import anything' do
+ describe "#execute" do
+ context "when the merge request no longer exists" do
+ it "does not import anything" do
expect(Gitlab::Database).not_to receive(:bulk_insert)
importer.execute
end
end
- context 'when the merge request exists' do
+ context "when the merge request exists" do
let!(:merge_request) do
create(:merge_request, source_project: project, target_project: project)
end
@@ -51,7 +51,7 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
.and_return(merge_request.id)
end
- it 'imports the note' do
+ it "imports the note" do
allow(importer.user_finder)
.to receive(:author_id_for)
.and_return([user.id, true])
@@ -62,19 +62,19 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
LegacyDiffNote.table_name,
[
{
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
project_id: project.id,
author_id: user.id,
- note: 'Hello',
+ note: "Hello",
system: false,
- commit_id: '123abc',
+ commit_id: "123abc",
line_code: note.line_code,
- type: 'LegacyDiffNote',
+ type: "LegacyDiffNote",
created_at: created_at,
updated_at: updated_at,
- st_diff: note.diff_hash.to_yaml
- }
+ st_diff: note.diff_hash.to_yaml,
+ },
]
)
.and_call_original
@@ -82,7 +82,7 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
importer.execute
end
- it 'imports the note when the author could not be found' do
+ it "imports the note when the author could not be found" do
allow(importer.user_finder)
.to receive(:author_id_for)
.and_return([project.creator_id, false])
@@ -93,19 +93,19 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
LegacyDiffNote.table_name,
[
{
- noteable_type: 'MergeRequest',
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
project_id: project.id,
author_id: project.creator_id,
note: "*Created by: #{user.username}*\n\nHello",
system: false,
- commit_id: '123abc',
+ commit_id: "123abc",
line_code: note.line_code,
- type: 'LegacyDiffNote',
+ type: "LegacyDiffNote",
created_at: created_at,
updated_at: updated_at,
- st_diff: note.diff_hash.to_yaml
- }
+ st_diff: note.diff_hash.to_yaml,
+ },
]
)
.and_call_original
@@ -113,7 +113,7 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
importer.execute
end
- it 'produces a valid LegacyDiffNote' do
+ it "produces a valid LegacyDiffNote" do
allow(importer.user_finder)
.to receive(:author_id_for)
.and_return([user.id, true])
@@ -126,22 +126,22 @@ describe Gitlab::GithubImport::Importer::DiffNoteImporter do
expect(note.diff).to be_an_instance_of(Gitlab::Git::Diff)
end
- it 'does not import the note when a foreign key error is raised' do
+ it "does not import the note when a foreign key error is raised" do
allow(importer.user_finder)
.to receive(:author_id_for)
.and_return([project.creator_id, false])
expect(Gitlab::Database)
.to receive(:bulk_insert)
- .and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ .and_raise(ActiveRecord::InvalidForeignKey, "invalid foreign key")
expect { importer.execute }.not_to raise_error
end
end
end
- describe '#find_merge_request_id' do
- it 'returns a merge request ID' do
+ describe "#find_merge_request_id" do
+ it "returns a merge request ID" do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
diff --git a/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
index 4713c6795bb..21e06b97220 100644
--- a/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/diff_notes_importer_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::DiffNotesImporter do
- let(:project) { double(:project, id: 4, import_source: 'foo/bar') }
+ let(:project) { double(:project, id: 4, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:github_comment) do
double(
:response,
- html_url: 'https://github.com/foo/bar/pull/42',
- path: 'README.md',
- commit_id: '123abc',
+ html_url: "https://github.com/foo/bar/pull/42",
+ path: "README.md",
+ commit_id: "123abc",
diff_hunk: "@@ -1 +1 @@\n-Hello\n+Hello world",
- user: double(:user, id: 4, login: 'alice'),
- body: 'Hello world',
+ user: double(:user, id: 4, login: "alice"),
+ body: "Hello world",
created_at: Time.zone.now,
updated_at: Time.zone.now,
id: 1
)
end
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
importer = described_class.new(project, client)
expect(importer).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = described_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- context 'when running in parallel mode' do
- it 'imports diff notes in parallel' do
+ describe "#execute" do
+ context "when running in parallel mode" do
+ it "imports diff notes in parallel" do
importer = described_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -42,8 +42,8 @@ describe Gitlab::GithubImport::Importer::DiffNotesImporter do
end
end
- context 'when running in sequential mode' do
- it 'imports diff notes in sequence' do
+ context "when running in sequential mode" do
+ it "imports diff notes in sequence" do
importer = described_class.new(project, client, parallel: false)
expect(importer).to receive(:sequential_import)
@@ -53,8 +53,8 @@ describe Gitlab::GithubImport::Importer::DiffNotesImporter do
end
end
- describe '#sequential_import' do
- it 'imports each diff note in sequence' do
+ describe "#sequential_import" do
+ it "imports each diff note in sequence" do
importer = described_class.new(project, client, parallel: false)
diff_note_importer = double(:diff_note_importer)
@@ -77,8 +77,8 @@ describe Gitlab::GithubImport::Importer::DiffNotesImporter do
end
end
- describe '#parallel_import' do
- it 'imports each diff note in parallel' do
+ describe "#parallel_import" do
+ it "imports each diff note in parallel" do
importer = described_class.new(project, client)
allow(importer)
@@ -96,8 +96,8 @@ describe Gitlab::GithubImport::Importer::DiffNotesImporter do
end
end
- describe '#id_for_already_imported_cache' do
- it 'returns the ID of the given note' do
+ describe "#id_for_already_imported_cache" do
+ it "returns the ID of the given note" do
importer = described_class.new(project, client)
expect(importer.id_for_already_imported_cache(github_comment))
@@ -105,8 +105,8 @@ describe Gitlab::GithubImport::Importer::DiffNotesImporter do
end
end
- describe '#collection_options' do
- it 'returns an empty Hash' do
+ describe "#collection_options" do
+ it "returns an empty Hash" do
# For large projects (e.g. kubernetes/kubernetes) GitHub's API may produce
# HTTP 500 errors when using explicit sorting options, regardless of what
# order you sort in. Not using any sorting options at all allows us to
diff --git a/spec/lib/gitlab/github_import/importer/issue_and_label_links_importer_spec.rb b/spec/lib/gitlab/github_import/importer/issue_and_label_links_importer_spec.rb
index 665b31ef244..7e556f5823f 100644
--- a/spec/lib/gitlab/github_import/importer/issue_and_label_links_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/issue_and_label_links_importer_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::IssueAndLabelLinksImporter do
- describe '#execute' do
- it 'imports an issue and its labels' do
+ describe "#execute" do
+ it "imports an issue and its labels" do
issue = double(:issue)
project = double(:project)
client = double(:client)
diff --git a/spec/lib/gitlab/github_import/importer/issue_importer_spec.rb b/spec/lib/gitlab/github_import/importer/issue_importer_spec.rb
index 7901ae005d9..38f986cc30c 100644
--- a/spec/lib/gitlab/github_import/importer/issue_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/issue_importer_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cache do
let(:project) { create(:project) }
let(:client) { double(:client) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:issue) do
Gitlab::GithubImport::Representation::Issue.new(
iid: 42,
- title: 'My Issue',
- description: 'This is my issue',
+ title: "My Issue",
+ description: "This is my issue",
milestone_number: 1,
state: :opened,
assignees: [
- Gitlab::GithubImport::Representation::User.new(id: 4, login: 'alice'),
- Gitlab::GithubImport::Representation::User.new(id: 5, login: 'bob')
+ Gitlab::GithubImport::Representation::User.new(id: 4, login: "alice"),
+ Gitlab::GithubImport::Representation::User.new(id: 5, login: "bob"),
],
label_names: %w[bug],
- author: Gitlab::GithubImport::Representation::User.new(id: 4, login: 'alice'),
+ author: Gitlab::GithubImport::Representation::User.new(id: 4, login: "alice"),
created_at: created_at,
updated_at: updated_at,
pull_request: false
)
end
- describe '.import_if_issue' do
- it 'imports an issuable if it is a regular issue' do
+ describe ".import_if_issue" do
+ it "imports an issuable if it is a regular issue" do
importer = double(:importer)
expect(described_class)
@@ -41,7 +41,7 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
described_class.import_if_issue(issue, project, client)
end
- it 'does not import the issuable if it is a pull request' do
+ it "does not import the issuable if it is a pull request" do
expect(issue).to receive(:pull_request?).and_return(true)
expect(described_class).not_to receive(:new)
@@ -50,10 +50,10 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
end
end
- describe '#execute' do
+ describe "#execute" do
let(:importer) { described_class.new(issue, project, client) }
- it 'creates the issue and assignees' do
+ it "creates the issue and assignees" do
expect(importer)
.to receive(:create_issue)
.and_return(10)
@@ -70,7 +70,7 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
end
end
- describe '#create_issue' do
+ describe "#create_issue" do
let(:importer) { described_class.new(issue, project, client) }
before do
@@ -80,8 +80,8 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
.and_return(milestone.id)
end
- context 'when the issue author could be found' do
- it 'creates the issue with the found author as the issue author' do
+ context "when the issue author could be found" do
+ it "creates the issue with the found author as the issue author" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(issue)
@@ -92,14 +92,14 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
.with(
{
iid: 42,
- title: 'My Issue',
+ title: "My Issue",
author_id: user.id,
project_id: project.id,
- description: 'This is my issue',
+ description: "This is my issue",
milestone_id: milestone.id,
state: :opened,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
},
project.issues
)
@@ -109,8 +109,8 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
end
end
- context 'when the issue author could not be found' do
- it 'creates the issue with the project creator as the issue author' do
+ context "when the issue author could not be found" do
+ it "creates the issue with the project creator as the issue author" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(issue)
@@ -121,14 +121,14 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
.with(
{
iid: 42,
- title: 'My Issue',
+ title: "My Issue",
author_id: project.creator_id,
project_id: project.id,
description: "*Created by: alice*\n\nThis is my issue",
milestone_id: milestone.id,
state: :opened,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
},
project.issues
)
@@ -138,8 +138,8 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
end
end
- context 'when the import fails due to a foreign key error' do
- it 'does not raise any errors' do
+ context "when the import fails due to a foreign key error" do
+ it "does not raise any errors" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(issue)
@@ -147,13 +147,13 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
expect(importer)
.to receive(:insert_and_return_id)
- .and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ .and_raise(ActiveRecord::InvalidForeignKey, "invalid foreign key")
expect { importer.create_issue }.not_to raise_error
end
end
- it 'produces a valid Issue' do
+ it "produces a valid Issue" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(issue)
@@ -164,7 +164,7 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
expect(project.issues.take).to be_valid
end
- it 'returns the ID of the created issue' do
+ it "returns the ID of the created issue" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(issue)
@@ -174,8 +174,8 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
end
end
- describe '#create_assignees' do
- it 'inserts the issue assignees in bulk' do
+ describe "#create_assignees" do
+ it "inserts the issue assignees in bulk" do
importer = described_class.new(issue, project, client)
allow(importer.user_finder)
@@ -192,7 +192,7 @@ describe Gitlab::GithubImport::Importer::IssueImporter, :clean_gitlab_redis_cach
.to receive(:bulk_insert)
.with(
IssueAssignee.table_name,
- [{ issue_id: 1, user_id: 4 }, { issue_id: 1, user_id: 5 }]
+ [{issue_id: 1, user_id: 4}, {issue_id: 1, user_id: 5}]
)
importer.create_assignees(1)
diff --git a/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb b/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
index e237e79e94b..5342d8fc64f 100644
--- a/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/issues_importer_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::IssuesImporter do
- let(:project) { double(:project, id: 4, import_source: 'foo/bar') }
+ let(:project) { double(:project, id: 4, import_source: "foo/bar") }
let(:client) { double(:client) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:github_issue) do
double(
:response,
number: 42,
- title: 'My Issue',
- body: 'This is my issue',
+ title: "My Issue",
+ body: "This is my issue",
milestone: double(:milestone, number: 4),
- state: 'open',
- assignees: [double(:user, id: 4, login: 'alice')],
- labels: [double(:label, name: 'bug')],
- user: double(:user, id: 4, login: 'alice'),
+ state: "open",
+ assignees: [double(:user, id: 4, login: "alice")],
+ labels: [double(:label, name: "bug")],
+ user: double(:user, id: 4, login: "alice"),
created_at: created_at,
updated_at: updated_at,
pull_request: false
)
end
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
importer = described_class.new(project, client)
expect(importer).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = described_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- context 'when running in parallel mode' do
- it 'imports issues in parallel' do
+ describe "#execute" do
+ context "when running in parallel mode" do
+ it "imports issues in parallel" do
importer = described_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -46,8 +46,8 @@ describe Gitlab::GithubImport::Importer::IssuesImporter do
end
end
- context 'when running in sequential mode' do
- it 'imports issues in sequence' do
+ context "when running in sequential mode" do
+ it "imports issues in sequence" do
importer = described_class.new(project, client, parallel: false)
expect(importer).to receive(:sequential_import)
@@ -57,8 +57,8 @@ describe Gitlab::GithubImport::Importer::IssuesImporter do
end
end
- describe '#sequential_import' do
- it 'imports each issue in sequence' do
+ describe "#sequential_import" do
+ it "imports each issue in sequence" do
importer = described_class.new(project, client, parallel: false)
issue_importer = double(:importer)
@@ -81,8 +81,8 @@ describe Gitlab::GithubImport::Importer::IssuesImporter do
end
end
- describe '#parallel_import' do
- it 'imports each issue in parallel' do
+ describe "#parallel_import" do
+ it "imports each issue in parallel" do
importer = described_class.new(project, client)
allow(importer)
@@ -100,8 +100,8 @@ describe Gitlab::GithubImport::Importer::IssuesImporter do
end
end
- describe '#id_for_already_imported_cache' do
- it 'returns the issue number of the given issue' do
+ describe "#id_for_already_imported_cache" do
+ it "returns the issue number of the given issue" do
importer = described_class.new(project, client)
expect(importer.id_for_already_imported_cache(github_issue))
diff --git a/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb b/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
index e2a71e78574..249b8e07597 100644
--- a/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/label_links_importer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::LabelLinksImporter do
let(:project) { create(:project) }
@@ -15,8 +15,8 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
let(:importer) { described_class.new(issue, project, client) }
- describe '#execute' do
- it 'creates the label links' do
+ describe "#execute" do
+ it "creates the label links" do
importer = described_class.new(issue, project, client)
expect(importer).to receive(:create_labels)
@@ -25,11 +25,11 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
end
end
- describe '#create_labels' do
- it 'inserts the label links in bulk' do
+ describe "#create_labels" do
+ it "inserts the label links in bulk" do
expect(importer.label_finder)
.to receive(:id_for)
- .with('bug')
+ .with("bug")
.and_return(2)
expect(importer)
@@ -47,8 +47,8 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
target_id: 1,
target_type: Issue,
created_at: Time.zone.now,
- updated_at: Time.zone.now
- }
+ updated_at: Time.zone.now,
+ },
]
)
@@ -56,10 +56,10 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
end
end
- it 'does not insert label links for non-existing labels' do
+ it "does not insert label links for non-existing labels" do
expect(importer.label_finder)
.to receive(:id_for)
- .with('bug')
+ .with("bug")
.and_return(nil)
expect(Gitlab::Database)
@@ -70,8 +70,8 @@ describe Gitlab::GithubImport::Importer::LabelLinksImporter do
end
end
- describe '#find_target_id' do
- it 'returns the ID of the issuable to create the label link for' do
+ describe "#find_target_id" do
+ it "returns the ID of the issuable to create the label link for" do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
diff --git a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
index 156ef96a0fa..9637f1a0095 100644
--- a/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/labels_importer_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cache do
- let(:project) { create(:project, import_source: 'foo/bar') }
+ let(:project) { create(:project, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:importer) { described_class.new(project, client) }
- describe '#execute' do
- it 'imports the labels in bulk' do
- label_hash = { title: 'bug', color: '#fffaaa' }
+ describe "#execute" do
+ it "imports the labels in bulk" do
+ label_hash = {title: "bug", color: "#fffaaa"}
expect(importer)
.to receive(:build_labels)
@@ -24,30 +24,30 @@ describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cac
end
end
- describe '#build_labels' do
- it 'returns an Array containnig label rows' do
- label = double(:label, name: 'bug', color: 'ffffff')
+ describe "#build_labels" do
+ it "returns an Array containnig label rows" do
+ label = double(:label, name: "bug", color: "ffffff")
expect(importer).to receive(:each_label).and_return([label])
rows = importer.build_labels
expect(rows.length).to eq(1)
- expect(rows[0][:title]).to eq('bug')
+ expect(rows[0][:title]).to eq("bug")
end
- it 'does not create labels that already exist' do
- create(:label, project: project, title: 'bug')
+ it "does not create labels that already exist" do
+ create(:label, project: project, title: "bug")
- label = double(:label, name: 'bug', color: 'ffffff')
+ label = double(:label, name: "bug", color: "ffffff")
expect(importer).to receive(:each_label).and_return([label])
expect(importer.build_labels).to be_empty
end
end
- describe '#build_labels_cache' do
- it 'builds the labels cache' do
+ describe "#build_labels_cache" do
+ it "builds the labels cache" do
expect_any_instance_of(Gitlab::GithubImport::LabelFinder)
.to receive(:build_cache)
@@ -55,39 +55,39 @@ describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cac
end
end
- describe '#build' do
+ describe "#build" do
let(:label_hash) do
- importer.build(double(:label, name: 'bug', color: 'ffffff'))
+ importer.build(double(:label, name: "bug", color: "ffffff"))
end
- it 'returns the attributes of the label as a Hash' do
+ it "returns the attributes of the label as a Hash" do
expect(label_hash).to be_an_instance_of(Hash)
end
- context 'the returned Hash' do
- it 'includes the label title' do
- expect(label_hash[:title]).to eq('bug')
+ context "the returned Hash" do
+ it "includes the label title" do
+ expect(label_hash[:title]).to eq("bug")
end
- it 'includes the label color' do
- expect(label_hash[:color]).to eq('#ffffff')
+ it "includes the label color" do
+ expect(label_hash[:color]).to eq("#ffffff")
end
- it 'includes the project ID' do
+ it "includes the project ID" do
expect(label_hash[:project_id]).to eq(project.id)
end
- it 'includes the label type' do
- expect(label_hash[:type]).to eq('ProjectLabel')
+ it "includes the label type" do
+ expect(label_hash[:type]).to eq("ProjectLabel")
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
Timecop.freeze do
expect(label_hash[:created_at]).to eq(Time.zone.now)
end
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
Timecop.freeze do
expect(label_hash[:updated_at]).to eq(Time.zone.now)
end
@@ -95,11 +95,11 @@ describe Gitlab::GithubImport::Importer::LabelsImporter, :clean_gitlab_redis_cac
end
end
- describe '#each_label' do
- it 'returns the labels' do
+ describe "#each_label" do
+ it "returns the labels" do
expect(client)
.to receive(:labels)
- .with('foo/bar')
+ .with("foo/bar")
importer.each_label
end
diff --git a/spec/lib/gitlab/github_import/importer/lfs_object_importer_spec.rb b/spec/lib/gitlab/github_import/importer/lfs_object_importer_spec.rb
index 8fd328d9c1e..8bf5dee431d 100644
--- a/spec/lib/gitlab/github_import/importer/lfs_object_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/lfs_object_importer_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::LfsObjectImporter do
let(:project) { create(:project) }
let(:lfs_attributes) do
{
- oid: 'oid',
+ oid: "oid",
size: 1,
- link: 'http://www.gitlab.com/lfs_objects/oid'
+ link: "http://www.gitlab.com/lfs_objects/oid",
}
end
@@ -15,8 +15,8 @@ describe Gitlab::GithubImport::Importer::LfsObjectImporter do
let(:importer) { described_class.new(github_lfs_object, project, nil) }
- describe '#execute' do
- it 'calls the LfsDownloadService with the lfs object attributes' do
+ describe "#execute" do
+ it "calls the LfsDownloadService with the lfs object attributes" do
allow(importer).to receive(:lfs_download_object).and_return(lfs_download_object)
service = double
diff --git a/spec/lib/gitlab/github_import/importer/lfs_objects_importer_spec.rb b/spec/lib/gitlab/github_import/importer/lfs_objects_importer_spec.rb
index 50442552eee..4c8eda2e75f 100644
--- a/spec/lib/gitlab/github_import/importer/lfs_objects_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/lfs_objects_importer_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
- let(:project) { double(:project, id: 4, import_source: 'foo/bar') }
+ let(:project) { double(:project, id: 4, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:download_link) { "http://www.gitlab.com/lfs_objects/oid" }
let(:lfs_attributes) do
{
- oid: 'oid',
+ oid: "oid",
size: 1,
- link: 'http://www.gitlab.com/lfs_objects/oid'
+ link: "http://www.gitlab.com/lfs_objects/oid",
}
end
let(:lfs_download_object) { LfsDownloadObject.new(lfs_attributes) }
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
importer = described_class.new(project, client)
expect(importer).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = described_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- context 'when running in parallel mode' do
- it 'imports lfs objects in parallel' do
+ describe "#execute" do
+ context "when running in parallel mode" do
+ it "imports lfs objects in parallel" do
importer = described_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -38,8 +38,8 @@ describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
end
end
- context 'when running in sequential mode' do
- it 'imports lfs objects in sequence' do
+ context "when running in sequential mode" do
+ it "imports lfs objects in sequence" do
importer = described_class.new(project, client, parallel: false)
expect(importer).to receive(:sequential_import)
@@ -49,8 +49,8 @@ describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
end
end
- describe '#sequential_import' do
- it 'imports each lfs object in sequence' do
+ describe "#sequential_import" do
+ it "imports each lfs object in sequence" do
importer = described_class.new(project, client, parallel: false)
lfs_object_importer = double(:lfs_object_importer)
@@ -73,8 +73,8 @@ describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
end
end
- describe '#parallel_import' do
- it 'imports each lfs object in parallel' do
+ describe "#parallel_import" do
+ it "imports each lfs object in parallel" do
importer = described_class.new(project, client)
allow(importer)
@@ -92,8 +92,8 @@ describe Gitlab::GithubImport::Importer::LfsObjectsImporter do
end
end
- describe '#collection_options' do
- it 'returns an empty Hash' do
+ describe "#collection_options" do
+ it "returns an empty Hash" do
importer = described_class.new(project, client)
expect(importer.collection_options).to eq({})
diff --git a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
index b1cac3b6e46..2858f7bddf3 100644
--- a/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/milestones_importer_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis_cache do
- let(:project) { create(:project, import_source: 'foo/bar') }
+ let(:project) { create(:project, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:importer) { described_class.new(project, client) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:milestone) do
double(
:milestone,
number: 1,
- title: '1.0',
- description: 'The first release',
- state: 'open',
+ title: "1.0",
+ description: "The first release",
+ state: "open",
created_at: created_at,
updated_at: updated_at
)
end
- describe '#execute' do
- it 'imports the milestones in bulk' do
- milestone_hash = { number: 1, title: '1.0' }
+ describe "#execute" do
+ it "imports the milestones in bulk" do
+ milestone_hash = {number: 1, title: "1.0"}
expect(importer)
.to receive(:build_milestones)
@@ -38,8 +38,8 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
end
end
- describe '#build_milestones' do
- it 'returns an Array containnig milestone rows' do
+ describe "#build_milestones" do
+ it "returns an Array containnig milestone rows" do
expect(importer)
.to receive(:each_milestone)
.and_return([milestone])
@@ -47,11 +47,11 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
rows = importer.build_milestones
expect(rows.length).to eq(1)
- expect(rows[0][:title]).to eq('1.0')
+ expect(rows[0][:title]).to eq("1.0")
end
- it 'does not create milestones that already exist' do
- create(:milestone, project: project, title: '1.0', iid: 1)
+ it "does not create milestones that already exist" do
+ create(:milestone, project: project, title: "1.0", iid: 1)
expect(importer)
.to receive(:each_milestone)
@@ -61,8 +61,8 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
end
end
- describe '#build_milestones_cache' do
- it 'builds the milestones cache' do
+ describe "#build_milestones_cache" do
+ it "builds the milestones cache" do
expect_any_instance_of(Gitlab::GithubImport::MilestoneFinder)
.to receive(:build_cache)
@@ -70,49 +70,49 @@ describe Gitlab::GithubImport::Importer::MilestonesImporter, :clean_gitlab_redis
end
end
- describe '#build' do
+ describe "#build" do
let(:milestone_hash) { importer.build(milestone) }
- it 'returns the attributes of the milestone as a Hash' do
+ it "returns the attributes of the milestone as a Hash" do
expect(milestone_hash).to be_an_instance_of(Hash)
end
- context 'the returned Hash' do
- it 'includes the milestone number' do
+ context "the returned Hash" do
+ it "includes the milestone number" do
expect(milestone_hash[:iid]).to eq(1)
end
- it 'includes the milestone title' do
- expect(milestone_hash[:title]).to eq('1.0')
+ it "includes the milestone title" do
+ expect(milestone_hash[:title]).to eq("1.0")
end
- it 'includes the milestone description' do
- expect(milestone_hash[:description]).to eq('The first release')
+ it "includes the milestone description" do
+ expect(milestone_hash[:description]).to eq("The first release")
end
- it 'includes the project ID' do
+ it "includes the project ID" do
expect(milestone_hash[:project_id]).to eq(project.id)
end
- it 'includes the milestone state' do
+ it "includes the milestone state" do
expect(milestone_hash[:state]).to eq(:active)
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(milestone_hash[:created_at]).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(milestone_hash[:updated_at]).to eq(updated_at)
end
end
end
- describe '#each_milestone' do
- it 'returns the milestones' do
+ describe "#each_milestone" do
+ it "returns the milestones" do
expect(client)
.to receive(:milestones)
- .with('foo/bar', state: 'all')
+ .with("foo/bar", state: "all")
importer.each_milestone
end
diff --git a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
index 9bdcc42be19..34fc3533f5b 100644
--- a/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/note_importer_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::NoteImporter do
let(:client) { double(:client) }
let(:project) { create(:project) }
let(:user) { create(:user) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:github_note) do
Gitlab::GithubImport::Representation::Note.new(
noteable_id: 1,
- noteable_type: 'Issue',
- author: Gitlab::GithubImport::Representation::User.new(id: 4, login: 'alice'),
- note: 'This is my note',
+ noteable_type: "Issue",
+ author: Gitlab::GithubImport::Representation::User.new(id: 4, login: "alice"),
+ note: "This is my note",
created_at: created_at,
updated_at: updated_at,
github_id: 1
@@ -21,8 +21,8 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
let(:importer) { described_class.new(github_note, project, client) }
- describe '#execute' do
- context 'when the noteable exists' do
+ describe "#execute" do
+ context "when the noteable exists" do
let!(:issue_row) { create(:issue, project: project, iid: 1) }
before do
@@ -31,8 +31,8 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
.and_return(issue_row.id)
end
- context 'when the author could be found' do
- it 'imports the note with the found author as the note author' do
+ context "when the author could be found" do
+ it "imports the note with the found author as the note author" do
expect(importer.user_finder)
.to receive(:author_id_for)
.with(github_note)
@@ -44,15 +44,15 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
Note.table_name,
[
{
- noteable_type: 'Issue',
+ noteable_type: "Issue",
noteable_id: issue_row.id,
project_id: project.id,
author_id: user.id,
- note: 'This is my note',
+ note: "This is my note",
system: false,
created_at: created_at,
- updated_at: updated_at
- }
+ updated_at: updated_at,
+ },
]
)
.and_call_original
@@ -61,8 +61,8 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
end
end
- context 'when the note author could not be found' do
- it 'imports the note with the project creator as the note author' do
+ context "when the note author could not be found" do
+ it "imports the note with the project creator as the note author" do
expect(importer.user_finder)
.to receive(:author_id_for)
.with(github_note)
@@ -74,15 +74,15 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
Note.table_name,
[
{
- noteable_type: 'Issue',
+ noteable_type: "Issue",
noteable_id: issue_row.id,
project_id: project.id,
author_id: project.creator_id,
note: "*Created by: alice*\n\nThis is my note",
system: false,
created_at: created_at,
- updated_at: updated_at
- }
+ updated_at: updated_at,
+ },
]
)
.and_call_original
@@ -92,16 +92,16 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
end
end
- context 'when the noteable does not exist' do
- it 'does not import the note' do
+ context "when the noteable does not exist" do
+ it "does not import the note" do
expect(Gitlab::Database).not_to receive(:bulk_insert)
importer.execute
end
end
- context 'when the import fails due to a foreign key error' do
- it 'does not raise any errors' do
+ context "when the import fails due to a foreign key error" do
+ it "does not raise any errors" do
issue_row = create(:issue, project: project, iid: 1)
allow(importer)
@@ -115,13 +115,13 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
expect(Gitlab::Database)
.to receive(:bulk_insert)
- .and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ .and_raise(ActiveRecord::InvalidForeignKey, "invalid foreign key")
expect { importer.execute }.not_to raise_error
end
end
- it 'produces a valid Note' do
+ it "produces a valid Note" do
issue_row = create(:issue, project: project, iid: 1)
allow(importer)
@@ -139,8 +139,8 @@ describe Gitlab::GithubImport::Importer::NoteImporter do
end
end
- describe '#find_noteable_id' do
- it 'returns the ID of the noteable' do
+ describe "#find_noteable_id" do
+ it "returns the ID of the noteable" do
expect_any_instance_of(Gitlab::GithubImport::IssuableFinder)
.to receive(:database_id)
.and_return(10)
diff --git a/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb b/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
index f046d13f879..7980b6bb0a5 100644
--- a/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/notes_importer_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::NotesImporter do
- let(:project) { double(:project, id: 4, import_source: 'foo/bar') }
+ let(:project) { double(:project, id: 4, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:github_comment) do
double(
:response,
- html_url: 'https://github.com/foo/bar/issues/42',
- user: double(:user, id: 4, login: 'alice'),
- body: 'Hello world',
+ html_url: "https://github.com/foo/bar/issues/42",
+ user: double(:user, id: 4, login: "alice"),
+ body: "Hello world",
created_at: Time.zone.now,
updated_at: Time.zone.now,
id: 1
)
end
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
importer = described_class.new(project, client)
expect(importer).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = described_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- context 'when running in parallel mode' do
- it 'imports notes in parallel' do
+ describe "#execute" do
+ context "when running in parallel mode" do
+ it "imports notes in parallel" do
importer = described_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -39,8 +39,8 @@ describe Gitlab::GithubImport::Importer::NotesImporter do
end
end
- context 'when running in sequential mode' do
- it 'imports notes in sequence' do
+ context "when running in sequential mode" do
+ it "imports notes in sequence" do
importer = described_class.new(project, client, parallel: false)
expect(importer).to receive(:sequential_import)
@@ -50,8 +50,8 @@ describe Gitlab::GithubImport::Importer::NotesImporter do
end
end
- describe '#sequential_import' do
- it 'imports each note in sequence' do
+ describe "#sequential_import" do
+ it "imports each note in sequence" do
importer = described_class.new(project, client, parallel: false)
note_importer = double(:note_importer)
@@ -74,8 +74,8 @@ describe Gitlab::GithubImport::Importer::NotesImporter do
end
end
- describe '#parallel_import' do
- it 'imports each note in parallel' do
+ describe "#parallel_import" do
+ it "imports each note in parallel" do
importer = described_class.new(project, client)
allow(importer)
@@ -93,8 +93,8 @@ describe Gitlab::GithubImport::Importer::NotesImporter do
end
end
- describe '#id_for_already_imported_cache' do
- it 'returns the ID of the given note' do
+ describe "#id_for_already_imported_cache" do
+ it "returns the ID of the given note" do
importer = described_class.new(project, client)
expect(importer.id_for_already_imported_cache(github_comment))
@@ -102,8 +102,8 @@ describe Gitlab::GithubImport::Importer::NotesImporter do
end
end
- describe '#collection_options' do
- it 'returns an empty Hash' do
+ describe "#collection_options" do
+ it "returns an empty Hash" do
# For large projects (e.g. kubernetes/kubernetes) GitHub's API may produce
# HTTP 500 errors when using explicit sorting options, regardless of what
# order you sort in. Not using any sorting options at all allows us to
diff --git a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb
index 15e59718dce..f3d67079c1a 100644
--- a/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_request_importer_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redis_cache do
let(:project) { create(:project, :repository) }
let(:client) { double(:client) }
let(:user) { create(:user) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:merged_at) { Time.new(2017, 1, 1, 12, 17) }
- let(:source_commit) { project.repository.commit('feature') }
- let(:target_commit) { project.repository.commit('master') }
+ let(:source_commit) { project.repository.commit("feature") }
+ let(:target_commit) { project.repository.commit("master") }
let(:milestone) { create(:milestone, project: project) }
let(:pull_request) do
- alice = Gitlab::GithubImport::Representation::User.new(id: 4, login: 'alice')
+ alice = Gitlab::GithubImport::Representation::User.new(id: 4, login: "alice")
Gitlab::GithubImport::Representation::PullRequest.new(
iid: 42,
- title: 'My Pull Request',
- description: 'This is my pull request',
- source_branch: 'feature',
+ title: "My Pull Request",
+ description: "This is my pull request",
+ source_branch: "feature",
source_branch_sha: source_commit.id,
- target_branch: 'master',
+ target_branch: "master",
target_branch_sha: target_commit.id,
source_repository_id: 400,
target_repository_id: 200,
- source_repository_owner: 'alice',
+ source_repository_owner: "alice",
state: :closed,
milestone_number: milestone.iid,
author: alice,
@@ -38,8 +38,8 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
let(:importer) { described_class.new(pull_request, project, client) }
- describe '#execute' do
- it 'imports the pull request' do
+ describe "#execute" do
+ it "imports the pull request" do
mr = double(:merge_request, id: 10)
expect(importer)
@@ -58,7 +58,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
end
end
- describe '#create_merge_request' do
+ describe "#create_merge_request" do
before do
allow(importer.milestone_finder)
.to receive(:id_for)
@@ -66,7 +66,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.and_return(milestone.id)
end
- context 'when the author could be found' do
+ context "when the author could be found" do
before do
allow(importer.user_finder)
.to receive(:author_id_for)
@@ -79,24 +79,24 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.and_return(user.id)
end
- it 'imports the pull request with the pull request author as the merge request author' do
+ it "imports the pull request with the pull request author as the merge request author" do
expect(importer)
.to receive(:insert_and_return_id)
.with(
{
iid: 42,
- title: 'My Pull Request',
- description: 'This is my pull request',
+ title: "My Pull Request",
+ description: "This is my pull request",
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'github/fork/alice/feature',
- target_branch: 'master',
+ source_branch: "github/fork/alice/feature",
+ target_branch: "master",
state: :merged,
milestone_id: milestone.id,
author_id: user.id,
assignee_id: user.id,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
},
project.merge_requests
)
@@ -105,7 +105,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
importer.create_merge_request
end
- it 'returns the created merge request' do
+ it "returns the created merge request" do
mr, exists = importer.create_merge_request
expect(mr).to be_instance_of(MergeRequest)
@@ -113,8 +113,8 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
end
end
- context 'when the author could not be found' do
- it 'imports the pull request with the project creator as the merge request author' do
+ context "when the author could not be found" do
+ it "imports the pull request with the project creator as the merge request author" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(pull_request)
@@ -130,18 +130,18 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.with(
{
iid: 42,
- title: 'My Pull Request',
+ title: "My Pull Request",
description: "*Created by: alice*\n\nThis is my pull request",
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'github/fork/alice/feature',
- target_branch: 'master',
+ source_branch: "github/fork/alice/feature",
+ target_branch: "master",
state: :merged,
milestone_id: milestone.id,
author_id: project.creator_id,
assignee_id: user.id,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
},
project.merge_requests
)
@@ -151,8 +151,8 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
end
end
- context 'when the source and target branch are identical' do
- it 'uses a generated source branch name for the merge request' do
+ context "when the source and target branch are identical" do
+ it "uses a generated source branch name for the merge request" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(pull_request)
@@ -169,25 +169,25 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
allow(pull_request)
.to receive(:source_branch)
- .and_return('master')
+ .and_return("master")
expect(importer)
.to receive(:insert_and_return_id)
.with(
{
iid: 42,
- title: 'My Pull Request',
- description: 'This is my pull request',
+ title: "My Pull Request",
+ description: "This is my pull request",
source_project_id: project.id,
target_project_id: project.id,
- source_branch: 'master-42',
- target_branch: 'master',
+ source_branch: "master-42",
+ target_branch: "master",
state: :merged,
milestone_id: milestone.id,
author_id: user.id,
assignee_id: user.id,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
},
project.merge_requests
)
@@ -197,8 +197,8 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
end
end
- context 'when the import fails due to a foreign key error' do
- it 'does not raise any errors' do
+ context "when the import fails due to a foreign key error" do
+ it "does not raise any errors" do
allow(importer.user_finder)
.to receive(:author_id_for)
.with(pull_request)
@@ -211,13 +211,13 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(importer)
.to receive(:insert_and_return_id)
- .and_raise(ActiveRecord::InvalidForeignKey, 'invalid foreign key')
+ .and_raise(ActiveRecord::InvalidForeignKey, "invalid foreign key")
expect { importer.create_merge_request }.not_to raise_error
end
end
- context 'when the merge request already exists' do
+ context "when the merge request already exists" do
before do
allow(importer.user_finder)
.to receive(:author_id_for)
@@ -230,7 +230,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.and_return(user.id)
end
- it 'returns the existing merge request' do
+ it "returns the existing merge request" do
mr1, exists1 = importer.create_merge_request
mr2, exists2 = importer.create_merge_request
@@ -241,7 +241,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
end
end
- describe '#insert_git_data' do
+ describe "#insert_git_data" do
before do
allow(importer.milestone_finder)
.to receive(:id_for)
@@ -259,7 +259,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
.and_return(user.id)
end
- it 'does not create the source branch if merge request is merged' do
+ it "does not create the source branch if merge request is merged" do
mr, exists = importer.create_merge_request
importer.insert_git_data(mr, exists)
@@ -268,9 +268,9 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy
end
- it 'creates the source branch if merge request is open' do
+ it "creates the source branch if merge request is open" do
mr, exists = importer.create_merge_request
- mr.state = 'opened'
+ mr.state = "opened"
mr.save
importer.insert_git_data(mr, exists)
@@ -279,9 +279,9 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy
end
- it 'ignores Git errors when creating a branch' do
+ it "ignores Git errors when creating a branch" do
mr, exists = importer.create_merge_request
- mr.state = 'opened'
+ mr.state = "opened"
mr.save
expect(project.repository).to receive(:add_branch).and_raise(Gitlab::Git::CommandError)
@@ -293,7 +293,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(project.repository.branch_exists?(mr.target_branch)).to be_truthy
end
- it 'creates the merge request diffs' do
+ it "creates the merge request diffs" do
mr, exists = importer.create_merge_request
importer.insert_git_data(mr, exists)
@@ -301,7 +301,7 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(mr.merge_request_diffs.exists?).to eq(true)
end
- it 'creates the merge request diff commits' do
+ it "creates the merge request diff commits" do
mr, exists = importer.create_merge_request
importer.insert_git_data(mr, exists)
@@ -311,8 +311,8 @@ describe Gitlab::GithubImport::Importer::PullRequestImporter, :clean_gitlab_redi
expect(diff.merge_request_diff_commits.exists?).to eq(true)
end
- context 'when the merge request exists' do
- it 'creates the merge request diffs if they do not yet exist' do
+ context "when the merge request exists" do
+ it "creates the merge request diffs if they do not yet exist" do
mr, _ = importer.create_merge_request
mr.merge_request_diffs.delete_all
diff --git a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
index c51985f00a2..bc95bdd38f5 100644
--- a/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/pull_requests_importer_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::PullRequestsImporter do
- let(:project) { create(:project, import_source: 'foo/bar') }
+ let(:project) { create(:project, import_source: "foo/bar") }
let(:client) { double(:client) }
let(:pull_request) do
double(
:response,
number: 42,
- title: 'My Pull Request',
- body: 'This is my pull request',
- state: 'closed',
+ title: "My Pull Request",
+ body: "This is my pull request",
+ state: "closed",
head: double(
:head,
- sha: '123abc',
- ref: 'my-feature',
+ sha: "123abc",
+ ref: "my-feature",
repo: double(:repo, id: 400),
- user: double(:user, id: 4, login: 'alice')
+ user: double(:user, id: 4, login: "alice")
),
base: double(
:base,
- sha: '456def',
- ref: 'master',
+ sha: "456def",
+ ref: "master",
repo: double(:repo, id: 200)
),
milestone: double(:milestone, number: 4),
- user: double(:user, id: 4, login: 'alice'),
- assignee: double(:user, id: 4, login: 'alice'),
+ user: double(:user, id: 4, login: "alice"),
+ assignee: double(:user, id: 4, login: "alice"),
created_at: 1.second.ago,
updated_at: 1.second.ago,
merged_at: 1.second.ago
)
end
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
importer = described_class.new(project, client)
expect(importer).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = described_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- context 'when running in parallel mode' do
- it 'imports pull requests in parallel' do
+ describe "#execute" do
+ context "when running in parallel mode" do
+ it "imports pull requests in parallel" do
importer = described_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -56,8 +56,8 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- context 'when running in sequential mode' do
- it 'imports pull requests in sequence' do
+ context "when running in sequential mode" do
+ it "imports pull requests in sequence" do
importer = described_class.new(project, client, parallel: false)
expect(importer).to receive(:sequential_import)
@@ -67,8 +67,8 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#sequential_import' do
- it 'imports each pull request in sequence' do
+ describe "#sequential_import" do
+ it "imports each pull request in sequence" do
importer = described_class.new(project, client, parallel: false)
pull_request_importer = double(:pull_request_importer)
@@ -91,8 +91,8 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#parallel_import' do
- it 'imports each note in parallel' do
+ describe "#parallel_import" do
+ it "imports each note in parallel" do
importer = described_class.new(project, client)
allow(importer)
@@ -110,7 +110,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#each_object_to_import', :clean_gitlab_redis_cache do
+ describe "#each_object_to_import", :clean_gitlab_redis_cache do
let(:importer) { described_class.new(project, client) }
before do
@@ -120,18 +120,18 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
.to receive(:each_page)
.with(
:pull_requests,
- 'foo/bar',
- { state: 'all', sort: 'created', direction: 'asc', page: 1 }
+ "foo/bar",
+ {state: "all", sort: "created", direction: "asc", page: 1}
)
.and_yield(page)
end
- it 'yields every pull request to the supplied block' do
+ it "yields every pull request to the supplied block" do
expect { |b| importer.each_object_to_import(&b) }
.to yield_with_args(pull_request)
end
- it 'updates the repository if a pull request was updated after the last clone' do
+ it "updates the repository if a pull request was updated after the last clone" do
expect(importer)
.to receive(:update_repository?)
.with(pull_request)
@@ -144,13 +144,13 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#update_repository' do
- it 'updates the repository' do
+ describe "#update_repository" do
+ it "updates the repository" do
importer = described_class.new(project, client)
expect(project.repository)
.to receive(:fetch_remote)
- .with('github', forced: false)
+ .with("github", forced: false)
expect(Rails.logger)
.to receive(:info)
@@ -168,16 +168,16 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#update_repository?' do
+ describe "#update_repository?" do
let(:importer) { described_class.new(project, client) }
- context 'when the pull request was updated after the last update' do
+ context "when the pull request was updated after the last update" do
let(:pr) do
double(
:pr,
updated_at: Time.zone.now,
- head: double(:head, sha: '123'),
- base: double(:base, sha: '456')
+ head: double(:head, sha: "123"),
+ base: double(:base, sha: "456")
)
end
@@ -187,7 +187,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
.and_return(1.year.ago)
end
- it 'returns true when the head SHA is not present' do
+ it "returns true when the head SHA is not present" do
expect(importer)
.to receive(:commit_exists?)
.with(pr.head.sha)
@@ -196,7 +196,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
expect(importer.update_repository?(pr)).to eq(true)
end
- it 'returns true when the base SHA is not present' do
+ it "returns true when the base SHA is not present" do
expect(importer)
.to receive(:commit_exists?)
.with(pr.head.sha)
@@ -210,7 +210,7 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
expect(importer.update_repository?(pr)).to eq(true)
end
- it 'returns false if both the head and base SHAs are present' do
+ it "returns false if both the head and base SHAs are present" do
expect(importer)
.to receive(:commit_exists?)
.with(pr.head.sha)
@@ -225,8 +225,8 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- context 'when the pull request was updated before the last update' do
- it 'returns false' do
+ context "when the pull request was updated before the last update" do
+ it "returns false" do
pr = double(:pr, updated_at: 1.year.ago)
allow(project)
@@ -238,30 +238,30 @@ describe Gitlab::GithubImport::Importer::PullRequestsImporter do
end
end
- describe '#commit_exists?' do
+ describe "#commit_exists?" do
let(:importer) { described_class.new(project, client) }
- it 'returns true when a commit exists' do
+ it "returns true when a commit exists" do
expect(project.repository)
.to receive(:commit)
- .with('123')
+ .with("123")
.and_return(double(:commit))
- expect(importer.commit_exists?('123')).to eq(true)
+ expect(importer.commit_exists?("123")).to eq(true)
end
- it 'returns false when a commit does not exist' do
+ it "returns false when a commit does not exist" do
expect(project.repository)
.to receive(:commit)
- .with('123')
+ .with("123")
.and_return(nil)
- expect(importer.commit_exists?('123')).to eq(false)
+ expect(importer.commit_exists?("123")).to eq(false)
end
end
- describe '#id_for_already_imported_cache' do
- it 'returns the PR number of the given PR' do
+ describe "#id_for_already_imported_cache" do
+ it "returns the PR number of the given PR" do
importer = described_class.new(project, client)
expect(importer.id_for_already_imported_cache(pull_request))
diff --git a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
index 23ae026fb14..67ba81505bb 100644
--- a/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/releases_importer_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::ReleasesImporter do
let(:project) { create(:project) }
let(:client) { double(:client) }
let(:importer) { described_class.new(project, client) }
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:release) do
double(
:release,
- tag_name: '1.0',
- body: 'This is my release',
+ tag_name: "1.0",
+ body: "This is my release",
created_at: created_at,
updated_at: updated_at
)
end
- describe '#execute' do
- it 'imports the releases in bulk' do
+ describe "#execute" do
+ it "imports the releases in bulk" do
release_hash = {
- tag_name: '1.0',
- description: 'This is my release',
+ tag_name: "1.0",
+ description: "This is my release",
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(importer).to receive(:build_releases).and_return([release_hash])
@@ -33,93 +33,93 @@ describe Gitlab::GithubImport::Importer::ReleasesImporter do
end
end
- describe '#build_releases' do
- it 'returns an Array containnig release rows' do
+ describe "#build_releases" do
+ it "returns an Array containnig release rows" do
expect(importer).to receive(:each_release).and_return([release])
rows = importer.build_releases
expect(rows.length).to eq(1)
- expect(rows[0][:tag]).to eq('1.0')
+ expect(rows[0][:tag]).to eq("1.0")
end
- it 'does not create releases that already exist' do
- create(:release, project: project, tag: '1.0', description: '1.0')
+ it "does not create releases that already exist" do
+ create(:release, project: project, tag: "1.0", description: "1.0")
expect(importer).to receive(:each_release).and_return([release])
expect(importer.build_releases).to be_empty
end
- it 'uses a default release description if none is provided' do
- expect(release).to receive(:body).and_return('')
+ it "uses a default release description if none is provided" do
+ expect(release).to receive(:body).and_return("")
expect(importer).to receive(:each_release).and_return([release])
release = importer.build_releases.first
- expect(release[:description]).to eq('Release for tag 1.0')
+ expect(release[:description]).to eq("Release for tag 1.0")
end
end
- describe '#build' do
+ describe "#build" do
let(:release_hash) { importer.build(release) }
- it 'returns the attributes of the release as a Hash' do
+ it "returns the attributes of the release as a Hash" do
expect(release_hash).to be_an_instance_of(Hash)
end
- context 'the returned Hash' do
- it 'includes the tag name' do
- expect(release_hash[:tag]).to eq('1.0')
+ context "the returned Hash" do
+ it "includes the tag name" do
+ expect(release_hash[:tag]).to eq("1.0")
end
- it 'includes the release description' do
- expect(release_hash[:description]).to eq('This is my release')
+ it "includes the release description" do
+ expect(release_hash[:description]).to eq("This is my release")
end
- it 'includes the project ID' do
+ it "includes the project ID" do
expect(release_hash[:project_id]).to eq(project.id)
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(release_hash[:created_at]).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(release_hash[:updated_at]).to eq(updated_at)
end
end
end
- describe '#each_release' do
+ describe "#each_release" do
let(:release) { double(:release) }
before do
- allow(project).to receive(:import_source).and_return('foo/bar')
+ allow(project).to receive(:import_source).and_return("foo/bar")
allow(client)
.to receive(:releases)
- .with('foo/bar')
+ .with("foo/bar")
.and_return([release].to_enum)
end
- it 'returns an Enumerator' do
+ it "returns an Enumerator" do
expect(importer.each_release).to be_an_instance_of(Enumerator)
end
- it 'yields every release to the Enumerator' do
+ it "yields every release to the Enumerator" do
expect(importer.each_release.next).to eq(release)
end
end
- describe '#description_for' do
- it 'returns the description when present' do
+ describe "#description_for" do
+ it "returns the description when present" do
expect(importer.description_for(release)).to eq(release.body)
end
- it 'returns a generated description when one is not present' do
- allow(release).to receive(:body).and_return('')
+ it "returns a generated description when one is not present" do
+ allow(release).to receive(:body).and_return("")
- expect(importer.description_for(release)).to eq('Release for tag 1.0')
+ expect(importer.description_for(release)).to eq("Release for tag 1.0")
end
end
end
diff --git a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
index 47233ea6ee2..f1b239b9af7 100644
--- a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Importer::RepositoryImporter do
let(:repository) { double(:repository) }
@@ -8,22 +8,22 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
let(:wiki) do
double(
:wiki,
- disk_path: 'foo.wiki',
- full_path: 'group/foo.wiki'
+ disk_path: "foo.wiki",
+ full_path: "group/foo.wiki"
)
end
let(:project) do
double(
:project,
- import_url: 'foo.git',
- import_source: 'foo/bar',
- repository_storage: 'foo',
- disk_path: 'foo',
+ import_url: "foo.git",
+ import_source: "foo/bar",
+ repository_storage: "foo",
+ disk_path: "foo",
repository: repository,
create_wiki: true,
import_state: import_state,
- full_path: 'group/foo',
+ full_path: "group/foo",
lfs_enabled?: true,
wiki: wiki
)
@@ -39,13 +39,13 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
allow(importer).to receive(:gitlab_shell).and_return(shell_adapter)
end
- describe '#import_wiki?' do
- it 'returns true if the wiki should be imported' do
+ describe "#import_wiki?" do
+ it "returns true if the wiki should be imported" do
repo = double(:repo, has_wiki: true)
expect(client)
.to receive(:repository)
- .with('foo/bar')
+ .with("foo/bar")
.and_return(repo)
expect(project)
@@ -59,23 +59,23 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
expect(importer.import_wiki?).to be(true)
end
- it 'returns false if the GitHub wiki is disabled' do
+ it "returns false if the GitHub wiki is disabled" do
repo = double(:repo, has_wiki: false)
expect(client)
.to receive(:repository)
- .with('foo/bar')
+ .with("foo/bar")
.and_return(repo)
expect(importer.import_wiki?).to eq(false)
end
- it 'returns false if the wiki has already been imported' do
+ it "returns false if the wiki has already been imported" do
repo = double(:repo, has_wiki: true)
expect(client)
.to receive(:repository)
- .with('foo/bar')
+ .with("foo/bar")
.and_return(repo)
expect(project)
@@ -86,8 +86,8 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
end
end
- describe '#execute' do
- it 'imports the repository and wiki' do
+ describe "#execute" do
+ it "imports the repository and wiki" do
expect(project)
.to receive(:empty_repo?)
.and_return(true)
@@ -110,7 +110,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
expect(importer.execute).to eq(true)
end
- it 'does not import the repository if it already exists' do
+ it "does not import the repository if it already exists" do
expect(project)
.to receive(:empty_repo?)
.and_return(false)
@@ -132,7 +132,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
expect(importer.execute).to eq(true)
end
- it 'does not import the wiki if it is disabled' do
+ it "does not import the wiki if it is disabled" do
expect(project)
.to receive(:empty_repo?)
.and_return(true)
@@ -154,7 +154,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
expect(importer.execute).to eq(true)
end
- it 'does not import the wiki if the repository could not be imported' do
+ it "does not import the wiki if the repository could not be imported" do
expect(project)
.to receive(:empty_repo?)
.and_return(true)
@@ -177,19 +177,19 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
end
end
- describe '#import_repository' do
- it 'imports the repository' do
+ describe "#import_repository" do
+ it "imports the repository" do
expect(project)
.to receive(:ensure_repository)
expect(repository)
.to receive(:fetch_as_mirror)
- .with(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true, remote_name: 'github')
+ .with(project.import_url, refmap: Gitlab::GithubImport.refmap, forced: true, remote_name: "github")
expect(importer.import_repository).to eq(true)
end
- it 'marks the import as failed when an error was raised' do
+ it "marks the import as failed when an error was raised" do
expect(project).to receive(:ensure_repository)
.and_raise(Gitlab::Git::Repository::NoRepository)
@@ -201,16 +201,16 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
end
end
- describe '#import_wiki_repository' do
- it 'imports the wiki repository' do
+ describe "#import_wiki_repository" do
+ it "imports the wiki repository" do
expect(importer.gitlab_shell)
.to receive(:import_repository)
- .with('foo', 'foo.wiki', 'foo.wiki.git', 'group/foo.wiki')
+ .with("foo", "foo.wiki", "foo.wiki.git", "group/foo.wiki")
expect(importer.import_wiki_repository).to eq(true)
end
- it 'marks the import as failed and creates an empty repo if an error was raised' do
+ it "marks the import as failed and creates an empty repo if an error was raised" do
expect(importer.gitlab_shell)
.to receive(:import_repository)
.and_raise(Gitlab::Shell::Error)
@@ -226,16 +226,16 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do
end
end
- describe '#fail_import' do
- it 'marks the import as failed' do
- expect(project.import_state).to receive(:mark_as_failed).with('foo')
+ describe "#fail_import" do
+ it "marks the import as failed" do
+ expect(project.import_state).to receive(:mark_as_failed).with("foo")
- expect(importer.fail_import('foo')).to eq(false)
+ expect(importer.fail_import("foo")).to eq(false)
end
end
- describe '#update_clone_time' do
- it 'sets the timestamp for when the cloning process finished' do
+ describe "#update_clone_time" do
+ it "sets the timestamp for when the cloning process finished" do
Timecop.freeze do
expect(project)
.to receive(:update_column)
diff --git a/spec/lib/gitlab/github_import/issuable_finder_spec.rb b/spec/lib/gitlab/github_import/issuable_finder_spec.rb
index da69911812a..5b44ade9b7f 100644
--- a/spec/lib/gitlab/github_import/issuable_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/issuable_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache do
let(:project) { double(:project, id: 4) }
@@ -8,29 +8,29 @@ describe Gitlab::GithubImport::IssuableFinder, :clean_gitlab_redis_cache do
let(:finder) { described_class.new(project, issue) }
- describe '#database_id' do
- it 'returns nil when no cache is in place' do
+ describe "#database_id" do
+ it "returns nil when no cache is in place" do
expect(finder.database_id).to be_nil
end
- it 'returns the ID of an issuable when the cache is in place' do
+ it "returns the ID of an issuable when the cache is in place" do
finder.cache_database_id(10)
expect(finder.database_id).to eq(10)
end
- it 'raises TypeError when the object is not supported' do
+ it "raises TypeError when the object is not supported" do
finder = described_class.new(project, double(:issue))
expect { finder.database_id }.to raise_error(TypeError)
end
end
- describe '#cache_database_id' do
- it 'caches the ID of a database row' do
+ describe "#cache_database_id" do
+ it "caches the ID of a database row" do
expect(Gitlab::GithubImport::Caching)
.to receive(:write)
- .with('github-import/issuable-finder/4/MergeRequest/1', 10)
+ .with("github-import/issuable-finder/4/MergeRequest/1", 10)
finder.cache_database_id(10)
end
diff --git a/spec/lib/gitlab/github_import/label_finder_spec.rb b/spec/lib/gitlab/github_import/label_finder_spec.rb
index 8ba766944d6..6fb44a0f177 100644
--- a/spec/lib/gitlab/github_import/label_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/label_finder_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::LabelFinder, :clean_gitlab_redis_cache do
let(:project) { create(:project) }
let(:finder) { described_class.new(project) }
- let!(:bug) { create(:label, project: project, name: 'Bug') }
- let!(:feature) { create(:label, project: project, name: 'Feature') }
+ let!(:bug) { create(:label, project: project, name: "Bug") }
+ let!(:feature) { create(:label, project: project, name: "Feature") }
- describe '#id_for' do
- context 'with a cache in place' do
+ describe "#id_for" do
+ context "with a cache in place" do
before do
finder.build_cache
end
- it 'returns the ID of the given label' do
+ it "returns the ID of the given label" do
expect(finder.id_for(feature.name)).to eq(feature.id)
end
- it 'returns nil for an empty cache key' do
+ it "returns nil for an empty cache key" do
key = finder.cache_key_for(bug.name)
- Gitlab::GithubImport::Caching.write(key, '')
+ Gitlab::GithubImport::Caching.write(key, "")
expect(finder.id_for(bug.name)).to be_nil
end
- it 'returns nil for a non existing label name' do
- expect(finder.id_for('kittens')).to be_nil
+ it "returns nil for a non existing label name" do
+ expect(finder.id_for("kittens")).to be_nil
end
end
- context 'without a cache in place' do
- it 'returns nil for a label' do
+ context "without a cache in place" do
+ it "returns nil for a label" do
expect(finder.id_for(feature.name)).to be_nil
end
end
end
- describe '#build_cache' do
- it 'builds the cache of all project labels' do
+ describe "#build_cache" do
+ it "builds the cache of all project labels" do
expect(Gitlab::GithubImport::Caching)
.to receive(:write_multiple)
.with(
{
"github-import/label-finder/#{project.id}/Bug" => bug.id,
- "github-import/label-finder/#{project.id}/Feature" => feature.id
+ "github-import/label-finder/#{project.id}/Feature" => feature.id,
}
)
.and_call_original
@@ -52,9 +52,9 @@ describe Gitlab::GithubImport::LabelFinder, :clean_gitlab_redis_cache do
end
end
- describe '#cache_key_for' do
- it 'returns the cache key for a label name' do
- expect(finder.cache_key_for('foo'))
+ describe "#cache_key_for" do
+ it "returns the cache key for a label name" do
+ expect(finder.cache_key_for("foo"))
.to eq("github-import/label-finder/#{project.id}/foo")
end
end
diff --git a/spec/lib/gitlab/github_import/markdown_text_spec.rb b/spec/lib/gitlab/github_import/markdown_text_spec.rb
index 1ff5b9d66b3..5d034e1a9fb 100644
--- a/spec/lib/gitlab/github_import/markdown_text_spec.rb
+++ b/spec/lib/gitlab/github_import/markdown_text_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::MarkdownText do
- describe '.format' do
- it 'formats the text' do
- author = double(:author, login: 'Alice')
- text = described_class.format('Hello', author)
+ describe ".format" do
+ it "formats the text" do
+ author = double(:author, login: "Alice")
+ text = described_class.format("Hello", author)
expect(text).to eq("*Created by: Alice*\n\nHello")
end
end
- describe '#to_s' do
- it 'returns the text when the author was found' do
- author = double(:author, login: 'Alice')
- text = described_class.new('Hello', author, true)
+ describe "#to_s" do
+ it "returns the text when the author was found" do
+ author = double(:author, login: "Alice")
+ text = described_class.new("Hello", author, true)
- expect(text.to_s).to eq('Hello')
+ expect(text.to_s).to eq("Hello")
end
- it 'returns the text with an extra header when the author was not found' do
- author = double(:author, login: 'Alice')
- text = described_class.new('Hello', author)
+ it "returns the text with an extra header when the author was not found" do
+ author = double(:author, login: "Alice")
+ text = described_class.new("Hello", author)
expect(text.to_s).to eq("*Created by: Alice*\n\nHello")
end
diff --git a/spec/lib/gitlab/github_import/milestone_finder_spec.rb b/spec/lib/gitlab/github_import/milestone_finder_spec.rb
index dff931a2fe8..2df1a998cbb 100644
--- a/spec/lib/gitlab/github_import/milestone_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/milestone_finder_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::MilestoneFinder, :clean_gitlab_redis_cache do
let!(:project) { create(:project) }
let!(:milestone) { create(:milestone, project: project) }
let(:finder) { described_class.new(project) }
- describe '#id_for' do
+ describe "#id_for" do
let(:issuable) { double(:issuable, milestone_number: milestone.iid) }
- context 'with a cache in place' do
+ context "with a cache in place" do
before do
finder.build_cache
end
- it 'returns the milestone ID of the given issuable' do
+ it "returns the milestone ID of the given issuable" do
expect(finder.id_for(issuable)).to eq(milestone.id)
end
- it 'returns nil for an empty cache key' do
+ it "returns nil for an empty cache key" do
key = finder.cache_key_for(milestone.iid)
- Gitlab::GithubImport::Caching.write(key, '')
+ Gitlab::GithubImport::Caching.write(key, "")
expect(finder.id_for(issuable)).to be_nil
end
- it 'returns nil for an issuable with a non-existing milestone' do
+ it "returns nil for an issuable with a non-existing milestone" do
expect(finder.id_for(double(:issuable, milestone_number: 5))).to be_nil
end
end
- context 'without a cache in place' do
- it 'returns nil' do
+ context "without a cache in place" do
+ it "returns nil" do
expect(finder.id_for(issuable)).to be_nil
end
end
end
- describe '#build_cache' do
- it 'builds the cache of all project milestones' do
+ describe "#build_cache" do
+ it "builds the cache of all project milestones" do
expect(Gitlab::GithubImport::Caching)
.to receive(:write_multiple)
.with("github-import/milestone-finder/#{project.id}/1" => milestone.id)
@@ -48,8 +48,8 @@ describe Gitlab::GithubImport::MilestoneFinder, :clean_gitlab_redis_cache do
end
end
- describe '#cache_key_for' do
- it 'returns the cache key for an IID' do
+ describe "#cache_key_for" do
+ it "returns the cache key for an IID" do
expect(finder.cache_key_for(10))
.to eq("github-import/milestone-finder/#{project.id}/10")
end
diff --git a/spec/lib/gitlab/github_import/page_counter_spec.rb b/spec/lib/gitlab/github_import/page_counter_spec.rb
index c2613a9a415..ca183a1d741 100644
--- a/spec/lib/gitlab/github_import/page_counter_spec.rb
+++ b/spec/lib/gitlab/github_import/page_counter_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::PageCounter, :clean_gitlab_redis_cache do
let(:project) { double(:project, id: 1) }
let(:counter) { described_class.new(project, :issues) }
- describe '#initialize' do
- it 'sets the initial page number to 1 when no value is cached' do
+ describe "#initialize" do
+ it "sets the initial page number to 1 when no value is cached" do
expect(counter.current).to eq(1)
end
- it 'sets the initial page number to the cached value when one is present' do
+ it "sets the initial page number to the cached value when one is present" do
Gitlab::GithubImport::Caching.write(counter.cache_key, 2)
expect(described_class.new(project, :issues).current).to eq(2)
end
end
- describe '#set' do
- it 'overwrites the page number when the given number is greater than the current number' do
+ describe "#set" do
+ it "overwrites the page number when the given number is greater than the current number" do
counter.set(4)
expect(counter.current).to eq(4)
end
- it 'does not overwrite the page number when the given number is lower than the current number' do
+ it "does not overwrite the page number when the given number is lower than the current number" do
counter.set(2)
counter.set(1)
diff --git a/spec/lib/gitlab/github_import/parallel_importer_spec.rb b/spec/lib/gitlab/github_import/parallel_importer_spec.rb
index f5df38c9aaf..62f1799d4a5 100644
--- a/spec/lib/gitlab/github_import/parallel_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/parallel_importer_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ParallelImporter do
- describe '.async?' do
- it 'returns true' do
+ describe ".async?" do
+ it "returns true" do
expect(described_class).to be_async
end
end
- describe '#execute', :clean_gitlab_redis_shared_state do
+ describe "#execute", :clean_gitlab_redis_shared_state do
let(:project) { create(:project) }
let(:importer) { described_class.new(project) }
@@ -17,14 +17,14 @@ describe Gitlab::GithubImport::ParallelImporter do
expect(Gitlab::GithubImport::Stage::ImportRepositoryWorker)
.to receive(:perform_async)
.with(project.id)
- .and_return('123')
+ .and_return("123")
end
- it 'schedules the importing of the repository' do
+ it "schedules the importing of the repository" do
expect(importer.execute).to eq(true)
end
- it 'sets the JID in Redis' do
+ it "sets the JID in Redis" do
expect(Gitlab::SidekiqStatus)
.to receive(:set)
.with("github-importer/#{project.id}", StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)
@@ -33,7 +33,7 @@ describe Gitlab::GithubImport::ParallelImporter do
importer.execute
end
- it 'updates the import JID of the project' do
+ it "updates the import JID of the project" do
importer.execute
expect(project.import_state.reload.jid).to eq("github-importer/#{project.id}")
diff --git a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
index 98205d3ee25..73d58eed527 100644
--- a/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
+++ b/spec/lib/gitlab/github_import/parallel_scheduling_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ParallelScheduling do
let(:importer_class) do
@@ -11,23 +11,23 @@ describe Gitlab::GithubImport::ParallelScheduling do
end
end
- let(:project) { double(:project, id: 4, import_source: 'foo/bar') }
+ let(:project) { double(:project, id: 4, import_source: "foo/bar") }
let(:client) { double(:client) }
- describe '#parallel?' do
- it 'returns true when running in parallel mode' do
+ describe "#parallel?" do
+ it "returns true when running in parallel mode" do
expect(importer_class.new(project, client)).to be_parallel
end
- it 'returns false when running in sequential mode' do
+ it "returns false when running in sequential mode" do
importer = importer_class.new(project, client, parallel: false)
expect(importer).not_to be_parallel
end
end
- describe '#execute' do
- it 'imports data in parallel when running in parallel mode' do
+ describe "#execute" do
+ it "imports data in parallel when running in parallel mode" do
importer = importer_class.new(project, client)
waiter = double(:waiter)
@@ -39,7 +39,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
.to eq(waiter)
end
- it 'imports data in parallel when running in sequential mode' do
+ it "imports data in parallel when running in sequential mode" do
importer = importer_class.new(project, client, parallel: false)
expect(importer)
@@ -50,7 +50,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
.to eq([])
end
- it 'expires the cache used for tracking already imported objects' do
+ it "expires the cache used for tracking already imported objects" do
importer = importer_class.new(project, client)
expect(importer).to receive(:parallel_import)
@@ -63,10 +63,10 @@ describe Gitlab::GithubImport::ParallelScheduling do
end
end
- describe '#sequential_import' do
+ describe "#sequential_import" do
let(:importer) { importer_class.new(project, client, parallel: false) }
- it 'imports data in sequence' do
+ it "imports data in sequence" do
repr_class = double(:representation_class)
repr_instance = double(:representation_instance)
gh_importer = double(:github_importer)
@@ -102,10 +102,10 @@ describe Gitlab::GithubImport::ParallelScheduling do
end
end
- describe '#parallel_import' do
+ describe "#parallel_import" do
let(:importer) { importer_class.new(project, client) }
- it 'imports data in parallel' do
+ it "imports data in parallel" do
repr_class = double(:representation)
worker_class = double(:worker)
object = double(:object)
@@ -125,33 +125,33 @@ describe Gitlab::GithubImport::ParallelScheduling do
expect(repr_class)
.to receive(:from_api_response)
.with(object)
- .and_return({ title: 'Foo' })
+ .and_return({title: "Foo"})
expect(worker_class)
.to receive(:perform_async)
- .with(project.id, { title: 'Foo' }, an_instance_of(String))
+ .with(project.id, {title: "Foo"}, an_instance_of(String))
expect(importer.parallel_import)
.to be_an_instance_of(Gitlab::JobWaiter)
end
end
- describe '#each_object_to_import' do
+ describe "#each_object_to_import" do
let(:importer) { importer_class.new(project, client) }
let(:object) { double(:object) }
before do
expect(importer)
.to receive(:collection_options)
- .and_return({ state: 'all' })
+ .and_return({state: "all"})
end
- it 'yields every object to import' do
+ it "yields every object to import" do
page = double(:page, objects: [object], number: 1)
expect(client)
.to receive(:each_page)
- .with(:issues, 'foo/bar', { state: 'all', page: 1 })
+ .with(:issues, "foo/bar", {state: "all", page: 1})
.and_yield(page)
expect(importer.page_counter)
@@ -172,7 +172,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
.to yield_with_args(object)
end
- it 'resumes from the last page' do
+ it "resumes from the last page" do
page = double(:page, objects: [object], number: 2)
expect(importer.page_counter)
@@ -181,7 +181,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
expect(client)
.to receive(:each_page)
- .with(:issues, 'foo/bar', { state: 'all', page: 2 })
+ .with(:issues, "foo/bar", {state: "all", page: 2})
.and_yield(page)
expect(importer.page_counter)
@@ -202,12 +202,12 @@ describe Gitlab::GithubImport::ParallelScheduling do
.to yield_with_args(object)
end
- it 'does not yield any objects if the page number was not set' do
+ it "does not yield any objects if the page number was not set" do
page = double(:page, objects: [object], number: 1)
expect(client)
.to receive(:each_page)
- .with(:issues, 'foo/bar', { state: 'all', page: 1 })
+ .with(:issues, "foo/bar", {state: "all", page: 1})
.and_yield(page)
expect(importer.page_counter)
@@ -219,12 +219,12 @@ describe Gitlab::GithubImport::ParallelScheduling do
.not_to yield_control
end
- it 'does not yield the object if it was already imported' do
+ it "does not yield the object if it was already imported" do
page = double(:page, objects: [object], number: 1)
expect(client)
.to receive(:each_page)
- .with(:issues, 'foo/bar', { state: 'all', page: 1 })
+ .with(:issues, "foo/bar", {state: "all", page: 1})
.and_yield(page)
expect(importer.page_counter)
@@ -245,10 +245,10 @@ describe Gitlab::GithubImport::ParallelScheduling do
end
end
- describe '#already_imported?', :clean_gitlab_redis_cache do
+ describe "#already_imported?", :clean_gitlab_redis_cache do
let(:importer) { importer_class.new(project, client) }
- it 'returns false when an object has not yet been imported' do
+ it "returns false when an object has not yet been imported" do
object = double(:object, id: 10)
expect(importer)
@@ -260,7 +260,7 @@ describe Gitlab::GithubImport::ParallelScheduling do
.to eq(false)
end
- it 'returns true when an object has already been imported' do
+ it "returns true when an object has already been imported" do
object = double(:object, id: 10)
allow(importer)
@@ -275,8 +275,8 @@ describe Gitlab::GithubImport::ParallelScheduling do
end
end
- describe '#mark_as_imported', :clean_gitlab_redis_cache do
- it 'marks an object as already imported' do
+ describe "#mark_as_imported", :clean_gitlab_redis_cache do
+ it "marks an object as already imported" do
object = double(:object, id: 10)
importer = importer_class.new(project, client)
diff --git a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
index 7b0a1ea4948..36c9c059d5b 100644
--- a/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/diff_note_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::DiffNote do
let(:hunk) do
@@ -7,78 +7,78 @@ describe Gitlab::GithubImport::Representation::DiffNote do
+Hello world'
end
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
- shared_examples 'a DiffNote' do
- it 'returns an instance of DiffNote' do
+ shared_examples "a DiffNote" do
+ it "returns an instance of DiffNote" do
expect(note).to be_an_instance_of(described_class)
end
- context 'the returned DiffNote' do
- it 'includes the number of the note' do
+ context "the returned DiffNote" do
+ it "includes the number of the note" do
expect(note.noteable_id).to eq(42)
end
- it 'includes the file path of the diff' do
- expect(note.file_path).to eq('README.md')
+ it "includes the file path of the diff" do
+ expect(note.file_path).to eq("README.md")
end
- it 'includes the commit ID' do
- expect(note.commit_id).to eq('123abc')
+ it "includes the commit ID" do
+ expect(note.commit_id).to eq("123abc")
end
- it 'includes the user details' do
+ it "includes the user details" do
expect(note.author)
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(note.author.id).to eq(4)
- expect(note.author.login).to eq('alice')
+ expect(note.author.login).to eq("alice")
end
- it 'includes the note body' do
- expect(note.note).to eq('Hello world')
+ it "includes the note body" do
+ expect(note.note).to eq("Hello world")
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(note.created_at).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(note.updated_at).to eq(updated_at)
end
- it 'includes the GitHub ID' do
+ it "includes the GitHub ID" do
expect(note.github_id).to eq(1)
end
- it 'returns the noteable type' do
- expect(note.noteable_type).to eq('MergeRequest')
+ it "returns the noteable type" do
+ expect(note.noteable_type).to eq("MergeRequest")
end
end
end
- describe '.from_api_response' do
+ describe ".from_api_response" do
let(:response) do
double(
:response,
- html_url: 'https://github.com/foo/bar/pull/42',
- path: 'README.md',
- commit_id: '123abc',
+ html_url: "https://github.com/foo/bar/pull/42",
+ path: "README.md",
+ commit_id: "123abc",
diff_hunk: hunk,
- user: double(:user, id: 4, login: 'alice'),
- body: 'Hello world',
+ user: double(:user, id: 4, login: "alice"),
+ body: "Hello world",
created_at: created_at,
updated_at: updated_at,
id: 1
)
end
- it_behaves_like 'a DiffNote' do
+ it_behaves_like "a DiffNote" do
let(:note) { described_class.from_api_response(response) }
end
- it 'does not set the user if the response did not include a user' do
+ it "does not set the user if the response did not include a user" do
allow(response)
.to receive(:user)
.and_return(nil)
@@ -89,37 +89,37 @@ describe Gitlab::GithubImport::Representation::DiffNote do
end
end
- describe '.from_json_hash' do
- it_behaves_like 'a DiffNote' do
+ describe ".from_json_hash" do
+ it_behaves_like "a DiffNote" do
let(:hash) do
{
- 'noteable_type' => 'MergeRequest',
- 'noteable_id' => 42,
- 'file_path' => 'README.md',
- 'commit_id' => '123abc',
- 'diff_hunk' => hunk,
- 'author' => { 'id' => 4, 'login' => 'alice' },
- 'note' => 'Hello world',
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'github_id' => 1
+ "noteable_type" => "MergeRequest",
+ "noteable_id" => 42,
+ "file_path" => "README.md",
+ "commit_id" => "123abc",
+ "diff_hunk" => hunk,
+ "author" => {"id" => 4, "login" => "alice"},
+ "note" => "Hello world",
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "github_id" => 1,
}
end
let(:note) { described_class.from_json_hash(hash) }
end
- it 'does not convert the author if it was not specified' do
+ it "does not convert the author if it was not specified" do
hash = {
- 'noteable_type' => 'MergeRequest',
- 'noteable_id' => 42,
- 'file_path' => 'README.md',
- 'commit_id' => '123abc',
- 'diff_hunk' => hunk,
- 'note' => 'Hello world',
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'github_id' => 1
+ "noteable_type" => "MergeRequest",
+ "noteable_id" => 42,
+ "file_path" => "README.md",
+ "commit_id" => "123abc",
+ "diff_hunk" => hunk,
+ "note" => "Hello world",
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "github_id" => 1,
}
note = described_class.from_json_hash(hash)
@@ -128,35 +128,35 @@ describe Gitlab::GithubImport::Representation::DiffNote do
end
end
- describe '#line_code' do
- it 'returns a String' do
- note = described_class.new(diff_hunk: hunk, file_path: 'README.md')
+ describe "#line_code" do
+ it "returns a String" do
+ note = described_class.new(diff_hunk: hunk, file_path: "README.md")
expect(note.line_code).to be_an_instance_of(String)
end
end
- describe '#diff_hash' do
- it 'returns a Hash containing the diff details' do
+ describe "#diff_hash" do
+ it "returns a Hash containing the diff details" do
note = described_class.from_json_hash(
- 'noteable_type' => 'MergeRequest',
- 'noteable_id' => 42,
- 'file_path' => 'README.md',
- 'commit_id' => '123abc',
- 'diff_hunk' => hunk,
- 'author' => { 'id' => 4, 'login' => 'alice' },
- 'note' => 'Hello world',
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'github_id' => 1
+ "noteable_type" => "MergeRequest",
+ "noteable_id" => 42,
+ "file_path" => "README.md",
+ "commit_id" => "123abc",
+ "diff_hunk" => hunk,
+ "author" => {"id" => 4, "login" => "alice"},
+ "note" => "Hello world",
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "github_id" => 1
)
expect(note.diff_hash).to eq(
diff: hunk,
- new_path: 'README.md',
- old_path: 'README.md',
- a_mode: '100644',
- b_mode: '100644',
+ new_path: "README.md",
+ old_path: "README.md",
+ a_mode: "100644",
+ b_mode: "100644",
new_file: false
)
end
diff --git a/spec/lib/gitlab/github_import/representation/expose_attribute_spec.rb b/spec/lib/gitlab/github_import/representation/expose_attribute_spec.rb
index 15de0fe49ff..ea2af8a3207 100644
--- a/spec/lib/gitlab/github_import/representation/expose_attribute_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/expose_attribute_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::ExposeAttribute do
- it 'defines a getter method that returns an attribute value' do
- klass = Class.new do
+ it "defines a getter method that returns an attribute value" do
+ klass = Class.new {
include Gitlab::GithubImport::Representation::ExposeAttribute
expose_attribute :number
@@ -10,9 +10,9 @@ describe Gitlab::GithubImport::Representation::ExposeAttribute do
attr_reader :attributes
def initialize
- @attributes = { number: 42 }
+ @attributes = {number: 42}
end
- end
+ }
expect(klass.new.number).to eq(42)
end
diff --git a/spec/lib/gitlab/github_import/representation/issue_spec.rb b/spec/lib/gitlab/github_import/representation/issue_spec.rb
index 99330ce42cb..6f6eee350c1 100644
--- a/spec/lib/gitlab/github_import/representation/issue_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/issue_spec.rb
@@ -1,92 +1,92 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::Issue do
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
- shared_examples 'an Issue' do
- it 'returns an instance of Issue' do
+ shared_examples "an Issue" do
+ it "returns an instance of Issue" do
expect(issue).to be_an_instance_of(described_class)
end
- context 'the returned Issue' do
- it 'includes the issue number' do
+ context "the returned Issue" do
+ it "includes the issue number" do
expect(issue.iid).to eq(42)
end
- it 'includes the issue title' do
- expect(issue.title).to eq('My Issue')
+ it "includes the issue title" do
+ expect(issue.title).to eq("My Issue")
end
- it 'includes the issue description' do
- expect(issue.description).to eq('This is my issue')
+ it "includes the issue description" do
+ expect(issue.description).to eq("This is my issue")
end
- it 'includes the milestone number' do
+ it "includes the milestone number" do
expect(issue.milestone_number).to eq(4)
end
- it 'includes the issue state' do
+ it "includes the issue state" do
expect(issue.state).to eq(:opened)
end
- it 'includes the issue assignees' do
+ it "includes the issue assignees" do
expect(issue.assignees[0])
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(issue.assignees[0].id).to eq(4)
- expect(issue.assignees[0].login).to eq('alice')
+ expect(issue.assignees[0].login).to eq("alice")
end
- it 'includes the label names' do
+ it "includes the label names" do
expect(issue.label_names).to eq(%w[bug])
end
- it 'includes the author details' do
+ it "includes the author details" do
expect(issue.author)
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(issue.author.id).to eq(4)
- expect(issue.author.login).to eq('alice')
+ expect(issue.author.login).to eq("alice")
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(issue.created_at).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(issue.updated_at).to eq(updated_at)
end
- it 'is not a pull request' do
+ it "is not a pull request" do
expect(issue.pull_request?).to eq(false)
end
end
end
- describe '.from_api_response' do
+ describe ".from_api_response" do
let(:response) do
double(
:response,
number: 42,
- title: 'My Issue',
- body: 'This is my issue',
+ title: "My Issue",
+ body: "This is my issue",
milestone: double(:milestone, number: 4),
- state: 'open',
- assignees: [double(:user, id: 4, login: 'alice')],
- labels: [double(:label, name: 'bug')],
- user: double(:user, id: 4, login: 'alice'),
+ state: "open",
+ assignees: [double(:user, id: 4, login: "alice")],
+ labels: [double(:label, name: "bug")],
+ user: double(:user, id: 4, login: "alice"),
created_at: created_at,
updated_at: updated_at,
pull_request: false
)
end
- it_behaves_like 'an Issue' do
+ it_behaves_like "an Issue" do
let(:issue) { described_class.from_api_response(response) }
end
- it 'does not set the user if the response did not include a user' do
+ it "does not set the user if the response did not include a user" do
allow(response)
.to receive(:user)
.and_return(nil)
@@ -97,39 +97,39 @@ describe Gitlab::GithubImport::Representation::Issue do
end
end
- describe '.from_json_hash' do
- it_behaves_like 'an Issue' do
+ describe ".from_json_hash" do
+ it_behaves_like "an Issue" do
let(:hash) do
{
- 'iid' => 42,
- 'title' => 'My Issue',
- 'description' => 'This is my issue',
- 'milestone_number' => 4,
- 'state' => 'opened',
- 'assignees' => [{ 'id' => 4, 'login' => 'alice' }],
- 'label_names' => %w[bug],
- 'author' => { 'id' => 4, 'login' => 'alice' },
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'pull_request' => false
+ "iid" => 42,
+ "title" => "My Issue",
+ "description" => "This is my issue",
+ "milestone_number" => 4,
+ "state" => "opened",
+ "assignees" => [{"id" => 4, "login" => "alice"}],
+ "label_names" => %w[bug],
+ "author" => {"id" => 4, "login" => "alice"},
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "pull_request" => false,
}
end
let(:issue) { described_class.from_json_hash(hash) }
end
- it 'does not convert the author if it was not specified' do
+ it "does not convert the author if it was not specified" do
hash = {
- 'iid' => 42,
- 'title' => 'My Issue',
- 'description' => 'This is my issue',
- 'milestone_number' => 4,
- 'state' => 'opened',
- 'assignees' => [{ 'id' => 4, 'login' => 'alice' }],
- 'label_names' => %w[bug],
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'pull_request' => false
+ "iid" => 42,
+ "title" => "My Issue",
+ "description" => "This is my issue",
+ "milestone_number" => 4,
+ "state" => "opened",
+ "assignees" => [{"id" => 4, "login" => "alice"}],
+ "label_names" => %w[bug],
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "pull_request" => false,
}
issue = described_class.from_json_hash(hash)
@@ -138,45 +138,45 @@ describe Gitlab::GithubImport::Representation::Issue do
end
end
- describe '#labels?' do
- it 'returns true when the issue has labels assigned' do
+ describe "#labels?" do
+ it "returns true when the issue has labels assigned" do
issue = described_class.new(label_names: %w[bug])
expect(issue.labels?).to eq(true)
end
- it 'returns false when the issue has no labels assigned' do
+ it "returns false when the issue has no labels assigned" do
issue = described_class.new(label_names: [])
expect(issue.labels?).to eq(false)
end
end
- describe '#pull_request?' do
- it 'returns false for an issue' do
+ describe "#pull_request?" do
+ it "returns false for an issue" do
issue = described_class.new(pull_request: false)
expect(issue.pull_request?).to eq(false)
end
- it 'returns true for a pull request' do
+ it "returns true for a pull request" do
issue = described_class.new(pull_request: true)
expect(issue.pull_request?).to eq(true)
end
end
- describe '#truncated_title' do
- it 'truncates the title to 255 characters' do
- object = described_class.new(title: 'm' * 300)
+ describe "#truncated_title" do
+ it "truncates the title to 255 characters" do
+ object = described_class.new(title: "m" * 300)
expect(object.truncated_title.length).to eq(255)
end
- it 'does not truncate the title if it is shorter than 255 characters' do
- object = described_class.new(title: 'foo')
+ it "does not truncate the title if it is shorter than 255 characters" do
+ object = described_class.new(title: "foo")
- expect(object.truncated_title).to eq('foo')
+ expect(object.truncated_title).to eq("foo")
end
end
end
diff --git a/spec/lib/gitlab/github_import/representation/note_spec.rb b/spec/lib/gitlab/github_import/representation/note_spec.rb
index f2c1c66b357..6f8e179566a 100644
--- a/spec/lib/gitlab/github_import/representation/note_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/note_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::Note do
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
- shared_examples 'a Note' do
- it 'returns an instance of Note' do
+ shared_examples "a Note" do
+ it "returns an instance of Note" do
expect(note).to be_an_instance_of(described_class)
end
- context 'the returned Note' do
- it 'includes the noteable ID' do
+ context "the returned Note" do
+ it "includes the noteable ID" do
expect(note.noteable_id).to eq(42)
end
- it 'includes the noteable type' do
- expect(note.noteable_type).to eq('Issue')
+ it "includes the noteable type" do
+ expect(note.noteable_type).to eq("Issue")
end
- it 'includes the author details' do
+ it "includes the author details" do
expect(note.author)
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(note.author.id).to eq(4)
- expect(note.author.login).to eq('alice')
+ expect(note.author.login).to eq("alice")
end
- it 'includes the note body' do
- expect(note.note).to eq('Hello world')
+ it "includes the note body" do
+ expect(note.note).to eq("Hello world")
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(note.created_at).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(note.updated_at).to eq(updated_at)
end
- it 'includes the GitHub ID' do
+ it "includes the GitHub ID" do
expect(note.github_id).to eq(1)
end
end
end
- describe '.from_api_response' do
+ describe ".from_api_response" do
let(:response) do
double(
:response,
- html_url: 'https://github.com/foo/bar/issues/42',
- user: double(:user, id: 4, login: 'alice'),
- body: 'Hello world',
+ html_url: "https://github.com/foo/bar/issues/42",
+ user: double(:user, id: 4, login: "alice"),
+ body: "Hello world",
created_at: created_at,
updated_at: updated_at,
id: 1
)
end
- it_behaves_like 'a Note' do
+ it_behaves_like "a Note" do
let(:note) { described_class.from_api_response(response) }
end
- it 'does not set the user if the response did not include a user' do
+ it "does not set the user if the response did not include a user" do
allow(response)
.to receive(:user)
.and_return(nil)
@@ -72,31 +72,31 @@ describe Gitlab::GithubImport::Representation::Note do
end
end
- describe '.from_json_hash' do
- it_behaves_like 'a Note' do
+ describe ".from_json_hash" do
+ it_behaves_like "a Note" do
let(:hash) do
{
- 'noteable_id' => 42,
- 'noteable_type' => 'Issue',
- 'author' => { 'id' => 4, 'login' => 'alice' },
- 'note' => 'Hello world',
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'github_id' => 1
+ "noteable_id" => 42,
+ "noteable_type" => "Issue",
+ "author" => {"id" => 4, "login" => "alice"},
+ "note" => "Hello world",
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "github_id" => 1,
}
end
let(:note) { described_class.from_json_hash(hash) }
end
- it 'does not convert the author if it was not specified' do
+ it "does not convert the author if it was not specified" do
hash = {
- 'noteable_id' => 42,
- 'noteable_type' => 'Issue',
- 'note' => 'Hello world',
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'github_id' => 1
+ "noteable_id" => 42,
+ "noteable_type" => "Issue",
+ "note" => "Hello world",
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "github_id" => 1,
}
note = described_class.from_json_hash(hash)
diff --git a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
index d478e5ae899..4b85181aa8d 100644
--- a/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/pull_request_spec.rb
@@ -1,129 +1,129 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::PullRequest do
- let(:created_at) { Time.new(2017, 1, 1, 12, 00) }
+ let(:created_at) { Time.new(2017, 1, 1, 12, 0o0) }
let(:updated_at) { Time.new(2017, 1, 1, 12, 15) }
let(:merged_at) { Time.new(2017, 1, 1, 12, 17) }
- shared_examples 'a PullRequest' do
- it 'returns an instance of PullRequest' do
+ shared_examples "a PullRequest" do
+ it "returns an instance of PullRequest" do
expect(pr).to be_an_instance_of(described_class)
end
- context 'the returned PullRequest' do
- it 'includes the pull request number' do
+ context "the returned PullRequest" do
+ it "includes the pull request number" do
expect(pr.iid).to eq(42)
end
- it 'includes the pull request title' do
- expect(pr.title).to eq('My Pull Request')
+ it "includes the pull request title" do
+ expect(pr.title).to eq("My Pull Request")
end
- it 'includes the pull request description' do
- expect(pr.description).to eq('This is my pull request')
+ it "includes the pull request description" do
+ expect(pr.description).to eq("This is my pull request")
end
- it 'includes the source branch name' do
- expect(pr.source_branch).to eq('my-feature')
+ it "includes the source branch name" do
+ expect(pr.source_branch).to eq("my-feature")
end
- it 'includes the source branch SHA' do
- expect(pr.source_branch_sha).to eq('123abc')
+ it "includes the source branch SHA" do
+ expect(pr.source_branch_sha).to eq("123abc")
end
- it 'includes the target branch name' do
- expect(pr.target_branch).to eq('master')
+ it "includes the target branch name" do
+ expect(pr.target_branch).to eq("master")
end
- it 'includes the target branch SHA' do
- expect(pr.target_branch_sha).to eq('456def')
+ it "includes the target branch SHA" do
+ expect(pr.target_branch_sha).to eq("456def")
end
- it 'includes the milestone number' do
+ it "includes the milestone number" do
expect(pr.milestone_number).to eq(4)
end
- it 'includes the user details' do
+ it "includes the user details" do
expect(pr.author)
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(pr.author.id).to eq(4)
- expect(pr.author.login).to eq('alice')
+ expect(pr.author.login).to eq("alice")
end
- it 'includes the assignee details' do
+ it "includes the assignee details" do
expect(pr.assignee)
.to be_an_instance_of(Gitlab::GithubImport::Representation::User)
expect(pr.assignee.id).to eq(4)
- expect(pr.assignee.login).to eq('alice')
+ expect(pr.assignee.login).to eq("alice")
end
- it 'includes the created timestamp' do
+ it "includes the created timestamp" do
expect(pr.created_at).to eq(created_at)
end
- it 'includes the updated timestamp' do
+ it "includes the updated timestamp" do
expect(pr.updated_at).to eq(updated_at)
end
- it 'includes the merged timestamp' do
+ it "includes the merged timestamp" do
expect(pr.merged_at).to eq(merged_at)
end
- it 'includes the source repository ID' do
+ it "includes the source repository ID" do
expect(pr.source_repository_id).to eq(400)
end
- it 'includes the target repository ID' do
+ it "includes the target repository ID" do
expect(pr.target_repository_id).to eq(200)
end
- it 'includes the source repository owner name' do
- expect(pr.source_repository_owner).to eq('alice')
+ it "includes the source repository owner name" do
+ expect(pr.source_repository_owner).to eq("alice")
end
- it 'includes the pull request state' do
+ it "includes the pull request state" do
expect(pr.state).to eq(:merged)
end
end
end
- describe '.from_api_response' do
+ describe ".from_api_response" do
let(:response) do
double(
:response,
number: 42,
- title: 'My Pull Request',
- body: 'This is my pull request',
- state: 'closed',
+ title: "My Pull Request",
+ body: "This is my pull request",
+ state: "closed",
head: double(
:head,
- sha: '123abc',
- ref: 'my-feature',
+ sha: "123abc",
+ ref: "my-feature",
repo: double(:repo, id: 400),
- user: double(:user, id: 4, login: 'alice')
+ user: double(:user, id: 4, login: "alice")
),
base: double(
:base,
- sha: '456def',
- ref: 'master',
+ sha: "456def",
+ ref: "master",
repo: double(:repo, id: 200)
),
milestone: double(:milestone, number: 4),
- user: double(:user, id: 4, login: 'alice'),
- assignee: double(:user, id: 4, login: 'alice'),
+ user: double(:user, id: 4, login: "alice"),
+ assignee: double(:user, id: 4, login: "alice"),
created_at: created_at,
updated_at: updated_at,
merged_at: merged_at
)
end
- it_behaves_like 'a PullRequest' do
+ it_behaves_like "a PullRequest" do
let(:pr) { described_class.from_api_response(response) }
end
- it 'does not set the user if the response did not include a user' do
+ it "does not set the user if the response did not include a user" do
allow(response)
.to receive(:user)
.and_return(nil)
@@ -134,51 +134,51 @@ describe Gitlab::GithubImport::Representation::PullRequest do
end
end
- describe '.from_json_hash' do
- it_behaves_like 'a PullRequest' do
+ describe ".from_json_hash" do
+ it_behaves_like "a PullRequest" do
let(:hash) do
{
- 'iid' => 42,
- 'title' => 'My Pull Request',
- 'description' => 'This is my pull request',
- 'source_branch' => 'my-feature',
- 'source_branch_sha' => '123abc',
- 'target_branch' => 'master',
- 'target_branch_sha' => '456def',
- 'source_repository_id' => 400,
- 'target_repository_id' => 200,
- 'source_repository_owner' => 'alice',
- 'state' => 'closed',
- 'milestone_number' => 4,
- 'author' => { 'id' => 4, 'login' => 'alice' },
- 'assignee' => { 'id' => 4, 'login' => 'alice' },
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'merged_at' => merged_at.to_s
+ "iid" => 42,
+ "title" => "My Pull Request",
+ "description" => "This is my pull request",
+ "source_branch" => "my-feature",
+ "source_branch_sha" => "123abc",
+ "target_branch" => "master",
+ "target_branch_sha" => "456def",
+ "source_repository_id" => 400,
+ "target_repository_id" => 200,
+ "source_repository_owner" => "alice",
+ "state" => "closed",
+ "milestone_number" => 4,
+ "author" => {"id" => 4, "login" => "alice"},
+ "assignee" => {"id" => 4, "login" => "alice"},
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "merged_at" => merged_at.to_s,
}
end
let(:pr) { described_class.from_json_hash(hash) }
end
- it 'does not convert the author if it was not specified' do
+ it "does not convert the author if it was not specified" do
hash = {
- 'iid' => 42,
- 'title' => 'My Pull Request',
- 'description' => 'This is my pull request',
- 'source_branch' => 'my-feature',
- 'source_branch_sha' => '123abc',
- 'target_branch' => 'master',
- 'target_branch_sha' => '456def',
- 'source_repository_id' => 400,
- 'target_repository_id' => 200,
- 'source_repository_owner' => 'alice',
- 'state' => 'closed',
- 'milestone_number' => 4,
- 'assignee' => { 'id' => 4, 'login' => 'alice' },
- 'created_at' => created_at.to_s,
- 'updated_at' => updated_at.to_s,
- 'merged_at' => merged_at.to_s
+ "iid" => 42,
+ "title" => "My Pull Request",
+ "description" => "This is my pull request",
+ "source_branch" => "my-feature",
+ "source_branch_sha" => "123abc",
+ "target_branch" => "master",
+ "target_branch_sha" => "456def",
+ "source_repository_id" => 400,
+ "target_repository_id" => 200,
+ "source_repository_owner" => "alice",
+ "state" => "closed",
+ "milestone_number" => 4,
+ "assignee" => {"id" => 4, "login" => "alice"},
+ "created_at" => created_at.to_s,
+ "updated_at" => updated_at.to_s,
+ "merged_at" => merged_at.to_s,
}
pr = described_class.from_json_hash(hash)
@@ -187,102 +187,102 @@ describe Gitlab::GithubImport::Representation::PullRequest do
end
end
- describe '#state' do
- it 'returns :opened for an open pull request' do
+ describe "#state" do
+ it "returns :opened for an open pull request" do
pr = described_class.new(state: :opened)
expect(pr.state).to eq(:opened)
end
- it 'returns :closed for a closed pull request' do
+ it "returns :closed for a closed pull request" do
pr = described_class.new(state: :closed)
expect(pr.state).to eq(:closed)
end
- it 'returns :merged for a merged pull request' do
+ it "returns :merged for a merged pull request" do
pr = described_class.new(state: :closed, merged_at: merged_at)
expect(pr.state).to eq(:merged)
end
end
- describe '#cross_project?' do
- it 'returns false for a pull request submitted from the target project' do
+ describe "#cross_project?" do
+ it "returns false for a pull request submitted from the target project" do
pr = described_class.new(source_repository_id: 1, target_repository_id: 1)
expect(pr).not_to be_cross_project
end
- it 'returns true for a pull request submitted from a different project' do
+ it "returns true for a pull request submitted from a different project" do
pr = described_class.new(source_repository_id: 1, target_repository_id: 2)
expect(pr).to be_cross_project
end
- it 'returns true if no source repository is present' do
+ it "returns true if no source repository is present" do
pr = described_class.new(target_repository_id: 2)
expect(pr).to be_cross_project
end
end
- describe '#formatted_source_branch' do
- context 'for a cross-project pull request' do
- it 'includes the owner name in the branch name' do
+ describe "#formatted_source_branch" do
+ context "for a cross-project pull request" do
+ it "includes the owner name in the branch name" do
pr = described_class.new(
- source_repository_owner: 'foo',
- source_branch: 'branch',
- target_branch: 'master',
+ source_repository_owner: "foo",
+ source_branch: "branch",
+ target_branch: "master",
source_repository_id: 1,
target_repository_id: 2
)
- expect(pr.formatted_source_branch).to eq('github/fork/foo/branch')
+ expect(pr.formatted_source_branch).to eq("github/fork/foo/branch")
end
end
- context 'for a regular pull request' do
- it 'returns the source branch name' do
+ context "for a regular pull request" do
+ it "returns the source branch name" do
pr = described_class.new(
- source_repository_owner: 'foo',
- source_branch: 'branch',
- target_branch: 'master',
+ source_repository_owner: "foo",
+ source_branch: "branch",
+ target_branch: "master",
source_repository_id: 1,
target_repository_id: 1
)
- expect(pr.formatted_source_branch).to eq('branch')
+ expect(pr.formatted_source_branch).to eq("branch")
end
end
- context 'for a pull request with the same source and target branches' do
- it 'returns a generated source branch name' do
+ context "for a pull request with the same source and target branches" do
+ it "returns a generated source branch name" do
pr = described_class.new(
iid: 1,
- source_repository_owner: 'foo',
- source_branch: 'branch',
- target_branch: 'branch',
+ source_repository_owner: "foo",
+ source_branch: "branch",
+ target_branch: "branch",
source_repository_id: 1,
target_repository_id: 1
)
- expect(pr.formatted_source_branch).to eq('branch-1')
+ expect(pr.formatted_source_branch).to eq("branch-1")
end
end
end
- describe '#truncated_title' do
- it 'truncates the title to 255 characters' do
- object = described_class.new(title: 'm' * 300)
+ describe "#truncated_title" do
+ it "truncates the title to 255 characters" do
+ object = described_class.new(title: "m" * 300)
expect(object.truncated_title.length).to eq(255)
end
- it 'does not truncate the title if it is shorter than 255 characters' do
- object = described_class.new(title: 'foo')
+ it "does not truncate the title if it is shorter than 255 characters" do
+ object = described_class.new(title: "foo")
- expect(object.truncated_title).to eq('foo')
+ expect(object.truncated_title).to eq("foo")
end
end
end
diff --git a/spec/lib/gitlab/github_import/representation/to_hash_spec.rb b/spec/lib/gitlab/github_import/representation/to_hash_spec.rb
index c296aa0a45b..b55ee43e5ee 100644
--- a/spec/lib/gitlab/github_import/representation/to_hash_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/to_hash_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::ToHash do
- describe '#to_hash' do
- let(:user) { double(:user, attributes: { login: 'alice' }) }
+ describe "#to_hash" do
+ let(:user) { double(:user, attributes: {login: "alice"}) }
let(:issue) do
double(
:issue,
- attributes: { user: user, assignees: [user], number: 42 }
+ attributes: {user: user, assignees: [user], number: 42}
)
end
@@ -18,19 +18,19 @@ describe Gitlab::GithubImport::Representation::ToHash do
issue.extend(described_class)
end
- it 'converts an object to a Hash' do
+ it "converts an object to a Hash" do
expect(issue_hash).to be_an_instance_of(Hash)
end
- it 'converts nested objects to Hashes' do
- expect(issue_hash[:user]).to eq({ login: 'alice' })
+ it "converts nested objects to Hashes" do
+ expect(issue_hash[:user]).to eq({login: "alice"})
end
- it 'converts Array values to Hashes' do
- expect(issue_hash[:assignees]).to eq([{ login: 'alice' }])
+ it "converts Array values to Hashes" do
+ expect(issue_hash[:assignees]).to eq([{login: "alice"}])
end
- it 'keeps values as-is if they do not respond to #to_hash' do
+ it "keeps values as-is if they do not respond to #to_hash" do
expect(issue_hash[:number]).to eq(42)
end
end
diff --git a/spec/lib/gitlab/github_import/representation/user_spec.rb b/spec/lib/gitlab/github_import/representation/user_spec.rb
index 4e63e8ea568..9a059a3ce84 100644
--- a/spec/lib/gitlab/github_import/representation/user_spec.rb
+++ b/spec/lib/gitlab/github_import/representation/user_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation::User do
- shared_examples 'a User' do
- it 'returns an instance of User' do
+ shared_examples "a User" do
+ it "returns an instance of User" do
expect(user).to be_an_instance_of(described_class)
end
- context 'the returned User' do
- it 'includes the user ID' do
+ context "the returned User" do
+ it "includes the user ID" do
expect(user.id).to eq(42)
end
- it 'includes the username' do
- expect(user.login).to eq('alice')
+ it "includes the username" do
+ expect(user.login).to eq("alice")
end
end
end
- describe '.from_api_response' do
- it_behaves_like 'a User' do
- let(:response) { double(:response, id: 42, login: 'alice') }
+ describe ".from_api_response" do
+ it_behaves_like "a User" do
+ let(:response) { double(:response, id: 42, login: "alice") }
let(:user) { described_class.from_api_response(response) }
end
end
- describe '.from_json_hash' do
- it_behaves_like 'a User' do
- let(:hash) { { 'id' => 42, 'login' => 'alice' } }
+ describe ".from_json_hash" do
+ it_behaves_like "a User" do
+ let(:hash) { {"id" => 42, "login" => "alice"} }
let(:user) { described_class.from_json_hash(hash) }
end
end
diff --git a/spec/lib/gitlab/github_import/representation_spec.rb b/spec/lib/gitlab/github_import/representation_spec.rb
index 0b0610817b0..0586b94044d 100644
--- a/spec/lib/gitlab/github_import/representation_spec.rb
+++ b/spec/lib/gitlab/github_import/representation_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Representation do
- describe '.symbolize_hash' do
- it 'returns a Hash with the keys as Symbols' do
- hash = described_class.symbolize_hash('number' => 10)
+ describe ".symbolize_hash" do
+ it "returns a Hash with the keys as Symbols" do
+ hash = described_class.symbolize_hash("number" => 10)
- expect(hash).to eq({ number: 10 })
+ expect(hash).to eq({number: 10})
end
- it 'parses timestamp fields into Time instances' do
- hash = described_class.symbolize_hash('created_at' => '2017-01-01 12:00')
+ it "parses timestamp fields into Time instances" do
+ hash = described_class.symbolize_hash("created_at" => "2017-01-01 12:00")
expect(hash[:created_at]).to be_an_instance_of(Time)
end
diff --git a/spec/lib/gitlab/github_import/sequential_importer_spec.rb b/spec/lib/gitlab/github_import/sequential_importer_spec.rb
index 05d3243f806..63225e20696 100644
--- a/spec/lib/gitlab/github_import/sequential_importer_spec.rb
+++ b/spec/lib/gitlab/github_import/sequential_importer_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::SequentialImporter do
- describe '#execute' do
- it 'imports a project in sequence' do
+ describe "#execute" do
+ it "imports a project in sequence" do
repository = double(:repository)
project = double(:project, id: 1, repository: repository)
- importer = described_class.new(project, token: 'foo')
+ importer = described_class.new(project, token: "foo")
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
.to receive(:execute)
diff --git a/spec/lib/gitlab/github_import/user_finder_spec.rb b/spec/lib/gitlab/github_import/user_finder_spec.rb
index 29f4c00d9c7..e7a3beca161 100644
--- a/spec/lib/gitlab/github_import/user_finder_spec.rb
+++ b/spec/lib/gitlab/github_import/user_finder_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
let(:project) { create(:project) }
let(:client) { double(:client) }
let(:finder) { described_class.new(project, client) }
- describe '#author_id_for' do
- it 'returns the user ID for the author of an object' do
- user = double(:user, id: 4, login: 'kittens')
+ describe "#author_id_for" do
+ it "returns the user ID for the author of an object" do
+ user = double(:user, id: 4, login: "kittens")
note = double(:note, author: user)
expect(finder).to receive(:user_id_for).with(user).and_return(42)
@@ -15,8 +15,8 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
expect(finder.author_id_for(note)).to eq([42, true])
end
- it 'returns the ID of the project creator if no user ID could be found' do
- user = double(:user, id: 4, login: 'kittens')
+ it "returns the ID of the project creator if no user ID could be found" do
+ user = double(:user, id: 4, login: "kittens")
note = double(:note, author: user)
expect(finder).to receive(:user_id_for).with(user).and_return(nil)
@@ -24,27 +24,27 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
expect(finder.author_id_for(note)).to eq([project.creator_id, false])
end
- it 'returns the ID of the ghost user when the object has no user' do
+ it "returns the ID of the ghost user when the object has no user" do
note = double(:note, author: nil)
expect(finder.author_id_for(note)).to eq([User.ghost.id, true])
end
- it 'returns the ID of the ghost user when the given object is nil' do
+ it "returns the ID of the ghost user when the given object is nil" do
expect(finder.author_id_for(nil)).to eq([User.ghost.id, true])
end
end
- describe '#assignee_id_for' do
- it 'returns the user ID for the assignee of an issuable' do
- user = double(:user, id: 4, login: 'kittens')
+ describe "#assignee_id_for" do
+ it "returns the user ID for the assignee of an issuable" do
+ user = double(:user, id: 4, login: "kittens")
issue = double(:issue, assignee: user)
expect(finder).to receive(:user_id_for).with(user).and_return(42)
expect(finder.assignee_id_for(issue)).to eq(42)
end
- it 'returns nil if the issuable does not have an assignee' do
+ it "returns nil if the issuable does not have an assignee" do
issue = double(:issue, assignee: nil)
expect(finder).not_to receive(:user_id_for)
@@ -52,16 +52,16 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
end
- describe '#user_id_for' do
- it 'returns the user ID for the given user' do
- user = double(:user, id: 4, login: 'kittens')
+ describe "#user_id_for" do
+ it "returns the user ID for the given user" do
+ user = double(:user, id: 4, login: "kittens")
expect(finder).to receive(:find).with(user.id, user.login).and_return(42)
expect(finder.user_id_for(user)).to eq(42)
end
end
- describe '#find' do
+ describe "#find" do
let(:user) { create(:user) }
before do
@@ -69,32 +69,32 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
.and_return(user.email)
end
- context 'without a cache' do
+ context "without a cache" do
before do
allow(finder).to receive(:find_from_cache).and_return([false, nil])
expect(finder).to receive(:find_id_from_database).and_call_original
end
- it 'finds a GitLab user for a GitHub user ID' do
+ it "finds a GitLab user for a GitHub user ID" do
user.identities.create!(provider: :github, extern_uid: 42)
expect(finder.find(42, user.username)).to eq(user.id)
end
- it 'finds a GitLab user for a GitHub Email address' do
+ it "finds a GitLab user for a GitHub Email address" do
expect(finder.find(42, user.username)).to eq(user.id)
end
end
- context 'with a cache' do
- it 'returns the cached user ID' do
+ context "with a cache" do
+ it "returns the cached user ID" do
expect(finder).to receive(:find_from_cache).and_return([true, user.id])
expect(finder).not_to receive(:find_id_from_database)
expect(finder.find(42, user.username)).to eq(user.id)
end
- it 'does not query the database if the cache key exists but is empty' do
+ it "does not query the database if the cache key exists but is empty" do
expect(finder).to receive(:find_from_cache).and_return([true, nil])
expect(finder).not_to receive(:find_id_from_database)
@@ -103,8 +103,8 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
end
- describe '#find_from_cache' do
- it 'retrieves a GitLab user ID for a GitHub user ID' do
+ describe "#find_from_cache" do
+ it "retrieves a GitLab user ID for a GitHub user ID" do
expect(finder)
.to receive(:cached_id_for_github_id)
.with(42)
@@ -113,8 +113,8 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
expect(finder.find_from_cache(42)).to eq([true, 4])
end
- it 'retrieves a GitLab user ID for a GitHub Email address' do
- email = 'kittens@example.com'
+ it "retrieves a GitLab user ID for a GitHub Email address" do
+ email = "kittens@example.com"
expect(finder)
.to receive(:cached_id_for_github_id)
@@ -129,7 +129,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
expect(finder.find_from_cache(42, email)).to eq([true, 4])
end
- it 'does not query the cache for an Email address when none is given' do
+ it "does not query the cache for an Email address when none is given" do
expect(finder)
.to receive(:cached_id_for_github_id)
.with(42)
@@ -141,100 +141,100 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
end
- describe '#find_id_from_database' do
+ describe "#find_id_from_database" do
let(:user) { create(:user) }
- it 'returns the GitLab user ID for a GitHub user ID' do
+ it "returns the GitLab user ID for a GitHub user ID" do
user.identities.create!(provider: :github, extern_uid: 42)
expect(finder.find_id_from_database(42, user.email)).to eq(user.id)
end
- it 'returns the GitLab user ID for a GitHub Email address' do
+ it "returns the GitLab user ID for a GitHub Email address" do
expect(finder.find_id_from_database(42, user.email)).to eq(user.id)
end
end
- describe '#email_for_github_username' do
- let(:email) { 'kittens@example.com' }
+ describe "#email_for_github_username" do
+ let(:email) { "kittens@example.com" }
- context 'when an Email address is cached' do
- it 'reads the Email address from the cache' do
+ context "when an Email address is cached" do
+ it "reads the Email address from the cache" do
expect(Gitlab::GithubImport::Caching)
.to receive(:read)
.and_return(email)
expect(client).not_to receive(:user)
- expect(finder.email_for_github_username('kittens')).to eq(email)
+ expect(finder.email_for_github_username("kittens")).to eq(email)
end
end
- context 'when an Email address is not cached' do
+ context "when an Email address is not cached" do
let(:user) { double(:user, email: email) }
- it 'retrieves the Email address from the GitHub API' do
- expect(client).to receive(:user).with('kittens').and_return(user)
- expect(finder.email_for_github_username('kittens')).to eq(email)
+ it "retrieves the Email address from the GitHub API" do
+ expect(client).to receive(:user).with("kittens").and_return(user)
+ expect(finder.email_for_github_username("kittens")).to eq(email)
end
- it 'caches the Email address when an Email address is available' do
- expect(client).to receive(:user).with('kittens').and_return(user)
+ it "caches the Email address when an Email address is available" do
+ expect(client).to receive(:user).with("kittens").and_return(user)
expect(Gitlab::GithubImport::Caching)
.to receive(:write)
.with(an_instance_of(String), email)
- finder.email_for_github_username('kittens')
+ finder.email_for_github_username("kittens")
end
- it 'returns nil if the user does not exist' do
+ it "returns nil if the user does not exist" do
expect(client)
.to receive(:user)
- .with('kittens')
+ .with("kittens")
.and_return(nil)
expect(Gitlab::GithubImport::Caching)
.not_to receive(:write)
- expect(finder.email_for_github_username('kittens')).to be_nil
+ expect(finder.email_for_github_username("kittens")).to be_nil
end
end
end
- describe '#cached_id_for_github_id' do
+ describe "#cached_id_for_github_id" do
let(:id) { 4 }
- it 'reads a user ID from the cache' do
+ it "reads a user ID from the cache" do
Gitlab::GithubImport::Caching
.write(described_class::ID_CACHE_KEY % id, 4)
expect(finder.cached_id_for_github_id(id)).to eq([true, 4])
end
- it 'reads a non existing cache key' do
+ it "reads a non existing cache key" do
expect(finder.cached_id_for_github_id(id)).to eq([false, nil])
end
end
- describe '#cached_id_for_github_email' do
- let(:email) { 'kittens@example.com' }
+ describe "#cached_id_for_github_email" do
+ let(:email) { "kittens@example.com" }
- it 'reads a user ID from the cache' do
+ it "reads a user ID from the cache" do
Gitlab::GithubImport::Caching
.write(described_class::ID_FOR_EMAIL_CACHE_KEY % email, 4)
expect(finder.cached_id_for_github_email(email)).to eq([true, 4])
end
- it 'reads a non existing cache key' do
+ it "reads a non existing cache key" do
expect(finder.cached_id_for_github_email(email)).to eq([false, nil])
end
end
- describe '#id_for_github_id' do
+ describe "#id_for_github_id" do
let(:id) { 4 }
- it 'queries and caches the user ID for a given GitHub ID' do
+ it "queries and caches the user ID for a given GitHub ID" do
expect(finder).to receive(:query_id_for_github_id)
.with(id)
.and_return(42)
@@ -246,7 +246,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
finder.id_for_github_id(id)
end
- it 'caches a nil value if no ID could be found' do
+ it "caches a nil value if no ID could be found" do
expect(finder).to receive(:query_id_for_github_id)
.with(id)
.and_return(nil)
@@ -259,10 +259,10 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
end
- describe '#id_for_github_email' do
- let(:email) { 'kittens@example.com' }
+ describe "#id_for_github_email" do
+ let(:email) { "kittens@example.com" }
- it 'queries and caches the user ID for a given Email address' do
+ it "queries and caches the user ID for a given Email address" do
expect(finder).to receive(:query_id_for_github_email)
.with(email)
.and_return(42)
@@ -274,7 +274,7 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
finder.id_for_github_email(email)
end
- it 'caches a nil value if no ID could be found' do
+ it "caches a nil value if no ID could be found" do
expect(finder).to receive(:query_id_for_github_email)
.with(email)
.and_return(nil)
@@ -287,47 +287,47 @@ describe Gitlab::GithubImport::UserFinder, :clean_gitlab_redis_cache do
end
end
- describe '#query_id_for_github_id' do
- it 'returns the ID of the user for the given GitHub user ID' do
+ describe "#query_id_for_github_id" do
+ it "returns the ID of the user for the given GitHub user ID" do
user = create(:user)
- user.identities.create!(provider: :github, extern_uid: '42')
+ user.identities.create!(provider: :github, extern_uid: "42")
expect(finder.query_id_for_github_id(42)).to eq(user.id)
end
- it 'returns nil when no user ID could be found' do
+ it "returns nil when no user ID could be found" do
expect(finder.query_id_for_github_id(42)).to be_nil
end
end
- describe '#query_id_for_github_email' do
- it 'returns the ID of the user for the given Email address' do
- user = create(:user, email: 'kittens@example.com')
+ describe "#query_id_for_github_email" do
+ it "returns the ID of the user for the given Email address" do
+ user = create(:user, email: "kittens@example.com")
expect(finder.query_id_for_github_email(user.email)).to eq(user.id)
end
- it 'returns nil if no user ID could be found' do
- expect(finder.query_id_for_github_email('kittens@example.com')).to be_nil
+ it "returns nil if no user ID could be found" do
+ expect(finder.query_id_for_github_email("kittens@example.com")).to be_nil
end
end
- describe '#read_id_from_cache' do
- it 'reads an ID from the cache' do
- Gitlab::GithubImport::Caching.write('foo', 10)
+ describe "#read_id_from_cache" do
+ it "reads an ID from the cache" do
+ Gitlab::GithubImport::Caching.write("foo", 10)
- expect(finder.read_id_from_cache('foo')).to eq([true, 10])
+ expect(finder.read_id_from_cache("foo")).to eq([true, 10])
end
- it 'reads a cache key with an empty value' do
- Gitlab::GithubImport::Caching.write('foo', nil)
+ it "reads a cache key with an empty value" do
+ Gitlab::GithubImport::Caching.write("foo", nil)
- expect(finder.read_id_from_cache('foo')).to eq([true, nil])
+ expect(finder.read_id_from_cache("foo")).to eq([true, nil])
end
- it 'reads a cache key that does not exist' do
- expect(finder.read_id_from_cache('foo')).to eq([false, nil])
+ it "reads a cache key that does not exist" do
+ expect(finder.read_id_from_cache("foo")).to eq([false, nil])
end
end
end
diff --git a/spec/lib/gitlab/github_import_spec.rb b/spec/lib/gitlab/github_import_spec.rb
index 496244c91bf..84fa3c23301 100644
--- a/spec/lib/gitlab/github_import_spec.rb
+++ b/spec/lib/gitlab/github_import_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport do
let(:project) { double(:project) }
- describe '.new_client_for' do
- it 'returns a new Client with a custom token' do
+ describe ".new_client_for" do
+ it "returns a new Client with a custom token" do
expect(described_class::Client)
.to receive(:new)
- .with('123', parallel: true)
+ .with("123", parallel: true)
- described_class.new_client_for(project, token: '123')
+ described_class.new_client_for(project, token: "123")
end
- it 'returns a new Client with a token stored in the import data' do
- import_data = double(:import_data, credentials: { user: '123' })
+ it "returns a new Client with a token stored in the import data" do
+ import_data = double(:import_data, credentials: {user: "123"})
expect(project)
.to receive(:import_data)
@@ -21,18 +21,18 @@ describe Gitlab::GithubImport do
expect(described_class::Client)
.to receive(:new)
- .with('123', parallel: true)
+ .with("123", parallel: true)
described_class.new_client_for(project)
end
end
- describe '.ghost_user_id', :clean_gitlab_redis_cache do
- it 'returns the ID of the ghost user' do
+ describe ".ghost_user_id", :clean_gitlab_redis_cache do
+ it "returns the ID of the ghost user" do
expect(described_class.ghost_user_id).to eq(User.ghost.id)
end
- it 'caches the ghost user ID' do
+ it "caches the ghost user ID" do
expect(Gitlab::GithubImport::Caching)
.to receive(:write)
.once
diff --git a/spec/lib/gitlab/gitlab_import/client_spec.rb b/spec/lib/gitlab/gitlab_import/client_spec.rb
index 22ad88e28cb..41ad9b140a6 100644
--- a/spec/lib/gitlab/gitlab_import/client_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/client_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitlabImport::Client do
include ImportSpecHelper
- let(:token) { '123456' }
+ let(:token) { "123456" }
let(:client) { described_class.new(token) }
before do
- stub_omniauth_provider('gitlab')
+ stub_omniauth_provider("gitlab")
end
- it 'all OAuth2 client options are symbols' do
+ it "all OAuth2 client options are symbols" do
client.client.options.keys.each do |key|
expect(key).to be_kind_of(Symbol)
end
end
- it 'uses membership and simple flags' do
- stub_request('/api/v4/projects?membership=true&page=1&per_page=100&simple=true')
+ it "uses membership and simple flags" do
+ stub_request("/api/v4/projects?membership=true&page=1&per_page=100&simple=true")
expect_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
expect(client.projects.to_a).to eq []
end
- shared_examples 'pagination params' do
+ shared_examples "pagination params" do
before do
allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return([])
end
- it 'allows page_limit param' do
+ it "allows page_limit param" do
allow_any_instance_of(OAuth2::Response).to receive(:parsed).and_return(element_list)
expect(client).to receive(:lazy_page_iterator).with(hash_including(page_limit: 2)).and_call_original
@@ -37,62 +37,62 @@ describe Gitlab::GitlabImport::Client do
client.send(method, *args, page_limit: 2, per_page: 1).to_a
end
- it 'allows per_page param' do
+ it "allows per_page param" do
expect(client).to receive(:lazy_page_iterator).with(hash_including(per_page: 2)).and_call_original
client.send(method, *args, per_page: 2).to_a
end
- it 'allows starting_page param' do
+ it "allows starting_page param" do
expect(client).to receive(:lazy_page_iterator).with(hash_including(starting_page: 3)).and_call_original
client.send(method, *args, starting_page: 3).to_a
end
end
- describe '#projects' do
+ describe "#projects" do
subject(:method) { :projects }
let(:args) { [] }
let(:element_list) { build_list(:project, 2) }
before do
- stub_request('/api/v4/projects?membership=true&page=1&per_page=1&simple=true')
- stub_request('/api/v4/projects?membership=true&page=2&per_page=1&simple=true')
- stub_request('/api/v4/projects?membership=true&page=1&per_page=2&simple=true')
- stub_request('/api/v4/projects?membership=true&page=3&per_page=100&simple=true')
+ stub_request("/api/v4/projects?membership=true&page=1&per_page=1&simple=true")
+ stub_request("/api/v4/projects?membership=true&page=2&per_page=1&simple=true")
+ stub_request("/api/v4/projects?membership=true&page=1&per_page=2&simple=true")
+ stub_request("/api/v4/projects?membership=true&page=3&per_page=100&simple=true")
end
- it_behaves_like 'pagination params'
+ it_behaves_like "pagination params"
end
- describe '#issues' do
+ describe "#issues" do
subject(:method) { :issues }
let(:args) { [1] }
let(:element_list) { build_list(:issue, 2) }
before do
- stub_request('/api/v4/projects/1/issues?page=1&per_page=1')
- stub_request('/api/v4/projects/1/issues?page=2&per_page=1')
- stub_request('/api/v4/projects/1/issues?page=1&per_page=2')
- stub_request('/api/v4/projects/1/issues?page=3&per_page=100')
+ stub_request("/api/v4/projects/1/issues?page=1&per_page=1")
+ stub_request("/api/v4/projects/1/issues?page=2&per_page=1")
+ stub_request("/api/v4/projects/1/issues?page=1&per_page=2")
+ stub_request("/api/v4/projects/1/issues?page=3&per_page=100")
end
- it_behaves_like 'pagination params'
+ it_behaves_like "pagination params"
end
- describe '#issue_comments' do
+ describe "#issue_comments" do
subject(:method) { :issue_comments }
let(:args) { [1, 1] }
let(:element_list) { build_list(:note_on_issue, 2) }
before do
- stub_request('/api/v4/projects/1/issues/1/notes?page=1&per_page=1')
- stub_request('/api/v4/projects/1/issues/1/notes?page=2&per_page=1')
- stub_request('/api/v4/projects/1/issues/1/notes?page=1&per_page=2')
- stub_request('/api/v4/projects/1/issues/1/notes?page=3&per_page=100')
+ stub_request("/api/v4/projects/1/issues/1/notes?page=1&per_page=1")
+ stub_request("/api/v4/projects/1/issues/1/notes?page=2&per_page=1")
+ stub_request("/api/v4/projects/1/issues/1/notes?page=1&per_page=2")
+ stub_request("/api/v4/projects/1/issues/1/notes?page=3&per_page=100")
end
- it_behaves_like 'pagination params'
+ it_behaves_like "pagination params"
end
def stub_request(path)
diff --git a/spec/lib/gitlab/gitlab_import/importer_spec.rb b/spec/lib/gitlab/gitlab_import/importer_spec.rb
index 200edceca8c..d7644a93c1c 100644
--- a/spec/lib/gitlab/gitlab_import/importer_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/importer_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitlabImport::Importer do
include ImportSpecHelper
- describe '#execute' do
+ describe "#execute" do
before do
- stub_omniauth_provider('gitlab')
- stub_request('issues', [
+ stub_omniauth_provider("gitlab")
+ stub_request("issues", [
{
- 'id' => 2579857,
- 'iid' => 3,
- 'title' => 'Issue',
- 'description' => 'Lorem ipsum',
- 'state' => 'opened',
- 'confidential' => true,
- 'author' => {
- 'id' => 283999,
- 'name' => 'John Doe'
- }
- }
+ "id" => 2579857,
+ "iid" => 3,
+ "title" => "Issue",
+ "description" => "Lorem ipsum",
+ "state" => "opened",
+ "confidential" => true,
+ "author" => {
+ "id" => 283999,
+ "name" => "John Doe",
+ },
+ },
])
- stub_request('issues/3/notes', [])
+ stub_request("issues/3/notes", [])
end
- it 'persists issues' do
- project = create(:project, import_source: 'asd/vim')
- project.build_import_data(credentials: { password: 'password' })
+ it "persists issues" do
+ project = create(:project, import_source: "asd/vim")
+ project.build_import_data(credentials: {password: "password"})
subject = described_class.new(project)
subject.execute
expected_attributes = {
iid: 3,
- title: 'Issue',
+ title: "Issue",
description: "*Created by: John Doe*\n\nLorem ipsum",
- state: 'opened',
+ state: "opened",
confidential: true,
- author_id: project.creator_id
+ author_id: project.creator_id,
}
expect(project.issues.first).to have_attributes(expected_attributes)
@@ -47,7 +47,7 @@ describe Gitlab::GitlabImport::Importer do
WebMock.stub_request(:get, url)
.to_return(
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body
)
end
diff --git a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
index b814f5fc76c..fbdcc639d90 100644
--- a/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/gitlab_import/project_creator_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GitlabImport::ProjectCreator do
let(:user) { create(:user) }
let(:repo) do
{
- name: 'vim',
- path: 'vim',
+ name: "vim",
+ path: "vim",
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
- path_with_namespace: 'asd/vim',
+ path_with_namespace: "asd/vim",
http_url_to_repo: "https://gitlab.com/asd/vim.git",
- owner: { name: "john" }
+ owner: {name: "john"},
}.with_indifferent_access
end
let(:namespace) { create(:group) }
let(:token) { "asdffg" }
- let(:access_params) { { gitlab_access_token: token } }
+ let(:access_params) { {gitlab_access_token: token} }
before do
namespace.add_owner(user)
end
- it 'creates project' do
+ it "creates project" do
expect_next_instance_of(Project) do |project|
expect(project).to receive(:add_import_job)
end
diff --git a/spec/lib/gitlab/gl_repository_spec.rb b/spec/lib/gitlab/gl_repository_spec.rb
index 4e09020471b..4c2eef08bb2 100644
--- a/spec/lib/gitlab/gl_repository_spec.rb
+++ b/spec/lib/gitlab/gl_repository_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe ::Gitlab::GlRepository do
- describe '.parse' do
+ describe ".parse" do
set(:project) { create(:project, :repository) }
- it 'parses a project gl_repository' do
+ it "parses a project gl_repository" do
expect(described_class.parse("project-#{project.id}")).to eq([project, false])
end
- it 'parses a wiki gl_repository' do
+ it "parses a wiki gl_repository" do
expect(described_class.parse("wiki-#{project.id}")).to eq([project, true])
end
- it 'throws an argument error on an invalid gl_repository' do
+ it "throws an argument error on an invalid gl_repository" do
expect { described_class.parse("badformat-#{project.id}") }.to raise_error(ArgumentError)
end
end
diff --git a/spec/lib/gitlab/gon_helper_spec.rb b/spec/lib/gitlab/gon_helper_spec.rb
index 1ff2334bacf..c43b34907bd 100644
--- a/spec/lib/gitlab/gon_helper_spec.rb
+++ b/spec/lib/gitlab/gon_helper_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GonHelper do
let(:helper) do
- Class.new do
+ Class.new {
include Gitlab::GonHelper
- end.new
+ }.new
end
- describe '#push_frontend_feature_flag' do
- it 'pushes a feature flag to the frontend' do
- gon = instance_double('gon')
+ describe "#push_frontend_feature_flag" do
+ it "pushes a feature flag to the frontend" do
+ gon = instance_double("gon")
allow(helper)
.to receive(:gon)
@@ -24,14 +24,14 @@ describe Gitlab::GonHelper do
expect(gon)
.to receive(:push)
- .with({ features: { 'myFeatureFlag' => true } }, true)
+ .with({features: {"myFeatureFlag" => true}}, true)
helper.push_frontend_feature_flag(:my_feature_flag, 10)
end
end
- describe '#default_avatar_url' do
- it 'returns an absolute URL' do
+ describe "#default_avatar_url" do
+ it "returns an absolute URL" do
url = helper.default_avatar_url
expect(url).to match(/^http/)
diff --git a/spec/lib/gitlab/google_code_import/importer_spec.rb b/spec/lib/gitlab/google_code_import/importer_spec.rb
index 031f57dbc65..17686de16e6 100644
--- a/spec/lib/gitlab/google_code_import/importer_spec.rb
+++ b/spec/lib/gitlab/google_code_import/importer_spec.rb
@@ -6,8 +6,8 @@ describe Gitlab::GoogleCodeImport::Importer do
let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) }
let(:import_data) do
{
- 'repo' => client.repo('tint2').raw_data,
- 'user_map' => { 'thilo...' => "@#{mapped_user.username}" }
+ "repo" => client.repo("tint2").raw_data,
+ "user_map" => {"thilo..." => "@#{mapped_user.username}"},
}
end
let(:project) { create(:project) }
@@ -23,7 +23,7 @@ describe Gitlab::GoogleCodeImport::Importer do
it "imports status labels" do
subject.execute
- %w(New NeedInfo Accepted Wishlist Started Fixed Invalid Duplicate WontFix Incomplete).each do |status|
+ %w[New NeedInfo Accepted Wishlist Started Fixed Invalid Duplicate WontFix Incomplete].each do |status|
expect(project.labels.find_by(name: "Status: #{status}")).not_to be_nil
end
end
@@ -31,12 +31,12 @@ describe Gitlab::GoogleCodeImport::Importer do
it "imports labels" do
subject.execute
- %w(
+ %w[
Type-Defect Type-Enhancement Type-Task Type-Review Type-Other Milestone-0.12 Priority-Critical
Priority-High Priority-Medium Priority-Low OpSys-All OpSys-Windows OpSys-Linux OpSys-OSX Security
Performance Usability Maintainability Component-Panel Component-Taskbar Component-Battery
Component-Systray Component-Clock Component-Launcher Component-Tint2conf Component-Docs Component-New
- ).each do |label|
+ ].each do |label|
label.sub!("-", ": ")
expect(project.labels.find_by(name: label)).not_to be_nil
end
@@ -59,13 +59,13 @@ describe Gitlab::GoogleCodeImport::Importer do
expect(issue.description).to include("schattenpr\\.\\.\\.")
expect(issue.description).to include("November 18, 2009 00:20")
expect(issue.description).to include("Google Code")
- expect(issue.description).to include('I like to scroll through the tasks with my scrollwheel (like in fluxbox).')
- expect(issue.description).to include('Patch is attached that adds two new mouse-actions (next_task+prev_task)')
- expect(issue.description).to include('that can be used for exactly that purpose.')
- expect(issue.description).to include('all the best!')
- expect(issue.description).to include('[tint2_task_scrolling.diff](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/tint2_task_scrolling.diff)')
- expect(issue.description).to include('![screenshot.png](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/screenshot.png)')
- expect(issue.description).to include('![screenshot1.PNG](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/screenshot1.PNG)')
+ expect(issue.description).to include("I like to scroll through the tasks with my scrollwheel (like in fluxbox).")
+ expect(issue.description).to include("Patch is attached that adds two new mouse-actions (next_task+prev_task)")
+ expect(issue.description).to include("that can be used for exactly that purpose.")
+ expect(issue.description).to include("all the best!")
+ expect(issue.description).to include("[tint2_task_scrolling.diff](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/tint2_task_scrolling.diff)")
+ expect(issue.description).to include("![screenshot.png](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/screenshot.png)")
+ expect(issue.description).to include("![screenshot1.PNG](https://storage.googleapis.com/google-code-attachments/tint2/issue-169/comment-0/screenshot1.PNG)")
end
it "imports issue comments" do
diff --git a/spec/lib/gitlab/google_code_import/project_creator_spec.rb b/spec/lib/gitlab/google_code_import/project_creator_spec.rb
index b959e006292..51aa92d873d 100644
--- a/spec/lib/gitlab/google_code_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/google_code_import/project_creator_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GoogleCodeImport::ProjectCreator do
let(:user) { create(:user) }
let(:repo) do
Gitlab::GoogleCodeImport::Repository.new(
- "name" => 'vim',
- "summary" => 'VI Improved',
+ "name" => "vim",
+ "summary" => "VI Improved",
"repositoryUrls" => ["https://vim.googlecode.com/git/"]
)
end
@@ -15,7 +15,7 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
namespace.add_owner(user)
end
- it 'creates project' do
+ it "creates project" do
expect_next_instance_of(Project) do |project|
expect(project).to receive(:add_import_job)
end
diff --git a/spec/lib/gitlab/gpg/commit_spec.rb b/spec/lib/gitlab/gpg/commit_spec.rb
index 8229f0eb794..c61fb2dcbf5 100644
--- a/spec/lib/gitlab/gpg/commit_spec.rb
+++ b/spec/lib/gitlab/gpg/commit_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Gpg::Commit do
- describe '#signature' do
- shared_examples 'returns the cached signature on second call' do
- it 'returns the cached signature on second call' do
+ describe "#signature" do
+ shared_examples "returns the cached signature on second call" do
+ it "returns the cached signature on second call" do
gpg_commit = described_class.new(commit)
expect(gpg_commit).to receive(:using_keychain).and_call_original
@@ -15,42 +15,42 @@ describe Gitlab::Gpg::Commit do
end
end
- let!(:project) { create :project, :repository, path: 'sample-project' }
- let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
+ let!(:project) { create :project, :repository, path: "sample-project" }
+ let!(:commit_sha) { "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" }
- context 'unsigned commit' do
+ context "unsigned commit" do
let!(:commit) { create :commit, project: project, sha: commit_sha }
- it 'returns nil' do
+ it "returns nil" do
expect(described_class.new(commit).signature).to be_nil
end
end
- context 'invalid signature' do
+ context "invalid signature" do
let!(:commit) { create :commit, project: project, sha: commit_sha, committer_email: GpgHelpers::User1.emails.first }
let!(:user) { create(:user, email: GpgHelpers::User1.emails.first) }
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- # Corrupt the key
- GpgHelpers::User1.signed_commit_signature.tr('=', 'a'),
- GpgHelpers::User1.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ # Corrupt the key
+ GpgHelpers::User1.signed_commit_signature.tr("=", "a"),
+ GpgHelpers::User1.signed_commit_base_data,
+ ]
+ )
end
- it 'returns nil' do
+ it "returns nil" do
expect(described_class.new(commit).signature).to be_nil
end
end
- context 'known key' do
- context 'user matches the key uid' do
- context 'user email matches the email committer' do
+ context "known key" do
+ context "user matches the key uid" do
+ context "user email matches the email committer" do
let!(:commit) { create :commit, project: project, sha: commit_sha, committer_email: GpgHelpers::User1.emails.first }
let!(:user) { create(:user, email: GpgHelpers::User1.emails.first) }
@@ -61,16 +61,16 @@ describe Gitlab::Gpg::Commit do
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- GpgHelpers::User1.signed_commit_signature,
- GpgHelpers::User1.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ GpgHelpers::User1.signed_commit_signature,
+ GpgHelpers::User1.signed_commit_base_data,
+ ]
+ )
end
- it 'returns a valid signature' do
+ it "returns a valid signature" do
signature = described_class.new(commit).signature
expect(signature).to have_attributes(
@@ -80,19 +80,19 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
- verification_status: 'verified'
+ verification_status: "verified"
)
expect(signature.persisted?).to be_truthy
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
- context 'read-only mode' do
+ context "read-only mode" do
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
- it 'does not create a cached signature' do
+ it "does not create a cached signature" do
signature = described_class.new(commit).signature
expect(signature).to have_attributes(
@@ -102,14 +102,14 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
- verification_status: 'verified'
+ verification_status: "verified"
)
expect(signature.persisted?).to be_falsey
end
end
end
- context 'commit signed with a subkey' do
+ context "commit signed with a subkey" do
let!(:commit) { create :commit, project: project, sha: commit_sha, committer_email: GpgHelpers::User3.emails.first }
let!(:user) { create(:user, email: GpgHelpers::User3.emails.first) }
@@ -119,21 +119,21 @@ describe Gitlab::Gpg::Commit do
end
let(:gpg_key_subkey) do
- gpg_key.subkeys.find_by(fingerprint: '0522DD29B98F167CD8421752E38FFCAF75ABD92A')
+ gpg_key.subkeys.find_by(fingerprint: "0522DD29B98F167CD8421752E38FFCAF75ABD92A")
end
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- GpgHelpers::User3.signed_commit_signature,
- GpgHelpers::User3.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ GpgHelpers::User3.signed_commit_signature,
+ GpgHelpers::User3.signed_commit_base_data,
+ ]
+ )
end
- it 'returns a valid signature' do
+ it "returns a valid signature" do
expect(described_class.new(commit).signature).to have_attributes(
commit_sha: commit_sha,
project: project,
@@ -141,14 +141,14 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: gpg_key_subkey.keyid,
gpg_key_user_name: GpgHelpers::User3.names.first,
gpg_key_user_email: GpgHelpers::User3.emails.first,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
end
- context 'user email does not match the committer email, but is the same user' do
+ context "user email does not match the committer email, but is the same user" do
let!(:commit) { create :commit, project: project, sha: commit_sha, committer_email: GpgHelpers::User2.emails.first }
let(:user) do
@@ -163,16 +163,16 @@ describe Gitlab::Gpg::Commit do
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- GpgHelpers::User1.signed_commit_signature,
- GpgHelpers::User1.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ GpgHelpers::User1.signed_commit_signature,
+ GpgHelpers::User1.signed_commit_base_data,
+ ]
+ )
end
- it 'returns an invalid signature' do
+ it "returns an invalid signature" do
expect(described_class.new(commit).signature).to have_attributes(
commit_sha: commit_sha,
project: project,
@@ -180,14 +180,14 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
- verification_status: 'same_user_different_email'
+ verification_status: "same_user_different_email"
)
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
end
- context 'user email does not match the committer email' do
+ context "user email does not match the committer email" do
let!(:commit) { create :commit, project: project, sha: commit_sha, committer_email: GpgHelpers::User2.emails.first }
let(:user) { create(:user, email: GpgHelpers::User1.emails.first) }
@@ -198,16 +198,16 @@ describe Gitlab::Gpg::Commit do
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- GpgHelpers::User1.signed_commit_signature,
- GpgHelpers::User1.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ GpgHelpers::User1.signed_commit_signature,
+ GpgHelpers::User1.signed_commit_base_data,
+ ]
+ )
end
- it 'returns an invalid signature' do
+ it "returns an invalid signature" do
expect(described_class.new(commit).signature).to have_attributes(
commit_sha: commit_sha,
project: project,
@@ -215,15 +215,15 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
- verification_status: 'other_user'
+ verification_status: "other_user"
)
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
end
end
- context 'user does not match the key uid' do
+ context "user does not match the key uid" do
let!(:commit) { create :commit, project: project, sha: commit_sha }
let(:user) { create(:user, email: GpgHelpers::User2.emails.first) }
@@ -234,16 +234,16 @@ describe Gitlab::Gpg::Commit do
before do
allow(Gitlab::Git::Commit).to receive(:extract_signature_lazily)
- .with(Gitlab::Git::Repository, commit_sha)
- .and_return(
- [
- GpgHelpers::User1.signed_commit_signature,
- GpgHelpers::User1.signed_commit_base_data
- ]
- )
+ .with(Gitlab::Git::Repository, commit_sha)
+ .and_return(
+ [
+ GpgHelpers::User1.signed_commit_signature,
+ GpgHelpers::User1.signed_commit_base_data,
+ ]
+ )
end
- it 'returns an invalid signature' do
+ it "returns an invalid signature" do
expect(described_class.new(commit).signature).to have_attributes(
commit_sha: commit_sha,
project: project,
@@ -251,15 +251,15 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: GpgHelpers::User1.names.first,
gpg_key_user_email: GpgHelpers::User1.emails.first,
- verification_status: 'unverified_key'
+ verification_status: "unverified_key"
)
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
end
end
- context 'unknown key' do
+ context "unknown key" do
let!(:commit) { create :commit, project: project, sha: commit_sha }
before do
@@ -268,12 +268,12 @@ describe Gitlab::Gpg::Commit do
.and_return(
[
GpgHelpers::User1.signed_commit_signature,
- GpgHelpers::User1.signed_commit_base_data
+ GpgHelpers::User1.signed_commit_base_data,
]
)
end
- it 'returns an invalid signature' do
+ it "returns an invalid signature" do
expect(described_class.new(commit).signature).to have_attributes(
commit_sha: commit_sha,
project: project,
@@ -281,11 +281,11 @@ describe Gitlab::Gpg::Commit do
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
gpg_key_user_name: nil,
gpg_key_user_email: nil,
- verification_status: 'unknown_key'
+ verification_status: "unknown_key"
)
end
- it_behaves_like 'returns the cached signature on second call'
+ it_behaves_like "returns the cached signature on second call"
end
end
end
diff --git a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
index 1a2c6ef25c4..f14dc8ee707 100644
--- a/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
+++ b/spec/lib/gitlab/gpg/invalid_gpg_signature_updater_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
- describe '#run' do
+ describe "#run" do
let(:signature) { [GpgHelpers::User1.signed_commit_signature, GpgHelpers::User1.signed_commit_base_data] }
let(:committer_email) { GpgHelpers::User1.emails.first }
- let!(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
- let!(:project) { create :project, :repository, path: 'sample-project' }
+ let!(:commit_sha) { "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" }
+ let!(:project) { create :project, :repository, path: "sample-project" }
let!(:raw_commit) do
raw_commit = double(
:raw_commit,
@@ -31,7 +31,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
.and_return(signature)
end
- context 'gpg signature did have an associated gpg key which was removed later' do
+ context "gpg signature did have an associated gpg key which was removed later" do
let!(:user) { create :user, email: GpgHelpers::User1.emails.first }
let!(:valid_gpg_signature) do
@@ -40,10 +40,10 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'verified'
+ verification_status: "verified"
end
- it 'assigns the gpg key to the signature when the missing gpg key is added' do
+ it "assigns the gpg key to the signature when the missing gpg key is added" do
# InvalidGpgSignatureUpdater is called by the after_create hook
gpg_key = create :gpg_key,
key: GpgHelpers::User1.public_key,
@@ -54,11 +54,11 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
- it 'does not assign the gpg key when an unrelated gpg key is added' do
+ it "does not assign the gpg key when an unrelated gpg key is added" do
# InvalidGpgSignatureUpdater is called by the after_create hook
create :gpg_key,
key: GpgHelpers::User2.public_key,
@@ -69,12 +69,12 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
end
- context 'gpg signature did not have an associated gpg key' do
+ context "gpg signature did not have an associated gpg key" do
let!(:user) { create :user, email: GpgHelpers::User1.emails.first }
let!(:invalid_gpg_signature) do
@@ -83,10 +83,10 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'unknown_key'
+ verification_status: "unknown_key"
end
- it 'updates the signature to being valid when the missing gpg key is added' do
+ it "updates the signature to being valid when the missing gpg key is added" do
# InvalidGpgSignatureUpdater is called by the after_create hook
gpg_key = create :gpg_key,
key: GpgHelpers::User1.public_key,
@@ -97,11 +97,11 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
- it 'keeps the signature at being invalid when an unrelated gpg key is added' do
+ it "keeps the signature at being invalid when an unrelated gpg key is added" do
# InvalidGpgSignatureUpdater is called by the after_create hook
create :gpg_key,
key: GpgHelpers::User2.public_key,
@@ -112,14 +112,14 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'unknown_key'
+ verification_status: "unknown_key"
)
end
end
- context 'gpg signature did have an associated unverified gpg key' do
+ context "gpg signature did have an associated unverified gpg key" do
let!(:user) do
- create(:user, email: 'unrelated@example.com').tap do |user|
+ create(:user, email: "unrelated@example.com").tap do |user|
user.skip_reconfirmation!
end
end
@@ -130,15 +130,15 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'unknown_key'
+ verification_status: "unknown_key"
end
- it 'updates the signature to being valid when the user updates the email address' do
+ it "updates the signature to being valid when the user updates the email address" do
gpg_key = create :gpg_key,
key: GpgHelpers::User1.public_key,
user: user
- expect(invalid_gpg_signature.reload.verification_status).to eq 'unverified_key'
+ expect(invalid_gpg_signature.reload.verification_status).to eq "unverified_key"
# InvalidGpgSignatureUpdater is called by the after_update hook
user.update!(email: GpgHelpers::User1.emails.first)
@@ -148,11 +148,11 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
- it 'keeps the signature at being invalid when the changed email address is still unrelated' do
+ it "keeps the signature at being invalid when the changed email address is still unrelated" do
gpg_key = create :gpg_key,
key: GpgHelpers::User1.public_key,
user: user
@@ -162,23 +162,23 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'unverified_key'
+ verification_status: "unverified_key"
)
# InvalidGpgSignatureUpdater is called by the after_update hook
- user.update!(email: 'still.unrelated@example.com')
+ user.update!(email: "still.unrelated@example.com")
expect(invalid_gpg_signature.reload).to have_attributes(
project: project,
commit_sha: commit_sha,
gpg_key: gpg_key,
gpg_key_primary_keyid: GpgHelpers::User1.primary_keyid,
- verification_status: 'unverified_key'
+ verification_status: "unverified_key"
)
end
end
- context 'gpg signature did not have an associated gpg subkey' do
+ context "gpg signature did not have an associated gpg subkey" do
let(:signature) { [GpgHelpers::User3.signed_commit_signature, GpgHelpers::User3.signed_commit_base_data] }
let(:committer_email) { GpgHelpers::User3.emails.first }
let!(:user) { create :user, email: GpgHelpers::User3.emails.first }
@@ -189,10 +189,10 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key: nil,
gpg_key_primary_keyid: GpgHelpers::User3.subkey_fingerprints.last[24..-1],
- verification_status: 'unknown_key'
+ verification_status: "unknown_key"
end
- it 'updates the signature to being valid when the missing gpg key is added' do
+ it "updates the signature to being valid when the missing gpg key is added" do
# InvalidGpgSignatureUpdater is called by the after_create hook
gpg_key = create(:gpg_key, key: GpgHelpers::User3.public_key, user: user)
subkey = gpg_key.subkeys.last
@@ -202,7 +202,7 @@ RSpec.describe Gitlab::Gpg::InvalidGpgSignatureUpdater do
commit_sha: commit_sha,
gpg_key_subkey_id: subkey.id,
gpg_key_primary_keyid: subkey.keyid,
- verification_status: 'verified'
+ verification_status: "verified"
)
end
end
diff --git a/spec/lib/gitlab/gpg_spec.rb b/spec/lib/gitlab/gpg_spec.rb
index 48bbd7f854c..0901358cd5e 100644
--- a/spec/lib/gitlab/gpg_spec.rb
+++ b/spec/lib/gitlab/gpg_spec.rb
@@ -1,35 +1,35 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Gpg do
- describe '.fingerprints_from_key' do
+ describe ".fingerprints_from_key" do
before do
# make sure that each method is using the temporary keychain
expect(described_class).to receive(:using_tmp_keychain).and_call_original
end
- it 'returns CurrentKeyChain.fingerprints_from_key' do
+ it "returns CurrentKeyChain.fingerprints_from_key" do
expect(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(GpgHelpers::User1.public_key)
described_class.fingerprints_from_key(GpgHelpers::User1.public_key)
end
end
- describe '.primary_keyids_from_key' do
- it 'returns the keyid' do
+ describe ".primary_keyids_from_key" do
+ it "returns the keyid" do
expect(
described_class.primary_keyids_from_key(GpgHelpers::User1.public_key)
).to eq [GpgHelpers::User1.primary_keyid]
end
- it 'returns an empty array when the key is invalid' do
+ it "returns an empty array when the key is invalid" do
expect(
- described_class.primary_keyids_from_key('bogus')
+ described_class.primary_keyids_from_key("bogus")
).to eq []
end
end
- describe '.subkeys_from_key' do
- it 'returns the subkeys by primary key' do
+ describe ".subkeys_from_key" do
+ it "returns the subkeys by primary key" do
all_subkeys = described_class.subkeys_from_key(GpgHelpers::User1.public_key)
subkeys = all_subkeys[GpgHelpers::User1.primary_keyid]
@@ -38,48 +38,48 @@ describe Gitlab::Gpg do
expect(subkeys.first[:fingerprint]).to be_present
end
- it 'returns an empty array when there are not subkeys' do
+ it "returns an empty array when there are not subkeys" do
all_subkeys = described_class.subkeys_from_key(GpgHelpers::User4.public_key)
expect(all_subkeys[GpgHelpers::User4.primary_keyid]).to be_empty
end
end
- describe '.user_infos_from_key' do
- it 'returns the names and emails' do
+ describe ".user_infos_from_key" do
+ it "returns the names and emails" do
user_infos = described_class.user_infos_from_key(GpgHelpers::User1.public_key)
expect(user_infos).to eq([{
name: GpgHelpers::User1.names.first,
- email: GpgHelpers::User1.emails.first
+ email: GpgHelpers::User1.emails.first,
}])
end
- it 'returns an empty array when the key is invalid' do
+ it "returns an empty array when the key is invalid" do
expect(
- described_class.user_infos_from_key('bogus')
+ described_class.user_infos_from_key("bogus")
).to eq []
end
- it 'downcases the email' do
+ it "downcases the email" do
public_key = double(:key)
fingerprints = double(:fingerprints)
- uid = double(:uid, name: 'Nannie Bernhard', email: 'NANNIE.BERNHARD@EXAMPLE.COM')
+ uid = double(:uid, name: "Nannie Bernhard", email: "NANNIE.BERNHARD@EXAMPLE.COM")
raw_key = double(:raw_key, uids: [uid])
allow(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(public_key).and_return(fingerprints)
allow(GPGME::Key).to receive(:find).with(:public, anything).and_return([raw_key])
user_infos = described_class.user_infos_from_key(public_key)
expect(user_infos).to eq([{
- name: 'Nannie Bernhard',
- email: 'nannie.bernhard@example.com'
+ name: "Nannie Bernhard",
+ email: "nannie.bernhard@example.com",
}])
end
- it 'rejects non UTF-8 names and addresses' do
+ it "rejects non UTF-8 names and addresses" do
public_key = double(:key)
fingerprints = double(:fingerprints)
- email = "\xEEch@test.com".force_encoding('ASCII-8BIT')
- uid = double(:uid, name: 'Test User', email: email)
+ email = "\xEEch@test.com".force_encoding("ASCII-8BIT")
+ uid = double(:uid, name: "Test User", email: email)
raw_key = double(:raw_key, uids: [uid])
allow(Gitlab::Gpg::CurrentKeyChain).to receive(:fingerprints_from_key).with(public_key).and_return(fingerprints)
allow(GPGME::Key).to receive(:find).with(:public, anything).and_return([raw_key])
@@ -89,55 +89,55 @@ describe Gitlab::Gpg do
end
end
- describe '.current_home_dir' do
- let(:default_home_dir) { GPGME::Engine.dirinfo('homedir') }
+ describe ".current_home_dir" do
+ let(:default_home_dir) { GPGME::Engine.dirinfo("homedir") }
- it 'returns the default value when no explicit home dir has been set' do
+ it "returns the default value when no explicit home dir has been set" do
expect(described_class.current_home_dir).to eq default_home_dir
end
- it 'returns the explicitly set home dir' do
- GPGME::Engine.home_dir = '/tmp/gpg'
+ it "returns the explicitly set home dir" do
+ GPGME::Engine.home_dir = "/tmp/gpg"
- expect(described_class.current_home_dir).to eq '/tmp/gpg'
+ expect(described_class.current_home_dir).to eq "/tmp/gpg"
- GPGME::Engine.home_dir = GPGME::Engine.dirinfo('homedir')
+ GPGME::Engine.home_dir = GPGME::Engine.dirinfo("homedir")
end
- it 'returns the default value when explicitly setting the home dir to nil' do
+ it "returns the default value when explicitly setting the home dir to nil" do
GPGME::Engine.home_dir = nil
expect(described_class.current_home_dir).to eq default_home_dir
end
end
- describe '.using_tmp_keychain' do
+ describe ".using_tmp_keychain" do
it "the second thread does not change the first thread's directory" do
- thread1 = Thread.new do
+ thread1 = Thread.new {
described_class.using_tmp_keychain do
dir = described_class.current_home_dir
sleep 0.1
expect(described_class.current_home_dir).to eq dir
end
- end
+ }
- thread2 = Thread.new do
+ thread2 = Thread.new {
described_class.using_tmp_keychain do
sleep 0.2
end
- end
+ }
thread1.join
thread2.join
end
- it 'allows recursive execution in the same thread' do
- expect do
+ it "allows recursive execution in the same thread" do
+ expect {
described_class.using_tmp_keychain do
described_class.using_tmp_keychain do
end
end
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
@@ -149,8 +149,8 @@ describe Gitlab::Gpg::CurrentKeyChain do
end
end
- describe '.add' do
- it 'stores the key in the keychain' do
+ describe ".add" do
+ it "stores the key in the keychain" do
expect(GPGME::Key.find(:public, GpgHelpers::User1.fingerprint)).to eq []
described_class.add(GpgHelpers::User1.public_key)
@@ -164,16 +164,16 @@ describe Gitlab::Gpg::CurrentKeyChain do
end
end
- describe '.fingerprints_from_key' do
- it 'returns the fingerprint' do
+ describe ".fingerprints_from_key" do
+ it "returns the fingerprint" do
expect(
described_class.fingerprints_from_key(GpgHelpers::User1.public_key)
).to eq [GpgHelpers::User1.fingerprint]
end
- it 'returns an empty array when the key is invalid' do
+ it "returns an empty array when the key is invalid" do
expect(
- described_class.fingerprints_from_key('bogus')
+ described_class.fingerprints_from_key("bogus")
).to eq []
end
end
diff --git a/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb b/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
index f47b9dd3498..ac5975fee69 100644
--- a/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
+++ b/spec/lib/gitlab/grape_logging/loggers/queue_duration_logger_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GrapeLogging::Loggers::QueueDurationLogger do
subject { described_class.new }
describe ".parameters" do
- let(:start_time) { Time.new(2018, 01, 01) }
+ let(:start_time) { Time.new(2018, 0o1, 0o1) }
- describe 'when no proxy time is available' do
+ describe "when no proxy time is available" do
let(:mock_request) { OpenStruct.new(env: {}) }
- it 'returns an empty hash' do
+ it "returns an empty hash" do
expect(subject.parameters(mock_request, nil)).to eq({})
end
end
- describe 'when a proxy time is available' do
+ describe "when a proxy time is available" do
let(:mock_request) do
OpenStruct.new(
env: {
- 'HTTP_GITLAB_WORKHORSE_PROXY_START' => (start_time - 1.hour).to_i * (10**9)
+ "HTTP_GITLAB_WORKHORSE_PROXY_START" => (start_time - 1.hour).to_i * (10**9),
}
)
end
- it 'returns the correct duration in ms' do
+ it "returns the correct duration in ms" do
Timecop.freeze(start_time) do
subject.before
- expect(subject.parameters(mock_request, nil)).to eq( { 'queue_duration': 1.hour.to_f * 1000 })
+ expect(subject.parameters(mock_request, nil)).to eq({'queue_duration': 1.hour.to_f * 1000})
end
end
end
diff --git a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb
index 13cf52fd795..1dbd1def17b 100644
--- a/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb
+++ b/spec/lib/gitlab/graphql/authorize/authorize_resource_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Graphql::Authorize::AuthorizeResource do
let(:fake_class) do
@@ -27,91 +27,91 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do
let(:project) { build(:project) }
subject(:loading_resource) { fake_class.new(user, project) }
- context 'when the user is allowed to perform the action' do
+ context "when the user is allowed to perform the action" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_the_thing, project, scope: :user) do
true
end
end
- describe '#authorized_find' do
- it 'returns the object' do
+ describe "#authorized_find" do
+ it "returns the object" do
expect(loading_resource.authorized_find).to eq(project)
end
end
- describe '#authorized_find!' do
- it 'returns the object' do
+ describe "#authorized_find!" do
+ it "returns the object" do
expect(loading_resource.authorized_find!).to eq(project)
end
end
- describe '#authorize!' do
- it 'does not raise an error' do
+ describe "#authorize!" do
+ it "does not raise an error" do
expect { loading_resource.authorize!(project) }.not_to raise_error
end
end
- describe '#authorized?' do
- it 'is true' do
+ describe "#authorized?" do
+ it "is true" do
expect(loading_resource.authorized?(project)).to be(true)
end
end
end
- context 'when the user is not allowed to perform the action' do
+ context "when the user is not allowed to perform the action" do
before do
allow(Ability).to receive(:allowed?).with(user, :read_the_thing, project, scope: :user) do
false
end
end
- describe '#authorized_find' do
- it 'returns `nil`' do
+ describe "#authorized_find" do
+ it "returns `nil`" do
expect(loading_resource.authorized_find).to be_nil
end
end
- describe '#authorized_find!' do
- it 'raises an error' do
+ describe "#authorized_find!" do
+ it "raises an error" do
expect { loading_resource.authorize!(project) }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
- describe '#authorize!' do
- it 'does not raise an error' do
+ describe "#authorize!" do
+ it "does not raise an error" do
expect { loading_resource.authorize!(project) }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
- describe '#authorized?' do
- it 'is false' do
+ describe "#authorized?" do
+ it "is false" do
expect(loading_resource.authorized?(project)).to be(false)
end
end
end
- context 'when the class does not define #find_object' do
+ context "when the class does not define #find_object" do
let(:fake_class) do
Class.new { include Gitlab::Graphql::Authorize::AuthorizeResource }
end
- it 'raises a comprehensive error message' do
+ it "raises a comprehensive error message" do
expect { fake_class.new.find_object }.to raise_error(/Implement #find_object in #{fake_class.name}/)
end
end
- describe '#authorize' do
- it 'adds permissions from subclasses to those of superclasses when used on classes' do
- base_class = Class.new do
+ describe "#authorize" do
+ it "adds permissions from subclasses to those of superclasses when used on classes" do
+ base_class = Class.new {
include Gitlab::Graphql::Authorize::AuthorizeResource
authorize :base_authorization
- end
+ }
- sub_class = Class.new(base_class) do
+ sub_class = Class.new(base_class) {
authorize :sub_authorization
- end
+ }
expect(base_class.required_permissions).to contain_exactly(:base_authorization)
expect(sub_class.required_permissions)
diff --git a/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb b/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb
index cf3a8bcc8b4..231627d9439 100644
--- a/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb
+++ b/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Graphql::Authorize::Instrumentation do
- describe '#build_checker' do
+ describe "#build_checker" do
let(:current_user) { double(:current_user) }
let(:abilities) { [double(:first_ability), double(:last_ability)] }
@@ -11,7 +11,7 @@ describe Gitlab::Graphql::Authorize::Instrumentation do
described_class.new.__send__(:build_checker, current_user, abilities)
end
- it 'returns a checker which checks for a single object' do
+ it "returns a checker which checks for a single object" do
object = double(:object)
abilities.each do |ability|
@@ -21,7 +21,7 @@ describe Gitlab::Graphql::Authorize::Instrumentation do
expect(checker.call(object)).to eq(object)
end
- it 'returns a checker which checks for all objects' do
+ it "returns a checker which checks for all objects" do
objects = [double(:first), double(:last)]
abilities.each do |ability|
@@ -33,8 +33,8 @@ describe Gitlab::Graphql::Authorize::Instrumentation do
expect(checker.call(objects)).to eq(objects)
end
- context 'when some objects would not pass the check' do
- it 'returns nil when it is single object' do
+ context "when some objects would not pass the check" do
+ it "returns nil when it is single object" do
disallowed = double(:object)
spy_ability_check_for(abilities.first, disallowed, passed: false)
@@ -42,7 +42,7 @@ describe Gitlab::Graphql::Authorize::Instrumentation do
expect(checker.call(disallowed)).to be_nil
end
- it 'returns only objects which passed when there are more than one' do
+ it "returns only objects which passed when there are more than one" do
allowed = double(:allowed)
disallowed = double(:disallowed)
diff --git a/spec/lib/gitlab/graphql/connections/keyset_connection_spec.rb b/spec/lib/gitlab/graphql/connections/keyset_connection_spec.rb
index 9bcc1e78a78..ffc5f656f05 100644
--- a/spec/lib/gitlab/graphql/connections/keyset_connection_spec.rb
+++ b/spec/lib/gitlab/graphql/connections/keyset_connection_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Graphql::Connections::KeysetConnection do
let(:nodes) { Project.all.order(id: :asc) }
@@ -11,100 +11,100 @@ describe Gitlab::Graphql::Connections::KeysetConnection do
Base64.strict_encode64(value.to_s)
end
- describe '#cursor_from_nodes' do
+ describe "#cursor_from_nodes" do
let(:project) { create(:project) }
- it 'returns an encoded ID' do
+ it "returns an encoded ID" do
expect(connection.cursor_from_node(project))
.to eq(encoded_property(project.id))
end
- context 'when an order was specified' do
+ context "when an order was specified" do
let(:nodes) { Project.order(:updated_at) }
- it 'returns the encoded value of the order' do
+ it "returns the encoded value of the order" do
expect(connection.cursor_from_node(project))
.to eq(encoded_property(project.updated_at))
end
end
end
- describe '#sliced_nodes' do
+ describe "#sliced_nodes" do
let(:projects) { create_list(:project, 4) }
- context 'when before is passed' do
- let(:arguments) { { before: encoded_property(projects[1].id) } }
+ context "when before is passed" do
+ let(:arguments) { {before: encoded_property(projects[1].id)} }
- it 'only returns the project before the selected one' do
+ it "only returns the project before the selected one" do
expect(subject.sliced_nodes).to contain_exactly(projects.first)
end
- context 'when the sort order is descending' do
+ context "when the sort order is descending" do
let(:nodes) { Project.all.order(id: :desc) }
- it 'returns the correct nodes' do
+ it "returns the correct nodes" do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1])
end
end
end
- context 'when after is passed' do
- let(:arguments) { { after: encoded_property(projects[1].id) } }
+ context "when after is passed" do
+ let(:arguments) { {after: encoded_property(projects[1].id)} }
- it 'only returns the project before the selected one' do
+ it "only returns the project before the selected one" do
expect(subject.sliced_nodes).to contain_exactly(*projects[2..-1])
end
- context 'when the sort order is descending' do
+ context "when the sort order is descending" do
let(:nodes) { Project.all.order(id: :desc) }
- it 'returns the correct nodes' do
+ it "returns the correct nodes" do
expect(subject.sliced_nodes).to contain_exactly(projects.first)
end
end
end
- context 'when both before and after are passed' do
+ context "when both before and after are passed" do
let(:arguments) do
{
after: encoded_property(projects[1].id),
- before: encoded_property(projects[3].id)
+ before: encoded_property(projects[3].id),
}
end
- it 'returns the expected set' do
+ it "returns the expected set" do
expect(subject.sliced_nodes).to contain_exactly(projects[2])
end
end
end
- describe '#paged_nodes' do
+ describe "#paged_nodes" do
let!(:projects) { create_list(:project, 5) }
- it 'returns the collection limited to max page size' do
+ it "returns the collection limited to max page size" do
expect(subject.paged_nodes.size).to eq(3)
end
- context 'when `first` is passed' do
- let(:arguments) { { first: 2 } }
+ context "when `first` is passed" do
+ let(:arguments) { {first: 2} }
- it 'returns only the first elements' do
+ it "returns only the first elements" do
expect(subject.paged_nodes).to contain_exactly(projects.first, projects.second)
end
end
- context 'when `last` is passed' do
- let(:arguments) { { last: 2 } }
+ context "when `last` is passed" do
+ let(:arguments) { {last: 2} }
- it 'returns only the last elements' do
+ it "returns only the last elements" do
expect(subject.paged_nodes).to contain_exactly(projects[3], projects[4])
end
end
- context 'when both are passed' do
- let(:arguments) { { first: 2, last: 2 } }
+ context "when both are passed" do
+ let(:arguments) { {first: 2, last: 2} }
- it 'raises an error' do
+ it "raises an error" do
expect { subject.paged_nodes }.to raise_error(Gitlab::Graphql::Errors::ArgumentError)
end
end
diff --git a/spec/lib/gitlab/graphql/loaders/batch_model_loader_spec.rb b/spec/lib/gitlab/graphql/loaders/batch_model_loader_spec.rb
index 4609593ef6a..a85c9090e79 100644
--- a/spec/lib/gitlab/graphql/loaders/batch_model_loader_spec.rb
+++ b/spec/lib/gitlab/graphql/loaders/batch_model_loader_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Graphql::Loaders::BatchModelLoader do
- describe '#find' do
+ describe "#find" do
let(:issue) { create(:issue) }
let(:user) { create(:user) }
- it 'finds a model by id' do
+ it "finds a model by id" do
issue_result = described_class.new(Issue, issue.id).find
user_result = described_class.new(User, user.id).find
@@ -13,16 +13,16 @@ describe Gitlab::Graphql::Loaders::BatchModelLoader do
expect(user_result.__sync).to eq(user)
end
- it 'only queries once per model' do
+ it "only queries once per model" do
other_user = create(:user)
user
issue
- expect do
+ expect {
[described_class.new(User, other_user.id).find,
described_class.new(User, user.id).find,
- described_class.new(Issue, issue.id).find].map(&:__sync)
- end.not_to exceed_query_limit(2)
+ described_class.new(Issue, issue.id).find,].map(&:__sync)
+ }.not_to exceed_query_limit(2)
end
end
end
diff --git a/spec/lib/gitlab/graphs/commits_spec.rb b/spec/lib/gitlab/graphs/commits_spec.rb
index 530d4a981bf..85f02033c15 100644
--- a/spec/lib/gitlab/graphs/commits_spec.rb
+++ b/spec/lib/gitlab/graphs/commits_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Graphs::Commits do
let!(:project) { create(:project, :public) }
@@ -8,31 +8,31 @@ describe Gitlab::Graphs::Commits do
let!(:commit2) { create(:commit, git_commit: RepoHelpers.another_sample_commit, project: project, committed_date: Time.now) }
- describe '#commit_per_day' do
- context 'when range is only commits from today' do
+ describe "#commit_per_day" do
+ context "when range is only commits from today" do
subject { described_class.new([commit2, commit1]).commit_per_day }
it { is_expected.to eq 2 }
end
end
- context 'when range is only commits from today' do
+ context "when range is only commits from today" do
subject { described_class.new([commit2, commit1]) }
- describe '#commit_per_day' do
+ describe "#commit_per_day" do
it { expect(subject.commit_per_day).to eq 2 }
end
- describe '#duration' do
+ describe "#duration" do
it { expect(subject.duration).to eq 0 }
end
end
- context 'with commits from yesterday and today' do
+ context "with commits from yesterday and today" do
subject { described_class.new([commit2, commit1_yesterday]) }
- describe '#commit_per_day' do
+ describe "#commit_per_day" do
it { expect(subject.commit_per_day).to eq 1.0 }
end
- describe '#duration' do
+ describe "#duration" do
it { expect(subject.duration).to eq 1 }
end
end
diff --git a/spec/lib/gitlab/hashed_storage/migrator_spec.rb b/spec/lib/gitlab/hashed_storage/migrator_spec.rb
index 3942f168ceb..516d9d96489 100644
--- a/spec/lib/gitlab/hashed_storage/migrator_spec.rb
+++ b/spec/lib/gitlab/hashed_storage/migrator_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HashedStorage::Migrator do
- describe '#bulk_schedule' do
- it 'schedules job to StorageMigratorWorker' do
+ describe "#bulk_schedule" do
+ it "schedules job to StorageMigratorWorker" do
Sidekiq::Testing.fake! do
expect { subject.bulk_schedule(start: 1, finish: 5) }.to change(HashedStorage::MigratorWorker.jobs, :size).by(1)
end
end
end
- describe '#bulk_migrate' do
+ describe "#bulk_migrate" do
let(:projects) { create_list(:project, 2, :legacy_storage) }
let(:ids) { projects.map(&:id) }
- it 'enqueue jobs to ProjectMigrateHashedStorageWorker' do
+ it "enqueue jobs to ProjectMigrateHashedStorageWorker" do
Sidekiq::Testing.fake! do
expect { subject.bulk_migrate(start: ids.min, finish: ids.max) }.to change(ProjectMigrateHashedStorageWorker.jobs, :size).by(2)
end
end
- it 'rescues and log exceptions' do
+ it "rescues and log exceptions" do
allow_any_instance_of(Project).to receive(:migrate_to_hashed_storage!).and_raise(StandardError)
expect { subject.bulk_migrate(start: ids.min, finish: ids.max) }.not_to raise_error
end
- it 'delegates each project in specified range to #migrate' do
+ it "delegates each project in specified range to #migrate" do
projects.each do |project|
expect(subject).to receive(:migrate).with(project)
end
@@ -32,7 +32,7 @@ describe Gitlab::HashedStorage::Migrator do
subject.bulk_migrate(start: ids.min, finish: ids.max)
end
- it 'has migrated projects set as writable' do
+ it "has migrated projects set as writable" do
perform_enqueued_jobs do
subject.bulk_migrate(start: ids.min, finish: ids.max)
end
@@ -43,22 +43,22 @@ describe Gitlab::HashedStorage::Migrator do
end
end
- describe '#migrate' do
+ describe "#migrate" do
let(:project) { create(:project, :legacy_storage, :empty_repo) }
- it 'enqueues project migration job' do
+ it "enqueues project migration job" do
Sidekiq::Testing.fake! do
expect { subject.migrate(project) }.to change(ProjectMigrateHashedStorageWorker.jobs, :size).by(1)
end
end
- it 'rescues and log exceptions' do
+ it "rescues and log exceptions" do
allow(project).to receive(:migrate_to_hashed_storage!).and_raise(StandardError)
expect { subject.migrate(project) }.not_to raise_error
end
- it 'migrates project storage' do
+ it "migrates project storage" do
perform_enqueued_jobs do
subject.migrate(project)
end
@@ -66,7 +66,7 @@ describe Gitlab::HashedStorage::Migrator do
expect(project.reload.hashed_storage?(:attachments)).to be_truthy
end
- it 'has migrated project set as writable' do
+ it "has migrated project set as writable" do
perform_enqueued_jobs do
subject.migrate(project)
end
@@ -74,16 +74,16 @@ describe Gitlab::HashedStorage::Migrator do
expect(project.reload.repository_read_only?).to be_falsey
end
- context 'when project is already on hashed storage' do
+ context "when project is already on hashed storage" do
let(:project) { create(:project, :empty_repo) }
- it 'doesnt enqueue any migration job' do
+ it "doesnt enqueue any migration job" do
Sidekiq::Testing.fake! do
expect { subject.migrate(project) }.not_to change(ProjectMigrateHashedStorageWorker.jobs, :size)
end
end
- it 'returns false' do
+ it "returns false" do
expect(subject.migrate(project)).to be_falsey
end
end
diff --git a/spec/lib/gitlab/health_checks/db_check_spec.rb b/spec/lib/gitlab/health_checks/db_check_spec.rb
index 33c6c24449c..378ffd080f1 100644
--- a/spec/lib/gitlab/health_checks/db_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/db_check_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require_relative './simple_check_shared'
+require "spec_helper"
+require_relative "./simple_check_shared"
describe Gitlab::HealthChecks::DbCheck do
- include_examples 'simple_check', 'db_ping', 'Db', '1'
+ include_examples "simple_check", "db_ping", "Db", "1"
end
diff --git a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
index 4912cd48761..73642a866c7 100644
--- a/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/gitaly_check_spec.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HealthChecks::GitalyCheck do
let(:result_class) { Gitlab::HealthChecks::Result }
- let(:repository_storages) { ['default'] }
+ let(:repository_storages) { ["default"] }
before do
allow(described_class).to receive(:repository_storages) { repository_storages }
end
- describe '#readiness' do
+ describe "#readiness" do
subject { described_class.readiness }
before do
expect(Gitlab::GitalyClient::HealthCheckService).to receive(:new).and_return(gitaly_check)
end
- context 'Gitaly server is up' do
- let(:gitaly_check) { double(check: { success: true }) }
+ context "Gitaly server is up" do
+ let(:gitaly_check) { double(check: {success: true}) }
- it { is_expected.to eq([result_class.new(true, nil, shard: 'default')]) }
+ it { is_expected.to eq([result_class.new(true, nil, shard: "default")]) }
end
- context 'Gitaly server is down' do
- let(:gitaly_check) { double(check: { success: false, message: 'Connection refused' }) }
+ context "Gitaly server is down" do
+ let(:gitaly_check) { double(check: {success: false, message: "Connection refused"}) }
- it { is_expected.to eq([result_class.new(false, 'Connection refused', shard: 'default')]) }
+ it { is_expected.to eq([result_class.new(false, "Connection refused", shard: "default")]) }
end
end
- describe '#metrics' do
+ describe "#metrics" do
subject { described_class.metrics }
- let(:server) { double(storage: 'default', read_writeable?: up) }
+ let(:server) { double(storage: "default", read_writeable?: up) }
before do
allow(Gitaly::Server).to receive(:new).and_return(server)
end
- context 'Gitaly server is up' do
+ context "Gitaly server is up" do
let(:up) { true }
- it 'provides metrics' do
- expect(subject).to all(have_attributes(labels: { shard: 'default' }))
- expect(subject).to include(an_object_having_attributes(name: 'gitaly_health_check_success', value: 1))
- expect(subject).to include(an_object_having_attributes(name: 'gitaly_health_check_latency_seconds', value: be >= 0))
+ it "provides metrics" do
+ expect(subject).to all(have_attributes(labels: {shard: "default"}))
+ expect(subject).to include(an_object_having_attributes(name: "gitaly_health_check_success", value: 1))
+ expect(subject).to include(an_object_having_attributes(name: "gitaly_health_check_latency_seconds", value: be >= 0))
end
end
- context 'Gitaly server is down' do
+ context "Gitaly server is down" do
let(:up) { false }
- it 'provides metrics' do
- expect(subject).to include(an_object_having_attributes(name: 'gitaly_health_check_success', value: 0))
- expect(subject).to include(an_object_having_attributes(name: 'gitaly_health_check_latency_seconds', value: be >= 0))
+ it "provides metrics" do
+ expect(subject).to include(an_object_having_attributes(name: "gitaly_health_check_success", value: 0))
+ expect(subject).to include(an_object_having_attributes(name: "gitaly_health_check_latency_seconds", value: be >= 0))
end
end
end
diff --git a/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb b/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb
index ed757ed60d8..a25c3aecfe3 100644
--- a/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb
+++ b/spec/lib/gitlab/health_checks/prometheus_text_format_spec.rb
@@ -2,13 +2,13 @@ describe Gitlab::HealthChecks::PrometheusTextFormat do
let(:metric_class) { Gitlab::HealthChecks::Metric }
subject { described_class.new }
- describe '#marshal' do
+ describe "#marshal" do
let(:sample_metrics) do
- [metric_class.new('metric1', 1),
- metric_class.new('metric2', 2)]
+ [metric_class.new("metric1", 1),
+ metric_class.new("metric2", 2),]
end
- it 'marshal to text with non repeating type definition' do
+ it "marshal to text with non repeating type definition" do
expected = <<-EXPECTED.strip_heredoc
# TYPE metric1 gauge
metric1 1
@@ -19,14 +19,14 @@ describe Gitlab::HealthChecks::PrometheusTextFormat do
expect(subject.marshal(sample_metrics)).to eq(expected)
end
- context 'metrics where name repeats' do
+ context "metrics where name repeats" do
let(:sample_metrics) do
- [metric_class.new('metric1', 1),
- metric_class.new('metric1', 2),
- metric_class.new('metric2', 3)]
+ [metric_class.new("metric1", 1),
+ metric_class.new("metric1", 2),
+ metric_class.new("metric2", 3),]
end
- it 'marshal to text with non repeating type definition' do
+ it "marshal to text with non repeating type definition" do
expected = <<-EXPECTED.strip_heredoc
# TYPE metric1 gauge
metric1 1
diff --git a/spec/lib/gitlab/health_checks/redis/cache_check_spec.rb b/spec/lib/gitlab/health_checks/redis/cache_check_spec.rb
index 3693f52b51b..001cddccfe7 100644
--- a/spec/lib/gitlab/health_checks/redis/cache_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/redis/cache_check_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require_relative '../simple_check_shared'
+require "spec_helper"
+require_relative "../simple_check_shared"
describe Gitlab::HealthChecks::Redis::CacheCheck do
- include_examples 'simple_check', 'redis_cache_ping', 'RedisCache', 'PONG'
+ include_examples "simple_check", "redis_cache_ping", "RedisCache", "PONG"
end
diff --git a/spec/lib/gitlab/health_checks/redis/queues_check_spec.rb b/spec/lib/gitlab/health_checks/redis/queues_check_spec.rb
index c69443d205d..58a73f30163 100644
--- a/spec/lib/gitlab/health_checks/redis/queues_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/redis/queues_check_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require_relative '../simple_check_shared'
+require "spec_helper"
+require_relative "../simple_check_shared"
describe Gitlab::HealthChecks::Redis::QueuesCheck do
- include_examples 'simple_check', 'redis_queues_ping', 'RedisQueues', 'PONG'
+ include_examples "simple_check", "redis_queues_ping", "RedisQueues", "PONG"
end
diff --git a/spec/lib/gitlab/health_checks/redis/redis_check_spec.rb b/spec/lib/gitlab/health_checks/redis/redis_check_spec.rb
index 03afc1cd761..6d45484d5e0 100644
--- a/spec/lib/gitlab/health_checks/redis/redis_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/redis/redis_check_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require_relative '../simple_check_shared'
+require "spec_helper"
+require_relative "../simple_check_shared"
describe Gitlab::HealthChecks::Redis::RedisCheck do
- include_examples 'simple_check', 'redis_ping', 'Redis', 'PONG'
+ include_examples "simple_check", "redis_ping", "Redis", "PONG"
end
diff --git a/spec/lib/gitlab/health_checks/redis/shared_state_check_spec.rb b/spec/lib/gitlab/health_checks/redis/shared_state_check_spec.rb
index b72e152bbe2..45fb2ef6b29 100644
--- a/spec/lib/gitlab/health_checks/redis/shared_state_check_spec.rb
+++ b/spec/lib/gitlab/health_checks/redis/shared_state_check_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require_relative '../simple_check_shared'
+require "spec_helper"
+require_relative "../simple_check_shared"
describe Gitlab::HealthChecks::Redis::SharedStateCheck do
- include_examples 'simple_check', 'redis_shared_state_ping', 'RedisSharedState', 'PONG'
+ include_examples "simple_check", "redis_shared_state_ping", "RedisSharedState", "PONG"
end
diff --git a/spec/lib/gitlab/health_checks/simple_check_shared.rb b/spec/lib/gitlab/health_checks/simple_check_shared.rb
index e2643458aca..dc050504ae7 100644
--- a/spec/lib/gitlab/health_checks/simple_check_shared.rb
+++ b/spec/lib/gitlab/health_checks/simple_check_shared.rb
@@ -1,7 +1,7 @@
-shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
- describe '#metrics' do
+shared_context "simple_check" do |metrics_prefix, check_name, success_result|
+ describe "#metrics" do
subject { described_class.metrics }
- context 'Check is passing' do
+ context "Check is passing" do
before do
allow(described_class).to receive(:check).and_return success_result
end
@@ -11,9 +11,9 @@ shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
it { is_expected.to include(have_attributes(name: "#{metrics_prefix}_latency_seconds", value: be >= 0)) }
end
- context 'Check is misbehaving' do
+ context "Check is misbehaving" do
before do
- allow(described_class).to receive(:check).and_return 'error!'
+ allow(described_class).to receive(:check).and_return "error!"
end
it { is_expected.to include(have_attributes(name: "#{metrics_prefix}_success", value: 0)) }
@@ -21,7 +21,7 @@ shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
it { is_expected.to include(have_attributes(name: "#{metrics_prefix}_latency_seconds", value: be >= 0)) }
end
- context 'Check is timeouting' do
+ context "Check is timeouting" do
before do
allow(described_class).to receive(:check).and_return Timeout::Error.new
end
@@ -32,9 +32,9 @@ shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
end
end
- describe '#readiness' do
+ describe "#readiness" do
subject { described_class.readiness }
- context 'Check returns ok' do
+ context "Check returns ok" do
before do
allow(described_class).to receive(:check).and_return success_result
end
@@ -42,24 +42,24 @@ shared_context 'simple_check' do |metrics_prefix, check_name, success_result|
it { is_expected.to have_attributes(success: true) }
end
- context 'Check is misbehaving' do
+ context "Check is misbehaving" do
before do
- allow(described_class).to receive(:check).and_return 'error!'
+ allow(described_class).to receive(:check).and_return "error!"
end
it { is_expected.to have_attributes(success: false, message: "unexpected #{described_class.human_name} check result: error!") }
end
- context 'Check is timeouting' do
+ context "Check is timeouting" do
before do
- allow(described_class).to receive(:check ).and_return Timeout::Error.new
+ allow(described_class).to receive(:check).and_return Timeout::Error.new
end
it { is_expected.to have_attributes(success: false, message: "#{described_class.human_name} check timed out") }
end
end
- describe '#liveness' do
+ describe "#liveness" do
subject { described_class.readiness }
it { is_expected.to eq(Gitlab::HealthChecks::Result.new(true)) }
end
diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb
index fe0e9702f8a..d63de81666e 100644
--- a/spec/lib/gitlab/highlight_spec.rb
+++ b/spec/lib/gitlab/highlight_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Highlight do
include RepoHelpers
@@ -6,108 +6,108 @@ describe Gitlab::Highlight do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- describe 'language provided' do
+ describe "language provided" do
let(:highlighter) do
- described_class.new('foo.erb', 'bar', language: 'erb?parent=json')
+ described_class.new("foo.erb", "bar", language: "erb?parent=json")
end
- it 'sets correct lexer' do
- expect(highlighter.lexer.tag).to eq 'erb'
- expect(highlighter.lexer.parent.tag).to eq 'json'
+ it "sets correct lexer" do
+ expect(highlighter.lexer.tag).to eq "erb"
+ expect(highlighter.lexer.parent.tag).to eq "json"
end
end
- describe '#highlight' do
- let(:file_name) { 'test.lisp' }
+ describe "#highlight" do
+ let(:file_name) { "test.lisp" }
let(:no_context_content) { ":type \"assem\"))" }
let(:content) { "(make-pathname :defaults name\n#{no_context_content}" }
let(:multiline_content) do
- %q(
+ '
def test(input):
"""This is line 1 of a multi-line comment.
This is line 2.
"""
- )
+ '
end
- it 'highlights' do
- expected = %Q[<span id="LC1" class="line" lang="common_lisp"><span class="p">(</span><span class="nb">make-pathname</span> <span class="ss">:defaults</span> <span class="nv">name</span></span>
+ it "highlights" do
+ expected = %[<span id="LC1" class="line" lang="common_lisp"><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" lang="common_lisp"><span class="ss">:type</span> <span class="s">"assem"</span><span class="p">))</span></span>]
expect(described_class.highlight(file_name, content)).to eq(expected)
end
- it 'returns plain version for unknown lexer context' do
+ it "returns plain version for unknown lexer context" do
result = described_class.highlight(file_name, no_context_content)
expect(result).to eq(%[<span id="LC1" class="line" lang="">:type "assem"))</span>])
end
- it 'returns plain version for long content' do
- stub_const('Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE', 1)
+ it "returns plain version for long content" do
+ stub_const("Gitlab::Highlight::MAXIMUM_TEXT_HIGHLIGHT_SIZE", 1)
result = described_class.highlight(file_name, content)
expect(result).to eq(%[<span id="LC1" class="line" lang="">(make-pathname :defaults name</span>\n<span id="LC2" class="line" lang="">:type "assem"))</span>])
end
- it 'highlights multi-line comments' do
+ it "highlights multi-line comments" do
result = described_class.highlight(file_name, multiline_content)
html = Nokogiri::HTML(result)
- lines = html.search('.s')
+ lines = html.search(".s")
expect(lines.count).to eq(3)
expect(lines[0].text).to eq('"""This is line 1 of a multi-line comment.')
- expect(lines[1].text).to eq(' This is line 2.')
+ expect(lines[1].text).to eq(" This is line 2.")
expect(lines[2].text).to eq(' """')
end
- context 'diff highlighting' do
- let(:file_name) { 'test.diff' }
+ context "diff highlighting" do
+ let(:file_name) { "test.diff" }
let(:content) { "+aaa\n+bbb\n- ccc\n ddd\n"}
let(:expected) do
- %q(<span id="LC1" class="line" lang="diff"><span class="gi">+aaa</span></span>
+ '<span id="LC1" class="line" lang="diff"><span class="gi">+aaa</span></span>
<span id="LC2" class="line" lang="diff"><span class="gi">+bbb</span></span>
<span id="LC3" class="line" lang="diff"><span class="gd">- ccc</span></span>
-<span id="LC4" class="line" lang="diff"> ddd</span>)
+<span id="LC4" class="line" lang="diff"> ddd</span>'
end
- it 'highlights each line properly' do
+ it "highlights each line properly" do
result = described_class.highlight(file_name, content)
expect(result).to eq(expected)
end
end
- describe 'with CRLF' do
- let(:branch) { 'crlf-diff' }
- let(:path) { 'files/whitespace' }
+ describe "with CRLF" do
+ let(:branch) { "crlf-diff" }
+ let(:path) { "files/whitespace" }
let(:blob) { repository.blob_at_branch(branch, path) }
let(:lines) do
described_class.highlight(blob.path, blob.data).lines
end
- it 'strips extra LFs' do
+ it "strips extra LFs" do
expect(lines[0]).to eq("<span id=\"LC1\" class=\"line\" lang=\"plaintext\">test </span>")
end
end
- it 'links dependencies via DependencyLinker' do
+ it "links dependencies via DependencyLinker" do
expect(Gitlab::DependencyLinker).to receive(:link)
- .with('file.name', 'Contents', anything).and_call_original
+ .with("file.name", "Contents", anything).and_call_original
- described_class.highlight('file.name', 'Contents')
+ described_class.highlight("file.name", "Contents")
end
- context 'timeout' do
- subject { described_class.new('file.name', 'Contents') }
+ context "timeout" do
+ subject { described_class.new("file.name", "Contents") }
- it 'utilizes timeout for web' do
+ it "utilizes timeout for web" do
expect(Timeout).to receive(:timeout).with(described_class::TIMEOUT_FOREGROUND).and_call_original
subject.highlight("Content")
end
- it 'utilizes longer timeout for sidekiq' do
+ it "utilizes longer timeout for sidekiq" do
allow(Sidekiq).to receive(:server?).and_return(true)
expect(Timeout).to receive(:timeout).with(described_class::TIMEOUT_BACKGROUND).and_call_original
diff --git a/spec/lib/gitlab/hook_data/base_builder_spec.rb b/spec/lib/gitlab/hook_data/base_builder_spec.rb
index e3c5ee3b905..c8ce11e575a 100644
--- a/spec/lib/gitlab/hook_data/base_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/base_builder_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HookData::BaseBuilder do
- describe '#absolute_image_urls' do
+ describe "#absolute_image_urls" do
let(:subclass) do
Class.new(described_class) do
public :absolute_image_urls
@@ -10,25 +10,25 @@ describe Gitlab::HookData::BaseBuilder do
using RSpec::Parameterized::TableSyntax
- context 'with an upload prefix specified' do
- let(:project_with_path) { double(full_path: 'baz/bar') }
+ context "with an upload prefix specified" do
+ let(:project_with_path) { double(full_path: "baz/bar") }
let(:object_with_project) { double(project: project_with_path) }
subject { subclass.new(object_with_project) }
where do
{
- 'relative image URL' => {
- input: '![an image](foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/foo.png)"
+ "relative image URL" => {
+ input: "![an image](foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/foo.png)",
},
- 'absolute upload URL' => {
- input: '![an image](/uploads/foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/baz/bar/uploads/foo.png)"
+ "absolute upload URL" => {
+ input: "![an image](/uploads/foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/baz/bar/uploads/foo.png)",
+ },
+ "absolute non-upload URL" => {
+ input: "![an image](/downloads/foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/downloads/foo.png)",
},
- 'absolute non-upload URL' => {
- input: '![an image](/downloads/foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/downloads/foo.png)"
- }
}
end
@@ -37,59 +37,59 @@ describe Gitlab::HookData::BaseBuilder do
end
end
- context 'without an upload prefix specified' do
+ context "without an upload prefix specified" do
subject { subclass.new(nil) }
where do
{
- 'relative image URL' => {
- input: '![an image](foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/foo.png)"
+ "relative image URL" => {
+ input: "![an image](foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/foo.png)",
},
- 'absolute upload URL' => {
- input: '![an image](/uploads/foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/uploads/foo.png)"
+ "absolute upload URL" => {
+ input: "![an image](/uploads/foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/uploads/foo.png)",
},
- 'absolute non-upload URL' => {
- input: '![an image](/downloads/foo.png)',
- output: "![an image](#{Gitlab.config.gitlab.url}/downloads/foo.png)"
+ "absolute non-upload URL" => {
+ input: "![an image](/downloads/foo.png)",
+ output: "![an image](#{Gitlab.config.gitlab.url}/downloads/foo.png)",
},
- 'HTTP URL' => {
- input: '![an image](http://example.com/foo.png)',
- output: '![an image](http://example.com/foo.png)'
+ "HTTP URL" => {
+ input: "![an image](http://example.com/foo.png)",
+ output: "![an image](http://example.com/foo.png)",
},
- 'HTTPS URL' => {
- input: '![an image](https://example.com/foo.png)',
- output: '![an image](https://example.com/foo.png)'
+ "HTTPS URL" => {
+ input: "![an image](https://example.com/foo.png)",
+ output: "![an image](https://example.com/foo.png)",
},
- 'protocol-relative URL' => {
- input: '![an image](//example.com/foo.png)',
- output: '![an image](//example.com/foo.png)'
+ "protocol-relative URL" => {
+ input: "![an image](//example.com/foo.png)",
+ output: "![an image](//example.com/foo.png)",
},
- 'URL reference by title' => {
+ "URL reference by title" => {
input: "![foo]\n\n[foo]: foo.png",
- output: "![foo]\n\n[foo]: foo.png"
+ output: "![foo]\n\n[foo]: foo.png",
},
- 'URL reference by label' => {
+ "URL reference by label" => {
input: "![][foo]\n\n[foo]: foo.png",
- output: "![][foo]\n\n[foo]: foo.png"
+ output: "![][foo]\n\n[foo]: foo.png",
},
- 'in Markdown inline code block' => {
- input: '`![an image](foo.png)`',
- output: "`![an image](#{Gitlab.config.gitlab.url}/foo.png)`"
+ "in Markdown inline code block" => {
+ input: "`![an image](foo.png)`",
+ output: "`![an image](#{Gitlab.config.gitlab.url}/foo.png)`",
},
- 'in HTML tag on the same line' => {
- input: '<p>![an image](foo.png)</p>',
- output: "<p>![an image](#{Gitlab.config.gitlab.url}/foo.png)</p>"
+ "in HTML tag on the same line" => {
+ input: "<p>![an image](foo.png)</p>",
+ output: "<p>![an image](#{Gitlab.config.gitlab.url}/foo.png)</p>",
},
- 'in Markdown multi-line code block' => {
+ "in Markdown multi-line code block" => {
input: "```\n![an image](foo.png)\n```",
- output: "```\n![an image](foo.png)\n```"
+ output: "```\n![an image](foo.png)\n```",
},
- 'in HTML tag on different lines' => {
+ "in HTML tag on different lines" => {
input: "<p>\n![an image](foo.png)\n</p>",
- output: "<p>\n![an image](foo.png)\n</p>"
- }
+ output: "<p>\n![an image](foo.png)\n</p>",
+ },
}
end
diff --git a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
index 26529c4759d..9f41302a43d 100644
--- a/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/issuable_builder_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HookData::IssuableBuilder do
set(:user) { create(:user) }
# This shared example requires a `builder` and `user` variable
- shared_examples 'issuable hook data' do |kind|
+ shared_examples "issuable hook data" do |kind|
let(:data) { builder.build(user: user) }
- include_examples 'project hook data' do
+ include_examples "project hook data" do
let(:project) { builder.issuable.project }
end
- include_examples 'deprecated repository hook data'
+ include_examples "deprecated repository hook data"
context "with a #{kind}" do
- it 'contains issuable data' do
+ it "contains issuable data" do
expect(data[:object_kind]).to eq(kind)
expect(data[:user]).to eq(user.hook_attrs)
expect(data[:project]).to eq(builder.issuable.project.hook_attrs)
@@ -22,86 +22,86 @@ describe Gitlab::HookData::IssuableBuilder do
expect(data[:repository]).to eq(builder.issuable.project.hook_attrs.slice(:name, :url, :description, :homepage))
end
- it 'does not contain certain keys' do
+ it "does not contain certain keys" do
expect(data).not_to have_key(:assignees)
expect(data).not_to have_key(:assignee)
end
- describe 'changes are given' do
+ describe "changes are given" do
let(:changes) do
{
cached_markdown_version: %w[foo bar],
- description: ['A description', 'A cool description'],
+ description: ["A description", "A cool description"],
description_html: %w[foo bar],
in_progress_merge_commit_sha: %w[foo bar],
lock_version: %w[foo bar],
merge_jid: %w[foo bar],
- title: ['A title', 'Hello World'],
+ title: ["A title", "Hello World"],
title_html: %w[foo bar],
labels: [
- [{ id: 1, title: 'foo' }],
- [{ id: 1, title: 'foo' }, { id: 2, title: 'bar' }]
+ [{id: 1, title: "foo"}],
+ [{id: 1, title: "foo"}, {id: 2, title: "bar"}],
],
- total_time_spent: [1, 2]
+ total_time_spent: [1, 2],
}
end
let(:data) { builder.build(user: user, changes: changes) }
- it 'populates the :changes hash' do
+ it "populates the :changes hash" do
expect(data[:changes]).to match(hash_including({
- title: { previous: 'A title', current: 'Hello World' },
- description: { previous: 'A description', current: 'A cool description' },
+ title: {previous: "A title", current: "Hello World"},
+ description: {previous: "A description", current: "A cool description"},
labels: {
- previous: [{ id: 1, title: 'foo' }],
- current: [{ id: 1, title: 'foo' }, { id: 2, title: 'bar' }]
+ previous: [{id: 1, title: "foo"}],
+ current: [{id: 1, title: "foo"}, {id: 2, title: "bar"}],
},
total_time_spent: {
previous: 1,
- current: 2
- }
+ current: 2,
+ },
}))
end
- it 'does not contain certain keys' do
- expect(data[:changes]).not_to have_key('cached_markdown_version')
- expect(data[:changes]).not_to have_key('description_html')
- expect(data[:changes]).not_to have_key('lock_version')
- expect(data[:changes]).not_to have_key('title_html')
- expect(data[:changes]).not_to have_key('in_progress_merge_commit_sha')
- expect(data[:changes]).not_to have_key('merge_jid')
+ it "does not contain certain keys" do
+ expect(data[:changes]).not_to have_key("cached_markdown_version")
+ expect(data[:changes]).not_to have_key("description_html")
+ expect(data[:changes]).not_to have_key("lock_version")
+ expect(data[:changes]).not_to have_key("title_html")
+ expect(data[:changes]).not_to have_key("in_progress_merge_commit_sha")
+ expect(data[:changes]).not_to have_key("merge_jid")
end
end
end
end
- describe '#build' do
- it_behaves_like 'issuable hook data', 'issue' do
- let(:issuable) { create(:issue, description: 'A description') }
+ describe "#build" do
+ it_behaves_like "issuable hook data", "issue" do
+ let(:issuable) { create(:issue, description: "A description") }
let(:builder) { described_class.new(issuable) }
end
- it_behaves_like 'issuable hook data', 'merge_request' do
- let(:issuable) { create(:merge_request, description: 'A description') }
+ it_behaves_like "issuable hook data", "merge_request" do
+ let(:issuable) { create(:merge_request, description: "A description") }
let(:builder) { described_class.new(issuable) }
end
- context 'issue is assigned' do
+ context "issue is assigned" do
let(:issue) { create(:issue, assignees: [user]) }
let(:data) { described_class.new(issue).build(user: user) }
- it 'returns correct hook data' do
- expect(data[:object_attributes]['assignee_id']).to eq(user.id)
+ it "returns correct hook data" do
+ expect(data[:object_attributes]["assignee_id"]).to eq(user.id)
expect(data[:assignees].first).to eq(user.hook_attrs)
expect(data).not_to have_key(:assignee)
end
end
- context 'merge_request is assigned' do
+ context "merge_request is assigned" do
let(:merge_request) { create(:merge_request, assignee: user) }
let(:data) { described_class.new(merge_request).build(user: user) }
- it 'returns correct hook data' do
- expect(data[:object_attributes]['assignee_id']).to eq(user.id)
+ it "returns correct hook data" do
+ expect(data[:object_attributes]["assignee_id"]).to eq(user.id)
expect(data[:assignee]).to eq(user.hook_attrs)
expect(data).not_to have_key(:assignees)
end
diff --git a/spec/lib/gitlab/hook_data/issue_builder_spec.rb b/spec/lib/gitlab/hook_data/issue_builder_spec.rb
index f066c0e3813..6c27dcdf4d9 100644
--- a/spec/lib/gitlab/hook_data/issue_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/issue_builder_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HookData::IssueBuilder do
set(:issue) { create(:issue) }
let(:builder) { described_class.new(issue) }
- describe '#build' do
+ describe "#build" do
let(:data) { builder.build }
- it 'includes safe attribute' do
+ it "includes safe attribute" do
%w[
assignee_id
author_id
@@ -34,18 +34,18 @@ describe Gitlab::HookData::IssueBuilder do
end
end
- it 'includes additional attrs' do
+ it "includes additional attrs" do
expect(data).to include(:total_time_spent)
expect(data).to include(:human_time_estimate)
expect(data).to include(:human_total_time_spent)
expect(data).to include(:assignee_ids)
end
- context 'when the issue has an image in the description' do
- let(:issue_with_description) { create(:issue, description: 'test![Issue_Image](/uploads/abc/Issue_Image.png)') }
+ context "when the issue has an image in the description" do
+ let(:issue_with_description) { create(:issue, description: "test![Issue_Image](/uploads/abc/Issue_Image.png)") }
let(:builder) { described_class.new(issue_with_description) }
- it 'sets the image to use an absolute URL' do
+ it "sets the image to use an absolute URL" do
expected_path = "#{issue_with_description.project.path_with_namespace}/uploads/abc/Issue_Image.png"
expect(data[:description])
diff --git a/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb b/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
index 9ce697adbba..0b4023b78ab 100644
--- a/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
+++ b/spec/lib/gitlab/hook_data/merge_request_builder_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HookData::MergeRequestBuilder do
set(:merge_request) { create(:merge_request) }
let(:builder) { described_class.new(merge_request) }
- describe '#build' do
+ describe "#build" do
let(:data) { builder.build }
- it 'includes safe attribute' do
+ it "includes safe attribute" do
%w[
assignee_id
author_id
@@ -41,13 +41,13 @@ describe Gitlab::HookData::MergeRequestBuilder do
%i[source target].each do |key|
describe "#{key} key" do
- include_examples 'project hook data', project_key: key do
+ include_examples "project hook data", project_key: key do
let(:project) { merge_request.public_send("#{key}_project") }
end
end
end
- it 'includes additional attrs' do
+ it "includes additional attrs" do
expect(data).to include(:source)
expect(data).to include(:target)
expect(data).to include(:last_commit)
@@ -57,11 +57,11 @@ describe Gitlab::HookData::MergeRequestBuilder do
expect(data).to include(:human_total_time_spent)
end
- context 'when the MR has an image in the description' do
- let(:mr_with_description) { create(:merge_request, description: 'test![MR_Image](/uploads/abc/MR_Image.png)') }
+ context "when the MR has an image in the description" do
+ let(:mr_with_description) { create(:merge_request, description: "test![MR_Image](/uploads/abc/MR_Image.png)") }
let(:builder) { described_class.new(mr_with_description) }
- it 'sets the image to use an absolute URL' do
+ it "sets the image to use an absolute URL" do
expected_path = "#{mr_with_description.project.path_with_namespace}/uploads/abc/MR_Image.png"
expect(data[:description])
diff --git a/spec/lib/gitlab/http_io_spec.rb b/spec/lib/gitlab/http_io_spec.rb
index 788bddb8f59..0ceb217039d 100644
--- a/spec/lib/gitlab/http_io_spec.rb
+++ b/spec/lib/gitlab/http_io_spec.rb
@@ -1,75 +1,75 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HttpIO do
include HttpIOHelpers
let(:http_io) { described_class.new(url, size) }
- let(:url) { 'http://object-storage/trace' }
- let(:file_path) { expand_fixture_path('trace/sample_trace') }
+ let(:url) { "http://object-storage/trace" }
+ let(:file_path) { expand_fixture_path("trace/sample_trace") }
let(:file_body) { File.read(file_path).force_encoding(Encoding::BINARY) }
let(:size) { File.size(file_path) }
- describe '#close' do
+ describe "#close" do
subject { http_io.close }
it { is_expected.to be_nil }
end
- describe '#binmode' do
+ describe "#binmode" do
subject { http_io.binmode }
it { is_expected.to be_nil }
end
- describe '#binmode?' do
+ describe "#binmode?" do
subject { http_io.binmode? }
it { is_expected.to be_truthy }
end
- describe '#path' do
+ describe "#path" do
subject { http_io.path }
it { is_expected.to be_nil }
end
- describe '#url' do
+ describe "#url" do
subject { http_io.url }
it { is_expected.to eq(url) }
end
- describe '#seek' do
+ describe "#seek" do
subject { http_io.seek(pos, where) }
- context 'when moves pos to end of the file' do
+ context "when moves pos to end of the file" do
let(:pos) { 0 }
let(:where) { IO::SEEK_END }
it { is_expected.to eq(size) }
end
- context 'when moves pos to middle of the file' do
+ context "when moves pos to middle of the file" do
let(:pos) { size / 2 }
let(:where) { IO::SEEK_SET }
it { is_expected.to eq(size / 2) }
end
- context 'when moves pos around' do
- it 'matches the result' do
+ context "when moves pos around" do
+ it "matches the result" do
expect(http_io.seek(0)).to eq(0)
expect(http_io.seek(100, IO::SEEK_CUR)).to eq(100)
- expect { http_io.seek(size + 1, IO::SEEK_CUR) }.to raise_error('new position is outside of file')
+ expect { http_io.seek(size + 1, IO::SEEK_CUR) }.to raise_error("new position is outside of file")
end
end
end
- describe '#eof?' do
+ describe "#eof?" do
subject { http_io.eof? }
- context 'when current pos is at end of the file' do
+ context "when current pos is at end of the file" do
before do
http_io.seek(size, IO::SEEK_SET)
end
@@ -77,7 +77,7 @@ describe Gitlab::HttpIO do
it { is_expected.to be_truthy }
end
- context 'when current pos is not at end of the file' do
+ context "when current pos is not at end of the file" do
before do
http_io.seek(0, IO::SEEK_SET)
end
@@ -86,7 +86,7 @@ describe Gitlab::HttpIO do
end
end
- describe '#each_line' do
+ describe "#each_line" do
subject { http_io.each_line }
let(:string_io) { StringIO.new(file_body) }
@@ -95,18 +95,18 @@ describe Gitlab::HttpIO do
stub_remote_url_206(url, file_path)
end
- it 'yields lines' do
+ it "yields lines" do
expect { |b| http_io.each_line(&b) }.to yield_successive_args(*string_io.each_line.to_a)
end
- context 'when buckets on GCS' do
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when buckets on GCS" do
+ context "when BUFFER_SIZE is larger than file size" do
before do
stub_remote_url_200(url, file_path)
set_larger_buffer_size_than(size)
end
- it 'calls get_chunk only once' do
+ it "calls get_chunk only once" do
expect_any_instance_of(Net::HTTP).to receive(:request).once.and_call_original
http_io.each_line { |line| }
@@ -115,125 +115,125 @@ describe Gitlab::HttpIO do
end
end
- describe '#read' do
+ describe "#read" do
subject { http_io.read(length) }
- context 'when there are no network issue' do
+ context "when there are no network issue" do
before do
stub_remote_url_206(url, file_path)
end
- context 'when read whole size' do
+ context "when read whole size" do
let(:length) { nil }
- context 'when BUFFER_SIZE is smaller than file size' do
+ context "when BUFFER_SIZE is smaller than file size" do
before do
set_smaller_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body)
end
end
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when BUFFER_SIZE is larger than file size" do
before do
set_larger_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body)
end
end
end
- context 'when read only first 100 bytes' do
+ context "when read only first 100 bytes" do
let(:length) { 100 }
- context 'when BUFFER_SIZE is smaller than file size' do
+ context "when BUFFER_SIZE is smaller than file size" do
before do
set_smaller_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body[0, length])
end
end
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when BUFFER_SIZE is larger than file size" do
before do
set_larger_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body[0, length])
end
end
end
- context 'when tries to read oversize' do
+ context "when tries to read oversize" do
let(:length) { size + 1000 }
- context 'when BUFFER_SIZE is smaller than file size' do
+ context "when BUFFER_SIZE is smaller than file size" do
before do
set_smaller_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body)
end
end
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when BUFFER_SIZE is larger than file size" do
before do
set_larger_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to eq(file_body)
end
end
end
- context 'when tries to read 0 bytes' do
+ context "when tries to read 0 bytes" do
let(:length) { 0 }
- context 'when BUFFER_SIZE is smaller than file size' do
+ context "when BUFFER_SIZE is smaller than file size" do
before do
set_smaller_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to be_empty
end
end
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when BUFFER_SIZE is larger than file size" do
before do
set_larger_buffer_size_than(size)
end
- it 'reads a trace' do
+ it "reads a trace" do
is_expected.to be_empty
end
end
end
end
- context 'when there is anetwork issue' do
+ context "when there is anetwork issue" do
let(:length) { nil }
before do
stub_remote_url_500(url)
end
- it 'reads a trace' do
+ it "reads a trace" do
expect { subject }.to raise_error(Gitlab::HttpIO::FailedToGetChunkError)
end
end
end
- describe '#readline' do
+ describe "#readline" do
subject { http_io.readline }
let(:string_io) { StringIO.new(file_body) }
@@ -242,43 +242,43 @@ describe Gitlab::HttpIO do
stub_remote_url_206(url, file_path)
end
- shared_examples 'all line matching' do
- it 'reads a line' do
+ shared_examples "all line matching" do
+ it "reads a line" do
(0...file_body.lines.count).each do
expect(http_io.readline).to eq(string_io.readline)
end
end
end
- context 'when there is anetwork issue' do
+ context "when there is anetwork issue" do
let(:length) { nil }
before do
stub_remote_url_500(url)
end
- it 'reads a trace' do
+ it "reads a trace" do
expect { subject }.to raise_error(Gitlab::HttpIO::FailedToGetChunkError)
end
end
- context 'when BUFFER_SIZE is smaller than file size' do
+ context "when BUFFER_SIZE is smaller than file size" do
before do
set_smaller_buffer_size_than(size)
end
- it_behaves_like 'all line matching'
+ it_behaves_like "all line matching"
end
- context 'when BUFFER_SIZE is larger than file size' do
+ context "when BUFFER_SIZE is larger than file size" do
before do
set_larger_buffer_size_than(size)
end
- it_behaves_like 'all line matching'
+ it_behaves_like "all line matching"
end
- context 'when pos is at middle of the file' do
+ context "when pos is at middle of the file" do
before do
set_smaller_buffer_size_than(size)
@@ -286,31 +286,31 @@ describe Gitlab::HttpIO do
string_io.seek(size / 2)
end
- it 'reads from pos' do
+ it "reads from pos" do
expect(http_io.readline).to eq(string_io.readline)
end
end
end
- describe '#write' do
+ describe "#write" do
subject { http_io.write(nil) }
it { expect { subject }.to raise_error(NotImplementedError) }
end
- describe '#truncate' do
+ describe "#truncate" do
subject { http_io.truncate(nil) }
it { expect { subject }.to raise_error(NotImplementedError) }
end
- describe '#flush' do
+ describe "#flush" do
subject { http_io.flush }
it { expect { subject }.to raise_error(NotImplementedError) }
end
- describe '#present?' do
+ describe "#present?" do
subject { http_io.present? }
it { is_expected.to be_truthy }
diff --git a/spec/lib/gitlab/http_spec.rb b/spec/lib/gitlab/http_spec.rb
index 6c37c157f5d..ecfaf63477e 100644
--- a/spec/lib/gitlab/http_spec.rb
+++ b/spec/lib/gitlab/http_spec.rb
@@ -1,75 +1,75 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::HTTP do
- describe 'allow_local_requests_from_hooks_and_services is' do
+ describe "allow_local_requests_from_hooks_and_services is" do
before do
- WebMock.stub_request(:get, /.*/).to_return(status: 200, body: 'Success')
+ WebMock.stub_request(:get, /.*/).to_return(status: 200, body: "Success")
end
- context 'disabled' do
+ context "disabled" do
before do
allow(Gitlab::CurrentSettings).to receive(:allow_local_requests_from_hooks_and_services?).and_return(false)
end
- it 'deny requests to localhost' do
- expect { described_class.get('http://localhost:3003') }.to raise_error(Gitlab::HTTP::BlockedUrlError)
+ it "deny requests to localhost" do
+ expect { described_class.get("http://localhost:3003") }.to raise_error(Gitlab::HTTP::BlockedUrlError)
end
- it 'deny requests to private network' do
- expect { described_class.get('http://192.168.1.2:3003') }.to raise_error(Gitlab::HTTP::BlockedUrlError)
+ it "deny requests to private network" do
+ expect { described_class.get("http://192.168.1.2:3003") }.to raise_error(Gitlab::HTTP::BlockedUrlError)
end
- context 'if allow_local_requests set to true' do
- it 'override the global value and allow requests to localhost or private network' do
- expect { described_class.get('http://localhost:3003', allow_local_requests: true) }.not_to raise_error
+ context "if allow_local_requests set to true" do
+ it "override the global value and allow requests to localhost or private network" do
+ expect { described_class.get("http://localhost:3003", allow_local_requests: true) }.not_to raise_error
end
end
end
- context 'enabled' do
+ context "enabled" do
before do
allow(Gitlab::CurrentSettings).to receive(:allow_local_requests_from_hooks_and_services?).and_return(true)
end
- it 'allow requests to localhost' do
- expect { described_class.get('http://localhost:3003') }.not_to raise_error
+ it "allow requests to localhost" do
+ expect { described_class.get("http://localhost:3003") }.not_to raise_error
end
- it 'allow requests to private network' do
- expect { described_class.get('http://192.168.1.2:3003') }.not_to raise_error
+ it "allow requests to private network" do
+ expect { described_class.get("http://192.168.1.2:3003") }.not_to raise_error
end
- context 'if allow_local_requests set to false' do
- it 'override the global value and ban requests to localhost or private network' do
- expect { described_class.get('http://localhost:3003', allow_local_requests: false) }.to raise_error(Gitlab::HTTP::BlockedUrlError)
+ context "if allow_local_requests set to false" do
+ it "override the global value and ban requests to localhost or private network" do
+ expect { described_class.get("http://localhost:3003", allow_local_requests: false) }.to raise_error(Gitlab::HTTP::BlockedUrlError)
end
end
end
end
- describe 'handle redirect loops' do
+ describe "handle redirect loops" do
before do
WebMock.stub_request(:any, "http://example.org").to_raise(HTTParty::RedirectionTooDeep.new("Redirection Too Deep"))
end
- it 'handles GET requests' do
- expect { described_class.get('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
+ it "handles GET requests" do
+ expect { described_class.get("http://example.org") }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
end
- it 'handles POST requests' do
- expect { described_class.post('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
+ it "handles POST requests" do
+ expect { described_class.post("http://example.org") }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
end
- it 'handles PUT requests' do
- expect { described_class.put('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
+ it "handles PUT requests" do
+ expect { described_class.put("http://example.org") }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
end
- it 'handles DELETE requests' do
- expect { described_class.delete('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
+ it "handles DELETE requests" do
+ expect { described_class.delete("http://example.org") }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
end
- it 'handles HEAD requests' do
- expect { described_class.head('http://example.org') }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
+ it "handles HEAD requests" do
+ expect { described_class.head("http://example.org") }.to raise_error(Gitlab::HTTP::RedirectionTooDeep)
end
end
end
diff --git a/spec/lib/gitlab/i18n/metadata_entry_spec.rb b/spec/lib/gitlab/i18n/metadata_entry_spec.rb
index a399517cc04..34cbbf8cf02 100644
--- a/spec/lib/gitlab/i18n/metadata_entry_spec.rb
+++ b/spec/lib/gitlab/i18n/metadata_entry_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::I18n::MetadataEntry do
- describe '#expected_forms' do
- it 'returns the number of plurals' do
+ describe "#expected_forms" do
+ it "returns the number of plurals" do
data = {
msgid: "",
msgstr: [
@@ -17,15 +17,15 @@ describe Gitlab::I18n::MetadataEntry do
"Content-Transfer-Encoding: 8bit\\n",
"Plural-Forms: nplurals=2; plural=n != 1;\\n",
"Last-Translator: Bob Van Landuyt <bob@gitlab.com>\\n",
- "X-Generator: Poedit 2.0.2\\n"
- ]
+ "X-Generator: Poedit 2.0.2\\n",
+ ],
}
entry = described_class.new(data)
expect(entry.expected_forms).to eq(2)
end
- it 'returns 0 for the POT-metadata' do
+ it "returns 0 for the POT-metadata" do
data = {
msgid: "",
msgstr: [
@@ -40,8 +40,8 @@ describe Gitlab::I18n::MetadataEntry do
"Content-Transfer-Encoding: 8bit\\n",
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n",
"Last-Translator: Bob Van Landuyt <bob@gitlab.com>\\n",
- "X-Generator: Poedit 2.0.2\\n"
- ]
+ "X-Generator: Poedit 2.0.2\\n",
+ ],
}
entry = described_class.new(data)
diff --git a/spec/lib/gitlab/i18n/po_linter_spec.rb b/spec/lib/gitlab/i18n/po_linter_spec.rb
index 3dbc23d2aaf..5c74efd70b5 100644
--- a/spec/lib/gitlab/i18n/po_linter_spec.rb
+++ b/spec/lib/gitlab/i18n/po_linter_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require 'simple_po_parser'
+require "spec_helper"
+require "simple_po_parser"
# Disabling this cop to allow for multi-language examples in comments
# rubocop:disable Style/AsciiComments
describe Gitlab::I18n::PoLinter do
let(:linter) { described_class.new(po_path) }
- let(:po_path) { 'spec/fixtures/valid.po' }
+ let(:po_path) { "spec/fixtures/valid.po" }
def fake_translation(msgid:, translation:, plural_id: nil, plurals: [])
- data = { msgid: msgid, msgid_plural: plural_id }
+ data = {msgid: msgid, msgid_plural: plural_id}
if plural_id
[translation, *plurals].each_with_index do |plural, index|
@@ -26,147 +26,147 @@ describe Gitlab::I18n::PoLinter do
)
end
- describe '#errors' do
- it 'only calls validation once' do
+ describe "#errors" do
+ it "only calls validation once" do
expect(linter).to receive(:validate_po).once.and_call_original
2.times { linter.errors }
end
end
- describe '#validate_po' do
+ describe "#validate_po" do
subject(:errors) { linter.validate_po }
- context 'for a fuzzy message' do
- let(:po_path) { 'spec/fixtures/fuzzy.po' }
+ context "for a fuzzy message" do
+ let(:po_path) { "spec/fixtures/fuzzy.po" }
- it 'has an error' do
- is_expected.to include('PipelineSchedules|Remove variable row' => ['is marked fuzzy'])
+ it "has an error" do
+ is_expected.to include("PipelineSchedules|Remove variable row" => ["is marked fuzzy"])
end
end
- context 'for a translations with newlines' do
- let(:po_path) { 'spec/fixtures/newlines.po' }
+ context "for a translations with newlines" do
+ let(:po_path) { "spec/fixtures/newlines.po" }
- it 'has an error for a normal string' do
+ it "has an error for a normal string" do
message_id = "You are going to remove %{group_name}.\\nRemoved groups CANNOT be restored!\\nAre you ABSOLUTELY sure?"
expected_message = "is defined over multiple lines, this breaks some tooling."
expect(errors[message_id]).to include(expected_message)
end
- it 'has an error when a translation is defined over multiple lines' do
+ it "has an error when a translation is defined over multiple lines" do
message_id = "You are going to remove %{group_name}.\\nRemoved groups CANNOT be restored!\\nAre you ABSOLUTELY sure?"
expected_message = "has translations defined over multiple lines, this breaks some tooling."
expect(errors[message_id]).to include(expected_message)
end
- it 'raises an error when a plural translation is defined over multiple lines' do
- message_id = 'With plural'
+ it "raises an error when a plural translation is defined over multiple lines" do
+ message_id = "With plural"
expected_message = "has translations defined over multiple lines, this breaks some tooling."
expect(errors[message_id]).to include(expected_message)
end
- it 'raises an error when the plural id is defined over multiple lines' do
- message_id = 'multiline plural id'
+ it "raises an error when the plural id is defined over multiple lines" do
+ message_id = "multiline plural id"
expected_message = "plural is defined over multiple lines, this breaks some tooling."
expect(errors[message_id]).to include(expected_message)
end
end
- context 'with an invalid po' do
- let(:po_path) { 'spec/fixtures/invalid.po' }
+ context "with an invalid po" do
+ let(:po_path) { "spec/fixtures/invalid.po" }
- it 'returns the error' do
- is_expected.to include('PO-syntax errors' => a_kind_of(Array))
+ it "returns the error" do
+ is_expected.to include("PO-syntax errors" => a_kind_of(Array))
end
- it 'does not validate entries' do
+ it "does not validate entries" do
expect(linter).not_to receive(:validate_entries)
linter.validate_po
end
end
- context 'with missing metadata' do
- let(:po_path) { 'spec/fixtures/missing_metadata.po' }
+ context "with missing metadata" do
+ let(:po_path) { "spec/fixtures/missing_metadata.po" }
- it 'returns the an error' do
- is_expected.to include('PO-syntax errors' => a_kind_of(Array))
+ it "returns the an error" do
+ is_expected.to include("PO-syntax errors" => a_kind_of(Array))
end
end
- context 'with a valid po' do
- it 'parses the file' do
+ context "with a valid po" do
+ it "parses the file" do
expect(linter).to receive(:parse_po).and_call_original
linter.validate_po
end
- it 'validates the entries' do
+ it "validates the entries" do
expect(linter).to receive(:validate_entries).and_call_original
linter.validate_po
end
- it 'has no errors' do
+ it "has no errors" do
is_expected.to be_empty
end
end
- context 'with missing plurals' do
- let(:po_path) { 'spec/fixtures/missing_plurals.po' }
+ context "with missing plurals" do
+ let(:po_path) { "spec/fixtures/missing_plurals.po" }
- it 'has errors' do
+ it "has errors" do
is_expected.not_to be_empty
end
end
- context 'with multiple plurals' do
- let(:po_path) { 'spec/fixtures/multiple_plurals.po' }
+ context "with multiple plurals" do
+ let(:po_path) { "spec/fixtures/multiple_plurals.po" }
- it 'has errors' do
+ it "has errors" do
is_expected.not_to be_empty
end
end
- context 'with unescaped chars' do
- let(:po_path) { 'spec/fixtures/unescaped_chars.po' }
+ context "with unescaped chars" do
+ let(:po_path) { "spec/fixtures/unescaped_chars.po" }
- it 'contains an error' do
- message_id = 'You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?'
- expected_error = 'translation contains unescaped `%`, escape it using `%%`'
+ it "contains an error" do
+ message_id = "You are going to transfer %{project_name_with_namespace} to another owner. Are you ABSOLUTELY sure?"
+ expected_error = "translation contains unescaped `%`, escape it using `%%`"
expect(errors[message_id]).to include(expected_error)
end
end
end
- describe '#parse_po' do
- context 'with a valid po' do
- it 'fills in the entries' do
+ describe "#parse_po" do
+ context "with a valid po" do
+ it "fills in the entries" do
linter.parse_po
expect(linter.translation_entries).not_to be_empty
expect(linter.metadata_entry).to be_kind_of(Gitlab::I18n::MetadataEntry)
end
- it 'does not have errors' do
+ it "does not have errors" do
expect(linter.parse_po).to be_nil
end
end
- context 'with an invalid po' do
- let(:po_path) { 'spec/fixtures/invalid.po' }
+ context "with an invalid po" do
+ let(:po_path) { "spec/fixtures/invalid.po" }
- it 'contains an error' do
+ it "contains an error" do
expect(linter.parse_po).not_to be_nil
end
- it 'sets the entries to an empty array' do
+ it "sets the entries to an empty array" do
linter.parse_po
expect(linter.translation_entries).to eq([])
@@ -174,22 +174,22 @@ describe Gitlab::I18n::PoLinter do
end
end
- describe '#validate_entries' do
- it 'keeps track of errors for entries' do
+ describe "#validate_entries" do
+ it "keeps track of errors for entries" do
fake_invalid_entry = fake_translation(msgid: "Hello %{world}",
translation: "Bonjour %{monde}")
allow(linter).to receive(:translation_entries) { [fake_invalid_entry] }
expect(linter).to receive(:validate_entry)
- .with(fake_invalid_entry)
- .and_call_original
+ .with(fake_invalid_entry)
+ .and_call_original
expect(linter.validate_entries).to include("Hello %{world}" => an_instance_of(Array))
end
end
- describe '#validate_entry' do
- it 'validates the flags, variable usage, newlines, and unescaped chars' do
+ describe "#validate_entry" do
+ it "validates the flags, variable usage, newlines, and unescaped chars" do
fake_entry = double
expect(linter).to receive(:validate_flags).with([], fake_entry)
@@ -203,117 +203,117 @@ describe Gitlab::I18n::PoLinter do
end
end
- describe '#validate_number_of_plurals' do
- it 'validates when there are an incorrect number of translations' do
+ describe "#validate_number_of_plurals" do
+ it "validates when there are an incorrect number of translations" do
fake_metadata = double
allow(fake_metadata).to receive(:expected_forms).and_return(2)
allow(linter).to receive(:metadata_entry).and_return(fake_metadata)
fake_entry = Gitlab::I18n::TranslationEntry.new(
- { msgid: 'the singular', msgid_plural: 'the plural', 'msgstr[0]' => 'the singular' },
+ {:msgid => "the singular", :msgid_plural => "the plural", "msgstr[0]" => "the singular"},
2
)
errors = []
linter.validate_number_of_plurals(errors, fake_entry)
- expect(errors).to include('should have 2 translations')
+ expect(errors).to include("should have 2 translations")
end
end
- describe '#validate_variables' do
+ describe "#validate_variables" do
before do
allow(linter).to receive(:validate_variables_in_message).and_call_original
end
- it 'validates both singular and plural in a pluralized string when the entry has a singular' do
+ it "validates both singular and plural in a pluralized string when the entry has a singular" do
pluralized_entry = fake_translation(
- msgid: 'Hello %{world}',
- translation: 'Bonjour %{world}',
- plural_id: 'Hello all %{world}',
- plurals: ['Bonjour tous %{world}']
+ msgid: "Hello %{world}",
+ translation: "Bonjour %{world}",
+ plural_id: "Hello all %{world}",
+ plurals: ["Bonjour tous %{world}"]
)
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello %{world}', 'Bonjour %{world}')
- .and_call_original
+ .with([], "Hello %{world}", "Bonjour %{world}")
+ .and_call_original
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello all %{world}', 'Bonjour tous %{world}')
- .and_call_original
+ .with([], "Hello all %{world}", "Bonjour tous %{world}")
+ .and_call_original
linter.validate_variables([], pluralized_entry)
end
- it 'only validates plural when there is no separate singular' do
+ it "only validates plural when there is no separate singular" do
pluralized_entry = fake_translation(
- msgid: 'Hello %{world}',
- translation: 'Bonjour %{world}',
- plural_id: 'Hello all %{world}'
+ msgid: "Hello %{world}",
+ translation: "Bonjour %{world}",
+ plural_id: "Hello all %{world}"
)
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello all %{world}', 'Bonjour %{world}')
+ .with([], "Hello all %{world}", "Bonjour %{world}")
linter.validate_variables([], pluralized_entry)
end
- it 'validates the message variables' do
- entry = fake_translation(msgid: 'Hello', translation: 'Bonjour')
+ it "validates the message variables" do
+ entry = fake_translation(msgid: "Hello", translation: "Bonjour")
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello', 'Bonjour')
+ .with([], "Hello", "Bonjour")
linter.validate_variables([], entry)
end
- it 'validates variable usage in message ids' do
+ it "validates variable usage in message ids" do
entry = fake_translation(
- msgid: 'Hello %{world}',
- translation: 'Bonjour %{world}',
- plural_id: 'Hello all %{world}',
- plurals: ['Bonjour tous %{world}']
+ msgid: "Hello %{world}",
+ translation: "Bonjour %{world}",
+ plural_id: "Hello all %{world}",
+ plurals: ["Bonjour tous %{world}"]
)
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello %{world}', 'Hello %{world}')
- .and_call_original
+ .with([], "Hello %{world}", "Hello %{world}")
+ .and_call_original
expect(linter).to receive(:validate_variables_in_message)
- .with([], 'Hello all %{world}', 'Hello all %{world}')
- .and_call_original
+ .with([], "Hello all %{world}", "Hello all %{world}")
+ .and_call_original
linter.validate_variables([], entry)
end
end
- describe '#validate_variables_in_message' do
- it 'detects when a variables are used incorrectly' do
+ describe "#validate_variables_in_message" do
+ it "detects when a variables are used incorrectly" do
errors = []
- expected_errors = ['<%d hello %{world} %s> is missing: [%{hello}]',
- '<%d hello %{world} %s> is using unknown variables: [%{world}]',
- 'is combining multiple unnamed variables',
- 'is combining named variables with unnamed variables']
+ expected_errors = ["<%d hello %{world} %s> is missing: [%{hello}]",
+ "<%d hello %{world} %s> is using unknown variables: [%{world}]",
+ "is combining multiple unnamed variables",
+ "is combining named variables with unnamed variables",]
- linter.validate_variables_in_message(errors, '%d %{hello} world %s', '%d hello %{world} %s')
+ linter.validate_variables_in_message(errors, "%d %{hello} world %s", "%d hello %{world} %s")
expect(errors).to include(*expected_errors)
end
- it 'does not allow combining 1 `%d` unnamed variable with named variables' do
+ it "does not allow combining 1 `%d` unnamed variable with named variables" do
errors = []
linter.validate_variables_in_message(errors,
- '%{type} detected %d vulnerability',
- '%{type} detecteerde %d kwetsbaarheid')
+ "%{type} detected %d vulnerability",
+ "%{type} detecteerde %d kwetsbaarheid")
expect(errors).not_to be_empty
end
end
- describe '#validate_translation' do
- let(:entry) { fake_translation(msgid: 'Hello %{world}', translation: 'Bonjour %{world}') }
+ describe "#validate_translation" do
+ let(:entry) { fake_translation(msgid: "Hello %{world}", translation: "Bonjour %{world}") }
- it 'succeeds with valid variables' do
+ it "succeeds with valid variables" do
errors = []
linter.validate_translation(errors, entry)
@@ -321,29 +321,29 @@ describe Gitlab::I18n::PoLinter do
expect(errors).to be_empty
end
- it 'adds an error message when translating fails' do
+ it "adds an error message when translating fails" do
errors = []
- expect(FastGettext::Translation).to receive(:_) { raise 'broken' }
+ expect(FastGettext::Translation).to receive(:_) { raise "broken" }
linter.validate_translation(errors, entry)
- expect(errors).to include('Failure translating to en: broken')
+ expect(errors).to include("Failure translating to en: broken")
end
- it 'adds an error message when translating fails when translating with context' do
- entry = fake_translation(msgid: 'Tests|Hello', translation: 'broken')
+ it "adds an error message when translating fails when translating with context" do
+ entry = fake_translation(msgid: "Tests|Hello", translation: "broken")
errors = []
- expect(FastGettext::Translation).to receive(:s_) { raise 'broken' }
+ expect(FastGettext::Translation).to receive(:s_) { raise "broken" }
linter.validate_translation(errors, entry)
- expect(errors).to include('Failure translating to en: broken')
+ expect(errors).to include("Failure translating to en: broken")
end
it "adds an error when trying to translate with incorrect variables when using unnamed variables" do
- entry = fake_translation(msgid: 'Hello %s', translation: 'Hello %d')
+ entry = fake_translation(msgid: "Hello %s", translation: "Hello %d")
errors = []
linter.validate_translation(errors, entry)
@@ -352,7 +352,7 @@ describe Gitlab::I18n::PoLinter do
end
it "adds an error when trying to translate with named variables when unnamed variables are expected" do
- entry = fake_translation(msgid: 'Hello %s', translation: 'Hello %{thing}')
+ entry = fake_translation(msgid: "Hello %s", translation: "Hello %{thing}")
errors = []
linter.validate_translation(errors, entry)
@@ -360,16 +360,16 @@ describe Gitlab::I18n::PoLinter do
expect(errors.first).to start_with("Failure translating to en")
end
- it 'tests translation for all given forms' do
+ it "tests translation for all given forms" do
# Fake a language that has 3 forms to translate
fake_metadata = double
allow(fake_metadata).to receive(:forms_to_test).and_return(3)
allow(linter).to receive(:metadata_entry).and_return(fake_metadata)
entry = fake_translation(
- msgid: '%d exception',
- translation: '%d uitzondering',
- plural_id: '%d exceptions',
- plurals: ['%d uitzonderingen', '%d uitzonderingetjes']
+ msgid: "%d exception",
+ translation: "%d uitzondering",
+ plural_id: "%d exceptions",
+ plurals: ["%d uitzonderingen", "%d uitzonderingetjes"]
)
# Make each count use a different index
@@ -377,16 +377,16 @@ describe Gitlab::I18n::PoLinter do
allow(linter).to receive(:index_for_pluralization).with(1).and_return(1)
allow(linter).to receive(:index_for_pluralization).with(2).and_return(2)
- expect(FastGettext::Translation).to receive(:n_).with('%d exception', '%d exceptions', 0).and_call_original
- expect(FastGettext::Translation).to receive(:n_).with('%d exception', '%d exceptions', 1).and_call_original
- expect(FastGettext::Translation).to receive(:n_).with('%d exception', '%d exceptions', 2).and_call_original
+ expect(FastGettext::Translation).to receive(:n_).with("%d exception", "%d exceptions", 0).and_call_original
+ expect(FastGettext::Translation).to receive(:n_).with("%d exception", "%d exceptions", 1).and_call_original
+ expect(FastGettext::Translation).to receive(:n_).with("%d exception", "%d exceptions", 2).and_call_original
linter.validate_translation([], entry)
end
end
- describe '#numbers_covering_all_plurals' do
- it 'can correctly find all required numbers to translate to Polish' do
+ describe "#numbers_covering_all_plurals" do
+ it "can correctly find all required numbers to translate to Polish" do
# Polish used as an example with 3 different forms:
# 0, all plurals except the ones ending in 2,3,4: Kotów
# 1: Kot
@@ -395,7 +395,7 @@ describe Gitlab::I18n::PoLinter do
fake_metadata = double
allow(fake_metadata).to receive(:forms_to_test).and_return(4)
allow(linter).to receive(:metadata_entry).and_return(fake_metadata)
- allow(linter).to receive(:locale).and_return('pl_PL')
+ allow(linter).to receive(:locale).and_return("pl_PL")
numbers = linter.numbers_covering_all_plurals
@@ -403,24 +403,24 @@ describe Gitlab::I18n::PoLinter do
end
end
- describe '#fill_in_variables' do
- it 'builds an array for %d translations' do
- result = linter.fill_in_variables(['%d'])
+ describe "#fill_in_variables" do
+ it "builds an array for %d translations" do
+ result = linter.fill_in_variables(["%d"])
expect(result).to contain_exactly(a_kind_of(Integer))
end
- it 'builds an array for %s translations' do
- result = linter.fill_in_variables(['%s'])
+ it "builds an array for %s translations" do
+ result = linter.fill_in_variables(["%s"])
expect(result).to contain_exactly(a_kind_of(String))
end
- it 'builds a hash for named variables' do
- result = linter.fill_in_variables(['%{hello}'])
+ it "builds a hash for named variables" do
+ result = linter.fill_in_variables(["%{hello}"])
expect(result).to be_a(Hash)
- expect(result).to include('hello' => an_instance_of(String))
+ expect(result).to include("hello" => an_instance_of(String))
end
end
end
diff --git a/spec/lib/gitlab/i18n/translation_entry_spec.rb b/spec/lib/gitlab/i18n/translation_entry_spec.rb
index b301e6ea443..0fcac1ffc1d 100644
--- a/spec/lib/gitlab/i18n/translation_entry_spec.rb
+++ b/spec/lib/gitlab/i18n/translation_entry_spec.rb
@@ -1,102 +1,102 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::I18n::TranslationEntry do
- describe '#singular_translation' do
- it 'returns the normal `msgstr` for translations without plural' do
- data = { msgid: 'Hello world', msgstr: 'Bonjour monde' }
+ describe "#singular_translation" do
+ it "returns the normal `msgstr` for translations without plural" do
+ data = {msgid: "Hello world", msgstr: "Bonjour monde"}
entry = described_class.new(data, 2)
- expect(entry.singular_translation).to eq('Bonjour monde')
+ expect(entry.singular_translation).to eq("Bonjour monde")
end
- it 'returns the first string for entries with plurals' do
+ it "returns the first string for entries with plurals" do
data = {
- msgid: 'Hello world',
- msgid_plural: 'Hello worlds',
- 'msgstr[0]' => 'Bonjour monde',
- 'msgstr[1]' => 'Bonjour mondes'
+ :msgid => "Hello world",
+ :msgid_plural => "Hello worlds",
+ "msgstr[0]" => "Bonjour monde",
+ "msgstr[1]" => "Bonjour mondes",
}
entry = described_class.new(data, 2)
- expect(entry.singular_translation).to eq('Bonjour monde')
+ expect(entry.singular_translation).to eq("Bonjour monde")
end
end
- describe '#all_translations' do
- it 'returns all translations for singular translations' do
- data = { msgid: 'Hello world', msgstr: 'Bonjour monde' }
+ describe "#all_translations" do
+ it "returns all translations for singular translations" do
+ data = {msgid: "Hello world", msgstr: "Bonjour monde"}
entry = described_class.new(data, 2)
- expect(entry.all_translations).to eq(['Bonjour monde'])
+ expect(entry.all_translations).to eq(["Bonjour monde"])
end
- it 'returns all translations when including plural translations' do
+ it "returns all translations when including plural translations" do
data = {
- msgid: 'Hello world',
- msgid_plural: 'Hello worlds',
- 'msgstr[0]' => 'Bonjour monde',
- 'msgstr[1]' => 'Bonjour mondes'
+ :msgid => "Hello world",
+ :msgid_plural => "Hello worlds",
+ "msgstr[0]" => "Bonjour monde",
+ "msgstr[1]" => "Bonjour mondes",
}
entry = described_class.new(data, 2)
- expect(entry.all_translations).to eq(['Bonjour monde', 'Bonjour mondes'])
+ expect(entry.all_translations).to eq(["Bonjour monde", "Bonjour mondes"])
end
end
- describe '#plural_translations' do
- it 'returns all translations if there is only one plural' do
+ describe "#plural_translations" do
+ it "returns all translations if there is only one plural" do
data = {
- msgid: 'Hello world',
- msgid_plural: 'Hello worlds',
- 'msgstr[0]' => 'Bonjour monde'
+ :msgid => "Hello world",
+ :msgid_plural => "Hello worlds",
+ "msgstr[0]" => "Bonjour monde",
}
entry = described_class.new(data, 1)
- expect(entry.plural_translations).to eq(['Bonjour monde'])
+ expect(entry.plural_translations).to eq(["Bonjour monde"])
end
- it 'returns all translations except for the first one if there are multiple' do
+ it "returns all translations except for the first one if there are multiple" do
data = {
- msgid: 'Hello world',
- msgid_plural: 'Hello worlds',
- 'msgstr[0]' => 'Bonjour monde',
- 'msgstr[1]' => 'Bonjour mondes',
- 'msgstr[2]' => 'Bonjour tous les mondes'
+ :msgid => "Hello world",
+ :msgid_plural => "Hello worlds",
+ "msgstr[0]" => "Bonjour monde",
+ "msgstr[1]" => "Bonjour mondes",
+ "msgstr[2]" => "Bonjour tous les mondes",
}
entry = described_class.new(data, 3)
- expect(entry.plural_translations).to eq(['Bonjour mondes', 'Bonjour tous les mondes'])
+ expect(entry.plural_translations).to eq(["Bonjour mondes", "Bonjour tous les mondes"])
end
end
- describe '#has_singular_translation?' do
- it 'has a singular when the translation is not pluralized' do
+ describe "#has_singular_translation?" do
+ it "has a singular when the translation is not pluralized" do
data = {
- msgid: 'hello world',
- msgstr: 'hello'
+ msgid: "hello world",
+ msgstr: "hello",
}
entry = described_class.new(data, 2)
expect(entry).to have_singular_translation
end
- it 'has a singular when plural and singular are separately defined' do
+ it "has a singular when plural and singular are separately defined" do
data = {
- msgid: 'hello world',
- msgid_plural: 'hello worlds',
- "msgstr[0]" => 'hello world',
- "msgstr[1]" => 'hello worlds'
+ :msgid => "hello world",
+ :msgid_plural => "hello worlds",
+ "msgstr[0]" => "hello world",
+ "msgstr[1]" => "hello worlds",
}
entry = described_class.new(data, 2)
expect(entry).to have_singular_translation
end
- it 'does not have a separate singular if the plural string only has one translation' do
+ it "does not have a separate singular if the plural string only has one translation" do
data = {
- msgid: 'hello world',
- msgid_plural: 'hello worlds',
- "msgstr[0]" => 'hello worlds'
+ :msgid => "hello world",
+ :msgid_plural => "hello worlds",
+ "msgstr[0]" => "hello worlds",
}
entry = described_class.new(data, 1)
@@ -104,76 +104,76 @@ describe Gitlab::I18n::TranslationEntry do
end
end
- describe '#msgid_contains_newlines' do
- it 'is true when the msgid is an array' do
- data = { msgid: %w(hello world) }
+ describe "#msgid_contains_newlines" do
+ it "is true when the msgid is an array" do
+ data = {msgid: %w[hello world]}
entry = described_class.new(data, 2)
expect(entry.msgid_has_multiple_lines?).to be_truthy
end
end
- describe '#plural_id_contains_newlines' do
- it 'is true when the msgid is an array' do
- data = { msgid_plural: %w(hello world) }
+ describe "#plural_id_contains_newlines" do
+ it "is true when the msgid is an array" do
+ data = {msgid_plural: %w[hello world]}
entry = described_class.new(data, 2)
expect(entry.plural_id_has_multiple_lines?).to be_truthy
end
end
- describe '#translations_contain_newlines' do
- it 'is true when the msgid is an array' do
- data = { msgstr: %w(hello world) }
+ describe "#translations_contain_newlines" do
+ it "is true when the msgid is an array" do
+ data = {msgstr: %w[hello world]}
entry = described_class.new(data, 2)
expect(entry.translations_have_multiple_lines?).to be_truthy
end
end
- describe '#contains_unescaped_chars' do
- let(:data) { { msgid: '' } }
+ describe "#contains_unescaped_chars" do
+ let(:data) { {msgid: ""} }
let(:entry) { described_class.new(data, 2) }
- it 'is true when the msgid is an array' do
- string = '「100%確定」'
+ it "is true when the msgid is an array" do
+ string = "「100%確定」"
expect(entry.contains_unescaped_chars?(string)).to be_truthy
end
- it 'is false when the `%` char is escaped' do
- string = '「100%%確定」'
+ it "is false when the `%` char is escaped" do
+ string = "「100%%確定」"
expect(entry.contains_unescaped_chars?(string)).to be_falsy
end
- it 'is false when using an unnamed variable' do
- string = '「100%d確定」'
+ it "is false when using an unnamed variable" do
+ string = "「100%d確定」"
expect(entry.contains_unescaped_chars?(string)).to be_falsy
end
- it 'is false when using a named variable' do
- string = '「100%{named}確定」'
+ it "is false when using a named variable" do
+ string = "「100%{named}確定」"
expect(entry.contains_unescaped_chars?(string)).to be_falsy
end
- it 'is true when an unnamed variable is not closed' do
- string = '「100%{named確定」'
+ it "is true when an unnamed variable is not closed" do
+ string = "「100%{named確定」"
expect(entry.contains_unescaped_chars?(string)).to be_truthy
end
- it 'is true when the string starts with a `%`' do
- string = '%10'
+ it "is true when the string starts with a `%`" do
+ string = "%10"
expect(entry.contains_unescaped_chars?(string)).to be_truthy
end
end
- describe '#msgid_contains_unescaped_chars' do
- it 'is true when the msgid contains a `%`' do
- data = { msgid: '「100%確定」' }
+ describe "#msgid_contains_unescaped_chars" do
+ it "is true when the msgid contains a `%`" do
+ data = {msgid: "「100%確定」"}
entry = described_class.new(data, 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
@@ -181,9 +181,9 @@ describe Gitlab::I18n::TranslationEntry do
end
end
- describe '#plural_id_contains_unescaped_chars' do
- it 'is true when the plural msgid contains a `%`' do
- data = { msgid_plural: '「100%確定」' }
+ describe "#plural_id_contains_unescaped_chars" do
+ it "is true when the plural msgid contains a `%`" do
+ data = {msgid_plural: "「100%確定」"}
entry = described_class.new(data, 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
@@ -191,9 +191,9 @@ describe Gitlab::I18n::TranslationEntry do
end
end
- describe '#translations_contain_unescaped_chars' do
- it 'is true when the translation contains a `%`' do
- data = { msgstr: '「100%確定」' }
+ describe "#translations_contain_unescaped_chars" do
+ it "is true when the translation contains a `%`" do
+ data = {msgstr: "「100%確定」"}
entry = described_class.new(data, 2)
expect(entry).to receive(:contains_unescaped_chars?).and_call_original
diff --git a/spec/lib/gitlab/i18n_spec.rb b/spec/lib/gitlab/i18n_spec.rb
index 785035d993f..76c9ac73601 100644
--- a/spec/lib/gitlab/i18n_spec.rb
+++ b/spec/lib/gitlab/i18n_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::I18n do
- let(:user) { create(:user, preferred_language: 'es') }
+ let(:user) { create(:user, preferred_language: "es") }
- describe '.locale=' do
+ describe ".locale=" do
after do
described_class.use_default_locale
end
- it 'sets the locale based on current user preferred language' do
+ it "sets the locale based on current user preferred language" do
described_class.locale = user.preferred_language
- expect(FastGettext.locale).to eq('es')
+ expect(FastGettext.locale).to eq("es")
expect(::I18n.locale).to eq(:es)
end
end
- describe '.use_default_locale' do
- it 'resets the locale to the default language' do
+ describe ".use_default_locale" do
+ it "resets the locale to the default language" do
described_class.locale = user.preferred_language
described_class.use_default_locale
- expect(FastGettext.locale).to eq('en')
+ expect(FastGettext.locale).to eq("en")
expect(::I18n.locale).to eq(:en)
end
end
diff --git a/spec/lib/gitlab/identifier_spec.rb b/spec/lib/gitlab/identifier_spec.rb
index 1e583f4cee2..3f0473cad3d 100644
--- a/spec/lib/gitlab/identifier_spec.rb
+++ b/spec/lib/gitlab/identifier_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Identifier do
let(:identifier) do
@@ -9,15 +9,15 @@ describe Gitlab::Identifier do
let(:user) { create(:user) }
let(:key) { create(:key, user: user) }
- describe '#identify' do
- context 'without an identifier' do
- it 'returns nil' do
- expect(identifier.identify('')).to be nil
+ describe "#identify" do
+ context "without an identifier" do
+ it "returns nil" do
+ expect(identifier.identify("")).to be nil
end
end
- context 'with a user identifier' do
- it 'identifies the user using a user ID' do
+ context "with a user identifier" do
+ it "identifies the user using a user ID" do
expect(identifier).to receive(:identify_using_user)
.with("user-#{user.id}")
@@ -25,8 +25,8 @@ describe Gitlab::Identifier do
end
end
- context 'with an SSH key identifier' do
- it 'identifies the user using an SSH key ID' do
+ context "with an SSH key identifier" do
+ it "identifies the user using an SSH key ID" do
expect(identifier).to receive(:identify_using_ssh_key)
.with("key-#{key.id}")
@@ -35,20 +35,20 @@ describe Gitlab::Identifier do
end
end
- describe '#identify_using_user' do
- it 'returns the User for an existing ID in the identifier' do
+ describe "#identify_using_user" do
+ it "returns the User for an existing ID in the identifier" do
found = identifier.identify_using_user("user-#{user.id}")
expect(found).to eq(user)
end
- it 'returns nil for a non existing user ID' do
- found = identifier.identify_using_user('user--1')
+ it "returns nil for a non existing user ID" do
+ found = identifier.identify_using_user("user--1")
expect(found).to be_nil
end
- it 'caches the found users per ID' do
+ it "caches the found users per ID" do
expect(User).to receive(:find_by).once.and_call_original
2.times do
@@ -59,20 +59,20 @@ describe Gitlab::Identifier do
end
end
- describe '#identify_using_ssh_key' do
- it 'returns the User for an existing SSH key' do
+ describe "#identify_using_ssh_key" do
+ it "returns the User for an existing SSH key" do
found = identifier.identify_using_ssh_key("key-#{key.id}")
expect(found).to eq(user)
end
- it 'returns nil for an invalid SSH key' do
- found = identifier.identify_using_ssh_key('key--1')
+ it "returns nil for an invalid SSH key" do
+ found = identifier.identify_using_ssh_key("key--1")
expect(found).to be_nil
end
- it 'caches the found users per key' do
+ it "caches the found users per key" do
expect(User).to receive(:find_by_ssh_key_id).once.and_call_original
2.times do
diff --git a/spec/lib/gitlab/import/database_helpers_spec.rb b/spec/lib/gitlab/import/database_helpers_spec.rb
index e716155b7d5..e7790c91438 100644
--- a/spec/lib/gitlab/import/database_helpers_spec.rb
+++ b/spec/lib/gitlab/import/database_helpers_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Import::DatabaseHelpers do
let(:database_helper) do
@@ -11,12 +11,12 @@ describe Gitlab::Import::DatabaseHelpers do
subject { database_helper.new }
- describe '.insert_and_return_id' do
- let(:attributes) { { iid: 1, title: 'foo' } }
+ describe ".insert_and_return_id" do
+ let(:attributes) { {iid: 1, title: "foo"} }
let(:project) { create(:project) }
- context 'on PostgreSQL' do
- it 'returns the ID returned by the query' do
+ context "on PostgreSQL" do
+ it "returns the ID returned by the query" do
expect(Gitlab::Database)
.to receive(:bulk_insert)
.with(Issue.table_name, [attributes], return_ids: true)
@@ -28,8 +28,8 @@ describe Gitlab::Import::DatabaseHelpers do
end
end
- context 'on MySQL' do
- it 'uses a separate query to retrieve the ID' do
+ context "on MySQL" do
+ it "uses a separate query to retrieve the ID" do
issue = create(:issue, project: project, iid: attributes[:iid])
expect(Gitlab::Database)
diff --git a/spec/lib/gitlab/import/merge_request_creator_spec.rb b/spec/lib/gitlab/import/merge_request_creator_spec.rb
index 7c73e9b39f7..d9072525f65 100644
--- a/spec/lib/gitlab/import/merge_request_creator_spec.rb
+++ b/spec/lib/gitlab/import/merge_request_creator_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Import::MergeRequestCreator do
let(:project) { create(:project, :repository) }
subject { described_class.new(project) }
- describe '#execute' do
- context 'merge request already exists' do
+ describe "#execute" do
+ context "merge request already exists" do
let(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
let(:commits) { merge_request.merge_request_diffs.first.commits }
let(:attributes) { HashWithIndifferentAccess.new(merge_request.attributes.except("merge_params")) }
- it 'updates the data' do
+ it "updates the data" do
commits_count = commits.count
merge_request.merge_request_diffs.destroy_all # rubocop: disable DestroyAll
@@ -26,11 +26,11 @@ describe Gitlab::Import::MergeRequestCreator do
end
end
- context 'new merge request' do
+ context "new merge request" do
let(:merge_request) { build(:merge_request, target_project: project, source_project: project) }
let(:attributes) { HashWithIndifferentAccess.new(merge_request.attributes.except("merge_params")) }
- it 'creates a new merge request' do
+ it "creates a new merge request" do
attributes.delete(:id)
expect { subject.execute(attributes) }.to change { MergeRequest.count }.by(1)
diff --git a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
index 9a442de2900..938c8ecb8d7 100644
--- a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
let!(:service) { described_class.new }
@@ -6,12 +6,12 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
let(:shared) { project.import_export_shared }
let!(:user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
before do
allow(service).to receive(:strategy_execute)
end
- it 'returns if project exported file is not found' do
+ it "returns if project exported file is not found" do
allow(project).to receive(:export_file_exists?).and_return(false)
expect(service).not_to receive(:strategy_execute)
@@ -19,7 +19,7 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
service.execute(user, project)
end
- it 'creates a lock file in the export dir' do
+ it "creates a lock file in the export dir" do
allow(service).to receive(:delete_after_export_lock)
service.execute(user, project)
@@ -27,45 +27,45 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
expect(lock_path_exist?).to be_truthy
end
- context 'when the method succeeds' do
- it 'removes the lock file' do
+ context "when the method succeeds" do
+ it "removes the lock file" do
service.execute(user, project)
expect(lock_path_exist?).to be_falsey
end
end
- context 'when the method fails' do
+ context "when the method fails" do
before do
allow(service).to receive(:strategy_execute).and_call_original
end
- context 'when validation fails' do
+ context "when validation fails" do
before do
allow(service).to receive(:invalid?).and_return(true)
end
- it 'does not create the lock file' do
+ it "does not create the lock file" do
expect(service).not_to receive(:create_or_update_after_export_lock)
service.execute(user, project)
end
- it 'does not execute main logic' do
+ it "does not execute main logic" do
expect(service).not_to receive(:strategy_execute)
service.execute(user, project)
end
- it 'logs validation errors in shared context' do
+ it "logs validation errors in shared context" do
expect(service).to receive(:log_validation_errors)
service.execute(user, project)
end
end
- context 'when an exception is raised' do
- it 'removes the lock' do
+ context "when an exception is raised" do
+ it "removes the lock" do
expect { service.execute(user, project) }.to raise_error(NotImplementedError)
expect(lock_path_exist?).to be_falsey
@@ -74,9 +74,9 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
end
end
- describe '#log_validation_errors' do
- it 'add the message to the shared context' do
- errors = %w(test_message test_message2)
+ describe "#log_validation_errors" do
+ it "add the message to the shared context" do
+ errors = %w[test_message test_message2]
allow(service).to receive(:invalid?).and_return(true)
allow(service.errors).to receive(:full_messages).and_return(errors)
@@ -89,9 +89,9 @@ describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do
end
end
- describe '#to_json' do
- it 'adds the current strategy class to the serialized attributes' do
- params = { param1: 1 }
+ describe "#to_json" do
+ it "adds the current strategy class to the serialized attributes" do
+ params = {param1: 1}
result = params.merge(klass: described_class.to_s).to_json
expect(described_class.new(params).to_json).to eq result
diff --git a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
index ec17ad8541f..34c18b2086d 100644
--- a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do
- let(:example_url) { 'http://www.example.com' }
- let(:strategy) { subject.new(url: example_url, http_method: 'post') }
+ let(:example_url) { "http://www.example.com" }
+ let(:strategy) { subject.new(url: example_url, http_method: "post") }
let!(:project) { create(:project, :with_export) }
let!(:user) { build(:user) }
subject { described_class }
- describe 'validations' do
- it 'only POST and PUT method allowed' do
- %w(POST post PUT put).each do |method|
+ describe "validations" do
+ it "only POST and PUT method allowed" do
+ %w[POST post PUT put].each do |method|
expect(subject.new(url: example_url, http_method: method)).to be_valid
end
- expect(subject.new(url: example_url, http_method: 'whatever')).not_to be_valid
+ expect(subject.new(url: example_url, http_method: "whatever")).not_to be_valid
end
- it 'onyl allow urls as upload urls' do
+ it "onyl allow urls as upload urls" do
expect(subject.new(url: example_url)).to be_valid
- expect(subject.new(url: 'whatever')).not_to be_valid
+ expect(subject.new(url: "whatever")).not_to be_valid
end
end
- describe '#execute' do
- it 'removes the exported project file after the upload' do
+ describe "#execute" do
+ it "removes the exported project file after the upload" do
allow(strategy).to receive(:send_file)
allow(strategy).to receive(:handle_response_error)
diff --git a/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb b/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb
index bf727285a9f..c62acb0a7ea 100644
--- a/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb
+++ b/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AfterExportStrategyBuilder do
- let!(:strategies_namespace) { 'Gitlab::ImportExport::AfterExportStrategies' }
+ let!(:strategies_namespace) { "Gitlab::ImportExport::AfterExportStrategies" }
- describe '.build!' do
- context 'when klass param is' do
- it 'null it returns the default strategy' do
+ describe ".build!" do
+ context "when klass param is" do
+ it "null it returns the default strategy" do
expect(described_class.build!(nil).class).to eq described_class.default_strategy
end
- it 'not a valid class it raises StrategyNotFoundError exception' do
- expect { described_class.build!('Whatever') }.to raise_error(described_class::StrategyNotFoundError)
+ it "not a valid class it raises StrategyNotFoundError exception" do
+ expect { described_class.build!("Whatever") }.to raise_error(described_class::StrategyNotFoundError)
end
- it 'not a descendant of AfterExportStrategy' do
- expect { described_class.build!('User') }.to raise_error(described_class::StrategyNotFoundError)
+ it "not a descendant of AfterExportStrategy" do
+ expect { described_class.build!("User") }.to raise_error(described_class::StrategyNotFoundError)
end
end
- it 'initializes strategy with attributes param' do
- params = { param1: 1, param2: 2, param3: 3 }
+ it "initializes strategy with attributes param" do
+ params = {param1: 1, param2: 2, param3: 3}
strategy = described_class.build!("#{strategies_namespace}::DownloadNotificationStrategy", params)
diff --git a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
index 536cc359d39..6ccd4226259 100644
--- a/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
+++ b/spec/lib/gitlab/import_export/attribute_cleaner_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AttributeCleaner do
- let(:relation_class) { double('relation_class').as_null_object }
+ let(:relation_class) { double("relation_class").as_null_object }
let(:unsafe_hash) do
{
- 'id' => 101,
- 'service_id' => 99,
- 'moved_to_id' => 99,
- 'namespace_id' => 99,
- 'ci_id' => 99,
- 'random_project_id' => 99,
- 'random_id' => 99,
- 'milestone_id' => 99,
- 'project_id' => 99,
- 'user_id' => 99,
- 'random_id_in_the_middle' => 99,
- 'notid' => 99,
- 'import_source' => 'whatever',
- 'import_type' => 'whatever',
- 'non_existent_attr' => 'whatever'
+ "id" => 101,
+ "service_id" => 99,
+ "moved_to_id" => 99,
+ "namespace_id" => 99,
+ "ci_id" => 99,
+ "random_project_id" => 99,
+ "random_id" => 99,
+ "milestone_id" => 99,
+ "project_id" => 99,
+ "user_id" => 99,
+ "random_id_in_the_middle" => 99,
+ "notid" => 99,
+ "import_source" => "whatever",
+ "import_type" => "whatever",
+ "non_existent_attr" => "whatever",
}
end
let(:post_safe_hash) do
{
- 'project_id' => 99,
- 'user_id' => 99,
- 'random_id_in_the_middle' => 99,
- 'notid' => 99
+ "project_id" => 99,
+ "user_id" => 99,
+ "random_id_in_the_middle" => 99,
+ "notid" => 99,
}
end
@@ -37,22 +37,22 @@ describe Gitlab::ImportExport::AttributeCleaner do
before do
allow(relation_class).to receive(:attribute_method?).and_return(true)
- allow(relation_class).to receive(:attribute_method?).with('non_existent_attr').and_return(false)
+ allow(relation_class).to receive(:attribute_method?).with("non_existent_attr").and_return(false)
end
- it 'removes unwanted attributes from the hash' do
+ it "removes unwanted attributes from the hash" do
expect(subject).to eq(post_safe_hash)
end
- it 'removes attributes not present in relation_class' do
- expect(subject.keys).not_to include 'non_existent_attr'
+ it "removes attributes not present in relation_class" do
+ expect(subject.keys).not_to include "non_existent_attr"
end
- it 'removes excluded keys from the hash' do
+ it "removes excluded keys from the hash" do
expect(subject.keys).not_to include excluded_keys
end
- it 'does not remove excluded key if not listed' do
+ it "does not remove excluded key if not listed" do
parsed_hash = described_class.clean(relation_hash: unsafe_hash, relation_class: relation_class)
expect(parsed_hash.keys).to eq post_safe_hash.keys + excluded_keys
diff --git a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
index 87ab81d8169..d204d1d0c8e 100644
--- a/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
+++ b/spec/lib/gitlab/import_export/attribute_configuration_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Part of the test security suite for the Import/Export feature
# Checks whether there are new attributes in models that are currently being exported as part of the
@@ -7,26 +7,26 @@ require 'spec_helper'
# to be included as part of the export, or blacklist them using the import_export.yml configuration file.
# Likewise, new models added to import_export.yml, will need to be added with their correspondent attributes
# to this spec.
-describe 'Import/Export attribute configuration' do
+describe "Import/Export attribute configuration" do
include ConfigurationHelper
let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys }
let(:relation_names) do
- names = names_from_tree(config_hash['project_tree'])
+ names = names_from_tree(config_hash["project_tree"])
# Remove duplicated or add missing models
# - project is not part of the tree, so it has to be added manually.
# - milestone, labels have both singular and plural versions in the tree, so remove the duplicates.
- names.flatten.uniq - %w(milestones labels) + ['project']
+ names.flatten.uniq - %w[milestones labels] + ["project"]
end
- let(:safe_attributes_file) { 'spec/lib/gitlab/import_export/safe_model_attributes.yml' }
+ let(:safe_attributes_file) { "spec/lib/gitlab/import_export/safe_model_attributes.yml" }
let(:safe_model_attributes) { YAML.load_file(safe_attributes_file) }
- let(:ee_safe_attributes_file) { 'ee/spec/lib/gitlab/import_export/safe_model_attributes.yml' }
+ let(:ee_safe_attributes_file) { "ee/spec/lib/gitlab/import_export/safe_model_attributes.yml" }
let(:ee_safe_model_attributes) { File.exist?(ee_safe_attributes_file) ? YAML.load_file(ee_safe_attributes_file) : {} }
- it 'has no new columns' do
+ it "has no new columns" do
relation_names.each do |relation_name|
relation_class = relation_class_for_name(relation_name)
relation_attributes = relation_class.new.attributes.keys
@@ -48,7 +48,7 @@ describe 'Import/Export attribute configuration' do
def failure_message(relation_class, new_attributes)
<<-MSG
- It looks like #{relation_class}, which is exported using the project Import/Export, has new attributes: #{new_attributes.join(',')}
+ It looks like #{relation_class}, which is exported using the project Import/Export, has new attributes: #{new_attributes.join(",")}
Please add the attribute(s) to SAFE_MODEL_ATTRIBUTES if you consider this can be exported.
#{"If the model/associations are EE-specific, use `#{File.expand_path(ee_safe_attributes_file)}`.\n" if ee_safe_model_attributes.any?}
diff --git a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb
index e44ff6bbcbd..e549b386f47 100644
--- a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AvatarRestorer do
include UploadHelpers
@@ -10,29 +10,29 @@ describe Gitlab::ImportExport::AvatarRestorer do
project.remove_avatar!
end
- context 'with avatar' do
+ context "with avatar" do
before do
allow_any_instance_of(described_class).to receive(:avatar_export_file)
- .and_return(uploaded_image_temp_path)
+ .and_return(uploaded_image_temp_path)
end
- it 'restores a project avatar' do
+ it "restores a project avatar" do
expect(described_class.new(project: project, shared: shared).restore).to be true
end
- it 'saves the avatar into the project' do
+ it "saves the avatar into the project" do
described_class.new(project: project, shared: shared).restore
expect(project.reload.avatar.file.exists?).to be true
end
end
- it 'does not break if there is just a directory' do
+ it "does not break if there is just a directory" do
Dir.mktmpdir do |tmpdir|
FileUtils.mkdir_p("#{tmpdir}/a/b")
allow_any_instance_of(described_class).to receive(:avatar_export_path)
- .and_return("#{tmpdir}/a")
+ .and_return("#{tmpdir}/a")
expect(described_class.new(project: project, shared: shared).restore).to be true
end
diff --git a/spec/lib/gitlab/import_export/avatar_saver_spec.rb b/spec/lib/gitlab/import_export/avatar_saver_spec.rb
index 2bd1b9924c6..2b70643dcd7 100644
--- a/spec/lib/gitlab/import_export/avatar_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/avatar_saver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::AvatarSaver do
let(:shared) { project.import_export_shared }
@@ -15,13 +15,13 @@ describe Gitlab::ImportExport::AvatarSaver do
FileUtils.rm_rf("#{shared.export_path}/avatar")
end
- it 'saves a project avatar' do
+ it "saves a project avatar" do
described_class.new(project: project_with_avatar, shared: shared).save
expect(File).to exist(Dir["#{shared.export_path}/avatar/**/dk.png"].first)
end
- it 'is fine not to have an avatar' do
+ it "is fine not to have an avatar" do
expect(described_class.new(project: project, shared: shared).save).to be true
end
end
diff --git a/spec/lib/gitlab/import_export/command_line_util_spec.rb b/spec/lib/gitlab/import_export/command_line_util_spec.rb
index 8e5e0aefac0..f4daac2ab60 100644
--- a/spec/lib/gitlab/import_export/command_line_util_spec.rb
+++ b/spec/lib/gitlab/import_export/command_line_util_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::CommandLineUtil do
include ExportFileHelper
let(:path) { "#{Dir.tmpdir}/symlink_test" }
- let(:archive) { 'spec/fixtures/symlink_export.tar.gz' }
+ let(:archive) { "spec/fixtures/symlink_export.tar.gz" }
let(:shared) { Gitlab::ImportExport::Shared.new(nil) }
subject do
- Class.new do
+ Class.new {
include Gitlab::ImportExport::CommandLineUtil
def initialize
@shared = Gitlab::ImportExport::Shared.new(nil)
end
- end.new
+ }.new
end
before do
@@ -28,11 +28,11 @@ describe Gitlab::ImportExport::CommandLineUtil do
FileUtils.rm_rf(path)
end
- it 'has the right mask for project.json' do
- expect(file_permissions("#{path}/project.json")).to eq(0755) # originally 777
+ it "has the right mask for project.json" do
+ expect(file_permissions("#{path}/project.json")).to eq(0o755) # originally 777
end
- it 'has the right mask for uploads' do
- expect(file_permissions("#{path}/uploads")).to eq(0755) # originally 555
+ it "has the right mask for uploads" do
+ expect(file_permissions("#{path}/uploads")).to eq(0o755) # originally 555
end
end
diff --git a/spec/lib/gitlab/import_export/file_importer_spec.rb b/spec/lib/gitlab/import_export/file_importer_spec.rb
index fbc9bcd2df5..b0798ca0a13 100644
--- a/spec/lib/gitlab/import_export/file_importer_spec.rb
+++ b/spec/lib/gitlab/import_export/file_importer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::FileImporter do
include ExportFileHelper
@@ -13,13 +13,13 @@ describe Gitlab::ImportExport::FileImporter do
let(:custom_mode_symlink_file) { "#{shared.export_path}/symlink.mode" }
before do
- stub_const('Gitlab::ImportExport::FileImporter::MAX_RETRIES', 0)
+ stub_const("Gitlab::ImportExport::FileImporter::MAX_RETRIES", 0)
stub_uploads_object_storage(FileUploader)
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(storage_path)
allow_any_instance_of(Gitlab::ImportExport::CommandLineUtil).to receive(:untar_zxf).and_return(true)
- allow_any_instance_of(Gitlab::ImportExport::Shared).to receive(:relative_archive_path).and_return('test')
- allow(SecureRandom).to receive(:hex).and_return('abcd')
+ allow_any_instance_of(Gitlab::ImportExport::Shared).to receive(:relative_archive_path).and_return("test")
+ allow(SecureRandom).to receive(:hex).and_return("abcd")
setup_files
end
@@ -27,63 +27,63 @@ describe Gitlab::ImportExport::FileImporter do
FileUtils.rm_rf(storage_path)
end
- context 'normal run' do
+ context "normal run" do
before do
- described_class.import(project: build(:project), archive_file: '', shared: shared)
+ described_class.import(project: build(:project), archive_file: "", shared: shared)
end
- it 'removes symlinks in root folder' do
+ it "removes symlinks in root folder" do
expect(File.exist?(symlink_file)).to be false
end
- it 'removes hidden symlinks in root folder' do
+ it "removes hidden symlinks in root folder" do
expect(File.exist?(hidden_symlink_file)).to be false
end
- it 'removes evil symlinks in root folder' do
+ it "removes evil symlinks in root folder" do
expect(File.exist?(evil_symlink_file)).to be false
end
- it 'removes symlinks in subfolders' do
+ it "removes symlinks in subfolders" do
expect(File.exist?(subfolder_symlink_file)).to be false
end
- it 'removes symlinks without any file permissions' do
+ it "removes symlinks without any file permissions" do
expect(File.exist?(custom_mode_symlink_file)).to be false
end
- it 'does not remove a valid file' do
+ it "does not remove a valid file" do
expect(File.exist?(valid_file)).to be true
end
- it 'does not change a valid file permissions' do
- expect(file_permissions(valid_file)).not_to eq(0000)
+ it "does not change a valid file permissions" do
+ expect(file_permissions(valid_file)).not_to eq(0o000)
end
- it 'creates the file in the right subfolder' do
- expect(shared.export_path).to include('test/abcd')
+ it "creates the file in the right subfolder" do
+ expect(shared.export_path).to include("test/abcd")
end
end
- context 'error' do
+ context "error" do
before do
allow_any_instance_of(described_class).to receive(:wait_for_archived_file).and_raise(StandardError)
- described_class.import(project: build(:project), archive_file: '', shared: shared)
+ described_class.import(project: build(:project), archive_file: "", shared: shared)
end
- it 'removes symlinks in root folder' do
+ it "removes symlinks in root folder" do
expect(File.exist?(symlink_file)).to be false
end
- it 'removes hidden symlinks in root folder' do
+ it "removes hidden symlinks in root folder" do
expect(File.exist?(hidden_symlink_file)).to be false
end
- it 'removes symlinks in subfolders' do
+ it "removes symlinks in subfolders" do
expect(File.exist?(subfolder_symlink_file)).to be false
end
- it 'does not remove a valid file' do
+ it "does not remove a valid file" do
expect(File.exist?(valid_file)).to be true
end
end
@@ -96,6 +96,6 @@ describe Gitlab::ImportExport::FileImporter do
FileUtils.ln_s(valid_file, hidden_symlink_file)
FileUtils.ln_s(valid_file, evil_symlink_file)
FileUtils.ln_s(valid_file, custom_mode_symlink_file)
- FileUtils.chmod_R(0000, custom_mode_symlink_file)
+ FileUtils.chmod_R(0o000, custom_mode_symlink_file)
end
end
diff --git a/spec/lib/gitlab/import_export/fork_spec.rb b/spec/lib/gitlab/import_export/fork_spec.rb
index 71fd5a51c3b..a381f0e8c4b 100644
--- a/spec/lib/gitlab/import_export/fork_spec.rb
+++ b/spec/lib/gitlab/import_export/fork_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'forked project import' do
+describe "forked project import" do
include ProjectForksHelper
let(:user) { create(:user) }
- let!(:project_with_repo) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
- let!(:project) { create(:project, name: 'test-repo-restorer-no-repo', path: 'test-repo-restorer-no-repo') }
+ let!(:project_with_repo) { create(:project, :repository, name: "test-repo-restorer", path: "test-repo-restorer") }
+ let!(:project) { create(:project, name: "test-repo-restorer-no-repo", path: "test-repo-restorer-no-repo") }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
let(:forked_from_project) { create(:project, :repository) }
@@ -47,9 +47,9 @@ describe 'forked project import' do
end
end
- it 'can access the MR' do
+ it "can access the MR" do
project.merge_requests.first.fetch_ref!
- expect(project.repository.ref_exists?('refs/merge-requests/1/head')).to be_truthy
+ expect(project.repository.ref_exists?("refs/merge-requests/1/head")).to be_truthy
end
end
diff --git a/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb b/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb
index 6a803c48b34..b8a196b3b71 100644
--- a/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb
+++ b/spec/lib/gitlab/import_export/group_project_object_builder_spec.rb
@@ -1,50 +1,50 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::GroupProjectObjectBuilder do
let(:project) do
create(:project,
- :builds_disabled,
- :issues_disabled,
- name: 'project',
- path: 'project',
- group: create(:group))
+ :builds_disabled,
+ :issues_disabled,
+ name: "project",
+ path: "project",
+ group: create(:group))
end
- context 'labels' do
- it 'finds the right group label' do
- group_label = create(:group_label, 'name': 'group label', 'group': project.group)
+ context "labels" do
+ it "finds the right group label" do
+ group_label = create(:group_label, 'name': "group label", 'group': project.group)
expect(described_class.build(Label,
- 'title' => 'group label',
- 'project' => project,
- 'group' => project.group)).to eq(group_label)
+ "title" => "group label",
+ "project" => project,
+ "group" => project.group)).to eq(group_label)
end
- it 'creates a new label' do
+ it "creates a new label" do
label = described_class.build(Label,
- 'title' => 'group label',
- 'project' => project,
- 'group' => project.group)
+ "title" => "group label",
+ "project" => project,
+ "group" => project.group)
expect(label.persisted?).to be true
end
end
- context 'milestones' do
- it 'finds the right group milestone' do
- milestone = create(:milestone, 'name' => 'group milestone', 'group' => project.group)
+ context "milestones" do
+ it "finds the right group milestone" do
+ milestone = create(:milestone, "name" => "group milestone", "group" => project.group)
expect(described_class.build(Milestone,
- 'title' => 'group milestone',
- 'project' => project,
- 'group' => project.group)).to eq(milestone)
+ "title" => "group milestone",
+ "project" => project,
+ "group" => project.group)).to eq(milestone)
end
- it 'creates a new milestone' do
+ it "creates a new milestone" do
milestone = described_class.build(Milestone,
- 'title' => 'group milestone',
- 'project' => project,
- 'group' => project.group)
+ "title" => "group milestone",
+ "project" => project,
+ "group" => project.group)
expect(milestone.persisted?).to be true
end
diff --git a/spec/lib/gitlab/import_export/hash_util_spec.rb b/spec/lib/gitlab/import_export/hash_util_spec.rb
index 366582dece3..49ec242de80 100644
--- a/spec/lib/gitlab/import_export/hash_util_spec.rb
+++ b/spec/lib/gitlab/import_export/hash_util_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::HashUtil do
- let(:stringified_array) { [{ 'test' => 1 }] }
- let(:stringified_array_with_date) { [{ 'test_date' => '2016-04-06 06:17:44 +0200' }] }
+ let(:stringified_array) { [{"test" => 1}] }
+ let(:stringified_array_with_date) { [{"test_date" => "2016-04-06 06:17:44 +0200"}] }
- describe '.deep_symbolize_array!' do
- it 'symbolizes keys' do
+ describe ".deep_symbolize_array!" do
+ it "symbolizes keys" do
expect { described_class.deep_symbolize_array!(stringified_array) }.to change {
stringified_array.first.keys.first
- }.from('test').to(:test)
+ }.from("test").to(:test)
end
end
- describe '.deep_symbolize_array_with_date!' do
- it 'symbolizes keys' do
+ describe ".deep_symbolize_array_with_date!" do
+ it "symbolizes keys" do
expect { described_class.deep_symbolize_array_with_date!(stringified_array_with_date) }.to change {
stringified_array_with_date.first.keys.first
- }.from('test_date').to(:test_date)
+ }.from("test_date").to(:test_date)
end
- it 'transforms date strings into Time objects' do
+ it "transforms date strings into Time objects" do
expect { described_class.deep_symbolize_array_with_date!(stringified_array_with_date) }.to change {
stringified_array_with_date.first.values.first.class
}.from(String).to(ActiveSupport::TimeWithZone)
diff --git a/spec/lib/gitlab/import_export/import_export_spec.rb b/spec/lib/gitlab/import_export/import_export_spec.rb
index 40a5f2294a2..c7e92a8bce4 100644
--- a/spec/lib/gitlab/import_export/import_export_spec.rb
+++ b/spec/lib/gitlab/import_export/import_export_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport do
- describe 'export filename' do
+ describe "export filename" do
let(:group) { create(:group, :nested) }
- let(:project) { create(:project, :public, path: 'project-path', namespace: group) }
+ let(:project) { create(:project, :public, path: "project-path", namespace: group) }
- it 'contains the project path' do
+ it "contains the project path" do
expect(described_class.export_filename(project: project)).to include(project.path)
end
- it 'contains the namespace path' do
- expect(described_class.export_filename(project: project)).to include(project.namespace.full_path.tr('/', '_'))
+ it "contains the namespace path" do
+ expect(described_class.export_filename(project: project)).to include(project.namespace.full_path.tr("/", "_"))
end
- it 'does not go over a certain length' do
- project.path = 'a' * 100
+ it "does not go over a certain length" do
+ project.path = "a" * 100
expect(described_class.export_filename(project: project).length).to be < 70
end
diff --git a/spec/lib/gitlab/import_export/importer_spec.rb b/spec/lib/gitlab/import_export/importer_spec.rb
index 898e4d07760..d77212cdbfa 100644
--- a/spec/lib/gitlab/import_export/importer_spec.rb
+++ b/spec/lib/gitlab/import_export/importer_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::Importer do
let(:user) { create(:user) }
let(:test_path) { "#{Dir.tmpdir}/importer_spec" }
let(:shared) { project.import_export_shared }
let(:project) { create(:project) }
- let(:import_file) { fixture_file_upload('spec/features/projects/import_export/test_project_export.tar.gz') }
+ let(:import_file) { fixture_file_upload("spec/features/projects/import_export/test_project_export.tar.gz") }
subject(:importer) { described_class.new(project) }
@@ -22,33 +22,33 @@ describe Gitlab::ImportExport::Importer do
FileUtils.rm_rf(test_path)
end
- describe '#execute' do
- it 'succeeds' do
+ describe "#execute" do
+ it "succeeds" do
importer.execute
expect(shared.errors).to be_empty
end
- it 'extracts the archive' do
+ it "extracts the archive" do
expect(Gitlab::ImportExport::FileImporter).to receive(:import).and_call_original
importer.execute
end
- it 'checks the version' do
+ it "checks the version" do
expect(Gitlab::ImportExport::VersionChecker).to receive(:check!).and_call_original
importer.execute
end
- context 'all restores are executed' do
+ context "all restores are executed" do
[
Gitlab::ImportExport::AvatarRestorer,
Gitlab::ImportExport::RepoRestorer,
Gitlab::ImportExport::WikiRestorer,
Gitlab::ImportExport::UploadsRestorer,
Gitlab::ImportExport::LfsRestorer,
- Gitlab::ImportExport::StatisticsRestorer
+ Gitlab::ImportExport::StatisticsRestorer,
].each do |restorer|
it "calls the #{restorer}" do
fake_restorer = double(restorer.to_s)
@@ -60,13 +60,13 @@ describe Gitlab::ImportExport::Importer do
end
end
- it 'restores the ProjectTree' do
+ it "restores the ProjectTree" do
expect(Gitlab::ImportExport::ProjectTreeRestorer).to receive(:new).and_call_original
importer.execute
end
- it 'removes the import file' do
+ it "removes the import file" do
expect(importer).to receive(:remove_import_file).and_call_original
importer.execute
@@ -74,9 +74,9 @@ describe Gitlab::ImportExport::Importer do
expect(project.import_export_upload.import_file&.file).to be_nil
end
- it 'sets the correct visibility_level when visibility level is a string' do
+ it "sets the correct visibility_level when visibility level is a string" do
project.create_or_update_import_data(
- data: { override_params: { visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s } }
+ data: {override_params: {visibility_level: Gitlab::VisibilityLevel::PRIVATE.to_s}}
)
importer.execute
@@ -85,9 +85,9 @@ describe Gitlab::ImportExport::Importer do
end
end
- context 'when project successfully restored' do
+ context "when project successfully restored" do
let!(:existing_project) { create(:project, namespace: user.namespace) }
- let(:project) { create(:project, namespace: user.namespace, name: 'whatever', path: 'whatever') }
+ let(:project) { create(:project, namespace: user.namespace, name: "whatever", path: "whatever") }
before do
restorers = double(:restorers, all?: true)
@@ -95,24 +95,24 @@ describe Gitlab::ImportExport::Importer do
allow(subject).to receive(:import_file).and_return(true)
allow(subject).to receive(:check_version!).and_return(true)
allow(subject).to receive(:restorers).and_return(restorers)
- allow(project).to receive(:import_data).and_return(double(data: { 'original_path' => existing_project.path }))
+ allow(project).to receive(:import_data).and_return(double(data: {"original_path" => existing_project.path}))
end
- context 'when import_data' do
- context 'has original_path' do
- it 'overwrites existing project' do
+ context "when import_data" do
+ context "has original_path" do
+ it "overwrites existing project" do
expect_any_instance_of(::Projects::OverwriteProjectService).to receive(:execute).with(existing_project)
subject.execute
end
end
- context 'has not original_path' do
+ context "has not original_path" do
before do
allow(project).to receive(:import_data).and_return(double(data: {}))
end
- it 'does not call the overwrite service' do
+ it "does not call the overwrite service" do
expect_any_instance_of(::Projects::OverwriteProjectService).not_to receive(:execute).with(existing_project)
subject.execute
diff --git a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb
index 70eeb9ee66b..9e96ec3412e 100644
--- a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::LfsRestorer do
include UploadHelpers
@@ -17,12 +17,12 @@ describe Gitlab::ImportExport::LfsRestorer do
FileUtils.rm_rf(shared.export_path)
end
- describe '#restore' do
- context 'when the archive contains lfs files' do
- let(:dummy_lfs_file_path) { File.join(shared.export_path, 'lfs-objects', 'dummy') }
+ describe "#restore" do
+ context "when the archive contains lfs files" do
+ let(:dummy_lfs_file_path) { File.join(shared.export_path, "lfs-objects", "dummy") }
def create_lfs_object_with_content(content)
- dummy_lfs_file = Tempfile.new('existing')
+ dummy_lfs_file = Tempfile.new("existing")
File.write(dummy_lfs_file.path, content)
size = dummy_lfs_file.size
oid = LfsObject.calculate_oid(dummy_lfs_file.path)
@@ -31,42 +31,42 @@ describe Gitlab::ImportExport::LfsRestorer do
before do
FileUtils.mkdir_p(File.dirname(dummy_lfs_file_path))
- File.write(dummy_lfs_file_path, 'not very large')
+ File.write(dummy_lfs_file_path, "not very large")
allow(restorer).to receive(:lfs_file_paths).and_return([dummy_lfs_file_path])
end
- it 'creates an lfs object for the project' do
+ it "creates an lfs object for the project" do
expect { restorer.restore }.to change { project.reload.lfs_objects.size }.by(1)
end
- it 'assigns the file correctly' do
+ it "assigns the file correctly" do
restorer.restore
- expect(project.lfs_objects.first.file.read).to eq('not very large')
+ expect(project.lfs_objects.first.file.read).to eq("not very large")
end
- it 'links an existing LFS object if it existed' do
- lfs_object = create_lfs_object_with_content('not very large')
+ it "links an existing LFS object if it existed" do
+ lfs_object = create_lfs_object_with_content("not very large")
restorer.restore
expect(project.lfs_objects).to include(lfs_object)
end
- it 'succeeds' do
+ it "succeeds" do
expect(restorer.restore).to be_truthy
expect(shared.errors).to be_empty
end
- it 'stores the upload' do
+ it "stores the upload" do
expect_any_instance_of(LfsObjectUploader).to receive(:store!)
restorer.restore
end
end
- context 'without any LFS-objects' do
- it 'succeeds' do
+ context "without any LFS-objects" do
+ it "succeeds" do
expect(restorer.restore).to be_truthy
expect(shared.errors).to be_empty
end
diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
index 9b0e21deb2e..d0ff8d0549c 100644
--- a/spec/lib/gitlab/import_export/lfs_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::LfsSaver do
let(:shared) { project.import_export_shared }
@@ -16,46 +16,46 @@ describe Gitlab::ImportExport::LfsSaver do
FileUtils.rm_rf(shared.export_path)
end
- describe '#save' do
- context 'when the project has LFS objects locally stored' do
+ describe "#save" do
+ context "when the project has LFS objects locally stored" do
let(:lfs_object) { create(:lfs_object, :with_file) }
before do
project.lfs_objects << lfs_object
end
- it 'does not cause errors' do
+ it "does not cause errors" do
saver.save
expect(shared.errors).to be_empty
end
- it 'copies the file in the correct location when there is an lfs object' do
+ it "copies the file in the correct location when there is an lfs object" do
saver.save
expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}")
end
end
- context 'when the LFS objects are stored in object storage' do
+ context "when the LFS objects are stored in object storage" do
let(:lfs_object) { create(:lfs_object, :object_storage) }
before do
allow(LfsObjectUploader).to receive(:object_store_enabled?).and_return(true)
- allow(lfs_object.file).to receive(:url).and_return('http://my-object-storage.local')
+ allow(lfs_object.file).to receive(:url).and_return("http://my-object-storage.local")
project.lfs_objects << lfs_object
end
- it 'downloads the file to include in an archive' do
+ it "downloads the file to include in an archive" do
fake_uri = double
exported_file_path = "#{shared.export_path}/lfs-objects/#{lfs_object.oid}"
- expect(fake_uri).to receive(:open).and_return(StringIO.new('LFS file content'))
- expect(URI).to receive(:parse).with('http://my-object-storage.local').and_return(fake_uri)
+ expect(fake_uri).to receive(:open).and_return(StringIO.new("LFS file content"))
+ expect(URI).to receive(:parse).with("http://my-object-storage.local").and_return(fake_uri)
saver.save
- expect(File.read(exported_file_path)).to eq('LFS file content')
+ expect(File.read(exported_file_path)).to eq("LFS file content")
end
end
end
diff --git a/spec/lib/gitlab/import_export/members_mapper_spec.rb b/spec/lib/gitlab/import_export/members_mapper_spec.rb
index 67e4c289906..291b0547962 100644
--- a/spec/lib/gitlab/import_export/members_mapper_spec.rb
+++ b/spec/lib/gitlab/import_export/members_mapper_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::MembersMapper do
- describe 'map members' do
+ describe "map members" do
let(:user) { create(:admin) }
- let(:project) { create(:project, :public, name: 'searchable_project') }
+ let(:project) { create(:project, :public, name: "searchable_project") }
let(:user2) { create(:user) }
let(:exported_user_id) { 99 }
let(:exported_members) do
[{
- "id" => 2,
- "access_level" => 40,
- "source_id" => 14,
- "source_type" => "Project",
- "user_id" => 19,
- "notification_level" => 3,
- "created_at" => "2016-03-11T10:21:44.822Z",
- "updated_at" => "2016-03-11T10:21:44.822Z",
- "created_by_id" => nil,
- "invite_email" => nil,
- "invite_token" => nil,
- "invite_accepted_at" => nil,
- "user" =>
+ "id" => 2,
+ "access_level" => 40,
+ "source_id" => 14,
+ "source_type" => "Project",
+ "user_id" => 19,
+ "notification_level" => 3,
+ "created_at" => "2016-03-11T10:21:44.822Z",
+ "updated_at" => "2016-03-11T10:21:44.822Z",
+ "created_by_id" => nil,
+ "invite_email" => nil,
+ "invite_token" => nil,
+ "invite_accepted_at" => nil,
+ "user" =>
{
"id" => exported_user_id,
"email" => user2.email,
- "username" => 'test'
- }
- },
+ "username" => "test",
+ },
+ },
{
"id" => 3,
"access_level" => 40,
@@ -37,104 +37,107 @@ describe Gitlab::ImportExport::MembersMapper do
"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
- }]
+ "invite_email" => "invite@test.com",
+ "invite_token" => "token",
+ "invite_accepted_at" => nil,
+ },]
end
let(:members_mapper) do
described_class.new(
- exported_members: exported_members, user: user, project: project)
+ exported_members: exported_members, user: user, project: project
+ )
end
- it 'includes the exported user ID in the map' do
+ it "includes the exported user ID in the map" do
expect(members_mapper.map.keys).to include(exported_user_id)
end
- it 'maps a project member' do
+ it "maps a project member" do
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end
- it 'defaults to importer project member if it does not exist' do
+ it "defaults to importer project member if it does not exist" do
expect(members_mapper.map[-1]).to eq(user.id)
end
- it 'has invited members with no user' do
+ it "has invited members with no user" do
members_mapper.map
- expect(ProjectMember.find_by_invite_email('invite@test.com')).not_to be_nil
+ expect(ProjectMember.find_by_invite_email("invite@test.com")).not_to be_nil
end
- it 'authorizes the users to the project' do
+ it "authorizes the users to the project" do
members_mapper.map
expect(user.authorized_project?(project)).to be true
expect(user2.authorized_project?(project)).to be true
end
- context 'user is not an admin' do
+ context "user is not an admin" do
let(:user) { create(:user) }
- it 'does not map a project member' do
+ it "does not map a project member" do
expect(members_mapper.map[exported_user_id]).to eq(user.id)
end
- it 'defaults to importer project member if it does not exist' do
+ it "defaults to importer project member if it does not exist" do
expect(members_mapper.map[-1]).to eq(user.id)
end
end
- context 'chooses the one with an email first' do
- let(:user3) { create(:user, username: 'test') }
+ context "chooses the one with an email first" do
+ let(:user3) { create(:user, username: "test") }
- it 'maps the project member that has a matching email first' do
+ it "maps the project member that has a matching email first" do
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end
end
- context 'importer same as group member' do
+ context "importer same as group member" do
let(:user2) { create(:admin) }
let(:group) { create(:group) }
- let(:project) { create(:project, :public, name: 'searchable_project', namespace: group) }
+ let(:project) { create(:project, :public, name: "searchable_project", namespace: group) }
let(:members_mapper) do
described_class.new(
- exported_members: exported_members, user: user2, project: project)
+ exported_members: exported_members, user: user2, project: project
+ )
end
before do
group.add_users([user, user2], GroupMember::DEVELOPER)
end
- it 'maps the project member' do
+ it "maps the project member" do
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end
- it 'maps the project member if it already exists' do
+ it "maps the project member if it already exists" do
project.add_maintainer(user2)
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end
end
- context 'importing group members' do
+ context "importing group members" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:members_mapper) do
described_class.new(
- exported_members: exported_members, user: user, project: project)
+ exported_members: exported_members, user: user, project: project
+ )
end
before do
group.add_users([user, user2], GroupMember::DEVELOPER)
- user.update(email: 'invite@test.com')
+ user.update(email: "invite@test.com")
end
- it 'maps the importer' do
+ it "maps the importer" do
expect(members_mapper.map[-1]).to eq(user.id)
end
- it 'maps the group member' do
+ it "maps the group member" do
expect(members_mapper.map[exported_user_id]).to eq(user2.id)
end
end
diff --git a/spec/lib/gitlab/import_export/merge_request_parser_spec.rb b/spec/lib/gitlab/import_export/merge_request_parser_spec.rb
index 68eaa70e6b6..b7c0b16589c 100644
--- a/spec/lib/gitlab/import_export/merge_request_parser_spec.rb
+++ b/spec/lib/gitlab/import_export/merge_request_parser_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::MergeRequestParser do
include ProjectForksHelper
let(:user) { create(:user) }
- let!(:project) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
+ let!(:project) { create(:project, :repository, name: "test-repo-restorer", path: "test-repo-restorer") }
let(:forked_project) { fork_project(project) }
let!(:merge_request) do
@@ -13,9 +13,9 @@ describe Gitlab::ImportExport::MergeRequestParser do
let(:parsed_merge_request) do
described_class.new(project,
- 'abcd',
- merge_request,
- merge_request.as_json).parse!
+ "abcd",
+ merge_request,
+ merge_request.as_json).parse!
end
after do
@@ -24,15 +24,15 @@ describe Gitlab::ImportExport::MergeRequestParser do
end
end
- it 'has a source branch' do
+ it "has a source branch" do
expect(project.repository.branch_exists?(parsed_merge_request.source_branch)).to be true
end
- it 'has a target branch' do
+ it "has a target branch" do
expect(project.repository.branch_exists?(parsed_merge_request.target_branch)).to be true
end
- it 'parses a MR that has no source branch' do
+ it "parses a MR that has no source branch" do
allow_any_instance_of(described_class).to receive(:branch_exists?).and_call_original
allow_any_instance_of(described_class).to receive(:branch_exists?).with(merge_request.source_branch).and_return(false)
allow_any_instance_of(described_class).to receive(:fork_merge_request?).and_return(true)
diff --git a/spec/lib/gitlab/import_export/model_configuration_spec.rb b/spec/lib/gitlab/import_export/model_configuration_spec.rb
index 2e28f978c3a..c8120f1e344 100644
--- a/spec/lib/gitlab/import_export/model_configuration_spec.rb
+++ b/spec/lib/gitlab/import_export/model_configuration_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
# Part of the test security suite for the Import/Export feature
# Finds if a new model has been added that can potentially be part of the Import/Export
# If it finds a new model, it will show a +failure_message+ with the options available.
-describe 'Import/Export model configuration' do
+describe "Import/Export model configuration" do
include ConfigurationHelper
let(:config_hash) { YAML.load_file(Gitlab::ImportExport.config_file).deep_stringify_keys }
let(:model_names) do
- names = names_from_tree(config_hash['project_tree'])
+ names = names_from_tree(config_hash["project_tree"])
# Remove duplicated or add missing models
# - project is not part of the tree, so it has to be added manually.
# - milestone, labels have both singular and plural versions in the tree, so remove the duplicates.
# - User, Author... Models we do not care about for checking models
- names.flatten.uniq - %w(milestones labels user author) + ['project']
+ names.flatten.uniq - %w[milestones labels user author] + ["project"]
end
- let(:ce_models_yml) { 'spec/lib/gitlab/import_export/all_models.yml' }
+ let(:ce_models_yml) { "spec/lib/gitlab/import_export/all_models.yml" }
let(:ce_models_hash) { YAML.load_file(ce_models_yml) }
- let(:ee_models_yml) { 'ee/spec/lib/gitlab/import_export/all_models.yml' }
+ let(:ee_models_yml) { "ee/spec/lib/gitlab/import_export/all_models.yml" }
let(:ee_models_hash) { File.exist?(ee_models_yml) ? YAML.load_file(ee_models_yml) : {} }
let(:current_models) { setup_models }
@@ -37,7 +37,7 @@ describe 'Import/Export model configuration' do
all_models_hash
end
- it 'has no new models' do
+ it "has no new models" do
model_names.each do |model_name|
new_models = Array(current_models[model_name]) - Array(all_models_hash[model_name])
expect(new_models).to be_empty, failure_message(model_name.classify, new_models)
@@ -48,13 +48,13 @@ describe 'Import/Export model configuration' do
# {model: [model_2, model3], ...}
def setup_models
model_names.each_with_object({}) do |model_name, hash|
- hash[model_name] = associations_for(relation_class_for_name(model_name)) - ['project']
+ hash[model_name] = associations_for(relation_class_for_name(model_name)) - ["project"]
end
end
def failure_message(parent_model_name, new_models)
<<~MSG
- New model(s) <#{new_models.join(',')}> have been added, related to #{parent_model_name}, which is exported by
+ New model(s) <#{new_models.join(",")}> have been added, related to #{parent_model_name}, which is exported by
the Import/Export feature.
If you think this model should be included in the export, please add it to `#{Gitlab::ImportExport.config_file}`.
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 6084dc96410..10573c4b043 100644
--- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
include ImportExport::CommonUtil
describe Gitlab::ImportExport::ProjectTreeRestorer do
- describe 'restore project tree' do
+ describe "restore project tree" do
before(:context) do
# Using an admin for import, so we can check assignment of existing members
@user = create(:admin)
@existing_members = [
- create(:user, username: 'bernard_willms'),
- create(:user, username: 'saul_will')
+ create(:user, username: "bernard_willms"),
+ create(:user, username: "saul_will"),
]
RSpec::Mocks.with_temporary_scope do
- @project = create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project')
+ @project = create(:project, :builds_enabled, :issues_disabled, name: "project", path: "project")
@shared = @project.import_export_shared
- allow(@shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/')
+ allow(@shared).to receive(:export_path).and_return("spec/lib/gitlab/import_export/")
allow_any_instance_of(Repository).to receive(:fetch_source_branch!).and_return(true)
allow_any_instance_of(Gitlab::Git::Repository).to receive(:branch_exists?).and_return(false)
- expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with('feature', 'DCBA')
+ expect_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch).with("feature", "DCBA")
allow_any_instance_of(Gitlab::Git::Repository).to receive(:create_branch)
project_tree_restorer = described_class.new(user: @user, shared: @shared, project: @project)
- expect(Gitlab::ImportExport::RelationFactory).to receive(:create).with(hash_including(excluded_keys: ['whatever'])).and_call_original.at_least(:once)
- allow(project_tree_restorer).to receive(:excluded_keys_for_relation).and_return(['whatever'])
+ expect(Gitlab::ImportExport::RelationFactory).to receive(:create).with(hash_including(excluded_keys: ["whatever"])).and_call_original.at_least(:once)
+ allow(project_tree_restorer).to receive(:excluded_keys_for_relation).and_return(["whatever"])
@restored_project_json = project_tree_restorer.restore
end
end
- context 'JSON' do
- it 'restores models based on JSON' do
+ context "JSON" do
+ it "restores models based on JSON" do
expect(@restored_project_json).to be_truthy
end
- it 'restore correct project features' do
- project = Project.find_by_path('project')
+ it "restore correct project features" do
+ project = Project.find_by_path("project")
expect(project.project_feature.issues_access_level).to eq(ProjectFeature::DISABLED)
expect(project.project_feature.builds_access_level).to eq(ProjectFeature::ENABLED)
@@ -46,157 +46,157 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(project.project_feature.merge_requests_access_level).to eq(ProjectFeature::ENABLED)
end
- it 'has the project description' do
- expect(Project.find_by_path('project').description).to eq('Nisi et repellendus ut enim quo accusamus vel magnam.')
+ it "has the project description" do
+ expect(Project.find_by_path("project").description).to eq("Nisi et repellendus ut enim quo accusamus vel magnam.")
end
- it 'has the same label associated to two issues' do
- expect(ProjectLabel.find_by_title('test2').issues.count).to eq(2)
+ it "has the same label associated to two issues" do
+ expect(ProjectLabel.find_by_title("test2").issues.count).to eq(2)
end
- it 'has milestones associated to two separate issues' do
- expect(Milestone.find_by_description('test milestone').issues.count).to eq(2)
+ it "has milestones associated to two separate issues" do
+ expect(Milestone.find_by_description("test milestone").issues.count).to eq(2)
end
- it 'creates a valid pipeline note' do
- expect(Ci::Pipeline.find_by_sha('sha-notes').notes).not_to be_empty
+ it "creates a valid pipeline note" do
+ expect(Ci::Pipeline.find_by_sha("sha-notes").notes).not_to be_empty
end
- it 'pipeline has the correct user ID' do
- expect(Ci::Pipeline.find_by_sha('sha-notes').user_id).to eq(@user.id)
+ it "pipeline has the correct user ID" do
+ expect(Ci::Pipeline.find_by_sha("sha-notes").user_id).to eq(@user.id)
end
- it 'restores pipelines with missing ref' do
+ it "restores pipelines with missing ref" do
expect(Ci::Pipeline.where(ref: nil)).not_to be_empty
end
- it 'preserves updated_at on issues' do
- issue = Issue.where(description: 'Aliquam enim illo et possimus.').first
+ it "preserves updated_at on issues" do
+ issue = Issue.where(description: "Aliquam enim illo et possimus.").first
- expect(issue.reload.updated_at.to_s).to eq('2016-06-14 15:02:47 UTC')
+ expect(issue.reload.updated_at.to_s).to eq("2016-06-14 15:02:47 UTC")
end
- it 'has multiple issue assignees' do
- expect(Issue.find_by(title: 'Voluptatem').assignees).to contain_exactly(@user, *@existing_members)
- expect(Issue.find_by(title: 'Issue without assignees').assignees).to be_empty
+ it "has multiple issue assignees" do
+ expect(Issue.find_by(title: "Voluptatem").assignees).to contain_exactly(@user, *@existing_members)
+ expect(Issue.find_by(title: "Issue without assignees").assignees).to be_empty
end
- it 'contains the merge access levels on a protected branch' do
+ it "contains the merge access levels on a protected branch" do
expect(ProtectedBranch.first.merge_access_levels).not_to be_empty
end
- it 'contains the push access levels on a protected branch' do
+ it "contains the push access levels on a protected branch" do
expect(ProtectedBranch.first.push_access_levels).not_to be_empty
end
- it 'contains the create access levels on a protected tag' do
+ it "contains the create access levels on a protected tag" do
expect(ProtectedTag.first.create_access_levels).not_to be_empty
end
- it 'restores issue resource label events' do
- expect(Issue.find_by(title: 'Voluptatem').resource_label_events).not_to be_empty
+ it "restores issue resource label events" do
+ expect(Issue.find_by(title: "Voluptatem").resource_label_events).not_to be_empty
end
- it 'restores merge requests resource label events' do
- expect(MergeRequest.find_by(title: 'MR1').resource_label_events).not_to be_empty
+ it "restores merge requests resource label events" do
+ expect(MergeRequest.find_by(title: "MR1").resource_label_events).not_to be_empty
end
- context 'event at forth level of the tree' do
+ context "event at forth level of the tree" do
let(:event) { Event.where(action: 6).first }
- it 'restores the event' do
+ it "restores the event" do
expect(event).not_to be_nil
end
- it 'has the action' do
+ it "has the action" do
expect(event.action).not_to be_nil
end
- it 'event belongs to note, belongs to merge request, belongs to a project' do
+ it "event belongs to note, belongs to merge request, belongs to a project" do
expect(event.note.noteable.project).not_to be_nil
end
end
- it 'has the correct data for merge request diff files' do
+ it "has the correct data for merge request diff files" do
expect(MergeRequestDiffFile.where.not(diff: nil).count).to eq(55)
end
- it 'has the correct data for merge request diff commits' do
+ it "has the correct data for merge request diff commits" do
expect(MergeRequestDiffCommit.count).to eq(77)
end
- it 'has the correct data for merge request latest_merge_request_diff' do
+ it "has the correct data for merge request latest_merge_request_diff" do
MergeRequest.find_each do |merge_request|
expect(merge_request.latest_merge_request_diff_id).to eq(merge_request.merge_request_diffs.maximum(:id))
end
end
- it 'has labels associated to label links, associated to issues' do
+ it "has labels associated to label links, associated to issues" do
expect(Label.first.label_links.first.target).not_to be_nil
end
- it 'has project labels' do
+ it "has project labels" do
expect(ProjectLabel.count).to eq(2)
end
- it 'has no group labels' do
+ it "has no group labels" do
expect(GroupLabel.count).to eq(0)
end
- it 'has a project feature' do
+ it "has a project feature" do
expect(@project.project_feature).not_to be_nil
end
- it 'has custom attributes' do
+ it "has custom attributes" do
expect(@project.custom_attributes.count).to eq(2)
end
- it 'has badges' do
+ it "has badges" do
expect(@project.project_badges.count).to eq(2)
end
- it 'restores the correct service' do
+ it "restores the correct service" do
expect(CustomIssueTrackerService.first).not_to be_nil
end
- context 'Merge requests' do
- it 'always has the new project as a target' do
- expect(MergeRequest.find_by_title('MR1').target_project).to eq(@project)
+ context "Merge requests" do
+ it "always has the new project as a target" do
+ expect(MergeRequest.find_by_title("MR1").target_project).to eq(@project)
end
- it 'has the same source project as originally if source/target are the same' do
- expect(MergeRequest.find_by_title('MR1').source_project).to eq(@project)
+ it "has the same source project as originally if source/target are the same" do
+ expect(MergeRequest.find_by_title("MR1").source_project).to eq(@project)
end
- it 'has the new project as target if source/target differ' do
- expect(MergeRequest.find_by_title('MR2').target_project).to eq(@project)
+ it "has the new project as target if source/target differ" do
+ expect(MergeRequest.find_by_title("MR2").target_project).to eq(@project)
end
- it 'has no source if source/target differ' do
- expect(MergeRequest.find_by_title('MR2').source_project_id).to be_nil
+ it "has no source if source/target differ" do
+ expect(MergeRequest.find_by_title("MR2").source_project_id).to be_nil
end
end
- context 'tokens are regenerated' do
- it 'has a new CI trigger token' do
- expect(Ci::Trigger.where(token: 'cdbfasdf44a5958c83654733449e585')).to be_empty
+ context "tokens are regenerated" do
+ it "has a new CI trigger token" do
+ expect(Ci::Trigger.where(token: "cdbfasdf44a5958c83654733449e585")).to be_empty
end
- it 'has a new CI build token' do
- expect(Ci::Build.where(token: 'abcd')).to be_empty
+ it "has a new CI build token" do
+ expect(Ci::Build.where(token: "abcd")).to be_empty
end
end
- context 'has restored the correct number of records' do
- it 'has the correct number of merge requests' do
+ context "has restored the correct number of records" do
+ it "has the correct number of merge requests" do
expect(@project.merge_requests.size).to eq(9)
end
- it 'has the correct number of triggers' do
+ it "has the correct number of triggers" do
expect(@project.triggers.size).to eq(1)
end
- it 'has the correct number of pipelines and statuses' do
+ it "has the correct number of pipelines and statuses" do
expect(@project.ci_pipelines.size).to eq(5)
@project.ci_pipelines.zip([2, 2, 2, 2, 2])
@@ -206,109 +206,109 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
end
- context 'when restoring hierarchy of pipeline, stages and jobs' do
- it 'restores pipelines' do
+ context "when restoring hierarchy of pipeline, stages and jobs" do
+ it "restores pipelines" do
expect(Ci::Pipeline.all.count).to be 5
end
- it 'restores pipeline stages' do
+ it "restores pipeline stages" do
expect(Ci::Stage.all.count).to be 6
end
- it 'correctly restores association between stage and a pipeline' do
+ it "correctly restores association between stage and a pipeline" do
expect(Ci::Stage.all).to all(have_attributes(pipeline_id: a_value > 0))
end
- it 'restores statuses' do
+ it "restores statuses" do
expect(CommitStatus.all.count).to be 10
end
- it 'correctly restores association between a stage and a job' do
+ it "correctly restores association between a stage and a job" do
expect(CommitStatus.all).to all(have_attributes(stage_id: a_value > 0))
end
- it 'correctly restores association between a pipeline and a job' do
+ it "correctly restores association between a pipeline and a job" do
expect(CommitStatus.all).to all(have_attributes(pipeline_id: a_value > 0))
end
end
end
end
- shared_examples 'restores project successfully' do
- it 'correctly restores project' do
+ shared_examples "restores project successfully" do
+ it "correctly restores project" do
expect(shared.errors).to be_empty
expect(restored_project_json).to be_truthy
end
end
- shared_examples 'restores project correctly' do |**results|
- it 'has labels' do
+ shared_examples "restores project correctly" do |**results|
+ it "has labels" do
expect(project.labels.size).to eq(results.fetch(:labels, 0))
end
- it 'has label priorities' do
+ it "has label priorities" do
expect(project.labels.first.priorities).not_to be_empty
end
- it 'has milestones' do
+ it "has milestones" do
expect(project.milestones.size).to eq(results.fetch(:milestones, 0))
end
- it 'has issues' do
+ it "has issues" do
expect(project.issues.size).to eq(results.fetch(:issues, 0))
end
- it 'does not set params that are excluded from import_export settings' do
+ it "does not set params that are excluded from import_export settings" do
expect(project.import_type).to be_nil
expect(project.creator_id).not_to eq 123
end
end
- shared_examples 'restores group correctly' do |**results|
- it 'has group label' do
+ shared_examples "restores group correctly" do |**results|
+ it "has group label" do
expect(project.group.labels.size).to eq(results.fetch(:labels, 0))
expect(project.group.labels.where(type: "GroupLabel").where.not(project_id: nil).count).to eq(0)
end
- it 'has group milestone' do
+ it "has group milestone" do
expect(project.group.milestones.size).to eq(results.fetch(:milestones, 0))
end
- it 'has the correct visibility level' do
+ it "has the correct visibility level" do
# INTERNAL in the `project.json`, group's is PRIVATE
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
- context 'Light JSON' do
+ context "Light JSON" do
let(:user) { create(:user) }
let(:shared) { project.import_export_shared }
- let!(:project) { create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project') }
+ let!(:project) { create(:project, :builds_disabled, :issues_disabled, name: "project", path: "project") }
let(:project_tree_restorer) { described_class.new(user: user, shared: shared, project: project) }
let(:restored_project_json) { project_tree_restorer.restore }
before do
- allow(shared).to receive(:export_path).and_return('spec/lib/gitlab/import_export/')
+ allow(shared).to receive(:export_path).and_return("spec/lib/gitlab/import_export/")
end
- context 'with a simple project' do
+ context "with a simple project" do
before do
project_tree_restorer.instance_variable_set(:@path, "spec/lib/gitlab/import_export/project.light.json")
restored_project_json
end
- it_behaves_like 'restores project correctly',
- issues: 1,
- labels: 1,
- milestones: 1,
- first_issue_labels: 1,
- services: 1
+ it_behaves_like "restores project correctly",
+ issues: 1,
+ labels: 1,
+ milestones: 1,
+ first_issue_labels: 1,
+ services: 1
- context 'project.json file access check' do
- it 'does not read a symlink' do
+ context "project.json file access check" do
+ it "does not read a symlink" do
Dir.mktmpdir do |tmpdir|
- setup_symlink(tmpdir, 'project.json')
+ setup_symlink(tmpdir, "project.json")
allow(shared).to receive(:export_path).and_call_original
restored_project_json
@@ -318,26 +318,26 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
end
- context 'when there is an existing build with build token' do
+ context "when there is an existing build with build token" do
before do
- create(:ci_build, token: 'abcd')
+ create(:ci_build, token: "abcd")
end
- it_behaves_like 'restores project successfully'
+ it_behaves_like "restores project successfully"
end
end
- context 'when the project has overridden params in import data' do
- it 'overwrites the params stored in the JSON' do
- project.create_import_data(data: { override_params: { description: "Overridden" } })
+ context "when the project has overridden params in import data" do
+ it "overwrites the params stored in the JSON" do
+ project.create_import_data(data: {override_params: {description: "Overridden"}})
restored_project_json
expect(project.description).to eq("Overridden")
end
- it 'does not allow setting params that are excluded from import_export settings' do
- project.create_import_data(data: { override_params: { lfs_enabled: true } })
+ it "does not allow setting params that are excluded from import_export settings" do
+ project.create_import_data(data: {override_params: {lfs_enabled: true}})
restored_project_json
@@ -345,14 +345,14 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
end
- context 'with a project that has a group' do
+ context "with a project that has a group" do
let!(:project) do
create(:project,
- :builds_disabled,
- :issues_disabled,
- name: 'project',
- path: 'project',
- group: create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE))
+ :builds_disabled,
+ :issues_disabled,
+ name: "project",
+ path: "project",
+ group: create(:group, visibility_level: Gitlab::VisibilityLevel::PRIVATE))
end
before do
@@ -361,41 +361,41 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
restored_project_json
end
- it_behaves_like 'restores project successfully'
- it_behaves_like 'restores project correctly',
- issues: 2,
- labels: 1,
- milestones: 2,
- first_issue_labels: 1
+ it_behaves_like "restores project successfully"
+ it_behaves_like "restores project correctly",
+ issues: 2,
+ labels: 1,
+ milestones: 2,
+ first_issue_labels: 1
- it_behaves_like 'restores group correctly',
- labels: 0,
- milestones: 0,
- first_issue_labels: 1
+ it_behaves_like "restores group correctly",
+ labels: 0,
+ milestones: 0,
+ first_issue_labels: 1
end
- context 'with existing group models' do
+ context "with existing group models" do
let!(:project) do
create(:project,
- :builds_disabled,
- :issues_disabled,
- name: 'project',
- path: 'project',
- group: create(:group))
+ :builds_disabled,
+ :issues_disabled,
+ name: "project",
+ path: "project",
+ group: create(:group))
end
before do
project_tree_restorer.instance_variable_set(:@path, "spec/lib/gitlab/import_export/project.light.json")
end
- it 'does not import any templated services' do
+ it "does not import any templated services" do
restored_project_json
expect(project.services.where(template: true).count).to eq(0)
end
- it 'imports labels' do
- create(:group_label, name: 'Another label', group: project.group)
+ it "imports labels" do
+ create(:group_label, name: "Another label", group: project.group)
expect_any_instance_of(Gitlab::ImportExport::Shared).not_to receive(:error)
@@ -404,8 +404,8 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
expect(project.labels.count).to eq(1)
end
- it 'imports milestones' do
- create(:milestone, name: 'A milestone', group: project.group)
+ it "imports milestones" do
+ create(:milestone, name: "A milestone", group: project.group)
expect_any_instance_of(Gitlab::ImportExport::Shared).not_to receive(:error)
@@ -416,17 +416,17 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
end
end
- context 'with clashing milestones on IID' do
+ context "with clashing milestones on IID" do
let!(:project) do
create(:project,
- :builds_disabled,
- :issues_disabled,
- name: 'project',
- path: 'project',
- group: create(:group))
+ :builds_disabled,
+ :issues_disabled,
+ name: "project",
+ path: "project",
+ group: create(:group))
end
- it 'preserves the project milestone IID' do
+ it "preserves the project milestone IID" do
project_tree_restorer.instance_variable_set(:@path, "spec/lib/gitlab/import_export/project.milestone-iid.json")
expect_any_instance_of(Gitlab::ImportExport::Shared).not_to receive(:error)
@@ -434,60 +434,60 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do
restored_project_json
expect(project.milestones.count).to eq(2)
- expect(Milestone.find_by_title('Another milestone').iid).to eq(1)
- expect(Milestone.find_by_title('Group-level milestone').iid).to eq(2)
+ expect(Milestone.find_by_title("Another milestone").iid).to eq(1)
+ expect(Milestone.find_by_title("Group-level milestone").iid).to eq(2)
end
end
end
- describe '#restored_project' do
+ describe "#restored_project" do
let(:project) { create(:project) }
let(:shared) { project.import_export_shared }
- let(:tree_hash) { { 'visibility_level' => visibility } }
+ let(:tree_hash) { {"visibility_level" => visibility} }
let(:restorer) { described_class.new(user: nil, shared: shared, project: project) }
before do
restorer.instance_variable_set(:@tree_hash, tree_hash)
end
- context 'no group visibility' do
+ context "no group visibility" do
let(:visibility) { Gitlab::VisibilityLevel::PRIVATE }
- it 'uses the project visibility' do
+ it "uses the project visibility" do
expect(restorer.restored_project.visibility_level).to eq(visibility)
end
end
- context 'with group visibility' do
+ context "with group visibility" do
before do
group = create(:group, visibility_level: group_visibility)
project.update(group: group)
end
- context 'private group visibility' do
+ context "private group visibility" do
let(:group_visibility) { Gitlab::VisibilityLevel::PRIVATE }
let(:visibility) { Gitlab::VisibilityLevel::PUBLIC }
- it 'uses the group visibility' do
+ it "uses the group visibility" do
expect(restorer.restored_project.visibility_level).to eq(group_visibility)
end
end
- context 'public group visibility' do
+ context "public group visibility" do
let(:group_visibility) { Gitlab::VisibilityLevel::PUBLIC }
let(:visibility) { Gitlab::VisibilityLevel::PRIVATE }
- it 'uses the project visibility' do
+ it "uses the project visibility" do
expect(restorer.restored_project.visibility_level).to eq(visibility)
end
end
- context 'internal group visibility' do
+ context "internal group visibility" do
let(:group_visibility) { Gitlab::VisibilityLevel::INTERNAL }
let(:visibility) { Gitlab::VisibilityLevel::PUBLIC }
- it 'uses the group visibility' do
+ it "uses the group visibility" do
expect(restorer.restored_project.visibility_level).to eq(group_visibility)
end
end
diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
index cfc3e0ce926..bdfe426340d 100644
--- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::ProjectTreeSaver do
- describe 'saves the project tree into a json object' do
+ describe "saves the project tree into a json object" do
let(:shared) { project.import_export_shared }
let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
@@ -11,215 +11,215 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
before do
project.add_maintainer(user)
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
- allow_any_instance_of(MergeRequest).to receive(:source_branch_sha).and_return('ABCD')
- allow_any_instance_of(MergeRequest).to receive(:target_branch_sha).and_return('DCBA')
+ allow_any_instance_of(MergeRequest).to receive(:source_branch_sha).and_return("ABCD")
+ allow_any_instance_of(MergeRequest).to receive(:target_branch_sha).and_return("DCBA")
end
after do
FileUtils.rm_rf(export_path)
end
- it 'saves project successfully' do
+ it "saves project successfully" do
expect(project_tree_saver.save).to be true
end
- context 'JSON' do
+ context "JSON" do
let(:saved_project_json) do
project_tree_saver.save
project_json(project_tree_saver.full_path)
end
- context 'with description override' do
- let(:params) { { description: 'Foo Bar' } }
+ context "with description override" do
+ let(:params) { {description: "Foo Bar"} }
let(:project_tree_saver) { described_class.new(project: project, current_user: user, shared: shared, params: params) }
- it 'overrides the project description' do
- expect(saved_project_json).to include({ 'description' => params[:description] })
+ it "overrides the project description" do
+ expect(saved_project_json).to include({"description" => params[:description]})
end
end
- it 'saves the correct json' do
- expect(saved_project_json).to include({ 'description' => 'description', 'visibility_level' => 20 })
+ it "saves the correct json" do
+ expect(saved_project_json).to include({"description" => "description", "visibility_level" => 20})
end
- it 'has milestones' do
- expect(saved_project_json['milestones']).not_to be_empty
+ it "has milestones" do
+ expect(saved_project_json["milestones"]).not_to be_empty
end
- it 'has merge requests' do
- expect(saved_project_json['merge_requests']).not_to be_empty
+ it "has merge requests" do
+ expect(saved_project_json["merge_requests"]).not_to be_empty
end
- it 'has merge request\'s milestones' do
- expect(saved_project_json['merge_requests'].first['milestone']).not_to be_empty
+ it "has merge request's milestones" do
+ expect(saved_project_json["merge_requests"].first["milestone"]).not_to be_empty
end
- it 'has merge request\'s source branch SHA' do
- expect(saved_project_json['merge_requests'].first['source_branch_sha']).to eq('ABCD')
+ it "has merge request's source branch SHA" do
+ expect(saved_project_json["merge_requests"].first["source_branch_sha"]).to eq("ABCD")
end
- it 'has merge request\'s target branch SHA' do
- expect(saved_project_json['merge_requests'].first['target_branch_sha']).to eq('DCBA')
+ it "has merge request's target branch SHA" do
+ expect(saved_project_json["merge_requests"].first["target_branch_sha"]).to eq("DCBA")
end
- it 'has events' do
- expect(saved_project_json['merge_requests'].first['milestone']['events']).not_to be_empty
+ it "has events" do
+ expect(saved_project_json["merge_requests"].first["milestone"]["events"]).not_to be_empty
end
- it 'has snippets' do
- expect(saved_project_json['snippets']).not_to be_empty
+ it "has snippets" do
+ expect(saved_project_json["snippets"]).not_to be_empty
end
- it 'has snippet notes' do
- expect(saved_project_json['snippets'].first['notes']).not_to be_empty
+ it "has snippet notes" do
+ expect(saved_project_json["snippets"].first["notes"]).not_to be_empty
end
- it 'has releases' do
- expect(saved_project_json['releases']).not_to be_empty
+ it "has releases" do
+ expect(saved_project_json["releases"]).not_to be_empty
end
- it 'has no author on releases' do
- expect(saved_project_json['releases'].first['author']).to be_nil
+ it "has no author on releases" do
+ expect(saved_project_json["releases"].first["author"]).to be_nil
end
- it 'has the author ID on releases' do
- expect(saved_project_json['releases'].first['author_id']).not_to be_nil
+ it "has the author ID on releases" do
+ expect(saved_project_json["releases"].first["author_id"]).not_to be_nil
end
- it 'has issues' do
- expect(saved_project_json['issues']).not_to be_empty
+ it "has issues" do
+ expect(saved_project_json["issues"]).not_to be_empty
end
- it 'has issue comments' do
- expect(saved_project_json['issues'].first['notes']).not_to be_empty
+ it "has issue comments" do
+ expect(saved_project_json["issues"].first["notes"]).not_to be_empty
end
- it 'has issue assignees' do
- expect(saved_project_json['issues'].first['issue_assignees']).not_to be_empty
+ it "has issue assignees" do
+ expect(saved_project_json["issues"].first["issue_assignees"]).not_to be_empty
end
- it 'has author on issue comments' do
- expect(saved_project_json['issues'].first['notes'].first['author']).not_to be_empty
+ it "has author on issue comments" do
+ expect(saved_project_json["issues"].first["notes"].first["author"]).not_to be_empty
end
- it 'has project members' do
- expect(saved_project_json['project_members']).not_to be_empty
+ it "has project members" do
+ expect(saved_project_json["project_members"]).not_to be_empty
end
- it 'has merge requests diffs' do
- expect(saved_project_json['merge_requests'].first['merge_request_diff']).not_to be_empty
+ it "has merge requests diffs" do
+ expect(saved_project_json["merge_requests"].first["merge_request_diff"]).not_to be_empty
end
- it 'has merge request diff files' do
- expect(saved_project_json['merge_requests'].first['merge_request_diff']['merge_request_diff_files']).not_to be_empty
+ it "has merge request diff files" do
+ expect(saved_project_json["merge_requests"].first["merge_request_diff"]["merge_request_diff_files"]).not_to be_empty
end
- it 'has merge request diff commits' do
- expect(saved_project_json['merge_requests'].first['merge_request_diff']['merge_request_diff_commits']).not_to be_empty
+ it "has merge request diff commits" do
+ expect(saved_project_json["merge_requests"].first["merge_request_diff"]["merge_request_diff_commits"]).not_to be_empty
end
- it 'has merge requests comments' do
- expect(saved_project_json['merge_requests'].first['notes']).not_to be_empty
+ it "has merge requests comments" do
+ expect(saved_project_json["merge_requests"].first["notes"]).not_to be_empty
end
- it 'has author on merge requests comments' do
- expect(saved_project_json['merge_requests'].first['notes'].first['author']).not_to be_empty
+ it "has author on merge requests comments" do
+ expect(saved_project_json["merge_requests"].first["notes"].first["author"]).not_to be_empty
end
- it 'has pipeline stages' do
- expect(saved_project_json.dig('ci_pipelines', 0, 'stages')).not_to be_empty
+ it "has pipeline stages" do
+ expect(saved_project_json.dig("ci_pipelines", 0, "stages")).not_to be_empty
end
- it 'has pipeline statuses' do
- expect(saved_project_json.dig('ci_pipelines', 0, 'stages', 0, 'statuses')).not_to be_empty
+ it "has pipeline statuses" do
+ expect(saved_project_json.dig("ci_pipelines", 0, "stages", 0, "statuses")).not_to be_empty
end
- it 'has pipeline builds' do
+ it "has pipeline builds" do
builds_count = saved_project_json
- .dig('ci_pipelines', 0, 'stages', 0, 'statuses')
- .count { |hash| hash['type'] == 'Ci::Build' }
+ .dig("ci_pipelines", 0, "stages", 0, "statuses")
+ .count { |hash| hash["type"] == "Ci::Build" }
expect(builds_count).to eq(1)
end
- it 'has no when YML attributes but only the DB column' do
- allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')))
+ it "has no when YML attributes but only the DB column" do
+ allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file).and_return(File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml")))
expect_any_instance_of(Gitlab::Ci::YamlProcessor).not_to receive(:build_attributes)
saved_project_json
end
- it 'has pipeline commits' do
- expect(saved_project_json['ci_pipelines']).not_to be_empty
+ it "has pipeline commits" do
+ expect(saved_project_json["ci_pipelines"]).not_to be_empty
end
- it 'has ci pipeline notes' do
- expect(saved_project_json['ci_pipelines'].first['notes']).not_to be_empty
+ it "has ci pipeline notes" do
+ expect(saved_project_json["ci_pipelines"].first["notes"]).not_to be_empty
end
- it 'has labels with no associations' do
- expect(saved_project_json['labels']).not_to be_empty
+ it "has labels with no associations" do
+ expect(saved_project_json["labels"]).not_to be_empty
end
- it 'has labels associated to records' do
- expect(saved_project_json['issues'].first['label_links'].first['label']).not_to be_empty
+ it "has labels associated to records" do
+ expect(saved_project_json["issues"].first["label_links"].first["label"]).not_to be_empty
end
- it 'has project and group labels' do
- label_types = saved_project_json['issues'].first['label_links'].map { |link| link['label']['type'] }
+ it "has project and group labels" do
+ label_types = saved_project_json["issues"].first["label_links"].map { |link| link["label"]["type"] }
- expect(label_types).to match_array(%w(ProjectLabel GroupLabel))
+ expect(label_types).to match_array(%w[ProjectLabel GroupLabel])
end
- it 'has priorities associated to labels' do
- priorities = saved_project_json['issues'].first['label_links'].map { |link| link['label']['priorities'] }
+ it "has priorities associated to labels" do
+ priorities = saved_project_json["issues"].first["label_links"].map { |link| link["label"]["priorities"] }
expect(priorities.flatten).not_to be_empty
end
- it 'has issue resource label events' do
- expect(saved_project_json['issues'].first['resource_label_events']).not_to be_empty
+ it "has issue resource label events" do
+ expect(saved_project_json["issues"].first["resource_label_events"]).not_to be_empty
end
- it 'has merge request resource label events' do
- expect(saved_project_json['merge_requests'].first['resource_label_events']).not_to be_empty
+ it "has merge request resource label events" do
+ expect(saved_project_json["merge_requests"].first["resource_label_events"]).not_to be_empty
end
- it 'saves the correct service type' do
- expect(saved_project_json['services'].first['type']).to eq('CustomIssueTrackerService')
+ it "saves the correct service type" do
+ expect(saved_project_json["services"].first["type"]).to eq("CustomIssueTrackerService")
end
- it 'saves the properties for a service' do
- expect(saved_project_json['services'].first['properties']).to eq('one' => 'value')
+ it "saves the properties for a service" do
+ expect(saved_project_json["services"].first["properties"]).to eq("one" => "value")
end
- it 'has project feature' do
- project_feature = saved_project_json['project_feature']
+ it "has project feature" do
+ project_feature = saved_project_json["project_feature"]
expect(project_feature).not_to be_empty
expect(project_feature["issues_access_level"]).to eq(ProjectFeature::DISABLED)
expect(project_feature["wiki_access_level"]).to eq(ProjectFeature::ENABLED)
expect(project_feature["builds_access_level"]).to eq(ProjectFeature::PRIVATE)
end
- it 'has custom attributes' do
- expect(saved_project_json['custom_attributes'].count).to eq(2)
+ it "has custom attributes" do
+ expect(saved_project_json["custom_attributes"].count).to eq(2)
end
- it 'has badges' do
- expect(saved_project_json['project_badges'].count).to eq(2)
+ it "has badges" do
+ expect(saved_project_json["project_badges"].count).to eq(2)
end
- it 'does not complain about non UTF-8 characters in MR diff files' do
+ it "does not complain about non UTF-8 characters in MR diff files" do
ActiveRecord::Base.connection.execute("UPDATE merge_request_diff_files SET diff = '---\n- :diff: !binary |-\n LS0tIC9kZXYvbnVsbAorKysgYi9pbWFnZXMvbnVjb3IucGRmCkBAIC0wLDAg\n KzEsMTY3OSBAQAorJVBERi0xLjUNJeLjz9MNCisxIDAgb2JqDTw8L01ldGFk\n YXR'")
expect(project_tree_saver.save).to be true
end
- context 'group members' do
- let(:user2) { create(:user, email: 'group@member.com') }
+ context "group members" do
+ let(:user2) { create(:user, email: "group@member.com") }
let(:member_emails) do
- saved_project_json['project_members'].map do |pm|
- pm['user']['email']
+ saved_project_json["project_members"].map do |pm|
+ pm["user"]["email"]
end
end
@@ -227,42 +227,42 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
Group.first.add_developer(user2)
end
- it 'does not export group members if it has no permission' do
+ it "does not export group members if it has no permission" do
Group.first.add_developer(user)
- expect(member_emails).not_to include('group@member.com')
+ expect(member_emails).not_to include("group@member.com")
end
- it 'does not export group members as maintainer' do
+ it "does not export group members as maintainer" do
Group.first.add_maintainer(user)
- expect(member_emails).not_to include('group@member.com')
+ expect(member_emails).not_to include("group@member.com")
end
- it 'exports group members as group owner' do
+ it "exports group members as group owner" do
Group.first.add_owner(user)
- expect(member_emails).to include('group@member.com')
+ expect(member_emails).to include("group@member.com")
end
- context 'as admin' do
+ context "as admin" do
let(:user) { create(:admin) }
- it 'exports group members as admin' do
- expect(member_emails).to include('group@member.com')
+ it "exports group members as admin" do
+ expect(member_emails).to include("group@member.com")
end
- it 'exports group members as project members' do
- member_types = saved_project_json['project_members'].map { |pm| pm['source_type'] }
+ it "exports group members as project members" do
+ member_types = saved_project_json["project_members"].map { |pm| pm["source_type"] }
- expect(member_types).to all(eq('Project'))
+ expect(member_types).to all(eq("Project"))
end
end
end
- context 'project attributes' do
- it 'does not contain the runners token' do
- expect(saved_project_json).not_to include("runners_token" => 'token')
+ context "project attributes" do
+ it "does not contain the runners token" do
+ expect(saved_project_json).not_to include("runners_token" => "token")
end
end
end
@@ -275,17 +275,16 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
group = create(:group)
project = create(:project,
- :public,
- :repository,
- :issues_disabled,
- :wiki_enabled,
- :builds_private,
- description: 'description',
- issues: [issue],
- snippets: [snippet],
- releases: [release],
- group: group
- )
+ :public,
+ :repository,
+ :issues_disabled,
+ :wiki_enabled,
+ :builds_private,
+ description: "description",
+ issues: [issue],
+ snippets: [snippet],
+ releases: [release],
+ group: group)
project_label = create(:label, project: project)
group_label = create(:group_label, group: group)
create(:label_link, label: project_label, target: issue)
@@ -303,15 +302,15 @@ describe Gitlab::ImportExport::ProjectTreeSaver do
create(:note, noteable: merge_request, project: project)
create(:note, noteable: snippet, project: project)
create(:note_on_commit,
- author: user,
- project: project,
- commit_id: ci_build.pipeline.sha)
+ author: user,
+ project: project,
+ commit_id: ci_build.pipeline.sha)
create(:resource_label_event, label: project_label, issue: issue)
create(:resource_label_event, label: group_label, merge_request: merge_request)
create(:event, :created, target: milestone, project: project, author: user)
- create(:service, project: project, type: 'CustomIssueTrackerService', category: 'issue_tracker', properties: { one: 'value' })
+ create(:service, project: project, type: "CustomIssueTrackerService", category: "issue_tracker", properties: {one: "value"})
create(:project_custom_attribute, project: project)
create(:project_custom_attribute, project: project)
diff --git a/spec/lib/gitlab/import_export/reader_spec.rb b/spec/lib/gitlab/import_export/reader_spec.rb
index f93ff074770..2d3e8444ad2 100644
--- a/spec/lib/gitlab/import_export/reader_spec.rb
+++ b/spec/lib/gitlab/import_export/reader_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::Reader do
let(:shared) { Gitlab::ImportExport::Shared.new(nil) }
- let(:test_config) { 'spec/support/import_export/import_export.yml' }
+ let(:test_config) { "spec/support/import_export/import_export.yml" }
let(:project_tree_hash) do
{
except: [:id, :created_at],
include: [:issues, :labels,
- { merge_requests: {
+ {merge_requests: {
only: [:id],
except: [:iid],
- include: [:merge_request_diff, :merge_request_test]
- } },
- { commit_statuses: { include: :commit } },
- { project_members: { include: { user: { only: [:email] } } } }]
+ include: [:merge_request_diff, :merge_request_test],
+ }},
+ {commit_statuses: {include: :commit}},
+ {project_members: {include: {user: {only: [:email]}}}},],
}
end
@@ -21,73 +21,73 @@ describe Gitlab::ImportExport::Reader do
allow_any_instance_of(Gitlab::ImportExport).to receive(:config_file).and_return(test_config)
end
- it 'generates hash from project tree config' do
+ it "generates hash from project tree config" do
expect(described_class.new(shared: shared).project_tree).to match(project_tree_hash)
end
- context 'individual scenarios' do
- it 'generates the correct hash for a single project relation' do
+ context "individual scenarios" do
+ it "generates the correct hash for a single project relation" do
setup_yaml(project_tree: [:issues])
expect(described_class.new(shared: shared).project_tree).to match(include: [:issues])
end
- it 'generates the correct hash for a single project feature relation' do
+ it "generates the correct hash for a single project feature relation" do
setup_yaml(project_tree: [:project_feature])
expect(described_class.new(shared: shared).project_tree).to match(include: [:project_feature])
end
- it 'generates the correct hash for a multiple project relation' do
+ it "generates the correct hash for a multiple project relation" do
setup_yaml(project_tree: [:issues, :snippets])
expect(described_class.new(shared: shared).project_tree).to match(include: [:issues, :snippets])
end
- it 'generates the correct hash for a single sub-relation' do
+ it "generates the correct hash for a single sub-relation" do
setup_yaml(project_tree: [issues: [:notes]])
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { include: :notes } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{issues: {include: :notes}}])
end
- it 'generates the correct hash for a multiple sub-relation' do
+ it "generates the correct hash for a multiple sub-relation" do
setup_yaml(project_tree: [merge_requests: [:notes, :merge_request_diff]])
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ merge_requests: { include: [:notes, :merge_request_diff] } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{merge_requests: {include: [:notes, :merge_request_diff]}}])
end
- it 'generates the correct hash for a sub-relation with another sub-relation' do
+ it "generates the correct hash for a sub-relation with another sub-relation" do
setup_yaml(project_tree: [merge_requests: [notes: :author]])
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ merge_requests: { include: { notes: { include: :author } } } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{merge_requests: {include: {notes: {include: :author}}}}])
end
- it 'generates the correct hash for a relation with included attributes' do
- setup_yaml(project_tree: [:issues], included_attributes: { issues: [:name, :description] })
+ it "generates the correct hash for a relation with included attributes" do
+ setup_yaml(project_tree: [:issues], included_attributes: {issues: [:name, :description]})
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { only: [:name, :description] } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{issues: {only: [:name, :description]}}])
end
- it 'generates the correct hash for a relation with excluded attributes' do
- setup_yaml(project_tree: [:issues], excluded_attributes: { issues: [:name] })
+ it "generates the correct hash for a relation with excluded attributes" do
+ setup_yaml(project_tree: [:issues], excluded_attributes: {issues: [:name]})
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { except: [:name] } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{issues: {except: [:name]}}])
end
- it 'generates the correct hash for a relation with both excluded and included attributes' do
- setup_yaml(project_tree: [:issues], excluded_attributes: { issues: [:name] }, included_attributes: { issues: [:description] })
+ it "generates the correct hash for a relation with both excluded and included attributes" do
+ setup_yaml(project_tree: [:issues], excluded_attributes: {issues: [:name]}, included_attributes: {issues: [:description]})
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { except: [:name], only: [:description] } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{issues: {except: [:name], only: [:description]}}])
end
- it 'generates the correct hash for a relation with custom methods' do
- setup_yaml(project_tree: [:issues], methods: { issues: [:name] })
+ it "generates the correct hash for a relation with custom methods" do
+ setup_yaml(project_tree: [:issues], methods: {issues: [:name]})
- expect(described_class.new(shared: shared).project_tree).to match(include: [{ issues: { methods: [:name] } }])
+ expect(described_class.new(shared: shared).project_tree).to match(include: [{issues: {methods: [:name]}}])
end
- it 'generates the correct hash for group members' do
- expect(described_class.new(shared: shared).group_members_tree).to match({ include: { user: { only: [:email] } } })
+ it "generates the correct hash for group members" do
+ expect(described_class.new(shared: shared).group_members_tree).to match({include: {user: {only: [:email]}}})
end
def setup_yaml(hash)
diff --git a/spec/lib/gitlab/import_export/relation_factory_spec.rb b/spec/lib/gitlab/import_export/relation_factory_spec.rb
index a31f77484d8..a0b4d0ac8c0 100644
--- a/spec/lib/gitlab/import_export/relation_factory_spec.rb
+++ b/spec/lib/gitlab/import_export/relation_factory_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::RelationFactory do
let(:project) { create(:project) }
- let(:members_mapper) { double('members_mapper').as_null_object }
+ let(:members_mapper) { double("members_mapper").as_null_object }
let(:user) { create(:admin) }
let(:excluded_keys) { [] }
let(:created_object) do
@@ -14,66 +14,66 @@ describe Gitlab::ImportExport::RelationFactory do
excluded_keys: excluded_keys)
end
- context 'hook object' do
+ context "hook object" do
let(:relation_sym) { :hooks }
let(:id) { 999 }
let(:service_id) { 99 }
let(:original_project_id) { 8 }
- let(:token) { 'secret' }
+ let(:token) { "secret" }
let(:relation_hash) do
{
- 'id' => id,
- 'url' => 'https://example.json',
- 'project_id' => original_project_id,
- 'created_at' => '2016-08-12T09:41:03.462Z',
- 'updated_at' => '2016-08-12T09:41:03.462Z',
- 'service_id' => service_id,
- 'push_events' => true,
- 'issues_events' => false,
- 'confidential_issues_events' => false,
- 'merge_requests_events' => true,
- 'tag_push_events' => false,
- 'note_events' => true,
- 'enable_ssl_verification' => true,
- 'job_events' => false,
- 'wiki_page_events' => true,
- 'token' => token
+ "id" => id,
+ "url" => "https://example.json",
+ "project_id" => original_project_id,
+ "created_at" => "2016-08-12T09:41:03.462Z",
+ "updated_at" => "2016-08-12T09:41:03.462Z",
+ "service_id" => service_id,
+ "push_events" => true,
+ "issues_events" => false,
+ "confidential_issues_events" => false,
+ "merge_requests_events" => true,
+ "tag_push_events" => false,
+ "note_events" => true,
+ "enable_ssl_verification" => true,
+ "job_events" => false,
+ "wiki_page_events" => true,
+ "token" => token,
}
end
- it 'does not have the original ID' do
+ it "does not have the original ID" do
expect(created_object.id).not_to eq(id)
end
- it 'does not have the original service_id' do
+ it "does not have the original service_id" do
expect(created_object.service_id).not_to eq(service_id)
end
- it 'does not have the original project_id' do
+ it "does not have the original project_id" do
expect(created_object.project_id).not_to eq(original_project_id)
end
- it 'has the new project_id' do
+ it "has the new project_id" do
expect(created_object.project_id).to eq(project.id)
end
- it 'has a nil token' do
+ it "has a nil token" do
expect(created_object.token).to eq(nil)
end
- context 'original service exists' do
+ context "original service exists" do
let(:service_id) { create(:service, project: project).id }
- it 'does not have the original service_id' do
+ it "does not have the original service_id" do
expect(created_object.service_id).not_to eq(service_id)
end
end
- context 'excluded attributes' do
+ context "excluded attributes" do
let(:excluded_keys) { %w[url] }
- it 'are removed from the imported object' do
+ it "are removed from the imported object" do
expect(created_object.url).to be_nil
end
end
@@ -94,19 +94,19 @@ describe Gitlab::ImportExport::RelationFactory do
# `project_id`, `described_class.USER_REFERENCES`, noteable_id, target_id, and some project IDs are already
# re-assigned by described_class.
- context 'Potentially hazardous foreign keys' do
+ context "Potentially hazardous foreign keys" do
let(:relation_sym) { :hazardous_foo_model }
let(:relation_hash) do
{
- 'service_id' => 99,
- 'moved_to_id' => 99,
- 'namespace_id' => 99,
- 'ci_id' => 99,
- 'random_project_id' => 99,
- 'random_id' => 99,
- 'milestone_id' => 99,
- 'project_id' => 99,
- 'user_id' => 99
+ "service_id" => 99,
+ "moved_to_id" => 99,
+ "namespace_id" => 99,
+ "ci_id" => 99,
+ "random_project_id" => 99,
+ "random_id" => 99,
+ "milestone_id" => 99,
+ "project_id" => 99,
+ "user_id" => 99,
}
end
@@ -114,46 +114,46 @@ describe Gitlab::ImportExport::RelationFactory do
attr_accessor :service_id, :moved_to_id, :namespace_id, :ci_id, :random_project_id, :random_id, :milestone_id, :project_id
end
- it 'does not preserve any foreign key IDs' do
+ it "does not preserve any foreign key IDs" do
expect(created_object.values).not_to include(99)
end
end
- context 'overrided model with pluralized name' do
+ context "overrided model with pluralized name" do
let(:relation_sym) { :metrics }
let(:relation_hash) do
{
- 'id' => 99,
- 'merge_request_id' => 99,
- 'merged_at' => Time.now,
- 'merged_by_id' => 99,
- 'latest_closed_at' => nil,
- 'latest_closed_by_id' => nil
+ "id" => 99,
+ "merge_request_id" => 99,
+ "merged_at" => Time.now,
+ "merged_by_id" => 99,
+ "latest_closed_at" => nil,
+ "latest_closed_by_id" => nil,
}
end
- it 'does not raise errors' do
+ it "does not raise errors" do
expect { created_object }.not_to raise_error
end
end
- context 'Project references' do
+ context "Project references" do
let(:relation_sym) { :project_foo_model }
let(:relation_hash) do
- Gitlab::ImportExport::RelationFactory::PROJECT_REFERENCES.map { |ref| { ref => 99 } }.inject(:merge)
+ Gitlab::ImportExport::RelationFactory::PROJECT_REFERENCES.map { |ref| {ref => 99} }.inject(:merge)
end
class ProjectFooModel < FooModel
attr_accessor(*Gitlab::ImportExport::RelationFactory::PROJECT_REFERENCES)
end
- it 'does not preserve any project foreign key IDs' do
+ it "does not preserve any project foreign key IDs" do
expect(created_object.values).not_to include(99)
end
end
- context 'Notes user references' do
+ context "Notes user references" do
let(:relation_sym) { :notes }
let(:new_user) { create(:user) }
let(:exported_member) do
@@ -169,8 +169,8 @@ describe Gitlab::ImportExport::RelationFactory do
"user" => {
"id" => 999,
"email" => new_user.email,
- "username" => new_user.username
- }
+ "username" => new_user.username,
+ },
}
end
@@ -184,14 +184,14 @@ describe Gitlab::ImportExport::RelationFactory do
"updated_at" => "2016-11-18T09:29:42.634Z",
"project_id" => 1,
"attachment" => {
- "url" => nil
+ "url" => nil,
},
"noteable_id" => 377,
"system" => true,
"author" => {
- "name" => "Administrator"
+ "name" => "Administrator",
},
- "events" => []
+ "events" => [],
}
end
@@ -199,21 +199,22 @@ describe Gitlab::ImportExport::RelationFactory do
Gitlab::ImportExport::MembersMapper.new(
exported_members: [exported_member],
user: user,
- project: project)
+ project: project
+ )
end
- it 'maps the right author to the imported note' do
+ it "maps the right author to the imported note" do
expect(created_object.author).to eq(new_user)
end
end
- context 'encrypted attributes' do
- let(:relation_sym) { 'Ci::Variable' }
+ context "encrypted attributes" do
+ let(:relation_sym) { "Ci::Variable" }
let(:relation_hash) do
create(:ci_variable).as_json
end
- it 'has no value for the encrypted attribute' do
+ it "has no value for the encrypted attribute" do
expect(created_object.value).to be_nil
end
end
diff --git a/spec/lib/gitlab/import_export/relation_rename_service_spec.rb b/spec/lib/gitlab/import_export/relation_rename_service_spec.rb
index a20a844a492..0c419d7ffe0 100644
--- a/spec/lib/gitlab/import_export/relation_rename_service_spec.rb
+++ b/spec/lib/gitlab/import_export/relation_rename_service_spec.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::RelationRenameService do
let(:renames) do
{
- 'example_relation1' => 'new_example_relation1',
- 'example_relation2' => 'new_example_relation2'
+ "example_relation1" => "new_example_relation1",
+ "example_relation2" => "new_example_relation2",
}
end
let(:user) { create(:admin) }
let(:group) { create(:group, :nested) }
- let!(:project) { create(:project, :builds_disabled, :issues_disabled, name: 'project', path: 'project') }
+ let!(:project) { create(:project, :builds_disabled, :issues_disabled, name: "project", path: "project") }
let(:shared) { project.import_export_shared }
before do
stub_const("#{described_class}::RENAMES", renames)
end
- context 'when importing' do
+ context "when importing" do
let(:project_tree_restorer) { Gitlab::ImportExport::ProjectTreeRestorer.new(user: user, shared: shared, project: project) }
- let(:import_path) { 'spec/lib/gitlab/import_export' }
+ let(:import_path) { "spec/lib/gitlab/import_export" }
let(:file_content) { IO.read("#{import_path}/project.json") }
let!(:json_file) { ActiveSupport::JSON.decode(file_content) }
let(:tree_hash) { project_tree_restorer.instance_variable_get(:@tree_hash) }
@@ -31,7 +31,7 @@ describe Gitlab::ImportExport::RelationRenameService do
allow(ActiveSupport::JSON).to receive(:decode).with(file_content).and_return(json_file)
end
- context 'when the file has only old relationship names' do
+ context "when the file has only old relationship names" do
# Configuring the json as an old version exported file, with only
# the previous association with the old name
before do
@@ -40,7 +40,7 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- it 'renames old relationships to the new name' do
+ it "renames old relationships to the new name" do
expect(json_file.keys).to include(*renames.keys)
project_tree_restorer.restore
@@ -50,7 +50,7 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- context 'when the file has both the old and new relationships' do
+ context "when the file has both the old and new relationships" do
# Configuring the json as the new version exported file, with both
# the old association name and the new one
before do
@@ -60,7 +60,7 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- it 'uses the new relationships and removes the old ones from the hash' do
+ it "uses the new relationships and removes the old ones from the hash" do
expect(json_file.keys).to include(*renames.keys)
project_tree_restorer.restore
@@ -71,7 +71,7 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- context 'when the file has only new relationship names' do
+ context "when the file has only new relationship names" do
# Configuring the json as the future version exported file, with only
# the new association name
before do
@@ -80,7 +80,7 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- it 'uses the new relationships' do
+ it "uses the new relationships" do
expect(json_file.keys).not_to include(*renames.keys)
project_tree_restorer.restore
@@ -90,11 +90,11 @@ describe Gitlab::ImportExport::RelationRenameService do
end
end
- context 'when exporting' do
+ context "when exporting" do
let(:project_tree_saver) { Gitlab::ImportExport::ProjectTreeSaver.new(project: project, current_user: user, shared: shared) }
let(:project_tree) { project_tree_saver.send(:project_json) }
- it 'adds old relationships to the exported file' do
+ it "adds old relationships to the exported file" do
project_tree.merge!(renames.values.map { |new_name| [new_name, []] }.to_h)
allow(project_tree_saver).to receive(:save) do |arg|
diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
index 8a699eb1461..491c76dba19 100644
--- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::RepoRestorer do
include GitHelpers
- describe 'bundle a project Git repo' do
+ describe "bundle a project Git repo" do
let(:user) { create(:user) }
- let!(:project_with_repo) { create(:project, :repository, name: 'test-repo-restorer', path: 'test-repo-restorer') }
+ let!(:project_with_repo) { create(:project, :repository, name: "test-repo-restorer", path: "test-repo-restorer") }
let!(:project) { create(:project) }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
@@ -31,11 +31,11 @@ describe Gitlab::ImportExport::RepoRestorer do
end
end
- it 'restores the repo successfully' do
+ it "restores the repo successfully" do
expect(restorer.restore).to be_truthy
end
- it 'has the webhooks' do
+ it "has the webhooks" do
restorer.restore
expect(project_hook_exists?(project)).to be true
diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb
index 5a646b4aac8..a74e5ce1b3c 100644
--- a/spec/lib/gitlab/import_export/repo_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::RepoSaver do
- describe 'bundle a project Git repo' do
+ describe "bundle a project Git repo" do
let(:user) { create(:user) }
- let!(:project) { create(:project, :public, name: 'searchable_project') }
+ let!(:project) { create(:project, :public, name: "searchable_project") }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
let(:bundler) { described_class.new(project: project, shared: shared) }
@@ -17,7 +17,7 @@ describe Gitlab::ImportExport::RepoSaver do
FileUtils.rm_rf(export_path)
end
- it 'bundles the repo successfully' do
+ it "bundles the repo successfully" do
expect(bundler.save).to be true
end
end
diff --git a/spec/lib/gitlab/import_export/saver_spec.rb b/spec/lib/gitlab/import_export/saver_spec.rb
index d185ff2dfcc..b29191c945b 100644
--- a/spec/lib/gitlab/import_export/saver_spec.rb
+++ b/spec/lib/gitlab/import_export/saver_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'fileutils'
+require "spec_helper"
+require "fileutils"
describe Gitlab::ImportExport::Saver do
- let!(:project) { create(:project, :public, name: 'project') }
+ let!(:project) { create(:project, :public, name: "project") }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
subject { described_class.new(project: project, shared: shared) }
@@ -18,12 +18,12 @@ describe Gitlab::ImportExport::Saver do
FileUtils.rm_rf(export_path)
end
- it 'saves the repo using object storage' do
+ it "saves the repo using object storage" do
stub_uploads_object_storage(ImportExportUploader)
subject.save
expect(ImportExportUpload.find_by(project: project).export_file.url)
- .to match(%r[\/uploads\/-\/system\/import_export_upload\/export_file.*])
+ .to match(%r{\/uploads\/-\/system\/import_export_upload\/export_file.*})
end
end
diff --git a/spec/lib/gitlab/import_export/shared_spec.rb b/spec/lib/gitlab/import_export/shared_spec.rb
index 2c288cff6ef..9a1f96f04d9 100644
--- a/spec/lib/gitlab/import_export/shared_spec.rb
+++ b/spec/lib/gitlab/import_export/shared_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
-require 'fileutils'
+require "spec_helper"
+require "fileutils"
describe Gitlab::ImportExport::Shared do
let(:project) { build(:project) }
subject { project.import_export_shared }
- describe '#error' do
- let(:error) { StandardError.new('Error importing into /my/folder Permission denied @ unlink_internal - /var/opt/gitlab/gitlab-rails/shared/a/b/c/uploads/file') }
+ describe "#error" do
+ let(:error) { StandardError.new("Error importing into /my/folder Permission denied @ unlink_internal - /var/opt/gitlab/gitlab-rails/shared/a/b/c/uploads/file") }
- it 'filters any full paths' do
+ it "filters any full paths" do
subject.error(error)
- expect(subject.errors).to eq(['Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED]'])
+ expect(subject.errors).to eq(["Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED]"])
end
- it 'updates the import JID' do
- import_state = create(:import_state, project: project, jid: 'jid-test')
+ it "updates the import JID" do
+ import_state = create(:import_state, project: project, jid: "jid-test")
expect_next_instance_of(Gitlab::Import::Logger) do |logger|
expect(logger).to receive(:error).with(hash_including(import_jid: import_state.jid))
@@ -24,16 +24,16 @@ describe Gitlab::ImportExport::Shared do
subject.error(error)
end
- it 'calls the error logger with the full message' do
+ it "calls the error logger with the full message" do
expect(subject).to receive(:log_error).with(hash_including(message: error.message))
subject.error(error)
end
- it 'calls the debug logger with a backtrace' do
- error.set_backtrace('backtrace')
+ it "calls the debug logger with a backtrace" do
+ error.set_backtrace("backtrace")
- expect(subject).to receive(:log_debug).with(hash_including(backtrace: 'backtrace'))
+ expect(subject).to receive(:log_debug).with(hash_including(backtrace: "backtrace"))
subject.error(error)
end
diff --git a/spec/lib/gitlab/import_export/uploads_manager_spec.rb b/spec/lib/gitlab/import_export/uploads_manager_spec.rb
index 792117e1df1..6094558d2ba 100644
--- a/spec/lib/gitlab/import_export/uploads_manager_spec.rb
+++ b/spec/lib/gitlab/import_export/uploads_manager_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::UploadsManager do
let(:shared) { project.import_export_shared }
@@ -18,28 +18,28 @@ describe Gitlab::ImportExport::UploadsManager do
FileUtils.rm_rf(shared.export_path)
end
- describe '#save' do
- context 'when the project has uploads locally stored' do
+ describe "#save" do
+ context "when the project has uploads locally stored" do
let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) }
before do
project.uploads << upload
end
- it 'does not cause errors' do
+ it "does not cause errors" do
manager.save
expect(shared.errors).to be_empty
end
- it 'copies the file in the correct location when there is an upload' do
+ it "copies the file in the correct location when there is an upload" do
manager.save
expect(File).to exist(exported_file_path)
end
- context 'with orphaned project upload files' do
- let(:orphan_path) { File.join(FileUploader.absolute_base_dir(project), 'f93f088ddf492ffd950cf059002cbbb6', 'orphan.jpg') }
+ context "with orphaned project upload files" do
+ let(:orphan_path) { File.join(FileUploader.absolute_base_dir(project), "f93f088ddf492ffd950cf059002cbbb6", "orphan.jpg") }
let(:exported_orphan_path) { "#{shared.export_path}/uploads/f93f088ddf492ffd950cf059002cbbb6/orphan.jpg" }
before do
@@ -51,19 +51,19 @@ describe Gitlab::ImportExport::UploadsManager do
File.delete(orphan_path) if File.exist?(orphan_path)
end
- it 'excludes orphaned upload files' do
+ it "excludes orphaned upload files" do
manager.save
expect(File).not_to exist(exported_orphan_path)
end
end
- context 'with an upload missing its file' do
+ context "with an upload missing its file" do
before do
File.delete(upload.absolute_path)
end
- it 'does not cause errors' do
+ it "does not cause errors" do
manager.save
expect(shared.errors).to be_empty
@@ -72,18 +72,18 @@ describe Gitlab::ImportExport::UploadsManager do
end
end
- describe '#restore' do
+ describe "#restore" do
before do
stub_uploads_object_storage(FileUploader)
- FileUtils.mkdir_p(File.join(shared.export_path, 'uploads/72a497a02fe3ee09edae2ed06d390038'))
- FileUtils.touch(File.join(shared.export_path, 'uploads/72a497a02fe3ee09edae2ed06d390038', "dummy.txt"))
+ FileUtils.mkdir_p(File.join(shared.export_path, "uploads/72a497a02fe3ee09edae2ed06d390038"))
+ FileUtils.touch(File.join(shared.export_path, "uploads/72a497a02fe3ee09edae2ed06d390038", "dummy.txt"))
end
- it 'restores the file' do
+ it "restores the file" do
manager.restore
- expect(project.uploads.map { |u| u.build_uploader.filename }).to include('dummy.txt')
+ expect(project.uploads.map { |u| u.build_uploader.filename }).to include("dummy.txt")
end
end
end
diff --git a/spec/lib/gitlab/import_export/uploads_restorer_spec.rb b/spec/lib/gitlab/import_export/uploads_restorer_spec.rb
index 6072f18b8c7..2adf8c95916 100644
--- a/spec/lib/gitlab/import_export/uploads_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/uploads_restorer_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::UploadsRestorer do
- describe 'bundle a project Git repo' do
+ describe "bundle a project Git repo" do
let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" }
let(:shared) { project.import_export_shared }
before do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
- FileUtils.mkdir_p(File.join(shared.export_path, 'uploads/random'))
- FileUtils.touch(File.join(shared.export_path, 'uploads/random', 'dummy.txt'))
+ FileUtils.mkdir_p(File.join(shared.export_path, "uploads/random"))
+ FileUtils.touch(File.join(shared.export_path, "uploads/random", "dummy.txt"))
end
after do
FileUtils.rm_rf(export_path)
end
- describe 'legacy storage' do
+ describe "legacy storage" do
let(:project) { create(:project, :legacy_storage) }
subject(:restorer) { described_class.new(project: project, shared: shared) }
- it 'saves the uploads successfully' do
+ it "saves the uploads successfully" do
expect(restorer.restore).to be true
end
- it 'copies the uploads to the project path' do
+ it "copies the uploads to the project path" do
subject.restore
- expect(project.uploads.map { |u| u.build_uploader.filename }).to include('dummy.txt')
+ expect(project.uploads.map { |u| u.build_uploader.filename }).to include("dummy.txt")
end
end
- describe 'hashed storage' do
+ describe "hashed storage" do
let(:project) { create(:project) }
subject(:restorer) { described_class.new(project: project, shared: shared) }
- it 'saves the uploads successfully' do
+ it "saves the uploads successfully" do
expect(restorer.restore).to be true
end
- it 'copies the uploads to the project path' do
+ it "copies the uploads to the project path" do
subject.restore
- expect(project.uploads.map { |u| u.build_uploader.filename }).to include('dummy.txt')
+ expect(project.uploads.map { |u| u.build_uploader.filename }).to include("dummy.txt")
end
end
end
diff --git a/spec/lib/gitlab/import_export/uploads_saver_spec.rb b/spec/lib/gitlab/import_export/uploads_saver_spec.rb
index 24993460e51..879df99c900 100644
--- a/spec/lib/gitlab/import_export/uploads_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/uploads_saver_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::UploadsSaver do
- describe 'bundle a project Git repo' do
+ describe "bundle a project Git repo" do
let(:export_path) { "#{Dir.tmpdir}/uploads_saver_spec" }
- let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
+ let(:file) { fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif") }
let(:shared) { project.import_export_shared }
before do
@@ -14,7 +14,7 @@ describe Gitlab::ImportExport::UploadsSaver do
FileUtils.rm_rf(export_path)
end
- describe 'legacy storage' do
+ describe "legacy storage" do
let(:project) { create(:project, :legacy_storage) }
subject(:saver) { described_class.new(shared: shared, project: project) }
@@ -23,20 +23,20 @@ describe Gitlab::ImportExport::UploadsSaver do
UploadService.new(project, file, FileUploader).execute
end
- it 'saves the uploads successfully' do
+ it "saves the uploads successfully" do
expect(saver.save).to be true
end
- it 'copies the uploads to the export path' do
+ it "copies the uploads to the export path" do
saver.save
- uploads = Dir.glob(File.join(shared.export_path, 'uploads/**/*')).map { |file| File.basename(file) }
+ uploads = Dir.glob(File.join(shared.export_path, "uploads/**/*")).map { |file| File.basename(file) }
- expect(uploads).to include('banana_sample.gif')
+ expect(uploads).to include("banana_sample.gif")
end
end
- describe 'hashed storage' do
+ describe "hashed storage" do
let(:project) { create(:project) }
subject(:saver) { described_class.new(shared: shared, project: project) }
@@ -45,16 +45,16 @@ describe Gitlab::ImportExport::UploadsSaver do
UploadService.new(project, file, FileUploader).execute
end
- it 'saves the uploads successfully' do
+ it "saves the uploads successfully" do
expect(saver.save).to be true
end
- it 'copies the uploads to the export path' do
+ it "copies the uploads to the export path" do
saver.save
- uploads = Dir.glob(File.join(shared.export_path, 'uploads/**/*')).map { |file| File.basename(file) }
+ uploads = Dir.glob(File.join(shared.export_path, "uploads/**/*")).map { |file| File.basename(file) }
- expect(uploads).to include('banana_sample.gif')
+ expect(uploads).to include("banana_sample.gif")
end
end
end
diff --git a/spec/lib/gitlab/import_export/version_checker_spec.rb b/spec/lib/gitlab/import_export/version_checker_spec.rb
index 76f8253ec9b..9fe360a24ca 100644
--- a/spec/lib/gitlab/import_export/version_checker_spec.rb
+++ b/spec/lib/gitlab/import_export/version_checker_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
include ImportExport::CommonUtil
describe Gitlab::ImportExport::VersionChecker do
let!(:shared) { Gitlab::ImportExport::Shared.new(nil) }
- describe 'bundle a project Git repo' do
+ describe "bundle a project Git repo" do
let(:version) { Gitlab::ImportExport.version }
before do
- allow_any_instance_of(Gitlab::ImportExport::Shared).to receive(:relative_archive_path).and_return('')
+ allow_any_instance_of(Gitlab::ImportExport::Shared).to receive(:relative_archive_path).and_return("")
allow(File).to receive(:open).and_return(version)
end
- it 'returns true if Import/Export have the same version' do
+ it "returns true if Import/Export have the same version" do
expect(described_class.check!(shared: shared)).to be true
end
- context 'newer version' do
- let(:version) { '900.0'}
+ context "newer version" do
+ let(:version) { "900.0"}
- it 'returns false if export version is newer' do
+ it "returns false if export version is newer" do
expect(described_class.check!(shared: shared)).to be false
end
- it 'shows the correct error message' do
+ it "shows the correct error message" do
described_class.check!(shared: shared)
expect(shared.errors.first).to eq("Import version mismatch: Required #{Gitlab::ImportExport.version} but was #{version}")
@@ -31,14 +31,14 @@ describe Gitlab::ImportExport::VersionChecker do
end
end
- describe 'version file access check' do
- it 'does not read a symlink' do
+ describe "version file access check" do
+ it "does not read a symlink" do
Dir.mktmpdir do |tmpdir|
- setup_symlink(tmpdir, 'VERSION')
+ setup_symlink(tmpdir, "VERSION")
described_class.check!(shared: shared)
- expect(shared.errors.first).not_to include('test')
+ expect(shared.errors.first).not_to include("test")
end
end
end
diff --git a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
index 441aa1defe6..438029ef8a0 100644
--- a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
+++ b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::WikiRepoSaver do
- describe 'bundle a wiki Git repo' do
+ describe "bundle a wiki Git repo" do
let(:user) { create(:user) }
- let!(:project) { create(:project, :public, :wiki_repo, name: 'searchable_project') }
+ let!(:project) { create(:project, :public, :wiki_repo, name: "searchable_project") }
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
let(:shared) { project.import_export_shared }
let(:wiki_bundler) { described_class.new(project: project, shared: shared) }
@@ -20,7 +20,7 @@ describe Gitlab::ImportExport::WikiRepoSaver do
FileUtils.rm_rf(export_path)
end
- it 'bundles the repo successfully' do
+ it "bundles the repo successfully" do
expect(wiki_bundler.save).to be true
end
end
diff --git a/spec/lib/gitlab/import_export/wiki_restorer_spec.rb b/spec/lib/gitlab/import_export/wiki_restorer_spec.rb
index f99f198da33..b8730b2fede 100644
--- a/spec/lib/gitlab/import_export/wiki_restorer_spec.rb
+++ b/spec/lib/gitlab/import_export/wiki_restorer_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportExport::WikiRestorer do
- describe 'restore a wiki Git repo' do
+ describe "restore a wiki Git repo" do
let!(:project_with_wiki) { create(:project, :wiki_repo) }
let!(:project_without_wiki) { create(:project) }
let!(:project) { create(:project) }
@@ -28,14 +28,14 @@ describe Gitlab::ImportExport::WikiRestorer do
Gitlab::Shell.new.remove_repository(project.wiki.repository_storage, project.wiki.disk_path)
end
- it 'restores the wiki repo successfully' do
+ it "restores the wiki repo successfully" do
expect(restorer.restore).to be true
end
describe "no wiki in the bundle" do
let(:bundler) { Gitlab::ImportExport::WikiRepoSaver.new(project: project_without_wiki, shared: shared) }
- it 'creates an empty wiki' do
+ it "creates an empty wiki" do
expect(restorer.restore).to be true
expect(project.wiki_repository_exists?).to be true
diff --git a/spec/lib/gitlab/import_sources_spec.rb b/spec/lib/gitlab/import_sources_spec.rb
index 94abf9679c4..46ec9acaeb0 100644
--- a/spec/lib/gitlab/import_sources_spec.rb
+++ b/spec/lib/gitlab/import_sources_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ImportSources do
- describe '.options' do
- it 'returns a hash' do
+ describe ".options" do
+ it "returns a hash" do
expected =
{
- 'GitHub' => 'github',
- 'Bitbucket Cloud' => 'bitbucket',
- 'Bitbucket Server' => 'bitbucket_server',
- 'GitLab.com' => 'gitlab',
- 'Google Code' => 'google_code',
- 'FogBugz' => 'fogbugz',
- 'Repo by URL' => 'git',
- 'GitLab export' => 'gitlab_project',
- 'Gitea' => 'gitea',
- 'Manifest file' => 'manifest'
+ "GitHub" => "github",
+ "Bitbucket Cloud" => "bitbucket",
+ "Bitbucket Server" => "bitbucket_server",
+ "GitLab.com" => "gitlab",
+ "Google Code" => "google_code",
+ "FogBugz" => "fogbugz",
+ "Repo by URL" => "git",
+ "GitLab export" => "gitlab_project",
+ "Gitea" => "gitea",
+ "Manifest file" => "manifest",
}
expect(described_class.options).to eq(expected)
end
end
- describe '.values' do
- it 'returns an array' do
+ describe ".values" do
+ it "returns an array" do
expected =
- %w(
+ %w[
github
bitbucket
bitbucket_server
@@ -35,16 +35,16 @@ describe Gitlab::ImportSources do
gitlab_project
gitea
manifest
- )
+ ]
expect(described_class.values).to eq(expected)
end
end
- describe '.importer_names' do
- it 'returns an array of importer names' do
+ describe ".importer_names" do
+ it "returns an array of importer names" do
expected =
- %w(
+ %w[
github
bitbucket
bitbucket_server
@@ -53,24 +53,24 @@ describe Gitlab::ImportSources do
fogbugz
gitlab_project
gitea
- )
+ ]
expect(described_class.importer_names).to eq(expected)
end
end
- describe '.importer' do
+ describe ".importer" do
import_sources = {
- 'github' => Gitlab::GithubImport::ParallelImporter,
- 'bitbucket' => Gitlab::BitbucketImport::Importer,
- 'bitbucket_server' => Gitlab::BitbucketServerImport::Importer,
- 'gitlab' => Gitlab::GitlabImport::Importer,
- 'google_code' => Gitlab::GoogleCodeImport::Importer,
- 'fogbugz' => Gitlab::FogbugzImport::Importer,
- 'git' => nil,
- 'gitlab_project' => Gitlab::ImportExport::Importer,
- 'gitea' => Gitlab::LegacyGithubImport::Importer,
- 'manifest' => nil
+ "github" => Gitlab::GithubImport::ParallelImporter,
+ "bitbucket" => Gitlab::BitbucketImport::Importer,
+ "bitbucket_server" => Gitlab::BitbucketServerImport::Importer,
+ "gitlab" => Gitlab::GitlabImport::Importer,
+ "google_code" => Gitlab::GoogleCodeImport::Importer,
+ "fogbugz" => Gitlab::FogbugzImport::Importer,
+ "git" => nil,
+ "gitlab_project" => Gitlab::ImportExport::Importer,
+ "gitea" => Gitlab::LegacyGithubImport::Importer,
+ "manifest" => nil,
}
import_sources.each do |name, klass|
@@ -80,18 +80,18 @@ describe Gitlab::ImportSources do
end
end
- describe '.title' do
+ describe ".title" do
import_sources = {
- 'github' => 'GitHub',
- 'bitbucket' => 'Bitbucket Cloud',
- 'bitbucket_server' => 'Bitbucket Server',
- 'gitlab' => 'GitLab.com',
- 'google_code' => 'Google Code',
- 'fogbugz' => 'FogBugz',
- 'git' => 'Repo by URL',
- 'gitlab_project' => 'GitLab export',
- 'gitea' => 'Gitea',
- 'manifest' => 'Manifest file'
+ "github" => "GitHub",
+ "bitbucket" => "Bitbucket Cloud",
+ "bitbucket_server" => "Bitbucket Server",
+ "gitlab" => "GitLab.com",
+ "google_code" => "Google Code",
+ "fogbugz" => "FogBugz",
+ "git" => "Repo by URL",
+ "gitlab_project" => "GitLab export",
+ "gitea" => "Gitea",
+ "manifest" => "Manifest file",
}
import_sources.each do |name, title|
@@ -101,10 +101,10 @@ describe Gitlab::ImportSources do
end
end
- describe 'imports_repository? checker' do
+ describe "imports_repository? checker" do
let(:allowed_importers) { %w[github gitlab_project bitbucket_server] }
- it 'fails if any importer other than the allowed ones implements this method' do
+ it "fails if any importer other than the allowed ones implements this method" do
current_importers = described_class.values.select { |kind| described_class.importer(kind).try(:imports_repository?) }
not_allowed_importers = current_importers - allowed_importers
@@ -113,7 +113,7 @@ describe Gitlab::ImportSources do
def failure_message(importers_class_names)
<<-MSG
- It looks like the #{importers_class_names.join(', ')} importers implements its own way to import the repository.
+ It looks like the #{importers_class_names.join(", ")} importers implements its own way to import the repository.
That means that the lfs object download must be handled for each of them. You can use 'LfsImportService' and
'LfsDownloadService' to implement it. After that, add the importer name to the list of allowed importers in this spec.
MSG
diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb
index 2db62ab983a..307641c6acb 100644
--- a/spec/lib/gitlab/incoming_email_spec.rb
+++ b/spec/lib/gitlab/incoming_email_spec.rb
@@ -7,7 +7,7 @@ describe Gitlab::IncomingEmail do
stub_incoming_email_setting(enabled: true)
end
- it 'returns true' do
+ it "returns true" do
expect(described_class.enabled?).to be_truthy
end
end
@@ -23,45 +23,45 @@ describe Gitlab::IncomingEmail do
end
end
- describe 'self.supports_wildcard?' do
- context 'address contains the wildcard placeholder' do
+ describe "self.supports_wildcard?" do
+ context "address contains the wildcard placeholder" do
before do
- stub_incoming_email_setting(address: 'replies+%{key}@example.com')
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
end
- it 'confirms that wildcard is supported' do
+ it "confirms that wildcard is supported" do
expect(described_class.supports_wildcard?).to be_truthy
end
end
context "address doesn't contain the wildcard placeholder" do
before do
- stub_incoming_email_setting(address: 'replies@example.com')
+ stub_incoming_email_setting(address: "replies@example.com")
end
- it 'returns that wildcard is not supported' do
+ it "returns that wildcard is not supported" do
expect(described_class.supports_wildcard?).to be_falsey
end
end
- context 'address is not set' do
+ context "address is not set" do
before do
stub_incoming_email_setting(address: nil)
end
- it 'returns that wildcard is not supported' do
+ it "returns that wildcard is not supported" do
expect(described_class.supports_wildcard?).to be_falsey
end
end
end
- context 'self.unsubscribe_address' do
+ context "self.unsubscribe_address" do
before do
- stub_incoming_email_setting(address: 'replies+%{key}@example.com')
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
end
- it 'returns the address with interpolated reply key and unsubscribe suffix' do
- expect(described_class.unsubscribe_address('key')).to eq("replies+key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX}@example.com")
+ it "returns the address with interpolated reply key and unsubscribe suffix" do
+ expect(described_class.unsubscribe_address("key")).to eq("replies+key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX}@example.com")
end
end
@@ -84,25 +84,25 @@ describe Gitlab::IncomingEmail do
expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
end
- it 'does not match emails with extra bits' do
- expect(described_class.key_from_address('somereplies+somekey@example.com.someotherdomain.com')).to be nil
+ it "does not match emails with extra bits" do
+ expect(described_class.key_from_address("somereplies+somekey@example.com.someotherdomain.com")).to be nil
end
end
- context 'self.key_from_fallback_message_id' do
- it 'returns reply key' do
- expect(described_class.key_from_fallback_message_id('reply-key@localhost')).to eq('key')
+ context "self.key_from_fallback_message_id" do
+ it "returns reply key" do
+ expect(described_class.key_from_fallback_message_id("reply-key@localhost")).to eq("key")
end
end
- context 'self.scan_fallback_references' do
+ context "self.scan_fallback_references" do
let(:references) do
- '<issue_1@localhost>' +
- ' <reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost>' +
- ',<exchange@microsoft.com>'
+ "<issue_1@localhost>" +
+ " <reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost>" +
+ ",<exchange@microsoft.com>"
end
- it 'returns reply key' do
+ it "returns reply key" do
expect(described_class.scan_fallback_references(references))
.to eq(%w[issue_1@localhost
reply-59d8df8370b7e95c5a49fbf86aeb2c93@localhost
diff --git a/spec/lib/gitlab/insecure_key_fingerprint_spec.rb b/spec/lib/gitlab/insecure_key_fingerprint_spec.rb
index 6532579b1c9..0cc43e5a60a 100644
--- a/spec/lib/gitlab/insecure_key_fingerprint_spec.rb
+++ b/spec/lib/gitlab/insecure_key_fingerprint_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::InsecureKeyFingerprint do
let(:key) do
- 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn' \
- '1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qk' \
- 'r8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMg' \
- 'Jw0='
+ "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn" \
+ "1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qk" \
+ "r8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMg" \
+ "Jw0="
end
let(:fingerprint) { "3f:a2:ee:de:b5:de:53:c3:aa:2f:9c:45:24:4c:47:7b" }
diff --git a/spec/lib/gitlab/issuable_metadata_spec.rb b/spec/lib/gitlab/issuable_metadata_spec.rb
index 6ec86163233..798843efaad 100644
--- a/spec/lib/gitlab/issuable_metadata_spec.rb
+++ b/spec/lib/gitlab/issuable_metadata_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::IssuableMetadata do
let(:user) { create(:user) }
@@ -6,15 +6,15 @@ describe Gitlab::IssuableMetadata do
subject { Class.new { include Gitlab::IssuableMetadata }.new }
- it 'returns an empty Hash if an empty collection is provided' do
- expect(subject.issuable_meta_data(Issue.none, 'Issue')).to eq({})
+ it "returns an empty Hash if an empty collection is provided" do
+ expect(subject.issuable_meta_data(Issue.none, "Issue")).to eq({})
end
- it 'raises an error when given a collection with no limit' do
- expect { subject.issuable_meta_data(Issue.all, 'Issue') }.to raise_error(/must have a limit/)
+ it "raises an error when given a collection with no limit" do
+ expect { subject.issuable_meta_data(Issue.all, "Issue") }.to raise_error(/must have a limit/)
end
- context 'issues' do
+ context "issues" do
let!(:issue) { create(:issue, author: user, project: project) }
let!(:closed_issue) { create(:issue, state: :closed, author: user, project: project) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: closed_issue) }
@@ -22,8 +22,8 @@ describe Gitlab::IssuableMetadata do
let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, target_project: project, title: "Test") }
let!(:closing_issues) { create(:merge_requests_closing_issues, issue: issue, merge_request: merge_request) }
- it 'aggregates stats on issues' do
- data = subject.issuable_meta_data(Issue.all.limit(10), 'Issue')
+ it "aggregates stats on issues" do
+ data = subject.issuable_meta_data(Issue.all.limit(10), "Issue")
expect(data.count).to eq(2)
expect(data[issue.id].upvotes).to eq(1)
@@ -38,15 +38,15 @@ describe Gitlab::IssuableMetadata do
end
end
- context 'merge requests' do
+ context "merge requests" do
let!(:merge_request) { create(:merge_request, :simple, author: user, assignee: user, source_project: project, target_project: project, title: "Test") }
let!(:merge_request_closed) { create(:merge_request, state: "closed", source_project: project, target_project: project, title: "Closed Test") }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request) }
let!(:upvote) { create(:award_emoji, :upvote, awardable: merge_request) }
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
- it 'aggregates stats on merge requests' do
- data = subject.issuable_meta_data(MergeRequest.all.limit(10), 'MergeRequest')
+ it "aggregates stats on merge requests" do
+ data = subject.issuable_meta_data(MergeRequest.all.limit(10), "MergeRequest")
expect(data.count).to eq(2)
expect(data[merge_request.id].upvotes).to eq(1)
diff --git a/spec/lib/gitlab/issuable_sorter_spec.rb b/spec/lib/gitlab/issuable_sorter_spec.rb
index 642a6cb6caa..6981231ef3a 100644
--- a/spec/lib/gitlab/issuable_sorter_spec.rb
+++ b/spec/lib/gitlab/issuable_sorter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::IssuableSorter do
let(:namespace1) { build_stubbed(:namespace, id: 1) }
@@ -19,27 +19,27 @@ describe Gitlab::IssuableSorter do
[build_stubbed(:issue, iid: 1, project: project1),
build_stubbed(:issue, iid: 2, project: project1),
build_stubbed(:issue, iid: 10, project: project1),
- build_stubbed(:issue, iid: 20, project: project1)]
+ build_stubbed(:issue, iid: 20, project: project1),]
end
- it 'sorts references by a given key' do
+ it "sorts references by a given key" do
expect(described_class.sort(project1, unsorted)).to eq(sorted)
end
- context 'for JIRA issues' do
+ context "for JIRA issues" do
let(:sorted) do
- [ExternalIssue.new('JIRA-1', project1),
- ExternalIssue.new('JIRA-2', project1),
- ExternalIssue.new('JIRA-10', project1),
- ExternalIssue.new('JIRA-20', project1)]
+ [ExternalIssue.new("JIRA-1", project1),
+ ExternalIssue.new("JIRA-2", project1),
+ ExternalIssue.new("JIRA-10", project1),
+ ExternalIssue.new("JIRA-20", project1),]
end
- it 'sorts references by a given key' do
+ it "sorts references by a given key" do
expect(described_class.sort(project1, unsorted)).to eq(sorted)
end
end
- context 'for references from multiple projects and namespaces' do
+ context "for references from multiple projects and namespaces" do
let(:sorted) do
[build_stubbed(:issue, iid: 1, project: project1),
build_stubbed(:issue, iid: 2, project: project1),
@@ -48,14 +48,14 @@ describe Gitlab::IssuableSorter do
build_stubbed(:issue, iid: 1, project: project3),
build_stubbed(:issue, iid: 1, project: project4),
build_stubbed(:issue, iid: 1, project: project5),
- build_stubbed(:issue, iid: 1, project: project6)]
+ build_stubbed(:issue, iid: 1, project: project6),]
end
let(:unsorted) do
[sorted[3], sorted[1], sorted[4], sorted[2],
- sorted[6], sorted[5], sorted[0], sorted[7]]
+ sorted[6], sorted[5], sorted[0], sorted[7],]
end
- it 'sorts references by project and then by a given key' do
+ it "sorts references by project and then by a given key" do
expect(subject.sort(project1, unsorted)).to eq(sorted)
end
end
diff --git a/spec/lib/gitlab/issuables_count_for_state_spec.rb b/spec/lib/gitlab/issuables_count_for_state_spec.rb
index c262fdfcb61..a7b2e559ba9 100644
--- a/spec/lib/gitlab/issuables_count_for_state_spec.rb
+++ b/spec/lib/gitlab/issuables_count_for_state_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::IssuablesCountForState do
let(:finder) do
- double(:finder, count_by_state: { opened: 2, closed: 1 })
+ double(:finder, count_by_state: {opened: 2, closed: 1})
end
let(:counter) { described_class.new(finder) }
- describe '#for_state_or_opened' do
- it 'returns the number of issuables for the given state' do
+ describe "#for_state_or_opened" do
+ it "returns the number of issuables for the given state" do
expect(counter.for_state_or_opened(:closed)).to eq(1)
end
- it 'returns the number of open issuables when no state is given' do
+ it "returns the number of open issuables when no state is given" do
expect(counter.for_state_or_opened).to eq(2)
end
- it 'returns the number of open issuables when a nil value is given' do
+ it "returns the number of open issuables when a nil value is given" do
expect(counter.for_state_or_opened(nil)).to eq(2)
end
end
- describe '#[]' do
- it 'returns the number of issuables for the given state' do
+ describe "#[]" do
+ it "returns the number of issuables for the given state" do
expect(counter[:closed]).to eq(1)
end
- it 'casts valid states from Strings to Symbols' do
- expect(counter['closed']).to eq(1)
+ it "casts valid states from Strings to Symbols" do
+ expect(counter["closed"]).to eq(1)
end
- it 'returns 0 when using an invalid state name as a String' do
- expect(counter['kittens']).to be_zero
+ it "returns 0 when using an invalid state name as a String" do
+ expect(counter["kittens"]).to be_zero
end
end
end
diff --git a/spec/lib/gitlab/job_waiter_spec.rb b/spec/lib/gitlab/job_waiter_spec.rb
index b0b4fdc09bc..52624570842 100644
--- a/spec/lib/gitlab/job_waiter_spec.rb
+++ b/spec/lib/gitlab/job_waiter_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::JobWaiter do
- describe '.notify' do
- it 'pushes the jid to the named queue' do
- key = 'gitlab:job_waiter:foo'
+ describe ".notify" do
+ it "pushes the jid to the named queue" do
+ key = "gitlab:job_waiter:foo"
jid = 1
- redis = double('redis')
+ redis = double("redis")
expect(Gitlab::Redis::SharedState).to receive(:with).and_yield(redis)
expect(redis).to receive(:lpush).with(key, jid)
@@ -14,26 +14,26 @@ describe Gitlab::JobWaiter do
end
end
- describe '#wait' do
+ describe "#wait" do
let(:waiter) { described_class.new(2) }
- it 'returns when all jobs have been completed' do
- described_class.notify(waiter.key, 'a')
- described_class.notify(waiter.key, 'b')
+ it "returns when all jobs have been completed" do
+ described_class.notify(waiter.key, "a")
+ described_class.notify(waiter.key, "b")
result = nil
expect { Timeout.timeout(1) { result = waiter.wait(2) } }.not_to raise_error
- expect(result).to contain_exactly('a', 'b')
+ expect(result).to contain_exactly("a", "b")
end
- it 'times out if not all jobs complete' do
- described_class.notify(waiter.key, 'a')
+ it "times out if not all jobs complete" do
+ described_class.notify(waiter.key, "a")
result = nil
expect { Timeout.timeout(2) { result = waiter.wait(1) } }.not_to raise_error
- expect(result).to contain_exactly('a')
+ expect(result).to contain_exactly("a")
end
end
end
diff --git a/spec/lib/gitlab/json_cache_spec.rb b/spec/lib/gitlab/json_cache_spec.rb
index b52078e8556..3d81b334bd9 100644
--- a/spec/lib/gitlab/json_cache_spec.rb
+++ b/spec/lib/gitlab/json_cache_spec.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::JsonCache do
- let(:backend) { double('backend').as_null_object }
- let(:namespace) { 'geo' }
- let(:key) { 'foo' }
+ let(:backend) { double("backend").as_null_object }
+ let(:namespace) { "geo" }
+ let(:key) { "foo" }
let(:expanded_key) { "#{namespace}:#{key}:#{Rails.version}" }
let(:broadcast_message) { create(:broadcast_message) }
subject(:cache) { described_class.new(namespace: namespace, backend: backend) }
- describe '#active?' do
- context 'when backend respond to active? method' do
- it 'delegates to the underlying cache implementation' do
- backend = double('backend', active?: false)
+ describe "#active?" do
+ context "when backend respond to active? method" do
+ it "delegates to the underlying cache implementation" do
+ backend = double("backend", active?: false)
cache = described_class.new(namespace: namespace, backend: backend)
@@ -22,9 +22,9 @@ describe Gitlab::JsonCache do
end
end
- context 'when backend does not respond to active? method' do
- it 'returns true' do
- backend = double('backend')
+ context "when backend does not respond to active? method" do
+ it "returns true" do
+ backend = double("backend")
cache = described_class.new(namespace: namespace, backend: backend)
@@ -33,9 +33,9 @@ describe Gitlab::JsonCache do
end
end
- describe '#cache_key' do
- context 'when namespace is not defined' do
- it 'expands out the key with Rails version' do
+ describe "#cache_key" do
+ context "when namespace is not defined" do
+ it "expands out the key with Rails version" do
cache = described_class.new(cache_key_with_version: true)
cache_key = cache.cache_key(key)
@@ -44,8 +44,8 @@ describe Gitlab::JsonCache do
end
end
- context 'when cache_key_with_version is true' do
- it 'expands out the key with namespace and Rails version' do
+ context "when cache_key_with_version is true" do
+ it "expands out the key with namespace and Rails version" do
cache = described_class.new(namespace: namespace, cache_key_with_version: true)
cache_key = cache.cache_key(key)
@@ -54,8 +54,8 @@ describe Gitlab::JsonCache do
end
end
- context 'when cache_key_with_version is false' do
- it 'expands out the key with namespace' do
+ context "when cache_key_with_version is false" do
+ it "expands out the key with namespace" do
cache = described_class.new(namespace: namespace, cache_key_with_version: false)
cache_key = cache.cache_key(key)
@@ -64,8 +64,8 @@ describe Gitlab::JsonCache do
end
end
- context 'when namespace is nil, and cache_key_with_version is false' do
- it 'returns the key' do
+ context "when namespace is nil, and cache_key_with_version is false" do
+ it "returns the key" do
cache = described_class.new(namespace: nil, cache_key_with_version: false)
cache_key = cache.cache_key(key)
@@ -75,22 +75,22 @@ describe Gitlab::JsonCache do
end
end
- describe '#expire' do
- it 'expires the given key from the cache' do
+ describe "#expire" do
+ it "expires the given key from the cache" do
cache.expire(key)
expect(backend).to have_received(:delete).with(expanded_key)
end
end
- describe '#read' do
- it 'reads the given key from the cache' do
+ describe "#read" do
+ it "reads the given key from the cache" do
cache.read(key)
expect(backend).to have_received(:read).with(expanded_key)
end
- it 'returns the cached value when there is data in the cache with the given key' do
+ it "returns the cached value when there is data in the cache with the given key" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return("true")
@@ -98,7 +98,7 @@ describe Gitlab::JsonCache do
expect(cache.read(key)).to eq(true)
end
- it 'returns nil when there is no data in the cache with the given key' do
+ it "returns nil when there is no data in the cache with the given key" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return(nil)
@@ -106,8 +106,8 @@ describe Gitlab::JsonCache do
expect(cache.read(key)).to be_nil
end
- context 'when the cached value is a hash' do
- it 'parses the cached value' do
+ context "when the cached value is a hash" do
+ it "parses the cached value" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return(broadcast_message.to_json)
@@ -115,7 +115,7 @@ describe Gitlab::JsonCache do
expect(cache.read(key, BroadcastMessage)).to eq(broadcast_message)
end
- it 'returns nil when klass is nil' do
+ it "returns nil when klass is nil" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return(broadcast_message.to_json)
@@ -123,23 +123,23 @@ describe Gitlab::JsonCache do
expect(cache.read(key)).to be_nil
end
- it 'gracefully handles bad cached entry' do
+ it "gracefully handles bad cached entry" do
allow(backend).to receive(:read)
.with(expanded_key)
- .and_return('{')
+ .and_return("{")
expect(cache.read(key, BroadcastMessage)).to be_nil
end
- it 'gracefully handles an empty hash' do
+ it "gracefully handles an empty hash" do
allow(backend).to receive(:read)
.with(expanded_key)
- .and_return('{}')
+ .and_return("{}")
expect(cache.read(key, BroadcastMessage)).to be_a(BroadcastMessage)
end
- it 'gracefully handles unknown attributes' do
+ it "gracefully handles unknown attributes" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return(broadcast_message.attributes.merge(unknown_attribute: 1).to_json)
@@ -148,8 +148,8 @@ describe Gitlab::JsonCache do
end
end
- context 'when the cached value is an array' do
- it 'parses the cached value' do
+ context "when the cached value is an array" do
+ it "parses the cached value" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return([broadcast_message].to_json)
@@ -157,7 +157,7 @@ describe Gitlab::JsonCache do
expect(cache.read(key, BroadcastMessage)).to eq([broadcast_message])
end
- it 'returns an empty array when klass is nil' do
+ it "returns an empty array when klass is nil" do
allow(backend).to receive(:read)
.with(expanded_key)
.and_return([broadcast_message].to_json)
@@ -165,61 +165,61 @@ describe Gitlab::JsonCache do
expect(cache.read(key)).to eq([])
end
- it 'gracefully handles bad cached entry' do
+ it "gracefully handles bad cached entry" do
allow(backend).to receive(:read)
.with(expanded_key)
- .and_return('[')
+ .and_return("[")
expect(cache.read(key, BroadcastMessage)).to be_nil
end
- it 'gracefully handles an empty array' do
+ it "gracefully handles an empty array" do
allow(backend).to receive(:read)
.with(expanded_key)
- .and_return('[]')
+ .and_return("[]")
expect(cache.read(key, BroadcastMessage)).to eq([])
end
- it 'gracefully handles unknown attributes' do
+ it "gracefully handles unknown attributes" do
allow(backend).to receive(:read)
.with(expanded_key)
- .and_return([{ unknown_attribute: 1 }, broadcast_message.attributes].to_json)
+ .and_return([{unknown_attribute: 1}, broadcast_message.attributes].to_json)
expect(cache.read(key, BroadcastMessage)).to eq([broadcast_message])
end
end
end
- describe '#write' do
- it 'writes value to the cache with the given key' do
+ describe "#write" do
+ it "writes value to the cache with the given key" do
cache.write(key, true)
expect(backend).to have_received(:write).with(expanded_key, "true", nil)
end
- it 'writes a string containing a JSON representation of the value to the cache' do
+ it "writes a string containing a JSON representation of the value to the cache" do
cache.write(key, broadcast_message)
expect(backend).to have_received(:write)
.with(expanded_key, broadcast_message.to_json, nil)
end
- it 'passes options the underlying cache implementation' do
+ it "passes options the underlying cache implementation" do
cache.write(key, true, expires_in: 15.seconds)
expect(backend).to have_received(:write)
.with(expanded_key, "true", expires_in: 15.seconds)
end
- it 'passes options the underlying cache implementation when options is empty' do
+ it "passes options the underlying cache implementation when options is empty" do
cache.write(key, true, {})
expect(backend).to have_received(:write)
.with(expanded_key, "true", {})
end
- it 'passes options the underlying cache implementation when options is nil' do
+ it "passes options the underlying cache implementation when options is nil" do
cache.write(key, true, nil)
expect(backend).to have_received(:write)
@@ -227,57 +227,57 @@ describe Gitlab::JsonCache do
end
end
- describe '#fetch', :use_clean_rails_memory_store_caching do
+ describe "#fetch", :use_clean_rails_memory_store_caching do
let(:backend) { Rails.cache }
- it 'requires a block' do
+ it "requires a block" do
expect { cache.fetch(key) }.to raise_error(LocalJumpError)
end
- it 'passes options the underlying cache implementation' do
+ it "passes options the underlying cache implementation" do
expect(backend).to receive(:write)
.with(expanded_key, "true", expires_in: 15.seconds)
cache.fetch(key, expires_in: 15.seconds) { true }
end
- context 'when the given key does not exist in the cache' do
- context 'when the result of the block is truthy' do
- it 'returns the result of the block' do
+ context "when the given key does not exist in the cache" do
+ context "when the result of the block is truthy" do
+ it "returns the result of the block" do
result = cache.fetch(key) { true }
expect(result).to eq(true)
end
- it 'caches the value' do
+ it "caches the value" do
expect(backend).to receive(:write).with(expanded_key, "true", {})
cache.fetch(key) { true }
end
end
- context 'when the result of the block is false' do
- it 'returns the result of the block' do
+ context "when the result of the block is false" do
+ it "returns the result of the block" do
result = cache.fetch(key) { false }
expect(result).to eq(false)
end
- it 'caches the value' do
+ it "caches the value" do
expect(backend).to receive(:write).with(expanded_key, "false", {})
cache.fetch(key) { false }
end
end
- context 'when the result of the block is nil' do
- it 'returns the result of the block' do
+ context "when the result of the block is nil" do
+ it "returns the result of the block" do
result = cache.fetch(key) { nil }
expect(result).to eq(nil)
end
- it 'caches the value' do
+ it "caches the value" do
expect(backend).to receive(:write).with(expanded_key, "null", {})
cache.fetch(key) { nil }
@@ -285,115 +285,115 @@ describe Gitlab::JsonCache do
end
end
- context 'when the given key exists in the cache' do
- context 'when the cached value is a hash' do
+ context "when the given key exists in the cache" do
+ context "when the cached value is a hash" do
before do
backend.write(expanded_key, broadcast_message.to_json)
end
- it 'parses the cached value' do
- result = cache.fetch(key, as: BroadcastMessage) { 'block result' }
+ it "parses the cached value" do
+ result = cache.fetch(key, as: BroadcastMessage) { "block result" }
expect(result).to eq(broadcast_message)
end
it "returns the result of the block when 'as' option is nil" do
- result = cache.fetch(key, as: nil) { 'block result' }
+ result = cache.fetch(key, as: nil) { "block result" }
- expect(result).to eq('block result')
+ expect(result).to eq("block result")
end
it "returns the result of the block when 'as' option is not informed" do
- result = cache.fetch(key) { 'block result' }
+ result = cache.fetch(key) { "block result" }
- expect(result).to eq('block result')
+ expect(result).to eq("block result")
end
end
- context 'when the cached value is a array' do
+ context "when the cached value is a array" do
before do
backend.write(expanded_key, [broadcast_message].to_json)
end
- it 'parses the cached value' do
- result = cache.fetch(key, as: BroadcastMessage) { 'block result' }
+ it "parses the cached value" do
+ result = cache.fetch(key, as: BroadcastMessage) { "block result" }
expect(result).to eq([broadcast_message])
end
it "returns an empty array when 'as' option is nil" do
- result = cache.fetch(key, as: nil) { 'block result' }
+ result = cache.fetch(key, as: nil) { "block result" }
expect(result).to eq([])
end
it "returns an empty array when 'as' option is not informed" do
- result = cache.fetch(key) { 'block result' }
+ result = cache.fetch(key) { "block result" }
expect(result).to eq([])
end
end
- context 'when the cached value is true' do
+ context "when the cached value is true" do
before do
backend.write(expanded_key, "true")
end
- it 'returns the cached value' do
- result = cache.fetch(key) { 'block result' }
+ it "returns the cached value" do
+ result = cache.fetch(key) { "block result" }
expect(result).to eq(true)
end
- it 'does not execute the block' do
+ it "does not execute the block" do
expect { |block| cache.fetch(key, &block) }.not_to yield_control
end
- it 'does not write to the cache' do
+ it "does not write to the cache" do
expect(backend).not_to receive(:write)
- cache.fetch(key) { 'block result' }
+ cache.fetch(key) { "block result" }
end
end
- context 'when the cached value is false' do
+ context "when the cached value is false" do
before do
backend.write(expanded_key, "false")
end
- it 'returns the cached value' do
- result = cache.fetch(key) { 'block result' }
+ it "returns the cached value" do
+ result = cache.fetch(key) { "block result" }
expect(result).to eq(false)
end
- it 'does not execute the block' do
+ it "does not execute the block" do
expect { |block| cache.fetch(key, &block) }.not_to yield_control
end
- it 'does not write to the cache' do
+ it "does not write to the cache" do
expect(backend).not_to receive(:write)
- cache.fetch(key) { 'block result' }
+ cache.fetch(key) { "block result" }
end
end
- context 'when the cached value is nil' do
+ context "when the cached value is nil" do
before do
backend.write(expanded_key, "null")
end
- it 'returns the result of the block' do
- result = cache.fetch(key) { 'block result' }
+ it "returns the result of the block" do
+ result = cache.fetch(key) { "block result" }
- expect(result).to eq('block result')
+ expect(result).to eq("block result")
end
- it 'writes the result of the block to the cache' do
+ it "writes the result of the block to the cache" do
expect(backend).to receive(:write)
- .with(expanded_key, 'block result'.to_json, {})
+ .with(expanded_key, "block result".to_json, {})
- cache.fetch(key) { 'block result' }
+ cache.fetch(key) { "block result" }
end
end
end
diff --git a/spec/lib/gitlab/json_logger_spec.rb b/spec/lib/gitlab/json_logger_spec.rb
index cff7dd58c8c..6897dae91a9 100644
--- a/spec/lib/gitlab/json_logger_spec.rb
+++ b/spec/lib/gitlab/json_logger_spec.rb
@@ -1,35 +1,34 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::JsonLogger do
- subject { described_class.new('/dev/null') }
+ subject { described_class.new("/dev/null") }
let(:now) { Time.now }
- describe '#format_message' do
+ describe "#format_message" do
before do
- allow(Gitlab::CorrelationId).to receive(:current_id).and_return('new-correlation-id')
+ allow(Gitlab::CorrelationId).to receive(:current_id).and_return("new-correlation-id")
end
- it 'formats strings' do
- output = subject.format_message('INFO', now, 'test', 'Hello world')
+ it "formats strings" do
+ output = subject.format_message("INFO", now, "test", "Hello world")
data = JSON.parse(output)
- expect(data['severity']).to eq('INFO')
- expect(data['time']).to eq(now.utc.iso8601(3))
- expect(data['message']).to eq('Hello world')
- expect(data['correlation_id']).to eq('new-correlation-id')
+ expect(data["severity"]).to eq("INFO")
+ expect(data["time"]).to eq(now.utc.iso8601(3))
+ expect(data["message"]).to eq("Hello world")
+ expect(data["correlation_id"]).to eq("new-correlation-id")
end
- it 'formats hashes' do
- output = subject.format_message('INFO', now, 'test', { hello: 1 })
+ it "formats hashes" do
+ output = subject.format_message("INFO", now, "test", {hello: 1})
data = JSON.parse(output)
- expect(data['severity']).to eq('INFO')
- expect(data['time']).to eq(now.utc.iso8601(3))
- expect(data['hello']).to eq(1)
- expect(data['message']).to be_nil
- expect(data['correlation_id']).to eq('new-correlation-id')
+ expect(data["severity"]).to eq("INFO")
+ expect(data["time"]).to eq(now.utc.iso8601(3))
+ expect(data["hello"]).to eq(1)
+ expect(data["message"]).to be_nil
+ expect(data["correlation_id"]).to eq("new-correlation-id")
end
end
end
diff --git a/spec/lib/gitlab/kubernetes/cluster_role_binding_spec.rb b/spec/lib/gitlab/kubernetes/cluster_role_binding_spec.rb
index 4a669408025..1420cb42b38 100644
--- a/spec/lib/gitlab/kubernetes/cluster_role_binding_spec.rb
+++ b/spec/lib/gitlab/kubernetes/cluster_role_binding_spec.rb
@@ -1,26 +1,26 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::ClusterRoleBinding do
let(:cluster_role_binding) { described_class.new(name, cluster_role_name, subjects) }
- let(:name) { 'cluster-role-binding-name' }
- let(:cluster_role_name) { 'cluster-admin' }
+ let(:name) { "cluster-role-binding-name" }
+ let(:cluster_role_name) { "cluster-admin" }
- let(:subjects) { [{ kind: 'ServiceAccount', name: 'sa', namespace: 'ns' }] }
+ let(:subjects) { [{kind: "ServiceAccount", name: "sa", namespace: "ns"}] }
- describe '#generate' do
+ describe "#generate" do
let(:role_ref) do
{
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: cluster_role_name
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: cluster_role_name,
}
end
let(:resource) do
::Kubeclient::Resource.new(
- metadata: { name: name },
+ metadata: {name: name},
roleRef: role_ref,
subjects: subjects
)
@@ -28,7 +28,7 @@ describe Gitlab::Kubernetes::ClusterRoleBinding do
subject { cluster_role_binding.generate }
- it 'should build a Kubeclient Resource' do
+ it "should build a Kubeclient Resource" do
is_expected.to eq(resource)
end
end
diff --git a/spec/lib/gitlab/kubernetes/config_map_spec.rb b/spec/lib/gitlab/kubernetes/config_map_spec.rb
index fe65d03875f..e327dbc24da 100644
--- a/spec/lib/gitlab/kubernetes/config_map_spec.rb
+++ b/spec/lib/gitlab/kubernetes/config_map_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::ConfigMap do
- let(:kubeclient) { double('kubernetes client') }
+ let(:kubeclient) { double("kubernetes client") }
let(:application) { create(:clusters_applications_prometheus) }
let(:config_map) { described_class.new(application.name, application.files) }
let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
@@ -10,21 +10,21 @@ describe Gitlab::Kubernetes::ConfigMap do
{
name: "values-content-configuration-#{application.name}",
namespace: namespace,
- labels: { name: "values-content-configuration-#{application.name}" }
+ labels: {name: "values-content-configuration-#{application.name}"},
}
end
- describe '#generate' do
+ describe "#generate" do
let(:resource) { ::Kubeclient::Resource.new(metadata: metadata, data: application.files) }
subject { config_map.generate }
- it 'should build a Kubeclient Resource' do
+ it "should build a Kubeclient Resource" do
is_expected.to eq(resource)
end
end
- describe '#config_map_name' do
- it 'returns the config_map name' do
+ describe "#config_map_name" do
+ it "returns the config_map name" do
expect(config_map.config_map_name).to eq("values-content-configuration-#{application.name}")
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/api_spec.rb b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
index 8433d40b2ea..ca7883d4979 100644
--- a/spec/lib/gitlab/kubernetes/helm/api_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/api_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::Helm::Api do
- let(:client) { double('kubernetes client') }
+ let(:client) { double("kubernetes client") }
let(:helm) { described_class.new(client) }
let(:gitlab_namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
let(:namespace) { Gitlab::Kubernetes::Namespace.new(gitlab_namespace, client) }
- let(:application_name) { 'app-name' }
+ let(:application_name) { "app-name" }
let(:rbac) { false }
let(:files) { {} }
let(:command) do
Gitlab::Kubernetes::Helm::InstallCommand.new(
name: application_name,
- chart: 'chart-name',
+ chart: "chart-name",
rbac: rbac,
files: files
)
@@ -25,15 +25,15 @@ describe Gitlab::Kubernetes::Helm::Api do
allow(client).to receive(:create_config_map)
end
- describe '#initialize' do
- it 'creates a namespace object' do
+ describe "#initialize" do
+ it "creates a namespace object" do
expect(Gitlab::Kubernetes::Namespace).to receive(:new).with(gitlab_namespace, client)
subject
end
end
- describe '#install' do
+ describe "#install" do
before do
allow(client).to receive(:create_pod).and_return(nil)
allow(client).to receive(:get_config_map).and_return(nil)
@@ -44,35 +44,35 @@ describe Gitlab::Kubernetes::Helm::Api do
allow(namespace).to receive(:ensure_exists!).once
end
- it 'ensures the namespace exists before creating the POD' do
+ it "ensures the namespace exists before creating the POD" do
expect(namespace).to receive(:ensure_exists!).once.ordered
expect(client).to receive(:create_pod).once.ordered
subject.install(command)
end
- it 'removes an existing pod before installing' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps').once.ordered
+ it "removes an existing pod before installing" do
+ expect(client).to receive(:delete_pod).with("install-app-name", "gitlab-managed-apps").once.ordered
expect(client).to receive(:create_pod).once.ordered
subject.install(command)
end
- context 'with a ConfigMap' do
+ context "with a ConfigMap" do
let(:resource) { Gitlab::Kubernetes::ConfigMap.new(application_name, files).generate }
- it 'creates a ConfigMap on kubeclient' do
+ it "creates a ConfigMap on kubeclient" do
expect(client).to receive(:create_config_map).with(resource).once
subject.install(command)
end
- context 'config map already exists' do
+ context "config map already exists" do
before do
expect(client).to receive(:get_config_map).with("values-content-configuration-#{application_name}", gitlab_namespace).and_return(resource)
end
- it 'updates the config map' do
+ it "updates the config map" do
expect(client).to receive(:update_config_map).with(resource).once
subject.install(command)
@@ -80,8 +80,8 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- context 'without a service account' do
- it 'does not create a service account on kubeclient' do
+ context "without a service account" do
+ it "does not create a service account on kubeclient" do
expect(client).not_to receive(:create_service_account)
expect(client).not_to receive(:create_cluster_role_binding)
@@ -89,31 +89,31 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- context 'with a service account' do
+ context "with a service account" do
let(:command) { Gitlab::Kubernetes::Helm::InitCommand.new(name: application_name, files: files, rbac: rbac) }
- context 'rbac-enabled cluster' do
+ context "rbac-enabled cluster" do
let(:rbac) { true }
let(:service_account_resource) do
- Kubeclient::Resource.new(metadata: { name: 'tiller', namespace: 'gitlab-managed-apps' })
+ Kubeclient::Resource.new(metadata: {name: "tiller", namespace: "gitlab-managed-apps"})
end
let(:cluster_role_binding_resource) do
Kubeclient::Resource.new(
- metadata: { name: 'tiller-admin' },
- roleRef: { apiGroup: 'rbac.authorization.k8s.io', kind: 'ClusterRole', name: 'cluster-admin' },
- subjects: [{ kind: 'ServiceAccount', name: 'tiller', namespace: 'gitlab-managed-apps' }]
+ metadata: {name: "tiller-admin"},
+ roleRef: {apiGroup: "rbac.authorization.k8s.io", kind: "ClusterRole", name: "cluster-admin"},
+ subjects: [{kind: "ServiceAccount", name: "tiller", namespace: "gitlab-managed-apps"}]
)
end
- context 'service account and cluster role binding does not exist' do
+ context "service account and cluster role binding does not exist" do
before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
- expect(client).to receive(:get_cluster_role_binding).with('tiller-admin').and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
+ expect(client).to receive(:get_service_account).with("tiller", "gitlab-managed-apps").and_raise(Kubeclient::ResourceNotFoundError.new(404, "Not found", nil))
+ expect(client).to receive(:get_cluster_role_binding).with("tiller-admin").and_raise(Kubeclient::ResourceNotFoundError.new(404, "Not found", nil))
end
- it 'creates a service account, followed the cluster role binding on kubeclient' do
+ it "creates a service account, followed the cluster role binding on kubeclient" do
expect(client).to receive(:create_service_account).with(service_account_resource).once.ordered
expect(client).to receive(:create_cluster_role_binding).with(cluster_role_binding_resource).once.ordered
@@ -121,13 +121,13 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- context 'service account already exists' do
+ context "service account already exists" do
before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_return(service_account_resource)
- expect(client).to receive(:get_cluster_role_binding).with('tiller-admin').and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
+ expect(client).to receive(:get_service_account).with("tiller", "gitlab-managed-apps").and_return(service_account_resource)
+ expect(client).to receive(:get_cluster_role_binding).with("tiller-admin").and_raise(Kubeclient::ResourceNotFoundError.new(404, "Not found", nil))
end
- it 'updates the service account, followed by creating the cluster role binding' do
+ it "updates the service account, followed by creating the cluster role binding" do
expect(client).to receive(:update_service_account).with(service_account_resource).once.ordered
expect(client).to receive(:create_cluster_role_binding).with(cluster_role_binding_resource).once.ordered
@@ -135,13 +135,13 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- context 'service account and cluster role binding already exists' do
+ context "service account and cluster role binding already exists" do
before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_return(service_account_resource)
- expect(client).to receive(:get_cluster_role_binding).with('tiller-admin').and_return(cluster_role_binding_resource)
+ expect(client).to receive(:get_service_account).with("tiller", "gitlab-managed-apps").and_return(service_account_resource)
+ expect(client).to receive(:get_cluster_role_binding).with("tiller-admin").and_return(cluster_role_binding_resource)
end
- it 'updates the service account, followed by creating the cluster role binding' do
+ it "updates the service account, followed by creating the cluster role binding" do
expect(client).to receive(:update_service_account).with(service_account_resource).once.ordered
expect(client).to receive(:update_cluster_role_binding).with(cluster_role_binding_resource).once.ordered
@@ -149,19 +149,19 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- context 'a non-404 error is thrown' do
+ context "a non-404 error is thrown" do
before do
- expect(client).to receive(:get_service_account).with('tiller', 'gitlab-managed-apps').and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
+ expect(client).to receive(:get_service_account).with("tiller", "gitlab-managed-apps").and_raise(Kubeclient::HttpError.new(401, "Unauthorized", nil))
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject.install(command) }.to raise_error(Kubeclient::HttpError)
end
end
end
- context 'legacy abac cluster' do
- it 'does not create a service account on kubeclient' do
+ context "legacy abac cluster" do
+ it "does not create a service account on kubeclient" do
expect(client).not_to receive(:create_service_account)
expect(client).not_to receive(:create_cluster_role_binding)
@@ -171,63 +171,63 @@ describe Gitlab::Kubernetes::Helm::Api do
end
end
- describe '#status' do
+ describe "#status" do
let(:phase) { Gitlab::Kubernetes::Pod::RUNNING }
- let(:pod) { Kubeclient::Resource.new(status: { phase: phase }) } # partial representation
+ let(:pod) { Kubeclient::Resource.new(status: {phase: phase}) } # partial representation
- it 'fetches POD phase from kubernetes cluster' do
+ it "fetches POD phase from kubernetes cluster" do
expect(client).to receive(:get_pod).with(command.pod_name, gitlab_namespace).once.and_return(pod)
expect(subject.status(command.pod_name)).to eq(phase)
end
end
- describe '#log' do
- let(:log) { 'some output' }
+ describe "#log" do
+ let(:log) { "some output" }
let(:response) { RestClient::Response.new(log) }
- it 'fetches POD phase from kubernetes cluster' do
+ it "fetches POD phase from kubernetes cluster" do
expect(client).to receive(:get_pod_log).with(command.pod_name, gitlab_namespace).once.and_return(response)
expect(subject.log(command.pod_name)).to eq(log)
end
end
- describe '#delete_pod!' do
- it 'deletes the POD from kubernetes cluster' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps').once
+ describe "#delete_pod!" do
+ it "deletes the POD from kubernetes cluster" do
+ expect(client).to receive(:delete_pod).with("install-app-name", "gitlab-managed-apps").once
- subject.delete_pod!('install-app-name')
+ subject.delete_pod!("install-app-name")
end
- context 'when the resource being deleted does not exist' do
- it 'catches the error' do
- expect(client).to receive(:delete_pod).with('install-app-name', 'gitlab-managed-apps')
- .and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
+ context "when the resource being deleted does not exist" do
+ it "catches the error" do
+ expect(client).to receive(:delete_pod).with("install-app-name", "gitlab-managed-apps")
+ .and_raise(Kubeclient::ResourceNotFoundError.new(404, "Not found", nil))
- subject.delete_pod!('install-app-name')
+ subject.delete_pod!("install-app-name")
end
end
end
- describe '#get_config_map' do
+ describe "#get_config_map" do
before do
allow(namespace).to receive(:ensure_exists!).once
allow(client).to receive(:get_config_map).and_return(nil)
end
- it 'ensures the namespace exists before retrieving the config map' do
+ it "ensures the namespace exists before retrieving the config map" do
expect(namespace).to receive(:ensure_exists!).once
- subject.get_config_map('example-config-map-name')
+ subject.get_config_map("example-config-map-name")
end
- it 'gets the config map on kubeclient' do
+ it "gets the config map on kubeclient" do
expect(client).to receive(:get_config_map)
- .with('example-config-map-name', namespace.name)
+ .with("example-config-map-name", namespace.name)
.once
- subject.get_config_map('example-config-map-name')
+ subject.get_config_map("example-config-map-name")
end
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb
index aacae78be43..b9c3ff8797e 100644
--- a/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/base_command_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::Helm::BaseCommand do
let(:application) { create(:clusters_applications_helm) }
@@ -22,7 +22,7 @@ describe Gitlab::Kubernetes::Helm::BaseCommand do
def files
{
- some: 'value'
+ some: "value",
}
end
end
@@ -34,29 +34,29 @@ describe Gitlab::Kubernetes::Helm::BaseCommand do
subject { base_command }
- it_behaves_like 'helm commands' do
- let(:commands) { '' }
+ it_behaves_like "helm commands" do
+ let(:commands) { "" }
end
- describe '#pod_resource' do
+ describe "#pod_resource" do
subject { base_command.pod_resource }
- it 'should returns a kubeclient resoure with pod content for application' do
+ it "should returns a kubeclient resoure with pod content for application" do
is_expected.to be_an_instance_of ::Kubeclient::Resource
end
- context 'when rbac is true' do
+ context "when rbac is true" do
let(:rbac) { true }
- it 'also returns a kubeclient resource' do
+ it "also returns a kubeclient resource" do
is_expected.to be_an_instance_of ::Kubeclient::Resource
end
end
end
- describe '#pod_name' do
+ describe "#pod_name" do
subject { base_command.pod_name }
- it { is_expected.to eq('install-test-class-name') }
+ it { is_expected.to eq("install-test-class-name") }
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/certificate_spec.rb b/spec/lib/gitlab/kubernetes/helm/certificate_spec.rb
index 167bee22fc3..938a9118483 100644
--- a/spec/lib/gitlab/kubernetes/helm/certificate_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/certificate_spec.rb
@@ -1,26 +1,27 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Gitlab::Kubernetes::Helm::Certificate do
- describe '.generate_root' do
+ describe ".generate_root" do
subject { described_class.generate_root }
- it 'should generate a root CA that expires a long way in the future' do
+ it "should generate a root CA that expires a long way in the future" do
expect(subject.cert.not_after).to be > 999.years.from_now
end
end
- describe '#issue' do
+ describe "#issue" do
subject { described_class.generate_root.issue }
- it 'should generate a cert that expires soon' do
+ it "should generate a cert that expires soon" do
expect(subject.cert.not_after).to be < 60.minutes.from_now
end
- context 'passing in INFINITE_EXPIRY' do
+ context "passing in INFINITE_EXPIRY" do
subject { described_class.generate_root.issue(expires_in: described_class::INFINITE_EXPIRY) }
- it 'should generate a cert that expires a long way in the future' do
+ it "should generate a cert that expires a long way in the future" do
expect(subject.cert.not_after).to be > 999.years.from_now
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/init_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/init_command_spec.rb
index 4a3b9d4bf6a..72b7f051a93 100644
--- a/spec/lib/gitlab/kubernetes/helm/init_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/init_command_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::Helm::InitCommand do
let(:application) { create(:clusters_applications_helm) }
@@ -8,48 +8,48 @@ describe Gitlab::Kubernetes::Helm::InitCommand do
let(:commands) do
<<~EOS
- helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem
+ helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem
EOS
end
subject { init_command }
- it_behaves_like 'helm commands'
+ it_behaves_like "helm commands"
- context 'on a rbac-enabled cluster' do
+ context "on a rbac-enabled cluster" do
let(:rbac) { true }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem --service-account tiller
+ helm init --tiller-tls --tiller-tls-verify --tls-ca-cert /data/helm/helm/config/ca.pem --tiller-tls-cert /data/helm/helm/config/cert.pem --tiller-tls-key /data/helm/helm/config/key.pem --service-account tiller
EOS
end
end
end
- describe '#rbac?' do
+ describe "#rbac?" do
subject { init_command.rbac? }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
it { is_expected.to be_truthy }
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
it { is_expected.to be_falsey }
end
end
- describe '#config_map_resource' do
+ describe "#config_map_resource" do
let(:metadata) do
{
- name: 'values-content-configuration-helm',
- namespace: 'gitlab-managed-apps',
- labels: { name: 'values-content-configuration-helm' }
+ name: "values-content-configuration-helm",
+ namespace: "gitlab-managed-apps",
+ labels: {name: "values-content-configuration-helm"},
}
end
@@ -57,78 +57,78 @@ describe Gitlab::Kubernetes::Helm::InitCommand do
subject { init_command.config_map_resource }
- it 'returns a KubeClient resource with config map content for the application' do
+ it "returns a KubeClient resource with config map content for the application" do
is_expected.to eq(resource)
end
end
- describe '#pod_resource' do
+ describe "#pod_resource" do
subject { init_command.pod_resource }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
- it 'generates a pod that uses the tiller serviceAccountName' do
- expect(subject.spec.serviceAccountName).to eq('tiller')
+ it "generates a pod that uses the tiller serviceAccountName" do
+ expect(subject.spec.serviceAccountName).to eq("tiller")
end
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
- it 'generates a pod that uses the default serviceAccountName' do
+ it "generates a pod that uses the default serviceAccountName" do
expect(subject.spec.serviceAcccountName).to be_nil
end
end
end
- describe '#service_account_resource' do
+ describe "#service_account_resource" do
let(:resource) do
- Kubeclient::Resource.new(metadata: { name: 'tiller', namespace: 'gitlab-managed-apps' })
+ Kubeclient::Resource.new(metadata: {name: "tiller", namespace: "gitlab-managed-apps"})
end
subject { init_command.service_account_resource }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
- it 'generates a Kubeclient resource for the tiller ServiceAccount' do
+ it "generates a Kubeclient resource for the tiller ServiceAccount" do
is_expected.to eq(resource)
end
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
- it 'generates nothing' do
+ it "generates nothing" do
is_expected.to be_nil
end
end
end
- describe '#cluster_role_binding_resource' do
+ describe "#cluster_role_binding_resource" do
let(:resource) do
Kubeclient::Resource.new(
- metadata: { name: 'tiller-admin' },
- roleRef: { apiGroup: 'rbac.authorization.k8s.io', kind: 'ClusterRole', name: 'cluster-admin' },
- subjects: [{ kind: 'ServiceAccount', name: 'tiller', namespace: 'gitlab-managed-apps' }]
+ metadata: {name: "tiller-admin"},
+ roleRef: {apiGroup: "rbac.authorization.k8s.io", kind: "ClusterRole", name: "cluster-admin"},
+ subjects: [{kind: "ServiceAccount", name: "tiller", namespace: "gitlab-managed-apps"}]
)
end
subject { init_command.cluster_role_binding_resource }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
- it 'generates a Kubeclient resource for the ClusterRoleBinding for tiller' do
+ it "generates a Kubeclient resource for the ClusterRoleBinding for tiller" do
is_expected.to eq(resource)
end
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
- it 'generates nothing' do
+ it "generates nothing" do
is_expected.to be_nil
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
index db76d5d207e..e26423894ac 100644
--- a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Kubernetes::Helm::InstallCommand do
- let(:files) { { 'ca.pem': 'some file content' } }
- let(:repository) { 'https://repository.example.com' }
+ let(:files) { {'ca.pem': "some file content"} }
+ let(:repository) { "https://repository.example.com" }
let(:rbac) { false }
- let(:version) { '1.2.3' }
+ let(:version) { "1.2.3" }
let(:preinstall) { nil }
let(:postinstall) { nil }
let(:install_command) do
described_class.new(
- name: 'app-name',
- chart: 'chart-name',
+ name: "app-name",
+ chart: "chart-name",
rbac: rbac,
files: files,
version: version,
@@ -23,256 +23,256 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
let(:tls_flags) do
<<~EOS.squish
- --tls
- --tls-ca-cert /data/helm/app-name/config/ca.pem
- --tls-cert /data/helm/app-name/config/cert.pem
- --tls-key /data/helm/app-name/config/key.pem
+ --tls
+ --tls-ca-cert /data/helm/app-name/config/ca.pem
+ --tls-cert /data/helm/app-name/config/cert.pem
+ --tls-key /data/helm/app-name/config/key.pem
EOS
end
subject { install_command }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_comand}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ #{helm_install_comand}
EOS
end
let(:helm_install_comand) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
- context 'when rbac is true' do
+ context "when rbac is true" do
let(:rbac) { true }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ #{helm_install_command}
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --version 1.2.3
- --set rbac.create\\=true,rbac.enabled\\=true
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=true,rbac.enabled\\=true
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- context 'when there is no repository' do
+ context "when there is no repository" do
let(:repository) { nil }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- #{helm_install_command}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ #{helm_install_command}
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- context 'when there is a pre-install script' do
- let(:preinstall) { ['/bin/date', '/bin/true'] }
+ context "when there is a pre-install script" do
+ let(:preinstall) { ["/bin/date", "/bin/true"] }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- /bin/date
- /bin/true
- #{helm_install_command}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ /bin/date
+ /bin/true
+ #{helm_install_command}
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- context 'when there is a post-install script' do
- let(:postinstall) { ['/bin/date', "/bin/false\n"] }
+ context "when there is a post-install script" do
+ let(:postinstall) { ["/bin/date", "/bin/false\n"] }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
- /bin/date
- /bin/false
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ #{helm_install_command}
+ /bin/date
+ /bin/false
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- context 'when there is no ca.pem file' do
- let(:files) { { 'file.txt': 'some content' } }
+ context "when there is no ca.pem file" do
+ let(:files) { {'file.txt': "some content"} }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ #{helm_install_command}
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- --version 1.2.3
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ --version 1.2.3
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- context 'when there is no version' do
+ context "when there is no version" do
let(:version) { nil }
- it_behaves_like 'helm commands' do
+ it_behaves_like "helm commands" do
let(:commands) do
<<~EOS
- helm init --upgrade
- for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
- helm repo add app-name https://repository.example.com
- helm repo update
- #{helm_install_command}
+ helm init --upgrade
+ for i in $(seq 1 30); do helm version && break; sleep 1s; echo "Retrying ($i)..."; done
+ helm repo add app-name https://repository.example.com
+ helm repo update
+ #{helm_install_command}
EOS
end
let(:helm_install_command) do
<<~EOS.squish
- helm upgrade app-name chart-name
- --install
- --reset-values
- #{tls_flags}
- --set rbac.create\\=false,rbac.enabled\\=false
- --namespace gitlab-managed-apps
- -f /data/helm/app-name/config/values.yaml
+ helm upgrade app-name chart-name
+ --install
+ --reset-values
+ #{tls_flags}
+ --set rbac.create\\=false,rbac.enabled\\=false
+ --namespace gitlab-managed-apps
+ -f /data/helm/app-name/config/values.yaml
EOS
end
end
end
- describe '#rbac?' do
+ describe "#rbac?" do
subject { install_command.rbac? }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
it { is_expected.to be_truthy }
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
it { is_expected.to be_falsey }
end
end
- describe '#pod_resource' do
+ describe "#pod_resource" do
subject { install_command.pod_resource }
- context 'rbac is enabled' do
+ context "rbac is enabled" do
let(:rbac) { true }
- it 'generates a pod that uses the tiller serviceAccountName' do
- expect(subject.spec.serviceAccountName).to eq('tiller')
+ it "generates a pod that uses the tiller serviceAccountName" do
+ expect(subject.spec.serviceAccountName).to eq("tiller")
end
end
- context 'rbac is not enabled' do
+ context "rbac is not enabled" do
let(:rbac) { false }
- it 'generates a pod that uses the default serviceAccountName' do
+ it "generates a pod that uses the default serviceAccountName" do
expect(subject.spec.serviceAcccountName).to be_nil
end
end
end
- describe '#config_map_resource' do
+ describe "#config_map_resource" do
let(:metadata) do
{
name: "values-content-configuration-app-name",
- namespace: 'gitlab-managed-apps',
- labels: { name: "values-content-configuration-app-name" }
+ namespace: "gitlab-managed-apps",
+ labels: {name: "values-content-configuration-app-name"},
}
end
@@ -280,23 +280,23 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do
subject { install_command.config_map_resource }
- it 'returns a KubeClient resource with config map content for the application' do
+ it "returns a KubeClient resource with config map content for the application" do
is_expected.to eq(resource)
end
end
- describe '#service_account_resource' do
+ describe "#service_account_resource" do
subject { install_command.service_account_resource }
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_nil
end
end
- describe '#cluster_role_binding_resource' do
+ describe "#cluster_role_binding_resource" do
subject { install_command.cluster_role_binding_resource }
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_nil
end
end
diff --git a/spec/lib/gitlab/kubernetes/helm/pod_spec.rb b/spec/lib/gitlab/kubernetes/helm/pod_spec.rb
index 95b6b3fd953..38e57a256c8 100644
--- a/spec/lib/gitlab/kubernetes/helm/pod_spec.rb
+++ b/spec/lib/gitlab/kubernetes/helm/pod_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Kubernetes::Helm::Pod do
- describe '#generate' do
+ describe "#generate" do
let(:app) { create(:clusters_applications_prometheus) }
let(:command) { app.install_command }
let(:namespace) { Gitlab::Kubernetes::Helm::NAMESPACE }
@@ -9,66 +9,66 @@ describe Gitlab::Kubernetes::Helm::Pod do
subject { described_class.new(command, namespace, service_account_name: service_account_name) }
- context 'with a command' do
- it 'should generate a Kubeclient::Resource' do
+ context "with a command" do
+ it "should generate a Kubeclient::Resource" do
expect(subject.generate).to be_a_kind_of(Kubeclient::Resource)
end
- it 'should generate the appropriate metadata' do
+ it "should generate the appropriate metadata" do
metadata = subject.generate.metadata
expect(metadata.name).to eq("install-#{app.name}")
- expect(metadata.namespace).to eq('gitlab-managed-apps')
- expect(metadata.labels['gitlab.org/action']).to eq('install')
- expect(metadata.labels['gitlab.org/application']).to eq(app.name)
+ expect(metadata.namespace).to eq("gitlab-managed-apps")
+ expect(metadata.labels["gitlab.org/action"]).to eq("install")
+ expect(metadata.labels["gitlab.org/application"]).to eq(app.name)
end
- it 'should generate a container spec' do
+ it "should generate a container spec" do
spec = subject.generate.spec
expect(spec.containers.count).to eq(1)
end
- it 'should generate the appropriate specifications for the container' do
+ it "should generate the appropriate specifications for the container" do
container = subject.generate.spec.containers.first
- expect(container.name).to eq('helm')
- expect(container.image).to eq('registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/2.12.3-kube-1.11.7')
+ expect(container.name).to eq("helm")
+ expect(container.image).to eq("registry.gitlab.com/gitlab-org/cluster-integration/helm-install-image/releases/2.12.3-kube-1.11.7")
expect(container.env.count).to eq(3)
expect(container.env.map(&:name)).to match_array([:HELM_VERSION, :TILLER_NAMESPACE, :COMMAND_SCRIPT])
expect(container.command).to match_array(["/bin/sh"])
expect(container.args).to match_array(["-c", "$(COMMAND_SCRIPT)"])
end
- it 'should include a never restart policy' do
+ it "should include a never restart policy" do
spec = subject.generate.spec
- expect(spec.restartPolicy).to eq('Never')
+ expect(spec.restartPolicy).to eq("Never")
end
- it 'should include volumes for the container' do
+ it "should include volumes for the container" do
container = subject.generate.spec.containers.first
- expect(container.volumeMounts.first['name']).to eq('configuration-volume')
- expect(container.volumeMounts.first['mountPath']).to eq("/data/helm/#{app.name}/config")
+ expect(container.volumeMounts.first["name"]).to eq("configuration-volume")
+ expect(container.volumeMounts.first["mountPath"]).to eq("/data/helm/#{app.name}/config")
end
- it 'should include a volume inside the specification' do
+ it "should include a volume inside the specification" do
spec = subject.generate.spec
- expect(spec.volumes.first['name']).to eq('configuration-volume')
+ expect(spec.volumes.first["name"]).to eq("configuration-volume")
end
- it 'should mount configMap specification in the volume' do
+ it "should mount configMap specification in the volume" do
volume = subject.generate.spec.volumes.first
- expect(volume.configMap['name']).to eq("values-content-configuration-#{app.name}")
- expect(volume.configMap['items'].first['key']).to eq(:'values.yaml')
- expect(volume.configMap['items'].first['path']).to eq(:'values.yaml')
+ expect(volume.configMap["name"]).to eq("values-content-configuration-#{app.name}")
+ expect(volume.configMap["items"].first["key"]).to eq(:'values.yaml')
+ expect(volume.configMap["items"].first["path"]).to eq(:'values.yaml')
end
- it 'should have no serviceAccountName' do
+ it "should have no serviceAccountName" do
spec = subject.generate.spec
expect(spec.serviceAccountName).to be_nil
end
- context 'with a service_account_name' do
- let(:service_account_name) { 'sa' }
+ context "with a service_account_name" do
+ let(:service_account_name) { "sa" }
- it 'should use the serviceAccountName provided' do
+ it "should use the serviceAccountName provided" do
spec = subject.generate.spec
expect(spec.serviceAccountName).to eq(service_account_name)
end
diff --git a/spec/lib/gitlab/kubernetes/kube_client_spec.rb b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
index 02364e92149..617e3b82fa8 100644
--- a/spec/lib/gitlab/kubernetes/kube_client_spec.rb
+++ b/spec/lib/gitlab/kubernetes/kube_client_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::KubeClient do
include KubernetesHelpers
- let(:api_url) { 'https://kubernetes.example.com/prefix' }
- let(:kubeclient_options) { { auth_options: { bearer_token: 'xyz' } } }
+ let(:api_url) { "https://kubernetes.example.com/prefix" }
+ let(:kubeclient_options) { {auth_options: {bearer_token: "xyz"}} }
let(:client) { described_class.new(api_url, kubeclient_options) }
@@ -14,28 +14,28 @@ describe Gitlab::Kubernetes::KubeClient do
stub_kubeclient_discover(api_url)
end
- shared_examples 'a Kubeclient' do
- it 'is a Kubeclient::Client' do
+ shared_examples "a Kubeclient" do
+ it "is a Kubeclient::Client" do
is_expected.to be_an_instance_of Kubeclient::Client
end
- it 'has the kubeclient options' do
- expect(subject.auth_options).to eq({ bearer_token: 'xyz' })
+ it "has the kubeclient options" do
+ expect(subject.auth_options).to eq({bearer_token: "xyz"})
end
end
- shared_examples 'redirection not allowed' do |method_name|
+ shared_examples "redirection not allowed" do |method_name|
before do
- redirect_url = 'https://not-under-our-control.example.com/api/v1/pods'
+ redirect_url = "https://not-under-our-control.example.com/api/v1/pods"
stub_request(:get, %r{\A#{api_url}/})
- .to_return(status: 302, headers: { location: redirect_url })
+ .to_return(status: 302, headers: {location: redirect_url})
stub_request(:get, redirect_url)
- .to_return(status: 200, body: '{}')
+ .to_return(status: 200, body: "{}")
end
- it 'does not follow redirects' do
+ it "does not follow redirects" do
method_call = -> do
case method_name
when /\A(get_|delete_)/
@@ -50,63 +50,63 @@ describe Gitlab::Kubernetes::KubeClient do
end
end
- describe '#core_client' do
+ describe "#core_client" do
subject { client.core_client }
- it_behaves_like 'a Kubeclient'
+ it_behaves_like "a Kubeclient"
- it 'has the core API endpoint' do
+ it "has the core API endpoint" do
expect(subject.api_endpoint.to_s).to match(%r{\/api\Z})
end
- it 'has the api_version' do
- expect(subject.instance_variable_get(:@api_version)).to eq('v1')
+ it "has the api_version" do
+ expect(subject.instance_variable_get(:@api_version)).to eq("v1")
end
end
- describe '#rbac_client' do
+ describe "#rbac_client" do
subject { client.rbac_client }
- it_behaves_like 'a Kubeclient'
+ it_behaves_like "a Kubeclient"
- it 'has the RBAC API group endpoint' do
+ it "has the RBAC API group endpoint" do
expect(subject.api_endpoint.to_s).to match(%r{\/apis\/rbac.authorization.k8s.io\Z})
end
- it 'has the api_version' do
- expect(subject.instance_variable_get(:@api_version)).to eq('v1')
+ it "has the api_version" do
+ expect(subject.instance_variable_get(:@api_version)).to eq("v1")
end
end
- describe '#extensions_client' do
+ describe "#extensions_client" do
subject { client.extensions_client }
- it_behaves_like 'a Kubeclient'
+ it_behaves_like "a Kubeclient"
- it 'has the extensions API group endpoint' do
+ it "has the extensions API group endpoint" do
expect(subject.api_endpoint.to_s).to match(%r{\/apis\/extensions\Z})
end
- it 'has the api_version' do
- expect(subject.instance_variable_get(:@api_version)).to eq('v1beta1')
+ it "has the api_version" do
+ expect(subject.instance_variable_get(:@api_version)).to eq("v1beta1")
end
end
- describe '#knative_client' do
+ describe "#knative_client" do
subject { client.knative_client }
- it_behaves_like 'a Kubeclient'
+ it_behaves_like "a Kubeclient"
- it 'has the extensions API group endpoint' do
+ it "has the extensions API group endpoint" do
expect(subject.api_endpoint.to_s).to match(%r{\/apis\/serving.knative.dev\Z})
end
- it 'has the api_version' do
- expect(subject.instance_variable_get(:@api_version)).to eq('v1alpha1')
+ it "has the api_version" do
+ expect(subject.instance_variable_get(:@api_version)).to eq("v1alpha1")
end
end
- describe 'core API' do
+ describe "core API" do
let(:core_client) { client.core_client }
[
@@ -126,110 +126,110 @@ describe Gitlab::Kubernetes::KubeClient do
:create_service_account,
:update_config_map,
:update_secret,
- :update_service_account
+ :update_service_account,
].each do |method|
describe "##{method}" do
- include_examples 'redirection not allowed', method
+ include_examples "redirection not allowed", method
- it 'delegates to the core client' do
+ it "delegates to the core client" do
expect(client).to delegate_method(method).to(:core_client)
end
- it 'responds to the method' do
+ it "responds to the method" do
expect(client).to respond_to method
end
end
end
end
- describe 'rbac API group' do
+ describe "rbac API group" do
let(:rbac_client) { client.rbac_client }
[
:create_cluster_role_binding,
:get_cluster_role_binding,
- :update_cluster_role_binding
+ :update_cluster_role_binding,
].each do |method|
describe "##{method}" do
- include_examples 'redirection not allowed', method
+ include_examples "redirection not allowed", method
- it 'delegates to the rbac client' do
+ it "delegates to the rbac client" do
expect(client).to delegate_method(method).to(:rbac_client)
end
- it 'responds to the method' do
+ it "responds to the method" do
expect(client).to respond_to method
end
end
end
end
- describe 'extensions API group' do
- let(:api_groups) { ['apis/extensions'] }
+ describe "extensions API group" do
+ let(:api_groups) { ["apis/extensions"] }
let(:extensions_client) { client.extensions_client }
- describe '#get_deployments' do
- include_examples 'redirection not allowed', 'get_deployments'
+ describe "#get_deployments" do
+ include_examples "redirection not allowed", "get_deployments"
- it 'delegates to the extensions client' do
+ it "delegates to the extensions client" do
expect(client).to delegate_method(:get_deployments).to(:extensions_client)
end
- it 'responds to the method' do
+ it "responds to the method" do
expect(client).to respond_to :get_deployments
end
end
end
- describe 'non-entity methods' do
- it 'does not proxy for non-entity methods' do
+ describe "non-entity methods" do
+ it "does not proxy for non-entity methods" do
expect(client).not_to respond_to :proxy_url
end
- it 'throws an error' do
+ it "throws an error" do
expect { client.proxy_url }.to raise_error(NoMethodError)
end
end
- describe '#get_pod_log' do
+ describe "#get_pod_log" do
let(:core_client) { client.core_client }
- it 'is delegated to the core client' do
+ it "is delegated to the core client" do
expect(client).to delegate_method(:get_pod_log).to(:core_client)
end
end
- describe '#watch_pod_log' do
+ describe "#watch_pod_log" do
let(:core_client) { client.core_client }
- it 'is delegated to the core client' do
+ it "is delegated to the core client" do
expect(client).to delegate_method(:watch_pod_log).to(:core_client)
end
end
- shared_examples 'create_or_update method' do
+ shared_examples "create_or_update method" do
let(:get_method) { "get_#{resource_type}" }
let(:update_method) { "update_#{resource_type}" }
let(:create_method) { "create_#{resource_type}" }
- context 'resource exists' do
+ context "resource exists" do
before do
expect(client).to receive(get_method).and_return(resource)
end
- it 'calls the update method' do
+ it "calls the update method" do
expect(client).to receive(update_method).with(resource)
subject
end
end
- context 'resource does not exist' do
+ context "resource does not exist" do
before do
- expect(client).to receive(get_method).and_raise(Kubeclient::ResourceNotFoundError.new(404, 'Not found', nil))
+ expect(client).to receive(get_method).and_raise(Kubeclient::ResourceNotFoundError.new(404, "Not found", nil))
end
- it 'calls the create method' do
+ it "calls the create method" do
expect(client).to receive(create_method).with(resource)
subject
@@ -237,60 +237,60 @@ describe Gitlab::Kubernetes::KubeClient do
end
end
- describe '#create_or_update_cluster_role_binding' do
- let(:resource_type) { 'cluster_role_binding' }
+ describe "#create_or_update_cluster_role_binding" do
+ let(:resource_type) { "cluster_role_binding" }
let(:resource) do
- ::Kubeclient::Resource.new(metadata: { name: 'name', namespace: 'namespace' })
+ ::Kubeclient::Resource.new(metadata: {name: "name", namespace: "namespace"})
end
subject { client.create_or_update_cluster_role_binding(resource) }
- it_behaves_like 'create_or_update method'
+ it_behaves_like "create_or_update method"
end
- describe '#create_or_update_role_binding' do
- let(:resource_type) { 'role_binding' }
+ describe "#create_or_update_role_binding" do
+ let(:resource_type) { "role_binding" }
let(:resource) do
- ::Kubeclient::Resource.new(metadata: { name: 'name', namespace: 'namespace' })
+ ::Kubeclient::Resource.new(metadata: {name: "name", namespace: "namespace"})
end
subject { client.create_or_update_role_binding(resource) }
- it_behaves_like 'create_or_update method'
+ it_behaves_like "create_or_update method"
end
- describe '#create_or_update_service_account' do
- let(:resource_type) { 'service_account' }
+ describe "#create_or_update_service_account" do
+ let(:resource_type) { "service_account" }
let(:resource) do
- ::Kubeclient::Resource.new(metadata: { name: 'name', namespace: 'namespace' })
+ ::Kubeclient::Resource.new(metadata: {name: "name", namespace: "namespace"})
end
subject { client.create_or_update_service_account(resource) }
- it_behaves_like 'create_or_update method'
+ it_behaves_like "create_or_update method"
end
- describe '#create_or_update_secret' do
- let(:resource_type) { 'secret' }
+ describe "#create_or_update_secret" do
+ let(:resource_type) { "secret" }
let(:resource) do
- ::Kubeclient::Resource.new(metadata: { name: 'name', namespace: 'namespace' })
+ ::Kubeclient::Resource.new(metadata: {name: "name", namespace: "namespace"})
end
subject { client.create_or_update_secret(resource) }
- it_behaves_like 'create_or_update method'
+ it_behaves_like "create_or_update method"
end
- describe 'methods that do not exist on any client' do
- it 'throws an error' do
+ describe "methods that do not exist on any client" do
+ it "throws an error" do
expect { client.non_existent_method }.to raise_error(NoMethodError)
end
- it 'returns false for respond_to' do
+ it "returns false for respond_to" do
expect(client.respond_to?(:non_existent_method)).to be_falsey
end
end
diff --git a/spec/lib/gitlab/kubernetes/namespace_spec.rb b/spec/lib/gitlab/kubernetes/namespace_spec.rb
index e1c35c355f4..2f4a9c16ea7 100644
--- a/spec/lib/gitlab/kubernetes/namespace_spec.rb
+++ b/spec/lib/gitlab/kubernetes/namespace_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::Namespace do
- let(:name) { 'a_namespace' }
- let(:client) { double('kubernetes client') }
+ let(:name) { "a_namespace" }
+ let(:client) { double("kubernetes client") }
subject { described_class.new(name, client) }
it { expect(subject.name).to eq(name) }
- describe '#exists?' do
- context 'when namespace do not exits' do
+ describe "#exists?" do
+ context "when namespace do not exits" do
let(:exception) { ::Kubeclient::ResourceNotFoundError.new(404, "namespace #{name} not found", nil) }
- it 'returns false' do
+ it "returns false" do
expect(client).to receive(:get_namespace).with(name).once.and_raise(exception)
expect(subject.exists?).to be_falsey
end
end
- context 'when namespace exits' do
- let(:namespace) { ::Kubeclient::Resource.new(kind: 'Namespace', metadata: { name: name }) } # partial representation
+ context "when namespace exits" do
+ let(:namespace) { ::Kubeclient::Resource.new(kind: "Namespace", metadata: {name: name}) } # partial representation
- it 'returns true' do
+ it "returns true" do
expect(client).to receive(:get_namespace).with(name).once.and_return(namespace)
expect(subject.exists?).to be_truthy
end
end
- context 'when cluster cannot be reached' do
+ context "when cluster cannot be reached" do
let(:exception) { Errno::ECONNREFUSED.new }
- it 'raises exception' do
+ it "raises exception" do
expect(client).to receive(:get_namespace).with(name).once.and_raise(exception)
expect { subject.exists? }.to raise_error(exception)
@@ -39,8 +39,8 @@ describe Gitlab::Kubernetes::Namespace do
end
end
- describe '#create!' do
- it 'creates a namespace' do
+ describe "#create!" do
+ it "creates a namespace" do
matcher = have_attributes(metadata: have_attributes(name: name))
expect(client).to receive(:create_namespace).with(matcher).once
@@ -48,15 +48,15 @@ describe Gitlab::Kubernetes::Namespace do
end
end
- describe '#ensure_exists!' do
- it 'checks for existing namespace before creating' do
+ describe "#ensure_exists!" do
+ it "checks for existing namespace before creating" do
expect(subject).to receive(:exists?).once.ordered.and_return(false)
expect(subject).to receive(:create!).once.ordered
subject.ensure_exists!
end
- it 'do not re-create an existing namespace' do
+ it "do not re-create an existing namespace" do
expect(subject).to receive(:exists?).once.and_return(true)
expect(subject).not_to receive(:create!)
diff --git a/spec/lib/gitlab/kubernetes/role_binding_spec.rb b/spec/lib/gitlab/kubernetes/role_binding_spec.rb
index a1a59533bfb..dff8901cafb 100644
--- a/spec/lib/gitlab/kubernetes/role_binding_spec.rb
+++ b/spec/lib/gitlab/kubernetes/role_binding_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe Gitlab::Kubernetes::RoleBinding, '#generate' do
- let(:role_name) { 'edit' }
- let(:namespace) { 'my-namespace' }
- let(:service_account_name) { 'my-service-account' }
+describe Gitlab::Kubernetes::RoleBinding, "#generate" do
+ let(:role_name) { "edit" }
+ let(:namespace) { "my-namespace" }
+ let(:service_account_name) { "my-service-account" }
let(:subjects) do
[
{
- kind: 'ServiceAccount',
+ kind: "ServiceAccount",
name: service_account_name,
- namespace: namespace
- }
+ namespace: namespace,
+ },
]
end
let(:role_ref) do
{
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: role_name
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: role_name,
}
end
let(:resource) do
::Kubeclient::Resource.new(
- metadata: { name: "gitlab-#{namespace}", namespace: namespace },
+ metadata: {name: "gitlab-#{namespace}", namespace: namespace},
roleRef: role_ref,
subjects: subjects
)
@@ -42,7 +42,7 @@ describe Gitlab::Kubernetes::RoleBinding, '#generate' do
).generate
end
- it 'should build a Kubeclient Resource' do
+ it "should build a Kubeclient Resource" do
is_expected.to eq(resource)
end
end
diff --git a/spec/lib/gitlab/kubernetes/service_account_spec.rb b/spec/lib/gitlab/kubernetes/service_account_spec.rb
index 8da9e932dc3..44fb698b463 100644
--- a/spec/lib/gitlab/kubernetes/service_account_spec.rb
+++ b/spec/lib/gitlab/kubernetes/service_account_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::ServiceAccount do
- let(:name) { 'a_service_account' }
- let(:namespace_name) { 'a_namespace' }
+ let(:name) { "a_service_account" }
+ let(:namespace_name) { "a_namespace" }
let(:service_account) { described_class.new(name, namespace_name) }
it { expect(service_account.name).to eq(name) }
it { expect(service_account.namespace_name).to eq(namespace_name) }
- describe '#generate' do
+ describe "#generate" do
let(:resource) do
- ::Kubeclient::Resource.new(metadata: { name: name, namespace: namespace_name })
+ ::Kubeclient::Resource.new(metadata: {name: name, namespace: namespace_name})
end
subject { service_account.generate }
- it 'should build a Kubeclient Resource' do
+ it "should build a Kubeclient Resource" do
is_expected.to eq(resource)
end
end
diff --git a/spec/lib/gitlab/kubernetes/service_account_token_spec.rb b/spec/lib/gitlab/kubernetes/service_account_token_spec.rb
index 0773d3d9aec..14be0d1cb75 100644
--- a/spec/lib/gitlab/kubernetes/service_account_token_spec.rb
+++ b/spec/lib/gitlab/kubernetes/service_account_token_spec.rb
@@ -1,34 +1,34 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes::ServiceAccountToken do
- let(:name) { 'token-name' }
- let(:service_account_name) { 'a_service_account' }
- let(:namespace_name) { 'a_namespace' }
+ let(:name) { "token-name" }
+ let(:service_account_name) { "a_service_account" }
+ let(:namespace_name) { "a_namespace" }
let(:service_account_token) { described_class.new(name, service_account_name, namespace_name) }
it { expect(service_account_token.name).to eq(name) }
it { expect(service_account_token.service_account_name).to eq(service_account_name) }
it { expect(service_account_token.namespace_name).to eq(namespace_name) }
- describe '#generate' do
+ describe "#generate" do
let(:resource) do
::Kubeclient::Resource.new(
metadata: {
name: name,
namespace: namespace_name,
annotations: {
- 'kubernetes.io/service-account.name': service_account_name
- }
+ 'kubernetes.io/service-account.name': service_account_name,
+ },
},
- type: 'kubernetes.io/service-account-token'
+ type: "kubernetes.io/service-account-token"
)
end
subject { service_account_token.generate }
- it 'should build a Kubeclient Resource' do
+ it "should build a Kubeclient Resource" do
is_expected.to eq(resource)
end
end
diff --git a/spec/lib/gitlab/kubernetes_spec.rb b/spec/lib/gitlab/kubernetes_spec.rb
index f326d57e9c6..a1ca0042e1c 100644
--- a/spec/lib/gitlab/kubernetes_spec.rb
+++ b/spec/lib/gitlab/kubernetes_spec.rb
@@ -1,91 +1,91 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Kubernetes do
include KubernetesHelpers
include described_class
- describe '#container_exec_url' do
- let(:api_url) { 'https://example.com' }
- let(:namespace) { 'default' }
- let(:pod_name) { 'pod1' }
- let(:container_name) { 'container1' }
+ describe "#container_exec_url" do
+ let(:api_url) { "https://example.com" }
+ let(:namespace) { "default" }
+ let(:pod_name) { "pod1" }
+ let(:container_name) { "container1" }
subject(:result) { URI.parse(container_exec_url(api_url, namespace, pod_name, container_name)) }
- it { expect(result.scheme).to eq('wss') }
- it { expect(result.host).to eq('example.com') }
- it { expect(result.path).to eq('/api/v1/namespaces/default/pods/pod1/exec') }
- it { expect(result.query).to eq('container=container1&stderr=true&stdin=true&stdout=true&tty=true&command=sh&command=-c&command=bash+%7C%7C+sh') }
+ it { expect(result.scheme).to eq("wss") }
+ it { expect(result.host).to eq("example.com") }
+ it { expect(result.path).to eq("/api/v1/namespaces/default/pods/pod1/exec") }
+ it { expect(result.query).to eq("container=container1&stderr=true&stdin=true&stdout=true&tty=true&command=sh&command=-c&command=bash+%7C%7C+sh") }
- context 'with a HTTP API URL' do
- let(:api_url) { 'http://example.com' }
+ context "with a HTTP API URL" do
+ let(:api_url) { "http://example.com" }
- it { expect(result.scheme).to eq('ws') }
+ it { expect(result.scheme).to eq("ws") }
end
- context 'with a path prefix in the API URL' do
- let(:api_url) { 'https://example.com/prefix/' }
- it { expect(result.path).to eq('/prefix/api/v1/namespaces/default/pods/pod1/exec') }
+ context "with a path prefix in the API URL" do
+ let(:api_url) { "https://example.com/prefix/" }
+ it { expect(result.path).to eq("/prefix/api/v1/namespaces/default/pods/pod1/exec") }
end
- context 'with arguments that need urlencoding' do
- let(:namespace) { 'default namespace' }
- let(:pod_name) { 'pod 1' }
- let(:container_name) { 'container 1' }
+ context "with arguments that need urlencoding" do
+ let(:namespace) { "default namespace" }
+ let(:pod_name) { "pod 1" }
+ let(:container_name) { "container 1" }
- it { expect(result.path).to eq('/api/v1/namespaces/default%20namespace/pods/pod%201/exec') }
+ it { expect(result.path).to eq("/api/v1/namespaces/default%20namespace/pods/pod%201/exec") }
it { expect(result.query).to match(/\Acontainer=container\+1&/) }
end
end
- describe '#filter_by_label' do
- it 'returns matching labels' do
- matching_items = [kube_pod(app: 'foo')]
+ describe "#filter_by_label" do
+ it "returns matching labels" do
+ matching_items = [kube_pod(app: "foo")]
items = matching_items + [kube_pod]
- expect(filter_by_label(items, app: 'foo')).to eq(matching_items)
+ expect(filter_by_label(items, app: "foo")).to eq(matching_items)
end
end
- describe '#to_kubeconfig' do
- let(:token) { 'TOKEN' }
- let(:ca_pem) { 'PEM' }
+ describe "#to_kubeconfig" do
+ let(:token) { "TOKEN" }
+ let(:ca_pem) { "PEM" }
subject do
to_kubeconfig(
- url: 'https://kube.domain.com',
- namespace: 'NAMESPACE',
+ url: "https://kube.domain.com",
+ namespace: "NAMESPACE",
token: token,
ca_pem: ca_pem
)
end
- it { expect(YAML.safe_load(subject)).to eq(YAML.load_file(expand_fixture_path('config/kubeconfig.yml'))) }
+ it { expect(YAML.safe_load(subject)).to eq(YAML.load_file(expand_fixture_path("config/kubeconfig.yml"))) }
- context 'when CA PEM is not provided' do
+ context "when CA PEM is not provided" do
let(:ca_pem) { nil }
- it { expect(YAML.safe_load(subject)).to eq(YAML.load_file(expand_fixture_path('config/kubeconfig-without-ca.yml'))) }
+ it { expect(YAML.safe_load(subject)).to eq(YAML.load_file(expand_fixture_path("config/kubeconfig-without-ca.yml"))) }
end
- context 'when token is not provided' do
+ context "when token is not provided" do
let(:token) { nil }
it { is_expected.to be_nil }
end
end
- describe '#add_terminal_auth' do
- it 'adds authentication parameters to a hash' do
- terminal = { original: 'value' }
+ describe "#add_terminal_auth" do
+ it "adds authentication parameters to a hash" do
+ terminal = {original: "value"}
- add_terminal_auth(terminal, token: 'foo', max_session_time: 0, ca_pem: 'bar')
+ add_terminal_auth(terminal, token: "foo", max_session_time: 0, ca_pem: "bar")
expect(terminal).to eq(
- original: 'value',
- headers: { 'Authorization' => ['Bearer foo'] },
+ original: "value",
+ headers: {"Authorization" => ["Bearer foo"]},
max_session_time: 0,
- ca_pem: 'bar'
+ ca_pem: "bar"
)
end
end
diff --git a/spec/lib/gitlab/language_data_spec.rb b/spec/lib/gitlab/language_data_spec.rb
index b08150855fe..0491e873c3b 100644
--- a/spec/lib/gitlab/language_data_spec.rb
+++ b/spec/lib/gitlab/language_data_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LanguageData do
- describe '#extensions' do
+ describe "#extensions" do
before do
described_class.clear_extensions!
end
- it 'loads the extensions once' do
+ it "loads the extensions once" do
expect(YAML).to receive(:load_file).once.and_call_original
2.times do
expect(described_class.extensions).to be_a(Set)
expect(described_class.extensions.count).to be > 0
# Sanity check for known extensions
- expect(described_class.extensions).to include(*%w(.rb .yml .json))
+ expect(described_class.extensions).to include(".rb", ".yml", ".json")
end
end
end
diff --git a/spec/lib/gitlab/language_detection_spec.rb b/spec/lib/gitlab/language_detection_spec.rb
index 9636fbd401b..fdbbc2d220c 100644
--- a/spec/lib/gitlab/language_detection_spec.rb
+++ b/spec/lib/gitlab/language_detection_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LanguageDetection do
set(:project) { create(:project, :repository) }
- set(:ruby) { create(:programming_language, name: 'Ruby') }
- set(:haskell) { create(:programming_language, name: 'Haskell') }
+ set(:ruby) { create(:programming_language, name: "Ruby") }
+ set(:haskell) { create(:programming_language, name: "Haskell") }
let(:repository) { project.repository }
let(:detection) do
- [{ value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516" },
- { value: 12.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
- { value: 7.9, label: "Elixir", color: "#e34c26", highlight: "#e34c26" },
- { value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776" },
- { value: 1.51, label: "Go", color: "#2a4776", highlight: "#244776" },
- { value: 1.1, label: "MepmepLang", color: "#2a4776", highlight: "#244776" }]
+ [{value: 66.63, label: "Ruby", color: "#701516", highlight: "#701516"},
+ {value: 12.96, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a"},
+ {value: 7.9, label: "Elixir", color: "#e34c26", highlight: "#e34c26"},
+ {value: 2.51, label: "CoffeeScript", color: "#244776", highlight: "#244776"},
+ {value: 1.51, label: "Go", color: "#2a4776", highlight: "#244776"},
+ {value: 1.1, label: "MepmepLang", color: "#2a4776", highlight: "#244776"},]
end
let(:repository_languages) do
[RepositoryLanguage.new(share: 10, programming_language: ruby)]
@@ -23,19 +23,19 @@ describe Gitlab::LanguageDetection do
allow(repository).to receive(:languages).and_return(detection)
end
- describe '#languages' do
- it 'returns the language names' do
+ describe "#languages" do
+ it "returns the language names" do
expect(subject.languages).to eq(%w[Ruby JavaScript Elixir CoffeeScript Go])
end
end
- describe '#insertions' do
+ describe "#insertions" do
let(:programming_languages) { [ruby, haskell] }
let(:detection) do
- [{ value: 10, label: haskell.name, color: haskell.color }]
+ [{value: 10, label: haskell.name, color: haskell.color}]
end
- it 'only includes new languages' do
+ it "only includes new languages" do
insertions = subject.insertions(programming_languages)
expect(insertions).not_to be_empty
@@ -45,8 +45,8 @@ describe Gitlab::LanguageDetection do
end
end
- describe '#updates' do
- it 'updates the share of languages' do
+ describe "#updates" do
+ it "updates the share of languages" do
first_update = subject.updates.first
expect(first_update).not_to be_nil
@@ -54,13 +54,13 @@ describe Gitlab::LanguageDetection do
expect(first_update[:share]).to eq(66.63)
end
- it 'does not include languages to be removed' do
+ it "does not include languages to be removed" do
ids = subject.updates.map { |h| h[:programming_language_id] }
expect(ids).not_to include(haskell.id)
end
- context 'when silent writes occur' do
+ context "when silent writes occur" do
let(:repository_languages) do
[RepositoryLanguage.new(share: 66.63, programming_language: ruby)]
end
@@ -71,13 +71,13 @@ describe Gitlab::LanguageDetection do
end
end
- describe '#deletions' do
+ describe "#deletions" do
let(:repository_languages) do
[RepositoryLanguage.new(share: 10, programming_language: ruby),
- RepositoryLanguage.new(share: 5, programming_language: haskell)]
+ RepositoryLanguage.new(share: 5, programming_language: haskell),]
end
- it 'lists undetected languages' do
+ it "lists undetected languages" do
expect(subject.deletions).not_to be_empty
expect(subject.deletions).to include(haskell.id)
end
diff --git a/spec/lib/gitlab/lazy_spec.rb b/spec/lib/gitlab/lazy_spec.rb
index 37a3ac74316..ac284e13836 100644
--- a/spec/lib/gitlab/lazy_spec.rb
+++ b/spec/lib/gitlab/lazy_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Lazy do
let(:dummy) { double(:dummy) }
- context 'when not calling any methods' do
- it 'does not call the supplied block' do
+ context "when not calling any methods" do
+ it "does not call the supplied block" do
expect(dummy).not_to receive(:foo)
described_class.new { dummy.foo }
end
end
- context 'when calling a method on the object' do
- it 'lazy loads the value returned by the block' do
- expect(dummy).to receive(:foo).and_return('foo')
+ context "when calling a method on the object" do
+ it "lazy loads the value returned by the block" do
+ expect(dummy).to receive(:foo).and_return("foo")
lazy = described_class.new { dummy.foo }
- expect(lazy.to_s).to eq('foo')
+ expect(lazy.to_s).to eq("foo")
end
end
- describe '#respond_to?' do
- it 'returns true for a method defined on the wrapped object' do
- lazy = described_class.new { 'foo' }
+ describe "#respond_to?" do
+ it "returns true for a method defined on the wrapped object" do
+ lazy = described_class.new { "foo" }
expect(lazy).to respond_to(:downcase)
end
- it 'returns false for a method not defined on the wrapped object' do
- lazy = described_class.new { 'foo' }
+ it "returns false for a method not defined on the wrapped object" do
+ lazy = described_class.new { "foo" }
expect(lazy).not_to respond_to(:quack)
end
diff --git a/spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb
index 48655851140..85e243ba126 100644
--- a/spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/branch_formatter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::BranchFormatter do
let(:project) { create(:project, :repository) }
@@ -6,62 +6,62 @@ describe Gitlab::LegacyGithubImport::BranchFormatter do
let(:repo) { double }
let(:raw) do
{
- ref: 'branch-merged',
+ ref: "branch-merged",
repo: repo,
- sha: commit.id
+ sha: commit.id,
}
end
- describe '#exists?' do
- it 'returns true when branch exists and commit is part of the branch' do
+ describe "#exists?" do
+ it "returns true when branch exists and commit is part of the branch" do
branch = described_class.new(project, double(raw))
expect(branch.exists?).to eq true
end
- it 'returns false when branch exists and commit is not part of the branch' do
- branch = described_class.new(project, double(raw.merge(ref: 'feature')))
+ it "returns false when branch exists and commit is not part of the branch" do
+ branch = described_class.new(project, double(raw.merge(ref: "feature")))
expect(branch.exists?).to eq false
end
- it 'returns false when branch does not exist' do
- branch = described_class.new(project, double(raw.merge(ref: 'removed-branch')))
+ it "returns false when branch does not exist" do
+ branch = described_class.new(project, double(raw.merge(ref: "removed-branch")))
expect(branch.exists?).to eq false
end
end
- describe '#repo' do
- it 'returns raw repo' do
+ describe "#repo" do
+ it "returns raw repo" do
branch = described_class.new(project, double(raw))
expect(branch.repo).to eq repo
end
end
- describe '#sha' do
- it 'returns raw sha' do
+ describe "#sha" do
+ it "returns raw sha" do
branch = described_class.new(project, double(raw))
expect(branch.sha).to eq commit.id
end
end
- describe '#valid?' do
- it 'returns true when raw sha and ref are present' do
+ describe "#valid?" do
+ it "returns true when raw sha and ref are present" do
branch = described_class.new(project, double(raw))
expect(branch.valid?).to eq true
end
- it 'returns false when raw sha is blank' do
+ it "returns false when raw sha is blank" do
branch = described_class.new(project, double(raw.merge(sha: nil)))
expect(branch.valid?).to eq false
end
- it 'returns false when raw ref is blank' do
+ it "returns false when raw ref is blank" do
branch = described_class.new(project, double(raw.merge(ref: nil)))
expect(branch.valid?).to eq false
diff --git a/spec/lib/gitlab/legacy_github_import/client_spec.rb b/spec/lib/gitlab/legacy_github_import/client_spec.rb
index 80b767abce0..12233e2afa0 100644
--- a/spec/lib/gitlab/legacy_github_import/client_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/client_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::Client do
- let(:token) { '123456' }
- let(:github_provider) { Settingslogic.new('app_id' => 'asd123', 'app_secret' => 'asd123', 'name' => 'github', 'args' => { 'client_options' => {} }) }
+ let(:token) { "123456" }
+ let(:github_provider) { Settingslogic.new("app_id" => "asd123", "app_secret" => "asd123", "name" => "github", "args" => {"client_options" => {}}) }
subject(:client) { described_class.new(token) }
@@ -10,85 +10,85 @@ describe Gitlab::LegacyGithubImport::Client do
allow(Gitlab.config.omniauth).to receive(:providers).and_return([github_provider])
end
- it 'convert OAuth2 client options to symbols' do
+ it "convert OAuth2 client options to symbols" do
client.client.options.keys.each do |key|
expect(key).to be_kind_of(Symbol)
end
end
- it 'does not crash (e.g. Settingslogic::MissingSetting) when verify_ssl config is not present' do
+ it "does not crash (e.g. Settingslogic::MissingSetting) when verify_ssl config is not present" do
expect { client.api }.not_to raise_error
end
- context 'when config is missing' do
+ context "when config is missing" do
before do
allow(Gitlab.config.omniauth).to receive(:providers).and_return([])
end
- it 'is still possible to get an Octokit client' do
+ it "is still possible to get an Octokit client" do
expect { client.api }.not_to raise_error
end
- it 'is not be possible to get an OAuth2 client' do
+ it "is not be possible to get an OAuth2 client" do
expect { client.client }.to raise_error(Projects::ImportService::Error)
end
end
- context 'allow SSL verification to be configurable on API' do
+ context "allow SSL verification to be configurable on API" do
before do
- github_provider['verify_ssl'] = false
+ github_provider["verify_ssl"] = false
end
- it 'uses supplied value' do
- expect(client.client.options[:connection_opts][:ssl]).to eq({ verify: false })
- expect(client.api.connection_options[:ssl]).to eq({ verify: false })
+ it "uses supplied value" do
+ expect(client.client.options[:connection_opts][:ssl]).to eq({verify: false})
+ expect(client.api.connection_options[:ssl]).to eq({verify: false})
end
end
- describe '#api_endpoint' do
- context 'when provider does not specity an API endpoint' do
- it 'uses GitHub root API endpoint' do
- expect(client.api.api_endpoint).to eq 'https://api.github.com/'
+ describe "#api_endpoint" do
+ context "when provider does not specity an API endpoint" do
+ it "uses GitHub root API endpoint" do
+ expect(client.api.api_endpoint).to eq "https://api.github.com/"
end
end
- context 'when provider specify a custom API endpoint' do
+ context "when provider specify a custom API endpoint" do
before do
- github_provider['args']['client_options']['site'] = 'https://github.company.com/'
+ github_provider["args"]["client_options"]["site"] = "https://github.company.com/"
end
- it 'uses the custom API endpoint' do
+ it "uses the custom API endpoint" do
expect(OmniAuth::Strategies::GitHub).not_to receive(:default_options)
- expect(client.api.api_endpoint).to eq 'https://github.company.com/'
+ expect(client.api.api_endpoint).to eq "https://github.company.com/"
end
end
- context 'when given a host' do
- subject(:client) { described_class.new(token, host: 'https://try.gitea.io/') }
+ context "when given a host" do
+ subject(:client) { described_class.new(token, host: "https://try.gitea.io/") }
- it 'builds a endpoint with the given host and the default API version' do
- expect(client.api.api_endpoint).to eq 'https://try.gitea.io/api/v3/'
+ it "builds a endpoint with the given host and the default API version" do
+ expect(client.api.api_endpoint).to eq "https://try.gitea.io/api/v3/"
end
end
- context 'when given an API version' do
- subject(:client) { described_class.new(token, api_version: 'v3') }
+ context "when given an API version" do
+ subject(:client) { described_class.new(token, api_version: "v3") }
- it 'does not use the API version without a host' do
- expect(client.api.api_endpoint).to eq 'https://api.github.com/'
+ it "does not use the API version without a host" do
+ expect(client.api.api_endpoint).to eq "https://api.github.com/"
end
end
- context 'when given a host and version' do
- subject(:client) { described_class.new(token, host: 'https://try.gitea.io/', api_version: 'v3') }
+ context "when given a host and version" do
+ subject(:client) { described_class.new(token, host: "https://try.gitea.io/", api_version: "v3") }
- it 'builds a endpoint with the given options' do
- expect(client.api.api_endpoint).to eq 'https://try.gitea.io/api/v3/'
+ it "builds a endpoint with the given options" do
+ expect(client.api.api_endpoint).to eq "https://try.gitea.io/api/v3/"
end
end
end
- it 'does not raise error when rate limit is disabled' do
+ it "does not raise error when rate limit is disabled" do
stub_request(:get, /api.github.com/)
allow(client.api).to receive(:rate_limit!).and_raise(Octokit::NotFound)
diff --git a/spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb
index 413654e108c..60b95aa67b6 100644
--- a/spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/comment_formatter_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::CommentFormatter do
let(:client) { double }
let(:project) { create(:project) }
- let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
- let(:created_at) { DateTime.strptime('2013-04-10T20:09:31Z') }
- let(:updated_at) { DateTime.strptime('2014-03-03T18:58:10Z') }
+ let(:octocat) { double(id: 123456, login: "octocat", email: "octocat@example.com") }
+ let(:created_at) { DateTime.strptime("2013-04-10T20:09:31Z") }
+ let(:updated_at) { DateTime.strptime("2014-03-03T18:58:10Z") }
let(:base) do
{
body: "I'm having a problem with this.",
@@ -13,7 +13,7 @@ describe Gitlab::LegacyGithubImport::CommentFormatter do
commit_id: nil,
diff_hunk: nil,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
end
@@ -23,11 +23,11 @@ describe Gitlab::LegacyGithubImport::CommentFormatter do
allow(client).to receive(:user).and_return(octocat)
end
- describe '#attributes' do
- context 'when do not reference a portion of the diff' do
+ describe "#attributes" do
+ context "when do not reference a portion of the diff" do
let(:raw) { double(base) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
project: project,
note: "*Created by: octocat*\n\nI'm having a problem with this.",
@@ -36,58 +36,58 @@ describe Gitlab::LegacyGithubImport::CommentFormatter do
author_id: project.creator_id,
type: nil,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(comment.attributes).to eq(expected)
end
end
- context 'when on a portion of the diff' do
+ context "when on a portion of the diff" do
let(:diff) do
{
- body: 'Great stuff',
- commit_id: '6dcb09b5b57875f334f61aebed695e2e4193db5e',
+ body: "Great stuff",
+ commit_id: "6dcb09b5b57875f334f61aebed695e2e4193db5e",
diff_hunk: "@@ -1,5 +1,9 @@\n class User\n def name\n- 'John Doe'\n+ 'Jane Doe'",
- path: 'file1.txt'
+ path: "file1.txt",
}
end
let(:raw) { double(base.merge(diff)) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
project: project,
note: "*Created by: octocat*\n\nGreat stuff",
- commit_id: '6dcb09b5b57875f334f61aebed695e2e4193db5e',
- line_code: 'ce1be0ff4065a6e9415095c95f25f47a633cef2b_4_3',
+ commit_id: "6dcb09b5b57875f334f61aebed695e2e4193db5e",
+ line_code: "ce1be0ff4065a6e9415095c95f25f47a633cef2b_4_3",
author_id: project.creator_id,
- type: 'LegacyDiffNote',
+ type: "LegacyDiffNote",
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(comment.attributes).to eq(expected)
end
end
- context 'when author is a GitLab user' do
+ context "when author is a GitLab user" do
let(:raw) { double(base.merge(user: octocat)) }
- it 'returns GitLab user id associated with GitHub id as author_id' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns GitLab user id associated with GitHub id as author_id" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(comment.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns GitLab user id associated with GitHub email as author_id' do
+ it "returns GitLab user id associated with GitHub email as author_id" do
gl_user = create(:user, email: octocat.email)
expect(comment.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns note without created at tag line' do
- create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns note without created at tag line" do
+ create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(comment.attributes.fetch(:note)).to eq("I'm having a problem with this.")
end
diff --git a/spec/lib/gitlab/legacy_github_import/importer_spec.rb b/spec/lib/gitlab/legacy_github_import/importer_spec.rb
index 6bc3792eb22..26c92c59663 100644
--- a/spec/lib/gitlab/legacy_github_import/importer_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/importer_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::Importer do
- shared_examples 'Gitlab::LegacyGithubImport::Importer#execute' do
+ shared_examples "Gitlab::LegacyGithubImport::Importer#execute" do
let(:expected_not_called) { [] }
before do
allow(project).to receive(:import_data).and_return(double.as_null_object)
end
- it 'calls import methods' do
+ it "calls import methods" do
importer = described_class.new(project)
expected_called = [
:import_labels, :import_milestones, :import_pull_requests, :import_issues,
- :import_wiki, :import_releases, :handle_errors
+ :import_wiki, :import_releases, :handle_errors,
]
expected_called -= expected_not_called
@@ -35,7 +35,7 @@ describe Gitlab::LegacyGithubImport::Importer do
end
end
- shared_examples 'Gitlab::LegacyGithubImport::Importer#execute an error occurs' do
+ shared_examples "Gitlab::LegacyGithubImport::Importer#execute an error occurs" do
before do
allow(project).to receive(:import_data).and_return(double.as_null_object)
@@ -51,14 +51,14 @@ describe Gitlab::LegacyGithubImport::Importer do
allow_any_instance_of(Octokit::Client).to receive(:pull_requests).and_return([pull_request, pull_request])
allow_any_instance_of(Octokit::Client).to receive(:issues_comments).and_return([])
allow_any_instance_of(Octokit::Client).to receive(:pull_requests_comments).and_return([])
- allow_any_instance_of(Octokit::Client).to receive(:last_response).and_return(double(rels: { next: nil }))
+ allow_any_instance_of(Octokit::Client).to receive(:last_response).and_return(double(rels: {next: nil}))
allow_any_instance_of(Octokit::Client).to receive(:releases).and_return([release1, release2])
end
let(:label1) do
double(
- name: 'Bug',
- color: 'ff0000',
+ name: "Bug",
+ color: "ff0000",
url: "#{api_root}/repos/octocat/Hello-World/labels/bug"
)
end
@@ -66,7 +66,7 @@ describe Gitlab::LegacyGithubImport::Importer do
let(:label2) do
double(
name: nil,
- color: 'ff0000',
+ color: "ff0000",
url: "#{api_root}/repos/octocat/Hello-World/labels/bug"
)
end
@@ -75,9 +75,9 @@ describe Gitlab::LegacyGithubImport::Importer do
double(
id: 1347, # For Gitea
number: 1347,
- state: 'open',
- title: '1.0',
- description: 'Version 1.0',
+ state: "open",
+ title: "1.0",
+ description: "Version 1.0",
due_on: nil,
created_at: created_at,
updated_at: updated_at,
@@ -90,8 +90,8 @@ describe Gitlab::LegacyGithubImport::Importer do
double(
number: 1347,
milestone: nil,
- state: 'open',
- title: 'Found a bug',
+ state: "open",
+ title: "Found a bug",
body: "I'm having a problem with this.",
assignee: nil,
user: octocat,
@@ -101,7 +101,7 @@ describe Gitlab::LegacyGithubImport::Importer do
updated_at: updated_at,
closed_at: nil,
url: "#{api_root}/repos/octocat/Hello-World/issues/1347",
- labels: [double(name: 'Label #1')]
+ labels: [double(name: "Label #1")]
)
end
@@ -109,7 +109,7 @@ describe Gitlab::LegacyGithubImport::Importer do
double(
number: 1348,
milestone: nil,
- state: 'open',
+ state: "open",
title: nil,
body: "I'm having a problem with this.",
assignee: nil,
@@ -120,15 +120,15 @@ describe Gitlab::LegacyGithubImport::Importer do
updated_at: updated_at,
closed_at: nil,
url: "#{api_root}/repos/octocat/Hello-World/issues/1348",
- labels: [double(name: 'Label #2')]
+ labels: [double(name: "Label #2")]
)
end
let(:release1) do
double(
- tag_name: 'v1.0.0',
- name: 'First release',
- body: 'Release v1.0.0',
+ tag_name: "v1.0.0",
+ name: "First release",
+ body: "Release v1.0.0",
draft: false,
created_at: created_at,
updated_at: updated_at,
@@ -138,8 +138,8 @@ describe Gitlab::LegacyGithubImport::Importer do
let(:release2) do
double(
- tag_name: 'v1.1.0',
- name: 'Second release',
+ tag_name: "v1.1.0",
+ name: "Second release",
body: nil,
draft: false,
created_at: created_at,
@@ -150,26 +150,26 @@ describe Gitlab::LegacyGithubImport::Importer do
subject { described_class.new(project) }
- it 'returns true' do
+ it "returns true" do
expect(subject.execute).to eq true
end
- it 'does not raise an error' do
+ it "does not raise an error" do
expect { subject.execute }.not_to raise_error
end
- it 'stores error messages' do
+ it "stores error messages" do
error = {
- message: 'The remote data could not be fully imported.',
+ message: "The remote data could not be fully imported.",
errors: [
- { type: :label, url: "#{api_root}/repos/octocat/Hello-World/labels/bug", errors: "Validation failed: Title can't be blank, Title is invalid" },
- { type: :issue, url: "#{api_root}/repos/octocat/Hello-World/issues/1348", errors: "Validation failed: Title can't be blank" },
- { type: :wiki, errors: "Gitlab::Shell::Error" }
- ]
+ {type: :label, url: "#{api_root}/repos/octocat/Hello-World/labels/bug", errors: "Validation failed: Title can't be blank, Title is invalid"},
+ {type: :issue, url: "#{api_root}/repos/octocat/Hello-World/issues/1348", errors: "Validation failed: Title can't be blank"},
+ {type: :wiki, errors: "Gitlab::Shell::Error"},
+ ],
}
unless project.gitea_import?
- error[:errors] << { type: :release, url: "#{api_root}/repos/octocat/Hello-World/releases/2", errors: "Validation failed: Description can't be blank" }
+ error[:errors] << {type: :release, url: "#{api_root}/repos/octocat/Hello-World/releases/2", errors: "Validation failed: Description can't be blank"}
end
described_class.new(project).execute
@@ -178,8 +178,8 @@ describe Gitlab::LegacyGithubImport::Importer do
end
end
- shared_examples 'Gitlab::LegacyGithubImport unit-testing' do
- describe '#clean_up_restored_branches' do
+ shared_examples "Gitlab::LegacyGithubImport unit-testing" do
+ describe "#clean_up_restored_branches" do
subject { described_class.new(project) }
before do
@@ -187,19 +187,19 @@ describe Gitlab::LegacyGithubImport::Importer do
allow(gh_pull_request).to receive(:target_branch_exists?).at_least(:once) { false }
end
- context 'when pull request stills open' do
+ context "when pull request stills open" do
let(:gh_pull_request) { Gitlab::LegacyGithubImport::PullRequestFormatter.new(project, pull_request) }
- it 'does not remove branches' do
+ it "does not remove branches" do
expect(subject).not_to receive(:remove_branch)
subject.send(:clean_up_restored_branches, gh_pull_request)
end
end
- context 'when pull request is closed' do
+ context "when pull request is closed" do
let(:gh_pull_request) { Gitlab::LegacyGithubImport::PullRequestFormatter.new(project, closed_pull_request) }
- it 'does remove branches' do
+ it "does remove branches" do
expect(subject).to receive(:remove_branch).at_least(2).times
subject.send(:clean_up_restored_branches, gh_pull_request)
end
@@ -208,23 +208,23 @@ describe Gitlab::LegacyGithubImport::Importer do
end
let(:project) { create(:project, :repository, :wiki_disabled, import_url: "#{repo_root}/octocat/Hello-World.git") }
- let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
- let(:credentials) { { user: 'joe' } }
+ let(:octocat) { double(id: 123456, login: "octocat", email: "octocat@example.com") }
+ let(:credentials) { {user: "joe"} }
- let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
- let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') }
+ let(:created_at) { DateTime.strptime("2011-01-26T19:01:12Z") }
+ let(:updated_at) { DateTime.strptime("2011-01-27T19:01:12Z") }
let(:repository) { double(id: 1, fork: false) }
let(:source_sha) { create(:commit, project: project).id }
- let(:source_branch) { double(ref: 'branch-merged', repo: repository, sha: source_sha, user: octocat) }
+ let(:source_branch) { double(ref: "branch-merged", repo: repository, sha: source_sha, user: octocat) }
let(:target_sha) { create(:commit, project: project, git_commit: RepoHelpers.another_sample_commit).id }
- let(:target_branch) { double(ref: 'master', repo: repository, sha: target_sha, user: octocat) }
+ let(:target_branch) { double(ref: "master", repo: repository, sha: target_sha, user: octocat) }
let(:pull_request) do
double(
number: 1347,
milestone: nil,
- state: 'open',
- title: 'New feature',
- body: 'Please pull these awesome changes',
+ state: "open",
+ title: "New feature",
+ body: "Please pull these awesome changes",
head: source_branch,
base: target_branch,
assignee: nil,
@@ -234,16 +234,16 @@ describe Gitlab::LegacyGithubImport::Importer do
closed_at: nil,
merged_at: nil,
url: "#{api_root}/repos/octocat/Hello-World/pulls/1347",
- labels: [double(name: 'Label #2')]
+ labels: [double(name: "Label #2")]
)
end
let(:closed_pull_request) do
double(
number: 1347,
milestone: nil,
- state: 'closed',
- title: 'New feature',
- body: 'Please pull these awesome changes',
+ state: "closed",
+ title: "New feature",
+ body: "Please pull these awesome changes",
head: source_branch,
base: target_branch,
assignee: nil,
@@ -253,21 +253,21 @@ describe Gitlab::LegacyGithubImport::Importer do
closed_at: updated_at,
merged_at: nil,
url: "#{api_root}/repos/octocat/Hello-World/pulls/1347",
- labels: [double(name: 'Label #2')]
+ labels: [double(name: "Label #2")]
)
end
- context 'when importing a GitHub project' do
- let(:api_root) { 'https://api.github.com' }
- let(:repo_root) { 'https://github.com' }
+ context "when importing a GitHub project" do
+ let(:api_root) { "https://api.github.com" }
+ let(:repo_root) { "https://github.com" }
subject { described_class.new(project) }
- it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute'
- it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute an error occurs'
- it_behaves_like 'Gitlab::LegacyGithubImport unit-testing'
+ it_behaves_like "Gitlab::LegacyGithubImport::Importer#execute"
+ it_behaves_like "Gitlab::LegacyGithubImport::Importer#execute an error occurs"
+ it_behaves_like "Gitlab::LegacyGithubImport unit-testing"
- describe '#client' do
- it 'instantiates a Client' do
+ describe "#client" do
+ it "instantiates a Client" do
allow(project).to receive(:import_data).and_return(double(credentials: credentials))
expect(Gitlab::LegacyGithubImport::Client).to receive(:new).with(
credentials[:user],
@@ -279,27 +279,27 @@ describe Gitlab::LegacyGithubImport::Importer do
end
end
- context 'when importing a Gitea project' do
- let(:api_root) { 'https://try.gitea.io/api/v1' }
- let(:repo_root) { 'https://try.gitea.io' }
+ context "when importing a Gitea project" do
+ let(:api_root) { "https://try.gitea.io/api/v1" }
+ let(:repo_root) { "https://try.gitea.io" }
subject { described_class.new(project) }
before do
- project.update(import_type: 'gitea', import_url: "#{repo_root}/foo/group/project.git")
+ project.update(import_type: "gitea", import_url: "#{repo_root}/foo/group/project.git")
end
- it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute' do
+ it_behaves_like "Gitlab::LegacyGithubImport::Importer#execute" do
let(:expected_not_called) { [:import_releases] }
end
- it_behaves_like 'Gitlab::LegacyGithubImport::Importer#execute an error occurs'
- it_behaves_like 'Gitlab::LegacyGithubImport unit-testing'
+ it_behaves_like "Gitlab::LegacyGithubImport::Importer#execute an error occurs"
+ it_behaves_like "Gitlab::LegacyGithubImport unit-testing"
- describe '#client' do
- it 'instantiates a Client' do
+ describe "#client" do
+ it "instantiates a Client" do
allow(project).to receive(:import_data).and_return(double(credentials: credentials))
expect(Gitlab::LegacyGithubImport::Client).to receive(:new).with(
credentials[:user],
- { host: "#{repo_root}:443/foo", api_version: 'v1' }
+ {host: "#{repo_root}:443/foo", api_version: "v1"}
)
subject.client
diff --git a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb
index 3b5d8945344..47e3e3b202c 100644
--- a/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/issuable_formatter_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::IssuableFormatter do
let(:raw_data) do
double(number: 42)
end
- let(:project) { double(import_type: 'github') }
+ let(:project) { double(import_type: "github") }
let(:issuable_formatter) { described_class.new(project, raw_data) }
- describe '#project_association' do
+ describe "#project_association" do
it { expect { issuable_formatter.project_association }.to raise_error(NotImplementedError) }
end
- describe '#number' do
+ describe "#number" do
it { expect(issuable_formatter.number).to eq(42) }
end
- describe '#find_condition' do
- it { expect(issuable_formatter.find_condition).to eq({ iid: 42 }) }
+ describe "#find_condition" do
+ it { expect(issuable_formatter.find_condition).to eq({iid: 42}) }
end
end
diff --git a/spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb
index 1a4d5dbfb70..77dfe205bd9 100644
--- a/spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/issue_formatter_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::IssueFormatter do
let(:client) { double }
- let!(:project) { create(:project, namespace: create(:namespace, path: 'octocat')) }
- let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
- let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
- let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') }
+ let!(:project) { create(:project, namespace: create(:namespace, path: "octocat")) }
+ let(:octocat) { double(id: 123456, login: "octocat", email: "octocat@example.com") }
+ let(:created_at) { DateTime.strptime("2011-01-26T19:01:12Z") }
+ let(:updated_at) { DateTime.strptime("2011-01-27T19:01:12Z") }
let(:base_data) do
{
number: 1347,
milestone: nil,
- state: 'open',
- title: 'Found a bug',
+ state: "open",
+ title: "Found a bug",
body: "I'm having a problem with this.",
assignee: nil,
user: octocat,
@@ -20,7 +20,7 @@ describe Gitlab::LegacyGithubImport::IssueFormatter do
pull_request: nil,
created_at: created_at,
updated_at: updated_at,
- closed_at: nil
+ closed_at: nil,
}
end
@@ -30,164 +30,164 @@ describe Gitlab::LegacyGithubImport::IssueFormatter do
allow(client).to receive(:user).and_return(octocat)
end
- shared_examples 'Gitlab::LegacyGithubImport::IssueFormatter#attributes' do
- context 'when issue is open' do
- let(:raw_data) { double(base_data.merge(state: 'open')) }
+ shared_examples "Gitlab::LegacyGithubImport::IssueFormatter#attributes" do
+ context "when issue is open" do
+ let(:raw_data) { double(base_data.merge(state: "open")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
project: project,
milestone: nil,
- title: 'Found a bug',
+ title: "Found a bug",
description: "*Created by: octocat*\n\nI'm having a problem with this.",
- state: 'opened',
+ state: "opened",
author_id: project.creator_id,
assignee_ids: [],
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(issue.attributes).to eq(expected)
end
end
- context 'when issue is closed' do
- let(:raw_data) { double(base_data.merge(state: 'closed')) }
+ context "when issue is closed" do
+ let(:raw_data) { double(base_data.merge(state: "closed")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
project: project,
milestone: nil,
- title: 'Found a bug',
+ title: "Found a bug",
description: "*Created by: octocat*\n\nI'm having a problem with this.",
- state: 'closed',
+ state: "closed",
author_id: project.creator_id,
assignee_ids: [],
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(issue.attributes).to eq(expected)
end
end
- context 'when it is assigned to someone' do
+ context "when it is assigned to someone" do
let(:raw_data) { double(base_data.merge(assignee: octocat)) }
- it 'returns nil as assignee_id when is not a GitLab user' do
+ it "returns nil as assignee_id when is not a GitLab user" do
expect(issue.attributes.fetch(:assignee_ids)).to be_empty
end
- it 'returns GitLab user id associated with GitHub id as assignee_id' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns GitLab user id associated with GitHub id as assignee_id" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(issue.attributes.fetch(:assignee_ids)).to eq [gl_user.id]
end
- it 'returns GitLab user id associated with GitHub email as assignee_id' do
+ it "returns GitLab user id associated with GitHub email as assignee_id" do
gl_user = create(:user, email: octocat.email)
expect(issue.attributes.fetch(:assignee_ids)).to eq [gl_user.id]
end
end
- context 'when it has a milestone' do
+ context "when it has a milestone" do
let(:milestone) { double(id: 42, number: 42) }
let(:raw_data) { double(base_data.merge(milestone: milestone)) }
- it 'returns nil when milestone does not exist' do
+ it "returns nil when milestone does not exist" do
expect(issue.attributes.fetch(:milestone)).to be_nil
end
- it 'returns milestone when it exists' do
+ it "returns milestone when it exists" do
milestone = create(:milestone, project: project, iid: 42)
expect(issue.attributes.fetch(:milestone)).to eq milestone
end
end
- context 'when author is a GitLab user' do
+ context "when author is a GitLab user" do
let(:raw_data) { double(base_data.merge(user: octocat)) }
- it 'returns project creator_id as author_id when is not a GitLab user' do
+ it "returns project creator_id as author_id when is not a GitLab user" do
expect(issue.attributes.fetch(:author_id)).to eq project.creator_id
end
- it 'returns GitLab user id associated with GitHub id as author_id' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns GitLab user id associated with GitHub id as author_id" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(issue.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns GitLab user id associated with GitHub email as author_id' do
+ it "returns GitLab user id associated with GitHub email as author_id" do
gl_user = create(:user, email: octocat.email)
expect(issue.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns description without created at tag line' do
- create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns description without created at tag line" do
+ create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(issue.attributes.fetch(:description)).to eq("I'm having a problem with this.")
end
end
end
- shared_examples 'Gitlab::LegacyGithubImport::IssueFormatter#number' do
+ shared_examples "Gitlab::LegacyGithubImport::IssueFormatter#number" do
let(:raw_data) { double(base_data.merge(number: 1347)) }
- it 'returns issue number' do
+ it "returns issue number" do
expect(issue.number).to eq 1347
end
end
- context 'when importing a GitHub project' do
- it_behaves_like 'Gitlab::LegacyGithubImport::IssueFormatter#attributes'
- it_behaves_like 'Gitlab::LegacyGithubImport::IssueFormatter#number'
+ context "when importing a GitHub project" do
+ it_behaves_like "Gitlab::LegacyGithubImport::IssueFormatter#attributes"
+ it_behaves_like "Gitlab::LegacyGithubImport::IssueFormatter#number"
end
- context 'when importing a Gitea project' do
+ context "when importing a Gitea project" do
before do
- project.update(import_type: 'gitea')
+ project.update(import_type: "gitea")
end
- it_behaves_like 'Gitlab::LegacyGithubImport::IssueFormatter#attributes'
- it_behaves_like 'Gitlab::LegacyGithubImport::IssueFormatter#number'
+ it_behaves_like "Gitlab::LegacyGithubImport::IssueFormatter#attributes"
+ it_behaves_like "Gitlab::LegacyGithubImport::IssueFormatter#number"
end
- describe '#has_comments?' do
- context 'when number of comments is greater than zero' do
+ describe "#has_comments?" do
+ context "when number of comments is greater than zero" do
let(:raw_data) { double(base_data.merge(comments: 1)) }
- it 'returns true' do
+ it "returns true" do
expect(issue.has_comments?).to eq true
end
end
- context 'when number of comments is equal to zero' do
+ context "when number of comments is equal to zero" do
let(:raw_data) { double(base_data.merge(comments: 0)) }
- it 'returns false' do
+ it "returns false" do
expect(issue.has_comments?).to eq false
end
end
end
- describe '#pull_request?' do
- context 'when mention a pull request' do
+ describe "#pull_request?" do
+ context "when mention a pull request" do
let(:raw_data) { double(base_data.merge(pull_request: double)) }
- it 'returns true' do
+ it "returns true" do
expect(issue.pull_request?).to eq true
end
end
- context 'when does not mention a pull request' do
+ context "when does not mention a pull request" do
let(:raw_data) { double(base_data.merge(pull_request: nil)) }
- it 'returns false' do
+ it "returns false" do
expect(issue.pull_request?).to eq false
end
end
diff --git a/spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb
index 0d1d04f1bf6..2ea6bfb5abe 100644
--- a/spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/label_formatter_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::LabelFormatter do
let(:project) { create(:project) }
- let(:raw) { double(name: 'improvements', color: 'e6e6e6') }
+ let(:raw) { double(name: "improvements", color: "e6e6e6") }
subject { described_class.new(project, raw) }
- describe '#attributes' do
- it 'returns formatted attributes' do
+ describe "#attributes" do
+ it "returns formatted attributes" do
expect(subject.attributes).to eq({
project: project,
- title: 'improvements',
- color: '#e6e6e6'
+ title: "improvements",
+ color: "#e6e6e6",
})
end
end
- describe '#create!' do
- context 'when label does not exist' do
- it 'creates a new label' do
+ describe "#create!" do
+ context "when label does not exist" do
+ it "creates a new label" do
expect { subject.create! }.to change(Label, :count).by(1)
end
end
- context 'when label exists' do
- it 'does not create a new label' do
+ context "when label exists" do
+ it "does not create a new label" do
Labels::CreateService.new(name: raw.name).execute(project: project)
expect { subject.create! }.not_to change(Label, :count)
diff --git a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb
index 1db4bbb568c..a2935bc2bbc 100644
--- a/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/milestone_formatter_spec.rb
@@ -1,79 +1,79 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::MilestoneFormatter do
let(:project) { create(:project) }
- let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
- let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') }
+ let(:created_at) { DateTime.strptime("2011-01-26T19:01:12Z") }
+ let(:updated_at) { DateTime.strptime("2011-01-27T19:01:12Z") }
let(:base_data) do
{
- state: 'open',
- title: '1.0',
- description: 'Version 1.0',
+ state: "open",
+ title: "1.0",
+ description: "Version 1.0",
due_on: nil,
created_at: created_at,
updated_at: updated_at,
- closed_at: nil
+ closed_at: nil,
}
end
let(:iid_attr) { :number }
subject(:formatter) { described_class.new(project, raw_data) }
- shared_examples 'Gitlab::LegacyGithubImport::MilestoneFormatter#attributes' do
+ shared_examples "Gitlab::LegacyGithubImport::MilestoneFormatter#attributes" do
let(:data) { base_data.merge(iid_attr => 1347) }
- context 'when milestone is open' do
- let(:raw_data) { double(data.merge(state: 'open')) }
+ context "when milestone is open" do
+ let(:raw_data) { double(data.merge(state: "open")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
project: project,
- title: '1.0',
- description: 'Version 1.0',
- state: 'active',
+ title: "1.0",
+ description: "Version 1.0",
+ state: "active",
due_date: nil,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(formatter.attributes).to eq(expected)
end
end
- context 'when milestone is closed' do
- let(:raw_data) { double(data.merge(state: 'closed')) }
+ context "when milestone is closed" do
+ let(:raw_data) { double(data.merge(state: "closed")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
project: project,
- title: '1.0',
- description: 'Version 1.0',
- state: 'closed',
+ title: "1.0",
+ description: "Version 1.0",
+ state: "closed",
due_date: nil,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(formatter.attributes).to eq(expected)
end
end
- context 'when milestone has a due date' do
- let(:due_date) { DateTime.strptime('2011-01-28T19:01:12Z') }
+ context "when milestone has a due date" do
+ let(:due_date) { DateTime.strptime("2011-01-28T19:01:12Z") }
let(:raw_data) { double(data.merge(due_on: due_date)) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
project: project,
- title: '1.0',
- description: 'Version 1.0',
- state: 'active',
+ title: "1.0",
+ description: "Version 1.0",
+ state: "active",
due_date: due_date,
created_at: created_at,
- updated_at: updated_at
+ updated_at: updated_at,
}
expect(formatter.attributes).to eq(expected)
@@ -81,16 +81,16 @@ describe Gitlab::LegacyGithubImport::MilestoneFormatter do
end
end
- context 'when importing a GitHub project' do
- it_behaves_like 'Gitlab::LegacyGithubImport::MilestoneFormatter#attributes'
+ context "when importing a GitHub project" do
+ it_behaves_like "Gitlab::LegacyGithubImport::MilestoneFormatter#attributes"
end
- context 'when importing a Gitea project' do
+ context "when importing a Gitea project" do
let(:iid_attr) { :id }
before do
- project.update(import_type: 'gitea')
+ project.update(import_type: "gitea")
end
- it_behaves_like 'Gitlab::LegacyGithubImport::MilestoneFormatter#attributes'
+ it_behaves_like "Gitlab::LegacyGithubImport::MilestoneFormatter#attributes"
end
end
diff --git a/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb b/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb
index 3d4240fa4ba..3ad33e8553b 100644
--- a/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/project_creator_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::ProjectCreator do
let(:user) { create(:user) }
@@ -6,14 +6,14 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
let(:repo) do
OpenStruct.new(
- login: 'vim',
- name: 'vim',
- full_name: 'asd/vim',
- clone_url: 'https://gitlab.com/asd/vim.git'
+ login: "vim",
+ name: "vim",
+ full_name: "asd/vim",
+ clone_url: "https://gitlab.com/asd/vim.git"
)
end
- subject(:service) { described_class.new(repo, repo.name, namespace, user, github_access_token: 'asdffg') }
+ subject(:service) { described_class.new(repo, repo.name, namespace, user, github_access_token: "asdffg") }
before do
namespace.add_owner(user)
@@ -23,21 +23,21 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- describe '#execute' do
- it 'creates a project' do
+ describe "#execute" do
+ it "creates a project" do
expect { service.execute }.to change(Project, :count).by(1)
end
- it 'handle GitHub credentials' do
+ it "handle GitHub credentials" do
project = service.execute
- expect(project.import_url).to eq('https://asdffg@gitlab.com/asd/vim.git')
- expect(project.safe_import_url).to eq('https://*****@gitlab.com/asd/vim.git')
- expect(project.import_data.credentials).to eq(user: 'asdffg', password: nil)
+ expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git")
+ expect(project.safe_import_url).to eq("https://*****@gitlab.com/asd/vim.git")
+ expect(project.import_data.credentials).to eq(user: "asdffg", password: nil)
end
- context 'when GitHub project is private' do
- it 'sets project visibility to private' do
+ context "when GitHub project is private" do
+ it "sets project visibility to private" do
repo.private = true
project = service.execute
@@ -46,8 +46,8 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- context 'when GitHub project is public' do
- it 'sets project visibility to public' do
+ context "when GitHub project is public" do
+ it "sets project visibility to public" do
repo.private = false
project = service.execute
@@ -56,14 +56,14 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- context 'when visibility level is restricted' do
- context 'when GitHub project is private' do
+ context "when visibility level is restricted" do
+ context "when GitHub project is private" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PRIVATE])
allow_any_instance_of(ApplicationSetting).to receive(:default_project_visibility).and_return(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'sets project visibility to the default project visibility' do
+ it "sets project visibility to the default project visibility" do
repo.private = true
project = service.execute
@@ -72,13 +72,13 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- context 'when GitHub project is public' do
+ context "when GitHub project is public" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
allow_any_instance_of(ApplicationSetting).to receive(:default_project_visibility).and_return(Gitlab::VisibilityLevel::INTERNAL)
end
- it 'sets project visibility to the default project visibility' do
+ it "sets project visibility to the default project visibility" do
repo.private = false
project = service.execute
@@ -88,8 +88,8 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- context 'when GitHub project has wiki' do
- it 'does not create the wiki repository' do
+ context "when GitHub project has wiki" do
+ it "does not create the wiki repository" do
allow(repo).to receive(:has_wiki?).and_return(true)
project = service.execute
@@ -98,8 +98,8 @@ describe Gitlab::LegacyGithubImport::ProjectCreator do
end
end
- context 'when GitHub project does not have wiki' do
- it 'creates the wiki repository' do
+ context "when GitHub project does not have wiki" do
+ it "creates the wiki repository" do
allow(repo).to receive(:has_wiki?).and_return(false)
project = service.execute
diff --git a/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb
index 267a41e3f32..cd956a1d808 100644
--- a/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/pull_request_formatter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::PullRequestFormatter do
let(:client) { double }
@@ -9,23 +9,23 @@ describe Gitlab::LegacyGithubImport::PullRequestFormatter do
let(:target_short_sha) { target_commit.id.to_s[0..7] }
let(:repository) { double(id: 1, fork: false) }
let(:source_repo) { repository }
- let(:source_branch) { double(ref: 'branch-merged', repo: source_repo, sha: source_sha) }
- let(:forked_source_repo) { double(id: 2, fork: true, name: 'otherproject', full_name: 'company/otherproject') }
+ let(:source_branch) { double(ref: "branch-merged", repo: source_repo, sha: source_sha) }
+ let(:forked_source_repo) { double(id: 2, fork: true, name: "otherproject", full_name: "company/otherproject") }
let(:target_repo) { repository }
- let(:target_branch) { double(ref: 'master', repo: target_repo, sha: target_sha, user: octocat) }
- let(:removed_branch) { double(ref: 'removed-branch', repo: source_repo, sha: '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b', user: octocat) }
- let(:forked_branch) { double(ref: 'master', repo: forked_source_repo, sha: '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b', user: octocat) }
- let(:branch_deleted_repo) { double(ref: 'master', repo: nil, sha: '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b', user: octocat) }
- let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
- let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
- let(:updated_at) { DateTime.strptime('2011-01-27T19:01:12Z') }
+ let(:target_branch) { double(ref: "master", repo: target_repo, sha: target_sha, user: octocat) }
+ let(:removed_branch) { double(ref: "removed-branch", repo: source_repo, sha: "2e5d3239642f9161dcbbc4b70a211a68e5e45e2b", user: octocat) }
+ let(:forked_branch) { double(ref: "master", repo: forked_source_repo, sha: "2e5d3239642f9161dcbbc4b70a211a68e5e45e2b", user: octocat) }
+ let(:branch_deleted_repo) { double(ref: "master", repo: nil, sha: "2e5d3239642f9161dcbbc4b70a211a68e5e45e2b", user: octocat) }
+ let(:octocat) { double(id: 123456, login: "octocat", email: "octocat@example.com") }
+ let(:created_at) { DateTime.strptime("2011-01-26T19:01:12Z") }
+ let(:updated_at) { DateTime.strptime("2011-01-27T19:01:12Z") }
let(:base_data) do
{
number: 1347,
milestone: nil,
- state: 'open',
- title: 'New feature',
- body: 'Please pull these awesome changes',
+ state: "open",
+ title: "New feature",
+ body: "Please pull these awesome changes",
head: source_branch,
base: target_branch,
assignee: nil,
@@ -34,7 +34,7 @@ describe Gitlab::LegacyGithubImport::PullRequestFormatter do
updated_at: updated_at,
closed_at: nil,
merged_at: nil,
- url: 'https://api.github.com/repos/octocat/Hello-World/pulls/1347'
+ url: "https://api.github.com/repos/octocat/Hello-World/pulls/1347",
}
end
@@ -44,144 +44,144 @@ describe Gitlab::LegacyGithubImport::PullRequestFormatter do
allow(client).to receive(:user).and_return(octocat)
end
- shared_examples 'Gitlab::LegacyGithubImport::PullRequestFormatter#attributes' do
- context 'when pull request is open' do
- let(:raw_data) { double(base_data.merge(state: 'open')) }
+ shared_examples "Gitlab::LegacyGithubImport::PullRequestFormatter#attributes" do
+ context "when pull request is open" do
+ let(:raw_data) { double(base_data.merge(state: "open")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
- title: 'New feature',
+ title: "New feature",
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,
- source_branch: 'branch-merged',
+ source_branch: "branch-merged",
source_branch_sha: source_sha,
target_project: project,
- target_branch: 'master',
+ target_branch: "master",
target_branch_sha: target_sha,
- state: 'opened',
+ state: "opened",
milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
updated_at: updated_at,
- imported: true
+ imported: true,
}
expect(pull_request.attributes).to eq(expected)
end
end
- context 'when pull request is closed' do
- let(:raw_data) { double(base_data.merge(state: 'closed')) }
+ context "when pull request is closed" do
+ let(:raw_data) { double(base_data.merge(state: "closed")) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
- title: 'New feature',
+ title: "New feature",
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,
- source_branch: 'branch-merged',
+ source_branch: "branch-merged",
source_branch_sha: source_sha,
target_project: project,
- target_branch: 'master',
+ target_branch: "master",
target_branch_sha: target_sha,
- state: 'closed',
+ state: "closed",
milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
updated_at: updated_at,
- imported: true
+ imported: true,
}
expect(pull_request.attributes).to eq(expected)
end
end
- context 'when pull request is merged' do
- let(:merged_at) { DateTime.strptime('2011-01-28T13:01:12Z') }
- let(:raw_data) { double(base_data.merge(state: 'closed', merged_at: merged_at)) }
+ context "when pull request is merged" do
+ let(:merged_at) { DateTime.strptime("2011-01-28T13:01:12Z") }
+ let(:raw_data) { double(base_data.merge(state: "closed", merged_at: merged_at)) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
iid: 1347,
- title: 'New feature',
+ title: "New feature",
description: "*Created by: octocat*\n\nPlease pull these awesome changes",
source_project: project,
- source_branch: 'branch-merged',
+ source_branch: "branch-merged",
source_branch_sha: source_sha,
target_project: project,
- target_branch: 'master',
+ target_branch: "master",
target_branch_sha: target_sha,
- state: 'merged',
+ state: "merged",
milestone: nil,
author_id: project.creator_id,
assignee_id: nil,
created_at: created_at,
updated_at: updated_at,
- imported: true
+ imported: true,
}
expect(pull_request.attributes).to eq(expected)
end
end
- context 'when it is assigned to someone' do
+ context "when it is assigned to someone" do
let(:raw_data) { double(base_data.merge(assignee: octocat)) }
- it 'returns nil as assignee_id when is not a GitLab user' do
+ it "returns nil as assignee_id when is not a GitLab user" do
expect(pull_request.attributes.fetch(:assignee_id)).to be_nil
end
- it 'returns GitLab user id associated with GitHub id as assignee_id' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns GitLab user id associated with GitHub id as assignee_id" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(pull_request.attributes.fetch(:assignee_id)).to eq gl_user.id
end
- it 'returns GitLab user id associated with GitHub email as assignee_id' do
+ it "returns GitLab user id associated with GitHub email as assignee_id" do
gl_user = create(:user, email: octocat.email)
expect(pull_request.attributes.fetch(:assignee_id)).to eq gl_user.id
end
end
- context 'when author is a GitLab user' do
+ context "when author is a GitLab user" do
let(:raw_data) { double(base_data.merge(user: octocat)) }
- it 'returns project creator_id as author_id when is not a GitLab user' do
+ it "returns project creator_id as author_id when is not a GitLab user" do
expect(pull_request.attributes.fetch(:author_id)).to eq project.creator_id
end
- it 'returns GitLab user id associated with GitHub id as author_id' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns GitLab user id associated with GitHub id as author_id" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(pull_request.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns GitLab user id associated with GitHub email as author_id' do
+ it "returns GitLab user id associated with GitHub email as author_id" do
gl_user = create(:user, email: octocat.email)
expect(pull_request.attributes.fetch(:author_id)).to eq gl_user.id
end
- it 'returns description without created at tag line' do
- create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ it "returns description without created at tag line" do
+ create(:omniauth_user, extern_uid: octocat.id, provider: "github")
- expect(pull_request.attributes.fetch(:description)).to eq('Please pull these awesome changes')
+ expect(pull_request.attributes.fetch(:description)).to eq("Please pull these awesome changes")
end
end
- context 'when it has a milestone' do
+ context "when it has a milestone" do
let(:milestone) { double(id: 42, number: 42) }
let(:raw_data) { double(base_data.merge(milestone: milestone)) }
- it 'returns nil when milestone does not exist' do
+ it "returns nil when milestone does not exist" do
expect(pull_request.attributes.fetch(:milestone)).to be_nil
end
- it 'returns milestone when it exists' do
+ it "returns milestone when it exists" do
milestone = create(:milestone, project: project, iid: 42)
expect(pull_request.attributes.fetch(:milestone)).to eq milestone
@@ -189,156 +189,156 @@ describe Gitlab::LegacyGithubImport::PullRequestFormatter do
end
end
- shared_examples 'Gitlab::LegacyGithubImport::PullRequestFormatter#number' do
+ shared_examples "Gitlab::LegacyGithubImport::PullRequestFormatter#number" do
let(:raw_data) { double(base_data) }
- it 'returns pull request number' do
+ it "returns pull request number" do
expect(pull_request.number).to eq 1347
end
end
- shared_examples 'Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name' do
- context 'when source branch exists' do
+ shared_examples "Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name" do
+ context "when source branch exists" do
let(:raw_data) { double(base_data) }
- it 'returns branch ref' do
- expect(pull_request.source_branch_name).to eq 'branch-merged'
+ it "returns branch ref" do
+ expect(pull_request.source_branch_name).to eq "branch-merged"
end
end
- context 'when source branch does not exist' do
+ context "when source branch does not exist" do
let(:raw_data) { double(base_data.merge(head: removed_branch)) }
- it 'prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision' do
+ it "prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision" do
expect(pull_request.source_branch_name).to eq "gh-#{target_short_sha}/1347/octocat/removed-branch"
end
end
- context 'when source branch is from a fork' do
+ context "when source branch is from a fork" do
let(:raw_data) { double(base_data.merge(head: forked_branch)) }
- it 'prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision' do
+ it "prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision" do
expect(pull_request.source_branch_name).to eq "gh-#{target_short_sha}/1347/octocat/master"
end
end
- context 'when source branch is from a deleted fork' do
+ context "when source branch is from a deleted fork" do
let(:raw_data) { double(base_data.merge(head: branch_deleted_repo)) }
- it 'prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision' do
+ it "prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision" do
expect(pull_request.source_branch_name).to eq "gh-#{target_short_sha}/1347/octocat/master"
end
end
end
- shared_examples 'Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name' do
- context 'when target branch exists' do
+ shared_examples "Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name" do
+ context "when target branch exists" do
let(:raw_data) { double(base_data) }
- it 'returns branch ref' do
- expect(pull_request.target_branch_name).to eq 'master'
+ it "returns branch ref" do
+ expect(pull_request.target_branch_name).to eq "master"
end
end
- context 'when target branch does not exist' do
+ context "when target branch does not exist" do
let(:raw_data) { double(base_data.merge(base: removed_branch)) }
- it 'prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision' do
- expect(pull_request.target_branch_name).to eq 'gl-2e5d3239/1347/octocat/removed-branch'
+ it "prefixes branch name with gh-:short_sha/:number/:user pattern to avoid collision" do
+ expect(pull_request.target_branch_name).to eq "gl-2e5d3239/1347/octocat/removed-branch"
end
end
end
- context 'when importing a GitHub project' do
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#attributes'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#number'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name'
+ context "when importing a GitHub project" do
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#attributes"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#number"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name"
end
- context 'when importing a Gitea project' do
+ context "when importing a Gitea project" do
before do
- project.update(import_type: 'gitea')
+ project.update(import_type: "gitea")
end
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#attributes'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#number'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name'
- it_behaves_like 'Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name'
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#attributes"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#number"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#source_branch_name"
+ it_behaves_like "Gitlab::LegacyGithubImport::PullRequestFormatter#target_branch_name"
end
- describe '#valid?' do
- context 'when source, and target repos are not a fork' do
+ describe "#valid?" do
+ context "when source, and target repos are not a fork" do
let(:raw_data) { double(base_data) }
- it 'returns true' do
+ it "returns true" do
expect(pull_request.valid?).to eq true
end
end
- context 'when source repo is a fork' do
+ context "when source repo is a fork" do
let(:source_repo) { double(id: 2) }
let(:raw_data) { double(base_data) }
- it 'returns true' do
+ it "returns true" do
expect(pull_request.valid?).to eq true
end
end
- context 'when target repo is a fork' do
+ context "when target repo is a fork" do
let(:target_repo) { double(id: 2) }
let(:raw_data) { double(base_data) }
- it 'returns true' do
+ it "returns true" do
expect(pull_request.valid?).to eq true
end
end
end
- describe '#cross_project?' do
- context 'when source and target repositories are different' do
+ describe "#cross_project?" do
+ context "when source and target repositories are different" do
let(:raw_data) { double(base_data.merge(head: forked_branch)) }
- it 'returns true' do
+ it "returns true" do
expect(pull_request.cross_project?).to eq true
end
end
- context 'when source repository does not exist anymore' do
+ context "when source repository does not exist anymore" do
let(:raw_data) { double(base_data.merge(head: branch_deleted_repo)) }
- it 'returns true' do
+ it "returns true" do
expect(pull_request.cross_project?).to eq true
end
end
- context 'when source and target repositories are the same' do
+ context "when source and target repositories are the same" do
let(:raw_data) { double(base_data.merge(head: source_branch)) }
- it 'returns false' do
+ it "returns false" do
expect(pull_request.cross_project?).to eq false
end
end
end
- describe '#source_branch_exists?' do
+ describe "#source_branch_exists?" do
let(:raw_data) { double(base_data.merge(head: forked_branch)) }
- it 'returns false when is a cross_project' do
+ it "returns false when is a cross_project" do
expect(pull_request.source_branch_exists?).to eq false
end
end
- describe '#url' do
+ describe "#url" do
let(:raw_data) { double(base_data) }
- it 'return raw url' do
- expect(pull_request.url).to eq 'https://api.github.com/repos/octocat/Hello-World/pulls/1347'
+ it "return raw url" do
+ expect(pull_request.url).to eq "https://api.github.com/repos/octocat/Hello-World/pulls/1347"
end
end
- describe '#opened?' do
- let(:raw_data) { double(base_data.merge(state: 'open')) }
+ describe "#opened?" do
+ let(:raw_data) { double(base_data.merge(state: "open")) }
it 'returns true when state is "open"' do
expect(pull_request.opened?).to be_truthy
diff --git a/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb
index 082e3b36dd0..c52e99ba3c3 100644
--- a/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/release_formatter_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::ReleaseFormatter do
- let!(:project) { create(:project, namespace: create(:namespace, path: 'octocat')) }
- let(:octocat) { double(id: 123456, login: 'octocat') }
- let(:created_at) { DateTime.strptime('2011-01-26T19:01:12Z') }
+ let!(:project) { create(:project, namespace: create(:namespace, path: "octocat")) }
+ let(:octocat) { double(id: 123456, login: "octocat") }
+ let(:created_at) { DateTime.strptime("2011-01-26T19:01:12Z") }
let(:base_data) do
{
- tag_name: 'v1.0.0',
- name: 'First release',
+ tag_name: "v1.0.0",
+ name: "First release",
draft: false,
created_at: created_at,
published_at: created_at,
- body: 'Release v1.0.0'
+ body: "Release v1.0.0",
}
end
subject(:release) { described_class.new(project, raw_data) }
- describe '#attributes' do
+ describe "#attributes" do
let(:raw_data) { double(base_data) }
- it 'returns formatted attributes' do
+ it "returns formatted attributes" do
expected = {
project: project,
- tag: 'v1.0.0',
- description: 'Release v1.0.0',
+ tag: "v1.0.0",
+ description: "Release v1.0.0",
created_at: created_at,
- updated_at: created_at
+ updated_at: created_at,
}
expect(release.attributes).to eq(expected)
end
end
- describe '#valid' do
- context 'when release is not a draft' do
+ describe "#valid" do
+ context "when release is not a draft" do
let(:raw_data) { double(base_data) }
- it 'returns true' do
+ it "returns true" do
expect(release.valid?).to eq true
end
end
- context 'when release is draft' do
+ context "when release is draft" do
let(:raw_data) { double(base_data.merge(draft: true)) }
- it 'returns false' do
+ it "returns false" do
expect(release.valid?).to eq false
end
end
diff --git a/spec/lib/gitlab/legacy_github_import/user_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/user_formatter_spec.rb
index 3cd096eb0ad..6f7ec230430 100644
--- a/spec/lib/gitlab/legacy_github_import/user_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/user_formatter_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::UserFormatter do
let(:client) { double }
- let(:octocat) { double(id: 123456, login: 'octocat', email: 'octocat@example.com') }
+ let(:octocat) { double(id: 123456, login: "octocat", email: "octocat@example.com") }
subject(:user) { described_class.new(client, octocat) }
@@ -10,29 +10,29 @@ describe Gitlab::LegacyGithubImport::UserFormatter do
allow(client).to receive(:user).and_return(octocat)
end
- describe '#gitlab_id' do
- context 'when GitHub user is a GitLab user' do
- it 'return GitLab user id when user associated their account with GitHub' do
- gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: 'github')
+ describe "#gitlab_id" do
+ context "when GitHub user is a GitLab user" do
+ it "return GitLab user id when user associated their account with GitHub" do
+ gl_user = create(:omniauth_user, extern_uid: octocat.id, provider: "github")
expect(user.gitlab_id).to eq gl_user.id
end
- it 'returns GitLab user id when user primary email matches GitHub email' do
+ it "returns GitLab user id when user primary email matches GitHub email" do
gl_user = create(:user, email: octocat.email)
expect(user.gitlab_id).to eq gl_user.id
end
- it 'returns GitLab user id when any of user linked emails matches GitHub email' do
- gl_user = create(:user, email: 'johndoe@example.com')
+ it "returns GitLab user id when any of user linked emails matches GitHub email" do
+ gl_user = create(:user, email: "johndoe@example.com")
create(:email, user: gl_user, email: octocat.email)
expect(user.gitlab_id).to eq gl_user.id
end
end
- it 'returns nil when GitHub user is not a GitLab user' do
+ it "returns nil when GitHub user is not a GitLab user" do
expect(user.gitlab_id).to be_nil
end
end
diff --git a/spec/lib/gitlab/legacy_github_import/wiki_formatter_spec.rb b/spec/lib/gitlab/legacy_github_import/wiki_formatter_spec.rb
index 7519707293c..c4d9c37221c 100644
--- a/spec/lib/gitlab/legacy_github_import/wiki_formatter_spec.rb
+++ b/spec/lib/gitlab/legacy_github_import/wiki_formatter_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LegacyGithubImport::WikiFormatter do
let(:project) do
create(:project,
- namespace: create(:namespace, path: 'gitlabhq'),
- import_url: 'https://xxx@github.com/gitlabhq/sample.gitlabhq.git')
+ namespace: create(:namespace, path: "gitlabhq"),
+ import_url: "https://xxx@github.com/gitlabhq/sample.gitlabhq.git")
end
subject(:wiki) { described_class.new(project) }
- describe '#disk_path' do
- it 'appends .wiki to disk path' do
+ describe "#disk_path" do
+ it "appends .wiki to disk path" do
expect(wiki.disk_path).to eq project.wiki.disk_path
end
end
- describe '#full_path' do
- it 'appends .wiki to project path' do
+ describe "#full_path" do
+ it "appends .wiki to project path" do
expect(wiki.full_path).to eq project.wiki.full_path
end
end
- describe '#import_url' do
- it 'returns URL of the wiki repository' do
- expect(wiki.import_url).to eq 'https://xxx@github.com/gitlabhq/sample.gitlabhq.wiki.git'
+ describe "#import_url" do
+ it "returns URL of the wiki repository" do
+ expect(wiki.import_url).to eq "https://xxx@github.com/gitlabhq/sample.gitlabhq.wiki.git"
end
end
end
diff --git a/spec/lib/gitlab/lfs_token_spec.rb b/spec/lib/gitlab/lfs_token_spec.rb
index 8961ecc4be0..9bad636026f 100644
--- a/spec/lib/gitlab/lfs_token_spec.rb
+++ b/spec/lib/gitlab/lfs_token_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
- describe '#token' do
- shared_examples 'a valid LFS token' do
- it 'returns a computed token' do
+ describe "#token" do
+ shared_examples "a valid LFS token" do
+ it "returns a computed token" do
token = lfs_token.token
expect(token).not_to be_nil
@@ -14,38 +14,38 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
end
end
- context 'when the actor is a user' do
- let(:actor) { create(:user, username: 'test_user_lfs_1') }
+ context "when the actor is a user" do
+ let(:actor) { create(:user, username: "test_user_lfs_1") }
let(:lfs_token) { described_class.new(actor) }
- it_behaves_like 'a valid LFS token'
+ it_behaves_like "a valid LFS token"
- it 'returns the correct username' do
+ it "returns the correct username" do
expect(lfs_token.actor_name).to eq(actor.username)
end
- it 'returns the correct token type' do
+ it "returns the correct token type" do
expect(lfs_token.type).to eq(:lfs_token)
end
end
- context 'when the actor is a key' do
- let(:user) { create(:user, username: 'test_user_lfs_2') }
+ context "when the actor is a key" do
+ let(:user) { create(:user, username: "test_user_lfs_2") }
let(:actor) { create(:key, user: user) }
let(:lfs_token) { described_class.new(actor) }
- it_behaves_like 'a valid LFS token'
+ it_behaves_like "a valid LFS token"
- it 'returns the correct username' do
+ it "returns the correct username" do
expect(lfs_token.actor_name).to eq(user.username)
end
- it 'returns the correct token type' do
+ it "returns the correct token type" do
expect(lfs_token.type).to eq(:lfs_token)
end
end
- context 'when the actor is a deploy key' do
+ context "when the actor is a deploy key" do
let(:actor_id) { 1 }
let(:actor) { create(:deploy_key) }
let(:project) { create(:project) }
@@ -55,58 +55,58 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
allow(actor).to receive(:id).and_return(actor_id)
end
- it_behaves_like 'a valid LFS token'
+ it_behaves_like "a valid LFS token"
- it 'returns the correct username' do
+ it "returns the correct username" do
expect(lfs_token.actor_name).to eq("lfs+deploy-key-#{actor_id}")
end
- it 'returns the correct token type' do
+ it "returns the correct token type" do
expect(lfs_token.type).to eq(:lfs_deploy_token)
end
end
- context 'when the actor is invalid' do
- it 'raises an exception' do
- expect { described_class.new('invalid') }.to raise_error('Bad Actor')
+ context "when the actor is invalid" do
+ it "raises an exception" do
+ expect { described_class.new("invalid") }.to raise_error("Bad Actor")
end
end
end
- describe '#token_valid?' do
- let(:actor) { create(:user, username: 'test_user_lfs_1') }
+ describe "#token_valid?" do
+ let(:actor) { create(:user, username: "test_user_lfs_1") }
let(:lfs_token) { described_class.new(actor) }
- context 'for an HMAC token' do
+ context "for an HMAC token" do
before do
# We're not interested in testing LegacyRedisDeviseToken here
allow(Gitlab::LfsToken::LegacyRedisDeviseToken).to receive_message_chain(:new, :token_valid?).and_return(false)
end
- context 'where the token is invalid' do
+ context "where the token is invalid" do
context "because it's junk" do
- it 'returns false' do
- expect(lfs_token.token_valid?('junk')).to be_falsey
+ it "returns false" do
+ expect(lfs_token.token_valid?("junk")).to be_falsey
end
end
context "because it's been fiddled with" do
- it 'returns false' do
- fiddled_token = lfs_token.token.tap { |token| token[0] = 'E' }
+ it "returns false" do
+ fiddled_token = lfs_token.token.tap { |token| token[0] = "E" }
expect(lfs_token.token_valid?(fiddled_token)).to be_falsey
end
end
context "because it was generated with a different secret" do
- it 'returns false' do
- different_actor = create(:user, username: 'test_user_lfs_2')
+ it "returns false" do
+ different_actor = create(:user, username: "test_user_lfs_2")
different_secret_token = described_class.new(different_actor).token
expect(lfs_token.token_valid?(different_secret_token)).to be_falsey
end
end
context "because it's expired" do
- it 'returns false' do
+ it "returns false" do
expired_token = lfs_token.token
# Needs to be at least 1860 seconds, because the default expiry is
# 1800 seconds with an additional 60 second leeway.
@@ -117,44 +117,44 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
end
end
- context 'where the token is valid' do
- it 'returns true' do
+ context "where the token is valid" do
+ it "returns true" do
expect(lfs_token.token_valid?(lfs_token.token)).to be_truthy
end
end
end
- context 'for a LegacyRedisDevise token' do
+ context "for a LegacyRedisDevise token" do
before do
# We're not interested in testing HMACToken here
allow_any_instance_of(Gitlab::LfsToken::HMACToken).to receive(:token_valid?).and_return(false)
end
- context 'where the token is invalid' do
+ context "where the token is invalid" do
context "because it's junk" do
- it 'returns false' do
- expect(lfs_token.token_valid?('junk')).to be_falsey
+ it "returns false" do
+ expect(lfs_token.token_valid?("junk")).to be_falsey
end
end
context "because it's been fiddled with" do
- it 'returns false' do
+ it "returns false" do
generated_token = Gitlab::LfsToken::LegacyRedisDeviseToken.new(actor).store_new_token
- fiddled_token = generated_token.tap { |token| token[0] = 'E' }
+ fiddled_token = generated_token.tap { |token| token[0] = "E" }
expect(lfs_token.token_valid?(fiddled_token)).to be_falsey
end
end
context "because it was generated with a different secret" do
- it 'returns false' do
- different_actor = create(:user, username: 'test_user_lfs_2')
+ it "returns false" do
+ different_actor = create(:user, username: "test_user_lfs_2")
different_secret_token = described_class.new(different_actor).token
expect(lfs_token.token_valid?(different_secret_token)).to be_falsey
end
end
context "because it's expired" do
- it 'returns false' do
+ it "returns false" do
generated_token = Gitlab::LfsToken::LegacyRedisDeviseToken.new(actor).store_new_token(1)
# We need a real sleep here because we need to wait for redis to expire the key.
sleep(0.01)
@@ -163,8 +163,8 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
end
end
- context 'where the token is valid' do
- it 'returns true' do
+ context "where the token is valid" do
+ it "returns true" do
generated_token = Gitlab::LfsToken::LegacyRedisDeviseToken.new(actor).store_new_token
expect(lfs_token.token_valid?(generated_token)).to be_truthy
end
@@ -172,66 +172,66 @@ describe Gitlab::LfsToken, :clean_gitlab_redis_shared_state do
end
end
- describe '#deploy_key_pushable?' do
+ describe "#deploy_key_pushable?" do
let(:lfs_token) { described_class.new(actor) }
- context 'when actor is not a DeployKey' do
+ context "when actor is not a DeployKey" do
let(:actor) { create(:user) }
let(:project) { create(:project) }
- it 'returns false' do
+ it "returns false" do
expect(lfs_token.deploy_key_pushable?(project)).to be_falsey
end
end
- context 'when actor is a DeployKey' do
+ context "when actor is a DeployKey" do
let(:deploy_keys_project) { create(:deploy_keys_project, can_push: can_push) }
let(:project) { deploy_keys_project.project }
let(:actor) { deploy_keys_project.deploy_key }
- context 'but the DeployKey cannot push to the project' do
+ context "but the DeployKey cannot push to the project" do
let(:can_push) { false }
- it 'returns false' do
+ it "returns false" do
expect(lfs_token.deploy_key_pushable?(project)).to be_falsey
end
end
- context 'and the DeployKey can push to the project' do
+ context "and the DeployKey can push to the project" do
let(:can_push) { true }
- it 'returns true' do
+ it "returns true" do
expect(lfs_token.deploy_key_pushable?(project)).to be_truthy
end
end
end
end
- describe '#type' do
+ describe "#type" do
let(:lfs_token) { described_class.new(actor) }
- context 'when actor is not a User' do
+ context "when actor is not a User" do
let(:actor) { create(:deploy_key) }
- it 'returns false' do
+ it "returns false" do
expect(lfs_token.type).to eq(:lfs_deploy_token)
end
end
- context 'when actor is a User' do
+ context "when actor is a User" do
let(:actor) { create(:user) }
- it 'returns false' do
+ it "returns false" do
expect(lfs_token.type).to eq(:lfs_token)
end
end
end
- describe '#authentication_payload' do
- it 'returns a Hash designed for gitlab-shell' do
+ describe "#authentication_payload" do
+ it "returns a Hash designed for gitlab-shell" do
actor = create(:user)
lfs_token = described_class.new(actor)
- repo_http_path = 'http://localhost/user/repo.git'
+ repo_http_path = "http://localhost/user/repo.git"
authentication_payload = lfs_token.authentication_payload(repo_http_path)
expect(authentication_payload[:username]).to eq(actor.username)
diff --git a/spec/lib/gitlab/loop_helpers_spec.rb b/spec/lib/gitlab/loop_helpers_spec.rb
index e17a0342d64..1fff96edb9c 100644
--- a/spec/lib/gitlab/loop_helpers_spec.rb
+++ b/spec/lib/gitlab/loop_helpers_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::LoopHelpers do
let(:class_instance) { (Class.new { include ::Gitlab::LoopHelpers }).new }
- describe '#loop_until' do
+ describe "#loop_until" do
subject do
class_instance.loop_until(**params) { true }
end
- context 'when limit is not given' do
- let(:params) { { limit: nil } }
+ context "when limit is not given" do
+ let(:params) { {limit: nil} }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(ArgumentError)
end
end
- context 'when timeout is specified' do
- let(:params) { { timeout: 1.second } }
+ context "when timeout is specified" do
+ let(:params) { {timeout: 1.second} }
it "returns false after it's expired" do
is_expected.to be_falsy
end
- it 'executes the block at least once' do
+ it "executes the block at least once" do
expect { |b| class_instance.loop_until(**params, &b) }
.to yield_control.at_least(1)
end
end
- context 'when iteration limit is specified' do
- let(:params) { { limit: 1 } }
+ context "when iteration limit is specified" do
+ let(:params) { {limit: 1} }
it "returns false after it's expired" do
is_expected.to be_falsy
end
- it 'executes the block once' do
+ it "executes the block once" do
expect { |b| class_instance.loop_until(**params, &b) }
.to yield_control.once
end
diff --git a/spec/lib/gitlab/manifest_import/manifest_spec.rb b/spec/lib/gitlab/manifest_import/manifest_spec.rb
index ab305fb2316..33eca8157e1 100644
--- a/spec/lib/gitlab/manifest_import/manifest_spec.rb
+++ b/spec/lib/gitlab/manifest_import/manifest_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ManifestImport::Manifest, :postgresql do
- let(:file) { File.open(Rails.root.join('spec/fixtures/aosp_manifest.xml')) }
+ let(:file) { File.open(Rails.root.join("spec/fixtures/aosp_manifest.xml")) }
let(:manifest) { described_class.new(file) }
- describe '#valid?' do
- context 'valid file' do
+ describe "#valid?" do
+ context "valid file" do
it { expect(manifest.valid?).to be true }
end
- context 'missing or invalid attributes' do
- let(:file) { Tempfile.new('foo') }
+ context "missing or invalid attributes" do
+ let(:file) { Tempfile.new("foo") }
before do
content = <<~EOS
@@ -26,21 +26,21 @@ describe Gitlab::ManifestImport::Manifest, :postgresql do
it { expect(manifest.valid?).to be false }
- describe 'errors' do
+ describe "errors" do
before do
manifest.valid?
end
- it { expect(manifest.errors).to include('Make sure a <remote> tag is present and is valid.') }
- it { expect(manifest.errors).to include('Make sure every <project> tag has name and path attributes.') }
+ it { expect(manifest.errors).to include("Make sure a <remote> tag is present and is valid.") }
+ it { expect(manifest.errors).to include("Make sure every <project> tag has name and path attributes.") }
end
end
end
- describe '#projects' do
+ describe "#projects" do
it { expect(manifest.projects.size).to eq(660) }
- it { expect(manifest.projects[0][:name]).to eq('platform/build') }
- it { expect(manifest.projects[0][:path]).to eq('build/make') }
- it { expect(manifest.projects[0][:url]).to eq('https://android-review.googlesource.com/platform/build') }
+ it { expect(manifest.projects[0][:name]).to eq("platform/build") }
+ it { expect(manifest.projects[0][:path]).to eq("build/make") }
+ it { expect(manifest.projects[0][:url]).to eq("https://android-review.googlesource.com/platform/build") }
end
end
diff --git a/spec/lib/gitlab/manifest_import/project_creator_spec.rb b/spec/lib/gitlab/manifest_import/project_creator_spec.rb
index 1d01d437535..f5e94e19684 100644
--- a/spec/lib/gitlab/manifest_import/project_creator_spec.rb
+++ b/spec/lib/gitlab/manifest_import/project_creator_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ManifestImport::ProjectCreator, :postgresql do
let(:group) { create(:group) }
let(:user) { create(:user) }
let(:repository) do
{
- path: 'device/common',
- url: 'https://android-review.googlesource.com/device/common'
+ path: "device/common",
+ url: "https://android-review.googlesource.com/device/common",
}
end
@@ -16,18 +16,18 @@ describe Gitlab::ManifestImport::ProjectCreator, :postgresql do
subject { described_class.new(repository, group, user) }
- describe '#execute' do
+ describe "#execute" do
it { expect(subject.execute).to be_a(Project) }
it { expect { subject.execute }.to change { Project.count }.by(1) }
it { expect { subject.execute }.to change { Group.count }.by(1) }
- it 'creates project with valid full path and import url' do
+ it "creates project with valid full path and import url" do
subject.execute
project = Project.last
- expect(project.full_path).to eq(File.join(group.path, 'device/common'))
- expect(project.import_url).to eq('https://android-review.googlesource.com/device/common')
+ expect(project.full_path).to eq(File.join(group.path, "device/common"))
+ expect(project.import_url).to eq("https://android-review.googlesource.com/device/common")
end
end
end
diff --git a/spec/lib/gitlab/markup_helper_spec.rb b/spec/lib/gitlab/markup_helper_spec.rb
index 09e518ff989..499cd44e3a2 100644
--- a/spec/lib/gitlab/markup_helper_spec.rb
+++ b/spec/lib/gitlab/markup_helper_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::MarkupHelper do
- describe '#markup?' do
- %w(textile rdoc org creole wiki
- mediawiki rst adoc ad asciidoc mdown md markdown).each do |type|
+ describe "#markup?" do
+ %w[textile rdoc org creole wiki
+ mediawiki rst adoc ad asciidoc mdown md markdown].each do |type|
it "returns true for #{type} files" do
expect(described_class.markup?("README.#{type}")).to be_truthy
end
end
- it 'returns false when given a non-markup filename' do
- expect(described_class.markup?('README.rb')).not_to be_truthy
+ it "returns false when given a non-markup filename" do
+ expect(described_class.markup?("README.rb")).not_to be_truthy
end
end
- describe '#gitlab_markdown?' do
- %w(mdown mkd mkdn md markdown).each do |type|
+ describe "#gitlab_markdown?" do
+ %w[mdown mkd mkdn md markdown].each do |type|
it "returns true for #{type} files" do
expect(described_class.gitlab_markdown?("README.#{type}")).to be_truthy
end
end
- it 'returns false when given a non-markdown filename' do
- expect(described_class.gitlab_markdown?('README.rb')).not_to be_truthy
+ it "returns false when given a non-markdown filename" do
+ expect(described_class.gitlab_markdown?("README.rb")).not_to be_truthy
end
end
- describe '#asciidoc?' do
- %w(adoc ad asciidoc ADOC).each do |type|
+ describe "#asciidoc?" do
+ %w[adoc ad asciidoc ADOC].each do |type|
it "returns true for #{type} files" do
expect(described_class.asciidoc?("README.#{type}")).to be_truthy
end
end
- it 'returns false when given a non-asciidoc filename' do
- expect(described_class.asciidoc?('README.rb')).not_to be_truthy
+ it "returns false when given a non-asciidoc filename" do
+ expect(described_class.asciidoc?("README.rb")).not_to be_truthy
end
end
end
diff --git a/spec/lib/gitlab/metrics/background_transaction_spec.rb b/spec/lib/gitlab/metrics/background_transaction_spec.rb
index 17445fe6de5..c0f39f6bba9 100644
--- a/spec/lib/gitlab/metrics/background_transaction_spec.rb
+++ b/spec/lib/gitlab/metrics/background_transaction_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::BackgroundTransaction do
- let(:test_worker_class) { double(:class, name: 'TestWorker') }
+ let(:test_worker_class) { double(:class, name: "TestWorker") }
subject { described_class.new(test_worker_class) }
- describe '#action' do
- it 'returns transaction action name' do
- expect(subject.action).to eq('TestWorker#perform')
+ describe "#action" do
+ it "returns transaction action name" do
+ expect(subject.action).to eq("TestWorker#perform")
end
end
- describe '#label' do
- it 'returns labels based on class name' do
- expect(subject.labels).to eq(controller: 'TestWorker', action: 'perform')
+ describe "#label" do
+ it "returns labels based on class name" do
+ expect(subject.labels).to eq(controller: "TestWorker", action: "perform")
end
end
end
diff --git a/spec/lib/gitlab/metrics/delta_spec.rb b/spec/lib/gitlab/metrics/delta_spec.rb
index 718387cdee1..688eb889ac5 100644
--- a/spec/lib/gitlab/metrics/delta_spec.rb
+++ b/spec/lib/gitlab/metrics/delta_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Delta do
let(:delta) { described_class.new }
- describe '#compared_with' do
- it 'returns the delta as a Numeric' do
+ describe "#compared_with" do
+ it "returns the delta as a Numeric" do
expect(delta.compared_with(5)).to eq(5)
end
- it 'bases the delta on a previously used value' do
+ it "bases the delta on a previously used value" do
expect(delta.compared_with(5)).to eq(5)
expect(delta.compared_with(15)).to eq(10)
end
diff --git a/spec/lib/gitlab/metrics/instrumentation_spec.rb b/spec/lib/gitlab/metrics/instrumentation_spec.rb
index 977bc250049..5c6d46b448e 100644
--- a/spec/lib/gitlab/metrics/instrumentation_spec.rb
+++ b/spec/lib/gitlab/metrics/instrumentation_spec.rb
@@ -1,84 +1,84 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Instrumentation do
let(:env) { {} }
let(:transaction) { Gitlab::Metrics::WebTransaction.new(env) }
before do
- @dummy = Class.new do
- def self.foo(text = 'foo')
+ @dummy = Class.new {
+ def self.foo(text = "foo")
text
end
class << self
- def buzz(text = 'buzz')
+ def buzz(text = "buzz")
text
end
private :buzz
- def flaky(text = 'flaky')
+ def flaky(text = "flaky")
text
end
protected :flaky
end
- def bar(text = 'bar')
+ def bar(text = "bar")
text
end
- def wadus(text = 'wadus')
+ def wadus(text = "wadus")
text
end
private :wadus
- def chaf(text = 'chaf')
+ def chaf(text = "chaf")
text
end
protected :chaf
- end
+ }
- allow(@dummy).to receive(:name).and_return('Dummy')
+ allow(@dummy).to receive(:name).and_return("Dummy")
end
- describe '.series' do
- it 'returns a String' do
+ describe ".series" do
+ it "returns a String" do
expect(described_class.series).to be_an_instance_of(String)
end
end
- describe '.configure' do
- it 'yields self' do
+ describe ".configure" do
+ it "yields self" do
described_class.configure do |c|
expect(c).to eq(described_class)
end
end
end
- describe '.instrument_method' do
- describe 'with metrics enabled' do
+ describe ".instrument_method" do
+ describe "with metrics enabled" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
described_class.instrument_method(@dummy, :foo)
end
- it 'instruments the Class' do
+ it "instruments the Class" do
target = @dummy.singleton_class
expect(described_class.instrumented?(target)).to eq(true)
end
- it 'defines a proxy method' do
+ it "defines a proxy method" do
mod = described_class.proxy_module(@dummy.singleton_class)
expect(mod.method_defined?(:foo)).to eq(true)
end
- it 'calls the instrumented method with the correct arguments' do
- expect(@dummy.foo).to eq('foo')
+ it "calls the instrumented method with the correct arguments" do
+ expect(@dummy.foo).to eq("foo")
end
- it 'tracks the call duration upon calling the method' do
+ it "tracks the call duration upon calling the method" do
allow(Gitlab::Metrics).to receive(:method_call_threshold)
.and_return(0)
@@ -90,7 +90,7 @@ describe Gitlab::Metrics::Instrumentation do
@dummy.foo
end
- it 'does not track method calls below a given duration threshold' do
+ it "does not track method calls below a given duration threshold" do
allow(Gitlab::Metrics).to receive(:method_call_threshold)
.and_return(100)
@@ -99,31 +99,32 @@ describe Gitlab::Metrics::Instrumentation do
@dummy.foo
end
- it 'generates a method with the correct arity when using methods without arguments' do
- dummy = Class.new do
- def self.test; end
- end
+ it "generates a method with the correct arity when using methods without arguments" do
+ dummy = Class.new {
+ def self.test
+ end
+ }
described_class.instrument_method(dummy, :test)
expect(dummy.method(:test).arity).to eq(0)
end
- describe 'when a module is instrumented multiple times' do
- it 'calls the instrumented method with the correct arguments' do
+ describe "when a module is instrumented multiple times" do
+ it "calls the instrumented method with the correct arguments" do
described_class.instrument_method(@dummy, :foo)
- expect(@dummy.foo).to eq('foo')
+ expect(@dummy.foo).to eq("foo")
end
end
end
- describe 'with metrics disabled' do
+ describe "with metrics disabled" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(false)
end
- it 'does not instrument the method' do
+ it "does not instrument the method" do
described_class.instrument_method(@dummy, :foo)
target = @dummy.singleton_class
@@ -133,8 +134,8 @@ describe Gitlab::Metrics::Instrumentation do
end
end
- describe '.instrument_instance_method' do
- describe 'with metrics enabled' do
+ describe ".instrument_instance_method" do
+ describe "with metrics enabled" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
@@ -142,21 +143,21 @@ describe Gitlab::Metrics::Instrumentation do
.instrument_instance_method(@dummy, :bar)
end
- it 'instruments instances of the Class' do
+ it "instruments instances of the Class" do
expect(described_class.instrumented?(@dummy)).to eq(true)
end
- it 'defines a proxy method' do
+ it "defines a proxy method" do
mod = described_class.proxy_module(@dummy)
expect(mod.method_defined?(:bar)).to eq(true)
end
- it 'calls the instrumented method with the correct arguments' do
- expect(@dummy.new.bar).to eq('bar')
+ it "calls the instrumented method with the correct arguments" do
+ expect(@dummy.new.bar).to eq("bar")
end
- it 'tracks the call duration upon calling the method' do
+ it "tracks the call duration upon calling the method" do
allow(Gitlab::Metrics).to receive(:method_call_threshold)
.and_return(0)
@@ -168,7 +169,7 @@ describe Gitlab::Metrics::Instrumentation do
@dummy.new.bar
end
- it 'does not track method calls below a given duration threshold' do
+ it "does not track method calls below a given duration threshold" do
allow(Gitlab::Metrics).to receive(:method_call_threshold)
.and_return(100)
@@ -178,12 +179,12 @@ describe Gitlab::Metrics::Instrumentation do
end
end
- describe 'with metrics disabled' do
+ describe "with metrics disabled" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(false)
end
- it 'does not instrument the method' do
+ it "does not instrument the method" do
described_class
.instrument_instance_method(@dummy, :bar)
@@ -192,24 +193,28 @@ describe Gitlab::Metrics::Instrumentation do
end
end
- describe '.instrument_class_hierarchy' do
+ describe ".instrument_class_hierarchy" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
- @child1 = Class.new(@dummy) do
- def self.child1_foo; end
+ @child1 = Class.new(@dummy) {
+ def self.child1_foo
+ end
- def child1_bar; end
- end
+ def child1_bar
+ end
+ }
- @child2 = Class.new(@child1) do
- def self.child2_foo; end
+ @child2 = Class.new(@child1) {
+ def self.child2_foo
+ end
- def child2_bar; end
- end
+ def child2_bar
+ end
+ }
end
- it 'recursively instruments a class hierarchy' do
+ it "recursively instruments a class hierarchy" do
described_class.instrument_class_hierarchy(@dummy)
expect(described_class.instrumented?(@child1.singleton_class)).to eq(true)
@@ -219,44 +224,44 @@ describe Gitlab::Metrics::Instrumentation do
expect(described_class.instrumented?(@child2)).to eq(true)
end
- it 'does not instrument the root module' do
+ it "does not instrument the root module" do
described_class.instrument_class_hierarchy(@dummy)
expect(described_class.instrumented?(@dummy)).to eq(false)
end
end
- describe '.instrument_methods' do
+ describe ".instrument_methods" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
end
- it 'instruments all public class methods' do
+ it "instruments all public class methods" do
described_class.instrument_methods(@dummy)
expect(described_class.instrumented?(@dummy.singleton_class)).to eq(true)
expect(@dummy.method(:foo).source_location.first).to match(/instrumentation\.rb/)
end
- it 'instruments all protected class methods' do
+ it "instruments all protected class methods" do
described_class.instrument_methods(@dummy)
expect(described_class.instrumented?(@dummy.singleton_class)).to eq(true)
expect(@dummy.method(:flaky).source_location.first).to match(/instrumentation\.rb/)
end
- it 'instruments all private instance methods' do
+ it "instruments all private instance methods" do
described_class.instrument_methods(@dummy)
expect(described_class.instrumented?(@dummy.singleton_class)).to eq(true)
expect(@dummy.method(:buzz).source_location.first).to match(/instrumentation\.rb/)
end
- it 'only instruments methods directly defined in the module' do
- mod = Module.new do
+ it "only instruments methods directly defined in the module" do
+ mod = Module.new {
def kittens
end
- end
+ }
@dummy.extend(mod)
@@ -265,7 +270,7 @@ describe Gitlab::Metrics::Instrumentation do
expect(@dummy).not_to respond_to(:_original_kittens)
end
- it 'can take a block to determine if a method should be instrumented' do
+ it "can take a block to determine if a method should be instrumented" do
described_class.instrument_methods(@dummy) do
false
end
@@ -274,37 +279,37 @@ describe Gitlab::Metrics::Instrumentation do
end
end
- describe '.instrument_instance_methods' do
+ describe ".instrument_instance_methods" do
before do
allow(Gitlab::Metrics).to receive(:enabled?).and_return(true)
end
- it 'instruments all public instance methods' do
+ it "instruments all public instance methods" do
described_class.instrument_instance_methods(@dummy)
expect(described_class.instrumented?(@dummy)).to eq(true)
expect(@dummy.new.method(:bar).source_location.first).to match(/instrumentation\.rb/)
end
- it 'instruments all protected instance methods' do
+ it "instruments all protected instance methods" do
described_class.instrument_instance_methods(@dummy)
expect(described_class.instrumented?(@dummy)).to eq(true)
expect(@dummy.new.method(:chaf).source_location.first).to match(/instrumentation\.rb/)
end
- it 'instruments all private instance methods' do
+ it "instruments all private instance methods" do
described_class.instrument_instance_methods(@dummy)
expect(described_class.instrumented?(@dummy)).to eq(true)
expect(@dummy.new.method(:wadus).source_location.first).to match(/instrumentation\.rb/)
end
- it 'only instruments methods directly defined in the module' do
- mod = Module.new do
+ it "only instruments methods directly defined in the module" do
+ mod = Module.new {
def kittens
end
- end
+ }
@dummy.include(mod)
@@ -313,7 +318,7 @@ describe Gitlab::Metrics::Instrumentation do
expect(@dummy.new.method(:kittens).source_location.first).not_to match(/instrumentation\.rb/)
end
- it 'can take a block to determine if a method should be instrumented' do
+ it "can take a block to determine if a method should be instrumented" do
described_class.instrument_instance_methods(@dummy) do
false
end
diff --git a/spec/lib/gitlab/metrics/method_call_spec.rb b/spec/lib/gitlab/metrics/method_call_spec.rb
index d9379cfe674..1f6590f6bd9 100644
--- a/spec/lib/gitlab/metrics/method_call_spec.rb
+++ b/spec/lib/gitlab/metrics/method_call_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::MethodCall do
let(:transaction) { double(:transaction, labels: {}) }
- let(:method_call) { described_class.new('Foo#bar', :Foo, '#bar', transaction) }
+ let(:method_call) { described_class.new("Foo#bar", :Foo, "#bar", transaction) }
- describe '#measure' do
+ describe "#measure" do
after do
described_class.reload_metric!(:gitlab_method_call_duration_seconds)
end
- it 'measures the performance of the supplied block' do
- method_call.measure { 'foo' }
+ it "measures the performance of the supplied block" do
+ method_call.measure { "foo" }
expect(method_call.real_time).to be_a_kind_of(Numeric)
expect(method_call.cpu_time).to be_a_kind_of(Numeric)
expect(method_call.call_count).to eq(1)
end
- context 'when measurement is above threshold' do
+ context "when measurement is above threshold" do
before do
allow(method_call).to receive(:above_threshold?).and_return(true)
end
- context 'prometheus instrumentation is enabled' do
+ context "prometheus instrumentation is enabled" do
before do
Feature.get(:prometheus_metrics_method_instrumentation).enable
end
@@ -33,126 +33,126 @@ describe Gitlab::Metrics::MethodCall do
end
end
- it 'metric is not a NullMetric' do
+ it "metric is not a NullMetric" do
expect(described_class).not_to be_instance_of(Gitlab::Metrics::NullMetric)
end
- it 'observes the performance of the supplied block' do
+ it "observes the performance of the supplied block" do
expect(described_class.gitlab_method_call_duration_seconds)
.to receive(:observe)
- .with({ module: :Foo, method: '#bar' }, be_a_kind_of(Numeric))
+ .with({module: :Foo, method: "#bar"}, be_a_kind_of(Numeric))
- method_call.measure { 'foo' }
+ method_call.measure { "foo" }
end
end
- context 'prometheus instrumentation is disabled' do
+ context "prometheus instrumentation is disabled" do
before do
Feature.get(:prometheus_metrics_method_instrumentation).disable
end
- it 'observes using NullMetric' do
+ it "observes using NullMetric" do
expect(described_class.gitlab_method_call_duration_seconds).to be_instance_of(Gitlab::Metrics::NullMetric)
expect(described_class.gitlab_method_call_duration_seconds).to receive(:observe)
- method_call.measure { 'foo' }
+ method_call.measure { "foo" }
end
end
end
- context 'when measurement is below threshold' do
+ context "when measurement is below threshold" do
before do
allow(method_call).to receive(:above_threshold?).and_return(false)
end
- it 'does not observe the performance' do
+ it "does not observe the performance" do
expect(described_class.gitlab_method_call_duration_seconds)
.not_to receive(:observe)
- method_call.measure { 'foo' }
+ method_call.measure { "foo" }
end
end
end
- describe '#to_metric' do
- it 'returns a Metric instance' do
+ describe "#to_metric" do
+ it "returns a Metric instance" do
expect(method_call).to receive(:real_time).and_return(4.0001).twice
expect(method_call).to receive(:cpu_time).and_return(3.0001)
- method_call.measure { 'foo' }
+ method_call.measure { "foo" }
metric = method_call.to_metric
expect(metric).to be_an_instance_of(Gitlab::Metrics::Metric)
- expect(metric.series).to eq('rails_method_calls')
+ expect(metric.series).to eq("rails_method_calls")
expect(metric.values[:duration]).to eq(4000)
expect(metric.values[:cpu_duration]).to eq(3000)
expect(metric.values[:call_count]).to be_an(Integer)
- expect(metric.tags).to eq({ method: 'Foo#bar' })
+ expect(metric.tags).to eq({method: "Foo#bar"})
end
end
- describe '#above_threshold?' do
+ describe "#above_threshold?" do
before do
allow(Gitlab::Metrics).to receive(:method_call_threshold).and_return(100)
end
- it 'returns false when the total call time is not above the threshold' do
+ it "returns false when the total call time is not above the threshold" do
expect(method_call).to receive(:real_time).and_return(0.009)
expect(method_call.above_threshold?).to eq(false)
end
- it 'returns true when the total call time is above the threshold' do
+ it "returns true when the total call time is above the threshold" do
expect(method_call).to receive(:real_time).and_return(9)
expect(method_call.above_threshold?).to eq(true)
end
end
- describe '#call_count' do
- context 'without any method calls' do
- it 'returns 0' do
+ describe "#call_count" do
+ context "without any method calls" do
+ it "returns 0" do
expect(method_call.call_count).to eq(0)
end
end
- context 'with method calls' do
- it 'returns the number of method calls' do
- method_call.measure { 'foo' }
+ context "with method calls" do
+ it "returns the number of method calls" do
+ method_call.measure { "foo" }
expect(method_call.call_count).to eq(1)
end
end
end
- describe '#cpu_time' do
- context 'without timings' do
- it 'returns 0.0' do
+ describe "#cpu_time" do
+ context "without timings" do
+ it "returns 0.0" do
expect(method_call.cpu_time).to eq(0.0)
end
end
- context 'with timings' do
- it 'returns the total CPU time' do
- method_call.measure { 'foo' }
+ context "with timings" do
+ it "returns the total CPU time" do
+ method_call.measure { "foo" }
expect(method_call.cpu_time >= 0.0).to be(true)
end
end
end
- describe '#real_time' do
- context 'without timings' do
- it 'returns 0.0' do
+ describe "#real_time" do
+ context "without timings" do
+ it "returns 0.0" do
expect(method_call.real_time).to eq(0.0)
end
end
- context 'with timings' do
- it 'returns the total real time' do
- method_call.measure { 'foo' }
+ context "with timings" do
+ it "returns the total real time" do
+ method_call.measure { "foo" }
expect(method_call.real_time >= 0.0).to be(true)
end
diff --git a/spec/lib/gitlab/metrics/methods_spec.rb b/spec/lib/gitlab/metrics/methods_spec.rb
index 9d41ed2442b..919477c5b98 100644
--- a/spec/lib/gitlab/metrics/methods_spec.rb
+++ b/spec/lib/gitlab/metrics/methods_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Methods do
subject { Class.new { include Gitlab::Metrics::Methods } }
- shared_context 'metric' do |metric_type, *args|
- let(:docstring) { 'description' }
+ shared_context "metric" do |metric_type, *args|
+ let(:docstring) { "description" }
let(:metric_name) { :sample_metric }
describe "#define_#{metric_type}" do
@@ -12,7 +12,7 @@ describe Gitlab::Metrics::Methods do
subject.__send__("define_#{metric_type}", metric_name, **args)
end
- context 'metrics access method not defined' do
+ context "metrics access method not defined" do
it "defines metrics accessing method" do
expect(subject).not_to respond_to(metric_name)
@@ -22,29 +22,29 @@ describe Gitlab::Metrics::Methods do
end
end
- context 'metrics access method defined' do
+ context "metrics access method defined" do
before do
call_define_metric_method(docstring: docstring)
end
- it 'raises error when trying to redefine method' do
+ it "raises error when trying to redefine method" do
expect { call_define_metric_method(docstring: docstring) }.to raise_error(ArgumentError)
end
- context 'metric is not cached' do
- it 'calls fetch_metric' do
+ context "metric is not cached" do
+ it "calls fetch_metric" do
expect(subject).to receive(:init_metric).with(metric_type, metric_name, docstring: docstring)
subject.public_send(metric_name)
end
end
- context 'metric is cached' do
+ context "metric is cached" do
before do
subject.public_send(metric_name)
end
- it 'returns cached metric' do
+ it "returns cached metric" do
expect(subject).not_to receive(:init_metric)
subject.public_send(metric_name)
@@ -61,7 +61,7 @@ describe Gitlab::Metrics::Methods do
end
context "when #{metric_type} is not cached" do
- it 'initializes counter metric' do
+ it "initializes counter metric" do
allow(Gitlab::Metrics).to receive(metric_type).and_return(null_metric)
call_fetch_metric_method(docstring: docstring)
@@ -75,13 +75,13 @@ describe Gitlab::Metrics::Methods do
call_fetch_metric_method(docstring: docstring)
end
- it 'uses class metric cache' do
+ it "uses class metric cache" do
expect(Gitlab::Metrics).not_to receive(metric_type)
call_fetch_metric_method(docstring: docstring)
end
- context 'when metric is reloaded' do
+ context "when metric is reloaded" do
before do
subject.reload_metric!(metric_name)
end
@@ -96,11 +96,11 @@ describe Gitlab::Metrics::Methods do
end
end
- context 'when metric is configured with feature' do
+ context "when metric is configured with feature" do
let(:feature_name) { :some_metric_feature }
let(:metric) { call_fetch_metric_method(docstring: docstring, with_feature: feature_name) }
- context 'when feature is enabled' do
+ context "when feature is enabled" do
before do
Feature.get(feature_name).enable
end
@@ -114,7 +114,7 @@ describe Gitlab::Metrics::Methods do
end
end
- context 'when feature is disabled' do
+ context "when feature is disabled" do
before do
Feature.get(feature_name).disable
end
@@ -131,7 +131,7 @@ describe Gitlab::Metrics::Methods do
end
end
- include_examples 'metric', :counter, {}
- include_examples 'metric', :gauge, {}, :all
- include_examples 'metric', :histogram, {}, [0.005, 0.01, 0.1, 1, 10]
+ include_examples "metric", :counter, {}
+ include_examples "metric", :gauge, {}, :all
+ include_examples "metric", :histogram, {}, [0.005, 0.01, 0.1, 1, 10]
end
diff --git a/spec/lib/gitlab/metrics/metric_spec.rb b/spec/lib/gitlab/metrics/metric_spec.rb
index d240b8a01fd..90777260fb1 100644
--- a/spec/lib/gitlab/metrics/metric_spec.rb
+++ b/spec/lib/gitlab/metrics/metric_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Metric do
let(:metric) do
- described_class.new('foo', { number: 10 }, { host: 'localtoast' })
+ described_class.new("foo", {number: 10}, {host: "localtoast"})
end
- describe '#series' do
+ describe "#series" do
subject { metric.series }
- it { is_expected.to eq('foo') }
+ it { is_expected.to eq("foo") }
end
- describe '#values' do
+ describe "#values" do
subject { metric.values }
- it { is_expected.to eq({ number: 10 }) }
+ it { is_expected.to eq({number: 10}) }
end
- describe '#tags' do
+ describe "#tags" do
subject { metric.tags }
- it { is_expected.to eq({ host: 'localtoast' }) }
+ it { is_expected.to eq({host: "localtoast"}) }
end
- describe '#type' do
+ describe "#type" do
subject { metric.type }
it { is_expected.to eq(:metric) }
end
- describe '#event?' do
- it 'returns false for a regular metric' do
+ describe "#event?" do
+ it "returns false for a regular metric" do
expect(metric.event?).to eq(false)
end
- it 'returns true for an event metric' do
+ it "returns true for an event metric" do
expect(metric).to receive(:type).and_return(:event)
expect(metric.event?).to eq(true)
end
end
- describe '#to_hash' do
- it 'returns a Hash' do
+ describe "#to_hash" do
+ it "returns a Hash" do
expect(metric.to_hash).to be_an_instance_of(Hash)
end
- describe 'the returned Hash' do
+ describe "the returned Hash" do
let(:hash) { metric.to_hash }
- it 'includes the series' do
- expect(hash[:series]).to eq('foo')
+ it "includes the series" do
+ expect(hash[:series]).to eq("foo")
end
- it 'includes the tags' do
+ it "includes the tags" do
expect(hash[:tags]).to be_an_instance_of(Hash)
end
- it 'includes the values' do
- expect(hash[:values]).to eq({ number: 10 })
+ it "includes the values" do
+ expect(hash[:values]).to eq({number: 10})
end
- it 'includes the timestamp' do
+ it "includes the timestamp" do
expect(hash[:timestamp]).to be_an(Integer)
end
end
diff --git a/spec/lib/gitlab/metrics/prometheus_spec.rb b/spec/lib/gitlab/metrics/prometheus_spec.rb
index 3d4dd5fdf01..c7378e0ea4d 100644
--- a/spec/lib/gitlab/metrics/prometheus_spec.rb
+++ b/spec/lib/gitlab/metrics/prometheus_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Prometheus, :prometheus do
let(:all_metrics) { Gitlab::Metrics }
let(:registry) { all_metrics.registry }
- describe '#reset_registry!' do
- it 'clears existing metrics' do
- registry.counter(:test, 'test metric')
+ describe "#reset_registry!" do
+ it "clears existing metrics" do
+ registry.counter(:test, "test metric")
expect(registry.metrics.count).to eq(1)
diff --git a/spec/lib/gitlab/metrics/rack_middleware_spec.rb b/spec/lib/gitlab/metrics/rack_middleware_spec.rb
index b84387204ee..93dc86953cf 100644
--- a/spec/lib/gitlab/metrics/rack_middleware_spec.rb
+++ b/spec/lib/gitlab/metrics/rack_middleware_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::RackMiddleware do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
- let(:env) { { 'REQUEST_METHOD' => 'GET', 'REQUEST_URI' => '/foo' } }
+ let(:env) { {"REQUEST_METHOD" => "GET", "REQUEST_URI" => "/foo"} }
- describe '#call' do
+ describe "#call" do
before do
expect_any_instance_of(Gitlab::Metrics::Transaction).to receive(:finish)
end
- it 'tracks a transaction' do
- expect(app).to receive(:call).with(env).and_return('yay')
+ it "tracks a transaction" do
+ expect(app).to receive(:call).with(env).and_return("yay")
- expect(middleware.call(env)).to eq('yay')
+ expect(middleware.call(env)).to eq("yay")
end
- it 'tracks any raised exceptions' do
+ it "tracks any raised exceptions" do
expect(app).to receive(:call).with(env).and_raise(RuntimeError)
expect_any_instance_of(Gitlab::Metrics::Transaction)
@@ -28,31 +28,31 @@ describe Gitlab::Metrics::RackMiddleware do
end
end
- describe '#transaction_from_env' do
+ describe "#transaction_from_env" do
let(:transaction) { middleware.transaction_from_env(env) }
- it 'returns a Transaction' do
+ it "returns a Transaction" do
expect(transaction).to be_an_instance_of(Gitlab::Metrics::WebTransaction)
end
- it 'stores the request method and URI in the transaction as values' do
- expect(transaction.values[:request_method]).to eq('GET')
- expect(transaction.values[:request_uri]).to eq('/foo')
+ it "stores the request method and URI in the transaction as values" do
+ expect(transaction.values[:request_method]).to eq("GET")
+ expect(transaction.values[:request_uri]).to eq("/foo")
end
context "when URI includes sensitive parameters" do
let(:env) do
{
- 'REQUEST_METHOD' => 'GET',
- 'REQUEST_URI' => '/foo?private_token=my-token',
- 'PATH_INFO' => '/foo',
- 'QUERY_STRING' => 'private_token=my_token',
- 'action_dispatch.parameter_filter' => [:private_token]
+ "REQUEST_METHOD" => "GET",
+ "REQUEST_URI" => "/foo?private_token=my-token",
+ "PATH_INFO" => "/foo",
+ "QUERY_STRING" => "private_token=my_token",
+ "action_dispatch.parameter_filter" => [:private_token],
}
end
- it 'stores the request URI with the sensitive parameters filtered' do
- expect(transaction.values[:request_uri]).to eq('/foo?private_token=[FILTERED]')
+ it "stores the request URI with the sensitive parameters filtered" do
+ expect(transaction.values[:request_uri]).to eq("/foo?private_token=[FILTERED]")
end
end
end
diff --git a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
index ebe66948a91..3ebe2aa1251 100644
--- a/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
+++ b/spec/lib/gitlab/metrics/requests_rack_middleware_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::RequestsRackMiddleware do
- let(:app) { double('app') }
+ let(:app) { double("app") }
subject { described_class.new(app) }
- describe '#call' do
+ describe "#call" do
let(:status) { 100 }
- let(:env) { { 'REQUEST_METHOD' => 'GET' } }
- let(:stack_result) { [status, {}, 'body'] }
+ let(:env) { {"REQUEST_METHOD" => "GET"} }
+ let(:stack_result) { [status, {}, "body"] }
before do
allow(app).to receive(:call).and_return(stack_result)
end
- context '@app.call succeeds with 200' do
+ context "@app.call succeeds with 200" do
before do
allow(app).to receive(:call).and_return([200, nil, nil])
end
- it 'increments requests count' do
- expect(described_class).to receive_message_chain(:http_request_total, :increment).with(method: 'get')
+ it "increments requests count" do
+ expect(described_class).to receive_message_chain(:http_request_total, :increment).with(method: "get")
subject.call(env)
end
@@ -28,29 +28,29 @@ describe Gitlab::Metrics::RequestsRackMiddleware do
match { |actual| actual > 0 }
end
- it 'measures execution time' do
- expect(described_class).to receive_message_chain(:http_request_duration_seconds, :observe).with({ status: 200, method: 'get' }, a_positive_execution_time)
+ it "measures execution time" do
+ expect(described_class).to receive_message_chain(:http_request_duration_seconds, :observe).with({status: 200, method: "get"}, a_positive_execution_time)
Timecop.scale(3600) { subject.call(env) }
end
end
- context '@app.call throws exception' do
- let(:http_request_duration_seconds) { double('http_request_duration_seconds') }
+ context "@app.call throws exception" do
+ let(:http_request_duration_seconds) { double("http_request_duration_seconds") }
before do
allow(app).to receive(:call).and_raise(StandardError)
allow(described_class).to receive(:http_request_duration_seconds).and_return(http_request_duration_seconds)
end
- it 'increments exceptions count' do
+ it "increments exceptions count" do
expect(described_class).to receive_message_chain(:rack_uncaught_errors_count, :increment)
expect { subject.call(env) }.to raise_error(StandardError)
end
- it 'increments requests count' do
- expect(described_class).to receive_message_chain(:http_request_total, :increment).with(method: 'get')
+ it "increments requests count" do
+ expect(described_class).to receive_message_chain(:http_request_total, :increment).with(method: "get")
expect { subject.call(env) }.to raise_error(StandardError)
end
diff --git a/spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
index 81954fcf8c5..2ce52ec64cf 100644
--- a/spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
+++ b/spec/lib/gitlab/metrics/samplers/influx_sampler_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Samplers::InfluxSampler do
let(:sampler) { described_class.new(5) }
- describe '#start' do
- it 'runs once and gathers a sample at a given interval' do
+ describe "#start" do
+ it "runs once and gathers a sample at a given interval" do
expect(sampler).to receive(:sleep).with(a_kind_of(Numeric)).twice
expect(sampler).to receive(:sample).once
expect(sampler).to receive(:running).and_return(true, false)
@@ -13,8 +13,8 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#sample' do
- it 'samples various statistics' do
+ describe "#sample" do
+ it "samples various statistics" do
expect(sampler).to receive(:sample_memory_usage)
expect(sampler).to receive(:sample_file_descriptors)
expect(sampler).to receive(:sample_gc)
@@ -23,7 +23,7 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
sampler.sample
end
- it 'clears any GC profiles' do
+ it "clears any GC profiles" do
expect(sampler).to receive(:flush)
expect(GC::Profiler).to receive(:clear)
@@ -31,8 +31,8 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#flush' do
- it 'schedules the metrics using Sidekiq' do
+ describe "#flush" do
+ it "schedules the metrics using Sidekiq" do
expect(Gitlab::Metrics).to receive(:submit_metrics)
.with([an_instance_of(Hash)])
@@ -41,8 +41,8 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#sample_memory_usage' do
- it 'adds a metric containing the memory usage' do
+ describe "#sample_memory_usage" do
+ it "adds a metric containing the memory usage" do
expect(Gitlab::Metrics::System).to receive(:memory_usage)
.and_return(9000)
@@ -54,8 +54,8 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#sample_file_descriptors' do
- it 'adds a metric containing the amount of open file descriptors' do
+ describe "#sample_file_descriptors" do
+ it "adds a metric containing the amount of open file descriptors" do
expect(Gitlab::Metrics::System).to receive(:file_descriptor_count)
.and_return(4)
@@ -67,8 +67,8 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#sample_gc' do
- it 'adds a metric containing garbage collection statistics' do
+ describe "#sample_gc" do
+ it "adds a metric containing garbage collection statistics" do
expect(GC::Profiler).to receive(:total_time).and_return(0.24)
expect(sampler).to receive(:add_metric)
@@ -79,36 +79,36 @@ describe Gitlab::Metrics::Samplers::InfluxSampler do
end
end
- describe '#add_metric' do
- it 'prefixes the series name for a Rails process' do
+ describe "#add_metric" do
+ it "prefixes the series name for a Rails process" do
expect(sampler).to receive(:sidekiq?).and_return(false)
expect(Gitlab::Metrics::Metric).to receive(:new)
- .with('rails_cats', { value: 10 }, {})
+ .with("rails_cats", {value: 10}, {})
.and_call_original
- sampler.add_metric('cats', value: 10)
+ sampler.add_metric("cats", value: 10)
end
- it 'prefixes the series name for a Sidekiq process' do
+ it "prefixes the series name for a Sidekiq process" do
expect(sampler).to receive(:sidekiq?).and_return(true)
expect(Gitlab::Metrics::Metric).to receive(:new)
- .with('sidekiq_cats', { value: 10 }, {})
+ .with("sidekiq_cats", {value: 10}, {})
.and_call_original
- sampler.add_metric('cats', value: 10)
+ sampler.add_metric("cats", value: 10)
end
end
- describe '#sleep_interval' do
- it 'returns a Numeric' do
+ describe "#sleep_interval" do
+ it "returns a Numeric" do
expect(sampler.sleep_interval).to be_a_kind_of(Numeric)
end
# Testing random behaviour is very hard, so treat this test as a basic smoke
# test instead of a very accurate behaviour/unit test.
- it 'does not return the same interval twice in a row' do
+ it "does not return the same interval twice in a row" do
last = nil
100.times do
diff --git a/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
index 7972ff253fe..fb8e106c3e4 100644
--- a/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
+++ b/spec/lib/gitlab/metrics/samplers/ruby_sampler_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Samplers::RubySampler do
let(:sampler) { described_class.new(5) }
- let(:null_metric) { double('null_metric', set: nil, observe: nil) }
+ let(:null_metric) { double("null_metric", set: nil, observe: nil) }
before do
allow(Gitlab::Metrics::NullMetric).to receive(:instance).and_return(null_metric)
end
- describe '#sample' do
- it 'samples various statistics' do
+ describe "#sample" do
+ it "samples various statistics" do
expect(Gitlab::Metrics::System).to receive(:memory_usage)
expect(Gitlab::Metrics::System).to receive(:file_descriptor_count)
expect(sampler).to receive(:sample_gc)
@@ -17,7 +17,7 @@ describe Gitlab::Metrics::Samplers::RubySampler do
sampler.sample
end
- it 'adds a metric containing the memory usage' do
+ it "adds a metric containing the memory usage" do
expect(Gitlab::Metrics::System).to receive(:memory_usage).and_return(9000)
expect(sampler.metrics[:memory_usage]).to receive(:set).with({}, 9000)
@@ -25,24 +25,24 @@ describe Gitlab::Metrics::Samplers::RubySampler do
sampler.sample
end
- it 'adds a metric containing the amount of open file descriptors' do
+ it "adds a metric containing the amount of open file descriptors" do
expect(Gitlab::Metrics::System).to receive(:file_descriptor_count)
- .and_return(4)
+ .and_return(4)
expect(sampler.metrics[:file_descriptors]).to receive(:set).with({}, 4)
sampler.sample
end
- it 'clears any GC profiles' do
+ it "clears any GC profiles" do
expect(GC::Profiler).to receive(:clear)
sampler.sample
end
end
- describe '#sample_gc' do
- it 'adds a metric containing garbage collection time statistics' do
+ describe "#sample_gc" do
+ it "adds a metric containing garbage collection time statistics" do
expect(GC::Profiler).to receive(:total_time).and_return(0.24)
expect(sampler.metrics[:total_time]).to receive(:increment).with({}, 0.24)
@@ -50,7 +50,7 @@ describe Gitlab::Metrics::Samplers::RubySampler do
sampler.sample
end
- it 'adds a metric containing garbage collection statistics' do
+ it "adds a metric containing garbage collection statistics" do
GC.stat.keys.each do |key|
expect(sampler.metrics[key]).to receive(:set).with({}, anything)
end
diff --git a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb
index 4b03f3c2532..f3bc3b9f61a 100644
--- a/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb
+++ b/spec/lib/gitlab/metrics/samplers/unicorn_sampler_spec.rb
@@ -1,78 +1,78 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Samplers::UnicornSampler do
subject { described_class.new(1.second) }
- describe '#sample' do
- let(:unicorn) { double('unicorn') }
- let(:raindrops) { double('raindrops') }
- let(:stats) { double('stats') }
+ describe "#sample" do
+ let(:unicorn) { double("unicorn") }
+ let(:raindrops) { double("raindrops") }
+ let(:stats) { double("stats") }
before do
- stub_const('Unicorn', unicorn)
- stub_const('Raindrops::Linux', raindrops)
+ stub_const("Unicorn", unicorn)
+ stub_const("Raindrops::Linux", raindrops)
allow(raindrops).to receive(:unix_listener_stats).and_return({})
allow(raindrops).to receive(:tcp_listener_stats).and_return({})
end
- context 'unicorn listens on unix sockets' do
- let(:socket_address) { '/some/sock' }
+ context "unicorn listens on unix sockets" do
+ let(:socket_address) { "/some/sock" }
let(:sockets) { [socket_address] }
before do
allow(unicorn).to receive(:listener_names).and_return(sockets)
end
- it 'samples socket data' do
+ it "samples socket data" do
expect(raindrops).to receive(:unix_listener_stats).with(sockets)
subject.sample
end
- context 'stats collected' do
+ context "stats collected" do
before do
- allow(stats).to receive(:active).and_return('active')
- allow(stats).to receive(:queued).and_return('queued')
- allow(raindrops).to receive(:unix_listener_stats).and_return({ socket_address => stats })
+ allow(stats).to receive(:active).and_return("active")
+ allow(stats).to receive(:queued).and_return("queued")
+ allow(raindrops).to receive(:unix_listener_stats).and_return({socket_address => stats})
end
- it 'updates metrics type unix and with addr' do
- labels = { socket_type: 'unix', socket_address: socket_address }
+ it "updates metrics type unix and with addr" do
+ labels = {socket_type: "unix", socket_address: socket_address}
- expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active')
- expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued')
+ expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, "active")
+ expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, "queued")
subject.sample
end
end
end
- context 'unicorn listens on tcp sockets' do
- let(:tcp_socket_address) { '0.0.0.0:8080' }
+ context "unicorn listens on tcp sockets" do
+ let(:tcp_socket_address) { "0.0.0.0:8080" }
let(:tcp_sockets) { [tcp_socket_address] }
before do
allow(unicorn).to receive(:listener_names).and_return(tcp_sockets)
end
- it 'samples socket data' do
+ it "samples socket data" do
expect(raindrops).to receive(:tcp_listener_stats).with(tcp_sockets)
subject.sample
end
- context 'stats collected' do
+ context "stats collected" do
before do
- allow(stats).to receive(:active).and_return('active')
- allow(stats).to receive(:queued).and_return('queued')
- allow(raindrops).to receive(:tcp_listener_stats).and_return({ tcp_socket_address => stats })
+ allow(stats).to receive(:active).and_return("active")
+ allow(stats).to receive(:queued).and_return("queued")
+ allow(raindrops).to receive(:tcp_listener_stats).and_return({tcp_socket_address => stats})
end
- it 'updates metrics type unix and with addr' do
- labels = { socket_type: 'tcp', socket_address: tcp_socket_address }
+ it "updates metrics type unix and with addr" do
+ labels = {socket_type: "tcp", socket_address: tcp_socket_address}
- expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active')
- expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued')
+ expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, "active")
+ expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, "queued")
subject.sample
end
@@ -80,20 +80,20 @@ describe Gitlab::Metrics::Samplers::UnicornSampler do
end
end
- describe '#start' do
- context 'when enabled' do
+ describe "#start" do
+ context "when enabled" do
before do
allow(subject).to receive(:enabled?).and_return(true)
end
- it 'creates new thread' do
+ it "creates new thread" do
expect(Thread).to receive(:new)
subject.start
end
end
- context 'when disabled' do
+ context "when disabled" do
before do
allow(subject).to receive(:enabled?).and_return(false)
end
diff --git a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
index 61eb059a731..88ce2179bf6 100644
--- a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
+++ b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::SidekiqMetricsExporter do
let(:exporter) { described_class.new }
- let(:server) { double('server') }
+ let(:server) { double("server") }
before do
allow(::WEBrick::HTTPServer).to receive(:new).and_return(server)
@@ -11,29 +11,29 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
allow(server).to receive(:shutdown)
end
- describe 'when exporter is enabled' do
+ describe "when exporter is enabled" do
before do
allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(true)
end
- describe 'when exporter is stopped' do
- describe '#start' do
- it 'starts the exporter' do
+ describe "when exporter is stopped" do
+ describe "#start" do
+ it "starts the exporter" do
expect { exporter.start.join }.to change { exporter.thread? }.from(false).to(true)
expect(server).to have_received(:start)
end
- describe 'with custom settings' do
+ describe "with custom settings" do
let(:port) { 99999 }
- let(:address) { 'sidekiq_exporter_address' }
+ let(:address) { "sidekiq_exporter_address" }
before do
allow(Settings.monitoring.sidekiq_exporter).to receive(:port).and_return(port)
allow(Settings.monitoring.sidekiq_exporter).to receive(:address).and_return(address)
end
- it 'starts server with port and address from settings' do
+ it "starts server with port and address from settings" do
exporter.start.join
expect(::WEBrick::HTTPServer).to have_received(:new).with(
@@ -46,7 +46,7 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
end
end
- describe '#stop' do
+ describe "#stop" do
it "doesn't shutdown stopped server" do
expect { exporter.stop }.not_to change { exporter.thread? }
@@ -55,12 +55,12 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
end
end
- describe 'when exporter is running' do
+ describe "when exporter is running" do
before do
exporter.start.join
end
- describe '#start' do
+ describe "#start" do
it "doesn't start running server" do
expect { exporter.start.join }.not_to change { exporter.thread? }
@@ -68,8 +68,8 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
end
end
- describe '#stop' do
- it 'shutdowns server' do
+ describe "#stop" do
+ it "shutdowns server" do
expect { exporter.stop }.to change { exporter.thread? }.from(true).to(false)
expect(server).to have_received(:shutdown)
@@ -78,12 +78,12 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
end
end
- describe 'when exporter is disabled' do
+ describe "when exporter is disabled" do
before do
allow(Settings.monitoring.sidekiq_exporter).to receive(:enabled).and_return(false)
end
- describe '#start' do
+ describe "#start" do
it "doesn't start" do
expect(exporter.start).to be_nil
expect { exporter.start }.not_to change { exporter.thread? }
@@ -92,7 +92,7 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do
end
end
- describe '#stop' do
+ describe "#stop" do
it "doesn't shutdown" do
expect { exporter.stop }.not_to change { exporter.thread? }
diff --git a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
index ae1d8b47fe9..084f4876255 100644
--- a/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
+++ b/spec/lib/gitlab/metrics/sidekiq_middleware_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::SidekiqMiddleware do
let(:middleware) { described_class.new }
- let(:message) { { 'args' => ['test'], 'enqueued_at' => Time.new(2016, 6, 23, 6, 59).to_f } }
+ let(:message) { {"args" => ["test"], "enqueued_at" => Time.new(2016, 6, 23, 6, 59).to_f} }
- describe '#call' do
- it 'tracks the transaction' do
- worker = double(:worker, class: double(:class, name: 'TestWorker'))
+ describe "#call" do
+ it "tracks the transaction" do
+ worker = double(:worker, class: double(:class, name: "TestWorker"))
expect(Gitlab::Metrics::BackgroundTransaction).to receive(:new)
.with(worker.class)
@@ -20,8 +20,8 @@ describe Gitlab::Metrics::SidekiqMiddleware do
middleware.call(worker, message, :test) { nil }
end
- it 'tracks the transaction (for messages without `enqueued_at`)' do
- worker = double(:worker, class: double(:class, name: 'TestWorker'))
+ it "tracks the transaction (for messages without `enqueued_at`)" do
+ worker = double(:worker, class: double(:class, name: "TestWorker"))
expect(Gitlab::Metrics::BackgroundTransaction).to receive(:new)
.with(worker.class)
@@ -35,8 +35,8 @@ describe Gitlab::Metrics::SidekiqMiddleware do
middleware.call(worker, {}, :test) { nil }
end
- it 'tracks any raised exceptions' do
- worker = double(:worker, class: double(:class, name: 'TestWorker'))
+ it "tracks any raised exceptions" do
+ worker = double(:worker, class: double(:class, name: "TestWorker"))
expect_any_instance_of(Gitlab::Metrics::Transaction)
.to receive(:run).and_raise(RuntimeError)
diff --git a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
index 9f3af1acef7..7a4a562da30 100644
--- a/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
+++ b/spec/lib/gitlab/metrics/subscribers/action_view_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Subscribers::ActionView do
let(:env) { {} }
@@ -10,17 +10,17 @@ describe Gitlab::Metrics::Subscribers::ActionView do
root = Rails.root.to_s
double(:event, duration: 2.1,
- payload: { identifier: "#{root}/app/views/x.html.haml" })
+ payload: {identifier: "#{root}/app/views/x.html.haml"})
end
before do
allow(subscriber).to receive(:current_transaction).and_return(transaction)
end
- describe '#render_template' do
- it 'tracks rendering of a template' do
- values = { duration: 2.1 }
- tags = { view: 'app/views/x.html.haml' }
+ describe "#render_template" do
+ it "tracks rendering of a template" do
+ values = {duration: 2.1}
+ tags = {view: "app/views/x.html.haml"}
expect(transaction).to receive(:increment)
.with(:view_duration, 2.1)
@@ -31,10 +31,10 @@ describe Gitlab::Metrics::Subscribers::ActionView do
subscriber.render_template(event)
end
- it 'observes view rendering time' do
+ it "observes view rendering time" do
expect(described_class.gitlab_view_rendering_duration_seconds)
.to receive(:observe)
- .with({ view: 'app/views/x.html.haml' }, 2.1)
+ .with({view: "app/views/x.html.haml"}, 2.1)
subscriber.render_template(event)
end
diff --git a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb
index ee6d6fc961f..b960f25e952 100644
--- a/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb
+++ b/spec/lib/gitlab/metrics/subscribers/active_record_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Subscribers::ActiveRecord do
let(:env) { {} }
@@ -7,12 +7,12 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
let(:event) do
double(:event, duration: 2,
- payload: { sql: 'SELECT * FROM users WHERE id = 10' })
+ payload: {sql: "SELECT * FROM users WHERE id = 10"})
end
- describe '#sql' do
- describe 'without a current transaction' do
- it 'simply returns' do
+ describe "#sql" do
+ describe "without a current transaction" do
+ it "simply returns" do
expect_any_instance_of(Gitlab::Metrics::Transaction)
.not_to receive(:increment)
@@ -20,16 +20,16 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
end
end
- describe 'with a current transaction' do
- it 'observes sql_duration metric' do
+ describe "with a current transaction" do
+ it "observes sql_duration metric" do
expect(subscriber).to receive(:current_transaction)
- .at_least(:once)
- .and_return(transaction)
+ .at_least(:once)
+ .and_return(transaction)
expect(described_class.send(:gitlab_sql_duration_seconds)).to receive(:observe).with({}, 0.002)
subscriber.sql(event)
end
- it 'increments the :sql_duration value' do
+ it "increments the :sql_duration value" do
expect(subscriber).to receive(:current_transaction)
.at_least(:once)
.and_return(transaction)
@@ -43,17 +43,17 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
subscriber.sql(event)
end
- context 'events are internal to Rails or irrelevant' do
+ context "events are internal to Rails or irrelevant" do
let(:schema_event) do
double(
:event,
- name: 'sql.active_record',
+ name: "sql.active_record",
payload: {
sql: "SELECT attr.attname FROM pg_attribute attr INNER JOIN pg_constraint cons ON attr.attrelid = cons.conrelid AND attr.attnum = any(cons.conkey) WHERE cons.contype = 'p' AND cons.conrelid = '\"projects\"'::regclass",
- name: 'SCHEMA',
+ name: "SCHEMA",
connection_id: 135,
statement_name: nil,
- binds: []
+ binds: [],
},
duration: 0.7
)
@@ -62,13 +62,13 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
let(:begin_event) do
double(
:event,
- name: 'sql.active_record',
+ name: "sql.active_record",
payload: {
sql: "BEGIN",
name: nil,
connection_id: 231,
statement_name: nil,
- binds: []
+ binds: [],
},
duration: 1.1
)
@@ -77,22 +77,22 @@ describe Gitlab::Metrics::Subscribers::ActiveRecord do
let(:commit_event) do
double(
:event,
- name: 'sql.active_record',
+ name: "sql.active_record",
payload: {
sql: "COMMIT",
name: nil,
connection_id: 212,
statement_name: nil,
- binds: []
+ binds: [],
},
duration: 1.6
)
end
- it 'skips schema/begin/commit sql commands' do
+ it "skips schema/begin/commit sql commands" do
expect(subscriber).to receive(:current_transaction)
- .at_least(:once)
- .and_return(transaction)
+ .at_least(:once)
+ .and_return(transaction)
expect(transaction).not_to receive(:increment)
diff --git a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
index 6795c1ab56b..f66886aa881 100644
--- a/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
+++ b/spec/lib/gitlab/metrics/subscribers/rails_cache_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::Subscribers::RailsCache do
let(:env) { {} }
@@ -7,73 +7,73 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
let(:event) { double(:event, duration: 15.2) }
- describe '#cache_read' do
- it 'increments the cache_read duration' do
+ describe "#cache_read" do
+ it "increments the cache_read duration" do
expect(subscriber).to receive(:observe)
- .with(:read, event.duration)
+ .with(:read, event.duration)
subscriber.cache_read(event)
end
- context 'with a transaction' do
+ context "with a transaction" do
before do
allow(subscriber).to receive(:current_transaction)
- .and_return(transaction)
+ .and_return(transaction)
end
- context 'with hit event' do
- let(:event) { double(:event, duration: 15.2, payload: { hit: true }) }
+ context "with hit event" do
+ let(:event) { double(:event, duration: 15.2, payload: {hit: true}) }
- it 'increments the cache_read_hit count' do
+ it "increments the cache_read_hit count" do
expect(transaction).to receive(:increment)
- .with(:cache_read_hit_count, 1, false)
+ .with(:cache_read_hit_count, 1, false)
expect(transaction).to receive(:increment)
- .with(any_args).at_least(1) # Other calls
+ .with(any_args).at_least(1) # Other calls
subscriber.cache_read(event)
end
- context 'when super operation is fetch' do
- let(:event) { double(:event, duration: 15.2, payload: { hit: true, super_operation: :fetch }) }
+ context "when super operation is fetch" do
+ let(:event) { double(:event, duration: 15.2, payload: {hit: true, super_operation: :fetch}) }
- it 'does not increment cache read miss' do
+ it "does not increment cache read miss" do
expect(transaction).not_to receive(:increment)
- .with(:cache_read_hit_count, 1)
+ .with(:cache_read_hit_count, 1)
subscriber.cache_read(event)
end
end
end
- context 'with miss event' do
- let(:event) { double(:event, duration: 15.2, payload: { hit: false }) }
+ context "with miss event" do
+ let(:event) { double(:event, duration: 15.2, payload: {hit: false}) }
- it 'increments the cache_read_miss count' do
+ it "increments the cache_read_miss count" do
expect(transaction).to receive(:increment)
- .with(:cache_read_miss_count, 1, false)
+ .with(:cache_read_miss_count, 1, false)
expect(transaction).to receive(:increment)
- .with(any_args).at_least(1) # Other calls
+ .with(any_args).at_least(1) # Other calls
subscriber.cache_read(event)
end
- it 'increments the cache_read_miss total' do
+ it "increments the cache_read_miss total" do
expect(subscriber.send(:metric_cache_misses_total)).to receive(:increment).with({})
subscriber.cache_read(event)
end
- context 'when super operation is fetch' do
- let(:event) { double(:event, duration: 15.2, payload: { hit: false, super_operation: :fetch }) }
+ context "when super operation is fetch" do
+ let(:event) { double(:event, duration: 15.2, payload: {hit: false, super_operation: :fetch}) }
- it 'does not increment cache read miss' do
+ it "does not increment cache read miss" do
expect(transaction).not_to receive(:increment)
- .with(:cache_read_miss_count, 1)
+ .with(:cache_read_miss_count, 1)
subscriber.cache_read(event)
end
- it 'does not increment cache_read_miss total' do
+ it "does not increment cache_read_miss total" do
expect(subscriber.send(:metric_cache_misses_total)).not_to receive(:increment).with({})
subscriber.cache_read(event)
@@ -83,83 +83,83 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
end
- describe '#cache_write' do
- it 'observes write duration' do
+ describe "#cache_write" do
+ it "observes write duration" do
expect(subscriber).to receive(:observe)
- .with(:write, event.duration)
+ .with(:write, event.duration)
subscriber.cache_write(event)
end
end
- describe '#cache_delete' do
- it 'observes delete duration' do
+ describe "#cache_delete" do
+ it "observes delete duration" do
expect(subscriber).to receive(:observe)
- .with(:delete, event.duration)
+ .with(:delete, event.duration)
subscriber.cache_delete(event)
end
end
- describe '#cache_exist?' do
- it 'observes the exists duration' do
+ describe "#cache_exist?" do
+ it "observes the exists duration" do
expect(subscriber).to receive(:observe)
- .with(:exists, event.duration)
+ .with(:exists, event.duration)
subscriber.cache_exist?(event)
end
end
- describe '#cache_fetch_hit' do
- context 'without a transaction' do
- it 'returns' do
+ describe "#cache_fetch_hit" do
+ context "without a transaction" do
+ it "returns" do
expect(transaction).not_to receive(:increment)
subscriber.cache_fetch_hit(event)
end
end
- context 'with a transaction' do
+ context "with a transaction" do
before do
allow(subscriber).to receive(:current_transaction)
- .and_return(transaction)
+ .and_return(transaction)
end
- it 'increments the cache_read_hit count' do
+ it "increments the cache_read_hit count" do
expect(transaction).to receive(:increment)
- .with(:cache_read_hit_count, 1)
+ .with(:cache_read_hit_count, 1)
subscriber.cache_fetch_hit(event)
end
end
end
- describe '#cache_generate' do
- context 'without a transaction' do
- it 'returns' do
+ describe "#cache_generate" do
+ context "without a transaction" do
+ it "returns" do
expect(transaction).not_to receive(:increment)
subscriber.cache_generate(event)
end
end
- context 'with a transaction' do
- let(:metric_cache_misses_total) { double('metric_cache_misses_total', increment: nil) }
+ context "with a transaction" do
+ let(:metric_cache_misses_total) { double("metric_cache_misses_total", increment: nil) }
before do
allow(subscriber).to receive(:metric_cache_misses_total).and_return(metric_cache_misses_total)
allow(subscriber).to receive(:current_transaction)
- .and_return(transaction)
+ .and_return(transaction)
end
- it 'increments the cache_fetch_miss count' do
+ it "increments the cache_fetch_miss count" do
expect(transaction).to receive(:increment)
- .with(:cache_read_miss_count, 1)
+ .with(:cache_read_miss_count, 1)
subscriber.cache_generate(event)
end
- it 'increments the cache_read_miss total' do
+ it "increments the cache_read_miss total" do
subscriber.cache_generate(event)
expect(metric_cache_misses_total).to have_received(:increment).with({})
@@ -167,41 +167,41 @@ describe Gitlab::Metrics::Subscribers::RailsCache do
end
end
- describe '#observe' do
- context 'without a transaction' do
- it 'returns' do
+ describe "#observe" do
+ context "without a transaction" do
+ it "returns" do
expect(transaction).not_to receive(:increment)
subscriber.observe(:foo, 15.2)
end
end
- context 'with a transaction' do
+ context "with a transaction" do
before do
allow(subscriber).to receive(:current_transaction)
- .and_return(transaction)
+ .and_return(transaction)
end
- it 'increments the total and specific cache duration' do
+ it "increments the total and specific cache duration" do
expect(transaction).to receive(:increment)
- .with(:cache_duration, event.duration, false)
+ .with(:cache_duration, event.duration, false)
expect(transaction).to receive(:increment)
- .with(:cache_count, 1, false)
+ .with(:cache_count, 1, false)
expect(transaction).to receive(:increment)
- .with(:cache_delete_duration, event.duration, false)
+ .with(:cache_delete_duration, event.duration, false)
expect(transaction).to receive(:increment)
- .with(:cache_delete_count, 1, false)
+ .with(:cache_delete_count, 1, false)
subscriber.observe(:delete, event.duration)
end
- it 'observes cache metric' do
+ it "observes cache metric" do
expect(subscriber.send(:metric_cache_operation_duration_seconds))
.to receive(:observe)
- .with(transaction.labels.merge(operation: :delete), event.duration / 1000.0)
+ .with(transaction.labels.merge(operation: :delete), event.duration / 1000.0)
subscriber.observe(:delete, event.duration)
end
diff --git a/spec/lib/gitlab/metrics/system_spec.rb b/spec/lib/gitlab/metrics/system_spec.rb
index 14afcdf5daa..86f5640fe59 100644
--- a/spec/lib/gitlab/metrics/system_spec.rb
+++ b/spec/lib/gitlab/metrics/system_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::System do
- if File.exist?('/proc')
- describe '.memory_usage' do
+ if File.exist?("/proc")
+ describe ".memory_usage" do
it "returns the process' memory usage in bytes" do
expect(described_class.memory_usage).to be > 0
end
end
- describe '.file_descriptor_count' do
- it 'returns the amount of open file descriptors' do
+ describe ".file_descriptor_count" do
+ it "returns the amount of open file descriptors" do
expect(described_class.file_descriptor_count).to be > 0
end
end
else
- describe '.memory_usage' do
- it 'returns 0.0' do
+ describe ".memory_usage" do
+ it "returns 0.0" do
expect(described_class.memory_usage).to eq(0.0)
end
end
- describe '.file_descriptor_count' do
- it 'returns 0' do
+ describe ".file_descriptor_count" do
+ it "returns 0" do
expect(described_class.file_descriptor_count).to eq(0)
end
end
end
- describe '.cpu_time' do
- it 'returns a Fixnum' do
+ describe ".cpu_time" do
+ it "returns a Fixnum" do
expect(described_class.cpu_time).to be_an(Float)
end
end
- describe '.real_time' do
- it 'returns a Fixnum' do
+ describe ".real_time" do
+ it "returns a Fixnum" do
expect(described_class.real_time).to be_an(Float)
end
end
- describe '.monotonic_time' do
- it 'returns a Float' do
+ describe ".monotonic_time" do
+ it "returns a Float" do
expect(described_class.monotonic_time).to be_an(Float)
end
end
diff --git a/spec/lib/gitlab/metrics/web_transaction_spec.rb b/spec/lib/gitlab/metrics/web_transaction_spec.rb
index 0b3b23e930f..1327180166a 100644
--- a/spec/lib/gitlab/metrics/web_transaction_spec.rb
+++ b/spec/lib/gitlab/metrics/web_transaction_spec.rb
@@ -1,93 +1,93 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics::WebTransaction do
let(:env) { {} }
let(:transaction) { described_class.new(env) }
- describe '#duration' do
- it 'returns the duration of a transaction in seconds' do
+ describe "#duration" do
+ it "returns the duration of a transaction in seconds" do
transaction.run { sleep(0.5) }
expect(transaction.duration).to be >= 0.5
end
end
- describe '#allocated_memory' do
- it 'returns the allocated memory in bytes' do
- transaction.run { 'a' * 32 }
+ describe "#allocated_memory" do
+ it "returns the allocated memory in bytes" do
+ transaction.run { "a" * 32 }
expect(transaction.allocated_memory).to be_a_kind_of(Numeric)
end
end
- describe '#run' do
- it 'yields the supplied block' do
+ describe "#run" do
+ it "yields the supplied block" do
expect { |b| transaction.run(&b) }.to yield_control
end
- it 'stores the transaction in the current thread' do
+ it "stores the transaction in the current thread" do
transaction.run do
expect(Thread.current[described_class::THREAD_KEY]).to eq(transaction)
end
end
- it 'removes the transaction from the current thread upon completion' do
+ it "removes the transaction from the current thread upon completion" do
transaction.run { }
expect(Thread.current[described_class::THREAD_KEY]).to be_nil
end
end
- describe '#add_metric' do
- it 'adds a metric to the transaction' do
+ describe "#add_metric" do
+ it "adds a metric to the transaction" do
expect(Gitlab::Metrics::Metric).to receive(:new)
- .with('rails_foo', { number: 10 }, {})
+ .with("rails_foo", {number: 10}, {})
- transaction.add_metric('foo', number: 10)
+ transaction.add_metric("foo", number: 10)
end
end
- describe '#method_call_for' do
- it 'returns a MethodCall' do
- method = transaction.method_call_for('Foo#bar', :Foo, '#bar')
+ describe "#method_call_for" do
+ it "returns a MethodCall" do
+ method = transaction.method_call_for("Foo#bar", :Foo, "#bar")
expect(method).to be_an_instance_of(Gitlab::Metrics::MethodCall)
end
end
- describe '#increment' do
- it 'increments a counter' do
+ describe "#increment" do
+ it "increments a counter" do
transaction.increment(:time, 1)
transaction.increment(:time, 2)
- values = { duration: 0.0, time: 3, allocated_memory: a_kind_of(Numeric) }
+ values = {duration: 0.0, time: 3, allocated_memory: a_kind_of(Numeric)}
expect(transaction).to receive(:add_metric)
- .with('transactions', values, {})
+ .with("transactions", values, {})
transaction.track_self
end
end
- describe '#set' do
- it 'sets a value' do
+ describe "#set" do
+ it "sets a value" do
transaction.set(:number, 10)
values = {
- duration: 0.0,
- number: 10,
- allocated_memory: a_kind_of(Numeric)
+ duration: 0.0,
+ number: 10,
+ allocated_memory: a_kind_of(Numeric),
}
expect(transaction).to receive(:add_metric)
- .with('transactions', values, {})
+ .with("transactions", values, {})
transaction.track_self
end
end
- describe '#finish' do
- it 'tracks the transaction details and submits them to Sidekiq' do
+ describe "#finish" do
+ it "tracks the transaction details and submits them to Sidekiq" do
expect(transaction).to receive(:track_self)
expect(transaction).to receive(:submit)
@@ -95,22 +95,22 @@ describe Gitlab::Metrics::WebTransaction do
end
end
- describe '#track_self' do
- it 'adds a metric for the transaction itself' do
+ describe "#track_self" do
+ it "adds a metric for the transaction itself" do
values = {
- duration: transaction.duration,
- allocated_memory: a_kind_of(Numeric)
+ duration: transaction.duration,
+ allocated_memory: a_kind_of(Numeric),
}
expect(transaction).to receive(:add_metric)
- .with('transactions', values, {})
+ .with("transactions", values, {})
transaction.track_self
end
end
- describe '#submit' do
- it 'submits the metrics to Sidekiq' do
+ describe "#submit" do
+ it "submits the metrics to Sidekiq" do
transaction.track_self
expect(Gitlab::Metrics).to receive(:submit_metrics)
@@ -119,15 +119,15 @@ describe Gitlab::Metrics::WebTransaction do
transaction.submit
end
- it 'adds the action as a tag for every metric' do
- allow(transaction).to receive(:labels).and_return(controller: 'Foo', action: 'bar')
+ it "adds the action as a tag for every metric" do
+ allow(transaction).to receive(:labels).and_return(controller: "Foo", action: "bar")
transaction.track_self
hash = {
- series: 'rails_transactions',
- tags: { action: 'Foo#bar' },
- values: { duration: 0.0, allocated_memory: a_kind_of(Numeric) },
- timestamp: a_kind_of(Integer)
+ series: "rails_transactions",
+ tags: {action: "Foo#bar"},
+ values: {duration: 0.0, allocated_memory: a_kind_of(Numeric)},
+ timestamp: a_kind_of(Integer),
}
expect(Gitlab::Metrics).to receive(:submit_metrics)
@@ -136,16 +136,16 @@ describe Gitlab::Metrics::WebTransaction do
transaction.submit
end
- it 'does not add an action tag for events' do
- allow(transaction).to receive(:labels).and_return(controller: 'Foo', action: 'bar')
+ it "does not add an action tag for events" do
+ allow(transaction).to receive(:labels).and_return(controller: "Foo", action: "bar")
transaction.add_event(:meow)
hash = {
- series: 'events',
- tags: { event: :meow },
- values: { count: 1 },
- timestamp: a_kind_of(Integer)
+ series: "events",
+ tags: {event: :meow},
+ values: {count: 1},
+ timestamp: a_kind_of(Integer),
}
expect(Gitlab::Metrics).to receive(:submit_metrics)
@@ -155,72 +155,72 @@ describe Gitlab::Metrics::WebTransaction do
end
end
- describe '#labels' do
- context 'when request goes to Grape endpoint' do
+ describe "#labels" do
+ context "when request goes to Grape endpoint" do
before do
- route = double(:route, request_method: 'GET', path: '/:version/projects/:id/archive(.:format)')
+ route = double(:route, request_method: "GET", path: "/:version/projects/:id/archive(.:format)")
endpoint = double(:endpoint, route: route)
- env['api.endpoint'] = endpoint
+ env["api.endpoint"] = endpoint
end
- it 'provides labels with the method and path of the route in the grape endpoint' do
- expect(transaction.labels).to eq({ controller: 'Grape', action: 'GET /projects/:id/archive' })
- expect(transaction.action).to eq('Grape#GET /projects/:id/archive')
+ it "provides labels with the method and path of the route in the grape endpoint" do
+ expect(transaction.labels).to eq({controller: "Grape", action: "GET /projects/:id/archive"})
+ expect(transaction.action).to eq("Grape#GET /projects/:id/archive")
end
- it 'does not provide labels if route infos are missing' do
+ it "does not provide labels if route infos are missing" do
endpoint = double(:endpoint)
allow(endpoint).to receive(:route).and_raise
- env['api.endpoint'] = endpoint
+ env["api.endpoint"] = endpoint
expect(transaction.labels).to eq({})
expect(transaction.action).to be_nil
end
end
- context 'when request goes to ActionController' do
+ context "when request goes to ActionController" do
let(:request) { double(:request, format: double(:format, ref: :html)) }
before do
- klass = double(:klass, name: 'TestController')
- controller = double(:controller, class: klass, action_name: 'show', request: request)
+ klass = double(:klass, name: "TestController")
+ controller = double(:controller, class: klass, action_name: "show", request: request)
- env['action_controller.instance'] = controller
+ env["action_controller.instance"] = controller
end
- it 'tags a transaction with the name and action of a controller' do
- expect(transaction.labels).to eq({ controller: 'TestController', action: 'show' })
- expect(transaction.action).to eq('TestController#show')
+ it "tags a transaction with the name and action of a controller" do
+ expect(transaction.labels).to eq({controller: "TestController", action: "show"})
+ expect(transaction.action).to eq("TestController#show")
end
- context 'when the request content type is not :html' do
+ context "when the request content type is not :html" do
let(:request) { double(:request, format: double(:format, ref: :json)) }
- it 'appends the mime type to the transaction action' do
- expect(transaction.labels).to eq({ controller: 'TestController', action: 'show.json' })
- expect(transaction.action).to eq('TestController#show.json')
+ it "appends the mime type to the transaction action" do
+ expect(transaction.labels).to eq({controller: "TestController", action: "show.json"})
+ expect(transaction.action).to eq("TestController#show.json")
end
end
- context 'when the request content type is not' do
- let(:request) { double(:request, format: double(:format, ref: 'http://example.com')) }
+ context "when the request content type is not" do
+ let(:request) { double(:request, format: double(:format, ref: "http://example.com")) }
- it 'does not append the MIME type to the transaction action' do
- expect(transaction.labels).to eq({ controller: 'TestController', action: 'show' })
- expect(transaction.action).to eq('TestController#show')
+ it "does not append the MIME type to the transaction action" do
+ expect(transaction.labels).to eq({controller: "TestController", action: "show"})
+ expect(transaction.action).to eq("TestController#show")
end
end
end
- it 'returns no labels when no route information is present in env' do
+ it "returns no labels when no route information is present in env" do
expect(transaction.labels).to eq({})
expect(transaction.action).to eq(nil)
end
end
- describe '#add_event' do
- it 'adds a metric' do
+ describe "#add_event" do
+ it "adds a metric" do
transaction.add_event(:meow)
expect(transaction.metrics[0]).to be_an_instance_of(Gitlab::Metrics::Metric)
@@ -234,7 +234,7 @@ describe Gitlab::Metrics::WebTransaction do
expect(metric.series).to eq(described_class::EVENT_SERIES)
end
- it 'tracks a counter for every event' do
+ it "tracks a counter for every event" do
transaction.add_event(:meow)
metric = transaction.metrics[0]
@@ -242,7 +242,7 @@ describe Gitlab::Metrics::WebTransaction do
expect(metric.values).to eq(count: 1)
end
- it 'tracks the event name' do
+ it "tracks the event name" do
transaction.add_event(:meow)
metric = transaction.metrics[0]
@@ -250,12 +250,12 @@ describe Gitlab::Metrics::WebTransaction do
expect(metric.tags).to eq(event: :meow)
end
- it 'allows tracking of custom tags' do
- transaction.add_event(:meow, animal: 'cat')
+ it "allows tracking of custom tags" do
+ transaction.add_event(:meow, animal: "cat")
metric = transaction.metrics[0]
- expect(metric.tags).to eq(event: :meow, animal: 'cat')
+ expect(metric.tags).to eq(event: :meow, animal: "cat")
end
end
end
diff --git a/spec/lib/gitlab/metrics_spec.rb b/spec/lib/gitlab/metrics_spec.rb
index 03c185ddc07..38c90f02ab2 100644
--- a/spec/lib/gitlab/metrics_spec.rb
+++ b/spec/lib/gitlab/metrics_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Metrics do
include StubENV
- describe '.settings' do
- it 'returns a Hash' do
+ describe ".settings" do
+ it "returns a Hash" do
expect(described_class.settings).to be_an_instance_of(Hash)
end
end
- describe '.enabled?' do
- it 'returns a boolean' do
+ describe ".enabled?" do
+ it "returns a boolean" do
expect(described_class.enabled?).to be_in([true, false])
end
end
- describe '.prometheus_metrics_enabled_unmemoized' do
+ describe ".prometheus_metrics_enabled_unmemoized" do
subject { described_class.send(:prometheus_metrics_enabled_unmemoized) }
- context 'prometheus metrics enabled in config' do
+ context "prometheus metrics enabled in config" do
before do
allow(Gitlab::CurrentSettings).to receive(:prometheus_metrics_enabled).and_return(true)
end
- context 'when metrics folder is present' do
+ context "when metrics folder is present" do
before do
allow(described_class).to receive(:metrics_folder_present?).and_return(true)
end
- it 'metrics are enabled' do
+ it "metrics are enabled" do
expect(subject).to eq(true)
end
end
- context 'when metrics folder is missing' do
+ context "when metrics folder is missing" do
before do
allow(described_class).to receive(:metrics_folder_present?).and_return(false)
end
- it 'metrics are disabled' do
+ it "metrics are disabled" do
expect(subject).to eq(false)
end
end
end
end
- describe '.prometheus_metrics_enabled?' do
- it 'returns a boolean' do
+ describe ".prometheus_metrics_enabled?" do
+ it "returns a boolean" do
expect(described_class.prometheus_metrics_enabled?).to be_in([true, false])
end
end
- describe '.influx_metrics_enabled?' do
- it 'returns a boolean' do
+ describe ".influx_metrics_enabled?" do
+ it "returns a boolean" do
expect(described_class.influx_metrics_enabled?).to be_in([true, false])
end
end
- describe '.submit_metrics' do
- it 'prepares and writes the metrics to InfluxDB' do
+ describe ".submit_metrics" do
+ it "prepares and writes the metrics to InfluxDB" do
connection = double(:connection)
pool = double(:pool)
@@ -66,55 +66,55 @@ describe Gitlab::Metrics do
expect(connection).to receive(:write_points).with(an_instance_of(Array))
expect(described_class).to receive(:pool).and_return(pool)
- described_class.submit_metrics([{ 'series' => 'kittens', 'tags' => {} }])
+ described_class.submit_metrics([{"series" => "kittens", "tags" => {}}])
end
end
- describe '.prepare_metrics' do
- it 'returns a Hash with the keys as Symbols' do
+ describe ".prepare_metrics" do
+ it "returns a Hash with the keys as Symbols" do
metrics = described_class
- .prepare_metrics([{ 'values' => {}, 'tags' => {} }])
+ .prepare_metrics([{"values" => {}, "tags" => {}}])
- expect(metrics).to eq([{ values: {}, tags: {} }])
+ expect(metrics).to eq([{values: {}, tags: {}}])
end
- it 'escapes tag values' do
+ it "escapes tag values" do
metrics = described_class.prepare_metrics([
- { 'values' => {}, 'tags' => { 'foo' => 'bar=' } }
+ {"values" => {}, "tags" => {"foo" => "bar="}},
])
- expect(metrics).to eq([{ values: {}, tags: { 'foo' => 'bar\\=' } }])
+ expect(metrics).to eq([{values: {}, tags: {"foo" => 'bar\\='}}])
end
- it 'drops empty tags' do
+ it "drops empty tags" do
metrics = described_class.prepare_metrics([
- { 'values' => {}, 'tags' => { 'cats' => '', 'dogs' => nil } }
+ {"values" => {}, "tags" => {"cats" => "", "dogs" => nil}},
])
- expect(metrics).to eq([{ values: {}, tags: {} }])
+ expect(metrics).to eq([{values: {}, tags: {}}])
end
end
- describe '.escape_value' do
- it 'escapes an equals sign' do
- expect(described_class.escape_value('foo=')).to eq('foo\\=')
+ describe ".escape_value" do
+ it "escapes an equals sign" do
+ expect(described_class.escape_value("foo=")).to eq('foo\\=')
end
- it 'casts values to Strings' do
- expect(described_class.escape_value(10)).to eq('10')
+ it "casts values to Strings" do
+ expect(described_class.escape_value(10)).to eq("10")
end
end
- describe '.measure' do
- context 'without a transaction' do
- it 'returns the return value of the block' do
+ describe ".measure" do
+ context "without a transaction" do
+ it "returns the return value of the block" do
val = described_class.measure(:foo) { 10 }
expect(val).to eq(10)
end
end
- context 'with a transaction' do
+ context "with a transaction" do
let(:transaction) { Gitlab::Metrics::WebTransaction.new({}) }
before do
@@ -122,20 +122,20 @@ describe Gitlab::Metrics do
.and_return(transaction)
end
- it 'adds a metric to the current transaction' do
+ it "adds a metric to the current transaction" do
expect(transaction).to receive(:increment)
- .with('foo_real_time', a_kind_of(Numeric), false)
+ .with("foo_real_time", a_kind_of(Numeric), false)
expect(transaction).to receive(:increment)
- .with('foo_cpu_time', a_kind_of(Numeric), false)
+ .with("foo_cpu_time", a_kind_of(Numeric), false)
expect(transaction).to receive(:increment)
- .with('foo_call_count', 1, false)
+ .with("foo_call_count", 1, false)
described_class.measure(:foo) { 10 }
end
- it 'returns the return value of the block' do
+ it "returns the return value of the block" do
val = described_class.measure(:foo) { 10 }
expect(val).to eq(10)
@@ -143,39 +143,39 @@ describe Gitlab::Metrics do
end
end
- describe '.action=' do
- context 'without a transaction' do
- it 'does nothing' do
+ describe ".action=" do
+ context "without a transaction" do
+ it "does nothing" do
expect_any_instance_of(Gitlab::Metrics::Transaction)
.not_to receive(:action=)
- described_class.action = 'foo'
+ described_class.action = "foo"
end
end
- context 'with a transaction' do
- it 'sets the action of a transaction' do
+ context "with a transaction" do
+ it "sets the action of a transaction" do
trans = Gitlab::Metrics::WebTransaction.new({})
expect(described_class).to receive(:current_transaction)
.and_return(trans)
- expect(trans).to receive(:action=).with('foo')
+ expect(trans).to receive(:action=).with("foo")
- described_class.action = 'foo'
+ described_class.action = "foo"
end
end
end
- describe '#series_prefix' do
- it 'returns a String' do
+ describe "#series_prefix" do
+ it "returns a String" do
expect(described_class.series_prefix).to be_an_instance_of(String)
end
end
- describe '.add_event' do
- context 'without a transaction' do
- it 'does nothing' do
+ describe ".add_event" do
+ context "without a transaction" do
+ it "does nothing" do
expect_any_instance_of(Gitlab::Metrics::Transaction)
.not_to receive(:add_event)
@@ -183,8 +183,8 @@ describe Gitlab::Metrics do
end
end
- context 'with a transaction' do
- it 'adds an event' do
+ context "with a transaction" do
+ it "adds an event" do
transaction = Gitlab::Metrics::WebTransaction.new({})
expect(transaction).to receive(:add_event).with(:meow)
@@ -197,130 +197,130 @@ describe Gitlab::Metrics do
end
end
- shared_examples 'prometheus metrics API' do
- describe '#counter' do
- subject { described_class.counter(:counter, 'doc') }
+ shared_examples "prometheus metrics API" do
+ describe "#counter" do
+ subject { described_class.counter(:counter, "doc") }
- describe '#increment' do
- it 'successfully calls #increment without arguments' do
+ describe "#increment" do
+ it "successfully calls #increment without arguments" do
expect { subject.increment }.not_to raise_exception
end
- it 'successfully calls #increment with 1 argument' do
+ it "successfully calls #increment with 1 argument" do
expect { subject.increment({}) }.not_to raise_exception
end
- it 'successfully calls #increment with 2 arguments' do
+ it "successfully calls #increment with 2 arguments" do
expect { subject.increment({}, 1) }.not_to raise_exception
end
end
end
- describe '#summary' do
- subject { described_class.summary(:summary, 'doc') }
+ describe "#summary" do
+ subject { described_class.summary(:summary, "doc") }
- describe '#observe' do
- it 'successfully calls #observe with 2 arguments' do
+ describe "#observe" do
+ it "successfully calls #observe with 2 arguments" do
expect { subject.observe({}, 2) }.not_to raise_exception
end
end
end
- describe '#gauge' do
- subject { described_class.gauge(:gauge, 'doc') }
+ describe "#gauge" do
+ subject { described_class.gauge(:gauge, "doc") }
- describe '#set' do
- it 'successfully calls #set with 2 arguments' do
+ describe "#set" do
+ it "successfully calls #set with 2 arguments" do
expect { subject.set({}, 1) }.not_to raise_exception
end
end
end
- describe '#histogram' do
- subject { described_class.histogram(:histogram, 'doc') }
+ describe "#histogram" do
+ subject { described_class.histogram(:histogram, "doc") }
- describe '#observe' do
- it 'successfully calls #observe with 2 arguments' do
+ describe "#observe" do
+ it "successfully calls #observe with 2 arguments" do
expect { subject.observe({}, 2) }.not_to raise_exception
end
end
end
end
- context 'prometheus metrics disabled' do
+ context "prometheus metrics disabled" do
before do
allow(described_class).to receive(:prometheus_metrics_enabled?).and_return(false)
end
- it_behaves_like 'prometheus metrics API'
+ it_behaves_like "prometheus metrics API"
- describe '#null_metric' do
+ describe "#null_metric" do
subject { described_class.send(:provide_metric, :test) }
it { is_expected.to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#counter' do
- subject { described_class.counter(:counter, 'doc') }
+ describe "#counter" do
+ subject { described_class.counter(:counter, "doc") }
it { is_expected.to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#summary' do
- subject { described_class.summary(:summary, 'doc') }
+ describe "#summary" do
+ subject { described_class.summary(:summary, "doc") }
it { is_expected.to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#gauge' do
- subject { described_class.gauge(:gauge, 'doc') }
+ describe "#gauge" do
+ subject { described_class.gauge(:gauge, "doc") }
it { is_expected.to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#histogram' do
- subject { described_class.histogram(:histogram, 'doc') }
+ describe "#histogram" do
+ subject { described_class.histogram(:histogram, "doc") }
it { is_expected.to be_a(Gitlab::Metrics::NullMetric) }
end
end
- context 'prometheus metrics enabled' do
+ context "prometheus metrics enabled" do
let(:metrics_multiproc_dir) { Dir.mktmpdir }
before do
- stub_const('Prometheus::Client::Multiprocdir', metrics_multiproc_dir)
+ stub_const("Prometheus::Client::Multiprocdir", metrics_multiproc_dir)
allow(described_class).to receive(:prometheus_metrics_enabled?).and_return(true)
end
- it_behaves_like 'prometheus metrics API'
+ it_behaves_like "prometheus metrics API"
- describe '#null_metric' do
+ describe "#null_metric" do
subject { described_class.send(:provide_metric, :test) }
it { is_expected.to be_nil }
end
- describe '#counter' do
- subject { described_class.counter(:name, 'doc') }
+ describe "#counter" do
+ subject { described_class.counter(:name, "doc") }
it { is_expected.not_to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#summary' do
- subject { described_class.summary(:name, 'doc') }
+ describe "#summary" do
+ subject { described_class.summary(:name, "doc") }
it { is_expected.not_to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#gauge' do
- subject { described_class.gauge(:name, 'doc') }
+ describe "#gauge" do
+ subject { described_class.gauge(:name, "doc") }
it { is_expected.not_to be_a(Gitlab::Metrics::NullMetric) }
end
- describe '#histogram' do
- subject { described_class.histogram(:name, 'doc') }
+ describe "#histogram" do
+ subject { described_class.histogram(:name, "doc") }
it { is_expected.not_to be_a(Gitlab::Metrics::NullMetric) }
end
diff --git a/spec/lib/gitlab/middleware/basic_health_check_spec.rb b/spec/lib/gitlab/middleware/basic_health_check_spec.rb
index 187d903a5e1..524243c1843 100644
--- a/spec/lib/gitlab/middleware/basic_health_check_spec.rb
+++ b/spec/lib/gitlab/middleware/basic_health_check_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Middleware::BasicHealthCheck do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
let(:env) { {} }
- describe '#call' do
- context 'outside IP' do
+ describe "#call" do
+ context "outside IP" do
before do
- env['REMOTE_ADDR'] = '8.8.8.8'
+ env["REMOTE_ADDR"] = "8.8.8.8"
end
- it 'returns a 404' do
- env['PATH_INFO'] = described_class::HEALTH_PATH
+ it "returns a 404" do
+ env["PATH_INFO"] = described_class::HEALTH_PATH
response = middleware.call(env)
expect(response[0]).to eq(404)
end
- it 'forwards the call for other paths' do
- env['PATH_INFO'] = '/'
+ it "forwards the call for other paths" do
+ env["PATH_INFO"] = "/"
expect(app).to receive(:call)
@@ -28,25 +28,25 @@ describe Gitlab::Middleware::BasicHealthCheck do
end
end
- context 'whitelisted IP' do
+ context "whitelisted IP" do
before do
- env['REMOTE_ADDR'] = '127.0.0.1'
+ env["REMOTE_ADDR"] = "127.0.0.1"
end
- it 'returns 200 response when endpoint is hit' do
- env['PATH_INFO'] = described_class::HEALTH_PATH
+ it "returns 200 response when endpoint is hit" do
+ env["PATH_INFO"] = described_class::HEALTH_PATH
expect(app).not_to receive(:call)
response = middleware.call(env)
expect(response[0]).to eq(200)
- expect(response[1]).to eq({ 'Content-Type' => 'text/plain' })
- expect(response[2]).to eq(['GitLab OK'])
+ expect(response[1]).to eq({"Content-Type" => "text/plain"})
+ expect(response[2]).to eq(["GitLab OK"])
end
- it 'forwards the call for other paths' do
- env['PATH_INFO'] = '/-/readiness'
+ it "forwards the call for other paths" do
+ env["PATH_INFO"] = "/-/readiness"
expect(app).to receive(:call)
diff --git a/spec/lib/gitlab/middleware/go_spec.rb b/spec/lib/gitlab/middleware/go_spec.rb
index f52095bf633..57af3e4144a 100644
--- a/spec/lib/gitlab/middleware/go_spec.rb
+++ b/spec/lib/gitlab/middleware/go_spec.rb
@@ -1,130 +1,130 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Middleware::Go do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
let(:env) do
{
- 'rack.input' => '',
- 'REQUEST_METHOD' => 'GET'
+ "rack.input" => "",
+ "REQUEST_METHOD" => "GET",
}
end
- describe '#call' do
- describe 'when go-get=0' do
+ describe "#call" do
+ describe "when go-get=0" do
before do
- env['QUERY_STRING'] = 'go-get=0'
+ env["QUERY_STRING"] = "go-get=0"
end
- it 'skips go-import generation' do
- expect(app).to receive(:call).with(env).and_return('no-go')
+ it "skips go-import generation" do
+ expect(app).to receive(:call).with(env).and_return("no-go")
middleware.call(env)
end
end
- describe 'when go-get=1' do
+ describe "when go-get=1" do
before do
- env['QUERY_STRING'] = 'go-get=1'
- env['PATH_INFO'] = "/#{path}"
+ env["QUERY_STRING"] = "go-get=1"
+ env["PATH_INFO"] = "/#{path}"
end
- shared_examples 'go-get=1' do |enabled_protocol:|
- context 'with simple 2-segment project path' do
+ shared_examples "go-get=1" do |enabled_protocol:|
+ context "with simple 2-segment project path" do
let!(:project) { create(:project, :private) }
- context 'with subpackages' do
+ context "with subpackages" do
let(:path) { "#{project.full_path}/subpackage" }
- it 'returns the full project path' do
+ it "returns the full project path" do
expect_response_with_path(go, enabled_protocol, project.full_path)
end
end
- context 'without subpackages' do
+ context "without subpackages" do
let(:path) { project.full_path }
- it 'returns the full project path' do
+ it "returns the full project path" do
expect_response_with_path(go, enabled_protocol, project.full_path)
end
end
end
- context 'with a nested project path' do
+ context "with a nested project path" do
let(:group) { create(:group, :nested) }
let!(:project) { create(:project, :public, namespace: group) }
- shared_examples 'a nested project' do
- context 'when the project is public' do
- it 'returns the full project path' do
+ shared_examples "a nested project" do
+ context "when the project is public" do
+ it "returns the full project path" do
expect_response_with_path(go, enabled_protocol, project.full_path)
end
end
- context 'when the project is private' do
+ context "when the project is private" do
before do
project.update_attribute(:visibility_level, Project::PRIVATE)
end
- shared_examples 'unauthorized' do
- it 'returns the 2-segment group path' do
+ shared_examples "unauthorized" do
+ it "returns the 2-segment group path" do
expect_response_with_path(go, enabled_protocol, group.full_path)
end
end
- context 'when not authenticated' do
- it_behaves_like 'unauthorized'
+ context "when not authenticated" do
+ it_behaves_like "unauthorized"
end
- context 'when authenticated' do
+ context "when authenticated" do
let(:current_user) { project.creator }
before do
project.team.add_maintainer(current_user)
end
- shared_examples 'authenticated' do
- context 'with access to the project' do
- it 'returns the full project path' do
+ shared_examples "authenticated" do
+ context "with access to the project" do
+ it "returns the full project path" do
expect_response_with_path(go, enabled_protocol, project.full_path)
end
end
- context 'without access to the project' do
+ context "without access to the project" do
before do
project.team.find_member(current_user).destroy
end
- it_behaves_like 'unauthorized'
+ it_behaves_like "unauthorized"
end
- context 'with user is blocked' do
+ context "with user is blocked" do
before do
current_user.block
end
- it_behaves_like 'unauthorized'
+ it_behaves_like "unauthorized"
end
end
- context 'using basic auth' do
- context 'using a personal access token' do
+ context "using basic auth" do
+ context "using a personal access token" do
let(:personal_access_token) { create(:personal_access_token, user: current_user) }
before do
- env['REMOTE_ADDR'] = "192.168.0.1"
- env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(current_user.username, personal_access_token.token)
+ env["REMOTE_ADDR"] = "192.168.0.1"
+ env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(current_user.username, personal_access_token.token)
end
- context 'with api scope' do
- it_behaves_like 'authenticated'
+ context "with api scope" do
+ it_behaves_like "authenticated"
end
- context 'with read_user scope' do
+ context "with read_user scope" do
before do
personal_access_token.update_attribute(:scopes, [:read_user])
end
- it_behaves_like 'unauthorized'
+ it_behaves_like "unauthorized"
end
end
end
@@ -132,66 +132,66 @@ describe Gitlab::Middleware::Go do
end
end
- context 'with subpackages' do
+ context "with subpackages" do
let(:path) { "#{project.full_path}/subpackage" }
- it_behaves_like 'a nested project'
+ it_behaves_like "a nested project"
end
- context 'with a subpackage that is not a valid project path' do
+ context "with a subpackage that is not a valid project path" do
let(:path) { "#{project.full_path}/---subpackage" }
- it_behaves_like 'a nested project'
+ it_behaves_like "a nested project"
end
- context 'without subpackages' do
+ context "without subpackages" do
let(:path) { project.full_path }
- it_behaves_like 'a nested project'
+ it_behaves_like "a nested project"
end
end
- context 'with a bogus path' do
+ context "with a bogus path" do
let(:path) { "http:;url=http:&sol;&sol;www.example.com'http-equiv='refresh'x='?go-get=1" }
- it 'skips go-import generation' do
- expect(app).to receive(:call).and_return('no-go')
+ it "skips go-import generation" do
+ expect(app).to receive(:call).and_return("no-go")
go
end
end
end
- context 'with SSH disabled' do
+ context "with SSH disabled" do
before do
- stub_application_setting(enabled_git_access_protocol: 'http')
+ stub_application_setting(enabled_git_access_protocol: "http")
end
- include_examples 'go-get=1', enabled_protocol: :http
+ include_examples "go-get=1", enabled_protocol: :http
end
- context 'with HTTP disabled' do
+ context "with HTTP disabled" do
before do
- stub_application_setting(enabled_git_access_protocol: 'ssh')
+ stub_application_setting(enabled_git_access_protocol: "ssh")
end
- include_examples 'go-get=1', enabled_protocol: :ssh
+ include_examples "go-get=1", enabled_protocol: :ssh
end
- context 'with nothing disabled' do
+ context "with nothing disabled" do
before do
stub_application_setting(enabled_git_access_protocol: nil)
end
- include_examples 'go-get=1', enabled_protocol: nil
+ include_examples "go-get=1", enabled_protocol: nil
end
- context 'with nothing disabled (blank string)' do
+ context "with nothing disabled (blank string)" do
before do
- stub_application_setting(enabled_git_access_protocol: '')
+ stub_application_setting(enabled_git_access_protocol: "")
end
- include_examples 'go-get=1', enabled_protocol: nil
+ include_examples "go-get=1", enabled_protocol: nil
end
end
@@ -205,10 +205,10 @@ describe Gitlab::Middleware::Go do
"ssh://git@#{Gitlab.config.gitlab.host}/#{path}.git"
when :http, nil
"http://#{Gitlab.config.gitlab.host}/#{path}.git"
- end
+ end
expect(response[0]).to eq(200)
- expect(response[1]['Content-Type']).to eq('text/html')
- expected_body = %{<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /></head></html>}
+ expect(response[1]["Content-Type"]).to eq("text/html")
+ expected_body = %(<html><head><meta name="go-import" content="#{Gitlab.config.gitlab.host}/#{path} git #{repository_url}" /></head></html>)
expect(response[2].body).to eq([expected_body])
end
end
diff --git a/spec/lib/gitlab/middleware/multipart_spec.rb b/spec/lib/gitlab/middleware/multipart_spec.rb
index 3f6ada6832a..00b8e0a620a 100644
--- a/spec/lib/gitlab/middleware/multipart_spec.rb
+++ b/spec/lib/gitlab/middleware/multipart_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
-require 'tempfile'
+require "tempfile"
describe Gitlab::Middleware::Multipart do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
- let(:original_filename) { 'filename' }
+ let(:original_filename) { "filename" }
- shared_examples_for 'multipart upload files' do
- it 'opens top-level files' do
- Tempfile.open('top-level') do |tempfile|
- rewritten = { 'file' => tempfile.path }
- in_params = { 'file.name' => original_filename, 'file.path' => tempfile.path, 'file.remote_id' => remote_id }
- env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, 'gitlab-workhorse')
+ shared_examples_for "multipart upload files" do
+ it "opens top-level files" do
+ Tempfile.open("top-level") do |tempfile|
+ rewritten = {"file" => tempfile.path}
+ in_params = {"file.name" => original_filename, "file.path" => tempfile.path, "file.remote_id" => remote_id}
+ env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, "gitlab-workhorse")
- expect_uploaded_file(tempfile, %w(file))
+ expect_uploaded_file(tempfile, %w[file])
middleware.call(env)
end
end
- it 'opens files one level deep' do
- Tempfile.open('one-level') do |tempfile|
- in_params = { 'user' => { 'avatar' => { '.name' => original_filename, '.path' => tempfile.path, '.remote_id' => remote_id } } }
- rewritten = { 'user[avatar]' => tempfile.path }
- env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, 'gitlab-workhorse')
+ it "opens files one level deep" do
+ Tempfile.open("one-level") do |tempfile|
+ in_params = {"user" => {"avatar" => {".name" => original_filename, ".path" => tempfile.path, ".remote_id" => remote_id}}}
+ rewritten = {"user[avatar]" => tempfile.path}
+ env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, "gitlab-workhorse")
- expect_uploaded_file(tempfile, %w(user avatar))
+ expect_uploaded_file(tempfile, %w[user avatar])
middleware.call(env)
end
end
- it 'opens files two levels deep' do
- Tempfile.open('two-levels') do |tempfile|
- in_params = { 'project' => { 'milestone' => { 'themesong' => { '.name' => original_filename, '.path' => tempfile.path, '.remote_id' => remote_id } } } }
- rewritten = { 'project[milestone][themesong]' => tempfile.path }
- env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, 'gitlab-workhorse')
+ it "opens files two levels deep" do
+ Tempfile.open("two-levels") do |tempfile|
+ in_params = {"project" => {"milestone" => {"themesong" => {".name" => original_filename, ".path" => tempfile.path, ".remote_id" => remote_id}}}}
+ rewritten = {"project[milestone][themesong]" => tempfile.path}
+ env = post_env(rewritten, in_params, Gitlab::Workhorse.secret, "gitlab-workhorse")
- expect_uploaded_file(tempfile, %w(project milestone themesong))
+ expect_uploaded_file(tempfile, %w[project milestone themesong])
middleware.call(env)
end
@@ -55,43 +55,43 @@ describe Gitlab::Middleware::Multipart do
end
end
- it 'rejects headers signed with the wrong secret' do
- env = post_env({ 'file' => '/var/empty/nonesuch' }, {}, 'x' * 32, 'gitlab-workhorse')
+ it "rejects headers signed with the wrong secret" do
+ env = post_env({"file" => "/var/empty/nonesuch"}, {}, "x" * 32, "gitlab-workhorse")
expect { middleware.call(env) }.to raise_error(JWT::VerificationError)
end
- it 'rejects headers signed with the wrong issuer' do
- env = post_env({ 'file' => '/var/empty/nonesuch' }, {}, Gitlab::Workhorse.secret, 'acme-inc')
+ it "rejects headers signed with the wrong issuer" do
+ env = post_env({"file" => "/var/empty/nonesuch"}, {}, Gitlab::Workhorse.secret, "acme-inc")
expect { middleware.call(env) }.to raise_error(JWT::InvalidIssuerError)
end
- context 'with remote file' do
- let(:remote_id) { 'someid' }
+ context "with remote file" do
+ let(:remote_id) { "someid" }
- it_behaves_like 'multipart upload files'
+ it_behaves_like "multipart upload files"
end
- context 'with local file' do
+ context "with local file" do
let(:remote_id) { nil }
- it_behaves_like 'multipart upload files'
+ it_behaves_like "multipart upload files"
end
- it 'allows files in uploads/tmp directory' do
+ it "allows files in uploads/tmp directory" do
Dir.mktmpdir do |dir|
- uploads_dir = File.join(dir, 'public/uploads/tmp')
+ uploads_dir = File.join(dir, "public/uploads/tmp")
FileUtils.mkdir_p(uploads_dir)
allow(Rails).to receive(:root).and_return(dir)
- allow(Dir).to receive(:tmpdir).and_return(File.join(Dir.tmpdir, 'tmpsubdir'))
+ allow(Dir).to receive(:tmpdir).and_return(File.join(Dir.tmpdir, "tmpsubdir"))
- Tempfile.open('top-level', uploads_dir) do |tempfile|
- env = post_env({ 'file' => tempfile.path }, { 'file.name' => original_filename, 'file.path' => tempfile.path }, Gitlab::Workhorse.secret, 'gitlab-workhorse')
+ Tempfile.open("top-level", uploads_dir) do |tempfile|
+ env = post_env({"file" => tempfile.path}, {"file.name" => original_filename, "file.path" => tempfile.path}, Gitlab::Workhorse.secret, "gitlab-workhorse")
expect(app).to receive(:call) do |env|
- expect(get_params(env)['file']).to be_a(::UploadedFile)
+ expect(get_params(env)["file"]).to be_a(::UploadedFile)
end
middleware.call(env)
@@ -99,11 +99,11 @@ describe Gitlab::Middleware::Multipart do
end
end
- it 'allows symlinks for uploads dir' do
- Tempfile.open('two-levels') do |tempfile|
- symlinked_dir = '/some/dir/uploads'
+ it "allows symlinks for uploads dir" do
+ Tempfile.open("two-levels") do |tempfile|
+ symlinked_dir = "/some/dir/uploads"
symlinked_path = File.join(symlinked_dir, File.basename(tempfile.path))
- env = post_env({ 'file' => symlinked_path }, { 'file.name' => original_filename, 'file.path' => symlinked_path }, Gitlab::Workhorse.secret, 'gitlab-workhorse')
+ env = post_env({"file" => symlinked_path}, {"file.name" => original_filename, "file.path" => symlinked_path}, Gitlab::Workhorse.secret, "gitlab-workhorse")
allow(FileUploader).to receive(:root).and_return(symlinked_dir)
allow(UploadedFile).to receive(:allowed_paths).and_return([symlinked_dir, Gitlab.config.uploads.storage_path])
@@ -116,10 +116,10 @@ describe Gitlab::Middleware::Multipart do
# override Dir.tmpdir because this dir is in the list of allowed paths
# and it would match FileUploader.root path (which in this test is linked
# to /tmp too)
- allow(Dir).to receive(:tmpdir).and_return(File.join(Dir.tmpdir, 'tmpsubdir'))
+ allow(Dir).to receive(:tmpdir).and_return(File.join(Dir.tmpdir, "tmpsubdir"))
expect(app).to receive(:call) do |env|
- expect(get_params(env)['file']).to be_a(::UploadedFile)
+ expect(get_params(env)["file"]).to be_a(::UploadedFile)
end
middleware.call(env)
@@ -135,11 +135,11 @@ describe Gitlab::Middleware::Multipart do
end
def post_env(rewritten_fields, params, secret, issuer)
- token = JWT.encode({ 'iss' => issuer, 'rewritten_fields' => rewritten_fields }, secret, 'HS256')
+ token = JWT.encode({"iss" => issuer, "rewritten_fields" => rewritten_fields}, secret, "HS256")
Rack::MockRequest.env_for(
- '/',
- method: 'post',
- params: params,
+ "/",
+ :method => "post",
+ :params => params,
described_class::RACK_ENV_KEY => token
)
end
diff --git a/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb
index 14f2c3cb86f..a102d45ca7e 100644
--- a/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb
+++ b/spec/lib/gitlab/middleware/rails_queue_duration_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Middleware::RailsQueueDuration do
let(:app) { double(:app) }
@@ -7,37 +7,37 @@ describe Gitlab::Middleware::RailsQueueDuration do
let(:transaction) { Gitlab::Metrics::WebTransaction.new(env) }
before do
- expect(app).to receive(:call).with(env).and_return('yay')
+ expect(app).to receive(:call).with(env).and_return("yay")
end
- describe '#call' do
- it 'calls the app when metrics are disabled' do
+ describe "#call" do
+ it "calls the app when metrics are disabled" do
expect(Gitlab::Metrics).to receive(:current_transaction).and_return(nil)
- expect(middleware.call(env)).to eq('yay')
+ expect(middleware.call(env)).to eq("yay")
end
- context 'when metrics are enabled' do
+ context "when metrics are enabled" do
before do
allow(Gitlab::Metrics).to receive(:current_transaction).and_return(transaction)
end
- it 'calls the app when metrics are enabled but no timing header is found' do
- expect(middleware.call(env)).to eq('yay')
+ it "calls the app when metrics are enabled but no timing header is found" do
+ expect(middleware.call(env)).to eq("yay")
end
- it 'sets proxy_flight_time and calls the app when the header is present' do
- env['HTTP_GITLAB_WORKHORSE_PROXY_START'] = '123'
+ it "sets proxy_flight_time and calls the app when the header is present" do
+ env["HTTP_GITLAB_WORKHORSE_PROXY_START"] = "123"
expect(transaction).to receive(:set).with(:rails_queue_duration, an_instance_of(Float))
- expect(middleware.call(env)).to eq('yay')
+ expect(middleware.call(env)).to eq("yay")
end
- it 'observes rails queue duration metrics and calls the app when the header is present' do
- env['HTTP_GITLAB_WORKHORSE_PROXY_START'] = '2000000000'
+ it "observes rails queue duration metrics and calls the app when the header is present" do
+ env["HTTP_GITLAB_WORKHORSE_PROXY_START"] = "2000000000"
expect(middleware.send(:metric_rails_queue_duration_seconds)).to receive(:observe).with(transaction.labels, 1)
Timecop.freeze(Time.at(3)) do
- expect(middleware.call(env)).to eq('yay')
+ expect(middleware.call(env)).to eq("yay")
end
end
end
diff --git a/spec/lib/gitlab/middleware/read_only_spec.rb b/spec/lib/gitlab/middleware/read_only_spec.rb
index 24d49a049b6..f54ed756b69 100644
--- a/spec/lib/gitlab/middleware/read_only_spec.rb
+++ b/spec/lib/gitlab/middleware/read_only_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Middleware::ReadOnly do
include Rack::Test::Methods
using RSpec::Parameterized::TableSyntax
let(:rack_stack) do
- rack = Rack::Builder.new do
+ rack = Rack::Builder.new {
use ActionDispatch::Session::CacheStore
use ActionDispatch::Flash
- end
+ }
rack.run(subject)
rack.to_app
@@ -33,36 +33,36 @@ describe Gitlab::Middleware::ReadOnly do
end
end
- context 'normal requests to a read-only GitLab instance' do
- let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'text/plain' }, ['OK']] } }
+ context "normal requests to a read-only GitLab instance" do
+ let(:fake_app) { lambda { |env| [200, {"Content-Type" => "text/plain"}, ["OK"]] } }
before do
allow(Gitlab::Database).to receive(:read_only?) { true }
end
- it 'expects PATCH requests to be disallowed' do
- response = request.patch('/test_request')
+ it "expects PATCH requests to be disallowed" do
+ response = request.patch("/test_request")
expect(response).to be_redirect
expect(subject).to disallow_request
end
- it 'expects PUT requests to be disallowed' do
- response = request.put('/test_request')
+ it "expects PUT requests to be disallowed" do
+ response = request.put("/test_request")
expect(response).to be_redirect
expect(subject).to disallow_request
end
- it 'expects POST requests to be disallowed' do
- response = request.post('/test_request')
+ it "expects POST requests to be disallowed" do
+ response = request.post("/test_request")
expect(response).to be_redirect
expect(subject).to disallow_request
end
- it 'expects a internal POST request to be allowed after a disallowed request' do
- response = request.post('/test_request')
+ it "expects a internal POST request to be allowed after a disallowed request" do
+ response = request.post("/test_request")
expect(response).to be_redirect
@@ -71,29 +71,29 @@ describe Gitlab::Middleware::ReadOnly do
expect(response).not_to be_redirect
end
- it 'expects DELETE requests to be disallowed' do
- response = request.delete('/test_request')
+ it "expects DELETE requests to be disallowed" do
+ response = request.delete("/test_request")
expect(response).to be_redirect
expect(subject).to disallow_request
end
- it 'expects POST of new file that looks like an LFS batch url to be disallowed' do
+ it "expects POST of new file that looks like an LFS batch url to be disallowed" do
expect(Rails.application.routes).to receive(:recognize_path).and_call_original
- response = request.post('/root/gitlab-ce/new/master/app/info/lfs/objects/batch')
+ response = request.post("/root/gitlab-ce/new/master/app/info/lfs/objects/batch")
expect(response).to be_redirect
expect(subject).to disallow_request
end
- it 'returns last_vistited_url for disallowed request' do
- response = request.post('/test_request')
+ it "returns last_vistited_url for disallowed request" do
+ response = request.post("/test_request")
- expect(response.location).to eq 'http://localhost/'
+ expect(response.location).to eq "http://localhost/"
end
- context 'whitelisted requests' do
- it 'expects a POST internal request to be allowed' do
+ context "whitelisted requests" do
+ it "expects a POST internal request to be allowed" do
expect(Rails.application.routes).not_to receive(:recognize_path)
response = request.post("/api/#{API::API.version}/internal")
@@ -101,15 +101,15 @@ describe Gitlab::Middleware::ReadOnly do
expect(subject).not_to disallow_request
end
- context 'sidekiq admin requests' do
+ context "sidekiq admin requests" do
where(:mounted_at) do
[
- '',
- '/',
- '/gitlab',
- '/gitlab/',
- '/gitlab/gitlab',
- '/gitlab/gitlab/'
+ "",
+ "/",
+ "/gitlab",
+ "/gitlab/",
+ "/gitlab/gitlab",
+ "/gitlab/gitlab/",
]
end
@@ -118,8 +118,8 @@ describe Gitlab::Middleware::ReadOnly do
stub_config_setting(relative_url_root: mounted_at)
end
- it 'allows requests' do
- path = File.join(mounted_at, 'admin/sidekiq')
+ it "allows requests" do
+ path = File.join(mounted_at, "admin/sidekiq")
response = request.post(path)
expect(response).not_to be_redirect
@@ -134,12 +134,12 @@ describe Gitlab::Middleware::ReadOnly do
end
where(:description, :path) do
- 'LFS request to batch' | '/root/rouge.git/info/lfs/objects/batch'
- 'LFS request to locks verify' | '/root/rouge.git/info/lfs/locks/verify'
- 'LFS request to locks create' | '/root/rouge.git/info/lfs/locks'
- 'LFS request to locks unlock' | '/root/rouge.git/info/lfs/locks/1/unlock'
- 'request to git-upload-pack' | '/root/rouge.git/git-upload-pack'
- 'request to git-receive-pack' | '/root/rouge.git/git-receive-pack'
+ "LFS request to batch" | "/root/rouge.git/info/lfs/objects/batch"
+ "LFS request to locks verify" | "/root/rouge.git/info/lfs/locks/verify"
+ "LFS request to locks create" | "/root/rouge.git/info/lfs/locks"
+ "LFS request to locks unlock" | "/root/rouge.git/info/lfs/locks/1/unlock"
+ "request to git-upload-pack" | "/root/rouge.git/git-upload-pack"
+ "request to git-receive-pack" | "/root/rouge.git/git-receive-pack"
end
with_them do
@@ -154,34 +154,34 @@ describe Gitlab::Middleware::ReadOnly do
end
end
- context 'json requests to a read-only GitLab instance' do
- let(:fake_app) { lambda { |env| [200, { 'Content-Type' => 'application/json' }, ['OK']] } }
- let(:content_json) { { 'CONTENT_TYPE' => 'application/json' } }
+ context "json requests to a read-only GitLab instance" do
+ let(:fake_app) { lambda { |env| [200, {"Content-Type" => "application/json"}, ["OK"]] } }
+ let(:content_json) { {"CONTENT_TYPE" => "application/json"} }
before do
allow(Gitlab::Database).to receive(:read_only?) { true }
end
- it 'expects PATCH requests to be disallowed' do
- response = request.patch('/test_request', content_json)
+ it "expects PATCH requests to be disallowed" do
+ response = request.patch("/test_request", content_json)
expect(response).to disallow_request_in_json
end
- it 'expects PUT requests to be disallowed' do
- response = request.put('/test_request', content_json)
+ it "expects PUT requests to be disallowed" do
+ response = request.put("/test_request", content_json)
expect(response).to disallow_request_in_json
end
- it 'expects POST requests to be disallowed' do
- response = request.post('/test_request', content_json)
+ it "expects POST requests to be disallowed" do
+ response = request.post("/test_request", content_json)
expect(response).to disallow_request_in_json
end
- it 'expects DELETE requests to be disallowed' do
- response = request.delete('/test_request', content_json)
+ it "expects DELETE requests to be disallowed" do
+ response = request.delete("/test_request", content_json)
expect(response).to disallow_request_in_json
end
diff --git a/spec/lib/gitlab/middleware/release_env_spec.rb b/spec/lib/gitlab/middleware/release_env_spec.rb
index 5e3aa877409..6ba5a1cca78 100644
--- a/spec/lib/gitlab/middleware/release_env_spec.rb
+++ b/spec/lib/gitlab/middleware/release_env_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Middleware::ReleaseEnv do
- let(:inner_app) { double(:app, call: 'yay') }
+ let(:inner_app) { double(:app, call: "yay") }
let(:app) { described_class.new(inner_app) }
- let(:env) { { 'action_controller.instance' => 'something' } }
+ let(:env) { {"action_controller.instance" => "something"} }
- describe '#call' do
- it 'calls the app and clears the env' do
+ describe "#call" do
+ it "calls the app and clears the env" do
result = app.call(env)
- expect(result).to eq('yay')
+ expect(result).to eq("yay")
expect(env).to be_empty
end
end
diff --git a/spec/lib/gitlab/multi_collection_paginator_spec.rb b/spec/lib/gitlab/multi_collection_paginator_spec.rb
index 28cd704b05a..8efa1069013 100644
--- a/spec/lib/gitlab/multi_collection_paginator_spec.rb
+++ b/spec/lib/gitlab/multi_collection_paginator_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::MultiCollectionPaginator do
subject(:paginator) { described_class.new(Project.all.order(:id), Group.all.order(:id), per_page: 3) }
- it 'combines both collections' do
+ it "combines both collections" do
project = create(:project)
group = create(:group)
expect(paginator.paginate(1)).to eq([project, group])
end
- it 'includes elements second collection if first collection is empty' do
+ it "includes elements second collection if first collection is empty" do
group = create(:group)
expect(paginator.paginate(1)).to eq([group])
end
- context 'with a full first page' do
+ context "with a full first page" do
let!(:all_groups) { create_list(:group, 4) }
let!(:all_projects) { create_list(:project, 4) }
- it 'knows the total count of the collection' do
+ it "knows the total count of the collection" do
expect(paginator.total_count).to eq(8)
end
- it 'fills the first page with elements of the first collection' do
+ it "fills the first page with elements of the first collection" do
expect(paginator.paginate(1)).to eq(all_projects.take(3))
end
- it 'fils the second page with a mixture of the first & second collection' do
+ it "fils the second page with a mixture of the first & second collection" do
first_collection_element = all_projects.last
second_collection_elements = all_groups.take(2)
@@ -37,7 +37,7 @@ describe Gitlab::MultiCollectionPaginator do
expect(paginator.paginate(2)).to eq(expected_collection)
end
- it 'fils the last page with elements from the second collection' do
+ it "fils the last page with elements from the second collection" do
expected_collection = all_groups[-2..-1]
expect(paginator.paginate(3)).to eq(expected_collection)
diff --git a/spec/lib/gitlab/null_request_store_spec.rb b/spec/lib/gitlab/null_request_store_spec.rb
index c023dac53ad..bf39711f5b2 100644
--- a/spec/lib/gitlab/null_request_store_spec.rb
+++ b/spec/lib/gitlab/null_request_store_spec.rb
@@ -1,74 +1,74 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::NullRequestStore do
let(:null_store) { described_class.new }
- describe '#store' do
- it 'returns an empty hash' do
+ describe "#store" do
+ it "returns an empty hash" do
expect(null_store.store).to eq({})
end
end
- describe '#active?' do
- it 'returns falsey' do
+ describe "#active?" do
+ it "returns falsey" do
expect(null_store.active?).to be_falsey
end
end
- describe '#read' do
- it 'returns nil' do
- expect(null_store.read('foo')).to be nil
+ describe "#read" do
+ it "returns nil" do
+ expect(null_store.read("foo")).to be nil
end
end
- describe '#[]' do
- it 'returns nil' do
- expect(null_store['foo']).to be nil
+ describe "#[]" do
+ it "returns nil" do
+ expect(null_store["foo"]).to be nil
end
end
- describe '#write' do
- it 'returns the same value' do
- expect(null_store.write('key', 'value')).to eq('value')
+ describe "#write" do
+ it "returns the same value" do
+ expect(null_store.write("key", "value")).to eq("value")
end
end
- describe '#[]=' do
- it 'returns the same value' do
- expect(null_store['key'] = 'value').to eq('value')
+ describe "#[]=" do
+ it "returns the same value" do
+ expect(null_store["key"] = "value").to eq("value")
end
end
- describe '#exist?' do
- it 'returns falsey' do
- expect(null_store.exist?('foo')).to be_falsey
+ describe "#exist?" do
+ it "returns falsey" do
+ expect(null_store.exist?("foo")).to be_falsey
end
end
- describe '#fetch' do
- it 'returns the block result' do
- expect(null_store.fetch('key') { 'block result' }).to eq('block result')
+ describe "#fetch" do
+ it "returns the block result" do
+ expect(null_store.fetch("key") { "block result" }).to eq("block result")
end
end
- describe '#delete' do
- context 'when a block is given' do
- it 'yields the key to the block' do
- expect do |b|
- null_store.delete('foo', &b)
- end.to yield_with_args('foo')
+ describe "#delete" do
+ context "when a block is given" do
+ it "yields the key to the block" do
+ expect { |b|
+ null_store.delete("foo", &b)
+ }.to yield_with_args("foo")
end
- it 'returns the block result' do
- expect(null_store.delete('foo') { |key| 'block result' }).to eq('block result')
+ it "returns the block result" do
+ expect(null_store.delete("foo") { |key| "block result" }).to eq("block result")
end
end
- context 'when a block is not given' do
- it 'returns nil' do
- expect(null_store.delete('foo')).to be nil
+ context "when a block is not given" do
+ it "returns nil" do
+ expect(null_store.delete("foo")).to be nil
end
end
end
diff --git a/spec/lib/gitlab/object_hierarchy_spec.rb b/spec/lib/gitlab/object_hierarchy_spec.rb
index 4700a7ad2e1..c42f187ef05 100644
--- a/spec/lib/gitlab/object_hierarchy_spec.rb
+++ b/spec/lib/gitlab/object_hierarchy_spec.rb
@@ -1,140 +1,140 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ObjectHierarchy, :postgresql do
let!(:parent) { create(:group) }
let!(:child1) { create(:group, parent: parent) }
let!(:child2) { create(:group, parent: child1) }
- describe '#base_and_ancestors' do
+ describe "#base_and_ancestors" do
let(:relation) do
described_class.new(Group.where(id: child2.id)).base_and_ancestors
end
- it 'includes the base rows' do
+ it "includes the base rows" do
expect(relation).to include(child2)
end
- it 'includes all of the ancestors' do
+ it "includes all of the ancestors" do
expect(relation).to include(parent, child1)
end
- it 'can find ancestors upto a certain level' do
+ it "can find ancestors upto a certain level" do
relation = described_class.new(Group.where(id: child2)).base_and_ancestors(upto: child1)
expect(relation).to contain_exactly(child2)
end
- it 'uses ancestors_base #initialize argument' do
+ it "uses ancestors_base #initialize argument" do
relation = described_class.new(Group.where(id: child2.id), Group.none).base_and_ancestors
expect(relation).to include(parent, child1, child2)
end
- it 'does not allow the use of #update_all' do
+ it "does not allow the use of #update_all" do
expect { relation.update_all(share_with_group_lock: false) }
.to raise_error(ActiveRecord::ReadOnlyRecord)
end
- describe 'hierarchy_order option' do
+ describe "hierarchy_order option" do
let(:relation) do
described_class.new(Group.where(id: child2.id)).base_and_ancestors(hierarchy_order: hierarchy_order)
end
- context ':asc' do
+ context ":asc" do
let(:hierarchy_order) { :asc }
- it 'orders by child to parent' do
+ it "orders by child to parent" do
expect(relation).to eq([child2, child1, parent])
end
end
- context ':desc' do
+ context ":desc" do
let(:hierarchy_order) { :desc }
- it 'orders by parent to child' do
+ it "orders by parent to child" do
expect(relation).to eq([parent, child1, child2])
end
end
end
end
- describe '#base_and_descendants' do
+ describe "#base_and_descendants" do
let(:relation) do
described_class.new(Group.where(id: parent.id)).base_and_descendants
end
- it 'includes the base rows' do
+ it "includes the base rows" do
expect(relation).to include(parent)
end
- it 'includes all the descendants' do
+ it "includes all the descendants" do
expect(relation).to include(child1, child2)
end
- it 'uses descendants_base #initialize argument' do
+ it "uses descendants_base #initialize argument" do
relation = described_class.new(Group.none, Group.where(id: parent.id)).base_and_descendants
expect(relation).to include(parent, child1, child2)
end
- it 'does not allow the use of #update_all' do
+ it "does not allow the use of #update_all" do
expect { relation.update_all(share_with_group_lock: false) }
.to raise_error(ActiveRecord::ReadOnlyRecord)
end
end
- describe '#descendants' do
- it 'includes only the descendants' do
+ describe "#descendants" do
+ it "includes only the descendants" do
relation = described_class.new(Group.where(id: parent)).descendants
expect(relation).to contain_exactly(child1, child2)
end
end
- describe '#ancestors' do
- it 'includes only the ancestors' do
+ describe "#ancestors" do
+ it "includes only the ancestors" do
relation = described_class.new(Group.where(id: child2)).ancestors
expect(relation).to contain_exactly(child1, parent)
end
- it 'can find ancestors upto a certain level' do
+ it "can find ancestors upto a certain level" do
relation = described_class.new(Group.where(id: child2)).ancestors(upto: child1)
expect(relation).to be_empty
end
end
- describe '#all_objects' do
+ describe "#all_objects" do
let(:relation) do
described_class.new(Group.where(id: child1.id)).all_objects
end
- it 'includes the base rows' do
+ it "includes the base rows" do
expect(relation).to include(child1)
end
- it 'includes the ancestors' do
+ it "includes the ancestors" do
expect(relation).to include(parent)
end
- it 'includes the descendants' do
+ it "includes the descendants" do
expect(relation).to include(child2)
end
- it 'uses ancestors_base #initialize argument for ancestors' do
+ it "uses ancestors_base #initialize argument for ancestors" do
relation = described_class.new(Group.where(id: child1.id), Group.where(id: Group.maximum(:id).succ)).all_objects
expect(relation).to include(parent)
end
- it 'uses descendants_base #initialize argument for descendants' do
+ it "uses descendants_base #initialize argument for descendants" do
relation = described_class.new(Group.where(id: Group.maximum(:id).succ), Group.where(id: child1.id)).all_objects
expect(relation).to include(child2)
end
- it 'does not allow the use of #update_all' do
+ it "does not allow the use of #update_all" do
expect { relation.update_all(share_with_group_lock: false) }
.to raise_error(ActiveRecord::ReadOnlyRecord)
end
diff --git a/spec/lib/gitlab/omniauth_initializer_spec.rb b/spec/lib/gitlab/omniauth_initializer_spec.rb
index d808b4d49e0..657134251eb 100644
--- a/spec/lib/gitlab/omniauth_initializer_spec.rb
+++ b/spec/lib/gitlab/omniauth_initializer_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::OmniauthInitializer do
let(:devise_config) { class_double(Devise) }
subject { described_class.new(devise_config) }
- describe '#execute' do
- it 'configures providers from array' do
- generic_config = { 'name' => 'generic' }
+ describe "#execute" do
+ it "configures providers from array" do
+ generic_config = {"name" => "generic"}
expect(devise_config).to receive(:omniauth).with(:generic)
@@ -15,47 +15,47 @@ describe Gitlab::OmniauthInitializer do
end
it 'allows "args" array for app_id and app_secret' do
- legacy_config = { 'name' => 'legacy', 'args' => %w(123 abc) }
+ legacy_config = {"name" => "legacy", "args" => %w[123 abc]}
- expect(devise_config).to receive(:omniauth).with(:legacy, '123', 'abc')
+ expect(devise_config).to receive(:omniauth).with(:legacy, "123", "abc")
subject.execute([legacy_config])
end
- it 'passes app_id and app_secret as additional arguments' do
- twitter_config = { 'name' => 'twitter', 'app_id' => '123', 'app_secret' => 'abc' }
+ it "passes app_id and app_secret as additional arguments" do
+ twitter_config = {"name" => "twitter", "app_id" => "123", "app_secret" => "abc"}
- expect(devise_config).to receive(:omniauth).with(:twitter, '123', 'abc')
+ expect(devise_config).to receive(:omniauth).with(:twitter, "123", "abc")
subject.execute([twitter_config])
end
it 'passes "args" hash as symbolized hash argument' do
- hash_config = { 'name' => 'hash', 'args' => { 'custom' => 'format' } }
+ hash_config = {"name" => "hash", "args" => {"custom" => "format"}}
- expect(devise_config).to receive(:omniauth).with(:hash, custom: 'format')
+ expect(devise_config).to receive(:omniauth).with(:hash, custom: "format")
subject.execute([hash_config])
end
- it 'configures fail_with_empty_uid for shibboleth' do
- shibboleth_config = { 'name' => 'shibboleth', 'args' => {} }
+ it "configures fail_with_empty_uid for shibboleth" do
+ shibboleth_config = {"name" => "shibboleth", "args" => {}}
expect(devise_config).to receive(:omniauth).with(:shibboleth, fail_with_empty_uid: true)
subject.execute([shibboleth_config])
end
- it 'configures remote_sign_out_handler proc for authentiq' do
- authentiq_config = { 'name' => 'authentiq', 'args' => {} }
+ it "configures remote_sign_out_handler proc for authentiq" do
+ authentiq_config = {"name" => "authentiq", "args" => {}}
expect(devise_config).to receive(:omniauth).with(:authentiq, remote_sign_out_handler: an_instance_of(Proc))
subject.execute([authentiq_config])
end
- it 'configures on_single_sign_out proc for cas3' do
- cas3_config = { 'name' => 'cas3', 'args' => {} }
+ it "configures on_single_sign_out proc for cas3" do
+ cas3_config = {"name" => "cas3", "args" => {}}
expect(devise_config).to receive(:omniauth).with(:cas3, on_single_sign_out: an_instance_of(Proc))
diff --git a/spec/lib/gitlab/optimistic_locking_spec.rb b/spec/lib/gitlab/optimistic_locking_spec.rb
index 81f81d4f963..f4028e557d4 100644
--- a/spec/lib/gitlab/optimistic_locking_spec.rb
+++ b/spec/lib/gitlab/optimistic_locking_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::OptimisticLocking do
let!(:pipeline) { create(:ci_pipeline) }
let!(:pipeline2) { Ci::Pipeline.find(pipeline.id) }
- describe '#retry_lock' do
- it 'does not reload object if state changes' do
+ describe "#retry_lock" do
+ it "does not reload object if state changes" do
expect(pipeline).not_to receive(:reload)
expect(pipeline).to receive(:succeed).and_call_original
@@ -14,7 +14,7 @@ describe Gitlab::OptimisticLocking do
end
end
- it 'retries action if exception is raised' do
+ it "retries action if exception is raised" do
pipeline.succeed
expect(pipeline2).to receive(:reload).and_call_original
@@ -25,25 +25,25 @@ describe Gitlab::OptimisticLocking do
end
end
- it 'raises exception when too many retries' do
+ it "raises exception when too many retries" do
expect(pipeline).to receive(:drop).twice.and_call_original
- expect do
+ expect {
described_class.retry_lock(pipeline, 1) do |subject|
subject.lock_version = 100
subject.drop
end
- end.to raise_error(ActiveRecord::StaleObjectError)
+ }.to raise_error(ActiveRecord::StaleObjectError)
end
end
- describe '#retry_optimistic_lock' do
- context 'when locking module is mixed in' do
+ describe "#retry_optimistic_lock" do
+ context "when locking module is mixed in" do
let(:unlockable) do
Class.new.include(described_class).new
end
- it 'is an alias for retry_lock' do
+ it "is an alias for retry_lock" do
expect(unlockable.method(:retry_optimistic_lock))
.to eq unlockable.method(:retry_lock)
end
diff --git a/spec/lib/gitlab/other_markup_spec.rb b/spec/lib/gitlab/other_markup_spec.rb
index e26f39e193e..86ec1fc3911 100644
--- a/spec/lib/gitlab/other_markup_spec.rb
+++ b/spec/lib/gitlab/other_markup_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::OtherMarkup do
let(:context) { {} }
context "XSS Checks" do
links = {
- 'links' => {
- file: 'file.rdoc',
- input: 'XSS[JaVaScriPt:alert(1)]',
- output: "\n" + '<p><a>XSS</a></p>' + "\n"
- }
+ "links" => {
+ file: "file.rdoc",
+ input: "XSS[JaVaScriPt:alert(1)]",
+ output: "\n" + "<p><a>XSS</a></p>" + "\n",
+ },
}
links.each do |name, data|
it "does not convert dangerous #{name} into HTML" do
diff --git a/spec/lib/gitlab/otp_key_rotator_spec.rb b/spec/lib/gitlab/otp_key_rotator_spec.rb
index 6e6e9ce29ac..a483dd87c6f 100644
--- a/spec/lib/gitlab/otp_key_rotator_spec.rb
+++ b/spec/lib/gitlab/otp_key_rotator_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::OtpKeyRotator do
let(:file) { Tempfile.new("otp-key-rotator-test") }
@@ -25,46 +25,46 @@ describe Gitlab::OtpKeyRotator do
value: user.otp_secret,
iv: user.encrypted_otp_secret_iv.unpack("m").join,
salt: user.encrypted_otp_secret_salt.unpack("m").join,
- algorithm: 'aes-256-cbc',
+ algorithm: "aes-256-cbc",
insecure_mode: true,
- key: key
+ key: key,
}
[Encryptor.encrypt(opts)].pack("m")
end
subject(:rotator) { described_class.new(filename) }
- describe '#rotate!' do
+ describe "#rotate!" do
subject(:rotation) { rotator.rotate!(old_key: old_key, new_key: new_key) }
- it 'stores the calculated values in a spreadsheet' do
+ it "stores the calculated values in a spreadsheet" do
rotation
expect(data).to match_array(users.map {|u| build_row(u) })
end
- context 'new key is too short' do
+ context "new key is too short" do
let(:new_key) { "00" * 31 }
it { expect { rotation }.to raise_error(ArgumentError) }
end
- context 'new key is the same as the old key' do
+ context "new key is the same as the old key" do
let(:new_key) { old_key }
it { expect { rotation }.to raise_error(ArgumentError) }
end
end
- describe '#rollback!' do
- it 'updates rows to the old value' do
+ describe "#rollback!" do
+ it "updates rows to the old value" do
file.puts("#{users[0].id},old,new")
file.close
rotator.rollback!
- expect(users[0].reload.encrypted_otp_secret).to eq('old')
- expect(users[1].reload.encrypted_otp_secret).not_to eq('old')
+ expect(users[0].reload.encrypted_otp_secret).to eq("old")
+ expect(users[1].reload.encrypted_otp_secret).not_to eq("old")
end
end
end
diff --git a/spec/lib/gitlab/pages_client_spec.rb b/spec/lib/gitlab/pages_client_spec.rb
index da6d26f4aee..ad3d2429730 100644
--- a/spec/lib/gitlab/pages_client_spec.rb
+++ b/spec/lib/gitlab/pages_client_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PagesClient do
subject { described_class }
- describe '.token' do
- it 'returns the token as it is on disk' do
- pending 'add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466'
- expect(subject.token).to eq(File.read('.gitlab_pages_secret'))
+ describe ".token" do
+ it "returns the token as it is on disk" do
+ pending "add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466"
+ expect(subject.token).to eq(File.read(".gitlab_pages_secret"))
end
end
- describe '.read_or_create_token' do
+ describe ".read_or_create_token" do
subject { described_class.read_or_create_token }
- let(:token_path) { 'tmp/tests/gitlab-pages-secret' }
+ let(:token_path) { "tmp/tests/gitlab-pages-secret" }
before do
allow(described_class).to receive(:token_path).and_return(token_path)
FileUtils.rm_f(token_path)
end
- it 'uses the existing token file if it exists' do
- secret = 'existing secret'
+ it "uses the existing token file if it exists" do
+ secret = "existing secret"
File.write(token_path, secret)
subject
expect(described_class.token).to eq(secret)
end
- it 'creates one if none exists' do
- pending 'add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466'
+ it "creates one if none exists" do
+ pending "add omnibus support for generating the secret file https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/2466"
old_token = described_class.token
# sanity check
@@ -39,15 +39,15 @@ describe Gitlab::PagesClient do
end
end
- describe '.write_token' do
- let(:token_path) { 'tmp/tests/gitlab-pages-secret' }
+ describe ".write_token" do
+ let(:token_path) { "tmp/tests/gitlab-pages-secret" }
before do
allow(described_class).to receive(:token_path).and_return(token_path)
FileUtils.rm_f(token_path)
end
- it 'writes the secret' do
- new_secret = 'hello new secret'
+ it "writes the secret" do
+ new_secret = "hello new secret"
expect(File.exist?(token_path)).to eq(false)
described_class.send(:write_token, new_secret)
@@ -55,37 +55,37 @@ describe Gitlab::PagesClient do
expect(File.read(token_path)).to eq(new_secret)
end
- it 'does nothing if the file already exists' do
- existing_secret = 'hello secret'
+ it "does nothing if the file already exists" do
+ existing_secret = "hello secret"
File.write(token_path, existing_secret)
- described_class.send(:write_token, 'new secret')
+ described_class.send(:write_token, "new secret")
expect(File.read(token_path)).to eq(existing_secret)
end
end
- describe '.load_certificate' do
+ describe ".load_certificate" do
subject { described_class.load_certificate }
before do
allow(described_class).to receive(:config).and_return(config)
end
- context 'with no certificate in the config' do
- let(:config) { double(:config, certificate: '') }
+ context "with no certificate in the config" do
+ let(:config) { double(:config, certificate: "") }
- it 'does not set @certificate' do
+ it "does not set @certificate" do
subject
expect(described_class.certificate).to be_nil
end
end
- context 'with a certificate path in the config' do
- let(:certificate_path) { 'tmp/tests/fake-certificate' }
+ context "with a certificate path in the config" do
+ let(:certificate_path) { "tmp/tests/fake-certificate" }
let(:config) { double(:config, certificate: certificate_path) }
- it 'sets @certificate' do
+ it "sets @certificate" do
certificate_data = "--- BEGIN CERTIFICATE ---\nbla\n--- END CERTIFICATE ---\n"
File.write(certificate_path, certificate_data)
subject
@@ -95,25 +95,25 @@ describe Gitlab::PagesClient do
end
end
- describe '.request_kwargs' do
- let(:token) { 'secret token' }
- let(:auth_header) { 'Bearer c2VjcmV0IHRva2Vu' }
+ describe ".request_kwargs" do
+ let(:token) { "secret token" }
+ let(:auth_header) { "Bearer c2VjcmV0IHRva2Vu" }
before do
allow(described_class).to receive(:token).and_return(token)
end
- context 'without timeout' do
- it { expect(subject.send(:request_kwargs, nil)[:metadata]['authorization']).to eq(auth_header) }
+ context "without timeout" do
+ it { expect(subject.send(:request_kwargs, nil)[:metadata]["authorization"]).to eq(auth_header) }
end
- context 'with timeout' do
+ context "with timeout" do
let(:timeout) { 1.second }
- it 'still sets the authorization header' do
- expect(subject.send(:request_kwargs, timeout)[:metadata]['authorization']).to eq(auth_header)
+ it "still sets the authorization header" do
+ expect(subject.send(:request_kwargs, timeout)[:metadata]["authorization"]).to eq(auth_header)
end
- it 'sets a deadline value' do
+ it "sets a deadline value" do
now = Time.now
deadline = subject.send(:request_kwargs, timeout)[:deadline]
@@ -122,49 +122,49 @@ describe Gitlab::PagesClient do
end
end
- describe '.stub' do
+ describe ".stub" do
before do
- allow(described_class).to receive(:address).and_return('unix:/foo/bar')
+ allow(described_class).to receive(:address).and_return("unix:/foo/bar")
end
it { expect(subject.send(:stub, :health_check)).to be_a(Grpc::Health::V1::Health::Stub) }
end
- describe '.address' do
+ describe ".address" do
subject { described_class.send(:address) }
before do
allow(described_class).to receive(:config).and_return(config)
end
- context 'with a unix: address' do
- let(:config) { double(:config, address: 'unix:/foo/bar') }
+ context "with a unix: address" do
+ let(:config) { double(:config, address: "unix:/foo/bar") }
- it { expect(subject).to eq('unix:/foo/bar') }
+ it { expect(subject).to eq("unix:/foo/bar") }
end
- context 'with a tcp:// address' do
- let(:config) { double(:config, address: 'tcp://localhost:1234') }
+ context "with a tcp:// address" do
+ let(:config) { double(:config, address: "tcp://localhost:1234") }
- it { expect(subject).to eq('localhost:1234') }
+ it { expect(subject).to eq("localhost:1234") }
end
end
- describe '.grpc_creds' do
+ describe ".grpc_creds" do
subject { described_class.send(:grpc_creds) }
before do
allow(described_class).to receive(:config).and_return(config)
end
- context 'with a unix: address' do
- let(:config) { double(:config, address: 'unix:/foo/bar') }
+ context "with a unix: address" do
+ let(:config) { double(:config, address: "unix:/foo/bar") }
it { expect(subject).to eq(:this_channel_is_insecure) }
end
- context 'with a tcp:// address' do
- let(:config) { double(:config, address: 'tcp://localhost:1234') }
+ context "with a tcp:// address" do
+ let(:config) { double(:config, address: "tcp://localhost:1234") }
it { expect(subject).to be_a(GRPC::Core::ChannelCredentials) }
end
diff --git a/spec/lib/gitlab/patch/draw_route_spec.rb b/spec/lib/gitlab/patch/draw_route_spec.rb
index 4009b903dc3..21102f85b08 100644
--- a/spec/lib/gitlab/patch/draw_route_spec.rb
+++ b/spec/lib/gitlab/patch/draw_route_spec.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Patch::DrawRoute do
subject do
- Class.new do
+ Class.new {
include Gitlab::Patch::DrawRoute
def route_path(route_name)
File.expand_path("../../../../#{route_name}", __dir__)
end
- end.new
+ }.new
end
before do
allow(subject).to receive(:instance_eval)
end
- it 'evaluates CE only route' do
+ it "evaluates CE only route" do
subject.draw(:help)
expect(subject).to have_received(:instance_eval)
- .with(File.read(subject.route_path('config/routes/help.rb')))
+ .with(File.read(subject.route_path("config/routes/help.rb")))
.once
expect(subject).to have_received(:instance_eval)
diff --git a/spec/lib/gitlab/patch/prependable_spec.rb b/spec/lib/gitlab/patch/prependable_spec.rb
index 725d733d176..53aa8f4a2e9 100644
--- a/spec/lib/gitlab/patch/prependable_spec.rb
+++ b/spec/lib/gitlab/patch/prependable_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
# Patching ActiveSupport::Concern
-require_relative '../../../../config/initializers/0_as_concern'
+require_relative "../../../../config/initializers/0_as_concern"
describe Gitlab::Patch::Prependable do
before do
@@ -19,7 +19,7 @@ describe Gitlab::Patch::Prependable do
class_methods do
def class_name
- super.tr('C', 'E')
+ super.tr("C", "E")
end
end
@@ -29,7 +29,7 @@ describe Gitlab::Patch::Prependable do
end
def name
- super.tr('c', 'e')
+ super.tr("c", "e")
end
end
end
@@ -45,7 +45,7 @@ describe Gitlab::Patch::Prependable do
class_methods do
def class_name
- 'CE'
+ "CE"
end
end
@@ -55,28 +55,28 @@ describe Gitlab::Patch::Prependable do
end
def name
- 'ce'
+ "ce"
end
end
end
- describe 'a class including a concern prepending a concern' do
+ describe "a class including a concern prepending a concern" do
subject { Class.new.include(ce) }
- it 'returns values from prepended module ee' do
- expect(subject.new.name).to eq('ee')
- expect(subject.class_name).to eq('EE')
+ it "returns values from prepended module ee" do
+ expect(subject.new.name).to eq("ee")
+ expect(subject.class_name).to eq("EE")
end
- it 'has the expected ancestors' do
+ it "has the expected ancestors" do
expect(subject.ancestors.take(3)).to eq([subject, ee, ce])
expect(subject.singleton_class.ancestors.take(3))
.to eq([subject.singleton_class,
ee.const_get(:ClassMethods),
- ce.const_get(:ClassMethods)])
+ ce.const_get(:ClassMethods),])
end
- it 'prepends only once even if called twice' do
+ it "prepends only once even if called twice" do
2.times { ce.prepend(ee) }
subject
@@ -84,50 +84,50 @@ describe Gitlab::Patch::Prependable do
expect(@prepended_modules).to eq([[ce, ee]])
end
- context 'overriding methods' do
+ context "overriding methods" do
before do
subject.module_eval do
def self.class_name
- 'Custom'
+ "Custom"
end
def name
- 'custom'
+ "custom"
end
end
end
- it 'returns values from the class' do
- expect(subject.new.name).to eq('custom')
- expect(subject.class_name).to eq('Custom')
+ it "returns values from the class" do
+ expect(subject.new.name).to eq("custom")
+ expect(subject.class_name).to eq("Custom")
end
end
end
- describe 'a class prepending a concern prepending a concern' do
+ describe "a class prepending a concern prepending a concern" do
subject { Class.new.prepend(ce) }
- it 'returns values from prepended module ee' do
- expect(subject.new.name).to eq('ee')
- expect(subject.class_name).to eq('EE')
+ it "returns values from prepended module ee" do
+ expect(subject.new.name).to eq("ee")
+ expect(subject.class_name).to eq("EE")
end
- it 'has the expected ancestors' do
+ it "has the expected ancestors" do
expect(subject.ancestors.take(3)).to eq([ee, ce, subject])
expect(subject.singleton_class.ancestors.take(3))
.to eq([ee.const_get(:ClassMethods),
ce.const_get(:ClassMethods),
- subject.singleton_class])
+ subject.singleton_class,])
end
- it 'prepends only once' do
+ it "prepends only once" do
subject.prepend(ce)
expect(@prepended_modules).to eq([[ce, ee], [subject, ce]])
end
end
- describe 'a class prepending a concern' do
+ describe "a class prepending a concern" do
subject do
ee_ = ee
@@ -135,35 +135,35 @@ describe Gitlab::Patch::Prependable do
prepend ee_
def self.class_name
- 'CE'
+ "CE"
end
def name
- 'ce'
+ "ce"
end
end
end
- it 'returns values from prepended module ee' do
- expect(subject.new.name).to eq('ee')
- expect(subject.class_name).to eq('EE')
+ it "returns values from prepended module ee" do
+ expect(subject.new.name).to eq("ee")
+ expect(subject.class_name).to eq("EE")
end
- it 'has the expected ancestors' do
+ it "has the expected ancestors" do
expect(subject.ancestors.take(2)).to eq([ee, subject])
expect(subject.singleton_class.ancestors.take(2))
.to eq([ee.const_get(:ClassMethods),
- subject.singleton_class])
+ subject.singleton_class,])
end
- it 'prepends only once' do
+ it "prepends only once" do
subject.prepend(ee)
expect(@prepended_modules).to eq([[subject, ee]])
end
end
- describe 'simple case' do
+ describe "simple case" do
subject do
foo_ = foo
@@ -192,28 +192,28 @@ describe Gitlab::Patch::Prependable do
end
end
- context 'class methods' do
+ context "class methods" do
it "has a method" do
expect(subject).to respond_to(:class_value)
end
- it 'can execute a method' do
+ it "can execute a method" do
expect(subject.class_value).to eq(20)
end
end
- context 'instance methods' do
+ context "instance methods" do
it "has a method" do
expect(subject.new).to respond_to(:value)
end
- it 'chains a method execution' do
+ it "chains a method execution" do
expect(subject.new.value).to eq(100)
end
end
end
- context 'having two prepended blocks' do
+ context "having two prepended blocks" do
subject do
Module.new do
extend ActiveSupport::Concern
diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb
index e90e0aba0a4..db036708fd4 100644
--- a/spec/lib/gitlab/path_regex_spec.rb
+++ b/spec/lib/gitlab/path_regex_spec.rb
@@ -1,11 +1,10 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PathRegex do
# Pass in a full path to remove the format segment:
# `/ci/lint(.:format)` -> `/ci/lint`
def without_format(path)
- path.split('(', 2)[0]
+ path.split("(", 2)[0]
end
# Pass in a full path and get the last segment before a wildcard
@@ -14,12 +13,12 @@ describe Gitlab::PathRegex do
# -> 'builds/artifacts'
def path_before_wildcard(path)
path = path.gsub(STARTING_WITH_NAMESPACE, "")
- path_segments = path.split('/').reject(&:empty?)
+ path_segments = path.split("/").reject(&:empty?)
wildcard_index = path_segments.index { |segment| parameter?(segment) }
segments_before_wildcard = path_segments[0..wildcard_index - 1]
- segments_before_wildcard.join('/')
+ segments_before_wildcard.join("/")
end
def parameter?(segment)
@@ -33,7 +32,7 @@ describe Gitlab::PathRegex do
# `build`
def wildcards_include?(path)
described_class::PROJECT_WILDCARD_ROUTES.include?(path) ||
- described_class::PROJECT_WILDCARD_ROUTES.include?(path.split('/').first)
+ described_class::PROJECT_WILDCARD_ROUTES.include?(path.split("/").first)
end
def failure_message(constant_name, migration_helper, missing_words: [], additional_words: [])
@@ -45,7 +44,7 @@ describe Gitlab::PathRegex do
Found new routes that could cause conflicts with existing namespaced routes
for groups or projects.
- Nest <#{missing_words.join(', ')}> in a route containing `-`, that way
+ Nest <#{missing_words.join(", ")}> in a route containing `-`, that way
we know there will be no conflicts with groups or projects created with those
paths.
@@ -54,7 +53,7 @@ describe Gitlab::PathRegex do
if additional_words.any?
message += <<-ADDITIONAL
- Is <#{additional_words.join(', ')}> in `#{constant_name}` required?
+ Is <#{additional_words.join(", ")}> in `#{constant_name}` required?
If they are really required, update these specs to reflect that.
ADDITIONAL
@@ -68,17 +67,17 @@ describe Gitlab::PathRegex do
routes_collection = route_set.routes
routes_array = routes_collection.routes
- non_legacy_routes = routes_array.reject do |route|
+ non_legacy_routes = routes_array.reject { |route|
route.name.to_s =~ /legacy_(\w*)_redirect/
- end
+ }
- non_deprecated_redirect_routes = non_legacy_routes.reject do |route|
+ non_deprecated_redirect_routes = non_legacy_routes.reject { |route|
app = route.app
# `app.app` is either another app, or `self`. We want to find the final app.
app = app.app while app.try(:app) && app.app != app
- app.is_a?(ActionDispatch::Routing::PathRedirect) && app.block.include?('/-/')
- end
+ app.is_a?(ActionDispatch::Routing::PathRedirect) && app.block.include?("/-/")
+ }
non_deprecated_redirect_routes.map { |route| route.path.spec.to_s }
end
@@ -91,7 +90,7 @@ describe Gitlab::PathRegex do
let(:top_level_words) do
routes_not_starting_in_wildcard
- .map { |route| route.split('/')[1] }
+ .map { |route| route.split("/")[1] }
.concat(ee_top_level_words)
.concat(files_in_public)
.concat(Array(API::API.prefix.to_s))
@@ -100,16 +99,16 @@ describe Gitlab::PathRegex do
end
let(:ee_top_level_words) do
- ['unsubscribes']
+ ["unsubscribes"]
end
let(:files_in_public) do
git = Gitlab.config.git.bin_path
tracked = `cd #{Rails.root} && #{git} ls-files public`
.split("\n")
- .map { |entry| entry.gsub('public/', '') }
+ .map { |entry| entry.gsub("public/", "") }
.uniq
- tracked + %w(assets uploads)
+ tracked + %w[assets uploads]
end
# All routes that start with a namespaced path, that have 1 or more
@@ -139,9 +138,9 @@ describe Gitlab::PathRegex do
# /*namespace_id/:project_id/builds/:build_id/artifacts/file/*path
# -> ['builds/artifacts', 'info/lfs/objects', 'commits', 'artifacts/file']
let(:all_wildcard_paths) do
- namespaced_wildcard_routes.map do |route|
+ namespaced_wildcard_routes.map { |route|
path_before_wildcard(route)
- end.uniq
+ }.uniq
end
STARTING_WITH_GROUP = %r{^/groups/\*(group_)?id/}
@@ -152,18 +151,18 @@ describe Gitlab::PathRegex do
end
let(:paths_after_group_id) do
- group_routes.map do |route|
- route.gsub(STARTING_WITH_GROUP, '').split('/').first
- end.uniq
+ group_routes.map { |route|
+ route.gsub(STARTING_WITH_GROUP, "").split("/").first
+ }.uniq
end
- describe 'TOP_LEVEL_ROUTES' do
- it 'includes all the top level namespaces' do
+ describe "TOP_LEVEL_ROUTES" do
+ it "includes all the top level namespaces" do
failure_block = lambda do
missing_words = top_level_words - described_class::TOP_LEVEL_ROUTES
additional_words = described_class::TOP_LEVEL_ROUTES - top_level_words
- failure_message('TOP_LEVEL_ROUTES', 'rename_root_paths',
- missing_words: missing_words, additional_words: additional_words)
+ failure_message("TOP_LEVEL_ROUTES", "rename_root_paths",
+ missing_words: missing_words, additional_words: additional_words)
end
expect(described_class::TOP_LEVEL_ROUTES)
@@ -171,13 +170,13 @@ describe Gitlab::PathRegex do
end
end
- describe 'GROUP_ROUTES' do
+ describe "GROUP_ROUTES" do
it "don't contain a second wildcard" do
failure_block = lambda do
missing_words = paths_after_group_id - described_class::GROUP_ROUTES
additional_words = described_class::GROUP_ROUTES - paths_after_group_id
- failure_message('GROUP_ROUTES', 'rename_child_paths',
- missing_words: missing_words, additional_words: additional_words)
+ failure_message("GROUP_ROUTES", "rename_child_paths",
+ missing_words: missing_words, additional_words: additional_words)
end
expect(described_class::GROUP_ROUTES)
@@ -185,229 +184,229 @@ describe Gitlab::PathRegex do
end
end
- describe 'PROJECT_WILDCARD_ROUTES' do
- it 'includes all paths that can be used after a namespace/project path' do
+ describe "PROJECT_WILDCARD_ROUTES" do
+ it "includes all paths that can be used after a namespace/project path" do
aggregate_failures do
all_wildcard_paths.each do |path|
expect(wildcards_include?(path))
- .to be(true), failure_message('PROJECT_WILDCARD_ROUTES', 'rename_wildcard_paths', missing_words: path)
+ .to be(true), failure_message("PROJECT_WILDCARD_ROUTES", "rename_wildcard_paths", missing_words: path)
end
end
end
end
- describe '.root_namespace_route_regex' do
+ describe ".root_namespace_route_regex" do
subject { %r{\A#{described_class.root_namespace_route_regex}/\z} }
- it 'rejects top level routes' do
- expect(subject).not_to match('admin/')
- expect(subject).not_to match('api/')
- expect(subject).not_to match('.well-known/')
+ it "rejects top level routes" do
+ expect(subject).not_to match("admin/")
+ expect(subject).not_to match("api/")
+ expect(subject).not_to match(".well-known/")
end
- it 'accepts project wildcard routes' do
- expect(subject).to match('blob/')
- expect(subject).to match('edit/')
- expect(subject).to match('wikis/')
+ it "accepts project wildcard routes" do
+ expect(subject).to match("blob/")
+ expect(subject).to match("edit/")
+ expect(subject).to match("wikis/")
end
- it 'accepts group routes' do
- expect(subject).to match('activity/')
+ it "accepts group routes" do
+ expect(subject).to match("activity/")
end
- it 'is not case sensitive' do
- expect(subject).not_to match('Users/')
+ it "is not case sensitive" do
+ expect(subject).not_to match("Users/")
end
- it 'does not allow extra slashes' do
- expect(subject).not_to match('/blob/')
- expect(subject).not_to match('blob//')
+ it "does not allow extra slashes" do
+ expect(subject).not_to match("/blob/")
+ expect(subject).not_to match("blob//")
end
end
- describe '.full_namespace_path_regex' do
+ describe ".full_namespace_path_regex" do
subject { described_class.full_namespace_path_regex }
- context 'at the top level' do
- context 'when the final level' do
- it 'rejects top level routes' do
- expect(subject).not_to match('admin/')
- expect(subject).not_to match('api/')
- expect(subject).not_to match('.well-known/')
+ context "at the top level" do
+ context "when the final level" do
+ it "rejects top level routes" do
+ expect(subject).not_to match("admin/")
+ expect(subject).not_to match("api/")
+ expect(subject).not_to match(".well-known/")
end
- it 'accepts project wildcard routes' do
- expect(subject).to match('blob/')
- expect(subject).to match('edit/')
- expect(subject).to match('wikis/')
+ it "accepts project wildcard routes" do
+ expect(subject).to match("blob/")
+ expect(subject).to match("edit/")
+ expect(subject).to match("wikis/")
end
- it 'accepts group routes' do
- expect(subject).to match('activity/')
+ it "accepts group routes" do
+ expect(subject).to match("activity/")
end
end
- context 'when more levels follow' do
- it 'rejects top level routes' do
- expect(subject).not_to match('admin/more/')
- expect(subject).not_to match('api/more/')
- expect(subject).not_to match('.well-known/more/')
+ context "when more levels follow" do
+ it "rejects top level routes" do
+ expect(subject).not_to match("admin/more/")
+ expect(subject).not_to match("api/more/")
+ expect(subject).not_to match(".well-known/more/")
end
- it 'accepts project wildcard routes' do
- expect(subject).to match('blob/more/')
- expect(subject).to match('edit/more/')
- expect(subject).to match('wikis/more/')
- expect(subject).to match('environments/folders/')
- expect(subject).to match('info/lfs/objects/')
+ it "accepts project wildcard routes" do
+ expect(subject).to match("blob/more/")
+ expect(subject).to match("edit/more/")
+ expect(subject).to match("wikis/more/")
+ expect(subject).to match("environments/folders/")
+ expect(subject).to match("info/lfs/objects/")
end
- it 'accepts group routes' do
- expect(subject).to match('activity/more/')
+ it "accepts group routes" do
+ expect(subject).to match("activity/more/")
end
end
end
- context 'at the second level' do
- context 'when the final level' do
- it 'accepts top level routes' do
- expect(subject).to match('root/admin/')
- expect(subject).to match('root/api/')
- expect(subject).to match('root/.well-known/')
+ context "at the second level" do
+ context "when the final level" do
+ it "accepts top level routes" do
+ expect(subject).to match("root/admin/")
+ expect(subject).to match("root/api/")
+ expect(subject).to match("root/.well-known/")
end
- it 'rejects project wildcard routes' do
- expect(subject).not_to match('root/blob/')
- expect(subject).not_to match('root/edit/')
- expect(subject).not_to match('root/wikis/')
- expect(subject).not_to match('root/environments/folders/')
- expect(subject).not_to match('root/info/lfs/objects/')
+ it "rejects project wildcard routes" do
+ expect(subject).not_to match("root/blob/")
+ expect(subject).not_to match("root/edit/")
+ expect(subject).not_to match("root/wikis/")
+ expect(subject).not_to match("root/environments/folders/")
+ expect(subject).not_to match("root/info/lfs/objects/")
end
- it 'rejects group routes' do
- expect(subject).not_to match('root/-/')
+ it "rejects group routes" do
+ expect(subject).not_to match("root/-/")
end
end
- context 'when more levels follow' do
- it 'accepts top level routes' do
- expect(subject).to match('root/admin/more/')
- expect(subject).to match('root/api/more/')
- expect(subject).to match('root/.well-known/more/')
+ context "when more levels follow" do
+ it "accepts top level routes" do
+ expect(subject).to match("root/admin/more/")
+ expect(subject).to match("root/api/more/")
+ expect(subject).to match("root/.well-known/more/")
end
- it 'rejects project wildcard routes' do
- expect(subject).not_to match('root/blob/more/')
- expect(subject).not_to match('root/edit/more/')
- expect(subject).not_to match('root/wikis/more/')
- expect(subject).not_to match('root/environments/folders/more/')
- expect(subject).not_to match('root/info/lfs/objects/more/')
+ it "rejects project wildcard routes" do
+ expect(subject).not_to match("root/blob/more/")
+ expect(subject).not_to match("root/edit/more/")
+ expect(subject).not_to match("root/wikis/more/")
+ expect(subject).not_to match("root/environments/folders/more/")
+ expect(subject).not_to match("root/info/lfs/objects/more/")
end
- it 'rejects group routes' do
- expect(subject).not_to match('root/-/')
+ it "rejects group routes" do
+ expect(subject).not_to match("root/-/")
end
end
end
- it 'is not case sensitive' do
- expect(subject).not_to match('root/Blob/')
+ it "is not case sensitive" do
+ expect(subject).not_to match("root/Blob/")
end
- it 'does not allow extra slashes' do
- expect(subject).not_to match('/root/admin/')
- expect(subject).not_to match('root/admin//')
+ it "does not allow extra slashes" do
+ expect(subject).not_to match("/root/admin/")
+ expect(subject).not_to match("root/admin//")
end
end
- describe '.project_route_regex' do
+ describe ".project_route_regex" do
subject { %r{\A#{described_class.project_route_regex}/\z} }
- it 'accepts top level routes' do
- expect(subject).to match('admin/')
- expect(subject).to match('api/')
- expect(subject).to match('.well-known/')
+ it "accepts top level routes" do
+ expect(subject).to match("admin/")
+ expect(subject).to match("api/")
+ expect(subject).to match(".well-known/")
end
- it 'rejects project wildcard routes' do
- expect(subject).not_to match('blob/')
- expect(subject).not_to match('edit/')
- expect(subject).not_to match('wikis/')
- expect(subject).not_to match('environments/folders/')
- expect(subject).not_to match('info/lfs/objects/')
+ it "rejects project wildcard routes" do
+ expect(subject).not_to match("blob/")
+ expect(subject).not_to match("edit/")
+ expect(subject).not_to match("wikis/")
+ expect(subject).not_to match("environments/folders/")
+ expect(subject).not_to match("info/lfs/objects/")
end
- it 'accepts group routes' do
- expect(subject).to match('analytics/')
+ it "accepts group routes" do
+ expect(subject).to match("analytics/")
end
- it 'is not case sensitive' do
- expect(subject).not_to match('Blob/')
+ it "is not case sensitive" do
+ expect(subject).not_to match("Blob/")
end
- it 'does not allow extra slashes' do
- expect(subject).not_to match('/admin/')
- expect(subject).not_to match('admin//')
+ it "does not allow extra slashes" do
+ expect(subject).not_to match("/admin/")
+ expect(subject).not_to match("admin//")
end
end
- describe '.full_project_path_regex' do
+ describe ".full_project_path_regex" do
subject { described_class.full_project_path_regex }
- it 'accepts top level routes' do
- expect(subject).to match('root/admin/')
- expect(subject).to match('root/api/')
- expect(subject).to match('root/.well-known/')
+ it "accepts top level routes" do
+ expect(subject).to match("root/admin/")
+ expect(subject).to match("root/api/")
+ expect(subject).to match("root/.well-known/")
end
- it 'rejects project wildcard routes' do
- expect(subject).not_to match('root/blob/')
- expect(subject).not_to match('root/edit/')
- expect(subject).not_to match('root/wikis/')
- expect(subject).not_to match('root/environments/folders/')
- expect(subject).not_to match('root/info/lfs/objects/')
+ it "rejects project wildcard routes" do
+ expect(subject).not_to match("root/blob/")
+ expect(subject).not_to match("root/edit/")
+ expect(subject).not_to match("root/wikis/")
+ expect(subject).not_to match("root/environments/folders/")
+ expect(subject).not_to match("root/info/lfs/objects/")
end
- it 'accepts group routes' do
- expect(subject).to match('root/analytics/')
+ it "accepts group routes" do
+ expect(subject).to match("root/analytics/")
end
- it 'is not case sensitive' do
- expect(subject).not_to match('root/Blob/')
+ it "is not case sensitive" do
+ expect(subject).not_to match("root/Blob/")
end
- it 'does not allow extra slashes' do
- expect(subject).not_to match('/root/admin/')
- expect(subject).not_to match('root/admin//')
+ it "does not allow extra slashes" do
+ expect(subject).not_to match("/root/admin/")
+ expect(subject).not_to match("root/admin//")
end
end
- describe '.namespace_format_regex' do
+ describe ".namespace_format_regex" do
subject { described_class.namespace_format_regex }
- it { is_expected.to match('gitlab-ce') }
- it { is_expected.to match('gitlab_git') }
- it { is_expected.to match('_underscore.js') }
- it { is_expected.to match('100px.com') }
- it { is_expected.to match('gitlab.org') }
- it { is_expected.not_to match('?gitlab') }
- it { is_expected.not_to match('git lab') }
- it { is_expected.not_to match('gitlab.git') }
- it { is_expected.not_to match('gitlab.org.') }
- it { is_expected.not_to match('gitlab.org/') }
- it { is_expected.not_to match('/gitlab.org') }
- it { is_expected.not_to match('gitlab git') }
+ it { is_expected.to match("gitlab-ce") }
+ it { is_expected.to match("gitlab_git") }
+ it { is_expected.to match("_underscore.js") }
+ it { is_expected.to match("100px.com") }
+ it { is_expected.to match("gitlab.org") }
+ it { is_expected.not_to match("?gitlab") }
+ it { is_expected.not_to match("git lab") }
+ it { is_expected.not_to match("gitlab.git") }
+ it { is_expected.not_to match("gitlab.org.") }
+ it { is_expected.not_to match("gitlab.org/") }
+ it { is_expected.not_to match("/gitlab.org") }
+ it { is_expected.not_to match("gitlab git") }
end
- describe '.project_path_format_regex' do
+ describe ".project_path_format_regex" do
subject { described_class.project_path_format_regex }
- it { is_expected.to match('gitlab-ce') }
- it { is_expected.to match('gitlab_git') }
- it { is_expected.to match('_underscore.js') }
- it { is_expected.to match('100px.com') }
- it { is_expected.not_to match('?gitlab') }
- it { is_expected.not_to match('git lab') }
- it { is_expected.not_to match('gitlab.git') }
+ it { is_expected.to match("gitlab-ce") }
+ it { is_expected.to match("gitlab_git") }
+ it { is_expected.to match("_underscore.js") }
+ it { is_expected.to match("100px.com") }
+ it { is_expected.not_to match("?gitlab") }
+ it { is_expected.not_to match("git lab") }
+ it { is_expected.not_to match("gitlab.git") }
end
end
diff --git a/spec/lib/gitlab/performance_bar_spec.rb b/spec/lib/gitlab/performance_bar_spec.rb
index f480376acb4..27bb27c6423 100644
--- a/spec/lib/gitlab/performance_bar_spec.rb
+++ b/spec/lib/gitlab/performance_bar_spec.rb
@@ -1,96 +1,96 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PerformanceBar do
- shared_examples 'allowed user IDs are cached' do
+ shared_examples "allowed user IDs are cached" do
before do
# Warm the Redis cache
described_class.enabled?(user)
end
- it 'caches the allowed user IDs in cache', :use_clean_rails_memory_store_caching do
- expect do
+ it "caches the allowed user IDs in cache", :use_clean_rails_memory_store_caching do
+ expect {
expect(described_class.enabled?(user)).to be_truthy
- end.not_to exceed_query_limit(0)
+ }.not_to exceed_query_limit(0)
end
end
- describe '.enabled?' do
+ describe ".enabled?" do
let(:user) { create(:user) }
before do
stub_application_setting(performance_bar_allowed_group_id: -1)
end
- it 'returns false when given user is nil' do
+ it "returns false when given user is nil" do
expect(described_class.enabled?(nil)).to be_falsy
end
- it 'returns true when given user is an admin' do
+ it "returns true when given user is an admin" do
user = build_stubbed(:user, :admin)
expect(described_class.enabled?(user)).to be_truthy
end
- it 'returns false when allowed_group_id is nil' do
+ it "returns false when allowed_group_id is nil" do
expect(described_class).to receive(:allowed_group_id).and_return(nil)
expect(described_class.enabled?(user)).to be_falsy
end
- context 'when allowed group ID does not exist' do
- it 'returns false' do
+ context "when allowed group ID does not exist" do
+ it "returns false" do
expect(described_class.enabled?(user)).to be_falsy
end
end
- context 'when allowed group exists' do
- let!(:my_group) { create(:group, path: 'my-group') }
+ context "when allowed group exists" do
+ let!(:my_group) { create(:group, path: "my-group") }
before do
stub_application_setting(performance_bar_allowed_group_id: my_group.id)
end
- context 'when user is not a member of the allowed group' do
- it 'returns false' do
+ context "when user is not a member of the allowed group" do
+ it "returns false" do
expect(described_class.enabled?(user)).to be_falsy
end
- it_behaves_like 'allowed user IDs are cached'
+ it_behaves_like "allowed user IDs are cached"
end
- context 'when user is a member of the allowed group' do
+ context "when user is a member of the allowed group" do
before do
my_group.add_developer(user)
end
- it 'returns true' do
+ it "returns true" do
expect(described_class.enabled?(user)).to be_truthy
end
- it_behaves_like 'allowed user IDs are cached'
+ it_behaves_like "allowed user IDs are cached"
end
end
- context 'when allowed group is nested', :nested_groups do
- let!(:nested_my_group) { create(:group, parent: create(:group, path: 'my-org'), path: 'my-group') }
+ context "when allowed group is nested", :nested_groups do
+ let!(:nested_my_group) { create(:group, parent: create(:group, path: "my-org"), path: "my-group") }
before do
- create(:group, path: 'my-group')
+ create(:group, path: "my-group")
nested_my_group.add_developer(user)
stub_application_setting(performance_bar_allowed_group_id: nested_my_group.id)
end
- it 'returns the nested group' do
+ it "returns the nested group" do
expect(described_class.enabled?(user)).to be_truthy
end
end
- context 'when a nested group has the same path', :nested_groups do
+ context "when a nested group has the same path", :nested_groups do
before do
- create(:group, :nested, path: 'my-group').add_developer(user)
+ create(:group, :nested, path: "my-group").add_developer(user)
end
- it 'returns false' do
+ it "returns false" do
expect(described_class.enabled?(user)).to be_falsy
end
end
diff --git a/spec/lib/gitlab/plugin_spec.rb b/spec/lib/gitlab/plugin_spec.rb
index 33dd4f79130..6b9ef05998a 100644
--- a/spec/lib/gitlab/plugin_spec.rb
+++ b/spec/lib/gitlab/plugin_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Plugin do
- describe '.execute' do
+ describe ".execute" do
let(:data) { Gitlab::DataBuilder::Push::SAMPLE_DATA }
- let(:plugin) { Rails.root.join('plugins', 'test.rb') }
- let(:tmp_file) { Tempfile.new('plugin-dump') }
+ let(:plugin) { Rails.root.join("plugins", "test.rb") }
+ let(:tmp_file) { Tempfile.new("plugin-dump") }
let(:result) { described_class.execute(plugin.to_s, data) }
let(:success) { result.first }
let(:message) { result.last }
@@ -25,7 +25,7 @@ describe Gitlab::Plugin do
FileUtils.rm(plugin)
end
- context 'successful execution' do
+ context "successful execution" do
before do
File.chmod(0o777, plugin)
end
@@ -37,19 +37,19 @@ describe Gitlab::Plugin do
it { expect(success).to be true }
it { expect(message).to be_empty }
- it 'ensures plugin received data via stdin' do
+ it "ensures plugin received data via stdin" do
result
expect(File.read(tmp_file.path)).to eq(data.to_json)
end
end
- context 'non-executable' do
+ context "non-executable" do
it { expect(success).to be false }
- it { expect(message).to include('Permission denied') }
+ it { expect(message).to include("Permission denied") }
end
- context 'non-zero exit' do
+ context "non-zero exit" do
let(:plugin_source) do
<<~EOS
#!/usr/bin/env ruby
diff --git a/spec/lib/gitlab/polling_interval_spec.rb b/spec/lib/gitlab/polling_interval_spec.rb
index eb8e618156b..ab2c80288fb 100644
--- a/spec/lib/gitlab/polling_interval_spec.rb
+++ b/spec/lib/gitlab/polling_interval_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PollingInterval do
let(:polling_interval) { described_class }
- describe '.set_header' do
+ describe ".set_header" do
let(:headers) { {} }
let(:response) { double(headers: headers) }
- context 'when polling is disabled' do
+ context "when polling is disabled" do
before do
stub_application_setting(polling_interval_multiplier: 0)
end
- it 'sets value to -1' do
+ it "sets value to -1" do
polling_interval.set_header(response, interval: 10_000)
- expect(headers['Poll-Interval']).to eq('-1')
+ expect(headers["Poll-Interval"]).to eq("-1")
end
end
- context 'when polling is enabled' do
+ context "when polling is enabled" do
before do
stub_application_setting(polling_interval_multiplier: 0.33333)
end
- it 'applies modifier to base interval' do
+ it "applies modifier to base interval" do
polling_interval.set_header(response, interval: 10_000)
- expect(headers['Poll-Interval']).to eq('3333')
+ expect(headers["Poll-Interval"]).to eq("3333")
end
end
end
diff --git a/spec/lib/gitlab/popen/runner_spec.rb b/spec/lib/gitlab/popen/runner_spec.rb
index 2e2cb4ca28f..d622d4edf4a 100644
--- a/spec/lib/gitlab/popen/runner_spec.rb
+++ b/spec/lib/gitlab/popen/runner_spec.rb
@@ -1,123 +1,124 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Popen::Runner do
subject { described_class.new }
- describe '#run' do
- it 'runs the command and returns the result' do
+ describe "#run" do
+ it "runs the command and returns the result" do
run_command
expect(Gitlab::Popen).to have_received(:popen_with_detail)
end
end
- describe '#all_success_and_clean?' do
- it 'returns true when exit status is 0 and stderr is empty' do
+ describe "#all_success_and_clean?" do
+ it "returns true when exit status is 0 and stderr is empty" do
run_command
expect(subject).to be_all_success_and_clean
end
- it 'returns false when exit status is not 0' do
+ it "returns false when exit status is not 0" do
run_command(exitstatus: 1)
expect(subject).not_to be_all_success_and_clean
end
- it 'returns false when exit stderr has something' do
- run_command(stderr: 'stderr')
+ it "returns false when exit stderr has something" do
+ run_command(stderr: "stderr")
expect(subject).not_to be_all_success_and_clean
end
end
- describe '#all_success?' do
- it 'returns true when exit status is 0' do
+ describe "#all_success?" do
+ it "returns true when exit status is 0" do
run_command
expect(subject).to be_all_success
end
- it 'returns false when exit status is not 0' do
+ it "returns false when exit status is not 0" do
run_command(exitstatus: 1)
expect(subject).not_to be_all_success
end
- it 'returns true' do
- run_command(stderr: 'stderr')
+ it "returns true" do
+ run_command(stderr: "stderr")
expect(subject).to be_all_success
end
end
- describe '#all_stderr_empty?' do
- it 'returns true when stderr is empty' do
+ describe "#all_stderr_empty?" do
+ it "returns true when stderr is empty" do
run_command
expect(subject).to be_all_stderr_empty
end
- it 'returns true when exit status is not 0' do
+ it "returns true when exit status is not 0" do
run_command(exitstatus: 1)
expect(subject).to be_all_stderr_empty
end
- it 'returns false when exit stderr has something' do
- run_command(stderr: 'stderr')
+ it "returns false when exit stderr has something" do
+ run_command(stderr: "stderr")
expect(subject).not_to be_all_stderr_empty
end
end
- describe '#failed_results' do
- it 'returns [] when everything is passed' do
+ describe "#failed_results" do
+ it "returns [] when everything is passed" do
run_command
expect(subject.failed_results).to be_empty
end
- it 'returns the result when exit status is not 0' do
+ it "returns the result when exit status is not 0" do
result = run_command(exitstatus: 1)
expect(subject.failed_results).to contain_exactly(result)
end
- it 'returns [] when exit stderr has something' do
- run_command(stderr: 'stderr')
+ it "returns [] when exit stderr has something" do
+ run_command(stderr: "stderr")
expect(subject.failed_results).to be_empty
end
end
- describe '#warned_results' do
- it 'returns [] when everything is passed' do
+ describe "#warned_results" do
+ it "returns [] when everything is passed" do
run_command
expect(subject.warned_results).to be_empty
end
- it 'returns [] when exit status is not 0' do
+ it "returns [] when exit status is not 0" do
run_command(exitstatus: 1)
expect(subject.warned_results).to be_empty
end
- it 'returns the result when exit stderr has something' do
- result = run_command(stderr: 'stderr')
+ it "returns the result when exit stderr has something" do
+ result = run_command(stderr: "stderr")
expect(subject.warned_results).to contain_exactly(result)
end
end
def run_command(
- command: 'command',
- stdout: 'stdout',
- stderr: '',
+ command: "command",
+ stdout: "stdout",
+ stderr: "",
exitstatus: 0,
status: double(exitstatus: exitstatus, success?: exitstatus.zero?),
- duration: 0.1)
+ duration: 0.1
+ )
result =
Gitlab::Popen::Result.new(command, stdout, stderr, status, duration)
diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb
index c1b84e9f077..bbc1266f298 100644
--- a/spec/lib/gitlab/popen_spec.rb
+++ b/spec/lib/gitlab/popen_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Popen do
- let(:path) { Rails.root.join('tmp').to_s }
+ let(:path) { Rails.root.join("tmp").to_s }
before do
@klass = Class.new(Object)
@klass.send(:include, described_class)
end
- describe '.popen_with_detail' do
+ describe ".popen_with_detail" do
subject { @klass.new.popen_with_detail(cmd) }
let(:cmd) { %W[#{Gem.ruby} -e $stdout.puts(1);$stderr.puts(2);exit(3)] }
@@ -20,47 +20,47 @@ describe Gitlab::Popen do
it { expect(subject.duration).to be_kind_of(Numeric) }
end
- context 'zero status' do
+ context "zero status" do
before do
- @output, @status = @klass.new.popen(%w(ls), path)
+ @output, @status = @klass.new.popen(%w[ls], path)
end
it { expect(@status).to be_zero }
- it { expect(@output).to include('tests') }
+ it { expect(@output).to include("tests") }
end
- context 'non-zero status' do
+ context "non-zero status" do
before do
- @output, @status = @klass.new.popen(%w(cat NOTHING), path)
+ @output, @status = @klass.new.popen(%w[cat NOTHING], path)
end
it { expect(@status).to eq(1) }
- it { expect(@output).to include('No such file or directory') }
+ it { expect(@output).to include("No such file or directory") }
end
- context 'unsafe string command' do
- it 'raises an error when it gets called with a string argument' do
- expect { @klass.new.popen('ls', path) }.to raise_error(RuntimeError)
+ context "unsafe string command" do
+ it "raises an error when it gets called with a string argument" do
+ expect { @klass.new.popen("ls", path) }.to raise_error(RuntimeError)
end
end
- context 'with custom options' do
- let(:vars) { { 'foobar' => 123, 'PWD' => path } }
- let(:options) { { chdir: path } }
+ context "with custom options" do
+ let(:vars) { {"foobar" => 123, "PWD" => path} }
+ let(:options) { {chdir: path} }
- it 'calls popen3 with the provided environment variables' do
- expect(Open3).to receive(:popen3).with(vars, 'ls', options)
+ it "calls popen3 with the provided environment variables" do
+ expect(Open3).to receive(:popen3).with(vars, "ls", options)
- @output, @status = @klass.new.popen(%w(ls), path, { 'foobar' => 123 })
+ @output, @status = @klass.new.popen(%w[ls], path, {"foobar" => 123})
end
end
- context 'with a process that writes a lot of data to stderr' do
- let(:test_string) { 'The quick brown fox jumped over the lazy dog' }
+ context "with a process that writes a lot of data to stderr" do
+ let(:test_string) { "The quick brown fox jumped over the lazy dog" }
# The pipe buffer is typically 64K. This string is about 440K.
- let(:spew_command) { ['bash', '-c', "for i in {1..10000}; do echo '#{test_string}' 1>&2; done"] }
+ let(:spew_command) { ["bash", "-c", "for i in {1..10000}; do echo '#{test_string}' 1>&2; done"] }
- it 'returns zero' do
+ it "returns zero" do
output, status = @klass.new.popen(spew_command, path)
expect(output).to include(test_string)
@@ -68,21 +68,21 @@ describe Gitlab::Popen do
end
end
- context 'without a directory argument' do
+ context "without a directory argument" do
before do
- @output, @status = @klass.new.popen(%w(ls))
+ @output, @status = @klass.new.popen(%w[ls])
end
it { expect(@status).to be_zero }
- it { expect(@output).to include('spec') }
+ it { expect(@output).to include("spec") }
end
- context 'use stdin' do
+ context "use stdin" do
before do
- @output, @status = @klass.new.popen(%w[cat]) { |stdin| stdin.write 'hello' }
+ @output, @status = @klass.new.popen(%w[cat]) { |stdin| stdin.write "hello" }
end
it { expect(@status).to be_zero }
- it { expect(@output).to eq('hello') }
+ it { expect(@output).to eq("hello") }
end
end
diff --git a/spec/lib/gitlab/private_commit_email_spec.rb b/spec/lib/gitlab/private_commit_email_spec.rb
index 10bf624bbdd..b4cc1867c2d 100644
--- a/spec/lib/gitlab/private_commit_email_spec.rb
+++ b/spec/lib/gitlab/private_commit_email_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PrivateCommitEmail do
let(:hostname) { Gitlab::CurrentSettings.current_application_settings.commit_email_hostname }
@@ -8,41 +8,41 @@ describe Gitlab::PrivateCommitEmail do
let(:valid_email) { "#{id}-foo@#{hostname}" }
let(:invalid_email) { "#{id}-foo@users.noreply.bar.com" }
- context '.regex' do
+ context ".regex" do
subject { described_class.regex }
it { is_expected.to match("1-foo@#{hostname}") }
it { is_expected.not_to match("1-foo@#{hostname}.foo") }
- it { is_expected.not_to match('1-foo@users.noreply.gitlab.com') }
- it { is_expected.not_to match('foo-1@users.noreply.gitlab.com') }
- it { is_expected.not_to match('foobar@gitlab.com') }
+ it { is_expected.not_to match("1-foo@users.noreply.gitlab.com") }
+ it { is_expected.not_to match("foo-1@users.noreply.gitlab.com") }
+ it { is_expected.not_to match("foobar@gitlab.com") }
end
- context '.user_id_for_email' do
- it 'parses user id from email' do
+ context ".user_id_for_email" do
+ it "parses user id from email" do
expect(described_class.user_id_for_email(valid_email)).to eq(id)
end
- it 'returns nil on invalid commit email' do
+ it "returns nil on invalid commit email" do
expect(described_class.user_id_for_email(invalid_email)).to be_nil
end
end
- context '.user_ids_for_email' do
- it 'returns deduplicated user IDs for each valid email' do
+ context ".user_ids_for_email" do
+ it "returns deduplicated user IDs for each valid email" do
result = described_class.user_ids_for_emails([valid_email, valid_email, invalid_email])
expect(result).to eq([id])
end
- it 'returns an empty array with no valid emails' do
+ it "returns an empty array with no valid emails" do
result = described_class.user_ids_for_emails([invalid_email])
expect(result).to eq([])
end
end
- context '.for_user' do
- it 'returns email in the format id-username@hostname' do
+ context ".for_user" do
+ it "returns email in the format id-username@hostname" do
user = create(:user)
expect(described_class.for_user(user)).to eq("#{user.id}-#{user.username}@#{hostname}")
diff --git a/spec/lib/gitlab/profiler_spec.rb b/spec/lib/gitlab/profiler_spec.rb
index 9f2214f7ce7..8811e5100b6 100644
--- a/spec/lib/gitlab/profiler_spec.rb
+++ b/spec/lib/gitlab/profiler_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Profiler do
- let(:null_logger) { Logger.new('/dev/null') }
- let(:private_token) { 'private' }
+ let(:null_logger) { Logger.new("/dev/null") }
+ let(:private_token) { "private" }
- describe '.profile' do
+ describe ".profile" do
let(:app) { double(:app) }
before do
@@ -12,114 +12,114 @@ describe Gitlab::Profiler do
allow(app).to receive(:get)
end
- it 'returns a profile result' do
- expect(described_class.profile('/')).to be_an_instance_of(RubyProf::Profile)
+ it "returns a profile result" do
+ expect(described_class.profile("/")).to be_an_instance_of(RubyProf::Profile)
end
- it 'uses the custom logger given' do
+ it "uses the custom logger given" do
expect(described_class).to receive(:create_custom_logger)
- .with(null_logger, private_token: anything)
- .and_call_original
+ .with(null_logger, private_token: anything)
+ .and_call_original
- described_class.profile('/', logger: null_logger)
+ described_class.profile("/", logger: null_logger)
end
- it 'sends a POST request when data is passed' do
+ it "sends a POST request when data is passed" do
post_data = '{"a":1}'
expect(app).to receive(:post).with(anything, post_data, anything)
- described_class.profile('/', post_data: post_data)
+ described_class.profile("/", post_data: post_data)
end
- it 'uses the private_token for auth if given' do
- expect(app).to receive(:get).with('/', nil, 'Private-Token' => private_token)
- expect(app).to receive(:get).with('/api/v4/users')
+ it "uses the private_token for auth if given" do
+ expect(app).to receive(:get).with("/", nil, "Private-Token" => private_token)
+ expect(app).to receive(:get).with("/api/v4/users")
- described_class.profile('/', private_token: private_token)
+ described_class.profile("/", private_token: private_token)
end
- it 'uses the user for auth if given' do
+ it "uses the user for auth if given" do
user = double(:user)
expect(described_class).to receive(:with_user).with(user)
- described_class.profile('/', user: user)
+ described_class.profile("/", user: user)
end
- it 'uses the private_token for auth if both it and user are set' do
+ it "uses the private_token for auth if both it and user are set" do
user = double(:user)
expect(described_class).to receive(:with_user).with(nil).and_call_original
- expect(app).to receive(:get).with('/', nil, 'Private-Token' => private_token)
- expect(app).to receive(:get).with('/api/v4/users')
+ expect(app).to receive(:get).with("/", nil, "Private-Token" => private_token)
+ expect(app).to receive(:get).with("/api/v4/users")
- described_class.profile('/', user: user, private_token: private_token)
+ described_class.profile("/", user: user, private_token: private_token)
end
end
- describe '.create_custom_logger' do
- it 'does nothing when nil is passed' do
+ describe ".create_custom_logger" do
+ it "does nothing when nil is passed" do
expect(described_class.create_custom_logger(nil)).to be_nil
end
- context 'the new logger' do
+ context "the new logger" do
let(:custom_logger) do
described_class.create_custom_logger(null_logger, private_token: private_token)
end
- it 'does not affect the existing logger' do
+ it "does not affect the existing logger" do
expect(null_logger).not_to receive(:debug)
expect(custom_logger).to receive(:debug).and_call_original
- custom_logger.debug('Foo')
+ custom_logger.debug("Foo")
end
- it 'strips out the private token' do
+ it "strips out the private token" do
expect(custom_logger).to receive(:add) do |severity, _progname, message|
- next if message.include?('spec/')
+ next if message.include?("spec/")
expect(severity).to eq(Logger::DEBUG)
- expect(message).to include('public').and include(described_class::FILTERED_STRING)
+ expect(message).to include("public").and include(described_class::FILTERED_STRING)
expect(message).not_to include(private_token)
end.twice
custom_logger.debug("public #{private_token}")
end
- it 'tracks model load times by model' do
- custom_logger.debug('This is not a model load')
- custom_logger.debug('User Load (1.2ms)')
- custom_logger.debug('User Load (1.3ms)')
- custom_logger.debug('Project Load (10.4ms)')
+ it "tracks model load times by model" do
+ custom_logger.debug("This is not a model load")
+ custom_logger.debug("User Load (1.2ms)")
+ custom_logger.debug("User Load (1.3ms)")
+ custom_logger.debug("Project Load (10.4ms)")
- expect(custom_logger.load_times_by_model).to eq('User' => [1.2, 1.3],
- 'Project' => [10.4])
+ expect(custom_logger.load_times_by_model).to eq("User" => [1.2, 1.3],
+ "Project" => [10.4])
end
- it 'logs the backtrace, ignoring lines as appropriate' do
+ it "logs the backtrace, ignoring lines as appropriate" do
# Skip Rails's backtrace cleaning.
allow(Rails.backtrace_cleaner).to receive(:clean, &:itself)
expect(custom_logger).to receive(:add)
- .with(Logger::DEBUG,
- anything,
- a_string_matching(File.basename(__FILE__)))
- .twice
+ .with(Logger::DEBUG,
+ anything,
+ a_string_matching(File.basename(__FILE__)))
+ .twice
expect(custom_logger).not_to receive(:add).with(Logger::DEBUG,
- anything,
- a_string_matching('lib/gitlab/profiler.rb'))
+ anything,
+ a_string_matching("lib/gitlab/profiler.rb"))
# Force a part of the backtrace to be in the (ignored) profiler source
# file.
- described_class.with_custom_logger(nil) { custom_logger.debug('Foo') }
+ described_class.with_custom_logger(nil) { custom_logger.debug("Foo") }
end
end
end
- describe '.clean_backtrace' do
- it 'uses the Rails backtrace cleaner' do
+ describe ".clean_backtrace" do
+ it "uses the Rails backtrace cleaner" do
backtrace = []
expect(Rails.backtrace_cleaner).to receive(:clean).with(backtrace)
@@ -127,7 +127,7 @@ describe Gitlab::Profiler do
described_class.clean_backtrace(backtrace)
end
- it 'removes lines from IGNORE_BACKTRACES' do
+ it "removes lines from IGNORE_BACKTRACES" do
backtrace = [
"lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'",
"lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'",
@@ -145,46 +145,46 @@ describe Gitlab::Profiler do
"lib/gitlab/middleware/multipart.rb:95:in `call'",
"lib/gitlab/request_profiler/middleware.rb:14:in `call'",
"ee/lib/gitlab/database/load_balancing/rack_middleware.rb:37:in `call'",
- "ee/lib/gitlab/jira/middleware.rb:15:in `call'"
+ "ee/lib/gitlab/jira/middleware.rb:15:in `call'",
]
expect(described_class.clean_backtrace(backtrace))
.to eq([
- "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'",
- "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'",
- "lib/gitlab/gitaly_client.rb:280:in `block in migrate'",
- "lib/gitlab/gitaly_client.rb:278:in `migrate'",
- "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'",
- "lib/gitlab/git/commit.rb:66:in `find'",
- "app/models/repository.rb:1047:in `find_commit'",
- "app/models/repository.rb:113:in `commit'",
- "ee/lib/gitlab/jira/middleware.rb:15:in `call'"
- ])
+ "lib/gitlab/gitaly_client.rb:294:in `block (2 levels) in migrate'",
+ "lib/gitlab/gitaly_client.rb:331:in `allow_n_plus_1_calls'",
+ "lib/gitlab/gitaly_client.rb:280:in `block in migrate'",
+ "lib/gitlab/gitaly_client.rb:278:in `migrate'",
+ "lib/gitlab/git/repository.rb:1451:in `gitaly_migrate'",
+ "lib/gitlab/git/commit.rb:66:in `find'",
+ "app/models/repository.rb:1047:in `find_commit'",
+ "app/models/repository.rb:113:in `commit'",
+ "ee/lib/gitlab/jira/middleware.rb:15:in `call'",
+ ])
end
end
- describe '.with_custom_logger' do
- context 'when the logger is set' do
- it 'uses the replacement logger for the duration of the block' do
+ describe ".with_custom_logger" do
+ context "when the logger is set" do
+ it "uses the replacement logger for the duration of the block" do
expect(null_logger).to receive(:debug).and_call_original
- expect { described_class.with_custom_logger(null_logger) { ActiveRecord::Base.logger.debug('foo') } }
+ expect { described_class.with_custom_logger(null_logger) { ActiveRecord::Base.logger.debug("foo") } }
.to not_change { ActiveRecord::Base.logger }
.and not_change { ActionController::Base.logger }
.and not_change { ActiveSupport::LogSubscriber.colorize_logging }
end
- it 'returns the result of the block' do
+ it "returns the result of the block" do
expect(described_class.with_custom_logger(null_logger) { 2 }).to eq(2)
end
end
- context 'when the logger is nil' do
- it 'returns the result of the block' do
+ context "when the logger is nil" do
+ it "returns the result of the block" do
expect(described_class.with_custom_logger(nil) { 2 }).to eq(2)
end
- it 'does not modify the standard Rails loggers' do
+ it "does not modify the standard Rails loggers" do
expect { described_class.with_custom_logger(nil) {} }
.to not_change { ActiveRecord::Base.logger }
.and not_change { ActionController::Base.logger }
@@ -193,22 +193,22 @@ describe Gitlab::Profiler do
end
end
- describe '.with_user' do
- context 'when the user is set' do
+ describe ".with_user" do
+ context "when the user is set" do
let(:user) { double(:user) }
- it 'overrides auth in ApplicationController to use the given user' do
+ it "overrides auth in ApplicationController to use the given user" do
expect(described_class.with_user(user) { ApplicationController.new.current_user }).to eq(user)
end
- it 'cleans up ApplicationController afterwards' do
+ it "cleans up ApplicationController afterwards" do
expect { described_class.with_user(user) {} }
.to not_change { ActionController.instance_methods(false) }
end
end
- context 'when the user is nil' do
- it 'does not define methods on ApplicationController' do
+ context "when the user is nil" do
+ it "does not define methods on ApplicationController" do
expect(ApplicationController).not_to receive(:define_method)
described_class.with_user(nil) {}
@@ -216,20 +216,20 @@ describe Gitlab::Profiler do
end
end
- describe '.log_load_times_by_model' do
- it 'logs the model, query count, and time by slowest first' do
+ describe ".log_load_times_by_model" do
+ it "logs the model, query count, and time by slowest first" do
expect(null_logger).to receive(:load_times_by_model).and_return(
- 'User' => [1.2, 1.3],
- 'Project' => [10.4]
+ "User" => [1.2, 1.3],
+ "Project" => [10.4]
)
- expect(null_logger).to receive(:info).with('Project total (1): 10.4ms')
- expect(null_logger).to receive(:info).with('User total (2): 2.5ms')
+ expect(null_logger).to receive(:info).with("Project total (1): 10.4ms")
+ expect(null_logger).to receive(:info).with("User total (2): 2.5ms")
described_class.log_load_times_by_model(null_logger)
end
- it 'does nothing when called with a logger that does not have load times' do
+ it "does nothing when called with a logger that does not have load times" do
expect(null_logger).not_to receive(:info)
expect(described_class.log_load_times_by_model(null_logger)).to be_nil
diff --git a/spec/lib/gitlab/project_authorizations_spec.rb b/spec/lib/gitlab/project_authorizations_spec.rb
index bd0bc2c9044..74ee57716e6 100644
--- a/spec/lib/gitlab/project_authorizations_spec.rb
+++ b/spec/lib/gitlab/project_authorizations_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ProjectAuthorizations do
let(:group) { create(:group) }
@@ -21,24 +21,24 @@ describe Gitlab::ProjectAuthorizations do
let(:authorizations) do
klass = if Group.supports_nested_objects?
- Gitlab::ProjectAuthorizations::WithNestedGroups
- else
- Gitlab::ProjectAuthorizations::WithoutNestedGroups
- end
+ Gitlab::ProjectAuthorizations::WithNestedGroups
+ else
+ Gitlab::ProjectAuthorizations::WithoutNestedGroups
+ end
klass.new(user).calculate
end
- it 'returns the correct number of authorizations' do
+ it "returns the correct number of authorizations" do
expect(authorizations.length).to eq(3)
end
- it 'includes the correct projects' do
+ it "includes the correct projects" do
expect(authorizations.pluck(:project_id))
.to include(owned_project.id, other_project.id, group_project.id)
end
- it 'includes the correct access levels' do
+ it "includes the correct access levels" do
mapping = map_access_levels(authorizations)
expect(mapping[owned_project.id]).to eq(Gitlab::Access::MAINTAINER)
@@ -47,21 +47,21 @@ describe Gitlab::ProjectAuthorizations do
end
if Group.supports_nested_objects?
- context 'with nested groups' do
+ context "with nested groups" do
let!(:nested_group) { create(:group, parent: group) }
let!(:nested_project) { create(:project, namespace: nested_group) }
- it 'includes nested groups' do
+ it "includes nested groups" do
expect(authorizations.pluck(:project_id)).to include(nested_project.id)
end
- it 'inherits access levels when the user is not a member of a nested group' do
+ it "inherits access levels when the user is not a member of a nested group" do
mapping = map_access_levels(authorizations)
expect(mapping[nested_project.id]).to eq(Gitlab::Access::DEVELOPER)
end
- it 'uses the greatest access level when a user is a member of a nested group' do
+ it "uses the greatest access level when a user is a member of a nested group" do
nested_group.add_maintainer(user)
mapping = map_access_levels(authorizations)
diff --git a/spec/lib/gitlab/project_search_results_spec.rb b/spec/lib/gitlab/project_search_results_spec.rb
index 6831274d37c..ac463f7dcc7 100644
--- a/spec/lib/gitlab/project_search_results_spec.rb
+++ b/spec/lib/gitlab/project_search_results_spec.rb
@@ -1,29 +1,28 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ProjectSearchResults do
let(:user) { create(:user) }
let(:project) { create(:project) }
- let(:query) { 'hello world' }
+ let(:query) { "hello world" }
- describe 'initialize with empty ref' do
- let(:results) { described_class.new(user, project, query, '') }
+ describe "initialize with empty ref" do
+ let(:results) { described_class.new(user, project, query, "") }
it { expect(results.project).to eq(project) }
- it { expect(results.query).to eq('hello world') }
+ it { expect(results.query).to eq("hello world") }
end
- describe 'initialize with ref' do
- let(:ref) { 'refs/heads/test' }
+ describe "initialize with ref" do
+ let(:ref) { "refs/heads/test" }
let(:results) { described_class.new(user, project, query, ref) }
it { expect(results.project).to eq(project) }
it { expect(results.repository_ref).to eq(ref) }
- it { expect(results.query).to eq('hello world') }
+ it { expect(results.query).to eq("hello world") }
end
- shared_examples 'general blob search' do |entity_type, blob_kind|
- let(:query) { 'files' }
+ shared_examples "general blob search" do |entity_type, blob_kind|
+ let(:query) { "files" }
subject(:results) { described_class.new(user, project, query).objects(blob_type) }
context "when #{entity_type} is disabled" do
@@ -53,28 +52,28 @@ describe Gitlab::ProjectSearchResults do
end
end
- it 'finds by name' do
+ it "finds by name" do
expect(results.map(&:filename)).to include(expected_file_by_name)
end
it "loads all blobs for filename matches in single batch" do
expect(Gitlab::Git::Blob).to receive(:batch).once.and_call_original
- expected = project.repository.search_files_by_name(query, 'master')
+ expected = project.repository.search_files_by_name(query, "master")
expect(results.map(&:filename)).to include(*expected)
end
- it 'finds by content' do
+ it "finds by content" do
blob = results.select { |result| result.filename == expected_file_by_content }.flatten.last
expect(blob.filename).to eq(expected_file_by_content)
end
end
- shared_examples 'blob search repository ref' do |entity_type|
- let(:query) { 'files' }
+ shared_examples "blob search repository ref" do |entity_type|
+ let(:query) { "files" }
let(:file_finder) { double }
- let(:project_branch) { 'project_branch' }
+ let(:project_branch) { "project_branch" }
subject(:results) { described_class.new(user, project, query, repository_ref).objects(blob_type) }
@@ -83,17 +82,17 @@ describe Gitlab::ProjectSearchResults do
allow(file_finder).to receive(:find).and_return([])
end
- context 'when repository_ref exists' do
- let(:repository_ref) { 'ref_branch' }
+ context "when repository_ref exists" do
+ let(:repository_ref) { "ref_branch" }
- it 'uses it' do
+ it "uses it" do
expect(Gitlab::FileFinder).to receive(:new).with(project, repository_ref).and_return(file_finder)
results
end
end
- context 'when repository_ref is not present' do
+ context "when repository_ref is not present" do
let(:repository_ref) { nil }
it "uses #{entity_type} repository default reference" do
@@ -103,8 +102,8 @@ describe Gitlab::ProjectSearchResults do
end
end
- context 'when repository_ref is blank' do
- let(:repository_ref) { '' }
+ context "when repository_ref is blank" do
+ let(:repository_ref) { "" }
it "uses #{entity_type} repository default reference" do
expect(Gitlab::FileFinder).to receive(:new).with(project, project_branch).and_return(file_finder)
@@ -114,69 +113,69 @@ describe Gitlab::ProjectSearchResults do
end
end
- describe 'blob search' do
+ describe "blob search" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'general blob search', 'repository', 'blobs' do
- let(:blob_type) { 'blobs' }
+ it_behaves_like "general blob search", "repository", "blobs" do
+ let(:blob_type) { "blobs" }
let(:disabled_project) { create(:project, :public, :repository, :repository_disabled) }
let(:private_project) { create(:project, :public, :repository, :repository_private) }
- let(:expected_file_by_name) { 'files/images/wm.svg' }
- let(:expected_file_by_content) { 'CHANGELOG' }
+ let(:expected_file_by_name) { "files/images/wm.svg" }
+ let(:expected_file_by_content) { "CHANGELOG" }
end
- it_behaves_like 'blob search repository ref', 'project' do
- let(:blob_type) { 'blobs' }
+ it_behaves_like "blob search repository ref", "project" do
+ let(:blob_type) { "blobs" }
let(:entity) { project }
end
end
- describe 'wiki search' do
+ describe "wiki search" do
let(:project) { create(:project, :public, :wiki_repo) }
let(:wiki) { build(:project_wiki, project: project) }
before do
- wiki.create_page('Files/Title', 'Content')
- wiki.create_page('CHANGELOG', 'Files example')
+ wiki.create_page("Files/Title", "Content")
+ wiki.create_page("CHANGELOG", "Files example")
end
- it_behaves_like 'general blob search', 'wiki', 'wiki blobs' do
- let(:blob_type) { 'wiki_blobs' }
+ it_behaves_like "general blob search", "wiki", "wiki blobs" do
+ let(:blob_type) { "wiki_blobs" }
let(:disabled_project) { create(:project, :public, :wiki_repo, :wiki_disabled) }
let(:private_project) { create(:project, :public, :wiki_repo, :wiki_private) }
- let(:expected_file_by_name) { 'Files/Title.md' }
- let(:expected_file_by_content) { 'CHANGELOG.md' }
+ let(:expected_file_by_name) { "Files/Title.md" }
+ let(:expected_file_by_content) { "CHANGELOG.md" }
end
- it_behaves_like 'blob search repository ref', 'wiki' do
- let(:blob_type) { 'wiki_blobs' }
+ it_behaves_like "blob search repository ref", "wiki" do
+ let(:blob_type) { "wiki_blobs" }
let(:entity) { project.wiki }
end
end
- it 'does not list issues on private projects' do
+ it "does not list issues on private projects" do
issue = create(:issue, project: project)
results = described_class.new(user, project, issue.title)
- expect(results.objects('issues')).not_to include issue
+ expect(results.objects("issues")).not_to include issue
end
- describe 'confidential issues' do
- let(:query) { 'issue' }
+ describe "confidential issues" do
+ let(:query) { "issue" }
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, :internal) }
- let!(:issue) { create(:issue, project: project, title: 'Issue 1') }
- 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, assignees: [assignee]) }
+ let!(:issue) { create(:issue, project: project, title: "Issue 1") }
+ 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, assignees: [assignee]) }
- it 'does 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')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -184,11 +183,11 @@ describe Gitlab::ProjectSearchResults do
expect(results.limited_issues_count).to eq 1
end
- it 'does 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.add_guest(member)
results = described_class.new(member, project, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -196,9 +195,9 @@ describe Gitlab::ProjectSearchResults do
expect(results.limited_issues_count).to eq 1
end
- it 'lists 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')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -206,9 +205,9 @@ describe Gitlab::ProjectSearchResults do
expect(results.limited_issues_count).to eq 2
end
- it 'lists project confidential issues for assignee' do
+ it "lists project confidential issues for assignee" do
results = described_class.new(assignee, project, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -216,11 +215,11 @@ describe Gitlab::ProjectSearchResults do
expect(results.limited_issues_count).to eq 2
end
- it 'lists project confidential issues for project members' do
+ it "lists project confidential issues for project members" do
project.add_developer(member)
results = described_class.new(member, project, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -228,9 +227,9 @@ describe Gitlab::ProjectSearchResults do
expect(results.limited_issues_count).to eq 3
end
- it 'lists 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')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -239,14 +238,14 @@ describe Gitlab::ProjectSearchResults do
end
end
- describe 'notes search' do
- it 'lists notes' do
+ describe "notes search" do
+ it "lists notes" do
project = create(:project, :public)
note = create(:note, project: project)
results = described_class.new(user, project, note.note)
- expect(results.objects('notes')).to include note
+ expect(results.objects("notes")).to include note
end
it "doesn't list issue notes when access is restricted" do
@@ -255,7 +254,7 @@ describe Gitlab::ProjectSearchResults do
results = described_class.new(user, project, note.note)
- expect(results.objects('notes')).not_to include note
+ expect(results.objects("notes")).not_to include note
end
it "doesn't list merge_request notes when access is restricted" do
@@ -264,28 +263,28 @@ describe Gitlab::ProjectSearchResults do
results = described_class.new(user, project, note.note)
- expect(results.objects('notes')).not_to include note
+ expect(results.objects("notes")).not_to include note
end
end
- describe '#limited_notes_count' do
+ describe "#limited_notes_count" do
let(:project) { create(:project, :public) }
let(:note) { create(:note_on_issue, project: project) }
let(:results) { described_class.new(user, project, note.note) }
- context 'when count_limit is lower than total amount' do
+ context "when count_limit is lower than total amount" do
before do
allow(results).to receive(:count_limit).and_return(1)
end
- it 'calls note finder once to get the limited amount of notes' do
+ it "calls note finder once to get the limited amount of notes" do
expect(results).to receive(:notes_finder).once.and_call_original
expect(results.limited_notes_count).to eq(1)
end
end
- context 'when count_limit is higher than total amount' do
- it 'calls note finder multiple times to get the limited amount of notes' do
+ context "when count_limit is higher than total amount" do
+ it "calls note finder multiple times to get the limited amount of notes" do
project = create(:project, :public)
note = create(:note_on_issue, project: project)
@@ -303,58 +302,58 @@ describe Gitlab::ProjectSearchResults do
# * search_phrase
# * commit
#
- shared_examples 'access restricted commits' do
- context 'when project is internal' do
+ shared_examples "access restricted commits" do
+ context "when project is internal" do
let(:project) { create(:project, :internal, :repository) }
- it 'does not search if user is not authenticated' do
- commits = described_class.new(nil, project, search_phrase).objects('commits')
+ it "does not search if user is not authenticated" do
+ commits = described_class.new(nil, project, search_phrase).objects("commits")
expect(commits).to be_empty
end
- it 'searches if user is authenticated' do
- commits = described_class.new(user, project, search_phrase).objects('commits')
+ it "searches if user is authenticated" do
+ commits = described_class.new(user, project, search_phrase).objects("commits")
expect(commits).to contain_exactly commit
end
end
- context 'when project is private' do
- let!(:creator) { create(:user, username: 'private-project-author') }
+ context "when project is private" do
+ let!(:creator) { create(:user, username: "private-project-author") }
let!(:private_project) { create(:project, :private, :repository, creator: creator, namespace: creator.namespace) }
let(:team_master) do
- user = create(:user, username: 'private-project-master')
+ user = create(:user, username: "private-project-master")
private_project.add_maintainer(user)
user
end
let(:team_reporter) do
- user = create(:user, username: 'private-project-reporter')
+ user = create(:user, username: "private-project-reporter")
private_project.add_reporter(user)
user
end
- it 'does not show commit to stranger' do
- commits = described_class.new(nil, private_project, search_phrase).objects('commits')
+ it "does not show commit to stranger" do
+ commits = described_class.new(nil, private_project, search_phrase).objects("commits")
expect(commits).to be_empty
end
- context 'team access' do
- it 'shows commit to creator' do
- commits = described_class.new(creator, private_project, search_phrase).objects('commits')
+ context "team access" do
+ it "shows commit to creator" do
+ commits = described_class.new(creator, private_project, search_phrase).objects("commits")
expect(commits).to contain_exactly commit
end
- it 'shows commit to master' do
- commits = described_class.new(team_master, private_project, search_phrase).objects('commits')
+ it "shows commit to master" do
+ commits = described_class.new(team_master, private_project, search_phrase).objects("commits")
expect(commits).to contain_exactly commit
end
- it 'shows commit to reporter' do
- commits = described_class.new(team_reporter, private_project, search_phrase).objects('commits')
+ it "shows commit to reporter" do
+ commits = described_class.new(team_reporter, private_project, search_phrase).objects("commits")
expect(commits).to contain_exactly commit
end
@@ -362,53 +361,53 @@ describe Gitlab::ProjectSearchResults do
end
end
- describe 'commit search' do
- context 'by commit message' do
+ describe "commit search" do
+ context "by commit message" do
let(:project) { create(:project, :public, :repository) }
- let(:commit) { project.repository.commit('59e29889be61e6e0e5e223bfa9ac2721d31605b8') }
- let(:message) { 'Sorry, I did a mistake' }
+ let(:commit) { project.repository.commit("59e29889be61e6e0e5e223bfa9ac2721d31605b8") }
+ let(:message) { "Sorry, I did a mistake" }
- it 'finds commit by message' do
- commits = described_class.new(user, project, message).objects('commits')
+ it "finds commit by message" do
+ commits = described_class.new(user, project, message).objects("commits")
expect(commits).to contain_exactly commit
end
- it 'handles when no commit match' do
- commits = described_class.new(user, project, 'not really an existing description').objects('commits')
+ it "handles when no commit match" do
+ commits = described_class.new(user, project, "not really an existing description").objects("commits")
expect(commits).to be_empty
end
- it_behaves_like 'access restricted commits' do
+ it_behaves_like "access restricted commits" do
let(:search_phrase) { message }
- let(:commit) { project.repository.commit('59e29889be61e6e0e5e223bfa9ac2721d31605b8') }
+ let(:commit) { project.repository.commit("59e29889be61e6e0e5e223bfa9ac2721d31605b8") }
end
end
- context 'by commit hash' do
+ context "by commit hash" do
let(:project) { create(:project, :public, :repository) }
- let(:commit) { project.repository.commit('0b4bc9a') }
+ let(:commit) { project.repository.commit("0b4bc9a") }
- commit_hashes = { short: '0b4bc9a', full: '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
+ commit_hashes = {short: "0b4bc9a", full: "0b4bc9a49b562e85de7cc9e834518ea6828729b9"}
commit_hashes.each do |type, commit_hash|
it "shows commit by #{type} hash id" do
- commits = described_class.new(user, project, commit_hash).objects('commits')
+ commits = described_class.new(user, project, commit_hash).objects("commits")
expect(commits).to contain_exactly commit
end
end
- it 'handles not existing commit hash correctly' do
- commits = described_class.new(user, project, 'deadbeef').objects('commits')
+ it "handles not existing commit hash correctly" do
+ commits = described_class.new(user, project, "deadbeef").objects("commits")
expect(commits).to be_empty
end
- it_behaves_like 'access restricted commits' do
- let(:search_phrase) { '0b4bc9a49' }
- let(:commit) { project.repository.commit('0b4bc9a') }
+ it_behaves_like "access restricted commits" do
+ let(:search_phrase) { "0b4bc9a49" }
+ let(:commit) { project.repository.commit("0b4bc9a") }
end
end
end
diff --git a/spec/lib/gitlab/project_template_spec.rb b/spec/lib/gitlab/project_template_spec.rb
index 115097e0d26..3b38b1108ad 100644
--- a/spec/lib/gitlab/project_template_spec.rb
+++ b/spec/lib/gitlab/project_template_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ProjectTemplate do
- describe '.all' do
- it 'returns a all templates' do
+ describe ".all" do
+ it "returns a all templates" do
expected = [
- described_class.new('rails', 'Ruby on Rails', 'Includes an MVC structure, .gitignore, Gemfile, and more great stuff', 'https://gitlab.com/gitlab-org/project-templates/rails'),
- described_class.new('spring', 'Spring', 'Includes an MVC structure, .gitignore, Gemfile, and more great stuff', 'https://gitlab.com/gitlab-org/project-templates/spring'),
- described_class.new('express', 'NodeJS Express', 'Includes an MVC structure, .gitignore, Gemfile, and more great stuff', 'https://gitlab.com/gitlab-org/project-templates/express'),
- described_class.new('dotnetcore', '.NET Core', 'A .NET Core console application template, customizable for any .NET Core project', 'https://gitlab.com/gitlab-org/project-templates/dotnetcore'),
- described_class.new('gomicro', 'Go Micro', 'Go Micro is a framework for micro service development.', 'https://gitlab.com/gitlab-org/project-templates/go-micro'),
- described_class.new('hugo', 'Pages/Hugo', 'Everything you need to get started using a Hugo Pages site.', 'https://gitlab.com/pages/hugo'),
- described_class.new('jekyll', 'Pages/Jekyll', 'Everything you need to get started using a Jekyll Pages site.', 'https://gitlab.com/pages/jekyll'),
- described_class.new('plainhtml', 'Pages/Plain HTML', 'Everything you need to get started using a plain HTML Pages site.', 'https://gitlab.com/pages/plain-html'),
- described_class.new('gitbook', 'Pages/GitBook', 'Everything you need to get started using a GitBook Pages site.', 'https://gitlab.com/pages/gitbook'),
- described_class.new('hexo', 'Pages/Hexo', 'Everything you need to get started using a Hexo Pages site.', 'https://gitlab.com/pages/hexo'),
- described_class.new('nfhugo', 'Netlify/Hugo', _('A Hugo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfhugo'),
- described_class.new('nfjekyll', 'Netlify/Jekyll', _('A Jekyll site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfjekyll'),
- described_class.new('nfplainhtml', 'Netlify/Plain HTML', _('A plain HTML site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfplain-html'),
- described_class.new('nfgitbook', 'Netlify/GitBook', _('A GitBook site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfgitbook'),
- described_class.new('nfhexo', 'Netlify/Hexo', _('A Hexo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features.'), 'https://gitlab.com/pages/nfhexo')
+ described_class.new("rails", "Ruby on Rails", "Includes an MVC structure, .gitignore, Gemfile, and more great stuff", "https://gitlab.com/gitlab-org/project-templates/rails"),
+ described_class.new("spring", "Spring", "Includes an MVC structure, .gitignore, Gemfile, and more great stuff", "https://gitlab.com/gitlab-org/project-templates/spring"),
+ described_class.new("express", "NodeJS Express", "Includes an MVC structure, .gitignore, Gemfile, and more great stuff", "https://gitlab.com/gitlab-org/project-templates/express"),
+ described_class.new("dotnetcore", ".NET Core", "A .NET Core console application template, customizable for any .NET Core project", "https://gitlab.com/gitlab-org/project-templates/dotnetcore"),
+ described_class.new("gomicro", "Go Micro", "Go Micro is a framework for micro service development.", "https://gitlab.com/gitlab-org/project-templates/go-micro"),
+ described_class.new("hugo", "Pages/Hugo", "Everything you need to get started using a Hugo Pages site.", "https://gitlab.com/pages/hugo"),
+ described_class.new("jekyll", "Pages/Jekyll", "Everything you need to get started using a Jekyll Pages site.", "https://gitlab.com/pages/jekyll"),
+ described_class.new("plainhtml", "Pages/Plain HTML", "Everything you need to get started using a plain HTML Pages site.", "https://gitlab.com/pages/plain-html"),
+ described_class.new("gitbook", "Pages/GitBook", "Everything you need to get started using a GitBook Pages site.", "https://gitlab.com/pages/gitbook"),
+ described_class.new("hexo", "Pages/Hexo", "Everything you need to get started using a Hexo Pages site.", "https://gitlab.com/pages/hexo"),
+ described_class.new("nfhugo", "Netlify/Hugo", _("A Hugo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfhugo"),
+ described_class.new("nfjekyll", "Netlify/Jekyll", _("A Jekyll site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfjekyll"),
+ described_class.new("nfplainhtml", "Netlify/Plain HTML", _("A plain HTML site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfplain-html"),
+ described_class.new("nfgitbook", "Netlify/GitBook", _("A GitBook site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfgitbook"),
+ described_class.new("nfhexo", "Netlify/Hexo", _("A Hexo site that uses Netlify for CI/CD instead of GitLab, but still with all the other great GitLab features."), "https://gitlab.com/pages/nfhexo"),
]
expect(described_class.all).to be_an(Array)
@@ -26,29 +26,29 @@ describe Gitlab::ProjectTemplate do
end
end
- describe '.find' do
+ describe ".find" do
subject { described_class.find(query) }
- context 'when there is a match' do
+ context "when there is a match" do
let(:query) { :rails }
it { is_expected.to be_a(described_class) }
end
- context 'when there is no match' do
- let(:query) { 'no-match' }
+ context "when there is no match" do
+ let(:query) { "no-match" }
it { is_expected.to be(nil) }
end
end
- describe 'instance methods' do
- subject { described_class.new('phoenix', 'Phoenix Framework', 'Phoenix description', 'link-to-template') }
+ describe "instance methods" do
+ subject { described_class.new("phoenix", "Phoenix Framework", "Phoenix description", "link-to-template") }
it { is_expected.to respond_to(:logo, :file, :archive_path) }
end
- describe 'validate all templates' do
+ describe "validate all templates" do
set(:admin) { create(:admin) }
described_class.all.each do |template|
@@ -58,12 +58,12 @@ describe Gitlab::ProjectTemplate do
expect(File.exist?(archive)).to be(true)
end
- context 'with valid parameters' do
- it 'can be imported' do
+ context "with valid parameters" do
+ it "can be imported" do
params = {
template_name: template.name,
namespace_id: admin.namespace.id,
- path: template.name
+ path: template.name,
}
project = Projects::CreateFromTemplateService.new(admin, params).execute
diff --git a/spec/lib/gitlab/project_transfer_spec.rb b/spec/lib/gitlab/project_transfer_spec.rb
index 0b9b1f537b5..c3253c169b6 100644
--- a/spec/lib/gitlab/project_transfer_spec.rb
+++ b/spec/lib/gitlab/project_transfer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ProjectTransfer do
before do
@@ -15,11 +15,11 @@ describe Gitlab::ProjectTransfer do
after do
FileUtils.rm_rf([
File.join(@root_dir, @namespace_path),
- File.join(@root_dir, @namespace_path_was)
+ File.join(@root_dir, @namespace_path_was),
])
end
- describe '#move_project' do
+ describe "#move_project" do
it "moves project upload to another namespace" do
path_to_be_moved = File.join(@root_dir, @namespace_path_was, @project_path)
expected_path = File.join(@root_dir, @namespace_path, @project_path)
@@ -31,10 +31,10 @@ describe Gitlab::ProjectTransfer do
end
end
- describe '#move_namespace' do
- context 'when moving namespace from root into another namespace' do
+ describe "#move_namespace" do
+ context "when moving namespace from root into another namespace" do
it "moves namespace projects' upload" do
- child_namespace = 'test_child_namespace'
+ child_namespace = "test_child_namespace"
path_to_be_moved = File.join(@root_dir, child_namespace, @project_path)
expected_path = File.join(@root_dir, @namespace_path, child_namespace, @project_path)
FileUtils.mkdir_p(path_to_be_moved)
@@ -45,9 +45,9 @@ describe Gitlab::ProjectTransfer do
end
end
- context 'when moving namespace from one parent to another' do
+ context "when moving namespace from one parent to another" do
it "moves namespace projects' upload" do
- child_namespace = 'test_child_namespace'
+ child_namespace = "test_child_namespace"
path_to_be_moved = File.join(@root_dir, @namespace_path_was, child_namespace, @project_path)
expected_path = File.join(@root_dir, @namespace_path, child_namespace, @project_path)
FileUtils.mkdir_p(path_to_be_moved)
@@ -58,9 +58,9 @@ describe Gitlab::ProjectTransfer do
end
end
- context 'when moving namespace from having a parent to root' do
+ context "when moving namespace from having a parent to root" do
it "moves namespace projects' upload" do
- child_namespace = 'test_child_namespace'
+ child_namespace = "test_child_namespace"
path_to_be_moved = File.join(@root_dir, @namespace_path_was, child_namespace, @project_path)
expected_path = File.join(@root_dir, child_namespace, @project_path)
FileUtils.mkdir_p(path_to_be_moved)
@@ -72,7 +72,7 @@ describe Gitlab::ProjectTransfer do
end
end
- describe '#rename_project' do
+ describe "#rename_project" do
it "renames project" do
path_to_be_moved = File.join(@root_dir, @namespace_path, @project_path_was)
expected_path = File.join(@root_dir, @namespace_path, @project_path)
@@ -84,7 +84,7 @@ describe Gitlab::ProjectTransfer do
end
end
- describe '#rename_namespace' do
+ describe "#rename_namespace" do
it "renames namespace" do
path_to_be_moved = File.join(@root_dir, @namespace_path_was, @project_path)
expected_path = File.join(@root_dir, @namespace_path, @project_path)
diff --git a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
index 1a108003bc2..30848197651 100644
--- a/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
+++ b/spec/lib/gitlab/prometheus/additional_metrics_parser_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::AdditionalMetricsParser do
include Prometheus::MetricBuilders
let(:parser_error_class) { Gitlab::Prometheus::ParsingError }
- describe '#load_groups_from_yaml' do
- subject { described_class.load_groups_from_yaml('dummy.yaml') }
+ describe "#load_groups_from_yaml" do
+ subject { described_class.load_groups_from_yaml("dummy.yaml") }
- describe 'parsing sample yaml' do
+ describe "parsing sample yaml" do
let(:sample_yaml) do
<<-EOF.strip_heredoc
- group: group_a
@@ -36,43 +36,43 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
allow(described_class).to receive(:load_yaml_file) { YAML.load(sample_yaml) }
end
- it 'parses to two metric groups with 2 and 1 metric respectively' do
+ it "parses to two metric groups with 2 and 1 metric respectively" do
expect(subject.count).to eq(2)
expect(subject[0].metrics.count).to eq(2)
expect(subject[1].metrics.count).to eq(1)
end
- it 'provide group data' do
- expect(subject[0]).to have_attributes(name: 'group_a', priority: 1)
- expect(subject[1]).to have_attributes(name: 'group_b', priority: 1)
+ it "provide group data" do
+ expect(subject[0]).to have_attributes(name: "group_a", priority: 1)
+ expect(subject[1]).to have_attributes(name: "group_b", priority: 1)
end
- it 'provides metrics data' do
+ it "provides metrics data" do
metrics = subject.flat_map(&:metrics)
expect(metrics.count).to eq(3)
- expect(metrics[0]).to have_attributes(title: 'title', required_metrics: %w(metric_a metric_b), weight: 1)
- expect(metrics[1]).to have_attributes(title: 'title', required_metrics: %w(metric_a), weight: 1)
- expect(metrics[2]).to have_attributes(title: 'title', required_metrics: %w{metric_a}, weight: 1)
+ expect(metrics[0]).to have_attributes(title: "title", required_metrics: %w[metric_a metric_b], weight: 1)
+ expect(metrics[1]).to have_attributes(title: "title", required_metrics: %w[metric_a], weight: 1)
+ expect(metrics[2]).to have_attributes(title: "title", required_metrics: %w[metric_a], weight: 1)
end
- it 'provides query data' do
+ it "provides query data" do
queries = subject.flat_map(&:metrics).flat_map(&:queries)
expect(queries.count).to eq(3)
- expect(queries[0]).to eq(query_range: 'query_range_a', label: 'label', unit: 'unit')
- expect(queries[1]).to eq(query_range: 'query_range_empty')
- expect(queries[2]).to eq(query_range: 'query_range_a')
+ expect(queries[0]).to eq(query_range: "query_range_a", label: "label", unit: "unit")
+ expect(queries[1]).to eq(query_range: "query_range_empty")
+ expect(queries[2]).to eq(query_range: "query_range_a")
end
end
- shared_examples 'required field' do |field_name|
+ shared_examples "required field" do |field_name|
context "when #{field_name} is nil" do
before do
allow(described_class).to receive(:load_yaml_file) { YAML.load(field_missing) }
end
- it 'throws parsing error' do
+ it "throws parsing error" do
expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i)
end
end
@@ -82,14 +82,14 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
allow(described_class).to receive(:load_yaml_file) { YAML.load(field_nil) }
end
- it 'throws parsing error' do
+ it "throws parsing error" do
expect { subject }.to raise_error(parser_error_class, /#{field_name} can't be blank/i)
end
end
end
- describe 'group required fields' do
- it_behaves_like 'required field', 'metrics' do
+ describe "group required fields" do
+ it_behaves_like "required field", "metrics" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -106,7 +106,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- it_behaves_like 'required field', 'name' do
+ it_behaves_like "required field", "name" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group:
@@ -123,7 +123,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- it_behaves_like 'required field', 'priority' do
+ it_behaves_like "required field", "priority" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -141,8 +141,8 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- describe 'metrics fields parsing' do
- it_behaves_like 'required field', 'title' do
+ describe "metrics fields parsing" do
+ it_behaves_like "required field", "title" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -167,7 +167,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- it_behaves_like 'required field', 'required metrics' do
+ it_behaves_like "required field", "required metrics" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -192,7 +192,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- it_behaves_like 'required field', 'weight' do
+ it_behaves_like "required field", "weight" do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
@@ -217,7 +217,7 @@ describe Gitlab::Prometheus::AdditionalMetricsParser do
end
end
- it_behaves_like 'required field', :queries do
+ it_behaves_like "required field", :queries do
let(:field_nil) do
<<-EOF.strip_heredoc
- group: group_a
diff --git a/spec/lib/gitlab/prometheus/metric_group_spec.rb b/spec/lib/gitlab/prometheus/metric_group_spec.rb
index 5cc6827488b..2091fd7f7f5 100644
--- a/spec/lib/gitlab/prometheus/metric_group_spec.rb
+++ b/spec/lib/gitlab/prometheus/metric_group_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::Prometheus::MetricGroup do
- describe '.common_metrics' do
+ describe ".common_metrics" do
let!(:project_metric) { create(:prometheus_metric) }
let!(:common_metric_group_a) { create(:prometheus_metric, :common, group: :aws_elb) }
let!(:common_metric_group_b_q1) { create(:prometheus_metric, :common, group: :kubernetes) }
@@ -11,26 +11,28 @@ describe Gitlab::Prometheus::MetricGroup do
subject { described_class.common_metrics }
- it 'returns exactly two groups' do
+ it "returns exactly two groups" do
expect(subject.map(&:name)).to contain_exactly(
- 'Response metrics (AWS ELB)', 'System metrics (Kubernetes)')
+ "Response metrics (AWS ELB)", "System metrics (Kubernetes)"
+ )
end
- it 'returns exactly three metric queries' do
+ it "returns exactly three metric queries" do
expect(subject.map(&:metrics).flatten.map(&:id)).to contain_exactly(
common_metric_group_a.id, common_metric_group_b_q1.id,
- common_metric_group_b_q2.id)
+ common_metric_group_b_q2.id
+ )
end
- it 'orders by priority' do
+ it "orders by priority" do
priorities = subject.map(&:priority)
names = subject.map(&:name)
expect(priorities).to eq([10, 5])
- expect(names).to eq(['Response metrics (AWS ELB)', 'System metrics (Kubernetes)'])
+ expect(names).to eq(["Response metrics (AWS ELB)", "System metrics (Kubernetes)"])
end
end
- describe '.for_project' do
+ describe ".for_project" do
let!(:other_project) { create(:project) }
let!(:project_metric) { create(:prometheus_metric) }
let!(:common_metric) { create(:prometheus_metric, :common, group: :aws_elb) }
@@ -41,7 +43,7 @@ describe Gitlab::Prometheus::MetricGroup do
.map(&:id)
end
- it 'returns exactly one common metric' do
+ it "returns exactly one common metric" do
is_expected.to contain_exactly(common_metric.id)
end
end
diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb
index c7169717fc1..2dfbf4367ef 100644
--- a/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_deployment_query_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::Queries::AdditionalMetricsDeploymentQuery do
around do |example|
Timecop.freeze(Time.local(2008, 9, 1, 12, 0, 0)) { example.run }
end
- include_examples 'additional metrics query' do
+ include_examples "additional metrics query" do
let(:deployment) { create(:deployment, environment: environment) }
let(:query_params) { [deployment.id] }
- it 'queries using specific time' do
+ it "queries using specific time" do
expect(client).to receive(:query_range).with(anything,
- start: (deployment.created_at - 30.minutes).to_f,
- stop: (deployment.created_at + 30.minutes).to_f)
+ start: (deployment.created_at - 30.minutes).to_f,
+ stop: (deployment.created_at + 30.minutes).to_f)
expect(query_result).not_to be_nil
end
diff --git a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb
index 5a88b23aa82..9eea3730cea 100644
--- a/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/additional_metrics_environment_query_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::Queries::AdditionalMetricsEnvironmentQuery do
around do |example|
Timecop.freeze { example.run }
end
- include_examples 'additional metrics query' do
+ include_examples "additional metrics query" do
let(:query_params) { [environment.id] }
- it 'queries using specific time' do
+ it "queries using specific time" do
expect(client).to receive(:query_range).with(anything, start: 8.hours.ago.to_f, stop: Time.now.to_f)
expect(query_result).not_to be_nil
diff --git a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
index ffe3ad85baa..961db66e2e5 100644
--- a/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/deployment_query_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::Queries::DeploymentQuery do
- let(:environment) { create(:environment, slug: 'environment-slug') }
+ let(:environment) { create(:environment, slug: "environment-slug") }
let(:deployment) { create(:deployment, environment: environment) }
- let(:client) { double('prometheus_client') }
+ let(:client) { double("prometheus_client") }
subject { described_class.new(client) }
around do |example|
@@ -12,24 +12,24 @@ describe Gitlab::Prometheus::Queries::DeploymentQuery do
Timecop.freeze(time_without_subsecond_values) { example.run }
end
- it 'sends appropriate queries to prometheus' do
+ it "sends appropriate queries to prometheus" do
start_time = (deployment.created_at - 30.minutes).to_f
stop_time = (deployment.created_at + 30.minutes).to_f
created_at = deployment.created_at.to_f
expect(client).to receive(:query_range).with('avg(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}) / 2^20',
- start: start_time, stop: stop_time)
+ start: start_time, stop: stop_time)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
- time: created_at)
+ time: created_at)
expect(client).to receive(:query).with('avg(avg_over_time(container_memory_usage_bytes{container_name!="POD",environment="environment-slug"}[30m]))',
- time: stop_time)
+ time: stop_time)
expect(client).to receive(:query_range).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[2m])) * 100',
- start: start_time, stop: stop_time)
+ start: start_time, stop: stop_time)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
- time: created_at)
+ time: created_at)
expect(client).to receive(:query).with('avg(rate(container_cpu_usage_seconds_total{container_name!="POD",environment="environment-slug"}[30m])) * 100',
- time: stop_time)
+ time: stop_time)
expect(subject.query(deployment.id)).to eq(memory_values: nil, memory_before: nil, memory_after: nil,
cpu_values: nil, cpu_before: nil, cpu_after: nil)
diff --git a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb
index 936447b8474..590c6ec7dba 100644
--- a/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb
+++ b/spec/lib/gitlab/prometheus/queries/matched_metric_query_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::Queries::MatchedMetricQuery do
include Prometheus::MetricBuilders
@@ -7,127 +7,125 @@ describe Gitlab::Prometheus::Queries::MatchedMetricQuery do
let(:metric_class) { Gitlab::Prometheus::Metric }
def series_info_with_environment(*more_metrics)
- %w{metric_a metric_b}.concat(more_metrics).map { |metric_name| { '__name__' => metric_name, 'environment' => '' } }
+ %w[metric_a metric_b].concat(more_metrics).map { |metric_name| {"__name__" => metric_name, "environment" => ""} }
end
- let(:metric_names) { %w{metric_a metric_b} }
+ let(:metric_names) { %w[metric_a metric_b] }
let(:series_info_without_environment) do
- [{ '__name__' => 'metric_a' },
- { '__name__' => 'metric_b' }]
+ [{"__name__" => "metric_a"},
+ {"__name__" => "metric_b"},]
end
- let(:partially_empty_series_info) { [{ '__name__' => 'metric_a', 'environment' => '' }] }
+ let(:partially_empty_series_info) { [{"__name__" => "metric_a", "environment" => ""}] }
let(:empty_series_info) { [] }
- let(:client) { double('prometheus_client') }
+ let(:client) { double("prometheus_client") }
subject { described_class.new(client) }
- context 'with one group where two metrics is found' do
+ context "with one group where two metrics is found" do
before do
allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group])
allow(client).to receive(:label_values).and_return(metric_names)
end
- context 'both metrics in the group pass requirements' do
+ context "both metrics in the group pass requirements" do
before do
allow(client).to receive(:series).and_return(series_info_with_environment)
end
- it 'responds with both metrics as actve' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 2, metrics_missing_requirements: 0 }])
+ it "responds with both metrics as actve" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 2, metrics_missing_requirements: 0}])
end
end
- context 'none of the metrics pass requirements' do
+ context "none of the metrics pass requirements" do
before do
allow(client).to receive(:series).and_return(series_info_without_environment)
end
- it 'responds with both metrics missing requirements' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 }])
+ it "responds with both metrics missing requirements" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 0, metrics_missing_requirements: 2}])
end
end
- context 'no series information found about the metrics' do
+ context "no series information found about the metrics" do
before do
allow(client).to receive(:series).and_return(empty_series_info)
end
- it 'responds with both metrics missing requirements' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 }])
+ it "responds with both metrics missing requirements" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 0, metrics_missing_requirements: 2}])
end
end
- context 'one of the series info was not found' do
+ context "one of the series info was not found" do
before do
allow(client).to receive(:series).and_return(partially_empty_series_info)
end
- it 'responds with one active and one missing metric' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 1 }])
+ it "responds with one active and one missing metric" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 1, metrics_missing_requirements: 1}])
end
end
end
- context 'with one group where only one metric is found' do
+ context "with one group where only one metric is found" do
before do
allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group])
- allow(client).to receive(:label_values).and_return('metric_a')
+ allow(client).to receive(:label_values).and_return("metric_a")
end
- context 'both metrics in the group pass requirements' do
+ context "both metrics in the group pass requirements" do
before do
allow(client).to receive(:series).and_return(series_info_with_environment)
end
- it 'responds with one metrics as active and no missing requiremens' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 0 }])
+ it "responds with one metrics as active and no missing requiremens" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 1, metrics_missing_requirements: 0}])
end
end
- context 'no metrics in group pass requirements' do
+ context "no metrics in group pass requirements" do
before do
allow(client).to receive(:series).and_return(series_info_without_environment)
end
- it 'responds with one metrics as active and no missing requiremens' do
- expect(subject.query).to eq([{ group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 1 }])
+ it "responds with one metrics as active and no missing requiremens" do
+ expect(subject.query).to eq([{group: "name", priority: 1, active_metrics: 0, metrics_missing_requirements: 1}])
end
end
end
- context 'with two groups where metrics are found in each group' do
- let(:second_metric_group) { simple_metric_group(name: 'nameb', metrics: simple_metrics(added_metric_name: 'metric_c')) }
+ context "with two groups where metrics are found in each group" do
+ let(:second_metric_group) { simple_metric_group(name: "nameb", metrics: simple_metrics(added_metric_name: "metric_c")) }
before do
allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group, second_metric_group])
- allow(client).to receive(:label_values).and_return('metric_c')
+ allow(client).to receive(:label_values).and_return("metric_c")
end
- context 'all metrics in both groups pass requirements' do
+ context "all metrics in both groups pass requirements" do
before do
- allow(client).to receive(:series).and_return(series_info_with_environment('metric_c'))
+ allow(client).to receive(:series).and_return(series_info_with_environment("metric_c"))
end
- it 'responds with one metrics as active and no missing requiremens' do
+ it "responds with one metrics as active and no missing requiremens" do
expect(subject.query).to eq([
- { group: 'name', priority: 1, active_metrics: 1, metrics_missing_requirements: 0 },
- { group: 'nameb', priority: 1, active_metrics: 2, metrics_missing_requirements: 0 }
- ]
- )
+ {group: "name", priority: 1, active_metrics: 1, metrics_missing_requirements: 0},
+ {group: "nameb", priority: 1, active_metrics: 2, metrics_missing_requirements: 0},
+ ])
end
end
- context 'no metrics in groups pass requirements' do
+ context "no metrics in groups pass requirements" do
before do
allow(client).to receive(:series).and_return(series_info_without_environment)
end
- it 'responds with one metrics as active and no missing requiremens' do
+ it "responds with one metrics as active and no missing requiremens" do
expect(subject.query).to eq([
- { group: 'name', priority: 1, active_metrics: 0, metrics_missing_requirements: 1 },
- { group: 'nameb', priority: 1, active_metrics: 0, metrics_missing_requirements: 2 }
- ]
- )
+ {group: "name", priority: 1, active_metrics: 0, metrics_missing_requirements: 1},
+ {group: "nameb", priority: 1, active_metrics: 0, metrics_missing_requirements: 2},
+ ])
end
end
end
diff --git a/spec/lib/gitlab/prometheus/query_variables_spec.rb b/spec/lib/gitlab/prometheus/query_variables_spec.rb
index 78c74266c61..59e51cff682 100644
--- a/spec/lib/gitlab/prometheus/query_variables_spec.rb
+++ b/spec/lib/gitlab/prometheus/query_variables_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Prometheus::QueryVariables do
- describe '.call' do
+ describe ".call" do
let(:environment) { create(:environment) }
let(:slug) { environment.slug }
@@ -13,14 +13,14 @@ describe Gitlab::Prometheus::QueryVariables do
it do
is_expected.to include(environment_filter:
- %{container_name!="POD",environment="#{slug}"})
+ %(container_name!="POD",environment="#{slug}"))
end
- context 'without deployment platform' do
- it { is_expected.to include(kube_namespace: '') }
+ context "without deployment platform" do
+ it { is_expected.to include(kube_namespace: "") }
end
- context 'with deployment platform' do
+ context "with deployment platform" do
let(:kube_namespace) { environment.deployment_platform.actual_namespace }
before do
diff --git a/spec/lib/gitlab/prometheus_client_spec.rb b/spec/lib/gitlab/prometheus_client_spec.rb
index 4c3b8deefb9..8efeff93e80 100644
--- a/spec/lib/gitlab/prometheus_client_spec.rb
+++ b/spec/lib/gitlab/prometheus_client_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::PrometheusClient do
include PrometheusHelpers
- subject { described_class.new(RestClient::Resource.new('https://prometheus.example.com')) }
+ subject { described_class.new(RestClient::Resource.new("https://prometheus.example.com")) }
- describe '#ping' do
+ describe "#ping" do
it 'issues a "query" request to the API endpoint' do
- req_stub = stub_prometheus_request(prometheus_query_url('1'), body: prometheus_value_body('vector'))
+ req_stub = stub_prometheus_request(prometheus_query_url("1"), body: prometheus_value_body("vector"))
- expect(subject.ping).to eq({ "resultType" => "vector", "result" => [{ "metric" => {}, "value" => [1488772511.004, "0.000041021495238095323"] }] })
+ expect(subject.ping).to eq({"resultType" => "vector", "result" => [{"metric" => {}, "value" => [1488772511.004, "0.000041021495238095323"]}]})
expect(req_stub).to have_been_requested
end
end
@@ -17,30 +17,30 @@ describe Gitlab::PrometheusClient do
# This shared examples expect:
# - query_url: A query URL
# - execute_query: A query call
- shared_examples 'failure response' do
- context 'when request returns 400 with an error message' do
- it 'raises a Gitlab::PrometheusClient::Error error' do
- req_stub = stub_prometheus_request(query_url, status: 400, body: { error: 'bar!' })
+ shared_examples "failure response" do
+ context "when request returns 400 with an error message" do
+ it "raises a Gitlab::PrometheusClient::Error error" do
+ req_stub = stub_prometheus_request(query_url, status: 400, body: {error: "bar!"})
expect { execute_query }
- .to raise_error(Gitlab::PrometheusClient::Error, 'bar!')
+ .to raise_error(Gitlab::PrometheusClient::Error, "bar!")
expect(req_stub).to have_been_requested
end
end
- context 'when request returns 400 without an error message' do
- it 'raises a Gitlab::PrometheusClient::Error error' do
+ context "when request returns 400 without an error message" do
+ it "raises a Gitlab::PrometheusClient::Error error" do
req_stub = stub_prometheus_request(query_url, status: 400)
expect { execute_query }
- .to raise_error(Gitlab::PrometheusClient::Error, 'Bad data received')
+ .to raise_error(Gitlab::PrometheusClient::Error, "Bad data received")
expect(req_stub).to have_been_requested
end
end
- context 'when request returns 500' do
- it 'raises a Gitlab::PrometheusClient::Error error' do
- req_stub = stub_prometheus_request(query_url, status: 500, body: { message: 'FAIL!' })
+ context "when request returns 500" do
+ it "raises a Gitlab::PrometheusClient::Error error" do
+ req_stub = stub_prometheus_request(query_url, status: 500, body: {message: "FAIL!"})
expect { execute_query }
.to raise_error(Gitlab::PrometheusClient::Error, '500 - {"message":"FAIL!"}')
@@ -48,185 +48,185 @@ describe Gitlab::PrometheusClient do
end
end
- context 'when request returns non json data' do
- it 'raises a Gitlab::PrometheusClient::Error error' do
- req_stub = stub_prometheus_request(query_url, status: 200, body: 'not json')
+ context "when request returns non json data" do
+ it "raises a Gitlab::PrometheusClient::Error error" do
+ req_stub = stub_prometheus_request(query_url, status: 200, body: "not json")
expect { execute_query }
- .to raise_error(Gitlab::PrometheusClient::Error, 'Parsing response failed')
+ .to raise_error(Gitlab::PrometheusClient::Error, "Parsing response failed")
expect(req_stub).to have_been_requested
end
end
end
- describe 'failure to reach a provided prometheus url' do
+ describe "failure to reach a provided prometheus url" do
let(:prometheus_url) {"https://prometheus.invalid.example.com"}
subject { described_class.new(RestClient::Resource.new(prometheus_url)) }
- context 'exceptions are raised' do
- it 'raises a Gitlab::PrometheusClient::Error error when a SocketError is rescued' do
+ context "exceptions are raised" do
+ it "raises a Gitlab::PrometheusClient::Error error when a SocketError is rescued" do
req_stub = stub_prometheus_request_with_exception(prometheus_url, SocketError)
- expect { subject.send(:get, '/', {}) }
+ expect { subject.send(:get, "/", {}) }
.to raise_error(Gitlab::PrometheusClient::Error, "Can't connect to #{prometheus_url}")
expect(req_stub).to have_been_requested
end
- it 'raises a Gitlab::PrometheusClient::Error error when a SSLError is rescued' do
+ it "raises a Gitlab::PrometheusClient::Error error when a SSLError is rescued" do
req_stub = stub_prometheus_request_with_exception(prometheus_url, OpenSSL::SSL::SSLError)
- expect { subject.send(:get, '/', {}) }
+ expect { subject.send(:get, "/", {}) }
.to raise_error(Gitlab::PrometheusClient::Error, "#{prometheus_url} contains invalid SSL data")
expect(req_stub).to have_been_requested
end
- it 'raises a Gitlab::PrometheusClient::Error error when a RestClient::Exception is rescued' do
+ it "raises a Gitlab::PrometheusClient::Error error when a RestClient::Exception is rescued" do
req_stub = stub_prometheus_request_with_exception(prometheus_url, RestClient::Exception)
- expect { subject.send(:get, '/', {}) }
+ expect { subject.send(:get, "/", {}) }
.to raise_error(Gitlab::PrometheusClient::Error, "Network connection error")
expect(req_stub).to have_been_requested
end
end
end
- describe '#query' do
- let(:prometheus_query) { prometheus_cpu_query('env-slug') }
+ describe "#query" do
+ let(:prometheus_query) { prometheus_cpu_query("env-slug") }
let(:query_url) { prometheus_query_with_time_url(prometheus_query, Time.now.utc) }
around do |example|
Timecop.freeze { example.run }
end
- context 'when request returns vector results' do
- it 'returns data from the API call' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_value_body('vector'))
+ context "when request returns vector results" do
+ it "returns data from the API call" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_value_body("vector"))
- expect(subject.query(prometheus_query)).to eq [{ "metric" => {}, "value" => [1488772511.004, "0.000041021495238095323"] }]
+ expect(subject.query(prometheus_query)).to eq [{"metric" => {}, "value" => [1488772511.004, "0.000041021495238095323"]}]
expect(req_stub).to have_been_requested
end
end
- context 'when request returns matrix results' do
- it 'returns nil' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_value_body('matrix'))
+ context "when request returns matrix results" do
+ it "returns nil" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_value_body("matrix"))
expect(subject.query(prometheus_query)).to be_nil
expect(req_stub).to have_been_requested
end
end
- context 'when request returns no data' do
- it 'returns []' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_empty_body('vector'))
+ context "when request returns no data" do
+ it "returns []" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_empty_body("vector"))
expect(subject.query(prometheus_query)).to be_empty
expect(req_stub).to have_been_requested
end
end
- it_behaves_like 'failure response' do
+ it_behaves_like "failure response" do
let(:execute_query) { subject.query(prometheus_query) }
end
end
- describe '#series' do
- let(:query_url) { prometheus_series_url('series_name', 'other_service') }
+ describe "#series" do
+ let(:query_url) { prometheus_series_url("series_name", "other_service") }
around do |example|
Timecop.freeze { example.run }
end
- it 'calls endpoint and returns list of series' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_series('series_name'))
- expected = prometheus_series('series_name').deep_stringify_keys['data']
+ it "calls endpoint and returns list of series" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_series("series_name"))
+ expected = prometheus_series("series_name").deep_stringify_keys["data"]
- expect(subject.series('series_name', 'other_service')).to eq(expected)
+ expect(subject.series("series_name", "other_service")).to eq(expected)
expect(req_stub).to have_been_requested
end
end
- describe '#label_values' do
- let(:query_url) { prometheus_label_values_url('__name__') }
+ describe "#label_values" do
+ let(:query_url) { prometheus_label_values_url("__name__") }
- it 'calls endpoint and returns label values' do
+ it "calls endpoint and returns label values" do
req_stub = stub_prometheus_request(query_url, body: prometheus_label_values)
- expected = prometheus_label_values.deep_stringify_keys['data']
+ expected = prometheus_label_values.deep_stringify_keys["data"]
- expect(subject.label_values('__name__')).to eq(expected)
+ expect(subject.label_values("__name__")).to eq(expected)
expect(req_stub).to have_been_requested
end
end
- describe '#query_range' do
- let(:prometheus_query) { prometheus_memory_query('env-slug') }
+ describe "#query_range" do
+ let(:prometheus_query) { prometheus_memory_query("env-slug") }
let(:query_url) { prometheus_query_range_url(prometheus_query) }
around do |example|
Timecop.freeze { example.run }
end
- context 'when non utc time is passed' do
+ context "when non utc time is passed" do
let(:time_stop) { Time.now.in_time_zone("Warsaw") }
let(:time_start) { time_stop - 8.hours }
let(:query_url) { prometheus_query_range_url(prometheus_query, start: time_start.utc.to_f, stop: time_stop.utc.to_f) }
- it 'passed dates are properly converted to utc' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector'))
+ it "passed dates are properly converted to utc" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_values_body("vector"))
subject.query_range(prometheus_query, start: time_start, stop: time_stop)
expect(req_stub).to have_been_requested
end
end
- context 'when a start time is passed' do
+ context "when a start time is passed" do
let(:query_url) { prometheus_query_range_url(prometheus_query, start: 2.hours.ago) }
- it 'passed it in the requested URL' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector'))
+ it "passed it in the requested URL" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_values_body("vector"))
subject.query_range(prometheus_query, start: 2.hours.ago)
expect(req_stub).to have_been_requested
end
end
- context 'when request returns vector results' do
- it 'returns nil' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('vector'))
+ context "when request returns vector results" do
+ it "returns nil" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_values_body("vector"))
expect(subject.query_range(prometheus_query)).to be_nil
expect(req_stub).to have_been_requested
end
end
- context 'when request returns matrix results' do
- it 'returns data from the API call' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_values_body('matrix'))
+ context "when request returns matrix results" do
+ it "returns data from the API call" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_values_body("matrix"))
expect(subject.query_range(prometheus_query)).to eq([
{
"metric" => {},
- "values" => [[1488758662.506, "0.00002996364761904785"], [1488758722.506, "0.00003090239047619091"]]
- }
+ "values" => [[1488758662.506, "0.00002996364761904785"], [1488758722.506, "0.00003090239047619091"]],
+ },
])
expect(req_stub).to have_been_requested
end
end
- context 'when request returns no data' do
- it 'returns []' do
- req_stub = stub_prometheus_request(query_url, body: prometheus_empty_body('matrix'))
+ context "when request returns no data" do
+ it "returns []" do
+ req_stub = stub_prometheus_request(query_url, body: prometheus_empty_body("matrix"))
expect(subject.query_range(prometheus_query)).to be_empty
expect(req_stub).to have_been_requested
end
end
- it_behaves_like 'failure response' do
+ it_behaves_like "failure response" do
let(:execute_query) { subject.query_range(prometheus_query) }
end
end
diff --git a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
index f8faeffb935..3dd4dbb2f61 100644
--- a/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
+++ b/spec/lib/gitlab/query_limiting/active_support_subscriber_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QueryLimiting::ActiveSupportSubscriber do
let(:transaction) { instance_double(Gitlab::QueryLimiting::Transaction, increment: true) }
@@ -9,8 +9,8 @@ describe Gitlab::QueryLimiting::ActiveSupportSubscriber do
.and_return(transaction)
end
- describe '#sql' do
- it 'increments the number of executed SQL queries' do
+ describe "#sql" do
+ it "increments the number of executed SQL queries" do
User.count
expect(transaction)
@@ -18,8 +18,8 @@ describe Gitlab::QueryLimiting::ActiveSupportSubscriber do
.once
end
- context 'when the query is actually a rails cache hit' do
- it 'does not increment the number of executed SQL queries' do
+ context "when the query is actually a rails cache hit" do
+ it "does not increment the number of executed SQL queries" do
ActiveRecord::Base.connection.cache do
User.count
User.count
diff --git a/spec/lib/gitlab/query_limiting/middleware_spec.rb b/spec/lib/gitlab/query_limiting/middleware_spec.rb
index a04bcdecb4b..43a5766dd33 100644
--- a/spec/lib/gitlab/query_limiting/middleware_spec.rb
+++ b/spec/lib/gitlab/query_limiting/middleware_spec.rb
@@ -1,65 +1,65 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QueryLimiting::Middleware do
- describe '#call' do
- it 'runs the application with query limiting in place' do
- middleware = described_class.new(-> (env) { env })
+ describe "#call" do
+ it "runs the application with query limiting in place" do
+ middleware = described_class.new(->(env) { env })
expect_any_instance_of(Gitlab::QueryLimiting::Transaction)
.to receive(:act_upon_results)
- expect(middleware.call({ number: 10 }))
- .to eq({ number: 10 })
+ expect(middleware.call({number: 10}))
+ .to eq({number: 10})
end
end
- describe '#action_name' do
- let(:middleware) { described_class.new(-> (env) { env }) }
+ describe "#action_name" do
+ let(:middleware) { described_class.new(->(env) { env }) }
- context 'using a Rails request' do
- it 'returns the name of the controller and action' do
+ context "using a Rails request" do
+ it "returns the name of the controller and action" do
env = {
described_class::CONTROLLER_KEY => double(
:controller,
- action_name: 'show',
- class: double(:class, name: 'UsersController'),
- content_type: 'text/html'
- )
+ action_name: "show",
+ class: double(:class, name: "UsersController"),
+ content_type: "text/html"
+ ),
}
- expect(middleware.action_name(env)).to eq('UsersController#show')
+ expect(middleware.action_name(env)).to eq("UsersController#show")
end
- it 'includes the content type if this is not text/html' do
+ it "includes the content type if this is not text/html" do
env = {
described_class::CONTROLLER_KEY => double(
:controller,
- action_name: 'show',
- class: double(:class, name: 'UsersController'),
- content_type: 'application/json'
- )
+ action_name: "show",
+ class: double(:class, name: "UsersController"),
+ content_type: "application/json"
+ ),
}
expect(middleware.action_name(env))
- .to eq('UsersController#show (application/json)')
+ .to eq("UsersController#show (application/json)")
end
end
- context 'using a Grape API request' do
- it 'returns the name of the request method and endpoint path' do
+ context "using a Grape API request" do
+ it "returns the name of the request method and endpoint path" do
env = {
described_class::ENDPOINT_KEY => double(
:endpoint,
- route: double(:route, request_method: 'GET', path: '/foo')
- )
+ route: double(:route, request_method: "GET", path: "/foo")
+ ),
}
- expect(middleware.action_name(env)).to eq('GET /foo')
+ expect(middleware.action_name(env)).to eq("GET /foo")
end
- it 'returns nil if the route can not be retrieved' do
+ it "returns nil if the route can not be retrieved" do
endpoint = double(:endpoint)
- env = { described_class::ENDPOINT_KEY => endpoint }
+ env = {described_class::ENDPOINT_KEY => endpoint}
allow(endpoint)
.to receive(:route)
diff --git a/spec/lib/gitlab/query_limiting/transaction_spec.rb b/spec/lib/gitlab/query_limiting/transaction_spec.rb
index b72b8574174..1a244b515e0 100644
--- a/spec/lib/gitlab/query_limiting/transaction_spec.rb
+++ b/spec/lib/gitlab/query_limiting/transaction_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QueryLimiting::Transaction do
after do
Thread.current[described_class::THREAD_KEY] = nil
end
- describe '.current' do
- it 'returns nil when there is no transaction' do
+ describe ".current" do
+ it "returns nil when there is no transaction" do
expect(described_class.current).to be_nil
end
- it 'returns the transaction when present' do
+ it "returns the transaction when present" do
Thread.current[described_class::THREAD_KEY] = described_class.new
expect(described_class.current).to be_an_instance_of(described_class)
end
end
- describe '.run' do
- it 'runs a transaction and returns it and its return value' do
- trans, ret = described_class.run do
+ describe ".run" do
+ it "runs a transaction and returns it and its return value" do
+ trans, ret = described_class.run {
10
- end
+ }
expect(trans).to be_an_instance_of(described_class)
expect(ret).to eq(10)
end
- it 'removes the transaction from the current thread upon completion' do
+ it "removes the transaction from the current thread upon completion" do
described_class.run do
10
end
@@ -36,9 +36,9 @@ describe Gitlab::QueryLimiting::Transaction do
end
end
- describe '#act_upon_results' do
- context 'when the query threshold is not exceeded' do
- it 'does nothing' do
+ describe "#act_upon_results" do
+ context "when the query threshold is not exceeded" do
+ it "does nothing" do
trans = described_class.new
expect(trans).not_to receive(:raise)
@@ -47,7 +47,7 @@ describe Gitlab::QueryLimiting::Transaction do
end
end
- context 'when the query threshold is exceeded' do
+ context "when the query threshold is exceeded" do
let(:transaction) do
trans = described_class.new
trans.count = described_class::THRESHOLD + 1
@@ -55,15 +55,15 @@ describe Gitlab::QueryLimiting::Transaction do
trans
end
- it 'raises an error when this is enabled' do
+ it "raises an error when this is enabled" do
expect { transaction.act_upon_results }
.to raise_error(described_class::ThresholdExceededError)
end
end
end
- describe '#increment' do
- it 'increments the number of executed queries' do
+ describe "#increment" do
+ it "increments the number of executed queries" do
transaction = described_class.new
expect(transaction.count).to be_zero
@@ -74,14 +74,14 @@ describe Gitlab::QueryLimiting::Transaction do
end
end
- describe '#raise_error?' do
- it 'returns true in a test environment' do
+ describe "#raise_error?" do
+ it "returns true in a test environment" do
transaction = described_class.new
expect(transaction.raise_error?).to eq(true)
end
- it 'returns false in a production environment' do
+ it "returns false in a production environment" do
transaction = described_class.new
expect(Rails.env)
@@ -92,14 +92,14 @@ describe Gitlab::QueryLimiting::Transaction do
end
end
- describe '#threshold_exceeded?' do
- it 'returns false when the threshold is not exceeded' do
+ describe "#threshold_exceeded?" do
+ it "returns false when the threshold is not exceeded" do
transaction = described_class.new
expect(transaction.threshold_exceeded?).to eq(false)
end
- it 'returns true when the threshold is exceeded' do
+ it "returns true when the threshold is exceeded" do
transaction = described_class.new
transaction.count = described_class::THRESHOLD + 1
@@ -107,8 +107,8 @@ describe Gitlab::QueryLimiting::Transaction do
end
end
- describe '#error_message' do
- it 'returns the error message to display when the threshold is exceeded' do
+ describe "#error_message" do
+ it "returns the error message to display when the threshold is exceeded" do
transaction = described_class.new
transaction.count = max = described_class::THRESHOLD
@@ -118,10 +118,10 @@ describe Gitlab::QueryLimiting::Transaction do
)
end
- it 'includes the action name in the error message when present' do
+ it "includes the action name in the error message when present" do
transaction = described_class.new
transaction.count = max = described_class::THRESHOLD
- transaction.action = 'UsersController#show'
+ transaction.action = "UsersController#show"
expect(transaction.error_message).to eq(
"Too many SQL queries were executed in UsersController#show: " \
diff --git a/spec/lib/gitlab/query_limiting_spec.rb b/spec/lib/gitlab/query_limiting_spec.rb
index 42877b1e2dd..43f1933eea4 100644
--- a/spec/lib/gitlab/query_limiting_spec.rb
+++ b/spec/lib/gitlab/query_limiting_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QueryLimiting do
- describe '.enable?' do
- it 'returns true in a test environment' do
+ describe ".enable?" do
+ it "returns true in a test environment" do
expect(described_class.enable?).to eq(true)
end
- it 'returns true in a development environment' do
+ it "returns true in a development environment" do
allow(Rails.env).to receive(:development?).and_return(true)
expect(described_class.enable?).to eq(true)
end
- it 'returns false on GitLab.com' do
+ it "returns false on GitLab.com" do
expect(Rails.env).to receive(:development?).and_return(false)
expect(Rails.env).to receive(:test?).and_return(false)
allow(Gitlab).to receive(:com?).and_return(true)
@@ -20,7 +20,7 @@ describe Gitlab::QueryLimiting do
expect(described_class.enable?).to eq(false)
end
- it 'returns false in a non GitLab.com' do
+ it "returns false in a non GitLab.com" do
allow(Gitlab).to receive(:com?).and_return(false)
expect(Rails.env).to receive(:development?).and_return(false)
expect(Rails.env).to receive(:test?).and_return(false)
@@ -29,20 +29,20 @@ describe Gitlab::QueryLimiting do
end
end
- describe '.whitelist' do
- it 'raises ArgumentError when an invalid issue URL is given' do
- expect { described_class.whitelist('foo') }
+ describe ".whitelist" do
+ it "raises ArgumentError when an invalid issue URL is given" do
+ expect { described_class.whitelist("foo") }
.to raise_error(ArgumentError)
end
- context 'without a transaction' do
- it 'does nothing' do
- expect { described_class.whitelist('https://example.com') }
+ context "without a transaction" do
+ it "does nothing" do
+ expect { described_class.whitelist("https://example.com") }
.not_to raise_error
end
end
- context 'with a transaction' do
+ context "with a transaction" do
let(:transaction) { Gitlab::QueryLimiting::Transaction.new }
before do
@@ -51,10 +51,10 @@ describe Gitlab::QueryLimiting do
.and_return(transaction)
end
- it 'does not increment the number of SQL queries executed in the block' do
+ it "does not increment the number of SQL queries executed in the block" do
before = transaction.count
- described_class.whitelist('https://example.com')
+ described_class.whitelist("https://example.com")
2.times do
User.count
diff --git a/spec/lib/gitlab/quick_actions/command_definition_spec.rb b/spec/lib/gitlab/quick_actions/command_definition_spec.rb
index 5dae82a63b4..8d7160947d6 100644
--- a/spec/lib/gitlab/quick_actions/command_definition_spec.rb
+++ b/spec/lib/gitlab/quick_actions/command_definition_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QuickActions::CommandDefinition do
subject { described_class.new(:command) }
@@ -168,70 +168,70 @@ describe Gitlab::QuickActions::CommandDefinition do
end
end
- context 'when the command defines parse_params block' do
+ context "when the command defines parse_params block" do
before do
subject.parse_params_block = ->(raw) { raw.strip }
subject.action_block = ->(parsed) { self.received_arg = parsed }
end
- it 'executes the command passing the parsed param' do
- subject.execute(context, 'something ')
+ it "executes the command passing the parsed param" do
+ subject.execute(context, "something ")
- expect(context.received_arg).to eq('something')
+ expect(context.received_arg).to eq("something")
end
end
end
end
end
- describe '#explain' do
- context 'when the command is not available' do
+ describe "#explain" do
+ context "when the command is not available" do
before do
subject.condition_block = proc { false }
- subject.explanation = 'Explanation'
+ subject.explanation = "Explanation"
end
- it 'returns nil' do
+ it "returns nil" do
result = subject.explain({}, nil)
expect(result).to be_nil
end
end
- context 'when the explanation is a static string' do
+ context "when the explanation is a static string" do
before do
- subject.explanation = 'Explanation'
+ subject.explanation = "Explanation"
end
- it 'returns this static string' do
+ it "returns this static string" do
result = subject.explain({}, nil)
- expect(result).to eq 'Explanation'
+ expect(result).to eq "Explanation"
end
end
- context 'when warning is set' do
+ context "when warning is set" do
before do
- subject.explanation = 'Explanation'
- subject.warning = 'dangerous!'
+ subject.explanation = "Explanation"
+ subject.warning = "dangerous!"
end
- it 'returns this static string' do
+ it "returns this static string" do
result = subject.explain({}, nil)
- expect(result).to eq 'Explanation (dangerous!)'
+ expect(result).to eq "Explanation (dangerous!)"
end
end
- context 'when the explanation is dynamic' do
+ context "when the explanation is dynamic" do
before do
subject.explanation = proc { |arg| "Dynamic #{arg}" }
end
- it 'invokes the proc' do
- result = subject.explain({}, 'explanation')
+ it "invokes the proc" do
+ result = subject.explain({}, "explanation")
- expect(result).to eq 'Dynamic explanation'
+ expect(result).to eq "Dynamic explanation"
end
end
end
diff --git a/spec/lib/gitlab/quick_actions/dsl_spec.rb b/spec/lib/gitlab/quick_actions/dsl_spec.rb
index fd4df8694ba..166bdbdeddb 100644
--- a/spec/lib/gitlab/quick_actions/dsl_spec.rb
+++ b/spec/lib/gitlab/quick_actions/dsl_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QuickActions::Dsl do
before :all do
- DummyClass = Struct.new(:project) do
+ DummyClass = Struct.new(:project) {
include Gitlab::QuickActions::Dsl # rubocop:disable RSpec/DescribedClass
- desc 'A command with no args'
+ desc "A command with no args"
command :no_args, :none do
"Hello World!"
end
- params 'The first argument'
- explanation 'Static explanation'
- warning 'Possible problem!'
+ params "The first argument"
+ explanation "Static explanation"
+ warning "Possible problem!"
command :explanation_with_aliases, :once, :first do |arg|
arg
end
@@ -20,7 +20,7 @@ describe Gitlab::QuickActions::Dsl do
desc do
"A dynamic description for #{noteable.upcase}"
end
- params 'The first argument', 'The second argument'
+ params "The first argument", "The second argument"
command :dynamic_description do |args|
args.split
end
@@ -31,7 +31,7 @@ describe Gitlab::QuickActions::Dsl do
"Action does something with #{arg}"
end
condition do
- project == 'foo'
+ project == "foo"
end
command :cond_action do |arg|
arg
@@ -44,88 +44,88 @@ describe Gitlab::QuickActions::Dsl do
parsed
end
- params '<Comment>'
+ params "<Comment>"
substitution :something do |text|
"#{text} Some complicated thing you want in here"
end
- end
+ }
end
- describe '.command_definitions' do
- it 'returns an array with commands definitions' do
+ describe ".command_definitions" do
+ it "returns an array with commands definitions" do
no_args_def, explanation_with_aliases_def, dynamic_description_def,
cc_def, cond_action_def, with_params_parsing_def, substitution_def =
DummyClass.command_definitions
expect(no_args_def.name).to eq(:no_args)
expect(no_args_def.aliases).to eq([:none])
- expect(no_args_def.description).to eq('A command with no args')
- expect(no_args_def.explanation).to eq('')
+ expect(no_args_def.description).to eq("A command with no args")
+ expect(no_args_def.explanation).to eq("")
expect(no_args_def.params).to eq([])
expect(no_args_def.condition_block).to be_nil
expect(no_args_def.action_block).to be_a_kind_of(Proc)
expect(no_args_def.parse_params_block).to be_nil
- expect(no_args_def.warning).to eq('')
+ expect(no_args_def.warning).to eq("")
expect(explanation_with_aliases_def.name).to eq(:explanation_with_aliases)
expect(explanation_with_aliases_def.aliases).to eq([:once, :first])
- expect(explanation_with_aliases_def.description).to eq('')
- expect(explanation_with_aliases_def.explanation).to eq('Static explanation')
- expect(explanation_with_aliases_def.params).to eq(['The first argument'])
+ expect(explanation_with_aliases_def.description).to eq("")
+ expect(explanation_with_aliases_def.explanation).to eq("Static explanation")
+ expect(explanation_with_aliases_def.params).to eq(["The first argument"])
expect(explanation_with_aliases_def.condition_block).to be_nil
expect(explanation_with_aliases_def.action_block).to be_a_kind_of(Proc)
expect(explanation_with_aliases_def.parse_params_block).to be_nil
- expect(explanation_with_aliases_def.warning).to eq('Possible problem!')
+ expect(explanation_with_aliases_def.warning).to eq("Possible problem!")
expect(dynamic_description_def.name).to eq(:dynamic_description)
expect(dynamic_description_def.aliases).to eq([])
- expect(dynamic_description_def.to_h(OpenStruct.new(noteable: 'issue'))[:description]).to eq('A dynamic description for ISSUE')
- expect(dynamic_description_def.explanation).to eq('')
- expect(dynamic_description_def.params).to eq(['The first argument', 'The second argument'])
+ expect(dynamic_description_def.to_h(OpenStruct.new(noteable: "issue"))[:description]).to eq("A dynamic description for ISSUE")
+ expect(dynamic_description_def.explanation).to eq("")
+ expect(dynamic_description_def.params).to eq(["The first argument", "The second argument"])
expect(dynamic_description_def.condition_block).to be_nil
expect(dynamic_description_def.action_block).to be_a_kind_of(Proc)
expect(dynamic_description_def.parse_params_block).to be_nil
- expect(dynamic_description_def.warning).to eq('')
+ expect(dynamic_description_def.warning).to eq("")
expect(cc_def.name).to eq(:cc)
expect(cc_def.aliases).to eq([])
- expect(cc_def.description).to eq('')
- expect(cc_def.explanation).to eq('')
+ expect(cc_def.description).to eq("")
+ expect(cc_def.explanation).to eq("")
expect(cc_def.params).to eq([])
expect(cc_def.condition_block).to be_nil
expect(cc_def.action_block).to be_nil
expect(cc_def.parse_params_block).to be_nil
- expect(cc_def.warning).to eq('')
+ expect(cc_def.warning).to eq("")
expect(cond_action_def.name).to eq(:cond_action)
expect(cond_action_def.aliases).to eq([])
- expect(cond_action_def.description).to eq('')
+ expect(cond_action_def.description).to eq("")
expect(cond_action_def.explanation).to be_a_kind_of(Proc)
expect(cond_action_def.params).to eq([])
expect(cond_action_def.condition_block).to be_a_kind_of(Proc)
expect(cond_action_def.action_block).to be_a_kind_of(Proc)
expect(cond_action_def.parse_params_block).to be_nil
- expect(cond_action_def.warning).to eq('')
+ expect(cond_action_def.warning).to eq("")
expect(with_params_parsing_def.name).to eq(:with_params_parsing)
expect(with_params_parsing_def.aliases).to eq([])
- expect(with_params_parsing_def.description).to eq('')
- expect(with_params_parsing_def.explanation).to eq('')
+ expect(with_params_parsing_def.description).to eq("")
+ expect(with_params_parsing_def.explanation).to eq("")
expect(with_params_parsing_def.params).to eq([])
expect(with_params_parsing_def.condition_block).to be_nil
expect(with_params_parsing_def.action_block).to be_a_kind_of(Proc)
expect(with_params_parsing_def.parse_params_block).to be_a_kind_of(Proc)
- expect(with_params_parsing_def.warning).to eq('')
+ expect(with_params_parsing_def.warning).to eq("")
expect(substitution_def.name).to eq(:something)
expect(substitution_def.aliases).to eq([])
- expect(substitution_def.description).to eq('')
- expect(substitution_def.explanation).to eq('')
- expect(substitution_def.params).to eq(['<Comment>'])
+ expect(substitution_def.description).to eq("")
+ expect(substitution_def.explanation).to eq("")
+ expect(substitution_def.params).to eq(["<Comment>"])
expect(substitution_def.condition_block).to be_nil
- expect(substitution_def.action_block.call('text')).to eq('text Some complicated thing you want in here')
+ expect(substitution_def.action_block.call("text")).to eq("text Some complicated thing you want in here")
expect(substitution_def.parse_params_block).to be_nil
- expect(substitution_def.warning).to eq('')
+ expect(substitution_def.warning).to eq("")
end
end
end
diff --git a/spec/lib/gitlab/quick_actions/extractor_spec.rb b/spec/lib/gitlab/quick_actions/extractor_spec.rb
index 873bb359d6e..1e57176524c 100644
--- a/spec/lib/gitlab/quick_actions/extractor_spec.rb
+++ b/spec/lib/gitlab/quick_actions/extractor_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QuickActions::Extractor do
let(:definitions) do
- Class.new do
+ Class.new {
include Gitlab::QuickActions::Dsl
command(:reopen, :open) { }
@@ -10,60 +10,60 @@ describe Gitlab::QuickActions::Extractor do
command(:labels) { }
command(:power) { }
command(:noop_command)
- substitution(:substitution) { 'foo' }
+ substitution(:substitution) { "foo" }
substitution :shrug do |comment|
"#{comment} SHRUG"
end
- end.command_definitions
+ }.command_definitions
end
let(:extractor) { described_class.new(definitions) }
- shared_examples 'command with no argument' do
- it 'extracts command' do
+ shared_examples "command with no argument" do
+ it "extracts command" do
msg, commands = extractor.extract_commands(original_msg)
- expect(commands).to eq [['reopen']]
+ expect(commands).to eq [["reopen"]]
expect(msg).to eq final_msg
end
end
- shared_examples 'command with a single argument' do
- it 'extracts command' do
+ shared_examples "command with a single argument" do
+ it "extracts command" do
msg, commands = extractor.extract_commands(original_msg)
- expect(commands).to eq [['assign', '@joe']]
+ expect(commands).to eq [["assign", "@joe"]]
expect(msg).to eq final_msg
end
end
- shared_examples 'command with multiple arguments' do
- it 'extracts command' do
+ shared_examples "command with multiple arguments" do
+ it "extracts command" do
msg, commands = extractor.extract_commands(original_msg)
- expect(commands).to eq [['labels', '~foo ~"bar baz" label']]
+ expect(commands).to eq [["labels", '~foo ~"bar baz" label']]
expect(msg).to eq final_msg
end
end
- describe '#extract_commands' do
- describe 'command with no argument' do
- context 'at the start of content' do
- it_behaves_like 'command with no argument' do
+ describe "#extract_commands" do
+ describe "command with no argument" do
+ context "at the start of content" do
+ it_behaves_like "command with no argument" do
let(:original_msg) { "/reopen\nworld" }
let(:final_msg) { "world" }
end
end
- context 'in the middle of content' do
- it_behaves_like 'command with no argument' do
+ context "in the middle of content" do
+ it_behaves_like "command with no argument" do
let(:original_msg) { "hello\n/reopen\nworld" }
let(:final_msg) { "hello\nworld" }
end
end
- context 'in the middle of a line' do
- it 'does not extract command' do
+ context "in the middle of a line" do
+ it "does not extract command" do
msg = "hello\nworld /reopen"
msg, commands = extractor.extract_commands(msg)
@@ -72,39 +72,39 @@ describe Gitlab::QuickActions::Extractor do
end
end
- context 'at the end of content' do
- it_behaves_like 'command with no argument' do
+ context "at the end of content" do
+ it_behaves_like "command with no argument" do
let(:original_msg) { "hello\n/reopen" }
let(:final_msg) { "hello" }
end
end
end
- describe 'command with a single argument' do
- context 'at the start of content' do
- it_behaves_like 'command with a single argument' do
+ describe "command with a single argument" do
+ context "at the start of content" do
+ it_behaves_like "command with a single argument" do
let(:original_msg) { "/assign @joe\nworld" }
let(:final_msg) { "world" }
end
- it 'allows slash in command arguments' do
+ it "allows slash in command arguments" do
msg = "/assign @joe / @jane\nworld"
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['assign', '@joe / @jane']]
- expect(msg).to eq 'world'
+ expect(commands).to eq [["assign", "@joe / @jane"]]
+ expect(msg).to eq "world"
end
end
- context 'in the middle of content' do
- it_behaves_like 'command with a single argument' do
+ context "in the middle of content" do
+ it_behaves_like "command with a single argument" do
let(:original_msg) { "hello\n/assign @joe\nworld" }
let(:final_msg) { "hello\nworld" }
end
end
- context 'in the middle of a line' do
- it 'does not extract command' do
+ context "in the middle of a line" do
+ it "does not extract command" do
msg = "hello\nworld /assign @joe"
msg, commands = extractor.extract_commands(msg)
@@ -113,15 +113,15 @@ describe Gitlab::QuickActions::Extractor do
end
end
- context 'at the end of content' do
- it_behaves_like 'command with a single argument' do
+ context "at the end of content" do
+ it_behaves_like "command with a single argument" do
let(:original_msg) { "hello\n/assign @joe" }
let(:final_msg) { "hello" }
end
end
- context 'when argument is not separated with a space' do
- it 'does not extract command' do
+ context "when argument is not separated with a space" do
+ it "does not extract command" do
msg = "hello\n/assign@joe\nworld"
msg, commands = extractor.extract_commands(msg)
@@ -131,23 +131,23 @@ describe Gitlab::QuickActions::Extractor do
end
end
- describe 'command with multiple arguments' do
- context 'at the start of content' do
- it_behaves_like 'command with multiple arguments' do
+ describe "command with multiple arguments" do
+ context "at the start of content" do
+ it_behaves_like "command with multiple arguments" do
let(:original_msg) { %(/labels ~foo ~"bar baz" label\nworld) }
let(:final_msg) { "world" }
end
end
- context 'in the middle of content' do
- it_behaves_like 'command with multiple arguments' do
+ context "in the middle of content" do
+ it_behaves_like "command with multiple arguments" do
let(:original_msg) { %(hello\n/labels ~foo ~"bar baz" label\nworld) }
let(:final_msg) { "hello\nworld" }
end
end
- context 'in the middle of a line' do
- it 'does not extract command' do
+ context "in the middle of a line" do
+ it "does not extract command" do
msg = %(hello\nworld /labels ~foo ~"bar baz" label)
msg, commands = extractor.extract_commands(msg)
@@ -156,15 +156,15 @@ describe Gitlab::QuickActions::Extractor do
end
end
- context 'at the end of content' do
- it_behaves_like 'command with multiple arguments' do
+ context "at the end of content" do
+ it_behaves_like "command with multiple arguments" do
let(:original_msg) { %(hello\n/labels ~foo ~"bar baz" label) }
let(:final_msg) { "hello" }
end
end
- context 'when argument is not separated with a space' do
- it 'does not extract command' do
+ context "when argument is not separated with a space" do
+ it "does not extract command" do
msg = %(hello\n/labels~foo ~"bar baz" label\nworld)
msg, commands = extractor.extract_commands(msg)
@@ -174,79 +174,79 @@ describe Gitlab::QuickActions::Extractor do
end
end
- it 'extracts command with multiple arguments and various prefixes' do
+ it "extracts command with multiple arguments and various prefixes" do
msg = %(hello\n/power @user.name %9.10 ~"bar baz.2"\nworld)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2"']]
+ expect(commands).to eq [["power", '@user.name %9.10 ~"bar baz.2"']]
expect(msg).to eq "hello\nworld"
end
- it 'extracts command case insensitive' do
+ it "extracts command case insensitive" do
msg = %(hello\n/PoWer @user.name %9.10 ~"bar baz.2"\nworld)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2"']]
+ expect(commands).to eq [["power", '@user.name %9.10 ~"bar baz.2"']]
expect(msg).to eq "hello\nworld"
end
- it 'does not extract noop commands' do
+ it "does not extract noop commands" do
msg = %(hello\nworld\n/reopen\n/noop_command)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['reopen']]
+ expect(commands).to eq [["reopen"]]
expect(msg).to eq "hello\nworld\n/noop_command"
end
- it 'extracts and performs substitution commands' do
+ it "extracts and performs substitution commands" do
msg = %(hello\nworld\n/reopen\n/substitution)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['reopen'], ['substitution']]
+ expect(commands).to eq [["reopen"], ["substitution"]]
expect(msg).to eq "hello\nworld\nfoo"
end
- it 'extracts and performs substitution commands' do
+ it "extracts and performs substitution commands" do
msg = %(hello\nworld\n/reopen\n/shrug this is great?)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['reopen'], ['shrug', 'this is great?']]
+ expect(commands).to eq [["reopen"], ["shrug", "this is great?"]]
expect(msg).to eq "hello\nworld\nthis is great? SHRUG"
end
- it 'extracts and performs substitution commands case insensitive' do
+ it "extracts and performs substitution commands case insensitive" do
msg = %(hello\nworld\n/reOpen\n/sHRuG this is great?)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['reopen'], ['shrug', 'this is great?']]
+ expect(commands).to eq [["reopen"], ["shrug", "this is great?"]]
expect(msg).to eq "hello\nworld\nthis is great? SHRUG"
end
- it 'extracts and performs substitution commands with comments' do
+ it "extracts and performs substitution commands with comments" do
msg = %(hello\nworld\n/reopen\n/substitution wow this is a thing.)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['reopen'], ['substitution', 'wow this is a thing.']]
+ expect(commands).to eq [["reopen"], ["substitution", "wow this is a thing."]]
expect(msg).to eq "hello\nworld\nfoo"
end
- it 'extracts multiple commands' do
+ it "extracts multiple commands" do
msg = %(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/reopen)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2" label'], ['reopen']]
+ expect(commands).to eq [["power", '@user.name %9.10 ~"bar baz.2" label'], ["reopen"]]
expect(msg).to eq "hello\nworld"
end
- it 'does not alter original content if no command is found' do
- msg = 'Fixes #123'
+ it "does not alter original content if no command is found" do
+ msg = "Fixes #123"
msg, commands = extractor.extract_commands(msg)
expect(commands).to be_empty
- expect(msg).to eq 'Fixes #123'
+ expect(msg).to eq "Fixes #123"
end
- it 'does not extract commands inside a blockcode' do
+ it "does not extract commands inside a blockcode" do
msg = "Hello\r\n```\r\nThis is some text\r\n/close\r\n/assign @user\r\n```\r\n\r\nWorld"
expected = msg.delete("\r")
msg, commands = extractor.extract_commands(msg)
@@ -255,7 +255,7 @@ describe Gitlab::QuickActions::Extractor do
expect(msg).to eq expected
end
- it 'does not extract commands inside a blockquote' do
+ it "does not extract commands inside a blockquote" do
msg = "Hello\r\n>>>\r\nThis is some text\r\n/close\r\n/assign @user\r\n>>>\r\n\r\nWorld"
expected = msg.delete("\r")
msg, commands = extractor.extract_commands(msg)
@@ -264,7 +264,7 @@ describe Gitlab::QuickActions::Extractor do
expect(msg).to eq expected
end
- it 'does not extract commands inside a HTML tag' do
+ it "does not extract commands inside a HTML tag" do
msg = "Hello\r\n<div>\r\nThis is some text\r\n/close\r\n/assign @user\r\n</div>\r\n\r\nWorld"
expected = msg.delete("\r")
msg, commands = extractor.extract_commands(msg)
@@ -273,18 +273,18 @@ describe Gitlab::QuickActions::Extractor do
expect(msg).to eq expected
end
- it 'limits to passed commands when they are passed' do
+ it "limits to passed commands when they are passed" do
msg = <<~MSG.strip
- Hello, we should only extract the commands passed
- /reopen
- /labels hello world
- /power
+ Hello, we should only extract the commands passed
+ /reopen
+ /labels hello world
+ /power
MSG
expected_msg = <<~EXPECTED.strip
- Hello, we should only extract the commands passed
- /power
+ Hello, we should only extract the commands passed
+ /power
EXPECTED
- expected_commands = [['reopen'], ['labels', 'hello world']]
+ expected_commands = [["reopen"], ["labels", "hello world"]]
msg, commands = extractor.extract_commands(msg, only: [:open, :labels])
diff --git a/spec/lib/gitlab/quick_actions/spend_time_and_date_separator_spec.rb b/spec/lib/gitlab/quick_actions/spend_time_and_date_separator_spec.rb
index 8b58f0b3725..dd9cc8d612e 100644
--- a/spec/lib/gitlab/quick_actions/spend_time_and_date_separator_spec.rb
+++ b/spec/lib/gitlab/quick_actions/spend_time_and_date_separator_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QuickActions::SpendTimeAndDateSeparator do
subject { described_class }
- shared_examples 'arg line with invalid parameters' do
- it 'return nil' do
+ shared_examples "arg line with invalid parameters" do
+ it "return nil" do
expect(subject.new(invalid_arg).execute).to eq(nil)
end
end
- shared_examples 'arg line with valid parameters' do
- it 'return time and date array' do
+ shared_examples "arg line with valid parameters" do
+ it "return time and date array" do
expect(subject.new(valid_arg).execute).to eq(expected_response)
end
end
- describe '#execute' do
- context 'invalid paramenter in arg line' do
- context 'empty arg line' do
- it_behaves_like 'arg line with invalid parameters' do
- let(:invalid_arg) { '' }
+ describe "#execute" do
+ context "invalid paramenter in arg line" do
+ context "empty arg line" do
+ it_behaves_like "arg line with invalid parameters" do
+ let(:invalid_arg) { "" }
end
end
- context 'future date in arg line' do
- it_behaves_like 'arg line with invalid parameters' do
- let(:invalid_arg) { '10m 6023-02-02' }
+ context "future date in arg line" do
+ it_behaves_like "arg line with invalid parameters" do
+ let(:invalid_arg) { "10m 6023-02-02" }
end
end
- context 'unparseable date(invalid mixes of delimiters)' do
- it_behaves_like 'arg line with invalid parameters' do
- let(:invalid_arg) { '10m 2017.02-02' }
+ context "unparseable date(invalid mixes of delimiters)" do
+ it_behaves_like "arg line with invalid parameters" do
+ let(:invalid_arg) { "10m 2017.02-02" }
end
end
- context 'trash in arg line' do
- let(:invalid_arg) { 'dfjkghdskjfghdjskfgdfg' }
+ context "trash in arg line" do
+ let(:invalid_arg) { "dfjkghdskjfghdjskfgdfg" }
- it 'return nil as time value' do
+ it "return nil as time value" do
time_date_response = subject.new(invalid_arg).execute
expect(time_date_response).to be_an_instance_of(Array)
@@ -47,19 +47,19 @@ describe Gitlab::QuickActions::SpendTimeAndDateSeparator do
end
end
- context 'only time present in arg line' do
- it_behaves_like 'arg line with valid parameters' do
- let(:valid_arg) { '2m 3m 5m 1h' }
+ context "only time present in arg line" do
+ it_behaves_like "arg line with valid parameters" do
+ let(:valid_arg) { "2m 3m 5m 1h" }
let(:time) { Gitlab::TimeTrackingFormatter.parse(valid_arg) }
let(:date) { DateTime.now.to_date }
let(:expected_response) { [time, date] }
end
end
- context 'simple time with date in arg line' do
- it_behaves_like 'arg line with valid parameters' do
- let(:raw_time) { '10m' }
- let(:raw_date) { '2016-02-02' }
+ context "simple time with date in arg line" do
+ it_behaves_like "arg line with valid parameters" do
+ let(:raw_time) { "10m" }
+ let(:raw_date) { "2016-02-02" }
let(:valid_arg) { "#{raw_time} #{raw_date}" }
let(:date) { Date.parse(raw_date) }
let(:time) { Gitlab::TimeTrackingFormatter.parse(raw_time) }
@@ -67,10 +67,10 @@ describe Gitlab::QuickActions::SpendTimeAndDateSeparator do
end
end
- context 'composite time with date in arg line' do
- it_behaves_like 'arg line with valid parameters' do
- let(:raw_time) { '2m 10m 1h 3d' }
- let(:raw_date) { '2016/02/02' }
+ context "composite time with date in arg line" do
+ it_behaves_like "arg line with valid parameters" do
+ let(:raw_time) { "2m 10m 1h 3d" }
+ let(:raw_date) { "2016/02/02" }
let(:valid_arg) { "#{raw_time} #{raw_date}" }
let(:date) { Date.parse(raw_date) }
let(:time) { Gitlab::TimeTrackingFormatter.parse(raw_time) }
diff --git a/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb
index 1bb8bc51c96..ce3461ae308 100644
--- a/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb
+++ b/spec/lib/gitlab/quick_actions/substitution_definition_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::QuickActions::SubstitutionDefinition do
let(:content) do
- <<EOF
-Hello! Let's do this!
-/sub_name I like this stuff
-EOF
+ <<~EOF
+ Hello! Let's do this!
+ /sub_name I like this stuff
+ EOF
end
subject do
described_class.new(:sub_name, action_block: proc { |text| "#{text} foo" })
end
- describe '#perform_substitution!' do
- it 'returns nil if content is nil' do
+ describe "#perform_substitution!" do
+ it "returns nil if content is nil" do
expect(subject.perform_substitution(self, nil)).to be_nil
end
- it 'performs the substitution by default' do
- expect(subject.perform_substitution(self, content)).to eq <<EOF
-Hello! Let's do this!
-I like this stuff foo
-EOF
+ it "performs the substitution by default" do
+ expect(subject.perform_substitution(self, content)).to eq <<~EOF
+ Hello! Let's do this!
+ I like this stuff foo
+ EOF
end
end
- describe '#match' do
- it 'checks the content for the command' do
+ describe "#match" do
+ it "checks the content for the command" do
expect(subject.match(content)).to be_truthy
end
- it 'returns the match data' do
+ it "returns the match data" do
data = subject.match(content)
expect(data).to be_a(MatchData)
- expect(data[1]).to eq('I like this stuff')
+ expect(data[1]).to eq("I like this stuff")
end
- it 'is nil if content does not have the command' do
- expect(subject.match('blah')).to be_falsey
+ it "is nil if content does not have the command" do
+ expect(subject.match("blah")).to be_falsey
end
end
end
diff --git a/spec/lib/gitlab/redis/cache_spec.rb b/spec/lib/gitlab/redis/cache_spec.rb
index 5a4f17cfcf6..2c1cd332678 100644
--- a/spec/lib/gitlab/redis/cache_spec.rb
+++ b/spec/lib/gitlab/redis/cache_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Redis::Cache do
let(:config_file_name) { "config/redis.cache.yml" }
diff --git a/spec/lib/gitlab/redis/queues_spec.rb b/spec/lib/gitlab/redis/queues_spec.rb
index 01ca25635a9..74b230b019e 100644
--- a/spec/lib/gitlab/redis/queues_spec.rb
+++ b/spec/lib/gitlab/redis/queues_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Redis::Queues do
let(:config_file_name) { "config/redis.queues.yml" }
diff --git a/spec/lib/gitlab/redis/shared_state_spec.rb b/spec/lib/gitlab/redis/shared_state_spec.rb
index 24b73745dc5..9e365afedca 100644
--- a/spec/lib/gitlab/redis/shared_state_spec.rb
+++ b/spec/lib/gitlab/redis/shared_state_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Redis::SharedState do
let(:config_file_name) { "config/redis.shared_state.yml" }
diff --git a/spec/lib/gitlab/redis/wrapper_spec.rb b/spec/lib/gitlab/redis/wrapper_spec.rb
index 0c22a0d62cc..180e434c1ee 100644
--- a/spec/lib/gitlab/redis/wrapper_spec.rb
+++ b/spec/lib/gitlab/redis/wrapper_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Redis::Wrapper do
let(:config_file_name) { "config/resque.yml" }
@@ -18,10 +18,10 @@ describe Gitlab::Redis::Wrapper do
include_examples "redis_shared_examples"
- describe '.config_file_path' do
- it 'returns the absolute path to the configuration file' do
- expect(described_class.config_file_path('foo.yml'))
- .to eq Rails.root.join('config', 'foo.yml').to_s
+ describe ".config_file_path" do
+ it "returns the absolute path to the configuration file" do
+ expect(described_class.config_file_path("foo.yml"))
+ .to eq Rails.root.join("config", "foo.yml").to_s
end
end
end
diff --git a/spec/lib/gitlab/reference_counter_spec.rb b/spec/lib/gitlab/reference_counter_spec.rb
index b2344d1870a..571ad458383 100644
--- a/spec/lib/gitlab/reference_counter_spec.rb
+++ b/spec/lib/gitlab/reference_counter_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ReferenceCounter do
- let(:redis) { double('redis') }
+ let(:redis) { double("redis") }
let(:reference_counter_key) { "git-receive-pack-reference-counter:project-1" }
- let(:reference_counter) { described_class.new('project-1') }
+ let(:reference_counter) { described_class.new("project-1") }
before do
allow(Gitlab::Redis::SharedState).to receive(:with).and_yield(redis)
end
- it 'increases and set the expire time of a reference count for a path' do
+ it "increases and set the expire time of a reference count for a path" do
expect(redis).to receive(:incr).with(reference_counter_key)
expect(redis).to receive(:expire).with(reference_counter_key,
- described_class::REFERENCE_EXPIRE_TIME)
+ described_class::REFERENCE_EXPIRE_TIME)
expect(reference_counter.increase).to be(true)
end
- it 'decreases the reference count for a path' do
+ it "decreases the reference count for a path" do
allow(redis).to receive(:decr).and_return(0)
expect(redis).to receive(:decr).with(reference_counter_key)
expect(reference_counter.decrease).to be(true)
end
- it 'warns if attempting to decrease a counter with a value of one or less, and resets the counter' do
+ it "warns if attempting to decrease a counter with a value of one or less, and resets the counter" do
expect(redis).to receive(:decr).and_return(-1)
expect(redis).to receive(:del)
expect(Rails.logger).to receive(:warn).with("Reference counter for project-1" \
@@ -30,7 +30,7 @@ describe Gitlab::ReferenceCounter do
expect(reference_counter.decrease).to be(true)
end
- it 'get the reference count for a path' do
+ it "get the reference count for a path" do
allow(redis).to receive(:get).and_return(1)
expect(reference_counter.value).to be(1)
end
diff --git a/spec/lib/gitlab/reference_extractor_spec.rb b/spec/lib/gitlab/reference_extractor_spec.rb
index 4139d1c650c..cbb86f1e12b 100644
--- a/spec/lib/gitlab/reference_extractor_spec.rb
+++ b/spec/lib/gitlab/reference_extractor_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ReferenceExtractor do
let(:project) { create(:project) }
@@ -9,27 +9,27 @@ describe Gitlab::ReferenceExtractor do
subject { described_class.new(project, project.creator) }
- it 'accesses valid user objects' do
- @u_foo = create(:user, username: 'foo')
- @u_bar = create(:user, username: 'bar')
- @u_offteam = create(:user, username: 'offteam')
+ it "accesses valid user objects" do
+ @u_foo = create(:user, username: "foo")
+ @u_bar = create(:user, username: "bar")
+ @u_offteam = create(:user, username: "offteam")
project.add_guest(@u_foo)
project.add_guest(@u_bar)
- subject.analyze('@foo, @baduser, @bar, and @offteam')
+ subject.analyze("@foo, @baduser, @bar, and @offteam")
expect(subject.users).to match_array([@u_foo, @u_bar, @u_offteam])
end
- it 'ignores user mentions inside specific elements' do
- @u_foo = create(:user, username: 'foo')
- @u_bar = create(:user, username: 'bar')
- @u_offteam = create(:user, username: 'offteam')
+ it "ignores user mentions inside specific elements" do
+ @u_foo = create(:user, username: "foo")
+ @u_bar = create(:user, username: "bar")
+ @u_offteam = create(:user, username: "offteam")
project.add_reporter(@u_foo)
project.add_reporter(@u_bar)
- subject.analyze(%Q{
+ subject.analyze(%(
Inline code: `@foo`
Code block:
@@ -41,58 +41,58 @@ describe Gitlab::ReferenceExtractor do
Quote:
> @offteam
- })
+ ))
expect(subject.users).to match_array([])
end
- describe 'directly addressed users' do
+ describe "directly addressed users" do
before do
- @u_foo = create(:user, username: 'foo')
- @u_foo2 = create(:user, username: 'foo2')
- @u_foo3 = create(:user, username: 'foo3')
- @u_foo4 = create(:user, username: 'foo4')
- @u_foo5 = create(:user, username: 'foo5')
-
- @u_bar = create(:user, username: 'bar')
- @u_bar2 = create(:user, username: 'bar2')
- @u_bar3 = create(:user, username: 'bar3')
- @u_bar4 = create(:user, username: 'bar4')
-
- @u_tom = create(:user, username: 'tom')
- @u_tom2 = create(:user, username: 'tom2')
+ @u_foo = create(:user, username: "foo")
+ @u_foo2 = create(:user, username: "foo2")
+ @u_foo3 = create(:user, username: "foo3")
+ @u_foo4 = create(:user, username: "foo4")
+ @u_foo5 = create(:user, username: "foo5")
+
+ @u_bar = create(:user, username: "bar")
+ @u_bar2 = create(:user, username: "bar2")
+ @u_bar3 = create(:user, username: "bar3")
+ @u_bar4 = create(:user, username: "bar4")
+
+ @u_tom = create(:user, username: "tom")
+ @u_tom2 = create(:user, username: "tom2")
end
- context 'when a user is directly addressed' do
- it 'accesses the user object which is mentioned in the beginning of the line' do
- subject.analyze('@foo What do you think? cc: @bar, @tom')
+ context "when a user is directly addressed" do
+ it "accesses the user object which is mentioned in the beginning of the line" do
+ subject.analyze("@foo What do you think? cc: @bar, @tom")
expect(subject.directly_addressed_users).to match_array([@u_foo])
end
it "doesn't access the user object if it's not mentioned in the beginning of the line" do
- subject.analyze('What do you think? cc: @bar')
+ subject.analyze("What do you think? cc: @bar")
expect(subject.directly_addressed_users).to be_empty
end
end
- context 'when multiple users are addressed' do
- it 'accesses the user objects which are mentioned in the beginning of the line' do
- subject.analyze('@foo @bar What do you think? cc: @tom')
+ context "when multiple users are addressed" do
+ it "accesses the user objects which are mentioned in the beginning of the line" do
+ subject.analyze("@foo @bar What do you think? cc: @tom")
expect(subject.directly_addressed_users).to match_array([@u_foo, @u_bar])
end
it "doesn't access the user objects if they are not mentioned in the beginning of the line" do
- subject.analyze('What do you think? cc: @foo @bar @tom')
+ subject.analyze("What do you think? cc: @foo @bar @tom")
expect(subject.directly_addressed_users).to be_empty
end
end
- context 'when multiple users are addressed in different paragraphs' do
- it 'accesses user objects which are mentioned in the beginning of each paragraph' do
+ context "when multiple users are addressed in different paragraphs" do
+ it "accesses user objects which are mentioned in the beginning of each paragraph" do
subject.analyze <<-NOTE.strip_heredoc
@foo What do you think? cc: @tom
@@ -115,7 +115,7 @@ describe Gitlab::ReferenceExtractor do
end
end
- it 'does not include anchors from table of contents in issue references' do
+ it "does not include anchors from table of contents in issue references" do
issue1 = create(:issue, project: project)
issue2 = create(:issue, project: project)
@@ -124,7 +124,7 @@ describe Gitlab::ReferenceExtractor do
expect(subject.issues).to match_array([issue2])
end
- it 'accesses valid issue objects' do
+ it "accesses valid issue objects" do
@i0 = create(:issue, project: project)
@i1 = create(:issue, project: project)
@@ -133,18 +133,18 @@ describe Gitlab::ReferenceExtractor do
expect(subject.issues).to match_array([@i0, @i1])
end
- it 'accesses valid merge requests' do
- @m0 = create(:merge_request, source_project: project, target_project: project, source_branch: 'markdown')
- @m1 = create(:merge_request, source_project: project, target_project: project, source_branch: 'feature_conflict')
+ it "accesses valid merge requests" do
+ @m0 = create(:merge_request, source_project: project, target_project: project, source_branch: "markdown")
+ @m1 = create(:merge_request, source_project: project, target_project: project, source_branch: "feature_conflict")
subject.analyze("!999, !#{@m1.iid}, and !#{@m0.iid}.")
expect(subject.merge_requests).to match_array([@m1, @m0])
end
- it 'accesses valid labels' do
- @l0 = create(:label, title: 'one', project: project)
- @l1 = create(:label, title: 'two', project: project)
+ it "accesses valid labels" do
+ @l0 = create(:label, title: "one", project: project)
+ @l1 = create(:label, title: "two", project: project)
@l2 = create(:label)
subject.analyze("~#{@l0.id}, ~999, ~#{@l2.id}, ~#{@l1.id}")
@@ -152,7 +152,7 @@ describe Gitlab::ReferenceExtractor do
expect(subject.labels).to match_array([@l0, @l1])
end
- it 'accesses valid snippets' do
+ it "accesses valid snippets" do
@s0 = create(:project_snippet, project: project)
@s1 = create(:project_snippet, project: project)
@s2 = create(:project_snippet)
@@ -162,9 +162,9 @@ describe Gitlab::ReferenceExtractor do
expect(subject.snippets).to match_array([@s0, @s1])
end
- it 'accesses valid commits' do
+ it "accesses valid commits" do
project = create(:project, :repository) { |p| p.add_developer(p.creator) }
- commit = project.commit('master')
+ commit = project.commit("master")
extractor = described_class.new(project, project.creator)
extractor.analyze("this references commits #{commit.sha[0..6]} and 012345")
@@ -175,10 +175,10 @@ describe Gitlab::ReferenceExtractor do
expect(extracted[0].message).to eq(commit.message)
end
- it 'accesses valid commit ranges' do
+ it "accesses valid commit ranges" do
project = create(:project, :repository) { |p| p.add_developer(p.creator) }
- commit = project.commit('master')
- earlier_commit = project.commit('master~2')
+ commit = project.commit("master")
+ earlier_commit = project.commit("master~2")
extractor = described_class.new(project, project.creator)
extractor.analyze("this references commits #{earlier_commit.sha[0..6]}...#{commit.sha[0..6]}")
@@ -190,48 +190,48 @@ describe Gitlab::ReferenceExtractor do
expect(extracted.first.commit_to).to eq commit
end
- context 'with an external issue tracker' do
+ context "with an external issue tracker" do
let(:project) { create(:jira_project) }
let(:issue) { create(:issue, project: project) }
- context 'when GitLab issues are enabled' do
- it 'returns both JIRA and internal issues' do
+ context "when GitLab issues are enabled" do
+ it "returns both JIRA and internal issues" do
subject.analyze("JIRA-123 and FOOBAR-4567 and #{issue.to_reference}")
- expect(subject.issues).to eq [ExternalIssue.new('JIRA-123', project),
- ExternalIssue.new('FOOBAR-4567', project),
- issue]
+ expect(subject.issues).to eq [ExternalIssue.new("JIRA-123", project),
+ ExternalIssue.new("FOOBAR-4567", project),
+ issue,]
end
- it 'returns only JIRA issues if the internal one does not exists' do
+ it "returns only JIRA issues if the internal one does not exists" do
subject.analyze("JIRA-123 and FOOBAR-4567 and #999")
- expect(subject.issues).to eq [ExternalIssue.new('JIRA-123', project),
- ExternalIssue.new('FOOBAR-4567', project)]
+ expect(subject.issues).to eq [ExternalIssue.new("JIRA-123", project),
+ ExternalIssue.new("FOOBAR-4567", project),]
end
end
- context 'when GitLab issues are disabled' do
+ context "when GitLab issues are disabled" do
before do
project.issues_enabled = false
project.save!
end
- it 'returns only JIRA issues' do
+ it "returns only JIRA issues" do
subject.analyze("JIRA-123 and FOOBAR-4567 and #{issue.to_reference}")
- expect(subject.issues).to eq [ExternalIssue.new('JIRA-123', project),
- ExternalIssue.new('FOOBAR-4567', project)]
+ expect(subject.issues).to eq [ExternalIssue.new("JIRA-123", project),
+ ExternalIssue.new("FOOBAR-4567", project),]
end
end
end
- context 'with a project with an underscore' do
- let(:other_project) { create(:project, path: 'test_project') }
+ context "with a project with an underscore" do
+ let(:other_project) { create(:project, path: "test_project") }
let(:issue) { create(:issue, project: other_project) }
before do
other_project.add_developer(project.creator)
end
- it 'handles project issue references' do
+ it "handles project issue references" do
subject.analyze("this refers issue #{issue.to_reference(project)}")
extracted = subject.issues
@@ -240,7 +240,7 @@ describe Gitlab::ReferenceExtractor do
end
end
- describe '#all' do
+ describe "#all" do
let(:issue) { create(:issue, project: project) }
let(:label) { create(:label, project: project) }
let(:text) { "Ref. #{issue.to_reference} and #{label.to_reference}" }
@@ -250,17 +250,17 @@ describe Gitlab::ReferenceExtractor do
subject.analyze(text)
end
- it 'returns all referables' do
+ it "returns all referables" do
expect(subject.all).to match_array([issue, label])
end
end
- describe '.references_pattern' do
+ describe ".references_pattern" do
subject { described_class.references_pattern }
it { is_expected.to be_kind_of Regexp }
end
- describe 'referables prefixes' do
+ describe "referables prefixes" do
def prefixes
described_class::REFERABLES.each_with_object({}) do |referable, result|
klass = referable.to_s.camelize.constantize
@@ -273,14 +273,14 @@ describe Gitlab::ReferenceExtractor do
end
end
- it 'returns all supported prefixes' do
- expect(prefixes.keys.uniq).to match_array(%w(@ # ~ % ! $ &))
+ it "returns all supported prefixes" do
+ expect(prefixes.keys.uniq).to match_array(%w[@ # ~ % ! $ &])
end
- it 'does not allow one prefix for multiple referables if not allowed specificly' do
+ it "does not allow one prefix for multiple referables if not allowed specificly" do
# make sure you are not overriding existing prefix before changing this hash
multiple_allowed = {
- '@' => 3
+ "@" => 3,
}
prefixes.each do |prefix, referables|
diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb
index a1079e54975..66b2000c207 100644
--- a/spec/lib/gitlab/regex_spec.rb
+++ b/spec/lib/gitlab/regex_spec.rb
@@ -1,58 +1,57 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Regex do
- describe '.project_name_regex' do
+ describe ".project_name_regex" do
subject { described_class.project_name_regex }
- it { is_expected.to match('gitlab-ce') }
- it { is_expected.to match('GitLab CE') }
- it { is_expected.to match('100 lines') }
- it { is_expected.to match('gitlab.git') }
- it { is_expected.to match('Český název') }
- it { is_expected.to match('Dash – is this') }
- it { is_expected.not_to match('?gitlab') }
+ it { is_expected.to match("gitlab-ce") }
+ it { is_expected.to match("GitLab CE") }
+ it { is_expected.to match("100 lines") }
+ it { is_expected.to match("gitlab.git") }
+ it { is_expected.to match("Český název") }
+ it { is_expected.to match("Dash – is this") }
+ it { is_expected.not_to match("?gitlab") }
end
- describe '.environment_name_regex' do
+ describe ".environment_name_regex" do
subject { described_class.environment_name_regex }
- it { is_expected.to match('foo') }
- it { is_expected.to match('a') }
- it { is_expected.to match('foo-1') }
- it { is_expected.to match('FOO') }
- it { is_expected.to match('foo/1') }
- it { is_expected.to match('foo.1') }
- it { is_expected.not_to match('9&foo') }
- it { is_expected.not_to match('foo-^') }
- it { is_expected.not_to match('!!()()') }
- it { is_expected.not_to match('/foo') }
- it { is_expected.not_to match('foo/') }
- it { is_expected.not_to match('/foo/') }
- it { is_expected.not_to match('/') }
+ it { is_expected.to match("foo") }
+ it { is_expected.to match("a") }
+ it { is_expected.to match("foo-1") }
+ it { is_expected.to match("FOO") }
+ it { is_expected.to match("foo/1") }
+ it { is_expected.to match("foo.1") }
+ it { is_expected.not_to match("9&foo") }
+ it { is_expected.not_to match("foo-^") }
+ it { is_expected.not_to match("!!()()") }
+ it { is_expected.not_to match("/foo") }
+ it { is_expected.not_to match("foo/") }
+ it { is_expected.not_to match("/foo/") }
+ it { is_expected.not_to match("/") }
end
- describe '.environment_slug_regex' do
+ describe ".environment_slug_regex" do
subject { described_class.environment_slug_regex }
- it { is_expected.to match('foo') }
- it { is_expected.to match('foo-1') }
- it { is_expected.not_to match('FOO') }
- it { is_expected.not_to match('foo/1') }
- it { is_expected.not_to match('foo.1') }
- it { is_expected.not_to match('foo*1') }
- it { is_expected.not_to match('9foo') }
- it { is_expected.not_to match('foo-') }
+ it { is_expected.to match("foo") }
+ it { is_expected.to match("foo-1") }
+ it { is_expected.not_to match("FOO") }
+ it { is_expected.not_to match("foo/1") }
+ it { is_expected.not_to match("foo.1") }
+ it { is_expected.not_to match("foo*1") }
+ it { is_expected.not_to match("9foo") }
+ it { is_expected.not_to match("foo-") }
end
- describe '.container_repository_name_regex' do
+ describe ".container_repository_name_regex" do
subject { described_class.container_repository_name_regex }
- it { is_expected.to match('image') }
- it { is_expected.to match('my/image') }
- it { is_expected.to match('my/awesome/image-1') }
- it { is_expected.to match('my/awesome/image.test') }
- it { is_expected.not_to match('.my/image') }
- it { is_expected.not_to match('my/image.') }
+ it { is_expected.to match("image") }
+ it { is_expected.to match("my/image") }
+ it { is_expected.to match("my/awesome/image-1") }
+ it { is_expected.to match("my/awesome/image.test") }
+ it { is_expected.not_to match(".my/image") }
+ it { is_expected.not_to match("my/image.") }
end
end
diff --git a/spec/lib/gitlab/repo_path_spec.rb b/spec/lib/gitlab/repo_path_spec.rb
index 13940713dfc..b527a87cca5 100644
--- a/spec/lib/gitlab/repo_path_spec.rb
+++ b/spec/lib/gitlab/repo_path_spec.rb
@@ -1,74 +1,74 @@
-require 'spec_helper'
+require "spec_helper"
describe ::Gitlab::RepoPath do
- describe '.parse' do
+ describe ".parse" do
set(:project) { create(:project, :repository) }
- context 'a repository storage path' do
- it 'parses a full repository path' do
+ context "a repository storage path" do
+ it "parses a full repository path" do
expect(described_class.parse(project.repository.full_path)).to eq([project, false, nil])
end
- it 'parses a full wiki path' do
+ it "parses a full wiki path" do
expect(described_class.parse(project.wiki.repository.full_path)).to eq([project, true, nil])
end
end
- context 'a relative path' do
- it 'parses a relative repository path' do
- expect(described_class.parse(project.full_path + '.git')).to eq([project, false, nil])
+ context "a relative path" do
+ it "parses a relative repository path" do
+ expect(described_class.parse(project.full_path + ".git")).to eq([project, false, nil])
end
- it 'parses a relative wiki path' do
- expect(described_class.parse(project.full_path + '.wiki.git')).to eq([project, true, nil])
+ it "parses a relative wiki path" do
+ expect(described_class.parse(project.full_path + ".wiki.git")).to eq([project, true, nil])
end
- it 'parses a relative path starting with /' do
- expect(described_class.parse('/' + project.full_path + '.git')).to eq([project, false, nil])
+ it "parses a relative path starting with /" do
+ expect(described_class.parse("/" + project.full_path + ".git")).to eq([project, false, nil])
end
- context 'of a redirected project' do
- let(:redirect) { project.route.create_redirect('foo/bar') }
+ context "of a redirected project" do
+ let(:redirect) { project.route.create_redirect("foo/bar") }
- it 'parses a relative repository path' do
- expect(described_class.parse(redirect.path + '.git')).to eq([project, false, 'foo/bar'])
+ it "parses a relative repository path" do
+ expect(described_class.parse(redirect.path + ".git")).to eq([project, false, "foo/bar"])
end
- it 'parses a relative wiki path' do
- expect(described_class.parse(redirect.path + '.wiki.git')).to eq([project, true, 'foo/bar.wiki'])
+ it "parses a relative wiki path" do
+ expect(described_class.parse(redirect.path + ".wiki.git")).to eq([project, true, "foo/bar.wiki"])
end
- it 'parses a relative path starting with /' do
- expect(described_class.parse('/' + redirect.path + '.git')).to eq([project, false, 'foo/bar'])
+ it "parses a relative path starting with /" do
+ expect(described_class.parse("/" + redirect.path + ".git")).to eq([project, false, "foo/bar"])
end
end
end
end
- describe '.find_project' do
+ describe ".find_project" do
let(:project) { create(:project) }
- let(:redirect) { project.route.create_redirect('foo/bar/baz') }
+ let(:redirect) { project.route.create_redirect("foo/bar/baz") }
- context 'when finding a project by its canonical path' do
- context 'when the cases match' do
- it 'returns the project and false' do
+ context "when finding a project by its canonical path" do
+ context "when the cases match" do
+ it "returns the project and false" do
expect(described_class.find_project(project.full_path)).to eq([project, false])
end
end
- context 'when the cases do not match' do
+ context "when the cases do not match" do
# This is slightly different than web behavior because on the web it is
# easy and safe to redirect someone to the correctly-cased URL. For git
# requests, we should accept wrongly-cased URLs because it is a pain to
# block people's git operations and force them to update remote URLs.
- it 'returns the project and false' do
+ it "returns the project and false" do
expect(described_class.find_project(project.full_path.upcase)).to eq([project, false])
end
end
end
- context 'when finding a project via a redirect' do
- it 'returns the project and true' do
+ context "when finding a project via a redirect" do
+ it "returns the project and true" do
expect(described_class.find_project(redirect.path)).to eq([project, true])
end
end
diff --git a/spec/lib/gitlab/repository_cache_adapter_spec.rb b/spec/lib/gitlab/repository_cache_adapter_spec.rb
index 0295138fc3a..6cd84718f33 100644
--- a/spec/lib/gitlab/repository_cache_adapter_spec.rb
+++ b/spec/lib/gitlab/repository_cache_adapter_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RepositoryCacheAdapter do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:cache) { repository.send(:cache) }
- describe '#cache_method_output', :use_clean_rails_memory_store_caching do
+ describe "#cache_method_output", :use_clean_rails_memory_store_caching do
let(:fallback) { 10 }
- context 'with a non-existing repository' do
+ context "with a non-existing repository" do
let(:project) { create(:project) } # No repository
subject do
@@ -17,29 +17,29 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- it 'returns the fallback value' do
+ it "returns the fallback value" do
expect(subject).to eq(fallback)
end
- it 'avoids calling the original method' do
+ it "avoids calling the original method" do
expect(repository).not_to receive(:cats_call_stub)
subject
end
end
- context 'with a method throwing a non-existing-repository error' do
+ context "with a method throwing a non-existing-repository error" do
subject do
repository.cache_method_output(:cats, fallback: fallback) do
raise Gitlab::Git::Repository::NoRepository
end
end
- it 'returns the fallback value' do
+ it "returns the fallback value" do
expect(subject).to eq(fallback)
end
- it 'does not cache the data' do
+ it "does not cache the data" do
subject
expect(repository.instance_variable_defined?(:@cats)).to eq(false)
@@ -47,8 +47,8 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- context 'with an existing repository' do
- it 'caches the output' do
+ context "with an existing repository" do
+ it "caches the output" do
object = double
expect(object).to receive(:number).once.and_return(10)
@@ -65,10 +65,10 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- describe '#cache_method_output_asymmetrically', :use_clean_rails_memory_store_caching, :request_store do
+ describe "#cache_method_output_asymmetrically", :use_clean_rails_memory_store_caching, :request_store do
let(:request_store_cache) { repository.send(:request_store_cache) }
- context 'with a non-existing repository' do
+ context "with a non-existing repository" do
let(:project) { create(:project) } # No repository
let(:object) { double }
@@ -78,25 +78,25 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- it 'returns the output of the original method' do
- expect(object).to receive(:cats_call_stub).and_return('output')
+ it "returns the output of the original method" do
+ expect(object).to receive(:cats_call_stub).and_return("output")
- expect(subject).to eq('output')
+ expect(subject).to eq("output")
end
end
- context 'with a method throwing a non-existing-repository error' do
+ context "with a method throwing a non-existing-repository error" do
subject do
repository.cache_method_output_asymmetrically(:cats) do
raise Gitlab::Git::Repository::NoRepository
end
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to eq(nil)
end
- it 'does not cache the data' do
+ it "does not cache the data" do
subject
expect(repository.instance_variable_defined?(:@cats)).to eq(false)
@@ -104,51 +104,51 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- context 'with an existing repository' do
+ context "with an existing repository" do
let(:object) { double }
- context 'when it returns truthy' do
+ context "when it returns truthy" do
before do
- expect(object).to receive(:cats).once.and_return('truthy output')
+ expect(object).to receive(:cats).once.and_return("truthy output")
end
- it 'caches the output in RequestStore' do
- expect do
+ it "caches the output in RequestStore" do
+ expect {
repository.cache_method_output_asymmetrically(:cats) { object.cats }
- end.to change { request_store_cache.read(:cats) }.from(nil).to('truthy output')
+ }.to change { request_store_cache.read(:cats) }.from(nil).to("truthy output")
end
- it 'caches the output in RepositoryCache' do
- expect do
+ it "caches the output in RepositoryCache" do
+ expect {
repository.cache_method_output_asymmetrically(:cats) { object.cats }
- end.to change { cache.read(:cats) }.from(nil).to('truthy output')
+ }.to change { cache.read(:cats) }.from(nil).to("truthy output")
end
end
- context 'when it returns false' do
+ context "when it returns false" do
before do
expect(object).to receive(:cats).once.and_return(false)
end
- it 'caches the output in RequestStore' do
- expect do
+ it "caches the output in RequestStore" do
+ expect {
repository.cache_method_output_asymmetrically(:cats) { object.cats }
- end.to change { request_store_cache.read(:cats) }.from(nil).to(false)
+ }.to change { request_store_cache.read(:cats) }.from(nil).to(false)
end
- it 'does NOT cache the output in RepositoryCache' do
- expect do
+ it "does NOT cache the output in RepositoryCache" do
+ expect {
repository.cache_method_output_asymmetrically(:cats) { object.cats }
- end.not_to change { cache.read(:cats) }.from(nil)
+ }.not_to change { cache.read(:cats) }.from(nil)
end
end
end
end
- describe '#memoize_method_output' do
+ describe "#memoize_method_output" do
let(:fallback) { 10 }
- context 'with a non-existing repository' do
+ context "with a non-existing repository" do
let(:project) { create(:project) } # No repository
subject do
@@ -157,66 +157,67 @@ describe Gitlab::RepositoryCacheAdapter do
end
end
- it 'returns the fallback value' do
+ it "returns the fallback value" do
expect(subject).to eq(fallback)
end
- it 'avoids calling the original method' do
+ it "avoids calling the original method" do
expect(repository).not_to receive(:cats_call_stub)
subject
end
- it 'does not set the instance variable' do
+ it "does not set the instance variable" do
subject
expect(repository.instance_variable_defined?(:@cats)).to eq(false)
end
end
- context 'with a method throwing a non-existing-repository error' do
+ context "with a method throwing a non-existing-repository error" do
subject do
repository.memoize_method_output(:cats, fallback: fallback) do
raise Gitlab::Git::Repository::NoRepository
end
end
- it 'returns the fallback value' do
+ it "returns the fallback value" do
expect(subject).to eq(fallback)
end
- it 'does not set the instance variable' do
+ it "does not set the instance variable" do
subject
expect(repository.instance_variable_defined?(:@cats)).to eq(false)
end
end
- context 'with an existing repository' do
- it 'sets the instance variable' do
+ context "with an existing repository" do
+ it "sets the instance variable" do
repository.memoize_method_output(:cats, fallback: fallback) do
- 'block output'
+ "block output"
end
- expect(repository.instance_variable_get(:@cats)).to eq('block output')
+ expect(repository.instance_variable_get(:@cats)).to eq("block output")
end
end
end
- describe '#expire_method_caches' do
- it 'expires the caches of the given methods' do
+ describe "#expire_method_caches" do
+ it "expires the caches of the given methods" do
expect(cache).to receive(:expire).with(:rendered_readme)
expect(cache).to receive(:expire).with(:gitignore)
- repository.expire_method_caches(%i(rendered_readme gitignore))
+ repository.expire_method_caches(%i[rendered_readme gitignore])
end
- it 'does not expire caches for non-existent methods' do
+ it "does not expire caches for non-existent methods" do
expect(cache).not_to receive(:expire).with(:nonexistent)
expect(Rails.logger).to(
- receive(:error).with("Requested to expire non-existent method 'nonexistent' for Repository"))
+ receive(:error).with("Requested to expire non-existent method 'nonexistent' for Repository")
+ )
- repository.expire_method_caches(%i(nonexistent))
+ repository.expire_method_caches(%i[nonexistent])
end
end
end
diff --git a/spec/lib/gitlab/repository_cache_spec.rb b/spec/lib/gitlab/repository_cache_spec.rb
index 741ee12633f..553bbcd7b72 100644
--- a/spec/lib/gitlab/repository_cache_spec.rb
+++ b/spec/lib/gitlab/repository_cache_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RepositoryCache do
- let(:backend) { double('backend').as_null_object }
+ let(:backend) { double("backend").as_null_object }
let(:project) { create(:project) }
let(:repository) { project.repository }
let(:namespace) { "#{repository.full_path}:#{project.id}" }
let(:cache) { described_class.new(repository, backend: backend) }
- describe '#cache_key' do
+ describe "#cache_key" do
subject { cache.cache_key(:foo) }
- it 'includes the namespace' do
+ it "includes the namespace" do
expect(subject).to eq "foo:#{namespace}"
end
- context 'with a given namespace' do
- let(:extra_namespace) { 'my:data' }
+ context "with a given namespace" do
+ let(:extra_namespace) { "my:data" }
let(:cache) do
described_class.new(repository, extra_namespace: extra_namespace,
backend: backend)
end
- it 'includes the full namespace' do
+ it "includes the full namespace" do
expect(subject).to eq "foo:#{namespace}:#{extra_namespace}"
end
end
end
- describe '#expire' do
- it 'expires the given key from the cache' do
+ describe "#expire" do
+ it "expires the given key from the cache" do
cache.expire(:foo)
expect(backend).to have_received(:delete).with("foo:#{namespace}")
end
end
- describe '#fetch' do
- it 'fetches the given key from the cache' do
+ describe "#fetch" do
+ it "fetches the given key from the cache" do
cache.fetch(:bar)
expect(backend).to have_received(:fetch).with("bar:#{namespace}")
end
- it 'accepts a block' do
+ it "accepts a block" do
p = -> {}
cache.fetch(:baz, &p)
@@ -48,41 +48,41 @@ describe Gitlab::RepositoryCache do
end
end
- describe '#fetch_without_caching_false', :use_clean_rails_memory_store_caching do
+ describe "#fetch_without_caching_false", :use_clean_rails_memory_store_caching do
let(:key) { :foo }
let(:backend) { Rails.cache }
- it 'requires a block' do
- expect do
+ it "requires a block" do
+ expect {
cache.fetch_without_caching_false(key)
- end.to raise_error(LocalJumpError)
+ }.to raise_error(LocalJumpError)
end
- context 'when the key does not exist in the cache' do
- context 'when the result of the block is truthy' do
- it 'returns the result of the block' do
+ context "when the key does not exist in the cache" do
+ context "when the result of the block is truthy" do
+ it "returns the result of the block" do
result = cache.fetch_without_caching_false(key) { true }
expect(result).to be true
end
- it 'caches the value' do
+ it "caches the value" do
expect(backend).to receive(:write).with("#{key}:#{namespace}", true)
cache.fetch_without_caching_false(key) { true }
end
end
- context 'when the result of the block is falsey' do
+ context "when the result of the block is falsey" do
let(:p) { -> { false } }
- it 'returns the result of the block' do
+ it "returns the result of the block" do
result = cache.fetch_without_caching_false(key, &p)
expect(result).to be false
end
- it 'does not cache the value' do
+ it "does not cache the value" do
expect(backend).not_to receive(:write).with("#{key}:#{namespace}", true)
cache.fetch_without_caching_false(key, &p)
@@ -90,45 +90,45 @@ describe Gitlab::RepositoryCache do
end
end
- context 'when the cached value is truthy' do
+ context "when the cached value is truthy" do
before do
backend.write("#{key}:#{namespace}", true)
end
- it 'returns the cached value' do
- result = cache.fetch_without_caching_false(key) { 'block result' }
+ it "returns the cached value" do
+ result = cache.fetch_without_caching_false(key) { "block result" }
expect(result).to be true
end
- it 'does not execute the block' do
- expect do |b|
+ it "does not execute the block" do
+ expect { |b|
cache.fetch_without_caching_false(key, &b)
- end.not_to yield_control
+ }.not_to yield_control
end
- it 'does not write to the cache' do
+ it "does not write to the cache" do
expect(backend).not_to receive(:write)
- cache.fetch_without_caching_false(key) { 'block result' }
+ cache.fetch_without_caching_false(key) { "block result" }
end
end
- context 'when the cached value is falsey' do
+ context "when the cached value is falsey" do
before do
backend.write("#{key}:#{namespace}", false)
end
- it 'returns the result of the block' do
- result = cache.fetch_without_caching_false(key) { 'block result' }
+ it "returns the result of the block" do
+ result = cache.fetch_without_caching_false(key) { "block result" }
- expect(result).to eq 'block result'
+ expect(result).to eq "block result"
end
- it 'writes the truthy value to the cache' do
- expect(backend).to receive(:write).with("#{key}:#{namespace}", 'block result')
+ it "writes the truthy value to the cache" do
+ expect(backend).to receive(:write).with("#{key}:#{namespace}", "block result")
- cache.fetch_without_caching_false(key) { 'block result' }
+ cache.fetch_without_caching_false(key) { "block result" }
end
end
end
diff --git a/spec/lib/gitlab/request_context_spec.rb b/spec/lib/gitlab/request_context_spec.rb
index fd443cc1f71..5847d959af1 100644
--- a/spec/lib/gitlab/request_context_spec.rb
+++ b/spec/lib/gitlab/request_context_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RequestContext do
- describe '#client_ip' do
+ describe "#client_ip" do
subject { described_class.client_ip }
- let(:app) { -> (env) {} }
- let(:env) { Hash.new }
+ let(:app) { ->(env) {} }
+ let(:env) { {} }
- context 'when RequestStore::Middleware is used' do
+ context "when RequestStore::Middleware is used" do
around do |example|
- RequestStore::Middleware.new(-> (env) { example.run }).call({})
+ RequestStore::Middleware.new(->(env) { example.run }).call({})
end
- context 'request' do
- let(:ip) { '192.168.1.11' }
+ context "request" do
+ let(:ip) { "192.168.1.11" }
before do
allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return(ip)
@@ -22,7 +22,7 @@ describe Gitlab::RequestContext do
it { is_expected.to eq(ip) }
end
- context 'before RequestContext middleware run' do
+ context "before RequestContext middleware run" do
it { is_expected.to be_nil }
end
end
diff --git a/spec/lib/gitlab/request_forgery_protection_spec.rb b/spec/lib/gitlab/request_forgery_protection_spec.rb
index 305de613866..f2b97a9e906 100644
--- a/spec/lib/gitlab/request_forgery_protection_spec.rb
+++ b/spec/lib/gitlab/request_forgery_protection_spec.rb
@@ -1,86 +1,86 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RequestForgeryProtection, :allow_forgery_protection do
let(:csrf_token) { SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) }
let(:env) do
{
- 'rack.input' => '',
- 'rack.session' => {
- _csrf_token: csrf_token
- }
+ "rack.input" => "",
+ "rack.session" => {
+ _csrf_token: csrf_token,
+ },
}
end
- describe '.call' do
- context 'when the request method is GET' do
+ describe ".call" do
+ context "when the request method is GET" do
before do
- env['REQUEST_METHOD'] = 'GET'
+ env["REQUEST_METHOD"] = "GET"
end
- it 'does not raise an exception' do
+ it "does not raise an exception" do
expect { described_class.call(env) }.not_to raise_exception
end
end
- context 'when the request method is POST' do
+ context "when the request method is POST" do
before do
- env['REQUEST_METHOD'] = 'POST'
+ env["REQUEST_METHOD"] = "POST"
end
- context 'when the CSRF token is valid' do
+ context "when the CSRF token is valid" do
before do
- env['HTTP_X_CSRF_TOKEN'] = csrf_token
+ env["HTTP_X_CSRF_TOKEN"] = csrf_token
end
- it 'does not raise an exception' do
+ it "does not raise an exception" do
expect { described_class.call(env) }.not_to raise_exception
end
end
- context 'when the CSRF token is invalid' do
+ context "when the CSRF token is invalid" do
before do
- env['HTTP_X_CSRF_TOKEN'] = 'foo'
+ env["HTTP_X_CSRF_TOKEN"] = "foo"
end
- it 'raises an ActionController::InvalidAuthenticityToken exception' do
+ it "raises an ActionController::InvalidAuthenticityToken exception" do
expect { described_class.call(env) }.to raise_exception(ActionController::InvalidAuthenticityToken)
end
end
end
end
- describe '.verified?' do
- context 'when the request method is GET' do
+ describe ".verified?" do
+ context "when the request method is GET" do
before do
- env['REQUEST_METHOD'] = 'GET'
+ env["REQUEST_METHOD"] = "GET"
end
- it 'returns true' do
+ it "returns true" do
expect(described_class.verified?(env)).to be_truthy
end
end
- context 'when the request method is POST' do
+ context "when the request method is POST" do
before do
- env['REQUEST_METHOD'] = 'POST'
+ env["REQUEST_METHOD"] = "POST"
end
- context 'when the CSRF token is valid' do
+ context "when the CSRF token is valid" do
before do
- env['HTTP_X_CSRF_TOKEN'] = csrf_token
+ env["HTTP_X_CSRF_TOKEN"] = csrf_token
end
- it 'returns true' do
+ it "returns true" do
expect(described_class.verified?(env)).to be_truthy
end
end
- context 'when the CSRF token is invalid' do
+ context "when the CSRF token is invalid" do
before do
- env['HTTP_X_CSRF_TOKEN'] = 'foo'
+ env["HTTP_X_CSRF_TOKEN"] = "foo"
end
- it 'returns false' do
+ it "returns false" do
expect(described_class.verified?(env)).to be_falsey
end
end
diff --git a/spec/lib/gitlab/request_profiler_spec.rb b/spec/lib/gitlab/request_profiler_spec.rb
index fd8cbf39bce..be2dfbb3ae6 100644
--- a/spec/lib/gitlab/request_profiler_spec.rb
+++ b/spec/lib/gitlab/request_profiler_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RequestProfiler do
- describe '.profile_token' do
- it 'returns a token' do
+ describe ".profile_token" do
+ it "returns a token" do
expect(described_class.profile_token).to be_present
end
- it 'caches the token' do
- expect(Rails.cache).to receive(:fetch).with('profile-token')
+ it "caches the token" do
+ expect(Rails.cache).to receive(:fetch).with("profile-token")
described_class.profile_token
end
end
- describe '.remove_all_profiles' do
- it 'removes Gitlab::RequestProfiler::PROFILES_DIR directory' do
+ describe ".remove_all_profiles" do
+ it "removes Gitlab::RequestProfiler::PROFILES_DIR directory" do
dir = described_class::PROFILES_DIR
FileUtils.mkdir_p(dir)
diff --git a/spec/lib/gitlab/route_map_spec.rb b/spec/lib/gitlab/route_map_spec.rb
index d672f7b5675..1078b9aac5a 100644
--- a/spec/lib/gitlab/route_map_spec.rb
+++ b/spec/lib/gitlab/route_map_spec.rb
@@ -1,62 +1,62 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::RouteMap do
- describe '#initialize' do
- context 'when the data is not YAML' do
- it 'raises an error' do
+ describe "#initialize" do
+ context "when the data is not YAML" do
+ it "raises an error" do
expect { described_class.new('"') }
.to raise_error(Gitlab::RouteMap::FormatError, /valid YAML/)
end
end
- context 'when the data is not a YAML array' do
- it 'raises an error' do
- expect { described_class.new(YAML.dump('foo')) }
+ context "when the data is not a YAML array" do
+ it "raises an error" do
+ expect { described_class.new(YAML.dump("foo")) }
.to raise_error(Gitlab::RouteMap::FormatError, /an array/)
end
end
- context 'when an entry is not a hash' do
- it 'raises an error' do
- expect { described_class.new(YAML.dump(['foo'])) }
+ context "when an entry is not a hash" do
+ it "raises an error" do
+ expect { described_class.new(YAML.dump(["foo"])) }
.to raise_error(Gitlab::RouteMap::FormatError, /a hash/)
end
end
- context 'when an entry does not have a source key' do
- it 'raises an error' do
- expect { described_class.new(YAML.dump([{ 'public' => 'index.html' }])) }
+ context "when an entry does not have a source key" do
+ it "raises an error" do
+ expect { described_class.new(YAML.dump([{"public" => "index.html"}])) }
.to raise_error(Gitlab::RouteMap::FormatError, /source key/)
end
end
- context 'when an entry does not have a public key' do
- it 'raises an error' do
- expect { described_class.new(YAML.dump([{ 'source' => '/index\.html/' }])) }
+ context "when an entry does not have a public key" do
+ it "raises an error" do
+ expect { described_class.new(YAML.dump([{"source" => '/index\.html/'}])) }
.to raise_error(Gitlab::RouteMap::FormatError, /public key/)
end
end
- context 'when an entry source is not a valid regex' do
- it 'raises an error' do
- expect { described_class.new(YAML.dump([{ 'source' => '/[/', 'public' => 'index.html' }])) }
+ context "when an entry source is not a valid regex" do
+ it "raises an error" do
+ expect { described_class.new(YAML.dump([{"source" => "/[/", "public" => "index.html"}])) }
.to raise_error(Gitlab::RouteMap::FormatError, /regular expression/)
end
end
- context 'when all is good' do
- it 'returns a route map' do
- route_map = described_class.new(YAML.dump([{ 'source' => 'index.haml', 'public' => 'index.html' }, { 'source' => '/(.*)\.md/', 'public' => '\1.html' }]))
+ context "when all is good" do
+ it "returns a route map" do
+ route_map = described_class.new(YAML.dump([{"source" => "index.haml", "public" => "index.html"}, {"source" => '/(.*)\.md/', "public" => '\1.html'}]))
- expect(route_map.public_path_for_source_path('index.haml')).to eq('index.html')
- expect(route_map.public_path_for_source_path('foo.md')).to eq('foo.html')
+ expect(route_map.public_path_for_source_path("index.haml")).to eq("index.html")
+ expect(route_map.public_path_for_source_path("foo.md")).to eq("foo.html")
end
end
end
- describe '#public_path_for_source_path' do
- context 'malicious regexp' do
- include_examples 'malicious regexp'
+ describe "#public_path_for_source_path" do
+ context "malicious regexp" do
+ include_examples "malicious regexp"
subject do
map = described_class.new(<<-"MAP".strip_heredoc)
@@ -88,16 +88,16 @@ describe Gitlab::RouteMap do
MAP
end
- it 'returns the public path for a provided source path' do
- expect(subject.public_path_for_source_path('data/team.yml')).to eq('team/')
+ it "returns the public path for a provided source path" do
+ expect(subject.public_path_for_source_path("data/team.yml")).to eq("team/")
- expect(subject.public_path_for_source_path('source/posts/2017-01-30-around-the-world-in-6-releases.html.md.erb')).to eq('2017/01/30/around-the-world-in-6-releases/')
+ expect(subject.public_path_for_source_path("source/posts/2017-01-30-around-the-world-in-6-releases.html.md.erb")).to eq("2017/01/30/around-the-world-in-6-releases/")
- expect(subject.public_path_for_source_path('source/index.html.haml')).to eq('index.html')
+ expect(subject.public_path_for_source_path("source/index.html.haml")).to eq("index.html")
- expect(subject.public_path_for_source_path('source/images/blogimages/around-the-world-in-6-releases-cover.png')).to eq('images/blogimages/around-the-world-in-6-releases-cover.png')
+ expect(subject.public_path_for_source_path("source/images/blogimages/around-the-world-in-6-releases-cover.png")).to eq("images/blogimages/around-the-world-in-6-releases-cover.png")
- expect(subject.public_path_for_source_path('.gitlab/route-map.yml')).to be_nil
+ expect(subject.public_path_for_source_path(".gitlab/route-map.yml")).to be_nil
end
end
end
diff --git a/spec/lib/gitlab/routing_spec.rb b/spec/lib/gitlab/routing_spec.rb
index 01d5acfc15b..7f8621e87ef 100644
--- a/spec/lib/gitlab/routing_spec.rb
+++ b/spec/lib/gitlab/routing_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Routing do
- context 'when module is included' do
+ context "when module is included" do
subject do
Class.new.include(described_class).new
end
- it 'makes it possible to access url helpers' do
+ it "makes it possible to access url helpers" do
expect(subject).to respond_to(:namespace_project_path)
end
end
- context 'when module is not included' do
+ context "when module is not included" do
subject do
Class.new.include(described_class.url_helpers).new
end
- it 'exposes url helpers module through a method' do
+ it "exposes url helpers module through a method" do
expect(subject).to respond_to(:namespace_project_path)
end
end
diff --git a/spec/lib/gitlab/safe_request_store_spec.rb b/spec/lib/gitlab/safe_request_store_spec.rb
index bae87e43615..2c76de703ba 100644
--- a/spec/lib/gitlab/safe_request_store_spec.rb
+++ b/spec/lib/gitlab/safe_request_store_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SafeRequestStore do
- describe '.store' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
+ describe ".store" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
expect(described_class.store).to eq(RequestStore)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
expect(described_class.store).to be_a(Gitlab::NullRequestStore)
end
end
end
- describe '.begin!' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
+ describe ".begin!" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:begin!)
described_class.begin!
end
end
- context 'when RequestStore is NOT active' do
- it 'uses RequestStore' do
+ context "when RequestStore is NOT active" do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:begin!)
described_class.begin!
@@ -35,17 +35,17 @@ describe Gitlab::SafeRequestStore do
end
end
- describe '.clear!' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
+ describe ".clear!" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:clear!).twice.and_call_original
described_class.clear!
end
end
- context 'when RequestStore is NOT active' do
- it 'uses RequestStore' do
+ context "when RequestStore is NOT active" do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:clear!).and_call_original
described_class.clear!
@@ -53,17 +53,17 @@ describe Gitlab::SafeRequestStore do
end
end
- describe '.end!' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
+ describe ".end!" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:end!).twice.and_call_original
described_class.end!
end
end
- context 'when RequestStore is NOT active' do
- it 'uses RequestStore' do
+ context "when RequestStore is NOT active" do
+ it "uses RequestStore" do
expect(RequestStore).to receive(:end!).and_call_original
described_class.end!
@@ -71,185 +71,185 @@ describe Gitlab::SafeRequestStore do
end
end
- describe '.write' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- described_class.write('foo', true)
- end.to change { described_class.read('foo') }.from(nil).to(true)
+ describe ".write" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ described_class.write("foo", true)
+ }.to change { described_class.read("foo") }.from(nil).to(true)
end
- it 'does not pass the options hash to the underlying store implementation' do
- expect(described_class.store).to receive(:write).with('foo', true)
+ it "does not pass the options hash to the underlying store implementation" do
+ expect(described_class.store).to receive(:write).with("foo", true)
- described_class.write('foo', true, expires_in: 15.seconds)
+ described_class.write("foo", true, expires_in: 15.seconds)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
- expect do
- described_class.write('foo', true)
- end.not_to change { described_class.read('foo') }.from(nil)
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
+ expect {
+ described_class.write("foo", true)
+ }.not_to change { described_class.read("foo") }.from(nil)
end
- it 'does not pass the options hash to the underlying store implementation' do
- expect(described_class.store).to receive(:write).with('foo', true)
+ it "does not pass the options hash to the underlying store implementation" do
+ expect(described_class.store).to receive(:write).with("foo", true)
- described_class.write('foo', true, expires_in: 15.seconds)
+ described_class.write("foo", true, expires_in: 15.seconds)
end
end
end
- describe '.[]=' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- described_class['foo'] = true
- end.to change { described_class.read('foo') }.from(nil).to(true)
+ describe ".[]=" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ described_class["foo"] = true
+ }.to change { described_class.read("foo") }.from(nil).to(true)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
- expect do
- described_class['foo'] = true
- end.not_to change { described_class.read('foo') }.from(nil)
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
+ expect {
+ described_class["foo"] = true
+ }.not_to change { described_class.read("foo") }.from(nil)
end
end
end
- describe '.read' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- RequestStore.write('foo', true)
- end.to change { described_class.read('foo') }.from(nil).to(true)
+ describe ".read" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ RequestStore.write("foo", true)
+ }.to change { described_class.read("foo") }.from(nil).to(true)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
- expect do
- RequestStore.write('foo', true)
- end.not_to change { described_class.read('foo') }.from(nil)
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
+ expect {
+ RequestStore.write("foo", true)
+ }.not_to change { described_class.read("foo") }.from(nil)
RequestStore.clear! # Clean up
end
end
end
- describe '.[]' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- RequestStore.write('foo', true)
- end.to change { described_class['foo'] }.from(nil).to(true)
+ describe ".[]" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ RequestStore.write("foo", true)
+ }.to change { described_class["foo"] }.from(nil).to(true)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
- expect do
- RequestStore.write('foo', true)
- end.not_to change { described_class['foo'] }.from(nil)
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
+ expect {
+ RequestStore.write("foo", true)
+ }.not_to change { described_class["foo"] }.from(nil)
RequestStore.clear! # Clean up
end
end
end
- describe '.exist?' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- RequestStore.write('foo', 'not nil')
- end.to change { described_class.exist?('foo') }.from(false).to(true)
+ describe ".exist?" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ RequestStore.write("foo", "not nil")
+ }.to change { described_class.exist?("foo") }.from(false).to(true)
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
- expect do
- RequestStore.write('foo', 'not nil')
- end.not_to change { described_class.exist?('foo') }.from(false)
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
+ expect {
+ RequestStore.write("foo", "not nil")
+ }.not_to change { described_class.exist?("foo") }.from(false)
RequestStore.clear! # Clean up
end
end
end
- describe '.fetch' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- expect do
- described_class.fetch('foo') { 'block result' }
- end.to change { described_class.read('foo') }.from(nil).to('block result')
+ describe ".fetch" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ expect {
+ described_class.fetch("foo") { "block result" }
+ }.to change { described_class.read("foo") }.from(nil).to("block result")
end
end
- context 'when RequestStore is NOT active' do
- it 'does not use RequestStore' do
+ context "when RequestStore is NOT active" do
+ it "does not use RequestStore" do
RequestStore.clear! # Ensure clean
- expect do
- described_class.fetch('foo') { 'block result' }
- end.not_to change { described_class.read('foo') }.from(nil)
+ expect {
+ described_class.fetch("foo") { "block result" }
+ }.not_to change { described_class.read("foo") }.from(nil)
RequestStore.clear! # Clean up
end
end
end
- describe '.delete' do
- context 'when RequestStore is active', :request_store do
- it 'uses RequestStore' do
- described_class.write('foo', true)
+ describe ".delete" do
+ context "when RequestStore is active", :request_store do
+ it "uses RequestStore" do
+ described_class.write("foo", true)
- expect do
- described_class.delete('foo')
- end.to change { described_class.read('foo') }.from(true).to(nil)
+ expect {
+ described_class.delete("foo")
+ }.to change { described_class.read("foo") }.from(true).to(nil)
end
- context 'when given a block and the key exists' do
- it 'does not execute the block' do
- described_class.write('foo', true)
+ context "when given a block and the key exists" do
+ it "does not execute the block" do
+ described_class.write("foo", true)
- expect do |b|
- described_class.delete('foo', &b)
- end.not_to yield_control
+ expect { |b|
+ described_class.delete("foo", &b)
+ }.not_to yield_control
end
end
- context 'when given a block and the key does not exist' do
- it 'yields the key and returns the block result' do
- result = described_class.delete('foo') { |key| "#{key} block result" }
+ context "when given a block and the key does not exist" do
+ it "yields the key and returns the block result" do
+ result = described_class.delete("foo") { |key| "#{key} block result" }
- expect(result).to eq('foo block result')
+ expect(result).to eq("foo block result")
end
end
end
- context 'when RequestStore is NOT active' do
+ context "when RequestStore is NOT active" do
before do
- RequestStore.write('foo', true)
+ RequestStore.write("foo", true)
end
after do
RequestStore.clear! # Clean up
end
- it 'does not use RequestStore' do
- expect do
- described_class.delete('foo')
- end.not_to change { RequestStore.read('foo') }.from(true)
+ it "does not use RequestStore" do
+ expect {
+ described_class.delete("foo")
+ }.not_to change { RequestStore.read("foo") }.from(true)
end
- context 'when given a block' do
- it 'yields the key and returns the block result' do
- result = described_class.delete('foo') { |key| "#{key} block result" }
+ context "when given a block" do
+ it "yields the key and returns the block result" do
+ result = described_class.delete("foo") { |key| "#{key} block result" }
- expect(result).to eq('foo block result')
+ expect(result).to eq("foo block result")
end
end
end
diff --git a/spec/lib/gitlab/sanitizers/svg_spec.rb b/spec/lib/gitlab/sanitizers/svg_spec.rb
index df46a874528..5a8c8cdbb55 100644
--- a/spec/lib/gitlab/sanitizers/svg_spec.rb
+++ b/spec/lib/gitlab/sanitizers/svg_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sanitizers::SVG do
let(:scrubber) { Gitlab::Sanitizers::SVG::Scrubber.new }
- let(:namespace) { double(Nokogiri::XML::Namespace, prefix: 'xlink', href: 'http://www.w3.org/1999/xlink') }
- let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: 'href', namespace: namespace, value: '#awesome_id') }
+ let(:namespace) { double(Nokogiri::XML::Namespace, prefix: "xlink", href: "http://www.w3.org/1999/xlink") }
+ let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: "href", namespace: namespace, value: "#awesome_id") }
- describe '.clean' do
- let(:input_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'unsanitized.svg') }
+ describe ".clean" do
+ let(:input_svg_path) { File.join(Rails.root, "spec", "fixtures", "unsanitized.svg") }
let(:data) { File.read(input_svg_path) }
- let(:sanitized_svg_path) { File.join(Rails.root, 'spec', 'fixtures', 'sanitized.svg') }
+ let(:sanitized_svg_path) { File.join(Rails.root, "spec", "fixtures", "sanitized.svg") }
let(:sanitized) { File.read(sanitized_svg_path) }
- it 'delegates sanitization to scrubber' do
+ it "delegates sanitization to scrubber" do
expect_any_instance_of(Gitlab::Sanitizers::SVG::Scrubber).to receive(:scrub).at_least(:once)
described_class.clean(data)
end
- it 'returns sanitized data' do
+ it "returns sanitized data" do
expect(described_class.clean(data)).to eq(sanitized)
end
end
- context 'scrubber' do
- describe '#scrub' do
- let(:invalid_element) { double(Nokogiri::XML::Node, name: 'invalid', value: 'invalid') }
- let(:invalid_attribute) { double(Nokogiri::XML::Attr, name: 'invalid', namespace: nil) }
- let(:valid_element) { double(Nokogiri::XML::Node, name: 'use') }
+ context "scrubber" do
+ describe "#scrub" do
+ let(:invalid_element) { double(Nokogiri::XML::Node, name: "invalid", value: "invalid") }
+ let(:invalid_attribute) { double(Nokogiri::XML::Attr, name: "invalid", namespace: nil) }
+ let(:valid_element) { double(Nokogiri::XML::Node, name: "use") }
- it 'removes an invalid element' do
+ it "removes an invalid element" do
expect(invalid_element).to receive(:unlink)
scrubber.scrub(invalid_element)
end
- it 'removes an invalid attribute' do
+ it "removes an invalid attribute" do
allow(valid_element).to receive(:attribute_nodes) { [invalid_attribute] }
expect(invalid_attribute).to receive(:unlink)
scrubber.scrub(valid_element)
end
- it 'accepts valid element' do
+ it "accepts valid element" do
allow(valid_element).to receive(:attribute_nodes) { [namespaced_attr] }
expect(valid_element).not_to receive(:unlink)
scrubber.scrub(valid_element)
end
- it 'accepts valid namespaced attributes' do
+ it "accepts valid namespaced attributes" do
allow(valid_element).to receive(:attribute_nodes) { [namespaced_attr] }
expect(namespaced_attr).not_to receive(:unlink)
@@ -55,38 +55,38 @@ describe Gitlab::Sanitizers::SVG do
end
end
- describe '#attribute_name_with_namespace' do
- it 'returns name with prefix when attribute is namespaced' do
- expect(scrubber.attribute_name_with_namespace(namespaced_attr)).to eq('xlink:href')
+ describe "#attribute_name_with_namespace" do
+ it "returns name with prefix when attribute is namespaced" do
+ expect(scrubber.attribute_name_with_namespace(namespaced_attr)).to eq("xlink:href")
end
end
- describe '#unsafe_href?' do
- let(:unsafe_attr) { double(Nokogiri::XML::Attr, name: 'href', namespace: namespace, value: 'http://evilsite.example.com/random.svg') }
+ describe "#unsafe_href?" do
+ let(:unsafe_attr) { double(Nokogiri::XML::Attr, name: "href", namespace: namespace, value: "http://evilsite.example.com/random.svg") }
- it 'returns true if href attribute is an external url' do
+ it "returns true if href attribute is an external url" do
expect(scrubber.unsafe_href?(unsafe_attr)).to be_truthy
end
- it 'returns false if href atttribute is an internal reference' do
+ it "returns false if href atttribute is an internal reference" do
expect(scrubber.unsafe_href?(namespaced_attr)).to be_falsey
end
end
- describe '#data_attribute?' do
- let(:data_attr) { double(Nokogiri::XML::Attr, name: 'data-gitlab', namespace: nil, value: 'gitlab is awesome') }
- let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: 'data-gitlab', namespace: namespace, value: 'gitlab is awesome') }
- let(:other_attr) { double(Nokogiri::XML::Attr, name: 'something', namespace: nil, value: 'content') }
+ describe "#data_attribute?" do
+ let(:data_attr) { double(Nokogiri::XML::Attr, name: "data-gitlab", namespace: nil, value: "gitlab is awesome") }
+ let(:namespaced_attr) { double(Nokogiri::XML::Attr, name: "data-gitlab", namespace: namespace, value: "gitlab is awesome") }
+ let(:other_attr) { double(Nokogiri::XML::Attr, name: "something", namespace: nil, value: "content") }
- it 'returns true if is a valid data attribute' do
+ it "returns true if is a valid data attribute" do
expect(scrubber.data_attribute?(data_attr)).to be_truthy
end
- it 'returns false if attribute is namespaced' do
+ it "returns false if attribute is namespaced" do
expect(scrubber.data_attribute?(namespaced_attr)).to be_falsey
end
- it 'returns false if not a data attribute' do
+ it "returns false if not a data attribute" do
expect(scrubber.data_attribute?(other_attr)).to be_falsey
end
end
diff --git a/spec/lib/gitlab/search/found_blob_spec.rb b/spec/lib/gitlab/search/found_blob_spec.rb
index 74157e5c67c..b8d76147108 100644
--- a/spec/lib/gitlab/search/found_blob_spec.rb
+++ b/spec/lib/gitlab/search/found_blob_spec.rb
@@ -1,11 +1,9 @@
-# coding: utf-8
-
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Search::FoundBlob do
- describe 'parsing results' do
+ describe "parsing results" do
let(:project) { create(:project, :public, :repository) }
- let(:results) { project.repository.search_files_by_content('feature', 'master') }
+ let(:results) { project.repository.search_files_by_content("feature", "master") }
let(:search_result) { results.first }
subject { described_class.new(content_match: search_result, project: project) }
@@ -13,10 +11,10 @@ describe Gitlab::Search::FoundBlob do
it "returns a valid FoundBlob" do
is_expected.to be_an described_class
expect(subject.id).to be_nil
- expect(subject.path).to eq('CHANGELOG')
- expect(subject.filename).to eq('CHANGELOG')
- expect(subject.basename).to eq('CHANGELOG')
- expect(subject.ref).to eq('master')
+ expect(subject.path).to eq("CHANGELOG")
+ expect(subject.filename).to eq("CHANGELOG")
+ expect(subject.basename).to eq("CHANGELOG")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(188)
expect(subject.data.lines[2]).to eq(" - Feature: Replace teams with group membership\n")
end
@@ -24,95 +22,95 @@ describe Gitlab::Search::FoundBlob do
it "doesn't parses content if not needed" do
expect(subject).not_to receive(:parse_search_result)
expect(subject.project_id).to eq(project.id)
- expect(subject.binary_filename).to eq('CHANGELOG')
+ expect(subject.binary_filename).to eq("CHANGELOG")
end
it "parses content only once when needed" do
expect(subject).to receive(:parse_search_result).once.and_call_original
- expect(subject.filename).to eq('CHANGELOG')
+ expect(subject.filename).to eq("CHANGELOG")
expect(subject.startline).to eq(188)
end
- context 'when the matching filename contains a colon' do
+ context "when the matching filename contains a colon" do
let(:search_result) { "master:testdata/project::function1.yaml\x001\x00---\n" }
- it 'returns a valid FoundBlob' do
- expect(subject.filename).to eq('testdata/project::function1.yaml')
- expect(subject.basename).to eq('testdata/project::function1')
- expect(subject.ref).to eq('master')
+ it "returns a valid FoundBlob" do
+ expect(subject.filename).to eq("testdata/project::function1.yaml")
+ expect(subject.basename).to eq("testdata/project::function1")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
expect(subject.data).to eq("---\n")
end
end
- context 'when the matching content contains a number surrounded by colons' do
+ context "when the matching content contains a number surrounded by colons" do
let(:search_result) { "master:testdata/foo.txt\x001\x00blah:9:blah" }
- it 'returns a valid FoundBlob' do
- expect(subject.filename).to eq('testdata/foo.txt')
- expect(subject.basename).to eq('testdata/foo')
- expect(subject.ref).to eq('master')
+ it "returns a valid FoundBlob" do
+ expect(subject.filename).to eq("testdata/foo.txt")
+ expect(subject.basename).to eq("testdata/foo")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
- expect(subject.data).to eq('blah:9:blah')
+ expect(subject.data).to eq("blah:9:blah")
end
end
- context 'when the matching content contains multiple null bytes' do
+ context "when the matching content contains multiple null bytes" do
let(:search_result) { "master:testdata/foo.txt\x001\x00blah\x001\x00foo" }
- it 'returns a valid FoundBlob' do
- expect(subject.filename).to eq('testdata/foo.txt')
- expect(subject.basename).to eq('testdata/foo')
- expect(subject.ref).to eq('master')
+ it "returns a valid FoundBlob" do
+ expect(subject.filename).to eq("testdata/foo.txt")
+ expect(subject.basename).to eq("testdata/foo")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
expect(subject.data).to eq("blah\x001\x00foo")
end
end
- context 'when the search result ends with an empty line' do
- let(:results) { project.repository.search_files_by_content('Role models', 'master') }
+ context "when the search result ends with an empty line" do
+ let(:results) { project.repository.search_files_by_content("Role models", "master") }
- it 'returns a valid FoundBlob that ends with an empty line' do
- expect(subject.filename).to eq('files/markdown/ruby-style-guide.md')
- expect(subject.basename).to eq('files/markdown/ruby-style-guide')
- expect(subject.ref).to eq('master')
+ it "returns a valid FoundBlob that ends with an empty line" do
+ expect(subject.filename).to eq("files/markdown/ruby-style-guide.md")
+ expect(subject.basename).to eq("files/markdown/ruby-style-guide")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
expect(subject.data).to eq("# Prelude\n\n> Role models are important. <br/>\n> -- Officer Alex J. Murphy / RoboCop\n\n")
end
end
- context 'when the search returns non-ASCII data' do
- context 'with UTF-8' do
- let(:results) { project.repository.search_files_by_content('файл', 'master') }
+ context "when the search returns non-ASCII data" do
+ context "with UTF-8" do
+ let(:results) { project.repository.search_files_by_content("файл", "master") }
- it 'returns results as UTF-8' do
- expect(subject.filename).to eq('encoding/russian.rb')
- expect(subject.basename).to eq('encoding/russian')
- expect(subject.ref).to eq('master')
+ it "returns results as UTF-8" do
+ expect(subject.filename).to eq("encoding/russian.rb")
+ expect(subject.basename).to eq("encoding/russian")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
expect(subject.data).to eq("Хороший файл\n")
end
end
- context 'with UTF-8 in the filename' do
- let(:results) { project.repository.search_files_by_content('webhook', 'master') }
+ context "with UTF-8 in the filename" do
+ let(:results) { project.repository.search_files_by_content("webhook", "master") }
- it 'returns results as UTF-8' do
- expect(subject.filename).to eq('encoding/テスト.txt')
- expect(subject.basename).to eq('encoding/テスト')
- expect(subject.ref).to eq('master')
+ it "returns results as UTF-8" do
+ expect(subject.filename).to eq("encoding/テスト.txt")
+ expect(subject.basename).to eq("encoding/テスト")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(3)
- expect(subject.data).to include('WebHookの確認')
+ expect(subject.data).to include("WebHookの確認")
end
end
- context 'with ISO-8859-1' do
+ context "with ISO-8859-1" do
let(:search_result) { "master:encoding/iso8859.txt\x001\x00\xC4\xFC\nmaster:encoding/iso8859.txt\x002\x00\nmaster:encoding/iso8859.txt\x003\x00foo\n".force_encoding(Encoding::ASCII_8BIT) }
- it 'returns results as UTF-8' do
- expect(subject.filename).to eq('encoding/iso8859.txt')
- expect(subject.basename).to eq('encoding/iso8859')
- expect(subject.ref).to eq('master')
+ it "returns results as UTF-8" do
+ expect(subject.filename).to eq("encoding/iso8859.txt")
+ expect(subject.basename).to eq("encoding/iso8859")
+ expect(subject.ref).to eq("master")
expect(subject.startline).to eq(1)
expect(subject.data).to eq("Äü\n\nfoo\n")
end
@@ -122,17 +120,17 @@ describe Gitlab::Search::FoundBlob do
context "when filename has extension" do
let(:search_result) { "master:CONTRIBUTE.md\x005\x00- [Contribute to GitLab](#contribute-to-gitlab)\n" }
- it { expect(subject.path).to eq('CONTRIBUTE.md') }
- it { expect(subject.filename).to eq('CONTRIBUTE.md') }
- it { expect(subject.basename).to eq('CONTRIBUTE') }
+ it { expect(subject.path).to eq("CONTRIBUTE.md") }
+ it { expect(subject.filename).to eq("CONTRIBUTE.md") }
+ it { expect(subject.basename).to eq("CONTRIBUTE") }
end
context "when file under directory" do
let(:search_result) { "master:a/b/c.md\x005\x00a b c\n" }
- it { expect(subject.path).to eq('a/b/c.md') }
- it { expect(subject.filename).to eq('a/b/c.md') }
- it { expect(subject.basename).to eq('a/b/c') }
+ it { expect(subject.path).to eq("a/b/c.md") }
+ it { expect(subject.filename).to eq("a/b/c.md") }
+ it { expect(subject.basename).to eq("a/b/c") }
end
end
end
diff --git a/spec/lib/gitlab/search/query_spec.rb b/spec/lib/gitlab/search/query_spec.rb
index 2d00428fffa..4518734af7c 100644
--- a/spec/lib/gitlab/search/query_spec.rb
+++ b/spec/lib/gitlab/search/query_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Search::Query do
- let(:query) { 'base filter:wow anotherfilter:noway name:maybe other:mmm leftover' }
+ let(:query) { "base filter:wow anotherfilter:noway name:maybe other:mmm leftover" }
let(:subject) do
described_class.new(query) do
filter :filter
@@ -12,27 +12,27 @@ describe Gitlab::Search::Query do
it { expect(described_class).to be < SimpleDelegator }
- it 'leaves undefined filters in the main query' do
- expect(subject.term).to eq('base anotherfilter:noway leftover')
+ it "leaves undefined filters in the main query" do
+ expect(subject.term).to eq("base anotherfilter:noway leftover")
end
- it 'parses filters' do
+ it "parses filters" do
expect(subject.filters.count).to eq(3)
expect(subject.filters.map { |f| f[:value] }).to match_array(%w[wow MAYBE mmm])
end
- context 'with an empty filter' do
- let(:query) { 'some bar name: baz' }
+ context "with an empty filter" do
+ let(:query) { "some bar name: baz" }
- it 'ignores empty filters' do
- expect(subject.term).to eq('some bar name: baz')
+ it "ignores empty filters" do
+ expect(subject.term).to eq("some bar name: baz")
end
end
- context 'with a pipe' do
- let(:query) { 'base | nofilter' }
+ context "with a pipe" do
+ let(:query) { "base | nofilter" }
- it 'does not escape the pipe' do
+ it "does not escape the pipe" do
expect(subject.term).to eq(query)
end
end
diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb
index 87288baedb0..71eb23a0193 100644
--- a/spec/lib/gitlab/search_results_spec.rb
+++ b/spec/lib/gitlab/search_results_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SearchResults do
include ProjectForksHelper
let(:user) { create(:user) }
- let!(:project) { create(:project, name: 'foo') }
- let!(:issue) { create(:issue, project: project, title: 'foo') }
+ let!(:project) { create(:project, name: "foo") }
+ let!(:issue) { create(:issue, project: project, title: "foo") }
let!(:merge_request) do
- create(:merge_request, source_project: project, title: 'foo')
+ create(:merge_request, source_project: project, title: "foo")
end
- let!(:milestone) { create(:milestone, project: project, title: 'foo') }
- let(:results) { described_class.new(user, Project.all, 'foo') }
+ let!(:milestone) { create(:milestone, project: project, title: "foo") }
+ let(:results) { described_class.new(user, Project.all, "foo") }
- context 'as a user with access' do
+ context "as a user with access" do
before do
project.add_developer(user)
end
- describe '#objects' do
- it 'returns without_counts collection by default' do
- expect(results.objects('projects')).to be_kind_of(Kaminari::PaginatableWithoutCount)
+ describe "#objects" do
+ it "returns without_counts collection by default" do
+ expect(results.objects("projects")).to be_kind_of(Kaminari::PaginatableWithoutCount)
end
- it 'returns with counts collection when requested' do
- expect(results.objects('projects', 1, false)).not_to be_kind_of(Kaminari::PaginatableWithoutCount)
+ it "returns with counts collection when requested" do
+ expect(results.objects("projects", 1, false)).not_to be_kind_of(Kaminari::PaginatableWithoutCount)
end
end
@@ -34,33 +34,33 @@ describe Gitlab::SearchResults do
allow(results).to receive(:count_limit).and_return(1)
end
- describe '#limited_projects_count' do
- it 'returns the limited amount of projects' do
- create(:project, name: 'foo2')
+ describe "#limited_projects_count" do
+ it "returns the limited amount of projects" do
+ create(:project, name: "foo2")
expect(results.limited_projects_count).to eq(1)
end
end
- describe '#limited_merge_requests_count' do
- it 'returns the limited amount of merge requests' do
- create(:merge_request, :simple, source_project: project, title: 'foo2')
+ describe "#limited_merge_requests_count" do
+ it "returns the limited amount of merge requests" do
+ create(:merge_request, :simple, source_project: project, title: "foo2")
expect(results.limited_merge_requests_count).to eq(1)
end
end
- describe '#limited_milestones_count' do
- it 'returns the limited amount of milestones' do
- create(:milestone, project: project, title: 'foo2')
+ describe "#limited_milestones_count" do
+ it "returns the limited amount of milestones" do
+ create(:milestone, project: project, title: "foo2")
expect(results.limited_milestones_count).to eq(1)
end
end
- describe '#limited_issues_count' do
- it 'runs single SQL query to get the limited amount of issues' do
- create(:milestone, project: project, title: 'foo2')
+ describe "#limited_issues_count" do
+ it "runs single SQL query to get the limited amount of issues" do
+ create(:milestone, project: project, title: "foo2")
expect(results).to receive(:issues).with(public_only: true).and_call_original
expect(results).not_to receive(:issues).with(no_args).and_call_original
@@ -71,8 +71,8 @@ describe Gitlab::SearchResults do
end
context "when count_limit is higher than total amount" do
- describe '#limited_issues_count' do
- it 'runs multiple queries to get the limited amount of issues' do
+ describe "#limited_issues_count" do
+ it "runs multiple queries to get the limited amount of issues" do
expect(results).to receive(:issues).with(public_only: true).and_call_original
expect(results).to receive(:issues).with(no_args).and_call_original
@@ -81,77 +81,77 @@ describe Gitlab::SearchResults do
end
end
- it 'includes merge requests from source and target projects' do
+ it "includes merge requests from source and target projects" do
forked_project = fork_project(project, user)
- merge_request_2 = create(:merge_request, target_project: project, source_project: forked_project, title: 'foo')
+ merge_request_2 = create(:merge_request, target_project: project, source_project: forked_project, title: "foo")
- results = described_class.new(user, Project.where(id: forked_project.id), 'foo')
+ results = described_class.new(user, Project.where(id: forked_project.id), "foo")
- expect(results.objects('merge_requests')).to include merge_request_2
+ expect(results.objects("merge_requests")).to include merge_request_2
end
- describe '#merge_requests' do
- it 'includes project filter by default' do
+ describe "#merge_requests" do
+ it "includes project filter by default" do
expect(results).to receive(:project_ids_relation).and_call_original
- results.objects('merge_requests')
+ results.objects("merge_requests")
end
- it 'it skips project filter if default project context is used' do
+ it "it skips project filter if default project context is used" do
allow(results).to receive(:default_project_filter).and_return(true)
expect(results).not_to receive(:project_ids_relation)
- results.objects('merge_requests')
+ results.objects("merge_requests")
end
end
- describe '#issues' do
- it 'includes project filter by default' do
+ describe "#issues" do
+ it "includes project filter by default" do
expect(results).to receive(:project_ids_relation).and_call_original
- results.objects('issues')
+ results.objects("issues")
end
- it 'it skips project filter if default project context is used' do
+ it "it skips project filter if default project context is used" do
allow(results).to receive(:default_project_filter).and_return(true)
expect(results).not_to receive(:project_ids_relation)
- results.objects('issues')
+ results.objects("issues")
end
end
end
- it 'does not list issues on private projects' do
+ it "does not list issues on private projects" do
private_project = create(:project, :private)
- issue = create(:issue, project: private_project, title: 'foo')
+ issue = create(:issue, project: private_project, title: "foo")
- expect(results.objects('issues')).not_to include issue
+ expect(results.objects("issues")).not_to include issue
end
- describe 'confidential issues' do
+ describe "confidential issues" do
let(:project_1) { create(:project, :internal) }
let(:project_2) { create(:project, :internal) }
let(:project_3) { create(:project, :internal) }
let(:project_4) { create(:project, :internal) }
- let(:query) { 'issue' }
+ let(:query) { "issue" }
let(:limit_projects) { Project.where(id: [project_1.id, project_2.id, project_3.id]) }
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:admin) { create(:admin) }
- let!(:issue) { create(:issue, project: project_1, title: 'Issue 1') }
- let!(:security_issue_1) { create(:issue, :confidential, project: project_1, title: 'Security issue 1', author: author) }
- let!(:security_issue_2) { create(:issue, :confidential, title: 'Security issue 2', project: project_1, assignees: [assignee]) }
- let!(:security_issue_3) { create(:issue, :confidential, project: project_2, title: 'Security issue 3', author: author) }
- let!(:security_issue_4) { create(:issue, :confidential, project: project_3, title: 'Security issue 4', assignees: [assignee]) }
- let!(:security_issue_5) { create(:issue, :confidential, project: project_4, title: 'Security issue 5') }
-
- it 'does not list confidential issues for non project members' do
+ let!(:issue) { create(:issue, project: project_1, title: "Issue 1") }
+ let!(:security_issue_1) { create(:issue, :confidential, project: project_1, title: "Security issue 1", author: author) }
+ let!(:security_issue_2) { create(:issue, :confidential, title: "Security issue 2", project: project_1, assignees: [assignee]) }
+ let!(:security_issue_3) { create(:issue, :confidential, project: project_2, title: "Security issue 3", author: author) }
+ let!(:security_issue_4) { create(:issue, :confidential, project: project_3, title: "Security issue 4", assignees: [assignee]) }
+ let!(:security_issue_5) { create(:issue, :confidential, project: project_4, title: "Security issue 5") }
+
+ it "does not list confidential issues for non project members" do
results = described_class.new(non_member, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -162,12 +162,12 @@ describe Gitlab::SearchResults do
expect(results.limited_issues_count).to eq 1
end
- it 'does 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.add_guest(member)
project_2.add_guest(member)
results = described_class.new(member, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -178,9 +178,9 @@ describe Gitlab::SearchResults do
expect(results.limited_issues_count).to eq 1
end
- it 'lists confidential issues for author' do
+ it "lists confidential issues for author" do
results = described_class.new(author, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -191,9 +191,9 @@ describe Gitlab::SearchResults do
expect(results.limited_issues_count).to eq 3
end
- it 'lists confidential issues for assignee' do
+ it "lists confidential issues for assignee" do
results = described_class.new(assignee, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).not_to include security_issue_1
@@ -204,12 +204,12 @@ describe Gitlab::SearchResults do
expect(results.limited_issues_count).to eq 3
end
- it 'lists confidential issues for project members' do
+ it "lists confidential issues for project members" do
project_1.add_developer(member)
project_2.add_developer(member)
results = described_class.new(member, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -220,9 +220,9 @@ describe Gitlab::SearchResults do
expect(results.limited_issues_count).to eq 4
end
- it 'lists all issues for admin' do
+ it "lists all issues for admin" do
results = described_class.new(admin, limit_projects, query)
- issues = results.objects('issues')
+ issues = results.objects("issues")
expect(issues).to include issue
expect(issues).to include security_issue_1
@@ -234,10 +234,10 @@ describe Gitlab::SearchResults do
end
end
- it 'does not list merge requests on projects with limited access' do
+ it "does not list merge requests on projects with limited access" do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
- expect(results.objects('merge_requests')).not_to include merge_request
+ expect(results.objects("merge_requests")).not_to include merge_request
end
end
diff --git a/spec/lib/gitlab/sentry_spec.rb b/spec/lib/gitlab/sentry_spec.rb
index 1128eaf8560..88edd0e9b9a 100644
--- a/spec/lib/gitlab/sentry_spec.rb
+++ b/spec/lib/gitlab/sentry_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sentry do
- describe '.context' do
- it 'adds the locale to the tags' do
+ describe ".context" do
+ it "adds the locale to the tags" do
expect(described_class).to receive(:enabled?).and_return(true)
described_class.context(nil)
@@ -11,48 +11,48 @@ describe Gitlab::Sentry do
end
end
- describe '.track_exception' do
- let(:exception) { RuntimeError.new('boom') }
+ describe ".track_exception" do
+ let(:exception) { RuntimeError.new("boom") }
before do
allow(described_class).to receive(:enabled?).and_return(true)
end
- it 'raises the exception if it should' do
+ it "raises the exception if it should" do
expect(described_class).to receive(:should_raise_for_dev?).and_return(true)
expect { described_class.track_exception(exception) }
.to raise_error(RuntimeError)
end
- context 'when exceptions should not be raised' do
+ context "when exceptions should not be raised" do
before do
allow(described_class).to receive(:should_raise_for_dev?).and_return(false)
- allow(Gitlab::CorrelationId).to receive(:current_id).and_return('cid')
+ allow(Gitlab::CorrelationId).to receive(:current_id).and_return("cid")
end
- it 'logs the exception with all attributes passed' do
+ it "logs the exception with all attributes passed" do
expected_extras = {
- some_other_info: 'info',
- issue_url: 'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
+ some_other_info: "info",
+ issue_url: "http://gitlab.com/gitlab-org/gitlab-ce/issues/1",
}
expected_tags = {
- correlation_id: 'cid'
+ correlation_id: "cid",
}
expect(Raven).to receive(:capture_exception)
- .with(exception,
- tags: a_hash_including(expected_tags),
- extra: a_hash_including(expected_extras))
+ .with(exception,
+ tags: a_hash_including(expected_tags),
+ extra: a_hash_including(expected_extras))
described_class.track_exception(
exception,
- issue_url: 'http://gitlab.com/gitlab-org/gitlab-ce/issues/1',
- extra: { some_other_info: 'info' }
+ issue_url: "http://gitlab.com/gitlab-org/gitlab-ce/issues/1",
+ extra: {some_other_info: "info"}
)
end
- it 'sets the context' do
+ it "sets the context" do
expect(described_class).to receive(:context)
described_class.track_exception(exception)
@@ -60,33 +60,33 @@ describe Gitlab::Sentry do
end
end
- context '.track_acceptable_exception' do
- let(:exception) { RuntimeError.new('boom') }
+ context ".track_acceptable_exception" do
+ let(:exception) { RuntimeError.new("boom") }
before do
allow(described_class).to receive(:enabled?).and_return(true)
- allow(Gitlab::CorrelationId).to receive(:current_id).and_return('cid')
+ allow(Gitlab::CorrelationId).to receive(:current_id).and_return("cid")
end
- it 'calls Raven.capture_exception' do
+ it "calls Raven.capture_exception" do
expected_extras = {
- some_other_info: 'info',
- issue_url: 'http://gitlab.com/gitlab-org/gitlab-ce/issues/1'
+ some_other_info: "info",
+ issue_url: "http://gitlab.com/gitlab-org/gitlab-ce/issues/1",
}
expected_tags = {
- correlation_id: 'cid'
+ correlation_id: "cid",
}
expect(Raven).to receive(:capture_exception)
- .with(exception,
- tags: a_hash_including(expected_tags),
- extra: a_hash_including(expected_extras))
+ .with(exception,
+ tags: a_hash_including(expected_tags),
+ extra: a_hash_including(expected_extras))
described_class.track_acceptable_exception(
exception,
- issue_url: 'http://gitlab.com/gitlab-org/gitlab-ce/issues/1',
- extra: { some_other_info: 'info' }
+ issue_url: "http://gitlab.com/gitlab-org/gitlab-ce/issues/1",
+ extra: {some_other_info: "info"}
)
end
end
diff --git a/spec/lib/gitlab/serializer/ci/variables_spec.rb b/spec/lib/gitlab/serializer/ci/variables_spec.rb
index 1d1fd5b0763..d1d875038a5 100644
--- a/spec/lib/gitlab/serializer/ci/variables_spec.rb
+++ b/spec/lib/gitlab/serializer/ci/variables_spec.rb
@@ -1,4 +1,4 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Serializer::Ci::Variables do
subject do
@@ -6,14 +6,14 @@ describe Gitlab::Serializer::Ci::Variables do
end
let(:object) do
- [{ 'key' => :key, 'value' => 'value', 'public' => true },
- { key: 'wee', value: 1, public: false }]
+ [{"key" => :key, "value" => "value", "public" => true},
+ {key: "wee", value: 1, public: false},]
end
- it 'converts keys into strings and symbolizes hash' do
+ it "converts keys into strings and symbolizes hash" do
is_expected.to eq([
- { key: 'key', value: 'value', public: true },
- { key: 'wee', value: 1, public: false }
+ {key: "key", value: "value", public: true},
+ {key: "wee", value: 1, public: false},
])
end
end
diff --git a/spec/lib/gitlab/serializer/pagination_spec.rb b/spec/lib/gitlab/serializer/pagination_spec.rb
index c54be78f050..bd4bbc20c0a 100644
--- a/spec/lib/gitlab/serializer/pagination_spec.rb
+++ b/spec/lib/gitlab/serializer/pagination_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Serializer::Pagination do
let(:request) { double(url: "#{Gitlab.config.gitlab.url}:8080/api/v4/projects?#{query.to_query}", query_parameters: query) }
- let(:response) { spy('response') }
- let(:headers) { spy('headers') }
+ let(:response) { spy("response") }
+ let(:headers) { spy("headers") }
before do
allow(response).to receive(:headers).and_return(headers)
@@ -11,36 +11,37 @@ describe Gitlab::Serializer::Pagination do
let(:pagination) { described_class.new(request, response) }
- describe '#paginate' do
+ describe "#paginate" do
subject { pagination.paginate(resource) }
let(:resource) { User.all }
- let(:query) { { page: 1, per_page: 2 } }
+ let(:query) { {page: 1, per_page: 2} }
- context 'when a multiple resources are present in relation' do
+ context "when a multiple resources are present in relation" do
before do
create_list(:user, 3)
end
- it 'correctly paginates the resource' do
+ it "correctly paginates the resource" do
expect(subject.count).to be 2
end
- it 'appends relevant headers' do
- expect(headers).to receive(:[]=).with('X-Total', '3')
- expect(headers).to receive(:[]=).with('X-Total-Pages', '2')
- expect(headers).to receive(:[]=).with('X-Per-Page', '2')
+ it "appends relevant headers" do
+ expect(headers).to receive(:[]=).with("X-Total", "3")
+ expect(headers).to receive(:[]=).with("X-Total-Pages", "2")
+ expect(headers).to receive(:[]=).with("X-Per-Page", "2")
subject
end
end
- context 'when an invalid resource is about to be paginated' do
+ context "when an invalid resource is about to be paginated" do
let(:resource) { create(:user) }
- it 'raises error' do
+ it "raises error" do
expect { subject }.to raise_error(
- described_class::InvalidResourceError)
+ described_class::InvalidResourceError
+ )
end
end
end
diff --git a/spec/lib/gitlab/shard_health_cache_spec.rb b/spec/lib/gitlab/shard_health_cache_spec.rb
index e1a69261939..518bba1366c 100644
--- a/spec/lib/gitlab/shard_health_cache_spec.rb
+++ b/spec/lib/gitlab/shard_health_cache_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::ShardHealthCache, :clean_gitlab_redis_cache do
- let(:shards) { %w(foo bar) }
+ let(:shards) { %w[foo bar] }
before do
described_class.update(shards)
end
- describe '.clear' do
- it 'leaves no shards around' do
+ describe ".clear" do
+ it "leaves no shards around" do
described_class.clear
expect(described_class.healthy_shard_count).to eq(0)
end
end
- describe '.update' do
- it 'returns the healthy shards' do
+ describe ".update" do
+ it "returns the healthy shards" do
expect(described_class.cached_healthy_shards).to match_array(shards)
end
- it 'replaces the existing set' do
- new_set = %w(test me more)
+ it "replaces the existing set" do
+ new_set = %w[test me more]
described_class.update(new_set)
expect(described_class.cached_healthy_shards).to match_array(new_set)
end
end
- describe '.healthy_shard_count' do
- it 'returns the healthy shard count' do
+ describe ".healthy_shard_count" do
+ it "returns the healthy shard count" do
expect(described_class.healthy_shard_count).to eq(2)
end
- it 'returns 0 if no shards are available' do
+ it "returns 0 if no shards are available" do
described_class.update([])
expect(described_class.healthy_shard_count).to eq(0)
end
end
- describe '.healthy_shard?' do
- it 'returns true for a healthy shard' do
- expect(described_class.healthy_shard?('foo')).to be_truthy
+ describe ".healthy_shard?" do
+ it "returns true for a healthy shard" do
+ expect(described_class.healthy_shard?("foo")).to be_truthy
end
- it 'returns false for an unknown shard' do
- expect(described_class.healthy_shard?('unknown')).to be_falsey
+ it "returns false for an unknown shard" do
+ expect(described_class.healthy_shard?("unknown")).to be_falsey
end
end
end
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb
index d6aadf0f7de..eda06f4670d 100644
--- a/spec/lib/gitlab/shell_spec.rb
+++ b/spec/lib/gitlab/shell_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
-require 'stringio'
+require "spec_helper"
+require "stringio"
describe Gitlab::Shell do
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:gitlab_shell) { described_class.new }
- let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } }
+ let(:popen_vars) { {"GIT_TERMINAL_PROMPT" => ENV["GIT_TERMINAL_PROMPT"]} }
let(:timeout) { Gitlab.config.gitlab_shell.git_timeout }
before do
@@ -19,25 +19,25 @@ describe Gitlab::Shell do
it { is_expected.to respond_to :remove_repository }
it { is_expected.to respond_to :fork_repository }
- it { expect(gitlab_shell.url_to_repo('diaspora')).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") }
+ it { expect(gitlab_shell.url_to_repo("diaspora")).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "diaspora.git") }
- describe 'memoized secret_token' do
- let(:secret_file) { 'tmp/tests/.secret_shell_test' }
- let(:link_file) { 'tmp/tests/shell-secret-test/.gitlab_shell_secret' }
+ describe "memoized secret_token" do
+ let(:secret_file) { "tmp/tests/.secret_shell_test" }
+ let(:link_file) { "tmp/tests/shell-secret-test/.gitlab_shell_secret" }
before do
allow(Gitlab.config.gitlab_shell).to receive(:secret_file).and_return(secret_file)
- allow(Gitlab.config.gitlab_shell).to receive(:path).and_return('tmp/tests/shell-secret-test')
- FileUtils.mkdir('tmp/tests/shell-secret-test')
+ allow(Gitlab.config.gitlab_shell).to receive(:path).and_return("tmp/tests/shell-secret-test")
+ FileUtils.mkdir("tmp/tests/shell-secret-test")
described_class.ensure_secret_token!
end
after do
- FileUtils.rm_rf('tmp/tests/shell-secret-test')
+ FileUtils.rm_rf("tmp/tests/shell-secret-test")
FileUtils.rm_rf(secret_file)
end
- it 'creates and links the secret token file' do
+ it "creates and links the secret token file" do
secret_token = described_class.secret_token
expect(File.exist?(secret_file)).to be(true)
@@ -47,168 +47,168 @@ describe Gitlab::Shell do
end
end
- describe '#add_key' do
- context 'when authorized_keys_enabled is true' do
- it 'removes trailing garbage' do
+ describe "#add_key" do
+ context "when authorized_keys_enabled is true" do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'add-key', 'key-123', 'ssh-rsa foobar']
+ [:gitlab_shell_keys_path, "add-key", "key-123", "ssh-rsa foobar"]
)
- gitlab_shell.add_key('key-123', 'ssh-rsa foobar trailing garbage')
+ gitlab_shell.add_key("key-123", "ssh-rsa foobar trailing garbage")
end
end
- context 'when authorized_keys_enabled is false' do
+ context "when authorized_keys_enabled is false" do
before do
stub_application_setting(authorized_keys_enabled: false)
end
- it 'does nothing' do
+ it "does nothing" do
expect(gitlab_shell).not_to receive(:gitlab_shell_fast_execute)
- gitlab_shell.add_key('key-123', 'ssh-rsa foobar trailing garbage')
+ gitlab_shell.add_key("key-123", "ssh-rsa foobar trailing garbage")
end
end
- context 'when authorized_keys_enabled is nil' do
+ context "when authorized_keys_enabled is nil" do
before do
stub_application_setting(authorized_keys_enabled: nil)
end
- it 'removes trailing garbage' do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'add-key', 'key-123', 'ssh-rsa foobar']
+ [:gitlab_shell_keys_path, "add-key", "key-123", "ssh-rsa foobar"]
)
- gitlab_shell.add_key('key-123', 'ssh-rsa foobar trailing garbage')
+ gitlab_shell.add_key("key-123", "ssh-rsa foobar trailing garbage")
end
end
end
- describe '#batch_add_keys' do
- context 'when authorized_keys_enabled is true' do
- it 'instantiates KeyAdder' do
- expect_any_instance_of(Gitlab::Shell::KeyAdder).to receive(:add_key).with('key-123', 'ssh-rsa foobar')
+ describe "#batch_add_keys" do
+ context "when authorized_keys_enabled is true" do
+ it "instantiates KeyAdder" do
+ expect_any_instance_of(Gitlab::Shell::KeyAdder).to receive(:add_key).with("key-123", "ssh-rsa foobar")
gitlab_shell.batch_add_keys do |adder|
- adder.add_key('key-123', 'ssh-rsa foobar')
+ adder.add_key("key-123", "ssh-rsa foobar")
end
end
end
- context 'when authorized_keys_enabled is false' do
+ context "when authorized_keys_enabled is false" do
before do
stub_application_setting(authorized_keys_enabled: false)
end
- it 'does nothing' do
+ it "does nothing" do
expect_any_instance_of(Gitlab::Shell::KeyAdder).not_to receive(:add_key)
gitlab_shell.batch_add_keys do |adder|
- adder.add_key('key-123', 'ssh-rsa foobar')
+ adder.add_key("key-123", "ssh-rsa foobar")
end
end
end
- context 'when authorized_keys_enabled is nil' do
+ context "when authorized_keys_enabled is nil" do
before do
stub_application_setting(authorized_keys_enabled: nil)
end
- it 'instantiates KeyAdder' do
- expect_any_instance_of(Gitlab::Shell::KeyAdder).to receive(:add_key).with('key-123', 'ssh-rsa foobar')
+ it "instantiates KeyAdder" do
+ expect_any_instance_of(Gitlab::Shell::KeyAdder).to receive(:add_key).with("key-123", "ssh-rsa foobar")
gitlab_shell.batch_add_keys do |adder|
- adder.add_key('key-123', 'ssh-rsa foobar')
+ adder.add_key("key-123", "ssh-rsa foobar")
end
end
end
end
- describe '#remove_key' do
- context 'when authorized_keys_enabled is true' do
- it 'removes trailing garbage' do
+ describe "#remove_key" do
+ context "when authorized_keys_enabled is true" do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'rm-key', 'key-123', 'ssh-rsa foobar']
+ [:gitlab_shell_keys_path, "rm-key", "key-123", "ssh-rsa foobar"]
)
- gitlab_shell.remove_key('key-123', 'ssh-rsa foobar')
+ gitlab_shell.remove_key("key-123", "ssh-rsa foobar")
end
end
- context 'when authorized_keys_enabled is false' do
+ context "when authorized_keys_enabled is false" do
before do
stub_application_setting(authorized_keys_enabled: false)
end
- it 'does nothing' do
+ it "does nothing" do
expect(gitlab_shell).not_to receive(:gitlab_shell_fast_execute)
- gitlab_shell.remove_key('key-123', 'ssh-rsa foobar')
+ gitlab_shell.remove_key("key-123", "ssh-rsa foobar")
end
end
- context 'when authorized_keys_enabled is nil' do
+ context "when authorized_keys_enabled is nil" do
before do
stub_application_setting(authorized_keys_enabled: nil)
end
- it 'removes trailing garbage' do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'rm-key', 'key-123', 'ssh-rsa foobar']
+ [:gitlab_shell_keys_path, "rm-key", "key-123", "ssh-rsa foobar"]
)
- gitlab_shell.remove_key('key-123', 'ssh-rsa foobar')
+ gitlab_shell.remove_key("key-123", "ssh-rsa foobar")
end
end
- context 'when key content is not given' do
- it 'calls rm-key with only one argument' do
+ context "when key content is not given" do
+ it "calls rm-key with only one argument" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'rm-key', 'key-123']
+ [:gitlab_shell_keys_path, "rm-key", "key-123"]
)
- gitlab_shell.remove_key('key-123')
+ gitlab_shell.remove_key("key-123")
end
end
end
- describe '#remove_all_keys' do
- context 'when authorized_keys_enabled is true' do
- it 'removes trailing garbage' do
+ describe "#remove_all_keys" do
+ context "when authorized_keys_enabled is true" do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
- expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with([:gitlab_shell_keys_path, 'clear'])
+ expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with([:gitlab_shell_keys_path, "clear"])
gitlab_shell.remove_all_keys
end
end
- context 'when authorized_keys_enabled is false' do
+ context "when authorized_keys_enabled is false" do
before do
stub_application_setting(authorized_keys_enabled: false)
end
- it 'does nothing' do
+ it "does nothing" do
expect(gitlab_shell).not_to receive(:gitlab_shell_fast_execute)
gitlab_shell.remove_all_keys
end
end
- context 'when authorized_keys_enabled is nil' do
+ context "when authorized_keys_enabled is nil" do
before do
stub_application_setting(authorized_keys_enabled: nil)
end
- it 'removes trailing garbage' do
+ it "removes trailing garbage" do
allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path)
expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with(
- [:gitlab_shell_keys_path, 'clear']
+ [:gitlab_shell_keys_path, "clear"]
)
gitlab_shell.remove_all_keys
@@ -216,16 +216,16 @@ describe Gitlab::Shell do
end
end
- describe '#remove_keys_not_found_in_db' do
- context 'when keys are in the file that are not in the DB' do
+ describe "#remove_keys_not_found_in_db" do
+ context "when keys are in the file that are not in the DB" do
before do
gitlab_shell.remove_all_keys
- gitlab_shell.add_key('key-1234', 'ssh-rsa ASDFASDF')
- gitlab_shell.add_key('key-9876', 'ssh-rsa ASDFASDF')
+ gitlab_shell.add_key("key-1234", "ssh-rsa ASDFASDF")
+ gitlab_shell.add_key("key-9876", "ssh-rsa ASDFASDF")
@another_key = create(:key) # this one IS in the DB
end
- it 'removes the keys' do
+ it "removes the keys" do
expect(find_in_authorized_keys_file(1234)).to be_truthy
expect(find_in_authorized_keys_file(9876)).to be_truthy
expect(find_in_authorized_keys_file(@another_key.id)).to be_truthy
@@ -236,52 +236,52 @@ describe Gitlab::Shell do
end
end
- context 'when keys there are duplicate keys in the file that are not in the DB' do
+ context "when keys there are duplicate keys in the file that are not in the DB" do
before do
gitlab_shell.remove_all_keys
- gitlab_shell.add_key('key-1234', 'ssh-rsa ASDFASDF')
- gitlab_shell.add_key('key-1234', 'ssh-rsa ASDFASDF')
+ gitlab_shell.add_key("key-1234", "ssh-rsa ASDFASDF")
+ gitlab_shell.add_key("key-1234", "ssh-rsa ASDFASDF")
end
- it 'removes the keys' do
+ it "removes the keys" do
expect(find_in_authorized_keys_file(1234)).to be_truthy
gitlab_shell.remove_keys_not_found_in_db
expect(find_in_authorized_keys_file(1234)).to be_falsey
end
- it 'does not run remove more than once per key (in a batch)' do
- expect(gitlab_shell).to receive(:remove_key).with('key-1234').once
+ it "does not run remove more than once per key (in a batch)" do
+ expect(gitlab_shell).to receive(:remove_key).with("key-1234").once
gitlab_shell.remove_keys_not_found_in_db
end
end
- context 'when keys there are duplicate keys in the file that ARE in the DB' do
+ context "when keys there are duplicate keys in the file that ARE in the DB" do
before do
gitlab_shell.remove_all_keys
@key = create(:key)
gitlab_shell.add_key(@key.shell_id, @key.key)
end
- it 'does not remove the key' do
+ it "does not remove the key" do
gitlab_shell.remove_keys_not_found_in_db
expect(find_in_authorized_keys_file(@key.id)).to be_truthy
end
- it 'does not need to run a SELECT query for that batch, on account of that key' do
+ it "does not need to run a SELECT query for that batch, on account of that key" do
expect_any_instance_of(ActiveRecord::Relation).not_to receive(:pluck)
gitlab_shell.remove_keys_not_found_in_db
end
end
- unless ENV['CI'] # Skip in CI, it takes 1 minute
- context 'when the first batch can be skipped, but the next batch has keys that are not in the DB' do
+ unless ENV["CI"] # Skip in CI, it takes 1 minute
+ context "when the first batch can be skipped, but the next batch has keys that are not in the DB" do
before do
gitlab_shell.remove_all_keys
100.times { |i| create(:key) } # first batch is all in the DB
- gitlab_shell.add_key('key-1234', 'ssh-rsa ASDFASDF')
+ gitlab_shell.add_key("key-1234", "ssh-rsa ASDFASDF")
end
- it 'removes the keys not in the DB' do
+ it "removes the keys not in the DB" do
expect(find_in_authorized_keys_file(1234)).to be_truthy
gitlab_shell.remove_keys_not_found_in_db
expect(find_in_authorized_keys_file(1234)).to be_falsey
@@ -290,8 +290,8 @@ describe Gitlab::Shell do
end
end
- describe '#batch_read_key_ids' do
- context 'when there are keys in the authorized_keys file' do
+ describe "#batch_read_key_ids" do
+ context "when there are keys in the authorized_keys file" do
before do
gitlab_shell.remove_all_keys
(1..4).each do |i|
@@ -299,7 +299,7 @@ describe Gitlab::Shell do
end
end
- it 'iterates over the key IDs in the file, in batches' do
+ it "iterates over the key IDs in the file, in batches" do
loop_count = 0
first_batch = [1, 2]
second_batch = [3, 4]
@@ -313,8 +313,8 @@ describe Gitlab::Shell do
end
end
- describe '#list_key_ids' do
- context 'when there are keys in the authorized_keys file' do
+ describe "#list_key_ids" do
+ context "when there are keys in the authorized_keys file" do
before do
gitlab_shell.remove_all_keys
(1..4).each do |i|
@@ -322,7 +322,7 @@ describe Gitlab::Shell do
end
end
- it 'outputs the key IDs in the file, separated by newlines' do
+ it "outputs the key IDs in the file, separated by newlines" do
ids = []
gitlab_shell.list_key_ids do |io|
io.each do |line|
@@ -330,16 +330,16 @@ describe Gitlab::Shell do
end
end
- expect(ids).to eq(%W{1\n 2\n 3\n 4\n})
+ expect(ids).to eq(%W[1\n 2\n 3\n 4\n])
end
end
- context 'when there are no keys in the authorized_keys file' do
+ context "when there are no keys in the authorized_keys file" do
before do
gitlab_shell.remove_all_keys
end
- it 'outputs nothing, not even an empty string' do
+ it "outputs nothing, not even an empty string" do
ids = []
gitlab_shell.list_key_ids do |io|
io.each do |line|
@@ -353,74 +353,74 @@ describe Gitlab::Shell do
end
describe Gitlab::Shell::KeyAdder do
- describe '#add_key' do
- it 'removes trailing garbage' do
+ describe "#add_key" do
+ it "removes trailing garbage" do
io = spy(:io)
adder = described_class.new(io)
- adder.add_key('key-42', "ssh-rsa foo bar\tbaz")
+ adder.add_key("key-42", "ssh-rsa foo bar\tbaz")
expect(io).to have_received(:puts).with("key-42\tssh-rsa foo")
end
- it 'handles multiple spaces in the key' do
+ it "handles multiple spaces in the key" do
io = spy(:io)
adder = described_class.new(io)
- adder.add_key('key-42', "ssh-rsa foo")
+ adder.add_key("key-42", "ssh-rsa foo")
expect(io).to have_received(:puts).with("key-42\tssh-rsa foo")
end
- it 'raises an exception if the key contains a tab' do
- expect do
- described_class.new(StringIO.new).add_key('key-42', "ssh-rsa\tfoobar")
- end.to raise_error(Gitlab::Shell::Error)
+ it "raises an exception if the key contains a tab" do
+ expect {
+ described_class.new(StringIO.new).add_key("key-42", "ssh-rsa\tfoobar")
+ }.to raise_error(Gitlab::Shell::Error)
end
- it 'raises an exception if the key contains a newline' do
- expect do
- described_class.new(StringIO.new).add_key('key-42', "ssh-rsa foobar\nssh-rsa pawned")
- end.to raise_error(Gitlab::Shell::Error)
+ it "raises an exception if the key contains a newline" do
+ expect {
+ described_class.new(StringIO.new).add_key("key-42", "ssh-rsa foobar\nssh-rsa pawned")
+ }.to raise_error(Gitlab::Shell::Error)
end
end
end
- describe 'projects commands' do
- let(:gitlab_shell_path) { File.expand_path('tmp/tests/gitlab-shell') }
- let(:projects_path) { File.join(gitlab_shell_path, 'bin/gitlab-projects') }
- let(:gitlab_shell_hooks_path) { File.join(gitlab_shell_path, 'hooks') }
+ describe "projects commands" do
+ let(:gitlab_shell_path) { File.expand_path("tmp/tests/gitlab-shell") }
+ let(:projects_path) { File.join(gitlab_shell_path, "bin/gitlab-projects") }
+ let(:gitlab_shell_hooks_path) { File.join(gitlab_shell_path, "hooks") }
before do
allow(Gitlab.config.gitlab_shell).to receive(:path).and_return(gitlab_shell_path)
allow(Gitlab.config.gitlab_shell).to receive(:git_timeout).and_return(800)
end
- describe '#create_repository' do
- let(:repository_storage) { 'default' }
+ describe "#create_repository" do
+ let(:repository_storage) { "default" }
let(:repository_storage_path) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
Gitlab.config.repositories.storages[repository_storage].legacy_disk_path
end
end
- let(:repo_name) { 'project/path' }
- let(:created_path) { File.join(repository_storage_path, repo_name + '.git') }
+ let(:repo_name) { "project/path" }
+ let(:created_path) { File.join(repository_storage_path, repo_name + ".git") }
after do
FileUtils.rm_rf(created_path)
end
- it 'creates a repository' do
+ it "creates a repository" do
expect(gitlab_shell.create_repository(repository_storage, repo_name, repo_name)).to be_truthy
expect(File.stat(created_path).mode & 0o777).to eq(0o770)
- hooks_path = File.join(created_path, 'hooks')
+ hooks_path = File.join(created_path, "hooks")
expect(File.lstat(hooks_path)).to be_symlink
expect(File.realpath(hooks_path)).to eq(gitlab_shell_hooks_path)
end
- it 'returns false when the command fails' do
+ it "returns false when the command fails" do
FileUtils.mkdir_p(File.dirname(created_path))
# This file will block the creation of the repo's .git directory. That
# should cause #create_repository to fail.
@@ -430,11 +430,11 @@ describe Gitlab::Shell do
end
end
- describe '#remove_repository' do
+ describe "#remove_repository" do
let!(:project) { create(:project, :repository, :legacy_storage) }
let(:disk_path) { "#{project.disk_path}.git" }
- it 'returns true when the command succeeds' do
+ it "returns true when the command succeeds" do
expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(true)
expect(gitlab_shell.remove_repository(project.repository_storage, project.disk_path)).to be(true)
@@ -442,18 +442,18 @@ describe Gitlab::Shell do
expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(false)
end
- it 'keeps the namespace directory' do
+ it "keeps the namespace directory" do
gitlab_shell.remove_repository(project.repository_storage, project.disk_path)
expect(gitlab_shell.exists?(project.repository_storage, disk_path)).to be(false)
- expect(gitlab_shell.exists?(project.repository_storage, project.disk_path.gsub(project.name, ''))).to be(true)
+ expect(gitlab_shell.exists?(project.repository_storage, project.disk_path.gsub(project.name, ""))).to be(true)
end
end
- describe '#mv_repository' do
+ describe "#mv_repository" do
let!(:project2) { create(:project, :repository) }
- it 'returns true when the command succeeds' do
+ it "returns true when the command succeeds" do
old_path = project2.disk_path
new_path = "project/new_path"
@@ -466,39 +466,39 @@ describe Gitlab::Shell do
expect(gitlab_shell.exists?(project2.repository_storage, "#{new_path}.git")).to be(true)
end
- it 'returns false when the command fails' do
- expect(gitlab_shell.mv_repository(project2.repository_storage, project2.disk_path, '')).to be_falsy
+ it "returns false when the command fails" do
+ expect(gitlab_shell.mv_repository(project2.repository_storage, project2.disk_path, "")).to be_falsy
expect(gitlab_shell.exists?(project2.repository_storage, "#{project2.disk_path}.git")).to be(true)
end
end
- describe '#fork_repository' do
+ describe "#fork_repository" do
let(:target_project) { create(:project) }
subject do
gitlab_shell.fork_repository(project, target_project)
end
- it 'returns true when the command succeeds' do
+ it "returns true when the command succeeds" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:fork_repository)
.with(repository.raw_repository) { :gitaly_response_object }
is_expected.to be_truthy
end
- it 'return false when the command fails' do
+ it "return false when the command fails" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:fork_repository)
- .with(repository.raw_repository) { raise GRPC::BadStatus, 'bla' }
+ .with(repository.raw_repository) { raise GRPC::BadStatus, "bla" }
is_expected.to be_falsy
end
end
- describe '#import_repository' do
- let(:import_url) { 'https://gitlab.com/gitlab-org/gitlab-ce.git' }
+ describe "#import_repository" do
+ let(:import_url) { "https://gitlab.com/gitlab-org/gitlab-ce.git" }
- context 'with gitaly' do
- it 'returns true when the command succeeds' do
+ context "with gitaly" do
+ it "returns true when the command succeeds" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository).with(import_url)
result = gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url, project.full_path)
@@ -506,40 +506,40 @@ describe Gitlab::Shell do
expect(result).to be_truthy
end
- it 'raises an exception when the command fails' do
+ it "raises an exception when the command fails" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:import_repository)
- .with(import_url) { raise GRPC::BadStatus, 'bla' }
- expect_any_instance_of(Gitlab::Shell::GitalyGitlabProjects).to receive(:output) { 'error'}
+ .with(import_url) { raise GRPC::BadStatus, "bla" }
+ expect_any_instance_of(Gitlab::Shell::GitalyGitlabProjects).to receive(:output) { "error"}
- expect do
+ expect {
gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url, project.full_path)
- end.to raise_error(Gitlab::Shell::Error, "error")
+ }.to raise_error(Gitlab::Shell::Error, "error")
end
end
end
end
- describe 'namespace actions' do
+ describe "namespace actions" do
subject { described_class.new }
let(:storage) { Gitlab.config.repositories.storages.keys.first }
- describe '#add_namespace' do
- it 'creates a namespace' do
+ describe "#add_namespace" do
+ it "creates a namespace" do
subject.add_namespace(storage, "mepmep")
expect(subject.exists?(storage, "mepmep")).to be(true)
end
end
- describe '#exists?' do
- context 'when the namespace does not exist' do
- it 'returns false' do
+ describe "#exists?" do
+ context "when the namespace does not exist" do
+ it "returns false" do
expect(subject.exists?(storage, "non-existing")).to be(false)
end
end
- context 'when the namespace exists' do
- it 'returns true' do
+ context "when the namespace exists" do
+ it "returns true" do
subject.add_namespace(storage, "mepmep")
expect(subject.exists?(storage, "mepmep")).to be(true)
@@ -547,8 +547,8 @@ describe Gitlab::Shell do
end
end
- describe '#remove' do
- it 'removes the namespace' do
+ describe "#remove" do
+ it "removes the namespace" do
subject.add_namespace(storage, "mepmep")
subject.rm_namespace(storage, "mepmep")
@@ -556,8 +556,8 @@ describe Gitlab::Shell do
end
end
- describe '#mv_namespace' do
- it 'renames the namespace' do
+ describe "#mv_namespace" do
+ it "renames the namespace" do
subject.add_namespace(storage, "mepmep")
subject.mv_namespace(storage, "mepmep", "2mep")
diff --git a/spec/lib/gitlab/sherlock/collection_spec.rb b/spec/lib/gitlab/sherlock/collection_spec.rb
index 873ed14f804..2aa28905332 100644
--- a/spec/lib/gitlab/sherlock/collection_spec.rb
+++ b/spec/lib/gitlab/sherlock/collection_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::Collection do
let(:collection) { described_class.new }
let(:transaction) do
- Gitlab::Sherlock::Transaction.new('POST', '/cat_pictures')
+ Gitlab::Sherlock::Transaction.new("POST", "/cat_pictures")
end
- describe '#add' do
- it 'adds a new transaction' do
+ describe "#add" do
+ it "adds a new transaction" do
collection.add(transaction)
expect(collection).not_to be_empty
end
- it 'is aliased as <<' do
+ it "is aliased as <<" do
collection << transaction
expect(collection).not_to be_empty
end
end
- describe '#each' do
- it 'iterates over every transaction' do
+ describe "#each" do
+ it "iterates over every transaction" do
collection.add(transaction)
expect { |b| collection.each(&b) }.to yield_with_args(transaction)
end
end
- describe '#clear' do
- it 'removes all transactions' do
+ describe "#clear" do
+ it "removes all transactions" do
collection.add(transaction)
collection.clear
@@ -39,36 +39,36 @@ describe Gitlab::Sherlock::Collection do
end
end
- describe '#empty?' do
- it 'returns true for an empty collection' do
+ describe "#empty?" do
+ it "returns true for an empty collection" do
expect(collection).to be_empty
end
- it 'returns false for a collection with a transaction' do
+ it "returns false for a collection with a transaction" do
collection.add(transaction)
expect(collection).not_to be_empty
end
end
- describe '#find_transaction' do
- it 'returns the transaction for the given ID' do
+ describe "#find_transaction" do
+ it "returns the transaction for the given ID" do
collection.add(transaction)
expect(collection.find_transaction(transaction.id)).to eq(transaction)
end
- it 'returns nil when no transaction could be found' do
+ it "returns nil when no transaction could be found" do
collection.add(transaction)
- expect(collection.find_transaction('cats')).to be_nil
+ expect(collection.find_transaction("cats")).to be_nil
end
end
- describe '#newest_first' do
- it 'returns transactions sorted from new to old' do
- trans1 = Gitlab::Sherlock::Transaction.new('POST', '/cat_pictures')
- trans2 = Gitlab::Sherlock::Transaction.new('POST', '/more_cat_pictures')
+ describe "#newest_first" do
+ it "returns transactions sorted from new to old" do
+ trans1 = Gitlab::Sherlock::Transaction.new("POST", "/cat_pictures")
+ trans2 = Gitlab::Sherlock::Transaction.new("POST", "/more_cat_pictures")
allow(trans1).to receive(:finished_at).and_return(Time.utc(2015, 1, 1))
allow(trans2).to receive(:finished_at).and_return(Time.utc(2015, 1, 2))
diff --git a/spec/lib/gitlab/sherlock/file_sample_spec.rb b/spec/lib/gitlab/sherlock/file_sample_spec.rb
index 394421504e0..cf77233b780 100644
--- a/spec/lib/gitlab/sherlock/file_sample_spec.rb
+++ b/spec/lib/gitlab/sherlock/file_sample_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::FileSample do
let(:sample) { described_class.new(__FILE__, [], 150.4, 2) }
- describe '#id' do
- it 'returns the ID' do
+ describe "#id" do
+ it "returns the ID" do
expect(sample.id).to be_an_instance_of(String)
end
end
- describe '#file' do
- it 'returns the file path' do
+ describe "#file" do
+ it "returns the file path" do
expect(sample.file).to eq(__FILE__)
end
end
- describe '#line_samples' do
- it 'returns the line samples' do
+ describe "#line_samples" do
+ it "returns the line samples" do
expect(sample.line_samples).to eq([])
end
end
- describe '#events' do
- it 'returns the total number of events' do
+ describe "#events" do
+ it "returns the total number of events" do
expect(sample.events).to eq(2)
end
end
- describe '#duration' do
- it 'returns the total execution time' do
+ describe "#duration" do
+ it "returns the total execution time" do
expect(sample.duration).to eq(150.4)
end
end
- describe '#relative_path' do
- it 'returns the relative path' do
+ describe "#relative_path" do
+ it "returns the relative path" do
expect(sample.relative_path)
- .to eq('spec/lib/gitlab/sherlock/file_sample_spec.rb')
+ .to eq("spec/lib/gitlab/sherlock/file_sample_spec.rb")
end
end
- describe '#to_param' do
- it 'returns the sample ID' do
+ describe "#to_param" do
+ it "returns the sample ID" do
expect(sample.to_param).to eq(sample.id)
end
end
- describe '#source' do
- it 'returns the contents of the file' do
+ describe "#source" do
+ it "returns the contents of the file" do
expect(sample.source).to eq(File.read(__FILE__))
end
end
diff --git a/spec/lib/gitlab/sherlock/line_profiler_spec.rb b/spec/lib/gitlab/sherlock/line_profiler_spec.rb
index f2f8040fa0b..2ae78ab864e 100644
--- a/spec/lib/gitlab/sherlock/line_profiler_spec.rb
+++ b/spec/lib/gitlab/sherlock/line_profiler_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::LineProfiler do
let(:profiler) { described_class.new }
- describe '#profile' do
- it 'runs the profiler when using MRI' do
+ describe "#profile" do
+ it "runs the profiler when using MRI" do
allow(profiler).to receive(:mri?).and_return(true)
allow(profiler).to receive(:profile_mri)
- profiler.profile { 'cats' }
+ profiler.profile { "cats" }
end
- it 'raises NotImplementedError when profiling an unsupported platform' do
+ it "raises NotImplementedError when profiling an unsupported platform" do
allow(profiler).to receive(:mri?).and_return(false)
- expect { profiler.profile { 'cats' } }.to raise_error(NotImplementedError)
+ expect { profiler.profile { "cats" } }.to raise_error(NotImplementedError)
end
end
- describe '#profile_mri' do
- it 'returns an Array containing the return value and profiling samples' do
+ describe "#profile_mri" do
+ it "returns an Array containing the return value and profiling samples" do
allow(profiler).to receive(:lineprof)
.and_yield
- .and_return({ __FILE__ => [[0, 0, 0, 0]] })
+ .and_return({__FILE__ => [[0, 0, 0, 0]]})
retval, samples = profiler.profile_mri { 42 }
@@ -31,28 +31,28 @@ describe Gitlab::Sherlock::LineProfiler do
end
end
- describe '#aggregate_rblineprof' do
+ describe "#aggregate_rblineprof" do
let(:raw_samples) do
- { __FILE__ => [[30000, 30000, 5, 0], [15000, 15000, 4, 0]] }
+ {__FILE__ => [[30000, 30000, 5, 0], [15000, 15000, 4, 0]]}
end
- it 'returns an Array of FileSample objects' do
+ it "returns an Array of FileSample objects" do
samples = profiler.aggregate_rblineprof(raw_samples)
expect(samples).to be_an_instance_of(Array)
expect(samples[0]).to be_an_instance_of(Gitlab::Sherlock::FileSample)
end
- describe 'the first FileSample object' do
+ describe "the first FileSample object" do
let(:file_sample) do
profiler.aggregate_rblineprof(raw_samples)[0]
end
- it 'uses the correct file path' do
+ it "uses the correct file path" do
expect(file_sample.file).to eq(__FILE__)
end
- it 'contains a list of line samples' do
+ it "contains a list of line samples" do
line_sample = file_sample.line_samples[0]
expect(line_sample).to be_an_instance_of(Gitlab::Sherlock::LineSample)
@@ -61,11 +61,11 @@ describe Gitlab::Sherlock::LineProfiler do
expect(line_sample.events).to eq(4)
end
- it 'contains the total file execution time' do
+ it "contains the total file execution time" do
expect(file_sample.duration).to eq(30.0)
end
- it 'contains the total amount of file events' do
+ it "contains the total amount of file events" do
expect(file_sample.events).to eq(5)
end
end
diff --git a/spec/lib/gitlab/sherlock/line_sample_spec.rb b/spec/lib/gitlab/sherlock/line_sample_spec.rb
index 5f02f6a3213..485c1d70e1e 100644
--- a/spec/lib/gitlab/sherlock/line_sample_spec.rb
+++ b/spec/lib/gitlab/sherlock/line_sample_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::LineSample do
let(:sample) { described_class.new(150.0, 4) }
- describe '#duration' do
- it 'returns the duration' do
+ describe "#duration" do
+ it "returns the duration" do
expect(sample.duration).to eq(150.0)
end
end
- describe '#events' do
- it 'returns the amount of events' do
+ describe "#events" do
+ it "returns the amount of events" do
expect(sample.events).to eq(4)
end
end
- describe '#percentage_of' do
- it 'returns the percentage of 1500.0' do
+ describe "#percentage_of" do
+ it "returns the percentage of 1500.0" do
expect(sample.percentage_of(1500.0)).to be_within(0.1).of(10.0)
end
end
- describe '#majority_of' do
- it 'returns true if the sample takes up the majority of the given duration' do
+ describe "#majority_of" do
+ it "returns true if the sample takes up the majority of the given duration" do
expect(sample.majority_of?(500.0)).to eq(true)
end
diff --git a/spec/lib/gitlab/sherlock/location_spec.rb b/spec/lib/gitlab/sherlock/location_spec.rb
index b295a624b35..111e13eb662 100644
--- a/spec/lib/gitlab/sherlock/location_spec.rb
+++ b/spec/lib/gitlab/sherlock/location_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::Location do
let(:location) { described_class.new(__FILE__, 1) }
- describe 'from_ruby_location' do
- it 'creates a Location from a Thread::Backtrace::Location' do
+ describe "from_ruby_location" do
+ it "creates a Location from a Thread::Backtrace::Location" do
input = caller_locations[0]
output = described_class.from_ruby_location(input)
@@ -14,25 +14,25 @@ describe Gitlab::Sherlock::Location do
end
end
- describe '#path' do
- it 'returns the file path' do
+ describe "#path" do
+ it "returns the file path" do
expect(location.path).to eq(__FILE__)
end
end
- describe '#line' do
- it 'returns the line number' do
+ describe "#line" do
+ it "returns the line number" do
expect(location.line).to eq(1)
end
end
- describe '#application?' do
- it 'returns true for an application frame' do
+ describe "#application?" do
+ it "returns true for an application frame" do
expect(location.application?).to eq(true)
end
- it 'returns false for a non application frame' do
- loc = described_class.new('/tmp/cats.rb', 1)
+ it "returns false for a non application frame" do
+ loc = described_class.new("/tmp/cats.rb", 1)
expect(loc.application?).to eq(false)
end
diff --git a/spec/lib/gitlab/sherlock/middleware_spec.rb b/spec/lib/gitlab/sherlock/middleware_spec.rb
index 2016023df06..760c13eeeef 100644
--- a/spec/lib/gitlab/sherlock/middleware_spec.rb
+++ b/spec/lib/gitlab/sherlock/middleware_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::Middleware do
let(:app) { double(:app) }
let(:middleware) { described_class.new(app) }
- describe '#call' do
- describe 'when instrumentation is enabled' do
- it 'instruments a request' do
+ describe "#call" do
+ describe "when instrumentation is enabled" do
+ it "instruments a request" do
allow(middleware).to receive(:instrument?).and_return(true)
allow(middleware).to receive(:call_with_instrumentation)
@@ -14,7 +14,7 @@ describe Gitlab::Sherlock::Middleware do
end
end
- describe 'when instrumentation is disabled' do
+ describe "when instrumentation is disabled" do
it "doesn't instrument a request" do
allow(middleware).to receive(:instrument).and_return(false)
allow(app).to receive(:call)
@@ -24,10 +24,10 @@ describe Gitlab::Sherlock::Middleware do
end
end
- describe '#call_with_instrumentation' do
- it 'instruments a request' do
+ describe "#call_with_instrumentation" do
+ it "instruments a request" do
trans = double(:transaction)
- retval = 'cats are amazing'
+ retval = "cats are amazing"
env = {}
allow(app).to receive(:call).with(env).and_return(retval)
@@ -39,37 +39,37 @@ describe Gitlab::Sherlock::Middleware do
end
end
- describe '#instrument?' do
- it 'returns false for a text/css request' do
- env = { 'HTTP_ACCEPT' => 'text/css', 'REQUEST_URI' => '/' }
+ describe "#instrument?" do
+ it "returns false for a text/css request" do
+ env = {"HTTP_ACCEPT" => "text/css", "REQUEST_URI" => "/"}
expect(middleware.instrument?(env)).to eq(false)
end
- it 'returns false for a request to a Sherlock route' do
+ it "returns false for a request to a Sherlock route" do
env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/sherlock/transactions'
+ "HTTP_ACCEPT" => "text/html",
+ "REQUEST_URI" => "/sherlock/transactions",
}
expect(middleware.instrument?(env)).to eq(false)
end
- it 'returns true for a request that should be instrumented' do
+ it "returns true for a request that should be instrumented" do
env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/cats'
+ "HTTP_ACCEPT" => "text/html",
+ "REQUEST_URI" => "/cats",
}
expect(middleware.instrument?(env)).to eq(true)
end
end
- describe '#transaction_from_env' do
- it 'returns a Transaction' do
+ describe "#transaction_from_env" do
+ it "returns a Transaction" do
env = {
- 'HTTP_ACCEPT' => 'text/html',
- 'REQUEST_URI' => '/cats'
+ "HTTP_ACCEPT" => "text/html",
+ "REQUEST_URI" => "/cats",
}
expect(middleware.transaction_from_env(env))
diff --git a/spec/lib/gitlab/sherlock/query_spec.rb b/spec/lib/gitlab/sherlock/query_spec.rb
index 426071c7f92..7cf987b9a8a 100644
--- a/spec/lib/gitlab/sherlock/query_spec.rb
+++ b/spec/lib/gitlab/sherlock/query_spec.rb
@@ -1,78 +1,78 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::Query do
let(:started_at) { Time.utc(2015, 1, 1) }
let(:finished_at) { started_at + 5 }
let(:query) do
- described_class.new('SELECT COUNT(*) FROM users', started_at, finished_at)
+ described_class.new("SELECT COUNT(*) FROM users", started_at, finished_at)
end
- describe 'new_with_bindings' do
- it 'returns a Query' do
- sql = 'SELECT COUNT(*) FROM users WHERE id = $1'
+ describe "new_with_bindings" do
+ it "returns a Query" do
+ sql = "SELECT COUNT(*) FROM users WHERE id = $1"
bindings = [[double(:column), 10]]
query = described_class
.new_with_bindings(sql, bindings, started_at, finished_at)
- expect(query.query).to eq('SELECT COUNT(*) FROM users WHERE id = 10;')
+ expect(query.query).to eq("SELECT COUNT(*) FROM users WHERE id = 10;")
end
end
- describe '#id' do
- it 'returns a String' do
+ describe "#id" do
+ it "returns a String" do
expect(query.id).to be_an_instance_of(String)
end
end
- describe '#query' do
- it 'returns the query with a trailing semi-colon' do
- expect(query.query).to eq('SELECT COUNT(*) FROM users;')
+ describe "#query" do
+ it "returns the query with a trailing semi-colon" do
+ expect(query.query).to eq("SELECT COUNT(*) FROM users;")
end
end
- describe '#started_at' do
- it 'returns the start time' do
+ describe "#started_at" do
+ it "returns the start time" do
expect(query.started_at).to eq(started_at)
end
end
- describe '#finished_at' do
- it 'returns the completion time' do
+ describe "#finished_at" do
+ it "returns the completion time" do
expect(query.finished_at).to eq(finished_at)
end
end
- describe '#backtrace' do
- it 'returns the backtrace' do
+ describe "#backtrace" do
+ it "returns the backtrace" do
expect(query.backtrace).to be_an_instance_of(Array)
end
end
- describe '#duration' do
- it 'returns the duration in milliseconds' do
+ describe "#duration" do
+ it "returns the duration in milliseconds" do
expect(query.duration).to be_within(0.1).of(5000.0)
end
end
- describe '#to_param' do
- it 'returns the query ID' do
+ describe "#to_param" do
+ it "returns the query ID" do
expect(query.to_param).to eq(query.id)
end
end
- describe '#formatted_query' do
- it 'returns a formatted version of the query' do
- expect(query.formatted_query).to eq(<<-EOF.strip)
-SELECT COUNT(*)
-FROM users;
+ describe "#formatted_query" do
+ it "returns a formatted version of the query" do
+ expect(query.formatted_query).to eq(<<~EOF.strip)
+ SELECT COUNT(*)
+ FROM users;
EOF
end
end
- describe '#last_application_frame' do
- it 'returns the last application frame' do
+ describe "#last_application_frame" do
+ it "returns the last application frame" do
frame = query.last_application_frame
expect(frame).to be_an_instance_of(Gitlab::Sherlock::Location)
@@ -80,8 +80,8 @@ FROM users;
end
end
- describe '#application_backtrace' do
- it 'returns an Array of application frames' do
+ describe "#application_backtrace" do
+ it "returns an Array of application frames" do
frames = query.application_backtrace
expect(frames).to be_an_instance_of(Array)
@@ -93,20 +93,20 @@ FROM users;
end
end
- describe '#explain' do
- it 'returns the query plan as a String' do
+ describe "#explain" do
+ it "returns the query plan as a String" do
lines = [
- ['Aggregate (cost=123 rows=1)'],
- [' -> Index Only Scan using index_cats_are_amazing']
+ ["Aggregate (cost=123 rows=1)"],
+ [" -> Index Only Scan using index_cats_are_amazing"],
]
result = double(:result, values: lines)
allow(query).to receive(:raw_explain).and_return(result)
- expect(query.explain).to eq(<<-EOF.strip)
-Aggregate (cost=123 rows=1)
- -> Index Only Scan using index_cats_are_amazing
+ expect(query.explain).to eq(<<~EOF.strip)
+ Aggregate (cost=123 rows=1)
+ -> Index Only Scan using index_cats_are_amazing
EOF
end
end
diff --git a/spec/lib/gitlab/sherlock/transaction_spec.rb b/spec/lib/gitlab/sherlock/transaction_spec.rb
index 4a14dfbec56..92cb7fda7c7 100644
--- a/spec/lib/gitlab/sherlock/transaction_spec.rb
+++ b/spec/lib/gitlab/sherlock/transaction_spec.rb
@@ -1,80 +1,80 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Sherlock::Transaction do
- let(:transaction) { described_class.new('POST', '/cat_pictures') }
+ let(:transaction) { described_class.new("POST", "/cat_pictures") }
- describe '#id' do
- it 'returns the transaction ID' do
+ describe "#id" do
+ it "returns the transaction ID" do
expect(transaction.id).to be_an_instance_of(String)
end
end
- describe '#type' do
- it 'returns the type' do
- expect(transaction.type).to eq('POST')
+ describe "#type" do
+ it "returns the type" do
+ expect(transaction.type).to eq("POST")
end
end
- describe '#path' do
- it 'returns the path' do
- expect(transaction.path).to eq('/cat_pictures')
+ describe "#path" do
+ it "returns the path" do
+ expect(transaction.path).to eq("/cat_pictures")
end
end
- describe '#queries' do
- it 'returns an Array of queries' do
+ describe "#queries" do
+ it "returns an Array of queries" do
expect(transaction.queries).to be_an_instance_of(Array)
end
end
- describe '#file_samples' do
- it 'returns an Array of file samples' do
+ describe "#file_samples" do
+ it "returns an Array of file samples" do
expect(transaction.file_samples).to be_an_instance_of(Array)
end
end
- describe '#started_at' do
- it 'returns the start time' do
+ describe "#started_at" do
+ it "returns the start time" do
allow(transaction).to receive(:profile_lines).and_yield
- transaction.run { 'cats are amazing' }
+ transaction.run { "cats are amazing" }
expect(transaction.started_at).to be_an_instance_of(Time)
end
end
- describe '#finished_at' do
- it 'returns the completion time' do
+ describe "#finished_at" do
+ it "returns the completion time" do
allow(transaction).to receive(:profile_lines).and_yield
- transaction.run { 'cats are amazing' }
+ transaction.run { "cats are amazing" }
expect(transaction.finished_at).to be_an_instance_of(Time)
end
end
- describe '#view_counts' do
- it 'returns a Hash' do
+ describe "#view_counts" do
+ it "returns a Hash" do
expect(transaction.view_counts).to be_an_instance_of(Hash)
end
- it 'sets the default value of a key to 0' do
- expect(transaction.view_counts['cats.rb']).to be_zero
+ it "sets the default value of a key to 0" do
+ expect(transaction.view_counts["cats.rb"]).to be_zero
end
end
- describe '#run' do
- it 'runs the transaction' do
+ describe "#run" do
+ it "runs the transaction" do
allow(transaction).to receive(:profile_lines).and_yield
- retval = transaction.run { 'cats are amazing' }
+ retval = transaction.run { "cats are amazing" }
- expect(retval).to eq('cats are amazing')
+ expect(retval).to eq("cats are amazing")
end
end
- describe '#duration' do
- it 'returns the duration in seconds' do
+ describe "#duration" do
+ it "returns the duration in seconds" do
start_time = Time.now
allow(transaction).to receive(:started_at).and_return(start_time)
@@ -84,11 +84,11 @@ describe Gitlab::Sherlock::Transaction do
end
end
- describe '#query_duration' do
- it 'returns the total query duration in seconds' do
+ describe "#query_duration" do
+ it "returns the total query duration in seconds" do
time = Time.now
- query1 = Gitlab::Sherlock::Query.new('SELECT 1', time, time + 5)
- query2 = Gitlab::Sherlock::Query.new('SELECT 2', time, time + 2)
+ query1 = Gitlab::Sherlock::Query.new("SELECT 1", time, time + 5)
+ query2 = Gitlab::Sherlock::Query.new("SELECT 2", time, time + 2)
transaction.queries << query1
transaction.queries << query2
@@ -97,20 +97,20 @@ describe Gitlab::Sherlock::Transaction do
end
end
- describe '#to_param' do
- it 'returns the transaction ID' do
+ describe "#to_param" do
+ it "returns the transaction ID" do
expect(transaction.to_param).to eq(transaction.id)
end
end
- describe '#sorted_queries' do
- it 'returns the queries in descending order' do
+ describe "#sorted_queries" do
+ it "returns the queries in descending order" do
start_time = Time.now
- query1 = Gitlab::Sherlock::Query.new('SELECT 1', start_time, start_time)
+ query1 = Gitlab::Sherlock::Query.new("SELECT 1", start_time, start_time)
query2 = Gitlab::Sherlock::Query
- .new('SELECT 2', start_time, start_time + 5)
+ .new("SELECT 2", start_time, start_time + 5)
transaction.queries << query1
transaction.queries << query2
@@ -119,8 +119,8 @@ describe Gitlab::Sherlock::Transaction do
end
end
- describe '#sorted_file_samples' do
- it 'returns the file samples in descending order' do
+ describe "#sorted_file_samples" do
+ it "returns the file samples in descending order" do
sample1 = Gitlab::Sherlock::FileSample.new(__FILE__, [], 10.0, 1)
sample2 = Gitlab::Sherlock::FileSample.new(__FILE__, [], 15.0, 1)
@@ -131,22 +131,22 @@ describe Gitlab::Sherlock::Transaction do
end
end
- describe '#find_query' do
- it 'returns a Query when found' do
- query = Gitlab::Sherlock::Query.new('SELECT 1', Time.now, Time.now)
+ describe "#find_query" do
+ it "returns a Query when found" do
+ query = Gitlab::Sherlock::Query.new("SELECT 1", Time.now, Time.now)
transaction.queries << query
expect(transaction.find_query(query.id)).to eq(query)
end
- it 'returns nil when no query could be found' do
- expect(transaction.find_query('cats')).to be_nil
+ it "returns nil when no query could be found" do
+ expect(transaction.find_query("cats")).to be_nil
end
end
- describe '#find_file_sample' do
- it 'returns a FileSample when found' do
+ describe "#find_file_sample" do
+ it "returns a FileSample when found" do
sample = Gitlab::Sherlock::FileSample.new(__FILE__, [], 10.0, 1)
transaction.file_samples << sample
@@ -154,81 +154,81 @@ describe Gitlab::Sherlock::Transaction do
expect(transaction.find_file_sample(sample.id)).to eq(sample)
end
- it 'returns nil when no file sample could be found' do
- expect(transaction.find_file_sample('cats')).to be_nil
+ it "returns nil when no file sample could be found" do
+ expect(transaction.find_file_sample("cats")).to be_nil
end
end
- describe '#profile_lines' do
- describe 'when line profiling is enabled' do
- it 'yields the block using the line profiler' do
+ describe "#profile_lines" do
+ describe "when line profiling is enabled" do
+ it "yields the block using the line profiler" do
allow(Gitlab::Sherlock).to receive(:enable_line_profiler?)
.and_return(true)
allow_any_instance_of(Gitlab::Sherlock::LineProfiler)
- .to receive(:profile).and_return('cats are amazing', [])
+ .to receive(:profile).and_return("cats are amazing", [])
- retval = transaction.profile_lines { 'cats are amazing' }
+ retval = transaction.profile_lines { "cats are amazing" }
- expect(retval).to eq('cats are amazing')
+ expect(retval).to eq("cats are amazing")
end
end
- describe 'when line profiling is disabled' do
- it 'yields the block' do
+ describe "when line profiling is disabled" do
+ it "yields the block" do
allow(Gitlab::Sherlock).to receive(:enable_line_profiler?)
.and_return(false)
- retval = transaction.profile_lines { 'cats are amazing' }
+ retval = transaction.profile_lines { "cats are amazing" }
- expect(retval).to eq('cats are amazing')
+ expect(retval).to eq("cats are amazing")
end
end
end
- describe '#subscribe_to_active_record' do
+ describe "#subscribe_to_active_record" do
let(:subscription) { transaction.subscribe_to_active_record }
let(:time) { Time.now }
- let(:query_data) { { sql: 'SELECT 1', binds: [] } }
+ let(:query_data) { {sql: "SELECT 1", binds: []} }
after do
ActiveSupport::Notifications.unsubscribe(subscription)
end
- it 'tracks executed queries' do
+ it "tracks executed queries" do
expect(transaction).to receive(:track_query)
- .with('SELECT 1', [], time, time)
+ .with("SELECT 1", [], time, time)
- subscription.publish('test', time, time, nil, query_data)
+ subscription.publish("test", time, time, nil, query_data)
end
- it 'only tracks queries triggered from the transaction thread' do
+ it "only tracks queries triggered from the transaction thread" do
expect(transaction).not_to receive(:track_query)
- Thread.new { subscription.publish('test', time, time, nil, query_data) }
+ Thread.new { subscription.publish("test", time, time, nil, query_data) }
.join
end
end
- describe '#subscribe_to_action_view' do
+ describe "#subscribe_to_action_view" do
let(:subscription) { transaction.subscribe_to_action_view }
let(:time) { Time.now }
- let(:view_data) { { identifier: 'foo.rb' } }
+ let(:view_data) { {identifier: "foo.rb"} }
after do
ActiveSupport::Notifications.unsubscribe(subscription)
end
- it 'tracks rendered views' do
- expect(transaction).to receive(:track_view).with('foo.rb')
+ it "tracks rendered views" do
+ expect(transaction).to receive(:track_view).with("foo.rb")
- subscription.publish('test', time, time, nil, view_data)
+ subscription.publish("test", time, time, nil, view_data)
end
- it 'only tracks views rendered from the transaction thread' do
+ it "only tracks views rendered from the transaction thread" do
expect(transaction).not_to receive(:track_view)
- Thread.new { subscription.publish('test', time, time, nil, view_data) }
+ Thread.new { subscription.publish("test", time, time, nil, view_data) }
.join
end
end
diff --git a/spec/lib/gitlab/sidekiq_config_spec.rb b/spec/lib/gitlab/sidekiq_config_spec.rb
index 0c66d764851..a2dee01b7da 100644
--- a/spec/lib/gitlab/sidekiq_config_spec.rb
+++ b/spec/lib/gitlab/sidekiq_config_spec.rb
@@ -1,8 +1,8 @@
-require 'rails_helper'
+require "rails_helper"
describe Gitlab::SidekiqConfig do
- describe '.workers' do
- it 'includes all workers' do
+ describe ".workers" do
+ it "includes all workers" do
workers = described_class.workers
expect(workers).to include(PostReceive)
@@ -10,36 +10,36 @@ describe Gitlab::SidekiqConfig do
end
end
- describe '.worker_queues' do
- it 'includes all queues' do
+ describe ".worker_queues" do
+ it "includes all queues" do
queues = described_class.worker_queues
- expect(queues).to include('post_receive')
- expect(queues).to include('merge')
- expect(queues).to include('cronjob:stuck_import_jobs')
- expect(queues).to include('mailers')
- expect(queues).to include('default')
+ expect(queues).to include("post_receive")
+ expect(queues).to include("merge")
+ expect(queues).to include("cronjob:stuck_import_jobs")
+ expect(queues).to include("mailers")
+ expect(queues).to include("default")
end
end
- describe '.expand_queues' do
- it 'expands queue namespaces to concrete queue names' do
+ describe ".expand_queues" do
+ it "expands queue namespaces to concrete queue names" do
queues = described_class.expand_queues(%w[cronjob])
- expect(queues).to include('cronjob:stuck_import_jobs')
- expect(queues).to include('cronjob:stuck_merge_jobs')
+ expect(queues).to include("cronjob:stuck_import_jobs")
+ expect(queues).to include("cronjob:stuck_merge_jobs")
end
- it 'lets concrete queue names pass through' do
+ it "lets concrete queue names pass through" do
queues = described_class.expand_queues(%w[post_receive])
- expect(queues).to include('post_receive')
+ expect(queues).to include("post_receive")
end
- it 'lets unknown queues pass through' do
+ it "lets unknown queues pass through" do
queues = described_class.expand_queues(%w[unknown])
- expect(queues).to include('unknown')
+ expect(queues).to include("unknown")
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb
index fed9aeba30c..c25794575e7 100644
--- a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqLogging::JSONFormatter do
- let(:hash_input) { { foo: 1, bar: 'test' } }
- let(:message) { 'This is a test' }
+ let(:hash_input) { {foo: 1, bar: "test"} }
+ let(:message) { "This is a test" }
let(:timestamp) { Time.now }
- it 'wraps a Hash' do
- result = subject.call('INFO', timestamp, 'my program', hash_input)
+ it "wraps a Hash" do
+ result = subject.call("INFO", timestamp, "my program", hash_input)
data = JSON.parse(result)
expected_output = hash_input.stringify_keys
- expected_output['severity'] = 'INFO'
- expected_output['time'] = timestamp.utc.iso8601(3)
+ expected_output["severity"] = "INFO"
+ expected_output["time"] = timestamp.utc.iso8601(3)
expect(data).to eq(expected_output)
end
- it 'wraps a String' do
- result = subject.call('DEBUG', timestamp, 'my string', message)
+ it "wraps a String" do
+ result = subject.call("DEBUG", timestamp, "my string", message)
data = JSON.parse(result)
expected_output = {
- severity: 'DEBUG',
+ severity: "DEBUG",
time: timestamp.utc.iso8601(3),
- message: message
+ message: message,
}
expect(data).to eq(expected_output.stringify_keys)
diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
index 7bc4599e20f..6be478a7785 100644
--- a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqLogging::StructuredLogger do
- describe '#call' do
- let(:timestamp) { Time.new('2018-01-01 12:00:00').utc }
+ describe "#call" do
+ let(:timestamp) { Time.new("2018-01-01 12:00:00").utc }
let(:job) do
{
"class" => "TestWorker",
- "args" => [1234, 'hello'],
+ "args" => [1234, "hello"],
"retry" => false,
"queue" => "cronjob:test_queue",
"queue_namespace" => "cronjob",
"jid" => "da883554ee4fe414012f5f42",
"created_at" => timestamp.to_f,
"enqueued_at" => timestamp.to_f,
- "correlation_id" => 'cid'
+ "correlation_id" => "cid",
}
end
let(:logger) { double }
let(:start_payload) do
job.merge(
- 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start',
- 'job_status' => 'start',
- 'pid' => Process.pid,
- 'created_at' => timestamp.iso8601(3),
- 'enqueued_at' => timestamp.iso8601(3)
+ "message" => "TestWorker JID-da883554ee4fe414012f5f42: start",
+ "job_status" => "start",
+ "pid" => Process.pid,
+ "created_at" => timestamp.iso8601(3),
+ "enqueued_at" => timestamp.iso8601(3)
)
end
let(:end_payload) do
start_payload.merge(
- 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec',
- 'job_status' => 'done',
- 'duration' => 0.0,
+ "message" => "TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec",
+ "job_status" => "done",
+ "duration" => 0.0,
"completed_at" => timestamp.iso8601(3)
)
end
let(:exception_payload) do
end_payload.merge(
- 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec',
- 'job_status' => 'fail',
- 'error' => ArgumentError,
- 'error_message' => 'some exception'
+ "message" => "TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec",
+ "job_status" => "fail",
+ "error" => ArgumentError,
+ "error_message" => "some exception"
)
end
@@ -51,23 +51,23 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
subject { described_class.new }
- context 'with SIDEKIQ_LOG_ARGUMENTS enabled' do
+ context "with SIDEKIQ_LOG_ARGUMENTS enabled" do
before do
- stub_env('SIDEKIQ_LOG_ARGUMENTS', '1')
+ stub_env("SIDEKIQ_LOG_ARGUMENTS", "1")
end
- it 'logs start and end of job' do
+ it "logs start and end of job" do
Timecop.freeze(timestamp) do
expect(logger).to receive(:info).with(start_payload).ordered
expect(logger).to receive(:info).with(end_payload).ordered
expect(subject).to receive(:log_job_start).and_call_original
expect(subject).to receive(:log_job_done).and_call_original
- subject.call(job, 'test_queue') { }
+ subject.call(job, "test_queue") { }
end
end
- it 'logs an exception in job' do
+ it "logs an exception in job" do
Timecop.freeze(timestamp) do
expect(logger).to receive(:info).with(start_payload)
# This excludes the exception_backtrace
@@ -75,47 +75,47 @@ describe Gitlab::SidekiqLogging::StructuredLogger do
expect(subject).to receive(:log_job_start).and_call_original
expect(subject).to receive(:log_job_done).and_call_original
- expect do
- subject.call(job, 'test_queue') do
- raise ArgumentError, 'some exception'
+ expect {
+ subject.call(job, "test_queue") do
+ raise ArgumentError, "some exception"
end
- end.to raise_error(ArgumentError)
+ }.to raise_error(ArgumentError)
end
end
- context 'when the job args are bigger than the maximum allowed' do
- it 'keeps args from the front until they exceed the limit' do
+ context "when the job args are bigger than the maximum allowed" do
+ it "keeps args from the front until they exceed the limit" do
Timecop.freeze(timestamp) do
- job['args'] = [
+ job["args"] = [
1,
2,
- 'a' * (described_class::MAXIMUM_JOB_ARGUMENTS_LENGTH / 2),
- 'b' * (described_class::MAXIMUM_JOB_ARGUMENTS_LENGTH / 2),
- 3
+ "a" * (described_class::MAXIMUM_JOB_ARGUMENTS_LENGTH / 2),
+ "b" * (described_class::MAXIMUM_JOB_ARGUMENTS_LENGTH / 2),
+ 3,
]
- expected_args = job['args'].take(3) + ['...']
+ expected_args = job["args"].take(3) + ["..."]
- expect(logger).to receive(:info).with(start_payload.merge('args' => expected_args)).ordered
- expect(logger).to receive(:info).with(end_payload.merge('args' => expected_args)).ordered
+ expect(logger).to receive(:info).with(start_payload.merge("args" => expected_args)).ordered
+ expect(logger).to receive(:info).with(end_payload.merge("args" => expected_args)).ordered
expect(subject).to receive(:log_job_start).and_call_original
expect(subject).to receive(:log_job_done).and_call_original
- subject.call(job, 'test_queue') { }
+ subject.call(job, "test_queue") { }
end
end
end
end
- context 'with SIDEKIQ_LOG_ARGUMENTS disabled' do
- it 'logs start and end of job without args' do
+ context "with SIDEKIQ_LOG_ARGUMENTS disabled" do
+ it "logs start and end of job without args" do
Timecop.freeze(timestamp) do
- expect(logger).to receive(:info).with(start_payload.except('args')).ordered
- expect(logger).to receive(:info).with(end_payload.except('args')).ordered
+ expect(logger).to receive(:info).with(start_payload.except("args")).ordered
+ expect(logger).to receive(:info).with(end_payload.except("args")).ordered
expect(subject).to receive(:log_job_start).and_call_original
expect(subject).to receive(:log_job_done).and_call_original
- subject.call(job, 'test_queue') { }
+ subject.call(job, "test_queue") { }
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
index a138ad7c910..e455f07728c 100644
--- a/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/correlation_injector_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqMiddleware::CorrelationInjector do
class TestWorker
@@ -27,21 +27,23 @@ describe Gitlab::SidekiqMiddleware::CorrelationInjector do
end
end
- it 'injects into payload the correlation id' do
+ it "injects into payload the correlation id" do
expect_any_instance_of(described_class).to receive(:call).and_call_original
- Gitlab::CorrelationId.use_id('new-correlation-id') do
+ Gitlab::CorrelationId.use_id("new-correlation-id") do
TestWorker.perform_async(1234)
end
expected_job_params = {
"class" => "TestWorker",
"args" => [1234],
- "correlation_id" => "new-correlation-id"
+ "correlation_id" => "new-correlation-id",
}
expect(Sidekiq::Queues.jobs_by_worker).to a_hash_including(
"TestWorker" => a_collection_containing_exactly(
- a_hash_including(expected_job_params)))
+ a_hash_including(expected_job_params)
+ )
+ )
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
index 94ae4ffa184..038c1f53e6f 100644
--- a/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/correlation_logger_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqMiddleware::CorrelationLogger do
class TestWorker
@@ -19,17 +19,18 @@ describe Gitlab::SidekiqMiddleware::CorrelationLogger do
end
end
- it 'injects into payload the correlation id' do
+ it "injects into payload the correlation id" do
expect_any_instance_of(described_class).to receive(:call).and_call_original
expect_any_instance_of(TestWorker).to receive(:perform).with(1234) do
- expect(Gitlab::CorrelationId.current_id).to eq('new-correlation-id')
+ expect(Gitlab::CorrelationId.current_id).to eq("new-correlation-id")
end
Sidekiq::Client.push(
- 'queue' => 'test',
- 'class' => TestWorker,
- 'args' => [1234],
- 'correlation_id' => 'new-correlation-id')
+ "queue" => "test",
+ "class" => TestWorker,
+ "args" => [1234],
+ "correlation_id" => "new-correlation-id"
+ )
end
end
diff --git a/spec/lib/gitlab/sidekiq_middleware/shutdown_spec.rb b/spec/lib/gitlab/sidekiq_middleware/shutdown_spec.rb
index 0001795c3f0..c2e18fd2db7 100644
--- a/spec/lib/gitlab/sidekiq_middleware/shutdown_spec.rb
+++ b/spec/lib/gitlab/sidekiq_middleware/shutdown_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqMiddleware::Shutdown do
subject { described_class.new }
let(:pid) { Process.pid }
- let(:worker) { double(:worker, class: 'TestWorker') }
- let(:job) { { 'jid' => 123 } }
- let(:queue) { 'test_queue' }
+ let(:worker) { double(:worker, class: "TestWorker") }
+ let(:job) { {"jid" => 123} }
+ let(:queue) { "test_queue" }
let(:block) { proc { nil } }
def run
@@ -23,12 +23,12 @@ describe Gitlab::SidekiqMiddleware::Shutdown do
described_class.clear_shutdown_thread
end
- context 'when MAX_RSS is set to 0' do
+ context "when MAX_RSS is set to 0" do
before do
stub_const("#{described_class}::MAX_RSS", 0)
end
- it 'does nothing' do
+ it "does nothing" do
expect(subject).not_to receive(:sleep)
run
@@ -37,43 +37,43 @@ describe Gitlab::SidekiqMiddleware::Shutdown do
def expect_shutdown_sequence
expect(pop_trace).to eq([:sleep, 15 * 60])
- expect(pop_trace).to eq([:kill, 'SIGTSTP', pid])
+ expect(pop_trace).to eq([:kill, "SIGTSTP", pid])
expect(pop_trace).to eq([:sleep, 30])
- expect(pop_trace).to eq([:kill, 'SIGTERM', pid])
+ expect(pop_trace).to eq([:kill, "SIGTERM", pid])
expect(pop_trace).to eq([:sleep, 10])
- expect(pop_trace).to eq([:kill, 'SIGKILL', pid])
+ expect(pop_trace).to eq([:kill, "SIGKILL", pid])
end
- context 'when MAX_RSS is exceeded' do
+ context "when MAX_RSS is exceeded" do
before do
stub_const("#{described_class}::MAX_RSS", 5.kilobytes)
end
- it 'sends the TSTP, TERM and KILL signals at expected times' do
+ it "sends the TSTP, TERM and KILL signals at expected times" do
run
expect_shutdown_sequence
end
end
- context 'when MAX_RSS is not exceeded' do
+ context "when MAX_RSS is not exceeded" do
before do
stub_const("#{described_class}::MAX_RSS", 15.kilobytes)
end
- it 'does nothing' do
+ it "does nothing" do
expect(subject).not_to receive(:sleep)
run
end
end
- context 'when WantShutdown is raised' do
+ context "when WantShutdown is raised" do
let(:block) { proc { raise described_class::WantShutdown } }
- it 'starts the shutdown sequence and re-raises the exception' do
+ it "starts the shutdown sequence and re-raises the exception" do
expect { run }.to raise_exception(described_class::WantShutdown)
# We can't expect 'run' to have joined on the shutdown thread, because
diff --git a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb
index 37d9e1d3e6b..7799bd517bc 100644
--- a/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb
+++ b/spec/lib/gitlab/sidekiq_status/client_middleware_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqStatus::ClientMiddleware do
- describe '#call' do
- it 'tracks the job in Redis' do
- expect(Gitlab::SidekiqStatus).to receive(:set).with('123', Gitlab::SidekiqStatus::DEFAULT_EXPIRATION)
+ describe "#call" do
+ it "tracks the job in Redis" do
+ expect(Gitlab::SidekiqStatus).to receive(:set).with("123", Gitlab::SidekiqStatus::DEFAULT_EXPIRATION)
described_class.new
- .call('Foo', { 'jid' => '123' }, double(:queue), double(:pool)) { nil }
+ .call("Foo", {"jid" => "123"}, double(:queue), double(:pool)) { nil }
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb
index 04e09d3dec8..309760422d4 100644
--- a/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb
+++ b/spec/lib/gitlab/sidekiq_status/server_middleware_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqStatus::ServerMiddleware do
- describe '#call' do
- it 'stops tracking of a job upon completion' do
- expect(Gitlab::SidekiqStatus).to receive(:unset).with('123')
+ describe "#call" do
+ it "stops tracking of a job upon completion" do
+ expect(Gitlab::SidekiqStatus).to receive(:unset).with("123")
ret = described_class.new
- .call(double(:worker), { 'jid' => '123' }, double(:queue)) { 10 }
+ .call(double(:worker), {"jid" => "123"}, double(:queue)) { 10 }
expect(ret).to eq(10)
end
diff --git a/spec/lib/gitlab/sidekiq_status_spec.rb b/spec/lib/gitlab/sidekiq_status_spec.rb
index 884f27b212c..236d401d484 100644
--- a/spec/lib/gitlab/sidekiq_status_spec.rb
+++ b/spec/lib/gitlab/sidekiq_status_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqStatus do
- describe '.set', :clean_gitlab_redis_shared_state do
- it 'stores the job ID' do
- described_class.set('123')
+ describe ".set", :clean_gitlab_redis_shared_state do
+ it "stores the job ID" do
+ described_class.set("123")
- key = described_class.key_for('123')
+ key = described_class.key_for("123")
Sidekiq.redis do |redis|
expect(redis.exists(key)).to eq(true)
@@ -14,12 +14,12 @@ describe Gitlab::SidekiqStatus do
end
end
- describe '.unset', :clean_gitlab_redis_shared_state do
- it 'removes the job ID' do
- described_class.set('123')
- described_class.unset('123')
+ describe ".unset", :clean_gitlab_redis_shared_state do
+ it "removes the job ID" do
+ described_class.set("123")
+ described_class.unset("123")
- key = described_class.key_for('123')
+ key = described_class.key_for("123")
Sidekiq.redis do |redis|
expect(redis.exists(key)).to eq(false)
@@ -27,75 +27,75 @@ describe Gitlab::SidekiqStatus do
end
end
- describe '.all_completed?', :clean_gitlab_redis_shared_state do
- it 'returns true if all jobs have been completed' do
- expect(described_class.all_completed?(%w(123))).to eq(true)
+ describe ".all_completed?", :clean_gitlab_redis_shared_state do
+ it "returns true if all jobs have been completed" do
+ expect(described_class.all_completed?(%w[123])).to eq(true)
end
- it 'returns false if a job has not yet been completed' do
- described_class.set('123')
+ it "returns false if a job has not yet been completed" do
+ described_class.set("123")
- expect(described_class.all_completed?(%w(123 456))).to eq(false)
+ expect(described_class.all_completed?(%w[123 456])).to eq(false)
end
end
- describe '.running?', :clean_gitlab_redis_shared_state do
- it 'returns true if job is running' do
- described_class.set('123')
+ describe ".running?", :clean_gitlab_redis_shared_state do
+ it "returns true if job is running" do
+ described_class.set("123")
- expect(described_class.running?('123')).to be(true)
+ expect(described_class.running?("123")).to be(true)
end
- it 'returns false if job is not found' do
- expect(described_class.running?('123')).to be(false)
+ it "returns false if job is not found" do
+ expect(described_class.running?("123")).to be(false)
end
end
- describe '.num_running', :clean_gitlab_redis_shared_state do
- it 'returns 0 if all jobs have been completed' do
- expect(described_class.num_running(%w(123))).to eq(0)
+ describe ".num_running", :clean_gitlab_redis_shared_state do
+ it "returns 0 if all jobs have been completed" do
+ expect(described_class.num_running(%w[123])).to eq(0)
end
- it 'returns 2 if two jobs are still running' do
- described_class.set('123')
- described_class.set('456')
+ it "returns 2 if two jobs are still running" do
+ described_class.set("123")
+ described_class.set("456")
- expect(described_class.num_running(%w(123 456 789))).to eq(2)
+ expect(described_class.num_running(%w[123 456 789])).to eq(2)
end
end
- describe '.num_completed', :clean_gitlab_redis_shared_state do
- it 'returns 1 if all jobs have been completed' do
- expect(described_class.num_completed(%w(123))).to eq(1)
+ describe ".num_completed", :clean_gitlab_redis_shared_state do
+ it "returns 1 if all jobs have been completed" do
+ expect(described_class.num_completed(%w[123])).to eq(1)
end
- it 'returns 1 if a job has not yet been completed' do
- described_class.set('123')
- described_class.set('456')
+ it "returns 1 if a job has not yet been completed" do
+ described_class.set("123")
+ described_class.set("456")
- expect(described_class.num_completed(%w(123 456 789))).to eq(1)
+ expect(described_class.num_completed(%w[123 456 789])).to eq(1)
end
end
- describe '.key_for' do
- it 'returns the key for a job ID' do
- key = described_class.key_for('123')
+ describe ".key_for" do
+ it "returns the key for a job ID" do
+ key = described_class.key_for("123")
expect(key).to be_an_instance_of(String)
- expect(key).to include('123')
+ expect(key).to include("123")
end
end
- describe 'completed', :clean_gitlab_redis_shared_state do
- it 'returns the completed job' do
- expect(described_class.completed_jids(%w(123))).to eq(['123'])
+ describe "completed", :clean_gitlab_redis_shared_state do
+ it "returns the completed job" do
+ expect(described_class.completed_jids(%w[123])).to eq(["123"])
end
- it 'returns only the jobs completed' do
- described_class.set('123')
- described_class.set('456')
+ it "returns only the jobs completed" do
+ described_class.set("123")
+ described_class.set("456")
- expect(described_class.completed_jids(%w(123 456 789))).to eq(['789'])
+ expect(described_class.completed_jids(%w[123 456 789])).to eq(["789"])
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_versioning/manager_spec.rb b/spec/lib/gitlab/sidekiq_versioning/manager_spec.rb
index 7debf70a16f..cc2656c82a5 100644
--- a/spec/lib/gitlab/sidekiq_versioning/manager_spec.rb
+++ b/spec/lib/gitlab/sidekiq_versioning/manager_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqVersioning::Manager do
before do
Sidekiq::Manager.prepend described_class
end
- describe '#initialize' do
- it 'listens on all expanded queues' do
+ describe "#initialize" do
+ it "listens on all expanded queues" do
manager = Sidekiq::Manager.new(queues: %w[post_receive repository_fork cronjob unknown])
queues = manager.options[:queues]
- expect(queues).to include('post_receive')
- expect(queues).to include('repository_fork')
- expect(queues).to include('cronjob')
- expect(queues).to include('cronjob:stuck_import_jobs')
- expect(queues).to include('cronjob:stuck_merge_jobs')
- expect(queues).to include('unknown')
+ expect(queues).to include("post_receive")
+ expect(queues).to include("repository_fork")
+ expect(queues).to include("cronjob")
+ expect(queues).to include("cronjob:stuck_import_jobs")
+ expect(queues).to include("cronjob:stuck_merge_jobs")
+ expect(queues).to include("unknown")
end
end
end
diff --git a/spec/lib/gitlab/sidekiq_versioning_spec.rb b/spec/lib/gitlab/sidekiq_versioning_spec.rb
index fa6d42e730d..e9213af24c1 100644
--- a/spec/lib/gitlab/sidekiq_versioning_spec.rb
+++ b/spec/lib/gitlab/sidekiq_versioning_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SidekiqVersioning, :sidekiq, :redis do
let(:foo_worker) do
Class.new do
def self.name
- 'FooWorker'
+ "FooWorker"
end
include ApplicationWorker
@@ -14,7 +14,7 @@ describe Gitlab::SidekiqVersioning, :sidekiq, :redis do
let(:bar_worker) do
Class.new do
def self.name
- 'BarWorker'
+ "BarWorker"
end
include ApplicationWorker
@@ -26,19 +26,19 @@ describe Gitlab::SidekiqVersioning, :sidekiq, :redis do
allow(Gitlab::SidekiqConfig).to receive(:worker_queues).and_return([foo_worker.queue, bar_worker.queue])
end
- describe '.install!' do
- it 'prepends SidekiqVersioning::Manager into Sidekiq::Manager' do
+ describe ".install!" do
+ it "prepends SidekiqVersioning::Manager into Sidekiq::Manager" do
described_class.install!
expect(Sidekiq::Manager).to include(Gitlab::SidekiqVersioning::Manager)
end
- it 'registers all versionless and versioned queues with Redis' do
+ it "registers all versionless and versioned queues with Redis" do
described_class.install!
queues = Sidekiq::Queue.all.map(&:name)
- expect(queues).to include('foo')
- expect(queues).to include('bar')
+ expect(queues).to include("foo")
+ expect(queues).to include("bar")
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/application_help_spec.rb b/spec/lib/gitlab/slash_commands/application_help_spec.rb
index b203a1ee79c..e639990770e 100644
--- a/spec/lib/gitlab/slash_commands/application_help_spec.rb
+++ b/spec/lib/gitlab/slash_commands/application_help_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::ApplicationHelp do
- let(:params) { { command: '/gitlab', text: 'help' } }
+ let(:params) { {command: "/gitlab", text: "help"} }
- describe '#execute' do
+ describe "#execute" do
subject do
described_class.new(params).execute
end
- it 'displays the help section' do
+ it "displays the help section" do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to include('Available commands')
- expect(subject[:text]).to include('/gitlab [project name or alias] issue show')
+ expect(subject[:text]).to include("Available commands")
+ expect(subject[:text]).to include("/gitlab [project name or alias] issue show")
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/command_spec.rb b/spec/lib/gitlab/slash_commands/command_spec.rb
index eceacac58af..28701682f06 100644
--- a/spec/lib/gitlab/slash_commands/command_spec.rb
+++ b/spec/lib/gitlab/slash_commands/command_spec.rb
@@ -1,85 +1,85 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Command do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:chat_name) { double(:chat_name, user: user) }
- describe '#execute' do
+ describe "#execute" do
subject do
described_class.new(project, chat_name, params).execute
end
- context 'when no command is available' do
- let(:params) { { text: 'issue show 1' } }
+ context "when no command is available" do
+ let(:params) { {text: "issue show 1"} }
let(:project) { create(:project, has_external_issue_tracker: true) }
- it 'displays 404 messages' do
+ it "displays 404 messages" do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('404 not found')
+ expect(subject[:text]).to start_with("404 not found")
end
end
- context 'when an unknown command is triggered' do
- let(:params) { { command: '/gitlab', text: "unknown command 123" } }
+ context "when an unknown command is triggered" do
+ let(:params) { {command: "/gitlab", text: "unknown command 123"} }
- it 'displays the help message' do
+ it "displays the help message" do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Unknown command')
- expect(subject[:text]).to match('/gitlab issue show')
+ expect(subject[:text]).to start_with("Unknown command")
+ expect(subject[:text]).to match("/gitlab issue show")
end
end
- context 'the user can not create an issue' do
- let(:params) { { text: "issue create my new issue" } }
+ context "the user can not create an issue" do
+ let(:params) { {text: "issue create my new issue"} }
- it 'rejects the actions' do
+ it "rejects the actions" do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Whoops! This action is not allowed')
+ expect(subject[:text]).to start_with("Whoops! This action is not allowed")
end
end
- context 'when trying to do deployment' do
- let(:params) { { text: 'deploy staging to production' } }
+ context "when trying to do deployment" do
+ let(:params) { {text: "deploy staging to production"} }
let!(:build) { create(:ci_build, pipeline: pipeline) }
let!(:pipeline) { create(:ci_pipeline, project: project) }
- let!(:staging) { create(:environment, name: 'staging', project: project) }
+ let!(:staging) { create(:environment, name: "staging", project: project) }
let!(:deployment) { create(:deployment, :success, environment: staging, deployable: build) }
let!(:manual) do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'first',
- environment: 'production')
+ name: "first",
+ environment: "production")
end
- context 'and user can not create deployment' do
- it 'returns action' do
+ context "and user can not create deployment" do
+ it "returns action" do
expect(subject[:response_type]).to be(:ephemeral)
- expect(subject[:text]).to start_with('Whoops! This action is not allowed')
+ expect(subject[:text]).to start_with("Whoops! This action is not allowed")
end
end
- context 'and user has deployment permission' do
+ context "and user has deployment permission" do
before do
build.project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'returns action' do
- expect(subject[:text]).to include('Deployment started from staging to production')
+ it "returns action" do
+ expect(subject[:text]).to include("Deployment started from staging to production")
expect(subject[:response_type]).to be(:in_channel)
end
- context 'when duplicate action exists' do
+ context "when duplicate action exists" do
let!(:manual2) do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'second',
- environment: 'production')
+ name: "second",
+ environment: "production")
end
- it 'returns error' do
+ it "returns error" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to include("Couldn't find a deployment manual action.")
end
@@ -88,29 +88,29 @@ describe Gitlab::SlashCommands::Command do
end
end
- describe '#match_command' do
+ describe "#match_command" do
subject { described_class.new(project, chat_name, params).match_command.first }
- context 'IssueShow is triggered' do
- let(:params) { { text: 'issue show 123' } }
+ context "IssueShow is triggered" do
+ let(:params) { {text: "issue show 123"} }
it { is_expected.to eq(Gitlab::SlashCommands::IssueShow) }
end
- context 'IssueCreate is triggered' do
- let(:params) { { text: 'issue create my title' } }
+ context "IssueCreate is triggered" do
+ let(:params) { {text: "issue create my title"} }
it { is_expected.to eq(Gitlab::SlashCommands::IssueNew) }
end
- context 'IssueSearch is triggered' do
- let(:params) { { text: 'issue search my query' } }
+ context "IssueSearch is triggered" do
+ let(:params) { {text: "issue search my query"} }
it { is_expected.to eq(Gitlab::SlashCommands::IssueSearch) }
end
- context 'IssueMove is triggered' do
- let(:params) { { text: 'issue move #78291 to gitlab/gitlab-ci' } }
+ context "IssueMove is triggered" do
+ let(:params) { {text: "issue move #78291 to gitlab/gitlab-ci"} }
it { is_expected.to eq(Gitlab::SlashCommands::IssueMove) }
end
end
diff --git a/spec/lib/gitlab/slash_commands/deploy_spec.rb b/spec/lib/gitlab/slash_commands/deploy_spec.rb
index 25f3e8a0409..c9f81fcce46 100644
--- a/spec/lib/gitlab/slash_commands/deploy_spec.rb
+++ b/spec/lib/gitlab/slash_commands/deploy_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Deploy do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:chat_name) { double(:chat_name, user: user) }
- let(:regex_match) { described_class.match('deploy staging to production') }
+ let(:regex_match) { described_class.match("deploy staging to production") }
before do
# Make it possible to trigger protected manual actions for developers.
@@ -13,96 +13,96 @@ describe Gitlab::SlashCommands::Deploy do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
+ name: "master", project: project)
end
subject do
described_class.new(project, chat_name).execute(regex_match)
end
- context 'if no environment is defined' do
- it 'does not execute an action' do
+ context "if no environment is defined" do
+ it "does not execute an action" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to eq "Couldn't find a deployment manual action."
end
end
- context 'with environment' do
- let!(:staging) { create(:environment, name: 'staging', project: project) }
+ context "with environment" do
+ let!(:staging) { create(:environment, name: "staging", project: project) }
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, pipeline: pipeline) }
let!(:deployment) { create(:deployment, :success, environment: staging, deployable: build) }
- context 'without actions' do
- it 'does not execute an action' do
+ context "without actions" do
+ it "does not execute an action" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to eq "Couldn't find a deployment manual action."
end
end
- context 'when single action has been matched' do
+ context "when single action has been matched" do
before do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'first',
- environment: 'production')
+ name: "first",
+ environment: "production")
end
- it 'returns success result' do
+ it "returns success result" do
expect(subject[:response_type]).to be(:in_channel)
expect(subject[:text])
- .to start_with('Deployment started from staging to production')
+ .to start_with("Deployment started from staging to production")
end
end
- context 'when more than one action has been matched' do
- context 'when there is no specific actions with a environment name' do
+ context "when more than one action has been matched" do
+ context "when there is no specific actions with a environment name" do
before do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'first',
- environment: 'production')
+ name: "first",
+ environment: "production")
create(:ci_build, :manual, pipeline: pipeline,
- name: 'second',
- environment: 'production')
+ name: "second",
+ environment: "production")
end
- it 'returns error about too many actions defined' do
+ it "returns error about too many actions defined" do
expect(subject[:text]).to eq("Couldn't find a deployment manual action.")
expect(subject[:response_type]).to be(:ephemeral)
end
end
- context 'when one of the actions is environement specific action' do
+ context "when one of the actions is environement specific action" do
before do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'first',
- environment: 'production')
+ name: "first",
+ environment: "production")
create(:ci_build, :manual, pipeline: pipeline,
- name: 'production',
- environment: 'production')
+ name: "production",
+ environment: "production")
end
- it 'deploys to production' do
+ it "deploys to production" do
expect(subject[:text])
- .to start_with('Deployment started from staging to production')
+ .to start_with("Deployment started from staging to production")
expect(subject[:response_type]).to be(:in_channel)
end
end
- context 'when one of the actions is a teardown action' do
+ context "when one of the actions is a teardown action" do
before do
create(:ci_build, :manual, pipeline: pipeline,
- name: 'first',
- environment: 'production')
+ name: "first",
+ environment: "production")
create(:ci_build, :manual, :teardown_environment,
- pipeline: pipeline, name: 'teardown', environment: 'production')
+ pipeline: pipeline, name: "teardown", environment: "production")
end
- it 'deploys to production' do
+ it "deploys to production" do
expect(subject[:text])
- .to start_with('Deployment started from staging to production')
+ .to start_with("Deployment started from staging to production")
expect(subject[:response_type]).to be(:in_channel)
end
end
@@ -110,12 +110,12 @@ describe Gitlab::SlashCommands::Deploy do
end
end
- describe 'self.match' do
- it 'matches the environment' do
- match = described_class.match('deploy staging to production')
+ describe "self.match" do
+ it "matches the environment" do
+ match = described_class.match("deploy staging to production")
- expect(match[:from]).to eq('staging')
- expect(match[:to]).to eq('production')
+ expect(match[:from]).to eq("staging")
+ expect(match[:to]).to eq("production")
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/issue_move_spec.rb b/spec/lib/gitlab/slash_commands/issue_move_spec.rb
index 9a990e1fad7..5a5af61c75a 100644
--- a/spec/lib/gitlab/slash_commands/issue_move_spec.rb
+++ b/spec/lib/gitlab/slash_commands/issue_move_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::IssueMove, service: true do
- describe '#match' do
- shared_examples_for 'move command' do |text_command|
- it 'can be parsed to extract the needed fields' do
+ describe "#match" do
+ shared_examples_for "move command" do |text_command|
+ it "can be parsed to extract the needed fields" do
match_data = described_class.match(text_command)
- expect(match_data['iid']).to eq('123456')
- expect(match_data['project_path']).to eq('gitlab/gitlab-ci')
+ expect(match_data["iid"]).to eq("123456")
+ expect(match_data["project_path"]).to eq("gitlab/gitlab-ci")
end
end
- it_behaves_like 'move command', 'issue move #123456 to gitlab/gitlab-ci'
- it_behaves_like 'move command', 'issue move #123456 gitlab/gitlab-ci'
- it_behaves_like 'move command', 'issue move #123456 gitlab/gitlab-ci '
- it_behaves_like 'move command', 'issue move 123456 to gitlab/gitlab-ci'
- it_behaves_like 'move command', 'issue move 123456 gitlab/gitlab-ci'
- it_behaves_like 'move command', 'issue move 123456 gitlab/gitlab-ci '
+ it_behaves_like "move command", "issue move #123456 to gitlab/gitlab-ci"
+ it_behaves_like "move command", "issue move #123456 gitlab/gitlab-ci"
+ it_behaves_like "move command", "issue move #123456 gitlab/gitlab-ci "
+ it_behaves_like "move command", "issue move 123456 to gitlab/gitlab-ci"
+ it_behaves_like "move command", "issue move 123456 gitlab/gitlab-ci"
+ it_behaves_like "move command", "issue move 123456 gitlab/gitlab-ci "
end
- describe '#execute' do
+ describe "#execute" do
set(:user) { create(:user) }
set(:issue) { create(:issue) }
set(:chat_name) { create(:chat_name, user: user) }
@@ -36,81 +36,81 @@ describe Gitlab::SlashCommands::IssueMove, service: true do
subject.execute(described_class.match(message))
end
- context 'when the user can move the issue' do
- context 'when the move fails' do
- it 'returns the error message' do
+ context "when the user can move the issue" do
+ context "when the move fails" do
+ it "returns the error message" do
message = "issue move #{issue.iid} #{project.full_path}"
expect(process_message(message)).to include(response_type: :ephemeral,
- text: a_string_matching('Cannot move issue'))
+ text: a_string_matching("Cannot move issue"))
end
end
- context 'when the move succeeds' do
+ context "when the move succeeds" do
let(:message) { "issue move #{issue.iid} #{other_project.full_path}" }
- it 'moves the issue to the new destination' do
+ it "moves the issue to the new destination" do
expect { process_message(message) }.to change { Issue.count }.by(1)
new_issue = issue.reload.moved_to
- expect(new_issue.state).to eq('opened')
+ expect(new_issue.state).to eq("opened")
expect(new_issue.project_id).to eq(other_project.id)
expect(new_issue.author_id).to eq(issue.author_id)
- expect(issue.state).to eq('closed')
+ expect(issue.state).to eq("closed")
expect(issue.project_id).to eq(project.id)
end
- it 'returns the new issue' do
+ it "returns the new issue" do
expect(process_message(message))
.to include(response_type: :in_channel,
attachments: [a_hash_including(title_link: a_string_including(other_project.full_path))])
end
- it 'mentions the old issue' do
+ it "mentions the old issue" do
expect(process_message(message))
.to include(attachments: [a_hash_including(pretext: a_string_including(project.full_path))])
end
end
end
- context 'when the issue does not exist' do
- it 'returns not found' do
+ context "when the issue does not exist" do
+ it "returns not found" do
message = "issue move #{issue.iid.succ} #{other_project.full_path}"
expect(process_message(message)).to include(response_type: :ephemeral,
- text: a_string_matching('not found'))
+ text: a_string_matching("not found"))
end
end
- context 'when the target project does not exist' do
- it 'returns not found' do
+ context "when the target project does not exist" do
+ it "returns not found" do
message = "issue move #{issue.iid} #{other_project.full_path}/foo"
expect(process_message(message)).to include(response_type: :ephemeral,
- text: a_string_matching('not found'))
+ text: a_string_matching("not found"))
end
end
- context 'when the user cannot see the target project' do
- it 'returns not found' do
+ context "when the user cannot see the target project" do
+ it "returns not found" do
message = "issue move #{issue.iid} #{other_project.full_path}"
other_project.team.truncate
expect(process_message(message)).to include(response_type: :ephemeral,
- text: a_string_matching('not found'))
+ text: a_string_matching("not found"))
end
end
- context 'when the user does not have the required permissions on the target project' do
- it 'returns the error message' do
+ context "when the user does not have the required permissions on the target project" do
+ it "returns the error message" do
message = "issue move #{issue.iid} #{other_project.full_path}"
other_project.team.truncate
other_project.team.add_guest(user)
expect(process_message(message)).to include(response_type: :ephemeral,
- text: a_string_matching('Cannot move issue'))
+ text: a_string_matching("Cannot move issue"))
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/issue_new_spec.rb b/spec/lib/gitlab/slash_commands/issue_new_spec.rb
index 59de11766d8..3802518b106 100644
--- a/spec/lib/gitlab/slash_commands/issue_new_spec.rb
+++ b/spec/lib/gitlab/slash_commands/issue_new_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::IssueNew do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:chat_name) { double(:chat_name, user: user) }
@@ -15,19 +15,19 @@ describe Gitlab::SlashCommands::IssueNew do
described_class.new(project, chat_name).execute(regex_match)
end
- context 'without description' do
- it 'creates the issue' do
+ context "without description" do
+ it "creates the issue" do
expect { subject }.to change { project.issues.count }.by(1)
expect(subject[:response_type]).to be(:in_channel)
end
end
- context 'with description' do
+ context "with description" do
let(:description) { "Surfin bird" }
let(:regex_match) { described_class.match("issue create bird is the word\n#{description}") }
- it 'creates the issue with description' do
+ it "creates the issue with description" do
subject
expect(Issue.last.description).to eq(description)
@@ -38,42 +38,42 @@ describe Gitlab::SlashCommands::IssueNew do
let(:description) { "Surfin bird" }
let(:regex_match) { described_class.match("issue create bird is the word\n\n#{description}\n") }
- it 'creates the issue' do
+ it "creates the issue" do
expect { subject }.to change { project.issues.count }.by(1)
end
end
- context 'issue cannot be created' do
- let!(:issue) { create(:issue, project: project, title: 'bird is the word') }
- let(:regex_match) { described_class.match("issue create #{'a' * 512}}") }
+ context "issue cannot be created" do
+ let!(:issue) { create(:issue, project: project, title: "bird is the word") }
+ let(:regex_match) { described_class.match("issue create #{"a" * 512}}") }
- it 'displays the errors' do
+ it "displays the errors" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to match("- Title is too long")
end
end
end
- describe '.match' do
- it 'matches the title without description' do
+ describe ".match" do
+ it "matches the title without description" do
match = described_class.match("issue create my title")
- expect(match[:title]).to eq('my title')
+ expect(match[:title]).to eq("my title")
expect(match[:description]).to eq("")
end
- it 'matches the title with description' do
+ it "matches the title with description" do
match = described_class.match("issue create my title\n\ndescription")
- expect(match[:title]).to eq('my title')
- expect(match[:description]).to eq('description')
+ expect(match[:title]).to eq("my title")
+ expect(match[:description]).to eq("description")
end
- it 'matches the alias new' do
+ it "matches the alias new" do
match = described_class.match("issue new my title")
expect(match).not_to be_nil
- expect(match[:title]).to eq('my title')
+ expect(match[:title]).to eq("my title")
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/issue_search_spec.rb b/spec/lib/gitlab/slash_commands/issue_search_spec.rb
index 47787307990..604de2477df 100644
--- a/spec/lib/gitlab/slash_commands/issue_search_spec.rb
+++ b/spec/lib/gitlab/slash_commands/issue_search_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::IssueSearch do
- describe '#execute' do
- let!(:issue) { create(:issue, project: project, title: 'find me') }
- let!(:confidential) { create(:issue, :confidential, project: project, title: 'mepmep find') }
+ describe "#execute" do
+ let!(:issue) { create(:issue, project: project, title: "find me") }
+ let!(:confidential) { create(:issue, :confidential, project: project, title: "mepmep find") }
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:chat_name) { double(:chat_name, user: user) }
@@ -13,34 +13,34 @@ describe Gitlab::SlashCommands::IssueSearch do
described_class.new(project, chat_name).execute(regex_match)
end
- context 'when the user has no access' do
- it 'only returns the open issues' do
+ context "when the user has no access" do
+ it "only returns the open issues" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to match("not found")
end
end
- context 'the user has access' do
+ context "the user has access" do
before do
project.add_maintainer(user)
end
- it 'returns all results' do
+ it "returns all results" do
expect(subject).to have_key(:attachments)
expect(subject[:text]).to eq("Here are the 2 issues I found:")
end
end
- context 'without hits on the query' do
- it 'returns an empty collection' do
+ context "without hits on the query" do
+ it "returns an empty collection" do
expect(subject[:text]).to match("not found")
end
end
end
- describe 'self.match' do
+ describe "self.match" do
let(:query) { "my search keywords" }
- it 'matches the query' do
+ it "matches the query" do
match = described_class.match("issue search #{query}")
expect(match[:query]).to eq(query)
diff --git a/spec/lib/gitlab/slash_commands/issue_show_spec.rb b/spec/lib/gitlab/slash_commands/issue_show_spec.rb
index 5c4ba2736ba..744cbb2a97c 100644
--- a/spec/lib/gitlab/slash_commands/issue_show_spec.rb
+++ b/spec/lib/gitlab/slash_commands/issue_show_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::IssueShow do
- describe '#execute' do
+ describe "#execute" do
let(:issue) { create(:issue, project: project) }
let(:project) { create(:project) }
let(:user) { issue.author }
@@ -16,25 +16,25 @@ describe Gitlab::SlashCommands::IssueShow do
described_class.new(project, chat_name).execute(regex_match)
end
- context 'the issue exists' do
+ context "the issue exists" do
let(:title) { subject[:attachments].first[:title] }
- it 'returns the issue' do
+ it "returns the issue" do
expect(subject[:response_type]).to be(:in_channel)
expect(title).to start_with(issue.title)
end
- context 'when its reference is given' do
+ context "when its reference is given" do
let(:regex_match) { described_class.match("issue show #{issue.to_reference}") }
- it 'shows the issue' do
+ it "shows the issue" do
expect(subject[:response_type]).to be(:in_channel)
expect(title).to start_with(issue.title)
end
end
end
- context 'the issue does not exist' do
+ context "the issue does not exist" do
let(:regex_match) { described_class.match("issue show 2343242") }
it "returns not found" do
@@ -44,14 +44,14 @@ describe Gitlab::SlashCommands::IssueShow do
end
end
- describe '.match' do
- it 'matches the iid' do
+ describe ".match" do
+ it "matches the iid" do
match = described_class.match("issue show 123")
expect(match[:iid]).to eq("123")
end
- it 'accepts a reference' do
+ it "accepts a reference" do
match = described_class.match("issue show #{Issue.reference_prefix}123")
expect(match[:iid]).to eq("123")
diff --git a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
index ef3d217f7be..e9e6ec114ca 100644
--- a/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/access_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::Access do
- describe '#access_denied' do
+ describe "#access_denied" do
subject { described_class.new.access_denied }
it { is_expected.to be_a(Hash) }
- it 'displays an error message' do
+ it "displays an error message" do
expect(subject[:text]).to match("is not allowed")
expect(subject[:response_type]).to be(:ephemeral)
end
end
- describe '#not_found' do
+ describe "#not_found" do
subject { described_class.new.not_found }
it { is_expected.to be_a(Hash) }
- it 'tells the user the resource was not found' do
+ it "tells the user the resource was not found" do
expect(subject[:text]).to match("not found!")
expect(subject[:response_type]).to be(:ephemeral)
end
end
- describe '#authorize' do
- context 'with an authorization URL' do
- subject { described_class.new('http://authorize.me').authorize }
+ describe "#authorize" do
+ context "with an authorization URL" do
+ subject { described_class.new("http://authorize.me").authorize }
it { is_expected.to be_a(Hash) }
- it 'tells the user to authorize' do
+ it "tells the user to authorize" do
expect(subject[:text]).to match("connect your GitLab account")
expect(subject[:response_type]).to be(:ephemeral)
end
end
- context 'without authorization url' do
+ context "without authorization url" do
subject { described_class.new.authorize }
it { is_expected.to be_a(Hash) }
- it 'tells the user to authorize' do
+ it "tells the user to authorize" do
expect(subject[:text]).to match("Couldn't identify you")
expect(subject[:response_type]).to be(:ephemeral)
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb b/spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb
index d16d122c64e..c2c5d095243 100644
--- a/spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/deploy_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::Deploy do
let(:build) { create(:ci_build) }
- describe '#present' do
- subject { described_class.new(build).present('staging', 'prod') }
+ describe "#present" do
+ subject { described_class.new(build).present("staging", "prod") }
it { is_expected.to have_key(:text) }
it { is_expected.to have_key(:response_type) }
it { is_expected.to have_key(:status) }
it { is_expected.not_to have_key(:attachments) }
- it 'messages the channel of the deploy' do
+ it "messages the channel of the deploy" do
expect(subject[:response_type]).to be(:in_channel)
expect(subject[:text]).to start_with("Deployment started from staging to prod")
end
end
- describe '#action_not_found' do
+ describe "#action_not_found" do
subject { described_class.new(nil).action_not_found }
it { is_expected.to have_key(:text) }
@@ -25,7 +25,7 @@ describe Gitlab::SlashCommands::Presenters::Deploy do
it { is_expected.to have_key(:status) }
it { is_expected.not_to have_key(:attachments) }
- it 'tells the user there is no action' do
+ it "tells the user there is no action" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:text]).to eq "Couldn't find a deployment manual action."
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/error_spec.rb b/spec/lib/gitlab/slash_commands/presenters/error_spec.rb
index 30ff81510c1..e87ee3a238f 100644
--- a/spec/lib/gitlab/slash_commands/presenters/error_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/error_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::Error do
- subject { described_class.new('Error').message }
+ subject { described_class.new("Error").message }
it { is_expected.to be_a(Hash) }
- it 'shows the error message' do
+ it "shows the error message" do
expect(subject[:response_type]).to be(:ephemeral)
expect(subject[:status]).to eq(200)
- expect(subject[:text]).to eq('Error')
+ expect(subject[:text]).to eq("Error")
end
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
index 58c341a284e..a2ba31a19c9 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_move_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::IssueMove do
set(:admin) { create(:admin) }
@@ -12,14 +12,14 @@ describe Gitlab::SlashCommands::Presenters::IssueMove do
it { is_expected.to be_a(Hash) }
- it 'shows the new issue' do
+ it "shows the new issue" do
expect(subject[:response_type]).to be(:in_channel)
expect(subject).to have_key(:attachments)
expect(attachment[:title]).to start_with(new_issue.title)
expect(attachment[:title_link]).to include(other_project.full_path)
end
- it 'mentions the old issue and the new issue in the pretext' do
+ it "mentions the old issue and the new issue in the pretext" do
expect(attachment[:pretext]).to include(project.full_path)
expect(attachment[:pretext]).to include(other_project.full_path)
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_new_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_new_spec.rb
index 76e4bad88fd..f4cbf444b0d 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_new_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_new_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::IssueNew do
let(:project) { create(:project) }
@@ -9,7 +9,7 @@ describe Gitlab::SlashCommands::Presenters::IssueNew do
it { is_expected.to be_a(Hash) }
- it 'shows the issue' do
+ it "shows the issue" do
expect(subject[:response_type]).to be(:in_channel)
expect(subject).to have_key(:attachments)
expect(attachment[:title]).to start_with(issue.title)
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_search_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_search_spec.rb
index 5a7ec0685fe..505ff621d1d 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_search_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_search_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::IssueSearch do
let(:project) { create(:project) }
@@ -10,14 +10,14 @@ describe Gitlab::SlashCommands::Presenters::IssueSearch do
subject { described_class.new(project.issues).present }
- it 'formats the message correct' do
+ it "formats the message correct" do
is_expected.to have_key(:text)
is_expected.to have_key(:status)
is_expected.to have_key(:response_type)
is_expected.to have_key(:attachments)
end
- it 'shows a list of results' do
+ it "shows a list of results" do
expect(subject[:response_type]).to be(:ephemeral)
expect(message).to start_with("Here are the 2 issues I found")
diff --git a/spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb b/spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb
index 8f607d7a9c9..d8226912c03 100644
--- a/spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/issue_show_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::IssueShow do
let(:project) { create(:project) }
@@ -9,42 +9,42 @@ describe Gitlab::SlashCommands::Presenters::IssueShow do
it { is_expected.to be_a(Hash) }
- it 'shows the issue' do
+ it "shows the issue" do
expect(subject[:response_type]).to be(:in_channel)
expect(subject).to have_key(:attachments)
expect(attachment[:title]).to start_with(issue.title)
end
- context 'with upvotes' do
+ context "with upvotes" do
before do
create(:award_emoji, :upvote, awardable: issue)
end
- it 'shows the upvote count' do
+ it "shows the upvote count" do
expect(subject[:response_type]).to be(:in_channel)
expect(attachment[:text]).to start_with("**Open** · :+1: 1")
end
end
- context 'with labels' do
- let(:label) { create(:label, project: project, title: 'mep') }
- let(:label1) { create(:label, project: project, title: 'mop') }
+ context "with labels" do
+ let(:label) { create(:label, project: project, title: "mep") }
+ let(:label1) { create(:label, project: project, title: "mop") }
before do
issue.labels << [label, label1]
end
- it 'shows the labels' do
- labels = attachment[:fields].find { |f| f[:title] == 'Labels' }
+ it "shows the labels" do
+ labels = attachment[:fields].find { |f| f[:title] == "Labels" }
expect(labels[:value]).to eq("mep, mop")
end
end
- context 'confidential issue' do
+ context "confidential issue" do
let(:issue) { create(:issue, project: project) }
- it 'shows an ephemeral response' do
+ it "shows an ephemeral response" do
expect(subject[:response_type]).to be(:in_channel)
expect(attachment[:text]).to start_with("**Open**")
end
diff --git a/spec/lib/gitlab/slash_commands/presenters/run_spec.rb b/spec/lib/gitlab/slash_commands/presenters/run_spec.rb
index f3ab01ef6bb..6eff3017ea5 100644
--- a/spec/lib/gitlab/slash_commands/presenters/run_spec.rb
+++ b/spec/lib/gitlab/slash_commands/presenters/run_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Presenters::Run do
let(:presenter) { described_class.new }
- describe '#present' do
- context 'when no builds are present' do
- it 'returns an error' do
+ describe "#present" do
+ context "when no builds are present" do
+ it "returns an error" do
builds = double(:builds, take: nil)
pipeline = double(:pipeline, builds: builds)
@@ -18,9 +18,9 @@ describe Gitlab::SlashCommands::Presenters::Run do
end
end
- context 'when a responder could be found' do
- it 'returns the output for a scheduled pipeline' do
- responder = double(:responder, scheduled_output: 'hello')
+ context "when a responder could be found" do
+ it "returns the output for a scheduled pipeline" do
+ responder = double(:responder, scheduled_output: "hello")
build = double(:build)
builds = double(:builds, take: build)
pipeline = double(:pipeline, builds: builds)
@@ -32,14 +32,14 @@ describe Gitlab::SlashCommands::Presenters::Run do
expect(presenter)
.to receive(:in_channel_response)
- .with('hello')
+ .with("hello")
presenter.present(pipeline)
end
end
- context 'when a responder could not be found' do
- it 'returns an error' do
+ context "when a responder could not be found" do
+ it "returns an error" do
build = double(:build)
builds = double(:builds, take: build)
pipeline = double(:pipeline, builds: builds)
@@ -57,8 +57,8 @@ describe Gitlab::SlashCommands::Presenters::Run do
end
end
- describe '#unsupported_chat_service' do
- it 'returns an ephemeral response' do
+ describe "#unsupported_chat_service" do
+ it "returns an ephemeral response" do
expect(presenter)
.to receive(:ephemeral_response)
.with(text: /Sorry, this chat service is currently not supported/)
@@ -67,13 +67,13 @@ describe Gitlab::SlashCommands::Presenters::Run do
end
end
- describe '#failed_to_schedule' do
- it 'returns an ephemeral response' do
+ describe "#failed_to_schedule" do
+ it "returns an ephemeral response" do
expect(presenter)
.to receive(:ephemeral_response)
.with(text: /The command could not be scheduled/)
- presenter.failed_to_schedule('foo')
+ presenter.failed_to_schedule("foo")
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/run_spec.rb b/spec/lib/gitlab/slash_commands/run_spec.rb
index 900fae05719..01fdf6b960c 100644
--- a/spec/lib/gitlab/slash_commands/run_spec.rb
+++ b/spec/lib/gitlab/slash_commands/run_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SlashCommands::Run do
- describe '.available?' do
- it 'returns true when builds are enabled for the project' do
+ describe ".available?" do
+ it "returns true when builds are enabled for the project" do
project = double(:project, builds_enabled?: true)
allow(Gitlab::Chat)
@@ -14,13 +14,13 @@ describe Gitlab::SlashCommands::Run do
expect(described_class.available?(project)).to eq(true)
end
- it 'returns false when builds are disabled for the project' do
+ it "returns false when builds are disabled for the project" do
project = double(:project, builds_enabled?: false)
expect(described_class.available?(project)).to eq(false)
end
- it 'returns false when chatops is not available' do
+ it "returns false when chatops is not available" do
allow(Gitlab::Chat)
.to receive(:available?)
.and_return(false)
@@ -31,14 +31,14 @@ describe Gitlab::SlashCommands::Run do
end
end
- describe '.allowed?' do
- it 'returns true when the user can create a pipeline' do
+ describe ".allowed?" do
+ it "returns true when the user can create a pipeline" do
project = create(:project)
expect(described_class.allowed?(project, project.creator)).to eq(true)
end
- it 'returns false when the user can not create a pipeline' do
+ it "returns false when the user can not create a pipeline" do
project = create(:project)
user = create(:user)
@@ -46,30 +46,30 @@ describe Gitlab::SlashCommands::Run do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:chat_name) { create(:chat_name) }
let(:project) { create(:project) }
let(:command) do
- described_class.new(project, chat_name, response_url: 'http://example.com')
+ described_class.new(project, chat_name, response_url: "http://example.com")
end
- context 'when a pipeline could not be scheduled' do
- it 'returns an error' do
+ context "when a pipeline could not be scheduled" do
+ it "returns an error" do
expect_any_instance_of(Gitlab::Chat::Command)
.to receive(:try_create_pipeline)
.and_return(nil)
expect_any_instance_of(Gitlab::SlashCommands::Presenters::Run)
.to receive(:failed_to_schedule)
- .with('foo')
+ .with("foo")
- command.execute(command: 'foo', arguments: '')
+ command.execute(command: "foo", arguments: "")
end
end
- context 'when a pipeline could be created but the chat service was not supported' do
- it 'returns an error' do
+ context "when a pipeline could be created but the chat service was not supported" do
+ it "returns an error" do
build = double(:build)
pipeline = double(
:pipeline,
@@ -89,13 +89,13 @@ describe Gitlab::SlashCommands::Run do
expect_any_instance_of(Gitlab::SlashCommands::Presenters::Run)
.to receive(:unsupported_chat_service)
- command.execute(command: 'foo', arguments: '')
+ command.execute(command: "foo", arguments: "")
end
end
- context 'using a valid pipeline' do
- it 'schedules the pipeline' do
- responder = double(:responder, scheduled_output: 'hello')
+ context "using a valid pipeline" do
+ it "schedules the pipeline" do
+ responder = double(:responder, scheduled_output: "hello")
build = double(:build)
pipeline = double(
:pipeline,
@@ -116,7 +116,7 @@ describe Gitlab::SlashCommands::Run do
.to receive(:in_channel_response)
.with(responder.scheduled_output)
- command.execute(command: 'foo', arguments: '')
+ command.execute(command: "foo", arguments: "")
end
end
end
diff --git a/spec/lib/gitlab/snippet_search_results_spec.rb b/spec/lib/gitlab/snippet_search_results_spec.rb
index b661a894c0c..976cf59a6df 100644
--- a/spec/lib/gitlab/snippet_search_results_spec.rb
+++ b/spec/lib/gitlab/snippet_search_results_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SnippetSearchResults do
- let!(:snippet) { create(:snippet, content: 'foo', file_name: 'foo') }
+ let!(:snippet) { create(:snippet, content: "foo", file_name: "foo") }
- let(:results) { described_class.new(Snippet.all, 'foo') }
+ let(:results) { described_class.new(Snippet.all, "foo") }
- describe '#snippet_titles_count' do
- it 'returns the amount of matched snippet titles' do
+ describe "#snippet_titles_count" do
+ it "returns the amount of matched snippet titles" do
expect(results.snippet_titles_count).to eq(1)
end
end
- describe '#snippet_blobs_count' do
- it 'returns the amount of matched snippet blobs' do
+ describe "#snippet_blobs_count" do
+ it "returns the amount of matched snippet blobs" do
expect(results.snippet_blobs_count).to eq(1)
end
end
diff --git a/spec/lib/gitlab/sql/cte_spec.rb b/spec/lib/gitlab/sql/cte_spec.rb
index d6763c7b2e1..0eabcbd2b25 100644
--- a/spec/lib/gitlab/sql/cte_spec.rb
+++ b/spec/lib/gitlab/sql/cte_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SQL::CTE, :postgresql do
- describe '#to_arel' do
- it 'generates an Arel relation for the CTE body' do
+ describe "#to_arel" do
+ it "generates an Arel relation for the CTE body" do
relation = User.where(id: 1)
cte = described_class.new(:cte_name, relation)
sql = cte.to_arel.to_sql
name = ActiveRecord::Base.connection.quote_table_name(:cte_name)
- sql1 = ActiveRecord::Base.connection.unprepared_statement do
+ sql1 = ActiveRecord::Base.connection.unprepared_statement {
relation.except(:order).to_sql
- end
+ }
expect(sql).to eq("#{name} AS (#{sql1})")
end
end
- describe '#alias_to' do
- it 'returns an alias for the CTE' do
+ describe "#alias_to" do
+ it "returns an alias for the CTE" do
cte = described_class.new(:cte_name, nil)
table = Arel::Table.new(:kittens)
@@ -28,8 +28,8 @@ describe Gitlab::SQL::CTE, :postgresql do
end
end
- describe '#apply_to' do
- it 'applies a CTE to an ActiveRecord::Relation' do
+ describe "#apply_to" do
+ it "applies a CTE to an ActiveRecord::Relation" do
user = create(:user)
cte = described_class.new(:cte_name, User.where(id: user.id))
diff --git a/spec/lib/gitlab/sql/glob_spec.rb b/spec/lib/gitlab/sql/glob_spec.rb
index 3147b52dcc5..deed311eec1 100644
--- a/spec/lib/gitlab/sql/glob_spec.rb
+++ b/spec/lib/gitlab/sql/glob_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SQL::Glob do
- describe '.to_like' do
- it 'matches * as %' do
- expect(glob('apple', '*')).to be(true)
- expect(glob('apple', 'app*')).to be(true)
- expect(glob('apple', 'apple*')).to be(true)
- expect(glob('apple', '*pple')).to be(true)
- expect(glob('apple', 'ap*le')).to be(true)
-
- expect(glob('apple', '*a')).to be(false)
- expect(glob('apple', 'app*a')).to be(false)
- expect(glob('apple', 'ap*l')).to be(false)
+ describe ".to_like" do
+ it "matches * as %" do
+ expect(glob("apple", "*")).to be(true)
+ expect(glob("apple", "app*")).to be(true)
+ expect(glob("apple", "apple*")).to be(true)
+ expect(glob("apple", "*pple")).to be(true)
+ expect(glob("apple", "ap*le")).to be(true)
+
+ expect(glob("apple", "*a")).to be(false)
+ expect(glob("apple", "app*a")).to be(false)
+ expect(glob("apple", "ap*l")).to be(false)
end
- it 'matches % literally' do
- expect(glob('100%', '100%')).to be(true)
+ it "matches % literally" do
+ expect(glob("100%", "100%")).to be(true)
- expect(glob('100%', '%')).to be(false)
+ expect(glob("100%", "%")).to be(false)
end
- it 'matches _ literally' do
- expect(glob('^_^', '^_^')).to be(true)
+ it "matches _ literally" do
+ expect(glob("^_^", "^_^")).to be(true)
- expect(glob('^A^', '^_^')).to be(false)
+ expect(glob("^A^", "^_^")).to be(false)
end
end
@@ -33,7 +33,7 @@ describe Gitlab::SQL::Glob do
def match(string, pattern)
value = query("SELECT #{quote(string)} LIKE #{pattern}")
- .rows.flatten.first
+ .rows.flatten.first
case value
when true, 1
diff --git a/spec/lib/gitlab/sql/pattern_spec.rb b/spec/lib/gitlab/sql/pattern_spec.rb
index 5b5052de372..35af8966d98 100644
--- a/spec/lib/gitlab/sql/pattern_spec.rb
+++ b/spec/lib/gitlab/sql/pattern_spec.rb
@@ -1,195 +1,195 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SQL::Pattern do
- describe '.to_pattern' do
+ describe ".to_pattern" do
subject(:to_pattern) { User.to_pattern(query) }
- context 'when a query is shorter than 3 chars' do
- let(:query) { '12' }
+ context "when a query is shorter than 3 chars" do
+ let(:query) { "12" }
- it 'returns exact matching pattern' do
- expect(to_pattern).to eq('12')
+ it "returns exact matching pattern" do
+ expect(to_pattern).to eq("12")
end
end
- context 'when a query with a escape character is shorter than 3 chars' do
- let(:query) { '_2' }
+ context "when a query with a escape character is shorter than 3 chars" do
+ let(:query) { "_2" }
- it 'returns sanitized exact matching pattern' do
+ it "returns sanitized exact matching pattern" do
expect(to_pattern).to eq('\_2')
end
end
- context 'when a query is equal to 3 chars' do
- let(:query) { '123' }
+ context "when a query is equal to 3 chars" do
+ let(:query) { "123" }
- it 'returns partial matching pattern' do
- expect(to_pattern).to eq('%123%')
+ it "returns partial matching pattern" do
+ expect(to_pattern).to eq("%123%")
end
end
- context 'when a query with a escape character is equal to 3 chars' do
- let(:query) { '_23' }
+ context "when a query with a escape character is equal to 3 chars" do
+ let(:query) { "_23" }
- it 'returns partial matching pattern' do
+ it "returns partial matching pattern" do
expect(to_pattern).to eq('%\_23%')
end
end
- context 'when a query is longer than 3 chars' do
- let(:query) { '1234' }
+ context "when a query is longer than 3 chars" do
+ let(:query) { "1234" }
- it 'returns partial matching pattern' do
- expect(to_pattern).to eq('%1234%')
+ it "returns partial matching pattern" do
+ expect(to_pattern).to eq("%1234%")
end
end
- context 'when a query with a escape character is longer than 3 chars' do
- let(:query) { '_234' }
+ context "when a query with a escape character is longer than 3 chars" do
+ let(:query) { "_234" }
- it 'returns sanitized partial matching pattern' do
+ it "returns sanitized partial matching pattern" do
expect(to_pattern).to eq('%\_234%')
end
end
end
- describe '.select_fuzzy_words' do
+ describe ".select_fuzzy_words" do
subject(:select_fuzzy_words) { Issue.select_fuzzy_words(query) }
- context 'with a word equal to 3 chars' do
- let(:query) { 'foo' }
+ context "with a word equal to 3 chars" do
+ let(:query) { "foo" }
- it 'returns array cotaining a word' do
- expect(select_fuzzy_words).to match_array(['foo'])
+ it "returns array cotaining a word" do
+ expect(select_fuzzy_words).to match_array(["foo"])
end
end
- context 'with a word shorter than 3 chars' do
- let(:query) { 'fo' }
+ context "with a word shorter than 3 chars" do
+ let(:query) { "fo" }
- it 'returns empty array' do
+ it "returns empty array" do
expect(select_fuzzy_words).to match_array([])
end
end
- context 'with two words both equal to 3 chars' do
- let(:query) { 'foo baz' }
+ context "with two words both equal to 3 chars" do
+ let(:query) { "foo baz" }
- it 'returns array containing two words' do
+ it "returns array containing two words" do
expect(select_fuzzy_words).to match_array(%w[foo baz])
end
end
- context 'with two words divided by two spaces both equal to 3 chars' do
- let(:query) { 'foo baz' }
+ context "with two words divided by two spaces both equal to 3 chars" do
+ let(:query) { "foo baz" }
- it 'returns array containing two words' do
+ it "returns array containing two words" do
expect(select_fuzzy_words).to match_array(%w[foo baz])
end
end
- context 'with two words equal to 3 chars and shorter than 3 chars' do
- let(:query) { 'foo ba' }
+ context "with two words equal to 3 chars and shorter than 3 chars" do
+ let(:query) { "foo ba" }
- it 'returns array containing a word' do
- expect(select_fuzzy_words).to match_array(['foo'])
+ it "returns array containing a word" do
+ expect(select_fuzzy_words).to match_array(["foo"])
end
end
- context 'with a multi-word surrounded by double quote' do
+ context "with a multi-word surrounded by double quote" do
let(:query) { '"really bar"' }
- it 'returns array containing a multi-word' do
- expect(select_fuzzy_words).to match_array(['really bar'])
+ it "returns array containing a multi-word" do
+ expect(select_fuzzy_words).to match_array(["really bar"])
end
end
- context 'with a multi-word surrounded by double quote and two words' do
+ context "with a multi-word surrounded by double quote and two words" do
let(:query) { 'foo "really bar" baz' }
- it 'returns array containing a multi-word and tow words' do
- expect(select_fuzzy_words).to match_array(['foo', 'really bar', 'baz'])
+ it "returns array containing a multi-word and tow words" do
+ expect(select_fuzzy_words).to match_array(["foo", "really bar", "baz"])
end
end
- context 'with a multi-word surrounded by double quote missing a spece before the first double quote' do
+ context "with a multi-word surrounded by double quote missing a spece before the first double quote" do
let(:query) { 'foo"really bar"' }
- it 'returns array containing two words with double quote' do
+ it "returns array containing two words with double quote" do
expect(select_fuzzy_words).to match_array(['foo"really', 'bar"'])
end
end
- context 'with a multi-word surrounded by double quote missing a spece after the second double quote' do
+ context "with a multi-word surrounded by double quote missing a spece after the second double quote" do
let(:query) { '"really bar"baz' }
- it 'returns array containing two words with double quote' do
+ it "returns array containing two words with double quote" do
expect(select_fuzzy_words).to match_array(['"really', 'bar"baz'])
end
end
- context 'with two multi-word surrounded by double quote and two words' do
+ context "with two multi-word surrounded by double quote and two words" do
let(:query) { 'foo "really bar" baz "awesome feature"' }
- it 'returns array containing two multi-words and tow words' do
- expect(select_fuzzy_words).to match_array(['foo', 'really bar', 'baz', 'awesome feature'])
+ it "returns array containing two multi-words and tow words" do
+ expect(select_fuzzy_words).to match_array(["foo", "really bar", "baz", "awesome feature"])
end
end
end
- describe '.fuzzy_arel_match' do
+ describe ".fuzzy_arel_match" do
subject(:fuzzy_arel_match) { Issue.fuzzy_arel_match(:title, query) }
- context 'with a word equal to 3 chars' do
- let(:query) { 'foo' }
+ context "with a word equal to 3 chars" do
+ let(:query) { "foo" }
- it 'returns a single ILIKE condition' do
+ it "returns a single ILIKE condition" do
expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE '\%foo\%'/)
end
end
- context 'with a word shorter than 3 chars' do
- let(:query) { 'fo' }
+ context "with a word shorter than 3 chars" do
+ let(:query) { "fo" }
- it 'returns a single equality condition' do
+ it "returns a single equality condition" do
expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE 'fo'/)
end
- it 'uses LOWER instead of ILIKE when LOWER is enabled' do
+ it "uses LOWER instead of ILIKE when LOWER is enabled" do
rel = Issue.fuzzy_arel_match(:title, query, lower_exact_match: true)
expect(rel.to_sql).to match(/LOWER\(.*title.*\).*=.*'fo'/)
end
end
- context 'with two words both equal to 3 chars' do
- let(:query) { 'foo baz' }
+ context "with two words both equal to 3 chars" do
+ let(:query) { "foo baz" }
- it 'returns a joining LIKE condition using a AND' do
+ it "returns a joining LIKE condition using a AND" do
expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%'/)
end
end
- context 'with two words both shorter than 3 chars' do
- let(:query) { 'fo ba' }
+ context "with two words both shorter than 3 chars" do
+ let(:query) { "fo ba" }
- it 'returns a single ILIKE condition' do
+ it "returns a single ILIKE condition" do
expect(fuzzy_arel_match.to_sql).to match(/title.*I?LIKE 'fo ba'/)
end
end
- context 'with two words, one shorter 3 chars' do
- let(:query) { 'foo ba' }
+ context "with two words, one shorter 3 chars" do
+ let(:query) { "foo ba" }
- it 'returns a single ILIKE condition using the longer word' do
+ it "returns a single ILIKE condition using the longer word" do
expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%'/)
end
end
- context 'with a multi-word surrounded by double quote and two words' do
+ context "with a multi-word surrounded by double quote and two words" do
let(:query) { 'foo "really bar" baz' }
- it 'returns a joining LIKE condition using a AND' do
+ it "returns a joining LIKE condition using a AND" do
expect(fuzzy_arel_match.to_sql).to match(/title.+I?LIKE '\%foo\%' AND .*title.*I?LIKE '\%baz\%' AND .*title.*I?LIKE '\%really bar\%'/)
end
end
diff --git a/spec/lib/gitlab/sql/recursive_cte_spec.rb b/spec/lib/gitlab/sql/recursive_cte_spec.rb
index 7fe39dd5a96..7d56007cfae 100644
--- a/spec/lib/gitlab/sql/recursive_cte_spec.rb
+++ b/spec/lib/gitlab/sql/recursive_cte_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SQL::RecursiveCTE, :postgresql do
let(:cte) { described_class.new(:cte_name) }
- describe '#to_arel' do
- it 'generates an Arel relation for the CTE body' do
+ describe "#to_arel" do
+ it "generates an Arel relation for the CTE body" do
rel1 = User.where(id: 1)
rel2 = User.where(id: 2)
@@ -14,16 +14,16 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do
sql = cte.to_arel.to_sql
name = ActiveRecord::Base.connection.quote_table_name(:cte_name)
- sql1, sql2 = ActiveRecord::Base.connection.unprepared_statement do
+ sql1, sql2 = ActiveRecord::Base.connection.unprepared_statement {
[rel1.except(:order).to_sql, rel2.except(:order).to_sql]
- end
+ }
expect(sql).to eq("#{name} AS (#{sql1}\nUNION\n#{sql2})")
end
end
- describe '#alias_to' do
- it 'returns an alias for the CTE' do
+ describe "#alias_to" do
+ it "returns an alias for the CTE" do
table = Arel::Table.new(:kittens)
source_name = ActiveRecord::Base.connection.quote_table_name(:cte_name)
@@ -32,8 +32,8 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do
expect(cte.alias_to(table).to_sql).to eq("#{source_name} AS #{alias_name}")
end
- it 'replaces dots with an underscore' do
- table = Arel::Table.new('gitlab.kittens')
+ it "replaces dots with an underscore" do
+ table = Arel::Table.new("gitlab.kittens")
source_name = ActiveRecord::Base.connection.quote_table_name(:cte_name)
alias_name = ActiveRecord::Base.connection.quote_table_name(:gitlab_kittens)
@@ -42,8 +42,8 @@ describe Gitlab::SQL::RecursiveCTE, :postgresql do
end
end
- describe '#apply_to' do
- it 'applies a CTE to an ActiveRecord::Relation' do
+ describe "#apply_to" do
+ it "applies a CTE to an ActiveRecord::Relation" do
user = create(:user)
cte = described_class.new(:cte_name)
diff --git a/spec/lib/gitlab/sql/union_spec.rb b/spec/lib/gitlab/sql/union_spec.rb
index fe6422c32b6..49bf120b36a 100644
--- a/spec/lib/gitlab/sql/union_spec.rb
+++ b/spec/lib/gitlab/sql/union_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SQL::Union do
- let(:relation_1) { User.where(email: 'alice@example.com').select(:id) }
- let(:relation_2) { User.where(email: 'bob@example.com').select(:id) }
+ let(:relation_1) { User.where(email: "alice@example.com").select(:id) }
+ let(:relation_2) { User.where(email: "bob@example.com").select(:id) }
def to_sql(relation)
relation.reorder(nil).to_sql
end
- describe '#to_sql' do
- it 'returns a String joining relations together using a UNION' do
+ describe "#to_sql" do
+ it "returns a String joining relations together using a UNION" do
union = described_class.new([relation_1, relation_2])
expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}")
end
- it 'skips Model.none segements' do
+ it "skips Model.none segements" do
empty_relation = User.none
union = described_class.new([empty_relation, relation_1, relation_2])
@@ -23,18 +23,18 @@ describe Gitlab::SQL::Union do
expect(union.to_sql).to eq("#{to_sql(relation_1)}\nUNION\n#{to_sql(relation_2)}")
end
- it 'uses UNION ALL when removing duplicates is disabled' do
+ it "uses UNION ALL when removing duplicates is disabled" do
union = described_class
.new([relation_1, relation_2], remove_duplicates: false)
- expect(union.to_sql).to include('UNION ALL')
+ expect(union.to_sql).to include("UNION ALL")
end
- it 'returns `NULL` if all relations are empty' do
+ it "returns `NULL` if all relations are empty" do
empty_relation = User.none
union = described_class.new([empty_relation, empty_relation])
- expect(union.to_sql).to eq('NULL')
+ expect(union.to_sql).to eq("NULL")
end
end
end
diff --git a/spec/lib/gitlab/ssh_public_key_spec.rb b/spec/lib/gitlab/ssh_public_key_spec.rb
index a6ea07e8b6d..2f1c3e2f7c5 100644
--- a/spec/lib/gitlab/ssh_public_key_spec.rb
+++ b/spec/lib/gitlab/ssh_public_key_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::SSHPublicKey, lib: true do
let(:key) { attributes_for(:rsa_key_2048)[:key] }
let(:public_key) { described_class.new(key) }
- describe '.technology(name)' do
- it 'returns nil for an unrecognised name' do
+ describe ".technology(name)" do
+ it "returns nil for an unrecognised name" do
expect(described_class.technology(:foo)).to be_nil
end
@@ -19,13 +19,13 @@ describe Gitlab::SSHPublicKey, lib: true do
end
end
- describe '.supported_sizes(name)' do
+ describe ".supported_sizes(name)" do
where(:name, :sizes) do
[
[:rsa, [1024, 2048, 3072, 4096]],
[:dsa, [1024, 2048, 3072]],
[:ecdsa, [256, 384, 521]],
- [:ed25519, [256]]
+ [:ed25519, [256]],
]
end
@@ -37,14 +37,14 @@ describe Gitlab::SSHPublicKey, lib: true do
end
end
- describe '.sanitize(key_content)' do
+ describe ".sanitize(key_content)" do
let(:content) { build(:key).key }
- context 'when key has blank space characters' do
- it 'removes the extra blank space characters' do
+ context "when key has blank space characters" do
+ it "removes the extra blank space characters" do
unsanitized = content.insert(100, "\n")
.insert(40, "\r\n")
- .insert(30, ' ')
+ .insert(30, " ")
sanitized = described_class.sanitize(unsanitized)
_, body = sanitized.split
@@ -63,7 +63,7 @@ describe Gitlab::SSHPublicKey, lib: true do
end
context "when key is invalid" do
- it 'returns the original content' do
+ it "returns the original content" do
unsanitized = "ssh-foo any content=="
sanitized = described_class.sanitize(unsanitized)
@@ -72,18 +72,18 @@ describe Gitlab::SSHPublicKey, lib: true do
end
end
- describe '#valid?' do
+ describe "#valid?" do
subject { public_key }
- context 'with a valid SSH key' do
+ context "with a valid SSH key" do
where(:factory) do
- %i(rsa_key_2048
+ %i[rsa_key_2048
rsa_key_4096
rsa_key_5120
rsa_key_8192
dsa_key_2048
ecdsa_key_256
- ed25519_key_256)
+ ed25519_key_256]
end
with_them do
@@ -93,14 +93,14 @@ describe Gitlab::SSHPublicKey, lib: true do
end
end
- context 'with an invalid SSH key' do
- let(:key) { 'this is not a key' }
+ context "with an invalid SSH key" do
+ let(:key) { "this is not a key" }
it { is_expected.not_to be_valid }
end
end
- describe '#type' do
+ describe "#type" do
subject { public_key.type }
where(:factory, :type) do
@@ -108,7 +108,7 @@ describe Gitlab::SSHPublicKey, lib: true do
[:rsa_key_2048, :rsa],
[:dsa_key_2048, :dsa],
[:ecdsa_key_256, :ecdsa],
- [:ed25519_key_256, :ed25519]
+ [:ed25519_key_256, :ed25519],
]
end
@@ -118,14 +118,14 @@ describe Gitlab::SSHPublicKey, lib: true do
it { is_expected.to eq(type) }
end
- context 'with an invalid SSH key' do
- let(:key) { 'this is not a key' }
+ context "with an invalid SSH key" do
+ let(:key) { "this is not a key" }
it { is_expected.to be_nil }
end
end
- describe '#bits' do
+ describe "#bits" do
subject { public_key.bits }
where(:factory, :bits) do
@@ -136,7 +136,7 @@ describe Gitlab::SSHPublicKey, lib: true do
[:rsa_key_8192, 8192],
[:dsa_key_2048, 2048],
[:ecdsa_key_256, 256],
- [:ed25519_key_256, 256]
+ [:ed25519_key_256, 256],
]
end
@@ -146,25 +146,25 @@ describe Gitlab::SSHPublicKey, lib: true do
it { is_expected.to eq(bits) }
end
- context 'with an invalid SSH key' do
- let(:key) { 'this is not a key' }
+ context "with an invalid SSH key" do
+ let(:key) { "this is not a key" }
it { is_expected.to be_nil }
end
end
- describe '#fingerprint' do
+ describe "#fingerprint" do
subject { public_key.fingerprint }
where(:factory, :fingerprint) do
[
- [:rsa_key_2048, '58:a8:9d:cd:1f:70:f8:5a:d9:e4:24:8e:da:89:e4:fc'],
- [:rsa_key_4096, 'df:73:db:29:3c:a5:32:cf:09:17:7e:8e:9d:de:d7:f7'],
- [:rsa_key_5120, 'fe:fa:3a:4d:7d:51:ec:bf:c7:64:0c:96:d0:17:8a:d0'],
- [:rsa_key_8192, 'fb:53:7f:e9:2f:f7:17:aa:c8:32:52:06:8e:05:e2:82'],
- [:dsa_key_2048, 'c8:85:1e:df:44:0f:20:00:3c:66:57:2b:21:10:5a:27'],
- [:ecdsa_key_256, '67:a3:a9:7d:b8:e1:15:d4:80:40:21:34:bb:ed:97:38'],
- [:ed25519_key_256, 'e6:eb:45:8a:3c:59:35:5f:e9:5b:80:12:be:7e:22:73']
+ [:rsa_key_2048, "58:a8:9d:cd:1f:70:f8:5a:d9:e4:24:8e:da:89:e4:fc"],
+ [:rsa_key_4096, "df:73:db:29:3c:a5:32:cf:09:17:7e:8e:9d:de:d7:f7"],
+ [:rsa_key_5120, "fe:fa:3a:4d:7d:51:ec:bf:c7:64:0c:96:d0:17:8a:d0"],
+ [:rsa_key_8192, "fb:53:7f:e9:2f:f7:17:aa:c8:32:52:06:8e:05:e2:82"],
+ [:dsa_key_2048, "c8:85:1e:df:44:0f:20:00:3c:66:57:2b:21:10:5a:27"],
+ [:ecdsa_key_256, "67:a3:a9:7d:b8:e1:15:d4:80:40:21:34:bb:ed:97:38"],
+ [:ed25519_key_256, "e6:eb:45:8a:3c:59:35:5f:e9:5b:80:12:be:7e:22:73"],
]
end
@@ -174,17 +174,17 @@ describe Gitlab::SSHPublicKey, lib: true do
it { is_expected.to eq(fingerprint) }
end
- context 'with an invalid SSH key' do
- let(:key) { 'this is not a key' }
+ context "with an invalid SSH key" do
+ let(:key) { "this is not a key" }
it { is_expected.to be_nil }
end
end
- describe '#key_text' do
- let(:key) { 'this is not a key' }
+ describe "#key_text" do
+ let(:key) { "this is not a key" }
- it 'carries the unmodified key data' do
+ it "carries the unmodified key data" do
expect(public_key.key_text).to eq(key)
end
end
diff --git a/spec/lib/gitlab/string_placeholder_replacer_spec.rb b/spec/lib/gitlab/string_placeholder_replacer_spec.rb
index 7a03ea4154c..19e22a2b80b 100644
--- a/spec/lib/gitlab/string_placeholder_replacer_spec.rb
+++ b/spec/lib/gitlab/string_placeholder_replacer_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::StringPlaceholderReplacer do
- describe '.render_url' do
- it 'returns the nil if the string is blank' do
+ describe ".render_url" do
+ it "returns the nil if the string is blank" do
expect(described_class.replace_string_placeholders(nil, /whatever/)).to be_blank
end
- it 'returns the string if the placeholder regex' do
- expect(described_class.replace_string_placeholders('whatever')).to eq 'whatever'
+ it "returns the string if the placeholder regex" do
+ expect(described_class.replace_string_placeholders("whatever")).to eq "whatever"
end
- it 'returns the string if no block given' do
- expect(described_class.replace_string_placeholders('whatever', /whatever/)).to eq 'whatever'
+ it "returns the string if no block given" do
+ expect(described_class.replace_string_placeholders("whatever", /whatever/)).to eq "whatever"
end
- context 'when all params are valid' do
- let(:string) { '%{path}/%{id}/%{branch}' }
+ context "when all params are valid" do
+ let(:string) { "%{path}/%{id}/%{branch}" }
let(:regex) { /(path|id)/ }
- it 'replaces each placeholders with the block result' do
- result = described_class.replace_string_placeholders(string, regex) do |arg|
- 'WHATEVER'
- end
+ it "replaces each placeholders with the block result" do
+ result = described_class.replace_string_placeholders(string, regex) { |arg|
+ "WHATEVER"
+ }
- expect(result).to eq 'WHATEVER/WHATEVER/%{branch}'
+ expect(result).to eq "WHATEVER/WHATEVER/%{branch}"
end
- it 'does not replace the placeholder if the block result is nil' do
- result = described_class.replace_string_placeholders(string, regex) do |arg|
- arg == 'path' ? nil : 'WHATEVER'
- end
+ it "does not replace the placeholder if the block result is nil" do
+ result = described_class.replace_string_placeholders(string, regex) { |arg|
+ arg == "path" ? nil : "WHATEVER"
+ }
- expect(result).to eq '%{path}/WHATEVER/%{branch}'
+ expect(result).to eq "%{path}/WHATEVER/%{branch}"
end
end
end
diff --git a/spec/lib/gitlab/string_range_marker_spec.rb b/spec/lib/gitlab/string_range_marker_spec.rb
index 6bc02459dbd..cd61af6462e 100644
--- a/spec/lib/gitlab/string_range_marker_spec.rb
+++ b/spec/lib/gitlab/string_range_marker_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::StringRangeMarker do
- describe '#mark' do
+ describe "#mark" do
def mark_diff(rich = nil)
- raw = 'abc <def>'
+ raw = "abc <def>"
inline_diffs = [2..5]
described_class.new(raw, rich).mark(inline_diffs) do |text, left:, right:|
@@ -12,27 +12,27 @@ describe Gitlab::StringRangeMarker do
end
context "when the rich text is html safe" do
- let(:rich) { %{<span class="abc">abc</span><span class="space"> </span><span class="def">&lt;def&gt;</span>}.html_safe }
+ let(:rich) { %(<span class="abc">abc</span><span class="space"> </span><span class="def">&lt;def&gt;</span>).html_safe }
- it 'marks the inline diffs' do
- expect(mark_diff(rich)).to eq(%{<span class="abc">abLEFTcRIGHT</span><span class="space">LEFT RIGHT</span><span class="def">LEFT&lt;dRIGHTef&gt;</span>})
+ it "marks the inline diffs" do
+ expect(mark_diff(rich)).to eq(%(<span class="abc">abLEFTcRIGHT</span><span class="space">LEFT RIGHT</span><span class="def">LEFT&lt;dRIGHTef&gt;</span>))
expect(mark_diff(rich)).to be_html_safe
end
end
context "when the rich text is not html safe" do
- context 'when rich text equals raw text' do
- it 'marks the inline diffs' do
- expect(mark_diff).to eq(%{abLEFTc <dRIGHTef>})
+ context "when rich text equals raw text" do
+ it "marks the inline diffs" do
+ expect(mark_diff).to eq(%(abLEFTc <dRIGHTef>))
expect(mark_diff).not_to be_html_safe
end
end
- context 'when rich text doeas not equal raw text' do
+ context "when rich text doeas not equal raw text" do
let(:rich) { "abc <def> differs" }
- it 'marks the inline diffs' do
- expect(mark_diff(rich)).to eq(%{abLEFTc &lt;dRIGHTef&gt; differs})
+ it "marks the inline diffs" do
+ expect(mark_diff(rich)).to eq(%(abLEFTc &lt;dRIGHTef&gt; differs))
expect(mark_diff(rich)).to be_html_safe
end
end
diff --git a/spec/lib/gitlab/string_regex_marker_spec.rb b/spec/lib/gitlab/string_regex_marker_spec.rb
index 37b1298b962..07f5595b5bd 100644
--- a/spec/lib/gitlab/string_regex_marker_spec.rb
+++ b/spec/lib/gitlab/string_regex_marker_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::StringRegexMarker do
- describe '#mark' do
- context 'with a single occurrence' do
- let(:raw) { %{"name": "AFNetworking"} }
- let(:rich) { %{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>}.html_safe }
+ describe "#mark" do
+ context "with a single occurrence" do
+ let(:raw) { %("name": "AFNetworking") }
+ let(:rich) { %(<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"AFNetworking"</span>).html_safe }
subject do
described_class.new(raw, rich).mark(/"[^"]+":\s*"(?<name>[^"]+)"/, group: :name) do |text, left:, right:|
- %{<a href="#">#{text}</a>}
+ %(<a href="#">#{text}</a>)
end
end
- it 'marks the match' do
- expect(subject).to eq(%{<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"<a href="#">AFNetworking</a>"</span>})
+ it "marks the match" do
+ expect(subject).to eq(%(<span class="key">"name"</span><span class="punctuation">: </span><span class="value">"<a href="#">AFNetworking</a>"</span>))
expect(subject).to be_html_safe
end
end
- context 'with multiple occurrences' do
- let(:raw) { %{a <b> <c> d} }
- let(:rich) { %{a &lt;b&gt; &lt;c&gt; d}.html_safe }
+ context "with multiple occurrences" do
+ let(:raw) { %(a <b> <c> d) }
+ let(:rich) { %(a &lt;b&gt; &lt;c&gt; d).html_safe }
subject do
described_class.new(raw, rich).mark(/<[a-z]>/) do |text, left:, right:|
- %{<strong>#{text}</strong>}
+ %(<strong>#{text}</strong>)
end
end
- it 'marks the matches' do
- expect(subject).to eq(%{a <strong>&lt;b&gt;</strong> <strong>&lt;c&gt;</strong> d})
+ it "marks the matches" do
+ expect(subject).to eq(%(a <strong>&lt;b&gt;</strong> <strong>&lt;c&gt;</strong> d))
expect(subject).to be_html_safe
end
end
diff --git a/spec/lib/gitlab/tcp_checker_spec.rb b/spec/lib/gitlab/tcp_checker_spec.rb
index 4acf0334496..732786dd8f8 100644
--- a/spec/lib/gitlab/tcp_checker_spec.rb
+++ b/spec/lib/gitlab/tcp_checker_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::TcpChecker do
before do
- @server = TCPServer.new('localhost', 0)
+ @server = TCPServer.new("localhost", 0)
_, @port, _, @ip = @server.addr
end
@@ -12,16 +12,16 @@ describe Gitlab::TcpChecker do
subject(:checker) { described_class.new(@ip, @port) }
- describe '#check' do
+ describe "#check" do
subject { checker.check }
- it 'can connect to an open port' do
+ it "can connect to an open port" do
is_expected.to be_truthy
expect(checker.error).to be_nil
end
- it 'fails to connect to a closed port' do
+ it "fails to connect to a closed port" do
@server.close
is_expected.to be_falsy
diff --git a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
index c7f58fbd2a5..292a47de871 100644
--- a/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
+++ b/spec/lib/gitlab/template/finders/global_template_finder_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::Finders::GlobalTemplateFinder do
let(:base_dir) { Dir.mktmpdir }
@@ -13,23 +13,23 @@ describe Gitlab::Template::Finders::GlobalTemplateFinder do
FileUtils.rm_rf(base_dir)
end
- subject(:finder) { described_class.new(base_dir, '', 'Foo' => '', 'Bar' => 'bar') }
+ subject(:finder) { described_class.new(base_dir, "", "Foo" => "", "Bar" => "bar") }
- describe '.find' do
- it 'finds a template in the Foo category' do
- create_template!('test-template')
+ describe ".find" do
+ it "finds a template in the Foo category" do
+ create_template!("test-template")
- expect(finder.find('test-template')).to be_present
+ expect(finder.find("test-template")).to be_present
end
- it 'finds a template in the Bar category' do
- create_template!('bar/test-template')
+ it "finds a template in the Bar category" do
+ create_template!("bar/test-template")
- expect(finder.find('test-template')).to be_present
+ expect(finder.find("test-template")).to be_present
end
- it 'does not permit path traversal requests' do
- expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ it "does not permit path traversal requests" do
+ expect { finder.find("../foo") }.to raise_error(/Invalid path/)
end
end
end
diff --git a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
index e329d55d837..e4a523700f4 100644
--- a/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
+++ b/spec/lib/gitlab/template/finders/repo_template_finders_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::Finders::RepoTemplateFinder do
set(:project) { create(:project, :repository) }
- let(:categories) { { 'HTML' => 'html' } }
+ let(:categories) { {"HTML" => "html"} }
- subject(:finder) { described_class.new(project, 'files/', '.html', categories) }
+ subject(:finder) { described_class.new(project, "files/", ".html", categories) }
- describe '#read' do
- it 'returns the content of the given path' do
- result = finder.read('files/html/500.html')
+ describe "#read" do
+ it "returns the content of the given path" do
+ result = finder.read("files/html/500.html")
expect(result).to be_present
end
- it 'raises an error if the path does not exist' do
- expect { finder.read('does/not/exist') }.to raise_error(described_class::FileNotFoundError)
+ it "raises an error if the path does not exist" do
+ expect { finder.read("does/not/exist") }.to raise_error(described_class::FileNotFoundError)
end
end
- describe '#find' do
- it 'returns the full path of the found template' do
- result = finder.find('500')
+ describe "#find" do
+ it "returns the full path of the found template" do
+ result = finder.find("500")
- expect(result).to eq('files/html/500.html')
+ expect(result).to eq("files/html/500.html")
end
- it 'does not permit path traversal requests' do
- expect { finder.find('../foo') }.to raise_error(/Invalid path/)
+ it "does not permit path traversal requests" do
+ expect { finder.find("../foo") }.to raise_error(/Invalid path/)
end
end
- describe '#list_files_for' do
- it 'returns the full path of the found files' do
- result = finder.list_files_for('files/html')
+ describe "#list_files_for" do
+ it "returns the full path of the found files" do
+ result = finder.list_files_for("files/html")
- expect(result).to contain_exactly('files/html/500.html')
+ expect(result).to contain_exactly("files/html/500.html")
end
end
end
diff --git a/spec/lib/gitlab/template/gitignore_template_spec.rb b/spec/lib/gitlab/template/gitignore_template_spec.rb
index 97797f42aaa..e94f5e38694 100644
--- a/spec/lib/gitlab/template/gitignore_template_spec.rb
+++ b/spec/lib/gitlab/template/gitignore_template_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::GitignoreTemplate do
subject { described_class }
- describe '.all' do
- it 'strips the gitignore suffix' do
- expect(subject.all.first.name).not_to end_with('.gitignore')
+ describe ".all" do
+ it "strips the gitignore suffix" do
+ expect(subject.all.first.name).not_to end_with(".gitignore")
end
- it 'combines the globals and rest' do
+ it "combines the globals and rest" do
all = subject.all.map(&:name)
- expect(all).to include('Vim')
- expect(all).to include('Ruby')
+ expect(all).to include("Vim")
+ expect(all).to include("Ruby")
end
end
- describe '.find' do
- it 'returns nil if the file does not exist' do
- expect(subject.find('mepmep-yadida')).to be nil
+ describe ".find" do
+ it "returns nil if the file does not exist" do
+ expect(subject.find("mepmep-yadida")).to be nil
end
- it 'returns the Gitignore object of a valid file' do
- ruby = subject.find('Ruby')
+ it "returns the Gitignore object of a valid file" do
+ ruby = subject.find("Ruby")
expect(ruby).to be_a described_class
- expect(ruby.name).to eq('Ruby')
+ expect(ruby.name).to eq("Ruby")
end
end
- describe '#content' do
- it 'loads the full file' do
- gitignore = subject.new(Rails.root.join('vendor/gitignore/Ruby.gitignore'))
+ describe "#content" do
+ it "loads the full file" do
+ gitignore = subject.new(Rails.root.join("vendor/gitignore/Ruby.gitignore"))
- expect(gitignore.name).to eq 'Ruby'
- expect(gitignore.content).to start_with('*.gem')
+ expect(gitignore.name).to eq "Ruby"
+ expect(gitignore.content).to start_with("*.gem")
end
end
end
diff --git a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
index fe46c67a920..ab03a059723 100644
--- a/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
+++ b/spec/lib/gitlab/template/gitlab_ci_yml_template_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::GitlabCiYmlTemplate do
subject { described_class }
- describe '.all' do
- it 'strips the gitlab-ci suffix' do
- expect(subject.all.first.name).not_to end_with('.gitlab-ci.yml')
+ describe ".all" do
+ it "strips the gitlab-ci suffix" do
+ expect(subject.all.first.name).not_to end_with(".gitlab-ci.yml")
end
- it 'combines the globals and rest' do
+ it "combines the globals and rest" do
all = subject.all.map(&:name)
- expect(all).to include('Elixir')
- expect(all).to include('Docker')
- expect(all).to include('Ruby')
+ expect(all).to include("Elixir")
+ expect(all).to include("Docker")
+ expect(all).to include("Ruby")
end
end
- describe '.find' do
- it 'returns nil if the file does not exist' do
- expect(subject.find('mepmep-yadida')).to be nil
+ describe ".find" do
+ it "returns nil if the file does not exist" do
+ expect(subject.find("mepmep-yadida")).to be nil
end
- it 'returns the GitlabCiYml object of a valid file' do
- ruby = subject.find('Ruby')
+ it "returns the GitlabCiYml object of a valid file" do
+ ruby = subject.find("Ruby")
expect(ruby).to be_a described_class
- expect(ruby.name).to eq('Ruby')
+ expect(ruby.name).to eq("Ruby")
end
end
- describe '.by_category' do
- it 'returns sorted results' do
- result = described_class.by_category('General')
+ describe ".by_category" do
+ it "returns sorted results" do
+ result = described_class.by_category("General")
expect(result).to eq(result.sort)
end
end
- describe '#content' do
- it 'loads the full file' do
- gitignore = subject.new(Rails.root.join('lib/gitlab/ci/templates/Ruby.gitlab-ci.yml'))
+ describe "#content" do
+ it "loads the full file" do
+ gitignore = subject.new(Rails.root.join("lib/gitlab/ci/templates/Ruby.gitlab-ci.yml"))
- expect(gitignore.name).to eq 'Ruby'
- expect(gitignore.content).to start_with('#')
+ expect(gitignore.name).to eq "Ruby"
+ expect(gitignore.content).to start_with("#")
end
end
- describe '#<=>' do
- it 'sorts lexicographically' do
- one = described_class.new('a.gitlab-ci.yml')
- other = described_class.new('z.gitlab-ci.yml')
+ describe "#<=>" do
+ it "sorts lexicographically" do
+ one = described_class.new("a.gitlab-ci.yml")
+ other = described_class.new("z.gitlab-ci.yml")
expect(one.<=>(other)).to be(-1)
expect([other, one].sort).to eq([one, other])
diff --git a/spec/lib/gitlab/template/issue_template_spec.rb b/spec/lib/gitlab/template/issue_template_spec.rb
index 7098499f996..c7c850c2f96 100644
--- a/spec/lib/gitlab/template/issue_template_spec.rb
+++ b/spec/lib/gitlab/template/issue_template_spec.rb
@@ -1,62 +1,62 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::IssueTemplate do
let(:project) { create(:project, :repository, create_templates: :issue) }
- describe '.all' do
- it 'strips the md suffix' do
- expect(described_class.all(project).first.name).not_to end_with('.issue_template')
+ describe ".all" do
+ it "strips the md suffix" do
+ expect(described_class.all(project).first.name).not_to end_with(".issue_template")
end
- it 'combines the globals and rest' do
+ it "combines the globals and rest" do
all = described_class.all(project).map(&:name)
- expect(all).to include('bug')
- expect(all).to include('feature_proposal')
+ expect(all).to include("bug")
+ expect(all).to include("feature_proposal")
end
end
- describe '.find' do
- it 'returns nil if the file does not exist' do
- expect { described_class.find('mepmep-yadida', project) }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
+ describe ".find" do
+ it "returns nil if the file does not exist" do
+ expect { described_class.find("mepmep-yadida", project) }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
- it 'returns the issue object of a valid file' do
- ruby = described_class.find('bug', project)
+ it "returns the issue object of a valid file" do
+ ruby = described_class.find("bug", project)
expect(ruby).to be_a described_class
- expect(ruby.name).to eq('bug')
+ expect(ruby.name).to eq("bug")
end
end
- describe '.by_category' do
- it 'return array of templates' do
- all = described_class.by_category('', project).map(&:name)
- expect(all).to include('bug')
- expect(all).to include('feature_proposal')
+ describe ".by_category" do
+ it "return array of templates" do
+ all = described_class.by_category("", project).map(&:name)
+ expect(all).to include("bug")
+ expect(all).to include("feature_proposal")
end
- context 'when repo is bare or empty' do
+ context "when repo is bare or empty" do
let(:empty_project) { create(:project) }
it "returns empty array" do
- templates = described_class.by_category('', empty_project)
+ templates = described_class.by_category("", empty_project)
expect(templates).to be_empty
end
end
end
- describe '#content' do
- it 'loads the full file' do
- issue_template = described_class.new('.gitlab/issue_templates/bug.md', project)
+ describe "#content" do
+ it "loads the full file" do
+ issue_template = described_class.new(".gitlab/issue_templates/bug.md", project)
- expect(issue_template.name).to eq 'bug'
- expect(issue_template.content).to eq('something valid')
+ expect(issue_template.name).to eq "bug"
+ expect(issue_template.content).to eq("something valid")
end
- it 'raises error when file is not found' do
- issue_template = described_class.new('.gitlab/issue_templates/bugnot.md', project)
+ it "raises error when file is not found" do
+ issue_template = described_class.new(".gitlab/issue_templates/bugnot.md", project)
expect { issue_template.content }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
@@ -64,7 +64,7 @@ describe Gitlab::Template::IssueTemplate do
let(:empty_project) { create(:project) }
it "raises file not found" do
- issue_template = described_class.new('.gitlab/issue_templates/not_existent.md', empty_project)
+ issue_template = described_class.new(".gitlab/issue_templates/not_existent.md", empty_project)
expect { issue_template.content }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
diff --git a/spec/lib/gitlab/template/merge_request_template_spec.rb b/spec/lib/gitlab/template/merge_request_template_spec.rb
index bd7ff64aa8a..85de0bc0a1b 100644
--- a/spec/lib/gitlab/template/merge_request_template_spec.rb
+++ b/spec/lib/gitlab/template/merge_request_template_spec.rb
@@ -1,62 +1,62 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Template::MergeRequestTemplate do
let(:project) { create(:project, :repository, create_templates: :merge_request) }
- describe '.all' do
- it 'strips the md suffix' do
- expect(described_class.all(project).first.name).not_to end_with('.issue_template')
+ describe ".all" do
+ it "strips the md suffix" do
+ expect(described_class.all(project).first.name).not_to end_with(".issue_template")
end
- it 'combines the globals and rest' do
+ it "combines the globals and rest" do
all = described_class.all(project).map(&:name)
- expect(all).to include('bug')
- expect(all).to include('feature_proposal')
+ expect(all).to include("bug")
+ expect(all).to include("feature_proposal")
end
end
- describe '.find' do
- it 'returns nil if the file does not exist' do
- expect { described_class.find('mepmep-yadida', project) }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
+ describe ".find" do
+ it "returns nil if the file does not exist" do
+ expect { described_class.find("mepmep-yadida", project) }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
- it 'returns the merge request object of a valid file' do
- ruby = described_class.find('bug', project)
+ it "returns the merge request object of a valid file" do
+ ruby = described_class.find("bug", project)
expect(ruby).to be_a described_class
- expect(ruby.name).to eq('bug')
+ expect(ruby.name).to eq("bug")
end
end
- describe '.by_category' do
- it 'return array of templates' do
- all = described_class.by_category('', project).map(&:name)
- expect(all).to include('bug')
- expect(all).to include('feature_proposal')
+ describe ".by_category" do
+ it "return array of templates" do
+ all = described_class.by_category("", project).map(&:name)
+ expect(all).to include("bug")
+ expect(all).to include("feature_proposal")
end
- context 'when repo is bare or empty' do
+ context "when repo is bare or empty" do
let(:empty_project) { create(:project) }
it "returns empty array" do
- templates = described_class.by_category('', empty_project)
+ templates = described_class.by_category("", empty_project)
expect(templates).to be_empty
end
end
end
- describe '#content' do
- it 'loads the full file' do
- issue_template = described_class.new('.gitlab/merge_request_templates/bug.md', project)
+ describe "#content" do
+ it "loads the full file" do
+ issue_template = described_class.new(".gitlab/merge_request_templates/bug.md", project)
- expect(issue_template.name).to eq 'bug'
- expect(issue_template.content).to eq('something valid')
+ expect(issue_template.name).to eq "bug"
+ expect(issue_template.content).to eq("something valid")
end
- it 'raises error when file is not found' do
- issue_template = described_class.new('.gitlab/merge_request_templates/bugnot.md', project)
+ it "raises error when file is not found" do
+ issue_template = described_class.new(".gitlab/merge_request_templates/bugnot.md", project)
expect { issue_template.content }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
@@ -64,7 +64,7 @@ describe Gitlab::Template::MergeRequestTemplate do
let(:empty_project) { create(:project) }
it "raises file not found" do
- issue_template = described_class.new('.gitlab/merge_request_templates/not_existent.md', empty_project)
+ issue_template = described_class.new(".gitlab/merge_request_templates/not_existent.md", empty_project)
expect { issue_template.content }.to raise_error(Gitlab::Template::Finders::RepoTemplateFinder::FileNotFoundError)
end
diff --git a/spec/lib/gitlab/themes_spec.rb b/spec/lib/gitlab/themes_spec.rb
index a8213988f70..313dc8afd40 100644
--- a/spec/lib/gitlab/themes_spec.rb
+++ b/spec/lib/gitlab/themes_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Themes, lib: true do
- describe '.body_classes' do
- it 'returns a space-separated list of class names' do
+ describe ".body_classes" do
+ it "returns a space-separated list of class names" do
css = described_class.body_classes
- expect(css).to include('ui-indigo')
- expect(css).to include('ui-dark')
- expect(css).to include('ui-blue')
+ expect(css).to include("ui-indigo")
+ expect(css).to include("ui-dark")
+ expect(css).to include("ui-blue")
end
end
- describe '.by_id' do
- it 'returns a Theme by its ID' do
- expect(described_class.by_id(1).name).to eq 'Indigo'
- expect(described_class.by_id(3).name).to eq 'Light'
+ describe ".by_id" do
+ it "returns a Theme by its ID" do
+ expect(described_class.by_id(1).name).to eq "Indigo"
+ expect(described_class.by_id(3).name).to eq "Light"
end
end
- describe '.default' do
- it 'returns the default application theme' do
+ describe ".default" do
+ it "returns the default application theme" do
allow(described_class).to receive(:default_id).and_return(2)
expect(described_class.default.id).to eq 2
end
- it 'prevents an infinite loop when configuration default is invalid' do
+ it "prevents an infinite loop when configuration default is invalid" do
default = described_class::APPLICATION_DEFAULT
themes = described_class::THEMES
@@ -38,8 +38,8 @@ describe Gitlab::Themes, lib: true do
end
end
- describe '.each' do
- it 'passes the block to the THEMES Array' do
+ describe ".each" do
+ it "passes the block to the THEMES Array" do
ids = []
described_class.each { |theme| ids << theme.id }
expect(ids).not_to be_empty
diff --git a/spec/lib/gitlab/tracing/factory_spec.rb b/spec/lib/gitlab/tracing/factory_spec.rb
index 945490f0988..4fe84cf0eba 100644
--- a/spec/lib/gitlab/tracing/factory_spec.rb
+++ b/spec/lib/gitlab/tracing/factory_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Tracing::Factory do
- describe '.create_tracer' do
- let(:service_name) { 'rspec' }
+ describe ".create_tracer" do
+ let(:service_name) { "rspec" }
context "when tracing is not configured" do
- it 'ignores null connection strings' do
+ it "ignores null connection strings" do
expect(described_class.create_tracer(service_name, nil)).to be_nil
end
- it 'ignores empty connection strings' do
- expect(described_class.create_tracer(service_name, '')).to be_nil
+ it "ignores empty connection strings" do
+ expect(described_class.create_tracer(service_name, "")).to be_nil
end
- it 'ignores unknown implementations' do
- expect(described_class.create_tracer(service_name, 'opentracing://invalid_driver')).to be_nil
+ it "ignores unknown implementations" do
+ expect(described_class.create_tracer(service_name, "opentracing://invalid_driver")).to be_nil
end
- it 'ignores invalid connection strings' do
- expect(described_class.create_tracer(service_name, 'open?tracing')).to be_nil
+ it "ignores invalid connection strings" do
+ expect(described_class.create_tracer(service_name, "open?tracing")).to be_nil
end
end
context "when tracing is configured with jaeger" do
- let(:mock_tracer) { double('tracer') }
+ let(:mock_tracer) { double("tracer") }
- it 'processes default connections' do
+ it "processes default connections" do
expect(Gitlab::Tracing::JaegerFactory).to receive(:create_tracer).with(service_name, {}).and_return(mock_tracer)
- expect(described_class.create_tracer(service_name, 'opentracing://jaeger')).to be(mock_tracer)
+ expect(described_class.create_tracer(service_name, "opentracing://jaeger")).to be(mock_tracer)
end
- it 'processes connections with parameters' do
- expect(Gitlab::Tracing::JaegerFactory).to receive(:create_tracer).with(service_name, { a: '1', b: '2', c: '3' }).and_return(mock_tracer)
+ it "processes connections with parameters" do
+ expect(Gitlab::Tracing::JaegerFactory).to receive(:create_tracer).with(service_name, {a: "1", b: "2", c: "3"}).and_return(mock_tracer)
- expect(described_class.create_tracer(service_name, 'opentracing://jaeger?a=1&b=2&c=3')).to be(mock_tracer)
+ expect(described_class.create_tracer(service_name, "opentracing://jaeger?a=1&b=2&c=3")).to be(mock_tracer)
end
end
end
diff --git a/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb b/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb
index 7f5aecb7baa..10c615fc3a0 100644
--- a/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb
+++ b/spec/lib/gitlab/tracing/grpc_interceptor_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Tracing::GRPCInterceptor do
subject { described_class.instance }
@@ -8,40 +8,40 @@ describe Gitlab::Tracing::GRPCInterceptor do
shared_examples_for "a grpc interceptor method" do
let(:custom_error) { Class.new(StandardError) }
- it 'yields' do
+ it "yields" do
expect { |b| method.call(kwargs, &b) }.to yield_control
end
- it 'propagates exceptions' do
+ it "propagates exceptions" do
expect { method.call(kwargs) { raise custom_error } }.to raise_error(custom_error)
end
end
- describe '#request_response' do
+ describe "#request_response" do
let(:method) { subject.method(:request_response) }
- let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } }
+ let(:kwargs) { {request: {}, call: {}, method: "grc_method", metadata: {}} }
- it_behaves_like 'a grpc interceptor method'
+ it_behaves_like "a grpc interceptor method"
end
- describe '#client_streamer' do
+ describe "#client_streamer" do
let(:method) { subject.method(:client_streamer) }
- let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } }
+ let(:kwargs) { {requests: [], call: {}, method: "grc_method", metadata: {}} }
- it_behaves_like 'a grpc interceptor method'
+ it_behaves_like "a grpc interceptor method"
end
- describe '#server_streamer' do
+ describe "#server_streamer" do
let(:method) { subject.method(:server_streamer) }
- let(:kwargs) { { request: {}, call: {}, method: 'grc_method', metadata: {} } }
+ let(:kwargs) { {request: {}, call: {}, method: "grc_method", metadata: {}} }
- it_behaves_like 'a grpc interceptor method'
+ it_behaves_like "a grpc interceptor method"
end
- describe '#bidi_streamer' do
+ describe "#bidi_streamer" do
let(:method) { subject.method(:bidi_streamer) }
- let(:kwargs) { { requests: [], call: {}, method: 'grc_method', metadata: {} } }
+ let(:kwargs) { {requests: [], call: {}, method: "grc_method", metadata: {}} }
- it_behaves_like 'a grpc interceptor method'
+ it_behaves_like "a grpc interceptor method"
end
end
diff --git a/spec/lib/gitlab/tracing/jaeger_factory_spec.rb b/spec/lib/gitlab/tracing/jaeger_factory_spec.rb
index 3d6a007cfd9..7f0d381f326 100644
--- a/spec/lib/gitlab/tracing/jaeger_factory_spec.rb
+++ b/spec/lib/gitlab/tracing/jaeger_factory_spec.rb
@@ -1,71 +1,71 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Tracing::JaegerFactory do
- describe '.create_tracer' do
- let(:service_name) { 'rspec' }
+ describe ".create_tracer" do
+ let(:service_name) { "rspec" }
- shared_examples_for 'a jaeger tracer' do
- it 'responds to active_span methods' do
+ shared_examples_for "a jaeger tracer" do
+ it "responds to active_span methods" do
expect(tracer).to respond_to(:active_span)
end
- it 'yields control' do
- expect { |b| tracer.start_active_span('operation_name', &b) }.to yield_control
+ it "yields control" do
+ expect { |b| tracer.start_active_span("operation_name", &b) }.to yield_control
end
end
- context 'processes default connections' do
- it_behaves_like 'a jaeger tracer' do
+ context "processes default connections" do
+ it_behaves_like "a jaeger tracer" do
let(:tracer) { described_class.create_tracer(service_name, {}) }
end
end
- context 'handles debug options' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { debug: "1" }) }
+ context "handles debug options" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {debug: "1"}) }
end
end
- context 'handles const sampler' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { sampler: "const", sampler_param: "1" }) }
+ context "handles const sampler" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {sampler: "const", sampler_param: "1"}) }
end
end
- context 'handles probabilistic sampler' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { sampler: "probabilistic", sampler_param: "0.5" }) }
+ context "handles probabilistic sampler" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {sampler: "probabilistic", sampler_param: "0.5"}) }
end
end
- context 'handles http_endpoint configurations' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { http_endpoint: "http://localhost:1234" }) }
+ context "handles http_endpoint configurations" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {http_endpoint: "http://localhost:1234"}) }
end
end
- context 'handles udp_endpoint configurations' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { udp_endpoint: "localhost:4321" }) }
+ context "handles udp_endpoint configurations" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {udp_endpoint: "localhost:4321"}) }
end
end
- context 'ignores invalid parameters' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { invalid: "true" }) }
+ context "ignores invalid parameters" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {invalid: "true"}) }
end
end
- context 'accepts the debug parameter when strict_parser is set' do
- it_behaves_like 'a jaeger tracer' do
- let(:tracer) { described_class.create_tracer(service_name, { debug: "1", strict_parsing: "1" }) }
+ context "accepts the debug parameter when strict_parser is set" do
+ it_behaves_like "a jaeger tracer" do
+ let(:tracer) { described_class.create_tracer(service_name, {debug: "1", strict_parsing: "1"}) }
end
end
- it 'rejects invalid parameters when strict_parser is set' do
- expect { described_class.create_tracer(service_name, { invalid: "true", strict_parsing: "1" }) }.to raise_error(StandardError)
+ it "rejects invalid parameters when strict_parser is set" do
+ expect { described_class.create_tracer(service_name, {invalid: "true", strict_parsing: "1"}) }.to raise_error(StandardError)
end
end
end
diff --git a/spec/lib/gitlab/tracing/rack_middleware_spec.rb b/spec/lib/gitlab/tracing/rack_middleware_spec.rb
index 13d4d8a89f7..0184755f7fc 100644
--- a/spec/lib/gitlab/tracing/rack_middleware_spec.rb
+++ b/spec/lib/gitlab/tracing/rack_middleware_spec.rb
@@ -1,58 +1,58 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Tracing::RackMiddleware do
using RSpec::Parameterized::TableSyntax
- describe '#call' do
- context 'for normal middleware flow' do
- let(:fake_app) { -> (env) { fake_app_response } }
+ describe "#call" do
+ context "for normal middleware flow" do
+ let(:fake_app) { ->(env) { fake_app_response } }
subject { described_class.new(fake_app) }
let(:request) { }
- context 'for 200 responses' do
- let(:fake_app_response) { [200, { 'Content-Type': 'text/plain' }, ['OK']] }
+ context "for 200 responses" do
+ let(:fake_app_response) { [200, {'Content-Type': "text/plain"}, ["OK"]] }
- it 'delegates correctly' do
+ it "delegates correctly" do
expect(subject.call(Rack::MockRequest.env_for("/"))).to eq(fake_app_response)
end
end
- context 'for 500 responses' do
- let(:fake_app_response) { [500, { 'Content-Type': 'text/plain' }, ['Error']] }
+ context "for 500 responses" do
+ let(:fake_app_response) { [500, {'Content-Type': "text/plain"}, ["Error"]] }
- it 'delegates correctly' do
+ it "delegates correctly" do
expect(subject.call(Rack::MockRequest.env_for("/"))).to eq(fake_app_response)
end
end
end
- context 'when an application is raising an exception' do
+ context "when an application is raising an exception" do
let(:custom_error) { Class.new(StandardError) }
let(:fake_app) { ->(env) { raise custom_error } }
subject { described_class.new(fake_app) }
- it 'delegates propagates exceptions correctly' do
+ it "delegates propagates exceptions correctly" do
expect { subject.call(Rack::MockRequest.env_for("/")) }.to raise_error(custom_error)
end
end
end
- describe '.build_sanitized_url_from_env' do
+ describe ".build_sanitized_url_from_env" do
def env_for_url(url)
env = Rack::MockRequest.env_for(input_url)
- env['action_dispatch.parameter_filter'] = [/token/]
+ env["action_dispatch.parameter_filter"] = [/token/]
env
end
where(:input_url, :output_url) do
- '/gitlab-org/gitlab-ce' | 'http://example.org/gitlab-org/gitlab-ce'
- '/gitlab-org/gitlab-ce?safe=1' | 'http://example.org/gitlab-org/gitlab-ce?safe=1'
- '/gitlab-org/gitlab-ce?private_token=secret' | 'http://example.org/gitlab-org/gitlab-ce?private_token=%5BFILTERED%5D'
- '/gitlab-org/gitlab-ce?mixed=1&private_token=secret' | 'http://example.org/gitlab-org/gitlab-ce?mixed=1&private_token=%5BFILTERED%5D'
+ "/gitlab-org/gitlab-ce" | "http://example.org/gitlab-org/gitlab-ce"
+ "/gitlab-org/gitlab-ce?safe=1" | "http://example.org/gitlab-org/gitlab-ce?safe=1"
+ "/gitlab-org/gitlab-ce?private_token=secret" | "http://example.org/gitlab-org/gitlab-ce?private_token=%5BFILTERED%5D"
+ "/gitlab-org/gitlab-ce?mixed=1&private_token=secret" | "http://example.org/gitlab-org/gitlab-ce?mixed=1&private_token=%5BFILTERED%5D"
end
with_them do
diff --git a/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb b/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb
index c9d1a06b3e6..4cb8bd561a2 100644
--- a/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb
+++ b/spec/lib/gitlab/tracing/rails/action_view_subscriber_spec.rb
@@ -1,31 +1,31 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
-require 'rspec-parameterized'
+require "fast_spec_helper"
+require "rspec-parameterized"
describe Gitlab::Tracing::Rails::ActionViewSubscriber do
using RSpec::Parameterized::TableSyntax
- shared_examples 'an actionview notification' do
- it 'should notify the tracer when the hash contains null values' do
+ shared_examples "an actionview notification" do
+ it "should notify the tracer when the hash contains null values" do
expect(subject).to receive(:postnotify_span).with(notification_name, start, finish, tags: expected_tags, exception: exception)
subject.public_send(notify_method, start, finish, payload)
end
- it 'should notify the tracer when the payload is missing values' do
+ it "should notify the tracer when the payload is missing values" do
expect(subject).to receive(:postnotify_span).with(notification_name, start, finish, tags: expected_tags, exception: exception)
subject.public_send(notify_method, start, finish, payload.compact)
end
- it 'should not throw exceptions when with the default tracer' do
+ it "should not throw exceptions when with the default tracer" do
expect { subject.public_send(notify_method, start, finish, payload) }.not_to raise_error
end
end
- describe '.instrument' do
- it 'is unsubscribeable' do
+ describe ".instrument" do
+ it "is unsubscribeable" do
unsubscribe = described_class.instrument
expect(unsubscribe).not_to be_nil
@@ -33,11 +33,11 @@ describe Gitlab::Tracing::Rails::ActionViewSubscriber do
end
end
- describe '#notify_render_template' do
+ describe "#notify_render_template" do
subject { described_class.new }
let(:start) { Time.now }
let(:finish) { Time.now }
- let(:notification_name) { 'render_template' }
+ let(:notification_name) { "render_template" }
let(:notify_method) { :notify_render_template }
where(:identifier, :layout, :exception) do
@@ -54,31 +54,32 @@ describe Gitlab::Tracing::Rails::ActionViewSubscriber do
{
exception: exception,
identifier: identifier,
- layout: layout
+ layout: layout,
}
end
let(:expected_tags) do
{
- 'component' => 'ActionView',
- 'template.id' => identifier,
- 'template.layout' => layout
+ "component" => "ActionView",
+ "template.id" => identifier,
+ "template.layout" => layout,
}
end
- it_behaves_like 'an actionview notification'
+ it_behaves_like "an actionview notification"
end
end
- describe '#notify_render_collection' do
+ describe "#notify_render_collection" do
subject { described_class.new }
let(:start) { Time.now }
let(:finish) { Time.now }
- let(:notification_name) { 'render_collection' }
+ let(:notification_name) { "render_collection" }
let(:notify_method) { :notify_render_collection }
where(
- :identifier, :count, :expected_count, :cache_hits, :expected_cache_hits, :exception) do
+ :identifier, :count, :expected_count, :cache_hits, :expected_cache_hits, :exception
+ ) do
nil | nil | 0 | nil | 0 | nil
"" | nil | 0 | nil | 0 | nil
"show.haml" | nil | 0 | nil | 0 | nil
@@ -95,28 +96,28 @@ describe Gitlab::Tracing::Rails::ActionViewSubscriber do
exception: exception,
identifier: identifier,
count: count,
- cache_hits: cache_hits
+ cache_hits: cache_hits,
}
end
let(:expected_tags) do
{
- 'component' => 'ActionView',
- 'template.id' => identifier,
- 'template.count' => expected_count,
- 'template.cache.hits' => expected_cache_hits
+ "component" => "ActionView",
+ "template.id" => identifier,
+ "template.count" => expected_count,
+ "template.cache.hits" => expected_cache_hits,
}
end
- it_behaves_like 'an actionview notification'
+ it_behaves_like "an actionview notification"
end
end
- describe '#notify_render_partial' do
+ describe "#notify_render_partial" do
subject { described_class.new }
let(:start) { Time.now }
let(:finish) { Time.now }
- let(:notification_name) { 'render_partial' }
+ let(:notification_name) { "render_partial" }
let(:notify_method) { :notify_render_partial }
where(:identifier, :exception) do
@@ -130,18 +131,18 @@ describe Gitlab::Tracing::Rails::ActionViewSubscriber do
let(:payload) do
{
exception: exception,
- identifier: identifier
+ identifier: identifier,
}
end
let(:expected_tags) do
{
- 'component' => 'ActionView',
- 'template.id' => identifier
+ "component" => "ActionView",
+ "template.id" => identifier,
}
end
- it_behaves_like 'an actionview notification'
+ it_behaves_like "an actionview notification"
end
end
end
diff --git a/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb b/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb
index 3d066843148..d36737895a9 100644
--- a/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb
+++ b/spec/lib/gitlab/tracing/rails/active_record_subscriber_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
-require 'rspec-parameterized'
+require "fast_spec_helper"
+require "rspec-parameterized"
describe Gitlab::Tracing::Rails::ActiveRecordSubscriber do
using RSpec::Parameterized::TableSyntax
- describe '.instrument' do
- it 'is unsubscribeable' do
+ describe ".instrument" do
+ it "is unsubscribeable" do
unsubscribe = described_class.instrument
expect(unsubscribe).not_to be_nil
@@ -15,7 +15,7 @@ describe Gitlab::Tracing::Rails::ActiveRecordSubscriber do
end
end
- describe '#notify' do
+ describe "#notify" do
subject { described_class.new }
let(:start) { Time.now }
let(:finish) { Time.now }
@@ -38,34 +38,34 @@ describe Gitlab::Tracing::Rails::ActiveRecordSubscriber do
exception: exception,
connection_id: connection_id,
cached: cached,
- sql: sql
+ sql: sql,
}
end
def expected_tags
{
- "component" => "ActiveRecord",
- "span.kind" => "client",
- "db.type" => "sql",
+ "component" => "ActiveRecord",
+ "span.kind" => "client",
+ "db.type" => "sql",
"db.connection_id" => connection_id,
- "db.cached" => cached_response,
- "db.statement" => sql
+ "db.cached" => cached_response,
+ "db.statement" => sql,
}
end
- it 'should notify the tracer when the hash contains null values' do
+ it "should notify the tracer when the hash contains null values" do
expect(subject).to receive(:postnotify_span).with(operation_name, start, finish, tags: expected_tags, exception: exception)
subject.notify(start, finish, payload)
end
- it 'should notify the tracer when the payload is missing values' do
+ it "should notify the tracer when the payload is missing values" do
expect(subject).to receive(:postnotify_span).with(operation_name, start, finish, tags: expected_tags, exception: exception)
subject.notify(start, finish, payload.compact)
end
- it 'should not throw exceptions when with the default tracer' do
+ it "should not throw exceptions when with the default tracer" do
expect { subject.notify(start, finish, payload) }.not_to raise_error
end
end
diff --git a/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb b/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb
index 3755860b5ba..5621ba24554 100644
--- a/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb
+++ b/spec/lib/gitlab/tracing/sidekiq/client_middleware_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Tracing::Sidekiq::ClientMiddleware do
- describe '#call' do
- let(:worker_class) { 'test_worker_class' }
+ describe "#call" do
+ let(:worker_class) { "test_worker_class" }
let(:job) do
{
- 'class' => "jobclass",
- 'queue' => "jobqueue",
- 'retry' => 0,
- 'args' => %w{1 2 3}
+ "class" => "jobclass",
+ "queue" => "jobqueue",
+ "retry" => 0,
+ "args" => %w[1 2 3],
}
end
- let(:queue) { 'test_queue' }
+ let(:queue) { "test_queue" }
let(:redis_pool) { double("redis_pool") }
let(:custom_error) { Class.new(StandardError) }
- let(:span) { OpenTracing.start_span('test', ignore_active_scope: true) }
+ let(:span) { OpenTracing.start_span("test", ignore_active_scope: true) }
subject { described_class.new }
- it 'yields' do
+ it "yields" do
expect(subject).to receive(:in_tracing_span).with(
operation_name: "sidekiq:jobclass",
tags: {
- "component" => "sidekiq",
- "span.kind" => "client",
+ "component" => "sidekiq",
+ "span.kind" => "client",
"sidekiq.queue" => "jobqueue",
- "sidekiq.jid" => nil,
+ "sidekiq.jid" => nil,
"sidekiq.retry" => "0",
- "sidekiq.args" => "1, 2, 3"
+ "sidekiq.args" => "1, 2, 3",
}
).and_yield(span)
expect { |b| subject.call(worker_class, job, queue, redis_pool, &b) }.to yield_control
end
- it 'propagates exceptions' do
+ it "propagates exceptions" do
expect { subject.call(worker_class, job, queue, redis_pool) { raise custom_error } }.to raise_error(custom_error)
end
end
diff --git a/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb b/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb
index c3087de785a..62c52c2d590 100644
--- a/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb
+++ b/spec/lib/gitlab/tracing/sidekiq/server_middleware_spec.rb
@@ -1,34 +1,34 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Tracing::Sidekiq::ServerMiddleware do
- describe '#call' do
- let(:worker_class) { 'test_worker_class' }
+ describe "#call" do
+ let(:worker_class) { "test_worker_class" }
let(:job) do
{
- 'class' => "jobclass",
- 'queue' => "jobqueue",
- 'retry' => 0,
- 'args' => %w{1 2 3}
+ "class" => "jobclass",
+ "queue" => "jobqueue",
+ "retry" => 0,
+ "args" => %w[1 2 3],
}
end
- let(:queue) { 'test_queue' }
+ let(:queue) { "test_queue" }
let(:custom_error) { Class.new(StandardError) }
- let(:span) { OpenTracing.start_span('test', ignore_active_scope: true) }
+ let(:span) { OpenTracing.start_span("test", ignore_active_scope: true) }
subject { described_class.new }
- it 'yields' do
+ it "yields" do
expect(subject).to receive(:in_tracing_span).with(
hash_including(
operation_name: "sidekiq:jobclass",
tags: {
- "component" => "sidekiq",
- "span.kind" => "server",
+ "component" => "sidekiq",
+ "span.kind" => "server",
"sidekiq.queue" => "jobqueue",
- "sidekiq.jid" => nil,
+ "sidekiq.jid" => nil,
"sidekiq.retry" => "0",
- "sidekiq.args" => "1, 2, 3"
+ "sidekiq.args" => "1, 2, 3",
}
)
).and_yield(span)
@@ -36,7 +36,7 @@ describe Gitlab::Tracing::Sidekiq::ServerMiddleware do
expect { |b| subject.call(worker_class, job, queue, &b) }.to yield_control
end
- it 'propagates exceptions' do
+ it "propagates exceptions" do
expect { subject.call(worker_class, job, queue) { raise custom_error } }.to raise_error(custom_error)
end
end
diff --git a/spec/lib/gitlab/tracing_spec.rb b/spec/lib/gitlab/tracing_spec.rb
index 566b5050e47..dba0c29f33d 100644
--- a/spec/lib/gitlab/tracing_spec.rb
+++ b/spec/lib/gitlab/tracing_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
-require 'rspec-parameterized'
+require "fast_spec_helper"
+require "rspec-parameterized"
describe Gitlab::Tracing do
using RSpec::Parameterized::TableSyntax
- describe '.enabled?' do
+ describe ".enabled?" do
where(:connection_string, :enabled_state) do
nil | false
"" | false
@@ -14,7 +14,7 @@ describe Gitlab::Tracing do
end
with_them do
- it 'should return the correct state for .enabled?' do
+ it "should return the correct state for .enabled?" do
expect(described_class).to receive(:connection_string).and_return(connection_string)
expect(described_class.enabled?).to eq(enabled_state)
@@ -22,7 +22,7 @@ describe Gitlab::Tracing do
end
end
- describe '.tracing_url_enabled?' do
+ describe ".tracing_url_enabled?" do
where(:enabled?, :tracing_url_template, :tracing_url_enabled_state) do
false | nil | false
false | "" | false
@@ -33,7 +33,7 @@ describe Gitlab::Tracing do
end
with_them do
- it 'should return the correct state for .tracing_url_enabled?' do
+ it "should return the correct state for .tracing_url_enabled?" do
expect(described_class).to receive(:enabled?).and_return(enabled?)
allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template)
@@ -42,7 +42,7 @@ describe Gitlab::Tracing do
end
end
- describe '.tracing_url' do
+ describe ".tracing_url" do
where(:tracing_url_enabled?, :tracing_url_template, :correlation_id, :process_name, :tracing_url) do
false | "https://localhost" | "123" | "web" | nil
true | "https://localhost" | "123" | "web" | "https://localhost"
@@ -56,7 +56,7 @@ describe Gitlab::Tracing do
end
with_them do
- it 'should return the correct state for .tracing_url' do
+ it "should return the correct state for .tracing_url" do
expect(described_class).to receive(:tracing_url_enabled?).and_return(tracing_url_enabled?)
allow(described_class).to receive(:tracing_url_template).and_return(tracing_url_template)
allow(Gitlab::CorrelationId).to receive(:current_id).and_return(correlation_id)
diff --git a/spec/lib/gitlab/tree_summary_spec.rb b/spec/lib/gitlab/tree_summary_spec.rb
index e22f898dc4c..854ce7060a4 100644
--- a/spec/lib/gitlab/tree_summary_spec.rb
+++ b/spec/lib/gitlab/tree_summary_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::TreeSummary do
using RSpec::Parameterized::TableSyntax
@@ -13,29 +13,29 @@ describe Gitlab::TreeSummary do
subject(:summary) { described_class.new(commit, project, path: path, offset: offset, limit: limit) }
- describe '#initialize' do
- it 'defaults offset to 0' do
+ describe "#initialize" do
+ it "defaults offset to 0" do
expect(summary.offset).to eq(0)
end
- it 'defaults limit to 25' do
+ it "defaults limit to 25" do
expect(summary.limit).to eq(25)
end
end
- describe '#summarize' do
- let(:project) { create(:project, :custom_repo, files: { 'a.txt' => '' }) }
+ describe "#summarize" do
+ let(:project) { create(:project, :custom_repo, files: {"a.txt" => ""}) }
subject(:summarized) { summary.summarize }
- it 'returns an array of entries, and an array of commits' do
+ it "returns an array of entries, and an array of commits" do
expect(summarized).to be_a(Array)
expect(summarized.size).to eq(2)
entries, commits = *summarized
aggregate_failures do
expect(entries).to contain_exactly(
- a_hash_including(file_name: 'a.txt', commit: have_attributes(id: commit.id))
+ a_hash_including(file_name: "a.txt", commit: have_attributes(id: commit.id))
)
expect(commits).to match_array(entries.map { |entry| entry[:commit] })
@@ -43,13 +43,13 @@ describe Gitlab::TreeSummary do
end
end
- describe '#summarize (entries)' do
+ describe "#summarize (entries)" do
let(:limit) { 2 }
custom_files = {
- 'a.txt' => '',
- 'b.txt' => '',
- 'directory/c.txt' => ''
+ "a.txt" => "",
+ "b.txt" => "",
+ "directory/c.txt" => "",
}
let(:project) { create(:project, :custom_repo, files: custom_files) }
@@ -57,15 +57,15 @@ describe Gitlab::TreeSummary do
subject(:entries) { summary.summarize.first }
- it 'summarizes the entries within the window' do
+ it "summarizes the entries within the window" do
is_expected.to contain_exactly(
- a_hash_including(type: :tree, file_name: 'directory'),
- a_hash_including(type: :blob, file_name: 'a.txt')
+ a_hash_including(type: :tree, file_name: "directory"),
+ a_hash_including(type: :blob, file_name: "a.txt")
# b.txt is excluded by the limit
)
end
- it 'references the commit and commit path in entries' do
+ it "references the commit and commit path in entries" do
entry = entries.first
expected_commit_path = Gitlab::Routing.url_helpers.project_commit_path(project, commit)
@@ -73,34 +73,34 @@ describe Gitlab::TreeSummary do
expect(entry[:commit_path]).to eq expected_commit_path
end
- context 'in a good subdirectory' do
- let(:path) { 'directory' }
+ context "in a good subdirectory" do
+ let(:path) { "directory" }
- it 'summarizes the entries in the subdirectory' do
- is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: 'c.txt'))
+ it "summarizes the entries in the subdirectory" do
+ is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: "c.txt"))
end
end
- context 'in a non-existent subdirectory' do
- let(:path) { 'tmp' }
+ context "in a non-existent subdirectory" do
+ let(:path) { "tmp" }
it { is_expected.to be_empty }
end
- context 'custom offset and limit' do
+ context "custom offset and limit" do
let(:offset) { 2 }
- it 'returns entries from the offset' do
- is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: 'b.txt'))
+ it "returns entries from the offset" do
+ is_expected.to contain_exactly(a_hash_including(type: :blob, file_name: "b.txt"))
end
end
end
- describe '#summarize (commits)' do
+ describe "#summarize (commits)" do
# This is a commit in the master branch of the gitlab-test repository that
# satisfies certain assumptions these tests depend on
- let(:test_commit_sha) { '7975be0116940bf2ad4321f79d02a55c5f7779aa' }
- let(:whitespace_commit_sha) { '66eceea0db202bb39c4e445e8ca28689645366c5' }
+ let(:test_commit_sha) { "7975be0116940bf2ad4321f79d02a55c5f7779aa" }
+ let(:whitespace_commit_sha) { "66eceea0db202bb39c4e445e8ca28689645366c5" }
let(:project) { create(:project, :repository) }
let(:commit) { repo.commit(test_commit_sha) }
@@ -111,26 +111,26 @@ describe Gitlab::TreeSummary do
summary.summarize.last
end
- it 'returns an Array of ::Commit objects' do
+ it "returns an Array of ::Commit objects" do
is_expected.not_to be_empty
is_expected.to all(be_kind_of(::Commit))
end
- it 'deduplicates commits when multiple entries reference the same commit' do
+ it "deduplicates commits when multiple entries reference the same commit" do
expect(commits.size).to be < entries.size
end
- context 'in a subdirectory' do
- let(:path) { 'files' }
+ context "in a subdirectory" do
+ let(:path) { "files" }
- it 'returns commits for entries in the subdirectory' do
+ it "returns commits for entries in the subdirectory" do
expect(commits).to satisfy_one { |c| c.id == whitespace_commit_sha }
end
end
end
- describe '#more?' do
- let(:path) { 'tmp/more' }
+ describe "#more?" do
+ let(:path) { "tmp/more" }
where(:num_entries, :offset, :limit, :expected_result) do
0 | 0 | 0 | false
@@ -153,7 +153,7 @@ describe Gitlab::TreeSummary do
with_them do
before do
- create_file('dummy', path: 'other') if num_entries.zero?
+ create_file("dummy", path: "other") if num_entries.zero?
1.upto(num_entries) { |n| create_file(n, path: path) }
end
@@ -163,8 +163,8 @@ describe Gitlab::TreeSummary do
end
end
- describe '#next_offset' do
- let(:path) { 'tmp/next_offset' }
+ describe "#next_offset" do
+ let(:path) { "tmp/next_offset" }
where(:num_entries, :offset, :limit, :expected_result) do
0 | 0 | 0 | 0
@@ -180,7 +180,7 @@ describe Gitlab::TreeSummary do
with_them do
before do
- create_file('dummy', path: 'other') if num_entries.zero?
+ create_file("dummy", path: "other") if num_entries.zero?
1.upto(num_entries) { |n| create_file(n, path: path) }
end
@@ -194,9 +194,9 @@ describe Gitlab::TreeSummary do
repo.create_file(
project.creator,
"#{path}/file-#{unique}.txt",
- 'content',
+ "content",
message: "Commit message #{unique}",
- branch_name: 'master'
+ branch_name: "master"
)
end
end
diff --git a/spec/lib/gitlab/untrusted_regexp_spec.rb b/spec/lib/gitlab/untrusted_regexp_spec.rb
index 0a6ac0aa294..b45c0433429 100644
--- a/spec/lib/gitlab/untrusted_regexp_spec.rb
+++ b/spec/lib/gitlab/untrusted_regexp_spec.rb
@@ -1,89 +1,89 @@
-require 'fast_spec_helper'
-require 'support/shared_examples/malicious_regexp_shared_examples'
+require "fast_spec_helper"
+require "support/shared_examples/malicious_regexp_shared_examples"
describe Gitlab::UntrustedRegexp do
- describe '.valid?' do
- it 'returns true if regexp is valid' do
- expect(described_class.valid?('/some ( thing/'))
+ describe ".valid?" do
+ it "returns true if regexp is valid" do
+ expect(described_class.valid?("/some ( thing/"))
.to be false
end
- it 'returns true if regexp is invalid' do
- expect(described_class.valid?('/some .* thing/'))
+ it "returns true if regexp is invalid" do
+ expect(described_class.valid?("/some .* thing/"))
.to be true
end
end
- describe '.fabricate' do
- context 'when regexp is using /regexp/ scheme with flags' do
- it 'fabricates regexp with a single flag' do
- regexp = described_class.fabricate('/something/i')
+ describe ".fabricate" do
+ context "when regexp is using /regexp/ scheme with flags" do
+ it "fabricates regexp with a single flag" do
+ regexp = described_class.fabricate("/something/i")
- expect(regexp).to eq described_class.new('(?i)something')
- expect(regexp.scan('SOMETHING')).to be_one
+ expect(regexp).to eq described_class.new("(?i)something")
+ expect(regexp.scan("SOMETHING")).to be_one
end
- it 'fabricates regexp with multiple flags' do
- regexp = described_class.fabricate('/something/im')
+ it "fabricates regexp with multiple flags" do
+ regexp = described_class.fabricate("/something/im")
- expect(regexp).to eq described_class.new('(?im)something')
+ expect(regexp).to eq described_class.new("(?im)something")
end
- it 'fabricates regexp without flags' do
- regexp = described_class.fabricate('/something/')
+ it "fabricates regexp without flags" do
+ regexp = described_class.fabricate("/something/")
- expect(regexp).to eq described_class.new('something')
+ expect(regexp).to eq described_class.new("something")
end
end
- context 'when regexp is a raw pattern' do
- it 'raises an error' do
- expect { described_class.fabricate('some .* thing') }
+ context "when regexp is a raw pattern" do
+ it "raises an error" do
+ expect { described_class.fabricate("some .* thing") }
.to raise_error(RegexpError)
end
end
end
- describe '#initialize' do
+ describe "#initialize" do
subject { described_class.new(pattern) }
- context 'invalid regexp' do
- let(:pattern) { '[' }
+ context "invalid regexp" do
+ let(:pattern) { "[" }
it { expect { subject }.to raise_error(RegexpError) }
end
end
- describe '#replace_all' do
- it 'replaces all instances of the match in a string' do
- result = described_class.new('foo').replace_all('foo bar foo', 'oof')
+ describe "#replace_all" do
+ it "replaces all instances of the match in a string" do
+ result = described_class.new("foo").replace_all("foo bar foo", "oof")
- expect(result).to eq('oof bar oof')
+ expect(result).to eq("oof bar oof")
end
end
- describe '#replace' do
- it 'replaces the first instance of the match in a string' do
- result = described_class.new('foo').replace('foo bar foo', 'oof')
+ describe "#replace" do
+ it "replaces the first instance of the match in a string" do
+ result = described_class.new("foo").replace("foo bar foo", "oof")
- expect(result).to eq('oof bar foo')
+ expect(result).to eq("oof bar foo")
end
end
- describe '#===' do
- it 'returns true for a match' do
- result = described_class.new('foo') === 'a foo here'
+ describe "#===" do
+ it "returns true for a match" do
+ result = described_class.new("foo") === "a foo here"
expect(result).to be_truthy
end
- it 'returns false for no match' do
- result = described_class.new('foo') === 'a bar here'
+ it "returns false for no match" do
+ result = described_class.new("foo") === "a bar here"
expect(result).to be_falsy
end
- it 'can handle regular expressions in multiline mode' do
+ it "can handle regular expressions in multiline mode" do
regexp = described_class.new('^\d', multiline: true)
result = regexp === "Header\n\n1. Content"
@@ -92,56 +92,56 @@ describe Gitlab::UntrustedRegexp do
end
end
- describe '#scan' do
+ describe "#scan" do
subject { described_class.new(regexp).scan(text) }
- context 'malicious regexp' do
+ context "malicious regexp" do
let(:text) { malicious_text }
let(:regexp) { malicious_regexp }
- include_examples 'malicious regexp'
+ include_examples "malicious regexp"
end
- context 'empty regexp' do
- let(:regexp) { '' }
- let(:text) { 'foo' }
+ context "empty regexp" do
+ let(:regexp) { "" }
+ let(:text) { "foo" }
- it 'returns an array of nil matches' do
+ it "returns an array of nil matches" do
is_expected.to eq([nil, nil, nil, nil])
end
end
- context 'empty capture group regexp' do
- let(:regexp) { '()' }
- let(:text) { 'foo' }
+ context "empty capture group regexp" do
+ let(:regexp) { "()" }
+ let(:text) { "foo" }
- it 'returns an array of nil matches in an array' do
+ it "returns an array of nil matches in an array" do
is_expected.to eq([[nil], [nil], [nil], [nil]])
end
end
- context 'no capture group' do
- let(:regexp) { '.+' }
- let(:text) { 'foo' }
+ context "no capture group" do
+ let(:regexp) { ".+" }
+ let(:text) { "foo" }
- it 'returns the whole match' do
- is_expected.to eq(['foo'])
+ it "returns the whole match" do
+ is_expected.to eq(["foo"])
end
end
- context 'one capture group' do
- let(:regexp) { '(f).+' }
- let(:text) { 'foo' }
+ context "one capture group" do
+ let(:regexp) { "(f).+" }
+ let(:text) { "foo" }
- it 'returns the captured part' do
+ it "returns the captured part" do
is_expected.to eq([%w[f]])
end
end
- context 'two capture groups' do
- let(:regexp) { '(f).(o)' }
- let(:text) { 'foo' }
+ context "two capture groups" do
+ let(:regexp) { "(f).(o)" }
+ let(:text) { "foo" }
- it 'returns the captured parts' do
+ it "returns the captured parts" do
is_expected.to eq([%w[f o]])
end
end
diff --git a/spec/lib/gitlab/uploads_transfer_spec.rb b/spec/lib/gitlab/uploads_transfer_spec.rb
index 4275e7b015b..b812f8bc80b 100644
--- a/spec/lib/gitlab/uploads_transfer_spec.rb
+++ b/spec/lib/gitlab/uploads_transfer_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UploadsTransfer do
- it 'leaves avatar uploads where they are' do
+ it "leaves avatar uploads where they are" do
project_with_avatar = create(:project, :with_avatar)
- described_class.new.rename_namespace('project', 'project-renamed')
+ described_class.new.rename_namespace("project", "project-renamed")
expect(File.exist?(project_with_avatar.avatar.path)).to be_truthy
end
diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb
index 62970bd8cb6..3aa956dee97 100644
--- a/spec/lib/gitlab/url_blocker_spec.rb
+++ b/spec/lib/gitlab/url_blocker_spec.rb
@@ -1,35 +1,34 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UrlBlocker do
- describe '#blocked_url?' do
+ describe "#blocked_url?" do
let(:ports) { Project::VALID_IMPORT_PORTS }
- it 'allows imports from configured web host and port' do
+ it "allows imports from configured web host and port" do
import_url = "http://#{Gitlab.config.gitlab.host}:#{Gitlab.config.gitlab.port}/t.git"
expect(described_class.blocked_url?(import_url)).to be false
end
- it 'allows mirroring from configured SSH host and port' do
+ it "allows mirroring from configured SSH host and port" do
import_url = "ssh://#{Gitlab.config.gitlab_shell.ssh_host}:#{Gitlab.config.gitlab_shell.ssh_port}/t.git"
expect(described_class.blocked_url?(import_url)).to be false
end
- it 'returns true for bad localhost hostname' do
- expect(described_class.blocked_url?('https://localhost:65535/foo/foo.git')).to be true
+ it "returns true for bad localhost hostname" do
+ expect(described_class.blocked_url?("https://localhost:65535/foo/foo.git")).to be true
end
- it 'returns true for bad port' do
- expect(described_class.blocked_url?('https://gitlab.com:25/foo/foo.git', ports: ports)).to be true
+ it "returns true for bad port" do
+ expect(described_class.blocked_url?("https://gitlab.com:25/foo/foo.git", ports: ports)).to be true
end
- it 'returns true for bad protocol' do
- expect(described_class.blocked_url?('https://gitlab.com/foo/foo.git', protocols: ['https'])).to be false
- expect(described_class.blocked_url?('https://gitlab.com/foo/foo.git')).to be false
- expect(described_class.blocked_url?('https://gitlab.com/foo/foo.git', protocols: ['http'])).to be true
+ it "returns true for bad protocol" do
+ expect(described_class.blocked_url?("https://gitlab.com/foo/foo.git", protocols: ["https"])).to be false
+ expect(described_class.blocked_url?("https://gitlab.com/foo/foo.git")).to be false
+ expect(described_class.blocked_url?("https://gitlab.com/foo/foo.git", protocols: ["http"])).to be true
end
- it 'returns true for bad protocol on configured web/SSH host and ports' do
+ it "returns true for bad protocol on configured web/SSH host and ports" do
web_url = "javascript://#{Gitlab.config.gitlab.host}:#{Gitlab.config.gitlab.port}/t.git%0aalert(1)"
expect(described_class.blocked_url?(web_url)).to be true
@@ -37,110 +36,110 @@ describe Gitlab::UrlBlocker do
expect(described_class.blocked_url?(ssh_url)).to be true
end
- it 'returns true for localhost IPs' do
- expect(described_class.blocked_url?('https://[0:0:0:0:0:0:0:0]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://0.0.0.0/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::]/foo/foo.git')).to be true
+ it "returns true for localhost IPs" do
+ expect(described_class.blocked_url?("https://[0:0:0:0:0:0:0:0]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://0.0.0.0/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::]/foo/foo.git")).to be true
end
- it 'returns true for loopback IP' do
- expect(described_class.blocked_url?('https://127.0.0.2/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://127.0.0.1/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::1]/foo/foo.git')).to be true
+ it "returns true for loopback IP" do
+ expect(described_class.blocked_url?("https://127.0.0.2/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://127.0.0.1/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::1]/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (0177.1)' do
- expect(described_class.blocked_url?('https://0177.1:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (0177.1)" do
+ expect(described_class.blocked_url?("https://0177.1:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (017700000001)' do
- expect(described_class.blocked_url?('https://017700000001:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (017700000001)" do
+ expect(described_class.blocked_url?("https://017700000001:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (0x7f.1)' do
- expect(described_class.blocked_url?('https://0x7f.1:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (0x7f.1)" do
+ expect(described_class.blocked_url?("https://0x7f.1:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (0x7f.0.0.1)' do
- expect(described_class.blocked_url?('https://0x7f.0.0.1:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (0x7f.0.0.1)" do
+ expect(described_class.blocked_url?("https://0x7f.0.0.1:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (0x7f000001)' do
- expect(described_class.blocked_url?('https://0x7f000001:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (0x7f000001)" do
+ expect(described_class.blocked_url?("https://0x7f000001:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (2130706433)' do
- expect(described_class.blocked_url?('https://2130706433:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (2130706433)" do
+ expect(described_class.blocked_url?("https://2130706433:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (127.000.000.001)' do
- expect(described_class.blocked_url?('https://127.000.000.001:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (127.000.000.001)" do
+ expect(described_class.blocked_url?("https://127.000.000.001:65535/foo/foo.git")).to be true
end
- it 'returns true for alternative version of 127.0.0.1 (127.0.1)' do
- expect(described_class.blocked_url?('https://127.0.1:65535/foo/foo.git')).to be true
+ it "returns true for alternative version of 127.0.0.1 (127.0.1)" do
+ expect(described_class.blocked_url?("https://127.0.1:65535/foo/foo.git")).to be true
end
- context 'with ipv6 mapped address' do
- it 'returns true for localhost IPs' do
- expect(described_class.blocked_url?('https://[0:0:0:0:0:ffff:0.0.0.0]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:0.0.0.0]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:0:0]/foo/foo.git')).to be true
+ context "with ipv6 mapped address" do
+ it "returns true for localhost IPs" do
+ expect(described_class.blocked_url?("https://[0:0:0:0:0:ffff:0.0.0.0]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:0.0.0.0]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:0:0]/foo/foo.git")).to be true
end
- it 'returns true for loopback IPs' do
- expect(described_class.blocked_url?('https://[0:0:0:0:0:ffff:127.0.0.1]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:127.0.0.1]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:7f00:1]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[0:0:0:0:0:ffff:127.0.0.2]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:127.0.0.2]/foo/foo.git')).to be true
- expect(described_class.blocked_url?('https://[::ffff:7f00:2]/foo/foo.git')).to be true
+ it "returns true for loopback IPs" do
+ expect(described_class.blocked_url?("https://[0:0:0:0:0:ffff:127.0.0.1]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:127.0.0.1]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:7f00:1]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[0:0:0:0:0:ffff:127.0.0.2]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:127.0.0.2]/foo/foo.git")).to be true
+ expect(described_class.blocked_url?("https://[::ffff:7f00:2]/foo/foo.git")).to be true
end
end
- it 'returns true for a non-alphanumeric hostname' do
+ it "returns true for a non-alphanumeric hostname" do
stub_resolv
aggregate_failures do
- expect(described_class).to be_blocked_url('ssh://-oProxyCommand=whoami/a')
+ expect(described_class).to be_blocked_url("ssh://-oProxyCommand=whoami/a")
# The leading character here is a Unicode "soft hyphen"
- expect(described_class).to be_blocked_url('ssh://­oProxyCommand=whoami/a')
+ expect(described_class).to be_blocked_url("ssh://­oProxyCommand=whoami/a")
# Unicode alphanumerics are allowed
- expect(described_class).not_to be_blocked_url('ssh://ğitlab.com/a')
+ expect(described_class).not_to be_blocked_url("ssh://ğitlab.com/a")
end
end
- it 'returns true for invalid URL' do
- expect(described_class.blocked_url?('http://:8080')).to be true
+ it "returns true for invalid URL" do
+ expect(described_class.blocked_url?("http://:8080")).to be true
end
- it 'returns false for legitimate URL' do
- expect(described_class.blocked_url?('https://gitlab.com/foo/foo.git')).to be false
+ it "returns false for legitimate URL" do
+ expect(described_class.blocked_url?("https://gitlab.com/foo/foo.git")).to be false
end
- context 'when allow_local_network is' do
+ context "when allow_local_network is" do
let(:local_ips) do
[
- '192.168.1.2',
- '[0:0:0:0:0:ffff:192.168.1.2]',
- '[::ffff:c0a8:102]',
- '10.0.0.2',
- '[0:0:0:0:0:ffff:10.0.0.2]',
- '[::ffff:a00:2]',
- '172.16.0.2',
- '[0:0:0:0:0:ffff:172.16.0.2]',
- '[::ffff:ac10:20]',
- '[feef::1]',
- '[fee2::]',
- '[fc00:bf8b:e62c:abcd:abcd:aaaa:aaaa:aaaa]'
+ "192.168.1.2",
+ "[0:0:0:0:0:ffff:192.168.1.2]",
+ "[::ffff:c0a8:102]",
+ "10.0.0.2",
+ "[0:0:0:0:0:ffff:10.0.0.2]",
+ "[::ffff:a00:2]",
+ "172.16.0.2",
+ "[0:0:0:0:0:ffff:172.16.0.2]",
+ "[::ffff:ac10:20]",
+ "[feef::1]",
+ "[fee2::]",
+ "[fc00:bf8b:e62c:abcd:abcd:aaaa:aaaa:aaaa]",
]
end
- let(:fake_domain) { 'www.fakedomain.fake' }
+ let(:fake_domain) { "www.fakedomain.fake" }
- context 'true (default)' do
- it 'does not block urls from private networks' do
+ context "true (default)" do
+ it "does not block urls from private networks" do
local_ips.each do |ip|
stub_domain_resolv(fake_domain, ip)
@@ -152,34 +151,34 @@ describe Gitlab::UrlBlocker do
end
end
- it 'allows localhost endpoints' do
- expect(described_class).not_to be_blocked_url('http://0.0.0.0', allow_localhost: true)
- expect(described_class).not_to be_blocked_url('http://localhost', allow_localhost: true)
- expect(described_class).not_to be_blocked_url('http://127.0.0.1', allow_localhost: true)
+ it "allows localhost endpoints" do
+ expect(described_class).not_to be_blocked_url("http://0.0.0.0", allow_localhost: true)
+ expect(described_class).not_to be_blocked_url("http://localhost", allow_localhost: true)
+ expect(described_class).not_to be_blocked_url("http://127.0.0.1", allow_localhost: true)
end
- it 'allows loopback endpoints' do
- expect(described_class).not_to be_blocked_url('http://127.0.0.2', allow_localhost: true)
+ it "allows loopback endpoints" do
+ expect(described_class).not_to be_blocked_url("http://127.0.0.2", allow_localhost: true)
end
- it 'allows IPv4 link-local endpoints' do
- expect(described_class).not_to be_blocked_url('http://169.254.169.254')
- expect(described_class).not_to be_blocked_url('http://169.254.168.100')
+ it "allows IPv4 link-local endpoints" do
+ expect(described_class).not_to be_blocked_url("http://169.254.169.254")
+ expect(described_class).not_to be_blocked_url("http://169.254.168.100")
end
- it 'allows IPv6 link-local endpoints' do
- expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.169.254]')
- expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.169.254]')
- expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a9fe]')
- expect(described_class).not_to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.168.100]')
- expect(described_class).not_to be_blocked_url('http://[::ffff:169.254.168.100]')
- expect(described_class).not_to be_blocked_url('http://[::ffff:a9fe:a864]')
- expect(described_class).not_to be_blocked_url('http://[fe80::c800:eff:fe74:8]')
+ it "allows IPv6 link-local endpoints" do
+ expect(described_class).not_to be_blocked_url("http://[0:0:0:0:0:ffff:169.254.169.254]")
+ expect(described_class).not_to be_blocked_url("http://[::ffff:169.254.169.254]")
+ expect(described_class).not_to be_blocked_url("http://[::ffff:a9fe:a9fe]")
+ expect(described_class).not_to be_blocked_url("http://[0:0:0:0:0:ffff:169.254.168.100]")
+ expect(described_class).not_to be_blocked_url("http://[::ffff:169.254.168.100]")
+ expect(described_class).not_to be_blocked_url("http://[::ffff:a9fe:a864]")
+ expect(described_class).not_to be_blocked_url("http://[fe80::c800:eff:fe74:8]")
end
end
- context 'false' do
- it 'blocks urls from private networks' do
+ context "false" do
+ it "blocks urls from private networks" do
local_ips.each do |ip|
stub_domain_resolv(fake_domain, ip)
@@ -191,19 +190,19 @@ describe Gitlab::UrlBlocker do
end
end
- it 'blocks IPv4 link-local endpoints' do
- expect(described_class).to be_blocked_url('http://169.254.169.254', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://169.254.168.100', allow_local_network: false)
+ it "blocks IPv4 link-local endpoints" do
+ expect(described_class).to be_blocked_url("http://169.254.169.254", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://169.254.168.100", allow_local_network: false)
end
- it 'blocks IPv6 link-local endpoints' do
- expect(described_class).to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.169.254]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[::ffff:169.254.169.254]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[::ffff:a9fe:a9fe]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[0:0:0:0:0:ffff:169.254.168.100]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[::ffff:169.254.168.100]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[::ffff:a9fe:a864]', allow_local_network: false)
- expect(described_class).to be_blocked_url('http://[fe80::c800:eff:fe74:8]', allow_local_network: false)
+ it "blocks IPv6 link-local endpoints" do
+ expect(described_class).to be_blocked_url("http://[0:0:0:0:0:ffff:169.254.169.254]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[::ffff:169.254.169.254]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[::ffff:a9fe:a9fe]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[0:0:0:0:0:ffff:169.254.168.100]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[::ffff:169.254.168.100]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[::ffff:a9fe:a864]", allow_local_network: false)
+ expect(described_class).to be_blocked_url("http://[fe80::c800:eff:fe74:8]", allow_local_network: false)
end
end
@@ -218,84 +217,84 @@ describe Gitlab::UrlBlocker do
end
end
- context 'when enforce_user is' do
+ context "when enforce_user is" do
before do
stub_resolv
end
- context 'false (default)' do
- it 'does not block urls with a non-alphanumeric username' do
- expect(described_class).not_to be_blocked_url('ssh://-oProxyCommand=whoami@example.com/a')
+ context "false (default)" do
+ it "does not block urls with a non-alphanumeric username" do
+ expect(described_class).not_to be_blocked_url("ssh://-oProxyCommand=whoami@example.com/a")
# The leading character here is a Unicode "soft hyphen"
- expect(described_class).not_to be_blocked_url('ssh://­oProxyCommand=whoami@example.com/a')
+ expect(described_class).not_to be_blocked_url("ssh://­oProxyCommand=whoami@example.com/a")
# Unicode alphanumerics are allowed
- expect(described_class).not_to be_blocked_url('ssh://ğitlab@example.com/a')
+ expect(described_class).not_to be_blocked_url("ssh://ğitlab@example.com/a")
end
end
- context 'true' do
- it 'blocks urls with a non-alphanumeric username' do
+ context "true" do
+ it "blocks urls with a non-alphanumeric username" do
aggregate_failures do
- expect(described_class).to be_blocked_url('ssh://-oProxyCommand=whoami@example.com/a', enforce_user: true)
+ expect(described_class).to be_blocked_url("ssh://-oProxyCommand=whoami@example.com/a", enforce_user: true)
# The leading character here is a Unicode "soft hyphen"
- expect(described_class).to be_blocked_url('ssh://­oProxyCommand=whoami@example.com/a', enforce_user: true)
+ expect(described_class).to be_blocked_url("ssh://­oProxyCommand=whoami@example.com/a", enforce_user: true)
# Unicode alphanumerics are allowed
- expect(described_class).not_to be_blocked_url('ssh://ğitlab@example.com/a', enforce_user: true)
+ expect(described_class).not_to be_blocked_url("ssh://ğitlab@example.com/a", enforce_user: true)
end
end
end
end
- context 'when ascii_only is true' do
- it 'returns true for unicode domain' do
- expect(described_class.blocked_url?('https://𝕘itⅼαƄ.com/foo/foo.bar', ascii_only: true)).to be true
+ context "when ascii_only is true" do
+ it "returns true for unicode domain" do
+ expect(described_class.blocked_url?("https://𝕘itⅼαƄ.com/foo/foo.bar", ascii_only: true)).to be true
end
- it 'returns true for unicode tld' do
- expect(described_class.blocked_url?('https://gitlab.ᴄοm/foo/foo.bar', ascii_only: true)).to be true
+ it "returns true for unicode tld" do
+ expect(described_class.blocked_url?("https://gitlab.ᴄοm/foo/foo.bar", ascii_only: true)).to be true
end
- it 'returns true for unicode path' do
- expect(described_class.blocked_url?('https://gitlab.com/𝒇οο/𝒇οο.Ƅαꮁ', ascii_only: true)).to be true
+ it "returns true for unicode path" do
+ expect(described_class.blocked_url?("https://gitlab.com/𝒇οο/𝒇οο.Ƅαꮁ", ascii_only: true)).to be true
end
- it 'returns true for IDNA deviations' do
- expect(described_class.blocked_url?('https://mißile.com/foo/foo.bar', ascii_only: true)).to be true
- expect(described_class.blocked_url?('https://miςςile.com/foo/foo.bar', ascii_only: true)).to be true
- expect(described_class.blocked_url?('https://git‍lab.com/foo/foo.bar', ascii_only: true)).to be true
- expect(described_class.blocked_url?('https://git‌lab.com/foo/foo.bar', ascii_only: true)).to be true
+ it "returns true for IDNA deviations" do
+ expect(described_class.blocked_url?("https://mißile.com/foo/foo.bar", ascii_only: true)).to be true
+ expect(described_class.blocked_url?("https://miςςile.com/foo/foo.bar", ascii_only: true)).to be true
+ expect(described_class.blocked_url?("https://git‍lab.com/foo/foo.bar", ascii_only: true)).to be true
+ expect(described_class.blocked_url?("https://git‌lab.com/foo/foo.bar", ascii_only: true)).to be true
end
end
end
- describe '#validate_hostname!' do
+ describe "#validate_hostname!" do
let(:ip_addresses) do
[
- '2001:db8:1f70::999:de8:7648:6e8',
- 'FE80::C800:EFF:FE74:8',
- '::ffff:127.0.0.1',
- '::ffff:169.254.168.100',
- '::ffff:7f00:1',
- '0:0:0:0:0:ffff:0.0.0.0',
- 'localhost',
- '127.0.0.1',
- '127.000.000.001',
- '0x7f000001',
- '0x7f.0.0.1',
- '0x7f.0.0.1',
- '017700000001',
- '0177.1',
- '2130706433',
- '::',
- '::1'
+ "2001:db8:1f70::999:de8:7648:6e8",
+ "FE80::C800:EFF:FE74:8",
+ "::ffff:127.0.0.1",
+ "::ffff:169.254.168.100",
+ "::ffff:7f00:1",
+ "0:0:0:0:0:ffff:0.0.0.0",
+ "localhost",
+ "127.0.0.1",
+ "127.000.000.001",
+ "0x7f000001",
+ "0x7f.0.0.1",
+ "0x7f.0.0.1",
+ "017700000001",
+ "0177.1",
+ "2130706433",
+ "::",
+ "::1",
]
end
- it 'does not raise error for valid Ip addresses' do
+ it "does not raise error for valid Ip addresses" do
ip_addresses.each do |ip|
expect { described_class.send(:validate_hostname!, ip) }.not_to raise_error
end
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb
index 9f495a5d50b..60e9b1d466f 100644
--- a/spec/lib/gitlab/url_builder_spec.rb
+++ b/spec/lib/gitlab/url_builder_spec.rb
@@ -1,150 +1,150 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UrlBuilder do
- describe '.build' do
- context 'when passing a Commit' do
- it 'returns a proper URL' do
+ describe ".build" do
+ context "when passing a Commit" do
+ it "returns a proper URL" do
commit = build_stubbed(:commit)
url = described_class.build(commit)
- expect(url).to eq "#{Settings.gitlab['url']}/#{commit.project.full_path}/commit/#{commit.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{commit.project.full_path}/commit/#{commit.id}"
end
end
- context 'when passing an Issue' do
- it 'returns a proper URL' do
+ context "when passing an Issue" do
+ it "returns a proper URL" do
issue = build_stubbed(:issue, iid: 42)
url = described_class.build(issue)
- expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{issue.project.full_path}/issues/#{issue.iid}"
end
end
- context 'when passing a Milestone' do
+ context "when passing a Milestone" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- context 'belonging to a project' do
- it 'returns a proper URL' do
+ context "belonging to a project" do
+ it "returns a proper URL" do
milestone = create(:milestone, project: project)
url = described_class.build(milestone)
- expect(url).to eq "#{Settings.gitlab['url']}/#{milestone.project.full_path}/milestones/#{milestone.iid}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{milestone.project.full_path}/milestones/#{milestone.iid}"
end
end
- context 'belonging to a group' do
- it 'returns a proper URL' do
+ context "belonging to a group" do
+ it "returns a proper URL" do
milestone = create(:milestone, group: group)
url = described_class.build(milestone)
- expect(url).to eq "#{Settings.gitlab['url']}/groups/#{milestone.group.full_path}/-/milestones/#{milestone.iid}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/groups/#{milestone.group.full_path}/-/milestones/#{milestone.iid}"
end
end
end
- context 'when passing a MergeRequest' do
- it 'returns a proper URL' do
+ context "when passing a MergeRequest" do
+ it "returns a proper URL" do
merge_request = build_stubbed(:merge_request, iid: 42)
url = described_class.build(merge_request)
- expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}"
end
end
- context 'when passing a Note' do
- context 'on a Commit' do
- it 'returns a proper URL' do
+ context "when passing a Note" do
+ context "on a Commit" do
+ it "returns a proper URL" do
note = build_stubbed(:note_on_commit)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
end
end
- context 'on a Commit Diff' do
- it 'returns a proper URL' do
+ context "on a Commit Diff" do
+ it "returns a proper URL" do
note = build_stubbed(:diff_note_on_commit)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{note.project.full_path}/commit/#{note.commit_id}#note_#{note.id}"
end
end
- context 'on an Issue' do
- it 'returns a proper URL' do
+ context "on an Issue" do
+ it "returns a proper URL" do
issue = create(:issue, iid: 42)
note = build_stubbed(:note_on_issue, noteable: issue)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{issue.project.full_path}/issues/#{issue.iid}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{issue.project.full_path}/issues/#{issue.iid}#note_#{note.id}"
end
end
- context 'on a MergeRequest' do
- it 'returns a proper URL' do
+ context "on a MergeRequest" do
+ it "returns a proper URL" do
merge_request = create(:merge_request, iid: 42)
note = build_stubbed(:note_on_merge_request, noteable: merge_request)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
end
end
- context 'on a MergeRequest Diff' do
- it 'returns a proper URL' do
+ context "on a MergeRequest Diff" do
+ it "returns a proper URL" do
merge_request = create(:merge_request, iid: 42)
note = build_stubbed(:diff_note_on_merge_request, noteable: merge_request)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{merge_request.project.full_path}/merge_requests/#{merge_request.iid}#note_#{note.id}"
end
end
- context 'on a ProjectSnippet' do
- it 'returns a proper URL' do
+ context "on a ProjectSnippet" do
+ it "returns a proper URL" do
project_snippet = create(:project_snippet)
note = build_stubbed(:note_on_project_snippet, noteable: project_snippet)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/#{project_snippet.project.full_path}/snippets/#{note.noteable_id}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/#{project_snippet.project.full_path}/snippets/#{note.noteable_id}#note_#{note.id}"
end
end
- context 'on a PersonalSnippet' do
- it 'returns a proper URL' do
+ context "on a PersonalSnippet" do
+ it "returns a proper URL" do
personal_snippet = create(:personal_snippet)
note = build_stubbed(:note_on_personal_snippet, noteable: personal_snippet)
url = described_class.build(note)
- expect(url).to eq "#{Settings.gitlab['url']}/snippets/#{note.noteable_id}#note_#{note.id}"
+ expect(url).to eq "#{Settings.gitlab["url"]}/snippets/#{note.noteable_id}#note_#{note.id}"
end
end
- context 'on another object' do
- it 'returns a proper URL' do
+ context "on another object" do
+ it "returns a proper URL" do
project = build_stubbed(:project)
expect { described_class.build(project) }
- .to raise_error(NotImplementedError, 'No URL builder defined for Project')
+ .to raise_error(NotImplementedError, "No URL builder defined for Project")
end
end
end
- context 'when passing a WikiPage' do
- it 'returns a proper URL' do
+ context "when passing a WikiPage" do
+ it "returns a proper URL" do
wiki_page = build(:wiki_page)
url = described_class.build(wiki_page)
diff --git a/spec/lib/gitlab/url_sanitizer_spec.rb b/spec/lib/gitlab/url_sanitizer_spec.rb
index 6e98a999766..29ad3c6ff1e 100644
--- a/spec/lib/gitlab/url_sanitizer_spec.rb
+++ b/spec/lib/gitlab/url_sanitizer_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UrlSanitizer do
using RSpec::Parameterized::TableSyntax
- describe '.sanitize' do
+ describe ".sanitize" do
def sanitize_url(url)
# We want to try with multi-line content because is how error messages are formatted
- described_class.sanitize(%Q{
+ described_class.sanitize(%(
remote: Not Found
fatal: repository '#{url}' not found
- })
+ ))
end
where(:input, :output) do
- 'http://user:pass@test.com/root/repoC.git/' | 'http://*****:*****@test.com/root/repoC.git/'
- 'https://user:pass@test.com/root/repoA.git/' | 'https://*****:*****@test.com/root/repoA.git/'
- 'ssh://user@host.test/path/to/repo.git' | 'ssh://*****@host.test/path/to/repo.git'
+ "http://user:pass@test.com/root/repoC.git/" | "http://*****:*****@test.com/root/repoC.git/"
+ "https://user:pass@test.com/root/repoA.git/" | "https://*****:*****@test.com/root/repoA.git/"
+ "ssh://user@host.test/path/to/repo.git" | "ssh://*****@host.test/path/to/repo.git"
# git protocol does not support authentication but clean any details anyway
- 'git://user:pass@host.test/path/to/repo.git' | 'git://*****:*****@host.test/path/to/repo.git'
- 'git://host.test/path/to/repo.git' | 'git://host.test/path/to/repo.git'
+ "git://user:pass@host.test/path/to/repo.git" | "git://*****:*****@host.test/path/to/repo.git"
+ "git://host.test/path/to/repo.git" | "git://host.test/path/to/repo.git"
# SCP-style URLs are left unmodified
- 'user@server:project.git' | 'user@server:project.git'
- 'user:pass@server:project.git' | 'user:pass@server:project.git'
+ "user@server:project.git" | "user@server:project.git"
+ "user:pass@server:project.git" | "user:pass@server:project.git"
# return an empty string for invalid URLs
- 'ssh://' | ''
+ "ssh://" | ""
end
with_them do
@@ -34,23 +34,23 @@ describe Gitlab::UrlSanitizer do
end
end
- describe '.valid?' do
+ describe ".valid?" do
where(:value, :url) do
false | nil
- false | ''
- false | '123://invalid:url'
- false | 'valid@project:url.git'
- false | 'valid:pass@project:url.git'
- false | %w(test array)
- true | 'ssh://example.com'
- true | 'ssh://:@example.com'
- true | 'ssh://foo@example.com'
- true | 'ssh://foo:bar@example.com'
- true | 'ssh://foo:bar@example.com/group/group/project.git'
- true | 'git://example.com/group/group/project.git'
- true | 'git://foo:bar@example.com/group/group/project.git'
- true | 'http://foo:bar@example.com/group/group/project.git'
- true | 'https://foo:bar@example.com/group/group/project.git'
+ false | ""
+ false | "123://invalid:url"
+ false | "valid@project:url.git"
+ false | "valid:pass@project:url.git"
+ false | %w[test array]
+ true | "ssh://example.com"
+ true | "ssh://:@example.com"
+ true | "ssh://foo@example.com"
+ true | "ssh://foo:bar@example.com"
+ true | "ssh://foo:bar@example.com/group/group/project.git"
+ true | "git://example.com/group/group/project.git"
+ true | "git://foo:bar@example.com/group/group/project.git"
+ true | "http://foo:bar@example.com/group/group/project.git"
+ true | "https://foo:bar@example.com/group/group/project.git"
end
with_them do
@@ -58,53 +58,53 @@ describe Gitlab::UrlSanitizer do
end
end
- describe '#sanitized_url' do
- context 'credentials in hash' do
- where(username: ['foo', '', nil], password: ['bar', '', nil])
+ describe "#sanitized_url" do
+ context "credentials in hash" do
+ where(username: ["foo", "", nil], password: ["bar", "", nil])
with_them do
- let(:credentials) { { user: username, password: password } }
- subject { described_class.new('http://example.com', credentials: credentials).sanitized_url }
+ let(:credentials) { {user: username, password: password} }
+ subject { described_class.new("http://example.com", credentials: credentials).sanitized_url }
- it { is_expected.to eq('http://example.com') }
+ it { is_expected.to eq("http://example.com") }
end
end
- context 'credentials in URL' do
+ context "credentials in URL" do
where(userinfo: %w[foo:bar@ foo@ :bar@ :@ @] + [nil])
with_them do
subject { described_class.new("http://#{userinfo}example.com").sanitized_url }
- it { is_expected.to eq('http://example.com') }
+ it { is_expected.to eq("http://example.com") }
end
end
end
- describe '#credentials' do
- context 'credentials in hash' do
- it 'overrides URL-provided credentials' do
- sanitizer = described_class.new('http://a:b@example.com', credentials: { user: 'c', password: 'd' })
+ describe "#credentials" do
+ context "credentials in hash" do
+ it "overrides URL-provided credentials" do
+ sanitizer = described_class.new("http://a:b@example.com", credentials: {user: "c", password: "d"})
- expect(sanitizer.credentials).to eq(user: 'c', password: 'd')
+ expect(sanitizer.credentials).to eq(user: "c", password: "d")
end
end
- context 'credentials in URL' do
+ context "credentials in URL" do
where(:url, :credentials) do
- 'http://foo:bar@example.com' | { user: 'foo', password: 'bar' }
- 'http://foo:bar:baz@example.com' | { user: 'foo', password: 'bar:baz' }
- 'http://:bar@example.com' | { user: nil, password: 'bar' }
- 'http://foo:@example.com' | { user: 'foo', password: nil }
- 'http://foo@example.com' | { user: 'foo', password: nil }
- 'http://:@example.com' | { user: nil, password: nil }
- 'http://@example.com' | { user: nil, password: nil }
- 'http://example.com' | { user: nil, password: nil }
+ "http://foo:bar@example.com" | {user: "foo", password: "bar"}
+ "http://foo:bar:baz@example.com" | {user: "foo", password: "bar:baz"}
+ "http://:bar@example.com" | {user: nil, password: "bar"}
+ "http://foo:@example.com" | {user: "foo", password: nil}
+ "http://foo@example.com" | {user: "foo", password: nil}
+ "http://:@example.com" | {user: nil, password: nil}
+ "http://@example.com" | {user: nil, password: nil}
+ "http://example.com" | {user: nil, password: nil}
# Other invalid URLs
- nil | { user: nil, password: nil }
- '' | { user: nil, password: nil }
- 'no' | { user: nil, password: nil }
+ nil | {user: nil, password: nil}
+ "" | {user: nil, password: nil}
+ "no" | {user: nil, password: nil}
end
with_them do
@@ -115,41 +115,41 @@ describe Gitlab::UrlSanitizer do
end
end
- describe '#full_url' do
- context 'credentials in hash' do
+ describe "#full_url" do
+ context "credentials in hash" do
where(:credentials, :userinfo) do
- { user: 'foo', password: 'bar' } | 'foo:bar@'
- { user: 'foo', password: '' } | 'foo@'
- { user: 'foo', password: nil } | 'foo@'
- { user: '', password: 'bar' } | ':bar@'
- { user: '', password: '' } | nil
- { user: '', password: nil } | nil
- { user: nil, password: 'bar' } | ':bar@'
- { user: nil, password: '' } | nil
- { user: nil, password: nil } | nil
+ {user: "foo", password: "bar"} | "foo:bar@"
+ {user: "foo", password: ""} | "foo@"
+ {user: "foo", password: nil} | "foo@"
+ {user: "", password: "bar"} | ":bar@"
+ {user: "", password: ""} | nil
+ {user: "", password: nil} | nil
+ {user: nil, password: "bar"} | ":bar@"
+ {user: nil, password: ""} | nil
+ {user: nil, password: nil} | nil
end
with_them do
- subject { described_class.new('http://example.com', credentials: credentials).full_url }
+ subject { described_class.new("http://example.com", credentials: credentials).full_url }
it { is_expected.to eq("http://#{userinfo}example.com") }
end
end
- context 'credentials in URL' do
+ context "credentials in URL" do
where(:input, :output) do
- nil | ''
- '' | :same
- 'git@example.com' | :same
- 'http://example.com' | :same
- 'http://foo@example.com' | :same
- 'http://foo:@example.com' | 'http://foo@example.com'
- 'http://:bar@example.com' | :same
- 'http://foo:bar@example.com' | :same
- 'http://foo:g p@example.com' | 'http://foo:g%20p@example.com'
- 'http://foo:s/h@example.com' | 'http://foo:s%2Fh@example.com'
- 'http://t u:a#b@example.com' | 'http://t%20u:a%23b@example.com'
- 'http://t+u:a#b@example.com' | 'http://t%2Bu:a%23b@example.com'
+ nil | ""
+ "" | :same
+ "git@example.com" | :same
+ "http://example.com" | :same
+ "http://foo@example.com" | :same
+ "http://foo:@example.com" | "http://foo@example.com"
+ "http://:bar@example.com" | :same
+ "http://foo:bar@example.com" | :same
+ "http://foo:g p@example.com" | "http://foo:g%20p@example.com"
+ "http://foo:s/h@example.com" | "http://foo:s%2Fh@example.com"
+ "http://t u:a#b@example.com" | "http://t%20u:a%23b@example.com"
+ "http://t+u:a#b@example.com" | "http://t%2Bu:a%23b@example.com"
end
with_them do
@@ -160,8 +160,8 @@ describe Gitlab::UrlSanitizer do
end
end
- context 'when credentials contains special chars' do
- it 'should parse the URL without errors' do
+ context "when credentials contains special chars" do
+ it "should parse the URL without errors" do
url_sanitizer = described_class.new("https://foo:b?r@github.com/me/project.git")
expect(url_sanitizer.sanitized_url).to eq("https://github.com/me/project.git")
diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb
index d3eae80cc56..b2297ca5217 100644
--- a/spec/lib/gitlab/usage_data_spec.rb
+++ b/spec/lib/gitlab/usage_data_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UsageData do
let(:projects) { create_list(:project, 3) }
let!(:board) { create(:board, project: projects[0]) }
- describe '#data' do
+ describe "#data" do
before do
create(:jira_service, project: projects[0])
create(:jira_service, project: projects[1])
create(:jira_cloud_service, project: projects[2])
create(:prometheus_service, project: projects[1])
- create(:service, project: projects[0], type: 'SlackSlashCommandsService', active: true)
- create(:service, project: projects[1], type: 'SlackService', active: true)
- create(:service, project: projects[2], type: 'SlackService', active: true)
+ create(:service, project: projects[0], type: "SlackSlashCommandsService", active: true)
+ create(:service, project: projects[1], type: "SlackService", active: true)
+ create(:service, project: projects[2], type: "SlackService", active: true)
gcp_cluster = create(:cluster, :provided_by_gcp)
create(:cluster, :provided_by_user)
@@ -27,13 +27,13 @@ describe Gitlab::UsageData do
create(:clusters_applications_runner, :installed, cluster: gcp_cluster)
create(:clusters_applications_knative, :installed, cluster: gcp_cluster)
- ProjectFeature.first.update_attribute('repository_access_level', 0)
+ ProjectFeature.first.update_attribute("repository_access_level", 0)
end
subject { described_class.data }
it "gathers usage data" do
- expect(subject.keys).to match_array(%i(
+ expect(subject.keys).to match_array(%i[
active_user_count
counts
recorded_at
@@ -55,7 +55,7 @@ describe Gitlab::UsageData do
database
avg_cycle_analytics
web_ide_commits
- ))
+ ])
end
it "gathers usage counts" do
@@ -64,7 +64,7 @@ describe Gitlab::UsageData do
expect(count_data[:boards]).to eq(1)
expect(count_data[:projects]).to eq(3)
- expect(count_data.keys).to match_array(%i(
+ expect(count_data.keys).to match_array(%i[
assignee_lists
boards
ci_builds
@@ -125,15 +125,15 @@ describe Gitlab::UsageData do
uploads
web_hooks
user_preferences
- ))
+ ])
end
- it 'does not gather user preferences usage data when the feature is disabled' do
+ it "does not gather user preferences usage data when the feature is disabled" do
stub_feature_flags(group_overview_security_dashboard: false)
expect(subject[:counts].keys).not_to include(:user_preferences)
end
- it 'gathers projects data correctly' do
+ it "gathers projects data correctly" do
count_data = subject[:counts]
expect(count_data[:projects]).to eq(3)
@@ -162,18 +162,18 @@ describe Gitlab::UsageData do
expect(count_data[:clusters_applications_knative]).to eq(1)
end
- it 'works when queries time out' do
+ it "works when queries time out" do
allow_any_instance_of(ActiveRecord::Relation)
- .to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(''))
+ .to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(""))
expect { subject }.not_to raise_error
end
end
- describe '#features_usage_data_ce' do
+ describe "#features_usage_data_ce" do
subject { described_class.features_usage_data_ce }
- it 'gathers feature usage data' do
+ it "gathers feature usage data" do
expect(subject[:mattermost_enabled]).to eq(Gitlab.config.mattermost.enabled)
expect(subject[:signup_enabled]).to eq(Gitlab::CurrentSettings.allow_signup?)
expect(subject[:ldap_enabled]).to eq(Gitlab.config.ldap.enabled)
@@ -185,10 +185,10 @@ describe Gitlab::UsageData do
end
end
- describe '#components_usage_data' do
+ describe "#components_usage_data" do
subject { described_class.components_usage_data }
- it 'gathers components usage data' do
+ it "gathers components usage data" do
expect(subject[:gitlab_pages][:enabled]).to eq(Gitlab.config.pages.enabled)
expect(subject[:gitlab_pages][:version]).to eq(Gitlab::Pages::VERSION)
expect(subject[:git][:version]).to eq(Gitlab::Git.version)
@@ -197,7 +197,7 @@ describe Gitlab::UsageData do
end
end
- describe '#license_usage_data' do
+ describe "#license_usage_data" do
subject { described_class.license_usage_data }
it "gathers license data" do
@@ -209,24 +209,24 @@ describe Gitlab::UsageData do
end
end
- describe '#count' do
+ describe "#count" do
let(:relation) { double(:relation) }
- it 'returns the count when counting succeeds' do
+ it "returns the count when counting succeeds" do
allow(relation).to receive(:count).and_return(1)
expect(described_class.count(relation)).to eq(1)
end
- it 'returns the fallback value when counting fails' do
- allow(relation).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(''))
+ it "returns the fallback value when counting fails" do
+ allow(relation).to receive(:count).and_raise(ActiveRecord::StatementInvalid.new(""))
expect(described_class.count(relation, fallback: 15)).to eq(15)
end
end
- describe '#approximate_counts' do
- it 'gets approximate counts for selected models' do
+ describe "#approximate_counts" do
+ it "gets approximate counts for selected models" do
create(:label)
expect(Gitlab::Database::Count).to receive(:approximate_counts)
@@ -238,7 +238,7 @@ describe Gitlab::UsageData do
expect(counts.any? { |count| count < 0 }).to be_falsey
end
- it 'returns default values if counts can not be retrieved' do
+ it "returns default values if counts can not be retrieved" do
described_class::APPROXIMATE_COUNT_MODELS.map do |model|
model.name.underscore.pluralize.to_sym
end
diff --git a/spec/lib/gitlab/user_access_spec.rb b/spec/lib/gitlab/user_access_spec.rb
index 9da06bb40f4..414f8d2d122 100644
--- a/spec/lib/gitlab/user_access_spec.rb
+++ b/spec/lib/gitlab/user_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UserAccess do
include ProjectForksHelper
@@ -7,132 +7,132 @@ describe Gitlab::UserAccess do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- describe '#can_push_to_branch?' do
- describe 'push to none protected branch' do
- it 'returns true if user is a maintainer' do
+ describe "#can_push_to_branch?" do
+ describe "push to none protected branch" do
+ it "returns true if user is a maintainer" do
project.add_maintainer(user)
- expect(access.can_push_to_branch?('random_branch')).to be_truthy
+ expect(access.can_push_to_branch?("random_branch")).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_developer(user)
- expect(access.can_push_to_branch?('random_branch')).to be_truthy
+ expect(access.can_push_to_branch?("random_branch")).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_reporter(user)
- expect(access.can_push_to_branch?('random_branch')).to be_falsey
+ expect(access.can_push_to_branch?("random_branch")).to be_falsey
end
end
- describe 'push to empty project' do
+ describe "push to empty project" do
let(:empty_project) { create(:project_empty_repo) }
let(:project_access) { described_class.new(user, project: empty_project) }
- it 'returns true for admins' do
+ it "returns true for admins" do
user.update!(admin: true)
- expect(access.can_push_to_branch?('master')).to be_truthy
+ expect(access.can_push_to_branch?("master")).to be_truthy
end
- it 'returns true if user is maintainer' do
+ it "returns true if user is maintainer" do
empty_project.add_maintainer(user)
- expect(project_access.can_push_to_branch?('master')).to be_truthy
+ 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
+ it "returns false if user is developer and project is fully protected" do
empty_project.add_developer(user)
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
- expect(project_access.can_push_to_branch?('master')).to be_falsey
+ 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
+ it "returns false if user is developer and it is not allowed to push new commits but can merge into branch" do
empty_project.add_developer(user)
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
- expect(project_access.can_push_to_branch?('master')).to be_falsey
+ expect(project_access.can_push_to_branch?("master")).to be_falsey
end
- it 'returns true if user is developer and project is unprotected' do
+ it "returns true if user is developer and project is unprotected" do
empty_project.add_developer(user)
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
- expect(project_access.can_push_to_branch?('master')).to be_truthy
+ 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
+ it "returns true if user is developer and project grants developers permission" do
empty_project.add_developer(user)
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
- expect(project_access.can_push_to_branch?('master')).to be_truthy
+ expect(project_access.can_push_to_branch?("master")).to be_truthy
end
end
- describe 'push to protected branch' do
+ describe "push to protected branch" do
let(:branch) { create :protected_branch, project: project, name: "test" }
let(:not_existing_branch) { create :protected_branch, :developers_can_merge, project: project }
- it 'returns true for admins' do
+ it "returns true for admins" do
user.update!(admin: true)
expect(access.can_push_to_branch?(branch.name)).to be_truthy
end
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_maintainer(user)
expect(access.can_push_to_branch?(branch.name)).to be_truthy
end
- it 'returns false if user is a developer' do
+ it "returns false if user is a developer" do
project.add_developer(user)
expect(access.can_push_to_branch?(branch.name)).to be_falsey
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_reporter(user)
expect(access.can_push_to_branch?(branch.name)).to be_falsey
end
- it 'returns false if branch does not exist' do
+ it "returns false if branch does not exist" do
project.add_developer(user)
expect(access.can_push_to_branch?(not_existing_branch.name)).to be_falsey
end
end
- describe 'push to protected branch if allowed for developers' do
+ describe "push to protected branch if allowed for developers" do
before do
@branch = create :protected_branch, :developers_can_push, project: project
end
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_maintainer(user)
expect(access.can_push_to_branch?(@branch.name)).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_developer(user)
expect(access.can_push_to_branch?(@branch.name)).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_reporter(user)
expect(access.can_push_to_branch?(@branch.name)).to be_falsey
end
end
- describe 'allowing pushes to maintainers of forked projects' do
+ describe "allowing pushes to maintainers of forked projects" do
let(:canonical_project) { create(:project, :public, :repository) }
let(:project) { fork_project(canonical_project, create(:user), repository: true) }
@@ -141,48 +141,48 @@ describe Gitlab::UserAccess do
:merge_request,
target_project: canonical_project,
source_project: project,
- source_branch: 'awesome-feature',
+ source_branch: "awesome-feature",
allow_collaboration: true
)
end
- it 'allows users that have push access to the canonical project to push to the MR branch' do
+ it "allows users that have push access to the canonical project to push to the MR branch" do
canonical_project.add_developer(user)
- expect(access.can_push_to_branch?('awesome-feature')).to be_truthy
+ expect(access.can_push_to_branch?("awesome-feature")).to be_truthy
end
- it 'does not allow the user to push to other branches' do
+ it "does not allow the user to push to other branches" do
canonical_project.add_developer(user)
- expect(access.can_push_to_branch?('master')).to be_falsey
+ expect(access.can_push_to_branch?("master")).to be_falsey
end
- it 'does not allow the user to push if he does not have push access to the canonical project' do
+ it "does not allow the user to push if he does not have push access to the canonical project" do
canonical_project.add_guest(user)
- expect(access.can_push_to_branch?('awesome-feature')).to be_falsey
+ expect(access.can_push_to_branch?("awesome-feature")).to be_falsey
end
end
- describe 'merge to protected branch if allowed for developers' do
+ describe "merge to protected branch if allowed for developers" do
before do
@branch = create :protected_branch, :developers_can_merge, project: project
end
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_maintainer(user)
expect(access.can_merge_to_branch?(@branch.name)).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_developer(user)
expect(access.can_merge_to_branch?(@branch.name)).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_reporter(user)
expect(access.can_merge_to_branch?(@branch.name)).to be_falsey
@@ -190,68 +190,68 @@ describe Gitlab::UserAccess do
end
end
- describe '#can_create_tag?' do
- describe 'push to none protected tag' do
- it 'returns true if user is a maintainer' do
+ describe "#can_create_tag?" do
+ describe "push to none protected tag" do
+ it "returns true if user is a maintainer" do
project.add_user(user, :maintainer)
- expect(access.can_create_tag?('random_tag')).to be_truthy
+ expect(access.can_create_tag?("random_tag")).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_user(user, :developer)
- expect(access.can_create_tag?('random_tag')).to be_truthy
+ expect(access.can_create_tag?("random_tag")).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_user(user, :reporter)
- expect(access.can_create_tag?('random_tag')).to be_falsey
+ expect(access.can_create_tag?("random_tag")).to be_falsey
end
end
- describe 'push to protected tag' do
+ describe "push to protected tag" do
let(:tag) { create(:protected_tag, project: project, name: "test") }
let(:not_existing_tag) { create :protected_tag, project: project }
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_user(user, :maintainer)
expect(access.can_create_tag?(tag.name)).to be_truthy
end
- it 'returns false if user is a developer' do
+ it "returns false if user is a developer" do
project.add_user(user, :developer)
expect(access.can_create_tag?(tag.name)).to be_falsey
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_user(user, :reporter)
expect(access.can_create_tag?(tag.name)).to be_falsey
end
end
- describe 'push to protected tag if allowed for developers' do
+ describe "push to protected tag if allowed for developers" do
before do
@tag = create(:protected_tag, :developers_can_create, project: project)
end
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_user(user, :maintainer)
expect(access.can_create_tag?(@tag.name)).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_user(user, :developer)
expect(access.can_create_tag?(@tag.name)).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_user(user, :reporter)
expect(access.can_create_tag?(@tag.name)).to be_falsey
@@ -259,43 +259,43 @@ describe Gitlab::UserAccess do
end
end
- describe '#can_delete_branch?' do
- describe 'delete unprotected branch' do
- it 'returns true if user is a maintainer' do
+ describe "#can_delete_branch?" do
+ describe "delete unprotected branch" do
+ it "returns true if user is a maintainer" do
project.add_user(user, :maintainer)
- expect(access.can_delete_branch?('random_branch')).to be_truthy
+ expect(access.can_delete_branch?("random_branch")).to be_truthy
end
- it 'returns true if user is a developer' do
+ it "returns true if user is a developer" do
project.add_user(user, :developer)
- expect(access.can_delete_branch?('random_branch')).to be_truthy
+ expect(access.can_delete_branch?("random_branch")).to be_truthy
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_user(user, :reporter)
- expect(access.can_delete_branch?('random_branch')).to be_falsey
+ expect(access.can_delete_branch?("random_branch")).to be_falsey
end
end
- describe 'delete protected branch' do
+ describe "delete protected branch" do
let(:branch) { create(:protected_branch, project: project, name: "test") }
- it 'returns true if user is a maintainer' do
+ it "returns true if user is a maintainer" do
project.add_user(user, :maintainer)
expect(access.can_delete_branch?(branch.name)).to be_truthy
end
- it 'returns false if user is a developer' do
+ it "returns false if user is a developer" do
project.add_user(user, :developer)
expect(access.can_delete_branch?(branch.name)).to be_falsey
end
- it 'returns false if user is a reporter' do
+ it "returns false if user is a reporter" do
project.add_user(user, :reporter)
expect(access.can_delete_branch?(branch.name)).to be_falsey
diff --git a/spec/lib/gitlab/user_extractor_spec.rb b/spec/lib/gitlab/user_extractor_spec.rb
index fcc05ab3a0c..bec25da0ceb 100644
--- a/spec/lib/gitlab/user_extractor_spec.rb
+++ b/spec/lib/gitlab/user_extractor_spec.rb
@@ -1,58 +1,58 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::UserExtractor do
let(:text) do
<<~TXT
- This is a long texth that mentions some users.
- @user-1, @user-2 and user@gitlab.org take a walk in the park.
- There they meet @user-4 that was out with other-user@gitlab.org.
- @user-1 thought it was late, so went home straight away
+ This is a long texth that mentions some users.
+ @user-1, @user-2 and user@gitlab.org take a walk in the park.
+ There they meet @user-4 that was out with other-user@gitlab.org.
+ @user-1 thought it was late, so went home straight away
TXT
end
subject(:extractor) { described_class.new(text) }
- describe '#users' do
- it 'returns an empty relation when nil was passed' do
+ describe "#users" do
+ it "returns an empty relation when nil was passed" do
extractor = described_class.new(nil)
expect(extractor.users).to be_empty
expect(extractor.users).to be_a(ActiveRecord::Relation)
end
- it 'returns the user case insensitive for usernames' do
+ it "returns the user case insensitive for usernames" do
user = create(:user, username: "USER-4")
expect(extractor.users).to include(user)
end
- it 'returns users by primary email' do
- user = create(:user, email: 'user@gitlab.org')
+ it "returns users by primary email" do
+ user = create(:user, email: "user@gitlab.org")
expect(extractor.users).to include(user)
end
- it 'returns users by secondary email' do
- user = create(:email, email: 'other-user@gitlab.org').user
+ it "returns users by secondary email" do
+ user = create(:email, email: "other-user@gitlab.org").user
expect(extractor.users).to include(user)
end
end
- describe '#matches' do
- it 'includes all mentioned email adresses' do
- expect(extractor.matches[:emails]).to contain_exactly('user@gitlab.org', 'other-user@gitlab.org')
+ describe "#matches" do
+ it "includes all mentioned email adresses" do
+ expect(extractor.matches[:emails]).to contain_exactly("user@gitlab.org", "other-user@gitlab.org")
end
- it 'includes all mentioned usernames' do
- expect(extractor.matches[:usernames]).to contain_exactly('user-1', 'user-2', 'user-4')
+ it "includes all mentioned usernames" do
+ expect(extractor.matches[:usernames]).to contain_exactly("user-1", "user-2", "user-4")
end
end
- describe '#references' do
- it 'includes all user-references once' do
- expect(extractor.references).to contain_exactly('user-1', 'user-2', 'user@gitlab.org', 'user-4', 'other-user@gitlab.org')
+ describe "#references" do
+ it "includes all user-references once" do
+ expect(extractor.references).to contain_exactly("user-1", "user-2", "user@gitlab.org", "user-4", "other-user@gitlab.org")
end
end
end
diff --git a/spec/lib/gitlab/utils/merge_hash_spec.rb b/spec/lib/gitlab/utils/merge_hash_spec.rb
index 4fa7bb31301..38367f995bf 100644
--- a/spec/lib/gitlab/utils/merge_hash_spec.rb
+++ b/spec/lib/gitlab/utils/merge_hash_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Utils::MergeHash do
- describe '.crush' do
- it 'can flatten a hash to each element' do
- input = { hello: "world", this: { crushes: ["an entire", "hash"] } }
+ describe ".crush" do
+ it "can flatten a hash to each element" do
+ input = {hello: "world", this: {crushes: ["an entire", "hash"]}}
expected_result = [:hello, "world", :this, :crushes, "an entire", "hash"]
expect(described_class.crush(input)).to eq(expected_result)
end
end
- describe '.elements' do
- it 'deep merges an array of elements' do
- input = [{ hello: ["world"] },
- { hello: "Everyone" },
- { hello: { greetings: ['Bonjour', 'Hello', 'Hallo', 'Dzień dobry'] } },
- "Goodbye", "Hallo"]
+ describe ".elements" do
+ it "deep merges an array of elements" do
+ input = [{hello: ["world"]},
+ {hello: "Everyone"},
+ {hello: {greetings: ["Bonjour", "Hello", "Hallo", "Dzień dobry"]}},
+ "Goodbye", "Hallo",]
expected_output = [
{
hello:
[
"world",
"Everyone",
- { greetings: ['Bonjour', 'Hello', 'Hallo', 'Dzień dobry'] }
- ]
+ {greetings: ["Bonjour", "Hello", "Hallo", "Dzień dobry"]},
+ ],
},
- "Goodbye"
+ "Goodbye",
]
expect(described_class.merge(input)).to eq(expected_output)
diff --git a/spec/lib/gitlab/utils/override_spec.rb b/spec/lib/gitlab/utils/override_spec.rb
index 9e7c97f8095..19feb167d75 100644
--- a/spec/lib/gitlab/utils/override_spec.rb
+++ b/spec/lib/gitlab/utils/override_spec.rb
@@ -1,4 +1,4 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Gitlab::Utils::Override do
let(:base) do
@@ -57,8 +57,8 @@ describe Gitlab::Utils::Override do
mod
end
- shared_examples 'checking as intended' do
- it 'checks ok for overriding method' do
+ shared_examples "checking as intended" do
+ it "checks ok for overriding method" do
good(subject)
result = instance.good
@@ -66,7 +66,7 @@ describe Gitlab::Utils::Override do
described_class.verify!
end
- it 'checks ok for overriding method using negative arity' do
+ it "checks ok for overriding method using negative arity" do
good(subject, negative_arity: true)
result = instance.good
@@ -74,43 +74,43 @@ describe Gitlab::Utils::Override do
described_class.verify!
end
- it 'raises NotImplementedError when it is not overriding anything' do
- expect do
+ it "raises NotImplementedError when it is not overriding anything" do
+ expect {
bad(subject)
instance.bad
described_class.verify!
- end.to raise_error(NotImplementedError)
+ }.to raise_error(NotImplementedError)
end
- it 'raises NotImplementedError when overriding a method with different arity' do
- expect do
+ it "raises NotImplementedError when overriding a method with different arity" do
+ expect {
good(subject, bad_arity: true)
instance.good(1)
described_class.verify!
- end.to raise_error(NotImplementedError)
+ }.to raise_error(NotImplementedError)
end
end
- shared_examples 'checking as intended, nothing was overridden' do
- it 'raises NotImplementedError because it is not overriding it' do
- expect do
+ shared_examples "checking as intended, nothing was overridden" do
+ it "raises NotImplementedError because it is not overriding it" do
+ expect {
good(subject)
instance.good
described_class.verify!
- end.to raise_error(NotImplementedError)
+ }.to raise_error(NotImplementedError)
end
- it 'raises NotImplementedError when it is not overriding anything' do
- expect do
+ it "raises NotImplementedError when it is not overriding anything" do
+ expect {
bad(subject)
instance.bad
described_class.verify!
- end.to raise_error(NotImplementedError)
+ }.to raise_error(NotImplementedError)
end
end
- shared_examples 'nothing happened' do
- it 'does not complain when it is overriding something' do
+ shared_examples "nothing happened" do
+ it "does not complain when it is overriding something" do
good(subject)
result = instance.good
@@ -118,7 +118,7 @@ describe Gitlab::Utils::Override do
described_class.verify!
end
- it 'does not complain when it is not overriding anything' do
+ it "does not complain when it is not overriding anything" do
bad(subject)
result = instance.bad
@@ -132,59 +132,59 @@ describe Gitlab::Utils::Override do
allow(described_class).to receive(:extensions).and_return({})
end
- describe '#override' do
- context 'when instance is klass.new(0)' do
+ describe "#override" do
+ context "when instance is klass.new(0)" do
let(:instance) { klass.new(0) }
- context 'when STATIC_VERIFICATION is set' do
+ context "when STATIC_VERIFICATION is set" do
before do
- stub_env('STATIC_VERIFICATION', 'true')
+ stub_env("STATIC_VERIFICATION", "true")
end
- context 'when subject is a class' do
+ context "when subject is a class" do
subject { derived }
- it_behaves_like 'checking as intended'
+ it_behaves_like "checking as intended"
end
- context 'when subject is a module, and class is prepending it' do
+ context "when subject is a module, and class is prepending it" do
subject { extension }
let(:klass) { prepending_class }
- it_behaves_like 'checking as intended'
+ it_behaves_like "checking as intended"
end
- context 'when subject is a module, and class is including it' do
+ context "when subject is a module, and class is including it" do
subject { extension }
let(:klass) { including_class }
- it_behaves_like 'checking as intended, nothing was overridden'
+ it_behaves_like "checking as intended, nothing was overridden"
end
end
- context 'when STATIC_VERIFICATION is not set' do
+ context "when STATIC_VERIFICATION is not set" do
before do
- stub_env('STATIC_VERIFICATION', nil)
+ stub_env("STATIC_VERIFICATION", nil)
end
- context 'when subject is a class' do
+ context "when subject is a class" do
subject { derived }
- it_behaves_like 'nothing happened'
+ it_behaves_like "nothing happened"
end
- context 'when subject is a module, and class is prepending it' do
+ context "when subject is a module, and class is prepending it" do
subject { extension }
let(:klass) { prepending_class }
- it_behaves_like 'nothing happened'
+ it_behaves_like "nothing happened"
end
- context 'when subject is a module, and class is including it' do
+ context "when subject is a module, and class is including it" do
subject { extension }
let(:klass) { including_class }
- it 'does not complain when it is overriding something' do
+ it "does not complain when it is overriding something" do
good(subject)
result = instance.good
@@ -192,7 +192,7 @@ describe Gitlab::Utils::Override do
described_class.verify!
end
- it 'does not complain when it is not overriding anything' do
+ it "does not complain when it is not overriding anything" do
bad(subject)
result = instance.bad
@@ -203,26 +203,26 @@ describe Gitlab::Utils::Override do
end
end
- context 'when instance is klass' do
+ context "when instance is klass" do
let(:instance) { klass }
- context 'when STATIC_VERIFICATION is set' do
+ context "when STATIC_VERIFICATION is set" do
before do
- stub_env('STATIC_VERIFICATION', 'true')
+ stub_env("STATIC_VERIFICATION", "true")
end
- context 'when subject is a module, and class is prepending it' do
+ context "when subject is a module, and class is prepending it" do
subject { extension }
let(:klass) { prepending_class_methods }
- it_behaves_like 'checking as intended'
+ it_behaves_like "checking as intended"
end
- context 'when subject is a module, and class is extending it' do
+ context "when subject is a module, and class is extending it" do
subject { extension }
let(:klass) { extending_class_methods }
- it_behaves_like 'checking as intended, nothing was overridden'
+ it_behaves_like "checking as intended, nothing was overridden"
end
end
end
diff --git a/spec/lib/gitlab/utils/strong_memoize_spec.rb b/spec/lib/gitlab/utils/strong_memoize_spec.rb
index 473f8100771..0c6e1809fdb 100644
--- a/spec/lib/gitlab/utils/strong_memoize_spec.rb
+++ b/spec/lib/gitlab/utils/strong_memoize_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Utils::StrongMemoize do
let(:klass) do
- struct = Struct.new(:value) do
+ struct = Struct.new(:value) {
def method_name
strong_memoize(:method_name) do
trace << value
@@ -13,7 +13,7 @@ describe Gitlab::Utils::StrongMemoize do
def trace
@trace ||= []
end
- end
+ }
struct.include(described_class)
struct
@@ -21,8 +21,8 @@ describe Gitlab::Utils::StrongMemoize do
subject(:object) { klass.new(value) }
- shared_examples 'caching the value' do
- it 'only calls the block once' do
+ shared_examples "caching the value" do
+ it "only calls the block once" do
value0 = object.method_name
value1 = object.method_name
@@ -31,7 +31,7 @@ describe Gitlab::Utils::StrongMemoize do
expect(object.trace).to contain_exactly(value)
end
- it 'returns and defines the instance variable for the exact value' do
+ it "returns and defines the instance variable for the exact value" do
returned_value = object.method_name
memoized_value = object.instance_variable_get(:@method_name)
@@ -40,20 +40,20 @@ describe Gitlab::Utils::StrongMemoize do
end
end
- describe '#strong_memoize' do
- [nil, false, true, 'value', 0, [0]].each do |value|
+ describe "#strong_memoize" do
+ [nil, false, true, "value", 0, [0]].each do |value|
context "with value #{value}" do
let(:value) { value }
- it_behaves_like 'caching the value'
+ it_behaves_like "caching the value"
end
end
end
- describe '#clear_memoization' do
- let(:value) { 'mepmep' }
+ describe "#clear_memoization" do
+ let(:value) { "mepmep" }
- it 'removes the instance variable' do
+ it "removes the instance variable" do
object.method_name
object.clear_memoization(:method_name)
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
index 8f5029b3565..0231a991bc8 100644
--- a/spec/lib/gitlab/utils_spec.rb
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Utils do
delegate :to_boolean, :boolean_to_yes_no, :slugify, :random_string, :which, :ensure_array_from_string,
- :bytes_to_megabytes, :append_path, :check_path_traversal!, to: :described_class
+ :bytes_to_megabytes, :append_path, :check_path_traversal!, to: :described_class
- describe '.check_path_traversal!' do
- it 'detects path traversal at the start of the string' do
- expect { check_path_traversal!('../foo') }.to raise_error(/Invalid path/)
+ describe ".check_path_traversal!" do
+ it "detects path traversal at the start of the string" do
+ expect { check_path_traversal!("../foo") }.to raise_error(/Invalid path/)
end
- it 'detects path traversal at the start of the string, even to just the subdirectory' do
- expect { check_path_traversal!('../') }.to raise_error(/Invalid path/)
+ it "detects path traversal at the start of the string, even to just the subdirectory" do
+ expect { check_path_traversal!("../") }.to raise_error(/Invalid path/)
end
- it 'detects path traversal in the middle of the string' do
- expect { check_path_traversal!('foo/../../bar') }.to raise_error(/Invalid path/)
+ it "detects path traversal in the middle of the string" do
+ expect { check_path_traversal!("foo/../../bar") }.to raise_error(/Invalid path/)
end
- it 'detects path traversal at the end of the string when slash-terminates' do
- expect { check_path_traversal!('foo/../') }.to raise_error(/Invalid path/)
+ it "detects path traversal at the end of the string when slash-terminates" do
+ expect { check_path_traversal!("foo/../") }.to raise_error(/Invalid path/)
end
- it 'detects path traversal at the end of the string' do
- expect { check_path_traversal!('foo/..') }.to raise_error(/Invalid path/)
+ it "detects path traversal at the end of the string" do
+ expect { check_path_traversal!("foo/..") }.to raise_error(/Invalid path/)
end
- it 'does nothing for a safe string' do
- expect(check_path_traversal!('./foo')).to eq('./foo')
+ it "does nothing for a safe string" do
+ expect(check_path_traversal!("./foo")).to eq("./foo")
end
end
- describe '.slugify' do
+ describe ".slugify" do
{
- 'TEST' => 'test',
- 'project_with_underscores' => 'project-with-underscores',
- 'namespace/project' => 'namespace-project',
- 'a' * 70 => 'a' * 63,
- 'test_trailing_' => 'test-trailing'
+ "TEST" => "test",
+ "project_with_underscores" => "project-with-underscores",
+ "namespace/project" => "namespace-project",
+ "a" * 70 => "a" * 63,
+ "test_trailing_" => "test-trailing",
}.each do |original, expected|
it "slugifies #{original} to #{expected}" do
expect(slugify(original)).to eq(expected)
@@ -44,13 +44,13 @@ describe Gitlab::Utils do
end
end
- describe '.nlbr' do
- it 'replaces new lines with <br>' do
+ describe ".nlbr" do
+ it "replaces new lines with <br>" do
expect(described_class.nlbr("<b>hello</b>\n<i>world</i>".freeze)).to eq("hello<br>world")
end
end
- describe '.remove_line_breaks' do
+ describe ".remove_line_breaks" do
using RSpec::Parameterized::TableSyntax
where(:original, :expected) do
@@ -66,151 +66,151 @@ describe Gitlab::Utils do
end
end
- describe '.to_boolean' do
- it 'accepts booleans' do
+ describe ".to_boolean" do
+ it "accepts booleans" do
expect(to_boolean(true)).to be(true)
expect(to_boolean(false)).to be(false)
end
- it 'converts a valid string to a boolean' do
+ it "converts a valid string to a boolean" do
expect(to_boolean(true)).to be(true)
- expect(to_boolean('true')).to be(true)
- expect(to_boolean('YeS')).to be(true)
- expect(to_boolean('t')).to be(true)
- expect(to_boolean('1')).to be(true)
- expect(to_boolean('ON')).to be(true)
-
- expect(to_boolean('FaLse')).to be(false)
- expect(to_boolean('F')).to be(false)
- expect(to_boolean('NO')).to be(false)
- expect(to_boolean('n')).to be(false)
- expect(to_boolean('0')).to be(false)
- expect(to_boolean('oFF')).to be(false)
- end
-
- it 'converts an invalid string to nil' do
- expect(to_boolean('fals')).to be_nil
- expect(to_boolean('yeah')).to be_nil
- expect(to_boolean('')).to be_nil
+ expect(to_boolean("true")).to be(true)
+ expect(to_boolean("YeS")).to be(true)
+ expect(to_boolean("t")).to be(true)
+ expect(to_boolean("1")).to be(true)
+ expect(to_boolean("ON")).to be(true)
+
+ expect(to_boolean("FaLse")).to be(false)
+ expect(to_boolean("F")).to be(false)
+ expect(to_boolean("NO")).to be(false)
+ expect(to_boolean("n")).to be(false)
+ expect(to_boolean("0")).to be(false)
+ expect(to_boolean("oFF")).to be(false)
+ end
+
+ it "converts an invalid string to nil" do
+ expect(to_boolean("fals")).to be_nil
+ expect(to_boolean("yeah")).to be_nil
+ expect(to_boolean("")).to be_nil
expect(to_boolean(nil)).to be_nil
end
end
- describe '.boolean_to_yes_no' do
- it 'converts booleans to Yes or No' do
- expect(boolean_to_yes_no(true)).to eq('Yes')
- expect(boolean_to_yes_no(false)).to eq('No')
+ describe ".boolean_to_yes_no" do
+ it "converts booleans to Yes or No" do
+ expect(boolean_to_yes_no(true)).to eq("Yes")
+ expect(boolean_to_yes_no(false)).to eq("No")
end
end
- describe '.random_string' do
- it 'generates a string' do
+ describe ".random_string" do
+ it "generates a string" do
expect(random_string).to be_kind_of(String)
end
end
- describe '.which' do
- it 'finds the full path to an executable binary' do
- expect(File).to receive(:executable?).with('/bin/sh').and_return(true)
+ describe ".which" do
+ it "finds the full path to an executable binary" do
+ expect(File).to receive(:executable?).with("/bin/sh").and_return(true)
- expect(which('sh', 'PATH' => '/bin')).to eq('/bin/sh')
+ expect(which("sh", "PATH" => "/bin")).to eq("/bin/sh")
end
end
- describe '.ensure_array_from_string' do
- it 'returns the same array if given one' do
- arr = ['a', 4, true, { test: 1 }]
+ describe ".ensure_array_from_string" do
+ it "returns the same array if given one" do
+ arr = ["a", 4, true, {test: 1}]
expect(ensure_array_from_string(arr)).to eq(arr)
end
- it 'turns comma-separated strings into arrays' do
- str = 'seven, eight, 9, 10'
+ it "turns comma-separated strings into arrays" do
+ str = "seven, eight, 9, 10"
expect(ensure_array_from_string(str)).to eq(%w[seven eight 9 10])
end
end
- describe '.bytes_to_megabytes' do
- it 'converts bytes to megabytes' do
+ describe ".bytes_to_megabytes" do
+ it "converts bytes to megabytes" do
bytes = 1.megabyte
expect(bytes_to_megabytes(bytes)).to eq(1)
end
end
- describe '.append_path' do
+ describe ".append_path" do
using RSpec::Parameterized::TableSyntax
where(:host, :path, :result) do
- 'http://test/' | '/foo/bar' | 'http://test/foo/bar'
- 'http://test/' | '//foo/bar' | 'http://test/foo/bar'
- 'http://test//' | '/foo/bar' | 'http://test/foo/bar'
- 'http://test' | 'foo/bar' | 'http://test/foo/bar'
- 'http://test//' | '' | 'http://test/'
- 'http://test//' | nil | 'http://test/'
- '' | '/foo/bar' | '/foo/bar'
- nil | '/foo/bar' | '/foo/bar'
+ "http://test/" | "/foo/bar" | "http://test/foo/bar"
+ "http://test/" | "//foo/bar" | "http://test/foo/bar"
+ "http://test//" | "/foo/bar" | "http://test/foo/bar"
+ "http://test" | "foo/bar" | "http://test/foo/bar"
+ "http://test//" | "" | "http://test/"
+ "http://test//" | nil | "http://test/"
+ "" | "/foo/bar" | "/foo/bar"
+ nil | "/foo/bar" | "/foo/bar"
end
with_them do
- it 'makes sure there is only one slash as path separator' do
+ it "makes sure there is only one slash as path separator" do
expect(append_path(host, path)).to eq(result)
end
end
end
- describe '.ensure_utf8_size' do
- context 'string is has less bytes than expected' do
- it 'backfills string with null characters' do
- transformed = described_class.ensure_utf8_size('a' * 10, bytes: 32)
+ describe ".ensure_utf8_size" do
+ context "string is has less bytes than expected" do
+ it "backfills string with null characters" do
+ transformed = described_class.ensure_utf8_size("a" * 10, bytes: 32)
expect(transformed.bytesize).to eq 32
- expect(transformed).to eq(('a' * 10) + ('0' * 22))
+ expect(transformed).to eq(("a" * 10) + ("0" * 22))
end
end
- context 'string size is exactly the one that is expected' do
- it 'returns original value' do
- transformed = described_class.ensure_utf8_size('a' * 32, bytes: 32)
+ context "string size is exactly the one that is expected" do
+ it "returns original value" do
+ transformed = described_class.ensure_utf8_size("a" * 32, bytes: 32)
- expect(transformed).to eq 'a' * 32
+ expect(transformed).to eq "a" * 32
expect(transformed.bytesize).to eq 32
end
end
- context 'when string contains a few multi-byte UTF characters' do
- it 'backfills string with null characters' do
- transformed = described_class.ensure_utf8_size('❤' * 6, bytes: 32)
+ context "when string contains a few multi-byte UTF characters" do
+ it "backfills string with null characters" do
+ transformed = described_class.ensure_utf8_size("❤" * 6, bytes: 32)
- expect(transformed).to eq '❤❤❤❤❤❤' + ('0' * 14)
+ expect(transformed).to eq "❤❤❤❤❤❤" + ("0" * 14)
expect(transformed.bytesize).to eq 32
end
end
- context 'when string has multiple multi-byte UTF chars exceeding 32 bytes' do
- it 'truncates string to 32 characters and backfills it if needed' do
- transformed = described_class.ensure_utf8_size('❤' * 18, bytes: 32)
+ context "when string has multiple multi-byte UTF chars exceeding 32 bytes" do
+ it "truncates string to 32 characters and backfills it if needed" do
+ transformed = described_class.ensure_utf8_size("❤" * 18, bytes: 32)
- expect(transformed).to eq(('❤' * 10) + ('0' * 2))
+ expect(transformed).to eq(("❤" * 10) + ("0" * 2))
expect(transformed.bytesize).to eq 32
end
end
end
- describe '.deep_indifferent_access' do
+ describe ".deep_indifferent_access" do
let(:hash) do
- { "variables" => [{ "key" => "VAR1", "value" => "VALUE2" }] }
+ {"variables" => [{"key" => "VAR1", "value" => "VALUE2"}]}
end
subject { described_class.deep_indifferent_access(hash) }
- it 'allows to access hash keys with symbols' do
+ it "allows to access hash keys with symbols" do
expect(subject[:variables]).to be_a(Array)
end
- it 'allows to access array keys with symbols' do
- expect(subject[:variables].first[:key]).to eq('VAR1')
+ it "allows to access array keys with symbols" do
+ expect(subject[:variables].first[:key]).to eq("VAR1")
end
end
end
diff --git a/spec/lib/gitlab/verify/job_artifacts_spec.rb b/spec/lib/gitlab/verify/job_artifacts_spec.rb
index 6e916a56564..4163cf5e32c 100644
--- a/spec/lib/gitlab/verify/job_artifacts_spec.rb
+++ b/spec/lib/gitlab/verify/job_artifacts_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Verify::JobArtifacts do
include GitlabVerifyHelpers
- it_behaves_like 'Gitlab::Verify::BatchVerifier subclass' do
+ it_behaves_like "Gitlab::Verify::BatchVerifier subclass" do
let!(:objects) { create_list(:ci_job_artifact, 3, :archive) }
end
- describe '#run_batches' do
+ describe "#run_batches" do
let(:failures) { collect_failures }
let(:failure) { failures[artifact] }
let!(:artifact) { create(:ci_job_artifact, :archive, :correct_checksum) }
- it 'passes artifacts with the correct file' do
+ it "passes artifacts with the correct file" do
expect(failures).to eq({})
end
- it 'fails artifacts with a missing file' do
+ it "fails artifacts with a missing file" do
FileUtils.rm_f(artifact.file.path)
expect(failures.keys).to contain_exactly(artifact)
- expect(failure).to include('No such file or directory')
+ expect(failure).to include("No such file or directory")
expect(failure).to include(artifact.file.path)
end
- it 'fails artifacts with a mismatched checksum' do
+ it "fails artifacts with a mismatched checksum" do
File.truncate(artifact.file.path, 0)
expect(failures.keys).to contain_exactly(artifact)
- expect(failure).to include('Checksum mismatch')
+ expect(failure).to include("Checksum mismatch")
end
- context 'with remote files' do
+ context "with remote files" do
let(:file) { double(:file) }
before do
@@ -41,17 +41,17 @@ describe Gitlab::Verify::JobArtifacts do
expect(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
end
- it 'passes artifacts in object storage that exist' do
+ it "passes artifacts in object storage that exist" do
expect(file).to receive(:exists?).and_return(true)
expect(failures).to eq({})
end
- it 'fails artifacts in object storage that do not exist' do
+ it "fails artifacts in object storage that do not exist" do
expect(file).to receive(:exists?).and_return(false)
expect(failures.keys).to contain_exactly(artifact)
- expect(failure).to include('Remote object does not exist')
+ expect(failure).to include("Remote object does not exist")
end
end
end
diff --git a/spec/lib/gitlab/verify/lfs_objects_spec.rb b/spec/lib/gitlab/verify/lfs_objects_spec.rb
index 2feaedd6f14..7fdfce9c51d 100644
--- a/spec/lib/gitlab/verify/lfs_objects_spec.rb
+++ b/spec/lib/gitlab/verify/lfs_objects_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Verify::LfsObjects do
include GitlabVerifyHelpers
- it_behaves_like 'Gitlab::Verify::BatchVerifier subclass' do
+ it_behaves_like "Gitlab::Verify::BatchVerifier subclass" do
let!(:objects) { create_list(:lfs_object, 3, :with_file) }
end
- describe '#run_batches' do
+ describe "#run_batches" do
let(:failures) { collect_failures }
let(:failure) { failures[lfs_object] }
let!(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) }
- it 'passes LFS objects with the correct file' do
+ it "passes LFS objects with the correct file" do
expect(failures).to eq({})
end
- it 'fails LFS objects with a missing file' do
+ it "fails LFS objects with a missing file" do
FileUtils.rm_f(lfs_object.file.path)
expect(failures.keys).to contain_exactly(lfs_object)
- expect(failure).to include('No such file or directory')
+ expect(failure).to include("No such file or directory")
expect(failure).to include(lfs_object.file.path)
end
- it 'fails LFS objects with a mismatched oid' do
+ it "fails LFS objects with a mismatched oid" do
File.truncate(lfs_object.file.path, 0)
expect(failures.keys).to contain_exactly(lfs_object)
- expect(failure).to include('Checksum mismatch')
+ expect(failure).to include("Checksum mismatch")
end
- context 'with remote files' do
+ context "with remote files" do
let(:file) { double(:file) }
before do
@@ -41,17 +41,17 @@ describe Gitlab::Verify::LfsObjects do
expect(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
end
- it 'passes LFS objects in object storage that exist' do
+ it "passes LFS objects in object storage that exist" do
expect(file).to receive(:exists?).and_return(true)
expect(failures).to eq({})
end
- it 'fails LFS objects in object storage that do not exist' do
+ it "fails LFS objects in object storage that do not exist" do
expect(file).to receive(:exists?).and_return(false)
expect(failures.keys).to contain_exactly(lfs_object)
- expect(failure).to include('Remote object does not exist')
+ expect(failure).to include("Remote object does not exist")
end
end
end
diff --git a/spec/lib/gitlab/verify/uploads_spec.rb b/spec/lib/gitlab/verify/uploads_spec.rb
index 38c30fab1ba..945653f4851 100644
--- a/spec/lib/gitlab/verify/uploads_spec.rb
+++ b/spec/lib/gitlab/verify/uploads_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Verify::Uploads do
include GitlabVerifyHelpers
- it_behaves_like 'Gitlab::Verify::BatchVerifier subclass' do
+ it_behaves_like "Gitlab::Verify::BatchVerifier subclass" do
let(:projects) { create_list(:project, 3, :with_avatar) }
let!(:objects) { projects.flat_map(&:uploads) }
end
- describe '#run_batches' do
+ describe "#run_batches" do
let(:project) { create(:project, :with_avatar) }
let(:failures) { collect_failures }
let(:failure) { failures[upload] }
let!(:upload) { project.uploads.first }
- it 'passes uploads with the correct file' do
+ it "passes uploads with the correct file" do
expect(failures).to eq({})
end
- it 'fails uploads with a missing file' do
+ it "fails uploads with a missing file" do
FileUtils.rm_f(upload.absolute_path)
expect(failures.keys).to contain_exactly(upload)
- expect(failure).to include('No such file or directory')
+ expect(failure).to include("No such file or directory")
expect(failure).to include(upload.absolute_path)
end
- it 'fails uploads with a mismatched checksum' do
- upload.update!(checksum: 'something incorrect')
+ it "fails uploads with a mismatched checksum" do
+ upload.update!(checksum: "something incorrect")
expect(failures.keys).to contain_exactly(upload)
- expect(failure).to include('Checksum mismatch')
+ expect(failure).to include("Checksum mismatch")
end
- it 'fails uploads with a missing precalculated checksum' do
- upload.update!(checksum: '')
+ it "fails uploads with a missing precalculated checksum" do
+ upload.update!(checksum: "")
expect(failures.keys).to contain_exactly(upload)
- expect(failure).to include('Checksum missing')
+ expect(failure).to include("Checksum missing")
end
- context 'with remote files' do
+ context "with remote files" do
let(:file) { double(:file) }
before do
@@ -49,26 +49,26 @@ describe Gitlab::Verify::Uploads do
upload.update!(store: ObjectStorage::Store::REMOTE)
end
- describe 'returned hash object' do
+ describe "returned hash object" do
before do
expect(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
end
- it 'passes uploads in object storage that exist' do
+ it "passes uploads in object storage that exist" do
expect(file).to receive(:exists?).and_return(true)
expect(failures).to eq({})
end
- it 'fails uploads in object storage that do not exist' do
+ it "fails uploads in object storage that do not exist" do
expect(file).to receive(:exists?).and_return(false)
expect(failures.keys).to contain_exactly(upload)
- expect(failure).to include('Remote object does not exist')
+ expect(failure).to include("Remote object does not exist")
end
end
- describe 'performance' do
+ describe "performance" do
before do
allow(file).to receive(:exists?)
allow(CarrierWave::Storage::Fog::File).to receive(:new).and_return(file)
diff --git a/spec/lib/gitlab/version_info_spec.rb b/spec/lib/gitlab/version_info_spec.rb
index 30035c79e58..36af3003863 100644
--- a/spec/lib/gitlab/version_info_spec.rb
+++ b/spec/lib/gitlab/version_info_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Gitlab::VersionInfo' do
+describe "Gitlab::VersionInfo" do
before do
@unknown = Gitlab::VersionInfo.new
@v0_0_1 = Gitlab::VersionInfo.new(0, 0, 1)
@@ -11,7 +11,7 @@ describe 'Gitlab::VersionInfo' do
@v2_0_0 = Gitlab::VersionInfo.new(2, 0, 0)
end
- context '>' do
+ context ">" do
it { expect(@v2_0_0).to be > @v1_1_0 }
it { expect(@v1_1_0).to be > @v1_0_1 }
it { expect(@v1_0_1).to be > @v1_0_0 }
@@ -19,12 +19,12 @@ describe 'Gitlab::VersionInfo' do
it { expect(@v0_1_0).to be > @v0_0_1 }
end
- context '>=' do
+ context ">=" do
it { expect(@v2_0_0).to be >= Gitlab::VersionInfo.new(2, 0, 0) }
it { expect(@v2_0_0).to be >= @v1_1_0 }
end
- context '<' do
+ context "<" do
it { expect(@v0_0_1).to be < @v0_1_0 }
it { expect(@v0_1_0).to be < @v1_0_0 }
it { expect(@v1_0_0).to be < @v1_0_1 }
@@ -32,29 +32,29 @@ describe 'Gitlab::VersionInfo' do
it { expect(@v1_1_0).to be < @v2_0_0 }
end
- context '<=' do
+ context "<=" do
it { expect(@v0_0_1).to be <= Gitlab::VersionInfo.new(0, 0, 1) }
it { expect(@v0_0_1).to be <= @v0_1_0 }
end
- context '==' do
+ context "==" do
it { expect(@v0_0_1).to eq(Gitlab::VersionInfo.new(0, 0, 1)) }
it { expect(@v0_1_0).to eq(Gitlab::VersionInfo.new(0, 1, 0)) }
it { expect(@v1_0_0).to eq(Gitlab::VersionInfo.new(1, 0, 0)) }
end
- context '!=' do
+ context "!=" do
it { expect(@v0_0_1).not_to eq(@v0_1_0) }
end
- context 'unknown' do
+ context "unknown" do
it { expect(@unknown).not_to be @v0_0_1 }
it { expect(@unknown).not_to be Gitlab::VersionInfo.new }
it { expect {@unknown > @v0_0_1}.to raise_error(ArgumentError) }
it { expect {@unknown < @v0_0_1}.to raise_error(ArgumentError) }
end
- context 'parse' do
+ context "parse" do
it { expect(Gitlab::VersionInfo.parse("1.0.0")).to eq(@v1_0_0) }
it { expect(Gitlab::VersionInfo.parse("1.0.0.1")).to eq(@v1_0_0) }
it { expect(Gitlab::VersionInfo.parse("1.0.0-ee")).to eq(@v1_0_0) }
@@ -64,7 +64,7 @@ describe 'Gitlab::VersionInfo' do
it { expect(Gitlab::VersionInfo.parse("git 1.0b1")).not_to be_valid }
end
- context 'to_s' do
+ context "to_s" do
it { expect(@v1_0_0.to_s).to eq("1.0.0") }
it { expect(@unknown.to_s).to eq("Unknown") }
end
diff --git a/spec/lib/gitlab/view/presenter/base_spec.rb b/spec/lib/gitlab/view/presenter/base_spec.rb
index 02c2fd47197..8f88f79cc9a 100644
--- a/spec/lib/gitlab/view/presenter/base_spec.rb
+++ b/spec/lib/gitlab/view/presenter/base_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::View::Presenter::Base do
let(:project) { double(:project) }
@@ -6,16 +6,16 @@ describe Gitlab::View::Presenter::Base do
Struct.new(:subject).include(described_class)
end
- describe '.presenter?' do
- it 'returns true' do
+ describe ".presenter?" do
+ it "returns true" do
presenter = presenter_class.new(project)
expect(presenter.class).to be_presenter
end
end
- describe '.presents' do
- it 'exposes #subject with the given keyword' do
+ describe ".presents" do
+ it "exposes #subject with the given keyword" do
presenter_class.presents(:foo)
presenter = presenter_class.new(project)
@@ -23,25 +23,25 @@ describe Gitlab::View::Presenter::Base do
end
end
- describe '#can?' do
- context 'user is not allowed' do
- it 'returns false' do
+ describe "#can?" do
+ context "user is not allowed" do
+ it "returns false" do
presenter = presenter_class.new(build_stubbed(:project))
expect(presenter.can?(nil, :read_project)).to be_falsy
end
end
- context 'user is allowed' do
- it 'returns true' do
+ context "user is allowed" do
+ it "returns true" do
presenter = presenter_class.new(build_stubbed(:project, :public))
expect(presenter.can?(nil, :read_project)).to be_truthy
end
end
- context 'subject is overridden' do
- it 'returns true' do
+ context "subject is overridden" do
+ it "returns true" do
presenter = presenter_class.new(build_stubbed(:project, :public))
expect(presenter.can?(nil, :read_project, build_stubbed(:project))).to be_falsy
@@ -49,8 +49,8 @@ describe Gitlab::View::Presenter::Base do
end
end
- describe '#present' do
- it 'returns self' do
+ describe "#present" do
+ it "returns self" do
presenter = presenter_class.new(build_stubbed(:project))
expect(presenter.present).to eq(presenter)
end
diff --git a/spec/lib/gitlab/view/presenter/delegated_spec.rb b/spec/lib/gitlab/view/presenter/delegated_spec.rb
index 940a2ce6ebd..f81245e7406 100644
--- a/spec/lib/gitlab/view/presenter/delegated_spec.rb
+++ b/spec/lib/gitlab/view/presenter/delegated_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::View::Presenter::Delegated do
- let(:project) { double(:project, user: 'John Doe') }
+ let(:project) { double(:project, user: "John Doe") }
let(:presenter_class) do
Class.new(described_class)
end
- it 'includes Gitlab::View::Presenter::Base' do
+ it "includes Gitlab::View::Presenter::Base" do
expect(described_class).to include(Gitlab::View::Presenter::Base)
end
- describe '#initialize' do
- it 'takes arbitrary key/values and exposes them' do
- presenter = presenter_class.new(project, current_user: 'Jane Doe')
+ describe "#initialize" do
+ it "takes arbitrary key/values and exposes them" do
+ presenter = presenter_class.new(project, current_user: "Jane Doe")
- expect(presenter.current_user).to eq('Jane Doe')
+ expect(presenter.current_user).to eq("Jane Doe")
end
- it 'raise an error if the presentee already respond to method' do
- expect { presenter_class.new(project, user: 'Jane Doe') }
+ it "raise an error if the presentee already respond to method" do
+ expect { presenter_class.new(project, user: "Jane Doe") }
.to raise_error Gitlab::View::Presenter::CannotOverrideMethodError
end
end
- describe 'delegation' do
- it 'forwards missing methods to subject' do
+ describe "delegation" do
+ it "forwards missing methods to subject" do
presenter = presenter_class.new(project)
- expect(presenter.user).to eq('John Doe')
+ expect(presenter.user).to eq("John Doe")
end
end
end
diff --git a/spec/lib/gitlab/view/presenter/factory_spec.rb b/spec/lib/gitlab/view/presenter/factory_spec.rb
index 6120bafb2e3..bdcf285cb01 100644
--- a/spec/lib/gitlab/view/presenter/factory_spec.rb
+++ b/spec/lib/gitlab/view/presenter/factory_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::View::Presenter::Factory do
let(:build) { Ci::Build.new }
- describe '#initialize' do
- context 'without optional parameters' do
- it 'takes a subject and optional params' do
+ describe "#initialize" do
+ context "without optional parameters" do
+ it "takes a subject and optional params" do
presenter = described_class.new(build)
expect { presenter }.not_to raise_error
end
end
- context 'with optional parameters' do
- it 'takes a subject and optional params' do
- presenter = described_class.new(build, user: 'user')
+ context "with optional parameters" do
+ it "takes a subject and optional params" do
+ presenter = described_class.new(build, user: "user")
expect { presenter }.not_to raise_error
end
end
end
- describe '#fabricate!' do
- it 'detects the presenter based on the given subject' do
+ describe "#fabricate!" do
+ it "detects the presenter based on the given subject" do
presenter = described_class.new(build).fabricate!
expect(presenter).to be_a(Ci::BuildPresenter)
end
- it 'uses the presenter_class if given on #initialize' do
+ it "uses the presenter_class if given on #initialize" do
MyCustomPresenter = Class.new(described_class)
presenter = described_class.new(build, presenter_class: MyCustomPresenter).fabricate!
diff --git a/spec/lib/gitlab/view/presenter/simple_spec.rb b/spec/lib/gitlab/view/presenter/simple_spec.rb
index 1795ed2405b..b43e350a19e 100644
--- a/spec/lib/gitlab/view/presenter/simple_spec.rb
+++ b/spec/lib/gitlab/view/presenter/simple_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::View::Presenter::Simple do
- let(:project) { double(:project, user: 'John Doe') }
+ let(:project) { double(:project, user: "John Doe") }
let(:presenter_class) do
Class.new(described_class)
end
- it 'includes Gitlab::View::Presenter::Base' do
+ it "includes Gitlab::View::Presenter::Base" do
expect(described_class).to include(Gitlab::View::Presenter::Base)
end
- describe '#initialize' do
- it 'takes arbitrary key/values and exposes them' do
- presenter = presenter_class.new(project, current_user: 'Jane Doe')
+ describe "#initialize" do
+ it "takes arbitrary key/values and exposes them" do
+ presenter = presenter_class.new(project, current_user: "Jane Doe")
- expect(presenter.current_user).to eq('Jane Doe')
+ expect(presenter.current_user).to eq("Jane Doe")
end
- it 'override the presentee attributes' do
- presenter = presenter_class.new(project, user: 'Jane Doe')
+ it "override the presentee attributes" do
+ presenter = presenter_class.new(project, user: "Jane Doe")
- expect(presenter.user).to eq('Jane Doe')
+ expect(presenter.user).to eq("Jane Doe")
end
end
- describe 'delegation' do
- it 'does not forward missing methods to subject' do
+ describe "delegation" do
+ it "does not forward missing methods to subject" do
presenter = presenter_class.new(project)
expect { presenter.user }.to raise_error(NoMethodError)
diff --git a/spec/lib/gitlab/visibility_level_spec.rb b/spec/lib/gitlab/visibility_level_spec.rb
index 2c1146ceff5..06c6c9e1edb 100644
--- a/spec/lib/gitlab/visibility_level_spec.rb
+++ b/spec/lib/gitlab/visibility_level_spec.rb
@@ -1,85 +1,85 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::VisibilityLevel do
- describe '.level_value' do
+ describe ".level_value" do
it 'converts "public" to integer value' do
- expect(described_class.level_value('public')).to eq(Gitlab::VisibilityLevel::PUBLIC)
+ expect(described_class.level_value("public")).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
- it 'converts string integer to integer value' do
- expect(described_class.level_value('20')).to eq(20)
+ it "converts string integer to integer value" do
+ expect(described_class.level_value("20")).to eq(20)
end
- it 'defaults to PRIVATE when string value is not valid' do
- expect(described_class.level_value('invalid')).to eq(Gitlab::VisibilityLevel::PRIVATE)
+ it "defaults to PRIVATE when string value is not valid" do
+ expect(described_class.level_value("invalid")).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
- it 'defaults to PRIVATE when integer value is not valid' do
+ it "defaults to PRIVATE when integer value is not valid" do
expect(described_class.level_value(100)).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
end
- describe '.levels_for_user' do
- it 'returns all levels for an admin' do
+ describe ".levels_for_user" do
+ it "returns all levels for an admin" do
user = build(:user, :admin)
expect(described_class.levels_for_user(user))
.to eq([Gitlab::VisibilityLevel::PRIVATE,
Gitlab::VisibilityLevel::INTERNAL,
- Gitlab::VisibilityLevel::PUBLIC])
+ Gitlab::VisibilityLevel::PUBLIC,])
end
- it 'returns INTERNAL and PUBLIC for internal users' do
+ it "returns INTERNAL and PUBLIC for internal users" do
user = build(:user)
expect(described_class.levels_for_user(user))
.to eq([Gitlab::VisibilityLevel::INTERNAL,
- Gitlab::VisibilityLevel::PUBLIC])
+ Gitlab::VisibilityLevel::PUBLIC,])
end
- it 'returns PUBLIC for external users' do
+ it "returns PUBLIC for external users" do
user = build(:user, :external)
expect(described_class.levels_for_user(user))
.to eq([Gitlab::VisibilityLevel::PUBLIC])
end
- it 'returns PUBLIC when no user is given' do
+ it "returns PUBLIC when no user is given" do
expect(described_class.levels_for_user)
.to eq([Gitlab::VisibilityLevel::PUBLIC])
end
end
- describe '.allowed_levels' do
- it 'only includes the levels that arent restricted' do
+ describe ".allowed_levels" do
+ it "only includes the levels that arent restricted" do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::INTERNAL])
expect(described_class.allowed_levels)
.to contain_exactly(described_class::PRIVATE, described_class::PUBLIC)
end
- it 'returns all levels when no visibility level was set' do
+ it "returns all levels when no visibility level was set" do
allow(described_class)
- .to receive_message_chain('current_application_settings.restricted_visibility_levels')
- .and_return(nil)
+ .to receive_message_chain("current_application_settings.restricted_visibility_levels")
+ .and_return(nil)
expect(described_class.allowed_levels)
.to contain_exactly(described_class::PRIVATE, described_class::INTERNAL, described_class::PUBLIC)
end
end
- describe '.closest_allowed_level' do
- it 'picks INTERNAL instead of PUBLIC if public is restricted' do
+ describe ".closest_allowed_level" do
+ it "picks INTERNAL instead of PUBLIC if public is restricted" do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
expect(described_class.closest_allowed_level(described_class::PUBLIC))
.to eq(described_class::INTERNAL)
end
- it 'picks PRIVATE if nothing is available' do
+ it "picks PRIVATE if nothing is available" do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC,
Gitlab::VisibilityLevel::INTERNAL,
- Gitlab::VisibilityLevel::PRIVATE])
+ Gitlab::VisibilityLevel::PRIVATE,])
expect(described_class.closest_allowed_level(described_class::PUBLIC))
.to eq(described_class::PRIVATE)
diff --git a/spec/lib/gitlab/web_ide_commits_counter_spec.rb b/spec/lib/gitlab/web_ide_commits_counter_spec.rb
index c51889a1c63..4898e790f84 100644
--- a/spec/lib/gitlab/web_ide_commits_counter_spec.rb
+++ b/spec/lib/gitlab/web_ide_commits_counter_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::WebIdeCommitsCounter, :clean_gitlab_redis_shared_state do
- describe '.increment' do
- it 'increments the web ide commits counter by 1' do
- expect do
+ describe ".increment" do
+ it "increments the web ide commits counter by 1" do
+ expect {
described_class.increment
- end.to change { described_class.total_count }.from(0).to(1)
+ }.to change { described_class.total_count }.from(0).to(1)
end
end
- describe '.total_count' do
- it 'returns the total amount of web ide commits' do
+ describe ".total_count" do
+ it "returns the total amount of web ide commits" do
expect(described_class.total_count).to eq(0)
end
end
diff --git a/spec/lib/gitlab/wiki_file_finder_spec.rb b/spec/lib/gitlab/wiki_file_finder_spec.rb
index 025d1203dc5..8729a3afc1e 100644
--- a/spec/lib/gitlab/wiki_file_finder_spec.rb
+++ b/spec/lib/gitlab/wiki_file_finder_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::WikiFileFinder do
- describe '#find' do
+ describe "#find" do
let(:project) { create(:project, :public, :wiki_repo) }
let(:wiki) { build(:project_wiki, project: project) }
before do
- wiki.create_page('Files/Title', 'Content')
- wiki.create_page('CHANGELOG', 'Files example')
+ wiki.create_page("Files/Title", "Content")
+ wiki.create_page("CHANGELOG", "Files example")
end
- it_behaves_like 'file finder' do
+ it_behaves_like "file finder" do
subject { described_class.new(project, project.wiki.default_branch) }
- let(:expected_file_by_name) { 'Files/Title.md' }
- let(:expected_file_by_content) { 'CHANGELOG.md' }
+ let(:expected_file_by_name) { "Files/Title.md" }
+ let(:expected_file_by_content) { "CHANGELOG.md" }
end
end
end
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index 7213eee5675..d7bde1ae134 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::Workhorse do
set(:project) { create(:project, :repository) }
@@ -13,17 +13,17 @@ describe Gitlab::Workhorse do
end
describe ".send_git_archive" do
- let(:ref) { 'master' }
- let(:format) { 'zip' }
+ let(:ref) { "master" }
+ let(:format) { "zip" }
let(:storage_path) { Gitlab.config.gitlab.repository_downloads_path }
let(:base_params) { repository.archive_metadata(ref, storage_path, format, append_sha: nil) }
let(:gitaly_params) do
base_params.merge(
- 'GitalyServer' => {
- 'address' => Gitlab::GitalyClient.address(project.repository_storage),
- 'token' => Gitlab::GitalyClient.token(project.repository_storage)
+ "GitalyServer" => {
+ "address" => Gitlab::GitalyClient.address(project.repository_storage),
+ "token" => Gitlab::GitalyClient.token(project.repository_storage),
},
- 'GitalyRepository' => repository.gitaly_repository.to_h.deep_stringify_keys
+ "GitalyRepository" => repository.gitaly_repository.to_h.deep_stringify_keys
)
end
let(:cache_disabled) { false }
@@ -36,26 +36,26 @@ describe Gitlab::Workhorse do
allow(described_class).to receive(:git_archive_cache_disabled?).and_return(cache_disabled)
end
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(subject)
- expect(key).to eq('Gitlab-Workhorse-Send-Data')
- expect(command).to eq('git-archive')
+ expect(key).to eq("Gitlab-Workhorse-Send-Data")
+ expect(command).to eq("git-archive")
expect(params).to include(gitaly_params)
end
- context 'when archive caching is disabled' do
+ context "when archive caching is disabled" do
let(:cache_disabled) { true }
- it 'tells workhorse not to use the cache' do
+ it "tells workhorse not to use the cache" do
_, _, params = decode_workhorse_header(subject)
- expect(params).to include({ 'DisableCache' => true })
+ expect(params).to include({"DisableCache" => true})
end
end
context "when the repository doesn't have an archive file path" do
before do
- allow(project.repository).to receive(:archive_metadata).and_return(Hash.new)
+ allow(project.repository).to receive(:archive_metadata).and_return({})
end
it "raises an error" do
@@ -64,36 +64,36 @@ describe Gitlab::Workhorse do
end
end
- describe '.send_git_patch' do
+ describe ".send_git_patch" do
let(:diff_refs) { double(base_sha: "base", head_sha: "head") }
subject { described_class.send_git_patch(repository, diff_refs) }
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(subject)
expect(key).to eq("Gitlab-Workhorse-Send-Data")
expect(command).to eq("git-format-patch")
expect(params).to eq({
- 'GitalyServer' => {
+ "GitalyServer" => {
address: Gitlab::GitalyClient.address(project.repository_storage),
- token: Gitlab::GitalyClient.token(project.repository_storage)
+ token: Gitlab::GitalyClient.token(project.repository_storage),
},
- 'RawPatchRequest' => Gitaly::RawPatchRequest.new(
+ "RawPatchRequest" => Gitaly::RawPatchRequest.new(
repository: repository.gitaly_repository,
- left_commit_id: 'base',
- right_commit_id: 'head'
- ).to_json
+ left_commit_id: "base",
+ right_commit_id: "head"
+ ).to_json,
}.deep_stringify_keys)
end
end
- describe '.terminal_websocket' do
+ describe ".terminal_websocket" do
def terminal(ca_pem: nil)
out = {
- subprotocols: ['foo'],
- url: 'wss://example.com/terminal.ws',
- headers: { 'Authorization' => ['Token x'] },
- max_session_time: 600
+ subprotocols: ["foo"],
+ url: "wss://example.com/terminal.ws",
+ headers: {"Authorization" => ["Token x"]},
+ max_session_time: 600,
}
out[:ca_pem] = ca_pem if ca_pem
out
@@ -101,49 +101,49 @@ describe Gitlab::Workhorse do
def workhorse(ca_pem: nil)
out = {
- 'Terminal' => {
- 'Subprotocols' => ['foo'],
- 'Url' => 'wss://example.com/terminal.ws',
- 'Header' => { 'Authorization' => ['Token x'] },
- 'MaxSessionTime' => 600
- }
+ "Terminal" => {
+ "Subprotocols" => ["foo"],
+ "Url" => "wss://example.com/terminal.ws",
+ "Header" => {"Authorization" => ["Token x"]},
+ "MaxSessionTime" => 600,
+ },
}
- out['Terminal']['CAPem'] = ca_pem if ca_pem
+ out["Terminal"]["CAPem"] = ca_pem if ca_pem
out
end
- context 'without ca_pem' do
+ context "without ca_pem" do
subject { described_class.terminal_websocket(terminal) }
it { is_expected.to eq(workhorse) }
end
- context 'with ca_pem' do
+ context "with ca_pem" do
subject { described_class.terminal_websocket(terminal(ca_pem: "foo")) }
it { is_expected.to eq(workhorse(ca_pem: "foo")) }
end
end
- describe '.send_git_diff' do
+ describe ".send_git_diff" do
let(:diff_refs) { double(base_sha: "base", head_sha: "head") }
subject { described_class.send_git_diff(repository, diff_refs) }
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(subject)
expect(key).to eq("Gitlab-Workhorse-Send-Data")
expect(command).to eq("git-diff")
expect(params).to eq({
- 'GitalyServer' => {
+ "GitalyServer" => {
address: Gitlab::GitalyClient.address(project.repository_storage),
- token: Gitlab::GitalyClient.token(project.repository_storage)
+ token: Gitlab::GitalyClient.token(project.repository_storage),
},
- 'RawDiffRequest' => Gitaly::RawDiffRequest.new(
+ "RawDiffRequest" => Gitaly::RawDiffRequest.new(
repository: repository.gitaly_repository,
- left_commit_id: 'base',
- right_commit_id: 'head'
- ).to_json
+ left_commit_id: "base",
+ right_commit_id: "head"
+ ).to_json,
}.deep_stringify_keys)
end
end
@@ -156,23 +156,23 @@ describe Gitlab::Workhorse do
described_class.write_secret
end
- it 'returns 32 bytes' do
+ it "returns 32 bytes" do
expect(subject).to be_a(String)
expect(subject.length).to eq(32)
expect(subject.encoding).to eq(Encoding::ASCII_8BIT)
end
- it 'accepts a trailing newline' do
- File.open(described_class.secret_path, 'a') { |f| f.write "\n" }
+ it "accepts a trailing newline" do
+ File.open(described_class.secret_path, "a") { |f| f.write "\n" }
expect(subject.length).to eq(32)
end
- it 'raises an exception if the secret file cannot be read' do
+ it "raises an exception if the secret file cannot be read" do
File.delete(described_class.secret_path)
expect { subject }.to raise_exception(Errno::ENOENT)
end
- it 'raises an exception if the secret file contains the wrong number of bytes' do
+ it "raises an exception if the secret file contains the wrong number of bytes" do
File.truncate(described_class.secret_path, 0)
expect { subject }.to raise_exception(RuntimeError)
end
@@ -189,42 +189,42 @@ describe Gitlab::Workhorse do
described_class.write_secret
end
- it 'uses mode 0600' do
- expect(File.stat(secret_path).mode & 0777).to eq(0600)
+ it "uses mode 0600" do
+ expect(File.stat(secret_path).mode & 0o777).to eq(0o600)
end
- it 'writes base64 data' do
+ it "writes base64 data" do
bytes = Base64.strict_decode64(File.read(secret_path))
expect(bytes).not_to be_empty
end
end
- describe '#verify_api_request!' do
+ describe "#verify_api_request!" do
let(:header_key) { described_class::INTERNAL_API_REQUEST_HEADER }
- let(:payload) { { 'iss' => 'gitlab-workhorse' } }
+ let(:payload) { {"iss" => "gitlab-workhorse"} }
- it 'accepts a correct header' do
- headers = { header_key => JWT.encode(payload, described_class.secret, 'HS256') }
+ it "accepts a correct header" do
+ headers = {header_key => JWT.encode(payload, described_class.secret, "HS256")}
expect { call_verify(headers) }.not_to raise_error
end
- it 'raises an error when the header is not set' do
+ it "raises an error when the header is not set" do
expect { call_verify({}) }.to raise_jwt_error
end
- it 'raises an error when the header is not signed' do
- headers = { header_key => JWT.encode(payload, nil, 'none') }
+ it "raises an error when the header is not signed" do
+ headers = {header_key => JWT.encode(payload, nil, "none")}
expect { call_verify(headers) }.to raise_jwt_error
end
- it 'raises an error when the header is signed with the wrong key' do
- headers = { header_key => JWT.encode(payload, 'wrongkey', 'HS256') }
+ it "raises an error when the header is signed with the wrong key" do
+ headers = {header_key => JWT.encode(payload, "wrongkey", "HS256")}
expect { call_verify(headers) }.to raise_jwt_error
end
- it 'raises an error when the issuer is incorrect' do
- payload['iss'] = 'somebody else'
- headers = { header_key => JWT.encode(payload, described_class.secret, 'HS256') }
+ it "raises an error when the issuer is incorrect" do
+ payload["iss"] = "somebody else"
+ headers = {header_key => JWT.encode(payload, described_class.secret, "HS256")}
expect { call_verify(headers) }.to raise_jwt_error
end
@@ -237,16 +237,16 @@ describe Gitlab::Workhorse do
end
end
- describe '.git_http_ok' do
+ describe ".git_http_ok" do
let(:user) { create(:user) }
- let(:repo_path) { 'ignored but not allowed to be empty in gitlab-workhorse' }
- let(:action) { 'info_refs' }
+ let(:repo_path) { "ignored but not allowed to be empty in gitlab-workhorse" }
+ let(:action) { "info_refs" }
let(:params) do
{
GL_ID: "user-#{user.id}",
GL_USERNAME: user.username,
GL_REPOSITORY: "project-#{project.id}",
- ShowAllRefs: false
+ ShowAllRefs: false,
}
end
@@ -254,13 +254,13 @@ describe Gitlab::Workhorse do
it { expect(subject).to include(params) }
- context 'when is_wiki' do
+ context "when is_wiki" do
let(:params) do
{
GL_ID: "user-#{user.id}",
GL_USERNAME: user.username,
GL_REPOSITORY: "wiki-#{project.id}",
- ShowAllRefs: false
+ ShowAllRefs: false,
}
end
@@ -269,13 +269,13 @@ describe Gitlab::Workhorse do
it { expect(subject).to include(params) }
end
- context 'when Gitaly is enabled' do
+ context "when Gitaly is enabled" do
let(:gitaly_params) do
{
GitalyServer: {
- address: Gitlab::GitalyClient.address('default'),
- token: Gitlab::GitalyClient.token('default')
- }
+ address: Gitlab::GitalyClient.address("default"),
+ token: Gitlab::GitalyClient.token("default"),
+ },
}
end
@@ -283,27 +283,27 @@ describe Gitlab::Workhorse do
allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true)
end
- it 'includes a Repository param' do
+ it "includes a Repository param" do
repo_param = {
- storage_name: 'default',
- relative_path: project.disk_path + '.git',
- gl_repository: "project-#{project.id}"
+ storage_name: "default",
+ relative_path: project.disk_path + ".git",
+ gl_repository: "project-#{project.id}",
}
expect(subject[:Repository]).to include(repo_param)
end
context "when git_upload_pack action is passed" do
- let(:action) { 'git_upload_pack' }
+ let(:action) { "git_upload_pack" }
let(:feature_flag) { :post_upload_pack }
- it 'includes Gitaly params in the returned value' do
+ it "includes Gitaly params in the returned value" do
allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(feature_flag).and_return(true)
expect(subject).to include(gitaly_params)
end
- context 'show_all_refs enabled' do
+ context "show_all_refs enabled" do
subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
it { is_expected.to include(ShowAllRefs: true) }
@@ -311,40 +311,40 @@ describe Gitlab::Workhorse do
end
context "when git_receive_pack action is passed" do
- let(:action) { 'git_receive_pack' }
+ let(:action) { "git_receive_pack" }
it { expect(subject).to include(gitaly_params) }
end
context "when info_refs action is passed" do
- let(:action) { 'info_refs' }
+ let(:action) { "info_refs" }
it { expect(subject).to include(gitaly_params) }
- context 'show_all_refs enabled' do
+ context "show_all_refs enabled" do
subject { described_class.git_http_ok(repository, false, user, action, show_all_refs: true) }
it { is_expected.to include(ShowAllRefs: true) }
end
end
- context 'when action passed is not supported by Gitaly' do
- let(:action) { 'download' }
+ context "when action passed is not supported by Gitaly" do
+ let(:action) { "download" }
- it { expect { subject }.to raise_exception('Unsupported action: download') }
+ it { expect { subject }.to raise_exception("Unsupported action: download") }
end
end
- context 'when receive_max_input_size has been updated' do
- it 'returns custom git config' do
+ context "when receive_max_input_size has been updated" do
+ it "returns custom git config" do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { 1 }
expect(subject[:GitConfigOptions]).to be_present
end
end
- context 'when receive_max_input_size is empty' do
- it 'returns an empty git config' do
+ context "when receive_max_input_size is empty" do
+ it "returns an empty git config" do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { nil }
expect(subject[:GitConfigOptions]).to be_empty
@@ -352,18 +352,18 @@ describe Gitlab::Workhorse do
end
end
- describe '.set_key_and_notify' do
- let(:key) { 'test-key' }
- let(:value) { 'test-value' }
+ describe ".set_key_and_notify" do
+ let(:key) { "test-key" }
+ let(:value) { "test-value" }
subject { described_class.set_key_and_notify(key, value, overwrite: overwrite) }
- shared_examples 'set and notify' do
- it 'set and return the same value' do
+ shared_examples "set and notify" do
+ it "set and return the same value" do
is_expected.to eq(value)
end
- it 'set and notify' do
+ it "set and notify" do
expect_any_instance_of(::Redis).to receive(:publish)
.with(described_class::NOTIFICATION_CHANNEL, "test-key=test-value")
@@ -371,33 +371,33 @@ describe Gitlab::Workhorse do
end
end
- context 'when we set a new key' do
+ context "when we set a new key" do
let(:overwrite) { true }
- it_behaves_like 'set and notify'
+ it_behaves_like "set and notify"
end
- context 'when we set an existing key' do
- let(:old_value) { 'existing-key' }
+ context "when we set an existing key" do
+ let(:old_value) { "existing-key" }
before do
described_class.set_key_and_notify(key, old_value, overwrite: true)
end
- context 'and overwrite' do
+ context "and overwrite" do
let(:overwrite) { true }
- it_behaves_like 'set and notify'
+ it_behaves_like "set and notify"
end
- context 'and do not overwrite' do
+ context "and do not overwrite" do
let(:overwrite) { false }
- it 'try to set but return the previous value' do
+ it "try to set but return the previous value" do
is_expected.to eq(old_value)
end
- it 'does not notify' do
+ it "does not notify" do
expect_any_instance_of(::Redis).not_to receive(:publish)
subject
@@ -406,65 +406,65 @@ describe Gitlab::Workhorse do
end
end
- describe '.send_git_blob' do
+ describe ".send_git_blob" do
include FakeBlobHelpers
let(:blob) { fake_blob }
subject { described_class.send_git_blob(repository, blob) }
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(subject)
- expect(key).to eq('Gitlab-Workhorse-Send-Data')
- expect(command).to eq('git-blob')
+ expect(key).to eq("Gitlab-Workhorse-Send-Data")
+ expect(command).to eq("git-blob")
expect(params).to eq({
- 'GitalyServer' => {
+ "GitalyServer" => {
address: Gitlab::GitalyClient.address(project.repository_storage),
- token: Gitlab::GitalyClient.token(project.repository_storage)
+ token: Gitlab::GitalyClient.token(project.repository_storage),
},
- 'GetBlobRequest' => {
+ "GetBlobRequest" => {
repository: repository.gitaly_repository.to_h,
oid: blob.id,
- limit: -1
- }
+ limit: -1,
+ },
}.deep_stringify_keys)
end
end
- describe '.send_url' do
- let(:url) { 'http://example.com' }
+ describe ".send_url" do
+ let(:url) { "http://example.com" }
subject { described_class.send_url(url) }
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(subject)
expect(key).to eq("Gitlab-Workhorse-Send-Data")
expect(command).to eq("send-url")
expect(params).to eq({
- 'URL' => url,
- 'AllowRedirects' => false
+ "URL" => url,
+ "AllowRedirects" => false,
}.deep_stringify_keys)
end
end
- describe '.send_git_snapshot' do
- let(:url) { 'http://example.com' }
+ describe ".send_git_snapshot" do
+ let(:url) { "http://example.com" }
subject(:request) { described_class.send_git_snapshot(repository) }
- it 'sets the header correctly' do
+ it "sets the header correctly" do
key, command, params = decode_workhorse_header(request)
expect(key).to eq("Gitlab-Workhorse-Send-Data")
- expect(command).to eq('git-snapshot')
+ expect(command).to eq("git-snapshot")
expect(params).to eq(
- 'GitalyServer' => {
- 'address' => Gitlab::GitalyClient.address(project.repository_storage),
- 'token' => Gitlab::GitalyClient.token(project.repository_storage)
+ "GitalyServer" => {
+ "address" => Gitlab::GitalyClient.address(project.repository_storage),
+ "token" => Gitlab::GitalyClient.token(project.repository_storage),
},
- 'GetSnapshotRequest' => Gitaly::GetSnapshotRequest.new(
+ "GetSnapshotRequest" => Gitaly::GetSnapshotRequest.new(
repository: repository.gitaly_repository
).to_json
)
diff --git a/spec/lib/gitlab_spec.rb b/spec/lib/gitlab_spec.rb
index 5f7a0cca351..dc27d30d5c6 100644
--- a/spec/lib/gitlab_spec.rb
+++ b/spec/lib/gitlab_spec.rb
@@ -1,15 +1,15 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
-require_dependency 'gitlab'
+require_dependency "gitlab"
describe Gitlab do
- describe '.root' do
- it 'returns the root path of the app' do
- expect(described_class.root).to eq(Pathname.new(File.expand_path('../..', __dir__)))
+ describe ".root" do
+ it "returns the root path of the app" do
+ expect(described_class.root).to eq(Pathname.new(File.expand_path("../..", __dir__)))
end
end
- describe '.revision' do
+ describe ".revision" do
let(:cmd) { %W[#{described_class.config.git.bin_path} log --pretty=format:%h -n 1] }
around do |example|
@@ -18,79 +18,79 @@ describe Gitlab do
described_class.instance_variable_set(:@_revision, nil)
end
- context 'when a REVISION file exists' do
+ context "when a REVISION file exists" do
before do
expect(File).to receive(:exist?)
- .with(described_class.root.join('REVISION'))
+ .with(described_class.root.join("REVISION"))
.and_return(true)
end
- it 'returns the actual Git revision' do
+ it "returns the actual Git revision" do
expect(File).to receive(:read)
- .with(described_class.root.join('REVISION'))
+ .with(described_class.root.join("REVISION"))
.and_return("abc123\n")
- expect(described_class.revision).to eq('abc123')
+ expect(described_class.revision).to eq("abc123")
end
- it 'memoizes the revision' do
+ it "memoizes the revision" do
expect(File).to receive(:read)
.once
- .with(described_class.root.join('REVISION'))
+ .with(described_class.root.join("REVISION"))
.and_return("abc123\n")
2.times { described_class.revision }
end
end
- context 'when no REVISION file exist' do
- context 'when the Git command succeeds' do
+ context "when no REVISION file exist" do
+ context "when the Git command succeeds" do
before do
expect(Gitlab::Popen).to receive(:popen_with_detail)
- .with(cmd)
- .and_return(Gitlab::Popen::Result.new(cmd, 'abc123', '', double(success?: true)))
+ .with(cmd)
+ .and_return(Gitlab::Popen::Result.new(cmd, "abc123", "", double(success?: true)))
end
- it 'returns the actual Git revision' do
- expect(described_class.revision).to eq('abc123')
+ it "returns the actual Git revision" do
+ expect(described_class.revision).to eq("abc123")
end
end
- context 'when the Git command fails' do
+ context "when the Git command fails" do
before do
expect(Gitlab::Popen).to receive(:popen_with_detail)
- .with(cmd)
- .and_return(Gitlab::Popen::Result.new(cmd, '', 'fatal: Not a git repository', double('Process::Status', success?: false)))
+ .with(cmd)
+ .and_return(Gitlab::Popen::Result.new(cmd, "", "fatal: Not a git repository", double("Process::Status", success?: false)))
end
it 'returns "Unknown"' do
- expect(described_class.revision).to eq('Unknown')
+ expect(described_class.revision).to eq("Unknown")
end
end
end
end
- describe '.com?' do
- it 'is true when on GitLab.com' do
- stub_config_setting(url: 'https://gitlab.com')
+ describe ".com?" do
+ it "is true when on GitLab.com" do
+ stub_config_setting(url: "https://gitlab.com")
expect(described_class.com?).to eq true
end
- it 'is true when on staging' do
- stub_config_setting(url: 'https://staging.gitlab.com')
+ it "is true when on staging" do
+ stub_config_setting(url: "https://staging.gitlab.com")
expect(described_class.com?).to eq true
end
- it 'is true when on other gitlab subdomain' do
- stub_config_setting(url: 'https://example.gitlab.com')
+ it "is true when on other gitlab subdomain" do
+ stub_config_setting(url: "https://example.gitlab.com")
expect(described_class.com?).to eq true
end
- it 'is false when not on GitLab.com' do
- stub_config_setting(url: 'http://example.com')
+ it "is false when not on GitLab.com" do
+ stub_config_setting(url: "http://example.com")
expect(described_class.com?).to eq false
end
diff --git a/spec/lib/google_api/auth_spec.rb b/spec/lib/google_api/auth_spec.rb
index 87a3f43274f..0c8789804a4 100644
--- a/spec/lib/google_api/auth_spec.rb
+++ b/spec/lib/google_api/auth_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe GoogleApi::Auth do
- let(:redirect_uri) { 'http://localhost:3000/google_api/authorizations/callback' }
- let(:redirect_to) { 'http://localhost:3000/namaspace/project/clusters' }
+ let(:redirect_uri) { "http://localhost:3000/google_api/authorizations/callback" }
+ let(:redirect_to) { "http://localhost:3000/namaspace/project/clusters" }
let(:client) do
GoogleApi::CloudPlatform::Client
.new(nil, redirect_uri, state: redirect_to)
end
- describe '#authorize_url' do
+ describe "#authorize_url" do
subject { client.authorize_url }
- it 'returns authorize_url' do
- is_expected.to start_with('https://accounts.google.com/o/oauth2')
+ it "returns authorize_url" do
+ is_expected.to start_with("https://accounts.google.com/o/oauth2")
is_expected.to include(URI.encode(redirect_uri, URI::PATTERN::RESERVED))
is_expected.to include(URI.encode(redirect_to, URI::PATTERN::RESERVED))
end
end
- describe '#get_token' do
+ describe "#get_token" do
let(:token) do
double.tap do |dbl|
- allow(dbl).to receive(:token).and_return('token')
- allow(dbl).to receive(:expires_at).and_return('expires_at')
+ allow(dbl).to receive(:token).and_return("token")
+ allow(dbl).to receive(:expires_at).and_return("expires_at")
end
end
@@ -32,10 +32,10 @@ describe GoogleApi::Auth do
.to receive(:get_token).and_return(token)
end
- it 'returns token and expires_at' do
- token, expires_at = client.get_token('xxx')
- expect(token).to eq('token')
- expect(expires_at).to eq('expires_at')
+ it "returns token and expires_at" do
+ token, expires_at = client.get_token("xxx")
+ expect(token).to eq("token")
+ expect(expires_at).to eq("expires_at")
end
end
end
diff --git a/spec/lib/google_api/cloud_platform/client_spec.rb b/spec/lib/google_api/cloud_platform/client_spec.rb
index e2134dc279c..fbca51a4970 100644
--- a/spec/lib/google_api/cloud_platform/client_spec.rb
+++ b/spec/lib/google_api/cloud_platform/client_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
describe GoogleApi::CloudPlatform::Client do
- let(:token) { 'token' }
+ let(:token) { "token" }
let(:client) { described_class.new(token, nil) }
let(:user_agent_options) { client.instance_eval { user_agent_header } }
- describe '.session_key_for_redirect_uri' do
- let(:state) { 'random_string' }
+ describe ".session_key_for_redirect_uri" do
+ let(:state) { "random_string" }
subject { described_class.session_key_for_redirect_uri(state) }
- it 'creates a new session key' do
- is_expected.to eq('cloud_platform_second_redirect_uri_random_string')
+ it "creates a new session key" do
+ is_expected.to eq("cloud_platform_second_redirect_uri_random_string")
end
end
- describe '.new_session_key_for_redirect_uri' do
- it 'generates a new session key' do
+ describe ".new_session_key_for_redirect_uri" do
+ it "generates a new session key" do
expect { |b| described_class.new_session_key_for_redirect_uri(&b) }
.to yield_with_args(String)
end
end
- describe '#validate_token' do
+ describe "#validate_token" do
subject { client.validate_token(expires_at) }
- let(:expires_at) { 1.hour.since.utc.strftime('%s') }
+ let(:expires_at) { 1.hour.since.utc.strftime("%s") }
- context 'when token is nil' do
+ context "when token is nil" do
let(:token) { nil }
it { is_expected.to be_falsy }
end
- context 'when expires_at is nil' do
+ context "when expires_at is nil" do
let(:expires_at) { nil }
it { is_expected.to be_falsy }
end
- context 'when expires in 1 hour' do
+ context "when expires in 1 hour" do
it { is_expected.to be_truthy }
end
- context 'when expires in 10 minutes' do
- let(:expires_at) { 5.minutes.since.utc.strftime('%s') }
+ context "when expires in 10 minutes" do
+ let(:expires_at) { 5.minutes.since.utc.strftime("%s") }
it { is_expected.to be_falsy }
end
end
- describe '#projects_zones_clusters_get' do
+ describe "#projects_zones_clusters_get" do
subject { client.projects_zones_clusters_get(spy, spy, spy) }
let(:gke_cluster) { double }
@@ -63,19 +63,20 @@ describe GoogleApi::CloudPlatform::Client do
it { is_expected.to eq(gke_cluster) }
end
- describe '#projects_zones_clusters_create' do
+ describe "#projects_zones_clusters_create" do
subject do
client.projects_zones_clusters_create(
- project_id, zone, cluster_name, cluster_size, machine_type: machine_type, legacy_abac: legacy_abac)
+ project_id, zone, cluster_name, cluster_size, machine_type: machine_type, legacy_abac: legacy_abac
+ )
end
- let(:project_id) { 'project-123' }
- let(:zone) { 'us-central1-a' }
- let(:cluster_name) { 'test-cluster' }
+ let(:project_id) { "project-123" }
+ let(:zone) { "us-central1-a" }
+ let(:cluster_name) { "test-cluster" }
let(:cluster_size) { 1 }
- let(:machine_type) { 'n1-standard-2' }
+ let(:machine_type) { "n1-standard-2" }
let(:legacy_abac) { true }
- let(:create_cluster_request_body) { double('Google::Apis::ContainerV1::CreateClusterRequest') }
+ let(:create_cluster_request_body) { double("Google::Apis::ContainerV1::CreateClusterRequest") }
let(:operation) { double }
before do
@@ -84,7 +85,7 @@ describe GoogleApi::CloudPlatform::Client do
.and_return(operation)
end
- it 'sets corresponded parameters' do
+ it "sets corresponded parameters" do
expect_any_instance_of(Google::Apis::ContainerV1::ContainerService)
.to receive(:create_cluster).with(project_id, zone, create_cluster_request_body, options: user_agent_options)
@@ -95,21 +96,22 @@ describe GoogleApi::CloudPlatform::Client do
"name": cluster_name,
"initial_node_count": cluster_size,
"node_config": {
- "machine_type": machine_type
+ "machine_type": machine_type,
},
"legacy_abac": {
- "enabled": true
- }
- }
- } ).and_return(create_cluster_request_body)
+ "enabled": true,
+ },
+ },
+ }
+ ).and_return(create_cluster_request_body)
expect(subject).to eq operation
end
- context 'create without legacy_abac' do
+ context "create without legacy_abac" do
let(:legacy_abac) { false }
- it 'sets corresponded parameters' do
+ it "sets corresponded parameters" do
expect_any_instance_of(Google::Apis::ContainerV1::ContainerService)
.to receive(:create_cluster).with(project_id, zone, create_cluster_request_body, options: user_agent_options)
@@ -120,20 +122,21 @@ describe GoogleApi::CloudPlatform::Client do
"name": cluster_name,
"initial_node_count": cluster_size,
"node_config": {
- "machine_type": machine_type
+ "machine_type": machine_type,
},
"legacy_abac": {
- "enabled": false
- }
- }
- } ).and_return(create_cluster_request_body)
+ "enabled": false,
+ },
+ },
+ }
+ ).and_return(create_cluster_request_body)
expect(subject).to eq operation
end
end
end
- describe '#projects_zones_operations' do
+ describe "#projects_zones_operations" do
subject { client.projects_zones_operations(spy, spy, spy) }
let(:operation) { double }
@@ -146,35 +149,35 @@ describe GoogleApi::CloudPlatform::Client do
it { is_expected.to eq(operation) }
end
- describe '#parse_operation_id' do
+ describe "#parse_operation_id" do
subject { client.parse_operation_id(self_link) }
- context 'when expected url' do
+ context "when expected url" do
let(:self_link) do
- 'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123'
+ "projects/gcp-project-12345/zones/us-central1-a/operations/ope-123"
end
- it { is_expected.to eq('ope-123') }
+ it { is_expected.to eq("ope-123") }
end
- context 'when unexpected url' do
- let(:self_link) { '???' }
+ context "when unexpected url" do
+ let(:self_link) { "???" }
it { is_expected.to be_nil }
end
end
- describe '#user_agent_header' do
+ describe "#user_agent_header" do
subject { client.instance_eval { user_agent_header } }
- it 'returns a RequestOptions object' do
+ it "returns a RequestOptions object" do
expect(subject).to be_instance_of(Google::Apis::RequestOptions)
end
- it 'has the correct GitLab version in User-Agent header' do
- stub_const('Gitlab::VERSION', '10.3.0-pre')
+ it "has the correct GitLab version in User-Agent header" do
+ stub_const("Gitlab::VERSION", "10.3.0-pre")
- expect(subject.header).to eq({ 'User-Agent': 'GitLab/10.3 (GPN:GitLab;)' })
+ expect(subject.header).to eq({'User-Agent': "GitLab/10.3 (GPN:GitLab;)"})
end
end
end
diff --git a/spec/lib/json_web_token/hmac_token_spec.rb b/spec/lib/json_web_token/hmac_token_spec.rb
index f2cbc381967..19fce33ca30 100644
--- a/spec/lib/json_web_token/hmac_token_spec.rb
+++ b/spec/lib/json_web_token/hmac_token_spec.rb
@@ -1,59 +1,59 @@
# frozen_string_literal: true
-require 'json'
-require 'timecop'
+require "json"
+require "timecop"
describe JSONWebToken::HMACToken do
- let(:secret) { 'shh secret squirrel' }
+ let(:secret) { "shh secret squirrel" }
- shared_examples 'a valid, non-expired token' do
- it 'is an Array with two elements' do
+ shared_examples "a valid, non-expired token" do
+ it "is an Array with two elements" do
expect(decoded_token).to be_a(Array)
expect(decoded_token.count).to eq(2)
end
- it 'contains the following keys in the first Array element Hash - jti, iat, nbf, exp' do
- expect(decoded_token[0].keys).to include('jti', 'iat', 'nbf', 'exp')
+ it "contains the following keys in the first Array element Hash - jti, iat, nbf, exp" do
+ expect(decoded_token[0].keys).to include("jti", "iat", "nbf", "exp")
end
- it 'contains the following keys in the second Array element Hash - typ and alg' do
- expect(decoded_token[1]['typ']).to eql('JWT')
- expect(decoded_token[1]['alg']).to eql('HS256')
+ it "contains the following keys in the second Array element Hash - typ and alg" do
+ expect(decoded_token[1]["typ"]).to eql("JWT")
+ expect(decoded_token[1]["alg"]).to eql("HS256")
end
end
- describe '.decode' do
+ describe ".decode" do
let(:leeway) { described_class::IAT_LEEWAY }
let(:decoded_token) { described_class.decode(encoded_token, secret, leeway: leeway) }
- context 'with an invalid token' do
- context 'that is junk' do
- let(:encoded_token) { 'junk' }
+ context "with an invalid token" do
+ context "that is junk" do
+ let(:encoded_token) { "junk" }
it "raises exception saying 'Not enough or too many segments'" do
- expect { decoded_token }.to raise_error(JWT::DecodeError, 'Not enough or too many segments')
+ expect { decoded_token }.to raise_error(JWT::DecodeError, "Not enough or too many segments")
end
end
- context 'that has been fiddled with' do
+ context "that has been fiddled with" do
let(:encoded_token) do
- described_class.new(secret).encoded.tap { |token| token[0] = 'E' }
+ described_class.new(secret).encoded.tap { |token| token[0] = "E" }
end
it "raises exception saying 'Invalid segment encoding'" do
- expect { decoded_token }.to raise_error(JWT::DecodeError, 'Invalid segment encoding')
+ expect { decoded_token }.to raise_error(JWT::DecodeError, "Invalid segment encoding")
end
end
- context 'that was generated using a different secret' do
- let(:encoded_token) { described_class.new('some other secret').encoded }
+ context "that was generated using a different secret" do
+ let(:encoded_token) { described_class.new("some other secret").encoded }
it "raises exception saying 'Signature verification raised" do
- expect { decoded_token }.to raise_error(JWT::VerificationError, 'Signature verification raised')
+ expect { decoded_token }.to raise_error(JWT::VerificationError, "Signature verification raised")
end
end
- context 'that is expired' do
+ context "that is expired" do
# Needs the ! so Timecop.freeze() is effective
let!(:encoded_token) { described_class.new(secret).encoded }
@@ -61,72 +61,72 @@ describe JSONWebToken::HMACToken do
# Needs to be 120 seconds, because the default expiry is 60 seconds
# with an additional 60 second leeway.
Timecop.freeze(Time.now + 120) do
- expect { decoded_token }.to raise_error(JWT::ExpiredSignature, 'Signature has expired')
+ expect { decoded_token }.to raise_error(JWT::ExpiredSignature, "Signature has expired")
end
end
end
end
- context 'with a valid token' do
+ context "with a valid token" do
let(:encoded_token) do
hmac_token = described_class.new(secret)
hmac_token.expire_time = Time.now + expire_time
hmac_token.encoded
end
- context 'that has expired' do
+ context "that has expired" do
let(:expire_time) { 0 }
- context 'with the default leeway' do
+ context "with the default leeway" do
Timecop.freeze(Time.now + 1) do
- it_behaves_like 'a valid, non-expired token'
+ it_behaves_like "a valid, non-expired token"
end
end
- context 'with a leeway of 0 seconds' do
+ context "with a leeway of 0 seconds" do
let(:leeway) { 0 }
it "raises exception saying 'Signature has expired'" do
Timecop.freeze(Time.now + 1) do
- expect { decoded_token }.to raise_error(JWT::ExpiredSignature, 'Signature has expired')
+ expect { decoded_token }.to raise_error(JWT::ExpiredSignature, "Signature has expired")
end
end
end
end
- context 'that has not expired' do
+ context "that has not expired" do
let(:expire_time) { described_class::DEFAULT_EXPIRE_TIME }
- it_behaves_like 'a valid, non-expired token'
+ it_behaves_like "a valid, non-expired token"
end
end
end
- describe '#encoded' do
+ describe "#encoded" do
let(:decoded_token) { described_class.decode(encoded_token, secret) }
- context 'without data' do
+ context "without data" do
let(:encoded_token) { described_class.new(secret).encoded }
- it_behaves_like 'a valid, non-expired token'
+ it_behaves_like "a valid, non-expired token"
end
- context 'with data' do
- let(:data) { { secret_key: 'secret value' }.to_json }
+ context "with data" do
+ let(:data) { {secret_key: "secret value"}.to_json }
let(:encoded_token) do
ec = described_class.new(secret)
ec[:data] = data
ec.encoded
end
- it_behaves_like 'a valid, non-expired token'
+ it_behaves_like "a valid, non-expired token"
it "contains the 'data' key in the first Array element Hash" do
- expect(decoded_token[0]).to have_key('data')
+ expect(decoded_token[0]).to have_key("data")
end
- it 'can re-read back the data' do
- expect(decoded_token[0]['data']).to eql(data)
+ it "can re-read back the data" do
+ expect(decoded_token[0]["data"]).to eql(data)
end
end
end
diff --git a/spec/lib/json_web_token/rsa_token_spec.rb b/spec/lib/json_web_token/rsa_token_spec.rb
index a3c54651e80..c0998e2f3d2 100644
--- a/spec/lib/json_web_token/rsa_token_spec.rb
+++ b/spec/lib/json_web_token/rsa_token_spec.rb
@@ -19,27 +19,28 @@ describe JSONWebToken::RSAToken do
allow_any_instance_of(described_class).to receive(:key).and_return(rsa_key)
end
- context 'token' do
- context 'for valid key to be validated' do
+ context "token" do
+ context "for valid key to be validated" do
before do
- rsa_token['key'] = 'value'
+ rsa_token["key"] = "value"
end
- subject { JWT.decode(rsa_encoded, rsa_key, true, { algorithm: 'RS256' }) }
+ subject { JWT.decode(rsa_encoded, rsa_key, true, {algorithm: "RS256"}) }
it { expect {subject}.not_to raise_error }
- it { expect(subject.first).to include('key' => 'value') }
+ it { expect(subject.first).to include("key" => "value") }
it do
expect(subject.second).to eq(
"typ" => "JWT",
"alg" => "RS256",
- "kid" => "OGXY:4TR7:FAVO:WEM2:XXEW:E4FP:TKL7:7ACK:TZAF:D54P:SUIA:P3B2")
+ "kid" => "OGXY:4TR7:FAVO:WEM2:XXEW:E4FP:TKL7:7ACK:TZAF:D54P:SUIA:P3B2"
+ )
end
end
- context 'for invalid key to raise an exception' do
+ context "for invalid key to raise an exception" do
let(:new_key) { OpenSSL::PKey::RSA.generate(512) }
- subject { JWT.decode(rsa_encoded, new_key, true, { algorithm: 'RS256' }) }
+ subject { JWT.decode(rsa_encoded, new_key, true, {algorithm: "RS256"}) }
it { expect {subject}.to raise_error(JWT::DecodeError) }
end
diff --git a/spec/lib/json_web_token/token_spec.rb b/spec/lib/json_web_token/token_spec.rb
index d7e7560d962..c74bab8b3a2 100644
--- a/spec/lib/json_web_token/token_spec.rb
+++ b/spec/lib/json_web_token/token_spec.rb
@@ -1,8 +1,8 @@
describe JSONWebToken::Token do
let(:token) { described_class.new }
- context 'custom parameters' do
- let(:value) { 'value' }
+ context "custom parameters" do
+ let(:value) { "value" }
before do
token[:key] = value
@@ -12,7 +12,7 @@ describe JSONWebToken::Token do
it { expect(token.payload).to include(key: value) }
end
- context 'embeds default payload' do
+ context "embeds default payload" do
subject { token.payload }
let(:default) { token.send(:default_payload) }
diff --git a/spec/lib/mattermost/client_spec.rb b/spec/lib/mattermost/client_spec.rb
index dc11a414717..5b3eb756288 100644
--- a/spec/lib/mattermost/client_spec.rb
+++ b/spec/lib/mattermost/client_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Mattermost::Client do
let(:user) { build(:user) }
subject { described_class.new(user) }
- context 'JSON parse error' do
+ context "JSON parse error" do
before do
Struct.new("Request", :body, :success?)
end
- it 'yields an error on malformed JSON' do
+ it "yields an error on malformed JSON" do
bad_json = Struct::Request.new("I'm not json", true)
expect { subject.send(:json_response, bad_json) }.to raise_error(Mattermost::ClientError)
end
- it 'shows a client error if the request was unsuccessful' do
+ it "shows a client error if the request was unsuccessful" do
bad_request = Struct::Request.new("true", false)
expect { subject.send(:json_response, bad_request) }.to raise_error(Mattermost::ClientError)
diff --git a/spec/lib/mattermost/command_spec.rb b/spec/lib/mattermost/command_spec.rb
index 7c194749dfb..847d4c06610 100644
--- a/spec/lib/mattermost/command_spec.rb
+++ b/spec/lib/mattermost/command_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe Mattermost::Command do
- let(:params) { { 'token' => 'token', team_id: 'abc' } }
+ let(:params) { {"token" => "token", :team_id => "abc"} }
before do
session = Mattermost::Session.new(nil)
- session.base_uri = 'http://mattermost.example.com'
+ session.base_uri = "http://mattermost.example.com"
allow_any_instance_of(Mattermost::Client).to receive(:with_session)
.and_yield(session)
end
- describe '#create' do
+ describe "#create" do
let(:params) do
- { team_id: 'abc',
- trigger: 'gitlab' }
+ {team_id: "abc",
+ trigger: "gitlab",}
end
subject { described_class.new(nil).create(params) }
- context 'for valid trigger word' do
+ context "for valid trigger word" do
before do
- stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
+ stub_request(:post, "http://mattermost.example.com/api/v4/commands")
.with(body: {
- team_id: 'abc',
- trigger: 'gitlab'
+ team_id: "abc",
+ trigger: "gitlab",
}.to_json)
.to_return(
status: 201,
- headers: { 'Content-Type' => 'application/json' },
- body: { token: 'token' }.to_json
+ headers: {"Content-Type" => "application/json"},
+ body: {token: "token"}.to_json
)
end
- it 'returns a token' do
- is_expected.to eq('token')
+ it "returns a token" do
+ is_expected.to eq("token")
end
end
- context 'for error message' do
+ context "for error message" do
before do
- stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
+ stub_request(:post, "http://mattermost.example.com/api/v4/commands")
.to_return(
status: 400,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: {
- id: 'api.command.duplicate_trigger.app_error',
- message: 'This trigger word is already in use. Please choose another word.',
- detailed_error: '',
- request_id: 'obc374man7bx5r3dbc1q5qhf3r',
- status_code: 400
+ id: "api.command.duplicate_trigger.app_error",
+ message: "This trigger word is already in use. Please choose another word.",
+ detailed_error: "",
+ request_id: "obc374man7bx5r3dbc1q5qhf3r",
+ status_code: 400,
}.to_json
)
end
- it 'raises an error with message' do
- expect { subject }.to raise_error(Mattermost::Error, 'This trigger word is already in use. Please choose another word.')
+ it "raises an error with message" do
+ expect { subject }.to raise_error(Mattermost::Error, "This trigger word is already in use. Please choose another word.")
end
end
end
diff --git a/spec/lib/mattermost/session_spec.rb b/spec/lib/mattermost/session_spec.rb
index 77fea5b2d24..09f115c20db 100644
--- a/spec/lib/mattermost/session_spec.rb
+++ b/spec/lib/mattermost/session_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Mattermost::Session, type: :request do
include ExclusiveLeaseHelpers
@@ -20,43 +20,44 @@ describe Mattermost::Session, type: :request do
subject.base_uri = mattermost_url
end
- describe '#with session' do
- let(:location) { 'http://location.tld' }
- let(:cookie_header) {'MMOAUTH=taskik8az7rq8k6rkpuas7htia; Path=/;'}
+ describe "#with session" do
+ let(:location) { "http://location.tld" }
+ let(:cookie_header) {"MMOAUTH=taskik8az7rq8k6rkpuas7htia; Path=/;"}
let!(:stub) do
WebMock.stub_request(:get, "#{mattermost_url}/oauth/gitlab/login")
- .to_return(headers: { 'location' => location, 'Set-Cookie' => cookie_header }, status: 302)
+ .to_return(headers: {"location" => location, "Set-Cookie" => cookie_header}, status: 302)
end
- context 'without oauth uri' do
- it 'makes a request to the oauth uri' do
+ context "without oauth uri" do
+ it "makes a request to the oauth uri" do
expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
end
end
- context 'with oauth_uri' do
+ context "with oauth_uri" do
let!(:doorkeeper) do
Doorkeeper::Application.create(
- name: 'GitLab Mattermost',
+ name: "GitLab Mattermost",
redirect_uri: "#{mattermost_url}/signup/gitlab/complete\n#{mattermost_url}/login/gitlab/complete",
- scopes: '')
+ scopes: ""
+ )
end
- context 'without token_uri' do
- it 'can not create a session' do
- expect do
+ context "without token_uri" do
+ it "can not create a session" do
+ expect {
subject.with_session
- end.to raise_error(Mattermost::NoSessionError)
+ }.to raise_error(Mattermost::NoSessionError)
end
end
- context 'with token_uri' do
+ context "with token_uri" do
let(:state) { "state" }
let(:params) do
- { response_type: "code",
- client_id: doorkeeper.uid,
- redirect_uri: "#{mattermost_url}/signup/gitlab/complete",
- state: state }
+ {response_type: "code",
+ client_id: doorkeeper.uid,
+ redirect_uri: "#{mattermost_url}/signup/gitlab/complete",
+ state: state,}
end
let(:location) do
"#{gitlab_url}/oauth/authorize?#{URI.encode_www_form(params)}"
@@ -64,55 +65,55 @@ describe Mattermost::Session, type: :request do
before do
WebMock.stub_request(:get, "#{mattermost_url}/signup/gitlab/complete")
- .with(query: hash_including({ 'state' => state }))
+ .with(query: hash_including({"state" => state}))
.to_return do |request|
post "/oauth/token",
params: {
client_id: doorkeeper.uid,
client_secret: doorkeeper.secret,
redirect_uri: params[:redirect_uri],
- grant_type: 'authorization_code',
- code: request.uri.query_values['code']
+ grant_type: "authorization_code",
+ code: request.uri.query_values["code"],
}
if response.status == 200
- { headers: { 'token' => 'thisworksnow' }, status: 202 }
+ {headers: {"token" => "thisworksnow"}, status: 202}
end
end
WebMock.stub_request(:post, "#{mattermost_url}/api/v4/users/logout")
- .to_return(headers: { Authorization: 'token thisworksnow' }, status: 200)
+ .to_return(headers: {Authorization: "token thisworksnow"}, status: 200)
end
- it 'can set up a session' do
+ it "can set up a session" do
subject.with_session do |session|
end
expect(subject.token).not_to be_nil
end
- it 'returns the value of the block' do
- result = subject.with_session do |session|
+ it "returns the value of the block" do
+ result = subject.with_session { |session|
"value"
- end
+ }
expect(result).to eq("value")
end
end
end
- context 'exclusive lease' do
- let(:lease_key) { 'mattermost:session' }
+ context "exclusive lease" do
+ let(:lease_key) { "mattermost:session" }
- it 'tries to obtain a lease' do
- expect_to_obtain_exclusive_lease(lease_key, 'uuid')
- expect_to_cancel_exclusive_lease(lease_key, 'uuid')
+ it "tries to obtain a lease" do
+ expect_to_obtain_exclusive_lease(lease_key, "uuid")
+ expect_to_cancel_exclusive_lease(lease_key, "uuid")
# Cannot set up a session, but we should still cancel the lease
expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
end
- it 'returns a NoSessionError error without lease' do
+ it "returns a NoSessionError error without lease" do
stub_exclusive_lease_taken(lease_key)
expect { subject.with_session }.to raise_error(Mattermost::NoSessionError)
diff --git a/spec/lib/mattermost/team_spec.rb b/spec/lib/mattermost/team_spec.rb
index 030aa5d06a8..828431f3279 100644
--- a/spec/lib/mattermost/team_spec.rb
+++ b/spec/lib/mattermost/team_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Mattermost::Team do
before do
session = Mattermost::Session.new(nil)
- session.base_uri = 'http://mattermost.example.com'
+ session.base_uri = "http://mattermost.example.com"
allow_any_instance_of(Mattermost::Client).to receive(:with_session)
.and_yield(session)
end
- describe '#all' do
+ describe "#all" do
subject { described_class.new(nil).all }
let(:test_team) do
@@ -25,53 +25,53 @@ describe Mattermost::Team do
"company_name" => "",
"allowed_domains" => "",
"invite_id" => "o4utakb9jtb7imctdfzbf9r5ro",
- "allow_open_invite" => false
+ "allow_open_invite" => false,
}
end
- context 'for valid request' do
+ context "for valid request" do
let(:response) { [test_team] }
before do
- stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
+ stub_request(:get, "http://mattermost.example.com/api/v4/users/me/teams")
.to_return(
status: 200,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: response.to_json
)
end
- it 'returns teams' do
+ it "returns teams" do
is_expected.to eq(response)
end
end
- context 'for error message' do
+ context "for error message" do
before do
- stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
+ stub_request(:get, "http://mattermost.example.com/api/v4/users/me/teams")
.to_return(
status: 500,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: {
- id: 'api.team.list.app_error',
- message: 'Cannot list teams.',
- detailed_error: '',
- request_id: 'obc374man7bx5r3dbc1q5qhf3r',
- status_code: 500
+ id: "api.team.list.app_error",
+ message: "Cannot list teams.",
+ detailed_error: "",
+ request_id: "obc374man7bx5r3dbc1q5qhf3r",
+ status_code: 500,
}.to_json
)
end
- it 'raises an error with message' do
- expect { subject }.to raise_error(Mattermost::Error, 'Cannot list teams.')
+ it "raises an error with message" do
+ expect { subject }.to raise_error(Mattermost::Error, "Cannot list teams.")
end
end
end
- describe '#create' do
+ describe "#create" do
subject { described_class.new(nil).create(name: "devteam", display_name: "Dev Team", type: "O") }
- context 'for a new team' do
+ context "for a new team" do
let(:response) do
{
"id" => "cuojfcetjty7tb4pxe47pwpndo",
@@ -86,7 +86,7 @@ describe Mattermost::Team do
"company_name" => "",
"allowed_domains" => "",
"invite_id" => "7mp9d3ayaj833ymmkfnid8js6w",
- "allow_open_invite" => false
+ "allow_open_invite" => false,
}
end
@@ -95,44 +95,44 @@ describe Mattermost::Team do
.to_return(
status: 201,
body: response.to_json,
- headers: { 'Content-Type' => 'application/json' }
+ headers: {"Content-Type" => "application/json"}
)
end
- it 'returns the new team' do
+ it "returns the new team" do
is_expected.to eq(response)
end
end
- context 'for existing team' do
+ context "for existing team" do
before do
- stub_request(:post, 'http://mattermost.example.com/api/v4/teams')
+ stub_request(:post, "http://mattermost.example.com/api/v4/teams")
.to_return(
status: 400,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: {
- id: "store.sql_team.save.domain_exists.app_error",
- message: "A team with that name already exists",
- detailed_error: "",
- request_id: "1hsb5bxs97r8bdggayy7n9gxaw",
- status_code: 400
+ id: "store.sql_team.save.domain_exists.app_error",
+ message: "A team with that name already exists",
+ detailed_error: "",
+ request_id: "1hsb5bxs97r8bdggayy7n9gxaw",
+ status_code: 400,
}.to_json
)
end
- it 'raises an error with message' do
- expect { subject }.to raise_error(Mattermost::Error, 'A team with that name already exists')
+ it "raises an error with message" do
+ expect { subject }.to raise_error(Mattermost::Error, "A team with that name already exists")
end
end
end
- describe '#delete' do
+ describe "#delete" do
subject { described_class.new(nil).destroy(team_id: "cuojfcetjty7tb4pxe47pwpndo") }
- context 'for an existing team' do
+ context "for an existing team" do
let(:response) do
{
- "status" => "OK"
+ "status" => "OK",
}
end
@@ -141,16 +141,16 @@ describe Mattermost::Team do
.to_return(
status: 200,
body: response.to_json,
- headers: { 'Content-Type' => 'application/json' }
+ headers: {"Content-Type" => "application/json"}
)
end
- it 'returns team status' do
+ it "returns team status" do
is_expected.to eq(response)
end
end
- context 'for an unknown team' do
+ context "for an unknown team" do
before do
stub_request(:delete, "http://mattermost.example.com/api/v4/teams/cuojfcetjty7tb4pxe47pwpndo")
.to_return(
@@ -160,13 +160,13 @@ describe Mattermost::Team do
message: "We couldn't find the existing team",
detailed_error: "",
request_id: "my114ab5nbnui8c9pes4kz8mza",
- status_code: 404
+ status_code: 404,
}.to_json,
- headers: { 'Content-Type' => 'application/json' }
+ headers: {"Content-Type" => "application/json"}
)
end
- it 'raises an error with message' do
+ it "raises an error with message" do
expect { subject }.to raise_error(Mattermost::Error, "We couldn't find the existing team")
end
end
diff --git a/spec/lib/microsoft_teams/activity_spec.rb b/spec/lib/microsoft_teams/activity_spec.rb
index 7890ae2e7b0..73fd0dd3fc0 100644
--- a/spec/lib/microsoft_teams/activity_spec.rb
+++ b/spec/lib/microsoft_teams/activity_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe MicrosoftTeams::Activity do
- subject { described_class.new(title: 'title', subtitle: 'subtitle', text: 'text', image: 'image') }
+ subject { described_class.new(title: "title", subtitle: "subtitle", text: "text", image: "image") }
- describe '#prepare' do
- it 'returns the correct JSON object' do
+ describe "#prepare" do
+ it "returns the correct JSON object" do
expect(subject.prepare).to eq({
- 'activityTitle' => 'title',
- 'activitySubtitle' => 'subtitle',
- 'activityText' => 'text',
- 'activityImage' => 'image'
+ "activityTitle" => "title",
+ "activitySubtitle" => "subtitle",
+ "activityText" => "text",
+ "activityImage" => "image",
})
end
end
diff --git a/spec/lib/microsoft_teams/notifier_spec.rb b/spec/lib/microsoft_teams/notifier_spec.rb
index 2aaa7c24ad8..2e1ed29569f 100644
--- a/spec/lib/microsoft_teams/notifier_spec.rb
+++ b/spec/lib/microsoft_teams/notifier_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
describe MicrosoftTeams::Notifier do
subject { described_class.new(webhook_url) }
- let(:webhook_url) { 'https://example.gitlab.com/'}
- let(:header) { { 'Content-Type' => 'application/json' } }
+ let(:webhook_url) { "https://example.gitlab.com/"}
+ let(:header) { {"Content-Type" => "application/json"} }
let(:options) do
{
- title: 'JohnDoe4/project2',
- summary: '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6',
+ title: "JohnDoe4/project2",
+ summary: "[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6",
activity: {
- title: 'Issue opened by user6',
- subtitle: 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
- text: '[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)',
- image: 'http://someimage.com'
+ title: "Issue opened by user6",
+ subtitle: "in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)",
+ text: "[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)",
+ image: "http://someimage.com",
},
- attachments: 'please fix'
+ attachments: "please fix",
}
end
let(:body) do
{
- 'sections' => [
+ "sections" => [
{
- 'activityTitle' => 'Issue opened by user6',
- 'activitySubtitle' => 'in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)',
- 'activityText' => '[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)',
- 'activityImage' => 'http://someimage.com'
+ "activityTitle" => "Issue opened by user6",
+ "activitySubtitle" => "in [JohnDoe4/project2](http://localhost/namespace2/gitlabhq)",
+ "activityText" => "[#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1)",
+ "activityImage" => "http://someimage.com",
},
{
- 'title' => 'Details',
- 'facts' => [
+ "title" => "Details",
+ "facts" => [
{
- 'name' => 'Attachments',
- 'value' => 'please fix'
- }
- ]
- }
+ "name" => "Attachments",
+ "value" => "please fix",
+ },
+ ],
+ },
],
- 'title' => 'JohnDoe4/project2',
- 'summary' => '[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6'
+ "title" => "JohnDoe4/project2",
+ "summary" => "[[JohnDoe4/project2](http://localhost/namespace2/gitlabhq)] Issue [#1 Awesome issue](http://localhost/namespace2/gitlabhq/issues/1) opened by user6",
}
end
- describe '#ping' do
+ describe "#ping" do
before do
- stub_request(:post, webhook_url).with(body: JSON(body), headers: { 'Content-Type' => 'application/json' }).to_return(status: 200, body: "", headers: {})
+ stub_request(:post, webhook_url).with(body: JSON(body), headers: {"Content-Type" => "application/json"}).to_return(status: 200, body: "", headers: {})
end
- it 'expects to receive successful answer' do
+ it "expects to receive successful answer" do
expect(subject.ping(options)).to be true
end
end
diff --git a/spec/lib/milestone_array_spec.rb b/spec/lib/milestone_array_spec.rb
index df91677b925..eaf6eca99e5 100644
--- a/spec/lib/milestone_array_spec.rb
+++ b/spec/lib/milestone_array_spec.rb
@@ -1,34 +1,34 @@
-require 'spec_helper'
+require "spec_helper"
describe MilestoneArray do
- let(:object1) { instance_double("BirdMilestone", due_date: Time.now, start_date: Time.now - 15.days, title: 'v2.0') }
- let(:object2) { instance_double("CatMilestone", due_date: Time.now - 1.day, start_date: nil, title: 'v1.0') }
- let(:object3) { instance_double("DogMilestone", due_date: nil, start_date: Time.now - 30.days, title: 'v3.0') }
+ let(:object1) { instance_double("BirdMilestone", due_date: Time.now, start_date: Time.now - 15.days, title: "v2.0") }
+ let(:object2) { instance_double("CatMilestone", due_date: Time.now - 1.day, start_date: nil, title: "v1.0") }
+ let(:object3) { instance_double("DogMilestone", due_date: nil, start_date: Time.now - 30.days, title: "v3.0") }
let(:array) { [object1, object3, object2] }
- describe '#sort' do
- it 'reorders array with due date in ascending order with nulls last' do
- expect(described_class.sort(array, 'due_date_asc')).to eq([object2, object1, object3])
+ describe "#sort" do
+ it "reorders array with due date in ascending order with nulls last" do
+ expect(described_class.sort(array, "due_date_asc")).to eq([object2, object1, object3])
end
- it 'reorders array with due date in desc order with nulls last' do
- expect(described_class.sort(array, 'due_date_desc')).to eq([object1, object2, object3])
+ it "reorders array with due date in desc order with nulls last" do
+ expect(described_class.sort(array, "due_date_desc")).to eq([object1, object2, object3])
end
- it 'reorders array with start date in ascending order with nulls last' do
- expect(described_class.sort(array, 'start_date_asc')).to eq([object3, object1, object2])
+ it "reorders array with start date in ascending order with nulls last" do
+ expect(described_class.sort(array, "start_date_asc")).to eq([object3, object1, object2])
end
- it 'reorders array with start date in descending order with nulls last' do
- expect(described_class.sort(array, 'start_date_desc')).to eq([object1, object3, object2])
+ it "reorders array with start date in descending order with nulls last" do
+ expect(described_class.sort(array, "start_date_desc")).to eq([object1, object3, object2])
end
- it 'reorders array with title in ascending order' do
- expect(described_class.sort(array, 'name_asc')).to eq([object2, object1, object3])
+ it "reorders array with title in ascending order" do
+ expect(described_class.sort(array, "name_asc")).to eq([object2, object1, object3])
end
- it 'reorders array with title in descending order' do
- expect(described_class.sort(array, 'name_desc')).to eq([object3, object1, object2])
+ it "reorders array with title in descending order" do
+ expect(described_class.sort(array, "name_desc")).to eq([object3, object1, object2])
end
end
end
diff --git a/spec/lib/object_storage/direct_upload_spec.rb b/spec/lib/object_storage/direct_upload_spec.rb
index 8ccbd90ddb8..bb4e8f84a22 100644
--- a/spec/lib/object_storage/direct_upload_spec.rb
+++ b/spec/lib/object_storage/direct_upload_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe ObjectStorage::DirectUpload do
let(:credentials) do
{
- provider: 'AWS',
- aws_access_key_id: 'AWS_ACCESS_KEY_ID',
- aws_secret_access_key: 'AWS_SECRET_ACCESS_KEY'
+ provider: "AWS",
+ aws_access_key_id: "AWS_ACCESS_KEY_ID",
+ aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
}
end
- let(:storage_url) { 'https://uploads.s3.amazonaws.com/' }
+ let(:storage_url) { "https://uploads.s3.amazonaws.com/" }
- let(:bucket_name) { 'uploads' }
- let(:object_name) { 'tmp/uploads/my-file' }
+ let(:bucket_name) { "uploads" }
+ let(:object_name) { "tmp/uploads/my-file" }
let(:maximum_size) { 1.gigabyte }
let(:direct_upload) { described_class.new(credentials, bucket_name, object_name, has_length: has_length, maximum_size: maximum_size) }
@@ -21,8 +21,8 @@ describe ObjectStorage::DirectUpload do
Fog.unmock!
end
- describe '#has_length' do
- context 'is known' do
+ describe "#has_length" do
+ context "is known" do
let(:has_length) { true }
let(:maximum_size) { nil }
@@ -31,10 +31,10 @@ describe ObjectStorage::DirectUpload do
end
end
- context 'is unknown' do
+ context "is unknown" do
let(:has_length) { false }
- context 'and maximum size is specified' do
+ context "and maximum size is specified" do
let(:maximum_size) { 1.gigabyte }
it "does not raise an error" do
@@ -42,7 +42,7 @@ describe ObjectStorage::DirectUpload do
end
end
- context 'and maximum size is not specified' do
+ context "and maximum size is not specified" do
let(:maximum_size) { nil }
it "raises an error" do
@@ -52,10 +52,10 @@ describe ObjectStorage::DirectUpload do
end
end
- describe '#to_hash' do
+ describe "#to_hash" do
subject { direct_upload.to_hash }
- shared_examples 'a valid upload' do
+ shared_examples "a valid upload" do
it "returns valid structure" do
expect(subject).to have_key(:Timeout)
expect(subject[:GetURL]).to start_with(storage_url)
@@ -66,25 +66,25 @@ describe ObjectStorage::DirectUpload do
end
end
- shared_examples 'a valid upload with multipart data' do
+ shared_examples "a valid upload with multipart data" do
before do
stub_object_storage_multipart_init(storage_url, "myUpload")
end
- it_behaves_like 'a valid upload'
+ it_behaves_like "a valid upload"
it "returns valid structure" do
expect(subject).to have_key(:MultipartUpload)
expect(subject[:MultipartUpload]).to have_key(:PartSize)
expect(subject[:MultipartUpload][:PartURLs]).to all(start_with(storage_url))
- expect(subject[:MultipartUpload][:PartURLs]).to all(include('uploadId=myUpload'))
+ expect(subject[:MultipartUpload][:PartURLs]).to all(include("uploadId=myUpload"))
expect(subject[:MultipartUpload][:CompleteURL]).to start_with(storage_url)
- expect(subject[:MultipartUpload][:CompleteURL]).to include('uploadId=myUpload')
+ expect(subject[:MultipartUpload][:CompleteURL]).to include("uploadId=myUpload")
expect(subject[:MultipartUpload][:AbortURL]).to start_with(storage_url)
- expect(subject[:MultipartUpload][:AbortURL]).to include('uploadId=myUpload')
+ expect(subject[:MultipartUpload][:AbortURL]).to include("uploadId=myUpload")
end
- it 'uses only strings in query parameters' do
+ it "uses only strings in query parameters" do
expect(direct_upload.send(:connection)).to receive(:signed_url).at_least(:once) do |params|
if params[:query]
expect(params[:query].keys.all? { |key| key.is_a?(String) }).to be_truthy
@@ -95,57 +95,57 @@ describe ObjectStorage::DirectUpload do
end
end
- shared_examples 'a valid upload without multipart data' do
- it_behaves_like 'a valid upload'
+ shared_examples "a valid upload without multipart data" do
+ it_behaves_like "a valid upload"
it "returns valid structure" do
expect(subject).not_to have_key(:MultipartUpload)
end
end
- context 'when AWS is used' do
- context 'when length is known' do
+ context "when AWS is used" do
+ context "when length is known" do
let(:has_length) { true }
- it_behaves_like 'a valid upload without multipart data'
+ it_behaves_like "a valid upload without multipart data"
end
- context 'when length is unknown' do
+ context "when length is unknown" do
let(:has_length) { false }
- it_behaves_like 'a valid upload with multipart data' do
- context 'when maximum upload size is 10MB' do
+ it_behaves_like "a valid upload with multipart data" do
+ context "when maximum upload size is 10MB" do
let(:maximum_size) { 10.megabyte }
- it 'returns only 2 parts' do
+ it "returns only 2 parts" do
expect(subject[:MultipartUpload][:PartURLs].length).to eq(2)
end
- it 'part size is minimum, 5MB' do
+ it "part size is minimum, 5MB" do
expect(subject[:MultipartUpload][:PartSize]).to eq(5.megabyte)
end
end
- context 'when maximum upload size is 12MB' do
+ context "when maximum upload size is 12MB" do
let(:maximum_size) { 12.megabyte }
- it 'returns only 3 parts' do
+ it "returns only 3 parts" do
expect(subject[:MultipartUpload][:PartURLs].length).to eq(3)
end
- it 'part size is rounded-up to 5MB' do
+ it "part size is rounded-up to 5MB" do
expect(subject[:MultipartUpload][:PartSize]).to eq(5.megabyte)
end
end
- context 'when maximum upload size is 49GB' do
+ context "when maximum upload size is 49GB" do
let(:maximum_size) { 49.gigabyte }
- it 'returns maximum, 100 parts' do
+ it "returns maximum, 100 parts" do
expect(subject[:MultipartUpload][:PartURLs].length).to eq(100)
end
- it 'part size is rounded-up to 5MB' do
+ it "part size is rounded-up to 5MB" do
expect(subject[:MultipartUpload][:PartSize]).to eq(505.megabyte)
end
end
@@ -153,27 +153,27 @@ describe ObjectStorage::DirectUpload do
end
end
- context 'when Google is used' do
+ context "when Google is used" do
let(:credentials) do
{
- provider: 'Google',
- google_storage_access_key_id: 'GOOGLE_ACCESS_KEY_ID',
- google_storage_secret_access_key: 'GOOGLE_SECRET_ACCESS_KEY'
+ provider: "Google",
+ google_storage_access_key_id: "GOOGLE_ACCESS_KEY_ID",
+ google_storage_secret_access_key: "GOOGLE_SECRET_ACCESS_KEY",
}
end
- let(:storage_url) { 'https://storage.googleapis.com/uploads/' }
+ let(:storage_url) { "https://storage.googleapis.com/uploads/" }
- context 'when length is known' do
+ context "when length is known" do
let(:has_length) { true }
- it_behaves_like 'a valid upload without multipart data'
+ it_behaves_like "a valid upload without multipart data"
end
- context 'when length is unknown' do
+ context "when length is unknown" do
let(:has_length) { false }
- it_behaves_like 'a valid upload without multipart data'
+ it_behaves_like "a valid upload without multipart data"
end
end
end
diff --git a/spec/lib/omni_auth/strategies/jwt_spec.rb b/spec/lib/omni_auth/strategies/jwt_spec.rb
index c1eaf0bb0bf..1a4f35907ce 100644
--- a/spec/lib/omni_auth/strategies/jwt_spec.rb
+++ b/spec/lib/omni_auth/strategies/jwt_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe OmniAuth::Strategies::Jwt do
include Rack::Test::Methods
include DeviseHelpers
- context '#decoded' do
+ context "#decoded" do
subject { described_class.new({}) }
let(:timestamp) { Time.now.to_i }
let(:jwt_config) { Devise.omniauth_configs[:jwt] }
@@ -13,10 +13,10 @@ describe OmniAuth::Strategies::Jwt do
id: 123,
name: "user_example",
email: "user@example.com",
- iat: timestamp
+ iat: timestamp,
}
end
- let(:algorithm) { 'HS256' }
+ let(:algorithm) { "HS256" }
let(:secret) { jwt_config.strategy.secret }
let(:private_key) { secret }
let(:payload) { JWT.encode(claims, private_key, algorithm) }
@@ -28,20 +28,20 @@ describe OmniAuth::Strategies::Jwt do
# We use Rack::Request instead of ActionDispatch::Request because
# Rack::Test::Methods enables testing of this module.
expect_next_instance_of(Rack::Request) do |rack_request|
- expect(rack_request).to receive(:params).and_return('jwt' => payload)
+ expect(rack_request).to receive(:params).and_return("jwt" => payload)
end
end
ECDSA_NAMED_CURVES = {
- 'ES256' => 'prime256v1',
- 'ES384' => 'secp384r1',
- 'ES512' => 'secp521r1'
+ "ES256" => "prime256v1",
+ "ES384" => "secp384r1",
+ "ES512" => "secp521r1",
}.freeze
{
OpenSSL::PKey::RSA => %w[RS256 RS384 RS512],
OpenSSL::PKey::EC => %w[ES256 ES384 ES512],
- String => %w[HS256 HS384 HS512]
+ String => %w[HS256 HS384 HS512],
}.each do |private_key_class, algorithms|
algorithms.each do |algorithm|
context "when the #{algorithm} algorithm is used" do
@@ -60,7 +60,7 @@ describe OmniAuth::Strategies::Jwt do
end
let(:private_key) { private_key_class ? private_key_class.new(secret) : secret }
- it 'decodes the user information' do
+ it "decodes the user information" do
result = subject.decoded
expect(result).to eq(claims.stringify_keys)
@@ -69,26 +69,26 @@ describe OmniAuth::Strategies::Jwt do
end
end
- context 'required claims is missing' do
+ context "required claims is missing" do
let(:claims) do
{
id: 123,
email: "user@example.com",
- iat: timestamp
+ iat: timestamp,
}
end
- it 'raises error' do
+ it "raises error" do
expect { subject.decoded }.to raise_error(OmniAuth::Strategies::Jwt::ClaimInvalid)
end
end
- context 'when valid_within is specified but iat attribute is missing in response' do
+ context "when valid_within is specified but iat attribute is missing in response" do
let(:claims) do
{
id: 123,
name: "user_example",
- email: "user@example.com"
+ email: "user@example.com",
}
end
@@ -97,18 +97,18 @@ describe OmniAuth::Strategies::Jwt do
subject.options[:valid_within] = 2.days.to_s
end
- it 'raises error' do
+ it "raises error" do
expect { subject.decoded }.to raise_error(OmniAuth::Strategies::Jwt::ClaimInvalid)
end
end
- context 'when timestamp claim is too skewed from present' do
+ context "when timestamp claim is too skewed from present" do
let(:claims) do
{
id: 123,
name: "user_example",
email: "user@example.com",
- iat: timestamp - 10.minutes.to_i
+ iat: timestamp - 10.minutes.to_i,
}
end
@@ -117,7 +117,7 @@ describe OmniAuth::Strategies::Jwt do
subject.options[:valid_within] = 2.seconds.to_s
end
- it 'raises error' do
+ it "raises error" do
expect { subject.decoded }.to raise_error(OmniAuth::Strategies::Jwt::ClaimInvalid)
end
end
diff --git a/spec/lib/quality/helm_client_spec.rb b/spec/lib/quality/helm_client_spec.rb
index 7abb9688d5a..def48d726b8 100644
--- a/spec/lib/quality/helm_client_spec.rb
+++ b/spec/lib/quality/helm_client_spec.rb
@@ -1,111 +1,111 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
RSpec.describe Quality::HelmClient do
- let(:namespace) { 'review-apps-ee' }
- let(:release_name) { 'my-release' }
+ let(:namespace) { "review-apps-ee" }
+ let(:release_name) { "my-release" }
let(:raw_helm_list_page1) do
<<~OUTPUT
- {"Next":"review-6709-group-t40qbv",
- "Releases":[
- {"Name":"review-qa-60-reor-1mugd1", "Revision":1,"Updated":"Thu Oct 4 17:52:31 2018","Status":"FAILED", "Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-7846-fix-s-261vd6","Revision":1,"Updated":"Thu Oct 4 17:33:29 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-7867-snowp-lzo3iy","Revision":1,"Updated":"Thu Oct 4 17:22:14 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-rename-geo-o4a780","Revision":1,"Updated":"Thu Oct 4 17:14:57 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-5781-opera-0k93fx","Revision":1,"Updated":"Thu Oct 4 17:06:15 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-6709-group-2pzeec","Revision":1,"Updated":"Thu Oct 4 16:36:59 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-ce-to-ee-2-l554mn","Revision":1,"Updated":"Thu Oct 4 16:27:02 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-epics-e2e-m690eb","Revision":1,"Updated":"Thu Oct 4 16:08:26 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-7126-admin-06fae2","Revision":1,"Updated":"Thu Oct 4 15:56:35 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
- {"Name":"review-6983-promo-xyou11","Revision":1,"Updated":"Thu Oct 4 15:15:34 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"}
- ]}
+ {"Next":"review-6709-group-t40qbv",
+ "Releases":[
+ {"Name":"review-qa-60-reor-1mugd1", "Revision":1,"Updated":"Thu Oct 4 17:52:31 2018","Status":"FAILED", "Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-7846-fix-s-261vd6","Revision":1,"Updated":"Thu Oct 4 17:33:29 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-7867-snowp-lzo3iy","Revision":1,"Updated":"Thu Oct 4 17:22:14 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-rename-geo-o4a780","Revision":1,"Updated":"Thu Oct 4 17:14:57 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-5781-opera-0k93fx","Revision":1,"Updated":"Thu Oct 4 17:06:15 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-6709-group-2pzeec","Revision":1,"Updated":"Thu Oct 4 16:36:59 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-ce-to-ee-2-l554mn","Revision":1,"Updated":"Thu Oct 4 16:27:02 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-epics-e2e-m690eb","Revision":1,"Updated":"Thu Oct 4 16:08:26 2018","Status":"DEPLOYED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-7126-admin-06fae2","Revision":1,"Updated":"Thu Oct 4 15:56:35 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"},
+ {"Name":"review-6983-promo-xyou11","Revision":1,"Updated":"Thu Oct 4 15:15:34 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"}
+ ]}
OUTPUT
end
let(:raw_helm_list_page2) do
<<~OUTPUT
- {"Releases":[
- {"Name":"review-6709-group-t40qbv","Revision":1,"Updated":"Thu Oct 4 17:52:31 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"}
- ]}
+ {"Releases":[
+ {"Name":"review-6709-group-t40qbv","Revision":1,"Updated":"Thu Oct 4 17:52:31 2018","Status":"FAILED","Chart":"gitlab-1.1.3","AppVersion":"master","Namespace":"#{namespace}"}
+ ]}
OUTPUT
end
subject { described_class.new(namespace: namespace) }
- describe '#releases' do
- it 'raises an error if the Helm command fails' do
+ describe "#releases" do
+ it "raises an error if the Helm command fails" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json)])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: false)))
expect { subject.releases.to_a }.to raise_error(described_class::CommandFailedError)
end
- it 'calls helm list with default arguments' do
+ it "calls helm list with default arguments" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json)])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: true)))
subject.releases.to_a
end
- it 'calls helm list with extra arguments' do
+ it "calls helm list with extra arguments" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json --deployed)])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: true)))
- subject.releases(args: ['--deployed']).to_a
+ subject.releases(args: ["--deployed"]).to_a
end
- it 'returns a list of Release objects' do
+ it "returns a list of Release objects" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json --deployed)])
- .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page2, '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page2, "", double(success?: true)))
- releases = subject.releases(args: ['--deployed']).to_a
+ releases = subject.releases(args: ["--deployed"]).to_a
expect(releases.size).to eq(1)
expect(releases[0]).to have_attributes(
- name: 'review-6709-group-t40qbv',
+ name: "review-6709-group-t40qbv",
revision: 1,
- last_update: Time.parse('Thu Oct 4 17:52:31 2018'),
- status: 'FAILED',
- chart: 'gitlab-1.1.3',
- app_version: 'master',
+ last_update: Time.parse("Thu Oct 4 17:52:31 2018"),
+ status: "FAILED",
+ chart: "gitlab-1.1.3",
+ app_version: "master",
namespace: namespace
)
end
- it 'automatically paginates releases' do
+ it "automatically paginates releases" do
expect(Gitlab::Popen).to receive(:popen_with_detail).ordered
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json)])
- .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page1, '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page1, "", double(success?: true)))
expect(Gitlab::Popen).to receive(:popen_with_detail).ordered
.with([%(helm list --namespace "#{namespace}" --tiller-namespace "#{namespace}" --output json --offset review-6709-group-t40qbv)])
- .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page2, '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], raw_helm_list_page2, "", double(success?: true)))
releases = subject.releases.to_a
expect(releases.size).to eq(11)
- expect(releases.last.name).to eq('review-6709-group-t40qbv')
+ expect(releases.last.name).to eq("review-6709-group-t40qbv")
end
end
- describe '#delete' do
- it 'raises an error if the Helm command fails' do
+ describe "#delete" do
+ it "raises an error if the Helm command fails" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm delete --tiller-namespace "#{namespace}" --purge #{release_name})])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: false)))
expect { subject.delete(release_name: release_name) }.to raise_error(described_class::CommandFailedError)
end
- it 'calls helm delete with default arguments' do
+ it "calls helm delete with default arguments" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(helm delete --tiller-namespace "#{namespace}" --purge #{release_name})])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: true)))
- expect(subject.delete(release_name: release_name)).to eq('')
+ expect(subject.delete(release_name: release_name)).to eq("")
end
end
end
diff --git a/spec/lib/quality/kubernetes_client_spec.rb b/spec/lib/quality/kubernetes_client_spec.rb
index f35d9464d48..c17aca53b1b 100644
--- a/spec/lib/quality/kubernetes_client_spec.rb
+++ b/spec/lib/quality/kubernetes_client_spec.rb
@@ -1,30 +1,30 @@
# frozen_string_literal: true
-require 'fast_spec_helper'
+require "fast_spec_helper"
RSpec.describe Quality::KubernetesClient do
- let(:namespace) { 'review-apps-ee' }
- let(:release_name) { 'my-release' }
+ let(:namespace) { "review-apps-ee" }
+ let(:release_name) { "my-release" }
subject { described_class.new(namespace: namespace) }
- describe '#cleanup' do
- it 'raises an error if the Kubernetes command fails' do
+ describe "#cleanup" do
+ it "raises an error if the Kubernetes command fails" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(kubectl --namespace "#{namespace}" delete ) \
- 'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa ' \
+ "ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa " \
"--now -l release=\"#{release_name}\""])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: false)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: false)))
expect { subject.cleanup(release_name: release_name) }.to raise_error(described_class::CommandFailedError)
end
- it 'calls kubectl with the correct arguments' do
+ it "calls kubectl with the correct arguments" do
expect(Gitlab::Popen).to receive(:popen_with_detail)
.with([%(kubectl --namespace "#{namespace}" delete ) \
- 'ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa ' \
+ "ingress,svc,pdb,hpa,deploy,statefulset,job,pod,secret,configmap,pvc,secret,clusterrole,clusterrolebinding,role,rolebinding,sa " \
"--now -l release=\"#{release_name}\""])
- .and_return(Gitlab::Popen::Result.new([], '', '', double(success?: true)))
+ .and_return(Gitlab::Popen::Result.new([], "", "", double(success?: true)))
# We're not verifying the output here, just silencing it
expect { subject.cleanup(release_name: release_name) }.to output.to_stdout
diff --git a/spec/lib/rspec_flaky/config_spec.rb b/spec/lib/rspec_flaky/config_spec.rb
index 4a71b1feebd..aa46ef3356d 100644
--- a/spec/lib/rspec_flaky/config_spec.rb
+++ b/spec/lib/rspec_flaky/config_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::Config, :aggregate_failures do
before do
# Stub these env variables otherwise specs don't behave the same on the CI
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', nil)
- stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', nil)
- stub_env('FLAKY_RSPEC_REPORT_PATH', nil)
- stub_env('NEW_FLAKY_RSPEC_REPORT_PATH', nil)
+ stub_env("FLAKY_RSPEC_GENERATE_REPORT", nil)
+ stub_env("SUITE_FLAKY_RSPEC_REPORT_PATH", nil)
+ stub_env("FLAKY_RSPEC_REPORT_PATH", nil)
+ stub_env("NEW_FLAKY_RSPEC_REPORT_PATH", nil)
end
- describe '.generate_report?' do
+ describe ".generate_report?" do
context "when ENV['FLAKY_RSPEC_GENERATE_REPORT'] is not set" do
- it 'returns false' do
+ it "returns false" do
expect(described_class).not_to be_generate_report
end
end
@@ -20,84 +20,84 @@ describe RspecFlaky::Config, :aggregate_failures do
using RSpec::Parameterized::TableSyntax
where(:env_value, :result) do
- '1' | true
- 'true' | true
- 'foo' | false
- '0' | false
- 'false' | false
+ "1" | true
+ "true" | true
+ "foo" | false
+ "0" | false
+ "false" | false
end
with_them do
before do
- stub_env('FLAKY_RSPEC_GENERATE_REPORT', env_value)
+ stub_env("FLAKY_RSPEC_GENERATE_REPORT", env_value)
end
- it 'returns false' do
+ it "returns false" do
expect(described_class.generate_report?).to be(result)
end
end
end
end
- describe '.suite_flaky_examples_report_path' do
+ describe ".suite_flaky_examples_report_path" do
context "when ENV['SUITE_FLAKY_RSPEC_REPORT_PATH'] is not set" do
- it 'returns the default path' do
- expect(Rails.root).to receive(:join).with('rspec_flaky/suite-report.json')
- .and_return('root/rspec_flaky/suite-report.json')
+ it "returns the default path" do
+ expect(Rails.root).to receive(:join).with("rspec_flaky/suite-report.json")
+ .and_return("root/rspec_flaky/suite-report.json")
- expect(described_class.suite_flaky_examples_report_path).to eq('root/rspec_flaky/suite-report.json')
+ expect(described_class.suite_flaky_examples_report_path).to eq("root/rspec_flaky/suite-report.json")
end
end
context "when ENV['SUITE_FLAKY_RSPEC_REPORT_PATH'] is set" do
before do
- stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', 'foo/suite-report.json')
+ stub_env("SUITE_FLAKY_RSPEC_REPORT_PATH", "foo/suite-report.json")
end
- it 'returns the value of the env variable' do
- expect(described_class.suite_flaky_examples_report_path).to eq('foo/suite-report.json')
+ it "returns the value of the env variable" do
+ expect(described_class.suite_flaky_examples_report_path).to eq("foo/suite-report.json")
end
end
end
- describe '.flaky_examples_report_path' do
+ describe ".flaky_examples_report_path" do
context "when ENV['FLAKY_RSPEC_REPORT_PATH'] is not set" do
- it 'returns the default path' do
- expect(Rails.root).to receive(:join).with('rspec_flaky/report.json')
- .and_return('root/rspec_flaky/report.json')
+ it "returns the default path" do
+ expect(Rails.root).to receive(:join).with("rspec_flaky/report.json")
+ .and_return("root/rspec_flaky/report.json")
- expect(described_class.flaky_examples_report_path).to eq('root/rspec_flaky/report.json')
+ expect(described_class.flaky_examples_report_path).to eq("root/rspec_flaky/report.json")
end
end
context "when ENV['FLAKY_RSPEC_REPORT_PATH'] is set" do
before do
- stub_env('FLAKY_RSPEC_REPORT_PATH', 'foo/report.json')
+ stub_env("FLAKY_RSPEC_REPORT_PATH", "foo/report.json")
end
- it 'returns the value of the env variable' do
- expect(described_class.flaky_examples_report_path).to eq('foo/report.json')
+ it "returns the value of the env variable" do
+ expect(described_class.flaky_examples_report_path).to eq("foo/report.json")
end
end
end
- describe '.new_flaky_examples_report_path' do
+ describe ".new_flaky_examples_report_path" do
context "when ENV['NEW_FLAKY_RSPEC_REPORT_PATH'] is not set" do
- it 'returns the default path' do
- expect(Rails.root).to receive(:join).with('rspec_flaky/new-report.json')
- .and_return('root/rspec_flaky/new-report.json')
+ it "returns the default path" do
+ expect(Rails.root).to receive(:join).with("rspec_flaky/new-report.json")
+ .and_return("root/rspec_flaky/new-report.json")
- expect(described_class.new_flaky_examples_report_path).to eq('root/rspec_flaky/new-report.json')
+ expect(described_class.new_flaky_examples_report_path).to eq("root/rspec_flaky/new-report.json")
end
end
context "when ENV['NEW_FLAKY_RSPEC_REPORT_PATH'] is set" do
before do
- stub_env('NEW_FLAKY_RSPEC_REPORT_PATH', 'foo/new-report.json')
+ stub_env("NEW_FLAKY_RSPEC_REPORT_PATH", "foo/new-report.json")
end
- it 'returns the value of the env variable' do
- expect(described_class.new_flaky_examples_report_path).to eq('foo/new-report.json')
+ it "returns the value of the env variable" do
+ expect(described_class.new_flaky_examples_report_path).to eq("foo/new-report.json")
end
end
end
diff --git a/spec/lib/rspec_flaky/example_spec.rb b/spec/lib/rspec_flaky/example_spec.rb
index 5b4fd5ddf3e..234039bedd7 100644
--- a/spec/lib/rspec_flaky/example_spec.rb
+++ b/spec/lib/rspec_flaky/example_spec.rb
@@ -1,88 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::Example do
let(:example_attrs) do
{
- id: 'spec/foo/bar_spec.rb:2',
+ id: "spec/foo/bar_spec.rb:2",
metadata: {
- file_path: 'spec/foo/bar_spec.rb',
+ file_path: "spec/foo/bar_spec.rb",
line_number: 2,
- full_description: 'hello world'
+ full_description: "hello world",
},
- execution_result: double(status: 'passed', exception: 'BOOM!'),
- attempts: 1
+ execution_result: double(status: "passed", exception: "BOOM!"),
+ attempts: 1,
}
end
let(:rspec_example) { double(example_attrs) }
- describe '#initialize' do
- shared_examples 'a valid Example instance' do
- it 'returns valid attributes' do
+ describe "#initialize" do
+ shared_examples "a valid Example instance" do
+ it "returns valid attributes" do
example = described_class.new(args)
expect(example.example_id).to eq(example_attrs[:id])
end
end
- context 'when given an Rspec::Core::Example that responds to #example' do
+ context "when given an Rspec::Core::Example that responds to #example" do
let(:args) { double(example: rspec_example) }
- it_behaves_like 'a valid Example instance'
+ it_behaves_like "a valid Example instance"
end
- context 'when given an Rspec::Core::Example that does not respond to #example' do
+ context "when given an Rspec::Core::Example that does not respond to #example" do
let(:args) { rspec_example }
- it_behaves_like 'a valid Example instance'
+ it_behaves_like "a valid Example instance"
end
end
subject { described_class.new(rspec_example) }
- describe '#uid' do
- it 'returns a hash of the full description' do
+ describe "#uid" do
+ it "returns a hash of the full description" do
expect(subject.uid).to eq(Digest::MD5.hexdigest("#{subject.description}-#{subject.file}"))
end
end
- describe '#example_id' do
- it 'returns the ID of the RSpec::Core::Example' do
+ describe "#example_id" do
+ it "returns the ID of the RSpec::Core::Example" do
expect(subject.example_id).to eq(rspec_example.id)
end
end
- describe '#attempts' do
- it 'returns the attempts of the RSpec::Core::Example' do
+ describe "#attempts" do
+ it "returns the attempts of the RSpec::Core::Example" do
expect(subject.attempts).to eq(rspec_example.attempts)
end
end
- describe '#file' do
- it 'returns the metadata[:file_path] of the RSpec::Core::Example' do
+ describe "#file" do
+ it "returns the metadata[:file_path] of the RSpec::Core::Example" do
expect(subject.file).to eq(rspec_example.metadata[:file_path])
end
end
- describe '#line' do
- it 'returns the metadata[:line_number] of the RSpec::Core::Example' do
+ describe "#line" do
+ it "returns the metadata[:line_number] of the RSpec::Core::Example" do
expect(subject.line).to eq(rspec_example.metadata[:line_number])
end
end
- describe '#description' do
- it 'returns the metadata[:full_description] of the RSpec::Core::Example' do
+ describe "#description" do
+ it "returns the metadata[:full_description] of the RSpec::Core::Example" do
expect(subject.description).to eq(rspec_example.metadata[:full_description])
end
end
- describe '#status' do
- it 'returns the execution_result.status of the RSpec::Core::Example' do
+ describe "#status" do
+ it "returns the execution_result.status of the RSpec::Core::Example" do
expect(subject.status).to eq(rspec_example.execution_result.status)
end
end
- describe '#exception' do
- it 'returns the execution_result.exception of the RSpec::Core::Example' do
+ describe "#exception" do
+ it "returns the execution_result.exception of the RSpec::Core::Example" do
expect(subject.exception).to eq(rspec_example.execution_result.exception)
end
end
diff --git a/spec/lib/rspec_flaky/flaky_example_spec.rb b/spec/lib/rspec_flaky/flaky_example_spec.rb
index d19c34bebb3..537bb943c4b 100644
--- a/spec/lib/rspec_flaky/flaky_example_spec.rb
+++ b/spec/lib/rspec_flaky/flaky_example_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::FlakyExample, :aggregate_failures do
let(:flaky_example_attrs) do
{
- example_id: 'spec/foo/bar_spec.rb:2',
- file: 'spec/foo/bar_spec.rb',
+ example_id: "spec/foo/bar_spec.rb:2",
+ file: "spec/foo/bar_spec.rb",
line: 2,
- description: 'hello world',
+ description: "hello world",
first_flaky_at: 1234,
last_flaky_at: 2345,
- last_flaky_job: 'https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/12',
+ last_flaky_job: "https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/12",
last_attempts_count: 2,
- flaky_reports: 1
+ flaky_reports: 1,
}
end
let(:example_attrs) do
{
- uid: 'abc123',
+ uid: "abc123",
example_id: flaky_example_attrs[:example_id],
file: flaky_example_attrs[:file],
line: flaky_example_attrs[:line],
description: flaky_example_attrs[:description],
- status: 'passed',
- exception: 'BOOM!',
- attempts: flaky_example_attrs[:last_attempts_count]
+ status: "passed",
+ exception: "BOOM!",
+ attempts: flaky_example_attrs[:last_attempts_count],
}
end
let(:example) { double(example_attrs) }
before do
# Stub these env variables otherwise specs don't behave the same on the CI
- stub_env('CI_PROJECT_URL', nil)
- stub_env('CI_JOB_ID', nil)
+ stub_env("CI_PROJECT_URL", nil)
+ stub_env("CI_JOB_ID", nil)
end
- describe '#initialize' do
- shared_examples 'a valid FlakyExample instance' do
+ describe "#initialize" do
+ shared_examples "a valid FlakyExample instance" do
let(:flaky_example) { described_class.new(args) }
- it 'returns valid attributes' do
+ it "returns valid attributes" do
expect(flaky_example.uid).to eq(flaky_example_attrs[:uid])
expect(flaky_example.file).to eq(flaky_example_attrs[:file])
expect(flaky_example.line).to eq(flaky_example_attrs[:line])
@@ -50,8 +50,8 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do
end
end
- context 'when given an Rspec::Example' do
- it_behaves_like 'a valid FlakyExample instance' do
+ context "when given an Rspec::Example" do
+ it_behaves_like "a valid FlakyExample instance" do
let(:args) { example }
let(:expected_first_flaky_at) { nil }
let(:expected_last_flaky_at) { nil }
@@ -59,8 +59,8 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do
end
end
- context 'when given a hash' do
- it_behaves_like 'a valid FlakyExample instance' do
+ context "when given a hash" do
+ it_behaves_like "a valid FlakyExample instance" do
let(:args) { flaky_example_attrs }
let(:expected_flaky_reports) { flaky_example_attrs[:flaky_reports] }
let(:expected_first_flaky_at) { flaky_example_attrs[:first_flaky_at] }
@@ -69,72 +69,72 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do
end
end
- describe '#update_flakiness!' do
- shared_examples 'an up-to-date FlakyExample instance' do
+ describe "#update_flakiness!" do
+ shared_examples "an up-to-date FlakyExample instance" do
let(:flaky_example) { described_class.new(args) }
- it 'updates the first_flaky_at' do
+ it "updates the first_flaky_at" do
now = Time.now
- expected_first_flaky_at = flaky_example.first_flaky_at ? flaky_example.first_flaky_at : now
+ expected_first_flaky_at = flaky_example.first_flaky_at || now
Timecop.freeze(now) { flaky_example.update_flakiness! }
expect(flaky_example.first_flaky_at).to eq(expected_first_flaky_at)
end
- it 'updates the last_flaky_at' do
+ it "updates the last_flaky_at" do
now = Time.now
Timecop.freeze(now) { flaky_example.update_flakiness! }
expect(flaky_example.last_flaky_at).to eq(now)
end
- it 'updates the flaky_reports' do
+ it "updates the flaky_reports" do
expected_flaky_reports = flaky_example.first_flaky_at ? flaky_example.flaky_reports + 1 : 1
expect { flaky_example.update_flakiness! }.to change { flaky_example.flaky_reports }.by(1)
expect(flaky_example.flaky_reports).to eq(expected_flaky_reports)
end
- context 'when passed a :last_attempts_count' do
- it 'updates the last_attempts_count' do
+ context "when passed a :last_attempts_count" do
+ it "updates the last_attempts_count" do
flaky_example.update_flakiness!(last_attempts_count: 42)
expect(flaky_example.last_attempts_count).to eq(42)
end
end
- context 'when run on the CI' do
+ context "when run on the CI" do
before do
- stub_env('CI_PROJECT_URL', 'https://gitlab.com/gitlab-org/gitlab-ce')
- stub_env('CI_JOB_ID', 42)
+ stub_env("CI_PROJECT_URL", "https://gitlab.com/gitlab-org/gitlab-ce")
+ stub_env("CI_JOB_ID", 42)
end
- it 'updates the last_flaky_job' do
+ it "updates the last_flaky_job" do
flaky_example.update_flakiness!
- expect(flaky_example.last_flaky_job).to eq('https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/42')
+ expect(flaky_example.last_flaky_job).to eq("https://gitlab.com/gitlab-org/gitlab-ce/-/jobs/42")
end
end
end
- context 'when given an Rspec::Example' do
- it_behaves_like 'an up-to-date FlakyExample instance' do
+ context "when given an Rspec::Example" do
+ it_behaves_like "an up-to-date FlakyExample instance" do
let(:args) { example }
end
end
- context 'when given a hash' do
- it_behaves_like 'an up-to-date FlakyExample instance' do
+ context "when given a hash" do
+ it_behaves_like "an up-to-date FlakyExample instance" do
let(:args) { flaky_example_attrs }
end
end
end
- describe '#to_h' do
- shared_examples 'a valid FlakyExample hash' do
+ describe "#to_h" do
+ shared_examples "a valid FlakyExample hash" do
let(:additional_attrs) { {} }
- it 'returns a valid hash' do
+ it "returns a valid hash" do
flaky_example = described_class.new(args)
final_hash = flaky_example_attrs.merge(additional_attrs)
@@ -142,20 +142,20 @@ describe RspecFlaky::FlakyExample, :aggregate_failures do
end
end
- context 'when given an Rspec::Example' do
+ context "when given an Rspec::Example" do
let(:args) { example }
- it_behaves_like 'a valid FlakyExample hash' do
+ it_behaves_like "a valid FlakyExample hash" do
let(:additional_attrs) do
- { first_flaky_at: nil, last_flaky_at: nil, last_flaky_job: nil, flaky_reports: 0 }
+ {first_flaky_at: nil, last_flaky_at: nil, last_flaky_job: nil, flaky_reports: 0}
end
end
end
- context 'when given a hash' do
+ context "when given a hash" do
let(:args) { flaky_example_attrs }
- it_behaves_like 'a valid FlakyExample hash'
+ it_behaves_like "a valid FlakyExample hash"
end
end
end
diff --git a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
index 6731a27ed17..641102c7d4a 100644
--- a/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
+++ b/spec/lib/rspec_flaky/flaky_examples_collection_spec.rb
@@ -1,68 +1,70 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::FlakyExamplesCollection, :aggregate_failures do
let(:collection_hash) do
{
- a: { example_id: 'spec/foo/bar_spec.rb:2' },
- b: { example_id: 'spec/foo/baz_spec.rb:3' }
+ a: {example_id: "spec/foo/bar_spec.rb:2"},
+ b: {example_id: "spec/foo/baz_spec.rb:3"},
}
end
let(:collection_report) do
{
a: {
- example_id: 'spec/foo/bar_spec.rb:2',
+ example_id: "spec/foo/bar_spec.rb:2",
first_flaky_at: nil,
last_flaky_at: nil,
- last_flaky_job: nil
+ last_flaky_job: nil,
},
b: {
- example_id: 'spec/foo/baz_spec.rb:3',
+ example_id: "spec/foo/baz_spec.rb:3",
first_flaky_at: nil,
last_flaky_at: nil,
- last_flaky_job: nil
- }
+ last_flaky_job: nil,
+ },
}
end
- describe '#initialize' do
- it 'accepts no argument' do
+ describe "#initialize" do
+ it "accepts no argument" do
expect { described_class.new }.not_to raise_error
end
- it 'accepts a hash' do
+ it "accepts a hash" do
expect { described_class.new(collection_hash) }.not_to raise_error
end
- it 'does not accept anything else' do
+ it "does not accept anything else" do
expect { described_class.new([1, 2, 3]) }.to raise_error(ArgumentError, "`collection` must be a Hash, Array given!")
end
end
- describe '#to_h' do
- it 'calls #to_h on the values' do
+ describe "#to_h" do
+ it "calls #to_h on the values" do
collection = described_class.new(collection_hash)
expect(collection.to_h).to eq(collection_report)
end
end
- describe '#-' do
- it 'returns only examples that are not present in the given collection' do
+ describe "#-" do
+ it "returns only examples that are not present in the given collection" do
collection1 = described_class.new(collection_hash)
collection2 = described_class.new(
- a: { example_id: 'spec/foo/bar_spec.rb:2' },
- c: { example_id: 'spec/bar/baz_spec.rb:4' })
+ a: {example_id: "spec/foo/bar_spec.rb:2"},
+ c: {example_id: "spec/bar/baz_spec.rb:4"}
+ )
expect((collection2 - collection1).to_h).to eq(
c: {
- example_id: 'spec/bar/baz_spec.rb:4',
+ example_id: "spec/bar/baz_spec.rb:4",
first_flaky_at: nil,
last_flaky_at: nil,
- last_flaky_job: nil
- })
+ last_flaky_job: nil,
+ }
+ )
end
- it 'fails if the given collection does not respond to `#key?`' do
+ it "fails if the given collection does not respond to `#key?`" do
collection = described_class.new(collection_hash)
expect { collection - [1, 2, 3] }.to raise_error(ArgumentError, "`other` must respond to `#key?`, Array does not!")
diff --git a/spec/lib/rspec_flaky/listener_spec.rb b/spec/lib/rspec_flaky/listener_spec.rb
index ef085445081..5653ae3c592 100644
--- a/spec/lib/rspec_flaky/listener_spec.rb
+++ b/spec/lib/rspec_flaky/listener_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::Listener, :aggregate_failures do
- let(:already_flaky_example_uid) { '6e869794f4cfd2badd93eb68719371d1' }
+ let(:already_flaky_example_uid) { "6e869794f4cfd2badd93eb68719371d1" }
let(:suite_flaky_example_report) do
{
- "#{already_flaky_example_uid}": {
- example_id: 'spec/foo/bar_spec.rb:2',
- file: 'spec/foo/bar_spec.rb',
+ :"#{already_flaky_example_uid}" => {
+ example_id: "spec/foo/bar_spec.rb:2",
+ file: "spec/foo/bar_spec.rb",
line: 2,
- description: 'hello world',
+ description: "hello world",
first_flaky_at: 1234,
last_flaky_at: 4321,
last_attempts_count: 3,
flaky_reports: 1,
- last_flaky_job: nil
- }
+ last_flaky_job: nil,
+ },
}
end
let(:already_flaky_example_attrs) do
{
- id: 'spec/foo/bar_spec.rb:2',
+ id: "spec/foo/bar_spec.rb:2",
metadata: {
- file_path: 'spec/foo/bar_spec.rb',
+ file_path: "spec/foo/bar_spec.rb",
line_number: 2,
- full_description: 'hello world'
+ full_description: "hello world",
},
- execution_result: double(status: 'passed', exception: nil)
+ execution_result: double(status: "passed", exception: nil),
}
end
let(:already_flaky_example) { RspecFlaky::FlakyExample.new(suite_flaky_example_report[already_flaky_example_uid]) }
let(:new_example_attrs) do
{
- id: 'spec/foo/baz_spec.rb:3',
+ id: "spec/foo/baz_spec.rb:3",
metadata: {
- file_path: 'spec/foo/baz_spec.rb',
+ file_path: "spec/foo/baz_spec.rb",
line_number: 3,
- full_description: 'hello GitLab'
+ full_description: "hello GitLab",
},
- execution_result: double(status: 'passed', exception: nil)
+ execution_result: double(status: "passed", exception: nil),
}
end
before do
# Stub these env variables otherwise specs don't behave the same on the CI
- stub_env('CI_PROJECT_URL', nil)
- stub_env('CI_JOB_ID', nil)
- stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', nil)
+ stub_env("CI_PROJECT_URL", nil)
+ stub_env("CI_JOB_ID", nil)
+ stub_env("SUITE_FLAKY_RSPEC_REPORT_PATH", nil)
end
- describe '#initialize' do
- shared_examples 'a valid Listener instance' do
+ describe "#initialize" do
+ shared_examples "a valid Listener instance" do
let(:expected_suite_flaky_examples) { {} }
- it 'returns a valid Listener instance' do
+ it "returns a valid Listener instance" do
listener = described_class.new
expect(listener.suite_flaky_examples.to_h).to eq(expected_suite_flaky_examples)
@@ -60,23 +60,23 @@ describe RspecFlaky::Listener, :aggregate_failures do
end
end
- context 'when no report file exists' do
- it_behaves_like 'a valid Listener instance'
+ context "when no report file exists" do
+ it_behaves_like "a valid Listener instance"
end
- context 'when SUITE_FLAKY_RSPEC_REPORT_PATH is set' do
- let(:report_file_path) { 'foo/report.json' }
+ context "when SUITE_FLAKY_RSPEC_REPORT_PATH is set" do
+ let(:report_file_path) { "foo/report.json" }
before do
- stub_env('SUITE_FLAKY_RSPEC_REPORT_PATH', report_file_path)
+ stub_env("SUITE_FLAKY_RSPEC_REPORT_PATH", report_file_path)
end
- context 'and report file exists' do
+ context "and report file exists" do
before do
expect(File).to receive(:exist?).with(report_file_path).and_return(true)
end
- it 'delegates the load to RspecFlaky::Report' do
+ it "delegates the load to RspecFlaky::Report" do
report = RspecFlaky::Report.new(RspecFlaky::FlakyExamplesCollection.new(suite_flaky_example_report))
expect(RspecFlaky::Report).to receive(:load).with(report_file_path).and_return(report)
@@ -84,12 +84,12 @@ describe RspecFlaky::Listener, :aggregate_failures do
end
end
- context 'and report file does not exist' do
+ context "and report file does not exist" do
before do
expect(File).to receive(:exist?).with(report_file_path).and_return(false)
end
- it 'return an empty hash' do
+ it "return an empty hash" do
expect(RspecFlaky::Report).not_to receive(:load)
expect(described_class.new.suite_flaky_examples.to_h).to eq({})
end
@@ -97,33 +97,33 @@ describe RspecFlaky::Listener, :aggregate_failures do
end
end
- describe '#example_passed' do
+ describe "#example_passed" do
let(:rspec_example) { double(new_example_attrs) }
let(:notification) { double(example: rspec_example) }
let(:listener) { described_class.new(suite_flaky_example_report.to_json) }
- shared_examples 'a non-flaky example' do
- it 'does not change the flaky examples hash' do
+ shared_examples "a non-flaky example" do
+ it "does not change the flaky examples hash" do
expect { listener.example_passed(notification) }
.not_to change { listener.flaky_examples }
end
end
- shared_examples 'an existing flaky example' do
+ shared_examples "an existing flaky example" do
let(:expected_flaky_example) do
{
- example_id: 'spec/foo/bar_spec.rb:2',
- file: 'spec/foo/bar_spec.rb',
+ example_id: "spec/foo/bar_spec.rb:2",
+ file: "spec/foo/bar_spec.rb",
line: 2,
- description: 'hello world',
+ description: "hello world",
first_flaky_at: 1234,
last_attempts_count: 2,
flaky_reports: 2,
- last_flaky_job: nil
+ last_flaky_job: nil,
}
end
- it 'changes the flaky examples hash' do
+ it "changes the flaky examples hash" do
new_example = RspecFlaky::Example.new(rspec_example)
now = Time.now
@@ -137,20 +137,20 @@ describe RspecFlaky::Listener, :aggregate_failures do
end
end
- shared_examples 'a new flaky example' do
+ shared_examples "a new flaky example" do
let(:expected_flaky_example) do
{
- example_id: 'spec/foo/baz_spec.rb:3',
- file: 'spec/foo/baz_spec.rb',
+ example_id: "spec/foo/baz_spec.rb:3",
+ file: "spec/foo/baz_spec.rb",
line: 3,
- description: 'hello GitLab',
+ description: "hello GitLab",
last_attempts_count: 2,
flaky_reports: 1,
- last_flaky_job: nil
+ last_flaky_job: nil,
}
end
- it 'changes the all flaky examples hash' do
+ it "changes the all flaky examples hash" do
new_example = RspecFlaky::Example.new(rspec_example)
now = Time.now
@@ -164,38 +164,38 @@ describe RspecFlaky::Listener, :aggregate_failures do
end
end
- describe 'when the RSpec example does not respond to attempts' do
- it_behaves_like 'a non-flaky example'
+ describe "when the RSpec example does not respond to attempts" do
+ it_behaves_like "a non-flaky example"
end
- describe 'when the RSpec example has 1 attempt' do
+ describe "when the RSpec example has 1 attempt" do
let(:rspec_example) { double(new_example_attrs.merge(attempts: 1)) }
- it_behaves_like 'a non-flaky example'
+ it_behaves_like "a non-flaky example"
end
- describe 'when the RSpec example has 2 attempts' do
+ describe "when the RSpec example has 2 attempts" do
let(:rspec_example) { double(new_example_attrs.merge(attempts: 2)) }
- it_behaves_like 'a new flaky example'
+ it_behaves_like "a new flaky example"
- context 'with an existing flaky example' do
+ context "with an existing flaky example" do
let(:rspec_example) { double(already_flaky_example_attrs.merge(attempts: 2)) }
- it_behaves_like 'an existing flaky example'
+ it_behaves_like "an existing flaky example"
end
end
end
- describe '#dump_summary' do
+ describe "#dump_summary" do
let(:listener) { described_class.new(suite_flaky_example_report.to_json) }
let(:new_flaky_rspec_example) { double(new_example_attrs.merge(attempts: 2)) }
let(:already_flaky_rspec_example) { double(already_flaky_example_attrs.merge(attempts: 2)) }
let(:notification_new_flaky_rspec_example) { double(example: new_flaky_rspec_example) }
let(:notification_already_flaky_rspec_example) { double(example: already_flaky_rspec_example) }
- context 'when a report file path is set by FLAKY_RSPEC_REPORT_PATH' do
- it 'delegates the writes to RspecFlaky::Report' do
+ context "when a report file path is set by FLAKY_RSPEC_REPORT_PATH" do
+ it "delegates the writes to RspecFlaky::Report" do
listener.example_passed(notification_new_flaky_rspec_example)
listener.example_passed(notification_already_flaky_rspec_example)
diff --git a/spec/lib/rspec_flaky/report_spec.rb b/spec/lib/rspec_flaky/report_spec.rb
index 7d57d99f7e5..120f635dea3 100644
--- a/spec/lib/rspec_flaky/report_spec.rb
+++ b/spec/lib/rspec_flaky/report_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe RspecFlaky::Report, :aggregate_failures do
let(:a_hundred_days) { 3600 * 24 * 100 }
let(:collection_hash) do
{
- a: { example_id: 'spec/foo/bar_spec.rb:2' },
- b: { example_id: 'spec/foo/baz_spec.rb:3', first_flaky_at: (Time.now - a_hundred_days).to_s, last_flaky_at: (Time.now - a_hundred_days).to_s }
+ a: {example_id: "spec/foo/bar_spec.rb:2"},
+ b: {example_id: "spec/foo/baz_spec.rb:3", first_flaky_at: (Time.now - a_hundred_days).to_s, last_flaky_at: (Time.now - a_hundred_days).to_s},
}
end
let(:suite_flaky_example_report) do
{
'6e869794f4cfd2badd93eb68719371d1': {
- example_id: 'spec/foo/bar_spec.rb:2',
- file: 'spec/foo/bar_spec.rb',
+ example_id: "spec/foo/bar_spec.rb:2",
+ file: "spec/foo/bar_spec.rb",
line: 2,
- description: 'hello world',
+ description: "hello world",
first_flaky_at: 1234,
last_flaky_at: 4321,
last_attempts_count: 3,
flaky_reports: 1,
- last_flaky_job: nil
- }
+ last_flaky_job: nil,
+ },
}
end
let(:flaky_examples) { RspecFlaky::FlakyExamplesCollection.new(collection_hash) }
let(:report) { described_class.new(flaky_examples) }
- describe '.load' do
+ describe ".load" do
let!(:report_file) do
Tempfile.new(%w[rspec_flaky_report .json]).tap do |f|
f.write(JSON.pretty_generate(suite_flaky_example_report))
@@ -39,37 +39,37 @@ describe RspecFlaky::Report, :aggregate_failures do
report_file.unlink
end
- it 'loads the report file' do
+ it "loads the report file" do
expect(described_class.load(report_file.path).flaky_examples.to_h).to eq(suite_flaky_example_report)
end
end
- describe '.load_json' do
+ describe ".load_json" do
let(:report_json) do
JSON.pretty_generate(suite_flaky_example_report)
end
- it 'loads the report file' do
+ it "loads the report file" do
expect(described_class.load_json(report_json).flaky_examples.to_h).to eq(suite_flaky_example_report)
end
end
- describe '#initialize' do
- it 'accepts a RspecFlaky::FlakyExamplesCollection' do
+ describe "#initialize" do
+ it "accepts a RspecFlaky::FlakyExamplesCollection" do
expect { report }.not_to raise_error
end
- it 'does not accept anything else' do
+ it "does not accept anything else" do
expect { described_class.new([1, 2, 3]) }.to raise_error(ArgumentError, "`flaky_examples` must be a RspecFlaky::FlakyExamplesCollection, Array given!")
end
end
- it 'delegates to #flaky_examples using SimpleDelegator' do
+ it "delegates to #flaky_examples using SimpleDelegator" do
expect(report.__getobj__).to eq(flaky_examples)
end
- describe '#write' do
- let(:report_file_path) { Rails.root.join('tmp', 'rspec_flaky_report.json') }
+ describe "#write" do
+ let(:report_file_path) { Rails.root.join("tmp", "rspec_flaky_report.json") }
before do
FileUtils.rm(report_file_path) if File.exist?(report_file_path)
@@ -79,24 +79,24 @@ describe RspecFlaky::Report, :aggregate_failures do
FileUtils.rm(report_file_path) if File.exist?(report_file_path)
end
- context 'when RspecFlaky::Config.generate_report? is false' do
+ context "when RspecFlaky::Config.generate_report? is false" do
before do
allow(RspecFlaky::Config).to receive(:generate_report?).and_return(false)
end
- it 'does not write any report file' do
+ it "does not write any report file" do
report.write(report_file_path)
expect(File.exist?(report_file_path)).to be(false)
end
end
- context 'when RspecFlaky::Config.generate_report? is true' do
+ context "when RspecFlaky::Config.generate_report? is true" do
before do
allow(RspecFlaky::Config).to receive(:generate_report?).and_return(true)
end
- it 'delegates the writes to RspecFlaky::Report' do
+ it "delegates the writes to RspecFlaky::Report" do
report.write(report_file_path)
expect(File.exist?(report_file_path)).to be(true)
@@ -106,8 +106,8 @@ describe RspecFlaky::Report, :aggregate_failures do
end
end
- describe '#prune_outdated' do
- it 'returns a new collection without the examples older than 90 days by default' do
+ describe "#prune_outdated" do
+ it "returns a new collection without the examples older than 90 days by default" do
new_report = flaky_examples.to_h.dup.tap { |r| r.delete(:b) }
new_flaky_examples = report.prune_outdated
@@ -116,7 +116,7 @@ describe RspecFlaky::Report, :aggregate_failures do
expect(flaky_examples).to have_key(:b)
end
- it 'accepts a given number of days' do
+ it "accepts a given number of days" do
new_flaky_examples = report.prune_outdated(days: 200)
expect(new_flaky_examples.to_h).to eq(report.to_h)
diff --git a/spec/lib/safe_zip/entry_spec.rb b/spec/lib/safe_zip/entry_spec.rb
index 115e28c5994..ae8ac7bf03c 100644
--- a/spec/lib/safe_zip/entry_spec.rb
+++ b/spec/lib/safe_zip/entry_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe SafeZip::Entry do
- let(:target_path) { Dir.mktmpdir('safe-zip') }
- let(:directories) { %w(public folder/with/subfolder) }
+ let(:target_path) { Dir.mktmpdir("safe-zip") }
+ let(:directories) { %w[public folder/with/subfolder] }
let(:params) { SafeZip::ExtractParams.new(directories: directories, to: target_path) }
let(:entry) { described_class.new(zip_archive, zip_entry, params) }
- let(:entry_name) { 'public/folder/index.html' }
+ let(:entry_name) { "public/folder/index.html" }
let(:entry_path_dir) { File.join(target_path, File.dirname(entry_name)) }
let(:entry_path) { File.join(target_path, entry_name) }
let(:zip_archive) { double }
@@ -16,27 +16,28 @@ describe SafeZip::Entry do
name: entry_name,
file?: false,
directory?: false,
- symlink?: false)
+ symlink?: false
+ )
end
after do
FileUtils.remove_entry_secure(target_path)
end
- context '#path_dir' do
+ context "#path_dir" do
subject { entry.path_dir }
- it { is_expected.to eq(target_path + '/public/folder') }
+ it { is_expected.to eq(target_path + "/public/folder") }
end
- context '#exist?' do
+ context "#exist?" do
subject { entry.exist? }
- context 'when entry does not exist' do
+ context "when entry does not exist" do
it { is_expected.not_to be_truthy }
end
- context 'when entry does exist' do
+ context "when entry does exist" do
before do
create_entry
end
@@ -45,65 +46,65 @@ describe SafeZip::Entry do
end
end
- describe '#extract' do
+ describe "#extract" do
subject { entry.extract }
- context 'when entry does not match the filtered directories' do
+ context "when entry does not match the filtered directories" do
using RSpec::Parameterized::TableSyntax
where(:entry_name) do
[
- 'assets/folder/index.html',
- 'public/../folder/index.html',
- 'public/../../../../../index.html',
- '../../../../../public/index.html',
- '/etc/passwd'
+ "assets/folder/index.html",
+ "public/../folder/index.html",
+ "public/../../../../../index.html",
+ "../../../../../public/index.html",
+ "/etc/passwd",
]
end
with_them do
- it 'does not extract file' do
+ it "does not extract file" do
is_expected.to be_falsey
end
end
end
- context 'when entry does exist' do
+ context "when entry does exist" do
before do
create_entry
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::AlreadyExistsError)
end
end
- context 'when entry type is unknown' do
- it 'raises an exception' do
+ context "when entry type is unknown" do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::UnsupportedEntryError)
end
end
- context 'when entry is valid' do
- shared_examples 'secured symlinks' do
- context 'when we try to extract entry into symlinked folder' do
+ context "when entry is valid" do
+ shared_examples "secured symlinks" do
+ context "when we try to extract entry into symlinked folder" do
before do
FileUtils.mkdir_p(File.join(target_path, "source"))
File.symlink("source", File.join(target_path, "public"))
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::PermissionDeniedError)
end
end
end
- context 'and is file' do
+ context "and is file" do
before do
allow(zip_entry).to receive(:file?) { true }
end
- it 'does extract file' do
+ it "does extract file" do
expect(zip_archive).to receive(:extract)
.with(zip_entry, entry_path)
.and_return(true)
@@ -111,75 +112,75 @@ describe SafeZip::Entry do
is_expected.to be_truthy
end
- it_behaves_like 'secured symlinks'
+ it_behaves_like "secured symlinks"
end
- context 'and is directory' do
- let(:entry_name) { 'public/folder/assets' }
+ context "and is directory" do
+ let(:entry_name) { "public/folder/assets" }
before do
allow(zip_entry).to receive(:directory?) { true }
end
- it 'does create directory' do
+ it "does create directory" do
is_expected.to be_truthy
expect(File.exist?(entry_path)).to eq(true)
end
- it_behaves_like 'secured symlinks'
+ it_behaves_like "secured symlinks"
end
- context 'and is symlink' do
- let(:entry_name) { 'public/folder/assets' }
+ context "and is symlink" do
+ let(:entry_name) { "public/folder/assets" }
before do
allow(zip_entry).to receive(:symlink?) { true }
allow(zip_archive).to receive(:read).with(zip_entry) { entry_symlink }
end
- shared_examples 'a valid symlink' do
- it 'does create symlink' do
+ shared_examples "a valid symlink" do
+ it "does create symlink" do
is_expected.to be_truthy
expect(File.exist?(entry_path)).to eq(true)
end
end
- context 'when source is within target' do
- let(:entry_symlink) { '../images' }
+ context "when source is within target" do
+ let(:entry_symlink) { "../images" }
- context 'but does not exist' do
- it 'raises an exception' do
+ context "but does not exist" do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::SymlinkSourceDoesNotExistError)
end
end
- context 'and does exist' do
+ context "and does exist" do
before do
- FileUtils.mkdir_p(File.join(target_path, 'public', 'images'))
+ FileUtils.mkdir_p(File.join(target_path, "public", "images"))
end
- it_behaves_like 'a valid symlink'
+ it_behaves_like "a valid symlink"
end
end
- context 'when source points outside of target' do
- let(:entry_symlink) { '../../images' }
+ context "when source points outside of target" do
+ let(:entry_symlink) { "../../images" }
before do
- FileUtils.mkdir(File.join(target_path, 'images'))
+ FileUtils.mkdir(File.join(target_path, "images"))
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::PermissionDeniedError)
end
end
- context 'when source points to /etc/passwd' do
- let(:entry_symlink) { '/etc/passwd' }
+ context "when source points to /etc/passwd" do
+ let(:entry_symlink) { "/etc/passwd" }
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(SafeZip::Extract::PermissionDeniedError)
end
end
diff --git a/spec/lib/safe_zip/extract_params_spec.rb b/spec/lib/safe_zip/extract_params_spec.rb
index 85e22cfa495..8e4e757f530 100644
--- a/spec/lib/safe_zip/extract_params_spec.rb
+++ b/spec/lib/safe_zip/extract_params_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe SafeZip::ExtractParams do
let(:target_path) { Dir.mktmpdir("safe-zip") }
let(:params) { described_class.new(directories: directories, to: target_path) }
- let(:directories) { %w(public folder/with/subfolder) }
+ let(:directories) { %w[public folder/with/subfolder] }
after do
FileUtils.remove_entry_secure(target_path)
end
- describe '#extract_path' do
+ describe "#extract_path" do
subject { params.extract_path }
it { is_expected.to eq(target_path) }
end
- describe '#matching_target_directory' do
+ describe "#matching_target_directory" do
using RSpec::Parameterized::TableSyntax
subject { params.matching_target_directory(target_path + path) }
where(:path, :result) do
- '/public/index.html' | '/public/'
- '/non/existing/path' | nil
- '/public' | nil
- '/folder/with/index.html' | nil
+ "/public/index.html" | "/public/"
+ "/non/existing/path" | nil
+ "/public" | nil
+ "/folder/with/index.html" | nil
end
with_them do
@@ -32,23 +32,23 @@ describe SafeZip::ExtractParams do
end
end
- describe '#target_directories' do
+ describe "#target_directories" do
subject { params.target_directories }
- it 'starts with target_path' do
- is_expected.to all(start_with(target_path + '/'))
+ it "starts with target_path" do
+ is_expected.to all(start_with(target_path + "/"))
end
- it 'ends with / for all paths' do
- is_expected.to all(end_with('/'))
+ it "ends with / for all paths" do
+ is_expected.to all(end_with("/"))
end
end
- describe '#directories_wildcard' do
+ describe "#directories_wildcard" do
subject { params.directories_wildcard }
- it 'adds * for all paths' do
- is_expected.to all(end_with('/*'))
+ it "adds * for all paths" do
+ is_expected.to all(end_with("/*"))
end
end
end
diff --git a/spec/lib/safe_zip/extract_spec.rb b/spec/lib/safe_zip/extract_spec.rb
index b75a8fede00..dc40f015f59 100644
--- a/spec/lib/safe_zip/extract_spec.rb
+++ b/spec/lib/safe_zip/extract_spec.rb
@@ -1,79 +1,79 @@
-require 'spec_helper'
+require "spec_helper"
describe SafeZip::Extract do
- let(:target_path) { Dir.mktmpdir('safe-zip') }
- let(:directories) { %w(public) }
+ let(:target_path) { Dir.mktmpdir("safe-zip") }
+ let(:directories) { %w[public] }
let(:object) { described_class.new(archive) }
- let(:archive) { Rails.root.join('spec', 'fixtures', 'safe_zip', archive_name) }
+ let(:archive) { Rails.root.join("spec", "fixtures", "safe_zip", archive_name) }
after do
FileUtils.remove_entry_secure(target_path)
end
- context '#extract' do
+ context "#extract" do
subject { object.extract(directories: directories, to: target_path) }
- shared_examples 'extracts archive' do |param|
+ shared_examples "extracts archive" do |param|
before do
stub_feature_flags(safezip_use_rubyzip: param)
end
- it 'does extract archive' do
+ it "does extract archive" do
subject
- expect(File.exist?(File.join(target_path, 'public', 'index.html'))).to eq(true)
- expect(File.exist?(File.join(target_path, 'source'))).to eq(false)
+ expect(File.exist?(File.join(target_path, "public", "index.html"))).to eq(true)
+ expect(File.exist?(File.join(target_path, "source"))).to eq(false)
end
end
- shared_examples 'fails to extract archive' do |param|
+ shared_examples "fails to extract archive" do |param|
before do
stub_feature_flags(safezip_use_rubyzip: param)
end
- it 'does not extract archive' do
+ it "does not extract archive" do
expect { subject }.to raise_error(SafeZip::Extract::Error)
end
end
- %w(valid-simple.zip valid-symlinks-first.zip valid-non-writeable.zip).each do |name|
+ %w[valid-simple.zip valid-symlinks-first.zip valid-non-writeable.zip].each do |name|
context "when using #{name} archive" do
let(:archive_name) { name }
- context 'for RubyZip' do
- it_behaves_like 'extracts archive', true
+ context "for RubyZip" do
+ it_behaves_like "extracts archive", true
end
- context 'for UnZip' do
- it_behaves_like 'extracts archive', false
+ context "for UnZip" do
+ it_behaves_like "extracts archive", false
end
end
end
- %w(invalid-symlink-does-not-exist.zip invalid-symlinks-outside.zip).each do |name|
+ %w[invalid-symlink-does-not-exist.zip invalid-symlinks-outside.zip].each do |name|
context "when using #{name} archive" do
let(:archive_name) { name }
- context 'for RubyZip' do
- it_behaves_like 'fails to extract archive', true
+ context "for RubyZip" do
+ it_behaves_like "fails to extract archive", true
end
- context 'for UnZip (UNSAFE)' do
- it_behaves_like 'extracts archive', false
+ context "for UnZip (UNSAFE)" do
+ it_behaves_like "extracts archive", false
end
end
end
- context 'when no matching directories are found' do
- let(:archive_name) { 'valid-simple.zip' }
- let(:directories) { %w(non/existing) }
+ context "when no matching directories are found" do
+ let(:archive_name) { "valid-simple.zip" }
+ let(:directories) { %w[non/existing] }
- context 'for RubyZip' do
- it_behaves_like 'fails to extract archive', true
+ context "for RubyZip" do
+ it_behaves_like "fails to extract archive", true
end
- context 'for UnZip' do
- it_behaves_like 'fails to extract archive', false
+ context "for UnZip" do
+ it_behaves_like "fails to extract archive", false
end
end
end
diff --git a/spec/lib/sentry/client_spec.rb b/spec/lib/sentry/client_spec.rb
index 88e7e2e5ebb..e1320aeecc0 100644
--- a/spec/lib/sentry/client_spec.rb
+++ b/spec/lib/sentry/client_spec.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Sentry::Client do
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
- let(:token) { 'test-token' }
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project" }
+ let(:token) { "test-token" }
let(:issues_sample_response) do
Gitlab::Utils.deep_indifferent_access(
- JSON.parse(fixture_file('sentry/issues_sample_response.json'))
+ JSON.parse(fixture_file("sentry/issues_sample_response.json"))
)
end
let(:projects_sample_response) do
Gitlab::Utils.deep_indifferent_access(
- JSON.parse(fixture_file('sentry/list_projects_sample_response.json'))
+ JSON.parse(fixture_file("sentry/list_projects_sample_response.json"))
)
end
subject(:client) { described_class.new(sentry_url, token) }
# Requires sentry_api_url and subject to be defined
- shared_examples 'no redirects' do
- let(:redirect_to) { 'https://redirected.example.com' }
- let(:other_url) { 'https://other.example.org' }
+ shared_examples "no redirects" do
+ let(:redirect_to) { "https://redirected.example.com" }
+ let(:other_url) { "https://other.example.org" }
let!(:redirected_req_stub) { stub_sentry_request(other_url) }
@@ -31,50 +31,50 @@ describe Sentry::Client do
stub_sentry_request(
sentry_api_url,
status: 302,
- headers: { location: redirect_to }
+ headers: {location: redirect_to}
)
end
- it 'does not follow redirects' do
- expect { subject }.to raise_exception(Sentry::Client::Error, 'Sentry response status code: 302')
+ it "does not follow redirects" do
+ expect { subject }.to raise_exception(Sentry::Client::Error, "Sentry response status code: 302")
expect(redirect_req_stub).to have_been_requested
expect(redirected_req_stub).not_to have_been_requested
end
end
- shared_examples 'has correct return type' do |klass|
+ shared_examples "has correct return type" do |klass|
it "returns objects of type #{klass}" do
- expect(subject).to all( be_a(klass) )
+ expect(subject).to all(be_a(klass))
end
end
- shared_examples 'has correct length' do |length|
+ shared_examples "has correct length" do |length|
it { expect(subject.length).to eq(length) }
end
# Requires sentry_api_request and subject to be defined
- shared_examples 'calls sentry api' do
- it 'calls sentry api' do
+ shared_examples "calls sentry api" do
+ it "calls sentry api" do
subject
expect(sentry_api_request).to have_been_requested
end
end
- describe '#list_issues' do
- let(:issue_status) { 'unresolved' }
+ describe "#list_issues" do
+ let(:issue_status) { "unresolved" }
let(:limit) { 20 }
- let!(:sentry_api_request) { stub_sentry_request(sentry_url + '/issues/?limit=20&query=is:unresolved', body: issues_sample_response) }
+ let!(:sentry_api_request) { stub_sentry_request(sentry_url + "/issues/?limit=20&query=is:unresolved", body: issues_sample_response) }
subject { client.list_issues(issue_status: issue_status, limit: limit) }
- it_behaves_like 'calls sentry api'
+ it_behaves_like "calls sentry api"
- it_behaves_like 'has correct return type', Gitlab::ErrorTracking::Error
- it_behaves_like 'has correct length', 1
+ it_behaves_like "has correct return type", Gitlab::ErrorTracking::Error
+ it_behaves_like "has correct length", 1
- context 'error object created from sentry response' do
+ context "error object created from sentry response" do
using RSpec::Parameterized::TableSyntax
where(:error_object, :sentry_response) do
@@ -89,7 +89,7 @@ describe Sentry::Client do
:culprit | :culprit
:short_id | :shortId
:status | :status
- :frequency | [:stats, '24h']
+ :frequency | [:stats, "24h"]
:project_id | [:project, :id]
:project_name | [:project, :name]
:project_slug | [:project, :slug]
@@ -99,34 +99,34 @@ describe Sentry::Client do
it { expect(subject[0].public_send(error_object)).to eq(issues_sample_response[0].dig(*sentry_response)) }
end
- context 'external_url' do
- it 'is constructed correctly' do
- expect(subject[0].external_url).to eq('https://sentrytest.gitlab.com/sentry-org/sentry-project/issues/11')
+ context "external_url" do
+ it "is constructed correctly" do
+ expect(subject[0].external_url).to eq("https://sentrytest.gitlab.com/sentry-org/sentry-project/issues/11")
end
end
end
- context 'redirects' do
- let(:sentry_api_url) { sentry_url + '/issues/?limit=20&query=is:unresolved' }
+ context "redirects" do
+ let(:sentry_api_url) { sentry_url + "/issues/?limit=20&query=is:unresolved" }
- it_behaves_like 'no redirects'
+ it_behaves_like "no redirects"
end
# Sentry API returns 404 if there are extra slashes in the URL!
- context 'extra slashes in URL' do
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects//sentry-org/sentry-project/' }
+ context "extra slashes in URL" do
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api/0/projects//sentry-org/sentry-project/" }
let(:client) { described_class.new(sentry_url, token) }
let!(:valid_req_stub) do
stub_sentry_request(
- 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/' \
- 'issues/?limit=20&query=is:unresolved'
+ "https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/" \
+ "issues/?limit=20&query=is:unresolved"
)
end
- it 'removes extra slashes in api url' do
+ it "removes extra slashes in api url" do
expect(Gitlab::HTTP).to receive(:get).with(
- URI('https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/issues/'),
+ URI("https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project/issues/"),
anything
).and_call_original
@@ -137,20 +137,20 @@ describe Sentry::Client do
end
end
- describe '#list_projects' do
- let(:sentry_list_projects_url) { 'https://sentrytest.gitlab.com/api/0/projects/' }
+ describe "#list_projects" do
+ let(:sentry_list_projects_url) { "https://sentrytest.gitlab.com/api/0/projects/" }
let!(:sentry_api_request) { stub_sentry_request(sentry_list_projects_url, body: projects_sample_response) }
subject { client.list_projects }
- it_behaves_like 'calls sentry api'
+ it_behaves_like "calls sentry api"
- it_behaves_like 'has correct return type', Gitlab::ErrorTracking::Project
- it_behaves_like 'has correct length', 2
+ it_behaves_like "has correct return type", Gitlab::ErrorTracking::Project
+ it_behaves_like "has correct length", 2
- context 'keys missing in API response' do
- it 'raises exception' do
+ context "keys missing in API response" do
+ it "raises exception" do
projects_sample_response[0].delete(:slug)
stub_sentry_request(sentry_list_projects_url, body: projects_sample_response)
@@ -159,7 +159,7 @@ describe Sentry::Client do
end
end
- context 'error object created from sentry response' do
+ context "error object created from sentry response" do
using RSpec::Parameterized::TableSyntax
where(:sentry_project_object, :sentry_response) do
@@ -177,22 +177,22 @@ describe Sentry::Client do
end
end
- context 'redirects' do
+ context "redirects" do
let(:sentry_api_url) { sentry_list_projects_url }
- it_behaves_like 'no redirects'
+ it_behaves_like "no redirects"
end
# Sentry API returns 404 if there are extra slashes in the URL!
- context 'extra slashes in URL' do
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api//0/projects//' }
+ context "extra slashes in URL" do
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api//0/projects//" }
let(:client) { described_class.new(sentry_url, token) }
let!(:valid_req_stub) do
stub_sentry_request(sentry_list_projects_url)
end
- it 'removes extra slashes in api url' do
+ it "removes extra slashes in api url" do
expect(Gitlab::HTTP).to receive(:get).with(
URI(sentry_list_projects_url),
anything
@@ -211,7 +211,7 @@ describe Sentry::Client do
WebMock.stub_request(:get, url)
.to_return(
status: status,
- headers: { 'Content-Type' => 'application/json' }.merge(headers),
+ headers: {"Content-Type" => "application/json"}.merge(headers),
body: body.to_json
)
end
diff --git a/spec/lib/serializers/json_spec.rb b/spec/lib/serializers/json_spec.rb
index 5d59d66e8b8..f6d8ac141a9 100644
--- a/spec/lib/serializers/json_spec.rb
+++ b/spec/lib/serializers/json_spec.rb
@@ -1,99 +1,99 @@
-require 'fast_spec_helper'
+require "fast_spec_helper"
describe Serializers::JSON do
- describe '.dump' do
- let(:obj) { { key: "value" } }
+ describe ".dump" do
+ let(:obj) { {key: "value"} }
subject { described_class.dump(obj) }
- context 'when MySQL is used' do
+ context "when MySQL is used" do
before do
- allow(Gitlab::Database).to receive(:adapter_name) { 'mysql2' }
+ allow(Gitlab::Database).to receive(:adapter_name) { "mysql2" }
end
- it 'encodes as string' do
+ it "encodes as string" do
is_expected.to eq('{"key":"value"}')
end
end
- context 'when PostgreSQL is used' do
+ context "when PostgreSQL is used" do
before do
- allow(Gitlab::Database).to receive(:adapter_name) { 'postgresql' }
+ allow(Gitlab::Database).to receive(:adapter_name) { "postgresql" }
end
- it 'returns a hash' do
+ it "returns a hash" do
is_expected.to eq(obj)
end
end
end
- describe '.load' do
+ describe ".load" do
let(:data_string) { '{"key":"value","variables":[{"key":"VAR1","value":"VALUE1"}]}' }
let(:data_hash) { JSON.parse(data_string) }
- shared_examples 'having consistent accessor' do
- it 'allows to access with symbols' do
- expect(subject[:key]).to eq('value')
- expect(subject[:variables].first[:key]).to eq('VAR1')
+ shared_examples "having consistent accessor" do
+ it "allows to access with symbols" do
+ expect(subject[:key]).to eq("value")
+ expect(subject[:variables].first[:key]).to eq("VAR1")
end
- it 'allows to access with strings' do
- expect(subject["key"]).to eq('value')
- expect(subject["variables"].first["key"]).to eq('VAR1')
+ it "allows to access with strings" do
+ expect(subject["key"]).to eq("value")
+ expect(subject["variables"].first["key"]).to eq("VAR1")
end
end
- context 'when MySQL is used' do
+ context "when MySQL is used" do
before do
- allow(Gitlab::Database).to receive(:adapter_name) { 'mysql2' }
+ allow(Gitlab::Database).to receive(:adapter_name) { "mysql2" }
end
- context 'when loading a string' do
+ context "when loading a string" do
subject { described_class.load(data_string) }
- it 'decodes a string' do
+ it "decodes a string" do
is_expected.to be_a(Hash)
end
- it_behaves_like 'having consistent accessor'
+ it_behaves_like "having consistent accessor"
end
- context 'when loading a different type' do
- subject { described_class.load({ key: 'hash' }) }
+ context "when loading a different type" do
+ subject { described_class.load({key: "hash"}) }
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(TypeError)
end
end
- context 'when loading a nil' do
+ context "when loading a nil" do
subject { described_class.load(nil) }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- context 'when PostgreSQL is used' do
+ context "when PostgreSQL is used" do
before do
- allow(Gitlab::Database).to receive(:adapter_name) { 'postgresql' }
+ allow(Gitlab::Database).to receive(:adapter_name) { "postgresql" }
end
- context 'when loading a hash' do
+ context "when loading a hash" do
subject { described_class.load(data_hash) }
- it 'decodes a string' do
+ it "decodes a string" do
is_expected.to be_a(Hash)
end
- it_behaves_like 'having consistent accessor'
+ it_behaves_like "having consistent accessor"
end
- context 'when loading a nil' do
+ context "when loading a nil" do
subject { described_class.load(nil) }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
diff --git a/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb b/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb
index a0fb86345f3..5d68bbf5346 100644
--- a/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb
+++ b/spec/lib/system_check/app/git_user_default_ssh_config_check_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemCheck::App::GitUserDefaultSSHConfigCheck do
- let(:username) { '_this_user_will_not_exist_unless_it_is_stubbed' }
+ let(:username) { "_this_user_will_not_exist_unless_it_is_stubbed" }
let(:base_dir) { Dir.mktmpdir }
let(:home_dir) { File.join(base_dir, "/var/lib/#{username}") }
- let(:ssh_dir) { File.join(home_dir, '.ssh') }
- let(:forbidden_file) { 'id_rsa' }
+ let(:ssh_dir) { File.join(home_dir, ".ssh") }
+ let(:forbidden_file) { "id_rsa" }
before do
allow(Gitlab.config.gitlab).to receive(:user).and_return(username)
@@ -15,16 +15,16 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do
FileUtils.rm_rf(base_dir)
end
- it 'only whitelists safe files' do
+ it "only whitelists safe files" do
expect(described_class::WHITELIST).to contain_exactly(
- 'authorized_keys',
- 'authorized_keys2',
- 'authorized_keys.lock',
- 'known_hosts'
+ "authorized_keys",
+ "authorized_keys2",
+ "authorized_keys.lock",
+ "known_hosts"
)
end
- describe '#skip?' do
+ describe "#skip?" do
subject { described_class.new.skip? }
where(user_exists: [true, false], home_dir_exists: [true, false])
@@ -41,14 +41,14 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do
end
end
- describe '#check?' do
+ describe "#check?" do
subject { described_class.new.check? }
before do
stub_user
end
- it 'fails if a forbidden file exists' do
+ it "fails if a forbidden file exists" do
stub_ssh_file(forbidden_file)
is_expected.to be_falsy
@@ -60,7 +60,7 @@ describe SystemCheck::App::GitUserDefaultSSHConfigCheck do
is_expected.to be_truthy
end
- it 'succeeds if all the whitelisted files exist' do
+ it "succeeds if all the whitelisted files exist" do
described_class::WHITELIST.each do |filename|
stub_ssh_file(filename)
end
diff --git a/spec/lib/system_check/base_check_spec.rb b/spec/lib/system_check/base_check_spec.rb
index faf8c99e772..418ca661ca8 100644
--- a/spec/lib/system_check/base_check_spec.rb
+++ b/spec/lib/system_check/base_check_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemCheck::BaseCheck do
- context 'helpers on instance level' do
- it 'responds to SystemCheck::Helpers methods' do
+ context "helpers on instance level" do
+ it "responds to SystemCheck::Helpers methods" do
expect(subject).to respond_to :fix_and_rerun, :for_more_information, :see_installation_guide_section,
:finished_checking, :start_checking, :try_fixing_it, :sanitized_message, :should_sanitize?, :omnibus_gitlab?,
:sudo_gitlab
end
- it 'responds to Gitlab::TaskHelpers methods' do
+ it "responds to Gitlab::TaskHelpers methods" do
expect(subject).to respond_to :ask_to_continue, :os_name, :prompt, :run_and_match, :run_command,
:run_command!, :uid_for, :gid_for, :gitlab_user, :gitlab_user?, :warn_user_is_not_gitlab, :all_repos,
:repository_storage_paths_args, :user_home, :checkout_or_clone_version, :clone_repo, :checkout_version
diff --git a/spec/lib/system_check/orphans/namespace_check_spec.rb b/spec/lib/system_check/orphans/namespace_check_spec.rb
index 2a61ff3ad65..d8cdd159b72 100644
--- a/spec/lib/system_check/orphans/namespace_check_spec.rb
+++ b/spec/lib/system_check/orphans/namespace_check_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'rake_helper'
+require "spec_helper"
+require "rake_helper"
describe SystemCheck::Orphans::NamespaceCheck do
- let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } }
+ let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? "broken" } }
before do
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
@@ -10,44 +10,44 @@ describe SystemCheck::Orphans::NamespaceCheck do
silence_output
end
- describe '#multi_check' do
- context 'all orphans' do
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) }
+ describe "#multi_check" do
+ context "all orphans" do
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] }
- it 'prints list of all orphaned namespaces except @hashed' do
- expect_list_of_orphans(%w(orphan1 orphan2))
+ it "prints list of all orphaned namespaces except @hashed" do
+ expect_list_of_orphans(%w[orphan1 orphan2])
subject.multi_check
end
end
- context 'few orphans with existing namespace' do
- let!(:first_level) { create(:group, path: 'my-namespace') }
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) }
+ context "few orphans with existing namespace" do
+ let!(:first_level) { create(:group, path: "my-namespace") }
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] }
- it 'prints list of orphaned namespaces' do
- expect_list_of_orphans(%w(orphan1 orphan2))
+ it "prints list of orphaned namespaces" do
+ expect_list_of_orphans(%w[orphan1 orphan2])
subject.multi_check
end
end
- context 'few orphans with existing namespace and parents with same name as orphans' do
- let!(:first_level) { create(:group, path: 'my-namespace') }
- let!(:second_level) { create(:group, path: 'second-level', parent: first_level) }
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) }
+ context "few orphans with existing namespace and parents with same name as orphans" do
+ let!(:first_level) { create(:group, path: "my-namespace") }
+ let!(:second_level) { create(:group, path: "second-level", parent: first_level) }
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] }
- it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do
- expect_list_of_orphans(%w(orphan1 orphan2 second-level))
+ it "prints list of orphaned namespaces ignoring parents with same namespace as orphans" do
+ expect_list_of_orphans(%w[orphan1 orphan2 second-level])
subject.multi_check
end
end
- context 'no orphans' do
- let(:disk_namespaces) { %w(@hashed) }
+ context "no orphans" do
+ let(:disk_namespaces) { %w[@hashed] }
- it 'prints an empty list ignoring @hashed' do
+ it "prints an empty list ignoring @hashed" do
expect_list_of_orphans([])
subject.multi_check
@@ -56,6 +56,6 @@ describe SystemCheck::Orphans::NamespaceCheck do
end
def expect_list_of_orphans(orphans)
- expect(subject).to receive(:print_orphans).with(orphans, 'default')
+ expect(subject).to receive(:print_orphans).with(orphans, "default")
end
end
diff --git a/spec/lib/system_check/orphans/repository_check_spec.rb b/spec/lib/system_check/orphans/repository_check_spec.rb
index b0c2267d177..8fc0fa3e77a 100644
--- a/spec/lib/system_check/orphans/repository_check_spec.rb
+++ b/spec/lib/system_check/orphans/repository_check_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require 'rake_helper'
+require "spec_helper"
+require "rake_helper"
describe SystemCheck::Orphans::RepositoryCheck do
- let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? 'broken' } }
+ let(:storages) { Gitlab.config.repositories.storages.reject { |key, _| key.eql? "broken" } }
before do
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
@@ -11,50 +11,50 @@ describe SystemCheck::Orphans::RepositoryCheck do
# silence_output
end
- describe '#multi_check' do
- context 'all orphans' do
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 repos/@hashed) }
- let(:disk_repositories) { %w(repo1.git repo2.git) }
+ describe "#multi_check" do
+ context "all orphans" do
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 repos/@hashed] }
+ let(:disk_repositories) { %w[repo1.git repo2.git] }
- it 'prints list of all orphaned namespaces except @hashed' do
- expect_list_of_orphans(%w(orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git))
+ it "prints list of all orphaned namespaces except @hashed" do
+ expect_list_of_orphans(%w[orphan1/repo1.git orphan1/repo2.git orphan2/repo1.git orphan2/repo2.git])
subject.multi_check
end
end
- context 'few orphans with existing namespace' do
- let!(:first_level) { create(:group, path: 'my-namespace') }
- let!(:project) { create(:project, path: 'repo', namespace: first_level) }
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed) }
- let(:disk_repositories) { %w(repo.git) }
+ context "few orphans with existing namespace" do
+ let!(:first_level) { create(:group, path: "my-namespace") }
+ let!(:project) { create(:project, path: "repo", namespace: first_level) }
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/@hashed] }
+ let(:disk_repositories) { %w[repo.git] }
- it 'prints list of orphaned namespaces' do
- expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git))
+ it "prints list of orphaned namespaces" do
+ expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git])
subject.multi_check
end
end
- context 'few orphans with existing namespace and parents with same name as orphans' do
- let!(:first_level) { create(:group, path: 'my-namespace') }
- let!(:second_level) { create(:group, path: 'second-level', parent: first_level) }
- let!(:project) { create(:project, path: 'repo', namespace: first_level) }
- let(:disk_namespaces) { %w(/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed) }
- let(:disk_repositories) { %w(repo.git) }
+ context "few orphans with existing namespace and parents with same name as orphans" do
+ let!(:first_level) { create(:group, path: "my-namespace") }
+ let!(:second_level) { create(:group, path: "second-level", parent: first_level) }
+ let!(:project) { create(:project, path: "repo", namespace: first_level) }
+ let(:disk_namespaces) { %w[/repos/orphan1 /repos/orphan2 /repos/my-namespace /repos/second-level /repos/@hashed] }
+ let(:disk_repositories) { %w[repo.git] }
- it 'prints list of orphaned namespaces ignoring parents with same namespace as orphans' do
- expect_list_of_orphans(%w(orphan1/repo.git orphan2/repo.git second-level/repo.git))
+ it "prints list of orphaned namespaces ignoring parents with same namespace as orphans" do
+ expect_list_of_orphans(%w[orphan1/repo.git orphan2/repo.git second-level/repo.git])
subject.multi_check
end
end
- context 'no orphans' do
- let(:disk_namespaces) { %w(@hashed) }
- let(:disk_repositories) { %w(repo.git) }
+ context "no orphans" do
+ let(:disk_namespaces) { %w[@hashed] }
+ let(:disk_repositories) { %w[repo.git] }
- it 'prints an empty list ignoring @hashed' do
+ it "prints an empty list ignoring @hashed" do
expect_list_of_orphans([])
subject.multi_check
@@ -63,6 +63,6 @@ describe SystemCheck::Orphans::RepositoryCheck do
end
def expect_list_of_orphans(orphans)
- expect(subject).to receive(:print_orphans).with(orphans, 'default')
+ expect(subject).to receive(:print_orphans).with(orphans, "default")
end
end
diff --git a/spec/lib/system_check/simple_executor_spec.rb b/spec/lib/system_check/simple_executor_spec.rb
index e71e9da369d..c8c4f7b76db 100644
--- a/spec/lib/system_check/simple_executor_spec.rb
+++ b/spec/lib/system_check/simple_executor_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
-require 'rake_helper'
+require "spec_helper"
+require "rake_helper"
describe SystemCheck::SimpleExecutor do
class SimpleCheck < SystemCheck::BaseCheck
- set_name 'my simple check'
+ set_name "my simple check"
def check?
true
@@ -11,70 +11,70 @@ describe SystemCheck::SimpleExecutor do
end
class OtherCheck < SystemCheck::BaseCheck
- set_name 'other check'
+ set_name "other check"
def check?
false
end
def show_error
- $stdout.puts 'this is an error text'
+ $stdout.puts "this is an error text"
end
end
class SkipCheck < SystemCheck::BaseCheck
- set_name 'skip check'
- set_skip_reason 'this is a skip reason'
+ set_name "skip check"
+ set_skip_reason "this is a skip reason"
def skip?
true
end
def check?
- raise 'should not execute this'
+ raise "should not execute this"
end
end
class DynamicSkipCheck < SystemCheck::BaseCheck
- set_name 'dynamic skip check'
- set_skip_reason 'this is a skip reason'
+ set_name "dynamic skip check"
+ set_skip_reason "this is a skip reason"
def skip?
- self.skip_reason = 'this is a dynamic skip reason'
+ self.skip_reason = "this is a dynamic skip reason"
true
end
def check?
- raise 'should not execute this'
+ raise "should not execute this"
end
end
class MultiCheck < SystemCheck::BaseCheck
- set_name 'multi check'
+ set_name "multi check"
def multi_check
- $stdout.puts 'this is a multi output check'
+ $stdout.puts "this is a multi output check"
end
def check?
- raise 'should not execute this'
+ raise "should not execute this"
end
end
class SkipMultiCheck < SystemCheck::BaseCheck
- set_name 'skip multi check'
+ set_name "skip multi check"
def skip?
true
end
def multi_check
- raise 'should not execute this'
+ raise "should not execute this"
end
end
class RepairCheck < SystemCheck::BaseCheck
- set_name 'repair check'
+ set_name "repair check"
def check?
false
@@ -85,41 +85,41 @@ describe SystemCheck::SimpleExecutor do
end
def show_error
- $stdout.puts 'this is an error message'
+ $stdout.puts "this is an error message"
end
end
class BugousCheck < SystemCheck::BaseCheck
CustomError = Class.new(StandardError)
- set_name 'my bugous check'
+ set_name "my bugous check"
def check?
- raise CustomError, 'omg'
+ raise CustomError, "omg"
end
end
- describe '#component' do
- it 'returns stored component name' do
- expect(subject.component).to eq('Test')
+ describe "#component" do
+ it "returns stored component name" do
+ expect(subject.component).to eq("Test")
end
end
- describe '#checks' do
+ describe "#checks" do
before do
subject << SimpleCheck
end
- it 'returns a set of classes' do
+ it "returns a set of classes" do
expect(subject.checks).to include(SimpleCheck)
end
end
- describe '#<<' do
+ describe "#<<" do
before do
subject << SimpleCheck
end
- it 'appends a new check to the Set' do
+ it "appends a new check to the Set" do
subject << OtherCheck
stored_checks = subject.checks.to_a
@@ -127,20 +127,20 @@ describe SystemCheck::SimpleExecutor do
expect(stored_checks.last).to eq(OtherCheck)
end
- it 'inserts unique itens only' do
+ it "inserts unique itens only" do
subject << SimpleCheck
expect(subject.checks.size).to eq(1)
end
- it 'errors out when passing multiple items' do
+ it "errors out when passing multiple items" do
expect { subject << [SimpleCheck, OtherCheck] }.to raise_error(ArgumentError)
end
end
- subject { described_class.new('Test') }
+ subject { described_class.new("Test") }
- describe '#execute' do
+ describe "#execute" do
before do
silence_output
@@ -148,7 +148,7 @@ describe SystemCheck::SimpleExecutor do
subject << OtherCheck
end
- it 'runs included checks' do
+ it "runs included checks" do
expect(subject).to receive(:run_check).with(SimpleCheck)
expect(subject).to receive(:run_check).with(OtherCheck)
@@ -156,39 +156,39 @@ describe SystemCheck::SimpleExecutor do
end
end
- describe '#run_check' do
- it 'prints check name' do
+ describe "#run_check" do
+ it "prints check name" do
expect(SimpleCheck).to receive(:display_name).and_call_original
expect { subject.run_check(SimpleCheck) }.to output(/my simple check/).to_stdout
end
- context 'when check pass' do
- it 'prints yes' do
+ context "when check pass" do
+ it "prints yes" do
expect_any_instance_of(SimpleCheck).to receive(:check?).and_call_original
expect { subject.run_check(SimpleCheck) }.to output(/ \.\.\. yes/).to_stdout
end
end
- context 'when check fails' do
- it 'prints no' do
+ context "when check fails" do
+ it "prints no" do
expect_any_instance_of(OtherCheck).to receive(:check?).and_call_original
expect { subject.run_check(OtherCheck) }.to output(/ \.\.\. no/).to_stdout
end
- it 'displays error message from #show_error' do
+ it "displays error message from #show_error" do
expect_any_instance_of(OtherCheck).to receive(:show_error).and_call_original
expect { subject.run_check(OtherCheck) }.to output(/this is an error text/).to_stdout
end
- context 'when check implements #repair!' do
- it 'executes #repair!' do
+ context "when check implements #repair!" do
+ it "executes #repair!" do
expect_any_instance_of(RepairCheck).to receive(:repair!)
subject.run_check(RepairCheck)
end
- context 'when repair succeeds' do
- it 'does not execute #show_error' do
+ context "when repair succeeds" do
+ it "does not execute #show_error" do
expect_any_instance_of(RepairCheck).to receive(:repair!).and_call_original
expect_any_instance_of(RepairCheck).not_to receive(:show_error)
@@ -196,8 +196,8 @@ describe SystemCheck::SimpleExecutor do
end
end
- context 'when repair fails' do
- it 'does not execute #show_error' do
+ context "when repair fails" do
+ it "does not execute #show_error" do
expect_any_instance_of(RepairCheck).to receive(:repair!) { false }
expect_any_instance_of(RepairCheck).to receive(:show_error)
@@ -207,43 +207,43 @@ describe SystemCheck::SimpleExecutor do
end
end
- context 'when check implements skip?' do
- it 'executes #skip? method' do
+ context "when check implements skip?" do
+ it "executes #skip? method" do
expect_any_instance_of(SkipCheck).to receive(:skip?).and_call_original
subject.run_check(SkipCheck)
end
- it 'displays .skip_reason' do
+ it "displays .skip_reason" do
expect { subject.run_check(SkipCheck) }.to output(/this is a skip reason/).to_stdout
end
- it 'displays #skip_reason' do
+ it "displays #skip_reason" do
expect { subject.run_check(DynamicSkipCheck) }.to output(/this is a dynamic skip reason/).to_stdout
end
- it 'does not execute #check when #skip? is true' do
+ it "does not execute #check when #skip? is true" do
expect_any_instance_of(SkipCheck).not_to receive(:check?)
subject.run_check(SkipCheck)
end
end
- context 'when implements a #multi_check' do
- it 'executes #multi_check method' do
+ context "when implements a #multi_check" do
+ it "executes #multi_check method" do
expect_any_instance_of(MultiCheck).to receive(:multi_check)
subject.run_check(MultiCheck)
end
- it 'does not execute #check method' do
+ it "does not execute #check method" do
expect_any_instance_of(MultiCheck).not_to receive(:check)
subject.run_check(MultiCheck)
end
- context 'when check implements #skip?' do
- it 'executes #skip? method' do
+ context "when check implements #skip?" do
+ it "executes #skip? method" do
expect_any_instance_of(SkipMultiCheck).to receive(:skip?).and_call_original
subject.run_check(SkipMultiCheck)
@@ -251,8 +251,8 @@ describe SystemCheck::SimpleExecutor do
end
end
- context 'when there is an exception' do
- it 'rescues the exception' do
+ context "when there is an exception" do
+ it "rescues the exception" do
expect { subject.run_check(BugousCheck) }.not_to raise_exception
end
end
diff --git a/spec/lib/system_check_spec.rb b/spec/lib/system_check_spec.rb
index 4d9e17fa6ec..61985751b5c 100644
--- a/spec/lib/system_check_spec.rb
+++ b/spec/lib/system_check_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'rake_helper'
+require "spec_helper"
+require "rake_helper"
describe SystemCheck do
class SimpleCheck < SystemCheck::BaseCheck
@@ -18,19 +18,19 @@ describe SystemCheck do
silence_output
end
- describe '.run' do
+ describe ".run" do
subject { described_class }
- it 'detects execution of SimpleCheck' do
+ it "detects execution of SimpleCheck" do
is_expected.to execute_check(SimpleCheck)
- subject.run('Test', [SimpleCheck])
+ subject.run("Test", [SimpleCheck])
end
- it 'detects exclusion of OtherCheck in execution' do
+ it "detects exclusion of OtherCheck in execution" do
is_expected.not_to execute_check(OtherCheck)
- subject.run('Test', [SimpleCheck])
+ subject.run("Test", [SimpleCheck])
end
end
end
diff --git a/spec/lib/uploaded_file_spec.rb b/spec/lib/uploaded_file_spec.rb
index a2f5c2e7121..47d77e88067 100644
--- a/spec/lib/uploaded_file_spec.rb
+++ b/spec/lib/uploaded_file_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UploadedFile do
let(:temp_dir) { Dir.tmpdir }
@@ -23,10 +23,10 @@ describe UploadedFile do
described_class.from_params(params, :file, upload_path)
end
- context 'when valid file is specified' do
- context 'only local path is specified' do
+ context "when valid file is specified" do
+ context "only local path is specified" do
let(:params) do
- { 'file.path' => temp_file.path }
+ {"file.path" => temp_file.path}
end
it "succeeds" do
@@ -38,13 +38,13 @@ describe UploadedFile do
end
end
- context 'all parameters are specified' do
+ context "all parameters are specified" do
let(:params) do
- { 'file.path' => temp_file.path,
- 'file.name' => 'dir/my file&.txt',
- 'file.type' => 'my/type',
- 'file.sha256' => 'sha256',
- 'file.remote_id' => 'remote_id' }
+ {"file.path" => temp_file.path,
+ "file.name" => "dir/my file&.txt",
+ "file.type" => "my/type",
+ "file.sha256" => "sha256",
+ "file.remote_id" => "remote_id",}
end
it "succeeds" do
@@ -52,15 +52,15 @@ describe UploadedFile do
end
it "generates filename from path" do
- expect(subject.original_filename).to eq('my_file_.txt')
- expect(subject.content_type).to eq('my/type')
- expect(subject.sha256).to eq('sha256')
- expect(subject.remote_id).to eq('remote_id')
+ expect(subject.original_filename).to eq("my_file_.txt")
+ expect(subject.content_type).to eq("my/type")
+ expect(subject.sha256).to eq("sha256")
+ expect(subject.remote_id).to eq("remote_id")
end
end
end
- context 'when no params are specified' do
+ context "when no params are specified" do
let(:params) do
{}
end
@@ -70,9 +70,9 @@ describe UploadedFile do
end
end
- context 'when only remote id is specified' do
+ context "when only remote id is specified" do
let(:params) do
- { 'file.remote_id' => 'remote_id' }
+ {"file.remote_id" => "remote_id"}
end
it "raises an error" do
@@ -80,12 +80,12 @@ describe UploadedFile do
end
end
- context 'when verifying allowed paths' do
+ context "when verifying allowed paths" do
let(:params) do
- { 'file.path' => temp_file.path }
+ {"file.path" => temp_file.path}
end
- context 'when file is stored in system temporary folder' do
+ context "when file is stored in system temporary folder" do
let(:temp_dir) { Dir.tmpdir }
it "succeeds" do
@@ -93,7 +93,7 @@ describe UploadedFile do
end
end
- context 'when file is stored in user provided upload path' do
+ context "when file is stored in user provided upload path" do
let(:upload_path) { Dir.mktmpdir }
let(:temp_dir) { upload_path }
@@ -102,7 +102,7 @@ describe UploadedFile do
end
end
- context 'when file is stored outside of user provided upload path' do
+ context "when file is stored outside of user provided upload path" do
let!(:generated_dir) { Dir.mktmpdir }
let!(:temp_dir) { Dir.mktmpdir }
@@ -118,10 +118,10 @@ describe UploadedFile do
end
end
- describe '#sanitize_filename' do
- it { expect(described_class.new(temp_file.path).sanitize_filename('spaced name')).to eq('spaced_name') }
- it { expect(described_class.new(temp_file.path).sanitize_filename('#$%^&')).to eq('_____') }
- it { expect(described_class.new(temp_file.path).sanitize_filename('..')).to eq('_..') }
- it { expect(described_class.new(temp_file.path).sanitize_filename('')).to eq('unnamed') }
+ describe "#sanitize_filename" do
+ it { expect(described_class.new(temp_file.path).sanitize_filename("spaced name")).to eq("spaced_name") }
+ it { expect(described_class.new(temp_file.path).sanitize_filename("\#$%^&")).to eq("_____") }
+ it { expect(described_class.new(temp_file.path).sanitize_filename("..")).to eq("_..") }
+ it { expect(described_class.new(temp_file.path).sanitize_filename("")).to eq("unnamed") }
end
end
diff --git a/spec/mailers/abuse_report_mailer_spec.rb b/spec/mailers/abuse_report_mailer_spec.rb
index f96870cc112..6e2c582c89e 100644
--- a/spec/mailers/abuse_report_mailer_spec.rb
+++ b/spec/mailers/abuse_report_mailer_spec.rb
@@ -1,32 +1,32 @@
-require 'rails_helper'
+require "rails_helper"
describe AbuseReportMailer do
include EmailSpec::Matchers
- describe '.notify' do
+ describe ".notify" do
before do
- stub_application_setting(admin_notification_email: 'admin@example.com')
+ stub_application_setting(admin_notification_email: "admin@example.com")
end
let(:report) { create(:abuse_report) }
subject { described_class.notify(report.id) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- context 'with admin_notification_email set' do
- it 'sends to the admin_notification_email' do
- is_expected.to deliver_to 'admin@example.com'
+ context "with admin_notification_email set" do
+ it "sends to the admin_notification_email" do
+ is_expected.to deliver_to "admin@example.com"
end
- it 'includes the user in the subject' do
+ it "includes the user in the subject" do
is_expected.to have_subject "#{report.user.name} (#{report.user.username}) was reported for abuse"
end
end
- context 'with no admin_notification_email set' do
- it 'returns early' do
+ context "with no admin_notification_email set" do
+ it "returns early" do
stub_application_setting(admin_notification_email: nil)
expect { described_class.notify(spy).deliver_now }
diff --git a/spec/mailers/email_rejection_mailer_spec.rb b/spec/mailers/email_rejection_mailer_spec.rb
index bbe0a50ae8e..bdfe1372c3a 100644
--- a/spec/mailers/email_rejection_mailer_spec.rb
+++ b/spec/mailers/email_rejection_mailer_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
describe EmailRejectionMailer do
include EmailSpec::Matchers
- describe '#rejection' do
+ describe "#rejection" do
let(:raw_email) { 'From: someone@example.com\nraw email here' }
- subject { described_class.rejection('some rejection reason', raw_email) }
+ subject { described_class.rejection("some rejection reason", raw_email) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
end
end
diff --git a/spec/mailers/emails/auto_devops_spec.rb b/spec/mailers/emails/auto_devops_spec.rb
index dd7c12c3143..2291125b86c 100644
--- a/spec/mailers/emails/auto_devops_spec.rb
+++ b/spec/mailers/emails/auto_devops_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Emails::AutoDevops do
include EmailSpec::Matchers
- describe '#auto_devops_disabled_email' do
+ describe "#auto_devops_disabled_email" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, :repository, :auto_devops) }
@@ -13,20 +13,20 @@ describe Emails::AutoDevops do
subject { Notify.autodevops_disabled_email(pipeline, owner.email) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'sents email with correct subject' do
+ it "sents email with correct subject" do
is_expected.to have_subject("#{project.name} | Auto DevOps pipeline was disabled for #{project.name}")
end
- it 'sents an email to the user' do
+ it "sents an email to the user" do
recipient = subject.header[:to].addrs.map(&:address).first
expect(recipient).to eq(owner.email)
end
- it 'is sent as GitLab email' do
+ it "is sent as GitLab email" do
sender = subject.header[:from].addrs[0].address
expect(sender).to match(/gitlab/)
diff --git a/spec/mailers/emails/issues_spec.rb b/spec/mailers/emails/issues_spec.rb
index 5b5bd6f4308..173fb125bee 100644
--- a/spec/mailers/emails/issues_spec.rb
+++ b/spec/mailers/emails/issues_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'email_spec'
+require "spec_helper"
+require "email_spec"
describe Emails::Issues do
include EmailSpec::Matchers
@@ -13,30 +13,30 @@ describe Emails::Issues do
subject { Notify.import_issues_csv_email(user.id, project.id, @results) }
it "shows number of successful issues imported" do
- @results = { success: 165, error_lines: [], parse_error: false }
+ @results = {success: 165, error_lines: [], parse_error: false}
expect(subject).to have_body_text "165 issues imported"
end
it "shows error when file is invalid" do
- @results = { success: 0, error_lines: [], parse_error: true }
+ @results = {success: 0, error_lines: [], parse_error: true}
expect(subject).to have_body_text "Error parsing CSV"
end
it "shows line numbers with errors" do
- @results = { success: 0, error_lines: [23, 34, 58], parse_error: false }
+ @results = {success: 0, error_lines: [23, 34, 58], parse_error: false}
expect(subject).to have_body_text "23, 34, 58"
end
- context 'with header and footer' do
- let(:results) { { success: 165, error_lines: [], parse_error: false } }
+ context "with header and footer" do
+ let(:results) { {success: 165, error_lines: [], parse_error: false} }
subject { Notify.import_issues_csv_email(user.id, project.id, results) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
end
end
end
diff --git a/spec/mailers/emails/merge_requests_spec.rb b/spec/mailers/emails/merge_requests_spec.rb
index 2ad572bb5c7..8b79e0e989c 100644
--- a/spec/mailers/emails/merge_requests_spec.rb
+++ b/spec/mailers/emails/merge_requests_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'email_spec'
+require "spec_helper"
+require "email_spec"
describe Emails::MergeRequests do
include EmailSpec::Matchers
diff --git a/spec/mailers/emails/pages_domains_spec.rb b/spec/mailers/emails/pages_domains_spec.rb
index c74fd66ad22..8ee435353b0 100644
--- a/spec/mailers/emails/pages_domains_spec.rb
+++ b/spec/mailers/emails/pages_domains_spec.rb
@@ -1,71 +1,71 @@
-require 'spec_helper'
-require 'email_spec'
+require "spec_helper"
+require "email_spec"
describe Emails::PagesDomains do
include EmailSpec::Matchers
- include_context 'gitlab email notification'
+ include_context "gitlab email notification"
set(:project) { create(:project) }
set(:domain) { create(:pages_domain, project: project) }
set(:user) { project.owner }
- shared_examples 'a pages domain email' do
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ shared_examples "a pages domain email" do
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'has the expected content' do
+ it "has the expected content" do
aggregate_failures do
is_expected.to have_subject(email_subject)
is_expected.to have_body_text(project.human_name)
is_expected.to have_body_text(domain.domain)
is_expected.to have_body_text domain.url
is_expected.to have_body_text project_pages_domain_url(project, domain)
- is_expected.to have_body_text help_page_url('user/project/pages/getting_started_part_three.md', anchor: 'dns-txt-record')
+ is_expected.to have_body_text help_page_url("user/project/pages/getting_started_part_three.md", anchor: "dns-txt-record")
end
end
end
- describe '#pages_domain_enabled_email' do
+ describe "#pages_domain_enabled_email" do
let(:email_subject) { "#{project.path} | GitLab Pages domain '#{domain.domain}' has been enabled" }
subject { Notify.pages_domain_enabled_email(domain, user) }
- it_behaves_like 'a pages domain email'
+ it_behaves_like "a pages domain email"
- it { is_expected.to have_body_text 'has been enabled' }
+ it { is_expected.to have_body_text "has been enabled" }
end
- describe '#pages_domain_disabled_email' do
+ describe "#pages_domain_disabled_email" do
let(:email_subject) { "#{project.path} | GitLab Pages domain '#{domain.domain}' has been disabled" }
subject { Notify.pages_domain_disabled_email(domain, user) }
- it_behaves_like 'a pages domain email'
+ it_behaves_like "a pages domain email"
- it { is_expected.to have_body_text 'has been disabled' }
+ it { is_expected.to have_body_text "has been disabled" }
end
- describe '#pages_domain_verification_succeeded_email' do
+ describe "#pages_domain_verification_succeeded_email" do
let(:email_subject) { "#{project.path} | Verification succeeded for GitLab Pages domain '#{domain.domain}'" }
subject { Notify.pages_domain_verification_succeeded_email(domain, user) }
- it_behaves_like 'a pages domain email'
+ it_behaves_like "a pages domain email"
- it { is_expected.to have_body_text 'successfully verified' }
+ it { is_expected.to have_body_text "successfully verified" }
end
- describe '#pages_domain_verification_failed_email' do
+ describe "#pages_domain_verification_failed_email" do
let(:email_subject) { "#{project.path} | ACTION REQUIRED: Verification failed for GitLab Pages domain '#{domain.domain}'" }
subject { Notify.pages_domain_verification_failed_email(domain, user) }
- it_behaves_like 'a pages domain email'
+ it_behaves_like "a pages domain email"
- it 'says verification has failed and when the domain is enabled until' do
- is_expected.to have_body_text 'Verification has failed'
- is_expected.to have_body_text domain.enabled_until.strftime('%F %T')
+ it "says verification has failed and when the domain is enabled until" do
+ is_expected.to have_body_text "Verification has failed"
+ is_expected.to have_body_text domain.enabled_until.strftime("%F %T")
end
end
end
diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb
index 1f7be415e35..152202086c0 100644
--- a/spec/mailers/emails/profile_spec.rb
+++ b/spec/mailers/emails/profile_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
-require 'email_spec'
+require "spec_helper"
+require "email_spec"
describe Emails::Profile do
include EmailSpec::Matchers
- include_context 'gitlab email notification'
+ include_context "gitlab email notification"
- shared_examples 'a new user email' do
- it 'is sent to the new user with the correct subject and body' do
+ shared_examples "a new user email" do
+ it "is sent to the new user with the correct subject and body" do
aggregate_failures do
is_expected.to deliver_to new_user_address
is_expected.to have_subject(/^Account was created for you$/i)
@@ -15,109 +15,109 @@ describe Emails::Profile do
end
end
- describe 'for new users, the email' do
+ describe "for new users, the email" do
let(:example_site_path) { root_path }
let(:new_user) { create(:user, email: new_user_address, created_by_id: 1) }
- let(:token) { 'kETLwRaayvigPq_x3SNM' }
+ let(:token) { "kETLwRaayvigPq_x3SNM" }
subject { Notify.new_user_email(new_user.id, token) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'a new user email'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "a new user email"
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'contains the password text' do
+ it "contains the password text" do
is_expected.to have_body_text /Click here to set your password/
end
- it 'includes a link for user to set password' do
+ it "includes a link for user to set password" do
params = "reset_password_token=#{token}"
is_expected.to have_body_text(
%r{http://#{Gitlab.config.gitlab.host}(:\d+)?/users/password/edit\?#{params}}
)
end
- it 'explains the reset link expiration' do
+ it "explains the reset link expiration" do
is_expected.to have_body_text(/This link is valid for \d+ (hours?|days?)/)
is_expected.to have_body_text(new_user_password_url)
is_expected.to have_body_text(/\?user_email=.*%40.*/)
end
end
- describe 'for users that signed up, the email' do
+ describe "for users that signed up, the email" do
let(:example_site_path) { root_path }
let(:new_user) { create(:user, email: new_user_address, password: "securePassword") }
subject { Notify.new_user_email(new_user.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'a new user email'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "a new user email"
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'does 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
- describe 'user added ssh key' do
+ describe "user added ssh key" do
let(:key) { create(:personal_key) }
subject { Notify.new_ssh_key_email(key.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'is sent to the new user' do
+ it "is sent to the new user" do
is_expected.to deliver_to key.user.email
end
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_subject /^SSH key was added to your account$/i
end
- it 'contains the new ssh key title' do
+ it "contains the new ssh key title" do
is_expected.to have_body_text /#{key.title}/
end
- it 'includes a link to ssh keys page' do
+ it "includes a link to ssh keys page" do
is_expected.to have_body_text /#{profile_keys_path}/
end
- context 'with SSH key that does not exist' do
- it { expect { Notify.new_ssh_key_email('foo') }.not_to raise_error }
+ context "with SSH key that does not exist" do
+ it { expect { Notify.new_ssh_key_email("foo") }.not_to raise_error }
end
end
- describe 'user added gpg key' do
+ describe "user added gpg key" do
let(:gpg_key) { create(:gpg_key) }
subject { Notify.new_gpg_key_email(gpg_key.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'is sent to the new user' do
+ it "is sent to the new user" do
is_expected.to deliver_to gpg_key.user.email
end
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_subject /^GPG key was added to your account$/i
end
- it 'contains the new gpg key title' do
+ it "contains the new gpg key title" do
is_expected.to have_body_text /#{gpg_key.fingerprint}/
end
- it 'includes a link to gpg keys page' do
+ it "includes a link to gpg keys page" do
is_expected.to have_body_text /#{profile_gpg_keys_path}/
end
- context 'with GPG key that does not exist' do
- it { expect { Notify.new_gpg_key_email('foo') }.not_to raise_error }
+ context "with GPG key that does not exist" do
+ it { expect { Notify.new_gpg_key_email("foo") }.not_to raise_error }
end
end
end
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 15b04c9d066..3e21aca6511 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'email_spec'
+require "spec_helper"
+require "email_spec"
describe Notify do
include EmailSpec::Helpers
@@ -7,32 +7,32 @@ describe Notify do
include EmailHelpers
include RepoHelpers
- include_context 'gitlab email notification'
+ include_context "gitlab email notification"
- let(:current_user_sanitized) { 'www_example_com' }
+ let(:current_user_sanitized) { "www_example_com" }
set(:user) { create(:user) }
- set(:current_user) { create(:user, email: "current@email.com", name: 'www.example.com') }
- set(:assignee) { create(:user, email: 'assignee@example.com', name: 'John Doe') }
+ set(:current_user) { create(:user, email: "current@email.com", name: "www.example.com") }
+ set(:assignee) { create(:user, email: "assignee@example.com", name: "John Doe") }
set(:merge_request) do
create(:merge_request, source_project: project,
target_project: project,
author: current_user,
assignee: assignee,
- description: 'Awesome description')
+ description: "Awesome description")
end
set(:issue) do
create(:issue, author: current_user,
assignees: [assignee],
project: project,
- description: 'My awesome description!')
+ description: "My awesome description!")
end
- context 'for a project' do
- shared_examples 'an assignee email' do
- it 'is sent to the assignee as the author' do
+ context "for a project" do
+ shared_examples "an assignee email" do
+ it "is sent to the assignee as the author" do
sender = subject.header[:from].addrs.first
aggregate_failures do
@@ -43,77 +43,77 @@ describe Notify do
end
end
- context 'for issues' do
- describe 'that are new' do
+ context "for issues" do
+ describe "that are new" do
subject { described_class.new_issue_email(issue.assignees.first.id, issue.id) }
- it_behaves_like 'an assignee email'
- it_behaves_like 'an email starting a new thread with reply-by-email enabled' do
+ it_behaves_like "an assignee email"
+ it_behaves_like "an email starting a new thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(issue)
is_expected.to have_body_text(project_issue_path(project, issue))
end
end
- it 'contains the description' do
+ it "contains the description" do
is_expected.to have_body_text issue.description
end
- it 'does not add a reason header' do
- is_expected.not_to have_header('X-GitLab-NotificationReason', /.+/)
+ it "does not add a reason header" do
+ is_expected.not_to have_header("X-GitLab-NotificationReason", /.+/)
end
- context 'when sent with a reason' do
+ context "when sent with a reason" do
subject { described_class.new_issue_email(issue.assignees.first.id, issue.id, NotificationReason::ASSIGNED) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'includes the reason in a header' do
- is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ it "includes the reason in a header" do
+ is_expected.to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
end
- context 'when enabled email_author_in_body' do
+ context "when enabled email_author_in_body" do
before do
stub_application_setting(email_author_in_body: true)
end
- it 'contains a link to note author' do
+ it "contains a link to note author" do
is_expected.to have_body_text(issue.author_name)
- is_expected.to have_body_text 'created an issue:'
+ is_expected.to have_body_text "created an issue:"
end
end
end
- describe 'that are reassigned' do
- let(:previous_assignee) { create(:user, name: 'Previous Assignee') }
+ describe "that are reassigned" do
+ let(:previous_assignee) { create(:user, name: "Previous Assignee") }
subject { described_class.reassigned_issue_email(recipient.id, issue.id, [previous_assignee.id], current_user.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true)
is_expected.to have_body_text(previous_assignee.name)
@@ -122,46 +122,46 @@ describe Notify do
end
end
- context 'when sent with a reason' do
+ context "when sent with a reason" do
subject { described_class.reassigned_issue_email(recipient.id, issue.id, [previous_assignee.id], current_user.id, NotificationReason::ASSIGNED) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'includes the reason in a header' do
- is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ it "includes the reason in a header" do
+ is_expected.to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
end
end
- describe 'that have been relabeled' do
+ describe "that have been relabeled" do
subject { described_class.relabeled_issue_email(recipient.id, issue.id, %w[foo bar baz], current_user.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with a labels subscriptions link in its footer'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with a labels subscriptions link in its footer"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true)
- is_expected.to have_body_text('foo, bar, and baz')
+ is_expected.to have_body_text("foo, bar, and baz")
is_expected.to have_body_text(project_issue_path(project, issue))
end
end
- context 'with a preferred language' do
+ context "with a preferred language" do
before do
Gitlab::I18n.locale = :es
end
@@ -170,57 +170,57 @@ describe Notify do
Gitlab::I18n.use_default_locale
end
- it 'always generates the email using the default language' do
- is_expected.to have_body_text('foo, bar, and baz')
+ it "always generates the email using the default language" do
+ is_expected.to have_body_text("foo, bar, and baz")
end
end
end
- describe 'status changed' do
- let(:status) { 'closed' }
+ describe "status changed" do
+ let(:status) { "closed" }
subject { described_class.issue_status_changed_email(recipient.id, issue.id, status, current_user.id) }
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true)
is_expected.to have_body_text(status)
is_expected.to have_body_text(current_user_sanitized)
- is_expected.to have_body_text(project_issue_path project, issue)
+ is_expected.to have_body_text(project_issue_path(project, issue))
end
end
end
- describe 'moved to another project' do
+ describe "moved to another project" do
let(:new_issue) { create(:issue) }
subject { described_class.issue_moved_email(recipient, issue, new_issue, current_user) }
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains description about action taken' do
- is_expected.to have_body_text 'Issue was moved to another project'
+ it "contains description about action taken" do
+ is_expected.to have_body_text "Issue was moved to another project"
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
new_issue_url = project_issue_path(new_issue.project, new_issue)
aggregate_failures do
@@ -232,20 +232,20 @@ describe Notify do
end
end
- context 'for merge requests' do
- describe 'that are new' do
+ context "for merge requests" do
+ describe "that are new" do
subject { described_class.new_merge_request_email(merge_request.assignee_id, merge_request.id) }
- it_behaves_like 'an assignee email'
- it_behaves_like 'an email starting a new thread with reply-by-email enabled' do
+ it_behaves_like "an assignee email"
+ it_behaves_like "an email starting a new thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request)
is_expected.to have_body_text(project_merge_request_path(project, merge_request))
@@ -254,53 +254,53 @@ describe Notify do
end
end
- it 'contains the description' do
+ it "contains the description" do
is_expected.to have_body_text merge_request.description
end
- context 'when sent with a reason' do
+ context "when sent with a reason" do
subject { described_class.new_merge_request_email(merge_request.assignee_id, merge_request.id, NotificationReason::ASSIGNED) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'includes the reason in a header' do
- is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ it "includes the reason in a header" do
+ is_expected.to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
end
- context 'when enabled email_author_in_body' do
+ context "when enabled email_author_in_body" do
before do
stub_application_setting(email_author_in_body: true)
end
- it 'contains a link to note author' do
+ it "contains a link to note author" do
is_expected.to have_body_text merge_request.author_name
- is_expected.to have_body_text 'created a merge request:'
+ is_expected.to have_body_text "created a merge request:"
end
end
end
- describe 'that are reassigned' do
- let(:previous_assignee) { create(:user, name: 'Previous Assignee') }
+ describe "that are reassigned" do
+ let(:previous_assignee) { create(:user, name: "Previous Assignee") }
subject { described_class.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id, current_user.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
it_behaves_like "an unsubscribeable thread"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text(previous_assignee.name)
@@ -309,17 +309,17 @@ describe Notify do
end
end
- context 'when sent with a reason' do
+ context "when sent with a reason" do
subject { described_class.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id, current_user.id, NotificationReason::ASSIGNED) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'includes the reason in a header' do
- is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ it "includes the reason in a header" do
+ is_expected.to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
- it 'includes the reason in the footer' do
+ it "includes the reason in the footer" do
text = EmailsHelper.instance_method(:notification_reason_text).bind(self).call(NotificationReason::ASSIGNED)
is_expected.to have_body_text(text)
@@ -334,64 +334,64 @@ describe Notify do
end
end
- describe 'that are new with a description' do
+ describe "that are new with a description" do
subject { described_class.new_merge_request_email(merge_request.assignee_id, merge_request.id) }
- it_behaves_like 'it should show Gmail Actions View Merge request link'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
it_behaves_like "an unsubscribeable thread"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains the description' do
+ it "contains the description" do
is_expected.to have_body_text(merge_request.description)
end
end
- describe 'that have been relabeled' do
+ describe "that have been relabeled" do
subject { described_class.relabeled_merge_request_email(recipient.id, merge_request.id, %w[foo bar baz], current_user.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with a labels subscriptions link in its footer'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with a labels subscriptions link in its footer"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
is_expected.to have_referable_subject(merge_request, reply: true)
- is_expected.to have_body_text('foo, bar, and baz')
+ is_expected.to have_body_text("foo, bar, and baz")
is_expected.to have_body_text(project_merge_request_path(project, merge_request))
end
end
- describe 'status changed' do
- let(:status) { 'reopened' }
+ describe "status changed" do
+ let(:status) { "reopened" }
subject { described_class.merge_request_status_email(recipient.id, merge_request.id, status, current_user.id) }
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(current_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text(status)
@@ -401,94 +401,94 @@ describe Notify do
end
end
- describe 'that are merged' do
+ describe "that are merged" do
let(:merge_author) { create(:user) }
subject { described_class.merged_merge_request_email(recipient.id, merge_request.id, merge_author.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the merge author' do
+ it "is sent as the merge author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(merge_author.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
- is_expected.to have_body_text('merged')
+ is_expected.to have_body_text("merged")
is_expected.to have_body_text(project_merge_request_path(project, merge_request))
end
end
end
- describe 'that are unmergeable' do
+ describe "that are unmergeable" do
set(:merge_request) do
create(:merge_request, :conflict,
- source_project: project,
- target_project: project,
- author: current_user,
- assignee: assignee,
- description: 'Awesome description')
+ source_project: project,
+ target_project: project,
+ author: current_user,
+ assignee: assignee,
+ description: "Awesome description")
end
subject { described_class.merge_request_unmergeable_email(recipient.id, merge_request.id) }
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the merge request author' do
+ it "is sent as the merge request author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(merge_request.author.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text(project_merge_request_path(project, merge_request))
- is_expected.to have_body_text('due to conflict.')
+ is_expected.to have_body_text("due to conflict.")
end
end
end
- shared_examples 'a push to an existing merge request' do
+ shared_examples "a push to an existing merge request" do
let(:push_user) { create(:user) }
subject do
described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits, existing_commits: existing_commits)
end
- it_behaves_like 'a multiple recipients email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a multiple recipients email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the push user' do
+ it "is sent as the push user" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(push_user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text("#{push_user.name} pushed new commits")
@@ -497,102 +497,102 @@ describe Notify do
end
end
- describe 'that have new commits' do
+ describe "that have new commits" do
let(:existing_commits) { [] }
- it_behaves_like 'a push to an existing merge request'
+ it_behaves_like "a push to an existing merge request"
end
- describe 'that have new commits on top of an existing one' do
+ describe "that have new commits on top of an existing one" do
let(:existing_commits) { [merge_request.commits.first] }
- it_behaves_like 'a push to an existing merge request'
+ it_behaves_like "a push to an existing merge request"
end
end
- context 'for issue notes' do
+ context "for issue notes" do
let(:host) { Gitlab.config.gitlab.host }
- context 'in discussion' do
+ context "in discussion" do
set(:first_note) { create(:discussion_note_on_issue) }
set(:second_note) { create(:discussion_note_on_issue, in_reply_to: first_note) }
set(:third_note) { create(:discussion_note_on_issue, in_reply_to: second_note) }
subject { described_class.note_issue_email(recipient.id, third_note.id) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has In-Reply-To header pointing to previous note in discussion' do
- expect(subject.header['In-Reply-To'].message_ids).to eq(["note_#{second_note.id}@#{host}"])
+ it "has In-Reply-To header pointing to previous note in discussion" do
+ expect(subject.header["In-Reply-To"].message_ids).to eq(["note_#{second_note.id}@#{host}"])
end
- it 'has References header including the notes and issue of the discussion' do
- expect(subject.header['References'].message_ids).to include("issue_#{first_note.noteable.id}@#{host}",
- "note_#{first_note.id}@#{host}",
- "note_#{second_note.id}@#{host}")
+ it "has References header including the notes and issue of the discussion" do
+ expect(subject.header["References"].message_ids).to include("issue_#{first_note.noteable.id}@#{host}",
+ "note_#{first_note.id}@#{host}",
+ "note_#{second_note.id}@#{host}")
end
- it 'has X-GitLab-Discussion-ID header' do
- expect(subject.header['X-GitLab-Discussion-ID'].value).to eq(third_note.discussion.id)
+ it "has X-GitLab-Discussion-ID header" do
+ expect(subject.header["X-GitLab-Discussion-ID"].value).to eq(third_note.discussion.id)
end
end
- context 'individual issue comments' do
+ context "individual issue comments" do
set(:note) { create(:note_on_issue) }
subject { described_class.note_issue_email(recipient.id, note.id) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has In-Reply-To header pointing to the issue' do
- expect(subject.header['In-Reply-To'].message_ids).to eq(["issue_#{note.noteable.id}@#{host}"])
+ it "has In-Reply-To header pointing to the issue" do
+ expect(subject.header["In-Reply-To"].message_ids).to eq(["issue_#{note.noteable.id}@#{host}"])
end
- it 'has References header including the notes and issue of the discussion' do
- expect(subject.header['References'].message_ids).to include("issue_#{note.noteable.id}@#{host}")
+ it "has References header including the notes and issue of the discussion" do
+ expect(subject.header["References"].message_ids).to include("issue_#{note.noteable.id}@#{host}")
end
end
end
- context 'for snippet notes' do
+ context "for snippet notes" do
let(:project_snippet) { create(:project_snippet, project: project) }
let(:project_snippet_note) { create(:note_on_project_snippet, project: project, noteable: project_snippet) }
subject { described_class.note_project_snippet_email(project_snippet_note.author_id, project_snippet_note.id) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { project_snippet }
end
- it_behaves_like 'a user cannot unsubscribe through footer link'
+ it_behaves_like "a user cannot unsubscribe through footer link"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
is_expected.to have_referable_subject(project_snippet, reply: true)
is_expected.to have_body_text project_snippet_note.note
end
end
- describe 'project was moved' do
+ describe "project was moved" do
subject { described_class.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
is_expected.to have_subject("#{project.name} | Project was moved")
is_expected.to have_body_text project.full_name
is_expected.to have_body_text(project.ssh_url_to_repo)
end
end
- describe 'project access requested' do
+ describe "project access requested" do
let(:project) do
create(:project, :public, :access_requestable) do |project|
project.add_maintainer(project.owner)
@@ -603,15 +603,15 @@ describe Notify do
project.request_access(user)
project.requesters.find_by(user_id: user.id)
end
- subject { described_class.member_access_requested_email('project', project_member.id, recipient.notification_email) }
+ subject { described_class.member_access_requested_email("project", project_member.id, recipient.notification_email) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
to_emails = subject.header[:to].addrs.map(&:address)
expect(to_emails).to eq([recipient.notification_email])
@@ -622,40 +622,40 @@ describe Notify do
end
end
- describe 'project access denied' do
+ describe "project access denied" do
let(:project) { create(:project, :public, :access_requestable) }
let(:project_member) do
project.request_access(user)
project.requesters.find_by(user_id: user.id)
end
- subject { described_class.member_access_denied_email('project', project.id, user.id) }
+ subject { described_class.member_access_denied_email("project", project.id, user.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Access to the #{project.full_name} project was denied"
is_expected.to have_body_text project.full_name
is_expected.to have_body_text project.web_url
end
end
- describe 'project access changed' do
+ describe "project access changed" do
let(:owner) { create(:user, name: "Chang O'Keefe") }
let(:project) { create(:project, :public, :access_requestable, namespace: owner.namespace) }
let(:project_member) { create(:project_member, project: project, user: user) }
- subject { described_class.member_access_granted_email('project', project_member.id) }
+ subject { described_class.member_access_granted_email("project", project_member.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Access to the #{project.full_name} project was granted"
is_expected.to have_body_text project.full_name
is_expected.to have_body_text project.web_url
@@ -668,26 +668,26 @@ describe Notify do
:project_member,
:developer,
project: project,
- invite_token: '1234',
- invite_email: 'toto@example.com',
+ invite_token: "1234",
+ invite_email: "toto@example.com",
user: nil,
created_by: inviter
)
end
- describe 'project invitation' do
+ describe "project invitation" do
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:project_member) { invite_to_project(project, inviter: maintainer) }
- subject { described_class.member_invited_email('project', project_member.id, project_member.invite_token) }
+ subject { described_class.member_invited_email("project", project_member.id, project_member.invite_token) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Invitation to join the #{project.full_name} project"
is_expected.to have_body_text project.full_name
is_expected.to have_body_text project.full_name
@@ -696,8 +696,8 @@ describe Notify do
end
end
- describe 'project invitation accepted' do
- let(:invited_user) { create(:user, name: 'invited user') }
+ describe "project invitation accepted" do
+ let(:invited_user) { create(:user, name: "invited user") }
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:project_member) do
invitee = invite_to_project(project, inviter: maintainer)
@@ -705,16 +705,16 @@ describe Notify do
invitee
end
- subject { described_class.member_invite_accepted_email('project', project_member.id) }
+ subject { described_class.member_invite_accepted_email("project", project_member.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
- is_expected.to have_subject 'Invitation accepted'
+ it "contains all the useful information" do
+ is_expected.to have_subject "Invitation accepted"
is_expected.to have_body_text project.full_name
is_expected.to have_body_text project.web_url
is_expected.to have_body_text project_member.invite_email
@@ -722,7 +722,7 @@ describe Notify do
end
end
- describe 'project invitation declined' do
+ describe "project invitation declined" do
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:project_member) do
invitee = invite_to_project(project, inviter: maintainer)
@@ -730,31 +730,31 @@ describe Notify do
invitee
end
- subject { described_class.member_invite_declined_email('project', project.id, project_member.invite_email, maintainer.id) }
+ subject { described_class.member_invite_declined_email("project", project.id, project_member.invite_email, maintainer.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
- is_expected.to have_subject 'Invitation declined'
+ it "contains all the useful information" do
+ is_expected.to have_subject "Invitation declined"
is_expected.to have_body_text project.full_name
is_expected.to have_body_text project.web_url
is_expected.to have_body_text project_member.invite_email
end
end
- context 'items that are noteable, the email for a note' do
- let(:note_author) { create(:user, name: 'author_name') }
+ context "items that are noteable, the email for a note" do
+ let(:note_author) { create(:user, name: "author_name") }
let(:note) { create(:note, project: project, author: note_author) }
before do
allow(Note).to receive(:find).with(note.id).and_return(note)
end
- describe 'on a commit' do
+ describe "on a commit" do
let(:commit) { project.commit }
before do
@@ -763,16 +763,16 @@ describe Notify do
subject { described_class.note_commit_email(recipient.id, note.id) }
- it_behaves_like 'a note email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a note email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { commit }
end
- it_behaves_like 'it should show Gmail Actions View Commit link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Commit link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_subject("Re: #{project.name} | #{commit.title} (#{commit.short_id})")
is_expected.to have_body_text(commit.short_id)
@@ -780,7 +780,7 @@ describe Notify do
end
end
- describe 'on a merge request' do
+ describe "on a merge request" do
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
before do
@@ -789,16 +789,16 @@ describe Notify do
subject { described_class.note_merge_request_email(recipient.id, note.id) }
- it_behaves_like 'a note email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a note email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(merge_request, reply: true)
is_expected.to have_body_text note_on_merge_request_path
@@ -806,7 +806,7 @@ describe Notify do
end
end
- describe 'on an issue' do
+ describe "on an issue" do
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
before do
@@ -815,16 +815,16 @@ describe Notify do
subject { described_class.note_issue_email(recipient.id, note.id) }
- it_behaves_like 'a note email'
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a note email"
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_referable_subject(issue, reply: true)
is_expected.to have_body_text(note_on_issue_path)
@@ -833,17 +833,17 @@ describe Notify do
end
end
- context 'items that are noteable, the email for a discussion note' do
- let(:note_author) { create(:user, name: 'author_name') }
+ context "items that are noteable, the email for a discussion note" do
+ let(:note_author) { create(:user, name: "author_name") }
before do
allow(Note).to receive(:find).with(note.id).and_return(note)
end
- shared_examples 'a discussion note email' do |model|
- it_behaves_like 'it should have Gmail Actions links'
+ shared_examples "a discussion note email" do |model|
+ it_behaves_like "it should have Gmail Actions links"
- it 'is sent to the given recipient as the author' do
+ it "is sent to the given recipient as the author" do
sender = subject.header[:from].addrs[0]
aggregate_failures do
@@ -853,24 +853,24 @@ describe Notify do
end
end
- it 'contains the message from the note' do
+ it "contains the message from the note" do
is_expected.to have_body_text note.note
end
- it 'contains an introduction' do
- is_expected.to have_body_text 'started a new discussion'
+ it "contains an introduction" do
+ is_expected.to have_body_text "started a new discussion"
end
- context 'when a comment on an existing discussion' do
+ context "when a comment on an existing discussion" do
let!(:second_note) { create(model, author: note_author, noteable: nil, in_reply_to: note) }
- it 'contains an introduction' do
- is_expected.to have_body_text 'commented on a'
+ it "contains an introduction" do
+ is_expected.to have_body_text "commented on a"
end
end
end
- describe 'on a commit' do
+ describe "on a commit" do
let(:commit) { project.commit }
let(:note) { create(:discussion_note_on_commit, commit_id: commit.id, project: project, author: note_author) }
@@ -880,25 +880,25 @@ describe Notify do
subject { described_class.note_commit_email(recipient.id, note.id) }
- it_behaves_like 'a discussion note email', :discussion_note_on_commit
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a discussion note email", :discussion_note_on_commit
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { commit }
end
- it_behaves_like 'it should show Gmail Actions View Commit link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Commit link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_subject "Re: #{project.name} | #{commit.title} (#{commit.short_id})"
end
- it 'contains a link to the commit' do
+ it "contains a link to the commit" do
is_expected.to have_body_text commit.short_id
end
end
- describe 'on a merge request' do
+ describe "on a merge request" do
let(:note) { create(:discussion_note_on_merge_request, noteable: merge_request, project: project, author: note_author) }
let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") }
@@ -908,25 +908,25 @@ describe Notify do
subject { described_class.note_merge_request_email(recipient.id, note.id) }
- it_behaves_like 'a discussion note email', :discussion_note_on_merge_request
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a discussion note email", :discussion_note_on_merge_request
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { merge_request }
end
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_referable_subject(merge_request, reply: true)
end
- it 'contains a link to the merge request note' do
+ it "contains a link to the merge request note" do
is_expected.to have_body_text note_on_merge_request_path
end
end
- describe 'on an issue' do
+ describe "on an issue" do
let(:note) { create(:discussion_note_on_issue, noteable: issue, project: project, author: note_author) }
let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") }
@@ -936,56 +936,56 @@ describe Notify do
subject { described_class.note_issue_email(recipient.id, note.id) }
- it_behaves_like 'a discussion note email', :discussion_note_on_issue
- it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do
+ it_behaves_like "a discussion note email", :discussion_note_on_issue
+ it_behaves_like "an answer to an existing thread with reply-by-email enabled" do
let(:model) { issue }
end
- it_behaves_like 'it should show Gmail Actions View Issue link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Issue link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_referable_subject(issue, reply: true)
end
- it 'contains a link to the issue note' do
+ it "contains a link to the issue note" do
is_expected.to have_body_text note_on_issue_path
end
end
end
- context 'items that are noteable, the email for a diff discussion note' do
- let(:note_author) { create(:user, name: 'author_name') }
+ context "items that are noteable, the email for a diff discussion note" do
+ let(:note_author) { create(:user, name: "author_name") }
before do
allow(Note).to receive(:find).with(note.id).and_return(note)
end
- shared_examples 'an email for a note on a diff discussion' do |model|
+ shared_examples "an email for a note on a diff discussion" do |model|
let(:note) { create(model, author: note_author) }
- context 'when note is not on text' do
+ context "when note is not on text" do
before do
allow_any_instance_of(DiffDiscussion).to receive(:on_text?).and_return(false)
end
- it 'does not include diffs with character-level highlighting' do
+ it "does not include diffs with character-level highlighting" do
is_expected.not_to have_body_text '<span class="p">}</span></span>'
end
end
- it 'includes diffs with character-level highlighting' do
+ it "includes diffs with character-level highlighting" do
is_expected.to have_body_text '<span class="p">}</span></span>'
end
- it 'contains a link to the diff file' do
+ it "contains a link to the diff file" do
is_expected.to have_body_text note.diff_file.file_path
end
- it_behaves_like 'it should have Gmail Actions links'
+ it_behaves_like "it should have Gmail Actions links"
- it 'is sent to the given recipient as the author' do
+ it "is sent to the given recipient as the author" do
sender = subject.header[:from].addrs[0]
aggregate_failures do
@@ -995,68 +995,68 @@ describe Notify do
end
end
- it 'contains the message from the note' do
+ it "contains the message from the note" do
is_expected.to have_body_text note.note
end
- it 'contains an introduction' do
- is_expected.to have_body_text 'started a new discussion on'
+ it "contains an introduction" do
+ is_expected.to have_body_text "started a new discussion on"
end
- context 'when a comment on an existing discussion' do
+ context "when a comment on an existing discussion" do
let!(:second_note) { create(model, author: note_author, noteable: nil, in_reply_to: note) }
- it 'contains an introduction' do
- is_expected.to have_body_text 'commented on a discussion on'
+ it "contains an introduction" do
+ is_expected.to have_body_text "commented on a discussion on"
end
end
end
- describe 'on a commit' do
+ describe "on a commit" do
let(:commit) { project.commit }
let(:note) { create(:diff_note_on_commit) }
subject { described_class.note_commit_email(recipient.id, note.id) }
- it_behaves_like 'an email for a note on a diff discussion', :diff_note_on_commit
- it_behaves_like 'it should show Gmail Actions View Commit link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "an email for a note on a diff discussion", :diff_note_on_commit
+ it_behaves_like "it should show Gmail Actions View Commit link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
end
- describe 'on a merge request' do
+ describe "on a merge request" do
let(:note) { create(:diff_note_on_merge_request) }
subject { described_class.note_merge_request_email(recipient.id, note.id) }
- it_behaves_like 'an email for a note on a diff discussion', :diff_note_on_merge_request
- it_behaves_like 'it should show Gmail Actions View Merge request link'
- it_behaves_like 'an unsubscribeable thread'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "an email for a note on a diff discussion", :diff_note_on_merge_request
+ it_behaves_like "it should show Gmail Actions View Merge request link"
+ it_behaves_like "an unsubscribeable thread"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
end
end
end
- context 'for a group' do
+ context "for a group" do
set(:group) { create(:group) }
- describe 'group access requested' do
+ describe "group access requested" do
let(:group) { create(:group, :public, :access_requestable) }
let(:group_member) do
group.request_access(user)
group.requesters.find_by(user_id: user.id)
end
- subject { described_class.member_access_requested_email('group', group_member.id, recipient.notification_email) }
+ subject { described_class.member_access_requested_email("group", group_member.id, recipient.notification_email) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
to_emails = subject.header[:to].addrs.map(&:address)
expect(to_emails).to eq([recipient.notification_email])
@@ -1067,38 +1067,38 @@ describe Notify do
end
end
- describe 'group access denied' do
+ describe "group access denied" do
let(:group_member) do
group.request_access(user)
group.requesters.find_by(user_id: user.id)
end
- subject { described_class.member_access_denied_email('group', group.id, user.id) }
+ subject { described_class.member_access_denied_email("group", group.id, user.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Access to the #{group.name} group was denied"
is_expected.to have_body_text group.name
is_expected.to have_body_text group.web_url
end
end
- describe 'group access changed' do
+ describe "group access changed" do
let(:group_member) { create(:group_member, group: group, user: user) }
- subject { described_class.member_access_granted_email('group', group_member.id) }
+ subject { described_class.member_access_granted_email("group", group_member.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Access to the #{group.name} group was granted"
is_expected.to have_body_text group.name
is_expected.to have_body_text group.web_url
@@ -1111,26 +1111,26 @@ describe Notify do
:group_member,
:developer,
group: group,
- invite_token: '1234',
- invite_email: 'toto@example.com',
+ invite_token: "1234",
+ invite_email: "toto@example.com",
user: nil,
created_by: inviter
)
end
- describe 'group invitation' do
+ describe "group invitation" do
let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
let(:group_member) { invite_to_group(group, inviter: owner) }
- subject { described_class.member_invited_email('group', group_member.id, group_member.invite_token) }
+ subject { described_class.member_invited_email("group", group_member.id, group_member.invite_token) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
+ it "contains all the useful information" do
is_expected.to have_subject "Invitation to join the #{group.name} group"
is_expected.to have_body_text group.name
is_expected.to have_body_text group.web_url
@@ -1139,8 +1139,8 @@ describe Notify do
end
end
- describe 'group invitation accepted' do
- let(:invited_user) { create(:user, name: 'invited user') }
+ describe "group invitation accepted" do
+ let(:invited_user) { create(:user, name: "invited user") }
let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
let(:group_member) do
invitee = invite_to_group(group, inviter: owner)
@@ -1148,16 +1148,16 @@ describe Notify do
invitee
end
- subject { described_class.member_invite_accepted_email('group', group_member.id) }
+ subject { described_class.member_invite_accepted_email("group", group_member.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
- is_expected.to have_subject 'Invitation accepted'
+ it "contains all the useful information" do
+ is_expected.to have_subject "Invitation accepted"
is_expected.to have_body_text group.name
is_expected.to have_body_text group.web_url
is_expected.to have_body_text group_member.invite_email
@@ -1165,7 +1165,7 @@ describe Notify do
end
end
- describe 'group invitation declined' do
+ describe "group invitation declined" do
let(:owner) { create(:user).tap { |u| group.add_user(u, Gitlab::Access::OWNER) } }
let(:group_member) do
invitee = invite_to_group(group, inviter: owner)
@@ -1173,16 +1173,16 @@ describe Notify do
invitee
end
- subject { described_class.member_invite_declined_email('group', group.id, group_member.invite_email, owner.id) }
+ subject { described_class.member_invite_declined_email("group", group.id, group_member.invite_email, owner.id) }
- it_behaves_like 'an email sent from GitLab'
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "an email sent from GitLab"
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'contains all the useful information' do
- is_expected.to have_subject 'Invitation declined'
+ it "contains all the useful information" do
+ is_expected.to have_subject "Invitation declined"
is_expected.to have_body_text group.name
is_expected.to have_body_text group.web_url
is_expected.to have_body_text group_member.invite_email
@@ -1190,12 +1190,12 @@ describe Notify do
end
end
- describe 'confirmation if email changed' do
+ describe "confirmation if email changed" do
let(:example_site_path) { root_path }
- let(:user) { create(:user, email: 'old-email@mail.com') }
+ let(:user) { create(:user, email: "old-email@mail.com") }
before do
- stub_config_setting(email_subject_suffix: 'A Nice Suffix')
+ stub_config_setting(email_subject_suffix: "A Nice Suffix")
perform_enqueued_jobs do
user.email = "new-email@mail.com"
user.save
@@ -1204,41 +1204,41 @@ describe Notify do
subject { ActionMailer::Base.deliveries.last }
- it_behaves_like 'an email sent from GitLab'
+ it_behaves_like "an email sent from GitLab"
it_behaves_like "a user cannot unsubscribe through footer link"
- it 'is sent to the new user' do
- is_expected.to deliver_to 'new-email@mail.com'
+ it "is sent to the new user" do
+ is_expected.to deliver_to "new-email@mail.com"
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
- is_expected.to have_subject('Confirmation instructions | A Nice Suffix')
+ is_expected.to have_subject("Confirmation instructions | A Nice Suffix")
is_expected.to have_body_text(example_site_path)
end
end
end
- describe 'email on push for a created branch' do
+ describe "email on push for a created branch" do
let(:example_site_path) { root_path }
let(:tree_path) { project_tree_path(project, "empty-branch") }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/empty-branch', action: :create) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/heads/empty-branch", action: :create) }
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_subject("[Git][#{project.full_path}] Pushed new branch empty-branch")
is_expected.to have_body_text(tree_path)
@@ -1246,26 +1246,26 @@ describe Notify do
end
end
- describe 'email on push for a created tag' do
+ describe "email on push for a created tag" do
let(:example_site_path) { root_path }
let(:tree_path) { project_tree_path(project, "v1.0") }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/tags/v1.0', action: :create) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/tags/v1.0", action: :create) }
- it_behaves_like 'it should not have Gmail Actions links'
+ it_behaves_like "it should not have Gmail Actions links"
it_behaves_like "a user cannot unsubscribe through footer link"
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_subject("[Git][#{project.full_path}] Pushed new tag v1.0")
is_expected.to have_body_text(tree_path)
@@ -1273,53 +1273,53 @@ describe Notify do
end
end
- describe 'email on push for a deleted branch' do
+ describe "email on push for a deleted branch" do
let(:example_site_path) { root_path }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/master', action: :delete) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/heads/master", action: :delete) }
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_subject "[Git][#{project.full_path}] Deleted branch master"
end
end
- describe 'email on push for a deleted tag' do
+ describe "email on push for a deleted tag" do
let(:example_site_path) { root_path }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/tags/v1.0', action: :delete) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/tags/v1.0", action: :delete) }
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject' do
+ it "has the correct subject" do
is_expected.to have_subject "[Git][#{project.full_path}] Deleted tag v1.0"
end
end
- describe 'email on push with multiple commits' do
+ describe "email on push with multiple commits" do
let(:example_site_path) { root_path }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) }
let(:compare) { Compare.decorate(raw_compare, project) }
@@ -1328,28 +1328,28 @@ describe Notify do
let(:send_from_committer_email) { false }
let(:diff_refs) { Gitlab::Diff::DiffRefs.new(base_sha: project.merge_base_commit(sample_image_commit.id, sample_commit.id).id, head_sha: sample_commit.id) }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/master', action: :push, compare: compare, reverse_compare: false, diff_refs: diff_refs, send_from_committer_email: send_from_committer_email) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/heads/master", action: :push, compare: compare, reverse_compare: false, diff_refs: diff_refs, send_from_committer_email: send_from_committer_email) }
- it_behaves_like 'it should not have Gmail Actions links'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should not have Gmail Actions links"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_subject("[Git][#{project.full_path}][master] #{commits.length} commits: Ruby files modified")
- is_expected.to have_body_text('Change some files')
+ is_expected.to have_body_text("Change some files")
is_expected.to have_body_text('def</span> <span class="nf">archive_formats_regex')
is_expected.to have_body_text(diff_path)
- is_expected.not_to have_body_text('you are a member of')
+ is_expected.not_to have_body_text("you are a member of")
end
end
@@ -1413,7 +1413,7 @@ describe Notify do
end
end
- describe 'email on push with a single commit' do
+ describe "email on push with a single commit" do
let(:example_site_path) { root_path }
let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_commit.parent_id, sample_commit.id) }
let(:compare) { Compare.decorate(raw_compare, project) }
@@ -1421,60 +1421,60 @@ describe Notify do
let(:diff_path) { project_commit_path(project, commits.first) }
let(:diff_refs) { Gitlab::Diff::DiffRefs.new(base_sha: project.merge_base_commit(sample_image_commit.id, sample_commit.id).id, head_sha: sample_commit.id) }
- subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/master', action: :push, compare: compare, diff_refs: diff_refs) }
+ subject { described_class.repository_push_email(project.id, author_id: user.id, ref: "refs/heads/master", action: :push, compare: compare, diff_refs: diff_refs) }
- it_behaves_like 'it should show Gmail Actions View Commit link'
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'an email with X-GitLab headers containing project details'
- it_behaves_like 'an email that contains a header with author username'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "it should show Gmail Actions View Commit link"
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "an email with X-GitLab headers containing project details"
+ it_behaves_like "an email that contains a header with author username"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'is sent as the author' do
+ it "is sent as the author" do
sender = subject.header[:from].addrs[0]
expect(sender.display_name).to eq(user.name)
expect(sender.address).to eq(gitlab_sender)
end
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
aggregate_failures do
is_expected.to have_subject("[Git][#{project.full_path}][master] #{commits.first.title}")
- is_expected.to have_body_text('Change some files')
+ is_expected.to have_body_text("Change some files")
is_expected.to have_body_text('def</span> <span class="nf">archive_formats_regex')
is_expected.to have_body_text(diff_path)
end
end
end
- describe 'HTML emails setting' do
+ describe "HTML emails setting" do
let(:multipart_mail) { described_class.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
subject { multipart_mail }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- context 'when disabled' do
- it 'only sends the text template' do
+ context "when disabled" do
+ it "only sends the text template" do
stub_application_setting(html_emails_enabled: false)
Gitlab::Email::Hook::EmailTemplateInterceptor
.delivering_email(multipart_mail)
- expect(multipart_mail).to have_part_with('text/plain')
- expect(multipart_mail).not_to have_part_with('text/html')
+ expect(multipart_mail).to have_part_with("text/plain")
+ expect(multipart_mail).not_to have_part_with("text/html")
end
end
- context 'when enabled' do
- it 'sends a multipart message' do
+ context "when enabled" do
+ it "sends a multipart message" do
stub_application_setting(html_emails_enabled: true)
Gitlab::Email::Hook::EmailTemplateInterceptor
.delivering_email(multipart_mail)
- expect(multipart_mail).to have_part_with('text/plain')
- expect(multipart_mail).to have_part_with('text/html')
+ expect(multipart_mail).to have_part_with("text/plain")
+ expect(multipart_mail).to have_part_with("text/html")
end
end
@@ -1485,17 +1485,17 @@ describe Notify do
end
end
- context 'for personal snippet notes' do
+ context "for personal snippet notes" do
let(:personal_snippet) { create(:personal_snippet) }
let(:personal_snippet_note) { create(:note_on_personal_snippet, noteable: personal_snippet) }
subject { described_class.note_personal_snippet_email(personal_snippet_note.author_id, personal_snippet_note.id) }
- it_behaves_like 'a user cannot unsubscribe through footer link'
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "a user cannot unsubscribe through footer link"
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
- it 'has the correct subject and body' do
+ it "has the correct subject and body" do
is_expected.to have_referable_subject(personal_snippet, reply: true)
is_expected.to have_body_text personal_snippet_note.note
end
diff --git a/spec/mailers/repository_check_mailer_spec.rb b/spec/mailers/repository_check_mailer_spec.rb
index 384660f7221..6e67b99eac0 100644
--- a/spec/mailers/repository_check_mailer_spec.rb
+++ b/spec/mailers/repository_check_mailer_spec.rb
@@ -1,10 +1,10 @@
-require 'rails_helper'
+require "rails_helper"
describe RepositoryCheckMailer do
include EmailSpec::Matchers
- describe '.notify' do
- it 'emails all admins' do
+ describe ".notify" do
+ it "emails all admins" do
admins = create_list(:admin, 3)
mail = described_class.notify(1)
@@ -12,17 +12,17 @@ describe RepositoryCheckMailer do
expect(mail).to deliver_to admins.map(&:email)
end
- it 'mentions the number of failed checks' do
+ it "mentions the number of failed checks" do
mail = described_class.notify(3)
- expect(mail).to have_subject 'GitLab Admin | 3 projects failed their last repository check'
+ expect(mail).to have_subject "GitLab Admin | 3 projects failed their last repository check"
end
- context 'with footer and header' do
+ context "with footer and header" do
subject { described_class.notify(1) }
- it_behaves_like 'appearance header and footer enabled'
- it_behaves_like 'appearance header and footer not enabled'
+ it_behaves_like "appearance header and footer enabled"
+ it_behaves_like "appearance header and footer not enabled"
end
end
end
diff --git a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb
index 5c6f213e15b..5e7c2b7d8a4 100644
--- a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb
+++ b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180122154930_schedule_set_confidential_note_events_on_services.rb")
describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do
let(:services_table) { table(:services) }
@@ -17,7 +17,7 @@ describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do
stub_const("#{described_class}::BATCH_SIZE", 1)
end
- it 'schedules background migrations at correct time' do
+ it "schedules background migrations at correct time" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -30,7 +30,7 @@ describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do
end
end
- it 'correctly processes services' do
+ it "correctly processes services" do
perform_enqueued_jobs do
expect(services_table.where(confidential_note_events: nil).count).to eq 4
expect(services_table.where(confidential_note_events: true).count).to eq 1
diff --git a/spec/migrations/active_record/schema_spec.rb b/spec/migrations/active_record/schema_spec.rb
index 9d35b3cd642..bb971a70381 100644
--- a/spec/migrations/active_record/schema_spec.rb
+++ b/spec/migrations/active_record/schema_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Check consistency of db/schema.rb version, migrations' timestamps, and the latest migration timestamp
# stored in the database's schema_migrations table.
@@ -7,21 +7,21 @@ describe ActiveRecord::Schema do
let(:latest_migration_timestamp) do
migrations_paths = %w[db ee/db]
.product(%w[migrate post_migrate])
- .map { |path| Rails.root.join(*path, '*') }
+ .map { |path| Rails.root.join(*path, "*") }
migrations = Dir[*migrations_paths]
- migrations.map { |migration| File.basename(migration).split('_').first.to_i }.max
+ migrations.map { |migration| File.basename(migration).split("_").first.to_i }.max
end
- it '> schema version equals last migration timestamp' do
- defined_schema_version = File.open(Rails.root.join('db', 'schema.rb')) do |file|
+ it "> schema version equals last migration timestamp" do
+ defined_schema_version = File.open(Rails.root.join("db", "schema.rb")) { |file|
file.find { |line| line =~ /ActiveRecord::Schema.define/ }
- end.match(/(\d+)/)[0].to_i
+ }.match(/(\d+)/)[0].to_i
expect(defined_schema_version).to eq(latest_migration_timestamp)
end
- it '> schema version should equal the latest migration timestamp stored in schema_migrations table' do
+ it "> schema version should equal the latest migration timestamp stored in schema_migrations table" do
expect(latest_migration_timestamp).to eq(ActiveRecord::Migrator.current_version.to_i)
end
end
diff --git a/spec/migrations/add_foreign_key_from_notification_settings_to_users_spec.rb b/spec/migrations/add_foreign_key_from_notification_settings_to_users_spec.rb
index 656d4f75e3b..9701b3aa32d 100644
--- a/spec/migrations/add_foreign_key_from_notification_settings_to_users_spec.rb
+++ b/spec/migrations/add_foreign_key_from_notification_settings_to_users_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180710162338_add_foreign_key_from_notification_settings_to_users.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180710162338_add_foreign_key_from_notification_settings_to_users.rb")
describe AddForeignKeyFromNotificationSettingsToUsers, :migration do
let(:notification_settings) { table(:notification_settings) }
@@ -9,15 +9,15 @@ describe AddForeignKeyFromNotificationSettingsToUsers, :migration do
let(:projects) { table(:projects) }
before do
- users.create!(email: 'email@email.com', name: 'foo', username: 'foo', projects_limit: 0)
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce', namespace_id: 1)
+ users.create!(email: "email@email.com", name: "foo", username: "foo", projects_limit: 0)
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ce", namespace_id: 1)
end
- describe 'removal of orphans without user' do
+ describe "removal of orphans without user" do
let!(:notification_setting_without_user) { create_notification_settings!(user_id: 123) }
let!(:notification_setting_with_user) { create_notification_settings!(user_id: users.last.id) }
- it 'removes orphaned notification_settings without user' do
+ it "removes orphaned notification_settings without user" do
expect { migrate! }.to change { notification_settings.count }.by(-1)
end
@@ -29,8 +29,9 @@ describe AddForeignKeyFromNotificationSettingsToUsers, :migration do
def create_notification_settings!(**opts)
notification_settings.create!(
source_id: projects.last.id,
- source_type: 'Project',
+ source_type: "Project",
user_id: users.last.id,
- **opts)
+ **opts
+ )
end
end
diff --git a/spec/migrations/add_foreign_key_to_merge_requests_spec.rb b/spec/migrations/add_foreign_key_to_merge_requests_spec.rb
index d9ad9a585f0..0eba4025503 100644
--- a/spec/migrations/add_foreign_key_to_merge_requests_spec.rb
+++ b/spec/migrations/add_foreign_key_to_merge_requests_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170713104829_add_foreign_key_to_merge_requests.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170713104829_add_foreign_key_to_merge_requests.rb")
describe AddForeignKeyToMergeRequests, :migration do
let(:projects) { table(:projects) }
@@ -7,10 +7,10 @@ describe AddForeignKeyToMergeRequests, :migration do
let(:pipelines) { table(:ci_pipelines) }
before do
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce')
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ce")
pipelines.create!(project_id: projects.first.id,
- ref: 'some-branch',
- sha: 'abc12345')
+ ref: "some-branch",
+ sha: "abc12345")
# merge request without a pipeline
create_merge_request(head_pipeline_id: nil)
@@ -22,7 +22,7 @@ describe AddForeignKeyToMergeRequests, :migration do
create_merge_request(head_pipeline_id: pipelines.first.id)
end
- it 'correctly adds a foreign key to head_pipeline_id' do
+ it "correctly adds a foreign key to head_pipeline_id" do
migrate!
expect(merge_requests.first.head_pipeline_id).to be_nil
@@ -33,7 +33,7 @@ describe AddForeignKeyToMergeRequests, :migration do
def create_merge_request(**opts)
merge_requests.create!(source_project_id: projects.first.id,
target_project_id: projects.first.id,
- source_branch: 'some-branch',
- target_branch: 'master', **opts)
+ source_branch: "some-branch",
+ target_branch: "master", **opts)
end
end
diff --git a/spec/migrations/add_foreign_keys_to_todos_spec.rb b/spec/migrations/add_foreign_keys_to_todos_spec.rb
index efd87173b9c..3247aeff3f7 100644
--- a/spec/migrations/add_foreign_keys_to_todos_spec.rb
+++ b/spec/migrations/add_foreign_keys_to_todos_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_todos.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180201110056_add_foreign_keys_to_todos.rb")
describe AddForeignKeysToTodos, :migration do
let(:todos) { table(:todos) }
let(:users) { table(:users) }
let(:projects) { table(:projects) }
- let(:project) { projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce', namespace_id: 1) }
- let(:user) { users.create!(email: 'email@email.com', name: 'foo', username: 'foo', projects_limit: 0) }
+ let(:project) { projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ce", namespace_id: 1) }
+ let(:user) { users.create!(email: "email@email.com", name: "foo", username: "foo", projects_limit: 0) }
- context 'add foreign key on user_id' do
+ context "add foreign key on user_id" do
let!(:todo_with_user) { create_todo(user_id: user.id) }
let!(:todo_without_user) { create_todo(user_id: 4711) }
- it 'removes orphaned todos without corresponding user' do
+ it "removes orphaned todos without corresponding user" do
expect { migrate! }.to change { Todo.count }.from(2).to(1)
end
- it 'does not remove entries with valid user_id' do
+ it "does not remove entries with valid user_id" do
expect { migrate! }.not_to change { todo_with_user.reload }
end
end
- context 'add foreign key on author_id' do
+ context "add foreign key on author_id" do
let!(:todo_with_author) { create_todo(author_id: user.id) }
let!(:todo_with_invalid_author) { create_todo(author_id: 4711) }
- it 'removes orphaned todos by author_id' do
+ it "removes orphaned todos by author_id" do
expect { migrate! }.to change { Todo.count }.from(2).to(1)
end
- it 'does not touch author_id for valid entries' do
+ it "does not touch author_id for valid entries" do
expect { migrate! }.not_to change { todo_with_author.reload }
end
end
- context 'add foreign key on note_id' do
+ context "add foreign key on note_id" do
let(:note) { create(:note) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let!(:todo_with_note) { create_todo(note_id: note.id) }
let!(:todo_with_invalid_note) { create_todo(note_id: 4711) }
let!(:todo_without_note) { create_todo(note_id: nil) }
- it 'deletes todo if note_id is set but does not exist in notes table' do
+ it "deletes todo if note_id is set but does not exist in notes table" do
expect { migrate! }.to change { Todo.count }.from(3).to(2)
end
- it 'does not touch entry if note_id is nil' do
+ it "does not touch entry if note_id is nil" do
expect { migrate! }.not_to change { todo_without_note.reload }
end
- it 'does not touch note_id for valid entries' do
+ it "does not touch note_id for valid entries" do
expect { migrate! }.not_to change { todo_with_note.reload }
end
end
@@ -59,9 +59,9 @@ describe AddForeignKeysToTodos, :migration do
project_id: project.id,
user_id: user.id,
author_id: user.id,
- target_type: '',
+ target_type: "",
action: 0,
- state: '', **opts
+ state: "", **opts
)
end
end
diff --git a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb
index d8dd7a2fb83..898368db854 100644
--- a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb
+++ b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170508170547_add_head_pipeline_for_each_merge_request.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170508170547_add_head_pipeline_for_each_merge_request.rb")
describe AddHeadPipelineForEachMergeRequest, :delete do
include ProjectForksHelper
diff --git a/spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb b/spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb
index 6fd3cb1f44e..c948acc079a 100644
--- a/spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb
+++ b/spec/migrations/add_not_null_constraint_to_project_mirror_data_foreign_key_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180508100222_add_not_null_constraint_to_project_mirror_data_foreign_key.rb")
describe AddNotNullConstraintToProjectMirrorDataForeignKey, :migration do
let(:namespaces) { table(:namespaces) }
@@ -10,9 +10,9 @@ describe AddNotNullConstraintToProjectMirrorDataForeignKey, :migration do
import_state.create!(id: 1, project_id: nil, status: :started)
end
- it 'removes every import state without an associated project_id' do
- expect do
+ it "removes every import state without an associated project_id" do
+ expect {
subject.up
- end.to change { import_state.count }.from(1).to(0)
+ }.to change { import_state.count }.from(1).to(0)
end
end
diff --git a/spec/migrations/add_pages_access_level_to_project_feature_spec.rb b/spec/migrations/add_pages_access_level_to_project_feature_spec.rb
index 3946602c5be..d21793a57cb 100644
--- a/spec/migrations/add_pages_access_level_to_project_feature_spec.rb
+++ b/spec/migrations/add_pages_access_level_to_project_feature_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180423204600_add_pages_access_level_to_project_feature.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180423204600_add_pages_access_level_to_project_feature.rb")
describe AddPagesAccessLevelToProjectFeature, :migration do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:features) { table(:project_features) }
- let!(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab') }
- let!(:first_project) { projects.create(name: 'gitlab1', path: 'gitlab1', namespace_id: namespace.id) }
+ let!(:namespace) { namespaces.create(name: "gitlab", path: "gitlab") }
+ let!(:first_project) { projects.create(name: "gitlab1", path: "gitlab1", namespace_id: namespace.id) }
let!(:first_project_features) { features.create(project_id: first_project.id) }
- let!(:second_project) { projects.create(name: 'gitlab2', path: 'gitlab2', namespace_id: namespace.id) }
+ let!(:second_project) { projects.create(name: "gitlab2", path: "gitlab2", namespace_id: namespace.id) }
let!(:second_project_features) { features.create(project_id: second_project.id) }
- it 'correctly migrate pages for old projects to be public' do
+ it "correctly migrate pages for old projects to be public" do
migrate!
# For old projects pages should be public
@@ -19,11 +19,11 @@ describe AddPagesAccessLevelToProjectFeature, :migration do
expect(second_project_features.reload.pages_access_level).to eq ProjectFeature::PUBLIC
end
- it 'after migration pages are enabled as default' do
+ it "after migration pages are enabled as default" do
migrate!
# For new project default is enabled
- third_project = projects.create(name: 'gitlab3', path: 'gitlab3', namespace_id: namespace.id)
+ third_project = projects.create(name: "gitlab3", path: "gitlab3", namespace_id: namespace.id)
third_project_features = features.create(project_id: third_project.id)
expect(third_project_features.reload.pages_access_level).to eq ProjectFeature::ENABLED
end
diff --git a/spec/migrations/add_pipeline_build_foreign_key_spec.rb b/spec/migrations/add_pipeline_build_foreign_key_spec.rb
index e9413f52f19..a9825253c2a 100644
--- a/spec/migrations/add_pipeline_build_foreign_key_spec.rb
+++ b/spec/migrations/add_pipeline_build_foreign_key_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180420010016_add_pipeline_build_foreign_key.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180420010016_add_pipeline_build_foreign_key.rb")
describe AddPipelineBuildForeignKey, :migration do
let(:namespaces) { table(:namespaces) }
@@ -8,9 +8,9 @@ describe AddPipelineBuildForeignKey, :migration do
let(:builds) { table(:ci_builds) }
before do
- namespaces.create(id: 10, name: 'gitlab-org', path: 'gitlab-org')
- projects.create!(id: 11, namespace_id: 10, name: 'gitlab', path: 'gitlab')
- pipelines.create!(id: 12, project_id: 11, ref: 'master', sha: 'adf43c3a')
+ namespaces.create(id: 10, name: "gitlab-org", path: "gitlab-org")
+ projects.create!(id: 11, namespace_id: 10, name: "gitlab", path: "gitlab")
+ pipelines.create!(id: 12, project_id: 11, ref: "master", sha: "adf43c3a")
builds.create!(id: 101, commit_id: 12, project_id: 11)
builds.create!(id: 102, commit_id: 222, project_id: 11)
@@ -20,7 +20,7 @@ describe AddPipelineBuildForeignKey, :migration do
builds.create!(id: 107, commit_id: 12, project_id: nil)
end
- it 'adds foreign key after removing orphans' do
+ it "adds foreign key after removing orphans" do
expect(builds.all.count).to eq 6
expect(foreign_key_exists?(:ci_builds, :ci_pipelines, column: :commit_id)).to be_falsey
diff --git a/spec/migrations/add_unique_constraint_to_project_features_project_id_spec.rb b/spec/migrations/add_unique_constraint_to_project_features_project_id_spec.rb
index bf299b70a29..46620bbb107 100644
--- a/spec/migrations/add_unique_constraint_to_project_features_project_id_spec.rb
+++ b/spec/migrations/add_unique_constraint_to_project_features_project_id_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180511174224_add_unique_constraint_to_project_features_project_id.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180511174224_add_unique_constraint_to_project_features_project_id.rb")
describe AddUniqueConstraintToProjectFeaturesProjectId, :migration do
let(:namespaces) { table(:namespaces) }
@@ -7,7 +7,7 @@ describe AddUniqueConstraintToProjectFeaturesProjectId, :migration do
let(:features) { table(:project_features) }
let(:migration) { described_class.new }
- describe '#up' do
+ describe "#up" do
before do
(1..3).each do |i|
namespaces.create(id: i, name: "ns-test-#{i}", path: "ns-test-i#{i}")
@@ -22,13 +22,13 @@ describe AddUniqueConstraintToProjectFeaturesProjectId, :migration do
features.create!(id: 6, project_id: 3)
end
- it 'creates a unique index and removes duplicates' do
- expect(migration.index_exists?(:project_features, :project_id, unique: false, name: 'index_project_features_on_project_id')).to be true
+ it "creates a unique index and removes duplicates" do
+ expect(migration.index_exists?(:project_features, :project_id, unique: false, name: "index_project_features_on_project_id")).to be true
expect { migration.up }.to change { features.count }.from(6).to(3)
- expect(migration.index_exists?(:project_features, :project_id, unique: true, name: 'index_project_features_on_project_id')).to be true
- expect(migration.index_exists?(:project_features, :project_id, name: 'index_project_features_on_project_id_unique')).to be false
+ expect(migration.index_exists?(:project_features, :project_id, unique: true, name: "index_project_features_on_project_id")).to be true
+ expect(migration.index_exists?(:project_features, :project_id, name: "index_project_features_on_project_id_unique")).to be false
project_1_features = features.where(project_id: 1)
expect(project_1_features.count).to eq(1)
@@ -44,16 +44,16 @@ describe AddUniqueConstraintToProjectFeaturesProjectId, :migration do
end
end
- describe '#down' do
- it 'restores the original index' do
+ describe "#down" do
+ it "restores the original index" do
migration.up
- expect(migration.index_exists?(:project_features, :project_id, unique: true, name: 'index_project_features_on_project_id')).to be true
+ expect(migration.index_exists?(:project_features, :project_id, unique: true, name: "index_project_features_on_project_id")).to be true
migration.down
- expect(migration.index_exists?(:project_features, :project_id, unique: false, name: 'index_project_features_on_project_id')).to be true
- expect(migration.index_exists?(:project_features, :project_id, name: 'index_project_features_on_project_id_old')).to be false
+ expect(migration.index_exists?(:project_features, :project_id, unique: false, name: "index_project_features_on_project_id")).to be true
+ expect(migration.index_exists?(:project_features, :project_id, name: "index_project_features_on_project_id_old")).to be false
end
end
end
diff --git a/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb b/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb
index b8c3a3eda4e..e56f45879da 100644
--- a/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb
+++ b/spec/migrations/assure_commits_count_for_merge_request_diff_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180425131009_assure_commits_count_for_merge_request_diff.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180425131009_assure_commits_count_for_merge_request_diff.rb")
describe AssureCommitsCountForMergeRequestDiff, :migration, :sidekiq, :redis do
- let(:migration) { spy('migration') }
+ let(:migration) { spy("migration") }
before do
allow(Gitlab::BackgroundMigration::AddMergeRequestDiffCommitsCount)
.to receive(:new).and_return(migration)
end
- context 'when there are still unmigrated commit_counts afterwards' do
- let(:namespaces) { table('namespaces') }
- let(:projects) { table('projects') }
- let(:merge_requests) { table('merge_requests') }
- let(:diffs) { table('merge_request_diffs') }
+ context "when there are still unmigrated commit_counts afterwards" do
+ let(:namespaces) { table("namespaces") }
+ let(:projects) { table("projects") }
+ let(:merge_requests) { table("merge_requests") }
+ let(:diffs) { table("merge_request_diffs") }
before do
- namespace = namespaces.create(name: 'foo', path: 'foo')
+ namespace = namespaces.create(name: "foo", path: "foo")
project = projects.create!(namespace_id: namespace.id)
- merge_request = merge_requests.create!(source_branch: 'x', target_branch: 'y', target_project_id: project.id)
+ merge_request = merge_requests.create!(source_branch: "x", target_branch: "y", target_project_id: project.id)
diffs.create!(commits_count: nil, merge_request_id: merge_request.id)
diffs.create!(commits_count: nil, merge_request_id: merge_request.id)
end
- it 'migrates commit_counts sequentially in batches' do
+ it "migrates commit_counts sequentially in batches" do
migrate!
expect(migration).to have_received(:perform).once
diff --git a/spec/migrations/backfill_releases_name_with_tag_name_spec.rb b/spec/migrations/backfill_releases_name_with_tag_name_spec.rb
index 6f436de84b7..7ff6753949b 100644
--- a/spec/migrations/backfill_releases_name_with_tag_name_spec.rb
+++ b/spec/migrations/backfill_releases_name_with_tag_name_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20181212104941_backfill_releases_name_with_tag_name.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20181212104941_backfill_releases_name_with_tag_name.rb")
describe BackfillReleasesNameWithTagName, :migration do
let(:releases) { table(:releases) }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
- let(:namespace) { namespaces.create(name: 'foo', path: 'foo') }
+ let(:namespace) { namespaces.create(name: "foo", path: "foo") }
let(:project) { projects.create!(namespace_id: namespace.id) }
- let(:release) { releases.create!(project_id: project.id, tag: 'v1.0.0') }
+ let(:release) { releases.create!(project_id: project.id, tag: "v1.0.0") }
- it 'defaults name to tag value' do
+ it "defaults name to tag value" do
expect(release.tag).to be_present
migrate!
diff --git a/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb b/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
index 34f4a36d63d..c988c95308c 100644
--- a/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
+++ b/spec/migrations/backfill_store_project_full_path_in_repo_spec.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-require Rails.root.join('db', 'post_migrate', '20181010133639_backfill_store_project_full_path_in_repo.rb')
+require Rails.root.join("db", "post_migrate", "20181010133639_backfill_store_project_full_path_in_repo.rb")
describe BackfillStoreProjectFullPathInRepo, :migration do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
- let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
- let(:subgroup) { namespaces.create!(name: 'bar', path: 'bar', parent_id: group.id) }
+ let(:group) { namespaces.create!(name: "foo", path: "foo") }
+ let(:subgroup) { namespaces.create!(name: "bar", path: "bar", parent_id: group.id) }
subject(:migration) { described_class.new }
@@ -18,29 +18,29 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
end
end
- describe '#up' do
- shared_examples_for 'writes the full path to git config' do
- it 'writes the git config' do
+ describe "#up" do
+ shared_examples_for "writes the full path to git config" do
+ it "writes the git config" do
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |repository_service|
allow(repository_service).to receive(:cleanup)
- expect(repository_service).to receive(:set_config).with('gitlab.fullpath' => expected_path)
+ expect(repository_service).to receive(:set_config).with("gitlab.fullpath" => expected_path)
end
migration.up
end
- it 'retries in case of failure' do
+ it "retries in case of failure" do
repository_service = spy(:repository_service)
allow(Gitlab::GitalyClient::RepositoryService).to receive(:new).and_return(repository_service)
- allow(repository_service).to receive(:set_config).and_raise(GRPC::BadStatus, 'Retry me')
+ allow(repository_service).to receive(:set_config).and_raise(GRPC::BadStatus, "Retry me")
expect(repository_service).to receive(:set_config).exactly(3).times
migration.up
end
- it 'cleans up repository before writing the config' do
+ it "cleans up repository before writing the config" do
expect_next_instance_of(Gitlab::GitalyClient::RepositoryService) do |repository_service|
expect(repository_service).to receive(:cleanup).ordered
expect(repository_service).to receive(:set_config).ordered
@@ -49,16 +49,16 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
migration.up
end
- context 'legacy storage' do
- it 'finds the repository at the correct location' do
+ context "legacy storage" do
+ it "finds the repository at the correct location" do
Project.find(project.id).create_repository
expect { migration.up }.not_to raise_error
end
end
- context 'hashed storage' do
- it 'finds the repository at the correct location' do
+ context "hashed storage" do
+ it "finds the repository at the correct location" do
project.update_attribute(:storage_version, 1)
Project.find(project.id).create_repository
@@ -68,28 +68,28 @@ describe BackfillStoreProjectFullPathInRepo, :migration do
end
end
- context 'project in group' do
- let!(:project) { projects.create!(namespace_id: group.id, name: 'baz', path: 'baz') }
- let(:expected_path) { 'foo/baz' }
+ context "project in group" do
+ let!(:project) { projects.create!(namespace_id: group.id, name: "baz", path: "baz") }
+ let(:expected_path) { "foo/baz" }
- it_behaves_like 'writes the full path to git config'
+ it_behaves_like "writes the full path to git config"
end
- context 'project in subgroup' do
- let!(:project) { projects.create!(namespace_id: subgroup.id, name: 'baz', path: 'baz') }
- let(:expected_path) { 'foo/bar/baz' }
+ context "project in subgroup" do
+ let!(:project) { projects.create!(namespace_id: subgroup.id, name: "baz", path: "baz") }
+ let(:expected_path) { "foo/bar/baz" }
- it_behaves_like 'writes the full path to git config'
+ it_behaves_like "writes the full path to git config"
end
end
- describe '#down' do
- context 'project in group' do
- let!(:project) { projects.create!(namespace_id: group.id, name: 'baz', path: 'baz') }
+ describe "#down" do
+ context "project in group" do
+ let!(:project) { projects.create!(namespace_id: group.id, name: "baz", path: "baz") }
- it 'deletes the gitlab full config value' do
+ it "deletes the gitlab full config value" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService)
- .to receive(:delete_config).with(['gitlab.fullpath'])
+ .to receive(:delete_config).with(["gitlab.fullpath"])
migration.down
end
diff --git a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb
index 19f06810e54..8a7c12b6138 100644
--- a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb
+++ b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev_index_percentages.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170803090603_calculate_conv_dev_index_percentages.rb")
describe CalculateConvDevIndexPercentages, :delete do
let(:migration) { described_class.new }
@@ -21,8 +19,8 @@ describe CalculateConvDevIndexPercentages, :delete do
percentage_service_desk_issues: 0)
end
- describe '#up' do
- it 'calculates percentages correctly' do
+ describe "#up" do
+ it "calculates percentages correctly" do
migration.up
conv_dev_index.reload
diff --git a/spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb b/spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb
index 7e61ab9b52e..2e9cdb84ab1 100644
--- a/spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb
+++ b/spec/migrations/change_default_value_for_dsa_key_restriction_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180531220618_change_default_value_for_dsa_key_restriction.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180531220618_change_default_value_for_dsa_key_restriction.rb")
describe ChangeDefaultValueForDsaKeyRestriction, :migration do
let(:application_settings) { table(:application_settings) }
@@ -8,7 +8,7 @@ describe ChangeDefaultValueForDsaKeyRestriction, :migration do
application_settings.create!
end
- it 'changes the default value for dsa_key_restriction' do
+ it "changes the default value for dsa_key_restriction" do
expect(application_settings.first.dsa_key_restriction).to eq(0)
migrate!
@@ -20,7 +20,7 @@ describe ChangeDefaultValueForDsaKeyRestriction, :migration do
expect(new_setting.dsa_key_restriction).to eq(-1)
end
- it 'changes the existing setting' do
+ it "changes the existing setting" do
setting = application_settings.last
expect(setting.dsa_key_restriction).to eq(0)
diff --git a/spec/migrations/clean_appearance_symlinks_spec.rb b/spec/migrations/clean_appearance_symlinks_spec.rb
index 9225dc0d894..a31a0e0d25a 100644
--- a/spec/migrations/clean_appearance_symlinks_spec.rb
+++ b/spec/migrations/clean_appearance_symlinks_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170613111224_clean_appearance_symlinks.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170613111224_clean_appearance_symlinks.rb")
describe CleanAppearanceSymlinks do
let(:migration) { described_class.new }
let(:test_dir) { File.join(Rails.root, "tmp", "tests", "clean_appearance_test") }
let(:uploads_dir) { File.join(test_dir, "public", "uploads") }
let(:new_uploads_dir) { File.join(uploads_dir, "system") }
- let(:original_path) { File.join(new_uploads_dir, 'appearance') }
- let(:symlink_path) { File.join(uploads_dir, 'appearance') }
+ let(:original_path) { File.join(new_uploads_dir, "appearance") }
+ let(:symlink_path) { File.join(uploads_dir, "appearance") }
before do
FileUtils.remove_dir(test_dir) if File.directory?(test_dir)
@@ -22,20 +22,20 @@ describe CleanAppearanceSymlinks do
FileUtils.ln_s(original_path, symlink_path)
end
- it 'removes the symlink' do
+ it "removes the symlink" do
migration.up
expect(File.symlink?(symlink_path)).to be(false)
end
end
- describe '#down' do
+ describe "#down" do
before do
FileUtils.mkdir_p(File.join(original_path))
- FileUtils.touch(File.join(original_path, 'dummy.file'))
+ FileUtils.touch(File.join(original_path, "dummy.file"))
end
- it 'creates a symlink' do
+ it "creates a symlink" do
expected_path = File.join(symlink_path, "dummy.file")
migration.down
diff --git a/spec/migrations/clean_stage_id_reference_migration_spec.rb b/spec/migrations/clean_stage_id_reference_migration_spec.rb
index 9a581df28a2..008864272fb 100644
--- a/spec/migrations/clean_stage_id_reference_migration_spec.rb
+++ b/spec/migrations/clean_stage_id_reference_migration_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170710083355_clean_stage_id_reference_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170710083355_clean_stage_id_reference_migration.rb")
describe CleanStageIdReferenceMigration, :migration, :sidekiq, :redis do
- let(:migration_class) { 'MigrateBuildStageIdReference' }
- let(:migration) { spy('migration') }
+ let(:migration_class) { "MigrateBuildStageIdReference" }
+ let(:migration) { spy("migration") }
before do
allow(Gitlab::BackgroundMigration.const_get(migration_class))
.to receive(:new).and_return(migration)
end
- context 'when there are pending background migrations' do
- it 'processes pending jobs synchronously' do
+ context "when there are pending background migrations" do
+ it "processes pending jobs synchronously" do
Sidekiq::Testing.disable! do
BackgroundMigrationWorker.perform_in(2.minutes, migration_class, [1, 1])
BackgroundMigrationWorker.perform_async(migration_class, [1, 1])
@@ -22,8 +22,8 @@ describe CleanStageIdReferenceMigration, :migration, :sidekiq, :redis do
end
end
end
- context 'when there are no background migrations pending' do
- it 'does nothing' do
+ context "when there are no background migrations pending" do
+ it "does nothing" do
Sidekiq::Testing.disable! do
migrate!
diff --git a/spec/migrations/clean_stages_statuses_migration_spec.rb b/spec/migrations/clean_stages_statuses_migration_spec.rb
index 38705f8eaae..d812206b45a 100644
--- a/spec/migrations/clean_stages_statuses_migration_spec.rb
+++ b/spec/migrations/clean_stages_statuses_migration_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170912113435_clean_stages_statuses_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170912113435_clean_stages_statuses_migration.rb")
describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do
- let(:migration) { spy('migration') }
+ let(:migration) { spy("migration") }
before do
allow(Gitlab::BackgroundMigration::MigrateStageStatus)
.to receive(:new).and_return(migration)
end
- context 'when there are pending background migrations' do
- it 'processes pending jobs synchronously' do
+ context "when there are pending background migrations" do
+ it "processes pending jobs synchronously" do
Sidekiq::Testing.disable! do
BackgroundMigrationWorker
- .perform_in(2.minutes, 'MigrateStageStatus', [1, 1])
+ .perform_in(2.minutes, "MigrateStageStatus", [1, 1])
BackgroundMigrationWorker
- .perform_async('MigrateStageStatus', [1, 1])
+ .perform_async("MigrateStageStatus", [1, 1])
migrate!
@@ -24,8 +24,8 @@ describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are no background migrations pending' do
- it 'does nothing' do
+ context "when there are no background migrations pending" do
+ it "does nothing" do
Sidekiq::Testing.disable! do
migrate!
@@ -34,15 +34,15 @@ describe CleanStagesStatusesMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are still unmigrated stages afterwards' do
- let(:stages) { table('ci_stages') }
+ context "when there are still unmigrated stages afterwards" do
+ let(:stages) { table("ci_stages") }
before do
- stages.create!(status: nil, name: 'build')
- stages.create!(status: nil, name: 'test')
+ stages.create!(status: nil, name: "build")
+ stages.create!(status: nil, name: "test")
end
- it 'migrates statuses sequentially in batches' do
+ it "migrates statuses sequentially in batches" do
migrate!
expect(migration).to have_received(:perform).once
diff --git a/spec/migrations/clean_up_for_members_spec.rb b/spec/migrations/clean_up_for_members_spec.rb
index 1a79f94cf0d..c951263d664 100644
--- a/spec/migrations/clean_up_for_members_spec.rb
+++ b/spec/migrations/clean_up_for_members_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20171216111734_clean_up_for_members.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20171216111734_clean_up_for_members.rb")
describe CleanUpForMembers, :migration do
before do
@@ -17,7 +17,7 @@ describe CleanUpForMembers, :migration do
let!(:unbinded_project_member) { create_project_member }
let!(:not_valid_project_member) { create_project_member }
- it 'removes members without proper user_id' do
+ it "removes members without proper user_id" do
unbinded_group_member.update_column(:user_id, nil)
not_valid_group_member.update_column(:user_id, 9999)
unbinded_project_member.update_column(:user_id, nil)
@@ -30,7 +30,7 @@ describe CleanUpForMembers, :migration do
end
def create_group_member(invited = false)
- fill_member(GroupMember.new(source_id: create_group.id, source_type: 'Namespace'), invited)
+ fill_member(GroupMember.new(source_id: create_group.id, source_type: "Namespace"), invited)
end
def create_project_member(invited = false)
@@ -44,8 +44,8 @@ describe CleanUpForMembers, :migration do
if invited
m.user_id = nil
- m.invite_token = 'xxx'
- m.invite_email = 'email@email.com'
+ m.invite_token = "xxx"
+ m.invite_email = "email@email.com"
else
m.user_id = create_user.id
end
@@ -59,7 +59,7 @@ describe CleanUpForMembers, :migration do
def create_group
name = FFaker::Lorem.characters(10)
- groups.create!(type: 'Group', name: name, path: name.downcase.gsub(/\s/, '_'))
+ groups.create!(type: "Group", name: name, path: name.downcase.gsub(/\s/, "_"))
end
def create_project
@@ -67,14 +67,14 @@ describe CleanUpForMembers, :migration do
creator = create_user
Project.create(name: name,
- path: name.downcase.gsub(/\s/, '_'),
+ path: name.downcase.gsub(/\s/, "_"),
namespace: creator.namespace,
creator: creator)
end
def create_user
User.create(email: FFaker::Internet.email,
- password: '12345678',
+ password: "12345678",
name: FFaker::Name.name,
username: FFaker::Internet.user_name,
confirmed_at: Time.now,
diff --git a/spec/migrations/clean_upload_symlinks_spec.rb b/spec/migrations/clean_upload_symlinks_spec.rb
index 26653b9c008..197c3c814e8 100644
--- a/spec/migrations/clean_upload_symlinks_spec.rb
+++ b/spec/migrations/clean_upload_symlinks_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170406111121_clean_upload_symlinks.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170406111121_clean_upload_symlinks.rb")
describe CleanUploadSymlinks do
let(:migration) { described_class.new }
let(:test_dir) { File.join(Rails.root, "tmp", "tests", "move_uploads_test") }
let(:uploads_dir) { File.join(test_dir, "public", "uploads") }
let(:new_uploads_dir) { File.join(uploads_dir, "-", "system") }
- let(:original_path) { File.join(new_uploads_dir, 'user') }
- let(:symlink_path) { File.join(uploads_dir, 'user') }
+ let(:original_path) { File.join(new_uploads_dir, "user") }
+ let(:symlink_path) { File.join(uploads_dir, "user") }
before do
FileUtils.remove_dir(test_dir) if File.directory?(test_dir)
@@ -22,20 +22,20 @@ describe CleanUploadSymlinks do
FileUtils.ln_s(original_path, symlink_path)
end
- it 'removes the symlink' do
+ it "removes the symlink" do
migration.up
expect(File.symlink?(symlink_path)).to be(false)
end
end
- describe '#down' do
+ describe "#down" do
before do
FileUtils.mkdir_p(File.join(original_path))
- FileUtils.touch(File.join(original_path, 'dummy.file'))
+ FileUtils.touch(File.join(original_path, "dummy.file"))
end
- it 'creates a symlink' do
+ it "creates a symlink" do
expected_path = File.join(symlink_path, "dummy.file")
migration.down
diff --git a/spec/migrations/cleanup_build_stage_migration_spec.rb b/spec/migrations/cleanup_build_stage_migration_spec.rb
index 4d4d02aaa94..d33ba77fe00 100644
--- a/spec/migrations/cleanup_build_stage_migration_spec.rb
+++ b/spec/migrations/cleanup_build_stage_migration_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180420010616_cleanup_build_stage_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180420010616_cleanup_build_stage_migration.rb")
describe CleanupBuildStageMigration, :migration, :sidekiq, :redis do
- let(:migration) { spy('migration') }
+ let(:migration) { spy("migration") }
before do
allow(Gitlab::BackgroundMigration::MigrateBuildStage)
.to receive(:new).and_return(migration)
end
- context 'when there are pending background migrations' do
- it 'processes pending jobs synchronously' do
+ context "when there are pending background migrations" do
+ it "processes pending jobs synchronously" do
Sidekiq::Testing.disable! do
BackgroundMigrationWorker
- .perform_in(2.minutes, 'MigrateBuildStage', [1, 1])
+ .perform_in(2.minutes, "MigrateBuildStage", [1, 1])
BackgroundMigrationWorker
- .perform_async('MigrateBuildStage', [1, 1])
+ .perform_async("MigrateBuildStage", [1, 1])
migrate!
@@ -24,8 +24,8 @@ describe CleanupBuildStageMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are no background migrations pending' do
- it 'does nothing' do
+ context "when there are no background migrations pending" do
+ it "does nothing" do
Sidekiq::Testing.disable! do
migrate!
@@ -34,15 +34,15 @@ describe CleanupBuildStageMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are still unmigrated builds present' do
- let(:builds) { table('ci_builds') }
+ context "when there are still unmigrated builds present" do
+ let(:builds) { table("ci_builds") }
before do
- builds.create!(name: 'test:1', ref: 'master')
- builds.create!(name: 'test:2', ref: 'master')
+ builds.create!(name: "test:1", ref: "master")
+ builds.create!(name: "test:2", ref: "master")
end
- it 'migrates stages sequentially in batches' do
+ it "migrates stages sequentially in batches" do
expect(builds.all).to all(have_attributes(stage_id: nil))
migrate!
diff --git a/spec/migrations/cleanup_environments_external_url_spec.rb b/spec/migrations/cleanup_environments_external_url_spec.rb
index 07ddaf3d38f..41f64331f87 100644
--- a/spec/migrations/cleanup_environments_external_url_spec.rb
+++ b/spec/migrations/cleanup_environments_external_url_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20181108091549_cleanup_environments_external_url.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20181108091549_cleanup_environments_external_url.rb")
describe CleanupEnvironmentsExternalUrl, :migration do
let(:environments) { table(:environments) }
- let(:invalid_entries) { environments.where(environments.arel_table[:external_url].matches('javascript://%')) }
+ let(:invalid_entries) { environments.where(environments.arel_table[:external_url].matches("javascript://%")) }
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
before do
- namespace = namespaces.create(name: 'foo', path: 'foo')
+ namespace = namespaces.create(name: "foo", path: "foo")
project = projects.create!(namespace_id: namespace.id)
- environments.create!(id: 1, project_id: project.id, name: 'poisoned', slug: 'poisoned', external_url: 'javascript://alert("1")')
+ environments.create!(id: 1, project_id: project.id, name: "poisoned", slug: "poisoned", external_url: 'javascript://alert("1")')
end
- it 'clears every environment with a javascript external_url' do
- expect do
+ it "clears every environment with a javascript external_url" do
+ expect {
subject.up
- end.to change { invalid_entries.count }.from(1).to(0)
+ }.to change { invalid_entries.count }.from(1).to(0)
end
- it 'do not removes environments' do
- expect do
+ it "do not removes environments" do
+ expect {
subject.up
- end.not_to change { environments.count }
+ }.not_to change { environments.count }
end
end
diff --git a/spec/migrations/cleanup_legacy_artifact_migration_spec.rb b/spec/migrations/cleanup_legacy_artifact_migration_spec.rb
index dc269d32e5a..fa5bd989247 100644
--- a/spec/migrations/cleanup_legacy_artifact_migration_spec.rb
+++ b/spec/migrations/cleanup_legacy_artifact_migration_spec.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20190104182041_cleanup_legacy_artifact_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20190104182041_cleanup_legacy_artifact_migration.rb")
describe CleanupLegacyArtifactMigration, :migration, :sidekiq, :redis do
- let(:migration) { spy('migration') }
+ let(:migration) { spy("migration") }
- context 'when still legacy artifacts exist' do
+ context "when still legacy artifacts exist" do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) }
let(:jobs) { table(:ci_builds) }
let(:job_artifacts) { table(:ci_job_artifacts) }
- let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
- let(:project) { projects.create!(name: 'gitlab', path: 'gitlab-ce', namespace_id: namespace.id) }
- let(:pipeline) { pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a') }
+ let(:namespace) { namespaces.create!(name: "gitlab", path: "gitlab-org") }
+ let(:project) { projects.create!(name: "gitlab", path: "gitlab-ce", namespace_id: namespace.id) }
+ let(:pipeline) { pipelines.create!(project_id: project.id, ref: "master", sha: "adf43c3a") }
let(:archive_file_type) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::ARCHIVE_FILE_TYPE }
let(:metadata_file_type) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::METADATA_FILE_TYPE }
let(:local_store) { ::ObjectStorage::Store::LOCAL }
@@ -22,31 +22,31 @@ describe CleanupLegacyArtifactMigration, :migration, :sidekiq, :redis do
let(:legacy_location) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::LEGACY_PATH_FILE_LOCATION }
before do
- jobs.create!(id: 1, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: 'archive.zip')
- jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: 'metadata.gz')
- jobs.create!(id: 3, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: 'archive.zip', artifacts_metadata: 'metadata.gz')
+ jobs.create!(id: 1, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: "archive.zip")
+ jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: "metadata.gz")
+ jobs.create!(id: 3, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: "archive.zip", artifacts_metadata: "metadata.gz")
jobs.create!(id: 4, commit_id: pipeline.id, project_id: project.id, status: :running)
- jobs.create!(id: 5, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: 'archive.zip', artifacts_file_store: remote_store, artifacts_metadata: 'metadata.gz')
- jobs.create!(id: 6, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: 'archive.zip', artifacts_metadata: 'metadata.gz')
+ jobs.create!(id: 5, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: "archive.zip", artifacts_file_store: remote_store, artifacts_metadata: "metadata.gz")
+ jobs.create!(id: 6, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: "archive.zip", artifacts_metadata: "metadata.gz")
end
- it 'steals sidekiq jobs from MigrateLegacyArtifacts background migration' do
- expect(Gitlab::BackgroundMigration).to receive(:steal).with('MigrateLegacyArtifacts')
+ it "steals sidekiq jobs from MigrateLegacyArtifacts background migration" do
+ expect(Gitlab::BackgroundMigration).to receive(:steal).with("MigrateLegacyArtifacts")
migrate!
end
- it 'migrates legacy artifacts to ci_job_artifacts table' do
+ it "migrates legacy artifacts to ci_job_artifacts table" do
migrate!
- expect(job_artifacts.order(:job_id, :file_type).pluck('project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location'))
- .to eq([[project.id, 1, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 3, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 3, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location],
- [project.id, 5, archive_file_type, remote_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 5, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location],
- [project.id, 6, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 6, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location]])
+ expect(job_artifacts.order(:job_id, :file_type).pluck("project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location"))
+ .to eq([[project.id, 1, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 3, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 3, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],
+ [project.id, 5, archive_file_type, remote_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 5, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],
+ [project.id, 6, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 6, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],])
end
end
end
diff --git a/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb b/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb
index 3a9fa8c7113..67039febcc3 100644
--- a/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb
+++ b/spec/migrations/cleanup_move_system_upload_folder_symlink_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
require Rails.root.join("db", "post_migrate", "20170717111152_cleanup_move_system_upload_folder_symlink.rb")
describe CleanupMoveSystemUploadFolderSymlink do
let(:migration) { described_class.new }
- let(:test_base) { File.join(Rails.root, 'tmp', 'tests', 'move-system-upload-folder') }
- let(:test_folder) { File.join(test_base, '-', 'system') }
+ let(:test_base) { File.join(Rails.root, "tmp", "tests", "move-system-upload-folder") }
+ let(:test_folder) { File.join(test_base, "-", "system") }
before do
allow(migration).to receive(:base_directory).and_return(test_base)
@@ -13,23 +13,23 @@ describe CleanupMoveSystemUploadFolderSymlink do
allow(migration).to receive(:say)
end
- describe '#up' do
+ describe "#up" do
before do
- FileUtils.ln_s(test_folder, File.join(test_base, 'system'))
+ FileUtils.ln_s(test_folder, File.join(test_base, "system"))
end
- it 'removes the symlink' do
+ it "removes the symlink" do
migration.up
- expect(File.exist?(File.join(test_base, 'system'))).to be_falsey
+ expect(File.exist?(File.join(test_base, "system"))).to be_falsey
end
end
- describe '#down' do
- it 'creates the symlink' do
+ describe "#down" do
+ it "creates the symlink" do
migration.down
- expect(File.symlink?(File.join(test_base, 'system'))).to be_truthy
+ expect(File.symlink?(File.join(test_base, "system"))).to be_truthy
end
end
end
diff --git a/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb b/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb
index 651341906c2..65eaa37a8cd 100644
--- a/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb
+++ b/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170502101023_cleanup_namespaceless_pending_delete_projects.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170502101023_cleanup_namespaceless_pending_delete_projects.rb")
describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222043024 do
let(:projects) { table(:projects) }
@@ -10,10 +10,10 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
end
- describe '#up' do
- it 'only cleans up pending delete projects' do
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce', namespace_id: 1)
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ee', namespace_id: 2, pending_delete: true)
+ describe "#up" do
+ it "only cleans up pending delete projects" do
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ce", namespace_id: 1)
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ee", namespace_id: 2, pending_delete: true)
project = Project.new(pending_delete: true, namespace_id: nil)
project.save(validate: false)
@@ -22,9 +22,9 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222
described_class.new.up
end
- it 'does nothing when no pending delete projects without namespace found' do
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce', namespace_id: 1)
- projects.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ee', namespace_id: 2, pending_delete: true)
+ it "does nothing when no pending delete projects without namespace found" do
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ce", namespace_id: 1)
+ projects.create!(name: "gitlab", path: "gitlab-org/gitlab-ee", namespace_id: 2, pending_delete: true)
expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async)
diff --git a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb
index 8f40ac3e38b..91e2d1d0fb7 100644
--- a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb
+++ b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170816102555_cleanup_nonexisting_namespace_pending_delete_projects.rb")
describe CleanupNonexistingNamespacePendingDeleteProjects do
before do
@@ -8,10 +8,10 @@ describe CleanupNonexistingNamespacePendingDeleteProjects do
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
end
- describe '#up' do
+ describe "#up" do
set(:some_project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- it 'only cleans up when namespace does not exist' do
+ it "only cleans up when namespace does not exist" do
create(:project, pending_delete: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs
project = build(:project, pending_delete: true, namespace: nil, namespace_id: Namespace.maximum(:id).to_i.succ) # rubocop:disable RSpec/FactoriesInMigrationSpecs
project.save(validate: false)
@@ -21,7 +21,7 @@ describe CleanupNonexistingNamespacePendingDeleteProjects do
described_class.new.up
end
- it 'does nothing when no pending delete projects without namespace found' do
+ it "does nothing when no pending delete projects without namespace found" do
create(:project, pending_delete: true, namespace: create(:namespace)) # rubocop:disable RSpec/FactoriesInMigrationSpecs
expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async)
diff --git a/spec/migrations/cleanup_stages_position_migration_spec.rb b/spec/migrations/cleanup_stages_position_migration_spec.rb
index dde5a777487..91314b00f89 100644
--- a/spec/migrations/cleanup_stages_position_migration_spec.rb
+++ b/spec/migrations/cleanup_stages_position_migration_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180604123514_cleanup_stages_position_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180604123514_cleanup_stages_position_migration.rb")
describe CleanupStagesPositionMigration, :migration, :sidekiq, :redis do
- let(:migration) { spy('migration') }
+ let(:migration) { spy("migration") }
before do
allow(Gitlab::BackgroundMigration::MigrateStageIndex)
.to receive(:new).and_return(migration)
end
- context 'when there are pending background migrations' do
- it 'processes pending jobs synchronously' do
+ context "when there are pending background migrations" do
+ it "processes pending jobs synchronously" do
Sidekiq::Testing.disable! do
BackgroundMigrationWorker
- .perform_in(2.minutes, 'MigrateStageIndex', [1, 1])
+ .perform_in(2.minutes, "MigrateStageIndex", [1, 1])
BackgroundMigrationWorker
- .perform_async('MigrateStageIndex', [1, 1])
+ .perform_async("MigrateStageIndex", [1, 1])
migrate!
@@ -24,8 +24,8 @@ describe CleanupStagesPositionMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are no background migrations pending' do
- it 'does nothing' do
+ context "when there are no background migrations pending" do
+ it "does nothing" do
Sidekiq::Testing.disable! do
migrate!
@@ -34,9 +34,9 @@ describe CleanupStagesPositionMigration, :migration, :sidekiq, :redis do
end
end
- context 'when there are still unmigrated stages present' do
- let(:stages) { table('ci_stages') }
- let(:builds) { table('ci_builds') }
+ context "when there are still unmigrated stages present" do
+ let(:stages) { table("ci_stages") }
+ let(:builds) { table("ci_builds") }
let!(:entities) do
%w[build test broken].map do |name|
@@ -47,11 +47,11 @@ describe CleanupStagesPositionMigration, :migration, :sidekiq, :redis do
before do
stages.update_all(position: nil)
- builds.create(name: 'unit', stage_id: entities.first.id, stage_idx: 1, ref: 'master')
- builds.create(name: 'unit', stage_id: entities.second.id, stage_idx: 1, ref: 'master')
+ builds.create(name: "unit", stage_id: entities.first.id, stage_idx: 1, ref: "master")
+ builds.create(name: "unit", stage_id: entities.second.id, stage_idx: 1, ref: "master")
end
- it 'migrates stages sequentially for every stage' do
+ it "migrates stages sequentially for every stage" do
expect(stages.all).to all(have_attributes(position: nil))
migrate!
diff --git a/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb b/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb
index d1bf6bdf9d6..851a751fd8f 100644
--- a/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb
+++ b/spec/migrations/convert_custom_notification_settings_to_columns_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170607121233_convert_custom_notification_settings_to_columns')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170607121233_convert_custom_notification_settings_to_columns")
describe ConvertCustomNotificationSettingsToColumns, :migration do
let(:user_class) { table(:users) }
let(:settings_params) do
[
- { level: 0, events: [:new_note] }, # disabled, single event
- { level: 3, events: [:new_issue, :reopen_issue, :close_issue, :reassign_issue] }, # global, multiple events
- { level: 5, events: described_class::EMAIL_EVENTS }, # custom, all events
- { level: 5, events: [] } # custom, no events
+ {level: 0, events: [:new_note]}, # disabled, single event
+ {level: 3, events: [:new_issue, :reopen_issue, :close_issue, :reassign_issue]}, # global, multiple events
+ {level: 5, events: described_class::EMAIL_EVENTS}, # custom, all events
+ {level: 5, events: []}, # custom, no events
]
end
@@ -21,8 +21,8 @@ describe ConvertCustomNotificationSettingsToColumns, :migration do
events[event] = true
end
- user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: '12345678')
- create_params = { user_id: user.id, level: params[:level], events: events }
+ user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: "12345678")
+ create_params = {user_id: user.id, level: params[:level], events: events}
notification_setting = described_class::NotificationSetting.create(create_params)
[notification_setting, params]
@@ -37,7 +37,7 @@ describe ConvertCustomNotificationSettingsToColumns, :migration do
events[event] = true
end
- user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: '12345678')
+ user = user_class.create!(email: "user-#{SecureRandom.hex}@example.org", username: "user-#{SecureRandom.hex}", encrypted_password: "12345678")
create_params = events.merge(user_id: user.id, level: params[:level])
notification_setting = described_class::NotificationSetting.create(create_params)
@@ -45,8 +45,8 @@ describe ConvertCustomNotificationSettingsToColumns, :migration do
end
end
- describe '#up' do
- it 'migrates all settings where a custom event is enabled, even if they are not currently using the custom level' do
+ describe "#up" do
+ it "migrates all settings where a custom event is enabled, even if they are not currently using the custom level" do
notification_settings_before
described_class.new.up
@@ -67,8 +67,8 @@ describe ConvertCustomNotificationSettingsToColumns, :migration do
end
end
- describe '#down' do
- it 'creates a custom events hash for all settings where at least one event is enabled' do
+ describe "#down" do
+ it "creates a custom events hash for all settings where at least one event is enabled" do
notification_settings_after
described_class.new.down
@@ -92,7 +92,7 @@ describe ConvertCustomNotificationSettingsToColumns, :migration do
end
end
- it 'reverts the database to the state it was in before' do
+ it "reverts the database to the state it was in before" do
notification_settings_before
described_class.new.up
diff --git a/spec/migrations/create_missing_namespace_for_internal_users_spec.rb b/spec/migrations/create_missing_namespace_for_internal_users_spec.rb
index ac3a4b1f68f..2788c5742c9 100644
--- a/spec/migrations/create_missing_namespace_for_internal_users_spec.rb
+++ b/spec/migrations/create_missing_namespace_for_internal_users_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180413022611_create_missing_namespace_for_internal_users.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180413022611_create_missing_namespace_for_internal_users.rb")
describe CreateMissingNamespaceForInternalUsers, :migration do
let(:users) { table(:users) }
@@ -12,10 +12,10 @@ describe CreateMissingNamespaceForInternalUsers, :migration do
internal_user_types.each do |attr|
context "for #{attr} user" do
let(:internal_user) do
- users.create!(email: 'test@example.com', projects_limit: 100, username: 'test', attr => true)
+ users.create!(:email => "test@example.com", :projects_limit => 100, :username => "test", attr => true)
end
- it 'creates the missing namespace' do
+ it "creates the missing namespace" do
expect(namespaces.find_by(owner_id: internal_user.id)).to be_nil
migrate!
@@ -27,7 +27,7 @@ describe CreateMissingNamespaceForInternalUsers, :migration do
expect(namespace.name).to eq(route.name)
end
- it 'sets notification email' do
+ it "sets notification email" do
users.update(internal_user.id, notification_email: nil)
expect(users.find(internal_user.id).notification_email).to be_nil
diff --git a/spec/migrations/delete_conflicting_redirect_routes_spec.rb b/spec/migrations/delete_conflicting_redirect_routes_spec.rb
index 8a191bd7139..99ddb03d658 100644
--- a/spec/migrations/delete_conflicting_redirect_routes_spec.rb
+++ b/spec/migrations/delete_conflicting_redirect_routes_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170907170235_delete_conflicting_redirect_routes')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170907170235_delete_conflicting_redirect_routes")
describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do
let!(:redirect_routes) { table(:redirect_routes) }
@@ -10,27 +10,27 @@ describe DeleteConflictingRedirectRoutes, :migration, :sidekiq do
end
before do
- routes.create!(id: 1, source_id: 1, source_type: 'Namespace', path: 'foo1')
- routes.create!(id: 2, source_id: 2, source_type: 'Namespace', path: 'foo2')
- routes.create!(id: 3, source_id: 3, source_type: 'Namespace', path: 'foo3')
- routes.create!(id: 4, source_id: 4, source_type: 'Namespace', path: 'foo4')
- routes.create!(id: 5, source_id: 5, source_type: 'Namespace', path: 'foo5')
+ routes.create!(id: 1, source_id: 1, source_type: "Namespace", path: "foo1")
+ routes.create!(id: 2, source_id: 2, source_type: "Namespace", path: "foo2")
+ routes.create!(id: 3, source_id: 3, source_type: "Namespace", path: "foo3")
+ routes.create!(id: 4, source_id: 4, source_type: "Namespace", path: "foo4")
+ routes.create!(id: 5, source_id: 5, source_type: "Namespace", path: "foo5")
# Valid redirects
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'bar2')
- redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'bar3')
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "bar")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "bar2")
+ redirect_routes.create!(source_id: 2, source_type: "Namespace", path: "bar3")
# Conflicting redirects
- redirect_routes.create!(source_id: 2, source_type: 'Namespace', path: 'foo1')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo2')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo3')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo4')
- redirect_routes.create!(source_id: 1, source_type: 'Namespace', path: 'foo5')
+ redirect_routes.create!(source_id: 2, source_type: "Namespace", path: "foo1")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo2")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo3")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo4")
+ redirect_routes.create!(source_id: 1, source_type: "Namespace", path: "foo5")
end
# No-op. See https://gitlab.com/gitlab-com/infrastructure/issues/3460#note_53223252
- it 'NO-OP: does not schedule any background migrations' do
+ it "NO-OP: does not schedule any background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
diff --git a/spec/migrations/delete_inconsistent_internal_id_records_spec.rb b/spec/migrations/delete_inconsistent_internal_id_records_spec.rb
index e2ce69a7bb1..b3007c58d01 100644
--- a/spec/migrations/delete_inconsistent_internal_id_records_spec.rb
+++ b/spec/migrations/delete_inconsistent_internal_id_records_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
+
# rubocop:disable RSpec/FactoriesInMigrationSpecs
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180723130817_delete_inconsistent_internal_id_records.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180723130817_delete_inconsistent_internal_id_records.rb")
describe DeleteInconsistentInternalIdRecords, :migration do
let!(:project1) { create(:project) }
@@ -16,7 +17,7 @@ describe DeleteInconsistentInternalIdRecords, :migration do
3.times { create(scope, project: project3) }
end
- shared_examples_for 'deleting inconsistent internal_id records' do
+ shared_examples_for "deleting inconsistent internal_id records" do
before do
create_models
@@ -46,12 +47,12 @@ describe DeleteInconsistentInternalIdRecords, :migration do
end
end
- context 'for issues' do
+ context "for issues" do
let(:scope) { :issue }
- it_behaves_like 'deleting inconsistent internal_id records'
+ it_behaves_like "deleting inconsistent internal_id records"
end
- context 'for merge_requests' do
+ context "for merge_requests" do
let(:scope) { :merge_request }
let(:create_models) do
@@ -60,10 +61,10 @@ describe DeleteInconsistentInternalIdRecords, :migration do
3.times { |i| create(scope, target_project: project3, source_project: project3, source_branch: i.to_s) }
end
- it_behaves_like 'deleting inconsistent internal_id records'
+ it_behaves_like "deleting inconsistent internal_id records"
end
- context 'for deployments' do
+ context "for deployments" do
let(:scope) { :deployment }
let(:deployments) { table(:deployments) }
let(:internal_ids) { table(:internal_ids) }
@@ -75,20 +76,20 @@ describe DeleteInconsistentInternalIdRecords, :migration do
end
let(:create_models) do
- 3.times { |i| deployments.create!(project_id: project1.id, iid: i, environment_id: 1, ref: 'master', sha: 'a', tag: false) }
- 3.times { |i| deployments.create!(project_id: project2.id, iid: i, environment_id: 1, ref: 'master', sha: 'a', tag: false) }
- 3.times { |i| deployments.create!(project_id: project3.id, iid: i, environment_id: 1, ref: 'master', sha: 'a', tag: false) }
+ 3.times { |i| deployments.create!(project_id: project1.id, iid: i, environment_id: 1, ref: "master", sha: "a", tag: false) }
+ 3.times { |i| deployments.create!(project_id: project2.id, iid: i, environment_id: 1, ref: "master", sha: "a", tag: false) }
+ 3.times { |i| deployments.create!(project_id: project3.id, iid: i, environment_id: 1, ref: "master", sha: "a", tag: false) }
end
- it_behaves_like 'deleting inconsistent internal_id records'
+ it_behaves_like "deleting inconsistent internal_id records"
end
- context 'for milestones (by project)' do
+ context "for milestones (by project)" do
let(:scope) { :milestone }
- it_behaves_like 'deleting inconsistent internal_id records'
+ it_behaves_like "deleting inconsistent internal_id records"
end
- context 'for ci_pipelines' do
+ context "for ci_pipelines" do
let(:scope) { :ci_pipeline }
let(:create_models) do
@@ -97,17 +98,17 @@ describe DeleteInconsistentInternalIdRecords, :migration do
create_list(:ci_empty_pipeline, 3, project: project3)
end
- it_behaves_like 'deleting inconsistent internal_id records'
+ it_behaves_like "deleting inconsistent internal_id records"
end
- context 'for milestones (by group)' do
+ context "for milestones (by group)" do
# milestones (by group) is a little different than most of the other models
let(:groups) { table(:namespaces) }
- let(:group1) { groups.create(name: 'Group 1', type: 'Group', path: 'group_1') }
- let(:group2) { groups.create(name: 'Group 2', type: 'Group', path: 'group_2') }
- let(:group3) { groups.create(name: 'Group 2', type: 'Group', path: 'group_3') }
+ let(:group1) { groups.create(name: "Group 1", type: "Group", path: "group_1") }
+ let(:group2) { groups.create(name: "Group 2", type: "Group", path: "group_2") }
+ let(:group3) { groups.create(name: "Group 2", type: "Group", path: "group_3") }
- let(:internal_id_query) { ->(group) { InternalId.where(usage: InternalId.usages['milestones'], namespace: group) } }
+ let(:internal_id_query) { ->(group) { InternalId.where(usage: InternalId.usages["milestones"], namespace: group) } }
before do
3.times { create(:milestone, group_id: group1.id) }
diff --git a/spec/migrations/drop_duplicate_protected_tags_spec.rb b/spec/migrations/drop_duplicate_protected_tags_spec.rb
index acfb6850722..f1f3bef85bf 100644
--- a/spec/migrations/drop_duplicate_protected_tags_spec.rb
+++ b/spec/migrations/drop_duplicate_protected_tags_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180711103851_drop_duplicate_protected_tags.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180711103851_drop_duplicate_protected_tags.rb")
describe DropDuplicateProtectedTags, :migration do
let(:namespaces) { table(:namespaces) }
@@ -9,17 +9,17 @@ describe DropDuplicateProtectedTags, :migration do
before do
stub_const("#{described_class}::BATCH_SIZE", 2)
- namespaces.create(id: 1, name: 'gitlab-org', path: 'gitlab-org')
- projects.create!(id: 1, namespace_id: 1, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 2, namespace_id: 1, name: 'gitlab2', path: 'gitlab2')
+ namespaces.create(id: 1, name: "gitlab-org", path: "gitlab-org")
+ projects.create!(id: 1, namespace_id: 1, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 2, namespace_id: 1, name: "gitlab2", path: "gitlab2")
end
- it 'removes duplicated protected tags' do
- protected_tags.create!(id: 1, project_id: 1, name: 'foo')
- tag2 = protected_tags.create!(id: 2, project_id: 1, name: 'foo1')
- protected_tags.create!(id: 3, project_id: 1, name: 'foo')
- tag4 = protected_tags.create!(id: 4, project_id: 1, name: 'foo')
- tag5 = protected_tags.create!(id: 5, project_id: 2, name: 'foo')
+ it "removes duplicated protected tags" do
+ protected_tags.create!(id: 1, project_id: 1, name: "foo")
+ tag2 = protected_tags.create!(id: 2, project_id: 1, name: "foo1")
+ protected_tags.create!(id: 3, project_id: 1, name: "foo")
+ tag4 = protected_tags.create!(id: 4, project_id: 1, name: "foo")
+ tag5 = protected_tags.create!(id: 5, project_id: 2, name: "foo")
migrate!
@@ -27,10 +27,10 @@ describe DropDuplicateProtectedTags, :migration do
expect(protected_tags.all.pluck(:id)).to contain_exactly(tag2.id, tag4.id, tag5.id)
end
- it 'does not remove unique protected tags' do
- tag1 = protected_tags.create!(id: 1, project_id: 1, name: 'foo1')
- tag2 = protected_tags.create!(id: 2, project_id: 1, name: 'foo2')
- tag3 = protected_tags.create!(id: 3, project_id: 1, name: 'foo3')
+ it "does not remove unique protected tags" do
+ tag1 = protected_tags.create!(id: 1, project_id: 1, name: "foo1")
+ tag2 = protected_tags.create!(id: 2, project_id: 1, name: "foo2")
+ tag3 = protected_tags.create!(id: 3, project_id: 1, name: "foo3")
migrate!
diff --git a/spec/migrations/enqueue_delete_diff_files_workers_spec.rb b/spec/migrations/enqueue_delete_diff_files_workers_spec.rb
index 6bae870920c..380a05b7551 100644
--- a/spec/migrations/enqueue_delete_diff_files_workers_spec.rb
+++ b/spec/migrations/enqueue_delete_diff_files_workers_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180619121030_enqueue_delete_diff_files_workers.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180619121030_enqueue_delete_diff_files_workers.rb")
describe EnqueueDeleteDiffFilesWorkers, :migration, :sidekiq do
- it 'correctly schedules diff files deletion schedulers' do
+ it "correctly schedules diff files deletion schedulers" do
Sidekiq::Testing.fake! do
expect(BackgroundMigrationWorker)
.to receive(:perform_async)
diff --git a/spec/migrations/enqueue_redact_links_spec.rb b/spec/migrations/enqueue_redact_links_spec.rb
index a5da76977b7..d9201c8c86b 100644
--- a/spec/migrations/enqueue_redact_links_spec.rb
+++ b/spec/migrations/enqueue_redact_links_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181014121030_enqueue_redact_links.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181014121030_enqueue_redact_links.rb")
describe EnqueueRedactLinks, :migration, :sidekiq do
let(:merge_requests) { table(:merge_requests) }
@@ -9,23 +9,23 @@ describe EnqueueRedactLinks, :migration, :sidekiq do
let(:namespaces) { table(:namespaces) }
let(:snippets) { table(:snippets) }
let(:users) { table(:users) }
- let(:user) { users.create!(email: 'test@example.com', projects_limit: 100, username: 'test') }
+ let(:user) { users.create!(email: "test@example.com", projects_limit: 100, username: "test") }
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
- text = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
- group = namespaces.create!(name: 'gitlab', path: 'gitlab')
+ text = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
+ group = namespaces.create!(name: "gitlab", path: "gitlab")
project = projects.create!(namespace_id: group.id)
- merge_requests.create!(id: 1, target_project_id: project.id, source_project_id: project.id, target_branch: 'feature', source_branch: 'master', description: text)
+ merge_requests.create!(id: 1, target_project_id: project.id, source_project_id: project.id, target_branch: "feature", source_branch: "master", description: text)
issues.create!(id: 1, description: text)
notes.create!(id: 1, note: text)
notes.create!(id: 2, note: text)
snippets.create!(id: 1, description: text, author_id: user.id)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
diff --git a/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb b/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb
index afcaefa0591..b3e6fc23e5f 100644
--- a/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb
+++ b/spec/migrations/enqueue_verify_pages_domain_workers_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180216121030_enqueue_verify_pages_domain_workers')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180216121030_enqueue_verify_pages_domain_workers")
describe EnqueueVerifyPagesDomainWorkers, :sidekiq, :migration do
around do |example|
@@ -8,13 +8,13 @@ describe EnqueueVerifyPagesDomainWorkers, :sidekiq, :migration do
end
end
- describe '#up' do
- it 'enqueues a verification worker for every domain' do
+ describe "#up" do
+ it "enqueues a verification worker for every domain" do
domains = 1.upto(3).map { |i| PagesDomain.create!(domain: "my#{i}.domain.com") }
expect { migrate! }.to change(PagesDomainVerificationWorker.jobs, :size).by(3)
- enqueued_ids = PagesDomainVerificationWorker.jobs.map { |job| job['args'] }
+ enqueued_ids = PagesDomainVerificationWorker.jobs.map { |job| job["args"] }
expected_ids = domains.map { |domain| [domain.id] }
expect(enqueued_ids).to match_array(expected_ids)
diff --git a/spec/migrations/fill_empty_finished_at_in_deployments_spec.rb b/spec/migrations/fill_empty_finished_at_in_deployments_spec.rb
index cf5c10f77e1..94c4f2107e1 100644
--- a/spec/migrations/fill_empty_finished_at_in_deployments_spec.rb
+++ b/spec/migrations/fill_empty_finished_at_in_deployments_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181030135124_fill_empty_finished_at_in_deployments')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181030135124_fill_empty_finished_at_in_deployments")
describe FillEmptyFinishedAtInDeployments, :migration do
let(:namespaces) { table(:namespaces) }
@@ -7,16 +7,16 @@ describe FillEmptyFinishedAtInDeployments, :migration do
let(:environments) { table(:environments) }
let(:deployments) { table(:deployments) }
- context 'when a deployment row does not have a value on finished_at' do
- context 'when a deployment succeeded' do
+ context "when a deployment row does not have a value on finished_at" do
+ context "when a deployment succeeded" do
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
- environments.create!(id: 1, name: 'production', slug: 'production', project_id: 1)
- deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: 'master', sha: 'xxx', tag: false)
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1", namespace_id: 123)
+ environments.create!(id: 1, name: "production", slug: "production", project_id: 1)
+ deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: "master", sha: "xxx", tag: false)
end
- it 'correctly replicates finished_at by created_at' do
+ it "correctly replicates finished_at by created_at" do
expect(deployments.last.created_at).not_to be_nil
expect(deployments.last.finished_at).to be_nil
@@ -27,15 +27,15 @@ describe FillEmptyFinishedAtInDeployments, :migration do
end
end
- context 'when a deployment is running' do
+ context "when a deployment is running" do
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
- environments.create!(id: 1, name: 'production', slug: 'production', project_id: 1)
- deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: 'master', sha: 'xxx', tag: false, status: 1)
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1", namespace_id: 123)
+ environments.create!(id: 1, name: "production", slug: "production", project_id: 1)
+ deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: "master", sha: "xxx", tag: false, status: 1)
end
- it 'does not fill finished_at' do
+ it "does not fill finished_at" do
expect(deployments.last.created_at).not_to be_nil
expect(deployments.last.finished_at).to be_nil
@@ -47,17 +47,17 @@ describe FillEmptyFinishedAtInDeployments, :migration do
end
end
- context 'when a deployment row does has a value on finished_at' do
- let(:finished_at) { '2018-10-30 11:12:02 UTC' }
+ context "when a deployment row does has a value on finished_at" do
+ let(:finished_at) { "2018-10-30 11:12:02 UTC" }
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
- environments.create!(id: 1, name: 'production', slug: 'production', project_id: 1)
- deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: 'master', sha: 'xxx', tag: false, finished_at: finished_at)
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1", namespace_id: 123)
+ environments.create!(id: 1, name: "production", slug: "production", project_id: 1)
+ deployments.create!(id: 1, iid: 1, project_id: 1, environment_id: 1, ref: "master", sha: "xxx", tag: false, finished_at: finished_at)
end
- it 'does not affect existing value' do
+ it "does not affect existing value" do
expect(deployments.last.created_at).not_to be_nil
expect(deployments.last.finished_at).not_to be_nil
diff --git a/spec/migrations/fill_file_store_spec.rb b/spec/migrations/fill_file_store_spec.rb
index 5ff7aa56ce2..09addda35f1 100644
--- a/spec/migrations/fill_file_store_spec.rb
+++ b/spec/migrations/fill_file_store_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180424151928_fill_file_store')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180424151928_fill_file_store")
describe FillFileStore, :migration do
let(:namespaces) { table(:namespaces) }
@@ -10,18 +10,18 @@ describe FillFileStore, :migration do
let(:uploads) { table(:uploads) }
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1", namespace_id: 123)
builds.create!(id: 1)
##
# Create rows that have nullfied `file_store` column
job_artifacts.create!(project_id: 123, job_id: 1, file_type: 1, file_store: nil)
- lfs_objects.create!(oid: 123, size: 10, file: 'file_name', file_store: nil)
- uploads.create!(size: 10, path: 'path', uploader: 'uploader', mount_point: 'file_name', store: nil)
+ lfs_objects.create!(oid: 123, size: 10, file: "file_name", file_store: nil)
+ uploads.create!(size: 10, path: "path", uploader: "uploader", mount_point: "file_name", store: nil)
end
- it 'correctly migrates nullified file_store/store column' do
+ it "correctly migrates nullified file_store/store column" do
expect(job_artifacts.where(file_store: nil).count).to eq(1)
expect(lfs_objects.where(file_store: nil).count).to eq(1)
expect(uploads.where(store: nil).count).to eq(1)
diff --git a/spec/migrations/fix_null_type_labels_spec.rb b/spec/migrations/fix_null_type_labels_spec.rb
index 462ae9b913f..3d5ce72ee1f 100644
--- a/spec/migrations/fix_null_type_labels_spec.rb
+++ b/spec/migrations/fix_null_type_labels_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20190131122559_fix_null_type_labels')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20190131122559_fix_null_type_labels")
describe FixNullTypeLabels, :migration do
let(:migration) { described_class.new }
@@ -10,27 +10,27 @@ describe FixNullTypeLabels, :migration do
let(:labels) { table(:labels) }
before do
- group = namespaces.create(name: 'labels-test-project', path: 'labels-test-project', type: 'Group')
- project = projects.create!(namespace_id: group.id, name: 'labels-test-group', path: 'labels-test-group')
+ group = namespaces.create(name: "labels-test-project", path: "labels-test-project", type: "Group")
+ project = projects.create!(namespace_id: group.id, name: "labels-test-group", path: "labels-test-group")
- @template_label = labels.create(title: 'template', template: true)
- @project_label = labels.create(title: 'project label', project_id: project.id, type: 'ProjectLabel')
- @group_label = labels.create(title: 'group_label', group_id: group.id, type: 'GroupLabel')
- @broken_label_1 = labels.create(title: 'broken 1', project_id: project.id)
- @broken_label_2 = labels.create(title: 'broken 2', project_id: project.id)
+ @template_label = labels.create(title: "template", template: true)
+ @project_label = labels.create(title: "project label", project_id: project.id, type: "ProjectLabel")
+ @group_label = labels.create(title: "group_label", group_id: group.id, type: "GroupLabel")
+ @broken_label_1 = labels.create(title: "broken 1", project_id: project.id)
+ @broken_label_2 = labels.create(title: "broken 2", project_id: project.id)
end
- describe '#up' do
- it 'fix labels with type missing' do
+ describe "#up" do
+ it "fix labels with type missing" do
migration.up
# Labels that requires type change
- expect(@broken_label_1.reload.type).to eq('ProjectLabel')
- expect(@broken_label_2.reload.type).to eq('ProjectLabel')
+ expect(@broken_label_1.reload.type).to eq("ProjectLabel")
+ expect(@broken_label_2.reload.type).to eq("ProjectLabel")
# Labels out of scope
expect(@template_label.reload.type).to be_nil
- expect(@project_label.reload.type).to eq('ProjectLabel')
- expect(@group_label.reload.type).to eq('GroupLabel')
+ expect(@project_label.reload.type).to eq("ProjectLabel")
+ expect(@group_label.reload.type).to eq("GroupLabel")
end
end
end
diff --git a/spec/migrations/fix_wrongly_renamed_routes_spec.rb b/spec/migrations/fix_wrongly_renamed_routes_spec.rb
index 543cf55f076..63002fdffc3 100644
--- a/spec/migrations/fix_wrongly_renamed_routes_spec.rb
+++ b/spec/migrations/fix_wrongly_renamed_routes_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170518231126_fix_wrongly_renamed_routes.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170518231126_fix_wrongly_renamed_routes.rb")
describe FixWronglyRenamedRoutes, :migration do
let(:subject) { described_class.new }
@@ -7,17 +7,17 @@ describe FixWronglyRenamedRoutes, :migration do
let(:projects_table) { table(:projects) }
let(:routes_table) { table(:routes) }
let(:broken_namespace) do
- namespaces_table.create!(name: 'apiis', path: 'apiis').tap do |namespace|
- routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'api0is', path: 'api0is')
+ namespaces_table.create!(name: "apiis", path: "apiis").tap do |namespace|
+ routes_table.create!(source_type: "Namespace", source_id: namespace.id, name: "api0is", path: "api0is")
end
end
- let(:broken_namespace_route) { routes_table.where(source_type: 'Namespace', source_id: broken_namespace.id).first }
+ let(:broken_namespace_route) { routes_table.where(source_type: "Namespace", source_id: broken_namespace.id).first }
- describe '#wrongly_renamed' do
+ describe "#wrongly_renamed" do
it "includes routes that have names that don't match their namespace" do
broken_namespace
- other_namespace = namespaces_table.create!(name: 'api0', path: 'api0')
- routes_table.create!(source_type: 'Namespace', source_id: other_namespace.id, name: 'api0', path: 'api0')
+ other_namespace = namespaces_table.create!(name: "api0", path: "api0")
+ routes_table.create!(source_type: "Namespace", source_id: other_namespace.id, name: "api0", path: "api0")
expect(subject.wrongly_renamed.map(&:id))
.to contain_exactly(broken_namespace_route.id)
@@ -25,62 +25,62 @@ describe FixWronglyRenamedRoutes, :migration do
end
describe "#paths_and_corrections" do
- it 'finds the wrong path and gets the correction from the namespace' do
+ it "finds the wrong path and gets the correction from the namespace" do
broken_namespace
- namespaces_table.create!(name: 'uploads-test', path: 'uploads-test').tap do |namespace|
- routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'uploads-test', path: 'uploads0-test')
+ namespaces_table.create!(name: "uploads-test", path: "uploads-test").tap do |namespace|
+ routes_table.create!(source_type: "Namespace", source_id: namespace.id, name: "uploads-test", path: "uploads0-test")
end
expected_result = [
- { 'namespace_path' => 'apiis', 'path' => 'api0is' },
- { 'namespace_path' => 'uploads-test', 'path' => 'uploads0-test' }
+ {"namespace_path" => "apiis", "path" => "api0is"},
+ {"namespace_path" => "uploads-test", "path" => "uploads0-test"},
]
expect(subject.paths_and_corrections).to include(*expected_result)
end
end
- describe '#routes_in_namespace_query' do
- it 'includes only the required routes' do
- namespace = namespaces_table.create!(name: 'hello', path: 'hello')
- namespace_route = routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'hello', path: 'hello')
- project = projects_table.new(name: 'my-project', path: 'my-project', namespace_id: namespace.id).tap do |project|
+ describe "#routes_in_namespace_query" do
+ it "includes only the required routes" do
+ namespace = namespaces_table.create!(name: "hello", path: "hello")
+ namespace_route = routes_table.create!(source_type: "Namespace", source_id: namespace.id, name: "hello", path: "hello")
+ project = projects_table.new(name: "my-project", path: "my-project", namespace_id: namespace.id).tap do |project|
project.save!(validate: false)
end
- routes_table.create!(source_type: 'Project', source_id: project.id, name: 'my-project', path: 'hello/my-project')
- _other_namespace = namespaces_table.create!(name: 'hello0', path: 'hello0')
+ routes_table.create!(source_type: "Project", source_id: project.id, name: "my-project", path: "hello/my-project")
+ _other_namespace = namespaces_table.create!(name: "hello0", path: "hello0")
- result = routes_table.where(subject.routes_in_namespace_query('hello'))
- project_route = routes_table.where(source_type: 'Project', source_id: project.id).first
+ result = routes_table.where(subject.routes_in_namespace_query("hello"))
+ project_route = routes_table.where(source_type: "Project", source_id: project.id).first
expect(result).to contain_exactly(namespace_route, project_route)
end
end
- describe '#up' do
- it 'renames incorrectly named routes' do
+ describe "#up" do
+ it "renames incorrectly named routes" do
broken_project =
- projects_table.new(name: 'broken-project', path: 'broken-project', namespace_id: broken_namespace.id).tap do |project|
+ projects_table.new(name: "broken-project", path: "broken-project", namespace_id: broken_namespace.id).tap do |project|
project.save!(validate: false)
- routes_table.create!(source_type: 'Project', source_id: project.id, name: 'broken-project', path: 'api0is/broken-project')
+ routes_table.create!(source_type: "Project", source_id: project.id, name: "broken-project", path: "api0is/broken-project")
end
subject.up
- broken_project_route = routes_table.where(source_type: 'Project', source_id: broken_project.id).first
+ broken_project_route = routes_table.where(source_type: "Project", source_id: broken_project.id).first
- expect(broken_project_route.path).to eq('apiis/broken-project')
- expect(broken_namespace_route.reload.path).to eq('apiis')
+ expect(broken_project_route.path).to eq("apiis/broken-project")
+ expect(broken_namespace_route.reload.path).to eq("apiis")
end
it "doesn't touch namespaces that look like something that should be renamed" do
- namespaces_table.create!(name: 'apiis', path: 'apiis')
- namespace = namespaces_table.create!(name: 'hello', path: 'api0')
- namespace_route = routes_table.create!(source_type: 'Namespace', source_id: namespace.id, name: 'hello', path: 'api0')
+ namespaces_table.create!(name: "apiis", path: "apiis")
+ namespace = namespaces_table.create!(name: "hello", path: "api0")
+ namespace_route = routes_table.create!(source_type: "Namespace", source_id: namespace.id, name: "hello", path: "api0")
subject.up
- expect(namespace_route.reload.path).to eq('api0')
+ expect(namespace_route.reload.path).to eq("api0")
end
end
end
diff --git a/spec/migrations/generate_missing_routes_spec.rb b/spec/migrations/generate_missing_routes_spec.rb
index 32515d353b0..8ed784f22bd 100644
--- a/spec/migrations/generate_missing_routes_spec.rb
+++ b/spec/migrations/generate_missing_routes_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180702134423_generate_missing_routes.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180702134423_generate_missing_routes.rb")
describe GenerateMissingRoutes, :migration do
- describe '#up' do
+ describe "#up" do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
let(:routes) { table(:routes) }
- it 'creates routes for projects without a route' do
- namespace = namespaces.create!(name: 'GitLab', path: 'gitlab')
+ it "creates routes for projects without a route" do
+ namespace = namespaces.create!(name: "GitLab", path: "gitlab")
routes.create!(
- path: 'gitlab',
- source_type: 'Namespace',
+ path: "gitlab",
+ source_type: "Namespace",
source_id: namespace.id
)
project = projects.create!(
- name: 'GitLab CE',
- path: 'gitlab-ce',
+ name: "GitLab CE",
+ path: "gitlab-ce",
namespace_id: namespace.id
)
described_class.new.up
- route = routes.where(source_type: 'Project').take
+ route = routes.where(source_type: "Project").take
expect(route.source_id).to eq(project.id)
expect(route.path).to eq("gitlab/gitlab-ce-#{project.id}")
end
- it 'creates routes for namespaces without a route' do
- namespace = namespaces.create!(name: 'GitLab', path: 'gitlab')
+ it "creates routes for namespaces without a route" do
+ namespace = namespaces.create!(name: "GitLab", path: "gitlab")
described_class.new.up
- route = routes.where(source_type: 'Namespace').take
+ route = routes.where(source_type: "Namespace").take
expect(route.source_id).to eq(namespace.id)
expect(route.path).to eq("gitlab-#{namespace.id}")
end
- it 'does not create routes for namespaces that already have a route' do
- namespace = namespaces.create!(name: 'GitLab', path: 'gitlab')
+ it "does not create routes for namespaces that already have a route" do
+ namespace = namespaces.create!(name: "GitLab", path: "gitlab")
routes.create!(
- path: 'gitlab',
- source_type: 'Namespace',
+ path: "gitlab",
+ source_type: "Namespace",
source_id: namespace.id
)
@@ -55,24 +55,24 @@ describe GenerateMissingRoutes, :migration do
expect(routes.count).to eq(1)
end
- it 'does not create routes for projects that already have a route' do
- namespace = namespaces.create!(name: 'GitLab', path: 'gitlab')
+ it "does not create routes for projects that already have a route" do
+ namespace = namespaces.create!(name: "GitLab", path: "gitlab")
routes.create!(
- path: 'gitlab',
- source_type: 'Namespace',
+ path: "gitlab",
+ source_type: "Namespace",
source_id: namespace.id
)
project = projects.create!(
- name: 'GitLab CE',
- path: 'gitlab-ce',
+ name: "GitLab CE",
+ path: "gitlab-ce",
namespace_id: namespace.id
)
routes.create!(
- path: 'gitlab/gitlab-ce',
- source_type: 'Project',
+ path: "gitlab/gitlab-ce",
+ source_type: "Project",
source_id: project.id
)
diff --git a/spec/migrations/import_common_metrics_spec.rb b/spec/migrations/import_common_metrics_spec.rb
index 1001629007c..f3461476b7f 100644
--- a/spec/migrations/import_common_metrics_spec.rb
+++ b/spec/migrations/import_common_metrics_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180831164910_import_common_metrics.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180831164910_import_common_metrics.rb")
describe ImportCommonMetrics, :migration do
- describe '#up' do
+ describe "#up" do
it "imports all prometheus metrics" do
expect(PrometheusMetric.common).to be_empty
diff --git a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb
index 495e86ee888..8fa8e4a3159 100644
--- a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb
+++ b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_foreign_key.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20171106151218_issues_moved_to_id_foreign_key.rb")
# The schema version has to be far enough in advance to have the
# only_mirror_protected_branches column in the projects table to create a
@@ -11,7 +11,7 @@ describe IssuesMovedToIdForeignKey, :migration, schema: 20171114150259 do
subject { described_class.new }
- it 'removes the orphaned moved_to_id' do
+ it "removes the orphaned moved_to_id" do
subject.down
issue_third.update(moved_to_id: 100000)
diff --git a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
index b1ff3cfd355..64b8c9d4262 100644
--- a/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
+++ b/spec/migrations/migrate_auto_dev_ops_domain_to_cluster_domain_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20190204115450_migrate_auto_dev_ops_domain_to_cluster_domain.rb")
describe MigrateAutoDevOpsDomainToClusterDomain, :migration do
include MigrationHelpers::ClusterHelpers
@@ -22,34 +22,34 @@ describe MigrateAutoDevOpsDomainToClusterDomain, :migration do
setup_cluster_projects_with_domain(quantity: 20, domain: domain)
end
- context 'with ProjectAutoDevOps with no domain' do
+ context "with ProjectAutoDevOps with no domain" do
let(:domain) { nil }
- it 'should not update cluster project' do
+ it "should not update cluster project" do
migrate!
expect(clusters_without_domain.count).to eq(clusters_table.count)
end
end
- context 'with ProjectAutoDevOps with domain' do
- let(:domain) { 'example-domain.com' }
+ context "with ProjectAutoDevOps with domain" do
+ let(:domain) { "example-domain.com" }
- it 'should update all cluster projects' do
+ it "should update all cluster projects" do
migrate!
expect(clusters_with_domain.count).to eq(clusters_table.count)
end
end
- context 'when only some ProjectAutoDevOps have domain set' do
- let(:domain) { 'example-domain.com' }
+ context "when only some ProjectAutoDevOps have domain set" do
+ let(:domain) { "example-domain.com" }
before do
setup_cluster_projects_with_domain(quantity: 25, domain: nil)
end
- it 'should only update specific cluster projects' do
+ it "should only update specific cluster projects" do
migrate!
expect(clusters_with_domain.count).to eq(20)
diff --git a/spec/migrations/migrate_build_stage_reference_again_spec.rb b/spec/migrations/migrate_build_stage_reference_again_spec.rb
index 6be480ce58e..f616969a815 100644
--- a/spec/migrations/migrate_build_stage_reference_again_spec.rb
+++ b/spec/migrations/migrate_build_stage_reference_again_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170526190000_migrate_build_stage_reference_again.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170526190000_migrate_build_stage_reference_again.rb")
describe MigrateBuildStageReferenceAgain, :migration do
##
@@ -14,36 +14,36 @@ describe MigrateBuildStageReferenceAgain, :migration do
before do
# Create projects
#
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2')
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 456, name: "gitlab2", path: "gitlab2")
# Create CI/CD pipelines
#
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
- pipelines.create!(id: 2, project_id: 456, ref: 'feature', sha: '21a3deb')
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
+ pipelines.create!(id: 2, project_id: 456, ref: "feature", sha: "21a3deb")
# Create CI/CD jobs
#
- jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test')
- jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy')
- jobs.create!(id: 5, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2')
- jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1')
- jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1')
- jobs.create!(id: 8, commit_id: 3, project_id: 789, stage_idx: 3, stage: 'deploy')
+ jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: "test")
+ jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: "deploy")
+ jobs.create!(id: 5, commit_id: 2, project_id: 456, stage_idx: 2, stage: "test:2")
+ jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 1, stage: "test:1")
+ jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 1, stage: "test:1")
+ jobs.create!(id: 8, commit_id: 3, project_id: 789, stage_idx: 3, stage: "deploy")
# Create CI/CD stages
#
- stages.create(id: 101, pipeline_id: 1, project_id: 123, name: 'test')
- stages.create(id: 102, pipeline_id: 1, project_id: 123, name: 'build')
- stages.create(id: 103, pipeline_id: 1, project_id: 123, name: 'deploy')
- stages.create(id: 104, pipeline_id: 2, project_id: 456, name: 'test:1')
- stages.create(id: 105, pipeline_id: 2, project_id: 456, name: 'test:2')
- stages.create(id: 106, pipeline_id: 2, project_id: 456, name: 'deploy')
+ stages.create(id: 101, pipeline_id: 1, project_id: 123, name: "test")
+ stages.create(id: 102, pipeline_id: 1, project_id: 123, name: "build")
+ stages.create(id: 103, pipeline_id: 1, project_id: 123, name: "deploy")
+ stages.create(id: 104, pipeline_id: 2, project_id: 456, name: "test:1")
+ stages.create(id: 105, pipeline_id: 2, project_id: 456, name: "test:2")
+ stages.create(id: 106, pipeline_id: 2, project_id: 456, name: "deploy")
end
- it 'correctly migrate build stage references' do
+ it "correctly migrate build stage references" do
expect(jobs.where(stage_id: nil).count).to eq 8
migrate!
diff --git a/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb b/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
index b2d8f476bb2..af7312f5576 100644
--- a/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
+++ b/spec/migrations/migrate_cluster_configure_worker_sidekiq_queue_spec.rb
@@ -1,60 +1,60 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181219145520_migrate_cluster_configure_worker_sidekiq_queue.rb")
describe MigrateClusterConfigureWorkerSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queue' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queue" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'gcp_cluster:cluster_platform_configure').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:cluster_configure').perform_async('Something', [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_platform_configure").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_configure").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('gcp_cluster:cluster_platform_configure')).to eq 0
- expect(sidekiq_queue_length('gcp_cluster:cluster_configure')).to eq 2
+ expect(sidekiq_queue_length("gcp_cluster:cluster_platform_configure")).to eq 0
+ expect(sidekiq_queue_length("gcp_cluster:cluster_configure")).to eq 2
end
end
- it 'does not affect other queues under the same namespace' do
+ it "does not affect other queues under the same namespace" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'gcp_cluster:cluster_install_app').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:cluster_provision').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:cluster_wait_for_app_installation').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:wait_for_cluster_creation').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:cluster_wait_for_ingress_ip_address').perform_async('Something', [1])
- stubbed_worker(queue: 'gcp_cluster:cluster_project_configure').perform_async('Something', [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_install_app").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_provision").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_wait_for_app_installation").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:wait_for_cluster_creation").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_wait_for_ingress_ip_address").perform_async("Something", [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_project_configure").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('gcp_cluster:cluster_install_app')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:cluster_provision')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:cluster_wait_for_app_installation')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:wait_for_cluster_creation')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:cluster_wait_for_ingress_ip_address')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:cluster_project_configure')).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_install_app")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_provision")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_wait_for_app_installation")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:wait_for_cluster_creation")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_wait_for_ingress_ip_address")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_project_configure")).to eq 1
end
end
- it 'correctly migrates queue when migrating down' do
+ it "correctly migrates queue when migrating down" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'gcp_cluster:cluster_configure').perform_async('Something', [1])
+ stubbed_worker(queue: "gcp_cluster:cluster_configure").perform_async("Something", [1])
described_class.new.down
- expect(sidekiq_queue_length('gcp_cluster:cluster_platform_configure')).to eq 1
- expect(sidekiq_queue_length('gcp_cluster:cluster_configure')).to eq 0
+ expect(sidekiq_queue_length("gcp_cluster:cluster_platform_configure")).to eq 1
+ expect(sidekiq_queue_length("gcp_cluster:cluster_configure")).to eq 0
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
- it 'does not raise error when migrating down' do
+ it "does not raise error when migrating down" do
expect { described_class.new.down }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb b/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb
index c18ae3b76d3..16a6898024c 100644
--- a/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb
+++ b/spec/migrations/migrate_create_trace_artifact_sidekiq_queue_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180306074045_migrate_create_trace_artifact_sidekiq_queue.rb")
describe MigrateCreateTraceArtifactSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queues' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queues" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_default:create_trace_artifact').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_background:archive_trace').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_default:create_trace_artifact").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_background:archive_trace").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('pipeline_default:create_trace_artifact')).to eq 0
- expect(sidekiq_queue_length('pipeline_background:archive_trace')).to eq 2
+ expect(sidekiq_queue_length("pipeline_default:create_trace_artifact")).to eq 0
+ expect(sidekiq_queue_length("pipeline_background:archive_trace")).to eq 2
end
end
- it 'does not affect other queues under the same namespace' do
+ it "does not affect other queues under the same namespace" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_default:build_coverage').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:build_trace_sections').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:pipeline_metrics').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:pipeline_notification').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:update_head_pipeline_for_merge_request').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_default:build_coverage").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:build_trace_sections").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:pipeline_metrics").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:pipeline_notification").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:update_head_pipeline_for_merge_request").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('pipeline_default:build_coverage')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:build_trace_sections')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:pipeline_metrics')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:pipeline_notification')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:update_head_pipeline_for_merge_request')).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:build_coverage")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:build_trace_sections")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:pipeline_metrics")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:pipeline_notification")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:update_head_pipeline_for_merge_request")).to eq 1
end
end
- it 'correctly migrates queue when migrating down' do
+ it "correctly migrates queue when migrating down" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_background:archive_trace').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_background:archive_trace").perform_async("Something", [1])
described_class.new.down
- expect(sidekiq_queue_length('pipeline_default:create_trace_artifact')).to eq 1
- expect(sidekiq_queue_length('pipeline_background:archive_trace')).to eq 0
+ expect(sidekiq_queue_length("pipeline_default:create_trace_artifact")).to eq 1
+ expect(sidekiq_queue_length("pipeline_background:archive_trace")).to eq 0
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
- it 'does not raise error when migrating down' do
+ it "does not raise error when migrating down" do
expect { described_class.new.down }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_forbidden_redirect_uris_spec.rb b/spec/migrations/migrate_forbidden_redirect_uris_spec.rb
index 0bc13a3974a..659cb751bee 100644
--- a/spec/migrations/migrate_forbidden_redirect_uris_spec.rb
+++ b/spec/migrations/migrate_forbidden_redirect_uris_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181026091631_migrate_forbidden_redirect_uris.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181026091631_migrate_forbidden_redirect_uris.rb")
describe MigrateForbiddenRedirectUris, :migration do
let(:oauth_application) { table(:oauth_applications) }
@@ -9,40 +9,40 @@ describe MigrateForbiddenRedirectUris, :migration do
let!(:control_app) { oauth_application.create(random_params) }
let!(:control_access_grant) { oauth_application.create(random_params) }
- let!(:forbidden_js_app) { oauth_application.create(random_params.merge(redirect_uri: 'javascript://alert()')) }
- let!(:forbidden_vb_app) { oauth_application.create(random_params.merge(redirect_uri: 'VBSCRIPT://alert()')) }
- let!(:forbidden_access_grant) { oauth_application.create(random_params.merge(redirect_uri: 'vbscript://alert()')) }
+ let!(:forbidden_js_app) { oauth_application.create(random_params.merge(redirect_uri: "javascript://alert()")) }
+ let!(:forbidden_vb_app) { oauth_application.create(random_params.merge(redirect_uri: "VBSCRIPT://alert()")) }
+ let!(:forbidden_access_grant) { oauth_application.create(random_params.merge(redirect_uri: "vbscript://alert()")) }
- context 'oauth application' do
- it 'migrates forbidden javascript URI' do
- expect { migrate! }.to change { forbidden_js_app.reload.redirect_uri }.to('http://forbidden-scheme-has-been-overwritten')
+ context "oauth application" do
+ it "migrates forbidden javascript URI" do
+ expect { migrate! }.to change { forbidden_js_app.reload.redirect_uri }.to("http://forbidden-scheme-has-been-overwritten")
end
- it 'migrates forbidden VBScript URI' do
- expect { migrate! }.to change { forbidden_vb_app.reload.redirect_uri }.to('http://forbidden-scheme-has-been-overwritten')
+ it "migrates forbidden VBScript URI" do
+ expect { migrate! }.to change { forbidden_vb_app.reload.redirect_uri }.to("http://forbidden-scheme-has-been-overwritten")
end
- it 'does not migrate a valid URI' do
+ it "does not migrate a valid URI" do
expect { migrate! }.not_to change { control_app.reload.redirect_uri }
end
end
- context 'access grant' do
- it 'migrates forbidden VBScript URI' do
- expect { migrate! }.to change { forbidden_access_grant.reload.redirect_uri }.to('http://forbidden-scheme-has-been-overwritten')
+ context "access grant" do
+ it "migrates forbidden VBScript URI" do
+ expect { migrate! }.to change { forbidden_access_grant.reload.redirect_uri }.to("http://forbidden-scheme-has-been-overwritten")
end
- it 'does not migrate a valid URI' do
+ it "does not migrate a valid URI" do
expect { migrate! }.not_to change { control_access_grant.reload.redirect_uri }
end
end
def random_params
{
- name: 'test',
- secret: 'test',
+ name: "test",
+ secret: "test",
uid: Doorkeeper::OAuth::Helpers::UniqueToken.generate,
- redirect_uri: 'http://valid.com'
+ redirect_uri: "http://valid.com",
}
end
end
diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
index ba4c66057d4..ca0cdb1f5b1 100644
--- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
+++ b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171013104327_migrate_gcp_clusters_to_new_clusters_architectures.rb")
describe MigrateGcpClustersToNewClustersArchitectures, :migration do
let(:projects) { table(:projects) }
@@ -10,20 +10,20 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
module GcpMigrationSpec
class KubernetesService < ActiveRecord::Base
- self.table_name = 'services'
+ self.table_name = "services"
serialize :properties, JSON
default_value_for :active, true
- default_value_for :type, 'KubernetesService'
+ default_value_for :type, "KubernetesService"
default_value_for :properties, {
- api_url: 'https://kubernetes.example.com',
- token: 'a' * 40
+ api_url: "https://kubernetes.example.com",
+ token: "a" * 40,
}
end
end
- context 'when cluster is being created' do
+ context "when cluster is being created" do
let(:project_id) { project.id }
let(:user_id) { user.id }
let(:service_id) { service.id }
@@ -34,18 +34,18 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
let(:enabled) { true }
let(:status_reason) { "''" }
let(:project_namespace) { "'sample-app'" }
- let(:endpoint) { 'NULL' }
- let(:ca_cert) { 'NULL' }
- let(:encrypted_kubernetes_token) { 'NULL' }
- let(:encrypted_kubernetes_token_iv) { 'NULL' }
- let(:username) { 'NULL' }
- let(:encrypted_password) { 'NULL' }
- let(:encrypted_password_iv) { 'NULL' }
+ let(:endpoint) { "NULL" }
+ let(:ca_cert) { "NULL" }
+ let(:encrypted_kubernetes_token) { "NULL" }
+ let(:encrypted_kubernetes_token_iv) { "NULL" }
+ let(:username) { "NULL" }
+ let(:encrypted_password) { "NULL" }
+ let(:encrypted_password_iv) { "NULL" }
let(:gcp_project_id) { "'gcp_project_id'" }
let(:gcp_cluster_zone) { "'gcp_cluster_zone'" }
let(:gcp_cluster_name) { "'gcp_cluster_name'" }
let(:gcp_machine_type) { "'gcp_machine_type'" }
- let(:gcp_operation_id) { 'NULL' }
+ let(:gcp_operation_id) { "NULL" }
let(:encrypted_gcp_token) { "'encrypted_gcp_token'" }
let(:encrypted_gcp_token_iv) { "'encrypted_gcp_token_iv'" }
@@ -59,7 +59,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
SQL
end
- it 'correctly migrate to new clusters architectures' do
+ it "correctly migrate to new clusters architectures" do
migrate!
expect(described_class::Cluster.count).to eq(1)
@@ -70,8 +70,8 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
expect(cluster.user_id).to eq(user.id)
expect(cluster.enabled).to be_truthy
expect(cluster.name).to eq(gcp_cluster_name.delete!("'"))
- expect(cluster.provider_type).to eq('gcp')
- expect(cluster.platform_type).to eq('kubernetes')
+ expect(cluster.provider_type).to eq("gcp")
+ expect(cluster.platform_type).to eq("kubernetes")
expect(cluster.project_ids).to include(project.id)
@@ -99,7 +99,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
end
end
- context 'when cluster has been created' do
+ context "when cluster has been created" do
let(:project_id) { project.id }
let(:user_id) { user.id }
let(:service_id) { service.id }
@@ -135,7 +135,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
SQL
end
- it 'correctly migrate to new clusters architectures' do
+ it "correctly migrate to new clusters architectures" do
migrate!
expect(described_class::Cluster.count).to eq(1)
@@ -146,8 +146,8 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
expect(cluster.user_id).to eq(user.id)
expect(cluster.enabled).to be_truthy
expect(cluster.name).to eq(tr(gcp_cluster_name))
- expect(cluster.provider_type).to eq('gcp')
- expect(cluster.platform_type).to eq('kubernetes')
+ expect(cluster.provider_type).to eq("gcp")
+ expect(cluster.platform_type).to eq("kubernetes")
expect(cluster.project_ids).to include(project.id)
@@ -164,7 +164,7 @@ describe MigrateGcpClustersToNewClustersArchitectures, :migration do
expect(cluster.provider_gcp.encrypted_access_token_iv).to eq(tr(encrypted_gcp_token_iv))
expect(cluster.platform_kubernetes.cluster_id).to eq(cluster.id)
- expect(cluster.platform_kubernetes.api_url).to eq('https://' + tr(endpoint))
+ expect(cluster.platform_kubernetes.api_url).to eq("https://" + tr(endpoint))
expect(cluster.platform_kubernetes.ca_cert).to eq(tr(ca_cert))
expect(cluster.platform_kubernetes.namespace).to eq(tr(project_namespace))
expect(cluster.platform_kubernetes.username).to eq(tr(username))
diff --git a/spec/migrations/migrate_import_attributes_data_from_projects_to_project_mirror_data_spec.rb b/spec/migrations/migrate_import_attributes_data_from_projects_to_project_mirror_data_spec.rb
index 972c6dffc6f..23f0e9049ac 100644
--- a/spec/migrations/migrate_import_attributes_data_from_projects_to_project_mirror_data_spec.rb
+++ b/spec/migrations/migrate_import_attributes_data_from_projects_to_project_mirror_data_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb")
describe MigrateImportAttributesDataFromProjectsToProjectMirrorData, :sidekiq, :migration do
let(:namespaces) { table(:namespaces) }
@@ -8,18 +8,18 @@ describe MigrateImportAttributesDataFromProjectsToProjectMirrorData, :sidekiq, :
before do
stub_const("#{described_class}::BATCH_SIZE", 1)
- namespaces.create(id: 1, name: 'gitlab-org', path: 'gitlab-org')
+ namespaces.create(id: 1, name: "gitlab-org", path: "gitlab-org")
- projects.create!(id: 1, namespace_id: 1, name: 'gitlab1',
- path: 'gitlab1', import_error: "foo", import_status: :started,
+ projects.create!(id: 1, namespace_id: 1, name: "gitlab1",
+ path: "gitlab1", import_error: "foo", import_status: :started,
import_url: generate(:url))
- projects.create!(id: 2, namespace_id: 1, name: 'gitlab2',
- path: 'gitlab2', import_error: "bar", import_status: :failed,
+ projects.create!(id: 2, namespace_id: 1, name: "gitlab2",
+ path: "gitlab2", import_error: "bar", import_status: :failed,
import_url: generate(:url))
- projects.create!(id: 3, namespace_id: 1, name: 'gitlab3', path: 'gitlab3', import_status: :none, import_url: generate(:url))
+ projects.create!(id: 3, namespace_id: 1, name: "gitlab3", path: "gitlab3", import_status: :none, import_url: generate(:url))
end
- it 'schedules delayed background migrations in batches in bulk' do
+ it "schedules delayed background migrations in batches in bulk" do
Sidekiq::Testing.fake! do
Timecop.freeze do
expect(projects.where.not(import_status: :none).count).to eq(2)
@@ -33,13 +33,13 @@ describe MigrateImportAttributesDataFromProjectsToProjectMirrorData, :sidekiq, :
end
end
- describe '#down' do
+ describe "#down" do
before do
import_state.create!(id: 1, project_id: 1, status: :started)
import_state.create!(id: 2, project_id: 2, status: :started)
end
- it 'schedules delayed background migrations in batches in bulk for rollback' do
+ it "schedules delayed background migrations in batches in bulk for rollback" do
Sidekiq::Testing.fake! do
Timecop.freeze do
expect(import_state.where.not(status: :none).count).to eq(2)
diff --git a/spec/migrations/migrate_issues_to_ghost_user_spec.rb b/spec/migrations/migrate_issues_to_ghost_user_spec.rb
index 0016f058a17..9b3f9b305ad 100644
--- a/spec/migrations/migrate_issues_to_ghost_user_spec.rb
+++ b/spec/migrations/migrate_issues_to_ghost_user_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170825104051_migrate_issues_to_ghost_user.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170825104051_migrate_issues_to_ghost_user.rb")
describe MigrateIssuesToGhostUser, :migration do
- describe '#up' do
+ describe "#up" do
let(:projects) { table(:projects) }
let(:issues) { table(:issues) }
let(:users) { table(:users) }
before do
- project = projects.create!(name: 'gitlab', namespace_id: 1)
- user = users.create(email: 'test@example.com')
- issues.create(title: 'Issue 1', author_id: nil, project_id: project.id)
- issues.create(title: 'Issue 2', author_id: user.id, project_id: project.id)
+ project = projects.create!(name: "gitlab", namespace_id: 1)
+ user = users.create(email: "test@example.com")
+ issues.create(title: "Issue 1", author_id: nil, project_id: project.id)
+ issues.create(title: "Issue 2", author_id: user.id, project_id: project.id)
end
- context 'when ghost user exists' do
- let!(:ghost) { users.create(ghost: true, email: 'ghost@example.com') }
+ context "when ghost user exists" do
+ let!(:ghost) { users.create(ghost: true, email: "ghost@example.com") }
- it 'does not create a new user' do
+ it "does not create a new user" do
expect { migrate! }.not_to change { User.count }
end
- it 'migrates issues where author = nil to the ghost user' do
+ it "migrates issues where author = nil to the ghost user" do
migrate!
expect(issues.first.reload.author_id).to eq(ghost.id)
end
- it 'does not change issues authored by an existing user' do
+ it "does not change issues authored by an existing user" do
expect { migrate! }.not_to change { issues.second.reload.author_id}
end
end
- context 'when ghost user does not exist' do
- it 'creates a new user' do
+ context "when ghost user does not exist" do
+ it "creates a new user" do
expect { migrate! }.to change { User.count }.by(1)
end
- it 'migrates issues where author = nil to the ghost user' do
+ it "migrates issues where author = nil to the ghost user" do
migrate!
expect(issues.first.reload.author_id).to eq(User.ghost.id)
end
- it 'does not change issues authored by an existing user' do
+ it "does not change issues authored by an existing user" do
expect { migrate! }.not_to change { issues.second.reload.author_id}
end
end
diff --git a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
index df0015b6dd3..e36b0762ddf 100644
--- a/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
+++ b/spec/migrations/migrate_kubernetes_service_to_new_clusters_architectures_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171124104327_migrate_kubernetes_service_to_new_clusters_architectures.rb")
describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
- context 'when unique KubernetesService exists' do
- shared_examples 'KubernetesService migration' do
+ context "when unique KubernetesService exists" do
+ shared_examples "KubernetesService migration" do
let(:sample_num) { 2 }
let(:projects) do
@@ -17,13 +17,14 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: active,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"namespace\":\"prod\",\"api_url\":\"https://kubernetes#{project.id}.com\",\"ca_pem\":\"ca_pem#{project.id}\",\"token\":\"token#{project.id}\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"namespace\":\"prod\",\"api_url\":\"https://kubernetes#{project.id}.com\",\"ca_pem\":\"ca_pem#{project.id}\",\"token\":\"token#{project.id}\"}"
+ )
end
end
- it 'migrates the KubernetesService to Platform::Kubernetes' do
+ it "migrates the KubernetesService to Platform::Kubernetes" do
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(sample_num)
projects.each do |project|
@@ -38,14 +39,14 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when KubernetesService is active' do
+ context "when KubernetesService is active" do
let(:active) { true }
- it_behaves_like 'KubernetesService migration'
+ it_behaves_like "KubernetesService migration"
end
end
- context 'when unique KubernetesService spawned from Service Template' do
+ context "when unique KubernetesService spawned from Service Template" do
let(:sample_num) { 2 }
let(:projects) do
@@ -57,22 +58,24 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
let!(:kubernetes_service_template) do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
template: true,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"namespace\":\"prod\",\"api_url\":\"https://sample.kubernetes.com\",\"ca_pem\":\"ca_pem-sample\",\"token\":\"token-sample\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"namespace\":\"prod\",\"api_url\":\"https://sample.kubernetes.com\",\"ca_pem\":\"ca_pem-sample\",\"token\":\"token-sample\"}"
+ )
end
let!(:kubernetes_services) do
projects.map do |project|
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"namespace\":\"prod\",\"api_url\":\"#{kubernetes_service_template.api_url}\",\"ca_pem\":\"#{kubernetes_service_template.ca_pem}\",\"token\":\"#{kubernetes_service_template.token}\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"namespace\":\"prod\",\"api_url\":\"#{kubernetes_service_template.api_url}\",\"ca_pem\":\"#{kubernetes_service_template.ca_pem}\",\"token\":\"#{kubernetes_service_template.token}\"}"
+ )
end
end
- it 'migrates the KubernetesService to Platform::Kubernetes without template' do
+ it "migrates the KubernetesService to Platform::Kubernetes without template" do
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(sample_num)
projects.each do |project|
@@ -86,32 +89,34 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when managed KubernetesService exists' do
+ context "when managed KubernetesService exists" do
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
let(:cluster) do
MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!(
projects: [project],
- name: 'sample-cluster',
+ name: "sample-cluster",
platform_type: :kubernetes,
provider_type: :user,
platform_kubernetes_attributes: {
- api_url: 'https://sample.kubernetes.com',
- ca_cert: 'ca_pem-sample',
- token: 'token-sample'
- } )
+ api_url: "https://sample.kubernetes.com",
+ ca_cert: "ca_pem-sample",
+ token: "token-sample",
+ }
+ )
end
let!(:kubernetes_service) do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: cluster.enabled,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"api_url\":\"#{cluster.platform_kubernetes.api_url}\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"api_url\":\"#{cluster.platform_kubernetes.api_url}\"}"
+ )
end
- it 'does not migrate the KubernetesService and disables the kubernetes_service' do # Because the corresponding Platform::Kubernetes already exists
+ it "does not migrate the KubernetesService and disables the kubernetes_service" do # Because the corresponding Platform::Kubernetes already exists
expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }
kubernetes_service.reload
@@ -119,38 +124,40 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when production cluster has already been existed' do # i.e. There are no environment_scope conflicts
+ context "when production cluster has already been existed" do # i.e. There are no environment_scope conflicts
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
let(:cluster) do
MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!(
projects: [project],
- name: 'sample-cluster',
+ name: "sample-cluster",
platform_type: :kubernetes,
provider_type: :user,
- environment_scope: 'production/*',
+ environment_scope: "production/*",
platform_kubernetes_attributes: {
- api_url: 'https://sample.kubernetes.com',
- ca_cert: 'ca_pem-sample',
- token: 'token-sample'
- } )
+ api_url: "https://sample.kubernetes.com",
+ ca_cert: "ca_pem-sample",
+ token: "token-sample",
+ }
+ )
end
let!(:kubernetes_service) do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: true,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"api_url\":\"https://debug.kube.com\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"api_url\":\"https://debug.kube.com\"}"
+ )
end
- it 'migrates the KubernetesService to Platform::Kubernetes' do
+ it "migrates the KubernetesService to Platform::Kubernetes" do
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1)
kubernetes_service.reload
project.clusters.last.tap do |cluster|
- expect(cluster.environment_scope).to eq('*')
+ expect(cluster.environment_scope).to eq("*")
expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem)
expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token)
@@ -159,38 +166,40 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when default cluster has already been existed' do
+ context "when default cluster has already been existed" do
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
let!(:cluster) do
MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!(
projects: [project],
- name: 'sample-cluster',
+ name: "sample-cluster",
platform_type: :kubernetes,
provider_type: :user,
- environment_scope: '*',
+ environment_scope: "*",
platform_kubernetes_attributes: {
- api_url: 'https://sample.kubernetes.com',
- ca_cert: 'ca_pem-sample',
- token: 'token-sample'
- } )
+ api_url: "https://sample.kubernetes.com",
+ ca_cert: "ca_pem-sample",
+ token: "token-sample",
+ }
+ )
end
let!(:kubernetes_service) do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: true,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"api_url\":\"https://debug.kube.com\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"api_url\":\"https://debug.kube.com\"}"
+ )
end
- it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated
+ it "migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope" do # Because environment_scope is duplicated
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1)
kubernetes_service.reload
project.clusters.last.tap do |cluster|
- expect(cluster.environment_scope).to eq('migrated/*')
+ expect(cluster.environment_scope).to eq("migrated/*")
expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem)
expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token)
@@ -199,52 +208,55 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when default cluster and migrated cluster has already been existed' do
+ context "when default cluster and migrated cluster has already been existed" do
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
let!(:cluster) do
MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!(
projects: [project],
- name: 'sample-cluster',
+ name: "sample-cluster",
platform_type: :kubernetes,
provider_type: :user,
- environment_scope: '*',
+ environment_scope: "*",
platform_kubernetes_attributes: {
- api_url: 'https://sample.kubernetes.com',
- ca_cert: 'ca_pem-sample',
- token: 'token-sample'
- } )
+ api_url: "https://sample.kubernetes.com",
+ ca_cert: "ca_pem-sample",
+ token: "token-sample",
+ }
+ )
end
let!(:migrated_cluster) do
MigrateKubernetesServiceToNewClustersArchitectures::Cluster.create!(
projects: [project],
- name: 'sample-cluster',
+ name: "sample-cluster",
platform_type: :kubernetes,
provider_type: :user,
- environment_scope: 'migrated/*',
+ environment_scope: "migrated/*",
platform_kubernetes_attributes: {
- api_url: 'https://sample.kubernetes.com',
- ca_cert: 'ca_pem-sample',
- token: 'token-sample'
- } )
+ api_url: "https://sample.kubernetes.com",
+ ca_cert: "ca_pem-sample",
+ token: "token-sample",
+ }
+ )
end
let!(:kubernetes_service) do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: true,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"api_url\":\"https://debug.kube.com\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"api_url\":\"https://debug.kube.com\"}"
+ )
end
- it 'migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope' do # Because environment_scope is duplicated
+ it "migrates the KubernetesService to Platform::Kubernetes with dedicated environment_scope" do # Because environment_scope is duplicated
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1)
kubernetes_service.reload
project.clusters.last.tap do |cluster|
- expect(cluster.environment_scope).to eq('migrated0/*')
+ expect(cluster.environment_scope).to eq("migrated0/*")
expect(cluster.platform_kubernetes.api_url).to eq(kubernetes_service.api_url)
expect(cluster.platform_kubernetes.ca_cert).to eq(kubernetes_service.ca_pem)
expect(cluster.platform_kubernetes.token).to eq(kubernetes_service.token)
@@ -253,19 +265,20 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
end
end
- context 'when KubernetesService has nullified parameters' do
+ context "when KubernetesService has nullified parameters" do
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
before do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: false,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{}"
+ )
end
- it 'does not migrate the KubernetesService and disables the kubernetes_service' do
+ it "does not migrate the KubernetesService and disables the kubernetes_service" do
expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }
expect(project.kubernetes_service).not_to be_active
@@ -276,36 +289,37 @@ describe MigrateKubernetesServiceToNewClustersArchitectures, :migration do
# whereas KubernetesService validates `token` if only it's activated
# However, in this migration file, there are no validations because of the re-defined model class
# therefore, we should safely add this raw to Platform::Kubernetes
- context 'when KubernetesService has empty token' do
+ context "when KubernetesService has empty token" do
let(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
before do
MigrateKubernetesServiceToNewClustersArchitectures::Service.create!(
project: project,
active: false,
- category: 'deployment',
- type: 'KubernetesService',
- properties: "{\"namespace\":\"prod\",\"api_url\":\"http://111.111.111.111\",\"ca_pem\":\"a\",\"token\":\"\"}")
+ category: "deployment",
+ type: "KubernetesService",
+ properties: "{\"namespace\":\"prod\",\"api_url\":\"http://111.111.111.111\",\"ca_pem\":\"a\",\"token\":\"\"}"
+ )
end
- it 'does not migrate the KubernetesService and disables the kubernetes_service' do
+ it "does not migrate the KubernetesService and disables the kubernetes_service" do
expect { migrate! }.to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }.by(1)
project.clusters.last.tap do |cluster|
- expect(cluster.environment_scope).to eq('*')
- expect(cluster.platform_kubernetes.namespace).to eq('prod')
- expect(cluster.platform_kubernetes.api_url).to eq('http://111.111.111.111')
- expect(cluster.platform_kubernetes.ca_cert).to eq('a')
+ expect(cluster.environment_scope).to eq("*")
+ expect(cluster.platform_kubernetes.namespace).to eq("prod")
+ expect(cluster.platform_kubernetes.api_url).to eq("http://111.111.111.111")
+ expect(cluster.platform_kubernetes.ca_cert).to eq("a")
expect(cluster.platform_kubernetes.token).to be_empty
expect(project.kubernetes_service).not_to be_active
end
end
end
- context 'when KubernetesService does not exist' do
+ context "when KubernetesService does not exist" do
let!(:project) { MigrateKubernetesServiceToNewClustersArchitectures::Project.create! }
- it 'does not migrate the KubernetesService' do
+ it "does not migrate the KubernetesService" do
expect { migrate! }.not_to change { MigrateKubernetesServiceToNewClustersArchitectures::Cluster.count }
end
end
diff --git a/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb b/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb
index df82672f254..cc4e2cbdcd8 100644
--- a/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb
+++ b/spec/migrations/migrate_legacy_artifacts_to_job_artifacts_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180816161409_migrate_legacy_artifacts_to_job_artifacts.rb")
describe MigrateLegacyArtifactsToJobArtifacts, :migration, :sidekiq do
let(:migration_class) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts }
@@ -10,26 +10,26 @@ describe MigrateLegacyArtifactsToJobArtifacts, :migration, :sidekiq do
let(:pipelines) { table(:ci_pipelines) }
let(:jobs) { table(:ci_builds) }
let(:job_artifacts) { table(:ci_job_artifacts) }
- let(:namespace) { namespaces.create!(name: 'gitlab', path: 'gitlab-org') }
- let(:project) { projects.create!(name: 'gitlab', path: 'gitlab-ce', namespace_id: namespace.id) }
- let(:pipeline) { pipelines.create!(project_id: project.id, ref: 'master', sha: 'adf43c3a') }
+ let(:namespace) { namespaces.create!(name: "gitlab", path: "gitlab-org") }
+ let(:project) { projects.create!(name: "gitlab", path: "gitlab-ce", namespace_id: namespace.id) }
+ let(:pipeline) { pipelines.create!(project_id: project.id, ref: "master", sha: "adf43c3a") }
let(:archive_file_type) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::ARCHIVE_FILE_TYPE }
let(:metadata_file_type) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::METADATA_FILE_TYPE }
let(:local_store) { ::ObjectStorage::Store::LOCAL }
let(:remote_store) { ::ObjectStorage::Store::REMOTE }
let(:legacy_location) { Gitlab::BackgroundMigration::MigrateLegacyArtifacts::LEGACY_PATH_FILE_LOCATION }
- context 'when legacy artifacts exist' do
+ context "when legacy artifacts exist" do
before do
- jobs.create!(id: 1, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: 'archive.zip')
- jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: 'metadata.gz')
- jobs.create!(id: 3, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: 'archive.zip', artifacts_metadata: 'metadata.gz')
+ jobs.create!(id: 1, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: "archive.zip")
+ jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: "metadata.gz")
+ jobs.create!(id: 3, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: "archive.zip", artifacts_metadata: "metadata.gz")
jobs.create!(id: 4, commit_id: pipeline.id, project_id: project.id, status: :running)
- jobs.create!(id: 5, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: 'archive.zip', artifacts_file_store: remote_store, artifacts_metadata: 'metadata.gz')
- jobs.create!(id: 6, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: 'archive.zip', artifacts_metadata: 'metadata.gz')
+ jobs.create!(id: 5, commit_id: pipeline.id, project_id: project.id, status: :success, artifacts_file: "archive.zip", artifacts_file_store: remote_store, artifacts_metadata: "metadata.gz")
+ jobs.create!(id: 6, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_file: "archive.zip", artifacts_metadata: "metadata.gz")
end
- it 'schedules a background migration' do
+ it "schedules a background migration" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -40,27 +40,27 @@ describe MigrateLegacyArtifactsToJobArtifacts, :migration, :sidekiq do
end
end
- it 'migrates legacy artifacts to ci_job_artifacts table' do
+ it "migrates legacy artifacts to ci_job_artifacts table" do
migrate!
- expect(job_artifacts.order(:job_id, :file_type).pluck('project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location'))
- .to eq([[project.id, 1, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 3, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 3, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location],
- [project.id, 5, archive_file_type, remote_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 5, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location],
- [project.id, 6, archive_file_type, local_store, nil, nil, 'archive.zip', nil, legacy_location],
- [project.id, 6, metadata_file_type, local_store, nil, nil, 'metadata.gz', nil, legacy_location]])
+ expect(job_artifacts.order(:job_id, :file_type).pluck("project_id, job_id, file_type, file_store, size, expire_at, file, file_sha256, file_location"))
+ .to eq([[project.id, 1, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 3, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 3, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],
+ [project.id, 5, archive_file_type, remote_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 5, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],
+ [project.id, 6, archive_file_type, local_store, nil, nil, "archive.zip", nil, legacy_location],
+ [project.id, 6, metadata_file_type, local_store, nil, nil, "metadata.gz", nil, legacy_location],])
end
end
- context 'when legacy artifacts do not exist' do
+ context "when legacy artifacts do not exist" do
before do
jobs.create!(id: 1, commit_id: pipeline.id, project_id: project.id, status: :success)
- jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: 'metadata.gz')
+ jobs.create!(id: 2, commit_id: pipeline.id, project_id: project.id, status: :failed, artifacts_metadata: "metadata.gz")
end
- it 'does not schedule background migrations' do
+ it "does not schedule background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
diff --git a/spec/migrations/migrate_null_wiki_access_levels_spec.rb b/spec/migrations/migrate_null_wiki_access_levels_spec.rb
index f99273072a2..74162bb94b4 100644
--- a/spec/migrations/migrate_null_wiki_access_levels_spec.rb
+++ b/spec/migrations/migrate_null_wiki_access_levels_spec.rb
@@ -1,28 +1,28 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180809195358_migrate_null_wiki_access_levels.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180809195358_migrate_null_wiki_access_levels.rb")
describe MigrateNullWikiAccessLevels, :migration do
- let(:namespaces) { table('namespaces') }
+ let(:namespaces) { table("namespaces") }
let(:projects) { table(:projects) }
let(:project_features) { table(:project_features) }
let(:migration) { described_class.new }
before do
- namespace = namespaces.create(name: 'foo', path: 'foo')
+ namespace = namespaces.create(name: "foo", path: "foo")
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1', namespace_id: namespace.id)
- projects.create!(id: 2, name: 'gitlab2', path: 'gitlab2', namespace_id: namespace.id)
- projects.create!(id: 3, name: 'gitlab3', path: 'gitlab3', namespace_id: namespace.id)
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1", namespace_id: namespace.id)
+ projects.create!(id: 2, name: "gitlab2", path: "gitlab2", namespace_id: namespace.id)
+ projects.create!(id: 3, name: "gitlab3", path: "gitlab3", namespace_id: namespace.id)
project_features.create!(id: 1, project_id: 1, wiki_access_level: nil)
project_features.create!(id: 2, project_id: 2, wiki_access_level: 10)
project_features.create!(id: 3, project_id: 3, wiki_access_level: 20)
end
- describe '#up' do
- it 'migrates existing project_features with wiki_access_level NULL to 20' do
+ describe "#up" do
+ it "migrates existing project_features with wiki_access_level NULL to 20" do
expect { migration.up }.to change { project_features.where(wiki_access_level: 20).count }.by(1)
end
end
diff --git a/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb b/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb
index 1ee6c440cf4..d77724f5185 100644
--- a/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb
+++ b/spec/migrations/migrate_object_storage_upload_sidekiq_queue_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180603190921_migrate_object_storage_upload_sidekiq_queue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180603190921_migrate_object_storage_upload_sidekiq_queue.rb")
describe MigrateObjectStorageUploadSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queue' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queue" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'object_storage_upload').perform_async('Something', [1])
- stubbed_worker(queue: 'object_storage:object_storage_background_move').perform_async('Something', [1])
+ stubbed_worker(queue: "object_storage_upload").perform_async("Something", [1])
+ stubbed_worker(queue: "object_storage:object_storage_background_move").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('object_storage_upload')).to eq 0
- expect(sidekiq_queue_length('object_storage:object_storage_background_move')).to eq 2
+ expect(sidekiq_queue_length("object_storage_upload")).to eq 0
+ expect(sidekiq_queue_length("object_storage:object_storage_background_move")).to eq 2
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_old_artifacts_spec.rb b/spec/migrations/migrate_old_artifacts_spec.rb
index af77d64fdbf..0bd51c3e13c 100644
--- a/spec/migrations/migrate_old_artifacts_spec.rb
+++ b/spec/migrations/migrate_old_artifacts_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170523083112_migrate_old_artifacts.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170523083112_migrate_old_artifacts.rb")
describe MigrateOldArtifacts do
let(:migration) { described_class.new }
@@ -15,7 +13,7 @@ describe MigrateOldArtifacts do
FileUtils.remove_entry_secure(directory)
end
- context 'with migratable data' do
+ context "with migratable data" do
set(:project1) { create(:project, ci_id: 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
set(:project2) { create(:project, ci_id: 3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
set(:project3) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -43,47 +41,47 @@ describe MigrateOldArtifacts do
expect(build_with_legacy_artifacts.legacy_artifacts_file_identifier).not_to be_nil
end
- describe '#min_id' do
+ describe "#min_id" do
subject { migration.send(:min_id) }
- it 'returns the newest build for which ci_id is not defined' do
+ it "returns the newest build for which ci_id is not defined" do
is_expected.to eq(build3.id)
end
end
- describe '#builds_with_artifacts' do
+ describe "#builds_with_artifacts" do
subject { migration.send(:builds_with_artifacts).map(&:id) }
- it 'returns a list of builds that has artifacts and could be migrated' do
+ it "returns a list of builds that has artifacts and could be migrated" do
is_expected.to contain_exactly(build_with_legacy_artifacts.id, build2.id)
end
end
- describe '#up' do
- context 'when migrating artifacts' do
+ describe "#up" do
+ context "when migrating artifacts" do
before do
migration.up
end
- it 'all files do have artifacts' do
+ it "all files do have artifacts" do
Ci::Build.with_artifacts_archive do |build|
expect(build).to have_artifacts
end
end
- it 'artifacts are no longer present on legacy path' do
+ it "artifacts are no longer present on legacy path" do
expect(File.exist?(legacy_path(build_with_legacy_artifacts))).to eq(false)
end
end
- context 'when there are artifacts in old and new directory' do
+ context "when there are artifacts in old and new directory" do
before do
store_artifacts_in_legacy_path(build2)
migration.up
end
- it 'does not move old files' do
+ it "does not move old files" do
expect(File.exist?(legacy_path(build2))).to eq(true)
end
end
@@ -95,32 +93,35 @@ describe MigrateOldArtifacts do
FileUtils.mkdir_p(legacy_path(build))
FileUtils.copy(
- Rails.root.join('spec/fixtures/ci_build_artifacts.zip'),
- File.join(legacy_path(build), "ci_build_artifacts.zip"))
+ Rails.root.join("spec/fixtures/ci_build_artifacts.zip"),
+ File.join(legacy_path(build), "ci_build_artifacts.zip")
+ )
FileUtils.copy(
- Rails.root.join('spec/fixtures/ci_build_artifacts_metadata.gz'),
- File.join(legacy_path(build), "ci_build_artifacts_metadata.gz"))
+ Rails.root.join("spec/fixtures/ci_build_artifacts_metadata.gz"),
+ File.join(legacy_path(build), "ci_build_artifacts_metadata.gz")
+ )
build.update_columns(
- artifacts_file: 'ci_build_artifacts.zip',
- artifacts_metadata: 'ci_build_artifacts_metadata.gz')
+ artifacts_file: "ci_build_artifacts.zip",
+ artifacts_metadata: "ci_build_artifacts_metadata.gz"
+ )
build.reload
end
def legacy_path(build)
File.join(directory,
- build.created_at.utc.strftime('%Y_%m'),
+ build.created_at.utc.strftime("%Y_%m"),
build.project.ci_id.to_s,
build.id.to_s)
end
def new_legacy_path(build)
File.join(directory,
- build.created_at.utc.strftime('%Y_%m'),
- build.project_id.to_s,
- build.id.to_s)
+ build.created_at.utc.strftime("%Y_%m"),
+ build.project_id.to_s,
+ build.id.to_s)
end
def setup_builds(*builds)
@@ -128,8 +129,9 @@ describe MigrateOldArtifacts do
FileUtils.mkdir_p(new_legacy_path(build))
build.update_columns(
- artifacts_file: 'ci_build_artifacts.zip',
- artifacts_metadata: 'ci_build_artifacts_metadata.gz')
+ artifacts_file: "ci_build_artifacts.zip",
+ artifacts_metadata: "ci_build_artifacts_metadata.gz"
+ )
build.reload
end
diff --git a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
index e02bcd2f4da..3bb52ffe26e 100644
--- a/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
+++ b/spec/migrations/migrate_pipeline_sidekiq_queues_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170822101017_migrate_pipeline_sidekiq_queues.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170822101017_migrate_pipeline_sidekiq_queues.rb")
describe MigratePipelineSidekiqQueues, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queues' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queues" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: :pipeline).perform_async('Something', [1])
- stubbed_worker(queue: :build).perform_async('Something', [1])
+ stubbed_worker(queue: :pipeline).perform_async("Something", [1])
+ stubbed_worker(queue: :build).perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('pipeline')).to eq 0
- expect(sidekiq_queue_length('build')).to eq 0
- expect(sidekiq_queue_length('pipeline_default')).to eq 2
+ expect(sidekiq_queue_length("pipeline")).to eq 0
+ expect(sidekiq_queue_length("build")).to eq 0
+ expect(sidekiq_queue_length("pipeline_default")).to eq 2
end
end
- it 'correctly migrates queue when migrating down' do
+ it "correctly migrates queue when migrating down" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: :pipeline_default).perform_async('Class', [1])
- stubbed_worker(queue: :pipeline_processing).perform_async('Class', [2])
- stubbed_worker(queue: :pipeline_hooks).perform_async('Class', [3])
- stubbed_worker(queue: :pipeline_cache).perform_async('Class', [4])
+ stubbed_worker(queue: :pipeline_default).perform_async("Class", [1])
+ stubbed_worker(queue: :pipeline_processing).perform_async("Class", [2])
+ stubbed_worker(queue: :pipeline_hooks).perform_async("Class", [3])
+ stubbed_worker(queue: :pipeline_cache).perform_async("Class", [4])
described_class.new.down
- expect(sidekiq_queue_length('pipeline')).to eq 4
- expect(sidekiq_queue_length('pipeline_default')).to eq 0
- expect(sidekiq_queue_length('pipeline_processing')).to eq 0
- expect(sidekiq_queue_length('pipeline_hooks')).to eq 0
- expect(sidekiq_queue_length('pipeline_cache')).to eq 0
+ expect(sidekiq_queue_length("pipeline")).to eq 4
+ expect(sidekiq_queue_length("pipeline_default")).to eq 0
+ expect(sidekiq_queue_length("pipeline_processing")).to eq 0
+ expect(sidekiq_queue_length("pipeline_hooks")).to eq 0
+ expect(sidekiq_queue_length("pipeline_cache")).to eq 0
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
- it 'does not raise error when migrating down' do
+ it "does not raise error when migrating down" do
expect { described_class.new.down }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_pipeline_stages_spec.rb b/spec/migrations/migrate_pipeline_stages_spec.rb
index c47f2bb8ff9..f1d0d9b72d5 100644
--- a/spec/migrations/migrate_pipeline_stages_spec.rb
+++ b/spec/migrations/migrate_pipeline_stages_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170526185842_migrate_pipeline_stages.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170526185842_migrate_pipeline_stages.rb")
describe MigratePipelineStages, :migration do
##
@@ -14,31 +14,31 @@ describe MigratePipelineStages, :migration do
before do
# Create projects
#
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2')
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 456, name: "gitlab2", path: "gitlab2")
# Create CI/CD pipelines
#
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
- pipelines.create!(id: 2, project_id: 456, ref: 'feature', sha: '21a3deb')
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
+ pipelines.create!(id: 2, project_id: 456, ref: "feature", sha: "21a3deb")
# Create CI/CD jobs
#
- jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test')
- jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test')
- jobs.create!(id: 5, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy')
- jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 3, stage: 'deploy')
- jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2')
- jobs.create!(id: 8, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1')
- jobs.create!(id: 9, commit_id: 2, project_id: 456, stage_idx: 1, stage: 'test:1')
- jobs.create!(id: 10, commit_id: 2, project_id: 456, stage_idx: 2, stage: 'test:2')
- jobs.create!(id: 11, commit_id: 3, project_id: 456, stage_idx: 3, stage: 'deploy')
- jobs.create!(id: 12, commit_id: 2, project_id: 789, stage_idx: 3, stage: 'deploy')
+ jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: "test")
+ jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 1, stage: "test")
+ jobs.create!(id: 5, commit_id: 1, project_id: 123, stage_idx: 3, stage: "deploy")
+ jobs.create!(id: 6, commit_id: 2, project_id: 456, stage_idx: 3, stage: "deploy")
+ jobs.create!(id: 7, commit_id: 2, project_id: 456, stage_idx: 2, stage: "test:2")
+ jobs.create!(id: 8, commit_id: 2, project_id: 456, stage_idx: 1, stage: "test:1")
+ jobs.create!(id: 9, commit_id: 2, project_id: 456, stage_idx: 1, stage: "test:1")
+ jobs.create!(id: 10, commit_id: 2, project_id: 456, stage_idx: 2, stage: "test:2")
+ jobs.create!(id: 11, commit_id: 3, project_id: 456, stage_idx: 3, stage: "deploy")
+ jobs.create!(id: 12, commit_id: 2, project_id: 789, stage_idx: 3, stage: "deploy")
end
- it 'correctly migrates pipeline stages' do
+ it "correctly migrates pipeline stages" do
expect(stages.count).to be_zero
migrate!
diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
index 6219a67c900..a4a4e5d204c 100644
--- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
+++ b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20161124141322_migrate_process_commit_worker_jobs.rb")
describe MigrateProcessCommitWorkerJobs do
set(:project) { create(:project, :legacy_storage, :repository) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -10,14 +8,14 @@ describe MigrateProcessCommitWorkerJobs do
Gitlab::Git::Commit.last(project.repository.raw)
end
- describe 'Project' do
- describe 'find_including_path' do
- it 'returns Project instances' do
+ describe "Project" do
+ describe "find_including_path" do
+ it "returns Project instances" do
expect(described_class::Project.find_including_path(project.id))
.to be_an_instance_of(described_class::Project)
end
- it 'selects the full path for every Project' do
+ it "selects the full path for every Project" do
migration_project = described_class::Project
.find_including_path(project.id)
@@ -26,8 +24,8 @@ describe MigrateProcessCommitWorkerJobs do
end
end
- describe '#repository' do
- it 'returns a mock implemention of ::Repository' do
+ describe "#repository" do
+ it "returns a mock implemention of ::Repository" do
migration_project = described_class::Project
.find_including_path(project.id)
@@ -37,25 +35,25 @@ describe MigrateProcessCommitWorkerJobs do
end
end
- describe '#up', :clean_gitlab_redis_shared_state do
+ describe "#up", :clean_gitlab_redis_shared_state do
let(:migration) { described_class.new }
def job_count
- Sidekiq.redis { |r| r.llen('queue:process_commit') }
+ Sidekiq.redis { |r| r.llen("queue:process_commit") }
end
def pop_job
- JSON.parse(Sidekiq.redis { |r| r.lpop('queue:process_commit') })
+ JSON.parse(Sidekiq.redis { |r| r.lpop("queue:process_commit") })
end
before do
Sidekiq.redis do |redis|
job = JSON.dump(args: [project.id, user.id, commit.id])
- redis.lpush('queue:process_commit', job)
+ redis.lpush("queue:process_commit", job)
end
end
- it 'skips jobs using a project that no longer exists' do
+ it "skips jobs using a project that no longer exists" do
allow(described_class::Project).to receive(:find_including_path)
.with(project.id)
.and_return(nil)
@@ -65,7 +63,7 @@ describe MigrateProcessCommitWorkerJobs do
expect(job_count).to eq(0)
end
- it 'skips jobs using commits that no longer exist' do
+ it "skips jobs using commits that no longer exist" do
allow_any_instance_of(Gitlab::GitalyClient::CommitService)
.to receive(:find_commit)
.with(commit.id)
@@ -76,15 +74,15 @@ describe MigrateProcessCommitWorkerJobs do
expect(job_count).to eq(0)
end
- it 'inserts migrated jobs back into the queue' do
+ it "inserts migrated jobs back into the queue" do
migration.up
expect(job_count).to eq(1)
end
- it 'encodes data to UTF-8' do
+ it "encodes data to UTF-8" do
allow(commit).to receive(:body)
- .and_return('김치'.force_encoding('BINARY'))
+ .and_return("김치".force_encoding("BINARY"))
migration.up
@@ -93,104 +91,104 @@ describe MigrateProcessCommitWorkerJobs do
# We don't care so much about what is being stored, instead we just want
# to make sure the encoding is right so that JSON encoding the data
# doesn't produce any errors.
- expect(job['args'][2]['message'].encoding).to eq(Encoding::UTF_8)
+ expect(job["args"][2]["message"].encoding).to eq(Encoding::UTF_8)
end
- context 'a migrated job' do
+ context "a migrated job" do
let(:job) do
migration.up
pop_job
end
let(:commit_hash) do
- job['args'][2]
+ job["args"][2]
end
- it 'includes the project ID' do
- expect(job['args'][0]).to eq(project.id)
+ it "includes the project ID" do
+ expect(job["args"][0]).to eq(project.id)
end
- it 'includes the user ID' do
- expect(job['args'][1]).to eq(user.id)
+ it "includes the user ID" do
+ expect(job["args"][1]).to eq(user.id)
end
- it 'includes the commit ID' do
- expect(commit_hash['id']).to eq(commit.id)
+ it "includes the commit ID" do
+ expect(commit_hash["id"]).to eq(commit.id)
end
- it 'includes the commit message' do
- expect(commit_hash['message']).to eq(commit.message)
+ it "includes the commit message" do
+ expect(commit_hash["message"]).to eq(commit.message)
end
- it 'includes the parent IDs' do
- expect(commit_hash['parent_ids']).to eq(commit.parent_ids)
+ it "includes the parent IDs" do
+ expect(commit_hash["parent_ids"]).to eq(commit.parent_ids)
end
- it 'includes the author date' do
- expect(commit_hash['authored_date']).to eq(commit.authored_date.to_s)
+ it "includes the author date" do
+ expect(commit_hash["authored_date"]).to eq(commit.authored_date.to_s)
end
- it 'includes the author name' do
- expect(commit_hash['author_name']).to eq(commit.author_name)
+ it "includes the author name" do
+ expect(commit_hash["author_name"]).to eq(commit.author_name)
end
- it 'includes the author Email' do
- expect(commit_hash['author_email']).to eq(commit.author_email)
+ it "includes the author Email" do
+ expect(commit_hash["author_email"]).to eq(commit.author_email)
end
- it 'includes the commit date' do
- expect(commit_hash['committed_date']).to eq(commit.committed_date.to_s)
+ it "includes the commit date" do
+ expect(commit_hash["committed_date"]).to eq(commit.committed_date.to_s)
end
- it 'includes the committer name' do
- expect(commit_hash['committer_name']).to eq(commit.committer_name)
+ it "includes the committer name" do
+ expect(commit_hash["committer_name"]).to eq(commit.committer_name)
end
- it 'includes the committer Email' do
- expect(commit_hash['committer_email']).to eq(commit.committer_email)
+ it "includes the committer Email" do
+ expect(commit_hash["committer_email"]).to eq(commit.committer_email)
end
end
end
- describe '#down', :clean_gitlab_redis_shared_state do
+ describe "#down", :clean_gitlab_redis_shared_state do
let(:migration) { described_class.new }
def job_count
- Sidekiq.redis { |r| r.llen('queue:process_commit') }
+ Sidekiq.redis { |r| r.llen("queue:process_commit") }
end
before do
Sidekiq.redis do |redis|
job = JSON.dump(args: [project.id, user.id, commit.id])
- redis.lpush('queue:process_commit', job)
+ redis.lpush("queue:process_commit", job)
migration.up
end
end
- it 'pushes migrated jobs back into the queue' do
+ it "pushes migrated jobs back into the queue" do
migration.down
expect(job_count).to eq(1)
end
- context 'a migrated job' do
+ context "a migrated job" do
let(:job) do
migration.down
- JSON.parse(Sidekiq.redis { |r| r.lpop('queue:process_commit') })
+ JSON.parse(Sidekiq.redis { |r| r.lpop("queue:process_commit") })
end
- it 'includes the project ID' do
- expect(job['args'][0]).to eq(project.id)
+ it "includes the project ID" do
+ expect(job["args"][0]).to eq(project.id)
end
- it 'includes the user ID' do
- expect(job['args'][1]).to eq(user.id)
+ it "includes the user ID" do
+ expect(job["args"][1]).to eq(user.id)
end
- it 'includes the commit SHA' do
- expect(job['args'][2]).to eq(commit.id)
+ it "includes the commit SHA" do
+ expect(job["args"][2]).to eq(commit.id)
end
end
end
diff --git a/spec/migrations/migrate_remaining_mr_metrics_populating_background_migration_spec.rb b/spec/migrations/migrate_remaining_mr_metrics_populating_background_migration_spec.rb
index 47dab18183c..2c55034d543 100644
--- a/spec/migrations/migrate_remaining_mr_metrics_populating_background_migration_spec.rb
+++ b/spec/migrations/migrate_remaining_mr_metrics_populating_background_migration_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180521162137_migrate_remaining_mr_metrics_populating_background_migration.rb")
describe MigrateRemainingMrMetricsPopulatingBackgroundMigration, :migration, :sidekiq do
let(:namespaces) { table(:namespaces) }
@@ -7,16 +7,16 @@ describe MigrateRemainingMrMetricsPopulatingBackgroundMigration, :migration, :si
let(:mrs) { table(:merge_requests) }
before do
- namespaces.create!(id: 1, name: 'foo', path: 'foo')
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1', namespace_id: 1)
- projects.create!(id: 456, name: 'gitlab2', path: 'gitlab2', namespace_id: 1)
- projects.create!(id: 789, name: 'gitlab3', path: 'gitlab3', namespace_id: 1)
- mrs.create!(title: 'foo', target_branch: 'target', source_branch: 'source', target_project_id: 123)
- mrs.create!(title: 'bar', target_branch: 'target', source_branch: 'source', target_project_id: 456)
- mrs.create!(title: 'kux', target_branch: 'target', source_branch: 'source', target_project_id: 789)
+ namespaces.create!(id: 1, name: "foo", path: "foo")
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1", namespace_id: 1)
+ projects.create!(id: 456, name: "gitlab2", path: "gitlab2", namespace_id: 1)
+ projects.create!(id: 789, name: "gitlab3", path: "gitlab3", namespace_id: 1)
+ mrs.create!(title: "foo", target_branch: "target", source_branch: "source", target_project_id: 123)
+ mrs.create!(title: "bar", target_branch: "target", source_branch: "source", target_project_id: 456)
+ mrs.create!(title: "kux", target_branch: "target", source_branch: "source", target_project_id: 789)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do
diff --git a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb b/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
index dd6f5325750..2ed9b179e7c 100644
--- a/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
+++ b/spec/migrations/migrate_stage_id_reference_in_background_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170628080858_migrate_stage_id_reference_in_background')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170628080858_migrate_stage_id_reference_in_background")
describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
let(:jobs) { table(:ci_builds) }
@@ -11,26 +11,26 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
stub_const("#{described_class.name}::BATCH_SIZE", 3)
stub_const("#{described_class.name}::RANGE_SIZE", 2)
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 345, name: 'gitlab2', path: 'gitlab2')
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 345, name: "gitlab2", path: "gitlab2")
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
- pipelines.create!(id: 2, project_id: 345, ref: 'feature', sha: 'cdf43c3c')
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
+ pipelines.create!(id: 2, project_id: 345, ref: "feature", sha: "cdf43c3c")
- jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
- jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test')
- jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy')
- jobs.create!(id: 5, commit_id: 2, project_id: 345, stage_idx: 1, stage: 'test')
+ jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: "build")
+ jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: "test")
+ jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: "deploy")
+ jobs.create!(id: 5, commit_id: 2, project_id: 345, stage_idx: 1, stage: "test")
- stages.create(id: 101, pipeline_id: 1, project_id: 123, name: 'test')
- stages.create(id: 102, pipeline_id: 1, project_id: 123, name: 'build')
- stages.create(id: 103, pipeline_id: 1, project_id: 123, name: 'deploy')
+ stages.create(id: 101, pipeline_id: 1, project_id: 123, name: "test")
+ stages.create(id: 102, pipeline_id: 1, project_id: 123, name: "build")
+ stages.create(id: 103, pipeline_id: 1, project_id: 123, name: "deploy")
- jobs.create!(id: 6, commit_id: 2, project_id: 345, stage_id: 101, stage_idx: 1, stage: 'test')
+ jobs.create!(id: 6, commit_id: 2, project_id: 345, stage_id: 101, stage_idx: 1, stage: "test")
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -43,7 +43,7 @@ describe MigrateStageIdReferenceInBackground, :migration, :sidekiq do
end
end
- it 'schedules background migrations' do
+ it "schedules background migrations" do
perform_enqueued_jobs do
expect(jobs.where(stage_id: nil).count).to eq 5
diff --git a/spec/migrations/migrate_stages_statuses_spec.rb b/spec/migrations/migrate_stages_statuses_spec.rb
index 5483e24fce7..73d1e4eb7aa 100644
--- a/spec/migrations/migrate_stages_statuses_spec.rb
+++ b/spec/migrations/migrate_stages_statuses_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170711145558_migrate_stages_statuses.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170711145558_migrate_stages_statuses.rb")
describe MigrateStagesStatuses, :sidekiq, :migration do
let(:jobs) { table(:ci_builds) }
@@ -7,45 +7,45 @@ describe MigrateStagesStatuses, :sidekiq, :migration do
let(:pipelines) { table(:ci_pipelines) }
let(:projects) { table(:projects) }
- STATUSES = { created: 0, pending: 1, running: 2, success: 3,
- failed: 4, canceled: 5, skipped: 6, manual: 7 }.freeze
+ STATUSES = {created: 0, pending: 1, running: 2, success: 3,
+ failed: 4, canceled: 5, skipped: 6, manual: 7,}.freeze
before do
stub_const("#{described_class.name}::BATCH_SIZE", 2)
stub_const("#{described_class.name}::RANGE_SIZE", 1)
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 2, name: 'gitlab2', path: 'gitlab2')
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 2, name: "gitlab2", path: "gitlab2")
- pipelines.create!(id: 1, project_id: 1, ref: 'master', sha: 'adf43c3a')
- pipelines.create!(id: 2, project_id: 2, ref: 'feature', sha: '21a3deb')
+ pipelines.create!(id: 1, project_id: 1, ref: "master", sha: "adf43c3a")
+ pipelines.create!(id: 2, project_id: 2, ref: "feature", sha: "21a3deb")
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'success')
- create_job(project: 1, pipeline: 1, stage: 'test', status: 'running')
- create_job(project: 1, pipeline: 1, stage: 'build', status: 'success')
- create_job(project: 1, pipeline: 1, stage: 'build', status: 'failed')
- create_job(project: 2, pipeline: 2, stage: 'test', status: 'success')
- create_job(project: 2, pipeline: 2, stage: 'test', status: 'success')
- create_job(project: 2, pipeline: 2, stage: 'test', status: 'failed', retried: true)
+ create_job(project: 1, pipeline: 1, stage: "test", status: "success")
+ create_job(project: 1, pipeline: 1, stage: "test", status: "running")
+ create_job(project: 1, pipeline: 1, stage: "build", status: "success")
+ create_job(project: 1, pipeline: 1, stage: "build", status: "failed")
+ create_job(project: 2, pipeline: 2, stage: "test", status: "success")
+ create_job(project: 2, pipeline: 2, stage: "test", status: "success")
+ create_job(project: 2, pipeline: 2, stage: "test", status: "failed", retried: true)
- stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: 'test', status: nil)
- stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: 'build', status: nil)
- stages.create!(id: 3, pipeline_id: 2, project_id: 2, name: 'test', status: nil)
+ stages.create!(id: 1, pipeline_id: 1, project_id: 1, name: "test", status: nil)
+ stages.create!(id: 2, pipeline_id: 1, project_id: 1, name: "build", status: nil)
+ stages.create!(id: 3, pipeline_id: 2, project_id: 2, name: "test", status: nil)
end
- it 'correctly migrates stages statuses' do
+ it "correctly migrates stages statuses" do
perform_enqueued_jobs do
expect(stages.where(status: nil).count).to eq 3
migrate!
expect(stages.where(status: nil)).to be_empty
- expect(stages.all.order('id ASC').pluck(:status))
+ expect(stages.all.order("id ASC").pluck(:status))
.to eq [STATUSES[:running], STATUSES[:failed], STATUSES[:success]]
end
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -59,7 +59,7 @@ describe MigrateStagesStatuses, :sidekiq, :migration do
end
def create_job(project:, pipeline:, stage:, status:, **opts)
- stages = { test: 1, build: 2, deploy: 3 }
+ stages = {test: 1, build: 2, deploy: 3}
jobs.create!(project_id: project, commit_id: pipeline,
stage_idx: stages[stage.to_sym], stage: stage,
diff --git a/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb b/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
index f8cf76cb339..844e7d5b422 100644
--- a/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
+++ b/spec/migrations/migrate_storage_migrator_sidekiq_queue_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20190124200344_migrate_storage_migrator_sidekiq_queue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20190124200344_migrate_storage_migrator_sidekiq_queue.rb")
describe MigrateStorageMigratorSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queues' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queues" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
stubbed_worker(queue: :storage_migrator).perform_async(1, 5)
described_class.new.up
- expect(sidekiq_queue_length('storage_migrator')).to eq 0
- expect(sidekiq_queue_length('hashed_storage:hashed_storage_migrator')).to eq 1
+ expect(sidekiq_queue_length("storage_migrator")).to eq 0
+ expect(sidekiq_queue_length("hashed_storage:hashed_storage_migrator")).to eq 1
end
end
- it 'correctly migrates queue when migrating down' do
+ it "correctly migrates queue when migrating down" do
Sidekiq::Testing.disable! do
stubbed_worker(queue: :'hashed_storage:hashed_storage_migrator').perform_async(1, 5)
described_class.new.down
- expect(sidekiq_queue_length('storage_migrator')).to eq 1
- expect(sidekiq_queue_length('hashed_storage:hashed_storage_migrator')).to eq 0
+ expect(sidekiq_queue_length("storage_migrator")).to eq 1
+ expect(sidekiq_queue_length("hashed_storage:hashed_storage_migrator")).to eq 0
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
- it 'does not raise error when migrating down' do
+ it "does not raise error when migrating down" do
expect { described_class.new.down }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb b/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
index 5e3b20ab4a8..a6428469bd7 100644
--- a/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
+++ b/spec/migrations/migrate_update_head_pipeline_for_merge_request_sidekiq_queue_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180307012445_migrate_update_head_pipeline_for_merge_request_sidekiq_queue.rb")
describe MigrateUpdateHeadPipelineForMergeRequestSidekiqQueue, :sidekiq, :redis do
include Gitlab::Database::MigrationHelpers
- context 'when there are jobs in the queues' do
- it 'correctly migrates queue when migrating up' do
+ context "when there are jobs in the queues" do
+ it "correctly migrates queue when migrating up" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_default:update_head_pipeline_for_merge_request').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_processing:update_head_pipeline_for_merge_request').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_default:update_head_pipeline_for_merge_request").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_processing:update_head_pipeline_for_merge_request").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('pipeline_default:update_head_pipeline_for_merge_request')).to eq 0
- expect(sidekiq_queue_length('pipeline_processing:update_head_pipeline_for_merge_request')).to eq 2
+ expect(sidekiq_queue_length("pipeline_default:update_head_pipeline_for_merge_request")).to eq 0
+ expect(sidekiq_queue_length("pipeline_processing:update_head_pipeline_for_merge_request")).to eq 2
end
end
- it 'does not affect other queues under the same namespace' do
+ it "does not affect other queues under the same namespace" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_default:build_coverage').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:build_trace_sections').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:pipeline_metrics').perform_async('Something', [1])
- stubbed_worker(queue: 'pipeline_default:pipeline_notification').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_default:build_coverage").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:build_trace_sections").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:pipeline_metrics").perform_async("Something", [1])
+ stubbed_worker(queue: "pipeline_default:pipeline_notification").perform_async("Something", [1])
described_class.new.up
- expect(sidekiq_queue_length('pipeline_default:build_coverage')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:build_trace_sections')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:pipeline_metrics')).to eq 1
- expect(sidekiq_queue_length('pipeline_default:pipeline_notification')).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:build_coverage")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:build_trace_sections")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:pipeline_metrics")).to eq 1
+ expect(sidekiq_queue_length("pipeline_default:pipeline_notification")).to eq 1
end
end
- it 'correctly migrates queue when migrating down' do
+ it "correctly migrates queue when migrating down" do
Sidekiq::Testing.disable! do
- stubbed_worker(queue: 'pipeline_processing:update_head_pipeline_for_merge_request').perform_async('Something', [1])
+ stubbed_worker(queue: "pipeline_processing:update_head_pipeline_for_merge_request").perform_async("Something", [1])
described_class.new.down
- expect(sidekiq_queue_length('pipeline_default:update_head_pipeline_for_merge_request')).to eq 1
- expect(sidekiq_queue_length('pipeline_processing:update_head_pipeline_for_merge_request')).to eq 0
+ expect(sidekiq_queue_length("pipeline_default:update_head_pipeline_for_merge_request")).to eq 1
+ expect(sidekiq_queue_length("pipeline_processing:update_head_pipeline_for_merge_request")).to eq 0
end
end
end
- context 'when there are no jobs in the queues' do
- it 'does not raise error when migrating up' do
+ context "when there are no jobs in the queues" do
+ it "does not raise error when migrating up" do
expect { described_class.new.up }.not_to raise_error
end
- it 'does not raise error when migrating down' do
+ it "does not raise error when migrating down" do
expect { described_class.new.down }.not_to raise_error
end
end
diff --git a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb
index 99173708190..df5fb5823d1 100644
--- a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb
+++ b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170324160416_migrate_user_activities_to_users_last_activity_on.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170324160416_migrate_user_activities_to_users_last_activity_on.rb")
describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_state, :delete do
let(:migration) { described_class.new }
@@ -24,15 +22,15 @@ describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_
mute_stdout { migration.up }
end
- describe '#up' do
- it 'fills last_activity_on from the legacy Redis Sorted Set' do
+ describe "#up" do
+ it "fills last_activity_on from the legacy Redis Sorted Set" do
expect(user_active_1.reload.last_activity_on).to eq((described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 2.months).to_date)
expect(user_active_2.reload.last_activity_on).to eq((described_class::TIME_WHEN_ACTIVITY_SET_WAS_INTRODUCED + 3.months).to_date)
end
end
- describe '#down' do
- it 'sets last_activity_on to NULL for all users' do
+ describe "#down" do
+ it "sets last_activity_on to NULL for all users" do
mute_stdout { migration.down }
expect(user_active_1.reload.last_activity_on).to be_nil
diff --git a/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb b/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb
index b4834705011..9ad118aade0 100644
--- a/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb
+++ b/spec/migrations/migrate_user_authentication_token_to_personal_access_token_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20171012125712_migrate_user_authentication_token_to_personal_access_token.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20171012125712_migrate_user_authentication_token_to_personal_access_token.rb")
describe MigrateUserAuthenticationTokenToPersonalAccessToken, :migration do
let(:users) { table(:users) }
let(:personal_access_tokens) { table(:personal_access_tokens) }
- let!(:user) { users.create!(id: 1, email: 'user@example.com', authentication_token: 'user-token', admin: false) }
- let!(:admin) { users.create!(id: 2, email: 'admin@example.com', authentication_token: 'admin-token', admin: true) }
+ let!(:user) { users.create!(id: 1, email: "user@example.com", authentication_token: "user-token", admin: false) }
+ let!(:admin) { users.create!(id: 2, email: "admin@example.com", authentication_token: "admin-token", admin: true) }
- it 'migrates private tokens to Personal Access Tokens' do
+ it "migrates private tokens to Personal Access Tokens" do
migrate!
expect(personal_access_tokens.count).to eq(2)
@@ -16,8 +16,8 @@ describe MigrateUserAuthenticationTokenToPersonalAccessToken, :migration do
user_token = personal_access_tokens.find_by(user_id: user.id)
admin_token = personal_access_tokens.find_by(user_id: admin.id)
- expect(user_token.token).to eq('user-token')
- expect(admin_token.token).to eq('admin-token')
+ expect(user_token.token).to eq("user-token")
+ expect(admin_token.token).to eq("admin-token")
expect(user_token.scopes).to eq(%w[api].to_yaml)
expect(admin_token.scopes).to eq(%w[api sudo].to_yaml)
diff --git a/spec/migrations/migrate_user_project_view_spec.rb b/spec/migrations/migrate_user_project_view_spec.rb
index 80468b9d01e..18f3357894d 100644
--- a/spec/migrations/migrate_user_project_view_spec.rb
+++ b/spec/migrations/migrate_user_project_view_spec.rb
@@ -1,17 +1,15 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_project_view.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170406142253_migrate_user_project_view.rb")
describe MigrateUserProjectView, :delete do
let(:migration) { described_class.new }
- let!(:user) { create(:user, project_view: 'readme') } # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ let!(:user) { create(:user, project_view: "readme") } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- describe '#up' do
- it 'updates project view setting with new value' do
+ describe "#up" do
+ it "updates project view setting with new value" do
migration.up
- expect(user.reload.project_view).to eq('files')
+ expect(user.reload.project_view).to eq("files")
end
end
end
diff --git a/spec/migrations/move_personal_snippets_files_spec.rb b/spec/migrations/move_personal_snippets_files_spec.rb
index 1f39ad98fb8..a3f29040a12 100644
--- a/spec/migrations/move_personal_snippets_files_spec.rb
+++ b/spec/migrations/move_personal_snippets_files_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170612071012_move_personal_snippets_files.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170612071012_move_personal_snippets_files.rb")
describe MovePersonalSnippetsFiles do
let(:migration) { described_class.new }
let(:test_dir) { File.join(Rails.root, "tmp", "tests", "move_snippet_files_test") }
- let(:uploads_dir) { File.join(test_dir, 'uploads') }
- let(:new_uploads_dir) { File.join(uploads_dir, '-', 'system') }
+ let(:uploads_dir) { File.join(test_dir, "uploads") }
+ let(:new_uploads_dir) { File.join(uploads_dir, "-", "system") }
before do
allow(CarrierWave).to receive(:root).and_return(test_dir)
@@ -17,21 +17,21 @@ describe MovePersonalSnippetsFiles do
describe "#up" do
let(:snippet) do
snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs
- create_upload('picture.jpg', snippet)
- snippet.update(description: markdown_linking_file('picture.jpg', snippet))
+ create_upload("picture.jpg", snippet)
+ snippet.update(description: markdown_linking_file("picture.jpg", snippet))
snippet
end
let(:snippet_with_missing_file) do
snippet = create(:snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs
- create_upload('picture.jpg', snippet, create_file: false)
- snippet.update(description: markdown_linking_file('picture.jpg', snippet))
+ create_upload("picture.jpg", snippet, create_file: false)
+ snippet.update(description: markdown_linking_file("picture.jpg", snippet))
snippet
end
- it 'moves the files' do
- source_path = File.join(uploads_dir, model_file_path('picture.jpg', snippet))
- destination_path = File.join(new_uploads_dir, model_file_path('picture.jpg', snippet))
+ it "moves the files" do
+ source_path = File.join(uploads_dir, model_file_path("picture.jpg", snippet))
+ destination_path = File.join(new_uploads_dir, model_file_path("picture.jpg", snippet))
migration.up
@@ -39,8 +39,8 @@ describe MovePersonalSnippetsFiles do
expect(File.exist?(destination_path)).to be_truthy
end
- describe 'updating the markdown' do
- it 'includes the new path when the file exists' do
+ describe "updating the markdown" do
+ it "includes the new path when the file exists" do
secret = "secret#{snippet.id}"
file_location = "/uploads/-/system/personal_snippet/#{snippet.id}/#{secret}/picture.jpg"
@@ -49,7 +49,7 @@ describe MovePersonalSnippetsFiles do
expect(snippet.reload.description).to include(file_location)
end
- it 'does not update the markdown when the file is missing' do
+ it "does not update the markdown when the file is missing" do
secret = "secret#{snippet_with_missing_file.id}"
file_location = "/uploads/personal_snippet/#{snippet_with_missing_file.id}/#{secret}/picture.jpg"
@@ -58,10 +58,10 @@ describe MovePersonalSnippetsFiles do
expect(snippet_with_missing_file.reload.description).to include(file_location)
end
- it 'updates the note markdown' do
+ it "updates the note markdown" do
secret = "secret#{snippet.id}"
file_location = "/uploads/-/system/personal_snippet/#{snippet.id}/#{secret}/picture.jpg"
- markdown = markdown_linking_file('picture.jpg', snippet)
+ markdown = markdown_linking_file("picture.jpg", snippet)
note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") # rubocop:disable RSpec/FactoriesInMigrationSpecs
migration.up
@@ -74,21 +74,21 @@ describe MovePersonalSnippetsFiles do
describe "#down" do
let(:snippet) do
snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs
- create_upload('picture.jpg', snippet, in_new_path: true)
- snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true))
+ create_upload("picture.jpg", snippet, in_new_path: true)
+ snippet.update(description: markdown_linking_file("picture.jpg", snippet, in_new_path: true))
snippet
end
let(:snippet_with_missing_file) do
snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs
- create_upload('picture.jpg', snippet, create_file: false, in_new_path: true)
- snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true))
+ create_upload("picture.jpg", snippet, create_file: false, in_new_path: true)
+ snippet.update(description: markdown_linking_file("picture.jpg", snippet, in_new_path: true))
snippet
end
- it 'moves the files' do
- source_path = File.join(new_uploads_dir, model_file_path('picture.jpg', snippet))
- destination_path = File.join(uploads_dir, model_file_path('picture.jpg', snippet))
+ it "moves the files" do
+ source_path = File.join(new_uploads_dir, model_file_path("picture.jpg", snippet))
+ destination_path = File.join(uploads_dir, model_file_path("picture.jpg", snippet))
migration.down
@@ -96,8 +96,8 @@ describe MovePersonalSnippetsFiles do
expect(File.exist?(destination_path)).to be_truthy
end
- describe 'updating the markdown' do
- it 'includes the new path when the file exists' do
+ describe "updating the markdown" do
+ it "includes the new path when the file exists" do
secret = "secret#{snippet.id}"
file_location = "/uploads/personal_snippet/#{snippet.id}/#{secret}/picture.jpg"
@@ -106,7 +106,7 @@ describe MovePersonalSnippetsFiles do
expect(snippet.reload.description).to include(file_location)
end
- it 'keeps the markdown as is when the file is missing' do
+ it "keeps the markdown as is when the file is missing" do
secret = "secret#{snippet_with_missing_file.id}"
file_location = "/uploads/-/system/personal_snippet/#{snippet_with_missing_file.id}/#{secret}/picture.jpg"
@@ -115,8 +115,8 @@ describe MovePersonalSnippetsFiles do
expect(snippet_with_missing_file.reload.description).to include(file_location)
end
- it 'updates the note markdown' do
- markdown = markdown_linking_file('picture.jpg', snippet, in_new_path: true)
+ it "updates the note markdown" do
+ markdown = markdown_linking_file("picture.jpg", snippet, in_new_path: true)
secret = "secret#{snippet.id}"
file_location = "/uploads/personal_snippet/#{snippet.id}/#{secret}/picture.jpg"
note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -128,13 +128,13 @@ describe MovePersonalSnippetsFiles do
end
end
- describe '#update_markdown' do
- it 'escapes sql in the snippet description' do
- migration.instance_variable_set('@source_relative_location', '/uploads/personal_snippet')
- migration.instance_variable_set('@destination_relative_location', '/uploads/system/personal_snippet')
+ describe "#update_markdown" do
+ it "escapes sql in the snippet description" do
+ migration.instance_variable_set("@source_relative_location", "/uploads/personal_snippet")
+ migration.instance_variable_set("@destination_relative_location", "/uploads/system/personal_snippet")
- secret = '123456789'
- filename = 'hello.jpg'
+ secret = "123456789"
+ filename = "hello.jpg"
snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs
path_before = "/uploads/personal_snippet/#{snippet.id}/#{secret}/#{filename}"
@@ -151,10 +151,10 @@ describe MovePersonalSnippetsFiles do
def create_upload(filename, snippet, create_file: true, in_new_path: false)
secret = "secret#{snippet.id}"
absolute_path = if in_new_path
- File.join(new_uploads_dir, model_file_path(filename, snippet))
- else
- File.join(uploads_dir, model_file_path(filename, snippet))
- end
+ File.join(new_uploads_dir, model_file_path(filename, snippet))
+ else
+ File.join(uploads_dir, model_file_path(filename, snippet))
+ end
if create_file
FileUtils.mkdir_p(File.dirname(absolute_path))
@@ -165,9 +165,9 @@ describe MovePersonalSnippetsFiles do
end
def markdown_linking_file(filename, snippet, in_new_path: false)
- markdown = "![#{filename.split('.')[0]}]"
- markdown += '(/uploads'
- markdown += '/-/system' if in_new_path
+ markdown = "![#{filename.split(".")[0]}]"
+ markdown += "(/uploads"
+ markdown += "/-/system" if in_new_path
markdown += "/#{model_file_path(filename, snippet)})"
markdown
end
@@ -175,6 +175,6 @@ describe MovePersonalSnippetsFiles do
def model_file_path(filename, snippet)
secret = "secret#{snippet.id}"
- File.join('personal_snippet', snippet.id.to_s, secret, filename)
+ File.join("personal_snippet", snippet.id.to_s, secret, filename)
end
end
diff --git a/spec/migrations/move_system_upload_folder_spec.rb b/spec/migrations/move_system_upload_folder_spec.rb
index d3180477db3..b659c212ac1 100644
--- a/spec/migrations/move_system_upload_folder_spec.rb
+++ b/spec/migrations/move_system_upload_folder_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
require Rails.root.join("db", "migrate", "20170717074009_move_system_upload_folder.rb")
describe MoveSystemUploadFolder do
let(:migration) { described_class.new }
- let(:test_base) { File.join(Rails.root, 'tmp', 'tests', 'move-system-upload-folder') }
+ let(:test_base) { File.join(Rails.root, "tmp", "tests", "move-system-upload-folder") }
before do
allow(migration).to receive(:base_directory).and_return(test_base)
@@ -12,30 +12,30 @@ describe MoveSystemUploadFolder do
allow(migration).to receive(:say)
end
- describe '#up' do
- let(:test_folder) { File.join(test_base, 'system') }
- let(:test_file) { File.join(test_folder, 'file') }
+ describe "#up" do
+ let(:test_folder) { File.join(test_base, "system") }
+ let(:test_file) { File.join(test_folder, "file") }
before do
FileUtils.mkdir_p(test_folder)
FileUtils.touch(test_file)
end
- it 'moves the related folder' do
+ it "moves the related folder" do
migration.up
- expect(File.exist?(File.join(test_base, '-', 'system', 'file'))).to be_truthy
+ expect(File.exist?(File.join(test_base, "-", "system", "file"))).to be_truthy
end
- it 'creates a symlink linking making the new folder available on the old path' do
+ it "creates a symlink linking making the new folder available on the old path" do
migration.up
- expect(File.symlink?(File.join(test_base, 'system'))).to be_truthy
- expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy
+ expect(File.symlink?(File.join(test_base, "system"))).to be_truthy
+ expect(File.exist?(File.join(test_base, "system", "file"))).to be_truthy
end
- it 'does not move if the target directory already exists' do
- FileUtils.mkdir_p(File.join(test_base, '-', 'system'))
+ it "does not move if the target directory already exists" do
+ FileUtils.mkdir_p(File.join(test_base, "-", "system"))
expect(FileUtils).not_to receive(:mv)
expect(migration).to receive(:say).with(/already exists. No need to redo the move/)
@@ -44,32 +44,32 @@ describe MoveSystemUploadFolder do
end
end
- describe '#down' do
- let(:test_folder) { File.join(test_base, '-', 'system') }
- let(:test_file) { File.join(test_folder, 'file') }
+ describe "#down" do
+ let(:test_folder) { File.join(test_base, "-", "system") }
+ let(:test_file) { File.join(test_folder, "file") }
before do
FileUtils.mkdir_p(test_folder)
FileUtils.touch(test_file)
end
- it 'moves the system folder back to the old location' do
+ it "moves the system folder back to the old location" do
migration.down
- expect(File.exist?(File.join(test_base, 'system', 'file'))).to be_truthy
+ expect(File.exist?(File.join(test_base, "system", "file"))).to be_truthy
end
- it 'removes the symlink if it existed' do
- FileUtils.ln_s(test_folder, File.join(test_base, 'system'))
+ it "removes the symlink if it existed" do
+ FileUtils.ln_s(test_folder, File.join(test_base, "system"))
migration.down
- expect(File.directory?(File.join(test_base, 'system'))).to be_truthy
- expect(File.symlink?(File.join(test_base, 'system'))).to be_falsey
+ expect(File.directory?(File.join(test_base, "system"))).to be_truthy
+ expect(File.symlink?(File.join(test_base, "system"))).to be_falsey
end
- it 'does not move if the old directory already exists' do
- FileUtils.mkdir_p(File.join(test_base, 'system'))
+ it "does not move if the old directory already exists" do
+ FileUtils.mkdir_p(File.join(test_base, "system"))
expect(FileUtils).not_to receive(:mv)
expect(migration).to receive(:say).with(/already exists and is not a symlink, no need to revert/)
diff --git a/spec/migrations/move_uploads_to_system_dir_spec.rb b/spec/migrations/move_uploads_to_system_dir_spec.rb
index ca11a2004c5..79001a0b30d 100644
--- a/spec/migrations/move_uploads_to_system_dir_spec.rb
+++ b/spec/migrations/move_uploads_to_system_dir_spec.rb
@@ -16,21 +16,21 @@ describe MoveUploadsToSystemDir do
describe "#up" do
before do
- FileUtils.mkdir_p(File.join(uploads_dir, 'user'))
- FileUtils.touch(File.join(uploads_dir, 'user', 'dummy.file'))
+ FileUtils.mkdir_p(File.join(uploads_dir, "user"))
+ FileUtils.touch(File.join(uploads_dir, "user", "dummy.file"))
end
- it 'moves the directory to the new path' do
- expected_path = File.join(new_uploads_dir, 'user', 'dummy.file')
+ it "moves the directory to the new path" do
+ expected_path = File.join(new_uploads_dir, "user", "dummy.file")
migration.up
expect(File.exist?(expected_path)).to be(true)
end
- it 'creates a symlink in the old location' do
- symlink_path = File.join(uploads_dir, 'user')
- expected_path = File.join(symlink_path, 'dummy.file')
+ it "creates a symlink in the old location" do
+ symlink_path = File.join(uploads_dir, "user")
+ expected_path = File.join(symlink_path, "dummy.file")
migration.up
@@ -41,23 +41,23 @@ describe MoveUploadsToSystemDir do
describe "#down" do
before do
- FileUtils.mkdir_p(File.join(new_uploads_dir, 'user'))
- FileUtils.touch(File.join(new_uploads_dir, 'user', 'dummy.file'))
+ FileUtils.mkdir_p(File.join(new_uploads_dir, "user"))
+ FileUtils.touch(File.join(new_uploads_dir, "user", "dummy.file"))
end
- it 'moves the directory to the old path' do
- expected_path = File.join(uploads_dir, 'user', 'dummy.file')
+ it "moves the directory to the old path" do
+ expected_path = File.join(uploads_dir, "user", "dummy.file")
migration.down
expect(File.exist?(expected_path)).to be(true)
end
- it 'removes the symlink if it existed' do
- FileUtils.ln_s(File.join(new_uploads_dir, 'user'), File.join(uploads_dir, 'user'))
+ it "removes the symlink if it existed" do
+ FileUtils.ln_s(File.join(new_uploads_dir, "user"), File.join(uploads_dir, "user"))
- directory = File.join(uploads_dir, 'user')
- expected_path = File.join(directory, 'dummy.file')
+ directory = File.join(uploads_dir, "user")
+ expected_path = File.join(directory, "dummy.file")
migration.down
diff --git a/spec/migrations/normalize_ldap_extern_uids_spec.rb b/spec/migrations/normalize_ldap_extern_uids_spec.rb
index a23a5d54e0a..57fb6ca7c75 100644
--- a/spec/migrations/normalize_ldap_extern_uids_spec.rb
+++ b/spec/migrations/normalize_ldap_extern_uids_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170921101004_normalize_ldap_extern_uids')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170921101004_normalize_ldap_extern_uids")
describe NormalizeLdapExternUids, :migration, :sidekiq do
let!(:identities) { table(:identities) }
@@ -14,30 +14,30 @@ describe NormalizeLdapExternUids, :migration, :sidekiq do
# LDAP identities
(1..4).each do |i|
- identities.create!(id: i, provider: 'ldapmain', extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i)
+ identities.create!(id: i, provider: "ldapmain", extern_uid: " uid = foo #{i}, ou = People, dc = example, dc = com ", user_id: i)
end
# Non-LDAP identity
- identities.create!(id: 5, provider: 'foo', extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5)
+ identities.create!(id: 5, provider: "foo", extern_uid: " uid = foo 5, ou = People, dc = example, dc = com ", user_id: 5)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
- expect(BackgroundMigrationWorker.jobs[0]['args']).to eq([described_class::MIGRATION, [1, 2]])
- expect(BackgroundMigrationWorker.jobs[0]['at']).to eq(2.minutes.from_now.to_f)
- expect(BackgroundMigrationWorker.jobs[1]['args']).to eq([described_class::MIGRATION, [3, 4]])
- expect(BackgroundMigrationWorker.jobs[1]['at']).to eq(4.minutes.from_now.to_f)
- expect(BackgroundMigrationWorker.jobs[2]['args']).to eq([described_class::MIGRATION, [5, 5]])
- expect(BackgroundMigrationWorker.jobs[2]['at']).to eq(6.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[0]["args"]).to eq([described_class::MIGRATION, [1, 2]])
+ expect(BackgroundMigrationWorker.jobs[0]["at"]).to eq(2.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[1]["args"]).to eq([described_class::MIGRATION, [3, 4]])
+ expect(BackgroundMigrationWorker.jobs[1]["at"]).to eq(4.minutes.from_now.to_f)
+ expect(BackgroundMigrationWorker.jobs[2]["args"]).to eq([described_class::MIGRATION, [5, 5]])
+ expect(BackgroundMigrationWorker.jobs[2]["at"]).to eq(6.minutes.from_now.to_f)
expect(BackgroundMigrationWorker.jobs.size).to eq 3
end
end
end
- it 'migrates the LDAP identities' do
+ it "migrates the LDAP identities" do
perform_enqueued_jobs do
migrate!
identities.where(id: 1..4).each do |identity|
@@ -46,7 +46,7 @@ describe NormalizeLdapExternUids, :migration, :sidekiq do
end
end
- it 'does not modify non-LDAP identities' do
+ it "does not modify non-LDAP identities" do
perform_enqueued_jobs do
migrate!
identity = identities.last
diff --git a/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb b/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb
index 0ff98933d5c..50656c18bfa 100644
--- a/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb
+++ b/spec/migrations/populate_can_push_from_deploy_keys_projects_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20171215113714_populate_can_push_from_deploy_keys_projects.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20171215113714_populate_can_push_from_deploy_keys_projects.rb")
describe PopulateCanPushFromDeployKeysProjects, :migration do
let(:migration) { described_class.new }
@@ -10,15 +10,15 @@ describe PopulateCanPushFromDeployKeysProjects, :migration do
before do
deploy_keys.inheritance_column = nil
- projects.create!(id: 1, name: 'gitlab1', path: 'gitlab1')
+ projects.create!(id: 1, name: "gitlab1", path: "gitlab1")
(1..10).each do |index|
- deploy_keys.create!(id: index, title: 'dummy', type: 'DeployKey', key: Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + ' dummy@gitlab.com')
+ deploy_keys.create!(id: index, title: "dummy", type: "DeployKey", key: Spec::Support::Helpers::KeyGeneratorHelper.new(1024).generate + " dummy@gitlab.com")
deploy_keys_projects.create!(id: index, deploy_key_id: index, project_id: 1)
end
end
- describe '#up' do
- it 'migrates can_push from deploy_keys to deploy_keys_projects' do
+ describe "#up" do
+ it "migrates can_push from deploy_keys to deploy_keys_projects" do
deploy_keys.limit(5).update_all(can_push: true)
expected = deploy_keys.order(:id).pluck(:id, :can_push)
@@ -29,8 +29,8 @@ describe PopulateCanPushFromDeployKeysProjects, :migration do
end
end
- describe '#down' do
- it 'migrates can_push from deploy_keys_projects to deploy_keys' do
+ describe "#down" do
+ it "migrates can_push from deploy_keys_projects to deploy_keys" do
deploy_keys_projects.limit(5).update_all(can_push: true)
expected = deploy_keys_projects.order(:id).pluck(:deploy_key_id, :can_push)
diff --git a/spec/migrations/populate_mr_metrics_with_events_data_spec.rb b/spec/migrations/populate_mr_metrics_with_events_data_spec.rb
index 291a52b904d..a86bad7d8b6 100644
--- a/spec/migrations/populate_mr_metrics_with_events_data_spec.rb
+++ b/spec/migrations/populate_mr_metrics_with_events_data_spec.rb
@@ -1,29 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181204154019_populate_mr_metrics_with_events_data.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181204154019_populate_mr_metrics_with_events_data.rb")
describe PopulateMrMetricsWithEventsData, :migration, :sidekiq do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) }
- let(:namespace) { namespaces.create(name: 'gitlab', path: 'gitlab-org') }
- let(:project) { projects.create(namespace_id: namespace.id, name: 'foo') }
+ let(:namespace) { namespaces.create(name: "gitlab", path: "gitlab-org") }
+ let(:project) { projects.create(namespace_id: namespace.id, name: "foo") }
let(:merge_requests) { table(:merge_requests) }
def create_merge_request(id)
params = {
id: id,
target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
- source_branch: 'mr name',
- title: "mr name#{id}"
+ source_branch: "mr name",
+ title: "mr name#{id}",
}
merge_requests.create!(params)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
create_merge_request(1)
create_merge_request(2)
create_merge_request(3)
diff --git a/spec/migrations/remove_assignee_id_from_issue_spec.rb b/spec/migrations/remove_assignee_id_from_issue_spec.rb
index 2c6f992d3ae..fb93236adb7 100644
--- a/spec/migrations/remove_assignee_id_from_issue_spec.rb
+++ b/spec/migrations/remove_assignee_id_from_issue_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170523073948_remove_assignee_id_from_issue.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170523073948_remove_assignee_id_from_issue.rb")
describe RemoveAssigneeIdFromIssue, :migration do
let(:issues) { table(:issues) }
let(:issue_assignees) { table(:issue_assignees) }
let(:users) { table(:users) }
- let!(:user_1) { users.create(email: 'email1@example.com') }
- let!(:user_2) { users.create(email: 'email2@example.com') }
- let!(:user_3) { users.create(email: 'email3@example.com') }
+ let!(:user_1) { users.create(email: "email1@example.com") }
+ let!(:user_2) { users.create(email: "email2@example.com") }
+ let!(:user_3) { users.create(email: "email3@example.com") }
def create_issue(assignees:)
issues.create.tap do |issue|
@@ -22,8 +22,8 @@ describe RemoveAssigneeIdFromIssue, :migration do
let!(:issue_no_assignee) { create_issue(assignees: []) }
let!(:issue_multiple_assignees) { create_issue(assignees: [user_2, user_3]) }
- describe '#down' do
- it 'sets the assignee_id to a random matching assignee from the assignees table' do
+ describe "#down" do
+ it "sets the assignee_id to a random matching assignee from the assignees table" do
migrate!
disable_migrations_output { described_class.new.down }
diff --git a/spec/migrations/remove_dot_git_from_usernames_spec.rb b/spec/migrations/remove_dot_git_from_usernames_spec.rb
index f11880a83e9..46d06e01f7b 100644
--- a/spec/migrations/remove_dot_git_from_usernames_spec.rb
+++ b/spec/migrations/remove_dot_git_from_usernames_spec.rb
@@ -1,49 +1,47 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20161226122833_remove_dot_git_from_usernames.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20161226122833_remove_dot_git_from_usernames.rb")
describe RemoveDotGitFromUsernames do
let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let(:migration) { described_class.new }
- describe '#up' do
+ describe "#up" do
before do
- update_namespace(user, 'test.git')
+ update_namespace(user, "test.git")
end
- it 'renames user with .git in username' do
+ it "renames user with .git in username" do
migration.up
- expect(user.reload.username).to eq('test_git')
- expect(user.namespace.reload.path).to eq('test_git')
- expect(user.namespace.route.path).to eq('test_git')
+ expect(user.reload.username).to eq("test_git")
+ expect(user.namespace.reload.path).to eq("test_git")
+ expect(user.namespace.route.path).to eq("test_git")
end
end
- context 'when new path exists already' do
- describe '#up' do
+ context "when new path exists already" do
+ describe "#up" do
let(:user2) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
before do
- update_namespace(user, 'test.git')
- update_namespace(user2, 'test_git')
+ update_namespace(user, "test.git")
+ update_namespace(user2, "test_git")
default_hash = Gitlab.config.repositories.storages.default.to_h
- default_hash['path'] = 'tmp/tests/custom_repositories'
- storages = { 'default' => Gitlab::GitalyClient::StorageSettings.new(default_hash) }
+ default_hash["path"] = "tmp/tests/custom_repositories"
+ storages = {"default" => Gitlab::GitalyClient::StorageSettings.new(default_hash)}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
- allow(migration).to receive(:route_exists?).with('test_git').and_return(true)
- allow(migration).to receive(:route_exists?).with('test_git1').and_return(false)
+ allow(migration).to receive(:route_exists?).with("test_git").and_return(true)
+ allow(migration).to receive(:route_exists?).with("test_git1").and_return(false)
end
- it 'renames user with .git in username' do
+ it "renames user with .git in username" do
migration.up
- expect(user.reload.username).to eq('test_git1')
- expect(user.namespace.reload.path).to eq('test_git1')
- expect(user.namespace.route.path).to eq('test_git1')
+ expect(user.reload.username).to eq("test_git1")
+ expect(user.namespace.reload.path).to eq("test_git1")
+ expect(user.namespace.route.path).to eq("test_git1")
end
end
end
diff --git a/spec/migrations/remove_duplicate_mr_events_spec.rb b/spec/migrations/remove_duplicate_mr_events_spec.rb
index 2509ac6afd6..8763a03b82b 100644
--- a/spec/migrations/remove_duplicate_mr_events_spec.rb
+++ b/spec/migrations/remove_duplicate_mr_events_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170815060945_remove_duplicate_mr_events.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170815060945_remove_duplicate_mr_events.rb")
describe RemoveDuplicateMrEvents, :delete do
let(:migration) { described_class.new }
- describe '#up' do
+ describe "#up" do
let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let(:merge_requests) { create_list(:merge_request, 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let(:issue) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -15,11 +15,11 @@ describe RemoveDuplicateMrEvents, :delete do
create(:event, :updated, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs
create(:event, :created, author: user, target: merge_requests.second), # rubocop:disable RSpec/FactoriesInMigrationSpecs
create(:event, :created, author: user, target: issue), # rubocop:disable RSpec/FactoriesInMigrationSpecs
- create(:event, :created, author: user, target: issue) # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ create(:event, :created, author: user, target: issue), # rubocop:disable RSpec/FactoriesInMigrationSpecs
]
end
- it 'removes duplicated merge request create records' do
+ it "removes duplicated merge request create records" do
expect { migration.up }.to change { Event.count }.from(6).to(5)
end
end
diff --git a/spec/migrations/remove_empty_extern_uid_auth0_identities_spec.rb b/spec/migrations/remove_empty_extern_uid_auth0_identities_spec.rb
index 441c4295a40..5136af7fec6 100644
--- a/spec/migrations/remove_empty_extern_uid_auth0_identities_spec.rb
+++ b/spec/migrations/remove_empty_extern_uid_auth0_identities_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180220150310_remove_empty_extern_uid_auth0_identities.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180220150310_remove_empty_extern_uid_auth0_identities.rb")
describe RemoveEmptyExternUidAuth0Identities, :migration do
let(:identities) { table(:identities) }
before do
- identities.create(provider: 'auth0', extern_uid: '')
- identities.create(provider: 'auth0', extern_uid: 'valid')
- identities.create(provider: 'github', extern_uid: '')
+ identities.create(provider: "auth0", extern_uid: "")
+ identities.create(provider: "auth0", extern_uid: "valid")
+ identities.create(provider: "github", extern_uid: "")
migrate!
end
- it 'leaves the correct auth0 identity' do
- expect(identities.where(provider: 'auth0').pluck(:extern_uid)).to eq(['valid'])
+ it "leaves the correct auth0 identity" do
+ expect(identities.where(provider: "auth0").pluck(:extern_uid)).to eq(["valid"])
end
- it 'leaves the correct github identity' do
- expect(identities.where(provider: 'github').count).to eq(1)
+ it "leaves the correct github identity" do
+ expect(identities.where(provider: "github").count).to eq(1)
end
end
diff --git a/spec/migrations/remove_empty_fork_networks_spec.rb b/spec/migrations/remove_empty_fork_networks_spec.rb
index f6d030ab25c..12e4d1a2d44 100644
--- a/spec/migrations/remove_empty_fork_networks_spec.rb
+++ b/spec/migrations/remove_empty_fork_networks_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171114104051_remove_empty_fork_networks.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171114104051_remove_empty_fork_networks.rb")
describe RemoveEmptyForkNetworks, :migration do
let!(:fork_networks) { table(:fork_networks) }
@@ -23,7 +23,7 @@ describe RemoveEmptyForkNetworks, :migration do
Upload.reset_column_information
end
- it 'deletes only the fork network without members' do
+ it "deletes only the fork network without members" do
expect(fork_networks.count).to eq(2)
migrate!
diff --git a/spec/migrations/remove_orphaned_label_links_spec.rb b/spec/migrations/remove_orphaned_label_links_spec.rb
index 13b8919343e..3a1f0e804b4 100644
--- a/spec/migrations/remove_orphaned_label_links_spec.rb
+++ b/spec/migrations/remove_orphaned_label_links_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180906051323_remove_orphaned_label_links.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180906051323_remove_orphaned_label_links.rb")
describe RemoveOrphanedLabelLinks, :migration do
let(:label_links) { table(:label_links) }
@@ -10,15 +10,15 @@ describe RemoveOrphanedLabelLinks, :migration do
let(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let(:label) { create_label }
- context 'add foreign key on label_id' do
+ context "add foreign key on label_id" do
let!(:label_link_with_label) { create_label_link(label_id: label.id) }
let!(:label_link_without_label) { create_label_link(label_id: nil) }
- it 'removes orphaned labels without corresponding label' do
+ it "removes orphaned labels without corresponding label" do
expect { migrate! }.to change { LabelLink.count }.from(2).to(1)
end
- it 'does not remove entries with valid label_id' do
+ it "does not remove entries with valid label_id" do
expect { migrate! }.not_to change { label_link_with_label.reload }
end
end
@@ -33,7 +33,7 @@ describe RemoveOrphanedLabelLinks, :migration do
def create_label_link(**opts)
label_links.create!(
target_id: 1,
- target_type: 'Issue',
+ target_type: "Issue",
**opts
)
end
diff --git a/spec/migrations/remove_project_labels_group_id_spec.rb b/spec/migrations/remove_project_labels_group_id_spec.rb
index 01b09e71d83..b68047b7ddb 100644
--- a/spec/migrations/remove_project_labels_group_id_spec.rb
+++ b/spec/migrations/remove_project_labels_group_id_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180202111106_remove_project_labels_group_id.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180202111106_remove_project_labels_group_id.rb")
describe RemoveProjectLabelsGroupId, :delete do
let(:migration) { described_class.new }
@@ -9,12 +7,12 @@ describe RemoveProjectLabelsGroupId, :delete do
let!(:project_label) { create(:label, group_id: group.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
let!(:group_label) { create(:group_label) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- describe '#up' do
- it 'updates the project labels group ID' do
+ describe "#up" do
+ it "updates the project labels group ID" do
expect { migration.up }.to change { project_label.reload.group_id }.to(nil)
end
- it 'keeps the group labels group ID' do
+ it "keeps the group labels group ID" do
expect { migration.up }.not_to change { group_label.reload.group_id }
end
end
diff --git a/spec/migrations/remove_redundant_pipeline_stages_spec.rb b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
index 8325f986594..975506b106b 100644
--- a/spec/migrations/remove_redundant_pipeline_stages_spec.rb
+++ b/spec/migrations/remove_redundant_pipeline_stages_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180119121225_remove_redundant_pipeline_stages.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180119121225_remove_redundant_pipeline_stages.rb")
describe RemoveRedundantPipelineStages, :migration do
let(:projects) { table(:projects) }
@@ -8,15 +8,15 @@ describe RemoveRedundantPipelineStages, :migration do
let(:builds) { table(:ci_builds) }
before do
- projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce')
- pipelines.create!(id: 234, project_id: 123, ref: 'master', sha: 'adf43c3a')
+ projects.create!(id: 123, name: "gitlab", path: "gitlab-ce")
+ pipelines.create!(id: 234, project_id: 123, ref: "master", sha: "adf43c3a")
- stages.create!(id: 6, project_id: 123, pipeline_id: 234, name: 'build')
- stages.create!(id: 10, project_id: 123, pipeline_id: 234, name: 'build')
- stages.create!(id: 21, project_id: 123, pipeline_id: 234, name: 'build')
- stages.create!(id: 41, project_id: 123, pipeline_id: 234, name: 'test')
- stages.create!(id: 62, project_id: 123, pipeline_id: 234, name: 'test')
- stages.create!(id: 102, project_id: 123, pipeline_id: 234, name: 'deploy')
+ stages.create!(id: 6, project_id: 123, pipeline_id: 234, name: "build")
+ stages.create!(id: 10, project_id: 123, pipeline_id: 234, name: "build")
+ stages.create!(id: 21, project_id: 123, pipeline_id: 234, name: "build")
+ stages.create!(id: 41, project_id: 123, pipeline_id: 234, name: "test")
+ stages.create!(id: 62, project_id: 123, pipeline_id: 234, name: "test")
+ stages.create!(id: 102, project_id: 123, pipeline_id: 234, name: "deploy")
builds.create!(id: 1, commit_id: 234, project_id: 123, stage_id: 10)
builds.create!(id: 2, commit_id: 234, project_id: 123, stage_id: 21)
@@ -26,7 +26,7 @@ describe RemoveRedundantPipelineStages, :migration do
builds.create!(id: 6, commit_id: 234, project_id: 123, stage_id: 102)
end
- it 'removes ambiguous stages and preserves builds' do
+ it "removes ambiguous stages and preserves builds" do
expect(stages.all.count).to eq 6
expect(builds.all.count).to eq 6
@@ -37,7 +37,7 @@ describe RemoveRedundantPipelineStages, :migration do
expect(builds.all.pluck(:stage_id).compact).to eq [102]
end
- it 'retries when incorrectly added index exception is caught' do
+ it "retries when incorrectly added index exception is caught" do
allow_any_instance_of(described_class)
.to receive(:remove_redundant_pipeline_stages!)
@@ -49,7 +49,7 @@ describe RemoveRedundantPipelineStages, :migration do
.to raise_error StandardError, /Failed to add an unique index/
end
- it 'does not retry when unknown exception is being raised' do
+ it "does not retry when unknown exception is being raised" do
allow(subject).to receive(:remove_outdated_index!)
expect(subject).to receive(:remove_redundant_pipeline_stages!).once
allow(subject).to receive(:add_unique_index!).and_raise(StandardError)
diff --git a/spec/migrations/remove_soft_removed_objects_spec.rb b/spec/migrations/remove_soft_removed_objects_spec.rb
index d0bde98b80e..97d02ef3e78 100644
--- a/spec/migrations/remove_soft_removed_objects_spec.rb
+++ b/spec/migrations/remove_soft_removed_objects_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171207150343_remove_soft_removed_objects.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171207150343_remove_soft_removed_objects.rb")
describe RemoveSoftRemovedObjects, :migration do
- describe '#up' do
+ describe "#up" do
let!(:groups) do
table(:namespaces).tap do |t|
t.inheritance_column = nil
@@ -15,7 +15,7 @@ describe RemoveSoftRemovedObjects, :migration do
end
end
- it 'removes various soft removed objects' do
+ it "removes various soft removed objects" do
5.times do
create_with_deleted_at(:issue)
end
@@ -28,7 +28,7 @@ describe RemoveSoftRemovedObjects, :migration do
expect(Issue.first).to eq(regular_issue)
end
- it 'removes the temporary indexes once soft removed data has been removed' do
+ it "removes the temporary indexes once soft removed data has been removed" do
migration = described_class.new
run_migration
@@ -38,10 +38,10 @@ describe RemoveSoftRemovedObjects, :migration do
end
end
- it 'removes routes of soft removed personal namespaces' do
+ it "removes routes of soft removed personal namespaces" do
namespace = create_with_deleted_at(:namespace)
- group = groups.create!(name: 'group', path: 'group_path', type: 'Group')
- routes.create!(source_id: group.id, source_type: 'Group', name: 'group', path: 'group_path')
+ group = groups.create!(name: "group", path: "group_path", type: "Group")
+ routes.create!(source_id: group.id, source_type: "Group", name: "group", path: "group_path")
expect(routes.where(source_id: namespace.id).exists?).to eq(true)
expect(routes.where(source_id: group.id).exists?).to eq(true)
@@ -52,7 +52,7 @@ describe RemoveSoftRemovedObjects, :migration do
expect(routes.where(source_id: group.id).exists?).to eq(true)
end
- it 'schedules the removal of soft removed groups' do
+ it "schedules the removal of soft removed groups" do
group = create_deleted_group
admin = create(:user, admin: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -63,7 +63,7 @@ describe RemoveSoftRemovedObjects, :migration do
run_migration
end
- it 'does not remove soft removed groups when no admin user could be found' do
+ it "does not remove soft removed groups when no admin user could be found" do
create_deleted_group
expect_any_instance_of(GroupDestroyWorker)
@@ -89,8 +89,8 @@ describe RemoveSoftRemovedObjects, :migration do
end
def create_deleted_group
- group = groups.create!(name: 'group', path: 'group_path', type: 'Group')
- routes.create!(source_id: group.id, source_type: 'Group', name: 'group', path: 'group_path')
+ group = groups.create!(name: "group", path: "group_path", type: "Group")
+ routes.create!(source_id: group.id, source_type: "Group", name: "group", path: "group_path")
groups.where(id: group.id).update_all(deleted_at: 1.year.ago)
diff --git a/spec/migrations/rename_duplicated_variable_key_spec.rb b/spec/migrations/rename_duplicated_variable_key_spec.rb
index 11096564dfa..104e44ee899 100644
--- a/spec/migrations/rename_duplicated_variable_key_spec.rb
+++ b/spec/migrations/rename_duplicated_variable_key_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170622135451_rename_duplicated_variable_key.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170622135451_rename_duplicated_variable_key.rb")
describe RenameDuplicatedVariableKey, :migration do
let(:variables) { table(:ci_variables) }
@@ -7,28 +7,28 @@ describe RenameDuplicatedVariableKey, :migration do
before do
projects.create!(id: 1)
- variables.create!(id: 1, key: 'key1', project_id: 1)
- variables.create!(id: 2, key: 'key2', project_id: 1)
- variables.create!(id: 3, key: 'keyX', project_id: 1)
- variables.create!(id: 4, key: 'keyX', project_id: 1)
- variables.create!(id: 5, key: 'keyY', project_id: 1)
- variables.create!(id: 6, key: 'keyX', project_id: 1)
- variables.create!(id: 7, key: 'key7', project_id: 1)
- variables.create!(id: 8, key: 'keyY', project_id: 1)
+ variables.create!(id: 1, key: "key1", project_id: 1)
+ variables.create!(id: 2, key: "key2", project_id: 1)
+ variables.create!(id: 3, key: "keyX", project_id: 1)
+ variables.create!(id: 4, key: "keyX", project_id: 1)
+ variables.create!(id: 5, key: "keyY", project_id: 1)
+ variables.create!(id: 6, key: "keyX", project_id: 1)
+ variables.create!(id: 7, key: "key7", project_id: 1)
+ variables.create!(id: 8, key: "keyY", project_id: 1)
end
- it 'correctly remove duplicated records with smaller id' do
+ it "correctly remove duplicated records with smaller id" do
migrate!
expect(variables.pluck(:id, :key)).to contain_exactly(
- [1, 'key1'],
- [2, 'key2'],
- [3, 'keyX_3'],
- [4, 'keyX_4'],
- [5, 'keyY_5'],
- [6, 'keyX'],
- [7, 'key7'],
- [8, 'keyY']
+ [1, "key1"],
+ [2, "key2"],
+ [3, "keyX_3"],
+ [4, "keyX_4"],
+ [5, "keyY_5"],
+ [6, "keyX"],
+ [7, "key7"],
+ [8, "keyY"]
)
end
end
diff --git a/spec/migrations/rename_more_reserved_project_names_spec.rb b/spec/migrations/rename_more_reserved_project_names_spec.rb
index 80ae209e9d1..83e3f827f4a 100644
--- a/spec/migrations/rename_more_reserved_project_names_spec.rb
+++ b/spec/migrations/rename_more_reserved_project_names_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170313133418_rename_more_reserved_project_names.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170313133418_rename_more_reserved_project_names.rb")
# This migration uses multiple threads, and thus different transactions. This
# means data created in this spec may not be visible to some threads. To work
@@ -11,27 +9,27 @@ describe RenameMoreReservedProjectNames, :delete do
let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
before do
- project.path = 'artifacts'
+ project.path = "artifacts"
project.save!(validate: false)
end
- describe '#up' do
- context 'when project repository exists' do
+ describe "#up" do
+ context "when project repository exists" do
before do
project.create_repository
end
- context 'when no exception is raised' do
- it 'renames project with reserved names' do
+ context "when no exception is raised" do
+ it "renames project with reserved names" do
migration.up
- expect(project.reload.path).to eq('artifacts0')
+ expect(project.reload.path).to eq("artifacts0")
end
end
- context 'when exception is raised during rename' do
+ context "when exception is raised during rename" do
before do
- service = instance_double('service')
+ service = instance_double("service")
allow(service)
.to receive(:execute)
@@ -42,14 +40,14 @@ describe RenameMoreReservedProjectNames, :delete do
.and_return(service)
end
- it 'captures exception from project rename' do
+ it "captures exception from project rename" do
expect { migration.up }.not_to raise_error
end
end
end
- context 'when project repository does not exist' do
- it 'does not raise error' do
+ context "when project repository does not exist" do
+ it "does not raise error" do
expect { migration.up }.not_to raise_error
end
end
diff --git a/spec/migrations/rename_reserved_project_names_spec.rb b/spec/migrations/rename_reserved_project_names_spec.rb
index 93e5c032287..dc5e8b268cf 100644
--- a/spec/migrations/rename_reserved_project_names_spec.rb
+++ b/spec/migrations/rename_reserved_project_names_spec.rb
@@ -1,7 +1,5 @@
-# encoding: utf-8
-
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_project_names.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20161221153951_rename_reserved_project_names.rb")
# This migration is using factories, which set fields that don't actually
# exist in the DB schema previous to 20161221153951. Thus we just use the
@@ -15,27 +13,27 @@ describe RenameReservedProjectNames, :migration, schema: :latest do
let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
before do
- project.path = 'projects'
+ project.path = "projects"
project.save!(validate: false)
end
- describe '#up' do
- context 'when project repository exists' do
+ describe "#up" do
+ context "when project repository exists" do
before do
project.create_repository
end
- context 'when no exception is raised' do
- it 'renames project with reserved names' do
+ context "when no exception is raised" do
+ it "renames project with reserved names" do
migration.up
- expect(project.reload.path).to eq('projects0')
+ expect(project.reload.path).to eq("projects0")
end
end
- context 'when exception is raised during rename' do
+ context "when exception is raised during rename" do
before do
- service = instance_double('service')
+ service = instance_double("service")
allow(service)
.to receive(:execute)
@@ -46,14 +44,14 @@ describe RenameReservedProjectNames, :migration, schema: :latest do
.and_return(service)
end
- it 'captures exception from project rename' do
+ it "captures exception from project rename" do
expect { migration.up }.not_to raise_error
end
end
end
- context 'when project repository does not exist' do
- it 'does not raise error' do
+ context "when project repository does not exist" do
+ it "does not raise error" do
expect { migration.up }.not_to raise_error
end
end
diff --git a/spec/migrations/rename_users_with_renamed_namespace_spec.rb b/spec/migrations/rename_users_with_renamed_namespace_spec.rb
index b8a4dc2b2c0..ab4de05f607 100644
--- a/spec/migrations/rename_users_with_renamed_namespace_spec.rb
+++ b/spec/migrations/rename_users_with_renamed_namespace_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170518200835_rename_users_with_renamed_namespace.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170518200835_rename_users_with_renamed_namespace.rb")
describe RenameUsersWithRenamedNamespace, :delete do
- it 'renames a user that had their namespace renamed to the namespace path' do
- other_user = create(:user, username: 'kodingu') # rubocop:disable RSpec/FactoriesInMigrationSpecs
- other_user1 = create(:user, username: 'api0') # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ it "renames a user that had their namespace renamed to the namespace path" do
+ other_user = create(:user, username: "kodingu") # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ other_user1 = create(:user, username: "api0") # rubocop:disable RSpec/FactoriesInMigrationSpecs
user = create(:user, username: "Users0") # rubocop:disable RSpec/FactoriesInMigrationSpecs
- user.update_column(:username, 'Users')
+ user.update_column(:username, "Users")
user1 = create(:user, username: "import0") # rubocop:disable RSpec/FactoriesInMigrationSpecs
- user1.update_column(:username, 'import')
+ user1.update_column(:username, "import")
described_class.new.up
- expect(user.reload.username).to eq('Users0')
- expect(user1.reload.username).to eq('import0')
+ expect(user.reload.username).to eq("Users0")
+ expect(user1.reload.username).to eq("import0")
- expect(other_user.reload.username).to eq('kodingu')
- expect(other_user1.reload.username).to eq('api0')
+ expect(other_user.reload.username).to eq("kodingu")
+ expect(other_user1.reload.username).to eq("api0")
end
end
diff --git a/spec/migrations/reschedule_builds_stages_migration_spec.rb b/spec/migrations/reschedule_builds_stages_migration_spec.rb
index 3bfd9dd9f6b..af382881d73 100644
--- a/spec/migrations/reschedule_builds_stages_migration_spec.rb
+++ b/spec/migrations/reschedule_builds_stages_migration_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180405101928_reschedule_builds_stages_migration")
describe RescheduleBuildsStagesMigration, :sidekiq, :migration do
let(:namespaces) { table(:namespaces) }
@@ -11,10 +11,10 @@ describe RescheduleBuildsStagesMigration, :sidekiq, :migration do
before do
stub_const("#{described_class}::BATCH_SIZE", 1)
- namespaces.create(id: 12, name: 'gitlab-org', path: 'gitlab-org')
- projects.create!(id: 123, namespace_id: 12, name: 'gitlab', path: 'gitlab')
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
- stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test')
+ namespaces.create(id: 12, name: "gitlab-org", path: "gitlab-org")
+ projects.create!(id: 123, namespace_id: 12, name: "gitlab", path: "gitlab")
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
+ stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: "test")
jobs.create!(id: 11, commit_id: 1, project_id: 123, stage_id: nil)
jobs.create!(id: 206, commit_id: 1, project_id: 123, stage_id: nil)
@@ -22,7 +22,7 @@ describe RescheduleBuildsStagesMigration, :sidekiq, :migration do
jobs.create!(id: 4109, commit_id: 1, project_id: 123, stage_id: 1)
end
- it 'schedules delayed background migrations in batches in bulk' do
+ it "schedules delayed background migrations in batches in bulk" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
diff --git a/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb b/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb
index 26489ef58bd..2358935acd0 100644
--- a/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb
+++ b/spec/migrations/reschedule_commits_count_for_merge_request_diff_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20180309121820_reschedule_commits_count_for_merge_request_diff')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20180309121820_reschedule_commits_count_for_merge_request_diff")
describe RescheduleCommitsCountForMergeRequestDiff, :migration, :sidekiq do
let(:merge_request_diffs) { table(:merge_request_diffs) }
@@ -10,11 +10,11 @@ describe RescheduleCommitsCountForMergeRequestDiff, :migration, :sidekiq do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
- namespaces.create!(id: 1, name: 'gitlab', path: 'gitlab')
+ namespaces.create!(id: 1, name: "gitlab", path: "gitlab")
projects.create!(id: 1, namespace_id: 1)
- merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: 'feature', source_branch: 'master')
+ merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: "feature", source_branch: "master")
merge_request_diffs.create!(id: 1, merge_request_id: 1)
merge_request_diffs.create!(id: 2, merge_request_id: 1)
@@ -22,7 +22,7 @@ describe RescheduleCommitsCountForMergeRequestDiff, :migration, :sidekiq do
merge_request_diffs.create!(id: 4, merge_request_id: 1)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
diff --git a/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
index c4427910518..55a98c05e9f 100644
--- a/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
+++ b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171005130944_schedule_create_gpg_key_subkeys_from_gpg_keys")
describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
before do
@@ -9,7 +9,7 @@ describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
GpgKeySubkey.destroy_all # rubocop: disable DestroyAll
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
migrate!
@@ -19,7 +19,7 @@ describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do
end
end
- it 'schedules background migrations' do
+ it "schedules background migrations" do
perform_enqueued_jobs do
expect(GpgKeySubkey.count).to eq(0)
diff --git a/spec/migrations/schedule_digest_personal_access_tokens_spec.rb b/spec/migrations/schedule_digest_personal_access_tokens_spec.rb
index 6d155f78342..f4dcbe04c60 100644
--- a/spec/migrations/schedule_digest_personal_access_tokens_spec.rb
+++ b/spec/migrations/schedule_digest_personal_access_tokens_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180913142237_schedule_digest_personal_access_tokens.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180913142237_schedule_digest_personal_access_tokens.rb")
describe ScheduleDigestPersonalAccessTokens, :migration, :sidekiq do
let(:personal_access_tokens) { table(:personal_access_tokens) }
@@ -8,33 +8,37 @@ describe ScheduleDigestPersonalAccessTokens, :migration, :sidekiq do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 4)
- users.create(id: 1, email: 'user@example.com', projects_limit: 10)
+ users.create(id: 1, email: "user@example.com", projects_limit: 10)
- personal_access_tokens.create!(id: 1, user_id: 1, name: 'pat-01', token: 'token-01')
- personal_access_tokens.create!(id: 2, user_id: 1, name: 'pat-02', token: 'token-02')
- personal_access_tokens.create!(id: 3, user_id: 1, name: 'pat-03', token_digest: 'token_digest')
- personal_access_tokens.create!(id: 4, user_id: 1, name: 'pat-04', token: 'token-04')
- personal_access_tokens.create!(id: 5, user_id: 1, name: 'pat-05', token: 'token-05')
- personal_access_tokens.create!(id: 6, user_id: 1, name: 'pat-06', token: 'token-06')
+ personal_access_tokens.create!(id: 1, user_id: 1, name: "pat-01", token: "token-01")
+ personal_access_tokens.create!(id: 2, user_id: 1, name: "pat-02", token: "token-02")
+ personal_access_tokens.create!(id: 3, user_id: 1, name: "pat-03", token_digest: "token_digest")
+ personal_access_tokens.create!(id: 4, user_id: 1, name: "pat-04", token: "token-04")
+ personal_access_tokens.create!(id: 5, user_id: 1, name: "pat-05", token: "token-05")
+ personal_access_tokens.create!(id: 6, user_id: 1, name: "pat-06", token: "token-06")
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
migrate!
expect(described_class::MIGRATION).to(
be_scheduled_delayed_migration(
- 5.minutes, 'PersonalAccessToken', 'token', 'token_digest', 1, 5))
+ 5.minutes, "PersonalAccessToken", "token", "token_digest", 1, 5
+ )
+ )
expect(described_class::MIGRATION).to(
be_scheduled_delayed_migration(
- 10.minutes, 'PersonalAccessToken', 'token', 'token_digest', 6, 6))
+ 10.minutes, "PersonalAccessToken", "token", "token_digest", 6, 6
+ )
+ )
expect(BackgroundMigrationWorker.jobs.size).to eq 2
end
end
- it 'schedules background migrations' do
+ it "schedules background migrations" do
perform_enqueued_jobs do
- plain_text_token = 'token IS NOT NULL'
+ plain_text_token = "token IS NOT NULL"
expect(personal_access_tokens.where(plain_text_token).count).to eq 5
diff --git a/spec/migrations/schedule_merge_request_diff_migrations_spec.rb b/spec/migrations/schedule_merge_request_diff_migrations_spec.rb
index 9f7e47bae0d..3b220a2b835 100644
--- a/spec/migrations/schedule_merge_request_diff_migrations_spec.rb
+++ b/spec/migrations/schedule_merge_request_diff_migrations_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170703130158_schedule_merge_request_diff_migrations')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170703130158_schedule_merge_request_diff_migrations")
describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
let(:merge_request_diffs) { table(:merge_request_diffs) }
@@ -9,9 +9,9 @@ describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
- projects.create!(id: 1, name: 'gitlab', path: 'gitlab')
+ projects.create!(id: 1, name: "gitlab", path: "gitlab")
- merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: 'feature', source_branch: 'master')
+ merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: "feature", source_branch: "master")
merge_request_diffs.create!(id: 1, merge_request_id: 1, st_commits: YAML.dump([]), st_diffs: nil)
merge_request_diffs.create!(id: 2, merge_request_id: 1, st_commits: nil, st_diffs: YAML.dump([]))
@@ -19,7 +19,7 @@ describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
merge_request_diffs.create!(id: 4, merge_request_id: 1, st_commits: YAML.dump([]), st_diffs: YAML.dump([]))
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -32,9 +32,9 @@ describe ScheduleMergeRequestDiffMigrations, :migration, :sidekiq do
end
end
- it 'schedules background migrations' do
+ it "schedules background migrations" do
perform_enqueued_jobs do
- non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL'
+ non_empty = "st_commits IS NOT NULL OR st_diffs IS NOT NULL"
expect(merge_request_diffs.where(non_empty).count).to eq 3
diff --git a/spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb b/spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb
index 5bcb923af7b..f9b0f36c976 100644
--- a/spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb
+++ b/spec/migrations/schedule_merge_request_diff_migrations_take_two_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170926150348_schedule_merge_request_diff_migrations_take_two')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170926150348_schedule_merge_request_diff_migrations_take_two")
describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
let(:merge_request_diffs) { table(:merge_request_diffs) }
@@ -9,9 +9,9 @@ describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
- projects.create!(id: 1, name: 'gitlab', path: 'gitlab')
+ projects.create!(id: 1, name: "gitlab", path: "gitlab")
- merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: 'feature', source_branch: 'master')
+ merge_requests.create!(id: 1, target_project_id: 1, source_project_id: 1, target_branch: "feature", source_branch: "master")
merge_request_diffs.create!(id: 1, merge_request_id: 1, st_commits: YAML.dump([]), st_diffs: nil)
merge_request_diffs.create!(id: 2, merge_request_id: 1, st_commits: nil, st_diffs: YAML.dump([]))
@@ -19,7 +19,7 @@ describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
merge_request_diffs.create!(id: 4, merge_request_id: 1, st_commits: YAML.dump([]), st_diffs: YAML.dump([]))
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -32,9 +32,9 @@ describe ScheduleMergeRequestDiffMigrationsTakeTwo, :migration, :sidekiq do
end
end
- it 'migrates the data' do
+ it "migrates the data" do
perform_enqueued_jobs do
- non_empty = 'st_commits IS NOT NULL OR st_diffs IS NOT NULL'
+ non_empty = "st_commits IS NOT NULL OR st_diffs IS NOT NULL"
expect(merge_request_diffs.where(non_empty).count).to eq 3
diff --git a/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb b/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb
index 76fe16581ac..747e16e6629 100644
--- a/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb
+++ b/spec/migrations/schedule_merge_request_latest_merge_request_diff_id_migrations_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171026082505_schedule_merge_request_latest_merge_request_diff_id_migrations")
describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :sidekiq do
let(:projects_table) { table(:projects) }
let(:merge_requests_table) { table(:merge_requests) }
let(:merge_request_diffs_table) { table(:merge_request_diffs) }
- let(:project) { projects_table.create!(name: 'gitlab', path: 'gitlab-org/gitlab-ce') }
+ let(:project) { projects_table.create!(name: "gitlab", path: "gitlab-org/gitlab-ce") }
- let!(:merge_request_1) { create_mr!('mr_1', diffs: 1) }
- let!(:merge_request_2) { create_mr!('mr_2', diffs: 2) }
- let!(:merge_request_migrated) { create_mr!('merge_request_migrated', diffs: 3) }
- let!(:merge_request_4) { create_mr!('mr_4', diffs: 3) }
+ let!(:merge_request_1) { create_mr!("mr_1", diffs: 1) }
+ let!(:merge_request_2) { create_mr!("mr_2", diffs: 2) }
+ let!(:merge_request_migrated) { create_mr!("merge_request_migrated", diffs: 3) }
+ let!(:merge_request_4) { create_mr!("mr_4", diffs: 3) }
def create_mr!(name, diffs: 0)
merge_request =
merge_requests_table.create!(target_project_id: project.id,
- target_branch: 'master',
+ target_branch: "master",
source_project_id: project.id,
source_branch: name,
title: name)
@@ -39,7 +39,7 @@ describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :si
merge_request_migrated.update!(latest_merge_request_diff_id: diff_id)
end
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -52,7 +52,7 @@ describe ScheduleMergeRequestLatestMergeRequestDiffIdMigrations, :migration, :si
end
end
- it 'schedules background migrations' do
+ it "schedules background migrations" do
perform_enqueued_jobs do
expect(merge_requests_table.where(latest_merge_request_diff_id: nil).count).to eq 3
diff --git a/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb b/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb
index 578440cba20..654de04d03a 100644
--- a/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb
+++ b/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171128214150_schedule_populate_merge_request_metrics_with_events_data.rb")
describe SchedulePopulateMergeRequestMetricsWithEventsData, :migration, :sidekiq do
# commits_count attribute is added in a next migration
@@ -10,7 +10,7 @@ describe SchedulePopulateMergeRequestMetricsWithEventsData, :migration, :sidekiq
let!(:mrs) { create_list(:merge_request, 3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- it 'correctly schedules background migrations' do
+ it "correctly schedules background migrations" do
stub_const("#{described_class.name}::BATCH_SIZE", 2)
Sidekiq::Testing.fake! do
diff --git a/spec/migrations/schedule_runners_token_encryption_spec.rb b/spec/migrations/schedule_runners_token_encryption_spec.rb
index 376d2795277..a6f5027ae40 100644
--- a/spec/migrations/schedule_runners_token_encryption_spec.rb
+++ b/spec/migrations/schedule_runners_token_encryption_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181121111200_schedule_runners_token_encryption')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181121111200_schedule_runners_token_encryption")
describe ScheduleRunnersTokenEncryption, :migration do
let(:settings) { table(:application_settings) }
@@ -10,27 +10,27 @@ describe ScheduleRunnersTokenEncryption, :migration do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 1)
- settings.create!(id: 1, runners_registration_token: 'plain-text-token1')
- namespaces.create!(id: 11, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token1')
- namespaces.create!(id: 12, name: 'gitlab', path: 'gitlab-org', runners_token: 'my-token2')
- projects.create!(id: 111, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token1')
- projects.create!(id: 114, namespace_id: 11, name: 'gitlab', path: 'gitlab-ce', runners_token: 'my-token2')
- runners.create!(id: 201, runner_type: 1, token: 'plain-text-token1')
- runners.create!(id: 202, runner_type: 1, token: 'plain-text-token2')
+ settings.create!(id: 1, runners_registration_token: "plain-text-token1")
+ namespaces.create!(id: 11, name: "gitlab", path: "gitlab-org", runners_token: "my-token1")
+ namespaces.create!(id: 12, name: "gitlab", path: "gitlab-org", runners_token: "my-token2")
+ projects.create!(id: 111, namespace_id: 11, name: "gitlab", path: "gitlab-ce", runners_token: "my-token1")
+ projects.create!(id: 114, namespace_id: 11, name: "gitlab", path: "gitlab-ce", runners_token: "my-token2")
+ runners.create!(id: 201, runner_type: 1, token: "plain-text-token1")
+ runners.create!(id: 202, runner_type: 1, token: "plain-text-token2")
end
- it 'schedules runners token encryption migration for multiple resources' do
+ it "schedules runners token encryption migration for multiple resources" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'settings', 1, 1)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'namespace', 11, 11)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'namespace', 12, 12)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'project', 111, 111)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'project', 114, 114)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, 'runner', 201, 201)
- expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, 'runner', 202, 202)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, "settings", 1, 1)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, "namespace", 11, 11)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, "namespace", 12, 12)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, "project", 111, 111)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, "project", 114, 114)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(4.minutes, "runner", 201, 201)
+ expect(described_class::MIGRATION).to be_scheduled_delayed_migration(8.minutes, "runner", 202, 202)
expect(BackgroundMigrationWorker.jobs.size).to eq 7
end
end
diff --git a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb
index fa4ddd5fbc7..a2500285a84 100644
--- a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb
+++ b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180104131052_schedule_set_confidential_note_events_on_webhooks.rb")
describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do
let(:web_hooks_table) { table(:web_hooks) }
@@ -17,7 +17,7 @@ describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do
stub_const("#{described_class}::BATCH_SIZE", 1)
end
- it 'schedules background migrations at correct time' do
+ it "schedules background migrations at correct time" do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
@@ -30,7 +30,7 @@ describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do
end
end
- it 'correctly processes web hooks' do
+ it "correctly processes web hooks" do
perform_enqueued_jobs do
expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 4
expect(web_hooks_table.where(confidential_note_events: true).count).to eq 1
diff --git a/spec/migrations/schedule_stages_index_migration_spec.rb b/spec/migrations/schedule_stages_index_migration_spec.rb
index 710264da375..da1172d8117 100644
--- a/spec/migrations/schedule_stages_index_migration_spec.rb
+++ b/spec/migrations/schedule_stages_index_migration_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180420080616_schedule_stages_index_migration')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180420080616_schedule_stages_index_migration")
describe ScheduleStagesIndexMigration, :sidekiq, :migration do
let(:namespaces) { table(:namespaces) }
@@ -10,15 +10,15 @@ describe ScheduleStagesIndexMigration, :sidekiq, :migration do
before do
stub_const("#{described_class}::BATCH_SIZE", 1)
- namespaces.create(id: 12, name: 'gitlab-org', path: 'gitlab-org')
- projects.create!(id: 123, namespace_id: 12, name: 'gitlab', path: 'gitlab')
- pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
- stages.create!(id: 121, project_id: 123, pipeline_id: 1, name: 'build')
- stages.create!(id: 122, project_id: 123, pipeline_id: 1, name: 'test')
- stages.create!(id: 123, project_id: 123, pipeline_id: 1, name: 'deploy')
+ namespaces.create(id: 12, name: "gitlab-org", path: "gitlab-org")
+ projects.create!(id: 123, namespace_id: 12, name: "gitlab", path: "gitlab")
+ pipelines.create!(id: 1, project_id: 123, ref: "master", sha: "adf43c3a")
+ stages.create!(id: 121, project_id: 123, pipeline_id: 1, name: "build")
+ stages.create!(id: 122, project_id: 123, pipeline_id: 1, name: "test")
+ stages.create!(id: 123, project_id: 123, pipeline_id: 1, name: "deploy")
end
- it 'schedules delayed background migrations in batches' do
+ it "schedules delayed background migrations in batches" do
Sidekiq::Testing.fake! do
Timecop.freeze do
expect(stages.all).to all(have_attributes(position: be_nil))
diff --git a/spec/migrations/schedule_to_archive_legacy_traces_spec.rb b/spec/migrations/schedule_to_archive_legacy_traces_spec.rb
index d3eac3c45ea..5c1cf48f9c7 100644
--- a/spec/migrations/schedule_to_archive_legacy_traces_spec.rb
+++ b/spec/migrations/schedule_to_archive_legacy_traces_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20180529152628_schedule_to_archive_legacy_traces')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20180529152628_schedule_to_archive_legacy_traces")
describe ScheduleToArchiveLegacyTraces, :migration do
include TraceHelpers
@@ -10,20 +10,20 @@ describe ScheduleToArchiveLegacyTraces, :migration do
let(:job_artifacts) { table(:ci_job_artifacts) }
before do
- namespaces.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
- projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1', namespace_id: 123)
- @build_success = builds.create!(id: 1, project_id: 123, status: 'success', type: 'Ci::Build')
- @build_failed = builds.create!(id: 2, project_id: 123, status: 'failed', type: 'Ci::Build')
- @builds_canceled = builds.create!(id: 3, project_id: 123, status: 'canceled', type: 'Ci::Build')
- @build_running = builds.create!(id: 4, project_id: 123, status: 'running', type: 'Ci::Build')
+ namespaces.create!(id: 123, name: "gitlab1", path: "gitlab1")
+ projects.create!(id: 123, name: "gitlab1", path: "gitlab1", namespace_id: 123)
+ @build_success = builds.create!(id: 1, project_id: 123, status: "success", type: "Ci::Build")
+ @build_failed = builds.create!(id: 2, project_id: 123, status: "failed", type: "Ci::Build")
+ @builds_canceled = builds.create!(id: 3, project_id: 123, status: "canceled", type: "Ci::Build")
+ @build_running = builds.create!(id: 4, project_id: 123, status: "running", type: "Ci::Build")
- create_legacy_trace(@build_success, 'This job is done')
- create_legacy_trace(@build_failed, 'This job is done')
- create_legacy_trace(@builds_canceled, 'This job is done')
- create_legacy_trace(@build_running, 'This job is not done yet')
+ create_legacy_trace(@build_success, "This job is done")
+ create_legacy_trace(@build_failed, "This job is done")
+ create_legacy_trace(@builds_canceled, "This job is done")
+ create_legacy_trace(@build_running, "This job is not done yet")
end
- it 'correctly archive legacy traces' do
+ it "correctly archive legacy traces" do
expect(job_artifacts.count).to eq(0)
expect(File.exist?(legacy_trace_path(@build_success))).to be_truthy
expect(File.exist?(legacy_trace_path(@build_failed))).to be_truthy
diff --git a/spec/migrations/steal_fill_store_upload_spec.rb b/spec/migrations/steal_fill_store_upload_spec.rb
index ed809baf2b5..04c55fdacf1 100644
--- a/spec/migrations/steal_fill_store_upload_spec.rb
+++ b/spec/migrations/steal_fill_store_upload_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181105201455_steal_fill_store_upload.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181105201455_steal_fill_store_upload.rb")
describe StealFillStoreUpload, :migration do
let(:uploads) { table(:uploads) }
- describe '#up' do
- it 'steals the FillStoreUpload background migration' do
- expect(Gitlab::BackgroundMigration).to receive(:steal).with('FillStoreUpload').and_call_original
+ describe "#up" do
+ it "steals the FillStoreUpload background migration" do
+ expect(Gitlab::BackgroundMigration).to receive(:steal).with("FillStoreUpload").and_call_original
migrate!
end
- it 'does not run migration if not needed' do
+ it "does not run migration if not needed" do
uploads.create(size: 100.kilobytes,
- uploader: 'AvatarUploader',
- path: 'uploads/-/system/avatar.jpg',
+ uploader: "AvatarUploader",
+ path: "uploads/-/system/avatar.jpg",
store: 1)
expect_any_instance_of(Gitlab::BackgroundMigration::FillStoreUpload).not_to receive(:perform)
@@ -24,17 +24,17 @@ describe StealFillStoreUpload, :migration do
migrate!
end
- it 'ensures all rows are migrated' do
+ it "ensures all rows are migrated" do
uploads.create(size: 100.kilobytes,
- uploader: 'AvatarUploader',
- path: 'uploads/-/system/avatar.jpg',
+ uploader: "AvatarUploader",
+ path: "uploads/-/system/avatar.jpg",
store: nil)
expect_any_instance_of(Gitlab::BackgroundMigration::FillStoreUpload).to receive(:perform).and_call_original
- expect do
+ expect {
migrate!
- end.to change { uploads.where(store: nil).count }.from(1).to(0)
+ }.to change { uploads.where(store: nil).count }.from(1).to(0)
end
end
end
diff --git a/spec/migrations/track_untracked_uploads_spec.rb b/spec/migrations/track_untracked_uploads_spec.rb
index 2fccfb3f12c..eabbdc63b5e 100644
--- a/spec/migrations/track_untracked_uploads_spec.rb
+++ b/spec/migrations/track_untracked_uploads_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20171103140253_track_untracked_uploads')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20171103140253_track_untracked_uploads")
describe TrackUntrackedUploads, :migration, :sidekiq do
include MigrationsHelpers::TrackUntrackedUploadsHelpers
- it 'correctly schedules the follow-up background migration' do
+ it "correctly schedules the follow-up background migration" do
Sidekiq::Testing.fake! do
migrate!
diff --git a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb
index 5f5ba426d69..950ae7b930e 100644
--- a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb
+++ b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'migrate', '20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb')
+require "spec_helper"
+require Rails.root.join("db", "migrate", "20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb")
describe TurnNestedGroupsIntoRegularGroupsForMysql do
let!(:parent_group) { create(:group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
@@ -15,7 +15,7 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do
allow(migration).to receive(:verbose).and_return(false)
end
- describe '#up' do
+ describe "#up" do
let(:updated_project) do
# path_with_namespace is memoized in an instance variable so we retrieve a
# new row here to work around that.
@@ -26,32 +26,32 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do
migration.up
end
- it 'unsets the parent_id column' do
- expect(Namespace.where('parent_id IS NOT NULL').any?).to eq(false)
+ it "unsets the parent_id column" do
+ expect(Namespace.where("parent_id IS NOT NULL").any?).to eq(false)
end
- it 'adds members of parent groups as members to the migrated group' do
+ it "adds members of parent groups as members to the migrated group" do
is_member = child_group.members
.where(user_id: member, access_level: Gitlab::Access::DEVELOPER).any?
expect(is_member).to eq(true)
end
- it 'update the path of the nested group' do
+ it "update the path of the nested group" do
child_group.reload
expect(child_group.path).to eq("#{parent_group.name}-#{child_group.name}")
end
- it 'renames projects of the nested group' do
+ it "renames projects of the nested group" do
expect(updated_project.full_path)
.to eq("#{parent_group.name}-#{child_group.name}/#{updated_project.path}")
end
- it 'renames the repository of any projects' do
- repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ it "renames the repository of any projects" do
+ repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
updated_project.repository.path
- end
+ }
expect(repo_path)
.to end_with("#{parent_group.name}-#{child_group.name}/#{updated_project.path}.git")
@@ -59,9 +59,9 @@ describe TurnNestedGroupsIntoRegularGroupsForMysql do
expect(File.directory?(repo_path)).to eq(true)
end
- it 'creates a redirect route for renamed projects' do
+ it "creates a redirect route for renamed projects" do
exists = RedirectRoute
- .where(source_type: 'Project', source_id: project.id)
+ .where(source_type: "Project", source_id: project.id)
.any?
expect(exists).to eq(true)
diff --git a/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb b/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb
index d625b60ff50..84f5e37e8fd 100644
--- a/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb
+++ b/spec/migrations/update_legacy_diff_notes_type_for_import_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170927112318_update_legacy_diff_notes_type_for_import.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170927112318_update_legacy_diff_notes_type_for_import.rb")
describe UpdateLegacyDiffNotesTypeForImport, :migration do
let(:notes) { table(:notes) }
@@ -7,16 +7,16 @@ describe UpdateLegacyDiffNotesTypeForImport, :migration do
before do
notes.inheritance_column = nil
- notes.create(type: 'Note')
- notes.create(type: 'LegacyDiffNote')
- notes.create(type: 'Github::Import::Note')
- notes.create(type: 'Github::Import::LegacyDiffNote')
+ notes.create(type: "Note")
+ notes.create(type: "LegacyDiffNote")
+ notes.create(type: "Github::Import::Note")
+ notes.create(type: "Github::Import::LegacyDiffNote")
end
- it 'updates the notes type' do
+ it "updates the notes type" do
migrate!
expect(notes.pluck(:type))
- .to contain_exactly('Note', 'Github::Import::Note', 'LegacyDiffNote', 'LegacyDiffNote')
+ .to contain_exactly("Note", "Github::Import::Note", "LegacyDiffNote", "LegacyDiffNote")
end
end
diff --git a/spec/migrations/update_notes_type_for_import_spec.rb b/spec/migrations/update_notes_type_for_import_spec.rb
index 06195d970d8..9cbe9eab711 100644
--- a/spec/migrations/update_notes_type_for_import_spec.rb
+++ b/spec/migrations/update_notes_type_for_import_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170927112319_update_notes_type_for_import.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170927112319_update_notes_type_for_import.rb")
describe UpdateNotesTypeForImport, :migration do
let(:notes) { table(:notes) }
@@ -7,16 +7,16 @@ describe UpdateNotesTypeForImport, :migration do
before do
notes.inheritance_column = nil
- notes.create(type: 'Note')
- notes.create(type: 'LegacyDiffNote')
- notes.create(type: 'Github::Import::Note')
- notes.create(type: 'Github::Import::LegacyDiffNote')
+ notes.create(type: "Note")
+ notes.create(type: "LegacyDiffNote")
+ notes.create(type: "Github::Import::Note")
+ notes.create(type: "Github::Import::LegacyDiffNote")
end
- it 'updates the notes type' do
+ it "updates the notes type" do
migrate!
expect(notes.pluck(:type))
- .to contain_exactly('Note', 'Note', 'LegacyDiffNote', 'Github::Import::LegacyDiffNote')
+ .to contain_exactly("Note", "Note", "LegacyDiffNote", "Github::Import::LegacyDiffNote")
end
end
diff --git a/spec/migrations/update_project_import_visibility_level_spec.rb b/spec/migrations/update_project_import_visibility_level_spec.rb
index 9ea9b956f67..2736b916da9 100644
--- a/spec/migrations/update_project_import_visibility_level_spec.rb
+++ b/spec/migrations/update_project_import_visibility_level_spec.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20181219130552_update_project_import_visibility_level.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20181219130552_update_project_import_visibility_level.rb")
describe UpdateProjectImportVisibilityLevel, :migration do
let(:namespaces) { table(:namespaces) }
@@ -12,10 +12,10 @@ describe UpdateProjectImportVisibilityLevel, :migration do
stub_const("#{described_class}::BATCH_SIZE", 1)
end
- context 'private visibility level' do
- let(:name) { 'private-public' }
+ context "private visibility level" do
+ let(:name) { "private-public" }
- it 'updates the project visibility' do
+ it "updates the project visibility" do
create_namespace(name, Gitlab::VisibilityLevel::PRIVATE)
create_project(name, Gitlab::VisibilityLevel::PUBLIC)
@@ -23,10 +23,10 @@ describe UpdateProjectImportVisibilityLevel, :migration do
end
end
- context 'internal visibility level' do
- let(:name) { 'internal-public' }
+ context "internal visibility level" do
+ let(:name) { "internal-public" }
- it 'updates the project visibility' do
+ it "updates the project visibility" do
create_namespace(name, Gitlab::VisibilityLevel::INTERNAL)
create_project(name, Gitlab::VisibilityLevel::PUBLIC)
@@ -34,10 +34,10 @@ describe UpdateProjectImportVisibilityLevel, :migration do
end
end
- context 'public visibility level' do
- let(:name) { 'public-public' }
+ context "public visibility level" do
+ let(:name) { "public-public" }
- it 'does not update the project visibility' do
+ it "does not update the project visibility" do
create_namespace(name, Gitlab::VisibilityLevel::PUBLIC)
create_project(name, Gitlab::VisibilityLevel::PUBLIC)
@@ -45,10 +45,10 @@ describe UpdateProjectImportVisibilityLevel, :migration do
end
end
- context 'private project visibility level' do
- let(:name) { 'public-private' }
+ context "private project visibility level" do
+ let(:name) { "public-private" }
- it 'does not update the project visibility' do
+ it "does not update the project visibility" do
create_namespace(name, Gitlab::VisibilityLevel::PUBLIC)
create_project(name, Gitlab::VisibilityLevel::PRIVATE)
@@ -56,10 +56,10 @@ describe UpdateProjectImportVisibilityLevel, :migration do
end
end
- context 'no namespace' do
- let(:name) { 'no-namespace' }
+ context "no namespace" do
+ let(:name) { "no-namespace" }
- it 'does not update the project visibility' do
+ it "does not update the project visibility" do
create_namespace(name, Gitlab::VisibilityLevel::PRIVATE, type: nil)
create_project(name, Gitlab::VisibilityLevel::PUBLIC)
@@ -69,18 +69,18 @@ describe UpdateProjectImportVisibilityLevel, :migration do
def create_namespace(name, visibility, options = {})
namespaces.create({
- name: name,
- path: name,
- type: 'Group',
- visibility_level: visibility
- }.merge(options))
+ name: name,
+ path: name,
+ type: "Group",
+ visibility_level: visibility,
+ }.merge(options))
end
def create_project(name, visibility)
projects.create!(namespace_id: namespaces.find_by_name(name).id,
name: name,
path: name,
- import_type: 'gitlab_project',
+ import_type: "gitlab_project",
visibility_level: visibility)
end
end
diff --git a/spec/migrations/update_retried_for_ci_build_spec.rb b/spec/migrations/update_retried_for_ci_build_spec.rb
index 637dcbb8e01..930a95b7ed8 100644
--- a/spec/migrations/update_retried_for_ci_build_spec.rb
+++ b/spec/migrations/update_retried_for_ci_build_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170503004427_update_retried_for_ci_build.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170503004427_update_retried_for_ci_build.rb")
describe UpdateRetriedForCiBuild, :delete do
let(:pipeline) { create(:ci_pipeline) } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs
- let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ let!(:build_old) { create(:ci_build, pipeline: pipeline, name: "test") } # rubocop:disable RSpec/FactoriesInMigrationSpecs
+ let!(:build_new) { create(:ci_build, pipeline: pipeline, name: "test") } # rubocop:disable RSpec/FactoriesInMigrationSpecs
before do
described_class.new.up
end
- it 'updates ci_builds.is_retried' do
+ it "updates ci_builds.is_retried" do
expect(build_old.reload).to be_retried
expect(build_new.reload).not_to be_retried
end
diff --git a/spec/migrations/update_upload_paths_to_system_spec.rb b/spec/migrations/update_upload_paths_to_system_spec.rb
index 984b428a020..8f03144d003 100644
--- a/spec/migrations/update_upload_paths_to_system_spec.rb
+++ b/spec/migrations/update_upload_paths_to_system_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
-require Rails.root.join('db', 'post_migrate', '20170317162059_update_upload_paths_to_system.rb')
+require "spec_helper"
+require Rails.root.join("db", "post_migrate", "20170317162059_update_upload_paths_to_system.rb")
describe UpdateUploadPathsToSystem, :migration do
let(:migration) { described_class.new }
let(:uploads_table) { table(:uploads) }
- let(:base_upload_attributes) { { size: 42, uploader: 'John Doe' } }
+ let(:base_upload_attributes) { {size: 42, uploader: "John Doe"} }
before do
allow(migration).to receive(:say)
end
- describe '#uploads_to_switch_to_new_path' do
- it 'contains only uploads with the old path for the correct models' do
- _upload_for_other_type = create_upload('Pipeline', 'uploads/ci_pipeline/avatar.jpg')
- _upload_with_system_path = create_upload('Project', 'uploads/-/system/project/avatar.jpg')
- _upload_with_other_path = create_upload('Project', 'thelongsecretforafileupload/avatar.jpg')
- old_upload = create_upload('Project', 'uploads/project/avatar.jpg')
- group_upload = create_upload('Namespace', 'uploads/group/avatar.jpg')
+ describe "#uploads_to_switch_to_new_path" do
+ it "contains only uploads with the old path for the correct models" do
+ _upload_for_other_type = create_upload("Pipeline", "uploads/ci_pipeline/avatar.jpg")
+ _upload_with_system_path = create_upload("Project", "uploads/-/system/project/avatar.jpg")
+ _upload_with_other_path = create_upload("Project", "thelongsecretforafileupload/avatar.jpg")
+ old_upload = create_upload("Project", "uploads/project/avatar.jpg")
+ group_upload = create_upload("Namespace", "uploads/group/avatar.jpg")
expect(uploads_table.where(migration.uploads_to_switch_to_new_path)).to contain_exactly(old_upload, group_upload)
end
end
- describe '#uploads_to_switch_to_old_path' do
- it 'contains only uploads with the new path for the correct models' do
- _upload_for_other_type = create_upload('Pipeline', 'uploads/ci_pipeline/avatar.jpg')
- upload_with_system_path = create_upload('Project', 'uploads/-/system/project/avatar.jpg')
- _upload_with_other_path = create_upload('Project', 'thelongsecretforafileupload/avatar.jpg')
- _old_upload = create_upload('Project', 'uploads/project/avatar.jpg')
+ describe "#uploads_to_switch_to_old_path" do
+ it "contains only uploads with the new path for the correct models" do
+ _upload_for_other_type = create_upload("Pipeline", "uploads/ci_pipeline/avatar.jpg")
+ upload_with_system_path = create_upload("Project", "uploads/-/system/project/avatar.jpg")
+ _upload_with_other_path = create_upload("Project", "thelongsecretforafileupload/avatar.jpg")
+ _old_upload = create_upload("Project", "uploads/project/avatar.jpg")
expect(uploads_table.where(migration.uploads_to_switch_to_old_path)).to contain_exactly(upload_with_system_path)
end
end
- describe '#up' do
- it 'updates old upload records to the new path' do
- old_upload = create_upload('Project', 'uploads/project/avatar.jpg')
+ describe "#up" do
+ it "updates old upload records to the new path" do
+ old_upload = create_upload("Project", "uploads/project/avatar.jpg")
migration.up
- expect(old_upload.reload.path).to eq('uploads/-/system/project/avatar.jpg')
+ expect(old_upload.reload.path).to eq("uploads/-/system/project/avatar.jpg")
end
end
- describe '#down' do
- it 'updates the new system patsh to the old paths' do
- new_upload = create_upload('Project', 'uploads/-/system/project/avatar.jpg')
+ describe "#down" do
+ it "updates the new system patsh to the old paths" do
+ new_upload = create_upload("Project", "uploads/-/system/project/avatar.jpg")
migration.down
- expect(new_upload.reload.path).to eq('uploads/project/avatar.jpg')
+ expect(new_upload.reload.path).to eq("uploads/project/avatar.jpg")
end
end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index eee80e9bad7..4b514a95f09 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Ability do
- context 'using a nil subject' do
- it 'has no permissions' do
+ context "using a nil subject" do
+ it "has no permissions" do
expect(described_class.policy_for(nil, nil)).to be_banned
end
end
- describe '.users_that_can_read_project' do
- context 'using a public project' do
- it 'returns all the users' do
+ describe ".users_that_can_read_project" do
+ context "using a public project" do
+ it "returns all the users" do
project = create(:project, :public)
user = build(:user)
@@ -18,17 +18,17 @@ describe Ability do
end
end
- context 'using an internal project' do
+ context "using an internal project" do
let(:project) { create(:project, :internal) }
- it 'returns users that are administrators' do
+ it "returns users that are administrators" do
user = build(:user, admin: true)
expect(described_class.users_that_can_read_project([user], project))
.to eq([user])
end
- it 'returns internal users while skipping external users' do
+ it "returns internal users while skipping external users" do
user1 = build(:user)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -37,7 +37,7 @@ describe Ability do
.to eq([user1])
end
- it 'returns external users if they are the project owner' do
+ it "returns external users if they are the project owner" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -48,7 +48,7 @@ describe Ability do
.to eq([user1])
end
- it 'returns external users if they are project members' do
+ it "returns external users if they are project members" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -59,7 +59,7 @@ describe Ability do
.to eq([user1])
end
- it 'returns an empty Array if all users are external users without access' do
+ it "returns an empty Array if all users are external users without access" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -69,17 +69,17 @@ describe Ability do
end
end
- context 'using a private project' do
+ context "using a private project" do
let(:project) { create(:project, :private) }
- it 'returns users that are administrators' do
+ it "returns users that are administrators" do
user = build(:user, admin: true)
expect(described_class.users_that_can_read_project([user], project))
.to eq([user])
end
- it 'returns external users if they are the project owner' do
+ it "returns external users if they are the project owner" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -90,7 +90,7 @@ describe Ability do
.to eq([user1])
end
- it 'returns external users if they are project members' do
+ it "returns external users if they are project members" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -101,7 +101,7 @@ describe Ability do
.to eq([user1])
end
- it 'returns an empty Array if all users are internal users without access' do
+ it "returns an empty Array if all users are internal users without access" do
user1 = build(:user)
user2 = build(:user)
users = [user1, user2]
@@ -110,7 +110,7 @@ describe Ability do
.to eq([])
end
- it 'returns an empty Array if all users are external users without access' do
+ it "returns an empty Array if all users are external users without access" do
user1 = build(:user, external: true)
user2 = build(:user, external: true)
users = [user1, user2]
@@ -121,7 +121,7 @@ describe Ability do
end
end
- describe '.users_that_can_read_personal_snippet' do
+ describe ".users_that_can_read_personal_snippet" do
def users_for_snippet(snippet)
described_class.users_that_can_read_personal_snippet(users, snippet)
end
@@ -129,28 +129,28 @@ describe Ability do
let(:users) { create_list(:user, 3) }
let(:author) { users[0] }
- it 'private snippet is readable only by its author' do
+ it "private snippet is readable only by its author" do
snippet = create(:personal_snippet, :private, author: author)
expect(users_for_snippet(snippet)).to match_array([author])
end
- it 'internal snippet is readable by all registered users' do
+ it "internal snippet is readable by all registered users" do
snippet = create(:personal_snippet, :public, author: author)
expect(users_for_snippet(snippet)).to match_array(users)
end
- it 'public snippet is readable by all users' do
+ it "public snippet is readable by all users" do
snippet = create(:personal_snippet, :public, author: author)
expect(users_for_snippet(snippet)).to match_array(users)
end
end
- describe '.merge_requests_readable_by_user' do
- context 'with an admin' do
- it 'returns all merge requests' do
+ describe ".merge_requests_readable_by_user" do
+ context "with an admin" do
+ it "returns all merge requests" do
user = build(:user, admin: true)
merge_request = build(:merge_request)
@@ -159,19 +159,19 @@ describe Ability do
end
end
- context 'without a user' do
- it 'returns merge_requests that are publicly visible' do
+ context "without a user" do
+ it "returns merge_requests that are publicly visible" do
hidden_merge_request = build(:merge_request)
visible_merge_request = build(:merge_request, source_project: build(:project, :public))
merge_requests = described_class
- .merge_requests_readable_by_user([hidden_merge_request, visible_merge_request])
+ .merge_requests_readable_by_user([hidden_merge_request, visible_merge_request])
expect(merge_requests).to eq([visible_merge_request])
end
end
- context 'with a user' do
+ context "with a user" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, source_project: project) }
@@ -191,27 +191,27 @@ describe Ability do
project.add_developer(user)
end
- it 'returns projects visible to the user' do
+ it "returns projects visible to the user" do
expect(readable_merge_requests).to contain_exactly(merge_request, cross_project_merge_request)
end
- context 'when a user cannot read cross project and a filter is passed' do
+ context "when a user cannot read cross project and a filter is passed" do
before do
allow(described_class).to receive(:allowed?).and_call_original
expect(described_class).to receive(:allowed?).with(user, :read_cross_project) { false }
end
subject(:readable_merge_requests) do
- read_cross_project_filter = -> (merge_requests) do
+ read_cross_project_filter = ->(merge_requests) do
merge_requests.select { |mr| mr.source_project == project }
end
described_class.merge_requests_readable_by_user(
all_merge_requests, user,
- filters: { read_cross_project: read_cross_project_filter }
+ filters: {read_cross_project: read_cross_project_filter}
)
end
- it 'returns only MRs of the specified project without checking access on others' do
+ it "returns only MRs of the specified project without checking access on others" do
expect(described_class).not_to receive(:allowed?).with(user, :read_merge_request, cross_project_merge_request)
expect(readable_merge_requests).to contain_exactly(merge_request)
@@ -220,9 +220,9 @@ describe Ability do
end
end
- describe '.issues_readable_by_user' do
- context 'with an admin user' do
- it 'returns all given issues' do
+ describe ".issues_readable_by_user" do
+ context "with an admin user" do
+ it "returns all given issues" do
user = build(:user, admin: true)
issue = build(:issue)
@@ -231,8 +231,8 @@ describe Ability do
end
end
- context 'with a regular user' do
- it 'returns the issues readable by the user' do
+ context "with a regular user" do
+ it "returns the issues readable by the user" do
user = build(:user)
issue = build(:issue)
@@ -242,7 +242,7 @@ describe Ability do
.to eq([issue])
end
- it 'returns an empty Array when no issues are readable' do
+ it "returns an empty Array when no issues are readable" do
user = build(:user)
issue = build(:issue)
@@ -252,8 +252,8 @@ describe Ability do
end
end
- context 'without a regular user' do
- it 'returns issues that are publicly visible' do
+ context "without a regular user" do
+ it "returns issues that are publicly visible" do
hidden_issue = build(:issue)
visible_issue = build(:issue)
@@ -267,7 +267,7 @@ describe Ability do
end
end
- context 'when the user cannot read cross project' do
+ context "when the user cannot read cross project" do
let(:user) { create(:user) }
let(:issue) { create(:issue) }
let(:other_project_issue) { create(:issue) }
@@ -280,10 +280,10 @@ describe Ability do
allow(described_class).to receive(:allowed?).with(user, :read_cross_project, any_args) { false }
end
- it 'excludes issues from other projects whithout checking separatly when passing a scope' do
+ it "excludes issues from other projects whithout checking separatly when passing a scope" do
expect(described_class).not_to receive(:allowed?).with(user, :read_issue, other_project_issue)
- filters = { read_cross_project: -> (issues) { issues.where(project: project) } }
+ filters = {read_cross_project: ->(issues) { issues.where(project: project) }}
result = described_class.issues_readable_by_user(Issue.all, user, filters: filters)
expect(result).to contain_exactly(issue)
@@ -291,13 +291,13 @@ describe Ability do
end
end
- describe '.project_disabled_features_rules' do
+ describe ".project_disabled_features_rules" do
let(:project) { create(:project, :wiki_disabled) }
subject { described_class.policy_for(project.owner, project) }
- context 'wiki named abilities' do
- it 'disables wiki abilities if the project has no wiki' do
+ context "wiki named abilities" do
+ it "disables wiki abilities if the project has no wiki" do
expect(subject).not_to be_allowed(:read_wiki)
expect(subject).not_to be_allowed(:create_wiki)
expect(subject).not_to be_allowed(:update_wiki)
diff --git a/spec/models/abuse_report_spec.rb b/spec/models/abuse_report_spec.rb
index f49a61062c1..6c3ebe2cc43 100644
--- a/spec/models/abuse_report_spec.rb
+++ b/spec/models/abuse_report_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe AbuseReport do
set(:report) { create(:abuse_report) }
@@ -7,8 +7,8 @@ describe AbuseReport do
it { expect(subject).to be_valid }
- describe 'associations' do
- it { is_expected.to belong_to(:reporter).class_name('User') }
+ describe "associations" do
+ it { is_expected.to belong_to(:reporter).class_name("User") }
it { is_expected.to belong_to(:user) }
it "aliases reporter to author" do
@@ -16,34 +16,34 @@ describe AbuseReport do
end
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:reporter) }
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:message) }
- it { is_expected.to validate_uniqueness_of(:user_id).with_message('has already been reported') }
+ it { is_expected.to validate_uniqueness_of(:user_id).with_message("has already been reported") }
end
- describe '#remove_user' do
- it 'blocks the user' do
+ describe "#remove_user" do
+ it "blocks the user" do
expect { subject.remove_user(deleted_by: user) }.to change { subject.user.blocked? }.to(true)
end
- it 'lets a worker delete the user' do
+ it "lets a worker delete the user" do
expect(DeleteUserWorker).to receive(:perform_async).with(user.id, subject.user.id, hard_delete: true)
subject.remove_user(deleted_by: user)
end
end
- describe '#notify' do
- it 'delivers' do
+ describe "#notify" do
+ it "delivers" do
expect(AbuseReportMailer).to receive(:notify).with(subject.id)
.and_return(spy)
subject.notify
end
- it 'returns early when not persisted' do
+ it "returns early when not persisted" do
report = build(:abuse_report)
expect(AbuseReportMailer).not_to receive(:notify)
diff --git a/spec/models/active_session_spec.rb b/spec/models/active_session_spec.rb
index 129b2f92683..639baf3cfe3 100644
--- a/spec/models/active_session_spec.rb
+++ b/spec/models/active_session_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
let(:user) do
@@ -7,31 +7,31 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
end
end
- let(:session) { double(:session, id: '6919a6f1bb119dd7396fadc38fd18d0d') }
+ let(:session) { double(:session, id: "6919a6f1bb119dd7396fadc38fd18d0d") }
let(:request) do
double(:request, {
- user_agent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 ' \
- '(KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]',
- ip: '127.0.0.1',
- session: session
+ user_agent: "Mozilla/5.0 (iPhone; CPU iPhone OS 8_1_3 like Mac OS X) AppleWebKit/600.1.4 " \
+ "(KHTML, like Gecko) Mobile/12B466 [FBDV/iPhone7,2]",
+ ip: "127.0.0.1",
+ session: session,
})
end
- describe '#current?' do
- it 'returns true if the active session matches the current session' do
- active_session = ActiveSession.new(session_id: '6919a6f1bb119dd7396fadc38fd18d0d')
+ describe "#current?" do
+ it "returns true if the active session matches the current session" do
+ active_session = ActiveSession.new(session_id: "6919a6f1bb119dd7396fadc38fd18d0d")
expect(active_session.current?(session)).to be true
end
- it 'returns false if the active session does not match the current session' do
- active_session = ActiveSession.new(session_id: '59822c7d9fcdfa03725eff41782ad97d')
+ it "returns false if the active session does not match the current session" do
+ active_session = ActiveSession.new(session_id: "59822c7d9fcdfa03725eff41782ad97d")
expect(active_session.current?(session)).to be false
end
- it 'returns false if the session id is nil' do
+ it "returns false if the session id is nil" do
active_session = ActiveSession.new(session_id: nil)
session = double(:session, id: nil)
@@ -39,12 +39,12 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
end
end
- describe '.list' do
- it 'returns all sessions by user' do
+ describe ".list" do
+ it "returns all sessions by user" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", Marshal.dump({ session_id: 'a' }))
- redis.set("session:user:gitlab:#{user.id}:59822c7d9fcdfa03725eff41782ad97d", Marshal.dump({ session_id: 'b' }))
- redis.set("session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358", '')
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", Marshal.dump({session_id: "a"}))
+ redis.set("session:user:gitlab:#{user.id}:59822c7d9fcdfa03725eff41782ad97d", Marshal.dump({session_id: "b"}))
+ redis.set("session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358", "")
redis.sadd(
"session:lookup:user:gitlab:#{user.id}",
@@ -55,12 +55,12 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
)
end
- expect(ActiveSession.list(user)).to match_array [{ session_id: 'a' }, { session_id: 'b' }]
+ expect(ActiveSession.list(user)).to match_array [{session_id: "a"}, {session_id: "b"}]
end
- it 'does not return obsolete entries and cleans them up' do
+ it "does not return obsolete entries and cleans them up" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", Marshal.dump({ session_id: 'a' }))
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", Marshal.dump({session_id: "a"}))
redis.sadd(
"session:lookup:user:gitlab:#{user.id}",
@@ -71,52 +71,52 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
)
end
- expect(ActiveSession.list(user)).to eq [{ session_id: 'a' }]
+ expect(ActiveSession.list(user)).to eq [{session_id: "a"}]
Gitlab::Redis::SharedState.with do |redis|
- expect(redis.sscan_each("session:lookup:user:gitlab:#{user.id}").to_a).to eq ['6919a6f1bb119dd7396fadc38fd18d0d']
+ expect(redis.sscan_each("session:lookup:user:gitlab:#{user.id}").to_a).to eq ["6919a6f1bb119dd7396fadc38fd18d0d"]
end
end
- it 'returns an empty array if the use does not have any active session' do
+ it "returns an empty array if the use does not have any active session" do
expect(ActiveSession.list(user)).to eq []
end
end
- describe '.set' do
- it 'sets a new redis entry for the user session and a lookup entry' do
+ describe ".set" do
+ it "sets a new redis entry for the user session and a lookup entry" do
ActiveSession.set(user, request)
Gitlab::Redis::SharedState.with do |redis|
expect(redis.scan_each.to_a).to match_array [
"session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d",
- "session:lookup:user:gitlab:#{user.id}"
+ "session:lookup:user:gitlab:#{user.id}",
]
end
end
- it 'adds timestamps and information from the request' do
- Timecop.freeze(Time.zone.parse('2018-03-12 09:06')) do
+ it "adds timestamps and information from the request" do
+ Timecop.freeze(Time.zone.parse("2018-03-12 09:06")) do
ActiveSession.set(user, request)
session = ActiveSession.list(user)
expect(session.count).to eq 1
expect(session.first).to have_attributes(
- ip_address: '127.0.0.1',
- browser: 'Mobile Safari',
- os: 'iOS',
- device_name: 'iPhone 6',
- device_type: 'smartphone',
- created_at: Time.zone.parse('2018-03-12 09:06'),
- updated_at: Time.zone.parse('2018-03-12 09:06'),
- session_id: '6919a6f1bb119dd7396fadc38fd18d0d'
+ ip_address: "127.0.0.1",
+ browser: "Mobile Safari",
+ os: "iOS",
+ device_name: "iPhone 6",
+ device_type: "smartphone",
+ created_at: Time.zone.parse("2018-03-12 09:06"),
+ updated_at: Time.zone.parse("2018-03-12 09:06"),
+ session_id: "6919a6f1bb119dd7396fadc38fd18d0d"
)
end
end
- it 'keeps the created_at from the login on consecutive requests' do
- now = Time.zone.parse('2018-03-12 09:06')
+ it "keeps the created_at from the login on consecutive requests" do
+ now = Time.zone.parse("2018-03-12 09:06")
Timecop.freeze(now) do
ActiveSession.set(user, request)
@@ -127,20 +127,20 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
session = ActiveSession.list(user)
expect(session.first).to have_attributes(
- created_at: Time.zone.parse('2018-03-12 09:06'),
- updated_at: Time.zone.parse('2018-03-12 09:07')
+ created_at: Time.zone.parse("2018-03-12 09:06"),
+ updated_at: Time.zone.parse("2018-03-12 09:07")
)
end
end
end
end
- describe '.destroy' do
- it 'removes the entry associated with the currently killed user session' do
+ describe ".destroy" do
+ it "removes the entry associated with the currently killed user session" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", '')
- redis.set("session:user:gitlab:#{user.id}:59822c7d9fcdfa03725eff41782ad97d", '')
- redis.set("session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358", '')
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", "")
+ redis.set("session:user:gitlab:#{user.id}:59822c7d9fcdfa03725eff41782ad97d", "")
+ redis.set("session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358", "")
end
ActiveSession.destroy(user, request.session.id)
@@ -148,15 +148,15 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
Gitlab::Redis::SharedState.with do |redis|
expect(redis.scan_each(match: "session:user:gitlab:*")).to match_array [
"session:user:gitlab:#{user.id}:59822c7d9fcdfa03725eff41782ad97d",
- "session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358"
+ "session:user:gitlab:9999:5c8611e4f9c69645ad1a1492f4131358",
]
end
end
- it 'removes the lookup entry' do
+ it "removes the lookup entry" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", '')
- redis.sadd("session:lookup:user:gitlab:#{user.id}", '6919a6f1bb119dd7396fadc38fd18d0d')
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", "")
+ redis.sadd("session:lookup:user:gitlab:#{user.id}", "6919a6f1bb119dd7396fadc38fd18d0d")
end
ActiveSession.destroy(user, request.session.id)
@@ -166,10 +166,10 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
end
end
- it 'removes the devise session' do
+ it "removes the devise session" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", '')
- redis.set("session:gitlab:6919a6f1bb119dd7396fadc38fd18d0d", '')
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", "")
+ redis.set("session:gitlab:6919a6f1bb119dd7396fadc38fd18d0d", "")
end
ActiveSession.destroy(user, request.session.id)
@@ -179,9 +179,9 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
end
end
- it 'does not remove the devise session if the active session could not be found' do
+ it "does not remove the devise session if the active session could not be found" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:gitlab:6919a6f1bb119dd7396fadc38fd18d0d", '')
+ redis.set("session:gitlab:6919a6f1bb119dd7396fadc38fd18d0d", "")
end
other_user = create(:user)
@@ -194,22 +194,22 @@ RSpec.describe ActiveSession, :clean_gitlab_redis_shared_state do
end
end
- describe '.cleanup' do
- it 'removes obsolete lookup entries' do
+ describe ".cleanup" do
+ it "removes obsolete lookup entries" do
Gitlab::Redis::SharedState.with do |redis|
- redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", '')
- redis.sadd("session:lookup:user:gitlab:#{user.id}", '6919a6f1bb119dd7396fadc38fd18d0d')
- redis.sadd("session:lookup:user:gitlab:#{user.id}", '59822c7d9fcdfa03725eff41782ad97d')
+ redis.set("session:user:gitlab:#{user.id}:6919a6f1bb119dd7396fadc38fd18d0d", "")
+ redis.sadd("session:lookup:user:gitlab:#{user.id}", "6919a6f1bb119dd7396fadc38fd18d0d")
+ redis.sadd("session:lookup:user:gitlab:#{user.id}", "59822c7d9fcdfa03725eff41782ad97d")
end
ActiveSession.cleanup(user)
Gitlab::Redis::SharedState.with do |redis|
- expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).to eq ['6919a6f1bb119dd7396fadc38fd18d0d']
+ expect(redis.smembers("session:lookup:user:gitlab:#{user.id}")).to eq ["6919a6f1bb119dd7396fadc38fd18d0d"]
end
end
- it 'does not bail if there are no lookup entries' do
+ it "does not bail if there are no lookup entries" do
ActiveSession.cleanup(user)
end
end
diff --git a/spec/models/appearance_spec.rb b/spec/models/appearance_spec.rb
index 3e95aa2b5dd..0d1792ac2c8 100644
--- a/spec/models/appearance_spec.rb
+++ b/spec/models/appearance_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe Appearance do
subject { build(:appearance) }
@@ -8,8 +8,8 @@ describe Appearance do
it { is_expected.to have_many(:uploads) }
- describe '#single_appearance_row' do
- it 'adds an error when more than 1 row exists' do
+ describe "#single_appearance_row" do
+ it "adds an error when more than 1 row exists" do
create(:appearance)
new_row = build(:appearance)
@@ -19,77 +19,77 @@ describe Appearance do
end
end
- context 'with uploads' do
- it_behaves_like 'model with uploads', false do
+ context "with uploads" do
+ it_behaves_like "model with uploads", false do
let(:model_object) { create(:appearance, :with_logo) }
let(:upload_attribute) { :logo }
let(:uploader_class) { AttachmentUploader }
end
end
- shared_examples 'logo paths' do |logo_type|
+ shared_examples "logo paths" do |logo_type|
let(:appearance) { create(:appearance, "with_#{logo_type}".to_sym) }
- let(:filename) { 'dk.png' }
+ let(:filename) { "dk.png" }
let(:expected_path) { "/uploads/-/system/appearance/#{logo_type}/#{appearance.id}/#{filename}" }
- it 'returns nil when there is no upload' do
+ it "returns nil when there is no upload" do
expect(subject.send("#{logo_type}_path")).to be_nil
end
- it 'returns the path when the upload has been orphaned' do
+ it "returns the path when the upload has been orphaned" do
appearance.send(logo_type).upload.destroy
appearance.reload
expect(appearance.send("#{logo_type}_path")).to eq(expected_path)
end
- it 'returns a local path using the system route' do
+ it "returns a local path using the system route" do
expect(appearance.send("#{logo_type}_path")).to eq(expected_path)
end
- describe 'with asset host configured' do
- let(:asset_host) { 'https://gitlab-assets.example.com' }
+ describe "with asset host configured" do
+ let(:asset_host) { "https://gitlab-assets.example.com" }
before do
allow(ActionController::Base).to receive(:asset_host) { asset_host }
end
- it 'returns a full URL with the system path' do
+ it "returns a full URL with the system path" do
expect(appearance.send("#{logo_type}_path")).to eq("#{asset_host}#{expected_path}")
end
end
end
- %i(logo header_logo favicon).each do |logo_type|
- it_behaves_like 'logo paths', logo_type
+ %i[logo header_logo favicon].each do |logo_type|
+ it_behaves_like "logo paths", logo_type
end
- describe 'validations' do
- let(:triplet) { '#000' }
- let(:hex) { '#AABBCC' }
+ describe "validations" do
+ let(:triplet) { "#000" }
+ let(:hex) { "#AABBCC" }
it { is_expected.to allow_value(nil).for(:message_background_color) }
it { is_expected.to allow_value(triplet).for(:message_background_color) }
it { is_expected.to allow_value(hex).for(:message_background_color) }
- it { is_expected.not_to allow_value('000').for(:message_background_color) }
+ it { is_expected.not_to allow_value("000").for(:message_background_color) }
it { is_expected.to allow_value(nil).for(:message_font_color) }
it { is_expected.to allow_value(triplet).for(:message_font_color) }
it { is_expected.to allow_value(hex).for(:message_font_color) }
- it { is_expected.not_to allow_value('000').for(:message_font_color) }
+ it { is_expected.not_to allow_value("000").for(:message_font_color) }
end
- describe 'email_header_and_footer_enabled' do
- context 'default email_header_and_footer_enabled flag value' do
- it 'returns email_header_and_footer_enabled as true' do
+ describe "email_header_and_footer_enabled" do
+ context "default email_header_and_footer_enabled flag value" do
+ it "returns email_header_and_footer_enabled as true" do
appearance = build(:appearance)
expect(appearance.email_header_and_footer_enabled?).to eq(false)
end
end
- context 'when setting email_header_and_footer_enabled flag value' do
- it 'returns email_header_and_footer_enabled as true' do
+ context "when setting email_header_and_footer_enabled flag value" do
+ it "returns email_header_and_footer_enabled as true" do
appearance = build(:appearance, email_header_and_footer_enabled: true)
expect(appearance.email_header_and_footer_enabled?).to eq(true)
diff --git a/spec/models/application_record_spec.rb b/spec/models/application_record_spec.rb
index fd25132ed3a..62065dce247 100644
--- a/spec/models/application_record_spec.rb
+++ b/spec/models/application_record_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ApplicationRecord do
- describe '#id_in' do
+ describe "#id_in" do
let(:records) { create_list(:user, 3) }
- it 'returns records of the ids' do
+ it "returns records of the ids" do
expect(User.id_in(records.last(2).map(&:id))).to eq(records.last(2))
end
end
- describe '.safe_find_or_create_by' do
- it 'creates the user avoiding race conditions' do
+ describe ".safe_find_or_create_by" do
+ it "creates the user avoiding race conditions" do
expect(Suggestion).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique)
allow(Suggestion).to receive(:find_or_create_by).and_call_original
@@ -21,15 +21,15 @@ describe ApplicationRecord do
end
end
- describe '.safe_find_or_create_by!' do
- it 'creates a record using safe_find_or_create_by' do
+ describe ".safe_find_or_create_by!" do
+ it "creates a record using safe_find_or_create_by" do
expect(Suggestion).to receive(:find_or_create_by).and_call_original
expect(Suggestion.safe_find_or_create_by!(build(:suggestion).attributes))
.to be_a(Suggestion)
end
- it 'raises a validation error if the record was not persisted' do
+ it "raises a validation error if the record was not persisted" do
expect { Suggestion.find_or_create_by!(note: nil) }.to raise_error(ActiveRecord::RecordInvalid)
end
end
diff --git a/spec/models/application_setting/term_spec.rb b/spec/models/application_setting/term_spec.rb
index aa49594f4d1..706d31d1938 100644
--- a/spec/models/application_setting/term_spec.rb
+++ b/spec/models/application_setting/term_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe ApplicationSetting::Term do
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:terms) }
end
- describe '.latest' do
- it 'finds the latest terms' do
+ describe ".latest" do
+ it "finds the latest terms" do
terms = create(:term)
expect(described_class.latest).to eq(terms)
end
end
- describe '#accepted_by_user?' do
+ describe "#accepted_by_user?" do
let(:user) { create(:user) }
let(:term) { create(:term) }
- it 'is true when the user accepted the terms' do
+ it "is true when the user accepted the terms" do
accept_terms(term, user)
expect(term.accepted_by_user?(user)).to be(true)
end
- it 'is false when the user declined the terms' do
+ it "is false when the user declined the terms" do
decline_terms(term, user)
expect(term.accepted_by_user?(user)).to be(false)
end
- it 'does not cause a query when the user accepted the current terms' do
+ it "does not cause a query when the user accepted the current terms" do
accept_terms(term, user)
expect { term.accepted_by_user?(user) }.not_to exceed_query_limit(0)
end
- it 'returns false if the currently accepted terms are different' do
+ it "returns false if the currently accepted terms are different" do
accept_terms(create(:term), user)
expect(term.accepted_by_user?(user)).to be(false)
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb
index 789e14e8a20..e61418da06c 100644
--- a/spec/models/application_setting_spec.rb
+++ b/spec/models/application_setting_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ApplicationSetting do
let(:setting) { described_class.create_from_defaults }
@@ -10,10 +10,10 @@ describe ApplicationSetting do
it { expect(setting.uuid).to be_present }
it { expect(setting).to have_db_column(:auto_devops_enabled) }
- describe 'validations' do
- let(:http) { 'http://example.com' }
- let(:https) { 'https://example.com' }
- let(:ftp) { 'ftp://example.com' }
+ describe "validations" do
+ let(:http) { "http://example.com" }
+ let(:https) { "https://example.com" }
+ let(:ftp) { "ftp://example.com" }
it { is_expected.to allow_value(nil).for(:home_page_url) }
it { is_expected.to allow_value(http).for(:home_page_url) }
@@ -28,31 +28,31 @@ describe ApplicationSetting do
it { is_expected.to allow_value("dev.gitlab.com").for(:commit_email_hostname) }
it { is_expected.not_to allow_value("@dev.gitlab").for(:commit_email_hostname) }
- describe 'default_artifacts_expire_in' do
- it 'sets an error if it cannot parse' do
- setting.update(default_artifacts_expire_in: 'a')
+ describe "default_artifacts_expire_in" do
+ it "sets an error if it cannot parse" do
+ setting.update(default_artifacts_expire_in: "a")
expect_invalid
end
- it 'sets an error if it is blank' do
- setting.update(default_artifacts_expire_in: ' ')
+ it "sets an error if it is blank" do
+ setting.update(default_artifacts_expire_in: " ")
expect_invalid
end
- it 'sets the value if it is valid' do
- setting.update(default_artifacts_expire_in: '30 days')
+ it "sets the value if it is valid" do
+ setting.update(default_artifacts_expire_in: "30 days")
expect(setting).to be_valid
- expect(setting.default_artifacts_expire_in).to eq('30 days')
+ expect(setting.default_artifacts_expire_in).to eq("30 days")
end
- it 'sets the value if it is 0' do
- setting.update(default_artifacts_expire_in: '0')
+ it "sets the value if it is 0" do
+ setting.update(default_artifacts_expire_in: "0")
expect(setting).to be_valid
- expect(setting.default_artifacts_expire_in).to eq('0')
+ expect(setting.default_artifacts_expire_in).to eq("0")
end
def expect_invalid
@@ -77,12 +77,12 @@ describe ApplicationSetting do
.is_less_than(65536)
end
- context 'key restrictions' do
- it 'supports all key types' do
+ context "key restrictions" do
+ it "supports all key types" do
expect(described_class::SUPPORTED_KEY_TYPES).to contain_exactly(:rsa, :dsa, :ecdsa, :ed25519)
end
- it 'does not allow all key types to be disabled' do
+ it "does not allow all key types to be disabled" do
described_class::SUPPORTED_KEY_TYPES.each do |type|
setting["#{type}_key_restriction"] = described_class::FORBIDDEN_KEY_VALUE
end
@@ -104,120 +104,120 @@ describe ApplicationSetting do
end
end
- it_behaves_like 'an object with email-formated attributes', :admin_notification_email do
+ it_behaves_like "an object with email-formated attributes", :admin_notification_email do
subject { setting }
end
# Upgraded databases will have this sort of content
- context 'repository_storages is a String, not an Array' do
+ context "repository_storages is a String, not an Array" do
before do
- described_class.where(id: setting.id).update_all(repository_storages: 'default')
+ described_class.where(id: setting.id).update_all(repository_storages: "default")
end
- it { expect(setting.repository_storages).to eq(['default']) }
+ it { expect(setting.repository_storages).to eq(["default"]) }
end
- context '#commit_email_hostname' do
- it 'returns configured gitlab hostname if commit_email_hostname is not defined' do
+ context "#commit_email_hostname" do
+ it "returns configured gitlab hostname if commit_email_hostname is not defined" do
setting.update(commit_email_hostname: nil)
expect(setting.commit_email_hostname).to eq("users.noreply.#{Gitlab.config.gitlab.host}")
end
end
- context 'auto_devops_domain setting' do
- context 'when auto_devops_enabled? is true' do
+ context "auto_devops_domain setting" do
+ context "when auto_devops_enabled? is true" do
before do
setting.update(auto_devops_enabled: true)
end
- it 'can be blank' do
- setting.update(auto_devops_domain: '')
+ it "can be blank" do
+ setting.update(auto_devops_domain: "")
expect(setting).to be_valid
end
- context 'with a valid value' do
+ context "with a valid value" do
before do
- setting.update(auto_devops_domain: 'domain.com')
+ setting.update(auto_devops_domain: "domain.com")
end
- it 'is valid' do
+ it "is valid" do
expect(setting).to be_valid
end
end
- context 'with an invalid value' do
+ context "with an invalid value" do
before do
- setting.update(auto_devops_domain: 'definitelynotahostname')
+ setting.update(auto_devops_domain: "definitelynotahostname")
end
- it 'is invalid' do
+ it "is invalid" do
expect(setting).to be_invalid
end
end
end
end
- context 'repository storages' do
+ context "repository storages" do
before do
storages = {
- 'custom1' => 'tmp/tests/custom_repositories_1',
- 'custom2' => 'tmp/tests/custom_repositories_2',
- 'custom3' => 'tmp/tests/custom_repositories_3'
+ "custom1" => "tmp/tests/custom_repositories_1",
+ "custom2" => "tmp/tests/custom_repositories_2",
+ "custom3" => "tmp/tests/custom_repositories_3",
}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
- describe 'inclusion' do
- it { is_expected.to allow_value('custom1').for(:repository_storages) }
- it { is_expected.to allow_value(%w(custom2 custom3)).for(:repository_storages) }
- it { is_expected.not_to allow_value('alternative').for(:repository_storages) }
- it { is_expected.not_to allow_value(%w(alternative custom1)).for(:repository_storages) }
+ describe "inclusion" do
+ it { is_expected.to allow_value("custom1").for(:repository_storages) }
+ it { is_expected.to allow_value(%w[custom2 custom3]).for(:repository_storages) }
+ it { is_expected.not_to allow_value("alternative").for(:repository_storages) }
+ it { is_expected.not_to allow_value(%w[alternative custom1]).for(:repository_storages) }
end
- describe 'presence' do
+ describe "presence" do
it { is_expected.not_to allow_value([]).for(:repository_storages) }
it { is_expected.not_to allow_value("").for(:repository_storages) }
it { is_expected.not_to allow_value(nil).for(:repository_storages) }
end
- describe '.pick_repository_storage' do
- it 'uses Array#sample to pick a random storage' do
- array = double('array', sample: 'random')
+ describe ".pick_repository_storage" do
+ it "uses Array#sample to pick a random storage" do
+ array = double("array", sample: "random")
expect(setting).to receive(:repository_storages).and_return(array)
- expect(setting.pick_repository_storage).to eq('random')
+ expect(setting.pick_repository_storage).to eq("random")
end
end
end
- context 'housekeeping settings' do
+ context "housekeeping settings" do
it { is_expected.not_to allow_value(0).for(:housekeeping_incremental_repack_period) }
- it 'wants the full repack period to be at least the incremental repack period' do
+ it "wants the full repack period to be at least the incremental repack period" do
subject.housekeeping_incremental_repack_period = 2
subject.housekeeping_full_repack_period = 1
expect(subject).not_to be_valid
end
- it 'wants the gc period to be at least the full repack period' do
+ it "wants the gc period to be at least the full repack period" do
subject.housekeeping_full_repack_period = 100
subject.housekeeping_gc_period = 90
expect(subject).not_to be_valid
end
- it 'allows the same period for incremental repack and full repack, effectively skipping incremental repack' do
+ it "allows the same period for incremental repack and full repack, effectively skipping incremental repack" do
subject.housekeeping_incremental_repack_period = 2
subject.housekeeping_full_repack_period = 2
expect(subject).to be_valid
end
- it 'allows the same period for full repack and gc, effectively skipping full repack' do
+ it "allows the same period for full repack and gc, effectively skipping full repack" do
subject.housekeeping_full_repack_period = 100
subject.housekeeping_gc_period = 100
@@ -225,7 +225,7 @@ describe ApplicationSetting do
end
end
- context 'gitaly timeouts' do
+ context "gitaly timeouts" do
[:gitaly_timeout_default, :gitaly_timeout_medium, :gitaly_timeout_fast].each do |timeout_name|
it do
is_expected.to validate_presence_of(timeout_name)
@@ -243,7 +243,7 @@ describe ApplicationSetting do
end
end
- it 'accepts all timeouts equal' do
+ it "accepts all timeouts equal" do
subject.gitaly_timeout_default = 0
subject.gitaly_timeout_medium = 0
subject.gitaly_timeout_fast = 0
@@ -251,7 +251,7 @@ describe ApplicationSetting do
expect(subject).to be_valid
end
- it 'accepts timeouts in descending order' do
+ it "accepts timeouts in descending order" do
subject.gitaly_timeout_default = 50
subject.gitaly_timeout_medium = 30
subject.gitaly_timeout_fast = 20
@@ -259,7 +259,7 @@ describe ApplicationSetting do
expect(subject).to be_valid
end
- it 'rejects timeouts in ascending order' do
+ it "rejects timeouts in ascending order" do
subject.gitaly_timeout_default = 20
subject.gitaly_timeout_medium = 30
subject.gitaly_timeout_fast = 50
@@ -267,7 +267,7 @@ describe ApplicationSetting do
expect(subject).to be_invalid
end
- it 'rejects medium timeout larger than default' do
+ it "rejects medium timeout larger than default" do
subject.gitaly_timeout_default = 30
subject.gitaly_timeout_medium = 50
subject.gitaly_timeout_fast = 20
@@ -275,7 +275,7 @@ describe ApplicationSetting do
expect(subject).to be_invalid
end
- it 'rejects medium timeout smaller than fast' do
+ it "rejects medium timeout smaller than fast" do
subject.gitaly_timeout_default = 30
subject.gitaly_timeout_medium = 15
subject.gitaly_timeout_fast = 20
@@ -284,14 +284,14 @@ describe ApplicationSetting do
end
end
- describe 'enforcing terms' do
- it 'requires the terms to present when enforcing users to accept' do
+ describe "enforcing terms" do
+ it "requires the terms to present when enforcing users to accept" do
subject.enforce_terms = true
expect(subject).to be_invalid
end
- it 'is valid when terms are created' do
+ it "is valid when terms are created" do
create(:term)
subject.enforce_terms = true
@@ -300,39 +300,39 @@ describe ApplicationSetting do
end
end
- context 'restrict creating duplicates' do
+ context "restrict creating duplicates" do
before do
described_class.create_from_defaults
end
- it 'raises an record creation violation if already created' do
+ it "raises an record creation violation if already created" do
expect { described_class.create_from_defaults }.to raise_error(ActiveRecord::RecordNotUnique)
end
end
- describe 'setting Sentry DSNs' do
- context 'server DSN' do
- it 'strips leading and trailing whitespace' do
- subject.update(sentry_dsn: ' http://test ')
+ describe "setting Sentry DSNs" do
+ context "server DSN" do
+ it "strips leading and trailing whitespace" do
+ subject.update(sentry_dsn: " http://test ")
- expect(subject.sentry_dsn).to eq('http://test')
+ expect(subject.sentry_dsn).to eq("http://test")
end
- it 'handles nil values' do
+ it "handles nil values" do
subject.update(sentry_dsn: nil)
expect(subject.sentry_dsn).to be_nil
end
end
- context 'client-side DSN' do
- it 'strips leading and trailing whitespace' do
- subject.update(clientside_sentry_dsn: ' http://test ')
+ context "client-side DSN" do
+ it "strips leading and trailing whitespace" do
+ subject.update(clientside_sentry_dsn: " http://test ")
- expect(subject.clientside_sentry_dsn).to eq('http://test')
+ expect(subject.clientside_sentry_dsn).to eq("http://test")
end
- it 'handles nil values' do
+ it "handles nil values" do
subject.update(clientside_sentry_dsn: nil)
expect(subject.clientside_sentry_dsn).to be_nil
@@ -340,26 +340,26 @@ describe ApplicationSetting do
end
end
- describe '#disabled_oauth_sign_in_sources=' do
+ describe "#disabled_oauth_sign_in_sources=" do
before do
allow(Devise).to receive(:omniauth_providers).and_return([:github])
end
- it 'removes unknown sources (as strings) from the array' do
+ it "removes unknown sources (as strings) from the array" do
subject.disabled_oauth_sign_in_sources = %w[github test]
expect(subject).to be_valid
- expect(subject.disabled_oauth_sign_in_sources).to eq ['github']
+ expect(subject.disabled_oauth_sign_in_sources).to eq ["github"]
end
- it 'removes unknown sources (as symbols) from the array' do
+ it "removes unknown sources (as symbols) from the array" do
subject.disabled_oauth_sign_in_sources = %i[github test]
expect(subject).to be_valid
- expect(subject.disabled_oauth_sign_in_sources).to eq ['github']
+ expect(subject.disabled_oauth_sign_in_sources).to eq ["github"]
end
- it 'ignores nil' do
+ it "ignores nil" do
subject.disabled_oauth_sign_in_sources = nil
expect(subject).to be_valid
@@ -367,169 +367,169 @@ describe ApplicationSetting do
end
end
- context 'restricted signup domains' do
- it 'sets single domain' do
- setting.domain_whitelist_raw = 'example.com'
- expect(setting.domain_whitelist).to eq(['example.com'])
+ context "restricted signup domains" do
+ it "sets single domain" do
+ setting.domain_whitelist_raw = "example.com"
+ expect(setting.domain_whitelist).to eq(["example.com"])
end
- 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'])
+ 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 'sets 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'])
+ expect(setting.domain_whitelist).to eq(["example.com", "*.example.com"])
end
- it 'sets 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'])
+ expect(setting.domain_whitelist).to eq(["example.com", "*.example.com"])
end
end
- context 'blacklisted signup domains' do
- it 'sets single domain' do
- setting.domain_blacklist_raw = 'example.com'
- expect(setting.domain_blacklist).to contain_exactly('example.com')
+ context "blacklisted signup domains" do
+ it "sets single domain" do
+ setting.domain_blacklist_raw = "example.com"
+ expect(setting.domain_blacklist).to contain_exactly("example.com")
end
- 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')
+ 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 'sets 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')
+ expect(setting.domain_blacklist).to contain_exactly("example.com", "*.example.com")
end
- it 'sets 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')
+ expect(setting.domain_blacklist).to contain_exactly("example.com", "*.example.com")
end
- it 'sets 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')
+ expect(setting.domain_blacklist).to contain_exactly("example.com", "*.example.com")
end
- it 'sets 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')
+ expect(setting.domain_blacklist).to contain_exactly("example.com", "*.example.com", "test.com", "block.com", "yes.com")
end
- 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')
+ 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
end
- describe 'performance bar settings' do
- describe 'performance_bar_allowed_group' do
- context 'with no performance_bar_allowed_group_id saved' do
- it 'returns nil' do
+ describe "performance bar settings" do
+ describe "performance_bar_allowed_group" do
+ context "with no performance_bar_allowed_group_id saved" do
+ it "returns nil" do
expect(setting.performance_bar_allowed_group).to be_nil
end
end
- context 'with a performance_bar_allowed_group_id saved' do
+ context "with a performance_bar_allowed_group_id saved" do
let(:group) { create(:group) }
before do
setting.update!(performance_bar_allowed_group_id: group.id)
end
- it 'returns the group' do
+ it "returns the group" do
expect(setting.reload.performance_bar_allowed_group).to eq(group)
end
end
end
- describe 'performance_bar_enabled' do
- context 'with the Performance Bar is enabled' do
+ describe "performance_bar_enabled" do
+ context "with the Performance Bar is enabled" do
let(:group) { create(:group) }
before do
setting.update!(performance_bar_allowed_group_id: group.id)
end
- it 'returns true' do
+ it "returns true" do
expect(setting.reload.performance_bar_enabled).to be_truthy
end
end
end
end
- describe 'usage ping settings' do
- context 'when the usage ping is disabled in gitlab.yml' do
+ describe "usage ping settings" do
+ context "when the usage ping is disabled in gitlab.yml" do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(false)
end
- it 'does not allow the usage ping to be configured' do
+ it "does not allow the usage ping to be configured" do
expect(setting.usage_ping_can_be_configured?).to be_falsey
end
- context 'when the usage ping is disabled in the DB' do
+ context "when the usage ping is disabled in the DB" do
before do
setting.usage_ping_enabled = false
end
- it 'returns false for usage_ping_enabled' do
+ it "returns false for usage_ping_enabled" do
expect(setting.usage_ping_enabled).to be_falsey
end
end
- context 'when the usage ping is enabled in the DB' do
+ context "when the usage ping is enabled in the DB" do
before do
setting.usage_ping_enabled = true
end
- it 'returns false for usage_ping_enabled' do
+ it "returns false for usage_ping_enabled" do
expect(setting.usage_ping_enabled).to be_falsey
end
end
end
- context 'when the usage ping is enabled in gitlab.yml' do
+ context "when the usage ping is enabled in gitlab.yml" do
before do
allow(Settings.gitlab).to receive(:usage_ping_enabled).and_return(true)
end
- it 'allows the usage ping to be configured' do
+ it "allows the usage ping to be configured" do
expect(setting.usage_ping_can_be_configured?).to be_truthy
end
- context 'when the usage ping is disabled in the DB' do
+ context "when the usage ping is disabled in the DB" do
before do
setting.usage_ping_enabled = false
end
- it 'returns false for usage_ping_enabled' do
+ it "returns false for usage_ping_enabled" do
expect(setting.usage_ping_enabled).to be_falsey
end
end
- context 'when the usage ping is enabled in the DB' do
+ context "when the usage ping is enabled in the DB" do
before do
setting.usage_ping_enabled = true
end
- it 'returns true for usage_ping_enabled' do
+ it "returns true for usage_ping_enabled" do
expect(setting.usage_ping_enabled).to be_truthy
end
end
end
end
- describe '#allowed_key_types' do
- it 'includes all key types by default' do
+ describe "#allowed_key_types" do
+ it "includes all key types by default" do
expect(setting.allowed_key_types).to contain_exactly(*described_class::SUPPORTED_KEY_TYPES)
end
- it 'excludes disabled key types' do
+ it "excludes disabled key types" do
expect(setting.allowed_key_types).to include(:ed25519)
setting.ed25519_key_restriction = described_class::FORBIDDEN_KEY_VALUE
@@ -538,50 +538,50 @@ describe ApplicationSetting do
end
end
- describe '#key_restriction_for' do
- it 'returns the restriction value for recognised types' do
+ describe "#key_restriction_for" do
+ it "returns the restriction value for recognised types" do
setting.rsa_key_restriction = 1024
expect(setting.key_restriction_for(:rsa)).to eq(1024)
end
- it 'allows types to be passed as a string' do
+ it "allows types to be passed as a string" do
setting.rsa_key_restriction = 1024
- expect(setting.key_restriction_for('rsa')).to eq(1024)
+ expect(setting.key_restriction_for("rsa")).to eq(1024)
end
- it 'returns forbidden for unrecognised type' do
+ it "returns forbidden for unrecognised type" do
expect(setting.key_restriction_for(:foo)).to eq(described_class::FORBIDDEN_KEY_VALUE)
end
end
- describe '#allow_signup?' do
- it 'returns true' do
+ describe "#allow_signup?" do
+ it "returns true" do
expect(setting.allow_signup?).to be_truthy
end
- it 'returns false if signup is disabled' do
+ it "returns false if signup is disabled" do
allow(setting).to receive(:signup_enabled?).and_return(false)
expect(setting.allow_signup?).to be_falsey
end
- it 'returns false if password authentication is disabled for the web interface' do
+ it "returns false if password authentication is disabled for the web interface" do
allow(setting).to receive(:password_authentication_enabled_for_web?).and_return(false)
expect(setting.allow_signup?).to be_falsey
end
end
- describe '#user_default_internal_regex_enabled?' do
+ describe "#user_default_internal_regex_enabled?" do
using RSpec::Parameterized::TableSyntax
where(:user_default_external, :user_default_internal_regex, :result) do
false | nil | false
- false | '' | false
+ false | "" | false
false | '^(?:(?!\.ext@).)*$\r?\n?' | false
- true | '' | false
+ true | "" | false
true | nil | false
true | '^(?:(?!\.ext@).)*$\r?\n?' | true
end
@@ -598,25 +598,25 @@ describe ApplicationSetting do
end
end
- context 'diff limit settings' do
- describe '#diff_max_patch_bytes' do
- context 'validations' do
+ context "diff limit settings" do
+ describe "#diff_max_patch_bytes" do
+ context "validations" do
it { is_expected.to validate_presence_of(:diff_max_patch_bytes) }
it do
is_expected.to validate_numericality_of(:diff_max_patch_bytes)
- .only_integer
- .is_greater_than_or_equal_to(Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES)
- .is_less_than_or_equal_to(Gitlab::Git::Diff::MAX_PATCH_BYTES_UPPER_BOUND)
+ .only_integer
+ .is_greater_than_or_equal_to(Gitlab::Git::Diff::DEFAULT_MAX_PATCH_BYTES)
+ .is_less_than_or_equal_to(Gitlab::Git::Diff::MAX_PATCH_BYTES_UPPER_BOUND)
end
end
end
end
- describe '#archive_builds_older_than' do
+ describe "#archive_builds_older_than" do
subject { setting.archive_builds_older_than }
- context 'when the archive_builds_in_seconds is set' do
+ context "when the archive_builds_in_seconds is set" do
before do
setting.archive_builds_in_seconds = 3600
end
@@ -624,7 +624,7 @@ describe ApplicationSetting do
it { is_expected.to be_within(1.minute).of(1.hour.ago) }
end
- context 'when the archive_builds_in_seconds is set' do
+ context "when the archive_builds_in_seconds is set" do
before do
setting.archive_builds_in_seconds = nil
end
diff --git a/spec/models/award_emoji_spec.rb b/spec/models/award_emoji_spec.rb
index 3f52091698c..2b5d612b8a9 100644
--- a/spec/models/award_emoji_spec.rb
+++ b/spec/models/award_emoji_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe AwardEmoji do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to(:awardable) }
it { is_expected.to belong_to(:user) }
end
- describe 'modules' do
+ describe "modules" do
it { is_expected.to include_module(Participable) }
end
@@ -42,35 +42,35 @@ describe AwardEmoji do
end
end
- describe 'expiring ETag cache' do
- context 'on a note' do
+ describe "expiring ETag cache" do
+ context "on a note" do
let(:note) { create(:note_on_issue) }
let(:award_emoji) { build(:award_emoji, user: build(:user), awardable: note) }
- it 'calls expire_etag_cache on the note when saved' do
+ it "calls expire_etag_cache on the note when saved" do
expect(note).to receive(:expire_etag_cache)
award_emoji.save!
end
- it 'calls expire_etag_cache on the note when destroyed' do
+ it "calls expire_etag_cache on the note when destroyed" do
expect(note).to receive(:expire_etag_cache)
award_emoji.destroy!
end
end
- context 'on another awardable' do
+ context "on another awardable" do
let(:issue) { create(:issue) }
let(:award_emoji) { build(:award_emoji, user: build(:user), awardable: issue) }
- it 'does not call expire_etag_cache on the issue when saved' do
+ it "does not call expire_etag_cache on the issue when saved" do
expect(issue).not_to receive(:expire_etag_cache)
award_emoji.save!
end
- it 'does not call expire_etag_cache on the issue when destroyed' do
+ it "does not call expire_etag_cache on the issue when destroyed" do
expect(issue).not_to receive(:expire_etag_cache)
award_emoji.destroy!
@@ -78,26 +78,26 @@ describe AwardEmoji do
end
end
- describe '.award_counts_for_user' do
+ describe ".award_counts_for_user" do
let(:user) { create(:user) }
before do
- create(:award_emoji, user: user, name: 'thumbsup')
- create(:award_emoji, user: user, name: 'thumbsup')
- create(:award_emoji, user: user, name: 'thumbsdown')
- create(:award_emoji, user: user, name: '+1')
+ create(:award_emoji, user: user, name: "thumbsup")
+ create(:award_emoji, user: user, name: "thumbsup")
+ create(:award_emoji, user: user, name: "thumbsdown")
+ create(:award_emoji, user: user, name: "+1")
end
- it 'returns the awarded emoji in descending order' do
+ it "returns the awarded emoji in descending order" do
awards = described_class.award_counts_for_user(user)
- expect(awards).to eq('thumbsup' => 2, 'thumbsdown' => 1, '+1' => 1)
+ expect(awards).to eq("thumbsup" => 2, "thumbsdown" => 1, "+1" => 1)
end
- it 'limits the returned number of rows' do
+ it "limits the returned number of rows" do
awards = described_class.award_counts_for_user(user, 1)
- expect(awards).to eq('thumbsup' => 2)
+ expect(awards).to eq("thumbsup" => 2)
end
end
end
diff --git a/spec/models/badge_spec.rb b/spec/models/badge_spec.rb
index 33dc19e3432..f5d599c1b54 100644
--- a/spec/models/badge_spec.rb
+++ b/spec/models/badge_spec.rb
@@ -1,94 +1,94 @@
-require 'spec_helper'
+require "spec_helper"
describe Badge do
- let(:placeholder_url) { 'http://www.example.com/%{project_path}/%{project_id}/%{default_branch}/%{commit_sha}' }
+ let(:placeholder_url) { "http://www.example.com/%{project_path}/%{project_id}/%{default_branch}/%{commit_sha}" }
- describe 'validations' do
+ describe "validations" do
# Requires the let variable url_sym
- shared_examples 'placeholder url' do
+ shared_examples "placeholder url" do
let(:badge) { build(:badge) }
- it 'allows url with http protocol' do
- badge[url_sym] = 'http://www.example.com'
+ it "allows url with http protocol" do
+ badge[url_sym] = "http://www.example.com"
expect(badge).to be_valid
end
- it 'allows url with https protocol' do
- badge[url_sym] = 'https://www.example.com'
+ it "allows url with https protocol" do
+ badge[url_sym] = "https://www.example.com"
expect(badge).to be_valid
end
- it 'cannot be empty' do
- badge[url_sym] = ''
+ it "cannot be empty" do
+ badge[url_sym] = ""
expect(badge).not_to be_valid
end
- it 'cannot be nil' do
+ it "cannot be nil" do
badge[url_sym] = nil
expect(badge).not_to be_valid
end
- it 'accept badges placeholders' do
+ it "accept badges placeholders" do
badge[url_sym] = placeholder_url
expect(badge).to be_valid
end
- it 'sanitize url' do
- badge[url_sym] = 'javascript:alert(1)'
+ it "sanitize url" do
+ badge[url_sym] = "javascript:alert(1)"
expect(badge).not_to be_valid
end
end
- context 'link_url format' do
+ context "link_url format" do
let(:url_sym) { :link_url }
- it_behaves_like 'placeholder url'
+ it_behaves_like "placeholder url"
end
- context 'image_url format' do
+ context "image_url format" do
let(:url_sym) { :image_url }
- it_behaves_like 'placeholder url'
+ it_behaves_like "placeholder url"
end
end
- shared_examples 'rendered_links' do
- it 'should use the project information to populate the url placeholders' do
+ shared_examples "rendered_links" do
+ it "should use the project information to populate the url placeholders" do
stub_project_commit_info(project)
expect(badge.public_send("rendered_#{method}", project)).to eq "http://www.example.com/#{project.full_path}/#{project.id}/master/whatever"
end
- it 'returns the url if the project used is nil' do
+ it "returns the url if the project used is nil" do
expect(badge.public_send("rendered_#{method}", nil)).to eq placeholder_url
end
def stub_project_commit_info(project)
- allow(project).to receive(:commit).and_return(double('Commit', sha: 'whatever'))
- allow(project).to receive(:default_branch).and_return('master')
+ allow(project).to receive(:commit).and_return(double("Commit", sha: "whatever"))
+ allow(project).to receive(:default_branch).and_return("master")
end
end
- context 'methods' do
+ context "methods" do
let(:badge) { build(:badge, link_url: placeholder_url, image_url: placeholder_url) }
let!(:project) { create(:project) }
- context '#rendered_link_url' do
+ context "#rendered_link_url" do
let(:method) { :link_url }
- it_behaves_like 'rendered_links'
+ it_behaves_like "rendered_links"
end
- context '#rendered_image_url' do
+ context "#rendered_image_url" do
let(:method) { :image_url }
- it_behaves_like 'rendered_links'
+ it_behaves_like "rendered_links"
end
end
end
diff --git a/spec/models/badges/group_badge_spec.rb b/spec/models/badges/group_badge_spec.rb
index ed7f83d0489..cec40f0d1f6 100644
--- a/spec/models/badges/group_badge_spec.rb
+++ b/spec/models/badges/group_badge_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupBadge do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:group) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:group) }
end
end
diff --git a/spec/models/badges/project_badge_spec.rb b/spec/models/badges/project_badge_spec.rb
index 0e1a8159cb6..e3ee0593e49 100644
--- a/spec/models/badges/project_badge_spec.rb
+++ b/spec/models/badges/project_badge_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectBadge do
- let(:placeholder_url) { 'http://www.example.com/%{project_path}/%{project_id}/%{default_branch}/%{commit_sha}' }
+ let(:placeholder_url) { "http://www.example.com/%{project_path}/%{project_id}/%{default_branch}/%{commit_sha}" }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
end
- shared_examples 'rendered_links' do
- it 'should use the badge project information to populate the url placeholders' do
+ shared_examples "rendered_links" do
+ it "should use the badge project information to populate the url placeholders" do
stub_project_commit_info(project)
expect(badge.public_send("rendered_#{method}")).to eq "http://www.example.com/#{project.full_path}/#{project.id}/master/whatever"
end
def stub_project_commit_info(project)
- allow(project).to receive(:commit).and_return(double('Commit', sha: 'whatever'))
- allow(project).to receive(:default_branch).and_return('master')
+ allow(project).to receive(:commit).and_return(double("Commit", sha: "whatever"))
+ allow(project).to receive(:default_branch).and_return("master")
end
end
- context 'methods' do
+ context "methods" do
let(:badge) { build(:project_badge, link_url: placeholder_url, image_url: placeholder_url) }
let!(:project) { badge.project }
- context '#rendered_link_url' do
+ context "#rendered_link_url" do
let(:method) { :link_url }
- it_behaves_like 'rendered_links'
+ it_behaves_like "rendered_links"
end
- context '#rendered_image_url' do
+ context "#rendered_image_url" do
let(:method) { :image_url }
- it_behaves_like 'rendered_links'
+ it_behaves_like "rendered_links"
end
end
end
diff --git a/spec/models/blob_spec.rb b/spec/models/blob_spec.rb
index 05cf242e84d..c3aa1dc17cd 100644
--- a/spec/models/blob_spec.rb
+++ b/spec/models/blob_spec.rb
@@ -1,5 +1,4 @@
-# encoding: utf-8
-require 'rails_helper'
+require "rails_helper"
describe Blob do
include FakeBlobHelpers
@@ -10,32 +9,32 @@ describe Blob do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
- describe '.decorate' do
- it 'returns NilClass when given nil' do
+ describe ".decorate" do
+ it "returns NilClass when given nil" do
expect(described_class.decorate(nil)).to be_nil
end
end
- describe '.lazy' do
+ describe ".lazy" do
let(:project) { create(:project, :repository) }
let(:same_project) { Project.find(project.id) }
let(:other_project) { create(:project, :repository) }
- let(:commit_id) { 'e63f41fe459e62e1228fcef60d7189127aeba95a' }
+ let(:commit_id) { "e63f41fe459e62e1228fcef60d7189127aeba95a" }
- it 'does not fetch blobs when none are accessed' do
+ it "does not fetch blobs when none are accessed" do
expect(project.repository).not_to receive(:blobs_at)
- described_class.lazy(project, commit_id, 'CHANGELOG')
+ described_class.lazy(project, commit_id, "CHANGELOG")
end
- it 'fetches all blobs for the same repository when one is accessed' do
- expect(project.repository).to receive(:blobs_at).with([[commit_id, 'CHANGELOG'], [commit_id, 'CONTRIBUTING.md']]).once.and_call_original
+ it "fetches all blobs for the same repository when one is accessed" do
+ expect(project.repository).to receive(:blobs_at).with([[commit_id, "CHANGELOG"], [commit_id, "CONTRIBUTING.md"]]).once.and_call_original
expect(other_project.repository).not_to receive(:blobs_at)
- changelog = described_class.lazy(project, commit_id, 'CHANGELOG')
- contributing = described_class.lazy(same_project, commit_id, 'CONTRIBUTING.md')
+ changelog = described_class.lazy(project, commit_id, "CHANGELOG")
+ contributing = described_class.lazy(same_project, commit_id, "CONTRIBUTING.md")
- described_class.lazy(other_project, commit_id, 'CHANGELOG')
+ described_class.lazy(other_project, commit_id, "CHANGELOG")
# Access property so the values are loaded
changelog.id
@@ -43,9 +42,9 @@ describe Blob do
end
end
- describe '#data' do
- context 'using a binary blob' do
- it 'returns the data as-is' do
+ describe "#data" do
+ context "using a binary blob" do
+ it "returns the data as-is" do
data = "\n\xFF\xB9\xC3"
blob = fake_blob(binary: true, data: data)
@@ -53,8 +52,8 @@ describe Blob do
end
end
- context 'using a text blob' do
- it 'converts the data to UTF-8' do
+ context "using a text blob" do
+ it "converts the data to UTF-8" do
blob = fake_blob(binary: false, data: "\n\xFF\xB9\xC3")
expect(blob.data).to eq("\n���")
@@ -62,80 +61,80 @@ describe Blob do
end
end
- describe '#external_storage_error?' do
- context 'if the blob is stored in LFS' do
- let(:blob) { fake_blob(path: 'file.pdf', lfs: true) }
+ describe "#external_storage_error?" do
+ context "if the blob is stored in LFS" do
+ let(:blob) { fake_blob(path: "file.pdf", lfs: true) }
- context 'when the project has LFS enabled' do
- it 'returns false' do
+ context "when the project has LFS enabled" do
+ it "returns false" do
expect(blob.external_storage_error?).to be_falsey
end
end
- context 'when the project does not have LFS enabled' do
+ context "when the project does not have LFS enabled" do
before do
project.lfs_enabled = false
end
- it 'returns true' do
+ it "returns true" do
expect(blob.external_storage_error?).to be_truthy
end
end
end
- context 'if the blob is not stored in LFS' do
- let(:blob) { fake_blob(path: 'file.md') }
+ context "if the blob is not stored in LFS" do
+ let(:blob) { fake_blob(path: "file.md") }
- it 'returns false' do
+ it "returns false" do
expect(blob.external_storage_error?).to be_falsey
end
end
end
- describe '#stored_externally?' do
- context 'if the blob is stored in LFS' do
- let(:blob) { fake_blob(path: 'file.pdf', lfs: true) }
+ describe "#stored_externally?" do
+ context "if the blob is stored in LFS" do
+ let(:blob) { fake_blob(path: "file.pdf", lfs: true) }
- context 'when the project has LFS enabled' do
- it 'returns true' do
+ context "when the project has LFS enabled" do
+ it "returns true" do
expect(blob.stored_externally?).to be_truthy
end
end
- context 'when the project does not have LFS enabled' do
+ context "when the project does not have LFS enabled" do
before do
project.lfs_enabled = false
end
- it 'returns false' do
+ it "returns false" do
expect(blob.stored_externally?).to be_falsey
end
end
end
- context 'if the blob is not stored in LFS' do
- let(:blob) { fake_blob(path: 'file.md') }
+ context "if the blob is not stored in LFS" do
+ let(:blob) { fake_blob(path: "file.md") }
- it 'returns false' do
+ it "returns false" do
expect(blob.stored_externally?).to be_falsey
end
end
end
- describe '#binary?' do
- context 'if the blob is stored externally' do
- context 'if the extension has a rich viewer' do
- context 'if the viewer is binary' do
- it 'returns true' do
- blob = fake_blob(path: 'file.pdf', lfs: true)
+ describe "#binary?" do
+ context "if the blob is stored externally" do
+ context "if the extension has a rich viewer" do
+ context "if the viewer is binary" do
+ it "returns true" do
+ blob = fake_blob(path: "file.pdf", lfs: true)
expect(blob.binary?).to be_truthy
end
end
- context 'if the viewer is text-based' do
- it 'return false' do
- blob = fake_blob(path: 'file.md', lfs: true)
+ context "if the viewer is text-based" do
+ it "return false" do
+ blob = fake_blob(path: "file.md", lfs: true)
expect(blob.binary?).to be_falsey
end
@@ -143,54 +142,54 @@ describe Blob do
end
context "if the extension doesn't have a rich viewer" do
- context 'if the extension has a text mime type' do
- context 'if the extension is for a programming language' do
- it 'returns false' do
- blob = fake_blob(path: 'file.txt', lfs: true)
+ context "if the extension has a text mime type" do
+ context "if the extension is for a programming language" do
+ it "returns false" do
+ blob = fake_blob(path: "file.txt", lfs: true)
expect(blob.binary?).to be_falsey
end
end
- context 'if the extension is not for a programming language' do
- it 'returns false' do
- blob = fake_blob(path: 'file.ics', lfs: true)
+ context "if the extension is not for a programming language" do
+ it "returns false" do
+ blob = fake_blob(path: "file.ics", lfs: true)
expect(blob.binary?).to be_falsey
end
end
end
- context 'if the extension has a binary mime type' do
- context 'if the extension is for a programming language' do
- it 'returns false' do
- blob = fake_blob(path: 'file.rb', lfs: true)
+ context "if the extension has a binary mime type" do
+ context "if the extension is for a programming language" do
+ it "returns false" do
+ blob = fake_blob(path: "file.rb", lfs: true)
expect(blob.binary?).to be_falsey
end
end
- context 'if the extension is not for a programming language' do
- it 'returns true' do
- blob = fake_blob(path: 'file.exe', lfs: true)
+ context "if the extension is not for a programming language" do
+ it "returns true" do
+ blob = fake_blob(path: "file.exe", lfs: true)
expect(blob.binary?).to be_truthy
end
end
end
- context 'if the extension has an unknown mime type' do
- context 'if the extension is for a programming language' do
- it 'returns false' do
- blob = fake_blob(path: 'file.ini', lfs: true)
+ context "if the extension has an unknown mime type" do
+ context "if the extension is for a programming language" do
+ it "returns false" do
+ blob = fake_blob(path: "file.ini", lfs: true)
expect(blob.binary?).to be_falsey
end
end
- context 'if the extension is not for a programming language' do
- it 'returns true' do
- blob = fake_blob(path: 'file.wtf', lfs: true)
+ context "if the extension is not for a programming language" do
+ it "returns true" do
+ blob = fake_blob(path: "file.wtf", lfs: true)
expect(blob.binary?).to be_truthy
end
@@ -199,18 +198,18 @@ describe Blob do
end
end
- context 'if the blob is not stored externally' do
- context 'if the blob is binary' do
- it 'returns true' do
- blob = fake_blob(path: 'file.pdf', binary: true)
+ context "if the blob is not stored externally" do
+ context "if the blob is binary" do
+ it "returns true" do
+ blob = fake_blob(path: "file.pdf", binary: true)
expect(blob.binary?).to be_truthy
end
end
- context 'if the blob is text-based' do
- it 'return false' do
- blob = fake_blob(path: 'file.md')
+ context "if the blob is text-based" do
+ it "return false" do
+ blob = fake_blob(path: "file.md")
expect(blob.binary?).to be_falsey
end
@@ -218,41 +217,41 @@ describe Blob do
end
end
- describe '#extension' do
- it 'returns the extension' do
- blob = fake_blob(path: 'file.md')
+ describe "#extension" do
+ it "returns the extension" do
+ blob = fake_blob(path: "file.md")
- expect(blob.extension).to eq('md')
+ expect(blob.extension).to eq("md")
end
end
- describe '#file_type' do
- it 'returns the file type' do
- blob = fake_blob(path: 'README.md')
+ describe "#file_type" do
+ it "returns the file type" do
+ blob = fake_blob(path: "README.md")
expect(blob.file_type).to eq(:readme)
end
end
- describe '#simple_viewer' do
- context 'when the blob is empty' do
- it 'returns an empty viewer' do
- blob = fake_blob(data: '', size: 0)
+ describe "#simple_viewer" do
+ context "when the blob is empty" do
+ it "returns an empty viewer" do
+ blob = fake_blob(data: "", size: 0)
expect(blob.simple_viewer).to be_a(BlobViewer::Empty)
end
end
- context 'when the file represented by the blob is binary' do
- it 'returns a download viewer' do
+ context "when the file represented by the blob is binary" do
+ it "returns a download viewer" do
blob = fake_blob(binary: true)
expect(blob.simple_viewer).to be_a(BlobViewer::Download)
end
end
- context 'when the file represented by the blob is text-based' do
- it 'returns a text viewer' do
+ context "when the file represented by the blob is text-based" do
+ it "returns a text viewer" do
blob = fake_blob
expect(blob.simple_viewer).to be_a(BlobViewer::Text)
@@ -260,129 +259,129 @@ describe Blob do
end
end
- describe '#rich_viewer' do
- context 'when the blob has an external storage error' do
+ describe "#rich_viewer" do
+ context "when the blob has an external storage error" do
before do
project.lfs_enabled = false
end
- it 'returns nil' do
- blob = fake_blob(path: 'file.pdf', lfs: true)
+ it "returns nil" do
+ blob = fake_blob(path: "file.pdf", lfs: true)
expect(blob.rich_viewer).to be_nil
end
end
- context 'when the blob is empty' do
- it 'returns nil' do
- blob = fake_blob(data: '')
+ context "when the blob is empty" do
+ it "returns nil" do
+ blob = fake_blob(data: "")
expect(blob.rich_viewer).to be_nil
end
end
- context 'when the blob is stored externally' do
- it 'returns a matching viewer' do
- blob = fake_blob(path: 'file.pdf', lfs: true)
+ context "when the blob is stored externally" do
+ it "returns a matching viewer" do
+ blob = fake_blob(path: "file.pdf", lfs: true)
expect(blob.rich_viewer).to be_a(BlobViewer::PDF)
end
end
- context 'when the blob is binary' do
- it 'returns a matching binary viewer' do
- blob = fake_blob(path: 'file.pdf', binary: true)
+ context "when the blob is binary" do
+ it "returns a matching binary viewer" do
+ blob = fake_blob(path: "file.pdf", binary: true)
expect(blob.rich_viewer).to be_a(BlobViewer::PDF)
end
end
- context 'when the blob is text-based' do
- it 'returns a matching text-based viewer' do
- blob = fake_blob(path: 'file.md')
+ context "when the blob is text-based" do
+ it "returns a matching text-based viewer" do
+ blob = fake_blob(path: "file.md")
expect(blob.rich_viewer).to be_a(BlobViewer::Markup)
end
end
end
- describe '#auxiliary_viewer' do
- context 'when the blob has an external storage error' do
+ describe "#auxiliary_viewer" do
+ context "when the blob has an external storage error" do
before do
project.lfs_enabled = false
end
- it 'returns nil' do
- blob = fake_blob(path: 'LICENSE', lfs: true)
+ it "returns nil" do
+ blob = fake_blob(path: "LICENSE", lfs: true)
expect(blob.auxiliary_viewer).to be_nil
end
end
- context 'when the blob is empty' do
- it 'returns nil' do
- blob = fake_blob(data: '')
+ context "when the blob is empty" do
+ it "returns nil" do
+ blob = fake_blob(data: "")
expect(blob.auxiliary_viewer).to be_nil
end
end
- context 'when the blob is stored externally' do
- it 'returns a matching viewer' do
- blob = fake_blob(path: 'LICENSE', lfs: true)
+ context "when the blob is stored externally" do
+ it "returns a matching viewer" do
+ blob = fake_blob(path: "LICENSE", lfs: true)
expect(blob.auxiliary_viewer).to be_a(BlobViewer::License)
end
end
- context 'when the blob is binary' do
- it 'returns nil' do
- blob = fake_blob(path: 'LICENSE', binary: true)
+ context "when the blob is binary" do
+ it "returns nil" do
+ blob = fake_blob(path: "LICENSE", binary: true)
expect(blob.auxiliary_viewer).to be_nil
end
end
- context 'when the blob is text-based' do
- it 'returns a matching text-based viewer' do
- blob = fake_blob(path: 'LICENSE')
+ context "when the blob is text-based" do
+ it "returns a matching text-based viewer" do
+ blob = fake_blob(path: "LICENSE")
expect(blob.auxiliary_viewer).to be_a(BlobViewer::License)
end
end
end
- describe '#rendered_as_text?' do
- context 'when ignoring errors' do
- context 'when the simple viewer is text-based' do
- it 'returns true' do
- blob = fake_blob(path: 'file.md', size: 100.megabytes)
+ describe "#rendered_as_text?" do
+ context "when ignoring errors" do
+ context "when the simple viewer is text-based" do
+ it "returns true" do
+ blob = fake_blob(path: "file.md", size: 100.megabytes)
expect(blob.rendered_as_text?).to be_truthy
end
end
- context 'when the simple viewer is binary' do
- it 'returns false' do
- blob = fake_blob(path: 'file.pdf', binary: true, size: 100.megabytes)
+ context "when the simple viewer is binary" do
+ it "returns false" do
+ blob = fake_blob(path: "file.pdf", binary: true, size: 100.megabytes)
expect(blob.rendered_as_text?).to be_falsey
end
end
end
- context 'when not ignoring errors' do
- context 'when the viewer has render errors' do
- it 'returns false' do
- blob = fake_blob(path: 'file.md', size: 100.megabytes)
+ context "when not ignoring errors" do
+ context "when the viewer has render errors" do
+ it "returns false" do
+ blob = fake_blob(path: "file.md", size: 100.megabytes)
expect(blob.rendered_as_text?(ignore_errors: false)).to be_falsey
end
end
context "when the viewer doesn't have render errors" do
- it 'returns true' do
- blob = fake_blob(path: 'file.md')
+ it "returns true" do
+ blob = fake_blob(path: "file.md")
expect(blob.rendered_as_text?(ignore_errors: false)).to be_truthy
end
diff --git a/spec/models/blob_viewer/base_spec.rb b/spec/models/blob_viewer/base_spec.rb
index 7ba28f72215..1d2e418e2b5 100644
--- a/spec/models/blob_viewer/base_spec.rb
+++ b/spec/models/blob_viewer/base_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::Base do
include FakeBlobHelpers
@@ -9,7 +9,7 @@ describe BlobViewer::Base do
Class.new(described_class) do
include BlobViewer::ServerSide
- self.extensions = %w(pdf)
+ self.extensions = %w[pdf]
self.binary = true
self.collapse_limit = 1.megabyte
self.size_limit = 5.megabytes
@@ -18,129 +18,129 @@ describe BlobViewer::Base do
let(:viewer) { viewer_class.new(blob) }
- describe '.can_render?' do
- context 'when the extension is supported' do
- context 'when the binaryness matches' do
- let(:blob) { fake_blob(path: 'file.pdf', binary: true) }
+ describe ".can_render?" do
+ context "when the extension is supported" do
+ context "when the binaryness matches" do
+ let(:blob) { fake_blob(path: "file.pdf", binary: true) }
- it 'returns true' do
+ it "returns true" do
expect(viewer_class.can_render?(blob)).to be_truthy
end
end
- context 'when the binaryness does not match' do
- let(:blob) { fake_blob(path: 'file.pdf', binary: false) }
+ context "when the binaryness does not match" do
+ let(:blob) { fake_blob(path: "file.pdf", binary: false) }
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(blob)).to be_falsey
end
end
end
- context 'when the file type is supported' do
+ context "when the file type is supported" do
before do
- viewer_class.file_types = %i(license)
+ viewer_class.file_types = %i[license]
viewer_class.binary = false
end
- context 'when the binaryness matches' do
- let(:blob) { fake_blob(path: 'LICENSE', binary: false) }
+ context "when the binaryness matches" do
+ let(:blob) { fake_blob(path: "LICENSE", binary: false) }
- it 'returns true' do
+ it "returns true" do
expect(viewer_class.can_render?(blob)).to be_truthy
end
end
- context 'when the binaryness does not match' do
- let(:blob) { fake_blob(path: 'LICENSE', binary: true) }
+ context "when the binaryness does not match" do
+ let(:blob) { fake_blob(path: "LICENSE", binary: true) }
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(blob)).to be_falsey
end
end
end
- context 'when the extension and file type are not supported' do
- let(:blob) { fake_blob(path: 'file.txt') }
+ context "when the extension and file type are not supported" do
+ let(:blob) { fake_blob(path: "file.txt") }
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(blob)).to be_falsey
end
end
end
- describe '#collapsed?' do
- context 'when the blob size is larger than the collapse limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 2.megabytes) }
+ describe "#collapsed?" do
+ context "when the blob size is larger than the collapse limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 2.megabytes) }
- it 'returns true' do
+ it "returns true" do
expect(viewer.collapsed?).to be_truthy
end
end
- context 'when the blob size is smaller than the collapse limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 10.kilobytes) }
+ context "when the blob size is smaller than the collapse limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 10.kilobytes) }
- it 'returns false' do
+ it "returns false" do
expect(viewer.collapsed?).to be_falsey
end
end
end
- describe '#too_large?' do
- context 'when the blob size is larger than the size limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 10.megabytes) }
+ describe "#too_large?" do
+ context "when the blob size is larger than the size limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 10.megabytes) }
- it 'returns true' do
+ it "returns true" do
expect(viewer.too_large?).to be_truthy
end
end
- context 'when the blob size is smaller than the size limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 2.megabytes) }
+ context "when the blob size is smaller than the size limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 2.megabytes) }
- it 'returns false' do
+ it "returns false" do
expect(viewer.too_large?).to be_falsey
end
end
end
- describe '#render_error' do
- context 'when the blob is expanded' do
+ describe "#render_error" do
+ context "when the blob is expanded" do
before do
blob.expand!
end
- context 'when the blob size is larger than the size limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 10.megabytes) }
+ context "when the blob size is larger than the size limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 10.megabytes) }
- it 'returns :too_large' do
+ it "returns :too_large" do
expect(viewer.render_error).to eq(:too_large)
end
end
- context 'when the blob size is smaller than the size limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 2.megabytes) }
+ context "when the blob size is smaller than the size limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 2.megabytes) }
- it 'returns nil' do
+ it "returns nil" do
expect(viewer.render_error).to be_nil
end
end
end
- context 'when not expanded' do
- context 'when the blob size is larger than the collapse limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 2.megabytes) }
+ context "when not expanded" do
+ context "when the blob size is larger than the collapse limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 2.megabytes) }
- it 'returns :collapsed' do
+ it "returns :collapsed" do
expect(viewer.render_error).to eq(:collapsed)
end
end
- context 'when the blob size is smaller than the collapse limit' do
- let(:blob) { fake_blob(path: 'file.pdf', size: 10.kilobytes) }
+ context "when the blob size is smaller than the collapse limit" do
+ let(:blob) { fake_blob(path: "file.pdf", size: 10.kilobytes) }
- it 'returns nil' do
+ it "returns nil" do
expect(viewer.render_error).to be_nil
end
end
diff --git a/spec/models/blob_viewer/changelog_spec.rb b/spec/models/blob_viewer/changelog_spec.rb
index db41eca0fc8..72153189c19 100644
--- a/spec/models/blob_viewer/changelog_spec.rb
+++ b/spec/models/blob_viewer/changelog_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::Changelog do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
- let(:blob) { fake_blob(path: 'CHANGELOG') }
+ let(:blob) { fake_blob(path: "CHANGELOG") }
subject { described_class.new(blob) }
- describe '#render_error' do
- context 'when there are no tags' do
+ describe "#render_error" do
+ context "when there are no tags" do
before do
allow(project.repository).to receive(:tag_count).and_return(0)
end
- it 'returns :no_tags' do
+ it "returns :no_tags" do
expect(subject.render_error).to eq(:no_tags)
end
end
- context 'when there are tags' do
- it 'returns nil' do
+ context "when there are tags" do
+ it "returns nil" do
expect(subject.render_error).to be_nil
end
end
diff --git a/spec/models/blob_viewer/composer_json_spec.rb b/spec/models/blob_viewer/composer_json_spec.rb
index 85b0d9668a0..2fad5d3203c 100644
--- a/spec/models/blob_viewer/composer_json_spec.rb
+++ b/spec/models/blob_viewer/composer_json_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::ComposerJson do
include FakeBlobHelpers
@@ -12,14 +12,14 @@ describe BlobViewer::ComposerJson do
}
SPEC
end
- let(:blob) { fake_blob(path: 'composer.json', data: data) }
+ let(:blob) { fake_blob(path: "composer.json", data: data) }
subject { described_class.new(blob) }
- describe '#package_name' do
- it 'returns the package name' do
+ describe "#package_name" do
+ it "returns the package name" do
expect(subject).to receive(:prepare!)
- expect(subject.package_name).to eq('laravel/laravel')
+ expect(subject.package_name).to eq("laravel/laravel")
end
end
end
diff --git a/spec/models/blob_viewer/gemspec_spec.rb b/spec/models/blob_viewer/gemspec_spec.rb
index d8c4490637f..0de3b02eaed 100644
--- a/spec/models/blob_viewer/gemspec_spec.rb
+++ b/spec/models/blob_viewer/gemspec_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::Gemspec do
include FakeBlobHelpers
@@ -12,14 +12,14 @@ describe BlobViewer::Gemspec do
end
SPEC
end
- let(:blob) { fake_blob(path: 'activerecord.gemspec', data: data) }
+ let(:blob) { fake_blob(path: "activerecord.gemspec", data: data) }
subject { described_class.new(blob) }
- describe '#package_name' do
- it 'returns the package name' do
+ describe "#package_name" do
+ it "returns the package name" do
expect(subject).to receive(:prepare!)
- expect(subject.package_name).to eq('activerecord')
+ expect(subject.package_name).to eq("activerecord")
end
end
end
diff --git a/spec/models/blob_viewer/gitlab_ci_yml_spec.rb b/spec/models/blob_viewer/gitlab_ci_yml_spec.rb
index 16bf947b493..6633c761fe7 100644
--- a/spec/models/blob_viewer/gitlab_ci_yml_spec.rb
+++ b/spec/models/blob_viewer/gitlab_ci_yml_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::GitlabCiYml do
include FakeBlobHelpers
@@ -7,29 +7,29 @@ describe BlobViewer::GitlabCiYml do
set(:project) { create(:project, :repository) }
set(:user) { create(:user) }
- let(:data) { File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) }
- let(:blob) { fake_blob(path: '.gitlab-ci.yml', data: data) }
+ let(:data) { File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml")) }
+ let(:blob) { fake_blob(path: ".gitlab-ci.yml", data: data) }
let(:sha) { sample_commit.id }
subject { described_class.new(blob) }
- describe '#validation_message' do
- it 'calls prepare! on the viewer' do
+ describe "#validation_message" do
+ it "calls prepare! on the viewer" do
expect(subject).to receive(:prepare!)
subject.validation_message(project: project, sha: sha, user: user)
end
- context 'when the configuration is valid' do
- it 'returns nil' do
+ context "when the configuration is valid" do
+ it "returns nil" do
expect(subject.validation_message(project: project, sha: sha, user: user)).to be_nil
end
end
- context 'when the configuration is invalid' do
- let(:data) { 'oof' }
+ context "when the configuration is invalid" do
+ let(:data) { "oof" }
- it 'returns the error message' do
- expect(subject.validation_message(project: project, sha: sha, user: user)).to eq('Invalid configuration format')
+ it "returns the error message" do
+ expect(subject.validation_message(project: project, sha: sha, user: user)).to eq("Invalid configuration format")
end
end
end
diff --git a/spec/models/blob_viewer/license_spec.rb b/spec/models/blob_viewer/license_spec.rb
index 222ed166ee0..5c315190592 100644
--- a/spec/models/blob_viewer/license_spec.rb
+++ b/spec/models/blob_viewer/license_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::License do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
- let(:blob) { fake_blob(path: 'LICENSE') }
+ let(:blob) { fake_blob(path: "LICENSE") }
subject { described_class.new(blob) }
- describe '#license' do
- it 'returns the blob project repository license' do
+ describe "#license" do
+ it "returns the blob project repository license" do
expect(subject.license).not_to be_nil
expect(subject.license).to eq(project.repository.license)
end
end
- describe '#render_error' do
- context 'when there is no license' do
+ describe "#render_error" do
+ context "when there is no license" do
before do
allow(project.repository).to receive(:license).and_return(nil)
end
- it 'returns :unknown_license' do
+ it "returns :unknown_license" do
expect(subject.render_error).to eq(:unknown_license)
end
end
- context 'when there is a license' do
- it 'returns nil' do
+ context "when there is a license" do
+ it "returns nil" do
expect(subject.render_error).to be_nil
end
end
diff --git a/spec/models/blob_viewer/package_json_spec.rb b/spec/models/blob_viewer/package_json_spec.rb
index fbaa8d47a71..d2b41f59c2f 100644
--- a/spec/models/blob_viewer/package_json_spec.rb
+++ b/spec/models/blob_viewer/package_json_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::PackageJson do
include FakeBlobHelpers
@@ -12,35 +12,35 @@ describe BlobViewer::PackageJson do
}
SPEC
end
- let(:blob) { fake_blob(path: 'package.json', data: data) }
+ let(:blob) { fake_blob(path: "package.json", data: data) }
subject { described_class.new(blob) }
- describe '#package_name' do
- it 'returns the package name' do
+ describe "#package_name" do
+ it "returns the package name" do
expect(subject).to receive(:prepare!)
- expect(subject.package_name).to eq('module-name')
+ expect(subject.package_name).to eq("module-name")
end
end
- describe '#package_url' do
- it 'returns the package URL' do
+ describe "#package_url" do
+ it "returns the package URL" do
expect(subject).to receive(:prepare!)
expect(subject.package_url).to eq("https://www.npmjs.com/package/#{subject.package_name}")
end
end
- describe '#package_type' do
+ describe "#package_type" do
it 'returns "package"' do
expect(subject).to receive(:prepare!)
- expect(subject.package_type).to eq('package')
+ expect(subject.package_type).to eq("package")
end
end
context 'when package.json has "private": true' do
- let(:homepage) { 'http://example.com' }
+ let(:homepage) { "http://example.com" }
let(:data) do
<<-SPEC.strip_heredoc
{
@@ -51,22 +51,22 @@ describe BlobViewer::PackageJson do
}
SPEC
end
- let(:blob) { fake_blob(path: 'package.json', data: data) }
+ let(:blob) { fake_blob(path: "package.json", data: data) }
subject { described_class.new(blob) }
- describe '#package_url' do
- context 'when the homepage has a valid URL' do
- it 'returns homepage URL' do
+ describe "#package_url" do
+ context "when the homepage has a valid URL" do
+ it "returns homepage URL" do
expect(subject).to receive(:prepare!)
expect(subject.package_url).to eq(homepage)
end
end
- context 'when the homepage has an invalid URL' do
- let(:homepage) { 'javascript:alert()' }
+ context "when the homepage has an invalid URL" do
+ let(:homepage) { "javascript:alert()" }
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to receive(:prepare!)
expect(subject.package_url).to be_nil
@@ -74,11 +74,11 @@ describe BlobViewer::PackageJson do
end
end
- describe '#package_type' do
+ describe "#package_type" do
it 'returns "private package"' do
expect(subject).to receive(:prepare!)
- expect(subject.package_type).to eq('private package')
+ expect(subject.package_type).to eq("private package")
end
end
end
diff --git a/spec/models/blob_viewer/podspec_json_spec.rb b/spec/models/blob_viewer/podspec_json_spec.rb
index 9a23877b23f..83d473970a1 100644
--- a/spec/models/blob_viewer/podspec_json_spec.rb
+++ b/spec/models/blob_viewer/podspec_json_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::PodspecJson do
include FakeBlobHelpers
@@ -12,14 +12,14 @@ describe BlobViewer::PodspecJson do
}
SPEC
end
- let(:blob) { fake_blob(path: 'AFNetworking.podspec.json', data: data) }
+ let(:blob) { fake_blob(path: "AFNetworking.podspec.json", data: data) }
subject { described_class.new(blob) }
- describe '#package_name' do
- it 'returns the package name' do
+ describe "#package_name" do
+ it "returns the package name" do
expect(subject).to receive(:prepare!)
- expect(subject.package_name).to eq('AFNetworking')
+ expect(subject.package_name).to eq("AFNetworking")
end
end
end
diff --git a/spec/models/blob_viewer/podspec_spec.rb b/spec/models/blob_viewer/podspec_spec.rb
index 02d06ea24d6..adea718355d 100644
--- a/spec/models/blob_viewer/podspec_spec.rb
+++ b/spec/models/blob_viewer/podspec_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::Podspec do
include FakeBlobHelpers
@@ -12,14 +12,14 @@ describe BlobViewer::Podspec do
end
SPEC
end
- let(:blob) { fake_blob(path: 'Reachability.podspec', data: data) }
+ let(:blob) { fake_blob(path: "Reachability.podspec", data: data) }
subject { described_class.new(blob) }
- describe '#package_name' do
- it 'returns the package name' do
+ describe "#package_name" do
+ it "returns the package name" do
expect(subject).to receive(:prepare!)
- expect(subject.package_name).to eq('Reachability')
+ expect(subject.package_name).to eq("Reachability")
end
end
end
diff --git a/spec/models/blob_viewer/readme_spec.rb b/spec/models/blob_viewer/readme_spec.rb
index 8d11d58cfca..acfb9269897 100644
--- a/spec/models/blob_viewer/readme_spec.rb
+++ b/spec/models/blob_viewer/readme_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::Readme do
include FakeBlobHelpers
let(:project) { create(:project, :repository, :wiki_repo) }
- let(:blob) { fake_blob(path: 'README.md') }
+ let(:blob) { fake_blob(path: "README.md") }
subject { described_class.new(blob) }
- describe '#render_error' do
- context 'when there is no wiki' do
- it 'returns :no_wiki' do
+ describe "#render_error" do
+ context "when there is no wiki" do
+ it "returns :no_wiki" do
expect(subject.render_error).to eq(:no_wiki)
end
end
- context 'when there is an external wiki' do
+ context "when there is an external wiki" do
before do
project.has_external_wiki = true
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.render_error).to be_nil
end
end
- context 'when there is a local wiki' do
+ context "when there is a local wiki" do
before do
project.wiki_enabled = true
end
- context 'when the wiki is empty' do
- it 'returns :no_wiki' do
+ context "when the wiki is empty" do
+ it "returns :no_wiki" do
expect(subject.render_error).to eq(:no_wiki)
end
end
- context 'when the wiki is not empty' do
+ context "when the wiki is not empty" do
before do
- create(:wiki_page, wiki: project.wiki, attrs: { title: 'home', content: 'Home page' })
+ create(:wiki_page, wiki: project.wiki, attrs: {title: "home", content: "Home page"})
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.render_error).to be_nil
end
end
diff --git a/spec/models/blob_viewer/route_map_spec.rb b/spec/models/blob_viewer/route_map_spec.rb
index c13662427b0..ce71954a5cb 100644
--- a/spec/models/blob_viewer/route_map_spec.rb
+++ b/spec/models/blob_viewer/route_map_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::RouteMap do
include FakeBlobHelpers
@@ -11,27 +11,27 @@ describe BlobViewer::RouteMap do
public: 'team/'
MAP
end
- let(:blob) { fake_blob(path: '.gitlab/route-map.yml', data: data) }
+ let(:blob) { fake_blob(path: ".gitlab/route-map.yml", data: data) }
subject { described_class.new(blob) }
- describe '#validation_message' do
- it 'calls prepare! on the viewer' do
+ describe "#validation_message" do
+ it "calls prepare! on the viewer" do
expect(subject).to receive(:prepare!)
subject.validation_message
end
- context 'when the configuration is valid' do
- it 'returns nil' do
+ context "when the configuration is valid" do
+ it "returns nil" do
expect(subject.validation_message).to be_nil
end
end
- context 'when the configuration is invalid' do
- let(:data) { 'oof' }
+ context "when the configuration is invalid" do
+ let(:data) { "oof" }
- it 'returns the error message' do
- expect(subject.validation_message).to eq('Route map is not an array')
+ it "returns the error message" do
+ expect(subject.validation_message).to eq("Route map is not an array")
end
end
end
diff --git a/spec/models/blob_viewer/server_side_spec.rb b/spec/models/blob_viewer/server_side_spec.rb
index 63790486200..ef79bc618e5 100644
--- a/spec/models/blob_viewer/server_side_spec.rb
+++ b/spec/models/blob_viewer/server_side_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobViewer::ServerSide do
include FakeBlobHelpers
@@ -13,27 +13,27 @@ describe BlobViewer::ServerSide do
subject { viewer_class.new(blob) }
- describe '#prepare!' do
- let(:blob) { fake_blob(path: 'file.txt') }
+ describe "#prepare!" do
+ let(:blob) { fake_blob(path: "file.txt") }
- it 'loads all blob data' do
+ it "loads all blob data" do
expect(blob).to receive(:load_all_data!)
subject.prepare!
end
end
- describe '#render_error' do
- context 'when the blob is stored externally' do
+ describe "#render_error" do
+ context "when the blob is stored externally" do
let(:project) { build(:project, lfs_enabled: true) }
- let(:blob) { fake_blob(path: 'file.pdf', lfs: true) }
+ let(:blob) { fake_blob(path: "file.pdf", lfs: true) }
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
- it 'return :server_side_but_stored_externally' do
+ it "return :server_side_but_stored_externally" do
expect(subject.render_error).to eq(:server_side_but_stored_externally)
end
end
diff --git a/spec/models/board_group_recent_visit_spec.rb b/spec/models/board_group_recent_visit_spec.rb
index 59ad4e5417e..ad4c8e6078b 100644
--- a/spec/models/board_group_recent_visit_spec.rb
+++ b/spec/models/board_group_recent_visit_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BoardGroupRecentVisit do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:board) { create(:board, group: group) }
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:board) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:group) }
it { is_expected.to validate_presence_of(:board) }
end
- describe '#visited' do
- it 'creates a visit if one does not exists' do
+ describe "#visited" do
+ it "creates a visit if one does not exists" do
expect { described_class.visited!(user, board) }.to change(described_class, :count).by(1)
end
- shared_examples 'was visited previously' do
+ shared_examples "was visited previously" do
let!(:visit) { create :board_group_recent_visit, group: board.group, board: board, user: user, updated_at: 7.days.ago }
- it 'updates the timestamp' do
+ it "updates the timestamp" do
Timecop.freeze do
described_class.visited!(user, board)
@@ -37,20 +37,20 @@ describe BoardGroupRecentVisit do
end
end
- it_behaves_like 'was visited previously'
+ it_behaves_like "was visited previously"
- context 'when we try to create a visit that is not unique' do
+ context "when we try to create a visit that is not unique" do
before do
- expect(described_class).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique, 'record not unique')
+ expect(described_class).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique, "record not unique")
expect(described_class).to receive(:find_or_create_by).and_return(visit)
end
- it_behaves_like 'was visited previously'
+ it_behaves_like "was visited previously"
end
end
- describe '#latest' do
- it 'returns the most recent visited' do
+ describe "#latest" do
+ it "returns the most recent visited" do
board2 = create(:board, group: group)
board3 = create(:board, group: group)
diff --git a/spec/models/board_project_recent_visit_spec.rb b/spec/models/board_project_recent_visit_spec.rb
index 275581945fa..1d66fbce52e 100644
--- a/spec/models/board_project_recent_visit_spec.rb
+++ b/spec/models/board_project_recent_visit_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BoardProjectRecentVisit do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:board) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:board) }
end
- describe '#visited' do
- it 'creates a visit if one does not exists' do
+ describe "#visited" do
+ it "creates a visit if one does not exists" do
expect { described_class.visited!(user, board) }.to change(described_class, :count).by(1)
end
- shared_examples 'was visited previously' do
+ shared_examples "was visited previously" do
let!(:visit) { create :board_project_recent_visit, project: board.project, board: board, user: user, updated_at: 7.days.ago }
- it 'updates the timestamp' do
+ it "updates the timestamp" do
Timecop.freeze do
described_class.visited!(user, board)
@@ -37,20 +37,20 @@ describe BoardProjectRecentVisit do
end
end
- it_behaves_like 'was visited previously'
+ it_behaves_like "was visited previously"
- context 'when we try to create a visit that is not unique' do
+ context "when we try to create a visit that is not unique" do
before do
- expect(described_class).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique, 'record not unique')
+ expect(described_class).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique, "record not unique")
expect(described_class).to receive(:find_or_create_by).and_return(visit)
end
- it_behaves_like 'was visited previously'
+ it_behaves_like "was visited previously"
end
end
- describe '#latest' do
- it 'returns the most recent visited' do
+ describe "#latest" do
+ it "returns the most recent visited" do
board2 = create(:board, project: project)
board3 = create(:board, project: project)
diff --git a/spec/models/board_spec.rb b/spec/models/board_spec.rb
index 12d29540137..ad03462702c 100644
--- a/spec/models/board_spec.rb
+++ b/spec/models/board_spec.rb
@@ -1,12 +1,12 @@
-require 'rails_helper'
+require "rails_helper"
describe Board do
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:lists).order(list_type: :asc, position: :asc).dependent(:delete_all) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
end
end
diff --git a/spec/models/broadcast_message_spec.rb b/spec/models/broadcast_message_spec.rb
index 89839709131..df576d0339d 100644
--- a/spec/models/broadcast_message_spec.rb
+++ b/spec/models/broadcast_message_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe BroadcastMessage do
subject { build(:broadcast_message) }
it { is_expected.to be_valid }
- describe 'validations' do
- let(:triplet) { '#000' }
- let(:hex) { '#AABBCC' }
+ describe "validations" do
+ let(:triplet) { "#000" }
+ let(:hex) { "#AABBCC" }
it { is_expected.to allow_value(nil).for(:color) }
it { is_expected.to allow_value(triplet).for(:color) }
it { is_expected.to allow_value(hex).for(:color) }
- it { is_expected.not_to allow_value('000').for(:color) }
+ it { is_expected.not_to allow_value("000").for(:color) }
it { is_expected.to allow_value(nil).for(:font) }
it { is_expected.to allow_value(triplet).for(:font) }
it { is_expected.to allow_value(hex).for(:font) }
- it { is_expected.not_to allow_value('000').for(:font) }
+ it { is_expected.not_to allow_value("000").for(:font) }
end
- describe '.current', :use_clean_rails_memory_store_caching do
- it 'returns message if time match' do
+ describe ".current", :use_clean_rails_memory_store_caching do
+ it "returns message if time match" do
message = create(:broadcast_message)
expect(described_class.current).to include(message)
end
- it 'returns multiple messages if time match' do
+ it "returns multiple messages if time match" do
message1 = create(:broadcast_message)
message2 = create(:broadcast_message)
expect(described_class.current).to contain_exactly(message1, message2)
end
- it 'returns empty list if time not come' do
+ it "returns empty list if time not come" do
create(:broadcast_message, :future)
expect(described_class.current).to be_empty
end
- it 'returns empty list if time has passed' do
+ it "returns empty list if time has passed" do
create(:broadcast_message, :expired)
expect(described_class.current).to be_empty
end
- it 'caches the output of the query' do
+ it "caches the output of the query" do
create(:broadcast_message)
expect(described_class).to receive(:current_and_future_messages).and_call_original.once
@@ -58,13 +58,13 @@ describe BroadcastMessage do
end
end
- it 'does not create new records' do
+ it "does not create new records" do
create(:broadcast_message)
expect { described_class.current }.not_to change { described_class.count }
end
- it 'includes messages that need to be displayed in the future' do
+ it "includes messages that need to be displayed in the future" do
create(:broadcast_message)
future = create(
@@ -80,14 +80,14 @@ describe BroadcastMessage do
end
end
- it 'does not clear the cache if only a future message should be displayed' do
+ it "does not clear the cache if only a future message should be displayed" do
create(:broadcast_message, :future)
expect(Rails.cache).not_to receive(:delete).with(described_class::CACHE_KEY)
expect(described_class.current.length).to eq(0)
end
- it 'clears the legacy cache key' do
+ it "clears the legacy cache key" do
create(:broadcast_message, :future)
expect(Rails.cache).to receive(:delete).with(described_class::LEGACY_CACHE_KEY)
@@ -95,28 +95,28 @@ describe BroadcastMessage do
end
end
- describe '#active?' do
- it 'is truthy when started and not ended' do
+ describe "#active?" do
+ it "is truthy when started and not ended" do
message = build(:broadcast_message)
expect(message).to be_active
end
- it 'is falsey when ended' do
+ it "is falsey when ended" do
message = build(:broadcast_message, :expired)
expect(message).not_to be_active
end
- it 'is falsey when not started' do
+ it "is falsey when not started" do
message = build(:broadcast_message, :future)
expect(message).not_to be_active
end
end
- describe '#started?' do
- it 'is truthy when starts_at has passed' do
+ describe "#started?" do
+ it "is truthy when starts_at has passed" do
message = build(:broadcast_message)
travel_to(3.days.from_now) do
@@ -124,7 +124,7 @@ describe BroadcastMessage do
end
end
- it 'is falsey when starts_at is in the future' do
+ it "is falsey when starts_at is in the future" do
message = build(:broadcast_message)
travel_to(3.days.ago) do
@@ -133,8 +133,8 @@ describe BroadcastMessage do
end
end
- describe '#ended?' do
- it 'is truthy when ends_at has passed' do
+ describe "#ended?" do
+ it "is truthy when ends_at has passed" do
message = build(:broadcast_message)
travel_to(3.days.from_now) do
@@ -142,7 +142,7 @@ describe BroadcastMessage do
end
end
- it 'is falsey when ends_at is in the future' do
+ it "is falsey when ends_at is in the future" do
message = build(:broadcast_message)
travel_to(3.days.ago) do
@@ -151,8 +151,8 @@ describe BroadcastMessage do
end
end
- describe '#flush_redis_cache' do
- it 'flushes the Redis cache' do
+ describe "#flush_redis_cache" do
+ it "flushes the Redis cache" do
message = create(:broadcast_message)
expect(Rails.cache).to receive(:delete).with(described_class::CACHE_KEY)
diff --git a/spec/models/chat_name_spec.rb b/spec/models/chat_name_spec.rb
index 504bc710b25..c65095a825c 100644
--- a/spec/models/chat_name_spec.rb
+++ b/spec/models/chat_name_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatName do
set(:chat_name) { create(:chat_name) }
@@ -15,8 +15,8 @@ describe ChatName do
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to(:service_id) }
it { is_expected.to validate_uniqueness_of(:chat_id).scoped_to(:service_id, :team_id) }
- describe '#update_last_used_at', :clean_gitlab_redis_shared_state do
- it 'updates the last_used_at timestamp' do
+ describe "#update_last_used_at", :clean_gitlab_redis_shared_state do
+ it "updates the last_used_at timestamp" do
expect(subject.last_used_at).to be_nil
subject.update_last_used_at
@@ -24,7 +24,7 @@ describe ChatName do
expect(subject.last_used_at).to be_present
end
- it 'does not update last_used_at if it was recently updated' do
+ it "does not update last_used_at if it was recently updated" do
subject.update_last_used_at
time = subject.last_used_at
diff --git a/spec/models/chat_team_spec.rb b/spec/models/chat_team_spec.rb
index 70a9a206faa..c1f952dafcd 100644
--- a/spec/models/chat_team_spec.rb
+++ b/spec/models/chat_team_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatTeam do
set(:chat_team) { create(:chat_team) }
diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb
index 0014bbcf9f5..a4edab3c0c1 100644
--- a/spec/models/ci/artifact_blob_spec.rb
+++ b/spec/models/ci/artifact_blob_spec.rb
@@ -1,75 +1,75 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::ArtifactBlob do
set(:project) { create(:project, :public) }
set(:build) { create(:ci_build, :artifacts, project: project) }
- let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/another-subdirectory/banana_sample.gif') }
+ let(:entry) { build.artifacts_metadata_entry("other_artifacts_0.1.2/another-subdirectory/banana_sample.gif") }
subject { described_class.new(entry) }
- describe '#id' do
- it 'returns a hash of the path' do
+ describe "#id" do
+ it "returns a hash of the path" do
expect(subject.id).to eq(Digest::SHA1.hexdigest(entry.path))
end
end
- describe '#name' do
- it 'returns the entry name' do
+ describe "#name" do
+ it "returns the entry name" do
expect(subject.name).to eq(entry.name)
end
end
- describe '#path' do
- it 'returns the entry path' do
+ describe "#path" do
+ it "returns the entry path" do
expect(subject.path).to eq(entry.path)
end
end
- describe '#size' do
- it 'returns the entry size' do
+ describe "#size" do
+ it "returns the entry size" do
expect(subject.size).to eq(entry.metadata[:size])
end
end
- describe '#mode' do
- it 'returns the entry mode' do
+ describe "#mode" do
+ it "returns the entry mode" do
expect(subject.mode).to eq(entry.metadata[:mode])
end
end
- describe '#external_storage' do
- it 'returns :build_artifact' do
+ describe "#external_storage" do
+ it "returns :build_artifact" do
expect(subject.external_storage).to eq(:build_artifact)
end
end
- describe '#external_url' do
+ describe "#external_url" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
- context '.gif extension' do
- it 'returns nil' do
+ context ".gif extension" do
+ it "returns nil" do
expect(subject.external_url(build.project, build)).to be_nil
end
end
- context 'txt extensions' do
- let(:path) { 'other_artifacts_0.1.2/doc_sample.txt' }
+ context "txt extensions" do
+ let(:path) { "other_artifacts_0.1.2/doc_sample.txt" }
let(:entry) { build.artifacts_metadata_entry(path) }
- it 'returns a URL' do
+ it "returns a URL" do
url = subject.external_url(build.project, build)
expect(url).not_to be_nil
expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}")
end
- context 'when port is configured' do
+ context "when port is configured" do
let(:port) { 1234 }
- it 'returns an URL with port number' do
+ it "returns an URL with port number" do
allow(Gitlab.config.pages).to receive(:url).and_return("#{Gitlab.config.pages.url}:#{port}")
url = subject.external_url(build.project, build)
@@ -81,22 +81,22 @@ describe Ci::ArtifactBlob do
end
end
- describe '#external_link?' do
+ describe "#external_link?" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
allow(Gitlab.config.pages).to receive(:artifacts_server).and_return(true)
end
- context 'gif extensions' do
- it 'returns false' do
+ context "gif extensions" do
+ it "returns false" do
expect(subject.external_link?(build)).to be false
end
end
- context 'txt extensions' do
- let(:entry) { build.artifacts_metadata_entry('other_artifacts_0.1.2/doc_sample.txt') }
+ context "txt extensions" do
+ let(:entry) { build.artifacts_metadata_entry("other_artifacts_0.1.2/doc_sample.txt") }
- it 'returns true' do
+ it "returns true" do
expect(subject.external_link?(build)).to be true
end
end
diff --git a/spec/models/ci/bridge_spec.rb b/spec/models/ci/bridge_spec.rb
index 741cdfef1a5..bfccfb462ce 100644
--- a/spec/models/ci/bridge_spec.rb
+++ b/spec/models/ci/bridge_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Bridge do
set(:project) { create(:project) }
@@ -8,17 +8,17 @@ describe Ci::Bridge do
create(:ci_bridge, pipeline: pipeline)
end
- describe '#tags' do
- it 'only has a bridge tag' do
+ describe "#tags" do
+ it "only has a bridge tag" do
expect(bridge.tags).to eq [:bridge]
end
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
let(:user) { create(:user) }
let(:status) { bridge.detailed_status(user) }
- it 'returns detailed status object' do
+ it "returns detailed status object" do
expect(status).to be_a Gitlab::Ci::Status::Success
end
end
diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb
index 016a5899eef..c2e6a910864 100644
--- a/spec/models/ci/build_metadata_spec.rb
+++ b/spec/models/ci/build_metadata_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildMetadata do
set(:user) { create(:user) }
@@ -9,18 +9,18 @@ describe Ci::BuildMetadata do
create(:ci_pipeline, project: project,
sha: project.commit.id,
ref: project.default_branch,
- status: 'success')
+ status: "success")
end
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:metadata) { build.metadata }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe '#update_timeout_state' do
+ describe "#update_timeout_state" do
subject { metadata }
- context 'when runner is not assigned to the job' do
+ context "when runner is not assigned to the job" do
it "doesn't change timeout value" do
expect { subject.update_timeout_state }.not_to change { subject.reload.timeout }
end
@@ -30,32 +30,32 @@ describe Ci::BuildMetadata do
end
end
- context 'when runner is assigned to the job' do
+ context "when runner is assigned to the job" do
before do
build.update(runner: runner)
end
- context 'when runner timeout is lower than project timeout' do
+ context "when runner timeout is lower than project timeout" do
let(:runner) { create(:ci_runner, maximum_timeout: 1900) }
- it 'sets runner timeout' do
+ it "sets runner timeout" do
expect { subject.update_timeout_state }.to change { subject.reload.timeout }.to(1900)
end
- it 'sets runner_timeout_source' do
- expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to('runner_timeout_source')
+ it "sets runner_timeout_source" do
+ expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to("runner_timeout_source")
end
end
- context 'when runner timeout is higher than project timeout' do
+ context "when runner timeout is higher than project timeout" do
let(:runner) { create(:ci_runner, maximum_timeout: 2100) }
- it 'sets project timeout' do
+ it "sets project timeout" do
expect { subject.update_timeout_state }.to change { subject.reload.timeout }.to(2000)
end
- it 'sets project_timeout_source' do
- expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to('project_timeout_source')
+ it "sets project_timeout_source" do
+ expect { subject.update_timeout_state }.to change { subject.reload.timeout_source }.to("project_timeout_source")
end
end
end
diff --git a/spec/models/ci/build_runner_session_spec.rb b/spec/models/ci/build_runner_session_spec.rb
index 35622366829..f218ea55bd8 100644
--- a/spec/models/ci/build_runner_session_spec.rb
+++ b/spec/models/ci/build_runner_session_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildRunnerSession, model: true do
let!(:build) { create(:ci_build, :with_runner_session) }
@@ -8,28 +8,28 @@ describe Ci::BuildRunnerSession, model: true do
it { is_expected.to belong_to(:build) }
it { is_expected.to validate_presence_of(:build) }
- it { is_expected.to validate_presence_of(:url).with_message('must be a valid URL') }
+ it { is_expected.to validate_presence_of(:url).with_message("must be a valid URL") }
- describe '#terminal_specification' do
+ describe "#terminal_specification" do
let(:terminal_specification) { subject.terminal_specification }
- it 'returns empty hash if no url' do
- subject.url = ''
+ it "returns empty hash if no url" do
+ subject.url = ""
expect(terminal_specification).to be_empty
end
- context 'when url is present' do
- it 'returns ca_pem nil if empty certificate' do
- subject.certificate = ''
+ context "when url is present" do
+ it "returns ca_pem nil if empty certificate" do
+ subject.certificate = ""
expect(terminal_specification[:ca_pem]).to be_nil
end
- it 'adds Authorization header if authorization is present' do
- subject.authorization = 'whatever'
+ it "adds Authorization header if authorization is present" do
+ subject.authorization = "whatever"
- expect(terminal_specification[:headers]).to include(Authorization: ['whatever'])
+ expect(terminal_specification[:headers]).to include(Authorization: ["whatever"])
end
end
end
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 81ff727b458..7e2ea60d093 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Build do
set(:user) { create(:user) }
@@ -9,7 +9,7 @@ describe Ci::Build do
create(:ci_pipeline, project: project,
sha: project.commit.id,
ref: project.default_branch,
- status: 'success')
+ status: "success")
end
let(:build) { create(:ci_build, pipeline: pipeline) }
@@ -27,16 +27,16 @@ describe Ci::Build do
it { is_expected.to be_a(ArtifactMigratable) }
- describe 'associations' do
- it 'has a bidirectional relationship with projects' do
+ describe "associations" do
+ it "has a bidirectional relationship with projects" do
expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:builds)
expect(Project.reflect_on_association(:builds).has_inverse?).to eq(:project)
end
end
- describe 'callbacks' do
- context 'when running after_create callback' do
- it 'triggers asynchronous build hooks worker' do
+ describe "callbacks" do
+ context "when running after_create callback" do
+ it "triggers asynchronous build hooks worker" do
expect(BuildHooksWorker).to receive(:perform_async)
create(:ci_build)
@@ -44,10 +44,10 @@ describe Ci::Build do
end
end
- describe 'status' do
- context 'when transitioning to any state from running' do
- it 'removes runner_session' do
- %w(success drop cancel).each do |event|
+ describe "status" do
+ context "when transitioning to any state from running" do
+ it "removes runner_session" do
+ %w[success drop cancel].each do |event|
build = FactoryBot.create(:ci_build, :running, :with_runner_session, pipeline: pipeline)
build.fire_events!(event)
@@ -58,7 +58,7 @@ describe Ci::Build do
end
end
- describe '.manual_actions' do
+ describe ".manual_actions" do
let!(:manual_but_created) { create(:ci_build, :manual, status: :created, pipeline: pipeline) }
let!(:manual_but_succeeded) { create(:ci_build, :manual, status: :success, pipeline: pipeline) }
let!(:manual_action) { create(:ci_build, :manual, pipeline: pipeline) }
@@ -70,22 +70,22 @@ describe Ci::Build do
it { is_expected.not_to include(manual_but_created) }
end
- describe '.ref_protected' do
+ describe ".ref_protected" do
subject { described_class.ref_protected }
- context 'when protected is true' do
+ context "when protected is true" do
let!(:job) { create(:ci_build, :protected) }
it { is_expected.to include(job) }
end
- context 'when protected is false' do
+ context "when protected is false" do
let!(:job) { create(:ci_build) }
it { is_expected.not_to include(job) }
end
- context 'when protected is nil' do
+ context "when protected is nil" do
let!(:job) { create(:ci_build) }
before do
@@ -96,137 +96,137 @@ describe Ci::Build do
end
end
- describe '.with_artifacts_archive' do
+ describe ".with_artifacts_archive" do
subject { described_class.with_artifacts_archive }
- context 'when job does not have an archive' do
+ context "when job does not have an archive" do
let!(:job) { create(:ci_build) }
- it 'does not return the job' do
+ it "does not return the job" do
is_expected.not_to include(job)
end
end
- context 'when job has a legacy archive' do
+ context "when job has a legacy archive" do
let!(:job) { create(:ci_build, :legacy_artifacts) }
- it 'returns the job' do
+ it "returns the job" do
is_expected.to include(job)
end
end
- context 'when job has a job artifact archive' do
+ context "when job has a job artifact archive" do
let!(:job) { create(:ci_build, :artifacts) }
- it 'returns the job' do
+ it "returns the job" do
is_expected.to include(job)
end
end
- context 'when job has a job artifact trace' do
+ context "when job has a job artifact trace" do
let!(:job) { create(:ci_build, :trace_artifact) }
- it 'does not return the job' do
+ it "does not return the job" do
is_expected.not_to include(job)
end
end
end
- describe '.with_live_trace' do
+ describe ".with_live_trace" do
subject { described_class.with_live_trace }
- context 'when build has live trace' do
+ context "when build has live trace" do
let!(:build) { create(:ci_build, :success, :trace_live) }
- it 'selects the build' do
+ it "selects the build" do
is_expected.to eq([build])
end
end
- context 'when build does not have live trace' do
+ context "when build does not have live trace" do
let!(:build) { create(:ci_build, :success, :trace_artifact) }
- it 'does not select the build' do
+ it "does not select the build" do
is_expected.to be_empty
end
end
end
- describe '.with_test_reports' do
+ describe ".with_test_reports" do
subject { described_class.with_test_reports }
- context 'when build has a test report' do
+ context "when build has a test report" do
let!(:build) { create(:ci_build, :success, :test_reports) }
- it 'selects the build' do
+ it "selects the build" do
is_expected.to eq([build])
end
end
- context 'when build does not have test reports' do
+ context "when build does not have test reports" do
let!(:build) { create(:ci_build, :success, :trace_artifact) }
- it 'does not select the build' do
+ it "does not select the build" do
is_expected.to be_empty
end
end
- context 'when there are multiple builds with test reports' do
+ context "when there are multiple builds with test reports" do
let!(:builds) { create_list(:ci_build, 5, :success, :test_reports) }
- it 'does not execute a query for selecting job artifact one by one' do
- recorded = ActiveRecord::QueryRecorder.new do
+ it "does not execute a query for selecting job artifact one by one" do
+ recorded = ActiveRecord::QueryRecorder.new {
subject.each do |build|
build.job_artifacts.map { |a| a.file.exists? }
end
- end
+ }
expect(recorded.count).to eq(2)
end
end
end
- describe '#actionize' do
- context 'when build is a created' do
+ describe "#actionize" do
+ context "when build is a created" do
before do
build.update_column(:status, :created)
end
- it 'makes build a manual action' do
+ it "makes build a manual action" do
expect(build.actionize).to be true
expect(build.reload).to be_manual
end
end
- context 'when build is not created' do
+ context "when build is not created" do
before do
build.update_column(:status, :pending)
end
- it 'does not change build status' do
+ it "does not change build status" do
expect(build.actionize).to be false
expect(build.reload).to be_pending
end
end
end
- describe '#schedulable?' do
+ describe "#schedulable?" do
subject { build.schedulable? }
- context 'when build is schedulable' do
+ context "when build is schedulable" do
let(:build) { create(:ci_build, :created, :schedulable, project: project) }
it { expect(subject).to be_truthy }
end
- context 'when build is not schedulable' do
+ context "when build is not schedulable" do
let(:build) { create(:ci_build, :created, project: project) }
it { expect(subject).to be_falsy }
end
end
- describe '#schedule' do
+ describe "#schedule" do
subject { build.schedule }
before do
@@ -235,7 +235,7 @@ describe Ci::Build do
let(:build) { create(:ci_build, :created, :schedulable, user: user, project: project) }
- it 'transits to scheduled' do
+ it "transits to scheduled" do
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
subject
@@ -243,7 +243,7 @@ describe Ci::Build do
expect(build).to be_scheduled
end
- it 'updates scheduled_at column' do
+ it "updates scheduled_at column" do
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
subject
@@ -251,7 +251,7 @@ describe Ci::Build do
expect(build.scheduled_at).not_to be_nil
end
- it 'schedules BuildScheduleWorker at the right time' do
+ it "schedules BuildScheduleWorker at the right time" do
Timecop.freeze do
expect(Ci::BuildScheduleWorker)
.to receive(:perform_at).with(be_like_time(1.minute.since), build.id)
@@ -261,29 +261,29 @@ describe Ci::Build do
end
end
- describe '#unschedule' do
+ describe "#unschedule" do
subject { build.unschedule }
- context 'when build is scheduled' do
+ context "when build is scheduled" do
let(:build) { create(:ci_build, :scheduled, pipeline: pipeline) }
- it 'cleans scheduled_at column' do
+ it "cleans scheduled_at column" do
subject
expect(build.scheduled_at).to be_nil
end
- it 'transits to manual' do
+ it "transits to manual" do
subject
expect(build).to be_manual
end
end
- context 'when build is not scheduled' do
+ context "when build is not scheduled" do
let(:build) { create(:ci_build, :created, pipeline: pipeline) }
- it 'does not transit status' do
+ it "does not transit status" do
subject
expect(build).to be_created
@@ -291,25 +291,25 @@ describe Ci::Build do
end
end
- describe '#options_scheduled_at' do
+ describe "#options_scheduled_at" do
subject { build.options_scheduled_at }
let(:build) { build_stubbed(:ci_build, options: option) }
- context 'when start_in is 1 day' do
- let(:option) { { start_in: '1 day' } }
+ context "when start_in is 1 day" do
+ let(:option) { {start_in: "1 day"} }
- it 'returns date after 1 day' do
+ it "returns date after 1 day" do
Timecop.freeze do
is_expected.to eq(1.day.since)
end
end
end
- context 'when start_in is 1 week' do
- let(:option) { { start_in: '1 week' } }
+ context "when start_in is 1 week" do
+ let(:option) { {start_in: "1 week"} }
- it 'returns date after 1 week' do
+ it "returns date after 1 week" do
Timecop.freeze do
is_expected.to eq(1.week.since)
end
@@ -317,29 +317,29 @@ describe Ci::Build do
end
end
- describe '#enqueue_scheduled' do
+ describe "#enqueue_scheduled" do
subject { build.enqueue_scheduled }
- context 'when build is scheduled and the right time has not come yet' do
+ context "when build is scheduled and the right time has not come yet" do
let(:build) { create(:ci_build, :scheduled, pipeline: pipeline) }
- it 'does not transits the status' do
+ it "does not transits the status" do
subject
expect(build).to be_scheduled
end
end
- context 'when build is scheduled and the right time has already come' do
+ context "when build is scheduled and the right time has already come" do
let(:build) { create(:ci_build, :expired_scheduled, pipeline: pipeline) }
- it 'cleans scheduled_at column' do
+ it "cleans scheduled_at column" do
subject
expect(build.scheduled_at).to be_nil
end
- it 'transits to pending' do
+ it "transits to pending" do
subject
expect(build).to be_pending
@@ -347,14 +347,14 @@ describe Ci::Build do
end
end
- describe '#any_runners_online?' do
+ describe "#any_runners_online?" do
subject { build.any_runners_online? }
- context 'when no runners' do
+ context "when no runners" do
it { is_expected.to be_falsey }
end
- context 'when there are runners' do
+ context "when there are runners" do
let(:runner) { create(:ci_runner, :project, projects: [build.project]) }
before do
@@ -363,39 +363,39 @@ describe Ci::Build do
it { is_expected.to be_truthy }
- it 'that is inactive' do
+ it "that is inactive" do
runner.update(active: false)
is_expected.to be_falsey
end
- it 'that is not online' do
+ it "that is not online" do
runner.update(contacted_at: nil)
is_expected.to be_falsey
end
- it 'that cannot handle build' do
+ it "that cannot handle build" do
expect_any_instance_of(Ci::Runner).to receive(:can_pick?).and_return(false)
is_expected.to be_falsey
end
end
end
- describe '#artifacts?' do
+ describe "#artifacts?" do
subject { build.artifacts? }
- context 'when new artifacts are used' do
- context 'artifacts archive does not exist' do
+ context "when new artifacts are used" do
+ context "artifacts archive does not exist" do
let(:build) { create(:ci_build) }
it { is_expected.to be_falsy }
end
- context 'artifacts archive exists' do
+ context "artifacts archive exists" do
let(:build) { create(:ci_build, :artifacts) }
it { is_expected.to be_truthy }
- context 'is expired' do
+ context "is expired" do
let(:build) { create(:ci_build, :artifacts, :expired) }
it { is_expected.to be_falsy }
@@ -403,24 +403,24 @@ describe Ci::Build do
end
end
- context 'when legacy artifacts are used' do
+ context "when legacy artifacts are used" do
let(:build) { create(:ci_build, :legacy_artifacts) }
subject { build.artifacts? }
- context 'is expired' do
+ context "is expired" do
let(:build) { create(:ci_build, :legacy_artifacts, :expired) }
it { is_expected.to be_falsy }
end
- context 'artifacts archive does not exist' do
+ context "artifacts archive does not exist" do
let(:build) { create(:ci_build) }
it { is_expected.to be_falsy }
end
- context 'artifacts archive exists' do
+ context "artifacts archive exists" do
let(:build) { create(:ci_build, :legacy_artifacts) }
it { is_expected.to be_truthy }
@@ -428,10 +428,10 @@ describe Ci::Build do
end
end
- describe '#browsable_artifacts?' do
+ describe "#browsable_artifacts?" do
subject { build.browsable_artifacts? }
- context 'artifacts metadata does not exist' do
+ context "artifacts metadata does not exist" do
before do
build.update(legacy_artifacts_metadata: nil)
end
@@ -439,17 +439,17 @@ describe Ci::Build do
it { is_expected.to be_falsy }
end
- context 'artifacts metadata does exists' do
+ context "artifacts metadata does exists" do
let(:build) { create(:ci_build, :artifacts) }
it { is_expected.to be_truthy }
end
end
- describe '#artifacts_expired?' do
+ describe "#artifacts_expired?" do
subject { build.artifacts_expired? }
- context 'is expired' do
+ context "is expired" do
before do
build.update(artifacts_expire_at: Time.now - 7.days)
end
@@ -457,7 +457,7 @@ describe Ci::Build do
it { is_expected.to be_truthy }
end
- context 'is not expired' do
+ context "is not expired" do
before do
build.update(artifacts_expire_at: Time.now + 7.days)
end
@@ -466,23 +466,23 @@ describe Ci::Build do
end
end
- describe '#artifacts_metadata?' do
+ describe "#artifacts_metadata?" do
subject { build.artifacts_metadata? }
- context 'artifacts metadata does not exist' do
+ context "artifacts metadata does not exist" do
it { is_expected.to be_falsy }
end
- context 'artifacts archive is a zip file and metadata exists' do
+ context "artifacts archive is a zip file and metadata exists" do
let(:build) { create(:ci_build, :artifacts) }
it { is_expected.to be_truthy }
end
end
- describe '#artifacts_expire_in' do
+ describe "#artifacts_expire_in" do
subject { build.artifacts_expire_in }
it { is_expected.to be_nil }
- context 'when artifacts_expire_at is specified' do
+ context "when artifacts_expire_at is specified" do
let(:expire_at) { Time.now + 7.days }
before do
@@ -493,50 +493,50 @@ describe Ci::Build do
end
end
- describe '#artifacts_expire_in=' do
+ describe "#artifacts_expire_in=" do
subject { build.artifacts_expire_in }
- it 'when assigning valid duration' do
- build.artifacts_expire_in = '7 days'
+ it "when assigning valid duration" do
+ build.artifacts_expire_in = "7 days"
is_expected.to be_within(10).of(7.days.to_i)
end
- it 'when assigning invalid duration' do
- expect { build.artifacts_expire_in = '7 elephants' }.to raise_error(ChronicDuration::DurationParseError)
+ it "when assigning invalid duration" do
+ expect { build.artifacts_expire_in = "7 elephants" }.to raise_error(ChronicDuration::DurationParseError)
is_expected.to be_nil
end
- it 'when resetting value' do
+ it "when resetting value" do
build.artifacts_expire_in = nil
is_expected.to be_nil
end
- it 'when setting to 0' do
- build.artifacts_expire_in = '0'
+ it "when setting to 0" do
+ build.artifacts_expire_in = "0"
is_expected.to be_nil
end
end
- describe '#commit' do
- it 'returns commit pipeline has been created for' do
+ describe "#commit" do
+ it "returns commit pipeline has been created for" do
expect(build.commit).to eq project.commit
end
end
- describe '#cache' do
- let(:options) { { cache: { key: "key", paths: ["public"], policy: "pull-push" } } }
+ describe "#cache" do
+ let(:options) { {cache: {key: "key", paths: ["public"], policy: "pull-push"}} }
subject { build.cache }
- context 'when build has cache' do
+ context "when build has cache" do
before do
allow(build).to receive(:options).and_return(options)
end
- context 'when project has jobs_cache_index' do
+ context "when project has jobs_cache_index" do
before do
allow_any_instance_of(Project).to receive(:jobs_cache_index).and_return(1)
end
@@ -544,7 +544,7 @@ describe Ci::Build do
it { is_expected.to be_an(Array).and all(include(key: "key-1")) }
end
- context 'when project does not have jobs_cache_index' do
+ context "when project does not have jobs_cache_index" do
before do
allow_any_instance_of(Project).to receive(:jobs_cache_index).and_return(nil)
end
@@ -553,7 +553,7 @@ describe Ci::Build do
end
end
- context 'when build does not have cache' do
+ context "when build does not have cache" do
before do
allow(build).to receive(:options).and_return({})
end
@@ -562,25 +562,25 @@ describe Ci::Build do
end
end
- describe '#depends_on_builds' do
- let!(:build) { create(:ci_build, pipeline: pipeline, name: 'build', stage_idx: 0, stage: 'build') }
- let!(:rspec_test) { create(:ci_build, pipeline: pipeline, name: 'rspec', stage_idx: 1, stage: 'test') }
- 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') }
+ describe "#depends_on_builds" do
+ let!(:build) { create(:ci_build, pipeline: pipeline, name: "build", stage_idx: 0, stage: "build") }
+ let!(:rspec_test) { create(:ci_build, pipeline: pipeline, name: "rspec", stage_idx: 1, stage: "test") }
+ 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 'expects 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 'expects 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 'expects 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 'expects to have retried builds instead the original ones' do
+ it "expects to have retried builds instead the original ones" do
project.add_developer(user)
retried_rspec = described_class.retry(rspec_test, user)
@@ -590,16 +590,16 @@ describe Ci::Build do
end
end
- describe '#triggered_by?' do
+ describe "#triggered_by?" do
subject { build.triggered_by?(user) }
- context 'when user is owner' do
+ context "when user is owner" do
let(:build) { create(:ci_build, pipeline: pipeline, user: user) }
it { is_expected.to be_truthy }
end
- context 'when user is not owner' do
+ context "when user is not owner" do
let(:another_user) { create(:user) }
let(:build) { create(:ci_build, pipeline: pipeline, user: another_user) }
@@ -607,28 +607,28 @@ describe Ci::Build do
end
end
- describe '#detailed_status' do
- it 'returns a detailed status' do
+ describe "#detailed_status" do
+ it "returns a detailed status" do
expect(build.detailed_status(user))
.to be_a Gitlab::Ci::Status::Build::Cancelable
end
end
- describe '#coverage_regex' do
+ describe "#coverage_regex" do
subject { build.coverage_regex }
- context 'when project has build_coverage_regex set' do
+ context "when project has build_coverage_regex set" do
let(:project_regex) { '\(\d+\.\d+\) covered' }
before do
project.update_column(:build_coverage_regex, project_regex)
end
- context 'and coverage_regex attribute is not set' do
+ context "and coverage_regex attribute is not set" do
it { is_expected.to eq(project_regex) }
end
- context 'but coverage_regex attribute is also set' do
+ context "but coverage_regex attribute is also set" do
let(:build_regex) { 'Code coverage: \d+\.\d+' }
before do
@@ -639,16 +639,16 @@ describe Ci::Build do
end
end
- context 'when neither project nor build has coverage regex set' do
+ context "when neither project nor build has coverage regex set" do
it { is_expected.to be_nil }
end
end
- describe '#update_coverage' do
+ describe "#update_coverage" do
context "regarding coverage_regex's value," do
before do
build.coverage_regex = '\(\d+.\d+\%\) covered'
- build.trace.set('Coverage 1033 / 1051 LOC (98.29%) covered')
+ build.trace.set("Coverage 1033 / 1051 LOC (98.29%) covered")
end
it "saves the correct extracted coverage value" do
@@ -658,10 +658,10 @@ describe Ci::Build do
end
end
- describe '#parse_trace_sections!' do
- it 'calls ExtractSectionsFromBuildTraceService' do
+ describe "#parse_trace_sections!" do
+ it "calls ExtractSectionsFromBuildTraceService" do
expect(Ci::ExtractSectionsFromBuildTraceService)
- .to receive(:new).with(project, build.user).once.and_call_original
+ .to receive(:new).with(project, build.user).once.and_call_original
expect_any_instance_of(Ci::ExtractSectionsFromBuildTraceService)
.to receive(:execute).with(build).once
@@ -669,13 +669,13 @@ describe Ci::Build do
end
end
- describe '#trace' do
+ describe "#trace" do
subject { build.trace }
it { is_expected.to be_a(Gitlab::Ci::Trace) }
end
- describe '#has_trace?' do
+ describe "#has_trace?" do
subject { build.has_trace? }
it "expect to call exist? method" do
@@ -686,62 +686,62 @@ describe Ci::Build do
end
end
- describe '#has_job_artifacts?' do
+ describe "#has_job_artifacts?" do
subject { build.has_job_artifacts? }
- context 'when build has a job artifact' do
+ context "when build has a job artifact" do
let(:build) { create(:ci_build, :artifacts) }
it { is_expected.to be_truthy }
end
- context 'when build does not have job artifacts' do
+ context "when build does not have job artifacts" do
let(:build) { create(:ci_build, :legacy_artifacts) }
it { is_expected.to be_falsy }
end
end
- describe '#has_old_trace?' do
+ describe "#has_old_trace?" do
subject { build.has_old_trace? }
- context 'when old trace exists' do
+ context "when old trace exists" do
before do
- build.update_column(:trace, 'old trace')
+ build.update_column(:trace, "old trace")
end
it { is_expected.to be_truthy }
end
- context 'when old trace does not exist' do
+ context "when old trace does not exist" do
it { is_expected.to be_falsy }
end
end
- describe '#trace=' do
+ describe "#trace=" do
it "expect to fail trace=" do
expect { build.trace = "new" }.to raise_error(NotImplementedError)
end
end
- describe '#old_trace' do
+ describe "#old_trace" do
subject { build.old_trace }
before do
- build.update_column(:trace, 'old trace')
+ build.update_column(:trace, "old trace")
end
it "expect to receive data from database" do
- is_expected.to eq('old trace')
+ is_expected.to eq("old trace")
end
end
- describe '#erase_old_trace!' do
+ describe "#erase_old_trace!" do
subject { build.erase_old_trace! }
- context 'when old trace exists' do
+ context "when old trace exists" do
before do
- build.update_column(:trace, 'old trace')
+ build.update_column(:trace, "old trace")
end
it "erases old trace" do
@@ -757,8 +757,8 @@ describe Ci::Build do
end
end
- context 'when old trace does not exist' do
- it 'does not execute UPDATE query' do
+ context "when old trace does not exist" do
+ it "does not execute UPDATE query" do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.log.select { |l| l.match?(/UPDATE.*ci_builds/) }.count).to eq(0)
@@ -766,138 +766,138 @@ describe Ci::Build do
end
end
- describe '#hide_secrets' do
+ describe "#hide_secrets" do
let(:subject) { build.hide_secrets(data) }
- context 'hide runners token' do
+ context "hide runners token" do
let(:data) { "new #{project.runners_token} data"}
it { is_expected.to match(/^new x+ data$/) }
end
- context 'hide build token' do
+ context "hide build token" do
let(:data) { "new #{build.token} data"}
it { is_expected.to match(/^new x+ data$/) }
end
end
- describe 'state transition as a deployable' do
+ describe "state transition as a deployable" do
let!(:build) { create(:ci_build, :start_review_app) }
let(:deployment) { build.deployment }
let(:environment) { deployment.environment }
- it 'has deployments record with created status' do
+ it "has deployments record with created status" do
expect(deployment).to be_created
- expect(environment.name).to eq('review/master')
+ expect(environment.name).to eq("review/master")
end
- context 'when transits to running' do
+ context "when transits to running" do
before do
build.run!
end
- it 'transits deployment status to running' do
+ it "transits deployment status to running" do
expect(deployment).to be_running
end
end
- context 'when transits to success' do
+ context "when transits to success" do
before do
allow(Deployments::SuccessWorker).to receive(:perform_async)
build.success!
end
- it 'transits deployment status to success' do
+ it "transits deployment status to success" do
expect(deployment).to be_success
end
end
- context 'when transits to failed' do
+ context "when transits to failed" do
before do
build.drop!
end
- it 'transits deployment status to failed' do
+ it "transits deployment status to failed" do
expect(deployment).to be_failed
end
end
- context 'when transits to skipped' do
+ context "when transits to skipped" do
before do
build.skip!
end
- it 'transits deployment status to canceled' do
+ it "transits deployment status to canceled" do
expect(deployment).to be_canceled
end
end
- context 'when transits to canceled' do
+ context "when transits to canceled" do
before do
build.cancel!
end
- it 'transits deployment status to canceled' do
+ it "transits deployment status to canceled" do
expect(deployment).to be_canceled
end
end
end
- describe '#on_stop' do
+ describe "#on_stop" do
subject { build.on_stop }
- context 'when a job has a specification that it can be stopped from the other job' do
+ context "when a job has a specification that it can be stopped from the other job" do
let(:build) { create(:ci_build, :start_review_app) }
- it 'returns the other job name' do
- is_expected.to eq('stop_review_app')
+ it "returns the other job name" do
+ is_expected.to eq("stop_review_app")
end
end
- context 'when a job does not have environment information' do
+ context "when a job does not have environment information" do
let(:build) { create(:ci_build) }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- describe 'deployment' do
- describe '#has_deployment?' do
+ describe "deployment" do
+ describe "#has_deployment?" do
subject { build.has_deployment? }
- context 'when build has a deployment' do
+ context "when build has a deployment" do
let!(:deployment) { create(:deployment, deployable: build) }
it { is_expected.to be_truthy }
end
- context 'when build does not have a deployment' do
+ context "when build does not have a deployment" do
it { is_expected.to be_falsy }
end
end
- describe '#outdated_deployment?' do
+ describe "#outdated_deployment?" do
subject { build.outdated_deployment? }
- context 'when build succeeded' do
+ context "when build succeeded" do
let(:build) { create(:ci_build, :success) }
let!(:deployment) { create(:deployment, :success, deployable: build) }
- context 'current deployment is latest' do
+ context "current deployment is latest" do
it { is_expected.to be_falsey }
end
- context 'current deployment is not latest on environment' do
+ context "current deployment is not latest on environment" do
let!(:deployment2) { create(:deployment, :success, environment: deployment.environment) }
it { is_expected.to be_truthy }
end
end
- context 'when build failed' do
+ context "when build failed" do
let(:build) { create(:ci_build, :failed) }
it { is_expected.to be_falsey }
@@ -905,19 +905,19 @@ describe Ci::Build do
end
end
- describe 'environment' do
- describe '#has_environment?' do
+ describe "environment" do
+ describe "#has_environment?" do
subject { build.has_environment? }
- context 'when environment is defined' do
+ context "when environment is defined" do
before do
- build.update(environment: 'review')
+ build.update(environment: "review")
end
it { is_expected.to be_truthy }
end
- context 'when environment is not defined' do
+ context "when environment is not defined" do
before do
build.update(environment: nil)
end
@@ -926,60 +926,60 @@ describe Ci::Build do
end
end
- describe '#expanded_environment_name' do
+ describe "#expanded_environment_name" do
subject { build.expanded_environment_name }
- context 'when environment uses $CI_COMMIT_REF_NAME' do
+ context "when environment uses $CI_COMMIT_REF_NAME" do
let(:build) do
create(:ci_build,
- ref: 'master',
- environment: 'review/$CI_COMMIT_REF_NAME')
+ ref: "master",
+ environment: "review/$CI_COMMIT_REF_NAME")
end
- it { is_expected.to eq('review/master') }
+ it { is_expected.to eq("review/master") }
end
- context 'when environment uses yaml_variables containing symbol keys' do
+ context "when environment uses yaml_variables containing symbol keys" do
let(:build) do
create(:ci_build,
- yaml_variables: [{ key: :APP_HOST, value: 'host' }],
- environment: 'review/$APP_HOST')
+ yaml_variables: [{key: :APP_HOST, value: "host"}],
+ environment: "review/$APP_HOST")
end
- it { is_expected.to eq('review/host') }
+ it { is_expected.to eq("review/host") }
end
- context 'when using persisted variables' do
+ context "when using persisted variables" do
let(:build) do
- create(:ci_build, environment: 'review/x$CI_BUILD_ID')
+ create(:ci_build, environment: "review/x$CI_BUILD_ID")
end
- it { is_expected.to eq('review/x') }
+ it { is_expected.to eq("review/x") }
end
end
- describe '#starts_environment?' do
+ describe "#starts_environment?" do
subject { build.starts_environment? }
- context 'when environment is defined' do
+ context "when environment is defined" do
before do
- build.update(environment: 'review')
+ build.update(environment: "review")
end
- context 'no action is defined' do
+ context "no action is defined" do
it { is_expected.to be_truthy }
end
- context 'and start action is defined' do
+ context "and start action is defined" do
before do
- build.update(options: { environment: { action: 'start' } } )
+ build.update(options: {environment: {action: "start"}})
end
it { is_expected.to be_truthy }
end
end
- context 'when environment is not defined' do
+ context "when environment is not defined" do
before do
build.update(environment: nil)
end
@@ -988,28 +988,28 @@ describe Ci::Build do
end
end
- describe '#stops_environment?' do
+ describe "#stops_environment?" do
subject { build.stops_environment? }
- context 'when environment is defined' do
+ context "when environment is defined" do
before do
- build.update(environment: 'review')
+ build.update(environment: "review")
end
- context 'no action is defined' do
+ context "no action is defined" do
it { is_expected.to be_falsey }
end
- context 'and stop action is defined' do
+ context "and stop action is defined" do
before do
- build.update(options: { environment: { action: 'stop' } } )
+ build.update(options: {environment: {action: "stop"}})
end
it { is_expected.to be_truthy }
end
end
- context 'when environment is not defined' do
+ context "when environment is not defined" do
before do
build.update(environment: nil)
end
@@ -1019,93 +1019,93 @@ describe Ci::Build do
end
end
- describe 'erasable build' do
- shared_examples 'erasable' do
- it 'removes artifact file' do
+ describe "erasable build" do
+ shared_examples "erasable" do
+ it "removes artifact file" do
expect(build.artifacts_file.exists?).to be_falsy
end
- it 'removes artifact metadata file' do
+ it "removes artifact metadata file" do
expect(build.artifacts_metadata.exists?).to be_falsy
end
- it 'removes all job_artifacts' do
+ it "removes all job_artifacts" do
expect(build.job_artifacts.count).to eq(0)
end
- it 'erases build trace in trace file' do
+ it "erases build trace in trace file" do
expect(build).not_to have_trace
end
- it 'sets erased to true' do
+ it "sets erased to true" do
expect(build.erased?).to be true
end
- it 'sets erase date' do
+ it "sets erase date" do
expect(build.erased_at).not_to be_falsy
end
end
- context 'build is not erasable' do
+ context "build is not erasable" do
let!(:build) { create(:ci_build) }
- describe '#erase' do
+ describe "#erase" do
subject { build.erase }
it { is_expected.to be false }
end
- describe '#erasable?' do
+ describe "#erasable?" do
subject { build.erasable? }
it { is_expected.to eq false }
end
end
- context 'build is erasable' do
- context 'new artifacts' do
+ context "build is erasable" do
+ context "new artifacts" do
let!(:build) { create(:ci_build, :test_reports, :trace_artifact, :success, :artifacts) }
- describe '#erase' do
+ describe "#erase" do
before do
build.erase(erased_by: erased_by)
end
- context 'erased by user' do
- let!(:erased_by) { create(:user, username: 'eraser') }
+ context "erased by user" do
+ let!(:erased_by) { create(:user, username: "eraser") }
- include_examples 'erasable'
+ include_examples "erasable"
- it 'records user who erased a build' do
+ it "records user who erased a build" do
expect(build.erased_by).to eq erased_by
end
end
- context 'erased by system' do
+ context "erased by system" do
let(:erased_by) { nil }
- include_examples 'erasable'
+ include_examples "erasable"
- it 'does 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
end
- describe '#erasable?' do
+ describe "#erasable?" do
subject { build.erasable? }
it { is_expected.to be_truthy }
end
- describe '#erased?' do
+ describe "#erased?" do
let!(:build) { create(:ci_build, :trace_artifact, :success, :artifacts) }
subject { build.erased? }
- context 'job has not been erased' do
+ context "job has not been erased" do
it { is_expected.to be_falsey }
end
- context 'job has been erased' do
+ context "job has been erased" do
before do
build.erase
end
@@ -1114,15 +1114,15 @@ describe Ci::Build do
end
end
- context 'metadata and build trace are not available' do
+ context "metadata and build trace are not available" do
let!(:build) { create(:ci_build, :success, :artifacts) }
before do
build.remove_artifacts_metadata!
end
- describe '#erase' do
- it 'does not raise error' do
+ describe "#erase" do
+ it "does not raise error" do
expect { build.erase }.not_to raise_error
end
end
@@ -1130,51 +1130,51 @@ describe Ci::Build do
end
end
- context 'old artifacts' do
- context 'build is erasable' do
- context 'new artifacts' do
+ context "old artifacts" do
+ context "build is erasable" do
+ context "new artifacts" do
let!(:build) { create(:ci_build, :trace_artifact, :success, :legacy_artifacts) }
- describe '#erase' do
+ describe "#erase" do
before do
build.erase(erased_by: erased_by)
end
- context 'erased by user' do
- let!(:erased_by) { create(:user, username: 'eraser') }
+ context "erased by user" do
+ let!(:erased_by) { create(:user, username: "eraser") }
- include_examples 'erasable'
+ include_examples "erasable"
- it 'records user who erased a build' do
+ it "records user who erased a build" do
expect(build.erased_by).to eq erased_by
end
end
- context 'erased by system' do
+ context "erased by system" do
let(:erased_by) { nil }
- include_examples 'erasable'
+ include_examples "erasable"
- it 'does 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
end
- describe '#erasable?' do
+ describe "#erasable?" do
subject { build.erasable? }
it { is_expected.to be_truthy }
end
- describe '#erased?' do
+ describe "#erased?" do
let!(:build) { create(:ci_build, :trace_artifact, :success, :legacy_artifacts) }
subject { build.erased? }
- context 'job has not been erased' do
+ context "job has not been erased" do
it { is_expected.to be_falsey }
end
- context 'job has been erased' do
+ context "job has been erased" do
before do
build.erase
end
@@ -1183,15 +1183,15 @@ describe Ci::Build do
end
end
- context 'metadata and build trace are not available' do
+ context "metadata and build trace are not available" do
let!(:build) { create(:ci_build, :success, :legacy_artifacts) }
before do
build.remove_artifacts_metadata!
end
- describe '#erase' do
- it 'does not raise error' do
+ describe "#erase" do
+ it "does not raise error" do
expect { build.erase }.not_to raise_error
end
end
@@ -1201,7 +1201,7 @@ describe Ci::Build do
end
end
- describe '#erase_erasable_artifacts!' do
+ describe "#erase_erasable_artifacts!" do
let!(:build) { create(:ci_build, :success) }
subject { build.erase_erasable_artifacts! }
@@ -1227,64 +1227,64 @@ describe Ci::Build do
end
end
- describe '#first_pending' do
- let!(:first) { create(:ci_build, pipeline: pipeline, status: 'pending', created_at: Date.yesterday) }
- let!(:second) { create(:ci_build, pipeline: pipeline, status: 'pending') }
+ describe "#first_pending" do
+ let!(:first) { create(:ci_build, pipeline: pipeline, status: "pending", created_at: Date.yesterday) }
+ let!(:second) { create(:ci_build, pipeline: pipeline, status: "pending") }
subject { described_class.first_pending }
it { is_expected.to be_a(described_class) }
- it('returns with the first pending build') { is_expected.to eq(first) }
+ it("returns with the first pending build") { is_expected.to eq(first) }
end
- describe '#failed_but_allowed?' do
+ describe "#failed_but_allowed?" do
subject { build.failed_but_allowed? }
- context 'when build is not allowed to fail' do
+ context "when build is not allowed to fail" do
before do
build.allow_failure = false
end
- context 'and build.status is success' do
+ context "and build.status is success" do
before do
- build.status = 'success'
+ build.status = "success"
end
it { is_expected.to be_falsey }
end
- context 'and build.status is failed' do
+ context "and build.status is failed" do
before do
- build.status = 'failed'
+ build.status = "failed"
end
it { is_expected.to be_falsey }
end
end
- context 'when build is allowed to fail' do
+ context "when build is allowed to fail" do
before do
build.allow_failure = true
end
- context 'and build.status is success' do
+ context "and build.status is success" do
before do
- build.status = 'success'
+ build.status = "success"
end
it { is_expected.to be_falsey }
end
- context 'and build status is failed' do
+ context "and build status is failed" do
before do
- build.status = 'failed'
+ build.status = "failed"
end
it { is_expected.to be_truthy }
end
- context 'when build is a manual action' do
+ context "when build is a manual action" do
before do
- build.status = 'manual'
+ build.status = "manual"
end
it { is_expected.to be_falsey }
@@ -1292,16 +1292,16 @@ describe Ci::Build do
end
end
- describe 'flags' do
- describe '#cancelable?' do
+ describe "flags" do
+ describe "#cancelable?" do
subject { build }
- context 'when build is cancelable' do
- context 'when build is pending' do
+ context "when build is cancelable" do
+ context "when build is pending" do
it { is_expected.to be_cancelable }
end
- context 'when build is running' do
+ context "when build is running" do
before do
build.run!
end
@@ -1309,15 +1309,15 @@ describe Ci::Build do
it { is_expected.to be_cancelable }
end
- context 'when build is created' do
+ context "when build is created" do
let(:build) { create(:ci_build, :created) }
it { is_expected.to be_cancelable }
end
end
- context 'when build is not cancelable' do
- context 'when build is successful' do
+ context "when build is not cancelable" do
+ context "when build is successful" do
before do
build.success!
end
@@ -1325,7 +1325,7 @@ describe Ci::Build do
it { is_expected.not_to be_cancelable }
end
- context 'when build is failed' do
+ context "when build is failed" do
before do
build.drop!
end
@@ -1335,11 +1335,11 @@ describe Ci::Build do
end
end
- describe '#retryable?' do
+ describe "#retryable?" do
subject { build }
- context 'when build is retryable' do
- context 'when build is successful' do
+ context "when build is retryable" do
+ context "when build is successful" do
before do
build.success!
end
@@ -1347,7 +1347,7 @@ describe Ci::Build do
it { is_expected.to be_retryable }
end
- context 'when build is failed' do
+ context "when build is failed" do
before do
build.drop!
end
@@ -1355,7 +1355,7 @@ describe Ci::Build do
it { is_expected.to be_retryable }
end
- context 'when build is canceled' do
+ context "when build is canceled" do
before do
build.cancel!
end
@@ -1364,8 +1364,8 @@ describe Ci::Build do
end
end
- context 'when build is not retryable' do
- context 'when build is running' do
+ context "when build is not retryable" do
+ context "when build is running" do
before do
build.run!
end
@@ -1373,7 +1373,7 @@ describe Ci::Build do
it { is_expected.not_to be_retryable }
end
- context 'when build is skipped' do
+ context "when build is skipped" do
before do
build.skip!
end
@@ -1381,7 +1381,7 @@ describe Ci::Build do
it { is_expected.not_to be_retryable }
end
- context 'when build is degenerated' do
+ context "when build is degenerated" do
before do
build.degenerate!
end
@@ -1391,203 +1391,203 @@ describe Ci::Build do
end
end
- describe '#action?' do
+ describe "#action?" do
before do
build.update(when: value)
end
subject { build.action? }
- context 'when is set to manual' do
- let(:value) { 'manual' }
+ context "when is set to manual" do
+ let(:value) { "manual" }
it { is_expected.to be_truthy }
end
- context 'when is set to delayed' do
- let(:value) { 'delayed' }
+ context "when is set to delayed" do
+ let(:value) { "delayed" }
it { is_expected.to be_truthy }
end
- context 'when set to something else' do
- let(:value) { 'something else' }
+ context "when set to something else" do
+ let(:value) { "something else" }
it { is_expected.to be_falsey }
end
end
end
- describe '#has_tags?' do
- context 'when build has tags' do
- subject { create(:ci_build, tag_list: ['tag']) }
+ describe "#has_tags?" do
+ context "when build has tags" do
+ subject { create(:ci_build, tag_list: ["tag"]) }
it { is_expected.to have_tags }
end
- context 'when build does not have tags' do
+ context "when build does not have tags" do
subject { create(:ci_build, tag_list: []) }
it { is_expected.not_to have_tags }
end
end
- describe 'build auto retry feature' do
- describe '#retries_count' do
- subject { create(:ci_build, name: 'test', pipeline: pipeline) }
+ describe "build auto retry feature" do
+ describe "#retries_count" do
+ subject { create(:ci_build, name: "test", pipeline: pipeline) }
- context 'when build has been retried several times' do
+ context "when build has been retried several times" do
before do
- create(:ci_build, :retried, name: 'test', pipeline: pipeline)
- create(:ci_build, :retried, name: 'test', pipeline: pipeline)
+ create(:ci_build, :retried, name: "test", pipeline: pipeline)
+ create(:ci_build, :retried, name: "test", pipeline: pipeline)
end
- it 'reports a correct retry count value' do
+ it "reports a correct retry count value" do
expect(subject.retries_count).to eq 2
end
end
- context 'when build has not been retried' do
- it 'returns zero' do
+ context "when build has not been retried" do
+ it "returns zero" do
expect(subject.retries_count).to eq 0
end
end
end
- describe '#retries_max' do
- context 'with retries max config option' do
- subject { create(:ci_build, options: { retry: { max: 1 } }) }
+ describe "#retries_max" do
+ context "with retries max config option" do
+ subject { create(:ci_build, options: {retry: {max: 1}}) }
- context 'when build_metadata_config is set' do
+ context "when build_metadata_config is set" do
before do
stub_feature_flags(ci_build_metadata_config: true)
end
- it 'returns the number of configured max retries' do
+ it "returns the number of configured max retries" do
expect(subject.retries_max).to eq 1
end
end
- context 'when build_metadata_config is not set' do
+ context "when build_metadata_config is not set" do
before do
stub_feature_flags(ci_build_metadata_config: false)
end
- it 'returns the number of configured max retries' do
+ it "returns the number of configured max retries" do
expect(subject.retries_max).to eq 1
end
end
end
- context 'without retries max config option' do
+ context "without retries max config option" do
subject { create(:ci_build) }
- it 'returns zero' do
+ it "returns zero" do
expect(subject.retries_max).to eq 0
end
end
- context 'when build is degenerated' do
+ context "when build is degenerated" do
subject { create(:ci_build, :degenerated) }
- it 'returns zero' do
+ it "returns zero" do
expect(subject.retries_max).to eq 0
end
end
- context 'with integer only config option' do
- subject { create(:ci_build, options: { retry: 1 }) }
+ context "with integer only config option" do
+ subject { create(:ci_build, options: {retry: 1}) }
- it 'returns the number of configured max retries' do
+ it "returns the number of configured max retries" do
expect(subject.retries_max).to eq 1
end
end
end
- describe '#retry_when' do
- context 'with retries when config option' do
- subject { create(:ci_build, options: { retry: { when: ['some_reason'] } }) }
+ describe "#retry_when" do
+ context "with retries when config option" do
+ subject { create(:ci_build, options: {retry: {when: ["some_reason"]}}) }
- it 'returns the configured when' do
- expect(subject.retry_when).to eq ['some_reason']
+ it "returns the configured when" do
+ expect(subject.retry_when).to eq ["some_reason"]
end
end
- context 'without retries when config option' do
+ context "without retries when config option" do
subject { create(:ci_build) }
- it 'returns always array' do
- expect(subject.retry_when).to eq ['always']
+ it "returns always array" do
+ expect(subject.retry_when).to eq ["always"]
end
end
- context 'with integer only config option' do
- subject { create(:ci_build, options: { retry: 1 }) }
+ context "with integer only config option" do
+ subject { create(:ci_build, options: {retry: 1}) }
- it 'returns always array' do
- expect(subject.retry_when).to eq ['always']
+ it "returns always array" do
+ expect(subject.retry_when).to eq ["always"]
end
end
end
- describe '#retry_failure?' do
+ describe "#retry_failure?" do
subject { create(:ci_build) }
- context 'when retries max is zero' do
+ context "when retries max is zero" do
before do
expect(subject).to receive(:retries_max).at_least(:once).and_return(0)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.retry_failure?).to eq false
end
end
- context 'when retries max equals retries count' do
+ context "when retries max equals retries count" do
before do
expect(subject).to receive(:retries_max).at_least(:once).and_return(1)
expect(subject).to receive(:retries_count).at_least(:once).and_return(1)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.retry_failure?).to eq false
end
end
- context 'when retries max is higher than retries count' do
+ context "when retries max is higher than retries count" do
before do
expect(subject).to receive(:retries_max).at_least(:once).and_return(2)
expect(subject).to receive(:retries_count).at_least(:once).and_return(1)
end
- context 'and retry when is always' do
+ context "and retry when is always" do
before do
- expect(subject).to receive(:retry_when).at_least(:once).and_return(['always'])
+ expect(subject).to receive(:retry_when).at_least(:once).and_return(["always"])
end
- it 'returns true' do
+ it "returns true" do
expect(subject.retry_failure?).to eq true
end
end
- context 'and retry when includes the failure_reason' do
+ context "and retry when includes the failure_reason" do
before do
- expect(subject).to receive(:failure_reason).at_least(:once).and_return('some_reason')
- expect(subject).to receive(:retry_when).at_least(:once).and_return(['some_reason'])
+ expect(subject).to receive(:failure_reason).at_least(:once).and_return("some_reason")
+ expect(subject).to receive(:retry_when).at_least(:once).and_return(["some_reason"])
end
- it 'returns true' do
+ it "returns true" do
expect(subject.retry_failure?).to eq true
end
end
- context 'and retry when does not include failure_reason' do
+ context "and retry when does not include failure_reason" do
before do
- expect(subject).to receive(:failure_reason).at_least(:once).and_return('some_reason')
- expect(subject).to receive(:retry_when).at_least(:once).and_return(['some', 'other failure'])
+ expect(subject).to receive(:failure_reason).at_least(:once).and_return("some_reason")
+ expect(subject).to receive(:retry_when).at_least(:once).and_return(["some", "other failure"])
end
- it 'returns false' do
+ it "returns false" do
expect(subject.retry_failure?).to eq false
end
end
@@ -1595,21 +1595,21 @@ describe Ci::Build do
end
end
- describe '#keep_artifacts!' do
+ describe "#keep_artifacts!" do
let(:build) { create(:ci_build, artifacts_expire_at: Time.now + 7.days) }
subject { build.keep_artifacts! }
- it 'to reset expire_at' do
+ it "to reset expire_at" do
subject
expect(build.artifacts_expire_at).to be_nil
end
- context 'when having artifacts files' do
- let!(:artifact) { create(:ci_job_artifact, job: build, expire_in: '7 days') }
+ context "when having artifacts files" do
+ let!(:artifact) { create(:ci_job_artifact, job: build, expire_in: "7 days") }
- it 'to reset dependent objects' do
+ it "to reset dependent objects" do
subject
expect(artifact.reload.expire_at).to be_nil
@@ -1617,20 +1617,20 @@ describe Ci::Build do
end
end
- describe '#artifacts_file_for_type' do
+ describe "#artifacts_file_for_type" do
let(:build) { create(:ci_build, :artifacts) }
let(:file_type) { :archive }
subject { build.artifacts_file_for_type(file_type) }
- it 'queries artifacts for type' do
+ it "queries artifacts for type" do
expect(build).to receive_message_chain(:job_artifacts, :find_by).with(file_type: Ci::JobArtifact.file_types[file_type])
subject
end
end
- describe '#merge_request' do
+ describe "#merge_request" do
def create_mr(build, pipeline, factory: :merge_request, created_at: Time.now)
create(factory, source_project: pipeline.project,
target_project: pipeline.project,
@@ -1638,7 +1638,7 @@ describe Ci::Build do
created_at: created_at)
end
- context 'when a MR has a reference to the pipeline' do
+ context "when a MR has a reference to the pipeline" do
before do
@merge_request = create_mr(build, pipeline, factory: :merge_request)
@@ -1647,18 +1647,18 @@ describe Ci::Build do
allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request])
end
- it 'returns the single associated MR' do
+ it "returns the single associated MR" do
expect(build.merge_request.id).to eq(@merge_request.id)
end
end
- context 'when there is not a MR referencing the pipeline' do
- it 'returns nil' do
+ context "when there is not a MR referencing the pipeline" do
+ it "returns nil" do
expect(build.merge_request).to be_nil
end
end
- context 'when more than one MR have a reference to the pipeline' do
+ context "when more than one MR have a reference to the pipeline" do
before do
@merge_request = create_mr(build, pipeline, factory: :merge_request)
@merge_request.close!
@@ -1670,12 +1670,12 @@ describe Ci::Build do
allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request, @merge_request2])
end
- it 'returns the first MR' do
+ it "returns the first MR" do
expect(build.merge_request.id).to eq(@merge_request.id)
end
end
- context 'when a Build is created after the MR' do
+ context "when a Build is created after the MR" do
before do
@merge_request = create_mr(build, pipeline, factory: :merge_request_with_diffs)
pipeline2 = create(:ci_pipeline, project: project)
@@ -1686,65 +1686,65 @@ describe Ci::Build do
allow(MergeRequest).to receive_message_chain(:includes, :where, :reorder).and_return([@merge_request])
end
- it 'returns the current MR' do
+ it "returns the current MR" do
expect(@build2.merge_request.id).to eq(@merge_request.id)
end
end
end
- describe '#options' do
+ describe "#options" do
let(:options) do
{
image: "ruby:2.1",
services: ["postgres"],
- script: ["ls -a"]
+ script: ["ls -a"],
}
end
- it 'contains options' do
+ it "contains options" do
expect(build.options).to eq(options.stringify_keys)
end
- it 'allows to access with keys' do
- expect(build.options[:image]).to eq('ruby:2.1')
+ it "allows to access with keys" do
+ expect(build.options[:image]).to eq("ruby:2.1")
end
- it 'allows to access with strings' do
- expect(build.options['image']).to eq('ruby:2.1')
+ it "allows to access with strings" do
+ expect(build.options["image"]).to eq("ruby:2.1")
end
- context 'when ci_build_metadata_config is set' do
+ context "when ci_build_metadata_config is set" do
before do
stub_feature_flags(ci_build_metadata_config: true)
end
- it 'persist data in build metadata' do
+ it "persist data in build metadata" do
expect(build.metadata.read_attribute(:config_options)).to eq(options.stringify_keys)
end
- it 'does not persist data in build' do
+ it "does not persist data in build" do
expect(build.read_attribute(:options)).to be_nil
end
end
- context 'when ci_build_metadata_config is disabled' do
+ context "when ci_build_metadata_config is disabled" do
before do
stub_feature_flags(ci_build_metadata_config: false)
end
- it 'persist data in build' do
+ it "persist data in build" do
expect(build.read_attribute(:options)).to eq(options.symbolize_keys)
end
- it 'does not persist data in build metadata' do
+ it "does not persist data in build metadata" do
expect(build.metadata.read_attribute(:config_options)).to be_nil
end
end
end
- describe '#other_manual_actions' do
+ describe "#other_manual_actions" do
let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
- let!(:other_build) { create(:ci_build, :manual, pipeline: pipeline, name: 'other action') }
+ let!(:other_build) { create(:ci_build, :manual, pipeline: pipeline, name: "other action") }
subject { build.other_manual_actions }
@@ -1752,32 +1752,32 @@ describe Ci::Build do
project.add_developer(user)
end
- it 'returns other actions' do
+ it "returns other actions" do
is_expected.to contain_exactly(other_build)
end
- context 'when build is retried' do
+ context "when build is retried" do
let!(:new_build) { described_class.retry(build, user) }
- it 'does not return any of them' do
+ it "does not return any of them" do
is_expected.not_to include(build, new_build)
end
end
- context 'when other build is retried' do
+ context "when other build is retried" do
let!(:retried_build) { described_class.retry(other_build, user) }
before do
retried_build.success
end
- it 'returns a retried build' do
+ it "returns a retried build" do
is_expected.to contain_exactly(retried_build)
end
end
end
- describe '#other_scheduled_actions' do
+ describe "#other_scheduled_actions" do
let(:build) { create(:ci_build, :scheduled, pipeline: pipeline) }
subject { build.other_scheduled_actions }
@@ -1787,46 +1787,46 @@ describe Ci::Build do
end
context "when other build's status is success" do
- let!(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other action') }
+ let!(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: "other action") }
- it 'returns other actions' do
+ it "returns other actions" do
is_expected.to contain_exactly(other_build)
end
end
context "when other build's status is failed" do
- let!(:other_build) { create(:ci_build, :schedulable, :failed, pipeline: pipeline, name: 'other action') }
+ let!(:other_build) { create(:ci_build, :schedulable, :failed, pipeline: pipeline, name: "other action") }
- it 'returns other actions' do
+ it "returns other actions" do
is_expected.to contain_exactly(other_build)
end
end
context "when other build's status is running" do
- let!(:other_build) { create(:ci_build, :schedulable, :running, pipeline: pipeline, name: 'other action') }
+ let!(:other_build) { create(:ci_build, :schedulable, :running, pipeline: pipeline, name: "other action") }
- it 'does not return other actions' do
+ it "does not return other actions" do
is_expected.to be_empty
end
end
context "when other build's status is scheduled" do
- let!(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other action') }
+ let!(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: "other action") }
- it 'does not return other actions' do
+ it "does not return other actions" do
is_expected.to contain_exactly(other_build)
end
end
end
- describe '#persisted_environment' do
+ describe "#persisted_environment" do
let!(:environment) do
create(:environment, project: project, name: "foo-#{project.default_branch}")
end
subject { build.persisted_environment }
- context 'when referenced literally' do
+ context "when referenced literally" do
let(:build) do
create(:ci_build, pipeline: pipeline, environment: "foo-#{project.default_branch}")
end
@@ -1834,7 +1834,7 @@ describe Ci::Build do
it { is_expected.to eq(environment) }
end
- context 'when referenced with a variable' do
+ context "when referenced with a variable" do
let(:build) do
create(:ci_build, pipeline: pipeline, environment: "foo-$CI_COMMIT_REF_NAME")
end
@@ -1842,24 +1842,24 @@ describe Ci::Build do
it { is_expected.to eq(environment) }
end
- context 'when there is no environment' do
+ context "when there is no environment" do
it { is_expected.to be_nil }
end
- context 'when build has a start environment' do
+ context "when build has a start environment" do
let(:build) { create(:ci_build, :deploy_to_production, pipeline: pipeline) }
- it 'does not expand environment name' do
+ it "does not expand environment name" do
expect(build).not_to receive(:expanded_environment_name)
subject
end
end
- context 'when build has a stop environment' do
+ context "when build has a stop environment" do
let(:build) { create(:ci_build, :stop_review_app, pipeline: pipeline) }
- it 'expands environment name' do
+ it "expands environment name" do
expect(build).to receive(:expanded_environment_name)
subject
@@ -1867,109 +1867,109 @@ describe Ci::Build do
end
end
- describe '#play' do
+ describe "#play" do
let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
before do
project.add_developer(user)
end
- it 'enqueues the build' do
+ it "enqueues the build" do
expect(build.play(user)).to be_pending
end
end
- describe '#playable?' do
- context 'when build is a manual action' do
- context 'when build has been skipped' do
+ describe "#playable?" do
+ context "when build is a manual action" do
+ context "when build has been skipped" do
subject { build_stubbed(:ci_build, :manual, status: :skipped) }
it { is_expected.not_to be_playable }
end
- context 'when build has been canceled' do
+ context "when build has been canceled" do
subject { build_stubbed(:ci_build, :manual, status: :canceled) }
it { is_expected.to be_playable }
end
- context 'when build is successful' do
+ context "when build is successful" do
subject { build_stubbed(:ci_build, :manual, status: :success) }
it { is_expected.to be_playable }
end
- context 'when build has failed' do
+ context "when build has failed" do
subject { build_stubbed(:ci_build, :manual, status: :failed) }
it { is_expected.to be_playable }
end
- context 'when build is a manual untriggered action' do
+ context "when build is a manual untriggered action" do
subject { build_stubbed(:ci_build, :manual, status: :manual) }
it { is_expected.to be_playable }
end
- context 'when build is a manual and degenerated' do
+ context "when build is a manual and degenerated" do
subject { build_stubbed(:ci_build, :manual, :degenerated, status: :manual) }
it { is_expected.not_to be_playable }
end
end
- context 'when build is scheduled' do
+ context "when build is scheduled" do
subject { build_stubbed(:ci_build, :scheduled) }
it { is_expected.to be_playable }
end
- context 'when build is not a manual action' do
+ context "when build is not a manual action" do
subject { build_stubbed(:ci_build, :success) }
it { is_expected.not_to be_playable }
end
end
- describe 'project settings' do
- describe '#allow_git_fetch' do
- it 'return project allow_git_fetch configuration' do
+ describe "project settings" do
+ describe "#allow_git_fetch" do
+ it "return project allow_git_fetch configuration" do
expect(build.allow_git_fetch).to eq(project.build_allow_git_fetch)
end
end
end
- describe '#project' do
+ describe "#project" do
subject { build.project }
it { is_expected.to eq(pipeline.project) }
end
- describe '#project_id' do
+ describe "#project_id" do
subject { build.project_id }
it { is_expected.to eq(pipeline.project_id) }
end
- describe '#project_name' do
+ describe "#project_name" do
subject { build.project_name }
it { is_expected.to eq(project.name) }
end
- describe '#ref_slug' do
+ describe "#ref_slug" do
{
- 'master' => 'master',
- '1-foo' => '1-foo',
- 'fix/1-foo' => 'fix-1-foo',
- 'fix-1-foo' => 'fix-1-foo',
- 'a' * 63 => 'a' * 63,
- 'a' * 64 => 'a' * 63,
- 'FOO' => 'foo',
- '-' + 'a' * 61 + '-' => 'a' * 61,
- '-' + 'a' * 62 + '-' => 'a' * 62,
- '-' + 'a' * 63 + '-' => 'a' * 62,
- 'a' * 62 + ' ' => 'a' * 62
+ "master" => "master",
+ "1-foo" => "1-foo",
+ "fix/1-foo" => "fix-1-foo",
+ "fix-1-foo" => "fix-1-foo",
+ "a" * 63 => "a" * 63,
+ "a" * 64 => "a" * 63,
+ "FOO" => "foo",
+ "-" + "a" * 61 + "-" => "a" * 61,
+ "-" + "a" * 62 + "-" => "a" * 62,
+ "-" + "a" * 63 + "-" => "a" * 62,
+ "a" * 62 + " " => "a" * 62,
}.each do |ref, slug|
it "transforms #{ref} to #{slug}" do
build.ref = ref
@@ -1979,10 +1979,10 @@ describe Ci::Build do
end
end
- describe '#repo_url' do
+ describe "#repo_url" do
subject { build.repo_url }
- context 'when token is set' do
+ context "when token is set" do
before do
build.ensure_token
end
@@ -1991,11 +1991,11 @@ describe Ci::Build do
it { is_expected.to end_with(".git") }
it { is_expected.to start_with(project.web_url[0..6]) }
it { is_expected.to include(build.token) }
- it { is_expected.to include('gitlab-ci-token') }
+ it { is_expected.to include("gitlab-ci-token") }
it { is_expected.to include(project.web_url[7..-1]) }
end
- context 'when token is empty' do
+ context "when token is empty" do
before do
build.update_columns(token: nil, token_encrypted: nil)
end
@@ -2004,12 +2004,12 @@ describe Ci::Build do
end
end
- describe '#stuck?' do
+ describe "#stuck?" do
subject { build.stuck? }
context "when commit_status.status is pending" do
before do
- build.status = 'pending'
+ build.status = "pending"
end
it { is_expected.to be_truthy }
@@ -2032,32 +2032,32 @@ describe Ci::Build do
end
end
- describe '#has_expiring_artifacts?' do
- context 'when artifacts have expiration date set' do
+ describe "#has_expiring_artifacts?" do
+ context "when artifacts have expiration date set" do
before do
build.update(artifacts_expire_at: 1.day.from_now)
end
- it 'has expiring artifacts' do
+ it "has expiring artifacts" do
expect(build).to have_expiring_artifacts
end
end
- context 'when artifacts do not have expiration date set' do
+ context "when artifacts do not have expiration date set" do
before do
build.update(artifacts_expire_at: nil)
end
- it 'does not have expiring artifacts' do
+ it "does not have expiring artifacts" do
expect(build).not_to have_expiring_artifacts
end
end
end
- context 'when updating the build' do
+ context "when updating the build" do
let(:build) { create(:ci_build, artifacts_size: 23) }
- it 'updates project statistics' do
+ it "updates project statistics" do
build.artifacts_size = 42
expect(build).to receive(:update_project_statistics_after_save).and_call_original
@@ -2067,9 +2067,9 @@ describe Ci::Build do
.by(19)
end
- context 'when the artifact size stays the same' do
- it 'does not update project statistics' do
- build.name = 'changed'
+ context "when the artifact size stays the same" do
+ it "does not update project statistics" do
+ build.name = "changed"
expect(build).not_to receive(:update_project_statistics_after_save)
@@ -2078,10 +2078,10 @@ describe Ci::Build do
end
end
- context 'when destroying the build' do
+ context "when destroying the build" do
let!(:build) { create(:ci_build, artifacts_size: 23) }
- it 'updates project statistics' do
+ it "updates project statistics" do
expect(ProjectStatistics)
.to receive(:increment_statistic)
.and_call_original
@@ -2091,8 +2091,8 @@ describe Ci::Build do
.by(-23)
end
- context 'when the build is destroyed due to the project being destroyed' do
- it 'does not update the project statistics' do
+ context "when the build is destroyed due to the project being destroyed" do
+ it "does not update the project statistics" do
expect(ProjectStatistics)
.not_to receive(:increment_statistic)
@@ -2102,83 +2102,83 @@ describe Ci::Build do
end
end
- describe '#variables' do
+ describe "#variables" do
let(:container_registry_enabled) { false }
before do
- stub_container_registry_config(enabled: container_registry_enabled, host_port: 'registry.example.com')
+ stub_container_registry_config(enabled: container_registry_enabled, host_port: "registry.example.com")
end
subject { build.variables }
- context 'returns variables' do
+ context "returns variables" do
let(:predefined_variables) do
[
- { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true, masked: false },
- { key: 'CI_PIPELINE_URL', value: project.web_url + "/pipelines/#{pipeline.id}", public: true, masked: false },
- { key: 'CI_JOB_ID', value: build.id.to_s, public: true, masked: false },
- { key: 'CI_JOB_URL', value: project.web_url + "/-/jobs/#{build.id}", public: true, masked: false },
- { key: 'CI_JOB_TOKEN', value: 'my-token', public: false, masked: false },
- { key: 'CI_BUILD_ID', value: build.id.to_s, public: true, masked: false },
- { key: 'CI_BUILD_TOKEN', value: 'my-token', public: false, masked: false },
- { key: 'CI_REGISTRY_USER', value: 'gitlab-ci-token', public: true, masked: false },
- { key: 'CI_REGISTRY_PASSWORD', value: 'my-token', public: false, masked: false },
- { key: 'CI_REPOSITORY_URL', value: build.repo_url, public: false, masked: false },
- { key: 'CI', value: 'true', public: true, masked: false },
- { key: 'GITLAB_CI', value: 'true', public: true, masked: false },
- { key: 'GITLAB_FEATURES', value: project.licensed_features.join(','), public: true, masked: false },
- { key: 'CI_SERVER_NAME', value: 'GitLab', public: true, masked: false },
- { key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true, masked: false },
- { key: 'CI_SERVER_VERSION_MAJOR', value: Gitlab.version_info.major.to_s, public: true, masked: false },
- { key: 'CI_SERVER_VERSION_MINOR', value: Gitlab.version_info.minor.to_s, public: true, masked: false },
- { key: 'CI_SERVER_VERSION_PATCH', value: Gitlab.version_info.patch.to_s, public: true, masked: false },
- { key: 'CI_SERVER_REVISION', value: Gitlab.revision, public: true, masked: false },
- { key: 'CI_JOB_NAME', value: 'test', public: true, masked: false },
- { key: 'CI_JOB_STAGE', value: 'test', public: true, masked: false },
- { key: 'CI_COMMIT_SHA', value: build.sha, public: true, masked: false },
- { key: 'CI_COMMIT_SHORT_SHA', value: build.short_sha, public: true, masked: false },
- { key: 'CI_COMMIT_BEFORE_SHA', value: build.before_sha, public: true, masked: false },
- { key: 'CI_COMMIT_REF_NAME', value: build.ref, public: true, masked: false },
- { key: 'CI_COMMIT_REF_SLUG', value: build.ref_slug, public: true, masked: false },
- { key: 'CI_NODE_TOTAL', value: '1', public: true, masked: false },
- { key: 'CI_BUILD_REF', value: build.sha, public: true, masked: false },
- { key: 'CI_BUILD_BEFORE_SHA', value: build.before_sha, public: true, masked: false },
- { key: 'CI_BUILD_REF_NAME', value: build.ref, public: true, masked: false },
- { key: 'CI_BUILD_REF_SLUG', value: build.ref_slug, public: true, masked: false },
- { key: 'CI_BUILD_NAME', value: 'test', public: true, masked: false },
- { key: 'CI_BUILD_STAGE', value: 'test', public: true, masked: false },
- { key: 'CI_PROJECT_ID', value: project.id.to_s, public: true, masked: false },
- { key: 'CI_PROJECT_NAME', value: project.path, public: true, masked: false },
- { key: 'CI_PROJECT_PATH', value: project.full_path, public: true, masked: false },
- { key: 'CI_PROJECT_PATH_SLUG', value: project.full_path_slug, public: true, masked: false },
- { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true, masked: false },
- { key: 'CI_PROJECT_URL', value: project.web_url, public: true, masked: false },
- { key: 'CI_PROJECT_VISIBILITY', value: 'private', public: true, masked: false },
- { key: 'CI_PAGES_DOMAIN', value: Gitlab.config.pages.host, public: true, masked: false },
- { key: 'CI_PAGES_URL', value: project.pages_url, public: true, masked: false },
- { key: 'CI_API_V4_URL', value: 'http://localhost/api/v4', public: true, masked: false },
- { key: 'CI_PIPELINE_IID', value: pipeline.iid.to_s, public: true, masked: false },
- { key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, public: true, masked: false },
- { key: 'CI_PIPELINE_SOURCE', value: pipeline.source, public: true, masked: false },
- { key: 'CI_COMMIT_MESSAGE', value: pipeline.git_commit_message, public: true, masked: false },
- { key: 'CI_COMMIT_TITLE', value: pipeline.git_commit_title, public: true, masked: false },
- { key: 'CI_COMMIT_DESCRIPTION', value: pipeline.git_commit_description, public: true, masked: false }
+ {key: "CI_PIPELINE_ID", value: pipeline.id.to_s, public: true, masked: false},
+ {key: "CI_PIPELINE_URL", value: project.web_url + "/pipelines/#{pipeline.id}", public: true, masked: false},
+ {key: "CI_JOB_ID", value: build.id.to_s, public: true, masked: false},
+ {key: "CI_JOB_URL", value: project.web_url + "/-/jobs/#{build.id}", public: true, masked: false},
+ {key: "CI_JOB_TOKEN", value: "my-token", public: false, masked: false},
+ {key: "CI_BUILD_ID", value: build.id.to_s, public: true, masked: false},
+ {key: "CI_BUILD_TOKEN", value: "my-token", public: false, masked: false},
+ {key: "CI_REGISTRY_USER", value: "gitlab-ci-token", public: true, masked: false},
+ {key: "CI_REGISTRY_PASSWORD", value: "my-token", public: false, masked: false},
+ {key: "CI_REPOSITORY_URL", value: build.repo_url, public: false, masked: false},
+ {key: "CI", value: "true", public: true, masked: false},
+ {key: "GITLAB_CI", value: "true", public: true, masked: false},
+ {key: "GITLAB_FEATURES", value: project.licensed_features.join(","), public: true, masked: false},
+ {key: "CI_SERVER_NAME", value: "GitLab", public: true, masked: false},
+ {key: "CI_SERVER_VERSION", value: Gitlab::VERSION, public: true, masked: false},
+ {key: "CI_SERVER_VERSION_MAJOR", value: Gitlab.version_info.major.to_s, public: true, masked: false},
+ {key: "CI_SERVER_VERSION_MINOR", value: Gitlab.version_info.minor.to_s, public: true, masked: false},
+ {key: "CI_SERVER_VERSION_PATCH", value: Gitlab.version_info.patch.to_s, public: true, masked: false},
+ {key: "CI_SERVER_REVISION", value: Gitlab.revision, public: true, masked: false},
+ {key: "CI_JOB_NAME", value: "test", public: true, masked: false},
+ {key: "CI_JOB_STAGE", value: "test", public: true, masked: false},
+ {key: "CI_COMMIT_SHA", value: build.sha, public: true, masked: false},
+ {key: "CI_COMMIT_SHORT_SHA", value: build.short_sha, public: true, masked: false},
+ {key: "CI_COMMIT_BEFORE_SHA", value: build.before_sha, public: true, masked: false},
+ {key: "CI_COMMIT_REF_NAME", value: build.ref, public: true, masked: false},
+ {key: "CI_COMMIT_REF_SLUG", value: build.ref_slug, public: true, masked: false},
+ {key: "CI_NODE_TOTAL", value: "1", public: true, masked: false},
+ {key: "CI_BUILD_REF", value: build.sha, public: true, masked: false},
+ {key: "CI_BUILD_BEFORE_SHA", value: build.before_sha, public: true, masked: false},
+ {key: "CI_BUILD_REF_NAME", value: build.ref, public: true, masked: false},
+ {key: "CI_BUILD_REF_SLUG", value: build.ref_slug, public: true, masked: false},
+ {key: "CI_BUILD_NAME", value: "test", public: true, masked: false},
+ {key: "CI_BUILD_STAGE", value: "test", public: true, masked: false},
+ {key: "CI_PROJECT_ID", value: project.id.to_s, public: true, masked: false},
+ {key: "CI_PROJECT_NAME", value: project.path, public: true, masked: false},
+ {key: "CI_PROJECT_PATH", value: project.full_path, public: true, masked: false},
+ {key: "CI_PROJECT_PATH_SLUG", value: project.full_path_slug, public: true, masked: false},
+ {key: "CI_PROJECT_NAMESPACE", value: project.namespace.full_path, public: true, masked: false},
+ {key: "CI_PROJECT_URL", value: project.web_url, public: true, masked: false},
+ {key: "CI_PROJECT_VISIBILITY", value: "private", public: true, masked: false},
+ {key: "CI_PAGES_DOMAIN", value: Gitlab.config.pages.host, public: true, masked: false},
+ {key: "CI_PAGES_URL", value: project.pages_url, public: true, masked: false},
+ {key: "CI_API_V4_URL", value: "http://localhost/api/v4", public: true, masked: false},
+ {key: "CI_PIPELINE_IID", value: pipeline.iid.to_s, public: true, masked: false},
+ {key: "CI_CONFIG_PATH", value: pipeline.ci_yaml_file_path, public: true, masked: false},
+ {key: "CI_PIPELINE_SOURCE", value: pipeline.source, public: true, masked: false},
+ {key: "CI_COMMIT_MESSAGE", value: pipeline.git_commit_message, public: true, masked: false},
+ {key: "CI_COMMIT_TITLE", value: pipeline.git_commit_title, public: true, masked: false},
+ {key: "CI_COMMIT_DESCRIPTION", value: pipeline.git_commit_description, public: true, masked: false},
]
end
before do
- build.set_token('my-token')
+ build.set_token("my-token")
build.yaml_variables = []
end
it { is_expected.to include(*predefined_variables) }
- describe 'variables ordering' do
- context 'when variables hierarchy is stubbed' do
- let(:build_pre_var) { { key: 'build', value: 'value', public: true, masked: false } }
- let(:project_pre_var) { { key: 'project', value: 'value', public: true, masked: false } }
- let(:pipeline_pre_var) { { key: 'pipeline', value: 'value', public: true, masked: false } }
- let(:build_yaml_var) { { key: 'yaml', value: 'value', public: true, masked: false } }
+ describe "variables ordering" do
+ context "when variables hierarchy is stubbed" do
+ let(:build_pre_var) { {key: "build", value: "value", public: true, masked: false} }
+ let(:project_pre_var) { {key: "project", value: "value", public: true, masked: false} }
+ let(:pipeline_pre_var) { {key: "pipeline", value: "value", public: true, masked: false} }
+ let(:build_yaml_var) { {key: "yaml", value: "value", public: true, masked: false} }
before do
allow(build).to receive(:predefined_variables) { [build_pre_var] }
@@ -2188,23 +2188,24 @@ describe Ci::Build do
allow_any_instance_of(Project)
.to receive(:predefined_variables) { [project_pre_var] }
- project.variables.create!(key: 'secret', value: 'value')
+ project.variables.create!(key: "secret", value: "value")
allow_any_instance_of(Ci::Pipeline)
.to receive(:predefined_variables) { [pipeline_pre_var] }
end
- it 'returns variables in order depending on resource hierarchy' do
+ it "returns variables in order depending on resource hierarchy" do
is_expected.to eq(
[build_pre_var,
project_pre_var,
pipeline_pre_var,
build_yaml_var,
- { key: 'secret', value: 'value', public: false, masked: false }])
+ {key: "secret", value: "value", public: false, masked: false},]
+ )
end
end
- context 'when build has environment and user-provided variables' do
+ context "when build has environment and user-provided variables" do
let(:expected_variables) do
predefined_variables.map { |variable| variable.fetch(:key) } +
%w[YAML_VARIABLE CI_ENVIRONMENT_NAME CI_ENVIRONMENT_SLUG
@@ -2213,15 +2214,15 @@ describe Ci::Build do
before do
create(:environment, project: build.project,
- name: 'staging')
+ name: "staging")
- build.yaml_variables = [{ key: 'YAML_VARIABLE',
- value: 'var',
- public: true }]
- build.environment = 'staging'
+ build.yaml_variables = [{key: "YAML_VARIABLE",
+ value: "var",
+ public: true,}]
+ build.environment = "staging"
end
- it 'matches explicit variables ordering' do
+ it "matches explicit variables ordering" do
received_variables = subject.map { |variable| variable.fetch(:key) }
expect(received_variables).to eq expected_variables
@@ -2230,13 +2231,13 @@ describe Ci::Build do
end
end
- context 'when build has user' do
+ context "when build has user" do
let(:user_variables) do
[
- { key: 'GITLAB_USER_ID', value: user.id.to_s, public: true, masked: false },
- { key: 'GITLAB_USER_EMAIL', value: user.email, public: true, masked: false },
- { key: 'GITLAB_USER_LOGIN', value: user.username, public: true, masked: false },
- { key: 'GITLAB_USER_NAME', value: user.name, public: true, masked: false }
+ {key: "GITLAB_USER_ID", value: user.id.to_s, public: true, masked: false},
+ {key: "GITLAB_USER_EMAIL", value: user.email, public: true, masked: false},
+ {key: "GITLAB_USER_LOGIN", value: user.username, public: true, masked: false},
+ {key: "GITLAB_USER_NAME", value: user.name, public: true, masked: false},
]
end
@@ -2247,91 +2248,91 @@ describe Ci::Build do
it { user_variables.each { |v| is_expected.to include(v) } }
end
- context 'when build has an environment' do
+ context "when build has an environment" do
let(:environment_variables) do
[
- { key: 'CI_ENVIRONMENT_NAME', value: 'production', public: true, masked: false },
- { key: 'CI_ENVIRONMENT_SLUG', value: 'prod-slug', public: true, masked: false }
+ {key: "CI_ENVIRONMENT_NAME", value: "production", public: true, masked: false},
+ {key: "CI_ENVIRONMENT_SLUG", value: "prod-slug", public: true, masked: false},
]
end
let!(:environment) do
create(:environment,
- project: build.project,
- name: 'production',
- slug: 'prod-slug',
- external_url: '')
+ project: build.project,
+ name: "production",
+ slug: "prod-slug",
+ external_url: "")
end
before do
- build.update(environment: 'production')
+ build.update(environment: "production")
end
- shared_examples 'containing environment variables' do
+ shared_examples "containing environment variables" do
it { environment_variables.each { |v| is_expected.to include(v) } }
end
- context 'when no URL was set' do
- it_behaves_like 'containing environment variables'
+ context "when no URL was set" do
+ it_behaves_like "containing environment variables"
- it 'does not have CI_ENVIRONMENT_URL' do
+ it "does not have CI_ENVIRONMENT_URL" do
keys = subject.map { |var| var[:key] }
- expect(keys).not_to include('CI_ENVIRONMENT_URL')
+ expect(keys).not_to include("CI_ENVIRONMENT_URL")
end
end
- context 'when an URL was set' do
- let(:url) { 'http://host/test' }
+ context "when an URL was set" do
+ let(:url) { "http://host/test" }
before do
environment_variables <<
- { key: 'CI_ENVIRONMENT_URL', value: url, public: true, masked: false }
+ {key: "CI_ENVIRONMENT_URL", value: url, public: true, masked: false}
end
- context 'when the URL was set from the job' do
+ context "when the URL was set from the job" do
before do
- build.update(options: { environment: { url: url } })
+ build.update(options: {environment: {url: url}})
end
- it_behaves_like 'containing environment variables'
+ it_behaves_like "containing environment variables"
- context 'when variables are used in the URL, it does not expand' do
- let(:url) { 'http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG' }
+ context "when variables are used in the URL, it does not expand" do
+ let(:url) { "http://$CI_PROJECT_NAME-$CI_ENVIRONMENT_SLUG" }
- it_behaves_like 'containing environment variables'
+ it_behaves_like "containing environment variables"
- it 'puts $CI_ENVIRONMENT_URL in the last so all other variables are available to be used when runners are trying to expand it' do
+ it "puts $CI_ENVIRONMENT_URL in the last so all other variables are available to be used when runners are trying to expand it" do
expect(subject.last).to eq(environment_variables.last)
end
end
end
- context 'when the URL was not set from the job, but environment' do
+ context "when the URL was not set from the job, but environment" do
before do
environment.update(external_url: url)
end
- it_behaves_like 'containing environment variables'
+ it_behaves_like "containing environment variables"
end
end
end
- context 'when build started manually' do
+ context "when build started manually" do
before do
build.update(when: :manual)
end
let(:manual_variable) do
- { key: 'CI_JOB_MANUAL', value: 'true', public: true, masked: false }
+ {key: "CI_JOB_MANUAL", value: "true", public: true, masked: false}
end
it { is_expected.to include(manual_variable) }
end
- context 'when build is for tag' do
+ context "when build is for tag" do
let(:tag_variable) do
- { key: 'CI_COMMIT_TAG', value: 'master', public: true, masked: false }
+ {key: "CI_COMMIT_TAG", value: "master", public: true, masked: false}
end
before do
@@ -2341,33 +2342,33 @@ describe Ci::Build do
it { is_expected.to include(tag_variable) }
end
- context 'when CI variable is defined' do
+ context "when CI variable is defined" do
let(:ci_variable) do
- { key: 'SECRET_KEY', value: 'secret_value', public: false, masked: false }
+ {key: "SECRET_KEY", value: "secret_value", public: false, masked: false}
end
before do
create(:ci_variable,
- ci_variable.slice(:key, :value).merge(project: project))
+ ci_variable.slice(:key, :value).merge(project: project))
end
it { is_expected.to include(ci_variable) }
end
- context 'when protected variable is defined' do
+ context "when protected variable is defined" do
let(:ref) { Gitlab::Git::BRANCH_REF_PREFIX + build.ref }
let(:protected_variable) do
- { key: 'PROTECTED_KEY', value: 'protected_value', public: false, masked: false }
+ {key: "PROTECTED_KEY", value: "protected_value", public: false, masked: false}
end
before do
create(:ci_variable,
- :protected,
- protected_variable.slice(:key, :value).merge(project: project))
+ :protected,
+ protected_variable.slice(:key, :value).merge(project: project))
end
- context 'when the branch is protected' do
+ context "when the branch is protected" do
before do
allow(build.project).to receive(:protected_for?).with(ref).and_return(true)
end
@@ -2375,7 +2376,7 @@ describe Ci::Build do
it { is_expected.to include(protected_variable) }
end
- context 'when the tag is protected' do
+ context "when the tag is protected" do
before do
allow(build.project).to receive(:protected_for?).with(ref).and_return(true)
end
@@ -2383,38 +2384,38 @@ describe Ci::Build do
it { is_expected.to include(protected_variable) }
end
- context 'when the ref is not protected' do
+ context "when the ref is not protected" do
it { is_expected.not_to include(protected_variable) }
end
end
- context 'when group CI variable is defined' do
+ context "when group CI variable is defined" do
let(:ci_variable) do
- { key: 'SECRET_KEY', value: 'secret_value', public: false, masked: false }
+ {key: "SECRET_KEY", value: "secret_value", public: false, masked: false}
end
before do
create(:ci_group_variable,
- ci_variable.slice(:key, :value).merge(group: group))
+ ci_variable.slice(:key, :value).merge(group: group))
end
it { is_expected.to include(ci_variable) }
end
- context 'when group protected variable is defined' do
+ context "when group protected variable is defined" do
let(:ref) { Gitlab::Git::BRANCH_REF_PREFIX + build.ref }
let(:protected_variable) do
- { key: 'PROTECTED_KEY', value: 'protected_value', public: false, masked: false }
+ {key: "PROTECTED_KEY", value: "protected_value", public: false, masked: false}
end
before do
create(:ci_group_variable,
- :protected,
- protected_variable.slice(:key, :value).merge(group: group))
+ :protected,
+ protected_variable.slice(:key, :value).merge(group: group))
end
- context 'when the branch is protected' do
+ context "when the branch is protected" do
before do
allow(build.project).to receive(:protected_for?).with(ref).and_return(true)
end
@@ -2422,7 +2423,7 @@ describe Ci::Build do
it { is_expected.to include(protected_variable) }
end
- context 'when the tag is protected' do
+ context "when the tag is protected" do
before do
allow(build.project).to receive(:protected_for?).with(ref).and_return(true)
end
@@ -2430,66 +2431,66 @@ describe Ci::Build do
it { is_expected.to include(protected_variable) }
end
- context 'when the ref is not protected' do
+ context "when the ref is not protected" do
before do
- build.update_column(:ref, 'some/feature')
+ build.update_column(:ref, "some/feature")
end
it { is_expected.not_to include(protected_variable) }
end
end
- context 'when build is for triggers' do
+ context "when build is for triggers" do
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, trigger: trigger) }
let(:user_trigger_variable) do
- { key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1', public: false, masked: false }
+ {key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1", public: false, masked: false}
end
let(:predefined_trigger_variable) do
- { key: 'CI_PIPELINE_TRIGGERED', value: 'true', public: true, masked: false }
+ {key: "CI_PIPELINE_TRIGGERED", value: "true", public: true, masked: false}
end
before do
build.trigger_request = trigger_request
end
- shared_examples 'returns variables for triggers' do
+ shared_examples "returns variables for triggers" do
it { is_expected.to include(user_trigger_variable) }
it { is_expected.to include(predefined_trigger_variable) }
end
- context 'when variables are stored in trigger_request' do
+ context "when variables are stored in trigger_request" do
before do
- trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } )
+ trigger_request.update_attribute(:variables, {"TRIGGER_KEY_1" => "TRIGGER_VALUE_1"})
end
- it_behaves_like 'returns variables for triggers'
+ it_behaves_like "returns variables for triggers"
end
- context 'when variables are stored in pipeline_variables' do
+ context "when variables are stored in pipeline_variables" do
before do
- create(:ci_pipeline_variable, pipeline: pipeline, key: 'TRIGGER_KEY_1', value: 'TRIGGER_VALUE_1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: "TRIGGER_KEY_1", value: "TRIGGER_VALUE_1")
end
- it_behaves_like 'returns variables for triggers'
+ it_behaves_like "returns variables for triggers"
end
end
- context 'when pipeline has a variable' do
+ context "when pipeline has a variable" do
let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline) }
it { is_expected.to include(key: pipeline_variable.key, value: pipeline_variable.value, public: false, masked: false) }
end
- context 'when a job was triggered by a pipeline schedule' do
+ context "when a job was triggered by a pipeline schedule" do
let(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project) }
let!(:pipeline_schedule_variable) do
create(:ci_pipeline_schedule_variable,
- key: 'SCHEDULE_VARIABLE_KEY',
- pipeline_schedule: pipeline_schedule)
+ key: "SCHEDULE_VARIABLE_KEY",
+ pipeline_schedule: pipeline_schedule)
end
before do
@@ -2500,16 +2501,16 @@ describe Ci::Build do
it { is_expected.to include(key: pipeline_schedule_variable.key, value: pipeline_schedule_variable.value, public: false, masked: false) }
end
- context 'when container registry is enabled' do
+ context "when container registry is enabled" do
let(:container_registry_enabled) { true }
let(:ci_registry) do
- { key: 'CI_REGISTRY', value: 'registry.example.com', public: true, masked: false }
+ {key: "CI_REGISTRY", value: "registry.example.com", public: true, masked: false}
end
let(:ci_registry_image) do
- { key: 'CI_REGISTRY_IMAGE', value: project.container_registry_url, public: true, masked: false }
+ {key: "CI_REGISTRY_IMAGE", value: project.container_registry_url, public: true, masked: false}
end
- context 'and is disabled for project' do
+ context "and is disabled for project" do
before do
project.update(container_registry_enabled: false)
end
@@ -2518,7 +2519,7 @@ describe Ci::Build do
it { is_expected.not_to include(ci_registry_image) }
end
- context 'and is enabled for project' do
+ context "and is enabled for project" do
before do
project.update(container_registry_enabled: true)
end
@@ -2528,23 +2529,23 @@ describe Ci::Build do
end
end
- context 'when runner is assigned to build' do
- let(:runner) { create(:ci_runner, description: 'description', tag_list: %w(docker linux)) }
+ context "when runner is assigned to build" do
+ let(:runner) { create(:ci_runner, description: "description", tag_list: %w[docker linux]) }
before do
build.update(runner: runner)
end
- it { is_expected.to include({ key: 'CI_RUNNER_ID', value: runner.id.to_s, public: true, masked: false }) }
- it { is_expected.to include({ key: 'CI_RUNNER_DESCRIPTION', value: 'description', public: true, masked: false }) }
- it { is_expected.to include({ key: 'CI_RUNNER_TAGS', value: 'docker, linux', public: true, masked: false }) }
+ it { is_expected.to include({key: "CI_RUNNER_ID", value: runner.id.to_s, public: true, masked: false}) }
+ it { is_expected.to include({key: "CI_RUNNER_DESCRIPTION", value: "description", public: true, masked: false}) }
+ it { is_expected.to include({key: "CI_RUNNER_TAGS", value: "docker, linux", public: true, masked: false}) }
end
- context 'when build is for a deployment' do
- let(:deployment_variable) { { key: 'KUBERNETES_TOKEN', value: 'TOKEN', public: false, masked: false } }
+ context "when build is for a deployment" do
+ let(:deployment_variable) { {key: "KUBERNETES_TOKEN", value: "TOKEN", public: false, masked: false} }
before do
- build.environment = 'production'
+ build.environment = "production"
allow_any_instance_of(Project)
.to receive(:deployment_variables)
@@ -2554,57 +2555,59 @@ describe Ci::Build do
it { is_expected.to include(deployment_variable) }
end
- context 'when project has custom CI config path' do
- let(:ci_config_path) { { key: 'CI_CONFIG_PATH', value: 'custom', public: true, masked: false } }
+ context "when project has custom CI config path" do
+ let(:ci_config_path) { {key: "CI_CONFIG_PATH", value: "custom", public: true, masked: false} }
before do
- project.update(ci_config_path: 'custom')
+ project.update(ci_config_path: "custom")
end
it { is_expected.to include(ci_config_path) }
end
- context 'when using auto devops' do
- context 'and is enabled' do
+ context "when using auto devops" do
+ context "and is enabled" do
before do
- project.create_auto_devops!(enabled: true, domain: 'example.com')
+ project.create_auto_devops!(enabled: true, domain: "example.com")
end
it "includes AUTO_DEVOPS_DOMAIN" do
is_expected.to include(
- { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true, masked: false })
+ {key: "AUTO_DEVOPS_DOMAIN", value: "example.com", public: true, masked: false}
+ )
end
end
- context 'and is disabled' do
+ context "and is disabled" do
before do
- project.create_auto_devops!(enabled: false, domain: 'example.com')
+ project.create_auto_devops!(enabled: false, domain: "example.com")
end
it "includes AUTO_DEVOPS_DOMAIN" do
is_expected.not_to include(
- { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true, masked: false })
+ {key: "AUTO_DEVOPS_DOMAIN", value: "example.com", public: true, masked: false}
+ )
end
end
end
- context 'when pipeline variable overrides build variable' do
+ context "when pipeline variable overrides build variable" do
before do
- build.yaml_variables = [{ key: 'MYVAR', value: 'myvar', public: true }]
- pipeline.variables.build(key: 'MYVAR', value: 'pipeline value')
+ build.yaml_variables = [{key: "MYVAR", value: "myvar", public: true}]
+ pipeline.variables.build(key: "MYVAR", value: "pipeline value")
end
- it 'overrides YAML variable using a pipeline variable' do
+ it "overrides YAML variable using a pipeline variable" do
variables = subject.reverse.uniq { |variable| variable[:key] }.reverse
expect(variables)
- .not_to include(key: 'MYVAR', value: 'myvar', public: true, masked: false)
+ .not_to include(key: "MYVAR", value: "myvar", public: true, masked: false)
expect(variables)
- .to include(key: 'MYVAR', value: 'pipeline value', public: false, masked: false)
+ .to include(key: "MYVAR", value: "pipeline value", public: false, masked: false)
end
end
- context 'when build is parallelized' do
+ context "when build is parallelized" do
let(:total) { 5 }
let(:index) { 3 }
@@ -2614,80 +2617,80 @@ describe Ci::Build do
build.name = "#{build.name} #{index}/#{total}"
end
- it 'includes CI_NODE_INDEX' do
+ it "includes CI_NODE_INDEX" do
is_expected.to include(
- { key: 'CI_NODE_INDEX', value: index.to_s, public: true, masked: false }
+ {key: "CI_NODE_INDEX", value: index.to_s, public: true, masked: false}
)
end
- it 'includes correct CI_NODE_TOTAL' do
+ it "includes correct CI_NODE_TOTAL" do
is_expected.to include(
- { key: 'CI_NODE_TOTAL', value: total.to_s, public: true, masked: false }
+ {key: "CI_NODE_TOTAL", value: total.to_s, public: true, masked: false}
)
end
end
- context 'when build has not been persisted yet' do
+ context "when build has not been persisted yet" do
let(:build) do
described_class.new(
- name: 'rspec',
- stage: 'test',
- ref: 'feature',
+ name: "rspec",
+ stage: "test",
+ ref: "feature",
project: project,
pipeline: pipeline
)
end
- it 'returns static predefined variables' do
+ it "returns static predefined variables" do
expect(build.variables.size).to be >= 28
expect(build.variables)
- .to include(key: 'CI_COMMIT_REF_NAME', value: 'feature', public: true, masked: false)
+ .to include(key: "CI_COMMIT_REF_NAME", value: "feature", public: true, masked: false)
expect(build).not_to be_persisted
end
end
- context 'for deploy tokens' do
+ context "for deploy tokens" do
let(:deploy_token) { create(:deploy_token, :gitlab_deploy_token) }
let(:deploy_token_variables) do
[
- { key: 'CI_DEPLOY_USER', value: deploy_token.username, public: true, masked: false },
- { key: 'CI_DEPLOY_PASSWORD', value: deploy_token.token, public: false, masked: false }
+ {key: "CI_DEPLOY_USER", value: deploy_token.username, public: true, masked: false},
+ {key: "CI_DEPLOY_PASSWORD", value: deploy_token.token, public: false, masked: false},
]
end
- context 'when gitlab-deploy-token exists' do
+ context "when gitlab-deploy-token exists" do
before do
project.deploy_tokens << deploy_token
end
- it 'should include deploy token variables' do
+ it "should include deploy token variables" do
is_expected.to include(*deploy_token_variables)
end
end
- context 'when gitlab-deploy-token does not exist' do
- it 'should not include deploy token variables' do
- expect(subject.find { |v| v[:key] == 'CI_DEPLOY_USER'}).to be_nil
- expect(subject.find { |v| v[:key] == 'CI_DEPLOY_PASSWORD'}).to be_nil
+ context "when gitlab-deploy-token does not exist" do
+ it "should not include deploy token variables" do
+ expect(subject.find { |v| v[:key] == "CI_DEPLOY_USER"}).to be_nil
+ expect(subject.find { |v| v[:key] == "CI_DEPLOY_PASSWORD"}).to be_nil
end
end
end
end
- describe '#scoped_variables' do
- context 'when build has not been persisted yet' do
+ describe "#scoped_variables" do
+ context "when build has not been persisted yet" do
let(:build) do
described_class.new(
- name: 'rspec',
- stage: 'test',
- ref: 'feature',
+ name: "rspec",
+ stage: "test",
+ ref: "feature",
project: project,
pipeline: pipeline
)
end
- it 'does not persist the build' do
+ it "does not persist the build" do
expect(build).to be_valid
expect(build).not_to be_persisted
@@ -2696,7 +2699,7 @@ describe Ci::Build do
expect(build).not_to be_persisted
end
- it 'returns static predefined variables' do
+ it "returns static predefined variables" do
keys = %w[CI_JOB_NAME
CI_COMMIT_SHA
CI_COMMIT_SHORT_SHA
@@ -2711,10 +2714,10 @@ describe Ci::Build do
end
expect(variables)
- .to include(key: 'CI_COMMIT_REF_NAME', value: 'feature', public: true, masked: false)
+ .to include(key: "CI_COMMIT_REF_NAME", value: "feature", public: true, masked: false)
end
- it 'does not return prohibited variables' do
+ it "does not return prohibited variables" do
keys = %w[CI_JOB_ID
CI_JOB_URL
CI_JOB_TOKEN
@@ -2734,95 +2737,95 @@ describe Ci::Build do
end
end
- describe '#scoped_variables_hash' do
- context 'when overriding CI variables' do
+ describe "#scoped_variables_hash" do
+ context "when overriding CI variables" do
before do
- project.variables.create!(key: 'MY_VAR', value: 'my value 1')
- pipeline.variables.create!(key: 'MY_VAR', value: 'my value 2')
+ project.variables.create!(key: "MY_VAR", value: "my value 1")
+ pipeline.variables.create!(key: "MY_VAR", value: "my value 2")
end
- it 'returns a regular hash created using valid ordering' do
- expect(build.scoped_variables_hash).to include('MY_VAR': 'my value 2')
- expect(build.scoped_variables_hash).not_to include('MY_VAR': 'my value 1')
+ it "returns a regular hash created using valid ordering" do
+ expect(build.scoped_variables_hash).to include('MY_VAR': "my value 2")
+ expect(build.scoped_variables_hash).not_to include('MY_VAR': "my value 1")
end
end
- context 'when overriding user-provided variables' do
+ context "when overriding user-provided variables" do
before do
- pipeline.variables.build(key: 'MY_VAR', value: 'pipeline value')
- build.yaml_variables = [{ key: 'MY_VAR', value: 'myvar', public: true }]
+ pipeline.variables.build(key: "MY_VAR", value: "pipeline value")
+ build.yaml_variables = [{key: "MY_VAR", value: "myvar", public: true}]
end
- it 'returns a hash including variable with higher precedence' do
- expect(build.scoped_variables_hash).to include('MY_VAR': 'pipeline value')
- expect(build.scoped_variables_hash).not_to include('MY_VAR': 'myvar')
+ it "returns a hash including variable with higher precedence" do
+ expect(build.scoped_variables_hash).to include('MY_VAR': "pipeline value")
+ expect(build.scoped_variables_hash).not_to include('MY_VAR': "myvar")
end
end
end
- describe '#yaml_variables' do
+ describe "#yaml_variables" do
let(:build) { create(:ci_build, pipeline: pipeline, yaml_variables: variables) }
let(:variables) do
[
- { 'key' => :VARIABLE, 'value' => 'my value' },
- { 'key' => 'VARIABLE2', 'value' => 'my value 2' }
+ {"key" => :VARIABLE, "value" => "my value"},
+ {"key" => "VARIABLE2", "value" => "my value 2"},
]
end
- shared_examples 'having consistent representation' do
- it 'allows to access using symbols' do
- expect(build.reload.yaml_variables.first[:key]).to eq('VARIABLE')
- expect(build.reload.yaml_variables.first[:value]).to eq('my value')
- expect(build.reload.yaml_variables.second[:key]).to eq('VARIABLE2')
- expect(build.reload.yaml_variables.second[:value]).to eq('my value 2')
+ shared_examples "having consistent representation" do
+ it "allows to access using symbols" do
+ expect(build.reload.yaml_variables.first[:key]).to eq("VARIABLE")
+ expect(build.reload.yaml_variables.first[:value]).to eq("my value")
+ expect(build.reload.yaml_variables.second[:key]).to eq("VARIABLE2")
+ expect(build.reload.yaml_variables.second[:value]).to eq("my value 2")
end
end
- context 'when ci_build_metadata_config is set' do
+ context "when ci_build_metadata_config is set" do
before do
stub_feature_flags(ci_build_metadata_config: true)
end
- it_behaves_like 'having consistent representation'
+ it_behaves_like "having consistent representation"
- it 'persist data in build metadata' do
+ it "persist data in build metadata" do
expect(build.metadata.read_attribute(:config_variables)).not_to be_nil
end
- it 'does not persist data in build' do
+ it "does not persist data in build" do
expect(build.read_attribute(:yaml_variables)).to be_nil
end
end
- context 'when ci_build_metadata_config is disabled' do
+ context "when ci_build_metadata_config is disabled" do
before do
stub_feature_flags(ci_build_metadata_config: false)
end
- it_behaves_like 'having consistent representation'
+ it_behaves_like "having consistent representation"
- it 'persist data in build' do
+ it "persist data in build" do
expect(build.read_attribute(:yaml_variables)).not_to be_nil
end
- it 'does not persist data in build metadata' do
+ it "does not persist data in build metadata" do
expect(build.metadata.read_attribute(:config_variables)).to be_nil
end
end
end
- describe 'state transition: any => [:pending]' do
+ describe "state transition: any => [:pending]" do
let(:build) { create(:ci_build, :created) }
- it 'queues BuildQueueWorker' do
+ it "queues BuildQueueWorker" do
expect(BuildQueueWorker).to receive(:perform_async).with(build.id)
build.enqueue
end
end
- describe 'state transition: pending: :running' do
+ describe "state transition: pending: :running" do
let(:runner) { create(:ci_runner) }
let(:job) { create(:ci_build, :pending, runner: runner) }
@@ -2835,16 +2838,16 @@ describe Ci::Build do
rescue StateMachines::InvalidTransition
end
- shared_examples 'saves data on transition' do
- it 'saves timeout' do
+ shared_examples "saves data on transition" do
+ it "saves timeout" do
expect { job.run! }.to change { job.reload.ensure_metadata.timeout }.from(nil).to(expected_timeout)
end
- it 'saves timeout_source' do
- expect { job.run! }.to change { job.reload.ensure_metadata.timeout_source }.from('unknown_timeout_source').to(expected_timeout_source)
+ it "saves timeout_source" do
+ expect { job.run! }.to change { job.reload.ensure_metadata.timeout_source }.from("unknown_timeout_source").to(expected_timeout_source)
end
- context 'when Ci::BuildMetadata#update_timeout_state fails update' do
+ context "when Ci::BuildMetadata#update_timeout_state fails update" do
before do
allow_any_instance_of(Ci::BuildMetadata).to receive(:update_timeout_state).and_return(false)
end
@@ -2859,45 +2862,45 @@ describe Ci::Build do
end
end
- context 'when runner timeout overrides project timeout' do
+ context "when runner timeout overrides project timeout" do
let(:expected_timeout) { 900 }
- let(:expected_timeout_source) { 'runner_timeout_source' }
+ let(:expected_timeout_source) { "runner_timeout_source" }
before do
runner.update_attribute(:maximum_timeout, 900)
end
- it_behaves_like 'saves data on transition'
+ it_behaves_like "saves data on transition"
end
context "when runner timeout doesn't override project timeout" do
let(:expected_timeout) { 1800 }
- let(:expected_timeout_source) { 'project_timeout_source' }
+ let(:expected_timeout_source) { "project_timeout_source" }
before do
runner.update_attribute(:maximum_timeout, 3600)
end
- it_behaves_like 'saves data on transition'
+ it_behaves_like "saves data on transition"
end
end
- describe '#has_valid_build_dependencies?' do
- shared_examples 'validation is active' do
- context 'when depended job has not been completed yet' do
- let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ describe "#has_valid_build_dependencies?" do
+ shared_examples "validation is active" do
+ context "when depended job has not been completed yet" do
+ let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(job).to have_valid_build_dependencies }
end
- context 'when artifacts of depended job has been expired' do
- let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ context "when artifacts of depended job has been expired" do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(job).not_to have_valid_build_dependencies }
end
- context 'when artifacts of depended job has been erased' do
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
+ context "when artifacts of depended job has been erased" do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0, erased_at: 1.minute.ago) }
before do
pre_stage_job.erase
@@ -2907,21 +2910,21 @@ describe Ci::Build do
end
end
- shared_examples 'validation is not active' do
- context 'when depended job has not been completed yet' do
- let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ shared_examples "validation is not active" do
+ context "when depended job has not been completed yet" do
+ let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(job).to have_valid_build_dependencies }
end
- context 'when artifacts of depended job has been expired' do
- let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ context "when artifacts of depended job has been expired" do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(job).to have_valid_build_dependencies }
end
- context 'when artifacts of depended job has been erased' do
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
+ context "when artifacts of depended job has been erased" do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0, erased_at: 1.minute.ago) }
before do
pre_stage_job.erase
@@ -2933,12 +2936,12 @@ describe Ci::Build do
let!(:job) { create(:ci_build, :pending, pipeline: pipeline, stage_idx: 1, options: options) }
- context 'when validates for dependencies is enabled' do
+ context "when validates for dependencies is enabled" do
before do
stub_feature_flags(ci_disable_validates_dependencies: false)
end
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0) }
context 'when "dependencies" keyword is not defined' do
let(:options) { {} }
@@ -2947,30 +2950,30 @@ describe Ci::Build do
end
context 'when "dependencies" keyword is empty' do
- let(:options) { { dependencies: [] } }
+ let(:options) { {dependencies: []} }
it { expect(job).to have_valid_build_dependencies }
end
context 'when "dependencies" keyword is specified' do
- let(:options) { { dependencies: ['test'] } }
+ let(:options) { {dependencies: ["test"]} }
- it_behaves_like 'validation is active'
+ it_behaves_like "validation is active"
end
end
- context 'when validates for dependencies is disabled' do
- let(:options) { { dependencies: ['test'] } }
+ context "when validates for dependencies is disabled" do
+ let(:options) { {dependencies: ["test"]} }
before do
stub_feature_flags(ci_disable_validates_dependencies: true)
end
- it_behaves_like 'validation is not active'
+ it_behaves_like "validation is not active"
end
end
- describe 'state transition when build fails' do
+ describe "state transition when build fails" do
let(:service) { MergeRequests::AddTodoWhenBuildFailsService.new(project, user) }
before do
@@ -2978,17 +2981,17 @@ describe Ci::Build do
allow(service).to receive(:close)
end
- context 'when build is configured to be retried' do
- subject { create(:ci_build, :running, options: { script: ["ls -al"], retry: 3 }, project: project, user: user) }
+ context "when build is configured to be retried" do
+ subject { create(:ci_build, :running, options: {script: ["ls -al"], retry: 3}, project: project, user: user) }
- it 'retries build and assigns the same user to it' do
+ it "retries build and assigns the same user to it" do
expect(described_class).to receive(:retry)
.with(subject, user)
subject.drop!
end
- it 'does not try to create a todo' do
+ it "does not try to create a todo" do
project.add_developer(user)
expect(service).not_to receive(:commit_status_merge_requests)
@@ -2996,7 +2999,7 @@ describe Ci::Build do
subject.drop!
end
- context 'when retry service raises Gitlab::Access::AccessDeniedError exception' do
+ context "when retry service raises Gitlab::Access::AccessDeniedError exception" do
let(:retry_service) { Ci::RetryBuildService.new(subject.project, subject.user) }
before do
@@ -3007,11 +3010,11 @@ describe Ci::Build do
allow(Rails.logger).to receive(:error)
end
- it 'handles raised exception' do
+ it "handles raised exception" do
expect { subject.drop! }.not_to raise_exception(Gitlab::Access::AccessDeniedError)
end
- it 'logs the error' do
+ it "logs the error" do
subject.drop!
expect(Rails.logger)
@@ -3019,23 +3022,23 @@ describe Ci::Build do
.with(a_string_matching("Unable to auto-retry job #{subject.id}"))
end
- it 'fails the job' do
+ it "fails the job" do
subject.drop!
expect(subject.failed?).to be_truthy
end
end
end
- context 'when build is not configured to be retried' do
+ context "when build is not configured to be retried" do
subject { create(:ci_build, :running, project: project, user: user) }
- it 'does not retry build' do
+ it "does not retry build" do
expect(described_class).not_to receive(:retry)
subject.drop!
end
- it 'does not count retries when not necessary' do
+ it "does not count retries when not necessary" do
expect(described_class).not_to receive(:retry)
expect_any_instance_of(described_class)
.not_to receive(:retries_count)
@@ -3043,7 +3046,7 @@ describe Ci::Build do
subject.drop!
end
- it 'creates a todo' do
+ it "creates a todo" do
project.add_developer(user)
expect(service).to receive(:commit_status_merge_requests)
@@ -3052,16 +3055,16 @@ describe Ci::Build do
end
end
- context 'when associated deployment failed to update its status' do
+ context "when associated deployment failed to update its status" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
let!(:deployment) { create(:deployment, deployable: build) }
before do
allow_any_instance_of(Deployment)
- .to receive(:drop!).and_raise('Unexpected error')
+ .to receive(:drop!).and_raise("Unexpected error")
end
- it 'can drop the build' do
+ it "can drop the build" do
expect(Gitlab::Sentry).to receive(:track_exception)
expect { build.drop! }.not_to raise_error
@@ -3071,7 +3074,7 @@ describe Ci::Build do
end
end
- describe '.matches_tag_ids' do
+ describe ".matches_tag_ids" do
set(:build) { create(:ci_build, project: project, user: user) }
let(:tag_ids) { ::ActsAsTaggableOn::Tag.named_any(tag_list).ids }
@@ -3081,36 +3084,36 @@ describe Ci::Build do
build.update(tag_list: build_tag_list)
end
- context 'when have different tags' do
- let(:build_tag_list) { %w(A B) }
- let(:tag_list) { %w(C D) }
+ context "when have different tags" do
+ let(:build_tag_list) { %w[A B] }
+ let(:tag_list) { %w[C D] }
it "does not match a build" do
is_expected.not_to contain_exactly(build)
end
end
- context 'when have a subset of tags' do
- let(:build_tag_list) { %w(A B) }
- let(:tag_list) { %w(A B C D) }
+ context "when have a subset of tags" do
+ let(:build_tag_list) { %w[A B] }
+ let(:tag_list) { %w[A B C D] }
it "does match a build" do
is_expected.to contain_exactly(build)
end
end
- context 'when build does not have tags' do
+ context "when build does not have tags" do
let(:build_tag_list) { [] }
- let(:tag_list) { %w(C D) }
+ let(:tag_list) { %w[C D] }
it "does match a build" do
is_expected.to contain_exactly(build)
end
end
- context 'when does not have a subset of tags' do
- let(:build_tag_list) { %w(A B C) }
- let(:tag_list) { %w(C D) }
+ context "when does not have a subset of tags" do
+ let(:build_tag_list) { %w[A B C] }
+ let(:tag_list) { %w[C D] }
it "does not match a build" do
is_expected.not_to contain_exactly(build)
@@ -3118,7 +3121,7 @@ describe Ci::Build do
end
end
- describe '.matches_tags' do
+ describe ".matches_tags" do
set(:build) { create(:ci_build, project: project, user: user) }
subject { described_class.where(id: build).with_any_tags }
@@ -3127,15 +3130,15 @@ describe Ci::Build do
build.update(tag_list: tag_list)
end
- context 'when does have tags' do
- let(:tag_list) { %w(A B) }
+ context "when does have tags" do
+ let(:tag_list) { %w[A B] }
it "does match a build" do
is_expected.to contain_exactly(build)
end
end
- context 'when does not have tags' do
+ context "when does not have tags" do
let(:tag_list) { [] }
it "does not match a build" do
@@ -3144,24 +3147,24 @@ describe Ci::Build do
end
end
- describe 'pages deployments' do
+ describe "pages deployments" do
set(:build) { create(:ci_build, project: project, user: user) }
context 'when job is "pages"' do
before do
- build.name = 'pages'
+ build.name = "pages"
end
- context 'when pages are enabled' do
+ context "when pages are enabled" do
before do
allow(Gitlab.config.pages).to receive_messages(enabled: true)
end
- it 'is marked as pages generator' do
+ it "is marked as pages generator" do
expect(build).to be_pages_generator
end
- context 'job succeeds' do
+ context "job succeeds" do
it "calls pages worker" do
expect(PagesWorker).to receive(:perform_async).with(:deploy, build.id)
@@ -3169,7 +3172,7 @@ describe Ci::Build do
end
end
- context 'job fails' do
+ context "job fails" do
it "does not call pages worker" do
expect(PagesWorker).not_to receive(:perform_async)
@@ -3178,16 +3181,16 @@ describe Ci::Build do
end
end
- context 'when pages are disabled' do
+ context "when pages are disabled" do
before do
allow(Gitlab.config.pages).to receive_messages(enabled: false)
end
- it 'is not marked as pages generator' do
+ it "is not marked as pages generator" do
expect(build).not_to be_pages_generator
end
- context 'job succeeds' do
+ context "job succeeds" do
it "does not call pages worker" do
expect(PagesWorker).not_to receive(:perform_async)
@@ -3199,14 +3202,14 @@ describe Ci::Build do
context 'when job is not "pages"' do
before do
- build.name = 'other-job'
+ build.name = "other-job"
end
- it 'is not marked as pages generator' do
+ it "is not marked as pages generator" do
expect(build).not_to be_pages_generator
end
- context 'job succeeds' do
+ context "job succeeds" do
it "does not call pages worker" do
expect(PagesWorker).not_to receive(:perform_async)
@@ -3216,28 +3219,28 @@ describe Ci::Build do
end
end
- describe '#has_terminal?' do
+ describe "#has_terminal?" do
let(:states) { described_class.state_machines[:status].states.keys - [:running] }
subject { build.has_terminal? }
- it 'returns true if the build is running and it has a runner_session_url' do
- build.build_runner_session(url: 'whatever')
+ it "returns true if the build is running and it has a runner_session_url" do
+ build.build_runner_session(url: "whatever")
build.status = :running
expect(subject).to be_truthy
end
- context 'returns false' do
- it 'when runner_session_url is empty' do
+ context "returns false" do
+ it "when runner_session_url is empty" do
build.status = :running
expect(subject).to be_falsey
end
- context 'unless the build is running' do
+ context "unless the build is running" do
before do
- build.build_runner_session(url: 'whatever')
+ build.build_runner_session(url: "whatever")
end
it do
@@ -3251,20 +3254,20 @@ describe Ci::Build do
end
end
- describe '#collect_test_reports!' do
+ describe "#collect_test_reports!" do
subject { build.collect_test_reports!(test_reports) }
let(:test_reports) { Gitlab::Ci::Reports::TestReports.new }
it { expect(test_reports.get_suite(build.name).total_count).to eq(0) }
- context 'when build has a test report' do
- context 'when there is a JUnit test report from rspec test suite' do
+ context "when build has a test report" do
+ context "when there is a JUnit test report from rspec test suite" do
before do
create(:ci_job_artifact, :junit, job: build, project: build.project)
end
- it 'parses blobs and add the results to the test suite' do
+ it "parses blobs and add the results to the test suite" do
expect { subject }.not_to raise_error
expect(test_reports.get_suite(build.name).total_count).to eq(4)
@@ -3273,12 +3276,12 @@ describe Ci::Build do
end
end
- context 'when there is a JUnit test report from java ant test suite' do
+ context "when there is a JUnit test report from java ant test suite" do
before do
create(:ci_job_artifact, :junit_with_ant, job: build, project: build.project)
end
- it 'parses blobs and add the results to the test suite' do
+ it "parses blobs and add the results to the test suite" do
expect { subject }.not_to raise_error
expect(test_reports.get_suite(build.name).total_count).to eq(3)
@@ -3287,21 +3290,21 @@ describe Ci::Build do
end
end
- context 'when there is a corrupted JUnit test report' do
+ context "when there is a corrupted JUnit test report" do
before do
create(:ci_job_artifact, :junit_with_corrupted_data, job: build, project: build.project)
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(Gitlab::Ci::Parsers::Test::Junit::JunitParserError)
end
end
end
end
- describe '#artifacts_metadata_entry' do
+ describe "#artifacts_metadata_entry" do
set(:build) { create(:ci_build, project: project) }
- let(:path) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
+ let(:path) { "other_artifacts_0.1.2/another-subdirectory/banana_sample.gif" }
before do
stub_artifacts_object_storage
@@ -3309,113 +3312,113 @@ describe Ci::Build do
subject { build.artifacts_metadata_entry(path) }
- context 'when using local storage' do
+ context "when using local storage" do
let!(:metadata) { create(:ci_job_artifact, :metadata, job: build) }
- context 'for existing file' do
- it 'does exist' do
+ context "for existing file" do
+ it "does exist" do
is_expected.to be_exists
end
end
- context 'for non-existing file' do
- let(:path) { 'invalid-file' }
+ context "for non-existing file" do
+ let(:path) { "invalid-file" }
- it 'does not exist' do
+ it "does not exist" do
is_expected.not_to be_exists
end
end
end
- context 'when using remote storage' do
+ context "when using remote storage" do
include HttpIOHelpers
let!(:metadata) { create(:ci_job_artifact, :remote_store, :metadata, job: build) }
- let(:file_path) { expand_fixture_path('ci_build_artifacts_metadata.gz') }
+ let(:file_path) { expand_fixture_path("ci_build_artifacts_metadata.gz") }
before do
stub_remote_url_206(metadata.file.url, file_path)
end
- context 'for existing file' do
- it 'does exist' do
+ context "for existing file" do
+ it "does exist" do
is_expected.to be_exists
end
end
- context 'for non-existing file' do
- let(:path) { 'invalid-file' }
+ context "for non-existing file" do
+ let(:path) { "invalid-file" }
- it 'does not exist' do
+ it "does not exist" do
is_expected.not_to be_exists
end
end
end
end
- describe '#publishes_artifacts_reports?' do
+ describe "#publishes_artifacts_reports?" do
let(:build) { create(:ci_build, options: options) }
subject { build.publishes_artifacts_reports? }
- context 'when artifacts reports are defined' do
+ context "when artifacts reports are defined" do
let(:options) do
- { artifacts: { reports: { junit: "junit.xml" } } }
+ {artifacts: {reports: {junit: "junit.xml"}}}
end
it { is_expected.to be_truthy }
end
- context 'when artifacts reports missing defined' do
+ context "when artifacts reports missing defined" do
let(:options) do
- { artifacts: { paths: ["file.txt"] } }
+ {artifacts: {paths: ["file.txt"]}}
end
it { is_expected.to be_falsey }
end
- context 'when options are missing' do
+ context "when options are missing" do
let(:options) { nil }
it { is_expected.to be_falsey }
end
end
- describe '#runner_required_feature_names' do
+ describe "#runner_required_feature_names" do
let(:build) { create(:ci_build, options: options) }
subject { build.runner_required_feature_names }
- context 'when artifacts reports are defined' do
+ context "when artifacts reports are defined" do
let(:options) do
- { artifacts: { reports: { junit: "junit.xml" } } }
+ {artifacts: {reports: {junit: "junit.xml"}}}
end
it { is_expected.to include(:upload_multiple_artifacts) }
end
end
- describe '#supported_runner?' do
+ describe "#supported_runner?" do
set(:build) { create(:ci_build) }
subject { build.supported_runner?(runner_features) }
- context 'when feature is required by build' do
+ context "when feature is required by build" do
before do
expect(build).to receive(:runner_required_feature_names) do
[:upload_multiple_artifacts]
end
end
- context 'when runner provides given feature' do
+ context "when runner provides given feature" do
let(:runner_features) do
- { upload_multiple_artifacts: true }
+ {upload_multiple_artifacts: true}
end
it { is_expected.to be_truthy }
end
- context 'when runner does not provide given feature' do
+ context "when runner does not provide given feature" do
let(:runner_features) do
{}
end
@@ -3425,58 +3428,58 @@ describe Ci::Build do
end
end
- describe '#deployment_status' do
+ describe "#deployment_status" do
before do
allow_any_instance_of(described_class).to receive(:create_deployment)
end
- context 'when build is a last deployment' do
- let(:build) { create(:ci_build, :success, environment: 'production') }
- let(:environment) { create(:environment, name: 'production', project: build.project) }
+ context "when build is a last deployment" do
+ let(:build) { create(:ci_build, :success, environment: "production") }
+ let(:environment) { create(:environment, name: "production", project: build.project) }
let!(:deployment) { create(:deployment, :success, environment: environment, project: environment.project, deployable: build) }
it { expect(build.deployment_status).to eq(:last) }
end
- context 'when there is a newer build with deployment' do
- let(:build) { create(:ci_build, :success, environment: 'production') }
- let(:environment) { create(:environment, name: 'production', project: build.project) }
+ context "when there is a newer build with deployment" do
+ let(:build) { create(:ci_build, :success, environment: "production") }
+ let(:environment) { create(:environment, name: "production", project: build.project) }
let!(:deployment) { create(:deployment, :success, environment: environment, project: environment.project, deployable: build) }
let!(:last_deployment) { create(:deployment, :success, environment: environment, project: environment.project) }
it { expect(build.deployment_status).to eq(:out_of_date) }
end
- context 'when build with deployment has failed' do
- let(:build) { create(:ci_build, :failed, environment: 'production') }
- let(:environment) { create(:environment, name: 'production', project: build.project) }
+ context "when build with deployment has failed" do
+ let(:build) { create(:ci_build, :failed, environment: "production") }
+ let(:environment) { create(:environment, name: "production", project: build.project) }
let!(:deployment) { create(:deployment, :success, environment: environment, project: environment.project, deployable: build) }
it { expect(build.deployment_status).to eq(:failed) }
end
- context 'when build with deployment is running' do
- let(:build) { create(:ci_build, environment: 'production') }
- let(:environment) { create(:environment, name: 'production', project: build.project) }
+ context "when build with deployment is running" do
+ let(:build) { create(:ci_build, environment: "production") }
+ let(:environment) { create(:environment, name: "production", project: build.project) }
let!(:deployment) { create(:deployment, :success, environment: environment, project: environment.project, deployable: build) }
it { expect(build.deployment_status).to eq(:creating) }
end
end
- describe '#degenerated?' do
- context 'when build is degenerated' do
+ describe "#degenerated?" do
+ context "when build is degenerated" do
subject { create(:ci_build, :degenerated) }
it { is_expected.to be_degenerated }
end
- context 'when build is valid' do
+ context "when build is valid" do
subject { create(:ci_build) }
it { is_expected.not_to be_degenerated }
- context 'and becomes degenerated' do
+ context "and becomes degenerated" do
before do
subject.degenerate!
end
@@ -3486,7 +3489,7 @@ describe Ci::Build do
end
end
- describe 'degenerate!' do
+ describe "degenerate!" do
let(:build) { create(:ci_build) }
subject { build.degenerate! }
@@ -3495,7 +3498,7 @@ describe Ci::Build do
build.ensure_metadata
end
- it 'drops metadata' do
+ it "drops metadata" do
subject
expect(build.reload).to be_degenerated
@@ -3503,17 +3506,17 @@ describe Ci::Build do
end
end
- describe '#archived?' do
- context 'when build is degenerated' do
+ describe "#archived?" do
+ context "when build is degenerated" do
subject { create(:ci_build, :degenerated) }
it { is_expected.to be_archived }
end
- context 'for old build' do
+ context "for old build" do
subject { create(:ci_build, created_at: 1.day.ago) }
- context 'when archive_builds_in is set' do
+ context "when archive_builds_in is set" do
before do
stub_application_setting(archive_builds_in_seconds: 3600)
end
@@ -3521,7 +3524,7 @@ describe Ci::Build do
it { is_expected.to be_archived }
end
- context 'when archive_builds_in is not set' do
+ context "when archive_builds_in is not set" do
before do
stub_application_setting(archive_builds_in_seconds: nil)
end
@@ -3531,67 +3534,67 @@ describe Ci::Build do
end
end
- describe '#read_metadata_attribute' do
+ describe "#read_metadata_attribute" do
let(:build) { create(:ci_build, :degenerated) }
- let(:build_options) { { "key" => "build" } }
- let(:metadata_options) { { "key" => "metadata" } }
- let(:default_options) { { "key" => "default" } }
+ let(:build_options) { {"key" => "build"} }
+ let(:metadata_options) { {"key" => "metadata"} }
+ let(:default_options) { {"key" => "default"} }
subject { build.send(:read_metadata_attribute, :options, :config_options, default_options) }
- context 'when build and metadata options is set' do
+ context "when build and metadata options is set" do
before do
build.write_attribute(:options, build_options)
build.ensure_metadata.write_attribute(:config_options, metadata_options)
end
- it 'prefers build options' do
+ it "prefers build options" do
is_expected.to eq(build_options)
end
end
- context 'when only metadata options is set' do
+ context "when only metadata options is set" do
before do
build.write_attribute(:options, nil)
build.ensure_metadata.write_attribute(:config_options, metadata_options)
end
- it 'returns metadata options' do
+ it "returns metadata options" do
is_expected.to eq(metadata_options)
end
end
- context 'when none is set' do
- it 'returns default value' do
+ context "when none is set" do
+ it "returns default value" do
is_expected.to eq(default_options)
end
end
end
- describe '#write_metadata_attribute' do
+ describe "#write_metadata_attribute" do
let(:build) { create(:ci_build, :degenerated) }
- let(:options) { { "key" => "new options" } }
- let(:existing_options) { { "key" => "existing options" } }
+ let(:options) { {"key" => "new options"} }
+ let(:existing_options) { {"key" => "existing options"} }
subject { build.send(:write_metadata_attribute, :options, :config_options, options) }
- context 'when ci_build_metadata_config is set' do
+ context "when ci_build_metadata_config is set" do
before do
stub_feature_flags(ci_build_metadata_config: true)
end
- context 'when data in build is already set' do
+ context "when data in build is already set" do
before do
build.write_attribute(:options, existing_options)
end
- it 'does set metadata options' do
+ it "does set metadata options" do
subject
expect(build.metadata.read_attribute(:config_options)).to eq(options)
end
- it 'does reset build options' do
+ it "does reset build options" do
subject
expect(build.read_attribute(:options)).to be_nil
@@ -3599,23 +3602,23 @@ describe Ci::Build do
end
end
- context 'when ci_build_metadata_config is disabled' do
+ context "when ci_build_metadata_config is disabled" do
before do
stub_feature_flags(ci_build_metadata_config: false)
end
- context 'when data in build metadata is already set' do
+ context "when data in build metadata is already set" do
before do
build.ensure_metadata.write_attribute(:config_options, existing_options)
end
- it 'does set metadata options' do
+ it "does set metadata options" do
subject
expect(build.read_attribute(:options)).to eq(options)
end
- it 'does reset build options' do
+ it "does reset build options" do
subject
expect(build.metadata.read_attribute(:config_options)).to be_nil
diff --git a/spec/models/ci/build_trace_chunk_spec.rb b/spec/models/ci/build_trace_chunk_spec.rb
index 59db347582b..53e42daff04 100644
--- a/spec/models/ci/build_trace_chunk_spec.rb
+++ b/spec/models/ci/build_trace_chunk_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
@@ -12,20 +12,20 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
described_class.new(build: build, chunk_index: chunk_index, data_store: data_store, raw_data: raw_data)
end
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
before do
stub_feature_flags(ci_enable_live_trace: true)
stub_artifacts_object_storage
end
- context 'FastDestroyAll' do
+ context "FastDestroyAll" do
let(:parent) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: parent) }
let(:build) { create(:ci_build, :running, :trace_live, pipeline: pipeline, project: parent) }
let(:subjects) { build.trace_chunks }
- it_behaves_like 'fast destroyable'
+ it_behaves_like "fast destroyable"
def external_data_counter
Gitlab::Redis::SharedState.with do |redis|
@@ -34,135 +34,135 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- describe 'CHUNK_SIZE' do
- it 'Chunk size can not be changed without special care' do
+ describe "CHUNK_SIZE" do
+ it "Chunk size can not be changed without special care" do
expect(described_class::CHUNK_SIZE).to eq(128.kilobytes)
end
end
- describe '.all_stores' do
+ describe ".all_stores" do
subject { described_class.all_stores }
- it 'returns a correctly ordered array' do
+ it "returns a correctly ordered array" do
is_expected.to eq(%w[redis database fog])
end
- it 'returns redis store as the lowest precedence' do
- expect(subject.first).to eq('redis')
+ it "returns redis store as the lowest precedence" do
+ expect(subject.first).to eq("redis")
end
- it 'returns fog store as the highest precedence' do
- expect(subject.last).to eq('fog')
+ it "returns fog store as the highest precedence" do
+ expect(subject.last).to eq("fog")
end
end
- describe '#data' do
+ describe "#data" do
subject { build_trace_chunk.data }
- context 'when data_store is redis' do
+ context "when data_store is redis" do
let(:data_store) { :redis }
before do
- build_trace_chunk.send(:unsafe_set_data!, 'Sample data in redis')
+ build_trace_chunk.send(:unsafe_set_data!, "Sample data in redis")
end
- it { is_expected.to eq('Sample data in redis') }
+ it { is_expected.to eq("Sample data in redis") }
end
- context 'when data_store is database' do
+ context "when data_store is database" do
let(:data_store) { :database }
- let(:raw_data) { 'Sample data in database' }
+ let(:raw_data) { "Sample data in database" }
- it { is_expected.to eq('Sample data in database') }
+ it { is_expected.to eq("Sample data in database") }
end
- context 'when data_store is fog' do
+ context "when data_store is fog" do
let(:data_store) { :fog }
before do
- build_trace_chunk.send(:unsafe_set_data!, 'Sample data in fog')
+ build_trace_chunk.send(:unsafe_set_data!, "Sample data in fog")
end
- it { is_expected.to eq('Sample data in fog') }
+ it { is_expected.to eq("Sample data in fog") }
end
end
- describe '#append' do
+ describe "#append" do
subject { build_trace_chunk.append(new_data, offset) }
- let(:new_data) { 'Sample new data' }
+ let(:new_data) { "Sample new data" }
let(:offset) { 0 }
let(:merged_data) { data + new_data.to_s }
- shared_examples_for 'Appending correctly' do
- context 'when offset is negative' do
+ shared_examples_for "Appending correctly" do
+ context "when offset is negative" do
let(:offset) { -1 }
- it { expect { subject }.to raise_error('Offset is out of range') }
+ it { expect { subject }.to raise_error("Offset is out of range") }
end
- context 'when offset is bigger than data size' do
+ context "when offset is bigger than data size" do
let(:offset) { data.bytesize + 1 }
- it { expect { subject }.to raise_error('Offset is out of range') }
+ it { expect { subject }.to raise_error("Offset is out of range") }
end
- context 'when new data overflows chunk size' do
- let(:new_data) { 'a' * (described_class::CHUNK_SIZE + 1) }
+ context "when new data overflows chunk size" do
+ let(:new_data) { "a" * (described_class::CHUNK_SIZE + 1) }
- it { expect { subject }.to raise_error('Chunk size overflow') }
+ it { expect { subject }.to raise_error("Chunk size overflow") }
end
- context 'when offset is EOF' do
+ context "when offset is EOF" do
let(:offset) { data.bytesize }
- it 'appends' do
+ it "appends" do
subject
expect(build_trace_chunk.data).to eq(merged_data)
end
- context 'when the other process is appending' do
+ context "when the other process is appending" do
let(:lease_key) { "trace_write:#{build_trace_chunk.build.id}:chunks:#{build_trace_chunk.chunk_index}" }
before do
stub_exclusive_lease_taken(lease_key)
end
- it 'raise an error' do
- expect { subject }.to raise_error('Failed to obtain a lock')
+ it "raise an error" do
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
end
- context 'when new_data is nil' do
+ context "when new_data is nil" do
let(:new_data) { nil }
- it 'raises an error' do
- expect { subject }.to raise_error('New data is missing')
+ it "raises an error" do
+ expect { subject }.to raise_error("New data is missing")
end
end
- context 'when new_data is empty' do
- let(:new_data) { '' }
+ context "when new_data is empty" do
+ let(:new_data) { "" }
- it 'does not append' do
+ it "does not append" do
subject
expect(build_trace_chunk.data).to eq(data)
end
- it 'does not execute UPDATE' do
+ it "does not execute UPDATE" do
ActiveRecord::QueryRecorder.new { subject }.log.map do |query|
- expect(query).not_to include('UPDATE')
+ expect(query).not_to include("UPDATE")
end
end
end
end
- context 'when offset is middle of datasize' do
+ context "when offset is middle of datasize" do
let(:offset) { data.bytesize / 2 }
- it 'appends' do
+ it "appends" do
subject
expect(build_trace_chunk.data).to eq(data.byteslice(0, offset) + new_data)
@@ -170,17 +170,17 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- shared_examples_for 'Scheduling sidekiq worker to flush data to persist store' do
- context 'when new data fulfilled chunk size' do
- let(:new_data) { 'a' * described_class::CHUNK_SIZE }
+ shared_examples_for "Scheduling sidekiq worker to flush data to persist store" do
+ context "when new data fulfilled chunk size" do
+ let(:new_data) { "a" * described_class::CHUNK_SIZE }
- it 'schedules trace chunk flush worker' do
+ it "schedules trace chunk flush worker" do
expect(Ci::BuildTraceChunkFlushWorker).to receive(:perform_async).once
subject
end
- it 'migrates data to object storage' do
+ it "migrates data to object storage" do
perform_enqueued_jobs do
subject
@@ -192,17 +192,17 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- shared_examples_for 'Scheduling no sidekiq worker' do
- context 'when new data fulfilled chunk size' do
- let(:new_data) { 'a' * described_class::CHUNK_SIZE }
+ shared_examples_for "Scheduling no sidekiq worker" do
+ context "when new data fulfilled chunk size" do
+ let(:new_data) { "a" * described_class::CHUNK_SIZE }
- it 'does not schedule trace chunk flush worker' do
+ it "does not schedule trace chunk flush worker" do
expect(Ci::BuildTraceChunkFlushWorker).not_to receive(:perform_async)
subject
end
- it 'does not migrate data to object storage' do
+ it "does not migrate data to object storage" do
perform_enqueued_jobs do
data_store = build_trace_chunk.data_store
@@ -215,114 +215,114 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- context 'when data_store is redis' do
+ context "when data_store is redis" do
let(:data_store) { :redis }
- context 'when there are no data' do
- let(:data) { '' }
+ context "when there are no data" do
+ let(:data) { "" }
- it 'has no data' do
+ it "has no data" do
expect(build_trace_chunk.data).to be_empty
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling sidekiq worker to flush data to persist store'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling sidekiq worker to flush data to persist store"
end
- context 'when there are some data' do
- let(:data) { 'Sample data in redis' }
+ context "when there are some data" do
+ let(:data) { "Sample data in redis" }
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- it 'has data' do
+ it "has data" do
expect(build_trace_chunk.data).to eq(data)
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling sidekiq worker to flush data to persist store'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling sidekiq worker to flush data to persist store"
end
end
- context 'when data_store is database' do
+ context "when data_store is database" do
let(:data_store) { :database }
- context 'when there are no data' do
- let(:data) { '' }
+ context "when there are no data" do
+ let(:data) { "" }
- it 'has no data' do
+ it "has no data" do
expect(build_trace_chunk.data).to be_empty
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling no sidekiq worker'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling no sidekiq worker"
end
- context 'when there are some data' do
- let(:raw_data) { 'Sample data in database' }
+ context "when there are some data" do
+ let(:raw_data) { "Sample data in database" }
let(:data) { raw_data }
- it 'has data' do
+ it "has data" do
expect(build_trace_chunk.data).to eq(data)
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling no sidekiq worker'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling no sidekiq worker"
end
end
- context 'when data_store is fog' do
+ context "when data_store is fog" do
let(:data_store) { :fog }
- context 'when there are no data' do
- let(:data) { '' }
+ context "when there are no data" do
+ let(:data) { "" }
- it 'has no data' do
+ it "has no data" do
expect(build_trace_chunk.data).to be_empty
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling no sidekiq worker'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling no sidekiq worker"
end
- context 'when there are some data' do
- let(:data) { 'Sample data in fog' }
+ context "when there are some data" do
+ let(:data) { "Sample data in fog" }
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- it 'has data' do
+ it "has data" do
expect(build_trace_chunk.data).to eq(data)
end
- it_behaves_like 'Appending correctly'
- it_behaves_like 'Scheduling no sidekiq worker'
+ it_behaves_like "Appending correctly"
+ it_behaves_like "Scheduling no sidekiq worker"
end
end
end
- describe '#truncate' do
+ describe "#truncate" do
subject { build_trace_chunk.truncate(offset) }
- shared_examples_for 'truncates' do
- context 'when offset is negative' do
+ shared_examples_for "truncates" do
+ context "when offset is negative" do
let(:offset) { -1 }
- it { expect { subject }.to raise_error('Offset is out of range') }
+ it { expect { subject }.to raise_error("Offset is out of range") }
end
- context 'when offset is bigger than data size' do
+ context "when offset is bigger than data size" do
let(:offset) { data.bytesize + 1 }
- it { expect { subject }.to raise_error('Offset is out of range') }
+ it { expect { subject }.to raise_error("Offset is out of range") }
end
- context 'when offset is 10' do
+ context "when offset is 10" do
let(:offset) { 10 }
- it 'truncates' do
+ it "truncates" do
subject
expect(build_trace_chunk.data).to eq(data.byteslice(0, offset))
@@ -330,45 +330,45 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- context 'when data_store is redis' do
+ context "when data_store is redis" do
let(:data_store) { :redis }
- let(:data) { 'Sample data in redis' }
+ let(:data) { "Sample data in redis" }
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- it_behaves_like 'truncates'
+ it_behaves_like "truncates"
end
- context 'when data_store is database' do
+ context "when data_store is database" do
let(:data_store) { :database }
- let(:raw_data) { 'Sample data in database' }
+ let(:raw_data) { "Sample data in database" }
let(:data) { raw_data }
- it_behaves_like 'truncates'
+ it_behaves_like "truncates"
end
- context 'when data_store is fog' do
+ context "when data_store is fog" do
let(:data_store) { :fog }
- let(:data) { 'Sample data in fog' }
+ let(:data) { "Sample data in fog" }
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- it_behaves_like 'truncates'
+ it_behaves_like "truncates"
end
end
- describe '#size' do
+ describe "#size" do
subject { build_trace_chunk.size }
- context 'when data_store is redis' do
+ context "when data_store is redis" do
let(:data_store) { :redis }
- context 'when data exists' do
- let(:data) { 'Sample data in redis' }
+ context "when data exists" do
+ let(:data) { "Sample data in redis" }
before do
build_trace_chunk.send(:unsafe_set_data!, data)
@@ -377,31 +377,31 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
it { is_expected.to eq(data.bytesize) }
end
- context 'when data exists' do
+ context "when data exists" do
it { is_expected.to eq(0) }
end
end
- context 'when data_store is database' do
+ context "when data_store is database" do
let(:data_store) { :database }
- context 'when data exists' do
- let(:raw_data) { 'Sample data in database' }
+ context "when data exists" do
+ let(:raw_data) { "Sample data in database" }
let(:data) { raw_data }
it { is_expected.to eq(data.bytesize) }
end
- context 'when data does not exist' do
+ context "when data does not exist" do
it { is_expected.to eq(0) }
end
end
- context 'when data_store is fog' do
+ context "when data_store is fog" do
let(:data_store) { :fog }
- context 'when data exists' do
- let(:data) { 'Sample data in fog' }
+ context "when data exists" do
+ let(:data) { "Sample data in fog" }
let(:key) { "tmp/builds/#{build.id}/chunks/#{chunk_index}.log" }
before do
@@ -411,41 +411,41 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
it { is_expected.to eq(data.bytesize) }
end
- context 'when data does not exist' do
+ context "when data does not exist" do
it { is_expected.to eq(0) }
end
end
end
- describe '#persist_data!' do
+ describe "#persist_data!" do
subject { build_trace_chunk.persist_data! }
- shared_examples_for 'Atomic operation' do
- context 'when the other process is persisting' do
+ shared_examples_for "Atomic operation" do
+ context "when the other process is persisting" do
let(:lease_key) { "trace_write:#{build_trace_chunk.build.id}:chunks:#{build_trace_chunk.chunk_index}" }
before do
stub_exclusive_lease_taken(lease_key)
end
- it 'raise an error' do
- expect { subject }.to raise_error('Failed to obtain a lock')
+ it "raise an error" do
+ expect { subject }.to raise_error("Failed to obtain a lock")
end
end
end
- context 'when data_store is redis' do
+ context "when data_store is redis" do
let(:data_store) { :redis }
- context 'when data exists' do
+ context "when data exists" do
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- context 'when data size reached CHUNK_SIZE' do
- let(:data) { 'a' * described_class::CHUNK_SIZE }
+ context "when data size reached CHUNK_SIZE" do
+ let(:data) { "a" * described_class::CHUNK_SIZE }
- it 'persists the data' do
+ it "persists the data" do
expect(build_trace_chunk.redis?).to be_truthy
expect(Ci::BuildTraceChunks::Redis.new.data(build_trace_chunk)).to eq(data)
expect(Ci::BuildTraceChunks::Database.new.data(build_trace_chunk)).to be_nil
@@ -459,13 +459,13 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect(Ci::BuildTraceChunks::Fog.new.data(build_trace_chunk)).to eq(data)
end
- it_behaves_like 'Atomic operation'
+ it_behaves_like "Atomic operation"
end
- context 'when data size has not reached CHUNK_SIZE' do
- let(:data) { 'Sample data in redis' }
+ context "when data size has not reached CHUNK_SIZE" do
+ let(:data) { "Sample data in redis" }
- it 'does not persist the data and the orignal data is intact' do
+ it "does not persist the data and the orignal data is intact" do
expect { subject }.to raise_error(described_class::FailedToPersistDataError)
expect(build_trace_chunk.redis?).to be_truthy
@@ -476,25 +476,25 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- context 'when data does not exist' do
- it 'does not persist' do
+ context "when data does not exist" do
+ it "does not persist" do
expect { subject }.to raise_error(described_class::FailedToPersistDataError)
end
end
end
- context 'when data_store is database' do
+ context "when data_store is database" do
let(:data_store) { :database }
- context 'when data exists' do
+ context "when data exists" do
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- context 'when data size reached CHUNK_SIZE' do
- let(:data) { 'a' * described_class::CHUNK_SIZE }
+ context "when data size reached CHUNK_SIZE" do
+ let(:data) { "a" * described_class::CHUNK_SIZE }
- it 'persists the data' do
+ it "persists the data" do
expect(build_trace_chunk.database?).to be_truthy
expect(Ci::BuildTraceChunks::Redis.new.data(build_trace_chunk)).to be_nil
expect(Ci::BuildTraceChunks::Database.new.data(build_trace_chunk)).to eq(data)
@@ -508,13 +508,13 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect(Ci::BuildTraceChunks::Fog.new.data(build_trace_chunk)).to eq(data)
end
- it_behaves_like 'Atomic operation'
+ it_behaves_like "Atomic operation"
end
- context 'when data size has not reached CHUNK_SIZE' do
- let(:data) { 'Sample data in database' }
+ context "when data size has not reached CHUNK_SIZE" do
+ let(:data) { "Sample data in database" }
- it 'does not persist the data and the orignal data is intact' do
+ it "does not persist the data and the orignal data is intact" do
expect { subject }.to raise_error(described_class::FailedToPersistDataError)
expect(build_trace_chunk.database?).to be_truthy
@@ -525,25 +525,25 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- context 'when data does not exist' do
- it 'does not persist' do
+ context "when data does not exist" do
+ it "does not persist" do
expect { subject }.to raise_error(described_class::FailedToPersistDataError)
end
end
end
- context 'when data_store is fog' do
+ context "when data_store is fog" do
let(:data_store) { :fog }
- context 'when data exists' do
+ context "when data exists" do
before do
build_trace_chunk.send(:unsafe_set_data!, data)
end
- context 'when data size reached CHUNK_SIZE' do
- let(:data) { 'a' * described_class::CHUNK_SIZE }
+ context "when data size reached CHUNK_SIZE" do
+ let(:data) { "a" * described_class::CHUNK_SIZE }
- it 'does not change data store' do
+ it "does not change data store" do
expect(build_trace_chunk.fog?).to be_truthy
expect(Ci::BuildTraceChunks::Redis.new.data(build_trace_chunk)).to be_nil
expect(Ci::BuildTraceChunks::Database.new.data(build_trace_chunk)).to be_nil
@@ -557,13 +557,13 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
expect(Ci::BuildTraceChunks::Fog.new.data(build_trace_chunk)).to eq(data)
end
- it_behaves_like 'Atomic operation'
+ it_behaves_like "Atomic operation"
end
- context 'when data size has not reached CHUNK_SIZE' do
- let(:data) { 'Sample data in fog' }
+ context "when data size has not reached CHUNK_SIZE" do
+ let(:data) { "Sample data in fog" }
- it 'does not raise error' do
+ it "does not raise error" do
expect { subject }.not_to raise_error
end
end
@@ -571,7 +571,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- describe 'deletes data in redis after a parent record destroyed' do
+ describe "deletes data in redis after a parent record destroyed" do
let(:project) { create(:project) }
before do
@@ -581,7 +581,7 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
create(:ci_build, :running, :trace_live, pipeline: pipeline, project: project)
end
- shared_examples_for 'deletes all build_trace_chunk and data in redis' do
+ shared_examples_for "deletes all build_trace_chunk and data in redis" do
it do
Gitlab::Redis::SharedState.with do |redis|
expect(redis.scan_each(match: "gitlab:ci:trace:*:chunks:*").to_a.size).to eq(3)
@@ -599,22 +599,22 @@ describe Ci::BuildTraceChunk, :clean_gitlab_redis_shared_state do
end
end
- context 'when traces are archived' do
+ context "when traces are archived" do
let(:subject) do
project.builds.each do |build|
build.success!
end
end
- it_behaves_like 'deletes all build_trace_chunk and data in redis'
+ it_behaves_like "deletes all build_trace_chunk and data in redis"
end
- context 'when project is destroyed' do
+ context "when project is destroyed" do
let(:subject) do
project.destroy!
end
- it_behaves_like 'deletes all build_trace_chunk and data in redis'
+ it_behaves_like "deletes all build_trace_chunk and data in redis"
end
end
end
diff --git a/spec/models/ci/build_trace_chunks/database_spec.rb b/spec/models/ci/build_trace_chunks/database_spec.rb
index d8fc9d57e95..85509faab4d 100644
--- a/spec/models/ci/build_trace_chunks/database_spec.rb
+++ b/spec/models/ci/build_trace_chunks/database_spec.rb
@@ -1,72 +1,72 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceChunks::Database do
let(:data_store) { described_class.new }
- describe '#available?' do
+ describe "#available?" do
subject { data_store.available? }
it { is_expected.to be_truthy }
end
- describe '#data' do
+ describe "#data" do
subject { data_store.data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: 'sample data in database') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: "sample data in database") }
- it 'returns the data' do
- is_expected.to eq('sample data in database')
+ it "returns the data" do
+ is_expected.to eq("sample data in database")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :database_without_data) }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- describe '#set_data' do
+ describe "#set_data" do
subject { data_store.set_data(model, data) }
- let(:data) { 'abc123' }
+ let(:data) { "abc123" }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: 'sample data in database') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: "sample data in database") }
- it 'overwrites data' do
- expect(data_store.data(model)).to eq('sample data in database')
+ it "overwrites data" do
+ expect(data_store.data(model)).to eq("sample data in database")
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :database_without_data) }
- it 'sets new data' do
+ it "sets new data" do
expect(data_store.data(model)).to be_nil
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
end
- describe '#delete_data' do
+ describe "#delete_data" do
subject { data_store.delete_data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: 'sample data in database') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :database_with_data, initial_data: "sample data in database") }
- it 'deletes data' do
- expect(data_store.data(model)).to eq('sample data in database')
+ it "deletes data" do
+ expect(data_store.data(model)).to eq("sample data in database")
subject
@@ -74,10 +74,10 @@ describe Ci::BuildTraceChunks::Database do
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :database_without_data) }
- it 'does nothing' do
+ it "does nothing" do
expect(data_store.data(model)).to be_nil
subject
@@ -87,7 +87,7 @@ describe Ci::BuildTraceChunks::Database do
end
end
- describe '#keys' do
+ describe "#keys" do
subject { data_store.keys(relation) }
let(:build) { create(:ci_build) }
@@ -98,7 +98,7 @@ describe Ci::BuildTraceChunks::Database do
create(:ci_build_trace_chunk, :database_with_data, chunk_index: 1, build: build)
end
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to eq([])
end
end
diff --git a/spec/models/ci/build_trace_chunks/fog_spec.rb b/spec/models/ci/build_trace_chunks/fog_spec.rb
index 8f49190af13..7b89db3e39f 100644
--- a/spec/models/ci/build_trace_chunks/fog_spec.rb
+++ b/spec/models/ci/build_trace_chunks/fog_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceChunks::Fog do
let(:data_store) { described_class.new }
@@ -7,14 +7,14 @@ describe Ci::BuildTraceChunks::Fog do
stub_artifacts_object_storage
end
- describe '#available?' do
+ describe "#available?" do
subject { data_store.available? }
- context 'when object storage is enabled' do
+ context "when object storage is enabled" do
it { is_expected.to be_truthy }
end
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
before do
stub_artifacts_object_storage(enabled: false)
end
@@ -23,64 +23,64 @@ describe Ci::BuildTraceChunks::Fog do
end
end
- describe '#data' do
+ describe "#data" do
subject { data_store.data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: 'sample data in fog') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: "sample data in fog") }
- it 'returns the data' do
- is_expected.to eq('sample data in fog')
+ it "returns the data" do
+ is_expected.to eq("sample data in fog")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :fog_without_data) }
- it 'returns nil' do
+ it "returns nil" do
expect { data_store.data(model) }.to raise_error(Excon::Error::NotFound)
end
end
end
- describe '#set_data' do
+ describe "#set_data" do
subject { data_store.set_data(model, data) }
- let(:data) { 'abc123' }
+ let(:data) { "abc123" }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: 'sample data in fog') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: "sample data in fog") }
- it 'overwrites data' do
- expect(data_store.data(model)).to eq('sample data in fog')
+ it "overwrites data" do
+ expect(data_store.data(model)).to eq("sample data in fog")
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :fog_without_data) }
- it 'sets new data' do
+ it "sets new data" do
expect { data_store.data(model) }.to raise_error(Excon::Error::NotFound)
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
end
- describe '#delete_data' do
+ describe "#delete_data" do
subject { data_store.delete_data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: 'sample data in fog') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :fog_with_data, initial_data: "sample data in fog") }
- it 'deletes data' do
- expect(data_store.data(model)).to eq('sample data in fog')
+ it "deletes data" do
+ expect(data_store.data(model)).to eq("sample data in fog")
subject
@@ -88,10 +88,10 @@ describe Ci::BuildTraceChunks::Fog do
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :fog_without_data) }
- it 'does nothing' do
+ it "does nothing" do
expect { data_store.data(model) }.to raise_error(Excon::Error::NotFound)
subject
@@ -101,7 +101,7 @@ describe Ci::BuildTraceChunks::Fog do
end
end
- describe '#keys' do
+ describe "#keys" do
subject { data_store.keys(relation) }
let(:build) { create(:ci_build) }
@@ -112,12 +112,12 @@ describe Ci::BuildTraceChunks::Fog do
create(:ci_build_trace_chunk, :fog_with_data, chunk_index: 1, build: build)
end
- it 'returns keys' do
+ it "returns keys" do
is_expected.to eq([[build.id, 0], [build.id, 1]])
end
end
- describe '#delete_keys' do
+ describe "#delete_keys" do
subject { data_store.delete_keys(keys) }
let(:build) { create(:ci_build) }
@@ -129,17 +129,17 @@ describe Ci::BuildTraceChunks::Fog do
create(:ci_build_trace_chunk, :fog_with_data, chunk_index: 1, build: build)
end
- it 'deletes multiple data' do
+ it "deletes multiple data" do
::Fog::Storage.new(JobArtifactUploader.object_store_credentials).tap do |connection|
- expect(connection.get_object('artifacts', "tmp/builds/#{build.id}/chunks/0.log")[:body]).to be_present
- expect(connection.get_object('artifacts', "tmp/builds/#{build.id}/chunks/1.log")[:body]).to be_present
+ expect(connection.get_object("artifacts", "tmp/builds/#{build.id}/chunks/0.log")[:body]).to be_present
+ expect(connection.get_object("artifacts", "tmp/builds/#{build.id}/chunks/1.log")[:body]).to be_present
end
subject
::Fog::Storage.new(JobArtifactUploader.object_store_credentials).tap do |connection|
- expect { connection.get_object('artifacts', "tmp/builds/#{build.id}/chunks/0.log")[:body] }.to raise_error(Excon::Error::NotFound)
- expect { connection.get_object('artifacts', "tmp/builds/#{build.id}/chunks/1.log")[:body] }.to raise_error(Excon::Error::NotFound)
+ expect { connection.get_object("artifacts", "tmp/builds/#{build.id}/chunks/0.log")[:body] }.to raise_error(Excon::Error::NotFound)
+ expect { connection.get_object("artifacts", "tmp/builds/#{build.id}/chunks/1.log")[:body] }.to raise_error(Excon::Error::NotFound)
end
end
end
diff --git a/spec/models/ci/build_trace_chunks/redis_spec.rb b/spec/models/ci/build_trace_chunks/redis_spec.rb
index 9da1e6a95ee..632328d9973 100644
--- a/spec/models/ci/build_trace_chunks/redis_spec.rb
+++ b/spec/models/ci/build_trace_chunks/redis_spec.rb
@@ -1,72 +1,72 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceChunks::Redis, :clean_gitlab_redis_shared_state do
let(:data_store) { described_class.new }
- describe '#available?' do
+ describe "#available?" do
subject { data_store.available? }
it { is_expected.to be_truthy }
end
- describe '#data' do
+ describe "#data" do
subject { data_store.data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: 'sample data in redis') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: "sample data in redis") }
- it 'returns the data' do
- is_expected.to eq('sample data in redis')
+ it "returns the data" do
+ is_expected.to eq("sample data in redis")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :redis_without_data) }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- describe '#set_data' do
+ describe "#set_data" do
subject { data_store.set_data(model, data) }
- let(:data) { 'abc123' }
+ let(:data) { "abc123" }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: 'sample data in redis') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: "sample data in redis") }
- it 'overwrites data' do
- expect(data_store.data(model)).to eq('sample data in redis')
+ it "overwrites data" do
+ expect(data_store.data(model)).to eq("sample data in redis")
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :redis_without_data) }
- it 'sets new data' do
+ it "sets new data" do
expect(data_store.data(model)).to be_nil
subject
- expect(data_store.data(model)).to eq('abc123')
+ expect(data_store.data(model)).to eq("abc123")
end
end
end
- describe '#delete_data' do
+ describe "#delete_data" do
subject { data_store.delete_data(model) }
- context 'when data exists' do
- let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: 'sample data in redis') }
+ context "when data exists" do
+ let(:model) { create(:ci_build_trace_chunk, :redis_with_data, initial_data: "sample data in redis") }
- it 'deletes data' do
- expect(data_store.data(model)).to eq('sample data in redis')
+ it "deletes data" do
+ expect(data_store.data(model)).to eq("sample data in redis")
subject
@@ -74,10 +74,10 @@ describe Ci::BuildTraceChunks::Redis, :clean_gitlab_redis_shared_state do
end
end
- context 'when data does not exist' do
+ context "when data does not exist" do
let(:model) { create(:ci_build_trace_chunk, :redis_without_data) }
- it 'does nothing' do
+ it "does nothing" do
expect(data_store.data(model)).to be_nil
subject
@@ -87,7 +87,7 @@ describe Ci::BuildTraceChunks::Redis, :clean_gitlab_redis_shared_state do
end
end
- describe '#keys' do
+ describe "#keys" do
subject { data_store.keys(relation) }
let(:build) { create(:ci_build) }
@@ -98,12 +98,12 @@ describe Ci::BuildTraceChunks::Redis, :clean_gitlab_redis_shared_state do
create(:ci_build_trace_chunk, :redis_with_data, chunk_index: 1, build: build)
end
- it 'returns keys' do
+ it "returns keys" do
is_expected.to eq([[build.id, 0], [build.id, 1]])
end
end
- describe '#delete_keys' do
+ describe "#delete_keys" do
subject { data_store.delete_keys(keys) }
let(:build) { create(:ci_build) }
@@ -115,7 +115,7 @@ describe Ci::BuildTraceChunks::Redis, :clean_gitlab_redis_shared_state do
create(:ci_build_trace_chunk, :redis_with_data, chunk_index: 1, build: build)
end
- it 'deletes multiple data' do
+ it "deletes multiple data" do
Gitlab::Redis::SharedState.with do |redis|
expect(redis.exists("gitlab:ci:trace:#{build.id}:chunks:0")).to be_truthy
expect(redis.exists("gitlab:ci:trace:#{build.id}:chunks:1")).to be_truthy
diff --git a/spec/models/ci/build_trace_section_name_spec.rb b/spec/models/ci/build_trace_section_name_spec.rb
index 386ee6880cb..0cb5223718a 100644
--- a/spec/models/ci/build_trace_section_name_spec.rb
+++ b/spec/models/ci/build_trace_section_name_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceSectionName, model: true do
subject { build(:ci_build_trace_section_name) }
diff --git a/spec/models/ci/build_trace_section_spec.rb b/spec/models/ci/build_trace_section_spec.rb
index 541a9a36fb8..38a8ba3148c 100644
--- a/spec/models/ci/build_trace_section_spec.rb
+++ b/spec/models/ci/build_trace_section_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildTraceSection, model: true do
it { is_expected.to belong_to(:build)}
diff --git a/spec/models/ci/group_spec.rb b/spec/models/ci/group_spec.rb
index 838fa63cb1f..9bb76bdb0a4 100644
--- a/spec/models/ci/group_spec.rb
+++ b/spec/models/ci/group_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Group do
subject do
- described_class.new('test', name: 'rspec', jobs: jobs)
+ described_class.new("test", name: "rspec", jobs: jobs)
end
let!(:jobs) { build_list(:ci_build, 1, :success) }
@@ -14,77 +14,77 @@ describe Ci::Group do
it { is_expected.to respond_to(:jobs) }
it { is_expected.to respond_to(:status) }
- describe '#size' do
- it 'returns the number of statuses in the group' do
+ describe "#size" do
+ it "returns the number of statuses in the group" do
expect(subject.size).to eq(1)
end
end
- describe '#detailed_status' do
- context 'when there is only one item in the group' do
- it 'calls the status from the object itself' do
+ describe "#detailed_status" do
+ context "when there is only one item in the group" do
+ it "calls the status from the object itself" do
expect(jobs.first).to receive(:detailed_status)
expect(subject.detailed_status(double(:user)))
end
end
- context 'when there are more than one commit status in the group' do
+ context "when there are more than one commit status in the group" do
let(:jobs) do
[create(:ci_build, :failed),
- create(:ci_build, :success)]
+ create(:ci_build, :success),]
end
- it 'fabricates a new detailed status object' do
+ it "fabricates a new detailed status object" do
expect(subject.detailed_status(double(:user)))
.to be_a(Gitlab::Ci::Status::Failed)
end
end
end
- describe '.fabricate' do
+ describe ".fabricate" do
let(:pipeline) { create(:ci_empty_pipeline) }
let(:stage) { create(:ci_stage_entity, pipeline: pipeline) }
before do
- create_build(:ci_build, name: 'rspec 0 2')
- create_build(:ci_build, name: 'rspec 0 1')
- create_build(:ci_build, name: 'spinach 0 1')
- create_build(:commit_status, name: 'aaaaa')
+ create_build(:ci_build, name: "rspec 0 2")
+ create_build(:ci_build, name: "rspec 0 1")
+ create_build(:ci_build, name: "spinach 0 1")
+ create_build(:commit_status, name: "aaaaa")
end
- it 'returns an array of three groups' do
+ it "returns an array of three groups" do
expect(stage.groups).to be_a Array
expect(stage.groups).to all(be_a described_class)
expect(stage.groups.size).to eq 3
end
- it 'returns groups with correctly ordered statuses' do
+ it "returns groups with correctly ordered statuses" do
expect(stage.groups.first.jobs.map(&:name))
- .to eq ['aaaaa']
+ .to eq ["aaaaa"]
expect(stage.groups.second.jobs.map(&:name))
- .to eq ['rspec 0 1', 'rspec 0 2']
+ .to eq ["rspec 0 1", "rspec 0 2"]
expect(stage.groups.third.jobs.map(&:name))
- .to eq ['spinach 0 1']
+ .to eq ["spinach 0 1"]
end
- it 'returns groups with correct names' do
+ it "returns groups with correct names" do
expect(stage.groups.map(&:name))
.to eq %w[aaaaa rspec spinach]
end
- context 'when a name is nil on legacy pipelines' do
+ context "when a name is nil on legacy pipelines" do
before do
pipeline.builds.first.update_attribute(:name, nil)
end
- it 'returns an array of three groups' do
+ it "returns an array of three groups" do
expect(stage.groups.map(&:name))
- .to eq ['', 'aaaaa', 'rspec', 'spinach']
+ .to eq ["", "aaaaa", "rspec", "spinach"]
end
end
- def create_build(type, status: 'success', **opts)
+ def create_build(type, status: "success", **opts)
create(type, pipeline: pipeline,
stage: stage.name,
status: status,
diff --git a/spec/models/ci/group_variable_spec.rb b/spec/models/ci/group_variable_spec.rb
index 21d96bf3454..5ae52c793a4 100644
--- a/spec/models/ci/group_variable_spec.rb
+++ b/spec/models/ci/group_variable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::GroupVariable do
subject { build(:ci_group_variable) }
@@ -8,23 +8,23 @@ describe Ci::GroupVariable do
it { is_expected.to include_module(Maskable) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:group_id).with_message(/\(\w+\) has already been taken/) }
- describe '.unprotected' do
+ describe ".unprotected" do
subject { described_class.unprotected }
- context 'when variable is protected' do
+ context "when variable is protected" do
before do
create(:ci_group_variable, :protected)
end
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
- context 'when variable is not protected' do
+ context "when variable is not protected" do
let(:variable) { create(:ci_group_variable, protected: false) }
- it 'returns the variable' do
+ it "returns the variable" do
is_expected.to contain_exactly(variable)
end
end
diff --git a/spec/models/ci/job_artifact_spec.rb b/spec/models/ci/job_artifact_spec.rb
index c68ba02b8de..45b153f5d8a 100644
--- a/spec/models/ci/job_artifact_spec.rb
+++ b/spec/models/ci/job_artifact_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::JobArtifact do
let(:artifact) { create(:ci_job_artifact, :archive) }
@@ -15,75 +15,75 @@ describe Ci::JobArtifact do
it { is_expected.to delegate_method(:open).to(:file) }
it { is_expected.to delegate_method(:exists?).to(:file) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe '.test_reports' do
+ describe ".test_reports" do
subject { described_class.test_reports }
- context 'when there is a test report' do
+ context "when there is a test report" do
let!(:artifact) { create(:ci_job_artifact, :junit) }
it { is_expected.to eq([artifact]) }
end
- context 'when there are no test reports' do
+ context "when there are no test reports" do
let!(:artifact) { create(:ci_job_artifact, :archive) }
it { is_expected.to be_empty }
end
end
- describe '.erasable' do
+ describe ".erasable" do
subject { described_class.erasable }
- context 'when there is an erasable artifact' do
+ context "when there is an erasable artifact" do
let!(:artifact) { create(:ci_job_artifact, :junit) }
it { is_expected.to eq([artifact]) }
end
- context 'when there are no erasable artifacts' do
+ context "when there are no erasable artifacts" do
let!(:artifact) { create(:ci_job_artifact, :trace) }
it { is_expected.to be_empty }
end
end
- describe 'callbacks' do
+ describe "callbacks" do
subject { create(:ci_job_artifact, :archive) }
- describe '#schedule_background_upload' do
- context 'when object storage is disabled' do
+ describe "#schedule_background_upload" do
+ context "when object storage is disabled" do
before do
stub_artifacts_object_storage(enabled: false)
end
- it 'does not schedule the migration' do
+ it "does not schedule the migration" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
subject
end
end
- context 'when object storage is enabled' do
- context 'when background upload is enabled' do
+ context "when object storage is enabled" do
+ context "when background upload is enabled" do
before do
stub_artifacts_object_storage(background_upload: true)
end
- it 'schedules the model for migration' do
- expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with('JobArtifactUploader', described_class.name, :file, kind_of(Numeric))
+ it "schedules the model for migration" do
+ expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with("JobArtifactUploader", described_class.name, :file, kind_of(Numeric))
subject
end
end
- context 'when background upload is disabled' do
+ context "when background upload is disabled" do
before do
stub_artifacts_object_storage(background_upload: false)
end
- it 'schedules the model for migration' do
+ it "schedules the model for migration" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
subject
@@ -93,35 +93,35 @@ describe Ci::JobArtifact do
end
end
- context 'creating the artifact' do
+ context "creating the artifact" do
let(:project) { create(:project) }
let(:artifact) { create(:ci_job_artifact, :archive, project: project) }
- it 'sets the size from the file size' do
+ it "sets the size from the file size" do
expect(artifact.size).to eq(106365)
end
- it 'updates the project statistics' do
+ it "updates the project statistics" do
expect { artifact }
.to change { project.statistics.reload.build_artifacts_size }
.by(106365)
end
end
- context 'updating the artifact file' do
- it 'updates the artifact size' do
- artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png'))
+ context "updating the artifact file" do
+ it "updates the artifact size" do
+ artifact.update!(file: fixture_file_upload("spec/fixtures/dk.png"))
expect(artifact.size).to eq(1062)
end
- it 'updates the project statistics' do
- expect { artifact.update!(file: fixture_file_upload('spec/fixtures/dk.png')) }
+ it "updates the project statistics" do
+ expect { artifact.update!(file: fixture_file_upload("spec/fixtures/dk.png")) }
.to change { artifact.project.statistics.reload.build_artifacts_size }
.by(1062 - 106365)
end
end
- describe 'validates file format' do
+ describe "validates file format" do
subject { artifact }
described_class::TYPE_AND_FORMAT_PAIRS.except(:trace).each do |file_type, file_format|
@@ -147,7 +147,7 @@ describe Ci::JobArtifact do
end
end
- describe 'validates DEFAULT_FILE_NAMES' do
+ describe "validates DEFAULT_FILE_NAMES" do
subject { described_class::DEFAULT_FILE_NAMES }
described_class.file_types.each do |file_type, _|
@@ -157,7 +157,7 @@ describe Ci::JobArtifact do
end
end
- describe 'validates TYPE_AND_FORMAT_PAIRS' do
+ describe "validates TYPE_AND_FORMAT_PAIRS" do
subject { described_class::TYPE_AND_FORMAT_PAIRS }
described_class.file_types.each do |file_type, _|
@@ -167,58 +167,58 @@ describe Ci::JobArtifact do
end
end
- describe '#file' do
+ describe "#file" do
subject { artifact.file }
- context 'the uploader api' do
+ context "the uploader api" do
it { is_expected.to respond_to(:store_dir) }
it { is_expected.to respond_to(:cache_dir) }
it { is_expected.to respond_to(:work_dir) }
end
end
- describe '#each_blob' do
- context 'when file format is gzip' do
- context 'when gzip file contains one file' do
+ describe "#each_blob" do
+ context "when file format is gzip" do
+ context "when gzip file contains one file" do
let(:artifact) { build(:ci_job_artifact, :junit) }
- it 'iterates blob once' do
+ it "iterates blob once" do
expect { |b| artifact.each_blob(&b) }.to yield_control.once
end
end
- context 'when gzip file contains three files' do
+ context "when gzip file contains three files" do
let(:artifact) { build(:ci_job_artifact, :junit_with_three_testsuites) }
- it 'iterates blob three times' do
+ it "iterates blob three times" do
expect { |b| artifact.each_blob(&b) }.to yield_control.exactly(3).times
end
end
end
- context 'when file format is raw' do
+ context "when file format is raw" do
let(:artifact) { build(:ci_job_artifact, :codequality, file_format: :raw) }
- it 'iterates blob once' do
+ it "iterates blob once" do
expect { |b| artifact.each_blob(&b) }.to yield_control.once
end
end
- context 'when there are no adapters for the file format' do
+ context "when there are no adapters for the file format" do
let(:artifact) { build(:ci_job_artifact, :junit, file_format: :zip) }
- it 'raises an error' do
+ it "raises an error" do
expect { |b| artifact.each_blob(&b) }.to raise_error(described_class::NotSupportedAdapterError)
end
end
end
- describe '#expire_in' do
+ describe "#expire_in" do
subject { artifact.expire_in }
it { is_expected.to be_nil }
- context 'when expire_at is specified' do
+ context "when expire_at is specified" do
let(:expire_at) { Time.now + 7.days }
before do
@@ -229,40 +229,40 @@ describe Ci::JobArtifact do
end
end
- describe '#expire_in=' do
+ describe "#expire_in=" do
subject { artifact.expire_in }
- it 'when assigning valid duration' do
- artifact.expire_in = '7 days'
+ it "when assigning valid duration" do
+ artifact.expire_in = "7 days"
is_expected.to be_within(10).of(7.days.to_i)
end
- it 'when assigning invalid duration' do
- expect { artifact.expire_in = '7 elephants' }.to raise_error(ChronicDuration::DurationParseError)
+ it "when assigning invalid duration" do
+ expect { artifact.expire_in = "7 elephants" }.to raise_error(ChronicDuration::DurationParseError)
is_expected.to be_nil
end
- it 'when resetting value' do
+ it "when resetting value" do
artifact.expire_in = nil
is_expected.to be_nil
end
- it 'when setting to 0' do
- artifact.expire_in = '0'
+ it "when setting to 0" do
+ artifact.expire_in = "0"
is_expected.to be_nil
end
end
- context 'when destroying the artifact' do
+ context "when destroying the artifact" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
- it 'updates the project statistics' do
+ it "updates the project statistics" do
artifact = build.job_artifacts.first
expect(ProjectStatistics)
@@ -274,8 +274,8 @@ describe Ci::JobArtifact do
.by(-106365)
end
- context 'when it is destroyed from the project level' do
- it 'does not update the project statistics' do
+ context "when it is destroyed from the project level" do
+ it "does not update the project statistics" do
expect(ProjectStatistics)
.not_to receive(:increment_statistic)
@@ -285,37 +285,37 @@ describe Ci::JobArtifact do
end
end
- describe 'file is being stored' do
+ describe "file is being stored" do
subject { create(:ci_job_artifact, :archive) }
- context 'when object has nil store' do
+ context "when object has nil store" do
before do
subject.update_column(:file_store, nil)
subject.reload
end
- it 'is stored locally' do
+ it "is stored locally" do
expect(subject.file_store).to be(nil)
expect(subject.file).to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::LOCAL)
end
end
- context 'when existing object has local store' do
- it 'is stored locally' do
+ context "when existing object has local store" do
+ it "is stored locally" do
expect(subject.file_store).to be(ObjectStorage::Store::LOCAL)
expect(subject.file).to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::LOCAL)
end
end
- context 'when direct upload is enabled' do
+ context "when direct upload is enabled" do
before do
stub_artifacts_object_storage(direct_upload: true)
end
- context 'when file is stored' do
- it 'is stored remotely' do
+ context "when file is stored" do
+ it "is stored remotely" do
expect(subject.file_store).to eq(ObjectStorage::Store::REMOTE)
expect(subject.file).not_to be_file_storage
expect(subject.file.object_store).to eq(ObjectStorage::Store::REMOTE)
diff --git a/spec/models/ci/legacy_stage_spec.rb b/spec/models/ci/legacy_stage_spec.rb
index 0c33c1466b7..74866845dae 100644
--- a/spec/models/ci/legacy_stage_spec.rb
+++ b/spec/models/ci/legacy_stage_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::LegacyStage do
let(:stage) { build(:ci_stage) }
let(:pipeline) { stage.pipeline }
let(:stage_name) { stage.name }
- describe '#expectations' do
+ describe "#expectations" do
subject { stage }
it { is_expected.to include_module(StaticModel) }
@@ -16,10 +16,10 @@ describe Ci::LegacyStage do
it { is_expected.to delegate_method(:project).to(:pipeline) }
end
- describe '#statuses' do
+ describe "#statuses" do
let!(:stage_build) { create_job(:ci_build) }
let!(:commit_status) { create_job(:commit_status) }
- let!(:other_build) { create_job(:ci_build, stage: 'other stage') }
+ let!(:other_build) { create_job(:ci_build, stage: "other stage") }
subject { stage.statuses }
@@ -28,50 +28,50 @@ describe Ci::LegacyStage do
end
end
- describe '#groups' do
+ describe "#groups" do
before do
- create_job(:ci_build, name: 'rspec 0 2')
- create_job(:ci_build, name: 'rspec 0 1')
- create_job(:ci_build, name: 'spinach 0 1')
- create_job(:commit_status, name: 'aaaaa')
+ create_job(:ci_build, name: "rspec 0 2")
+ create_job(:ci_build, name: "rspec 0 1")
+ create_job(:ci_build, name: "spinach 0 1")
+ create_job(:commit_status, name: "aaaaa")
end
- it 'returns an array of three groups' do
+ it "returns an array of three groups" do
expect(stage.groups).to be_a Array
expect(stage.groups).to all(be_a Ci::Group)
expect(stage.groups.size).to eq 3
end
- it 'returns groups with correctly ordered statuses' do
+ it "returns groups with correctly ordered statuses" do
expect(stage.groups.first.jobs.map(&:name))
- .to eq ['aaaaa']
+ .to eq ["aaaaa"]
expect(stage.groups.second.jobs.map(&:name))
- .to eq ['rspec 0 1', 'rspec 0 2']
+ .to eq ["rspec 0 1", "rspec 0 2"]
expect(stage.groups.third.jobs.map(&:name))
- .to eq ['spinach 0 1']
+ .to eq ["spinach 0 1"]
end
- it 'returns groups with correct names' do
+ it "returns groups with correct names" do
expect(stage.groups.map(&:name))
.to eq %w[aaaaa rspec spinach]
end
- context 'when a name is nil on legacy pipelines' do
+ context "when a name is nil on legacy pipelines" do
before do
pipeline.builds.first.update_attribute(:name, nil)
end
- it 'returns an array of three groups' do
+ it "returns an array of three groups" do
expect(stage.groups.map(&:name))
- .to eq ['', 'aaaaa', 'rspec', 'spinach']
+ .to eq ["", "aaaaa", "rspec", "spinach"]
end
end
end
- describe '#statuses_count' do
+ describe "#statuses_count" do
before do
create_job(:ci_build)
- create_job(:ci_build, stage: 'other stage')
+ create_job(:ci_build, stage: "other stage")
end
subject { stage.statuses_count }
@@ -81,7 +81,7 @@ describe Ci::LegacyStage do
end
end
- describe '#builds' do
+ describe "#builds" do
let!(:stage_build) { create_job(:ci_build) }
let!(:commit_status) { create_job(:commit_status) }
@@ -92,25 +92,25 @@ describe Ci::LegacyStage do
end
end
- describe '#status' do
+ describe "#status" do
subject { stage.status }
- context 'if status is already defined' do
- let(:stage) { build(:ci_stage, status: 'success') }
+ context "if status is already defined" do
+ let(:stage) { build(:ci_stage, status: "success") }
it "returns defined status" do
- is_expected.to eq('success')
+ is_expected.to eq("success")
end
end
- context 'if status has to be calculated' do
+ context "if status has to be calculated" do
let!(:stage_build) { create_job(:ci_build, status: :failed) }
it "returns status of a build" do
- is_expected.to eq('failed')
+ is_expected.to eq("failed")
end
- context 'and builds are retried' do
+ context "and builds are retried" do
let!(:new_build) { create_job(:ci_build, status: :success) }
before do
@@ -118,156 +118,156 @@ describe Ci::LegacyStage do
end
it "returns status of latest build" do
- is_expected.to eq('success')
+ is_expected.to eq("success")
end
end
end
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
let(:user) { create(:user) }
subject { stage.detailed_status(user) }
- context 'when build is created' do
+ context "when build is created" do
let!(:stage_build) { create_job(:ci_build, status: :created) }
- it 'returns detailed status for created stage' do
- expect(subject.text).to eq 'created'
+ it "returns detailed status for created stage" do
+ expect(subject.text).to eq "created"
end
end
- context 'when build is pending' do
+ context "when build is pending" do
let!(:stage_build) { create_job(:ci_build, status: :pending) }
- it 'returns detailed status for pending stage' do
- expect(subject.text).to eq 'pending'
+ it "returns detailed status for pending stage" do
+ expect(subject.text).to eq "pending"
end
end
- context 'when build is running' do
+ context "when build is running" do
let!(:stage_build) { create_job(:ci_build, status: :running) }
- it 'returns detailed status for running stage' do
- expect(subject.text).to eq 'running'
+ it "returns detailed status for running stage" do
+ expect(subject.text).to eq "running"
end
end
- context 'when build is successful' do
+ context "when build is successful" do
let!(:stage_build) { create_job(:ci_build, status: :success) }
- it 'returns detailed status for successful stage' do
- expect(subject.text).to eq 'passed'
+ it "returns detailed status for successful stage" do
+ expect(subject.text).to eq "passed"
end
end
- context 'when build is failed' do
+ context "when build is failed" do
let!(:stage_build) { create_job(:ci_build, status: :failed) }
- it 'returns detailed status for failed stage' do
- expect(subject.text).to eq 'failed'
+ it "returns detailed status for failed stage" do
+ expect(subject.text).to eq "failed"
end
end
- context 'when build is canceled' do
+ context "when build is canceled" do
let!(:stage_build) { create_job(:ci_build, status: :canceled) }
- it 'returns detailed status for canceled stage' do
- expect(subject.text).to eq 'canceled'
+ it "returns detailed status for canceled stage" do
+ expect(subject.text).to eq "canceled"
end
end
- context 'when build is skipped' do
+ context "when build is skipped" do
let!(:stage_build) { create_job(:ci_build, status: :skipped) }
- it 'returns detailed status for skipped stage' do
- expect(subject.text).to eq 'skipped'
+ it "returns detailed status for skipped stage" do
+ expect(subject.text).to eq "skipped"
end
end
end
- describe '#success?' do
- context 'when stage is successful' do
+ describe "#success?" do
+ context "when stage is successful" do
before do
create_job(:ci_build, status: :success)
create_job(:generic_commit_status, status: :success)
end
- it 'is successful' do
+ it "is successful" do
expect(stage).to be_success
end
end
- context 'when stage is not successful' do
+ context "when stage is not successful" do
before do
create_job(:ci_build, status: :failed)
create_job(:generic_commit_status, status: :success)
end
- it 'is not successful' do
+ it "is not successful" do
expect(stage).not_to be_success
end
end
end
- describe '#has_warnings?' do
- context 'when stage has warnings' do
- context 'when using memoized warnings flag' do
- context 'when there are warnings' do
+ describe "#has_warnings?" do
+ context "when stage has warnings" do
+ context "when using memoized warnings flag" do
+ context "when there are warnings" do
let(:stage) { build(:ci_stage, warnings: 2) }
- it 'returns true using memoized value' do
+ it "returns true using memoized value" do
expect(stage).not_to receive(:statuses)
expect(stage).to have_warnings
end
end
- context 'when there are no warnings' do
+ context "when there are no warnings" do
let(:stage) { build(:ci_stage, warnings: 0) }
- it 'returns false using memoized value' do
+ it "returns false using memoized value" do
expect(stage).not_to receive(:statuses)
expect(stage).not_to have_warnings
end
end
- context 'when number of warnings is not a valid value' do
+ context "when number of warnings is not a valid value" do
let(:stage) { build(:ci_stage, warnings: true) }
- it 'calculates statuses using database queries' do
+ it "calculates statuses using database queries" do
expect(stage).to receive(:statuses).and_call_original
expect(stage).not_to have_warnings
end
end
end
- context 'when calculating warnings from statuses' do
+ context "when calculating warnings from statuses" do
before do
create(:ci_build, :failed, :allowed_to_fail,
- stage: stage_name, pipeline: pipeline)
+ stage: stage_name, pipeline: pipeline)
end
- it 'has warnings calculated from statuses' do
+ it "has warnings calculated from statuses" do
expect(stage).to receive(:statuses).and_call_original
expect(stage).to have_warnings
end
end
end
- context 'when stage does not have warnings' do
+ context "when stage does not have warnings" do
before do
create(:ci_build, :success, stage: stage_name,
pipeline: pipeline)
end
- it 'does not have warnings calculated from statuses' do
+ it "does not have warnings calculated from statuses" do
expect(stage).to receive(:statuses).and_call_original
expect(stage).not_to have_warnings
end
end
end
- def create_job(type, status: 'success', stage: stage_name, **opts)
+ def create_job(type, status: "success", stage: stage_name, **opts)
create(type, pipeline: pipeline, stage: stage, status: status, **opts)
end
end
diff --git a/spec/models/ci/pipeline_schedule_spec.rb b/spec/models/ci/pipeline_schedule_spec.rb
index 8ee15f0e734..e48c71bd3a8 100644
--- a/spec/models/ci/pipeline_schedule_spec.rb
+++ b/spec/models/ci/pipeline_schedule_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelineSchedule do
it { is_expected.to belong_to(:project) }
@@ -13,21 +13,21 @@ describe Ci::PipelineSchedule do
it { is_expected.to respond_to(:description) }
it { is_expected.to respond_to(:next_run_at) }
- describe 'validations' do
- it 'does not allow invalid cron patters' do
- pipeline_schedule = build(:ci_pipeline_schedule, cron: '0 0 0 * *')
+ describe "validations" do
+ it "does not allow invalid cron patters" do
+ pipeline_schedule = build(:ci_pipeline_schedule, cron: "0 0 0 * *")
expect(pipeline_schedule).not_to be_valid
end
- it 'does not allow invalid cron patters' do
- pipeline_schedule = build(:ci_pipeline_schedule, cron_timezone: 'invalid')
+ it "does not allow invalid cron patters" do
+ pipeline_schedule = build(:ci_pipeline_schedule, cron_timezone: "invalid")
expect(pipeline_schedule).not_to be_valid
end
- context 'when active is false' do
- it 'does not allow nullified ref' do
+ context "when active is false" do
+ it "does not allow nullified ref" do
pipeline_schedule = build(:ci_pipeline_schedule, :inactive, ref: nil)
expect(pipeline_schedule).not_to be_valid
@@ -35,29 +35,29 @@ describe Ci::PipelineSchedule do
end
end
- describe '#set_next_run_at' do
+ describe "#set_next_run_at" do
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly) }
- context 'when creates new pipeline schedule' do
+ context "when creates new pipeline schedule" do
let(:expected_next_run_at) do
Gitlab::Ci::CronParser.new(pipeline_schedule.cron, pipeline_schedule.cron_timezone)
.next_time_from(Time.now)
end
- it 'updates next_run_at automatically' do
+ it "updates next_run_at automatically" do
expect(described_class.last.next_run_at).to eq(expected_next_run_at)
end
end
- context 'when updates cron of exsisted pipeline schedule' do
- let(:new_cron) { '0 0 1 1 *' }
+ context "when updates cron of exsisted pipeline schedule" do
+ let(:new_cron) { "0 0 1 1 *" }
let(:expected_next_run_at) do
Gitlab::Ci::CronParser.new(new_cron, pipeline_schedule.cron_timezone)
.next_time_from(Time.now)
end
- it 'updates next_run_at automatically' do
+ it "updates next_run_at automatically" do
pipeline_schedule.update!(cron: new_cron)
expect(described_class.last.next_run_at).to eq(expected_next_run_at)
@@ -65,10 +65,10 @@ describe Ci::PipelineSchedule do
end
end
- describe '#schedule_next_run!' do
+ describe "#schedule_next_run!" do
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly) }
- context 'when reschedules after 10 days from now' do
+ context "when reschedules after 10 days from now" do
let(:future_time) { 10.days.from_now }
let(:expected_next_run_at) do
@@ -76,7 +76,7 @@ describe Ci::PipelineSchedule do
.next_time_from(future_time)
end
- it 'points to proper next_run_at' do
+ it "points to proper next_run_at" do
Timecop.freeze(future_time) do
pipeline_schedule.schedule_next_run!
@@ -86,29 +86,29 @@ describe Ci::PipelineSchedule do
end
end
- describe '#real_next_run' do
+ describe "#real_next_run" do
subject do
described_class.last.real_next_run(worker_cron: worker_cron,
worker_time_zone: worker_time_zone)
end
- context 'when GitLab time_zone is UTC' do
+ context "when GitLab time_zone is UTC" do
before do
allow(Time).to receive(:zone)
.and_return(ActiveSupport::TimeZone[worker_time_zone])
end
- let(:worker_time_zone) { 'UTC' }
+ let(:worker_time_zone) { "UTC" }
- context 'when cron_timezone is Eastern Time (US & Canada)' do
+ context "when cron_timezone is Eastern Time (US & Canada)" do
before do
create(:ci_pipeline_schedule, :nightly,
- cron_timezone: 'Eastern Time (US & Canada)')
+ cron_timezone: "Eastern Time (US & Canada)")
end
- let(:worker_cron) { '0 1 2 3 *' }
+ let(:worker_cron) { "0 1 2 3 *" }
- it 'returns the next time worker executes' do
+ it "returns the next time worker executes" do
expect(subject.min).to eq(0)
expect(subject.hour).to eq(1)
expect(subject.day).to eq(2)
@@ -118,7 +118,7 @@ describe Ci::PipelineSchedule do
end
end
- describe '#job_variables' do
+ describe "#job_variables" do
let!(:pipeline_schedule) { create(:ci_pipeline_schedule) }
let!(:pipeline_schedule_variables) do
diff --git a/spec/models/ci/pipeline_schedule_variable_spec.rb b/spec/models/ci/pipeline_schedule_variable_spec.rb
index dc8427f28bc..dd29b8cb0b7 100644
--- a/spec/models/ci/pipeline_schedule_variable_spec.rb
+++ b/spec/models/ci/pipeline_schedule_variable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelineScheduleVariable do
subject { build(:ci_pipeline_schedule_variable) }
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb
index ee400bec04b..7c7b7bb32b2 100644
--- a/spec/models/ci/pipeline_spec.rb
+++ b/spec/models/ci/pipeline_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Pipeline, :mailer do
include ProjectForksHelper
@@ -10,7 +10,7 @@ describe Ci::Pipeline, :mailer do
create(:ci_empty_pipeline, status: :created, project: project)
end
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:user) }
@@ -34,29 +34,29 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to respond_to :short_sha }
it { is_expected.to delegate_method(:full_path).to(:project).with_prefix }
- describe 'associations' do
- it 'has a bidirectional relationship with projects' do
+ describe "associations" do
+ it "has a bidirectional relationship with projects" do
expect(described_class.reflect_on_association(:project).has_inverse?).to eq(:all_pipelines)
expect(Project.reflect_on_association(:all_pipelines).has_inverse?).to eq(:project)
expect(Project.reflect_on_association(:ci_pipelines).has_inverse?).to eq(:project)
end
end
- describe '.processables' do
+ describe ".processables" do
before do
- create(:ci_build, name: 'build', pipeline: pipeline)
- create(:ci_bridge, name: 'bridge', pipeline: pipeline)
- create(:commit_status, name: 'commit status', pipeline: pipeline)
- create(:generic_commit_status, name: 'generic status', pipeline: pipeline)
+ create(:ci_build, name: "build", pipeline: pipeline)
+ create(:ci_bridge, name: "bridge", pipeline: pipeline)
+ create(:commit_status, name: "commit status", pipeline: pipeline)
+ create(:generic_commit_status, name: "generic status", pipeline: pipeline)
end
- it 'has an association with processable CI/CD entities' do
- pipeline.processables.pluck('name').yield_self do |processables|
+ it "has an association with processable CI/CD entities" do
+ pipeline.processables.pluck("name").yield_self do |processables|
expect(processables).to match_array %w[build bridge]
end
end
- it 'makes it possible to append a new processable' do
+ it "makes it possible to append a new processable" do
pipeline.processables << build(:ci_bridge)
pipeline.save!
@@ -65,20 +65,20 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '.sort_by_merge_request_pipelines' do
+ describe ".sort_by_merge_request_pipelines" do
subject { described_class.sort_by_merge_request_pipelines }
- context 'when branch pipelines exist' do
+ context "when branch pipelines exist" do
let!(:branch_pipeline_1) { create(:ci_pipeline, source: :push) }
let!(:branch_pipeline_2) { create(:ci_pipeline, source: :push) }
- it 'returns pipelines order by id' do
+ it "returns pipelines order by id" do
expect(subject).to eq([branch_pipeline_2,
- branch_pipeline_1])
+ branch_pipeline_1,])
end
end
- context 'when merge request pipelines exist' do
+ context "when merge request pipelines exist" do
let!(:merge_request_pipeline_1) do
create(:ci_pipeline, source: :merge_request, merge_request: merge_request)
end
@@ -89,19 +89,19 @@ describe Ci::Pipeline, :mailer do
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'returns pipelines order by id' do
+ it "returns pipelines order by id" do
expect(subject).to eq([merge_request_pipeline_2,
- merge_request_pipeline_1])
+ merge_request_pipeline_1,])
end
end
- context 'when both branch pipeline and merge request pipeline exist' do
+ context "when both branch pipeline and merge request pipeline exist" do
let!(:branch_pipeline_1) { create(:ci_pipeline, source: :push) }
let!(:branch_pipeline_2) { create(:ci_pipeline, source: :push) }
@@ -115,22 +115,22 @@ describe Ci::Pipeline, :mailer do
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'returns merge request pipeline first' do
+ it "returns merge request pipeline first" do
expect(subject).to eq([merge_request_pipeline_2,
merge_request_pipeline_1,
branch_pipeline_2,
- branch_pipeline_1])
+ branch_pipeline_1,])
end
end
end
- describe '.detached_merge_request_pipelines' do
+ describe ".detached_merge_request_pipelines" do
subject { described_class.detached_merge_request_pipelines(merge_request) }
let!(:pipeline) do
@@ -140,20 +140,20 @@ describe Ci::Pipeline, :mailer do
let(:merge_request) { create(:merge_request) }
let(:target_sha) { nil }
- it 'returns detached merge request pipelines' do
+ it "returns detached merge request pipelines" do
is_expected.to eq([pipeline])
end
- context 'when target sha exists' do
+ context "when target sha exists" do
let(:target_sha) { merge_request.target_branch_sha }
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to be_empty
end
end
end
- describe '#detached_merge_request_pipeline?' do
+ describe "#detached_merge_request_pipeline?" do
subject { pipeline.detached_merge_request_pipeline? }
let!(:pipeline) do
@@ -165,14 +165,14 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to be_truthy }
- context 'when target sha exists' do
+ context "when target sha exists" do
let(:target_sha) { merge_request.target_branch_sha }
it { is_expected.to be_falsy }
end
end
- describe '.merge_request_pipelines' do
+ describe ".merge_request_pipelines" do
subject { described_class.merge_request_pipelines(merge_request) }
let!(:pipeline) do
@@ -182,20 +182,20 @@ describe Ci::Pipeline, :mailer do
let(:merge_request) { create(:merge_request) }
let(:target_sha) { merge_request.target_branch_sha }
- it 'returns merge pipelines' do
+ it "returns merge pipelines" do
is_expected.to eq([pipeline])
end
- context 'when target sha is empty' do
+ context "when target sha is empty" do
let(:target_sha) { nil }
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to be_empty
end
end
end
- describe '#merge_request_pipeline?' do
+ describe "#merge_request_pipeline?" do
subject { pipeline.merge_request_pipeline? }
let!(:pipeline) do
@@ -207,14 +207,14 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to be_truthy }
- context 'when target sha is empty' do
+ context "when target sha is empty" do
let(:target_sha) { nil }
it { is_expected.to be_falsy }
end
end
- describe '.mergeable_merge_request_pipelines' do
+ describe ".mergeable_merge_request_pipelines" do
subject { described_class.mergeable_merge_request_pipelines(merge_request) }
let!(:pipeline) do
@@ -224,20 +224,20 @@ describe Ci::Pipeline, :mailer do
let(:merge_request) { create(:merge_request) }
let(:target_sha) { merge_request.target_branch_sha }
- it 'returns mergeable merge pipelines' do
+ it "returns mergeable merge pipelines" do
is_expected.to eq([pipeline])
end
- context 'when target sha does not point the head of the target branch' do
+ context "when target sha does not point the head of the target branch" do
let(:target_sha) { merge_request.diff_head_sha }
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to be_empty
end
end
end
- describe '#mergeable_merge_request_pipeline?' do
+ describe "#mergeable_merge_request_pipeline?" do
subject { pipeline.mergeable_merge_request_pipeline? }
let!(:pipeline) do
@@ -249,63 +249,63 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to be_truthy }
- context 'when target sha does not point the head of the target branch' do
+ context "when target sha does not point the head of the target branch" do
let(:target_sha) { merge_request.diff_head_sha }
it { is_expected.to be_falsy }
end
end
- describe '.merge_request' do
+ describe ".merge_request" do
subject { described_class.merge_request }
- context 'when there is a merge request pipeline' do
+ context "when there is a merge request pipeline" do
let!(:pipeline) { create(:ci_pipeline, source: :merge_request, merge_request: merge_request) }
let(:merge_request) { create(:merge_request) }
- it 'returns merge request pipeline first' do
+ it "returns merge request pipeline first" do
expect(subject).to eq([pipeline])
end
end
- context 'when there are no merge request pipelines' do
+ context "when there are no merge request pipelines" do
let!(:pipeline) { create(:ci_pipeline, source: :push) }
- it 'returns empty array' do
+ it "returns empty array" do
expect(subject).to be_empty
end
end
end
- describe 'Validations for merge request pipelines' do
+ describe "Validations for merge request pipelines" do
let(:pipeline) { build(:ci_pipeline, source: source, merge_request: merge_request) }
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:source) { :merge_request }
- context 'when merge request is specified' do
- let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_project: project, target_branch: 'master') }
+ context "when merge request is specified" do
+ let(:merge_request) { create(:merge_request, source_project: project, source_branch: "feature", target_project: project, target_branch: "master") }
it { expect(pipeline).to be_valid }
end
- context 'when merge request is empty' do
+ context "when merge request is empty" do
let(:merge_request) { nil }
it { expect(pipeline).not_to be_valid }
end
end
- context 'when source is web' do
+ context "when source is web" do
let(:source) { :web }
- context 'when merge request is specified' do
- let(:merge_request) { create(:merge_request, source_project: project, source_branch: 'feature', target_project: project, target_branch: 'master') }
+ context "when merge request is specified" do
+ let(:merge_request) { create(:merge_request, source_project: project, source_branch: "feature", target_project: project, target_branch: "master") }
it { expect(pipeline).not_to be_valid }
end
- context 'when merge request is empty' do
+ context "when merge request is empty" do
let(:merge_request) { nil }
it { expect(pipeline).to be_valid }
@@ -313,18 +313,18 @@ describe Ci::Pipeline, :mailer do
end
end
- describe 'modules' do
- it_behaves_like 'AtomicInternalId', validate_presence: false do
+ describe "modules" do
+ it_behaves_like "AtomicInternalId", validate_presence: false do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:ci_pipeline) }
let(:scope) { :project }
- let(:scope_attrs) { { project: instance.project } }
+ let(:scope_attrs) { {project: instance.project} }
let(:usage) { :ci_pipelines }
end
end
- describe '#source' do
- context 'when creating new pipeline' do
+ describe "#source" do
+ context "when creating new pipeline" do
let(:pipeline) do
build(:ci_empty_pipeline, status: :created, project: project, source: nil)
end
@@ -334,7 +334,7 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when updating existing pipeline' do
+ context "when updating existing pipeline" do
before do
pipeline.update_attribute(:source, nil)
end
@@ -345,55 +345,55 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#block' do
- it 'changes pipeline status to manual' do
+ describe "#block" do
+ it "changes pipeline status to manual" do
expect(pipeline.block).to be true
expect(pipeline.reload).to be_manual
expect(pipeline.reload).to be_blocked
end
end
- describe '#delay' do
+ describe "#delay" do
subject { pipeline.delay }
let(:pipeline) { build(:ci_pipeline, status: :created) }
- it 'changes pipeline status to schedule' do
+ it "changes pipeline status to schedule" do
subject
expect(pipeline).to be_scheduled
end
end
- describe '#valid_commit_sha' do
- context 'commit.sha can not start with 00000000' do
+ describe "#valid_commit_sha" do
+ context "commit.sha can not start with 00000000" do
before do
- pipeline.sha = '0' * 40
+ pipeline.sha = "0" * 40
pipeline.valid_commit_sha
end
- it('commit errors should not be empty') { expect(pipeline.errors).not_to be_empty }
+ it("commit errors should not be empty") { expect(pipeline.errors).not_to be_empty }
end
end
- describe '#short_sha' do
+ describe "#short_sha" do
subject { pipeline.short_sha }
- it 'has 8 items' do
+ it "has 8 items" do
expect(subject.size).to eq(8)
end
it { expect(pipeline.sha).to start_with(subject) }
end
- describe '#retried' do
+ describe "#retried" do
subject { pipeline.retried }
before do
- @build1 = create(:ci_build, pipeline: pipeline, name: 'deploy', retried: true)
- @build2 = create(:ci_build, pipeline: pipeline, name: 'deploy')
+ @build1 = create(:ci_build, pipeline: pipeline, name: "deploy", retried: true)
+ @build2 = create(:ci_build, pipeline: pipeline, name: "deploy")
end
- it 'returns old builds' do
+ it "returns old builds" do
is_expected.to contain_exactly(@build1)
end
end
@@ -428,36 +428,36 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#retryable?' do
+ describe "#retryable?" do
subject { pipeline.retryable? }
- context 'no failed builds' do
+ context "no failed builds" do
before do
- create_build('rspec', 'success')
+ create_build("rspec", "success")
end
- it 'is not retryable' do
+ it "is not retryable" do
is_expected.to be_falsey
end
- context 'one canceled job' do
+ context "one canceled job" do
before do
- create_build('rubocop', 'canceled')
+ create_build("rubocop", "canceled")
end
- it 'is retryable' do
+ it "is retryable" do
is_expected.to be_truthy
end
end
end
- context 'with failed builds' do
+ context "with failed builds" do
before do
- create_build('rspec', 'running')
- create_build('rubocop', 'failed')
+ create_build("rspec", "running")
+ create_build("rubocop", "failed")
end
- it 'is retryable' do
+ it "is retryable" do
is_expected.to be_truthy
end
end
@@ -467,21 +467,21 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#persisted_variables' do
- context 'when pipeline is not persisted yet' do
+ describe "#persisted_variables" do
+ context "when pipeline is not persisted yet" do
subject { build(:ci_pipeline).persisted_variables }
- it 'does not contain some variables' do
+ it "does not contain some variables" do
keys = subject.map { |variable| variable[:key] }
- expect(keys).not_to include 'CI_PIPELINE_ID'
+ expect(keys).not_to include "CI_PIPELINE_ID"
end
end
- context 'when pipeline is persisted' do
+ context "when pipeline is persisted" do
subject { build_stubbed(:ci_pipeline).persisted_variables }
- it 'does contains persisted variables' do
+ it "does contains persisted variables" do
keys = subject.map { |variable| variable[:key] }
expect(keys).to eq %w[CI_PIPELINE_ID CI_PIPELINE_URL]
@@ -489,10 +489,10 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#predefined_variables' do
+ describe "#predefined_variables" do
subject { pipeline.predefined_variables }
- it 'includes all predefined variables in a valid order' do
+ it "includes all predefined variables in a valid order" do
keys = subject.map { |variable| variable[:key] }
expect(keys).to eq %w[CI_PIPELINE_IID
@@ -503,336 +503,338 @@ describe Ci::Pipeline, :mailer do
CI_COMMIT_DESCRIPTION]
end
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:pipeline) do
create(:ci_pipeline, source: :merge_request, merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'exposes merge request pipeline variables' do
+ it "exposes merge request pipeline variables" do
expect(subject.to_hash)
.to include(
- 'CI_MERGE_REQUEST_ID' => merge_request.id.to_s,
- 'CI_MERGE_REQUEST_IID' => merge_request.iid.to_s,
- 'CI_MERGE_REQUEST_REF_PATH' => merge_request.ref_path.to_s,
- 'CI_MERGE_REQUEST_PROJECT_ID' => merge_request.project.id.to_s,
- 'CI_MERGE_REQUEST_PROJECT_PATH' => merge_request.project.full_path,
- 'CI_MERGE_REQUEST_PROJECT_URL' => merge_request.project.web_url,
- 'CI_MERGE_REQUEST_TARGET_BRANCH_NAME' => merge_request.target_branch.to_s,
- 'CI_MERGE_REQUEST_TARGET_BRANCH_SHA' => pipeline.target_sha.to_s,
- 'CI_MERGE_REQUEST_SOURCE_PROJECT_ID' => merge_request.source_project.id.to_s,
- 'CI_MERGE_REQUEST_SOURCE_PROJECT_PATH' => merge_request.source_project.full_path,
- 'CI_MERGE_REQUEST_SOURCE_PROJECT_URL' => merge_request.source_project.web_url,
- 'CI_MERGE_REQUEST_SOURCE_BRANCH_NAME' => merge_request.source_branch.to_s,
- 'CI_MERGE_REQUEST_SOURCE_BRANCH_SHA' => pipeline.source_sha.to_s)
- end
-
- context 'when source project does not exist' do
+ "CI_MERGE_REQUEST_ID" => merge_request.id.to_s,
+ "CI_MERGE_REQUEST_IID" => merge_request.iid.to_s,
+ "CI_MERGE_REQUEST_REF_PATH" => merge_request.ref_path.to_s,
+ "CI_MERGE_REQUEST_PROJECT_ID" => merge_request.project.id.to_s,
+ "CI_MERGE_REQUEST_PROJECT_PATH" => merge_request.project.full_path,
+ "CI_MERGE_REQUEST_PROJECT_URL" => merge_request.project.web_url,
+ "CI_MERGE_REQUEST_TARGET_BRANCH_NAME" => merge_request.target_branch.to_s,
+ "CI_MERGE_REQUEST_TARGET_BRANCH_SHA" => pipeline.target_sha.to_s,
+ "CI_MERGE_REQUEST_SOURCE_PROJECT_ID" => merge_request.source_project.id.to_s,
+ "CI_MERGE_REQUEST_SOURCE_PROJECT_PATH" => merge_request.source_project.full_path,
+ "CI_MERGE_REQUEST_SOURCE_PROJECT_URL" => merge_request.source_project.web_url,
+ "CI_MERGE_REQUEST_SOURCE_BRANCH_NAME" => merge_request.source_branch.to_s,
+ "CI_MERGE_REQUEST_SOURCE_BRANCH_SHA" => pipeline.source_sha.to_s
+ )
+ end
+
+ context "when source project does not exist" do
before do
merge_request.update_column(:source_project_id, nil)
end
- it 'does not expose source project related variables' do
+ it "does not expose source project related variables" do
expect(subject.to_hash.keys).not_to include(
%w[CI_MERGE_REQUEST_SOURCE_PROJECT_ID
CI_MERGE_REQUEST_SOURCE_PROJECT_PATH
CI_MERGE_REQUEST_SOURCE_PROJECT_URL
- CI_MERGE_REQUEST_SOURCE_BRANCH_NAME])
+ CI_MERGE_REQUEST_SOURCE_BRANCH_NAME]
+ )
end
end
end
end
- describe '#protected_ref?' do
+ describe "#protected_ref?" do
before do
pipeline.project = create(:project, :repository)
end
- it 'delegates method to project' do
+ it "delegates method to project" do
expect(pipeline).not_to be_protected_ref
end
end
- describe '#legacy_trigger' do
+ describe "#legacy_trigger" do
let(:trigger_request) { create(:ci_trigger_request) }
before do
pipeline.trigger_requests << trigger_request
end
- it 'returns first trigger request' do
+ it "returns first trigger request" do
expect(pipeline.legacy_trigger).to eq trigger_request
end
end
- describe '#auto_canceled?' do
+ describe "#auto_canceled?" do
subject { pipeline.auto_canceled? }
- context 'when it is canceled' do
+ context "when it is canceled" do
before do
pipeline.cancel
end
- context 'when there is auto_canceled_by' do
+ context "when there is auto_canceled_by" do
before do
pipeline.update(auto_canceled_by: create(:ci_empty_pipeline))
end
- it 'is auto canceled' do
+ it "is auto canceled" do
is_expected.to be_truthy
end
end
- context 'when there is no auto_canceled_by' do
- it 'is not auto canceled' do
+ context "when there is no auto_canceled_by" do
+ it "is not auto canceled" do
is_expected.to be_falsey
end
end
- context 'when it is retried and canceled manually' do
+ context "when it is retried and canceled manually" do
before do
pipeline.enqueue
pipeline.cancel
end
- it 'is not auto canceled' do
+ it "is not auto canceled" do
is_expected.to be_falsey
end
end
end
end
- describe 'pipeline stages' do
- describe '#stage_seeds' do
+ describe "pipeline stages" do
+ describe "#stage_seeds" do
let(:pipeline) { build(:ci_pipeline, config: config) }
- let(:config) { { rspec: { script: 'rake' } } }
+ let(:config) { {rspec: {script: "rake"}} }
- it 'returns preseeded stage seeds object' do
+ it "returns preseeded stage seeds object" do
expect(pipeline.stage_seeds)
.to all(be_a Gitlab::Ci::Pipeline::Seed::Base)
expect(pipeline.stage_seeds.count).to eq 1
end
- context 'when no refs policy is specified' do
+ context "when no refs policy is specified" do
let(:config) do
- { production: { stage: 'deploy', script: 'cap prod' },
- rspec: { stage: 'test', script: 'rspec' },
- spinach: { stage: 'test', script: 'spinach' } }
+ {production: {stage: "deploy", script: "cap prod"},
+ rspec: {stage: "test", script: "rspec"},
+ spinach: {stage: "test", script: "spinach"},}
end
- it 'correctly fabricates a stage seeds object' do
+ it "correctly fabricates a stage seeds object" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 2
- expect(seeds.first.attributes[:name]).to eq 'test'
- expect(seeds.second.attributes[:name]).to eq 'deploy'
- expect(seeds.dig(0, 0, :name)).to eq 'rspec'
- expect(seeds.dig(0, 1, :name)).to eq 'spinach'
- expect(seeds.dig(1, 0, :name)).to eq 'production'
+ expect(seeds.first.attributes[:name]).to eq "test"
+ expect(seeds.second.attributes[:name]).to eq "deploy"
+ expect(seeds.dig(0, 0, :name)).to eq "rspec"
+ expect(seeds.dig(0, 1, :name)).to eq "spinach"
+ expect(seeds.dig(1, 0, :name)).to eq "production"
end
end
- context 'when refs policy is specified' do
+ context "when refs policy is specified" do
let(:pipeline) do
- build(:ci_pipeline, ref: 'feature', tag: true, config: config)
+ build(:ci_pipeline, ref: "feature", tag: true, config: config)
end
let(:config) do
- { production: { stage: 'deploy', script: 'cap prod', only: ['master'] },
- spinach: { stage: 'test', script: 'spinach', only: ['tags'] } }
+ {production: {stage: "deploy", script: "cap prod", only: ["master"]},
+ spinach: {stage: "test", script: "spinach", only: ["tags"]},}
end
- it 'returns stage seeds only assigned to master to master' do
+ it "returns stage seeds only assigned to master to master" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 1
- expect(seeds.first.attributes[:name]).to eq 'test'
- expect(seeds.dig(0, 0, :name)).to eq 'spinach'
+ expect(seeds.first.attributes[:name]).to eq "test"
+ expect(seeds.dig(0, 0, :name)).to eq "spinach"
end
end
- context 'when source policy is specified' do
+ context "when source policy is specified" do
let(:pipeline) { build(:ci_pipeline, source: :schedule, config: config) }
let(:config) do
- { production: { stage: 'deploy', script: 'cap prod', only: ['triggers'] },
- spinach: { stage: 'test', script: 'spinach', only: ['schedules'] } }
+ {production: {stage: "deploy", script: "cap prod", only: ["triggers"]},
+ spinach: {stage: "test", script: "spinach", only: ["schedules"]},}
end
- it 'returns stage seeds only assigned to schedules' do
+ it "returns stage seeds only assigned to schedules" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 1
- expect(seeds.first.attributes[:name]).to eq 'test'
- expect(seeds.dig(0, 0, :name)).to eq 'spinach'
+ expect(seeds.first.attributes[:name]).to eq "test"
+ expect(seeds.dig(0, 0, :name)).to eq "spinach"
end
end
- context 'when kubernetes policy is specified' do
+ context "when kubernetes policy is specified" do
let(:config) do
{
- spinach: { stage: 'test', script: 'spinach' },
+ spinach: {stage: "test", script: "spinach"},
production: {
- stage: 'deploy',
- script: 'cap',
- only: { kubernetes: 'active' }
- }
+ stage: "deploy",
+ script: "cap",
+ only: {kubernetes: "active"},
+ },
}
end
- context 'when kubernetes is active' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'returns seeds for kubernetes dependent job' do
+ context "when kubernetes is active" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "returns seeds for kubernetes dependent job" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 2
- expect(seeds.dig(0, 0, :name)).to eq 'spinach'
- expect(seeds.dig(1, 0, :name)).to eq 'production'
+ expect(seeds.dig(0, 0, :name)).to eq "spinach"
+ expect(seeds.dig(1, 0, :name)).to eq "production"
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
let(:pipeline) { build(:ci_pipeline, project: project, config: config) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'when kubernetes is not active' do
- it 'does not return seeds for kubernetes dependent job' do
+ context "when kubernetes is not active" do
+ it "does not return seeds for kubernetes dependent job" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 1
- expect(seeds.dig(0, 0, :name)).to eq 'spinach'
+ expect(seeds.dig(0, 0, :name)).to eq "spinach"
end
end
end
- context 'when variables policy is specified' do
+ context "when variables policy is specified" do
let(:config) do
- { unit: { script: 'minitest', only: { variables: ['$CI_PIPELINE_SOURCE'] } },
- feature: { script: 'spinach', only: { variables: ['$UNDEFINED'] } } }
+ {unit: {script: "minitest", only: {variables: ["$CI_PIPELINE_SOURCE"]}},
+ feature: {script: "spinach", only: {variables: ["$UNDEFINED"]}},}
end
- it 'returns stage seeds only when variables expression is truthy' do
+ it "returns stage seeds only when variables expression is truthy" do
seeds = pipeline.stage_seeds
expect(seeds.size).to eq 1
- expect(seeds.dig(0, 0, :name)).to eq 'unit'
+ expect(seeds.dig(0, 0, :name)).to eq "unit"
end
end
end
- describe '#seeds_size' do
- context 'when refs policy is specified' do
+ describe "#seeds_size" do
+ context "when refs policy is specified" do
let(:config) do
- { production: { stage: 'deploy', script: 'cap prod', only: ['master'] },
- spinach: { stage: 'test', script: 'spinach', only: ['tags'] } }
+ {production: {stage: "deploy", script: "cap prod", only: ["master"]},
+ spinach: {stage: "test", script: "spinach", only: ["tags"]},}
end
let(:pipeline) do
- build(:ci_pipeline, ref: 'feature', tag: true, config: config)
+ build(:ci_pipeline, ref: "feature", tag: true, config: config)
end
- it 'returns real seeds size' do
+ it "returns real seeds size" do
expect(pipeline.seeds_size).to eq 1
end
end
end
- describe 'legacy stages' do
+ describe "legacy stages" do
before do
create(:commit_status, pipeline: pipeline,
- stage: 'build',
- name: 'linux',
+ stage: "build",
+ name: "linux",
stage_idx: 0,
- status: 'success')
+ status: "success")
create(:commit_status, pipeline: pipeline,
- stage: 'build',
- name: 'mac',
+ stage: "build",
+ name: "mac",
stage_idx: 0,
- status: 'failed')
+ status: "failed")
create(:commit_status, pipeline: pipeline,
- stage: 'deploy',
- name: 'staging',
+ stage: "deploy",
+ name: "staging",
stage_idx: 2,
- status: 'running')
+ status: "running")
create(:commit_status, pipeline: pipeline,
- stage: 'test',
- name: 'rspec',
+ stage: "test",
+ name: "rspec",
stage_idx: 1,
- status: 'success')
+ status: "success")
end
- describe '#legacy_stages' do
+ describe "#legacy_stages" do
subject { pipeline.legacy_stages }
- context 'stages list' do
- it 'returns ordered list of stages' do
+ context "stages list" do
+ it "returns ordered list of stages" do
expect(subject.map(&:name)).to eq(%w[build test deploy])
end
end
- context 'stages with statuses' do
+ context "stages with statuses" do
let(:statuses) do
subject.map { |stage| [stage.name, stage.status] }
end
- it 'returns list of stages with correct statuses' do
- expect(statuses).to eq([%w(build failed),
- %w(test success),
- %w(deploy running)])
+ it "returns list of stages with correct statuses" do
+ expect(statuses).to eq([%w[build failed],
+ %w[test success],
+ %w[deploy running],])
end
- context 'when commit status is retried' do
+ context "when commit status is retried" do
before do
create(:commit_status, pipeline: pipeline,
- stage: 'build',
- name: 'mac',
+ stage: "build",
+ name: "mac",
stage_idx: 0,
- status: 'success')
+ status: "success")
pipeline.process!
end
- it 'ignores the previous state' do
- expect(statuses).to eq([%w(build success),
- %w(test success),
- %w(deploy running)])
+ it "ignores the previous state" do
+ expect(statuses).to eq([%w[build success],
+ %w[test success],
+ %w[deploy running],])
end
end
end
- context 'when there is a stage with warnings' do
+ context "when there is a stage with warnings" do
before do
create(:commit_status, pipeline: pipeline,
- stage: 'deploy',
- name: 'prod:2',
+ stage: "deploy",
+ name: "prod:2",
stage_idx: 2,
- status: 'failed',
+ status: "failed",
allow_failure: true)
end
- it 'populates stage with correct number of warnings' do
+ it "populates stage with correct number of warnings" do
deploy_stage = pipeline.legacy_stages.third
expect(deploy_stage).not_to receive(:statuses)
@@ -841,116 +843,116 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#stages_count' do
- it 'returns a valid number of stages' do
+ describe "#stages_count" do
+ it "returns a valid number of stages" do
expect(pipeline.stages_count).to eq(3)
end
end
- describe '#stages_names' do
- it 'returns a valid names of stages' do
- expect(pipeline.stages_names).to eq(%w(build test deploy))
+ describe "#stages_names" do
+ it "returns a valid names of stages" do
+ expect(pipeline.stages_names).to eq(%w[build test deploy])
end
end
end
- describe '#legacy_stage' do
- subject { pipeline.legacy_stage('test') }
+ describe "#legacy_stage" do
+ subject { pipeline.legacy_stage("test") }
- context 'with status in stage' do
+ context "with status in stage" do
before do
- create(:commit_status, pipeline: pipeline, stage: 'test')
+ create(:commit_status, pipeline: pipeline, stage: "test")
end
it { expect(subject).to be_a Ci::LegacyStage }
- it { expect(subject.name).to eq 'test' }
+ it { expect(subject.name).to eq "test" }
it { expect(subject.statuses).not_to be_empty }
end
- context 'without status in stage' do
+ context "without status in stage" do
before do
- create(:commit_status, pipeline: pipeline, stage: 'build')
+ create(:commit_status, pipeline: pipeline, stage: "build")
end
- it 'return stage object' do
+ it "return stage object" do
is_expected.to be_nil
end
end
end
- describe '#stages' do
+ describe "#stages" do
before do
create(:ci_stage_entity, project: project,
pipeline: pipeline,
- name: 'build')
+ name: "build")
end
- it 'returns persisted stages' do
+ it "returns persisted stages" do
expect(pipeline.stages).not_to be_empty
expect(pipeline.stages).to all(be_persisted)
end
end
- describe '#ordered_stages' do
+ describe "#ordered_stages" do
before do
create(:ci_stage_entity, project: project,
pipeline: pipeline,
position: 4,
- name: 'deploy')
+ name: "deploy")
create(:ci_build, project: project,
pipeline: pipeline,
- stage: 'test',
+ stage: "test",
stage_idx: 3,
- name: 'test')
+ name: "test")
create(:ci_build, project: project,
pipeline: pipeline,
- stage: 'build',
+ stage: "build",
stage_idx: 2,
- name: 'build')
+ name: "build")
create(:ci_stage_entity, project: project,
pipeline: pipeline,
position: 1,
- name: 'sanity')
+ name: "sanity")
create(:ci_stage_entity, project: project,
pipeline: pipeline,
position: 5,
- name: 'cleanup')
+ name: "cleanup")
end
subject { pipeline.ordered_stages }
- context 'when using legacy stages' do
+ context "when using legacy stages" do
before do
stub_feature_flags(ci_pipeline_persisted_stages: false)
end
- it 'returns legacy stages in valid order' do
+ it "returns legacy stages in valid order" do
expect(subject.map(&:name)).to eq %w[build test]
end
end
- context 'when using persisted stages' do
+ context "when using persisted stages" do
before do
stub_feature_flags(ci_pipeline_persisted_stages: true)
end
- context 'when pipelines is not complete' do
- it 'still returns legacy stages' do
+ context "when pipelines is not complete" do
+ it "still returns legacy stages" do
expect(subject).to all(be_a Ci::LegacyStage)
expect(subject.map(&:name)).to eq %w[build test]
end
end
- context 'when pipeline is complete' do
+ context "when pipeline is complete" do
before do
pipeline.succeed!
end
- it 'returns stages in valid order' do
+ it "returns stages in valid order" do
expect(subject).to all(be_a Ci::Stage)
expect(subject.map(&:name))
.to eq %w[sanity build test deploy cleanup]
@@ -960,14 +962,14 @@ describe Ci::Pipeline, :mailer do
end
end
- describe 'state machine' do
+ describe "state machine" do
let(:current) { Time.now.change(usec: 0) }
- let(:build) { create_build('build1', queued_at: 0) }
- let(:build_b) { create_build('build2', queued_at: 0) }
- let(:build_c) { create_build('build3', queued_at: 0) }
+ let(:build) { create_build("build1", queued_at: 0) }
+ let(:build_b) { create_build("build2", queued_at: 0) }
+ let(:build_c) { create_build("build3", queued_at: 0) }
- describe '#duration' do
- context 'when multiple builds are finished' do
+ describe "#duration" do
+ context "when multiple builds are finished" do
before do
travel_to(current + 30) do
build.run!
@@ -985,16 +987,16 @@ describe Ci::Pipeline, :mailer do
end
end
- it 'matches sum of builds duration' do
+ it "matches sum of builds duration" do
pipeline.reload
expect(pipeline.duration).to eq(40)
end
end
- context 'when pipeline becomes blocked' do
- let!(:build) { create_build('build:1') }
- let!(:action) { create_build('manual:action', :manual) }
+ context "when pipeline becomes blocked" do
+ let!(:build) { create_build("build:1") }
+ let!(:action) { create_build("manual:action", :manual) }
before do
travel_to(current + 1.minute) do
@@ -1006,7 +1008,7 @@ describe Ci::Pipeline, :mailer do
end
end
- it 'recalculates pipeline duration' do
+ it "recalculates pipeline duration" do
pipeline.reload
expect(pipeline).to be_manual
@@ -1015,58 +1017,58 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#started_at' do
- it 'updates on transitioning to running' do
+ describe "#started_at" do
+ it "updates on transitioning to running" do
build.run
expect(pipeline.reload.started_at).not_to be_nil
end
- it 'does not update on transitioning to success' do
+ it "does not update on transitioning to success" do
build.success
expect(pipeline.reload.started_at).to be_nil
end
end
- describe '#finished_at' do
- it 'updates on transitioning to success' do
+ describe "#finished_at" do
+ it "updates on transitioning to success" do
build.success
expect(pipeline.reload.finished_at).not_to be_nil
end
- it 'does not update on transitioning to running' do
+ it "does not update on transitioning to running" do
build.run
expect(pipeline.reload.finished_at).to be_nil
end
end
- describe 'merge request metrics' do
+ describe "merge request metrics" do
let(:project) { create(:project, :repository) }
- let(:pipeline) { FactoryBot.create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: project.repository.commit('master').id) }
+ let(:pipeline) { FactoryBot.create(:ci_empty_pipeline, status: "created", project: project, ref: "master", sha: project.repository.commit("master").id) }
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: pipeline.ref) }
before do
expect(PipelineMetricsWorker).to receive(:perform_async).with(pipeline.id)
end
- context 'when transitioning to running' do
- it 'schedules metrics workers' do
+ context "when transitioning to running" do
+ it "schedules metrics workers" do
pipeline.run
end
end
- context 'when transitioning to success' do
- it 'schedules metrics workers' do
+ context "when transitioning to success" do
+ it "schedules metrics workers" do
pipeline.succeed
end
end
end
- describe 'pipeline caching' do
- it 'performs ExpirePipelinesCacheWorker' do
+ describe "pipeline caching" do
+ it "performs ExpirePipelinesCacheWorker" do
expect(ExpirePipelineCacheWorker).to receive(:perform_async).with(pipeline.id)
pipeline.cancel
@@ -1075,107 +1077,107 @@ describe Ci::Pipeline, :mailer do
def create_build(name, *traits, queued_at: current, started_from: 0, **opts)
create(:ci_build, *traits,
- name: name,
- pipeline: pipeline,
- queued_at: queued_at,
- started_at: queued_at + started_from,
- **opts)
+ name: name,
+ pipeline: pipeline,
+ queued_at: queued_at,
+ started_at: queued_at + started_from,
+ **opts)
end
end
- describe '#branch?' do
+ describe "#branch?" do
subject { pipeline.branch? }
- context 'when ref is not a tag' do
+ context "when ref is not a tag" do
before do
pipeline.tag = false
end
- it 'return true' do
+ it "return true" do
is_expected.to be_truthy
end
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:pipeline) do
create(:ci_pipeline, source: :merge_request, merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
end
end
- context 'when ref is a tag' do
+ context "when ref is a tag" do
before do
pipeline.tag = true
end
- it 'return false' do
+ it "return false" do
is_expected.to be_falsey
end
end
end
- describe '#git_ref' do
+ describe "#git_ref" do
subject { pipeline.send(:git_ref) }
- context 'when ref is branch' do
+ context "when ref is branch" do
let(:pipeline) { create(:ci_pipeline, tag: false) }
- it 'returns branch ref' do
+ it "returns branch ref" do
is_expected.to eq(Gitlab::Git::BRANCH_REF_PREFIX + pipeline.ref.to_s)
end
end
- context 'when ref is tag' do
+ context "when ref is tag" do
let(:pipeline) { create(:ci_pipeline, tag: true) }
- it 'returns branch ref' do
+ it "returns branch ref" do
is_expected.to eq(Gitlab::Git::TAG_REF_PREFIX + pipeline.ref.to_s)
end
end
- context 'when ref is merge request' do
+ context "when ref is merge request" do
let(:pipeline) do
create(:ci_pipeline,
- source: :merge_request,
- merge_request: merge_request)
+ source: :merge_request,
+ merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'returns branch ref' do
+ it "returns branch ref" do
is_expected.to eq(Gitlab::Git::BRANCH_REF_PREFIX + pipeline.ref.to_s)
end
end
end
- describe 'ref_exists?' do
- context 'when repository exists' do
+ describe "ref_exists?" do
+ context "when repository exists" do
using RSpec::Parameterized::TableSyntax
let(:project) { create(:project, :repository) }
where(:tag, :ref, :result) do
- false | 'master' | true
- false | 'non-existent-branch' | false
- true | 'v1.1.0' | true
- true | 'non-existent-tag' | false
+ false | "master" | true
+ false | "non-existent-branch" | false
+ true | "v1.1.0" | true
+ true | "non-existent-tag" | false
end
with_them do
@@ -1189,223 +1191,224 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when repository does not exist' do
+ context "when repository does not exist" do
let(:pipeline) do
- create(:ci_empty_pipeline, project: project, ref: 'master')
+ create(:ci_empty_pipeline, project: project, ref: "master")
end
- it 'always returns false' do
+ it "always returns false" do
expect(pipeline.ref_exists?).to eq false
end
end
end
- context 'with non-empty project' do
+ context "with non-empty project" do
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- ref: project.default_branch,
- sha: project.commit.sha)
+ project: project,
+ ref: project.default_branch,
+ sha: project.commit.sha)
end
- describe '#latest?' do
- context 'with latest sha' do
- it 'returns true' do
+ describe "#latest?" do
+ context "with latest sha" do
+ it "returns true" do
expect(pipeline).to be_latest
end
end
- context 'with not latest sha' do
+ context "with not latest sha" do
before do
pipeline.update(
- sha: project.commit("#{project.default_branch}~1").sha)
+ sha: project.commit("#{project.default_branch}~1").sha
+ )
end
- it 'returns false' do
+ it "returns false" do
expect(pipeline).not_to be_latest
end
end
end
end
- describe '#manual_actions' do
+ describe "#manual_actions" do
subject { pipeline.manual_actions }
- it 'when none defined' do
+ it "when none defined" do
is_expected.to be_empty
end
- context 'when action defined' do
- let!(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: 'deploy') }
+ context "when action defined" do
+ let!(:manual) { create(:ci_build, :manual, pipeline: pipeline, name: "deploy") }
- it 'returns one action' do
+ it "returns one action" do
is_expected.to contain_exactly(manual)
end
- context 'there are multiple of the same name' do
- let!(:manual2) { create(:ci_build, :manual, pipeline: pipeline, name: 'deploy') }
+ context "there are multiple of the same name" do
+ let!(:manual2) { create(:ci_build, :manual, pipeline: pipeline, name: "deploy") }
before do
manual.update(retried: true)
end
- it 'returns latest one' do
+ it "returns latest one" do
is_expected.to contain_exactly(manual2)
end
end
end
end
- describe '#branch_updated?' do
- context 'when pipeline has before SHA' do
+ describe "#branch_updated?" do
+ context "when pipeline has before SHA" do
before do
- pipeline.update_column(:before_sha, 'a1b2c3d4')
+ pipeline.update_column(:before_sha, "a1b2c3d4")
end
- it 'runs on a branch update push' do
+ it "runs on a branch update push" do
expect(pipeline.before_sha).not_to be Gitlab::Git::BLANK_SHA
expect(pipeline.branch_updated?).to be true
end
end
- context 'when pipeline does not have before SHA' do
+ context "when pipeline does not have before SHA" do
before do
pipeline.update_column(:before_sha, Gitlab::Git::BLANK_SHA)
end
- it 'does not run on a branch updating push' do
+ it "does not run on a branch updating push" do
expect(pipeline.branch_updated?).to be false
end
end
end
- describe '#modified_paths' do
- context 'when old and new revisions are set' do
+ describe "#modified_paths" do
+ context "when old and new revisions are set" do
let(:project) { create(:project, :repository) }
before do
- pipeline.update(before_sha: '1234abcd', sha: '2345bcde')
+ pipeline.update(before_sha: "1234abcd", sha: "2345bcde")
end
- it 'fetches stats for changes between commits' do
+ it "fetches stats for changes between commits" do
expect(project.repository)
- .to receive(:diff_stats).with('1234abcd', '2345bcde')
+ .to receive(:diff_stats).with("1234abcd", "2345bcde")
.and_call_original
pipeline.modified_paths
end
end
- context 'when either old or new revision is missing' do
+ context "when either old or new revision is missing" do
before do
pipeline.update_column(:before_sha, Gitlab::Git::BLANK_SHA)
end
- it 'returns nil' do
+ it "returns nil" do
expect(pipeline.modified_paths).to be_nil
end
end
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:pipeline) do
create(:ci_pipeline, source: :merge_request, merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master')
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master")
end
- it 'returns merge request modified paths' do
+ it "returns merge request modified paths" do
expect(pipeline.modified_paths).to match(merge_request.modified_paths)
end
end
end
- describe '#has_kubernetes_active?' do
- context 'when kubernetes is active' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'returns true' do
+ describe "#has_kubernetes_active?" do
+ context "when kubernetes is active" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "returns true" do
expect(pipeline).to have_kubernetes_active
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'when kubernetes is not active' do
- it 'returns false' do
+ context "when kubernetes is not active" do
+ it "returns false" do
expect(pipeline).not_to have_kubernetes_active
end
end
end
- describe '#has_warnings?' do
+ describe "#has_warnings?" do
subject { pipeline.has_warnings? }
- context 'build which is allowed to fail fails' do
+ context "build which is allowed to fail fails" do
before do
- create :ci_build, :success, pipeline: pipeline, name: 'rspec'
- create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop'
+ create :ci_build, :success, pipeline: pipeline, name: "rspec"
+ create :ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: "rubocop"
end
- it 'returns true' do
+ it "returns true" do
is_expected.to be_truthy
end
end
- context 'build which is allowed to fail succeeds' do
+ context "build which is allowed to fail succeeds" do
before do
- create :ci_build, :success, pipeline: pipeline, name: 'rspec'
- create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: 'rubocop'
+ create :ci_build, :success, pipeline: pipeline, name: "rspec"
+ create :ci_build, :allowed_to_fail, :success, pipeline: pipeline, name: "rubocop"
end
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
end
- context 'build is retried and succeeds' do
+ context "build is retried and succeeds" do
before do
- create :ci_build, :success, pipeline: pipeline, name: 'rubocop'
- create :ci_build, :failed, pipeline: pipeline, name: 'rspec'
- create :ci_build, :success, pipeline: pipeline, name: 'rspec'
+ create :ci_build, :success, pipeline: pipeline, name: "rubocop"
+ create :ci_build, :failed, pipeline: pipeline, name: "rspec"
+ create :ci_build, :success, pipeline: pipeline, name: "rspec"
end
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
end
end
- describe '#number_of_warnings' do
- it 'returns the number of warnings' do
- create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop')
+ describe "#number_of_warnings" do
+ it "returns the number of warnings" do
+ create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: "rubocop")
expect(pipeline.number_of_warnings).to eq(1)
end
- it 'supports eager loading of the number of warnings' do
+ it "supports eager loading of the number of warnings" do
pipeline2 = create(:ci_empty_pipeline, status: :created, project: project)
- create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: 'rubocop')
- create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline2, name: 'rubocop')
+ create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline, name: "rubocop")
+ create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline2, name: "rubocop")
pipelines = project.ci_pipelines.to_a
@@ -1421,12 +1424,12 @@ describe Ci::Pipeline, :mailer do
end
end
- shared_context 'with some outdated pipelines' do
+ shared_context "with some outdated pipelines" do
before do
- create_pipeline(:canceled, 'ref', 'A', project)
- create_pipeline(:success, 'ref', 'A', project)
- create_pipeline(:failed, 'ref', 'B', project)
- create_pipeline(:skipped, 'feature', 'C', project)
+ create_pipeline(:canceled, "ref", "A", project)
+ create_pipeline(:success, "ref", "A", project)
+ create_pipeline(:failed, "ref", "B", project)
+ create_pipeline(:skipped, "feature", "C", project)
end
def create_pipeline(status, ref, sha, project)
@@ -1440,75 +1443,75 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '.newest_first' do
- include_context 'with some outdated pipelines'
+ describe ".newest_first" do
+ include_context "with some outdated pipelines"
- it 'returns the pipelines from new to old' do
+ it "returns the pipelines from new to old" do
expect(described_class.newest_first.pluck(:status))
.to eq(%w[skipped failed success canceled])
end
- it 'searches limited backlog' do
+ it "searches limited backlog" do
expect(described_class.newest_first(limit: 1).pluck(:status))
.to eq(%w[skipped])
end
end
- describe '.latest_status' do
- include_context 'with some outdated pipelines'
+ describe ".latest_status" do
+ include_context "with some outdated pipelines"
- context 'when no ref is specified' do
- it 'returns the status of the latest pipeline' do
- expect(described_class.latest_status).to eq('skipped')
+ context "when no ref is specified" do
+ it "returns the status of the latest pipeline" do
+ expect(described_class.latest_status).to eq("skipped")
end
end
- context 'when ref is specified' do
- it 'returns the status of the latest pipeline for the given ref' do
- expect(described_class.latest_status('ref')).to eq('failed')
+ context "when ref is specified" do
+ it "returns the status of the latest pipeline for the given ref" do
+ expect(described_class.latest_status("ref")).to eq("failed")
end
end
end
- describe '.latest_successful_for' do
- include_context 'with some outdated pipelines'
+ describe ".latest_successful_for" do
+ include_context "with some outdated pipelines"
let!(:latest_successful_pipeline) do
- create_pipeline(:success, 'ref', 'D', project)
+ create_pipeline(:success, "ref", "D", project)
end
- it 'returns the latest successful pipeline' do
- expect(described_class.latest_successful_for('ref'))
+ it "returns the latest successful pipeline" do
+ expect(described_class.latest_successful_for("ref"))
.to eq(latest_successful_pipeline)
end
end
- describe '.latest_successful_for_refs' do
- include_context 'with some outdated pipelines'
+ describe ".latest_successful_for_refs" do
+ include_context "with some outdated pipelines"
let!(:latest_successful_pipeline1) do
- create_pipeline(:success, 'ref1', 'D', project)
+ create_pipeline(:success, "ref1", "D", project)
end
let!(:latest_successful_pipeline2) do
- create_pipeline(:success, 'ref2', 'D', project)
+ create_pipeline(:success, "ref2", "D", project)
end
- it 'returns the latest successful pipeline for both refs' do
- refs = %w(ref1 ref2 ref3)
+ it "returns the latest successful pipeline for both refs" do
+ refs = %w[ref1 ref2 ref3]
- expect(described_class.latest_successful_for_refs(refs)).to eq({ 'ref1' => latest_successful_pipeline1, 'ref2' => latest_successful_pipeline2 })
+ expect(described_class.latest_successful_for_refs(refs)).to eq({"ref1" => latest_successful_pipeline1, "ref2" => latest_successful_pipeline2})
end
end
- describe '.latest_status_per_commit' do
+ describe ".latest_status_per_commit" do
let(:project) { create(:project) }
before do
pairs = [
%w[success ref1 123],
%w[manual master 123],
- %w[failed ref 456]
+ %w[failed ref 456],
]
pairs.each do |(status, ref, sha)|
@@ -1522,115 +1525,115 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'without a ref' do
- it 'returns a Hash containing the latest status per commit for all refs' do
+ context "without a ref" do
+ it "returns a Hash containing the latest status per commit for all refs" do
expect(described_class.latest_status_per_commit(%w[123 456]))
- .to eq({ '123' => 'manual', '456' => 'failed' })
+ .to eq({"123" => "manual", "456" => "failed"})
end
- it 'only includes the status of the given commit SHAs' do
+ it "only includes the status of the given commit SHAs" do
expect(described_class.latest_status_per_commit(%w[123]))
- .to eq({ '123' => 'manual' })
+ .to eq({"123" => "manual"})
end
- context 'when there are two pipelines for a ref and SHA' do
- it 'returns the status of the latest pipeline' do
+ context "when there are two pipelines for a ref and SHA" do
+ it "returns the status of the latest pipeline" do
create(
:ci_empty_pipeline,
- status: 'failed',
- ref: 'master',
- sha: '123',
+ status: "failed",
+ ref: "master",
+ sha: "123",
project: project
)
expect(described_class.latest_status_per_commit(%w[123]))
- .to eq({ '123' => 'failed' })
+ .to eq({"123" => "failed"})
end
end
end
- context 'with a ref' do
- it 'only includes the pipelines for the given ref' do
- expect(described_class.latest_status_per_commit(%w[123 456], 'master'))
- .to eq({ '123' => 'manual' })
+ context "with a ref" do
+ it "only includes the pipelines for the given ref" do
+ expect(described_class.latest_status_per_commit(%w[123 456], "master"))
+ .to eq({"123" => "manual"})
end
end
end
- describe '.latest_successful_ids_per_project' do
+ describe ".latest_successful_ids_per_project" do
let(:projects) { create_list(:project, 2) }
let!(:pipeline1) { create(:ci_pipeline, :success, project: projects[0]) }
let!(:pipeline2) { create(:ci_pipeline, :success, project: projects[0]) }
let!(:pipeline3) { create(:ci_pipeline, :failed, project: projects[0]) }
let!(:pipeline4) { create(:ci_pipeline, :success, project: projects[1]) }
- it 'returns expected pipeline ids' do
+ it "returns expected pipeline ids" do
expect(described_class.latest_successful_ids_per_project)
.to contain_exactly(pipeline2, pipeline4)
end
end
- describe '.internal_sources' do
+ describe ".internal_sources" do
subject { described_class.internal_sources }
it { is_expected.to be_an(Array) }
end
- describe '#status' do
+ describe "#status" do
let(:build) do
- create(:ci_build, :created, pipeline: pipeline, name: 'test')
+ create(:ci_build, :created, pipeline: pipeline, name: "test")
end
subject { pipeline.reload.status }
- context 'on queuing' do
+ context "on queuing" do
before do
build.enqueue
end
- it { is_expected.to eq('pending') }
+ it { is_expected.to eq("pending") }
end
- context 'on run' do
+ context "on run" do
before do
build.enqueue
build.run
end
- it { is_expected.to eq('running') }
+ it { is_expected.to eq("running") }
end
- context 'on drop' do
+ context "on drop" do
before do
build.drop
end
- it { is_expected.to eq('failed') }
+ it { is_expected.to eq("failed") }
end
- context 'on success' do
+ context "on success" do
before do
build.success
end
- it { is_expected.to eq('success') }
+ it { is_expected.to eq("success") }
end
- context 'on cancel' do
+ context "on cancel" do
before do
build.cancel
end
- context 'when build is pending' do
+ context "when build is pending" do
let(:build) do
create(:ci_build, :pending, pipeline: pipeline)
end
- it { is_expected.to eq('canceled') }
+ it { is_expected.to eq("canceled") }
end
end
- context 'on failure and build retry' do
+ context "on failure and build retry" do
before do
stub_not_protect_default_branch
@@ -1644,11 +1647,11 @@ describe Ci::Pipeline, :mailer do
# Instead of: created > failed > pending
# Since the pipeline already run, so it should not be pending anymore
- it { is_expected.to eq('running') }
+ it { is_expected.to eq("running") }
end
end
- describe '#ci_yaml_file_path' do
+ describe "#ci_yaml_file_path" do
subject { pipeline.ci_yaml_file_path }
%i[unknown_source repository_source].each do |source|
@@ -1657,74 +1660,74 @@ describe Ci::Pipeline, :mailer do
pipeline.config_source = described_class.config_sources.fetch(source)
end
- it 'returns the path from project' do
- allow(pipeline.project).to receive(:ci_config_path) { 'custom/path' }
+ it "returns the path from project" do
+ allow(pipeline.project).to receive(:ci_config_path) { "custom/path" }
- is_expected.to eq('custom/path')
+ is_expected.to eq("custom/path")
end
- it 'returns default when custom path is nil' do
+ it "returns default when custom path is nil" do
allow(pipeline.project).to receive(:ci_config_path) { nil }
- is_expected.to eq('.gitlab-ci.yml')
+ is_expected.to eq(".gitlab-ci.yml")
end
- it 'returns default when custom path is empty' do
- allow(pipeline.project).to receive(:ci_config_path) { '' }
+ it "returns default when custom path is empty" do
+ allow(pipeline.project).to receive(:ci_config_path) { "" }
- is_expected.to eq('.gitlab-ci.yml')
+ is_expected.to eq(".gitlab-ci.yml")
end
end
end
- context 'when pipeline is for auto-devops' do
+ context "when pipeline is for auto-devops" do
before do
- pipeline.config_source = 'auto_devops_source'
+ pipeline.config_source = "auto_devops_source"
end
- it 'does not return config file' do
+ it "does not return config file" do
is_expected.to be_nil
end
end
end
- describe '#set_config_source' do
- context 'when pipelines does not contain needed data and auto devops is disabled' do
+ describe "#set_config_source" do
+ context "when pipelines does not contain needed data and auto devops is disabled" do
before do
stub_application_setting(auto_devops_enabled: false)
end
- it 'defines source to be unknown' do
+ it "defines source to be unknown" do
pipeline.set_config_source
expect(pipeline).to be_unknown_source
end
end
- context 'when pipeline contains all needed data' do
+ context "when pipeline contains all needed data" do
let(:pipeline) do
create(:ci_pipeline, project: project,
- sha: '1234',
- ref: 'master',
+ sha: "1234",
+ ref: "master",
source: :push)
end
- context 'when the repository has a config file' do
+ context "when the repository has a config file" do
before do
allow(project.repository).to receive(:gitlab_ci_yml_for)
- .and_return('config')
+ .and_return("config")
end
- it 'defines source to be from repository' do
+ it "defines source to be from repository" do
pipeline.set_config_source
expect(pipeline).to be_repository_source
end
- context 'when loading an object' do
+ context "when loading an object" do
let(:new_pipeline) { Ci::Pipeline.find(pipeline.id) }
- it 'does not redefine the source' do
+ it "does not redefine the source" do
# force to overwrite the source
pipeline.unknown_source!
@@ -1733,15 +1736,15 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when the repository does not have a config file' do
- let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
+ context "when the repository does not have a config file" do
+ let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find("Auto-DevOps").content }
- context 'auto devops enabled' do
+ context "auto devops enabled" do
before do
- allow(project).to receive(:ci_config_path) { 'custom' }
+ allow(project).to receive(:ci_config_path) { "custom" }
end
- it 'defines source to be auto devops' do
+ it "defines source to be auto devops" do
pipeline.set_config_source
expect(pipeline).to be_auto_devops_source
@@ -1751,38 +1754,38 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#ci_yaml_file' do
- let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find('Auto-DevOps').content }
+ describe "#ci_yaml_file" do
+ let(:implied_yml) { Gitlab::Template::GitlabCiYmlTemplate.find("Auto-DevOps").content }
- context 'the source is unknown' do
+ context "the source is unknown" do
before do
pipeline.unknown_source!
end
- it 'returns the configuration if found' do
+ it "returns the configuration if found" do
allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
- .and_return('config')
+ .and_return("config")
expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil
end
- it 'sets yaml errors if not found' do
+ it "sets yaml errors if not found" do
expect(pipeline.ci_yaml_file).to be_nil
expect(pipeline.yaml_errors)
- .to start_with('Failed to load CI/CD config file')
+ .to start_with("Failed to load CI/CD config file")
end
end
- context 'the source is the repository' do
+ context "the source is the repository" do
before do
pipeline.repository_source!
end
- it 'returns the configuration if found' do
+ it "returns the configuration if found" do
allow(pipeline.project.repository).to receive(:gitlab_ci_yml_for)
- .and_return('config')
+ .and_return("config")
expect(pipeline.ci_yaml_file).to be_a(String)
expect(pipeline.ci_yaml_file).not_to eq(implied_yml)
@@ -1790,157 +1793,157 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when the source is auto_devops_source' do
+ context "when the source is auto_devops_source" do
before do
stub_application_setting(auto_devops_enabled: true)
pipeline.auto_devops_source!
end
- it 'finds the implied config' do
+ it "finds the implied config" do
expect(pipeline.ci_yaml_file).to eq(implied_yml)
expect(pipeline.yaml_errors).to be_nil
end
end
end
- describe '#update_status' do
- context 'when pipeline is empty' do
- it 'updates does not change pipeline status' do
+ describe "#update_status" do
+ context "when pipeline is empty" do
+ it "updates does not change pipeline status" do
expect(pipeline.statuses.latest.status).to be_nil
expect { pipeline.update_status }
- .to change { pipeline.reload.status }.to 'skipped'
+ .to change { pipeline.reload.status }.to "skipped"
end
end
- context 'when updating status to pending' do
+ context "when updating status to pending" do
before do
allow(pipeline)
.to receive_message_chain(:statuses, :latest, :status)
.and_return(:running)
end
- it 'updates pipeline status to running' do
+ it "updates pipeline status to running" do
expect { pipeline.update_status }
- .to change { pipeline.reload.status }.to 'running'
+ .to change { pipeline.reload.status }.to "running"
end
end
- context 'when updating status to scheduled' do
+ context "when updating status to scheduled" do
before do
allow(pipeline)
.to receive_message_chain(:statuses, :latest, :status)
.and_return(:scheduled)
end
- it 'updates pipeline status to scheduled' do
+ it "updates pipeline status to scheduled" do
expect { pipeline.update_status }
- .to change { pipeline.reload.status }.to 'scheduled'
+ .to change { pipeline.reload.status }.to "scheduled"
end
end
- context 'when statuses status was not recognized' do
+ context "when statuses status was not recognized" do
before do
allow(pipeline)
.to receive(:latest_builds_status)
.and_return(:unknown)
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { pipeline.update_status }
.to raise_error(HasStatus::UnknownStatusError)
end
end
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
subject { pipeline.detailed_status(user) }
- context 'when pipeline is created' do
+ context "when pipeline is created" do
let(:pipeline) { create(:ci_pipeline, status: :created) }
- it 'returns detailed status for created pipeline' do
- expect(subject.text).to eq 'created'
+ it "returns detailed status for created pipeline" do
+ expect(subject.text).to eq "created"
end
end
- context 'when pipeline is pending' do
+ context "when pipeline is pending" do
let(:pipeline) { create(:ci_pipeline, status: :pending) }
- it 'returns detailed status for pending pipeline' do
- expect(subject.text).to eq 'pending'
+ it "returns detailed status for pending pipeline" do
+ expect(subject.text).to eq "pending"
end
end
- context 'when pipeline is running' do
+ context "when pipeline is running" do
let(:pipeline) { create(:ci_pipeline, status: :running) }
- it 'returns detailed status for running pipeline' do
- expect(subject.text).to eq 'running'
+ it "returns detailed status for running pipeline" do
+ expect(subject.text).to eq "running"
end
end
- context 'when pipeline is successful' do
+ context "when pipeline is successful" do
let(:pipeline) { create(:ci_pipeline, status: :success) }
- it 'returns detailed status for successful pipeline' do
- expect(subject.text).to eq 'passed'
+ it "returns detailed status for successful pipeline" do
+ expect(subject.text).to eq "passed"
end
end
- context 'when pipeline is failed' do
+ context "when pipeline is failed" do
let(:pipeline) { create(:ci_pipeline, status: :failed) }
- it 'returns detailed status for failed pipeline' do
- expect(subject.text).to eq 'failed'
+ it "returns detailed status for failed pipeline" do
+ expect(subject.text).to eq "failed"
end
end
- context 'when pipeline is canceled' do
+ context "when pipeline is canceled" do
let(:pipeline) { create(:ci_pipeline, status: :canceled) }
- it 'returns detailed status for canceled pipeline' do
- expect(subject.text).to eq 'canceled'
+ it "returns detailed status for canceled pipeline" do
+ expect(subject.text).to eq "canceled"
end
end
- context 'when pipeline is skipped' do
+ context "when pipeline is skipped" do
let(:pipeline) { create(:ci_pipeline, status: :skipped) }
- it 'returns detailed status for skipped pipeline' do
- expect(subject.text).to eq 'skipped'
+ it "returns detailed status for skipped pipeline" do
+ expect(subject.text).to eq "skipped"
end
end
- context 'when pipeline is blocked' do
+ context "when pipeline is blocked" do
let(:pipeline) { create(:ci_pipeline, status: :manual) }
- it 'returns detailed status for blocked pipeline' do
- expect(subject.text).to eq 'blocked'
+ it "returns detailed status for blocked pipeline" do
+ expect(subject.text).to eq "blocked"
end
end
- context 'when pipeline is successful but with warnings' do
+ context "when pipeline is successful but with warnings" do
let(:pipeline) { create(:ci_pipeline, status: :success) }
before do
create(:ci_build, :allowed_to_fail, :failed, pipeline: pipeline)
end
- it 'retruns detailed status for successful pipeline with warnings' do
- expect(subject.label).to eq 'passed with warnings'
+ it "retruns detailed status for successful pipeline with warnings" do
+ expect(subject.label).to eq "passed with warnings"
end
end
end
- describe '#cancelable?' do
+ describe "#cancelable?" do
%i[created running pending].each do |status0|
context "when there is a build #{status0}" do
before do
create(:ci_build, status0, pipeline: pipeline)
end
- it 'is cancelable' do
+ it "is cancelable" do
expect(pipeline.cancelable?).to be_truthy
end
end
@@ -1950,7 +1953,7 @@ describe Ci::Pipeline, :mailer do
create(:generic_commit_status, status0, pipeline: pipeline)
end
- it 'is cancelable' do
+ it "is cancelable" do
expect(pipeline.cancelable?).to be_truthy
end
end
@@ -1962,7 +1965,7 @@ describe Ci::Pipeline, :mailer do
create(:generic_commit_status, status1, pipeline: pipeline)
end
- it 'is cancelable' do
+ it "is cancelable" do
expect(pipeline.cancelable?).to be_truthy
end
end
@@ -1973,7 +1976,7 @@ describe Ci::Pipeline, :mailer do
create(:ci_build, status1, pipeline: pipeline)
end
- it 'is cancelable' do
+ it "is cancelable" do
expect(pipeline.cancelable?).to be_truthy
end
end
@@ -1984,7 +1987,7 @@ describe Ci::Pipeline, :mailer do
create(:ci_build, status1, pipeline: pipeline)
end
- it 'is cancelable' do
+ it "is cancelable" do
expect(pipeline.cancelable?).to be_truthy
end
end
@@ -1997,7 +2000,7 @@ describe Ci::Pipeline, :mailer do
create(:ci_build, status, pipeline: pipeline)
end
- it 'is not cancelable' do
+ it "is not cancelable" do
expect(pipeline.cancelable?).to be_falsey
end
end
@@ -2007,27 +2010,27 @@ describe Ci::Pipeline, :mailer do
create(:generic_commit_status, status, pipeline: pipeline)
end
- it 'is not cancelable' do
+ it "is not cancelable" do
expect(pipeline.cancelable?).to be_falsey
end
end
end
- context 'when there is a manual action present in the pipeline' do
+ context "when there is a manual action present in the pipeline" do
before do
create(:ci_build, :manual, pipeline: pipeline)
end
- it 'is not cancelable' do
+ it "is not cancelable" do
expect(pipeline).not_to be_cancelable
end
end
end
- describe '#cancel_running' do
+ describe "#cancel_running" do
let(:latest_status) { pipeline.statuses.pluck(:status) }
- context 'when there is a running external job and a regular job' do
+ context "when there is a running external job and a regular job" do
before do
create(:ci_build, :running, pipeline: pipeline)
create(:generic_commit_status, :running, pipeline: pipeline)
@@ -2035,12 +2038,12 @@ describe Ci::Pipeline, :mailer do
pipeline.cancel_running
end
- it 'cancels both jobs' do
- expect(latest_status).to contain_exactly('canceled', 'canceled')
+ it "cancels both jobs" do
+ expect(latest_status).to contain_exactly("canceled", "canceled")
end
end
- context 'when jobs are in different stages' do
+ context "when jobs are in different stages" do
before do
create(:ci_build, :running, stage_idx: 0, pipeline: pipeline)
create(:ci_build, :running, stage_idx: 1, pipeline: pipeline)
@@ -2048,12 +2051,12 @@ describe Ci::Pipeline, :mailer do
pipeline.cancel_running
end
- it 'cancels both jobs' do
- expect(latest_status).to contain_exactly('canceled', 'canceled')
+ it "cancels both jobs" do
+ expect(latest_status).to contain_exactly("canceled", "canceled")
end
end
- context 'when there are created builds present in the pipeline' do
+ context "when there are created builds present in the pipeline" do
before do
create(:ci_build, :running, stage_idx: 0, pipeline: pipeline)
create(:ci_build, :created, stage_idx: 1, pipeline: pipeline)
@@ -2061,13 +2064,13 @@ describe Ci::Pipeline, :mailer do
pipeline.cancel_running
end
- it 'cancels created builds' do
- expect(latest_status).to eq %w(canceled canceled)
+ it "cancels created builds" do
+ expect(latest_status).to eq %w[canceled canceled]
end
end
end
- describe '#retry_failed' do
+ describe "#retry_failed" do
let(:latest_status) { pipeline.statuses.latest.pluck(:status) }
before do
@@ -2076,49 +2079,49 @@ describe Ci::Pipeline, :mailer do
project.add_developer(user)
end
- context 'when there is a failed build and failed external status' do
+ context "when there is a failed build and failed external status" do
before do
- create(:ci_build, :failed, name: 'build', pipeline: pipeline)
- create(:generic_commit_status, :failed, name: 'jenkins', pipeline: pipeline)
+ create(:ci_build, :failed, name: "build", pipeline: pipeline)
+ create(:generic_commit_status, :failed, name: "jenkins", pipeline: pipeline)
pipeline.retry_failed(user)
end
- it 'retries only build' do
- expect(latest_status).to contain_exactly('pending', 'failed')
+ it "retries only build" do
+ expect(latest_status).to contain_exactly("pending", "failed")
end
end
- context 'when builds are in different stages' do
+ context "when builds are in different stages" do
before do
- create(:ci_build, :failed, name: 'build', stage_idx: 0, pipeline: pipeline)
- create(:ci_build, :failed, name: 'jenkins', stage_idx: 1, pipeline: pipeline)
+ create(:ci_build, :failed, name: "build", stage_idx: 0, pipeline: pipeline)
+ create(:ci_build, :failed, name: "jenkins", stage_idx: 1, pipeline: pipeline)
pipeline.retry_failed(user)
end
- it 'retries both builds' do
- expect(latest_status).to contain_exactly('pending', 'created')
+ it "retries both builds" do
+ expect(latest_status).to contain_exactly("pending", "created")
end
end
- context 'when there are canceled and failed' do
+ context "when there are canceled and failed" do
before do
- create(:ci_build, :failed, name: 'build', stage_idx: 0, pipeline: pipeline)
- create(:ci_build, :canceled, name: 'jenkins', stage_idx: 1, pipeline: pipeline)
+ create(:ci_build, :failed, name: "build", stage_idx: 0, pipeline: pipeline)
+ create(:ci_build, :canceled, name: "jenkins", stage_idx: 1, pipeline: pipeline)
pipeline.retry_failed(user)
end
- it 'retries both builds' do
- expect(latest_status).to contain_exactly('pending', 'created')
+ it "retries both builds" do
+ expect(latest_status).to contain_exactly("pending", "created")
end
end
end
- describe '#execute_hooks' do
- let!(:build_a) { create_build('a', 0) }
- let!(:build_b) { create_build('b', 0) }
+ describe "#execute_hooks" do
+ let!(:build_a) { create_build("a", 0) }
+ let!(:build_b) { create_build("b", 0) }
let!(:hook) do
create(:project_hook, project: project, pipeline_events: enabled)
@@ -2128,26 +2131,26 @@ describe Ci::Pipeline, :mailer do
WebHookWorker.drain
end
- context 'with pipeline hooks enabled' do
+ context "with pipeline hooks enabled" do
let(:enabled) { true }
before do
WebMock.stub_request(:post, hook.url)
end
- context 'with multiple builds' do
- context 'when build is queued' do
+ context "with multiple builds" do
+ context "when build is queued" do
before do
build_a.enqueue
build_b.enqueue
end
- it 'receives a pending event once' do
- expect(WebMock).to have_requested_pipeline_hook('pending').once
+ it "receives a pending event once" do
+ expect(WebMock).to have_requested_pipeline_hook("pending").once
end
end
- context 'when build is run' do
+ context "when build is run" do
before do
build_a.enqueue
build_a.run
@@ -2155,12 +2158,12 @@ describe Ci::Pipeline, :mailer do
build_b.run
end
- it 'receives a running event once' do
- expect(WebMock).to have_requested_pipeline_hook('running').once
+ it "receives a running event once" do
+ expect(WebMock).to have_requested_pipeline_hook("running").once
end
end
- context 'when all builds succeed' do
+ context "when all builds succeed" do
before do
build_a.success
@@ -2168,34 +2171,34 @@ describe Ci::Pipeline, :mailer do
build_b.reload.success
end
- it 'receives a success event once' do
- expect(WebMock).to have_requested_pipeline_hook('success').once
+ it "receives a success event once" do
+ expect(WebMock).to have_requested_pipeline_hook("success").once
end
end
- context 'when stage one failed' do
- let!(:build_b) { create_build('b', 1) }
+ context "when stage one failed" do
+ let!(:build_b) { create_build("b", 1) }
before do
build_a.drop
end
- it 'receives a failed event once' do
- expect(WebMock).to have_requested_pipeline_hook('failed').once
+ it "receives a failed event once" do
+ expect(WebMock).to have_requested_pipeline_hook("failed").once
end
end
def have_requested_pipeline_hook(status)
have_requested(:post, hook.url).with do |req|
json_body = JSON.parse(req.body)
- json_body['object_attributes']['status'] == status &&
- json_body['builds'].length == 2
+ json_body["object_attributes"]["status"] == status &&
+ json_body["builds"].length == 2
end
end
end
end
- context 'with pipeline hooks disabled' do
+ context "with pipeline hooks disabled" do
let(:enabled) { false }
before do
@@ -2203,40 +2206,40 @@ describe Ci::Pipeline, :mailer do
build_b.enqueue
end
- it 'did not execute pipeline_hook after touched' do
+ it "did not execute pipeline_hook after touched" do
expect(WebMock).not_to have_requested(:post, hook.url)
end
end
def create_build(name, stage_idx)
create(:ci_build,
- :created,
- pipeline: pipeline,
- name: name,
- stage_idx: stage_idx)
+ :created,
+ pipeline: pipeline,
+ name: name,
+ stage_idx: stage_idx)
end
end
describe "#merge_requests" do
let(:project) { create(:project) }
- let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master', sha: 'a288a022a53a5a944fae87bcec6efc87b7061808') }
+ let(:pipeline) { create(:ci_empty_pipeline, status: "created", project: project, ref: "master", sha: "a288a022a53a5a944fae87bcec6efc87b7061808") }
it "returns merge requests whose `diff_head_sha` matches the pipeline's SHA" do
- allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { 'a288a022a53a5a944fae87bcec6efc87b7061808' }
+ allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { "a288a022a53a5a944fae87bcec6efc87b7061808" }
merge_request = create(:merge_request, source_project: project, head_pipeline: pipeline, source_branch: pipeline.ref)
expect(pipeline.merge_requests).to eq([merge_request])
end
it "doesn't return merge requests whose source branch doesn't match the pipeline's ref" do
- create(:merge_request, source_project: project, source_branch: 'feature', target_branch: 'master')
+ create(:merge_request, source_project: project, source_branch: "feature", target_branch: "master")
expect(pipeline.merge_requests).to be_empty
end
it "doesn't return merge requests whose `diff_head_sha` doesn't match the pipeline's SHA" do
create(:merge_request, source_project: project, source_branch: pipeline.ref)
- allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { '97de212e80737a608d939f648d959671fb0a0142b' }
+ allow_any_instance_of(MergeRequest).to receive(:diff_head_sha) { "97de212e80737a608d939f648d959671fb0a0142b" }
expect(pipeline.merge_requests).to be_empty
end
@@ -2245,8 +2248,8 @@ describe Ci::Pipeline, :mailer do
describe "#all_merge_requests" do
let(:project) { create(:project) }
- shared_examples 'a method that returns all merge requests for a given pipeline' do
- let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: pipeline_project, ref: 'master') }
+ shared_examples "a method that returns all merge requests for a given pipeline" do
+ let(:pipeline) { create(:ci_empty_pipeline, status: "created", project: pipeline_project, ref: "master") }
it "returns all merge requests having the same source branch" do
merge_request = create(:merge_request, source_project: pipeline_project, target_project: project, source_branch: pipeline.ref)
@@ -2255,133 +2258,133 @@ describe Ci::Pipeline, :mailer do
end
it "doesn't return merge requests having a different source branch" do
- create(:merge_request, source_project: pipeline_project, target_project: project, source_branch: 'feature', target_branch: 'master')
+ create(:merge_request, source_project: pipeline_project, target_project: project, source_branch: "feature", target_branch: "master")
expect(pipeline.all_merge_requests).to be_empty
end
- context 'when there is a merge request pipeline' do
- let(:source_branch) { 'feature' }
- let(:target_branch) { 'master' }
+ context "when there is a merge request pipeline" do
+ let(:source_branch) { "feature" }
+ let(:target_branch) { "master" }
let!(:pipeline) do
create(:ci_pipeline,
- source: :merge_request,
- project: pipeline_project,
- ref: source_branch,
- merge_request: merge_request)
+ source: :merge_request,
+ project: pipeline_project,
+ ref: source_branch,
+ merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: pipeline_project,
- source_branch: source_branch,
- target_project: project,
- target_branch: target_branch)
+ source_project: pipeline_project,
+ source_branch: source_branch,
+ target_project: project,
+ target_branch: target_branch)
end
- it 'returns an associated merge request' do
+ it "returns an associated merge request" do
expect(pipeline.all_merge_requests).to eq([merge_request])
end
- context 'when there is another merge request pipeline that targets a different branch' do
- let(:target_branch_2) { 'merge-test' }
+ context "when there is another merge request pipeline that targets a different branch" do
+ let(:target_branch_2) { "merge-test" }
let!(:pipeline_2) do
create(:ci_pipeline,
- source: :merge_request,
- project: pipeline_project,
- ref: source_branch,
- merge_request: merge_request_2)
+ source: :merge_request,
+ project: pipeline_project,
+ ref: source_branch,
+ merge_request: merge_request_2)
end
let(:merge_request_2) do
create(:merge_request,
- source_project: pipeline_project,
- source_branch: source_branch,
- target_project: project,
- target_branch: target_branch_2)
+ source_project: pipeline_project,
+ source_branch: source_branch,
+ target_project: project,
+ target_branch: target_branch_2)
end
- it 'does not return an associated merge request' do
+ it "does not return an associated merge request" do
expect(pipeline.all_merge_requests).not_to include(merge_request_2)
end
end
end
end
- it_behaves_like 'a method that returns all merge requests for a given pipeline' do
+ it_behaves_like "a method that returns all merge requests for a given pipeline" do
let(:pipeline_project) { project }
end
- context 'for a fork' do
+ context "for a fork" do
let(:fork) { fork_project(project) }
- it_behaves_like 'a method that returns all merge requests for a given pipeline' do
+ it_behaves_like "a method that returns all merge requests for a given pipeline" do
let(:pipeline_project) { fork }
end
end
end
- describe '#stuck?' do
+ describe "#stuck?" do
before do
create(:ci_build, :pending, pipeline: pipeline)
end
- context 'when pipeline is stuck' do
- it 'is stuck' do
+ context "when pipeline is stuck" do
+ it "is stuck" do
expect(pipeline).to be_stuck
end
end
- context 'when pipeline is not stuck' do
+ context "when pipeline is not stuck" do
before do
create(:ci_runner, :instance, :online)
end
- it 'is not stuck' do
+ it "is not stuck" do
expect(pipeline).not_to be_stuck
end
end
end
- describe '#has_yaml_errors?' do
- context 'when pipeline has errors' do
+ describe "#has_yaml_errors?" do
+ context "when pipeline has errors" do
let(:pipeline) do
- create(:ci_pipeline, config: { rspec: nil })
+ create(:ci_pipeline, config: {rspec: nil})
end
- it 'contains yaml errors' do
+ it "contains yaml errors" do
expect(pipeline).to have_yaml_errors
end
end
- context 'when pipeline does not have errors' do
+ context "when pipeline does not have errors" do
let(:pipeline) do
- create(:ci_pipeline, config: { rspec: { script: 'rake test' } })
+ create(:ci_pipeline, config: {rspec: {script: "rake test"}})
end
- it 'does not contain yaml errors' do
+ it "does not contain yaml errors" do
expect(pipeline).not_to have_yaml_errors
end
end
end
- describe 'notifications when pipeline success or failed' do
+ describe "notifications when pipeline success or failed" do
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- sha: project.commit('master').sha,
- user: create(:user))
+ project: project,
+ sha: project.commit("master").sha,
+ user: create(:user))
end
before do
project.add_developer(pipeline.user)
pipeline.user.global_notification_setting
- .update(level: 'custom', failed_pipeline: true, success_pipeline: true)
+ .update(level: "custom", failed_pipeline: true, success_pipeline: true)
perform_enqueued_jobs do
pipeline.enqueue
@@ -2389,29 +2392,29 @@ describe Ci::Pipeline, :mailer do
end
end
- shared_examples 'sending a notification' do
- it 'sends an email' do
+ shared_examples "sending a notification" do
+ it "sends an email" do
should_only_email(pipeline.user, kind: :bcc)
end
end
- shared_examples 'not sending any notification' do
- it 'does not send any email' do
+ shared_examples "not sending any notification" do
+ it "does not send any email" do
should_not_email_anyone
end
end
- context 'with success pipeline' do
+ context "with success pipeline" do
before do
perform_enqueued_jobs do
pipeline.succeed
end
end
- it_behaves_like 'sending a notification'
+ it_behaves_like "sending a notification"
end
- context 'with failed pipeline' do
+ context "with failed pipeline" do
before do
perform_enqueued_jobs do
create(:ci_build, :failed, pipeline: pipeline)
@@ -2421,46 +2424,46 @@ describe Ci::Pipeline, :mailer do
end
end
- it_behaves_like 'sending a notification'
+ it_behaves_like "sending a notification"
end
- context 'with skipped pipeline' do
+ context "with skipped pipeline" do
before do
perform_enqueued_jobs do
pipeline.skip
end
end
- it_behaves_like 'not sending any notification'
+ it_behaves_like "not sending any notification"
end
- context 'with cancelled pipeline' do
+ context "with cancelled pipeline" do
before do
perform_enqueued_jobs do
pipeline.cancel
end
end
- it_behaves_like 'not sending any notification'
+ it_behaves_like "not sending any notification"
end
end
- describe '#latest_builds_with_artifacts' do
+ describe "#latest_builds_with_artifacts" do
let!(:pipeline) { create(:ci_pipeline, :success) }
let!(:build) do
create(:ci_build, :success, :artifacts, pipeline: pipeline)
end
- it 'returns an Array' do
+ it "returns an Array" do
expect(pipeline.latest_builds_with_artifacts).to be_an_instance_of(Array)
end
- it 'returns the latest builds' do
+ it "returns the latest builds" do
expect(pipeline.latest_builds_with_artifacts).to eq([build])
end
- it 'memoizes the returned relation' do
+ it "memoizes the returned relation" do
query_count = ActiveRecord::QueryRecorder
.new { 2.times { pipeline.latest_builds_with_artifacts.to_a } }
.count
@@ -2469,28 +2472,28 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#has_test_reports?' do
+ describe "#has_test_reports?" do
subject { pipeline.has_test_reports? }
- context 'when pipeline has builds with test reports' do
+ context "when pipeline has builds with test reports" do
before do
create(:ci_build, :test_reports, pipeline: pipeline, project: project)
end
- context 'when pipeline status is running' do
+ context "when pipeline status is running" do
let(:pipeline) { create(:ci_pipeline, :running, project: project) }
it { is_expected.to be_falsey }
end
- context 'when pipeline status is success' do
+ context "when pipeline status is success" do
let(:pipeline) { create(:ci_pipeline, :success, project: project) }
it { is_expected.to be_truthy }
end
end
- context 'when pipeline does not have builds with test reports' do
+ context "when pipeline does not have builds with test reports" do
before do
create(:ci_build, :artifacts, pipeline: pipeline, project: project)
end
@@ -2500,7 +2503,7 @@ describe Ci::Pipeline, :mailer do
it { is_expected.to be_falsey }
end
- context 'when retried build has test reports' do
+ context "when retried build has test reports" do
before do
create(:ci_build, :retried, :test_reports, pipeline: pipeline, project: project)
end
@@ -2511,29 +2514,29 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#test_reports' do
+ describe "#test_reports" do
subject { pipeline.test_reports }
- context 'when pipeline has multiple builds with test reports' do
- let!(:build_rspec) { create(:ci_build, :success, name: 'rspec', pipeline: pipeline, project: project) }
- let!(:build_java) { create(:ci_build, :success, name: 'java', pipeline: pipeline, project: project) }
+ context "when pipeline has multiple builds with test reports" do
+ let!(:build_rspec) { create(:ci_build, :success, name: "rspec", pipeline: pipeline, project: project) }
+ let!(:build_java) { create(:ci_build, :success, name: "java", pipeline: pipeline, project: project) }
before do
create(:ci_job_artifact, :junit, job: build_rspec, project: project)
create(:ci_job_artifact, :junit_with_ant, job: build_java, project: project)
end
- it 'returns test reports with collected data' do
+ it "returns test reports with collected data" do
expect(subject.total_count).to be(7)
expect(subject.success_count).to be(5)
expect(subject.failed_count).to be(2)
end
- context 'when builds are retried' do
- let!(:build_rspec) { create(:ci_build, :retried, :success, name: 'rspec', pipeline: pipeline, project: project) }
- let!(:build_java) { create(:ci_build, :retried, :success, name: 'java', pipeline: pipeline, project: project) }
+ context "when builds are retried" do
+ let!(:build_rspec) { create(:ci_build, :retried, :success, name: "rspec", pipeline: pipeline, project: project) }
+ let!(:build_java) { create(:ci_build, :retried, :success, name: "java", pipeline: pipeline, project: project) }
- it 'does not take retried builds into account' do
+ it "does not take retried builds into account" do
expect(subject.total_count).to be(0)
expect(subject.success_count).to be(0)
expect(subject.failed_count).to be(0)
@@ -2541,41 +2544,41 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when pipeline does not have any builds with test reports' do
- it 'returns empty test reports' do
+ context "when pipeline does not have any builds with test reports" do
+ it "returns empty test reports" do
expect(subject.total_count).to be(0)
end
end
end
- describe '#total_size' do
+ describe "#total_size" do
let!(:build_job1) { create(:ci_build, pipeline: pipeline, stage_idx: 0) }
let!(:build_job2) { create(:ci_build, pipeline: pipeline, stage_idx: 0) }
let!(:test_job_failed_and_retried) { create(:ci_build, :failed, :retried, pipeline: pipeline, stage_idx: 1) }
let!(:second_test_job) { create(:ci_build, pipeline: pipeline, stage_idx: 1) }
let!(:deploy_job) { create(:ci_build, pipeline: pipeline, stage_idx: 2) }
- it 'returns all jobs (including failed and retried)' do
+ it "returns all jobs (including failed and retried)" do
expect(pipeline.total_size).to eq(5)
end
end
- describe '#status' do
- context 'when transitioning to failed' do
- context 'when pipeline has autodevops as source' do
+ describe "#status" do
+ context "when transitioning to failed" do
+ context "when pipeline has autodevops as source" do
let(:pipeline) { create(:ci_pipeline, :running, :auto_devops_source) }
- it 'calls autodevops disable service' do
+ it "calls autodevops disable service" do
expect(AutoDevops::DisableWorker).to receive(:perform_async).with(pipeline.id)
pipeline.drop
end
end
- context 'when pipeline has other source' do
+ context "when pipeline has other source" do
let(:pipeline) { create(:ci_pipeline, :running, :repository_source) }
- it 'does not call auto devops disable service' do
+ it "does not call auto devops disable service" do
expect(AutoDevops::DisableWorker).not_to receive(:perform_async)
pipeline.drop
@@ -2584,8 +2587,8 @@ describe Ci::Pipeline, :mailer do
end
end
- describe '#default_branch?' do
- let(:default_branch) { 'master'}
+ describe "#default_branch?" do
+ let(:default_branch) { "master"}
subject { pipeline.default_branch? }
@@ -2593,7 +2596,7 @@ describe Ci::Pipeline, :mailer do
allow(project).to receive(:default_branch).and_return(default_branch)
end
- context 'when pipeline ref is the default branch of the project' do
+ context "when pipeline ref is the default branch of the project" do
let(:pipeline) do
build(:ci_empty_pipeline, status: :created, project: project, ref: default_branch)
end
@@ -2603,9 +2606,9 @@ describe Ci::Pipeline, :mailer do
end
end
- context 'when pipeline ref is not the default branch of the project' do
+ context "when pipeline ref is not the default branch of the project" do
let(:pipeline) do
- build(:ci_empty_pipeline, status: :created, project: project, ref: 'another_branch')
+ build(:ci_empty_pipeline, status: :created, project: project, ref: "another_branch")
end
it "returns false" do
diff --git a/spec/models/ci/pipeline_variable_spec.rb b/spec/models/ci/pipeline_variable_spec.rb
index 03d09cb31d6..d457e34a6ba 100644
--- a/spec/models/ci/pipeline_variable_spec.rb
+++ b/spec/models/ci/pipeline_variable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelineVariable do
subject { build(:ci_pipeline_variable) }
@@ -6,12 +6,12 @@ describe Ci::PipelineVariable do
it { is_expected.to include_module(HasVariable) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:pipeline_id) }
- describe '#hook_attrs' do
- let(:variable) { create(:ci_pipeline_variable, key: 'foo', value: 'bar') }
+ describe "#hook_attrs" do
+ let(:variable) { create(:ci_pipeline_variable, key: "foo", value: "bar") }
subject { variable.hook_attrs }
it { is_expected.to be_a(Hash) }
- it { is_expected.to eq({ key: 'foo', value: 'bar' }) }
+ it { is_expected.to eq({key: "foo", value: "bar"}) }
end
end
diff --git a/spec/models/ci/runner_spec.rb b/spec/models/ci/runner_spec.rb
index eb2daed7f32..0fe42d74487 100644
--- a/spec/models/ci/runner_spec.rb
+++ b/spec/models/ci/runner_spec.rb
@@ -1,76 +1,76 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Runner do
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:access_level) }
it { is_expected.to validate_presence_of(:runner_type) }
- context 'when runner is not allowed to pick untagged jobs' do
- context 'when runner does not have tags' do
- it 'is not valid' do
+ context "when runner is not allowed to pick untagged jobs" do
+ context "when runner does not have tags" do
+ it "is not valid" do
runner = build(:ci_runner, tag_list: [], run_untagged: false)
expect(runner).to be_invalid
end
end
- context 'when runner has tags' do
- it 'is valid' do
- runner = build(:ci_runner, tag_list: ['tag'], run_untagged: false)
+ context "when runner has tags" do
+ it "is valid" do
+ runner = build(:ci_runner, tag_list: ["tag"], run_untagged: false)
expect(runner).to be_valid
end
end
end
- context '#exactly_one_group' do
+ context "#exactly_one_group" do
let(:group) { create(:group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
- it 'disallows assigning group if already assigned to a group' do
+ it "disallows assigning group if already assigned to a group" do
runner.groups << build(:group)
expect(runner).not_to be_valid
- expect(runner.errors.full_messages).to include('Runner needs to be assigned to exactly one group')
+ expect(runner.errors.full_messages).to include("Runner needs to be assigned to exactly one group")
end
end
- context 'runner_type validations' do
+ context "runner_type validations" do
set(:group) { create(:group) }
set(:project) { create(:project) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let(:project_runner) { create(:ci_runner, :project, projects: [project]) }
let(:instance_runner) { create(:ci_runner, :instance) }
- it 'disallows assigning group to project_type runner' do
+ it "disallows assigning group to project_type runner" do
project_runner.groups << build(:group)
expect(project_runner).not_to be_valid
- expect(project_runner.errors.full_messages).to include('Runner cannot have groups assigned')
+ expect(project_runner.errors.full_messages).to include("Runner cannot have groups assigned")
end
- it 'disallows assigning group to instance_type runner' do
+ it "disallows assigning group to instance_type runner" do
instance_runner.groups << build(:group)
expect(instance_runner).not_to be_valid
- expect(instance_runner.errors.full_messages).to include('Runner cannot have groups assigned')
+ expect(instance_runner.errors.full_messages).to include("Runner cannot have groups assigned")
end
- it 'disallows assigning project to group_type runner' do
+ it "disallows assigning project to group_type runner" do
group_runner.projects << build(:project)
expect(group_runner).not_to be_valid
- expect(group_runner.errors.full_messages).to include('Runner cannot have projects assigned')
+ expect(group_runner.errors.full_messages).to include("Runner cannot have projects assigned")
end
- it 'disallows assigning project to instance_type runner' do
+ it "disallows assigning project to instance_type runner" do
instance_runner.projects << build(:project)
expect(instance_runner).not_to be_valid
- expect(instance_runner.errors.full_messages).to include('Runner cannot have projects assigned')
+ expect(instance_runner.errors.full_messages).to include("Runner cannot have projects assigned")
end
- it 'should fail to save a group assigned to a project runner even if the runner is already saved' do
+ it "should fail to save a group assigned to a project runner even if the runner is already saved" do
group_runner
expect { create(:group, runners: [project_runner]) }
@@ -79,8 +79,8 @@ describe Ci::Runner do
end
end
- describe '#access_level' do
- context 'when creating new runner and access_level is nil' do
+ describe "#access_level" do
+ context "when creating new runner and access_level is nil" do
let(:runner) do
build(:ci_runner, access_level: nil)
end
@@ -90,7 +90,7 @@ describe Ci::Runner do
end
end
- context 'when creating new runner and access_level is defined in enum' do
+ context "when creating new runner and access_level is defined in enum" do
let(:runner) do
build(:ci_runner, access_level: :not_protected)
end
@@ -100,27 +100,27 @@ describe Ci::Runner do
end
end
- context 'when creating new runner and access_level is not defined in enum' do
+ context "when creating new runner and access_level is not defined in enum" do
it "raises an error" do
expect { build(:ci_runner, access_level: :this_is_not_defined) }.to raise_error(ArgumentError)
end
end
end
- describe '.instance_type' do
+ describe ".instance_type" do
let(:group) { create(:group) }
let(:project) { create(:project) }
let!(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:project_runner) { create(:ci_runner, :project, projects: [project]) }
let!(:shared_runner) { create(:ci_runner, :instance) }
- it 'returns only shared runners' do
+ it "returns only shared runners" do
expect(described_class.instance_type).to contain_exactly(shared_runner)
end
end
- describe '.belonging_to_project' do
- it 'returns the specific project runner' do
+ describe ".belonging_to_project" do
+ it "returns the specific project runner" do
# own
specific_project = create(:project)
specific_runner = create(:ci_runner, :project, projects: [specific_project])
@@ -133,7 +133,7 @@ describe Ci::Runner do
end
end
- describe '.belonging_to_parent_group_of_project' do
+ describe ".belonging_to_parent_group_of_project" do
let(:project) { create(:project, group: group) }
let(:group) { create(:group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
@@ -141,24 +141,24 @@ describe Ci::Runner do
let!(:unrelated_project) { create(:project, group: unrelated_group) }
let!(:unrelated_runner) { create(:ci_runner, :group, groups: [unrelated_group]) }
- it 'returns the specific group runner' do
+ it "returns the specific group runner" do
expect(described_class.belonging_to_parent_group_of_project(project.id)).to contain_exactly(runner)
end
- context 'with a parent group with a runner', :nested_groups do
+ context "with a parent group with a runner", :nested_groups do
let(:runner) { create(:ci_runner, :group, groups: [parent_group]) }
let(:project) { create(:project, group: group) }
let(:group) { create(:group, parent: parent_group) }
let(:parent_group) { create(:group) }
- it 'returns the group runner from the parent group' do
+ it "returns the group runner from the parent group" do
expect(described_class.belonging_to_parent_group_of_project(project.id)).to contain_exactly(runner)
end
end
end
- describe '.owned_or_instance_wide' do
- it 'returns a globally shared, a project specific and a group specific runner' do
+ describe ".owned_or_instance_wide" do
+ it "returns a globally shared, a project specific and a group specific runner" do
# group specific
group = create(:group)
project = create(:project, group: group)
@@ -176,32 +176,32 @@ describe Ci::Runner do
end
end
- describe '#display_name' do
- it 'returns the description if it has a value' do
- runner = build(:ci_runner, description: 'Linux/Ruby-1.9.3-p448')
- expect(runner.display_name).to eq 'Linux/Ruby-1.9.3-p448'
+ describe "#display_name" do
+ it "returns the description if it has a value" do
+ runner = build(:ci_runner, description: "Linux/Ruby-1.9.3-p448")
+ expect(runner.display_name).to eq "Linux/Ruby-1.9.3-p448"
end
- it 'returns the token if it does not have a description' do
+ it "returns the token if it does not have a description" do
runner = create(:ci_runner)
expect(runner.display_name).to eq runner.description
end
- it 'returns the token if the description is an empty string' do
- runner = build(:ci_runner, description: '', token: 'token')
+ it "returns the token if the description is an empty string" do
+ runner = build(:ci_runner, description: "", token: "token")
expect(runner.display_name).to eq runner.token
end
end
- describe '#assign_to' do
+ describe "#assign_to" do
let(:project) { create(:project) }
subject { runner.assign_to(project) }
- context 'with shared_runner' do
+ context "with shared_runner" do
let(:runner) { create(:ci_runner, :instance) }
- it 'transitions shared runner to project runner and assigns project' do
+ it "transitions shared runner to project runner and assigns project" do
expect(subject).to be_truthy
expect(runner).to be_project_type
@@ -210,18 +210,18 @@ describe Ci::Runner do
end
end
- context 'with group runner' do
+ context "with group runner" do
let(:group) { create(:group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }
- .to raise_error(ArgumentError, 'Transitioning a group runner to a project runner is not supported')
+ .to raise_error(ArgumentError, "Transitioning a group runner to a project runner is not supported")
end
end
end
- describe '.online' do
+ describe ".online" do
subject { described_class.online }
before do
@@ -232,7 +232,7 @@ describe Ci::Runner do
it { is_expected.to eq([@runner2])}
end
- describe '#online?' do
+ describe "#online?" do
let(:runner) { create(:ci_runner, :instance) }
subject { runner.online? }
@@ -243,12 +243,12 @@ describe Ci::Runner do
.with(:platform).and_return("darwin")
end
- context 'no cache value' do
+ context "no cache value" do
before do
stub_redis_runner_contacted_at(nil)
end
- context 'never contacted' do
+ context "never contacted" do
before do
runner.contacted_at = nil
end
@@ -256,7 +256,7 @@ describe Ci::Runner do
it { is_expected.to be_falsey }
end
- context 'contacted long time ago time' do
+ context "contacted long time ago time" do
before do
runner.contacted_at = 1.year.ago
end
@@ -264,7 +264,7 @@ describe Ci::Runner do
it { is_expected.to be_falsey }
end
- context 'contacted 1s ago' do
+ context "contacted 1s ago" do
before do
runner.contacted_at = 1.second.ago
end
@@ -273,8 +273,8 @@ describe Ci::Runner do
end
end
- context 'with cache value' do
- context 'contacted long time ago time' do
+ context "with cache value" do
+ context "contacted long time ago time" do
before do
runner.contacted_at = 1.year.ago
stub_redis_runner_contacted_at(1.year.ago.to_s)
@@ -283,7 +283,7 @@ describe Ci::Runner do
it { is_expected.to be_falsey }
end
- context 'contacted 1s ago' do
+ context "contacted 1s ago" do
before do
runner.contacted_at = 50.minutes.ago
stub_redis_runner_contacted_at(1.second.ago.to_s)
@@ -297,12 +297,12 @@ describe Ci::Runner do
Gitlab::Redis::SharedState.with do |redis|
cache_key = runner.send(:cache_attribute_key)
expect(redis).to receive(:get).with(cache_key)
- .and_return({ contacted_at: value }.to_json).at_least(:once)
+ .and_return({contacted_at: value}.to_json).at_least(:once)
end
end
end
- describe '.offline' do
+ describe ".offline" do
subject { described_class.offline }
before do
@@ -313,7 +313,7 @@ describe Ci::Runner do
it { is_expected.to eq([@runner1])}
end
- describe '#can_pick?' do
+ describe "#can_pick?" do
set(:pipeline) { create(:ci_pipeline) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:runner_project) { build.project }
@@ -323,110 +323,110 @@ describe Ci::Runner do
subject { runner.can_pick?(build) }
- context 'a different runner' do
+ context "a different runner" do
let(:other_project) { create(:project) }
let(:other_runner) { create(:ci_runner, :project, projects: [other_project], tag_list: tag_list, run_untagged: run_untagged) }
- it 'cannot handle builds' do
+ it "cannot handle builds" do
expect(other_runner.can_pick?(build)).to be_falsey
end
end
- context 'when runner does not have tags' do
- it 'can handle builds without tags' do
+ context "when runner does not have tags" do
+ it "can handle builds without tags" do
expect(runner.can_pick?(build)).to be_truthy
end
- it 'cannot handle build with tags' do
- build.tag_list = ['aa']
+ it "cannot handle build with tags" do
+ build.tag_list = ["aa"]
expect(runner.can_pick?(build)).to be_falsey
end
end
- context 'when runner has tags' do
- let(:tag_list) { %w(bb cc) }
+ context "when runner has tags" do
+ let(:tag_list) { %w[bb cc] }
- shared_examples 'tagged build picker' do
- it 'can handle build with matching tags' do
- build.tag_list = ['bb']
+ shared_examples "tagged build picker" do
+ it "can handle build with matching tags" do
+ build.tag_list = ["bb"]
expect(runner.can_pick?(build)).to be_truthy
end
- it 'cannot handle build without matching tags' do
- build.tag_list = ['aa']
+ it "cannot handle build without matching tags" do
+ build.tag_list = ["aa"]
expect(runner.can_pick?(build)).to be_falsey
end
end
- context 'when runner can pick untagged jobs' do
- it 'can handle builds without tags' do
+ context "when runner can pick untagged jobs" do
+ it "can handle builds without tags" do
expect(runner.can_pick?(build)).to be_truthy
end
- it_behaves_like 'tagged build picker'
+ it_behaves_like "tagged build picker"
end
- context 'when runner cannot pick untagged jobs' do
+ context "when runner cannot pick untagged jobs" do
let(:run_untagged) { false }
- it 'cannot handle builds without tags' do
+ it "cannot handle builds without tags" do
expect(runner.can_pick?(build)).to be_falsey
end
- it_behaves_like 'tagged build picker'
+ it_behaves_like "tagged build picker"
end
end
- context 'when runner is shared' do
+ context "when runner is shared" do
let(:runner) { create(:ci_runner, :instance) }
- it 'can handle builds' do
+ it "can handle builds" do
expect(runner.can_pick?(build)).to be_truthy
end
- context 'when runner is locked' do
+ context "when runner is locked" do
let(:runner) { create(:ci_runner, :instance, locked: true) }
- it 'can handle builds' do
+ it "can handle builds" do
expect(runner.can_pick?(build)).to be_truthy
end
end
end
- context 'when runner is not shared' do
- context 'when runner is assigned to a project' do
- it 'can handle builds' do
+ context "when runner is not shared" do
+ context "when runner is assigned to a project" do
+ it "can handle builds" do
expect(runner.can_pick?(build)).to be_truthy
end
end
- context 'when runner is assigned to another project' do
+ context "when runner is assigned to another project" do
let(:runner_project) { create(:project) }
- it 'cannot handle builds' do
+ it "cannot handle builds" do
expect(runner.can_pick?(build)).to be_falsey
end
end
- context 'when runner is assigned to a group' do
+ context "when runner is assigned to a group" do
let(:group) { create(:group, projects: [build.project]) }
let(:runner) { create(:ci_runner, :group, tag_list: tag_list, run_untagged: run_untagged, groups: [group]) }
- it 'can handle builds' do
+ it "can handle builds" do
expect(runner.can_pick?(build)).to be_truthy
end
end
end
- context 'when access_level of runner is not_protected' do
+ context "when access_level of runner is not_protected" do
before do
runner.not_protected!
end
- context 'when build is protected' do
+ context "when build is protected" do
before do
build.protected = true
end
@@ -434,7 +434,7 @@ describe Ci::Runner do
it { is_expected.to be_truthy }
end
- context 'when build is unprotected' do
+ context "when build is unprotected" do
before do
build.protected = false
end
@@ -443,12 +443,12 @@ describe Ci::Runner do
end
end
- context 'when access_level of runner is ref_protected' do
+ context "when access_level of runner is ref_protected" do
before do
runner.ref_protected!
end
- context 'when build is protected' do
+ context "when build is protected" do
before do
build.protected = true
end
@@ -456,7 +456,7 @@ describe Ci::Runner do
it { is_expected.to be_truthy }
end
- context 'when build is unprotected' do
+ context "when build is unprotected" do
before do
build.protected = false
end
@@ -466,12 +466,12 @@ describe Ci::Runner do
end
end
- describe '#status' do
+ describe "#status" do
let(:runner) { create(:ci_runner, :instance, contacted_at: 1.second.ago) }
subject { runner.status }
- context 'never connected' do
+ context "never connected" do
before do
runner.contacted_at = nil
end
@@ -479,7 +479,7 @@ describe Ci::Runner do
it { is_expected.to eq(:not_connected) }
end
- context 'contacted 1s ago' do
+ context "contacted 1s ago" do
before do
runner.contacted_at = 1.second.ago
end
@@ -487,7 +487,7 @@ describe Ci::Runner do
it { is_expected.to eq(:online) }
end
- context 'contacted long time ago' do
+ context "contacted long time ago" do
before do
runner.contacted_at = 1.year.ago
end
@@ -495,7 +495,7 @@ describe Ci::Runner do
it { is_expected.to eq(:offline) }
end
- context 'inactive' do
+ context "inactive" do
before do
runner.active = false
end
@@ -504,50 +504,50 @@ describe Ci::Runner do
end
end
- describe '#tick_runner_queue' do
+ describe "#tick_runner_queue" do
let(:runner) { create(:ci_runner) }
- it 'returns a new last_update value' do
+ it "returns a new last_update value" do
expect(runner.tick_runner_queue).not_to be_empty
end
end
- describe '#ensure_runner_queue_value' do
+ describe "#ensure_runner_queue_value" do
let(:runner) { create(:ci_runner) }
- it 'sets a new last_update value when it is called the first time' do
+ it "sets a new last_update value when it is called the first time" do
last_update = runner.ensure_runner_queue_value
expect_value_in_queues.to eq(last_update)
end
- it 'does not change if it is not expired and called again' do
+ it "does not change if it is not expired and called again" do
last_update = runner.ensure_runner_queue_value
expect(runner.ensure_runner_queue_value).to eq(last_update)
expect_value_in_queues.to eq(last_update)
end
- context 'updates runner queue after changing editable value' do
+ context "updates runner queue after changing editable value" do
let!(:last_update) { runner.ensure_runner_queue_value }
before do
- Ci::UpdateRunnerService.new(runner).update(description: 'new runner')
+ Ci::UpdateRunnerService.new(runner).update(description: "new runner")
end
- it 'sets a new last_update value' do
+ it "sets a new last_update value" do
expect_value_in_queues.not_to eq(last_update)
end
end
- context 'does not update runner value after save' do
+ context "does not update runner value after save" do
let!(:last_update) { runner.ensure_runner_queue_value }
before do
runner.touch
end
- it 'has an old last_update value' do
+ it "has an old last_update value" do
expect_value_in_queues.to eq(last_update)
end
end
@@ -560,34 +560,34 @@ describe Ci::Runner do
end
end
- describe '#update_cached_info' do
+ describe "#update_cached_info" do
let(:runner) { create(:ci_runner, :project) }
- subject { runner.update_cached_info(architecture: '18-bit') }
+ subject { runner.update_cached_info(architecture: "18-bit") }
- context 'when database was updated recently' do
+ context "when database was updated recently" do
before do
runner.contacted_at = Time.now
end
- it 'updates cache' do
+ it "updates cache" do
expect_redis_update
subject
end
end
- context 'when database was not updated recently' do
+ context "when database was not updated recently" do
before do
runner.contacted_at = 2.hours.ago
end
- context 'with invalid runner' do
+ context "with invalid runner" do
before do
runner.projects = []
end
- it 'still updates redis cache and database' do
+ it "still updates redis cache and database" do
expect(runner).to be_invalid
expect_redis_update
@@ -595,7 +595,7 @@ describe Ci::Runner do
end
end
- it 'updates redis cache and database' do
+ it "updates redis cache and database" do
expect_redis_update
does_db_update
end
@@ -614,10 +614,10 @@ describe Ci::Runner do
end
end
- describe '#destroy' do
+ describe "#destroy" do
let(:runner) { create(:ci_runner) }
- context 'when there is a tick in the queue' do
+ context "when there is a tick in the queue" do
let!(:queue_key) { runner.send(:runner_queue_key) }
before do
@@ -625,7 +625,7 @@ describe Ci::Runner do
runner.destroy
end
- it 'cleans up the queue' do
+ it "cleans up the queue" do
Gitlab::Redis::Queues.with do |redis|
expect(redis.get(queue_key)).to be_nil
end
@@ -633,7 +633,7 @@ describe Ci::Runner do
end
end
- describe '.assignable_for' do
+ describe ".assignable_for" do
let(:project) { create(:project) }
let(:group) { create(:group) }
let(:another_project) { create(:project) }
@@ -642,13 +642,13 @@ describe Ci::Runner do
let!(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:instance_runner) { create(:ci_runner, :instance) }
- context 'with already assigned project' do
+ context "with already assigned project" do
subject { described_class.assignable_for(project) }
it { is_expected.to be_empty }
end
- context 'with a different project' do
+ context "with a different project" do
subject { described_class.assignable_for(another_project) }
it { is_expected.to include(unlocked_project_runner) }
@@ -675,95 +675,95 @@ describe Ci::Runner do
end
end
- describe '#has_tags?' do
- context 'when runner has tags' do
- subject { create(:ci_runner, tag_list: ['tag']) }
+ describe "#has_tags?" do
+ context "when runner has tags" do
+ subject { create(:ci_runner, tag_list: ["tag"]) }
it { is_expected.to have_tags }
end
- context 'when runner does not have tags' do
+ context "when runner does not have tags" do
subject { create(:ci_runner, tag_list: []) }
it { is_expected.not_to have_tags }
end
end
- describe '.search' do
- let(:runner) { create(:ci_runner, token: '123abc', description: 'test runner') }
+ describe ".search" do
+ let(:runner) { create(:ci_runner, token: "123abc", description: "test runner") }
- it 'returns runners with a matching token' do
+ it "returns runners with a matching token" do
expect(described_class.search(runner.token)).to eq([runner])
end
- it 'returns runners with a partially matching token' do
+ it "returns runners with a partially matching token" do
expect(described_class.search(runner.token[0..2])).to eq([runner])
end
- it 'returns runners with a matching token regardless of the casing' do
+ it "returns runners with a matching token regardless of the casing" do
expect(described_class.search(runner.token.upcase)).to eq([runner])
end
- it 'returns runners with a matching description' do
+ it "returns runners with a matching description" do
expect(described_class.search(runner.description)).to eq([runner])
end
- it 'returns runners with a partially matching description' do
+ it "returns runners with a partially matching description" do
expect(described_class.search(runner.description[0..2])).to eq([runner])
end
- it 'returns runners with a matching description regardless of the casing' do
+ it "returns runners with a matching description regardless of the casing" do
expect(described_class.search(runner.description.upcase)).to eq([runner])
end
end
- describe '#assigned_to_group?' do
+ describe "#assigned_to_group?" do
subject { runner.assigned_to_group? }
- context 'when project runner' do
- let(:runner) { create(:ci_runner, :project, description: 'Project runner', projects: [project]) }
+ context "when project runner" do
+ let(:runner) { create(:ci_runner, :project, description: "Project runner", projects: [project]) }
let(:project) { create(:project) }
it { is_expected.to be_falsey }
end
- context 'when shared runner' do
- let(:runner) { create(:ci_runner, :instance, description: 'Shared runner') }
+ context "when shared runner" do
+ let(:runner) { create(:ci_runner, :instance, description: "Shared runner") }
it { is_expected.to be_falsey }
end
- context 'when group runner' do
+ context "when group runner" do
let(:group) { create(:group) }
- let(:runner) { create(:ci_runner, :group, description: 'Group runner', groups: [group]) }
+ let(:runner) { create(:ci_runner, :group, description: "Group runner", groups: [group]) }
it { is_expected.to be_truthy }
end
end
- describe '#assigned_to_project?' do
+ describe "#assigned_to_project?" do
subject { runner.assigned_to_project? }
- context 'when group runner' do
- let(:runner) { create(:ci_runner, :group, description: 'Group runner', groups: [group]) }
+ context "when group runner" do
+ let(:runner) { create(:ci_runner, :group, description: "Group runner", groups: [group]) }
let(:group) { create(:group) }
it { is_expected.to be_falsey }
end
- context 'when shared runner' do
- let(:runner) { create(:ci_runner, :instance, description: 'Shared runner') }
+ context "when shared runner" do
+ let(:runner) { create(:ci_runner, :instance, description: "Shared runner") }
it { is_expected.to be_falsey }
end
- context 'when project runner' do
- let(:runner) { create(:ci_runner, :project, description: 'Project runner', projects: [project]) }
+ context "when project runner" do
+ let(:runner) { create(:ci_runner, :project, description: "Project runner", projects: [project]) }
let(:project) { create(:project) }
it { is_expected.to be_truthy }
end
end
- describe '#pick_build!' do
- context 'runner can pick the build' do
- it 'calls #tick_runner_queue' do
+ describe "#pick_build!" do
+ context "runner can pick the build" do
+ it "calls #tick_runner_queue" do
ci_build = build(:ci_build)
runner = build(:ci_runner)
allow(runner).to receive(:can_pick?).with(ci_build).and_return(true)
@@ -774,8 +774,8 @@ describe Ci::Runner do
end
end
- context 'runner cannot pick the build' do
- it 'does not call #tick_runner_queue' do
+ context "runner cannot pick the build" do
+ it "does not call #tick_runner_queue" do
ci_build = build(:ci_build)
runner = build(:ci_runner)
allow(runner).to receive(:can_pick?).with(ci_build).and_return(false)
@@ -787,38 +787,38 @@ describe Ci::Runner do
end
end
- describe 'project runner without projects is destroyable' do
+ describe "project runner without projects is destroyable" do
subject { create(:ci_runner, :project, :without_projects) }
- it 'does not have projects' do
+ it "does not have projects" do
expect(subject.runner_projects).to be_empty
end
- it 'can be destroyed' do
+ it "can be destroyed" do
subject
expect { subject.destroy }.to change { described_class.count }.by(-1)
end
end
- describe '.order_by' do
- it 'supports ordering by the contact date' do
+ describe ".order_by" do
+ it "supports ordering by the contact date" do
runner1 = create(:ci_runner, contacted_at: 1.year.ago)
runner2 = create(:ci_runner, contacted_at: 1.month.ago)
- runners = described_class.order_by('contacted_asc')
+ runners = described_class.order_by("contacted_asc")
expect(runners).to eq([runner1, runner2])
end
- it 'supports ordering by the creation date' do
+ it "supports ordering by the creation date" do
runner1 = create(:ci_runner, created_at: 1.year.ago)
runner2 = create(:ci_runner, created_at: 1.month.ago)
- runners = described_class.order_by('created_asc')
+ runners = described_class.order_by("created_asc")
expect(runners).to eq([runner2, runner1])
end
end
- describe '#uncached_contacted_at' do
+ describe "#uncached_contacted_at" do
let(:contacted_at_stored) { 1.hour.ago.change(usec: 0) }
let(:runner) { create(:ci_runner, contacted_at: contacted_at_stored) }
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb
index 3228c400155..9c2790f8ae7 100644
--- a/spec/models/ci/stage_spec.rb
+++ b/spec/models/ci/stage_spec.rb
@@ -1,122 +1,122 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Stage, :models do
let(:stage) { create(:ci_stage_entity) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'associations' do
+ describe "associations" do
before do
create(:ci_build, stage_id: stage.id)
create(:commit_status, stage_id: stage.id)
end
- describe '#statuses' do
- it 'returns all commit statuses' do
+ describe "#statuses" do
+ it "returns all commit statuses" do
expect(stage.statuses.count).to be 2
end
end
- describe '#builds' do
- it 'returns only builds' do
+ describe "#builds" do
+ it "returns only builds" do
expect(stage.builds).to be_one
end
end
end
- describe '#status' do
- context 'when stage is pending' do
- let(:stage) { create(:ci_stage_entity, status: 'pending') }
+ describe "#status" do
+ context "when stage is pending" do
+ let(:stage) { create(:ci_stage_entity, status: "pending") }
- it 'has a correct status value' do
- expect(stage.status).to eq 'pending'
+ it "has a correct status value" do
+ expect(stage.status).to eq "pending"
end
end
- context 'when stage is success' do
- let(:stage) { create(:ci_stage_entity, status: 'success') }
+ context "when stage is success" do
+ let(:stage) { create(:ci_stage_entity, status: "success") }
- it 'has a correct status value' do
- expect(stage.status).to eq 'success'
+ it "has a correct status value" do
+ expect(stage.status).to eq "success"
end
end
- context 'when stage status is not defined' do
+ context "when stage status is not defined" do
before do
stage.update_column(:status, nil)
end
- it 'sets the default value' do
+ it "sets the default value" do
expect(described_class.find(stage.id).status)
- .to eq 'created'
+ .to eq "created"
end
end
end
- describe '#update_status' do
- context 'when stage objects needs to be updated' do
+ describe "#update_status" do
+ context "when stage objects needs to be updated" do
before do
create(:ci_build, :success, stage_id: stage.id)
create(:ci_build, :running, stage_id: stage.id)
end
- it 'updates stage status correctly' do
+ it "updates stage status correctly" do
expect { stage.update_status }
.to change { stage.reload.status }
- .to 'running'
+ .to "running"
end
end
- context 'when stage has only created builds' do
+ context "when stage has only created builds" do
let(:stage) { create(:ci_stage_entity, status: :created) }
before do
create(:ci_build, :created, stage_id: stage.id)
end
- it 'updates status to skipped' do
- expect(stage.reload.status).to eq 'created'
+ it "updates status to skipped" do
+ expect(stage.reload.status).to eq "created"
end
end
- context 'when stage is skipped because of skipped builds' do
+ context "when stage is skipped because of skipped builds" do
before do
create(:ci_build, :skipped, stage_id: stage.id)
end
- it 'updates status to skipped' do
+ it "updates status to skipped" do
expect { stage.update_status }
.to change { stage.reload.status }
- .to 'skipped'
+ .to "skipped"
end
end
- context 'when stage is scheduled because of scheduled builds' do
+ context "when stage is scheduled because of scheduled builds" do
before do
create(:ci_build, :scheduled, stage_id: stage.id)
end
- it 'updates status to scheduled' do
+ it "updates status to scheduled" do
expect { stage.update_status }
.to change { stage.reload.status }
- .to 'scheduled'
+ .to "scheduled"
end
end
- context 'when stage is skipped because is empty' do
- it 'updates status to skipped' do
+ context "when stage is skipped because is empty" do
+ it "updates status to skipped" do
expect { stage.update_status }
.to change { stage.reload.status }
- .to 'skipped'
+ .to "skipped"
end
end
- context 'when stage object is locked' do
+ context "when stage object is locked" do
before do
create(:ci_build, :failed, stage_id: stage.id)
end
- it 'retries a lock to update a stage status' do
+ it "retries a lock to update a stage status" do
stage.lock_version = 100
stage.update_status
@@ -125,21 +125,21 @@ describe Ci::Stage, :models do
end
end
- context 'when statuses status was not recognized' do
+ context "when statuses status was not recognized" do
before do
allow(stage)
.to receive_message_chain(:statuses, :latest, :status)
.and_return(:unknown)
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { stage.update_status }
.to raise_error(HasStatus::UnknownStatusError)
end
end
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
using RSpec::Parameterized::TableSyntax
let(:user) { create(:user) }
@@ -168,12 +168,12 @@ describe Ci::Stage, :models do
end
end
- it 'has a correct label' do
+ it "has a correct label" do
expect(subject.label).to eq label.to_s
end
end
- context 'when stage has warnings' do
+ context "when stage has warnings" do
before do
create(:ci_build, project: stage.project,
pipeline: stage.pipeline,
@@ -184,48 +184,48 @@ describe Ci::Stage, :models do
stage.update_status
end
- it 'is passed with warnings' do
- expect(subject.label).to eq 'passed with warnings'
+ it "is passed with warnings" do
+ expect(subject.label).to eq "passed with warnings"
end
end
end
- describe '#groups' do
+ describe "#groups" do
before do
- create(:ci_build, stage_id: stage.id, name: 'rspec 0 1')
- create(:ci_build, stage_id: stage.id, name: 'rspec 0 2')
+ create(:ci_build, stage_id: stage.id, name: "rspec 0 1")
+ create(:ci_build, stage_id: stage.id, name: "rspec 0 2")
end
- it 'groups stage builds by name' do
+ it "groups stage builds by name" do
expect(stage.groups).to be_one
- expect(stage.groups.first.name).to eq 'rspec'
+ expect(stage.groups.first.name).to eq "rspec"
end
end
- describe '#delay' do
+ describe "#delay" do
subject { stage.delay }
let(:stage) { create(:ci_stage_entity, status: :created) }
- it 'updates stage status' do
+ it "updates stage status" do
subject
expect(stage).to be_scheduled
end
end
- describe '#position' do
- context 'when stage has been imported and does not have position index set' do
+ describe "#position" do
+ context "when stage has been imported and does not have position index set" do
before do
stage.update_column(:position, nil)
end
- context 'when stage has statuses' do
+ context "when stage has statuses" do
before do
create(:ci_build, :running, stage_id: stage.id, stage_idx: 10)
end
- it 'recalculates index before updating status' do
+ it "recalculates index before updating status" do
expect(stage.reload.position).to be_nil
stage.update_status
@@ -234,8 +234,8 @@ describe Ci::Stage, :models do
end
end
- context 'when stage does not have statuses' do
- it 'fallbacks to zero' do
+ context "when stage does not have statuses" do
+ it "fallbacks to zero" do
expect(stage.reload.position).to be_nil
stage.update_status
@@ -246,39 +246,39 @@ describe Ci::Stage, :models do
end
end
- context 'when stage has warnings' do
+ context "when stage has warnings" do
before do
create(:ci_build, :failed, :allowed_to_fail, stage_id: stage.id)
end
- describe '#has_warnings?' do
- it 'returns true' do
+ describe "#has_warnings?" do
+ it "returns true" do
expect(stage).to have_warnings
end
end
- describe '#number_of_warnings' do
- it 'returns a lazy stage warnings counter' do
- lazy_queries = ActiveRecord::QueryRecorder.new do
+ describe "#number_of_warnings" do
+ it "returns a lazy stage warnings counter" do
+ lazy_queries = ActiveRecord::QueryRecorder.new {
stage.number_of_warnings
- end
+ }
- synced_queries = ActiveRecord::QueryRecorder.new do
+ synced_queries = ActiveRecord::QueryRecorder.new {
stage.number_of_warnings.to_i
- end
+ }
expect(lazy_queries.count).to eq 0
expect(synced_queries.count).to eq 1
- expect(stage.number_of_warnings.inspect).to include 'BatchLoader'
+ expect(stage.number_of_warnings.inspect).to include "BatchLoader"
expect(stage.number_of_warnings).to eq 1
end
end
end
- context 'when stage does not have warnings' do
- describe '#has_warnings?' do
- it 'returns false' do
+ context "when stage does not have warnings" do
+ describe "#has_warnings?" do
+ it "returns false" do
expect(stage).not_to have_warnings
end
end
diff --git a/spec/models/ci/trigger_request_spec.rb b/spec/models/ci/trigger_request_spec.rb
index 7dcf3528f73..683d3f12d85 100644
--- a/spec/models/ci/trigger_request_spec.rb
+++ b/spec/models/ci/trigger_request_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::TriggerRequest do
- describe 'validation' do
- it 'be invalid if saving a variable' do
- trigger = build(:ci_trigger_request, variables: { TRIGGER_KEY_1: 'TRIGGER_VALUE_1' } )
+ describe "validation" do
+ it "be invalid if saving a variable" do
+ trigger = build(:ci_trigger_request, variables: {TRIGGER_KEY_1: "TRIGGER_VALUE_1"})
expect(trigger).not_to be_valid
end
- it 'be valid if not saving a variable' do
+ it "be valid if not saving a variable" do
trigger = build(:ci_trigger_request)
expect(trigger).to be_valid
diff --git a/spec/models/ci/trigger_spec.rb b/spec/models/ci/trigger_spec.rb
index d4b72205203..672a1bbbba6 100644
--- a/spec/models/ci/trigger_spec.rb
+++ b/spec/models/ci/trigger_spec.rb
@@ -1,60 +1,60 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Trigger do
let(:project) { create :project }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:owner) }
it { is_expected.to have_many(:trigger_requests) }
end
- describe 'before_validation' do
- it 'sets an random token if none provided' do
+ describe "before_validation" do
+ it "sets an random token if none provided" do
trigger = create(:ci_trigger_without_token, project: project)
expect(trigger.token).not_to be_nil
end
- it 'does not set a random token if one provided' do
- trigger = create(:ci_trigger, project: project, token: 'token')
+ it "does not set a random token if one provided" do
+ trigger = create(:ci_trigger, project: project, token: "token")
- expect(trigger.token).to eq('token')
+ expect(trigger.token).to eq("token")
end
end
- describe '#short_token' do
- let(:trigger) { create(:ci_trigger, token: '12345678') }
+ describe "#short_token" do
+ let(:trigger) { create(:ci_trigger, token: "12345678") }
subject { trigger.short_token }
- it 'returns shortened token' do
- is_expected.to eq('1234')
+ it "returns shortened token" do
+ is_expected.to eq("1234")
end
end
- describe '#legacy?' do
+ describe "#legacy?" do
let(:trigger) { create(:ci_trigger, owner: owner, project: project) }
subject { trigger }
- context 'when owner is blank' do
+ context "when owner is blank" do
let(:owner) { nil }
it { is_expected.to be_legacy }
end
- context 'when owner is set' do
+ context "when owner is set" do
let(:owner) { create(:user) }
it { is_expected.not_to be_legacy }
end
end
- describe '#can_access_project?' do
+ describe "#can_access_project?" do
let(:trigger) { create(:ci_trigger, owner: owner, project: project) }
- context 'when owner is blank' do
+ context "when owner is blank" do
let(:owner) { nil }
subject { trigger.can_access_project? }
@@ -62,12 +62,12 @@ describe Ci::Trigger do
it { is_expected.to eq(true) }
end
- context 'when owner is set' do
+ context "when owner is set" do
let(:owner) { create(:user) }
subject { trigger.can_access_project? }
- context 'and is member of the project' do
+ context "and is member of the project" do
before do
project.add_developer(owner)
end
@@ -75,7 +75,7 @@ describe Ci::Trigger do
it { is_expected.to eq(true) }
end
- context 'and is not member of the project' do
+ context "and is not member of the project" do
it { is_expected.to eq(false) }
end
end
diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb
index 02c07a2bd83..05d4d9a9ecd 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/spec/models/ci/variable_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::Variable do
subject { build(:ci_variable) }
- describe 'validations' do
+ describe "validations" do
it { is_expected.to include_module(HasVariable) }
it { is_expected.to include_module(Presentable) }
it { is_expected.to include_module(Maskable) }
it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope).with_message(/\(\w+\) has already been taken/) }
end
- describe '.unprotected' do
+ describe ".unprotected" do
subject { described_class.unprotected }
- context 'when variable is protected' do
+ context "when variable is protected" do
before do
create(:ci_variable, :protected)
end
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
- context 'when variable is not protected' do
+ context "when variable is not protected" do
let(:variable) { create(:ci_variable, protected: false) }
- it 'returns the variable' do
+ it "returns the variable" do
is_expected.to contain_exactly(variable)
end
end
diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb
index cf5cbf8ec5c..8cc0a6b2dc9 100644
--- a/spec/models/clusters/applications/cert_manager_spec.rb
+++ b/spec/models/clusters/applications/cert_manager_spec.rb
@@ -1,40 +1,40 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::CertManager do
let(:cert_manager) { create(:clusters_applications_cert_managers) }
- include_examples 'cluster application core specs', :clusters_applications_cert_managers
- include_examples 'cluster application status specs', :clusters_applications_cert_managers
- include_examples 'cluster application version specs', :clusters_applications_cert_managers
- include_examples 'cluster application initial status specs'
+ include_examples "cluster application core specs", :clusters_applications_cert_managers
+ include_examples "cluster application status specs", :clusters_applications_cert_managers
+ include_examples "cluster application version specs", :clusters_applications_cert_managers
+ include_examples "cluster application initial status specs"
- describe '#install_command' do
- let(:cluster_issuer_file) { { "cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n" } }
+ describe "#install_command" do
+ let(:cluster_issuer_file) { {"cluster_issuer.yaml": "---\napiVersion: certmanager.k8s.io/v1alpha1\nkind: ClusterIssuer\nmetadata:\n name: letsencrypt-prod\nspec:\n acme:\n server: https://acme-v02.api.letsencrypt.org/directory\n email: admin@example.com\n privateKeySecretRef:\n name: letsencrypt-prod\n http01: {}\n"} }
subject { cert_manager.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
- it 'should be initialized with cert_manager arguments' do
- expect(subject.name).to eq('certmanager')
- expect(subject.chart).to eq('stable/cert-manager')
- expect(subject.version).to eq('v0.5.2')
+ it "should be initialized with cert_manager arguments" do
+ expect(subject.name).to eq("certmanager")
+ expect(subject.chart).to eq("stable/cert-manager")
+ expect(subject.version).to eq("v0.5.2")
expect(subject).to be_rbac
expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file))
- expect(subject.postinstall).to eq(['/usr/bin/kubectl create -f /data/helm/certmanager/config/cluster_issuer.yaml'])
+ expect(subject.postinstall).to eq(["/usr/bin/kubectl create -f /data/helm/certmanager/config/cluster_issuer.yaml"])
end
- context 'for a specific user' do
+ context "for a specific user" do
before do
- cert_manager.email = 'abc@xyz.com'
- cluster_issuer_file[:'cluster_issuer.yaml'].gsub! 'admin@example.com', 'abc@xyz.com'
+ cert_manager.email = "abc@xyz.com"
+ cluster_issuer_file[:'cluster_issuer.yaml'].gsub! "admin@example.com", "abc@xyz.com"
end
- it 'should use his/her email to register issuer with certificate provider' do
+ it "should use his/her email to register issuer with certificate provider" do
expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file))
end
end
- context 'on a non rbac enabled cluster' do
+ context "on a non rbac enabled cluster" do
before do
cert_manager.cluster.platform_kubernetes.abac!
end
@@ -42,27 +42,27 @@ describe Clusters::Applications::CertManager do
it { is_expected.not_to be_rbac }
end
- context 'application failed to install previously' do
- let(:cert_manager) { create(:clusters_applications_cert_managers, :errored, version: '0.0.1') }
+ context "application failed to install previously" do
+ let(:cert_manager) { create(:clusters_applications_cert_managers, :errored, version: "0.0.1") }
- it 'should be initialized with the locked version' do
- expect(subject.version).to eq('v0.5.2')
+ it "should be initialized with the locked version" do
+ expect(subject.version).to eq("v0.5.2")
end
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { cert_manager }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include cert_manager specific keys in the values.yaml file' do
- expect(values).to include('ingressShim')
+ it "should include cert_manager specific keys in the values.yaml file" do
+ expect(values).to include("ingressShim")
end
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:email) }
end
end
diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb
index f16eff92167..8edd8f199d6 100644
--- a/spec/models/clusters/applications/helm_spec.rb
+++ b/spec/models/clusters/applications/helm_spec.rb
@@ -1,9 +1,9 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Helm do
- include_examples 'cluster application core specs', :clusters_applications_helm
+ include_examples "cluster application core specs", :clusters_applications_helm
- describe '.available' do
+ describe ".available" do
subject { described_class.available }
let!(:installed_cluster) { create(:clusters_applications_helm, :installed) }
@@ -16,29 +16,29 @@ describe Clusters::Applications::Helm do
it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
end
- describe '#issue_client_cert' do
+ describe "#issue_client_cert" do
let(:application) { create(:clusters_applications_helm) }
subject { application.issue_client_cert }
- it 'returns a new cert' do
+ it "returns a new cert" do
is_expected.to be_kind_of(Gitlab::Kubernetes::Helm::Certificate)
expect(subject.cert_string).not_to eq(application.ca_cert)
expect(subject.key_string).not_to eq(application.ca_key)
end
end
- describe '#install_command' do
+ describe "#install_command" do
let(:helm) { create(:clusters_applications_helm) }
subject { helm.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InitCommand) }
- it 'should be initialized with 1 arguments' do
- expect(subject.name).to eq('helm')
+ it "should be initialized with 1 arguments" do
+ expect(subject.name).to eq("helm")
end
- it 'should have cert files' do
+ it "should have cert files" do
expect(subject.files[:'ca.pem']).to be_present
expect(subject.files[:'ca.pem']).to eq(helm.ca_cert)
@@ -49,12 +49,12 @@ describe Clusters::Applications::Helm do
expect(cert.not_after).to be > 999.years.from_now
end
- describe 'rbac' do
- context 'rbac cluster' do
+ describe "rbac" do
+ context "rbac cluster" do
it { expect(subject).to be_rbac }
end
- context 'non rbac cluster' do
+ context "non rbac cluster" do
before do
helm.cluster.platform_kubernetes.abac!
end
diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb
index d5fd42509a3..64f8e0b628b 100644
--- a/spec/models/clusters/applications/ingress_spec.rb
+++ b/spec/models/clusters/applications/ingress_spec.rb
@@ -1,77 +1,77 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Ingress do
let(:ingress) { create(:clusters_applications_ingress) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- include_examples 'cluster application core specs', :clusters_applications_ingress
- include_examples 'cluster application status specs', :clusters_applications_ingress
- include_examples 'cluster application version specs', :clusters_applications_ingress
- include_examples 'cluster application helm specs', :clusters_applications_ingress
- include_examples 'cluster application initial status specs'
+ include_examples "cluster application core specs", :clusters_applications_ingress
+ include_examples "cluster application status specs", :clusters_applications_ingress
+ include_examples "cluster application version specs", :clusters_applications_ingress
+ include_examples "cluster application helm specs", :clusters_applications_ingress
+ include_examples "cluster application initial status specs"
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
end
- describe '#make_installed!' do
+ describe "#make_installed!" do
before do
application.make_installed!
end
let(:application) { create(:clusters_applications_ingress, :installing) }
- it 'schedules a ClusterWaitForIngressIpAddressWorker' do
+ it "schedules a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).to have_received(:perform_in)
- .with(Clusters::Applications::Ingress::FETCH_IP_ADDRESS_DELAY, 'ingress', application.id)
+ .with(Clusters::Applications::Ingress::FETCH_IP_ADDRESS_DELAY, "ingress", application.id)
end
end
- describe '#schedule_status_update' do
+ describe "#schedule_status_update" do
let(:application) { create(:clusters_applications_ingress, :installed) }
before do
application.schedule_status_update
end
- it 'schedules a ClusterWaitForIngressIpAddressWorker' do
+ it "schedules a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).to have_received(:perform_async)
- .with('ingress', application.id)
+ .with("ingress", application.id)
end
- context 'when the application is not installed' do
+ context "when the application is not installed" do
let(:application) { create(:clusters_applications_ingress, :installing) }
- it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ it "does not schedule a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_async)
end
end
- context 'when there is already an external_ip' do
- let(:application) { create(:clusters_applications_ingress, :installed, external_ip: '111.222.222.111') }
+ context "when there is already an external_ip" do
+ let(:application) { create(:clusters_applications_ingress, :installed, external_ip: "111.222.222.111") }
- it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ it "does not schedule a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
end
end
end
- describe '#install_command' do
+ describe "#install_command" do
subject { ingress.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
- it 'should be initialized with ingress arguments' do
- expect(subject.name).to eq('ingress')
- expect(subject.chart).to eq('stable/nginx-ingress')
- expect(subject.version).to eq('1.1.2')
+ it "should be initialized with ingress arguments" do
+ expect(subject.name).to eq("ingress")
+ expect(subject.chart).to eq("stable/nginx-ingress")
+ expect(subject.version).to eq("1.1.2")
expect(subject).to be_rbac
expect(subject.files).to eq(ingress.files)
end
- context 'on a non rbac enabled cluster' do
+ context "on a non rbac enabled cluster" do
before do
ingress.cluster.platform_kubernetes.abac!
end
@@ -79,26 +79,26 @@ describe Clusters::Applications::Ingress do
it { is_expected.not_to be_rbac }
end
- context 'application failed to install previously' do
- let(:ingress) { create(:clusters_applications_ingress, :errored, version: 'nginx') }
+ context "application failed to install previously" do
+ let(:ingress) { create(:clusters_applications_ingress, :errored, version: "nginx") }
- it 'should be initialized with the locked version' do
- expect(subject.version).to eq('1.1.2')
+ it "should be initialized with the locked version" do
+ expect(subject.version).to eq("1.1.2")
end
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { ingress }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include ingress valid keys in values' do
- expect(values).to include('image')
- expect(values).to include('repository')
- expect(values).to include('stats')
- expect(values).to include('podAnnotations')
+ it "should include ingress valid keys in values" do
+ expect(values).to include("image")
+ expect(values).to include("repository")
+ expect(values).to include("stats")
+ expect(values).to include("podAnnotations")
end
end
end
diff --git a/spec/models/clusters/applications/jupyter_spec.rb b/spec/models/clusters/applications/jupyter_spec.rb
index 2c22c24c498..d7e8bc294f8 100644
--- a/spec/models/clusters/applications/jupyter_spec.rb
+++ b/spec/models/clusters/applications/jupyter_spec.rb
@@ -1,51 +1,51 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Jupyter do
- include_examples 'cluster application core specs', :clusters_applications_jupyter
- include_examples 'cluster application status specs', :clusters_applications_jupyter
- include_examples 'cluster application version specs', :clusters_applications_jupyter
- include_examples 'cluster application helm specs', :clusters_applications_jupyter
+ include_examples "cluster application core specs", :clusters_applications_jupyter
+ include_examples "cluster application status specs", :clusters_applications_jupyter
+ include_examples "cluster application version specs", :clusters_applications_jupyter
+ include_examples "cluster application helm specs", :clusters_applications_jupyter
it { is_expected.to belong_to(:oauth_application) }
- describe '#set_initial_status' do
+ describe "#set_initial_status" do
before do
jupyter.set_initial_status
end
- context 'when ingress is not installed' do
+ context "when ingress is not installed" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
let(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) }
it { expect(jupyter).to be_not_installable }
end
- context 'when ingress is installed and external_ip is assigned' do
- let(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
+ context "when ingress is installed and external_ip is assigned" do
+ let(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: "127.0.0.1") }
let(:jupyter) { create(:clusters_applications_jupyter, cluster: ingress.cluster) }
it { expect(jupyter).to be_installable }
end
end
- describe '#install_command' do
- let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: '127.0.0.1') }
+ describe "#install_command" do
+ let!(:ingress) { create(:clusters_applications_ingress, :installed, external_ip: "127.0.0.1") }
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: ingress.cluster) }
subject { jupyter.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
- it 'should be initialized with 4 arguments' do
- expect(subject.name).to eq('jupyter')
- expect(subject.chart).to eq('jupyter/jupyterhub')
- expect(subject.version).to eq('v0.6')
+ it "should be initialized with 4 arguments" do
+ expect(subject.name).to eq("jupyter")
+ expect(subject.chart).to eq("jupyter/jupyterhub")
+ expect(subject.version).to eq("v0.6")
expect(subject).to be_rbac
- expect(subject.repository).to eq('https://jupyterhub.github.io/helm-chart/')
+ expect(subject.repository).to eq("https://jupyterhub.github.io/helm-chart/")
expect(subject.files).to eq(jupyter.files)
end
- context 'on a non rbac enabled cluster' do
+ context "on a non rbac enabled cluster" do
before do
jupyter.cluster.platform_kubernetes.abac!
end
@@ -53,34 +53,34 @@ describe Clusters::Applications::Jupyter do
it { is_expected.not_to be_rbac }
end
- context 'application failed to install previously' do
- let(:jupyter) { create(:clusters_applications_jupyter, :errored, version: '0.0.1') }
+ context "application failed to install previously" do
+ let(:jupyter) { create(:clusters_applications_jupyter, :errored, version: "0.0.1") }
- it 'should be initialized with the locked version' do
- expect(subject.version).to eq('v0.6')
+ it "should be initialized with the locked version" do
+ expect(subject.version).to eq("v0.6")
end
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { create(:clusters_applications_jupyter) }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include valid values' do
- expect(values).to include('ingress')
- expect(values).to include('hub')
- expect(values).to include('rbac')
- expect(values).to include('proxy')
- expect(values).to include('auth')
- expect(values).to include('singleuser')
+ it "should include valid values" do
+ expect(values).to include("ingress")
+ expect(values).to include("hub")
+ expect(values).to include("rbac")
+ expect(values).to include("proxy")
+ expect(values).to include("auth")
+ expect(values).to include("singleuser")
expect(values).to match(/clientId: '?#{application.oauth_application.uid}/)
expect(values).to match(/callbackUrl: '?#{application.callback_url}/)
end
- context 'when cluster belongs to a project' do
- it 'sets GitLab project id' do
+ context "when cluster belongs to a project" do
+ it "sets GitLab project id" do
expect(values).to match(/GITLAB_CLUSTER_ID: '?#{application.cluster.id}/)
end
end
diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb
index 006b922ab27..fa051dfc61e 100644
--- a/spec/models/clusters/applications/knative_spec.rb
+++ b/spec/models/clusters/applications/knative_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Knative do
include KubernetesHelpers
@@ -6,91 +6,91 @@ describe Clusters::Applications::Knative do
let(:knative) { create(:clusters_applications_knative) }
- include_examples 'cluster application core specs', :clusters_applications_knative
- include_examples 'cluster application status specs', :clusters_applications_knative
- include_examples 'cluster application helm specs', :clusters_applications_knative
- include_examples 'cluster application version specs', :clusters_applications_knative
- include_examples 'cluster application initial status specs'
+ include_examples "cluster application core specs", :clusters_applications_knative
+ include_examples "cluster application status specs", :clusters_applications_knative
+ include_examples "cluster application helm specs", :clusters_applications_knative
+ include_examples "cluster application version specs", :clusters_applications_knative
+ include_examples "cluster application initial status specs"
before do
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_in)
allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async)
end
- describe 'when rbac is not enabled' do
+ describe "when rbac is not enabled" do
let(:cluster) { create(:cluster, :provided_by_gcp, :rbac_disabled) }
let(:knative_no_rbac) { create(:clusters_applications_knative, cluster: cluster) }
it { expect(knative_no_rbac).to be_not_installable }
end
- describe 'make_installed with external_ip' do
+ describe "make_installed with external_ip" do
before do
application.make_installed!
end
let(:application) { create(:clusters_applications_knative, :installing) }
- it 'schedules a ClusterWaitForIngressIpAddressWorker' do
+ it "schedules a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).to have_received(:perform_in)
- .with(Clusters::Applications::Knative::FETCH_IP_ADDRESS_DELAY, 'knative', application.id)
+ .with(Clusters::Applications::Knative::FETCH_IP_ADDRESS_DELAY, "knative", application.id)
end
end
- describe '#schedule_status_update with external_ip' do
+ describe "#schedule_status_update with external_ip" do
let(:application) { create(:clusters_applications_knative, :installed) }
before do
application.schedule_status_update
end
- it 'schedules a ClusterWaitForIngressIpAddressWorker' do
+ it "schedules a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).to have_received(:perform_async)
- .with('knative', application.id)
+ .with("knative", application.id)
end
- context 'when the application is not installed' do
+ context "when the application is not installed" do
let(:application) { create(:clusters_applications_knative, :installing) }
- it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ it "does not schedule a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_async)
end
end
- context 'when there is already an external_ip' do
- let(:application) { create(:clusters_applications_knative, :installed, external_ip: '111.222.222.111') }
+ context "when there is already an external_ip" do
+ let(:application) { create(:clusters_applications_knative, :installed, external_ip: "111.222.222.111") }
- it 'does not schedule a ClusterWaitForIngressIpAddressWorker' do
+ it "does not schedule a ClusterWaitForIngressIpAddressWorker" do
expect(ClusterWaitForIngressIpAddressWorker).not_to have_received(:perform_in)
end
end
end
- describe '#install_command' do
+ describe "#install_command" do
subject { knative.install_command }
- it 'should be an instance of Helm::InstallCommand' do
+ it "should be an instance of Helm::InstallCommand" do
expect(subject).to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand)
end
- it 'should be initialized with knative arguments' do
- expect(subject.name).to eq('knative')
- expect(subject.chart).to eq('knative/knative')
- expect(subject.version).to eq('0.2.2')
+ it "should be initialized with knative arguments" do
+ expect(subject.name).to eq("knative")
+ expect(subject.chart).to eq("knative/knative")
+ expect(subject.version).to eq("0.2.2")
expect(subject.files).to eq(knative.files)
end
- it 'should not install metrics for prometheus' do
+ it "should not install metrics for prometheus" do
expect(subject.postinstall).to be_nil
end
- context 'with prometheus installed' do
+ context "with prometheus installed" do
let(:prometheus) { create(:clusters_applications_prometheus, :installed) }
let(:knative) { create(:clusters_applications_knative, cluster: prometheus.cluster) }
subject { knative.install_command }
- it 'should install metrics' do
+ it "should install metrics" do
expect(subject.postinstall).not_to be_nil
expect(subject.postinstall.length).to be(1)
expect(subject.postinstall[0]).to eql("kubectl apply -f #{Clusters::Applications::Knative::METRICS_CONFIG}")
@@ -98,22 +98,22 @@ describe Clusters::Applications::Knative do
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { knative }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include knative specific keys in the values.yaml file' do
- expect(values).to include('domain')
+ it "should include knative specific keys in the values.yaml file" do
+ expect(values).to include("domain")
end
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:hostname) }
end
- describe '#service_pod_details' do
+ describe "#service_pod_details" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:service) { cluster.platform_kubernetes }
let(:knative) { create(:clusters_applications_knative, cluster: cluster) }
@@ -132,17 +132,17 @@ describe Clusters::Applications::Knative do
stub_reactive_cache(knative,
{
services: kube_response(kube_knative_services_body),
- pods: kube_response(kube_knative_pods_body(cluster.cluster_project.project.name, namespace.namespace))
+ pods: kube_response(kube_knative_pods_body(cluster.cluster_project.project.name, namespace.namespace)),
})
synchronous_reactive_cache(knative)
end
- it 'should be able k8s core for pod details' do
+ it "should be able k8s core for pod details" do
expect(knative.service_pod_details(namespace.namespace, cluster.cluster_project.project.name)).not_to be_nil
end
end
- describe '#services' do
+ describe "#services" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:service) { cluster.platform_kubernetes }
let(:knative) { create(:clusters_applications_knative, cluster: cluster) }
@@ -162,25 +162,25 @@ describe Clusters::Applications::Knative do
stub_kubeclient_service_pods
end
- it 'should have an unintialized cache' do
+ it "should have an unintialized cache" do
is_expected.to be_nil
end
- context 'when using synchronous reactive cache' do
+ context "when using synchronous reactive cache" do
before do
stub_reactive_cache(knative,
{
services: kube_response(kube_knative_services_body),
- pods: kube_response(kube_knative_pods_body(cluster.cluster_project.project.name, namespace.namespace))
+ pods: kube_response(kube_knative_pods_body(cluster.cluster_project.project.name, namespace.namespace)),
})
synchronous_reactive_cache(knative)
end
- it 'should have cached services' do
+ it "should have cached services" do
is_expected.not_to be_nil
end
- it 'should match our namespace' do
+ it "should match our namespace" do
expect(knative.services_for(ns: namespace)).not_to be_nil
end
end
diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb
index 81708b0c2ed..f242522f20a 100644
--- a/spec/models/clusters/applications/prometheus_spec.rb
+++ b/spec/models/clusters/applications/prometheus_spec.rb
@@ -1,35 +1,35 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Prometheus do
include KubernetesHelpers
- include_examples 'cluster application core specs', :clusters_applications_prometheus
- include_examples 'cluster application status specs', :clusters_applications_prometheus
- include_examples 'cluster application version specs', :clusters_applications_prometheus
- include_examples 'cluster application helm specs', :clusters_applications_prometheus
- include_examples 'cluster application initial status specs'
+ include_examples "cluster application core specs", :clusters_applications_prometheus
+ include_examples "cluster application status specs", :clusters_applications_prometheus
+ include_examples "cluster application version specs", :clusters_applications_prometheus
+ include_examples "cluster application helm specs", :clusters_applications_prometheus
+ include_examples "cluster application initial status specs"
- describe 'transition to installed' do
+ describe "transition to installed" do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
- let(:prometheus_service) { double('prometheus_service') }
+ let(:prometheus_service) { double("prometheus_service") }
subject { create(:clusters_applications_prometheus, :installing, cluster: cluster) }
before do
- allow(project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service
+ allow(project).to receive(:find_or_initialize_service).with("prometheus").and_return prometheus_service
end
- it 'ensures Prometheus service is activated' do
+ it "ensures Prometheus service is activated" do
expect(prometheus_service).to receive(:update).with(active: true)
subject.make_installed
end
end
- describe '#prometheus_client' do
- context 'cluster is nil' do
- it 'returns nil' do
+ describe "#prometheus_client" do
+ context "cluster is nil" do
+ it "returns nil" do
expect(subject.cluster).to be_nil
expect(subject.prometheus_client).to be_nil
end
@@ -39,12 +39,12 @@ describe Clusters::Applications::Prometheus do
let(:cluster) { create(:cluster) }
subject { create(:clusters_applications_prometheus, cluster: cluster) }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.prometheus_client).to be_nil
end
end
- context 'cluster has kubeclient' do
+ context "cluster has kubeclient" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:kubernetes_url) { subject.cluster.platform_kubernetes.api_url }
let(:kube_client) { subject.cluster.kubeclient.core_client }
@@ -52,55 +52,55 @@ describe Clusters::Applications::Prometheus do
subject { create(:clusters_applications_prometheus, cluster: cluster) }
before do
- subject.cluster.platform_kubernetes.namespace = 'a-namespace'
+ subject.cluster.platform_kubernetes.namespace = "a-namespace"
stub_kubeclient_discover(cluster.platform_kubernetes.api_url)
create(:cluster_kubernetes_namespace,
- cluster: cluster,
- cluster_project: cluster.cluster_project,
- project: cluster.cluster_project.project)
+ cluster: cluster,
+ cluster_project: cluster.cluster_project,
+ project: cluster.cluster_project.project)
end
- it 'creates proxy prometheus rest client' do
+ it "creates proxy prometheus rest client" do
expect(subject.prometheus_client).to be_instance_of(RestClient::Resource)
end
- it 'creates proper url' do
+ it "creates proper url" do
expect(subject.prometheus_client.url).to eq("#{kubernetes_url}/api/v1/namespaces/gitlab-managed-apps/services/prometheus-prometheus-server:80/proxy")
end
- it 'copies options and headers from kube client to proxy client' do
+ it "copies options and headers from kube client to proxy client" do
expect(subject.prometheus_client.options).to eq(kube_client.rest_client.options.merge(headers: kube_client.headers))
end
- context 'when cluster is not reachable' do
+ context "when cluster is not reachable" do
before do
- allow(kube_client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
+ allow(kube_client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, "Unauthorized", nil))
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.prometheus_client).to be_nil
end
end
end
end
- describe '#install_command' do
+ describe "#install_command" do
let(:prometheus) { create(:clusters_applications_prometheus) }
subject { prometheus.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
- it 'should be initialized with 3 arguments' do
- expect(subject.name).to eq('prometheus')
- expect(subject.chart).to eq('stable/prometheus')
- expect(subject.version).to eq('6.7.3')
+ it "should be initialized with 3 arguments" do
+ expect(subject.name).to eq("prometheus")
+ expect(subject.chart).to eq("stable/prometheus")
+ expect(subject.version).to eq("6.7.3")
expect(subject).to be_rbac
expect(subject.files).to eq(prometheus.files)
end
- context 'on a non rbac enabled cluster' do
+ context "on a non rbac enabled cluster" do
before do
prometheus.cluster.platform_kubernetes.abac!
end
@@ -108,51 +108,51 @@ describe Clusters::Applications::Prometheus do
it { is_expected.not_to be_rbac }
end
- context 'application failed to install previously' do
- let(:prometheus) { create(:clusters_applications_prometheus, :errored, version: '2.0.0') }
+ context "application failed to install previously" do
+ let(:prometheus) { create(:clusters_applications_prometheus, :errored, version: "2.0.0") }
- it 'should be initialized with the locked version' do
- expect(subject.version).to eq('6.7.3')
+ it "should be initialized with the locked version" do
+ expect(subject.version).to eq("6.7.3")
end
end
- it 'should not install knative metrics' do
+ it "should not install knative metrics" do
expect(subject.postinstall).to be_nil
end
- context 'with knative installed' do
- let(:knative) { create(:clusters_applications_knative, :updated ) }
+ context "with knative installed" do
+ let(:knative) { create(:clusters_applications_knative, :updated) }
let(:prometheus) { create(:clusters_applications_prometheus, cluster: knative.cluster) }
subject { prometheus.install_command }
- it 'should install knative metrics' do
+ it "should install knative metrics" do
expect(subject.postinstall).to include("kubectl apply -f #{Clusters::Applications::Knative::METRICS_CONFIG}")
end
end
end
- describe '#upgrade_command' do
+ describe "#upgrade_command" do
let(:prometheus) { build(:clusters_applications_prometheus) }
let(:values) { prometheus.values }
- it 'returns an instance of Gitlab::Kubernetes::Helm::InstallCommand' do
+ it "returns an instance of Gitlab::Kubernetes::Helm::InstallCommand" do
expect(prometheus.upgrade_command(values)).to be_an_instance_of(::Gitlab::Kubernetes::Helm::InstallCommand)
end
- it 'should be initialized with 3 arguments' do
+ it "should be initialized with 3 arguments" do
command = prometheus.upgrade_command(values)
- expect(command.name).to eq('prometheus')
- expect(command.chart).to eq('stable/prometheus')
- expect(command.version).to eq('6.7.3')
+ expect(command.name).to eq("prometheus")
+ expect(command.chart).to eq("stable/prometheus")
+ expect(command.version).to eq("6.7.3")
expect(command.files).to eq(prometheus.files)
end
end
- describe '#update_in_progress?' do
- context 'when app is updating' do
- it 'returns true' do
+ describe "#update_in_progress?" do
+ context "when app is updating" do
+ it "returns true" do
cluster = create(:cluster)
prometheus_app = build(:clusters_applications_prometheus, :updating, cluster: cluster)
@@ -161,9 +161,9 @@ describe Clusters::Applications::Prometheus do
end
end
- describe '#update_errored?' do
- context 'when app errored' do
- it 'returns true' do
+ describe "#update_errored?" do
+ context "when app errored" do
+ it "returns true" do
cluster = create(:cluster)
prometheus_app = build(:clusters_applications_prometheus, :update_errored, cluster: cluster)
@@ -172,37 +172,37 @@ describe Clusters::Applications::Prometheus do
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { create(:clusters_applications_prometheus) }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include prometheus valid values' do
- expect(values).to include('alertmanager')
- expect(values).to include('kubeStateMetrics')
- expect(values).to include('nodeExporter')
- expect(values).to include('pushgateway')
- expect(values).to include('serverFiles')
+ it "should include prometheus valid values" do
+ expect(values).to include("alertmanager")
+ expect(values).to include("kubeStateMetrics")
+ expect(values).to include("nodeExporter")
+ expect(values).to include("pushgateway")
+ expect(values).to include("serverFiles")
end
end
- describe '#files_with_replaced_values' do
+ describe "#files_with_replaced_values" do
let(:application) { build(:clusters_applications_prometheus) }
let(:files) { application.files }
- subject { application.files_with_replaced_values({ hello: :world }) }
+ subject { application.files_with_replaced_values({hello: :world}) }
- it 'does not modify #files' do
+ it "does not modify #files" do
expect(subject[:'values.yaml']).not_to eq(files)
expect(files[:'values.yaml']).to eq(application.values)
end
- it 'returns values.yaml with replaced values' do
- expect(subject[:'values.yaml']).to eq({ hello: :world })
+ it "returns values.yaml with replaced values" do
+ expect(subject[:'values.yaml']).to eq({hello: :world})
end
- it 'should include cert files' do
+ it "should include cert files" do
expect(subject[:'ca.pem']).to be_present
expect(subject[:'ca.pem']).to eq(application.cluster.application_helm.ca_cert)
@@ -213,12 +213,12 @@ describe Clusters::Applications::Prometheus do
expect(cert.not_after).to be < 60.minutes.from_now
end
- context 'when the helm application does not have a ca_cert' do
+ context "when the helm application does not have a ca_cert" do
before do
application.cluster.application_helm.ca_cert = nil
end
- it 'should not include cert files' do
+ it "should not include cert files" do
expect(subject[:'ca.pem']).not_to be_present
expect(subject[:'cert.pem']).not_to be_present
expect(subject[:'key.pem']).not_to be_present
diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb
index 6972fc03415..0235e828b29 100644
--- a/spec/models/clusters/applications/runner_spec.rb
+++ b/spec/models/clusters/applications/runner_spec.rb
@@ -1,34 +1,34 @@
-require 'rails_helper'
+require "rails_helper"
describe Clusters::Applications::Runner do
let(:ci_runner) { create(:ci_runner) }
- include_examples 'cluster application core specs', :clusters_applications_runner
- include_examples 'cluster application status specs', :clusters_applications_runner
- include_examples 'cluster application version specs', :clusters_applications_runner
- include_examples 'cluster application helm specs', :clusters_applications_runner
- include_examples 'cluster application initial status specs'
+ include_examples "cluster application core specs", :clusters_applications_runner
+ include_examples "cluster application status specs", :clusters_applications_runner
+ include_examples "cluster application version specs", :clusters_applications_runner
+ include_examples "cluster application helm specs", :clusters_applications_runner
+ include_examples "cluster application initial status specs"
it { is_expected.to belong_to(:runner) }
- describe '#install_command' do
- let(:kubeclient) { double('kubernetes client') }
+ describe "#install_command" do
+ let(:kubeclient) { double("kubernetes client") }
let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) }
subject { gitlab_runner.install_command }
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) }
- it 'should be initialized with 4 arguments' do
- expect(subject.name).to eq('runner')
- expect(subject.chart).to eq('runner/gitlab-runner')
- expect(subject.version).to eq('0.2.0')
+ it "should be initialized with 4 arguments" do
+ expect(subject.name).to eq("runner")
+ expect(subject.chart).to eq("runner/gitlab-runner")
+ expect(subject.version).to eq("0.2.0")
expect(subject).to be_rbac
- expect(subject.repository).to eq('https://charts.gitlab.io')
+ expect(subject.repository).to eq("https://charts.gitlab.io")
expect(subject.files).to eq(gitlab_runner.files)
end
- context 'on a non rbac enabled cluster' do
+ context "on a non rbac enabled cluster" do
before do
gitlab_runner.cluster.platform_kubernetes.abac!
end
@@ -36,62 +36,62 @@ describe Clusters::Applications::Runner do
it { is_expected.not_to be_rbac }
end
- context 'application failed to install previously' do
- let(:gitlab_runner) { create(:clusters_applications_runner, :errored, runner: ci_runner, version: '0.1.13') }
+ context "application failed to install previously" do
+ let(:gitlab_runner) { create(:clusters_applications_runner, :errored, runner: ci_runner, version: "0.1.13") }
- it 'should be initialized with the locked version' do
- expect(subject.version).to eq('0.2.0')
+ it "should be initialized with the locked version" do
+ expect(subject.version).to eq("0.2.0")
end
end
end
- describe '#files' do
+ describe "#files" do
let(:application) { create(:clusters_applications_runner, runner: ci_runner) }
let(:values) { subject[:'values.yaml'] }
subject { application.files }
- it 'should include runner valid values' do
- expect(values).to include('concurrent')
- expect(values).to include('checkInterval')
- expect(values).to include('rbac')
- expect(values).to include('runners')
- expect(values).to include('privileged: true')
- expect(values).to include('image: ubuntu:16.04')
- expect(values).to include('resources')
+ it "should include runner valid values" do
+ expect(values).to include("concurrent")
+ expect(values).to include("checkInterval")
+ expect(values).to include("rbac")
+ expect(values).to include("runners")
+ expect(values).to include("privileged: true")
+ expect(values).to include("image: ubuntu:16.04")
+ expect(values).to include("resources")
expect(values).to match(/runnerToken: '?#{ci_runner.token}/)
expect(values).to match(/gitlabUrl: '?#{Gitlab::Routing.url_helpers.root_url}/)
end
- context 'without a runner' do
+ context "without a runner" do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, :with_installed_helm, projects: [project]) }
let(:application) { create(:clusters_applications_runner, runner: nil, cluster: cluster) }
- it 'creates a runner' do
- expect do
+ it "creates a runner" do
+ expect {
subject
- end.to change { Ci::Runner.count }.by(1)
+ }.to change { Ci::Runner.count }.by(1)
end
- it 'uses the new runner token' do
+ it "uses the new runner token" do
expect(values).to match(/runnerToken: '?#{application.reload.runner.token}/)
end
- it 'assigns the new runner to runner' do
+ it "assigns the new runner to runner" do
subject
expect(application.reload.runner).to be_project_type
end
end
- context 'with duplicated values on vendor/runner/values.yaml' do
+ context "with duplicated values on vendor/runner/values.yaml" do
let(:stub_values) do
{
"concurrent" => 4,
"checkInterval" => 3,
"rbac" => {
- "create" => false
+ "create" => false,
},
"clusterWideAccess" => false,
"runners" => {
@@ -99,8 +99,8 @@ describe Clusters::Applications::Runner do
"image" => "ubuntu:16.04",
"builds" => {},
"services" => {},
- "helpers" => {}
- }
+ "helpers" => {},
+ },
}
end
@@ -108,7 +108,7 @@ describe Clusters::Applications::Runner do
allow(application).to receive(:chart_values).and_return(stub_values)
end
- it 'should overwrite values.yaml' do
+ it "should overwrite values.yaml" do
expect(values).to match(/privileged: '?#{application.privileged}/)
end
end
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb
index 3feed4e9718..fad9ec37873 100644
--- a/spec/models/clusters/cluster_spec.rb
+++ b/spec/models/clusters/cluster_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Cluster do
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:cluster_projects) }
@@ -34,7 +34,7 @@ describe Clusters::Cluster do
it { is_expected.to respond_to :project }
- describe '.enabled' do
+ describe ".enabled" do
subject { described_class.enabled }
let!(:cluster) { create(:cluster, enabled: true) }
@@ -46,7 +46,7 @@ describe Clusters::Cluster do
it { is_expected.to contain_exactly(cluster) }
end
- describe '.disabled' do
+ describe ".disabled" do
subject { described_class.disabled }
let!(:cluster) { create(:cluster, enabled: false) }
@@ -58,7 +58,7 @@ describe Clusters::Cluster do
it { is_expected.to contain_exactly(cluster) }
end
- describe '.user_provided' do
+ describe ".user_provided" do
subject { described_class.user_provided }
let!(:cluster) { create(:cluster, :provided_by_user) }
@@ -70,7 +70,7 @@ describe Clusters::Cluster do
it { is_expected.to contain_exactly(cluster) }
end
- describe '.gcp_provided' do
+ describe ".gcp_provided" do
subject { described_class.gcp_provided }
let!(:cluster) { create(:cluster, :provided_by_gcp) }
@@ -82,7 +82,7 @@ describe Clusters::Cluster do
it { is_expected.to contain_exactly(cluster) }
end
- describe '.gcp_installed' do
+ describe ".gcp_installed" do
subject { described_class.gcp_installed }
let!(:cluster) { create(:cluster, :provided_by_gcp) }
@@ -94,18 +94,18 @@ describe Clusters::Cluster do
it { is_expected.to contain_exactly(cluster) }
end
- describe '.missing_kubernetes_namespace' do
+ describe ".missing_kubernetes_namespace" do
let!(:cluster) { create(:cluster, :provided_by_gcp, :project) }
let(:project) { cluster.project }
let(:kubernetes_namespaces) { project.kubernetes_namespaces }
subject do
- described_class.joins(:projects).where(projects: { id: project.id }).missing_kubernetes_namespace(kubernetes_namespaces)
+ described_class.joins(:projects).where(projects: {id: project.id}).missing_kubernetes_namespace(kubernetes_namespaces)
end
it { is_expected.to contain_exactly(cluster) }
- context 'kubernetes namespace exists' do
+ context "kubernetes namespace exists" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
@@ -114,75 +114,75 @@ describe Clusters::Cluster do
end
end
- describe 'validations' do
+ describe "validations" do
subject { cluster.valid? }
- context 'when validates name' do
- context 'when provided by user' do
+ context "when validates name" do
+ context "when provided by user" do
let!(:cluster) { build(:cluster, :provided_by_user, name: name) }
- context 'when name is empty' do
- let(:name) { '' }
+ context "when name is empty" do
+ let(:name) { "" }
it { is_expected.to be_falsey }
end
- context 'when name is nil' do
+ context "when name is nil" do
let(:name) { nil }
it { is_expected.to be_falsey }
end
- context 'when name is present' do
- let(:name) { 'cluster-name-1' }
+ context "when name is present" do
+ let(:name) { "cluster-name-1" }
it { is_expected.to be_truthy }
end
end
- context 'when provided by gcp' do
+ context "when provided by gcp" do
let!(:cluster) { build(:cluster, :provided_by_gcp, name: name) }
- context 'when name is shorter than 1' do
- let(:name) { '' }
+ context "when name is shorter than 1" do
+ let(:name) { "" }
it { is_expected.to be_falsey }
end
- context 'when name is longer than 63' do
- let(:name) { 'a' * 64 }
+ context "when name is longer than 63" do
+ let(:name) { "a" * 64 }
it { is_expected.to be_falsey }
end
- context 'when name includes invalid character' do
- let(:name) { '!!!!!!' }
+ context "when name includes invalid character" do
+ let(:name) { "!!!!!!" }
it { is_expected.to be_falsey }
end
- context 'when name is present' do
- let(:name) { 'cluster-name-1' }
+ context "when name is present" do
+ let(:name) { "cluster-name-1" }
it { is_expected.to be_truthy }
end
- context 'when record is persisted' do
- let(:name) { 'cluster-name-1' }
+ context "when record is persisted" do
+ let(:name) { "cluster-name-1" }
before do
cluster.save!
end
- context 'when name is changed' do
+ context "when name is changed" do
before do
- cluster.name = 'new-cluster-name'
+ cluster.name = "new-cluster-name"
end
it { is_expected.to be_falsey }
end
- context 'when name is same' do
+ context "when name is same" do
before do
cluster.name = name
end
@@ -193,94 +193,94 @@ describe Clusters::Cluster do
end
end
- context 'when validates restrict_modification' do
- context 'when creation is on going' do
+ context "when validates restrict_modification" do
+ context "when creation is on going" do
let!(:cluster) { create(:cluster, :providing_by_gcp) }
it { expect(cluster.update(enabled: false)).to be_falsey }
end
- context 'when creation is done' do
+ context "when creation is done" do
let!(:cluster) { create(:cluster, :provided_by_gcp) }
it { expect(cluster.update(enabled: false)).to be_truthy }
end
end
- describe 'cluster_type validations' do
+ describe "cluster_type validations" do
let(:instance_cluster) { create(:cluster, :instance) }
let(:group_cluster) { create(:cluster, :group) }
let(:project_cluster) { create(:cluster, :project) }
- it 'validates presence' do
+ it "validates presence" do
cluster = build(:cluster, :project, cluster_type: nil)
expect(cluster).not_to be_valid
expect(cluster.errors.full_messages).to include("Cluster type can't be blank")
end
- context 'project_type cluster' do
- it 'does not allow setting group' do
+ context "project_type cluster" do
+ it "does not allow setting group" do
project_cluster.groups << build(:group)
expect(project_cluster).not_to be_valid
- expect(project_cluster.errors.full_messages).to include('Cluster cannot have groups assigned')
+ expect(project_cluster.errors.full_messages).to include("Cluster cannot have groups assigned")
end
end
- context 'group_type cluster' do
- it 'does not allow setting project' do
+ context "group_type cluster" do
+ it "does not allow setting project" do
group_cluster.projects << build(:project)
expect(group_cluster).not_to be_valid
- expect(group_cluster.errors.full_messages).to include('Cluster cannot have projects assigned')
+ expect(group_cluster.errors.full_messages).to include("Cluster cannot have projects assigned")
end
end
- context 'instance_type cluster' do
- it 'does not allow setting group' do
+ context "instance_type cluster" do
+ it "does not allow setting group" do
instance_cluster.groups << build(:group)
expect(instance_cluster).not_to be_valid
- expect(instance_cluster.errors.full_messages).to include('Cluster cannot have groups assigned')
+ expect(instance_cluster.errors.full_messages).to include("Cluster cannot have groups assigned")
end
- it 'does not allow setting project' do
+ it "does not allow setting project" do
instance_cluster.projects << build(:project)
expect(instance_cluster).not_to be_valid
- expect(instance_cluster.errors.full_messages).to include('Cluster cannot have projects assigned')
+ expect(instance_cluster.errors.full_messages).to include("Cluster cannot have projects assigned")
end
end
end
- describe 'domain validation' do
+ describe "domain validation" do
let(:cluster) { build(:cluster) }
subject { cluster }
- context 'when cluster has domain' do
+ context "when cluster has domain" do
let(:cluster) { build(:cluster, :with_domain) }
it { is_expected.to be_valid }
end
- context 'when cluster is not a valid hostname' do
- let(:cluster) { build(:cluster, domain: 'http://not.a.valid.hostname') }
+ context "when cluster is not a valid hostname" do
+ let(:cluster) { build(:cluster, domain: "http://not.a.valid.hostname") }
- it 'should add an error on domain' do
+ it "should add an error on domain" do
expect(subject).not_to be_valid
expect(subject.errors[:domain].first).to eq('contains invalid characters (valid characters: [a-z0-9\\-])')
end
end
- context 'when cluster does not have a domain' do
+ context "when cluster does not have a domain" do
it { is_expected.to be_valid }
end
end
end
- describe '.ancestor_clusters_for_clusterable' do
+ describe ".ancestor_clusters_for_clusterable" do
let(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { group_cluster.group }
let(:hierarchy_order) { :desc }
@@ -290,23 +290,23 @@ describe Clusters::Cluster do
described_class.ancestor_clusters_for_clusterable(clusterable, hierarchy_order: hierarchy_order)
end
- context 'when project does not belong to this group' do
+ context "when project does not belong to this group" do
let(:project) { create(:project, group: create(:group)) }
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
- context 'when group has a configured kubernetes cluster' do
+ context "when group has a configured kubernetes cluster" do
let(:project) { create(:project, group: group) }
- it 'returns the group cluster' do
+ it "returns the group cluster" do
is_expected.to eq([group_cluster])
end
end
- context 'when sub-group has configured kubernetes cluster', :nested_groups do
+ context "when sub-group has configured kubernetes cluster", :nested_groups do
let(:sub_group_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:sub_group) { sub_group_cluster.group }
let(:project) { create(:project, group: sub_group) }
@@ -315,149 +315,149 @@ describe Clusters::Cluster do
sub_group.update!(parent: group)
end
- it 'returns clusters in order, descending the hierachy' do
+ it "returns clusters in order, descending the hierachy" do
is_expected.to eq([group_cluster, sub_group_cluster])
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
another_project = create(:project)
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
described_class.ancestor_clusters_for_clusterable(another_project, hierarchy_order: hierarchy_order)
- end.count
+ }.count
cluster2 = create(:cluster, :provided_by_gcp, :group)
child2 = cluster2.group
child2.update!(parent: sub_group)
project = create(:project, group: child2)
- expect do
+ expect {
described_class.ancestor_clusters_for_clusterable(project, hierarchy_order: hierarchy_order)
- end.not_to exceed_query_limit(control_count)
+ }.not_to exceed_query_limit(control_count)
end
- context 'for a group' do
+ context "for a group" do
let(:clusterable) { sub_group }
- it 'returns clusters in order for a group' do
+ it "returns clusters in order for a group" do
is_expected.to eq([group_cluster])
end
end
end
- context 'scope chaining' do
+ context "scope chaining" do
let(:project) { create(:project, group: group) }
subject { described_class.none.ancestor_clusters_for_clusterable(project) }
- it 'returns nothing' do
+ it "returns nothing" do
is_expected.to be_empty
end
end
end
- describe '#provider' do
+ describe "#provider" do
subject { cluster.provider }
- context 'when provider is gcp' do
+ context "when provider is gcp" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
- it 'returns a provider' do
+ it "returns a provider" do
is_expected.to eq(cluster.provider_gcp)
expect(subject.class.name.deconstantize).to eq(Clusters::Providers.to_s)
end
end
- context 'when provider is user' do
+ context "when provider is user" do
let(:cluster) { create(:cluster, :provided_by_user) }
it { is_expected.to be_nil }
end
end
- describe '#platform' do
+ describe "#platform" do
subject { cluster.platform }
- context 'when platform is kubernetes' do
+ context "when platform is kubernetes" do
let(:cluster) { create(:cluster, :provided_by_user) }
- it 'returns a platform' do
+ it "returns a platform" do
is_expected.to eq(cluster.platform_kubernetes)
expect(subject.class.name.deconstantize).to eq(Clusters::Platforms.to_s)
end
end
end
- describe '#all_projects' do
+ describe "#all_projects" do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, projects: [project]) }
subject { cluster.all_projects }
- context 'project cluster' do
- it 'returns project' do
+ context "project cluster" do
+ it "returns project" do
is_expected.to eq([project])
end
end
- context 'group cluster' do
+ context "group cluster" do
let(:cluster) { create(:cluster, :group) }
let(:group) { cluster.group }
let(:project) { create(:project, group: group) }
let(:subgroup) { create(:group, parent: group) }
let(:subproject) { create(:project, group: subgroup) }
- it 'returns all projects for group' do
+ it "returns all projects for group" do
is_expected.to contain_exactly(project, subproject)
end
end
end
- describe '#first_project' do
+ describe "#first_project" do
subject { cluster.first_project }
- context 'when cluster belongs to a project' do
+ context "when cluster belongs to a project" do
let(:cluster) { create(:cluster, :project) }
let(:project) { Clusters::Project.find_by_cluster_id(cluster.id).project }
it { is_expected.to eq(project) }
end
- context 'when cluster does not belong to projects' do
+ context "when cluster does not belong to projects" do
let(:cluster) { create(:cluster) }
it { is_expected.to be_nil }
end
end
- describe '#group' do
+ describe "#group" do
subject { cluster.group }
- context 'when cluster belongs to a group' do
+ context "when cluster belongs to a group" do
let(:cluster) { create(:cluster, :group) }
let(:group) { cluster.groups.first }
it { is_expected.to eq(group) }
end
- context 'when cluster does not belong to any group' do
+ context "when cluster does not belong to any group" do
let(:cluster) { create(:cluster) }
it { is_expected.to be_nil }
end
end
- describe '#applications' do
+ describe "#applications" do
set(:cluster) { create(:cluster) }
subject { cluster.applications }
- context 'when none of applications are created' do
- it 'returns a list of a new objects' do
+ context "when none of applications are created" do
+ it "returns a list of a new objects" do
is_expected.not_to be_empty
end
end
- context 'when applications are created' do
+ context "when applications are created" do
let!(:helm) { create(:clusters_applications_helm, cluster: cluster) }
let!(:ingress) { create(:clusters_applications_ingress, cluster: cluster) }
let!(:cert_manager) { create(:clusters_applications_cert_managers, cluster: cluster) }
@@ -466,18 +466,18 @@ describe Clusters::Cluster do
let!(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) }
let!(:knative) { create(:clusters_applications_knative, cluster: cluster) }
- it 'returns a list of created applications' do
+ it "returns a list of created applications" do
is_expected.to contain_exactly(helm, ingress, cert_manager, prometheus, runner, jupyter, knative)
end
end
end
- describe '#created?' do
+ describe "#created?" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { cluster.created? }
- context 'when status_name is :created' do
+ context "when status_name is :created" do
before do
allow(cluster).to receive_message_chain(:provider, :status_name).and_return(:created)
end
@@ -485,7 +485,7 @@ describe Clusters::Cluster do
it { is_expected.to eq(true) }
end
- context 'when status_name is not :created' do
+ context "when status_name is not :created" do
before do
allow(cluster).to receive_message_chain(:provider, :status_name).and_return(:creating)
end
@@ -494,127 +494,127 @@ describe Clusters::Cluster do
end
end
- describe '#allow_user_defined_namespace?' do
+ describe "#allow_user_defined_namespace?" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { cluster.allow_user_defined_namespace? }
- context 'project type cluster' do
+ context "project type cluster" do
it { is_expected.to be_truthy }
end
- context 'group type cluster' do
+ context "group type cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
it { is_expected.to be_falsey }
end
- context 'instance type cluster' do
+ context "instance type cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
it { is_expected.to be_falsey }
end
end
- describe '#kube_ingress_domain' do
+ describe "#kube_ingress_domain" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { cluster.kube_ingress_domain }
- context 'with domain set in cluster' do
+ context "with domain set in cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :with_domain) }
it { is_expected.to eq(cluster.domain) }
end
- context 'with no domain on cluster' do
- context 'with a project cluster' do
+ context "with no domain on cluster" do
+ context "with a project cluster" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- context 'with domain set at instance level' do
+ context "with domain set at instance level" do
before do
- stub_application_setting(auto_devops_domain: 'global_domain.com')
+ stub_application_setting(auto_devops_domain: "global_domain.com")
- it { is_expected.to eq('global_domain.com') }
+ it { is_expected.to eq("global_domain.com") }
end
end
- context 'with domain set on ProjectAutoDevops' do
+ context "with domain set on ProjectAutoDevops" do
before do
- auto_devops = project.build_auto_devops(domain: 'legacy-ado-domain.com')
+ auto_devops = project.build_auto_devops(domain: "legacy-ado-domain.com")
auto_devops.save
end
- it { is_expected.to eq('legacy-ado-domain.com') }
+ it { is_expected.to eq("legacy-ado-domain.com") }
end
- context 'with domain set as environment variable on project' do
+ context "with domain set as environment variable on project" do
before do
- variable = project.variables.build(key: 'AUTO_DEVOPS_DOMAIN', value: 'project-ado-domain.com')
+ variable = project.variables.build(key: "AUTO_DEVOPS_DOMAIN", value: "project-ado-domain.com")
variable.save
end
- it { is_expected.to eq('project-ado-domain.com') }
+ it { is_expected.to eq("project-ado-domain.com") }
end
- context 'with domain set as environment variable on the group project' do
+ context "with domain set as environment variable on the group project" do
let(:group) { create(:group) }
before do
project.update(parent_id: group.id)
- variable = group.variables.build(key: 'AUTO_DEVOPS_DOMAIN', value: 'group-ado-domain.com')
+ variable = group.variables.build(key: "AUTO_DEVOPS_DOMAIN", value: "group-ado-domain.com")
variable.save
end
- it { is_expected.to eq('group-ado-domain.com') }
+ it { is_expected.to eq("group-ado-domain.com") }
end
end
- context 'with a group cluster' do
+ context "with a group cluster" do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
- context 'with domain set as environment variable for the group' do
+ context "with domain set as environment variable for the group" do
let(:group) { cluster.group }
before do
- variable = group.variables.build(key: 'AUTO_DEVOPS_DOMAIN', value: 'group-ado-domain.com')
+ variable = group.variables.build(key: "AUTO_DEVOPS_DOMAIN", value: "group-ado-domain.com")
variable.save
end
- it { is_expected.to eq('group-ado-domain.com') }
+ it { is_expected.to eq("group-ado-domain.com") }
end
end
end
end
- describe '#predefined_variables' do
+ describe "#predefined_variables" do
subject { cluster.predefined_variables }
- context 'with an instance domain' do
+ context "with an instance domain" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
before do
- stub_application_setting(auto_devops_domain: 'global_domain.com')
+ stub_application_setting(auto_devops_domain: "global_domain.com")
end
- it 'should include KUBE_INGRESS_BASE_DOMAIN' do
- expect(subject.to_hash).to include(KUBE_INGRESS_BASE_DOMAIN: 'global_domain.com')
+ it "should include KUBE_INGRESS_BASE_DOMAIN" do
+ expect(subject.to_hash).to include(KUBE_INGRESS_BASE_DOMAIN: "global_domain.com")
end
end
- context 'with a cluster domain' do
- let(:cluster) { create(:cluster, :provided_by_gcp, domain: 'example.com') }
+ context "with a cluster domain" do
+ let(:cluster) { create(:cluster, :provided_by_gcp, domain: "example.com") }
- it 'should include KUBE_INGRESS_BASE_DOMAIN' do
- expect(subject.to_hash).to include(KUBE_INGRESS_BASE_DOMAIN: 'example.com')
+ it "should include KUBE_INGRESS_BASE_DOMAIN" do
+ expect(subject.to_hash).to include(KUBE_INGRESS_BASE_DOMAIN: "example.com")
end
end
- context 'with no domain' do
+ context "with no domain" do
let(:cluster) { create(:cluster, :provided_by_gcp, :project) }
- it 'should return an empty array' do
+ it "should return an empty array" do
expect(subject.to_hash).to be_empty
end
end
diff --git a/spec/models/clusters/group_spec.rb b/spec/models/clusters/group_spec.rb
index ba145342cb8..b507d276a72 100644
--- a/spec/models/clusters/group_spec.rb
+++ b/spec/models/clusters/group_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Group do
it { is_expected.to belong_to(:cluster) }
diff --git a/spec/models/clusters/kubernetes_namespace_spec.rb b/spec/models/clusters/kubernetes_namespace_spec.rb
index b865909c7fd..0cbb6b07e20 100644
--- a/spec/models/clusters/kubernetes_namespace_spec.rb
+++ b/spec/models/clusters/kubernetes_namespace_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
RSpec.describe Clusters::KubernetesNamespace, type: :model do
it { is_expected.to belong_to(:cluster_project) }
@@ -8,71 +8,71 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
it { is_expected.to belong_to(:cluster) }
it { is_expected.to have_one(:platform_kubernetes) }
- describe 'has_service_account_token' do
+ describe "has_service_account_token" do
subject { described_class.has_service_account_token }
- context 'namespace has service_account_token' do
+ context "namespace has service_account_token" do
let!(:namespace) { create(:cluster_kubernetes_namespace, :with_token) }
it { is_expected.to include(namespace) }
end
- context 'namespace has no service_account_token' do
+ context "namespace has no service_account_token" do
let!(:namespace) { create(:cluster_kubernetes_namespace) }
it { is_expected.not_to include(namespace) }
end
end
- describe 'namespace uniqueness validation' do
+ describe "namespace uniqueness validation" do
let(:cluster_project) { create(:cluster_project) }
- let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace, namespace: 'my-namespace') }
+ let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace, namespace: "my-namespace") }
subject { kubernetes_namespace }
- context 'when cluster is using the namespace' do
+ context "when cluster is using the namespace" do
before do
create(:cluster_kubernetes_namespace,
- cluster: kubernetes_namespace.cluster,
- namespace: 'my-namespace')
+ cluster: kubernetes_namespace.cluster,
+ namespace: "my-namespace")
end
it { is_expected.not_to be_valid }
end
- context 'when cluster is not using the namespace' do
+ context "when cluster is not using the namespace" do
it { is_expected.to be_valid }
end
end
- describe '#set_defaults' do
+ describe "#set_defaults" do
let(:kubernetes_namespace) { build(:cluster_kubernetes_namespace) }
let(:cluster) { kubernetes_namespace.cluster }
let(:platform) { kubernetes_namespace.platform_kubernetes }
subject { kubernetes_namespace.set_defaults }
- describe '#namespace' do
+ describe "#namespace" do
before do
platform.update_column(:namespace, namespace)
end
- context 'when platform has a namespace assigned' do
- let(:namespace) { 'platform-namespace' }
+ context "when platform has a namespace assigned" do
+ let(:namespace) { "platform-namespace" }
- it 'should copy the namespace' do
+ it "should copy the namespace" do
subject
- expect(kubernetes_namespace.namespace).to eq('platform-namespace')
+ expect(kubernetes_namespace.namespace).to eq("platform-namespace")
end
end
- context 'when platform does not have namespace assigned' do
+ context "when platform does not have namespace assigned" do
let(:project) { kubernetes_namespace.project }
let(:namespace) { nil }
let(:project_slug) { "#{project.path}-#{project.id}" }
- it 'should fallback to project namespace' do
+ it "should fallback to project namespace" do
subject
expect(kubernetes_namespace.namespace).to eq(project_slug)
@@ -80,10 +80,10 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
end
end
- describe '#service_account_name' do
+ describe "#service_account_name" do
let(:service_account_name) { "#{kubernetes_namespace.namespace}-service-account" }
- it 'should set a service account name based on namespace' do
+ it "should set a service account name based on namespace" do
subject
expect(kubernetes_namespace.service_account_name).to eq(service_account_name)
@@ -91,32 +91,32 @@ RSpec.describe Clusters::KubernetesNamespace, type: :model do
end
end
- describe '#predefined_variables' do
+ describe "#predefined_variables" do
let(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster, service_account_token: token) }
let(:cluster) { create(:cluster, :project, platform_kubernetes: platform) }
let(:platform) { create(:cluster_platform_kubernetes, api_url: api_url, ca_cert: ca_pem, token: token) }
- let(:api_url) { 'https://kube.domain.com' }
- let(:ca_pem) { File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) }
- let(:token) { 'token' }
+ let(:api_url) { "https://kube.domain.com" }
+ let(:ca_pem) { File.read(Rails.root.join("spec/fixtures/clusters/sample_cert.pem")) }
+ let(:token) { "token" }
let(:kubeconfig) do
- config_file = expand_fixture_path('config/kubeconfig.yml')
+ config_file = expand_fixture_path("config/kubeconfig.yml")
config = YAML.safe_load(File.read(config_file))
- config.dig('users', 0, 'user')['token'] = token
- config.dig('contexts', 0, 'context')['namespace'] = kubernetes_namespace.namespace
- config.dig('clusters', 0, 'cluster')['certificate-authority-data'] =
+ config.dig("users", 0, "user")["token"] = token
+ config.dig("contexts", 0, "context")["namespace"] = kubernetes_namespace.namespace
+ config.dig("clusters", 0, "cluster")["certificate-authority-data"] =
Base64.strict_encode64(ca_pem)
YAML.dump(config)
end
- it 'sets the variables' do
+ it "sets the variables" do
expect(kubernetes_namespace.predefined_variables).to include(
- { key: 'KUBE_SERVICE_ACCOUNT', value: kubernetes_namespace.service_account_name, public: true },
- { key: 'KUBE_NAMESPACE', value: kubernetes_namespace.namespace, public: true },
- { key: 'KUBE_TOKEN', value: kubernetes_namespace.service_account_token, public: false },
- { key: 'KUBECONFIG', value: kubeconfig, public: false, file: true }
+ {key: "KUBE_SERVICE_ACCOUNT", value: kubernetes_namespace.service_account_name, public: true},
+ {key: "KUBE_NAMESPACE", value: kubernetes_namespace.namespace, public: true},
+ {key: "KUBE_TOKEN", value: kubernetes_namespace.service_account_token, public: false},
+ {key: "KUBECONFIG", value: kubeconfig, public: false, file: true}
)
end
end
diff --git a/spec/models/clusters/platforms/kubernetes_spec.rb b/spec/models/clusters/platforms/kubernetes_spec.rb
index 4068d98d8f7..483f17628d7 100644
--- a/spec/models/clusters/platforms/kubernetes_spec.rb
+++ b/spec/models/clusters/platforms/kubernetes_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching do
include KubernetesHelpers
@@ -9,7 +9,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to be_kind_of(ReactiveCaching) }
it { is_expected.to respond_to :ca_pem }
- it { is_expected.to validate_exclusion_of(:namespace).in_array(%w(gitlab-managed-apps)) }
+ it { is_expected.to validate_exclusion_of(:namespace).in_array(%w[gitlab-managed-apps]) }
it { is_expected.to validate_presence_of(:api_url) }
it { is_expected.to validate_presence_of(:token) }
@@ -18,51 +18,51 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to delegate_method(:managed?).to(:cluster) }
it { is_expected.to delegate_method(:kubernetes_namespace).to(:cluster) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'before_validation' do
- context 'when namespace includes upper case' do
+ describe "before_validation" do
+ context "when namespace includes upper case" do
let(:kubernetes) { create(:cluster_platform_kubernetes, :configured, namespace: namespace) }
- let(:namespace) { 'ABC' }
+ let(:namespace) { "ABC" }
- it 'converts to lower case' do
- expect(kubernetes.namespace).to eq('abc')
+ it "converts to lower case" do
+ expect(kubernetes.namespace).to eq("abc")
end
end
end
- describe 'validation' do
+ describe "validation" do
subject { kubernetes.valid? }
- context 'when validates namespace' do
+ context "when validates namespace" do
let(:kubernetes) { build(:cluster_platform_kubernetes, :configured, namespace: namespace) }
- context 'when namespace is blank' do
- let(:namespace) { '' }
+ context "when namespace is blank" do
+ let(:namespace) { "" }
it { is_expected.to be_truthy }
end
- context 'when namespace is longer than 63' do
- let(:namespace) { 'a' * 64 }
+ context "when namespace is longer than 63" do
+ let(:namespace) { "a" * 64 }
it { is_expected.to be_falsey }
end
- context 'when namespace includes invalid character' do
- let(:namespace) { '!!!!!!' }
+ context "when namespace includes invalid character" do
+ let(:namespace) { "!!!!!!" }
it { is_expected.to be_falsey }
end
- context 'when namespace is vaild' do
- let(:namespace) { 'namespace-123' }
+ context "when namespace is vaild" do
+ let(:namespace) { "namespace-123" }
it { is_expected.to be_truthy }
end
- context 'for group cluster' do
- let(:namespace) { 'namespace-123' }
+ context "for group cluster" do
+ let(:namespace) { "namespace-123" }
let(:cluster) { build(:cluster, :group, :provided_by_user) }
let(:kubernetes) { cluster.platform_kubernetes }
@@ -74,61 +74,61 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
- context 'when validates api_url' do
+ context "when validates api_url" do
let(:kubernetes) { build(:cluster_platform_kubernetes, :configured) }
before do
kubernetes.api_url = api_url
end
- context 'when api_url is invalid url' do
- let(:api_url) { '!!!!!!' }
+ context "when api_url is invalid url" do
+ let(:api_url) { "!!!!!!" }
it { expect(kubernetes.save).to be_falsey }
end
- context 'when api_url is nil' do
+ context "when api_url is nil" do
let(:api_url) { nil }
it { expect(kubernetes.save).to be_falsey }
end
- context 'when api_url is valid url' do
- let(:api_url) { 'https://111.111.111.111' }
+ context "when api_url is valid url" do
+ let(:api_url) { "https://111.111.111.111" }
it { expect(kubernetes.save).to be_truthy }
end
end
- context 'when validates token' do
+ context "when validates token" do
let(:kubernetes) { build(:cluster_platform_kubernetes, :configured) }
before do
kubernetes.token = token
end
- context 'when token is nil' do
+ context "when token is nil" do
let(:token) { nil }
it { expect(kubernetes.save).to be_falsey }
end
end
- context 'ca_cert' do
+ context "ca_cert" do
let(:kubernetes) { build(:cluster_platform_kubernetes, ca_pem: ca_pem) }
- context 'with a valid certificate' do
- let(:ca_pem) { File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) }
+ context "with a valid certificate" do
+ let(:ca_pem) { File.read(Rails.root.join("spec/fixtures/clusters/sample_cert.pem")) }
it { is_expected.to be_truthy }
end
- context 'with an invalid certificate' do
+ context "with an invalid certificate" do
let(:ca_pem) { "invalid" }
it { is_expected.to be_falsey }
- context 'but the certificate is not being updated' do
+ context "but the certificate is not being updated" do
before do
allow(kubernetes).to receive(:ca_cert_changed?).and_return(false)
end
@@ -137,53 +137,53 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
- context 'with no certificate' do
+ context "with no certificate" do
let(:ca_pem) { "" }
it { is_expected.to be_truthy }
end
end
- describe 'when using reserved namespaces' do
+ describe "when using reserved namespaces" do
subject { build(:cluster_platform_kubernetes, namespace: namespace) }
- context 'when no namespace is manually assigned' do
+ context "when no namespace is manually assigned" do
let(:namespace) { nil }
it { is_expected.to be_valid }
end
- context 'when no reserved namespace is assigned' do
- let(:namespace) { 'my-namespace' }
+ context "when no reserved namespace is assigned" do
+ let(:namespace) { "my-namespace" }
it { is_expected.to be_valid }
end
- context 'when reserved namespace is assigned' do
- let(:namespace) { 'gitlab-managed-apps' }
+ context "when reserved namespace is assigned" do
+ let(:namespace) { "gitlab-managed-apps" }
it { is_expected.not_to be_valid }
end
end
end
- describe '#kubeclient' do
+ describe "#kubeclient" do
let(:cluster) { create(:cluster, :project) }
- let(:kubernetes) { build(:cluster_platform_kubernetes, :configured, namespace: 'a-namespace', cluster: cluster) }
+ let(:kubernetes) { build(:cluster_platform_kubernetes, :configured, namespace: "a-namespace", cluster: cluster) }
subject { kubernetes.kubeclient }
before do
create(:cluster_kubernetes_namespace,
- cluster: kubernetes.cluster,
- cluster_project: kubernetes.cluster.cluster_project,
- project: kubernetes.cluster.cluster_project.project)
+ cluster: kubernetes.cluster,
+ cluster_project: kubernetes.cluster.cluster_project,
+ project: kubernetes.cluster.cluster_project.project)
end
it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::KubeClient) }
end
- describe '#rbac?' do
+ describe "#rbac?" do
let(:kubernetes) { build(:cluster_platform_kubernetes, :configured) }
subject { kubernetes.rbac? }
@@ -191,28 +191,28 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to be_truthy }
end
- describe '#actual_namespace' do
+ describe "#actual_namespace" do
let(:cluster) { create(:cluster, :project) }
let(:project) { cluster.project }
let(:platform) do
create(:cluster_platform_kubernetes,
- cluster: cluster,
- namespace: namespace)
+ cluster: cluster,
+ namespace: namespace)
end
subject { platform.actual_namespace }
- context 'with a namespace assigned' do
- let(:namespace) { 'namespace-123' }
+ context "with a namespace assigned" do
+ let(:namespace) { "namespace-123" }
it { is_expected.to eq(namespace) }
end
- context 'with no namespace assigned' do
+ context "with no namespace assigned" do
let(:namespace) { nil }
- context 'when kubernetes namespace is present' do
+ context "when kubernetes namespace is present" do
let(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster) }
before do
@@ -222,127 +222,127 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to eq(kubernetes_namespace.namespace) }
end
- context 'when kubernetes namespace is not present' do
+ context "when kubernetes namespace is not present" do
it { is_expected.to eq("#{project.path}-#{project.id}") }
end
end
end
- describe '#predefined_variables' do
+ describe "#predefined_variables" do
let!(:cluster) { create(:cluster, :project, platform_kubernetes: kubernetes) }
let(:kubernetes) { create(:cluster_platform_kubernetes, api_url: api_url, ca_cert: ca_pem) }
- let(:api_url) { 'https://kube.domain.com' }
- let(:ca_pem) { File.read(Rails.root.join('spec/fixtures/clusters/sample_cert.pem')) }
+ let(:api_url) { "https://kube.domain.com" }
+ let(:ca_pem) { File.read(Rails.root.join("spec/fixtures/clusters/sample_cert.pem")) }
subject { kubernetes.predefined_variables(project: cluster.project) }
- shared_examples 'setting variables' do
- it 'sets the variables' do
+ shared_examples "setting variables" do
+ it "sets the variables" do
expect(subject).to include(
- { key: 'KUBE_URL', value: api_url, public: true },
- { key: 'KUBE_CA_PEM', value: ca_pem, public: true },
- { key: 'KUBE_CA_PEM_FILE', value: ca_pem, public: true, file: true }
+ {key: "KUBE_URL", value: api_url, public: true},
+ {key: "KUBE_CA_PEM", value: ca_pem, public: true},
+ {key: "KUBE_CA_PEM_FILE", value: ca_pem, public: true, file: true}
)
end
end
- context 'kubernetes namespace is created with no service account token' do
+ context "kubernetes namespace is created with no service account token" do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, cluster: cluster) }
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets KUBE_TOKEN' do
+ it "sets KUBE_TOKEN" do
expect(subject).to include(
- { key: 'KUBE_TOKEN', value: kubernetes.token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes.token, public: false}
)
end
end
- context 'kubernetes namespace is created with no service account token' do
+ context "kubernetes namespace is created with no service account token" do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token, cluster: cluster) }
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets KUBE_TOKEN' do
+ it "sets KUBE_TOKEN" do
expect(subject).to include(
- { key: 'KUBE_TOKEN', value: kubernetes_namespace.service_account_token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes_namespace.service_account_token, public: false}
)
end
end
- context 'namespace is provided' do
- let(:namespace) { 'my-project' }
+ context "namespace is provided" do
+ let(:namespace) { "my-project" }
before do
kubernetes.namespace = namespace
end
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets KUBE_TOKEN' do
+ it "sets KUBE_TOKEN" do
expect(subject).to include(
- { key: 'KUBE_TOKEN', value: kubernetes.token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes.token, public: false}
)
end
end
- context 'no namespace provided' do
+ context "no namespace provided" do
let(:namespace) { kubernetes.actual_namespace }
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets KUBE_TOKEN' do
+ it "sets KUBE_TOKEN" do
expect(subject).to include(
- { key: 'KUBE_TOKEN', value: kubernetes.token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes.token, public: false}
)
end
end
- context 'group level cluster' do
+ context "group level cluster" do
let!(:cluster) { create(:cluster, :group, platform_kubernetes: kubernetes) }
let(:project) { create(:project, group: cluster.group) }
subject { kubernetes.predefined_variables(project: project) }
- context 'no kubernetes namespace for the project' do
- it_behaves_like 'setting variables'
+ context "no kubernetes namespace for the project" do
+ it_behaves_like "setting variables"
- it 'does not return KUBE_TOKEN' do
+ it "does not return KUBE_TOKEN" do
expect(subject).not_to include(
- { key: 'KUBE_TOKEN', value: kubernetes.token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes.token, public: false}
)
end
end
- context 'kubernetes namespace exists for the project' do
+ context "kubernetes namespace exists for the project" do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token, cluster: cluster, project: project) }
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets KUBE_TOKEN' do
+ it "sets KUBE_TOKEN" do
expect(subject).to include(
- { key: 'KUBE_TOKEN', value: kubernetes_namespace.service_account_token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes_namespace.service_account_token, public: false}
)
end
end
end
- context 'with a domain' do
+ context "with a domain" do
let!(:cluster) do
create(:cluster, :provided_by_gcp, :with_domain,
- platform_kubernetes: kubernetes)
+ platform_kubernetes: kubernetes)
end
- it 'sets KUBE_INGRESS_BASE_DOMAIN' do
+ it "sets KUBE_INGRESS_BASE_DOMAIN" do
expect(subject).to include(
- { key: 'KUBE_INGRESS_BASE_DOMAIN', value: cluster.domain, public: true }
+ {key: "KUBE_INGRESS_BASE_DOMAIN", value: cluster.domain, public: true}
)
end
end
end
- describe '#terminals' do
+ describe "#terminals" do
subject { service.terminals(environment) }
let!(:cluster) { create(:cluster, :project, platform_kubernetes: service) }
@@ -350,15 +350,15 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
let(:service) { create(:cluster_platform_kubernetes, :configured) }
let(:environment) { build(:environment, project: project, name: "env", slug: "env-000000") }
- context 'with invalid pods' do
- it 'returns no terminals' do
- stub_reactive_cache(service, pods: [{ "bad" => "pod" }])
+ context "with invalid pods" do
+ it "returns no terminals" do
+ stub_reactive_cache(service, pods: [{"bad" => "pod"}])
is_expected.to be_empty
end
end
- context 'with valid pods' do
+ context "with valid pods" do
let(:pod) { kube_pod(app: environment.slug) }
let(:pod_with_no_terminal) { kube_pod(app: environment.slug, status: "Pending") }
let(:terminals) { kube_terminals(service, pod) }
@@ -370,11 +370,11 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
)
end
- it 'returns terminals' do
+ it "returns terminals" do
is_expected.to eq(terminals + terminals)
end
- it 'uses max session time from settings' do
+ it "uses max session time from settings" do
stub_application_setting(terminal_max_session_time: 600)
times = subject.map { |terminal| terminal[:max_session_time] }
@@ -383,20 +383,20 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
- describe '#calculate_reactive_cache' do
+ describe "#calculate_reactive_cache" do
subject { service.calculate_reactive_cache }
let!(:cluster) { create(:cluster, :project, enabled: enabled, platform_kubernetes: service) }
let(:service) { create(:cluster_platform_kubernetes, :configured) }
let(:enabled) { true }
- context 'when cluster is disabled' do
+ context "when cluster is disabled" do
let(:enabled) { false }
it { is_expected.to be_nil }
end
- context 'when kubernetes responds with valid pods and deployments' do
+ context "when kubernetes responds with valid pods and deployments" do
before do
stub_kubeclient_pods
stub_kubeclient_deployments
@@ -405,7 +405,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { is_expected.to include(pods: [kube_pod]) }
end
- context 'when kubernetes responds with 500s' do
+ context "when kubernetes responds with 500s" do
before do
stub_kubeclient_pods(status: 500)
stub_kubeclient_deployments(status: 500)
@@ -414,7 +414,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
it { expect { subject }.to raise_error(Kubeclient::HttpError) }
end
- context 'when kubernetes responds with 404s' do
+ context "when kubernetes responds with 404s" do
before do
stub_kubeclient_pods(status: 404)
stub_kubeclient_deployments(status: 404)
@@ -424,21 +424,21 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
end
- describe '#update_kubernetes_namespace' do
+ describe "#update_kubernetes_namespace" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
let(:platform) { cluster.platform }
- context 'when namespace is updated' do
- it 'should call ConfigureWorker' do
+ context "when namespace is updated" do
+ it "should call ConfigureWorker" do
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id).once
- platform.namespace = 'new-namespace'
+ platform.namespace = "new-namespace"
platform.save
end
end
- context 'when namespace is not updated' do
- it 'should not call ConfigureWorker' do
+ context "when namespace is not updated" do
+ it "should not call ConfigureWorker" do
expect(ClusterConfigureWorker).not_to receive(:perform_async)
platform.username = "new-username"
diff --git a/spec/models/clusters/project_spec.rb b/spec/models/clusters/project_spec.rb
index 82ef5a23c18..859968b4710 100644
--- a/spec/models/clusters/project_spec.rb
+++ b/spec/models/clusters/project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Project do
it { is_expected.to belong_to(:cluster) }
diff --git a/spec/models/clusters/providers/gcp_spec.rb b/spec/models/clusters/providers/gcp_spec.rb
index 5012e6f15c6..cb0134aaeb1 100644
--- a/spec/models/clusters/providers/gcp_spec.rb
+++ b/spec/models/clusters/providers/gcp_spec.rb
@@ -1,72 +1,72 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Providers::Gcp do
it { is_expected.to belong_to(:cluster) }
it { is_expected.to validate_presence_of(:zone) }
- describe 'default_value_for' do
+ describe "default_value_for" do
let(:gcp) { build(:cluster_provider_gcp) }
it "has default value" do
- expect(gcp.zone).to eq('us-central1-a')
+ expect(gcp.zone).to eq("us-central1-a")
expect(gcp.num_nodes).to eq(3)
- expect(gcp.machine_type).to eq('n1-standard-2')
+ expect(gcp.machine_type).to eq("n1-standard-2")
end
end
- describe 'validation' do
+ describe "validation" do
subject { gcp.valid? }
- context 'when validates gcp_project_id' do
+ context "when validates gcp_project_id" do
let(:gcp) { build(:cluster_provider_gcp, gcp_project_id: gcp_project_id) }
- context 'when gcp_project_id is shorter than 1' do
- let(:gcp_project_id) { '' }
+ context "when gcp_project_id is shorter than 1" do
+ let(:gcp_project_id) { "" }
it { is_expected.to be_falsey }
end
- context 'when gcp_project_id is longer than 63' do
- let(:gcp_project_id) { 'a' * 64 }
+ context "when gcp_project_id is longer than 63" do
+ let(:gcp_project_id) { "a" * 64 }
it { is_expected.to be_falsey }
end
- context 'when gcp_project_id includes invalid character' do
- let(:gcp_project_id) { '!!!!!!' }
+ context "when gcp_project_id includes invalid character" do
+ let(:gcp_project_id) { "!!!!!!" }
it { is_expected.to be_falsey }
end
- context 'when gcp_project_id is valid' do
- let(:gcp_project_id) { 'gcp-project-1' }
+ context "when gcp_project_id is valid" do
+ let(:gcp_project_id) { "gcp-project-1" }
it { is_expected.to be_truthy }
end
end
- context 'when validates num_nodes' do
+ context "when validates num_nodes" do
let(:gcp) { build(:cluster_provider_gcp, num_nodes: num_nodes) }
- context 'when num_nodes is string' do
- let(:num_nodes) { 'A3' }
+ context "when num_nodes is string" do
+ let(:num_nodes) { "A3" }
it { is_expected.to be_falsey }
end
- context 'when num_nodes is nil' do
+ context "when num_nodes is nil" do
let(:num_nodes) { nil }
it { is_expected.to be_falsey }
end
- context 'when num_nodes is smaller than 1' do
+ context "when num_nodes is smaller than 1" do
let(:num_nodes) { 0 }
it { is_expected.to be_falsey }
end
- context 'when num_nodes is valid' do
+ context "when num_nodes is valid" do
let(:num_nodes) { 3 }
it { is_expected.to be_truthy }
@@ -74,7 +74,7 @@ describe Clusters::Providers::Gcp do
end
end
- describe '#legacy_abac?' do
+ describe "#legacy_abac?" do
let(:gcp) { build(:cluster_provider_gcp) }
subject { gcp }
@@ -82,52 +82,52 @@ describe Clusters::Providers::Gcp do
it { is_expected.not_to be_legacy_abac }
end
- describe '#state_machine' do
- context 'when any => [:created]' do
+ describe "#state_machine" do
+ context "when any => [:created]" do
let(:gcp) { build(:cluster_provider_gcp, :creating) }
before do
gcp.make_created
end
- it 'nullify access_token and operation_id' do
+ it "nullify access_token and operation_id" do
expect(gcp.access_token).to be_nil
expect(gcp.operation_id).to be_nil
expect(gcp).to be_created
end
end
- context 'when any => [:creating]' do
+ context "when any => [:creating]" do
let(:gcp) { build(:cluster_provider_gcp) }
- context 'when operation_id is present' do
- let(:operation_id) { 'operation-xxx' }
+ context "when operation_id is present" do
+ let(:operation_id) { "operation-xxx" }
before do
gcp.make_creating(operation_id)
end
- it 'sets operation_id' do
+ it "sets operation_id" do
expect(gcp.operation_id).to eq(operation_id)
expect(gcp).to be_creating
end
end
- context 'when operation_id is nil' do
+ context "when operation_id is nil" do
let(:operation_id) { nil }
- it 'raises an error' do
+ it "raises an error" do
expect { gcp.make_creating(operation_id) }
- .to raise_error('operation_id is required')
+ .to raise_error("operation_id is required")
end
end
end
- context 'when any => [:errored]' do
+ context "when any => [:errored]" do
let(:gcp) { build(:cluster_provider_gcp, :creating) }
- let(:status_reason) { 'err msg' }
+ let(:status_reason) { "err msg" }
- it 'nullify access_token and operation_id' do
+ it "nullify access_token and operation_id" do
gcp.make_errored(status_reason)
expect(gcp.access_token).to be_nil
@@ -136,10 +136,10 @@ describe Clusters::Providers::Gcp do
expect(gcp).to be_errored
end
- context 'when status_reason is nil' do
+ context "when status_reason is nil" do
let(:gcp) { build(:cluster_provider_gcp, :errored) }
- it 'does not set status_reason' do
+ it "does not set status_reason" do
gcp.make_errored(nil)
expect(gcp.status_reason).not_to be_nil
@@ -148,41 +148,41 @@ describe Clusters::Providers::Gcp do
end
end
- describe '#on_creation?' do
+ describe "#on_creation?" do
subject { gcp.on_creation? }
- context 'when status is creating' do
+ context "when status is creating" do
let(:gcp) { create(:cluster_provider_gcp, :creating) }
it { is_expected.to be_truthy }
end
- context 'when status is created' do
+ context "when status is created" do
let(:gcp) { create(:cluster_provider_gcp, :created) }
it { is_expected.to be_falsey }
end
end
- describe '#api_client' do
+ describe "#api_client" do
subject { gcp.api_client }
- context 'when status is creating' do
+ context "when status is creating" do
let(:gcp) { build(:cluster_provider_gcp, :creating) }
- it 'returns Cloud Platform API clinet' do
+ it "returns Cloud Platform API clinet" do
expect(subject).to be_an_instance_of(GoogleApi::CloudPlatform::Client)
expect(subject.access_token).to eq(gcp.access_token)
end
end
- context 'when status is created' do
+ context "when status is created" do
let(:gcp) { build(:cluster_provider_gcp, :created) }
it { is_expected.to be_nil }
end
- context 'when status is errored' do
+ context "when status is errored" do
let(:gcp) { build(:cluster_provider_gcp, :errored) }
it { is_expected.to be_nil }
diff --git a/spec/models/commit_collection_spec.rb b/spec/models/commit_collection_spec.rb
index 0f5d03ff458..a84ba24ca97 100644
--- a/spec/models/commit_collection_spec.rb
+++ b/spec/models/commit_collection_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe CommitCollection do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit("c1c67abbaf91f624347bb3ae96eabe3a1b742478") }
- describe '#each' do
- it 'yields every commit' do
+ describe "#each" do
+ it "yields every commit" do
collection = described_class.new(project, [commit])
expect { |b| collection.each(&b) }.to yield_with_args(commit)
end
end
- describe '.authors' do
- it 'returns a relation of users when users are found' do
+ describe ".authors" do
+ it "returns a relation of users when users are found" do
user = create(:user, email: commit.author_email.upcase)
collection = described_class.new(project, [commit])
expect(collection.authors).to contain_exactly(user)
end
- it 'returns empty array when authors cannot be found' do
+ it "returns empty array when authors cannot be found" do
collection = described_class.new(project, [commit])
expect(collection.authors).to be_empty
end
- it 'excludes authors of merge commits' do
+ it "excludes authors of merge commits" do
commit = project.commit("60ecb67744cb56576c30214ff52294f8ce2def98")
create(:user, email: commit.author_email.upcase)
collection = described_class.new(project, [commit])
@@ -35,54 +35,54 @@ describe CommitCollection do
end
end
- describe '#without_merge_commits' do
- it 'returns all commits except merge commits' do
+ describe "#without_merge_commits" do
+ it "returns all commits except merge commits" do
collection = described_class.new(project, [
build(:commit),
- build(:commit, :merge_commit)
+ build(:commit, :merge_commit),
])
expect(collection.without_merge_commits.size).to eq(1)
end
end
- describe '#with_pipeline_status' do
- it 'sets the pipeline status for every commit so no additional queries are necessary' do
+ describe "#with_pipeline_status" do
+ it "sets the pipeline status for every commit so no additional queries are necessary" do
create(
:ci_empty_pipeline,
- ref: 'master',
+ ref: "master",
sha: commit.id,
- status: 'success',
+ status: "success",
project: project
)
collection = described_class.new(project, [commit])
collection.with_pipeline_status
- recorder = ActiveRecord::QueryRecorder.new do
- expect(commit.status).to eq('success')
- end
+ recorder = ActiveRecord::QueryRecorder.new {
+ expect(commit.status).to eq("success")
+ }
expect(recorder.count).to be_zero
end
end
- describe '#respond_to_missing?' do
- it 'returns true when the underlying Array responds to the message' do
+ describe "#respond_to_missing?" do
+ it "returns true when the underlying Array responds to the message" do
collection = described_class.new(project, [])
expect(collection.respond_to?(:last)).to eq(true)
end
- it 'returns false when the underlying Array does not respond to the message' do
+ it "returns false when the underlying Array does not respond to the message" do
collection = described_class.new(project, [])
expect(collection.respond_to?(:foo)).to eq(false)
end
end
- describe '#method_missing' do
- it 'delegates undefined methods to the underlying Array' do
+ describe "#method_missing" do
+ it "delegates undefined methods to the underlying Array" do
collection = described_class.new(project, [commit])
expect(collection.length).to eq(1)
diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb
index f2efcd9d0e9..23840026881 100644
--- a/spec/models/commit_range_spec.rb
+++ b/spec/models/commit_range_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe CommitRange do
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Referable) }
@@ -20,12 +20,12 @@ describe CommitRange do
let(:range) { described_class.new("#{sha_from}...#{sha_to}", project) }
let(:range2) { described_class.new("#{sha_from}..#{sha_to}", project) }
- it 'raises ArgumentError when given an invalid range string' do
+ it "raises ArgumentError when given an invalid range string" do
expect { described_class.new("Foo", project) }.to raise_error(ArgumentError)
end
- describe '#initialize' do
- it 'does not modify strings in-place' do
+ describe "#initialize" do
+ it "does not modify strings in-place" do
input = "#{sha_from}...#{sha_to} "
described_class.new(input, project)
@@ -34,118 +34,118 @@ describe CommitRange do
end
end
- describe '#to_s' do
- it 'is correct for three-dot syntax' do
+ describe "#to_s" do
+ it "is correct for three-dot syntax" do
expect(range.to_s).to eq "#{full_sha_from}...#{full_sha_to}"
end
- it 'is correct for two-dot syntax' do
+ it "is correct for two-dot syntax" do
expect(range2.to_s).to eq "#{full_sha_from}..#{full_sha_to}"
end
end
- describe '#to_reference' do
+ describe "#to_reference" do
let(:cross) { create(:project, namespace: project.namespace) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(range.to_reference).to eq "#{full_sha_from}...#{full_sha_to}"
end
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(range2.to_reference).to eq "#{full_sha_from}..#{full_sha_to}"
end
- it 'supports a cross-project reference' do
+ it "supports a cross-project reference" do
expect(range.to_reference(cross)).to eq "#{project.path}@#{full_sha_from}...#{full_sha_to}"
end
end
- describe '#reference_link_text' do
+ describe "#reference_link_text" do
let(:cross) { create(:project, namespace: project.namespace) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(range.reference_link_text).to eq "#{sha_from}...#{sha_to}"
end
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(range2.reference_link_text).to eq "#{sha_from}..#{sha_to}"
end
- it 'supports a cross-project reference' do
+ it "supports a cross-project reference" do
expect(range.reference_link_text(cross)).to eq "#{project.path}@#{sha_from}...#{sha_to}"
end
end
- describe '#to_param' do
- it 'includes the correct keys' do
- expect(range.to_param.keys).to eq %i(from to)
+ describe "#to_param" do
+ it "includes the correct keys" do
+ expect(range.to_param.keys).to eq %i[from to]
end
- it 'includes the correct values for a three-dot range' do
- expect(range.to_param).to eq({ from: full_sha_from, to: full_sha_to })
+ it "includes the correct values for a three-dot range" do
+ expect(range.to_param).to eq({from: full_sha_from, to: full_sha_to})
end
- it 'includes the correct values for a two-dot range' do
- expect(range2.to_param).to eq({ from: full_sha_from + '^', to: full_sha_to })
+ it "includes the correct values for a two-dot range" do
+ expect(range2.to_param).to eq({from: full_sha_from + "^", to: full_sha_to})
end
end
- describe '#exclude_start?' do
- it 'is false for three-dot ranges' do
+ describe "#exclude_start?" do
+ it "is false for three-dot ranges" do
expect(range.exclude_start?).to eq false
end
- it 'is true for two-dot ranges' do
+ it "is true for two-dot ranges" do
expect(range2.exclude_start?).to eq true
end
end
- describe '#valid_commits?' do
- context 'with a valid repo' do
+ describe "#valid_commits?" do
+ context "with a valid repo" do
before do
expect(project).to receive(:valid_repo?).and_return(true)
end
- it 'is false when `sha_from` is invalid' do
+ it "is false when `sha_from` is invalid" do
expect(project).to receive(:commit).with(sha_from).and_return(nil)
expect(project).to receive(:commit).with(sha_to).and_call_original
expect(range).not_to be_valid_commits
end
- it 'is false when `sha_to` is invalid' do
+ it "is false when `sha_to` is invalid" do
expect(project).to receive(:commit).with(sha_from).and_call_original
expect(project).to receive(:commit).with(sha_to).and_return(nil)
expect(range).not_to be_valid_commits
end
- it 'is true when both `sha_from` and `sha_to` are valid' do
+ it "is true when both `sha_from` and `sha_to` are valid" do
expect(range).to be_valid_commits
end
end
- context 'without a valid repo' do
+ context "without a valid repo" do
before do
expect(project).to receive(:valid_repo?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(range).not_to be_valid_commits
end
end
end
- describe '#has_been_reverted?' do
+ describe "#has_been_reverted?" do
let(:issue) { create(:issue) }
let(:user) { issue.author }
- it 'returns true if the commit has been reverted' do
+ it "returns true if the commit has been reverted" do
create(:note_on_issue,
- noteable: issue,
- system: true,
- note: commit1.revert_description(user),
- project: issue.project)
+ noteable: issue,
+ system: true,
+ note: commit1.revert_description(user),
+ project: issue.project)
expect_any_instance_of(Commit).to receive(:reverts_commit?)
.with(commit1, user)
@@ -154,7 +154,7 @@ describe CommitRange do
expect(commit1.has_been_reverted?(user, issue.notes_with_associations)).to eq(true)
end
- it 'returns false if the commit has not been reverted' do
+ it "returns false if the commit has not been reverted" do
expect(commit1.has_been_reverted?(user, issue.notes_with_associations)).to eq(false)
end
end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index baad8352185..058397a9f32 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Commit do
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Mentionable) }
@@ -14,52 +14,52 @@ describe Commit do
it { is_expected.to include_module(Presentable) }
end
- describe '.lazy' do
+ describe ".lazy" do
set(:project) { create(:project, :repository) }
- context 'when the commits are found' do
+ context "when the commits are found" do
let(:oids) do
- %w(
+ %w[
498214de67004b1da3d820901307bed2a68a8ef6
c642fe9b8b9f28f9225d7ea953fe14e74748d53b
6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
048721d90c449b244b7b4c53a9186b04330174ec
281d3a76f31c812dbf48abce82ccf6860adedd81
- )
+ ]
end
subject { oids.map { |oid| described_class.lazy(project, oid) } }
- it 'batches requests for commits' do
+ it "batches requests for commits" do
expect(project.repository).to receive(:commits_by).once.and_call_original
subject.first.title
subject.last.title
end
- it 'maintains ordering' do
+ it "maintains ordering" do
subject.each_with_index do |commit, i|
expect(commit.id).to eq(oids[i])
end
end
end
- context 'when not found' do
- it 'returns nil as commit' do
- commit = described_class.lazy(project, 'deadbeef').__sync
+ context "when not found" do
+ it "returns nil as commit" do
+ commit = described_class.lazy(project, "deadbeef").__sync
expect(commit).to be_nil
end
end
end
- describe '#author', :request_store do
- it 'looks up the author in a case-insensitive way' do
+ describe "#author", :request_store do
+ it "looks up the author in a case-insensitive way" do
user = create(:user, email: commit.author_email.upcase)
expect(commit.author).to eq(user)
end
- it 'caches the author' do
+ it "caches the author" do
user = create(:user, email: commit.author_email)
expect(commit.author).to eq(user)
@@ -70,14 +70,14 @@ describe Commit do
expect(commit.author).to eq(user)
end
- context 'using eager loading' do
- let!(:alice) { create(:user, email: 'alice@example.com') }
- let!(:bob) { create(:user, email: 'hunter2@example.com') }
+ context "using eager loading" do
+ let!(:alice) { create(:user, email: "alice@example.com") }
+ let!(:bob) { create(:user, email: "hunter2@example.com") }
let!(:jeff) { create(:user) }
let(:alice_commit) do
described_class.new(RepoHelpers.sample_commit, project).tap do |c|
- c.author_email = 'alice@example.com'
+ c.author_email = "alice@example.com"
end
end
@@ -85,13 +85,13 @@ describe Commit do
# The commit for Bob uses one of his alternative Emails, instead of the
# primary one.
described_class.new(RepoHelpers.sample_commit, project).tap do |c|
- c.author_email = 'bob@example.com'
+ c.author_email = "bob@example.com"
end
end
let(:eve_commit) do
described_class.new(RepoHelpers.sample_commit, project).tap do |c|
- c.author_email = 'eve@example.com'
+ c.author_email = "eve@example.com"
end
end
@@ -105,11 +105,11 @@ describe Commit do
let!(:commits) { [alice_commit, bob_commit, eve_commit, jeff_commit] }
before do
- create(:email, user: bob, email: 'bob@example.com')
+ create(:email, user: bob, email: "bob@example.com")
end
- it 'executes only two SQL queries' do
- recorder = ActiveRecord::QueryRecorder.new do
+ it "executes only two SQL queries" do
+ recorder = ActiveRecord::QueryRecorder.new {
# Running this first ensures we don't run one query for every
# commit.
commits.each(&:lazy_author)
@@ -117,7 +117,7 @@ describe Commit do
# This forces the execution of the SQL queries necessary to load the
# data.
commits.each { |c| c.author.try(:id) }
- end
+ }
expect(recorder.count).to eq(2)
end
@@ -141,71 +141,71 @@ describe Commit do
end
it "preloads the authors for Commits using a User's outdated private commit Email" do
- jeff.update!(username: 'new-username')
+ jeff.update!(username: "new-username")
commits.each(&:lazy_author)
expect(jeff_commit.author).to eq(jeff)
end
- it 'sets the author to Nil if an author could not be found for a Commit' do
+ it "sets the author to Nil if an author could not be found for a Commit" do
commits.each(&:lazy_author)
expect(eve_commit.author).to be_nil
end
- it 'does not execute SQL queries once the authors are preloaded' do
+ it "does not execute SQL queries once the authors are preloaded" do
commits.each(&:lazy_author)
commits.each { |c| c.author.try(:id) }
- recorder = ActiveRecord::QueryRecorder.new do
+ recorder = ActiveRecord::QueryRecorder.new {
alice_commit.author
bob_commit.author
eve_commit.author
- end
+ }
expect(recorder.count).to be_zero
end
end
end
- describe '#to_reference' do
- let(:project) { create(:project, :repository, path: 'sample-project') }
+ describe "#to_reference" do
+ let(:project) { create(:project, :repository, path: "sample-project") }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(commit.to_reference).to eq commit.id
end
- it 'supports a cross-project reference' do
- another_project = build(:project, :repository, name: 'another-project', namespace: project.namespace)
+ it "supports a cross-project reference" do
+ another_project = build(:project, :repository, name: "another-project", namespace: project.namespace)
expect(commit.to_reference(another_project)).to eq "sample-project@#{commit.id}"
end
end
- describe '#reference_link_text' do
- let(:project) { create(:project, :repository, path: 'sample-project') }
+ describe "#reference_link_text" do
+ let(:project) { create(:project, :repository, path: "sample-project") }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(commit.reference_link_text).to eq commit.short_id
end
- it 'supports a cross-project reference' do
- another_project = build(:project, :repository, name: 'another-project', namespace: project.namespace)
+ it "supports a cross-project reference" do
+ another_project = build(:project, :repository, name: "another-project", namespace: project.namespace)
expect(commit.reference_link_text(another_project)).to eq "sample-project@#{commit.short_id}"
end
end
- describe '#title' do
+ describe "#title" do
it "returns no_commit_message when safe_message is blank" do
- allow(commit).to receive(:safe_message).and_return('')
+ allow(commit).to receive(:safe_message).and_return("")
expect(commit.title).to eq("--no commit message")
end
- it 'truncates a message without a newline at natural break to 80 characters' do
- message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
+ it "truncates a message without a newline at natural break to 80 characters" do
+ message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris."
allow(commit).to receive(:safe_message).and_return(message)
- expect(commit.title).to eq('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id...')
+ expect(commit.title).to eq("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id...")
end
it "truncates a message with a newline before 80 characters at the newline" do
@@ -216,24 +216,24 @@ describe Commit do
end
it "does not truncates a message with a newline after 80 but less 100 characters" do
- message = <<eos
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
-Vivamus egestas lacinia lacus, sed rutrum mauris.
-eos
+ message = <<~eos
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
+ Vivamus egestas lacinia lacus, sed rutrum mauris.
+ eos
allow(commit).to receive(:safe_message).and_return(message)
expect(commit.title).to eq(message.split("\n").first)
end
end
- describe '#full_title' do
+ describe "#full_title" do
it "returns no_commit_message when safe_message is blank" do
- allow(commit).to receive(:safe_message).and_return('')
+ allow(commit).to receive(:safe_message).and_return("")
expect(commit.full_title).to eq("--no commit message")
end
it "returns entire message if there is no newline" do
- message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.'
+ message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris."
allow(commit).to receive(:safe_message).and_return(message)
expect(commit.full_title).to eq(message)
@@ -247,28 +247,28 @@ eos
end
end
- describe 'description' do
- it 'returns no_commit_message when safe_message is blank' do
+ describe "description" do
+ it "returns no_commit_message when safe_message is blank" do
allow(commit).to receive(:safe_message).and_return(nil)
- expect(commit.description).to eq('--no commit message')
+ expect(commit.description).to eq("--no commit message")
end
- it 'returns description of commit message if title less than 100 characters' do
- message = <<eos
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
-Vivamus egestas lacinia lacus, sed rutrum mauris.
-eos
+ it "returns description of commit message if title less than 100 characters" do
+ message = <<~eos
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit.
+ Vivamus egestas lacinia lacus, sed rutrum mauris.
+ eos
allow(commit).to receive(:safe_message).and_return(message)
- expect(commit.description).to eq('Vivamus egestas lacinia lacus, sed rutrum mauris.')
+ expect(commit.description).to eq("Vivamus egestas lacinia lacus, sed rutrum mauris.")
end
- it 'returns full commit message if commit title more than 100 characters' do
- message = <<eos
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.
-Vivamus egestas lacinia lacus, sed rutrum mauris.
-eos
+ it "returns full commit message if commit title more than 100 characters" do
+ message = <<~eos
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec sodales id felis id blandit. Vivamus egestas lacinia lacus, sed rutrum mauris.
+ Vivamus egestas lacinia lacus, sed rutrum mauris.
+ eos
allow(commit).to receive(:safe_message).and_return(message)
expect(commit.description).to eq(message)
@@ -289,7 +289,7 @@ eos
it { is_expected.to respond_to(:id) }
end
- describe '#closes_issues' do
+ describe "#closes_issues" do
let(:issue) { create :issue, project: project }
let(:other_project) { create(:project, :public) }
let(:other_issue) { create :issue, project: other_project }
@@ -300,7 +300,7 @@ eos
other_project.add_developer(committer)
end
- it 'detects issues that this commit is marked as closing' do
+ it "detects issues that this commit is marked as closing" do
ext_ref = "#{other_project.full_path}##{other_issue.iid}"
allow(commit).to receive_messages(
@@ -313,7 +313,7 @@ eos
end
end
- it_behaves_like 'a mentionable' do
+ it_behaves_like "a mentionable" do
subject { create(:project, :repository).commit }
let(:author) { create(:user, email: subject.author_email) }
@@ -326,47 +326,47 @@ eos
let(:extra_commits) { [subject] }
end
- describe '#hook_attrs' do
+ describe "#hook_attrs" do
let(:data) { commit.hook_attrs(with_changed_files: true) }
it { expect(data).to be_a(Hash) }
- it { expect(data[:message]).to include('adds bar folder and branch-test text file to check Repository merged_to_root_ref method') }
- it { expect(data[:timestamp]).to eq('2016-09-27T14:37:46Z') }
+ it { expect(data[:message]).to include("adds bar folder and branch-test text file to check Repository merged_to_root_ref method") }
+ it { expect(data[:timestamp]).to eq("2016-09-27T14:37:46Z") }
it { expect(data[:added]).to contain_exactly("bar/branch-test.txt") }
it { expect(data[:modified]).to eq([]) }
it { expect(data[:removed]).to eq([]) }
end
- describe '#cherry_pick_message' do
+ describe "#cherry_pick_message" do
let(:user) { create(:user) }
- context 'of a regular commit' do
- let(:commit) { project.commit('video') }
+ context "of a regular commit" do
+ let(:commit) { project.commit("video") }
it { expect(commit.cherry_pick_message(user)).to include("\n\n(cherry picked from commit 88790590ed1337ab189bccaa355f068481c90bec)") }
end
- context 'of a merge commit' do
+ context "of a merge commit" do
let(:repository) { project.repository }
let(:merge_request) do
create(:merge_request,
- source_branch: 'video',
- target_branch: 'master',
- source_project: project,
- author: user)
+ source_branch: "video",
+ target_branch: "master",
+ source_project: project,
+ author: user)
end
let(:merge_commit) do
merge_commit_id = repository.merge(user,
- merge_request.diff_head_sha,
- merge_request,
- 'Test message')
+ merge_request.diff_head_sha,
+ merge_request,
+ "Test message")
repository.commit(merge_commit_id)
end
- context 'that is found' do
+ context "that is found" do
before do
# Artificially mark as completed.
merge_request.update(merge_commit_sha: merge_commit.id)
@@ -386,20 +386,20 @@ eos
end
context "that is existing but not found" do
- it 'does not include details of the merged commits' do
+ it "does not include details of the merged commits" do
expect(merge_commit.cherry_pick_message(user)).to end_with("(cherry picked from commit #{merge_commit.sha})")
end
end
end
end
- describe '#reverts_commit?' do
+ describe "#reverts_commit?" do
let(:another_commit) { double(:commit, revert_description: "This reverts commit #{commit.sha}") }
let(:user) { commit.author }
it { expect(commit.reverts_commit?(another_commit, user)).to be_falsy }
- context 'commit has no description' do
+ context "commit has no description" do
before do
allow(commit).to receive(:description?).and_return(false)
end
@@ -434,94 +434,94 @@ eos
end
end
- describe '#last_pipeline' do
+ describe "#last_pipeline" do
let!(:first_pipeline) do
create(:ci_empty_pipeline,
project: project,
sha: commit.sha,
- status: 'success')
+ status: "success")
end
let!(:second_pipeline) do
create(:ci_empty_pipeline,
project: project,
sha: commit.sha,
- status: 'success')
+ status: "success")
end
- it 'returns last pipeline' do
+ it "returns last pipeline" do
expect(commit.last_pipeline).to eq second_pipeline
end
end
- describe '#status' do
- context 'without ref argument' do
+ describe "#status" do
+ context "without ref argument" do
before do
%w[success failed created pending].each do |status|
create(:ci_empty_pipeline,
- project: project,
- sha: commit.sha,
- status: status)
+ project: project,
+ sha: commit.sha,
+ status: status)
end
end
- it 'gives compound status from latest pipelines' do
+ it "gives compound status from latest pipelines" do
expect(commit.status).to eq(Ci::Pipeline.latest_status)
- expect(commit.status).to eq('pending')
+ expect(commit.status).to eq("pending")
end
end
- context 'when a particular ref is specified' do
+ context "when a particular ref is specified" do
let!(:pipeline_from_master) do
create(:ci_empty_pipeline,
- project: project,
- sha: commit.sha,
- ref: 'master',
- status: 'failed')
+ project: project,
+ sha: commit.sha,
+ ref: "master",
+ status: "failed")
end
let!(:pipeline_from_fix) do
create(:ci_empty_pipeline,
- project: project,
- sha: commit.sha,
- ref: 'fix',
- status: 'success')
+ project: project,
+ sha: commit.sha,
+ ref: "fix",
+ status: "success")
end
- it 'gives pipelines from a particular branch' do
- expect(commit.status('master')).to eq(pipeline_from_master.status)
- expect(commit.status('fix')).to eq(pipeline_from_fix.status)
+ it "gives pipelines from a particular branch" do
+ expect(commit.status("master")).to eq(pipeline_from_master.status)
+ expect(commit.status("fix")).to eq(pipeline_from_fix.status)
end
- it 'gives compound status from latest pipelines if ref is nil' do
+ it "gives compound status from latest pipelines if ref is nil" do
expect(commit.status(nil)).to eq(pipeline_from_fix.status)
end
end
end
- describe '#set_status_for_ref' do
- it 'sets the status for a given reference' do
- commit.set_status_for_ref('master', 'failed')
+ describe "#set_status_for_ref" do
+ it "sets the status for a given reference" do
+ commit.set_status_for_ref("master", "failed")
- expect(commit.status('master')).to eq('failed')
+ expect(commit.status("master")).to eq("failed")
end
end
- describe '#participants' do
+ describe "#participants" do
let(:user1) { build(:user) }
let(:user2) { build(:user) }
let!(:note1) do
create(:note_on_commit,
- commit_id: commit.id,
- project: project,
- note: 'foo')
+ commit_id: commit.id,
+ project: project,
+ note: "foo")
end
let!(:note2) do
create(:note_on_commit,
- commit_id: commit.id,
- project: project,
- note: 'bar')
+ commit_id: commit.id,
+ project: project,
+ note: "bar")
end
before do
@@ -529,57 +529,57 @@ eos
allow(commit).to receive(:committer).and_return(user2)
end
- it 'includes the commit author' do
+ it "includes the commit author" do
expect(commit.participants).to include(commit.author)
end
- it 'includes the committer' do
+ it "includes the committer" do
expect(commit.participants).to include(commit.committer)
end
- it 'includes the authors of the commit notes' do
+ it "includes the authors of the commit notes" do
expect(commit.participants).to include(note1.author, note2.author)
end
end
- describe '#uri_type' do
- it 'returns the URI type at the given path' do
- expect(commit.uri_type('files/html')).to be(:tree)
- expect(commit.uri_type('files/images/logo-black.png')).to be(:raw)
- expect(project.commit('video').uri_type('files/videos/intro.mp4')).to be(:raw)
- expect(commit.uri_type('files/js/application.js')).to be(:blob)
+ describe "#uri_type" do
+ it "returns the URI type at the given path" do
+ expect(commit.uri_type("files/html")).to be(:tree)
+ expect(commit.uri_type("files/images/logo-black.png")).to be(:raw)
+ expect(project.commit("video").uri_type("files/videos/intro.mp4")).to be(:raw)
+ expect(commit.uri_type("files/js/application.js")).to be(:blob)
end
it "returns nil if the path doesn't exists" do
- expect(commit.uri_type('this/path/doesnt/exist')).to be_nil
- expect(commit.uri_type('../path/doesnt/exist')).to be_nil
+ expect(commit.uri_type("this/path/doesnt/exist")).to be_nil
+ expect(commit.uri_type("../path/doesnt/exist")).to be_nil
end
- it 'is nil if the path is nil or empty' do
+ it "is nil if the path is nil or empty" do
expect(commit.uri_type(nil)).to be_nil
expect(commit.uri_type("")).to be_nil
end
end
- describe '.from_hash' do
+ describe ".from_hash" do
let(:new_commit) { described_class.from_hash(commit.to_hash, project) }
- it 'returns a Commit' do
+ it "returns a Commit" do
expect(new_commit).to be_an_instance_of(described_class)
end
- it 'wraps a Gitlab::Git::Commit' do
+ it "wraps a Gitlab::Git::Commit" do
expect(new_commit.raw).to be_an_instance_of(Gitlab::Git::Commit)
end
- it 'stores the correct commit fields' do
+ it "stores the correct commit fields" do
expect(new_commit.id).to eq(commit.id)
expect(new_commit.message).to eq(commit.message)
end
end
- describe '#work_in_progress?' do
- ['squash! ', 'fixup! ', 'wip: ', 'WIP: ', '[WIP] '].each do |wip_prefix|
+ describe "#work_in_progress?" do
+ ["squash! ", "fixup! ", "wip: ", "WIP: ", "[WIP] "].each do |wip_prefix|
it "detects the '#{wip_prefix}' prefix" do
commit.message = "#{wip_prefix}#{commit.message}"
@@ -606,32 +606,32 @@ eos
end
end
- describe '.valid_hash?' do
- it 'checks hash contents' do
- expect(described_class.valid_hash?('abcdef01239ABCDEF')).to be true
+ describe ".valid_hash?" do
+ it "checks hash contents" do
+ expect(described_class.valid_hash?("abcdef01239ABCDEF")).to be true
expect(described_class.valid_hash?("abcdef01239ABCD\nEF")).to be false
- expect(described_class.valid_hash?(' abcdef01239ABCDEF ')).to be false
- expect(described_class.valid_hash?('Gabcdef01239ABCDEF')).to be false
- expect(described_class.valid_hash?('gabcdef01239ABCDEF')).to be false
- expect(described_class.valid_hash?('-abcdef01239ABCDEF')).to be false
+ expect(described_class.valid_hash?(" abcdef01239ABCDEF ")).to be false
+ expect(described_class.valid_hash?("Gabcdef01239ABCDEF")).to be false
+ expect(described_class.valid_hash?("gabcdef01239ABCDEF")).to be false
+ expect(described_class.valid_hash?("-abcdef01239ABCDEF")).to be false
end
- it 'checks hash length' do
- expect(described_class.valid_hash?('a' * 6)).to be false
- expect(described_class.valid_hash?('a' * 7)).to be true
- expect(described_class.valid_hash?('a' * 40)).to be true
- expect(described_class.valid_hash?('a' * 41)).to be false
+ it "checks hash length" do
+ expect(described_class.valid_hash?("a" * 6)).to be false
+ expect(described_class.valid_hash?("a" * 7)).to be true
+ expect(described_class.valid_hash?("a" * 40)).to be true
+ expect(described_class.valid_hash?("a" * 41)).to be false
end
end
- describe '#merge_requests' do
+ describe "#merge_requests" do
let!(:project) { create(:project, :repository) }
- let!(:merge_request1) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'feature') }
- let!(:merge_request2) { create(:merge_request, source_project: project, source_branch: 'merged-target', target_branch: 'feature') }
+ let!(:merge_request1) { create(:merge_request, source_project: project, source_branch: "master", target_branch: "feature") }
+ let!(:merge_request2) { create(:merge_request, source_project: project, source_branch: "merged-target", target_branch: "feature") }
let(:commit1) { merge_request1.merge_request_diff.commits.last }
let(:commit2) { merge_request1.merge_request_diff.commits.first }
- it 'returns merge_requests that introduced that commit' do
+ it "returns merge_requests that introduced that commit" do
expect(commit1.merge_requests).to contain_exactly(merge_request1, merge_request2)
expect(commit2.merge_requests).to contain_exactly(merge_request1)
end
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb
index 8b7c88805c1..266f0921f07 100644
--- a/spec/models/commit_status_spec.rb
+++ b/spec/models/commit_status_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CommitStatus do
set(:project) { create(:project, :repository) }
@@ -7,13 +7,13 @@ describe CommitStatus do
create(:ci_pipeline, project: project, sha: project.commit.id)
end
- let(:commit_status) { create_status(stage: 'test') }
+ let(:commit_status) { create_status(stage: "test") }
def create_status(**opts)
create(:commit_status, pipeline: pipeline, **opts)
end
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
it { is_expected.to belong_to(:pipeline) }
it { is_expected.to belong_to(:user) }
@@ -21,7 +21,7 @@ describe CommitStatus do
it { is_expected.to belong_to(:auto_canceled_by) }
it { is_expected.to validate_presence_of(:name) }
- it { is_expected.to validate_inclusion_of(:status).in_array(%w(pending running failed success canceled)) }
+ it { is_expected.to validate_inclusion_of(:status).in_array(%w[pending running failed success canceled]) }
it { is_expected.to delegate_method(:sha).to(:pipeline) }
it { is_expected.to delegate_method(:short_sha).to(:pipeline) }
@@ -31,7 +31,7 @@ describe CommitStatus do
it { is_expected.to respond_to :running? }
it { is_expected.to respond_to :pending? }
- describe '#author' do
+ describe "#author" do
subject { commit_status.author }
before do
@@ -41,20 +41,20 @@ describe CommitStatus do
it { is_expected.to eq(commit_status.user) }
end
- describe 'status state machine' do
+ describe "status state machine" do
let!(:commit_status) { create(:commit_status, :running, project: project) }
- it 'invalidates the cache after a transition' do
+ it "invalidates the cache after a transition" do
expect(ExpireJobCacheWorker).to receive(:perform_async).with(commit_status.id)
commit_status.success!
end
end
- describe '#started?' do
+ describe "#started?" do
subject { commit_status.started? }
- context 'without started_at' do
+ context "without started_at" do
before do
commit_status.started_at = nil
end
@@ -83,7 +83,7 @@ describe CommitStatus do
end
end
- describe '#active?' do
+ describe "#active?" do
subject { commit_status.active? }
%w[pending running].each do |state|
@@ -107,7 +107,7 @@ describe CommitStatus do
end
end
- describe '#complete?' do
+ describe "#complete?" do
subject { commit_status.complete? }
%w[success failed canceled].each do |state|
@@ -131,13 +131,13 @@ describe CommitStatus do
end
end
- describe '#cancel' do
+ describe "#cancel" do
subject { job.cancel }
- context 'when status is scheduled' do
+ context "when status is scheduled" do
let(:job) { build(:commit_status, :scheduled) }
- it 'updates the status' do
+ it "updates the status" do
subject
expect(job).to be_canceled
@@ -145,38 +145,38 @@ describe CommitStatus do
end
end
- describe '#auto_canceled?' do
+ describe "#auto_canceled?" do
subject { commit_status.auto_canceled? }
- context 'when it is canceled' do
+ context "when it is canceled" do
before do
- commit_status.update(status: 'canceled')
+ commit_status.update(status: "canceled")
end
- context 'when there is auto_canceled_by' do
+ context "when there is auto_canceled_by" do
before do
commit_status.update(auto_canceled_by: create(:ci_empty_pipeline))
end
- it 'is auto canceled' do
+ it "is auto canceled" do
is_expected.to be_truthy
end
end
- context 'when there is no auto_canceled_by' do
- it 'is not auto canceled' do
+ context "when there is no auto_canceled_by" do
+ it "is not auto canceled" do
is_expected.to be_falsey
end
end
end
end
- describe '#duration' do
+ describe "#duration" do
subject { commit_status.duration }
it { is_expected.to eq(120.0) }
- context 'if the building process has not started yet' do
+ context "if the building process has not started yet" do
before do
commit_status.started_at = nil
commit_status.finished_at = nil
@@ -185,7 +185,7 @@ describe CommitStatus do
it { is_expected.to be_nil }
end
- context 'if the building process has started' do
+ context "if the building process has started" do
before do
commit_status.started_at = Time.now - 1.minute
commit_status.finished_at = nil
@@ -196,195 +196,195 @@ describe CommitStatus do
end
end
- describe '.latest' do
+ describe ".latest" do
subject { described_class.latest.order(:id) }
let(:statuses) do
- [create_status(name: 'aa', ref: 'bb', status: 'running', retried: true),
- create_status(name: 'cc', ref: 'cc', status: 'pending', retried: true),
- create_status(name: 'aa', ref: 'cc', status: 'success', retried: true),
- create_status(name: 'cc', ref: 'bb', status: 'success'),
- create_status(name: 'aa', ref: 'bb', status: 'success')]
+ [create_status(name: "aa", ref: "bb", status: "running", retried: true),
+ create_status(name: "cc", ref: "cc", status: "pending", retried: true),
+ create_status(name: "aa", ref: "cc", status: "success", retried: true),
+ create_status(name: "cc", ref: "bb", status: "success"),
+ create_status(name: "aa", ref: "bb", status: "success"),]
end
- it 'returns unique statuses' do
+ it "returns unique statuses" do
is_expected.to eq(statuses.values_at(3, 4))
end
end
- describe '.retried' do
+ describe ".retried" do
subject { described_class.retried.order(:id) }
let(:statuses) do
- [create_status(name: 'aa', ref: 'bb', status: 'running', retried: true),
- create_status(name: 'cc', ref: 'cc', status: 'pending', retried: true),
- create_status(name: 'aa', ref: 'cc', status: 'success', retried: true),
- create_status(name: 'cc', ref: 'bb', status: 'success'),
- create_status(name: 'aa', ref: 'bb', status: 'success')]
+ [create_status(name: "aa", ref: "bb", status: "running", retried: true),
+ create_status(name: "cc", ref: "cc", status: "pending", retried: true),
+ create_status(name: "aa", ref: "cc", status: "success", retried: true),
+ create_status(name: "cc", ref: "bb", status: "success"),
+ create_status(name: "aa", ref: "bb", status: "success"),]
end
- it 'returns unique statuses' do
+ it "returns unique statuses" do
is_expected.to contain_exactly(*statuses.values_at(0, 1, 2))
end
end
- describe '.running_or_pending' do
+ describe ".running_or_pending" do
subject { described_class.running_or_pending.order(:id) }
let(:statuses) do
- [create_status(name: 'aa', ref: 'bb', status: 'running'),
- create_status(name: 'cc', ref: 'cc', status: 'pending'),
- create_status(name: 'aa', ref: nil, status: 'success'),
- create_status(name: 'dd', ref: nil, status: 'failed'),
- create_status(name: 'ee', ref: nil, status: 'canceled')]
+ [create_status(name: "aa", ref: "bb", status: "running"),
+ create_status(name: "cc", ref: "cc", status: "pending"),
+ create_status(name: "aa", ref: nil, status: "success"),
+ create_status(name: "dd", ref: nil, status: "failed"),
+ create_status(name: "ee", ref: nil, status: "canceled"),]
end
- it 'returns statuses that are running or pending' do
+ it "returns statuses that are running or pending" do
is_expected.to contain_exactly(*statuses.values_at(0, 1))
end
end
- describe '.after_stage' do
+ describe ".after_stage" do
subject { described_class.after_stage(0) }
let(:statuses) do
- [create_status(name: 'aa', stage_idx: 0),
- create_status(name: 'cc', stage_idx: 1),
- create_status(name: 'aa', stage_idx: 2)]
+ [create_status(name: "aa", stage_idx: 0),
+ create_status(name: "cc", stage_idx: 1),
+ create_status(name: "aa", stage_idx: 2),]
end
- it 'returns statuses from second and third stage' do
+ it "returns statuses from second and third stage" do
is_expected.to eq(statuses.values_at(1, 2))
end
end
- describe '.exclude_ignored' do
+ describe ".exclude_ignored" do
subject { described_class.exclude_ignored.order(:id) }
let(:statuses) do
- [create_status(when: 'manual', status: 'skipped'),
- create_status(when: 'manual', status: 'success'),
- create_status(when: 'manual', status: 'failed'),
- create_status(when: 'on_failure', status: 'skipped'),
- create_status(when: 'on_failure', status: 'success'),
- create_status(when: 'on_failure', status: 'failed'),
- create_status(allow_failure: true, status: 'success'),
- create_status(allow_failure: true, status: 'failed'),
- create_status(allow_failure: false, status: 'success'),
- create_status(allow_failure: false, status: 'failed'),
- create_status(allow_failure: true, status: 'manual'),
- create_status(allow_failure: false, status: 'manual')]
- end
-
- it 'returns statuses without what we want to ignore' do
+ [create_status(when: "manual", status: "skipped"),
+ create_status(when: "manual", status: "success"),
+ create_status(when: "manual", status: "failed"),
+ create_status(when: "on_failure", status: "skipped"),
+ create_status(when: "on_failure", status: "success"),
+ create_status(when: "on_failure", status: "failed"),
+ create_status(allow_failure: true, status: "success"),
+ create_status(allow_failure: true, status: "failed"),
+ create_status(allow_failure: false, status: "success"),
+ create_status(allow_failure: false, status: "failed"),
+ create_status(allow_failure: true, status: "manual"),
+ create_status(allow_failure: false, status: "manual"),]
+ end
+
+ it "returns statuses without what we want to ignore" do
is_expected.to eq(statuses.values_at(0, 1, 2, 3, 4, 5, 6, 8, 9, 11))
end
end
- describe '.failed_but_allowed' do
+ describe ".failed_but_allowed" do
subject { described_class.failed_but_allowed.order(:id) }
let(:statuses) do
- [create_status(allow_failure: true, status: 'success'),
- create_status(allow_failure: true, status: 'failed'),
- create_status(allow_failure: false, status: 'success'),
- create_status(allow_failure: false, status: 'failed'),
- create_status(allow_failure: true, status: 'canceled'),
- create_status(allow_failure: false, status: 'canceled'),
- create_status(allow_failure: true, status: 'manual'),
- create_status(allow_failure: false, status: 'manual')]
+ [create_status(allow_failure: true, status: "success"),
+ create_status(allow_failure: true, status: "failed"),
+ create_status(allow_failure: false, status: "success"),
+ create_status(allow_failure: false, status: "failed"),
+ create_status(allow_failure: true, status: "canceled"),
+ create_status(allow_failure: false, status: "canceled"),
+ create_status(allow_failure: true, status: "manual"),
+ create_status(allow_failure: false, status: "manual"),]
end
- it 'returns statuses without what we want to ignore' do
+ it "returns statuses without what we want to ignore" do
is_expected.to eq(statuses.values_at(1, 4))
end
end
- describe '.status' do
- context 'when there are multiple statuses present' do
+ describe ".status" do
+ context "when there are multiple statuses present" do
before do
- create_status(status: 'running')
- create_status(status: 'success')
- create_status(allow_failure: true, status: 'failed')
+ create_status(status: "running")
+ create_status(status: "success")
+ create_status(allow_failure: true, status: "failed")
end
- it 'returns a correct compound status' do
- expect(described_class.all.status).to eq 'running'
+ it "returns a correct compound status" do
+ expect(described_class.all.status).to eq "running"
end
end
- context 'when there are only allowed to fail commit statuses present' do
+ context "when there are only allowed to fail commit statuses present" do
before do
- create_status(allow_failure: true, status: 'failed')
+ create_status(allow_failure: true, status: "failed")
end
- it 'returns status that indicates success' do
- expect(described_class.all.status).to eq 'success'
+ it "returns status that indicates success" do
+ expect(described_class.all.status).to eq "success"
end
end
- context 'when using a scope to select latest statuses' do
+ context "when using a scope to select latest statuses" do
before do
- create_status(name: 'test', retried: true, status: 'failed')
- create_status(allow_failure: true, name: 'test', status: 'failed')
+ create_status(name: "test", retried: true, status: "failed")
+ create_status(allow_failure: true, name: "test", status: "failed")
end
- it 'returns status according to the scope' do
- expect(described_class.latest.status).to eq 'success'
+ it "returns status according to the scope" do
+ expect(described_class.latest.status).to eq "success"
end
end
end
- describe '#before_sha' do
+ describe "#before_sha" do
subject { commit_status.before_sha }
- context 'when no before_sha is set for pipeline' do
+ context "when no before_sha is set for pipeline" do
before do
pipeline.before_sha = nil
end
- it 'returns blank sha' do
+ it "returns blank sha" do
is_expected.to eq(Gitlab::Git::BLANK_SHA)
end
end
- context 'for before_sha set for pipeline' do
- let(:value) { '1234' }
+ context "for before_sha set for pipeline" do
+ let(:value) { "1234" }
before do
pipeline.before_sha = value
end
- it 'returns the set value' do
+ it "returns the set value" do
is_expected.to eq(value)
end
end
end
- describe '#commit' do
- it 'returns commit pipeline has been created for' do
+ describe "#commit" do
+ it "returns commit pipeline has been created for" do
expect(commit_status.commit).to eq project.commit
end
end
- describe '#group_name' do
+ describe "#group_name" do
subject { commit_status.group_name }
tests = {
- 'rspec:windows' => 'rspec:windows',
- 'rspec:windows 0' => 'rspec:windows 0',
- 'rspec:windows 0 test' => 'rspec:windows 0 test',
- 'rspec:windows 0 1' => 'rspec:windows',
- 'rspec:windows 0 1 name' => 'rspec:windows name',
- 'rspec:windows 0/1' => 'rspec:windows',
- 'rspec:windows 0/1 name' => 'rspec:windows name',
- 'rspec:windows 0:1' => 'rspec:windows',
- 'rspec:windows 0:1 name' => 'rspec:windows name',
- 'rspec:windows 10000 20000' => 'rspec:windows',
- 'rspec:windows 0 : / 1' => 'rspec:windows',
- 'rspec:windows 0 : / 1 name' => 'rspec:windows name',
- '0 1 name ruby' => 'name ruby',
- '0 :/ 1 name ruby' => 'name ruby'
+ "rspec:windows" => "rspec:windows",
+ "rspec:windows 0" => "rspec:windows 0",
+ "rspec:windows 0 test" => "rspec:windows 0 test",
+ "rspec:windows 0 1" => "rspec:windows",
+ "rspec:windows 0 1 name" => "rspec:windows name",
+ "rspec:windows 0/1" => "rspec:windows",
+ "rspec:windows 0/1 name" => "rspec:windows name",
+ "rspec:windows 0:1" => "rspec:windows",
+ "rspec:windows 0:1 name" => "rspec:windows name",
+ "rspec:windows 10000 20000" => "rspec:windows",
+ "rspec:windows 0 : / 1" => "rspec:windows",
+ "rspec:windows 0 : / 1 name" => "rspec:windows name",
+ "0 1 name ruby" => "name ruby",
+ "0 :/ 1 name ruby" => "name ruby",
}
tests.each do |name, group_name|
@@ -396,24 +396,24 @@ describe CommitStatus do
end
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
let(:user) { create(:user) }
- it 'returns a detailed status' do
+ it "returns a detailed status" do
expect(commit_status.detailed_status(user))
.to be_a Gitlab::Ci::Status::Success
end
end
- describe '#sortable_name' do
+ describe "#sortable_name" do
tests = {
- 'karma' => ['karma'],
- 'karma 0 20' => ['karma ', 0, ' ', 20],
- 'karma 10 20' => ['karma ', 10, ' ', 20],
- 'karma 50:100' => ['karma ', 50, ':', 100],
- 'karma 1.10' => ['karma ', 1, '.', 10],
- 'karma 1.5.1' => ['karma ', 1, '.', 5, '.', 1],
- 'karma 1 a' => ['karma ', 1, ' a']
+ "karma" => ["karma"],
+ "karma 0 20" => ["karma ", 0, " ", 20],
+ "karma 10 20" => ["karma ", 10, " ", 20],
+ "karma 50:100" => ["karma ", 50, ":", 100],
+ "karma 1.10" => ["karma ", 1, ".", 10],
+ "karma 1.5.1" => ["karma ", 1, ".", 5, ".", 1],
+ "karma 1 a" => ["karma ", 1, " a"],
}
tests.each do |name, sortable_name|
@@ -424,7 +424,7 @@ describe CommitStatus do
end
end
- describe '#locking_enabled?' do
+ describe "#locking_enabled?" do
before do
commit_status.lock_version = 100
end
@@ -460,7 +460,7 @@ describe CommitStatus do
end
end
- describe 'set failure_reason when drop' do
+ describe "set failure_reason when drop" do
let(:commit_status) { create(:commit_status, :created) }
subject do
@@ -468,46 +468,46 @@ describe CommitStatus do
commit_status
end
- context 'when failure_reason is nil' do
+ context "when failure_reason is nil" do
let(:reason) { }
it { is_expected.to be_unknown_failure }
end
- context 'when failure_reason is script_failure' do
+ context "when failure_reason is script_failure" do
let(:reason) { :script_failure }
it { is_expected.to be_script_failure }
end
end
- describe 'ensure stage assignment' do
- context 'when commit status has a stage_id assigned' do
+ describe "ensure stage assignment" do
+ context "when commit status has a stage_id assigned" do
let!(:stage) do
create(:ci_stage_entity, project: project, pipeline: pipeline)
end
let(:commit_status) do
- create(:commit_status, stage_id: stage.id, name: 'rspec', stage: 'test')
+ create(:commit_status, stage_id: stage.id, name: "rspec", stage: "test")
end
- it 'does not create a new stage' do
+ it "does not create a new stage" do
expect { commit_status }.not_to change { Ci::Stage.count }
expect(commit_status.stage_id).to eq stage.id
end
end
- context 'when commit status does not have a stage_id assigned' do
+ context "when commit status does not have a stage_id assigned" do
let(:commit_status) do
- create(:commit_status, name: 'rspec', stage: 'test', status: :success)
+ create(:commit_status, name: "rspec", stage: "test", status: :success)
end
let(:stage) { Ci::Stage.first }
- it 'creates a new stage' do
+ it "creates a new stage" do
expect { commit_status }.to change { Ci::Stage.count }.by(1)
- expect(stage.name).to eq 'test'
+ expect(stage.name).to eq "test"
expect(stage.project).to eq commit_status.project
expect(stage.pipeline).to eq commit_status.pipeline
expect(stage.status).to eq commit_status.status
@@ -515,22 +515,22 @@ describe CommitStatus do
end
end
- context 'when commit status does not have stage but it exists' do
+ context "when commit status does not have stage but it exists" do
let!(:stage) do
create(:ci_stage_entity, project: project,
pipeline: pipeline,
- name: 'test')
+ name: "test")
end
let(:commit_status) do
create(:commit_status, project: project,
pipeline: pipeline,
- name: 'rspec',
- stage: 'test',
+ name: "rspec",
+ stage: "test",
status: :success)
end
- it 'uses existing stage' do
+ it "uses existing stage" do
expect { commit_status }.not_to change { Ci::Stage.count }
expect(commit_status.stage_id).to eq stage.id
@@ -538,57 +538,57 @@ describe CommitStatus do
end
end
- context 'when commit status is being imported' do
+ context "when commit status is being imported" do
let(:commit_status) do
- create(:commit_status, name: 'rspec', stage: 'test', importing: true)
+ create(:commit_status, name: "rspec", stage: "test", importing: true)
end
- it 'does not create a new stage' do
+ it "does not create a new stage" do
expect { commit_status }.not_to change { Ci::Stage.count }
expect(commit_status.stage_id).not_to be_present
end
end
end
- describe '#enqueue' do
+ describe "#enqueue" do
let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) }
before do
allow(Time).to receive(:now).and_return(current_time)
end
- shared_examples 'commit status enqueued' do
- it 'sets queued_at value when enqueued' do
+ shared_examples "commit status enqueued" do
+ it "sets queued_at value when enqueued" do
expect { commit_status.enqueue }.to change { commit_status.reload.queued_at }.from(nil).to(current_time)
end
end
- context 'when initial state is :created' do
+ context "when initial state is :created" do
let(:commit_status) { create(:commit_status, :created) }
- it_behaves_like 'commit status enqueued'
+ it_behaves_like "commit status enqueued"
end
- context 'when initial state is :skipped' do
+ context "when initial state is :skipped" do
let(:commit_status) { create(:commit_status, :skipped) }
- it_behaves_like 'commit status enqueued'
+ it_behaves_like "commit status enqueued"
end
- context 'when initial state is :manual' do
+ context "when initial state is :manual" do
let(:commit_status) { create(:commit_status, :manual) }
- it_behaves_like 'commit status enqueued'
+ it_behaves_like "commit status enqueued"
end
- context 'when initial state is :scheduled' do
+ context "when initial state is :scheduled" do
let(:commit_status) { create(:commit_status, :scheduled) }
- it_behaves_like 'commit status enqueued'
+ it_behaves_like "commit status enqueued"
end
end
- describe '#present' do
+ describe "#present" do
subject { commit_status.present }
it { is_expected.to be_a(CommitStatusPresenter) }
diff --git a/spec/models/compare_spec.rb b/spec/models/compare_spec.rb
index 0bc3ee014e6..832eb9cbfed 100644
--- a/spec/models/compare_spec.rb
+++ b/spec/models/compare_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Compare do
include RepoHelpers
@@ -13,32 +13,32 @@ describe Compare do
subject { described_class.new(raw_compare, project) }
- describe '#start_commit' do
- it 'returns raw compare base commit' do
+ describe "#start_commit" do
+ it "returns raw compare base commit" do
expect(subject.start_commit.id).to eq(start_commit.id)
end
- it 'returns nil if compare base commit is nil' do
+ it "returns nil if compare base commit is nil" do
expect(raw_compare).to receive(:base).and_return(nil)
expect(subject.start_commit).to eq(nil)
end
end
- describe '#commit' do
- it 'returns raw compare head commit' do
+ describe "#commit" do
+ it "returns raw compare head commit" do
expect(subject.commit.id).to eq(head_commit.id)
end
- it 'returns nil if compare head commit is nil' do
+ it "returns nil if compare head commit is nil" do
expect(raw_compare).to receive(:head).and_return(nil)
expect(subject.commit).to eq(nil)
end
end
- describe '#base_commit_sha' do
- it 'returns @base_sha if it is present' do
+ describe "#base_commit_sha" do
+ it "returns @base_sha if it is present" do
expect(project).not_to receive(:merge_base_commit)
sha = double
@@ -47,7 +47,7 @@ describe Compare do
expect(service.base_commit_sha).to eq(sha)
end
- it 'fetches merge base SHA from repo when @base_sha is nil' do
+ it "fetches merge base SHA from repo when @base_sha is nil" do
expect(project).to receive(:merge_base_commit)
.with(start_commit.id, head_commit.id)
.once
@@ -57,7 +57,7 @@ describe Compare do
.to eq(project.repository.merge_base(start_commit.id, head_commit.id))
end
- it 'is memoized on first call' do
+ it "is memoized on first call" do
expect(project).to receive(:merge_base_commit)
.with(start_commit.id, head_commit.id)
.once
@@ -66,57 +66,51 @@ describe Compare do
3.times { subject.base_commit_sha }
end
- it 'returns nil if there is no start_commit' do
+ it "returns nil if there is no start_commit" do
expect(subject).to receive(:start_commit).and_return(nil)
expect(subject.base_commit_sha).to eq(nil)
end
- it 'returns nil if there is no head commit' do
+ it "returns nil if there is no head commit" do
expect(subject).to receive(:head_commit).and_return(nil)
expect(subject.base_commit_sha).to eq(nil)
end
end
- describe '#diff_refs' do
- it 'uses base_commit_sha sha as base_sha' do
+ describe "#diff_refs" do
+ it "uses base_commit_sha sha as base_sha" do
expect(subject.diff_refs.base_sha).to eq(subject.base_commit_sha)
end
- it 'uses start_commit sha as start_sha' do
+ it "uses start_commit sha as start_sha" do
expect(subject.diff_refs.start_sha).to eq(start_commit.id)
end
- it 'uses commit sha as head sha' do
+ it "uses commit sha as head sha" do
expect(subject.diff_refs.head_sha).to eq(head_commit.id)
end
end
- describe '#modified_paths' do
- context 'changes are present' do
+ describe "#modified_paths" do
+ context "changes are present" do
let(:raw_compare) do
Gitlab::Git::Compare.new(
- project.repository.raw_repository, 'before-create-delete-modify-move', 'after-create-delete-modify-move'
+ project.repository.raw_repository, "before-create-delete-modify-move", "after-create-delete-modify-move"
)
end
- it 'returns affected file paths, without duplication' do
- expect(subject.modified_paths).to contain_exactly(*%w{
- foo/for_move.txt
- foo/bar/for_move.txt
- foo/for_create.txt
- foo/for_delete.txt
- foo/for_edit.txt
- })
+ it "returns affected file paths, without duplication" do
+ expect(subject.modified_paths).to contain_exactly("foo/for_move.txt", "foo/bar/for_move.txt", "foo/for_create.txt", "foo/for_delete.txt", "foo/for_edit.txt")
end
end
- context 'changes are absent' do
+ context "changes are absent" do
let(:start_commit) { sample_commit }
let(:head_commit) { sample_commit }
- it 'returns empty array' do
+ it "returns empty array" do
expect(subject.modified_paths).to eq([])
end
end
diff --git a/spec/models/concerns/access_requestable_spec.rb b/spec/models/concerns/access_requestable_spec.rb
index 04d6cfa2c02..461d7a17de9 100644
--- a/spec/models/concerns/access_requestable_spec.rb
+++ b/spec/models/concerns/access_requestable_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe AccessRequestable do
- describe 'Group' do
- describe '#request_access' do
+ describe "Group" do
+ describe "#request_access" do
let(:group) { create(:group, :public, :access_requestable) }
let(:user) { create(:user) }
@@ -10,7 +10,7 @@ describe AccessRequestable do
it { expect(group.request_access(user).user).to eq(user) }
end
- describe '#access_requested?' do
+ describe "#access_requested?" do
let(:group) { create(:group, :public, :access_requestable) }
let(:user) { create(:user) }
@@ -22,15 +22,15 @@ describe AccessRequestable do
end
end
- describe 'Project' do
- describe '#request_access' do
+ describe "Project" do
+ describe "#request_access" do
let(:project) { create(:project, :public, :access_requestable) }
let(:user) { create(:user) }
it { expect(project.request_access(user)).to be_a(ProjectMember) }
end
- describe '#access_requested?' do
+ describe "#access_requested?" do
let(:project) { create(:project, :public, :access_requestable) }
let(:user) { create(:user) }
diff --git a/spec/models/concerns/avatarable_spec.rb b/spec/models/concerns/avatarable_spec.rb
index 1ea7f2b9985..245625b80bd 100644
--- a/spec/models/concerns/avatarable_spec.rb
+++ b/spec/models/concerns/avatarable_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Avatarable do
let(:project) { create(:project, :with_avatar) }
let(:gitlab_host) { "https://gitlab.example.com" }
let(:relative_url_root) { "/gitlab" }
- let(:asset_host) { 'https://gitlab-assets.example.com' }
+ let(:asset_host) { "https://gitlab-assets.example.com" }
before do
stub_config_setting(base_url: gitlab_host)
stub_config_setting(relative_url_root: relative_url_root)
end
- describe '#update' do
+ describe "#update" do
let(:validator) { project._validators[:avatar].detect { |v| v.is_a?(FileSizeValidator) } }
- context 'when avatar changed' do
- it 'validates the file size' do
+ context "when avatar changed" do
+ it "validates the file size" do
expect(validator).to receive(:validate_each).and_call_original
- project.update(avatar: 'uploads/avatar.png')
+ project.update(avatar: "uploads/avatar.png")
end
end
- context 'when avatar was not changed' do
- it 'skips validation of file size' do
+ context "when avatar was not changed" do
+ it "skips validation of file size" do
expect(validator).not_to receive(:validate_each)
- project.update(name: 'Hello world')
+ project.update(name: "Hello world")
end
end
end
- describe '#avatar_path' do
- context 'with caching enabled', :request_store do
+ describe "#avatar_path" do
+ context "with caching enabled", :request_store do
let!(:avatar_path) { [relative_url_root, project.avatar.local_url].join }
let!(:avatar_url) { [gitlab_host, relative_url_root, project.avatar.local_url].join }
- it 'only calls local_url once' do
+ it "only calls local_url once" do
expect(project.avatar).to receive(:local_url).once.and_call_original
2.times do
@@ -45,21 +45,21 @@ describe Avatarable do
end
end
- it 'calls local_url twice for path and URLs' do
+ it "calls local_url twice for path and URLs" do
expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original
expect(project.avatar_path(only_path: true)).to eq(avatar_path)
expect(project.avatar_path(only_path: false)).to eq(avatar_url)
end
- it 'calls local_url twice for different sizes' do
+ it "calls local_url twice for different sizes" do
expect(project.avatar).to receive(:local_url).exactly(2).times.and_call_original
expect(project.avatar_path).to eq(avatar_path)
expect(project.avatar_path(size: 40)).to eq(avatar_path + "?width=40")
end
- it 'handles unpersisted objects' do
+ it "handles unpersisted objects" do
new_project = build(:project, :with_avatar)
path = [relative_url_root, new_project.avatar.local_url].join
expect(new_project.avatar).to receive(:local_url).exactly(2).times.and_call_original
@@ -96,11 +96,11 @@ describe Avatarable do
let(:avatar_path) { (avatar_path_prefix + [project.avatar.local_url]).join }
- it 'returns the expected avatar path' do
+ it "returns the expected avatar path" do
expect(project.avatar_path(only_path: only_path)).to eq(avatar_path)
end
- it 'returns the expected avatar path with width parameter' do
+ it "returns the expected avatar path with width parameter" do
expect(project.avatar_path(only_path: only_path, size: 128)).to eq(avatar_path + "?width=128")
end
@@ -111,7 +111,7 @@ describe Avatarable do
project.avatar.migrate!(ObjectStorage::Store::REMOTE)
end
- it 'returns the expected avatar path' do
+ it "returns the expected avatar path" do
expect(project.avatar_url(only_path: only_path)).to eq(avatar_path)
end
end
diff --git a/spec/models/concerns/awardable_spec.rb b/spec/models/concerns/awardable_spec.rb
index 5713106418d..54623244b7d 100644
--- a/spec/models/concerns/awardable_spec.rb
+++ b/spec/models/concerns/awardable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Awardable do
let!(:issue) { create(:issue) }
@@ -62,18 +62,18 @@ describe Awardable do
end
end
- describe '#user_can_award?' do
+ describe "#user_can_award?" do
let(:user) { create(:user) }
before do
issue.project.add_guest(user)
end
- it 'is truthy when the user is allowed to award emoji' do
+ it "is truthy when the user is allowed to award emoji" do
expect(issue.user_can_award?(user)).to be_truthy
end
- it 'is falsy when the project is archived' do
+ it "is falsy when the project is archived" do
issue.project.update!(archived: true)
expect(issue.user_can_award?(user)).to be_falsy
@@ -90,10 +90,10 @@ describe Awardable do
end
end
- describe 'querying award_emoji on an Awardable' do
+ describe "querying award_emoji on an Awardable" do
let(:issue) { create(:issue) }
- it 'sorts in ascending fashion' do
+ it "sorts in ascending fashion" do
create_list(:award_emoji, 3, awardable: issue)
expect(issue.award_emoji).to eq issue.award_emoji.sort_by(&:id)
diff --git a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
index e5392fe0462..14dced7846e 100644
--- a/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
+++ b/spec/models/concerns/batch_destroy_dependent_associations_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe BatchDestroyDependentAssociations do
class TestProject < ActiveRecord::Base
- self.table_name = 'projects'
+ self.table_name = "projects"
has_many :builds, dependent: :destroy
has_many :notification_settings, as: :source, dependent: :delete_all
@@ -12,21 +12,21 @@ describe BatchDestroyDependentAssociations do
include BatchDestroyDependentAssociations
end
- describe '#dependent_associations_to_destroy' do
+ describe "#dependent_associations_to_destroy" do
set(:project) { TestProject.new }
- it 'returns the right associations' do
+ it "returns the right associations" do
expect(project.dependent_associations_to_destroy.map(&:name)).to match_array([:builds])
end
end
- describe '#destroy_dependent_associations_in_batches' do
+ describe "#destroy_dependent_associations_in_batches" do
set(:project) { create(:project) }
set(:build) { create(:ci_build, project: project) }
set(:notification_setting) { create(:notification_setting, project: project) }
let!(:todos) { create(:todo, project: project) }
- it 'destroys multiple builds' do
+ it "destroys multiple builds" do
create(:ci_build, project: project)
expect(Ci::Build.count).to eq(2)
@@ -36,7 +36,7 @@ describe BatchDestroyDependentAssociations do
expect(Ci::Build.count).to eq(0)
end
- it 'destroys builds in batches' do
+ it "destroys builds in batches" do
expect(project).to receive_message_chain(:builds, :find_each).and_yield(build)
expect(build).to receive(:destroy).and_call_original
@@ -48,7 +48,7 @@ describe BatchDestroyDependentAssociations do
expect(NotificationSetting.count).to eq(User.count)
end
- it 'excludes associations' do
+ it "excludes associations" do
project.destroy_dependent_associations_in_batches(exclude: [:builds])
expect(Ci::Build.count).to eq(1)
diff --git a/spec/models/concerns/blob_language_from_git_attributes_spec.rb b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
index 7f05073b08e..619e3e17498 100644
--- a/spec/models/concerns/blob_language_from_git_attributes_spec.rb
+++ b/spec/models/concerns/blob_language_from_git_attributes_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BlobLanguageFromGitAttributes do
include FakeBlobHelpers
let(:project) { build(:project, :repository) }
- describe '#language_from_gitattributes' do
- subject(:blob) { fake_blob(path: 'file.md') }
+ describe "#language_from_gitattributes" do
+ subject(:blob) { fake_blob(path: "file.md") }
- it 'returns return value from gitattribute' do
- expect(blob.project.repository).to receive(:gitattribute).with(blob.path, 'gitlab-language').and_return('erb?parent=json')
+ it "returns return value from gitattribute" do
+ expect(blob.project.repository).to receive(:gitattribute).with(blob.path, "gitlab-language").and_return("erb?parent=json")
- expect(blob.language_from_gitattributes).to eq('erb?parent=json')
+ expect(blob.language_from_gitattributes).to eq("erb?parent=json")
end
- it 'returns nil if project is absent' do
+ it "returns nil if project is absent" do
allow(blob).to receive(:project).and_return(nil)
expect(blob.language_from_gitattributes).to eq(nil)
diff --git a/spec/models/concerns/blocks_json_serialization_spec.rb b/spec/models/concerns/blocks_json_serialization_spec.rb
index 5906b588d0e..a95d2379696 100644
--- a/spec/models/concerns/blocks_json_serialization_spec.rb
+++ b/spec/models/concerns/blocks_json_serialization_spec.rb
@@ -1,16 +1,16 @@
-require 'rails_helper'
+require "rails_helper"
describe BlocksJsonSerialization do
- DummyModel = Class.new do
+ DummyModel = Class.new {
include BlocksJsonSerialization
- end
+ }
- it 'blocks as_json' do
+ it "blocks as_json" do
expect { DummyModel.new.as_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
- it 'blocks to_json' do
+ it "blocks to_json" do
expect { DummyModel.new.to_json }
.to raise_error(described_class::JsonSerializationError, /DummyModel/)
end
diff --git a/spec/models/concerns/cache_markdown_field_spec.rb b/spec/models/concerns/cache_markdown_field_spec.rb
index 447279f19a8..e89dd5d3fc4 100644
--- a/spec/models/concerns/cache_markdown_field_spec.rb
+++ b/spec/models/concerns/cache_markdown_field_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CacheMarkdownField do
# The minimum necessary ActiveModel to test this concern
@@ -70,10 +70,10 @@ describe CacheMarkdownField do
Class.new(ThingWithMarkdownFields) { add_attr(new_attr) }
end
- let(:markdown) { '`Foo`' }
+ let(:markdown) { "`Foo`" }
let(:html) { '<p dir="auto"><code>Foo</code></p>' }
- let(:updated_markdown) { '`Bar`' }
+ let(:updated_markdown) { "`Bar`" }
let(:updated_html) { '<p dir="auto"><code>Bar</code></p>' }
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
@@ -83,13 +83,13 @@ describe CacheMarkdownField do
stub_commonmark_sourcepos_disabled
end
- describe '.attributes' do
- it 'excludes cache attributes' do
+ describe ".attributes" do
+ it "excludes cache attributes" do
expect(thing.attributes.keys.sort).to eq(%w[bar baz foo])
end
end
- context 'an unchanged markdown field' do
+ context "an unchanged markdown field" do
before do
thing.foo = thing.foo
thing.save
@@ -101,7 +101,7 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'a changed markdown field' do
+ context "a changed markdown field" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version - 1) }
before do
@@ -113,50 +113,50 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'when a markdown field is set repeatedly to an empty string' do
+ context "when a markdown field is set repeatedly to an empty string" do
it do
expect(thing).to receive(:refresh_markdown_cache).once
- thing.foo = ''
+ thing.foo = ""
thing.save
- thing.foo = ''
+ thing.foo = ""
thing.save
end
end
- context 'when a markdown field is set repeatedly to a string which renders as empty html' do
+ context "when a markdown field is set repeatedly to a string which renders as empty html" do
it do
expect(thing).to receive(:refresh_markdown_cache).once
- thing.foo = '[//]: # (This is also a comment.)'
+ thing.foo = "[//]: # (This is also a comment.)"
thing.save
- thing.foo = '[//]: # (This is also a comment.)'
+ thing.foo = "[//]: # (This is also a comment.)"
thing.save
end
end
- context 'when a markdown field and html field are both changed' do
+ context "when a markdown field and html field are both changed" do
it do
expect(thing).not_to receive(:refresh_markdown_cache)
- thing.foo = '_look over there!_'
- thing.foo_html = '<em>look over there!</em>'
+ thing.foo = "_look over there!_"
+ thing.foo_html = "<em>look over there!</em>"
thing.save
end
end
- context 'a non-markdown field changed' do
+ context "a non-markdown field changed" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version - 1) }
before do
- thing.bar = 'OK'
+ thing.bar = "OK"
thing.save
end
- it { expect(thing.bar).to eq('OK') }
+ it { expect(thing.bar).to eq("OK") }
it { expect(thing.foo).to eq(markdown) }
it { expect(thing.foo_html).to eq(html) }
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- context 'version is out of date' do
+ context "version is out of date" do
let(:thing) { ThingWithMarkdownFields.new(foo: updated_markdown, foo_html: html, cached_markdown_version: nil) }
before do
@@ -167,90 +167,90 @@ describe CacheMarkdownField do
it { expect(thing.cached_markdown_version).to eq(cache_version) }
end
- describe '#cached_html_up_to_date?' do
+ describe "#cached_html_up_to_date?" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
subject { thing.cached_html_up_to_date?(:foo) }
- it 'returns false when the version is absent' do
+ it "returns false when the version is absent" do
thing.cached_markdown_version = nil
is_expected.to be_falsy
end
- it 'returns false when the cached version is too old' do
+ it "returns false when the cached version is too old" do
thing.cached_markdown_version = cache_version - 1
is_expected.to be_falsy
end
- it 'returns false when the cached version is in future' do
+ it "returns false when the cached version is in future" do
thing.cached_markdown_version = cache_version + 1
is_expected.to be_falsy
end
- it 'returns false when the local version was bumped' do
+ it "returns false when the local version was bumped" do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
thing.cached_markdown_version = cache_version
is_expected.to be_falsy
end
- it 'returns true when the local version is default' do
+ it "returns true when the local version is default" do
thing.cached_markdown_version = cache_version
is_expected.to be_truthy
end
- it 'returns true when the cached version is just right' do
+ it "returns true when the cached version is just right" do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
thing.cached_markdown_version = cache_version + 2
is_expected.to be_truthy
end
- it 'returns false if markdown has been changed but html has not' do
+ it "returns false if markdown has been changed but html has not" do
thing.foo = updated_html
is_expected.to be_falsy
end
- it 'returns true if markdown has not been changed but html has' do
+ it "returns true if markdown has not been changed but html has" do
thing.foo_html = updated_html
is_expected.to be_truthy
end
- it 'returns true if markdown and html have both been changed' do
+ it "returns true if markdown and html have both been changed" do
thing.foo = updated_markdown
thing.foo_html = updated_html
is_expected.to be_truthy
end
- it 'returns false if the markdown field is set but the html is not' do
+ it "returns false if the markdown field is set but the html is not" do
thing.foo_html = nil
is_expected.to be_falsy
end
end
- describe '#latest_cached_markdown_version' do
+ describe "#latest_cached_markdown_version" do
subject { thing.latest_cached_markdown_version }
- it 'returns default version' do
+ it "returns default version" do
thing.cached_markdown_version = nil
is_expected.to eq(cache_version)
end
end
- describe '#refresh_markdown_cache' do
+ describe "#refresh_markdown_cache" do
before do
thing.foo = updated_markdown
end
- it 'fills all html fields' do
+ it "fills all html fields" do
thing.refresh_markdown_cache
expect(thing.foo_html).to eq(updated_html)
@@ -258,13 +258,13 @@ describe CacheMarkdownField do
expect(thing.baz_html_changed?).to be_truthy
end
- it 'does not save the result' do
+ it "does not save the result" do
expect(thing).not_to receive(:update_columns)
thing.refresh_markdown_cache
end
- it 'updates the markdown cache version' do
+ it "updates the markdown cache version" do
thing.cached_markdown_version = nil
thing.refresh_markdown_cache
@@ -272,14 +272,14 @@ describe CacheMarkdownField do
end
end
- describe '#refresh_markdown_cache!' do
+ describe "#refresh_markdown_cache!" do
let(:thing) { ThingWithMarkdownFields.new(foo: markdown, foo_html: html, cached_markdown_version: cache_version) }
before do
thing.foo = updated_markdown
end
- it 'fills all html fields' do
+ it "fills all html fields" do
thing.refresh_markdown_cache!
expect(thing.foo_html).to eq(updated_html)
@@ -287,14 +287,14 @@ describe CacheMarkdownField do
expect(thing.baz_html_changed?).to be_truthy
end
- it 'skips saving if not persisted' do
+ it "skips saving if not persisted" do
expect(thing).to receive(:persisted?).and_return(false)
expect(thing).not_to receive(:update_columns)
thing.refresh_markdown_cache!
end
- it 'saves the changes using #update_columns' do
+ it "saves the changes using #update_columns" do
expect(thing).to receive(:persisted?).and_return(true)
expect(thing).to receive(:update_columns)
.with("foo_html" => updated_html, "baz_html" => "", "cached_markdown_version" => cache_version)
@@ -303,45 +303,45 @@ describe CacheMarkdownField do
end
end
- describe '#banzai_render_context' do
+ describe "#banzai_render_context" do
subject(:context) { thing.banzai_render_context(:foo) }
- it 'sets project to nil if the object lacks a project' do
+ it "sets project to nil if the object lacks a project" do
is_expected.to have_key(:project)
expect(context[:project]).to be_nil
end
- it 'excludes author if the object lacks an author' do
+ it "excludes author if the object lacks an author" do
is_expected.not_to have_key(:author)
end
- it 'raises if the context for an unrecognised field is requested' do
+ it "raises if the context for an unrecognised field is requested" do
expect { thing.banzai_render_context(:not_found) }.to raise_error(ArgumentError)
end
- it 'includes the pipeline' do
+ it "includes the pipeline" do
baz = thing.banzai_render_context(:baz)
expect(baz[:pipeline]).to eq(:single_line)
end
- it 'returns copies of the context template' do
+ it "returns copies of the context template" do
template = thing.cached_markdown_fields[:baz]
copy = thing.banzai_render_context(:baz)
expect(copy).not_to be(template)
end
- context 'with a project' do
+ context "with a project" do
let(:project) { create(:project, group: create(:group)) }
let(:thing) { thing_subclass(:project).new(foo: markdown, foo_html: html, project: project) }
- it 'sets the project in the context' do
+ it "sets the project in the context" do
is_expected.to have_key(:project)
expect(context[:project]).to eq(project)
end
- it 'invalidates the cache when project changes' do
+ it "invalidates the cache when project changes" do
thing.project = :new_project
allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html)
@@ -353,15 +353,15 @@ describe CacheMarkdownField do
end
end
- context 'with an author' do
+ context "with an author" do
let(:thing) { thing_subclass(:author).new(foo: markdown, foo_html: html, author: :author_value) }
- it 'sets the author in the context' do
+ it "sets the author in the context" do
is_expected.to have_key(:author)
expect(context[:author]).to eq(:author_value)
end
- it 'invalidates the cache when author changes' do
+ it "invalidates the cache when author changes" do
thing.author = :new_author
allow(Banzai::Renderer).to receive(:cacheless_render_field).and_return(updated_html)
diff --git a/spec/models/concerns/cacheable_attributes_spec.rb b/spec/models/concerns/cacheable_attributes_spec.rb
index 43a544cfe26..e8ef745e83d 100644
--- a/spec/models/concerns/cacheable_attributes_spec.rb
+++ b/spec/models/concerns/cacheable_attributes_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CacheableAttributes do
let(:minimal_test_class) do
@@ -9,15 +9,15 @@ describe CacheableAttributes do
include CacheableAttributes
def self.name
- 'TestClass'
+ "TestClass"
end
def self.first
- @_first ||= new('foo' => 'a')
+ @_first ||= new("foo" => "a")
end
def self.last
- @_last ||= new('foo' => 'a', 'bar' => 'b')
+ @_last ||= new("foo" => "a", "bar" => "b")
end
def self.column_names
@@ -32,20 +32,20 @@ describe CacheableAttributes do
end
end
- shared_context 'with defaults' do
+ shared_context "with defaults" do
before do
minimal_test_class.define_singleton_method(:defaults) do
- { foo: 'a', bar: 'b', baz: 'c' }
+ {foo: "a", bar: "b", baz: "c"}
end
end
end
- describe '.current_without_cache' do
- it 'defaults to last' do
+ describe ".current_without_cache" do
+ it "defaults to last" do
expect(minimal_test_class.current_without_cache).to eq(minimal_test_class.last)
end
- it 'can be overridden' do
+ it "can be overridden" do
minimal_test_class.define_singleton_method(:current_without_cache) do
first
end
@@ -54,45 +54,45 @@ describe CacheableAttributes do
end
end
- describe '.cache_key' do
- it 'excludes cache attributes' do
+ describe ".cache_key" do
+ it "excludes cache attributes" do
expect(minimal_test_class.cache_key).to eq("TestClass:#{Gitlab::VERSION}:#{Rails.version}")
end
end
- describe '.defaults' do
- it 'defaults to {}' do
+ describe ".defaults" do
+ it "defaults to {}" do
expect(minimal_test_class.defaults).to eq({})
end
- context 'with defaults defined' do
- include_context 'with defaults'
+ context "with defaults defined" do
+ include_context "with defaults"
- it 'can be overridden' do
- expect(minimal_test_class.defaults).to eq({ foo: 'a', bar: 'b', baz: 'c' })
+ it "can be overridden" do
+ expect(minimal_test_class.defaults).to eq({foo: "a", bar: "b", baz: "c"})
end
end
end
- describe '.build_from_defaults' do
- include_context 'with defaults'
+ describe ".build_from_defaults" do
+ include_context "with defaults"
- context 'without any attributes given' do
- it 'intializes a new object with the defaults' do
+ context "without any attributes given" do
+ it "intializes a new object with the defaults" do
expect(minimal_test_class.build_from_defaults.attributes).to eq(minimal_test_class.defaults.stringify_keys)
end
end
- context 'with attributes given' do
- it 'intializes a new object with the given attributes merged into the defaults' do
- expect(minimal_test_class.build_from_defaults(foo: 'd').attributes['foo']).to eq('d')
+ context "with attributes given" do
+ it "intializes a new object with the given attributes merged into the defaults" do
+ expect(minimal_test_class.build_from_defaults(foo: "d").attributes["foo"]).to eq("d")
end
end
- describe 'edge cases on concrete implementations' do
- describe '.build_from_defaults' do
- context 'without any attributes given' do
- it 'intializes all attributes even if they are nil' do
+ describe "edge cases on concrete implementations" do
+ describe ".build_from_defaults" do
+ context "without any attributes given" do
+ it "intializes all attributes even if they are nil" do
record = ApplicationSetting.build_from_defaults
expect(record).not_to be_persisted
@@ -103,31 +103,31 @@ describe CacheableAttributes do
end
end
- describe '.current', :use_clean_rails_memory_store_caching do
- context 'redis unavailable' do
+ describe ".current", :use_clean_rails_memory_store_caching do
+ context "redis unavailable" do
before do
allow(minimal_test_class).to receive(:last).and_return(:last)
expect(Rails.cache).to receive(:read).with(minimal_test_class.cache_key).and_raise(Redis::BaseError)
end
- context 'in production environment' do
+ context "in production environment" do
before do
expect(Rails.env).to receive(:production?).and_return(true)
end
- it 'returns an uncached record and logs a warning' do
+ it "returns an uncached record and logs a warning" do
expect(Rails.logger).to receive(:warn).with("Cached record for TestClass couldn't be loaded, falling back to uncached record: Redis::BaseError")
expect(minimal_test_class.current).to eq(:last)
end
end
- context 'in other environments' do
+ context "in other environments" do
before do
expect(Rails.env).to receive(:production?).and_return(false)
end
- it 'returns an uncached record and logs a warning' do
+ it "returns an uncached record and logs a warning" do
expect(Rails.logger).not_to receive(:warn)
expect { minimal_test_class.current }.to raise_error(Redis::BaseError)
@@ -135,8 +135,8 @@ describe CacheableAttributes do
end
end
- context 'when a record is not yet present' do
- it 'does not cache nil object' do
+ context "when a record is not yet present" do
+ it "does not cache nil object" do
# when missing settings a nil object is returned, but not cached
allow(ApplicationSetting).to receive(:current_without_cache).twice.and_return(nil)
@@ -144,7 +144,7 @@ describe CacheableAttributes do
expect(Rails.cache.exist?(ApplicationSetting.cache_key)).to be(false)
end
- it 'caches non-nil object' do
+ it "caches non-nil object" do
create(:application_setting)
expect(ApplicationSetting.current).to eq(ApplicationSetting.last)
@@ -157,13 +157,13 @@ describe CacheableAttributes do
end
end
- describe 'edge cases' do
- describe 'caching behavior', :use_clean_rails_memory_store_caching do
+ describe "edge cases" do
+ describe "caching behavior", :use_clean_rails_memory_store_caching do
before do
stub_commonmark_sourcepos_disabled
end
- it 'retrieves upload fields properly' do
+ it "retrieves upload fields properly" do
ar_record = create(:appearance, :with_logo)
ar_record.cache!
@@ -171,22 +171,22 @@ describe CacheableAttributes do
expect(cache_record).to be_persisted
expect(cache_record.logo).to be_an(AttachmentUploader)
- expect(cache_record.logo.url).to end_with('/dk.png')
+ expect(cache_record.logo.url).to end_with("/dk.png")
end
- it 'retrieves markdown fields properly' do
- ar_record = create(:appearance, description: '**Hello**')
+ it "retrieves markdown fields properly" do
+ ar_record = create(:appearance, description: "**Hello**")
ar_record.cache!
cache_record = Appearance.current
- expect(cache_record.description).to eq('**Hello**')
+ expect(cache_record.description).to eq("**Hello**")
expect(cache_record.description_html).to eq('<p dir="auto"><strong>Hello</strong></p>')
end
end
end
- it 'uses RequestStore in addition to Rails.cache', :request_store do
+ it "uses RequestStore in addition to Rails.cache", :request_store do
# Warm up the cache
create(:application_setting).cache!
@@ -196,39 +196,39 @@ describe CacheableAttributes do
end
end
- describe '.cached', :use_clean_rails_memory_store_caching do
- context 'when cache is cold' do
- it 'returns nil' do
+ describe ".cached", :use_clean_rails_memory_store_caching do
+ context "when cache is cold" do
+ it "returns nil" do
expect(minimal_test_class.cached).to be_nil
end
end
- context 'when cached is warm' do
+ context "when cached is warm" do
before do
# Warm up the cache
create(:appearance).cache!
end
- it 'retrieves the record from cache' do
+ it "retrieves the record from cache" do
expect(ActiveRecord::QueryRecorder.new { Appearance.cached }.count).to eq(0)
expect(Appearance.cached).to eq(Appearance.current_without_cache)
end
end
end
- describe '#cache!', :use_clean_rails_memory_store_caching do
+ describe "#cache!", :use_clean_rails_memory_store_caching do
let(:record) { create(:appearance) }
- it 'caches the attributes' do
+ it "caches the attributes" do
record.cache!
expect(Rails.cache.read(Appearance.cache_key)).to eq(record)
end
- describe 'edge cases' do
+ describe "edge cases" do
let(:record) { create(:appearance) }
- it 'caches the attributes' do
+ it "caches the attributes" do
record.cache!
expect(Rails.cache.read(Appearance.cache_key)).to eq(record)
diff --git a/spec/models/concerns/case_sensitivity_spec.rb b/spec/models/concerns/case_sensitivity_spec.rb
index 1bf6c9b3404..98d9593f7a2 100644
--- a/spec/models/concerns/case_sensitivity_spec.rb
+++ b/spec/models/concerns/case_sensitivity_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe CaseSensitivity do
- describe '.iwhere' do
+ describe ".iwhere" do
let(:connection) { ActiveRecord::Base.connection }
let(:model) do
Class.new(ActiveRecord::Base) do
include CaseSensitivity
- self.table_name = 'namespaces'
+ self.table_name = "namespaces"
end
end
- let!(:model_1) { model.create(path: 'mOdEl-1', name: 'mOdEl 1') }
- let!(:model_2) { model.create(path: 'mOdEl-2', name: 'mOdEl 2') }
+ let!(:model_1) { model.create(path: "mOdEl-1", name: "mOdEl 1") }
+ let!(:model_2) { model.create(path: "mOdEl-2", name: "mOdEl 2") }
- it 'finds a single instance by a single attribute regardless of case' do
- expect(model.iwhere(path: 'MODEL-1')).to contain_exactly(model_1)
+ it "finds a single instance by a single attribute regardless of case" do
+ expect(model.iwhere(path: "MODEL-1")).to contain_exactly(model_1)
end
- it 'finds multiple instances by a single attribute regardless of case' do
- expect(model.iwhere(path: %w(MODEL-1 model-2))).to contain_exactly(model_1, model_2)
+ it "finds multiple instances by a single attribute regardless of case" do
+ expect(model.iwhere(path: %w[MODEL-1 model-2])).to contain_exactly(model_1, model_2)
end
- it 'finds instances by multiple attributes' do
- expect(model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1'))
+ it "finds instances by multiple attributes" do
+ expect(model.iwhere(path: %w[MODEL-1 model-2], name: "model 1"))
.to contain_exactly(model_1)
end
# Using `mysql` & `postgresql` metadata-tags here because both adapters build
# the query slightly differently
- context 'for MySQL', :mysql do
- it 'builds a simple query' do
- query = model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1').to_sql
+ context "for MySQL", :mysql do
+ it "builds a simple query" do
+ query = model.iwhere(path: %w[MODEL-1 model-2], name: "model 1").to_sql
expected_query = <<~QRY.strip
- SELECT `namespaces`.* FROM `namespaces` WHERE (`namespaces`.`path` IN ('MODEL-1', 'model-2')) AND (`namespaces`.`name` = 'model 1')
+ SELECT `namespaces`.* FROM `namespaces` WHERE (`namespaces`.`path` IN ('MODEL-1', 'model-2')) AND (`namespaces`.`name` = 'model 1')
QRY
expect(query).to eq(expected_query)
end
end
- context 'for PostgreSQL', :postgresql do
- it 'builds a query using LOWER' do
- query = model.iwhere(path: %w(MODEL-1 model-2), name: 'model 1').to_sql
+ context "for PostgreSQL", :postgresql do
+ it "builds a query using LOWER" do
+ query = model.iwhere(path: %w[MODEL-1 model-2], name: "model 1").to_sql
expected_query = <<~QRY.strip
- SELECT \"namespaces\".* FROM \"namespaces\" WHERE (LOWER(\"namespaces\".\"path\") IN (LOWER('MODEL-1'), LOWER('model-2'))) AND (LOWER(\"namespaces\".\"name\") = LOWER('model 1'))
+ SELECT \"namespaces\".* FROM \"namespaces\" WHERE (LOWER(\"namespaces\".\"path\") IN (LOWER('MODEL-1'), LOWER('model-2'))) AND (LOWER(\"namespaces\".\"name\") = LOWER('model 1'))
QRY
expect(query).to eq(expected_query)
diff --git a/spec/models/concerns/chronic_duration_attribute_spec.rb b/spec/models/concerns/chronic_duration_attribute_spec.rb
index 51221e07ca3..5f90bfa09d0 100644
--- a/spec/models/concerns/chronic_duration_attribute_spec.rb
+++ b/spec/models/concerns/chronic_duration_attribute_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'ChronicDurationAttribute reader' do
- it 'contains dynamically created reader method' do
+shared_examples "ChronicDurationAttribute reader" do
+ it "contains dynamically created reader method" do
expect(subject.class).to be_public_method_defined(virtual_field)
end
- it 'outputs chronic duration formatted value' do
+ it "outputs chronic duration formatted value" do
subject.send("#{source_field}=", 120)
- expect(subject.send(virtual_field)).to eq('2m')
+ expect(subject.send(virtual_field)).to eq("2m")
end
- context 'when value is set to nil' do
- it 'outputs nil' do
+ context "when value is set to nil" do
+ it "outputs nil" do
subject.send("#{source_field}=", nil)
expect(subject.send(virtual_field)).to be_nil
@@ -20,69 +20,69 @@ shared_examples 'ChronicDurationAttribute reader' do
end
end
-shared_examples 'ChronicDurationAttribute writer' do
- it 'contains dynamically created writer method' do
+shared_examples "ChronicDurationAttribute writer" do
+ it "contains dynamically created writer method" do
expect(subject.class).to be_public_method_defined("#{virtual_field}=")
end
before do
- subject.send("#{virtual_field}=", '10m')
+ subject.send("#{virtual_field}=", "10m")
end
- it 'parses chronic duration input' do
+ it "parses chronic duration input" do
expect(subject.send(source_field)).to eq(600)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
- context 'when negative input is used' do
+ context "when negative input is used" do
before do
subject.send("#{source_field}=", 3600)
end
it "doesn't raise exception" do
- expect { subject.send("#{virtual_field}=", '-10m') }.not_to raise_error
+ expect { subject.send("#{virtual_field}=", "-10m") }.not_to raise_error
end
it "doesn't change value" do
- expect { subject.send("#{virtual_field}=", '-10m') }.not_to change { subject.send(source_field) }
+ expect { subject.send("#{virtual_field}=", "-10m") }.not_to change { subject.send(source_field) }
end
it "doesn't pass validation" do
- subject.send("#{virtual_field}=", '-10m')
+ subject.send("#{virtual_field}=", "-10m")
expect(subject.valid?).to be_falsey
expect(subject.errors&.messages)
- .to include(base: ['Maximum job timeout has a value which could not be accepted'])
+ .to include(base: ["Maximum job timeout has a value which could not be accepted"])
end
end
- context 'when empty input is used' do
+ context "when empty input is used" do
before do
- subject.send("#{virtual_field}=", '')
+ subject.send("#{virtual_field}=", "")
end
- it 'writes default value' do
+ it "writes default value" do
expect(subject.send(source_field)).to eq(default_value)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
end
- context 'when nil input is used' do
+ context "when nil input is used" do
before do
subject.send("#{virtual_field}=", nil)
end
- it 'writes default value' do
+ it "writes default value" do
expect(subject.send(source_field)).to eq(default_value)
end
- it 'passes validation' do
+ it "passes validation" do
expect(subject.valid?).to be_truthy
end
@@ -92,31 +92,31 @@ shared_examples 'ChronicDurationAttribute writer' do
end
end
-describe 'ChronicDurationAttribute' do
- context 'when default value is not set' do
+describe "ChronicDurationAttribute" do
+ context "when default value is not set" do
let(:source_field) {:maximum_timeout}
let(:virtual_field) {:maximum_timeout_human_readable}
let(:default_value) { nil }
subject { create(:ci_runner) }
- it_behaves_like 'ChronicDurationAttribute reader'
- it_behaves_like 'ChronicDurationAttribute writer'
+ it_behaves_like "ChronicDurationAttribute reader"
+ it_behaves_like "ChronicDurationAttribute writer"
end
- context 'when default value is set' do
+ context "when default value is set" do
let(:source_field) {:build_timeout}
let(:virtual_field) {:build_timeout_human_readable}
let(:default_value) { 3600 }
subject { create(:project) }
- it_behaves_like 'ChronicDurationAttribute reader'
- it_behaves_like 'ChronicDurationAttribute writer'
+ it_behaves_like "ChronicDurationAttribute reader"
+ it_behaves_like "ChronicDurationAttribute writer"
end
end
-describe 'ChronicDurationAttribute - reader' do
+describe "ChronicDurationAttribute - reader" do
let(:source_field) {:timeout}
let(:virtual_field) {:timeout_human_readable}
@@ -126,5 +126,5 @@ describe 'ChronicDurationAttribute - reader' do
expect(subject.class).not_to be_public_method_defined("#{virtual_field}=")
end
- it_behaves_like 'ChronicDurationAttribute reader'
+ it_behaves_like "ChronicDurationAttribute reader"
end
diff --git a/spec/models/concerns/deployable_spec.rb b/spec/models/concerns/deployable_spec.rb
index 6951be903fe..af029db6763 100644
--- a/spec/models/concerns/deployable_spec.rb
+++ b/spec/models/concerns/deployable_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
describe Deployable do
- describe '#create_deployment' do
+ describe "#create_deployment" do
let(:deployment) { job.deployment }
let(:environment) { deployment&.environment }
@@ -9,63 +9,64 @@ describe Deployable do
job.reload
end
- context 'when the deployable object will deploy to production' do
+ context "when the deployable object will deploy to production" do
let!(:job) { create(:ci_build, :start_review_app) }
- it 'creates a deployment and environment record' do
+ it "creates a deployment and environment record" do
expect(deployment.project).to eq(job.project)
expect(deployment.ref).to eq(job.ref)
expect(deployment.tag).to eq(job.tag)
expect(deployment.sha).to eq(job.sha)
expect(deployment.user).to eq(job.user)
expect(deployment.deployable).to eq(job)
- expect(deployment.on_stop).to eq('stop_review_app')
- expect(environment.name).to eq('review/master')
+ expect(deployment.on_stop).to eq("stop_review_app")
+ expect(environment.name).to eq("review/master")
end
end
- context 'when the deployable object will stop an environment' do
+ context "when the deployable object will stop an environment" do
let!(:job) { create(:ci_build, :stop_review_app) }
- it 'does not create a deployment record' do
+ it "does not create a deployment record" do
expect(deployment).to be_nil
end
end
- context 'when the deployable object has already had a deployment' do
+ context "when the deployable object has already had a deployment" do
let!(:job) { create(:ci_build, :start_review_app, deployment: race_deployment) }
let!(:race_deployment) { create(:deployment, :success) }
- it 'does not create a new deployment' do
+ it "does not create a new deployment" do
expect(deployment).to eq(race_deployment)
end
end
- context 'when the deployable object will not deploy' do
+ context "when the deployable object will not deploy" do
let!(:job) { create(:ci_build) }
- it 'does not create a deployment and environment record' do
+ it "does not create a deployment and environment record" do
expect(deployment).to be_nil
expect(environment).to be_nil
end
end
- context 'when environment scope contains invalid character' do
+ context "when environment scope contains invalid character" do
let(:job) do
create(
:ci_build,
- name: 'job:deploy-to-test-site',
- environment: '$CI_JOB_NAME',
+ name: "job:deploy-to-test-site",
+ environment: "$CI_JOB_NAME",
options: {
environment: {
- name: '$CI_JOB_NAME',
- url: 'http://staging.example.com/$CI_JOB_NAME',
- on_stop: 'stop_review_app'
- }
- })
+ name: "$CI_JOB_NAME",
+ url: "http://staging.example.com/$CI_JOB_NAME",
+ on_stop: "stop_review_app",
+ },
+ }
+ )
end
- it 'does not create a deployment and environment record' do
+ it "does not create a deployment and environment record" do
expect(deployment).to be_nil
expect(environment).to be_nil
end
diff --git a/spec/models/concerns/deployment_platform_spec.rb b/spec/models/concerns/deployment_platform_spec.rb
index 19ab4382b53..d8fc7ce1e79 100644
--- a/spec/models/concerns/deployment_platform_spec.rb
+++ b/spec/models/concerns/deployment_platform_spec.rb
@@ -1,37 +1,37 @@
-require 'rails_helper'
+require "rails_helper"
describe DeploymentPlatform do
let(:project) { create(:project) }
- describe '#deployment_platform' do
+ describe "#deployment_platform" do
subject { project.deployment_platform }
- context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and a Kubernetes template configured' do
+ context "with no Kubernetes configuration on CI/CD, no Kubernetes Service and a Kubernetes template configured" do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
- it 'returns a platform kubernetes' do
+ it "returns a platform kubernetes" do
expect(subject).to be_a_kind_of(Clusters::Platforms::Kubernetes)
end
- it 'creates a cluster and a platform kubernetes' do
+ it "creates a cluster and a platform kubernetes" do
expect { subject }
.to change { Clusters::Cluster.count }.by(1)
.and change { Clusters::Platforms::Kubernetes.count }.by(1)
end
- it 'includes appropriate attributes for Cluster' do
+ it "includes appropriate attributes for Cluster" do
cluster = subject.cluster
- expect(cluster.name).to eq('kubernetes-template')
+ expect(cluster.name).to eq("kubernetes-template")
expect(cluster.project).to eq(project)
- expect(cluster.provider_type).to eq('user')
- expect(cluster.platform_type).to eq('kubernetes')
+ expect(cluster.provider_type).to eq("user")
+ expect(cluster.platform_type).to eq("kubernetes")
end
- it 'creates a platform kubernetes' do
+ it "creates a platform kubernetes" do
expect { subject }.to change { Clusters::Platforms::Kubernetes.count }.by(1)
end
- it 'copies attributes from Clusters::Platform::Kubernetes template into the new Cluster::Platforms::Kubernetes' do
+ it "copies attributes from Clusters::Platform::Kubernetes template into the new Cluster::Platforms::Kubernetes" do
expect(subject.api_url).to eq(kubernetes_service.api_url)
expect(subject.ca_pem).to eq(kubernetes_service.ca_pem)
expect(subject.token).to eq(kubernetes_service.token)
@@ -39,32 +39,32 @@ describe DeploymentPlatform do
end
end
- context 'with no Kubernetes configuration on CI/CD, no Kubernetes Service and no Kubernetes template configured' do
+ context "with no Kubernetes configuration on CI/CD, no Kubernetes Service and no Kubernetes template configured" do
it { is_expected.to be_nil }
end
- context 'when project has configured kubernetes from CI/CD > Clusters' do
+ context "when project has configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:platform_kubernetes) { cluster.platform_kubernetes }
- it 'returns the Kubernetes platform' do
+ it "returns the Kubernetes platform" do
expect(subject).to eq(platform_kubernetes)
end
- context 'with a group level kubernetes cluster' do
+ context "with a group level kubernetes cluster" do
let(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
before do
project.update!(group: group_cluster.group)
end
- it 'returns the Kubernetes platform from the project cluster' do
+ it "returns the Kubernetes platform from the project cluster" do
expect(subject).to eq(platform_kubernetes)
end
end
end
- context 'when group has configured kubernetes cluster' do
+ context "when group has configured kubernetes cluster" do
let!(:group_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { group_cluster.group }
@@ -72,11 +72,11 @@ describe DeploymentPlatform do
project.update!(group: group)
end
- it 'returns the Kubernetes platform' do
+ it "returns the Kubernetes platform" do
is_expected.to eq(group_cluster.platform_kubernetes)
end
- context 'when child group has configured kubernetes cluster', :nested_groups do
+ context "when child group has configured kubernetes cluster", :nested_groups do
let!(:child_group1_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:child_group1) { child_group1_cluster.group }
@@ -85,11 +85,11 @@ describe DeploymentPlatform do
child_group1.update!(parent: group)
end
- it 'returns the Kubernetes platform for the child group' do
+ it "returns the Kubernetes platform for the child group" do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
- context 'deeply nested group' do
+ context "deeply nested group" do
let!(:child_group2_cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:child_group2) { child_group2_cluster.group }
@@ -98,42 +98,42 @@ describe DeploymentPlatform do
project.update!(group: child_group2)
end
- it 'returns most nested group cluster Kubernetes platform' do
+ it "returns most nested group cluster Kubernetes platform" do
is_expected.to eq(child_group2_cluster.platform_kubernetes)
end
- context 'cluster in the middle of hierarchy is disabled' do
+ context "cluster in the middle of hierarchy is disabled" do
before do
child_group2_cluster.update!(enabled: false)
end
- it 'returns closest enabled Kubenetes platform' do
+ it "returns closest enabled Kubenetes platform" do
is_expected.to eq(child_group1_cluster.platform_kubernetes)
end
end
end
end
- context 'feature flag disabled' do
+ context "feature flag disabled" do
before do
stub_feature_flags(group_clusters: false)
end
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- context 'when user configured kubernetes integration from project services' do
+ context "when user configured kubernetes integration from project services" do
let!(:kubernetes_service) { create(:kubernetes_service, project: project) }
- it 'returns the Kubernetes service' do
+ it "returns the Kubernetes service" do
expect(subject).to eq(kubernetes_service)
end
end
- context 'when the cluster creation fails' do
+ context "when the cluster creation fails" do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
before do
diff --git a/spec/models/concerns/discussion_on_diff_spec.rb b/spec/models/concerns/discussion_on_diff_spec.rb
index 64bf04071e8..53fea1ed801 100644
--- a/spec/models/concerns/discussion_on_diff_spec.rb
+++ b/spec/models/concerns/discussion_on_diff_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiscussionOnDiff do
subject { create(:diff_note_on_merge_request, line_number: 18).to_discussion }
@@ -13,27 +13,27 @@ describe DiscussionOnDiff do
expect(truncated_lines.count).to be <= DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
end
- context 'with truncated diff lines diff limit set' do
+ context "with truncated diff lines diff limit set" do
let(:truncated_lines) do
subject.truncated_diff_lines(
diff_limit: diff_limit
)
end
- context 'when diff limit is higher than default' do
+ context "when diff limit is higher than default" do
let(:diff_limit) { DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES + 1 }
- it 'returns fewer lines than the default' do
+ it "returns fewer lines than the default" do
expect(subject.diff_lines.count).to be > diff_limit
expect(truncated_lines.count).to be <= DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
end
end
- context 'when diff_limit is lower than default' do
+ context "when diff_limit is lower than default" do
let(:diff_limit) { 3 }
- it 'returns fewer lines than the default' do
+ it "returns fewer lines than the default" do
expect(subject.diff_lines.count).to be > DiffDiscussion::NUMBER_OF_TRUNCATED_DIFF_LINES
expect(truncated_lines.count).to be <= diff_limit
@@ -57,36 +57,36 @@ describe DiscussionOnDiff do
end
end
- context 'when the discussion is on an image' do
+ context "when the discussion is on an image" do
subject { create(:image_diff_note_on_merge_request).to_discussion }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(truncated_lines).to eq([])
end
end
end
- describe '#line_code_in_diffs' do
- context 'when the discussion is active in the diff' do
+ describe "#line_code_in_diffs" do
+ context "when the discussion is active in the diff" do
let(:diff_refs) { subject.position.diff_refs }
- it 'returns the current line code' do
+ it "returns the current line code" do
expect(subject.line_code_in_diffs(diff_refs)).to eq(subject.line_code)
end
end
- context 'when the discussion was created in the diff' do
+ context "when the discussion was created in the diff" do
let(:diff_refs) { subject.original_position.diff_refs }
- it 'returns the original line code' do
+ it "returns the original line code" do
expect(subject.line_code_in_diffs(diff_refs)).to eq(subject.original_line_code)
end
end
- context 'when the discussion is unrelated to the diff' do
+ context "when the discussion is unrelated to the diff" do
let(:diff_refs) { subject.project.commit(RepoHelpers.sample_commit.id).diff_refs }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.line_code_in_diffs(diff_refs)).to be_nil
end
end
diff --git a/spec/models/concerns/each_batch_spec.rb b/spec/models/concerns/each_batch_spec.rb
index 17224c09693..848f046d09a 100644
--- a/spec/models/concerns/each_batch_spec.rb
+++ b/spec/models/concerns/each_batch_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe EachBatch do
- describe '.each_batch' do
+ describe ".each_batch" do
let(:model) do
Class.new(ActiveRecord::Base) do
include EachBatch
- self.table_name = 'users'
+ self.table_name = "users"
end
end
@@ -14,34 +14,34 @@ describe EachBatch do
5.times { create(:user, updated_at: 1.day.ago) }
end
- shared_examples 'each_batch handling' do |kwargs|
- it 'yields an ActiveRecord::Relation when a block is given' do
+ shared_examples "each_batch handling" do |kwargs|
+ it "yields an ActiveRecord::Relation when a block is given" do
model.each_batch(kwargs) do |relation|
expect(relation).to be_a_kind_of(ActiveRecord::Relation)
end
end
- it 'yields a batch index as the second argument' do
+ it "yields a batch index as the second argument" do
model.each_batch(kwargs) do |_, index|
expect(index).to eq(1)
end
end
- it 'accepts a custom batch size' do
+ it "accepts a custom batch size" do
amount = 0
- model.each_batch(kwargs.merge({ of: 1 })) { amount += 1 }
+ model.each_batch(kwargs.merge({of: 1})) { amount += 1 }
expect(amount).to eq(5)
end
- it 'does not include ORDER BYs in the yielded relations' do
+ it "does not include ORDER BYs in the yielded relations" do
model.each_batch do |relation|
- expect(relation.to_sql).not_to include('ORDER BY')
+ expect(relation.to_sql).not_to include("ORDER BY")
end
end
- it 'allows updating of the yielded relations' do
+ it "allows updating of the yielded relations" do
time = Time.now
model.each_batch do |relation|
@@ -52,7 +52,7 @@ describe EachBatch do
end
end
- it_behaves_like 'each_batch handling', {}
- it_behaves_like 'each_batch handling', { order_hint: :updated_at }
+ it_behaves_like "each_batch handling", {}
+ it_behaves_like "each_batch handling", {order_hint: :updated_at}
end
end
diff --git a/spec/models/concerns/editable_spec.rb b/spec/models/concerns/editable_spec.rb
index 49a9a8ebcbc..49350966c96 100644
--- a/spec/models/concerns/editable_spec.rb
+++ b/spec/models/concerns/editable_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Editable do
- describe '#edited?' do
+ describe "#edited?" do
let(:issue) { create(:issue, last_edited_at: nil) }
let(:edited_issue) { create(:issue, created_at: 3.days.ago, last_edited_at: 2.days.ago) }
diff --git a/spec/models/concerns/expirable_spec.rb b/spec/models/concerns/expirable_spec.rb
index f7b436f32e6..34052832986 100644
--- a/spec/models/concerns/expirable_spec.rb
+++ b/spec/models/concerns/expirable_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe Expirable do
- describe 'ProjectMember' do
+ describe "ProjectMember" do
let(:no_expire) { create(:project_member) }
let(:expire_later) { create(:project_member, expires_at: Time.current + 6.days) }
let(:expired) { create(:project_member, expires_at: Time.current - 6.days) }
- describe '.expired' do
+ describe ".expired" do
it { expect(ProjectMember.expired).to match_array([expired]) }
end
- describe '#expired?' do
+ describe "#expired?" do
it { expect(no_expire.expired?).to eq(false) }
it { expect(expire_later.expired?).to eq(false) }
it { expect(expired.expired?).to eq(true) }
end
- describe '#expires?' do
+ describe "#expires?" do
it { expect(no_expire.expires?).to eq(false) }
it { expect(expire_later.expires?).to eq(true) }
it { expect(expired.expires?).to eq(true) }
end
- describe '#expires_soon?' do
+ describe "#expires_soon?" do
it { expect(no_expire.expires_soon?).to eq(false) }
it { expect(expire_later.expires_soon?).to eq(true) }
it { expect(expired.expires_soon?).to eq(true) }
diff --git a/spec/models/concerns/faster_cache_keys_spec.rb b/spec/models/concerns/faster_cache_keys_spec.rb
index 8d3f94267fa..0d96edeb0e3 100644
--- a/spec/models/concerns/faster_cache_keys_spec.rb
+++ b/spec/models/concerns/faster_cache_keys_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe FasterCacheKeys do
- describe '#cache_key' do
- it 'returns a String' 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'
+ time = "2016-08-08 16:39:00+02"
issue = build(:issue, updated_at: time)
issue.extend(described_class)
diff --git a/spec/models/concerns/feature_gate_spec.rb b/spec/models/concerns/feature_gate_spec.rb
index 3f601243245..6bd7e023f9a 100644
--- a/spec/models/concerns/feature_gate_spec.rb
+++ b/spec/models/concerns/feature_gate_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe FeatureGate do
- describe 'User' do
- describe '#flipper_id' do
- context 'when user is not persisted' do
+ describe "User" do
+ describe "#flipper_id" do
+ context "when user is not persisted" do
let(:user) { build(:user) }
it { expect(user.flipper_id).to be_nil }
end
- context 'when user is persisted' do
+ context "when user is persisted" do
let(:user) { create(:user) }
it { expect(user.flipper_id).to eq "User:#{user.id}" }
diff --git a/spec/models/concerns/from_union_spec.rb b/spec/models/concerns/from_union_spec.rb
index ee427a667c6..ec76d8ef9f0 100644
--- a/spec/models/concerns/from_union_spec.rb
+++ b/spec/models/concerns/from_union_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe FromUnion do
- describe '.from_union' do
+ describe ".from_union" do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'users'
+ self.table_name = "users"
include FromUnion
end
end
- it 'selects from the results of the UNION' do
+ it "selects from the results of the UNION" do
query = model.from_union([model.where(id: 1), model.where(id: 2)])
expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) users/m)
end
- it 'supports the use of a custom alias for the sub query' do
+ it "supports the use of a custom alias for the sub query" do
query = model.from_union(
[model.where(id: 1), model.where(id: 2)],
- alias_as: 'kittens'
+ alias_as: "kittens"
)
expect(query.to_sql).to match(/FROM \(SELECT.+UNION.+SELECT.+\) kittens/m)
end
- it 'supports keeping duplicate rows' do
+ it "supports keeping duplicate rows" do
query = model.from_union(
[model.where(id: 1), model.where(id: 2)],
remove_duplicates: false
diff --git a/spec/models/concerns/group_descendant_spec.rb b/spec/models/concerns/group_descendant_spec.rb
index 28352d8c961..625dfa7de1f 100644
--- a/spec/models/concerns/group_descendant_spec.rb
+++ b/spec/models/concerns/group_descendant_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupDescendant, :nested_groups do
let(:parent) { create(:group) }
@@ -9,9 +9,9 @@ describe GroupDescendant, :nested_groups do
groups + [parent, subgroup, subsub_group]
end
- context 'for a group' do
- describe '#hierarchy' do
- it 'only queries once for the ancestors' do
+ context "for a group" do
+ describe "#hierarchy" do
+ it "only queries once for the ancestors" do
# make sure the subsub_group does not have anything cached
test_group = create(:group, parent: subsub_group).reload
@@ -20,73 +20,73 @@ describe GroupDescendant, :nested_groups do
expect(query_count).to eq(1)
end
- it 'only queries once for the ancestors when a top is given' do
+ it "only queries once for the ancestors when a top is given" do
test_group = create(:group, parent: subsub_group).reload
recorder = ActiveRecord::QueryRecorder.new { test_group.hierarchy(subgroup) }
expect(recorder.count).to eq(1)
end
- it 'builds a hierarchy for a group' do
- expected_hierarchy = { parent => { subgroup => subsub_group } }
+ it "builds a hierarchy for a group" do
+ expected_hierarchy = {parent => {subgroup => subsub_group}}
expect(subsub_group.hierarchy).to eq(expected_hierarchy)
end
- it 'builds a hierarchy upto a specified parent' do
- expected_hierarchy = { subgroup => subsub_group }
+ it "builds a hierarchy upto a specified parent" do
+ expected_hierarchy = {subgroup => subsub_group}
expect(subsub_group.hierarchy(parent)).to eq(expected_hierarchy)
end
- it 'raises an error if specifying a base that is not part of the tree' do
+ it "raises an error if specifying a base that is not part of the tree" do
expect { subsub_group.hierarchy(build_stubbed(:group)) }
- .to raise_error('specified top is not part of the tree')
+ .to raise_error("specified top is not part of the tree")
end
end
- describe '.build_hierarchy' do
- it 'combines hierarchies until the top' do
+ describe ".build_hierarchy" do
+ it "combines hierarchies until the top" do
other_subgroup = create(:group, parent: parent)
other_subsub_group = create(:group, parent: subgroup)
groups = all_preloaded_groups(other_subgroup, subsub_group, other_subsub_group)
- expected_hierarchy = { parent => [other_subgroup, { subgroup => [subsub_group, other_subsub_group] }] }
+ expected_hierarchy = {parent => [other_subgroup, {subgroup => [subsub_group, other_subsub_group]}]}
expect(described_class.build_hierarchy(groups)).to eq(expected_hierarchy)
end
- it 'combines upto a given parent' do
+ it "combines upto a given parent" do
other_subgroup = create(:group, parent: parent)
other_subsub_group = create(:group, parent: subgroup)
groups = [other_subgroup, subsub_group, other_subsub_group]
groups << subgroup # Add the parent as if it was preloaded
- expected_hierarchy = [other_subgroup, { subgroup => [subsub_group, other_subsub_group] }]
+ expected_hierarchy = [other_subgroup, {subgroup => [subsub_group, other_subsub_group]}]
expect(described_class.build_hierarchy(groups, parent)).to eq(expected_hierarchy)
end
- it 'handles building a tree out of order' do
+ it "handles building a tree out of order" do
other_subgroup = create(:group, parent: parent)
other_subgroup2 = create(:group, parent: parent)
other_subsub_group = create(:group, parent: other_subgroup)
groups = all_preloaded_groups(subsub_group, other_subgroup2, other_subsub_group, other_subgroup)
- expected_hierarchy = { parent => [{ subgroup => subsub_group }, other_subgroup2, { other_subgroup => other_subsub_group }] }
+ expected_hierarchy = {parent => [{subgroup => subsub_group}, other_subgroup2, {other_subgroup => other_subsub_group}]}
expect(described_class.build_hierarchy(groups)).to eq(expected_hierarchy)
end
- it 'tracks the exception when a parent was not preloaded' do
+ it "tracks the exception when a parent was not preloaded" do
expect(Gitlab::Sentry).to receive(:track_exception).and_call_original
expect { GroupDescendant.build_hierarchy([subsub_group]) }.to raise_error(ArgumentError)
end
- it 'recovers if a parent was not reloaded by querying for the parent' do
- expected_hierarchy = { parent => { subgroup => subsub_group } }
+ it "recovers if a parent was not reloaded by querying for the parent" do
+ expected_hierarchy = {parent => {subgroup => subsub_group}}
# this does not raise in production, so stubbing it here.
allow(Gitlab::Sentry).to receive(:track_exception)
@@ -94,61 +94,61 @@ describe GroupDescendant, :nested_groups do
expect(GroupDescendant.build_hierarchy([subsub_group])).to eq(expected_hierarchy)
end
- it 'raises an error if not all elements were preloaded' do
+ it "raises an error if not all elements were preloaded" do
expect { described_class.build_hierarchy([subsub_group]) }
.to raise_error(/was not preloaded/)
end
end
end
- context 'for a project' do
+ context "for a project" do
let(:project) { create(:project, namespace: subsub_group) }
- describe '#hierarchy' do
- it 'builds a hierarchy for a project' do
- expected_hierarchy = { parent => { subgroup => { subsub_group => project } } }
+ describe "#hierarchy" do
+ it "builds a hierarchy for a project" do
+ expected_hierarchy = {parent => {subgroup => {subsub_group => project}}}
expect(project.hierarchy).to eq(expected_hierarchy)
end
- it 'builds a hierarchy upto a specified parent' do
- expected_hierarchy = { subsub_group => project }
+ it "builds a hierarchy upto a specified parent" do
+ expected_hierarchy = {subsub_group => project}
expect(project.hierarchy(subgroup)).to eq(expected_hierarchy)
end
end
- describe '.build_hierarchy' do
- it 'combines hierarchies until the top' do
+ describe ".build_hierarchy" do
+ it "combines hierarchies until the top" do
other_project = create(:project, namespace: parent)
other_subgroup_project = create(:project, namespace: subgroup)
elements = all_preloaded_groups(other_project, subsub_group, other_subgroup_project)
- expected_hierarchy = { parent => [other_project, { subgroup => [subsub_group, other_subgroup_project] }] }
+ expected_hierarchy = {parent => [other_project, {subgroup => [subsub_group, other_subgroup_project]}]}
expect(described_class.build_hierarchy(elements)).to eq(expected_hierarchy)
end
- it 'combines upto a given parent' do
+ it "combines upto a given parent" do
other_project = create(:project, namespace: parent)
other_subgroup_project = create(:project, namespace: subgroup)
elements = [other_project, subsub_group, other_subgroup_project]
elements << subgroup # Added as if it was preloaded
- expected_hierarchy = [other_project, { subgroup => [subsub_group, other_subgroup_project] }]
+ expected_hierarchy = [other_project, {subgroup => [subsub_group, other_subgroup_project]}]
expect(described_class.build_hierarchy(elements, parent)).to eq(expected_hierarchy)
end
- it 'merges to elements in the same hierarchy' do
- expected_hierarchy = { parent => subgroup }
+ it "merges to elements in the same hierarchy" do
+ expected_hierarchy = {parent => subgroup}
expect(described_class.build_hierarchy([parent, subgroup])).to eq(expected_hierarchy)
end
- it 'merges complex hierarchies' do
+ it "merges complex hierarchies" do
project = create(:project, namespace: parent)
sub_project = create(:project, namespace: subgroup)
subsubsub_group = create(:group, parent: subsub_group)
@@ -165,11 +165,11 @@ describe GroupDescendant, :nested_groups do
project,
{
subgroup => [
- { subsub_group => [{ subsubsub_group => subsubsub_project }, subsub_project] },
- sub_project
- ]
+ {subsub_group => [{subsubsub_group => subsubsub_project}, subsub_project]},
+ sub_project,
+ ],
},
- { other_subgroup => other_subproject }
+ {other_subgroup => other_subproject},
]
actual_hierarchy = described_class.build_hierarchy(elements, parent)
diff --git a/spec/models/concerns/has_ref_spec.rb b/spec/models/concerns/has_ref_spec.rb
index 8aed72d77a4..21840d08830 100644
--- a/spec/models/concerns/has_ref_spec.rb
+++ b/spec/models/concerns/has_ref_spec.rb
@@ -1,57 +1,57 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe HasRef do
- describe '#branch?' do
+ describe "#branch?" do
let(:build) { create(:ci_build) }
subject { build.branch? }
- context 'is not a tag' do
+ context "is not a tag" do
before do
build.tag = false
end
- it 'return true when tag is set to false' do
+ it "return true when tag is set to false" do
is_expected.to be_truthy
end
end
- context 'is not a tag' do
+ context "is not a tag" do
before do
build.tag = true
end
- it 'return false when tag is set to true' do
+ it "return false when tag is set to true" do
is_expected.to be_falsey
end
end
end
- describe '#git_ref' do
+ describe "#git_ref" do
subject { build.git_ref }
- context 'when tag is true' do
+ context "when tag is true" do
let(:build) { create(:ci_build, tag: true) }
- it 'returns a tag ref' do
+ it "returns a tag ref" do
is_expected.to start_with(Gitlab::Git::TAG_REF_PREFIX)
end
end
- context 'when tag is false' do
+ context "when tag is false" do
let(:build) { create(:ci_build, tag: false) }
- it 'returns a branch ref' do
+ it "returns a branch ref" do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
- context 'when tag is nil' do
+ context "when tag is nil" do
let(:build) { create(:ci_build, tag: nil) }
- it 'returns a branch ref' do
+ it "returns a branch ref" do
is_expected.to start_with(Gitlab::Git::BRANCH_REF_PREFIX)
end
end
diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb
index 6b1038cb8fd..7e06f3f074c 100644
--- a/spec/models/concerns/has_status_spec.rb
+++ b/spec/models/concerns/has_status_spec.rb
@@ -1,185 +1,185 @@
-require 'spec_helper'
+require "spec_helper"
describe HasStatus do
- describe '.status' do
+ describe ".status" do
subject { CommitStatus.status }
- shared_examples 'build status summary' do
- context 'all successful' do
+ shared_examples "build status summary" do
+ context "all successful" do
let!(:statuses) { Array.new(2) { create(type, status: :success) } }
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'at least one failed' do
+ context "at least one failed" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :failed)]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
- context 'at least one running' do
+ context "at least one running" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :running)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'at least one pending' do
+ context "at least one pending" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :pending)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'success and failed but allowed to fail' do
+ context "success and failed but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :failed, allow_failure: true)]
+ create(type, status: :failed, allow_failure: true),]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'one failed but allowed to fail' do
+ context "one failed but allowed to fail" do
let!(:statuses) do
[create(type, status: :failed, allow_failure: true)]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'success and canceled' do
+ context "success and canceled" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :canceled)]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'one failed and one canceled' do
+ context "one failed and one canceled" do
let!(:statuses) do
[create(type, status: :failed), create(type, status: :canceled)]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
- context 'one failed but allowed to fail and one canceled' do
+ context "one failed but allowed to fail and one canceled" do
let!(:statuses) do
[create(type, status: :failed, allow_failure: true),
- create(type, status: :canceled)]
+ create(type, status: :canceled),]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'one running one canceled' do
+ context "one running one canceled" do
let!(:statuses) do
[create(type, status: :running), create(type, status: :canceled)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'all canceled' do
+ context "all canceled" do
let!(:statuses) do
[create(type, status: :canceled), create(type, status: :canceled)]
end
- it { is_expected.to eq 'canceled' }
+ it { is_expected.to eq "canceled" }
end
- context 'success and canceled but allowed to fail' do
+ context "success and canceled but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :canceled, allow_failure: true)]
+ create(type, status: :canceled, allow_failure: true),]
end
- it { is_expected.to eq 'success' }
+ it { is_expected.to eq "success" }
end
- context 'one finished and second running but allowed to fail' do
+ context "one finished and second running but allowed to fail" do
let!(:statuses) do
[create(type, status: :success),
- create(type, status: :running, allow_failure: true)]
+ create(type, status: :running, allow_failure: true),]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'when one status finished and second is still created' do
+ context "when one status finished and second is still created" do
let!(:statuses) do
[create(type, status: :success), create(type, status: :created)]
end
- it { is_expected.to eq 'running' }
+ it { is_expected.to eq "running" }
end
- context 'when there is a manual status before created status' do
+ context "when there is a manual status before created status" do
let!(:statuses) do
[create(type, status: :success),
create(type, status: :manual, allow_failure: false),
- create(type, status: :created)]
+ create(type, status: :created),]
end
- it { is_expected.to eq 'manual' }
+ it { is_expected.to eq "manual" }
end
- context 'when one status is a blocking manual action' do
+ context "when one status is a blocking manual action" do
let!(:statuses) do
[create(type, status: :failed),
- create(type, status: :manual, allow_failure: false)]
+ create(type, status: :manual, allow_failure: false),]
end
- it { is_expected.to eq 'manual' }
+ it { is_expected.to eq "manual" }
end
- context 'when one status is a non-blocking manual action' do
+ context "when one status is a non-blocking manual action" do
let!(:statuses) do
[create(type, status: :failed),
- create(type, status: :manual, allow_failure: true)]
+ create(type, status: :manual, allow_failure: true),]
end
- it { is_expected.to eq 'failed' }
+ it { is_expected.to eq "failed" }
end
end
- context 'ci build statuses' do
+ context "ci build statuses" do
let(:type) { :ci_build }
- it_behaves_like 'build status summary'
+ it_behaves_like "build status summary"
end
- context 'generic commit statuses' do
+ context "generic commit statuses" do
let(:type) { :generic_commit_status }
- it_behaves_like 'build status summary'
+ it_behaves_like "build status summary"
end
end
- context 'for scope with one status' do
- shared_examples 'having a job' do |status|
+ context "for scope with one status" do
+ shared_examples "having a job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
describe ".#{status}" do
- it 'contains the job' do
+ it "contains the job" do
expect(CommitStatus.public_send(status).all)
.to contain_exactly(job)
end
end
- describe '.relevant' do
+ describe ".relevant" do
if status == :created
- it 'contains nothing' do
+ it "contains nothing" do
expect(CommitStatus.relevant.all).to be_empty
end
else
- it 'contains the job' do
+ it "contains the job" do
expect(CommitStatus.relevant.all).to contain_exactly(job)
end
end
@@ -190,151 +190,151 @@ describe HasStatus do
%i[created running pending success
failed canceled skipped].each do |status|
- it_behaves_like 'having a job', status
+ it_behaves_like "having a job", status
end
end
- context 'for scope with more statuses' do
- shared_examples 'containing the job' do |status|
+ context "for scope with more statuses" do
+ shared_examples "containing the job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
- it 'contains the job' do
+ it "contains the job" do
is_expected.to contain_exactly(job)
end
end
end
end
- shared_examples 'not containing the job' do |status|
+ shared_examples "not containing the job" do |status|
%i[ci_build generic_commit_status].each do |type|
context "when it's #{status} #{type} job" do
let!(:job) { create(type, status) }
- it 'contains nothing' do
+ it "contains nothing" do
is_expected.to be_empty
end
end
end
end
- describe '.running_or_pending' do
+ describe ".running_or_pending" do
subject { CommitStatus.running_or_pending }
%i[running pending].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[created failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.alive' do
+ describe ".alive" do
subject { CommitStatus.alive }
%i[running pending created].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.created_or_pending' do
+ describe ".created_or_pending" do
subject { CommitStatus.created_or_pending }
%i[created pending].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[running failed success].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.finished' do
+ describe ".finished" do
subject { CommitStatus.finished }
%i[success failed canceled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[created running pending].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.cancelable' do
+ describe ".cancelable" do
subject { CommitStatus.cancelable }
%i[running pending created scheduled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled manual].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.manual' do
+ describe ".manual" do
subject { CommitStatus.manual }
%i[manual].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
- describe '.scheduled' do
+ describe ".scheduled" do
subject { CommitStatus.scheduled }
%i[scheduled].each do |status|
- it_behaves_like 'containing the job', status
+ it_behaves_like "containing the job", status
end
%i[failed success skipped canceled].each do |status|
- it_behaves_like 'not containing the job', status
+ it_behaves_like "not containing the job", status
end
end
end
- describe '::DEFAULT_STATUS' do
- it 'is a status created' do
- expect(described_class::DEFAULT_STATUS).to eq 'created'
+ describe "::DEFAULT_STATUS" do
+ it "is a status created" do
+ expect(described_class::DEFAULT_STATUS).to eq "created"
end
end
- describe '::BLOCKED_STATUS' do
- it 'is a status manual' do
+ describe "::BLOCKED_STATUS" do
+ it "is a status manual" do
expect(described_class::BLOCKED_STATUS).to eq %w[manual scheduled]
end
end
- describe 'blocked?' do
+ describe "blocked?" do
subject { object.blocked? }
%w[ci_pipeline ci_stage ci_build generic_commit_status].each do |type|
let(:object) { build(type, status: status) }
- context 'when status is scheduled' do
+ context "when status is scheduled" do
let(:status) { :scheduled }
it { is_expected.to be_truthy }
end
- context 'when status is manual' do
+ context "when status is manual" do
let(:status) { :manual }
it { is_expected.to be_truthy }
end
- context 'when status is created' do
+ context "when status is created" do
let(:status) { :created }
it { is_expected.to be_falsy }
@@ -342,10 +342,10 @@ describe HasStatus do
end
end
- describe '.status_sql' do
+ describe ".status_sql" do
subject { Ci::Build.status_sql }
- it 'returns SQL' do
+ it "returns SQL" do
puts subject
end
end
diff --git a/spec/models/concerns/has_variable_spec.rb b/spec/models/concerns/has_variable_spec.rb
index bff96e12ffa..5b9d825c168 100644
--- a/spec/models/concerns/has_variable_spec.rb
+++ b/spec/models/concerns/has_variable_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe HasVariable do
subject { build(:ci_variable) }
it { is_expected.to validate_presence_of(:key) }
it { is_expected.to validate_length_of(:key).is_at_most(255) }
- it { is_expected.to allow_value('foo').for(:key) }
- it { is_expected.not_to allow_value('foo bar').for(:key) }
- it { is_expected.not_to allow_value('foo/bar').for(:key) }
+ it { is_expected.to allow_value("foo").for(:key) }
+ it { is_expected.not_to allow_value("foo bar").for(:key) }
+ it { is_expected.not_to allow_value("foo/bar").for(:key) }
- describe '#key=' do
- context 'when the new key is nil' do
- it 'strips leading and trailing whitespaces' do
+ describe "#key=" do
+ context "when the new key is nil" do
+ it "strips leading and trailing whitespaces" do
subject.key = nil
- expect(subject.key).to eq('')
+ expect(subject.key).to eq("")
end
end
- context 'when the new key has leadind and trailing whitespaces' do
- it 'strips leading and trailing whitespaces' do
- subject.key = ' my key '
+ context "when the new key has leadind and trailing whitespaces" do
+ it "strips leading and trailing whitespaces" do
+ subject.key = " my key "
- expect(subject.key).to eq('my key')
+ expect(subject.key).to eq("my key")
end
end
end
- describe '#value' do
+ describe "#value" do
before do
- subject.value = 'secret'
+ subject.value = "secret"
end
- it 'stores the encrypted value' do
+ it "stores the encrypted value" do
expect(subject.encrypted_value).not_to be_nil
end
- it 'stores an iv for value' do
+ it "stores an iv for value" do
expect(subject.encrypted_value_iv).not_to be_nil
end
- it 'stores a salt for value' do
+ it "stores a salt for value" do
expect(subject.encrypted_value_salt).not_to be_nil
end
- it 'fails to decrypt if iv is incorrect' do
+ it "fails to decrypt if iv is incorrect" do
# attr_encrypted expects the IV to be 16 bytes and base64-encoded
- subject.encrypted_value_iv = [SecureRandom.hex(8)].pack('m')
+ subject.encrypted_value_iv = [SecureRandom.hex(8)].pack("m")
subject.instance_variable_set(:@value, nil)
expect { subject.value }
- .to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt')
+ .to raise_error(OpenSSL::Cipher::CipherError, "bad decrypt")
end
end
- describe '#to_runner_variable' do
- it 'returns a hash for the runner' do
+ describe "#to_runner_variable" do
+ it "returns a hash for the runner" do
expect(subject.to_runner_variable)
.to include(key: subject.key, value: subject.value, public: false)
end
diff --git a/spec/models/concerns/ignorable_column_spec.rb b/spec/models/concerns/ignorable_column_spec.rb
index b70f2331a0e..9b7adb44c8f 100644
--- a/spec/models/concerns/ignorable_column_spec.rb
+++ b/spec/models/concerns/ignorable_column_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IgnorableColumn do
let :base_class do
@@ -6,9 +6,9 @@ describe IgnorableColumn do
def self.columns
# This method does not have access to "double"
[
- Struct.new(:name).new('id'),
- Struct.new(:name).new('title'),
- Struct.new(:name).new('date')
+ Struct.new(:name).new("id"),
+ Struct.new(:name).new("title"),
+ Struct.new(:name).new("date"),
]
end
end
@@ -20,23 +20,23 @@ describe IgnorableColumn do
end
end
- describe '.columns' do
- it 'returns the columns, excluding the ignored ones' do
+ describe ".columns" do
+ it "returns the columns, excluding the ignored ones" do
model.ignore_column(:title, :date)
- expect(model.columns.map(&:name)).to eq(%w(id))
+ expect(model.columns.map(&:name)).to eq(%w[id])
end
end
- describe '.ignored_columns' do
- it 'returns a Set' do
+ describe ".ignored_columns" do
+ it "returns a Set" do
expect(model.ignored_columns).to be_an_instance_of(Set)
end
- it 'returns the names of the ignored columns' do
+ it "returns the names of the ignored columns" do
model.ignore_column(:title, :date)
- expect(model.ignored_columns).to eq(Set.new(%w(title date)))
+ expect(model.ignored_columns).to eq(Set.new(%w[title date]))
end
end
end
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb
index 41159348e04..b6c0bdb75a2 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/spec/models/concerns/issuable_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Issuable do
let(:issuable_class) { Issue }
- let(:issue) { create(:issue, title: 'An issue', description: 'A description') }
+ let(:issue) { create(:issue, title: "An issue", description: "A description") }
let(:user) { create(:user) }
describe "Associations" do
@@ -14,18 +14,18 @@ describe Issuable do
it { is_expected.to have_many(:todos).dependent(:destroy) }
it { is_expected.to have_many(:labels) }
- context 'Notes' do
+ context "Notes" do
let!(:note) { create(:note, noteable: issue, project: issue.project) }
let(:scoped_issue) { Issue.includes(notes: :author).find(issue.id) }
- it 'indicates if the notes have their authors loaded' do
+ it "indicates if the notes have their authors loaded" do
expect(issue.notes).not_to be_authors_loaded
expect(scoped_issue.notes).to be_authors_loaded
end
end
end
- describe 'Included modules' do
+ describe "Included modules" do
let(:described_class) { issuable_class }
it { is_expected.to include_module(Awardable) }
@@ -53,12 +53,12 @@ describe Issuable do
it { expect(issuable_class).to respond_to(:assigned) }
end
- describe 'author_name' do
- it 'is delegated to author' do
+ describe "author_name" do
+ it "is delegated to author" do
expect(issue.author_name).to eq issue.author.name
end
- it 'returns nil when author is nil' do
+ it "returns nil when author is nil" do
issue.author_id = nil
issue.save(validate: false)
@@ -68,152 +68,152 @@ describe Issuable do
describe ".search" do
let!(:searchable_issue) { create(:issue, title: "Searchable awesome issue") }
- let!(:searchable_issue2) { create(:issue, title: 'Aw') }
+ let!(:searchable_issue2) { create(:issue, title: "Aw") }
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.search(searchable_issue.title))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching title' do
- expect(issuable_class.search('able')).to eq([searchable_issue])
+ it "returns issues with a partially matching title" do
+ expect(issuable_class.search("able")).to eq([searchable_issue])
end
- it 'returns issues with a matching title regardless of the casing' do
+ it "returns issues with a matching title regardless of the casing" do
expect(issuable_class.search(searchable_issue.title.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching title' do
- expect(issuable_class.search('searchable issue')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching title" do
+ expect(issuable_class.search("searchable issue")).to eq([searchable_issue])
end
- it 'returns issues with a matching title for a query shorter than 3 chars' do
+ it "returns issues with a matching title for a query shorter than 3 chars" do
expect(issuable_class.search(searchable_issue2.title.downcase)).to eq([searchable_issue2])
end
end
describe ".full_search" do
let!(:searchable_issue) do
- create(:issue, title: "Searchable awesome issue", description: 'Many cute kittens')
+ create(:issue, title: "Searchable awesome issue", description: "Many cute kittens")
end
let!(:searchable_issue2) { create(:issue, title: "Aw", description: "Cu") }
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.full_search(searchable_issue.title))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching title' do
- expect(issuable_class.full_search('able')).to eq([searchable_issue])
+ it "returns issues with a partially matching title" do
+ expect(issuable_class.full_search("able")).to eq([searchable_issue])
end
- it 'returns issues with a matching title regardless of the casing' do
+ it "returns issues with a matching title regardless of the casing" do
expect(issuable_class.full_search(searchable_issue.title.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching title' do
- expect(issuable_class.full_search('searchable issue')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching title" do
+ expect(issuable_class.full_search("searchable issue")).to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
+ it "returns issues with a matching description" do
expect(issuable_class.full_search(searchable_issue.description))
.to eq([searchable_issue])
end
- it 'returns issues with a partially matching description' do
+ it "returns issues with a partially matching description" do
expect(issuable_class.full_search(searchable_issue.description))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description regardless of the casing' do
+ it "returns issues with a matching description regardless of the casing" do
expect(issuable_class.full_search(searchable_issue.description.upcase))
.to eq([searchable_issue])
end
- it 'returns issues with a fuzzy matching description' do
- expect(issuable_class.full_search('many kittens')).to eq([searchable_issue])
+ it "returns issues with a fuzzy matching description" do
+ expect(issuable_class.full_search("many kittens")).to eq([searchable_issue])
end
- it 'returns issues with a matching description for a query shorter than 3 chars' do
+ it "returns issues with a matching description for a query shorter than 3 chars" do
expect(issuable_class.full_search(searchable_issue2.description.downcase)).to eq([searchable_issue2])
end
context 'when matching columns is "title"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title"))
.to eq([searchable_issue])
end
- it 'returns no issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title'))
+ it "returns no issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title"))
.to be_empty
end
end
context 'when matching columns is "description"' do
- it 'returns no issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'description'))
+ it "returns no issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "description"))
.to be_empty
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'description'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "description"))
.to eq([searchable_issue])
end
end
context 'when matching columns is "title,description"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title,description'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title,description"))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title,description'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title,description"))
.to eq([searchable_issue])
end
end
context 'when matching columns is nil"' do
- it 'returns issues with a matching title' do
+ it "returns issues with a matching title" do
expect(issuable_class.full_search(searchable_issue.title, matched_columns: nil))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
+ it "returns issues with a matching description" do
expect(issuable_class.full_search(searchable_issue.description, matched_columns: nil))
.to eq([searchable_issue])
end
end
context 'when matching columns is "invalid"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'invalid'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "invalid"))
.to eq([searchable_issue])
end
- it 'returns issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'invalid'))
+ it "returns issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "invalid"))
.to eq([searchable_issue])
end
end
context 'when matching columns is "title,invalid"' do
- it 'returns issues with a matching title' do
- expect(issuable_class.full_search(searchable_issue.title, matched_columns: 'title,invalid'))
+ it "returns issues with a matching title" do
+ expect(issuable_class.full_search(searchable_issue.title, matched_columns: "title,invalid"))
.to eq([searchable_issue])
end
- it 'returns no issues with a matching description' do
- expect(issuable_class.full_search(searchable_issue.description, matched_columns: 'title,invalid'))
+ it "returns no issues with a matching description" do
+ expect(issuable_class.full_search(searchable_issue.description, matched_columns: "title,invalid"))
.to be_empty
end
end
end
- describe '.to_ability_name' do
+ describe ".to_ability_name" do
it { expect(Issue.to_ability_name).to eq("issue") }
it { expect(MergeRequest.to_ability_name).to eq("merge_request") }
end
@@ -266,72 +266,72 @@ describe Issuable do
let!(:issue3) { create(:issue, project: project) }
it "sorts desc" do
- issues = project.issues.sort_by_attribute('milestone_due_desc')
+ issues = project.issues.sort_by_attribute("milestone_due_desc")
expect(issues).to match_array([issue2, issue1, issue, issue3])
end
it "sorts asc" do
- issues = project.issues.sort_by_attribute('milestone_due_asc')
+ issues = project.issues.sort_by_attribute("milestone_due_asc")
expect(issues).to match_array([issue1, issue2, issue, issue3])
end
end
- context 'when all of the results are level on the sort key' do
+ context "when all of the results are level on the sort key" do
let!(:issues) do
10.times { create(:issue, project: project) }
end
- it 'has no duplicates across pages' do
- sorted_issue_ids = 1.upto(10).map do |i|
- project.issues.sort_by_attribute('milestone_due_desc').page(i).per(1).first.id
- end
+ it "has no duplicates across pages" do
+ sorted_issue_ids = 1.upto(10).map { |i|
+ project.issues.sort_by_attribute("milestone_due_desc").page(i).per(1).first.id
+ }
expect(sorted_issue_ids).to eq(sorted_issue_ids.uniq)
end
end
end
- describe '#subscribed?' do
+ describe "#subscribed?" do
let(:project) { issue.project }
- context 'user is not a participant in the issue' do
+ context "user is not a participant in the issue" do
before do
allow(issue).to receive(:participants).with(user).and_return([])
end
- it 'returns false when no subcription exists' do
+ it "returns false when no subcription exists" do
expect(issue.subscribed?(user, project)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
issue.subscriptions.create(user: user, project: project, subscribed: true)
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
issue.subscriptions.create(user: user, project: project, subscribed: false)
expect(issue.subscribed?(user, project)).to be_falsey
end
end
- context 'user is a participant in the issue' do
+ context "user is a participant in the issue" do
before do
allow(issue).to receive(:participants).with(user).and_return([user])
end
- it 'returns false when no subcription exists' do
+ it "returns false when no subcription exists" do
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
issue.subscriptions.create(user: user, project: project, subscribed: true)
expect(issue.subscribed?(user, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
issue.subscriptions.create(user: user, project: project, subscribed: false)
expect(issue.subscribed?(user, project)).to be_falsey
@@ -339,23 +339,23 @@ describe Issuable do
end
end
- describe '#time_estimate=' do
- it 'coerces the value below Gitlab::Database::MAX_INT_VALUE' do
+ describe "#time_estimate=" do
+ it "coerces the value below Gitlab::Database::MAX_INT_VALUE" do
expect { issue.time_estimate = 100 }.to change { issue.time_estimate }.to(100)
expect { issue.time_estimate = Gitlab::Database::MAX_INT_VALUE + 100 }.to change { issue.time_estimate }.to(Gitlab::Database::MAX_INT_VALUE)
end
- it 'skips coercion for not Integer values' do
+ it "skips coercion for not Integer values" do
expect { issue.time_estimate = nil }.to change { issue.time_estimate }.to(nil)
- expect { issue.time_estimate = 'invalid time' }.not_to raise_error
+ expect { issue.time_estimate = "invalid time" }.not_to raise_error
expect { issue.time_estimate = 22.33 }.not_to raise_error
end
end
- describe '#to_hook_data' do
+ describe "#to_hook_data" do
let(:builder) { double }
- context 'labels are updated' do
+ context "labels are updated" do
let(:labels) { create_list(:label, 2) }
before do
@@ -364,18 +364,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'labels' => [[labels[0].hook_attrs], [labels[1].hook_attrs]]
- ))
+ "labels" => [[labels[0].hook_attrs], [labels[1].hook_attrs]]
+ )
+ )
- issue.to_hook_data(user, old_associations: { labels: [labels[0]] })
+ issue.to_hook_data(user, old_associations: {labels: [labels[0]]})
end
end
- context 'total_time_spent is updated' do
+ context "total_time_spent is updated" do
before do
issue.spend_time(duration: 2, user_id: user.id, spent_at: Time.now)
issue.save
@@ -383,18 +384,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'total_time_spent' => [1, 2]
- ))
+ "total_time_spent" => [1, 2]
+ )
+ )
- issue.to_hook_data(user, old_associations: { total_time_spent: 1 })
+ issue.to_hook_data(user, old_associations: {total_time_spent: 1})
end
end
- context 'issue is assigned' do
+ context "issue is assigned" do
let(:user2) { create(:user) }
before do
@@ -403,18 +405,19 @@ describe Issuable do
.to receive(:new).with(issue).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'assignees' => [[user.hook_attrs], [user.hook_attrs, user2.hook_attrs]]
- ))
+ "assignees" => [[user.hook_attrs], [user.hook_attrs, user2.hook_attrs]]
+ )
+ )
- issue.to_hook_data(user, old_associations: { assignees: [user] })
+ issue.to_hook_data(user, old_associations: {assignees: [user]})
end
end
- context 'merge_request is assigned' do
+ context "merge_request is assigned" do
let(:merge_request) { create(:merge_request) }
let(:user2) { create(:user) }
@@ -425,34 +428,35 @@ describe Issuable do
.to receive(:new).with(merge_request).and_return(builder)
end
- it 'delegates to Gitlab::HookData::IssuableBuilder#build' do
+ it "delegates to Gitlab::HookData::IssuableBuilder#build" do
expect(builder).to receive(:build).with(
user: user,
changes: hash_including(
- 'assignee_id' => [user.id, user2.id],
- 'assignee' => [user.hook_attrs, user2.hook_attrs]
- ))
+ "assignee_id" => [user.id, user2.id],
+ "assignee" => [user.hook_attrs, user2.hook_attrs]
+ )
+ )
- merge_request.to_hook_data(user, old_associations: { assignees: [user] })
+ merge_request.to_hook_data(user, old_associations: {assignees: [user]})
end
end
end
- describe '#labels_array' do
+ describe "#labels_array" do
let(:project) { create(:project) }
- let(:bug) { create(:label, project: project, title: 'bug') }
+ let(:bug) { create(:label, project: project, title: "bug") }
let(:issue) { create(:issue, project: project) }
before do
issue.labels << bug
end
- it 'loads the association and returns it as an array' do
+ it "loads the association and returns it as an array" do
expect(issue.reload.labels_array).to eq([bug])
end
end
- describe '#user_notes_count' do
+ describe "#user_notes_count" do
let(:project) { create(:project) }
let(:issue1) { create(:issue, project: project) }
let(:issue2) { create(:issue, project: project) }
@@ -462,7 +466,7 @@ describe Issuable do
create_list(:note, 6, noteable: issue2, project: project)
end
- it 'counts the user notes' do
+ it "counts the user notes" do
expect(issue1.user_notes_count).to be(3)
expect(issue2.user_notes_count).to be(6)
end
@@ -482,14 +486,14 @@ describe Issuable do
end
end
- describe '.order_due_date_and_labels_priority' do
+ describe ".order_due_date_and_labels_priority" do
let(:project) { create(:project) }
def create_issue(milestone, labels)
create(:labeled_issue, milestone: milestone, labels: labels, project: project)
end
- it 'sorts issues in order of milestone due date, then label priority' do
+ it "sorts issues in order of milestone due date, then label priority" do
first_priority = create(:label, project: project, priority: 1)
second_priority = create(:label, project: project, priority: 2)
no_priority = create(:label, project: project)
@@ -518,15 +522,15 @@ describe Issuable do
second_milestone_no_labels,
third_milestone_first_priority,
no_milestone_second_priority,
- third_milestone_no_priority])
+ third_milestone_no_priority,])
end
end
- describe '.order_labels_priority' do
- let(:label_1) { create(:label, title: 'label_1', project: issue.project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: issue.project, priority: 2) }
+ describe ".order_labels_priority" do
+ let(:label_1) { create(:label, title: "label_1", project: issue.project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: issue.project, priority: 2) }
- subject { Issue.order_labels_priority(excluded_labels: ['label_1']).first.highest_priority }
+ subject { Issue.order_labels_priority(excluded_labels: ["label_1"]).first.highest_priority }
before do
issue.labels << label_1
@@ -538,9 +542,9 @@ describe Issuable do
describe ".with_label" do
let(:project) { create(:project, :public) }
- let(:bug) { create(:label, project: project, title: 'bug') }
- let(:feature) { create(:label, project: project, title: 'feature') }
- let(:enhancement) { create(:label, project: project, title: 'enhancement') }
+ let(:bug) { create(:label, project: project, title: "bug") }
+ let(:feature) { create(:label, project: project, title: "feature") }
+ let(:enhancement) { create(:label, project: project, title: "enhancement") }
let(:issue1) { create(:issue, title: "Bugfix1", project: project) }
let(:issue2) { create(:issue, title: "Bugfix2", project: project) }
let(:issue3) { create(:issue, title: "Feature1", project: project) }
@@ -553,20 +557,20 @@ describe Issuable do
issue3.labels << feature
end
- it 'finds the correct issue containing just enhancement label' do
+ it "finds the correct issue containing just enhancement label" do
expect(Issue.with_label(enhancement.title)).to match_array([issue2])
end
- it 'finds the correct issues containing the same label' do
+ it "finds the correct issues containing the same label" do
expect(Issue.with_label(bug.title)).to match_array([issue1, issue2])
end
- it 'finds the correct issues containing only both labels' do
+ it "finds the correct issues containing only both labels" do
expect(Issue.with_label([bug.title, enhancement.title])).to match_array([issue2])
end
end
- describe '#spend_time' do
+ describe "#spend_time" do
let(:user) { create(:user) }
let(:issue) { create(:issue) }
@@ -575,14 +579,14 @@ describe Issuable do
issue.save!
end
- context 'adding time' do
- it 'should update the total time spent' do
+ context "adding time" do
+ it "should update the total time spent" do
spend_time(1800)
expect(issue.total_time_spent).to eq(1800)
end
- it 'updates issues updated_at' do
+ it "updates issues updated_at" do
issue
Timecop.travel(1.minute.from_now) do
@@ -591,32 +595,32 @@ describe Issuable do
end
end
- context 'subtracting time' do
+ context "subtracting time" do
before do
spend_time(1800)
end
- it 'should update the total time spent' do
+ it "should update the total time spent" do
spend_time(-900)
expect(issue.total_time_spent).to eq(900)
end
- context 'when time to subtract exceeds the total time spent' do
- it 'raise a validation error' do
+ context "when time to subtract exceeds the total time spent" do
+ it "raise a validation error" do
Timecop.travel(1.minute.from_now) do
- expect do
- expect do
+ expect {
+ expect {
spend_time(-3600)
- end.to raise_error(ActiveRecord::RecordInvalid)
- end.not_to change { issue.updated_at }
+ }.to raise_error(ActiveRecord::RecordInvalid)
+ }.not_to change { issue.updated_at }
end
end
end
end
end
- describe '#first_contribution?' do
+ describe "#first_contribution?" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:other_project) { create(:project) }
diff --git a/spec/models/concerns/loaded_in_group_list_spec.rb b/spec/models/concerns/loaded_in_group_list_spec.rb
index 7a279547a3a..435d863b2da 100644
--- a/spec/models/concerns/loaded_in_group_list_spec.rb
+++ b/spec/models/concerns/loaded_in_group_list_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe LoadedInGroupList do
let(:parent) { create(:group) }
subject(:found_group) { Group.with_selects_for_list.find_by(id: parent.id) }
- describe '.with_selects_for_list' do
- it 'includes the preloaded counts for groups' do
+ describe ".with_selects_for_list" do
+ it "includes the preloaded counts for groups" do
create(:group, parent: parent)
create(:project, namespace: parent)
parent.add_developer(create(:user))
@@ -17,29 +17,29 @@ describe LoadedInGroupList do
expect(found_group.preloaded_member_count).to eq(1)
end
- context 'with archived projects' do
- it 'counts including archived projects when `true` is passed' do
+ context "with archived projects" do
+ it "counts including archived projects when `true` is passed" do
create(:project, namespace: parent, archived: true)
create(:project, namespace: parent)
- found_group = Group.with_selects_for_list(archived: 'true').find_by(id: parent.id)
+ found_group = Group.with_selects_for_list(archived: "true").find_by(id: parent.id)
expect(found_group.preloaded_project_count).to eq(2)
end
- it 'counts only archived projects when `only` is passed' do
+ it "counts only archived projects when `only` is passed" do
create_list(:project, 2, namespace: parent, archived: true)
create(:project, namespace: parent)
- found_group = Group.with_selects_for_list(archived: 'only').find_by(id: parent.id)
+ found_group = Group.with_selects_for_list(archived: "only").find_by(id: parent.id)
expect(found_group.preloaded_project_count).to eq(2)
end
end
end
- describe '#children_count' do
- it 'counts groups and projects' do
+ describe "#children_count" do
+ it "counts groups and projects" do
create(:group, parent: parent)
create(:project, namespace: parent)
diff --git a/spec/models/concerns/manual_inverse_association_spec.rb b/spec/models/concerns/manual_inverse_association_spec.rb
index ff4a04ea573..025e94e06c3 100644
--- a/spec/models/concerns/manual_inverse_association_spec.rb
+++ b/spec/models/concerns/manual_inverse_association_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe ManualInverseAssociation do
let(:model) do
Class.new(MergeRequest) do
- belongs_to :manual_association, class_name: 'MergeRequestDiff', foreign_key: :latest_merge_request_diff_id
+ belongs_to :manual_association, class_name: "MergeRequestDiff", foreign_key: :latest_merge_request_diff_id
manual_inverse_association :manual_association, :merge_request
end
end
@@ -14,36 +14,36 @@ describe ManualInverseAssociation do
let(:instance) { create(:merge_request).becomes(model) }
- describe '.manual_inverse_association' do
- context 'when the relation exists' do
+ describe ".manual_inverse_association" do
+ context "when the relation exists" do
before do
instance.create_merge_request_diff
instance.reload
end
- it 'loads the relation' do
+ it "loads the relation" do
expect(instance.manual_association).to be_an_instance_of(MergeRequestDiff)
end
- it 'does not perform extra queries after loading' do
+ it "does not perform extra queries after loading" do
instance.manual_association
expect { instance.manual_association.merge_request }
.not_to exceed_query_limit(0)
end
- it 'allows reloading the relation' do
- query_count = ActiveRecord::QueryRecorder.new do
+ it "allows reloading the relation" do
+ query_count = ActiveRecord::QueryRecorder.new {
instance.manual_association
instance.reload_manual_association
- end.count
+ }.count
expect(query_count).to eq(2)
end
end
- context 'when the relation does not return a value' do
- it 'does not try to set an inverse' do
+ context "when the relation does not return a value" do
+ it "does not try to set an inverse" do
expect(instance.manual_association).to be_nil
end
end
diff --git a/spec/models/concerns/maskable_spec.rb b/spec/models/concerns/maskable_spec.rb
index aeba7ad862f..c5473cec3cd 100644
--- a/spec/models/concerns/maskable_spec.rb
+++ b/spec/models/concerns/maskable_spec.rb
@@ -1,58 +1,58 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Maskable do
let(:variable) { build(:ci_variable) }
- describe 'masked value validations' do
+ describe "masked value validations" do
subject { variable }
- context 'when variable is masked' do
+ context "when variable is masked" do
before do
subject.masked = true
end
- it { is_expected.not_to allow_value('hello').for(:value) }
- it { is_expected.not_to allow_value('hello world').for(:value) }
- it { is_expected.not_to allow_value('hello$VARIABLEworld').for(:value) }
+ it { is_expected.not_to allow_value("hello").for(:value) }
+ it { is_expected.not_to allow_value("hello world").for(:value) }
+ it { is_expected.not_to allow_value("hello$VARIABLEworld").for(:value) }
it { is_expected.not_to allow_value('hello\rworld').for(:value) }
- it { is_expected.to allow_value('helloworld').for(:value) }
+ it { is_expected.to allow_value("helloworld").for(:value) }
end
- context 'when variable is not masked' do
+ context "when variable is not masked" do
before do
subject.masked = false
end
- it { is_expected.to allow_value('hello').for(:value) }
- it { is_expected.to allow_value('hello world').for(:value) }
- it { is_expected.to allow_value('hello$VARIABLEworld').for(:value) }
+ it { is_expected.to allow_value("hello").for(:value) }
+ it { is_expected.to allow_value("hello world").for(:value) }
+ it { is_expected.to allow_value("hello$VARIABLEworld").for(:value) }
it { is_expected.to allow_value('hello\rworld').for(:value) }
- it { is_expected.to allow_value('helloworld').for(:value) }
+ it { is_expected.to allow_value("helloworld").for(:value) }
end
end
- describe 'REGEX' do
+ describe "REGEX" do
subject { Maskable::REGEX }
- it 'does not match strings shorter than 8 letters' do
- expect(subject.match?('hello')).to eq(false)
+ it "does not match strings shorter than 8 letters" do
+ expect(subject.match?("hello")).to eq(false)
end
- it 'does not match strings with spaces' do
- expect(subject.match?('hello world')).to eq(false)
+ it "does not match strings with spaces" do
+ expect(subject.match?("hello world")).to eq(false)
end
- it 'does not match strings with shell variables' do
- expect(subject.match?('hello$VARIABLEworld')).to eq(false)
+ it "does not match strings with shell variables" do
+ expect(subject.match?("hello$VARIABLEworld")).to eq(false)
end
- it 'does not match strings with escape characters' do
+ it "does not match strings with escape characters" do
expect(subject.match?('hello\rworld')).to eq(false)
end
- it 'does not match strings that span more than one line' do
+ it "does not match strings that span more than one line" do
string = <<~EOS
hello
world
@@ -61,15 +61,15 @@ describe Maskable do
expect(subject.match?(string)).to eq(false)
end
- it 'matches valid strings' do
- expect(subject.match?('helloworld')).to eq(true)
+ it "matches valid strings" do
+ expect(subject.match?("helloworld")).to eq(true)
end
end
- describe '#to_runner_variable' do
+ describe "#to_runner_variable" do
subject { variable.to_runner_variable }
- it 'exposes the masked attribute' do
+ it "exposes the masked attribute" do
expect(subject).to include(:masked)
end
end
diff --git a/spec/models/concerns/mentionable_spec.rb b/spec/models/concerns/mentionable_spec.rb
index a9b237fa9ea..e747492be14 100644
--- a/spec/models/concerns/mentionable_spec.rb
+++ b/spec/models/concerns/mentionable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Mentionable do
class Example
@@ -12,32 +12,32 @@ describe Mentionable do
end
end
- describe 'references' do
+ describe "references" do
let(:project) { create(:project) }
let(:mentionable) { Example.new }
- it 'excludes JIRA references' do
+ it "excludes JIRA references" do
allow(project).to receive_messages(jira_tracker?: true)
mentionable.project = project
- mentionable.message = 'JIRA-123'
+ mentionable.message = "JIRA-123"
expect(mentionable.referenced_mentionables).to be_empty
end
end
end
describe Issue, "Mentionable" do
- describe '#mentioned_users' do
- let!(:user) { create(:user, username: 'stranger') }
- let!(:user2) { create(:user, username: 'john') }
- let!(:user3) { create(:user, username: 'jim') }
+ describe "#mentioned_users" do
+ let!(:user) { create(:user, username: "stranger") }
+ let!(:user2) { create(:user, username: "john") }
+ let!(:user3) { create(:user, username: "jim") }
let(:issue) { create(:issue, description: "#{user.to_reference} mentioned") }
subject { issue.mentioned_users }
it { expect(subject).to contain_exactly(user) }
- context 'when a note on personal snippet' do
+ context "when a note on personal snippet" do
let!(:note) { create(:note_on_personal_snippet, note: "#{user.to_reference} mentioned #{user3.to_reference}") }
subject { note.mentioned_users }
@@ -46,8 +46,8 @@ describe Issue, "Mentionable" do
end
end
- describe '#referenced_mentionables' do
- context 'with an issue on a private project' do
+ describe "#referenced_mentionables" do
+ context "with an issue on a private project" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:public_issue) { create(:issue, project: project) }
@@ -60,31 +60,31 @@ describe Issue, "Mentionable" do
issue.referenced_mentionables(current_user)
end
- context 'when the current user can see the issue' do
+ context "when the current user can see the issue" do
before do
private_project.add_developer(user)
end
- it 'includes the reference' do
+ it "includes the reference" do
expect(referenced_issues(user)).to contain_exactly(private_issue, public_issue)
end
end
- context 'when the current user cannot see the issue' do
- it 'does not include the reference' do
+ context "when the current user cannot see the issue" do
+ it "does not include the reference" do
expect(referenced_issues(user)).to contain_exactly(public_issue)
end
end
- context 'when there is no current user' do
- it 'does not include the reference' do
+ context "when there is no current user" do
+ it "does not include the reference" do
expect(referenced_issues(nil)).to contain_exactly(public_issue)
end
end
end
end
- describe '#create_cross_references!' do
+ describe "#create_cross_references!" do
let(:project) { create(:project, :repository) }
let(:author) { build(:user) }
let(:commit) { project.commit }
@@ -94,14 +94,14 @@ describe Issue, "Mentionable" do
create(:issue, project: project, description: "See #{commit.to_reference}")
end
- it 'correctly removes already-mentioned Commits' do
+ it "correctly removes already-mentioned Commits" do
expect(SystemNoteService).not_to receive(:cross_reference)
issue.create_cross_references!(author, [commit2])
end
end
- describe '#create_new_cross_references!' do
+ describe "#create_new_cross_references!" do
let(:project) { create(:project) }
let(:author) { create(:author) }
let(:issues) { create_list(:issue, 2, project: project, author: author) }
@@ -110,17 +110,17 @@ describe Issue, "Mentionable" do
project.add_developer(author)
end
- context 'before changes are persisted' do
- it 'ignores pre-existing references' do
+ context "before changes are persisted" do
+ it "ignores pre-existing references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).not_to receive(:cross_reference)
- issue.description = 'New description'
+ issue.description = "New description"
issue.create_new_cross_references!
end
- it 'notifies new references' do
+ it "notifies new references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
@@ -130,17 +130,17 @@ describe Issue, "Mentionable" do
end
end
- context 'after changes are persisted' do
- it 'ignores pre-existing references' do
+ context "after changes are persisted" do
+ it "ignores pre-existing references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).not_to receive(:cross_reference)
- issue.update(description: 'New description')
+ issue.update(description: "New description")
issue.create_new_cross_references!
end
- it 'notifies new references' do
+ it "notifies new references" do
issue = create_issue(description: issues[0].to_reference)
expect(SystemNoteService).to receive(:cross_reference).with(issues[1], any_args)
@@ -149,7 +149,7 @@ describe Issue, "Mentionable" do
issue.create_new_cross_references!
end
- it 'notifies new references from project snippet note' do
+ it "notifies new references from project snippet note" do
snippet = create(:snippet, project: project)
note = create(:note, note: issues[0].to_reference, noteable: snippet, project: project, author: author)
@@ -166,36 +166,36 @@ describe Issue, "Mentionable" do
end
end
-describe Commit, 'Mentionable' do
+describe Commit, "Mentionable" do
let(:project) { create(:project, :public, :repository) }
let(:commit) { project.commit }
- describe '#matches_cross_reference_regex?' do
+ describe "#matches_cross_reference_regex?" do
it "is false when message doesn't reference anything" do
allow(commit.raw).to receive(:message).and_return "WIP: Do something"
expect(commit.matches_cross_reference_regex?).to be_falsey
end
- it 'is true if issue #number mentioned in title' do
+ it "is true if issue #number mentioned in title" do
allow(commit.raw).to receive(:message).and_return "#1"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if references an MR' do
+ it "is true if references an MR" do
allow(commit.raw).to receive(:message).and_return "See merge request !12"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if references a commit' do
+ it "is true if references a commit" do
allow(commit.raw).to receive(:message).and_return "a1b2c3d4"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if issue referenced by url' do
+ it "is true if issue referenced by url" do
issue = create(:issue, project: project)
allow(commit.raw).to receive(:message).and_return Gitlab::UrlBuilder.build(issue)
@@ -203,17 +203,17 @@ describe Commit, 'Mentionable' do
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- context 'with external issue tracker' do
+ context "with external issue tracker" do
let(:project) { create(:jira_project, :repository) }
- it 'is true if external issues referenced' do
- allow(commit.raw).to receive(:message).and_return 'JIRA-123'
+ it "is true if external issues referenced" do
+ allow(commit.raw).to receive(:message).and_return "JIRA-123"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
- it 'is true if internal issues referenced' do
- allow(commit.raw).to receive(:message).and_return '#123'
+ it "is true if internal issues referenced" do
+ allow(commit.raw).to receive(:message).and_return "#123"
expect(commit.matches_cross_reference_regex?).to be_truthy
end
diff --git a/spec/models/concerns/milestoneish_spec.rb b/spec/models/concerns/milestoneish_spec.rb
index 87bf731340f..24bd9ec8881 100644
--- a/spec/models/concerns/milestoneish_spec.rb
+++ b/spec/models/concerns/milestoneish_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Milestone, 'Milestoneish' do
+describe Milestone, "Milestoneish" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
@@ -19,17 +19,17 @@ describe Milestone, 'Milestoneish' do
let!(:closed_security_issue_3) { create(:issue, :confidential, :closed, project: project, author: author, milestone: milestone) }
let!(:closed_security_issue_4) { create(:issue, :confidential, :closed, project: project, assignees: [assignee], milestone: milestone) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, milestone: milestone) }
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project) }
+ let(:label_1) { create(:label, title: "label_1", project: project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: project, priority: 2) }
+ let(:label_3) { create(:label, title: "label_3", project: project) }
before do
project.add_developer(member)
project.add_guest(guest)
end
- describe '#sorted_issues' do
- it 'sorts issues by label priority' do
+ describe "#sorted_issues" do
+ it "sorts issues by label priority" do
issue.labels << label_1
security_issue_1.labels << label_2
closed_issue_1.labels << label_3
@@ -42,11 +42,11 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#sorted_merge_requests' do
- it 'sorts merge requests by label priority' do
- merge_request_1 = create(:labeled_merge_request, labels: [label_2], source_project: project, source_branch: 'branch_1', milestone: milestone)
- merge_request_2 = create(:labeled_merge_request, labels: [label_1], source_project: project, source_branch: 'branch_2', milestone: milestone)
- merge_request_3 = create(:labeled_merge_request, labels: [label_3], source_project: project, source_branch: 'branch_3', milestone: milestone)
+ describe "#sorted_merge_requests" do
+ it "sorts merge requests by label priority" do
+ merge_request_1 = create(:labeled_merge_request, labels: [label_2], source_project: project, source_branch: "branch_1", milestone: milestone)
+ merge_request_2 = create(:labeled_merge_request, labels: [label_1], source_project: project, source_branch: "branch_2", milestone: milestone)
+ merge_request_3 = create(:labeled_merge_request, labels: [label_3], source_project: project, source_branch: "branch_3", milestone: milestone)
merge_requests = milestone.sorted_merge_requests
@@ -56,64 +56,64 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#closed_items_count' do
- it 'does not count confidential issues for non project members' do
+ describe "#closed_items_count" do
+ it "does not count confidential issues for non project members" do
expect(milestone.closed_items_count(non_member)).to eq 2
end
- it 'does 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 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.closed_items_count(author)).to eq 4
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.closed_items_count(assignee)).to eq 4
end
- it 'counts 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 'counts 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 'does not count confidential issues for non project members' do
+ describe "#total_items_count" do
+ it "does not count confidential issues for non project members" do
expect(milestone.total_items_count(non_member)).to eq 4
end
- it 'does 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 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.total_items_count(author)).to eq 7
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.total_items_count(assignee)).to eq 7
end
- it 'counts 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 'counts all issues for admin' do
+ it "counts all issues for admin" do
expect(milestone.total_items_count(admin)).to eq 10
end
end
- describe '#complete?' do
- it 'returns false when has items opened' do
+ describe "#complete?" do
+ it "returns false when has items opened" do
expect(milestone.complete?(non_member)).to eq false
end
- it 'returns true when all items are closed' do
+ it "returns true when all items are closed" do
issue.close
merge_request.close
@@ -121,74 +121,74 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#percent_complete' do
- it 'does not count confidential issues for non project members' do
+ describe "#percent_complete" do
+ it "does not count confidential issues for non project members" do
expect(milestone.percent_complete(non_member)).to eq 50
end
- it 'does 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 'counts confidential issues for author' do
+ it "counts confidential issues for author" do
expect(milestone.percent_complete(author)).to eq 57
end
- it 'counts confidential issues for assignee' do
+ it "counts confidential issues for assignee" do
expect(milestone.percent_complete(assignee)).to eq 57
end
- it 'counts confidential issues for project members' do
+ it "counts confidential issues for project members" do
expect(milestone.percent_complete(member)).to eq 60
end
- it 'counts confidential issues for admin' do
+ it "counts confidential issues for admin" do
expect(milestone.percent_complete(admin)).to eq 60
end
end
- describe '#remaining_days' do
- it 'shows 0 if no due date' do
+ describe "#remaining_days" do
+ it "shows 0 if no due date" do
milestone = build_stubbed(:milestone)
expect(milestone.remaining_days).to eq(0)
end
- it 'shows 0 if expired' do
+ it "shows 0 if expired" do
milestone = build_stubbed(:milestone, due_date: 2.days.ago)
expect(milestone.remaining_days).to eq(0)
end
- it 'shows correct remaining days' do
+ it "shows correct remaining days" do
milestone = build_stubbed(:milestone, due_date: 2.days.from_now)
expect(milestone.remaining_days).to eq(2)
end
end
- describe '#elapsed_days' do
- it 'shows 0 if no start_date set' do
+ describe "#elapsed_days" do
+ it "shows 0 if no start_date set" do
milestone = build_stubbed(:milestone)
expect(milestone.elapsed_days).to eq(0)
end
- it 'shows 0 if start_date is a future' do
+ it "shows 0 if start_date is a future" do
milestone = build_stubbed(:milestone, start_date: Time.now + 2.days)
expect(milestone.elapsed_days).to eq(0)
end
- it 'shows correct amount of days' do
+ it "shows correct amount of days" do
milestone = build_stubbed(:milestone, start_date: Time.now - 2.days)
expect(milestone.elapsed_days).to eq(2)
end
end
- describe '#total_issue_time_spent' do
- it 'calculates total issue time spent' do
+ describe "#total_issue_time_spent" do
+ it "calculates total issue time spent" do
closed_issue_1.spend_time(duration: 300, user_id: author.id)
closed_issue_1.save!
closed_issue_2.spend_time(duration: 600, user_id: assignee.id)
@@ -198,8 +198,8 @@ describe Milestone, 'Milestoneish' do
end
end
- describe '#human_total_issue_time_spent' do
- it 'returns nil if no time has been spent' do
+ describe "#human_total_issue_time_spent" do
+ it "returns nil if no time has been spent" do
expect(milestone.human_total_issue_time_spent).to be_nil
end
end
diff --git a/spec/models/concerns/noteable_spec.rb b/spec/models/concerns/noteable_spec.rb
index 485a6e165a1..760b6c50679 100644
--- a/spec/models/concerns/noteable_spec.rb
+++ b/spec/models/concerns/noteable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Noteable do
let!(:active_diff_note1) { create(:diff_note_on_merge_request) }
@@ -40,10 +40,10 @@ describe Noteable do
)
end
- describe '#discussions' do
+ describe "#discussions" do
let(:discussions) { subject.discussions }
- it 'includes discussions for diff notes, commit diff notes, commit notes, and regular notes' do
+ it "includes discussions for diff notes, commit diff notes, commit notes, and regular notes" do
expect(discussions).to eq([
DiffDiscussion.new([active_diff_note1, active_diff_note2], subject),
DiffDiscussion.new([active_diff_note3], subject),
@@ -54,12 +54,12 @@ describe Noteable do
Discussion.new([commit_discussion_note1, commit_discussion_note2], subject),
Discussion.new([commit_discussion_note3], subject),
IndividualNoteDiscussion.new([note1], subject),
- IndividualNoteDiscussion.new([note2], subject)
+ IndividualNoteDiscussion.new([note2], subject),
])
end
end
- describe '#grouped_diff_discussions' do
+ describe "#grouped_diff_discussions" do
let(:grouped_diff_discussions) { subject.grouped_diff_discussions }
it "includes active discussions" do
@@ -225,34 +225,34 @@ describe Noteable do
allow(third_discussion).to receive(:to_be_resolved?).and_return(false)
end
- it 'includes only discussions that need to be resolved' do
+ it "includes only discussions that need to be resolved" do
expect(subject.discussions_to_be_resolved).to eq([first_discussion])
end
end
- describe '#discussions_can_be_resolved_by?' do
+ describe "#discussions_can_be_resolved_by?" do
let(:user) { build(:user) }
- context 'all discussions can be resolved by the user' do
+ context "all discussions can be resolved by the user" do
before do
allow(first_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(second_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(third_discussion).to receive(:can_resolve?).with(user).and_return(true)
end
- it 'allows a user to resolve the discussions' do
+ it "allows a user to resolve the discussions" do
expect(subject.discussions_can_be_resolved_by?(user)).to be(true)
end
end
- context 'one discussion cannot be resolved by the user' do
+ context "one discussion cannot be resolved by the user" do
before do
allow(first_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(second_discussion).to receive(:can_resolve?).with(user).and_return(true)
allow(third_discussion).to receive(:can_resolve?).with(user).and_return(false)
end
- it 'allows a user to resolve the discussions' do
+ it "allows a user to resolve the discussions" do
expect(subject.discussions_can_be_resolved_by?(user)).to be(false)
end
end
diff --git a/spec/models/concerns/optionally_search_spec.rb b/spec/models/concerns/optionally_search_spec.rb
index ff4212ddf18..c03fd2ab391 100644
--- a/spec/models/concerns/optionally_search_spec.rb
+++ b/spec/models/concerns/optionally_search_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe OptionallySearch do
let(:model) do
Class.new(ActiveRecord::Base) do
- self.table_name = 'users'
+ self.table_name = "users"
include OptionallySearch
end
end
- describe '.search' do
- it 'raises NotImplementedError' do
- expect { model.search('foo') }.to raise_error(NotImplementedError)
+ describe ".search" do
+ it "raises NotImplementedError" do
+ expect { model.search("foo") }.to raise_error(NotImplementedError)
end
end
- describe '.optionally_search' do
- context 'when a query is given' do
- it 'delegates to the search method' do
+ describe ".optionally_search" do
+ context "when a query is given" do
+ it "delegates to the search method" do
expect(model)
.to receive(:search)
- .with('foo')
+ .with("foo")
- model.optionally_search('foo')
+ model.optionally_search("foo")
end
end
- context 'when no query is given' do
- it 'returns the current relation' do
+ context "when no query is given" do
+ it "returns the current relation" do
expect(model.optionally_search).to be_a_kind_of(ActiveRecord::Relation)
end
end
- context 'when an empty query is given' do
- it 'returns the current relation' do
- expect(model.optionally_search(''))
+ context "when an empty query is given" do
+ it "returns the current relation" do
+ expect(model.optionally_search(""))
.to be_a_kind_of(ActiveRecord::Relation)
end
end
diff --git a/spec/models/concerns/participable_spec.rb b/spec/models/concerns/participable_spec.rb
index 431f1482615..4fb5204474f 100644
--- a/spec/models/concerns/participable_spec.rb
+++ b/spec/models/concerns/participable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Participable do
let(:model) do
@@ -7,8 +7,8 @@ describe Participable do
end
end
- describe '.participant' do
- it 'adds the participant attributes to the existing list' do
+ describe ".participant" do
+ it "adds the participant attributes to the existing list" do
model.participant(:foo)
model.participant(:bar)
@@ -16,8 +16,8 @@ describe Participable do
end
end
- describe '#participants' do
- it 'returns the list of participants' do
+ describe "#participants" do
+ it "returns the list of participants" do
model.participant(:foo)
model.participant(:bar)
@@ -37,7 +37,7 @@ describe Participable do
expect(participants).to include(user3)
end
- it 'caches the raw list of participants' do
+ it "caches the raw list of participants" do
instance = model.new
user1 = build(:user)
@@ -47,7 +47,7 @@ describe Participable do
instance.participants(user1)
end
- it 'supports attributes returning another Participable' do
+ it "supports attributes returning another Participable" do
other_model = Class.new { include Participable }
other_model.participant(:bar)
@@ -66,15 +66,15 @@ describe Participable do
expect(instance.participants(user1)).to eq([user2])
end
- context 'when using a Proc as an attribute' do
- it 'calls the supplied Proc' do
+ context "when using a Proc as an attribute" do
+ it "calls the supplied Proc" do
user1 = build(:user)
project = build(:project, :public)
user_arg = nil
ext_arg = nil
- model.participant -> (user, ext) do
+ model.participant ->(user, ext) do
user_arg = user
ext_arg = ext
end
diff --git a/spec/models/concerns/presentable_spec.rb b/spec/models/concerns/presentable_spec.rb
index 941647a79fb..ce31c9193b8 100644
--- a/spec/models/concerns/presentable_spec.rb
+++ b/spec/models/concerns/presentable_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Presentable do
let(:build) { Ci::Build.new }
- describe '#present' do
- it 'returns a presenter' do
+ describe "#present" do
+ it "returns a presenter" do
expect(build.present).to be_a(Ci::BuildPresenter)
end
- it 'takes optional attributes' do
- expect(build.present(foo: 'bar').foo).to eq('bar')
+ it "takes optional attributes" do
+ expect(build.present(foo: "bar").foo).to eq("bar")
end
end
end
diff --git a/spec/models/concerns/project_features_compatibility_spec.rb b/spec/models/concerns/project_features_compatibility_spec.rb
index 9041690023f..b05f51c8656 100644
--- a/spec/models/concerns/project_features_compatibility_spec.rb
+++ b/spec/models/concerns/project_features_compatibility_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectFeaturesCompatibility do
let(:project) { create(:project) }
- let(:features) { %w(issues wiki builds merge_requests snippets) }
+ let(:features) { %w[issues wiki builds merge_requests snippets] }
# We had issues_enabled, snippets_enabled, builds_enabled, merge_requests_enabled and issues_enabled fields on projects table
# All those fields got moved to a new table called project_feature and are now integers instead of booleans
diff --git a/spec/models/concerns/prometheus_adapter_spec.rb b/spec/models/concerns/prometheus_adapter_spec.rb
index f4b9c57e71a..6b6681a1d69 100644
--- a/spec/models/concerns/prometheus_adapter_spec.rb
+++ b/spec/models/concerns/prometheus_adapter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
include PrometheusHelpers
@@ -14,32 +14,32 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
let(:described_class) { TestClass }
let(:environment_query) { Gitlab::Prometheus::Queries::EnvironmentQuery }
- describe '#query' do
- describe 'environment' do
- let(:environment) { build_stubbed(:environment, slug: 'env-slug') }
+ describe "#query" do
+ describe "environment" do
+ let(:environment) { build_stubbed(:environment, slug: "env-slug") }
around do |example|
Timecop.freeze { example.run }
end
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:environment, environment) }
before do
stub_reactive_cache(service, prometheus_data, environment_query, environment.id)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
is_expected.to eq(prometheus_metrics_data)
end
end
end
- describe 'matched_metrics' do
+ describe "matched_metrics" do
let(:matched_metrics_query) { Gitlab::Prometheus::Queries::MatchedMetricQuery }
let(:prometheus_client_wrapper) { double(:prometheus_client_wrapper, label_values: nil) }
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:matched_metrics) }
before do
@@ -47,14 +47,14 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
synchronous_reactive_cache(service)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
expect(subject[:success]).to be_truthy
expect(subject[:data]).to eq([])
end
end
end
- describe 'deployment' do
+ describe "deployment" do
let(:deployment) { build_stubbed(:deployment) }
let(:deployment_query) { Gitlab::Prometheus::Queries::DeploymentQuery }
@@ -62,22 +62,22 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
Timecop.freeze { example.run }
end
- context 'with valid data' do
+ context "with valid data" do
subject { service.query(:deployment, deployment) }
before do
stub_reactive_cache(service, prometheus_data, deployment_query, deployment.id)
end
- it 'returns reactive data' do
+ it "returns reactive data" do
expect(subject).to eq(prometheus_metrics_data)
end
end
end
end
- describe '#calculate_reactive_cache' do
- let(:environment) { create(:environment, slug: 'env-slug') }
+ describe "#calculate_reactive_cache" do
+ let(:environment) { create(:environment, slug: "env-slug") }
before do
service.manual_configuration = true
service.active = true
@@ -91,7 +91,7 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
Timecop.freeze { example.run }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
service.active = false
end
@@ -99,7 +99,7 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
- context 'when Prometheus responds with valid data' do
+ context "when Prometheus responds with valid data" do
before do
stub_all_prometheus_requests(environment.slug)
end
diff --git a/spec/models/concerns/protected_ref_access_spec.rb b/spec/models/concerns/protected_ref_access_spec.rb
index ce602337647..b328b74ca3e 100644
--- a/spec/models/concerns/protected_ref_access_spec.rb
+++ b/spec/models/concerns/protected_ref_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedRefAccess do
subject(:protected_ref_access) do
@@ -7,21 +7,21 @@ describe ProtectedRefAccess do
let(:project) { protected_ref_access.project }
- describe '#check_access' do
- it 'is always true for admins' do
+ describe "#check_access" do
+ it "is always true for admins" do
admin = create(:admin)
expect(protected_ref_access.check_access(admin)).to be_truthy
end
- it 'is true for maintainers' do
+ it "is true for maintainers" do
maintainer = create(:user)
project.add_maintainer(maintainer)
expect(protected_ref_access.check_access(maintainer)).to be_truthy
end
- it 'is for developers of the project' do
+ it "is for developers of the project" do
developer = create(:user)
project.add_developer(developer)
diff --git a/spec/models/concerns/reactive_caching_spec.rb b/spec/models/concerns/reactive_caching_spec.rb
index 03ae45e6b17..47522c81c0d 100644
--- a/spec/models/concerns/reactive_caching_spec.rb
+++ b/spec/models/concerns/reactive_caching_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ReactiveCaching, :use_clean_rails_memory_store_caching do
include ExclusiveLeaseHelpers
@@ -34,23 +34,23 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
let(:cache_key) { "foo:666" }
let(:instance) { CacheTest.new(666, &calculation) }
- describe '#with_reactive_cache' do
+ describe "#with_reactive_cache" do
before do
stub_reactive_cache
end
subject(:go!) { instance.result }
- context 'when cache is empty' do
+ context "when cache is empty" do
it { is_expected.to be_nil }
- it 'enqueues a background worker to bootstrap the cache' do
+ it "enqueues a background worker to bootstrap the cache" do
expect(ReactiveCachingWorker).to receive(:perform_async).with(CacheTest, 666)
go!
end
- it 'updates the cache lifespan' do
+ it "updates the cache lifespan" do
expect(reactive_cache_alive?(instance)).to be_falsy
go!
@@ -59,26 +59,26 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when the cache is full' do
+ context "when the cache is full" do
before do
stub_reactive_cache(instance, 4)
end
it { is_expected.to eq(4) }
- it 'does not enqueue a background worker' do
+ it "does not enqueue a background worker" do
expect(ReactiveCachingWorker).not_to receive(:perform_async)
go!
end
- it 'updates the cache lifespan' do
+ it "updates the cache lifespan" do
expect(Rails.cache).to receive(:write).with(alive_reactive_cache_key(instance), true, expires_in: anything)
go!
end
- context 'and expired' do
+ context "and expired" do
before do
invalidate_reactive_cache(instance)
end
@@ -86,8 +86,8 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
- context 'when cache was invalidated' do
- it 'refreshes cache' do
+ context "when cache was invalidated" do
+ it "refreshes cache" do
expect(ReactiveCachingWorker).to receive(:perform_async).with(CacheTest, 666)
instance.with_reactive_cache { raise described_class::InvalidateReactiveCache }
@@ -95,7 +95,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when cache contains non-nil but blank value' do
+ context "when cache contains non-nil but blank value" do
before do
stub_reactive_cache(instance, false)
end
@@ -104,7 +104,7 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- describe '#clear_reactive_cache!' do
+ describe "#clear_reactive_cache!" do
before do
stub_reactive_cache(instance, 4)
instance.clear_reactive_cache!
@@ -114,22 +114,22 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
it { expect(reactive_cache_alive?(instance)).to be_falsy }
end
- describe '#exclusively_update_reactive_cache!' do
+ describe "#exclusively_update_reactive_cache!" do
subject(:go!) { instance.exclusively_update_reactive_cache! }
- context 'when the lease is free and lifetime is not exceeded' do
+ context "when the lease is free and lifetime is not exceeded" do
before do
stub_reactive_cache(instance, "preexisting")
end
- it 'takes and releases the lease' do
- expect_to_obtain_exclusive_lease(cache_key, 'uuid')
- expect_to_cancel_exclusive_lease(cache_key, 'uuid')
+ it "takes and releases the lease" do
+ expect_to_obtain_exclusive_lease(cache_key, "uuid")
+ expect_to_cancel_exclusive_lease(cache_key, "uuid")
go!
end
- it 'caches the result of #calculate_reactive_cache' do
+ it "caches the result of #calculate_reactive_cache" do
go!
expect(read_reactive_cache(instance)).to eq(calculation.call)
@@ -148,19 +148,19 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
2.times { instance.exclusively_update_reactive_cache! }
end
- context 'and #calculate_reactive_cache raises an exception' do
+ context "and #calculate_reactive_cache raises an exception" do
before do
stub_reactive_cache(instance, "preexisting")
end
let(:calculation) { -> { raise "foo"} }
- it 'leaves the cache untouched' do
+ it "leaves the cache untouched" do
expect { go! }.to raise_error("foo")
expect(read_reactive_cache(instance)).to eq("preexisting")
end
- it 'enqueues a repeat worker' do
+ it "enqueues a repeat worker" do
expect_reactive_cache_update_queued(instance)
expect { go! }.to raise_error("foo")
@@ -168,16 +168,16 @@ describe ReactiveCaching, :use_clean_rails_memory_store_caching do
end
end
- context 'when lifetime is exceeded' do
- it 'skips the calculation' do
+ context "when lifetime is exceeded" do
+ it "skips the calculation" do
expect(instance).to receive(:calculate_reactive_cache).never
go!
end
end
- context 'when the lease is already taken' do
- it 'skips the calculation' do
+ context "when the lease is already taken" do
+ it "skips the calculation" do
stub_exclusive_lease_taken(cache_key)
expect(instance).to receive(:calculate_reactive_cache).never
diff --git a/spec/models/concerns/redactable_spec.rb b/spec/models/concerns/redactable_spec.rb
index 7feeaa54069..156893fcc50 100644
--- a/spec/models/concerns/redactable_spec.rb
+++ b/spec/models/concerns/redactable_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Redactable do
before do
stub_commonmark_sourcepos_disabled
end
- shared_examples 'model with redactable field' do
- it 'redacts unsubscribe token' do
- model[field] = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
+ shared_examples "model with redactable field" do
+ it "redacts unsubscribe token" do
+ model[field] = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
model.save!
- expect(model[field]).to eq 'some text /sent_notifications/REDACTED/unsubscribe more text'
+ expect(model[field]).to eq "some text /sent_notifications/REDACTED/unsubscribe more text"
end
- it 'ignores not hexadecimal tokens' do
- text = 'some text /sent_notifications/token/unsubscribe more text'
+ it "ignores not hexadecimal tokens" do
+ text = "some text /sent_notifications/token/unsubscribe more text"
model[field] = text
model.save!
@@ -23,8 +23,8 @@ describe Redactable do
expect(model[field]).to eq text
end
- it 'ignores not matching texts' do
- text = 'some text /sent_notifications/.*/unsubscribe more text'
+ it "ignores not matching texts" do
+ text = "some text /sent_notifications/.*/unsubscribe more text"
model[field] = text
model.save!
@@ -32,40 +32,40 @@ describe Redactable do
expect(model[field]).to eq text
end
- it 'redacts the field when saving the model before creating markdown cache' do
- model[field] = 'some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text'
+ it "redacts the field when saving the model before creating markdown cache" do
+ model[field] = "some text /sent_notifications/00000000000000000000000000000000/unsubscribe more text"
model.save!
- expected = 'some text /sent_notifications/REDACTED/unsubscribe more text'
+ expected = "some text /sent_notifications/REDACTED/unsubscribe more text"
expect(model[field]).to eq expected
expect(model["#{field}_html"]).to eq "<p dir=\"auto\">#{expected}</p>"
end
end
- context 'when model is an issue' do
- it_behaves_like 'model with redactable field' do
+ context "when model is an issue" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:issue) }
let(:field) { :description }
end
end
- context 'when model is a merge request' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a merge request" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:merge_request) }
let(:field) { :description }
end
end
- context 'when model is a note' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a note" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:note) }
let(:field) { :note }
end
end
- context 'when model is a snippet' do
- it_behaves_like 'model with redactable field' do
+ context "when model is a snippet" do
+ it_behaves_like "model with redactable field" do
let(:model) { create(:snippet) }
let(:field) { :description }
end
diff --git a/spec/models/concerns/redis_cacheable_spec.rb b/spec/models/concerns/redis_cacheable_spec.rb
index 23c6c6233e9..7e1efb8af04 100644
--- a/spec/models/concerns/redis_cacheable_spec.rb
+++ b/spec/models/concerns/redis_cacheable_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RedisCacheable do
let(:model) do
@@ -12,12 +12,12 @@ describe RedisCacheable do
end
def has_attribute?(attribute)
- attributes.has_key?(attribute)
+ attributes.key?(attribute)
end
end
end
- let(:payload) { { name: 'value', time: Time.zone.now } }
+ let(:payload) { {name: "value", time: Time.zone.now} }
let(:instance) { model.new(1, payload) }
let(:cache_key) { instance.__send__(:cache_attribute_key) }
@@ -25,10 +25,10 @@ describe RedisCacheable do
model.include(described_class)
end
- describe '#cached_attribute' do
+ describe "#cached_attribute" do
subject { instance.cached_attribute(payload.keys.first) }
- it 'gets the cache attribute' do
+ it "gets the cache attribute" do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).to receive(:get).with(cache_key)
.and_return(payload.to_json)
@@ -38,10 +38,10 @@ describe RedisCacheable do
end
end
- describe '#cache_attributes' do
+ describe "#cache_attributes" do
subject { instance.cache_attributes(payload) }
- it 'sets the cache attributes' do
+ it "sets the cache attributes" do
Gitlab::Redis::SharedState.with do |redis|
expect(redis).to receive(:set).with(cache_key, payload.to_json, anything)
end
@@ -50,23 +50,23 @@ describe RedisCacheable do
end
end
- describe '#cached_attr_reader', :clean_gitlab_redis_shared_state do
+ describe "#cached_attr_reader", :clean_gitlab_redis_shared_state do
subject { instance.name }
before do
model.cached_attr_reader(:name)
end
- context 'when there is no cached value' do
- it 'reads the attribute' do
+ context "when there is no cached value" do
+ it "reads the attribute" do
expect(instance).to receive(:read_attribute).and_call_original
expect(subject).to eq(payload[:name])
end
end
- context 'when there is a cached value' do
- it 'reads the cached value' do
+ context "when there is a cached value" do
+ it "reads the cached value" do
expect(instance).not_to receive(:read_attribute)
instance.cache_attributes(payload)
@@ -75,24 +75,24 @@ describe RedisCacheable do
end
end
- it 'always returns the latest values' do
+ it "always returns the latest values" do
expect(instance.name).to eq(payload[:name])
- instance.cache_attributes(name: 'new_value')
+ instance.cache_attributes(name: "new_value")
- expect(instance.name).to eq('new_value')
+ expect(instance.name).to eq("new_value")
end
end
- describe '#cast_value_from_cache' do
+ describe "#cast_value_from_cache" do
subject { instance.__send__(:cast_value_from_cache, attribute, value) }
- context 'with runner contacted_at' do
+ context "with runner contacted_at" do
let(:instance) { Ci::Runner.new }
let(:attribute) { :contacted_at }
- let(:value) { '2018-05-07 13:53:08 UTC' }
+ let(:value) { "2018-05-07 13:53:08 UTC" }
- it 'converts cache string to appropriate type' do
+ it "converts cache string to appropriate type" do
expect(subject).to be_an_instance_of(ActiveSupport::TimeWithZone)
end
end
diff --git a/spec/models/concerns/relative_positioning_spec.rb b/spec/models/concerns/relative_positioning_spec.rb
index ac8da30b6c9..53adf192524 100644
--- a/spec/models/concerns/relative_positioning_spec.rb
+++ b/spec/models/concerns/relative_positioning_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RelativePositioning do
let(:project) { create(:project) }
@@ -6,8 +6,8 @@ describe RelativePositioning do
let(:issue1) { create(:issue, project: project) }
let(:new_issue) { create(:issue, project: project) }
- describe '.move_to_end' do
- it 'moves the object to the end' do
+ describe ".move_to_end" do
+ it "moves the object to the end" do
Issue.move_to_end([issue, issue1])
expect(issue1.prev_relative_position).to eq issue.relative_position
@@ -15,7 +15,7 @@ describe RelativePositioning do
expect(issue1.next_relative_position).to eq nil
end
- it 'does not perform any moves if all issues have their relative_position set' do
+ it "does not perform any moves if all issues have their relative_position set" do
issue.update!(relative_position: 1)
expect(issue).not_to receive(:save)
@@ -24,34 +24,34 @@ describe RelativePositioning do
end
end
- describe '#max_relative_position' do
- it 'returns maximum position' do
+ describe "#max_relative_position" do
+ it "returns maximum position" do
expect(issue.max_relative_position).to eq issue1.relative_position
end
end
- describe '#prev_relative_position' do
- it 'returns previous position if there is an issue above' do
+ describe "#prev_relative_position" do
+ it "returns previous position if there is an issue above" do
expect(issue1.prev_relative_position).to eq issue.relative_position
end
- it 'returns nil if there is no issue above' do
+ it "returns nil if there is no issue above" do
expect(issue.prev_relative_position).to eq nil
end
end
- describe '#next_relative_position' do
- it 'returns next position if there is an issue below' do
+ describe "#next_relative_position" do
+ it "returns next position if there is an issue below" do
expect(issue.next_relative_position).to eq issue1.relative_position
end
- it 'returns nil if there is no issue below' do
+ it "returns nil if there is no issue below" do
expect(issue1.next_relative_position).to eq nil
end
end
- describe '#move_before' do
- it 'moves issue before' do
+ describe "#move_before" do
+ it "moves issue before" do
[issue1, issue].each(&:move_to_end)
issue.move_before(issue1)
@@ -60,8 +60,8 @@ describe RelativePositioning do
end
end
- describe '#move_after' do
- it 'moves issue after' do
+ describe "#move_after" do
+ it "moves issue after" do
[issue, issue1].each(&:move_to_end)
issue.move_after(issue1)
@@ -70,87 +70,87 @@ describe RelativePositioning do
end
end
- describe '#move_to_end' do
+ describe "#move_to_end" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'moves issue to the end' do
+ it "moves issue to the end" do
new_issue.move_to_end
expect(new_issue.relative_position).to be > issue1.relative_position
end
end
- describe '#shift_after?' do
+ describe "#shift_after?" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'returns true' do
+ it "returns true" do
issue.update(relative_position: issue1.relative_position - 1)
expect(issue.shift_after?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
issue.update(relative_position: issue1.relative_position - 2)
expect(issue.shift_after?).to be_falsey
end
end
- describe '#shift_before?' do
+ describe "#shift_before?" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'returns true' do
+ it "returns true" do
issue.update(relative_position: issue1.relative_position + 1)
expect(issue.shift_before?).to be_truthy
end
- it 'returns false' do
+ it "returns false" do
issue.update(relative_position: issue1.relative_position + 2)
expect(issue.shift_before?).to be_falsey
end
end
- describe '#move_between' do
+ describe "#move_between" do
before do
[issue, issue1].each do |issue|
issue.move_to_end && issue.save
end
end
- it 'positions issue between two other' do
+ it "positions issue between two other" do
new_issue.move_between(issue, issue1)
expect(new_issue.relative_position).to be > issue.relative_position
expect(new_issue.relative_position).to be < issue1.relative_position
end
- it 'positions issue between on top' do
+ it "positions issue between on top" do
new_issue.move_between(nil, issue)
expect(new_issue.relative_position).to be < issue.relative_position
end
- it 'positions issue between to end' do
+ it "positions issue between to end" do
new_issue.move_between(issue1, nil)
expect(new_issue.relative_position).to be > issue1.relative_position
end
- it 'positions issues even when after and before positions are the same' do
+ it "positions issues even when after and before positions are the same" do
issue1.update relative_position: issue.relative_position
new_issue.move_between(issue, issue1)
@@ -159,7 +159,7 @@ describe RelativePositioning do
expect(issue.relative_position).to be < issue1.relative_position
end
- it 'positions issues between other two if distance is 1' do
+ it "positions issues between other two if distance is 1" do
issue1.update relative_position: issue.relative_position + 1
new_issue.move_between(issue, issue1)
@@ -168,7 +168,7 @@ describe RelativePositioning do
expect(issue.relative_position).to be < issue1.relative_position
end
- it 'positions issue in the middle of other two if distance is big enough' do
+ it "positions issue in the middle of other two if distance is big enough" do
issue.update relative_position: 6000
issue1.update relative_position: 10000
@@ -177,7 +177,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(8000)
end
- it 'positions issue closer to the middle if we are at the very top' do
+ it "positions issue closer to the middle if we are at the very top" do
issue1.update relative_position: 6000
new_issue.move_between(nil, issue1)
@@ -185,7 +185,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(6000 - RelativePositioning::IDEAL_DISTANCE)
end
- it 'positions issue closer to the middle if we are at the very bottom' do
+ it "positions issue closer to the middle if we are at the very bottom" do
issue.update relative_position: 6000
issue1.update relative_position: nil
@@ -194,7 +194,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(6000 + RelativePositioning::IDEAL_DISTANCE)
end
- it 'positions issue in the middle of other two if distance is not big enough' do
+ it "positions issue in the middle of other two if distance is not big enough" do
issue.update relative_position: 100
issue1.update relative_position: 400
@@ -203,7 +203,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to eq(250)
end
- it 'positions issue in the middle of other two is there is no place' do
+ it "positions issue in the middle of other two is there is no place" do
issue.update relative_position: 100
issue1.update relative_position: 101
@@ -212,7 +212,7 @@ describe RelativePositioning do
expect(new_issue.relative_position).to be_between(issue.relative_position, issue1.relative_position)
end
- it 'uses rebalancing if there is no place' do
+ it "uses rebalancing if there is no place" do
issue.update relative_position: 100
issue1.update relative_position: 101
issue2 = create(:issue, relative_position: 102, project: project)
@@ -225,7 +225,7 @@ describe RelativePositioning do
expect(issue.reload.relative_position).not_to eq(100)
end
- it 'positions issue right if we pass none-sequential parameters' do
+ it "positions issue right if we pass none-sequential parameters" do
issue.update relative_position: 99
issue1.update relative_position: 101
issue2 = create(:issue, relative_position: 102, project: project)
diff --git a/spec/models/concerns/resolvable_discussion_spec.rb b/spec/models/concerns/resolvable_discussion_spec.rb
index 97b046b0f21..45d689c731f 100644
--- a/spec/models/concerns/resolvable_discussion_spec.rb
+++ b/spec/models/concerns/resolvable_discussion_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Discussion, ResolvableDiscussion do
subject { described_class.new([first_note, second_note, third_note]) }
diff --git a/spec/models/concerns/resolvable_note_spec.rb b/spec/models/concerns/resolvable_note_spec.rb
index fcb5250278e..6800688b84c 100644
--- a/spec/models/concerns/resolvable_note_spec.rb
+++ b/spec/models/concerns/resolvable_note_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Note, ResolvableNote do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
subject { create(:discussion_note_on_merge_request, noteable: merge_request, project: project) }
- context 'resolvability scopes' do
+ context "resolvability scopes" do
let!(:note1) { create(:note, project: project) }
let!(:note2) { create(:diff_note_on_commit, project: project) }
let!(:note3) { create(:diff_note_on_merge_request, :resolved, noteable: merge_request, project: project) }
@@ -13,26 +13,26 @@ describe Note, ResolvableNote do
let!(:note5) { create(:discussion_note_on_issue, project: project) }
let!(:note6) { create(:discussion_note_on_merge_request, :system, noteable: merge_request, project: project) }
- describe '.potentially_resolvable' do
- it 'includes diff and discussion notes on merge requests' do
+ describe ".potentially_resolvable" do
+ it "includes diff and discussion notes on merge requests" do
expect(Note.potentially_resolvable).to match_array([note3, note4, note6])
end
end
- describe '.resolvable' do
- it 'includes non-system diff and discussion notes on merge requests' do
+ describe ".resolvable" do
+ it "includes non-system diff and discussion notes on merge requests" do
expect(Note.resolvable).to match_array([note3, note4])
end
end
- describe '.resolved' do
- it 'includes resolved non-system diff and discussion notes on merge requests' do
+ describe ".resolved" do
+ it "includes resolved non-system diff and discussion notes on merge requests" do
expect(Note.resolved).to match_array([note3])
end
end
- describe '.unresolved' do
- it 'includes non-resolved non-system diff and discussion notes on merge requests' do
+ describe ".unresolved" do
+ it "includes non-resolved non-system diff and discussion notes on merge requests" do
expect(Note.unresolved).to match_array([note4])
end
end
@@ -52,7 +52,7 @@ describe Note, ResolvableNote do
unresolved_note.reload
end
- it 'resolves only the resolvable, not yet resolved notes' do
+ it "resolves only the resolvable, not yet resolved notes" do
expect(commit_note.resolved_at).to be_nil
expect(resolved_note.resolved_by).not_to eq(current_user)
expect(unresolved_note.resolved_at).not_to be_nil
@@ -69,13 +69,13 @@ describe Note, ResolvableNote do
resolved_note.reload
end
- it 'unresolves the resolved notes' do
+ it "unresolves the resolved notes" do
expect(resolved_note.resolved_by).to be_nil
expect(resolved_note.resolved_at).to be_nil
end
end
- describe '#resolvable?' do
+ describe "#resolvable?" do
context "when potentially resolvable" do
before do
allow(subject).to receive(:potentially_resolvable?).and_return(true)
@@ -150,31 +150,31 @@ describe Note, ResolvableNote do
describe "#resolved?" do
let(:current_user) { create(:user) }
- context 'when not resolvable' do
+ context "when not resolvable" do
before do
subject.resolve!(current_user)
allow(subject).to receive(:resolvable?).and_return(false)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.resolved?).to be_falsey
end
end
- context 'when resolvable' do
- context 'when the note has been resolved' do
+ context "when resolvable" do
+ context "when the note has been resolved" do
before do
subject.resolve!(current_user)
end
- it 'returns true' do
+ it "returns true" do
expect(subject.resolved?).to be_truthy
end
end
- context 'when the note has not been resolved' do
- it 'returns false' do
+ context "when the note has not been resolved" do
+ it "returns false" do
expect(subject.resolved?).to be_falsey
end
end
@@ -328,7 +328,7 @@ describe Note, ResolvableNote do
end
describe "#potentially_resolvable?" do
- it 'returns false if noteable could not be found' do
+ it "returns false if noteable could not be found" do
allow(subject).to receive(:noteable).and_return(nil)
expect(subject.potentially_resolvable?).to be_falsey
diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb
index 565266321d3..8d5566407bf 100644
--- a/spec/models/concerns/routable_spec.rb
+++ b/spec/models/concerns/routable_spec.rb
@@ -1,82 +1,82 @@
-require 'spec_helper'
+require "spec_helper"
-describe Group, 'Routable' do
- let!(:group) { create(:group, name: 'foo') }
+describe Group, "Routable" do
+ let!(:group) { create(:group, name: "foo") }
- describe 'Validations' do
+ describe "Validations" do
it { is_expected.to validate_presence_of(:route) }
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to have_one(:route).dependent(:destroy) }
it { is_expected.to have_many(:redirect_routes).dependent(:destroy) }
end
- describe 'Callbacks' do
- it 'creates route record on create' do
+ describe "Callbacks" do
+ it "creates route record on create" do
expect(group.route.path).to eq(group.path)
expect(group.route.name).to eq(group.name)
end
- it 'updates route record on path change' do
- group.update(path: 'wow', name: 'much')
+ it "updates route record on path change" do
+ group.update(path: "wow", name: "much")
- expect(group.route.path).to eq('wow')
- expect(group.route.name).to eq('much')
+ expect(group.route.path).to eq("wow")
+ expect(group.route.name).to eq("much")
end
- it 'ensure route path uniqueness across different objects' do
- create(:group, parent: group, path: 'xyz')
- duplicate = build(:project, namespace: group, path: 'xyz')
+ it "ensure route path uniqueness across different objects" do
+ create(:group, parent: group, path: "xyz")
+ duplicate = build(:project, namespace: group, path: "xyz")
- expect { duplicate.save! }.to raise_error(ActiveRecord::RecordInvalid, 'Validation failed: Path has already been taken')
+ expect { duplicate.save! }.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Path has already been taken")
end
end
- describe '.find_by_full_path' do
+ describe ".find_by_full_path" do
let!(:nested_group) { create(:group, parent: group) }
- context 'without any redirect routes' do
+ context "without any redirect routes" do
it { expect(described_class.find_by_full_path(group.to_param)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param)).to eq(nested_group) }
- it { expect(described_class.find_by_full_path('unknown')).to eq(nil) }
+ it { expect(described_class.find_by_full_path("unknown")).to eq(nil) }
end
- context 'with redirect routes' do
- let!(:group_redirect_route) { group.redirect_routes.create!(path: 'bar') }
- let!(:nested_group_redirect_route) { nested_group.redirect_routes.create!(path: nested_group.path.sub('foo', 'bar')) }
+ context "with redirect routes" do
+ let!(:group_redirect_route) { group.redirect_routes.create!(path: "bar") }
+ let!(:nested_group_redirect_route) { nested_group.redirect_routes.create!(path: nested_group.path.sub("foo", "bar")) }
- context 'without follow_redirects option' do
- context 'with the given path not matching any route' do
- it { expect(described_class.find_by_full_path('unknown')).to eq(nil) }
+ context "without follow_redirects option" do
+ context "with the given path not matching any route" do
+ it { expect(described_class.find_by_full_path("unknown")).to eq(nil) }
end
- context 'with the given path matching the canonical route' do
+ context "with the given path matching the canonical route" do
it { expect(described_class.find_by_full_path(group.to_param)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param)).to eq(nested_group) }
end
- context 'with the given path matching a redirect route' do
+ context "with the given path matching a redirect route" do
it { expect(described_class.find_by_full_path(group_redirect_route.path)).to eq(nil) }
it { expect(described_class.find_by_full_path(group_redirect_route.path.upcase)).to eq(nil) }
it { expect(described_class.find_by_full_path(nested_group_redirect_route.path)).to eq(nil) }
end
end
- context 'with follow_redirects option set to true' do
- context 'with the given path not matching any route' do
- it { expect(described_class.find_by_full_path('unknown', follow_redirects: true)).to eq(nil) }
+ context "with follow_redirects option set to true" do
+ context "with the given path not matching any route" do
+ it { expect(described_class.find_by_full_path("unknown", follow_redirects: true)).to eq(nil) }
end
- context 'with the given path matching the canonical route' do
+ context "with the given path matching the canonical route" do
it { expect(described_class.find_by_full_path(group.to_param, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(group.to_param.upcase, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group.to_param, follow_redirects: true)).to eq(nested_group) }
end
- context 'with the given path matching a redirect route' do
+ context "with the given path matching a redirect route" do
it { expect(described_class.find_by_full_path(group_redirect_route.path, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(group_redirect_route.path.upcase, follow_redirects: true)).to eq(group) }
it { expect(described_class.find_by_full_path(nested_group_redirect_route.path, follow_redirects: true)).to eq(nested_group) }
@@ -85,29 +85,29 @@ describe Group, 'Routable' do
end
end
- describe '.where_full_path_in' do
- context 'without any paths' do
- it 'returns an empty relation' do
+ describe ".where_full_path_in" do
+ context "without any paths" do
+ it "returns an empty relation" do
expect(described_class.where_full_path_in([])).to eq([])
end
end
- context 'without any valid paths' do
- it 'returns an empty relation' do
+ context "without any valid paths" do
+ it "returns an empty relation" do
expect(described_class.where_full_path_in(%w[unknown])).to eq([])
end
end
- context 'with valid paths' do
+ context "with valid paths" do
let!(:nested_group) { create(:group, parent: group) }
- it 'returns the projects matching the paths' do
+ it "returns the projects matching the paths" do
result = described_class.where_full_path_in([group.to_param, nested_group.to_param])
expect(result).to contain_exactly(group, nested_group)
end
- it 'returns projects regardless of the casing of paths' do
+ it "returns projects regardless of the casing of paths" do
result = described_class.where_full_path_in([group.to_param.upcase, nested_group.to_param.upcase])
expect(result).to contain_exactly(group, nested_group)
@@ -115,7 +115,7 @@ describe Group, 'Routable' do
end
end
- describe '#full_path' do
+ describe "#full_path" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
@@ -123,7 +123,7 @@ describe Group, 'Routable' do
it { expect(nested_group.full_path).to eq("#{group.full_path}/#{nested_group.path}") }
end
- describe '#full_name' do
+ describe "#full_name" do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
@@ -132,14 +132,14 @@ describe Group, 'Routable' do
end
end
-describe Project, 'Routable' do
- describe '#full_path' do
+describe Project, "Routable" do
+ describe "#full_path" do
let(:project) { build_stubbed(:project) }
it { expect(project.full_path).to eq "#{project.namespace.full_path}/#{project.path}" }
end
- describe '#full_name' do
+ describe "#full_name" do
let(:project) { build_stubbed(:project) }
it { expect(project.full_name).to eq "#{project.namespace.human_name} / #{project.name}" }
diff --git a/spec/models/concerns/sha_attribute_spec.rb b/spec/models/concerns/sha_attribute_spec.rb
index 0d3beb6a6e3..8675af673c0 100644
--- a/spec/models/concerns/sha_attribute_spec.rb
+++ b/spec/models/concerns/sha_attribute_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe ShaAttribute do
let(:model) { Class.new { include ShaAttribute } }
before do
columns = [
- double(:column, name: 'name', type: :text),
- double(:column, name: 'sha1', type: :binary)
+ double(:column, name: "name", type: :text),
+ double(:column, name: "sha1", type: :binary),
]
allow(model).to receive(:columns).and_return(columns)
end
- describe '#sha_attribute' do
- context 'when in non-production' do
+ describe "#sha_attribute" do
+ context "when in non-production" do
before do
allow(Rails.env).to receive(:production?).and_return(false)
end
- context 'when the table exists' do
+ context "when the table exists" do
before do
allow(model).to receive(:table_exists?).and_return(true)
end
- it 'defines a SHA attribute for a binary column' do
+ it "defines a SHA attribute for a binary column" do
expect(model).to receive(:attribute)
.with(:sha1, an_instance_of(Gitlab::Database::ShaAttribute))
model.sha_attribute(:sha1)
end
- it 'raises ArgumentError when the column type is not :binary' do
+ it "raises ArgumentError when the column type is not :binary" do
expect { model.sha_attribute(:name) }.to raise_error(ArgumentError)
end
end
- context 'when the table does not exist' do
- it 'allows the attribute to be added and issues a warning' do
+ context "when the table does not exist" do
+ it "allows the attribute to be added and issues a warning" do
allow(model).to receive(:table_exists?).and_return(false)
expect(model).not_to receive(:columns)
@@ -47,8 +47,8 @@ describe ShaAttribute do
end
end
- context 'when the column does not exist' do
- it 'allows the attribute to be added and issues a warning' do
+ context "when the column does not exist" do
+ it "allows the attribute to be added and issues a warning" do
allow(model).to receive(:table_exists?).and_return(true)
expect(model).to receive(:columns)
@@ -59,9 +59,9 @@ describe ShaAttribute do
end
end
- context 'when other execeptions are raised' do
- it 'logs and re-rasises the error' do
- allow(model).to receive(:table_exists?).and_raise(ActiveRecord::NoDatabaseError.new('does not exist'))
+ context "when other execeptions are raised" do
+ it "logs and re-rasises the error" do
+ allow(model).to receive(:table_exists?).and_raise(ActiveRecord::NoDatabaseError.new("does not exist"))
expect(model).not_to receive(:columns)
expect(model).not_to receive(:attribute)
@@ -72,12 +72,12 @@ describe ShaAttribute do
end
end
- context 'when in production' do
+ context "when in production" do
before do
allow(Rails.env).to receive(:production?).and_return(true)
end
- it 'defines a SHA attribute' do
+ it "defines a SHA attribute" do
expect(model).not_to receive(:table_exists?)
expect(model).not_to receive(:columns)
expect(model).to receive(:attribute).with(:sha1, an_instance_of(Gitlab::Database::ShaAttribute))
diff --git a/spec/models/concerns/sortable_spec.rb b/spec/models/concerns/sortable_spec.rb
index 0a9d2021a19..c253f465b88 100644
--- a/spec/models/concerns/sortable_spec.rb
+++ b/spec/models/concerns/sortable_spec.rb
@@ -1,118 +1,118 @@
-require 'spec_helper'
+require "spec_helper"
describe Sortable do
- describe '.order_by' do
+ describe ".order_by" do
let(:relation) { Group.all }
- describe 'ordering by id' do
- it 'ascending' do
+ describe "ordering by id" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(id: :asc)
- relation.order_by('id_asc')
+ relation.order_by("id_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(id: :desc)
- relation.order_by('id_desc')
+ relation.order_by("id_desc")
end
end
- describe 'ordering by created day' do
- it 'ascending' do
+ describe "ordering by created day" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(created_at: :asc)
- relation.order_by('created_asc')
+ relation.order_by("created_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(created_at: :desc)
- relation.order_by('created_desc')
+ relation.order_by("created_desc")
end
it 'order by "date"' do
expect(relation).to receive(:reorder).with(created_at: :desc)
- relation.order_by('created_date')
+ relation.order_by("created_date")
end
end
- describe 'ordering by name' do
- it 'ascending' do
+ describe "ordering by name" do
+ it "ascending" do
expect(relation).to receive(:reorder).once.and_call_original
table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces))
column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name))
- sql = relation.order_by('name_asc').to_sql
+ sql = relation.order_by("name_asc").to_sql
expect(sql).to match /.+ORDER BY LOWER\(#{table}.#{column}\) ASC\z/
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).once.and_call_original
table = Regexp.escape(ActiveRecord::Base.connection.quote_table_name(:namespaces))
column = Regexp.escape(ActiveRecord::Base.connection.quote_column_name(:name))
- sql = relation.order_by('name_desc').to_sql
+ sql = relation.order_by("name_desc").to_sql
expect(sql).to match /.+ORDER BY LOWER\(#{table}.#{column}\) DESC\z/
end
end
- describe 'ordering by Updated Time' do
- it 'ascending' do
+ describe "ordering by Updated Time" do
+ it "ascending" do
expect(relation).to receive(:reorder).with(updated_at: :asc)
- relation.order_by('updated_asc')
+ relation.order_by("updated_asc")
end
- it 'descending' do
+ it "descending" do
expect(relation).to receive(:reorder).with(updated_at: :desc)
- relation.order_by('updated_desc')
+ relation.order_by("updated_desc")
end
end
- it 'does not call reorder in case of unrecognized ordering' do
+ it "does not call reorder in case of unrecognized ordering" do
expect(relation).not_to receive(:reorder)
- relation.order_by('random_ordering')
+ relation.order_by("random_ordering")
end
end
- describe 'sorting groups' do
+ describe "sorting groups" do
def ordered_group_names(order)
Group.all.order_by(order).map(&:name)
end
- let!(:ref_time) { Time.parse('2018-05-01 00:00:00') }
- let!(:group1) { create(:group, name: 'aa', id: 1, created_at: ref_time - 15.seconds, updated_at: ref_time) }
- let!(:group2) { create(:group, name: 'AAA', id: 2, created_at: ref_time - 10.seconds, updated_at: ref_time - 5.seconds) }
- let!(:group3) { create(:group, name: 'BB', id: 3, created_at: ref_time - 5.seconds, updated_at: ref_time - 10.seconds) }
- let!(:group4) { create(:group, name: 'bbb', id: 4, created_at: ref_time, updated_at: ref_time - 15.seconds) }
+ let!(:ref_time) { Time.parse("2018-05-01 00:00:00") }
+ let!(:group1) { create(:group, name: "aa", id: 1, created_at: ref_time - 15.seconds, updated_at: ref_time) }
+ let!(:group2) { create(:group, name: "AAA", id: 2, created_at: ref_time - 10.seconds, updated_at: ref_time - 5.seconds) }
+ let!(:group3) { create(:group, name: "BB", id: 3, created_at: ref_time - 5.seconds, updated_at: ref_time - 10.seconds) }
+ let!(:group4) { create(:group, name: "bbb", id: 4, created_at: ref_time, updated_at: ref_time - 15.seconds) }
- it 'sorts groups by id' do
- expect(ordered_group_names('id_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('id_desc')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by id" do
+ expect(ordered_group_names("id_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("id_desc")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by name via case-insensitive comparision' do
- expect(ordered_group_names('name_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('name_desc')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by name via case-insensitive comparision" do
+ expect(ordered_group_names("name_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("name_desc")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by created_at' do
- expect(ordered_group_names('created_asc')).to eq(%w(aa AAA BB bbb))
- expect(ordered_group_names('created_desc')).to eq(%w(bbb BB AAA aa))
- expect(ordered_group_names('created_date')).to eq(%w(bbb BB AAA aa))
+ it "sorts groups by created_at" do
+ expect(ordered_group_names("created_asc")).to eq(%w[aa AAA BB bbb])
+ expect(ordered_group_names("created_desc")).to eq(%w[bbb BB AAA aa])
+ expect(ordered_group_names("created_date")).to eq(%w[bbb BB AAA aa])
end
- it 'sorts groups by updated_at' do
- expect(ordered_group_names('updated_asc')).to eq(%w(bbb BB AAA aa))
- expect(ordered_group_names('updated_desc')).to eq(%w(aa AAA BB bbb))
+ it "sorts groups by updated_at" do
+ expect(ordered_group_names("updated_asc")).to eq(%w[bbb BB AAA aa])
+ expect(ordered_group_names("updated_desc")).to eq(%w[aa AAA BB bbb])
end
end
end
diff --git a/spec/models/concerns/spammable_spec.rb b/spec/models/concerns/spammable_spec.rb
index e698207166c..d9bc03f651d 100644
--- a/spec/models/concerns/spammable_spec.rb
+++ b/spec/models/concerns/spammable_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe Spammable do
- let(:issue) { create(:issue, description: 'Test Desc.') }
+ let(:issue) { create(:issue, description: "Test Desc.") }
- describe 'Associations' do
+ describe "Associations" do
subject { build(:issue) }
it { is_expected.to have_one(:user_agent_detail).dependent(:destroy) }
end
- describe 'ClassMethods' do
- it 'should return correct attr_spammable' do
+ describe "ClassMethods" do
+ it "should return correct attr_spammable" do
expect(issue.spammable_text).to eq("#{issue.title}\n#{issue.description}")
end
end
- describe 'InstanceMethods' do
+ describe "InstanceMethods" do
let(:issue) { build(:issue, spam: true) }
- it 'should be invalid if spam' do
+ it "should be invalid if spam" do
expect(issue.valid?).to be_falsey
end
- describe '#check_for_spam?' do
- it 'returns true for public project' do
+ describe "#check_for_spam?" do
+ it "returns true for public project" do
issue.project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC)
expect(issue.check_for_spam?).to eq(true)
end
- it 'returns false for other visibility levels' do
+ it "returns false for other visibility levels" do
expect(issue.check_for_spam?).to eq(false)
end
end
- describe '#submittable_as_spam_by?' do
+ describe "#submittable_as_spam_by?" do
let(:admin) { build(:admin) }
let(:user) { build(:user) }
@@ -42,7 +42,7 @@ describe Spammable do
allow(issue).to receive(:submittable_as_spam?).and_return(true)
end
- it 'tests if the user can submit spam' do
+ it "tests if the user can submit spam" do
expect(issue.submittable_as_spam_by?(admin)).to be(true)
expect(issue.submittable_as_spam_by?(user)).to be(false)
expect(issue.submittable_as_spam_by?(nil)).to be_nil
diff --git a/spec/models/concerns/strip_attribute_spec.rb b/spec/models/concerns/strip_attribute_spec.rb
index 8c945686b66..93e2ff3a2bf 100644
--- a/spec/models/concerns/strip_attribute_spec.rb
+++ b/spec/models/concerns/strip_attribute_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe StripAttribute do
let(:milestone) { create(:milestone) }
@@ -10,10 +10,10 @@ describe StripAttribute do
describe "#strip_attributes" do
before do
- milestone.title = ' 8.3 '
+ milestone.title = " 8.3 "
milestone.valid?
end
- it { expect(milestone.title).to eq('8.3') }
+ it { expect(milestone.title).to eq("8.3") }
end
end
diff --git a/spec/models/concerns/subscribable_spec.rb b/spec/models/concerns/subscribable_spec.rb
index 45dfb136aea..7bdeabbef9a 100644
--- a/spec/models/concerns/subscribable_spec.rb
+++ b/spec/models/concerns/subscribable_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
-describe Subscribable, 'Subscribable' do
+describe Subscribable, "Subscribable" do
let(:project) { create(:project) }
let(:resource) { create(:issue, project: project) }
let(:user_1) { create(:user) }
- describe '#subscribed?' do
- context 'without user' do
- it 'returns false' do
+ describe "#subscribed?" do
+ context "without user" do
+ it "returns false" do
expect(resource.subscribed?(nil, project)).to be_falsey
end
end
- context 'without project' do
- it 'returns false when no subscription exists' do
+ context "without project" do
+ it "returns false when no subscription exists" do
expect(resource.subscribed?(user_1)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
resource.subscriptions.create(user: user_1, subscribed: true)
expect(resource.subscribed?(user_1)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
resource.subscriptions.create(user: user_1, subscribed: false)
expect(resource.subscribed?(user_1)).to be_falsey
end
end
- context 'with project' do
- it 'returns false when no subscription exists' do
+ context "with project" do
+ it "returns false when no subscription exists" do
expect(resource.subscribed?(user_1, project)).to be_falsey
end
- it 'returns true when a subcription exists and subscribed is true' do
+ it "returns true when a subcription exists and subscribed is true" do
resource.subscriptions.create(user: user_1, project: project, subscribed: true)
expect(resource.subscribed?(user_1, project)).to be_truthy
end
- it 'returns false when a subcription exists and subscribed is false' do
+ it "returns false when a subcription exists and subscribed is false" do
resource.subscriptions.create(user: user_1, project: project, subscribed: false)
expect(resource.subscribed?(user_1, project)).to be_falsey
@@ -49,12 +49,12 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#subscribers' do
- it 'returns [] when no subcribers exists' do
+ describe "#subscribers" do
+ it "returns [] when no subcribers exists" do
expect(resource.subscribers(project)).to be_empty
end
- it 'returns the subscribed users' do
+ it "returns the subscribed users" do
user_2 = create(:user)
resource.subscriptions.create(user: user_1, subscribed: true)
resource.subscriptions.create(user: user_2, project: project, subscribed: true)
@@ -64,9 +64,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#toggle_subscription' do
- context 'without project' do
- it 'toggles the current subscription state for the given user' do
+ describe "#toggle_subscription" do
+ context "without project" do
+ it "toggles the current subscription state for the given user" do
expect(resource.subscribed?(user_1)).to be_falsey
resource.toggle_subscription(user_1)
@@ -75,8 +75,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'toggles the current subscription state for the given user' do
+ context "with project" do
+ it "toggles the current subscription state for the given user" do
expect(resource.subscribed?(user_1, project)).to be_falsey
resource.toggle_subscription(user_1, project)
@@ -86,9 +86,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#subscribe' do
- context 'without project' do
- it 'subscribes the given user' do
+ describe "#subscribe" do
+ context "without project" do
+ it "subscribes the given user" do
expect(resource.subscribed?(user_1)).to be_falsey
resource.subscribe(user_1)
@@ -97,8 +97,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'subscribes the given user' do
+ context "with project" do
+ it "subscribes the given user" do
expect(resource.subscribed?(user_1, project)).to be_falsey
resource.subscribe(user_1, project)
@@ -108,9 +108,9 @@ describe Subscribable, 'Subscribable' do
end
end
- describe '#unsubscribe' do
- context 'without project' do
- it 'unsubscribes the given current user' do
+ describe "#unsubscribe" do
+ context "without project" do
+ it "unsubscribes the given current user" do
resource.subscriptions.create(user: user_1, subscribed: true)
expect(resource.subscribed?(user_1)).to be_truthy
@@ -120,8 +120,8 @@ describe Subscribable, 'Subscribable' do
end
end
- context 'with project' do
- it 'unsubscribes the given current user' do
+ context "with project" do
+ it "unsubscribes the given current user" do
resource.subscriptions.create(user: user_1, project: project, subscribed: true)
expect(resource.subscribed?(user_1, project)).to be_truthy
diff --git a/spec/models/concerns/token_authenticatable_spec.rb b/spec/models/concerns/token_authenticatable_spec.rb
index 40cb4eef60a..77fed825132 100644
--- a/spec/models/concerns/token_authenticatable_spec.rb
+++ b/spec/models/concerns/token_authenticatable_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'TokenAuthenticatable' do
- describe 'dynamically defined methods' do
+shared_examples "TokenAuthenticatable" do
+ describe "dynamically defined methods" do
it { expect(described_class).to respond_to("find_by_#{token_field}") }
it { is_expected.to respond_to("ensure_#{token_field}") }
it { is_expected.to respond_to("set_#{token_field}") }
@@ -9,25 +9,25 @@ shared_examples 'TokenAuthenticatable' do
end
end
-describe User, 'TokenAuthenticatable' do
+describe User, "TokenAuthenticatable" do
let(:token_field) { :feed_token }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'ensures authentication token' do
+ describe "ensures authentication token" do
subject { create(:user).send(token_field) }
it { is_expected.to be_a String }
end
end
-describe ApplicationSetting, 'TokenAuthenticatable' do
+describe ApplicationSetting, "TokenAuthenticatable" do
let(:token_field) { :runners_registration_token }
let(:settings) { described_class.new }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'generating new token' do
- context 'token is not generated yet' do
- describe 'token field accessor' do
+ describe "generating new token" do
+ context "token is not generated yet" do
+ describe "token field accessor" do
subject { settings.send(token_field) }
it { is_expected.not_to be_blank }
@@ -39,46 +39,46 @@ describe ApplicationSetting, 'TokenAuthenticatable' do
it { is_expected.to be_a String }
it { is_expected.not_to be_blank }
- it 'does not persist token' do
+ it "does not persist token" do
expect(settings).not_to be_persisted
end
end
- describe 'ensure_runners_registration_token!' do
+ describe "ensure_runners_registration_token!" do
subject { settings.send("ensure_#{token_field}!") }
- it 'persists new token as an encrypted string' do
+ it "persists new token as an encrypted string" do
expect(subject).to eq settings.reload.runners_registration_token
- expect(settings.read_attribute('runners_registration_token_encrypted'))
+ expect(settings.read_attribute("runners_registration_token_encrypted"))
.to eq Gitlab::CryptoHelper.aes256_gcm_encrypt(subject)
expect(settings).to be_persisted
end
- it 'does not persist token in a clear text' do
+ it "does not persist token in a clear text" do
expect(subject).not_to eq settings.reload
- .read_attribute('runners_registration_token_encrypted')
+ .read_attribute("runners_registration_token_encrypted")
end
end
end
- context 'token is generated' do
+ context "token is generated" do
before do
settings.send("reset_#{token_field}!")
end
- it 'persists a new token' do
+ it "persists a new token" do
expect(settings.runners_registration_token).to be_a String
end
end
end
- describe 'setting new token' do
- subject { settings.send("set_#{token_field}", '0123456789') }
+ describe "setting new token" do
+ subject { settings.send("set_#{token_field}", "0123456789") }
- it { is_expected.to eq '0123456789' }
+ it { is_expected.to eq "0123456789" }
end
- describe 'multiple token fields' do
+ describe "multiple token fields" do
before(:all) do
described_class.send(:add_authentication_token_field, :yet_another_token)
end
@@ -87,18 +87,18 @@ describe ApplicationSetting, 'TokenAuthenticatable' do
it { is_expected.to respond_to(:ensure_yet_another_token) }
end
- describe 'setting same token field multiple times' do
+ describe "setting same token field multiple times" do
subject { described_class.send(:add_authentication_token_field, :runners_registration_token) }
- it 'raises error' do
+ it "raises error" do
expect {subject}.to raise_error(ArgumentError)
end
end
end
-describe PersonalAccessToken, 'TokenAuthenticatable' do
- shared_examples 'changes personal access token' do
- it 'sets new token' do
+describe PersonalAccessToken, "TokenAuthenticatable" do
+ shared_examples "changes personal access token" do
+ it "sets new token" do
subject
expect(personal_access_token.token).to eq(token_value)
@@ -106,8 +106,8 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- shared_examples 'does not change personal access token' do
- it 'sets new token' do
+ shared_examples "does not change personal access token" do
+ it "sets new token" do
subject
expect(personal_access_token.token).to be(nil)
@@ -115,11 +115,11 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- let(:token_value) { 'token' }
+ let(:token_value) { "token" }
let(:token_digest) { Gitlab::CryptoHelper.sha256(token_value) }
let(:user) { create(:user) }
let(:personal_access_token) do
- described_class.new(name: 'test-pat-01',
+ described_class.new(name: "test-pat-01",
user_id: user.id,
scopes: [:api],
token_digest: token_digest)
@@ -129,22 +129,22 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
allow(Devise).to receive(:friendly_token).and_return(token_value)
end
- describe '.find_by_token' do
+ describe ".find_by_token" do
subject { PersonalAccessToken.find_by_token(token_value) }
- it 'finds the token' do
+ it "finds the token" do
personal_access_token.save
expect(subject).to eq(personal_access_token)
end
end
- describe '#set_token' do
- let(:new_token_value) { 'new-token' }
+ describe "#set_token" do
+ let(:new_token_value) { "new-token" }
subject { personal_access_token.set_token(new_token_value) }
- it 'sets new token' do
+ it "sets new token" do
subject
expect(personal_access_token.token).to eq(new_token_value)
@@ -152,65 +152,65 @@ describe PersonalAccessToken, 'TokenAuthenticatable' do
end
end
- describe '#ensure_token' do
+ describe "#ensure_token" do
subject { personal_access_token.ensure_token }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'does not change personal access token'
+ it_behaves_like "does not change personal access token"
end
end
- describe '#ensure_token!' do
+ describe "#ensure_token!" do
subject { personal_access_token.ensure_token! }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'does not change personal access token'
+ it_behaves_like "does not change personal access token"
end
end
- describe '#reset_token!' do
+ describe "#reset_token!" do
subject { personal_access_token.reset_token! }
- context 'token_digest does not exist' do
+ context "token_digest does not exist" do
let(:token_digest) { nil }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
- context 'token_digest already generated' do
- let(:token_digest) { 's3cr3t' }
+ context "token_digest already generated" do
+ let(:token_digest) { "s3cr3t" }
- it_behaves_like 'changes personal access token'
+ it_behaves_like "changes personal access token"
end
end
end
-describe Ci::Build, 'TokenAuthenticatable' do
+describe Ci::Build, "TokenAuthenticatable" do
let(:token_field) { :token }
let(:build) { FactoryBot.build(:ci_build) }
- it_behaves_like 'TokenAuthenticatable'
+ it_behaves_like "TokenAuthenticatable"
- describe 'generating new token' do
- context 'token is not generated yet' do
- describe 'token field accessor' do
- it 'makes it possible to access token' do
+ describe "generating new token" do
+ context "token is not generated yet" do
+ describe "token field accessor" do
+ it "makes it possible to access token" do
expect(build.token).to be_nil
build.save!
@@ -225,35 +225,35 @@ describe Ci::Build, 'TokenAuthenticatable' do
it { is_expected.to be_a String }
it { is_expected.not_to be_blank }
- it 'does not persist token' do
+ it "does not persist token" do
expect(build).not_to be_persisted
end
end
- describe 'ensure_token!' do
- it 'persists a new token' do
+ describe "ensure_token!" do
+ it "persists a new token" do
expect(build.ensure_token!).to eq build.reload.token
expect(build).to be_persisted
end
- it 'persists new token as an encrypted string' do
+ it "persists new token as an encrypted string" do
build.ensure_token!
encrypted = Gitlab::CryptoHelper.aes256_gcm_encrypt(build.token)
- expect(build.read_attribute('token_encrypted')).to eq encrypted
+ expect(build.read_attribute("token_encrypted")).to eq encrypted
end
- it 'does not persist a token in a clear text' do
+ it "does not persist a token in a clear text" do
build.ensure_token!
- expect(build.read_attribute('token')).to be_nil
+ expect(build.read_attribute("token")).to be_nil
end
end
end
- describe '#reset_token!' do
- it 'persists a new token' do
+ describe "#reset_token!" do
+ it "persists a new token" do
build.save!
build.token.yield_self do |previous_token|
@@ -266,23 +266,23 @@ describe Ci::Build, 'TokenAuthenticatable' do
end
end
- describe 'setting a new token' do
- subject { build.set_token('0123456789') }
+ describe "setting a new token" do
+ subject { build.set_token("0123456789") }
- it 'returns the token' do
- expect(subject).to eq '0123456789'
+ it "returns the token" do
+ expect(subject).to eq "0123456789"
end
- it 'writes a new encrypted token' do
- expect(build.read_attribute('token_encrypted')).to be_nil
- expect(subject).to eq '0123456789'
- expect(build.read_attribute('token_encrypted')).to be_present
+ it "writes a new encrypted token" do
+ expect(build.read_attribute("token_encrypted")).to be_nil
+ expect(subject).to eq "0123456789"
+ expect(build.read_attribute("token_encrypted")).to be_present
end
- it 'does not write a new cleartext token' do
- expect(build.read_attribute('token')).to be_nil
- expect(subject).to eq '0123456789'
- expect(build.read_attribute('token')).to be_nil
+ it "does not write a new cleartext token" do
+ expect(build.read_attribute("token")).to be_nil
+ expect(subject).to eq "0123456789"
+ expect(build.read_attribute("token")).to be_nil
end
end
end
diff --git a/spec/models/concerns/token_authenticatable_strategies/base_spec.rb b/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
index 6605f1f5a5f..2208c325a0b 100644
--- a/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
+++ b/spec/models/concerns/token_authenticatable_strategies/base_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe TokenAuthenticatableStrategies::Base do
let(:instance) { double(:instance) }
let(:field) { double(:field) }
- describe '.fabricate' do
- context 'when digest stragegy is specified' do
- it 'fabricates digest strategy object' do
+ describe ".fabricate" do
+ context "when digest stragegy is specified" do
+ it "fabricates digest strategy object" do
strategy = described_class.fabricate(instance, field, digest: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Digest
end
end
- context 'when encrypted strategy is specified' do
- it 'fabricates encrypted strategy object' do
+ context "when encrypted strategy is specified" do
+ it "fabricates encrypted strategy object" do
strategy = described_class.fabricate(instance, field, encrypted: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Encrypted
end
end
- context 'when no strategy is specified' do
- it 'fabricates insecure strategy object' do
+ context "when no strategy is specified" do
+ it "fabricates insecure strategy object" do
strategy = described_class.fabricate(instance, field, something: true)
expect(strategy).to be_a TokenAuthenticatableStrategies::Insecure
end
end
- context 'when incompatible options are provided' do
- it 'raises an error' do
+ context "when incompatible options are provided" do
+ it "raises an error" do
expect { described_class.fabricate(instance, field, digest: true, encrypted: true) }
.to raise_error ArgumentError
end
end
end
- describe '#fallback?' do
- context 'when fallback is set' do
- it 'recognizes fallback setting' do
+ describe "#fallback?" do
+ context "when fallback is set" do
+ it "recognizes fallback setting" do
strategy = described_class.new(instance, field, fallback: true)
expect(strategy.fallback?).to be true
end
end
- context 'when fallback is not a valid value' do
- it 'raises an error' do
- strategy = described_class.new(instance, field, fallback: 'something')
+ context "when fallback is not a valid value" do
+ it "raises an error" do
+ strategy = described_class.new(instance, field, fallback: "something")
expect { strategy.fallback? }.to raise_error ArgumentError
end
end
- context 'when fallback is not set' do
- it 'raises an error' do
+ context "when fallback is not set" do
+ it "raises an error" do
strategy = described_class.new(instance, field, {})
expect(strategy.fallback?).to eq false
diff --git a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
index 93cab80cb1f..630227fe149 100644
--- a/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
+++ b/spec/models/concerns/token_authenticatable_strategies/encrypted_spec.rb
@@ -1,155 +1,155 @@
-require 'spec_helper'
+require "spec_helper"
describe TokenAuthenticatableStrategies::Encrypted do
let(:model) { double(:model) }
let(:instance) { double(:instance) }
let(:encrypted) do
- Gitlab::CryptoHelper.aes256_gcm_encrypt('my-value')
+ Gitlab::CryptoHelper.aes256_gcm_encrypt("my-value")
end
subject do
- described_class.new(model, 'some_field', options)
+ described_class.new(model, "some_field", options)
end
- describe '.new' do
- context 'when fallback and migration strategies are set' do
- let(:options) { { fallback: true, migrating: true } }
+ describe ".new" do
+ context "when fallback and migration strategies are set" do
+ let(:options) { {fallback: true, migrating: true} }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error ArgumentError, /not compatible/
end
end
end
- describe '#find_token_authenticatable' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#find_token_authenticatable" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'finds the encrypted resource by cleartext' do
+ it "finds the encrypted resource by cleartext" do
allow(model).to receive(:find_by)
- .with('some_field_encrypted' => encrypted)
- .and_return('encrypted resource')
+ .with("some_field_encrypted" => encrypted)
+ .and_return("encrypted resource")
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'encrypted resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "encrypted resource"
end
- it 'uses insecure strategy when encrypted token cannot be found' do
+ it "uses insecure strategy when encrypted token cannot be found" do
allow(subject.send(:insecure_strategy))
.to receive(:find_token_authenticatable)
- .and_return('plaintext resource')
+ .and_return("plaintext resource")
allow(model).to receive(:find_by)
- .with('some_field_encrypted' => encrypted)
+ .with("some_field_encrypted" => encrypted)
.and_return(nil)
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'plaintext resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "plaintext resource"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'finds the cleartext resource by cleartext' do
+ it "finds the cleartext resource by cleartext" do
allow(model).to receive(:find_by)
- .with('some_field' => 'my-value')
- .and_return('cleartext resource')
+ .with("some_field" => "my-value")
+ .and_return("cleartext resource")
- expect(subject.find_token_authenticatable('my-value'))
- .to eq 'cleartext resource'
+ expect(subject.find_token_authenticatable("my-value"))
+ .to eq "cleartext resource"
end
- it 'returns nil if resource cannot be found' do
+ it "returns nil if resource cannot be found" do
allow(model).to receive(:find_by)
- .with('some_field' => 'my-value')
+ .with("some_field" => "my-value")
.and_return(nil)
- expect(subject.find_token_authenticatable('my-value'))
+ expect(subject.find_token_authenticatable("my-value"))
.to be_nil
end
end
end
- describe '#get_token' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#get_token" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'returns decrypted token when an encrypted token is present' do
+ it "returns decrypted token when an encrypted token is present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(encrypted)
- expect(subject.get_token(instance)).to eq 'my-value'
+ expect(subject.get_token(instance)).to eq "my-value"
end
- it 'returns the plaintext token when encrypted token is not present' do
+ it "returns the plaintext token when encrypted token is not present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(nil)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('cleartext value')
+ .with("some_field")
+ .and_return("cleartext value")
- expect(subject.get_token(instance)).to eq 'cleartext value'
+ expect(subject.get_token(instance)).to eq "cleartext value"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'returns cleartext token when an encrypted token is present' do
+ it "returns cleartext token when an encrypted token is present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(encrypted)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('my-cleartext-value')
+ .with("some_field")
+ .and_return("my-cleartext-value")
- expect(subject.get_token(instance)).to eq 'my-cleartext-value'
+ expect(subject.get_token(instance)).to eq "my-cleartext-value"
end
- it 'returns the cleartext token when encrypted token is not present' do
+ it "returns the cleartext token when encrypted token is not present" do
allow(instance).to receive(:read_attribute)
- .with('some_field_encrypted')
+ .with("some_field_encrypted")
.and_return(nil)
allow(instance).to receive(:read_attribute)
- .with('some_field')
- .and_return('cleartext value')
+ .with("some_field")
+ .and_return("cleartext value")
- expect(subject.get_token(instance)).to eq 'cleartext value'
+ expect(subject.get_token(instance)).to eq "cleartext value"
end
end
end
- describe '#set_token' do
- context 'when using fallback strategy' do
- let(:options) { { fallback: true } }
+ describe "#set_token" do
+ context "when using fallback strategy" do
+ let(:options) { {fallback: true} }
- it 'writes encrypted token and removes plaintext token and returns it' do
+ it "writes encrypted token and removes plaintext token and returns it" do
expect(instance).to receive(:[]=)
- .with('some_field_encrypted', encrypted)
+ .with("some_field_encrypted", encrypted)
expect(instance).to receive(:[]=)
- .with('some_field', nil)
+ .with("some_field", nil)
- expect(subject.set_token(instance, 'my-value')).to eq 'my-value'
+ expect(subject.set_token(instance, "my-value")).to eq "my-value"
end
end
- context 'when using migration strategy' do
- let(:options) { { migrating: true } }
+ context "when using migration strategy" do
+ let(:options) { {migrating: true} }
- it 'writes encrypted token and writes plaintext token' do
+ it "writes encrypted token and writes plaintext token" do
expect(instance).to receive(:[]=)
- .with('some_field_encrypted', encrypted)
+ .with("some_field_encrypted", encrypted)
expect(instance).to receive(:[]=)
- .with('some_field', 'my-value')
+ .with("some_field", "my-value")
- expect(subject.set_token(instance, 'my-value')).to eq 'my-value'
+ expect(subject.set_token(instance, "my-value")).to eq "my-value"
end
end
end
diff --git a/spec/models/concerns/triggerable_hooks_spec.rb b/spec/models/concerns/triggerable_hooks_spec.rb
index 265abd6bd72..15eb162e89b 100644
--- a/spec/models/concerns/triggerable_hooks_spec.rb
+++ b/spec/models/concerns/triggerable_hooks_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe TriggerableHooks do
before do
@@ -8,43 +8,43 @@ RSpec.describe TriggerableHooks do
end
end
- describe 'scopes' do
- it 'defines a scope for each of the requested triggers' do
+ describe "scopes" do
+ it "defines a scope for each of the requested triggers" do
expect(TestableHook).to respond_to :push_hooks
expect(TestableHook).not_to respond_to :tag_push_hooks
end
end
- describe '.hooks_for' do
- context 'the model has the required trigger scope' do
- it 'returns the record' do
- hook = TestableHook.create!(url: 'http://example.com', push_events: true)
+ describe ".hooks_for" do
+ context "the model has the required trigger scope" do
+ it "returns the record" do
+ hook = TestableHook.create!(url: "http://example.com", push_events: true)
expect(TestableHook.hooks_for(:push_hooks)).to eq [hook]
end
end
- context 'the model does not have the required trigger scope' do
- it 'returns an empty relation' do
- TestableHook.create!(url: 'http://example.com')
+ context "the model does not have the required trigger scope" do
+ it "returns an empty relation" do
+ TestableHook.create!(url: "http://example.com")
expect(TestableHook.hooks_for(:tag_push_hooks)).to eq []
end
end
context 'the stock scope ".all" is accepted' do
- it 'returns the record' do
- hook = TestableHook.create!(url: 'http://example.com')
+ it "returns the record" do
+ hook = TestableHook.create!(url: "http://example.com")
expect(TestableHook.hooks_for(:all)).to eq [hook]
end
end
end
- describe '.select_active' do
- it 'returns hooks that match the active filter' do
- TestableHook.create!(url: 'http://example1.com', push_events: true)
- TestableHook.create!(url: 'http://example2.com', push_events: true)
+ describe ".select_active" do
+ it "returns hooks that match the active filter" do
+ TestableHook.create!(url: "http://example1.com", push_events: true)
+ TestableHook.create!(url: "http://example2.com", push_events: true)
filter1 = double(:filter1)
filter2 = double(:filter2)
allow(ActiveHookFilter).to receive(:new).exactly(2).times.and_return(filter1, filter2)
@@ -55,8 +55,8 @@ RSpec.describe TriggerableHooks do
expect(hooks.select_active(:push_hooks, {})).to eq [hooks.first]
end
- it 'returns empty list if no hooks match the active filter' do
- TestableHook.create!(url: 'http://example1.com', push_events: true)
+ it "returns empty list if no hooks match the active filter" do
+ TestableHook.create!(url: "http://example1.com", push_events: true)
filter = double(:filter)
allow(ActiveHookFilter).to receive(:new).and_return(filter)
expect(filter).to receive(:matches?).and_return(false)
diff --git a/spec/models/concerns/uniquify_spec.rb b/spec/models/concerns/uniquify_spec.rb
index 6cd2de6dcce..0da6f5a4d0d 100644
--- a/spec/models/concerns/uniquify_spec.rb
+++ b/spec/models/concerns/uniquify_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Uniquify do
let(:uniquify) { described_class.new }
describe "#string" do
- it 'returns the given string if it does not exist' do
- result = uniquify.string('test_string') { |s| false }
+ it "returns the given string if it does not exist" do
+ result = uniquify.string("test_string") { |s| false }
- expect(result).to eq('test_string')
+ expect(result).to eq("test_string")
end
- it 'returns the given string with a counter attached if the string exists' do
- result = uniquify.string('test_string') { |s| s == 'test_string' }
+ it "returns the given string with a counter attached if the string exists" do
+ result = uniquify.string("test_string") { |s| s == "test_string" }
- expect(result).to eq('test_string1')
+ expect(result).to eq("test_string1")
end
- it 'increments the counter for each candidate string that also exists' do
- result = uniquify.string('test_string') { |s| s == 'test_string' || s == 'test_string1' }
+ it "increments the counter for each candidate string that also exists" do
+ result = uniquify.string("test_string") { |s| s == "test_string" || s == "test_string1" }
- expect(result).to eq('test_string2')
+ expect(result).to eq("test_string2")
end
- it 'allows to pass an initial value for the counter' do
+ it "allows to pass an initial value for the counter" do
start_counting_from = 2
uniquify = described_class.new(start_counting_from)
- result = uniquify.string('test_string') { |s| s == 'test_string' }
+ result = uniquify.string("test_string") { |s| s == "test_string" }
- expect(result).to eq('test_string2')
+ expect(result).to eq("test_string2")
end
- it 'allows passing in a base function that defines the location of the counter' do
- result = uniquify.string(-> (counter) { "test_#{counter}_string" }) do |s|
- s == 'test__string'
- end
+ it "allows passing in a base function that defines the location of the counter" do
+ result = uniquify.string(->(counter) { "test_#{counter}_string" }) { |s|
+ s == "test__string"
+ }
- expect(result).to eq('test_1_string')
+ expect(result).to eq("test_1_string")
end
end
end
diff --git a/spec/models/container_repository_spec.rb b/spec/models/container_repository_spec.rb
index e46945e301e..818a5f73468 100644
--- a/spec/models/container_repository_spec.rb
+++ b/spec/models/container_repository_spec.rb
@@ -1,87 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRepository do
- let(:group) { create(:group, name: 'group') }
- let(:project) { create(:project, path: 'test', group: group) }
+ let(:group) { create(:group, name: "group") }
+ let(:project) { create(:project, path: "test", group: group) }
let(:repository) do
- create(:container_repository, name: 'my_image', project: project)
+ create(:container_repository, name: "my_image", project: project)
end
before do
stub_container_registry_config(enabled: true,
- api_url: 'http://registry.gitlab',
- host_port: 'registry.gitlab')
+ api_url: "http://registry.gitlab",
+ host_port: "registry.gitlab")
- stub_request(:get, 'http://registry.gitlab/v2/group/test/my_image/tags/list')
- .with(headers: { 'Accept' => 'application/vnd.docker.distribution.manifest.v2+json' })
+ stub_request(:get, "http://registry.gitlab/v2/group/test/my_image/tags/list")
+ .with(headers: {"Accept" => "application/vnd.docker.distribution.manifest.v2+json"})
.to_return(
status: 200,
- body: JSON.dump(tags: ['test_tag']),
- headers: { 'Content-Type' => 'application/json' })
+ body: JSON.dump(tags: ["test_tag"]),
+ headers: {"Content-Type" => "application/json"}
+ )
end
- describe 'associations' do
- it 'belongs to the project' do
+ describe "associations" do
+ it "belongs to the project" do
expect(repository).to belong_to(:project)
end
end
- describe '#tag' do
- it 'has a test tag' do
- expect(repository.tag('test')).not_to be_nil
+ describe "#tag" do
+ it "has a test tag" do
+ expect(repository.tag("test")).not_to be_nil
end
end
- describe '#path' do
- context 'when project path does not contain uppercase letters' do
- it 'returns a full path to the repository' do
- expect(repository.path).to eq('group/test/my_image')
+ describe "#path" do
+ context "when project path does not contain uppercase letters" do
+ it "returns a full path to the repository" do
+ expect(repository.path).to eq("group/test/my_image")
end
end
- context 'when path contains uppercase letters' do
- let(:project) { create(:project, :repository, path: 'MY_PROJECT', group: group) }
+ context "when path contains uppercase letters" do
+ let(:project) { create(:project, :repository, path: "MY_PROJECT", group: group) }
- it 'returns a full path without capital letters' do
- expect(repository.path).to eq('group/my_project/my_image')
+ it "returns a full path without capital letters" do
+ expect(repository.path).to eq("group/my_project/my_image")
end
end
end
- describe '#manifest' do
- it 'returns non-empty manifest' do
+ describe "#manifest" do
+ it "returns non-empty manifest" do
expect(repository.manifest).not_to be_nil
end
end
- describe '#valid?' do
- it 'is a valid repository' do
+ describe "#valid?" do
+ it "is a valid repository" do
expect(repository).to be_valid
end
end
- describe '#tags' do
- it 'returns non-empty tags list' do
+ describe "#tags" do
+ it "returns non-empty tags list" do
expect(repository.tags).not_to be_empty
end
end
- describe '#has_tags?' do
- it 'has tags' do
+ describe "#has_tags?" do
+ it "has tags" do
expect(repository).to have_tags
end
end
- describe '#delete_tags!' do
+ describe "#delete_tags!" do
let(:repository) do
- create(:container_repository, name: 'my_image',
+ create(:container_repository, name: "my_image",
tags: %w[latest rc1],
project: project)
end
- context 'when action succeeds' do
- it 'returns status that indicates success' do
+ context "when action succeeds" do
+ it "returns status that indicates success" do
expect(repository.client)
.to receive(:delete_repository_tag)
.and_return(true)
@@ -90,8 +91,8 @@ describe ContainerRepository do
end
end
- context 'when action fails' do
- it 'returns status that indicates failure' do
+ context "when action fails" do
+ it "returns status that indicates failure" do
expect(repository.client)
.to receive(:delete_repository_tag)
.and_return(false)
@@ -101,133 +102,134 @@ describe ContainerRepository do
end
end
- describe '#location' do
- context 'when registry is running on a custom port' do
+ describe "#location" do
+ context "when registry is running on a custom port" do
before do
stub_container_registry_config(enabled: true,
- api_url: 'http://registry.gitlab:5000',
- host_port: 'registry.gitlab:5000')
+ api_url: "http://registry.gitlab:5000",
+ host_port: "registry.gitlab:5000")
end
- it 'returns a full location of the repository' do
+ it "returns a full location of the repository" do
expect(repository.location)
- .to eq 'registry.gitlab:5000/group/test/my_image'
+ .to eq "registry.gitlab:5000/group/test/my_image"
end
end
end
- describe '#root_repository?' do
- context 'when repository is a root repository' do
+ describe "#root_repository?" do
+ context "when repository is a root repository" do
let(:repository) { create(:container_repository, :root) }
- it 'returns true' do
+ it "returns true" do
expect(repository).to be_root_repository
end
end
- context 'when repository is not a root repository' do
- it 'returns false' do
+ context "when repository is not a root repository" do
+ it "returns false" do
expect(repository).not_to be_root_repository
end
end
end
- describe '.build_from_path' do
+ describe ".build_from_path" do
let(:registry_path) do
- ContainerRegistry::Path.new(project.full_path + '/some/image')
+ ContainerRegistry::Path.new(project.full_path + "/some/image")
end
let(:repository) do
described_class.build_from_path(registry_path)
end
- it 'fabricates repository assigned to a correct project' do
+ it "fabricates repository assigned to a correct project" do
expect(repository.project).to eq project
end
- it 'fabricates repository with a correct name' do
- expect(repository.name).to eq 'some/image'
+ it "fabricates repository with a correct name" do
+ expect(repository.name).to eq "some/image"
end
- it 'is not persisted' do
+ it "is not persisted" do
expect(repository).not_to be_persisted
end
end
- describe '.create_from_path!' do
+ describe ".create_from_path!" do
let(:repository) do
described_class.create_from_path!(ContainerRegistry::Path.new(path))
end
let(:repository_path) { ContainerRegistry::Path.new(path) }
- context 'when received multi-level repository path' do
- let(:path) { project.full_path + '/some/image' }
+ context "when received multi-level repository path" do
+ let(:path) { project.full_path + "/some/image" }
- it 'fabricates repository assigned to a correct project' do
+ it "fabricates repository assigned to a correct project" do
expect(repository.project).to eq project
end
- it 'fabricates repository with a correct name' do
- expect(repository.name).to eq 'some/image'
+ it "fabricates repository with a correct name" do
+ expect(repository.name).to eq "some/image"
end
end
- context 'when path is too long' do
+ context "when path is too long" do
let(:path) do
- project.full_path + '/a/b/c/d/e/f/g/h/i/j/k/l/n/o/p/s/t/u/x/y/z'
+ project.full_path + "/a/b/c/d/e/f/g/h/i/j/k/l/n/o/p/s/t/u/x/y/z"
end
- it 'does not create repository and raises error' do
+ it "does not create repository and raises error" do
expect { repository }.to raise_error(
- ContainerRegistry::Path::InvalidRegistryPathError)
+ ContainerRegistry::Path::InvalidRegistryPathError
+ )
end
end
- context 'when received multi-level repository with nested groups' do
- let(:group) { create(:group, :nested, name: 'nested') }
- let(:path) { project.full_path + '/some/image' }
+ context "when received multi-level repository with nested groups" do
+ let(:group) { create(:group, :nested, name: "nested") }
+ let(:path) { project.full_path + "/some/image" }
- it 'fabricates repository assigned to a correct project' do
+ it "fabricates repository assigned to a correct project" do
expect(repository.project).to eq project
end
- it 'fabricates repository with a correct name' do
- expect(repository.name).to eq 'some/image'
+ it "fabricates repository with a correct name" do
+ expect(repository.name).to eq "some/image"
end
- it 'has path including a nested group' do
- expect(repository.path).to include 'nested/test/some/image'
+ it "has path including a nested group" do
+ expect(repository.path).to include "nested/test/some/image"
end
end
- context 'when received root repository path' do
+ context "when received root repository path" do
let(:path) { project.full_path }
- it 'fabricates repository assigned to a correct project' do
+ it "fabricates repository assigned to a correct project" do
expect(repository.project).to eq project
end
- it 'fabricates repository with an empty name' do
+ it "fabricates repository with an empty name" do
expect(repository.name).to be_empty
end
end
end
- describe '.build_root_repository' do
+ describe ".build_root_repository" do
let(:repository) do
described_class.build_root_repository(project)
end
- it 'fabricates a root repository object' do
+ it "fabricates a root repository object" do
expect(repository).to be_root_repository
end
- it 'assignes it to the correct project' do
+ it "assignes it to the correct project" do
expect(repository.project).to eq project
end
- it 'does not persist it' do
+ it "does not persist it" do
expect(repository).not_to be_persisted
end
end
diff --git a/spec/models/conversational_development_index/metric_spec.rb b/spec/models/conversational_development_index/metric_spec.rb
index b3193619503..63c3c416232 100644
--- a/spec/models/conversational_development_index/metric_spec.rb
+++ b/spec/models/conversational_development_index/metric_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
describe ConversationalDevelopmentIndex::Metric do
let(:conv_dev_index) { create(:conversational_development_index_metric) }
- describe '#percentage_score' do
- it 'returns stored percentage score' do
- expect(conv_dev_index.percentage_score('issues')).to eq(13.331)
+ describe "#percentage_score" do
+ it "returns stored percentage score" do
+ expect(conv_dev_index.percentage_score("issues")).to eq(13.331)
end
end
end
diff --git a/spec/models/cycle_analytics/code_spec.rb b/spec/models/cycle_analytics/code_spec.rb
index 6a6b58fb52b..49f473eefd2 100644
--- a/spec/models/cycle_analytics/code_spec.rb
+++ b/spec/models/cycle_analytics/code_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#code' do
+describe "CycleAnalytics#code" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -8,22 +8,23 @@ describe 'CycleAnalytics#code' do
let(:user) { create(:user, :admin) }
subject { CycleAnalytics.new(project, from: from_date) }
- context 'with deployment' do
+ context "with deployment" do
generate_cycle_analytics_spec(
phase: :code,
- data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
+ data_fn: ->(context) { {issue: context.create(:issue, project: context.project)} },
start_time_conditions: [["issue mentioned in a commit",
- -> (context, data) do
+ ->(context, data) do
context.create_commit_referencing_issue(data[:issue])
- end]],
+ end,]],
end_time_conditions: [["merge request that closes issue is created",
- -> (context, data) do
+ ->(context, data) do
context.create_merge_request_closing_issue(context.user, context.project, data[:issue])
- end]],
- post_fn: -> (context, data) do
+ end,]],
+ post_fn: ->(context, data) do
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
context.deploy_master(context.user, context.project)
- end)
+ end
+ )
context "when a regular merge request (that doesn't close the issue) is created" do
it "returns nil" do
@@ -40,21 +41,22 @@ describe 'CycleAnalytics#code' do
end
end
- context 'without deployment' do
+ context "without deployment" do
generate_cycle_analytics_spec(
phase: :code,
- data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
+ data_fn: ->(context) { {issue: context.create(:issue, project: context.project)} },
start_time_conditions: [["issue mentioned in a commit",
- -> (context, data) do
+ ->(context, data) do
context.create_commit_referencing_issue(data[:issue])
- end]],
+ end,]],
end_time_conditions: [["merge request that closes issue is created",
- -> (context, data) do
+ ->(context, data) do
context.create_merge_request_closing_issue(context.user, context.project, data[:issue])
- end]],
- post_fn: -> (context, data) do
+ end,]],
+ post_fn: ->(context, data) do
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
- end)
+ end
+ )
context "when a regular merge request (that doesn't close the issue) is created" do
it "returns nil" do
diff --git a/spec/models/cycle_analytics/issue_spec.rb b/spec/models/cycle_analytics/issue_spec.rb
index 45f1b4fe8a3..fd2b02d8e5d 100644
--- a/spec/models/cycle_analytics/issue_spec.rb
+++ b/spec/models/cycle_analytics/issue_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#issue' do
+describe "CycleAnalytics#issue" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -10,26 +10,27 @@ describe 'CycleAnalytics#issue' do
generate_cycle_analytics_spec(
phase: :issue,
- data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } },
- start_time_conditions: [["issue created", -> (context, data) { data[:issue].save }]],
- end_time_conditions: [["issue associated with a milestone",
- -> (context, data) do
- if data[:issue].persisted?
- data[:issue].update(milestone: context.create(:milestone, project: context.project))
- end
- end],
- ["list label added to issue",
- -> (context, data) do
- if data[:issue].persisted?
- data[:issue].update(label_ids: [context.create(:label, lists: [context.create(:list)]).id])
- end
- end]],
- post_fn: -> (context, data) do
+ data_fn: ->(context) { {issue: context.build(:issue, project: context.project)} },
+ start_time_conditions: [["issue created", ->(context, data) { data[:issue].save }]],
+ end_time_conditions: [["issue associated with a milestone",
+ ->(context, data) do
+ if data[:issue].persisted?
+ data[:issue].update(milestone: context.create(:milestone, project: context.project))
+ end
+ end,],
+ ["list label added to issue",
+ ->(context, data) do
+ if data[:issue].persisted?
+ data[:issue].update(label_ids: [context.create(:label, lists: [context.create(:list)]).id])
+ end
+ end,],],
+ post_fn: ->(context, data) do
if data[:issue].persisted?
context.create_merge_request_closing_issue(context.user, context.project, data[:issue].reload)
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
end
- end)
+ end
+ )
context "when a regular label (instead of a list label) is added to the issue" do
it "returns nil" do
diff --git a/spec/models/cycle_analytics/plan_spec.rb b/spec/models/cycle_analytics/plan_spec.rb
index d366e2b723a..f836691c75a 100644
--- a/spec/models/cycle_analytics/plan_spec.rb
+++ b/spec/models/cycle_analytics/plan_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#plan' do
+describe "CycleAnalytics#plan" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -10,28 +10,29 @@ describe 'CycleAnalytics#plan' do
generate_cycle_analytics_spec(
phase: :plan,
- data_fn: -> (context) do
+ data_fn: ->(context) do
{
issue: context.create(:issue, project: context.project),
- branch_name: context.generate(:branch)
+ branch_name: context.generate(:branch),
}
end,
start_time_conditions: [["issue associated with a milestone",
- -> (context, data) do
+ ->(context, data) do
data[:issue].update(milestone: context.create(:milestone, project: context.project))
- end],
+ end,],
["list label added to issue",
- -> (context, data) do
+ ->(context, data) do
data[:issue].update(label_ids: [context.create(:label, lists: [context.create(:list)]).id])
- end]],
- end_time_conditions: [["issue mentioned in a commit",
- -> (context, data) do
- context.create_commit_referencing_issue(data[:issue], branch_name: data[:branch_name])
- end]],
- post_fn: -> (context, data) do
+ end,],],
+ end_time_conditions: [["issue mentioned in a commit",
+ ->(context, data) do
+ context.create_commit_referencing_issue(data[:issue], branch_name: data[:branch_name])
+ end,]],
+ post_fn: ->(context, data) do
context.create_merge_request_closing_issue(context.user, context.project, data[:issue], source_branch: data[:branch_name])
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
- end)
+ end
+ )
context "when a regular label (instead of a list label) is added to the issue" do
it "returns nil" do
diff --git a/spec/models/cycle_analytics/production_spec.rb b/spec/models/cycle_analytics/production_spec.rb
index 156eb96cfce..51e1d1cefcb 100644
--- a/spec/models/cycle_analytics/production_spec.rb
+++ b/spec/models/cycle_analytics/production_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#production' do
+describe "CycleAnalytics#production" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -10,27 +10,29 @@ describe 'CycleAnalytics#production' do
generate_cycle_analytics_spec(
phase: :production,
- data_fn: -> (context) { { issue: context.build(:issue, project: context.project) } },
- start_time_conditions: [["issue is created", -> (context, data) { data[:issue].save }]],
+ data_fn: ->(context) { {issue: context.build(:issue, project: context.project)} },
+ start_time_conditions: [["issue is created", ->(context, data) { data[:issue].save }]],
before_end_fn: lambda do |context, data|
context.create_merge_request_closing_issue(context.user, context.project, data[:issue])
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
end,
end_time_conditions:
- [["merge request that closes issue is deployed to production", -> (context, data) { context.deploy_master(context.user, context.project) }],
+ [["merge request that closes issue is deployed to production", ->(context, data) { context.deploy_master(context.user, context.project) }],
["production deploy happens after merge request is merged (along with other changes)",
lambda do |context, data|
# Make other changes on master
sha = context.project.repository.create_file(
context.user,
context.generate(:branch),
- 'content',
- message: 'commit message',
- branch_name: 'master')
+ "content",
+ message: "commit message",
+ branch_name: "master"
+ )
context.project.repository.commit(sha)
context.deploy_master(context.user, context.project)
- end]])
+ end,],]
+ )
context "when a regular merge request (that doesn't close the issue) is merged and deployed" do
it "returns nil" do
@@ -47,7 +49,7 @@ describe 'CycleAnalytics#production' do
issue = create(:issue, project: project)
merge_request = create_merge_request_closing_issue(user, project, issue)
MergeRequests::MergeService.new(project, user).execute(merge_request)
- deploy_master(user, project, environment: 'staging')
+ deploy_master(user, project, environment: "staging")
expect(subject[:production].median).to be_nil
end
diff --git a/spec/models/cycle_analytics/review_spec.rb b/spec/models/cycle_analytics/review_spec.rb
index 0aedfb49cb5..359f47dc820 100644
--- a/spec/models/cycle_analytics/review_spec.rb
+++ b/spec/models/cycle_analytics/review_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#review' do
+describe "CycleAnalytics#review" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -10,16 +10,17 @@ describe 'CycleAnalytics#review' do
generate_cycle_analytics_spec(
phase: :review,
- data_fn: -> (context) { { issue: context.create(:issue, project: context.project) } },
+ data_fn: ->(context) { {issue: context.create(:issue, project: context.project)} },
start_time_conditions: [["merge request that closes issue is created",
- -> (context, data) do
+ ->(context, data) do
context.create_merge_request_closing_issue(context.user, context.project, data[:issue])
- end]],
- end_time_conditions: [["merge request that closes issue is merged",
- -> (context, data) do
- context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
- end]],
- post_fn: nil)
+ end,]],
+ end_time_conditions: [["merge request that closes issue is merged",
+ ->(context, data) do
+ context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
+ end,]],
+ post_fn: nil
+ )
context "when a regular merge request (that doesn't close the issue) is created and merged" do
it "returns nil" do
diff --git a/spec/models/cycle_analytics/staging_spec.rb b/spec/models/cycle_analytics/staging_spec.rb
index 0cbda50c688..813cef5e079 100644
--- a/spec/models/cycle_analytics/staging_spec.rb
+++ b/spec/models/cycle_analytics/staging_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#staging' do
+describe "CycleAnalytics#staging" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -13,29 +13,31 @@ describe 'CycleAnalytics#staging' do
phase: :staging,
data_fn: lambda do |context|
issue = context.create(:issue, project: context.project)
- { issue: issue, merge_request: context.create_merge_request_closing_issue(context.user, context.project, issue) }
+ {issue: issue, merge_request: context.create_merge_request_closing_issue(context.user, context.project, issue)}
end,
start_time_conditions: [["merge request that closes issue is merged",
- -> (context, data) do
+ ->(context, data) do
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
- end]],
- end_time_conditions: [["merge request that closes issue is deployed to production",
- -> (context, data) do
- context.deploy_master(context.user, context.project)
- end],
- ["production deploy happens after merge request is merged (along with other changes)",
- lambda do |context, data|
- # Make other changes on master
- sha = context.project.repository.create_file(
- context.user,
- context.generate(:branch),
- 'content',
- message: 'commit message',
- branch_name: 'master')
- context.project.repository.commit(sha)
-
- context.deploy_master(context.user, context.project)
- end]])
+ end,]],
+ end_time_conditions: [["merge request that closes issue is deployed to production",
+ ->(context, data) do
+ context.deploy_master(context.user, context.project)
+ end,],
+ ["production deploy happens after merge request is merged (along with other changes)",
+ lambda do |context, data|
+ # Make other changes on master
+ sha = context.project.repository.create_file(
+ context.user,
+ context.generate(:branch),
+ "content",
+ message: "commit message",
+ branch_name: "master"
+ )
+ context.project.repository.commit(sha)
+
+ context.deploy_master(context.user, context.project)
+ end,],]
+ )
context "when a regular merge request (that doesn't close the issue) is merged and deployed" do
it "returns nil" do
@@ -52,7 +54,7 @@ describe 'CycleAnalytics#staging' do
issue = create(:issue, project: project)
merge_request = create_merge_request_closing_issue(user, project, issue)
MergeRequests::MergeService.new(project, user).execute(merge_request)
- deploy_master(user, project, environment: 'staging')
+ deploy_master(user, project, environment: "staging")
expect(subject[:staging].median).to be_nil
end
diff --git a/spec/models/cycle_analytics/test_spec.rb b/spec/models/cycle_analytics/test_spec.rb
index e58b8fdff58..5b2ea41396b 100644
--- a/spec/models/cycle_analytics/test_spec.rb
+++ b/spec/models/cycle_analytics/test_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'CycleAnalytics#test' do
+describe "CycleAnalytics#test" do
extend CycleAnalyticsHelpers::TestGeneration
let(:project) { create(:project, :repository) }
@@ -14,13 +14,14 @@ describe 'CycleAnalytics#test' do
issue = context.create(:issue, project: context.project)
merge_request = context.create_merge_request_closing_issue(context.user, context.project, issue)
pipeline = context.create(:ci_pipeline, ref: merge_request.source_branch, sha: merge_request.diff_head_sha, project: context.project, head_pipeline_of: merge_request)
- { pipeline: pipeline, issue: issue }
+ {pipeline: pipeline, issue: issue}
end,
- start_time_conditions: [["pipeline is started", -> (context, data) { data[:pipeline].run! }]],
- end_time_conditions: [["pipeline is finished", -> (context, data) { data[:pipeline].succeed! }]],
- post_fn: -> (context, data) do
+ start_time_conditions: [["pipeline is started", ->(context, data) { data[:pipeline].run! }]],
+ end_time_conditions: [["pipeline is finished", ->(context, data) { data[:pipeline].succeed! }]],
+ post_fn: ->(context, data) do
context.merge_merge_requests_closing_issue(context.user, context.project, data[:issue])
- end)
+ end
+ )
context "when the pipeline is for a regular merge request (that doesn't close an issue)" do
it "returns nil" do
@@ -39,7 +40,7 @@ describe 'CycleAnalytics#test' do
context "when the pipeline is not for a merge request" do
it "returns nil" do
- pipeline = create(:ci_pipeline, ref: "refs/heads/master", sha: project.repository.commit('master').sha)
+ pipeline = create(:ci_pipeline, ref: "refs/heads/master", sha: project.repository.commit("master").sha)
pipeline.run!
pipeline.succeed!
diff --git a/spec/models/cycle_analytics_spec.rb b/spec/models/cycle_analytics_spec.rb
index 0fe24870f02..e5ec4a11ff1 100644
--- a/spec/models/cycle_analytics_spec.rb
+++ b/spec/models/cycle_analytics_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CycleAnalytics do
let(:project) { create(:project, :repository) }
@@ -7,11 +7,11 @@ describe CycleAnalytics do
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
let(:milestone) { create(:milestone, project: project) }
let(:mr) { create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}") }
- let(:pipeline) { create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
+ let(:pipeline) { create(:ci_empty_pipeline, status: "created", project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr) }
subject { described_class.new(project, from: from_date) }
- describe '#all_medians_per_stage' do
+ describe "#all_medians_per_stage" do
before do
allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue])
@@ -19,10 +19,10 @@ describe CycleAnalytics do
deploy_master(user, project)
end
- it 'returns every median for each stage for a specific project' do
- values = described_class::STAGES.each_with_object({}) do |stage_name, hsh|
+ it "returns every median for each stage for a specific project" do
+ values = described_class::STAGES.each_with_object({}) { |stage_name, hsh|
hsh[stage_name] = subject[stage_name].median.presence
- end
+ }
expect(subject.all_medians_per_stage).to eq(values)
end
diff --git a/spec/models/deploy_key_spec.rb b/spec/models/deploy_key_spec.rb
index 41440c6d288..d03a3c051eb 100644
--- a/spec/models/deploy_key_spec.rb
+++ b/spec/models/deploy_key_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployKey, :mailer do
describe "Associations" do
@@ -6,10 +6,10 @@ describe DeployKey, :mailer do
it { is_expected.to have_many(:projects) }
end
- describe 'notification' do
+ describe "notification" do
let(:user) { create(:user) }
- it 'does not send a notification' do
+ it "does not send a notification" do
perform_enqueued_jobs do
create(:deploy_key, user: user)
end
@@ -18,22 +18,22 @@ describe DeployKey, :mailer do
end
end
- describe '#user' do
+ describe "#user" do
let(:deploy_key) { create(:deploy_key) }
let(:user) { create(:user) }
- context 'when user is set' do
+ context "when user is set" do
before do
deploy_key.user = user
end
- it 'returns the user' do
+ it "returns the user" do
expect(deploy_key.user).to be(user)
end
end
- context 'when user is not set' do
- it 'returns the ghost user' do
+ context "when user is not set" do
+ it "returns the ghost user" do
expect(deploy_key.user).to eq(User.ghost)
end
end
diff --git a/spec/models/deploy_keys_project_spec.rb b/spec/models/deploy_keys_project_spec.rb
index fca3090ff4a..45fc8cfb128 100644
--- a/spec/models/deploy_keys_project_spec.rb
+++ b/spec/models/deploy_keys_project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployKeysProject do
describe "Associations" do
diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb
index 3435f93c999..06712fdccb2 100644
--- a/spec/models/deploy_token_spec.rb
+++ b/spec/models/deploy_token_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployToken do
subject(:deploy_token) { create(:deploy_token) }
@@ -6,8 +6,8 @@ describe DeployToken do
it { is_expected.to have_many :project_deploy_tokens }
it { is_expected.to have_many(:projects).through(:project_deploy_tokens) }
- describe '#ensure_token' do
- it 'should ensure a token' do
+ describe "#ensure_token" do
+ it "should ensure a token" do
deploy_token.token = nil
deploy_token.save
@@ -15,15 +15,15 @@ describe DeployToken do
end
end
- describe '#ensure_at_least_one_scope' do
- context 'with at least one scope' do
- it 'should be valid' do
+ describe "#ensure_at_least_one_scope" do
+ context "with at least one scope" do
+ it "should be valid" do
is_expected.to be_valid
end
end
- context 'with no scopes' do
- it 'should be invalid' do
+ context "with no scopes" do
+ it "should be invalid" do
deploy_token = build(:deploy_token, read_repository: false, read_registry: false)
expect(deploy_token).not_to be_valid
@@ -32,23 +32,23 @@ describe DeployToken do
end
end
- describe '#scopes' do
- context 'with all the scopes' do
- it 'should return scopes assigned to DeployToken' do
+ describe "#scopes" do
+ context "with all the scopes" do
+ it "should return scopes assigned to DeployToken" do
expect(deploy_token.scopes).to eq([:read_repository, :read_registry])
end
end
- context 'with only one scope' do
- it 'should return scopes assigned to DeployToken' do
+ context "with only one scope" do
+ it "should return scopes assigned to DeployToken" do
deploy_token = create(:deploy_token, read_registry: false)
expect(deploy_token.scopes).to eq([:read_repository])
end
end
end
- describe '#revoke!' do
- it 'should update revoke attribute' do
+ describe "#revoke!" do
+ it "should update revoke attribute" do
deploy_token.revoke!
expect(deploy_token.revoked?).to be_truthy
end
@@ -56,20 +56,20 @@ describe DeployToken do
describe "#active?" do
context "when it has been revoked" do
- it 'should return false' do
+ it "should return false" do
deploy_token.revoke!
expect(deploy_token.active?).to be_falsy
end
end
context "when it hasn't been revoked and is not expired" do
- it 'should return true' do
+ it "should return true" do
expect(deploy_token.active?).to be_truthy
end
end
context "when it hasn't been revoked and is expired" do
- it 'should return true' do
+ it "should return true" do
deploy_token.update_attribute(:expires_at, Date.today - 5.days)
expect(deploy_token.active?).to be_falsy
end
@@ -78,100 +78,100 @@ describe DeployToken do
context "when it hasn't been revoked and has no expiry" do
let(:deploy_token) { create(:deploy_token, expires_at: nil) }
- it 'should return true' do
+ it "should return true" do
expect(deploy_token.active?).to be_truthy
end
end
end
- describe '#username' do
- it 'returns a harcoded username' do
+ describe "#username" do
+ it "returns a harcoded username" do
expect(deploy_token.username).to eq("gitlab+deploy-token-#{deploy_token.id}")
end
end
- describe '#has_access_to?' do
+ describe "#has_access_to?" do
let(:project) { create(:project) }
subject { deploy_token.has_access_to?(project) }
- context 'when deploy token is active and related to project' do
+ context "when deploy token is active and related to project" do
let(:deploy_token) { create(:deploy_token, projects: [project]) }
it { is_expected.to be_truthy }
end
- context 'when deploy token is active but not related to project' do
+ context "when deploy token is active but not related to project" do
let(:deploy_token) { create(:deploy_token) }
it { is_expected.to be_falsy }
end
- context 'when deploy token is revoked and related to project' do
+ context "when deploy token is revoked and related to project" do
let(:deploy_token) { create(:deploy_token, :revoked, projects: [project]) }
it { is_expected.to be_falsy }
end
- context 'when deploy token is revoked and not related to the project' do
+ context "when deploy token is revoked and not related to the project" do
let(:deploy_token) { create(:deploy_token, :revoked) }
it { is_expected.to be_falsy }
end
end
- describe '#expires_at' do
- context 'when using Forever.date' do
+ describe "#expires_at" do
+ context "when using Forever.date" do
let(:deploy_token) { create(:deploy_token, expires_at: nil) }
- it 'should return nil' do
+ it "should return nil" do
expect(deploy_token.expires_at).to be_nil
end
end
- context 'when using a personalized date' do
+ context "when using a personalized date" do
let(:expires_at) { Date.today + 5.months }
let(:deploy_token) { create(:deploy_token, expires_at: expires_at) }
- it 'should return the personalized date' do
+ it "should return the personalized date" do
expect(deploy_token.expires_at).to eq(expires_at)
end
end
end
- describe '#expires_at=' do
- context 'when passing nil' do
+ describe "#expires_at=" do
+ context "when passing nil" do
let(:deploy_token) { create(:deploy_token, expires_at: nil) }
- it 'should assign Forever.date' do
+ it "should assign Forever.date" do
expect(deploy_token.read_attribute(:expires_at)).to eq(Forever.date)
end
end
- context 'when passign a value' do
+ context "when passign a value" do
let(:expires_at) { Date.today + 5.months }
let(:deploy_token) { create(:deploy_token, expires_at: expires_at) }
- it 'should respect the value' do
+ it "should respect the value" do
expect(deploy_token.read_attribute(:expires_at)).to eq(expires_at)
end
end
end
- describe '.gitlab_deploy_token' do
- let(:project) { create(:project ) }
+ describe ".gitlab_deploy_token" do
+ let(:project) { create(:project) }
subject { project.deploy_tokens.gitlab_deploy_token }
- context 'with a gitlab deploy token associated' do
- it 'should return the gitlab deploy token' do
+ context "with a gitlab deploy token associated" do
+ it "should return the gitlab deploy token" do
deploy_token = create(:deploy_token, :gitlab_deploy_token, projects: [project])
is_expected.to eq(deploy_token)
end
end
- context 'with no gitlab deploy token associated' do
- it 'should return nil' do
+ context "with no gitlab deploy token associated" do
+ it "should return nil" do
is_expected.to be_nil
end
end
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index a8d53cfcd7d..c2a590f9083 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Deployment do
subject { build(:deployment) }
@@ -16,9 +16,9 @@ describe Deployment do
it { is_expected.to validate_presence_of(:ref) }
it { is_expected.to validate_presence_of(:sha) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe '#scheduled_actions' do
+ describe "#scheduled_actions" do
subject { deployment.scheduled_actions }
let(:project) { create(:project, :repository) }
@@ -26,7 +26,7 @@ describe Deployment do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
let(:deployment) { create(:deployment, deployable: build) }
- it 'delegates to other_scheduled_actions' do
+ it "delegates to other_scheduled_actions" do
expect_any_instance_of(Ci::Build)
.to receive(:other_scheduled_actions)
@@ -34,47 +34,47 @@ describe Deployment do
end
end
- describe 'modules' do
- it_behaves_like 'AtomicInternalId' do
+ describe "modules" do
+ it_behaves_like "AtomicInternalId" do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:deployment) }
let(:scope) { :project }
- let(:scope_attrs) { { project: instance.project } }
+ let(:scope_attrs) { {project: instance.project} }
let(:usage) { :deployments }
end
end
- describe '.success' do
+ describe ".success" do
subject { described_class.success }
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to eq([deployment]) }
end
- context 'when deployment status is created' do
+ context "when deployment status is created" do
let(:deployment) { create(:deployment, :created) }
it { is_expected.to be_empty }
end
- context 'when deployment status is running' do
+ context "when deployment status is running" do
let(:deployment) { create(:deployment, :running) }
it { is_expected.to be_empty }
end
end
- describe 'state machine' do
- context 'when deployment runs' do
+ describe "state machine" do
+ context "when deployment runs" do
let(:deployment) { create(:deployment) }
before do
deployment.run!
end
- it 'starts running' do
+ it "starts running" do
Timecop.freeze do
expect(deployment).to be_running
expect(deployment.finished_at).to be_nil
@@ -82,10 +82,10 @@ describe Deployment do
end
end
- context 'when deployment succeeded' do
+ context "when deployment succeeded" do
let(:deployment) { create(:deployment, :running) }
- it 'has correct status' do
+ it "has correct status" do
Timecop.freeze do
deployment.succeed!
@@ -94,7 +94,7 @@ describe Deployment do
end
end
- it 'executes Deployments::SuccessWorker asynchronously' do
+ it "executes Deployments::SuccessWorker asynchronously" do
expect(Deployments::SuccessWorker)
.to receive(:perform_async).with(deployment.id)
@@ -102,10 +102,10 @@ describe Deployment do
end
end
- context 'when deployment failed' do
+ context "when deployment failed" do
let(:deployment) { create(:deployment, :running) }
- it 'has correct status' do
+ it "has correct status" do
Timecop.freeze do
deployment.drop!
@@ -115,10 +115,10 @@ describe Deployment do
end
end
- context 'when deployment was canceled' do
+ context "when deployment was canceled" do
let(:deployment) { create(:deployment, :running) }
- it 'has correct status' do
+ it "has correct status" do
Timecop.freeze do
deployment.cancel!
@@ -129,54 +129,54 @@ describe Deployment do
end
end
- describe '#success?' do
+ describe "#success?" do
subject { deployment.success? }
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to be_truthy }
end
- context 'when deployment status is failed' do
+ context "when deployment status is failed" do
let(:deployment) { create(:deployment, :failed) }
it { is_expected.to be_falsy }
end
end
- describe '#status_name' do
+ describe "#status_name" do
subject { deployment.status_name }
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to eq(:success) }
end
- context 'when deployment status is failed' do
+ context "when deployment status is failed" do
let(:deployment) { create(:deployment, :failed) }
it { is_expected.to eq(:failed) }
end
end
- describe '#finished_at' do
+ describe "#finished_at" do
subject { deployment.finished_at }
- context 'when deployment status is created' do
+ context "when deployment status is created" do
let(:deployment) { create(:deployment) }
it { is_expected.to be_nil }
end
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to eq(deployment.read_attribute(:finished_at)) }
end
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success, finished_at: nil) }
before do
@@ -186,37 +186,37 @@ describe Deployment do
it { is_expected.to eq(deployment.read_attribute(:created_at)) }
end
- context 'when deployment status is running' do
+ context "when deployment status is running" do
let(:deployment) { create(:deployment, :running) }
it { is_expected.to be_nil }
end
end
- describe '#deployed_at' do
+ describe "#deployed_at" do
subject { deployment.deployed_at }
- context 'when deployment status is created' do
+ context "when deployment status is created" do
let(:deployment) { create(:deployment) }
it { is_expected.to be_nil }
end
- context 'when deployment status is success' do
+ context "when deployment status is success" do
let(:deployment) { create(:deployment, :success) }
it { is_expected.to eq(deployment.read_attribute(:finished_at)) }
end
- context 'when deployment status is running' do
+ context "when deployment status is running" do
let(:deployment) { create(:deployment, :running) }
it { is_expected.to be_nil }
end
end
- describe 'scopes' do
- describe 'last_for_environment' do
+ describe "scopes" do
+ describe "last_for_environment" do
let(:production) { create(:environment) }
let(:staging) { create(:environment) }
let(:testing) { create(:environment) }
@@ -225,11 +225,11 @@ describe Deployment do
[
create(:deployment, environment: production),
create(:deployment, environment: staging),
- create(:deployment, environment: production)
+ create(:deployment, environment: production),
]
end
- it 'retrieves last deployments for environments' do
+ it "retrieves last deployments for environments" do
last_deployments = described_class.last_for_environment([staging, production, testing])
expect(last_deployments.size).to eq(2)
@@ -238,31 +238,31 @@ describe Deployment do
end
end
- describe '#includes_commit?' do
+ describe "#includes_commit?" do
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, project: project) }
let(:deployment) do
create(:deployment, environment: environment, sha: project.commit.id)
end
- context 'when there is no project commit' do
- it 'returns false' do
- commit = project.commit('feature')
+ context "when there is no project commit" do
+ it "returns false" do
+ commit = project.commit("feature")
expect(deployment.includes_commit?(commit)).to be false
end
end
- context 'when they share the same tree branch' do
- it 'returns true' do
+ context "when they share the same tree branch" do
+ it "returns true" do
commit = project.commit
expect(deployment.includes_commit?(commit)).to be true
end
end
- context 'when the SHA for the deployment does not exist in the repo' do
- it 'returns false' do
+ context "when the SHA for the deployment does not exist in the repo" do
+ it "returns false" do
deployment.update(sha: Gitlab::Git::BLANK_SHA)
commit = project.commit
@@ -271,22 +271,22 @@ describe Deployment do
end
end
- describe '#metrics' do
+ describe "#metrics" do
let(:deployment) { create(:deployment, :success) }
- let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
+ let(:prometheus_adapter) { double("prometheus_adapter", can_query?: true) }
subject { deployment.metrics }
- context 'metrics are disabled' do
+ context "metrics are disabled" do
it { is_expected.to eq({}) }
end
- context 'metrics are enabled' do
+ context "metrics are enabled" do
let(:simple_metrics) do
{
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
}
end
@@ -295,62 +295,62 @@ describe Deployment do
allow(prometheus_adapter).to receive(:query).with(:deployment, deployment).and_return(simple_metrics)
end
- it { is_expected.to eq(simple_metrics.merge({ deployment_time: deployment.created_at.to_i })) }
+ it { is_expected.to eq(simple_metrics.merge({deployment_time: deployment.created_at.to_i})) }
end
end
- describe '#additional_metrics' do
+ describe "#additional_metrics" do
let(:project) { create(:project, :repository) }
let(:deployment) { create(:deployment, :succeed, project: project) }
subject { deployment.additional_metrics }
- context 'metrics are disabled' do
+ context "metrics are disabled" do
it { is_expected.to eq({}) }
end
- context 'metrics are enabled' do
+ context "metrics are enabled" do
let(:simple_metrics) do
{
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
}
end
- let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
+ let(:prometheus_adapter) { double("prometheus_adapter", can_query?: true) }
before do
allow(deployment).to receive(:prometheus_adapter).and_return(prometheus_adapter)
allow(prometheus_adapter).to receive(:query).with(:additional_metrics_deployment, deployment).and_return(simple_metrics)
end
- it { is_expected.to eq(simple_metrics.merge({ deployment_time: deployment.created_at.to_i })) }
+ it { is_expected.to eq(simple_metrics.merge({deployment_time: deployment.created_at.to_i})) }
end
end
- describe '#stop_action' do
+ describe "#stop_action" do
let(:build) { create(:ci_build) }
subject { deployment.stop_action }
- context 'when no other actions' do
+ context "when no other actions" do
let(:deployment) { FactoryBot.build(:deployment, deployable: build) }
it { is_expected.to be_nil }
end
- context 'with other actions' do
- let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: 'close_app') }
+ context "with other actions" do
+ let!(:close_action) { create(:ci_build, :manual, pipeline: build.pipeline, name: "close_app") }
- context 'when matching action is defined' do
- let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: 'close_other_app') }
+ context "when matching action is defined" do
+ let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: "close_other_app") }
it { is_expected.to be_nil }
end
- context 'when no matching action is defined' do
- let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: 'close_app') }
+ context "when no matching action is defined" do
+ let(:deployment) { FactoryBot.build(:deployment, deployable: build, on_stop: "close_app") }
it { is_expected.to eq(close_action) }
end
diff --git a/spec/models/diff_discussion_spec.rb b/spec/models/diff_discussion_spec.rb
index 50b19000799..b960bb76920 100644
--- a/spec/models/diff_discussion_spec.rb
+++ b/spec/models/diff_discussion_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffDiscussion do
include RepoHelpers
@@ -9,27 +9,27 @@ describe DiffDiscussion do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project) }
- describe '#reply_attributes' do
- it 'includes position and original_position' do
+ describe "#reply_attributes" do
+ it "includes position and original_position" do
attributes = subject.reply_attributes
expect(attributes[:position]).to eq(diff_note.position.to_json)
expect(attributes[:original_position]).to eq(diff_note.original_position.to_json)
end
end
- describe '#merge_request_version_params' do
+ describe "#merge_request_version_params" do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, importing: true) }
- let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff1) { merge_request.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
let!(:merge_request_diff2) { merge_request.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff3) { merge_request.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
- context 'when the discussion is active' do
- it 'returns an empty hash, which will end up showing the latest version' do
+ context "when the discussion is active" do
+ it "returns an empty hash, which will end up showing the latest version" do
expect(subject.merge_request_version_params).to eq({})
end
end
- context 'when the discussion is on an older merge request version' do
+ context "when the discussion is on an older merge request version" do
let(:position) do
Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -47,24 +47,24 @@ describe DiffDiscussion do
diff_note.save!
end
- context 'when commit_id is not present' do
- it 'returns the diff ID for the version to show' do
+ context "when commit_id is not present" do
+ it "returns the diff ID for the version to show" do
expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff1.id)
end
end
- context 'when commit_id is present' do
+ context "when commit_id is present" do
before do
- diff_note.update_attribute(:commit_id, 'commit_123')
+ diff_note.update_attribute(:commit_id, "commit_123")
end
- it 'includes the commit_id in the result' do
- expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff1.id, commit_id: 'commit_123')
+ it "includes the commit_id in the result" do
+ expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff1.id, commit_id: "commit_123")
end
end
end
- context 'when the discussion is on a comparison between merge request versions' do
+ context "when the discussion is on a comparison between merge request versions" do
let(:position) do
Gitlab::Diff::Position.new(
old_path: ".gitmodules",
@@ -82,24 +82,24 @@ describe DiffDiscussion do
diff_note.save!
end
- context 'when commit_id is not present' do
- it 'returns the diff ID and start sha of the versions to compare' do
+ context "when commit_id is not present" do
+ it "returns the diff ID and start sha of the versions to compare" do
expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff3.id, start_sha: merge_request_diff1.head_commit_sha)
end
end
- context 'when commit_id is present' do
+ context "when commit_id is present" do
before do
- diff_note.update_attribute(:commit_id, 'commit_123')
+ diff_note.update_attribute(:commit_id, "commit_123")
end
- it 'includes the commit_id in the result' do
- expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff3.id, start_sha: merge_request_diff1.head_commit_sha, commit_id: 'commit_123')
+ it "includes the commit_id in the result" do
+ expect(subject.merge_request_version_params).to eq(diff_id: merge_request_diff3.id, start_sha: merge_request_diff1.head_commit_sha, commit_id: "commit_123")
end
end
end
- context 'when the discussion does not have a merge request version' do
+ context "when the discussion does not have a merge request version" do
let(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: project, diff_refs: project.commit(sample_commit.id).diff_refs) }
before do
@@ -107,19 +107,19 @@ describe DiffDiscussion do
diff_note.save!
end
- context 'when commit_id is not present' do
- it 'returns empty hash' do
+ context "when commit_id is not present" do
+ it "returns empty hash" do
expect(subject.merge_request_version_params).to eq(nil)
end
end
- context 'when commit_id is present' do
+ context "when commit_id is present" do
before do
- diff_note.update_attribute(:commit_id, 'commit_123')
+ diff_note.update_attribute(:commit_id, "commit_123")
end
- it 'returns the commit_id' do
- expect(subject.merge_request_version_params).to eq(commit_id: 'commit_123')
+ it "returns the commit_id" do
+ expect(subject.merge_request_version_params).to eq(commit_id: "commit_123")
end
end
end
diff --git a/spec/models/diff_note_spec.rb b/spec/models/diff_note_spec.rb
index fda00a693f0..41781b167ba 100644
--- a/spec/models/diff_note_spec.rb
+++ b/spec/models/diff_note_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffNote do
include RepoHelpers
@@ -84,40 +84,40 @@ describe DiffNote do
end
end
- describe '#create_diff_file callback' do
+ describe "#create_diff_file callback" do
let(:noteable) { create(:merge_request) }
let(:project) { noteable.project }
- context 'merge request' do
+ context "merge request" do
let!(:diff_note) { create(:diff_note_on_merge_request, project: project, noteable: noteable) }
- it 'creates a diff note file' do
+ it "creates a diff note file" do
expect(diff_note.reload.note_diff_file).to be_present
end
- it 'does not create diff note file if it is a reply' do
+ it "does not create diff note file if it is a reply" do
expect { create(:diff_note_on_merge_request, noteable: noteable, in_reply_to: diff_note) }
.not_to change(NoteDiffFile, :count)
end
end
- context 'commit' do
+ context "commit" do
let!(:diff_note) { create(:diff_note_on_commit, project: project) }
- it 'creates a diff note file' do
+ it "creates a diff note file" do
expect(diff_note.reload.note_diff_file).to be_present
end
- it 'does not create diff note file if it is a reply' do
+ it "does not create diff note file if it is a reply" do
expect { create(:diff_note_on_commit, in_reply_to: diff_note) }
.not_to change(NoteDiffFile, :count)
end
end
end
- describe '#diff_file', :clean_gitlab_redis_shared_state do
- context 'when note_diff_file association exists' do
- it 'returns persisted diff file data' do
+ describe "#diff_file", :clean_gitlab_redis_shared_state do
+ context "when note_diff_file association exists" do
+ it "returns persisted diff file data" do
diff_file = subject.diff_file
expect(diff_file.diff.to_hash.with_indifferent_access)
@@ -125,8 +125,8 @@ describe DiffNote do
end
end
- context 'when the discussion was created in the diff' do
- it 'returns correct diff file' do
+ context "when the discussion was created in the diff" do
+ it "returns correct diff file" do
diff_file = subject.diff_file
expect(diff_file.old_path).to eq(position.old_path)
@@ -135,7 +135,7 @@ describe DiffNote do
end
end
- context 'when discussion is outdated or not created in the diff' do
+ context "when discussion is outdated or not created in the diff" do
let(:diff_refs) { project.commit(sample_commit.id).diff_refs }
let(:position) do
Gitlab::Diff::Position.new(
@@ -147,7 +147,7 @@ describe DiffNote do
)
end
- it 'returns the correct diff file' do
+ it "returns the correct diff file" do
diff_file = subject.diff_file
expect(diff_file.old_path).to eq(position.old_path)
@@ -156,8 +156,8 @@ describe DiffNote do
end
end
- context 'note diff file creation enqueuing' do
- it 'enqueues CreateNoteDiffFileWorker if it is the first note of a discussion' do
+ context "note diff file creation enqueuing" do
+ it "enqueues CreateNoteDiffFileWorker if it is the first note of a discussion" do
subject.note_diff_file.destroy!
expect(CreateNoteDiffFileWorker).to receive(:perform_async).with(subject.id)
@@ -165,7 +165,7 @@ describe DiffNote do
subject.reload.diff_file
end
- it 'does not enqueues CreateNoteDiffFileWorker if not first note of a discussion' do
+ it "does not enqueues CreateNoteDiffFileWorker if not first note of a discussion" do
mr = create(:merge_request)
diff_note = create(:diff_note_on_merge_request, project: mr.project, noteable: mr)
reply_diff_note = create(:diff_note_on_merge_request, in_reply_to: diff_note)
@@ -283,7 +283,7 @@ describe DiffNote do
end
end
- describe '#created_at_diff?' do
+ describe "#created_at_diff?" do
let(:diff_refs) { project.commit(sample_commit.id).diff_refs }
let(:position) do
Gitlab::Diff::Position.new(
@@ -318,17 +318,17 @@ describe DiffNote do
end
end
- describe '#supports_suggestion?' do
- context 'when noteable does not support suggestions' do
- it 'returns false' do
+ describe "#supports_suggestion?" do
+ context "when noteable does not support suggestions" do
+ it "returns false" do
allow(subject.noteable).to receive(:supports_suggestion?) { false }
expect(subject.supports_suggestion?).to be(false)
end
end
- context 'when line is not suggestible' do
- it 'returns false' do
+ context "when line is not suggestible" do
+ it "returns false" do
allow_any_instance_of(Gitlab::Diff::Line).to receive(:suggestible?) { false }
expect(subject.supports_suggestion?).to be(false)
diff --git a/spec/models/diff_viewer/base_spec.rb b/spec/models/diff_viewer/base_spec.rb
index f4efe5a7b3a..c259c23f53a 100644
--- a/spec/models/diff_viewer/base_spec.rb
+++ b/spec/models/diff_viewer/base_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffViewer::Base do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
let(:viewer_class) do
Class.new(described_class) do
include DiffViewer::ServerSide
- self.extensions = %w(jpg)
+ self.extensions = %w[jpg]
self.binary = true
self.collapse_limit = 1.megabyte
self.size_limit = 5.megabytes
@@ -20,145 +20,145 @@ describe DiffViewer::Base do
let(:viewer) { viewer_class.new(diff_file) }
- describe '.can_render?' do
- context 'when the extension is supported' do
- let(:commit) { project.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ describe ".can_render?" do
+ context "when the extension is supported" do
+ let(:commit) { project.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
- context 'when the binaryness matches' do
- it 'returns true' do
+ context "when the binaryness matches" do
+ it "returns true" do
expect(viewer_class.can_render?(diff_file)).to be_truthy
end
end
- context 'when the binaryness does not match' do
- let(:commit) { project.commit_by(oid: 'ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('Gemfile.zip') }
+ context "when the binaryness does not match" do
+ let(:commit) { project.commit_by(oid: "ae73cb07c9eeaf35924a10f713b364d32b2dd34f") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("Gemfile.zip") }
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(diff_file)).to be_falsey
end
end
end
- context 'when the file type is supported' do
- let(:commit) { project.commit('1a0b36b3cdad1d2ee32457c102a8c0b7056fa863') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('LICENSE') }
+ context "when the file type is supported" do
+ let(:commit) { project.commit("1a0b36b3cdad1d2ee32457c102a8c0b7056fa863") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("LICENSE") }
before do
- viewer_class.file_types = %i(license)
+ viewer_class.file_types = %i[license]
viewer_class.binary = false
end
- context 'when the binaryness matches' do
- it 'returns true' do
+ context "when the binaryness matches" do
+ it "returns true" do
expect(viewer_class.can_render?(diff_file)).to be_truthy
end
end
- context 'when the binaryness does not match' do
+ context "when the binaryness does not match" do
before do
allow_any_instance_of(Blob).to receive(:binary_in_repo?).and_return(true)
end
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(diff_file)).to be_falsey
end
end
end
- context 'when the extension and file type are not supported' do
- it 'returns false' do
+ context "when the extension and file type are not supported" do
+ it "returns false" do
expect(viewer_class.can_render?(diff_file)).to be_falsey
end
end
- context 'when the file was renamed and only the old blob is supported' do
- let(:commit) { project.commit_by(oid: '2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/images/6049019_460s.jpg') }
+ context "when the file was renamed and only the old blob is supported" do
+ let(:commit) { project.commit_by(oid: "2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/images/6049019_460s.jpg") }
before do
allow(diff_file).to receive(:renamed_file?).and_return(true)
- viewer_class.extensions = %w(notjpg)
+ viewer_class.extensions = %w[notjpg]
end
- it 'returns false' do
+ it "returns false" do
expect(viewer_class.can_render?(diff_file)).to be_falsey
end
end
end
- describe '#collapsed?' do
- context 'when the combined blob size is larger than the collapse limit' do
+ describe "#collapsed?" do
+ context "when the combined blob size is larger than the collapse limit" do
before do
allow(diff_file).to receive(:raw_size).and_return(1025.kilobytes)
end
- it 'returns true' do
+ it "returns true" do
expect(viewer.collapsed?).to be_truthy
end
end
- context 'when the combined blob size is smaller than the collapse limit' do
- it 'returns false' do
+ context "when the combined blob size is smaller than the collapse limit" do
+ it "returns false" do
expect(viewer.collapsed?).to be_falsey
end
end
end
- describe '#too_large?' do
- context 'when the combined blob size is larger than the size limit' do
+ describe "#too_large?" do
+ context "when the combined blob size is larger than the size limit" do
before do
allow(diff_file).to receive(:raw_size).and_return(6.megabytes)
end
- it 'returns true' do
+ it "returns true" do
expect(viewer.too_large?).to be_truthy
end
end
- context 'when the blob size is smaller than the size limit' do
- it 'returns false' do
+ context "when the blob size is smaller than the size limit" do
+ it "returns false" do
expect(viewer.too_large?).to be_falsey
end
end
end
- describe '#render_error' do
- context 'when the combined blob size is larger than the size limit' do
+ describe "#render_error" do
+ context "when the combined blob size is larger than the size limit" do
before do
allow(diff_file).to receive(:raw_size).and_return(6.megabytes)
end
- it 'returns :too_large' do
+ it "returns :too_large" do
expect(viewer.render_error).to eq(:too_large)
end
end
- context 'when the combined blob size is smaller than the size limit' do
- it 'returns nil' do
+ context "when the combined blob size is smaller than the size limit" do
+ it "returns nil" do
expect(viewer.render_error).to be_nil
end
end
end
- describe '#render_error_message' do
- it 'returns nothing when no render_error' do
+ describe "#render_error_message" do
+ it "returns nothing when no render_error" do
expect(viewer.render_error).to be_nil
expect(viewer.render_error_message).to be_nil
end
- context 'when render_error error' do
+ context "when render_error error" do
before do
allow(viewer).to receive(:render_error).and_return(:too_large)
end
- it 'returns an error message' do
- expect(viewer.render_error_message).to include('it is too large')
+ it "returns an error message" do
+ expect(viewer.render_error_message).to include("it is too large")
end
it 'includes a "view the blob" link' do
- expect(viewer.render_error_message).to include('view the blob')
+ expect(viewer.render_error_message).to include("view the blob")
end
end
end
diff --git a/spec/models/diff_viewer/server_side_spec.rb b/spec/models/diff_viewer/server_side_spec.rb
index 86b14b6ebf3..36d44b7ffbc 100644
--- a/spec/models/diff_viewer/server_side_spec.rb
+++ b/spec/models/diff_viewer/server_side_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffViewer::ServerSide do
set(:project) { create(:project, :repository) }
- let(:commit) { project.commit_by(oid: '570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let!(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ let(:commit) { project.commit_by(oid: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let!(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
let(:viewer_class) do
Class.new(DiffViewer::Base) do
@@ -13,42 +13,42 @@ describe DiffViewer::ServerSide do
subject { viewer_class.new(diff_file) }
- describe '#prepare!' do
- it 'loads all diff file data' do
+ describe "#prepare!" do
+ it "loads all diff file data" do
expect(Blob).to receive(:lazy).at_least(:twice)
subject.prepare!
end
end
- describe '#render_error' do
- context 'when the diff file is stored externally' do
+ describe "#render_error" do
+ context "when the diff file is stored externally" do
before do
allow(diff_file).to receive(:stored_externally?).and_return(true)
end
- it 'return :server_side_but_stored_externally' do
+ it "return :server_side_but_stored_externally" do
expect(subject.render_error).to eq(:server_side_but_stored_externally)
end
end
end
- describe '#render_error_reason' do
- context 'when the diff file is stored externally' do
+ describe "#render_error_reason" do
+ context "when the diff file is stored externally" do
before do
allow(diff_file).to receive(:stored_externally?).and_return(true)
end
- it 'returns error message if stored in LFS' do
+ it "returns error message if stored in LFS" do
allow(diff_file).to receive(:external_storage).and_return(:lfs)
- expect(subject.render_error_message).to include('it is stored in LFS')
+ expect(subject.render_error_message).to include("it is stored in LFS")
end
- it 'returns error message if stored externally' do
+ it "returns error message if stored externally" do
allow(diff_file).to receive(:external_storage).and_return(:foo)
- expect(subject.render_error_message).to include('it is stored externally')
+ expect(subject.render_error_message).to include("it is stored externally")
end
end
end
diff --git a/spec/models/discussion_spec.rb b/spec/models/discussion_spec.rb
index a46f7ed6507..e059cf4b77a 100644
--- a/spec/models/discussion_spec.rb
+++ b/spec/models/discussion_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Discussion do
subject { described_class.new([first_note, second_note, third_note]) }
@@ -8,8 +8,8 @@ describe Discussion do
let(:second_note) { create(:diff_note_on_merge_request, in_reply_to: first_note) }
let(:third_note) { create(:diff_note_on_merge_request) }
- describe '.build' do
- it 'returns a discussion of the right type' do
+ describe ".build" do
+ it "returns a discussion of the right type" do
discussion = described_class.build([first_note, second_note], merge_request)
expect(discussion).to be_a(DiffDiscussion)
expect(discussion.notes.count).to be(2)
@@ -18,12 +18,12 @@ describe Discussion do
end
end
- describe '.build_collection' do
- it 'returns an array of discussions of the right type' do
+ describe ".build_collection" do
+ it "returns an array of discussions of the right type" do
discussions = described_class.build_collection([first_note, second_note, third_note], merge_request)
expect(discussions).to eq([
DiffDiscussion.new([first_note, second_note], merge_request),
- DiffDiscussion.new([third_note], merge_request)
+ DiffDiscussion.new([third_note], merge_request),
])
end
end
diff --git a/spec/models/email_spec.rb b/spec/models/email_spec.rb
index 47eb0717c0c..5172296abca 100644
--- a/spec/models/email_spec.rb
+++ b/spec/models/email_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe Email do
- describe 'validations' do
- it_behaves_like 'an object with email-formated attributes', :email do
+ describe "validations" do
+ it_behaves_like "an object with email-formated attributes", :email do
subject { build(:email) }
end
end
- it 'normalize email value' do
- expect(described_class.new(email: ' inFO@exAMPLe.com ').email)
- .to eq 'info@example.com'
+ it "normalize email value" do
+ expect(described_class.new(email: " inFO@exAMPLe.com ").email)
+ .to eq "info@example.com"
end
- describe '#update_invalid_gpg_signatures' do
+ describe "#update_invalid_gpg_signatures" do
let(:user) do
- create(:user, email: 'tula.torphy@abshire.ca').tap do |user|
+ create(:user, email: "tula.torphy@abshire.ca").tap do |user|
user.skip_reconfirmation!
end
end
let(:user) { create(:user) }
- it 'synchronizes the gpg keys when the email is updated' do
- email = user.emails.create(email: 'new@email.com')
+ it "synchronizes the gpg keys when the email is updated" do
+ email = user.emails.create(email: "new@email.com")
expect(user).to receive(:update_invalid_gpg_signatures)
@@ -29,10 +29,10 @@ describe Email do
end
end
- describe 'scopes' do
+ describe "scopes" do
let(:user) { create(:user) }
- it 'scopes confirmed emails' do
+ it "scopes confirmed emails" do
create(:email, :confirmed, user: user)
create(:email, user: user)
@@ -41,10 +41,10 @@ describe Email do
end
end
- describe 'delegation' do
+ describe "delegation" do
let(:user) { create(:user) }
- it 'delegates to :user' do
+ it "delegates to :user" do
expect(build(:email, user: user).username).to eq user.username
end
end
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index ab1b306e597..705780bc143 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Environment do
let(:project) { create(:project, :stubbed_repository) }
@@ -19,7 +19,7 @@ describe Environment do
it { is_expected.to validate_length_of(:external_url).is_at_most(255) }
- describe '.order_by_last_deployed_at' do
+ describe ".order_by_last_deployed_at" do
let(:project) { create(:project, :repository) }
let!(:environment1) { create(:environment, project: project) }
let!(:environment2) { create(:environment, project: project) }
@@ -28,93 +28,93 @@ describe Environment do
let!(:deployment2) { create(:deployment, environment: environment2) }
let!(:deployment3) { create(:deployment, environment: environment1) }
- it 'returns the environments in order of having been last deployed' do
+ it "returns the environments in order of having been last deployed" do
expect(project.environments.order_by_last_deployed_at.to_a).to eq([environment3, environment2, environment1])
end
end
- describe 'state machine' do
- it 'invalidates the cache after a change' do
+ describe "state machine" do
+ it "invalidates the cache after a change" do
expect(environment).to receive(:expire_etag_cache)
environment.stop
end
end
- describe '.for_name_like' do
+ describe ".for_name_like" do
subject { project.environments.for_name_like(query, limit: limit) }
- let!(:environment) { create(:environment, name: 'production', project: project) }
- let(:query) { 'pro' }
+ let!(:environment) { create(:environment, name: "production", project: project) }
+ let(:query) { "pro" }
let(:limit) { 5 }
- it 'returns a found name' do
+ it "returns a found name" do
is_expected.to include(environment)
end
- context 'when query is production' do
- let(:query) { 'production' }
+ context "when query is production" do
+ let(:query) { "production" }
- it 'returns a found name' do
+ it "returns a found name" do
is_expected.to include(environment)
end
end
- context 'when query is productionA' do
- let(:query) { 'productionA' }
+ context "when query is productionA" do
+ let(:query) { "productionA" }
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to be_empty
end
end
- context 'when query is empty' do
- let(:query) { '' }
+ context "when query is empty" do
+ let(:query) { "" }
- it 'returns a found name' do
+ it "returns a found name" do
is_expected.to include(environment)
end
end
- context 'when query is nil' do
+ context "when query is nil" do
let(:query) { }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(NoMethodError)
end
end
- context 'when query is partially matched in the middle of environment name' do
- let(:query) { 'duction' }
+ context "when query is partially matched in the middle of environment name" do
+ let(:query) { "duction" }
- it 'returns empty array' do
+ it "returns empty array" do
is_expected.to be_empty
end
end
- context 'when query contains a wildcard character' do
- let(:query) { 'produc%' }
+ context "when query contains a wildcard character" do
+ let(:query) { "produc%" }
- it 'prevents wildcard injection' do
+ it "prevents wildcard injection" do
is_expected.to be_empty
end
end
end
- describe '.pluck_names' do
+ describe ".pluck_names" do
subject { described_class.pluck_names }
- let!(:environment) { create(:environment, name: 'production', project: project) }
+ let!(:environment) { create(:environment, name: "production", project: project) }
- it 'plucks names' do
+ it "plucks names" do
is_expected.to eq(%w[production])
end
end
- describe '#expire_etag_cache' do
+ describe "#expire_etag_cache" do
let(:store) { Gitlab::EtagCaching::Store.new }
- it 'changes the cached value' do
+ it "changes the cached value" do
old_value = store.get(environment.etag_cache_key)
environment.stop
@@ -123,71 +123,71 @@ describe Environment do
end
end
- describe '.with_deployment' do
+ describe ".with_deployment" do
subject { described_class.with_deployment(sha) }
let(:environment) { create(:environment) }
let(:sha) { RepoHelpers.sample_commit.id }
- context 'when deployment has the specified sha' do
+ context "when deployment has the specified sha" do
let!(:deployment) { create(:deployment, environment: environment, sha: sha) }
it { is_expected.to eq([environment]) }
end
- context 'when deployment does not have the specified sha' do
- let!(:deployment) { create(:deployment, environment: environment, sha: 'abc') }
+ context "when deployment does not have the specified sha" do
+ let!(:deployment) { create(:deployment, environment: environment, sha: "abc") }
it { is_expected.to be_empty }
end
end
- describe '#folder_name' do
- context 'when it is inside a folder' do
+ describe "#folder_name" do
+ context "when it is inside a folder" do
subject(:environment) do
- create(:environment, name: 'staging/review-1')
+ create(:environment, name: "staging/review-1")
end
- it 'returns a top-level folder name' do
- expect(environment.folder_name).to eq 'staging'
+ it "returns a top-level folder name" do
+ expect(environment.folder_name).to eq "staging"
end
end
- context 'when the environment if a top-level item itself' do
+ context "when the environment if a top-level item itself" do
subject(:environment) do
- create(:environment, name: 'production')
+ create(:environment, name: "production")
end
- it 'returns an environment name' do
- expect(environment.folder_name).to eq 'production'
+ it "returns an environment name" do
+ expect(environment.folder_name).to eq "production"
end
end
end
- describe '#name_without_type' do
- context 'when it is inside a folder' do
+ describe "#name_without_type" do
+ context "when it is inside a folder" do
subject(:environment) do
- create(:environment, name: 'staging/review-1')
+ create(:environment, name: "staging/review-1")
end
- it 'returns name without folder' do
- expect(environment.name_without_type).to eq 'review-1'
+ it "returns name without folder" do
+ expect(environment.name_without_type).to eq "review-1"
end
end
- context 'when the environment if a top-level item itself' do
+ context "when the environment if a top-level item itself" do
subject(:environment) do
- create(:environment, name: 'production')
+ create(:environment, name: "production")
end
- it 'returns full name' do
- expect(environment.name_without_type).to eq 'production'
+ it "returns full name" do
+ expect(environment.name_without_type).to eq "production"
end
end
end
- describe '#nullify_external_url' do
- it 'replaces a blank url with nil' do
+ describe "#nullify_external_url" do
+ it "replaces a blank url with nil" do
env = build(:environment, external_url: "")
expect(env.save).to be true
@@ -195,47 +195,47 @@ describe Environment do
end
end
- describe '#includes_commit?' do
+ describe "#includes_commit?" do
let(:project) { create(:project, :repository) }
- context 'without a last deployment' do
+ context "without a last deployment" do
it "returns false" do
- expect(environment.includes_commit?('HEAD')).to be false
+ expect(environment.includes_commit?("HEAD")).to be false
end
end
- context 'with a last deployment' do
+ context "with a last deployment" do
let!(:deployment) do
- create(:deployment, :success, environment: environment, sha: project.commit('master').id)
+ create(:deployment, :success, environment: environment, sha: project.commit("master").id)
end
- context 'in the same branch' do
- it 'returns true' do
+ context "in the same branch" do
+ it "returns true" do
expect(environment.includes_commit?(RepoHelpers.sample_commit)).to be true
end
end
- context 'not in the same branch' do
+ context "not in the same branch" do
before do
- deployment.update(sha: project.commit('feature').id)
+ deployment.update(sha: project.commit("feature").id)
end
- it 'returns false' do
+ it "returns false" do
expect(environment.includes_commit?(RepoHelpers.sample_commit)).to be false
end
end
end
end
- describe '#update_merge_request_metrics?' do
+ describe "#update_merge_request_metrics?" do
{
- 'production' => true,
- 'production/eu' => true,
- 'production/www.gitlab.com' => true,
- 'productioneu' => false,
- 'Production' => false,
- 'Production/eu' => false,
- 'test-production' => false
+ "production" => true,
+ "production/eu" => true,
+ "production/www.gitlab.com" => true,
+ "productioneu" => false,
+ "Production" => false,
+ "Production/eu" => false,
+ "test-production" => false,
}.each do |name, expected_value|
it "returns #{expected_value} for #{name}" do
env = create(:environment, name: name)
@@ -245,65 +245,65 @@ describe Environment do
end
end
- describe '#first_deployment_for' do
+ describe "#first_deployment_for" do
let(:project) { create(:project, :repository) }
let!(:deployment) { create(:deployment, :succeed, environment: environment, ref: commit.parent.id) }
let!(:deployment1) { create(:deployment, :succeed, environment: environment, ref: commit.id) }
let(:head_commit) { project.commit }
let(:commit) { project.commit.parent }
- it 'returns deployment id for the environment' do
+ it "returns deployment id for the environment" do
expect(environment.first_deployment_for(commit.id)).to eq deployment1
end
- it 'return nil when no deployment is found' do
+ it "return nil when no deployment is found" do
expect(environment.first_deployment_for(head_commit.id)).to eq nil
end
- it 'returns a UTF-8 ref' do
+ it "returns a UTF-8 ref" do
expect(environment.first_deployment_for(commit.id).ref).to be_utf8
end
end
- describe '#environment_type' do
+ describe "#environment_type" do
subject { environment.environment_type }
- it 'sets a environment type if name has multiple segments' do
- environment.update!(name: 'production/worker.gitlab.com')
+ it "sets a environment type if name has multiple segments" do
+ environment.update!(name: "production/worker.gitlab.com")
- is_expected.to eq('production')
+ is_expected.to eq("production")
end
- it 'nullifies a type if it\'s a simple name' do
- environment.update!(name: 'production')
+ it "nullifies a type if it's a simple name" do
+ environment.update!(name: "production")
is_expected.to be_nil
end
end
- describe '#stop_action_available?' do
+ describe "#stop_action_available?" do
subject { environment.stop_action_available? }
- context 'when no other actions' do
+ context "when no other actions" do
it { is_expected.to be_falsey }
end
- context 'when matching action is defined' do
+ context "when matching action is defined" do
let(:build) { create(:ci_build) }
let!(:deployment) do
create(:deployment, :success,
- environment: environment,
- deployable: build,
- on_stop: 'close_app')
+ environment: environment,
+ deployable: build,
+ on_stop: "close_app")
end
let!(:close_action) do
create(:ci_build, :manual, pipeline: build.pipeline,
- name: 'close_app')
+ name: "close_app")
end
- context 'when environment is available' do
+ context "when environment is available" do
before do
environment.start
end
@@ -311,7 +311,7 @@ describe Environment do
it { is_expected.to be_truthy }
end
- context 'when environment is stopped' do
+ context "when environment is stopped" do
before do
environment.stop
end
@@ -321,7 +321,7 @@ describe Environment do
end
end
- describe '#stop_with_action!' do
+ describe "#stop_with_action!" do
let(:user) { create(:user) }
subject { environment.stop_with_action!(user) }
@@ -330,8 +330,8 @@ describe Environment do
expect(environment).to receive(:available?).and_call_original
end
- context 'when no other actions' do
- context 'environment is available' do
+ context "when no other actions" do
+ context "environment is available" do
before do
environment.update(state: :available)
end
@@ -343,7 +343,7 @@ describe Environment do
end
end
- context 'environment is already stopped' do
+ context "environment is already stopped" do
before do
environment.update(state: :stopped)
end
@@ -356,53 +356,53 @@ describe Environment do
end
end
- context 'when matching action is defined' do
+ context "when matching action is defined" do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let!(:deployment) do
create(:deployment, :success,
- environment: environment,
- deployable: build,
- on_stop: 'close_app')
+ environment: environment,
+ deployable: build,
+ on_stop: "close_app")
end
- context 'when user is not allowed to stop environment' do
+ context "when user is not allowed to stop environment" do
let!(:close_action) do
- create(:ci_build, :manual, pipeline: pipeline, name: 'close_app')
+ create(:ci_build, :manual, pipeline: pipeline, name: "close_app")
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- context 'when user is allowed to stop environment' do
+ context "when user is allowed to stop environment" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
+ name: "master", project: project)
end
- context 'when action did not yet finish' do
+ context "when action did not yet finish" do
let!(:close_action) do
- create(:ci_build, :manual, pipeline: pipeline, name: 'close_app')
+ create(:ci_build, :manual, pipeline: pipeline, name: "close_app")
end
- it 'returns the same action' do
+ it "returns the same action" do
expect(subject).to eq(close_action)
expect(subject.user).to eq(user)
end
end
- context 'if action did finish' do
+ context "if action did finish" do
let!(:close_action) do
create(:ci_build, :manual, :success,
- pipeline: pipeline, name: 'close_app')
+ pipeline: pipeline, name: "close_app")
end
- it 'returns a new action of the same type' do
+ it "returns a new action of the same type" do
expect(subject).to be_persisted
expect(subject.name).to eq(close_action.name)
expect(subject.user).to eq(user)
@@ -412,138 +412,138 @@ describe Environment do
end
end
- describe 'recently_updated_on_branch?' do
- subject { environment.recently_updated_on_branch?('feature') }
+ describe "recently_updated_on_branch?" do
+ subject { environment.recently_updated_on_branch?("feature") }
- context 'when last deployment to environment is the most recent one' do
+ context "when last deployment to environment is the most recent one" do
before do
- create(:deployment, :success, environment: environment, ref: 'feature')
+ create(:deployment, :success, environment: environment, ref: "feature")
end
it { is_expected.to be true }
end
- context 'when last deployment to environment is not the most recent' do
+ context "when last deployment to environment is not the most recent" do
before do
- create(:deployment, :success, environment: environment, ref: 'feature')
- create(:deployment, :success, environment: environment, ref: 'master')
+ create(:deployment, :success, environment: environment, ref: "feature")
+ create(:deployment, :success, environment: environment, ref: "master")
end
it { is_expected.to be false }
end
end
- describe '#actions_for' do
+ describe "#actions_for" do
let(:deployment) { create(:deployment, :success, environment: environment) }
let(:pipeline) { deployment.deployable.pipeline }
- let!(:review_action) { create(:ci_build, :manual, name: 'review-apps', pipeline: pipeline, environment: 'review/$CI_COMMIT_REF_NAME' )}
- let!(:production_action) { create(:ci_build, :manual, name: 'production', pipeline: pipeline, environment: 'production' )}
+ let!(:review_action) { create(:ci_build, :manual, name: "review-apps", pipeline: pipeline, environment: "review/$CI_COMMIT_REF_NAME")}
+ let!(:production_action) { create(:ci_build, :manual, name: "production", pipeline: pipeline, environment: "production")}
- it 'returns a list of actions with matching environment' do
- expect(environment.actions_for('review/master')).to contain_exactly(review_action)
+ it "returns a list of actions with matching environment" do
+ expect(environment.actions_for("review/master")).to contain_exactly(review_action)
end
end
- describe '.deployments' do
+ describe ".deployments" do
subject { environment.deployments }
- context 'when there is a deployment record with created status' do
+ context "when there is a deployment record with created status" do
let(:deployment) { create(:deployment, :created, environment: environment) }
- it 'does not return the record' do
+ it "does not return the record" do
is_expected.to be_empty
end
end
- context 'when there is a deployment record with running status' do
+ context "when there is a deployment record with running status" do
let(:deployment) { create(:deployment, :running, environment: environment) }
- it 'does not return the record' do
+ it "does not return the record" do
is_expected.to be_empty
end
end
- context 'when there is a deployment record with success status' do
+ context "when there is a deployment record with success status" do
let(:deployment) { create(:deployment, :success, environment: environment) }
- it 'returns the record' do
+ it "returns the record" do
is_expected.to eq([deployment])
end
end
end
- describe '.last_deployment' do
+ describe ".last_deployment" do
subject { environment.last_deployment }
before do
allow_any_instance_of(Deployment).to receive(:create_ref)
end
- context 'when there is an old deployment record' do
+ context "when there is an old deployment record" do
let!(:previous_deployment) { create(:deployment, :success, environment: environment) }
- context 'when there is a deployment record with created status' do
+ context "when there is a deployment record with created status" do
let!(:deployment) { create(:deployment, environment: environment) }
- it 'returns the previous deployment' do
+ it "returns the previous deployment" do
is_expected.to eq(previous_deployment)
end
end
- context 'when there is a deployment record with running status' do
+ context "when there is a deployment record with running status" do
let!(:deployment) { create(:deployment, :running, environment: environment) }
- it 'returns the previous deployment' do
+ it "returns the previous deployment" do
is_expected.to eq(previous_deployment)
end
end
- context 'when there is a deployment record with success status' do
+ context "when there is a deployment record with success status" do
let!(:deployment) { create(:deployment, :success, environment: environment) }
- it 'returns the latest successful deployment' do
+ it "returns the latest successful deployment" do
is_expected.to eq(deployment)
end
end
end
end
- describe '#has_terminals?' do
+ describe "#has_terminals?" do
subject { environment.has_terminals? }
- context 'when the environment is available' do
- context 'with a deployment service' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- context 'and a deployment' do
+ context "when the environment is available" do
+ context "with a deployment service" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ context "and a deployment" do
let!(:deployment) { create(:deployment, :success, environment: environment) }
it { is_expected.to be_truthy }
end
- context 'but no deployments' do
+ context "but no deployments" do
it { is_expected.to be_falsy }
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'without a deployment service' do
+ context "without a deployment service" do
it { is_expected.to be_falsy }
end
end
- context 'when the environment is unavailable' do
+ context "when the environment is unavailable" do
let(:project) { create(:kubernetes_project) }
before do
@@ -554,25 +554,25 @@ describe Environment do
end
end
- describe '#deployment_platform' do
- context 'when there is a deployment platform for environment' do
+ describe "#deployment_platform" do
+ context "when there is a deployment platform for environment" do
let!(:cluster) do
create(:cluster, :provided_by_gcp,
- environment_scope: '*', projects: [project])
+ environment_scope: "*", projects: [project])
end
- it 'finds a deployment platform' do
+ it "finds a deployment platform" do
expect(environment.deployment_platform).to eq cluster.platform
end
end
- context 'when there is no deployment platform for environment' do
- it 'returns nil' do
+ context "when there is no deployment platform for environment" do
+ it "returns nil" do
expect(environment.deployment_platform).to be_nil
end
end
- it 'checks deployment platforms associated with a project' do
+ it "checks deployment platforms associated with a project" do
expect(project).to receive(:deployment_platform)
.with(environment: environment.name)
@@ -580,16 +580,16 @@ describe Environment do
end
end
- describe '#terminals' do
+ describe "#terminals" do
subject { environment.terminals }
- context 'when the environment has terminals' do
+ context "when the environment has terminals" do
before do
allow(environment).to receive(:has_terminals?).and_return(true)
end
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'returns the terminals from the deployment service' do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "returns the terminals from the deployment service" do
expect(project.deployment_platform)
.to receive(:terminals).with(environment)
.and_return(:fake_terminals)
@@ -598,21 +598,21 @@ describe Environment do
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- context 'when the environment does not have terminals' do
+ context "when the environment does not have terminals" do
before do
allow(environment).to receive(:has_terminals?).and_return(false)
end
@@ -621,29 +621,29 @@ describe Environment do
end
end
- describe '#has_metrics?' do
+ describe "#has_metrics?" do
subject { environment.has_metrics? }
- context 'when the environment is available' do
- context 'with a deployment service' do
+ context "when the environment is available" do
+ context "with a deployment service" do
let(:project) { create(:prometheus_project) }
- context 'and a deployment' do
+ context "and a deployment" do
let!(:deployment) { create(:deployment, environment: environment) }
it { is_expected.to be_truthy }
end
- context 'and no deployments' do
+ context "and no deployments" do
it { is_expected.to be_truthy }
end
end
- context 'without a monitoring service' do
+ context "without a monitoring service" do
it { is_expected.to be_falsy }
end
end
- context 'when the environment is unavailable' do
+ context "when the environment is unavailable" do
let(:project) { create(:prometheus_project) }
before do
@@ -654,16 +654,16 @@ describe Environment do
end
end
- describe '#metrics' do
+ describe "#metrics" do
let(:project) { create(:prometheus_project) }
subject { environment.metrics }
- context 'when the environment has metrics' do
+ context "when the environment has metrics" do
before do
allow(environment).to receive(:has_metrics?).and_return(true)
end
- it 'returns the metrics from the deployment service' do
+ it "returns the metrics from the deployment service" do
expect(environment.prometheus_adapter)
.to receive(:query).with(:environment, environment)
.and_return(:fake_metrics)
@@ -672,7 +672,7 @@ describe Environment do
end
end
- context 'when the environment does not have metrics' do
+ context "when the environment does not have metrics" do
before do
allow(environment).to receive(:has_metrics?).and_return(false)
end
@@ -681,25 +681,25 @@ describe Environment do
end
end
- describe '#additional_metrics' do
+ describe "#additional_metrics" do
let(:project) { create(:prometheus_project) }
subject { environment.additional_metrics }
- context 'when the environment has additional metrics' do
+ context "when the environment has additional metrics" do
before do
allow(environment).to receive(:has_metrics?).and_return(true)
end
- it 'returns the additional metrics from the deployment service' do
+ it "returns the additional metrics from the deployment service" do
expect(environment.prometheus_adapter).to receive(:query)
- .with(:additional_metrics_environment, environment)
- .and_return(:fake_metrics)
+ .with(:additional_metrics_environment, environment)
+ .and_return(:fake_metrics)
is_expected.to eq(:fake_metrics)
end
end
- context 'when the environment does not have metrics' do
+ context "when the environment does not have metrics" do
before do
allow(environment).to receive(:has_metrics?).and_return(false)
end
@@ -708,7 +708,7 @@ describe Environment do
end
end
- describe '#slug' do
+ describe "#slug" do
it "is automatically generated" do
expect(environment.slug).not_to be_nil
end
@@ -730,23 +730,23 @@ describe Environment do
end
end
- describe '#generate_slug' do
+ describe "#generate_slug" do
SUFFIX = "-[a-z0-9]{6}".freeze
{
"staging-12345678901234567" => "staging-123456789" + SUFFIX,
"9-staging-123456789012345" => "env-9-staging-123" + SUFFIX,
- "staging-1234567890123456" => "staging-1234567890123456",
- "production" => "production",
- "PRODUCTION" => "production" + SUFFIX,
- "review/1-foo" => "review-1-foo" + SUFFIX,
- "1-foo" => "env-1-foo" + SUFFIX,
- "1/foo" => "env-1-foo" + SUFFIX,
- "foo-" => "foo" + SUFFIX,
- "foo--bar" => "foo-bar" + SUFFIX,
- "foo**bar" => "foo-bar" + SUFFIX,
- "*-foo" => "env-foo" + SUFFIX,
- "staging-12345678-" => "staging-12345678" + SUFFIX,
- "staging-12345678-01234567" => "staging-12345678" + SUFFIX
+ "staging-1234567890123456" => "staging-1234567890123456",
+ "production" => "production",
+ "PRODUCTION" => "production" + SUFFIX,
+ "review/1-foo" => "review-1-foo" + SUFFIX,
+ "1-foo" => "env-1-foo" + SUFFIX,
+ "1/foo" => "env-1-foo" + SUFFIX,
+ "foo-" => "foo" + SUFFIX,
+ "foo--bar" => "foo-bar" + SUFFIX,
+ "foo**bar" => "foo-bar" + SUFFIX,
+ "*-foo" => "env-foo" + SUFFIX,
+ "staging-12345678-" => "staging-12345678" + SUFFIX,
+ "staging-12345678-01234567" => "staging-12345678" + SUFFIX,
}.each do |name, matcher|
it "returns a slug matching #{matcher}, given #{name}" do
slug = described_class.new(name: name).generate_slug
@@ -756,13 +756,13 @@ describe Environment do
end
end
- describe '#ref_path' do
+ describe "#ref_path" do
subject(:environment) do
- create(:environment, name: 'staging / review-1')
+ create(:environment, name: "staging / review-1")
end
- it 'returns a path that uses the slug and does not have spaces' do
- expect(environment.ref_path).to start_with('refs/environments/staging-review-1-')
+ it "returns a path that uses the slug and does not have spaces" do
+ expect(environment.ref_path).to start_with("refs/environments/staging-review-1-")
end
it "doesn't change when the slug is nil initially" do
@@ -772,37 +772,37 @@ describe Environment do
end
end
- describe '#external_url_for' do
- let(:source_path) { 'source/file.html' }
+ describe "#external_url_for" do
+ let(:source_path) { "source/file.html" }
let(:sha) { RepoHelpers.sample_commit.id }
before do
- environment.external_url = 'http://example.com'
+ environment.external_url = "http://example.com"
end
- context 'when the public path is not known' do
+ context "when the public path is not known" do
before do
allow(project).to receive(:public_path_for_source_path).with(source_path, sha).and_return(nil)
end
- it 'returns nil' do
+ it "returns nil" do
expect(environment.external_url_for(source_path, sha)).to be_nil
end
end
- context 'when the public path is known' do
+ context "when the public path is known" do
before do
- allow(project).to receive(:public_path_for_source_path).with(source_path, sha).and_return('file.html')
+ allow(project).to receive(:public_path_for_source_path).with(source_path, sha).and_return("file.html")
end
- it 'returns the full external URL' do
- expect(environment.external_url_for(source_path, sha)).to eq('http://example.com/file.html')
+ it "returns the full external URL" do
+ expect(environment.external_url_for(source_path, sha)).to eq("http://example.com/file.html")
end
end
end
- describe '#prometheus_adapter' do
- it 'calls prometheus adapter service' do
+ describe "#prometheus_adapter" do
+ it "calls prometheus adapter service" do
expect_any_instance_of(Prometheus::AdapterService).to receive(:prometheus_adapter)
subject.prometheus_adapter
diff --git a/spec/models/environment_status_spec.rb b/spec/models/environment_status_spec.rb
index 9da16dea929..127e00b0581 100644
--- a/spec/models/environment_status_spec.rb
+++ b/spec/models/environment_status_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentStatus do
include ProjectForksHelper
@@ -17,19 +17,19 @@ describe EnvironmentStatus do
it { is_expected.to delegate_method(:deployed_at).to(:deployment) }
it { is_expected.to delegate_method(:status).to(:deployment) }
- describe '#project' do
+ describe "#project" do
subject { environment_status.project }
it { is_expected.to eq(project) }
end
- describe '#merge_request' do
+ describe "#merge_request" do
subject { environment_status.merge_request }
it { is_expected.to eq(merge_request) }
end
- describe '#deployment' do
+ describe "#deployment" do
subject { environment_status.deployment }
it { is_expected.to eq(deployment) }
@@ -49,25 +49,25 @@ describe EnvironmentStatus do
#
# - source: /files\/(.+)/
# public: '\1'
- describe '#changes' do
- it 'contains only added and modified public pages' do
+ describe "#changes" do
+ it "contains only added and modified public pages" do
expect(environment_status.changes).to contain_exactly(
{
- path: 'ruby-style-guide.html',
- external_url: "#{environment.external_url}/ruby-style-guide.html"
+ path: "ruby-style-guide.html",
+ external_url: "#{environment.external_url}/ruby-style-guide.html",
}, {
- path: 'html/page.html',
- external_url: "#{environment.external_url}/html/page.html"
+ path: "html/page.html",
+ external_url: "#{environment.external_url}/html/page.html",
}
)
end
end
- describe '.for_merge_request' do
+ describe ".for_merge_request" do
let(:admin) { create(:admin) }
let(:pipeline) { create(:ci_pipeline, sha: sha) }
- it 'is based on merge_request.diff_head_sha' do
+ it "is based on merge_request.diff_head_sha" do
expect(merge_request).to receive(:diff_head_sha)
expect(merge_request).not_to receive(:merge_commit_sha)
@@ -75,7 +75,7 @@ describe EnvironmentStatus do
end
end
- describe '.after_merge_request' do
+ describe ".after_merge_request" do
let(:admin) { create(:admin) }
let(:pipeline) { create(:ci_pipeline, sha: sha) }
@@ -83,7 +83,7 @@ describe EnvironmentStatus do
merge_request.mark_as_merged!
end
- it 'is based on merge_request.merge_commit_sha' do
+ it "is based on merge_request.merge_commit_sha" do
expect(merge_request).to receive(:merge_commit_sha)
expect(merge_request).not_to receive(:diff_head_sha)
@@ -91,14 +91,14 @@ describe EnvironmentStatus do
end
end
- describe '.build_environments_status' do
+ describe ".build_environments_status" do
subject { described_class.send(:build_environments_status, merge_request, user, pipeline) }
let!(:build) { create(:ci_build, :deploy_to_production, pipeline: pipeline) }
let(:environment) { build.deployment.environment }
let(:user) { project.owner }
- context 'when environment is created on a forked project' do
+ context "when environment is created on a forked project" do
let(:project) { create(:project, :repository) }
let(:forked) { fork_project(project, user, repository: true) }
let(:sha) { forked.commit.sha }
@@ -106,13 +106,13 @@ describe EnvironmentStatus do
let(:merge_request) do
create(:merge_request,
- source_project: forked,
- target_project: project,
- target_branch: 'master',
- head_pipeline: pipeline)
+ source_project: forked,
+ target_project: project,
+ target_branch: "master",
+ head_pipeline: pipeline)
end
- it 'returns environment status' do
+ it "returns environment status" do
expect(subject.count).to eq(1)
expect(subject[0].environment).to eq(environment)
expect(subject[0].merge_request).to eq(merge_request)
@@ -120,48 +120,48 @@ describe EnvironmentStatus do
end
end
- context 'when environment is created on a target project' do
+ context "when environment is created on a target project" do
let(:project) { create(:project, :repository) }
let(:sha) { project.commit.sha }
let(:pipeline) { create(:ci_pipeline, sha: sha, project: project) }
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: 'feature',
- target_project: project,
- target_branch: 'master',
- head_pipeline: pipeline)
+ source_project: project,
+ source_branch: "feature",
+ target_project: project,
+ target_branch: "master",
+ head_pipeline: pipeline)
end
- it 'returns environment status' do
+ it "returns environment status" do
expect(subject.count).to eq(1)
expect(subject[0].environment).to eq(environment)
expect(subject[0].merge_request).to eq(merge_request)
expect(subject[0].sha).to eq(sha)
end
- context 'when the build stops an environment' do
+ context "when the build stops an environment" do
let!(:build) { create(:ci_build, :stop_review_app, pipeline: pipeline) }
- it 'does not return environment status' do
+ it "does not return environment status" do
expect(subject.count).to eq(0)
end
end
- context 'when user does not have a permission to see the environment' do
+ context "when user does not have a permission to see the environment" do
let(:user) { create(:user) }
- it 'does not return environment status' do
+ it "does not return environment status" do
expect(subject.count).to eq(0)
end
end
- context 'when multiple deployments with the same SHA in different environments' do
+ context "when multiple deployments with the same SHA in different environments" do
let(:pipeline2) { create(:ci_pipeline, sha: sha, project: project) }
let!(:build2) { create(:ci_build, :start_review_app, pipeline: pipeline2) }
- it 'returns deployments related to the head pipeline' do
+ it "returns deployments related to the head pipeline" do
expect(subject.count).to eq(1)
expect(subject[0].environment).to eq(environment)
expect(subject[0].merge_request).to eq(merge_request)
@@ -169,10 +169,10 @@ describe EnvironmentStatus do
end
end
- context 'when multiple deployments in the same pipeline for the same environments' do
+ context "when multiple deployments in the same pipeline for the same environments" do
let!(:build2) { create(:ci_build, :deploy_to_production, pipeline: pipeline) }
- it 'returns unique entries' do
+ it "returns unique entries" do
expect(subject.count).to eq(1)
expect(subject[0].environment).to eq(environment)
expect(subject[0].merge_request).to eq(merge_request)
@@ -180,12 +180,12 @@ describe EnvironmentStatus do
end
end
- context 'when environment is stopped' do
+ context "when environment is stopped" do
before do
environment.stop!
end
- it 'does not return environment status' do
+ it "does not return environment status" do
expect(subject.count).to eq(0)
end
end
diff --git a/spec/models/error_tracking/project_error_tracking_setting_spec.rb b/spec/models/error_tracking/project_error_tracking_setting_spec.rb
index 076ccc96041..79f1d8a783c 100644
--- a/spec/models/error_tracking/project_error_tracking_setting_spec.rb
+++ b/spec/models/error_tracking/project_error_tracking_setting_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ErrorTracking::ProjectErrorTrackingSetting do
include ReactiveCachingHelpers
@@ -9,35 +9,35 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
subject { create(:project_error_tracking_setting, project: project) }
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'Validations' do
- context 'when api_url is over 255 chars' do
+ describe "Validations" do
+ context "when api_url is over 255 chars" do
before do
- subject.api_url = 'https://' + 'a' * 250
+ subject.api_url = "https://" + "a" * 250
end
- it 'fails validation' do
+ it "fails validation" do
expect(subject).not_to be_valid
- expect(subject.errors.messages[:api_url]).to include('is too long (maximum is 255 characters)')
+ expect(subject.errors.messages[:api_url]).to include("is too long (maximum is 255 characters)")
end
end
- context 'With unsafe url' do
- it 'fails validation' do
+ context "With unsafe url" do
+ it "fails validation" do
subject.api_url = "https://replaceme.com/'><script>alert(document.cookie)</script>"
expect(subject).not_to be_valid
end
end
- context 'presence validations' do
+ context "presence validations" do
using RSpec::Parameterized::TableSyntax
- valid_api_url = 'http://example.com/api/0/projects/org-slug/proj-slug/'
- valid_token = 'token'
+ valid_api_url = "http://example.com/api/0/projects/org-slug/proj-slug/"
+ valid_token = "token"
where(:enabled, :token, :api_url, :valid?) do
true | nil | nil | false
@@ -61,66 +61,66 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
- context 'URL path' do
- it 'fails validation with wrong path' do
- subject.api_url = 'http://gitlab.com/project1/something'
+ context "URL path" do
+ it "fails validation with wrong path" do
+ subject.api_url = "http://gitlab.com/project1/something"
expect(subject).not_to be_valid
- expect(subject.errors.messages[:api_url]).to include('path needs to start with /api/0/projects')
+ expect(subject.errors.messages[:api_url]).to include("path needs to start with /api/0/projects")
end
- it 'passes validation with correct path' do
- subject.api_url = 'http://gitlab.com/api/0/projects/project1/something'
+ it "passes validation with correct path" do
+ subject.api_url = "http://gitlab.com/api/0/projects/project1/something"
expect(subject).to be_valid
end
end
- context 'non ascii chars in api_url' do
+ context "non ascii chars in api_url" do
before do
- subject.api_url = 'http://gitlab.com/api/0/projects/project1/something€'
+ subject.api_url = "http://gitlab.com/api/0/projects/project1/something€"
end
- it 'fails validation' do
+ it "fails validation" do
expect(subject).not_to be_valid
end
end
end
- describe '#sentry_external_url' do
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
+ describe "#sentry_external_url" do
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project" }
before do
subject.api_url = sentry_url
end
- it 'returns the correct url' do
+ it "returns the correct url" do
expect(subject.class).to receive(:extract_sentry_external_url).with(sentry_url).and_call_original
result = subject.sentry_external_url
- expect(result).to eq('https://sentrytest.gitlab.com/sentry-org/sentry-project')
+ expect(result).to eq("https://sentrytest.gitlab.com/sentry-org/sentry-project")
end
end
- describe '#sentry_client' do
- it 'returns sentry client' do
+ describe "#sentry_client" do
+ it "returns sentry client" do
expect(subject.sentry_client).to be_a(Sentry::Client)
end
end
- describe '#list_sentry_issues' do
+ describe "#list_sentry_issues" do
let(:issues) { [:list, :of, :issues] }
let(:opts) do
- { issue_status: 'unresolved', limit: 10 }
+ {issue_status: "unresolved", limit: 10}
end
let(:result) do
subject.list_sentry_issues(**opts)
end
- context 'when cached' do
+ context "when cached" do
let(:sentry_client) { spy(:sentry_client) }
before do
@@ -130,7 +130,7 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
expect(subject).to receive(:sentry_client).and_return(sentry_client)
end
- it 'returns cached issues' do
+ it "returns cached issues" do
expect(sentry_client).to receive(:list_issues).with(opts)
.and_return(issues)
@@ -138,15 +138,15 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
- context 'when not cached' do
- it 'returns nil' do
+ context "when not cached" do
+ it "returns nil" do
expect(subject).not_to receive(:sentry_client)
expect(result).to be_nil
end
end
- context 'when sentry client raises exception' do
+ context "when sentry client raises exception" do
let(:sentry_client) { spy(:sentry_client) }
before do
@@ -154,22 +154,22 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
allow(subject).to receive(:sentry_client).and_return(sentry_client)
allow(sentry_client).to receive(:list_issues).with(opts)
- .and_raise(Sentry::Client::Error, 'error message')
+ .and_raise(Sentry::Client::Error, "error message")
end
- it 'returns error' do
- expect(result).to eq(error: 'error message')
+ it "returns error" do
+ expect(result).to eq(error: "error message")
expect(subject).to have_received(:sentry_client)
expect(sentry_client).to have_received(:list_issues)
end
end
end
- describe '#list_sentry_projects' do
+ describe "#list_sentry_projects" do
let(:projects) { [:list, :of, :projects] }
let(:sentry_client) { spy(:sentry_client) }
- it 'calls sentry client' do
+ it "calls sentry client" do
expect(subject).to receive(:sentry_client).and_return(sentry_client)
expect(sentry_client).to receive(:list_projects).and_return(projects)
@@ -179,60 +179,60 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
- context 'slugs' do
- shared_examples_for 'slug from api_url' do |method, slug|
- context 'when api_url is correct' do
+ context "slugs" do
+ shared_examples_for "slug from api_url" do |method, slug|
+ context "when api_url is correct" do
before do
- subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug/'
+ subject.api_url = "http://gitlab.com/api/0/projects/org-slug/project-slug/"
end
- it 'returns slug' do
+ it "returns slug" do
expect(subject.public_send(method)).to eq(slug)
end
end
- context 'when api_url is blank' do
+ context "when api_url is blank" do
before do
subject.api_url = nil
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.public_send(method)).to be_nil
end
end
end
- it_behaves_like 'slug from api_url', :project_slug, 'project-slug'
- it_behaves_like 'slug from api_url', :organization_slug, 'org-slug'
+ it_behaves_like "slug from api_url", :project_slug, "project-slug"
+ it_behaves_like "slug from api_url", :organization_slug, "org-slug"
end
- context 'names from api_url' do
- shared_examples_for 'name from api_url' do |name, titleized_slug|
- context 'name is present in DB' do
- it 'returns name from DB' do
- subject[name] = 'Sentry name'
- subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug'
+ context "names from api_url" do
+ shared_examples_for "name from api_url" do |name, titleized_slug|
+ context "name is present in DB" do
+ it "returns name from DB" do
+ subject[name] = "Sentry name"
+ subject.api_url = "http://gitlab.com/api/0/projects/org-slug/project-slug"
- expect(subject.public_send(name)).to eq('Sentry name')
+ expect(subject.public_send(name)).to eq("Sentry name")
end
end
- context 'name is null in DB' do
- it 'titleizes and returns slug from api_url' do
+ context "name is null in DB" do
+ it "titleizes and returns slug from api_url" do
subject[name] = nil
- subject.api_url = 'http://gitlab.com/api/0/projects/org-slug/project-slug'
+ subject.api_url = "http://gitlab.com/api/0/projects/org-slug/project-slug"
expect(subject.public_send(name)).to eq(titleized_slug)
end
- it 'returns nil when api_url is incorrect' do
+ it "returns nil when api_url is incorrect" do
subject[name] = nil
- subject.api_url = 'http://gitlab.com/api/0/projects/'
+ subject.api_url = "http://gitlab.com/api/0/projects/"
expect(subject.public_send(name)).to be_nil
end
- it 'returns nil when api_url is blank' do
+ it "returns nil when api_url is blank" do
subject[name] = nil
subject.api_url = nil
@@ -241,59 +241,59 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
- it_behaves_like 'name from api_url', :organization_name, 'Org Slug'
- it_behaves_like 'name from api_url', :project_name, 'Project Slug'
+ it_behaves_like "name from api_url", :organization_name, "Org Slug"
+ it_behaves_like "name from api_url", :project_name, "Project Slug"
end
- describe '.build_api_url_from' do
- it 'correctly builds api_url with slugs' do
+ describe ".build_api_url_from" do
+ it "correctly builds api_url with slugs" do
api_url = described_class.build_api_url_from(
- api_host: 'http://sentry.com/',
- organization_slug: 'org-slug',
- project_slug: 'proj-slug'
+ api_host: "http://sentry.com/",
+ organization_slug: "org-slug",
+ project_slug: "proj-slug"
)
- expect(api_url).to eq('http://sentry.com/api/0/projects/org-slug/proj-slug/')
+ expect(api_url).to eq("http://sentry.com/api/0/projects/org-slug/proj-slug/")
end
- it 'correctly builds api_url without slugs' do
+ it "correctly builds api_url without slugs" do
api_url = described_class.build_api_url_from(
- api_host: 'http://sentry.com/',
+ api_host: "http://sentry.com/",
organization_slug: nil,
project_slug: nil
)
- expect(api_url).to eq('http://sentry.com/api/0/projects/')
+ expect(api_url).to eq("http://sentry.com/api/0/projects/")
end
- it 'does not raise exception with invalid url' do
+ it "does not raise exception with invalid url" do
api_url = described_class.build_api_url_from(
- api_host: ':::',
- organization_slug: 'org-slug',
- project_slug: 'proj-slug'
+ api_host: ":::",
+ organization_slug: "org-slug",
+ project_slug: "proj-slug"
)
- expect(api_url).to eq(':::')
+ expect(api_url).to eq(":::")
end
end
- describe '#api_host' do
- context 'when api_url exists' do
+ describe "#api_host" do
+ context "when api_url exists" do
before do
- subject.api_url = 'https://example.com/api/0/projects/org-slug/proj-slug/'
+ subject.api_url = "https://example.com/api/0/projects/org-slug/proj-slug/"
end
- it 'extracts the api_host from api_url' do
- expect(subject.api_host).to eq('https://example.com/')
+ it "extracts the api_host from api_url" do
+ expect(subject.api_host).to eq("https://example.com/")
end
end
- context 'when api_url is nil' do
+ context "when api_url is nil" do
before do
subject.api_url = nil
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.api_url).to eq(nil)
end
end
diff --git a/spec/models/event_collection_spec.rb b/spec/models/event_collection_spec.rb
index 6078f429bdc..bd61bb45d4d 100644
--- a/spec/models/event_collection_spec.rb
+++ b/spec/models/event_collection_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe EventCollection do
- describe '#to_a' do
+ describe "#to_a" do
let(:project) { create(:project_empty_repo) }
let(:projects) { Project.where(id: project.id) }
let(:user) { create(:user) }
@@ -16,31 +16,31 @@ describe EventCollection do
create(:closed_issue_event, project: project, author: user)
end
- it 'returns an Array of events' do
+ it "returns an Array of events" do
events = described_class.new(projects).to_a
expect(events).to be_an_instance_of(Array)
end
- it 'applies a limit to the number of events' do
+ it "applies a limit to the number of events" do
events = described_class.new(projects).to_a
expect(events.length).to eq(20)
end
- it 'can paginate through events' do
+ it "can paginate through events" do
events = described_class.new(projects, offset: 20).to_a
expect(events.length).to eq(1)
end
- it 'returns an empty Array when crossing the maximum page number' do
+ it "returns an empty Array when crossing the maximum page number" do
events = described_class.new(projects, limit: 1, offset: 15).to_a
expect(events).to be_empty
end
- it 'allows filtering of events using an EventFilter' do
+ it "allows filtering of events using an EventFilter" do
filter = EventFilter.new(EventFilter::ISSUE)
events = described_class.new(projects, filter: filter).to_a
diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb
index ce4f8ee4705..92549b8bbd4 100644
--- a/spec/models/event_spec.rb
+++ b/spec/models/event_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Event do
describe "Associations" do
@@ -13,20 +13,20 @@ describe Event do
it { is_expected.to respond_to(:merge_request_title) }
end
- describe 'Callbacks' do
+ describe "Callbacks" do
let(:project) { create(:project) }
- describe 'after_create :reset_project_activity' do
- it 'calls the reset_project_activity method' do
+ describe "after_create :reset_project_activity" do
+ it "calls the reset_project_activity method" do
expect_any_instance_of(described_class).to receive(:reset_project_activity)
create_push_event(project, project.owner)
end
end
- describe 'after_create :set_last_repository_updated_at' do
- context 'with a push event' do
- it 'updates the project last_repository_updated_at' do
+ describe "after_create :set_last_repository_updated_at" do
+ context "with a push event" do
+ it "updates the project last_repository_updated_at" do
project.update(last_repository_updated_at: 1.year.ago)
create_push_event(project, project.owner)
@@ -37,8 +37,8 @@ describe Event do
end
end
- context 'without a push event' do
- it 'does not update the project last_repository_updated_at' do
+ context "without a push event" do
+ it "does not update the project last_repository_updated_at" do
project.update(last_repository_updated_at: 1.year.ago)
create(:closed_issue_event, project: project, author: project.owner)
@@ -50,29 +50,29 @@ describe Event do
end
end
- describe '#set_last_repository_updated_at' do
- it 'only updates once every Event::REPOSITORY_UPDATED_AT_INTERVAL minutes' do
+ describe "#set_last_repository_updated_at" do
+ it "only updates once every Event::REPOSITORY_UPDATED_AT_INTERVAL minutes" do
last_known_timestamp = (Event::REPOSITORY_UPDATED_AT_INTERVAL - 1.minute).ago
project.update(last_repository_updated_at: last_known_timestamp)
project.reload # a reload removes fractions of seconds
- expect do
+ expect {
create_push_event(project, project.owner)
project.reload
- end.not_to change { project.last_repository_updated_at }
+ }.not_to change { project.last_repository_updated_at }
end
end
- describe 'after_create :track_user_interacted_projects' do
+ describe "after_create :track_user_interacted_projects" do
let(:event) { build(:push_event, project: project, author: project.owner) }
- it 'passes event to UserInteractedProject.track' do
+ it "passes event to UserInteractedProject.track" do
expect(UserInteractedProject).to receive(:available?).and_return(true)
expect(UserInteractedProject).to receive(:track).with(event)
event.save
end
- it 'does not call UserInteractedProject.track if its not yet available' do
+ it "does not call UserInteractedProject.track if its not yet available" do
expect(UserInteractedProject).to receive(:available?).and_return(false)
expect(UserInteractedProject).not_to receive(:track)
event.save
@@ -95,7 +95,7 @@ describe Event do
end
end
- describe '#membership_changed?' do
+ describe "#membership_changed?" do
context "created" do
subject { build(:event, :created).membership_changed? }
it { is_expected.to be_falsey }
@@ -122,23 +122,23 @@ describe Event do
end
end
- describe '#note?' do
+ describe "#note?" do
subject { described_class.new(project: target.project, target: target) }
- context 'issue note event' do
+ context "issue note event" do
let(:target) { create(:note_on_issue) }
it { is_expected.to be_note }
end
- context 'merge request diff note event' do
+ context "merge request diff note event" do
let(:target) { create(:legacy_diff_note_on_merge_request) }
it { is_expected.to be_note }
end
end
- describe '#visible_to_user?' do
+ describe "#visible_to_user?" do
let(:project) { create(:project, :public) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
@@ -163,7 +163,7 @@ describe Event do
project.add_guest(guest)
end
- context 'commit note event' do
+ context "commit note event" do
let(:target) { note_on_commit }
it do
@@ -175,7 +175,7 @@ describe Event do
end
end
- context 'private project' do
+ context "private project" do
let(:project) { create(:project, :private) }
it do
@@ -189,8 +189,8 @@ describe Event do
end
end
- context 'issue event' do
- context 'for non confidential issues' do
+ context "issue event" do
+ context "for non confidential issues" do
let(:target) { issue }
it do
@@ -203,7 +203,7 @@ describe Event do
end
end
- context 'for confidential issues' do
+ context "for confidential issues" do
let(:target) { confidential_issue }
it do
@@ -217,8 +217,8 @@ describe Event do
end
end
- context 'issue note event' do
- context 'on non confidential issues' do
+ context "issue note event" do
+ context "on non confidential issues" do
let(:target) { note_on_issue }
it do
@@ -231,7 +231,7 @@ describe Event do
end
end
- context 'on confidential issues' do
+ context "on confidential issues" do
let(:target) { note_on_confidential_issue }
it do
@@ -244,7 +244,7 @@ describe Event do
end
end
- context 'private project' do
+ context "private project" do
let(:project) { create(:project, :private) }
let(:target) { note_on_issue }
@@ -259,7 +259,7 @@ describe Event do
end
end
- context 'merge request diff note event' do
+ context "merge request diff note event" do
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request, source_project: project, author: author, assignee: assignee) }
let(:note_on_merge_request) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project) }
@@ -274,7 +274,7 @@ describe Event do
expect(event.visible_to_user?(admin)).to eq true
end
- context 'private project' do
+ context "private project" do
let(:project) { create(:project, :private) }
it do
@@ -288,7 +288,7 @@ describe Event do
end
end
- context 'milestone event' do
+ context "milestone event" do
let(:target) { milestone_on_project }
it do
@@ -299,7 +299,7 @@ describe Event do
expect(event.visible_to_user?(admin)).to be_truthy
end
- context 'on public project with private issue tracker and merge requests' do
+ context "on public project with private issue tracker and merge requests" do
let(:project) { create(:project, :public, :issues_private, :merge_requests_private) }
it do
@@ -311,7 +311,7 @@ describe Event do
end
end
- context 'on private project' do
+ context "on private project" do
let(:project) { create(:project, :private) }
it do
@@ -324,7 +324,7 @@ describe Event do
end
end
- context 'project snippet note event' do
+ context "project snippet note event" do
let(:target) { note_on_project_snippet }
it do
@@ -336,7 +336,7 @@ describe Event do
expect(event.visible_to_user?(admin)).to be_truthy
end
- context 'on public project with private snippets' do
+ context "on public project with private snippets" do
let(:project) { create(:project, :public, :snippets_private) }
it do
@@ -353,7 +353,7 @@ describe Event do
end
end
- context 'on private project' do
+ context "on private project" do
let(:project) { create(:project, :private) }
it do
@@ -371,7 +371,7 @@ describe Event do
end
end
- context 'personal snippet note event' do
+ context "personal snippet note event" do
let(:target) { note_on_personal_snippet }
it do
@@ -381,7 +381,7 @@ describe Event do
expect(event.visible_to_user?(admin)).to be_truthy
end
- context 'on internal snippet' do
+ context "on internal snippet" do
let(:personal_snippet) { create(:personal_snippet, :internal, author: author) }
it do
@@ -392,7 +392,7 @@ describe Event do
end
end
- context 'on private snippet' do
+ context "on private snippet" do
let(:personal_snippet) { create(:personal_snippet, :private, author: author) }
it do
@@ -405,28 +405,28 @@ describe Event do
end
end
- describe '.limit_recent' do
+ describe ".limit_recent" do
let!(:event1) { create(:closed_issue_event) }
let!(:event2) { create(:closed_issue_event) }
- describe 'without an explicit limit' do
+ describe "without an explicit limit" do
subject { described_class.limit_recent }
it { is_expected.to eq([event2, event1]) }
end
- describe 'with an explicit limit' do
+ describe "with an explicit limit" do
subject { described_class.limit_recent(1) }
it { is_expected.to eq([event2]) }
end
end
- describe '#reset_project_activity' do
+ describe "#reset_project_activity" do
let(:project) { create(:project) }
- context 'when a project was updated less than 1 hour ago' do
- it 'does not update the project' do
+ context "when a project was updated less than 1 hour ago" do
+ it "does not update the project" do
project.update(last_activity_at: Time.now)
expect(project).not_to receive(:update_column)
@@ -436,8 +436,8 @@ describe Event do
end
end
- context 'when a project was updated more than 1 hour ago' do
- it 'updates the project' do
+ context "when a project was updated more than 1 hour ago" do
+ it "updates the project" do
project.update(last_activity_at: 1.year.ago)
create_push_event(project, project.owner)
@@ -449,25 +449,25 @@ describe Event do
end
end
- describe '#authored_by?' do
+ describe "#authored_by?" do
let(:event) { build(:event) }
- it 'returns true when the event author and user are the same' do
+ it "returns true when the event author and user are the same" do
expect(event.authored_by?(event.author)).to eq(true)
end
- it 'returns false when passing nil as an argument' do
+ it "returns false when passing nil as an argument" do
expect(event.authored_by?(nil)).to eq(false)
end
- it 'returns false when the given user is not the author of the event' do
+ it "returns false when the given user is not the author of the event" do
user = double(:user, id: -1)
expect(event.authored_by?(user)).to eq(false)
end
end
- describe '#body?' do
+ describe "#body?" do
let(:push_event) do
event = build(:push_event)
@@ -476,19 +476,19 @@ describe Event do
event
end
- it 'returns true for a push event with commits' do
+ it "returns true for a push event with commits" do
allow(push_event).to receive(:push_with_commits?).and_return(true)
expect(push_event).to be_body
end
- it 'returns false for a push event without a valid commit range' do
+ it "returns false for a push event without a valid commit range" do
allow(push_event).to receive(:push_with_commits?).and_return(false)
expect(push_event).not_to be_body
end
- it 'returns true for a Note event' do
+ it "returns true for a Note event" do
event = build(:event)
allow(event).to receive(:note?).and_return(true)
@@ -496,23 +496,23 @@ describe Event do
expect(event).to be_body
end
- it 'returns true if the target responds to #title' do
+ it "returns true if the target responds to #title" do
event = build(:event)
- allow(event).to receive(:target).and_return(double(:target, title: 'foo'))
+ allow(event).to receive(:target).and_return(double(:target, title: "foo"))
expect(event).to be_body
end
- it 'returns false for a regular event without a target' do
+ it "returns false for a regular event without a target" do
event = build(:event)
expect(event).not_to be_body
end
end
- describe '#target' do
- it 'eager loads the author of an event target' do
+ describe "#target" do
+ it "eager loads the author of an event target" do
create(:closed_issue_event)
events = described_class.preload(:target).all.to_a
@@ -531,10 +531,10 @@ describe Event do
event = create(:push_event, project: project, author: user)
create(:push_event_payload,
- event: event,
- commit_to: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
- commit_count: 0,
- ref: 'master')
+ event: event,
+ commit_to: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
+ commit_count: 0,
+ ref: "master")
event
end
diff --git a/spec/models/external_issue_spec.rb b/spec/models/external_issue_spec.rb
index 83ba22caa03..7f9b7014974 100644
--- a/spec/models/external_issue_spec.rb
+++ b/spec/models/external_issue_spec.rb
@@ -1,50 +1,50 @@
-require 'spec_helper'
+require "spec_helper"
describe ExternalIssue do
- let(:project) { double('project', id: 1, to_reference: 'namespace1/project1') }
- let(:issue) { described_class.new('EXT-1234', project) }
+ let(:project) { double("project", id: 1, to_reference: "namespace1/project1") }
+ let(:issue) { described_class.new("EXT-1234", project) }
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Referable) }
end
- describe '#to_reference' do
- it 'returns a String reference to the object' do
+ describe "#to_reference" do
+ it "returns a String reference to the object" do
expect(issue.to_reference).to eq issue.id
end
end
- describe '#title' do
- it 'returns a title' do
+ describe "#title" do
+ it "returns a title" do
expect(issue.title).to eq "External Issue #{issue}"
end
end
- describe '#reference_link_text' do
- context 'if issue id has a prefix' do
- it 'returns the issue ID' do
- expect(issue.reference_link_text).to eq 'EXT-1234'
+ describe "#reference_link_text" do
+ context "if issue id has a prefix" do
+ it "returns the issue ID" do
+ expect(issue.reference_link_text).to eq "EXT-1234"
end
end
- context 'if issue id is a number' do
- let(:issue) { described_class.new('1234', project) }
- it 'returns the issue ID prefixed by #' do
- expect(issue.reference_link_text).to eq '#1234'
+ context "if issue id is a number" do
+ let(:issue) { described_class.new("1234", project) }
+ it "returns the issue ID prefixed by #" do
+ expect(issue.reference_link_text).to eq "#1234"
end
end
end
- describe '#project_id' do
- it 'returns the ID of the project' do
+ describe "#project_id" do
+ it "returns the ID of the project" do
expect(issue.project_id).to eq(project.id)
end
end
- describe '#hash' do
- it 'returns the hash of its [class, to_s] pair' do
+ describe "#hash" do
+ it "returns the hash of its [class, to_s] pair" do
issue_2 = described_class.new(issue.to_s, project)
expect(issue.hash).to eq(issue_2.hash)
diff --git a/spec/models/fork_network_member_spec.rb b/spec/models/fork_network_member_spec.rb
index 60d04562e6c..25ed80f7fc8 100644
--- a/spec/models/fork_network_member_spec.rb
+++ b/spec/models/fork_network_member_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe ForkNetworkMember do
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:fork_network) }
end
- describe 'destroying a ForkNetworkMember' do
+ describe "destroying a ForkNetworkMember" do
let(:fork_network_member) { create(:fork_network_member) }
let(:fork_network) { fork_network_member.fork_network }
- it 'removes the fork network if it was the last member' do
+ it "removes the fork network if it was the last member" do
fork_network.fork_network_members.destroy_all # rubocop: disable DestroyAll
expect(ForkNetwork.count).to eq(0)
end
- it 'does not destroy the fork network if there are members left' do
+ it "does not destroy the fork network if there are members left" do
fork_network_member.destroy!
# The root of the fork network is left
diff --git a/spec/models/fork_network_spec.rb b/spec/models/fork_network_spec.rb
index a43baf1820a..b39123bb6a9 100644
--- a/spec/models/fork_network_spec.rb
+++ b/spec/models/fork_network_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe ForkNetwork do
include ProjectForksHelper
- describe '#add_root_as_member' do
- it 'adds the root project as a member when creating a new root network' do
+ describe "#add_root_as_member" do
+ it "adds the root project as a member when creating a new root network" do
project = create(:project)
fork_network = described_class.create(root_project: project)
@@ -12,20 +12,20 @@ describe ForkNetwork do
end
end
- describe '#find_fork_in' do
- it 'finds all fork of the current network in al collection' do
+ describe "#find_fork_in" do
+ it "finds all fork of the current network in al collection" do
network = create(:fork_network)
root_project = network.root_project
another_project = fork_project(root_project)
create(:project)
expect(network.find_forks_in(Project.all))
- .to contain_exactly(another_project, root_project)
+ .to contain_exactly(another_project, root_project)
end
end
- describe '#merge_requests' do
- it 'finds merge requests within the fork network' do
+ describe "#merge_requests" do
+ it "finds merge requests within the fork network" do
project = create(:project)
forked_project = fork_project(project)
merge_request = create(:merge_request, source_project: forked_project, target_project: project)
@@ -34,8 +34,8 @@ describe ForkNetwork do
end
end
- context 'for a deleted project' do
- it 'keeps the fork network' do
+ context "for a deleted project" do
+ it "keeps the fork network" do
project = create(:project, :public)
forked = fork_project(project)
project.destroy!
@@ -46,7 +46,7 @@ describe ForkNetwork do
expect(fork_network.root_project).to be_nil
end
- it 'allows multiple fork networks where the root project is deleted' do
+ it "allows multiple fork networks where the root project is deleted" do
first_project = create(:project)
second_project = create(:project)
first_fork = fork_project(first_project)
diff --git a/spec/models/generic_commit_status_spec.rb b/spec/models/generic_commit_status_spec.rb
index a3e68d2e646..72abab394df 100644
--- a/spec/models/generic_commit_status_spec.rb
+++ b/spec/models/generic_commit_status_spec.rb
@@ -1,85 +1,85 @@
-require 'spec_helper'
+require "spec_helper"
describe GenericCommitStatus do
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
- let(:external_url) { 'http://example.gitlab.com/status' }
+ let(:external_url) { "http://example.gitlab.com/status" }
let(:generic_commit_status) do
create(:generic_commit_status, pipeline: pipeline,
target_url: external_url)
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_length_of(:target_url).is_at_most(255) }
it { is_expected.to allow_value(nil).for(:target_url) }
- it { is_expected.to allow_value('http://gitlab.com/s').for(:target_url) }
- it { is_expected.not_to allow_value('javascript:alert(1)').for(:target_url) }
+ it { is_expected.to allow_value("http://gitlab.com/s").for(:target_url) }
+ it { is_expected.not_to allow_value("javascript:alert(1)").for(:target_url) }
end
- describe '#context' do
+ describe "#context" do
subject { generic_commit_status.context }
before do
- generic_commit_status.context = 'my_context'
+ generic_commit_status.context = "my_context"
end
it { is_expected.to eq(generic_commit_status.name) }
end
- describe '#tags' do
+ describe "#tags" do
subject { generic_commit_status.tags }
it { is_expected.to eq([:external]) }
end
- describe '#detailed_status' do
+ describe "#detailed_status" do
let(:user) { create(:user) }
let(:status) { generic_commit_status.detailed_status(user) }
- it 'returns detailed status object' do
+ it "returns detailed status object" do
expect(status).to be_a Gitlab::Ci::Status::Success
end
- context 'when user has ability to see datails' do
+ context "when user has ability to see datails" do
before do
project.add_developer(user)
end
- it 'details path points to an external URL' do
+ it "details path points to an external URL" do
expect(status).to have_details
expect(status.details_path).to eq external_url
end
end
- context 'when user should not see details' do
- it 'does not have details' do
+ context "when user should not see details" do
+ it "does not have details" do
expect(status).not_to have_details
end
end
end
- describe 'set_default_values' do
+ describe "set_default_values" do
before do
generic_commit_status.context = nil
generic_commit_status.stage = nil
generic_commit_status.save
end
- describe '#context' do
+ describe "#context" do
subject { generic_commit_status.context }
it { is_expected.not_to be_nil }
end
- describe '#stage' do
+ describe "#stage" do
subject { generic_commit_status.stage }
it { is_expected.not_to be_nil }
end
end
- describe '#present' do
+ describe "#present" do
subject { generic_commit_status.present }
it { is_expected.to be_a(GenericCommitStatusPresenter) }
diff --git a/spec/models/global_milestone_spec.rb b/spec/models/global_milestone_spec.rb
index f93904065c7..de3ae4e9765 100644
--- a/spec/models/global_milestone_spec.rb
+++ b/spec/models/global_milestone_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe GlobalMilestone do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:group) { create(:group) }
let(:project1) { create(:project, group: group) }
- let(:project2) { create(:project, path: 'gitlab-ci', group: group) }
- let(:project3) { create(:project, path: 'cookbook-gitlab', group: group) }
+ let(:project2) { create(:project, path: "gitlab-ci", group: group) }
+ let(:project3) { create(:project, path: "cookbook-gitlab", group: group) }
- describe '.build_collection' do
+ describe ".build_collection" do
let(:milestone1_due_date) { 2.weeks.from_now.to_date }
let!(:milestone1_project1) do
@@ -69,73 +69,73 @@ describe GlobalMilestone do
[
project1,
project2,
- project3
+ project3,
]
end
let!(:global_milestones) { described_class.build_collection(projects, {}) }
- context 'when building a collection of milestones' do
- it 'has all project milestones' do
+ context "when building a collection of milestones" do
+ it "has all project milestones" do
expect(global_milestones.count).to eq(6)
end
- it 'has all project milestones titles' do
- expect(global_milestones.map(&:title)).to match_array(['Milestone v1.2', 'Milestone v1.2', 'Milestone v1.2', 'VD-123', 'VD-123', 'VD-123'])
+ it "has all project milestones titles" do
+ expect(global_milestones.map(&:title)).to match_array(["Milestone v1.2", "Milestone v1.2", "Milestone v1.2", "VD-123", "VD-123", "VD-123"])
end
- it 'has all project milestones' do
+ it "has all project milestones" do
expect(global_milestones.size).to eq(6)
end
- it 'sorts collection by due date' do
+ it "sorts collection by due date" do
expect(global_milestones.map(&:due_date)).to eq [milestone1_due_date, milestone1_due_date, milestone1_due_date, nil, nil, nil]
end
- it 'filters milestones by search_title when params[:search_title] is present' do
- global_milestones = described_class.build_collection(projects, { search_title: 'v1.2' })
+ it "filters milestones by search_title when params[:search_title] is present" do
+ global_milestones = described_class.build_collection(projects, {search_title: "v1.2"})
- expect(global_milestones.map(&:title)).to match_array(['Milestone v1.2', 'Milestone v1.2', 'Milestone v1.2'])
+ expect(global_milestones.map(&:title)).to match_array(["Milestone v1.2", "Milestone v1.2", "Milestone v1.2"])
end
end
- context 'when adding new milestones' do
- it 'does not add more queries' do
- control_count = ActiveRecord::QueryRecorder.new do
+ context "when adding new milestones" do
+ it "does not add more queries" do
+ control_count = ActiveRecord::QueryRecorder.new {
described_class.build_collection(projects, {})
- end.count
+ }.count
create_list(:milestone, 3, project: project3)
- expect do
+ expect {
described_class.build_collection(projects, {})
- end.not_to exceed_all_query_limit(control_count)
+ }.not_to exceed_all_query_limit(control_count)
end
end
end
- describe '.states_count' do
- context 'when the projects have milestones' do
+ describe ".states_count" do
+ context "when the projects have milestones" do
before do
- create(:closed_milestone, title: 'Active Group Milestone', project: project3)
- create(:active_milestone, title: 'Active Group Milestone', project: project1)
- create(:active_milestone, title: 'Active Group Milestone', project: project2)
- create(:closed_milestone, title: 'Closed Group Milestone', project: project1)
- create(:closed_milestone, title: 'Closed Group Milestone', project: project2)
- create(:closed_milestone, title: 'Closed Group Milestone', project: project3)
- create(:closed_milestone, title: 'Closed Group Milestone 4', group: group)
+ create(:closed_milestone, title: "Active Group Milestone", project: project3)
+ create(:active_milestone, title: "Active Group Milestone", project: project1)
+ create(:active_milestone, title: "Active Group Milestone", project: project2)
+ create(:closed_milestone, title: "Closed Group Milestone", project: project1)
+ create(:closed_milestone, title: "Closed Group Milestone", project: project2)
+ create(:closed_milestone, title: "Closed Group Milestone", project: project3)
+ create(:closed_milestone, title: "Closed Group Milestone 4", group: group)
end
- it 'returns the quantity of global milestones and group milestones in each possible state' do
- expected_count = { opened: 2, closed: 5, all: 7 }
+ it "returns the quantity of global milestones and group milestones in each possible state" do
+ expected_count = {opened: 2, closed: 5, all: 7}
count = described_class.states_count(Project.all, group)
expect(count).to eq(expected_count)
end
- it 'returns the quantity of global milestones in each possible state' do
- expected_count = { opened: 2, closed: 4, all: 6 }
+ it "returns the quantity of global milestones in each possible state" do
+ expected_count = {opened: 2, closed: 4, all: 6}
count = described_class.states_count(Project.all)
@@ -143,13 +143,13 @@ describe GlobalMilestone do
end
end
- context 'when the projects do not have milestones' do
+ context "when the projects do not have milestones" do
before do
project1
end
- it 'returns 0 as the quantity of global milestones in each state' do
- expected_count = { opened: 0, closed: 0, all: 0 }
+ it "returns 0 as the quantity of global milestones in each state" do
+ expected_count = {opened: 0, closed: 0, all: 0}
count = described_class.states_count(Project.all)
@@ -158,47 +158,47 @@ describe GlobalMilestone do
end
end
- describe '#initialize' do
+ describe "#initialize" do
let(:milestone1_project1) { create(:milestone, title: "Milestone v1.2", project: project1) }
subject(:global_milestone) { described_class.new(milestone1_project1) }
- it 'has exactly one group milestone' do
- expect(global_milestone.title).to eq('Milestone v1.2')
+ it "has exactly one group milestone" do
+ expect(global_milestone.title).to eq("Milestone v1.2")
end
- it 'has all project milestones with the same title' do
+ it "has all project milestones with the same title" do
expect(global_milestone.milestone).to eq(milestone1_project1)
end
end
- describe '#safe_title' do
+ describe "#safe_title" do
let(:milestone) { create(:milestone, title: "git / test", project: project1) }
- it 'strips out slashes and spaces' do
+ it "strips out slashes and spaces" do
global_milestone = described_class.new(milestone)
- expect(global_milestone.safe_title).to eq('git-test')
+ expect(global_milestone.safe_title).to eq("git-test")
end
end
- describe '#state' do
- context 'when at least one milestone is active' do
- it 'returns active' do
- title = 'Active Group Milestone'
+ describe "#state" do
+ context "when at least one milestone is active" do
+ it "returns active" do
+ title = "Active Group Milestone"
global_milestone = described_class.new(create(:active_milestone, title: title))
- expect(global_milestone.state).to eq('active')
+ expect(global_milestone.state).to eq("active")
end
end
- context 'when all milestones are closed' do
- it 'returns closed' do
- title = 'Closed Group Milestone'
+ context "when all milestones are closed" do
+ it "returns closed" do
+ title = "Closed Group Milestone"
global_milestone = described_class.new(create(:closed_milestone, title: title))
- expect(global_milestone.state).to eq('closed')
+ expect(global_milestone.state).to eq("closed")
end
end
end
diff --git a/spec/models/gpg_key_spec.rb b/spec/models/gpg_key_spec.rb
index 58a1d2e4ea2..f88b16c45a5 100644
--- a/spec/models/gpg_key_spec.rb
+++ b/spec/models/gpg_key_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe GpgKey do
describe "associations" do
@@ -20,28 +20,28 @@ describe GpgKey do
it { is_expected.not_to allow_value("-----BEGIN PGP PUBLIC KEY BLOCK-----").for(:key) }
it { is_expected.not_to allow_value("-----END PGP PUBLIC KEY BLOCK-----").for(:key) }
it { is_expected.not_to allow_value("key\n-----END PGP PUBLIC KEY BLOCK-----").for(:key) }
- it { is_expected.not_to allow_value('BEGIN PGP').for(:key) }
+ it { is_expected.not_to allow_value("BEGIN PGP").for(:key) }
end
- context 'callbacks' do
- describe 'extract_fingerprint' do
- it 'extracts the fingerprint from the gpg key' do
+ context "callbacks" do
+ describe "extract_fingerprint" do
+ it "extracts the fingerprint from the gpg key" do
gpg_key = described_class.new(key: GpgHelpers::User1.public_key)
gpg_key.valid?
expect(gpg_key.fingerprint).to eq GpgHelpers::User1.fingerprint
end
end
- describe 'extract_primary_keyid' do
- it 'extracts the primary keyid from the gpg key' do
+ describe "extract_primary_keyid" do
+ it "extracts the primary keyid from the gpg key" do
gpg_key = described_class.new(key: GpgHelpers::User1.public_key)
gpg_key.valid?
expect(gpg_key.primary_keyid).to eq GpgHelpers::User1.primary_keyid
end
end
- describe 'generate_subkeys' do
- it 'extracts the subkeys from the gpg key' do
+ describe "generate_subkeys" do
+ it "extracts the subkeys from the gpg key" do
gpg_key = create(:gpg_key, key: GpgHelpers::User1.public_key_with_extra_signing_key)
expect(gpg_key.subkeys.count).to eq(2)
@@ -49,8 +49,8 @@ describe GpgKey do
end
end
- describe '#key=' do
- it 'strips white spaces' do
+ describe "#key=" do
+ it "strips white spaces" do
key = <<~KEY.strip
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1
@@ -62,13 +62,13 @@ describe GpgKey do
expect(described_class.new(key: " #{key} ").key).to eq(key)
end
- it 'does not strip when the key is nil' do
+ it "does not strip when the key is nil" do
expect(described_class.new(key: nil).key).to be_nil
end
end
- describe '#user_infos' do
- it 'returns the user infos from the gpg key' do
+ describe "#user_infos" do
+ it "returns the user infos from the gpg key" do
gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key
expect(Gitlab::Gpg).to receive(:user_infos_from_key).with(gpg_key.key)
@@ -76,98 +76,98 @@ describe GpgKey do
end
end
- describe '#verified_user_infos' do
- it 'returns the user infos if it is verified' do
+ describe "#verified_user_infos" do
+ it "returns the user infos if it is verified" do
user = create :user, email: GpgHelpers::User1.emails.first
gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key, user: user
expect(gpg_key.verified_user_infos).to eq([{
name: GpgHelpers::User1.names.first,
- email: GpgHelpers::User1.emails.first
+ email: GpgHelpers::User1.emails.first,
}])
end
- it 'returns an empty array if the user info is not verified' do
- user = create :user, email: 'unrelated@example.com'
+ it "returns an empty array if the user info is not verified" do
+ user = create :user, email: "unrelated@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User1.public_key, user: user
expect(gpg_key.verified_user_infos).to eq([])
end
end
- describe '#emails_with_verified_status' do
- it 'email is verified if the user has the matching email' do
- user = create :user, email: 'bette.cartwright@example.com'
+ describe "#emails_with_verified_status" do
+ it "email is verified if the user has the matching email" do
+ user = create :user, email: "bette.cartwright@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
create :email, user: user
user.reload
expect(gpg_key.emails_with_verified_status).to eq(
- 'bette.cartwright@example.com' => true,
- 'bette.cartwright@example.net' => false
+ "bette.cartwright@example.com" => true,
+ "bette.cartwright@example.net" => false
)
- create :email, :confirmed, user: user, email: 'bette.cartwright@example.net'
+ create :email, :confirmed, user: user, email: "bette.cartwright@example.net"
user.reload
expect(gpg_key.emails_with_verified_status).to eq(
- 'bette.cartwright@example.com' => true,
- 'bette.cartwright@example.net' => true
+ "bette.cartwright@example.com" => true,
+ "bette.cartwright@example.net" => true
)
end
end
- describe '#verified?' do
- it 'returns true if one of the email addresses in the key belongs to the user' do
- user = create :user, email: 'bette.cartwright@example.com'
+ describe "#verified?" do
+ it "returns true if one of the email addresses in the key belongs to the user" do
+ user = create :user, email: "bette.cartwright@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_truthy
end
- it 'returns false if none of the email addresses in the key does not belong to the user' do
- user = create :user, email: 'someone.else@example.com'
+ it "returns false if none of the email addresses in the key does not belong to the user" do
+ user = create :user, email: "someone.else@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_falsey
end
end
- describe 'verified_and_belongs_to_email?' do
- it 'returns false if none of the email addresses in the key does not belong to the user' do
- user = create :user, email: 'someone.else@example.com'
+ describe "verified_and_belongs_to_email?" do
+ it "returns false if none of the email addresses in the key does not belong to the user" do
+ user = create :user, email: "someone.else@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_falsey
- expect(gpg_key.verified_and_belongs_to_email?('someone.else@example.com')).to be_falsey
+ expect(gpg_key.verified_and_belongs_to_email?("someone.else@example.com")).to be_falsey
end
- it 'returns false if one of the email addresses in the key belongs to the user and does not match the provided email' do
- user = create :user, email: 'bette.cartwright@example.com'
+ it "returns false if one of the email addresses in the key belongs to the user and does not match the provided email" do
+ user = create :user, email: "bette.cartwright@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_truthy
- expect(gpg_key.verified_and_belongs_to_email?('bette.cartwright@example.net')).to be_falsey
+ expect(gpg_key.verified_and_belongs_to_email?("bette.cartwright@example.net")).to be_falsey
end
- it 'returns true if one of the email addresses in the key belongs to the user and matches the provided email' do
- user = create :user, email: 'bette.cartwright@example.com'
+ it "returns true if one of the email addresses in the key belongs to the user and matches the provided email" do
+ user = create :user, email: "bette.cartwright@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_truthy
- expect(gpg_key.verified_and_belongs_to_email?('bette.cartwright@example.com')).to be_truthy
+ expect(gpg_key.verified_and_belongs_to_email?("bette.cartwright@example.com")).to be_truthy
end
- it 'returns true if one of the email addresses in the key belongs to the user and case-insensitively matches the provided email' do
- user = create :user, email: 'bette.cartwright@example.com'
+ it "returns true if one of the email addresses in the key belongs to the user and case-insensitively matches the provided email" do
+ user = create :user, email: "bette.cartwright@example.com"
gpg_key = create :gpg_key, key: GpgHelpers::User2.public_key, user: user
expect(gpg_key.verified?).to be_truthy
- expect(gpg_key.verified_and_belongs_to_email?('Bette.Cartwright@example.com')).to be_truthy
+ expect(gpg_key.verified_and_belongs_to_email?("Bette.Cartwright@example.com")).to be_truthy
end
end
- describe '#revoke' do
- it 'invalidates all associated gpg signatures and destroys the key' do
+ describe "#revoke" do
+ it "invalidates all associated gpg signatures and destroys the key" do
gpg_key = create :gpg_key
gpg_signature = create :gpg_signature, verification_status: :verified, gpg_key: gpg_key
@@ -177,7 +177,7 @@ describe GpgKey do
gpg_key.revoke
expect(gpg_signature.reload).to have_attributes(
- verification_status: 'unknown_key',
+ verification_status: "unknown_key",
gpg_key: nil
)
@@ -185,14 +185,14 @@ describe GpgKey do
# unrelated signature is left untouched
expect(unrelated_gpg_signature.reload).to have_attributes(
- verification_status: 'verified',
+ verification_status: "verified",
gpg_key: unrelated_gpg_key
)
expect(unrelated_gpg_key.destroyed?).to be false
end
- it 'deletes all the associated subkeys' do
+ it "deletes all the associated subkeys" do
gpg_key = create :gpg_key, key: GpgHelpers::User3.public_key
expect(gpg_key.subkeys).to be_present
@@ -202,7 +202,7 @@ describe GpgKey do
expect(gpg_key.subkeys.reload).to be_blank
end
- it 'invalidates all signatures associated to the subkeys' do
+ it "invalidates all signatures associated to the subkeys" do
gpg_key = create :gpg_key, key: GpgHelpers::User3.public_key
gpg_key_subkey = gpg_key.subkeys.last
gpg_signature = create :gpg_signature, verification_status: :verified, gpg_key: gpg_key_subkey
@@ -210,7 +210,7 @@ describe GpgKey do
gpg_key.revoke
expect(gpg_signature.reload).to have_attributes(
- verification_status: 'unknown_key',
+ verification_status: "unknown_key",
gpg_key: nil,
gpg_key_subkey: nil
)
diff --git a/spec/models/gpg_key_subkey_spec.rb b/spec/models/gpg_key_subkey_spec.rb
index 3c86837f47f..3294a86a918 100644
--- a/spec/models/gpg_key_subkey_spec.rb
+++ b/spec/models/gpg_key_subkey_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
+require "rails_helper"
describe GpgKeySubkey do
subject { build(:gpg_key_subkey) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:gpg_key) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:gpg_key_id) }
it { is_expected.to validate_presence_of(:fingerprint) }
it { is_expected.to validate_presence_of(:keyid) }
diff --git a/spec/models/gpg_signature_spec.rb b/spec/models/gpg_signature_spec.rb
index e90319c39b1..44def2565c0 100644
--- a/spec/models/gpg_signature_spec.rb
+++ b/spec/models/gpg_signature_spec.rb
@@ -1,48 +1,48 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe GpgSignature do
- let(:commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33' }
- let!(:project) { create(:project, :repository, path: 'sample-project') }
+ let(:commit_sha) { "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33" }
+ let!(:project) { create(:project, :repository, path: "sample-project") }
let!(:commit) { create(:commit, project: project, sha: commit_sha) }
let(:gpg_signature) { create(:gpg_signature, commit_sha: commit_sha) }
let(:gpg_key) { create(:gpg_key) }
let(:gpg_key_subkey) { create(:gpg_key_subkey) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:gpg_key) }
it { is_expected.to belong_to(:gpg_key_subkey) }
end
- describe 'validation' do
+ describe "validation" do
subject { described_class.new }
it { is_expected.to validate_presence_of(:commit_sha) }
it { is_expected.to validate_presence_of(:project_id) }
it { is_expected.to validate_presence_of(:gpg_key_primary_keyid) }
end
- describe '.safe_create!' do
+ describe ".safe_create!" do
let(:attributes) do
{
commit_sha: commit_sha,
project: project,
- gpg_key_primary_keyid: gpg_key.keyid
+ gpg_key_primary_keyid: gpg_key.keyid,
}
end
- it 'finds a signature by commit sha if it existed' do
+ it "finds a signature by commit sha if it existed" do
gpg_signature
expect(described_class.safe_create!(commit_sha: commit_sha)).to eq(gpg_signature)
end
- it 'creates a new signature if it was not found' do
+ it "creates a new signature if it was not found" do
expect { described_class.safe_create!(attributes) }.to change { described_class.count }.by(1)
end
- it 'assigns the correct attributes when creating' do
+ it "assigns the correct attributes when creating" do
signature = described_class.safe_create!(attributes)
expect(signature.project).to eq(project)
@@ -50,7 +50,7 @@ RSpec.describe GpgSignature do
expect(signature.gpg_key_primary_keyid).to eq(gpg_key.keyid)
end
- it 'does not raise an error in case of a race condition' do
+ it "does not raise an error in case of a race condition" do
expect(described_class).to receive(:find_or_create_by).and_raise(ActiveRecord::RecordNotUnique)
allow(described_class).to receive(:find_or_create_by).and_call_original
@@ -58,28 +58,28 @@ RSpec.describe GpgSignature do
end
end
- describe '#commit' do
- it 'fetches the commit through the project' do
+ describe "#commit" do
+ it "fetches the commit through the project" do
expect_any_instance_of(Project).to receive(:commit).with(commit_sha).and_return(commit)
gpg_signature.commit
end
end
- describe '#gpg_key=' do
- it 'supports the assignment of a GpgKey' do
+ describe "#gpg_key=" do
+ it "supports the assignment of a GpgKey" do
gpg_signature = create(:gpg_signature, gpg_key: gpg_key)
expect(gpg_signature.gpg_key).to be_an_instance_of(GpgKey)
end
- it 'supports the assignment of a GpgKeySubkey' do
+ it "supports the assignment of a GpgKeySubkey" do
gpg_signature = create(:gpg_signature, gpg_key: gpg_key_subkey)
expect(gpg_signature.gpg_key).to be_an_instance_of(GpgKeySubkey)
end
- it 'clears gpg_key and gpg_key_subkey_id when passing nil' do
+ it "clears gpg_key and gpg_key_subkey_id when passing nil" do
gpg_signature.update_attribute(:gpg_key, nil)
expect(gpg_signature.gpg_key_id).to be_nil
@@ -87,17 +87,17 @@ RSpec.describe GpgSignature do
end
end
- describe '#gpg_commit' do
- context 'when commit does not exist' do
- it 'returns nil' do
+ describe "#gpg_commit" do
+ context "when commit does not exist" do
+ it "returns nil" do
allow(gpg_signature).to receive(:commit).and_return(nil)
expect(gpg_signature.gpg_commit).to be_nil
end
end
- context 'when commit exists' do
- it 'returns an instance of Gitlab::Gpg::Commit' do
+ context "when commit exists" do
+ it "returns an instance of Gitlab::Gpg::Commit" do
allow(gpg_signature).to receive(:commit).and_return(commit)
expect(gpg_signature.gpg_commit).to be_an_instance_of(Gitlab::Gpg::Commit)
diff --git a/spec/models/group_custom_attribute_spec.rb b/spec/models/group_custom_attribute_spec.rb
index 7ecb2022567..e911179493b 100644
--- a/spec/models/group_custom_attribute_spec.rb
+++ b/spec/models/group_custom_attribute_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupCustomAttribute do
- describe 'assocations' do
+ describe "assocations" do
it { is_expected.to belong_to(:group) }
end
- describe 'validations' do
+ describe "validations" do
subject { build :group_custom_attribute }
it { is_expected.to validate_presence_of(:group) }
diff --git a/spec/models/group_label_spec.rb b/spec/models/group_label_spec.rb
index d0fc1eaa3ec..89a6ce2d728 100644
--- a/spec/models/group_label_spec.rb
+++ b/spec/models/group_label_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupLabel do
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:group) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:group) }
end
- describe '#subject' do
- it 'aliases group to subject' do
+ describe "#subject" do
+ it "aliases group to subject" do
subject = described_class.new(group: build(:group))
expect(subject.subject).to be(subject.group)
end
end
- describe '#to_reference' do
- let(:label) { create(:group_label, title: 'feature') }
+ describe "#to_reference" do
+ let(:label) { create(:group_label, title: "feature") }
- context 'using id' do
- it 'returns a String reference to the object' do
+ context "using id" do
+ it "returns a String reference to the object" do
expect(label.to_reference).to eq "~#{label.id}"
end
end
- context 'using name' do
- it 'returns a String reference to the object' do
+ context "using name" do
+ it "returns a String reference to the object" do
expect(label.to_reference(format: :name)).to eq %(~"#{label.name}")
end
- it 'uses id when name contains double quote' do
- label = create(:label, name: %q{"irony"})
+ it "uses id when name contains double quote" do
+ label = create(:label, name: '"irony"')
expect(label.to_reference(format: :name)).to eq "~#{label.id}"
end
end
- context 'cross-project' do
+ context "cross-project" do
let(:namespace) { build_stubbed(:namespace) }
- let(:source_project) { build_stubbed(:project, name: 'project-1', namespace: namespace) }
- let(:target_project) { build_stubbed(:project, name: 'project-2', namespace: namespace) }
+ let(:source_project) { build_stubbed(:project, name: "project-1", namespace: namespace) }
+ let(:target_project) { build_stubbed(:project, name: "project-2", namespace: namespace) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(label.to_reference(source_project, target_project: target_project)).to eq %(project-1~#{label.id})
end
end
- context 'using invalid format' do
- it 'raises error' do
+ context "using invalid format" do
+ it "raises error" do
expect { label.to_reference(format: :invalid) }
.to raise_error StandardError, /Unknown format/
end
diff --git a/spec/models/group_milestone_spec.rb b/spec/models/group_milestone_spec.rb
index fcc33cd95fe..174f5ebf732 100644
--- a/spec/models/group_milestone_spec.rb
+++ b/spec/models/group_milestone_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupMilestone do
let(:group) { create(:group) }
@@ -7,8 +7,8 @@ describe GroupMilestone do
create(:milestone, title: "Milestone v1.2", project: project)
end
- describe '.build' do
- it 'returns milestone with group assigned' do
+ describe ".build" do
+ it "returns milestone with group assigned" do
milestone = described_class.build(
group,
[project],
@@ -19,36 +19,36 @@ describe GroupMilestone do
end
end
- describe '.build_collection' do
+ describe ".build_collection" do
let(:group) { create(:group) }
let(:project1) { create(:project, group: group) }
- let(:project2) { create(:project, path: 'gitlab-ci', group: group) }
- let(:project3) { create(:project, path: 'cookbook-gitlab', group: group) }
+ let(:project2) { create(:project, path: "gitlab-ci", group: group) }
+ let(:project3) { create(:project, path: "cookbook-gitlab", group: group) }
let!(:projects) do
[
- project1,
- project2,
- project3
+ project1,
+ project2,
+ project3,
]
end
- it 'returns array of milestones, each with group assigned' do
+ it "returns array of milestones, each with group assigned" do
milestones = described_class.build_collection(group, [project], {})
expect(milestones).to all(have_attributes(group: group))
end
- context 'when adding new milestones' do
- it 'does not add more queries' do
- control_count = ActiveRecord::QueryRecorder.new do
+ context "when adding new milestones" do
+ it "does not add more queries" do
+ control_count = ActiveRecord::QueryRecorder.new {
described_class.build_collection(group, projects, {})
- end.count
+ }.count
- create(:milestone, title: 'This title', project: project1)
+ create(:milestone, title: "This title", project: project1)
- expect do
+ expect {
described_class.build_collection(group, projects, {})
- end.not_to exceed_all_query_limit(control_count)
+ }.not_to exceed_all_query_limit(control_count)
end
end
end
diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb
index 9dc32a815d8..e1346ab2a57 100644
--- a/spec/models/group_spec.rb
+++ b/spec/models/group_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Group do
let!(:group) { create(:group, :access_requestable) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to have_many :projects }
it { is_expected.to have_many(:group_members).dependent(:destroy) }
it { is_expected.to have_many(:users).through(:group_members) }
@@ -13,16 +13,16 @@ describe Group do
it { is_expected.to have_many(:project_group_links).dependent(:destroy) }
it { is_expected.to have_many(:shared_projects).through(:project_group_links) }
it { is_expected.to have_many(:notification_settings).dependent(:destroy) }
- it { is_expected.to have_many(:labels).class_name('GroupLabel') }
- it { is_expected.to have_many(:variables).class_name('Ci::GroupVariable') }
+ it { is_expected.to have_many(:labels).class_name("GroupLabel") }
+ it { is_expected.to have_many(:variables).class_name("Ci::GroupVariable") }
it { is_expected.to have_many(:uploads) }
it { is_expected.to have_one(:chat_team) }
- it { is_expected.to have_many(:custom_attributes).class_name('GroupCustomAttribute') }
- it { is_expected.to have_many(:badges).class_name('GroupBadge') }
- it { is_expected.to have_many(:cluster_groups).class_name('Clusters::Group') }
- it { is_expected.to have_many(:clusters).class_name('Clusters::Cluster') }
+ it { is_expected.to have_many(:custom_attributes).class_name("GroupCustomAttribute") }
+ it { is_expected.to have_many(:badges).class_name("GroupBadge") }
+ it { is_expected.to have_many(:cluster_groups).class_name("Clusters::Group") }
+ it { is_expected.to have_many(:clusters).class_name("Clusters::Cluster") }
- describe '#members & #requesters' do
+ describe "#members & #requesters" do
let(:requester) { create(:user) }
let(:developer) { create(:user) }
before do
@@ -30,46 +30,46 @@ describe Group do
group.add_developer(developer)
end
- it_behaves_like 'members and requesters associations' do
+ it_behaves_like "members and requesters associations" do
let(:namespace) { group }
end
end
end
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Referable) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :path }
it { is_expected.not_to validate_presence_of :owner }
it { is_expected.to validate_presence_of :two_factor_grace_period }
it { is_expected.to validate_numericality_of(:two_factor_grace_period).is_greater_than_or_equal_to(0) }
- describe 'path validation' do
- it 'rejects paths reserved on the root namespace when the group has no parent' do
- group = build(:group, path: 'api')
+ describe "path validation" do
+ it "rejects paths reserved on the root namespace when the group has no parent" do
+ group = build(:group, path: "api")
expect(group).not_to be_valid
end
- it 'allows root paths when the group has a parent' do
- group = build(:group, path: 'api', parent: create(:group))
+ it "allows root paths when the group has a parent" do
+ group = build(:group, path: "api", parent: create(:group))
expect(group).to be_valid
end
- it 'rejects any wildcard paths when not a top level group' do
- group = build(:group, path: 'tree', parent: create(:group))
+ it "rejects any wildcard paths when not a top level group" do
+ group = build(:group, path: "tree", parent: create(:group))
expect(group).not_to be_valid
end
end
- describe '#notification_settings', :nested_groups do
+ describe "#notification_settings", :nested_groups do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:sub_group) { create(:group, parent_id: group.id) }
@@ -79,44 +79,44 @@ describe Group do
sub_group.add_maintainer(user)
end
- it 'also gets notification settings from parent groups' do
+ it "also gets notification settings from parent groups" do
expect(sub_group.notification_settings.size).to eq(2)
expect(sub_group.notification_settings).to include(group.notification_settings.first)
end
- context 'when sub group is deleted' do
- it 'does not delete parent notification settings' do
- expect do
+ context "when sub group is deleted" do
+ it "does not delete parent notification settings" do
+ expect {
sub_group.destroy
- end.to change { NotificationSetting.count }.by(-1)
+ }.to change { NotificationSetting.count }.by(-1)
end
end
end
- describe '#visibility_level_allowed_by_parent' do
+ describe "#visibility_level_allowed_by_parent" do
let(:parent) { create(:group, :internal) }
let(:sub_group) { build(:group, parent_id: parent.id) }
- context 'without a parent' do
- it 'is valid' do
+ context "without a parent" do
+ it "is valid" do
sub_group.parent_id = nil
expect(sub_group).to be_valid
end
end
- context 'with a parent' do
- context 'when visibility of sub group is greater than the parent' do
- it 'is invalid' do
+ context "with a parent" do
+ context "when visibility of sub group is greater than the parent" do
+ it "is invalid" do
sub_group.visibility_level = Gitlab::VisibilityLevel::PUBLIC
expect(sub_group).to be_invalid
end
end
- context 'when visibility of sub group is lower or equal to the parent' do
+ context "when visibility of sub group is lower or equal to the parent" do
[Gitlab::VisibilityLevel::INTERNAL, Gitlab::VisibilityLevel::PRIVATE].each do |level|
- it 'is valid' do
+ it "is valid" do
sub_group.visibility_level = level
expect(sub_group).to be_valid
@@ -126,21 +126,21 @@ describe Group do
end
end
- describe '#visibility_level_allowed_by_projects' do
+ describe "#visibility_level_allowed_by_projects" do
let!(:internal_group) { create(:group, :internal) }
let!(:internal_project) { create(:project, :internal, group: internal_group) }
- context 'when group has a lower visibility' do
- it 'is invalid' do
+ context "when group has a lower visibility" do
+ it "is invalid" do
internal_group.visibility_level = Gitlab::VisibilityLevel::PRIVATE
expect(internal_group).to be_invalid
- expect(internal_group.errors[:visibility_level]).to include('private is not allowed since this group contains projects with higher visibility.')
+ expect(internal_group.errors[:visibility_level]).to include("private is not allowed since this group contains projects with higher visibility.")
end
end
- context 'when group has a higher visibility' do
- it 'is valid' do
+ context "when group has a higher visibility" do
+ it "is valid" do
internal_group.visibility_level = Gitlab::VisibilityLevel::PUBLIC
expect(internal_group).to be_valid
@@ -148,21 +148,21 @@ describe Group do
end
end
- describe '#visibility_level_allowed_by_sub_groups' do
+ describe "#visibility_level_allowed_by_sub_groups" do
let!(:internal_group) { create(:group, :internal) }
let!(:internal_sub_group) { create(:group, :internal, parent: internal_group) }
- context 'when parent group has a lower visibility' do
- it 'is invalid' do
+ context "when parent group has a lower visibility" do
+ it "is invalid" do
internal_group.visibility_level = Gitlab::VisibilityLevel::PRIVATE
expect(internal_group).to be_invalid
- expect(internal_group.errors[:visibility_level]).to include('private is not allowed since there are sub-groups with higher visibility.')
+ expect(internal_group.errors[:visibility_level]).to include("private is not allowed since there are sub-groups with higher visibility.")
end
end
- context 'when parent group has a higher visibility' do
- it 'is valid' do
+ context "when parent group has a higher visibility" do
+ it "is valid" do
internal_group.visibility_level = Gitlab::VisibilityLevel::PUBLIC
expect(internal_group).to be_valid
@@ -171,26 +171,26 @@ describe Group do
end
end
- describe '.public_or_visible_to_user' do
+ describe ".public_or_visible_to_user" do
let!(:private_group) { create(:group, :private) }
let!(:internal_group) { create(:group, :internal) }
subject { described_class.public_or_visible_to_user(user) }
- context 'when user is nil' do
+ context "when user is nil" do
let!(:user) { nil }
it { is_expected.to match_array([group]) }
end
- context 'when user' do
+ context "when user" do
let!(:user) { create(:user) }
- context 'when user does not have access to any private group' do
+ context "when user does not have access to any private group" do
it { is_expected.to match_array([internal_group, group]) }
end
- context 'when user is a member of private group' do
+ context "when user is a member of private group" do
before do
private_group.add_user(user, Gitlab::Access::DEVELOPER)
end
@@ -198,7 +198,7 @@ describe Group do
it { is_expected.to match_array([private_group, internal_group, group]) }
end
- context 'when user is a member of private subgroup', :postgresql do
+ context "when user is a member of private subgroup", :postgresql do
let!(:private_subgroup) { create(:group, :private, parent: private_group) }
before do
@@ -210,44 +210,44 @@ describe Group do
end
end
- describe 'scopes' do
+ describe "scopes" do
let!(:private_group) { create(:group, :private) }
let!(:internal_group) { create(:group, :internal) }
- describe 'public_only' do
+ describe "public_only" do
subject { described_class.public_only.to_a }
it { is_expected.to eq([group]) }
end
- describe 'public_and_internal_only' do
+ describe "public_and_internal_only" do
subject { described_class.public_and_internal_only.to_a }
it { is_expected.to match_array([group, internal_group]) }
end
- describe 'non_public_only' do
+ describe "non_public_only" do
subject { described_class.non_public_only.to_a }
it { is_expected.to match_array([private_group, internal_group]) }
end
end
- describe '#to_reference' do
- it 'returns a String reference to the object' do
+ describe "#to_reference" do
+ it "returns a String reference to the object" do
expect(group.to_reference).to eq "@#{group.name}"
end
end
- describe '#users' do
+ describe "#users" do
it { expect(group.users).to eq(group.owners) }
end
- describe '#human_name' do
+ describe "#human_name" do
it { expect(group.human_name).to eq(group.name) }
end
- describe '#add_user' do
+ describe "#add_user" do
let(:user) { create(:user) }
before do
@@ -257,7 +257,7 @@ describe Group do
it { expect(group.group_members.maintainers.map(&:user)).to include(user) }
end
- describe '#add_users' do
+ describe "#add_users" do
let(:user) { create(:user) }
before do
@@ -272,7 +272,7 @@ describe Group do
end
end
- describe '#avatar_type' do
+ describe "#avatar_type" do
let(:user) { create(:user) }
before do
@@ -280,59 +280,59 @@ describe Group do
end
it "is true if avatar is image" do
- group.update_attribute(:avatar, 'uploads/avatar.png')
+ group.update_attribute(:avatar, "uploads/avatar.png")
expect(group.avatar_type).to be_truthy
end
it "is false if avatar is html page" do
- group.update_attribute(:avatar, 'uploads/avatar.html')
+ group.update_attribute(:avatar, "uploads/avatar.html")
expect(group.avatar_type).to eq(["file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico"])
end
end
- describe '#avatar_url' do
+ describe "#avatar_url" do
let!(:group) { create(:group, :access_requestable, :with_avatar) }
let(:user) { create(:user) }
- context 'when avatar file is uploaded' do
+ context "when avatar file is uploaded" do
before do
group.add_maintainer(user)
end
- it 'shows correct avatar url' do
+ it "shows correct avatar url" do
expect(group.avatar_url).to eq(group.avatar.url)
expect(group.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, group.avatar.url].join)
end
end
end
- describe '.search' do
- it 'returns groups with a matching name' do
+ describe ".search" do
+ it "returns groups with a matching name" do
expect(described_class.search(group.name)).to eq([group])
end
- it 'returns groups with a partially matching name' do
+ it "returns groups with a partially matching name" do
expect(described_class.search(group.name[0..2])).to eq([group])
end
- it 'returns groups with a matching name regardless of the casing' do
+ it "returns groups with a matching name regardless of the casing" do
expect(described_class.search(group.name.upcase)).to eq([group])
end
- it 'returns groups with a matching path' do
+ it "returns groups with a matching path" do
expect(described_class.search(group.path)).to eq([group])
end
- it 'returns groups with a partially matching path' do
+ it "returns groups with a partially matching path" do
expect(described_class.search(group.path[0..2])).to eq([group])
end
- it 'returns groups with a matching path regardless of the casing' do
+ it "returns groups with a matching path regardless of the casing" do
expect(described_class.search(group.path.upcase)).to eq([group])
end
end
- describe '#has_owner?' do
+ describe "#has_owner?" do
before do
@members = setup_group_members(group)
create(:group_member, :invited, :owner, group: group)
@@ -347,7 +347,7 @@ describe Group do
it { expect(group.has_owner?(nil)).to be_falsey }
end
- describe '#has_maintainer?' do
+ describe "#has_maintainer?" do
before do
@members = setup_group_members(group)
create(:group_member, :invited, :maintainer, group: group)
@@ -362,45 +362,45 @@ describe Group do
it { expect(group.has_maintainer?(nil)).to be_falsey }
end
- describe '#lfs_enabled?' do
- context 'LFS enabled globally' do
+ describe "#lfs_enabled?" do
+ context "LFS enabled globally" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
- it 'returns true when nothing is set' do
+ it "returns true when nothing is set" do
expect(group.lfs_enabled?).to be_truthy
end
- it 'returns false when set to false' do
+ it "returns false when set to false" do
group.update_attribute(:lfs_enabled, false)
expect(group.lfs_enabled?).to be_falsey
end
- it 'returns true when set to true' do
+ it "returns true when set to true" do
group.update_attribute(:lfs_enabled, true)
expect(group.lfs_enabled?).to be_truthy
end
end
- context 'LFS disabled globally' do
+ context "LFS disabled globally" do
before do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(false)
end
- it 'returns false when nothing is set' do
+ it "returns false when nothing is set" do
expect(group.lfs_enabled?).to be_falsey
end
- it 'returns false when set to false' do
+ it "returns false when set to false" do
group.update_attribute(:lfs_enabled, false)
expect(group.lfs_enabled?).to be_falsey
end
- it 'returns false when set to true' do
+ it "returns false when set to true" do
group.update_attribute(:lfs_enabled, true)
expect(group.lfs_enabled?).to be_falsey
@@ -408,11 +408,11 @@ describe Group do
end
end
- describe '#owners' do
+ describe "#owners" do
let(:owner) { create(:user) }
let(:developer) { create(:user) }
- it 'returns the owners of a Group' do
+ it "returns the owners of a Group" do
group.add_owner(owner)
group.add_developer(developer)
@@ -427,7 +427,7 @@ describe Group do
developer: create(:user),
reporter: create(:user),
guest: create(:user),
- requester: create(:user)
+ requester: create(:user),
}
group.add_user(members[:owner], GroupMember::OWNER)
@@ -440,54 +440,54 @@ describe Group do
members
end
- describe '#web_url' do
- it 'returns the canonical URL' do
+ describe "#web_url" do
+ it "returns the canonical URL" do
expect(group.web_url).to include("groups/#{group.name}")
end
- context 'nested group' do
+ context "nested group" do
let(:nested_group) { create(:group, :nested) }
it { expect(nested_group.web_url).to include("groups/#{nested_group.full_path}") }
end
end
- describe 'nested group' do
+ describe "nested group" do
subject { build(:group, :nested) }
it { is_expected.to be_valid }
it { expect(subject.parent).to be_kind_of(described_class) }
end
- describe '#members_with_parents', :nested_groups do
+ describe "#members_with_parents", :nested_groups do
let!(:group) { create(:group, :nested) }
let!(:maintainer) { group.parent.add_user(create(:user), GroupMember::MAINTAINER) }
let!(:developer) { group.add_user(create(:user), GroupMember::DEVELOPER) }
- it 'returns parents members' do
+ it "returns parents members" do
expect(group.members_with_parents).to include(developer)
expect(group.members_with_parents).to include(maintainer)
end
end
- describe '#direct_and_indirect_members', :nested_groups do
+ describe "#direct_and_indirect_members", :nested_groups do
let!(:group) { create(:group, :nested) }
let!(:sub_group) { create(:group, parent: group) }
let!(:maintainer) { group.parent.add_user(create(:user), GroupMember::MAINTAINER) }
let!(:developer) { group.add_user(create(:user), GroupMember::DEVELOPER) }
let!(:other_developer) { group.add_user(create(:user), GroupMember::DEVELOPER) }
- it 'returns parents members' do
+ it "returns parents members" do
expect(group.direct_and_indirect_members).to include(developer)
expect(group.direct_and_indirect_members).to include(maintainer)
end
- it 'returns descendant members' do
+ it "returns descendant members" do
expect(group.direct_and_indirect_members).to include(other_developer)
end
end
- describe '#users_with_descendants', :nested_groups do
+ describe "#users_with_descendants", :nested_groups do
let(:user_a) { create(:user) }
let(:user_b) { create(:user) }
@@ -495,7 +495,7 @@ describe Group do
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
- it 'returns member users on every nest level without duplication' do
+ it "returns member users on every nest level without duplication" do
group.add_developer(user_a)
nested_group.add_developer(user_b)
deep_nested_group.add_maintainer(user_a)
@@ -506,7 +506,7 @@ describe Group do
end
end
- describe '#direct_and_indirect_users', :nested_groups do
+ describe "#direct_and_indirect_users", :nested_groups do
let(:user_a) { create(:user) }
let(:user_b) { create(:user) }
let(:user_c) { create(:user) }
@@ -525,18 +525,18 @@ describe Group do
project.add_developer(user_d)
end
- it 'returns member users on every nest level without duplication' do
+ it "returns member users on every nest level without duplication" do
expect(group.direct_and_indirect_users).to contain_exactly(user_a, user_b, user_c, user_d)
expect(nested_group.direct_and_indirect_users).to contain_exactly(user_a, user_b, user_c)
expect(deep_nested_group.direct_and_indirect_users).to contain_exactly(user_a, user_b, user_c)
end
- it 'does not return members of projects belonging to ancestor groups' do
+ it "does not return members of projects belonging to ancestor groups" do
expect(nested_group.direct_and_indirect_users).not_to include(user_d)
end
end
- describe '#project_users_with_descendants', :nested_groups do
+ describe "#project_users_with_descendants", :nested_groups do
let(:user_a) { create(:user) }
let(:user_b) { create(:user) }
let(:user_c) { create(:user) }
@@ -548,7 +548,7 @@ describe Group do
let(:project_b) { create(:project, namespace: nested_group) }
let(:project_c) { create(:project, namespace: deep_nested_group) }
- it 'returns members of all projects in group and subgroups' do
+ it "returns members of all projects in group and subgroups" do
project_a.add_developer(user_a)
project_b.add_developer(user_b)
project_c.add_developer(user_c)
@@ -559,8 +559,8 @@ describe Group do
end
end
- describe '#user_ids_for_project_authorizations' do
- it 'returns the user IDs for which to refresh authorizations' do
+ describe "#user_ids_for_project_authorizations" do
+ it "returns the user IDs for which to refresh authorizations" do
maintainer = create(:user)
developer = create(:user)
@@ -572,32 +572,32 @@ describe Group do
end
end
- describe '#update_two_factor_requirement' do
+ describe "#update_two_factor_requirement" do
let(:user) { create(:user) }
before do
group.add_user(user, GroupMember::OWNER)
end
- it 'is called when require_two_factor_authentication is changed' do
+ it "is called when require_two_factor_authentication is changed" do
expect_any_instance_of(User).to receive(:update_two_factor_requirement)
group.update!(require_two_factor_authentication: true)
end
- it 'is called when two_factor_grace_period is changed' do
+ it "is called when two_factor_grace_period is changed" do
expect_any_instance_of(User).to receive(:update_two_factor_requirement)
group.update!(two_factor_grace_period: 23)
end
- it 'is not called when other attributes are changed' do
+ it "is not called when other attributes are changed" do
expect_any_instance_of(User).not_to receive(:update_two_factor_requirement)
- group.update!(description: 'foobar')
+ group.update!(description: "foobar")
end
- it 'calls #update_two_factor_requirement on each group member' do
+ it "calls #update_two_factor_requirement on each group member" do
other_user = create(:user)
group.add_user(other_user, GroupMember::OWNER)
@@ -612,30 +612,30 @@ describe Group do
end
end
- describe '#path_changed_hook' do
+ describe "#path_changed_hook" do
let(:system_hook_service) { SystemHooksService.new }
- context 'for a new group' do
+ context "for a new group" do
let(:group) { build(:group) }
before do
expect(group).to receive(:system_hook_service).and_return(system_hook_service)
end
- it 'does not trigger system hook' do
+ it "does not trigger system hook" do
expect(system_hook_service).to receive(:execute_hooks_for).with(group, :create)
group.save!
end
end
- context 'for an existing group' do
- let(:group) { create(:group, path: 'old-path') }
+ context "for an existing group" do
+ let(:group) { create(:group, path: "old-path") }
- context 'when the path is changed' do
- let(:new_path) { 'very-new-path' }
+ context "when the path is changed" do
+ let(:new_path) { "very-new-path" }
- it 'triggers the rename system hook' do
+ it "triggers the rename system hook" do
expect(group).to receive(:system_hook_service).and_return(system_hook_service)
expect(system_hook_service).to receive(:execute_hooks_for).with(group, :rename)
@@ -643,63 +643,64 @@ describe Group do
end
end
- context 'when the path is not changed' do
- it 'does not trigger system hook' do
+ context "when the path is not changed" do
+ it "does not trigger system hook" do
expect(group).not_to receive(:system_hook_service)
- group.update!(name: 'new name')
+ group.update!(name: "new name")
end
end
end
end
- describe '#ci_variables_for' do
+ describe "#ci_variables_for" do
let(:project) { create(:project, group: group) }
let!(:ci_variable) do
- create(:ci_group_variable, value: 'secret', group: group)
+ create(:ci_group_variable, value: "secret", group: group)
end
let!(:protected_variable) do
- create(:ci_group_variable, :protected, value: 'protected', group: group)
+ create(:ci_group_variable, :protected, value: "protected", group: group)
end
- subject { group.ci_variables_for('ref', project) }
+ subject { group.ci_variables_for("ref", project) }
- shared_examples 'ref is protected' do
- it 'contains all the variables' do
+ shared_examples "ref is protected" do
+ it "contains all the variables" do
is_expected.to contain_exactly(ci_variable, protected_variable)
end
end
- context 'when the ref is not protected' do
+ context "when the ref is not protected" do
before do
stub_application_setting(
- default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+ default_branch_protection: Gitlab::Access::PROTECTION_NONE
+ )
end
- it 'contains only the CI variables' do
+ it "contains only the CI variables" do
is_expected.to contain_exactly(ci_variable)
end
end
- context 'when the ref is a protected branch' do
+ context "when the ref is a protected branch" do
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(true)
+ allow(project).to receive(:protected_for?).with("ref").and_return(true)
end
- it_behaves_like 'ref is protected'
+ it_behaves_like "ref is protected"
end
- context 'when the ref is a protected tag' do
+ context "when the ref is a protected tag" do
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(true)
+ allow(project).to receive(:protected_for?).with("ref").and_return(true)
end
- it_behaves_like 'ref is protected'
+ it_behaves_like "ref is protected"
end
- context 'when group has children', :postgresql do
+ context "when group has children", :postgresql do
let(:group_child) { create(:group, parent: group) }
let(:group_child_2) { create(:group, parent: group_child) }
let(:group_child_3) { create(:group, parent: group_child_2) }
@@ -708,13 +709,13 @@ describe Group do
let(:variable_child_3) { create(:ci_group_variable, group: group_child_3) }
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(true)
+ allow(project).to receive(:protected_for?).with("ref").and_return(true)
end
- it 'returns all variables belong to the group and parent groups' do
+ it "returns all variables belong to the group and parent groups" do
expected_array1 = [protected_variable, ci_variable]
expected_array2 = [variable_child, variable_child_2, variable_child_3]
- got_array = group_child_3.ci_variables_for('ref', project).to_a
+ got_array = group_child_3.ci_variables_for("ref", project).to_a
expect(got_array.shift(2)).to contain_exactly(*expected_array1)
expect(got_array).to eq(expected_array2)
@@ -722,67 +723,67 @@ describe Group do
end
end
- describe '#highest_group_member', :nested_groups do
+ describe "#highest_group_member", :nested_groups do
let(:nested_group) { create(:group, parent: group) }
let(:nested_group_2) { create(:group, parent: nested_group) }
let(:user) { create(:user) }
subject(:highest_group_member) { nested_group_2.highest_group_member(user) }
- context 'when the user is not a member of any group in the hierarchy' do
- it 'returns nil' do
+ context "when the user is not a member of any group in the hierarchy" do
+ it "returns nil" do
expect(highest_group_member).to be_nil
end
end
- context 'when the user is only a member of one group in the hierarchy' do
+ context "when the user is only a member of one group in the hierarchy" do
before do
nested_group.add_developer(user)
end
- it 'returns that group member' do
+ it "returns that group member" do
expect(highest_group_member.access_level).to eq(Gitlab::Access::DEVELOPER)
end
end
- context 'when the user is a member of several groups in the hierarchy' do
+ context "when the user is a member of several groups in the hierarchy" do
before do
group.add_owner(user)
nested_group.add_developer(user)
nested_group_2.add_maintainer(user)
end
- it 'returns the group member with the highest access level' do
+ it "returns the group member with the highest access level" do
expect(highest_group_member.access_level).to eq(Gitlab::Access::OWNER)
end
end
end
- describe '#has_parent?' do
- context 'when the group has a parent' do
- it 'should be truthy' do
+ describe "#has_parent?" do
+ context "when the group has a parent" do
+ it "should be truthy" do
group = create(:group, :nested)
expect(group.has_parent?).to be_truthy
end
end
- context 'when the group has no parent' do
- it 'should be falsy' do
+ context "when the group has no parent" do
+ it "should be falsy" do
group = create(:group, parent: nil)
expect(group.has_parent?).to be_falsy
end
end
end
- context 'with uploads' do
- it_behaves_like 'model with uploads', true do
+ context "with uploads" do
+ it_behaves_like "model with uploads", true do
let(:model_object) { create(:group, :with_avatar) }
let(:upload_attribute) { :avatar }
let(:uploader_class) { AttachmentUploader }
end
end
- describe '#group_clusters_enabled?' do
+ describe "#group_clusters_enabled?" do
before do
# Override global stub in spec/spec_helper.rb
expect(Feature).to receive(:enabled?).and_call_original
@@ -792,7 +793,7 @@ describe Group do
it { is_expected.to be_truthy }
- context 'explicitly disabled for root ancestor' do
+ context "explicitly disabled for root ancestor" do
before do
feature = Feature.get(:group_clusters)
feature.disable(group.root_ancestor)
@@ -801,7 +802,7 @@ describe Group do
it { is_expected.to be_falsey }
end
- context 'explicitly disabled for root ancestor' do
+ context "explicitly disabled for root ancestor" do
before do
feature = Feature.get(:group_clusters)
feature.enable(group.root_ancestor)
diff --git a/spec/models/guest_spec.rb b/spec/models/guest_spec.rb
index fc30f3056e5..154ddec52fc 100644
--- a/spec/models/guest_spec.rb
+++ b/spec/models/guest_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe Guest do
set(:public_project) { create(:project, :public) }
set(:private_project) { create(:project, :private) }
set(:internal_project) { create(:project, :internal) }
- describe '.can_pull?' do
- context 'when project is private' do
- it 'does not allow to pull the repo' do
+ describe ".can_pull?" do
+ context "when project is private" do
+ it "does not allow to pull the repo" do
expect(described_class.can?(:download_code, private_project)).to eq(false)
end
end
- context 'when project is internal' do
- it 'does not allow to pull the repo' do
+ context "when project is internal" do
+ it "does not allow to pull the repo" do
expect(described_class.can?(:download_code, internal_project)).to eq(false)
end
end
- context 'when project is public' do
- context 'when repository is disabled' do
- it 'does not allow to pull the repo' do
+ context "when project is public" do
+ context "when repository is disabled" do
+ it "does not allow to pull the repo" do
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::DISABLED)
expect(described_class.can?(:download_code, public_project)).to eq(false)
end
end
- context 'when repository is accessible only by team members' do
- it 'does not allow to pull the repo' do
+ context "when repository is accessible only by team members" do
+ it "does not allow to pull the repo" do
public_project.project_feature.update_attribute(:repository_access_level, ProjectFeature::PRIVATE)
expect(described_class.can?(:download_code, public_project)).to eq(false)
end
end
- context 'when repository is enabled' do
- it 'allows to pull the repo' do
+ context "when repository is enabled" do
+ it "allows to pull the repo" do
expect(described_class.can?(:download_code, public_project)).to eq(true)
end
end
diff --git a/spec/models/hooks/active_hook_filter_spec.rb b/spec/models/hooks/active_hook_filter_spec.rb
index df7edda2213..4f36e1b5293 100644
--- a/spec/models/hooks/active_hook_filter_spec.rb
+++ b/spec/models/hooks/active_hook_filter_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe ActiveHookFilter do
subject(:filter) { described_class.new(hook) }
- describe '#matches?' do
- context 'for push event hooks' do
+ describe "#matches?" do
+ context "for push event hooks" do
let(:hook) do
create(:project_hook, push_events: true, push_events_branch_filter: branch_filter)
end
- context 'branch filter is specified' do
- let(:branch_filter) { 'master' }
+ context "branch filter is specified" do
+ let(:branch_filter) { "master" }
- it 'returns true if branch matches' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/master' })).to be true
+ it "returns true if branch matches" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/master"})).to be true
end
- it 'returns false if branch does not match' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/my_branch' })).to be false
+ it "returns false if branch does not match" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/my_branch"})).to be false
end
- it 'returns false if ref is nil' do
+ it "returns false if ref is nil" do
expect(filter.matches?(:push_hooks, {})).to be false
end
- context 'branch filter contains wildcard' do
- let(:branch_filter) { 'features/*' }
+ context "branch filter contains wildcard" do
+ let(:branch_filter) { "features/*" }
- it 'returns true if branch matches' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/features/my-branch' })).to be true
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/features/my-branch/something' })).to be true
+ it "returns true if branch matches" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/features/my-branch"})).to be true
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/features/my-branch/something"})).to be true
end
- it 'returns false if branch does not match' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/master' })).to be false
+ it "returns false if branch does not match" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/master"})).to be false
end
end
end
- context 'branch filter is not specified' do
+ context "branch filter is not specified" do
let(:branch_filter) { nil }
- it 'returns true' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/master' })).to be true
+ it "returns true" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/master"})).to be true
end
end
- context 'branch filter is empty string' do
- let(:branch_filter) { '' }
+ context "branch filter is empty string" do
+ let(:branch_filter) { "" }
- it 'acts like branch is not specified' do
- expect(filter.matches?(:push_hooks, { ref: 'refs/heads/master' })).to be true
+ it "acts like branch is not specified" do
+ expect(filter.matches?(:push_hooks, {ref: "refs/heads/master"})).to be true
end
end
end
- context 'for non-push-events hooks' do
+ context "for non-push-events hooks" do
let(:hook) do
- create(:project_hook, issues_events: true, push_events: false, push_events_branch_filter: '')
+ create(:project_hook, issues_events: true, push_events: false, push_events_branch_filter: "")
end
- it 'returns true as branch filters are not yet supported for these' do
- expect(filter.matches?(:issues_events, { ref: 'refs/heads/master' })).to be true
+ it "returns true as branch filters are not yet supported for these" do
+ expect(filter.matches?(:issues_events, {ref: "refs/heads/master"})).to be true
end
end
end
diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb
index 5dd31b1b5de..902120967cc 100644
--- a/spec/models/hooks/project_hook_spec.rb
+++ b/spec/models/hooks/project_hook_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectHook do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to :project }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
end
- describe '.push_hooks' do
- it 'returns hooks for push events only' do
+ describe ".push_hooks" do
+ it "returns hooks for push events only" do
hook = create(:project_hook, push_events: true)
create(:project_hook, push_events: false)
expect(described_class.push_hooks).to eq([hook])
end
end
- describe '.tag_push_hooks' do
- it 'returns hooks for tag push events only' do
+ describe ".tag_push_hooks" 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(described_class.tag_push_hooks).to eq([hook])
diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb
index e32eaafc13f..1beace50631 100644
--- a/spec/models/hooks/service_hook_spec.rb
+++ b/spec/models/hooks/service_hook_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe ServiceHook do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to :service }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:service) }
end
- describe 'execute' do
+ describe "execute" do
let(:hook) { build(:service_hook) }
- let(:data) { { key: 'value' } }
+ let(:data) { {key: "value"} }
- it '#execute' do
- expect(WebHookService).to receive(:new).with(hook, data, 'service_hook').and_call_original
+ it "#execute" do
+ expect(WebHookService).to receive(:new).with(hook, data, "service_hook").and_call_original
expect_any_instance_of(WebHookService).to receive(:execute)
hook.execute(data)
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
index edd1cb455af..9b030282436 100644
--- a/spec/models/hooks/system_hook_spec.rb
+++ b/spec/models/hooks/system_hook_spec.rb
@@ -1,14 +1,14 @@
require "spec_helper"
describe SystemHook do
- context 'default attributes' do
+ context "default attributes" do
let(:system_hook) { build(:system_hook) }
- it 'sets defined default parameters' do
+ it "sets defined default parameters" do
attrs = {
push_events: false,
repository_update_events: true,
- merge_requests_events: false
+ merge_requests_events: false,
}
expect(system_hook).to have_attributes(attrs)
end
@@ -20,7 +20,7 @@ describe SystemHook do
let(:project) { create(:project, namespace: user.namespace) }
let(:group) { create(:group) }
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jg@example.com', password: 'mydummypass' }
+ {name: "John Doe", username: "jduser", email: "jg@example.com", password: "mydummypass"}
end
before do
@@ -28,10 +28,10 @@ describe SystemHook do
end
it "project_create hook" do
- Projects::CreateService.new(user, name: 'empty').execute
+ Projects::CreateService.new(user, name: "empty").execute
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /project_create/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
@@ -40,7 +40,7 @@ describe SystemHook do
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /project_destroy/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
@@ -49,7 +49,7 @@ describe SystemHook do
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_create/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
@@ -58,7 +58,7 @@ describe SystemHook do
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_destroy/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
@@ -67,7 +67,7 @@ describe SystemHook do
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_add_to_team/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
@@ -77,72 +77,72 @@ describe SystemHook do
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_remove_from_team/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
- it 'group create hook' do
+ it "group create hook" do
create(:group)
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /group_create/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
- it 'group destroy hook' do
+ it "group destroy hook" do
group.destroy
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /group_destroy/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
- it 'group member create hook' do
+ it "group member create hook" do
group.add_maintainer(user)
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_add_to_group/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
- it 'group member destroy hook' do
+ it "group member destroy hook" do
group.add_maintainer(user)
group.group_members.destroy_all # rubocop: disable DestroyAll
expect(WebMock).to have_requested(:post, system_hook.url).with(
body: /user_remove_from_group/,
- headers: { 'Content-Type' => 'application/json', 'X-Gitlab-Event' => 'System Hook' }
+ headers: {"Content-Type" => "application/json", "X-Gitlab-Event" => "System Hook"}
).once
end
end
- describe '.repository_update_hooks' do
- it 'returns hooks for repository update events only' do
+ describe ".repository_update_hooks" do
+ it "returns hooks for repository update events only" do
hook = create(:system_hook, repository_update_events: true)
create(:system_hook, repository_update_events: false)
expect(described_class.repository_update_hooks).to eq([hook])
end
end
- describe 'execute WebHookService' do
+ describe "execute WebHookService" do
let(:hook) { build(:system_hook) }
- let(:data) { { key: 'value' } }
- let(:hook_name) { 'system_hook' }
+ let(:data) { {key: "value"} }
+ let(:hook_name) { "system_hook" }
before do
expect(WebHookService).to receive(:new).with(hook, data, hook_name).and_call_original
end
- it '#execute' do
+ it "#execute" do
expect_any_instance_of(WebHookService).to receive(:execute)
hook.execute(data, hook_name)
end
- it '#async_execute' do
+ it "#async_execute" do
expect_any_instance_of(WebHookService).to receive(:async_execute)
hook.async_execute(data, hook_name)
diff --git a/spec/models/hooks/web_hook_log_spec.rb b/spec/models/hooks/web_hook_log_spec.rb
index 744a6ccae8b..13ba8c042a1 100644
--- a/spec/models/hooks/web_hook_log_spec.rb
+++ b/spec/models/hooks/web_hook_log_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe WebHookLog do
it { is_expected.to belong_to(:web_hook) }
@@ -9,16 +9,16 @@ describe WebHookLog do
it { is_expected.to validate_presence_of(:web_hook) }
- describe '.recent' do
+ describe ".recent" do
let(:hook) { create(:project_hook) }
- it 'does not return web hook logs that are too old' do
+ it "does not return web hook logs that are too old" do
create(:web_hook_log, web_hook: hook, created_at: 91.days.ago)
expect(described_class.recent.size).to be_zero
end
- it 'returns the web hook logs in descending order' do
+ it "returns the web hook logs in descending order" do
hook1 = create(:web_hook_log, web_hook: hook, created_at: 2.hours.ago)
hook2 = create(:web_hook_log, web_hook: hook, created_at: 1.hour.ago)
hooks = described_class.recent.to_a
@@ -27,21 +27,21 @@ describe WebHookLog do
end
end
- describe '#success?' do
+ describe "#success?" do
let(:web_hook_log) { build(:web_hook_log, response_status: status) }
- describe '2xx' do
- let(:status) { '200' }
+ describe "2xx" do
+ let(:status) { "200" }
it { expect(web_hook_log.success?).to be_truthy }
end
- describe 'not 2xx' do
- let(:status) { '500' }
+ describe "not 2xx" do
+ let(:status) { "500" }
it { expect(web_hook_log.success?).to be_falsey }
end
- describe 'internal erorr' do
- let(:status) { 'internal error' }
+ describe "internal erorr" do
+ let(:status) { "internal error" }
it { expect(web_hook_log.success?).to be_falsey }
end
end
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index a308ac6e33a..0d6e7939add 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -1,83 +1,83 @@
-require 'spec_helper'
+require "spec_helper"
describe WebHook do
let(:hook) { build(:project_hook) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to have_many(:web_hook_logs).dependent(:destroy) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:url) }
- describe 'url' do
- it { is_expected.to allow_value('http://example.com').for(:url) }
- it { is_expected.to allow_value('https://example.com').for(:url) }
- it { is_expected.to allow_value(' https://example.com ').for(:url) }
- it { is_expected.to allow_value('http://test.com/api').for(:url) }
- it { is_expected.to allow_value('http://test.com/api?key=abc').for(:url) }
- it { is_expected.to allow_value('http://test.com/api?key=abc&type=def').for(:url) }
+ describe "url" do
+ it { is_expected.to allow_value("http://example.com").for(:url) }
+ it { is_expected.to allow_value("https://example.com").for(:url) }
+ it { is_expected.to allow_value(" https://example.com ").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
+ it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
- it { is_expected.not_to allow_value('example.com').for(:url) }
- it { is_expected.not_to allow_value('ftp://example.com').for(:url) }
- it { is_expected.not_to allow_value('herp-and-derp').for(:url) }
+ it { is_expected.not_to allow_value("example.com").for(:url) }
+ it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
+ it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
- it 'strips :url before saving it' do
- hook.url = ' https://example.com '
+ it "strips :url before saving it" do
+ hook.url = " https://example.com "
hook.save
- expect(hook.url).to eq('https://example.com')
+ expect(hook.url).to eq("https://example.com")
end
end
- describe 'token' do
+ describe "token" do
it { is_expected.to allow_value("foobar").for(:token) }
it { is_expected.not_to allow_values("foo\nbar", "foo\r\nbar").for(:token) }
end
- describe 'push_events_branch_filter' do
+ describe "push_events_branch_filter" do
it { is_expected.to allow_values("good_branch_name", "another/good-branch_name").for(:push_events_branch_filter) }
it { is_expected.to allow_values("").for(:push_events_branch_filter) }
it { is_expected.not_to allow_values("bad branch name", "bad~branchname").for(:push_events_branch_filter) }
- it 'gets rid of whitespace' do
- hook.push_events_branch_filter = ' branch '
+ it "gets rid of whitespace" do
+ hook.push_events_branch_filter = " branch "
hook.save
- expect(hook.push_events_branch_filter).to eq('branch')
+ expect(hook.push_events_branch_filter).to eq("branch")
end
- it 'stores whitespace only as empty' do
- hook.push_events_branch_filter = ' '
+ it "stores whitespace only as empty" do
+ hook.push_events_branch_filter = " "
hook.save
- expect(hook.push_events_branch_filter).to eq('')
+ expect(hook.push_events_branch_filter).to eq("")
end
end
end
- describe 'encrypted attributes' do
+ describe "encrypted attributes" do
subject { described_class.encrypted_attributes.keys }
it { is_expected.to contain_exactly(:token, :url) }
end
- describe 'execute' do
- let(:data) { { key: 'value' } }
- let(:hook_name) { 'project hook' }
+ describe "execute" do
+ let(:data) { {key: "value"} }
+ let(:hook_name) { "project hook" }
before do
expect(WebHookService).to receive(:new).with(hook, data, hook_name).and_call_original
end
- it '#execute' do
+ it "#execute" do
expect_any_instance_of(WebHookService).to receive(:execute)
hook.execute(data, hook_name)
end
- it '#async_execute' do
+ it "#async_execute" do
expect_any_instance_of(WebHookService).to receive(:async_execute)
hook.async_execute(data, hook_name)
diff --git a/spec/models/identity_spec.rb b/spec/models/identity_spec.rb
index e1a7a59dfd1..bb257acf498 100644
--- a/spec/models/identity_spec.rb
+++ b/spec/models/identity_spec.rb
@@ -1,95 +1,95 @@
-require 'spec_helper'
+require "spec_helper"
describe Identity do
- describe 'relations' do
+ describe "relations" do
it { is_expected.to belong_to(:user) }
end
- describe 'fields' do
+ describe "fields" do
it { is_expected.to respond_to(:provider) }
it { is_expected.to respond_to(:extern_uid) }
end
- describe 'validations' do
+ describe "validations" do
set(:user) { create(:user) }
- context 'with existing user and provider' do
+ context "with existing user and provider" do
before do
- create(:identity, provider: 'ldapmain', user_id: user.id)
+ create(:identity, provider: "ldapmain", user_id: user.id)
end
- it 'returns false for a duplicate entry' do
- identity = user.identities.build(provider: 'ldapmain', user_id: user.id)
+ it "returns false for a duplicate entry" do
+ identity = user.identities.build(provider: "ldapmain", user_id: user.id)
expect(identity.validate).to be_falsey
end
- it 'returns true when a different provider is used' do
- identity = user.identities.build(provider: 'gitlab', user_id: user.id)
+ it "returns true when a different provider is used" do
+ identity = user.identities.build(provider: "gitlab", user_id: user.id)
expect(identity.validate).to be_truthy
end
end
- context 'with newly-created user' do
+ context "with newly-created user" do
before do
- create(:identity, provider: 'ldapmain', user_id: nil)
+ create(:identity, provider: "ldapmain", user_id: nil)
end
- it 'successfully validates even with a nil user_id' do
- identity = user.identities.build(provider: 'ldapmain')
+ it "successfully validates even with a nil user_id" do
+ identity = user.identities.build(provider: "ldapmain")
expect(identity.validate).to be_truthy
end
end
end
- describe '#is_ldap?' do
- let(:ldap_identity) { create(:identity, provider: 'ldapmain') }
- let(:other_identity) { create(:identity, provider: 'twitter') }
+ describe "#is_ldap?" do
+ let(:ldap_identity) { create(:identity, provider: "ldapmain") }
+ let(:other_identity) { create(:identity, provider: "twitter") }
- it 'returns true if it is a ldap identity' do
+ it "returns true if it is a ldap identity" do
expect(ldap_identity.ldap?).to be_truthy
end
- it 'returns false if it is not a ldap identity' do
+ it "returns false if it is not a ldap identity" do
expect(other_identity.ldap?).to be_falsey
end
end
- describe '.with_extern_uid' do
- context 'LDAP identity' do
- let!(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com') }
+ describe ".with_extern_uid" do
+ context "LDAP identity" do
+ let!(:ldap_identity) { create(:identity, provider: "ldapmain", extern_uid: "uid=john smith,ou=people,dc=example,dc=com") }
- it 'finds the identity when the DN is formatted differently' do
- identity = described_class.with_extern_uid('ldapmain', 'uid=John Smith, ou=People, dc=example, dc=com').first
+ it "finds the identity when the DN is formatted differently" do
+ identity = described_class.with_extern_uid("ldapmain", "uid=John Smith, ou=People, dc=example, dc=com").first
expect(identity).to eq(ldap_identity)
end
end
- context 'any other provider' do
- let!(:test_entity) { create(:identity, provider: 'test_provider', extern_uid: 'test_uid') }
+ context "any other provider" do
+ let!(:test_entity) { create(:identity, provider: "test_provider", extern_uid: "test_uid") }
- it 'the extern_uid lookup is case insensitive' do
- identity = described_class.with_extern_uid('test_provider', 'TEST_UID').first
+ it "the extern_uid lookup is case insensitive" do
+ identity = described_class.with_extern_uid("test_provider", "TEST_UID").first
expect(identity).to eq(test_entity)
end
end
end
- context 'callbacks' do
- context 'before_save' do
- describe 'normalizes extern uid' do
- let!(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com') }
+ context "callbacks" do
+ context "before_save" do
+ describe "normalizes extern uid" do
+ let!(:ldap_identity) { create(:identity, provider: "ldapmain", extern_uid: "uid=john smith,ou=people,dc=example,dc=com") }
- it 'if extern_uid changes' do
+ it "if extern_uid changes" do
expect(ldap_identity).not_to receive(:ensure_normalized_extern_uid)
ldap_identity.save
end
- it 'if current_uid is nil' do
+ it "if current_uid is nil" do
expect(ldap_identity).to receive(:ensure_normalized_extern_uid)
ldap_identity.update(extern_uid: nil)
@@ -97,26 +97,26 @@ describe Identity do
expect(ldap_identity.extern_uid).to be_nil
end
- it 'if extern_uid changed and not nil' do
- ldap_identity.update(extern_uid: 'uid=john1,ou=PEOPLE,dc=example,dc=com')
+ it "if extern_uid changed and not nil" do
+ ldap_identity.update(extern_uid: "uid=john1,ou=PEOPLE,dc=example,dc=com")
- expect(ldap_identity.extern_uid).to eq 'uid=john1,ou=people,dc=example,dc=com'
+ expect(ldap_identity.extern_uid).to eq "uid=john1,ou=people,dc=example,dc=com"
end
end
end
- context 'after_destroy' do
+ context "after_destroy" do
let!(:user) { create(:user) }
- let(:ldap_identity) { create(:identity, provider: 'ldapmain', extern_uid: 'uid=john smith,ou=people,dc=example,dc=com', user: user) }
- let(:ldap_user_synced_attributes) { { provider: 'ldapmain', name_synced: true, email_synced: true } }
- let(:other_provider_user_synced_attributes) { { provider: 'other', name_synced: true, email_synced: true } }
+ let(:ldap_identity) { create(:identity, provider: "ldapmain", extern_uid: "uid=john smith,ou=people,dc=example,dc=com", user: user) }
+ let(:ldap_user_synced_attributes) { {provider: "ldapmain", name_synced: true, email_synced: true} }
+ let(:other_provider_user_synced_attributes) { {provider: "other", name_synced: true, email_synced: true} }
- describe 'if user synced attributes metadada provider' do
- context 'matches the identity provider ' do
- it 'removes the user synced attributes' do
+ describe "if user synced attributes metadada provider" do
+ context "matches the identity provider " do
+ it "removes the user synced attributes" do
user.create_user_synced_attributes_metadata(ldap_user_synced_attributes)
- expect(user.user_synced_attributes_metadata.provider).to eq 'ldapmain'
+ expect(user.user_synced_attributes_metadata.provider).to eq "ldapmain"
ldap_identity.destroy
@@ -124,15 +124,15 @@ describe Identity do
end
end
- context 'does not matche the identity provider' do
- it 'does not remove the user synced attributes' do
+ context "does not matche the identity provider" do
+ it "does not remove the user synced attributes" do
user.create_user_synced_attributes_metadata(other_provider_user_synced_attributes)
- expect(user.user_synced_attributes_metadata.provider).to eq 'other'
+ expect(user.user_synced_attributes_metadata.provider).to eq "other"
ldap_identity.destroy
- expect(user.reload.user_synced_attributes_metadata.provider).to eq 'other'
+ expect(user.reload.user_synced_attributes_metadata.provider).to eq "other"
end
end
end
diff --git a/spec/models/import_export_upload_spec.rb b/spec/models/import_export_upload_spec.rb
index 58af84b8a08..a8715ecce7c 100644
--- a/spec/models/import_export_upload_spec.rb
+++ b/spec/models/import_export_upload_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe ImportExportUpload do
subject { described_class.new(project: create(:project)) }
- shared_examples 'stores the Import/Export file' do |method|
- it 'stores the import file' do
- subject.public_send("#{method}=", fixture_file_upload('spec/fixtures/project_export.tar.gz'))
+ shared_examples "stores the Import/Export file" do |method|
+ it "stores the import file" do
+ subject.public_send("#{method}=", fixture_file_upload("spec/fixtures/project_export.tar.gz"))
subject.save!
@@ -15,11 +15,11 @@ describe ImportExportUpload do
end
end
- context 'import' do
- it_behaves_like 'stores the Import/Export file', :import_file
+ context "import" do
+ it_behaves_like "stores the Import/Export file", :import_file
end
- context 'export' do
- it_behaves_like 'stores the Import/Export file', :export_file
+ context "export" do
+ it_behaves_like "stores the Import/Export file", :export_file
end
end
diff --git a/spec/models/instance_configuration_spec.rb b/spec/models/instance_configuration_spec.rb
index cb3d6c7cda2..e7e81430c8c 100644
--- a/spec/models/instance_configuration_spec.rb
+++ b/spec/models/instance_configuration_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe InstanceConfiguration do
- context 'without cache' do
- describe '#settings' do
- describe '#ssh_algorithms_hashes' do
- let(:md5) { '5a:65:6c:4d:d4:4c:6d:e6:59:25:b8:cf:ba:34:e7:64' }
- let(:sha256) { 'SHA256:2KJDT7xf2i68mBgJ3TVsjISntg4droLbXYLfQj0VvSY' }
+ context "without cache" do
+ describe "#settings" do
+ describe "#ssh_algorithms_hashes" do
+ let(:md5) { "5a:65:6c:4d:d4:4c:6d:e6:59:25:b8:cf:ba:34:e7:64" }
+ let(:sha256) { "SHA256:2KJDT7xf2i68mBgJ3TVsjISntg4droLbXYLfQj0VvSY" }
- it 'does not return anything if file does not exist' do
+ it "does not return anything if file does not exist" do
stub_pub_file(exist: false)
expect(subject.settings[:ssh_algorithms_hashes]).to be_empty
end
- it 'does not return anything if file is empty' do
+ it "does not return anything if file is empty" do
stub_pub_file
- allow(File).to receive(:read).and_return('')
+ allow(File).to receive(:read).and_return("")
expect(subject.settings[:ssh_algorithms_hashes]).to be_empty
end
- it 'returns the md5 and sha256 if file valid and exists' do
+ it "returns the md5 and sha256 if file valid and exists" do
stub_pub_file
result = subject.settings[:ssh_algorithms_hashes].select { |o| o[:md5] == md5 && o[:sha256] == sha256 }
@@ -30,62 +30,62 @@ describe InstanceConfiguration do
end
def stub_pub_file(exist: true)
- path = 'spec/fixtures/ssh_host_example_key.pub'
- path << 'random' unless exist
+ path = "spec/fixtures/ssh_host_example_key.pub"
+ path << "random" unless exist
allow(subject).to receive(:ssh_algorithm_file).and_return(Rails.root.join(path))
end
end
- describe '#host' do
- it 'returns current instance host' do
- allow(Settings.gitlab).to receive(:host).and_return('exampledomain')
+ describe "#host" do
+ it "returns current instance host" do
+ allow(Settings.gitlab).to receive(:host).and_return("exampledomain")
expect(subject.settings[:host]).to eq(Settings.gitlab.host)
end
end
- describe '#gitlab_pages' do
+ describe "#gitlab_pages" do
let(:gitlab_pages) { subject.settings[:gitlab_pages] }
- it 'returns Settings.pages' do
+ it "returns Settings.pages" do
gitlab_pages.delete(:ip_address)
expect(gitlab_pages).to eq(Settings.pages.symbolize_keys)
end
- it 'returns the GitLab\'s pages host ip address' do
+ it "returns the GitLab's pages host ip address" do
expect(gitlab_pages.keys).to include(:ip_address)
end
- it 'returns the ip address as nil if the domain is invalid' do
- allow(Settings.pages).to receive(:host).and_return('exampledomain')
+ it "returns the ip address as nil if the domain is invalid" do
+ allow(Settings.pages).to receive(:host).and_return("exampledomain")
expect(gitlab_pages[:ip_address]).to eq nil
end
- it 'returns the ip address of the domain' do
- allow(Settings.pages).to receive(:host).and_return('localhost')
+ it "returns the ip address of the domain" do
+ allow(Settings.pages).to receive(:host).and_return("localhost")
- expect(gitlab_pages[:ip_address]).to eq('127.0.0.1').or eq('::1')
+ expect(gitlab_pages[:ip_address]).to eq("127.0.0.1").or eq("::1")
end
end
- describe '#gitlab_ci' do
+ describe "#gitlab_ci" do
let(:gitlab_ci) { subject.settings[:gitlab_ci] }
- it 'returns Settings.gitalb_ci' do
+ it "returns Settings.gitalb_ci" do
gitlab_ci.delete(:artifacts_max_size)
expect(gitlab_ci).to eq(Settings.gitlab_ci.symbolize_keys)
end
- it 'returns the key artifacts_max_size' do
+ it "returns the key artifacts_max_size" do
expect(gitlab_ci.keys).to include(:artifacts_max_size)
end
end
end
end
- context 'with cache', :use_clean_rails_memory_store_caching do
- it 'caches settings content' do
+ context "with cache", :use_clean_rails_memory_store_caching do
+ it "caches settings content" do
expect(Rails.cache.read(described_class::CACHE_KEY)).to be_nil
settings = subject.settings
@@ -93,12 +93,12 @@ describe InstanceConfiguration do
expect(Rails.cache.read(described_class::CACHE_KEY)).to eq(settings)
end
- describe 'cached settings' do
+ describe "cached settings" do
before do
subject.settings
end
- it 'expires after EXPIRATION_TIME' do
+ it "expires after EXPIRATION_TIME" do
allow(Time).to receive(:now).and_return(Time.now + described_class::EXPIRATION_TIME)
Rails.cache.cleanup
diff --git a/spec/models/internal_id_spec.rb b/spec/models/internal_id_spec.rb
index d32f163f05b..c341b53cd57 100644
--- a/spec/models/internal_id_spec.rb
+++ b/spec/models/internal_id_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe InternalId do
let(:project) { create(:project) }
let(:usage) { :issues }
let(:issue) { build(:issue, project: project) }
- let(:scope) { { project: project } }
+ let(:scope) { {project: project} }
let(:init) { ->(s) { s.project.issues.size } }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- context 'validations' do
+ context "validations" do
it { is_expected.to validate_presence_of(:usage) }
end
- describe '.flush_records!' do
+ describe ".flush_records!" do
subject { described_class.flush_records!(project: project) }
let(:another_project) { create(:project) }
@@ -23,28 +23,28 @@ describe InternalId do
create_list(:issue, 2, project: another_project)
end
- it 'deletes all records for the given project' do
+ it "deletes all records for the given project" do
expect { subject }.to change { described_class.where(project: project).count }.from(1).to(0)
end
- it 'retains records for other projects' do
+ it "retains records for other projects" do
expect { subject }.not_to change { described_class.where(project: another_project).count }
end
- it 'does not allow an empty filter' do
+ it "does not allow an empty filter" do
expect { described_class.flush_records!({}) }.to raise_error(/filter cannot be empty/)
end
end
- describe '.generate_next' do
+ describe ".generate_next" do
subject { described_class.generate_next(issue, scope, usage, init) }
- context 'in the absence of a record' do
- it 'creates a record if not yet present' do
+ context "in the absence of a record" do
+ it "creates a record if not yet present" do
expect { subject }.to change { described_class.count }.from(0).to(1)
end
- it 'stores record attributes' do
+ it "stores record attributes" do
subject
described_class.first.tap do |record|
@@ -53,24 +53,24 @@ describe InternalId do
end
end
- context 'with existing issues' do
+ context "with existing issues" do
before do
create_list(:issue, 2, project: project)
described_class.delete_all
end
- it 'calculates last_value values automatically' do
+ it "calculates last_value values automatically" do
expect(subject).to eq(project.issues.size + 1)
end
end
- context 'with concurrent inserts on table' do
- it 'looks up the record if it was created concurrently' do
- args = { **scope, usage: described_class.usages[usage.to_s] }
+ context "with concurrent inserts on table" do
+ it "looks up the record if it was created concurrently" do
+ args = {**scope, usage: described_class.usages[usage.to_s]}
record = double
expect(described_class).to receive(:find_by).with(args).and_return(nil) # first call, record not present
expect(described_class).to receive(:find_by).with(args).and_return(record) # second call, record was created by another process
- expect(described_class).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique, 'record not unique')
+ expect(described_class).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique, "record not unique")
expect(record).to receive(:increment_and_save!)
subject
@@ -78,25 +78,25 @@ describe InternalId do
end
end
- it 'generates a strictly monotone, gapless sequence' do
- seq = Array.new(10).map do
+ it "generates a strictly monotone, gapless sequence" do
+ seq = Array.new(10).map {
described_class.generate_next(issue, scope, usage, init)
- end
+ }
normalized = seq.map { |i| i - seq.min }
expect(normalized).to eq((0..seq.size - 1).to_a)
end
- context 'with an insufficient schema version' do
+ context "with an insufficient schema version" do
before do
described_class.reset_column_information
# Project factory will also call the current_version
expect(ActiveRecord::Migrator).to receive(:current_version).twice.and_return(InternalId::REQUIRED_SCHEMA_VERSION - 1)
end
- let(:init) { double('block') }
+ let(:init) { double("block") }
- it 'calculates next internal ids on the fly' do
+ it "calculates next internal ids on the fly" do
val = rand(1..100)
expect(init).to receive(:call).with(issue).and_return(val)
@@ -105,17 +105,17 @@ describe InternalId do
end
end
- describe '.track_greatest' do
+ describe ".track_greatest" do
let(:value) { 9001 }
subject { described_class.track_greatest(issue, scope, usage, value, init) }
- context 'in the absence of a record' do
- it 'creates a record if not yet present' do
+ context "in the absence of a record" do
+ it "creates a record if not yet present" do
expect { subject }.to change { described_class.count }.from(0).to(1)
end
end
- it 'stores record attributes' do
+ it "stores record attributes" do
subject
described_class.first.tap do |record|
@@ -125,19 +125,19 @@ describe InternalId do
end
end
- context 'with existing issues' do
+ context "with existing issues" do
before do
create(:issue, project: project)
described_class.delete_all
end
- it 'still returns the last value to that of the given value' do
+ it "still returns the last value to that of the given value" do
expect(subject).to eq(value)
end
end
- context 'when value is less than the current last_value' do
- it 'returns the current last_value' do
+ context "when value is less than the current last_value" do
+ it "returns the current last_value" do
described_class.create!(**scope, usage: usage, last_value: 10_001)
expect(subject).to eq 10_001
@@ -145,48 +145,48 @@ describe InternalId do
end
end
- describe '#increment_and_save!' do
+ describe "#increment_and_save!" do
let(:id) { create(:internal_id) }
subject { id.increment_and_save! }
- it 'returns incremented iid' do
+ it "returns incremented iid" do
value = id.last_value
expect(subject).to eq(value + 1)
end
- it 'saves the record' do
+ it "saves the record" do
subject
expect(id.changed?).to be_falsey
end
- context 'with last_value=nil' do
+ context "with last_value=nil" do
let(:id) { build(:internal_id, last_value: nil) }
- it 'returns 1' do
+ it "returns 1" do
expect(subject).to eq(1)
end
end
end
- describe '#track_greatest_and_save!' do
+ describe "#track_greatest_and_save!" do
let(:id) { create(:internal_id) }
let(:new_last_value) { 9001 }
subject { id.track_greatest_and_save!(new_last_value) }
- it 'returns new last value' do
+ it "returns new last value" do
expect(subject).to eq new_last_value
end
- it 'saves the record' do
+ it "saves the record" do
subject
expect(id.changed?).to be_falsey
end
- context 'when new last value is lower than the max' do
- it 'does not update the last value' do
+ context "when new last value is lower than the max" do
+ it "does not update the last value" do
id.update!(last_value: 10_001)
subject
diff --git a/spec/models/issue/metrics_spec.rb b/spec/models/issue/metrics_spec.rb
index 1bf0ecb98ad..211cb6c5093 100644
--- a/spec/models/issue/metrics_spec.rb
+++ b/spec/models/issue/metrics_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issue::Metrics do
let(:project) { create(:project) }
diff --git a/spec/models/issue_collection_spec.rb b/spec/models/issue_collection_spec.rb
index 580a98193af..979f549eee5 100644
--- a/spec/models/issue_collection_spec.rb
+++ b/spec/models/issue_collection_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IssueCollection do
let(:user) { create(:user) }
@@ -7,57 +7,57 @@ describe IssueCollection do
let(:issue2) { create(:issue, project: project) }
let(:collection) { described_class.new([issue1, issue2]) }
- describe '#collection' do
- it 'returns the issues in the same order as the input Array' do
+ describe "#collection" do
+ it "returns the issues in the same order as the input Array" do
expect(collection.collection).to eq([issue1, issue2])
end
end
- describe '#updatable_by_user' do
- context 'using an admin user' do
- it 'returns all issues' do
+ describe "#updatable_by_user" do
+ context "using an admin user" do
+ it "returns all issues" do
user = create(:admin)
expect(collection.updatable_by_user(user)).to eq([issue1, issue2])
end
end
- context 'using a user that has no access to the project' do
- it 'returns no issues when the user is not an assignee or author' do
+ context "using a user that has no access to the project" do
+ it "returns no issues when the user is not an assignee or author" do
expect(collection.updatable_by_user(user)).to be_empty
end
- it 'returns the issues the user is assigned to' do
+ it "returns the issues the user is assigned to" do
issue1.assignees << user
expect(collection.updatable_by_user(user)).to eq([issue1])
end
- it 'returns the issues for which the user is the author' do
+ it "returns the issues for which the user is the author" do
issue1.author = user
expect(collection.updatable_by_user(user)).to eq([issue1])
end
end
- context 'using a user that has reporter access to the project' do
- it 'returns the issues of the project' do
+ context "using a user that has reporter access to the project" do
+ it "returns the issues of the project" do
project.add_reporter(user)
expect(collection.updatable_by_user(user)).to eq([issue1, issue2])
end
end
- context 'using a user that is the owner of a project' do
- it 'returns the issues of the project' do
+ context "using a user that is the owner of a project" do
+ it "returns the issues of the project" do
expect(collection.updatable_by_user(project.namespace.owner))
.to eq([issue1, issue2])
end
end
end
- describe '#visible_to' do
- it 'is an alias for updatable_by_user' do
+ describe "#visible_to" do
+ it "is an alias for updatable_by_user" do
updatable_by_user = described_class.instance_method(:updatable_by_user)
visible_to = described_class.instance_method(:visible_to)
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index 6101df2e099..42b01c9234e 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issue do
describe "Associations" do
@@ -6,7 +6,7 @@ describe Issue do
it { is_expected.to have_many(:assignees) }
end
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Issuable) }
@@ -14,27 +14,27 @@ describe Issue do
it { is_expected.to include_module(Sortable) }
it { is_expected.to include_module(Taskable) }
- it_behaves_like 'AtomicInternalId' do
+ it_behaves_like "AtomicInternalId" do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:issue) }
let(:scope) { :project }
- let(:scope_attrs) { { project: instance.project } }
+ let(:scope_attrs) { {project: instance.project} }
let(:usage) { :issues }
end
end
subject { create(:issue) }
- describe 'callbacks' do
- describe '#ensure_metrics' do
- it 'creates metrics after saving' do
+ describe "callbacks" do
+ describe "#ensure_metrics" do
+ it "creates metrics after saving" do
issue = create(:issue)
expect(issue.metrics).to be_persisted
expect(Issue::Metrics.count).to eq(1)
end
- it 'does not create duplicate metrics for an issue' do
+ it "does not create duplicate metrics for an issue" do
issue = create(:issue)
issue.close!
@@ -43,7 +43,7 @@ describe Issue do
expect(Issue::Metrics.count).to eq(1)
end
- it 'records current metrics' do
+ it "records current metrics" do
expect_any_instance_of(Issue::Metrics).to receive(:record!)
create(:issue)
@@ -51,170 +51,170 @@ describe Issue do
end
end
- describe '#order_by_position_and_priority' do
+ describe "#order_by_position_and_priority" do
let(:project) { create :project }
- let(:p1) { create(:label, title: 'P1', project: project, priority: 1) }
- let(:p2) { create(:label, title: 'P2', project: project, priority: 2) }
+ let(:p1) { create(:label, title: "P1", project: project, priority: 1) }
+ let(:p2) { create(:label, title: "P2", project: project, priority: 2) }
let!(:issue1) { create(:labeled_issue, project: project, labels: [p1]) }
let!(:issue2) { create(:labeled_issue, project: project, labels: [p2]) }
let!(:issue3) { create(:issue, project: project, relative_position: 100) }
let!(:issue4) { create(:issue, project: project, relative_position: 200) }
- it 'returns ordered list' do
+ it "returns ordered list" do
expect(project.issues.order_by_position_and_priority)
.to match [issue3, issue4, issue1, issue2]
end
end
- describe '#card_attributes' do
- it 'includes the author name' do
- allow(subject).to receive(:author).and_return(double(name: 'Robert'))
+ describe "#card_attributes" do
+ it "includes the author name" do
+ allow(subject).to receive(:author).and_return(double(name: "Robert"))
allow(subject).to receive(:assignees).and_return([])
expect(subject.card_attributes)
- .to eq({ 'Author' => 'Robert', 'Assignee' => '' })
+ .to eq({"Author" => "Robert", "Assignee" => ""})
end
- it 'includes the assignee name' do
- allow(subject).to receive(:author).and_return(double(name: 'Robert'))
- allow(subject).to receive(:assignees).and_return([double(name: 'Douwe')])
+ it "includes the assignee name" do
+ allow(subject).to receive(:author).and_return(double(name: "Robert"))
+ allow(subject).to receive(:assignees).and_return([double(name: "Douwe")])
expect(subject.card_attributes)
- .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' })
+ .to eq({"Author" => "Robert", "Assignee" => "Douwe"})
end
end
- describe '#close' do
- subject(:issue) { create(:issue, state: 'opened') }
+ describe "#close" do
+ subject(:issue) { create(:issue, state: "opened") }
- it 'sets closed_at to Time.now when an issue is closed' do
+ it "sets closed_at to Time.now when an issue is closed" do
expect { issue.close }.to change { issue.closed_at }.from(nil)
end
- it 'changes the state to closed' do
- expect { issue.close }.to change { issue.state }.from('opened').to('closed')
+ it "changes the state to closed" do
+ expect { issue.close }.to change { issue.state }.from("opened").to("closed")
end
end
- describe '#reopen' do
+ describe "#reopen" do
let(:user) { create(:user) }
- let(:issue) { create(:issue, state: 'closed', closed_at: Time.now, closed_by: user) }
+ let(:issue) { create(:issue, state: "closed", closed_at: Time.now, closed_by: user) }
- it 'sets closed_at to nil when an issue is reopend' do
+ it "sets closed_at to nil when an issue is reopend" do
expect { issue.reopen }.to change { issue.closed_at }.to(nil)
end
- it 'sets closed_by to nil when an issue is reopend' do
+ it "sets closed_by to nil when an issue is reopend" do
expect { issue.reopen }.to change { issue.closed_by }.from(user).to(nil)
end
- it 'changes the state to opened' do
- expect { issue.reopen }.to change { issue.state }.from('closed').to('opened')
+ it "changes the state to opened" do
+ expect { issue.reopen }.to change { issue.state }.from("closed").to("opened")
end
end
- describe '#to_reference' do
- let(:namespace) { build(:namespace, path: 'sample-namespace') }
- let(:project) { build(:project, name: 'sample-project', namespace: namespace) }
+ describe "#to_reference" do
+ let(:namespace) { build(:namespace, path: "sample-namespace") }
+ let(:project) { build(:project, name: "sample-project", namespace: namespace) }
let(:issue) { build(:issue, iid: 1, project: project) }
- let(:group) { create(:group, name: 'Group', path: 'sample-group') }
+ let(:group) { create(:group, name: "Group", path: "sample-group") }
- context 'when nil argument' do
- it 'returns issue id' do
+ context "when nil argument" do
+ it "returns issue id" do
expect(issue.to_reference).to eq "#1"
end
end
- context 'when full is true' do
- it 'returns complete path to the issue' do
- expect(issue.to_reference(full: true)).to eq 'sample-namespace/sample-project#1'
- expect(issue.to_reference(project, full: true)).to eq 'sample-namespace/sample-project#1'
- expect(issue.to_reference(group, full: true)).to eq 'sample-namespace/sample-project#1'
+ context "when full is true" do
+ it "returns complete path to the issue" do
+ expect(issue.to_reference(full: true)).to eq "sample-namespace/sample-project#1"
+ expect(issue.to_reference(project, full: true)).to eq "sample-namespace/sample-project#1"
+ expect(issue.to_reference(group, full: true)).to eq "sample-namespace/sample-project#1"
end
end
- context 'when same project argument' do
- it 'returns issue id' do
+ context "when same project argument" do
+ it "returns issue id" do
expect(issue.to_reference(project)).to eq("#1")
end
end
- context 'when cross namespace project argument' do
- let(:another_namespace_project) { create(:project, name: 'another-project') }
+ context "when cross namespace project argument" do
+ let(:another_namespace_project) { create(:project, name: "another-project") }
- it 'returns complete path to the issue' do
- expect(issue.to_reference(another_namespace_project)).to eq 'sample-namespace/sample-project#1'
+ it "returns complete path to the issue" do
+ expect(issue.to_reference(another_namespace_project)).to eq "sample-namespace/sample-project#1"
end
end
- it 'supports a cross-project reference' do
- another_project = build(:project, name: 'another-project', namespace: project.namespace)
+ it "supports a cross-project reference" do
+ another_project = build(:project, name: "another-project", namespace: project.namespace)
expect(issue.to_reference(another_project)).to eq "sample-project#1"
end
- context 'when same namespace / cross-project argument' do
+ context "when same namespace / cross-project argument" do
let(:another_project) { create(:project, namespace: namespace) }
- it 'returns path to the issue with the project name' do
- expect(issue.to_reference(another_project)).to eq 'sample-project#1'
+ it "returns path to the issue with the project name" do
+ expect(issue.to_reference(another_project)).to eq "sample-project#1"
end
end
- context 'when different namespace / cross-project argument' do
- let(:another_namespace) { create(:namespace, path: 'another-namespace') }
- let(:another_project) { create(:project, path: 'another-project', namespace: another_namespace) }
+ context "when different namespace / cross-project argument" do
+ let(:another_namespace) { create(:namespace, path: "another-namespace") }
+ let(:another_project) { create(:project, path: "another-project", namespace: another_namespace) }
- it 'returns full path to the issue' do
- expect(issue.to_reference(another_project)).to eq 'sample-namespace/sample-project#1'
+ it "returns full path to the issue" do
+ expect(issue.to_reference(another_project)).to eq "sample-namespace/sample-project#1"
end
end
- context 'when argument is a namespace' do
- context 'with same project path' do
- it 'returns path to the issue with the project name' do
- expect(issue.to_reference(namespace)).to eq 'sample-project#1'
+ context "when argument is a namespace" do
+ context "with same project path" do
+ it "returns path to the issue with the project name" do
+ expect(issue.to_reference(namespace)).to eq "sample-project#1"
end
end
- context 'with different project path' do
- it 'returns full path to the issue' do
- expect(issue.to_reference(group)).to eq 'sample-namespace/sample-project#1'
+ context "with different project path" do
+ it "returns full path to the issue" do
+ expect(issue.to_reference(group)).to eq "sample-namespace/sample-project#1"
end
end
end
end
- describe '#assignee_or_author?' do
+ describe "#assignee_or_author?" do
let(:user) { create(:user) }
let(:issue) { create(:issue) }
- it 'returns true for a user that is assigned to an issue' do
+ it "returns true for a user that is assigned to an issue" do
issue.assignees << user
expect(issue.assignee_or_author?(user)).to be_truthy
end
- it 'returns true for a user that is the author of an issue' do
+ it "returns true for a user that is the author of an issue" do
issue.update(author: user)
expect(issue.assignee_or_author?(user)).to be_truthy
end
- it 'returns false for a user that is not the assignee or author' do
+ it "returns false for a user that is not the assignee or author" do
expect(issue.assignee_or_author?(user)).to be_falsey
end
end
- describe '#can_move?' do
+ describe "#can_move?" do
let(:user) { create(:user) }
let(:issue) { create(:issue) }
subject { issue.can_move?(user) }
- context 'user is not a member of project issue belongs to' do
+ context "user is not a member of project issue belongs to" do
it { is_expected.to eq false}
end
- context 'user is reporter in project issue belongs to' do
+ context "user is reporter in project issue belongs to" do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
@@ -224,16 +224,16 @@ describe Issue do
it { is_expected.to eq true }
- context 'issue not persisted' do
+ context "issue not persisted" do
let(:issue) { build(:issue, project: project) }
it { is_expected.to eq false }
end
- context 'checking destination project also' do
+ context "checking destination project also" do
subject { issue.can_move?(user, to_project) }
let(:to_project) { create(:project) }
- context 'destination project allowed' do
+ context "destination project allowed" do
before do
to_project.add_reporter(user)
end
@@ -241,7 +241,7 @@ describe Issue do
it { is_expected.to eq true }
end
- context 'destination project not allowed' do
+ context "destination project not allowed" do
before do
to_project.add_guest(user)
end
@@ -252,15 +252,15 @@ describe Issue do
end
end
- describe '#moved?' do
+ describe "#moved?" do
let(:issue) { create(:issue) }
subject { issue.moved? }
- context 'issue not moved' do
+ context "issue not moved" do
it { is_expected.to eq false }
end
- context 'issue already moved' do
+ context "issue already moved" do
let(:moved_to_issue) { create(:issue) }
let(:issue) { create(:issue, moved_to: moved_to_issue) }
@@ -268,7 +268,7 @@ describe Issue do
end
end
- describe '#suggested_branch_name' do
+ describe "#suggested_branch_name" do
let(:repository) { double }
subject { build(:issue) }
@@ -277,44 +277,44 @@ describe Issue do
allow(subject.project).to receive(:repository).and_return(repository)
end
- context '#to_branch_name does not exists' do
+ context "#to_branch_name does not exists" do
before do
allow(repository).to receive(:branch_exists?).and_return(false)
end
- it 'returns #to_branch_name' do
+ it "returns #to_branch_name" do
expect(subject.suggested_branch_name).to eq(subject.to_branch_name)
end
end
- context '#to_branch_name exists not ending with -index' do
+ context "#to_branch_name exists not ending with -index" do
before do
allow(repository).to receive(:branch_exists?).and_return(true)
allow(repository).to receive(:branch_exists?).with(/#{subject.to_branch_name}-\d/).and_return(false)
end
- it 'returns #to_branch_name ending with -2' do
+ it "returns #to_branch_name ending with -2" do
expect(subject.suggested_branch_name).to eq("#{subject.to_branch_name}-2")
end
end
- context '#to_branch_name exists ending with -index' do
+ context "#to_branch_name exists ending with -index" do
before do
allow(repository).to receive(:branch_exists?).and_return(true)
allow(repository).to receive(:branch_exists?).with("#{subject.to_branch_name}-3").and_return(false)
end
- it 'returns #to_branch_name ending with max index + 1' do
+ it "returns #to_branch_name ending with max index + 1" do
expect(subject.suggested_branch_name).to eq("#{subject.to_branch_name}-3")
end
end
end
- describe '#has_related_branch?' do
+ describe "#has_related_branch?" do
let(:issue) { create(:issue, title: "Blue Bell Knoll") }
subject { issue.has_related_branch? }
- context 'branch found' do
+ context "branch found" do
before do
allow(issue.project.repository).to receive(:branch_names).and_return(["iceblink-luck", issue.to_branch_name])
end
@@ -322,7 +322,7 @@ describe Issue do
it { is_expected.to eq true }
end
- context 'branch not found' do
+ context "branch not found" do
before do
allow(issue.project.repository).to receive(:branch_names).and_return(["lazy-calm"])
end
@@ -331,21 +331,21 @@ describe Issue do
end
end
- it_behaves_like 'an editable mentionable' do
+ it_behaves_like "an editable mentionable" do
subject { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { "issue #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt) { subject.description = txt } }
end
- it_behaves_like 'a Taskable' do
+ it_behaves_like "a Taskable" do
let(:subject) { create :issue }
end
describe "#to_branch_name" do
- let(:issue) { create(:issue, title: 'testing-issue') }
+ let(:issue) { create(:issue, title: "testing-issue") }
- it 'starts with the issue iid' do
+ it "starts with the issue iid" do
expect(issue.to_branch_name).to match /\A#{issue.iid}-[A-Za-z\-]+\z/
end
@@ -354,22 +354,22 @@ describe Issue do
end
it "does not contain the issue title if confidential" do
- issue = create(:issue, title: 'testing-issue', confidential: true)
+ issue = create(:issue, title: "testing-issue", confidential: true)
expect(issue.to_branch_name).to match /confidential-issue\z/
end
end
- describe '#can_be_worked_on?' do
+ describe "#can_be_worked_on?" do
let(:project) { build(:project) }
subject { build(:issue, :opened, project: project) }
- context 'is closed' do
+ context "is closed" do
subject { build(:issue, :closed) }
it { is_expected.not_to be_can_be_worked_on }
end
- context 'project is forked' do
+ context "project is forked" do
before do
allow(project).to receive(:forked?).and_return(true)
end
@@ -380,46 +380,46 @@ describe Issue do
it { is_expected.to be_can_be_worked_on }
end
- describe '#participants' do
- context 'using a public project' do
+ describe "#participants" do
+ context "using a public project" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let!(:note1) do
- create(:note_on_issue, noteable: issue, project: project, note: 'a')
+ create(:note_on_issue, noteable: issue, project: project, note: "a")
end
let!(:note2) do
- create(:note_on_issue, noteable: issue, project: project, note: 'b')
+ create(:note_on_issue, noteable: issue, project: project, note: "b")
end
- it 'includes the issue author' do
+ it "includes the issue author" do
expect(issue.participants).to include(issue.author)
end
- it 'includes the authors of the notes' do
+ it "includes the authors of the notes" do
expect(issue.participants).to include(note1.author, note2.author)
end
end
- context 'using a private project' do
- it 'does not include mentioned users that do not have access to the project' do
+ context "using a private project" do
+ it "does not include mentioned users that do not have access to the project" do
project = create(:project)
user = create(:user)
issue = create(:issue, project: project)
create(:note_on_issue,
- noteable: issue,
- project: project,
- note: user.to_reference)
+ noteable: issue,
+ project: project,
+ note: user.to_reference)
expect(issue.participants).not_to include(user)
end
end
end
- describe 'cached counts' do
- it 'updates when assignees change' do
+ describe "cached counts" do
+ it "updates when assignees change" do
user1 = create(:user)
user2 = create(:user)
project = create(:project)
@@ -438,40 +438,40 @@ describe Issue do
end
end
- describe '#visible_to_user?' do
- context 'without a user' do
+ describe "#visible_to_user?" do
+ context "without a user" do
let(:issue) { build(:issue) }
- it 'returns true when the issue is publicly visible' do
+ it "returns true when the issue is publicly visible" do
expect(issue).to receive(:publicly_visible?).and_return(true)
expect(issue.visible_to_user?).to eq(true)
end
- it 'returns false when the issue is not publicly visible' do
+ it "returns false when the issue is not publicly visible" do
expect(issue).to receive(:publicly_visible?).and_return(false)
expect(issue.visible_to_user?).to eq(false)
end
end
- context 'with a user' do
+ context "with a user" do
let(:user) { create(:user) }
let(:issue) { build(:issue) }
- it 'returns true when the issue is readable' do
+ it "returns true when the issue is readable" do
expect(issue).to receive(:readable_by?).with(user).and_return(true)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns false when the issue is not readable' do
+ it "returns false when the issue is not readable" do
expect(issue).to receive(:readable_by?).with(user).and_return(false)
expect(issue.visible_to_user?(user)).to eq(false)
end
- it 'returns false when feature is disabled' do
+ it "returns false when feature is disabled" do
expect(issue).not_to receive(:readable_by?)
issue.project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
@@ -479,7 +479,7 @@ describe Issue do
expect(issue.visible_to_user?(user)).to eq(false)
end
- it 'returns false when restricted for members' do
+ it "returns false when restricted for members" do
expect(issue).not_to receive(:readable_by?)
issue.project.project_feature.update_attribute(:issues_access_level, ProjectFeature::PRIVATE)
@@ -488,54 +488,54 @@ describe Issue do
end
end
- describe 'with a regular user that is not a team member' do
+ describe "with a regular user that is not a team member" do
let(:user) { create(:user) }
- context 'using a public project' do
+ context "using a public project" do
let(:project) { create(:project, :public) }
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, project: project, confidential: true)
expect(issue.visible_to_user?(user)).to eq(false)
end
end
- context 'using an internal project' do
+ context "using an internal project" do
let(:project) { create(:project, :internal) }
- context 'using an internal user' do
- it 'returns true for a regular issue' do
+ context "using an internal user" do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(false)
end
end
- context 'using an external user' do
+ context "using an external user" do
before do
allow(user).to receive(:external?).and_return(true)
end
- it 'returns false for a regular issue' do
+ it "returns false for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(false)
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(false)
@@ -543,33 +543,33 @@ describe Issue do
end
end
- context 'using a private project' do
+ context "using a private project" do
let(:project) { create(:project, :private) }
- it 'returns false for a regular issue' do
+ it "returns false for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(false)
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(false)
end
- context 'when the user is the project owner' do
+ context "when the user is the project owner" do
before do
project.add_maintainer(user)
end
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns true for a confidential issue' do
+ it "returns true for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
@@ -578,62 +578,62 @@ describe Issue do
end
end
- context 'with a regular user that is a team member' do
+ context "with a regular user that is a team member" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
- context 'using a public project' do
+ context "using a public project" do
before do
project.add_developer(user)
end
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns true for a confidential issue' do
+ it "returns true for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
end
- context 'using an internal project' do
+ context "using an internal project" do
let(:project) { create(:project, :internal) }
before do
project.add_developer(user)
end
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns true for a confidential issue' do
+ it "returns true for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
end
- context 'using a private project' do
+ context "using a private project" do
let(:project) { create(:project, :private) }
before do
project.add_developer(user)
end
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns true for a confidential issue' do
+ it "returns true for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
@@ -641,17 +641,17 @@ describe Issue do
end
end
- context 'with an admin user' do
+ context "with an admin user" do
let(:project) { create(:project) }
let(:user) { create(:admin) }
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
end
- it 'returns true for a confidential issue' do
+ it "returns true for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue.visible_to_user?(user)).to eq(true)
@@ -659,49 +659,49 @@ describe Issue do
end
end
- describe '#publicly_visible?' do
- context 'using a public project' do
+ describe "#publicly_visible?" do
+ context "using a public project" do
let(:project) { create(:project, :public) }
- it 'returns true for a regular issue' do
+ it "returns true for a regular issue" do
issue = build(:issue, project: project)
expect(issue).to be_truthy
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue).not_to be_falsy
end
end
- context 'using an internal project' do
+ context "using an internal project" do
let(:project) { create(:project, :internal) }
- it 'returns false for a regular issue' do
+ it "returns false for a regular issue" do
issue = build(:issue, project: project)
expect(issue).not_to be_falsy
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue).not_to be_falsy
end
end
- context 'using a private project' do
+ context "using a private project" do
let(:project) { create(:project, :private) }
- it 'returns false for a regular issue' do
+ it "returns false for a regular issue" do
issue = build(:issue, project: project)
expect(issue).not_to be_falsy
end
- it 'returns false for a confidential issue' do
+ it "returns false for a confidential issue" do
issue = build(:issue, :confidential, project: project)
expect(issue).not_to be_falsy
@@ -709,8 +709,8 @@ describe Issue do
end
end
- describe '#hook_attrs' do
- it 'delegates to Gitlab::HookData::IssueBuilder#build' do
+ describe "#hook_attrs" do
+ it "delegates to Gitlab::HookData::IssueBuilder#build" do
builder = double
expect(Gitlab::HookData::IssueBuilder)
@@ -721,24 +721,24 @@ describe Issue do
end
end
- describe '#check_for_spam?' do
+ describe "#check_for_spam?" do
using RSpec::Parameterized::TableSyntax
where(:visibility_level, :confidential, :new_attributes, :check_for_spam?) do
- Gitlab::VisibilityLevel::PUBLIC | false | { description: 'woo' } | true
- Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo' } | true
- Gitlab::VisibilityLevel::PUBLIC | true | { confidential: false } | true
- Gitlab::VisibilityLevel::PUBLIC | true | { description: 'woo' } | false
- Gitlab::VisibilityLevel::PUBLIC | false | { title: 'woo', confidential: true } | false
- Gitlab::VisibilityLevel::PUBLIC | false | { description: 'original description' } | false
- Gitlab::VisibilityLevel::INTERNAL | false | { description: 'woo' } | false
- Gitlab::VisibilityLevel::PRIVATE | false | { description: 'woo' } | false
+ Gitlab::VisibilityLevel::PUBLIC | false | {description: "woo"} | true
+ Gitlab::VisibilityLevel::PUBLIC | false | {title: "woo"} | true
+ Gitlab::VisibilityLevel::PUBLIC | true | {confidential: false} | true
+ Gitlab::VisibilityLevel::PUBLIC | true | {description: "woo"} | false
+ Gitlab::VisibilityLevel::PUBLIC | false | {title: "woo", confidential: true} | false
+ Gitlab::VisibilityLevel::PUBLIC | false | {description: "original description"} | false
+ Gitlab::VisibilityLevel::INTERNAL | false | {description: "woo"} | false
+ Gitlab::VisibilityLevel::PRIVATE | false | {description: "woo"} | false
end
with_them do
- it 'checks for spam on issues that can be seen anonymously' do
+ it "checks for spam on issues that can be seen anonymously" do
project = create(:project, visibility_level: visibility_level)
- issue = create(:issue, project: project, confidential: confidential, description: 'original description')
+ issue = create(:issue, project: project, confidential: confidential, description: "original description")
issue.assign_attributes(new_attributes)
@@ -747,8 +747,8 @@ describe Issue do
end
end
- describe 'removing an issue' do
- it 'refreshes the number of open issues of the project' do
+ describe "removing an issue" do
+ it "refreshes the number of open issues of the project" do
project = subject.project
expect { subject.destroy }
@@ -756,8 +756,8 @@ describe Issue do
end
end
- describe '.public_only' do
- it 'only returns public issues' do
+ describe ".public_only" do
+ it "only returns public issues" do
public_issue = create(:issue)
create(:issue, confidential: true)
@@ -765,8 +765,8 @@ describe Issue do
end
end
- describe '.confidential_only' do
- it 'only returns confidential_only issues' do
+ describe ".confidential_only" do
+ it "only returns confidential_only issues" do
create(:issue)
confidential_issue = create(:issue, confidential: true)
@@ -774,7 +774,7 @@ describe Issue do
end
end
- it_behaves_like 'throttled touch' do
+ it_behaves_like "throttled touch" do
subject { create(:issue, updated_at: 1.hour.ago) }
end
end
diff --git a/spec/models/key_spec.rb b/spec/models/key_spec.rb
index 06d26ef89f1..61ebbfe4e71 100644
--- a/spec/models/key_spec.rb
+++ b/spec/models/key_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Key, :mailer do
describe "Associations" do
@@ -18,7 +18,7 @@ describe Key, :mailer do
it { is_expected.to allow_value(attributes_for(:dsa_key_2048)[:key]).for(:key) }
it { is_expected.to allow_value(attributes_for(:ecdsa_key_256)[:key]).for(:key) }
it { is_expected.to allow_value(attributes_for(:ed25519_key_256)[:key]).for(:key) }
- it { is_expected.not_to allow_value('foo-bar').for(:key) }
+ it { is_expected.not_to allow_value("foo-bar").for(:key) }
end
describe "Methods" do
@@ -27,13 +27,13 @@ describe Key, :mailer do
it { is_expected.to respond_to :publishable_key }
describe "#publishable_keys" do
- it 'replaces SSH key comment with simple identifier of username + hostname' do
+ it "replaces SSH key comment with simple identifier of username + hostname" do
expect(build(:key, user: user).publishable_key).to include("#{user.name} (#{Gitlab.config.gitlab.host})")
end
end
describe "#update_last_used_at" do
- it 'updates the last used timestamp' do
+ it "updates the last used timestamp" do
key = build(:key)
service = double(:service)
@@ -64,7 +64,7 @@ describe Key, :mailer do
it "does not accept a duplicate key with a different comment" do
first_key = create(:key, user: user)
duplicate = build(:key, user: user, key: first_key.key)
- duplicate.key << ' extra comment'
+ duplicate.key << " extra comment"
expect(duplicate).not_to be_valid
end
@@ -75,15 +75,15 @@ describe Key, :mailer do
expect(build(:key)).to be_valid
end
- it 'rejects the unfingerprintable key (not a key)' do
- expect(build(:key, key: 'ssh-rsa an-invalid-key==')).not_to be_valid
+ it "rejects the unfingerprintable key (not a key)" do
+ expect(build(:key, key: "ssh-rsa an-invalid-key==")).not_to be_valid
end
where(:factory, :chars, :expected_sections) do
[
[:key, ["\n", "\r\n"], 3],
- [:key, [' ', ' '], 3],
- [:key_without_comment, [' ', ' '], 2]
+ [:key, [" ", " "], 3],
+ [:key_without_comment, [" ", " "], 2],
]
end
@@ -91,7 +91,7 @@ describe Key, :mailer do
let!(:key) { create(factory) }
let!(:original_fingerprint) { key.fingerprint }
- it 'accepts a key with blank space characters after stripping them' do
+ it "accepts a key with blank space characters after stripping them" do
modified_key = key.key.insert(100, chars.first).insert(40, chars.last)
_, content = modified_key.split
@@ -106,7 +106,7 @@ describe Key, :mailer do
end
end
- context 'validate it meets key restrictions' do
+ context "validate it meets key restrictions" do
where(:factory, :minimum, :result) do
forbidden = ApplicationSetting::FORBIDDEN_KEY_VALUE
@@ -133,7 +133,7 @@ describe Key, :mailer do
[:rsa_key_2048, forbidden, false],
[:dsa_key_2048, forbidden, false],
[:ecdsa_key_256, forbidden, false],
- [:ed25519_key_256, forbidden, false]
+ [:ed25519_key_256, forbidden, false],
]
end
@@ -148,30 +148,30 @@ describe Key, :mailer do
end
end
- context 'callbacks' do
- it 'adds new key to authorized_file' do
+ context "callbacks" 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 'removes 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
end
end
- describe '#key=' do
+ describe "#key=" do
let(:valid_key) do
"ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiPWx6WM4lhHNedGfBpPJNPpZ7yKu+dnn1SJejgt4596k6YjzGGphH2TUxwKzxcKDKKezwkpfnxPkSMkuEspGRt/aZZ9wa++Oi7Qkr8prgHc4soW6NUlfDzpvZK2H5E7eQaSeP3SAwGmQKUFHCddNaP0L+hM7zhFNzjFvpaMgJw0= dummy@gitlab.com"
end
- it 'strips white spaces' do
+ it "strips white spaces" do
expect(described_class.new(key: " #{valid_key} ").key).to eq(valid_key)
end
- it 'invalidates the public_key attribute' do
+ it "invalidates the public_key attribute" do
key = build(:key)
original = key.public_key
@@ -182,9 +182,9 @@ describe Key, :mailer do
end
end
- describe '#refresh_user_cache', :use_clean_rails_memory_store_caching do
- context 'when the key belongs to a user' do
- it 'refreshes the keys count cache for the user' do
+ describe "#refresh_user_cache", :use_clean_rails_memory_store_caching do
+ context "when the key belongs to a user" do
+ it "refreshes the keys count cache for the user" do
expect_any_instance_of(Users::KeysCountService)
.to receive(:refresh_cache)
.and_call_original
@@ -195,8 +195,8 @@ describe Key, :mailer do
end
end
- context 'when the key does not belong to a user' do
- it 'does nothing' do
+ context "when the key does not belong to a user" do
+ it "does nothing" do
expect_any_instance_of(Users::KeysCountService)
.not_to receive(:refresh_cache)
diff --git a/spec/models/label_link_spec.rb b/spec/models/label_link_spec.rb
index e2b49bc2de7..14f3081df50 100644
--- a/spec/models/label_link_spec.rb
+++ b/spec/models/label_link_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe LabelLink do
it { expect(build(:label_link)).to be_valid }
diff --git a/spec/models/label_note_spec.rb b/spec/models/label_note_spec.rb
index dd2c702a7a9..ae2373a3325 100644
--- a/spec/models/label_note_spec.rb
+++ b/spec/models/label_note_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe LabelNote do
set(:project) { create(:project, :repository) }
@@ -9,15 +9,15 @@ describe LabelNote do
set(:label2) { create(:label, project: project) }
let(:resource_parent) { project }
- context 'when resource is issue' do
+ context "when resource is issue" do
set(:resource) { create(:issue, project: project) }
- it_behaves_like 'label note created from events'
+ it_behaves_like "label note created from events"
end
- context 'when resource is merge request' do
+ context "when resource is merge request" do
set(:resource) { create(:merge_request, source_project: project, target_project: project) }
- it_behaves_like 'label note created from events'
+ it_behaves_like "label note created from events"
end
end
diff --git a/spec/models/label_priority_spec.rb b/spec/models/label_priority_spec.rb
index 9dcb0f06b20..d1a436a4278 100644
--- a/spec/models/label_priority_spec.rb
+++ b/spec/models/label_priority_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe LabelPriority do
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:label) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:label) }
it { is_expected.to validate_numericality_of(:priority).only_integer.is_greater_than_or_equal_to(0) }
- it 'validates uniqueness of label_id scoped to project_id' do
+ it "validates uniqueness of label_id scoped to project_id" do
create(:label_priority)
expect(subject).to validate_uniqueness_of(:label_id).scoped_to(:project_id)
diff --git a/spec/models/label_spec.rb b/spec/models/label_spec.rb
index 3fc6c06b7fa..26370d012a9 100644
--- a/spec/models/label_spec.rb
+++ b/spec/models/label_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe Label do
- describe 'modules' do
+ describe "modules" do
it { is_expected.to include_module(Referable) }
it { is_expected.to include_module(Subscribable) }
end
- describe 'associations' do
+ describe "associations" do
it { is_expected.to have_many(:issues).through(:label_links).source(:target) }
it { is_expected.to have_many(:label_links).dependent(:destroy) }
it { is_expected.to have_many(:lists).dependent(:destroy) }
- it { is_expected.to have_many(:priorities).class_name('LabelPriority') }
+ it { is_expected.to have_many(:priorities).class_name("LabelPriority") }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_uniqueness_of(:title).scoped_to([:group_id, :project_id]) }
- it 'validates color code' do
- is_expected.not_to allow_value('G-ITLAB').for(:color)
- is_expected.not_to allow_value('AABBCC').for(:color)
- is_expected.not_to allow_value('#AABBCCEE').for(:color)
- is_expected.not_to allow_value('GGHHII').for(:color)
- is_expected.not_to allow_value('#').for(:color)
- is_expected.not_to allow_value('').for(:color)
+ it "validates color code" do
+ is_expected.not_to allow_value("G-ITLAB").for(:color)
+ is_expected.not_to allow_value("AABBCC").for(:color)
+ is_expected.not_to allow_value("#AABBCCEE").for(:color)
+ is_expected.not_to allow_value("GGHHII").for(:color)
+ is_expected.not_to allow_value("#").for(:color)
+ is_expected.not_to allow_value("").for(:color)
- is_expected.to allow_value('#AABBCC').for(:color)
- is_expected.to allow_value('#abcdef').for(:color)
+ is_expected.to allow_value("#AABBCC").for(:color)
+ is_expected.to allow_value("#abcdef").for(:color)
end
- it 'validates title' do
- is_expected.not_to allow_value('G,ITLAB').for(:title)
- is_expected.not_to allow_value('').for(:title)
- is_expected.not_to allow_value('s' * 256).for(:title)
+ it "validates title" do
+ is_expected.not_to allow_value("G,ITLAB").for(:title)
+ is_expected.not_to allow_value("").for(:title)
+ is_expected.not_to allow_value("s" * 256).for(:title)
- is_expected.to allow_value('GITLAB').for(:title)
- is_expected.to allow_value('gitlab').for(:title)
- is_expected.to allow_value('G?ITLAB').for(:title)
- is_expected.to allow_value('G&ITLAB').for(:title)
+ is_expected.to allow_value("GITLAB").for(:title)
+ is_expected.to allow_value("gitlab").for(:title)
+ is_expected.to allow_value("G?ITLAB").for(:title)
+ is_expected.to allow_value("G&ITLAB").for(:title)
is_expected.to allow_value("customer's request").for(:title)
- is_expected.to allow_value('s' * 255).for(:title)
+ is_expected.to allow_value("s" * 255).for(:title)
end
end
- describe '#color' do
- it 'strips color' do
- label = described_class.new(color: ' #abcdef ')
+ describe "#color" do
+ it "strips color" do
+ label = described_class.new(color: " #abcdef ")
label.valid?
- expect(label.color).to eq('#abcdef')
+ expect(label.color).to eq("#abcdef")
end
- it 'uses default color if color is missing' do
+ it "uses default color if color is missing" do
label = described_class.new(color: nil)
expect(label.color).to be(Label::DEFAULT_COLOR)
end
end
- describe '#text_color' do
- it 'uses default color if color is missing' do
+ describe "#text_color" do
+ it "uses default color if color is missing" do
expect(LabelsHelper).to receive(:text_color_for_bg).with(Label::DEFAULT_COLOR)
.and_return(spy)
@@ -68,46 +68,46 @@ describe Label do
end
end
- describe '#title' do
- it 'sanitizes title' do
- label = described_class.new(title: '<b>foo & bar?</b>')
- expect(label.title).to eq('foo & bar?')
+ describe "#title" do
+ it "sanitizes title" do
+ label = described_class.new(title: "<b>foo & bar?</b>")
+ expect(label.title).to eq("foo & bar?")
end
- it 'strips title' do
- label = described_class.new(title: ' label ')
+ it "strips title" do
+ label = described_class.new(title: " label ")
label.valid?
- expect(label.title).to eq('label')
+ expect(label.title).to eq("label")
end
end
- describe 'priorization' do
+ describe "priorization" do
subject(:label) { create(:label) }
let(:project) { label.project }
- describe '#prioritize!' do
- context 'when label is not prioritized' do
- it 'creates a label priority' do
+ describe "#prioritize!" do
+ context "when label is not prioritized" do
+ it "creates a label priority" do
expect { label.prioritize!(project, 1) }.to change(label.priorities, :count).by(1)
end
- it 'sets label priority' do
+ it "sets label priority" do
label.prioritize!(project, 1)
expect(label.priorities.first.priority).to eq 1
end
end
- context 'when label is prioritized' do
+ context "when label is prioritized" do
let!(:priority) { create(:label_priority, project: project, label: label, priority: 0) }
- it 'does not create a label priority' do
+ it "does not create a label priority" do
expect { label.prioritize!(project, 1) }.not_to change(label.priorities, :count)
end
- it 'updates label priority' do
+ it "updates label priority" do
label.prioritize!(project, 1)
expect(priority.reload.priority).to eq 1
@@ -115,23 +115,23 @@ describe Label do
end
end
- describe '#unprioritize!' do
- it 'removes label priority' do
+ describe "#unprioritize!" do
+ it "removes label priority" do
create(:label_priority, project: project, label: label, priority: 0)
expect { label.unprioritize!(project) }.to change(label.priorities, :count).by(-1)
end
end
- describe '#priority' do
- context 'when label is not prioritized' do
- it 'returns nil' do
+ describe "#priority" do
+ context "when label is not prioritized" do
+ it "returns nil" do
expect(label.priority(project)).to be_nil
end
end
- context 'when label is prioritized' do
- it 'returns label priority' do
+ context "when label is prioritized" do
+ it "returns label priority" do
create(:label_priority, project: project, label: label, priority: 1)
expect(label.priority(project)).to eq 1
@@ -140,23 +140,23 @@ describe Label do
end
end
- describe '.search' do
- let(:label) { create(:label, title: 'bug', description: 'incorrect behavior') }
+ describe ".search" do
+ let(:label) { create(:label, title: "bug", description: "incorrect behavior") }
- it 'returns labels with a partially matching title' do
+ it "returns labels with a partially matching title" do
expect(described_class.search(label.title[0..2])).to eq([label])
end
- it 'returns labels with a partially matching description' do
+ it "returns labels with a partially matching description" do
expect(described_class.search(label.description[0..5])).to eq([label])
end
- it 'returns nothing' do
- expect(described_class.search('feature')).to be_empty
+ it "returns nothing" do
+ expect(described_class.search("feature")).to be_empty
end
end
- describe '.subscribed_by' do
+ describe ".subscribed_by" do
let!(:user) { create(:user) }
let!(:label) { create(:label) }
let!(:label2) { create(:label) }
@@ -165,16 +165,16 @@ describe Label do
label.subscribe(user)
end
- it 'returns subscribed labels' do
+ it "returns subscribed labels" do
expect(described_class.subscribed_by(user.id)).to eq([label])
end
- it 'returns nothing' do
+ it "returns nothing" do
expect(described_class.subscribed_by(0)).to be_empty
end
end
- describe '.optionally_subscribed_by' do
+ describe ".optionally_subscribed_by" do
let!(:user) { create(:user) }
let!(:label) { create(:label) }
let!(:label2) { create(:label) }
@@ -183,11 +183,11 @@ describe Label do
label.subscribe(user)
end
- it 'returns subscribed labels' do
+ it "returns subscribed labels" do
expect(described_class.optionally_subscribed_by(user.id)).to eq([label])
end
- it 'returns all labels if user_id is nil' do
+ it "returns all labels if user_id is nil" do
expect(described_class.optionally_subscribed_by(nil)).to match_array([label, label2])
end
end
diff --git a/spec/models/legacy_diff_discussion_spec.rb b/spec/models/legacy_diff_discussion_spec.rb
index dae97b69c84..22aa31cccdd 100644
--- a/spec/models/legacy_diff_discussion_spec.rb
+++ b/spec/models/legacy_diff_discussion_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe LegacyDiffDiscussion do
subject { create(:legacy_diff_note_on_merge_request).to_discussion }
- describe '#reply_attributes' do
- it 'includes line_code' do
+ describe "#reply_attributes" do
+ it "includes line_code" do
expect(subject.reply_attributes[:line_code]).to eq(subject.line_code)
end
end
- describe '#merge_request_version_params' do
- context 'when the discussion is active' do
+ describe "#merge_request_version_params" do
+ context "when the discussion is active" do
before do
allow(subject).to receive(:active?).and_return(true)
end
- it 'returns an empty hash, which will end up showing the latest version' do
+ it "returns an empty hash, which will end up showing the latest version" do
expect(subject.merge_request_version_params).to eq({})
end
end
- context 'when the discussion is outdated' do
+ context "when the discussion is outdated" do
before do
allow(subject).to receive(:active?).and_return(false)
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.merge_request_version_params).to be_nil
end
end
diff --git a/spec/models/lfs_download_object_spec.rb b/spec/models/lfs_download_object_spec.rb
index 88838b127d2..b84947e2022 100644
--- a/spec/models/lfs_download_object_spec.rb
+++ b/spec/models/lfs_download_object_spec.rb
@@ -1,63 +1,63 @@
-require 'rails_helper'
+require "rails_helper"
describe LfsDownloadObject do
- let(:oid) { 'cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411' }
- let(:link) { 'http://www.example.com' }
+ let(:oid) { "cd293be6cea034bd45a0352775a219ef5dc7825ce55d1f7dae9762d80ce64411" }
+ let(:link) { "http://www.example.com" }
let(:size) { 1 }
subject { described_class.new(oid: oid, size: size, link: link) }
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_numericality_of(:size).is_greater_than_or_equal_to(0) }
- context 'oid attribute' do
- it 'must be 64 characters long' do
+ context "oid attribute" do
+ it "must be 64 characters long" do
aggregate_failures do
- expect(described_class.new(oid: 'a' * 63, size: size, link: link)).to be_invalid
- expect(described_class.new(oid: 'a' * 65, size: size, link: link)).to be_invalid
- expect(described_class.new(oid: 'a' * 64, size: size, link: link)).to be_valid
+ expect(described_class.new(oid: "a" * 63, size: size, link: link)).to be_invalid
+ expect(described_class.new(oid: "a" * 65, size: size, link: link)).to be_invalid
+ expect(described_class.new(oid: "a" * 64, size: size, link: link)).to be_valid
end
end
- it 'must contain only hexadecimal characters' do
+ it "must contain only hexadecimal characters" do
aggregate_failures do
expect(subject).to be_valid
- expect(described_class.new(oid: 'g' * 64, size: size, link: link)).to be_invalid
+ expect(described_class.new(oid: "g" * 64, size: size, link: link)).to be_invalid
end
end
end
- context 'link attribute' do
- it 'only http and https protocols are valid' do
+ context "link attribute" do
+ it "only http and https protocols are valid" do
aggregate_failures do
- expect(described_class.new(oid: oid, size: size, link: 'http://www.example.com')).to be_valid
- expect(described_class.new(oid: oid, size: size, link: 'https://www.example.com')).to be_valid
- expect(described_class.new(oid: oid, size: size, link: 'ftp://www.example.com')).to be_invalid
- expect(described_class.new(oid: oid, size: size, link: 'ssh://www.example.com')).to be_invalid
- expect(described_class.new(oid: oid, size: size, link: 'git://www.example.com')).to be_invalid
+ expect(described_class.new(oid: oid, size: size, link: "http://www.example.com")).to be_valid
+ expect(described_class.new(oid: oid, size: size, link: "https://www.example.com")).to be_valid
+ expect(described_class.new(oid: oid, size: size, link: "ftp://www.example.com")).to be_invalid
+ expect(described_class.new(oid: oid, size: size, link: "ssh://www.example.com")).to be_invalid
+ expect(described_class.new(oid: oid, size: size, link: "git://www.example.com")).to be_invalid
end
end
- it 'cannot be empty' do
- expect(described_class.new(oid: oid, size: size, link: '')).not_to be_valid
+ it "cannot be empty" do
+ expect(described_class.new(oid: oid, size: size, link: "")).not_to be_valid
end
- context 'when localhost or local network addresses' do
- subject { described_class.new(oid: oid, size: size, link: 'http://192.168.1.1') }
+ context "when localhost or local network addresses" do
+ subject { described_class.new(oid: oid, size: size, link: "http://192.168.1.1") }
before do
allow(ApplicationSetting)
.to receive(:current)
- .and_return(ApplicationSetting.build_from_defaults(allow_local_requests_from_hooks_and_services: setting))
+ .and_return(ApplicationSetting.build_from_defaults(allow_local_requests_from_hooks_and_services: setting))
end
- context 'are allowed' do
+ context "are allowed" do
let(:setting) { true }
it { expect(subject).to be_valid }
end
- context 'are not allowed' do
+ context "are not allowed" do
let(:setting) { false }
it { expect(subject).to be_invalid }
diff --git a/spec/models/lfs_file_lock_spec.rb b/spec/models/lfs_file_lock_spec.rb
index 41ca1578b94..0fd4a71d6d7 100644
--- a/spec/models/lfs_file_lock_spec.rb
+++ b/spec/models/lfs_file_lock_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe LfsFileLock do
set(:lfs_file_lock) { create(:lfs_file_lock) }
@@ -11,7 +11,7 @@ describe LfsFileLock do
it { is_expected.to validate_presence_of(:user_id) }
it { is_expected.to validate_presence_of(:path) }
- describe '#can_be_unlocked_by?' do
+ describe "#can_be_unlocked_by?" do
let(:developer) { create(:user) }
let(:maintainer) { create(:user) }
@@ -23,13 +23,13 @@ describe LfsFileLock do
end
context "when it's forced" do
- it 'can be unlocked by the author' do
+ it "can be unlocked by the author" do
user = lfs_file_lock.user
expect(lfs_file_lock.can_be_unlocked_by?(user, true)).to eq(true)
end
- it 'can be unlocked by a maintainer' do
+ it "can be unlocked by a maintainer" do
expect(lfs_file_lock.can_be_unlocked_by?(maintainer, true)).to eq(true)
end
@@ -39,7 +39,7 @@ describe LfsFileLock do
end
context "when it isn't forced" do
- it 'can be unlocked by the author' do
+ it "can be unlocked by the author" do
user = lfs_file_lock.user
expect(lfs_file_lock.can_be_unlocked_by?(user)).to eq(true)
diff --git a/spec/models/lfs_object_spec.rb b/spec/models/lfs_object_spec.rb
index 3f929710862..40782a03bbf 100644
--- a/spec/models/lfs_object_spec.rb
+++ b/spec/models/lfs_object_spec.rb
@@ -1,59 +1,59 @@
-require 'spec_helper'
+require "spec_helper"
describe LfsObject do
- describe '#local_store?' do
- it 'returns true when file_store is equal to LfsObjectUploader::Store::LOCAL' do
+ describe "#local_store?" do
+ it "returns true when file_store is equal to LfsObjectUploader::Store::LOCAL" do
subject.file_store = LfsObjectUploader::Store::LOCAL
expect(subject.local_store?).to eq true
end
- it 'returns false when file_store is equal to LfsObjectUploader::Store::REMOTE' do
+ it "returns false when file_store is equal to LfsObjectUploader::Store::REMOTE" do
subject.file_store = LfsObjectUploader::Store::REMOTE
expect(subject.local_store?).to eq false
end
end
- describe '#schedule_background_upload' do
+ describe "#schedule_background_upload" do
before do
stub_lfs_setting(enabled: true)
end
subject { create(:lfs_object, :with_file) }
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
before do
stub_lfs_object_storage(enabled: false)
end
- it 'does not schedule the migration' do
+ it "does not schedule the migration" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
subject
end
end
- context 'when object storage is enabled' do
- context 'when background upload is enabled' do
- context 'when is licensed' do
+ context "when object storage is enabled" do
+ context "when background upload is enabled" do
+ context "when is licensed" do
before do
stub_lfs_object_storage(background_upload: true)
end
- it 'schedules the model for migration' do
+ it "schedules the model for migration" do
expect(ObjectStorage::BackgroundMoveWorker)
.to receive(:perform_async)
- .with('LfsObjectUploader', described_class.name, :file, kind_of(Numeric))
+ .with("LfsObjectUploader", described_class.name, :file, kind_of(Numeric))
.once
subject
end
- it 'schedules the model for migration once' do
+ it "schedules the model for migration once" do
expect(ObjectStorage::BackgroundMoveWorker)
.to receive(:perform_async)
- .with('LfsObjectUploader', described_class.name, :file, kind_of(Numeric))
+ .with("LfsObjectUploader", described_class.name, :file, kind_of(Numeric))
.once
create(:lfs_object, :with_file)
@@ -61,12 +61,12 @@ describe LfsObject do
end
end
- context 'when background upload is disabled' do
+ context "when background upload is disabled" do
before do
stub_lfs_object_storage(background_upload: false)
end
- it 'schedules the model for migration' do
+ it "schedules the model for migration" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
subject
@@ -74,24 +74,24 @@ describe LfsObject do
end
end
- describe 'file is being stored' do
+ describe "file is being stored" do
let(:lfs_object) { create(:lfs_object, :with_file) }
- context 'when existing object has local store' do
- it 'is stored locally' do
+ context "when existing object has local store" do
+ it "is stored locally" do
expect(lfs_object.file_store).to be(ObjectStorage::Store::LOCAL)
expect(lfs_object.file).to be_file_storage
expect(lfs_object.file.object_store).to eq(ObjectStorage::Store::LOCAL)
end
end
- context 'when direct upload is enabled' do
+ context "when direct upload is enabled" do
before do
stub_lfs_object_storage(direct_upload: true)
end
- context 'when file is stored' do
- it 'is stored remotely' do
+ context "when file is stored" do
+ it "is stored remotely" do
expect(lfs_object.file_store).to eq(ObjectStorage::Store::REMOTE)
expect(lfs_object.file).not_to be_file_storage
expect(lfs_object.file.object_store).to eq(ObjectStorage::Store::REMOTE)
diff --git a/spec/models/lfs_objects_project_spec.rb b/spec/models/lfs_objects_project_spec.rb
index 0a3180f43e8..5c60a6c6351 100644
--- a/spec/models/lfs_objects_project_spec.rb
+++ b/spec/models/lfs_objects_project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe LfsObjectsProject do
set(:project) { create(:project) }
@@ -7,31 +7,31 @@ describe LfsObjectsProject do
create(:lfs_objects_project, project: project)
end
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:lfs_object) }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:lfs_object_id) }
it { is_expected.to validate_presence_of(:project_id) }
- it 'validates object id' do
+ it "validates object id" do
is_expected.to validate_uniqueness_of(:lfs_object_id)
.scoped_to(:project_id)
.with_message("already exists in project")
end
end
- describe '#update_project_statistics' do
- it 'updates project statistics when the object is added' do
+ describe "#update_project_statistics" do
+ it "updates project statistics when the object is added" do
expect(ProjectCacheWorker).to receive(:perform_async)
.with(project.id, [], [:lfs_objects_size])
subject.save!
end
- it 'updates project statistics when the object is removed' do
+ it "updates project statistics when the object is removed" do
subject.save!
expect(ProjectCacheWorker).to receive(:perform_async)
diff --git a/spec/models/license_template_spec.rb b/spec/models/license_template_spec.rb
index dd912eefac1..686dcfe59e4 100644
--- a/spec/models/license_template_spec.rb
+++ b/spec/models/license_template_spec.rb
@@ -1,49 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe LicenseTemplate do
- describe '#content' do
- it 'calls a proc exactly once if provided' do
- lazy = build_template(-> { 'bar' })
+ describe "#content" do
+ it "calls a proc exactly once if provided" do
+ lazy = build_template(-> { "bar" })
content = lazy.content
- expect(content).to eq('bar')
+ expect(content).to eq("bar")
expect(content.object_id).to eq(lazy.content.object_id)
- content.replace('foo')
- expect(lazy.content).to eq('foo')
+ content.replace("foo")
+ expect(lazy.content).to eq("foo")
end
- it 'returns a string if provided' do
- lazy = build_template('bar')
+ it "returns a string if provided" do
+ lazy = build_template("bar")
- expect(lazy.content).to eq('bar')
+ expect(lazy.content).to eq("bar")
end
end
- describe '#resolve!' do
+ describe "#resolve!" do
let(:content) do
<<~TEXT
- Pretend License
-
- [project]
-
- Copyright (c) [year] [fullname]
+ Pretend License
+ [project]
+ Copyright (c) [year] [fullname]
TEXT
end
let(:expected) do
<<~TEXT
- Pretend License
-
- Foo Project
-
- Copyright (c) 1985 Nick Thomas
+ Pretend License
+ Foo Project
+ Copyright (c) 1985 Nick Thomas
TEXT
end
let(:template) { build_template(content) }
- it 'updates placeholders in a copy of the template content' do
+ it "updates placeholders in a copy of the template content" do
expect(template.content.object_id).to eq(content.object_id)
template.resolve!(project_name: "Foo Project", fullname: "Nick Thomas", year: "1985")
@@ -54,6 +50,6 @@ describe LicenseTemplate do
end
def build_template(content)
- described_class.new(key: 'foo', name: 'foo', category: :Other, content: content)
+ described_class.new(key: "foo", name: "foo", category: :Other, content: content)
end
end
diff --git a/spec/models/list_spec.rb b/spec/models/list_spec.rb
index a51580f8292..13433d59dc2 100644
--- a/spec/models/list_spec.rb
+++ b/spec/models/list_spec.rb
@@ -1,21 +1,21 @@
-require 'rails_helper'
+require "rails_helper"
describe List do
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:board) }
it { is_expected.to belong_to(:label) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:board) }
it { is_expected.to validate_presence_of(:label) }
it { is_expected.to validate_presence_of(:list_type) }
it { is_expected.to validate_presence_of(:position) }
it { is_expected.to validate_numericality_of(:position).only_integer.is_greater_than_or_equal_to(0) }
- context 'when list_type is set to closed' do
+ context "when list_type is set to closed" do
subject { described_class.new(list_type: :closed) }
it { is_expected.not_to validate_presence_of(:label) }
@@ -23,60 +23,60 @@ describe List do
end
end
- describe '#destroy' do
- it 'can be destroyed when list_type is set to label' do
+ describe "#destroy" do
+ it "can be destroyed when list_type is set to label" do
subject = create(:list)
expect(subject.destroy).to be_truthy
end
- it 'can not be destroyed when list_type is set to closed' do
+ it "can not be destroyed when list_type is set to closed" do
subject = create(:closed_list)
expect(subject.destroy).to be_falsey
end
end
- describe '#destroyable?' do
- it 'returns true when list_type is set to label' do
+ describe "#destroyable?" do
+ it "returns true when list_type is set to label" do
subject.list_type = :label
expect(subject).to be_destroyable
end
- it 'returns false when list_type is set to closed' do
+ it "returns false when list_type is set to closed" do
subject.list_type = :closed
expect(subject).not_to be_destroyable
end
end
- describe '#movable?' do
- it 'returns true when list_type is set to label' do
+ describe "#movable?" do
+ it "returns true when list_type is set to label" do
subject.list_type = :label
expect(subject).to be_movable
end
- it 'returns false when list_type is set to closed' do
+ it "returns false when list_type is set to closed" do
subject.list_type = :closed
expect(subject).not_to be_movable
end
end
- describe '#title' do
- it 'returns label name when list_type is set to label' do
+ describe "#title" do
+ it "returns label name when list_type is set to label" do
subject.list_type = :label
- subject.label = Label.new(name: 'Development')
+ subject.label = Label.new(name: "Development")
- expect(subject.title).to eq 'Development'
+ expect(subject.title).to eq "Development"
end
- it 'returns Closed when list_type is set to closed' do
+ it "returns Closed when list_type is set to closed" do
subject.list_type = :closed
- expect(subject.title).to eq 'Closed'
+ expect(subject.title).to eq "Closed"
end
end
end
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index 188beac1582..67b778d5eaa 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Member do
describe "Associations" do
@@ -12,7 +12,7 @@ describe Member do
it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_inclusion_of(:access_level).in_array(Gitlab::Access.all_values) }
- it_behaves_like 'an object with email-formated attributes', :invite_email do
+ it_behaves_like "an object with email-formated attributes", :invite_email do
subject { build(:project_member) }
end
@@ -78,7 +78,7 @@ describe Member do
end
end
- describe 'Scopes & finders' do
+ describe "Scopes & finders" do
before do
project = create(:project, :public, :access_requestable)
group = create(:group)
@@ -98,16 +98,16 @@ describe Member do
@blocked_developer = project.members.find_by(user_id: @blocked_user.id, access_level: Gitlab::Access::DEVELOPER)
@invited_member = create(:project_member, :developer,
- project: project,
- invite_token: '1234',
- invite_email: 'toto1@example.com')
+ project: project,
+ invite_token: "1234",
+ invite_email: "toto1@example.com")
accepted_invite_user = build(:user, state: :active)
@accepted_invite_member = create(:project_member, :developer,
- project: project,
- invite_token: '1234',
- invite_email: 'toto2@example.com')
- .tap { |u| u.accept_invite!(accepted_invite_user) }
+ project: project,
+ invite_token: "1234",
+ invite_email: "toto2@example.com")
+ .tap { |u| u.accept_invite!(accepted_invite_user) }
requested_user = create(:user).tap { |u| project.request_access(u) }
@requested_member = project.requesters.find_by(user_id: requested_user.id)
@@ -116,19 +116,19 @@ describe Member do
@accepted_request_member = project.requesters.find_by(user_id: accepted_request_user.id).tap { |m| m.accept_request }
end
- describe '.access_for_user_ids' do
- it 'returns the right access levels' do
+ describe ".access_for_user_ids" do
+ it "returns the right access levels" do
users = [@owner_user.id, @maintainer_user.id, @blocked_user.id]
expected = {
@owner_user.id => Gitlab::Access::OWNER,
- @maintainer_user.id => Gitlab::Access::MAINTAINER
+ @maintainer_user.id => Gitlab::Access::MAINTAINER,
}
expect(described_class.access_for_user_ids(users)).to eq(expected)
end
end
- describe '.invite' do
+ describe ".invite" do
it { expect(described_class.invite).not_to include @maintainer }
it { expect(described_class.invite).to include @invited_member }
it { expect(described_class.invite).not_to include @accepted_invite_member }
@@ -136,7 +136,7 @@ describe Member do
it { expect(described_class.invite).not_to include @accepted_request_member }
end
- describe '.non_invite' do
+ describe ".non_invite" do
it { expect(described_class.non_invite).to include @maintainer }
it { expect(described_class.non_invite).not_to include @invited_member }
it { expect(described_class.non_invite).to include @accepted_invite_member }
@@ -144,7 +144,7 @@ describe Member do
it { expect(described_class.non_invite).to include @accepted_request_member }
end
- describe '.request' do
+ describe ".request" do
it { expect(described_class.request).not_to include @maintainer }
it { expect(described_class.request).not_to include @invited_member }
it { expect(described_class.request).not_to include @accepted_invite_member }
@@ -152,7 +152,7 @@ describe Member do
it { expect(described_class.request).not_to include @accepted_request_member }
end
- describe '.non_request' do
+ describe ".non_request" do
it { expect(described_class.non_request).to include @maintainer }
it { expect(described_class.non_request).to include @invited_member }
it { expect(described_class.non_request).to include @accepted_invite_member }
@@ -160,7 +160,7 @@ describe Member do
it { expect(described_class.non_request).to include @accepted_request_member }
end
- describe '.developers' do
+ describe ".developers" do
subject { described_class.developers.to_a }
it { is_expected.not_to include @owner }
@@ -173,7 +173,7 @@ describe Member do
it { is_expected.not_to include @blocked_developer }
end
- describe '.owners_and_maintainers' do
+ describe ".owners_and_maintainers" do
it { expect(described_class.owners_and_maintainers).to include @owner }
it { expect(described_class.owners_and_maintainers).to include @maintainer }
it { expect(described_class.owners_and_maintainers).not_to include @invited_member }
@@ -183,7 +183,7 @@ describe Member do
it { expect(described_class.owners_and_maintainers).not_to include @blocked_maintainer }
end
- describe '.has_access' do
+ describe ".has_access" do
subject { described_class.has_access.to_a }
it { is_expected.to include @owner }
@@ -202,27 +202,27 @@ describe Member do
it { is_expected.to respond_to(:user_email) }
end
- describe '.add_user' do
+ describe ".add_user" do
%w[project group].each do |source_type|
context "when source is a #{source_type}" do
let!(:source) { create(source_type, :public, :access_requestable) }
let!(:user) { create(:user) }
let!(:admin) { create(:admin) }
- it 'returns a <Source>Member object' do
+ it "returns a <Source>Member object" do
member = described_class.add_user(source, user, :maintainer)
expect(member).to be_a "#{source_type.classify}Member".constantize
expect(member).to be_persisted
end
- it 'sets members.created_by to the given current_user' do
+ it "sets members.created_by to the given current_user" do
member = described_class.add_user(source, user, :maintainer, current_user: admin)
expect(member.created_by).to eq(admin)
end
- it 'sets members.expires_at to the given expires_at' do
+ it "sets members.expires_at to the given expires_at" do
member = described_class.add_user(source, user, :maintainer, expires_at: Date.new(2016, 9, 22))
expect(member.expires_at).to eq(Date.new(2016, 9, 22))
@@ -248,9 +248,9 @@ describe Member do
end
end
- context 'with no current_user' do
- context 'when called with a known user id' do
- it 'adds the user as a member' do
+ context "with no current_user" do
+ context "when called with a known user id" do
+ it "adds the user as a member" do
expect(source.users).not_to include(user)
described_class.add_user(source, user.id, :maintainer)
@@ -259,8 +259,8 @@ describe Member do
end
end
- context 'when called with an unknown user id' do
- it 'adds the user as a member' do
+ context "when called with an unknown user id" do
+ it "adds the user as a member" do
expect(source.users).not_to include(user)
described_class.add_user(source, 42, :maintainer)
@@ -269,8 +269,8 @@ describe Member do
end
end
- context 'when called with a user object' do
- it 'adds the user as a member' do
+ context "when called with a user object" do
+ it "adds the user as a member" do
expect(source.users).not_to include(user)
described_class.add_user(source, user, :maintainer)
@@ -279,12 +279,12 @@ describe Member do
end
end
- context 'when called with a requester user object' do
+ context "when called with a requester user object" do
before do
source.request_access(user)
end
- it 'adds the requester as a member' do
+ it "adds the requester as a member" do
expect(source.users).not_to include(user)
expect(source.requesters.exists?(user_id: user)).to be_truthy
@@ -296,8 +296,8 @@ describe Member do
end
end
- context 'when called with a known user email' do
- it 'adds the user as a member' do
+ context "when called with a known user email" do
+ it "adds the user as a member" do
expect(source.users).not_to include(user)
described_class.add_user(source, user.email, :maintainer)
@@ -306,19 +306,19 @@ describe Member do
end
end
- context 'when called with an unknown user email' do
- it 'creates an invited member' do
+ context "when called with an unknown user email" do
+ it "creates an invited member" do
expect(source.users).not_to include(user)
- described_class.add_user(source, 'user@example.com', :maintainer)
+ described_class.add_user(source, "user@example.com", :maintainer)
- expect(source.members.invite.pluck(:invite_email)).to include('user@example.com')
+ expect(source.members.invite.pluck(:invite_email)).to include("user@example.com")
end
end
end
- context 'when current_user can update member' do
- it 'creates the member' do
+ context "when current_user can update member" do
+ it "creates the member" do
expect(source.users).not_to include(user)
described_class.add_user(source, user, :maintainer, current_user: admin)
@@ -326,12 +326,12 @@ describe Member do
expect(source.users.reload).to include(user)
end
- context 'when called with a requester user object' do
+ context "when called with a requester user object" do
before do
source.request_access(user)
end
- it 'adds the requester as a member' do
+ it "adds the requester as a member" do
expect(source.users).not_to include(user)
expect(source.requesters.exists?(user_id: user)).to be_truthy
@@ -343,8 +343,8 @@ describe Member do
end
end
- context 'when current_user cannot update member' do
- it 'does not create the member' do
+ context "when current_user cannot update member" do
+ it "does not create the member" do
expect(source.users).not_to include(user)
member = described_class.add_user(source, user, :maintainer, current_user: user)
@@ -353,12 +353,12 @@ describe Member do
expect(member).not_to be_persisted
end
- context 'when called with a requester user object' do
+ context "when called with a requester user object" do
before do
source.request_access(user)
end
- it 'does not destroy the requester' do
+ it "does not destroy the requester" do
expect(source.users).not_to include(user)
expect(source.requesters.exists?(user_id: user)).to be_truthy
@@ -370,13 +370,13 @@ describe Member do
end
end
- context 'when member already exists' do
+ context "when member already exists" do
before do
source.add_user(user, :developer)
end
- context 'with no current_user' do
- it 'updates the member' do
+ context "with no current_user" do
+ it "updates the member" do
expect(source.users).to include(user)
described_class.add_user(source, user, :maintainer)
@@ -385,8 +385,8 @@ describe Member do
end
end
- context 'when current_user can update member' do
- it 'updates the member' do
+ context "when current_user can update member" do
+ it "updates the member" do
expect(source.users).to include(user)
described_class.add_user(source, user, :maintainer, current_user: admin)
@@ -395,8 +395,8 @@ describe Member do
end
end
- context 'when current_user cannot update member' do
- it 'does not update the member' do
+ context "when current_user cannot update member" do
+ it "does not update the member" do
expect(source.users).to include(user)
described_class.add_user(source, user, :maintainer, current_user: user)
@@ -409,7 +409,7 @@ describe Member do
end
end
- describe '.add_users' do
+ describe ".add_users" do
%w[project group].each do |source_type|
context "when source is a #{source_type}" do
let!(:source) { create(source_type, :public, :access_requestable) }
@@ -417,7 +417,7 @@ describe Member do
let(:user1) { create(:user) }
let(:user2) { create(:user) }
- it 'returns a <Source>Member objects' do
+ it "returns a <Source>Member objects" do
members = described_class.add_users(source, [user1, user2], :maintainer)
expect(members).to be_a Array
@@ -426,15 +426,15 @@ describe Member do
expect(members.first).to be_persisted
end
- it 'returns an empty array' do
+ it "returns an empty array" do
members = described_class.add_users(source, [], :maintainer)
expect(members).to be_a Array
expect(members).to be_empty
end
- it 'supports differents formats' do
- list = ['joe@local.test', admin, user1.id, user2.id.to_s]
+ it "supports differents formats" do
+ list = ["joe@local.test", admin, user1.id, user2.id.to_s]
members = described_class.add_users(source, list, :maintainer)
@@ -445,37 +445,37 @@ describe Member do
end
end
- describe '#accept_request' do
+ describe "#accept_request" do
let(:member) { create(:project_member, requested_at: Time.now.utc) }
it { expect(member.accept_request).to be_truthy }
- it 'clears requested_at' do
+ it "clears requested_at" do
member.accept_request
expect(member.requested_at).to be_nil
end
- it 'calls #after_accept_request' do
+ it "calls #after_accept_request" do
expect(member).to receive(:after_accept_request)
member.accept_request
end
end
- describe '#invite?' do
+ describe "#invite?" do
subject { create(:project_member, invite_email: "user@example.com", user: nil) }
it { is_expected.to be_invite }
end
- describe '#request?' do
+ describe "#request?" do
subject { create(:project_member, requested_at: Time.now.utc) }
it { is_expected.to be_request }
end
- describe '#pending?' do
+ describe "#pending?" do
let(:invited_member) { create(:project_member, invite_email: "user@example.com", user: nil) }
let(:requester) { create(:project_member, requested_at: Time.now.utc) }
diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb
index a3451c67bd8..1fbe0780960 100644
--- a/spec/models/members/group_member_spec.rb
+++ b/spec/models/members/group_member_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupMember do
- describe '.access_level_roles' do
- it 'returns Gitlab::Access.options_with_owner' do
+ describe ".access_level_roles" do
+ it "returns Gitlab::Access.options_with_owner" do
expect(described_class.access_level_roles).to eq(Gitlab::Access.options_with_owner)
end
end
- describe '.access_levels' do
- it 'returns Gitlab::Access.options_with_owner' do
+ describe ".access_levels" do
+ it "returns Gitlab::Access.options_with_owner" do
expect(described_class.access_levels).to eq(Gitlab::Access.sym_options_with_owner)
end
end
- describe '.add_users' do
- it 'adds the given users to the given group' do
+ describe ".add_users" do
+ it "adds the given users to the given group" do
group = create(:group)
users = create_list(:user, 2)
@@ -28,19 +28,19 @@ describe GroupMember do
end
end
- it_behaves_like 'members notifications', :group
+ it_behaves_like "members notifications", :group
- describe '#real_source_type' do
+ describe "#real_source_type" do
subject { create(:group_member).real_source_type }
- it { is_expected.to eq 'Group' }
+ it { is_expected.to eq "Group" }
end
- describe '#update_two_factor_requirement' do
+ describe "#update_two_factor_requirement" do
let(:user) { build :user }
let(:group_member) { build :group_member, user: user }
- it 'is called after creation and deletion' do
+ it "is called after creation and deletion" do
expect(user).to receive(:update_two_factor_requirement)
group_member.save
@@ -51,21 +51,21 @@ describe GroupMember do
end
end
- context 'access levels', :nested_groups do
- context 'with parent group' do
- it_behaves_like 'inherited access level as a member of entity' do
+ context "access levels", :nested_groups do
+ context "with parent group" do
+ it_behaves_like "inherited access level as a member of entity" do
let(:entity) { create(:group, parent: parent_entity) }
end
end
- context 'with parent group and a sub subgroup' do
- it_behaves_like 'inherited access level as a member of entity' do
+ context "with parent group and a sub subgroup" do
+ it_behaves_like "inherited access level as a member of entity" do
let(:subgroup) { create(:group, parent: parent_entity) }
let(:entity) { create(:group, parent: subgroup) }
end
- context 'when only the subgroup has the member' do
- it_behaves_like 'inherited access level as a member of entity' do
+ context "when only the subgroup has the member" do
+ it_behaves_like "inherited access level as a member of entity" do
let(:parent_entity) { create(:group, parent: create(:group)) }
let(:entity) { create(:group, parent: parent_entity) }
end
diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb
index 36bfff2c339..024185d05e1 100644
--- a/spec/models/members/project_member_spec.rb
+++ b/spec/models/members/project_member_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectMember do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project).with_foreign_key(:source_id) }
end
- describe 'validations' do
- it { is_expected.to allow_value('Project').for(:source_type) }
- it { is_expected.not_to allow_value('project').for(:source_type) }
+ describe "validations" do
+ it { is_expected.to allow_value("Project").for(:source_type) }
+ it { is_expected.not_to allow_value("project").for(:source_type) }
it { is_expected.to validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) }
end
- describe '.access_level_roles' do
- it 'returns Gitlab::Access.options' do
+ describe ".access_level_roles" do
+ it "returns Gitlab::Access.options" do
expect(described_class.access_level_roles).to eq(Gitlab::Access.options)
end
end
- describe '.add_user' do
- it 'adds the user as a member' do
+ describe ".add_user" do
+ it "adds the user as a member" do
user = create(:user)
project = create(:project)
@@ -30,10 +30,10 @@ describe ProjectMember do
end
end
- describe '#real_source_type' do
+ describe "#real_source_type" do
subject { create(:project_member).real_source_type }
- it { is_expected.to eq 'Project' }
+ it { is_expected.to eq "Project" }
end
describe "#destroy" do
@@ -53,7 +53,7 @@ describe ProjectMember do
end
end
- describe '.import_team' do
+ describe ".import_team" do
before do
@project_1 = create(:project)
@project_2 = create(:project)
@@ -69,7 +69,7 @@ describe ProjectMember do
it { expect(@status).to be_truthy }
- describe 'project 2 should get user 1 as developer. user_2 should not be changed' do
+ describe "project 2 should get user 1 as developer. user_2 should not be changed" do
it { expect(@project_2.users).to include(@user_1) }
it { expect(@project_2.users).to include(@user_2) }
@@ -77,21 +77,22 @@ describe ProjectMember do
it { expect(Ability.allowed?(@user_2, :read_project, @project_2)).to be_truthy }
end
- describe 'project 1 should not be changed' do
+ describe "project 1 should not be changed" do
it { expect(@project_1.users).to include(@user_1) }
it { expect(@project_1.users).not_to include(@user_2) }
end
end
- describe '.add_users_to_projects' do
- it 'adds the given users to the given projects' do
+ describe ".add_users_to_projects" do
+ it "adds the given users to the given projects" do
projects = create_list(:project, 2)
users = create_list(:user, 2)
described_class.add_users_to_projects(
[projects.first.id, projects.second.id],
[users.first.id, users.second],
- described_class::MAINTAINER)
+ described_class::MAINTAINER
+ )
expect(projects.first.users).to include(users.first)
expect(projects.first.users).to include(users.second)
@@ -101,7 +102,7 @@ describe ProjectMember do
end
end
- describe '.truncate_teams' do
+ describe ".truncate_teams" do
before do
@project_1 = create(:project)
@project_2 = create(:project)
@@ -119,17 +120,17 @@ describe ProjectMember do
it { expect(@project_2.users).to be_empty }
end
- it_behaves_like 'members notifications', :project
+ it_behaves_like "members notifications", :project
- context 'access levels' do
- context 'with parent group' do
- it_behaves_like 'inherited access level as a member of entity' do
+ context "access levels" do
+ context "with parent group" do
+ it_behaves_like "inherited access level as a member of entity" do
let(:entity) { create(:project, group: parent_entity) }
end
end
- context 'with parent group and a subgroup', :nested_groups do
- it_behaves_like 'inherited access level as a member of entity' do
+ context "with parent group and a subgroup", :nested_groups do
+ it_behaves_like "inherited access level as a member of entity" do
let(:subgroup) { create(:group, parent: parent_entity) }
let(:entity) { create(:project, group: subgroup) }
end
diff --git a/spec/models/merge_request/metrics_spec.rb b/spec/models/merge_request/metrics_spec.rb
index 02ff7839739..ed34adbf907 100644
--- a/spec/models/merge_request/metrics_spec.rb
+++ b/spec/models/merge_request/metrics_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequest::Metrics do
subject { described_class.new }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:merge_request) }
- it { is_expected.to belong_to(:latest_closed_by).class_name('User') }
- it { is_expected.to belong_to(:merged_by).class_name('User') }
+ it { is_expected.to belong_to(:latest_closed_by).class_name("User") }
+ it { is_expected.to belong_to(:merged_by).class_name("User") }
end
end
diff --git a/spec/models/merge_request_diff_commit_spec.rb b/spec/models/merge_request_diff_commit_spec.rb
index 10487190a44..b88fe89af34 100644
--- a/spec/models/merge_request_diff_commit_spec.rb
+++ b/spec/models/merge_request_diff_commit_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
+require "rails_helper"
describe MergeRequestDiffCommit do
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
- describe '#to_hash' do
+ describe "#to_hash" do
subject { merge_request.commits.first }
- it 'returns the same results as Commit#to_hash, except for parent_ids' do
+ it "returns the same results as Commit#to_hash, except for parent_ids" do
commit_from_repo = project.repository.commit(subject.sha)
commit_from_repo_hash = commit_from_repo.to_hash.merge(parent_ids: [])
@@ -15,13 +15,13 @@ describe MergeRequestDiffCommit do
end
end
- describe '.create_bulk' do
+ describe ".create_bulk" do
let(:sha_attribute) { Gitlab::Database::ShaAttribute.new }
let(:merge_request_diff_id) { merge_request.merge_request_diff.id }
let(:commits) do
[
- project.commit('5937ac0a7beb003549fc5fd26fc247adbce4a52e'),
- project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
+ project.commit("5937ac0a7beb003549fc5fd26fc247adbce4a52e"),
+ project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d"),
]
end
let(:rows) do
@@ -36,7 +36,7 @@ describe MergeRequestDiffCommit do
"committer_email": "dmitriy.zaporozhets@gmail.com",
"merge_request_diff_id": merge_request_diff_id,
"relative_order": 0,
- "sha": sha_attribute.serialize("5937ac0a7beb003549fc5fd26fc247adbce4a52e")
+ "sha": sha_attribute.serialize("5937ac0a7beb003549fc5fd26fc247adbce4a52e"),
},
{
"message": "Change some files\n\nSigned-off-by: Dmitriy Zaporozhets \u003cdmitriy.zaporozhets@gmail.com\u003e\n",
@@ -48,24 +48,24 @@ describe MergeRequestDiffCommit do
"committer_email": "dmitriy.zaporozhets@gmail.com",
"merge_request_diff_id": merge_request_diff_id,
"relative_order": 1,
- "sha": sha_attribute.serialize("570e7b2abdd848b95f2f578043fc23bd6f6fd24d")
- }
+ "sha": sha_attribute.serialize("570e7b2abdd848b95f2f578043fc23bd6f6fd24d"),
+ },
]
end
subject { described_class.create_bulk(merge_request_diff_id, commits) }
- it 'inserts the commits into the database en masse' do
+ it "inserts the commits into the database en masse" do
expect(Gitlab::Database).to receive(:bulk_insert)
.with(described_class.table_name, rows)
subject
end
- context 'with dates larger than the DB limit' do
+ context "with dates larger than the DB limit" do
let(:commits) do
# This commit's date is "Sun Aug 17 07:12:55 292278994 +0000"
- [project.commit('ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69')]
+ [project.commit("ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69")]
end
let(:timestamp) { Time.at((1 << 31) - 1) }
let(:rows) do
@@ -79,11 +79,11 @@ describe MergeRequestDiffCommit do
"committer_email": "alejorro70@gmail.com",
"merge_request_diff_id": merge_request_diff_id,
"relative_order": 0,
- "sha": sha_attribute.serialize("ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69")
+ "sha": sha_attribute.serialize("ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69"),
}]
end
- it 'uses a sanitized date' do
+ it "uses a sanitized date" do
expect(Gitlab::Database).to receive(:bulk_insert)
.with(described_class.table_name, rows)
diff --git a/spec/models/merge_request_diff_file_spec.rb b/spec/models/merge_request_diff_file_spec.rb
index faa47660a74..9fc1c10af09 100644
--- a/spec/models/merge_request_diff_file_spec.rb
+++ b/spec/models/merge_request_diff_file_spec.rb
@@ -1,33 +1,33 @@
-require 'rails_helper'
+require "rails_helper"
describe MergeRequestDiffFile do
- describe '#diff' do
- let(:unpacked) { 'unpacked' }
- let(:packed) { [unpacked].pack('m0') }
+ describe "#diff" do
+ let(:unpacked) { "unpacked" }
+ let(:packed) { [unpacked].pack("m0") }
before do
subject.diff = packed
end
- context 'when the diff is marked as binary' do
+ context "when the diff is marked as binary" do
before do
subject.binary = true
end
- it 'unpacks from base 64' do
+ it "unpacks from base 64" do
expect(subject.diff).to eq(unpacked)
end
end
- context 'when the diff is not marked as binary' do
- it 'returns the raw diff' do
+ context "when the diff is not marked as binary" do
+ it "returns the raw diff" do
expect(subject.diff).to eq(packed)
end
end
end
- describe '#utf8_diff' do
- it 'does not raise error when the diff is binary' do
+ describe "#utf8_diff" do
+ it "does not raise error when the diff is binary" do
subject.diff = "\x05\x00\x68\x65\x6c\x6c\x6f"
expect { subject.utf8_diff }.not_to raise_error
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index 1849d3bac12..2eba16db01e 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestDiff do
let(:diff_with_commits) { create(:merge_request).merge_request_diff }
- describe 'create new record' do
+ describe "create new record" do
subject { diff_with_commits }
it { expect(subject).to be_valid }
it { expect(subject).to be_persisted }
it { expect(subject.commits.count).to eq(29) }
it { expect(subject.diffs.count).to eq(20) }
- it { expect(subject.head_commit_sha).to eq('b83d6e391c22777fca1ed3012fce84f633d7fed0') }
- it { expect(subject.base_commit_sha).to eq('ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }
- it { expect(subject.start_commit_sha).to eq('0b4bc9a49b562e85de7cc9e834518ea6828729b9') }
+ it { expect(subject.head_commit_sha).to eq("b83d6e391c22777fca1ed3012fce84f633d7fed0") }
+ it { expect(subject.base_commit_sha).to eq("ae73cb07c9eeaf35924a10f713b364d32b2dd34f") }
+ it { expect(subject.start_commit_sha).to eq("0b4bc9a49b562e85de7cc9e834518ea6828729b9") }
end
- describe '.by_commit_sha' do
+ describe ".by_commit_sha" do
subject(:by_commit_sha) { described_class.by_commit_sha(sha) }
let!(:merge_request) { create(:merge_request, :with_diffs) }
- context 'with sha contained in' do
- let(:sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
+ context "with sha contained in" do
+ let(:sha) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
- it 'returns merge request diffs' do
+ it "returns merge request diffs" do
expect(by_commit_sha).to eq([merge_request.merge_request_diff])
end
end
- context 'with sha not contained in' do
- let(:sha) { 'b83d6e3' }
+ context "with sha not contained in" do
+ let(:sha) { "b83d6e3" }
- it 'returns empty result' do
+ it "returns empty result" do
expect(by_commit_sha).to be_empty
end
end
end
- describe '#latest' do
+ describe "#latest" do
let!(:mr) { create(:merge_request, :with_diffs) }
let!(:first_diff) { mr.merge_request_diff }
let!(:last_diff) { mr.create_merge_request_diff }
@@ -46,44 +46,44 @@ describe MergeRequestDiff do
it { expect(first_diff.reload).not_to be_latest }
end
- shared_examples_for 'merge request diffs' do
+ shared_examples_for "merge request diffs" do
let(:merge_request) { create(:merge_request, :with_diffs) }
let!(:diff) { merge_request.merge_request_diff.reload }
- context 'when it was not cleaned by the system' do
- it 'returns persisted diffs' do
+ context "when it was not cleaned by the system" do
+ it "returns persisted diffs" do
expect(diff).to receive(:load_diffs).and_call_original
diff.diffs.diff_files
end
end
- context 'when diff was cleaned by the system' do
+ context "when diff was cleaned by the system" do
before do
diff.clean!
end
- it 'returns diffs from repository if can compare with current diff refs' do
+ it "returns diffs from repository if can compare with current diff refs" do
expect(diff).not_to receive(:load_diffs)
expect(Compare)
.to receive(:new)
.with(instance_of(Gitlab::Git::Compare), merge_request.target_project,
- base_sha: diff.base_commit_sha, straight: false)
+ base_sha: diff.base_commit_sha, straight: false)
.and_call_original
diff.diffs
end
- it 'returns persisted diffs if cannot compare with diff refs' do
+ it "returns persisted diffs if cannot compare with diff refs" do
expect(diff).to receive(:load_diffs).and_call_original
- diff.update!(head_commit_sha: 'invalid-sha')
+ diff.update!(head_commit_sha: "invalid-sha")
diff.diffs.diff_files
end
- it 'returns persisted diffs if diff refs does not exist' do
+ it "returns persisted diffs if diff refs does not exist" do
expect(diff).to receive(:load_diffs).and_call_original
diff.update!(start_commit_sha: nil, base_commit_sha: nil)
@@ -92,9 +92,9 @@ describe MergeRequestDiff do
end
end
- describe '#raw_diffs' do
- context 'when the :ignore_whitespace_change option is set' do
- it 'creates a new compare object instead of using preprocessed data' do
+ describe "#raw_diffs" do
+ context "when the :ignore_whitespace_change option is set" do
+ it "creates a new compare object instead of using preprocessed data" do
expect(diff_with_commits).not_to receive(:load_diffs)
expect(diff_with_commits.compare).to receive(:diffs).and_call_original
@@ -102,38 +102,38 @@ describe MergeRequestDiff do
end
end
- context 'when the raw diffs are empty' do
+ context "when the raw diffs are empty" do
before do
MergeRequestDiffFile.where(merge_request_diff_id: diff_with_commits.id).delete_all
end
- it 'returns an empty DiffCollection' do
+ it "returns an empty DiffCollection" do
expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection)
expect(diff_with_commits.raw_diffs).to be_empty
end
end
- context 'when the raw diffs exist' do
- it 'returns the diffs' do
+ context "when the raw diffs exist" do
+ it "returns the diffs" do
expect(diff_with_commits.raw_diffs).to be_a(Gitlab::Git::DiffCollection)
expect(diff_with_commits.raw_diffs).not_to be_empty
end
- context 'when the :paths option is set' do
- let(:diffs) { diff_with_commits.raw_diffs(paths: ['files/ruby/popen.rb', 'files/ruby/popen.rb']) }
+ context "when the :paths option is set" do
+ let(:diffs) { diff_with_commits.raw_diffs(paths: ["files/ruby/popen.rb", "files/ruby/popen.rb"]) }
- it 'only returns diffs that match the (old path, new path) given' do
- expect(diffs.map(&:new_path)).to contain_exactly('files/ruby/popen.rb')
+ it "only returns diffs that match the (old path, new path) given" do
+ expect(diffs.map(&:new_path)).to contain_exactly("files/ruby/popen.rb")
end
- it 'only serializes diff files found by query' do
+ it "only serializes diff files found by query" do
expect(diff_with_commits.merge_request_diff_files.count).to be > 10
expect_any_instance_of(MergeRequestDiffFile).to receive(:to_hash).once
diffs
end
- it 'uses the preprocessed diffs' do
+ it "uses the preprocessed diffs" do
expect(diff_with_commits).to receive(:load_diffs)
diffs
@@ -142,14 +142,14 @@ describe MergeRequestDiff do
end
end
- describe '#save_diffs' do
- it 'saves collected state' do
+ describe "#save_diffs" do
+ it "saves collected state" do
mr_diff = create(:merge_request).merge_request_diff
expect(mr_diff.collected?).to be_truthy
end
- it 'saves overflow state' do
+ it "saves overflow state" do
allow(Commit).to receive(:max_diff_options)
.and_return(max_lines: 0, max_files: 0)
@@ -158,7 +158,7 @@ describe MergeRequestDiff do
expect(mr_diff.overflow?).to be_truthy
end
- it 'saves empty state' do
+ it "saves empty state" do
allow_any_instance_of(described_class).to receive_message_chain(:compare, :commits)
.and_return([])
@@ -167,16 +167,16 @@ describe MergeRequestDiff do
expect(mr_diff.empty?).to be_truthy
end
- it 'expands collapsed diffs before saving' do
- mr_diff = create(:merge_request, source_branch: 'expand-collapse-lines', target_branch: 'master').merge_request_diff
- diff_file = mr_diff.merge_request_diff_files.find_by(new_path: 'expand-collapse/file-5.txt')
+ it "expands collapsed diffs before saving" do
+ mr_diff = create(:merge_request, source_branch: "expand-collapse-lines", target_branch: "master").merge_request_diff
+ diff_file = mr_diff.merge_request_diff_files.find_by(new_path: "expand-collapse/file-5.txt")
expect(diff_file.diff).not_to be_empty
end
- it 'saves binary diffs correctly' do
- path = 'files/images/icn-time-tracking.pdf'
- mr_diff = create(:merge_request, source_branch: 'add-pdf-text-binary', target_branch: 'master').merge_request_diff
+ it "saves binary diffs correctly" do
+ path = "files/images/icn-time-tracking.pdf"
+ mr_diff = create(:merge_request, source_branch: "add-pdf-text-binary", target_branch: "master").merge_request_diff
diff_file = mr_diff.merge_request_diff_files.find_by(new_path: path)
expect(diff_file).to be_binary
@@ -185,59 +185,59 @@ describe MergeRequestDiff do
end
end
- describe 'internal diffs configured' do
- include_examples 'merge request diffs'
+ describe "internal diffs configured" do
+ include_examples "merge request diffs"
end
- describe 'external diffs configured' do
+ describe "external diffs configured" do
before do
stub_external_diffs_setting(enabled: true)
end
- include_examples 'merge request diffs'
+ include_examples "merge request diffs"
end
- describe '#commit_shas' do
- it 'returns all commit SHAs using commits from the DB' do
+ describe "#commit_shas" do
+ it "returns all commit SHAs using commits from the DB" do
expect(diff_with_commits.commit_shas).not_to be_empty
expect(diff_with_commits.commit_shas).to all(match(/\h{40}/))
end
end
- describe '#compare_with' do
- it 'delegates compare to the service' do
+ describe "#compare_with" do
+ it "delegates compare to the service" do
expect(CompareService).to receive(:new).and_call_original
diff_with_commits.compare_with(nil)
end
- it 'uses git diff A..B approach by default' do
- diffs = diff_with_commits.compare_with('0b4bc9a49b562e85de7cc9e834518ea6828729b9').diffs
+ it "uses git diff A..B approach by default" do
+ diffs = diff_with_commits.compare_with("0b4bc9a49b562e85de7cc9e834518ea6828729b9").diffs
expect(diffs.size).to eq(21)
end
end
- describe '#commits_count' do
- it 'returns number of commits using serialized commits' do
+ describe "#commits_count" do
+ it "returns number of commits using serialized commits" do
expect(diff_with_commits.commits_count).to eq(29)
end
end
- describe '#commits_by_shas' do
+ describe "#commits_by_shas" do
let(:commit_shas) { diff_with_commits.commit_shas }
- it 'returns empty if no SHAs were provided' do
+ it "returns empty if no SHAs were provided" do
expect(diff_with_commits.commits_by_shas([])).to be_empty
end
- it 'returns one SHA' do
+ it "returns one SHA" do
commits = diff_with_commits.commits_by_shas([commit_shas.first, Gitlab::Git::BLANK_SHA])
expect(commits.count).to eq(1)
end
- it 'returns all matching SHAs' do
+ it "returns all matching SHAs" do
commits = diff_with_commits.commits_by_shas(commit_shas)
expect(commits.count).to eq(commit_shas.count)
@@ -245,7 +245,7 @@ describe MergeRequestDiff do
end
end
- describe '#modified_paths' do
+ describe "#modified_paths" do
subject do
diff = create(:merge_request_diff)
create(:merge_request_diff_file, :new_file, merge_request_diff: diff)
@@ -253,24 +253,24 @@ describe MergeRequestDiff do
diff
end
- it 'returns affected file paths' do
- expect(subject.modified_paths).to eq(%w{foo bar baz})
+ it "returns affected file paths" do
+ expect(subject.modified_paths).to eq(%w[foo bar baz])
end
end
- describe '#opening_external_diff' do
+ describe "#opening_external_diff" do
subject(:diff) { diff_with_commits }
- context 'external diffs disabled' do
+ context "external diffs disabled" do
it { expect(diff.external_diff).not_to be_exists }
- it 'yields nil' do
+ it "yields nil" do
expect { |b| diff.opening_external_diff(&b) }.to yield_with_args(nil)
end
end
- context 'external diffs enabled' do
- let(:test_dir) { 'tmp/tests/external-diffs' }
+ context "external diffs enabled" do
+ let(:test_dir) { "tmp/tests/external-diffs" }
around do |example|
FileUtils.mkdir_p(test_dir)
@@ -288,19 +288,19 @@ describe MergeRequestDiff do
it { expect(diff.external_diff).to be_exists }
- it 'yields an open file' do
+ it "yields an open file" do
expect { |b| diff.opening_external_diff(&b) }.to yield_with_args(File)
end
- it 'is re-entrant' do
+ it "is re-entrant" do
outer_file_a =
- diff.opening_external_diff do |outer_file|
+ diff.opening_external_diff { |outer_file|
diff.opening_external_diff do |inner_file|
expect(outer_file).to eq(inner_file)
end
outer_file
- end
+ }
diff.opening_external_diff do |outer_file_b|
expect(outer_file_a).not_to eq(outer_file_b)
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index 82a853a23b9..d00dc178886 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequest do
include RepoHelpers
@@ -7,29 +7,29 @@ describe MergeRequest do
subject { create(:merge_request) }
- describe 'associations' do
- it { is_expected.to belong_to(:target_project).class_name('Project') }
- it { is_expected.to belong_to(:source_project).class_name('Project') }
+ describe "associations" do
+ it { is_expected.to belong_to(:target_project).class_name("Project") }
+ it { is_expected.to belong_to(:source_project).class_name("Project") }
it { is_expected.to belong_to(:merge_user).class_name("User") }
it { is_expected.to belong_to(:assignee) }
it { is_expected.to have_many(:merge_request_diffs) }
- context 'for forks' do
+ context "for forks" do
let!(:project) { create(:project) }
let!(:fork) { fork_project(project) }
let!(:merge_request) { create(:merge_request, target_project: project, source_project: fork) }
- it 'does not load another project due to inverse relationship' do
+ it "does not load another project due to inverse relationship" do
expect(project.merge_requests.first.target_project.object_id).to eq(project.object_id)
end
- it 'finds the associated merge request' do
+ it "finds the associated merge request" do
expect(project.merge_requests.find(merge_request.id)).to eq(merge_request)
end
end
end
- describe '#squash_in_progress?' do
+ describe "#squash_in_progress?" do
let(:repo_path) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
subject.source_project.repository.path
@@ -38,51 +38,51 @@ describe MergeRequest do
let(:squash_path) { File.join(repo_path, "gitlab-worktree", "squash-#{subject.id}") }
before do
- system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{squash_path} master))
+ system(Gitlab.config.git.bin_path.to_s, "-C", repo_path.to_s, "worktree", "add", "--detach", squash_path.to_s, "master")
end
- it 'returns true when there is a current squash directory' do
+ it "returns true when there is a current squash directory" do
expect(subject.squash_in_progress?).to be_truthy
end
- it 'returns false when there is no squash directory' do
+ it "returns false when there is no squash directory" do
FileUtils.rm_rf(squash_path)
expect(subject.squash_in_progress?).to be_falsey
end
- it 'returns false when the squash directory has expired' do
+ it "returns false when the squash directory has expired" do
time = 20.minutes.ago.to_time
File.utime(time, time, squash_path)
expect(subject.squash_in_progress?).to be_falsey
end
- it 'returns false when the source project has been removed' do
+ it "returns false when the source project has been removed" do
allow(subject).to receive(:source_project).and_return(nil)
expect(subject.squash_in_progress?).to be_falsey
end
end
- describe '#squash?' do
+ describe "#squash?" do
let(:merge_request) { build(:merge_request, squash: squash) }
subject { merge_request.squash? }
- context 'disabled in database' do
+ context "disabled in database" do
let(:squash) { false }
it { is_expected.to be_falsy }
end
- context 'enabled in database' do
+ context "enabled in database" do
let(:squash) { true }
it { is_expected.to be_truthy }
end
end
- describe '#default_squash_commit_message' do
+ describe "#default_squash_commit_message" do
let(:project) { subject.project }
def commit_collection(commit_hashes)
@@ -91,11 +91,11 @@ describe MergeRequest do
CommitCollection.new(project, raw_commits)
end
- it 'returns the oldest multiline commit message' do
+ it "returns the oldest multiline commit message" do
commits = commit_collection([
- { message: 'Singleline', parent_ids: [] },
- { message: "Second multiline\nCommit message", parent_ids: [] },
- { message: "First multiline\nCommit message", parent_ids: [] }
+ {message: "Singleline", parent_ids: []},
+ {message: "Second multiline\nCommit message", parent_ids: []},
+ {message: "First multiline\nCommit message", parent_ids: []},
])
expect(subject).to receive(:commits).and_return(commits)
@@ -103,9 +103,9 @@ describe MergeRequest do
expect(subject.default_squash_commit_message).to eq("First multiline\nCommit message")
end
- it 'returns the merge request title if there are no multiline commits' do
+ it "returns the merge request title if there are no multiline commits" do
commits = commit_collection([
- { message: 'Singleline', parent_ids: [] }
+ {message: "Singleline", parent_ids: []},
])
expect(subject).to receive(:commits).and_return(commits)
@@ -114,7 +114,7 @@ describe MergeRequest do
end
end
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Issuable) }
@@ -122,16 +122,16 @@ describe MergeRequest do
it { is_expected.to include_module(Sortable) }
it { is_expected.to include_module(Taskable) }
- it_behaves_like 'AtomicInternalId' do
+ it_behaves_like "AtomicInternalId" do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:merge_request) }
let(:scope) { :target_project }
- let(:scope_attrs) { { project: instance.target_project } }
+ let(:scope_attrs) { {project: instance.target_project} }
let(:usage) { :merge_requests }
end
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:target_branch) }
it { is_expected.to validate_presence_of(:source_branch) }
@@ -153,12 +153,12 @@ describe MergeRequest do
end
end
- context 'for forks' do
+ context "for forks" do
let(:project) { create(:project) }
let(:fork1) { fork_project(project) }
let(:fork2) { fork_project(project) }
- it 'allows merge requests for sibling-forks' do
+ it "allows merge requests for sibling-forks" do
subject.source_project = fork1
subject.target_project = fork2
@@ -167,16 +167,16 @@ describe MergeRequest do
end
end
- describe 'callbacks' do
- describe '#ensure_merge_request_metrics' do
- it 'creates metrics after saving' do
+ describe "callbacks" do
+ describe "#ensure_merge_request_metrics" do
+ it "creates metrics after saving" do
merge_request = create(:merge_request)
expect(merge_request.metrics).to be_persisted
expect(MergeRequest::Metrics.count).to eq(1)
end
- it 'does not duplicate metrics for a merge request' do
+ it "does not duplicate metrics for a merge request" do
merge_request = create(:merge_request)
merge_request.mark_as_merged!
@@ -186,7 +186,7 @@ describe MergeRequest do
end
end
- describe 'respond to' do
+ describe "respond to" do
it { is_expected.to respond_to(:unchecked?) }
it { is_expected.to respond_to(:can_be_merged?) }
it { is_expected.to respond_to(:cannot_be_merged?) }
@@ -194,52 +194,52 @@ describe MergeRequest do
it { is_expected.to respond_to(:merge_when_pipeline_succeeds) }
end
- describe '.by_commit_sha' do
+ describe ".by_commit_sha" do
subject(:by_commit_sha) { described_class.by_commit_sha(sha) }
let!(:merge_request) { create(:merge_request, :with_diffs) }
- context 'with sha contained in latest merge request diff' do
- let(:sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
+ context "with sha contained in latest merge request diff" do
+ let(:sha) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
- it 'returns merge requests' do
+ it "returns merge requests" do
expect(by_commit_sha).to eq([merge_request])
end
end
- context 'with sha contained not in latest merge request diff' do
- let(:sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
+ context "with sha contained not in latest merge request diff" do
+ let(:sha) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
- it 'returns empty requests' do
+ it "returns empty requests" do
latest_merge_request_diff = merge_request.merge_request_diffs.create
- latest_merge_request_diff.merge_request_diff_commits.where(sha: 'b83d6e391c22777fca1ed3012fce84f633d7fed0').delete_all
+ latest_merge_request_diff.merge_request_diff_commits.where(sha: "b83d6e391c22777fca1ed3012fce84f633d7fed0").delete_all
expect(by_commit_sha).to be_empty
end
end
- context 'with sha not contained in' do
- let(:sha) { 'b83d6e3' }
+ context "with sha not contained in" do
+ let(:sha) { "b83d6e3" }
- it 'returns empty result' do
+ it "returns empty result" do
expect(by_commit_sha).to be_empty
end
end
end
- describe '.in_projects' do
- it 'returns the merge requests for a set of projects' do
+ describe ".in_projects" do
+ it "returns the merge requests for a set of projects" do
expect(described_class.in_projects(Project.all)).to eq([subject])
end
end
- describe '.set_latest_merge_request_diff_ids!' do
+ describe ".set_latest_merge_request_diff_ids!" do
def create_merge_request_with_diffs(source_branch, diffs: 2)
params = {
target_project: project,
- target_branch: 'master',
+ target_branch: "master",
source_project: project,
- source_branch: source_branch
+ source_branch: source_branch,
}
create(:merge_request, params).tap do |mr|
@@ -249,105 +249,105 @@ describe MergeRequest do
let(:project) { create(:project) }
- it 'sets IDs for merge requests, whether they are already set or not' do
+ it "sets IDs for merge requests, whether they are already set or not" do
merge_requests = [
- create_merge_request_with_diffs('feature'),
- create_merge_request_with_diffs('feature-conflict'),
- create_merge_request_with_diffs('wip', diffs: 0),
- create_merge_request_with_diffs('csv')
+ create_merge_request_with_diffs("feature"),
+ create_merge_request_with_diffs("feature-conflict"),
+ create_merge_request_with_diffs("wip", diffs: 0),
+ create_merge_request_with_diffs("csv"),
]
merge_requests.take(2).each do |merge_request|
merge_request.update_column(:latest_merge_request_diff_id, nil)
end
- expected = merge_requests.map do |merge_request|
+ expected = merge_requests.map { |merge_request|
merge_request.merge_request_diffs.maximum(:id)
- end
+ }
expect { project.merge_requests.set_latest_merge_request_diff_ids! }
.to change { merge_requests.map { |mr| mr.reload.latest_merge_request_diff_id } }.to(expected)
end
end
- describe '#target_branch_sha' do
+ describe "#target_branch_sha" do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project, target_project: project) }
- context 'when the target branch does not exist' do
+ context "when the target branch does not exist" do
before do
project.repository.rm_branch(subject.author, subject.target_branch)
subject.clear_memoized_shas
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.target_branch_sha).to be_nil
end
end
- it 'returns memoized value' do
- subject.target_branch_sha = '8ffb3c15a5475e59ae909384297fede4badcb4c7'
+ it "returns memoized value" do
+ subject.target_branch_sha = "8ffb3c15a5475e59ae909384297fede4badcb4c7"
- expect(subject.target_branch_sha).to eq '8ffb3c15a5475e59ae909384297fede4badcb4c7'
+ expect(subject.target_branch_sha).to eq "8ffb3c15a5475e59ae909384297fede4badcb4c7"
end
end
- describe '#card_attributes' do
- it 'includes the author name' do
- allow(subject).to receive(:author).and_return(double(name: 'Robert'))
+ describe "#card_attributes" do
+ it "includes the author name" do
+ allow(subject).to receive(:author).and_return(double(name: "Robert"))
allow(subject).to receive(:assignee).and_return(nil)
expect(subject.card_attributes)
- .to eq({ 'Author' => 'Robert', 'Assignee' => nil })
+ .to eq({"Author" => "Robert", "Assignee" => nil})
end
- it 'includes the assignee name' do
- allow(subject).to receive(:author).and_return(double(name: 'Robert'))
- allow(subject).to receive(:assignee).and_return(double(name: 'Douwe'))
+ it "includes the assignee name" do
+ allow(subject).to receive(:author).and_return(double(name: "Robert"))
+ allow(subject).to receive(:assignee).and_return(double(name: "Douwe"))
expect(subject.card_attributes)
- .to eq({ 'Author' => 'Robert', 'Assignee' => 'Douwe' })
+ .to eq({"Author" => "Robert", "Assignee" => "Douwe"})
end
end
- describe '#assignee_ids' do
- it 'returns an array of the assigned user id' do
+ describe "#assignee_ids" do
+ it "returns an array of the assigned user id" do
subject.assignee_id = 123
expect(subject.assignee_ids).to eq([123])
end
end
- describe '#assignee_ids=' do
- it 'sets assignee_id to the last id in the array' do
+ describe "#assignee_ids=" do
+ it "sets assignee_id to the last id in the array" do
subject.assignee_ids = [123, 456]
expect(subject.assignee_id).to eq(456)
end
end
- describe '#assignee_or_author?' do
+ describe "#assignee_or_author?" do
let(:user) { create(:user) }
- it 'returns true for a user that is assigned to a merge request' do
+ it "returns true for a user that is assigned to a merge request" do
subject.assignee = user
expect(subject.assignee_or_author?(user)).to eq(true)
end
- it 'returns true for a user that is the author of a merge request' do
+ it "returns true for a user that is the author of a merge request" do
subject.author = user
expect(subject.assignee_or_author?(user)).to eq(true)
end
- it 'returns false for a user that is not the assignee or author' do
+ it "returns false for a user that is not the assignee or author" do
expect(subject.assignee_or_author?(user)).to eq(false)
end
end
- describe '#visible_closing_issues_for' do
+ describe "#visible_closing_issues_for" do
let(:guest) { create(:user) }
let(:developer) { create(:user) }
let(:issue_1) { create(:issue, project: subject.source_project) }
@@ -357,11 +357,11 @@ describe MergeRequest do
before do
subject.project.add_developer(subject.author)
subject.target_branch = subject.project.default_branch
- commit = double('commit1', safe_message: "Fixes #{issue_1.to_reference} #{issue_2.to_reference} #{confidential_issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue_1.to_reference} #{issue_2.to_reference} #{confidential_issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
end
- it 'shows only allowed issues to guest' do
+ it "shows only allowed issues to guest" do
subject.project.add_guest(guest)
subject.cache_merge_request_closes_issues!
@@ -369,7 +369,7 @@ describe MergeRequest do
expect(subject.visible_closing_issues_for(guest)).to match_array([issue_1, issue_2])
end
- it 'shows only allowed issues to developer' do
+ it "shows only allowed issues to developer" do
subject.project.add_developer(developer)
subject.cache_merge_request_closes_issues!
@@ -377,13 +377,13 @@ describe MergeRequest do
expect(subject.visible_closing_issues_for(developer)).to match_array([issue_1, confidential_issue, issue_2])
end
- context 'when external issue tracker is enabled' do
+ context "when external issue tracker is enabled" do
before do
subject.project.has_external_issue_tracker = true
subject.project.save!
end
- it 'calls non #closes_issues to retrieve data' do
+ it "calls non #closes_issues to retrieve data" do
expect(subject).to receive(:closes_issues)
expect(subject).not_to receive(:cached_closes_issues)
@@ -392,23 +392,23 @@ describe MergeRequest do
end
end
- describe '#cache_merge_request_closes_issues!' do
+ describe "#cache_merge_request_closes_issues!" do
before do
subject.project.add_developer(subject.author)
subject.target_branch = subject.project.default_branch
end
- it 'caches closed issues' do
+ it "caches closed issues" do
issue = create :issue, project: subject.project
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }.to change(subject.merge_requests_closing_issues, :count).by(1)
end
- it 'does not cache closed issues when merge request is closed' do
+ it "does not cache closed issues when merge request is closed" do
issue = create :issue, project: subject.project
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
allow(subject).to receive(:state).and_return("closed")
@@ -416,25 +416,25 @@ describe MergeRequest do
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count)
end
- it 'does not cache closed issues when merge request is merged' do
+ it "does not cache closed issues when merge request is merged" do
issue = create :issue, project: subject.project
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
allow(subject).to receive(:state).and_return("merged")
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count)
end
- context 'when both internal and external issue trackers are enabled' do
+ context "when both internal and external issue trackers are enabled" do
before do
subject.project.has_external_issue_tracker = true
subject.project.save!
create(:jira_service, project: subject.project)
end
- it 'does not cache issues from external trackers' do
- issue = ExternalIssue.new('JIRA-123', subject.project)
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ it "does not cache issues from external trackers" do
+ issue = ExternalIssue.new("JIRA-123", subject.project)
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
@@ -442,9 +442,9 @@ describe MergeRequest do
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count)
end
- it 'caches an internal issue' do
+ it "caches an internal issue" do
issue = create(:issue, project: subject.project)
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }
@@ -452,24 +452,24 @@ describe MergeRequest do
end
end
- context 'when only external issue tracker enabled' do
+ context "when only external issue tracker enabled" do
before do
subject.project.has_external_issue_tracker = true
subject.project.issues_enabled = false
subject.project.save!
end
- it 'does not cache issues from external trackers' do
- issue = ExternalIssue.new('JIRA-123', subject.project)
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ it "does not cache issues from external trackers" do
+ issue = ExternalIssue.new("JIRA-123", subject.project)
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }.not_to change(subject.merge_requests_closing_issues, :count)
end
- it 'does not cache an internal issue' do
+ it "does not cache an internal issue" do
issue = create(:issue, project: subject.project)
- commit = double('commit1', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit1", safe_message: "Fixes #{issue.to_reference}")
allow(subject).to receive(:commits).and_return([commit])
expect { subject.cache_merge_request_closes_issues!(subject.author) }
@@ -478,30 +478,30 @@ describe MergeRequest do
end
end
- describe '#source_branch_sha' do
+ describe "#source_branch_sha" do
let(:last_branch_commit) { subject.source_project.repository.commit(Gitlab::Git::BRANCH_REF_PREFIX + subject.source_branch) }
- context 'with diffs' do
+ context "with diffs" do
subject { create(:merge_request, :with_diffs) }
- it 'returns the sha of the source branch last commit' do
+ it "returns the sha of the source branch last commit" do
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
end
end
- context 'without diffs' do
+ context "without diffs" do
subject { create(:merge_request, :without_diffs) }
- it 'returns the sha of the source branch last commit' do
+ it "returns the sha of the source branch last commit" do
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
end
- context 'when there is a tag name matching the branch name' do
+ context "when there is a tag name matching the branch name" do
let(:tag_name) { subject.source_branch }
- it 'returns the sha of the source branch last commit' do
+ it "returns the sha of the source branch last commit" do
subject.source_project.repository.add_tag(subject.author,
- tag_name,
- subject.target_branch_sha,
- 'Add a tag')
+ tag_name,
+ subject.target_branch_sha,
+ "Add a tag")
expect(subject.source_branch_sha).to eq(last_branch_commit.sha)
@@ -510,44 +510,44 @@ describe MergeRequest do
end
end
- context 'when the merge request is being created' do
+ context "when the merge request is being created" do
subject { build(:merge_request, source_branch: nil, compare_commits: []) }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.source_branch_sha).to be_nil
end
end
- it 'returns memoized value' do
- subject.source_branch_sha = '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b'
+ it "returns memoized value" do
+ subject.source_branch_sha = "2e5d3239642f9161dcbbc4b70a211a68e5e45e2b"
- expect(subject.source_branch_sha).to eq '2e5d3239642f9161dcbbc4b70a211a68e5e45e2b'
+ expect(subject.source_branch_sha).to eq "2e5d3239642f9161dcbbc4b70a211a68e5e45e2b"
end
end
- describe '#to_reference' do
- let(:project) { build(:project, name: 'sample-project') }
+ describe "#to_reference" do
+ let(:project) { build(:project, name: "sample-project") }
let(:merge_request) { build(:merge_request, target_project: project, iid: 1) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(merge_request.to_reference).to eq "!1"
end
- it 'supports a cross-project reference' do
- another_project = build(:project, name: 'another-project', namespace: project.namespace)
+ it "supports a cross-project reference" do
+ another_project = build(:project, name: "another-project", namespace: project.namespace)
expect(merge_request.to_reference(another_project)).to eq "sample-project!1"
end
- it 'returns a String reference with the full path' do
- expect(merge_request.to_reference(full: true)).to eq(project.full_path + '!1')
+ it "returns a String reference with the full path" do
+ expect(merge_request.to_reference(full: true)).to eq(project.full_path + "!1")
end
end
- describe '#raw_diffs' do
+ describe "#raw_diffs" do
let(:merge_request) { build(:merge_request) }
- let(:options) { { paths: ['a/b', 'b/a', 'c/*'] } }
+ let(:options) { {paths: ["a/b", "b/a", "c/*"]} }
- context 'when there are MR diffs' do
- it 'delegates to the MR diffs' do
+ context "when there are MR diffs" do
+ it "delegates to the MR diffs" do
merge_request.merge_request_diff = MergeRequestDiff.new
expect(merge_request.merge_request_diff).to receive(:raw_diffs).with(options)
@@ -556,8 +556,8 @@ describe MergeRequest do
end
end
- context 'when there are no MR diffs' do
- it 'delegates to the compare object' do
+ context "when there are no MR diffs" do
+ it "delegates to the compare object" do
merge_request.compare = double(:compare)
expect(merge_request.compare).to receive(:raw_diffs).with(options)
@@ -567,12 +567,12 @@ describe MergeRequest do
end
end
- describe '#diffs' do
+ describe "#diffs" do
let(:merge_request) { build(:merge_request) }
- let(:options) { { paths: ['a/b', 'b/a', 'c/*'] } }
+ let(:options) { {paths: ["a/b", "b/a", "c/*"]} }
- context 'when there are MR diffs' do
- it 'delegates to the MR diffs' do
+ context "when there are MR diffs" do
+ it "delegates to the MR diffs" do
merge_request.save
expect(merge_request.merge_request_diff).to receive(:raw_diffs).with(hash_including(options)).and_call_original
@@ -581,8 +581,8 @@ describe MergeRequest do
end
end
- context 'when there are no MR diffs' do
- it 'delegates to the compare object, setting expanded: true' do
+ context "when there are no MR diffs" do
+ it "delegates to the compare object, setting expanded: true" do
merge_request.compare = double(:compare)
expect(merge_request.compare).to receive(:diffs).with(options.merge(expanded: true))
@@ -592,10 +592,10 @@ describe MergeRequest do
end
end
- describe '#preload_discussions_diff_highlight' do
+ describe "#preload_discussions_diff_highlight" do
let(:merge_request) { create(:merge_request) }
- context 'with commit diff note' do
+ context "with commit diff note" do
let(:other_merge_request) { create(:merge_request) }
let!(:diff_note) do
@@ -606,7 +606,7 @@ describe MergeRequest do
create(:diff_note_on_commit, project: other_merge_request.project)
end
- it 'preloads diff highlighting' do
+ it "preloads diff highlighting" do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = diff_note.note_diff_file
@@ -619,7 +619,7 @@ describe MergeRequest do
end
end
- context 'with merge request diff note' do
+ context "with merge request diff note" do
let!(:unresolved_diff_note) do
create(:diff_note_on_merge_request, project: merge_request.project, noteable: merge_request)
end
@@ -628,7 +628,7 @@ describe MergeRequest do
create(:diff_note_on_merge_request, :resolved, project: merge_request.project, noteable: merge_request)
end
- it 'preloads diff highlighting' do
+ it "preloads diff highlighting" do
expect_next_instance_of(Gitlab::DiscussionsDiff::FileCollection) do |collection|
note_diff_file = unresolved_diff_note.note_diff_file
@@ -643,26 +643,26 @@ describe MergeRequest do
end
end
- describe '#diff_size' do
+ describe "#diff_size" do
let(:merge_request) do
- build(:merge_request, source_branch: 'expand-collapse-files', target_branch: 'master')
+ build(:merge_request, source_branch: "expand-collapse-files", target_branch: "master")
end
- context 'when there are MR diffs' do
- it 'returns the correct count' do
+ context "when there are MR diffs" do
+ it "returns the correct count" do
merge_request.save
- expect(merge_request.diff_size).to eq('105')
+ expect(merge_request.diff_size).to eq("105")
end
- it 'returns the correct overflow count' do
+ it "returns the correct overflow count" do
allow(Commit).to receive(:max_diff_options).and_return(max_files: 2)
merge_request.save
- expect(merge_request.diff_size).to eq('2+')
+ expect(merge_request.diff_size).to eq("2+")
end
- it 'does not perform highlighting' do
+ it "does not perform highlighting" do
merge_request.save
expect(Gitlab::Diff::Highlight).not_to receive(:new)
@@ -671,7 +671,7 @@ describe MergeRequest do
end
end
- context 'when there are no MR diffs' do
+ context "when there are no MR diffs" do
def set_compare(merge_request)
merge_request.compare = CompareService.new(
merge_request.source_project,
@@ -682,20 +682,20 @@ describe MergeRequest do
)
end
- it 'returns the correct count' do
+ it "returns the correct count" do
set_compare(merge_request)
- expect(merge_request.diff_size).to eq('105')
+ expect(merge_request.diff_size).to eq("105")
end
- it 'returns the correct overflow count' do
+ it "returns the correct overflow count" do
allow(Commit).to receive(:max_diff_options).and_return(max_files: 2)
set_compare(merge_request)
- expect(merge_request.diff_size).to eq('2+')
+ expect(merge_request.diff_size).to eq("2+")
end
- it 'does not perform highlighting' do
+ it "does not perform highlighting" do
set_compare(merge_request)
expect(Gitlab::Diff::Highlight).not_to receive(:new)
@@ -705,7 +705,7 @@ describe MergeRequest do
end
end
- describe '#modified_paths' do
+ describe "#modified_paths" do
let(:paths) { double(:paths) }
subject(:merge_request) { build(:merge_request) }
@@ -713,31 +713,31 @@ describe MergeRequest do
expect(diff).to receive(:modified_paths).and_return(paths)
end
- context 'when past_merge_request_diff is specified' do
+ context "when past_merge_request_diff is specified" do
let(:another_diff) { double(:merge_request_diff) }
let(:diff) { another_diff }
- it 'returns affected file paths from specified past_merge_request_diff' do
+ it "returns affected file paths from specified past_merge_request_diff" do
expect(merge_request.modified_paths(past_merge_request_diff: another_diff)).to eq(paths)
end
end
- context 'when compare is present' do
+ context "when compare is present" do
let(:compare) { double(:compare) }
let(:diff) { compare }
- it 'returns affected file paths from compare' do
+ it "returns affected file paths from compare" do
merge_request.compare = compare
expect(merge_request.modified_paths).to eq(paths)
end
end
- context 'when no arguments provided' do
+ context "when no arguments provided" do
let(:diff) { merge_request.merge_request_diff }
- subject(:merge_request) { create(:merge_request, source_branch: 'feature', target_branch: 'master') }
+ subject(:merge_request) { create(:merge_request, source_branch: "feature", target_branch: "master") }
- it 'returns affected file paths for merge_request_diff' do
+ it "returns affected file paths for merge_request_diff" do
expect(merge_request.modified_paths).to eq(paths)
end
end
@@ -767,33 +767,33 @@ describe MergeRequest do
end
end
- describe '#for_fork?' do
- it 'returns true if the merge request is for a fork' do
+ describe "#for_fork?" do
+ it "returns true if the merge request is for a fork" do
subject.source_project = build_stubbed(:project, namespace: create(:group))
subject.target_project = build_stubbed(:project, namespace: create(:group))
expect(subject.for_fork?).to be_truthy
end
- it 'returns false if is not for a fork' do
+ it "returns false if is not for a fork" do
expect(subject.for_fork?).to be_falsey
end
end
- describe '#closes_issues' do
+ describe "#closes_issues" do
let(:issue0) { create :issue, project: subject.project }
let(:issue1) { create :issue, project: subject.project }
- let(:commit0) { double('commit0', safe_message: "Fixes #{issue0.to_reference}") }
- let(:commit1) { double('commit1', safe_message: "Fixes #{issue0.to_reference}") }
- let(:commit2) { double('commit2', safe_message: "Fixes #{issue1.to_reference}") }
+ let(:commit0) { double("commit0", safe_message: "Fixes #{issue0.to_reference}") }
+ let(:commit1) { double("commit1", safe_message: "Fixes #{issue0.to_reference}") }
+ let(:commit2) { double("commit2", safe_message: "Fixes #{issue1.to_reference}") }
before do
subject.project.add_developer(subject.author)
allow(subject).to receive(:commits).and_return([commit0, commit1, commit2])
end
- it 'accesses the set of issues that will be closed on acceptance' do
+ it "accesses the set of issues that will be closed on acceptance" do
allow(subject.project).to receive(:default_branch)
.and_return(subject.target_branch)
@@ -802,21 +802,21 @@ describe MergeRequest do
expect(closed).to include(issue0, issue1)
end
- it 'only lists issues as to be closed if it targets the default branch' do
- allow(subject.project).to receive(:default_branch).and_return('master')
- subject.target_branch = 'something-else'
+ it "only lists issues as to be closed if it targets the default branch" do
+ allow(subject.project).to receive(:default_branch).and_return("master")
+ subject.target_branch = "something-else"
expect(subject.closes_issues).to be_empty
end
end
- describe '#issues_mentioned_but_not_closing' do
+ describe "#issues_mentioned_but_not_closing" do
let(:closing_issue) { create :issue, project: subject.project }
let(:mentioned_issue) { create :issue, project: subject.project }
- let(:commit) { double('commit', safe_message: "Fixes #{closing_issue.to_reference}") }
+ let(:commit) { double("commit", safe_message: "Fixes #{closing_issue.to_reference}") }
- it 'detects issues mentioned in description but not closed' do
+ it "detects issues mentioned in description but not closed" do
subject.project.add_developer(subject.author)
subject.description = "Is related to #{mentioned_issue.to_reference} and #{closing_issue.to_reference}"
@@ -828,28 +828,28 @@ describe MergeRequest do
expect(subject.issues_mentioned_but_not_closing(subject.author)).to match_array([mentioned_issue])
end
- context 'when the project has an external issue tracker' do
+ context "when the project has an external issue tracker" do
before do
subject.project.add_developer(subject.author)
- commit = double(:commit, safe_message: 'Fixes TEST-3')
+ commit = double(:commit, safe_message: "Fixes TEST-3")
create(:jira_service, project: subject.project)
allow(subject).to receive(:commits).and_return([commit])
- allow(subject).to receive(:description).and_return('Is related to TEST-2 and TEST-3')
+ allow(subject).to receive(:description).and_return("Is related to TEST-2 and TEST-3")
allow(subject.project).to receive(:default_branch).and_return(subject.target_branch)
end
- it 'detects issues mentioned in description but not closed' do
+ it "detects issues mentioned in description but not closed" do
subject.cache_merge_request_closes_issues!
- expect(subject.issues_mentioned_but_not_closing(subject.author).map(&:to_s)).to match_array(['TEST-2'])
+ expect(subject.issues_mentioned_but_not_closing(subject.author).map(&:to_s)).to match_array(["TEST-2"])
end
end
end
describe "#work_in_progress?" do
- ['WIP ', 'WIP:', 'WIP: ', '[WIP]', '[WIP] ', ' [WIP] WIP [WIP] WIP: WIP '].each do |wip_prefix|
+ ["WIP ", "WIP:", "WIP: ", "[WIP]", "[WIP] ", " [WIP] WIP [WIP] WIP: WIP "].each do |wip_prefix|
it "detects the '#{wip_prefix}' prefix" do
subject.title = "#{wip_prefix}#{subject.title}"
expect(subject.work_in_progress?).to eq true
@@ -872,7 +872,7 @@ describe MergeRequest do
end
describe "#wipless_title" do
- ['WIP ', 'WIP:', 'WIP: ', '[WIP]', '[WIP] ', '[WIP] WIP [WIP] WIP: WIP '].each do |wip_prefix|
+ ["WIP ", "WIP:", "WIP: ", "[WIP]", "[WIP] ", "[WIP] WIP [WIP] WIP: WIP "].each do |wip_prefix|
it "removes the '#{wip_prefix}' prefix" do
wipless_title = subject.title
subject.title = "#{wip_prefix}#{subject.title}"
@@ -911,7 +911,7 @@ describe MergeRequest do
end
end
- describe '#can_remove_source_branch?' do
+ describe "#can_remove_source_branch?" do
set(:user) { create(:user) }
set(:merge_request) { create(:merge_request, :simple) }
@@ -928,7 +928,7 @@ describe MergeRequest do
end
it "can't remove a root ref" do
- subject.update(source_branch: 'master', target_branch: 'feature')
+ subject.update(source_branch: "master", target_branch: "feature")
expect(subject.can_remove_source_branch?(user)).to be_falsey
end
@@ -953,22 +953,22 @@ describe MergeRequest do
end
end
- describe '#default_merge_commit_message' do
- it 'includes merge information as the title' do
- request = build(:merge_request, source_branch: 'source', target_branch: 'target')
+ describe "#default_merge_commit_message" do
+ it "includes merge information as the title" do
+ request = build(:merge_request, source_branch: "source", target_branch: "target")
expect(request.default_merge_commit_message)
.to match("Merge branch 'source' into 'target'\n\n")
end
- it 'includes its title in the body' do
- request = build(:merge_request, title: 'Remove all technical debt')
+ it "includes its title in the body" do
+ request = build(:merge_request, title: "Remove all technical debt")
expect(request.default_merge_commit_message)
.to match("Remove all technical debt\n\n")
end
- it 'includes its closed issues in the body' do
+ it "includes its closed issues in the body" do
issue = create(:issue, project: subject.project)
subject.project.add_developer(subject.author)
@@ -980,28 +980,28 @@ describe MergeRequest do
.to match("Closes #{issue.to_reference}")
end
- it 'includes its reference in the body' do
+ it "includes its reference in the body" do
request = build_stubbed(:merge_request)
expect(request.default_merge_commit_message)
.to match("See merge request #{request.to_reference(full: true)}")
end
- it 'excludes multiple linebreak runs when description is blank' do
- request = build(:merge_request, title: 'Title', description: nil)
+ it "excludes multiple linebreak runs when description is blank" do
+ request = build(:merge_request, title: "Title", description: nil)
expect(request.default_merge_commit_message).not_to match("Title\n\n\n\n")
end
- it 'includes its description in the body' do
- request = build(:merge_request, description: 'By removing all code')
+ it "includes its description in the body" do
+ request = build(:merge_request, description: "By removing all code")
expect(request.default_merge_commit_message(include_description: true))
.to match("By removing all code\n\n")
end
- it 'does not includes its description in the body' do
- request = build(:merge_request, description: 'By removing all code')
+ it "does not includes its description in the body" do
+ request = build(:merge_request, description: "By removing all code")
expect(request.default_merge_commit_message)
.not_to match("By removing all code\n\n")
@@ -1011,7 +1011,7 @@ describe MergeRequest do
describe "#reset_merge_when_pipeline_succeeds" do
let(:merge_if_green) do
create :merge_request, merge_when_pipeline_succeeds: true, merge_user: create(:user),
- merge_params: { "should_remove_source_branch" => "1", "commit_message" => "msg" }
+ merge_params: {"should_remove_source_branch" => "1", "commit_message" => "msg"}
end
it "sets the item to false" do
@@ -1024,36 +1024,36 @@ describe MergeRequest do
end
end
- describe '#commit_authors' do
- it 'returns all the authors of every commit in the merge request' do
- users = subject.commits.map(&:author_email).uniq.map do |email|
+ describe "#commit_authors" do
+ it "returns all the authors of every commit in the merge request" do
+ users = subject.commits.map(&:author_email).uniq.map { |email|
create(:user, email: email)
- end
+ }
expect(subject.commit_authors).to match_array(users)
end
- it 'returns an empty array if no author is associated with a user' do
+ it "returns an empty array if no author is associated with a user" do
expect(subject.commit_authors).to be_empty
end
end
- describe '#authors' do
- it 'returns a list with all the commit authors in the merge request and author' do
- users = subject.commits.map(&:author_email).uniq.map do |email|
+ describe "#authors" do
+ it "returns a list with all the commit authors in the merge request and author" do
+ users = subject.commits.map(&:author_email).uniq.map { |email|
create(:user, email: email)
- end
+ }
expect(subject.authors).to match_array([subject.author, *users])
end
- it 'returns only the author if no committer is associated with a user' do
+ it "returns only the author if no committer is associated with a user" do
expect(subject.authors).to contain_exactly(subject.author)
end
end
- describe '#hook_attrs' do
- it 'delegates to Gitlab::HookData::MergeRequestBuilder#build' do
+ describe "#hook_attrs" do
+ it "delegates to Gitlab::HookData::MergeRequestBuilder#build" do
builder = double
expect(Gitlab::HookData::MergeRequestBuilder)
@@ -1064,11 +1064,11 @@ describe MergeRequest do
end
end
- describe '#diverged_commits_count' do
+ describe "#diverged_commits_count" do
let(:project) { create(:project, :repository) }
let(:forked_project) { fork_project(project, nil, repository: true) }
- context 'when the target branch does not exist anymore' do
+ context "when the target branch does not exist anymore" do
subject { create(:merge_request, source_project: project, target_project: project) }
before do
@@ -1076,45 +1076,45 @@ describe MergeRequest do
subject.clear_memoized_shas
end
- it 'does not crash' do
+ it "does not crash" do
expect { subject.diverged_commits_count }.not_to raise_error
end
- it 'returns 0' do
+ it "returns 0" do
expect(subject.diverged_commits_count).to eq(0)
end
end
- context 'diverged on same repository' do
+ context "diverged on same repository" do
subject(:merge_request_with_divergence) { create(:merge_request, :diverged, source_project: project, target_project: project) }
- it 'counts commits that are on target branch but not on source branch' do
+ it "counts commits that are on target branch but not on source branch" do
expect(subject.diverged_commits_count).to eq(29)
end
end
- context 'diverged on fork' do
+ context "diverged on fork" do
subject(:merge_request_fork_with_divergence) { create(:merge_request, :diverged, source_project: forked_project, target_project: project) }
- it 'counts commits that are on target branch but not on source branch' do
+ it "counts commits that are on target branch but not on source branch" do
expect(subject.diverged_commits_count).to eq(29)
end
end
- context 'rebased on fork' do
+ context "rebased on fork" do
subject(:merge_request_rebased) { create(:merge_request, :rebased, source_project: forked_project, target_project: project) }
- it 'counts commits that are on target branch but not on source branch' do
+ it "counts commits that are on target branch but not on source branch" do
expect(subject.diverged_commits_count).to eq(0)
end
end
- describe 'caching' do
+ describe "caching" do
before do
allow(Rails).to receive(:cache).and_return(ActiveSupport::Cache::MemoryStore.new)
end
- it 'caches the output' do
+ it "caches the output" do
expect(subject).to receive(:compute_diverged_commits_count)
.once
.and_return(2)
@@ -1123,64 +1123,64 @@ describe MergeRequest do
subject.diverged_commits_count
end
- it 'invalidates the cache when the source sha changes' do
+ it "invalidates the cache when the source sha changes" do
expect(subject).to receive(:compute_diverged_commits_count)
.twice
.and_return(2)
subject.diverged_commits_count
- allow(subject).to receive(:source_branch_sha).and_return('123abc')
+ allow(subject).to receive(:source_branch_sha).and_return("123abc")
subject.diverged_commits_count
end
- it 'invalidates the cache when the target sha changes' do
+ it "invalidates the cache when the target sha changes" do
expect(subject).to receive(:compute_diverged_commits_count)
.twice
.and_return(2)
subject.diverged_commits_count
- allow(subject).to receive(:target_branch_sha).and_return('123abc')
+ allow(subject).to receive(:target_branch_sha).and_return("123abc")
subject.diverged_commits_count
end
end
end
- it_behaves_like 'an editable mentionable' do
+ it_behaves_like "an editable mentionable" do
subject { create(:merge_request, :simple) }
let(:backref_text) { "merge request #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt) { subject.description = txt } }
end
- it_behaves_like 'a Taskable' do
+ it_behaves_like "a Taskable" do
subject { create :merge_request, :simple }
end
- describe '#commit_shas' do
+ describe "#commit_shas" do
before do
allow(subject.merge_request_diff).to receive(:commit_shas)
- .and_return(['sha1'])
+ .and_return(["sha1"])
end
- it 'delegates to merge request diff' do
- expect(subject.commit_shas).to eq ['sha1']
+ it "delegates to merge request diff" do
+ expect(subject.commit_shas).to eq ["sha1"]
end
end
- context 'head pipeline' do
+ context "head pipeline" do
before do
- allow(subject).to receive(:diff_head_sha).and_return('lastsha')
+ allow(subject).to receive(:diff_head_sha).and_return("lastsha")
end
- describe '#head_pipeline' do
- it 'returns nil for MR without head_pipeline_id' do
+ describe "#head_pipeline" do
+ it "returns nil for MR without head_pipeline_id" do
subject.update_attribute(:head_pipeline_id, nil)
expect(subject.head_pipeline).to be_nil
end
- context 'when the source project does not exist' do
- it 'returns nil' do
+ context "when the source project does not exist" do
+ it "returns nil" do
allow(subject).to receive(:source_project).and_return(nil)
expect(subject.head_pipeline).to be_nil
@@ -1188,23 +1188,23 @@ describe MergeRequest do
end
end
- describe '#actual_head_pipeline' do
- it 'returns nil for MR with old pipeline' do
- pipeline = create(:ci_empty_pipeline, sha: 'notlatestsha')
+ describe "#actual_head_pipeline" do
+ it "returns nil for MR with old pipeline" do
+ pipeline = create(:ci_empty_pipeline, sha: "notlatestsha")
subject.update_attribute(:head_pipeline_id, pipeline.id)
expect(subject.actual_head_pipeline).to be_nil
end
- it 'returns the pipeline for MR with recent pipeline' do
- pipeline = create(:ci_empty_pipeline, sha: 'lastsha')
+ it "returns the pipeline for MR with recent pipeline" do
+ pipeline = create(:ci_empty_pipeline, sha: "lastsha")
subject.update_attribute(:head_pipeline_id, pipeline.id)
expect(subject.actual_head_pipeline).to eq(subject.head_pipeline)
expect(subject.actual_head_pipeline).to eq(pipeline)
end
- it 'returns nil when source project does not exist' do
+ it "returns nil when source project does not exist" do
allow(subject).to receive(:source_project).and_return(nil)
expect(subject.actual_head_pipeline).to be_nil
@@ -1212,12 +1212,12 @@ describe MergeRequest do
end
end
- describe '#merge_pipeline' do
- it 'returns nil when not merged' do
+ describe "#merge_pipeline" do
+ it "returns nil when not merged" do
expect(subject.merge_pipeline).to be_nil
end
- context 'when the MR is merged' do
+ context "when the MR is merged" do
let(:sha) { subject.target_project.commit.id }
let(:pipeline) { create(:ci_empty_pipeline, sha: sha, ref: subject.target_branch, project: subject.target_project) }
@@ -1226,17 +1226,17 @@ describe MergeRequest do
subject.update_attribute(:merge_commit_sha, pipeline.sha)
end
- it 'returns the post-merge pipeline' do
+ it "returns the post-merge pipeline" do
expect(subject.merge_pipeline).to eq(pipeline)
end
end
end
- describe '#has_ci?' do
+ describe "#has_ci?" do
let(:merge_request) { build_stubbed(:merge_request) }
- context 'has ci' do
- it 'returns true if MR has head_pipeline_id and commits' do
+ context "has ci" do
+ it "returns true if MR has head_pipeline_id and commits" do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil }
allow(merge_request).to receive(:head_pipeline_id) { double }
allow(merge_request).to receive(:has_no_commits?) { false }
@@ -1244,7 +1244,7 @@ describe MergeRequest do
expect(merge_request.has_ci?).to be(true)
end
- it 'returns true if MR has any pipeline and commits' do
+ it "returns true if MR has any pipeline and commits" do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil }
allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:has_no_commits?) { false }
@@ -1253,7 +1253,7 @@ describe MergeRequest do
expect(merge_request.has_ci?).to be(true)
end
- it 'returns true if MR has CI service and commits' do
+ it "returns true if MR has CI service and commits" do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { double }
allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:has_no_commits?) { false }
@@ -1263,8 +1263,8 @@ describe MergeRequest do
end
end
- context 'has no ci' do
- it 'returns false if MR has no CI service nor pipeline, and no commits' do
+ context "has no ci" do
+ it "returns false if MR has no CI service nor pipeline, and no commits" do
allow(merge_request).to receive_message_chain(:source_project, :ci_service) { nil }
allow(merge_request).to receive(:head_pipeline_id) { nil }
allow(merge_request).to receive(:all_pipelines) { [] }
@@ -1275,77 +1275,77 @@ describe MergeRequest do
end
end
- describe '#all_pipelines' do
- shared_examples 'returning pipelines with proper ordering' do
+ describe "#all_pipelines" do
+ shared_examples "returning pipelines with proper ordering" do
let!(:all_pipelines) do
subject.all_commit_shas.map do |sha|
create(:ci_empty_pipeline,
- project: subject.source_project,
- sha: sha,
- ref: subject.source_branch)
+ project: subject.source_project,
+ sha: sha,
+ ref: subject.source_branch)
end
end
- it 'returns all pipelines' do
+ it "returns all pipelines" do
expect(subject.all_pipelines).not_to be_empty
expect(subject.all_pipelines).to eq(all_pipelines.reverse)
end
end
- context 'with single merge_request_diffs' do
- it_behaves_like 'returning pipelines with proper ordering'
+ context "with single merge_request_diffs" do
+ it_behaves_like "returning pipelines with proper ordering"
end
- context 'with multiple irrelevant merge_request_diffs' do
+ context "with multiple irrelevant merge_request_diffs" do
before do
- subject.update(target_branch: 'v1.0.0')
+ subject.update(target_branch: "v1.0.0")
end
- it_behaves_like 'returning pipelines with proper ordering'
+ it_behaves_like "returning pipelines with proper ordering"
end
- context 'with unsaved merge request' do
+ context "with unsaved merge request" do
subject { build(:merge_request) }
let!(:pipeline) do
create(:ci_empty_pipeline,
- project: subject.project,
- sha: subject.diff_head_sha,
- ref: subject.source_branch)
+ project: subject.project,
+ sha: subject.diff_head_sha,
+ ref: subject.source_branch)
end
- it 'returns pipelines from diff_head_sha' do
+ it "returns pipelines from diff_head_sha" do
expect(subject.all_pipelines).to contain_exactly(pipeline)
end
end
- context 'when pipelines exist for the branch and merge request' do
- let(:source_ref) { 'feature' }
- let(:target_ref) { 'master' }
+ context "when pipelines exist for the branch and merge request" do
+ let(:source_ref) { "feature" }
+ let(:target_ref) { "master" }
let!(:branch_pipeline) do
create(:ci_pipeline,
- source: :push,
- project: project,
- ref: source_ref,
- sha: shas.second)
+ source: :push,
+ project: project,
+ ref: source_ref,
+ sha: shas.second)
end
let!(:merge_request_pipeline) do
create(:ci_pipeline,
- source: :merge_request,
- project: project,
- ref: source_ref,
- sha: shas.second,
- merge_request: merge_request)
+ source: :merge_request,
+ project: project,
+ ref: source_ref,
+ sha: shas.second,
+ merge_request: merge_request)
end
let(:merge_request) do
create(:merge_request,
- source_project: project,
- source_branch: source_ref,
- target_project: project,
- target_branch: target_ref)
+ source_project: project,
+ source_branch: source_ref,
+ target_project: project,
+ target_branch: target_ref)
end
let(:project) { create(:project, :repository) }
@@ -1355,114 +1355,114 @@ describe MergeRequest do
allow(merge_request).to receive(:all_commit_shas) { shas }
end
- it 'returns merge request pipeline first' do
+ it "returns merge request pipeline first" do
expect(merge_request.all_pipelines)
.to eq([merge_request_pipeline,
- branch_pipeline])
+ branch_pipeline,])
end
- context 'when there are a branch pipeline and a merge request pipeline' do
+ context "when there are a branch pipeline and a merge request pipeline" do
let!(:branch_pipeline_2) do
create(:ci_pipeline,
- source: :push,
- project: project,
- ref: source_ref,
- sha: shas.first)
+ source: :push,
+ project: project,
+ ref: source_ref,
+ sha: shas.first)
end
let!(:merge_request_pipeline_2) do
create(:ci_pipeline,
- source: :merge_request,
- project: project,
- ref: source_ref,
- sha: shas.first,
- merge_request: merge_request)
+ source: :merge_request,
+ project: project,
+ ref: source_ref,
+ sha: shas.first,
+ merge_request: merge_request)
end
- it 'returns merge request pipelines first' do
+ it "returns merge request pipelines first" do
expect(merge_request.all_pipelines)
.to eq([merge_request_pipeline_2,
merge_request_pipeline,
branch_pipeline_2,
- branch_pipeline])
+ branch_pipeline,])
end
end
- context 'when there are multiple merge request pipelines from the same branch' do
+ context "when there are multiple merge request pipelines from the same branch" do
let!(:branch_pipeline_2) do
create(:ci_pipeline,
- source: :push,
- project: project,
- ref: source_ref,
- sha: shas.first)
+ source: :push,
+ project: project,
+ ref: source_ref,
+ sha: shas.first)
end
let!(:merge_request_pipeline_2) do
create(:ci_pipeline,
- source: :merge_request,
- project: project,
- ref: source_ref,
- sha: shas.first,
- merge_request: merge_request_2)
+ source: :merge_request,
+ project: project,
+ ref: source_ref,
+ sha: shas.first,
+ merge_request: merge_request_2)
end
let(:merge_request_2) do
create(:merge_request,
- source_project: project,
- source_branch: source_ref,
- target_project: project,
- target_branch: 'stable')
+ source_project: project,
+ source_branch: source_ref,
+ target_project: project,
+ target_branch: "stable")
end
before do
allow(merge_request_2).to receive(:all_commit_shas) { shas }
end
- it 'returns only related merge request pipelines' do
+ it "returns only related merge request pipelines" do
expect(merge_request.all_pipelines)
.to eq([merge_request_pipeline,
branch_pipeline_2,
- branch_pipeline])
+ branch_pipeline,])
expect(merge_request_2.all_pipelines)
.to eq([merge_request_pipeline_2,
branch_pipeline_2,
- branch_pipeline])
+ branch_pipeline,])
end
end
end
end
- describe '#update_head_pipeline' do
+ describe "#update_head_pipeline" do
subject { merge_request.update_head_pipeline }
let(:merge_request) { create(:merge_request) }
- context 'when there is a pipeline with the diff head sha' do
+ context "when there is a pipeline with the diff head sha" do
let!(:pipeline) do
create(:ci_empty_pipeline,
- project: merge_request.project,
- sha: merge_request.diff_head_sha,
- ref: merge_request.source_branch)
+ project: merge_request.project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch)
end
- it 'updates the head pipeline' do
+ it "updates the head pipeline" do
expect { subject }
.to change { merge_request.reload.head_pipeline }
.from(nil).to(pipeline)
end
- context 'when merge request has already had head pipeline' do
+ context "when merge request has already had head pipeline" do
before do
merge_request.update!(head_pipeline: pipeline)
end
- context 'when failed to find an actual head pipeline' do
+ context "when failed to find an actual head pipeline" do
before do
allow(merge_request).to receive(:find_actual_head_pipeline) { }
end
- it 'does not update the current head pipeline' do
+ it "does not update the current head pipeline" do
expect { subject }
.not_to change { merge_request.reload.head_pipeline }
end
@@ -1470,49 +1470,49 @@ describe MergeRequest do
end
end
- context 'when there are no pipelines with the diff head sha' do
- it 'does not update the head pipeline' do
+ context "when there are no pipelines with the diff head sha" do
+ it "does not update the head pipeline" do
expect { subject }
.not_to change { merge_request.reload.head_pipeline }
end
end
end
- describe '#has_test_reports?' do
+ describe "#has_test_reports?" do
subject { merge_request.has_test_reports? }
let(:project) { create(:project, :repository) }
- context 'when head pipeline has test reports' do
+ context "when head pipeline has test reports" do
let(:merge_request) { create(:merge_request, :with_test_reports, source_project: project) }
it { is_expected.to be_truthy }
end
- context 'when head pipeline does not have test reports' do
+ context "when head pipeline does not have test reports" do
let(:merge_request) { create(:merge_request, source_project: project) }
it { is_expected.to be_falsey }
end
end
- describe '#calculate_reactive_cache' do
+ describe "#calculate_reactive_cache" do
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
subject { merge_request.calculate_reactive_cache(service_class_name) }
- context 'when given an unknown service class name' do
- let(:service_class_name) { 'Integer' }
+ context "when given an unknown service class name" do
+ let(:service_class_name) { "Integer" }
- it 'raises a NameError exception' do
+ it "raises a NameError exception" do
expect { subject }.to raise_error(NameError, service_class_name)
end
end
- context 'when given a known service class name' do
- let(:service_class_name) { 'Ci::CompareTestReportsService' }
+ context "when given a known service class name" do
+ let(:service_class_name) { "Ci::CompareTestReportsService" }
- it 'does not raises a NameError exception' do
+ it "does not raises a NameError exception" do
allow_any_instance_of(service_class_name.constantize).to receive(:execute).and_return(nil)
expect { subject }.not_to raise_error
@@ -1520,7 +1520,7 @@ describe MergeRequest do
end
end
- describe '#compare_test_reports' do
+ describe "#compare_test_reports" do
subject { merge_request.compare_test_reports }
let(:project) { create(:project, :repository) }
@@ -1528,176 +1528,176 @@ describe MergeRequest do
let!(:base_pipeline) do
create(:ci_pipeline,
- :with_test_reports,
- project: project,
- ref: merge_request.target_branch,
- sha: merge_request.diff_base_sha)
+ :with_test_reports,
+ project: project,
+ ref: merge_request.target_branch,
+ sha: merge_request.diff_base_sha)
end
before do
merge_request.update!(head_pipeline_id: head_pipeline.id)
end
- context 'when head pipeline has test reports' do
+ context "when head pipeline has test reports" do
let!(:head_pipeline) do
create(:ci_pipeline,
- :with_test_reports,
- project: project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha)
+ :with_test_reports,
+ project: project,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha)
end
- context 'when reactive cache worker is parsing asynchronously' do
- it 'returns status' do
+ context "when reactive cache worker is parsing asynchronously" do
+ it "returns status" do
expect(subject[:status]).to eq(:parsing)
end
end
- context 'when reactive cache worker is inline' do
+ context "when reactive cache worker is inline" do
before do
synchronous_reactive_cache(merge_request)
end
- it 'returns status and data' do
+ it "returns status and data" do
expect_any_instance_of(Ci::CompareTestReportsService)
.to receive(:execute).with(base_pipeline, head_pipeline).and_call_original
subject
end
- context 'when cached results is not latest' do
+ context "when cached results is not latest" do
before do
allow_any_instance_of(Ci::CompareTestReportsService)
.to receive(:latest?).and_return(false)
end
- it 'raises and InvalidateReactiveCache error' do
+ it "raises and InvalidateReactiveCache error" do
expect { subject }.to raise_error(ReactiveCaching::InvalidateReactiveCache)
end
end
end
end
- context 'when head pipeline does not have test reports' do
+ context "when head pipeline does not have test reports" do
let!(:head_pipeline) do
create(:ci_pipeline,
- project: project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha)
+ project: project,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha)
end
- it 'returns status and error message' do
+ it "returns status and error message" do
expect(subject[:status]).to eq(:error)
- expect(subject[:status_reason]).to eq('This merge request does not have test reports')
+ expect(subject[:status_reason]).to eq("This merge request does not have test reports")
end
end
end
- describe '#all_commit_shas' do
- context 'when merge request is persisted' do
+ describe "#all_commit_shas" do
+ context "when merge request is persisted" do
let(:all_commit_shas) do
subject.merge_request_diffs.flat_map(&:commits).map(&:sha).uniq
end
- shared_examples 'returning all SHA' do
- it 'returns all SHAs from all merge_request_diffs' do
+ shared_examples "returning all SHA" do
+ it "returns all SHAs from all merge_request_diffs" do
expect(subject.merge_request_diffs.size).to eq(2)
expect(subject.all_commit_shas).to match_array(all_commit_shas)
end
end
- context 'with a completely different branch' do
+ context "with a completely different branch" do
before do
- subject.update(target_branch: 'csv')
+ subject.update(target_branch: "csv")
end
- it_behaves_like 'returning all SHA'
+ it_behaves_like "returning all SHA"
end
- context 'with a branch having no difference' do
+ context "with a branch having no difference" do
before do
- subject.update(target_branch: 'branch-merged')
+ subject.update(target_branch: "branch-merged")
subject.reload # make sure commits were not cached
end
- it_behaves_like 'returning all SHA'
+ it_behaves_like "returning all SHA"
end
end
- context 'when merge request is not persisted' do
- context 'when compare commits are set in the service' do
- let(:commit) { spy('commit') }
+ context "when merge request is not persisted" do
+ context "when compare commits are set in the service" do
+ let(:commit) { spy("commit") }
subject do
build(:merge_request, compare_commits: [commit, commit])
end
- it 'returns commits from compare commits temporary data' do
+ it "returns commits from compare commits temporary data" do
expect(subject.all_commit_shas).to eq [commit, commit]
end
end
- context 'when compare commits are not set in the service' do
+ context "when compare commits are not set in the service" do
subject { build(:merge_request) }
- it 'returns array with diff head sha element only' do
+ it "returns array with diff head sha element only" do
expect(subject.all_commit_shas).to eq [subject.diff_head_sha]
end
end
end
end
- describe '#short_merge_commit_sha' do
+ describe "#short_merge_commit_sha" do
let(:merge_request) { build_stubbed(:merge_request) }
- it 'returns short id when there is a merge_commit_sha' do
- merge_request.merge_commit_sha = 'f7ce827c314c9340b075657fd61c789fb01cf74d'
+ it "returns short id when there is a merge_commit_sha" do
+ merge_request.merge_commit_sha = "f7ce827c314c9340b075657fd61c789fb01cf74d"
- expect(merge_request.short_merge_commit_sha).to eq('f7ce827c')
+ expect(merge_request.short_merge_commit_sha).to eq("f7ce827c")
end
- it 'returns nil when there is no merge_commit_sha' do
+ it "returns nil when there is no merge_commit_sha" do
merge_request.merge_commit_sha = nil
expect(merge_request.short_merge_commit_sha).to be_nil
end
end
- describe '#can_be_reverted?' do
- context 'when there is no merge_commit for the MR' do
+ describe "#can_be_reverted?" do
+ context "when there is no merge_commit for the MR" do
before do
subject.metrics.update!(merged_at: Time.now.utc)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.can_be_reverted?(nil)).to be_falsey
end
end
- context 'when the MR has been merged' do
+ context "when the MR has been merged" do
before do
MergeRequests::MergeService
.new(subject.target_project, subject.author)
.execute(subject)
end
- context 'when there is no revert commit' do
- it 'returns true' do
+ context "when there is no revert commit" do
+ it "returns true" do
expect(subject.can_be_reverted?(nil)).to be_truthy
end
end
- context 'when there is no merged_at for the MR' do
+ context "when there is no merged_at for the MR" do
before do
subject.metrics.update!(merged_at: nil)
end
- it 'returns true' do
+ it "returns true" do
expect(subject.can_be_reverted?(nil)).to be_truthy
end
end
- context 'when there is a revert commit' do
+ context "when there is a revert commit" do
let(:current_user) { subject.author }
let(:branch) { subject.target_branch }
let(:project) { subject.target_project }
@@ -1706,7 +1706,7 @@ describe MergeRequest do
params = {
commit: subject.merge_commit,
branch_name: branch,
- start_branch: branch
+ start_branch: branch,
}
Commits::RevertService.new(project, current_user, params).execute[:result]
@@ -1716,53 +1716,53 @@ describe MergeRequest do
project.add_maintainer(current_user)
ProcessCommitWorker.new.perform(project.id,
- current_user.id,
- project.commit(revert_commit_id).to_hash,
- project.default_branch == branch)
+ current_user.id,
+ project.commit(revert_commit_id).to_hash,
+ project.default_branch == branch)
end
- context 'but merged at timestamp cannot be found' do
+ context "but merged at timestamp cannot be found" do
before do
allow(subject).to receive(:merged_at) { nil }
end
- it 'returns false' do
+ it "returns false" do
expect(subject.can_be_reverted?(current_user)).to be_falsey
end
end
- context 'when the revert commit is mentioned in a note after the MR was merged' do
- it 'returns false' do
+ context "when the revert commit is mentioned in a note after the MR was merged" do
+ it "returns false" do
expect(subject.can_be_reverted?(current_user)).to be_falsey
end
end
- context 'when there is no merged_at for the MR' do
+ context "when there is no merged_at for the MR" do
before do
subject.metrics.update!(merged_at: nil)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.can_be_reverted?(current_user)).to be_falsey
end
end
- context 'when the revert commit is mentioned in a note just before the MR was merged' do
+ context "when the revert commit is mentioned in a note just before the MR was merged" do
before do
subject.notes.last.update!(created_at: subject.metrics.merged_at - 30.seconds)
end
- it 'returns false' do
+ it "returns false" do
expect(subject.can_be_reverted?(current_user)).to be_falsey
end
end
- context 'when the revert commit is mentioned in a note long before the MR was merged' do
+ context "when the revert commit is mentioned in a note long before the MR was merged" do
before do
subject.notes.last.update!(created_at: subject.metrics.merged_at - 2.minutes)
end
- it 'returns true' do
+ it "returns true" do
expect(subject.can_be_reverted?(current_user)).to be_truthy
end
end
@@ -1770,28 +1770,28 @@ describe MergeRequest do
end
end
- describe '#merged_at' do
- context 'when MR is not merged' do
+ describe "#merged_at" do
+ context "when MR is not merged" do
let(:merge_request) { create(:merge_request, :closed) }
- it 'returns nil' do
+ it "returns nil" do
expect(merge_request.merged_at).to be_nil
end
end
- context 'when metrics has merged_at data' do
+ context "when metrics has merged_at data" do
let(:merge_request) { create(:merge_request, :merged) }
before do
merge_request.metrics.update!(merged_at: 1.day.ago)
end
- it 'returns metrics merged_at' do
+ it "returns metrics merged_at" do
expect(merge_request.merged_at).to eq(merge_request.metrics.merged_at)
end
end
- context 'when merged event is persisted, but no metrics merged_at is persisted' do
+ context "when merged event is persisted, but no metrics merged_at is persisted" do
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, :merged) }
@@ -1799,13 +1799,13 @@ describe MergeRequest do
EventCreateService.new.merge_mr(merge_request, user)
end
- it 'returns merged event creation date' do
+ it "returns merged event creation date" do
expect(merge_request.merge_event).to be_persisted
expect(merge_request.merged_at).to eq(merge_request.merge_event.created_at)
end
end
- context 'when merging note is persisted, but no metrics or merge event exists' do
+ context "when merging note is persisted, but no metrics or merge event exists" do
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, :merged) }
@@ -1813,12 +1813,12 @@ describe MergeRequest do
merge_request.metrics.destroy!
SystemNoteService.change_status(merge_request,
- merge_request.target_project,
- user,
- merge_request.state, nil)
+ merge_request.target_project,
+ user,
+ merge_request.state, nil)
end
- it 'returns merging note creation date' do
+ it "returns merging note creation date" do
expect(merge_request.reload.metrics).to be_nil
expect(merge_request.merge_event).to be_nil
expect(merge_request.notes.count).to eq(1)
@@ -1827,7 +1827,7 @@ describe MergeRequest do
end
end
- describe '#participants' do
+ describe "#participants" do
let(:project) { create(:project, :public) }
let(:mr) do
@@ -1835,24 +1835,24 @@ describe MergeRequest do
end
let!(:note1) do
- create(:note_on_merge_request, noteable: mr, project: project, note: 'a')
+ create(:note_on_merge_request, noteable: mr, project: project, note: "a")
end
let!(:note2) do
- create(:note_on_merge_request, noteable: mr, project: project, note: 'b')
+ create(:note_on_merge_request, noteable: mr, project: project, note: "b")
end
- it 'includes the merge request author' do
+ it "includes the merge request author" do
expect(mr.participants).to include(mr.author)
end
- it 'includes the authors of the notes' do
+ it "includes the authors of the notes" do
expect(mr.participants).to include(note1.author, note2.author)
end
end
- describe 'cached counts' do
- it 'updates when assignees change' do
+ describe "cached counts" do
+ it "updates when assignees change" do
user1 = create(:user)
user2 = create(:user)
mr = create(:merge_request, assignee: user1)
@@ -1870,12 +1870,12 @@ describe MergeRequest do
end
end
- describe '#merge_async' do
- it 'enqueues MergeWorker job and updates merge_jid' do
+ describe "#merge_async" do
+ it "enqueues MergeWorker job and updates merge_jid" do
merge_request = create(:merge_request)
user_id = double(:user_id)
params = {}
- merge_jid = 'hash-123'
+ merge_jid = "hash-123"
expect(MergeWorker).to receive(:perform_async).with(merge_request.id, user_id, params) do
merge_jid
@@ -1887,69 +1887,69 @@ describe MergeRequest do
end
end
- describe '#check_if_can_be_merged' do
+ describe "#check_if_can_be_merged" do
let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true) }
- shared_examples 'checking if can be merged' do
- context 'when it is not broken and has no conflicts' do
+ shared_examples "checking if can be merged" do
+ context "when it is not broken and has no conflicts" do
before do
allow(subject).to receive(:broken?) { false }
allow(project.repository).to receive(:can_be_merged?).and_return(true)
end
- it 'is marked as mergeable' do
- expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to('can_be_merged')
+ it "is marked as mergeable" do
+ expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to("can_be_merged")
end
end
- context 'when broken' do
+ context "when broken" do
before do
allow(subject).to receive(:broken?) { true }
allow(project.repository).to receive(:can_be_merged?).and_return(false)
end
- it 'becomes unmergeable' do
- expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to('cannot_be_merged')
+ it "becomes unmergeable" do
+ expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to("cannot_be_merged")
end
end
- context 'when it has conflicts' do
+ context "when it has conflicts" do
before do
allow(subject).to receive(:broken?) { false }
allow(project.repository).to receive(:can_be_merged?).and_return(false)
end
- it 'becomes unmergeable' do
- expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to('cannot_be_merged')
+ it "becomes unmergeable" do
+ expect { subject.check_if_can_be_merged }.to change { subject.merge_status }.to("cannot_be_merged")
end
end
end
- context 'when merge_status is unchecked' do
+ context "when merge_status is unchecked" do
subject { create(:merge_request, source_project: project, merge_status: :unchecked) }
- it_behaves_like 'checking if can be merged'
+ it_behaves_like "checking if can be merged"
end
- context 'when merge_status is unchecked' do
+ context "when merge_status is unchecked" do
subject { create(:merge_request, source_project: project, merge_status: :cannot_be_merged_recheck) }
- it_behaves_like 'checking if can be merged'
+ it_behaves_like "checking if can be merged"
end
end
- describe '#mergeable?' do
+ describe "#mergeable?" do
let(:project) { create(:project) }
subject { create(:merge_request, source_project: project) }
- it 'returns false if #mergeable_state? is false' do
+ it "returns false if #mergeable_state? is false" do
expect(subject).to receive(:mergeable_state?) { false }
expect(subject.mergeable?).to be_falsey
end
- it 'return true if #mergeable_state? is true and the MR #can_be_merged? is true' do
+ it "return true if #mergeable_state? is true and the MR #can_be_merged? is true" do
allow(subject).to receive(:mergeable_state?) { true }
expect(subject).to receive(:check_if_can_be_merged)
expect(subject).to receive(:can_be_merged?) { true }
@@ -1958,110 +1958,110 @@ describe MergeRequest do
end
end
- describe '#mergeable_state?' do
+ describe "#mergeable_state?" do
let(:project) { create(:project, :repository) }
subject { create(:merge_request, source_project: project) }
- it 'checks if merge request can be merged' do
+ it "checks if merge request can be merged" do
allow(subject).to receive(:mergeable_ci_state?) { true }
expect(subject).to receive(:check_if_can_be_merged)
subject.mergeable?
end
- context 'when not open' do
+ context "when not open" do
before do
subject.close
end
- it 'returns false' do
+ it "returns false" do
expect(subject.mergeable_state?).to be_falsey
end
end
- context 'when working in progress' do
+ context "when working in progress" do
before do
- subject.title = 'WIP MR'
+ subject.title = "WIP MR"
end
- it 'returns false' do
+ it "returns false" do
expect(subject.mergeable_state?).to be_falsey
end
end
- context 'when broken' do
+ context "when broken" do
before do
allow(subject).to receive(:broken?) { true }
end
- it 'returns false' do
+ it "returns false" do
expect(subject.mergeable_state?).to be_falsey
end
end
- context 'when failed' do
- context 'when #mergeable_ci_state? is false' do
+ context "when failed" do
+ context "when #mergeable_ci_state? is false" do
before do
allow(subject).to receive(:mergeable_ci_state?) { false }
end
- it 'returns false' do
+ it "returns false" do
expect(subject.mergeable_state?).to be_falsey
end
end
- context 'when #mergeable_discussions_state? is false' do
+ context "when #mergeable_discussions_state? is false" do
before do
allow(subject).to receive(:mergeable_discussions_state?) { false }
end
- it 'returns false' do
+ it "returns false" do
expect(subject.mergeable_state?).to be_falsey
end
- it 'returns true when skipping discussions check' do
+ it "returns true when skipping discussions check" do
expect(subject.mergeable_state?(skip_discussions_check: true)).to be(true)
end
end
end
end
- describe '#mergeable_ci_state?' do
+ describe "#mergeable_ci_state?" do
let(:project) { create(:project, only_allow_merge_if_pipeline_succeeds: true) }
let(:pipeline) { create(:ci_empty_pipeline) }
subject { build(:merge_request, target_project: project) }
- context 'when it is only allowed to merge when build is green' do
- context 'and a failed pipeline is associated' do
+ context "when it is only allowed to merge when build is green" do
+ context "and a failed pipeline is associated" do
before do
- pipeline.update(status: 'failed', sha: subject.diff_head_sha)
+ pipeline.update(status: "failed", sha: subject.diff_head_sha)
allow(subject).to receive(:head_pipeline) { pipeline }
end
it { expect(subject.mergeable_ci_state?).to be_falsey }
end
- context 'and a successful pipeline is associated' do
+ context "and a successful pipeline is associated" do
before do
- pipeline.update(status: 'success', sha: subject.diff_head_sha)
+ pipeline.update(status: "success", sha: subject.diff_head_sha)
allow(subject).to receive(:head_pipeline) { pipeline }
end
it { expect(subject.mergeable_ci_state?).to be_truthy }
end
- context 'and a skipped pipeline is associated' do
+ context "and a skipped pipeline is associated" do
before do
- pipeline.update(status: 'skipped', sha: subject.diff_head_sha)
+ pipeline.update(status: "skipped", sha: subject.diff_head_sha)
allow(subject).to receive(:head_pipeline) { pipeline }
end
it { expect(subject.mergeable_ci_state?).to be_truthy }
end
- context 'when no pipeline is associated' do
+ context "when no pipeline is associated" do
before do
allow(subject).to receive(:head_pipeline) { nil }
end
@@ -2070,19 +2070,19 @@ describe MergeRequest do
end
end
- context 'when merges are not restricted to green builds' do
+ context "when merges are not restricted to green builds" do
subject { build(:merge_request, target_project: build(:project, only_allow_merge_if_pipeline_succeeds: false)) }
- context 'and a failed pipeline is associated' do
+ context "and a failed pipeline is associated" do
before do
- pipeline.statuses << create(:commit_status, status: 'failed', project: project)
+ pipeline.statuses << create(:commit_status, status: "failed", project: project)
allow(subject).to receive(:head_pipeline) { pipeline }
end
it { expect(subject.mergeable_ci_state?).to be_truthy }
end
- context 'when no pipeline is associated' do
+ context "when no pipeline is associated" do
before do
allow(subject).to receive(:head_pipeline) { nil }
end
@@ -2092,52 +2092,52 @@ describe MergeRequest do
end
end
- describe '#mergeable_discussions_state?' do
+ describe "#mergeable_discussions_state?" do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) }
- context 'when project.only_allow_merge_if_all_discussions_are_resolved == true' do
+ context "when project.only_allow_merge_if_all_discussions_are_resolved == true" do
let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: true) }
- context 'with all discussions resolved' do
+ context "with all discussions resolved" do
before do
merge_request.discussions.each { |d| d.resolve!(merge_request.author) }
end
- it 'returns true' do
+ it "returns true" do
expect(merge_request.mergeable_discussions_state?).to be_truthy
end
end
- context 'with unresolved discussions' do
+ context "with unresolved discussions" do
before do
merge_request.discussions.each(&:unresolve!)
end
- it 'returns false' do
+ it "returns false" do
expect(merge_request.mergeable_discussions_state?).to be_falsey
end
end
- context 'with no discussions' do
+ context "with no discussions" do
before do
merge_request.notes.destroy_all # rubocop: disable DestroyAll
end
- it 'returns true' do
+ it "returns true" do
expect(merge_request.mergeable_discussions_state?).to be_truthy
end
end
end
- context 'when project.only_allow_merge_if_all_discussions_are_resolved == false' do
+ context "when project.only_allow_merge_if_all_discussions_are_resolved == false" do
let(:project) { create(:project, :repository, only_allow_merge_if_all_discussions_are_resolved: false) }
- context 'with unresolved discussions' do
+ context "with unresolved discussions" do
before do
merge_request.discussions.each(&:unresolve!)
end
- it 'returns true' do
+ it "returns true" do
expect(merge_request.mergeable_discussions_state?).to be_truthy
end
end
@@ -2154,64 +2154,64 @@ describe MergeRequest do
merge_request.target_project.add_maintainer(user)
end
- context 'with multiple environments' do
+ context "with multiple environments" do
let(:environments) { create_list(:environment, 3, project: project) }
before do
- create(:deployment, :success, environment: environments.first, ref: 'master', sha: project.commit('master').id)
- create(:deployment, :success, environment: environments.second, ref: 'feature', sha: project.commit('feature').id)
+ create(:deployment, :success, environment: environments.first, ref: "master", sha: project.commit("master").id)
+ create(:deployment, :success, environment: environments.second, ref: "feature", sha: project.commit("feature").id)
end
- it 'selects deployed environments' do
+ it "selects deployed environments" do
expect(merge_request.environments_for(user)).to contain_exactly(environments.first)
end
end
- context 'with environments on source project' do
+ context "with environments on source project" do
let(:source_project) { fork_project(project, nil, repository: true) }
let(:merge_request) do
create(:merge_request,
- source_project: source_project, source_branch: 'feature',
- target_project: project)
+ source_project: source_project, source_branch: "feature",
+ target_project: project)
end
let(:source_environment) { create(:environment, project: source_project) }
before do
- create(:deployment, :success, environment: source_environment, ref: 'feature', sha: merge_request.diff_head_sha)
+ create(:deployment, :success, environment: source_environment, ref: "feature", sha: merge_request.diff_head_sha)
end
- it 'selects deployed environments' do
+ it "selects deployed environments" do
expect(merge_request.environments_for(user)).to contain_exactly(source_environment)
end
- context 'with environments on target project' do
+ context "with environments on target project" do
let(:target_environment) { create(:environment, project: project) }
before do
create(:deployment, :success, environment: target_environment, tag: true, sha: merge_request.diff_head_sha)
end
- it 'selects deployed environments' do
+ it "selects deployed environments" do
expect(merge_request.environments_for(user)).to contain_exactly(source_environment, target_environment)
end
end
end
- context 'without a diff_head_commit' do
+ context "without a diff_head_commit" do
before do
expect(merge_request).to receive(:diff_head_commit).and_return(nil)
end
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(merge_request.environments_for(user)).to be_empty
end
end
end
describe "#reload_diff" do
- it 'calls MergeRequests::ReloadDiffsService#execute with correct params' do
+ it "calls MergeRequests::ReloadDiffsService#execute with correct params" do
user = create(:user)
service = instance_double(MergeRequests::ReloadDiffsService, execute: nil)
@@ -2224,9 +2224,9 @@ describe MergeRequest do
expect(service).to have_received(:execute)
end
- context 'when using the after_update hook to update' do
- context 'when the branches are updated' do
- it 'uses the new heads to generate the diff' do
+ context "when using the after_update hook to update" do
+ context "when the branches are updated" do
+ it "uses the new heads to generate the diff" do
expect { subject.update!(source_branch: subject.target_branch, target_branch: subject.source_branch) }
.to change { subject.merge_request_diff.start_commit_sha }
.and change { subject.merge_request_diff.head_commit_sha }
@@ -2235,7 +2235,7 @@ describe MergeRequest do
end
end
- describe '#update_diff_discussion_positions' do
+ describe "#update_diff_discussion_positions" do
let(:discussion) { create(:diff_note_on_merge_request, project: subject.project, noteable: subject).to_discussion }
let(:commit) { subject.project.commit(sample_commit.id) }
let(:old_diff_refs) { subject.diff_refs }
@@ -2270,14 +2270,14 @@ describe MergeRequest do
current_user: subject.author)
end
- context 'when resolve_outdated_diff_discussions is set' do
+ context "when resolve_outdated_diff_discussions is set" do
before do
discussion
subject.project.update!(resolve_outdated_diff_discussions: true)
end
- it 'calls MergeRequests::ResolvedDiscussionNotificationService' do
+ it "calls MergeRequests::ResolvedDiscussionNotificationService" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService)
.to receive(:execute).with(subject)
@@ -2288,19 +2288,19 @@ describe MergeRequest do
end
end
- describe '#branch_merge_base_commit' do
- context 'source and target branch exist' do
- it { expect(subject.branch_merge_base_commit.sha).to eq('ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }
+ describe "#branch_merge_base_commit" do
+ context "source and target branch exist" do
+ it { expect(subject.branch_merge_base_commit.sha).to eq("ae73cb07c9eeaf35924a10f713b364d32b2dd34f") }
it { expect(subject.branch_merge_base_commit).to be_a(Commit) }
end
- context 'when the target branch does not exist' do
+ context "when the target branch does not exist" do
before do
subject.project.repository.rm_branch(subject.author, subject.target_branch)
subject.clear_memoized_shas
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject.branch_merge_base_commit).to be_nil
end
end
@@ -2320,9 +2320,9 @@ describe MergeRequest do
it "returns expected diff_refs" do
expected_diff_refs = Gitlab::Diff::DiffRefs.new(
- base_sha: subject.merge_request_diff.base_commit_sha,
+ base_sha: subject.merge_request_diff.base_commit_sha,
start_sha: subject.merge_request_diff.start_commit_sha,
- head_sha: subject.merge_request_diff.head_commit_sha
+ head_sha: subject.merge_request_diff.head_commit_sha
)
expect(subject.diff_refs).to eq(expected_diff_refs)
@@ -2368,35 +2368,35 @@ describe MergeRequest do
end
end
- describe '#merge_ongoing?' do
- it 'returns true when the merge request is locked' do
+ describe "#merge_ongoing?" do
+ it "returns true when the merge request is locked" do
merge_request = build_stubbed(:merge_request, state: :locked)
expect(merge_request.merge_ongoing?).to be(true)
end
- it 'returns true when merge_id, MR is not merged and it has no running job' do
- merge_request = build_stubbed(:merge_request, state: :open, merge_jid: 'foo')
- allow(Gitlab::SidekiqStatus).to receive(:running?).with('foo') { true }
+ it "returns true when merge_id, MR is not merged and it has no running job" do
+ merge_request = build_stubbed(:merge_request, state: :open, merge_jid: "foo")
+ allow(Gitlab::SidekiqStatus).to receive(:running?).with("foo") { true }
expect(merge_request.merge_ongoing?).to be(true)
end
- it 'returns false when merge_jid is nil' do
+ it "returns false when merge_jid is nil" do
merge_request = build_stubbed(:merge_request, state: :open, merge_jid: nil)
expect(merge_request.merge_ongoing?).to be(false)
end
- it 'returns false if MR is merged' do
- merge_request = build_stubbed(:merge_request, state: :merged, merge_jid: 'foo')
+ it "returns false if MR is merged" do
+ merge_request = build_stubbed(:merge_request, state: :merged, merge_jid: "foo")
expect(merge_request.merge_ongoing?).to be(false)
end
- it 'returns false if there is no merge job running' do
- merge_request = build_stubbed(:merge_request, state: :open, merge_jid: 'foo')
- allow(Gitlab::SidekiqStatus).to receive(:running?).with('foo') { false }
+ it "returns false if there is no merge job running" do
+ merge_request = build_stubbed(:merge_request, state: :open, merge_jid: "foo")
+ allow(Gitlab::SidekiqStatus).to receive(:running?).with("foo") { false }
expect(merge_request.merge_ongoing?).to be(false)
end
@@ -2440,15 +2440,15 @@ describe MergeRequest do
end
end
- describe '#reopenable?' do
- context 'when the merge request is closed' do
- it 'returns true' do
+ describe "#reopenable?" do
+ context "when the merge request is closed" do
+ it "returns true" do
subject.close
expect(subject.reopenable?).to be_truthy
end
- context 'forked project' do
+ context "forked project" do
let(:project) { create(:project, :public) }
let(:user) { create(:user) }
let(:forked_project) { fork_project(project, user) }
@@ -2459,40 +2459,40 @@ describe MergeRequest do
target_project: project)
end
- it 'returns false if unforked' do
+ it "returns false if unforked" do
Projects::UnlinkForkService.new(forked_project, user).execute
expect(merge_request.reload.reopenable?).to be_falsey
end
- it 'returns false if the source project is deleted' do
+ it "returns false if the source project is deleted" do
Projects::DestroyService.new(forked_project, user).execute
expect(merge_request.reload.reopenable?).to be_falsey
end
- it 'returns false if the merge request is merged' do
- merge_request.update(state: 'merged')
+ it "returns false if the merge request is merged" do
+ merge_request.update(state: "merged")
expect(merge_request.reload.reopenable?).to be_falsey
end
end
end
- context 'when the merge request is opened' do
- it 'returns false' do
+ context "when the merge request is opened" do
+ it "returns false" do
expect(subject.reopenable?).to be_falsey
end
end
end
- describe '#mergeable_with_quick_action?' do
+ describe "#mergeable_with_quick_action?" do
def create_pipeline(status)
pipeline = create(:ci_pipeline_with_one_job,
project: project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha,
- status: status,
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha,
+ status: status,
head_pipeline_of: merge_request)
pipeline
@@ -2508,95 +2508,95 @@ describe MergeRequest do
project.add_developer(developer)
end
- context 'when autocomplete_precheck is set to true' do
- it 'is mergeable by developer' do
+ context "when autocomplete_precheck is set to true" do
+ it "is mergeable by developer" do
expect(merge_request.mergeable_with_quick_action?(developer, autocomplete_precheck: true)).to be_truthy
end
- it 'is not mergeable by normal user' do
+ it "is not mergeable by normal user" do
expect(merge_request.mergeable_with_quick_action?(user, autocomplete_precheck: true)).to be_falsey
end
end
- context 'when autocomplete_precheck is set to false' do
- it 'is mergeable by developer' do
+ context "when autocomplete_precheck is set to false" do
+ it "is mergeable by developer" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
- it 'is not mergeable by normal user' do
+ it "is not mergeable by normal user" do
expect(merge_request.mergeable_with_quick_action?(user, last_diff_sha: mr_sha)).to be_falsey
end
- context 'closed MR' do
+ context "closed MR" do
before do
merge_request.update_attribute(:state, :closed)
end
- it 'is not mergeable' do
+ it "is not mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
- context 'MR with WIP' do
+ context "MR with WIP" do
before do
- merge_request.update_attribute(:title, 'WIP: some MR')
+ merge_request.update_attribute(:title, "WIP: some MR")
end
- it 'is not mergeable' do
+ it "is not mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
- context 'sha differs from the MR diff_head_sha' do
- it 'is not mergeable' do
- expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: 'some other sha')).to be_falsey
+ context "sha differs from the MR diff_head_sha" do
+ it "is not mergeable" do
+ expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: "some other sha")).to be_falsey
end
end
- context 'sha is not provided' do
- it 'is not mergeable' do
+ context "sha is not provided" do
+ it "is not mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer)).to be_falsey
end
end
- context 'with pipeline ok' do
+ context "with pipeline ok" do
before do
create_pipeline(:success)
end
- it 'is mergeable' do
+ it "is mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
end
- context 'with failing pipeline' do
+ context "with failing pipeline" do
before do
create_pipeline(:failed)
end
- it 'is not mergeable' do
+ it "is not mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_falsey
end
end
- context 'with running pipeline' do
+ context "with running pipeline" do
before do
create_pipeline(:running)
end
- it 'is mergeable' do
+ it "is mergeable" do
expect(merge_request.mergeable_with_quick_action?(developer, last_diff_sha: mr_sha)).to be_truthy
end
end
end
end
- describe '#base_pipeline' do
+ describe "#base_pipeline" do
let(:pipeline_arguments) do
{
project: project,
ref: merge_request.target_branch,
- sha: merge_request.diff_base_sha
+ sha: merge_request.diff_base_sha,
}
end
@@ -2605,54 +2605,54 @@ describe MergeRequest do
let!(:first_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
let!(:last_pipeline) { create(:ci_pipeline_without_jobs, pipeline_arguments) }
- let!(:last_pipeline_with_other_ref) { create(:ci_pipeline_without_jobs, pipeline_arguments.merge(ref: 'other')) }
+ let!(:last_pipeline_with_other_ref) { create(:ci_pipeline_without_jobs, pipeline_arguments.merge(ref: "other")) }
- it 'returns latest pipeline for the target branch' do
+ it "returns latest pipeline for the target branch" do
expect(merge_request.base_pipeline).to eq(last_pipeline)
end
end
- describe '#has_commits?' do
+ describe "#has_commits?" do
before do
allow(subject.merge_request_diff).to receive(:commits_count)
.and_return(2)
end
- it 'returns true when merge request diff has commits' do
+ it "returns true when merge request diff has commits" do
expect(subject.has_commits?).to be_truthy
end
end
- describe '#has_no_commits?' do
+ describe "#has_no_commits?" do
before do
allow(subject.merge_request_diff).to receive(:commits_count)
.and_return(0)
end
- it 'returns true when merge request diff has 0 commits' do
+ it "returns true when merge request diff has 0 commits" do
expect(subject.has_no_commits?).to be_truthy
end
end
- describe '#merge_request_diff_for' do
+ describe "#merge_request_diff_for" do
subject { create(:merge_request, importing: true) }
- let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
- context 'with diff refs' do
- it 'returns the diffs' do
+ context "with diff refs" do
+ it "returns the diffs" do
expect(subject.merge_request_diff_for(merge_request_diff1.diff_refs)).to eq(merge_request_diff1)
end
end
- context 'with a commit SHA' do
- it 'returns the diffs' do
+ context "with a commit SHA" do
+ it "returns the diffs" do
expect(subject.merge_request_diff_for(merge_request_diff3.head_commit_sha)).to eq(merge_request_diff3)
end
end
- it 'runs a single query on the initial call, and none afterwards' do
+ it "runs a single query on the initial call, and none afterwards" do
expect { subject.merge_request_diff_for(merge_request_diff1.diff_refs) }
.not_to exceed_query_limit(1)
@@ -2664,40 +2664,40 @@ describe MergeRequest do
end
end
- describe '#version_params_for' do
+ describe "#version_params_for" do
subject { create(:merge_request, importing: true) }
let(:project) { subject.project }
- let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9') }
+ let!(:merge_request_diff1) { subject.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9") }
let!(:merge_request_diff2) { subject.merge_request_diffs.create(head_commit_sha: nil) }
- let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e') }
+ let!(:merge_request_diff3) { subject.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e") }
- context 'when the diff refs are for an older merge request version' do
+ context "when the diff refs are for an older merge request version" do
let(:diff_refs) { merge_request_diff1.diff_refs }
- it 'returns the diff ID for the version to show' do
+ it "returns the diff ID for the version to show" do
expect(subject.version_params_for(diff_refs)).to eq(diff_id: merge_request_diff1.id)
end
end
- context 'when the diff refs are for a comparison between merge request versions' do
+ context "when the diff refs are for a comparison between merge request versions" do
let(:diff_refs) { merge_request_diff3.compare_with(merge_request_diff1.head_commit_sha).diff_refs }
- it 'returns the diff ID and start sha of the versions to compare' do
+ it "returns the diff ID and start sha of the versions to compare" do
expect(subject.version_params_for(diff_refs)).to eq(diff_id: merge_request_diff3.id, start_sha: merge_request_diff1.head_commit_sha)
end
end
- context 'when the diff refs are not for a merge request version' do
+ context "when the diff refs are not for a merge request version" do
let(:diff_refs) { project.commit(sample_commit.id).diff_refs }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.version_params_for(diff_refs)).to be_nil
end
end
end
- describe '#fetch_ref!' do
- it 'fetches the ref correctly' do
+ describe "#fetch_ref!" do
+ it "fetches the ref correctly" do
expect { subject.target_project.repository.delete_refs(subject.ref_path) }.not_to raise_error
subject.fetch_ref!
@@ -2705,8 +2705,8 @@ describe MergeRequest do
end
end
- describe 'removing a merge request' do
- it 'refreshes the number of open merge requests of the target project' do
+ describe "removing a merge request" do
+ it "refreshes the number of open merge requests of the target project" do
project = subject.target_project
expect { subject.destroy }
@@ -2714,15 +2714,15 @@ describe MergeRequest do
end
end
- it_behaves_like 'throttled touch' do
+ it_behaves_like "throttled touch" do
subject { create(:merge_request, updated_at: 1.hour.ago) }
end
- context 'state machine transitions' do
- describe '#unlock_mr' do
- subject { create(:merge_request, state: 'locked', merge_jid: 123) }
+ context "state machine transitions" do
+ describe "#unlock_mr" do
+ subject { create(:merge_request, state: "locked", merge_jid: 123) }
- it 'updates merge request head pipeline and sets merge_jid to nil' do
+ it "updates merge request head pipeline and sets merge_jid to nil" do
pipeline = create(:ci_empty_pipeline, project: subject.project, ref: subject.source_branch, sha: subject.source_branch_sha)
subject.unlock_mr
@@ -2733,7 +2733,7 @@ describe MergeRequest do
end
end
- describe 'transition to cannot_be_merged' do
+ describe "transition to cannot_be_merged" do
let(:notification_service) { double(:notification_service) }
let(:todo_service) { double(:todo_service) }
subject { create(:merge_request, state, merge_status: :unchecked) }
@@ -2749,7 +2749,7 @@ describe MergeRequest do
context state do
let(:state) { state }
- it 'notifies conflict, but does not notify again if rechecking still results in cannot_be_merged' do
+ it "notifies conflict, but does not notify again if rechecking still results in cannot_be_merged" do
expect(notification_service).to receive(:merge_request_unmergeable).with(subject).once
expect(todo_service).to receive(:merge_request_became_unmergeable).with(subject).once
@@ -2758,7 +2758,7 @@ describe MergeRequest do
subject.mark_as_unmergeable
end
- it 'notifies conflict, whenever newly unmergeable' do
+ it "notifies conflict, whenever newly unmergeable" do
expect(notification_service).to receive(:merge_request_unmergeable).with(subject).twice
expect(todo_service).to receive(:merge_request_became_unmergeable).with(subject).twice
@@ -2769,7 +2769,7 @@ describe MergeRequest do
subject.mark_as_unmergeable
end
- it 'does not notify whenever merge request is newly unmergeable due to other reasons' do
+ it "does not notify whenever merge request is newly unmergeable due to other reasons" do
allow(subject.project.repository).to receive(:can_be_merged?).and_return(true)
expect(notification_service).not_to receive(:merge_request_unmergeable)
@@ -2784,7 +2784,7 @@ describe MergeRequest do
let(:state) { state }
context state do
- it 'does not notify' do
+ it "does not notify" do
expect(notification_service).not_to receive(:merge_request_unmergeable)
expect(todo_service).not_to receive(:merge_request_became_unmergeable)
@@ -2793,14 +2793,14 @@ describe MergeRequest do
end
end
- context 'source branch is missing' do
- subject { create(:merge_request, :invalid, :opened, merge_status: :unchecked, target_branch: 'master') }
+ context "source branch is missing" do
+ subject { create(:merge_request, :invalid, :opened, merge_status: :unchecked, target_branch: "master") }
before do
allow(subject.project.repository).to receive(:can_be_merged?).and_call_original
end
- it 'does not raise error' do
+ it "does not raise error" do
expect(notification_service).not_to receive(:merge_request_unmergeable)
expect(todo_service).not_to receive(:merge_request_became_unmergeable)
@@ -2810,8 +2810,8 @@ describe MergeRequest do
end
end
- describe 'check_state?' do
- it 'indicates whether MR is still checking for mergeability' do
+ describe "check_state?" do
+ it "indicates whether MR is still checking for mergeability" do
state_machine = described_class.state_machines[:merge_status]
check_states = [:unchecked, :cannot_be_merged_recheck]
@@ -2826,18 +2826,18 @@ describe MergeRequest do
end
end
- describe '#should_be_rebased?' do
+ describe "#should_be_rebased?" do
let(:project) { create(:project, :repository) }
- it 'returns false for the same source and target branches' do
+ it "returns false for the same source and target branches" do
merge_request = create(:merge_request, source_project: project, target_project: project)
expect(merge_request.should_be_rebased?).to be_falsey
end
end
- describe '#rebase_in_progress?' do
- shared_examples 'checking whether a rebase is in progress' do
+ describe "#rebase_in_progress?" do
+ shared_examples "checking whether a rebase is in progress" do
let(:repo_path) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
subject.source_project.repository.path
@@ -2846,27 +2846,27 @@ describe MergeRequest do
let(:rebase_path) { File.join(repo_path, "gitlab-worktree", "rebase-#{subject.id}") }
before do
- system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} worktree add --detach #{rebase_path} master))
+ system(Gitlab.config.git.bin_path.to_s, "-C", repo_path.to_s, "worktree", "add", "--detach", rebase_path.to_s, "master")
end
- it 'returns true when there is a current rebase directory' do
+ it "returns true when there is a current rebase directory" do
expect(subject.rebase_in_progress?).to be_truthy
end
- it 'returns false when there is no rebase directory' do
+ it "returns false when there is no rebase directory" do
FileUtils.rm_rf(rebase_path)
expect(subject.rebase_in_progress?).to be_falsey
end
- it 'returns false when the rebase directory has expired' do
+ it "returns false when the rebase directory has expired" do
time = 20.minutes.ago.to_time
File.utime(time, time, rebase_path)
expect(subject.rebase_in_progress?).to be_falsey
end
- it 'returns false when the source project has been removed' do
+ it "returns false when the source project has been removed" do
allow(subject).to receive(:source_project).and_return(nil)
expect(subject.rebase_in_progress?).to be_falsey
@@ -2874,96 +2874,96 @@ describe MergeRequest do
end
end
- describe '#allow_collaboration' do
+ describe "#allow_collaboration" do
let(:merge_request) do
- build(:merge_request, source_branch: 'fixes', allow_collaboration: true)
+ build(:merge_request, source_branch: "fixes", allow_collaboration: true)
end
- it 'is false when pushing by a maintainer is not possible' do
+ it "is false when pushing by a maintainer is not possible" do
expect(merge_request).to receive(:collaborative_push_possible?) { false }
expect(merge_request.allow_collaboration).to be_falsy
end
- it 'is true when pushing by a maintainer is possible' do
+ it "is true when pushing by a maintainer is possible" do
expect(merge_request).to receive(:collaborative_push_possible?) { true }
expect(merge_request.allow_collaboration).to be_truthy
end
end
- describe '#collaborative_push_possible?' do
+ describe "#collaborative_push_possible?" do
let(:merge_request) do
- build(:merge_request, source_branch: 'fixes')
+ build(:merge_request, source_branch: "fixes")
end
before do
allow(ProtectedBranch).to receive(:protected?) { false }
end
- it 'does not allow maintainer to push if the source project is the same as the target' do
+ it "does not allow maintainer to push if the source project is the same as the target" do
merge_request.target_project = merge_request.source_project = create(:project, :public)
expect(merge_request.collaborative_push_possible?).to be_falsy
end
- it 'allows maintainer to push when both source and target are public' do
+ it "allows maintainer to push when both source and target are public" do
merge_request.target_project = build(:project, :public)
merge_request.source_project = build(:project, :public)
expect(merge_request.collaborative_push_possible?).to be_truthy
end
- it 'is not available for protected branches' do
+ it "is not available for protected branches" do
merge_request.target_project = build(:project, :public)
merge_request.source_project = build(:project, :public)
expect(ProtectedBranch).to receive(:protected?)
- .with(merge_request.source_project, 'fixes')
- .and_return(true)
+ .with(merge_request.source_project, "fixes")
+ .and_return(true)
expect(merge_request.collaborative_push_possible?).to be_falsy
end
end
- describe '#includes_any_commits?' do
- it 'returns false' do
+ describe "#includes_any_commits?" do
+ it "returns false" do
expect(subject.includes_any_commits?([])).to be_falsey
end
- it 'returns false' do
+ it "returns false" do
expect(subject.includes_any_commits?([Gitlab::Git::BLANK_SHA])).to be_falsey
end
- it 'returns true' do
+ it "returns true" do
expect(subject.includes_any_commits?([subject.merge_request_diff.head_commit_sha])).to be_truthy
end
- it 'returns true even when there is a non-existent comit' do
+ it "returns true even when there is a non-existent comit" do
expect(subject.includes_any_commits?([Gitlab::Git::BLANK_SHA, subject.merge_request_diff.head_commit_sha])).to be_truthy
end
- context 'unpersisted merge request' do
+ context "unpersisted merge request" do
let(:new_mr) { build(:merge_request) }
- it 'returns false' do
+ it "returns false" do
expect(new_mr.includes_any_commits?([Gitlab::Git::BLANK_SHA])).to be_falsey
end
- it 'returns true' do
+ it "returns true" do
expect(new_mr.includes_any_commits?([subject.merge_request_diff.head_commit_sha])).to be_truthy
end
end
end
- describe '#can_allow_collaboration?' do
+ describe "#can_allow_collaboration?" do
let(:target_project) { create(:project, :public) }
let(:source_project) { fork_project(target_project) }
let(:merge_request) do
create(:merge_request,
- source_project: source_project,
- source_branch: 'fixes',
- target_project: target_project)
+ source_project: source_project,
+ source_branch: "fixes",
+ target_project: target_project)
end
let(:user) { create(:user) }
@@ -2971,46 +2971,46 @@ describe MergeRequest do
allow(merge_request).to receive(:collaborative_push_possible?) { true }
end
- it 'is false if the user does not have push access to the source project' do
+ it "is false if the user does not have push access to the source project" do
expect(merge_request.can_allow_collaboration?(user)).to be_falsy
end
- it 'is true when the user has push access to the source project' do
+ it "is true when the user has push access to the source project" do
source_project.add_developer(user)
expect(merge_request.can_allow_collaboration?(user)).to be_truthy
end
end
- describe '#merge_participants' do
- it 'contains author' do
+ describe "#merge_participants" do
+ it "contains author" do
expect(subject.merge_participants).to eq([subject.author])
end
- describe 'when merge_when_pipeline_succeeds? is true' do
- describe 'when merge user is author' do
+ describe "when merge_when_pipeline_succeeds? is true" do
+ describe "when merge user is author" do
let(:user) { create(:user) }
subject do
create(:merge_request,
- merge_when_pipeline_succeeds: true,
- merge_user: user,
- author: user)
+ merge_when_pipeline_succeeds: true,
+ merge_user: user,
+ author: user)
end
- it 'contains author only' do
+ it "contains author only" do
expect(subject.merge_participants).to eq([subject.author])
end
end
- describe 'when merge user and author are different users' do
+ describe "when merge user and author are different users" do
let(:merge_user) { create(:user) }
subject do
create(:merge_request,
- merge_when_pipeline_succeeds: true,
- merge_user: merge_user)
+ merge_when_pipeline_succeeds: true,
+ merge_user: merge_user)
end
- it 'contains author and merge user' do
+ it "contains author and merge user" do
expect(subject.merge_participants).to eq([subject.author, merge_user])
end
end
diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb
index af7e3d3a6c9..9b4caf010ae 100644
--- a/spec/models/milestone_spec.rb
+++ b/spec/models/milestone_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Milestone do
- describe 'modules' do
- context 'with a project' do
- it_behaves_like 'AtomicInternalId' do
+ describe "modules" do
+ context "with a project" do
+ it_behaves_like "AtomicInternalId" do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:milestone, project: build(:project), group: nil) }
let(:scope) { :project }
- let(:scope_attrs) { { project: instance.project } }
+ let(:scope_attrs) { {project: instance.project} }
let(:usage) { :milestones }
end
end
- context 'with a group' do
- it_behaves_like 'AtomicInternalId' do
+ context "with a group" do
+ it_behaves_like "AtomicInternalId" do
let(:internal_id_attribute) { :iid }
let(:instance) { build(:milestone, project: nil, group: build(:group)) }
let(:scope) { :group }
- let(:scope_attrs) { { namespace: instance.group } }
+ let(:scope_attrs) { {namespace: instance.group} }
let(:usage) { :milestones }
end
end
@@ -28,8 +28,8 @@ describe Milestone do
allow(subject).to receive(:set_iid).and_return(false)
end
- describe 'start_date' do
- it 'adds an error when start_date is greated then due_date' do
+ describe "start_date" do
+ it "adds an error when start_date is greated then due_date" do
milestone = build(:milestone, start_date: Date.tomorrow, due_date: Date.yesterday)
expect(milestone).not_to be_valid
@@ -95,17 +95,17 @@ describe Milestone do
end
end
- describe '.order_by_name_asc' do
- it 'sorts by name ascending' do
- milestone1 = create(:milestone, title: 'Foo')
- milestone2 = create(:milestone, title: 'Bar')
+ describe ".order_by_name_asc" do
+ it "sorts by name ascending" do
+ milestone1 = create(:milestone, title: "Foo")
+ milestone2 = create(:milestone, title: "Bar")
expect(described_class.order_by_name_asc).to eq([milestone2, milestone1])
end
end
- describe '.reorder_by_due_date_asc' do
- it 'reorders the input relation' do
+ describe ".reorder_by_due_date_asc" do
+ it "reorders the input relation" do
milestone1 = create(:milestone, due_date: Date.new(2018, 9, 30))
milestone2 = create(:milestone, due_date: Date.new(2018, 10, 20))
@@ -130,13 +130,13 @@ describe Milestone do
end
end
- describe '#expired?' do
+ describe "#expired?" do
context "expired" do
before do
allow(milestone).to receive(:due_date).and_return(Date.today.prev_year)
end
- it 'returns true when due_date is in the past' do
+ it "returns true when due_date is in the past" do
expect(milestone.expired?).to be_truthy
end
end
@@ -146,25 +146,25 @@ describe Milestone do
allow(milestone).to receive(:due_date).and_return(Date.today.next_year)
end
- it 'returns false when due_date is in the future' do
+ it "returns false when due_date is in the future" do
expect(milestone.expired?).to be_falsey
end
end
end
- describe '#upcoming?' do
- it 'returns true when start_date is in the future' do
+ describe "#upcoming?" do
+ it "returns true when start_date is in the future" do
milestone = build(:milestone, start_date: Time.now + 1.month)
expect(milestone.upcoming?).to be_truthy
end
- it 'returns false when start_date is in the past' do
+ it "returns false when start_date is in the past" do
milestone = build(:milestone, start_date: Date.today.prev_year)
expect(milestone.upcoming?).to be_falsey
end
end
- describe '#percent_complete' do
+ describe "#percent_complete" do
before do
allow(milestone).to receive_messages(
closed_items_count: 3,
@@ -175,22 +175,22 @@ describe Milestone do
it { expect(milestone.percent_complete(user)).to eq(75) }
end
- describe '#can_be_closed?' do
+ describe "#can_be_closed?" do
it { expect(milestone.can_be_closed?).to be_truthy }
end
- describe '#total_items_count' do
+ describe "#total_items_count" do
before do
create :closed_issue, milestone: milestone, project: project
create :merge_request, milestone: milestone
end
- it 'returns 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
- describe '#can_be_closed?' do
+ describe "#can_be_closed?" do
before do
milestone = create :milestone
create :closed_issue, milestone: milestone
@@ -198,11 +198,11 @@ describe Milestone do
create :issue
end
- it 'returns 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 'returns 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
@@ -210,60 +210,60 @@ describe Milestone do
end
end
- describe '.search' do
- let(:milestone) { create(:milestone, title: 'foo', description: 'bar') }
+ describe ".search" do
+ let(:milestone) { create(:milestone, title: "foo", description: "bar") }
- it 'returns milestones with a matching title' do
+ it "returns milestones with a matching title" do
expect(described_class.search(milestone.title)).to eq([milestone])
end
- it 'returns milestones with a partially matching title' do
+ it "returns milestones with a partially matching title" do
expect(described_class.search(milestone.title[0..2])).to eq([milestone])
end
- it 'returns milestones with a matching title regardless of the casing' do
+ it "returns milestones with a matching title regardless of the casing" do
expect(described_class.search(milestone.title.upcase)).to eq([milestone])
end
- it 'returns milestones with a matching description' do
+ it "returns milestones with a matching description" do
expect(described_class.search(milestone.description)).to eq([milestone])
end
- it 'returns milestones with a partially matching description' do
+ it "returns milestones with a partially matching description" do
expect(described_class.search(milestone.description[0..2]))
.to eq([milestone])
end
- it 'returns milestones with a matching description regardless of the casing' do
+ it "returns milestones with a matching description regardless of the casing" do
expect(described_class.search(milestone.description.upcase))
.to eq([milestone])
end
end
- describe '#search_title' do
- let(:milestone) { create(:milestone, title: 'foo', description: 'bar') }
+ describe "#search_title" do
+ let(:milestone) { create(:milestone, title: "foo", description: "bar") }
- it 'returns milestones with a matching title' do
+ it "returns milestones with a matching title" do
expect(described_class.search_title(milestone.title)) .to eq([milestone])
end
- it 'returns milestones with a partially matching title' do
+ it "returns milestones with a partially matching title" do
expect(described_class.search_title(milestone.title[0..2])).to eq([milestone])
end
- it 'returns milestones with a matching title regardless of the casing' do
+ it "returns milestones with a matching title regardless of the casing" do
expect(described_class.search_title(milestone.title.upcase))
.to eq([milestone])
end
- it 'searches only on the title and ignores milestones with a matching description' do
- create(:milestone, title: 'bar', description: 'foo')
+ it "searches only on the title and ignores milestones with a matching description" do
+ create(:milestone, title: "bar", description: "foo")
expect(described_class.search_title(milestone.title)) .to eq([milestone])
end
end
- describe '#for_projects_and_groups' do
+ describe "#for_projects_and_groups" do
let(:project) { create(:project) }
let(:project_other) { create(:project) }
let(:group) { create(:group) }
@@ -278,22 +278,22 @@ describe Milestone do
subject { described_class.for_projects_and_groups(projects, groups) }
- shared_examples 'filters by projects and groups' do
- it 'returns milestones filtered by project' do
+ shared_examples "filters by projects and groups" do
+ it "returns milestones filtered by project" do
milestones = described_class.for_projects_and_groups(projects, [])
expect(milestones.count).to eq(1)
expect(milestones.first.project_id).to eq(project.id)
end
- it 'returns milestones filtered by group' do
+ it "returns milestones filtered by group" do
milestones = described_class.for_projects_and_groups([], groups)
expect(milestones.count).to eq(1)
expect(milestones.first.group_id).to eq(group.id)
end
- it 'returns milestones filtered by both project and group' do
+ it "returns milestones filtered by both project and group" do
milestones = described_class.for_projects_and_groups(projects, groups)
expect(milestones.count).to eq(2)
@@ -301,35 +301,35 @@ describe Milestone do
end
end
- context 'ids as params' do
+ context "ids as params" do
let(:projects) { [project.id] }
let(:groups) { [group.id] }
- it_behaves_like 'filters by projects and groups'
+ it_behaves_like "filters by projects and groups"
end
- context 'relations as params' do
+ context "relations as params" do
let(:projects) { Project.where(id: project.id).select(:id) }
let(:groups) { Group.where(id: group.id).select(:id) }
- it_behaves_like 'filters by projects and groups'
+ it_behaves_like "filters by projects and groups"
end
- context 'objects as params' do
+ context "objects as params" do
let(:projects) { [project] }
let(:groups) { [group] }
- it_behaves_like 'filters by projects and groups'
+ it_behaves_like "filters by projects and groups"
end
- it 'returns no records if projects and groups are nil' do
+ it "returns no records if projects and groups are nil" do
milestones = described_class.for_projects_and_groups(nil, nil)
expect(milestones).to be_empty
end
end
- describe '.upcoming_ids' do
+ describe ".upcoming_ids" do
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
let(:group_3) { create(:group) }
@@ -362,7 +362,7 @@ describe Milestone do
let(:milestone_ids) { described_class.upcoming_ids(projects, groups).map(&:id) }
- it 'returns the next upcoming open milestone ID for each project and group' do
+ it "returns the next upcoming open milestone ID for each project and group" do
expect(milestone_ids).to contain_exactly(
current_milestone_project_1.id,
current_milestone_project_2.id,
@@ -371,73 +371,73 @@ describe Milestone do
)
end
- context 'when the projects and groups have no open upcoming milestones' do
+ context "when the projects and groups have no open upcoming milestones" do
let(:projects) { [project_3] }
let(:groups) { [group_3] }
- it 'returns no results' do
+ it "returns no results" do
expect(milestone_ids).to be_empty
end
end
end
- describe '#to_reference' do
+ describe "#to_reference" do
let(:group) { build_stubbed(:group) }
- let(:project) { build_stubbed(:project, name: 'sample-project') }
- let(:another_project) { build_stubbed(:project, name: 'another-project', namespace: project.namespace) }
+ let(:project) { build_stubbed(:project, name: "sample-project") }
+ let(:another_project) { build_stubbed(:project, name: "another-project", namespace: project.namespace) }
- context 'for a project milestone' do
- let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: 'milestone') }
+ context "for a project milestone" do
+ let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: "milestone") }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(milestone.to_reference).to eq '%"milestone"'
end
- it 'returns a reference by name when the format is set to :name' do
+ it "returns a reference by name when the format is set to :name" do
expect(milestone.to_reference(format: :name)).to eq '%"milestone"'
end
- it 'supports a cross-project reference' do
+ it "supports a cross-project reference" do
expect(milestone.to_reference(another_project)).to eq 'sample-project%"milestone"'
end
end
- context 'for a group milestone' do
- let(:milestone) { build_stubbed(:milestone, iid: 1, group: group, name: 'milestone') }
+ context "for a group milestone" do
+ let(:milestone) { build_stubbed(:milestone, iid: 1, group: group, name: "milestone") }
- it 'returns a group milestone reference with a default format' do
+ it "returns a group milestone reference with a default format" do
expect(milestone.to_reference).to eq '%"milestone"'
end
- it 'returns a reference by name when the format is set to :name' do
+ it "returns a reference by name when the format is set to :name" do
expect(milestone.to_reference(format: :name)).to eq '%"milestone"'
end
- it 'does supports cross-project references within a group' do
+ it "does supports cross-project references within a group" do
expect(milestone.to_reference(another_project, format: :name)).to eq '%"milestone"'
end
- it 'raises an error when using iid format' do
+ it "raises an error when using iid format" do
expect { milestone.to_reference(format: :iid) }
- .to raise_error(ArgumentError, 'Cannot refer to a group milestone by an internal id!')
+ .to raise_error(ArgumentError, "Cannot refer to a group milestone by an internal id!")
end
end
end
- describe '#reference_link_text' do
- let(:project) { build_stubbed(:project, name: 'sample-project') }
- let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: 'milestone') }
+ describe "#reference_link_text" do
+ let(:project) { build_stubbed(:project, name: "sample-project") }
+ let(:milestone) { build_stubbed(:milestone, iid: 1, project: project, name: "milestone") }
- it 'returns the title with the reference prefix' do
- expect(milestone.reference_link_text).to eq '%milestone'
+ it "returns the title with the reference prefix" do
+ expect(milestone.reference_link_text).to eq "%milestone"
end
end
- describe '#participants' do
- let(:project) { build(:project, name: 'sample-project') }
+ describe "#participants" do
+ let(:project) { build(:project, name: "sample-project") }
let(:milestone) { build(:milestone, iid: 1, project: project) }
- it 'returns participants without duplicates' do
+ it "returns participants without duplicates" do
user = create :user
create :issue, project: project, milestone: milestone, assignees: [user]
create :issue, project: project, milestone: milestone, assignees: [user]
@@ -446,55 +446,55 @@ describe Milestone do
end
end
- describe '.sort_by_attribute' do
- set(:milestone_1) { create(:milestone, title: 'Foo') }
- set(:milestone_2) { create(:milestone, title: 'Bar') }
- set(:milestone_3) { create(:milestone, title: 'Zoo') }
+ describe ".sort_by_attribute" do
+ set(:milestone_1) { create(:milestone, title: "Foo") }
+ set(:milestone_2) { create(:milestone, title: "Bar") }
+ set(:milestone_3) { create(:milestone, title: "Zoo") }
- context 'ordering by name ascending' do
- it 'sorts by title ascending' do
- expect(described_class.sort_by_attribute('name_asc'))
+ context "ordering by name ascending" do
+ it "sorts by title ascending" do
+ expect(described_class.sort_by_attribute("name_asc"))
.to eq([milestone_2, milestone_1, milestone_3])
end
end
- context 'ordering by name descending' do
- it 'sorts by title descending' do
- expect(described_class.sort_by_attribute('name_desc'))
+ context "ordering by name descending" do
+ it "sorts by title descending" do
+ expect(described_class.sort_by_attribute("name_desc"))
.to eq([milestone_3, milestone_1, milestone_2])
end
end
end
- describe '.states_count' do
- context 'when the projects have milestones' do
+ describe ".states_count" do
+ context "when the projects have milestones" do
before do
project_1 = create(:project)
project_2 = create(:project)
group_1 = create(:group)
group_2 = create(:group)
- create(:active_milestone, title: 'Active Group Milestone', project: project_1)
- create(:closed_milestone, title: 'Closed Group Milestone', project: project_1)
- create(:active_milestone, title: 'Active Group Milestone', project: project_2)
- create(:closed_milestone, title: 'Closed Group Milestone', project: project_2)
- create(:closed_milestone, title: 'Active Group Milestone', group: group_1)
- create(:closed_milestone, title: 'Closed Group Milestone', group: group_1)
- create(:closed_milestone, title: 'Active Group Milestone', group: group_2)
- create(:closed_milestone, title: 'Closed Group Milestone', group: group_2)
+ create(:active_milestone, title: "Active Group Milestone", project: project_1)
+ create(:closed_milestone, title: "Closed Group Milestone", project: project_1)
+ create(:active_milestone, title: "Active Group Milestone", project: project_2)
+ create(:closed_milestone, title: "Closed Group Milestone", project: project_2)
+ create(:closed_milestone, title: "Active Group Milestone", group: group_1)
+ create(:closed_milestone, title: "Closed Group Milestone", group: group_1)
+ create(:closed_milestone, title: "Active Group Milestone", group: group_2)
+ create(:closed_milestone, title: "Closed Group Milestone", group: group_2)
end
- it 'returns the quantity of milestones in each possible state' do
- expected_count = { opened: 5, closed: 6, all: 11 }
+ it "returns the quantity of milestones in each possible state" do
+ expected_count = {opened: 5, closed: 6, all: 11}
count = described_class.states_count(Project.all, Group.all)
expect(count).to eq(expected_count)
end
end
- context 'when the projects do not have milestones' do
- it 'returns 0 as the quantity of global milestones in each state' do
- expected_count = { opened: 0, closed: 0, all: 0 }
+ context "when the projects do not have milestones" do
+ it "returns 0 as the quantity of global milestones in each state" do
+ expected_count = {opened: 0, closed: 0, all: 0}
count = described_class.states_count([project])
diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb
index 475fbe56e4d..8cc303f5894 100644
--- a/spec/models/namespace_spec.rb
+++ b/spec/models/namespace_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Namespace do
include ProjectForksHelper
@@ -6,16 +6,16 @@ describe Namespace do
let!(:namespace) { create(:namespace) }
let(:gitlab_shell) { Gitlab::Shell.new }
- let(:repository_storage) { 'default' }
+ let(:repository_storage) { "default" }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to have_many :projects }
it { is_expected.to have_many :project_statistics }
it { is_expected.to belong_to :parent }
it { is_expected.to have_many :children }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_most(255) }
it { is_expected.to validate_length_of(:description).is_at_most(255) }
@@ -23,25 +23,25 @@ describe Namespace do
it { is_expected.to validate_length_of(:path).is_at_most(255) }
it { is_expected.to validate_presence_of(:owner) }
- it 'does not allow too deep nesting' do
+ it "does not allow too deep nesting" do
ancestors = (1..21).to_a
nested = build(:namespace, parent: namespace)
allow(nested).to receive(:ancestors).and_return(ancestors)
expect(nested).not_to be_valid
- expect(nested.errors[:parent_id].first).to eq('has too deep level of nesting')
+ expect(nested.errors[:parent_id].first).to eq("has too deep level of nesting")
end
- describe 'reserved path validation' do
- context 'nested group' do
- let(:group) { build(:group, :nested, path: 'tree') }
+ describe "reserved path validation" do
+ context "nested group" do
+ let(:group) { build(:group, :nested, path: "tree") }
it { expect(group).not_to be_valid }
- it 'rejects nested paths' do
- parent = create(:group, :nested, path: 'environments')
- namespace = build(:group, path: 'folders', parent: parent)
+ it "rejects nested paths" do
+ parent = create(:group, :nested, path: "environments")
+ namespace = build(:group, path: "folders", parent: parent)
expect(namespace).not_to be_valid
end
@@ -53,8 +53,8 @@ describe Namespace do
it { expect(group).not_to be_valid }
end
- context 'top-level group' do
- let(:group) { build(:group, path: 'tree') }
+ context "top-level group" do
+ let(:group) { build(:group, path: "tree") }
it { expect(group).to be_valid }
end
@@ -67,23 +67,23 @@ describe Namespace do
it { is_expected.to respond_to(:has_parent?) }
end
- describe 'inclusions' do
+ describe "inclusions" do
it { is_expected.to include_module(Gitlab::VisibilityLevel) }
end
- describe '#visibility_level_field' do
+ describe "#visibility_level_field" do
it { expect(namespace.visibility_level_field).to eq(:visibility_level) }
end
- describe '#to_param' do
+ describe "#to_param" do
it { expect(namespace.to_param).to eq(namespace.full_path) }
end
- describe '#human_name' do
+ describe "#human_name" do
it { expect(namespace.human_name).to eq(namespace.owner_name) }
end
- describe '#first_project_with_container_registry_tags' do
+ describe "#first_project_with_container_registry_tags" do
let(:container_repository) { create(:container_repository) }
let!(:project) { create(:project, namespace: namespace, container_repositories: [container_repository]) }
@@ -91,68 +91,68 @@ describe Namespace do
stub_container_registry_config(enabled: true)
end
- it 'returns the project' do
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ it "returns the project" do
+ stub_container_registry_tags(repository: :any, tags: ["tag"])
expect(namespace.first_project_with_container_registry_tags).to eq(project)
end
- it 'returns no project' do
+ it "returns no project" do
stub_container_registry_tags(repository: :any, tags: nil)
expect(namespace.first_project_with_container_registry_tags).to be_nil
end
end
- describe '.search' do
+ describe ".search" do
let(:namespace) { create(:namespace) }
- it 'returns namespaces with a matching name' do
+ it "returns namespaces with a matching name" do
expect(described_class.search(namespace.name)).to eq([namespace])
end
- it 'returns namespaces with a partially matching name' do
+ it "returns namespaces with a partially matching name" do
expect(described_class.search(namespace.name[0..2])).to eq([namespace])
end
- it 'returns namespaces with a matching name regardless of the casing' do
+ it "returns namespaces with a matching name regardless of the casing" do
expect(described_class.search(namespace.name.upcase)).to eq([namespace])
end
- it 'returns namespaces with a matching path' do
+ it "returns namespaces with a matching path" do
expect(described_class.search(namespace.path)).to eq([namespace])
end
- it 'returns namespaces with a partially matching path' do
+ it "returns namespaces with a partially matching path" do
expect(described_class.search(namespace.path[0..2])).to eq([namespace])
end
- it 'returns namespaces with a matching path regardless of the casing' do
+ it "returns namespaces with a matching path regardless of the casing" do
expect(described_class.search(namespace.path.upcase)).to eq([namespace])
end
end
- describe '.with_statistics' do
+ describe ".with_statistics" do
let(:namespace) { create :namespace }
let(:project1) do
create(:project,
- namespace: namespace,
- statistics: build(:project_statistics,
- storage_size: 606,
- repository_size: 101,
- lfs_objects_size: 202,
- build_artifacts_size: 303))
+ namespace: namespace,
+ statistics: build(:project_statistics,
+ storage_size: 606,
+ repository_size: 101,
+ lfs_objects_size: 202,
+ build_artifacts_size: 303))
end
let(:project2) do
create(:project,
- namespace: namespace,
- statistics: build(:project_statistics,
- storage_size: 60,
- repository_size: 10,
- lfs_objects_size: 20,
- build_artifacts_size: 30))
+ namespace: namespace,
+ statistics: build(:project_statistics,
+ storage_size: 60,
+ repository_size: 10,
+ lfs_objects_size: 20,
+ build_artifacts_size: 30))
end
it "sums all project storage counters in the namespace" do
@@ -176,72 +176,72 @@ describe Namespace do
end
end
- describe '#ancestors_upto', :nested_groups do
+ describe "#ancestors_upto", :nested_groups do
let(:parent) { create(:group) }
let(:child) { create(:group, parent: parent) }
let(:child2) { create(:group, parent: child) }
- it 'returns all ancestors when no namespace is given' do
+ it "returns all ancestors when no namespace is given" do
expect(child2.ancestors_upto).to contain_exactly(child, parent)
end
- it 'includes ancestors upto but excluding the given ancestor' do
+ it "includes ancestors upto but excluding the given ancestor" do
expect(child2.ancestors_upto(parent)).to contain_exactly(child)
end
end
- describe '#move_dir', :request_store do
+ describe "#move_dir", :request_store do
shared_examples "namespace restrictions" do
context "when any project has container images" do
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ stub_container_registry_tags(repository: :any, tags: ["tag"])
create(:project, namespace: namespace, container_repositories: [container_repository])
allow(namespace).to receive(:path_was).and_return(namespace.path)
- allow(namespace).to receive(:path).and_return('new_path')
+ allow(namespace).to receive(:path).and_return("new_path")
end
- it 'raises an error about not movable project' do
+ it "raises an error about not movable project" do
expect { namespace.move_dir }.to raise_error(Gitlab::UpdatePathError,
- /Namespace .* cannot be moved/)
+ /Namespace .* cannot be moved/)
end
end
end
- context 'legacy storage' do
+ context "legacy storage" do
let(:namespace) { create(:namespace) }
let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: namespace) }
- it_behaves_like 'namespace restrictions'
+ it_behaves_like "namespace restrictions"
it "raises error when directory exists" do
expect { namespace.move_dir }.to raise_error("namespace directory cannot be moved")
end
it "moves dir if path changed" do
- namespace.update(path: namespace.full_path + '_new')
+ namespace.update(path: namespace.full_path + "_new")
expect(gitlab_shell.exists?(project.repository_storage, "#{namespace.path}/#{project.path}.git")).to be_truthy
end
- context 'when #write_projects_repository_config raises an error' do
- context 'in test environment' do
- it 'raises an exception' do
- expect(namespace).to receive(:write_projects_repository_config).and_raise('foo')
+ context "when #write_projects_repository_config raises an error" do
+ context "in test environment" do
+ it "raises an exception" do
+ expect(namespace).to receive(:write_projects_repository_config).and_raise("foo")
- expect do
- namespace.update(path: namespace.full_path + '_new')
- end.to raise_error('foo')
+ expect {
+ namespace.update(path: namespace.full_path + "_new")
+ }.to raise_error("foo")
end
end
- context 'in production environment' do
- it 'does not cancel later callbacks' do
- expect(namespace).to receive(:write_projects_repository_config).and_raise('foo')
+ context "in production environment" do
+ it "does not cancel later callbacks" do
+ expect(namespace).to receive(:write_projects_repository_config).and_raise("foo")
expect(namespace).to receive(:move_dir).and_wrap_original do |m, *args|
move_dir_result = m.call(*args)
@@ -251,23 +251,23 @@ describe Namespace do
end
expect(Gitlab::Sentry).to receive(:should_raise_for_dev?).and_return(false) # like prod
- namespace.update(path: namespace.full_path + '_new')
+ namespace.update(path: namespace.full_path + "_new")
end
end
end
- context 'with subgroups', :nested_groups do
- let(:parent) { create(:group, name: 'parent', path: 'parent') }
- let(:new_parent) { create(:group, name: 'new_parent', path: 'new_parent') }
- let(:child) { create(:group, name: 'child', path: 'child', parent: parent) }
- let!(:project) { create(:project_empty_repo, :legacy_storage, path: 'the-project', namespace: child, skip_disk_validation: true) }
+ context "with subgroups", :nested_groups do
+ let(:parent) { create(:group, name: "parent", path: "parent") }
+ let(:new_parent) { create(:group, name: "new_parent", path: "new_parent") }
+ let(:child) { create(:group, name: "child", path: "child", parent: parent) }
+ let!(:project) { create(:project_empty_repo, :legacy_storage, path: "the-project", namespace: child, skip_disk_validation: true) }
let(:uploads_dir) { FileUploader.root }
let(:pages_dir) { File.join(TestEnv.pages_path) }
def expect_project_directories_at(namespace_path)
- expected_repository_path = File.join(TestEnv.repos_path, namespace_path, 'the-project.git')
- expected_upload_path = File.join(uploads_dir, namespace_path, 'the-project')
- expected_pages_path = File.join(pages_dir, namespace_path, 'the-project')
+ expected_repository_path = File.join(TestEnv.repos_path, namespace_path, "the-project.git")
+ expected_upload_path = File.join(uploads_dir, namespace_path, "the-project")
+ expected_pages_path = File.join(pages_dir, namespace_path, "the-project")
expect(File.directory?(expected_repository_path)).to be_truthy
expect(File.directory?(expected_upload_path)).to be_truthy
@@ -280,84 +280,84 @@ describe Namespace do
FileUtils.mkdir_p(File.join(pages_dir, project.full_path))
end
- context 'renaming child' do
- it 'correctly moves the repository, uploads and pages' do
- child.update!(path: 'renamed')
+ context "renaming child" do
+ it "correctly moves the repository, uploads and pages" do
+ child.update!(path: "renamed")
- expect_project_directories_at('parent/renamed')
+ expect_project_directories_at("parent/renamed")
end
end
- context 'renaming parent' do
- it 'correctly moves the repository, uploads and pages' do
- parent.update!(path: 'renamed')
+ context "renaming parent" do
+ it "correctly moves the repository, uploads and pages" do
+ parent.update!(path: "renamed")
- expect_project_directories_at('renamed/child')
+ expect_project_directories_at("renamed/child")
end
end
- context 'moving from one parent to another' do
- it 'correctly moves the repository, uploads and pages' do
+ context "moving from one parent to another" do
+ it "correctly moves the repository, uploads and pages" do
child.update!(parent: new_parent)
- expect_project_directories_at('new_parent/child')
+ expect_project_directories_at("new_parent/child")
end
end
- context 'moving from having a parent to root' do
- it 'correctly moves the repository, uploads and pages' do
+ context "moving from having a parent to root" do
+ it "correctly moves the repository, uploads and pages" do
child.update!(parent: nil)
- expect_project_directories_at('child')
+ expect_project_directories_at("child")
end
end
- context 'moving from root to having a parent' do
- it 'correctly moves the repository, uploads and pages' do
+ context "moving from root to having a parent" do
+ it "correctly moves the repository, uploads and pages" do
parent.update!(parent: new_parent)
- expect_project_directories_at('new_parent/parent/child')
+ expect_project_directories_at("new_parent/parent/child")
end
end
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let(:namespace) { create(:namespace) }
let!(:project) { create(:project_empty_repo, namespace: namespace) }
- it_behaves_like 'namespace restrictions'
+ it_behaves_like "namespace restrictions"
it "repository directory remains unchanged if path changed" do
before_disk_path = project.disk_path
- namespace.update(path: namespace.full_path + '_new')
+ namespace.update(path: namespace.full_path + "_new")
expect(before_disk_path).to eq(project.disk_path)
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_truthy
end
end
- context 'for each project inside the namespace' do
- let!(:parent) { create(:group, name: 'mygroup', path: 'mygroup') }
- let!(:subgroup) { create(:group, name: 'mysubgroup', path: 'mysubgroup', parent: parent) }
- let!(:project_in_parent_group) { create(:project, :legacy_storage, :repository, namespace: parent, name: 'foo1') }
- let!(:hashed_project_in_subgroup) { create(:project, :repository, namespace: subgroup, name: 'foo2') }
- let!(:legacy_project_in_subgroup) { create(:project, :legacy_storage, :repository, namespace: subgroup, name: 'foo3') }
+ context "for each project inside the namespace" do
+ let!(:parent) { create(:group, name: "mygroup", path: "mygroup") }
+ let!(:subgroup) { create(:group, name: "mysubgroup", path: "mysubgroup", parent: parent) }
+ let!(:project_in_parent_group) { create(:project, :legacy_storage, :repository, namespace: parent, name: "foo1") }
+ let!(:hashed_project_in_subgroup) { create(:project, :repository, namespace: subgroup, name: "foo2") }
+ let!(:legacy_project_in_subgroup) { create(:project, :legacy_storage, :repository, namespace: subgroup, name: "foo3") }
- it 'updates project full path in .git/config' do
- parent.update(path: 'mygroup_new')
+ it "updates project full path in .git/config" do
+ parent.update(path: "mygroup_new")
- expect(project_rugged(project_in_parent_group).config['gitlab.fullpath']).to eq "mygroup_new/#{project_in_parent_group.path}"
- expect(project_rugged(hashed_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{hashed_project_in_subgroup.path}"
- expect(project_rugged(legacy_project_in_subgroup).config['gitlab.fullpath']).to eq "mygroup_new/mysubgroup/#{legacy_project_in_subgroup.path}"
+ expect(project_rugged(project_in_parent_group).config["gitlab.fullpath"]).to eq "mygroup_new/#{project_in_parent_group.path}"
+ expect(project_rugged(hashed_project_in_subgroup).config["gitlab.fullpath"]).to eq "mygroup_new/mysubgroup/#{hashed_project_in_subgroup.path}"
+ expect(project_rugged(legacy_project_in_subgroup).config["gitlab.fullpath"]).to eq "mygroup_new/mysubgroup/#{legacy_project_in_subgroup.path}"
end
- it 'updates the project storage location' do
+ it "updates the project storage location" do
repository_project_in_parent_group = create(:project_repository, project: project_in_parent_group)
repository_hashed_project_in_subgroup = create(:project_repository, project: hashed_project_in_subgroup)
repository_legacy_project_in_subgroup = create(:project_repository, project: legacy_project_in_subgroup)
- parent.update(path: 'mygroup_moved')
+ parent.update(path: "mygroup_moved")
expect(repository_project_in_parent_group.reload.disk_path).to eq "mygroup_moved/#{project_in_parent_group.path}"
expect(repository_hashed_project_in_subgroup.reload.disk_path).to eq hashed_project_in_subgroup.disk_path
@@ -374,7 +374,7 @@ describe Namespace do
end
end
- describe '#rm_dir', 'callback' do
+ describe "#rm_dir", "callback" do
let(:repository_storage_path) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
Gitlab.config.repositories.storages.default.legacy_disk_path
@@ -384,10 +384,10 @@ describe Namespace do
let(:deleted_path) { namespace.full_path.gsub(namespace.path, "#{namespace.full_path}+#{namespace.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
- context 'legacy storage' do
+ context "legacy storage" do
let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: namespace) }
- it 'renames its dirs when deleted' do
+ it "renames its dirs when deleted" do
allow(GitlabShellWorker).to receive(:perform_in)
namespace.destroy
@@ -395,21 +395,21 @@ describe Namespace do
expect(File.exist?(deleted_path_in_dir)).to be(true)
end
- it 'schedules the namespace for deletion' do
+ it "schedules the namespace for deletion" do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage, deleted_path)
namespace.destroy
end
- context 'in sub-groups' do
- let(:parent) { create(:group, path: 'parent') }
- let(:child) { create(:group, parent: parent, path: 'child') }
+ context "in sub-groups" do
+ let(:parent) { create(:group, path: "parent") }
+ let(:child) { create(:group, parent: parent, path: "child") }
let!(:project) { create(:project_empty_repo, :legacy_storage, namespace: child) }
- let(:path_in_dir) { File.join(repository_storage_path, 'parent', 'child') }
- let(:deleted_path) { File.join('parent', "child+#{child.id}+deleted") }
+ let(:path_in_dir) { File.join(repository_storage_path, "parent", "child") }
+ let(:deleted_path) { File.join("parent", "child+#{child.id}+deleted") }
let(:deleted_path_in_dir) { File.join(repository_storage_path, deleted_path) }
- it 'renames its dirs when deleted' do
+ it "renames its dirs when deleted" do
allow(GitlabShellWorker).to receive(:perform_in)
child.destroy
@@ -417,7 +417,7 @@ describe Namespace do
expect(File.exist?(deleted_path_in_dir)).to be(true)
end
- it 'schedules the namespace for deletion' do
+ it "schedules the namespace for deletion" do
expect(GitlabShellWorker).to receive(:perform_in).with(5.minutes, :rm_namespace, repository_storage, deleted_path)
child.destroy
@@ -425,10 +425,10 @@ describe Namespace do
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let!(:project) { create(:project_empty_repo, namespace: namespace) }
- it 'has no repositories base directories to remove' do
+ it "has no repositories base directories to remove" do
allow(GitlabShellWorker).to receive(:perform_in)
expect(File.exist?(path_in_dir)).to be(false)
@@ -440,14 +440,14 @@ describe Namespace do
end
end
- describe '.find_by_path_or_name' do
+ describe ".find_by_path_or_name" do
before do
- @namespace = create(:namespace, name: 'WoW', path: 'woW')
+ @namespace = create(:namespace, name: "WoW", path: "woW")
end
- it { expect(described_class.find_by_path_or_name('wow')).to eq(@namespace) }
- it { expect(described_class.find_by_path_or_name('WOW')).to eq(@namespace) }
- it { expect(described_class.find_by_path_or_name('unknown')).to eq(nil) }
+ it { expect(described_class.find_by_path_or_name("wow")).to eq(@namespace) }
+ it { expect(described_class.find_by_path_or_name("WOW")).to eq(@namespace) }
+ it { expect(described_class.find_by_path_or_name("unknown")).to eq(nil) }
end
describe ".clean_path" do
@@ -460,28 +460,28 @@ describe Namespace do
end
end
- describe '#self_and_hierarchy', :nested_groups do
- let!(:group) { create(:group, path: 'git_lab') }
+ describe "#self_and_hierarchy", :nested_groups do
+ let!(:group) { create(:group, path: "git_lab") }
let!(:nested_group) { create(:group, parent: group) }
let!(:deep_nested_group) { create(:group, parent: nested_group) }
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- let!(:another_group) { create(:group, path: 'gitllab') }
- let!(:another_group_nested) { create(:group, path: 'foo', parent: another_group) }
+ let!(:another_group) { create(:group, path: "gitllab") }
+ let!(:another_group_nested) { create(:group, path: "foo", parent: another_group) }
- it 'returns the correct tree' do
+ it "returns the correct tree" do
expect(group.self_and_hierarchy).to contain_exactly(group, nested_group, deep_nested_group, very_deep_nested_group)
expect(nested_group.self_and_hierarchy).to contain_exactly(group, nested_group, deep_nested_group, very_deep_nested_group)
expect(very_deep_nested_group.self_and_hierarchy).to contain_exactly(group, nested_group, deep_nested_group, very_deep_nested_group)
end
end
- describe '#ancestors', :nested_groups do
+ describe "#ancestors", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
let(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- it 'returns the correct ancestors' do
+ it "returns the correct ancestors" do
expect(very_deep_nested_group.ancestors).to include(group, nested_group, deep_nested_group)
expect(deep_nested_group.ancestors).to include(group, nested_group)
expect(nested_group.ancestors).to include(group)
@@ -489,13 +489,13 @@ describe Namespace do
end
end
- describe '#self_and_ancestors', :nested_groups do
+ describe "#self_and_ancestors", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
let(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- it 'returns the correct ancestors' do
+ it "returns the correct ancestors" do
expect(very_deep_nested_group.self_and_ancestors).to contain_exactly(group, nested_group, deep_nested_group, very_deep_nested_group)
expect(deep_nested_group.self_and_ancestors).to contain_exactly(group, nested_group, deep_nested_group)
expect(nested_group.self_and_ancestors).to contain_exactly(group, nested_group)
@@ -503,15 +503,15 @@ describe Namespace do
end
end
- describe '#descendants', :nested_groups do
- let!(:group) { create(:group, path: 'git_lab') }
+ describe "#descendants", :nested_groups do
+ let!(:group) { create(:group, path: "git_lab") }
let!(:nested_group) { create(:group, parent: group) }
let!(:deep_nested_group) { create(:group, parent: nested_group) }
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- let!(:another_group) { create(:group, path: 'gitllab') }
- let!(:another_group_nested) { create(:group, path: 'foo', parent: another_group) }
+ let!(:another_group) { create(:group, path: "gitllab") }
+ let!(:another_group_nested) { create(:group, path: "foo", parent: another_group) }
- it 'returns the correct descendants' do
+ it "returns the correct descendants" do
expect(very_deep_nested_group.descendants.to_a).to eq([])
expect(deep_nested_group.descendants.to_a).to include(very_deep_nested_group)
expect(nested_group.descendants.to_a).to include(deep_nested_group, very_deep_nested_group)
@@ -519,15 +519,15 @@ describe Namespace do
end
end
- describe '#self_and_descendants', :nested_groups do
- let!(:group) { create(:group, path: 'git_lab') }
+ describe "#self_and_descendants", :nested_groups do
+ let!(:group) { create(:group, path: "git_lab") }
let!(:nested_group) { create(:group, parent: group) }
let!(:deep_nested_group) { create(:group, parent: nested_group) }
let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) }
- let!(:another_group) { create(:group, path: 'gitllab') }
- let!(:another_group_nested) { create(:group, path: 'foo', parent: another_group) }
+ let!(:another_group) { create(:group, path: "gitllab") }
+ let!(:another_group_nested) { create(:group, path: "foo", parent: another_group) }
- it 'returns the correct descendants' do
+ it "returns the correct descendants" do
expect(very_deep_nested_group.self_and_descendants).to contain_exactly(very_deep_nested_group)
expect(deep_nested_group.self_and_descendants).to contain_exactly(deep_nested_group, very_deep_nested_group)
expect(nested_group.self_and_descendants).to contain_exactly(nested_group, deep_nested_group, very_deep_nested_group)
@@ -535,7 +535,7 @@ describe Namespace do
end
end
- describe '#users_with_descendants', :nested_groups do
+ describe "#users_with_descendants", :nested_groups do
let(:user_a) { create(:user) }
let(:user_b) { create(:user) }
@@ -543,7 +543,7 @@ describe Namespace do
let(:nested_group) { create(:group, parent: group) }
let(:deep_nested_group) { create(:group, parent: nested_group) }
- it 'returns member users on every nest level without duplication' do
+ it "returns member users on every nest level without duplication" do
group.add_developer(user_a)
nested_group.add_developer(user_b)
deep_nested_group.add_maintainer(user_a)
@@ -554,14 +554,14 @@ describe Namespace do
end
end
- describe '#user_ids_for_project_authorizations' do
- it 'returns the user IDs for which to refresh authorizations' do
+ describe "#user_ids_for_project_authorizations" do
+ it "returns the user IDs for which to refresh authorizations" do
expect(namespace.user_ids_for_project_authorizations)
.to eq([namespace.owner_id])
end
end
- describe '#all_projects' do
+ describe "#all_projects" do
let(:group) { create(:group) }
let(:child) { create(:group, parent: group) }
let!(:project1) { create(:project_empty_repo, namespace: group) }
@@ -571,7 +571,7 @@ describe Namespace do
it { expect(child.all_projects.to_a).to match_array([project2]) }
end
- describe '#all_pipelines' do
+ describe "#all_pipelines" do
let(:group) { create(:group) }
let(:child) { create(:group, parent: group) }
let!(:project1) { create(:project_empty_repo, namespace: group) }
@@ -582,9 +582,9 @@ describe Namespace do
it { expect(group.all_pipelines.to_a).to match_array([pipeline1, pipeline2]) }
end
- describe '#share_with_group_lock with subgroups', :nested_groups do
- context 'when creating a subgroup' do
- let(:subgroup) { create(:group, parent: root_group )}
+ describe "#share_with_group_lock with subgroups", :nested_groups do
+ context "when creating a subgroup" do
+ let(:subgroup) { create(:group, parent: root_group)}
context 'under a parent with "Share with group lock" enabled' do
let(:root_group) { create(:group, share_with_group_lock: true) }
@@ -605,7 +605,7 @@ describe Namespace do
context 'when enabling the parent group "Share with group lock"' do
let(:root_group) { create(:group) }
- let!(:subgroup) { create(:group, parent: root_group )}
+ let!(:subgroup) { create(:group, parent: root_group)}
it 'the subgroup "Share with group lock" becomes enabled' do
root_group.update!(share_with_group_lock: true)
@@ -618,7 +618,7 @@ describe Namespace do
let(:root_group) { create(:group, share_with_group_lock: true) }
context 'and the subgroup "Share with group lock" is enabled' do
- let(:subgroup) { create(:group, parent: root_group, share_with_group_lock: true )}
+ let(:subgroup) { create(:group, parent: root_group, share_with_group_lock: true)}
it 'the subgroup "Share with group lock" does not change' do
root_group.update!(share_with_group_lock: false)
@@ -628,7 +628,7 @@ describe Namespace do
end
context 'but the subgroup "Share with group lock" is disabled' do
- let(:subgroup) { create(:group, parent: root_group )}
+ let(:subgroup) { create(:group, parent: root_group)}
it 'the subgroup "Share with group lock" does not change' do
root_group.update!(share_with_group_lock: false)
@@ -638,12 +638,12 @@ describe Namespace do
end
end
- context 'when a group is transferred into a root group' do
+ context "when a group is transferred into a root group" do
context 'when the root group "Share with group lock" is enabled' do
let(:root_group) { create(:group, share_with_group_lock: true) }
context 'when the subgroup "Share with group lock" is enabled' do
- let(:subgroup) { create(:group, share_with_group_lock: true )}
+ let(:subgroup) { create(:group, share_with_group_lock: true)}
it 'the subgroup "Share with group lock" does not change' do
subgroup.parent = root_group
@@ -669,7 +669,7 @@ describe Namespace do
let(:root_group) { create(:group) }
context 'when the subgroup "Share with group lock" is enabled' do
- let(:subgroup) { create(:group, share_with_group_lock: true )}
+ let(:subgroup) { create(:group, share_with_group_lock: true)}
it 'the subgroup "Share with group lock" does not change' do
subgroup.parent = root_group
@@ -693,7 +693,7 @@ describe Namespace do
end
end
- describe '#find_fork_of?' do
+ describe "#find_fork_of?" do
let(:project) { create(:project, :public) }
let!(:forked_project) { fork_project(project, namespace.owner, namespace: namespace) }
@@ -702,19 +702,19 @@ describe Namespace do
project.reload
end
- it 'knows if there is a direct fork in the namespace' do
+ it "knows if there is a direct fork in the namespace" do
expect(namespace.find_fork_of(project)).to eq(forked_project)
end
- it 'knows when there is as fork-of-fork in the namespace' do
+ it "knows when there is as fork-of-fork in the namespace" do
other_namespace = create(:namespace)
other_fork = fork_project(forked_project, other_namespace.owner, namespace: other_namespace)
expect(other_namespace.find_fork_of(project)).to eq(other_fork)
end
- context 'with request store enabled', :request_store do
- it 'only queries once' do
+ context "with request store enabled", :request_store do
+ it "only queries once" do
expect(project.fork_network).to receive(:find_forks_in).once.and_call_original
2.times { namespace.find_fork_of(project) }
@@ -722,8 +722,8 @@ describe Namespace do
end
end
- describe '#root_ancestor' do
- it 'returns the top most ancestor', :nested_groups do
+ describe "#root_ancestor" do
+ it "returns the top most ancestor", :nested_groups do
root_group = create(:group)
nested_group = create(:group, parent: root_group)
deep_nested_group = create(:group, parent: nested_group)
@@ -736,27 +736,27 @@ describe Namespace do
end
end
- describe '#full_path_was' do
- context 'when the group has no parent' do
- it 'should return the path was' do
+ describe "#full_path_was" do
+ context "when the group has no parent" do
+ it "should return the path was" do
group = create(:group, parent: nil)
expect(group.full_path_was).to eq(group.path_was)
end
end
- context 'when a parent is assigned to a group with no previous parent' do
- it 'should return the path was' do
+ context "when a parent is assigned to a group with no previous parent" do
+ it "should return the path was" do
group = create(:group, parent: nil)
parent = create(:group)
group.parent = parent
- expect(group.full_path_was).to eq("#{group.path_was}")
+ expect(group.full_path_was).to eq(group.path_was.to_s)
end
end
- context 'when a parent is removed from the group' do
- it 'should return the parent full path' do
+ context "when a parent is removed from the group" do
+ it "should return the parent full path" do
parent = create(:group)
group = create(:group, parent: parent)
group.parent = nil
@@ -765,8 +765,8 @@ describe Namespace do
end
end
- context 'when changing parents' do
- it 'should return the previous parent full path' do
+ context "when changing parents" do
+ it "should return the previous parent full path" do
parent = create(:group)
group = create(:group, parent: parent)
new_parent = create(:group)
diff --git a/spec/models/network/graph_spec.rb b/spec/models/network/graph_spec.rb
index c364dd6643b..662ed252b5e 100644
--- a/spec/models/network/graph_spec.rb
+++ b/spec/models/network/graph_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe Network::Graph do
let(:project) { create(:project, :repository) }
let!(:note_on_commit) { create(:note_on_commit, project: project) }
- it '#initialize' do
- graph = described_class.new(project, 'refs/heads/master', project.repository.commit, nil)
+ it "#initialize" do
+ graph = described_class.new(project, "refs/heads/master", project.repository.commit, nil)
- expect(graph.notes).to eq( { note_on_commit.commit_id => 1 } )
+ expect(graph.notes).to eq({note_on_commit.commit_id => 1})
end
- describe '#commits' do
- let(:graph) { described_class.new(project, 'refs/heads/master', project.repository.commit, nil) }
+ describe "#commits" do
+ let(:graph) { described_class.new(project, "refs/heads/master", project.repository.commit, nil) }
- it 'returns a list of commits' do
+ it "returns a list of commits" do
commits = graph.commits
expect(commits).not_to be_empty
- expect(commits).to all( be_kind_of(Network::Commit) )
+ expect(commits).to all(be_kind_of(Network::Commit))
end
- it 'it the commits by commit date (descending)' do
+ it "it the commits by commit date (descending)" do
# Remove duplicate timestamps because they make it harder to
# assert that the commits are sorted as expected.
commits = graph.commits.uniq(&:date)
@@ -30,7 +30,7 @@ describe Network::Graph do
expect(commits.map(&:id)).to eq(sorted_commits.map(&:id))
end
- it 'sorts children before parents for commits with the same timestamp' do
+ it "sorts children before parents for commits with the same timestamp" do
commits_by_time = graph.commits.group_by(&:date)
commits_by_time.each do |time, commits|
@@ -40,7 +40,7 @@ describe Network::Graph do
parent_indexes = commit.parent_ids.map { |parent_id| commit_ids.find_index(parent_id) }.compact
# All parents of the current commit should appear after it
- expect(parent_indexes).to all( be > index )
+ expect(parent_indexes).to all(be > index)
end
end
end
diff --git a/spec/models/note_diff_file_spec.rb b/spec/models/note_diff_file_spec.rb
index 591c1a89748..c3676041018 100644
--- a/spec/models/note_diff_file_spec.rb
+++ b/spec/models/note_diff_file_spec.rb
@@ -1,11 +1,11 @@
-require 'rails_helper'
+require "rails_helper"
describe NoteDiffFile do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:diff_note) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:diff_note) }
end
end
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 385b8a7959f..4e3e6477455 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Note do
include RepoHelpers
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:noteable).touch(false) }
- it { is_expected.to belong_to(:author).class_name('User') }
+ it { is_expected.to belong_to(:author).class_name("User") }
it { is_expected.to have_many(:todos) }
end
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Participable) }
@@ -19,11 +19,11 @@ describe Note do
it { is_expected.to include_module(Awardable) }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:note) }
it { is_expected.to validate_presence_of(:project) }
- context 'when note is on commit' do
+ context "when note is on commit" do
before do
allow(subject).to receive(:for_commit?).and_return(true)
end
@@ -32,7 +32,7 @@ describe Note do
it { is_expected.not_to validate_presence_of(:noteable_id) }
end
- context 'when note is not on commit' do
+ context "when note is not on commit" do
before do
allow(subject).to receive(:for_commit?).and_return(false)
end
@@ -41,7 +41,7 @@ describe Note do
it { is_expected.to validate_presence_of(:noteable_id) }
end
- context 'when noteable and note project differ' do
+ context "when noteable and note project differ" do
subject do
build(:note, noteable: build_stubbed(:issue),
project: build_stubbed(:project))
@@ -50,20 +50,20 @@ describe Note do
it { is_expected.to be_invalid }
end
- context 'when noteable and note project are the same' do
+ context "when noteable and note project are the same" do
subject { create(:note) }
it { is_expected.to be_valid }
end
- context 'when project is missing for a project related note' do
+ context "when project is missing for a project related note" do
subject { build(:note, project: nil, noteable: build_stubbed(:issue)) }
it { is_expected.to be_invalid }
end
- context 'when noteable is a personal snippet' do
+ context "when noteable is a personal snippet" do
subject { build(:note_on_personal_snippet) }
- it 'is valid without project' do
+ it "is valid without project" do
is_expected.to be_valid
end
end
@@ -92,7 +92,7 @@ describe Note do
expect(note.project.repository.kept_around?(commit.id)).to be_truthy
end
- it 'does not generate N+1 queries for participants', :request_store do
+ it "does not generate N+1 queries for participants", :request_store do
def retrieve_participants
commit.notes_with_associations.map(&:participants).to_a
end
@@ -100,17 +100,17 @@ describe Note do
# Project authorization checks are cached, establish a baseline
retrieve_participants
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
retrieve_participants
- end
+ }
- create(:note_on_commit, project: note.project, note: 'another note', noteable_id: commit.id)
+ create(:note_on_commit, project: note.project, note: "another note", noteable_id: commit.id)
expect { retrieve_participants }.not_to exceed_query_limit(control_count)
end
end
- describe 'authorization' do
+ describe "authorization" do
before do
@p1 = create(:project)
@p2 = create(:project)
@@ -119,7 +119,7 @@ describe Note do
@u3 = create(:user)
end
- describe 'read' do
+ describe "read" do
before do
@p1.project_members.create(user: @u2, access_level: ProjectMember::GUEST)
@p2.project_members.create(user: @u3, access_level: ProjectMember::GUEST)
@@ -130,7 +130,7 @@ describe Note do
it { expect(Ability.allowed?(@u3, :read_note, @p1)).to be_falsey }
end
- describe 'write' do
+ describe "write" do
before do
@p1.project_members.create(user: @u2, access_level: ProjectMember::DEVELOPER)
@p2.project_members.create(user: @u3, access_level: ProjectMember::DEVELOPER)
@@ -141,7 +141,7 @@ describe Note do
it { expect(Ability.allowed?(@u3, :create_note, @p1)).to be_falsey }
end
- describe 'admin' do
+ describe "admin" do
before do
@p1.project_members.create(user: @u1, access_level: ProjectMember::REPORTER)
@p1.project_members.create(user: @u2, access_level: ProjectMember::MAINTAINER)
@@ -154,7 +154,7 @@ describe Note do
end
end
- it_behaves_like 'an editable mentionable' do
+ it_behaves_like "an editable mentionable" do
subject { create :note, noteable: issue, project: issue.project }
let(:issue) { create(:issue, project: create(:project, :repository)) }
@@ -175,8 +175,8 @@ describe Note do
pipeline: :note,
cache_key: [note1, "note"],
project: note1.project,
- author: note1.author
- }
+ author: note1.author,
+ },
}]).and_call_original
expect(Banzai::Renderer).to receive(:cache_collection_render)
@@ -187,8 +187,8 @@ describe Note do
pipeline: :note,
cache_key: [note2, "note"],
project: note2.project,
- author: note2.author
- }
+ author: note2.author,
+ },
}]).and_call_original
note1.all_references.users
@@ -288,19 +288,19 @@ describe Note do
end
end
- describe '#cross_reference?' do
- it 'falsey for user-generated notes' do
+ describe "#cross_reference?" do
+ it "falsey for user-generated notes" do
note = create(:note, system: false)
expect(note.cross_reference?).to be_falsy
end
- context 'when the note might contain cross references' do
+ context "when the note might contain cross references" do
SystemNoteMetadata.new.cross_reference_types.each do |type|
let(:note) { create(:note, :system) }
let!(:metadata) { create(:system_note_metadata, note: note, action: type) }
- it 'delegates to the cross-reference regex' do
+ it "delegates to the cross-reference regex" do
expect(note).to receive(:matches_cross_reference_regex?).and_return(false)
note.cross_reference?
@@ -308,27 +308,27 @@ describe Note do
end
end
- context 'when the note cannot contain cross references' do
- let(:commit_note) { build(:note, note: 'mentioned in 1312312313 something else.', system: true) }
- let(:label_note) { build(:note, note: 'added ~2323232323', system: true) }
+ context "when the note cannot contain cross references" do
+ let(:commit_note) { build(:note, note: "mentioned in 1312312313 something else.", system: true) }
+ let(:label_note) { build(:note, note: "added ~2323232323", system: true) }
- it 'scan for a `mentioned in` prefix' do
+ it "scan for a `mentioned in` prefix" do
expect(commit_note.cross_reference?).to be_truthy
expect(label_note.cross_reference?).to be_falsy
end
end
end
- describe 'clear_blank_line_code!' do
- it 'clears a blank line code before validation' do
- note = build(:note, line_code: ' ')
+ describe "clear_blank_line_code!" do
+ it "clears a blank line code before validation" do
+ note = build(:note, line_code: " ")
expect { note.valid? }.to change(note, :line_code).to(nil)
end
end
- describe '#participants' do
- it 'includes the note author' do
+ describe "#participants" do
+ it "includes the note author" do
project = create(:project, :public)
issue = create(:issue, project: project)
note = create(:note_on_issue, noteable: issue, project: project)
@@ -337,12 +337,12 @@ describe Note do
end
end
- describe '.find_discussion' do
+ describe ".find_discussion" do
let!(:note) { create(:discussion_note_on_merge_request) }
let!(:note2) { create(:discussion_note_on_merge_request, in_reply_to: note) }
let(:merge_request) { note.noteable }
- it 'returns a discussion with multiple notes' do
+ it "returns a discussion with multiple notes" do
discussion = merge_request.notes.find_discussion(note.discussion_id)
expect(discussion).not_to be_nil
@@ -380,7 +380,7 @@ describe Note do
)
end
- context 'active diff discussions' do
+ context "active diff discussions" do
subject { merge_request.notes.grouped_diff_discussions }
it "includes active discussions" do
@@ -403,7 +403,7 @@ describe Note do
expect(subject[active_diff_note3.line_code].first.id).to eq(active_diff_note3.discussion_id)
end
- context 'with image discussions' do
+ context "with image discussions" do
let(:merge_request2) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, title: "Added images and changes") }
let(:image_path) { "files/images/ee_repo_logo.png" }
let(:text_path) { "bar/branch-test.txt" }
@@ -454,10 +454,10 @@ describe Note do
end
end
- context 'diff discussions for older diff refs' do
+ context "diff discussions for older diff refs" do
subject { merge_request.notes.grouped_diff_discussions(diff_refs) }
- context 'for diff refs a discussion was created at' do
+ context "for diff refs a discussion was created at" do
let(:diff_refs) { active_position2.diff_refs }
it "includes discussions that were created then" do
@@ -480,7 +480,7 @@ describe Note do
end
end
- context 'for diff refs a discussion was last active at' do
+ context "for diff refs a discussion was last active at" do
let(:diff_refs) { outdated_position.diff_refs }
it "includes discussions that were last active" do
@@ -505,123 +505,123 @@ describe Note do
end
end
- describe '#for_personal_snippet?' do
- it 'returns false for a project snippet note' do
+ describe "#for_personal_snippet?" do
+ it "returns false for a project snippet note" do
expect(build(:note_on_project_snippet).for_personal_snippet?).to be_falsy
end
- it 'returns true for a personal snippet note' do
+ it "returns true for a personal snippet note" do
expect(build(:note_on_personal_snippet).for_personal_snippet?).to be_truthy
end
end
- describe '#to_ability_name' do
- it 'returns snippet for a project snippet note' do
- expect(build(:note_on_project_snippet).to_ability_name).to eq('project_snippet')
+ describe "#to_ability_name" do
+ it "returns snippet for a project snippet note" do
+ expect(build(:note_on_project_snippet).to_ability_name).to eq("project_snippet")
end
- it 'returns personal_snippet for a personal snippet note' do
- expect(build(:note_on_personal_snippet).to_ability_name).to eq('personal_snippet')
+ it "returns personal_snippet for a personal snippet note" do
+ expect(build(:note_on_personal_snippet).to_ability_name).to eq("personal_snippet")
end
- it 'returns merge_request for an MR note' do
- expect(build(:note_on_merge_request).to_ability_name).to eq('merge_request')
+ it "returns merge_request for an MR note" do
+ expect(build(:note_on_merge_request).to_ability_name).to eq("merge_request")
end
- it 'returns issue for an issue note' do
- expect(build(:note_on_issue).to_ability_name).to eq('issue')
+ it "returns issue for an issue note" do
+ expect(build(:note_on_issue).to_ability_name).to eq("issue")
end
- it 'returns issue for a commit note' do
- expect(build(:note_on_commit).to_ability_name).to eq('commit')
+ it "returns issue for a commit note" do
+ expect(build(:note_on_commit).to_ability_name).to eq("commit")
end
end
- describe '#cache_markdown_field' do
- let(:html) { '<p>some html</p>'}
+ describe "#cache_markdown_field" do
+ let(:html) { "<p>some html</p>"}
- context 'note for a project snippet' do
+ context "note for a project snippet" do
let(:note) { build(:note_on_project_snippet) }
before do
expect(Banzai::Renderer).to receive(:cacheless_render_field)
- .with(note, :note, { skip_project_check: false }).and_return(html)
+ .with(note, :note, {skip_project_check: false}).and_return(html)
note.save
end
- it 'creates a note' do
+ it "creates a note" do
expect(note.note_html).to eq(html)
end
end
- context 'note for a personal snippet' do
+ context "note for a personal snippet" do
let(:note) { build(:note_on_personal_snippet) }
before do
expect(Banzai::Renderer).to receive(:cacheless_render_field)
- .with(note, :note, { skip_project_check: true }).and_return(html)
+ .with(note, :note, {skip_project_check: true}).and_return(html)
note.save
end
- it 'creates a note' do
+ it "creates a note" do
expect(note.note_html).to eq(html)
end
end
end
- describe '#can_be_discussion_note?' do
- context 'for a note on a merge request' do
- it 'returns true' do
+ describe "#can_be_discussion_note?" do
+ context "for a note on a merge request" do
+ it "returns true" do
note = build(:note_on_merge_request)
expect(note.can_be_discussion_note?).to be_truthy
end
end
- context 'for a note on an issue' do
- it 'returns true' do
+ context "for a note on an issue" do
+ it "returns true" do
note = build(:note_on_issue)
expect(note.can_be_discussion_note?).to be_truthy
end
end
- context 'for a note on a commit' do
- it 'returns true' do
+ context "for a note on a commit" do
+ it "returns true" do
note = build(:note_on_commit)
expect(note.can_be_discussion_note?).to be_truthy
end
end
- context 'for a note on a snippet' do
- it 'returns true' do
+ context "for a note on a snippet" do
+ it "returns true" do
note = build(:note_on_project_snippet)
expect(note.can_be_discussion_note?).to be_truthy
end
end
- context 'for a diff note on merge request' do
- it 'returns false' do
+ context "for a diff note on merge request" do
+ it "returns false" do
note = build(:diff_note_on_merge_request)
expect(note.can_be_discussion_note?).to be_falsey
end
end
- context 'for a diff note on commit' do
- it 'returns false' do
+ context "for a diff note on commit" do
+ it "returns false" do
note = build(:diff_note_on_commit)
expect(note.can_be_discussion_note?).to be_falsey
end
end
- context 'for a discussion note' do
- it 'returns false' do
+ context "for a discussion note" do
+ it "returns false" do
note = build(:discussion_note_on_merge_request)
expect(note.can_be_discussion_note?).to be_falsey
@@ -629,18 +629,18 @@ describe Note do
end
end
- describe '#discussion_class' do
+ describe "#discussion_class" do
let(:note) { build(:note_on_commit) }
let(:merge_request) { create(:merge_request) }
- context 'when the note is displayed out of context' do
- it 'returns OutOfContextDiscussion' do
+ context "when the note is displayed out of context" do
+ it "returns OutOfContextDiscussion" do
expect(note.discussion_class(merge_request)).to be(OutOfContextDiscussion)
end
end
- context 'when the note is displayed in the original context' do
- it 'returns IndividualNoteDiscussion' do
+ context "when the note is displayed in the original context" do
+ it "returns IndividualNoteDiscussion" do
expect(note.discussion_class(note.noteable)).to be(IndividualNoteDiscussion)
end
end
@@ -670,16 +670,16 @@ describe Note do
end
end
- context 'when the note is displayed out of context' do
+ context "when the note is displayed out of context" do
let(:merge_request) { create(:merge_request) }
- it 'overrides the discussion id' do
+ it "overrides the discussion id" do
expect(note.discussion_id(merge_request)).not_to eq(note.discussion_id)
end
end
end
- describe '#to_discussion' do
+ describe "#to_discussion" do
subject { create(:discussion_note_on_merge_request) }
let!(:note2) { create(:discussion_note_on_merge_request, project: subject.project, noteable: subject.noteable, in_reply_to: subject) }
@@ -695,7 +695,7 @@ describe Note do
let!(:note1) { create(:discussion_note_on_merge_request) }
let!(:note2) { create(:diff_note_on_merge_request, project: note1.project, noteable: note1.noteable) }
- context 'when the note is part of a discussion' do
+ context "when the note is part of a discussion" do
subject { create(:discussion_note_on_merge_request, project: note1.project, noteable: note1.noteable, in_reply_to: note1) }
it "returns the discussion this note is in" do
@@ -706,7 +706,7 @@ describe Note do
end
end
- context 'when the note is not part of a discussion' do
+ context "when the note is not part of a discussion" do
subject { create(:note) }
it "returns a discussion with just this note" do
@@ -719,38 +719,38 @@ describe Note do
end
describe "#part_of_discussion?" do
- context 'for a regular note' do
+ context "for a regular note" do
let(:note) { build(:note) }
- it 'returns false' do
+ it "returns false" do
expect(note.part_of_discussion?).to be_falsey
end
end
- context 'for a diff note' do
+ context "for a diff note" do
let(:note) { build(:diff_note_on_commit) }
- it 'returns true' do
+ it "returns true" do
expect(note.part_of_discussion?).to be_truthy
end
end
- context 'for a discussion note' do
+ context "for a discussion note" do
let(:note) { build(:discussion_note_on_merge_request) }
- it 'returns true' do
+ it "returns true" do
expect(note.part_of_discussion?).to be_truthy
end
end
end
- describe '#in_reply_to?' do
- context 'for a note' do
- context 'when part of a discussion' do
+ describe "#in_reply_to?" do
+ context "for a note" do
+ context "when part of a discussion" do
subject { create(:discussion_note_on_issue) }
let(:note) { create(:discussion_note_on_issue, in_reply_to: subject) }
- it 'checks if the note is in reply to the other discussion' do
+ it "checks if the note is in reply to the other discussion" do
expect(subject).to receive(:in_reply_to?).with(note).and_call_original
expect(subject).to receive(:in_reply_to?).with(note.noteable).and_call_original
expect(subject).to receive(:in_reply_to?).with(note.to_discussion).and_call_original
@@ -759,11 +759,11 @@ describe Note do
end
end
- context 'when not part of a discussion' do
+ context "when not part of a discussion" do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
- it 'checks if the note is in reply to the other noteable' do
+ it "checks if the note is in reply to the other noteable" do
expect(subject).to receive(:in_reply_to?).with(note).and_call_original
expect(subject).to receive(:in_reply_to?).with(note.noteable).and_call_original
@@ -772,50 +772,50 @@ describe Note do
end
end
- context 'for a discussion' do
- context 'when part of the same discussion' do
+ context "for a discussion" do
+ context "when part of the same discussion" do
subject { create(:diff_note_on_merge_request) }
let(:note) { create(:diff_note_on_merge_request, in_reply_to: subject) }
- it 'returns true' do
+ it "returns true" do
expect(subject.in_reply_to?(note.to_discussion)).to be_truthy
end
end
- context 'when not part of the same discussion' do
+ context "when not part of the same discussion" do
subject { create(:diff_note_on_merge_request) }
let(:note) { create(:diff_note_on_merge_request) }
- it 'returns false' do
+ it "returns false" do
expect(subject.in_reply_to?(note.to_discussion)).to be_falsey
end
end
end
- context 'for a noteable' do
- context 'when a comment on the same noteable' do
+ context "for a noteable" do
+ context "when a comment on the same noteable" do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
- it 'returns true' do
+ it "returns true" do
expect(subject.in_reply_to?(note.noteable)).to be_truthy
end
end
- context 'when not a comment on the same noteable' do
+ context "when not a comment on the same noteable" do
subject { create(:note) }
let(:note) { create(:note) }
- it 'returns false' do
+ it "returns false" do
expect(subject.in_reply_to?(note.noteable)).to be_falsey
end
end
end
end
- describe '#references' do
- context 'when part of a discussion' do
- it 'references all earlier notes in the discussion' do
+ describe "#references" do
+ context "when part of a discussion" do
+ it "references all earlier notes in the discussion" do
first_note = create(:discussion_note_on_issue)
second_note = create(:discussion_note_on_issue, in_reply_to: first_note)
third_note = create(:discussion_note_on_issue, in_reply_to: second_note)
@@ -825,17 +825,17 @@ describe Note do
end
end
- context 'when not part of a discussion' do
+ context "when not part of a discussion" do
subject { create(:note) }
let(:note) { create(:note, in_reply_to: subject) }
- it 'returns the noteable' do
+ it "returns the noteable" do
expect(note.references).to eq([note.noteable])
end
end
end
- describe 'expiring ETag cache' do
+ describe "expiring ETag cache" do
let(:note) { build(:note_on_issue) }
def expect_expiration(note)
@@ -856,8 +856,8 @@ describe Note do
note.destroy!
end
- context 'when issuable etag caching is disabled' do
- it 'does not store cache key' do
+ context "when issuable etag caching is disabled" do
+ it "does not store cache key" do
allow(note.noteable).to receive(:etag_caching_enabled?).and_return(false)
expect_any_instance_of(Gitlab::EtagCaching::Store).not_to receive(:touch)
@@ -866,23 +866,23 @@ describe Note do
end
end
- describe '#with_notes_filter' do
+ describe "#with_notes_filter" do
let!(:comment) { create(:note) }
let!(:system_note) { create(:note, system: true) }
- context 'when notes filter is nil' do
+ context "when notes filter is nil" do
subject { described_class.with_notes_filter(nil) }
it { is_expected.to include(comment, system_note) }
end
- context 'when notes filter is set to all notes' do
+ context "when notes filter is set to all notes" do
subject { described_class.with_notes_filter(UserPreference::NOTES_FILTERS[:all_notes]) }
it { is_expected.to include(comment, system_note) }
end
- context 'when notes filter is set to only comments' do
+ context "when notes filter is set to only comments" do
subject { described_class.with_notes_filter(UserPreference::NOTES_FILTERS[:only_comments]) }
it { is_expected.to include(comment) }
@@ -891,15 +891,15 @@ describe Note do
end
end
- describe '#parent' do
- it 'returns project for project notes' do
+ describe "#parent" do
+ it "returns project for project notes" do
project = create(:project)
note = create(:note_on_issue, project: project)
expect(note.parent).to eq(project)
end
- it 'returns nil for personal snippet note' do
+ it "returns nil for personal snippet note" do
note = create(:note_on_personal_snippet)
expect(note.parent).to be_nil
diff --git a/spec/models/notification_recipient_spec.rb b/spec/models/notification_recipient_spec.rb
index 13fe47799ed..b06f4558099 100644
--- a/spec/models/notification_recipient_spec.rb
+++ b/spec/models/notification_recipient_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NotificationRecipient do
let(:user) { create(:user) }
@@ -7,15 +7,15 @@ describe NotificationRecipient do
subject(:recipient) { described_class.new(user, :watch, target: target, project: project) }
- it 'denies access to a target when cross project access is denied' do
+ it "denies access to a target when cross project access is denied" do
allow(Ability).to receive(:allowed?).and_call_original
expect(Ability).to receive(:allowed?).with(user, :read_cross_project, :global).and_return(false)
expect(recipient.has_access?).to be_falsy
end
- context '#notification_setting' do
- context 'for child groups', :nested_groups do
+ context "#notification_setting" do
+ context "for child groups", :nested_groups do
let!(:moved_group) { create(:group) }
let(:group) { create(:group) }
let(:sub_group_1) { create(:group, parent: group) }
@@ -30,7 +30,7 @@ describe NotificationRecipient do
moved_group.reload
end
- context 'when notification setting is global' do
+ context "when notification setting is global" do
before do
user.notification_settings_for(group).global!
user.notification_settings_for(sub_group_1).mention!
@@ -38,12 +38,12 @@ describe NotificationRecipient do
user.notification_settings_for(moved_group).global!
end
- it 'considers notification setting from the first parent without global setting' do
+ it "considers notification setting from the first parent without global setting" do
expect(subject.notification_setting.source).to eq(sub_group_1)
end
end
- context 'when notification setting is not global' do
+ context "when notification setting is not global" do
before do
user.notification_settings_for(group).global!
user.notification_settings_for(sub_group_1).mention!
@@ -51,7 +51,7 @@ describe NotificationRecipient do
user.notification_settings_for(moved_group).disabled!
end
- it 'considers notification setting from lowest group member in hierarchy' do
+ it "considers notification setting from lowest group member in hierarchy" do
expect(subject.notification_setting.source).to eq(moved_group)
end
end
diff --git a/spec/models/notification_setting_spec.rb b/spec/models/notification_setting_spec.rb
index c8ab564e3bc..40bd5bd2313 100644
--- a/spec/models/notification_setting_spec.rb
+++ b/spec/models/notification_setting_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe NotificationSetting do
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
describe "Associations" do
it { is_expected.to belong_to(:user) }
@@ -9,12 +9,12 @@ RSpec.describe NotificationSetting do
end
describe "Validation" do
- subject { described_class.new(source_id: 1, source_type: 'Project') }
+ subject { described_class.new(source_id: 1, source_type: "Project") }
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:level) }
- describe 'user_id' do
+ describe "user_id" do
before do
subject.user = create(:user)
end
@@ -24,7 +24,7 @@ RSpec.describe NotificationSetting do
context "events" do
let(:user) { create(:user) }
- let(:notification_setting) { described_class.new(source_id: 1, source_type: 'Project', user_id: user.id) }
+ let(:notification_setting) { described_class.new(source_id: 1, source_type: "Project", user_id: user.id) }
before do
notification_setting.level = "custom"
@@ -48,7 +48,7 @@ RSpec.describe NotificationSetting do
end
end
- describe '#for_projects' do
+ describe "#for_projects" do
let(:user) { create(:user) }
before do
@@ -59,42 +59,42 @@ RSpec.describe NotificationSetting do
end
end
- it 'excludes projects pending delete' do
+ it "excludes projects pending delete" do
expect(user.notification_settings.for_projects).to all(have_attributes(project: an_instance_of(Project)))
expect(user.notification_settings.for_projects.map(&:project)).to all(have_attributes(pending_delete: false))
end
end
- describe '#event_enabled?' do
+ describe "#event_enabled?" do
before do
subject.update!(user: create(:user))
end
- context 'for an event with a matching column name' do
- it 'returns the value of the column' do
+ context "for an event with a matching column name" do
+ it "returns the value of the column" do
subject.update!(new_note: true)
expect(subject.event_enabled?(:new_note)).to be(true)
end
- context 'when the column has a nil value' do
- it 'returns false' do
+ context "when the column has a nil value" do
+ it "returns false" do
expect(subject.event_enabled?(:new_note)).to be(false)
end
end
end
- context 'for an event without a matching column name' do
- it 'returns false' do
+ context "for an event without a matching column name" do
+ it "returns false" do
expect(subject.event_enabled?(:foo_event)).to be(false)
end
end
end
- describe '.email_events' do
+ describe ".email_events" do
subject { described_class.email_events }
- it 'returns email events' do
+ it "returns email events" do
expect(subject).to include(
:new_note,
:new_issue,
@@ -111,17 +111,17 @@ RSpec.describe NotificationSetting do
)
end
- it 'includes EXCLUDED_WATCHER_EVENTS' do
+ it "includes EXCLUDED_WATCHER_EVENTS" do
expect(subject).to include(*described_class::EXCLUDED_WATCHER_EVENTS)
end
end
- describe '#email_events' do
+ describe "#email_events" do
let(:source) { build(:group) }
subject { build(:notification_setting, source: source) }
- it 'calls email_events' do
+ it "calls email_events" do
expect(described_class).to receive(:email_events).with(source)
subject.email_events
end
diff --git a/spec/models/pages_domain_spec.rb b/spec/models/pages_domain_spec.rb
index 4b85c5e8720..4c776e2e6d9 100644
--- a/spec/models/pages_domain_spec.rb
+++ b/spec/models/pages_domain_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe PagesDomain do
using RSpec::Parameterized::TableSyntax
subject(:pages_domain) { described_class.new }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'validate domain' do
+ describe "validate domain" do
subject(:pages_domain) { build(:pages_domain, domain: domain) }
- context 'is unique' do
- let(:domain) { 'my.domain.com' }
+ context "is unique" do
+ let(:domain) { "my.domain.com" }
it { is_expected.to validate_uniqueness_of(:domain).case_insensitive }
end
describe "hostname" do
{
- 'my.domain.com' => true,
- '123.456.789' => true,
- '0x12345.com' => true,
- '0123123' => true,
- '_foo.com' => false,
- 'reserved.com' => false,
- 'a.reserved.com' => false,
- nil => false
+ "my.domain.com" => true,
+ "123.456.789" => true,
+ "0x12345.com" => true,
+ "0123123" => true,
+ "_foo.com" => false,
+ "reserved.com" => false,
+ "a.reserved.com" => false,
+ nil => false,
}.each do |value, validity|
context "domain #{value.inspect} validity" do
before do
- allow(Settings.pages).to receive(:host).and_return('reserved.com')
+ allow(Settings.pages).to receive(:host).and_return("reserved.com")
end
let(:domain) { value }
@@ -44,7 +44,7 @@ describe PagesDomain do
describe "HTTPS-only" do
using RSpec::Parameterized::TableSyntax
- let(:domain) { 'my.domain.com' }
+ let(:domain) { "my.domain.com" }
let(:project) do
instance_double(Project, pages_https_only?: pages_https_only)
@@ -61,13 +61,13 @@ describe PagesDomain do
attributes = attributes_for(:pages_domain)
cert, key = attributes.fetch_values(:certificate, :key)
- true | nil | nil | %i(certificate key)
- true | cert | nil | %i(key)
- true | nil | key | %i(certificate key)
+ true | nil | nil | %i[certificate key]
+ true | cert | nil | %i[key]
+ true | nil | key | %i[certificate key]
true | cert | key | []
false | nil | nil | []
- false | cert | nil | %i(key)
- false | nil | key | %i(key)
+ false | cert | nil | %i[key]
+ false | nil | key | %i[key]
false | cert | key | []
end
@@ -79,110 +79,110 @@ describe PagesDomain do
end
end
- describe 'validate certificate' do
+ describe "validate certificate" do
subject { domain }
- context 'with matching key' do
+ context "with matching key" do
let(:domain) { build(:pages_domain) }
it { is_expected.to be_valid }
end
- context 'when no certificate is specified' do
+ context "when no certificate is specified" do
let(:domain) { build(:pages_domain, :without_certificate) }
it { is_expected.not_to be_valid }
end
- context 'when no key is specified' do
+ context "when no key is specified" do
let(:domain) { build(:pages_domain, :without_key) }
it { is_expected.not_to be_valid }
end
- context 'for not matching key' do
+ context "for not matching key" do
let(:domain) { build(:pages_domain, :with_missing_chain) }
it { is_expected.not_to be_valid }
end
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:verification_code) }
end
- describe '#verification_code' do
+ describe "#verification_code" do
subject { pages_domain.verification_code }
- it 'is set automatically with 128 bits of SecureRandom data' do
- expect(SecureRandom).to receive(:hex).with(16) { 'verification code' }
+ it "is set automatically with 128 bits of SecureRandom data" do
+ expect(SecureRandom).to receive(:hex).with(16) { "verification code" }
- is_expected.to eq('verification code')
+ is_expected.to eq("verification code")
end
end
- describe '#keyed_verification_code' do
+ describe "#keyed_verification_code" do
subject { pages_domain.keyed_verification_code }
it { is_expected.to eq("gitlab-pages-verification-code=#{pages_domain.verification_code}") }
end
- describe '#verification_domain' do
+ describe "#verification_domain" do
subject { pages_domain.verification_domain }
it { is_expected.to be_nil }
- it 'is a well-known subdomain if the domain is present' do
- pages_domain.domain = 'example.com'
+ it "is a well-known subdomain if the domain is present" do
+ pages_domain.domain = "example.com"
- is_expected.to eq('_gitlab-pages-verification-code.example.com')
+ is_expected.to eq("_gitlab-pages-verification-code.example.com")
end
end
- describe '#url' do
+ describe "#url" do
subject { domain.url }
let(:domain) { build(:pages_domain) }
it { is_expected.to eq("https://#{domain.domain}") }
- context 'without the certificate' do
+ context "without the certificate" do
let(:domain) { build(:pages_domain, :without_certificate) }
it { is_expected.to eq("http://#{domain.domain}") }
end
end
- describe '#has_matching_key?' do
+ describe "#has_matching_key?" do
subject { domain.has_matching_key? }
let(:domain) { build(:pages_domain) }
it { is_expected.to be_truthy }
- context 'for invalid key' do
+ context "for invalid key" do
let(:domain) { build(:pages_domain, :with_missing_chain) }
it { is_expected.to be_falsey }
end
end
- describe '#has_intermediates?' do
+ describe "#has_intermediates?" do
subject { domain.has_intermediates? }
- context 'for self signed' do
+ context "for self signed" do
let(:domain) { build(:pages_domain) }
it { is_expected.to be_truthy }
end
- context 'for missing certificate chain' do
+ context "for missing certificate chain" do
let(:domain) { build(:pages_domain, :with_missing_chain) }
it { is_expected.to be_falsey }
end
- context 'for trusted certificate chain' do
+ context "for trusted certificate chain" do
# We only validate that we can to rebuild the trust chain, for certificates
# We assume that 'AddTrustExternalCARoot' needed to validate the chain is in trusted store.
# It will be if ca-certificates is installed on Debian/Ubuntu/Alpine
@@ -193,31 +193,31 @@ describe PagesDomain do
end
end
- describe '#expired?' do
+ describe "#expired?" do
subject { domain.expired? }
- context 'for valid' do
+ context "for valid" do
let(:domain) { build(:pages_domain) }
it { is_expected.to be_falsey }
end
- context 'for expired' do
+ context "for expired" do
let(:domain) { build(:pages_domain, :with_expired_certificate) }
it { is_expected.to be_truthy }
end
end
- describe '#subject' do
+ describe "#subject" do
let(:domain) { build(:pages_domain) }
subject { domain.subject }
- it { is_expected.to eq('/CN=test-certificate') }
+ it { is_expected.to eq("/CN=test-certificate") }
end
- describe '#certificate_text' do
+ describe "#certificate_text" do
let(:domain) { build(:pages_domain) }
subject { domain.certificate_text }
@@ -238,8 +238,8 @@ describe PagesDomain do
end
end
- describe '#update_daemon' do
- it 'runs when the domain is created' do
+ describe "#update_daemon" do
+ it "runs when the domain is created" do
domain = build(:pages_domain)
expect(domain).to receive(:update_daemon)
@@ -247,7 +247,7 @@ describe PagesDomain do
domain.save!
end
- it 'runs when the domain is destroyed' do
+ it "runs when the domain is destroyed" do
domain = create(:pages_domain)
expect(domain).to receive(:update_daemon)
@@ -255,15 +255,15 @@ describe PagesDomain do
domain.destroy!
end
- it 'delegates to Projects::UpdatePagesConfigurationService' do
- service = instance_double('Projects::UpdatePagesConfigurationService')
+ it "delegates to Projects::UpdatePagesConfigurationService" do
+ service = instance_double("Projects::UpdatePagesConfigurationService")
expect(Projects::UpdatePagesConfigurationService).to receive(:new) { service }
expect(service).to receive(:execute)
create(:pages_domain)
end
- context 'configuration updates when attributes change' do
+ context "configuration updates when attributes change" do
set(:project1) { create(:project) }
set(:project2) { create(:project) }
set(:domain) { create(:pages_domain) }
@@ -278,12 +278,12 @@ describe PagesDomain do
:project | :project1 | nil | true
# domain can't be set to nil
- :domain | 'a.com' | 'a.com' | false
- :domain | 'a.com' | 'b.com' | true
+ :domain | "a.com" | "a.com" | false
+ :domain | "a.com" | "b.com" | true
# verification_code can't be set to nil
- :verification_code | 'foo' | 'foo' | false
- :verification_code | 'foo' | 'bar' | false
+ :verification_code | "foo" | "foo" | false
+ :verification_code | "foo" | "bar" | false
:verified_at | nil | now | false
:verified_at | now | now | false
@@ -297,7 +297,7 @@ describe PagesDomain do
end
with_them do
- it 'runs if a relevant attribute has changed' do
+ it "runs if a relevant attribute has changed" do
a = old_value.is_a?(Symbol) ? send(old_value) : old_value
b = new_value.is_a?(Symbol) ? send(new_value) : new_value
@@ -313,28 +313,28 @@ describe PagesDomain do
end
end
- context 'TLS configuration' do
+ context "TLS configuration" do
set(:domain_without_tls) { create(:pages_domain, :without_certificate, :without_key) }
set(:domain) { create(:pages_domain) }
let(:cert1) { domain.certificate }
- let(:cert2) { cert1 + ' ' }
+ let(:cert2) { cert1 + " " }
let(:key1) { domain.key }
- let(:key2) { key1 + ' ' }
+ let(:key2) { key1 + " " }
- it 'updates when added' do
+ it "updates when added" do
expect(domain_without_tls).to receive(:update_daemon)
domain_without_tls.update!(key: key1, certificate: cert1)
end
- it 'updates when changed' do
+ it "updates when changed" do
expect(domain).to receive(:update_daemon)
domain.update!(key: key2, certificate: cert2)
end
- it 'updates when removed' do
+ it "updates when removed" do
expect(domain).to receive(:update_daemon)
domain.update!(key: nil, certificate: nil)
diff --git a/spec/models/personal_access_token_spec.rb b/spec/models/personal_access_token_spec.rb
index c82ab9c9e62..c0964c20a52 100644
--- a/spec/models/personal_access_token_spec.rb
+++ b/spec/models/personal_access_token_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe PersonalAccessToken do
subject { described_class }
- describe '.build' do
+ describe ".build" do
let(:personal_access_token) { build(:personal_access_token) }
let(:invalid_personal_access_token) { build(:personal_access_token, :invalid) }
- it 'is a valid personal access token' do
+ it "is a valid personal access token" do
expect(personal_access_token).to be_valid
end
- it 'ensures that the token is generated' do
+ it "ensures that the token is generated" do
invalid_personal_access_token.save!
expect(invalid_personal_access_token).to be_valid
@@ -37,52 +37,52 @@ describe PersonalAccessToken do
end
end
- describe 'revoke!' do
+ describe "revoke!" do
let(:active_personal_access_token) { create(:personal_access_token) }
- it 'revokes the token' do
+ it "revokes the token" do
active_personal_access_token.revoke!
expect(active_personal_access_token).to be_revoked
end
end
- describe 'Redis storage' do
+ describe "Redis storage" do
let(:user_id) { 123 }
- let(:token) { 'KS3wegQYXBLYhQsciwsj' }
+ let(:token) { "KS3wegQYXBLYhQsciwsj" }
- context 'reading encrypted data' do
+ context "reading encrypted data" do
before do
subject.redis_store!(user_id, token)
end
- it 'returns stored data' do
+ it "returns stored data" do
expect(subject.redis_getdel(user_id)).to eq(token)
end
end
- context 'reading unencrypted data' do
+ context "reading unencrypted data" do
before do
Gitlab::Redis::SharedState.with do |redis|
redis.set(described_class.redis_shared_state_key(user_id),
- token,
- ex: PersonalAccessToken::REDIS_EXPIRY_TIME)
+ token,
+ ex: PersonalAccessToken::REDIS_EXPIRY_TIME)
end
end
- it 'returns stored data unmodified' do
+ it "returns stored data unmodified" do
expect(subject.redis_getdel(user_id)).to eq(token)
end
end
- context 'after deletion' do
+ context "after deletion" do
before do
subject.redis_store!(user_id, token)
expect(subject.redis_getdel(user_id)).to eq(token)
end
- it 'token is removed' do
+ it "token is removed" do
expect(subject.redis_getdel(user_id)).to be_nil
end
end
@@ -104,7 +104,7 @@ describe PersonalAccessToken do
expect(personal_access_token).to be_valid
end
- context 'when registry is disabled' do
+ context "when registry is disabled" do
before do
stub_container_registry_config(enabled: false)
end
@@ -125,7 +125,7 @@ describe PersonalAccessToken do
end
end
- context 'when registry is enabled' do
+ context "when registry is enabled" do
before do
stub_container_registry_config(enabled: true)
end
diff --git a/spec/models/pool_repository_spec.rb b/spec/models/pool_repository_spec.rb
index 112d4ab56fc..17f3a9b12ff 100644
--- a/spec/models/pool_repository_spec.rb
+++ b/spec/models/pool_repository_spec.rb
@@ -1,42 +1,42 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe PoolRepository do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:shard) }
it { is_expected.to have_one(:source_project) }
it { is_expected.to have_many(:member_projects) }
end
- describe 'validations' do
+ describe "validations" do
let!(:pool_repository) { create(:pool_repository) }
it { is_expected.to validate_presence_of(:shard) }
it { is_expected.to validate_presence_of(:source_project) }
end
- describe '#disk_path' do
- it 'sets the hashed disk_path' do
+ describe "#disk_path" do
+ it "sets the hashed disk_path" do
pool = create(:pool_repository)
expect(pool.disk_path).to match(%r{\A@pools/\h{2}/\h{2}/\h{64}})
end
end
- describe '#unlink_repository' do
+ describe "#unlink_repository" do
let(:pool) { create(:pool_repository, :ready) }
- context 'when the last member leaves' do
- it 'schedules pool removal' do
+ context "when the last member leaves" do
+ it "schedules pool removal" do
expect(::ObjectPool::DestroyWorker).to receive(:perform_async).with(pool.id).and_call_original
pool.unlink_repository(pool.source_project.repository)
end
end
- context 'when the second member leaves' do
- it 'does not schedule pool removal' do
+ context "when the second member leaves" do
+ it "does not schedule pool removal" do
create(:project, :repository, pool_repository: pool)
expect(::ObjectPool::DestroyWorker).not_to receive(:perform_async).with(pool.id)
diff --git a/spec/models/postgresql/replication_slot_spec.rb b/spec/models/postgresql/replication_slot_spec.rb
index e100af7ddc7..0daceef67e4 100644
--- a/spec/models/postgresql/replication_slot_spec.rb
+++ b/spec/models/postgresql/replication_slot_spec.rb
@@ -1,30 +1,30 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Postgresql::ReplicationSlot, :postgresql do
- describe '.in_use?' do
- it 'returns true when replication slots are present' do
+ describe ".in_use?" do
+ it "returns true when replication slots are present" do
expect(described_class).to receive(:exists?).and_return(true)
expect(described_class.in_use?).to be_truthy
end
- it 'returns false when replication slots are not present' do
+ it "returns false when replication slots are not present" do
expect(described_class.in_use?).to be_falsey
end
- it 'returns false if the existence check is invalid' do
- expect(described_class).to receive(:exists?).and_raise(ActiveRecord::StatementInvalid.new('PG::FeatureNotSupported'))
+ it "returns false if the existence check is invalid" do
+ expect(described_class).to receive(:exists?).and_raise(ActiveRecord::StatementInvalid.new("PG::FeatureNotSupported"))
expect(described_class.in_use?).to be_falsey
end
end
- describe '.lag_too_great?' do
+ describe ".lag_too_great?" do
before do
expect(described_class).to receive(:in_use?).and_return(true)
end
- it 'returns true when replication lag is too great' do
+ it "returns true when replication lag is too great" do
expect(described_class)
.to receive(:pluck)
.and_return([125.megabytes])
@@ -32,7 +32,7 @@ describe Postgresql::ReplicationSlot, :postgresql do
expect(described_class.lag_too_great?).to eq(true)
end
- it 'returns false when more than one replicas is up to date enough' do
+ it "returns false when more than one replicas is up to date enough" do
expect(described_class)
.to receive(:pluck)
.and_return([125.megabytes, 0.megabytes, 0.megabytes])
@@ -40,7 +40,7 @@ describe Postgresql::ReplicationSlot, :postgresql do
expect(described_class.lag_too_great?).to eq(false)
end
- it 'returns false when replication lag is not too great' do
+ it "returns false when replication lag is not too great" do
expect(described_class)
.to receive(:pluck)
.and_return([0.megabytes])
diff --git a/spec/models/programming_language_spec.rb b/spec/models/programming_language_spec.rb
index 99cd358f863..a37170f10b9 100644
--- a/spec/models/programming_language_spec.rb
+++ b/spec/models/programming_language_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProgrammingLanguage do
it { is_expected.to respond_to(:name) }
diff --git a/spec/models/project_authorization_spec.rb b/spec/models/project_authorization_spec.rb
index c289ee0859a..1807bada4cc 100644
--- a/spec/models/project_authorization_spec.rb
+++ b/spec/models/project_authorization_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectAuthorization do
let(:user) { create(:user) }
let(:project1) { create(:project) }
let(:project2) { create(:project) }
- describe '.insert_authorizations' do
- it 'inserts the authorizations' do
+ describe ".insert_authorizations" do
+ it "inserts the authorizations" do
described_class
.insert_authorizations([[user.id, project1.id, Gitlab::Access::MAINTAINER]])
expect(user.project_authorizations.count).to eq(1)
end
- it 'inserts rows in batches' do
+ it "inserts rows in batches" do
described_class.insert_authorizations([
[user.id, project1.id, Gitlab::Access::MAINTAINER],
- [user.id, project2.id, Gitlab::Access::MAINTAINER]
+ [user.id, project2.id, Gitlab::Access::MAINTAINER],
], 1)
expect(user.project_authorizations.count).to eq(2)
diff --git a/spec/models/project_auto_devops_spec.rb b/spec/models/project_auto_devops_spec.rb
index 7ff64c76e37..7c350444f71 100644
--- a/spec/models/project_auto_devops_spec.rb
+++ b/spec/models/project_auto_devops_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectAutoDevops do
set(:project) { build(:project) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
it { is_expected.to belong_to(:project) }
@@ -12,25 +12,25 @@ describe ProjectAutoDevops do
it { is_expected.to respond_to(:created_at) }
it { is_expected.to respond_to(:updated_at) }
- describe '#has_domain?' do
- context 'when domain is defined' do
- let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: 'domain.com') }
+ describe "#has_domain?" do
+ context "when domain is defined" do
+ let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: "domain.com") }
it { expect(auto_devops).to have_domain }
end
- context 'when domain is empty' do
- let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: '') }
+ context "when domain is empty" do
+ let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: "") }
- context 'when there is an instance domain specified' do
+ context "when there is an instance domain specified" do
before do
- allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return('example.com')
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return("example.com")
end
it { expect(auto_devops).to have_domain }
end
- context 'when there is no instance domain specified' do
+ context "when there is no instance domain specified" do
before do
allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return(nil)
end
@@ -40,29 +40,29 @@ describe ProjectAutoDevops do
end
end
- describe '#predefined_variables' do
+ describe "#predefined_variables" do
let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: domain) }
- context 'when domain is defined' do
- let(:domain) { 'example.com' }
+ context "when domain is defined" do
+ let(:domain) { "example.com" }
- it 'returns AUTO_DEVOPS_DOMAIN' do
+ it "returns AUTO_DEVOPS_DOMAIN" do
expect(auto_devops.predefined_variables).to include(domain_variable)
end
end
- context 'when domain is not defined' do
+ context "when domain is not defined" do
let(:domain) { nil }
- context 'when there is an instance domain specified' do
+ context "when there is an instance domain specified" do
before do
- allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return('example.com')
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return("example.com")
end
it { expect(auto_devops.predefined_variables).to include(domain_variable) }
end
- context 'when there is no instance domain specified' do
+ context "when there is no instance domain specified" do
before do
allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return(nil)
end
@@ -71,20 +71,20 @@ describe ProjectAutoDevops do
end
end
- context 'when deploy_strategy is manual' do
+ context "when deploy_strategy is manual" do
let(:auto_devops) { build_stubbed(:project_auto_devops, :manual_deployment, project: project) }
let(:expected_variables) do
[
- { key: 'INCREMENTAL_ROLLOUT_MODE', value: 'manual' },
- { key: 'STAGING_ENABLED', value: '1' },
- { key: 'INCREMENTAL_ROLLOUT_ENABLED', value: '1' }
+ {key: "INCREMENTAL_ROLLOUT_MODE", value: "manual"},
+ {key: "STAGING_ENABLED", value: "1"},
+ {key: "INCREMENTAL_ROLLOUT_ENABLED", value: "1"},
]
end
it { expect(auto_devops.predefined_variables).to include(*expected_variables) }
end
- context 'when deploy_strategy is continuous' do
+ context "when deploy_strategy is continuous" do
let(:auto_devops) { build_stubbed(:project_auto_devops, :continuous_deployment, project: project) }
it do
@@ -93,10 +93,10 @@ describe ProjectAutoDevops do
end
end
- context 'when deploy_strategy is timed_incremental' do
+ context "when deploy_strategy is timed_incremental" do
let(:auto_devops) { build_stubbed(:project_auto_devops, :timed_incremental_deployment, project: project) }
- it { expect(auto_devops.predefined_variables).to include(key: 'INCREMENTAL_ROLLOUT_MODE', value: 'timed') }
+ it { expect(auto_devops.predefined_variables).to include(key: "INCREMENTAL_ROLLOUT_MODE", value: "timed") }
it do
expect(auto_devops.predefined_variables.map { |var| var[:key] })
@@ -105,99 +105,99 @@ describe ProjectAutoDevops do
end
def domain_variable
- { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
+ {key: "AUTO_DEVOPS_DOMAIN", value: "example.com", public: true}
end
end
- describe '#create_gitlab_deploy_token' do
+ describe "#create_gitlab_deploy_token" do
let(:auto_devops) { build(:project_auto_devops, project: project) }
- context 'when the project is public' do
+ context "when the project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'should not create a gitlab deploy token' do
- expect do
+ it "should not create a gitlab deploy token" do
+ expect {
auto_devops.save
- end.not_to change { DeployToken.count }
+ }.not_to change { DeployToken.count }
end
end
- context 'when the project is internal' do
+ context "when the project is internal" do
let(:project) { create(:project, :repository, :internal) }
- it 'should create a gitlab deploy token' do
- expect do
+ it "should create a gitlab deploy token" do
+ expect {
auto_devops.save
- end.to change { DeployToken.count }.by(1)
+ }.to change { DeployToken.count }.by(1)
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:project) { create(:project, :repository, :private) }
- it 'should create a gitlab deploy token' do
- expect do
+ it "should create a gitlab deploy token" do
+ expect {
auto_devops.save
- end.to change { DeployToken.count }.by(1)
+ }.to change { DeployToken.count }.by(1)
end
end
- context 'when autodevops is enabled at project level' do
+ context "when autodevops is enabled at project level" do
let(:project) { create(:project, :repository, :internal) }
let(:auto_devops) { build(:project_auto_devops, project: project) }
- it 'should create a deploy token' do
- expect do
+ it "should create a deploy token" do
+ expect {
auto_devops.save
- end.to change { DeployToken.count }.by(1)
+ }.to change { DeployToken.count }.by(1)
end
end
- context 'when autodevops is enabled at instance level' do
+ context "when autodevops is enabled at instance level" do
let(:project) { create(:project, :repository, :internal) }
let(:auto_devops) { build(:project_auto_devops, enabled: nil, project: project) }
- it 'should create a deploy token' do
+ it "should create a deploy token" do
allow(Gitlab::CurrentSettings).to receive(:auto_devops_enabled?).and_return(true)
- expect do
+ expect {
auto_devops.save
- end.to change { DeployToken.count }.by(1)
+ }.to change { DeployToken.count }.by(1)
end
end
- context 'when autodevops is disabled' do
+ context "when autodevops is disabled" do
let(:project) { create(:project, :repository, :internal) }
let(:auto_devops) { build(:project_auto_devops, :disabled, project: project) }
- it 'should not create a deploy token' do
- expect do
+ it "should not create a deploy token" do
+ expect {
auto_devops.save
- end.not_to change { DeployToken.count }
+ }.not_to change { DeployToken.count }
end
end
- context 'when the project already has an active gitlab-deploy-token' do
+ context "when the project already has an active gitlab-deploy-token" do
let(:project) { create(:project, :repository, :internal) }
let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, projects: [project]) }
let(:auto_devops) { build(:project_auto_devops, project: project) }
- it 'should not create a deploy token' do
- expect do
+ it "should not create a deploy token" do
+ expect {
auto_devops.save
- end.not_to change { DeployToken.count }
+ }.not_to change { DeployToken.count }
end
end
- context 'when the project already has a revoked gitlab-deploy-token' do
+ context "when the project already has a revoked gitlab-deploy-token" do
let(:project) { create(:project, :repository, :internal) }
let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :expired, projects: [project]) }
let(:auto_devops) { build(:project_auto_devops, project: project) }
- it 'should not create a deploy token' do
- expect do
+ it "should not create a deploy token" do
+ expect {
auto_devops.save
- end.not_to change { DeployToken.count }
+ }.not_to change { DeployToken.count }
end
end
end
diff --git a/spec/models/project_ci_cd_setting_spec.rb b/spec/models/project_ci_cd_setting_spec.rb
index 4aa62028169..d650ea6196e 100644
--- a/spec/models/project_ci_cd_setting_spec.rb
+++ b/spec/models/project_ci_cd_setting_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectCiCdSetting do
- describe '.available?' do
+ describe ".available?" do
before do
described_class.reset_column_information
end
- it 'returns true' do
+ it "returns true" do
expect(described_class).to be_available
end
- it 'memoizes the schema version' do
+ it "memoizes the schema version" do
expect(ActiveRecord::Migrator)
.to receive(:current_version)
.and_call_original
diff --git a/spec/models/project_custom_attribute_spec.rb b/spec/models/project_custom_attribute_spec.rb
index 669de5506bc..838f9fe5964 100644
--- a/spec/models/project_custom_attribute_spec.rb
+++ b/spec/models/project_custom_attribute_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectCustomAttribute do
- describe 'assocations' do
+ describe "assocations" do
it { is_expected.to belong_to(:project) }
end
- describe 'validations' do
+ describe "validations" do
subject { build :project_custom_attribute }
it { is_expected.to validate_presence_of(:project) }
diff --git a/spec/models/project_daily_statistic_spec.rb b/spec/models/project_daily_statistic_spec.rb
index 86210af15d8..46256078dce 100644
--- a/spec/models/project_daily_statistic_spec.rb
+++ b/spec/models/project_daily_statistic_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectDailyStatistic do
it { is_expected.to belong_to(:project) }
diff --git a/spec/models/project_deploy_token_spec.rb b/spec/models/project_deploy_token_spec.rb
index 9e2e40c2e8f..6c239adcd94 100644
--- a/spec/models/project_deploy_token_spec.rb
+++ b/spec/models/project_deploy_token_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe ProjectDeployToken, type: :model do
let(:project) { create(:project) }
diff --git a/spec/models/project_feature_spec.rb b/spec/models/project_feature_spec.rb
index fee7d65c217..4d0d9a6ff3a 100644
--- a/spec/models/project_feature_spec.rb
+++ b/spec/models/project_feature_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectFeature do
let(:project) { create(:project) }
let(:user) { create(:user) }
- describe '.quoted_access_level_column' do
- it 'returns the table name and quoted column name for a feature' do
+ describe ".quoted_access_level_column" do
+ it "returns the table name and quoted column name for a feature" do
expected = if Gitlab::Database.postgresql?
- '"project_features"."issues_access_level"'
- else
- '`project_features`.`issues_access_level`'
- end
+ '"project_features"."issues_access_level"'
+ else
+ "`project_features`.`issues_access_level`"
+ end
expect(described_class.quoted_access_level_column(:issues)).to eq(expected)
end
end
- describe '#feature_available?' do
- let(:features) { %w(issues wiki builds merge_requests snippets repository pages) }
+ describe "#feature_available?" do
+ let(:features) { %w[issues wiki builds merge_requests snippets repository pages] }
- context 'when features are disabled' do
+ context "when features are disabled" do
it "returns false" do
features.each do |feature|
project.project_feature.update_attribute("#{feature}_access_level".to_sym, ProjectFeature::DISABLED)
@@ -28,7 +28,7 @@ describe ProjectFeature do
end
end
- context 'when features are enabled only for team members' do
+ context "when features are enabled only for team members" do
it "returns false when user is not a team member" do
features.each do |feature|
project.project_feature.update_attribute("#{feature}_access_level".to_sym, ProjectFeature::PRIVATE)
@@ -66,7 +66,7 @@ describe ProjectFeature do
end
end
- context 'when feature is enabled for everyone' do
+ context "when feature is enabled for everyone" do
it "returns true" do
features.each do |feature|
expect(project.feature_available?(:issues, user)).to eq(true)
@@ -74,16 +74,16 @@ describe ProjectFeature do
end
end
- context 'when feature is disabled by a feature flag' do
- it 'returns false' do
+ context "when feature is disabled by a feature flag" do
+ it "returns false" do
stub_feature_flags(issues: false)
expect(project.feature_available?(:issues, user)).to eq(false)
end
end
- context 'when feature is enabled by a feature flag' do
- it 'returns true' do
+ context "when feature is enabled by a feature flag" do
+ it "returns true" do
stub_feature_flags(issues: true)
expect(project.feature_available?(:issues, user)).to eq(true)
@@ -91,7 +91,7 @@ describe ProjectFeature do
end
end
- context 'repository related features' do
+ context "repository related features" do
before do
project.project_feature.update(
merge_requests_access_level: ProjectFeature::DISABLED,
@@ -101,7 +101,7 @@ describe ProjectFeature do
end
it "does not allow repository related features have higher level" do
- features = %w(builds merge_requests)
+ features = %w[builds merge_requests]
project_feature = project.project_feature
features.each do |feature|
@@ -112,9 +112,9 @@ describe ProjectFeature do
end
end
- context 'public features' do
+ context "public features" do
it "does not allow public for other than pages" do
- features = %w(issues wiki builds merge_requests snippets repository)
+ features = %w[issues wiki builds merge_requests snippets repository]
project_feature = project.project_feature
features.each do |feature|
@@ -125,8 +125,8 @@ describe ProjectFeature do
end
end
- describe '#*_enabled?' do
- let(:features) { %w(wiki builds merge_requests) }
+ describe "#*_enabled?" do
+ let(:features) { %w[wiki builds merge_requests] }
it "returns false when feature is disabled" do
features.each do |feature|
diff --git a/spec/models/project_group_link_spec.rb b/spec/models/project_group_link_spec.rb
index 5bea21427d4..9bbbf57ad01 100644
--- a/spec/models/project_group_link_spec.rb
+++ b/spec/models/project_group_link_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectGroupLink do
describe "Associations" do
diff --git a/spec/models/project_import_data_spec.rb b/spec/models/project_import_data_spec.rb
index fe47811f074..1d05272095a 100644
--- a/spec/models/project_import_data_spec.rb
+++ b/spec/models/project_import_data_spec.rb
@@ -1,50 +1,50 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectImportData do
- describe '#merge_data' do
- it 'writes the Hash to the attribute if it is nil' do
+ describe "#merge_data" do
+ it "writes the Hash to the attribute if it is nil" do
row = described_class.new
- row.merge_data('number' => 10)
+ row.merge_data("number" => 10)
- expect(row.data).to eq({ 'number' => 10 })
+ expect(row.data).to eq({"number" => 10})
end
- it 'merges the Hash into an existing Hash if one was present' do
- row = described_class.new(data: { 'number' => 10 })
+ it "merges the Hash into an existing Hash if one was present" do
+ row = described_class.new(data: {"number" => 10})
- row.merge_data('foo' => 'bar')
+ row.merge_data("foo" => "bar")
- expect(row.data).to eq({ 'number' => 10, 'foo' => 'bar' })
+ expect(row.data).to eq({"number" => 10, "foo" => "bar"})
end
end
- describe '#merge_credentials' do
- it 'writes the Hash to the attribute if it is nil' do
+ describe "#merge_credentials" do
+ it "writes the Hash to the attribute if it is nil" do
row = described_class.new
- row.merge_credentials('number' => 10)
+ row.merge_credentials("number" => 10)
- expect(row.credentials).to eq({ 'number' => 10 })
+ expect(row.credentials).to eq({"number" => 10})
end
- it 'merges the Hash into an existing Hash if one was present' do
+ it "merges the Hash into an existing Hash if one was present" do
row = described_class.new
- row.credentials = { 'number' => 10 }
- row.merge_credentials('foo' => 'bar')
+ row.credentials = {"number" => 10}
+ row.merge_credentials("foo" => "bar")
- expect(row.credentials).to eq({ 'number' => 10, 'foo' => 'bar' })
+ expect(row.credentials).to eq({"number" => 10, "foo" => "bar"})
end
end
- describe '#clear_credentials' do
- it 'clears out the Hash' do
+ describe "#clear_credentials" do
+ it "clears out the Hash" do
row = described_class.new
- row.merge_credentials('number' => 10)
+ row.merge_credentials("number" => 10)
row.clear_credentials
expect(row.credentials).to eq({})
diff --git a/spec/models/project_import_state_spec.rb b/spec/models/project_import_state_spec.rb
index e3b2d971419..bfd1b065a28 100644
--- a/spec/models/project_import_state_spec.rb
+++ b/spec/models/project_import_state_spec.rb
@@ -1,17 +1,17 @@
-require 'rails_helper'
+require "rails_helper"
describe ProjectImportState, type: :model do
subject { create(:import_state) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
end
- describe 'Project import job' do
+ describe "Project import job" do
let(:import_state) { create(:import_state, import_url: generate(:url)) }
let(:project) { import_state.project }
@@ -25,17 +25,17 @@ describe ProjectImportState, type: :model do
expect(project.wiki.repository).to receive(:after_import).and_call_original
end
- it 'imports a project' do
+ it "imports a project" do
expect(RepositoryImportWorker).to receive(:perform_async).and_call_original
expect { import_state.schedule }.to change { import_state.jid }
- expect(import_state.status).to eq('finished')
+ expect(import_state.status).to eq("finished")
end
end
- describe '#human_status_name' do
- context 'when import_state exists' do
- it 'returns the humanized status name' do
+ describe "#human_status_name" do
+ context "when import_state exists" do
+ it "returns the humanized status name" do
import_state = build(:import_state, :started)
expect(import_state.human_status_name).to eq("started")
@@ -43,8 +43,8 @@ describe ProjectImportState, type: :model do
end
end
- describe 'import state transitions' do
- context 'state transition: [:started] => [:finished]' do
+ describe "import state transitions" do
+ context "state transition: [:started] => [:finished]" do
let(:after_import_service) { spy(:after_import_service) }
let(:housekeeping_service) { spy(:housekeeping_service) }
@@ -59,14 +59,14 @@ describe ProjectImportState, type: :model do
.to receive(:new) { housekeeping_service }
end
- it 'resets last_error' do
- error_message = 'Some error'
+ it "resets last_error" do
+ error_message = "Some error"
import_state = create(:import_state, :started, last_error: error_message)
expect { import_state.finish }.to change { import_state.last_error }.from(error_message).to(nil)
end
- it 'performs housekeeping when an import of a fresh project is completed' do
+ it "performs housekeeping when an import of a fresh project is completed" do
project = create(:project_empty_repo, :import_started, import_type: :github)
project.import_state.finish
@@ -75,7 +75,7 @@ describe ProjectImportState, type: :model do
expect(housekeeping_service).to have_received(:execute)
end
- it 'does not perform housekeeping when project repository does not exist' do
+ it "does not perform housekeeping when project repository does not exist" do
project = create(:project, :import_started, import_type: :github)
project.import_state.finish
@@ -83,7 +83,7 @@ describe ProjectImportState, type: :model do
expect(housekeeping_service).not_to have_received(:execute)
end
- it 'does not perform housekeeping when project does not have a valid import type' do
+ it "does not perform housekeeping when project does not have a valid import type" do
project = create(:project, :import_started, import_type: nil)
project.import_state.finish
@@ -93,11 +93,11 @@ describe ProjectImportState, type: :model do
end
end
- describe '#remove_jid', :clean_gitlab_redis_cache do
+ describe "#remove_jid", :clean_gitlab_redis_cache do
let(:project) { }
- context 'without an JID' do
- it 'does nothing' do
+ context "without an JID" do
+ it "does nothing" do
import_state = create(:import_state)
expect(Gitlab::SidekiqStatus)
@@ -107,13 +107,13 @@ describe ProjectImportState, type: :model do
end
end
- context 'with an JID' do
- it 'unsets the JID' do
- import_state = create(:import_state, jid: '123')
+ context "with an JID" do
+ it "unsets the JID" do
+ import_state = create(:import_state, jid: "123")
expect(Gitlab::SidekiqStatus)
.to receive(:unset)
- .with('123')
+ .with("123")
.and_call_original
import_state.remove_jid
diff --git a/spec/models/project_label_spec.rb b/spec/models/project_label_spec.rb
index 689d4e505e5..ba0a21bae33 100644
--- a/spec/models/project_label_spec.rb
+++ b/spec/models/project_label_spec.rb
@@ -1,50 +1,50 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectLabel do
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:project) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:project) }
- context 'validates if title must not exist at group level' do
- let(:group) { create(:group, name: 'gitlab-org') }
+ context "validates if title must not exist at group level" do
+ let(:group) { create(:group, name: "gitlab-org") }
let(:project) { create(:project, group: group) }
before do
- create(:group_label, group: group, title: 'Bug')
+ create(:group_label, group: group, title: "Bug")
end
- it 'returns error if title already exists at group level' do
- label = described_class.new(project: project, title: 'Bug')
+ it "returns error if title already exists at group level" do
+ label = described_class.new(project: project, title: "Bug")
label.valid?
- expect(label.errors[:title]).to include 'already exists at group level for gitlab-org. Please choose another one.'
+ expect(label.errors[:title]).to include "already exists at group level for gitlab-org. Please choose another one."
end
- it 'does not returns error if title does not exist at group level' do
- label = described_class.new(project: project, title: 'Security')
+ it "does not returns error if title does not exist at group level" do
+ label = described_class.new(project: project, title: "Security")
label.valid?
expect(label.errors[:title]).to be_empty
end
- it 'does not returns error if project does not belong to group' do
+ it "does not returns error if project does not belong to group" do
another_project = create(:project)
- label = described_class.new(project: another_project, title: 'Bug')
+ label = described_class.new(project: another_project, title: "Bug")
label.valid?
expect(label.errors[:title]).to be_empty
end
- it 'does not returns error when title does not change' do
- project_label = create(:label, project: project, name: 'Security')
- create(:group_label, group: group, name: 'Security')
- project_label.description = 'Security related stuff.'
+ it "does not returns error when title does not change" do
+ project_label = create(:label, project: project, name: "Security")
+ create(:group_label, group: group, name: "Security")
+ project_label.description = "Security related stuff."
project_label.valid?
@@ -52,67 +52,67 @@ describe ProjectLabel do
end
end
- context 'when attempting to add more than one priority to the project label' do
- it 'returns error' do
+ context "when attempting to add more than one priority to the project label" do
+ it "returns error" do
subject.priorities.build
subject.priorities.build
subject.valid?
- expect(subject.errors[:priorities]).to include 'Number of permitted priorities exceeded'
+ expect(subject.errors[:priorities]).to include "Number of permitted priorities exceeded"
end
end
end
- describe '#subject' do
- it 'aliases project to subject' do
+ describe "#subject" do
+ it "aliases project to subject" do
subject = described_class.new(project: build(:project))
expect(subject.subject).to be(subject.project)
end
end
- describe '#to_reference' do
+ describe "#to_reference" do
let(:label) { create(:label) }
- context 'using id' do
- it 'returns a String reference to the object' do
+ context "using id" do
+ it "returns a String reference to the object" do
expect(label.to_reference).to eq "~#{label.id}"
end
end
- context 'using name' do
- it 'returns a String reference to the object' do
+ context "using name" do
+ it "returns a String reference to the object" do
expect(label.to_reference(format: :name)).to eq %(~"#{label.name}")
end
- it 'uses id when name contains double quote' do
- label = create(:label, name: %q{"irony"})
+ it "uses id when name contains double quote" do
+ label = create(:label, name: '"irony"')
expect(label.to_reference(format: :name)).to eq "~#{label.id}"
end
end
- context 'using invalid format' do
- it 'raises error' do
+ context "using invalid format" do
+ it "raises error" do
expect { label.to_reference(format: :invalid) }
.to raise_error StandardError, /Unknown format/
end
end
- context 'cross project reference' do
+ context "cross project reference" do
let(:project) { create(:project) }
- context 'using name' do
- it 'returns cross reference with label name' do
+ context "using name" do
+ it "returns cross reference with label name" do
expect(label.to_reference(project, format: :name))
- .to eq %Q(#{label.project.full_path}~"#{label.name}")
+ .to eq %(#{label.project.full_path}~"#{label.name}")
end
end
- context 'using id' do
- it 'returns cross reference with label id' do
+ context "using id" do
+ it "returns cross reference with label id" do
expect(label.to_reference(project, format: :id))
- .to eq %Q(#{label.project.full_path}~#{label.id})
+ .to eq %(#{label.project.full_path}~#{label.id})
end
end
end
diff --git a/spec/models/project_repository_spec.rb b/spec/models/project_repository_spec.rb
index c966447fedc..78538ec38ed 100644
--- a/spec/models/project_repository_spec.rb
+++ b/spec/models/project_repository_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectRepository do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:shard) }
it { is_expected.to belong_to(:project) }
end
- describe '.find_project' do
- it 'finds project by disk path' do
+ describe ".find_project" do
+ it "finds project by disk path" do
project = create(:project)
project.track_project_repository
expect(described_class.find_project(project.disk_path)).to eq(project)
end
- it 'returns nil when it does not find the project' do
- expect(described_class.find_project('@@unexisting/path/to/project')).to be_nil
+ it "returns nil when it does not find the project" do
+ expect(described_class.find_project("@@unexisting/path/to/project")).to be_nil
end
end
end
diff --git a/spec/models/project_services/asana_service_spec.rb b/spec/models/project_services/asana_service_spec.rb
index e66109fd98f..c8e915fc949 100644
--- a/spec/models/project_services/asana_service_spec.rb
+++ b/spec/models/project_services/asana_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe AsanaService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'active' do
+ describe "Validations" do
+ context "active" do
before do
subject.active = true
end
@@ -16,21 +16,21 @@ describe AsanaService do
end
end
- describe 'Execute' do
+ describe "Execute" do
let(:user) { create(:user) }
let(:project) { create(:project) }
def create_data_for_commits(*messages)
{
- object_kind: 'push',
- ref: 'master',
+ object_kind: "push",
+ ref: "master",
user_name: user.name,
commits: messages.map do |m|
{
message: m,
- url: 'https://gitlab.com/'
+ url: "https://gitlab.com/",
}
- end
+ end,
}
end
@@ -40,70 +40,70 @@ describe AsanaService do
project: project,
project_id: project.id,
service_hook: true,
- api_key: 'verySecret',
- restrict_to_branch: 'master'
+ api_key: "verySecret",
+ restrict_to_branch: "master"
)
end
- it 'calls Asana service to create a story' do
- data = create_data_for_commits('Message from commit. related to #123456')
+ 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.full_name} ( #{data[:commits][0][:url]} ): #{data[:commits][0][:message]}"
- d1 = double('Asana::Task')
+ d1 = double("Asana::Task")
expect(d1).to receive(:add_comment).with(text: expected_message)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '123456').once.and_return(d1)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "123456").once.and_return(d1)
@asana.execute(data)
end
- it 'calls Asana service to create a story and close a task' do
- data = create_data_for_commits('fix #456789')
- d1 = double('Asana::Task')
+ 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)
expect(d1).to receive(:update).with(completed: true)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '456789').once.and_return(d1)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "456789").once.and_return(d1)
@asana.execute(data)
end
- 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')
+ 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)
expect(d1).to receive(:update).with(completed: true)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '42').once.and_return(d1)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "42").once.and_return(d1)
@asana.execute(data)
end
- it 'allows 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
EOF
data = create_data_for_commits(message)
- d1 = double('Asana::Task')
+ d1 = double("Asana::Task")
expect(d1).to receive(:add_comment)
expect(d1).to receive(:update).with(completed: true)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '123').once.and_return(d1)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "123").once.and_return(d1)
- d2 = double('Asana::Task')
+ d2 = double("Asana::Task")
expect(d2).to receive(:add_comment)
expect(d2).to receive(:update).with(completed: true)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '456').once.and_return(d2)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "456").once.and_return(d2)
- d3 = double('Asana::Task')
+ d3 = double("Asana::Task")
expect(d3).to receive(:add_comment)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '789').once.and_return(d3)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "789").once.and_return(d3)
- d4 = double('Asana::Task')
+ d4 = double("Asana::Task")
expect(d4).to receive(:add_comment)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '42').once.and_return(d4)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "42").once.and_return(d4)
- d5 = double('Asana::Task')
+ d5 = double("Asana::Task")
expect(d5).to receive(:add_comment)
expect(d5).to receive(:update).with(completed: true)
- expect(Asana::Task).to receive(:find_by_id).with(anything, '12').once.and_return(d5)
+ expect(Asana::Task).to receive(:find_by_id).with(anything, "12").once.and_return(d5)
@asana.execute(data)
end
diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb
index 5cb6d63659e..26ee6c5e76a 100644
--- a/spec/models/project_services/assembla_service_spec.rb
+++ b/spec/models/project_services/assembla_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AssemblaService do
describe "Associations" do
@@ -16,11 +16,11 @@ describe AssemblaService do
project_id: project.id,
project: project,
service_hook: true,
- token: 'verySecret',
- subdomain: 'project_name'
+ token: "verySecret",
+ subdomain: "project_name"
)
@sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
- @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
+ @api_url = "https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret"
WebMock.stub_request(:post, @api_url)
end
diff --git a/spec/models/project_services/bamboo_service_spec.rb b/spec/models/project_services/bamboo_service_spec.rb
index b880d90d28f..09ba2c69d97 100644
--- a/spec/models/project_services/bamboo_service_spec.rb
+++ b/spec/models/project_services/bamboo_service_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe BambooService, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
- let(:bamboo_url) { 'http://gitlab.com/bamboo' }
+ let(:bamboo_url) { "http://gitlab.com/bamboo" }
subject(:service) do
described_class.create(
project: create(:project),
properties: {
bamboo_url: bamboo_url,
- username: 'mic',
- password: 'password',
- build_key: 'foo'
+ username: "mic",
+ password: "password",
+ build_key: "foo",
}
)
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:build_key) }
it { is_expected.to validate_presence_of(:bamboo_url) }
- it_behaves_like 'issue tracker service URL attribute', :bamboo_url
+ it_behaves_like "issue tracker service URL attribute", :bamboo_url
- describe '#username' do
- it 'does not validate the presence of username if password is nil' do
+ describe "#username" do
+ it "does not validate the presence of username if password is nil" do
subject.password = nil
expect(subject).not_to validate_presence_of(:username)
end
- it 'validates the presence of username if password is present' do
- subject.password = 'secret'
+ it "validates the presence of username if password is present" do
+ subject.password = "secret"
expect(subject).to validate_presence_of(:username)
end
end
- describe '#password' do
- it 'does not validate the presence of password if username is nil' do
+ describe "#password" do
+ it "does not validate the presence of password if username is nil" do
subject.username = nil
expect(subject).not_to validate_presence_of(:password)
end
- it 'validates the presence of password if username is present' do
- subject.username = 'john'
+ it "validates the presence of password if username is present" do
+ subject.username = "john"
expect(subject).to validate_presence_of(:password)
end
end
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -73,114 +73,114 @@ describe BambooService, :use_clean_rails_memory_store_caching do
end
end
- describe 'Callbacks' do
- describe 'before_update :reset_password' do
- context 'when a password was previously set' do
- it 'resets password if url changed' do
+ describe "Callbacks" do
+ describe "before_update :reset_password" do
+ context "when a password was previously set" do
+ it "resets password if url changed" do
bamboo_service = service
- bamboo_service.bamboo_url = 'http://gitlab1.com'
+ bamboo_service.bamboo_url = "http://gitlab1.com"
bamboo_service.save
expect(bamboo_service.password).to be_nil
end
- it 'does not reset password if username changed' do
+ it "does not reset password if username changed" do
bamboo_service = service
- bamboo_service.username = 'some_name'
+ bamboo_service.username = "some_name"
bamboo_service.save
- expect(bamboo_service.password).to eq('password')
+ expect(bamboo_service.password).to eq("password")
end
it "does not reset password if new url is set together with password, even if it's the same password" do
bamboo_service = service
- bamboo_service.bamboo_url = 'http://gitlab_edited.com'
- bamboo_service.password = 'password'
+ bamboo_service.bamboo_url = "http://gitlab_edited.com"
+ bamboo_service.password = "password"
bamboo_service.save
- expect(bamboo_service.password).to eq('password')
- expect(bamboo_service.bamboo_url).to eq('http://gitlab_edited.com')
+ expect(bamboo_service.password).to eq("password")
+ expect(bamboo_service.bamboo_url).to eq("http://gitlab_edited.com")
end
end
- it 'saves password if new url is set together with password when no password was previously set' do
+ it "saves password if new url is set together with password when no password was previously set" do
bamboo_service = service
bamboo_service.password = nil
- bamboo_service.bamboo_url = 'http://gitlab_edited.com'
- bamboo_service.password = 'password'
+ bamboo_service.bamboo_url = "http://gitlab_edited.com"
+ bamboo_service.password = "password"
bamboo_service.save
- expect(bamboo_service.password).to eq('password')
- expect(bamboo_service.bamboo_url).to eq('http://gitlab_edited.com')
+ expect(bamboo_service.password).to eq("password")
+ expect(bamboo_service.bamboo_url).to eq("http://gitlab_edited.com")
end
end
end
- describe '#execute' do
- it 'runs update and build action' do
+ describe "#execute" do
+ it "runs update and build action" do
stub_update_and_build_request
subject.execute(Gitlab::DataBuilder::Push::SAMPLE_DATA)
end
end
- describe '#build_page' do
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(service, { build_page: 'foo' }, 'sha', 'ref')
+ describe "#build_page" do
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(service, {build_page: "foo"}, "sha", "ref")
- expect(service.build_page('sha', 'ref')).to eq('foo')
+ expect(service.build_page("sha", "ref")).to eq("foo")
end
end
- describe '#commit_status' do
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(service, { commit_status: 'foo' }, 'sha', 'ref')
+ describe "#commit_status" do
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(service, {commit_status: "foo"}, "sha", "ref")
- expect(service.commit_status('sha', 'ref')).to eq('foo')
+ expect(service.commit_status("sha", "ref")).to eq("foo")
end
end
- shared_examples 'reactive cache calculation' do
- context '#build_page' do
- subject { service.calculate_reactive_cache('123', 'unused')[:build_page] }
+ shared_examples "reactive cache calculation" do
+ context "#build_page" do
+ subject { service.calculate_reactive_cache("123", "unused")[:build_page] }
- it 'returns a specific URL when status is 500' do
+ it "returns a specific URL when status is 500" do
stub_request(status: 500)
- is_expected.to eq('http://gitlab.com/bamboo/browse/foo')
+ is_expected.to eq("http://gitlab.com/bamboo/browse/foo")
end
- it 'returns a specific URL when response has no results' do
- stub_request(body: %q({"results":{"results":{"size":"0"}}}))
+ it "returns a specific URL when response has no results" do
+ stub_request(body: '{"results":{"results":{"size":"0"}}}')
- is_expected.to eq('http://gitlab.com/bamboo/browse/foo')
+ is_expected.to eq("http://gitlab.com/bamboo/browse/foo")
end
- it 'returns a build URL when bamboo_url has no trailing slash' do
+ it "returns a build URL when bamboo_url has no trailing slash" do
stub_request(body: bamboo_response)
- is_expected.to eq('http://gitlab.com/bamboo/browse/42')
+ is_expected.to eq("http://gitlab.com/bamboo/browse/42")
end
- context 'bamboo_url has trailing slash' do
- let(:bamboo_url) { 'http://gitlab.com/bamboo/' }
+ context "bamboo_url has trailing slash" do
+ let(:bamboo_url) { "http://gitlab.com/bamboo/" }
- it 'returns a build URL' do
+ it "returns a build URL" do
stub_request(body: bamboo_response)
- is_expected.to eq('http://gitlab.com/bamboo/browse/42')
+ is_expected.to eq("http://gitlab.com/bamboo/browse/42")
end
end
end
- context '#commit_status' do
- subject { service.calculate_reactive_cache('123', 'unused')[:commit_status] }
+ context "#commit_status" do
+ subject { service.calculate_reactive_cache("123", "unused")[:commit_status] }
- it 'sets commit status to :error when status is 500' do
+ it "sets commit status to :error when status is 500" do
stub_request(status: 500)
is_expected.to eq(:error)
@@ -189,67 +189,67 @@ describe BambooService, :use_clean_rails_memory_store_caching do
it 'sets commit status to "pending" when status is 404' do
stub_request(status: 404)
- is_expected.to eq('pending')
+ is_expected.to eq("pending")
end
it 'sets commit status to "pending" when response has no results' do
- stub_request(body: %q({"results":{"results":{"size":"0"}}}))
+ stub_request(body: '{"results":{"results":{"size":"0"}}}')
- is_expected.to eq('pending')
+ is_expected.to eq("pending")
end
it 'sets commit status to "success" when build state contains Success' do
- stub_request(body: bamboo_response(build_state: 'YAY Success!'))
+ stub_request(body: bamboo_response(build_state: "YAY Success!"))
- is_expected.to eq('success')
+ is_expected.to eq("success")
end
it 'sets commit status to "failed" when build state contains Failed' do
- stub_request(body: bamboo_response(build_state: 'NO Failed!'))
+ stub_request(body: bamboo_response(build_state: "NO Failed!"))
- is_expected.to eq('failed')
+ is_expected.to eq("failed")
end
it 'sets commit status to "pending" when build state contains Pending' do
- stub_request(body: bamboo_response(build_state: 'NO Pending!'))
+ stub_request(body: bamboo_response(build_state: "NO Pending!"))
- is_expected.to eq('pending')
+ is_expected.to eq("pending")
end
- it 'sets commit status to :error when build state is unknown' do
- stub_request(body: bamboo_response(build_state: 'FOO BAR!'))
+ it "sets commit status to :error when build state is unknown" do
+ stub_request(body: bamboo_response(build_state: "FOO BAR!"))
is_expected.to eq(:error)
end
end
end
- describe '#calculate_reactive_cache' do
- context 'when Bamboo API returns single result' do
+ describe "#calculate_reactive_cache" do
+ context "when Bamboo API returns single result" do
let(:bamboo_response_template) do
- %q({"results":{"results":{"size":"1","result":{"buildState":"%{build_state}","planResultKey":{"key":"42"}}}}})
+ '{"results":{"results":{"size":"1","result":{"buildState":"%{build_state}","planResultKey":{"key":"42"}}}}}'
end
- it_behaves_like 'reactive cache calculation'
+ it_behaves_like "reactive cache calculation"
end
- context 'when Bamboo API returns an array of results and we only consider the last one' do
+ context "when Bamboo API returns an array of results and we only consider the last one" do
let(:bamboo_response_template) do
- %q({"results":{"results":{"size":"2","result":[{"buildState":"%{build_state}","planResultKey":{"key":"41"}},{"buildState":"%{build_state}","planResultKey":{"key":"42"}}]}}})
+ '{"results":{"results":{"size":"2","result":[{"buildState":"%{build_state}","planResultKey":{"key":"41"}},{"buildState":"%{build_state}","planResultKey":{"key":"42"}}]}}}'
end
- it_behaves_like 'reactive cache calculation'
+ it_behaves_like "reactive cache calculation"
end
end
def stub_update_and_build_request(status: 200, body: nil)
- bamboo_full_url = 'http://gitlab.com/bamboo/updateAndBuild.action?buildKey=foo&os_authType=basic'
+ bamboo_full_url = "http://gitlab.com/bamboo/updateAndBuild.action?buildKey=foo&os_authType=basic"
stub_bamboo_request(bamboo_full_url, status, body)
end
def stub_request(status: 200, body: nil)
- bamboo_full_url = 'http://gitlab.com/bamboo/rest/api/latest/result/byChangeset/123?os_authType=basic'
+ bamboo_full_url = "http://gitlab.com/bamboo/rest/api/latest/result/byChangeset/123?os_authType=basic"
stub_bamboo_request(bamboo_full_url, status, body)
end
@@ -257,13 +257,13 @@ describe BambooService, :use_clean_rails_memory_store_caching do
def stub_bamboo_request(url, status, body)
WebMock.stub_request(:get, url).to_return(
status: status,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body
- ).with(basic_auth: %w(mic password))
+ ).with(basic_auth: %w[mic password])
end
- def bamboo_response(build_state: 'success')
+ def bamboo_response(build_state: "success")
# reference: https://docs.atlassian.com/atlassian-bamboo/REST/6.2.5/#d2e786
- bamboo_response_template % { build_state: build_state }
+ bamboo_response_template % {build_state: build_state}
end
end
diff --git a/spec/models/project_services/bugzilla_service_spec.rb b/spec/models/project_services/bugzilla_service_spec.rb
index 43f7bcb1a19..7cfc8b8e262 100644
--- a/spec/models/project_services/bugzilla_service_spec.rb
+++ b/spec/models/project_services/bugzilla_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe BugzillaService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,12 +15,12 @@ describe BugzillaService do
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) }
it { is_expected.to validate_presence_of(:new_issue_url) }
- it_behaves_like 'issue tracker service URL attribute', :project_url
- it_behaves_like 'issue tracker service URL attribute', :issues_url
- it_behaves_like 'issue tracker service URL attribute', :new_issue_url
+ it_behaves_like "issue tracker service URL attribute", :project_url
+ it_behaves_like "issue tracker service URL attribute", :issues_url
+ it_behaves_like "issue tracker service URL attribute", :new_issue_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb
index 1615a93a4ca..c37c3ca539f 100644
--- a/spec/models/project_services/buildkite_service_spec.rb
+++ b/spec/models/project_services/buildkite_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildkiteService, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
@@ -10,29 +10,29 @@ describe BuildkiteService, :use_clean_rails_memory_store_caching do
project: project,
properties: {
service_hook: true,
- project_url: 'https://buildkite.com/account-name/example-project',
- token: 'secret-sauce-webhook-token:secret-sauce-status-token'
+ project_url: "https://buildkite.com/account-name/example-project",
+ token: "secret-sauce-webhook-token:secret-sauce-status-token",
}
)
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:token) }
- it_behaves_like 'issue tracker service URL attribute', :project_url
+ it_behaves_like "issue tracker service URL attribute", :project_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -42,75 +42,75 @@ describe BuildkiteService, :use_clean_rails_memory_store_caching do
end
end
- describe 'commits methods' do
+ describe "commits methods" do
before do
- allow(project).to receive(:default_branch).and_return('default-brancho')
+ allow(project).to receive(:default_branch).and_return("default-brancho")
end
- describe '#webhook_url' do
- it 'returns the webhook url' do
+ describe "#webhook_url" do
+ it "returns the webhook url" do
expect(service.webhook_url).to eq(
- 'https://webhook.buildkite.com/deliver/secret-sauce-webhook-token'
+ "https://webhook.buildkite.com/deliver/secret-sauce-webhook-token"
)
end
end
- describe '#commit_status_path' do
- it 'returns the correct status page' do
- expect(service.commit_status_path('2ab7834c')).to eq(
- 'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=2ab7834c'
+ describe "#commit_status_path" do
+ it "returns the correct status page" do
+ expect(service.commit_status_path("2ab7834c")).to eq(
+ "https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=2ab7834c"
)
end
end
- describe '#build_page' do
- it 'returns the correct build page' do
- expect(service.build_page('2ab7834c', nil)).to eq(
- 'https://buildkite.com/account-name/example-project/builds?commit=2ab7834c'
+ describe "#build_page" do
+ it "returns the correct build page" do
+ expect(service.build_page("2ab7834c", nil)).to eq(
+ "https://buildkite.com/account-name/example-project/builds?commit=2ab7834c"
)
end
end
- describe '#commit_status' do
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(service, { commit_status: 'foo' }, 'sha', 'ref')
+ describe "#commit_status" do
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(service, {commit_status: "foo"}, "sha", "ref")
- expect(service.commit_status('sha', 'ref')).to eq('foo')
+ expect(service.commit_status("sha", "ref")).to eq("foo")
end
end
- describe '#calculate_reactive_cache' do
- context '#commit_status' do
- subject { service.calculate_reactive_cache('123', 'unused')[:commit_status] }
+ describe "#calculate_reactive_cache" do
+ context "#commit_status" do
+ subject { service.calculate_reactive_cache("123", "unused")[:commit_status] }
- it 'sets commit status to :error when status is 500' do
+ it "sets commit status to :error when status is 500" do
stub_request(status: 500)
is_expected.to eq(:error)
end
- it 'sets commit status to :error when status is 404' do
+ it "sets commit status to :error when status is 404" do
stub_request(status: 404)
is_expected.to eq(:error)
end
- it 'passes through build status untouched when status is 200' do
- stub_request(body: %q({"status":"Great Success"}))
+ it "passes through build status untouched when status is 200" do
+ stub_request(body: '{"status":"Great Success"}')
- is_expected.to eq('Great Success')
+ is_expected.to eq("Great Success")
end
end
end
end
def stub_request(status: 200, body: nil)
- body ||= %q({"status":"success"})
- buildkite_full_url = 'https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=123'
+ body ||= '{"status":"success"}'
+ buildkite_full_url = "https://gitlab.buildkite.com/status/secret-sauce-status-token.json?commit=123"
WebMock.stub_request(:get, buildkite_full_url).to_return(
status: status,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body
)
end
diff --git a/spec/models/project_services/campfire_service_spec.rb b/spec/models/project_services/campfire_service_spec.rb
index ed8347edffd..5115d1202a5 100644
--- a/spec/models/project_services/campfire_service_spec.rb
+++ b/spec/models/project_services/campfire_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe CampfireService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,7 +15,7 @@ describe CampfireService do
it { is_expected.to validate_presence_of(:token) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -34,26 +34,26 @@ describe CampfireService do
project_id: project.id,
project: project,
service_hook: true,
- token: 'verySecret',
- subdomain: 'project-name',
- room: 'test-room'
+ token: "verySecret",
+ subdomain: "project-name",
+ room: "test-room"
)
@sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
- @rooms_url = 'https://project-name.campfirenow.com/rooms.json'
- @auth = %w(verySecret X)
- @headers = { 'Content-Type' => 'application/json; charset=utf-8' }
+ @rooms_url = "https://project-name.campfirenow.com/rooms.json"
+ @auth = %w[verySecret X]
+ @headers = {"Content-Type" => "application/json; charset=utf-8"}
end
it "calls Campfire API to get a list of rooms and speak in a room" do
# make sure a valid list of rooms is returned
- body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms.json')
+ body = File.read(Rails.root + "spec/fixtures/project_services/campfire/rooms.json")
WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return(
body: body,
status: 200,
headers: @headers
)
# stub the speak request with the room id found in the previous request's response
- speak_url = 'https://project-name.campfirenow.com/room/123/speak.json'
+ speak_url = "https://project-name.campfirenow.com/room/123/speak.json"
WebMock.stub_request(:post, speak_url).with(basic_auth: @auth)
@campfire_service.execute(@sample_data)
@@ -66,7 +66,7 @@ describe CampfireService do
it "calls Campfire API to get a list of rooms but shouldn't speak in a room" do
# return a list of rooms that do not contain a room named 'test-room'
- body = File.read(Rails.root + 'spec/fixtures/project_services/campfire/rooms2.json')
+ body = File.read(Rails.root + "spec/fixtures/project_services/campfire/rooms2.json")
WebMock.stub_request(:get, @rooms_url).with(basic_auth: @auth).to_return(
body: body,
status: 200,
@@ -74,7 +74,7 @@ describe CampfireService do
)
# we want to make sure no request is sent to the /speak endpoint, here is a basic
# regexp that matches this endpoint
- speak_url = 'https://verySecret:X@project-name.campfirenow.com/room/.*/speak.json'
+ speak_url = "https://verySecret:X@project-name.campfirenow.com/room/.*/speak.json"
@campfire_service.execute(@sample_data)
diff --git a/spec/models/project_services/chat_message/issue_message_spec.rb b/spec/models/project_services/chat_message/issue_message_spec.rb
index f7a35fdc88a..fe03910e086 100644
--- a/spec/models/project_services/chat_message/issue_message_spec.rb
+++ b/spec/models/project_services/chat_message/issue_message_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::IssueMessage do
subject { described_class.new(args) }
@@ -6,115 +6,119 @@ describe ChatMessage::IssueMessage do
let(:args) do
{
user: {
- name: 'Test User',
- username: 'test.user',
- avatar_url: 'http://someavatar.com'
+ name: "Test User",
+ username: "test.user",
+ avatar_url: "http://someavatar.com",
},
- project_name: 'project_name',
- project_url: 'http://somewhere.com',
+ project_name: "project_name",
+ project_url: "http://somewhere.com",
object_attributes: {
- title: 'Issue title',
+ title: "Issue title",
id: 10,
iid: 100,
assignee_id: 1,
- url: 'http://url.com',
- action: 'open',
- state: 'opened',
- description: 'issue description'
- }
+ url: "http://url.com",
+ action: "open",
+ state: "opened",
+ description: "issue description",
+ },
}
end
- context 'without markdown' do
- let(:color) { '#C95823' }
+ context "without markdown" do
+ let(:color) { "#C95823" }
- context '#initialize' do
+ context "#initialize" do
before do
args[:object_attributes][:description] = nil
end
- it 'returns a non-null description' do
- expect(subject.description).to eq('')
+ it "returns a non-null description" do
+ expect(subject.description).to eq("")
end
end
- context 'open' do
- it 'returns a message regarding opening of issues' do
+ context "open" do
+ it "returns a message regarding opening of issues" do
expect(subject.pretext).to eq(
- '[<http://somewhere.com|project_name>] Issue opened by Test User (test.user)')
+ "[<http://somewhere.com|project_name>] Issue opened by Test User (test.user)"
+ )
expect(subject.attachments).to eq([
{
title: "#100 Issue title",
title_link: "http://url.com",
text: "issue description",
- color: color
- }
+ color: color,
+ },
])
end
end
- context 'close' do
+ context "close" do
before do
- args[:object_attributes][:action] = 'close'
- args[:object_attributes][:state] = 'closed'
+ args[:object_attributes][:action] = "close"
+ args[:object_attributes][:state] = "closed"
end
- it 'returns a message regarding closing of issues' do
+ it "returns a message regarding closing of issues" do
expect(subject.pretext). to eq(
- '[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> closed by Test User (test.user)')
+ "[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> closed by Test User (test.user)"
+ )
expect(subject.attachments).to be_empty
end
end
- context 'reopen' do
+ context "reopen" do
before do
- args[:object_attributes][:action] = 'reopen'
- args[:object_attributes][:state] = 'opened'
+ args[:object_attributes][:action] = "reopen"
+ args[:object_attributes][:state] = "opened"
end
- it 'returns a message regarding reopening of issues' do
+ it "returns a message regarding reopening of issues" do
expect(subject.pretext)
- .to eq('[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> opened by Test User (test.user)')
+ .to eq("[<http://somewhere.com|project_name>] Issue <http://url.com|#100 Issue title> opened by Test User (test.user)")
expect(subject.attachments).to be_empty
end
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- context 'open' do
- it 'returns a message regarding opening of issues' do
+ context "open" do
+ it "returns a message regarding opening of issues" do
expect(subject.pretext).to eq(
- '[[project_name](http://somewhere.com)] Issue opened by Test User (test.user)')
- expect(subject.attachments).to eq('issue description')
+ "[[project_name](http://somewhere.com)] Issue opened by Test User (test.user)"
+ )
+ expect(subject.attachments).to eq("issue description")
expect(subject.activity).to eq({
- title: 'Issue opened by Test User (test.user)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: '[#100 Issue title](http://url.com)',
- image: 'http://someavatar.com'
+ title: "Issue opened by Test User (test.user)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "[#100 Issue title](http://url.com)",
+ image: "http://someavatar.com",
})
end
end
- context 'close' do
+ context "close" do
before do
- args[:object_attributes][:action] = 'close'
- args[:object_attributes][:state] = 'closed'
+ args[:object_attributes][:action] = "close"
+ args[:object_attributes][:state] = "closed"
end
- it 'returns a message regarding closing of issues' do
+ it "returns a message regarding closing of issues" do
expect(subject.pretext). to eq(
- '[[project_name](http://somewhere.com)] Issue [#100 Issue title](http://url.com) closed by Test User (test.user)')
+ "[[project_name](http://somewhere.com)] Issue [#100 Issue title](http://url.com) closed by Test User (test.user)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq({
- title: 'Issue closed by Test User (test.user)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: '[#100 Issue title](http://url.com)',
- image: 'http://someavatar.com'
+ title: "Issue closed by Test User (test.user)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "[#100 Issue title](http://url.com)",
+ image: "http://someavatar.com",
})
end
end
diff --git a/spec/models/project_services/chat_message/merge_message_spec.rb b/spec/models/project_services/chat_message/merge_message_spec.rb
index 7997b5bb6b9..e9129c39bef 100644
--- a/spec/models/project_services/chat_message/merge_message_spec.rb
+++ b/spec/models/project_services/chat_message/merge_message_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::MergeMessage do
subject { described_class.new(args) }
@@ -6,100 +6,104 @@ describe ChatMessage::MergeMessage do
let(:args) do
{
user: {
- name: 'Test User',
- username: 'test.user',
- avatar_url: 'http://someavatar.com'
+ name: "Test User",
+ username: "test.user",
+ avatar_url: "http://someavatar.com",
},
- project_name: 'project_name',
- project_url: 'http://somewhere.com',
+ project_name: "project_name",
+ project_url: "http://somewhere.com",
object_attributes: {
title: "Merge Request title\nSecond line",
id: 10,
iid: 100,
assignee_id: 1,
- url: 'http://url.com',
- state: 'opened',
- description: 'merge request description',
- source_branch: 'source_branch',
- target_branch: 'target_branch'
- }
+ url: "http://url.com",
+ state: "opened",
+ description: "merge request description",
+ source_branch: "source_branch",
+ target_branch: "target_branch",
+ },
}
end
# Integration point in EE
- context 'when state is overridden' do
- it 'respects the overridden state' do
- allow(subject).to receive(:state_or_action_text) { 'devoured' }
+ context "when state is overridden" do
+ it "respects the overridden state" do
+ allow(subject).to receive(:state_or_action_text) { "devoured" }
aggregate_failures do
- expect(subject.summary).not_to include('opened')
- expect(subject.summary).to include('devoured')
+ expect(subject.summary).not_to include("opened")
+ expect(subject.summary).to include("devoured")
activity_title = subject.activity[:title]
- expect(activity_title).not_to include('opened')
- expect(activity_title).to include('devoured')
+ expect(activity_title).not_to include("opened")
+ expect(activity_title).to include("devoured")
end
end
end
- context 'without markdown' do
- let(:color) { '#345' }
+ context "without markdown" do
+ let(:color) { "#345" }
- context 'open' do
- it 'returns a message regarding opening of merge requests' do
+ context "open" do
+ it "returns a message regarding opening of merge requests" do
expect(subject.pretext).to eq(
- 'Test User (test.user) opened <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> in <http://somewhere.com|project_name>')
+ "Test User (test.user) opened <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> in <http://somewhere.com|project_name>"
+ )
expect(subject.attachments).to be_empty
end
end
- context 'close' do
+ context "close" do
before do
- args[:object_attributes][:state] = 'closed'
+ args[:object_attributes][:state] = "closed"
end
- it 'returns a message regarding closing of merge requests' do
+ it "returns a message regarding closing of merge requests" do
expect(subject.pretext).to eq(
- 'Test User (test.user) closed <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> in <http://somewhere.com|project_name>')
+ "Test User (test.user) closed <http://somewhere.com/merge_requests/100|!100 *Merge Request title*> in <http://somewhere.com|project_name>"
+ )
expect(subject.attachments).to be_empty
end
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- context 'open' do
- it 'returns a message regarding opening of merge requests' do
+ context "open" do
+ it "returns a message regarding opening of merge requests" do
expect(subject.pretext).to eq(
- 'Test User (test.user) opened [!100 *Merge Request title*](http://somewhere.com/merge_requests/100) in [project_name](http://somewhere.com)')
+ "Test User (test.user) opened [!100 *Merge Request title*](http://somewhere.com/merge_requests/100) in [project_name](http://somewhere.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq({
- title: 'Merge Request opened by Test User (test.user)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: '[!100 *Merge Request title*](http://somewhere.com/merge_requests/100)',
- image: 'http://someavatar.com'
+ title: "Merge Request opened by Test User (test.user)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "[!100 *Merge Request title*](http://somewhere.com/merge_requests/100)",
+ image: "http://someavatar.com",
})
end
end
- context 'close' do
+ context "close" do
before do
- args[:object_attributes][:state] = 'closed'
+ args[:object_attributes][:state] = "closed"
end
- it 'returns a message regarding closing of merge requests' do
+ it "returns a message regarding closing of merge requests" do
expect(subject.pretext).to eq(
- 'Test User (test.user) closed [!100 *Merge Request title*](http://somewhere.com/merge_requests/100) in [project_name](http://somewhere.com)')
+ "Test User (test.user) closed [!100 *Merge Request title*](http://somewhere.com/merge_requests/100) in [project_name](http://somewhere.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq({
- title: 'Merge Request closed by Test User (test.user)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: '[!100 *Merge Request title*](http://somewhere.com/merge_requests/100)',
- image: 'http://someavatar.com'
+ title: "Merge Request closed by Test User (test.user)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "[!100 *Merge Request title*](http://somewhere.com/merge_requests/100)",
+ image: "http://someavatar.com",
})
end
end
diff --git a/spec/models/project_services/chat_message/note_message_spec.rb b/spec/models/project_services/chat_message/note_message_spec.rb
index 5abbd7bec18..4416a1e87a7 100644
--- a/spec/models/project_services/chat_message/note_message_spec.rb
+++ b/spec/models/project_services/chat_message/note_message_spec.rb
@@ -1,189 +1,193 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::NoteMessage do
subject { described_class.new(args) }
- let(:color) { '#345' }
+ let(:color) { "#345" }
let(:args) do
{
user: {
- name: 'Test User',
- username: 'test.user',
- avatar_url: 'http://fakeavatar'
+ name: "Test User",
+ username: "test.user",
+ avatar_url: "http://fakeavatar",
},
- project_name: 'project_name',
- project_url: 'http://somewhere.com',
+ project_name: "project_name",
+ project_url: "http://somewhere.com",
repository: {
- name: 'project_name',
- url: 'http://somewhere.com'
+ name: "project_name",
+ url: "http://somewhere.com",
},
object_attributes: {
id: 10,
- note: 'comment on a commit',
- url: 'http://url.com',
- noteable_type: 'Commit'
- }
+ note: "comment on a commit",
+ url: "http://url.com",
+ noteable_type: "Commit",
+ },
}
end
- context 'commit notes' do
+ context "commit notes" do
before do
- args[:object_attributes][:note] = 'comment on a commit'
- args[:object_attributes][:noteable_type] = 'Commit'
+ args[:object_attributes][:note] = "comment on a commit"
+ args[:object_attributes][:noteable_type] = "Commit"
args[:commit] = {
- id: '5f163b2b95e6f53cbd428f5f0b103702a52b9a23',
- message: "Added a commit message\ndetails\n123\n"
+ id: "5f163b2b95e6f53cbd428f5f0b103702a52b9a23",
+ message: "Added a commit message\ndetails\n123\n",
}
end
- context 'without markdown' do
- it 'returns a message regarding notes on commits' do
+ context "without markdown" do
+ it "returns a message regarding notes on commits" do
expect(subject.pretext).to eq("Test User (test.user) <http://url.com|commented on " \
"commit 5f163b2b> in <http://somewhere.com|project_name>: " \
"*Added a commit message*")
expect(subject.attachments).to eq([{
- text: 'comment on a commit',
- color: color
+ text: "comment on a commit",
+ color: color,
}])
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding notes on commits' do
+ it "returns a message regarding notes on commits" do
expect(subject.pretext).to eq(
- 'Test User (test.user) [commented on commit 5f163b2b](http://url.com) in [project_name](http://somewhere.com): *Added a commit message*'
+ "Test User (test.user) [commented on commit 5f163b2b](http://url.com) in [project_name](http://somewhere.com): *Added a commit message*"
)
- expect(subject.attachments).to eq('comment on a commit')
+ expect(subject.attachments).to eq("comment on a commit")
expect(subject.activity).to eq({
- title: 'Test User (test.user) [commented on commit 5f163b2b](http://url.com)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: 'Added a commit message',
- image: 'http://fakeavatar'
+ title: "Test User (test.user) [commented on commit 5f163b2b](http://url.com)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "Added a commit message",
+ image: "http://fakeavatar",
})
end
end
end
- context 'merge request notes' do
+ context "merge request notes" do
before do
- args[:object_attributes][:note] = 'comment on a merge request'
- args[:object_attributes][:noteable_type] = 'MergeRequest'
+ args[:object_attributes][:note] = "comment on a merge request"
+ args[:object_attributes][:noteable_type] = "MergeRequest"
args[:merge_request] = {
id: 1,
iid: 30,
- title: "merge request title\ndetails\n"
+ title: "merge request title\ndetails\n",
}
end
- context 'without markdown' do
- it 'returns a message regarding notes on a merge request' do
+ context "without markdown" do
+ it "returns a message regarding notes on a merge request" do
expect(subject.pretext).to eq("Test User (test.user) <http://url.com|commented on " \
"merge request !30> in <http://somewhere.com|project_name>: " \
"*merge request title*")
expect(subject.attachments).to eq([{
- text: 'comment on a merge request',
- color: color
+ text: "comment on a merge request",
+ color: color,
}])
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding notes on a merge request' do
+ it "returns a message regarding notes on a merge request" do
expect(subject.pretext).to eq(
- 'Test User (test.user) [commented on merge request !30](http://url.com) in [project_name](http://somewhere.com): *merge request title*')
- expect(subject.attachments).to eq('comment on a merge request')
+ "Test User (test.user) [commented on merge request !30](http://url.com) in [project_name](http://somewhere.com): *merge request title*"
+ )
+ expect(subject.attachments).to eq("comment on a merge request")
expect(subject.activity).to eq({
- title: 'Test User (test.user) [commented on merge request !30](http://url.com)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: 'merge request title',
- image: 'http://fakeavatar'
+ title: "Test User (test.user) [commented on merge request !30](http://url.com)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "merge request title",
+ image: "http://fakeavatar",
})
end
end
end
- context 'issue notes' do
+ context "issue notes" do
before do
- args[:object_attributes][:note] = 'comment on an issue'
- args[:object_attributes][:noteable_type] = 'Issue'
+ args[:object_attributes][:note] = "comment on an issue"
+ args[:object_attributes][:noteable_type] = "Issue"
args[:issue] = {
id: 1,
iid: 20,
- title: "issue title\ndetails\n"
+ title: "issue title\ndetails\n",
}
end
- context 'without markdown' do
- it 'returns a message regarding notes on an issue' do
+ context "without markdown" do
+ it "returns a message regarding notes on an issue" do
expect(subject.pretext).to eq(
"Test User (test.user) <http://url.com|commented on " \
"issue #20> in <http://somewhere.com|project_name>: " \
- "*issue title*")
+ "*issue title*"
+ )
expect(subject.attachments).to eq([{
- text: 'comment on an issue',
- color: color
+ text: "comment on an issue",
+ color: color,
}])
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding notes on an issue' do
+ it "returns a message regarding notes on an issue" do
expect(subject.pretext).to eq(
- 'Test User (test.user) [commented on issue #20](http://url.com) in [project_name](http://somewhere.com): *issue title*')
- expect(subject.attachments).to eq('comment on an issue')
+ "Test User (test.user) [commented on issue #20](http://url.com) in [project_name](http://somewhere.com): *issue title*"
+ )
+ expect(subject.attachments).to eq("comment on an issue")
expect(subject.activity).to eq({
- title: 'Test User (test.user) [commented on issue #20](http://url.com)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: 'issue title',
- image: 'http://fakeavatar'
+ title: "Test User (test.user) [commented on issue #20](http://url.com)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "issue title",
+ image: "http://fakeavatar",
})
end
end
end
- context 'project snippet notes' do
+ context "project snippet notes" do
before do
- args[:object_attributes][:note] = 'comment on a snippet'
- args[:object_attributes][:noteable_type] = 'Snippet'
+ args[:object_attributes][:note] = "comment on a snippet"
+ args[:object_attributes][:noteable_type] = "Snippet"
args[:snippet] = {
id: 5,
- title: "snippet title\ndetails\n"
+ title: "snippet title\ndetails\n",
}
end
- context 'without markdown' do
- it 'returns a message regarding notes on a project snippet' do
+ context "without markdown" do
+ it "returns a message regarding notes on a project snippet" do
expect(subject.pretext).to eq("Test User (test.user) <http://url.com|commented on " \
"snippet $5> in <http://somewhere.com|project_name>: " \
"*snippet title*")
expect(subject.attachments).to eq([{
- text: 'comment on a snippet',
- color: color
+ text: "comment on a snippet",
+ color: color,
}])
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding notes on a project snippet' do
+ it "returns a message regarding notes on a project snippet" do
expect(subject.pretext).to eq(
- 'Test User (test.user) [commented on snippet $5](http://url.com) in [project_name](http://somewhere.com): *snippet title*')
- expect(subject.attachments).to eq('comment on a snippet')
+ "Test User (test.user) [commented on snippet $5](http://url.com) in [project_name](http://somewhere.com): *snippet title*"
+ )
+ expect(subject.attachments).to eq("comment on a snippet")
end
end
end
diff --git a/spec/models/project_services/chat_message/pipeline_message_spec.rb b/spec/models/project_services/chat_message/pipeline_message_spec.rb
index 0ff20400999..0281c454ca1 100644
--- a/spec/models/project_services/chat_message/pipeline_message_spec.rb
+++ b/spec/models/project_services/chat_message/pipeline_message_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::PipelineMessage do
subject { described_class.new(args) }
- let(:user) { { name: "The Hacker", username: 'hacker' } }
+ let(:user) { {name: "The Hacker", username: "hacker"} }
let(:duration) { 7210 }
let(:args) do
{
object_attributes: {
id: 123,
- sha: '97de212e80737a608d939f648d959671fb0a0142',
+ sha: "97de212e80737a608d939f648d959671fb0a0142",
tag: false,
- ref: 'develop',
+ ref: "develop",
status: status,
- duration: duration
+ duration: duration,
},
project: {
- path_with_namespace: 'project_name',
- web_url: 'http://example.gitlab.com'
+ path_with_namespace: "project_name",
+ web_url: "http://example.gitlab.com",
},
- user: user
+ user: user,
}
end
let(:combined_name) { "The Hacker (hacker)" }
- context 'without markdown' do
- context 'pipeline succeeded' do
- let(:status) { 'success' }
- let(:color) { 'good' }
- let(:message) { build_message('passed', combined_name) }
+ context "without markdown" do
+ context "pipeline succeeded" do
+ let(:status) { "success" }
+ let(:color) { "good" }
+ let(:message) { build_message("passed", combined_name) }
- it 'returns a message with information about succeeded build' do
+ it "returns a message with information about succeeded build" do
expect(subject.pretext).to be_empty
expect(subject.fallback).to eq(message)
expect(subject.attachments).to eq([text: message, color: color])
end
end
- context 'pipeline failed' do
- let(:status) { 'failed' }
- let(:color) { 'danger' }
+ context "pipeline failed" do
+ let(:status) { "failed" }
+ let(:color) { "danger" }
let(:message) { build_message(status, combined_name) }
- it 'returns a message with information about failed build' do
+ it "returns a message with information about failed build" do
expect(subject.pretext).to be_empty
expect(subject.fallback).to eq(message)
expect(subject.attachments).to eq([text: message, color: color])
end
- context 'when triggered by API therefore lacking user' do
+ context "when triggered by API therefore lacking user" do
let(:user) { nil }
- let(:message) { build_message(status, 'API') }
+ let(:message) { build_message(status, "API") }
- it 'returns a message stating it is by API' do
+ it "returns a message stating it is by API" do
expect(subject.pretext).to be_empty
expect(subject.fallback).to eq(message)
expect(subject.attachments).to eq([text: message, color: color])
@@ -68,56 +68,56 @@ describe ChatMessage::PipelineMessage do
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- context 'pipeline succeeded' do
- let(:status) { 'success' }
- let(:color) { 'good' }
- let(:message) { build_markdown_message('passed', combined_name) }
+ context "pipeline succeeded" do
+ let(:status) { "success" }
+ let(:color) { "good" }
+ let(:message) { build_markdown_message("passed", combined_name) }
- it 'returns a message with information about succeeded build' do
+ it "returns a message with information about succeeded build" do
expect(subject.pretext).to be_empty
expect(subject.attachments).to eq(message)
expect(subject.activity).to eq({
- title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by The Hacker (hacker) passed',
- subtitle: 'in [project_name](http://example.gitlab.com)',
- text: 'in 02:00:10',
- image: ''
+ title: "Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by The Hacker (hacker) passed",
+ subtitle: "in [project_name](http://example.gitlab.com)",
+ text: "in 02:00:10",
+ image: "",
})
end
end
- context 'pipeline failed' do
- let(:status) { 'failed' }
- let(:color) { 'danger' }
+ context "pipeline failed" do
+ let(:status) { "failed" }
+ let(:color) { "danger" }
let(:message) { build_markdown_message(status, combined_name) }
- it 'returns a message with information about failed build' do
+ it "returns a message with information about failed build" do
expect(subject.pretext).to be_empty
expect(subject.attachments).to eq(message)
expect(subject.activity).to eq({
- title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by The Hacker (hacker) failed',
- subtitle: 'in [project_name](http://example.gitlab.com)',
- text: 'in 02:00:10',
- image: ''
+ title: "Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by The Hacker (hacker) failed",
+ subtitle: "in [project_name](http://example.gitlab.com)",
+ text: "in 02:00:10",
+ image: "",
})
end
- context 'when triggered by API therefore lacking user' do
+ context "when triggered by API therefore lacking user" do
let(:user) { nil }
- let(:message) { build_markdown_message(status, 'API') }
+ let(:message) { build_markdown_message(status, "API") }
- it 'returns a message stating it is by API' do
+ it "returns a message stating it is by API" do
expect(subject.pretext).to be_empty
expect(subject.attachments).to eq(message)
expect(subject.activity).to eq({
- title: 'Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by API failed',
- subtitle: 'in [project_name](http://example.gitlab.com)',
- text: 'in 02:00:10',
- image: ''
+ title: "Pipeline [#123](http://example.gitlab.com/pipelines/123) of branch [develop](http://example.gitlab.com/commits/develop) by API failed",
+ subtitle: "in [project_name](http://example.gitlab.com)",
+ text: "in 02:00:10",
+ image: "",
})
end
end
diff --git a/spec/models/project_services/chat_message/push_message_spec.rb b/spec/models/project_services/chat_message/push_message_spec.rb
index 973d6bdb2a0..68de0c4091e 100644
--- a/spec/models/project_services/chat_message/push_message_spec.rb
+++ b/spec/models/project_services/chat_message/push_message_spec.rb
@@ -1,205 +1,214 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::PushMessage do
subject { described_class.new(args) }
let(:args) do
{
- after: 'after',
- before: 'before',
- project_name: 'project_name',
- ref: 'refs/heads/master',
- user_name: 'test.user',
- user_avatar: 'http://someavatar.com',
- project_url: 'http://url.com'
+ after: "after",
+ before: "before",
+ project_name: "project_name",
+ ref: "refs/heads/master",
+ user_name: "test.user",
+ user_avatar: "http://someavatar.com",
+ project_url: "http://url.com",
}
end
- let(:color) { '#345' }
+ let(:color) { "#345" }
- context 'push' do
+ context "push" do
before do
args[:commits] = [
- { message: 'message1', url: 'http://url1.com', id: 'abcdefghijkl', author: { name: 'author1' } },
- { message: 'message2', url: 'http://url2.com', id: '123456789012', author: { name: 'author2' } }
+ {message: "message1", url: "http://url1.com", id: "abcdefghijkl", author: {name: "author1"}},
+ {message: "message2", url: "http://url2.com", id: "123456789012", author: {name: "author2"}},
]
end
- context 'without markdown' do
- it 'returns a message regarding pushes' do
+ context "without markdown" do
+ it "returns a message regarding pushes" do
expect(subject.pretext).to eq(
- 'test.user pushed to branch <http://url.com/commits/master|master> of '\
- '<http://url.com|project_name> (<http://url.com/compare/before...after|Compare changes>)')
+ "test.user pushed to branch <http://url.com/commits/master|master> of "\
+ "<http://url.com|project_name> (<http://url.com/compare/before...after|Compare changes>)"
+ )
expect(subject.attachments).to eq([{
text: "<http://url1.com|abcdefgh>: message1 - author1\n\n"\
"<http://url2.com|12345678>: message2 - author2",
- color: color
+ color: color,
}])
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding pushes' do
+ it "returns a message regarding pushes" do
expect(subject.pretext).to eq(
- 'test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))')
+ "test.user pushed to branch [master](http://url.com/commits/master) of [project_name](http://url.com) ([Compare changes](http://url.com/compare/before...after))"
+ )
expect(subject.attachments).to eq(
- "[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2 - author2")
+ "[abcdefgh](http://url1.com): message1 - author1\n\n[12345678](http://url2.com): message2 - author2"
+ )
expect(subject.activity).to eq(
- title: 'test.user pushed to branch [master](http://url.com/commits/master)',
- subtitle: 'in [project_name](http://url.com)',
- text: '[Compare changes](http://url.com/compare/before...after)',
- image: 'http://someavatar.com'
+ title: "test.user pushed to branch [master](http://url.com/commits/master)",
+ subtitle: "in [project_name](http://url.com)",
+ text: "[Compare changes](http://url.com/compare/before...after)",
+ image: "http://someavatar.com"
)
end
end
end
- context 'tag push' do
+ context "tag push" do
let(:args) do
{
- after: 'after',
+ after: "after",
before: Gitlab::Git::BLANK_SHA,
- project_name: 'project_name',
- ref: 'refs/tags/new_tag',
- user_name: 'test.user',
- user_avatar: 'http://someavatar.com',
- project_url: 'http://url.com'
+ project_name: "project_name",
+ ref: "refs/tags/new_tag",
+ user_name: "test.user",
+ user_avatar: "http://someavatar.com",
+ project_url: "http://url.com",
}
end
- context 'without markdown' do
- it 'returns a message regarding pushes' do
- expect(subject.pretext).to eq('test.user pushed new tag ' \
- '<http://url.com/commits/new_tag|new_tag> to ' \
- '<http://url.com|project_name>')
+ context "without markdown" do
+ it "returns a message regarding pushes" do
+ expect(subject.pretext).to eq("test.user pushed new tag " \
+ "<http://url.com/commits/new_tag|new_tag> to " \
+ "<http://url.com|project_name>")
expect(subject.attachments).to be_empty
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding pushes' do
+ it "returns a message regarding pushes" do
expect(subject.pretext).to eq(
- 'test.user pushed new tag [new_tag](http://url.com/commits/new_tag) to [project_name](http://url.com)')
+ "test.user pushed new tag [new_tag](http://url.com/commits/new_tag) to [project_name](http://url.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq(
- title: 'test.user pushed new tag [new_tag](http://url.com/commits/new_tag)',
- subtitle: 'in [project_name](http://url.com)',
- text: '[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)',
- image: 'http://someavatar.com'
+ title: "test.user pushed new tag [new_tag](http://url.com/commits/new_tag)",
+ subtitle: "in [project_name](http://url.com)",
+ text: "[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)",
+ image: "http://someavatar.com"
)
end
end
end
- context 'removed tag' do
+ context "removed tag" do
let(:args) do
{
after: Gitlab::Git::BLANK_SHA,
- before: 'before',
- project_name: 'project_name',
- ref: 'refs/tags/new_tag',
- user_name: 'test.user',
- user_avatar: 'http://someavatar.com',
- project_url: 'http://url.com'
+ before: "before",
+ project_name: "project_name",
+ ref: "refs/tags/new_tag",
+ user_name: "test.user",
+ user_avatar: "http://someavatar.com",
+ project_url: "http://url.com",
}
end
- context 'without markdown' do
- it 'returns a message regarding removal of tags' do
- expect(subject.pretext).to eq('test.user removed tag ' \
- 'new_tag from ' \
- '<http://url.com|project_name>')
+ context "without markdown" do
+ it "returns a message regarding removal of tags" do
+ expect(subject.pretext).to eq("test.user removed tag " \
+ "new_tag from " \
+ "<http://url.com|project_name>")
expect(subject.attachments).to be_empty
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding removal of tags' do
+ it "returns a message regarding removal of tags" do
expect(subject.pretext).to eq(
- 'test.user removed tag new_tag from [project_name](http://url.com)')
+ "test.user removed tag new_tag from [project_name](http://url.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq(
- title: 'test.user removed tag new_tag',
- subtitle: 'in [project_name](http://url.com)',
- text: '[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)',
- image: 'http://someavatar.com'
+ title: "test.user removed tag new_tag",
+ subtitle: "in [project_name](http://url.com)",
+ text: "[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)",
+ image: "http://someavatar.com"
)
end
end
end
- context 'new branch' do
+ context "new branch" do
before do
args[:before] = Gitlab::Git::BLANK_SHA
end
- context 'without markdown' do
- it 'returns a message regarding a new branch' do
+ context "without markdown" do
+ it "returns a message regarding a new branch" do
expect(subject.pretext).to eq(
- 'test.user pushed new branch <http://url.com/commits/master|master> to '\
- '<http://url.com|project_name>')
+ "test.user pushed new branch <http://url.com/commits/master|master> to "\
+ "<http://url.com|project_name>"
+ )
expect(subject.attachments).to be_empty
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding a new branch' do
+ it "returns a message regarding a new branch" do
expect(subject.pretext).to eq(
- 'test.user pushed new branch [master](http://url.com/commits/master) to [project_name](http://url.com)')
+ "test.user pushed new branch [master](http://url.com/commits/master) to [project_name](http://url.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq(
- title: 'test.user pushed new branch [master](http://url.com/commits/master)',
- subtitle: 'in [project_name](http://url.com)',
- text: '[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)',
- image: 'http://someavatar.com'
+ title: "test.user pushed new branch [master](http://url.com/commits/master)",
+ subtitle: "in [project_name](http://url.com)",
+ text: "[Compare changes](http://url.com/compare/0000000000000000000000000000000000000000...after)",
+ image: "http://someavatar.com"
)
end
end
end
- context 'removed branch' do
+ context "removed branch" do
before do
args[:after] = Gitlab::Git::BLANK_SHA
end
- context 'without markdown' do
- it 'returns a message regarding a removed branch' do
+ context "without markdown" do
+ it "returns a message regarding a removed branch" do
expect(subject.pretext).to eq(
- 'test.user removed branch master from <http://url.com|project_name>')
+ "test.user removed branch master from <http://url.com|project_name>"
+ )
expect(subject.attachments).to be_empty
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- it 'returns a message regarding a removed branch' do
+ it "returns a message regarding a removed branch" do
expect(subject.pretext).to eq(
- 'test.user removed branch master from [project_name](http://url.com)')
+ "test.user removed branch master from [project_name](http://url.com)"
+ )
expect(subject.attachments).to be_empty
expect(subject.activity).to eq(
- title: 'test.user removed branch master',
- subtitle: 'in [project_name](http://url.com)',
- text: '[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)',
- image: 'http://someavatar.com'
+ title: "test.user removed branch master",
+ subtitle: "in [project_name](http://url.com)",
+ text: "[Compare changes](http://url.com/compare/before...0000000000000000000000000000000000000000)",
+ image: "http://someavatar.com"
)
end
end
diff --git a/spec/models/project_services/chat_message/wiki_page_message_spec.rb b/spec/models/project_services/chat_message/wiki_page_message_spec.rb
index 7efcba9bcfd..888dd70510e 100644
--- a/spec/models/project_services/chat_message/wiki_page_message_spec.rb
+++ b/spec/models/project_services/chat_message/wiki_page_message_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatMessage::WikiPageMessage do
subject { described_class.new(args) }
@@ -6,160 +6,164 @@ describe ChatMessage::WikiPageMessage do
let(:args) do
{
user: {
- name: 'Test User',
- username: 'test.user',
- avatar_url: 'http://someavatar.com'
+ name: "Test User",
+ username: "test.user",
+ avatar_url: "http://someavatar.com",
},
- project_name: 'project_name',
- project_url: 'http://somewhere.com',
+ project_name: "project_name",
+ project_url: "http://somewhere.com",
object_attributes: {
- title: 'Wiki page title',
- url: 'http://url.com',
- content: 'Wiki page description'
- }
+ title: "Wiki page title",
+ url: "http://url.com",
+ content: "Wiki page description",
+ },
}
end
- context 'without markdown' do
- describe '#pretext' do
+ context "without markdown" do
+ describe "#pretext" do
context 'when :action == "create"' do
before do
- args[:object_attributes][:action] = 'create'
+ args[:object_attributes][:action] = "create"
end
- it 'returns a message that a new wiki page was created' do
+ it "returns a message that a new wiki page was created" do
expect(subject.pretext).to eq(
- 'Test User (test.user) created <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\
- '*Wiki page title*')
+ "Test User (test.user) created <http://url.com|wiki page> in <http://somewhere.com|project_name>: "\
+ "*Wiki page title*"
+ )
end
end
context 'when :action == "update"' do
before do
- args[:object_attributes][:action] = 'update'
+ args[:object_attributes][:action] = "update"
end
- it 'returns a message that a wiki page was updated' do
+ it "returns a message that a wiki page was updated" do
expect(subject.pretext).to eq(
- 'Test User (test.user) edited <http://url.com|wiki page> in <http://somewhere.com|project_name>: '\
- '*Wiki page title*')
+ "Test User (test.user) edited <http://url.com|wiki page> in <http://somewhere.com|project_name>: "\
+ "*Wiki page title*"
+ )
end
end
end
- describe '#attachments' do
- let(:color) { '#345' }
+ describe "#attachments" do
+ let(:color) { "#345" }
context 'when :action == "create"' do
before do
- args[:object_attributes][:action] = 'create'
+ args[:object_attributes][:action] = "create"
end
- 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",
- color: color
- }
+ color: color,
+ },
])
end
end
context 'when :action == "update"' do
before do
- args[:object_attributes][:action] = 'update'
+ args[:object_attributes][:action] = "update"
end
- 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",
- color: color
- }
+ color: color,
+ },
])
end
end
end
end
- context 'with markdown' do
+ context "with markdown" do
before do
args[:markdown] = true
end
- describe '#pretext' do
+ describe "#pretext" do
context 'when :action == "create"' do
before do
- args[:object_attributes][:action] = 'create'
+ args[:object_attributes][:action] = "create"
end
- it 'returns a message that a new wiki page was created' do
+ it "returns a message that a new wiki page was created" do
expect(subject.pretext).to eq(
- 'Test User (test.user) created [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*')
+ "Test User (test.user) created [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*"
+ )
end
end
context 'when :action == "update"' do
before do
- args[:object_attributes][:action] = 'update'
+ args[:object_attributes][:action] = "update"
end
- it 'returns a message that a wiki page was updated' do
+ it "returns a message that a wiki page was updated" do
expect(subject.pretext).to eq(
- 'Test User (test.user) edited [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*')
+ "Test User (test.user) edited [wiki page](http://url.com) in [project_name](http://somewhere.com): *Wiki page title*"
+ )
end
end
end
- describe '#attachments' do
+ describe "#attachments" do
context 'when :action == "create"' do
before do
- args[:object_attributes][:action] = 'create'
+ args[:object_attributes][:action] = "create"
end
- it 'returns the attachment for a new wiki page' do
- expect(subject.attachments).to eq('Wiki page description')
+ it "returns the attachment for a new wiki page" do
+ expect(subject.attachments).to eq("Wiki page description")
end
end
context 'when :action == "update"' do
before do
- args[:object_attributes][:action] = 'update'
+ args[:object_attributes][:action] = "update"
end
- it 'returns the attachment for an updated wiki page' do
- expect(subject.attachments).to eq('Wiki page description')
+ it "returns the attachment for an updated wiki page" do
+ expect(subject.attachments).to eq("Wiki page description")
end
end
end
- describe '#activity' do
+ describe "#activity" do
context 'when :action == "create"' do
before do
- args[:object_attributes][:action] = 'create'
+ args[:object_attributes][:action] = "create"
end
- it 'returns the attachment for a new wiki page' do
+ it "returns the attachment for a new wiki page" do
expect(subject.activity).to eq({
- title: 'Test User (test.user) created [wiki page](http://url.com)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: 'Wiki page title',
- image: 'http://someavatar.com'
+ title: "Test User (test.user) created [wiki page](http://url.com)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "Wiki page title",
+ image: "http://someavatar.com",
})
end
end
context 'when :action == "update"' do
before do
- args[:object_attributes][:action] = 'update'
+ args[:object_attributes][:action] = "update"
end
- it 'returns the attachment for an updated wiki page' do
+ it "returns the attachment for an updated wiki page" do
expect(subject.activity).to eq({
- title: 'Test User (test.user) edited [wiki page](http://url.com)',
- subtitle: 'in [project_name](http://somewhere.com)',
- text: 'Wiki page title',
- image: 'http://someavatar.com'
+ title: "Test User (test.user) edited [wiki page](http://url.com)",
+ subtitle: "in [project_name](http://somewhere.com)",
+ text: "Wiki page title",
+ image: "http://someavatar.com",
})
end
end
diff --git a/spec/models/project_services/chat_notification_service_spec.rb b/spec/models/project_services/chat_notification_service_spec.rb
index 46713df77da..50646aa3de9 100644
--- a/spec/models/project_services/chat_notification_service_spec.rb
+++ b/spec/models/project_services/chat_notification_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatNotificationService do
- describe 'Associations' do
+ describe "Associations" do
before do
allow(subject).to receive(:activated?).and_return(true)
end
@@ -9,17 +9,17 @@ describe ChatNotificationService do
it { is_expected.to validate_presence_of :webhook }
end
- describe '#can_test?' do
- context 'with empty repository' do
- it 'returns true' do
+ describe "#can_test?" do
+ context "with empty repository" do
+ it "returns true" do
subject.project = create(:project, :empty_repo)
expect(subject.can_test?).to be true
end
end
- context 'with repository' do
- it 'returns true' do
+ context "with repository" do
+ it "returns true" do
subject.project = create(:project, :repository)
expect(subject.can_test?).to be true
@@ -27,11 +27,11 @@ describe ChatNotificationService do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:chat_service) { described_class.new }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:webhook_url) { 'https://example.gitlab.com/' }
+ let(:webhook_url) { "https://example.gitlab.com/" }
before do
allow(chat_service).to receive_messages(
@@ -46,31 +46,31 @@ describe ChatNotificationService do
subject.active = true
end
- context 'with a repository' do
- it 'returns true' do
+ context "with a repository" do
+ it "returns true" do
subject.project = project
data = Gitlab::DataBuilder::Push.build_sample(project, user)
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, {})
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, {})
+ .and_return(
+ double(:slack_service).as_null_object
+ )
expect(chat_service.execute(data)).to be true
end
end
- context 'with an empty repository' do
- it 'returns true' do
+ context "with an empty repository" do
+ it "returns true" do
subject.project = create(:project, :empty_repo)
data = Gitlab::DataBuilder::Push.build_sample(subject.project, user)
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, {})
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, {})
+ .and_return(
+ double(:slack_service).as_null_object
+ )
expect(chat_service.execute(data)).to be true
end
diff --git a/spec/models/project_services/custom_issue_tracker_service_spec.rb b/spec/models/project_services/custom_issue_tracker_service_spec.rb
index 7e1b1a4f2af..94facd7287b 100644
--- a/spec/models/project_services/custom_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/custom_issue_tracker_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe CustomIssueTrackerService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,12 +15,12 @@ describe CustomIssueTrackerService do
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) }
it { is_expected.to validate_presence_of(:new_issue_url) }
- it_behaves_like 'issue tracker service URL attribute', :project_url
- it_behaves_like 'issue tracker service URL attribute', :issues_url
- it_behaves_like 'issue tracker service URL attribute', :new_issue_url
+ it_behaves_like "issue tracker service URL attribute", :project_url
+ it_behaves_like "issue tracker service URL attribute", :issues_url
+ it_behaves_like "issue tracker service URL attribute", :new_issue_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -30,19 +30,19 @@ describe CustomIssueTrackerService do
it { is_expected.not_to validate_presence_of(:new_issue_url) }
end
- context 'title' do
+ context "title" do
let(:issue_tracker) { described_class.new(properties: {}) }
- it 'sets a default title' do
+ it "sets a default title" do
issue_tracker.title = nil
- expect(issue_tracker.title).to eq('Custom Issue Tracker')
+ expect(issue_tracker.title).to eq("Custom Issue Tracker")
end
- it 'sets the custom title' do
- issue_tracker.title = 'test title'
+ it "sets the custom title" do
+ issue_tracker.title = "test title"
- expect(issue_tracker.title).to eq('test title')
+ expect(issue_tracker.title).to eq("test title")
end
end
end
diff --git a/spec/models/project_services/discord_service_spec.rb b/spec/models/project_services/discord_service_spec.rb
index be82f223478..81af05f1c3b 100644
--- a/spec/models/project_services/discord_service_spec.rb
+++ b/spec/models/project_services/discord_service_spec.rb
@@ -5,7 +5,7 @@ require "spec_helper"
describe DiscordService do
it_behaves_like "chat service", "Discord notifications" do
let(:client) { Discordrb::Webhooks::Client }
- let(:client_arguments) { { url: webhook_url } }
+ let(:client_arguments) { {url: webhook_url} }
let(:content_key) { :content }
end
end
diff --git a/spec/models/project_services/drone_ci_service_spec.rb b/spec/models/project_services/drone_ci_service_spec.rb
index 26597d9b83c..4ba67693870 100644
--- a/spec/models/project_services/drone_ci_service_spec.rb
+++ b/spec/models/project_services/drone_ci_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe DroneCiService, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to have_one(:service_hook) }
end
- describe 'validations' do
- context 'active' do
+ describe "validations" do
+ context "active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:token) }
it { is_expected.to validate_presence_of(:drone_url) }
- it_behaves_like 'issue tracker service URL attribute', :drone_url
+ it_behaves_like "issue tracker service URL attribute", :drone_url
end
- context 'inactive' do
+ context "inactive" do
before do
subject.active = false
end
@@ -31,12 +31,12 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
shared_context :drone_ci_service do
let(:drone) { DroneCiService.new }
- let(:project) { create(:project, :repository, name: 'project') }
+ let(:project) { create(:project, :repository, name: "project") }
let(:path) { project.full_path }
- let(:drone_url) { 'http://drone.example.com' }
- let(:sha) { '2ab7834c' }
- let(:branch) { 'dev' }
- let(:token) { 'secret' }
+ let(:drone_url) { "http://drone.example.com" }
+ let(:sha) { "2ab7834c" }
+ let(:branch) { "dev" }
+ let(:token) { "secret" }
let(:iid) { rand(1..9999) }
# URL's
@@ -54,11 +54,11 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
end
def stub_request(status: 200, body: nil)
- body ||= %q({"status":"success"})
+ body ||= '{"status":"success"}'
WebMock.stub_request(:get, commit_status_path).to_return(
status: status,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body
)
end
@@ -71,42 +71,42 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
it { expect(drone.commit_status_path(sha, branch)).to eq(commit_status_path) }
end
- describe '#commit_status' do
+ describe "#commit_status" do
include_context :drone_ci_service
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(drone, { commit_status: 'foo' }, 'sha', 'ref')
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(drone, {commit_status: "foo"}, "sha", "ref")
- expect(drone.commit_status('sha', 'ref')).to eq('foo')
+ expect(drone.commit_status("sha", "ref")).to eq("foo")
end
end
- describe '#calculate_reactive_cache' do
+ describe "#calculate_reactive_cache" do
include_context :drone_ci_service
- context '#commit_status' do
+ context "#commit_status" do
subject { drone.calculate_reactive_cache(sha, branch)[:commit_status] }
- it 'sets commit status to :error when status is 500' do
+ it "sets commit status to :error when status is 500" do
stub_request(status: 500)
is_expected.to eq(:error)
end
- it 'sets commit status to :error when status is 404' do
+ it "sets commit status to :error when status is 404" do
stub_request(status: 404)
is_expected.to eq(:error)
end
{
- "killed" => :canceled,
+ "killed" => :canceled,
"failure" => :failed,
- "error" => :failed,
- "success" => "success"
+ "error" => :failed,
+ "success" => "success",
}.each do |drone_status, our_status|
it "sets commit status to #{our_status.inspect} when returned status is #{drone_status.inspect}" do
- stub_request(body: %Q({"status":"#{drone_status}"}))
+ stub_request(body: %({"status":"#{drone_status}"}))
is_expected.to eq(our_status)
end
@@ -117,7 +117,7 @@ describe DroneCiService, :use_clean_rails_memory_store_caching do
describe "execute" do
include_context :drone_ci_service
- let(:user) { create(:user, username: 'username') }
+ let(:user) { create(:user, username: "username") }
let(:push_sample_data) do
Gitlab::DataBuilder::Push.build_sample(project, user)
end
diff --git a/spec/models/project_services/emails_on_push_service_spec.rb b/spec/models/project_services/emails_on_push_service_spec.rb
index d9b7010e5e5..bb882a543b9 100644
--- a/spec/models/project_services/emails_on_push_service_spec.rb
+++ b/spec/models/project_services/emails_on_push_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe EmailsOnPushService do
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -10,7 +10,7 @@ describe EmailsOnPushService do
it { is_expected.to validate_presence_of(:recipients) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
diff --git a/spec/models/project_services/external_wiki_service_spec.rb b/spec/models/project_services/external_wiki_service_spec.rb
index 62fd97b038b..3848a165e97 100644
--- a/spec/models/project_services/external_wiki_service_spec.rb
+++ b/spec/models/project_services/external_wiki_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ExternalWikiService do
describe "Associations" do
@@ -6,17 +6,17 @@ describe ExternalWikiService do
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:external_wiki_url) }
- it_behaves_like 'issue tracker service URL attribute', :external_wiki_url
+ it_behaves_like "issue tracker service URL attribute", :external_wiki_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb
index fabcb142858..f3396aed013 100644
--- a/spec/models/project_services/flowdock_service_spec.rb
+++ b/spec/models/project_services/flowdock_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe FlowdockService do
describe "Associations" do
@@ -6,8 +6,8 @@ describe FlowdockService do
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,7 +15,7 @@ describe FlowdockService do
it { is_expected.to validate_presence_of(:token) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -34,10 +34,10 @@ describe FlowdockService do
project_id: project.id,
project: project,
service_hook: true,
- token: 'verySecret'
+ token: "verySecret"
)
@sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
- @api_url = 'https://api.flowdock.com/v1/messages'
+ @api_url = "https://api.flowdock.com/v1/messages"
WebMock.stub_request(:post, @api_url)
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 3237b660a16..e8f9cf3731a 100644
--- a/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
+++ b/spec/models/project_services/gitlab_issue_tracker_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GitlabIssueTrackerService do
describe "Associations" do
@@ -6,43 +6,43 @@ describe GitlabIssueTrackerService do
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
subject { described_class.new(project: create(:project), active: true) }
it { is_expected.to validate_presence_of(:issues_url) }
- it_behaves_like 'issue tracker service URL attribute', :issues_url
+ it_behaves_like "issue tracker service URL attribute", :issues_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
subject { described_class.new(project: create(:project), active: false) }
it { is_expected.not_to validate_presence_of(:issues_url) }
end
end
- describe 'project and issue urls' do
+ describe "project and issue urls" do
let(:project) { create(:project) }
let(:service) { project.create_gitlab_issue_tracker_service(active: true) }
- context 'with absolute urls' do
+ context "with absolute urls" do
before do
allow(described_class).to receive(:default_url_options).and_return(script_name: "/gitlab/root")
end
- it 'gives the correct path' do
+ it "gives the correct path" do
expect(service.project_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues")
expect(service.new_issue_url).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/new")
expect(service.issue_url(432)).to eq("http://#{Gitlab.config.gitlab.host}/gitlab/root/#{project.full_path}/issues/432")
end
end
- context 'with relative urls' do
+ context "with relative urls" do
before do
allow(described_class).to receive(:default_url_options).and_return(script_name: "/gitlab/root")
end
- it 'gives the correct path' do
+ it "gives the correct path" do
expect(service.issue_tracker_path).to eq("/gitlab/root/#{project.full_path}/issues")
expect(service.new_issue_path).to eq("/gitlab/root/#{project.full_path}/issues/new")
expect(service.issue_path(432)).to eq("/gitlab/root/#{project.full_path}/issues/432")
diff --git a/spec/models/project_services/irker_service_spec.rb b/spec/models/project_services/irker_service_spec.rb
index cb9ca76fc3f..3cf53487375 100644
--- a/spec/models/project_services/irker_service_spec.rb
+++ b/spec/models/project_services/irker_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
-require 'socket'
-require 'json'
+require "spec_helper"
+require "socket"
+require "json"
describe IrkerService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -17,7 +17,7 @@ describe IrkerService do
it { is_expected.to validate_presence_of(:recipients) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -26,7 +26,7 @@ describe IrkerService do
end
end
- describe 'Execute' do
+ describe "Execute" do
let(:irker) { described_class.new }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -34,11 +34,11 @@ describe IrkerService do
Gitlab::DataBuilder::Push.build_sample(project, user)
end
- let(:recipients) { '#commits irc://test.net/#test ftp://bad' }
- let(:colorize_messages) { '1' }
+ let(:recipients) { "#commits irc://test.net/#test ftp://bad" }
+ let(:colorize_messages) { "1" }
before do
- @irker_server = TCPServer.new 'localhost', 0
+ @irker_server = TCPServer.new "localhost", 0
allow(irker).to receive_messages(
active: true,
@@ -47,9 +47,10 @@ describe IrkerService do
service_hook: true,
server_host: @irker_server.addr[2],
server_port: @irker_server.addr[1],
- default_irc_uri: 'irc://chat.freenode.net/',
+ default_irc_uri: "irc://chat.freenode.net/",
recipients: recipients,
- colorize_messages: colorize_messages)
+ colorize_messages: colorize_messages
+ )
irker.valid?
end
@@ -58,15 +59,15 @@ describe IrkerService do
@irker_server.close
end
- it 'sends 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
conn.readlines.each do |line|
msg = JSON.parse(line.chomp("\n"))
- expect(msg.keys).to match_array(%w(to privmsg))
- expect(msg['to']).to match_array(["irc://chat.freenode.net/#commits",
- "irc://test.net/#test"])
+ expect(msg.keys).to match_array(%w[to privmsg])
+ expect(msg["to"]).to match_array(["irc://chat.freenode.net/#commits",
+ "irc://test.net/#test",])
end
conn.close
end
diff --git a/spec/models/project_services/issue_tracker_service_spec.rb b/spec/models/project_services/issue_tracker_service_spec.rb
index e6a1752576b..a797533dea4 100644
--- a/spec/models/project_services/issue_tracker_service_spec.rb
+++ b/spec/models/project_services/issue_tracker_service_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe IssueTrackerService do
- describe 'Validations' do
+ describe "Validations" do
let(:project) { create :project }
- describe 'only one issue tracker per project' do
+ describe "only one issue tracker per project" do
let(:service) { RedmineService.new(project: project, active: true) }
before do
create(:custom_issue_tracker_service, project: project)
end
- context 'when service is changed manually by user' do
- it 'executes the validation' do
+ context "when service is changed manually by user" do
+ it "executes the validation" do
valid = service.valid?(:manual_change)
expect(valid).to be_falsey
expect(service.errors[:base]).to include(
- 'Another issue tracker is already in use. Only one issue tracker service can be active at a time'
+ "Another issue tracker is already in use. Only one issue tracker service can be active at a time"
)
end
end
- context 'when service is changed internally' do
- it 'does not execute the validation' do
+ context "when service is changed internally" do
+ it "does not execute the validation" do
expect(service.valid?).to be_truthy
end
end
diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb
index 5428fcb1271..4840753e52b 100644
--- a/spec/models/project_services/jira_service_spec.rb
+++ b/spec/models/project_services/jira_service_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe JiraService do
include Gitlab::Routing
include AssetsHelpers
- describe '#options' do
+ describe "#options" do
let(:service) do
described_class.new(
project: build_stubbed(:project),
active: true,
- username: 'username',
- password: 'test',
+ username: "username",
+ password: "test",
jira_issue_transition_id: 24,
- url: 'http://jira.test.com/path/'
+ url: "http://jira.test.com/path/"
)
end
- it 'sets the URL properly' do
+ it "sets the URL properly" do
# jira-ruby gem parses the URI and handles trailing slashes
# fine: https://github.com/sumoheavy/jira-ruby/blob/v1.4.1/lib/jira/http_client.rb#L59
- expect(service.options[:site]).to eq('http://jira.test.com/')
+ expect(service.options[:site]).to eq("http://jira.test.com/")
end
- it 'leaves out trailing slashes in context' do
- expect(service.options[:context_path]).to eq('/path')
+ it "leaves out trailing slashes in context" do
+ expect(service.options[:context_path]).to eq("/path")
end
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
it { is_expected.to allow_value(nil).for(:jira_issue_transition_id) }
- it { is_expected.to allow_value('1,2,3').for(:jira_issue_transition_id) }
- it { is_expected.to allow_value('1;2;3').for(:jira_issue_transition_id) }
- it { is_expected.not_to allow_value('a,b,cd').for(:jira_issue_transition_id) }
+ it { is_expected.to allow_value("1,2,3").for(:jira_issue_transition_id) }
+ it { is_expected.to allow_value("1;2;3").for(:jira_issue_transition_id) }
+ it { is_expected.not_to allow_value("a,b,cd").for(:jira_issue_transition_id) }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:url) }
- it_behaves_like 'issue tracker service URL attribute', :url
+ it_behaves_like "issue tracker service URL attribute", :url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -56,108 +56,108 @@ describe JiraService do
it { is_expected.not_to validate_presence_of(:password) }
end
- context 'validating urls' do
+ context "validating urls" do
let(:service) do
described_class.new(
project: create(:project),
active: true,
- username: 'username',
- password: 'test',
+ username: "username",
+ password: "test",
jira_issue_transition_id: 24,
- url: 'http://jira.test.com'
+ url: "http://jira.test.com"
)
end
- it 'is valid when all fields have required values' do
+ it "is valid when all fields have required values" do
expect(service).to be_valid
end
- it 'is not valid when url is not a valid url' do
- service.url = 'not valid'
+ it "is not valid when url is not a valid url" do
+ service.url = "not valid"
expect(service).not_to be_valid
end
- it 'is not valid when api url is not a valid url' do
- service.api_url = 'not valid'
+ it "is not valid when api url is not a valid url" do
+ service.api_url = "not valid"
expect(service).not_to be_valid
end
- it 'is not valid when username is missing' do
+ it "is not valid when username is missing" do
service.username = nil
expect(service).not_to be_valid
end
- it 'is not valid when password is missing' do
+ it "is not valid when password is missing" do
service.password = nil
expect(service).not_to be_valid
end
- it 'is valid when api url is a valid url' do
- service.api_url = 'http://jira.test.com/api'
+ it "is valid when api url is a valid url" do
+ service.api_url = "http://jira.test.com/api"
expect(service).to be_valid
end
end
end
- describe '.reference_pattern' do
- it_behaves_like 'allows project key on reference pattern'
+ describe ".reference_pattern" do
+ it_behaves_like "allows project key on reference pattern"
- it 'does not allow # on the code' do
- expect(described_class.reference_pattern.match('#123')).to be_nil
- expect(described_class.reference_pattern.match('1#23#12')).to be_nil
+ it "does not allow # on the code" do
+ expect(described_class.reference_pattern.match("#123")).to be_nil
+ expect(described_class.reference_pattern.match("1#23#12")).to be_nil
end
end
- describe '#close_issue' do
- let(:custom_base_url) { 'http://custom_url' }
+ describe "#close_issue" do
+ let(:custom_base_url) { "http://custom_url" }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- shared_examples 'close_issue' do
+ shared_examples "close_issue" do
before do
@jira_service = described_class.new
allow(@jira_service).to receive_messages(
project_id: project.id,
project: project,
service_hook: true,
- url: 'http://jira.example.com',
- username: 'gitlab_jira_username',
- password: 'gitlab_jira_password',
- jira_issue_transition_id: '999'
+ url: "http://jira.example.com",
+ username: "gitlab_jira_username",
+ password: "gitlab_jira_password",
+ jira_issue_transition_id: "999"
)
# These stubs are needed to test JiraService#close_issue.
# We close the issue then do another request to API to check if it got closed.
# Here is stubbed the API return with a closed and an opened issues.
- open_issue = JIRA::Resource::Issue.new(@jira_service.client, attrs: { 'id' => 'JIRA-123' })
+ open_issue = JIRA::Resource::Issue.new(@jira_service.client, attrs: {"id" => "JIRA-123"})
closed_issue = open_issue.dup
allow(open_issue).to receive(:resolution).and_return(false)
allow(closed_issue).to receive(:resolution).and_return(true)
allow(JIRA::Resource::Issue).to receive(:find).and_return(open_issue, closed_issue)
- allow_any_instance_of(JIRA::Resource::Issue).to receive(:key).and_return('JIRA-123')
+ allow_any_instance_of(JIRA::Resource::Issue).to receive(:key).and_return("JIRA-123")
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
@jira_service.save
- project_issues_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123'
- @transitions_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/transitions'
- @comment_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/comment'
- @remote_link_url = 'http://jira.example.com/rest/api/2/issue/JIRA-123/remotelink'
+ project_issues_url = "http://jira.example.com/rest/api/2/issue/JIRA-123"
+ @transitions_url = "http://jira.example.com/rest/api/2/issue/JIRA-123/transitions"
+ @comment_url = "http://jira.example.com/rest/api/2/issue/JIRA-123/comment"
+ @remote_link_url = "http://jira.example.com/rest/api/2/issue/JIRA-123/remotelink"
- WebMock.stub_request(:get, project_issues_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
- WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
- WebMock.stub_request(:post, @comment_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
- WebMock.stub_request(:post, @remote_link_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password))
+ WebMock.stub_request(:get, project_issues_url).with(basic_auth: %w[gitlab_jira_username gitlab_jira_password])
+ WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w[gitlab_jira_username gitlab_jira_password])
+ WebMock.stub_request(:post, @comment_url).with(basic_auth: %w[gitlab_jira_username gitlab_jira_password])
+ WebMock.stub_request(:post, @remote_link_url).with(basic_auth: %w[gitlab_jira_username gitlab_jira_password])
end
- it 'calls JIRA API' do
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ it "calls JIRA API" do
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @comment_url).with(
body: /Issue solved with/
@@ -166,93 +166,93 @@ describe JiraService do
# Check https://developer.atlassian.com/jiradev/jira-platform/guides/other/guide-jira-remote-issue-links/fields-in-remote-issue-links
# for more information
- it 'creates Remote Link reference in JIRA for comment' do
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ it "creates Remote Link reference in JIRA for comment" do
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
- favicon_path = "http://localhost/assets/#{find_asset('favicon.png').digest_path}"
+ favicon_path = "http://localhost/assets/#{find_asset("favicon.png").digest_path}"
# Creates comment
expect(WebMock).to have_requested(:post, @comment_url)
# Creates Remote Link in JIRA issue fields
expect(WebMock).to have_requested(:post, @remote_link_url).with(
body: hash_including(
- GlobalID: 'GitLab',
- relationship: 'mentioned on',
+ GlobalID: "GitLab",
+ relationship: "mentioned on",
object: {
url: "#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/#{commit_id}",
title: "Solved by commit #{commit_id}.",
- icon: { title: 'GitLab', url16x16: favicon_path },
- status: { resolved: true }
+ icon: {title: "GitLab", url16x16: favicon_path},
+ status: {resolved: true},
}
)
).once
end
- it 'does not send comment or remote links to issues already closed' do
+ it "does not send comment or remote links to issues already closed" do
allow_any_instance_of(JIRA::Resource::Issue).to receive(:resolution).and_return(true)
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).not_to have_requested(:post, @comment_url)
expect(WebMock).not_to have_requested(:post, @remote_link_url)
end
- it 'does not send comment or remote links to issues with unknown resolution' do
+ it "does not send comment or remote links to issues with unknown resolution" do
allow_any_instance_of(JIRA::Resource::Issue).to receive(:respond_to?).with(:resolution).and_return(false)
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).not_to have_requested(:post, @comment_url)
expect(WebMock).not_to have_requested(:post, @remote_link_url)
end
- it 'references the GitLab commit' do
+ it "references the GitLab commit" do
stub_config_setting(base_url: custom_base_url)
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @comment_url).with(
body: %r{#{custom_base_url}/#{project.full_path}/commit/#{commit_id}}
).once
end
- it 'references the GitLab commit' do
- stub_config_setting(relative_url_root: '/gitlab')
+ it "references the GitLab commit" do
+ stub_config_setting(relative_url_root: "/gitlab")
stub_config_setting(url: Settings.send(:build_gitlab_url))
allow(described_class).to receive(:default_url_options) do
- { script_name: '/gitlab' }
+ {script_name: "/gitlab"}
end
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @comment_url).with(
body: %r{#{Gitlab.config.gitlab.url}/#{project.full_path}/commit/#{commit_id}}
).once
end
- it 'logs exception when transition id is not valid' do
+ it "logs exception when transition id is not valid" do
allow(@jira_service).to receive(:log_error)
- WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w(gitlab_jira_username gitlab_jira_password)).and_raise("Bad Request")
+ WebMock.stub_request(:post, @transitions_url).with(basic_auth: %w[gitlab_jira_username gitlab_jira_password]).and_raise("Bad Request")
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(@jira_service).to have_received(:log_error).with("Issue transition failed", error: "Bad Request", client_url: "http://jira.example.com")
end
- it 'calls the api with jira_issue_transition_id' do
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ it "calls the api with jira_issue_transition_id" do
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
expect(WebMock).to have_requested(:post, @transitions_url).with(
body: /999/
).once
end
- context 'when have multiple transition ids' do
- it 'calls the api with transition ids separated by comma' do
- allow(@jira_service).to receive_messages(jira_issue_transition_id: '1,2,3')
+ context "when have multiple transition ids" do
+ it "calls the api with transition ids separated by comma" do
+ allow(@jira_service).to receive_messages(jira_issue_transition_id: "1,2,3")
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
1.upto(3) do |transition_id|
expect(WebMock).to have_requested(:post, @transitions_url).with(
@@ -261,10 +261,10 @@ describe JiraService do
end
end
- it 'calls the api with transition ids separated by semicolon' do
- allow(@jira_service).to receive_messages(jira_issue_transition_id: '1;2;3')
+ it "calls the api with transition ids separated by semicolon" do
+ allow(@jira_service).to receive_messages(jira_issue_transition_id: "1;2;3")
- @jira_service.close_issue(resource, ExternalIssue.new('JIRA-123', project))
+ @jira_service.close_issue(resource, ExternalIssue.new("JIRA-123", project))
1.upto(3) do |transition_id|
expect(WebMock).to have_requested(:post, @transitions_url).with(
@@ -275,175 +275,175 @@ describe JiraService do
end
end
- context 'when resource is a merge request' do
+ context "when resource is a merge request" do
let(:resource) { create(:merge_request) }
let(:commit_id) { resource.diff_head_sha }
- it_behaves_like 'close_issue'
+ it_behaves_like "close_issue"
end
- context 'when resource is a commit' do
- let(:resource) { project.commit('master') }
+ context "when resource is a commit" do
+ let(:resource) { project.commit("master") }
let(:commit_id) { resource.id }
- it_behaves_like 'close_issue'
+ it_behaves_like "close_issue"
end
end
- describe '#test_settings' do
+ describe "#test_settings" do
let(:jira_service) do
described_class.new(
project: create(:project),
- url: 'http://jira.example.com',
- username: 'jira_username',
- password: 'jira_password'
+ url: "http://jira.example.com",
+ username: "jira_username",
+ password: "jira_password"
)
end
def test_settings(api_url = nil)
- api_url ||= 'jira.example.com'
+ api_url ||= "jira.example.com"
test_url = "http://#{api_url}/rest/api/2/serverInfo"
- WebMock.stub_request(:get, test_url).with(basic_auth: %w(jira_username jira_password)).to_return(body: { url: 'http://url' }.to_json )
+ WebMock.stub_request(:get, test_url).with(basic_auth: %w[jira_username jira_password]).to_return(body: {url: "http://url"}.to_json)
jira_service.test(nil)
end
- context 'when the test succeeds' do
- it 'tries to get JIRA project with URL when API URL not set' do
- test_settings('jira.example.com')
+ context "when the test succeeds" do
+ it "tries to get JIRA project with URL when API URL not set" do
+ test_settings("jira.example.com")
end
- it 'returns correct result' do
- expect(test_settings).to eq( { success: true, result: { 'url' => 'http://url' } })
+ it "returns correct result" do
+ expect(test_settings).to eq({success: true, result: {"url" => "http://url"}})
end
- it 'tries to get JIRA project with API URL if set' do
- jira_service.update(api_url: 'http://jira.api.com')
- test_settings('jira.api.com')
+ it "tries to get JIRA project with API URL if set" do
+ jira_service.update(api_url: "http://jira.api.com")
+ test_settings("jira.api.com")
end
end
- context 'when the test fails' do
- it 'returns result with the error' do
- test_url = 'http://jira.example.com/rest/api/2/serverInfo'
- WebMock.stub_request(:get, test_url).with(basic_auth: %w(jira_username jira_password))
- .to_raise(JIRA::HTTPError.new(double(message: 'Some specific failure.')))
+ context "when the test fails" do
+ it "returns result with the error" do
+ test_url = "http://jira.example.com/rest/api/2/serverInfo"
+ WebMock.stub_request(:get, test_url).with(basic_auth: %w[jira_username jira_password])
+ .to_raise(JIRA::HTTPError.new(double(message: "Some specific failure.")))
- expect(jira_service.test(nil)).to eq( { success: false, result: 'Some specific failure.' })
+ expect(jira_service.test(nil)).to eq({success: false, result: "Some specific failure."})
end
end
end
- describe 'Stored password invalidation' do
+ describe "Stored password invalidation" do
let(:project) { create(:project) }
- context 'when a password was previously set' do
+ context "when a password was previously set" do
before do
@jira_service = described_class.create!(
project: project,
properties: {
- url: 'http://jira.example.com/web',
- username: 'mic',
- password: 'password'
+ url: "http://jira.example.com/web",
+ username: "mic",
+ password: "password",
}
)
end
- context 'when only web url present' do
- it 'reset password if url changed' do
- @jira_service.url = 'http://jira_edited.example.com/rest/api/2'
+ context "when only web url present" do
+ it "reset password if url changed" do
+ @jira_service.url = "http://jira_edited.example.com/rest/api/2"
@jira_service.save
expect(@jira_service.password).to be_nil
end
- it 'reset password if url not changed but api url added' do
- @jira_service.api_url = 'http://jira_edited.example.com/rest/api/2'
+ it "reset password if url not changed but api url added" do
+ @jira_service.api_url = "http://jira_edited.example.com/rest/api/2"
@jira_service.save
expect(@jira_service.password).to be_nil
end
end
- context 'when both web and api url present' do
+ context "when both web and api url present" do
before do
- @jira_service.api_url = 'http://jira.example.com/rest/api/2'
- @jira_service.password = 'password'
+ @jira_service.api_url = "http://jira.example.com/rest/api/2"
+ @jira_service.password = "password"
@jira_service.save
end
- it 'reset password if api url changed' do
- @jira_service.api_url = 'http://jira_edited.example.com/rest/api/2'
+ it "reset password if api url changed" do
+ @jira_service.api_url = "http://jira_edited.example.com/rest/api/2"
@jira_service.save
expect(@jira_service.password).to be_nil
end
- it 'does not reset password if url changed' do
- @jira_service.url = 'http://jira_edited.example.com/rweb'
+ it "does not reset password if url changed" do
+ @jira_service.url = "http://jira_edited.example.com/rweb"
@jira_service.save
- expect(@jira_service.password).to eq('password')
+ expect(@jira_service.password).to eq("password")
end
- it 'reset password if api url set to empty' do
- @jira_service.api_url = ''
+ it "reset password if api url set to empty" do
+ @jira_service.api_url = ""
@jira_service.save
expect(@jira_service.password).to be_nil
end
end
- it 'does not reset password if username changed' do
- @jira_service.username = 'some_name'
+ it "does not reset password if username changed" do
+ @jira_service.username = "some_name"
@jira_service.save
- expect(@jira_service.password).to eq('password')
+ expect(@jira_service.password).to eq("password")
end
- it 'does not reset password if new url is set together with password, even if it\'s the same password' do
- @jira_service.url = 'http://jira_edited.example.com/rest/api/2'
- @jira_service.password = 'password'
+ it "does not reset password if new url is set together with password, even if it's the same password" do
+ @jira_service.url = "http://jira_edited.example.com/rest/api/2"
+ @jira_service.password = "password"
@jira_service.save
- expect(@jira_service.password).to eq('password')
- expect(@jira_service.url).to eq('http://jira_edited.example.com/rest/api/2')
+ expect(@jira_service.password).to eq("password")
+ expect(@jira_service.url).to eq("http://jira_edited.example.com/rest/api/2")
end
- it 'resets password if url changed, even if setter called multiple times' do
- @jira_service.url = 'http://jira1.example.com/rest/api/2'
- @jira_service.url = 'http://jira1.example.com/rest/api/2'
+ it "resets password if url changed, even if setter called multiple times" do
+ @jira_service.url = "http://jira1.example.com/rest/api/2"
+ @jira_service.url = "http://jira1.example.com/rest/api/2"
@jira_service.save
expect(@jira_service.password).to be_nil
end
end
- context 'when no password was previously set' do
+ context "when no password was previously set" do
before do
@jira_service = described_class.create(
project: project,
properties: {
- url: 'http://jira.example.com/rest/api/2',
- username: 'mic'
+ url: "http://jira.example.com/rest/api/2",
+ username: "mic",
}
)
end
- it 'saves password if new url is set together with password' do
- @jira_service.url = 'http://jira_edited.example.com/rest/api/2'
- @jira_service.password = 'password'
+ it "saves password if new url is set together with password" do
+ @jira_service.url = "http://jira_edited.example.com/rest/api/2"
+ @jira_service.password = "password"
@jira_service.save
- expect(@jira_service.password).to eq('password')
- expect(@jira_service.url).to eq('http://jira_edited.example.com/rest/api/2')
+ expect(@jira_service.password).to eq("password")
+ expect(@jira_service.url).to eq("http://jira_edited.example.com/rest/api/2")
end
end
end
- describe 'description and title' do
+ describe "description and title" do
let(:project) { create(:project) }
- context 'when it is not set' do
+ context "when it is not set" do
before do
@service = project.create_jira_service(active: true)
end
@@ -452,15 +452,15 @@ describe JiraService do
@service.destroy!
end
- it 'is initialized' do
- expect(@service.title).to eq('JIRA')
- expect(@service.description).to eq('Jira issue tracker')
+ it "is initialized" do
+ expect(@service.title).to eq("JIRA")
+ expect(@service.description).to eq("Jira issue tracker")
end
end
- context 'when it is set' do
+ context "when it is set" do
before do
- properties = { 'title' => 'Jira One', 'description' => 'Jira One issue tracker' }
+ properties = {"title" => "Jira One", "description" => "Jira One issue tracker"}
@service = project.create_jira_service(active: true, properties: properties)
end
@@ -468,44 +468,45 @@ describe JiraService do
@service.destroy!
end
- it 'is correct' do
- expect(@service.title).to eq('Jira One')
- expect(@service.description).to eq('Jira One issue tracker')
+ it "is correct" do
+ expect(@service.title).to eq("Jira One")
+ expect(@service.description).to eq("Jira One issue tracker")
end
end
end
- describe 'additional cookies' do
+ describe "additional cookies" do
let(:project) { create(:project) }
- context 'provides additional cookies to allow basic auth with oracle webgate' do
+ context "provides additional cookies to allow basic auth with oracle webgate" do
before do
@service = project.create_jira_service(
- active: true, properties: { url: 'http://jira.com' })
+ active: true, properties: {url: "http://jira.com"}
+ )
end
after do
@service.destroy!
end
- it 'is initialized' do
+ it "is initialized" do
expect(@service.options[:use_cookies]).to eq(true)
- expect(@service.options[:additional_cookies]).to eq(['OBBasicAuth=fromDialog'])
+ expect(@service.options[:additional_cookies]).to eq(["OBBasicAuth=fromDialog"])
end
end
end
- describe 'project and issue urls' do
+ describe "project and issue urls" do
let(:project) { create(:project) }
- context 'when gitlab.yml was initialized' do
+ context "when gitlab.yml was initialized" do
before do
settings = {
- 'jira' => {
- 'title' => 'Jira',
- 'url' => 'http://jira.sample/projects/project_a',
- 'api_url' => 'http://jira.sample/api'
- }
+ "jira" => {
+ "title" => "Jira",
+ "url" => "http://jira.sample/projects/project_a",
+ "api_url" => "http://jira.sample/api",
+ },
}
allow(Gitlab.config).to receive(:issues_tracker).and_return(settings)
@service = project.create_jira_service(active: true)
@@ -515,24 +516,24 @@ describe JiraService do
@service.destroy!
end
- it 'is prepopulated with the settings' do
- expect(@service.properties['title']).to eq('Jira')
- expect(@service.properties['url']).to eq('http://jira.sample/projects/project_a')
- expect(@service.properties['api_url']).to eq('http://jira.sample/api')
+ it "is prepopulated with the settings" do
+ expect(@service.properties["title"]).to eq("Jira")
+ expect(@service.properties["url"]).to eq("http://jira.sample/projects/project_a")
+ expect(@service.properties["api_url"]).to eq("http://jira.sample/api")
end
end
end
- describe 'favicon urls', :request_store do
- it 'includes the standard favicon' do
- props = described_class.new.send(:build_remote_link_props, url: 'http://example.com', title: 'title')
+ describe "favicon urls", :request_store do
+ it "includes the standard favicon" do
+ props = described_class.new.send(:build_remote_link_props, url: "http://example.com", title: "title")
expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/assets/favicon(?:-\h+).png$}
end
- it 'includes returns the custom favicon' do
- create :appearance, favicon: fixture_file_upload('spec/fixtures/dk.png')
+ it "includes returns the custom favicon" do
+ create :appearance, favicon: fixture_file_upload("spec/fixtures/dk.png")
- props = described_class.new.send(:build_remote_link_props, url: 'http://example.com', title: 'title')
+ props = described_class.new.send(:build_remote_link_props, url: "http://example.com", title: "title")
expect(props[:object][:icon][:url16x16]).to match %r{^http://localhost/uploads/-/system/appearance/favicon/\d+/dk.png$}
end
end
diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb
index 9c27357ffaf..f3032309771 100644
--- a/spec/models/project_services/kubernetes_service_spec.rb
+++ b/spec/models/project_services/kubernetes_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe KubernetesService, :use_clean_rails_memory_store_caching do
include KubernetesHelpers
@@ -7,12 +7,12 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
let(:project) { create(:kubernetes_project) }
let(:service) { project.deployment_platform }
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -21,7 +21,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { is_expected.to validate_presence_of(:api_url) }
it { is_expected.to validate_presence_of(:token) }
- context 'namespace format' do
+ context "namespace format" do
before do
subject.project = project
subject.api_url = "http://example.com"
@@ -29,19 +29,19 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
{
- 'foo' => true,
- '1foo' => true,
- 'foo1' => true,
- 'foo-bar' => true,
- '-foo' => false,
- 'foo-' => false,
- 'a' * 63 => true,
- 'a' * 64 => false,
- 'a.b' => false,
- 'a*b' => false,
- 'FOO' => true
+ "foo" => true,
+ "1foo" => true,
+ "foo1" => true,
+ "foo-bar" => true,
+ "-foo" => false,
+ "foo-" => false,
+ "a" * 63 => true,
+ "a" * 64 => false,
+ "a.b" => false,
+ "a*b" => false,
+ "FOO" => true,
}.each do |namespace, validity|
- it "validates #{namespace} as #{validity ? 'valid' : 'invalid'}" do
+ it "validates #{namespace} as #{validity ? "valid" : "invalid"}" do
subject.namespace = namespace
expect(subject.valid?).to eq(validity)
@@ -50,7 +50,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.project = project
subject.active = false
@@ -60,162 +60,162 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { is_expected.not_to validate_presence_of(:token) }
end
- context 'with a deprecated service' do
+ context "with a deprecated service" do
let(:kubernetes_service) { create(:kubernetes_service) }
before do
kubernetes_service.update_attribute(:active, false)
- kubernetes_service.properties['namespace'] = "foo"
+ kubernetes_service.properties["namespace"] = "foo"
end
- it 'should not update attributes' do
+ it "should not update attributes" do
expect(kubernetes_service.save).to be_falsy
end
- it 'should include an error with a deprecation message' do
+ it "should include an error with a deprecation message" do
kubernetes_service.valid?
expect(kubernetes_service.errors[:base].first).to match(/Kubernetes service integration has been deprecated/)
end
end
- context 'with a non-deprecated service' do
+ context "with a non-deprecated service" do
let(:kubernetes_service) { create(:kubernetes_service) }
- it 'should update attributes' do
- kubernetes_service.properties['namespace'] = 'foo'
+ it "should update attributes" do
+ kubernetes_service.properties["namespace"] = "foo"
expect(kubernetes_service.save).to be_truthy
end
end
- context 'with an active and deprecated service' do
+ context "with an active and deprecated service" do
let(:kubernetes_service) { create(:kubernetes_service) }
before do
kubernetes_service.active = false
- kubernetes_service.properties['namespace'] = 'foo'
+ kubernetes_service.properties["namespace"] = "foo"
kubernetes_service.save
end
- it 'should deactive the service' do
+ it "should deactive the service" do
expect(kubernetes_service.active?).to be_falsy
end
- it 'should not include a deprecation message as error' do
+ it "should not include a deprecation message as error" do
expect(kubernetes_service.errors.messages.count).to eq(0)
end
- it 'should update attributes' do
- expect(kubernetes_service.properties['namespace']).to eq("foo")
+ it "should update attributes" do
+ expect(kubernetes_service.properties["namespace"]).to eq("foo")
end
end
- context 'with a template service' do
+ context "with a template service" do
let(:kubernetes_service) { create(:kubernetes_service, template: true, active: false) }
before do
- kubernetes_service.properties['namespace'] = 'foo'
+ kubernetes_service.properties["namespace"] = "foo"
end
- it 'should update attributes' do
+ it "should update attributes" do
expect(kubernetes_service.save).to be_truthy
- expect(kubernetes_service.properties['namespace']).to eq('foo')
+ expect(kubernetes_service.properties["namespace"]).to eq("foo")
end
end
end
- describe '#initialize_properties' do
- context 'without a project' do
- it 'leaves the namespace unset' do
+ describe "#initialize_properties" do
+ context "without a project" do
+ it "leaves the namespace unset" do
expect(described_class.new.namespace).to be_nil
end
end
end
- describe '#fields' do
+ describe "#fields" do
let(:kube_namespace) do
- subject.fields.find { |h| h[:name] == 'namespace' }
+ subject.fields.find { |h| h[:name] == "namespace" }
end
- context 'as template' do
+ context "as template" do
before do
subject.template = true
end
- it 'sets the namespace to the default' do
+ it "sets the namespace to the default" do
expect(kube_namespace).not_to be_nil
expect(kube_namespace[:placeholder]).to eq(subject.class::TEMPLATE_PLACEHOLDER)
end
end
- context 'with associated project' do
+ context "with associated project" do
before do
subject.project = project
end
- it 'sets the namespace to the default' do
+ it "sets the namespace to the default" do
expect(kube_namespace).not_to be_nil
expect(kube_namespace[:placeholder]).to match(/\A#{Gitlab::PathRegex::PATH_REGEX_STR}-\d+\z/)
end
end
end
- describe '#actual_namespace' do
+ describe "#actual_namespace" do
subject { service.actual_namespace }
- shared_examples 'a correctly formatted namespace' do
- it 'returns a valid Kubernetes namespace name' do
+ shared_examples "a correctly formatted namespace" do
+ it "returns a valid Kubernetes namespace name" do
expect(subject).to match(Gitlab::Regex.kubernetes_namespace_regex)
expect(subject).to eq(expected_namespace)
end
end
- it_behaves_like 'a correctly formatted namespace' do
+ it_behaves_like "a correctly formatted namespace" do
let(:expected_namespace) { service.send(:default_namespace) }
end
- context 'when the project path contains forbidden characters' do
+ context "when the project path contains forbidden characters" do
before do
- project.path = '-a_Strange.Path--forSure'
+ project.path = "-a_Strange.Path--forSure"
end
- it_behaves_like 'a correctly formatted namespace' do
+ it_behaves_like "a correctly formatted namespace" do
let(:expected_namespace) { "a-strange-path--forsure-#{project.id}" }
end
end
- context 'when namespace is specified' do
+ context "when namespace is specified" do
before do
- service.namespace = 'my-namespace'
+ service.namespace = "my-namespace"
end
- it_behaves_like 'a correctly formatted namespace' do
- let(:expected_namespace) { 'my-namespace' }
+ it_behaves_like "a correctly formatted namespace" do
+ let(:expected_namespace) { "my-namespace" }
end
end
- context 'when service is not assigned to project' do
+ context "when service is not assigned to project" do
before do
service.project = nil
end
- it 'does not return namespace' do
+ it "does not return namespace" do
is_expected.to be_nil
end
end
end
- describe '#test' do
- let(:discovery_url) { 'https://kubernetes.example.com/api/v1' }
+ describe "#test" do
+ let(:discovery_url) { "https://kubernetes.example.com/api/v1" }
before do
stub_kubeclient_discover(service.api_url)
end
- context 'with path prefix in api_url' do
- let(:discovery_url) { 'https://kubernetes.example.com/prefix/api/v1' }
+ context "with path prefix in api_url" do
+ let(:discovery_url) { "https://kubernetes.example.com/prefix/api/v1" }
- it 'tests with the prefix' do
- service.api_url = 'https://kubernetes.example.com/prefix'
+ it "tests with the prefix" do
+ service.api_url = "https://kubernetes.example.com/prefix"
stub_kubeclient_discover(service.api_url)
expect(service.test[:success]).to be_truthy
@@ -223,8 +223,8 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- context 'with custom CA certificate' do
- it 'is added to the certificate store' do
+ context "with custom CA certificate" do
+ it "is added to the certificate store" do
service.ca_pem = "CA PEM DATA"
cert = double("certificate")
@@ -236,16 +236,16 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- context 'success' do
- it 'reads the discovery endpoint' do
+ context "success" do
+ it "reads the discovery endpoint" do
expect(service.test[:success]).to be_truthy
expect(WebMock).to have_requested(:get, discovery_url).once
end
end
- context 'failure' do
- it 'fails to read the discovery endpoint' do
- WebMock.stub_request(:get, service.api_url + '/api/v1').to_return(status: 404)
+ context "failure" do
+ it "fails to read the discovery endpoint" do
+ WebMock.stub_request(:get, service.api_url + "/api/v1").to_return(status: 404)
expect(service.test[:success]).to be_falsy
expect(WebMock).to have_requested(:get, discovery_url).once
@@ -253,55 +253,55 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- describe '#predefined_variable' do
+ describe "#predefined_variable" do
let(:kubeconfig) do
- config_file = expand_fixture_path('config/kubeconfig.yml')
+ config_file = expand_fixture_path("config/kubeconfig.yml")
config = YAML.load(File.read(config_file))
- config.dig('users', 0, 'user')['token'] = 'token'
- config.dig('contexts', 0, 'context')['namespace'] = namespace
- config.dig('clusters', 0, 'cluster')['certificate-authority-data'] =
- Base64.strict_encode64('CA PEM DATA')
+ config.dig("users", 0, "user")["token"] = "token"
+ config.dig("contexts", 0, "context")["namespace"] = namespace
+ config.dig("clusters", 0, "cluster")["certificate-authority-data"] =
+ Base64.strict_encode64("CA PEM DATA")
YAML.dump(config)
end
before do
- subject.api_url = 'https://kube.domain.com'
- subject.token = 'token'
- subject.ca_pem = 'CA PEM DATA'
+ subject.api_url = "https://kube.domain.com"
+ subject.token = "token"
+ subject.ca_pem = "CA PEM DATA"
subject.project = project
end
- shared_examples 'setting variables' do
- it 'sets the variables' do
+ shared_examples "setting variables" do
+ it "sets the variables" do
expect(subject.predefined_variables(project: project)).to include(
- { key: 'KUBE_URL', value: 'https://kube.domain.com', public: true },
- { key: 'KUBE_TOKEN', value: 'token', public: false },
- { key: 'KUBE_NAMESPACE', value: namespace, public: true },
- { key: 'KUBECONFIG', value: kubeconfig, public: false, file: true },
- { key: 'KUBE_CA_PEM', value: 'CA PEM DATA', public: true },
- { key: 'KUBE_CA_PEM_FILE', value: 'CA PEM DATA', public: true, file: true }
+ {key: "KUBE_URL", value: "https://kube.domain.com", public: true},
+ {key: "KUBE_TOKEN", value: "token", public: false},
+ {key: "KUBE_NAMESPACE", value: namespace, public: true},
+ {key: "KUBECONFIG", value: kubeconfig, public: false, file: true},
+ {key: "KUBE_CA_PEM", value: "CA PEM DATA", public: true},
+ {key: "KUBE_CA_PEM_FILE", value: "CA PEM DATA", public: true, file: true}
)
end
end
- context 'namespace is provided' do
- let(:namespace) { 'my-project' }
+ context "namespace is provided" do
+ let(:namespace) { "my-project" }
before do
subject.namespace = namespace
end
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
end
- context 'no namespace provided' do
+ context "no namespace provided" do
let(:namespace) { subject.actual_namespace }
- it_behaves_like 'setting variables'
+ it_behaves_like "setting variables"
- it 'sets the KUBE_NAMESPACE' do
- kube_namespace = subject.predefined_variables(project: project).find { |h| h[:key] == 'KUBE_NAMESPACE' }
+ it "sets the KUBE_NAMESPACE" do
+ kube_namespace = subject.predefined_variables(project: project).find { |h| h[:key] == "KUBE_NAMESPACE" }
expect(kube_namespace).not_to be_nil
expect(kube_namespace[:value]).to match(/\A#{Gitlab::PathRegex::PATH_REGEX_STR}-\d+\z/)
@@ -309,20 +309,20 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- describe '#terminals' do
+ describe "#terminals" do
let(:environment) { build(:environment, project: project, name: "env", slug: "env-000000") }
subject { service.terminals(environment) }
- context 'with invalid pods' do
- it 'returns no terminals' do
- stub_reactive_cache(service, pods: [{ "bad" => "pod" }])
+ context "with invalid pods" do
+ it "returns no terminals" do
+ stub_reactive_cache(service, pods: [{"bad" => "pod"}])
is_expected.to be_empty
end
end
- context 'with valid pods' do
+ context "with valid pods" do
let(:pod) { kube_pod(app: environment.slug) }
let(:terminals) { kube_terminals(service, pod) }
@@ -333,11 +333,11 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
)
end
- it 'returns terminals' do
+ it "returns terminals" do
is_expected.to eq(terminals + terminals)
end
- it 'uses max session time from settings' do
+ it "uses max session time from settings" do
stub_application_setting(terminal_max_session_time: 600)
times = subject.map { |terminal| terminal[:max_session_time] }
@@ -346,10 +346,10 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
end
end
- describe '#calculate_reactive_cache' do
+ describe "#calculate_reactive_cache" do
subject { service.calculate_reactive_cache }
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
service.active = false
end
@@ -357,7 +357,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { is_expected.to be_nil }
end
- context 'when kubernetes responds with valid pods' do
+ context "when kubernetes responds with valid pods" do
before do
stub_kubeclient_pods
end
@@ -365,7 +365,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { is_expected.to eq(pods: [kube_pod]) }
end
- context 'when kubernetes responds with 500s' do
+ context "when kubernetes responds with 500s" do
before do
stub_kubeclient_pods(status: 500)
end
@@ -373,7 +373,7 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
it { expect { subject }.to raise_error(Kubeclient::HttpError) }
end
- context 'when kubernetes responds with 404s' do
+ context "when kubernetes responds with 404s" do
before do
stub_kubeclient_pods(status: 404)
end
@@ -385,14 +385,14 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
describe "#deprecated?" do
let(:kubernetes_service) { create(:kubernetes_service) }
- context 'with an active kubernetes service' do
- it 'should return false' do
+ context "with an active kubernetes service" do
+ it "should return false" do
expect(kubernetes_service.deprecated?).to be_falsy
end
end
- context 'with a inactive kubernetes service' do
- it 'should return true' do
+ context "with a inactive kubernetes service" do
+ it "should return true" do
kubernetes_service.update_attribute(:active, false)
expect(kubernetes_service.deprecated?).to be_truthy
end
@@ -402,18 +402,18 @@ describe KubernetesService, :use_clean_rails_memory_store_caching do
describe "#deprecation_message" do
let(:kubernetes_service) { create(:kubernetes_service) }
- it 'should indicate the service is deprecated' do
+ it "should indicate the service is deprecated" do
expect(kubernetes_service.deprecation_message).to match(/Kubernetes service integration has been deprecated/)
end
- context 'if the services is active' do
- it 'should return a message' do
+ context "if the services is active" do
+ it "should return a message" do
expect(kubernetes_service.deprecation_message).to match(/Your Kubernetes cluster information on this page is still editable/)
end
end
- context 'if the service is not active' do
- it 'should return a message' do
+ context "if the service is not active" do
+ it "should return a message" do
kubernetes_service.update_attribute(:active, false)
expect(kubernetes_service.deprecation_message).to match(/Fields on this page are now uneditable/)
end
diff --git a/spec/models/project_services/mattermost_service_spec.rb b/spec/models/project_services/mattermost_service_spec.rb
index 10c62ca55a7..61c236995b4 100644
--- a/spec/models/project_services/mattermost_service_spec.rb
+++ b/spec/models/project_services/mattermost_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MattermostService do
it_behaves_like "slack or mattermost notifications"
diff --git a/spec/models/project_services/mattermost_slash_commands_service_spec.rb b/spec/models/project_services/mattermost_slash_commands_service_spec.rb
index 1983e0cc967..01b1eed9096 100644
--- a/spec/models/project_services/mattermost_slash_commands_service_spec.rb
+++ b/spec/models/project_services/mattermost_slash_commands_service_spec.rb
@@ -1,120 +1,120 @@
-require 'spec_helper'
+require "spec_helper"
describe MattermostSlashCommandsService do
it_behaves_like "chat slash commands service"
- context 'Mattermost API' do
+ context "Mattermost API" do
let(:project) { create(:project) }
let(:service) { project.build_mattermost_slash_commands_service }
let(:user) { create(:user) }
before do
session = Mattermost::Session.new(nil)
- session.base_uri = 'http://mattermost.example.com'
+ session.base_uri = "http://mattermost.example.com"
allow_any_instance_of(Mattermost::Client).to receive(:with_session)
.and_yield(session)
end
- describe '#configure' do
+ describe "#configure" do
subject do
- service.configure(user, team_id: 'abc',
- trigger: 'gitlab', url: 'http://trigger.url',
- icon_url: 'http://icon.url/icon.png')
+ service.configure(user, team_id: "abc",
+ trigger: "gitlab", url: "http://trigger.url",
+ icon_url: "http://icon.url/icon.png")
end
- context 'the requests succeeds' do
+ context "the requests succeeds" do
before do
- stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
+ stub_request(:post, "http://mattermost.example.com/api/v4/commands")
.with(body: {
- team_id: 'abc',
- trigger: 'gitlab',
- url: 'http://trigger.url',
- icon_url: 'http://icon.url/icon.png',
+ team_id: "abc",
+ trigger: "gitlab",
+ url: "http://trigger.url",
+ icon_url: "http://icon.url/icon.png",
auto_complete: true,
auto_complete_desc: "Perform common operations on: #{project.full_name}",
- auto_complete_hint: '[help]',
+ auto_complete_hint: "[help]",
description: "Perform common operations on: #{project.full_name}",
display_name: "GitLab / #{project.full_name}",
- method: 'P',
- username: 'GitLab'
+ method: "P",
+ username: "GitLab",
}.to_json)
.to_return(
status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: { token: 'token' }.to_json
+ headers: {"Content-Type" => "application/json"},
+ body: {token: "token"}.to_json
)
end
- it 'saves the service' do
+ it "saves the service" do
expect { subject }.to change { project.services.count }.by(1)
end
- it 'saves the token' do
+ it "saves the token" do
subject
- expect(service.reload.token).to eq('token')
+ expect(service.reload.token).to eq("token")
end
end
- context 'an error is received' do
+ context "an error is received" do
before do
- stub_request(:post, 'http://mattermost.example.com/api/v4/commands')
+ stub_request(:post, "http://mattermost.example.com/api/v4/commands")
.to_return(
status: 500,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: {
- id: 'api.command.duplicate_trigger.app_error',
- message: 'This trigger word is already in use. Please choose another word.',
- detailed_error: '',
- request_id: 'obc374man7bx5r3dbc1q5qhf3r',
- status_code: 500
+ id: "api.command.duplicate_trigger.app_error",
+ message: "This trigger word is already in use. Please choose another word.",
+ detailed_error: "",
+ request_id: "obc374man7bx5r3dbc1q5qhf3r",
+ status_code: 500,
}.to_json
)
end
- it 'shows error messages' do
+ it "shows error messages" do
succeeded, message = subject
expect(succeeded).to be(false)
- expect(message).to eq('This trigger word is already in use. Please choose another word.')
+ expect(message).to eq("This trigger word is already in use. Please choose another word.")
end
end
end
- describe '#list_teams' do
+ describe "#list_teams" do
subject do
service.list_teams(user)
end
- context 'the requests succeeds' do
+ context "the requests succeeds" do
before do
- stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
+ stub_request(:get, "http://mattermost.example.com/api/v4/users/me/teams")
.to_return(
status: 200,
- headers: { 'Content-Type' => 'application/json' },
- body: [{ id: 'test_team_id' }].to_json
+ headers: {"Content-Type" => "application/json"},
+ body: [{id: "test_team_id"}].to_json
)
end
- it 'returns a list of teams' do
+ it "returns a list of teams" do
expect(subject).not_to be_empty
end
end
- context 'an error is received' do
+ context "an error is received" do
before do
- stub_request(:get, 'http://mattermost.example.com/api/v4/users/me/teams')
+ stub_request(:get, "http://mattermost.example.com/api/v4/users/me/teams")
.to_return(
status: 500,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: {
- message: 'Failed to get team list.'
+ message: "Failed to get team list.",
}.to_json
)
end
- it 'shows error messages' do
+ it "shows error messages" do
expect(subject).to eq([[], "Failed to get team list."])
end
end
diff --git a/spec/models/project_services/microsoft_teams_service_spec.rb b/spec/models/project_services/microsoft_teams_service_spec.rb
index 3351c6280b4..15689065fca 100644
--- a/spec/models/project_services/microsoft_teams_service_spec.rb
+++ b/spec/models/project_services/microsoft_teams_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe MicrosoftTeamsService do
let(:chat_service) { described_class.new }
- let(:webhook_url) { 'https://example.gitlab.com/' }
+ let(:webhook_url) { "https://example.gitlab.com/" }
describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:webhook) }
- it_behaves_like 'issue tracker service URL attribute', :webhook
+ it_behaves_like "issue tracker service URL attribute", :webhook
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -43,7 +43,7 @@ describe MicrosoftTeamsService do
WebMock.stub_request(:post, webhook_url)
end
- context 'with push events' do
+ context "with push events" do
let(:push_sample_data) do
Gitlab::DataBuilder::Push.build_sample(project, user)
end
@@ -54,19 +54,19 @@ describe MicrosoftTeamsService do
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it 'specifies the webhook when it is configured' do
+ it "specifies the webhook when it is configured" do
expect(MicrosoftTeams::Notifier).to receive(:new).with(webhook_url).and_return(double(:microsoft_teams_service).as_null_object)
chat_service.execute(push_sample_data)
end
end
- context 'with issue events' do
- let(:opts) { { title: 'Awesome issue', description: 'please fix' } }
+ context "with issue events" do
+ let(:opts) { {title: "Awesome issue", description: "please fix"} }
let(:issues_sample_data) do
service = Issues::CreateService.new(project, user, opts)
issue = service.execute
- service.hook_data(issue, 'open')
+ service.hook_data(issue, "open")
end
it "calls Microsoft Teams API" do
@@ -76,20 +76,20 @@ describe MicrosoftTeamsService do
end
end
- context 'with merge events' do
+ context "with merge events" do
let(:opts) do
{
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'feature',
- target_branch: 'master'
+ title: "Awesome merge_request",
+ description: "please fix",
+ source_branch: "feature",
+ target_branch: "master",
}
end
let(:merge_sample_data) do
service = MergeRequests::CreateService.new(project, user, opts)
merge_request = service.execute
- service.hook_data(merge_request, 'open')
+ service.hook_data(merge_request, "open")
end
before do
@@ -103,17 +103,17 @@ describe MicrosoftTeamsService do
end
end
- context 'with wiki page events' do
+ context "with wiki page events" do
let(:opts) do
{
title: "Awesome wiki_page",
content: "Some text describing some thing or another",
format: "md",
- message: "user created page: Awesome wiki_page"
+ message: "user created page: Awesome wiki_page",
}
end
let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) }
- let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, 'create') }
+ let(:wiki_page_sample_data) { Gitlab::DataBuilder::WikiPage.build(wiki_page, user, "create") }
it "calls Microsoft Teams API" do
chat_service.execute(wiki_page_sample_data)
@@ -138,12 +138,12 @@ describe MicrosoftTeamsService do
WebMock.stub_request(:post, webhook_url)
end
- context 'when commit comment event executed' do
+ context "when commit comment event executed" do
let(:commit_note) do
create(:note_on_commit, author: user,
project: project,
commit_id: project.repository.commit.id,
- note: 'a comment on a commit')
+ note: "a comment on a commit")
end
it "calls Microsoft Teams API for commit comment events" do
@@ -155,7 +155,7 @@ describe MicrosoftTeamsService do
end
end
- context 'when merge request comment event executed' do
+ context "when merge request comment event executed" do
let(:merge_request_note) do
create(:note_on_merge_request, project: project,
note: "merge request note")
@@ -170,7 +170,7 @@ describe MicrosoftTeamsService do
end
end
- context 'when issue comment event executed' do
+ context "when issue comment event executed" do
let(:issue_note) do
create(:note_on_issue, project: project, note: "issue note")
end
@@ -184,7 +184,7 @@ describe MicrosoftTeamsService do
end
end
- context 'when snippet comment event executed' do
+ context "when snippet comment event executed" do
let(:snippet_note) do
create(:note_on_project_snippet, project: project,
note: "snippet note")
@@ -200,14 +200,14 @@ describe MicrosoftTeamsService do
end
end
- describe 'Pipeline events' do
+ describe "Pipeline events" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project, status: status,
- sha: project.commit.sha, ref: project.default_branch)
+ project: project, status: status,
+ sha: project.commit.sha, ref: project.default_branch)
end
before do
@@ -218,12 +218,12 @@ describe MicrosoftTeamsService do
)
end
- shared_examples 'call Microsoft Teams API' do
+ shared_examples "call Microsoft Teams API" do
before do
WebMock.stub_request(:post, webhook_url)
end
- it 'calls Microsoft Teams API for pipeline events' do
+ it "calls Microsoft Teams API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
data[:markdown] = true
@@ -232,22 +232,22 @@ describe MicrosoftTeamsService do
message = ChatMessage::PipelineMessage.new(data)
expect(WebMock).to have_requested(:post, webhook_url)
- .with(body: hash_including({ summary: message.summary }))
+ .with(body: hash_including({summary: message.summary}))
.once
end
end
- context 'with failed pipeline' do
- let(:status) { 'failed' }
+ context "with failed pipeline" do
+ let(:status) { "failed" }
- it_behaves_like 'call Microsoft Teams API'
+ it_behaves_like "call Microsoft Teams API"
end
- context 'with succeeded pipeline' do
- let(:status) { 'success' }
+ context "with succeeded pipeline" do
+ let(:status) { "success" }
- context 'with default to notify_only_broken_pipelines' do
- it 'does not call Microsoft Teams API for pipeline events' do
+ context "with default to notify_only_broken_pipelines" do
+ it "does not call Microsoft Teams API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
@@ -255,26 +255,26 @@ describe MicrosoftTeamsService do
end
end
- context 'with setting notify_only_broken_pipelines to false' do
+ context "with setting notify_only_broken_pipelines to false" do
before do
chat_service.notify_only_broken_pipelines = false
end
- it_behaves_like 'call Microsoft Teams API'
+ it_behaves_like "call Microsoft Teams API"
end
end
- context 'only notify for the default branch' do
- context 'when enabled' do
+ context "only notify for the default branch" do
+ context "when enabled" do
let(:pipeline) do
- create(:ci_pipeline, project: project, status: 'failed', ref: 'not-the-default-branch')
+ create(:ci_pipeline, project: project, status: "failed", ref: "not-the-default-branch")
end
before do
chat_service.notify_only_default_branch = true
end
- it 'does not call the Microsoft Teams API for pipeline events' do
+ it "does not call the Microsoft Teams API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
diff --git a/spec/models/project_services/packagist_service_spec.rb b/spec/models/project_services/packagist_service_spec.rb
index 6acee311700..a71227a251b 100644
--- a/spec/models/project_services/packagist_service_spec.rb
+++ b/spec/models/project_services/packagist_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PackagistService do
describe "Associations" do
@@ -8,26 +8,26 @@ describe PackagistService do
let(:project) { create(:project) }
- let(:packagist_server) { 'https://packagist.example.com' }
- let(:packagist_username) { 'theUser' }
- let(:packagist_token) { 'verySecret' }
+ let(:packagist_server) { "https://packagist.example.com" }
+ let(:packagist_username) { "theUser" }
+ let(:packagist_token) { "verySecret" }
let(:packagist_hook_url) do
"#{packagist_server}/api/update-package?username=#{packagist_username}&apiToken=#{packagist_token}"
end
let(:packagist_params) do
{
- active: true,
- project: project,
- properties: {
- username: packagist_username,
- token: packagist_token,
- server: packagist_server
- }
+ active: true,
+ project: project,
+ properties: {
+ username: packagist_username,
+ token: packagist_token,
+ server: packagist_server,
+ },
}
end
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:push_sample_data) { Gitlab::DataBuilder::Push.build_sample(project, user) }
@@ -37,7 +37,7 @@ describe PackagistService do
stub_request(:post, packagist_hook_url)
end
- it 'calls Packagist API' do
+ it "calls Packagist API" do
packagist_service.execute(push_sample_data)
expect(a_request(:post, packagist_hook_url)).to have_been_made.once
diff --git a/spec/models/project_services/pipelines_email_service_spec.rb b/spec/models/project_services/pipelines_email_service_spec.rb
index 75ae2207910..59f948da813 100644
--- a/spec/models/project_services/pipelines_email_service_spec.rb
+++ b/spec/models/project_services/pipelines_email_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelinesEmailService, :mailer do
let(:pipeline) do
- create(:ci_pipeline, project: project, sha: project.commit('master').sha)
+ create(:ci_pipeline, project: project, sha: project.commit("master").sha)
end
let(:project) { create(:project, :repository) }
- let(:recipients) { 'test@gitlab.com' }
+ let(:recipients) { "test@gitlab.com" }
let(:receivers) { [recipients] }
let(:data) do
Gitlab::DataBuilder::Pipeline.build(pipeline)
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -22,7 +22,7 @@ describe PipelinesEmailService, :mailer do
it { is_expected.to validate_presence_of(:recipients) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -31,7 +31,7 @@ describe PipelinesEmailService, :mailer do
end
end
- describe '#test_data' do
+ describe "#test_data" do
let(:build) { create(:ci_build) }
let(:project) { build.project }
let(:user) { create(:user) }
@@ -40,14 +40,14 @@ describe PipelinesEmailService, :mailer do
project.add_developer(user)
end
- it 'builds test data' do
+ it "builds test data" do
data = subject.test_data(project, user)
- expect(data[:object_kind]).to eq('pipeline')
+ expect(data[:object_kind]).to eq("pipeline")
end
end
- shared_examples 'sending email' do
+ shared_examples "sending email" do
before do
subject.recipients = recipients
@@ -56,14 +56,14 @@ describe PipelinesEmailService, :mailer do
end
end
- it 'sends email' do
+ it "sends email" do
emails = receivers.map { |r| double(notification_email: r) }
should_only_email(*emails, kind: :bcc)
end
end
- shared_examples 'not sending email' do
+ shared_examples "not sending email" do
before do
subject.recipients = recipients
@@ -72,108 +72,108 @@ describe PipelinesEmailService, :mailer do
end
end
- it 'does not send email' do
+ it "does not send email" do
should_not_email_anyone
end
end
- describe '#test' do
+ describe "#test" do
def run
subject.test(data)
end
- context 'when pipeline is failed' do
+ context "when pipeline is failed" do
before do
- data[:object_attributes][:status] = 'failed'
- pipeline.update(status: 'failed')
+ data[:object_attributes][:status] = "failed"
+ pipeline.update(status: "failed")
end
- it_behaves_like 'sending email'
+ it_behaves_like "sending email"
end
- context 'when pipeline is succeeded' do
+ context "when pipeline is succeeded" do
before do
- data[:object_attributes][:status] = 'success'
- pipeline.update(status: 'success')
+ data[:object_attributes][:status] = "success"
+ pipeline.update(status: "success")
end
- it_behaves_like 'sending email'
+ it_behaves_like "sending email"
end
end
- describe '#execute' do
+ describe "#execute" do
def run
subject.execute(data)
end
- context 'with recipients' do
- context 'with failed pipeline' do
+ context "with recipients" do
+ context "with failed pipeline" do
before do
- data[:object_attributes][:status] = 'failed'
- pipeline.update(status: 'failed')
+ data[:object_attributes][:status] = "failed"
+ pipeline.update(status: "failed")
end
- it_behaves_like 'sending email'
+ it_behaves_like "sending email"
end
- context 'with succeeded pipeline' do
+ context "with succeeded pipeline" do
before do
- data[:object_attributes][:status] = 'success'
- pipeline.update(status: 'success')
+ data[:object_attributes][:status] = "success"
+ pipeline.update(status: "success")
end
- it_behaves_like 'not sending email'
+ it_behaves_like "not sending email"
end
- context 'with notify_only_broken_pipelines on' do
+ context "with notify_only_broken_pipelines on" do
before do
subject.notify_only_broken_pipelines = true
end
- context 'with failed pipeline' do
+ context "with failed pipeline" do
before do
- data[:object_attributes][:status] = 'failed'
- pipeline.update(status: 'failed')
+ data[:object_attributes][:status] = "failed"
+ pipeline.update(status: "failed")
end
- it_behaves_like 'sending email'
+ it_behaves_like "sending email"
end
- context 'with succeeded pipeline' do
+ context "with succeeded pipeline" do
before do
- data[:object_attributes][:status] = 'success'
- pipeline.update(status: 'success')
+ data[:object_attributes][:status] = "success"
+ pipeline.update(status: "success")
end
- it_behaves_like 'not sending email'
+ it_behaves_like "not sending email"
end
end
end
- context 'with empty recipients list' do
- let(:recipients) { ' ,, ' }
+ context "with empty recipients list" do
+ let(:recipients) { " ,, " }
- context 'with failed pipeline' do
+ context "with failed pipeline" do
before do
- data[:object_attributes][:status] = 'failed'
- pipeline.update(status: 'failed')
+ data[:object_attributes][:status] = "failed"
+ pipeline.update(status: "failed")
end
- it_behaves_like 'not sending email'
+ it_behaves_like "not sending email"
end
end
- context 'with recipients list separating with newlines' do
+ context "with recipients list separating with newlines" do
let(:recipients) { "\ntest@gitlab.com, \r\nexample@gitlab.com" }
let(:receivers) { %w[test@gitlab.com example@gitlab.com] }
- context 'with failed pipeline' do
+ context "with failed pipeline" do
before do
- data[:object_attributes][:status] = 'failed'
- pipeline.update(status: 'failed')
+ data[:object_attributes][:status] = "failed"
+ pipeline.update(status: "failed")
end
- it_behaves_like 'sending email'
+ it_behaves_like "sending email"
end
end
end
diff --git a/spec/models/project_services/pivotaltracker_service_spec.rb b/spec/models/project_services/pivotaltracker_service_spec.rb
index f7d2372eca2..8496d9c6cbe 100644
--- a/spec/models/project_services/pivotaltracker_service_spec.rb
+++ b/spec/models/project_services/pivotaltracker_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe PivotaltrackerService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,7 +15,7 @@ describe PivotaltrackerService do
it { is_expected.to validate_presence_of(:token) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -24,29 +24,29 @@ describe PivotaltrackerService do
end
end
- describe 'Execute' do
+ describe "Execute" do
let(:service) do
described_class.new.tap do |service|
- service.token = 'secret_api_token'
+ service.token = "secret_api_token"
end
end
let(:url) { PivotaltrackerService::API_ENDPOINT }
- def push_data(branch: 'master')
+ def push_data(branch: "master")
{
- object_kind: 'push',
+ object_kind: "push",
ref: "refs/heads/#{branch}",
commits: [
{
- id: '21c12ea',
+ id: "21c12ea",
author: {
- name: 'Some User'
+ name: "Some User",
},
- url: 'https://example.com/commit',
- message: 'commit message'
- }
- ]
+ url: "https://example.com/commit",
+ message: "commit message",
+ },
+ ],
}
end
@@ -54,41 +54,41 @@ describe PivotaltrackerService do
WebMock.stub_request(:post, url)
end
- it 'should post correct message' do
+ it "should post correct message" do
service.execute(push_data)
expect(WebMock).to have_requested(:post, url).with(
body: {
- 'source_commit' => {
- 'commit_id' => '21c12ea',
- 'author' => 'Some User',
- 'url' => 'https://example.com/commit',
- 'message' => 'commit message'
- }
+ "source_commit" => {
+ "commit_id" => "21c12ea",
+ "author" => "Some User",
+ "url" => "https://example.com/commit",
+ "message" => "commit message",
+ },
},
headers: {
- 'Content-Type' => 'application/json',
- 'X-TrackerToken' => 'secret_api_token'
+ "Content-Type" => "application/json",
+ "X-TrackerToken" => "secret_api_token",
}
).once
end
- context 'when allowed branches is specified' do
+ context "when allowed branches is specified" do
let(:service) do
super().tap do |service|
- service.restrict_to_branch = 'master,v10'
+ service.restrict_to_branch = "master,v10"
end
end
- it 'should post message if branch is in the list' do
- service.execute(push_data(branch: 'master'))
- service.execute(push_data(branch: 'v10'))
+ it "should post message if branch is in the list" do
+ service.execute(push_data(branch: "master"))
+ service.execute(push_data(branch: "v10"))
expect(WebMock).to have_requested(:post, url).twice
end
- it 'should not post message if branch is not in the list' do
- service.execute(push_data(branch: 'mas'))
- service.execute(push_data(branch: 'v11'))
+ it "should not post message if branch is not in the list" do
+ service.execute(push_data(branch: "mas"))
+ service.execute(push_data(branch: "v11"))
expect(WebMock).not_to have_requested(:post, url)
end
diff --git a/spec/models/project_services/prometheus_service_spec.rb b/spec/models/project_services/prometheus_service_spec.rb
index b6cf4c72450..cd3890c4242 100644
--- a/spec/models/project_services/prometheus_service_spec.rb
+++ b/spec/models/project_services/prometheus_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe PrometheusService, :use_clean_rails_memory_store_caching do
include PrometheusHelpers
@@ -13,11 +13,11 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
it { is_expected.to belong_to :project }
end
- context 'redirects' do
- it 'does not follow redirects' do
- redirect_to = 'https://redirected.example.com'
- redirect_req_stub = stub_prometheus_request(prometheus_query_url('1'), status: 302, headers: { location: redirect_to })
- redirected_req_stub = stub_prometheus_request(redirect_to, body: { 'status': 'success' })
+ context "redirects" do
+ it "does not follow redirects" do
+ redirect_to = "https://redirected.example.com"
+ redirect_req_stub = stub_prometheus_request(prometheus_query_url("1"), status: 302, headers: {location: redirect_to})
+ redirected_req_stub = stub_prometheus_request(redirect_to, body: {'status': "success"})
result = service.test
@@ -30,8 +30,8 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
end
end
- describe 'Validations' do
- context 'when manual_configuration is enabled' do
+ describe "Validations" do
+ context "when manual_configuration is enabled" do
before do
subject.manual_configuration = true
end
@@ -39,7 +39,7 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
it { is_expected.to validate_presence_of(:api_url) }
end
- context 'when manual configuration is disabled' do
+ context "when manual configuration is disabled" do
before do
subject.manual_configuration = false
end
@@ -48,34 +48,34 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
end
end
- describe '#test' do
+ describe "#test" do
before do
service.manual_configuration = true
end
- let!(:req_stub) { stub_prometheus_request(prometheus_query_url('1'), body: prometheus_value_body('vector')) }
+ let!(:req_stub) { stub_prometheus_request(prometheus_query_url("1"), body: prometheus_value_body("vector")) }
- context 'success' do
- it 'reads the discovery endpoint' do
- expect(service.test[:result]).to eq('Checked API endpoint')
+ context "success" do
+ it "reads the discovery endpoint" do
+ expect(service.test[:result]).to eq("Checked API endpoint")
expect(service.test[:success]).to be_truthy
expect(req_stub).to have_been_requested.twice
end
end
- context 'failure' do
- let!(:req_stub) { stub_prometheus_request(prometheus_query_url('1'), status: 404) }
+ context "failure" do
+ let!(:req_stub) { stub_prometheus_request(prometheus_query_url("1"), status: 404) }
- it 'fails to read the discovery endpoint' do
+ it "fails to read the discovery endpoint" do
expect(service.test[:success]).to be_falsy
expect(req_stub).to have_been_requested
end
end
end
- describe '#prometheus_client' do
- context 'manual configuration is enabled' do
- let(:api_url) { 'http://some_url' }
+ describe "#prometheus_client" do
+ context "manual configuration is enabled" do
+ let(:api_url) { "http://some_url" }
before do
subject.active = true
@@ -83,128 +83,128 @@ describe PrometheusService, :use_clean_rails_memory_store_caching do
subject.api_url = api_url
end
- it 'returns rest client from api_url' do
+ it "returns rest client from api_url" do
expect(subject.prometheus_client.url).to eq(api_url)
end
end
- context 'manual configuration is disabled' do
- let(:api_url) { 'http://some_url' }
+ context "manual configuration is disabled" do
+ let(:api_url) { "http://some_url" }
before do
subject.manual_configuration = false
subject.api_url = api_url
end
- it 'no client provided' do
+ it "no client provided" do
expect(subject.prometheus_client).to be_nil
end
end
end
- describe '#prometheus_available?' do
- context 'clusters with installed prometheus' do
+ describe "#prometheus_available?" do
+ context "clusters with installed prometheus" do
let!(:cluster) { create(:cluster, projects: [project]) }
let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
- it 'returns true' do
+ it "returns true" do
expect(service.prometheus_available?).to be(true)
end
end
- context 'clusters with updated prometheus' do
+ context "clusters with updated prometheus" do
let!(:cluster) { create(:cluster, projects: [project]) }
let!(:prometheus) { create(:clusters_applications_prometheus, :updated, cluster: cluster) }
- it 'returns true' do
+ it "returns true" do
expect(service.prometheus_available?).to be(true)
end
end
- context 'clusters without prometheus installed' do
+ context "clusters without prometheus installed" do
let(:cluster) { create(:cluster, projects: [project]) }
let!(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) }
- it 'returns false' do
+ it "returns false" do
expect(service.prometheus_available?).to be(false)
end
end
- context 'clusters without prometheus' do
+ context "clusters without prometheus" do
let(:cluster) { create(:cluster, projects: [project]) }
- it 'returns false' do
+ it "returns false" do
expect(service.prometheus_available?).to be(false)
end
end
- context 'no clusters' do
- it 'returns false' do
+ context "no clusters" do
+ it "returns false" do
expect(service.prometheus_available?).to be(false)
end
end
end
- describe '#synchronize_service_state before_save callback' do
- context 'no clusters with prometheus are installed' do
- context 'when service is inactive' do
+ describe "#synchronize_service_state before_save callback" do
+ context "no clusters with prometheus are installed" do
+ context "when service is inactive" do
before do
service.active = false
end
- it 'activates service when manual_configuration is enabled' do
+ it "activates service when manual_configuration is enabled" do
expect { service.update!(manual_configuration: true) }.to change { service.active }.from(false).to(true)
end
- it 'keeps service inactive when manual_configuration is disabled' do
+ it "keeps service inactive when manual_configuration is disabled" do
expect { service.update!(manual_configuration: false) }.not_to change { service.active }.from(false)
end
end
- context 'when service is active' do
+ context "when service is active" do
before do
service.active = true
end
- it 'keeps the service active when manual_configuration is enabled' do
+ it "keeps the service active when manual_configuration is enabled" do
expect { service.update!(manual_configuration: true) }.not_to change { service.active }.from(true)
end
- it 'inactivates the service when manual_configuration is disabled' do
+ it "inactivates the service when manual_configuration is disabled" do
expect { service.update!(manual_configuration: false) }.to change { service.active }.from(true).to(false)
end
end
end
- context 'with prometheus installed in the cluster' do
+ context "with prometheus installed in the cluster" do
before do
allow(service).to receive(:prometheus_available?).and_return(true)
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
service.active = false
end
- it 'activates service when manual_configuration is enabled' do
+ it "activates service when manual_configuration is enabled" do
expect { service.update!(manual_configuration: true) }.to change { service.active }.from(false).to(true)
end
- it 'activates service when manual_configuration is disabled' do
+ it "activates service when manual_configuration is disabled" do
expect { service.update!(manual_configuration: false) }.to change { service.active }.from(false).to(true)
end
end
- context 'when service is active' do
+ context "when service is active" do
before do
service.active = true
end
- it 'keeps service active when manual_configuration is enabled' do
+ it "keeps service active when manual_configuration is enabled" do
expect { service.update!(manual_configuration: true) }.not_to change { service.active }.from(true)
end
- it 'keeps service active when manual_configuration is disabled' do
+ it "keeps service active when manual_configuration is disabled" do
expect { service.update!(manual_configuration: false) }.not_to change { service.active }.from(true)
end
end
diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb
index 54b8c658ff6..58dfa66b2b4 100644
--- a/spec/models/project_services/pushover_service_spec.rb
+++ b/spec/models/project_services/pushover_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe PushoverService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -17,7 +17,7 @@ describe PushoverService do
it { is_expected.to validate_presence_of(:priority) }
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -28,7 +28,7 @@ describe PushoverService do
end
end
- describe 'Execute' do
+ describe "Execute" do
let(:pushover) { described_class.new }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -36,12 +36,12 @@ describe PushoverService do
Gitlab::DataBuilder::Push.build_sample(project, user)
end
- let(:api_key) { 'verySecret' }
- let(:user_key) { 'verySecret' }
- let(:device) { 'myDevice' }
+ let(:api_key) { "verySecret" }
+ let(:user_key) { "verySecret" }
+ let(:device) { "myDevice" }
let(:priority) { 0 }
- let(:sound) { 'bike' }
- let(:api_url) { 'https://api.pushover.net/1/messages.json' }
+ let(:sound) { "bike" }
+ let(:api_url) { "https://api.pushover.net/1/messages.json" }
before do
allow(pushover).to receive_messages(
@@ -58,7 +58,7 @@ describe PushoverService do
WebMock.stub_request(:post, api_url)
end
- it 'calls 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/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb
index 2ac14eab5e1..11de94c39cd 100644
--- a/spec/models/project_services/redmine_service_spec.rb
+++ b/spec/models/project_services/redmine_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe RedmineService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
@@ -15,12 +15,12 @@ describe RedmineService do
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) }
it { is_expected.to validate_presence_of(:new_issue_url) }
- it_behaves_like 'issue tracker service URL attribute', :project_url
- it_behaves_like 'issue tracker service URL attribute', :issues_url
- it_behaves_like 'issue tracker service URL attribute', :new_issue_url
+ it_behaves_like "issue tracker service URL attribute", :project_url
+ it_behaves_like "issue tracker service URL attribute", :issues_url
+ it_behaves_like "issue tracker service URL attribute", :new_issue_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -31,11 +31,11 @@ describe RedmineService do
end
end
- describe '.reference_pattern' do
- it_behaves_like 'allows project key on reference pattern'
+ describe ".reference_pattern" do
+ it_behaves_like "allows project key on reference pattern"
- it 'does allow # on the reference' do
- expect(described_class.reference_pattern.match('#123')[:issue]).to eq('123')
+ it "does allow # on the reference" do
+ expect(described_class.reference_pattern.match("#123")[:issue]).to eq("123")
end
end
end
diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb
index 13cf4d1915e..fc4cbd0827a 100644
--- a/spec/models/project_services/slack_service_spec.rb
+++ b/spec/models/project_services/slack_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SlackService do
it_behaves_like "slack or mattermost notifications"
diff --git a/spec/models/project_services/slack_slash_commands_service_spec.rb b/spec/models/project_services/slack_slash_commands_service_spec.rb
index 5c4bce90ace..75d3c4b63eb 100644
--- a/spec/models/project_services/slack_slash_commands_service_spec.rb
+++ b/spec/models/project_services/slack_slash_commands_service_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
describe SlackSlashCommandsService do
it_behaves_like "chat slash commands service"
- describe '#trigger' do
- context 'when an auth url is generated' do
+ describe "#trigger" do
+ context "when an auth url is generated" do
let(:project) { create(:project) }
let(:params) do
{
- team_domain: 'http://domain.tld',
- team_id: 'T3423423',
- user_id: 'U234234',
- user_name: 'mepmep',
- token: 'token'
+ team_domain: "http://domain.tld",
+ team_id: "T3423423",
+ user_id: "U234234",
+ user_name: "mepmep",
+ token: "token",
}
end
let(:service) do
project.create_slack_slash_commands_service(
- properties: { token: 'token' },
+ properties: {token: "token"},
active: true
)
end
let(:authorize_url) do
- 'http://authorize.example.com/'
+ "http://authorize.example.com/"
end
before do
allow(service).to receive(:authorize_chat_name_url).and_return(authorize_url)
end
- it 'uses slack compatible links' do
+ it "uses slack compatible links" do
response = service.trigger(params)
expect(response[:text]).to include("<#{authorize_url}|connect your GitLab account>")
@@ -39,8 +39,8 @@ describe SlackSlashCommandsService do
end
end
- describe '#chat_responder' do
- it 'returns the responder to use for Slack' do
+ describe "#chat_responder" do
+ it "returns the responder to use for Slack" do
expect(described_class.new.chat_responder)
.to eq(Gitlab::Chat::Responder::Slack)
end
diff --git a/spec/models/project_services/teamcity_service_spec.rb b/spec/models/project_services/teamcity_service_spec.rb
index 64b4efca43a..f98b98651e3 100644
--- a/spec/models/project_services/teamcity_service_spec.rb
+++ b/spec/models/project_services/teamcity_service_spec.rb
@@ -1,67 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe TeamcityService, :use_clean_rails_memory_store_caching do
include ReactiveCachingHelpers
- let(:teamcity_url) { 'http://gitlab.com/teamcity' }
+ let(:teamcity_url) { "http://gitlab.com/teamcity" }
subject(:service) do
described_class.create(
project: create(:project),
properties: {
teamcity_url: teamcity_url,
- username: 'mic',
- password: 'password',
- build_type: 'foo'
+ username: "mic",
+ password: "password",
+ build_type: "foo",
}
)
end
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:build_type) }
it { is_expected.to validate_presence_of(:teamcity_url) }
- it_behaves_like 'issue tracker service URL attribute', :teamcity_url
+ it_behaves_like "issue tracker service URL attribute", :teamcity_url
- describe '#username' do
- it 'does not validate the presence of username if password is nil' do
+ describe "#username" do
+ it "does not validate the presence of username if password is nil" do
subject.password = nil
expect(subject).not_to validate_presence_of(:username)
end
- it 'validates the presence of username if password is present' do
- subject.password = 'secret'
+ it "validates the presence of username if password is present" do
+ subject.password = "secret"
expect(subject).to validate_presence_of(:username)
end
end
- describe '#password' do
- it 'does not validate the presence of password if username is nil' do
+ describe "#password" do
+ it "does not validate the presence of password if username is nil" do
subject.username = nil
expect(subject).not_to validate_presence_of(:password)
end
- it 'validates the presence of password if username is present' do
- subject.username = 'john'
+ it "validates the presence of password if username is present" do
+ subject.username = "john"
expect(subject).to validate_presence_of(:password)
end
end
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -73,100 +73,100 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do
end
end
- describe 'Callbacks' do
- describe 'before_update :reset_password' do
- context 'when a password was previously set' do
- it 'resets password if url changed' do
+ describe "Callbacks" do
+ describe "before_update :reset_password" do
+ context "when a password was previously set" do
+ it "resets password if url changed" do
teamcity_service = service
- teamcity_service.teamcity_url = 'http://gitlab1.com'
+ teamcity_service.teamcity_url = "http://gitlab1.com"
teamcity_service.save
expect(teamcity_service.password).to be_nil
end
- it 'does not reset password if username changed' do
+ it "does not reset password if username changed" do
teamcity_service = service
- teamcity_service.username = 'some_name'
+ teamcity_service.username = "some_name"
teamcity_service.save
- expect(teamcity_service.password).to eq('password')
+ expect(teamcity_service.password).to eq("password")
end
it "does not reset password if new url is set together with password, even if it's the same password" do
teamcity_service = service
- teamcity_service.teamcity_url = 'http://gitlab_edited.com'
- teamcity_service.password = 'password'
+ teamcity_service.teamcity_url = "http://gitlab_edited.com"
+ teamcity_service.password = "password"
teamcity_service.save
- expect(teamcity_service.password).to eq('password')
- expect(teamcity_service.teamcity_url).to eq('http://gitlab_edited.com')
+ expect(teamcity_service.password).to eq("password")
+ expect(teamcity_service.teamcity_url).to eq("http://gitlab_edited.com")
end
end
- it 'saves password if new url is set together with password when no password was previously set' do
+ it "saves password if new url is set together with password when no password was previously set" do
teamcity_service = service
teamcity_service.password = nil
- teamcity_service.teamcity_url = 'http://gitlab_edited.com'
- teamcity_service.password = 'password'
+ teamcity_service.teamcity_url = "http://gitlab_edited.com"
+ teamcity_service.password = "password"
teamcity_service.save
- expect(teamcity_service.password).to eq('password')
- expect(teamcity_service.teamcity_url).to eq('http://gitlab_edited.com')
+ expect(teamcity_service.password).to eq("password")
+ expect(teamcity_service.teamcity_url).to eq("http://gitlab_edited.com")
end
end
end
- describe '#build_page' do
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(service, { build_page: 'foo' }, 'sha', 'ref')
+ describe "#build_page" do
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(service, {build_page: "foo"}, "sha", "ref")
- expect(service.build_page('sha', 'ref')).to eq('foo')
+ expect(service.build_page("sha", "ref")).to eq("foo")
end
end
- describe '#commit_status' do
- it 'returns the contents of the reactive cache' do
- stub_reactive_cache(service, { commit_status: 'foo' }, 'sha', 'ref')
+ describe "#commit_status" do
+ it "returns the contents of the reactive cache" do
+ stub_reactive_cache(service, {commit_status: "foo"}, "sha", "ref")
- expect(service.commit_status('sha', 'ref')).to eq('foo')
+ expect(service.commit_status("sha", "ref")).to eq("foo")
end
end
- describe '#calculate_reactive_cache' do
- context 'build_page' do
- subject { service.calculate_reactive_cache('123', 'unused')[:build_page] }
+ describe "#calculate_reactive_cache" do
+ context "build_page" do
+ subject { service.calculate_reactive_cache("123", "unused")[:build_page] }
- it 'returns a specific URL when status is 500' do
+ it "returns a specific URL when status is 500" do
stub_request(status: 500)
- is_expected.to eq('http://gitlab.com/teamcity/viewLog.html?buildTypeId=foo')
+ is_expected.to eq("http://gitlab.com/teamcity/viewLog.html?buildTypeId=foo")
end
- it 'returns a build URL when teamcity_url has no trailing slash' do
- stub_request(body: %q({"build":{"id":"666"}}))
+ it "returns a build URL when teamcity_url has no trailing slash" do
+ stub_request(body: '{"build":{"id":"666"}}')
- is_expected.to eq('http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo')
+ is_expected.to eq("http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo")
end
- context 'teamcity_url has trailing slash' do
- let(:teamcity_url) { 'http://gitlab.com/teamcity/' }
+ context "teamcity_url has trailing slash" do
+ let(:teamcity_url) { "http://gitlab.com/teamcity/" }
- it 'returns a build URL' do
- stub_request(body: %q({"build":{"id":"666"}}))
+ it "returns a build URL" do
+ stub_request(body: '{"build":{"id":"666"}}')
- is_expected.to eq('http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo')
+ is_expected.to eq("http://gitlab.com/teamcity/viewLog.html?buildId=666&buildTypeId=foo")
end
end
end
- context 'commit_status' do
- subject { service.calculate_reactive_cache('123', 'unused')[:commit_status] }
+ context "commit_status" do
+ subject { service.calculate_reactive_cache("123", "unused")[:commit_status] }
- it 'sets commit status to :error when status is 500' do
+ it "sets commit status to :error when status is 500" do
stub_request(status: 500)
is_expected.to eq(:error)
@@ -175,44 +175,44 @@ describe TeamcityService, :use_clean_rails_memory_store_caching do
it 'sets commit status to "pending" when status is 404' do
stub_request(status: 404)
- is_expected.to eq('pending')
+ is_expected.to eq("pending")
end
it 'sets commit status to "success" when build status contains SUCCESS' do
- stub_request(build_status: 'YAY SUCCESS!')
+ stub_request(build_status: "YAY SUCCESS!")
- is_expected.to eq('success')
+ is_expected.to eq("success")
end
it 'sets commit status to "failed" when build status contains FAILURE' do
- stub_request(build_status: 'NO FAILURE!')
+ stub_request(build_status: "NO FAILURE!")
- is_expected.to eq('failed')
+ is_expected.to eq("failed")
end
it 'sets commit status to "pending" when build status contains Pending' do
- stub_request(build_status: 'NO Pending!')
+ stub_request(build_status: "NO Pending!")
- is_expected.to eq('pending')
+ is_expected.to eq("pending")
end
- it 'sets commit status to :error when build status is unknown' do
- stub_request(build_status: 'FOO BAR!')
+ it "sets commit status to :error when build status is unknown" do
+ stub_request(build_status: "FOO BAR!")
is_expected.to eq(:error)
end
end
end
- def stub_request(status: 200, body: nil, build_status: 'success')
- teamcity_full_url = 'http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123'
- auth = %w(mic password)
+ def stub_request(status: 200, body: nil, build_status: "success")
+ teamcity_full_url = "http://gitlab.com/teamcity/httpAuth/app/rest/builds/branch:unspecified:any,revision:123"
+ auth = %w[mic password]
- body ||= %Q({"build":{"status":"#{build_status}","id":"666"}})
+ body ||= %({"build":{"status":"#{build_status}","id":"666"}})
WebMock.stub_request(:get, teamcity_full_url).with(basic_auth: auth).to_return(
status: status,
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body
)
end
diff --git a/spec/models/project_services/youtrack_service_spec.rb b/spec/models/project_services/youtrack_service_spec.rb
index 9524b526a46..053ec2822da 100644
--- a/spec/models/project_services/youtrack_service_spec.rb
+++ b/spec/models/project_services/youtrack_service_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe YoutrackService do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to :project }
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:project_url) }
it { is_expected.to validate_presence_of(:issues_url) }
- it_behaves_like 'issue tracker service URL attribute', :project_url
- it_behaves_like 'issue tracker service URL attribute', :issues_url
+ it_behaves_like "issue tracker service URL attribute", :project_url
+ it_behaves_like "issue tracker service URL attribute", :issues_url
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -28,11 +28,11 @@ describe YoutrackService do
end
end
- describe '.reference_pattern' do
- it_behaves_like 'allows project key on reference pattern'
+ describe ".reference_pattern" do
+ it_behaves_like "allows project key on reference pattern"
- it 'does allow project prefix on the reference' do
- expect(described_class.reference_pattern.match('YT-123')[:issue]).to eq('YT-123')
+ it "does allow project prefix on the reference" do
+ expect(described_class.reference_pattern.match("YT-123")[:issue]).to eq("YT-123")
end
end
end
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb
index 1b439bcfad1..cde6f68718f 100644
--- a/spec/models/project_snippet_spec.rb
+++ b/spec/models/project_snippet_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectSnippet do
describe "Associations" do
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index 9fb0d04ca9e..3f3b6196d23 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Project do
include ProjectForksHelper
include GitHelpers
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:namespace) }
- it { is_expected.to belong_to(:creator).class_name('User') }
+ it { is_expected.to belong_to(:creator).class_name("User") }
it { is_expected.to belong_to(:pool_repository) }
it { is_expected.to have_many(:users) }
it { is_expected.to have_many(:services) }
@@ -21,7 +21,7 @@ describe Project do
it { is_expected.to have_many(:users).through(:project_members) }
it { is_expected.to have_many(:requesters).dependent(:delete_all) }
it { is_expected.to have_many(:notes) }
- it { is_expected.to have_many(:snippets).class_name('ProjectSnippet') }
+ it { is_expected.to have_many(:snippets).class_name("ProjectSnippet") }
it { is_expected.to have_many(:deploy_keys_projects) }
it { is_expected.to have_many(:deploy_keys) }
it { is_expected.to have_many(:hooks) }
@@ -57,12 +57,12 @@ describe Project do
it { is_expected.to have_one(:external_wiki_service) }
it { is_expected.to have_one(:project_feature) }
it { is_expected.to have_one(:project_repository) }
- it { is_expected.to have_one(:statistics).class_name('ProjectStatistics') }
- it { is_expected.to have_one(:import_data).class_name('ProjectImportData') }
- it { is_expected.to have_one(:last_event).class_name('Event') }
+ it { is_expected.to have_one(:statistics).class_name("ProjectStatistics") }
+ it { is_expected.to have_one(:import_data).class_name("ProjectImportData") }
+ it { is_expected.to have_one(:last_event).class_name("Event") }
it { is_expected.to have_one(:forked_from_project).through(:fork_network_member) }
- it { is_expected.to have_one(:auto_devops).class_name('ProjectAutoDevops') }
- it { is_expected.to have_one(:error_tracking_setting).class_name('ErrorTracking::ProjectErrorTrackingSetting') }
+ it { is_expected.to have_one(:auto_devops).class_name("ProjectAutoDevops") }
+ it { is_expected.to have_one(:error_tracking_setting).class_name("ErrorTracking::ProjectErrorTrackingSetting") }
it { is_expected.to have_many(:commit_statuses) }
it { is_expected.to have_many(:ci_pipelines) }
it { is_expected.to have_many(:builds) }
@@ -72,7 +72,7 @@ describe Project do
it { is_expected.to have_many(:variables) }
it { is_expected.to have_many(:triggers) }
it { is_expected.to have_many(:pages_domains) }
- it { is_expected.to have_many(:labels).class_name('ProjectLabel') }
+ it { is_expected.to have_many(:labels).class_name("ProjectLabel") }
it { is_expected.to have_many(:users_star_projects) }
it { is_expected.to have_many(:repository_languages) }
it { is_expected.to have_many(:environments) }
@@ -82,31 +82,31 @@ describe Project do
it { is_expected.to have_many(:lfs_objects_projects) }
it { is_expected.to have_many(:project_group_links) }
it { is_expected.to have_many(:notification_settings).dependent(:delete_all) }
- it { is_expected.to have_many(:forked_to_members).class_name('ForkNetworkMember') }
+ it { is_expected.to have_many(:forked_to_members).class_name("ForkNetworkMember") }
it { is_expected.to have_many(:forks).through(:forked_to_members) }
it { is_expected.to have_many(:uploads) }
it { is_expected.to have_many(:pipeline_schedules) }
it { is_expected.to have_many(:members_and_requesters) }
it { is_expected.to have_many(:clusters) }
it { is_expected.to have_many(:kubernetes_namespaces) }
- it { is_expected.to have_many(:custom_attributes).class_name('ProjectCustomAttribute') }
- it { is_expected.to have_many(:project_badges).class_name('ProjectBadge') }
+ it { is_expected.to have_many(:custom_attributes).class_name("ProjectCustomAttribute") }
+ it { is_expected.to have_many(:project_badges).class_name("ProjectBadge") }
it { is_expected.to have_many(:lfs_file_locks) }
it { is_expected.to have_many(:project_deploy_tokens) }
it { is_expected.to have_many(:deploy_tokens).through(:project_deploy_tokens) }
- it 'has an inverse relationship with merge requests' do
+ it "has an inverse relationship with merge requests" do
expect(described_class.reflect_on_association(:merge_requests).has_inverse?).to eq(:target_project)
end
- context 'after initialized' do
+ context "after initialized" do
it "has a project_feature" do
expect(described_class.new.project_feature).to be_present
end
end
- context 'when creating a new project' do
- it 'automatically creates a CI/CD settings row' do
+ context "when creating a new project" do
+ it "automatically creates a CI/CD settings row" do
project = create(:project)
expect(project.ci_cd_settings).to be_an_instance_of(ProjectCiCdSetting)
@@ -114,15 +114,15 @@ describe Project do
end
end
- context 'updating cd_cd_settings' do
- it 'does not raise an error' do
+ context "updating cd_cd_settings" do
+ it "does not raise an error" do
project = create(:project)
expect { project.update(ci_cd_settings: nil) }.not_to raise_exception
end
end
- describe '#members & #requesters' do
+ describe "#members & #requesters" do
let(:project) { create(:project, :public, :access_requestable) }
let(:requester) { create(:user) }
let(:developer) { create(:user) }
@@ -131,22 +131,22 @@ describe Project do
project.add_developer(developer)
end
- it_behaves_like 'members and requesters associations' do
+ it_behaves_like "members and requesters associations" do
let(:namespace) { project }
end
end
- describe '#boards' do
- it 'raises an error when attempting to add more than one board to the project' do
+ describe "#boards" do
+ it "raises an error when attempting to add more than one board to the project" do
subject.boards.build
- expect { subject.boards.build }.to raise_error(Project::BoardLimitExceeded, 'Number of permitted boards exceeded')
+ expect { subject.boards.build }.to raise_error(Project::BoardLimitExceeded, "Number of permitted boards exceeded")
expect(subject.boards.size).to eq 1
end
end
- describe 'ci_pipelines association' do
- it 'returns only pipelines from ci_sources' do
+ describe "ci_pipelines association" do
+ it "returns only pipelines from ci_sources" do
expect(Ci::Pipeline).to receive(:ci_sources).and_call_original
subject.ci_pipelines
@@ -154,7 +154,7 @@ describe Project do
end
end
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Gitlab::ConfigHelper) }
@@ -164,7 +164,7 @@ describe Project do
it { is_expected.to include_module(Sortable) }
end
- describe '.missing_kubernetes_namespace' do
+ describe ".missing_kubernetes_namespace" do
let!(:project) { create(:project) }
let!(:cluster) { create(:cluster, :provided_by_user, :group) }
let(:kubernetes_namespaces) { project.kubernetes_namespaces }
@@ -173,7 +173,7 @@ describe Project do
it { is_expected.to contain_exactly(project) }
- context 'kubernetes namespace exists' do
+ context "kubernetes namespace exists" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
@@ -182,7 +182,7 @@ describe Project do
end
end
- describe 'validation' do
+ describe "validation" do
let!(:project) { create(:project) }
it { is_expected.to validate_presence_of(:name) }
@@ -192,22 +192,22 @@ describe Project do
it { is_expected.to validate_length_of(:path).is_at_most(255) }
it { is_expected.to validate_length_of(:description).is_at_most(2000) }
it { is_expected.to validate_length_of(:ci_config_path).is_at_most(255) }
- it { is_expected.to allow_value('').for(:ci_config_path) }
- it { is_expected.not_to allow_value('test/../foo').for(:ci_config_path) }
- it { is_expected.not_to allow_value('/test/foo').for(:ci_config_path) }
+ it { is_expected.to allow_value("").for(:ci_config_path) }
+ it { is_expected.not_to allow_value("test/../foo").for(:ci_config_path) }
+ it { is_expected.not_to allow_value("/test/foo").for(:ci_config_path) }
it { is_expected.to validate_presence_of(:creator) }
it { is_expected.to validate_presence_of(:namespace) }
it { is_expected.to validate_presence_of(:repository_storage) }
- it 'validates build timeout constraints' do
+ it "validates build timeout constraints" do
is_expected.to validate_numericality_of(:build_timeout)
.only_integer
.is_greater_than_or_equal_to(10.minutes)
.is_less_than(1.month)
- .with_message('needs to be beetween 10 minutes and 1 month')
+ .with_message("needs to be beetween 10 minutes and 1 month")
end
- it 'does not allow new projects beyond user limits' do
+ it "does not allow new projects beyond user limits" do
project2 = build(:project)
allow(project2)
@@ -219,32 +219,32 @@ describe Project do
expect(project2).not_to be_valid
end
- describe 'wiki path conflict' do
+ describe "wiki path conflict" do
context "when the new path has been used by the wiki of other Project" do
- it 'has 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
- expect(new_project.errors[:name].first).to eq('has already been taken')
+ expect(new_project.errors[:name].first).to eq("has already been taken")
end
end
context "when the new wiki path has been used by the path of other Project" 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')
+ 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")
expect(new_project).not_to be_valid
- expect(new_project.errors[:name].first).to eq('has already been taken')
+ expect(new_project.errors[:name].first).to eq("has already been taken")
end
end
end
- context 'repository storages inclusion' do
- let(:project2) { build(:project, repository_storage: 'missing') }
+ context "repository storages inclusion" do
+ let(:project2) { build(:project, repository_storage: "missing") }
before do
- storages = { 'custom' => { 'path' => 'tmp/tests/custom_repositories' } }
+ storages = {"custom" => {"path" => "tmp/tests/custom_repositories"}}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
@@ -254,89 +254,89 @@ describe Project do
end
end
- describe 'import_url' do
- it 'does not allow an invalid URI as import_url' do
- project = build(:project, import_url: 'invalid://')
+ describe "import_url" do
+ it "does not allow an invalid URI as import_url" do
+ project = build(:project, import_url: "invalid://")
expect(project).not_to be_valid
end
- it 'does allow a SSH URI as import_url for persisted projects' do
+ it "does allow a SSH URI as import_url for persisted projects" do
project = create(:project)
- project.import_url = 'ssh://test@gitlab.com/project.git'
+ project.import_url = "ssh://test@gitlab.com/project.git"
expect(project).to be_valid
end
- it 'does not allow a SSH URI as import_url for new projects' do
- project = build(:project, import_url: 'ssh://test@gitlab.com/project.git')
+ it "does not allow a SSH URI as import_url for new projects" do
+ project = build(:project, import_url: "ssh://test@gitlab.com/project.git")
expect(project).not_to be_valid
end
- it 'does allow a valid URI as import_url' do
- project = build(:project, import_url: 'http://gitlab.com/project.git')
+ it "does allow a valid URI as import_url" do
+ project = build(:project, import_url: "http://gitlab.com/project.git")
expect(project).to be_valid
end
- it 'allows an empty URI' do
- project = build(:project, import_url: '')
+ it "allows an empty URI" do
+ project = build(:project, import_url: "")
expect(project).to be_valid
end
- it 'does not produce import data on an empty URI' do
- project = build(:project, import_url: '')
+ it "does not produce import data on an empty URI" do
+ project = build(:project, import_url: "")
expect(project.import_data).to be_nil
end
- it 'does not produce import data on an invalid URI' do
- project = build(:project, import_url: 'test://')
+ it "does not produce import data on an invalid URI" do
+ project = build(:project, import_url: "test://")
expect(project.import_data).to be_nil
end
it "does not allow import_url pointing to localhost" do
- project = build(:project, import_url: 'http://localhost:9000/t.git')
+ project = build(:project, import_url: "http://localhost:9000/t.git")
expect(project).to be_invalid
- expect(project.errors[:import_url].first).to include('Requests to localhost are not allowed')
+ expect(project.errors[:import_url].first).to include("Requests to localhost are not allowed")
end
- it 'does not allow import_url pointing to the local network' do
- project = build(:project, import_url: 'https://192.168.1.1')
+ it "does not allow import_url pointing to the local network" do
+ project = build(:project, import_url: "https://192.168.1.1")
expect(project).to be_invalid
- expect(project.errors[:import_url].first).to include('Requests to the local network are not allowed')
+ expect(project.errors[:import_url].first).to include("Requests to the local network are not allowed")
end
it "does not allow import_url with invalid ports for new projects" do
- project = build(:project, import_url: 'http://github.com:25/t.git')
+ project = build(:project, import_url: "http://github.com:25/t.git")
expect(project).to be_invalid
- expect(project.errors[:import_url].first).to include('Only allowed ports are 80, 443')
+ expect(project.errors[:import_url].first).to include("Only allowed ports are 80, 443")
end
it "does not allow import_url with invalid ports for persisted projects" do
project = create(:project)
- project.import_url = 'http://github.com:25/t.git'
+ project.import_url = "http://github.com:25/t.git"
expect(project).to be_invalid
- expect(project.errors[:import_url].first).to include('Only allowed ports are 22, 80, 443')
+ expect(project.errors[:import_url].first).to include("Only allowed ports are 22, 80, 443")
end
it "does not allow import_url with invalid user" do
- project = build(:project, import_url: 'http://$user:password@github.com/t.git')
+ project = build(:project, import_url: "http://$user:password@github.com/t.git")
expect(project).to be_invalid
- expect(project.errors[:import_url].first).to include('Username needs to start with an alphanumeric character')
+ expect(project.errors[:import_url].first).to include("Username needs to start with an alphanumeric character")
end
- include_context 'invalid urls'
+ include_context "invalid urls"
- it 'does not allow urls with CR or LF characters' do
+ it "does not allow urls with CR or LF characters" do
project = build(:project)
aggregate_failures do
@@ -350,122 +350,122 @@ describe Project do
end
end
- describe 'project pending deletion' do
+ describe "project pending deletion" do
let!(:project_pending_deletion) do
create(:project,
- pending_delete: true)
+ pending_delete: true)
end
let(:new_project) do
build(:project,
- name: project_pending_deletion.name,
- namespace: project_pending_deletion.namespace)
+ name: project_pending_deletion.name,
+ namespace: project_pending_deletion.namespace)
end
before do
new_project.validate
end
- it 'contains errors related to the project being deleted' do
- expect(new_project.errors.full_messages.first).to eq('The project is still being deleted. Please try again later.')
+ it "contains errors related to the project being deleted" do
+ expect(new_project.errors.full_messages.first).to eq("The project is still being deleted. Please try again later.")
end
end
- describe 'path validation' do
- it 'allows paths reserved on the root namespace' do
- project = build(:project, path: 'api')
+ describe "path validation" do
+ it "allows paths reserved on the root namespace" do
+ project = build(:project, path: "api")
expect(project).to be_valid
end
- it 'rejects paths reserved on another level' do
- project = build(:project, path: 'tree')
+ it "rejects paths reserved on another level" do
+ project = build(:project, path: "tree")
expect(project).not_to be_valid
end
- it 'rejects nested paths' do
- parent = create(:group, :nested, path: 'environments')
- project = build(:project, path: 'folders', namespace: parent)
+ it "rejects nested paths" do
+ parent = create(:group, :nested, path: "environments")
+ project = build(:project, path: "folders", namespace: parent)
expect(project).not_to be_valid
end
- it 'allows a reserved group name' do
+ it "allows a reserved group name" do
parent = create(:group)
- project = build(:project, path: 'avatar', namespace: parent)
+ project = build(:project, path: "avatar", namespace: parent)
expect(project).to be_valid
end
- it 'allows a path ending in a period' do
- project = build(:project, path: 'foo.')
+ it "allows a path ending in a period" do
+ project = build(:project, path: "foo.")
expect(project).to be_valid
end
end
end
- describe '#all_pipelines' do
+ describe "#all_pipelines" do
let(:project) { create(:project) }
before do
- create(:ci_pipeline, project: project, ref: 'master', source: :web)
- create(:ci_pipeline, project: project, ref: 'master', source: :external)
+ create(:ci_pipeline, project: project, ref: "master", source: :web)
+ create(:ci_pipeline, project: project, ref: "master", source: :external)
end
- it 'has all pipelines' do
+ it "has all pipelines" do
expect(project.all_pipelines.size).to eq(2)
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
before do
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end
- it 'should return .external pipelines' do
- expect(project.all_pipelines).to all(have_attributes(source: 'external'))
+ it "should return .external pipelines" do
+ expect(project.all_pipelines).to all(have_attributes(source: "external"))
expect(project.all_pipelines.size).to eq(1)
end
end
end
- describe '#ci_pipelines' do
+ describe "#ci_pipelines" do
let(:project) { create(:project) }
before do
- create(:ci_pipeline, project: project, ref: 'master', source: :web)
- create(:ci_pipeline, project: project, ref: 'master', source: :external)
+ create(:ci_pipeline, project: project, ref: "master", source: :web)
+ create(:ci_pipeline, project: project, ref: "master", source: :external)
end
- it 'has ci pipelines' do
+ it "has ci pipelines" do
expect(project.ci_pipelines.size).to eq(2)
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
before do
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end
- it 'should return .external pipelines' do
- expect(project.ci_pipelines).to all(have_attributes(source: 'external'))
+ it "should return .external pipelines" do
+ expect(project.ci_pipelines).to all(have_attributes(source: "external"))
expect(project.ci_pipelines.size).to eq(1)
end
end
end
- describe 'project token' do
- it 'sets an random token if none provided' do
- project = FactoryBot.create(:project, runners_token: '')
- expect(project.runners_token).not_to eq('')
+ describe "project token" do
+ it "sets an random token if none provided" do
+ project = FactoryBot.create(:project, runners_token: "")
+ expect(project.runners_token).not_to eq("")
end
- it 'does not set an random token if one provided' do
- project = FactoryBot.create(:project, runners_token: 'my-token')
- expect(project.runners_token).to eq('my-token')
+ it "does not set an random token if one provided" do
+ project = FactoryBot.create(:project, runners_token: "my-token")
+ expect(project.runners_token).to eq("my-token")
end
end
- describe 'Respond to' do
+ describe "Respond to" do
it { is_expected.to respond_to(:url_to_repo) }
it { is_expected.to respond_to(:repo_exists?) }
it { is_expected.to respond_to(:execute_hooks) }
@@ -474,7 +474,7 @@ describe Project do
it { is_expected.to respond_to(:full_path) }
end
- describe 'delegation' do
+ describe "delegation" do
[:add_guest, :add_reporter, :add_developer, :add_maintainer, :add_user, :add_users].each do |method|
it { is_expected.to delegate_method(method).to(:team) }
end
@@ -486,116 +486,116 @@ describe Project do
it { is_expected.to delegate_method(:last_pipeline).to(:commit).with_arguments(allow_nil: true) }
end
- describe '#to_reference_with_postfix' do
- it 'returns the full path with reference_postfix' do
- namespace = create(:namespace, path: 'sample-namespace')
- project = create(:project, path: 'sample-project', namespace: namespace)
+ describe "#to_reference_with_postfix" do
+ it "returns the full path with reference_postfix" do
+ namespace = create(:namespace, path: "sample-namespace")
+ project = create(:project, path: "sample-project", namespace: namespace)
- expect(project.to_reference_with_postfix).to eq 'sample-namespace/sample-project>'
+ expect(project.to_reference_with_postfix).to eq "sample-namespace/sample-project>"
end
end
- describe '#to_reference' do
- let(:owner) { create(:user, name: 'Gitlab') }
- let(:namespace) { create(:namespace, path: 'sample-namespace', owner: owner) }
- let(:project) { create(:project, path: 'sample-project', namespace: namespace) }
- let(:group) { create(:group, name: 'Group', path: 'sample-group') }
+ describe "#to_reference" do
+ let(:owner) { create(:user, name: "Gitlab") }
+ let(:namespace) { create(:namespace, path: "sample-namespace", owner: owner) }
+ let(:project) { create(:project, path: "sample-project", namespace: namespace) }
+ let(:group) { create(:group, name: "Group", path: "sample-group") }
- context 'when nil argument' do
- it 'returns nil' do
+ context "when nil argument" do
+ it "returns nil" do
expect(project.to_reference).to be_nil
end
end
- context 'when full is true' do
- it 'returns complete path to the project' do
- expect(project.to_reference(full: true)).to eq 'sample-namespace/sample-project'
- expect(project.to_reference(project, full: true)).to eq 'sample-namespace/sample-project'
- expect(project.to_reference(group, full: true)).to eq 'sample-namespace/sample-project'
+ context "when full is true" do
+ it "returns complete path to the project" do
+ expect(project.to_reference(full: true)).to eq "sample-namespace/sample-project"
+ expect(project.to_reference(project, full: true)).to eq "sample-namespace/sample-project"
+ expect(project.to_reference(group, full: true)).to eq "sample-namespace/sample-project"
end
end
- context 'when same project argument' do
- it 'returns nil' do
+ context "when same project argument" do
+ it "returns nil" do
expect(project.to_reference(project)).to be_nil
end
end
- context 'when cross namespace project argument' do
- let(:another_namespace_project) { create(:project, name: 'another-project') }
+ context "when cross namespace project argument" do
+ let(:another_namespace_project) { create(:project, name: "another-project") }
- it 'returns complete path to the project' do
- expect(project.to_reference(another_namespace_project)).to eq 'sample-namespace/sample-project'
+ it "returns complete path to the project" do
+ expect(project.to_reference(another_namespace_project)).to eq "sample-namespace/sample-project"
end
end
- context 'when same namespace / cross-project argument' do
+ context "when same namespace / cross-project argument" do
let(:another_project) { create(:project, namespace: namespace) }
- it 'returns path to the project' do
- expect(project.to_reference(another_project)).to eq 'sample-project'
+ it "returns path to the project" do
+ expect(project.to_reference(another_project)).to eq "sample-project"
end
end
- context 'when different namespace / cross-project argument' do
- let(:another_namespace) { create(:namespace, path: 'another-namespace', owner: owner) }
- let(:another_project) { create(:project, path: 'another-project', namespace: another_namespace) }
+ context "when different namespace / cross-project argument" do
+ let(:another_namespace) { create(:namespace, path: "another-namespace", owner: owner) }
+ let(:another_project) { create(:project, path: "another-project", namespace: another_namespace) }
- it 'returns full path to the project' do
- expect(project.to_reference(another_project)).to eq 'sample-namespace/sample-project'
+ it "returns full path to the project" do
+ expect(project.to_reference(another_project)).to eq "sample-namespace/sample-project"
end
end
- context 'when argument is a namespace' do
- context 'with same project path' do
- it 'returns path to the project' do
- expect(project.to_reference(namespace)).to eq 'sample-project'
+ context "when argument is a namespace" do
+ context "with same project path" do
+ it "returns path to the project" do
+ expect(project.to_reference(namespace)).to eq "sample-project"
end
end
- context 'with different project path' do
- it 'returns full path to the project' do
- expect(project.to_reference(group)).to eq 'sample-namespace/sample-project'
+ context "with different project path" do
+ it "returns full path to the project" do
+ expect(project.to_reference(group)).to eq "sample-namespace/sample-project"
end
end
end
end
- describe '#to_human_reference' do
- let(:owner) { create(:user, name: 'Gitlab') }
- let(:namespace) { create(:namespace, name: 'Sample namespace', owner: owner) }
- let(:project) { create(:project, name: 'Sample project', namespace: namespace) }
+ describe "#to_human_reference" do
+ let(:owner) { create(:user, name: "Gitlab") }
+ let(:namespace) { create(:namespace, name: "Sample namespace", owner: owner) }
+ let(:project) { create(:project, name: "Sample project", namespace: namespace) }
- context 'when nil argument' do
- it 'returns nil' do
+ context "when nil argument" do
+ it "returns nil" do
expect(project.to_human_reference).to be_nil
end
end
- context 'when same project argument' do
- it 'returns nil' do
+ context "when same project argument" do
+ it "returns nil" do
expect(project.to_human_reference(project)).to be_nil
end
end
- context 'when cross namespace project argument' do
- let(:another_namespace_project) { create(:project, name: 'another-project') }
+ context "when cross namespace project argument" do
+ let(:another_namespace_project) { create(:project, name: "another-project") }
- it 'returns complete name with namespace of the project' do
- expect(project.to_human_reference(another_namespace_project)).to eq 'Gitlab / Sample project'
+ it "returns complete name with namespace of the project" do
+ expect(project.to_human_reference(another_namespace_project)).to eq "Gitlab / Sample project"
end
end
- context 'when same namespace / cross-project argument' do
+ context "when same namespace / cross-project argument" do
let(:another_project) { create(:project, namespace: namespace) }
- it 'returns name of the project' do
- expect(project.to_human_reference(another_project)).to eq 'Sample project'
+ it "returns name of the project" do
+ expect(project.to_human_reference(another_project)).to eq "Sample project"
end
end
end
- describe '#merge_method' do
+ describe "#merge_method" do
using RSpec::Parameterized::TableSyntax
where(:ff, :rebase, :method) do
@@ -614,41 +614,41 @@ describe Project do
end
end
- it 'returns valid url to repo' do
- project = described_class.new(path: 'somewhere')
- expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git')
+ it "returns valid url to repo" do
+ project = described_class.new(path: "somewhere")
+ expect(project.url_to_repo).to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "somewhere.git")
end
describe "#web_url" do
let(:project) { create(:project, path: "somewhere") }
- it 'returns the full web URL for this repo' do
+ it "returns the full web URL for this repo" do
expect(project.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.namespace.full_path}/somewhere")
end
end
describe "#readme_url" do
- context 'with a non-existing repository' do
+ context "with a non-existing repository" do
let(:project) { create(:project) }
- it 'returns nil' do
+ it "returns nil" do
expect(project.readme_url).to be_nil
end
end
- context 'with an existing repository' do
- context 'when no README exists' do
+ context "with an existing repository" do
+ context "when no README exists" do
let(:project) { create(:project, :empty_repo) }
- it 'returns nil' do
+ it "returns nil" do
expect(project.readme_url).to be_nil
end
end
- context 'when a README exists' do
+ context "when a README exists" do
let(:project) { create(:project, :repository) }
- it 'returns the README' do
+ it "returns the README" do
expect(project.readme_url).to eq("#{project.web_url}/blob/master/README.md")
end
end
@@ -659,69 +659,69 @@ describe Project do
let(:project) { create(:project, path: "somewhere") }
let(:user) { create(:user) }
- context 'incoming email enabled' do
+ context "incoming email enabled" do
before do
stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab")
end
- it 'returns the address to create a new issue' do
+ it "returns the address to create a new issue" do
address = "p+#{project.full_path_slug}-#{project.project_id}-#{user.incoming_email_token}-issue@gl.ab"
- expect(project.new_issuable_address(user, 'issue')).to eq(address)
+ expect(project.new_issuable_address(user, "issue")).to eq(address)
end
- it 'returns the address to create a new merge request' do
+ it "returns the address to create a new merge request" do
address = "p+#{project.full_path_slug}-#{project.project_id}-#{user.incoming_email_token}-merge-request@gl.ab"
- expect(project.new_issuable_address(user, 'merge_request')).to eq(address)
+ expect(project.new_issuable_address(user, "merge_request")).to eq(address)
end
- it 'returns nil with invalid address type' do
- expect(project.new_issuable_address(user, 'invalid_param')).to be_nil
+ it "returns nil with invalid address type" do
+ expect(project.new_issuable_address(user, "invalid_param")).to be_nil
end
end
- context 'incoming email disabled' do
+ context "incoming email disabled" do
before do
stub_incoming_email_setting(enabled: false)
end
- it 'returns nil' do
- expect(project.new_issuable_address(user, 'issue')).to be_nil
+ it "returns nil" do
+ expect(project.new_issuable_address(user, "issue")).to be_nil
end
- it 'returns nil' do
- expect(project.new_issuable_address(user, 'merge_request')).to be_nil
+ it "returns nil" do
+ expect(project.new_issuable_address(user, "merge_request")).to be_nil
end
end
end
- describe 'last_activity methods' do
+ describe "last_activity methods" do
let(:timestamp) { 2.hours.ago }
# last_activity_at gets set to created_at upon creation
let(:project) { create(:project, created_at: timestamp, updated_at: timestamp) }
- describe 'last_activity' do
- it 'alias last_activity to last_event' do
+ describe "last_activity" do
+ it "alias last_activity to last_event" do
last_event = create(:event, :closed, project: project)
expect(project.last_activity).to eq(last_event)
end
end
- describe 'last_activity_date' do
- it 'returns the creation date of the project\'s last event if present' do
+ describe "last_activity_date" do
+ it "returns the creation date of the project's last event if present" do
new_event = create(:event, :closed, project: project, created_at: Time.now)
project.reload
expect(project.last_activity_at.to_i).to eq(new_event.created_at.to_i)
end
- it 'returns the project\'s last update date if it has no events' do
+ it "returns the project's last update date if it has no events" do
expect(project.last_activity_date).to eq(project.updated_at)
end
- it 'returns the most recent timestamp' do
+ it "returns the most recent timestamp" do
project.update(updated_at: nil,
last_activity_at: timestamp,
last_repository_updated_at: timestamp - 1.hour)
@@ -737,7 +737,7 @@ describe Project do
end
end
- describe '#get_issue' do
+ describe "#get_issue" do
let(:project) { create(:project) }
let!(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
@@ -746,16 +746,16 @@ describe Project do
project.add_developer(user)
end
- context 'with default issues tracker' do
- it 'returns an issue' do
+ context "with default issues tracker" do
+ it "returns an issue" do
expect(project.get_issue(issue.iid, user)).to eq issue
end
- it 'returns count of open issues' do
+ it "returns count of open issues" do
expect(project.open_issues_count).to eq(1)
end
- it 'returns nil when no issue found' do
+ it "returns nil when no issue found" do
expect(project.get_issue(999, user)).to be_nil
end
@@ -765,14 +765,14 @@ describe Project do
end
end
- context 'with external issues tracker' do
+ context "with external issues tracker" do
let!(:internal_issue) { create(:issue, project: project) }
before do
allow(project).to receive(:external_issue_tracker).and_return(true)
end
- context 'when internal issues are enabled' do
- it 'returns interlan issue' do
+ context "when internal issues are enabled" do
+ it "returns interlan issue" do
issue = project.get_issue(internal_issue.iid, user)
expect(issue).to be_kind_of(Issue)
@@ -780,90 +780,90 @@ describe Project do
expect(issue.project).to eq(project)
end
- it 'returns an ExternalIssue when internal issue does not exists' do
- issue = project.get_issue('FOO-1234', user)
+ it "returns an ExternalIssue when internal issue does not exists" do
+ issue = project.get_issue("FOO-1234", user)
expect(issue).to be_kind_of(ExternalIssue)
- expect(issue.iid).to eq('FOO-1234')
+ expect(issue.iid).to eq("FOO-1234")
expect(issue.project).to eq(project)
end
end
- context 'when internal issues are disabled' do
+ context "when internal issues are disabled" do
before do
project.issues_enabled = false
project.save!
end
- it 'returns always an External issues' do
+ it "returns always an External issues" do
issue = project.get_issue(internal_issue.iid, user)
expect(issue).to be_kind_of(ExternalIssue)
expect(issue.iid).to eq(internal_issue.iid.to_s)
expect(issue.project).to eq(project)
end
- it 'returns an ExternalIssue when internal issue does not exists' do
- issue = project.get_issue('FOO-1234', user)
+ it "returns an ExternalIssue when internal issue does not exists" do
+ issue = project.get_issue("FOO-1234", user)
expect(issue).to be_kind_of(ExternalIssue)
- expect(issue.iid).to eq('FOO-1234')
+ expect(issue.iid).to eq("FOO-1234")
expect(issue.project).to eq(project)
end
end
end
end
- describe '#issue_exists?' do
+ describe "#issue_exists?" do
let(:project) { create(:project) }
- it 'is truthy when issue exists' do
+ it "is truthy when issue exists" do
expect(project).to receive(:get_issue).and_return(double)
expect(project.issue_exists?(1)).to be_truthy
end
- it 'is falsey when issue does not exist' do
+ it "is falsey when issue does not exist" do
expect(project).to receive(:get_issue).and_return(nil)
expect(project.issue_exists?(1)).to be_falsey
end
end
- describe '#to_param' do
- context 'with namespace' do
+ describe "#to_param" do
+ context "with namespace" do
before do
- @group = create(:group, name: 'gitlab')
- @project = create(:project, name: 'gitlabhq', namespace: @group)
+ @group = create(:group, name: "gitlab")
+ @project = create(:project, name: "gitlabhq", namespace: @group)
end
- it { expect(@project.to_param).to eq('gitlabhq') }
+ it { expect(@project.to_param).to eq("gitlabhq") }
end
- context 'with invalid path' do
- it 'returns previous path to keep project suitable for use in URLs when persisted' do
- project = create(:project, path: 'gitlab')
- project.path = 'foo&bar'
+ context "with invalid path" do
+ it "returns previous path to keep project suitable for use in URLs when persisted" do
+ project = create(:project, path: "gitlab")
+ project.path = "foo&bar"
expect(project).not_to be_valid
- expect(project.to_param).to eq 'gitlab'
+ expect(project.to_param).to eq "gitlab"
end
- it 'returns current path when new record' do
- project = build(:project, path: 'gitlab')
- project.path = 'foo&bar'
+ it "returns current path when new record" do
+ project = build(:project, path: "gitlab")
+ project.path = "foo&bar"
expect(project).not_to be_valid
- expect(project.to_param).to eq 'foo&bar'
+ expect(project.to_param).to eq "foo&bar"
end
end
end
- describe '#repository' do
+ describe "#repository" do
let(:project) { create(:project, :repository) }
- it 'returns valid repo' do
+ it "returns valid repo" do
expect(project.repository).to be_kind_of(Repository)
end
end
- describe '#default_issues_tracker?' do
+ describe "#default_issues_tracker?" do
it "is true if used internal tracker" do
project = build(:project)
@@ -878,16 +878,16 @@ describe Project do
end
end
- describe '#empty_repo?' do
- context 'when the repo does not exist' do
+ describe "#empty_repo?" do
+ context "when the repo does not exist" do
let(:project) { build_stubbed(:project) }
- it 'returns true' do
+ it "returns true" do
expect(project.empty_repo?).to be(true)
end
end
- context 'when the repo exists' do
+ context "when the repo exists" do
let(:project) { create(:project, :repository) }
let(:empty_project) { create(:project, :empty_repo) }
@@ -896,34 +896,34 @@ describe Project do
end
end
- describe '#external_issue_tracker' do
+ describe "#external_issue_tracker" do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
- context 'on existing projects with no value for has_external_issue_tracker' do
+ context "on existing projects with no value for has_external_issue_tracker" do
before do
project.update_column(:has_external_issue_tracker, nil)
ext_project.update_column(:has_external_issue_tracker, nil)
end
- it 'updates the has_external_issue_tracker boolean' do
- expect do
+ it "updates the has_external_issue_tracker boolean" do
+ expect {
project.external_issue_tracker
- end.to change { project.reload.has_external_issue_tracker }.to(false)
+ }.to change { project.reload.has_external_issue_tracker }.to(false)
- expect do
+ expect {
ext_project.external_issue_tracker
- end.to change { ext_project.reload.has_external_issue_tracker }.to(true)
+ }.to change { ext_project.reload.has_external_issue_tracker }.to(true)
end
end
- it 'returns nil and does not query services when there is no external issue tracker' do
+ it "returns nil and does not query services when there is no external issue tracker" do
expect(project).not_to receive(:services)
expect(project.external_issue_tracker).to eq(nil)
end
- it 'retrieves external_issue_tracker querying services and cache it when there is external issue tracker' do
+ it "retrieves external_issue_tracker querying services and cache it when there is external issue tracker" do
ext_project.reload # Factory returns a project with changed attributes
expect(ext_project).to receive(:services).once.and_call_original
@@ -931,92 +931,92 @@ describe Project do
end
end
- describe '#cache_has_external_issue_tracker' do
+ describe "#cache_has_external_issue_tracker" do
let(:project) { create(:project, has_external_issue_tracker: nil) }
- it 'stores true if there is any external_issue_tracker' do
+ it "stores true if there is any external_issue_tracker" do
services = double(:service, external_issue_trackers: [RedmineService.new])
expect(project).to receive(:services).and_return(services)
- expect do
+ expect {
project.cache_has_external_issue_tracker
- end.to change { project.has_external_issue_tracker}.to(true)
+ }.to change { project.has_external_issue_tracker}.to(true)
end
- it 'stores false if there is no external_issue_tracker' do
+ it "stores false if there is no external_issue_tracker" do
services = double(:service, external_issue_trackers: [])
expect(project).to receive(:services).and_return(services)
- expect do
+ expect {
project.cache_has_external_issue_tracker
- end.to change { project.has_external_issue_tracker}.to(false)
+ }.to change { project.has_external_issue_tracker}.to(false)
end
- it 'does not cache data when in a read-only GitLab instance' do
+ it "does not cache data when in a read-only GitLab instance" do
allow(Gitlab::Database).to receive(:read_only?) { true }
- expect do
+ expect {
project.cache_has_external_issue_tracker
- end.not_to change { project.has_external_issue_tracker }
+ }.not_to change { project.has_external_issue_tracker }
end
end
- describe '#cache_has_external_wiki' do
+ describe "#cache_has_external_wiki" do
let(:project) { create(:project, has_external_wiki: nil) }
- it 'stores true if there is any external_wikis' do
+ it "stores true if there is any external_wikis" do
services = double(:service, external_wikis: [ExternalWikiService.new])
expect(project).to receive(:services).and_return(services)
- expect do
+ expect {
project.cache_has_external_wiki
- end.to change { project.has_external_wiki}.to(true)
+ }.to change { project.has_external_wiki}.to(true)
end
- it 'stores false if there is no external_wikis' do
+ it "stores false if there is no external_wikis" do
services = double(:service, external_wikis: [])
expect(project).to receive(:services).and_return(services)
- expect do
+ expect {
project.cache_has_external_wiki
- end.to change { project.has_external_wiki}.to(false)
+ }.to change { project.has_external_wiki}.to(false)
end
- it 'does not cache data when in a read-only GitLab instance' do
+ it "does not cache data when in a read-only GitLab instance" do
allow(Gitlab::Database).to receive(:read_only?) { true }
- expect do
+ expect {
project.cache_has_external_wiki
- end.not_to change { project.has_external_wiki }
+ }.not_to change { project.has_external_wiki }
end
end
- describe '#has_wiki?' do
+ describe "#has_wiki?" do
let(:no_wiki_project) { create(:project, :wiki_disabled, has_external_wiki: false) }
let(:wiki_enabled_project) { create(:project) }
let(:external_wiki_project) { create(:project, has_external_wiki: true) }
- it 'returns true if project is wiki enabled or has external wiki' do
+ it "returns true if project is wiki enabled or has external wiki" do
expect(wiki_enabled_project).to have_wiki
expect(external_wiki_project).to have_wiki
expect(no_wiki_project).not_to have_wiki
end
end
- describe '#external_wiki' do
+ describe "#external_wiki" do
let(:project) { create(:project) }
- context 'with an active external wiki' do
+ context "with an active external wiki" do
before do
- create(:service, project: project, type: 'ExternalWikiService', active: true)
+ create(:service, project: project, type: "ExternalWikiService", active: true)
project.external_wiki
end
- it 'sets :has_external_wiki as true' do
+ it "sets :has_external_wiki as true" do
expect(project.has_external_wiki).to be(true)
end
- it 'sets :has_external_wiki as false if an external wiki service is destroyed later' do
+ it "sets :has_external_wiki as false if an external wiki service is destroyed later" do
expect(project.has_external_wiki).to be(true)
project.services.external_wikis.first.destroy
@@ -1025,37 +1025,37 @@ describe Project do
end
end
- context 'with an inactive external wiki' do
+ context "with an inactive external wiki" do
before do
- create(:service, project: project, type: 'ExternalWikiService', active: false)
+ create(:service, project: project, type: "ExternalWikiService", active: false)
end
- it 'sets :has_external_wiki as false' do
+ it "sets :has_external_wiki as false" do
expect(project.has_external_wiki).to be(false)
end
end
- context 'with no external wiki' do
+ context "with no external wiki" do
before do
project.external_wiki
end
- it 'sets :has_external_wiki as false' do
+ it "sets :has_external_wiki as false" do
expect(project.has_external_wiki).to be(false)
end
- it 'sets :has_external_wiki as true if an external wiki service is created later' do
+ it "sets :has_external_wiki as true if an external wiki service is created later" do
expect(project.has_external_wiki).to be(false)
- create(:service, project: project, type: 'ExternalWikiService', active: true)
+ create(:service, project: project, type: "ExternalWikiService", active: true)
expect(project.has_external_wiki).to be(true)
end
end
end
- describe '#star_count' do
- it 'counts stars from multiple users' do
+ describe "#star_count" do
+ it "counts stars from multiple users" do
user1 = create(:user)
user2 = create(:user)
project = create(:project, :public)
@@ -1078,7 +1078,7 @@ describe Project do
expect(project.reload.star_count).to eq(0)
end
- it 'counts stars on the right project' do
+ it "counts stars on the right project" do
user = create(:user)
project1 = create(:project, :public)
project2 = create(:project, :public)
@@ -1112,35 +1112,35 @@ describe Project do
end
end
- describe '#avatar_type' do
+ describe "#avatar_type" do
let(:project) { create(:project) }
- it 'is true if avatar is image' do
- project.update_attribute(:avatar, 'uploads/avatar.png')
+ it "is true if avatar is image" do
+ project.update_attribute(:avatar, "uploads/avatar.png")
expect(project.avatar_type).to be_truthy
end
- it 'is false if avatar is html page' do
- project.update_attribute(:avatar, 'uploads/avatar.html')
- expect(project.avatar_type).to eq(['file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico'])
+ it "is false if avatar is html page" do
+ project.update_attribute(:avatar, "uploads/avatar.html")
+ expect(project.avatar_type).to eq(["file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico"])
end
end
- describe '#avatar_url' do
+ describe "#avatar_url" do
subject { project.avatar_url }
let(:project) { create(:project) }
- context 'when avatar file is uploaded' do
+ context "when avatar file is uploaded" do
let(:project) { create(:project, :public, :with_avatar) }
- it 'shows correct url' do
+ it "shows correct url" do
expect(project.avatar_url).to eq(project.avatar.url)
expect(project.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, project.avatar.url].join)
end
end
- context 'when avatar file in git' do
+ context "when avatar file in git" do
before do
allow(project).to receive(:avatar_in_git) { true }
end
@@ -1150,41 +1150,41 @@ describe Project do
it { is_expected.to eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" }
end
- context 'when git repo is empty' do
+ context "when git repo is empty" do
let(:project) { create(:project) }
it { is_expected.to eq nil }
end
end
- describe '#pipeline_for' do
+ describe "#pipeline_for" do
let(:project) { create(:project, :repository) }
let!(:pipeline) { create_pipeline(project) }
- shared_examples 'giving the correct pipeline' do
+ shared_examples "giving the correct pipeline" do
it { is_expected.to eq(pipeline) }
- context 'return latest' do
+ context "return latest" do
let!(:pipeline2) { create_pipeline(project) }
it { is_expected.to eq(pipeline2) }
end
end
- context 'with explicit sha' do
- subject { project.pipeline_for('master', pipeline.sha) }
+ context "with explicit sha" do
+ subject { project.pipeline_for("master", pipeline.sha) }
- it_behaves_like 'giving the correct pipeline'
+ it_behaves_like "giving the correct pipeline"
end
- context 'with implicit sha' do
- subject { project.pipeline_for('master') }
+ context "with implicit sha" do
+ subject { project.pipeline_for("master") }
- it_behaves_like 'giving the correct pipeline'
+ it_behaves_like "giving the correct pipeline"
end
end
- describe '#builds_enabled' do
+ describe "#builds_enabled" do
let(:project) { create(:project) }
subject { project.builds_enabled }
@@ -1192,8 +1192,8 @@ describe Project do
it { expect(project.builds_enabled?).to be_truthy }
end
- describe '.sort_by_attribute' do
- it 'reorders the input relation by start count desc' do
+ describe ".sort_by_attribute" do
+ it "reorders the input relation by start count desc" do
project1 = create(:project, star_count: 2)
project2 = create(:project, star_count: 1)
project3 = create(:project)
@@ -1204,10 +1204,10 @@ describe Project do
end
end
- describe '.with_shared_runners' do
+ describe ".with_shared_runners" do
subject { described_class.with_shared_runners }
- context 'when shared runners are enabled for project' do
+ context "when shared runners are enabled for project" do
let!(:project) { create(:project, shared_runners_enabled: true) }
it "returns a project" do
@@ -1215,7 +1215,7 @@ describe Project do
end
end
- context 'when shared runners are disabled for project' do
+ context "when shared runners are disabled for project" do
let!(:project) { create(:project, shared_runners_enabled: false) }
it "returns an empty array" do
@@ -1224,12 +1224,12 @@ describe Project do
end
end
- describe '.cached_count', :use_clean_rails_memory_store_caching do
+ describe ".cached_count", :use_clean_rails_memory_store_caching do
let(:group) { create(:group, :public) }
let!(:project1) { create(:project, :public, group: group) }
let!(:project2) { create(:project, :public, group: group) }
- it 'returns total project count' do
+ it "returns total project count" do
expect(described_class).to receive(:count).once.and_call_original
3.times do
@@ -1238,7 +1238,7 @@ describe Project do
end
end
- describe '.trending' do
+ describe ".trending" do
let(:group) { create(:group, :public) }
let(:project1) { create(:project, :public, group: group) }
let(:project2) { create(:project, :public, group: group) }
@@ -1255,11 +1255,11 @@ describe Project do
subject { described_class.trending.to_a }
- it 'sorts projects by the amount of notes in descending order' do
+ it "sorts projects by the amount of notes in descending order" do
expect(subject).to eq([project1, project2])
end
- it 'does not take system notes into account' do
+ it "does not take system notes into account" do
10.times do
create(:note_on_commit, project: project2, system: true)
end
@@ -1268,8 +1268,8 @@ describe Project do
end
end
- describe '.starred_by' do
- it 'returns only projects starred by the given user' do
+ describe ".starred_by" do
+ it "returns only projects starred by the given user" do
user1 = create(:user)
user2 = create(:user)
project1 = create(:project)
@@ -1282,13 +1282,13 @@ describe Project do
end
end
- describe '.visible_to_user' do
+ describe ".visible_to_user" do
let!(:project) { create(:project, :private) }
let!(:user) { create(:user) }
subject { described_class.visible_to_user(user) }
- describe 'when a user has access to a project' do
+ describe "when a user has access to a project" do
before do
project.add_user(user, Gitlab::Access::MAINTAINER)
end
@@ -1296,35 +1296,35 @@ describe Project do
it { is_expected.to eq([project]) }
end
- describe 'when a user does not have access to any projects' do
+ describe "when a user does not have access to any projects" do
it { is_expected.to eq([]) }
end
end
- context 'repository storage by default' do
+ context "repository storage by default" do
let(:project) { build(:project) }
before do
storages = {
- 'default' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories'),
- 'picked' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories')
+ "default" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/repositories"),
+ "picked" => Gitlab::GitalyClient::StorageSettings.new("path" => "tmp/tests/repositories"),
}
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
- it 'picks storage from ApplicationSetting' do
- expect_any_instance_of(ApplicationSetting).to receive(:pick_repository_storage).and_return('picked')
+ it "picks storage from ApplicationSetting" do
+ expect_any_instance_of(ApplicationSetting).to receive(:pick_repository_storage).and_return("picked")
- expect(project.repository_storage).to eq('picked')
+ expect(project.repository_storage).to eq("picked")
end
end
- context 'shared runners by default' do
+ context "shared runners by default" do
let(:project) { create(:project) }
subject { project.shared_runners_enabled }
- context 'are enabled' do
+ context "are enabled" do
before do
stub_application_setting(shared_runners_enabled: true)
end
@@ -1332,7 +1332,7 @@ describe Project do
it { is_expected.to be_truthy }
end
- context 'are disabled' do
+ context "are disabled" do
before do
stub_application_setting(shared_runners_enabled: false)
end
@@ -1341,60 +1341,60 @@ describe Project do
end
end
- describe '#any_runners?' do
- context 'shared runners' do
+ describe "#any_runners?" do
+ context "shared runners" do
let(:project) { create(:project, shared_runners_enabled: shared_runners_enabled) }
let(:specific_runner) { create(:ci_runner, :project, projects: [project]) }
let(:shared_runner) { create(:ci_runner, :instance) }
- context 'for shared runners disabled' do
+ context "for shared runners disabled" do
let(:shared_runners_enabled) { false }
- it 'has no runners available' do
+ it "has no runners available" do
expect(project.any_runners?).to be_falsey
end
- it 'has a specific runner' do
+ it "has a specific runner" do
specific_runner
expect(project.any_runners?).to be_truthy
end
- it 'has 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
- it 'checks the presence of specific runner' do
+ it "checks the presence of specific runner" do
specific_runner
expect(project.any_runners? { |runner| runner == specific_runner }).to be_truthy
end
- it 'returns false if match cannot be found' do
+ it "returns false if match cannot be found" do
specific_runner
expect(project.any_runners? { false }).to be_falsey
end
end
- context 'for shared runners enabled' do
+ context "for shared runners enabled" do
let(:shared_runners_enabled) { true }
- it 'has a shared runner' do
+ it "has a shared runner" do
shared_runner
expect(project.any_runners?).to be_truthy
end
- it 'checks the presence of shared runner' do
+ it "checks the presence of shared runner" do
shared_runner
expect(project.any_runners? { |runner| runner == shared_runner }).to be_truthy
end
- it 'returns false if match cannot be found' do
+ it "returns false if match cannot be found" do
shared_runner
expect(project.any_runners? { false }).to be_falsey
@@ -1402,41 +1402,41 @@ describe Project do
end
end
- context 'group runners' do
+ context "group runners" do
let(:project) { create(:project, group_runners_enabled: group_runners_enabled) }
let(:group) { create(:group, projects: [project]) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
- context 'for group runners disabled' do
+ context "for group runners disabled" do
let(:group_runners_enabled) { false }
- it 'has no runners available' do
+ it "has no runners available" do
expect(project.any_runners?).to be_falsey
end
- it 'has a group runner, but they are prohibited to use' do
+ it "has a group runner, but they are prohibited to use" do
group_runner
expect(project.any_runners?).to be_falsey
end
end
- context 'for group runners enabled' do
+ context "for group runners enabled" do
let(:group_runners_enabled) { true }
- it 'has a group runner' do
+ it "has a group runner" do
group_runner
expect(project.any_runners?).to be_truthy
end
- it 'checks the presence of group runner' do
+ it "checks the presence of group runner" do
group_runner
expect(project.any_runners? { |runner| runner == group_runner }).to be_truthy
end
- it 'returns false if match cannot be found' do
+ it "returns false if match cannot be found" do
group_runner
expect(project.any_runners? { false }).to be_falsey
@@ -1445,12 +1445,12 @@ describe Project do
end
end
- describe '#shared_runners' do
+ describe "#shared_runners" do
let!(:runner) { create(:ci_runner, :instance) }
subject { project.shared_runners }
- context 'when shared runners are enabled for project' do
+ context "when shared runners are enabled for project" do
let!(:project) { create(:project, shared_runners_enabled: true) }
it "returns a list of shared runners" do
@@ -1458,7 +1458,7 @@ describe Project do
end
end
- context 'when shared runners are disabled for project' do
+ context "when shared runners are disabled for project" do
let!(:project) { create(:project, shared_runners_enabled: false) }
it "returns a empty list" do
@@ -1467,16 +1467,16 @@ describe Project do
end
end
- describe '#visibility_level' do
+ describe "#visibility_level" do
let(:project) { build(:project) }
subject { project.visibility_level }
- context 'by default' do
+ context "by default" do
it { is_expected.to eq(Gitlab::VisibilityLevel::PRIVATE) }
end
- context 'when set to INTERNAL in application settings' do
+ context "when set to INTERNAL in application settings" do
before do
stub_application_setting(default_project_visibility: Gitlab::VisibilityLevel::INTERNAL)
end
@@ -1485,16 +1485,16 @@ describe Project do
end
end
- describe '#visibility_level_allowed?' do
+ describe "#visibility_level_allowed?" do
let(:project) { create(:project, :internal) }
- context 'when checking on non-forked project' do
+ context "when checking on non-forked project" do
it { expect(project.visibility_level_allowed?(Gitlab::VisibilityLevel::PRIVATE)).to be_truthy }
it { expect(project.visibility_level_allowed?(Gitlab::VisibilityLevel::INTERNAL)).to be_truthy }
it { expect(project.visibility_level_allowed?(Gitlab::VisibilityLevel::PUBLIC)).to be_truthy }
end
- context 'when checking on forked project' do
+ context "when checking on forked project" do
let(:project) { create(:project, :internal) }
let(:forked_project) { fork_project(project) }
@@ -1504,12 +1504,12 @@ describe Project do
end
end
- describe '#pages_deployed?' do
+ describe "#pages_deployed?" do
let(:project) { create(:project) }
subject { project.pages_deployed? }
- context 'if public folder does exist' do
+ context "if public folder does exist" do
before do
allow(Dir).to receive(:exist?).with(project.public_pages_path).and_return(true)
end
@@ -1522,37 +1522,37 @@ describe Project do
end
end
- describe '#pages_url' do
+ describe "#pages_url" do
let(:group) { create(:group, name: group_name) }
let(:project) { create(:project, namespace: group, name: project_name) }
- let(:domain) { 'Example.com' }
+ let(:domain) { "Example.com" }
subject { project.pages_url }
before do
allow(Settings.pages).to receive(:host).and_return(domain)
- allow(Gitlab.config.pages).to receive(:url).and_return('http://example.com')
+ allow(Gitlab.config.pages).to receive(:url).and_return("http://example.com")
end
- context 'group page' do
- let(:group_name) { 'Group' }
- let(:project_name) { 'group.example.com' }
+ context "group page" do
+ let(:group_name) { "Group" }
+ let(:project_name) { "group.example.com" }
it { is_expected.to eq("http://group.example.com") }
end
- context 'project page' do
- let(:group_name) { 'Group' }
- let(:project_name) { 'Project' }
+ context "project page" do
+ let(:group_name) { "Group" }
+ let(:project_name) { "Project" }
it { is_expected.to eq("http://group.example.com/project") }
end
end
- describe '#pages_group_url' do
+ describe "#pages_group_url" do
let(:group) { create(:group, name: group_name) }
let(:project) { create(:project, namespace: group, name: project_name) }
- let(:domain) { 'Example.com' }
+ let(:domain) { "Example.com" }
let(:port) { 1234 }
subject { project.pages_group_url }
@@ -1562,64 +1562,64 @@ describe Project do
allow(Gitlab.config.pages).to receive(:url).and_return("http://example.com:#{port}")
end
- context 'group page' do
- let(:group_name) { 'Group' }
- let(:project_name) { 'group.example.com' }
+ context "group page" do
+ let(:group_name) { "Group" }
+ let(:project_name) { "group.example.com" }
it { is_expected.to eq("http://group.example.com:#{port}") }
end
- context 'project page' do
- let(:group_name) { 'Group' }
- let(:project_name) { 'Project' }
+ context "project page" do
+ let(:group_name) { "Group" }
+ let(:project_name) { "Project" }
it { is_expected.to eq("http://group.example.com:#{port}") }
end
end
- describe '.search' do
- let(:project) { create(:project, description: 'kitten mittens') }
+ describe ".search" do
+ let(:project) { create(:project, description: "kitten mittens") }
- it 'returns projects with a matching name' do
+ it "returns projects with a matching name" do
expect(described_class.search(project.name)).to eq([project])
end
- it 'returns projects with a partially matching name' do
+ it "returns projects with a partially matching name" do
expect(described_class.search(project.name[0..2])).to eq([project])
end
- it 'returns projects with a matching name regardless of the casing' do
+ it "returns projects with a matching name regardless of the casing" do
expect(described_class.search(project.name.upcase)).to eq([project])
end
- it 'returns projects with a matching description' do
+ it "returns projects with a matching description" do
expect(described_class.search(project.description)).to eq([project])
end
- it 'returns projects with a partially matching description' do
- expect(described_class.search('kitten')).to eq([project])
+ it "returns projects with a partially matching description" do
+ expect(described_class.search("kitten")).to eq([project])
end
- it 'returns projects with a matching description regardless of the casing' do
- expect(described_class.search('KITTEN')).to eq([project])
+ it "returns projects with a matching description regardless of the casing" do
+ expect(described_class.search("KITTEN")).to eq([project])
end
- it 'returns projects with a matching path' do
+ it "returns projects with a matching path" do
expect(described_class.search(project.path)).to eq([project])
end
- it 'returns projects with a partially matching path' do
+ it "returns projects with a partially matching path" do
expect(described_class.search(project.path[0..2])).to eq([project])
end
- it 'returns projects with a matching path regardless of the casing' do
+ it "returns projects with a matching path regardless of the casing" do
expect(described_class.search(project.path.upcase)).to eq([project])
end
- describe 'with pending_delete project' do
+ describe "with pending_delete project" do
let(:pending_delete_project) { create(:project, pending_delete: true) }
- it 'shows pending deletion project' do
+ it "shows pending deletion project" do
search_result = described_class.search(pending_delete_project.name)
expect(search_result).to eq([pending_delete_project])
@@ -1627,44 +1627,44 @@ describe Project do
end
end
- describe '.optionally_search' do
+ describe ".optionally_search" do
let(:project) { create(:project) }
- it 'searches for projects matching the query if one is given' do
+ it "searches for projects matching the query if one is given" do
relation = described_class.optionally_search(project.name)
expect(relation).to eq([project])
end
- it 'returns the current relation if no search query is given' do
+ it "returns the current relation if no search query is given" do
relation = described_class.where(id: project.id)
expect(relation.optionally_search).to eq(relation)
end
end
- describe '.paginate_in_descending_order_using_id' do
+ describe ".paginate_in_descending_order_using_id" do
let!(:project1) { create(:project) }
let!(:project2) { create(:project) }
- it 'orders the relation in descending order' do
+ it "orders the relation in descending order" do
expect(described_class.paginate_in_descending_order_using_id)
.to eq([project2, project1])
end
- it 'applies a limit to the relation' do
+ it "applies a limit to the relation" do
expect(described_class.paginate_in_descending_order_using_id(limit: 1))
.to eq([project2])
end
- it 'limits projects by and ID when given' do
+ it "limits projects by and ID when given" do
expect(described_class.paginate_in_descending_order_using_id(before: project2.id))
.to eq([project1])
end
end
- describe '.including_namespace_and_owner' do
- it 'eager loads the namespace and namespace owner' do
+ describe ".including_namespace_and_owner" do
+ it "eager loads the namespace and namespace owner" do
create(:project)
row = described_class.eager_load_namespace_and_owner.to_a.first
@@ -1674,67 +1674,67 @@ describe Project do
end
end
- describe '#expire_caches_before_rename' do
+ describe "#expire_caches_before_rename" do
let(:project) { create(:project, :repository) }
let(:repo) { double(:repo, exists?: true) }
let(:wiki) { double(:wiki, exists?: true) }
- it 'expires the caches of the repository and wiki' do
+ it "expires the caches of the repository and wiki" do
allow(Repository).to receive(:new)
- .with('foo', project)
+ .with("foo", project)
.and_return(repo)
allow(Repository).to receive(:new)
- .with('foo.wiki', project)
+ .with("foo.wiki", project)
.and_return(wiki)
expect(repo).to receive(:before_delete)
expect(wiki).to receive(:before_delete)
- project.expire_caches_before_rename('foo')
+ project.expire_caches_before_rename("foo")
end
end
- describe '.search_by_title' do
- let(:project) { create(:project, name: 'kittens') }
+ describe ".search_by_title" do
+ let(:project) { create(:project, name: "kittens") }
- it 'returns projects with a matching name' do
+ it "returns projects with a matching name" do
expect(described_class.search_by_title(project.name)).to eq([project])
end
- it 'returns projects with a partially matching name' do
- expect(described_class.search_by_title('kitten')).to eq([project])
+ it "returns projects with a partially matching name" do
+ expect(described_class.search_by_title("kitten")).to eq([project])
end
- it 'returns projects with a matching name regardless of the casing' do
- expect(described_class.search_by_title('KITTENS')).to eq([project])
+ it "returns projects with a matching name regardless of the casing" do
+ expect(described_class.search_by_title("KITTENS")).to eq([project])
end
end
- context 'when checking projects from groups' do
+ context "when checking projects from groups" do
let(:private_group) { create(:group, visibility_level: 0) }
let(:internal_group) { create(:group, visibility_level: 10) }
let(:private_project) { create(:project, :private, group: private_group) }
let(:internal_project) { create(:project, :internal, group: internal_group) }
- context 'when group is private project can not be internal' do
+ context "when group is private project can not be internal" do
it { expect(private_project.visibility_level_allowed?(Gitlab::VisibilityLevel::INTERNAL)).to be_falsey }
end
- context 'when group is internal project can not be public' do
+ context "when group is internal project can not be public" do
it { expect(internal_project.visibility_level_allowed?(Gitlab::VisibilityLevel::PUBLIC)).to be_falsey }
end
end
- describe '#track_project_repository' do
- shared_examples 'tracks storage location' do
- context 'when a project repository entry does not exist' do
- it 'creates a new entry' do
+ describe "#track_project_repository" do
+ shared_examples "tracks storage location" do
+ context "when a project repository entry does not exist" do
+ it "creates a new entry" do
expect { project.track_project_repository }.to change(project, :project_repository)
end
- it 'tracks the project storage location' do
+ it "tracks the project storage location" do
project.track_project_repository
expect(project.project_repository).to have_attributes(
@@ -1744,42 +1744,42 @@ describe Project do
end
end
- context 'when a tracking entry exists' do
+ context "when a tracking entry exists" do
let!(:project_repository) { create(:project_repository, project: project) }
- let!(:shard) { create(:shard, name: 'foo') }
+ let!(:shard) { create(:shard, name: "foo") }
- it 'does not create a new entry in the database' do
+ it "does not create a new entry in the database" do
expect { project.track_project_repository }.not_to change(project, :project_repository)
end
- it 'updates the project storage location' do
- allow(project).to receive(:disk_path).and_return('fancy/new/path')
- allow(project).to receive(:repository_storage).and_return('foo')
+ it "updates the project storage location" do
+ allow(project).to receive(:disk_path).and_return("fancy/new/path")
+ allow(project).to receive(:repository_storage).and_return("foo")
project.track_project_repository
expect(project.project_repository).to have_attributes(
- disk_path: 'fancy/new/path',
- shard_name: 'foo'
+ disk_path: "fancy/new/path",
+ shard_name: "foo"
)
end
end
end
- context 'with projects on legacy storage' do
+ context "with projects on legacy storage" do
let(:project) { create(:project, :repository, :legacy_storage) }
- it_behaves_like 'tracks storage location'
+ it_behaves_like "tracks storage location"
end
- context 'with projects on hashed storage' do
+ context "with projects on hashed storage" do
let(:project) { create(:project, :repository) }
- it_behaves_like 'tracks storage location'
+ it_behaves_like "tracks storage location"
end
end
- describe '#create_repository' do
+ describe "#create_repository" do
let(:project) { create(:project, :repository) }
let(:shell) { Gitlab::Shell.new }
@@ -1787,8 +1787,8 @@ describe Project do
allow(project).to receive(:gitlab_shell).and_return(shell)
end
- context 'using a regular repository' do
- it 'creates the repository' do
+ context "using a regular repository" do
+ it "creates the repository" do
expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path, project.full_path)
.and_return(true)
@@ -1798,7 +1798,7 @@ describe Project do
expect(project.create_repository).to eq(true)
end
- it 'adds an error if the repository could not be created' do
+ it "adds an error if the repository could not be created" do
expect(shell).to receive(:create_repository)
.with(project.repository_storage, project.disk_path, project.full_path)
.and_return(false)
@@ -1810,8 +1810,8 @@ describe Project do
end
end
- context 'using a forked repository' do
- it 'does nothing' do
+ context "using a forked repository" do
+ it "does nothing" do
expect(project).to receive(:forked?).and_return(true)
expect(shell).not_to receive(:create_repository)
@@ -1820,7 +1820,7 @@ describe Project do
end
end
- describe '#ensure_repository' do
+ describe "#ensure_repository" do
let(:project) { create(:project, :repository) }
let(:shell) { Gitlab::Shell.new }
@@ -1828,7 +1828,7 @@ describe Project do
allow(project).to receive(:gitlab_shell).and_return(shell)
end
- it 'creates the repository if it not exist' do
+ it "creates the repository if it not exist" do
allow(project).to receive(:repository_exists?)
.and_return(false)
@@ -1841,7 +1841,7 @@ describe Project do
project.ensure_repository
end
- it 'does not create the repository if it exists' do
+ it "does not create the repository if it exists" do
allow(project).to receive(:repository_exists?)
.and_return(true)
@@ -1850,7 +1850,7 @@ describe Project do
project.ensure_repository
end
- it 'creates the repository if it is a fork' do
+ it "creates the repository if it is a fork" do
expect(project).to receive(:forked?).and_return(true)
allow(project).to receive(:repository_exists?)
@@ -1864,17 +1864,17 @@ describe Project do
end
end
- describe 'handling import URL' do
- it 'returns the sanitized URL' do
- project = create(:project, :import_started, import_url: 'http://user:pass@test.com')
+ describe "handling import URL" do
+ it "returns the sanitized URL" do
+ project = create(:project, :import_started, import_url: "http://user:pass@test.com")
project.import_state.finish
- expect(project.reload.import_url).to eq('http://test.com')
+ expect(project.reload.import_url).to eq("http://test.com")
end
end
- describe '#container_registry_url' do
+ describe "#container_registry_url" do
let(:project) { create(:project) }
subject { project.container_registry_url }
@@ -1883,158 +1883,158 @@ describe Project do
stub_container_registry_config(**registry_settings)
end
- context 'for enabled registry' do
+ context "for enabled registry" do
let(:registry_settings) do
- { enabled: true,
- host_port: 'example.com' }
+ {enabled: true,
+ host_port: "example.com",}
end
it { is_expected.not_to be_nil }
end
- context 'for disabled registry' do
+ context "for disabled registry" do
let(:registry_settings) do
- { enabled: false }
+ {enabled: false}
end
it { is_expected.to be_nil }
end
end
- describe '#has_container_registry_tags?' do
+ describe "#has_container_registry_tags?" do
let(:project) { create(:project) }
- context 'when container registry is enabled' do
+ context "when container registry is enabled" do
before do
stub_container_registry_config(enabled: true)
end
- context 'when tags are present for multi-level registries' do
+ context "when tags are present for multi-level registries" do
before do
- create(:container_repository, project: project, name: 'image')
+ create(:container_repository, project: project, name: "image")
stub_container_registry_tags(repository: /image/,
tags: %w[latest rc1])
end
- it 'should have image tags' do
+ it "should have image tags" do
expect(project).to have_container_registry_tags
end
end
- context 'when tags are present for root repository' do
+ context "when tags are present for root repository" do
before do
stub_container_registry_tags(repository: project.full_path,
tags: %w[latest rc1 pre1])
end
- it 'should have image tags' do
+ it "should have image tags" do
expect(project).to have_container_registry_tags
end
end
- context 'when there are no tags at all' do
+ context "when there are no tags at all" do
before do
stub_container_registry_tags(repository: :any, tags: [])
end
- it 'should not have image tags' do
+ it "should not have image tags" do
expect(project).not_to have_container_registry_tags
end
end
end
- context 'when container registry is disabled' do
+ context "when container registry is disabled" do
before do
stub_container_registry_config(enabled: false)
end
- it 'should not have image tags' do
+ it "should not have image tags" do
expect(project).not_to have_container_registry_tags
end
- it 'should not check root repository tags' do
+ it "should not check root repository tags" do
expect(project).not_to receive(:full_path)
expect(project).not_to have_container_registry_tags
end
- it 'should iterate through container repositories' do
+ it "should iterate through container repositories" do
expect(project).to receive(:container_repositories)
expect(project).not_to have_container_registry_tags
end
end
end
- describe '#ci_config_path=' do
+ describe "#ci_config_path=" do
let(:project) { create(:project) }
- it 'sets nil' do
+ it "sets nil" do
project.update!(ci_config_path: nil)
expect(project.ci_config_path).to be_nil
end
- it 'sets a string' do
- project.update!(ci_config_path: 'foo/.gitlab_ci.yml')
+ it "sets a string" do
+ project.update!(ci_config_path: "foo/.gitlab_ci.yml")
- expect(project.ci_config_path).to eq('foo/.gitlab_ci.yml')
+ expect(project.ci_config_path).to eq("foo/.gitlab_ci.yml")
end
- it 'sets a string but removes all null characters' do
+ it "sets a string but removes all null characters" do
project.update!(ci_config_path: "f\0oo/\0/.gitlab_ci.yml")
- expect(project.ci_config_path).to eq('foo//.gitlab_ci.yml')
+ expect(project.ci_config_path).to eq("foo//.gitlab_ci.yml")
end
end
- describe '#latest_successful_build_for' do
+ describe "#latest_successful_build_for" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create_pipeline(project) }
- context 'with many builds' do
- it 'gives the latest builds from latest pipeline' do
+ context "with many builds" do
+ it "gives the latest builds from latest pipeline" do
pipeline1 = create_pipeline(project)
pipeline2 = create_pipeline(project)
- create_build(pipeline1, 'test')
- create_build(pipeline1, 'test2')
- build1_p2 = create_build(pipeline2, 'test')
- create_build(pipeline2, 'test2')
+ create_build(pipeline1, "test")
+ create_build(pipeline1, "test2")
+ build1_p2 = create_build(pipeline2, "test")
+ create_build(pipeline2, "test2")
expect(project.latest_successful_build_for(build1_p2.name))
.to eq(build1_p2)
end
end
- context 'with succeeded pipeline' do
+ context "with succeeded pipeline" do
let!(:build) { create_build }
- context 'standalone pipeline' do
- it 'returns builds for ref for default_branch' do
+ context "standalone pipeline" do
+ it "returns builds for ref for default_branch" do
expect(project.latest_successful_build_for(build.name))
.to eq(build)
end
- it 'returns empty relation if the build cannot be found' do
- expect(project.latest_successful_build_for('TAIL'))
+ it "returns empty relation if the build cannot be found" do
+ expect(project.latest_successful_build_for("TAIL"))
.to be_nil
end
end
- context 'with some pending pipeline' do
+ context "with some pending pipeline" do
before do
- create_build(create_pipeline(project, 'pending'))
+ create_build(create_pipeline(project, "pending"))
end
- it 'gives the latest build from latest pipeline' do
+ it "gives the latest build from latest pipeline" do
expect(project.latest_successful_build_for(build.name))
.to eq(build)
end
end
end
- context 'with pending pipeline' do
- it 'returns empty relation' do
- pipeline.update(status: 'pending')
+ context "with pending pipeline" do
+ it "returns empty relation" do
+ pipeline.update(status: "pending")
pending_build = create_build(pipeline)
expect(project.latest_successful_build_for(pending_build.name)).to be_nil
@@ -2042,54 +2042,54 @@ describe Project do
end
end
- describe '#latest_successful_build_for!' do
+ describe "#latest_successful_build_for!" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create_pipeline(project) }
- context 'with many builds' do
- it 'gives the latest builds from latest pipeline' do
+ context "with many builds" do
+ it "gives the latest builds from latest pipeline" do
pipeline1 = create_pipeline(project)
pipeline2 = create_pipeline(project)
- create_build(pipeline1, 'test')
- create_build(pipeline1, 'test2')
- build1_p2 = create_build(pipeline2, 'test')
- create_build(pipeline2, 'test2')
+ create_build(pipeline1, "test")
+ create_build(pipeline1, "test2")
+ build1_p2 = create_build(pipeline2, "test")
+ create_build(pipeline2, "test2")
expect(project.latest_successful_build_for(build1_p2.name))
.to eq(build1_p2)
end
end
- context 'with succeeded pipeline' do
+ context "with succeeded pipeline" do
let!(:build) { create_build }
- context 'standalone pipeline' do
- it 'returns builds for ref for default_branch' do
+ context "standalone pipeline" do
+ it "returns builds for ref for default_branch" do
expect(project.latest_successful_build_for!(build.name))
.to eq(build)
end
- it 'returns exception if the build cannot be found' do
- expect { project.latest_successful_build_for!(build.name, 'TAIL') }
+ it "returns exception if the build cannot be found" do
+ expect { project.latest_successful_build_for!(build.name, "TAIL") }
.to raise_error(ActiveRecord::RecordNotFound)
end
end
- context 'with some pending pipeline' do
+ context "with some pending pipeline" do
before do
- create_build(create_pipeline(project, 'pending'))
+ create_build(create_pipeline(project, "pending"))
end
- it 'gives the latest build from latest pipeline' do
+ it "gives the latest build from latest pipeline" do
expect(project.latest_successful_build_for!(build.name))
.to eq(build)
end
end
end
- context 'with pending pipeline' do
- it 'returns empty relation' do
- pipeline.update(status: 'pending')
+ context "with pending pipeline" do
+ it "returns empty relation" do
+ pipeline.update(status: "pending")
pending_build = create_build(pipeline)
expect { project.latest_successful_build_for!(pending_build.name) }
@@ -2098,46 +2098,46 @@ describe Project do
end
end
- describe '#import_status' do
- context 'with import_state' do
- it 'returns the right status' do
+ describe "#import_status" do
+ context "with import_state" do
+ it "returns the right status" do
project = create(:project, :import_started)
expect(project.import_status).to eq("started")
end
end
- context 'without import_state' do
- it 'returns none' do
+ context "without import_state" do
+ it "returns none" do
project = create(:project)
- expect(project.import_status).to eq('none')
+ expect(project.import_status).to eq("none")
end
end
end
- describe '#human_import_status_name' do
- context 'with import_state' do
- it 'returns the right human import status' do
+ describe "#human_import_status_name" do
+ context "with import_state" do
+ it "returns the right human import status" do
project = create(:project, :import_started)
- expect(project.human_import_status_name).to eq('started')
+ expect(project.human_import_status_name).to eq("started")
end
end
- context 'without import_state' do
- it 'returns none' do
+ context "without import_state" do
+ it "returns none" do
project = create(:project)
- expect(project.human_import_status_name).to eq('none')
+ expect(project.human_import_status_name).to eq("none")
end
end
end
- describe '#add_import_job' do
- let(:import_jid) { '123' }
+ describe "#add_import_job" do
+ let(:import_jid) { "123" }
- context 'forked' do
+ context "forked" do
let(:forked_from_project) { create(:project, :repository) }
let(:project) { create(:project) }
@@ -2145,15 +2145,15 @@ describe Project do
fork_project(forked_from_project, nil, target_project: project)
end
- it 'schedules a RepositoryForkWorker job' do
+ it "schedules a RepositoryForkWorker job" do
expect(RepositoryForkWorker).to receive(:perform_async).with(project.id).and_return(import_jid)
expect(project.add_import_job).to eq(import_jid)
end
end
- context 'not forked' do
- it 'schedules a RepositoryImportWorker job' do
+ context "not forked" do
+ it "schedules a RepositoryImportWorker job" do
project = create(:project, import_url: generate(:url))
expect(RepositoryImportWorker).to receive(:perform_async).with(project.id).and_return(import_jid)
@@ -2162,19 +2162,19 @@ describe Project do
end
end
- describe '#gitlab_project_import?' do
- subject(:project) { build(:project, import_type: 'gitlab_project') }
+ describe "#gitlab_project_import?" do
+ subject(:project) { build(:project, import_type: "gitlab_project") }
it { expect(project.gitlab_project_import?).to be true }
end
- describe '#gitea_import?' do
- subject(:project) { build(:project, import_type: 'gitea') }
+ describe "#gitea_import?" do
+ subject(:project) { build(:project, import_type: "gitea") }
it { expect(project.gitea_import?).to be true }
end
- describe '#has_remote_mirror?' do
+ describe "#has_remote_mirror?" do
let(:project) { create(:project, :remote_mirror, :import_started) }
subject { project.has_remote_mirror? }
@@ -2182,18 +2182,18 @@ describe Project do
allow_any_instance_of(RemoteMirror).to receive(:refresh_remote)
end
- it 'returns true when a remote mirror is enabled' do
+ it "returns true when a remote mirror is enabled" do
is_expected.to be_truthy
end
- it 'returns false when remote mirror is disabled' do
+ it "returns false when remote mirror is disabled" do
project.remote_mirrors.first.update(enabled: false)
is_expected.to be_falsy
end
end
- describe '#update_remote_mirrors' do
+ describe "#update_remote_mirrors" do
let(:project) { create(:project, :remote_mirror, :import_started) }
delegate :update_remote_mirrors, to: :project
@@ -2201,13 +2201,13 @@ describe Project do
allow_any_instance_of(RemoteMirror).to receive(:refresh_remote)
end
- it 'syncs enabled remote mirror' do
+ it "syncs enabled remote mirror" do
expect_any_instance_of(RemoteMirror).to receive(:sync)
update_remote_mirrors
end
- it 'does nothing when remote mirror is disabled globally and not overridden' do
+ it "does nothing when remote mirror is disabled globally and not overridden" do
stub_application_setting(mirror_available: false)
project.remote_mirror_available_overridden = false
@@ -2216,7 +2216,7 @@ describe Project do
update_remote_mirrors
end
- it 'does not sync disabled remote mirrors' do
+ it "does not sync disabled remote mirrors" do
project.remote_mirrors.first.update(enabled: false)
expect_any_instance_of(RemoteMirror).not_to receive(:sync)
@@ -2225,72 +2225,72 @@ describe Project do
end
end
- describe '#remote_mirror_available?' do
+ describe "#remote_mirror_available?" do
let(:project) { create(:project) }
- context 'when remote mirror global setting is enabled' do
- it 'returns true' do
+ context "when remote mirror global setting is enabled" do
+ it "returns true" do
expect(project.remote_mirror_available?).to be(true)
end
end
- context 'when remote mirror global setting is disabled' do
+ context "when remote mirror global setting is disabled" do
before do
stub_application_setting(mirror_available: false)
end
- it 'returns true when overridden' do
+ it "returns true when overridden" do
project.remote_mirror_available_overridden = true
expect(project.remote_mirror_available?).to be(true)
end
- it 'returns false when not overridden' do
+ it "returns false when not overridden" do
expect(project.remote_mirror_available?).to be(false)
end
end
end
- describe '#ancestors_upto', :nested_groups do
+ describe "#ancestors_upto", :nested_groups do
let(:parent) { create(:group) }
let(:child) { create(:group, parent: parent) }
let(:child2) { create(:group, parent: child) }
let(:project) { create(:project, namespace: child2) }
- it 'returns all ancestors when no namespace is given' do
+ it "returns all ancestors when no namespace is given" do
expect(project.ancestors_upto).to contain_exactly(child2, child, parent)
end
- it 'includes ancestors upto but excluding the given ancestor' do
+ it "includes ancestors upto but excluding the given ancestor" do
expect(project.ancestors_upto(parent)).to contain_exactly(child2, child)
end
- describe 'with hierarchy_order' do
- it 'returns ancestors ordered by descending hierarchy' do
+ describe "with hierarchy_order" do
+ it "returns ancestors ordered by descending hierarchy" do
expect(project.ancestors_upto(hierarchy_order: :desc)).to eq([parent, child, child2])
end
- it 'can be used with upto option' do
+ it "can be used with upto option" do
expect(project.ancestors_upto(parent, hierarchy_order: :desc)).to eq([child, child2])
end
end
end
- describe '#root_ancestor' do
+ describe "#root_ancestor" do
let(:project) { create(:project) }
subject { project.root_ancestor }
it { is_expected.to eq(project.namespace) }
- context 'in a group' do
+ context "in a group" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
it { is_expected.to eq(group) }
end
- context 'in a nested group', :nested_groups do
+ context "in a nested group", :nested_groups do
let(:root) { create(:group) }
let(:child) { create(:group, parent: root) }
let(:project) { create(:project, group: child) }
@@ -2299,233 +2299,233 @@ describe Project do
end
end
- describe '#lfs_enabled?' do
+ describe "#lfs_enabled?" do
let(:project) { create(:project) }
- shared_examples 'project overrides group' do
- it 'returns true when enabled in project' do
+ shared_examples "project overrides group" do
+ it "returns true when enabled in project" do
project.update_attribute(:lfs_enabled, true)
expect(project.lfs_enabled?).to be_truthy
end
- it 'returns false when disabled in project' do
+ it "returns false when disabled in project" do
project.update_attribute(:lfs_enabled, false)
expect(project.lfs_enabled?).to be_falsey
end
- it 'returns the value from the namespace, when no value is set in project' do
+ it "returns the value from the namespace, when no value is set in project" do
expect(project.lfs_enabled?).to eq(project.namespace.lfs_enabled?)
end
end
- context 'LFS disabled in group' do
+ context "LFS disabled in group" do
before do
project.namespace.update_attribute(:lfs_enabled, false)
enable_lfs
end
- it_behaves_like 'project overrides group'
+ it_behaves_like "project overrides group"
end
- context 'LFS enabled in group' do
+ context "LFS enabled in group" do
before do
project.namespace.update_attribute(:lfs_enabled, true)
enable_lfs
end
- it_behaves_like 'project overrides group'
+ it_behaves_like "project overrides group"
end
- describe 'LFS disabled globally' do
- shared_examples 'it always returns false' do
+ describe "LFS disabled globally" do
+ shared_examples "it always returns false" do
it do
expect(project.lfs_enabled?).to be_falsey
expect(project.namespace.lfs_enabled?).to be_falsey
end
end
- context 'when no values are set' do
- it_behaves_like 'it always returns false'
+ context "when no values are set" do
+ it_behaves_like "it always returns false"
end
- context 'when all values are set to true' do
+ context "when all values are set to true" do
before do
project.namespace.update_attribute(:lfs_enabled, true)
project.update_attribute(:lfs_enabled, true)
end
- it_behaves_like 'it always returns false'
+ it_behaves_like "it always returns false"
end
end
end
- describe '#daily_statistics_enabled?' do
+ describe "#daily_statistics_enabled?" do
it { is_expected.to be_daily_statistics_enabled }
- context 'when :project_daily_statistics is disabled for the project' do
+ context "when :project_daily_statistics is disabled for the project" do
before do
- stub_feature_flags(project_daily_statistics: { thing: subject, enabled: false })
+ stub_feature_flags(project_daily_statistics: {thing: subject, enabled: false})
end
it { is_expected.not_to be_daily_statistics_enabled }
end
end
- describe '#change_head' do
+ describe "#change_head" do
let(:project) { create(:project, :repository) }
- it 'returns error if branch does not exist' do
- expect(project.change_head('unexisted-branch')).to be false
+ it "returns error if branch does not exist" do
+ expect(project.change_head("unexisted-branch")).to be false
expect(project.errors.size).to eq(1)
end
- it 'calls the before_change_head and after_change_head methods' do
+ it "calls the before_change_head and after_change_head methods" do
expect(project.repository).to receive(:before_change_head)
expect(project.repository).to receive(:after_change_head)
project.change_head(project.default_branch)
end
- it 'copies the gitattributes' do
+ it "copies the gitattributes" do
expect(project.repository).to receive(:copy_gitattributes).with(project.default_branch)
project.change_head(project.default_branch)
end
- it 'reloads the default branch' do
+ it "reloads the default branch" do
expect(project).to receive(:reload_default_branch)
project.change_head(project.default_branch)
end
end
- context 'forks' do
+ context "forks" do
include ProjectForksHelper
let(:project) { create(:project, :public) }
let!(:forked_project) { fork_project(project) }
- describe '#fork_network' do
- it 'includes a fork of the project' do
+ describe "#fork_network" do
+ it "includes a fork of the project" do
expect(project.fork_network.projects).to include(forked_project)
end
- it 'includes a fork of a fork' do
+ it "includes a fork of a fork" do
other_fork = fork_project(forked_project)
expect(project.fork_network.projects).to include(other_fork)
end
- it 'includes sibling forks' do
+ it "includes sibling forks" do
other_fork = fork_project(project)
expect(forked_project.fork_network.projects).to include(other_fork)
end
- it 'includes the base project' do
+ it "includes the base project" do
expect(forked_project.fork_network.projects).to include(project.reload)
end
end
- describe '#in_fork_network_of?' do
- it 'is true for a real fork' do
+ describe "#in_fork_network_of?" do
+ it "is true for a real fork" do
expect(forked_project.in_fork_network_of?(project)).to be_truthy
end
- it 'is true for a fork of a fork', :postgresql do
+ it "is true for a fork of a fork", :postgresql do
other_fork = fork_project(forked_project)
expect(other_fork.in_fork_network_of?(project)).to be_truthy
end
- it 'is true for sibling forks' do
+ it "is true for sibling forks" do
sibling = fork_project(project)
expect(sibling.in_fork_network_of?(forked_project)).to be_truthy
end
- it 'is false when another project is given' do
+ it "is false when another project is given" do
other_project = build_stubbed(:project)
expect(forked_project.in_fork_network_of?(other_project)).to be_falsy
end
end
- describe '#fork_source' do
+ describe "#fork_source" do
let!(:second_fork) { fork_project(forked_project) }
- it 'returns the direct source if it exists' do
+ it "returns the direct source if it exists" do
expect(second_fork.fork_source).to eq(forked_project)
end
- it 'returns the root of the fork network when the directs source was deleted' do
+ it "returns the root of the fork network when the directs source was deleted" do
forked_project.destroy
expect(second_fork.fork_source).to eq(project)
end
- it 'returns nil if it is the root of the fork network' do
+ it "returns nil if it is the root of the fork network" do
expect(project.fork_source).to be_nil
end
end
- describe '#forks' do
- it 'includes direct forks of the project' do
+ describe "#forks" do
+ it "includes direct forks of the project" do
expect(project.forks).to contain_exactly(forked_project)
end
end
- describe '#lfs_storage_project' do
- it 'returns self for non-forks' do
+ describe "#lfs_storage_project" do
+ it "returns self for non-forks" do
expect(project.lfs_storage_project).to eq project
end
- it 'returns the fork network root for forks' do
+ it "returns the fork network root for forks" do
second_fork = fork_project(forked_project)
expect(second_fork.lfs_storage_project).to eq project
end
- it 'returns self when fork_source is nil' do
+ it "returns self when fork_source is nil" do
expect(forked_project).to receive(:fork_source).and_return(nil)
expect(forked_project.lfs_storage_project).to eq forked_project
end
end
- describe '#all_lfs_objects' do
+ describe "#all_lfs_objects" do
let(:lfs_object) { create(:lfs_object) }
before do
project.lfs_objects << lfs_object
end
- it 'returns the lfs object for a project' do
+ it "returns the lfs object for a project" do
expect(project.all_lfs_objects).to contain_exactly(lfs_object)
end
- it 'returns the lfs object for a fork' do
+ it "returns the lfs object for a fork" do
expect(forked_project.all_lfs_objects).to contain_exactly(lfs_object)
end
end
end
- describe '#set_repository_read_only!' do
+ describe "#set_repository_read_only!" do
let(:project) { create(:project) }
- it 'returns true when there is no existing git transfer in progress' do
+ it "returns true when there is no existing git transfer in progress" do
expect(project.set_repository_read_only!).to be_truthy
end
- it 'returns false when there is an existing git transfer in progress' do
+ it "returns false when there is an existing git transfer in progress" do
allow(project).to receive(:git_transfer_in_progress?) { true }
expect(project.set_repository_read_only!).to be_falsey
end
end
- describe '#set_repository_writable!' do
- it 'sets repository_read_only to false' do
+ describe "#set_repository_writable!" do
+ it "sets repository_read_only to false" do
project = create(:project, :read_only)
expect { project.set_repository_writable! }
@@ -2534,21 +2534,21 @@ describe Project do
end
end
- describe '#pushes_since_gc' do
+ describe "#pushes_since_gc" do
let(:project) { create(:project) }
after do
project.reset_pushes_since_gc
end
- context 'without any pushes' do
- it 'returns 0' do
+ context "without any pushes" do
+ it "returns 0" do
expect(project.pushes_since_gc).to eq(0)
end
end
- context 'with a number of pushes' do
- it 'returns the number of pushes' do
+ context "with a number of pushes" do
+ it "returns the number of pushes" do
3.times { project.increment_pushes_since_gc }
expect(project.pushes_since_gc).to eq(3)
@@ -2556,28 +2556,28 @@ describe Project do
end
end
- describe '#increment_pushes_since_gc' do
+ describe "#increment_pushes_since_gc" do
let(:project) { create(:project) }
after do
project.reset_pushes_since_gc
end
- it 'increments the number of pushes since the last GC' do
+ it "increments the number of pushes since the last GC" do
3.times { project.increment_pushes_since_gc }
expect(project.pushes_since_gc).to eq(3)
end
end
- describe '#reset_pushes_since_gc' do
+ describe "#reset_pushes_since_gc" do
let(:project) { create(:project) }
after do
project.reset_pushes_since_gc
end
- it 'resets the number of pushes since the last GC' do
+ it "resets the number of pushes since the last GC" do
3.times { project.increment_pushes_since_gc }
project.reset_pushes_since_gc
@@ -2586,140 +2586,141 @@ describe Project do
end
end
- describe '#deployment_variables' do
- context 'when project has no deployment service' do
+ describe "#deployment_variables" do
+ context "when project has no deployment service" do
let(:project) { create(:project) }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(project.deployment_variables).to eq []
end
end
- context 'when project uses mock deployment service' do
+ context "when project uses mock deployment service" do
let(:project) { create(:mock_deployment_project) }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(project.deployment_variables).to eq []
end
end
- context 'when project has a deployment service' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- it 'returns variables from this service' do
+ context "when project has a deployment service" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ it "returns variables from this service" do
expect(project.deployment_variables).to include(
- { key: 'KUBE_TOKEN', value: project.deployment_platform.token, public: false }
+ {key: "KUBE_TOKEN", value: project.deployment_platform.token, public: false}
)
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters and KubernetesNamespace migration has not been executed' do
+ context "when user configured kubernetes from CI/CD > Clusters and KubernetesNamespace migration has not been executed" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters and KubernetesNamespace migration has been executed' do
+ context "when user configured kubernetes from CI/CD > Clusters and KubernetesNamespace migration has been executed" do
let!(:kubernetes_namespace) { create(:cluster_kubernetes_namespace, :with_token) }
let!(:cluster) { kubernetes_namespace.cluster }
let(:project) { kubernetes_namespace.project }
- it 'should return token from kubernetes namespace' do
+ it "should return token from kubernetes namespace" do
expect(project.deployment_variables).to include(
- { key: 'KUBE_TOKEN', value: kubernetes_namespace.service_account_token, public: false }
+ {key: "KUBE_TOKEN", value: kubernetes_namespace.service_account_token, public: false}
)
end
end
end
end
- describe '#default_environment' do
+ describe "#default_environment" do
let(:project) { create(:project) }
- it 'returns production environment when it exists' do
+ it "returns production environment when it exists" do
production = create(:environment, name: "production", project: project)
- create(:environment, name: 'staging', project: project)
+ create(:environment, name: "staging", project: project)
expect(project.default_environment).to eq(production)
end
- it 'returns first environment when no production environment exists' do
- create(:environment, name: 'staging', project: project)
- create(:environment, name: 'foo', project: project)
+ it "returns first environment when no production environment exists" do
+ create(:environment, name: "staging", project: project)
+ create(:environment, name: "foo", project: project)
expect(project.default_environment).to eq(project.environments.first)
end
- it 'returns nil when no available environment exists' do
+ it "returns nil when no available environment exists" do
expect(project.default_environment).to be_nil
end
end
- describe '#ci_variables_for' do
+ describe "#ci_variables_for" do
let(:project) { create(:project) }
let!(:ci_variable) do
- create(:ci_variable, value: 'secret', project: project)
+ create(:ci_variable, value: "secret", project: project)
end
let!(:protected_variable) do
- create(:ci_variable, :protected, value: 'protected', project: project)
+ create(:ci_variable, :protected, value: "protected", project: project)
end
- subject { project.reload.ci_variables_for(ref: 'ref') }
+ subject { project.reload.ci_variables_for(ref: "ref") }
before do
stub_application_setting(
- default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+ default_branch_protection: Gitlab::Access::PROTECTION_NONE
+ )
end
- shared_examples 'ref is protected' do
- it 'contains all the variables' do
+ shared_examples "ref is protected" do
+ it "contains all the variables" do
is_expected.to contain_exactly(ci_variable, protected_variable)
end
end
- context 'when the ref is not protected' do
+ context "when the ref is not protected" do
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(false)
+ allow(project).to receive(:protected_for?).with("ref").and_return(false)
end
- it 'contains only the CI variables' do
+ it "contains only the CI variables" do
is_expected.to contain_exactly(ci_variable)
end
end
- context 'when the ref is a protected branch' do
+ context "when the ref is a protected branch" do
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(true)
+ allow(project).to receive(:protected_for?).with("ref").and_return(true)
end
- it_behaves_like 'ref is protected'
+ it_behaves_like "ref is protected"
end
- context 'when the ref is a protected tag' do
+ context "when the ref is a protected tag" do
before do
- allow(project).to receive(:protected_for?).with('ref').and_return(true)
+ allow(project).to receive(:protected_for?).with("ref").and_return(true)
end
- it_behaves_like 'ref is protected'
+ it_behaves_like "ref is protected"
end
end
- describe '#any_lfs_file_locks?', :request_store do
+ describe "#any_lfs_file_locks?", :request_store do
set(:project) { create(:project) }
- it 'returns false when there are no LFS file locks' do
+ it "returns false when there are no LFS file locks" do
expect(project.any_lfs_file_locks?).to be_falsey
end
- it 'returns a cached true when there are LFS file locks' do
+ it "returns a cached true when there are LFS file locks" do
create(:lfs_file_lock, project: project)
expect(project.lfs_file_locks).to receive(:any?).once.and_call_original
@@ -2728,145 +2729,146 @@ describe Project do
end
end
- describe '#protected_for?' do
+ describe "#protected_for?" do
let(:project) { create(:project, :repository) }
subject { project.protected_for?(ref) }
- shared_examples 'ref is not protected' do
+ shared_examples "ref is not protected" do
before do
stub_application_setting(
- default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+ default_branch_protection: Gitlab::Access::PROTECTION_NONE
+ )
end
- it 'returns false' do
+ it "returns false" do
is_expected.to be false
end
end
- shared_examples 'ref is protected branch' do
+ shared_examples "ref is protected branch" do
before do
- create(:protected_branch, name: 'master', project: project)
+ create(:protected_branch, name: "master", project: project)
end
- it 'returns true' do
+ it "returns true" do
is_expected.to be true
end
end
- shared_examples 'ref is protected tag' do
+ shared_examples "ref is protected tag" do
before do
- create(:protected_tag, name: 'v1.0.0', project: project)
+ create(:protected_tag, name: "v1.0.0", project: project)
end
- it 'returns true' do
+ it "returns true" do
is_expected.to be true
end
end
- context 'when ref is nil' do
+ context "when ref is nil" do
let(:ref) { nil }
- it 'returns false' do
+ it "returns false" do
is_expected.to be false
end
end
- context 'when ref is ref name' do
- context 'when ref is ambiguous' do
- let(:ref) { 'ref' }
+ context "when ref is ref name" do
+ context "when ref is ambiguous" do
+ let(:ref) { "ref" }
before do
- project.repository.add_branch(project.creator, 'ref', 'master')
- project.repository.add_tag(project.creator, 'ref', 'master')
+ project.repository.add_branch(project.creator, "ref", "master")
+ project.repository.add_tag(project.creator, "ref", "master")
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(Repository::AmbiguousRefError)
end
end
- context 'when the ref is not protected' do
- let(:ref) { 'master' }
+ context "when the ref is not protected" do
+ let(:ref) { "master" }
- it_behaves_like 'ref is not protected'
+ it_behaves_like "ref is not protected"
end
- context 'when the ref is a protected branch' do
- let(:ref) { 'master' }
+ context "when the ref is a protected branch" do
+ let(:ref) { "master" }
- it_behaves_like 'ref is protected branch'
+ it_behaves_like "ref is protected branch"
end
- context 'when the ref is a protected tag' do
- let(:ref) { 'v1.0.0' }
+ context "when the ref is a protected tag" do
+ let(:ref) { "v1.0.0" }
- it_behaves_like 'ref is protected tag'
+ it_behaves_like "ref is protected tag"
end
- context 'when ref does not exist' do
- let(:ref) { 'something' }
+ context "when ref does not exist" do
+ let(:ref) { "something" }
- it 'returns false' do
+ it "returns false" do
is_expected.to be false
end
end
end
- context 'when ref is full ref' do
- context 'when the ref is not protected' do
- let(:ref) { 'refs/heads/master' }
+ context "when ref is full ref" do
+ context "when the ref is not protected" do
+ let(:ref) { "refs/heads/master" }
- it_behaves_like 'ref is not protected'
+ it_behaves_like "ref is not protected"
end
- context 'when the ref is a protected branch' do
- let(:ref) { 'refs/heads/master' }
+ context "when the ref is a protected branch" do
+ let(:ref) { "refs/heads/master" }
- it_behaves_like 'ref is protected branch'
+ it_behaves_like "ref is protected branch"
end
- context 'when the ref is a protected tag' do
- let(:ref) { 'refs/tags/v1.0.0' }
+ context "when the ref is a protected tag" do
+ let(:ref) { "refs/tags/v1.0.0" }
- it_behaves_like 'ref is protected tag'
+ it_behaves_like "ref is protected tag"
end
- context 'when branch ref name is a full tag ref' do
- let(:ref) { 'refs/tags/something' }
+ context "when branch ref name is a full tag ref" do
+ let(:ref) { "refs/tags/something" }
before do
- project.repository.add_branch(project.creator, ref, 'master')
+ project.repository.add_branch(project.creator, ref, "master")
end
- context 'when ref is not protected' do
- it 'returns false' do
+ context "when ref is not protected" do
+ it "returns false" do
is_expected.to be false
end
end
- context 'when ref is a protected branch' do
+ context "when ref is a protected branch" do
before do
- create(:protected_branch, name: 'refs/tags/something', project: project)
+ create(:protected_branch, name: "refs/tags/something", project: project)
end
- it 'returns true' do
+ it "returns true" do
is_expected.to be true
end
end
end
- context 'when ref does not exist' do
- let(:ref) { 'refs/heads/something' }
+ context "when ref does not exist" do
+ let(:ref) { "refs/heads/something" }
- it 'returns false' do
+ it "returns false" do
is_expected.to be false
end
end
end
end
- describe '#update_project_statistics' do
+ describe "#update_project_statistics" do
let(:project) { create(:project) }
it "is called after creation" do
@@ -2886,18 +2888,18 @@ describe Project do
end
end
- describe 'inside_path' do
- let!(:project1) { create(:project, namespace: create(:namespace, path: 'name_pace')) }
+ describe "inside_path" do
+ let!(:project1) { create(:project, namespace: create(:namespace, path: "name_pace")) }
let!(:project2) { create(:project) }
- let!(:project3) { create(:project, namespace: create(:namespace, path: 'namespace')) }
+ let!(:project3) { create(:project, namespace: create(:namespace, path: "namespace")) }
let!(:path) { project1.namespace.full_path }
- it 'returns correct project' do
+ it "returns correct project" do
expect(described_class.inside_path(path)).to eq([project1])
end
end
- describe '#route_map_for' do
+ describe "#route_map_for" do
let(:project) { create(:project, :repository) }
let(:route_map) do
<<-MAP.strip_heredoc
@@ -2907,34 +2909,34 @@ describe Project do
end
before do
- project.repository.create_file(User.last, '.gitlab/route-map.yml', route_map, message: 'Add .gitlab/route-map.yml', branch_name: 'master')
+ project.repository.create_file(User.last, ".gitlab/route-map.yml", route_map, message: "Add .gitlab/route-map.yml", branch_name: "master")
end
- context 'when there is a .gitlab/route-map.yml at the commit' do
- context 'when the route map is valid' do
- it 'returns a route map' do
+ context "when there is a .gitlab/route-map.yml at the commit" do
+ context "when the route map is valid" do
+ it "returns a route map" do
map = project.route_map_for(project.commit.sha)
expect(map).to be_a_kind_of(Gitlab::RouteMap)
end
end
- context 'when the route map is invalid' do
- let(:route_map) { 'INVALID' }
+ context "when the route map is invalid" do
+ let(:route_map) { "INVALID" }
- it 'returns nil' do
+ it "returns nil" do
expect(project.route_map_for(project.commit.sha)).to be_nil
end
end
end
- context 'when there is no .gitlab/route-map.yml at the commit' do
- it 'returns nil' do
+ context "when there is no .gitlab/route-map.yml at the commit" do
+ it "returns nil" do
expect(project.route_map_for(project.commit.parent.sha)).to be_nil
end
end
end
- describe '#public_path_for_source_path' do
+ describe "#public_path_for_source_path" do
let(:project) { create(:project, :repository) }
let(:route_map) do
Gitlab::RouteMap.new(<<-MAP.strip_heredoc)
@@ -2944,48 +2946,48 @@ describe Project do
end
let(:sha) { project.commit.id }
- context 'when there is a route map' do
+ context "when there is a route map" do
before do
allow(project).to receive(:route_map_for).with(sha).and_return(route_map)
end
- context 'when the source path is mapped' do
- it 'returns the public path' do
- expect(project.public_path_for_source_path('source/file.html', sha)).to eq('file.html')
+ context "when the source path is mapped" do
+ it "returns the public path" do
+ expect(project.public_path_for_source_path("source/file.html", sha)).to eq("file.html")
end
end
- context 'when the source path is not mapped' do
- it 'returns nil' do
- expect(project.public_path_for_source_path('file.html', sha)).to be_nil
+ context "when the source path is not mapped" do
+ it "returns nil" do
+ expect(project.public_path_for_source_path("file.html", sha)).to be_nil
end
end
end
- context 'when there is no route map' do
+ context "when there is no route map" do
before do
allow(project).to receive(:route_map_for).with(sha).and_return(nil)
end
- it 'returns nil' do
- expect(project.public_path_for_source_path('source/file.html', sha)).to be_nil
+ it "returns nil" do
+ expect(project.public_path_for_source_path("source/file.html", sha)).to be_nil
end
end
end
- describe '#parent' do
+ describe "#parent" do
let(:project) { create(:project) }
it { expect(project.parent).to eq(project.namespace) }
end
- describe '#parent_id' do
+ describe "#parent_id" do
let(:project) { create(:project) }
it { expect(project.parent_id).to eq(project.namespace_id) }
end
- describe '#parent_changed?' do
+ describe "#parent_changed?" do
let(:project) { create(:project) }
before do
@@ -2999,95 +3001,95 @@ describe Project do
allow(Gitlab.config.lfs).to receive(:enabled).and_return(true)
end
- describe '#pages_url' do
- let(:group) { create(:group, name: 'Group') }
+ describe "#pages_url" do
+ let(:group) { create(:group, name: "Group") }
let(:nested_group) { create(:group, parent: group) }
- let(:domain) { 'Example.com' }
+ let(:domain) { "Example.com" }
subject { project.pages_url }
before do
allow(Settings.pages).to receive(:host).and_return(domain)
- allow(Gitlab.config.pages).to receive(:url).and_return('http://example.com')
+ allow(Gitlab.config.pages).to receive(:url).and_return("http://example.com")
end
- context 'top-level group' do
+ context "top-level group" do
let(:project) { create(:project, namespace: group, name: project_name) }
- context 'group page' do
- let(:project_name) { 'group.example.com' }
+ context "group page" do
+ let(:project_name) { "group.example.com" }
it { is_expected.to eq("http://group.example.com") }
end
- context 'project page' do
- let(:project_name) { 'Project' }
+ context "project page" do
+ let(:project_name) { "Project" }
it { is_expected.to eq("http://group.example.com/project") }
end
end
- context 'nested group' do
+ context "nested group" do
let(:project) { create(:project, namespace: nested_group, name: project_name) }
let(:expected_url) { "http://group.example.com/#{nested_group.path}/#{project.path}" }
- context 'group page' do
- let(:project_name) { 'group.example.com' }
+ context "group page" do
+ let(:project_name) { "group.example.com" }
it { is_expected.to eq(expected_url) }
end
- context 'project page' do
- let(:project_name) { 'Project' }
+ context "project page" do
+ let(:project_name) { "Project" }
it { is_expected.to eq(expected_url) }
end
end
end
- describe '#http_url_to_repo' do
+ describe "#http_url_to_repo" do
let(:project) { create(:project) }
- it 'returns the url to the repo without a username' do
+ it "returns the url to the repo without a username" do
expect(project.http_url_to_repo).to eq("#{project.web_url}.git")
- expect(project.http_url_to_repo).not_to include('@')
+ expect(project.http_url_to_repo).not_to include("@")
end
end
- describe '#lfs_http_url_to_repo' do
+ describe "#lfs_http_url_to_repo" do
let(:project) { create(:project) }
- it 'returns the url to the repo without a username' do
- lfs_http_url_to_repo = project.lfs_http_url_to_repo('operation_that_doesnt_matter')
+ it "returns the url to the repo without a username" do
+ lfs_http_url_to_repo = project.lfs_http_url_to_repo("operation_that_doesnt_matter")
expect(lfs_http_url_to_repo).to eq("#{project.web_url}.git")
- expect(lfs_http_url_to_repo).not_to include('@')
+ expect(lfs_http_url_to_repo).not_to include("@")
end
end
- describe '#pipeline_status' do
+ describe "#pipeline_status" do
let(:project) { create(:project, :repository) }
- it 'builds a pipeline status' do
+ it "builds a pipeline status" do
expect(project.pipeline_status).to be_a(Gitlab::Cache::Ci::ProjectPipelineStatus)
end
- it 'hase a loaded pipeline status' do
+ it "hase a loaded pipeline status" do
expect(project.pipeline_status).to be_loaded
end
end
- describe '#append_or_update_attribute' do
+ describe "#append_or_update_attribute" do
let(:project) { create(:project) }
- it 'shows full error updating an invalid MR' do
- error_message = 'Failed to replace merge_requests because one or more of the new records could not be saved.'\
- ' Validate fork Source project is not a fork of the target project'
+ it "shows full error updating an invalid MR" do
+ error_message = "Failed to replace merge_requests because one or more of the new records could not be saved."\
+ " Validate fork Source project is not a fork of the target project"
expect { project.append_or_update_attribute(:merge_requests, [create(:merge_request)]) }
.to raise_error(ActiveRecord::RecordNotSaved, error_message)
end
- it 'updates the project successfully' do
+ it "updates the project successfully" do
merge_request = create(:merge_request, target_project: project, source_project: project)
expect { project.append_or_update_attribute(:merge_requests, [merge_request]) }
@@ -3095,17 +3097,17 @@ describe Project do
end
end
- describe '#update' do
+ describe "#update" do
let(:project) { create(:project) }
- it 'validates the visibility' do
+ it "validates the visibility" do
expect(project).to receive(:visibility_level_allowed_as_fork).and_call_original
expect(project).to receive(:visibility_level_allowed_by_group).and_call_original
project.update(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- it 'does not validate the visibility' do
+ it "does not validate the visibility" do
expect(project).not_to receive(:visibility_level_allowed_as_fork).and_call_original
expect(project).not_to receive(:visibility_level_allowed_by_group).and_call_original
@@ -3113,15 +3115,15 @@ describe Project do
end
end
- describe '#last_repository_updated_at' do
- it 'sets to created_at upon creation' do
+ describe "#last_repository_updated_at" do
+ it "sets to created_at upon creation" do
project = create(:project, created_at: 2.hours.ago)
expect(project.last_repository_updated_at.to_i).to eq(project.created_at.to_i)
end
end
- describe '.public_or_visible_to_user' do
+ describe ".public_or_visible_to_user" do
let!(:user) { create(:user) }
let!(:private_project) do
@@ -3130,22 +3132,22 @@ describe Project do
let!(:public_project) { create(:project, :public) }
- context 'with a user' do
+ context "with a user" do
let(:projects) do
described_class.all.public_or_visible_to_user(user)
end
- it 'includes projects the user has access to' do
+ it "includes projects the user has access to" do
expect(projects).to include(private_project)
end
- it 'includes projects the user can see' do
+ it "includes projects the user can see" do
expect(projects).to include(public_project)
end
end
- context 'without a user' do
- it 'only includes public projects' do
+ context "without a user" do
+ it "only includes public projects" do
projects = described_class.all.public_or_visible_to_user
expect(projects).to eq([public_project])
@@ -3153,67 +3155,67 @@ describe Project do
end
end
- describe '.with_feature_available_for_user' do
+ describe ".with_feature_available_for_user" do
let!(:user) { create(:user) }
let!(:feature) { MergeRequest }
let!(:project) { create(:project, :public, :merge_requests_enabled) }
subject { described_class.with_feature_available_for_user(feature, user) }
- context 'when user has access to project' do
+ context "when user has access to project" do
subject { described_class.with_feature_available_for_user(feature, user) }
before do
project.add_guest(user)
end
- context 'when public project' do
- context 'when feature is public' do
- it 'returns project' do
+ context "when public project" do
+ context "when feature is public" do
+ it "returns project" do
is_expected.to include(project)
end
end
- context 'when feature is private' do
+ context "when feature is private" do
let!(:project) { create(:project, :public, :merge_requests_private) }
- it 'returns project when user has access to the feature' do
+ it "returns project when user has access to the feature" do
project.add_maintainer(user)
is_expected.to include(project)
end
- it 'does not return project when user does not have the minimum access level required' do
+ it "does not return project when user does not have the minimum access level required" do
is_expected.not_to include(project)
end
end
end
- context 'when private project' do
+ context "when private project" do
let!(:project) { create(:project) }
- it 'returns project when user has access to the feature' do
+ it "returns project when user has access to the feature" do
project.add_maintainer(user)
is_expected.to include(project)
end
- it 'does not return project when user does not have the minimum access level required' do
+ it "does not return project when user does not have the minimum access level required" do
is_expected.not_to include(project)
end
end
end
- context 'when user does not have access to project' do
+ context "when user does not have access to project" do
let!(:project) { create(:project) }
- it 'does not return project when user cant access project' do
+ it "does not return project when user cant access project" do
is_expected.not_to include(project)
end
end
end
- describe '#pages_available?' do
+ describe "#pages_available?" do
let(:project) { create(:project, group: group) }
subject { project.pages_available? }
@@ -3222,41 +3224,41 @@ describe Project do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
- context 'when the project is in a top level namespace' do
+ context "when the project is in a top level namespace" do
let(:group) { create(:group) }
it { is_expected.to be(true) }
end
- context 'when the project is in a subgroup' do
+ context "when the project is in a subgroup" do
let(:group) { create(:group, :nested) }
it { is_expected.to be(true) }
end
end
- describe '#remove_private_deploy_keys' do
+ describe "#remove_private_deploy_keys" do
let!(:project) { create(:project) }
- context 'for a private deploy key' do
+ context "for a private deploy key" do
let!(:key) { create(:deploy_key, public: false) }
let!(:deploy_keys_project) { create(:deploy_keys_project, deploy_key: key, project: project) }
- context 'when the key is not linked to another project' do
- it 'removes the key' do
+ context "when the key is not linked to another project" do
+ it "removes the key" do
project.remove_private_deploy_keys
expect(project.deploy_keys).not_to include(key)
end
end
- context 'when the key is linked to another project' do
+ context "when the key is linked to another project" do
before do
another_project = create(:project)
create(:deploy_keys_project, deploy_key: key, project: another_project)
end
- it 'does not remove the key' do
+ it "does not remove the key" do
project.remove_private_deploy_keys
expect(project.deploy_keys).to include(key)
@@ -3264,11 +3266,11 @@ describe Project do
end
end
- context 'for a public deploy key' do
+ context "for a public deploy key" do
let!(:key) { create(:deploy_key, public: true) }
let!(:deploy_keys_project) { create(:deploy_keys_project, deploy_key: key, project: project) }
- it 'does not remove the key' do
+ it "does not remove the key" do
project.remove_private_deploy_keys
expect(project.deploy_keys).to include(key)
@@ -3276,7 +3278,7 @@ describe Project do
end
end
- describe '#remove_pages' do
+ describe "#remove_pages" do
let(:project) { create(:project) }
let(:namespace) { project.namespace }
let(:pages_path) { project.pages_path }
@@ -3290,7 +3292,7 @@ describe Project do
end
end
- it 'removes the pages directory' do
+ it "removes the pages directory" do
expect_any_instance_of(Projects::UpdatePagesConfigurationService).to receive(:execute)
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project).and_return(true)
expect(PagesWorker).to receive(:perform_in).with(5.minutes, :remove, namespace.full_path, anything)
@@ -3298,7 +3300,7 @@ describe Project do
project.remove_pages
end
- it 'is a no-op when there is no namespace' do
+ it "is a no-op when there is no namespace" do
project.namespace.delete
project.reload
@@ -3308,25 +3310,25 @@ describe Project do
project.remove_pages
end
- it 'is run when the project is destroyed' do
+ it "is run when the project is destroyed" do
expect(project).to receive(:remove_pages).and_call_original
project.destroy
end
end
- describe '#remove_export' do
+ describe "#remove_export" do
let(:project) { create(:project, :with_export) }
- it 'removes the export' do
+ it "removes the export" do
project.remove_exports
expect(project.export_file_exists?).to be_falsey
end
end
- describe '#forks_count' do
- it 'returns the number of forks' do
+ describe "#forks_count" do
+ it "returns the number of forks" do
project = build(:project)
expect_any_instance_of(Projects::ForksCountService).to receive(:count).and_return(1)
@@ -3335,26 +3337,26 @@ describe Project do
end
end
- describe '#git_transfer_in_progress?' do
+ describe "#git_transfer_in_progress?" do
let(:project) { build(:project) }
subject { project.git_transfer_in_progress? }
- it 'returns false when repo_reference_count and wiki_reference_count are 0' do
+ it "returns false when repo_reference_count and wiki_reference_count are 0" do
allow(project).to receive(:repo_reference_count) { 0 }
allow(project).to receive(:wiki_reference_count) { 0 }
expect(subject).to be_falsey
end
- it 'returns true when repo_reference_count is > 0' do
+ it "returns true when repo_reference_count is > 0" do
allow(project).to receive(:repo_reference_count) { 2 }
allow(project).to receive(:wiki_reference_count) { 0 }
expect(subject).to be_truthy
end
- it 'returns true when wiki_reference_count is > 0' do
+ it "returns true when wiki_reference_count is > 0" do
allow(project).to receive(:repo_reference_count) { 0 }
allow(project).to receive(:wiki_reference_count) { 2 }
@@ -3362,7 +3364,7 @@ describe Project do
end
end
- context 'legacy storage' do
+ context "legacy storage" do
set(:project) { create(:project, :repository, :legacy_storage) }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_storage) { project.send(:storage) }
@@ -3371,66 +3373,66 @@ describe Project do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
end
- describe '#base_dir' do
- it 'returns base_dir based on namespace only' do
+ describe "#base_dir" do
+ it "returns base_dir based on namespace only" do
expect(project.base_dir).to eq(project.namespace.full_path)
end
end
- describe '#disk_path' do
- it 'returns disk_path based on namespace and project path' do
+ describe "#disk_path" do
+ it "returns disk_path based on namespace and project path" do
expect(project.disk_path).to eq("#{project.namespace.full_path}/#{project.path}")
end
end
- describe '#ensure_storage_path_exists' do
- it 'delegates to gitlab_shell to ensure namespace is created' do
+ describe "#ensure_storage_path_exists" do
+ it "delegates to gitlab_shell to ensure namespace is created" do
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, project.base_dir)
project.ensure_storage_path_exists
end
end
- describe '#legacy_storage?' do
- it 'returns true when storage_version is nil' do
+ describe "#legacy_storage?" do
+ it "returns true when storage_version is nil" do
project = build(:project, storage_version: nil)
expect(project.legacy_storage?).to be_truthy
end
- it 'returns true when the storage_version is 0' do
+ it "returns true when the storage_version is 0" do
project = build(:project, storage_version: 0)
expect(project.legacy_storage?).to be_truthy
end
end
- describe '#hashed_storage?' do
- it 'returns false' do
+ describe "#hashed_storage?" do
+ it "returns false" do
expect(project.hashed_storage?(:repository)).to be_falsey
end
end
- describe '#pages_path' do
- it 'returns a path where pages are stored' do
+ describe "#pages_path" do
+ it "returns a path where pages are stored" do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
end
end
- describe '#migrate_to_hashed_storage!' do
+ describe "#migrate_to_hashed_storage!" do
let(:project) { create(:project, :empty_repo, :legacy_storage) }
- it 'returns true' do
+ it "returns true" do
expect(project.migrate_to_hashed_storage!).to be_truthy
end
- it 'does not run validation' do
+ it "does not run validation" do
expect(project).not_to receive(:valid?)
project.migrate_to_hashed_storage!
end
- it 'schedules ProjectMigrateHashedStorageWorker with delayed start when the project repo is in use' do
+ it "schedules ProjectMigrateHashedStorageWorker with delayed start when the project repo is in use" do
Gitlab::ReferenceCounter.new(project.gl_repository(is_wiki: false)).increase
expect(ProjectMigrateHashedStorageWorker).to receive(:perform_in)
@@ -3438,7 +3440,7 @@ describe Project do
project.migrate_to_hashed_storage!
end
- it 'schedules ProjectMigrateHashedStorageWorker with delayed start when the wiki repo is in use' do
+ it "schedules ProjectMigrateHashedStorageWorker with delayed start when the wiki repo is in use" do
Gitlab::ReferenceCounter.new(project.gl_repository(is_wiki: true)).increase
expect(ProjectMigrateHashedStorageWorker).to receive(:perform_in)
@@ -3446,7 +3448,7 @@ describe Project do
project.migrate_to_hashed_storage!
end
- it 'schedules ProjectMigrateHashedStorageWorker' do
+ it "schedules ProjectMigrateHashedStorageWorker" do
expect(ProjectMigrateHashedStorageWorker).to receive(:perform_async).with(project.id)
project.migrate_to_hashed_storage!
@@ -3454,49 +3456,49 @@ describe Project do
end
end
- context 'hashed storage' do
+ context "hashed storage" do
set(:project) { create(:project, :repository, skip_disk_validation: true) }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) }
- let(:hashed_prefix) { File.join('@hashed', hash[0..1], hash[2..3]) }
+ let(:hashed_prefix) { File.join("@hashed", hash[0..1], hash[2..3]) }
let(:hashed_path) { File.join(hashed_prefix, hash) }
before do
stub_application_setting(hashed_storage_enabled: true)
end
- describe '#legacy_storage?' do
- it 'returns false' do
+ describe "#legacy_storage?" do
+ it "returns false" do
expect(project.legacy_storage?).to be_falsey
end
end
- describe '#hashed_storage?' do
- it 'returns true if rolled out' do
+ describe "#hashed_storage?" do
+ it "returns true if rolled out" do
expect(project.hashed_storage?(:attachments)).to be_truthy
end
- it 'returns false when not rolled out yet' do
+ it "returns false when not rolled out yet" do
project.storage_version = 1
expect(project.hashed_storage?(:attachments)).to be_falsey
end
end
- describe '#base_dir' do
- it 'returns base_dir based on hash of project id' do
+ describe "#base_dir" do
+ it "returns base_dir based on hash of project id" do
expect(project.base_dir).to eq(hashed_prefix)
end
end
- describe '#disk_path' do
- it 'returns disk_path based on hash of project id' do
+ describe "#disk_path" do
+ it "returns disk_path based on hash of project id" do
expect(project.disk_path).to eq(hashed_path)
end
end
- describe '#ensure_storage_path_exists' do
- it 'delegates to gitlab_shell to ensure namespace is created' do
+ describe "#ensure_storage_path_exists" do
+ it "delegates to gitlab_shell to ensure namespace is created" do
allow(project).to receive(:gitlab_shell).and_return(gitlab_shell)
expect(gitlab_shell).to receive(:add_namespace).with(project.repository_storage, hashed_prefix)
@@ -3505,25 +3507,25 @@ describe Project do
end
end
- describe '#pages_path' do
- it 'returns a path where pages are stored' do
+ describe "#pages_path" do
+ it "returns a path where pages are stored" do
expect(project.pages_path).to eq(File.join(Settings.pages.path, project.namespace.full_path, project.path))
end
end
- describe '#migrate_to_hashed_storage!' do
+ describe "#migrate_to_hashed_storage!" do
let(:project) { create(:project, :repository, skip_disk_validation: true) }
- it 'returns nil' do
+ it "returns nil" do
expect(project.migrate_to_hashed_storage!).to be_nil
end
- it 'does not flag as read-only' do
+ it "does not flag as read-only" do
expect { project.migrate_to_hashed_storage! }.not_to change { project.repository_read_only }
end
- context 'when partially migrated' do
- it 'enqueues a job' do
+ context "when partially migrated" do
+ it "enqueues a job" do
project = create(:project, storage_version: 1, skip_disk_validation: true)
Sidekiq::Testing.fake! do
@@ -3534,17 +3536,17 @@ describe Project do
end
end
- describe '#gl_repository' do
+ describe "#gl_repository" do
let(:project) { create(:project) }
- it 'delegates to Gitlab::GlRepository.gl_repository' do
+ it "delegates to Gitlab::GlRepository.gl_repository" do
expect(Gitlab::GlRepository).to receive(:gl_repository).with(project, true)
project.gl_repository(is_wiki: true)
end
end
- describe '#has_ci?' do
+ describe "#has_ci?" do
set(:project) { create(:project) }
let(:repository) { double }
@@ -3552,9 +3554,9 @@ describe Project do
expect(project).to receive(:repository) { repository }
end
- context 'when has .gitlab-ci.yml' do
+ context "when has .gitlab-ci.yml" do
before do
- expect(repository).to receive(:gitlab_ci_yml) { 'content' }
+ expect(repository).to receive(:gitlab_ci_yml) { "content" }
end
it "CI is available" do
@@ -3562,7 +3564,7 @@ describe Project do
end
end
- context 'when there is no .gitlab-ci.yml' do
+ context "when there is no .gitlab-ci.yml" do
before do
expect(repository).to receive(:gitlab_ci_yml) { nil }
end
@@ -3571,7 +3573,7 @@ describe Project do
expect(project).to have_ci
end
- context 'when auto devops is disabled' do
+ context "when auto devops is disabled" do
before do
stub_application_setting(auto_devops_enabled: false)
end
@@ -3583,7 +3585,7 @@ describe Project do
end
end
- describe '#auto_devops_enabled?' do
+ describe "#auto_devops_enabled?" do
before do
allow(Feature).to receive(:enabled?).and_call_original
Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(0)
@@ -3593,14 +3595,14 @@ describe Project do
subject { project.auto_devops_enabled? }
- context 'when enabled in settings' do
+ context "when enabled in settings" do
before do
stub_application_setting(auto_devops_enabled: true)
end
it { is_expected.to be_truthy }
- context 'when explicitly enabled' do
+ context "when explicitly enabled" do
before do
create(:project_auto_devops, project: project)
end
@@ -3608,7 +3610,7 @@ describe Project do
it { is_expected.to be_truthy }
end
- context 'when explicitly disabled' do
+ context "when explicitly disabled" do
before do
create(:project_auto_devops, project: project, enabled: false)
end
@@ -3617,14 +3619,14 @@ describe Project do
end
end
- context 'when disabled in settings' do
+ context "when disabled in settings" do
before do
stub_application_setting(auto_devops_enabled: false)
end
it { is_expected.to be_falsey }
- context 'when explicitly enabled' do
+ context "when explicitly enabled" do
before do
create(:project_auto_devops, project: project)
end
@@ -3632,7 +3634,7 @@ describe Project do
it { is_expected.to be_truthy }
end
- context 'when force_autodevops_on_by_default is enabled for the project' do
+ context "when force_autodevops_on_by_default is enabled for the project" do
before do
Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(100)
end
@@ -3642,51 +3644,51 @@ describe Project do
end
end
- describe '#has_auto_devops_implicitly_enabled?' do
+ describe "#has_auto_devops_implicitly_enabled?" do
set(:project) { create(:project) }
- context 'when disabled in settings' do
+ context "when disabled in settings" do
before do
stub_application_setting(auto_devops_enabled: false)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_enabled
end
end
- context 'when enabled in settings' do
+ context "when enabled in settings" do
before do
stub_application_setting(auto_devops_enabled: true)
end
- it 'auto devops is implicitly disabled' do
+ it "auto devops is implicitly disabled" do
expect(project).to have_auto_devops_implicitly_enabled
end
- context 'when explicitly disabled' do
+ context "when explicitly disabled" do
before do
create(:project_auto_devops, project: project, enabled: false)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_enabled
end
end
- context 'when explicitly enabled' do
+ context "when explicitly enabled" do
before do
create(:project_auto_devops, project: project, enabled: true)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_enabled
end
end
end
end
- describe '#has_auto_devops_implicitly_disabled?' do
+ describe "#has_auto_devops_implicitly_disabled?" do
before do
allow(Feature).to receive(:enabled?).and_call_original
Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(0)
@@ -3694,148 +3696,148 @@ describe Project do
set(:project) { create(:project) }
- context 'when enabled in settings' do
+ context "when enabled in settings" do
before do
stub_application_setting(auto_devops_enabled: true)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
- context 'when disabled in settings' do
+ context "when disabled in settings" do
before do
stub_application_setting(auto_devops_enabled: false)
end
- it 'auto devops is implicitly disabled' do
+ it "auto devops is implicitly disabled" do
expect(project).to have_auto_devops_implicitly_disabled
end
- context 'when force_autodevops_on_by_default is enabled for the project' do
+ context "when force_autodevops_on_by_default is enabled for the project" do
before do
Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(100)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
- context 'when explicitly disabled' do
+ context "when explicitly disabled" do
before do
create(:project_auto_devops, project: project, enabled: false)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
- context 'when explicitly enabled' do
+ context "when explicitly enabled" do
before do
create(:project_auto_devops, project: project, enabled: true)
end
- it 'does not have auto devops implicitly disabled' do
+ it "does not have auto devops implicitly disabled" do
expect(project).not_to have_auto_devops_implicitly_disabled
end
end
end
end
- describe '#api_variables' do
+ describe "#api_variables" do
set(:project) { create(:project) }
- it 'exposes API v4 URL' do
- expect(project.api_variables.first[:key]).to eq 'CI_API_V4_URL'
- expect(project.api_variables.first[:value]).to include '/api/v4'
+ it "exposes API v4 URL" do
+ expect(project.api_variables.first[:key]).to eq "CI_API_V4_URL"
+ expect(project.api_variables.first[:value]).to include "/api/v4"
end
- it 'contains a URL variable for every supported API version' do
+ it "contains a URL variable for every supported API version" do
# Ensure future API versions have proper variables defined. We're not doing this for v3.
- supported_versions = API::API.versions - ['v3']
- supported_versions = supported_versions.select do |version|
+ supported_versions = API::API.versions - ["v3"]
+ supported_versions = supported_versions.select { |version|
API::API.routes.select { |route| route.version == version }.many?
- end
+ }
- required_variables = supported_versions.map do |version|
+ required_variables = supported_versions.map { |version|
"CI_API_#{version.upcase}_URL"
- end
+ }
expect(project.api_variables.map { |variable| variable[:key] })
.to contain_exactly(*required_variables)
end
end
- describe '#auto_devops_variables' do
+ describe "#auto_devops_variables" do
set(:project) { create(:project) }
subject { project.auto_devops_variables }
- context 'when enabled in instance settings' do
+ context "when enabled in instance settings" do
before do
stub_application_setting(auto_devops_enabled: true)
end
- context 'when domain is empty' do
+ context "when domain is empty" do
before do
stub_application_setting(auto_devops_domain: nil)
end
- it 'variables does not include AUTO_DEVOPS_DOMAIN' do
+ it "variables does not include AUTO_DEVOPS_DOMAIN" do
is_expected.not_to include(domain_variable)
end
end
- context 'when domain is configured' do
+ context "when domain is configured" do
before do
- stub_application_setting(auto_devops_domain: 'example.com')
+ stub_application_setting(auto_devops_domain: "example.com")
end
- it 'variables includes AUTO_DEVOPS_DOMAIN' do
+ it "variables includes AUTO_DEVOPS_DOMAIN" do
is_expected.to include(domain_variable)
end
end
end
- context 'when explicitly enabled' do
- context 'when domain is empty' do
+ context "when explicitly enabled" do
+ context "when domain is empty" do
before do
create(:project_auto_devops, project: project, domain: nil)
end
- it 'variables does not include AUTO_DEVOPS_DOMAIN' do
+ it "variables does not include AUTO_DEVOPS_DOMAIN" do
is_expected.not_to include(domain_variable)
end
end
- context 'when domain is configured' do
+ context "when domain is configured" do
before do
- create(:project_auto_devops, project: project, domain: 'example.com')
+ create(:project_auto_devops, project: project, domain: "example.com")
end
- it 'variables includes AUTO_DEVOPS_DOMAIN' do
+ it "variables includes AUTO_DEVOPS_DOMAIN" do
is_expected.to include(domain_variable)
end
end
end
def domain_variable
- { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
+ {key: "AUTO_DEVOPS_DOMAIN", value: "example.com", public: true}
end
end
- describe '#latest_successful_builds_for' do
+ describe "#latest_successful_builds_for" do
let(:project) { build(:project) }
before do
- allow(project).to receive(:default_branch).and_return('master')
+ allow(project).to receive(:default_branch).and_return("master")
end
- context 'without a ref' do
- it 'returns a pipeline for the default branch' do
+ context "without a ref" do
+ it "returns a pipeline for the default branch" do
expect(project)
.to receive(:latest_successful_pipeline_for_default_branch)
@@ -3843,8 +3845,8 @@ describe Project do
end
end
- context 'with the ref set to the default branch' do
- it 'returns a pipeline for the default branch' do
+ context "with the ref set to the default branch" do
+ it "returns a pipeline for the default branch" do
expect(project)
.to receive(:latest_successful_pipeline_for_default_branch)
@@ -3852,19 +3854,19 @@ describe Project do
end
end
- context 'with a ref that is not the default branch' do
- it 'returns the latest successful pipeline for the given ref' do
- expect(project.ci_pipelines).to receive(:latest_successful_for).with('foo')
+ context "with a ref that is not the default branch" do
+ it "returns the latest successful pipeline for the given ref" do
+ expect(project.ci_pipelines).to receive(:latest_successful_for).with("foo")
- project.latest_successful_pipeline_for('foo')
+ project.latest_successful_pipeline_for("foo")
end
end
end
- describe '#check_repository_path_availability' do
+ describe "#check_repository_path_availability" do
let(:project) { build(:project) }
- it 'skips gitlab-shell exists?' do
+ it "skips gitlab-shell exists?" do
project.skip_disk_validation = true
expect(project.gitlab_shell).not_to receive(:exists?)
@@ -3872,14 +3874,14 @@ describe Project do
end
end
- describe '#latest_successful_pipeline_for_default_branch' do
+ describe "#latest_successful_pipeline_for_default_branch" do
let(:project) { build(:project) }
before do
- allow(project).to receive(:default_branch).and_return('master')
+ allow(project).to receive(:default_branch).and_return("master")
end
- it 'memoizes and returns the latest successful pipeline for the default branch' do
+ it "memoizes and returns the latest successful pipeline for the default branch" do
pipeline = double(:pipeline)
expect(project.ci_pipelines).to receive(:latest_successful_for)
@@ -3894,11 +3896,11 @@ describe Project do
end
end
- describe '#after_import' do
+ describe "#after_import" do
let(:project) { create(:project) }
let(:import_state) { create(:import_state, project: project) }
- it 'runs the correct hooks' do
+ it "runs the correct hooks" do
expect(project.repository).to receive(:after_import)
expect(project.wiki.repository).to receive(:after_import)
expect(import_state).to receive(:finish)
@@ -3911,14 +3913,14 @@ describe Project do
project.after_import
end
- context 'branch protection' do
+ context "branch protection" do
let(:project) { create(:project, :repository) }
before do
create(:import_state, :started, project: project)
end
- it 'does not protect when branch protection is disabled' do
+ it "does not protect when branch protection is disabled" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
project.after_import
@@ -3946,7 +3948,7 @@ describe Project do
expect(project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::DEVELOPER])
end
- it 'protects default branch' do
+ it "protects default branch" do
project.after_import
expect(project.protected_branches).not_to be_empty
@@ -3957,10 +3959,10 @@ describe Project do
end
end
- describe '#update_project_counter_caches' do
+ describe "#update_project_counter_caches" do
let(:project) { create(:project) }
- it 'updates all project counter caches' do
+ it "updates all project counter caches" do
expect_any_instance_of(Projects::OpenIssuesCountService)
.to receive(:refresh_cache)
.and_call_original
@@ -3973,45 +3975,45 @@ describe Project do
end
end
- describe '#wiki_repository_exists?' do
- it 'returns true when the wiki repository exists' do
+ describe "#wiki_repository_exists?" do
+ it "returns true when the wiki repository exists" do
project = create(:project, :wiki_repo)
expect(project.wiki_repository_exists?).to eq(true)
end
- it 'returns false when the wiki repository does not exist' do
+ it "returns false when the wiki repository does not exist" do
project = create(:project)
expect(project.wiki_repository_exists?).to eq(false)
end
end
- describe '#write_repository_config' do
+ describe "#write_repository_config" do
set(:project) { create(:project, :repository) }
- it 'writes full path in .git/config when key is missing' do
+ it "writes full path in .git/config when key is missing" do
project.write_repository_config
- expect(rugged_config['gitlab.fullpath']).to eq project.full_path
+ expect(rugged_config["gitlab.fullpath"]).to eq project.full_path
end
- it 'updates full path in .git/config when key is present' do
- project.write_repository_config(gl_full_path: 'old/path')
+ it "updates full path in .git/config when key is present" do
+ project.write_repository_config(gl_full_path: "old/path")
- expect { project.write_repository_config }.to change { rugged_config['gitlab.fullpath'] }.from('old/path').to(project.full_path)
+ expect { project.write_repository_config }.to change { rugged_config["gitlab.fullpath"] }.from("old/path").to(project.full_path)
end
- it 'does not raise an error with an empty repository' do
+ it "does not raise an error with an empty repository" do
project = create(:project_empty_repo)
expect { project.write_repository_config }.not_to raise_error
end
end
- describe '#execute_hooks' do
- let(:data) { { ref: 'refs/heads/master', data: 'data' } }
- it 'executes active projects hooks with the specified scope' do
+ describe "#execute_hooks" do
+ let(:data) { {ref: "refs/heads/master", data: "data"} }
+ it "executes active projects hooks with the specified scope" do
hook = create(:project_hook, merge_requests_events: false, push_events: true)
expect(ProjectHook).to receive(:select_active)
.with(:push_hooks, data)
@@ -4023,7 +4025,7 @@ describe Project do
project.execute_hooks(data, :push_hooks)
end
- it 'does not execute project hooks that dont match the specified scope' do
+ it "does not execute project hooks that dont match the specified scope" do
hook = create(:project_hook, merge_requests_events: true, push_events: false)
project = create(:project, hooks: [hook])
@@ -4032,7 +4034,7 @@ describe Project do
project.execute_hooks(data, :push_hooks)
end
- it 'does not execute project hooks which are not active' do
+ it "does not execute project hooks which are not active" do
hook = create(:project_hook, push_events: true)
expect(ProjectHook).to receive(:select_active)
.with(:push_hooks, data)
@@ -4044,14 +4046,14 @@ describe Project do
project.execute_hooks(data, :push_hooks)
end
- it 'executes the system hooks with the specified scope' do
+ it "executes the system hooks with the specified scope" do
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks).with(data, :merge_request_hooks)
project = build(:project)
project.execute_hooks(data, :merge_request_hooks)
end
- it 'executes the system hooks when inside a transaction' do
+ it "executes the system hooks when inside a transaction" do
allow_any_instance_of(WebHookService).to receive(:execute)
create(:system_hook, merge_requests_events: true)
@@ -4061,24 +4063,24 @@ describe Project do
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
# but since the entire spec run takes place in a transaction, we never
# actually get to the `after_commit` hook that queues these jobs.
- expect do
+ expect {
project.transaction do
project.execute_hooks(data, :merge_request_hooks)
end
- end.not_to raise_error # Sidekiq::Worker::EnqueueFromTransactionError
+ }.not_to raise_error # Sidekiq::Worker::EnqueueFromTransactionError
end
end
- describe '#badges' do
+ describe "#badges" do
let(:project_group) { create(:group) }
- let(:project) { create(:project, path: 'avatar', namespace: project_group) }
+ let(:project) { create(:project, path: "avatar", namespace: project_group) }
before do
create_list(:project_badge, 2, project: project)
create(:group_badge, group: project_group)
end
- it 'returns the project and the project group badges' do
+ it "returns the project and the project group badges" do
create(:group_badge, group: create(:group))
expect(Badge.count).to eq 4
@@ -4086,7 +4088,7 @@ describe Project do
end
if Group.supports_nested_objects?
- context 'with nested_groups' do
+ context "with nested_groups" do
let(:parent_group) { create(:group) }
before do
@@ -4094,14 +4096,14 @@ describe Project do
project_group.update(parent: parent_group)
end
- it 'returns the project and the project nested groups badges' do
+ it "returns the project and the project nested groups badges" do
expect(project.badges.count).to eq 5
end
end
end
end
- context 'with cross project merge requests' do
+ context "with cross project merge requests" do
let(:user) { create(:user) }
let(:target_project) { create(:project, :repository) }
let(:project) { fork_project(target_project, nil, repository: true) }
@@ -4109,9 +4111,9 @@ describe Project do
create(
:merge_request,
target_project: project,
- target_branch: 'target-branch',
+ target_branch: "target-branch",
source_project: project,
- source_branch: 'awesome-feature-1',
+ source_branch: "awesome-feature-1",
allow_collaboration: true
)
end
@@ -4119,9 +4121,9 @@ describe Project do
create(
:merge_request,
target_project: target_project,
- target_branch: 'target-branch',
+ target_branch: "target-branch",
source_project: project,
- source_branch: 'awesome-feature-1',
+ source_branch: "awesome-feature-1",
allow_collaboration: true
)
end
@@ -4130,42 +4132,42 @@ describe Project do
target_project.add_developer(user)
end
- describe '#merge_requests_allowing_push_to_user' do
- it 'returns open merge requests for which the user has developer access to the target project' do
+ describe "#merge_requests_allowing_push_to_user" do
+ it "returns open merge requests for which the user has developer access to the target project" do
expect(project.merge_requests_allowing_push_to_user(user)).to include(merge_request)
end
- it 'does not include closed merge requests' do
+ it "does not include closed merge requests" do
merge_request.close
expect(project.merge_requests_allowing_push_to_user(user)).to be_empty
end
- it 'does not include merge requests for guest users' do
+ it "does not include merge requests for guest users" do
guest = create(:user)
target_project.add_guest(guest)
expect(project.merge_requests_allowing_push_to_user(guest)).to be_empty
end
- it 'does not include the merge request for other users' do
+ it "does not include the merge request for other users" do
other_user = create(:user)
expect(project.merge_requests_allowing_push_to_user(other_user)).to be_empty
end
- it 'is empty when no user is passed' do
+ it "is empty when no user is passed" do
expect(project.merge_requests_allowing_push_to_user(nil)).to be_empty
end
end
- describe '#any_branch_allows_collaboration?' do
- it 'allows access when there are merge requests open allowing collaboration' do
+ describe "#any_branch_allows_collaboration?" do
+ it "allows access when there are merge requests open allowing collaboration" do
expect(project.any_branch_allows_collaboration?(user))
.to be_truthy
end
- it 'does not allow access when there are no merge requests open allowing collaboration' do
+ it "does not allow access when there are no merge requests open allowing collaboration" do
merge_request.close!
expect(project.any_branch_allows_collaboration?(user))
@@ -4173,44 +4175,44 @@ describe Project do
end
end
- describe '#branch_allows_collaboration?' do
- it 'allows access if the user can merge the merge request' do
- expect(project.branch_allows_collaboration?(user, 'awesome-feature-1'))
+ describe "#branch_allows_collaboration?" do
+ it "allows access if the user can merge the merge request" do
+ expect(project.branch_allows_collaboration?(user, "awesome-feature-1"))
.to be_truthy
end
- it 'does not allow guest users access' do
+ it "does not allow guest users access" do
guest = create(:user)
target_project.add_guest(guest)
- expect(project.branch_allows_collaboration?(guest, 'awesome-feature-1'))
+ expect(project.branch_allows_collaboration?(guest, "awesome-feature-1"))
.to be_falsy
end
- it 'does not allow access to branches for which the merge request was closed' do
+ it "does not allow access to branches for which the merge request was closed" do
create(:merge_request, :closed,
- target_project: target_project,
- target_branch: 'target-branch',
- source_project: project,
- source_branch: 'rejected-feature-1',
- allow_collaboration: true)
+ target_project: target_project,
+ target_branch: "target-branch",
+ source_project: project,
+ source_branch: "rejected-feature-1",
+ allow_collaboration: true)
- expect(project.branch_allows_collaboration?(user, 'rejected-feature-1'))
+ expect(project.branch_allows_collaboration?(user, "rejected-feature-1"))
.to be_falsy
end
- it 'does not allow access if the user cannot merge the merge request' do
- create(:protected_branch, :maintainers_can_push, project: target_project, name: 'target-branch')
+ it "does not allow access if the user cannot merge the merge request" do
+ create(:protected_branch, :maintainers_can_push, project: target_project, name: "target-branch")
- expect(project.branch_allows_collaboration?(user, 'awesome-feature-1'))
+ expect(project.branch_allows_collaboration?(user, "awesome-feature-1"))
.to be_falsy
end
- context 'when the requeststore is active', :request_store do
- it 'only queries per project across instances' do
- control = ActiveRecord::QueryRecorder.new { project.branch_allows_collaboration?(user, 'awesome-feature-1') }
+ context "when the requeststore is active", :request_store do
+ it "only queries per project across instances" do
+ control = ActiveRecord::QueryRecorder.new { project.branch_allows_collaboration?(user, "awesome-feature-1") }
- expect { 2.times { described_class.find(project.id).branch_allows_collaboration?(user, 'awesome-feature-1') } }
+ expect { 2.times { described_class.find(project.id).branch_allows_collaboration?(user, "awesome-feature-1") } }
.not_to exceed_query_limit(control).with_threshold(2)
end
end
@@ -4262,8 +4264,8 @@ describe Project do
end
end
- describe '#toggle_ci_cd_settings!' do
- it 'toggles the value on #settings' do
+ describe "#toggle_ci_cd_settings!" do
+ it "toggles the value on #settings" do
project = create(:project, group_runners_enabled: false)
expect(project.group_runners_enabled).to be false
@@ -4274,39 +4276,39 @@ describe Project do
end
end
- describe '#gitlab_deploy_token' do
+ describe "#gitlab_deploy_token" do
let(:project) { create(:project) }
subject { project.gitlab_deploy_token }
- context 'when there is a gitlab deploy token associated' do
+ context "when there is a gitlab deploy token associated" do
let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, projects: [project]) }
it { is_expected.to eq(deploy_token) }
end
- context 'when there is no a gitlab deploy token associated' do
+ context "when there is no a gitlab deploy token associated" do
it { is_expected.to be_nil }
end
- context 'when there is a gitlab deploy token associated but is has been revoked' do
+ context "when there is a gitlab deploy token associated but is has been revoked" do
let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :revoked, projects: [project]) }
it { is_expected.to be_nil }
end
- context 'when there is a gitlab deploy token associated but it is expired' do
+ context "when there is a gitlab deploy token associated but it is expired" do
let!(:deploy_token) { create(:deploy_token, :gitlab_deploy_token, :expired, projects: [project]) }
it { is_expected.to be_nil }
end
- context 'when there is a deploy token associated with a different name' do
+ context "when there is a deploy token associated with a different name" do
let!(:deploy_token) { create(:deploy_token, projects: [project]) }
it { is_expected.to be_nil }
end
- context 'when there is a deploy token associated to a different project' do
+ context "when there is a deploy token associated to a different project" do
let(:project_2) { create(:project) }
let!(:deploy_token) { create(:deploy_token, projects: [project_2]) }
@@ -4314,25 +4316,25 @@ describe Project do
end
end
- context 'with uploads' do
- it_behaves_like 'model with uploads', true do
+ context "with uploads" do
+ it_behaves_like "model with uploads", true do
let(:model_object) { create(:project, :with_avatar) }
let(:upload_attribute) { :avatar }
let(:uploader_class) { AttachmentUploader }
end
end
- context '#commits_by' do
+ context "#commits_by" do
let(:project) { create(:project, :repository) }
- let(:commits) { project.repository.commits('HEAD', limit: 3).commits }
+ let(:commits) { project.repository.commits("HEAD", limit: 3).commits }
let(:commit_shas) { commits.map(&:id) }
- it 'retrieves several commits from the repository by oid' do
+ it "retrieves several commits from the repository by oid" do
expect(project.commits_by(oids: commit_shas)).to eq commits
end
end
- context '#members_among' do
+ context "#members_among" do
let(:users) { create_list(:user, 3) }
set(:group) { create(:group) }
set(:project) { create(:project, namespace: group) }
@@ -4342,31 +4344,31 @@ describe Project do
project.group.add_maintainer(users.last)
end
- context 'when users is an Array' do
- it 'returns project members among the users' do
+ context "when users is an Array" do
+ it "returns project members among the users" do
expect(project.members_among(users)).to eq([users.first, users.last])
end
- it 'maintains input order' do
+ it "maintains input order" do
expect(project.members_among(users.reverse)).to eq([users.last, users.first])
end
- it 'returns empty array if users is empty' do
+ it "returns empty array if users is empty" do
result = project.members_among([])
expect(result).to be_empty
end
end
- context 'when users is a relation' do
- it 'returns project members among the users' do
+ context "when users is a relation" do
+ it "returns project members among the users" do
result = project.members_among(User.where(id: users.map(&:id)))
expect(result).to be_a(ActiveRecord::Relation)
expect(result).to eq([users.first, users.last])
end
- it 'returns empty relation if users is empty' do
+ it "returns empty relation if users is empty" do
result = project.members_among(User.none)
expect(result).to be_a(ActiveRecord::Relation)
@@ -4378,9 +4380,9 @@ describe Project do
describe "#find_or_initialize_services" do
subject { build(:project) }
- it 'returns only enabled services' do
- allow(Service).to receive(:available_services_names).and_return(%w(prometheus pushover))
- allow(subject).to receive(:disabled_services).and_return(%w(prometheus))
+ it "returns only enabled services" do
+ allow(Service).to receive(:available_services_names).and_return(%w[prometheus pushover])
+ allow(subject).to receive(:disabled_services).and_return(%w[prometheus])
services = subject.find_or_initialize_services
@@ -4392,39 +4394,39 @@ describe Project do
describe "#find_or_initialize_service" do
subject { build(:project) }
- it 'avoids N+1 database queries' do
- allow(Service).to receive(:available_services_names).and_return(%w(prometheus pushover))
+ it "avoids N+1 database queries" do
+ allow(Service).to receive(:available_services_names).and_return(%w[prometheus pushover])
- control_count = ActiveRecord::QueryRecorder.new { subject.find_or_initialize_service('prometheus') }.count
+ control_count = ActiveRecord::QueryRecorder.new { subject.find_or_initialize_service("prometheus") }.count
allow(Service).to receive(:available_services_names).and_call_original
- expect { subject.find_or_initialize_service('prometheus') }.not_to exceed_query_limit(control_count)
+ expect { subject.find_or_initialize_service("prometheus") }.not_to exceed_query_limit(control_count)
end
- it 'returns nil if service is disabled' do
- allow(subject).to receive(:disabled_services).and_return(%w(prometheus))
+ it "returns nil if service is disabled" do
+ allow(subject).to receive(:disabled_services).and_return(%w[prometheus])
- expect(subject.find_or_initialize_service('prometheus')).to be_nil
+ expect(subject.find_or_initialize_service("prometheus")).to be_nil
end
end
- describe '.find_without_deleted' do
- it 'returns nil if the project is about to be removed' do
+ describe ".find_without_deleted" do
+ it "returns nil if the project is about to be removed" do
project = create(:project, pending_delete: true)
expect(described_class.find_without_deleted(project.id)).to be_nil
end
- it 'returns a project when it is not about to be removed' do
+ it "returns a project when it is not about to be removed" do
project = create(:project)
expect(described_class.find_without_deleted(project.id)).to eq(project)
end
end
- describe '.for_group' do
- it 'returns the projects for a given group' do
+ describe ".for_group" do
+ it "returns the projects for a given group" do
group = create(:group)
project = create(:project, namespace: group)
@@ -4432,7 +4434,7 @@ describe Project do
end
end
- describe '.deployments' do
+ describe ".deployments" do
subject { project.deployments }
let(:project) { create(:project) }
@@ -4441,46 +4443,46 @@ describe Project do
allow_any_instance_of(Deployment).to receive(:create_ref)
end
- context 'when there is a deployment record with created status' do
+ context "when there is a deployment record with created status" do
let(:deployment) { create(:deployment, :created, project: project) }
- it 'does not return the record' do
+ it "does not return the record" do
is_expected.to be_empty
end
end
- context 'when there is a deployment record with running status' do
+ context "when there is a deployment record with running status" do
let(:deployment) { create(:deployment, :running, project: project) }
- it 'does not return the record' do
+ it "does not return the record" do
is_expected.to be_empty
end
end
- context 'when there is a deployment record with success status' do
+ context "when there is a deployment record with success status" do
let(:deployment) { create(:deployment, :success, project: project) }
- it 'returns the record' do
+ it "returns the record" do
is_expected.to eq([deployment])
end
end
end
- describe '#snippets_visible?' do
- it 'returns true when a logged in user can read snippets' do
+ describe "#snippets_visible?" do
+ it "returns true when a logged in user can read snippets" do
project = create(:project, :public)
user = create(:user)
expect(project.snippets_visible?(user)).to eq(true)
end
- it 'returns true when an anonymous user can read snippets' do
+ it "returns true when an anonymous user can read snippets" do
project = create(:project, :public)
expect(project.snippets_visible?).to eq(true)
end
- it 'returns false when a user can not read snippets' do
+ it "returns false when a user can not read snippets" do
project = create(:project, :private)
user = create(:user)
@@ -4488,28 +4490,28 @@ describe Project do
end
end
- describe '#all_clusters' do
+ describe "#all_clusters" do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, cluster_type: :project_type, projects: [project]) }
subject { project.all_clusters }
- it 'returns project level cluster' do
+ it "returns project level cluster" do
expect(subject).to eq([cluster])
end
- context 'project belongs to a group' do
+ context "project belongs to a group" do
let(:group_cluster) { create(:cluster, :group) }
let(:group) { group_cluster.group }
let(:project) { create(:project, group: group) }
- it 'returns clusters for groups of this project' do
+ it "returns clusters for groups of this project" do
expect(subject).to contain_exactly(cluster, group_cluster)
end
end
end
- describe '#object_pool_params' do
+ describe "#object_pool_params" do
let(:project) { create(:project, :repository, :public) }
subject { project.object_pool_params }
@@ -4518,24 +4520,24 @@ describe Project do
stub_application_setting(hashed_storage_enabled: true)
end
- context 'when the objects cannot be pooled' do
+ context "when the objects cannot be pooled" do
let(:project) { create(:project, :repository, :private) }
it { is_expected.to be_empty }
end
- context 'when a pool is created' do
- it 'returns that pool repository' do
+ context "when a pool is created" do
+ it "returns that pool repository" do
expect(subject).not_to be_empty
expect(subject[:pool_repository]).to be_persisted
end
end
end
- describe '#git_objects_poolable?' do
+ describe "#git_objects_poolable?" do
subject { project }
- context 'when the feature flag is turned off' do
+ context "when the feature flag is turned off" do
before do
stub_feature_flags(object_pools: false)
end
@@ -4545,20 +4547,20 @@ describe Project do
it { is_expected.not_to be_git_objects_poolable }
end
- context 'when the feature flag is enabled' do
- context 'when not using hashed storage' do
+ context "when the feature flag is enabled" do
+ context "when not using hashed storage" do
let(:project) { create(:project, :legacy_storage, :public, :repository) }
it { is_expected.not_to be_git_objects_poolable }
end
- context 'when the project is not public' do
+ context "when the project is not public" do
let(:project) { create(:project, :private) }
it { is_expected.not_to be_git_objects_poolable }
end
- context 'when objects are poolable' do
+ context "when objects are poolable" do
let(:project) { create(:project, :repository, :public) }
before do
@@ -4570,20 +4572,20 @@ describe Project do
end
end
- describe '#leave_pool_repository' do
+ describe "#leave_pool_repository" do
let(:pool) { create(:pool_repository) }
let(:project) { create(:project, :repository, pool_repository: pool) }
- it 'removes the membership' do
+ it "removes the membership" do
project.leave_pool_repository
expect(pool.member_projects.reload).not_to include(project)
end
end
- describe '#check_personal_projects_limit' do
- context 'when creating a project for a group' do
- it 'does nothing' do
+ describe "#check_personal_projects_limit" do
+ context "when creating a project for a group" do
+ it "does nothing" do
creator = build(:user)
project = build(:project, namespace: build(:group), creator: creator)
@@ -4597,7 +4599,7 @@ describe Project do
end
end
- context 'when the user is not allowed to create a personal project' do
+ context "when the user is not allowed to create a personal project" do
let(:user) { build(:user) }
let(:project) { build(:project, creator: user) }
@@ -4607,8 +4609,8 @@ describe Project do
.and_return(false)
end
- context 'when the project limit is zero' do
- it 'adds a validation error' do
+ context "when the project limit is zero" do
+ it "adds a validation error" do
allow(user)
.to receive(:projects_limit)
.and_return(0)
@@ -4620,8 +4622,8 @@ describe Project do
end
end
- context 'when the project limit is greater than zero' do
- it 'adds a validation error' do
+ context "when the project limit is greater than zero" do
+ it "adds a validation error" do
allow(user)
.to receive(:projects_limit)
.and_return(5)
@@ -4634,8 +4636,8 @@ describe Project do
end
end
- context 'when the user is allowed to create personal projects' do
- it 'does nothing' do
+ context "when the user is allowed to create personal projects" do
+ it "does nothing" do
user = build(:user)
project = build(:project, creator: user)
@@ -4650,14 +4652,14 @@ describe Project do
end
end
- describe '#has_pool_repsitory?' do
- it 'returns false when it does not have a pool repository' do
+ describe "#has_pool_repsitory?" do
+ it "returns false when it does not have a pool repository" do
subject = create(:project, :repository)
expect(subject.has_pool_repository?).to be false
end
- it 'returns true when it has a pool repository' do
+ it "returns true when it has a pool repository" do
pool = create(:pool_repository, :ready)
subject = create(:project, :repository, pool_repository: pool)
@@ -4669,17 +4671,17 @@ describe Project do
rugged_repo(project.repository).config
end
- def create_pipeline(project, status = 'success')
+ def create_pipeline(project, status = "success")
create(:ci_pipeline, project: project,
sha: project.commit.sha,
ref: project.default_branch,
status: status)
end
- def create_build(new_pipeline = pipeline, name = 'test')
+ def create_build(new_pipeline = pipeline, name = "test")
create(:ci_build, :success, :artifacts,
- pipeline: new_pipeline,
- status: new_pipeline.status,
- name: name)
+ pipeline: new_pipeline,
+ status: new_pipeline.status,
+ name: name)
end
end
diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb
index 64c39f09e33..d3dc62e53fa 100644
--- a/spec/models/project_statistics_spec.rb
+++ b/spec/models/project_statistics_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
describe ProjectStatistics do
let(:project) { create :project }
let(:statistics) { project.statistics }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:namespace) }
end
- describe 'statistics columns' do
+ describe "statistics columns" do
it "support values up to 8 exabytes" do
statistics.update!(
commit_count: 8.exabytes - 1,
@@ -28,7 +28,7 @@ describe ProjectStatistics do
end
end
- describe '#total_repository_size' do
+ describe "#total_repository_size" do
it "sums repository and LFS object size" do
statistics.repository_size = 2
statistics.lfs_objects_size = 3
@@ -38,7 +38,7 @@ describe ProjectStatistics do
end
end
- describe '#refresh!' do
+ describe "#refresh!" do
before do
allow(statistics).to receive(:update_commit_count)
allow(statistics).to receive(:update_repository_size)
@@ -71,7 +71,7 @@ describe ProjectStatistics do
end
end
- describe '#update_commit_count' do
+ describe "#update_commit_count" do
before do
allow(project.repository).to receive(:commit_count).and_return(23)
statistics.update_commit_count
@@ -82,7 +82,7 @@ describe ProjectStatistics do
end
end
- describe '#update_repository_size' do
+ describe "#update_repository_size" do
before do
allow(project.repository).to receive(:size).and_return(12)
statistics.update_repository_size
@@ -93,7 +93,7 @@ describe ProjectStatistics do
end
end
- describe '#update_lfs_objects_size' do
+ describe "#update_lfs_objects_size" do
let!(:lfs_object1) { create(:lfs_object, size: 23.megabytes) }
let!(:lfs_object2) { create(:lfs_object, size: 34.megabytes) }
let!(:lfs_objects_project1) { create(:lfs_objects_project, project: project, lfs_object: lfs_object1) }
@@ -108,7 +108,7 @@ describe ProjectStatistics do
end
end
- describe '#update_storage_size' do
+ describe "#update_storage_size" do
it "sums all storage counters" do
statistics.update!(
repository_size: 2,
@@ -121,29 +121,29 @@ describe ProjectStatistics do
end
end
- describe '.increment_statistic' do
- it 'increases the statistic by that amount' do
+ describe ".increment_statistic" do
+ it "increases the statistic by that amount" do
expect { described_class.increment_statistic(project.id, :build_artifacts_size, 13) }
.to change { statistics.reload.build_artifacts_size }
.by(13)
end
- it 'increases also storage size by that amount' do
+ it "increases also storage size by that amount" do
expect { described_class.increment_statistic(project.id, :build_artifacts_size, 20) }
.to change { statistics.reload.storage_size }
.by(20)
end
- context 'when the amount is 0' do
- it 'does not execute a query' do
+ context "when the amount is 0" do
+ it "does not execute a query" do
project
expect { described_class.increment_statistic(project.id, :build_artifacts_size, 0) }
.not_to exceed_query_limit(0)
end
end
- context 'when using an invalid column' do
- it 'raises an error' do
+ context "when using an invalid column" do
+ it "raises an error" do
expect { described_class.increment_statistic(project.id, :id, 13) }
.to raise_error(ArgumentError, "Cannot increment attribute: id")
end
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index 3537dead5d1..97034c5e238 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -6,7 +6,7 @@ describe ProjectTeam do
let(:guest) { create(:user) }
let(:nonmember) { create(:user) }
- context 'personal project' do
+ context "personal project" do
let(:project) { create(:project) }
before do
@@ -15,14 +15,14 @@ describe ProjectTeam do
project.add_guest(guest)
end
- describe 'members collection' do
+ describe "members collection" do
it { expect(project.team.maintainers).to include(maintainer) }
it { expect(project.team.maintainers).not_to include(guest) }
it { expect(project.team.maintainers).not_to include(reporter) }
it { expect(project.team.maintainers).not_to include(nonmember) }
end
- describe 'access methods' do
+ describe "access methods" do
it { expect(project.team.maintainer?(maintainer)).to be_truthy }
it { expect(project.team.maintainer?(guest)).to be_falsey }
it { expect(project.team.maintainer?(reporter)).to be_falsey }
@@ -35,7 +35,7 @@ describe ProjectTeam do
end
end
- context 'group project' do
+ context "group project" do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
@@ -51,7 +51,7 @@ describe ProjectTeam do
project.add_guest(maintainer)
end
- describe 'members collection' do
+ describe "members collection" do
it { expect(project.team.reporters).to include(reporter) }
it { expect(project.team.maintainers).to include(maintainer) }
it { expect(project.team.maintainers).to include(guest) }
@@ -59,7 +59,7 @@ describe ProjectTeam do
it { expect(project.team.maintainers).not_to include(nonmember) }
end
- describe 'access methods' do
+ describe "access methods" do
it { expect(project.team.reporter?(reporter)).to be_truthy }
it { expect(project.team.maintainer?(maintainer)).to be_truthy }
it { expect(project.team.maintainer?(guest)).to be_truthy }
@@ -73,18 +73,18 @@ describe ProjectTeam do
end
end
- describe '#fetch_members' do
- context 'personal project' do
+ describe "#fetch_members" do
+ context "personal project" do
let(:project) { create(:project) }
- it 'returns project members' do
+ it "returns project members" do
user = create(:user)
project.add_guest(user)
expect(project.team.members).to contain_exactly(user, project.owner)
end
- it 'returns project members of a specified level' do
+ it "returns project members of a specified level" do
user = create(:user)
project.add_reporter(user)
@@ -92,7 +92,7 @@ describe ProjectTeam do
expect(project.team.reporters).to contain_exactly(user)
end
- it 'returns invited members of a group' do
+ it "returns invited members of a group" do
group_member = create(:group_member)
project.project_group_links.create!(
@@ -104,7 +104,7 @@ describe ProjectTeam do
.to contain_exactly(group_member.user, project.owner)
end
- it 'returns invited members of a group of a specified level' do
+ it "returns invited members of a group of a specified level" do
group_member = create(:group_member)
project.project_group_links.create!(
@@ -117,17 +117,17 @@ describe ProjectTeam do
end
end
- context 'group project' do
+ context "group project" do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
- it 'returns project members' do
+ it "returns project members" do
group_member = create(:group_member, group: group)
expect(project.team.members).to contain_exactly(group_member.user)
end
- it 'returns project members of a specified level' do
+ it "returns project members of a specified level" do
group_member = create(:group_member, :reporter, group: group)
expect(project.team.guests).to be_empty
@@ -136,8 +136,8 @@ describe ProjectTeam do
end
end
- describe '#find_member' do
- context 'personal project' do
+ describe "#find_member" do
+ context "personal project" do
let(:project) do
create(:project, :public, :access_requestable)
end
@@ -158,7 +158,7 @@ describe ProjectTeam do
it { expect(project.team.find_member(requester.id)).to be_nil }
end
- context 'group project' do
+ context "group project" do
let(:group) { create(:group, :access_requestable) }
let(:project) { create(:project, group: group) }
let(:requester) { create(:user) }
@@ -178,9 +178,9 @@ describe ProjectTeam do
end
end
- describe '#members_in_project_and_ancestors' do
- context 'group project' do
- it 'filters out users who are not members of the project' do
+ describe "#members_in_project_and_ancestors" do
+ context "group project" do
+ it "filters out users who are not members of the project" do
group = create(:group)
project = create(:project, group: group)
group_member = create(:group_member, group: group)
@@ -194,36 +194,36 @@ describe ProjectTeam do
end
describe "#human_max_access" do
- it 'returns Maintainer role' do
+ it "returns Maintainer role" do
user = create(:user)
group = create(:group)
project = create(:project, namespace: group)
group.add_maintainer(user)
- expect(project.team.human_max_access(user.id)).to eq 'Maintainer'
+ expect(project.team.human_max_access(user.id)).to eq "Maintainer"
end
- it 'returns Owner role' do
+ it "returns Owner role" do
user = create(:user)
group = create(:group)
project = create(:project, namespace: group)
group.add_owner(user)
- expect(project.team.human_max_access(user.id)).to eq 'Owner'
+ expect(project.team.human_max_access(user.id)).to eq "Owner"
end
end
- describe '#max_member_access' do
+ describe "#max_member_access" do
let(:requester) { create(:user) }
- context 'personal project' do
+ context "personal project" do
let(:project) do
create(:project, :public, :access_requestable)
end
- context 'when project is not shared with group' do
+ context "when project is not shared with group" do
before do
project.add_maintainer(maintainer)
project.add_reporter(reporter)
@@ -238,12 +238,13 @@ describe ProjectTeam do
it { expect(project.team.max_member_access(requester.id)).to eq(Gitlab::Access::NO_ACCESS) }
end
- context 'when project is shared with group' do
+ context "when project is shared with group" do
before do
group = create(:group)
project.project_group_links.create(
group: group,
- group_access: Gitlab::Access::DEVELOPER)
+ group_access: Gitlab::Access::DEVELOPER
+ )
group.add_maintainer(maintainer)
group.add_reporter(reporter)
@@ -254,7 +255,7 @@ describe ProjectTeam do
it { expect(project.team.max_member_access(nonmember.id)).to eq(Gitlab::Access::NO_ACCESS) }
it { expect(project.team.max_member_access(requester.id)).to eq(Gitlab::Access::NO_ACCESS) }
- context 'but share_with_group_lock is true' do
+ context "but share_with_group_lock is true" do
before do
project.namespace.update(share_with_group_lock: true)
end
@@ -265,7 +266,7 @@ describe ProjectTeam do
end
end
- context 'group project' do
+ context "group project" do
let(:group) { create(:group, :access_requestable) }
let!(:project) do
create(:project, group: group)
@@ -286,7 +287,7 @@ describe ProjectTeam do
end
end
- describe '#member?' do
+ describe "#member?" do
let(:group) { create(:group) }
let(:developer) { create(:user) }
let(:maintainer) { create(:user) }
@@ -312,27 +313,27 @@ describe ProjectTeam do
create(:project_group_link, project: shared_project, group: group)
end
- it 'returns false for no user' do
+ it "returns false for no user" do
expect(personal_project.team.member?(nil)).to be(false)
end
- it 'returns true for personal projects of the user' do
+ it "returns true for personal projects of the user" do
expect(personal_project.team.member?(developer)).to be(true)
end
- it 'returns true for projects of groups the user is a member of' do
+ it "returns true for projects of groups the user is a member of" do
expect(group_project.team.member?(developer)).to be(true)
end
- it 'returns true for projects for which the user is a member of' do
+ it "returns true for projects for which the user is a member of" do
expect(members_project.team.member?(developer)).to be(true)
end
- it 'returns true for projects shared on a group the user is a member of' do
+ it "returns true for projects shared on a group the user is a member of" do
expect(shared_project.team.member?(developer)).to be(true)
end
- it 'checks for the correct minimum level access' do
+ it "checks for the correct minimum level access" do
expect(group_project.team.member?(developer, Gitlab::Access::MAINTAINER)).to be(false)
expect(group_project.team.member?(maintainer, Gitlab::Access::MAINTAINER)).to be(true)
expect(members_project.team.member?(developer, Gitlab::Access::MAINTAINER)).to be(false)
@@ -344,7 +345,7 @@ describe ProjectTeam do
end
end
- shared_examples 'max member access for users' do
+ shared_examples "max member access for users" do
let(:project) { create(:project) }
let(:group) { create(:group) }
let(:second_group) { create(:group) }
@@ -373,7 +374,7 @@ describe ProjectTeam do
guest.id => Gitlab::Access::GUEST,
group_developer.id => Gitlab::Access::DEVELOPER,
second_developer.id => Gitlab::Access::MAINTAINER,
- user_without_access.id => Gitlab::Access::NO_ACCESS
+ user_without_access.id => Gitlab::Access::NO_ACCESS,
}
end
@@ -400,20 +401,20 @@ describe ProjectTeam do
second_group.add_maintainer(second_developer)
end
- it 'returns correct roles for different users' do
+ it "returns correct roles for different users" do
expect(project.team.max_member_access_for_user_ids(users)).to eq(expected)
end
end
- describe '#max_member_access_for_user_ids' do
- context 'with RequestStore enabled', :request_store do
- include_examples 'max member access for users'
+ describe "#max_member_access_for_user_ids" do
+ context "with RequestStore enabled", :request_store do
+ include_examples "max member access for users"
def access_levels(users)
project.team.max_member_access_for_user_ids(users)
end
- it 'does not perform extra queries when asked for users who have already been found' do
+ it "does not perform extra queries when asked for users who have already been found" do
access_levels(users)
expect { access_levels(users) }.not_to exceed_query_limit(0)
@@ -421,7 +422,7 @@ describe ProjectTeam do
expect(access_levels(users)).to eq(expected)
end
- it 'only requests the extra users when uncached users are passed' do
+ it "only requests the extra users when uncached users are passed" do
new_user = create(:user)
second_new_user = create(:user)
all_users = users + [new_user.id, second_new_user.id]
@@ -441,8 +442,8 @@ describe ProjectTeam do
end
end
- context 'with RequestStore disabled' do
- include_examples 'max member access for users'
+ context "with RequestStore disabled" do
+ include_examples "max member access for users"
end
end
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index 3ccc706edf2..ac697be636b 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -1,4 +1,3 @@
-# coding: utf-8
require "spec_helper"
describe ProjectWiki do
@@ -7,7 +6,7 @@ describe ProjectWiki do
let(:repository) { project.repository }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:project_wiki) { described_class.new(project, user) }
- let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + '.git', 'foo', 'group/project.wiki') }
+ let(:raw_repository) { Gitlab::Git::Repository.new(project.repository_storage, subject.disk_path + ".git", "foo", "group/project.wiki") }
let(:commit) { project_wiki.repository.head_commit }
subject { project_wiki }
@@ -17,16 +16,16 @@ describe ProjectWiki do
describe "#full_path" do
it "returns the project path with namespace with the .wiki extension" do
- expect(subject.full_path).to eq(project.full_path + '.wiki')
+ expect(subject.full_path).to eq(project.full_path + ".wiki")
end
- it 'returns the same value as #full_path' do
+ it "returns the same value as #full_path" do
expect(subject.full_path).to eq(subject.full_path)
end
end
- describe '#web_url' do
- it 'returns the full web URL to the wiki' do
+ describe "#web_url" do
+ it "returns the full web URL to the wiki" do
expect(subject.web_url).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}/wikis/home")
end
end
@@ -46,11 +45,11 @@ describe ProjectWiki do
describe "#http_url_to_repo" do
let(:project) { create :project }
- it 'returns the full http url to the repo' do
+ it "returns the full http url to the repo" do
expected_url = "#{Gitlab.config.gitlab.url}/#{subject.full_path}.git"
expect(project_wiki.http_url_to_repo).to eq(expected_url)
- expect(project_wiki.http_url_to_repo).not_to include('@')
+ expect(project_wiki.http_url_to_repo).not_to include("@")
end
end
@@ -84,7 +83,7 @@ describe ProjectWiki do
describe "#empty?" do
context "when the wiki repository is empty" do
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_truthy }
end
@@ -96,12 +95,12 @@ describe ProjectWiki do
project_wiki.create_page("another-page", "This is another page")
end
- describe '#empty?' do
+ describe "#empty?" do
subject { super().empty? }
it { is_expected.to be_falsey }
# Re-enable this when https://gitlab.com/gitlab-org/gitaly/issues/1204 is fixed
- xit 'only instantiates a Wiki page once' do
+ xit "only instantiates a Wiki page once" do
expect(WikiPage).to receive(:new).once.and_call_original
subject
@@ -157,7 +156,7 @@ describe ProjectWiki do
expect(page).to be_a WikiPage
end
- context 'pages with multibyte-character title' do
+ context "pages with multibyte-character title" do
before do
create_page("autre pagé", "C'est un génial Gollum Wiki")
end
@@ -168,7 +167,7 @@ describe ProjectWiki do
end
end
- context 'pages with invalidly-encoded content' do
+ context "pages with invalidly-encoded content" do
before do
create_page("encoding is fun", "f\xFCr".b)
end
@@ -180,51 +179,51 @@ describe ProjectWiki do
end
end
- describe '#find_sidebar' do
+ describe "#find_sidebar" do
before do
- create_page(described_class::SIDEBAR, 'This is an awesome Sidebar')
+ create_page(described_class::SIDEBAR, "This is an awesome Sidebar")
end
after do
subject.pages.each { |page| destroy_page(page.page) }
end
- it 'finds the page defined as _sidebar' do
- page = subject.find_page('_sidebar')
+ it "finds the page defined as _sidebar" do
+ page = subject.find_page("_sidebar")
- expect(page.content).to eq('This is an awesome Sidebar')
+ expect(page.content).to eq("This is an awesome Sidebar")
end
end
- describe '#find_file' do
- let(:image) { File.open(Rails.root.join('spec', 'fixtures', 'big-image.png')) }
+ describe "#find_file" do
+ let(:image) { File.open(Rails.root.join("spec", "fixtures", "big-image.png")) }
before do
subject.wiki # Make sure the wiki repo exists
- repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
subject.repository.path_to_repo
- end
+ }
- BareRepoOperations.new(repo_path).commit_file(image, 'image.png')
+ BareRepoOperations.new(repo_path).commit_file(image, "image.png")
end
- it 'returns the latest version of the file if it exists' do
- file = subject.find_file('image.png')
- expect(file.mime_type).to eq('image/png')
+ it "returns the latest version of the file if it exists" do
+ file = subject.find_file("image.png")
+ expect(file.mime_type).to eq("image/png")
end
- it 'returns nil if the page does not exist' do
- expect(subject.find_file('non-existent')).to eq(nil)
+ it "returns nil if the page does not exist" do
+ expect(subject.find_file("non-existent")).to eq(nil)
end
- it 'returns a Gitlab::Git::WikiFile instance' do
- file = subject.find_file('image.png')
+ it "returns a Gitlab::Git::WikiFile instance" do
+ file = subject.find_file("image.png")
expect(file).to be_a Gitlab::Git::WikiFile
end
- it 'returns the whole file' do
- file = subject.find_file('image.png')
+ it "returns the whole file" do
+ file = subject.find_file("image.png")
image.rewind
expect(file.raw_data.b).to eq(image.read.b)
@@ -256,16 +255,16 @@ describe ProjectWiki do
expect(subject.pages.first.page.version.message).to eq("commit message")
end
- it 'sets the correct commit email' do
- subject.create_page('test page', 'content')
+ it "sets the correct commit email" do
+ subject.create_page("test page", "content")
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
- it 'updates project activity' do
- subject.create_page('Test Page', 'This is content')
+ it "updates project activity" do
+ subject.create_page("Test Page", "This is content")
project.reload
@@ -299,18 +298,18 @@ describe ProjectWiki do
expect(@page.version.message).to eq("updated page")
end
- it 'sets the correct commit email' do
+ it "sets the correct commit email" do
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
- it 'updates project activity' do
+ it "updates project activity" do
subject.update_page(
@gitlab_git_wiki_page,
- content: 'Yet more content',
+ content: "Yet more content",
format: :markdown,
- message: 'Updated page again'
+ message: "Updated page again"
)
project.reload
@@ -331,7 +330,7 @@ describe ProjectWiki do
expect(subject.pages.count).to eq(0)
end
- it 'sets the correct commit email' do
+ it "sets the correct commit email" do
subject.delete_page(@page)
expect(user.commit_email).not_to eq(user.email)
@@ -339,7 +338,7 @@ describe ProjectWiki do
expect(commit.committer_email).to eq(user.commit_email)
end
- it 'updates project activity' do
+ it "updates project activity" do
subject.delete_page(@page)
project.reload
@@ -349,10 +348,10 @@ describe ProjectWiki do
end
end
- describe '#create_repo!' do
+ describe "#create_repo!" do
let(:project) { create(:project) }
- it 'creates a repository' do
+ it "creates a repository" do
expect(raw_repository.exists?).to eq(false)
expect(subject.repository).to receive(:after_create)
@@ -362,10 +361,10 @@ describe ProjectWiki do
end
end
- describe '#ensure_repository' do
+ describe "#ensure_repository" do
let(:project) { create(:project) }
- it 'creates the repository if it not exist' do
+ it "creates the repository if it not exist" do
expect(raw_repository.exists?).to eq(false)
expect(subject).to receive(:create_repo!).and_call_original
@@ -374,7 +373,7 @@ describe ProjectWiki do
expect(raw_repository.exists?).to eq(true)
end
- it 'does not create the repository if it exists' do
+ it "does not create the repository if it exists" do
subject.wiki
expect(raw_repository.exists?).to eq(true)
@@ -384,8 +383,8 @@ describe ProjectWiki do
end
end
- describe '#hook_attrs' do
- it 'returns a hash with values' do
+ describe "#hook_attrs" do
+ it "returns a hash with values" do
expect(subject.hook_attrs).to be_a Hash
expect(subject.hook_attrs.keys).to contain_exactly(:web_url, :git_ssh_url, :git_http_url, :path_with_namespace, :default_branch)
end
@@ -395,7 +394,7 @@ describe ProjectWiki do
def create_temp_repo(path)
FileUtils.mkdir_p path
- system(*%W(#{Gitlab.config.git.bin_path} init --quiet --bare -- #{path}))
+ system(Gitlab.config.git.bin_path.to_s, "init", "--quiet", "--bare", "--", path.to_s)
end
def remove_temp_repo(path)
diff --git a/spec/models/prometheus_metric_spec.rb b/spec/models/prometheus_metric_spec.rb
index 3610408c138..08d1c761f39 100644
--- a/spec/models/prometheus_metric_spec.rb
+++ b/spec/models/prometheus_metric_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe PrometheusMetric do
subject { build(:prometheus_metric) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
it { is_expected.to belong_to(:project) }
it { is_expected.to validate_presence_of(:title) }
it { is_expected.to validate_presence_of(:query) }
it { is_expected.to validate_presence_of(:group) }
- describe 'common metrics' do
+ describe "common metrics" do
using RSpec::Parameterized::TableSyntax
where(:common, :with_project, :result) do
@@ -32,12 +32,12 @@ describe PrometheusMetric do
end
end
- describe '#query_series' do
+ describe "#query_series" do
using RSpec::Parameterized::TableSyntax
where(:legend, :type) do
- 'Some other legend' | NilClass
- 'Status Code' | Array
+ "Some other legend" | NilClass
+ "Status Code" | Array
end
with_them do
@@ -49,8 +49,8 @@ describe PrometheusMetric do
end
end
- describe '#group_title' do
- shared_examples 'group_title' do |group, title|
+ describe "#group_title" do
+ shared_examples "group_title" do |group, title|
subject { build(:prometheus_metric, group: group).group_title }
it "returns text #{title} for group #{group}" do
@@ -58,18 +58,18 @@ describe PrometheusMetric do
end
end
- it_behaves_like 'group_title', :nginx_ingress_vts, 'Response metrics (NGINX Ingress VTS)'
- it_behaves_like 'group_title', :nginx_ingress, 'Response metrics (NGINX Ingress)'
- it_behaves_like 'group_title', :ha_proxy, 'Response metrics (HA Proxy)'
- it_behaves_like 'group_title', :aws_elb, 'Response metrics (AWS ELB)'
- it_behaves_like 'group_title', :nginx, 'Response metrics (NGINX)'
- it_behaves_like 'group_title', :kubernetes, 'System metrics (Kubernetes)'
- it_behaves_like 'group_title', :business, 'Business metrics (Custom)'
- it_behaves_like 'group_title', :response, 'Response metrics (Custom)'
- it_behaves_like 'group_title', :system, 'System metrics (Custom)'
+ it_behaves_like "group_title", :nginx_ingress_vts, "Response metrics (NGINX Ingress VTS)"
+ it_behaves_like "group_title", :nginx_ingress, "Response metrics (NGINX Ingress)"
+ it_behaves_like "group_title", :ha_proxy, "Response metrics (HA Proxy)"
+ it_behaves_like "group_title", :aws_elb, "Response metrics (AWS ELB)"
+ it_behaves_like "group_title", :nginx, "Response metrics (NGINX)"
+ it_behaves_like "group_title", :kubernetes, "System metrics (Kubernetes)"
+ it_behaves_like "group_title", :business, "Business metrics (Custom)"
+ it_behaves_like "group_title", :response, "Response metrics (Custom)"
+ it_behaves_like "group_title", :system, "System metrics (Custom)"
end
- describe '#priority' do
+ describe "#priority" do
using RSpec::Parameterized::TableSyntax
where(:group, :priority) do
@@ -93,19 +93,19 @@ describe PrometheusMetric do
end
end
- describe '#required_metrics' do
+ describe "#required_metrics" do
using RSpec::Parameterized::TableSyntax
where(:group, :required_metrics) do
- :nginx_ingress_vts | %w(nginx_upstream_responses_total nginx_upstream_response_msecs_avg)
- :nginx_ingress | %w(nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum)
- :ha_proxy | %w(haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total)
- :aws_elb | %w(aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum)
- :nginx | %w(nginx_server_requests nginx_server_requestMsec)
- :kubernetes | %w(container_memory_usage_bytes container_cpu_usage_seconds_total)
- :business | %w()
- :response | %w()
- :system | %w()
+ :nginx_ingress_vts | %w[nginx_upstream_responses_total nginx_upstream_response_msecs_avg]
+ :nginx_ingress | %w[nginx_ingress_controller_requests nginx_ingress_controller_ingress_upstream_latency_seconds_sum]
+ :ha_proxy | %w[haproxy_frontend_http_requests_total haproxy_frontend_http_responses_total]
+ :aws_elb | %w[aws_elb_request_count_sum aws_elb_latency_average aws_elb_httpcode_backend_5_xx_sum]
+ :nginx | %w[nginx_server_requests nginx_server_requestMsec]
+ :kubernetes | %w[container_memory_usage_bytes container_cpu_usage_seconds_total]
+ :business | %w[]
+ :response | %w[]
+ :system | %w[]
end
with_them do
@@ -117,34 +117,34 @@ describe PrometheusMetric do
end
end
- describe '#to_query_metric' do
- it 'converts to queryable metric object' do
+ describe "#to_query_metric" do
+ it "converts to queryable metric object" do
expect(subject.to_query_metric).to be_instance_of(Gitlab::Prometheus::Metric)
end
- it 'queryable metric object has title' do
+ it "queryable metric object has title" do
expect(subject.to_query_metric.title).to eq(subject.title)
end
- it 'queryable metric object has y_label' do
+ it "queryable metric object has y_label" do
expect(subject.to_query_metric.y_label).to eq(subject.y_label)
end
- it 'queryable metric has no required_metric' do
+ it "queryable metric has no required_metric" do
expect(subject.to_query_metric.required_metrics).to eq([])
end
- it 'queryable metric has weight 0' do
+ it "queryable metric has weight 0" do
expect(subject.to_query_metric.weight).to eq(0)
end
- it 'queryable metrics has query description' do
+ it "queryable metrics has query description" do
queries = [
{
query_range: subject.query,
unit: subject.unit,
- label: subject.legend
- }
+ label: subject.legend,
+ },
]
expect(subject.to_query_metric.queries).to eq(queries)
diff --git a/spec/models/protectable_dropdown_spec.rb b/spec/models/protectable_dropdown_spec.rb
index d4433a88a15..a498366638b 100644
--- a/spec/models/protectable_dropdown_spec.rb
+++ b/spec/models/protectable_dropdown_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectableDropdown do
let(:project) { create(:project, :repository) }
let(:subject) { described_class.new(project, :branches) }
- describe 'initialize' do
- it 'raises ArgumentError for invalid ref type' do
+ describe "initialize" do
+ it "raises ArgumentError for invalid ref type" do
expect { described_class.new(double, :foo) }
.to raise_error(ArgumentError, "invalid ref type `foo`")
end
end
- describe '#protectable_ref_names' do
+ describe "#protectable_ref_names" do
before do
- project.protected_branches.create(name: 'master')
+ project.protected_branches.create(name: "master")
end
- it { expect(subject.protectable_ref_names).to include('feature') }
- it { expect(subject.protectable_ref_names).not_to include('master') }
+ it { expect(subject.protectable_ref_names).to include("feature") }
+ it { expect(subject.protectable_ref_names).not_to include("master") }
it "includes branches matching a protected branch wildcard" do
- expect(subject.protectable_ref_names).to include('feature')
+ expect(subject.protectable_ref_names).to include("feature")
- create(:protected_branch, name: 'feat*', project: project)
+ create(:protected_branch, name: "feat*", project: project)
subject = described_class.new(project.reload, :branches)
- expect(subject.protectable_ref_names).to include('feature')
+ expect(subject.protectable_ref_names).to include("feature")
end
end
end
diff --git a/spec/models/protected_branch/merge_access_level_spec.rb b/spec/models/protected_branch/merge_access_level_spec.rb
index 612e4a0e332..8ce021800b6 100644
--- a/spec/models/protected_branch/merge_access_level_spec.rb
+++ b/spec/models/protected_branch/merge_access_level_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranch::MergeAccessLevel do
it { is_expected.to validate_inclusion_of(:access_level).in_array([Gitlab::Access::MAINTAINER, Gitlab::Access::DEVELOPER, Gitlab::Access::NO_ACCESS]) }
diff --git a/spec/models/protected_branch/push_access_level_spec.rb b/spec/models/protected_branch/push_access_level_spec.rb
index 9ccdc22fd41..65af1b6fd44 100644
--- a/spec/models/protected_branch/push_access_level_spec.rb
+++ b/spec/models/protected_branch/push_access_level_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranch::PushAccessLevel do
it { is_expected.to validate_inclusion_of(:access_level).in_array([Gitlab::Access::MAINTAINER, Gitlab::Access::DEVELOPER, Gitlab::Access::NO_ACCESS]) }
diff --git a/spec/models/protected_branch_spec.rb b/spec/models/protected_branch_spec.rb
index 4c677200ae2..3efe1baf4f6 100644
--- a/spec/models/protected_branch_spec.rb
+++ b/spec/models/protected_branch_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranch do
subject { build_stubbed(:protected_branch) }
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'Validation' do
+ describe "Validation" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:name) }
end
@@ -135,58 +135,58 @@ describe ProtectedBranch do
end
end
- describe '#protected?' do
- context 'existing project' do
+ describe "#protected?" do
+ context "existing project" do
let(:project) { create(:project, :repository) }
- it 'returns true when the branch matches a protected branch via direct match' do
+ it "returns true when the branch matches a protected branch via direct match" do
create(:protected_branch, project: project, name: "foo")
- expect(described_class.protected?(project, 'foo')).to eq(true)
+ expect(described_class.protected?(project, "foo")).to eq(true)
end
- it 'returns true when the branch matches a protected branch via wildcard match' do
+ it "returns true when the branch matches a protected branch via wildcard match" do
create(:protected_branch, project: project, name: "production/*")
- expect(described_class.protected?(project, 'production/some-branch')).to eq(true)
+ expect(described_class.protected?(project, "production/some-branch")).to eq(true)
end
- it 'returns false when the branch does not match a protected branch via direct match' do
- expect(described_class.protected?(project, 'foo')).to eq(false)
+ it "returns false when the branch does not match a protected branch via direct match" do
+ expect(described_class.protected?(project, "foo")).to eq(false)
end
- it 'returns false when the branch does not match a protected branch via wildcard match' do
+ it "returns false when the branch does not match a protected branch via wildcard match" do
create(:protected_branch, project: project, name: "production/*")
- expect(described_class.protected?(project, 'staging/some-branch')).to eq(false)
+ expect(described_class.protected?(project, "staging/some-branch")).to eq(false)
end
end
context "new project" do
let(:project) { create(:project) }
- it 'returns false when default_protected_branch is unprotected' do
+ it "returns false when default_protected_branch is unprotected" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_NONE)
- expect(described_class.protected?(project, 'master')).to be false
+ expect(described_class.protected?(project, "master")).to be false
end
- it 'returns false when default_protected_branch lets developers push' do
+ it "returns false when default_protected_branch lets developers push" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
- expect(described_class.protected?(project, 'master')).to be false
+ expect(described_class.protected?(project, "master")).to be false
end
- it 'returns true when default_branch_protection does not let developers push but let developer merge branches' do
+ 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(described_class.protected?(project, 'master')).to be true
+ expect(described_class.protected?(project, "master")).to be true
end
- it 'returns true when default_branch_protection is in full protection' do
+ it "returns true when default_branch_protection is in full protection" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_FULL)
- expect(described_class.protected?(project, 'master')).to be true
+ expect(described_class.protected?(project, "master")).to be true
end
end
end
diff --git a/spec/models/protected_tag_spec.rb b/spec/models/protected_tag_spec.rb
index e5a0f6ec23f..f88127904fb 100644
--- a/spec/models/protected_tag_spec.rb
+++ b/spec/models/protected_tag_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedTag do
- describe 'Associations' do
+ describe "Associations" do
it { is_expected.to belong_to(:project) }
end
- describe 'Validation' do
+ describe "Validation" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:name) }
end
diff --git a/spec/models/push_event_payload_spec.rb b/spec/models/push_event_payload_spec.rb
index 69a4922b6fd..29c1b226134 100644
--- a/spec/models/push_event_payload_spec.rb
+++ b/spec/models/push_event_payload_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe PushEventPayload do
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'saving payloads' do
- it 'does not allow commit messages longer than 70 characters' do
+ describe "saving payloads" do
+ it "does not allow commit messages longer than 70 characters" do
event = create(:push_event)
payload = build(:push_event_payload, event: event)
expect(payload).to be_valid
- payload.commit_title = 'a' * 100
+ payload.commit_title = "a" * 100
expect(payload).not_to be_valid
end
diff --git a/spec/models/push_event_spec.rb b/spec/models/push_event_spec.rb
index bfe7a30b96a..65719bea80b 100644
--- a/spec/models/push_event_spec.rb
+++ b/spec/models/push_event_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PushEvent do
let(:payload) { PushEventPayload.new }
@@ -11,7 +11,7 @@ describe PushEvent do
event
end
- describe '.created_or_pushed' do
+ describe ".created_or_pushed" do
let(:event1) { create(:push_event) }
let(:event2) { create(:push_event) }
let(:event3) { create(:push_event) }
@@ -24,20 +24,20 @@ describe PushEvent do
let(:relation) { described_class.created_or_pushed }
- it 'includes events for pushing to existing refs' do
+ it "includes events for pushing to existing refs" do
expect(relation).to include(event1)
end
- it 'includes events for creating new refs' do
+ it "includes events for creating new refs" do
expect(relation).to include(event2)
end
- it 'does not include events for removing refs' do
+ it "does not include events for removing refs" do
expect(relation).not_to include(event3)
end
end
- describe '.branch_events' do
+ describe ".branch_events" do
let(:event1) { create(:push_event) }
let(:event2) { create(:push_event) }
@@ -48,16 +48,16 @@ describe PushEvent do
let(:relation) { described_class.branch_events }
- it 'includes events for branches' do
+ it "includes events for branches" do
expect(relation).to include(event1)
end
- it 'does not include events for tags' do
+ it "does not include events for tags" do
expect(relation).not_to include(event2)
end
end
- describe '.without_existing_merge_requests' do
+ describe ".without_existing_merge_requests" do
let(:project) { create(:project, :repository) }
let(:event1) { create(:push_event, project: project) }
let(:event2) { create(:push_event, project: project) }
@@ -66,237 +66,237 @@ describe PushEvent do
let(:event5) { create(:push_event, project: project) }
before do
- create(:push_event_payload, event: event1, ref: 'foo', action: :created)
- create(:push_event_payload, event: event2, ref: 'bar', action: :created)
- create(:push_event_payload, event: event3, ref: 'qux', action: :created)
- create(:push_event_payload, event: event4, ref: 'baz', action: :removed)
- create(:push_event_payload, event: event5, ref: 'baz', ref_type: :tag)
+ create(:push_event_payload, event: event1, ref: "foo", action: :created)
+ create(:push_event_payload, event: event2, ref: "bar", action: :created)
+ create(:push_event_payload, event: event3, ref: "qux", action: :created)
+ create(:push_event_payload, event: event4, ref: "baz", action: :removed)
+ create(:push_event_payload, event: event5, ref: "baz", ref_type: :tag)
- project.repository.create_branch('bar', 'master')
+ project.repository.create_branch("bar", "master")
create(
:merge_request,
source_project: project,
target_project: project,
- source_branch: 'bar'
+ source_branch: "bar"
)
- project.repository.create_branch('qux', 'master')
+ project.repository.create_branch("qux", "master")
create(
:merge_request,
:closed,
source_project: project,
target_project: project,
- source_branch: 'qux'
+ source_branch: "qux"
)
end
let(:relation) { described_class.without_existing_merge_requests }
- it 'includes events that do not have a corresponding merge request' do
+ it "includes events that do not have a corresponding merge request" do
expect(relation).to include(event1)
end
- it 'does not include events that have a corresponding open merge request' do
+ it "does not include events that have a corresponding open merge request" do
expect(relation).not_to include(event2)
end
- it 'includes events that has corresponding closed/merged merge requests' do
+ it "includes events that has corresponding closed/merged merge requests" do
expect(relation).to include(event3)
end
- it 'does not include events for removed refs' do
+ it "does not include events for removed refs" do
expect(relation).not_to include(event4)
end
- it 'does not include events for pushing to tags' do
+ it "does not include events for pushing to tags" do
expect(relation).not_to include(event5)
end
end
- describe '.sti_name' do
- it 'returns Event::PUSHED' do
+ describe ".sti_name" do
+ it "returns Event::PUSHED" do
expect(described_class.sti_name).to eq(Event::PUSHED)
end
end
- describe '#push?' do
- it 'returns true' do
+ describe "#push?" do
+ it "returns true" do
expect(event).to be_push
end
end
- describe '#push_with_commits?' do
- it 'returns true when both the first and last commit are present' do
- allow(event).to receive(:commit_from).and_return('123')
- allow(event).to receive(:commit_to).and_return('456')
+ describe "#push_with_commits?" do
+ it "returns true when both the first and last commit are present" do
+ allow(event).to receive(:commit_from).and_return("123")
+ allow(event).to receive(:commit_to).and_return("456")
expect(event).to be_push_with_commits
end
- it 'returns false when the first commit is missing' do
- allow(event).to receive(:commit_to).and_return('456')
+ it "returns false when the first commit is missing" do
+ allow(event).to receive(:commit_to).and_return("456")
expect(event).not_to be_push_with_commits
end
- it 'returns false when the last commit is missing' do
- allow(event).to receive(:commit_from).and_return('123')
+ it "returns false when the last commit is missing" do
+ allow(event).to receive(:commit_from).and_return("123")
expect(event).not_to be_push_with_commits
end
end
- describe '#tag?' do
- it 'returns true when pushing to a tag' do
+ describe "#tag?" do
+ it "returns true when pushing to a tag" do
allow(payload).to receive(:tag?).and_return(true)
expect(event).to be_tag
end
- it 'returns false when pushing to a branch' do
+ it "returns false when pushing to a branch" do
allow(payload).to receive(:tag?).and_return(false)
expect(event).not_to be_tag
end
end
- describe '#branch?' do
- it 'returns true when pushing to a branch' do
+ describe "#branch?" do
+ it "returns true when pushing to a branch" do
allow(payload).to receive(:branch?).and_return(true)
expect(event).to be_branch
end
- it 'returns false when pushing to a tag' do
+ it "returns false when pushing to a tag" do
allow(payload).to receive(:branch?).and_return(false)
expect(event).not_to be_branch
end
end
- describe '#valid_push?' do
- it 'returns true if a ref exists' do
- allow(payload).to receive(:ref).and_return('master')
+ describe "#valid_push?" do
+ it "returns true if a ref exists" do
+ allow(payload).to receive(:ref).and_return("master")
expect(event).to be_valid_push
end
- it 'returns false when no ref is present' do
+ it "returns false when no ref is present" do
expect(event).not_to be_valid_push
end
end
- describe '#new_ref?' do
- it 'returns true when pushing a new ref' do
+ describe "#new_ref?" do
+ it "returns true when pushing a new ref" do
allow(payload).to receive(:created?).and_return(true)
expect(event).to be_new_ref
end
- it 'returns false when pushing to an existing ref' do
+ it "returns false when pushing to an existing ref" do
allow(payload).to receive(:created?).and_return(false)
expect(event).not_to be_new_ref
end
end
- describe '#rm_ref?' do
- it 'returns true when removing an existing ref' do
+ describe "#rm_ref?" do
+ it "returns true when removing an existing ref" do
allow(payload).to receive(:removed?).and_return(true)
expect(event).to be_rm_ref
end
- it 'returns false when pushing to an existing ref' do
+ it "returns false when pushing to an existing ref" do
allow(payload).to receive(:removed?).and_return(false)
expect(event).not_to be_rm_ref
end
end
- describe '#commit_from' do
- it 'returns the first commit SHA' do
- allow(payload).to receive(:commit_from).and_return('123')
+ describe "#commit_from" do
+ it "returns the first commit SHA" do
+ allow(payload).to receive(:commit_from).and_return("123")
- expect(event.commit_from).to eq('123')
+ expect(event.commit_from).to eq("123")
end
end
- describe '#commit_to' do
- it 'returns the last commit SHA' do
- allow(payload).to receive(:commit_to).and_return('123')
+ describe "#commit_to" do
+ it "returns the last commit SHA" do
+ allow(payload).to receive(:commit_to).and_return("123")
- expect(event.commit_to).to eq('123')
+ expect(event.commit_to).to eq("123")
end
end
- describe '#ref_name' do
- it 'returns the name of the ref' do
- allow(payload).to receive(:ref).and_return('master')
+ describe "#ref_name" do
+ it "returns the name of the ref" do
+ allow(payload).to receive(:ref).and_return("master")
- expect(event.ref_name).to eq('master')
+ expect(event.ref_name).to eq("master")
end
end
- describe '#ref_type' do
- it 'returns the type of the ref' do
- allow(payload).to receive(:ref_type).and_return('branch')
+ describe "#ref_type" do
+ it "returns the type of the ref" do
+ allow(payload).to receive(:ref_type).and_return("branch")
- expect(event.ref_type).to eq('branch')
+ expect(event.ref_type).to eq("branch")
end
end
- describe '#branch_name' do
- it 'returns the name of the branch' do
- allow(payload).to receive(:ref).and_return('master')
+ describe "#branch_name" do
+ it "returns the name of the branch" do
+ allow(payload).to receive(:ref).and_return("master")
- expect(event.branch_name).to eq('master')
+ expect(event.branch_name).to eq("master")
end
end
- describe '#tag_name' do
- it 'returns the name of the tag' do
- allow(payload).to receive(:ref).and_return('1.2')
+ describe "#tag_name" do
+ it "returns the name of the tag" do
+ allow(payload).to receive(:ref).and_return("1.2")
- expect(event.tag_name).to eq('1.2')
+ expect(event.tag_name).to eq("1.2")
end
end
- describe '#commit_title' do
- it 'returns the commit message' do
- allow(payload).to receive(:commit_title).and_return('foo')
+ describe "#commit_title" do
+ it "returns the commit message" do
+ allow(payload).to receive(:commit_title).and_return("foo")
- expect(event.commit_title).to eq('foo')
+ expect(event.commit_title).to eq("foo")
end
end
- describe '#commit_id' do
- it 'returns the SHA of the last commit if present' do
- allow(event).to receive(:commit_to).and_return('123')
+ describe "#commit_id" do
+ it "returns the SHA of the last commit if present" do
+ allow(event).to receive(:commit_to).and_return("123")
- expect(event.commit_id).to eq('123')
+ expect(event.commit_id).to eq("123")
end
- it 'returns the SHA of the first commit if the last commit is not present' do
+ it "returns the SHA of the first commit if the last commit is not present" do
allow(event).to receive(:commit_to).and_return(nil)
- allow(event).to receive(:commit_from).and_return('123')
+ allow(event).to receive(:commit_from).and_return("123")
- expect(event.commit_id).to eq('123')
+ expect(event.commit_id).to eq("123")
end
end
- describe '#commits_count' do
- it 'returns the number of commits' do
+ describe "#commits_count" do
+ it "returns the number of commits" do
allow(payload).to receive(:commit_count).and_return(1)
expect(event.commits_count).to eq(1)
end
end
- describe '#validate_push_action' do
- it 'adds an error when the action is not PUSHED' do
+ describe "#validate_push_action" do
+ it "adds an error when the action is not PUSHED" do
event.action = Event::CREATED
event.validate_push_action
diff --git a/spec/models/redirect_route_spec.rb b/spec/models/redirect_route_spec.rb
index 106ae59af29..0d4146448a9 100644
--- a/spec/models/redirect_route_spec.rb
+++ b/spec/models/redirect_route_spec.rb
@@ -1,34 +1,34 @@
-require 'rails_helper'
+require "rails_helper"
describe RedirectRoute do
let(:group) { create(:group) }
- let!(:redirect_route) { group.redirect_routes.create(path: 'gitlabb') }
+ let!(:redirect_route) { group.redirect_routes.create(path: "gitlabb") }
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:source) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_presence_of(:path) }
it { is_expected.to validate_uniqueness_of(:path).case_insensitive }
end
- describe '.matching_path_and_descendants' do
- let!(:redirect2) { group.redirect_routes.create(path: 'gitlabb/test') }
- let!(:redirect3) { group.redirect_routes.create(path: 'gitlabb/test/foo') }
- let!(:redirect4) { group.redirect_routes.create(path: 'gitlabb/test/foo/bar') }
- let!(:redirect5) { group.redirect_routes.create(path: 'gitlabb/test/baz') }
+ describe ".matching_path_and_descendants" do
+ let!(:redirect2) { group.redirect_routes.create(path: "gitlabb/test") }
+ let!(:redirect3) { group.redirect_routes.create(path: "gitlabb/test/foo") }
+ let!(:redirect4) { group.redirect_routes.create(path: "gitlabb/test/foo/bar") }
+ let!(:redirect5) { group.redirect_routes.create(path: "gitlabb/test/baz") }
- context 'when the redirect route matches with same casing' do
- it 'returns correct routes' do
- expect(described_class.matching_path_and_descendants('gitlabb/test')).to match_array([redirect2, redirect3, redirect4, redirect5])
+ context "when the redirect route matches with same casing" do
+ it "returns correct routes" do
+ expect(described_class.matching_path_and_descendants("gitlabb/test")).to match_array([redirect2, redirect3, redirect4, redirect5])
end
end
- context 'when the redirect route matches with different casing' do
- it 'returns correct routes' do
- expect(described_class.matching_path_and_descendants('GitLABB/test')).to match_array([redirect2, redirect3, redirect4, redirect5])
+ context "when the redirect route matches with different casing" do
+ it "returns correct routes" do
+ expect(described_class.matching_path_and_descendants("GitLABB/test")).to match_array([redirect2, redirect3, redirect4, redirect5])
end
end
end
diff --git a/spec/models/release_spec.rb b/spec/models/release_spec.rb
index 157c96c1f65..823a2becbfe 100644
--- a/spec/models/release_spec.rb
+++ b/spec/models/release_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe Release do
let(:user) { create(:user) }
@@ -7,37 +7,37 @@ RSpec.describe Release do
it { expect(release).to be_valid }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
- it { is_expected.to belong_to(:author).class_name('User') }
- it { is_expected.to have_many(:links).class_name('Releases::Link') }
+ it { is_expected.to belong_to(:author).class_name("User") }
+ it { is_expected.to have_many(:links).class_name("Releases::Link") }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:project) }
it { is_expected.to validate_presence_of(:description) }
end
- describe '#assets_count' do
+ describe "#assets_count" do
subject { release.assets_count }
- it 'returns the number of sources' do
+ it "returns the number of sources" do
is_expected.to eq(Releases::Source::FORMATS.count)
end
- context 'when a links exists' do
+ context "when a links exists" do
let!(:link) { create(:release_link, release: release) }
- it 'counts the link as an asset' do
+ it "counts the link as an asset" do
is_expected.to eq(1 + Releases::Source::FORMATS.count)
end
end
end
- describe '#sources' do
+ describe "#sources" do
subject { release.sources }
- it 'returns sources' do
+ it "returns sources" do
is_expected.to all(be_a(Releases::Source))
end
end
diff --git a/spec/models/releases/link_spec.rb b/spec/models/releases/link_spec.rb
index 4dd26c976cc..2b5c82cffcb 100644
--- a/spec/models/releases/link_spec.rb
+++ b/spec/models/releases/link_spec.rb
@@ -1,60 +1,60 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Releases::Link do
let(:release) { create(:release, project: project) }
let(:project) { create(:project) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:release) }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:name) }
- context 'when url is invalid' do
- let(:link) { build(:release_link, url: 'hoge') }
+ context "when url is invalid" do
+ let(:link) { build(:release_link, url: "hoge") }
- it 'will be invalid' do
+ it "will be invalid" do
expect(link).to be_invalid
end
end
- context 'when duplicate name is added to a release' do
- let!(:link) { create(:release_link, name: 'alpha', release: release) }
+ context "when duplicate name is added to a release" do
+ let!(:link) { create(:release_link, name: "alpha", release: release) }
- it 'raises an error' do
- expect do
- create(:release_link, name: 'alpha', release: release)
- end.to raise_error(ActiveRecord::RecordInvalid)
+ it "raises an error" do
+ expect {
+ create(:release_link, name: "alpha", release: release)
+ }.to raise_error(ActiveRecord::RecordInvalid)
end
end
- context 'when duplicate url is added to a release' do
- let!(:link) { create(:release_link, url: 'http://gitlab.com', release: release) }
+ context "when duplicate url is added to a release" do
+ let!(:link) { create(:release_link, url: "http://gitlab.com", release: release) }
- it 'raises an error' do
- expect do
- create(:release_link, url: 'http://gitlab.com', release: release)
- end.to raise_error(ActiveRecord::RecordInvalid)
+ it "raises an error" do
+ expect {
+ create(:release_link, url: "http://gitlab.com", release: release)
+ }.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
- describe '.sorted' do
+ describe ".sorted" do
subject { described_class.sorted }
- let!(:link_1) { create(:release_link, name: 'alpha', release: release, created_at: 1.day.ago) }
- let!(:link_2) { create(:release_link, name: 'beta', release: release, created_at: 2.days.ago) }
+ let!(:link_1) { create(:release_link, name: "alpha", release: release, created_at: 1.day.ago) }
+ let!(:link_2) { create(:release_link, name: "beta", release: release, created_at: 2.days.ago) }
- it 'returns a list of links by created_at order' do
+ it "returns a list of links by created_at order" do
is_expected.to eq([link_1, link_2])
end
end
- describe '#internal?' do
+ describe "#internal?" do
subject { link.internal? }
let(:link) { build(:release_link, release: release, url: url) }
@@ -62,41 +62,41 @@ describe Releases::Link do
it { is_expected.to be_truthy }
- context 'when link does not include project web url' do
- let(:url) { 'https://google.com/-/jobs/140463678/artifacts/download' }
+ context "when link does not include project web url" do
+ let(:url) { "https://google.com/-/jobs/140463678/artifacts/download" }
it { is_expected.to be_falsy }
end
end
- describe '#external?' do
+ describe "#external?" do
subject { link.external? }
let(:link) { build(:release_link, release: release, url: url) }
- let(:url) { 'https://google.com/-/jobs/140463678/artifacts/download' }
+ let(:url) { "https://google.com/-/jobs/140463678/artifacts/download" }
it { is_expected.to be_truthy }
end
- describe 'supported protocols' do
+ describe "supported protocols" do
where(:protocol) do
- %w(http https ftp)
+ %w[http https ftp]
end
with_them do
- let(:link) { build(:release_link, url: protocol + '://assets.com/download') }
+ let(:link) { build(:release_link, url: protocol + "://assets.com/download") }
- it 'will be valid' do
+ it "will be valid" do
expect(link).to be_valid
end
end
end
- describe 'unsupported protocol' do
- context 'for torrent' do
- let(:link) { build(:release_link, url: 'torrent://assets.com/download') }
+ describe "unsupported protocol" do
+ context "for torrent" do
+ let(:link) { build(:release_link, url: "torrent://assets.com/download") }
- it 'will be invalid' do
+ it "will be invalid" do
expect(link).to be_invalid
end
end
diff --git a/spec/models/releases/source_spec.rb b/spec/models/releases/source_spec.rb
index c5213196962..9259b770e50 100644
--- a/spec/models/releases/source_spec.rb
+++ b/spec/models/releases/source_spec.rb
@@ -1,38 +1,38 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Releases::Source do
- set(:project) { create(:project, :repository, name: 'finance-cal') }
- let(:tag_name) { 'v1.0' }
+ set(:project) { create(:project, :repository, name: "finance-cal") }
+ let(:tag_name) { "v1.0" }
- describe '.all' do
+ describe ".all" do
subject { described_class.all(project, tag_name) }
- it 'returns all formats of sources' do
+ it "returns all formats of sources" do
expect(subject.map(&:format))
.to match_array(described_class::FORMATS)
end
end
- describe '#url' do
+ describe "#url" do
subject { source.url }
let(:source) do
described_class.new(project: project, tag_name: tag_name, format: format)
end
- let(:format) { 'zip' }
+ let(:format) { "zip" }
- it 'returns zip archived source url' do
+ it "returns zip archived source url" do
is_expected
.to eq("#{project.web_url}/-/archive/v1.0/finance-cal-v1.0.zip")
end
- context 'when ref is directory structure' do
- let(:tag_name) { 'beta/v1.0' }
+ context "when ref is directory structure" do
+ let(:tag_name) { "beta/v1.0" }
- it 'converts slash to dash' do
+ it "converts slash to dash" do
is_expected
.to eq("#{project.web_url}/-/archive/beta/v1.0/finance-cal-beta-v1.0.zip")
end
diff --git a/spec/models/remote_mirror_spec.rb b/spec/models/remote_mirror_spec.rb
index c06e9a08ab4..29be8bb52d4 100644
--- a/spec/models/remote_mirror_spec.rb
+++ b/spec/models/remote_mirror_spec.rb
@@ -1,113 +1,113 @@
-require 'rails_helper'
+require "rails_helper"
describe RemoteMirror, :mailer do
include GitHelpers
- describe 'URL validation' do
- context 'with a valid URL' do
- it 'should be valid' do
+ describe "URL validation" do
+ context "with a valid URL" do
+ it "should be valid" do
remote_mirror = build(:remote_mirror)
expect(remote_mirror).to be_valid
end
end
- context 'with an invalid URL' do
- it 'should not be valid' do
- remote_mirror = build(:remote_mirror, url: 'ftp://invalid.invalid')
+ context "with an invalid URL" do
+ it "should not be valid" do
+ remote_mirror = build(:remote_mirror, url: "ftp://invalid.invalid")
expect(remote_mirror).not_to be_valid
end
- it 'does not allow url with an invalid user' do
- remote_mirror = build(:remote_mirror, url: 'http://$user:password@invalid.invalid')
+ it "does not allow url with an invalid user" do
+ remote_mirror = build(:remote_mirror, url: "http://$user:password@invalid.invalid")
expect(remote_mirror).to be_invalid
- expect(remote_mirror.errors[:url].first).to include('Username needs to start with an alphanumeric character')
+ expect(remote_mirror.errors[:url].first).to include("Username needs to start with an alphanumeric character")
end
- it 'does not allow url pointing to localhost' do
- remote_mirror = build(:remote_mirror, url: 'http://127.0.0.2/t.git')
+ it "does not allow url pointing to localhost" do
+ remote_mirror = build(:remote_mirror, url: "http://127.0.0.2/t.git")
expect(remote_mirror).to be_invalid
- expect(remote_mirror.errors[:url].first).to include('Requests to loopback addresses are not allowed')
+ expect(remote_mirror.errors[:url].first).to include("Requests to loopback addresses are not allowed")
end
- it 'does not allow url pointing to the local network' do
- remote_mirror = build(:remote_mirror, url: 'https://192.168.1.1')
+ it "does not allow url pointing to the local network" do
+ remote_mirror = build(:remote_mirror, url: "https://192.168.1.1")
expect(remote_mirror).to be_invalid
- expect(remote_mirror.errors[:url].first).to include('Requests to the local network are not allowed')
+ expect(remote_mirror.errors[:url].first).to include("Requests to the local network are not allowed")
end
end
end
- describe 'encrypting credentials' do
- context 'when setting URL for a first time' do
- it 'stores the URL without credentials' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ describe "encrypting credentials" do
+ context "when setting URL for a first time" do
+ it "stores the URL without credentials" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
- expect(mirror.read_attribute(:url)).to eq('http://test.com')
+ expect(mirror.read_attribute(:url)).to eq("http://test.com")
end
- it 'stores the credentials on a separate field' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ it "stores the credentials on a separate field" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
- expect(mirror.credentials).to eq({ user: 'foo', password: 'bar' })
+ expect(mirror.credentials).to eq({user: "foo", password: "bar"})
end
- it 'handles credentials with large content' do
- mirror = create_mirror(url: 'http://bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif:9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75@test.com')
+ it "handles credentials with large content" do
+ mirror = create_mirror(url: "http://bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif:9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75@test.com")
expect(mirror.credentials).to eq({
- user: 'bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif',
- password: '9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75'
+ user: "bxnhm8dote33ct932r3xavslj81wxmr7o8yux8do10oozckkif",
+ password: "9ne7fuvjn40qjt35dgt8v86q9m9g9essryxj76sumg2ccl2fg26c0krtz2gzfpyq4hf22h328uhq6npuiq6h53tpagtsj7vsrz75",
})
end
end
- context 'when updating the URL' do
- it 'allows a new URL without credentials' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ context "when updating the URL" do
+ it "allows a new URL without credentials" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
- mirror.update_attribute(:url, 'http://test.com')
+ mirror.update_attribute(:url, "http://test.com")
- expect(mirror.url).to eq('http://test.com')
- expect(mirror.credentials).to eq({ user: nil, password: nil })
+ expect(mirror.url).to eq("http://test.com")
+ expect(mirror.credentials).to eq({user: nil, password: nil})
end
- it 'allows a new URL with credentials' do
- mirror = create_mirror(url: 'http://test.com')
+ it "allows a new URL with credentials" do
+ mirror = create_mirror(url: "http://test.com")
- mirror.update_attribute(:url, 'http://foo:bar@test.com')
+ mirror.update_attribute(:url, "http://foo:bar@test.com")
- expect(mirror.url).to eq('http://foo:bar@test.com')
- expect(mirror.credentials).to eq({ user: 'foo', password: 'bar' })
+ expect(mirror.url).to eq("http://foo:bar@test.com")
+ expect(mirror.credentials).to eq({user: "foo", password: "bar"})
end
- it 'updates the remote config if credentials changed' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ it "updates the remote config if credentials changed" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
repo = mirror.project.repository
- mirror.update_attribute(:url, 'http://foo:baz@test.com')
+ mirror.update_attribute(:url, "http://foo:baz@test.com")
config = rugged_repo(repo).config
- expect(config["remote.#{mirror.remote_name}.url"]).to eq('http://foo:baz@test.com')
+ expect(config["remote.#{mirror.remote_name}.url"]).to eq("http://foo:baz@test.com")
end
- it 'removes previous remote' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ it "removes previous remote" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
expect(RepositoryRemoveRemoteWorker).to receive(:perform_async).with(mirror.project.id, mirror.remote_name).and_call_original
- mirror.update(url: 'http://test.com')
+ mirror.update(url: "http://test.com")
end
end
end
- describe '#remote_name' do
- context 'when remote name is persisted in the database' do
- it 'returns remote name with random value' do
- allow(SecureRandom).to receive(:hex).and_return('secret')
+ describe "#remote_name" do
+ context "when remote name is persisted in the database" do
+ it "returns remote name with random value" do
+ allow(SecureRandom).to receive(:hex).and_return("secret")
remote_mirror = create(:remote_mirror)
@@ -115,8 +115,8 @@ describe RemoteMirror, :mailer do
end
end
- context 'when remote name is not persisted in the database' do
- it 'returns remote name with remote mirror id' do
+ context "when remote name is not persisted in the database" do
+ it "returns remote name with remote mirror id" do
remote_mirror = create(:remote_mirror)
remote_mirror.remote_name = nil
@@ -124,8 +124,8 @@ describe RemoteMirror, :mailer do
end
end
- context 'when remote is not persisted in the database' do
- it 'returns nil' do
+ context "when remote is not persisted in the database" do
+ it "returns nil" do
remote_mirror = build(:remote_mirror, remote_name: nil)
expect(remote_mirror.remote_name).to be_nil
@@ -133,54 +133,54 @@ describe RemoteMirror, :mailer do
end
end
- describe '#safe_url' do
- context 'when URL contains credentials' do
- it 'masks the credentials' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ describe "#safe_url" do
+ context "when URL contains credentials" do
+ it "masks the credentials" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
- expect(mirror.safe_url).to eq('http://*****:*****@test.com')
+ expect(mirror.safe_url).to eq("http://*****:*****@test.com")
end
end
- context 'when URL does not contain credentials' do
- it 'shows the full URL' do
- mirror = create_mirror(url: 'http://test.com')
+ context "when URL does not contain credentials" do
+ it "shows the full URL" do
+ mirror = create_mirror(url: "http://test.com")
- expect(mirror.safe_url).to eq('http://test.com')
+ expect(mirror.safe_url).to eq("http://test.com")
end
end
end
- describe '#mark_as_failed' do
+ describe "#mark_as_failed" do
let(:remote_mirror) { create(:remote_mirror) }
- let(:error_message) { 'http://user:pass@test.com/root/repoC.git/' }
- let(:sanitized_error_message) { 'http://*****:*****@test.com/root/repoC.git/' }
+ let(:error_message) { "http://user:pass@test.com/root/repoC.git/" }
+ let(:sanitized_error_message) { "http://*****:*****@test.com/root/repoC.git/" }
subject do
remote_mirror.update_start
remote_mirror.mark_as_failed(error_message)
end
- it 'sets the update_status to failed' do
+ it "sets the update_status to failed" do
subject
- expect(remote_mirror.reload.update_status).to eq('failed')
+ expect(remote_mirror.reload.update_status).to eq("failed")
end
- it 'saves the sanitized error' do
+ it "saves the sanitized error" do
subject
expect(remote_mirror.last_error).to eq(sanitized_error_message)
end
- context 'notifications' do
+ context "notifications" do
let(:user) { create(:user) }
before do
remote_mirror.project.add_maintainer(user)
end
- it 'notifies the project maintainers' do
+ it "notifies the project maintainers" do
perform_enqueued_jobs { subject }
should_email(user)
@@ -188,9 +188,9 @@ describe RemoteMirror, :mailer do
end
end
- context 'when remote mirror gets destroyed' do
- it 'removes remote' do
- mirror = create_mirror(url: 'http://foo:bar@test.com')
+ context "when remote mirror gets destroyed" do
+ it "removes remote" do
+ mirror = create_mirror(url: "http://foo:bar@test.com")
expect(RepositoryRemoveRemoteWorker).to receive(:perform_async).with(mirror.project.id, mirror.remote_name).and_call_original
@@ -198,10 +198,10 @@ describe RemoteMirror, :mailer do
end
end
- context 'stuck mirrors' do
- it 'includes mirrors stuck in started with no last_update_at set' do
- mirror = create_mirror(url: 'http://cantbeblank',
- update_status: 'started',
+ context "stuck mirrors" do
+ it "includes mirrors stuck in started with no last_update_at set" do
+ mirror = create_mirror(url: "http://cantbeblank",
+ update_status: "started",
last_update_at: nil,
updated_at: 25.hours.ago)
@@ -209,41 +209,41 @@ describe RemoteMirror, :mailer do
end
end
- context '#sync' do
+ context "#sync" do
let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
around do |example|
Timecop.freeze { example.run }
end
- context 'with remote mirroring disabled' do
- it 'returns nil' do
+ context "with remote mirroring disabled" do
+ it "returns nil" do
remote_mirror.update(enabled: false)
expect(remote_mirror.sync).to be_nil
end
end
- context 'with remote mirroring enabled' do
- it 'defaults to disabling only protected branches' do
+ context "with remote mirroring enabled" do
+ it "defaults to disabling only protected branches" do
expect(remote_mirror.only_protected_branches?).to be_falsey
end
- context 'with only protected branches enabled' do
+ context "with only protected branches enabled" do
before do
remote_mirror.only_protected_branches = true
end
- context 'when it did not update in the last minute' do
- it 'schedules a RepositoryUpdateRemoteMirrorWorker to run now' do
+ context "when it did not update in the last minute" do
+ it "schedules a RepositoryUpdateRemoteMirrorWorker to run now" do
expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_async).with(remote_mirror.id, Time.now)
remote_mirror.sync
end
end
- context 'when it did update in the last minute' do
- it 'schedules a RepositoryUpdateRemoteMirrorWorker to run in the next minute' do
+ context "when it did update in the last minute" do
+ it "schedules a RepositoryUpdateRemoteMirrorWorker to run in the next minute" do
remote_mirror.last_update_started_at = Time.now - 30.seconds
expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_in).with(RemoteMirror::PROTECTED_BACKOFF_DELAY, remote_mirror.id, Time.now)
@@ -253,21 +253,21 @@ describe RemoteMirror, :mailer do
end
end
- context 'with only protected branches disabled' do
+ context "with only protected branches disabled" do
before do
remote_mirror.only_protected_branches = false
end
- context 'when it did not update in the last 5 minutes' do
- it 'schedules a RepositoryUpdateRemoteMirrorWorker to run now' do
+ context "when it did not update in the last 5 minutes" do
+ it "schedules a RepositoryUpdateRemoteMirrorWorker to run now" do
expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_async).with(remote_mirror.id, Time.now)
remote_mirror.sync
end
end
- context 'when it did update within the last 5 minutes' do
- it 'schedules a RepositoryUpdateRemoteMirrorWorker to run in the next 5 minutes' do
+ context "when it did update within the last 5 minutes" do
+ it "schedules a RepositoryUpdateRemoteMirrorWorker to run in the next 5 minutes" do
remote_mirror.last_update_started_at = Time.now - 30.seconds
expect(RepositoryUpdateRemoteMirrorWorker).to receive(:perform_in).with(RemoteMirror::UNPROTECTED_BACKOFF_DELAY, remote_mirror.id, Time.now)
@@ -279,12 +279,12 @@ describe RemoteMirror, :mailer do
end
end
- context '#ensure_remote!' do
+ context "#ensure_remote!" do
let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
let(:project) { remote_mirror.project }
let(:repository) { project.repository }
- it 'adds a remote multiple times with no errors' do
+ it "adds a remote multiple times with no errors" do
expect(repository).to receive(:add_remote).with(remote_mirror.remote_name, remote_mirror.url).twice.and_call_original
2.times do
@@ -292,37 +292,37 @@ describe RemoteMirror, :mailer do
end
end
- context 'SSH public-key authentication' do
- it 'omits the password from the URL' do
- remote_mirror.update!(auth_method: 'ssh_public_key', url: 'ssh://git:pass@example.com')
+ context "SSH public-key authentication" do
+ it "omits the password from the URL" do
+ remote_mirror.update!(auth_method: "ssh_public_key", url: "ssh://git:pass@example.com")
- expect(repository).to receive(:add_remote).with(remote_mirror.remote_name, 'ssh://git@example.com')
+ expect(repository).to receive(:add_remote).with(remote_mirror.remote_name, "ssh://git@example.com")
remote_mirror.ensure_remote!
end
end
end
- context '#url=' do
+ context "#url=" do
let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
- it 'resets all the columns when URL changes' do
+ it "resets all the columns when URL changes" do
remote_mirror.update(last_error: Time.now,
last_update_at: Time.now,
last_successful_update_at: Time.now,
- update_status: 'started',
+ update_status: "started",
error_notification_sent: true)
- expect { remote_mirror.update_attribute(:url, 'http://new.example.com') }
+ expect { remote_mirror.update_attribute(:url, "http://new.example.com") }
.to change { remote_mirror.last_error }.to(nil)
.and change { remote_mirror.last_update_at }.to(nil)
.and change { remote_mirror.last_successful_update_at }.to(nil)
- .and change { remote_mirror.update_status }.to('finished')
+ .and change { remote_mirror.update_status }.to("finished")
.and change { remote_mirror.error_notification_sent }.to(false)
end
end
- context '#updated_since?' do
+ context "#updated_since?" do
let(:remote_mirror) { create(:project, :repository, :remote_mirror).remote_mirrors.first }
let(:timestamp) { Time.now - 5.minutes }
@@ -334,29 +334,29 @@ describe RemoteMirror, :mailer do
remote_mirror.update(last_update_started_at: Time.now)
end
- context 'when remote mirror does not have status failed' do
- it 'returns true when last update started after the timestamp' do
+ context "when remote mirror does not have status failed" do
+ it "returns true when last update started after the timestamp" do
expect(remote_mirror.updated_since?(timestamp)).to be true
end
- it 'returns false when last update started before the timestamp' do
+ it "returns false when last update started before the timestamp" do
expect(remote_mirror.updated_since?(Time.now + 5.minutes)).to be false
end
end
- context 'when remote mirror has status failed' do
- it 'returns false when last update started after the timestamp' do
- remote_mirror.update(update_status: 'failed')
+ context "when remote mirror has status failed" do
+ it "returns false when last update started after the timestamp" do
+ remote_mirror.update(update_status: "failed")
expect(remote_mirror.updated_since?(timestamp)).to be false
end
end
end
- context 'no project' do
- it 'includes mirror with a project in pending_delete' do
- mirror = create_mirror(url: 'http://cantbeblank',
- update_status: 'finished',
+ context "no project" do
+ it "includes mirror with a project in pending_delete" do
+ mirror = create_mirror(url: "http://cantbeblank",
+ update_status: "finished",
enabled: true,
last_update_at: nil,
updated_at: 25.hours.ago)
@@ -367,7 +367,7 @@ describe RemoteMirror, :mailer do
expect(mirror.sync).to be_nil
expect(mirror.valid?).to be_truthy
- expect(mirror.update_status).to eq('finished')
+ expect(mirror.update_status).to eq("finished")
end
end
diff --git a/spec/models/repository_language_spec.rb b/spec/models/repository_language_spec.rb
index e2e4beb512f..fc9be1b83a1 100644
--- a/spec/models/repository_language_spec.rb
+++ b/spec/models/repository_language_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryLanguage do
let(:repository_language) { build(:repository_language) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:programming_language) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to allow_value(0).for(:share) }
it { is_expected.to allow_value(100.0).for(:share) }
it { is_expected.not_to allow_value(100.1).for(:share) }
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 17201d8b90a..88d72c90088 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Repository do
include RepoHelpers
@@ -12,21 +12,21 @@ describe Repository do
let(:user) { create(:user) }
let(:git_user) { Gitlab::Git::User.from_gitlab(user) }
- let(:message) { 'Test message' }
+ let(:message) { "Test message" }
let(:merge_commit) do
- merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project)
+ merge_request = create(:merge_request, source_branch: "feature", target_branch: "master", source_project: project)
merge_commit_id = repository.merge(user,
- merge_request.diff_head_sha,
- merge_request,
- message)
+ merge_request.diff_head_sha,
+ merge_request,
+ message)
repository.commit(merge_commit_id)
end
- let(:author_email) { 'user@example.org' }
- let(:author_name) { 'John Doe' }
+ let(:author_email) { "user@example.org" }
+ let(:author_name) { "John Doe" }
def expect_to_raise_storage_error
expect { yield }.to raise_error do |exception|
@@ -37,18 +37,18 @@ describe Repository do
end
end
- describe '#branch_names_contains' do
+ describe "#branch_names_contains" do
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject { repository.branch_names_contains(sample_commit.id) }
- it { is_expected.to include('master') }
- it { is_expected.not_to include('feature') }
- it { is_expected.not_to include('fix') }
+ it { is_expected.to include("master") }
+ it { is_expected.not_to include("feature") }
+ it { is_expected.not_to include("fix") }
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error do
broken_repository.branch_names_contains(sample_commit.id)
end
@@ -56,32 +56,32 @@ describe Repository do
end
end
- describe '#tag_names_contains' do
+ describe "#tag_names_contains" do
subject { repository.tag_names_contains(sample_commit.id) }
- it { is_expected.to include('v1.1.0') }
- it { is_expected.not_to include('v1.0.0') }
+ it { is_expected.to include("v1.1.0") }
+ it { is_expected.not_to include("v1.0.0") }
end
- describe 'tags_sorted_by' do
- context 'name_desc' do
- subject { repository.tags_sorted_by('name_desc').map(&:name) }
+ describe "tags_sorted_by" do
+ context "name_desc" do
+ subject { repository.tags_sorted_by("name_desc").map(&:name) }
- it { is_expected.to eq(['v1.1.0', 'v1.0.0']) }
+ it { is_expected.to eq(["v1.1.0", "v1.0.0"]) }
end
- context 'name_asc' do
- subject { repository.tags_sorted_by('name_asc').map(&:name) }
+ context "name_asc" do
+ subject { repository.tags_sorted_by("name_asc").map(&:name) }
- it { is_expected.to eq(['v1.0.0', 'v1.1.0']) }
+ it { is_expected.to eq(["v1.0.0", "v1.1.0"]) }
end
- context 'updated' do
- let(:tag_a) { repository.find_tag('v1.0.0') }
- let(:tag_b) { repository.find_tag('v1.1.0') }
+ context "updated" do
+ let(:tag_a) { repository.find_tag("v1.0.0") }
+ let(:tag_b) { repository.find_tag("v1.1.0") }
- context 'desc' do
- subject { repository.tags_sorted_by('updated_desc').map(&:name) }
+ context "desc" do
+ subject { repository.tags_sorted_by("updated_desc").map(&:name) }
before do
double_first = double(committed_date: Time.now)
@@ -92,11 +92,11 @@ describe Repository do
allow(repository).to receive(:tags).and_return([tag_a, tag_b])
end
- it { is_expected.to eq(['v1.0.0', 'v1.1.0']) }
+ it { is_expected.to eq(["v1.0.0", "v1.1.0"]) }
end
- context 'asc' do
- subject { repository.tags_sorted_by('updated_asc').map(&:name) }
+ context "asc" do
+ subject { repository.tags_sorted_by("updated_asc").map(&:name) }
before do
double_first = double(committed_date: Time.now - 1.second)
@@ -107,19 +107,19 @@ describe Repository do
allow(repository).to receive(:tags).and_return([tag_a, tag_b])
end
- it { is_expected.to eq(['v1.1.0', 'v1.0.0']) }
+ it { is_expected.to eq(["v1.1.0", "v1.0.0"]) }
end
- context 'annotated tag pointing to a blob' do
- let(:annotated_tag_name) { 'annotated-tag' }
+ context "annotated tag pointing to a blob" do
+ let(:annotated_tag_name) { "annotated-tag" }
- subject { repository.tags_sorted_by('updated_asc').map(&:name) }
+ subject { repository.tags_sorted_by("updated_asc").map(&:name) }
before do
- options = { message: 'test tag message\n',
- tagger: { name: 'John Smith', email: 'john@gmail.com' } }
+ options = {message: 'test tag message\n',
+ tagger: {name: "John Smith", email: "john@gmail.com"},}
- rugged_repo(repository).tags.create(annotated_tag_name, 'a48e4fc218069f68ef2e769dd8dfea3991362175', options)
+ rugged_repo(repository).tags.create(annotated_tag_name, "a48e4fc218069f68ef2e769dd8dfea3991362175", options)
double_first = double(committed_date: Time.now - 1.second)
double_last = double(committed_date: Time.now)
@@ -128,7 +128,7 @@ describe Repository do
allow(tag_b).to receive(:dereferenced_target).and_return(double_first)
end
- it { is_expected.to eq(['v1.1.0', 'v1.0.0', annotated_tag_name]) }
+ it { is_expected.to eq(["v1.1.0", "v1.0.0", annotated_tag_name]) }
after do
rugged_repo(repository).tags.delete(annotated_tag_name)
@@ -137,36 +137,36 @@ describe Repository do
end
end
- describe '#ref_name_for_sha' do
- it 'returns the ref' do
+ describe "#ref_name_for_sha" do
+ it "returns the ref" do
allow(repository.raw_repository).to receive(:ref_name_for_sha)
- .and_return('refs/environments/production/77')
+ .and_return("refs/environments/production/77")
- expect(repository.ref_name_for_sha('bla', '0' * 40)).to eq 'refs/environments/production/77'
+ expect(repository.ref_name_for_sha("bla", "0" * 40)).to eq "refs/environments/production/77"
end
end
- describe '#ref_exists?' do
- context 'when ref exists' do
- it 'returns true' do
- expect(repository.ref_exists?('refs/heads/master')).to be true
+ describe "#ref_exists?" do
+ context "when ref exists" do
+ it "returns true" do
+ expect(repository.ref_exists?("refs/heads/master")).to be true
end
end
- context 'when ref does not exist' do
- it 'returns false' do
- expect(repository.ref_exists?('refs/heads/non-existent')).to be false
+ context "when ref does not exist" do
+ it "returns false" do
+ expect(repository.ref_exists?("refs/heads/non-existent")).to be false
end
end
- context 'when ref format is incorrect' do
- it 'returns false' do
- expect(repository.ref_exists?('refs/heads/invalid:master')).to be false
+ context "when ref format is incorrect" do
+ it "returns false" do
+ expect(repository.ref_exists?("refs/heads/invalid:master")).to be false
end
end
end
- describe '#list_last_commits_for_tree' do
+ describe "#list_last_commits_for_tree" do
let(:path_to_commit) do
{
"encoding" => "913c66a37b4a45b9769037c55c2d238bd0942d2e",
@@ -182,14 +182,14 @@ describe Repository do
"README.md" => "1a0b36b3cdad1d2ee32457c102a8c0b7056fa863",
"VERSION" => "913c66a37b4a45b9769037c55c2d238bd0942d2e",
"gitlab-shell" => "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9",
- "six" => "cfe32cf61b73a0d5e9f13e774abde7ff789b1660"
+ "six" => "cfe32cf61b73a0d5e9f13e774abde7ff789b1660",
}
end
- subject { repository.list_last_commits_for_tree(sample_commit.id, '.').id }
+ subject { repository.list_last_commits_for_tree(sample_commit.id, ".").id }
- it 'returns the last commits for every entry in the current path' do
- result = repository.list_last_commits_for_tree(sample_commit.id, '.')
+ it "returns the last commits for every entry in the current path" do
+ result = repository.list_last_commits_for_tree(sample_commit.id, ".")
result.each do |key, value|
result[key] = value.id
@@ -198,170 +198,170 @@ describe Repository do
expect(result).to include(path_to_commit)
end
- it 'returns the last commits for every entry in the current path starting from the offset' do
- result = repository.list_last_commits_for_tree(sample_commit.id, '.', offset: path_to_commit.size - 1)
+ it "returns the last commits for every entry in the current path starting from the offset" do
+ result = repository.list_last_commits_for_tree(sample_commit.id, ".", offset: path_to_commit.size - 1)
expect(result.size).to eq(1)
end
- it 'returns a limited number of last commits for every entry in the current path starting from the offset' do
- result = repository.list_last_commits_for_tree(sample_commit.id, '.', limit: 1)
+ it "returns a limited number of last commits for every entry in the current path starting from the offset" do
+ result = repository.list_last_commits_for_tree(sample_commit.id, ".", limit: 1)
expect(result.size).to eq(1)
end
- it 'returns an empty hash when offset is out of bounds' do
- result = repository.list_last_commits_for_tree(sample_commit.id, '.', offset: path_to_commit.size)
+ it "returns an empty hash when offset is out of bounds" do
+ result = repository.list_last_commits_for_tree(sample_commit.id, ".", offset: path_to_commit.size)
expect(result.size).to eq(0)
end
end
- describe '#last_commit_for_path' do
- subject { repository.last_commit_for_path(sample_commit.id, '.gitignore').id }
+ describe "#last_commit_for_path" do
+ subject { repository.last_commit_for_path(sample_commit.id, ".gitignore").id }
- it { is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8') }
+ it { is_expected.to eq("c1acaa58bbcbc3eafe538cb8274ba387047b69f8") }
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error do
- broken_repository.last_commit_id_for_path(sample_commit.id, '.gitignore')
+ broken_repository.last_commit_id_for_path(sample_commit.id, ".gitignore")
end
end
end
end
- describe '#last_commit_id_for_path' do
- subject { repository.last_commit_id_for_path(sample_commit.id, '.gitignore') }
+ describe "#last_commit_id_for_path" do
+ subject { repository.last_commit_id_for_path(sample_commit.id, ".gitignore") }
it "returns last commit id for a given path" do
- is_expected.to eq('c1acaa58bbcbc3eafe538cb8274ba387047b69f8')
+ is_expected.to eq("c1acaa58bbcbc3eafe538cb8274ba387047b69f8")
end
it "caches last commit id for a given path" do
cache = repository.send(:cache)
- key = "last_commit_id_for_path:#{sample_commit.id}:#{Digest::SHA1.hexdigest('.gitignore')}"
+ key = "last_commit_id_for_path:#{sample_commit.id}:#{Digest::SHA1.hexdigest(".gitignore")}"
- expect(cache).to receive(:fetch).with(key).and_return('c1acaa5')
- is_expected.to eq('c1acaa5')
+ expect(cache).to receive(:fetch).with(key).and_return("c1acaa5")
+ is_expected.to eq("c1acaa5")
end
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error do
- broken_repository.last_commit_for_path(sample_commit.id, '.gitignore').id
+ broken_repository.last_commit_for_path(sample_commit.id, ".gitignore").id
end
end
end
end
- describe '#commits' do
- context 'when neither the all flag nor a ref are specified' do
- it 'returns every commit from default branch' do
+ describe "#commits" do
+ context "when neither the all flag nor a ref are specified" do
+ it "returns every commit from default branch" do
expect(repository.commits(limit: 60).size).to eq(37)
end
end
- context 'when ref is passed' do
- it 'returns every commit from the specified ref' do
- expect(repository.commits('master', limit: 60).size).to eq(37)
+ context "when ref is passed" do
+ it "returns every commit from the specified ref" do
+ expect(repository.commits("master", limit: 60).size).to eq(37)
end
- context 'when all' do
- it 'returns every commit from the repository' do
- expect(repository.commits('master', limit: 60, all: true).size).to eq(60)
+ context "when all" do
+ it "returns every commit from the repository" do
+ expect(repository.commits("master", limit: 60, all: true).size).to eq(60)
end
end
- context 'with path' do
- it 'sets follow when it is a single path' do
+ context "with path" do
+ it "sets follow when it is a single path" do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: true)).and_call_original.twice
- repository.commits('master', limit: 1, path: 'README.md')
- repository.commits('master', limit: 1, path: ['README.md'])
+ repository.commits("master", limit: 1, path: "README.md")
+ repository.commits("master", limit: 1, path: ["README.md"])
end
- it 'does not set follow when it is multiple paths' do
+ it "does not set follow when it is multiple paths" do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
- repository.commits('master', limit: 1, path: ['README.md', 'CHANGELOG'])
+ repository.commits("master", limit: 1, path: ["README.md", "CHANGELOG"])
end
end
- context 'without path' do
- it 'does not set follow' do
+ context "without path" do
+ it "does not set follow" do
expect(Gitlab::Git::Commit).to receive(:where).with(a_hash_including(follow: false)).and_call_original
- repository.commits('master', limit: 1)
+ repository.commits("master", limit: 1)
end
end
end
context "when 'all' flag is set" do
- it 'returns every commit from the repository' do
+ it "returns every commit from the repository" do
expect(repository.commits(all: true, limit: 60).size).to eq(60)
end
end
end
- describe '#new_commits' do
+ describe "#new_commits" do
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
subject { repository.new_commits(rev) }
- context 'when there are no new commits' do
+ context "when there are no new commits" do
let(:rev) { repository.commit.id }
- it 'returns an empty array' do
+ it "returns an empty array" do
expect(subject).to eq([])
end
end
- context 'when new commits are found' do
- let(:branch) { 'orphaned-branch' }
+ context "when new commits are found" do
+ let(:branch) { "orphaned-branch" }
let!(:rev) { repository.commit(branch).id }
- it 'returns the commits' do
+ it "returns the commits" do
repository.delete_branch(branch)
expect(subject).not_to be_empty
- expect(subject).to all( be_a(::Commit) )
+ expect(subject).to all(be_a(::Commit))
expect(subject.size).to eq(1)
end
end
end
- describe '#commits_by' do
+ describe "#commits_by" do
set(:project) { create(:project, :repository) }
let(:oids) { TestEnv::BRANCH_SHA.values }
subject { project.repository.commits_by(oids: oids) }
- it 'finds each commit' do
+ it "finds each commit" do
expect(subject).not_to include(nil)
expect(subject.size).to eq(oids.size)
end
- it 'returns only Commit instances' do
- expect(subject).to all( be_a(Commit) )
+ it "returns only Commit instances" do
+ expect(subject).to all(be_a(Commit))
end
- context 'when some commits are not found ' do
+ context "when some commits are not found " do
let(:oids) do
- ['deadbeef'] + TestEnv::BRANCH_SHA.values.first(10)
+ ["deadbeef"] + TestEnv::BRANCH_SHA.values.first(10)
end
- it 'returns only found commits' do
+ it "returns only found commits" do
expect(subject).not_to include(nil)
expect(subject.size).to eq(10)
end
end
- context 'when no oids are passed' do
+ context "when no oids are passed" do
let(:oids) { [] }
- it 'does not call #batch_by_oid' do
+ it "does not call #batch_by_oid" do
expect(Gitlab::Git::Commit).not_to receive(:batch_by_oid)
subject
@@ -369,154 +369,154 @@ describe Repository do
end
end
- describe '#find_commits_by_message' do
- it 'returns commits with messages containing a given string' do
- commit_ids = repository.find_commits_by_message('submodule').map(&:id)
+ describe "#find_commits_by_message" do
+ it "returns commits with messages containing a given string" do
+ commit_ids = repository.find_commits_by_message("submodule").map(&:id)
expect(commit_ids).to include(
- '5937ac0a7beb003549fc5fd26fc247adbce4a52e',
- '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9',
- 'cfe32cf61b73a0d5e9f13e774abde7ff789b1660'
+ "5937ac0a7beb003549fc5fd26fc247adbce4a52e",
+ "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9",
+ "cfe32cf61b73a0d5e9f13e774abde7ff789b1660"
)
- expect(commit_ids).not_to include('913c66a37b4a45b9769037c55c2d238bd0942d2e')
+ expect(commit_ids).not_to include("913c66a37b4a45b9769037c55c2d238bd0942d2e")
end
- it 'is case insensitive' do
- commit_ids = repository.find_commits_by_message('SUBMODULE').map(&:id)
+ it "is case insensitive" do
+ commit_ids = repository.find_commits_by_message("SUBMODULE").map(&:id)
- expect(commit_ids).to include('5937ac0a7beb003549fc5fd26fc247adbce4a52e')
+ expect(commit_ids).to include("5937ac0a7beb003549fc5fd26fc247adbce4a52e")
end
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
- expect_to_raise_storage_error { broken_repository.find_commits_by_message('s') }
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
+ expect_to_raise_storage_error { broken_repository.find_commits_by_message("s") }
end
end
end
- describe '#blob_at' do
- context 'blank sha' do
- subject { repository.blob_at(Gitlab::Git::BLANK_SHA, '.gitignore') }
+ describe "#blob_at" do
+ context "blank sha" do
+ subject { repository.blob_at(Gitlab::Git::BLANK_SHA, ".gitignore") }
it { is_expected.to be_nil }
end
- context 'regular blob' do
- subject { repository.blob_at(repository.head_commit.sha, '.gitignore') }
+ context "regular blob" do
+ subject { repository.blob_at(repository.head_commit.sha, ".gitignore") }
it { is_expected.to be_an_instance_of(::Blob) }
end
- context 'readme blob on HEAD' do
- subject { repository.blob_at(repository.head_commit.sha, 'README.md') }
+ context "readme blob on HEAD" do
+ subject { repository.blob_at(repository.head_commit.sha, "README.md") }
it { is_expected.to be_an_instance_of(::ReadmeBlob) }
end
- context 'readme blob not on HEAD' do
- subject { repository.blob_at(repository.find_branch('feature').target, 'README.md') }
+ context "readme blob not on HEAD" do
+ subject { repository.blob_at(repository.find_branch("feature").target, "README.md") }
it { is_expected.to be_an_instance_of(::Blob) }
end
end
- describe '#merged_to_root_ref?' do
- context 'merged branch without ff' do
- subject { repository.merged_to_root_ref?('branch-merged') }
+ describe "#merged_to_root_ref?" do
+ context "merged branch without ff" do
+ subject { repository.merged_to_root_ref?("branch-merged") }
it { is_expected.to be_truthy }
end
# If the HEAD was ff then it will be false
- context 'merged with ff' do
- subject { repository.merged_to_root_ref?('improve/awesome') }
+ context "merged with ff" do
+ subject { repository.merged_to_root_ref?("improve/awesome") }
it { is_expected.to be_truthy }
end
- context 'not merged branch' do
- subject { repository.merged_to_root_ref?('not-merged-branch') }
+ context "not merged branch" do
+ subject { repository.merged_to_root_ref?("not-merged-branch") }
it { is_expected.to be_falsey }
end
- context 'default branch' do
- subject { repository.merged_to_root_ref?('master') }
+ context "default branch" do
+ subject { repository.merged_to_root_ref?("master") }
it { is_expected.to be_falsey }
end
- context 'non merged branch' do
- subject { repository.merged_to_root_ref?('fix') }
+ context "non merged branch" do
+ subject { repository.merged_to_root_ref?("fix") }
it { is_expected.to be_falsey }
end
- context 'non existent branch' do
- subject { repository.merged_to_root_ref?('non_existent_branch') }
+ context "non existent branch" do
+ subject { repository.merged_to_root_ref?("non_existent_branch") }
it { is_expected.to be_nil }
end
end
- describe '#can_be_merged?' do
- context 'mergeable branches' do
- subject { repository.can_be_merged?('0b4bc9a49b562e85de7cc9e834518ea6828729b9', 'master') }
+ describe "#can_be_merged?" do
+ context "mergeable branches" do
+ subject { repository.can_be_merged?("0b4bc9a49b562e85de7cc9e834518ea6828729b9", "master") }
it { is_expected.to be_truthy }
end
- context 'non-mergeable branches without conflict sides missing' do
- subject { repository.can_be_merged?('bb5206fee213d983da88c47f9cf4cc6caf9c66dc', 'feature') }
+ context "non-mergeable branches without conflict sides missing" do
+ subject { repository.can_be_merged?("bb5206fee213d983da88c47f9cf4cc6caf9c66dc", "feature") }
it { is_expected.to be_falsey }
end
- context 'non-mergeable branches with conflict sides missing' do
- subject { repository.can_be_merged?('conflict-missing-side', 'conflict-start') }
+ context "non-mergeable branches with conflict sides missing" do
+ subject { repository.can_be_merged?("conflict-missing-side", "conflict-start") }
it { is_expected.to be_falsey }
end
- context 'submodule changes that confuse rugged' do
- subject { repository.can_be_merged?('update-gitlab-shell-v-6-0-1', 'update-gitlab-shell-v-6-0-3') }
+ context "submodule changes that confuse rugged" do
+ subject { repository.can_be_merged?("update-gitlab-shell-v-6-0-1", "update-gitlab-shell-v-6-0-3") }
it { is_expected.to be_falsey }
end
end
- describe '#commit' do
- context 'when ref exists' do
- it 'returns commit object' do
- expect(repository.commit('master'))
+ describe "#commit" do
+ context "when ref exists" do
+ it "returns commit object" do
+ expect(repository.commit("master"))
.to be_an_instance_of Commit
end
end
- context 'when ref does not exist' do
- it 'returns nil' do
- expect(repository.commit('non-existent-ref')).to be_nil
+ context "when ref does not exist" do
+ it "returns nil" do
+ expect(repository.commit("non-existent-ref")).to be_nil
end
end
- context 'when ref is not specified' do
- it 'is using a root ref' do
- expect(repository).to receive(:find_commit).with('master')
+ context "when ref is not specified" do
+ it "is using a root ref" do
+ expect(repository).to receive(:find_commit).with("master")
repository.commit
end
end
- context 'when ref is not valid' do
- context 'when preceding tree element exists' do
- it 'returns nil' do
- expect(repository.commit('master:ref')).to be_nil
+ context "when ref is not valid" do
+ context "when preceding tree element exists" do
+ it "returns nil" do
+ expect(repository.commit("master:ref")).to be_nil
end
end
- context 'when preceding tree element does not exist' do
- it 'returns nil' do
- expect(repository.commit('non-existent:ref')).to be_nil
+ context "when preceding tree element does not exist" do
+ it "returns nil" do
+ expect(repository.commit("non-existent:ref")).to be_nil
end
end
end
@@ -524,41 +524,41 @@ describe Repository do
describe "#create_dir" do
it "commits a change that creates a new directory" do
- expect do
- repository.create_dir(user, 'newdir',
- message: 'Create newdir', branch_name: 'master')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ expect {
+ repository.create_dir(user, "newdir",
+ message: "Create newdir", branch_name: "master")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- newdir = repository.tree('master', 'newdir')
- expect(newdir.path).to eq('newdir')
+ newdir = repository.tree("master", "newdir")
+ expect(newdir.path).to eq("newdir")
end
context "when committing to another project" do
let(:forked_project) { create(:project, :repository) }
it "creates a fork and commit to the forked project" do
- expect do
- repository.create_dir(user, 'newdir',
- message: 'Create newdir', branch_name: 'patch',
- start_branch_name: 'master', start_project: forked_project)
- end.to change { repository.count_commits(ref: 'master') }.by(0)
+ expect {
+ repository.create_dir(user, "newdir",
+ message: "Create newdir", branch_name: "patch",
+ start_branch_name: "master", start_project: forked_project)
+ }.to change { repository.count_commits(ref: "master") }.by(0)
- expect(repository.branch_exists?('patch')).to be_truthy
- expect(forked_project.repository.branch_exists?('patch')).to be_falsy
+ expect(repository.branch_exists?("patch")).to be_truthy
+ expect(forked_project.repository.branch_exists?("patch")).to be_falsy
- newdir = repository.tree('patch', 'newdir')
- expect(newdir.path).to eq('newdir')
+ newdir = repository.tree("patch", "newdir")
+ expect(newdir.path).to eq("newdir")
end
end
context "when an author is specified" do
it "uses the given email/name to set the commit's author" do
- expect do
- repository.create_dir(user, 'newdir',
- message: 'Add newdir',
- branch_name: 'master',
+ expect {
+ repository.create_dir(user, "newdir",
+ message: "Add newdir",
+ branch_name: "master",
author_email: author_email, author_name: author_name)
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ }.to change { repository.count_commits(ref: "master") }.by(1)
last_commit = repository.commit
@@ -569,48 +569,48 @@ describe Repository do
end
describe "#create_file" do
- it 'commits new file successfully' do
- expect do
- repository.create_file(user, 'NEWCHANGELOG', 'Changelog!',
- message: 'Create changelog',
- branch_name: 'master')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ it "commits new file successfully" do
+ expect {
+ repository.create_file(user, "NEWCHANGELOG", "Changelog!",
+ message: "Create changelog",
+ branch_name: "master")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- blob = repository.blob_at('master', 'NEWCHANGELOG')
+ blob = repository.blob_at("master", "NEWCHANGELOG")
- expect(blob.data).to eq('Changelog!')
+ expect(blob.data).to eq("Changelog!")
end
- it 'creates new file and dir when file_path has a forward slash' do
- expect do
- repository.create_file(user, 'new_dir/new_file.txt', 'File!',
- message: 'Create new_file with new_dir',
- branch_name: 'master')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ it "creates new file and dir when file_path has a forward slash" do
+ expect {
+ repository.create_file(user, "new_dir/new_file.txt", "File!",
+ message: "Create new_file with new_dir",
+ branch_name: "master")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- expect(repository.tree('master', 'new_dir').path).to eq('new_dir')
- expect(repository.blob_at('master', 'new_dir/new_file.txt').data).to eq('File!')
+ expect(repository.tree("master", "new_dir").path).to eq("new_dir")
+ expect(repository.blob_at("master", "new_dir/new_file.txt").data).to eq("File!")
end
- it 'respects the autocrlf setting' do
- repository.create_file(user, 'hello.txt', "Hello,\r\nWorld",
- message: 'Add hello world',
- branch_name: 'master')
+ it "respects the autocrlf setting" do
+ repository.create_file(user, "hello.txt", "Hello,\r\nWorld",
+ message: "Add hello world",
+ branch_name: "master")
- blob = repository.blob_at('master', 'hello.txt')
+ blob = repository.blob_at("master", "hello.txt")
expect(blob.data).to eq("Hello,\nWorld")
end
context "when an author is specified" do
it "uses the given email/name to set the commit's author" do
- expect do
- repository.create_file(user, 'NEWREADME', 'README!',
- message: 'Add README',
- branch_name: 'master',
- author_email: author_email,
- author_name: author_name)
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ expect {
+ repository.create_file(user, "NEWREADME", "README!",
+ message: "Add README",
+ branch_name: "master",
+ author_email: author_email,
+ author_name: author_name)
+ }.to change { repository.count_commits(ref: "master") }.by(1)
last_commit = repository.commit
@@ -621,42 +621,42 @@ describe Repository do
end
describe "#update_file" do
- it 'updates file successfully' do
- expect do
- repository.update_file(user, 'CHANGELOG', 'Changelog!',
- message: 'Update changelog',
- branch_name: 'master')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ it "updates file successfully" do
+ expect {
+ repository.update_file(user, "CHANGELOG", "Changelog!",
+ message: "Update changelog",
+ branch_name: "master")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- blob = repository.blob_at('master', 'CHANGELOG')
+ blob = repository.blob_at("master", "CHANGELOG")
- expect(blob.data).to eq('Changelog!')
+ expect(blob.data).to eq("Changelog!")
end
- it 'updates filename successfully' do
- expect do
- repository.update_file(user, 'NEWLICENSE', 'Copyright!',
- branch_name: 'master',
- previous_path: 'LICENSE',
- message: 'Changes filename')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ it "updates filename successfully" do
+ expect {
+ repository.update_file(user, "NEWLICENSE", "Copyright!",
+ branch_name: "master",
+ previous_path: "LICENSE",
+ message: "Changes filename")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- files = repository.ls_files('master')
+ files = repository.ls_files("master")
- expect(files).not_to include('LICENSE')
- expect(files).to include('NEWLICENSE')
+ expect(files).not_to include("LICENSE")
+ expect(files).to include("NEWLICENSE")
end
context "when an author is specified" do
it "uses the given email/name to set the commit's author" do
- expect do
- repository.update_file(user, 'README', 'Updated README!',
- branch_name: 'master',
- previous_path: 'README',
- message: 'Update README',
- author_email: author_email,
- author_name: author_name)
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ expect {
+ repository.update_file(user, "README", "Updated README!",
+ branch_name: "master",
+ previous_path: "README",
+ message: "Update README",
+ author_email: author_email,
+ author_name: author_name)
+ }.to change { repository.count_commits(ref: "master") }.by(1)
last_commit = repository.commit
@@ -667,22 +667,22 @@ describe Repository do
end
describe "#delete_file" do
- it 'removes file successfully' do
- expect do
- repository.delete_file(user, 'README',
- message: 'Remove README', branch_name: 'master')
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ it "removes file successfully" do
+ expect {
+ repository.delete_file(user, "README",
+ message: "Remove README", branch_name: "master")
+ }.to change { repository.count_commits(ref: "master") }.by(1)
- expect(repository.blob_at('master', 'README')).to be_nil
+ expect(repository.blob_at("master", "README")).to be_nil
end
context "when an author is specified" do
it "uses the given email/name to set the commit's author" do
- expect do
- repository.delete_file(user, 'README',
- message: 'Remove README', branch_name: 'master',
+ expect {
+ repository.delete_file(user, "README",
+ message: "Remove README", branch_name: "master",
author_email: author_email, author_name: author_name)
- end.to change { repository.count_commits(ref: 'master') }.by(1)
+ }.to change { repository.count_commits(ref: "master") }.by(1)
last_commit = repository.commit
@@ -693,45 +693,45 @@ describe Repository do
end
describe "search_files_by_content" do
- let(:results) { repository.search_files_by_content('feature', 'master') }
+ let(:results) { repository.search_files_by_content("feature", "master") }
subject { results }
it { is_expected.to be_an Array }
- it 'regex-escapes the query string' do
- results = repository.search_files_by_content("test\\", 'master')
+ it "regex-escapes the query string" do
+ results = repository.search_files_by_content("test\\", "master")
- expect(results.first).not_to start_with('fatal:')
+ expect(results.first).not_to start_with("fatal:")
end
- it 'properly handles an unmatched parenthesis' do
- results = repository.search_files_by_content("test(", 'master')
+ it "properly handles an unmatched parenthesis" do
+ results = repository.search_files_by_content("test(", "master")
- expect(results.first).not_to start_with('fatal:')
+ expect(results.first).not_to start_with("fatal:")
end
- it 'properly handles when query is not present' do
- results = repository.search_files_by_content('', 'master')
+ it "properly handles when query is not present" do
+ results = repository.search_files_by_content("", "master")
expect(results).to match_array([])
end
- it 'properly handles query when repo is empty' do
+ it "properly handles query when repo is empty" do
repository = create(:project, :empty_repo).repository
- results = repository.search_files_by_content('test', 'master')
+ results = repository.search_files_by_content("test", "master")
expect(results).to match_array([])
end
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error do
- broken_repository.search_files_by_content('feature', 'master')
+ broken_repository.search_files_by_content("feature", "master")
end
end
end
- describe 'result' do
+ describe "result" do
subject { results.first }
it { is_expected.to be_an String }
@@ -740,92 +740,92 @@ describe Repository do
end
describe "search_files_by_name" do
- let(:results) { repository.search_files_by_name('files', 'master') }
+ let(:results) { repository.search_files_by_name("files", "master") }
- it 'returns result' do
- expect(results.first).to eq('files/html/500.html')
+ it "returns result" do
+ expect(results.first).to eq("files/html/500.html")
end
- it 'ignores leading slashes' do
- results = repository.search_files_by_name('/files', 'master')
+ it "ignores leading slashes" do
+ results = repository.search_files_by_name("/files", "master")
- expect(results.first).to eq('files/html/500.html')
+ expect(results.first).to eq("files/html/500.html")
end
- it 'properly handles when query is only slashes' do
- results = repository.search_files_by_name('//', 'master')
+ it "properly handles when query is only slashes" do
+ results = repository.search_files_by_name("//", "master")
expect(results).to match_array([])
end
- it 'properly handles when query is not present' do
- results = repository.search_files_by_name('', 'master')
+ it "properly handles when query is not present" do
+ results = repository.search_files_by_name("", "master")
expect(results).to match_array([])
end
- it 'properly handles query when repo is empty' do
+ it "properly handles query when repo is empty" do
repository = create(:project, :empty_repo).repository
- results = repository.search_files_by_name('test', 'master')
+ results = repository.search_files_by_name("test", "master")
expect(results).to match_array([])
end
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
- expect_to_raise_storage_error { broken_repository.search_files_by_name('files', 'master') }
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
+ expect_to_raise_storage_error { broken_repository.search_files_by_name("files", "master") }
end
end
end
- describe '#async_remove_remote' do
+ describe "#async_remove_remote" do
before do
- masterrev = repository.find_branch('master').dereferenced_target
- create_remote_branch('joe', 'remote_branch', masterrev)
+ masterrev = repository.find_branch("master").dereferenced_target
+ create_remote_branch("joe", "remote_branch", masterrev)
end
- context 'when worker is scheduled successfully' do
+ context "when worker is scheduled successfully" do
before do
- masterrev = repository.find_branch('master').dereferenced_target
- create_remote_branch('remote_name', 'remote_branch', masterrev)
+ masterrev = repository.find_branch("master").dereferenced_target
+ create_remote_branch("remote_name", "remote_branch", masterrev)
- allow(RepositoryRemoveRemoteWorker).to receive(:perform_async).and_return('1234')
+ allow(RepositoryRemoveRemoteWorker).to receive(:perform_async).and_return("1234")
end
- it 'returns job_id' do
- expect(repository.async_remove_remote('joe')).to eq('1234')
+ it "returns job_id" do
+ expect(repository.async_remove_remote("joe")).to eq("1234")
end
end
- context 'when worker does not schedule successfully' do
+ context "when worker does not schedule successfully" do
before do
allow(RepositoryRemoveRemoteWorker).to receive(:perform_async).and_return(nil)
end
- it 'returns nil' do
+ it "returns nil" do
expect(Rails.logger).to receive(:info).with("Remove remote job failed to create for #{project.id} with remote name joe.")
- expect(repository.async_remove_remote('joe')).to be_nil
+ expect(repository.async_remove_remote("joe")).to be_nil
end
end
end
- describe '#fetch_ref' do
+ describe "#fetch_ref" do
let(:broken_repository) { create(:project, :broken_storage).repository }
- describe 'when storage is broken', :broken_storage do
- it 'should raise a storage error' do
+ describe "when storage is broken", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error do
- broken_repository.fetch_ref(broken_repository, source_ref: '1', target_ref: '2')
+ broken_repository.fetch_ref(broken_repository, source_ref: "1", target_ref: "2")
end
end
end
end
- describe '#create_ref' do
- it 'redirects the call to write_ref' do
- ref, ref_path = '1', '2'
+ describe "#create_ref" do
+ it "redirects the call to write_ref" do
+ ref, ref_path = "1", "2"
expect(repository.raw_repository).to receive(:write_ref).with(ref_path, ref)
@@ -834,241 +834,243 @@ describe Repository do
end
describe "#changelog", :use_clean_rails_memory_store_caching do
- it 'accepts changelog' do
- expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changelog')])
+ it "accepts changelog" do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new("changelog")])
- expect(repository.changelog.path).to eq('changelog')
+ expect(repository.changelog.path).to eq("changelog")
end
- it 'accepts news instead of changelog' do
- expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('news')])
+ it "accepts news instead of changelog" do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new("news")])
- expect(repository.changelog.path).to eq('news')
+ expect(repository.changelog.path).to eq("news")
end
- it 'accepts history instead of changelog' do
- expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('history')])
+ it "accepts history instead of changelog" do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new("history")])
- expect(repository.changelog.path).to eq('history')
+ expect(repository.changelog.path).to eq("history")
end
- it 'accepts changes instead of changelog' do
- expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('changes')])
+ it "accepts changes instead of changelog" do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new("changes")])
- expect(repository.changelog.path).to eq('changes')
+ expect(repository.changelog.path).to eq("changes")
end
- it 'is case-insensitive' do
- expect(repository.tree).to receive(:blobs).and_return([TestBlob.new('CHANGELOG')])
+ it "is case-insensitive" do
+ expect(repository.tree).to receive(:blobs).and_return([TestBlob.new("CHANGELOG")])
- expect(repository.changelog.path).to eq('CHANGELOG')
+ expect(repository.changelog.path).to eq("CHANGELOG")
end
end
describe "#license_blob", :use_clean_rails_memory_store_caching do
before do
repository.delete_file(
- user, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master')
+ user, "LICENSE", message: "Remove LICENSE", branch_name: "master"
+ )
end
- it 'handles when HEAD points to non-existent ref' do
+ it "handles when HEAD points to non-existent ref" do
repository.create_file(
- user, 'LICENSE', 'Copyright!',
- message: 'Add LICENSE', branch_name: 'master')
+ user, "LICENSE", "Copyright!",
+ message: "Add LICENSE", branch_name: "master"
+ )
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.license_blob).to be_nil
end
- it 'looks in the root_ref only' do
- repository.delete_file(user, 'LICENSE',
- message: 'Remove LICENSE', branch_name: 'markdown')
- repository.create_file(user, 'LICENSE',
- Licensee::License.new('mit').content,
- message: 'Add LICENSE', branch_name: 'markdown')
+ it "looks in the root_ref only" do
+ repository.delete_file(user, "LICENSE",
+ message: "Remove LICENSE", branch_name: "markdown")
+ repository.create_file(user, "LICENSE",
+ Licensee::License.new("mit").content,
+ message: "Add LICENSE", branch_name: "markdown")
expect(repository.license_blob).to be_nil
end
- it 'detects license file with no recognizable open-source license content' do
- repository.create_file(user, 'LICENSE', 'Copyright!',
- message: 'Add LICENSE', branch_name: 'master')
+ it "detects license file with no recognizable open-source license content" do
+ repository.create_file(user, "LICENSE", "Copyright!",
+ message: "Add LICENSE", branch_name: "master")
- expect(repository.license_blob.path).to eq('LICENSE')
+ expect(repository.license_blob.path).to eq("LICENSE")
end
%w[LICENSE LICENCE LiCensE LICENSE.md LICENSE.foo COPYING COPYING.md].each do |filename|
it "detects '#{filename}'" do
repository.create_file(user, filename,
- Licensee::License.new('mit').content,
- message: "Add #{filename}", branch_name: 'master')
+ Licensee::License.new("mit").content,
+ message: "Add #{filename}", branch_name: "master")
expect(repository.license_blob.name).to eq(filename)
end
end
end
- describe '#license_key', :use_clean_rails_memory_store_caching do
+ describe "#license_key", :use_clean_rails_memory_store_caching do
before do
- repository.delete_file(user, 'LICENSE',
- message: 'Remove LICENSE', branch_name: 'master')
+ repository.delete_file(user, "LICENSE",
+ message: "Remove LICENSE", branch_name: "master")
end
- it 'returns nil when no license is detected' do
+ it "returns nil when no license is detected" do
expect(repository.license_key).to be_nil
end
- it 'returns nil when the repository does not exist' do
+ it "returns nil when the repository does not exist" do
expect(repository).to receive(:exists?).and_return(false)
expect(repository.license_key).to be_nil
end
- it 'returns nil when the content is not recognizable' do
- repository.create_file(user, 'LICENSE', 'Gitlab B.V.',
- message: 'Add LICENSE', branch_name: 'master')
+ it "returns nil when the content is not recognizable" do
+ repository.create_file(user, "LICENSE", "Gitlab B.V.",
+ message: "Add LICENSE", branch_name: "master")
expect(repository.license_key).to be_nil
end
- it 'returns nil when the commit SHA does not exist' do
- allow(repository.head_commit).to receive(:sha).and_return('1' * 40)
+ it "returns nil when the commit SHA does not exist" do
+ allow(repository.head_commit).to receive(:sha).and_return("1" * 40)
expect(repository.license_key).to be_nil
end
- it 'returns nil when master does not exist' do
- repository.rm_branch(user, 'master')
+ it "returns nil when master does not exist" do
+ repository.rm_branch(user, "master")
expect(repository.license_key).to be_nil
end
- it 'returns the license key' do
- repository.create_file(user, 'LICENSE',
- Licensee::License.new('mit').content,
- message: 'Add LICENSE', branch_name: 'master')
+ it "returns the license key" do
+ repository.create_file(user, "LICENSE",
+ Licensee::License.new("mit").content,
+ message: "Add LICENSE", branch_name: "master")
- expect(repository.license_key).to eq('mit')
+ expect(repository.license_key).to eq("mit")
end
end
- describe '#license' do
+ describe "#license" do
before do
- repository.delete_file(user, 'LICENSE',
- message: 'Remove LICENSE', branch_name: 'master')
+ repository.delete_file(user, "LICENSE",
+ message: "Remove LICENSE", branch_name: "master")
end
- it 'returns nil when no license is detected' do
+ it "returns nil when no license is detected" do
expect(repository.license).to be_nil
end
- it 'returns nil when the repository does not exist' do
+ it "returns nil when the repository does not exist" do
expect(repository).to receive(:exists?).and_return(false)
expect(repository.license).to be_nil
end
- it 'returns nil when the content is not recognizable' do
- repository.create_file(user, 'LICENSE', 'Gitlab B.V.',
- message: 'Add LICENSE', branch_name: 'master')
+ it "returns nil when the content is not recognizable" do
+ repository.create_file(user, "LICENSE", "Gitlab B.V.",
+ message: "Add LICENSE", branch_name: "master")
expect(repository.license).to be_nil
end
- it 'returns the license' do
- license = Licensee::License.new('mit')
- repository.create_file(user, 'LICENSE',
+ it "returns the license" do
+ license = Licensee::License.new("mit")
+ repository.create_file(user, "LICENSE",
license.content,
- message: 'Add LICENSE', branch_name: 'master')
+ message: "Add LICENSE", branch_name: "master")
expect(repository.license).to eq(license)
end
end
describe "#gitlab_ci_yml", :use_clean_rails_memory_store_caching do
- it 'returns valid file' do
- files = [TestBlob.new('file'), TestBlob.new('.gitlab-ci.yml'), TestBlob.new('copying')]
+ it "returns valid file" do
+ files = [TestBlob.new("file"), TestBlob.new(".gitlab-ci.yml"), TestBlob.new("copying")]
expect(repository.tree).to receive(:blobs).and_return(files)
- expect(repository.gitlab_ci_yml.path).to eq('.gitlab-ci.yml')
+ expect(repository.gitlab_ci_yml.path).to eq(".gitlab-ci.yml")
end
- it 'returns nil if not exists' do
+ it "returns nil if not exists" do
expect(repository.tree).to receive(:blobs).and_return([])
expect(repository.gitlab_ci_yml).to be_nil
end
- it 'returns nil for empty repository' do
+ it "returns nil for empty repository" do
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.gitlab_ci_yml).to be_nil
end
end
- describe '#ambiguous_ref?' do
- let(:ref) { 'ref' }
+ describe "#ambiguous_ref?" do
+ let(:ref) { "ref" }
subject { repository.ambiguous_ref?(ref) }
- context 'when ref is ambiguous' do
+ context "when ref is ambiguous" do
before do
- repository.add_tag(project.creator, ref, 'master')
- repository.add_branch(project.creator, ref, 'master')
+ repository.add_tag(project.creator, ref, "master")
+ repository.add_branch(project.creator, ref, "master")
end
- it 'should be true' do
+ it "should be true" do
is_expected.to eq(true)
end
end
- context 'when ref is not ambiguous' do
+ context "when ref is not ambiguous" do
before do
- repository.add_tag(project.creator, ref, 'master')
+ repository.add_tag(project.creator, ref, "master")
end
- it 'should be false' do
+ it "should be false" do
is_expected.to eq(false)
end
end
end
- describe '#expand_ref' do
- let(:ref) { 'ref' }
+ describe "#expand_ref" do
+ let(:ref) { "ref" }
subject { repository.expand_ref(ref) }
- context 'when ref is not tag or branch name' do
- let(:ref) { 'refs/heads/master' }
+ context "when ref is not tag or branch name" do
+ let(:ref) { "refs/heads/master" }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to eq(nil)
end
end
- context 'when ref is tag name' do
+ context "when ref is tag name" do
before do
- repository.add_tag(project.creator, ref, 'master')
+ repository.add_tag(project.creator, ref, "master")
end
- it 'returns the tag ref' do
+ it "returns the tag ref" do
is_expected.to eq("refs/tags/#{ref}")
end
end
- context 'when ref is branch name' do
+ context "when ref is branch name" do
before do
- repository.add_branch(project.creator, ref, 'master')
+ repository.add_branch(project.creator, ref, "master")
end
- it 'returns the branch ref' do
+ it "returns the branch ref" do
is_expected.to eq("refs/heads/#{ref}")
end
end
end
- describe '#add_branch' do
- let(:branch_name) { 'new_feature' }
- let(:target) { 'master' }
+ describe "#add_branch" do
+ let(:branch_name) { "new_feature" }
+ let(:target) { "master" }
subject { repository.add_branch(user, branch_name, target) }
@@ -1080,13 +1082,13 @@ describe Repository do
subject
end
- it 'creates_the_branch' do
+ it "creates_the_branch" do
expect(subject.name).to eq(branch_name)
expect(repository.find_branch(branch_name)).not_to be_nil
end
- context 'with a non-existing target' do
- let(:target) { 'fake-target' }
+ context "with a non-existing target" do
+ let(:target) { "fake-target" }
it "returns false and doesn't create the branch" do
expect(subject).to be(false)
@@ -1095,66 +1097,66 @@ describe Repository do
end
end
- describe '#exists?' do
- it 'returns true when a repository exists' do
+ describe "#exists?" do
+ it "returns true when a repository exists" do
expect(repository.exists?).to be(true)
end
- it 'returns false if no full path can be constructed' do
+ it "returns false if no full path can be constructed" do
allow(repository).to receive(:full_path).and_return(nil)
expect(repository.exists?).to be(false)
end
- context 'with broken storage', :broken_storage do
- it 'should raise a storage error' do
+ context "with broken storage", :broken_storage do
+ it "should raise a storage error" do
expect_to_raise_storage_error { broken_repository.exists? }
end
end
- context 'asymmetric caching', :use_clean_rails_memory_store_caching, :request_store do
+ context "asymmetric caching", :use_clean_rails_memory_store_caching, :request_store do
let(:cache) { repository.send(:cache) }
let(:request_store_cache) { repository.send(:request_store_cache) }
- context 'when it returns true' do
+ context "when it returns true" do
before do
expect(repository.raw_repository).to receive(:exists?).once.and_return(true)
end
- it 'caches the output in RequestStore' do
- expect do
+ it "caches the output in RequestStore" do
+ expect {
repository.exists?
- end.to change { request_store_cache.read(:exists?) }.from(nil).to(true)
+ }.to change { request_store_cache.read(:exists?) }.from(nil).to(true)
end
- it 'caches the output in RepositoryCache' do
- expect do
+ it "caches the output in RepositoryCache" do
+ expect {
repository.exists?
- end.to change { cache.read(:exists?) }.from(nil).to(true)
+ }.to change { cache.read(:exists?) }.from(nil).to(true)
end
end
- context 'when it returns false' do
+ context "when it returns false" do
before do
expect(repository.raw_repository).to receive(:exists?).once.and_return(false)
end
- it 'caches the output in RequestStore' do
- expect do
+ it "caches the output in RequestStore" do
+ expect {
repository.exists?
- end.to change { request_store_cache.read(:exists?) }.from(nil).to(false)
+ }.to change { request_store_cache.read(:exists?) }.from(nil).to(false)
end
- it 'does NOT cache the output in RepositoryCache' do
- expect do
+ it "does NOT cache the output in RepositoryCache" do
+ expect {
repository.exists?
- end.not_to change { cache.read(:exists?) }.from(nil)
+ }.not_to change { cache.read(:exists?) }.from(nil)
end
end
end
end
- describe '#has_visible_content?' do
+ describe "#has_visible_content?" do
before do
# If raw_repository.has_visible_content? gets called more than once then
# caching is broken. We don't want that.
@@ -1163,20 +1165,20 @@ describe Repository do
.and_return(result)
end
- context 'when true' do
+ context "when true" do
let(:result) { true }
- it 'returns true and caches it' do
+ it "returns true and caches it" do
expect(repository.has_visible_content?).to eq(true)
# Second call hits the cache
expect(repository.has_visible_content?).to eq(true)
end
end
- context 'when false' do
+ context "when false" do
let(:result) { false }
- it 'returns false and caches it' do
+ it "returns false and caches it" do
expect(repository.has_visible_content?).to eq(false)
# Second call hits the cache
expect(repository.has_visible_content?).to eq(false)
@@ -1184,28 +1186,28 @@ describe Repository do
end
end
- describe '#branch_exists?' do
- it 'uses branch_names' do
- allow(repository).to receive(:branch_names).and_return(['foobar'])
+ describe "#branch_exists?" do
+ it "uses branch_names" do
+ allow(repository).to receive(:branch_names).and_return(["foobar"])
- expect(repository.branch_exists?('foobar')).to eq(true)
- expect(repository.branch_exists?('master')).to eq(false)
+ expect(repository.branch_exists?("foobar")).to eq(true)
+ expect(repository.branch_exists?("master")).to eq(false)
end
end
- describe '#tag_exists?' do
- it 'uses tag_names' do
- allow(repository).to receive(:tag_names).and_return(['foobar'])
+ describe "#tag_exists?" do
+ it "uses tag_names" do
+ allow(repository).to receive(:tag_names).and_return(["foobar"])
- expect(repository.tag_exists?('foobar')).to eq(true)
- expect(repository.tag_exists?('master')).to eq(false)
+ expect(repository.tag_exists?("foobar")).to eq(true)
+ expect(repository.tag_exists?("master")).to eq(false)
end
end
- describe '#branch_names', :use_clean_rails_memory_store_caching do
- let(:fake_branch_names) { ['foobar'] }
+ describe "#branch_names", :use_clean_rails_memory_store_caching do
+ let(:fake_branch_names) { ["foobar"] }
- it 'gets cached across Repository instances' do
+ it "gets cached across Repository instances" do
allow(repository.raw_repository).to receive(:branch_names).once.and_return(fake_branch_names)
expect(repository.branch_names).to eq(fake_branch_names)
@@ -1218,18 +1220,18 @@ describe Repository do
end
end
- describe '#empty?' do
+ describe "#empty?" do
let(:empty_repository) { create(:project_empty_repo).repository }
- it 'returns true for an empty repository' do
+ it "returns true for an empty repository" do
expect(empty_repository).to be_empty
end
- it 'returns false for a non-empty repository' do
+ it "returns false for a non-empty repository" do
expect(repository).not_to be_empty
end
- it 'caches the output' do
+ it "caches the output" do
expect(repository.raw_repository).to receive(:has_visible_content?).once
repository.empty?
@@ -1237,62 +1239,62 @@ describe Repository do
end
end
- describe '#blobs_at' do
+ describe "#blobs_at" do
let(:empty_repository) { create(:project_empty_repo).repository }
- it 'returns empty array for an empty repository' do
+ it "returns empty array for an empty repository" do
# rubocop:disable Style/WordArray
- expect(empty_repository.blobs_at(['master', 'foobar'])).to eq([])
+ expect(empty_repository.blobs_at(["master", "foobar"])).to eq([])
# rubocop:enable Style/WordArray
end
- it 'returns blob array for a non-empty repository' do
- repository.create_file(User.last, 'foobar', 'CONTENT', message: 'message', branch_name: 'master')
+ it "returns blob array for a non-empty repository" do
+ repository.create_file(User.last, "foobar", "CONTENT", message: "message", branch_name: "master")
# rubocop:disable Style/WordArray
- blobs = repository.blobs_at([['master', 'foobar']])
+ blobs = repository.blobs_at([["master", "foobar"]])
# rubocop:enable Style/WordArray
- expect(blobs.first.name).to eq('foobar')
+ expect(blobs.first.name).to eq("foobar")
expect(blobs.size).to eq(1)
end
end
- describe '#root_ref' do
- it 'returns a branch name' do
+ describe "#root_ref" do
+ it "returns a branch name" do
expect(repository.root_ref).to be_an_instance_of(String)
end
- it 'caches the output' do
+ it "caches the output" do
expect(repository.raw_repository).to receive(:root_ref)
.once
- .and_return('master')
+ .and_return("master")
repository.root_ref
repository.root_ref
end
end
- describe '#expire_root_ref_cache' do
- it 'expires the root reference cache' do
+ describe "#expire_root_ref_cache" do
+ it "expires the root reference cache" do
repository.root_ref
expect(repository.raw_repository).to receive(:root_ref)
.once
- .and_return('foo')
+ .and_return("foo")
repository.expire_root_ref_cache
- expect(repository.root_ref).to eq('foo')
+ expect(repository.root_ref).to eq("foo")
end
end
- describe '#expire_branch_cache' do
+ describe "#expire_branch_cache" do
# This method is private but we need it for testing purposes. Sadly there's
# no other proper way of testing caching operations.
let(:cache) { repository.send(:cache) }
- it 'expires the cache for all branches' do
+ it "expires the cache for all branches" do
expect(cache).to receive(:expire)
.at_least(repository.branches.length * 2)
.times
@@ -1300,7 +1302,7 @@ describe Repository do
repository.expire_branch_cache
end
- it 'expires the cache for all branches when the root branch is given' do
+ it "expires the cache for all branches when the root branch is given" do
expect(cache).to receive(:expire)
.at_least(repository.branches.length * 2)
.times
@@ -1308,17 +1310,17 @@ describe Repository do
repository.expire_branch_cache(repository.root_ref)
end
- it 'expires the cache for a specific branch' do
+ it "expires the cache for a specific branch" do
expect(cache).to receive(:expire).twice
- repository.expire_branch_cache('foo')
+ repository.expire_branch_cache("foo")
end
end
- describe '#expire_emptiness_caches' do
+ describe "#expire_emptiness_caches" do
let(:cache) { repository.send(:cache) }
- it 'expires the caches for an empty repository' do
+ it "expires the caches for an empty repository" do
allow(repository).to receive(:empty?).and_return(true)
expect(cache).to receive(:expire).with(:has_visible_content?)
@@ -1326,7 +1328,7 @@ describe Repository do
repository.expire_emptiness_caches
end
- it 'does not expire the cache for a non-empty repository' do
+ it "does not expire the cache for a non-empty repository" do
allow(repository).to receive(:empty?).and_return(false)
expect(cache).not_to receive(:expire).with(:has_visible_content?)
@@ -1334,35 +1336,35 @@ describe Repository do
repository.expire_emptiness_caches
end
- it 'expires the memoized repository cache' do
+ it "expires the memoized repository cache" do
allow(repository.raw_repository).to receive(:expire_has_local_branches_cache).and_call_original
repository.expire_emptiness_caches
end
end
- describe 'skip_merges option' do
+ describe "skip_merges option" do
subject { repository.commits(Gitlab::Git::BRANCH_REF_PREFIX + "'test'", limit: 100, skip_merges: true).map { |k| k.id } }
- it { is_expected.not_to include('e56497bb5f03a90a51293fc6d516788730953899') }
+ it { is_expected.not_to include("e56497bb5f03a90a51293fc6d516788730953899") }
end
- describe '#merge' do
- let(:merge_request) { create(:merge_request, source_branch: 'feature', target_branch: 'master', source_project: project) }
+ describe "#merge" do
+ let(:merge_request) { create(:merge_request, source_branch: "feature", target_branch: "master", source_project: project) }
let(:message) { 'Test \r\n\r\n message' }
- it 'merges the code and returns the commit id' do
+ it "merges the code and returns the commit id" do
expect(merge_commit).to be_present
- expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
+ expect(repository.blob_at(merge_commit.id, "files/ruby/feature.rb")).to be_present
end
- it 'sets the `in_progress_merge_commit_sha` flag for the given merge request' do
+ it "sets the `in_progress_merge_commit_sha` flag for the given merge request" do
merge_commit_id = merge(repository, user, merge_request, message)
expect(merge_request.in_progress_merge_commit_sha).to eq(merge_commit_id)
end
- it 'removes carriage returns from commit message' do
+ it "removes carriage returns from commit message" do
merge_commit_id = merge(repository, user, merge_request, message)
expect(repository.commit(merge_commit_id).message).to eq(message.delete("\r"))
@@ -1373,199 +1375,199 @@ describe Repository do
end
end
- describe '#merge_to_ref' do
+ describe "#merge_to_ref" do
let(:merge_request) do
- create(:merge_request, source_branch: 'feature',
- target_branch: 'master',
+ create(:merge_request, source_branch: "feature",
+ target_branch: "master",
source_project: project)
end
- it 'writes merge of source and target to MR merge_ref_path' do
+ it "writes merge of source and target to MR merge_ref_path" do
merge_commit_id = repository.merge_to_ref(user,
- merge_request.diff_head_sha,
- merge_request,
- merge_request.merge_ref_path,
- 'Custom message')
+ merge_request.diff_head_sha,
+ merge_request,
+ merge_request.merge_ref_path,
+ "Custom message")
merge_commit = repository.commit(merge_commit_id)
- expect(merge_commit.message).to eq('Custom message')
+ expect(merge_commit.message).to eq("Custom message")
expect(merge_commit.author_name).to eq(user.name)
expect(merge_commit.author_email).to eq(user.commit_email)
- expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
+ expect(repository.blob_at(merge_commit.id, "files/ruby/feature.rb")).to be_present
end
end
- describe '#ff_merge' do
+ describe "#ff_merge" do
before do
- repository.add_branch(user, 'ff-target', 'feature~5')
+ repository.add_branch(user, "ff-target", "feature~5")
end
- it 'merges the code and return the commit id' do
- merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'ff-target', source_project: project)
+ it "merges the code and return the commit id" do
+ merge_request = create(:merge_request, source_branch: "feature", target_branch: "ff-target", source_project: project)
merge_commit_id = repository.ff_merge(user,
- merge_request.diff_head_sha,
- merge_request.target_branch,
- merge_request: merge_request)
+ merge_request.diff_head_sha,
+ merge_request.target_branch,
+ merge_request: merge_request)
merge_commit = repository.commit(merge_commit_id)
expect(merge_commit).to be_present
- expect(repository.blob_at(merge_commit.id, 'files/ruby/feature.rb')).to be_present
+ expect(repository.blob_at(merge_commit.id, "files/ruby/feature.rb")).to be_present
end
- it 'sets the `in_progress_merge_commit_sha` flag for the given merge request' do
- merge_request = create(:merge_request, source_branch: 'feature', target_branch: 'ff-target', source_project: project)
+ it "sets the `in_progress_merge_commit_sha` flag for the given merge request" do
+ merge_request = create(:merge_request, source_branch: "feature", target_branch: "ff-target", source_project: project)
merge_commit_id = repository.ff_merge(user,
- merge_request.diff_head_sha,
- merge_request.target_branch,
- merge_request: merge_request)
+ merge_request.diff_head_sha,
+ merge_request.target_branch,
+ merge_request: merge_request)
expect(merge_request.in_progress_merge_commit_sha).to eq(merge_commit_id)
end
end
- describe '#revert' do
- let(:new_image_commit) { repository.commit('33f3729a45c02fc67d00adb1b8bca394b0e761d9') }
- let(:update_image_commit) { repository.commit('2f63565e7aac07bcdadb654e253078b727143ec4') }
- let(:message) { 'revert message' }
+ describe "#revert" do
+ let(:new_image_commit) { repository.commit("33f3729a45c02fc67d00adb1b8bca394b0e761d9") }
+ let(:update_image_commit) { repository.commit("2f63565e7aac07bcdadb654e253078b727143ec4") }
+ let(:message) { "revert message" }
- context 'when there is a conflict' do
- it 'raises an error' do
- expect { repository.revert(user, new_image_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
+ context "when there is a conflict" do
+ it "raises an error" do
+ expect { repository.revert(user, new_image_commit, "master", message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
end
end
- context 'when commit was already reverted' do
- it 'raises an error' do
- repository.revert(user, update_image_commit, 'master', message)
+ context "when commit was already reverted" do
+ it "raises an error" do
+ repository.revert(user, update_image_commit, "master", message)
- expect { repository.revert(user, update_image_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
+ expect { repository.revert(user, update_image_commit, "master", message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
end
end
- context 'when commit can be reverted' do
- it 'reverts the changes' do
- expect(repository.revert(user, update_image_commit, 'master', message)).to be_truthy
+ context "when commit can be reverted" do
+ it "reverts the changes" do
+ expect(repository.revert(user, update_image_commit, "master", message)).to be_truthy
end
end
- context 'reverting a merge commit' do
- it 'reverts the changes' do
+ context "reverting a merge commit" do
+ it "reverts the changes" do
merge_commit
- expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).to be_present
+ expect(repository.blob_at_branch("master", "files/ruby/feature.rb")).to be_present
- repository.revert(user, merge_commit, 'master', message)
- expect(repository.blob_at_branch('master', 'files/ruby/feature.rb')).not_to be_present
+ repository.revert(user, merge_commit, "master", message)
+ expect(repository.blob_at_branch("master", "files/ruby/feature.rb")).not_to be_present
end
end
end
- describe '#cherry_pick' do
- let(:conflict_commit) { repository.commit('c642fe9b8b9f28f9225d7ea953fe14e74748d53b') }
- let(:pickable_commit) { repository.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
- let(:pickable_merge) { repository.commit('e56497bb5f03a90a51293fc6d516788730953899') }
- let(:message) { 'cherry-pick message' }
+ describe "#cherry_pick" do
+ let(:conflict_commit) { repository.commit("c642fe9b8b9f28f9225d7ea953fe14e74748d53b") }
+ let(:pickable_commit) { repository.commit("7d3b0f7cff5f37573aea97cebfd5692ea1689924") }
+ let(:pickable_merge) { repository.commit("e56497bb5f03a90a51293fc6d516788730953899") }
+ let(:message) { "cherry-pick message" }
- context 'when there is a conflict' do
- it 'raises an error' do
- expect { repository.cherry_pick(user, conflict_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
+ context "when there is a conflict" do
+ it "raises an error" do
+ expect { repository.cherry_pick(user, conflict_commit, "master", message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
end
end
- context 'when commit was already cherry-picked' do
- it 'raises an error' do
- repository.cherry_pick(user, pickable_commit, 'master', message)
+ context "when commit was already cherry-picked" do
+ it "raises an error" do
+ repository.cherry_pick(user, pickable_commit, "master", message)
- expect { repository.cherry_pick(user, pickable_commit, 'master', message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
+ expect { repository.cherry_pick(user, pickable_commit, "master", message) }.to raise_error(Gitlab::Git::Repository::CreateTreeError)
end
end
- context 'when commit can be cherry-picked' do
- it 'cherry-picks the changes' do
- expect(repository.cherry_pick(user, pickable_commit, 'master', message)).to be_truthy
+ context "when commit can be cherry-picked" do
+ it "cherry-picks the changes" do
+ expect(repository.cherry_pick(user, pickable_commit, "master", message)).to be_truthy
end
end
- context 'cherry-picking a merge commit' do
- it 'cherry-picks the changes' do
- expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).to be_nil
+ context "cherry-picking a merge commit" do
+ it "cherry-picks the changes" do
+ expect(repository.blob_at_branch("improve/awesome", "foo/bar/.gitkeep")).to be_nil
- cherry_pick_commit_sha = repository.cherry_pick(user, pickable_merge, 'improve/awesome', message)
+ cherry_pick_commit_sha = repository.cherry_pick(user, pickable_merge, "improve/awesome", message)
cherry_pick_commit_message = project.commit(cherry_pick_commit_sha).message
- expect(repository.blob_at_branch('improve/awesome', 'foo/bar/.gitkeep')).not_to be_nil
+ expect(repository.blob_at_branch("improve/awesome", "foo/bar/.gitkeep")).not_to be_nil
expect(cherry_pick_commit_message).to eq(message)
end
end
end
- describe '#before_delete' do
- describe 'when a repository does not exist' do
+ describe "#before_delete" do
+ describe "when a repository does not exist" do
before do
allow(repository).to receive(:exists?).and_return(false)
end
- it 'does not flush caches that depend on repository data' do
+ it "does not flush caches that depend on repository data" do
expect(repository).not_to receive(:expire_cache)
repository.before_delete
end
- it 'flushes the tags cache' do
+ it "flushes the tags cache" do
expect(repository).to receive(:expire_tags_cache)
repository.before_delete
end
- it 'flushes the branches cache' do
+ it "flushes the branches cache" do
expect(repository).to receive(:expire_branches_cache)
repository.before_delete
end
- it 'flushes the root ref cache' do
+ it "flushes the root ref cache" do
expect(repository).to receive(:expire_root_ref_cache)
repository.before_delete
end
- it 'flushes the emptiness caches' do
+ it "flushes the emptiness caches" do
expect(repository).to receive(:expire_emptiness_caches)
repository.before_delete
end
- it 'flushes the exists cache' do
+ it "flushes the exists cache" do
expect(repository).to receive(:expire_exists_cache).twice
repository.before_delete
end
end
- describe 'when a repository exists' do
+ describe "when a repository exists" do
before do
allow(repository).to receive(:exists?).and_return(true)
end
- it 'flushes the tags cache' do
+ it "flushes the tags cache" do
expect(repository).to receive(:expire_tags_cache)
repository.before_delete
end
- it 'flushes the branches cache' do
+ it "flushes the branches cache" do
expect(repository).to receive(:expire_branches_cache)
repository.before_delete
end
- it 'flushes the root ref cache' do
+ it "flushes the root ref cache" do
expect(repository).to receive(:expire_root_ref_cache)
repository.before_delete
end
- it 'flushes the emptiness caches' do
+ it "flushes the emptiness caches" do
expect(repository).to receive(:expire_emptiness_caches)
repository.before_delete
@@ -1573,22 +1575,22 @@ describe Repository do
end
end
- describe '#before_change_head' do
- it 'flushes the branch cache' do
+ describe "#before_change_head" do
+ it "flushes the branch cache" do
expect(repository).to receive(:expire_branch_cache)
repository.before_change_head
end
- it 'flushes the root ref cache' do
+ it "flushes the root ref cache" do
expect(repository).to receive(:expire_root_ref_cache)
repository.before_change_head
end
end
- describe '#after_change_head' do
- it 'flushes the method caches' do
+ describe "#after_change_head" do
+ it "flushes the method caches" do
expect(repository).to receive(:expire_method_caches).with([
:size,
:commit_count,
@@ -1610,15 +1612,15 @@ describe Repository do
:has_visible_content?,
:issue_template_names,
:merge_request_template_names,
- :xcode_project?
+ :xcode_project?,
])
repository.after_change_head
end
end
- describe '#before_push_tag' do
- it 'flushes the cache' do
+ describe "#before_push_tag" do
+ it "flushes the cache" do
expect(repository).to receive(:expire_statistics_caches)
expect(repository).to receive(:expire_emptiness_caches)
expect(repository).to receive(:expire_tags_cache)
@@ -1627,57 +1629,57 @@ describe Repository do
end
end
- describe '#after_import' do
- it 'flushes and builds the cache' do
+ describe "#after_import" do
+ it "flushes and builds the cache" do
expect(repository).to receive(:expire_content_cache)
repository.after_import
end
end
- describe '#after_push_commit' do
- it 'expires statistics caches' do
+ describe "#after_push_commit" do
+ it "expires statistics caches" do
expect(repository).to receive(:expire_statistics_caches)
.and_call_original
expect(repository).to receive(:expire_branch_cache)
- .with('master')
+ .with("master")
.and_call_original
- repository.after_push_commit('master')
+ repository.after_push_commit("master")
end
end
- describe '#after_create_branch' do
- it 'expires the branch caches' do
+ describe "#after_create_branch" do
+ it "expires the branch caches" do
expect(repository).to receive(:expire_branches_cache)
repository.after_create_branch
end
end
- describe '#after_remove_branch' do
- it 'expires the branch caches' do
+ describe "#after_remove_branch" do
+ it "expires the branch caches" do
expect(repository).to receive(:expire_branches_cache)
repository.after_remove_branch
end
end
- describe '#after_create' do
- it 'flushes the exists cache' do
+ describe "#after_create" do
+ it "flushes the exists cache" do
expect(repository).to receive(:expire_exists_cache)
repository.after_create
end
- it 'flushes the root ref cache' do
+ it "flushes the root ref cache" do
expect(repository).to receive(:expire_root_ref_cache)
repository.after_create
end
- it 'flushes the emptiness caches' do
+ it "flushes the emptiness caches" do
expect(repository).to receive(:expire_emptiness_caches)
repository.after_create
@@ -1685,17 +1687,17 @@ describe Repository do
end
describe "#copy_gitattributes" do
- it 'returns true with a valid ref' do
- expect(repository.copy_gitattributes('master')).to be_truthy
+ it "returns true with a valid ref" do
+ expect(repository.copy_gitattributes("master")).to be_truthy
end
- it 'returns false with an invalid ref' do
- expect(repository.copy_gitattributes('invalid')).to be_falsey
+ it "returns false with an invalid ref" do
+ expect(repository.copy_gitattributes("invalid")).to be_falsey
end
end
- describe '#before_remove_tag' do
- it 'flushes the tag cache' do
+ describe "#before_remove_tag" do
+ it "flushes the tag cache" do
expect(repository).to receive(:expire_tags_cache).and_call_original
expect(repository).to receive(:expire_statistics_caches).and_call_original
@@ -1703,8 +1705,8 @@ describe Repository do
end
end
- describe '#branch_count' do
- it 'returns the number of branches' do
+ describe "#branch_count" do
+ it "returns the number of branches" do
expect(repository.branch_count).to be_an(Integer)
rugged_count = rugged_repo(repository).branches.count
@@ -1713,8 +1715,8 @@ describe Repository do
end
end
- describe '#tag_count' do
- it 'returns the number of tags' do
+ describe "#tag_count" do
+ it "returns the number of tags" do
expect(repository.tag_count).to be_an(Integer)
rugged_count = rugged_repo(repository).tags.count
@@ -1723,154 +1725,154 @@ describe Repository do
end
end
- describe '#expire_branches_cache' do
- it 'expires the cache' do
+ describe "#expire_branches_cache" do
+ it "expires the cache" do
expect(repository).to receive(:expire_method_caches)
- .with(%i(branch_names branch_count has_visible_content?))
+ .with(%i[branch_names branch_count has_visible_content?])
.and_call_original
repository.expire_branches_cache
end
end
- describe '#expire_tags_cache' do
- it 'expires the cache' do
+ describe "#expire_tags_cache" do
+ it "expires the cache" do
expect(repository).to receive(:expire_method_caches)
- .with(%i(tag_names tag_count))
+ .with(%i[tag_names tag_count])
.and_call_original
repository.expire_tags_cache
end
end
- describe '#add_tag' do
+ describe "#add_tag" do
let(:user) { build_stubbed(:user) }
- context 'with a valid target' do
- it 'creates the tag' do
- repository.add_tag(user, '8.5', 'master', 'foo')
+ context "with a valid target" do
+ it "creates the tag" do
+ repository.add_tag(user, "8.5", "master", "foo")
- tag = repository.find_tag('8.5')
+ tag = repository.find_tag("8.5")
expect(tag).to be_present
- expect(tag.message).to eq('foo')
- expect(tag.dereferenced_target.id).to eq(repository.commit('master').id)
+ expect(tag.message).to eq("foo")
+ expect(tag.dereferenced_target.id).to eq(repository.commit("master").id)
end
- it 'returns a Gitlab::Git::Tag object' do
- tag = repository.add_tag(user, '8.5', 'master', 'foo')
+ it "returns a Gitlab::Git::Tag object" do
+ tag = repository.add_tag(user, "8.5", "master", "foo")
expect(tag).to be_a(Gitlab::Git::Tag)
end
end
- context 'with an invalid target' do
- it 'returns false' do
- expect(repository.add_tag(user, '8.5', 'bar', 'foo')).to be false
+ context "with an invalid target" do
+ it "returns false" do
+ expect(repository.add_tag(user, "8.5", "bar", "foo")).to be false
end
end
end
- describe '#rm_branch' do
- it 'removes a branch' do
+ describe "#rm_branch" do
+ it "removes a branch" do
expect(repository).to receive(:before_remove_branch)
expect(repository).to receive(:after_remove_branch)
- repository.rm_branch(user, 'feature')
+ repository.rm_branch(user, "feature")
end
- context 'when pre hooks failed' do
+ context "when pre hooks failed" do
before do
allow_any_instance_of(Gitlab::GitalyClient::OperationService)
.to receive(:user_delete_branch).and_raise(Gitlab::Git::PreReceiveError)
end
- it 'gets an error and does not delete the branch' do
- expect do
- repository.rm_branch(user, 'feature')
- end.to raise_error(Gitlab::Git::PreReceiveError)
+ it "gets an error and does not delete the branch" do
+ expect {
+ repository.rm_branch(user, "feature")
+ }.to raise_error(Gitlab::Git::PreReceiveError)
- expect(repository.find_branch('feature')).not_to be_nil
+ expect(repository.find_branch("feature")).not_to be_nil
end
end
end
- describe '#rm_tag' do
- it 'removes a tag' do
+ describe "#rm_tag" do
+ it "removes a tag" do
expect(repository).to receive(:before_remove_tag)
- repository.rm_tag(build_stubbed(:user), 'v1.1.0')
+ repository.rm_tag(build_stubbed(:user), "v1.1.0")
- expect(repository.find_tag('v1.1.0')).to be_nil
+ expect(repository.find_tag("v1.1.0")).to be_nil
end
end
- describe '#avatar' do
- it 'returns nil if repo does not exist' do
+ describe "#avatar" do
+ it "returns nil if repo does not exist" do
allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository)
expect(repository.avatar).to eq(nil)
end
- it 'returns the first avatar file found in the repository' do
+ it "returns the first avatar file found in the repository" do
expect(repository).to receive(:file_on_head)
.with(:avatar)
- .and_return(double(:tree, path: 'logo.png'))
+ .and_return(double(:tree, path: "logo.png"))
- expect(repository.avatar).to eq('logo.png')
+ expect(repository.avatar).to eq("logo.png")
end
- it 'caches the output' do
+ it "caches the output" do
expect(repository).to receive(:file_on_head)
.with(:avatar)
.once
- .and_return(double(:tree, path: 'logo.png'))
+ .and_return(double(:tree, path: "logo.png"))
- 2.times { expect(repository.avatar).to eq('logo.png') }
+ 2.times { expect(repository.avatar).to eq("logo.png") }
end
end
- describe '#expire_exists_cache' do
+ describe "#expire_exists_cache" do
let(:cache) { repository.send(:cache) }
let(:request_store_cache) { repository.send(:request_store_cache) }
- it 'expires the cache' do
+ it "expires the cache" do
expect(cache).to receive(:expire).with(:exists?)
repository.expire_exists_cache
end
- it 'expires the request store cache', :request_store do
+ it "expires the request store cache", :request_store do
expect(request_store_cache).to receive(:expire).with(:exists?)
repository.expire_exists_cache
end
end
- describe '#xcode_project?' do
+ describe "#xcode_project?" do
before do
allow(repository).to receive(:tree).with(:head).and_return(double(:tree, trees: [tree]))
end
- context 'when the root contains a *.xcodeproj directory' do
- let(:tree) { double(:tree, path: 'Foo.xcodeproj') }
+ context "when the root contains a *.xcodeproj directory" do
+ let(:tree) { double(:tree, path: "Foo.xcodeproj") }
- it 'returns true' do
+ it "returns true" do
expect(repository.xcode_project?).to be_truthy
end
end
- context 'when the root contains a *.xcworkspace directory' do
- let(:tree) { double(:tree, path: 'Foo.xcworkspace') }
+ context "when the root contains a *.xcworkspace directory" do
+ let(:tree) { double(:tree, path: "Foo.xcworkspace") }
- it 'returns true' do
+ it "returns true" do
expect(repository.xcode_project?).to be_truthy
end
end
- context 'when the root contains no Xcode config directory' do
- let(:tree) { double(:tree, path: 'Foo') }
+ context "when the root contains no Xcode config directory" do
+ let(:tree) { double(:tree, path: "Foo") }
- it 'returns false' do
+ it "returns false" do
expect(repository.xcode_project?).to be_falsey
end
end
@@ -1878,7 +1880,7 @@ describe Repository do
describe "#keep_around" do
it "does not fail if we attempt to reference bad commit" do
- expect(repository.kept_around?('abc1234')).to be_falsey
+ expect(repository.kept_around?("abc1234")).to be_falsey
end
it "stores a reference to the specified commit sha so it isn't garbage collected" do
@@ -1891,9 +1893,9 @@ describe Repository do
repository.keep_around(sample_commit.id)
ref = repository.send(:keep_around_ref_name, sample_commit.id)
- path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
File.join(repository.path, ref)
- end
+ }
# Corrupt the reference
File.truncate(path, 0)
@@ -1906,14 +1908,14 @@ describe Repository do
File.delete(path)
end
- context 'for multiple SHAs' do
- it 'skips non-existent SHAs' do
- repository.keep_around('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', sample_commit.id)
+ context "for multiple SHAs" do
+ it "skips non-existent SHAs" do
+ repository.keep_around("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", sample_commit.id)
expect(repository.kept_around?(sample_commit.id)).to be_truthy
end
- it 'skips already-kept-around SHAs' do
+ it "skips already-kept-around SHAs" do
repository.keep_around(sample_commit.id)
expect(repository.raw_repository).to receive(:write_ref).exactly(1).and_call_original
@@ -1925,11 +1927,11 @@ describe Repository do
end
end
- describe '#contribution_guide', :use_clean_rails_memory_store_caching do
- it 'returns and caches the output' do
+ describe "#contribution_guide", :use_clean_rails_memory_store_caching do
+ it "returns and caches the output" do
expect(repository).to receive(:file_on_head)
.with(:contributing)
- .and_return(Gitlab::Git::Tree.new(path: 'CONTRIBUTING.md'))
+ .and_return(Gitlab::Git::Tree.new(path: "CONTRIBUTING.md"))
.once
2.times do
@@ -1939,11 +1941,11 @@ describe Repository do
end
end
- describe '#gitignore', :use_clean_rails_memory_store_caching do
- it 'returns and caches the output' do
+ describe "#gitignore", :use_clean_rails_memory_store_caching do
+ it "returns and caches the output" do
expect(repository).to receive(:file_on_head)
.with(:gitignore)
- .and_return(Gitlab::Git::Tree.new(path: '.gitignore'))
+ .and_return(Gitlab::Git::Tree.new(path: ".gitignore"))
.once
2.times do
@@ -1952,60 +1954,60 @@ describe Repository do
end
end
- describe '#readme', :use_clean_rails_memory_store_caching do
- context 'with a non-existing repository' do
+ describe "#readme", :use_clean_rails_memory_store_caching do
+ context "with a non-existing repository" do
let(:project) { create(:project) }
- it 'returns nil' do
+ it "returns nil" do
expect(repository.readme).to be_nil
end
end
- context 'with an existing repository' do
- context 'when no README exists' do
+ context "with an existing repository" do
+ context "when no README exists" do
let(:project) { create(:project, :empty_repo) }
- it 'returns nil' do
+ it "returns nil" do
expect(repository.readme).to be_nil
end
end
- context 'when a README exists' do
+ context "when a README exists" do
let(:project) { create(:project, :repository) }
- it 'returns the README' do
+ it "returns the README" do
expect(repository.readme).to be_an_instance_of(ReadmeBlob)
end
end
end
end
- describe '#readme_path', :use_clean_rails_memory_store_caching do
- context 'with a non-existing repository' do
+ describe "#readme_path", :use_clean_rails_memory_store_caching do
+ context "with a non-existing repository" do
let(:project) { create(:project) }
- it 'returns nil' do
+ it "returns nil" do
expect(repository.readme_path).to be_nil
end
end
- context 'with an existing repository' do
- context 'when no README exists' do
+ context "with an existing repository" do
+ context "when no README exists" do
let(:project) { create(:project, :empty_repo) }
- it 'returns nil' do
+ it "returns nil" do
expect(repository.readme_path).to be_nil
end
end
- context 'when a README exists' do
+ context "when a README exists" do
let(:project) { create(:project, :repository) }
- it 'returns the README' do
+ it "returns the README" do
expect(repository.readme_path).to eq("README.md")
end
- it 'caches the response' do
+ it "caches the response" do
expect(repository).to receive(:readme).and_call_original.once
2.times do
@@ -2016,67 +2018,67 @@ describe Repository do
end
end
- describe '#expire_statistics_caches' do
- it 'expires the caches' do
+ describe "#expire_statistics_caches" do
+ it "expires the caches" do
expect(repository).to receive(:expire_method_caches)
- .with(%i(size commit_count))
+ .with(%i[size commit_count])
repository.expire_statistics_caches
end
end
- describe '#expire_all_method_caches' do
- it 'expires the caches of all methods' do
+ describe "#expire_all_method_caches" do
+ it "expires the caches of all methods" do
expect(repository).to receive(:expire_method_caches)
.with(Repository::CACHED_METHODS)
repository.expire_all_method_caches
end
- it 'all cache_method definitions are in the lists of method caches' do
- methods = repository.methods.map do |method|
+ it "all cache_method definitions are in the lists of method caches" do
+ methods = repository.methods.map { |method|
match = /^_uncached_(.*)/.match(method)
match[1].to_sym if match
- end.compact
+ }.compact
expect(Repository::CACHED_METHODS + Repository::MEMOIZED_CACHED_METHODS).to include(*methods)
end
end
- describe '#file_on_head' do
- context 'with a non-existing repository' do
- it 'returns nil' do
+ describe "#file_on_head" do
+ context "with a non-existing repository" do
+ it "returns nil" do
expect(repository).to receive(:tree).with(:head).and_return(nil)
expect(repository.file_on_head(:readme)).to be_nil
end
end
- context 'with a repository that has no blobs' do
- it 'returns nil' do
+ context "with a repository that has no blobs" do
+ it "returns nil" do
expect_any_instance_of(Tree).to receive(:blobs).and_return([])
expect(repository.file_on_head(:readme)).to be_nil
end
end
- context 'with an existing repository' do
- it 'returns a Gitlab::Git::Tree' do
+ context "with an existing repository" do
+ it "returns a Gitlab::Git::Tree" do
expect(repository.file_on_head(:readme))
.to be_an_instance_of(Gitlab::Git::Tree)
end
end
end
- describe '#head_tree' do
- context 'with an existing repository' do
- it 'returns a Tree' do
+ describe "#head_tree" do
+ context "with an existing repository" do
+ it "returns a Tree" do
expect(repository.head_tree).to be_an_instance_of(Tree)
end
end
- context 'with a non-existing repository' do
- it 'returns nil' do
+ context "with a non-existing repository" do
+ it "returns nil" do
expect(repository).to receive(:head_commit).and_return(nil)
expect(repository.head_tree).to be_nil
@@ -2084,107 +2086,108 @@ describe Repository do
end
end
- describe '#tree' do
- context 'using a non-existing repository' do
+ describe "#tree" do
+ context "using a non-existing repository" do
before do
allow(repository).to receive(:head_commit).and_return(nil)
end
- it 'returns nil' do
+ it "returns nil" do
expect(repository.tree(:head)).to be_nil
end
- it 'returns nil when using a path' do
- expect(repository.tree(:head, 'README.md')).to be_nil
+ it "returns nil when using a path" do
+ expect(repository.tree(:head, "README.md")).to be_nil
end
end
- context 'using an existing repository' do
- it 'returns a Tree' do
+ context "using an existing repository" do
+ it "returns a Tree" do
expect(repository.tree(:head)).to be_an_instance_of(Tree)
end
end
end
- describe '#size' do
- context 'with a non-existing repository' do
- it 'returns 0' do
+ describe "#size" do
+ context "with a non-existing repository" do
+ it "returns 0" do
expect(repository).to receive(:exists?).and_return(false)
expect(repository.size).to eq(0.0)
end
end
- context 'with an existing repository' do
- it 'returns the repository size as a Float' do
+ context "with an existing repository" do
+ it "returns the repository size as a Float" do
expect(repository.size).to be_an_instance_of(Float)
end
end
end
- describe '#local_branches' do
- it 'returns the local branches' do
- masterrev = repository.find_branch('master').dereferenced_target
- create_remote_branch('joe', 'remote_branch', masterrev)
- repository.add_branch(user, 'local_branch', masterrev.id)
+ describe "#local_branches" do
+ it "returns the local branches" do
+ masterrev = repository.find_branch("master").dereferenced_target
+ create_remote_branch("joe", "remote_branch", masterrev)
+ repository.add_branch(user, "local_branch", masterrev.id)
- expect(repository.local_branches.any? { |branch| branch.name == 'remote_branch' }).to eq(false)
- expect(repository.local_branches.any? { |branch| branch.name == 'local_branch' }).to eq(true)
+ expect(repository.local_branches.any? { |branch| branch.name == "remote_branch" }).to eq(false)
+ expect(repository.local_branches.any? { |branch| branch.name == "local_branch" }).to eq(true)
end
end
- describe '#commit_count' do
- context 'with a non-existing repository' do
- it 'returns 0' do
+ describe "#commit_count" do
+ context "with a non-existing repository" do
+ it "returns 0" do
expect(repository).to receive(:root_ref).and_return(nil)
expect(repository.commit_count).to eq(0)
end
end
- context 'with an existing repository' do
- it 'returns the commit count' do
+ context "with an existing repository" do
+ it "returns the commit count" do
expect(repository.commit_count).to be_an(Integer)
end
end
end
- describe '#commit_count_for_ref' do
+ describe "#commit_count_for_ref" do
let(:project) { create :project }
- context 'with a non-existing repository' do
- it 'returns 0' do
- expect(project.repository.commit_count_for_ref('master')).to eq(0)
+ context "with a non-existing repository" do
+ it "returns 0" do
+ expect(project.repository.commit_count_for_ref("master")).to eq(0)
end
end
- context 'with empty repository' do
- it 'returns 0' do
+ context "with empty repository" do
+ it "returns 0" do
project.create_repository
- expect(project.repository.commit_count_for_ref('master')).to eq(0)
+ expect(project.repository.commit_count_for_ref("master")).to eq(0)
end
end
- context 'when searching for the root ref' do
- it 'returns the same count as #commit_count' do
+ context "when searching for the root ref" do
+ it "returns the same count as #commit_count" do
expect(repository.commit_count_for_ref(repository.root_ref)).to eq(repository.commit_count)
end
end
end
- describe '#diverging_commit_counts' do
- it 'returns the commit counts behind and ahead of default branch' do
+ describe "#diverging_commit_counts" do
+ it "returns the commit counts behind and ahead of default branch" do
result = repository.diverging_commit_counts(
- repository.find_branch('fix'))
+ repository.find_branch("fix")
+ )
expect(result).to eq(behind: 29, ahead: 2)
end
end
- describe '#refresh_method_caches' do
- it 'refreshes the caches of the given types' do
+ describe "#refresh_method_caches" do
+ it "refreshes the caches of the given types" do
expect(repository).to receive(:expire_method_caches)
- .with(%i(rendered_readme readme_path license_blob license_key license))
+ .with(%i[rendered_readme readme_path license_blob license_key license])
expect(repository).to receive(:rendered_readme)
expect(repository).to receive(:readme_path)
@@ -2192,41 +2195,41 @@ describe Repository do
expect(repository).to receive(:license_key)
expect(repository).to receive(:license)
- repository.refresh_method_caches(%i(readme license))
+ repository.refresh_method_caches(%i[readme license])
end
end
- describe '#gitlab_ci_yml_for' do
+ describe "#gitlab_ci_yml_for" do
before do
- repository.create_file(User.last, '.gitlab-ci.yml', 'CONTENT', message: 'Add .gitlab-ci.yml', branch_name: 'master')
+ repository.create_file(User.last, ".gitlab-ci.yml", "CONTENT", message: "Add .gitlab-ci.yml", branch_name: "master")
end
- context 'when there is a .gitlab-ci.yml at the commit' do
- it 'returns the content' do
- expect(repository.gitlab_ci_yml_for(repository.commit.sha)).to eq('CONTENT')
+ context "when there is a .gitlab-ci.yml at the commit" do
+ it "returns the content" do
+ expect(repository.gitlab_ci_yml_for(repository.commit.sha)).to eq("CONTENT")
end
end
- context 'when there is no .gitlab-ci.yml at the commit' do
- it 'returns nil' do
+ context "when there is no .gitlab-ci.yml at the commit" do
+ it "returns nil" do
expect(repository.gitlab_ci_yml_for(repository.commit.parent.sha)).to be_nil
end
end
end
- describe '#route_map_for' do
+ describe "#route_map_for" do
before do
- repository.create_file(User.last, '.gitlab/route-map.yml', 'CONTENT', message: 'Add .gitlab/route-map.yml', branch_name: 'master')
+ repository.create_file(User.last, ".gitlab/route-map.yml", "CONTENT", message: "Add .gitlab/route-map.yml", branch_name: "master")
end
- context 'when there is a .gitlab/route-map.yml at the commit' do
- it 'returns the content' do
- expect(repository.route_map_for(repository.commit.sha)).to eq('CONTENT')
+ context "when there is a .gitlab/route-map.yml at the commit" do
+ it "returns the content" do
+ expect(repository.route_map_for(repository.commit.sha)).to eq("CONTENT")
end
end
- context 'when there is no .gitlab/route-map.yml at the commit' do
- it 'returns nil' do
+ context "when there is no .gitlab/route-map.yml at the commit" do
+ it "returns nil" do
expect(repository.route_map_for(repository.commit.parent.sha)).to be_nil
end
end
@@ -2237,60 +2240,60 @@ describe Repository do
rugged.references.create("refs/remotes/#{remote_name}/#{branch_name}", target.id)
end
- describe '#ancestor?' do
+ describe "#ancestor?" do
let(:commit) { repository.commit }
let(:ancestor) { commit.parents.first }
- it 'it is an ancestor' do
+ it "it is an ancestor" do
expect(repository.ancestor?(ancestor.id, commit.id)).to eq(true)
end
- it 'it is not an ancestor' do
+ it "it is not an ancestor" do
expect(repository.ancestor?(commit.id, ancestor.id)).to eq(false)
end
- it 'returns false on nil-values' do
+ it "returns false on nil-values" do
expect(repository.ancestor?(nil, commit.id)).to eq(false)
expect(repository.ancestor?(ancestor.id, nil)).to eq(false)
expect(repository.ancestor?(nil, nil)).to eq(false)
end
- it 'returns false for invalid commit IDs' do
+ it "returns false for invalid commit IDs" do
expect(repository.ancestor?(commit.id, Gitlab::Git::BLANK_SHA)).to eq(false)
- expect(repository.ancestor?( Gitlab::Git::BLANK_SHA, commit.id)).to eq(false)
+ expect(repository.ancestor?(Gitlab::Git::BLANK_SHA, commit.id)).to eq(false)
end
end
- describe '#archive_metadata' do
- let(:ref) { 'master' }
- let(:storage_path) { '/tmp' }
+ describe "#archive_metadata" do
+ let(:ref) { "master" }
+ let(:storage_path) { "/tmp" }
- let(:prefix) { [project.path, ref].join('-') }
- let(:filename) { prefix + '.tar.gz' }
+ let(:prefix) { [project.path, ref].join("-") }
+ let(:filename) { prefix + ".tar.gz" }
subject(:result) { repository.archive_metadata(ref, storage_path, append_sha: false) }
- context 'with hashed storage disabled' do
+ context "with hashed storage disabled" do
let(:project) { create(:project, :repository, :legacy_storage) }
- it 'uses the project path to generate the filename' do
- expect(result['ArchivePrefix']).to eq(prefix)
- expect(File.basename(result['ArchivePath'])).to eq(filename)
+ it "uses the project path to generate the filename" do
+ expect(result["ArchivePrefix"]).to eq(prefix)
+ expect(File.basename(result["ArchivePath"])).to eq(filename)
end
end
- context 'with hashed storage enabled' do
- it 'uses the project path to generate the filename' do
- expect(result['ArchivePrefix']).to eq(prefix)
- expect(File.basename(result['ArchivePath'])).to eq(filename)
+ context "with hashed storage enabled" do
+ it "uses the project path to generate the filename" do
+ expect(result["ArchivePrefix"]).to eq(prefix)
+ expect(File.basename(result["ArchivePath"])).to eq(filename)
end
end
end
- describe 'commit cache' do
+ describe "commit cache" do
set(:project) { create(:project, :repository) }
- it 'caches based on SHA' do
+ it "caches based on SHA" do
# Gets the commit oid, and warms the cache
oid = project.commit.id
@@ -2299,47 +2302,47 @@ describe Repository do
project.commit_by(oid: oid)
end
- it 'caches nil values' do
+ it "caches nil values" do
expect(Gitlab::Git::Commit).to receive(:find).once
- project.commit_by(oid: '1' * 40)
- project.commit_by(oid: '1' * 40)
+ project.commit_by(oid: "1" * 40)
+ project.commit_by(oid: "1" * 40)
end
end
- describe '#raw_repository' do
+ describe "#raw_repository" do
subject { repository.raw_repository }
- it 'returns a Gitlab::Git::Repository representation of the repository' do
+ it "returns a Gitlab::Git::Repository representation of the repository" do
expect(subject).to be_a(Gitlab::Git::Repository)
- expect(subject.relative_path).to eq(project.disk_path + '.git')
+ expect(subject.relative_path).to eq(project.disk_path + ".git")
expect(subject.gl_repository).to eq("project-#{project.id}")
expect(subject.gl_project_path).to eq(project.full_path)
end
- context 'with a wiki repository' do
+ context "with a wiki repository" do
let(:repository) { project.wiki.repository }
- it 'creates a Gitlab::Git::Repository with the proper attributes' do
+ it "creates a Gitlab::Git::Repository with the proper attributes" do
expect(subject).to be_a(Gitlab::Git::Repository)
- expect(subject.relative_path).to eq(project.disk_path + '.wiki.git')
+ expect(subject.relative_path).to eq(project.disk_path + ".wiki.git")
expect(subject.gl_repository).to eq("wiki-#{project.id}")
expect(subject.gl_project_path).to eq(project.full_path)
end
end
end
- describe '#contributors' do
- let(:author_a) { build(:author, email: 'tiagonbotelho@hotmail.com', name: 'tiagonbotelho') }
- let(:author_b) { build(:author, email: 'gitlab@winniehell.de', name: 'Winnie') }
- let(:author_c) { build(:author, email: 'douwe@gitlab.com', name: 'Douwe Maan') }
+ describe "#contributors" do
+ let(:author_a) { build(:author, email: "tiagonbotelho@hotmail.com", name: "tiagonbotelho") }
+ let(:author_b) { build(:author, email: "gitlab@winniehell.de", name: "Winnie") }
+ let(:author_c) { build(:author, email: "douwe@gitlab.com", name: "Douwe Maan") }
let(:stubbed_commits) do
[build(:commit, author: author_a),
build(:commit, author: author_a),
build(:commit, author: author_b),
build(:commit, author: author_c),
build(:commit, author: author_c),
- build(:commit, author: author_c)]
+ build(:commit, author: author_c),]
end
let(:order_by) { nil }
let(:sort) { nil }
@@ -2354,96 +2357,96 @@ describe Repository do
expect(subject.map(&:email)).to eq(contributors.map(&:email))
end
- it 'returns the array of Gitlab::Contributor for the repository' do
+ it "returns the array of Gitlab::Contributor for the repository" do
expect_contributors(author_a, author_b, author_c)
end
- context 'order_by email' do
- let(:order_by) { 'email' }
+ context "order_by email" do
+ let(:order_by) { "email" }
- context 'asc' do
- let(:sort) { 'asc' }
+ context "asc" do
+ let(:sort) { "asc" }
- it 'returns all the contributors ordered by email asc case insensitive' do
+ it "returns all the contributors ordered by email asc case insensitive" do
expect_contributors(author_c, author_b, author_a)
end
end
- context 'desc' do
- let(:sort) { 'desc' }
+ context "desc" do
+ let(:sort) { "desc" }
- it 'returns all the contributors ordered by email desc case insensitive' do
+ it "returns all the contributors ordered by email desc case insensitive" do
expect_contributors(author_a, author_b, author_c)
end
end
end
- context 'order_by name' do
- let(:order_by) { 'name' }
+ context "order_by name" do
+ let(:order_by) { "name" }
- context 'asc' do
- let(:sort) { 'asc' }
+ context "asc" do
+ let(:sort) { "asc" }
- it 'returns all the contributors ordered by name asc case insensitive' do
+ it "returns all the contributors ordered by name asc case insensitive" do
expect_contributors(author_c, author_a, author_b)
end
end
- context 'desc' do
- let(:sort) { 'desc' }
+ context "desc" do
+ let(:sort) { "desc" }
- it 'returns all the contributors ordered by name desc case insensitive' do
+ it "returns all the contributors ordered by name desc case insensitive" do
expect_contributors(author_b, author_a, author_c)
end
end
end
- context 'order_by commits' do
- let(:order_by) { 'commits' }
+ context "order_by commits" do
+ let(:order_by) { "commits" }
- context 'asc' do
- let(:sort) { 'asc' }
+ context "asc" do
+ let(:sort) { "asc" }
- it 'returns all the contributors ordered by commits asc' do
+ it "returns all the contributors ordered by commits asc" do
expect_contributors(author_b, author_a, author_c)
end
end
- context 'desc' do
- let(:sort) { 'desc' }
+ context "desc" do
+ let(:sort) { "desc" }
- it 'returns all the contributors ordered by commits desc' do
+ it "returns all the contributors ordered by commits desc" do
expect_contributors(author_c, author_a, author_b)
end
end
end
- context 'invalid ordering' do
- let(:order_by) { 'unknown' }
+ context "invalid ordering" do
+ let(:order_by) { "unknown" }
- it 'returns the contributors unsorted' do
+ it "returns the contributors unsorted" do
expect_contributors(author_a, author_b, author_c)
end
end
- context 'invalid sorting' do
- let(:order_by) { 'name' }
- let(:sort) { 'unknown' }
+ context "invalid sorting" do
+ let(:order_by) { "name" }
+ let(:sort) { "unknown" }
- it 'returns the contributors unsorted' do
+ it "returns the contributors unsorted" do
expect_contributors(author_a, author_b, author_c)
end
end
end
- describe '#merge_base' do
+ describe "#merge_base" do
set(:project) { create(:project, :repository) }
subject(:repository) { project.repository }
- it 'only makes one gitaly call' do
+ it "only makes one gitaly call" do
expect(Gitlab::GitalyClient).to receive(:call).once.and_call_original
- repository.merge_base('master', 'fix')
+ repository.merge_base("master", "fix")
end
end
end
diff --git a/spec/models/resource_label_event_spec.rb b/spec/models/resource_label_event_spec.rb
index 7eeb2fae57d..c8622b1fe7c 100644
--- a/spec/models/resource_label_event_spec.rb
+++ b/spec/models/resource_label_event_spec.rb
@@ -1,65 +1,65 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
RSpec.describe ResourceLabelEvent, type: :model do
subject { build(:resource_label_event, issue: issue) }
let(:issue) { create(:issue) }
let(:merge_request) { create(:merge_request) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:issue) }
it { is_expected.to belong_to(:merge_request) }
it { is_expected.to belong_to(:label) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to be_valid }
- describe 'Issuable validation' do
- it 'is invalid if issue_id and merge_request_id are missing' do
- subject.attributes = { issue: nil, merge_request: nil }
+ describe "Issuable validation" do
+ it "is invalid if issue_id and merge_request_id are missing" do
+ subject.attributes = {issue: nil, merge_request: nil}
expect(subject).to be_invalid
end
- it 'is invalid if issue_id and merge_request_id are set' do
- subject.attributes = { issue: issue, merge_request: merge_request }
+ it "is invalid if issue_id and merge_request_id are set" do
+ subject.attributes = {issue: issue, merge_request: merge_request}
expect(subject).to be_invalid
end
- it 'is valid if only issue_id is set' do
- subject.attributes = { issue: issue, merge_request: nil }
+ it "is valid if only issue_id is set" do
+ subject.attributes = {issue: issue, merge_request: nil}
expect(subject).to be_valid
end
- it 'is valid if only merge_request_id is set' do
- subject.attributes = { merge_request: merge_request, issue: nil }
+ it "is valid if only merge_request_id is set" do
+ subject.attributes = {merge_request: merge_request, issue: nil}
expect(subject).to be_valid
end
end
end
- describe '#expire_etag_cache' do
+ describe "#expire_etag_cache" do
def expect_expiration(issue)
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:touch)
.with("/#{issue.project.namespace.to_param}/#{issue.project.to_param}/noteable/issue/#{issue.id}/notes")
end
- it 'expires resource note etag cache on event save' do
+ it "expires resource note etag cache on event save" do
expect_expiration(subject.issuable)
subject.save!
end
- it 'expires resource note etag cache on event destroy' do
+ it "expires resource note etag cache on event destroy" do
subject.save!
expect_expiration(subject.issuable)
@@ -68,27 +68,27 @@ RSpec.describe ResourceLabelEvent, type: :model do
end
end
- describe '#outdated_markdown?' do
- it 'returns true if label is missing and reference is not empty' do
- subject.attributes = { reference: 'ref', label_id: nil }
+ describe "#outdated_markdown?" do
+ it "returns true if label is missing and reference is not empty" do
+ subject.attributes = {reference: "ref", label_id: nil}
expect(subject.outdated_markdown?).to be true
end
- it 'returns true if reference is not set yet' do
- subject.attributes = { reference: nil }
+ it "returns true if reference is not set yet" do
+ subject.attributes = {reference: nil}
expect(subject.outdated_markdown?).to be true
end
- it 'returns true if markdown is outdated' do
- subject.attributes = { cached_markdown_version: ((CacheMarkdownField::CACHE_COMMONMARK_VERSION - 1) << 16) | 0 }
+ it "returns true if markdown is outdated" do
+ subject.attributes = {cached_markdown_version: ((CacheMarkdownField::CACHE_COMMONMARK_VERSION - 1) << 16) | 0}
expect(subject.outdated_markdown?).to be true
end
- it 'returns false if label and reference are set' do
- subject.attributes = { reference: 'whatever', cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION << 16 }
+ it "returns false if label and reference are set" do
+ subject.attributes = {reference: "whatever", cached_markdown_version: CacheMarkdownField::CACHE_COMMONMARK_VERSION << 16}
expect(subject.outdated_markdown?).to be false
end
diff --git a/spec/models/route_spec.rb b/spec/models/route_spec.rb
index 48799781b87..9d7c3ca3c9f 100644
--- a/spec/models/route_spec.rb
+++ b/spec/models/route_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Route do
- let(:group) { create(:group, path: 'git_lab', name: 'git_lab') }
+ let(:group) { create(:group, path: "git_lab", name: "git_lab") }
let(:route) { group.route }
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:source) }
end
- describe 'validations' do
+ describe "validations" do
before do
expect(route).to be_persisted
end
@@ -18,28 +18,28 @@ describe Route do
it { is_expected.to validate_uniqueness_of(:path).case_insensitive }
end
- describe 'callbacks' do
- context 'before validation' do
- it 'calls #delete_conflicting_orphaned_routes' do
+ describe "callbacks" do
+ context "before validation" do
+ it "calls #delete_conflicting_orphaned_routes" do
expect(route).to receive(:delete_conflicting_orphaned_routes)
route.valid?
end
end
- context 'after update' do
- it 'calls #create_redirect_for_old_path' do
+ context "after update" do
+ it "calls #create_redirect_for_old_path" do
expect(route).to receive(:create_redirect_for_old_path)
- route.update(path: 'foo')
+ route.update(path: "foo")
end
- it 'calls #delete_conflicting_redirects' do
+ it "calls #delete_conflicting_redirects" do
expect(route).to receive(:delete_conflicting_redirects)
- route.update(path: 'foo')
+ route.update(path: "foo")
end
end
- context 'after create' do
- it 'calls #delete_conflicting_redirects' do
+ context "after create" do
+ it "calls #delete_conflicting_redirects" do
route.destroy
new_route = described_class.new(source: group, path: group.path)
expect(new_route).to receive(:delete_conflicting_redirects)
@@ -48,182 +48,182 @@ describe Route do
end
end
- describe '.inside_path' do
- let!(:nested_group) { create(:group, path: 'test', name: 'test', parent: group) }
- let!(:deep_nested_group) { create(:group, path: 'foo', name: 'foo', parent: nested_group) }
- let!(:another_group) { create(:group, path: 'other') }
- let!(:similar_group) { create(:group, path: 'gitllab') }
- let!(:another_group_nested) { create(:group, path: 'another', name: 'another', parent: similar_group) }
+ describe ".inside_path" do
+ let!(:nested_group) { create(:group, path: "test", name: "test", parent: group) }
+ let!(:deep_nested_group) { create(:group, path: "foo", name: "foo", parent: nested_group) }
+ let!(:another_group) { create(:group, path: "other") }
+ let!(:similar_group) { create(:group, path: "gitllab") }
+ let!(:another_group_nested) { create(:group, path: "another", name: "another", parent: similar_group) }
- it 'returns correct routes' do
- expect(described_class.inside_path('git_lab')).to match_array([nested_group.route, deep_nested_group.route])
+ it "returns correct routes" do
+ expect(described_class.inside_path("git_lab")).to match_array([nested_group.route, deep_nested_group.route])
end
end
- describe '#rename_descendants' do
- let!(:nested_group) { create(:group, path: 'test', name: 'test', parent: group) }
- let!(:deep_nested_group) { create(:group, path: 'foo', name: 'foo', parent: nested_group) }
- let!(:similar_group) { create(:group, path: 'gitlab-org', name: 'gitlab-org') }
- let!(:another_group) { create(:group, path: 'gittlab', name: 'gitllab') }
- let!(:another_group_nested) { create(:group, path: 'git_lab', name: 'git_lab', parent: another_group) }
+ describe "#rename_descendants" do
+ let!(:nested_group) { create(:group, path: "test", name: "test", parent: group) }
+ let!(:deep_nested_group) { create(:group, path: "foo", name: "foo", parent: nested_group) }
+ let!(:similar_group) { create(:group, path: "gitlab-org", name: "gitlab-org") }
+ let!(:another_group) { create(:group, path: "gittlab", name: "gitllab") }
+ let!(:another_group_nested) { create(:group, path: "git_lab", name: "git_lab", parent: another_group) }
- context 'path update' do
- context 'when route name is set' do
+ context "path update" do
+ context "when route name is set" do
before do
- route.update(path: 'bar')
+ route.update(path: "bar")
end
- it 'updates children routes with new path' do
- expect(described_class.exists?(path: 'bar')).to be_truthy
- expect(described_class.exists?(path: 'bar/test')).to be_truthy
- expect(described_class.exists?(path: 'bar/test/foo')).to be_truthy
- expect(described_class.exists?(path: 'gitlab-org')).to be_truthy
- expect(described_class.exists?(path: 'gittlab')).to be_truthy
- expect(described_class.exists?(path: 'gittlab/git_lab')).to be_truthy
+ it "updates children routes with new path" do
+ expect(described_class.exists?(path: "bar")).to be_truthy
+ expect(described_class.exists?(path: "bar/test")).to be_truthy
+ expect(described_class.exists?(path: "bar/test/foo")).to be_truthy
+ expect(described_class.exists?(path: "gitlab-org")).to be_truthy
+ expect(described_class.exists?(path: "gittlab")).to be_truthy
+ expect(described_class.exists?(path: "gittlab/git_lab")).to be_truthy
end
end
- context 'when route name is nil' do
+ context "when route name is nil" do
before do
route.update_column(:name, nil)
end
it "does not fail" do
- expect(route.update(path: 'bar')).to be_truthy
+ expect(route.update(path: "bar")).to be_truthy
end
end
- context 'when conflicting redirects exist' do
+ context "when conflicting redirects exist" do
let(:route) { create(:project).route }
- let!(:conflicting_redirect1) { route.create_redirect('bar/test') }
- let!(:conflicting_redirect2) { route.create_redirect('bar/test/foo') }
- let!(:conflicting_redirect3) { route.create_redirect('gitlab-org') }
+ let!(:conflicting_redirect1) { route.create_redirect("bar/test") }
+ let!(:conflicting_redirect2) { route.create_redirect("bar/test/foo") }
+ let!(:conflicting_redirect3) { route.create_redirect("gitlab-org") }
- it 'deletes the conflicting redirects' do
- route.update(path: 'bar')
+ it "deletes the conflicting redirects" do
+ route.update(path: "bar")
- expect(RedirectRoute.exists?(path: 'bar/test')).to be_falsey
- expect(RedirectRoute.exists?(path: 'bar/test/foo')).to be_falsey
- expect(RedirectRoute.exists?(path: 'gitlab-org')).to be_truthy
+ expect(RedirectRoute.exists?(path: "bar/test")).to be_falsey
+ expect(RedirectRoute.exists?(path: "bar/test/foo")).to be_falsey
+ expect(RedirectRoute.exists?(path: "gitlab-org")).to be_truthy
end
end
end
- context 'name update' do
- it 'updates children routes with new path' do
- route.update(name: 'bar')
+ context "name update" do
+ it "updates children routes with new path" do
+ route.update(name: "bar")
- expect(described_class.exists?(name: 'bar')).to be_truthy
- expect(described_class.exists?(name: 'bar / test')).to be_truthy
- expect(described_class.exists?(name: 'bar / test / foo')).to be_truthy
- expect(described_class.exists?(name: 'gitlab-org')).to be_truthy
+ expect(described_class.exists?(name: "bar")).to be_truthy
+ expect(described_class.exists?(name: "bar / test")).to be_truthy
+ expect(described_class.exists?(name: "bar / test / foo")).to be_truthy
+ expect(described_class.exists?(name: "gitlab-org")).to be_truthy
end
- it 'handles a rename from nil' do
+ it "handles a rename from nil" do
# Note: using `update_columns` to skip all validation and callbacks
route.update_columns(name: nil)
- expect { route.update(name: 'bar') }
- .to change { route.name }.from(nil).to('bar')
+ expect { route.update(name: "bar") }
+ .to change { route.name }.from(nil).to("bar")
end
end
end
- describe '#create_redirect_for_old_path' do
- context 'if the path changed' do
- it 'creates a RedirectRoute for the old path' do
- redirect_scope = route.source.redirect_routes.where(path: 'git_lab')
+ describe "#create_redirect_for_old_path" do
+ context "if the path changed" do
+ it "creates a RedirectRoute for the old path" do
+ redirect_scope = route.source.redirect_routes.where(path: "git_lab")
expect(redirect_scope.exists?).to be_falsey
- route.path = 'new-path'
+ route.path = "new-path"
route.save!
expect(redirect_scope.exists?).to be_truthy
end
end
end
- describe '#create_redirect' do
- it 'creates a RedirectRoute with the same source' do
- redirect_route = route.create_redirect('foo')
+ describe "#create_redirect" do
+ it "creates a RedirectRoute with the same source" do
+ redirect_route = route.create_redirect("foo")
expect(redirect_route).to be_a(RedirectRoute)
expect(redirect_route).to be_persisted
expect(redirect_route.source).to eq(route.source)
- expect(redirect_route.path).to eq('foo')
+ expect(redirect_route.path).to eq("foo")
end
- context 'when the source is a Project' do
- it 'creates a RedirectRoute' do
+ context "when the source is a Project" do
+ it "creates a RedirectRoute" do
project = create(:project)
route = project.route
- redirect_route = route.create_redirect('foo')
+ redirect_route = route.create_redirect("foo")
expect(redirect_route).not_to be_nil
end
end
- context 'when the source is not a project' do
- it 'creates a RedirectRoute' do
- redirect_route = route.create_redirect('foo')
+ context "when the source is not a project" do
+ it "creates a RedirectRoute" do
+ redirect_route = route.create_redirect("foo")
expect(redirect_route).not_to be_nil
end
end
end
- describe '#delete_conflicting_redirects' do
+ describe "#delete_conflicting_redirects" do
let(:route) { create(:project).route }
- it 'deletes the redirect' do
+ it "deletes the redirect" do
route.create_redirect("#{route.path}/foo")
- expect do
+ expect {
route.delete_conflicting_redirects
- end.to change { RedirectRoute.count }.by(-1)
+ }.to change { RedirectRoute.count }.by(-1)
end
- context 'when a redirect route with the same path exists' do
- context 'when the redirect route has matching case' do
+ context "when a redirect route with the same path exists" do
+ context "when the redirect route has matching case" do
let(:route) { create(:project).route }
let!(:redirect1) { route.create_redirect(route.path) }
- it 'deletes the redirect' do
- expect do
+ it "deletes the redirect" do
+ expect {
route.delete_conflicting_redirects
- end.to change { RedirectRoute.count }.by(-1)
+ }.to change { RedirectRoute.count }.by(-1)
end
- context 'when redirect routes with paths descending from the route path exists' do
+ context "when redirect routes with paths descending from the route path exists" do
let!(:redirect2) { route.create_redirect("#{route.path}/foo") }
let!(:redirect3) { route.create_redirect("#{route.path}/foo/bar") }
let!(:redirect4) { route.create_redirect("#{route.path}/baz/quz") }
let!(:other_redirect) { route.create_redirect("other") }
- it 'deletes all redirects with paths that descend from the route path' do
- expect do
+ it "deletes all redirects with paths that descend from the route path" do
+ expect {
route.delete_conflicting_redirects
- end.to change { RedirectRoute.count }.by(-4)
+ }.to change { RedirectRoute.count }.by(-4)
end
end
end
- context 'when the redirect route is differently cased' do
+ context "when the redirect route is differently cased" do
let(:route) { create(:project).route }
let!(:redirect1) { route.create_redirect(route.path.upcase) }
- it 'deletes the redirect' do
- expect do
+ it "deletes the redirect" do
+ expect {
route.delete_conflicting_redirects
- end.to change { RedirectRoute.count }.by(-1)
+ }.to change { RedirectRoute.count }.by(-1)
end
end
end
end
- describe '#conflicting_redirects' do
+ describe "#conflicting_redirects" do
let(:route) { create(:project).route }
- it 'returns an ActiveRecord::Relation' do
+ it "returns an ActiveRecord::Relation" do
expect(route.conflicting_redirects).to be_an(ActiveRecord::Relation)
end
- it 'returns the redirect routes' do
+ it "returns the redirect routes" do
redirect1 = route.create_redirect("#{route.path}/foo")
redirect2 = route.create_redirect("#{route.path}/foo/bar")
redirect3 = route.create_redirect("#{route.path}/baz/quz")
@@ -231,87 +231,87 @@ describe Route do
expect(route.conflicting_redirects).to match_array([redirect1, redirect2, redirect3])
end
- context 'when a redirect route with the same path exists' do
+ context "when a redirect route with the same path exists" do
let(:route) { create(:project).route }
- context 'when the redirect route has matching case' do
+ context "when the redirect route has matching case" do
let!(:redirect1) { route.create_redirect(route.path) }
- it 'returns the redirect route' do
+ it "returns the redirect route" do
expect(route.conflicting_redirects).to match_array([redirect1])
end
- context 'when redirect routes with paths descending from the route path exists' do
+ context "when redirect routes with paths descending from the route path exists" do
let!(:redirect2) { route.create_redirect("#{route.path}/foo") }
let!(:redirect3) { route.create_redirect("#{route.path}/foo/bar") }
let!(:redirect4) { route.create_redirect("#{route.path}/baz/quz") }
let!(:other_redirect) { route.create_redirect("other") }
- it 'returns the redirect routes' do
+ it "returns the redirect routes" do
expect(route.conflicting_redirects).to match_array([redirect1, redirect2, redirect3, redirect4])
end
end
end
- context 'when the redirect route is differently cased' do
+ context "when the redirect route is differently cased" do
let!(:redirect1) { route.create_redirect(route.path.upcase) }
- it 'returns the redirect route' do
+ it "returns the redirect route" do
expect(route.conflicting_redirects).to match_array([redirect1])
end
end
end
end
- describe '#delete_conflicting_orphaned_routes' do
- context 'when there is a conflicting route' do
- let!(:conflicting_group) { create(:group, path: 'foo') }
+ describe "#delete_conflicting_orphaned_routes" do
+ context "when there is a conflicting route" do
+ let!(:conflicting_group) { create(:group, path: "foo") }
before do
route.path = conflicting_group.route.path
end
- context 'when the route is orphaned' do
+ context "when the route is orphaned" do
let!(:offending_route) { conflicting_group.route }
before do
Group.delete(conflicting_group) # Orphan the route
end
- it 'deletes the orphaned route' do
- expect do
+ it "deletes the orphaned route" do
+ expect {
route.valid?
- end.to change { described_class.count }.from(2).to(1)
+ }.to change { described_class.count }.from(2).to(1)
end
- it 'passes validation, as usual' do
+ it "passes validation, as usual" do
expect(route.valid?).to be_truthy
end
end
- context 'when the route is not orphaned' do
- it 'does not delete the conflicting route' do
- expect do
+ context "when the route is not orphaned" do
+ it "does not delete the conflicting route" do
+ expect {
route.valid?
- end.not_to change { described_class.count }
+ }.not_to change { described_class.count }
end
- it 'fails validation, as usual' do
+ it "fails validation, as usual" do
expect(route.valid?).to be_falsey
end
end
end
- context 'when there are no conflicting routes' do
- it 'does not delete any routes' do
+ context "when there are no conflicting routes" do
+ it "does not delete any routes" do
route
- expect do
+ expect {
route.valid?
- end.not_to change { described_class.count }
+ }.not_to change { described_class.count }
end
- it 'passes validation, as usual' do
+ it "passes validation, as usual" do
expect(route.valid?).to be_truthy
end
end
diff --git a/spec/models/sent_notification_spec.rb b/spec/models/sent_notification_spec.rb
index 6c35ed8f649..09095bf2b62 100644
--- a/spec/models/sent_notification_spec.rb
+++ b/spec/models/sent_notification_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe SentNotification do
set(:user) { create(:user) }
set(:project) { create(:project) }
- describe 'validation' do
- describe 'note validity' do
+ describe "validation" do
+ describe "note validity" do
context "when the project doesn't match the noteable's project" do
subject { build(:sent_notification, noteable: create(:issue)) }
@@ -36,46 +36,46 @@ describe SentNotification do
end
end
- shared_examples 'a successful sent notification' do
- it 'creates a new SentNotification' do
+ shared_examples "a successful sent notification" do
+ it "creates a new SentNotification" do
expect { subject }.to change { described_class.count }.by(1)
end
end
- describe '.record' do
+ describe ".record" do
let(:issue) { create(:issue) }
subject { described_class.record(issue, user.id) }
- it_behaves_like 'a successful sent notification'
+ it_behaves_like "a successful sent notification"
end
- describe '.record_note' do
+ describe ".record_note" do
subject { described_class.record_note(note, note.author.id) }
- context 'for a discussion note' do
+ context "for a discussion note" do
let(:note) { create(:diff_note_on_merge_request) }
- it_behaves_like 'a successful sent notification'
+ it_behaves_like "a successful sent notification"
- it 'sets in_reply_to_discussion_id' do
+ it "sets in_reply_to_discussion_id" do
expect(subject.in_reply_to_discussion_id).to eq(note.discussion_id)
end
end
- context 'for an individual note' do
+ context "for an individual note" do
let(:note) { create(:note_on_merge_request) }
- it_behaves_like 'a successful sent notification'
+ it_behaves_like "a successful sent notification"
- it 'does not set in_reply_to_discussion_id' do
+ it "does not set in_reply_to_discussion_id" do
expect(subject.in_reply_to_discussion_id).to be_nil
end
end
end
- describe '#unsubscribable?' do
- shared_examples 'an unsubscribable notification' do |noteable_type|
+ describe "#unsubscribable?" do
+ shared_examples "an unsubscribable notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for #{noteable_type}" do
@@ -83,7 +83,7 @@ describe SentNotification do
end
end
- shared_examples 'a non-unsubscribable notification' do |noteable_type|
+ shared_examples "a non-unsubscribable notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for a #{noteable_type}" do
@@ -91,30 +91,30 @@ describe SentNotification do
end
end
- it_behaves_like 'an unsubscribable notification', 'issue' do
+ it_behaves_like "an unsubscribable notification", "issue" do
let(:noteable) { create(:issue, project: project) }
end
- it_behaves_like 'an unsubscribable notification', 'merge request' do
+ it_behaves_like "an unsubscribable notification", "merge request" do
let(:noteable) { create(:merge_request, source_project: project) }
end
- it_behaves_like 'a non-unsubscribable notification', 'commit' do
+ it_behaves_like "a non-unsubscribable notification", "commit" do
let(:project) { create(:project, :repository) }
let(:noteable) { project.commit }
end
- it_behaves_like 'a non-unsubscribable notification', 'personal snippet' do
+ it_behaves_like "a non-unsubscribable notification", "personal snippet" do
let(:noteable) { create(:personal_snippet, project: project) }
end
- it_behaves_like 'a non-unsubscribable notification', 'project snippet' do
+ it_behaves_like "a non-unsubscribable notification", "project snippet" do
let(:noteable) { create(:project_snippet, project: project) }
end
end
- describe '#for_commit?' do
- shared_examples 'a commit notification' do |noteable_type|
+ describe "#for_commit?" do
+ shared_examples "a commit notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for #{noteable_type}" do
@@ -122,7 +122,7 @@ describe SentNotification do
end
end
- shared_examples 'a non-commit notification' do |noteable_type|
+ shared_examples "a non-commit notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for a #{noteable_type}" do
@@ -130,30 +130,30 @@ describe SentNotification do
end
end
- it_behaves_like 'a non-commit notification', 'issue' do
+ it_behaves_like "a non-commit notification", "issue" do
let(:noteable) { create(:issue, project: project) }
end
- it_behaves_like 'a non-commit notification', 'merge request' do
+ it_behaves_like "a non-commit notification", "merge request" do
let(:noteable) { create(:merge_request, source_project: project) }
end
- it_behaves_like 'a commit notification', 'commit' do
+ it_behaves_like "a commit notification", "commit" do
let(:project) { create(:project, :repository) }
let(:noteable) { project.commit }
end
- it_behaves_like 'a non-commit notification', 'personal snippet' do
+ it_behaves_like "a non-commit notification", "personal snippet" do
let(:noteable) { create(:personal_snippet, project: project) }
end
- it_behaves_like 'a non-commit notification', 'project snippet' do
+ it_behaves_like "a non-commit notification", "project snippet" do
let(:noteable) { create(:project_snippet, project: project) }
end
end
- describe '#for_snippet?' do
- shared_examples 'a snippet notification' do |noteable_type|
+ describe "#for_snippet?" do
+ shared_examples "a snippet notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for #{noteable_type}" do
@@ -161,7 +161,7 @@ describe SentNotification do
end
end
- shared_examples 'a non-snippet notification' do |noteable_type|
+ shared_examples "a non-snippet notification" do |noteable_type|
subject { described_class.record(noteable, user.id) }
context "for a #{noteable_type}" do
@@ -169,143 +169,143 @@ describe SentNotification do
end
end
- it_behaves_like 'a non-snippet notification', 'issue' do
+ it_behaves_like "a non-snippet notification", "issue" do
let(:noteable) { create(:issue, project: project) }
end
- it_behaves_like 'a non-snippet notification', 'merge request' do
+ it_behaves_like "a non-snippet notification", "merge request" do
let(:noteable) { create(:merge_request, source_project: project) }
end
- it_behaves_like 'a non-snippet notification', 'commit' do
+ it_behaves_like "a non-snippet notification", "commit" do
let(:project) { create(:project, :repository) }
let(:noteable) { project.commit }
end
- it_behaves_like 'a snippet notification', 'personal snippet' do
+ it_behaves_like "a snippet notification", "personal snippet" do
let(:noteable) { create(:personal_snippet, project: project) }
end
- it_behaves_like 'a snippet notification', 'project snippet' do
+ it_behaves_like "a snippet notification", "project snippet" do
let(:noteable) { create(:project_snippet, project: project) }
end
end
- describe '#create_reply' do
- context 'for issue' do
+ describe "#create_reply" do
+ context "for issue" do
let(:issue) { create(:issue) }
subject { described_class.record(issue, issue.author.id) }
- it 'creates a comment on the issue' do
- note = subject.create_reply('Test')
+ it "creates a comment on the issue" do
+ note = subject.create_reply("Test")
expect(note.in_reply_to?(issue)).to be_truthy
end
end
- context 'for issue comment' do
+ context "for issue comment" do
let(:note) { create(:note_on_issue) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a comment on the issue' do
- new_note = subject.create_reply('Test')
+ it "creates a comment on the issue" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
- context 'for issue discussion' do
+ context "for issue discussion" do
let(:note) { create(:discussion_note_on_issue) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a reply on the discussion' do
- new_note = subject.create_reply('Test')
+ it "creates a reply on the discussion" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
- context 'for merge request' do
+ context "for merge request" do
let(:merge_request) { create(:merge_request) }
subject { described_class.record(merge_request, merge_request.author.id) }
- it 'creates a comment on the merge_request' do
- note = subject.create_reply('Test')
+ it "creates a comment on the merge_request" do
+ note = subject.create_reply("Test")
expect(note.in_reply_to?(merge_request)).to be_truthy
end
end
- context 'for merge request comment' do
+ context "for merge request comment" do
let(:note) { create(:note_on_merge_request) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a comment on the merge request' do
- new_note = subject.create_reply('Test')
+ it "creates a comment on the merge request" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
- context 'for merge request diff discussion' do
+ context "for merge request diff discussion" do
let(:note) { create(:diff_note_on_merge_request) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a reply on the discussion' do
- new_note = subject.create_reply('Test')
+ it "creates a reply on the discussion" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
- context 'for merge request non-diff discussion' do
+ context "for merge request non-diff discussion" do
let(:note) { create(:discussion_note_on_merge_request) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a reply on the discussion' do
- new_note = subject.create_reply('Test')
+ it "creates a reply on the discussion" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
- context 'for commit' do
+ context "for commit" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
subject { described_class.record(commit, project.creator.id) }
- it 'creates a comment on the commit' do
- note = subject.create_reply('Test')
+ it "creates a comment on the commit" do
+ note = subject.create_reply("Test")
expect(note.in_reply_to?(commit)).to be_truthy
end
end
- context 'for commit comment' do
+ context "for commit comment" do
let(:note) { create(:note_on_commit) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a comment on the commit' do
- new_note = subject.create_reply('Test')
+ it "creates a comment on the commit" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).not_to eq(note.discussion_id)
end
end
- context 'for commit diff discussion' do
+ context "for commit diff discussion" do
let(:note) { create(:diff_note_on_commit) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a reply on the discussion' do
- new_note = subject.create_reply('Test')
+ it "creates a reply on the discussion" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).to eq(note.discussion_id)
end
end
- context 'for commit non-diff discussion' do
+ context "for commit non-diff discussion" do
let(:note) { create(:discussion_note_on_commit) }
subject { described_class.record_note(note, note.author.id) }
- it 'creates a reply on the discussion' do
- new_note = subject.create_reply('Test')
+ it "creates a reply on the discussion" do
+ new_note = subject.create_reply("Test")
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.discussion_id).to eq(note.discussion_id)
end
diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb
index 25eecb3f909..69684623275 100644
--- a/spec/models/service_spec.rb
+++ b/spec/models/service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Service do
describe "Associations" do
@@ -6,19 +6,19 @@ describe Service do
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
+ describe "Validations" do
it { is_expected.to validate_presence_of(:type) }
end
- describe 'Scopes' do
- describe '.confidential_note_hooks' do
- it 'includes services where confidential_note_events is true' do
+ describe "Scopes" do
+ describe ".confidential_note_hooks" do
+ it "includes services where confidential_note_events is true" do
create(:service, active: true, confidential_note_events: true)
expect(described_class.confidential_note_hooks.count).to eq 1
end
- it 'excludes services where confidential_note_events is false' do
+ it "excludes services where confidential_note_events is false" do
create(:service, active: true, confidential_note_events: false)
expect(described_class.confidential_note_hooks.count).to eq 0
@@ -27,44 +27,44 @@ describe Service do
end
describe "Test Button" do
- describe '#can_test?' do
+ describe "#can_test?" do
let(:service) { create(:service, project: project) }
- context 'when repository is not empty' do
+ context "when repository is not empty" do
let(:project) { create(:project, :repository) }
- it 'returns true' do
+ it "returns true" do
expect(service.can_test?).to be true
end
end
- context 'when repository is empty' do
+ context "when repository is empty" do
let(:project) { create(:project) }
- it 'returns true' do
+ it "returns true" do
expect(service.can_test?).to be true
end
end
end
- describe '#test' do
- let(:data) { 'test' }
+ describe "#test" do
+ let(:data) { "test" }
let(:service) { create(:service, project: project) }
- context 'when repository is not empty' do
+ context "when repository is not empty" do
let(:project) { create(:project, :repository) }
- it 'test runs execute' do
+ it "test runs execute" do
expect(service).to receive(:execute).with(data)
service.test(data)
end
end
- context 'when repository is empty' do
+ context "when repository is empty" do
let(:project) { create(:project) }
- it 'test runs execute' do
+ it "test runs execute" do
expect(service).to receive(:execute).with(data)
service.test(data)
@@ -74,9 +74,9 @@ describe Service do
end
describe "Template" do
- describe '.build_from_template' do
- context 'when template is invalid' do
- it 'sets service template to inactive when template is invalid' do
+ describe ".build_from_template" do
+ context "when template is invalid" do
+ it "sets service template to inactive when template is invalid" do
project = create(:project)
template = KubernetesService.new(template: true, active: true)
template.save(validate: false)
@@ -94,23 +94,24 @@ describe Service do
PushoverService.create(
template: true,
properties: {
- device: 'MyDevice',
- sound: 'mic',
+ device: "MyDevice",
+ sound: "mic",
priority: 4,
- api_key: '123456789'
- })
+ api_key: "123456789",
+ }
+ )
end
let(:project) { create(:project) }
- describe 'is prefilled for projects pushover service' do
+ describe "is prefilled for projects pushover service" do
it "has all fields prefilled" do
- service = project.find_or_initialize_service('pushover')
+ service = project.find_or_initialize_service("pushover")
expect(service.template).to eq(false)
- expect(service.device).to eq('MyDevice')
- expect(service.sound).to eq('mic')
+ expect(service.device).to eq("MyDevice")
+ expect(service.sound).to eq("mic")
expect(service.priority).to eq(4)
- expect(service.api_key).to eq('123456789')
+ expect(service.api_key).to eq("123456789")
end
end
end
@@ -121,9 +122,9 @@ describe Service do
BambooService.create(
project: create(:project),
properties: {
- bamboo_url: 'http://gitlab.com',
- username: 'mic',
- password: "password"
+ bamboo_url: "http://gitlab.com",
+ username: "mic",
+ password: "password",
}
)
end
@@ -145,12 +146,12 @@ describe Service do
end
it "returns false when the property has been re-assigned the same value" do
- service.bamboo_url = 'http://gitlab.com'
+ service.bamboo_url = "http://gitlab.com"
expect(service.bamboo_url_changed?).to be_falsy
end
it "returns false when the property has been assigned a new value then saved" do
- service.bamboo_url = 'http://example.com'
+ service.bamboo_url = "http://example.com"
service.save
expect(service.bamboo_url_changed?).to be_falsy
end
@@ -161,9 +162,9 @@ describe Service do
BambooService.create(
project: create(:project),
properties: {
- bamboo_url: 'http://gitlab.com',
- username: 'mic',
- password: "password"
+ bamboo_url: "http://gitlab.com",
+ username: "mic",
+ password: "password",
}
)
end
@@ -185,12 +186,12 @@ describe Service do
end
it "returns true when the property has been re-assigned the same value" do
- service.bamboo_url = 'http://gitlab.com'
+ service.bamboo_url = "http://gitlab.com"
expect(service.bamboo_url_touched?).to be_truthy
end
it "returns false when the property has been assigned a new value then saved" do
- service.bamboo_url = 'http://example.com'
+ service.bamboo_url = "http://example.com"
service.save
expect(service.bamboo_url_changed?).to be_falsy
end
@@ -201,9 +202,9 @@ describe Service do
BambooService.create(
project: create(:project),
properties: {
- bamboo_url: 'http://gitlab.com',
- username: 'mic',
- password: "password"
+ bamboo_url: "http://gitlab.com",
+ username: "mic",
+ password: "password",
}
)
end
@@ -215,41 +216,41 @@ describe Service do
it "returns the previous value when the property has been assigned a different value" do
service.bamboo_url = "http://example.com"
- expect(service.bamboo_url_was).to eq('http://gitlab.com')
+ expect(service.bamboo_url_was).to eq("http://gitlab.com")
end
it "returns initial value when the property has been re-assigned the same value" do
- service.bamboo_url = 'http://gitlab.com'
- expect(service.bamboo_url_was).to eq('http://gitlab.com')
+ service.bamboo_url = "http://gitlab.com"
+ expect(service.bamboo_url_was).to eq("http://gitlab.com")
end
it "returns initial value when the property has been assigned multiple values" do
service.bamboo_url = "http://example.com"
service.bamboo_url = "http://example2.com"
- expect(service.bamboo_url_was).to eq('http://gitlab.com')
+ expect(service.bamboo_url_was).to eq("http://gitlab.com")
end
it "returns nil when the property has been assigned a new value then saved" do
- service.bamboo_url = 'http://example.com'
+ service.bamboo_url = "http://example.com"
service.save
expect(service.bamboo_url_was).to be_nil
end
end
- describe 'initialize service with no properties' do
+ describe "initialize service with no properties" do
let(:service) do
GitlabIssueTrackerService.create(
project: create(:project),
- title: 'random title'
+ title: "random title"
)
end
- it 'does not raise error' do
+ it "does not raise error" do
expect { service }.not_to raise_error
end
- it 'creates the properties' do
- expect(service.properties).to eq({ "title" => "random title" })
+ it "creates the properties" do
+ expect(service.properties).to eq({"title" => "random title"})
end
end
@@ -260,18 +261,18 @@ describe Service do
project: project,
active: true,
properties: {
- project_url: 'http://redmine/projects/project_name_in_redmine',
+ project_url: "http://redmine/projects/project_name_in_redmine",
issues_url: "http://redmine/#{project.id}/project_name_in_redmine/:id",
- new_issue_url: 'http://redmine/projects/project_name_in_redmine/issues/new'
+ new_issue_url: "http://redmine/projects/project_name_in_redmine/issues/new",
}
)
end
describe "on create" do
it "updates the has_external_issue_tracker boolean" do
- expect do
+ expect {
service.save!
- end.to change { service.project.has_external_issue_tracker }.from(false).to(true)
+ }.to change { service.project.has_external_issue_tracker }.from(false).to(true)
end
end
@@ -279,9 +280,9 @@ describe Service do
it "updates the has_external_issue_tracker boolean" do
service.save!
- expect do
+ expect {
service.update(active: false)
- end.to change { service.project.has_external_issue_tracker }.from(true).to(false)
+ }.to change { service.project.has_external_issue_tracker }.from(true).to(false)
end
end
end
@@ -289,7 +290,7 @@ describe Service do
describe "#deprecated?" do
let(:project) { create(:project, :repository) }
- it 'should return false by default' do
+ it "should return false by default" do
service = create(:service, project: project)
expect(service.deprecated?).to be_falsy
end
@@ -298,32 +299,32 @@ describe Service do
describe "#deprecation_message" do
let(:project) { create(:project, :repository) }
- it 'should be empty by default' do
+ it "should be empty by default" do
service = create(:service, project: project)
expect(service.deprecation_message).to be_nil
end
end
- describe '.find_by_template' do
+ describe ".find_by_template" do
let!(:kubernetes_service) { create(:kubernetes_service, template: true) }
- it 'returns service template' do
+ it "returns service template" do
expect(KubernetesService.find_by_template).to eq(kubernetes_service)
end
end
- describe '#api_field_names' do
+ describe "#api_field_names" do
let(:fake_service) do
Class.new(Service) do
def fields
[
- { name: 'token' },
- { name: 'api_token' },
- { name: 'key' },
- { name: 'api_key' },
- { name: 'password' },
- { name: 'password_field' },
- { name: 'safe_field' }
+ {name: "token"},
+ {name: "api_token"},
+ {name: "key"},
+ {name: "api_key"},
+ {name: "password"},
+ {name: "password_field"},
+ {name: "safe_field"},
]
end
end
@@ -331,22 +332,22 @@ describe Service do
let(:service) do
fake_service.new(properties: [
- { token: 'token-value' },
- { api_token: 'api_token-value' },
- { key: 'key-value' },
- { api_key: 'api_key-value' },
- { password: 'password-value' },
- { password_field: 'password_field-value' },
- { safe_field: 'safe_field-value' }
+ {token: "token-value"},
+ {api_token: "api_token-value"},
+ {key: "key-value"},
+ {api_key: "api_key-value"},
+ {password: "password-value"},
+ {password_field: "password_field-value"},
+ {safe_field: "safe_field-value"},
])
end
- it 'filters out sensitive fields' do
- expect(service.api_field_names).to eq(['safe_field'])
+ it "filters out sensitive fields" do
+ expect(service.api_field_names).to eq(["safe_field"])
end
end
- context 'logging' do
+ context "logging" do
let(:project) { create(:project) }
let(:service) { create(:service, project: project) }
let(:test_message) { "test message" }
@@ -356,20 +357,20 @@ describe Service do
project_path: project.full_path,
project_id: project.id,
message: test_message,
- additional_argument: 'some argument'
+ additional_argument: "some argument",
}
end
- it 'logs info messages using json logger' do
+ it "logs info messages using json logger" do
expect(Gitlab::JsonLogger).to receive(:info).with(arguments)
- service.log_info(test_message, additional_argument: 'some argument')
+ service.log_info(test_message, additional_argument: "some argument")
end
- it 'logs error messages using json logger' do
+ it "logs error messages using json logger" do
expect(Gitlab::JsonLogger).to receive(:error).with(arguments)
- service.log_error(test_message, additional_argument: 'some argument')
+ service.log_error(test_message, additional_argument: "some argument")
end
end
end
diff --git a/spec/models/shard_spec.rb b/spec/models/shard_spec.rb
index 83104711b55..e4a2ccee7d0 100644
--- a/spec/models/shard_spec.rb
+++ b/spec/models/shard_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literals: true
-require 'spec_helper'
+require "spec_helper"
describe Shard do
- describe '.populate!' do
- it 'creates shards based on the config file' do
+ describe ".populate!" do
+ it "creates shards based on the config file" do
expect(described_class.all).to be_empty
stub_storage_settings(foo: {}, bar: {}, baz: {})
@@ -14,37 +14,37 @@ describe Shard do
end
end
- describe '.by_name' do
- let(:default_shard) { described_class.find_by(name: 'default') }
+ describe ".by_name" do
+ let(:default_shard) { described_class.find_by(name: "default") }
before do
described_class.populate!
end
- it 'returns an existing shard' do
- expect(described_class.by_name('default')).to eq(default_shard)
+ it "returns an existing shard" do
+ expect(described_class.by_name("default")).to eq(default_shard)
end
- it 'creates a new shard' do
- result = described_class.by_name('foo')
+ it "creates a new shard" do
+ result = described_class.by_name("foo")
expect(result).not_to eq(default_shard)
- expect(result.name).to eq('foo')
+ expect(result.name).to eq("foo")
end
- it 'retries if creation races' do
+ it "retries if creation races" do
expect(described_class)
.to receive(:find_or_create_by)
- .with(name: 'default')
- .and_raise(ActiveRecord::RecordNotUnique, 'fail')
+ .with(name: "default")
+ .and_raise(ActiveRecord::RecordNotUnique, "fail")
.once
expect(described_class)
.to receive(:find_or_create_by)
- .with(name: 'default')
+ .with(name: "default")
.and_call_original
- expect(described_class.by_name('default')).to eq(default_shard)
+ expect(described_class.by_name("default")).to eq(default_shard)
end
end
end
diff --git a/spec/models/snippet_blob_spec.rb b/spec/models/snippet_blob_spec.rb
index 7c71c458fcc..f7a4a2d1d5c 100644
--- a/spec/models/snippet_blob_spec.rb
+++ b/spec/models/snippet_blob_spec.rb
@@ -1,45 +1,45 @@
-require 'spec_helper'
+require "spec_helper"
describe SnippetBlob do
let(:snippet) { create(:snippet) }
subject { described_class.new(snippet) }
- describe '#id' do
- it 'returns the snippet ID' do
+ describe "#id" do
+ it "returns the snippet ID" do
expect(subject.id).to eq(snippet.id)
end
end
- describe '#name' do
- it 'returns the snippet file name' do
+ describe "#name" do
+ it "returns the snippet file name" do
expect(subject.name).to eq(snippet.file_name)
end
end
- describe '#size' do
- it 'returns the data size' do
+ describe "#size" do
+ it "returns the data size" do
expect(subject.size).to eq(subject.data.bytesize)
end
end
- describe '#data' do
- it 'returns the snippet content' do
+ describe "#data" do
+ it "returns the snippet content" do
expect(subject.data).to eq(snippet.content)
end
end
- describe '#rendered_markup' do
- context 'when the content is GFM' do
- let(:snippet) { create(:snippet, file_name: 'file.md') }
+ describe "#rendered_markup" do
+ context "when the content is GFM" do
+ let(:snippet) { create(:snippet, file_name: "file.md") }
- it 'returns the rendered GFM' do
+ it "returns the rendered GFM" do
expect(subject.rendered_markup).to eq(snippet.content_html)
end
end
- context 'when the content is not GFM' do
- it 'returns nil' do
+ context "when the content is not GFM" do
+ it "returns nil" do
expect(subject.rendered_markup).to be_nil
end
end
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb
index 664dc3fa145..7f1809e2ea2 100644
--- a/spec/models/snippet_spec.rb
+++ b/spec/models/snippet_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Snippet do
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Gitlab::VisibilityLevel) }
@@ -11,14 +11,14 @@ describe Snippet do
it { is_expected.to include_module(Awardable) }
end
- describe 'associations' do
- it { is_expected.to belong_to(:author).class_name('User') }
+ describe "associations" do
+ it { is_expected.to belong_to(:author).class_name("User") }
it { is_expected.to belong_to(:project) }
it { is_expected.to have_many(:notes).dependent(:destroy) }
it { is_expected.to have_many(:award_emoji).dependent(:destroy) }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:author) }
it { is_expected.to validate_presence_of(:title) }
@@ -31,51 +31,51 @@ describe Snippet do
it { is_expected.to validate_inclusion_of(:visibility_level).in_array(Gitlab::VisibilityLevel.values) }
end
- describe '#to_reference' do
- context 'when snippet belongs to a project' do
- let(:project) { build(:project, name: 'sample-project') }
+ describe "#to_reference" do
+ context "when snippet belongs to a project" do
+ let(:project) { build(:project, name: "sample-project") }
let(:snippet) { build(:snippet, id: 1, project: project) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(snippet.to_reference).to eq "$1"
end
- it 'supports a cross-project reference' do
- another_project = build(:project, name: 'another-project', namespace: project.namespace)
+ it "supports a cross-project reference" do
+ another_project = build(:project, name: "another-project", namespace: project.namespace)
expect(snippet.to_reference(another_project)).to eq "sample-project$1"
end
end
- context 'when snippet does not belong to a project' do
+ context "when snippet does not belong to a project" do
let(:snippet) { build(:snippet, id: 1, project: nil) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(snippet.to_reference).to eq "$1"
end
- it 'still returns shortest reference when project arg present' do
- another_project = build(:project, name: 'another-project')
+ it "still returns shortest reference when project arg present" do
+ another_project = build(:project, name: "another-project")
expect(snippet.to_reference(another_project)).to eq "$1"
end
end
end
- describe '#file_name' do
+ describe "#file_name" do
let(:project) { create(:project) }
- context 'file_name is nil' do
+ context "file_name is nil" do
let(:snippet) { create(:snippet, project: project, file_name: nil) }
- it 'returns an empty string' do
- expect(snippet.file_name).to eq ''
+ it "returns an empty string" do
+ expect(snippet.file_name).to eq ""
end
end
- context 'file_name is not nil' do
- let(:snippet) { create(:snippet, project: project, file_name: 'foo.txt') }
+ context "file_name is not nil" do
+ let(:snippet) { create(:snippet, project: project, file_name: "foo.txt") }
- it 'returns the file_name' do
- expect(snippet.file_name).to eq 'foo.txt'
+ it "returns the file_name" do
+ expect(snippet.file_name).to eq "foo.txt"
end
end
end
@@ -87,53 +87,53 @@ describe Snippet do
end
end
- describe '.search' do
- let(:snippet) { create(:snippet, title: 'test snippet') }
+ describe ".search" do
+ let(:snippet) { create(:snippet, title: "test snippet") }
- it 'returns snippets with a matching title' do
+ it "returns snippets with a matching title" do
expect(described_class.search(snippet.title)).to eq([snippet])
end
- it 'returns snippets with a partially matching title' do
+ it "returns snippets with a partially matching title" do
expect(described_class.search(snippet.title[0..2])).to eq([snippet])
end
- it 'returns snippets with a matching title regardless of the casing' do
+ it "returns snippets with a matching title regardless of the casing" do
expect(described_class.search(snippet.title.upcase)).to eq([snippet])
end
- it 'returns snippets with a matching file name' do
+ it "returns snippets with a matching file name" do
expect(described_class.search(snippet.file_name)).to eq([snippet])
end
- it 'returns snippets with a partially matching file name' do
+ it "returns snippets with a partially matching file name" do
expect(described_class.search(snippet.file_name[0..2])).to eq([snippet])
end
- it 'returns snippets with a matching file name regardless of the casing' do
+ it "returns snippets with a matching file name regardless of the casing" do
expect(described_class.search(snippet.file_name.upcase)).to eq([snippet])
end
end
- describe '.search_code' do
- let(:snippet) { create(:snippet, content: 'class Foo; end') }
+ describe ".search_code" do
+ let(:snippet) { create(:snippet, content: "class Foo; end") }
- it 'returns snippets with matching content' do
+ it "returns snippets with matching content" do
expect(described_class.search_code(snippet.content)).to eq([snippet])
end
- it 'returns snippets with partially matching content' do
- expect(described_class.search_code('class')).to eq([snippet])
+ it "returns snippets with partially matching content" do
+ expect(described_class.search_code("class")).to eq([snippet])
end
- it 'returns snippets with matching content regardless of the casing' do
- expect(described_class.search_code('FOO')).to eq([snippet])
+ it "returns snippets with matching content regardless of the casing" do
+ expect(described_class.search_code("FOO")).to eq([snippet])
end
end
- describe '.with_optional_visibility' do
- context 'when a visibility level is provided' do
- it 'returns snippets with the given visibility' do
+ describe ".with_optional_visibility" do
+ context "when a visibility level is provided" do
+ it "returns snippets with the given visibility" do
create(:snippet, :private)
snippet = create(:snippet, :public)
@@ -144,8 +144,8 @@ describe Snippet do
end
end
- context 'when a visibility level is not provided' do
- it 'returns all snippets' do
+ context "when a visibility level is not provided" do
+ it "returns all snippets" do
snippet1 = create(:snippet, :public)
snippet2 = create(:snippet, :private)
snippets = described_class.with_optional_visibility
@@ -155,8 +155,8 @@ describe Snippet do
end
end
- describe '.only_global_snippets' do
- it 'returns snippets not associated with any projects' do
+ describe ".only_global_snippets" do
+ it "returns snippets not associated with any projects" do
create(:project_snippet)
snippet = create(:snippet)
@@ -166,7 +166,7 @@ describe Snippet do
end
end
- describe '.only_include_projects_visible_to' do
+ describe ".only_include_projects_visible_to" do
let!(:project1) { create(:project, :public) }
let!(:project2) { create(:project, :internal) }
let!(:project3) { create(:project, :private) }
@@ -174,8 +174,8 @@ describe Snippet do
let!(:snippet2) { create(:project_snippet, project: project2) }
let!(:snippet3) { create(:project_snippet, project: project3) }
- context 'when a user is provided' do
- it 'returns snippets visible to the user' do
+ context "when a user is provided" do
+ it "returns snippets visible to the user" do
user = create(:user)
snippets = described_class.only_include_projects_visible_to(user)
@@ -185,8 +185,8 @@ describe Snippet do
end
end
- context 'when a user is not provided' do
- it 'returns snippets visible to anonymous users' do
+ context "when a user is not provided" do
+ it "returns snippets visible to anonymous users" do
snippets = described_class.only_include_projects_visible_to
expect(snippets).to include(snippet1)
@@ -195,9 +195,9 @@ describe Snippet do
end
end
- describe 'only_include_projects_with_snippets_enabled' do
- context 'when the include_private option is enabled' do
- it 'includes snippets for projects with snippets set to private' do
+ describe "only_include_projects_with_snippets_enabled" do
+ context "when the include_private option is enabled" do
+ it "includes snippets for projects with snippets set to private" do
project = create(:project)
project.project_feature
@@ -212,8 +212,8 @@ describe Snippet do
end
end
- context 'when the include_private option is not enabled' do
- it 'does not include snippets for projects that have snippets set to private' do
+ context "when the include_private option is not enabled" do
+ it "does not include snippets for projects that have snippets set to private" do
project = create(:project)
project.project_feature
@@ -227,7 +227,7 @@ describe Snippet do
end
end
- it 'includes snippets for projects with snippets enabled' do
+ it "includes snippets for projects with snippets enabled" do
project = create(:project)
project.project_feature
@@ -240,8 +240,8 @@ describe Snippet do
end
end
- describe '.only_include_authorized_projects' do
- it 'only includes snippets for projects the user is authorized to see' do
+ describe ".only_include_authorized_projects" do
+ it "only includes snippets for projects the user is authorized to see" do
user = create(:user)
project1 = create(:project, :private)
project2 = create(:project, :private)
@@ -257,9 +257,9 @@ describe Snippet do
end
end
- describe '.for_project_with_user' do
- context 'when a user is provided' do
- it 'returns an empty collection if the user can not view the snippets' do
+ describe ".for_project_with_user" do
+ context "when a user is provided" do
+ it "returns an empty collection if the user can not view the snippets" do
project = create(:project, :private)
user = create(:user)
@@ -271,7 +271,7 @@ describe Snippet do
expect(described_class.for_project_with_user(project, user)).to be_empty
end
- it 'returns the snippets if the user is a member of the project' do
+ it "returns the snippets if the user is a member of the project" do
project = create(:project, :private)
user = create(:user)
snippet = create(:project_snippet, project: project)
@@ -283,7 +283,7 @@ describe Snippet do
expect(snippets).to eq([snippet])
end
- it 'returns public snippets for a public project the user is not a member of' do
+ it "returns public snippets for a public project the user is not a member of" do
project = create(:project, :public)
project.project_feature
@@ -300,8 +300,8 @@ describe Snippet do
end
end
- context 'when a user is not provided' do
- it 'returns an empty collection for a private project' do
+ context "when a user is not provided" do
+ it "returns an empty collection for a private project" do
project = create(:project, :private)
project.project_feature
@@ -312,7 +312,7 @@ describe Snippet do
expect(described_class.for_project_with_user(project)).to be_empty
end
- it 'returns public snippets for a public project' do
+ it "returns public snippets for a public project" do
project = create(:project, :public)
snippet = create(:project_snippet, :public, project: project)
@@ -328,8 +328,8 @@ describe Snippet do
end
end
- describe '.visible_to_or_authored_by' do
- it 'returns snippets visible to the user' do
+ describe ".visible_to_or_authored_by" do
+ it "returns snippets visible to the user" do
user = create(:user)
snippet1 = create(:snippet, :public)
snippet2 = create(:snippet, :private, author: user)
@@ -342,34 +342,34 @@ describe Snippet do
end
end
- describe '#participants' do
+ describe "#participants" do
let(:project) { create(:project, :public) }
- let(:snippet) { create(:snippet, content: 'foo', project: project) }
+ let(:snippet) { create(:snippet, content: "foo", project: project) }
let!(:note1) do
create(:note_on_project_snippet,
- noteable: snippet,
- project: project,
- note: 'a')
+ noteable: snippet,
+ project: project,
+ note: "a")
end
let!(:note2) do
create(:note_on_project_snippet,
- noteable: snippet,
- project: project,
- note: 'b')
+ noteable: snippet,
+ project: project,
+ note: "b")
end
- it 'includes the snippet author' do
+ it "includes the snippet author" do
expect(snippet.participants).to include(snippet.author)
end
- it 'includes the note authors' do
+ it "includes the note authors" do
expect(snippet.participants).to include(note1.author, note2.author)
end
end
- describe '#check_for_spam' do
+ describe "#check_for_spam" do
let(:snippet) { create :snippet, visibility_level: visibility_level }
subject do
@@ -377,24 +377,24 @@ describe Snippet do
snippet.check_for_spam?
end
- context 'when public and spammable attributes changed' do
+ context "when public and spammable attributes changed" do
let(:visibility_level) { Snippet::PUBLIC }
- let(:title) { 'woo' }
+ let(:title) { "woo" }
- it 'returns true' do
+ it "returns true" do
is_expected.to be_truthy
end
end
- context 'when private' do
+ context "when private" do
let(:visibility_level) { Snippet::PRIVATE }
let(:title) { snippet.title }
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
- it 'returns true when switching to public' do
+ it "returns true when switching to public" do
snippet.save!
snippet.visibility_level = Snippet::PUBLIC
@@ -402,20 +402,20 @@ describe Snippet do
end
end
- context 'when spammable attributes have not changed' do
+ context "when spammable attributes have not changed" do
let(:visibility_level) { Snippet::PUBLIC }
let(:title) { snippet.title }
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
end
end
- describe '#blob' do
+ describe "#blob" do
let(:snippet) { create(:snippet) }
- it 'returns a blob representing the snippet data' do
+ it "returns a blob representing the snippet data" do
blob = snippet.blob
expect(blob).to be_a(Blob)
@@ -424,20 +424,20 @@ describe Snippet do
end
end
- describe '#embeddable?' do
- context 'project snippet' do
+ describe "#embeddable?" do
+ context "project snippet" do
[
- { project: :public, snippet: :public, embeddable: true },
- { project: :internal, snippet: :public, embeddable: false },
- { project: :private, snippet: :public, embeddable: false },
- { project: :public, snippet: :internal, embeddable: false },
- { project: :internal, snippet: :internal, embeddable: false },
- { project: :private, snippet: :internal, embeddable: false },
- { project: :public, snippet: :private, embeddable: false },
- { project: :internal, snippet: :private, embeddable: false },
- { project: :private, snippet: :private, embeddable: false }
+ {project: :public, snippet: :public, embeddable: true},
+ {project: :internal, snippet: :public, embeddable: false},
+ {project: :private, snippet: :public, embeddable: false},
+ {project: :public, snippet: :internal, embeddable: false},
+ {project: :internal, snippet: :internal, embeddable: false},
+ {project: :private, snippet: :internal, embeddable: false},
+ {project: :public, snippet: :private, embeddable: false},
+ {project: :internal, snippet: :private, embeddable: false},
+ {project: :private, snippet: :private, embeddable: false},
].each do |combination|
- it 'only returns true when both project and snippet are public' do
+ it "only returns true when both project and snippet are public" do
project = create(:project, combination[:project])
snippet = create(:project_snippet, combination[:snippet], project: project)
@@ -446,13 +446,13 @@ describe Snippet do
end
end
- context 'personal snippet' do
+ context "personal snippet" do
[
- { snippet: :public, embeddable: true },
- { snippet: :internal, embeddable: false },
- { snippet: :private, embeddable: false }
+ {snippet: :public, embeddable: true},
+ {snippet: :internal, embeddable: false},
+ {snippet: :private, embeddable: false},
].each do |combination|
- it 'only returns true when snippet is public' do
+ it "only returns true when snippet is public" do
snippet = create(:personal_snippet, combination[:snippet])
expect(snippet.embeddable?).to eq(combination[:embeddable])
diff --git a/spec/models/spam_log_spec.rb b/spec/models/spam_log_spec.rb
index 90a2caaeb88..0c3875c4cb5 100644
--- a/spec/models/spam_log_spec.rb
+++ b/spec/models/spam_log_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe SpamLog do
let(:admin) { create(:admin) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:user) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:user) }
end
- describe '#remove_user' do
- it 'blocks the user' do
+ describe "#remove_user" do
+ it "blocks the user" do
spam_log = build(:spam_log)
expect { spam_log.remove_user(deleted_by: admin) }.to change { spam_log.user.blocked? }.to(true)
end
- it 'removes the user' do
+ it "removes the user" do
spam_log = build(:spam_log)
user = spam_log.user
diff --git a/spec/models/ssh_host_key_spec.rb b/spec/models/ssh_host_key_spec.rb
index 4c677569561..e4b6cfdf2bd 100644
--- a/spec/models/ssh_host_key_spec.rb
+++ b/spec/models/ssh_host_key_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe SshHostKey do
using RSpec::Parameterized::TableSyntax
include ReactiveCachingHelpers
let(:key1) do
- 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3UpyF2iLqy1d63M6k3jH1vuEnq/NWtE+o' \
- 'rJe1Xn7JoRbduKd6zpsJ0JhBGWgcQK0ph0aGW5PcudzzBSc+SlYfCc4GTaxDtmj41hW0o72m' \
- 'NiuDW3oKXXShOiVRde2ZOquH8Z865jGiZIC8BI/bXZD29IGUih0hPu7Rjp70VYiE+35QRf/p' \
- 'sD0Ddrz8QUIG3A/2dMzLI5F5ZORk3BIX2F3mJwJOvZxRhR/SqyphDMZ5eZ0EzqbFBCDE6HAB' \
- 'Woz9ck8RBGLvCIggmDHj3FmMLcQGMDiy6wKp7QdnBtxjCP6vtE6YPUM223AqsWt+9NTtCfB8' \
- 'YdNAH7YcHHOR1FgtSk1x'
+ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3UpyF2iLqy1d63M6k3jH1vuEnq/NWtE+o" \
+ "rJe1Xn7JoRbduKd6zpsJ0JhBGWgcQK0ph0aGW5PcudzzBSc+SlYfCc4GTaxDtmj41hW0o72m" \
+ "NiuDW3oKXXShOiVRde2ZOquH8Z865jGiZIC8BI/bXZD29IGUih0hPu7Rjp70VYiE+35QRf/p" \
+ "sD0Ddrz8QUIG3A/2dMzLI5F5ZORk3BIX2F3mJwJOvZxRhR/SqyphDMZ5eZ0EzqbFBCDE6HAB" \
+ "Woz9ck8RBGLvCIggmDHj3FmMLcQGMDiy6wKp7QdnBtxjCP6vtE6YPUM223AqsWt+9NTtCfB8" \
+ "YdNAH7YcHHOR1FgtSk1x"
end
let(:key2) do
- 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLIp+4ciR2YO9f9rpldc7InNQw/TBUtcNb' \
- 'J2XR0rr15/5ytz7YM16xXG0Qjx576PNSmqs4gbTrvTuFZak+v1Jx/9deHRq/yqp9f+tv33+i' \
- 'aJGCQCX/+OVY7aWgV2R9YsS7XQ4mnv4XlOTEssib/rGAIT+ATd/GcdYSEOO+dh4O09/6O/jI' \
- 'MGSeP+NNetgn1nPCnLOjrXFZUnUtNDi6EEKeIlrliJjSb7Jr4f7gjvZnv4RskWHHFo8FgAAq' \
- 't0gOMT6EmKrnypBe2vLGSAXbtkXr01q6/DNPH+n9VA1LTV6v1KN/W5CN5tQV11wRSKiM8g5O' \
- 'Ebi86VjJRi2sOuYoXQU1'
+ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLIp+4ciR2YO9f9rpldc7InNQw/TBUtcNb" \
+ "J2XR0rr15/5ytz7YM16xXG0Qjx576PNSmqs4gbTrvTuFZak+v1Jx/9deHRq/yqp9f+tv33+i" \
+ "aJGCQCX/+OVY7aWgV2R9YsS7XQ4mnv4XlOTEssib/rGAIT+ATd/GcdYSEOO+dh4O09/6O/jI" \
+ "MGSeP+NNetgn1nPCnLOjrXFZUnUtNDi6EEKeIlrliJjSb7Jr4f7gjvZnv4RskWHHFo8FgAAq" \
+ "t0gOMT6EmKrnypBe2vLGSAXbtkXr01q6/DNPH+n9VA1LTV6v1KN/W5CN5tQV11wRSKiM8g5O" \
+ "Ebi86VjJRi2sOuYoXQU1"
end
# Purposefully ordered so that `sort` will make changes
@@ -41,36 +41,36 @@ describe SshHostKey do
stderr = double(:stderr, read: stderr)
wait_thr = double(:wait_thr, value: double(success?: status))
- expect(Open3).to receive(:popen3).with({}, 'ssh-keyscan', *args).and_yield(stdin, stdout, stderr, wait_thr)
+ expect(Open3).to receive(:popen3).with({}, "ssh-keyscan", *args).and_yield(stdin, stdout, stderr, wait_thr)
stdin
end
let(:project) { build(:project) }
- subject(:ssh_host_key) { described_class.new(project: project, url: 'ssh://example.com:2222', compare_host_keys: compare_host_keys) }
+ subject(:ssh_host_key) { described_class.new(project: project, url: "ssh://example.com:2222", compare_host_keys: compare_host_keys) }
- describe '.primary_key' do
- it 'returns a symbol' do
+ describe ".primary_key" do
+ it "returns a symbol" do
expect(described_class.primary_key).to eq(:id)
end
end
- describe '.find_by' do
+ describe ".find_by" do
let(:project) { create(:project) }
- let(:url) { 'ssh://invalid.invalid:2222' }
+ let(:url) { "ssh://invalid.invalid:2222" }
- let(:finding_id) { [project.id, url].join(':') }
+ let(:finding_id) { [project.id, url].join(":") }
- it 'accepts a string key' do
- result = described_class.find_by('id' => finding_id)
+ it "accepts a string key" do
+ result = described_class.find_by("id" => finding_id)
expect(result).to be_a(described_class)
expect(result.project).to eq(project)
expect(result.url.to_s).to eq(url)
end
- it 'accepts a symbol key' do
+ it "accepts a symbol key" do
result = described_class.find_by(id: finding_id)
expect(result).to be_a(described_class)
@@ -79,52 +79,52 @@ describe SshHostKey do
end
end
- describe '#fingerprints', :use_clean_rails_memory_store_caching do
- it 'returns an array of indexed fingerprints when the cache is filled' do
+ describe "#fingerprints", :use_clean_rails_memory_store_caching do
+ it "returns an array of indexed fingerprints when the cache is filled" do
stub_reactive_cache(ssh_host_key, known_hosts: known_hosts)
expected = [key1, key2]
.map { |data| Gitlab::SSHPublicKey.new(data) }
.each_with_index
- .map { |key, i| { bits: key.bits, fingerprint: key.fingerprint, type: key.type, index: i } }
+ .map { |key, i| {bits: key.bits, fingerprint: key.fingerprint, type: key.type, index: i} }
expect(ssh_host_key.fingerprints.as_json).to eq(expected)
end
- it 'returns an empty array when the cache is empty' do
+ it "returns an empty array when the cache is empty" do
expect(ssh_host_key.fingerprints).to eq([])
end
end
- describe '#fingerprints', :use_clean_rails_memory_store_caching do
- it 'returns an array of indexed fingerprints when the cache is filled' do
+ describe "#fingerprints", :use_clean_rails_memory_store_caching do
+ it "returns an array of indexed fingerprints when the cache is filled" do
stub_reactive_cache(ssh_host_key, known_hosts: known_hosts)
expect(ssh_host_key.fingerprints.as_json).to eq(
[
- { bits: 2048, fingerprint: Gitlab::SSHPublicKey.new(key1).fingerprint, type: :rsa, index: 0 },
- { bits: 2048, fingerprint: Gitlab::SSHPublicKey.new(key2).fingerprint, type: :rsa, index: 1 }
+ {bits: 2048, fingerprint: Gitlab::SSHPublicKey.new(key1).fingerprint, type: :rsa, index: 0},
+ {bits: 2048, fingerprint: Gitlab::SSHPublicKey.new(key2).fingerprint, type: :rsa, index: 1},
]
)
end
- it 'returns an empty array when the cache is empty' do
+ it "returns an empty array when the cache is empty" do
expect(ssh_host_key.fingerprints).to eq([])
end
end
- describe '#host_keys_changed?' do
+ describe "#host_keys_changed?" do
where(:known_hosts_a, :known_hosts_b, :result) do
known_hosts | extra | true
known_hosts | "foo\n" | true
- known_hosts | '' | true
+ known_hosts | "" | true
known_hosts | nil | true
known_hosts | known_hosts | false
reversed | known_hosts | false
extra | "foo\n" | true
- '' | '' | false
+ "" | "" | false
nil | nil | false
- '' | nil | false
+ "" | nil | false
end
with_them do
@@ -132,7 +132,7 @@ describe SshHostKey do
subject { ssh_host_key.host_keys_changed? }
- context '(normal)' do
+ context "(normal)" do
let(:compare_host_keys) { known_hosts_b }
before do
@@ -143,7 +143,7 @@ describe SshHostKey do
end
# Comparisons should be symmetrical, so test the reverse too
- context '(reversed)' do
+ context "(reversed)" do
let(:compare_host_keys) { known_hosts_a }
before do
@@ -155,10 +155,10 @@ describe SshHostKey do
end
end
- describe '#calculate_reactive_cache' do
+ describe "#calculate_reactive_cache" do
subject(:cache) { ssh_host_key.calculate_reactive_cache }
- it 'writes the hostname to STDIN' do
+ it "writes the hostname to STDIN" do
stdin = stub_ssh_keyscan(%w[-T 5 -p 2222 -f-])
cache
@@ -166,27 +166,27 @@ describe SshHostKey do
expect(stdin.string).to eq("example.com\n")
end
- context 'successful key scan' do
- it 'stores the cleaned known_hosts data' do
+ context "successful key scan" do
+ it "stores the cleaned known_hosts data" do
stub_ssh_keyscan(%w[-T 5 -p 2222 -f-], stdout: "KEY 1\nKEY 1\n\n# comment\nKEY 2\n")
is_expected.to eq(known_hosts: "KEY 1\nKEY 2\n")
end
end
- context 'failed key scan (exit code 1)' do
- it 'returns a generic error' do
- stub_ssh_keyscan(%w[-T 5 -p 2222 -f-], stdout: 'blarg', status: false)
+ context "failed key scan (exit code 1)" do
+ it "returns a generic error" do
+ stub_ssh_keyscan(%w[-T 5 -p 2222 -f-], stdout: "blarg", status: false)
- is_expected.to eq(error: 'Failed to detect SSH host keys')
+ is_expected.to eq(error: "Failed to detect SSH host keys")
end
end
- context 'failed key scan (exit code 0)' do
- it 'returns a generic error' do
- stub_ssh_keyscan(%w[-T 5 -p 2222 -f-], stderr: 'Unknown host')
+ context "failed key scan (exit code 0)" do
+ it "returns a generic error" do
+ stub_ssh_keyscan(%w[-T 5 -p 2222 -f-], stderr: "Unknown host")
- is_expected.to eq(error: 'Failed to detect SSH host keys')
+ is_expected.to eq(error: "Failed to detect SSH host keys")
end
end
end
diff --git a/spec/models/subscription_spec.rb b/spec/models/subscription_spec.rb
index 9e4c2620d82..867e981a00b 100644
--- a/spec/models/subscription_spec.rb
+++ b/spec/models/subscription_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Subscription do
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:subscribable) }
it { is_expected.to belong_to(:user) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:subscribable) }
it { is_expected.to validate_presence_of(:user) }
- it 'validates uniqueness of project_id scoped to subscribable_id, subscribable_type, and user_id' do
+ it "validates uniqueness of project_id scoped to subscribable_id, subscribable_type, and user_id" do
create(:subscription)
expect(subject).to validate_uniqueness_of(:project_id).scoped_to([:subscribable_id, :subscribable_type, :user_id])
diff --git a/spec/models/suggestion_spec.rb b/spec/models/suggestion_spec.rb
index cafc725dddb..bd3dbd85acc 100644
--- a/spec/models/suggestion_spec.rb
+++ b/spec/models/suggestion_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Suggestion do
let(:suggestion) { create(:suggestion) }
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:note) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:note) }
- context 'when suggestion is applied' do
+ context "when suggestion is applied" do
before do
allow(subject).to receive(:applied?).and_return(true)
end
@@ -21,9 +21,9 @@ describe Suggestion do
end
end
- describe '#appliable?' do
- context 'when note does not support suggestions' do
- it 'returns false' do
+ describe "#appliable?" do
+ context "when note does not support suggestions" do
+ it "returns false" do
expect_next_instance_of(DiffNote) do |note|
allow(note).to receive(:supports_suggestion?) { false }
end
@@ -32,15 +32,15 @@ describe Suggestion do
end
end
- context 'when patch is already applied' do
+ context "when patch is already applied" do
let(:suggestion) { create(:suggestion, :applied) }
- it 'returns false' do
+ it "returns false" do
expect(suggestion).not_to be_appliable
end
end
- context 'when merge request is not opened' do
+ context "when merge request is not opened" do
let(:merge_request) { create(:merge_request, :merged) }
let(:note) do
create(:diff_note_on_merge_request, project: merge_request.project,
@@ -49,7 +49,7 @@ describe Suggestion do
let(:suggestion) { create(:suggestion, note: note) }
- it 'returns false' do
+ it "returns false" do
expect(suggestion).not_to be_appliable
end
end
diff --git a/spec/models/system_note_metadata_spec.rb b/spec/models/system_note_metadata_spec.rb
index 1e3f587e460..9ede4a0d024 100644
--- a/spec/models/system_note_metadata_spec.rb
+++ b/spec/models/system_note_metadata_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemNoteMetadata do
- describe 'associations' do
+ describe "associations" do
it { is_expected.to belong_to(:note) }
end
- describe 'validation' do
+ describe "validation" do
it { is_expected.to validate_presence_of(:note) }
- context 'when action type is invalid' do
+ context "when action type is invalid" do
subject do
- build(:system_note_metadata, note: build(:note), action: 'invalid_type' )
+ build(:system_note_metadata, note: build(:note), action: "invalid_type")
end
it { is_expected.to be_invalid }
end
- context 'when action type is valid' do
+ context "when action type is valid" do
subject do
- build(:system_note_metadata, note: build(:note), action: 'merge' )
+ build(:system_note_metadata, note: build(:note), action: "merge")
end
it { is_expected.to be_valid }
diff --git a/spec/models/term_agreement_spec.rb b/spec/models/term_agreement_spec.rb
index 950dfa09a6a..9a7e132f7bd 100644
--- a/spec/models/term_agreement_spec.rb
+++ b/spec/models/term_agreement_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe TermAgreement do
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:term) }
it { is_expected.to validate_presence_of(:user) }
end
- describe '.accepted' do
- it 'only includes accepted terms' do
+ describe ".accepted" do
+ it "only includes accepted terms" do
accepted = create(:term_agreement, :accepted)
create(:term_agreement, :declined)
diff --git a/spec/models/timelog_spec.rb b/spec/models/timelog_spec.rb
index a0c93c531ea..ee6cc0138dc 100644
--- a/spec/models/timelog_spec.rb
+++ b/spec/models/timelog_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
RSpec.describe Timelog do
subject { build(:timelog) }
@@ -13,27 +13,27 @@ RSpec.describe Timelog do
it { is_expected.to validate_presence_of(:time_spent) }
it { is_expected.to validate_presence_of(:user) }
- describe 'Issuable validation' do
- it 'is invalid if issue_id and merge_request_id are missing' do
- subject.attributes = { issue: nil, merge_request: nil }
+ describe "Issuable validation" do
+ it "is invalid if issue_id and merge_request_id are missing" do
+ subject.attributes = {issue: nil, merge_request: nil}
expect(subject).to be_invalid
end
- it 'is invalid if issue_id and merge_request_id are set' do
- subject.attributes = { issue: issue, merge_request: merge_request }
+ it "is invalid if issue_id and merge_request_id are set" do
+ subject.attributes = {issue: issue, merge_request: merge_request}
expect(subject).to be_invalid
end
- it 'is valid if only issue_id is set' do
- subject.attributes = { issue: issue, merge_request: nil }
+ it "is valid if only issue_id is set" do
+ subject.attributes = {issue: issue, merge_request: nil}
expect(subject).to be_valid
end
- it 'is valid if only merge_request_id is set' do
- subject.attributes = { merge_request: merge_request, issue: nil }
+ it "is valid if only merge_request_id is set" do
+ subject.attributes = {merge_request: merge_request, issue: nil}
expect(subject).to be_valid
end
diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb
index 3682e21ca40..66b5052760c 100644
--- a/spec/models/todo_spec.rb
+++ b/spec/models/todo_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Todo do
let(:issue) { create(:issue) }
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:author).class_name("User") }
it { is_expected.to belong_to(:note) }
it { is_expected.to belong_to(:project) }
@@ -12,25 +12,25 @@ describe Todo do
it { is_expected.to belong_to(:user) }
end
- describe 'respond to' do
+ describe "respond to" do
it { is_expected.to respond_to(:author_name) }
it { is_expected.to respond_to(:author_email) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:action) }
it { is_expected.to validate_presence_of(:target_type) }
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:author) }
- context 'for commits' do
- subject { described_class.new(target_type: 'Commit') }
+ context "for commits" do
+ subject { described_class.new(target_type: "Commit") }
it { is_expected.to validate_presence_of(:commit_id) }
it { is_expected.not_to validate_presence_of(:target_id) }
end
- context 'for issuables' do
+ context "for issuables" do
subject { described_class.new(target: issue) }
it { is_expected.to validate_presence_of(:target_id) }
@@ -38,117 +38,117 @@ describe Todo do
end
end
- describe '#body' do
+ describe "#body" do
before do
- subject.target = build(:issue, title: 'Bugfix')
+ subject.target = build(:issue, title: "Bugfix")
end
- it 'returns target title when note is blank' do
+ it "returns target title when note is blank" do
subject.note = nil
- expect(subject.body).to eq 'Bugfix'
+ expect(subject.body).to eq "Bugfix"
end
- it 'returns note when note is present' do
- subject.note = build(:note, note: 'quick fix')
+ it "returns note when note is present" do
+ subject.note = build(:note, note: "quick fix")
- expect(subject.body).to eq 'quick fix'
+ expect(subject.body).to eq "quick fix"
end
end
- describe '#done' do
- it 'changes state to done' do
+ describe "#done" do
+ it "changes state to done" do
todo = create(:todo, state: :pending)
- expect { todo.done }.to change(todo, :state).from('pending').to('done')
+ expect { todo.done }.to change(todo, :state).from("pending").to("done")
end
- it 'does not raise error when is already done' do
+ it "does not raise error when is already done" do
todo = create(:todo, state: :done)
expect { todo.done }.not_to raise_error
end
end
- describe '#for_commit?' do
- it 'returns true when target is a commit' do
- subject.target_type = 'Commit'
+ describe "#for_commit?" do
+ it "returns true when target is a commit" do
+ subject.target_type = "Commit"
expect(subject.for_commit?).to eq true
end
- it 'returns false when target is an issuable' do
- subject.target_type = 'Issue'
+ it "returns false when target is an issuable" do
+ subject.target_type = "Issue"
expect(subject.for_commit?).to eq false
end
end
- describe '#target' do
- context 'for commits' do
+ describe "#target" do
+ context "for commits" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
- it 'returns an instance of Commit when exists' do
+ it "returns an instance of Commit when exists" do
subject.project = project
- subject.target_type = 'Commit'
+ subject.target_type = "Commit"
subject.commit_id = commit.id
expect(subject.target).to be_a(Commit)
expect(subject.target).to eq commit
end
- it 'returns nil when does not exists' do
+ it "returns nil when does not exists" do
subject.project = project
- subject.target_type = 'Commit'
- subject.commit_id = 'xxxx'
+ subject.target_type = "Commit"
+ subject.commit_id = "xxxx"
expect(subject.target).to be_nil
end
end
- it 'returns the issuable for issuables' do
+ it "returns the issuable for issuables" do
subject.target_id = issue.id
subject.target_type = issue.class.name
expect(subject.target).to eq issue
end
end
- describe '#target_reference' do
- it 'returns commit full reference with short id' do
+ describe "#target_reference" do
+ it "returns commit full reference with short id" do
project = create(:project, :repository)
commit = project.commit
subject.project = project
- subject.target_type = 'Commit'
+ subject.target_type = "Commit"
subject.commit_id = commit.id
expect(subject.target_reference).to eq commit.reference_link_text(full: true)
end
- it 'returns full reference for issuables' do
+ it "returns full reference for issuables" do
subject.target = issue
expect(subject.target_reference).to eq issue.to_reference(full: true)
end
end
- describe '#self_added?' do
+ describe "#self_added?" do
let(:user_1) { build(:user) }
before do
subject.user = user_1
end
- it 'is true when the user is the author' do
+ it "is true when the user is the author" do
subject.author = user_1
expect(subject).to be_self_added
end
- it 'is false when the user is not the author' do
+ it "is false when the user is not the author" do
subject.author = build(:user)
expect(subject).not_to be_self_added
end
end
- describe '#self_assigned?' do
+ describe "#self_assigned?" do
let(:user_1) { build(:user) }
before do
@@ -157,25 +157,25 @@ describe Todo do
subject.action = Todo::ASSIGNED
end
- it 'is true when todo is ASSIGNED and self_added' do
+ it "is true when todo is ASSIGNED and self_added" do
expect(subject).to be_self_assigned
end
- it 'is false when the todo is not ASSIGNED' do
+ it "is false when the todo is not ASSIGNED" do
subject.action = Todo::MENTIONED
expect(subject).not_to be_self_assigned
end
- it 'is false when todo is not self_added' do
+ it "is false when todo is not self_added" do
subject.author = build(:user)
expect(subject).not_to be_self_assigned
end
end
- describe '.for_action' do
- it 'returns the todos for a given action' do
+ describe ".for_action" do
+ it "returns the todos for a given action" do
create(:todo, action: Todo::MENTIONED)
todo = create(:todo, action: Todo::ASSIGNED)
@@ -184,8 +184,8 @@ describe Todo do
end
end
- describe '.for_author' do
- it 'returns the todos for a given author' do
+ describe ".for_author" do
+ it "returns the todos for a given author" do
user1 = create(:user)
user2 = create(:user)
todo = create(:todo, author: user1)
@@ -196,8 +196,8 @@ describe Todo do
end
end
- describe '.for_project' do
- it 'returns the todos for a given project' do
+ describe ".for_project" do
+ it "returns the todos for a given project" do
project1 = create(:project)
project2 = create(:project)
todo = create(:todo, project: project1)
@@ -208,8 +208,8 @@ describe Todo do
end
end
- describe '.for_group' do
- it 'returns the todos for a given group' do
+ describe ".for_group" do
+ it "returns the todos for a given group" do
group1 = create(:group)
group2 = create(:group)
todo = create(:todo, group: group1)
@@ -220,8 +220,8 @@ describe Todo do
end
end
- describe '.for_type' do
- it 'returns the todos for a given target type' do
+ describe ".for_type" do
+ it "returns the todos for a given target type" do
todo = create(:todo, target: create(:issue))
create(:todo, target: create(:merge_request))
@@ -230,8 +230,8 @@ describe Todo do
end
end
- describe '.for_target' do
- it 'returns the todos for a given target' do
+ describe ".for_target" do
+ it "returns the todos for a given target" do
todo = create(:todo, target: create(:issue))
create(:todo, target: create(:merge_request))
@@ -241,18 +241,18 @@ describe Todo do
end
end
- describe '.for_commit' do
- it 'returns the todos for a commit ID' do
- todo = create(:todo, commit_id: '123')
+ describe ".for_commit" do
+ it "returns the todos for a commit ID" do
+ todo = create(:todo, commit_id: "123")
- create(:todo, commit_id: '456')
+ create(:todo, commit_id: "456")
- expect(described_class.for_commit('123')).to eq([todo])
+ expect(described_class.for_commit("123")).to eq([todo])
end
end
- describe '.for_group_and_descendants' do
- it 'returns the todos for a group and its descendants' do
+ describe ".for_group_and_descendants" do
+ it "returns the todos for a group and its descendants" do
parent_group = create(:group)
child_group = create(:group, parent: parent_group)
@@ -268,32 +268,32 @@ describe Todo do
end
end
- describe '.any_for_target?' do
- it 'returns true if there are todos for a given target' do
+ describe ".any_for_target?" do
+ it "returns true if there are todos for a given target" do
todo = create(:todo)
expect(described_class.any_for_target?(todo.target)).to eq(true)
end
- it 'returns false if there are no todos for a given target' do
+ it "returns false if there are no todos for a given target" do
issue = create(:issue)
expect(described_class.any_for_target?(issue)).to eq(false)
end
end
- describe '.update_state' do
- it 'updates the state of todos' do
+ describe ".update_state" do
+ it "updates the state of todos" do
todo = create(:todo, :pending)
ids = described_class.update_state(:done)
todo.reload
expect(ids).to eq([todo.id])
- expect(todo.state).to eq('done')
+ expect(todo.state).to eq("done")
end
- it 'does not update todos that already have the given state' do
+ it "does not update todos that already have the given state" do
create(:todo, :pending)
expect(described_class.update_state(:pending)).to be_empty
diff --git a/spec/models/tree_spec.rb b/spec/models/tree_spec.rb
index 6bdb62a0864..263dde639c4 100644
--- a/spec/models/tree_spec.rb
+++ b/spec/models/tree_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Tree do
let(:repository) { create(:project, :repository).repository }
let(:sha) { repository.root_ref }
- subject { described_class.new(repository, '54fcc214') }
+ subject { described_class.new(repository, "54fcc214") }
- describe '#readme' do
+ describe "#readme" do
class FakeBlob
attr_reader :name
@@ -19,46 +19,46 @@ describe Tree do
end
end
- it 'returns nil when repository does not contains a README file' do
- files = [FakeBlob.new('file'), FakeBlob.new('license'), FakeBlob.new('copying')]
+ it "returns nil when repository does not contains a README file" do
+ files = [FakeBlob.new("file"), FakeBlob.new("license"), FakeBlob.new("copying")]
expect(subject).to receive(:blobs).and_return(files)
expect(subject.readme).to eq nil
end
- it 'returns nil when repository does not contains a previewable README file' do
- files = [FakeBlob.new('file'), FakeBlob.new('README.pages'), FakeBlob.new('README.png')]
+ it "returns nil when repository does not contains a previewable README file" do
+ files = [FakeBlob.new("file"), FakeBlob.new("README.pages"), FakeBlob.new("README.png")]
expect(subject).to receive(:blobs).and_return(files)
expect(subject.readme).to eq nil
end
- it 'returns README when repository contains a previewable README file' do
- files = [FakeBlob.new('README.png'), FakeBlob.new('README'), FakeBlob.new('file')]
+ it "returns README when repository contains a previewable README file" do
+ files = [FakeBlob.new("README.png"), FakeBlob.new("README"), FakeBlob.new("file")]
expect(subject).to receive(:blobs).and_return(files)
- expect(subject.readme.name).to eq 'README'
+ expect(subject.readme.name).to eq "README"
end
- it 'returns first previewable README when repository contains more than one' do
- files = [FakeBlob.new('file'), FakeBlob.new('README.md'), FakeBlob.new('README.asciidoc')]
+ it "returns first previewable README when repository contains more than one" do
+ files = [FakeBlob.new("file"), FakeBlob.new("README.md"), FakeBlob.new("README.asciidoc")]
expect(subject).to receive(:blobs).and_return(files)
- expect(subject.readme.name).to eq 'README.md'
+ expect(subject.readme.name).to eq "README.md"
end
- it 'returns first plain text README when repository contains more than one' do
- files = [FakeBlob.new('file'), FakeBlob.new('README'), FakeBlob.new('README.txt')]
+ it "returns first plain text README when repository contains more than one" do
+ files = [FakeBlob.new("file"), FakeBlob.new("README"), FakeBlob.new("README.txt")]
expect(subject).to receive(:blobs).and_return(files)
- expect(subject.readme.name).to eq 'README'
+ expect(subject.readme.name).to eq "README"
end
- it 'prioritizes previewable README file over one in plain text' do
- files = [FakeBlob.new('file'), FakeBlob.new('README'), FakeBlob.new('README.md')]
+ it "prioritizes previewable README file over one in plain text" do
+ files = [FakeBlob.new("file"), FakeBlob.new("README"), FakeBlob.new("README.md")]
expect(subject).to receive(:blobs).and_return(files)
- expect(subject.readme.name).to eq 'README.md'
+ expect(subject.readme.name).to eq "README.md"
end
end
end
diff --git a/spec/models/trending_project_spec.rb b/spec/models/trending_project_spec.rb
index 3b5e7ca0d39..f21c7b32612 100644
--- a/spec/models/trending_project_spec.rb
+++ b/spec/models/trending_project_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TrendingProject do
let(:user) { create(:user) }
@@ -22,33 +22,33 @@ describe TrendingProject do
create(:note_on_commit, project: internal_project)
end
- describe '.refresh!' do
+ describe ".refresh!" do
before do
described_class.refresh!
end
- it 'populates the trending projects table' do
+ it "populates the trending projects table" do
expect(described_class.count).to eq(2)
end
- it 'removes existing rows before populating the table' do
+ it "removes existing rows before populating the table" do
described_class.refresh!
expect(described_class.count).to eq(2)
end
- it 'stores the project IDs for every trending project' do
+ it "stores the project IDs for every trending project" do
rows = described_class.order(id: :asc).all
expect(rows[0].project_id).to eq(public_project1.id)
expect(rows[1].project_id).to eq(public_project2.id)
end
- it 'does not store projects that fall out of the trending time range' do
+ it "does not store projects that fall out of the trending time range" do
expect(described_class.where(project_id: public_project3).any?).to eq(false)
end
- it 'stores only public projects' do
+ it "stores only public projects" do
expect(described_class.where(project_id: [public_project1.id, public_project2.id]).count).to eq(2)
expect(described_class.where(project_id: [private_project.id, internal_project.id]).count).to eq(0)
end
diff --git a/spec/models/upload_spec.rb b/spec/models/upload_spec.rb
index 5a0df9fbbb0..3098f71c5d7 100644
--- a/spec/models/upload_spec.rb
+++ b/spec/models/upload_spec.rb
@@ -1,27 +1,27 @@
-require 'rails_helper'
+require "rails_helper"
describe Upload do
- describe 'assocations' do
+ describe "assocations" do
it { is_expected.to belong_to(:model) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:size) }
it { is_expected.to validate_presence_of(:path) }
it { is_expected.to validate_presence_of(:model) }
it { is_expected.to validate_presence_of(:uploader) }
end
- describe 'callbacks' do
- context 'for a file above the checksum threshold' do
- it 'schedules checksum calculation' do
- stub_const('UploadChecksumWorker', spy)
+ describe "callbacks" do
+ context "for a file above the checksum threshold" do
+ it "schedules checksum calculation" do
+ stub_const("UploadChecksumWorker", spy)
upload = described_class.create(
path: __FILE__,
size: described_class::CHECKSUM_THRESHOLD + 1.kilobyte,
model: build_stubbed(:user),
- uploader: double('ExampleUploader'),
+ uploader: double("ExampleUploader"),
store: ObjectStorage::Store::LOCAL
)
@@ -30,13 +30,13 @@ describe Upload do
end
end
- context 'for a file at or below the checksum threshold' do
- it 'calculates checksum immediately before save' do
+ context "for a file at or below the checksum threshold" do
+ it "calculates checksum immediately before save" do
upload = described_class.new(
path: __FILE__,
size: described_class::CHECKSUM_THRESHOLD,
model: build_stubbed(:user),
- uploader: double('ExampleUploader'),
+ uploader: double("ExampleUploader"),
store: ObjectStorage::Store::LOCAL
)
@@ -46,11 +46,11 @@ describe Upload do
end
end
- describe 'after_destroy' do
- context 'uploader is FileUploader-based' do
+ describe "after_destroy" do
+ context "uploader is FileUploader-based" do
subject { create(:upload, :issuable_upload) }
- it 'calls delete_file!' do
+ it "calls delete_file!" do
is_expected.to receive(:delete_file!)
subject.destroy
@@ -59,9 +59,9 @@ describe Upload do
end
end
- describe '#absolute_path' do
- it 'returns the path directly when already absolute' do
- path = '/path/to/namespace/project/secret/file.jpg'
+ describe "#absolute_path" do
+ it "returns the path directly when already absolute" do
+ path = "/path/to/namespace/project/secret/file.jpg"
upload = described_class.new(path: path, store: ObjectStorage::Store::LOCAL)
expect(upload).not_to receive(:uploader_class)
@@ -70,8 +70,8 @@ describe Upload do
end
it "delegates to the uploader's absolute_path method" do
- uploader = spy('FakeUploader')
- upload = described_class.new(path: 'secret/file.jpg', store: ObjectStorage::Store::LOCAL)
+ uploader = spy("FakeUploader")
+ upload = described_class.new(path: "secret/file.jpg", store: ObjectStorage::Store::LOCAL)
expect(upload).to receive(:uploader_class).and_return(uploader)
upload.absolute_path
@@ -80,21 +80,21 @@ describe Upload do
end
end
- describe '#calculate_checksum!' do
+ describe "#calculate_checksum!" do
let(:upload) do
described_class.new(path: __FILE__,
size: described_class::CHECKSUM_THRESHOLD - 1.megabyte,
store: ObjectStorage::Store::LOCAL)
end
- it 'sets `checksum` to SHA256 sum of the file' do
+ it "sets `checksum` to SHA256 sum of the file" do
expected = Digest::SHA256.file(__FILE__).hexdigest
expect { upload.calculate_checksum! }
.to change { upload.checksum }.from(nil).to(expected)
end
- it 'sets `checksum` to nil for a non-existent file' do
+ it "sets `checksum` to nil for a non-existent file" do
expect(upload).to receive(:exist?).and_return(false)
checksum = Digest::SHA256.file(__FILE__).hexdigest
@@ -105,22 +105,22 @@ describe Upload do
end
end
- describe '#exist?' do
- it 'returns true when the file exists' do
+ describe "#exist?" do
+ it "returns true when the file exists" do
upload = described_class.new(path: __FILE__, store: ObjectStorage::Store::LOCAL)
expect(upload).to exist
end
- context 'when the file does not exist' do
- it 'returns false' do
+ context "when the file does not exist" do
+ it "returns false" do
upload = described_class.new(path: "#{__FILE__}-nope", store: ObjectStorage::Store::LOCAL)
expect(upload).not_to exist
end
- context 'when the record is persisted' do
- it 'sends a message to Sentry' do
+ context "when the record is persisted" do
+ it "sends a message to Sentry" do
upload = create(:upload, :issuable_upload)
expect(Gitlab::Sentry).to receive(:enabled?).and_return(true)
@@ -129,19 +129,19 @@ describe Upload do
upload.exist?
end
- it 'increments a metric counter to signal a problem' do
+ it "increments a metric counter to signal a problem" do
upload = create(:upload, :issuable_upload)
counter = double(:counter)
expect(counter).to receive(:increment)
- expect(Gitlab::Metrics).to receive(:counter).with(:upload_file_does_not_exist_total, 'The number of times an upload record could not find its file').and_return(counter)
+ expect(Gitlab::Metrics).to receive(:counter).with(:upload_file_does_not_exist_total, "The number of times an upload record could not find its file").and_return(counter)
upload.exist?
end
end
- context 'when the record is not persisted' do
- it 'does not send a message to Sentry' do
+ context "when the record is not persisted" do
+ it "does not send a message to Sentry" do
upload = described_class.new(path: "#{__FILE__}-nope", store: ObjectStorage::Store::LOCAL)
expect(Raven).not_to receive(:capture_message)
@@ -149,7 +149,7 @@ describe Upload do
upload.exist?
end
- it 'does not increment a metric counter' do
+ it "does not increment a metric counter" do
upload = described_class.new(path: "#{__FILE__}-nope", store: ObjectStorage::Store::LOCAL)
expect(Gitlab::Metrics).not_to receive(:counter)
@@ -161,8 +161,8 @@ describe Upload do
end
describe "#uploader_context" do
- subject { create(:upload, :issuable_upload, secret: 'secret', filename: 'file.txt') }
+ subject { create(:upload, :issuable_upload, secret: "secret", filename: "file.txt") }
- it { expect(subject.uploader_context).to match(a_hash_including(secret: 'secret', identifier: 'file.txt')) }
+ it { expect(subject.uploader_context).to match(a_hash_including(secret: "secret", identifier: "file.txt")) }
end
end
diff --git a/spec/models/uploads/fog_spec.rb b/spec/models/uploads/fog_spec.rb
index 4a44cf5ab0f..0449791e9c9 100644
--- a/spec/models/uploads/fog_spec.rb
+++ b/spec/models/uploads/fog_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Uploads::Fog do
let(:data_store) { described_class.new }
@@ -9,14 +9,14 @@ describe Uploads::Fog do
stub_uploads_object_storage(FileUploader)
end
- describe '#available?' do
+ describe "#available?" do
subject { data_store.available? }
- context 'when object storage is enabled' do
+ context "when object storage is enabled" do
it { is_expected.to be_truthy }
end
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
before do
stub_uploads_object_storage(FileUploader, enabled: false)
end
@@ -25,20 +25,20 @@ describe Uploads::Fog do
end
end
- context 'model with uploads' do
+ context "model with uploads" do
let(:project) { create(:project) }
let(:relation) { project.uploads }
- describe '#keys' do
+ describe "#keys" do
let!(:uploads) { create_list(:upload, 2, :object_storage, uploader: FileUploader, model: project) }
subject { data_store.keys(relation) }
- it 'returns keys' do
+ it "returns keys" do
is_expected.to match_array(relation.pluck(:path))
end
end
- describe '#delete_keys' do
+ describe "#delete_keys" do
let(:keys) { data_store.keys(relation) }
let!(:uploads) { create_list(:upload, 2, :with_file, :issuable_upload, model: project) }
subject { data_store.delete_keys(keys) }
@@ -47,12 +47,12 @@ describe Uploads::Fog do
uploads.each { |upload| upload.build_uploader.migrate!(2) }
end
- it 'deletes multiple data' do
+ it "deletes multiple data" do
paths = relation.pluck(:path)
::Fog::Storage.new(FileUploader.object_store_credentials).tap do |connection|
paths.each do |path|
- expect(connection.get_object('uploads', path)[:body]).not_to be_nil
+ expect(connection.get_object("uploads", path)[:body]).not_to be_nil
end
end
@@ -60,7 +60,7 @@ describe Uploads::Fog do
::Fog::Storage.new(FileUploader.object_store_credentials).tap do |connection|
paths.each do |path|
- expect { connection.get_object('uploads', path)[:body] }.to raise_error(Excon::Error::NotFound)
+ expect { connection.get_object("uploads", path)[:body] }.to raise_error(Excon::Error::NotFound)
end
end
end
diff --git a/spec/models/uploads/local_spec.rb b/spec/models/uploads/local_spec.rb
index 3468399f370..7bdd1b1a436 100644
--- a/spec/models/uploads/local_spec.rb
+++ b/spec/models/uploads/local_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Uploads::Local do
let(:data_store) { described_class.new }
@@ -9,25 +9,25 @@ describe Uploads::Local do
stub_uploads_object_storage(FileUploader)
end
- context 'model with uploads' do
+ context "model with uploads" do
let(:project) { create(:project) }
let(:relation) { project.uploads }
- describe '#keys' do
+ describe "#keys" do
let!(:uploads) { create_list(:upload, 2, uploader: FileUploader, model: project) }
subject { data_store.keys(relation) }
- it 'returns keys' do
+ it "returns keys" do
is_expected.to match_array(relation.map(&:absolute_path))
end
end
- describe '#delete_keys' do
+ describe "#delete_keys" do
let(:keys) { data_store.keys(relation) }
let!(:uploads) { create_list(:upload, 2, :with_file, :issuable_upload, model: project) }
subject { data_store.delete_keys(keys) }
- it 'deletes multiple data' do
+ it "deletes multiple data" do
paths = relation.map(&:absolute_path)
paths.each do |path|
diff --git a/spec/models/user_agent_detail_spec.rb b/spec/models/user_agent_detail_spec.rb
index b4669f8c1c2..1dc72f1fa30 100644
--- a/spec/models/user_agent_detail_spec.rb
+++ b/spec/models/user_agent_detail_spec.rb
@@ -1,28 +1,28 @@
-require 'rails_helper'
+require "rails_helper"
describe UserAgentDetail do
- describe '.submittable?' do
- it 'is submittable when not already submitted' do
+ describe ".submittable?" do
+ it "is submittable when not already submitted" do
detail = build(:user_agent_detail)
expect(detail.submittable?).to be_truthy
end
- it 'is not submittable when already submitted' do
+ it "is not submittable when already submitted" do
detail = build(:user_agent_detail, submitted: true)
expect(detail.submittable?).to be_falsey
end
end
- describe '.valid?' do
- it 'is valid with a subject' do
+ describe ".valid?" do
+ it "is valid with a subject" do
detail = build(:user_agent_detail)
expect(detail).to be_valid
end
- it 'is invalid without a subject' do
+ it "is invalid without a subject" do
detail = build(:user_agent_detail, subject: nil)
expect(detail).not_to be_valid
diff --git a/spec/models/user_callout_spec.rb b/spec/models/user_callout_spec.rb
index d54355afe12..55b3dfe0818 100644
--- a/spec/models/user_callout_spec.rb
+++ b/spec/models/user_callout_spec.rb
@@ -1,15 +1,15 @@
-require 'rails_helper'
+require "rails_helper"
describe UserCallout do
let!(:callout) { create(:user_callout) }
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'relationships' do
+ describe "relationships" do
it { is_expected.to belong_to(:user) }
end
- describe 'validations' do
+ describe "validations" do
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:feature_name) }
diff --git a/spec/models/user_custom_attribute_spec.rb b/spec/models/user_custom_attribute_spec.rb
index 37fc3cb64f0..ce6789184fa 100644
--- a/spec/models/user_custom_attribute_spec.rb
+++ b/spec/models/user_custom_attribute_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe UserCustomAttribute do
- describe 'assocations' do
+ describe "assocations" do
it { is_expected.to belong_to(:user) }
end
- describe 'validations' do
+ describe "validations" do
subject { build :user_custom_attribute }
it { is_expected.to validate_presence_of(:user_id) }
diff --git a/spec/models/user_interacted_project_spec.rb b/spec/models/user_interacted_project_spec.rb
index cb4bb3372d4..ff03c80b7b6 100644
--- a/spec/models/user_interacted_project_spec.rb
+++ b/spec/models/user_interacted_project_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
describe UserInteractedProject do
- describe '.track' do
+ describe ".track" do
subject { described_class.track(event) }
let(:event) { build(:event) }
Event::ACTIONS.each do |action|
context "for all actions (event types)" do
let(:event) { build(:event, action: action) }
- it 'creates a record' do
+ it "creates a record" do
expect { subject }.to change { described_class.count }.from(0).to(1)
end
end
end
- it 'sets project accordingly' do
+ it "sets project accordingly" do
subject
expect(described_class.first.project).to eq(event.project)
end
- it 'sets user accordingly' do
+ it "sets user accordingly" do
subject
expect(described_class.first.user).to eq(event.author)
end
- it 'only creates a record once per user/project' do
- expect do
+ it "only creates a record once per user/project" do
+ expect {
subject
described_class.track(event)
- end.to change { described_class.count }.from(0).to(1)
+ }.to change { described_class.count }.from(0).to(1)
end
- describe 'with an event without a project' do
+ describe "with an event without a project" do
let(:event) { build(:event, project: nil) }
- it 'ignores the event' do
+ it "ignores the event" do
expect { subject }.not_to change { described_class.count }
end
end
end
- describe '.available?' do
+ describe ".available?" do
before do
- described_class.instance_variable_set('@available_flag', nil)
+ described_class.instance_variable_set("@available_flag", nil)
end
- it 'checks schema version and properly caches positive result' do
+ it "checks schema version and properly caches positive result" do
expect(ActiveRecord::Migrator).to receive(:current_version).and_return(described_class::REQUIRED_SCHEMA_VERSION - 1 - rand(1000))
expect(described_class.available?).to be_falsey
expect(ActiveRecord::Migrator).to receive(:current_version).and_return(described_class::REQUIRED_SCHEMA_VERSION + rand(1000))
diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rb
index b2ef17a81d4..be30f233eae 100644
--- a/spec/models/user_preference_spec.rb
+++ b/spec/models/user_preference_spec.rb
@@ -1,50 +1,50 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe UserPreference do
let(:user_preference) { create(:user_preference) }
- describe '#set_notes_filter' do
+ describe "#set_notes_filter" do
let(:issuable) { build_stubbed(:issue) }
- shared_examples 'setting system notes' do
- it 'returns updated discussion filter' do
+ shared_examples "setting system notes" do
+ it "returns updated discussion filter" do
filter_name =
user_preference.set_notes_filter(filter, issuable)
expect(filter_name).to eq(filter)
end
- it 'updates discussion filter for issuable class' do
+ it "updates discussion filter for issuable class" do
user_preference.set_notes_filter(filter, issuable)
expect(user_preference.reload.issue_notes_filter).to eq(filter)
end
end
- context 'when filter is set to all notes' do
+ context "when filter is set to all notes" do
let(:filter) { described_class::NOTES_FILTERS[:all_notes] }
- it_behaves_like 'setting system notes'
+ it_behaves_like "setting system notes"
end
- context 'when filter is set to only comments' do
+ context "when filter is set to only comments" do
let(:filter) { described_class::NOTES_FILTERS[:only_comments] }
- it_behaves_like 'setting system notes'
+ it_behaves_like "setting system notes"
end
- context 'when filter is set to only activity' do
+ context "when filter is set to only activity" do
let(:filter) { described_class::NOTES_FILTERS[:only_activity] }
- it_behaves_like 'setting system notes'
+ it_behaves_like "setting system notes"
end
- context 'when notes_filter parameter is invalid' do
+ context "when notes_filter parameter is invalid" do
let(:only_comments) { described_class::NOTES_FILTERS[:only_comments] }
- it 'returns the current notes filter' do
+ it "returns the current notes filter" do
user_preference.set_notes_filter(only_comments, issuable)
expect(user_preference.set_notes_filter(9999, issuable)).to eq(only_comments)
@@ -52,25 +52,25 @@ describe UserPreference do
end
end
- describe 'sort_by preferences' do
- shared_examples_for 'a sort_by preference' do
- it 'allows nil sort fields' do
+ describe "sort_by preferences" do
+ shared_examples_for "a sort_by preference" do
+ it "allows nil sort fields" do
user_preference.update(attribute => nil)
expect(user_preference).to be_valid
end
end
- context 'merge_requests_sort attribute' do
+ context "merge_requests_sort attribute" do
let(:attribute) { :merge_requests_sort }
- it_behaves_like 'a sort_by preference'
+ it_behaves_like "a sort_by preference"
end
- context 'issues_sort attribute' do
+ context "issues_sort attribute" do
let(:attribute) { :issues_sort }
- it_behaves_like 'a sort_by preference'
+ it_behaves_like "a sort_by preference"
end
end
end
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 85b157a9435..eeec662d959 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe User do
include ProjectForksHelper
include TermsHelper
- it_behaves_like 'having unique enum values'
+ it_behaves_like "having unique enum values"
- describe 'modules' do
+ describe "modules" do
subject { described_class }
it { is_expected.to include_module(Gitlab::ConfigHelper) }
@@ -16,11 +16,11 @@ describe User do
it { is_expected.to include_module(BlocksJsonSerialization) }
end
- describe 'delegations' do
+ describe "delegations" do
it { is_expected.to delegate_method(:path).to(:namespace).with_prefix }
end
- describe 'associations' do
+ describe "associations" do
it { is_expected.to have_one(:namespace) }
it { is_expected.to have_one(:status) }
it { is_expected.to have_many(:snippets).dependent(:destroy) }
@@ -43,8 +43,8 @@ describe User do
it { is_expected.to have_many(:pipelines).dependent(:nullify) }
it { is_expected.to have_many(:chat_names).dependent(:destroy) }
it { is_expected.to have_many(:uploads) }
- it { is_expected.to have_many(:reported_abuse_reports).dependent(:destroy).class_name('AbuseReport') }
- it { is_expected.to have_many(:custom_attributes).class_name('UserCustomAttribute') }
+ it { is_expected.to have_many(:reported_abuse_reports).dependent(:destroy).class_name("AbuseReport") }
+ it { is_expected.to have_many(:custom_attributes).class_name("UserCustomAttribute") }
it { is_expected.to have_many(:releases).dependent(:nullify) }
describe "#abuse_report" do
@@ -74,8 +74,8 @@ describe User do
end
end
- describe '#group_members' do
- it 'does not include group memberships for which user is a requester' do
+ describe "#group_members" do
+ it "does not include group memberships for which user is a requester" do
user = create(:user)
group = create(:group, :public, :access_requestable)
group.request_access(user)
@@ -84,8 +84,8 @@ describe User do
end
end
- describe '#project_members' do
- it 'does not include project memberships for which user is a requester' do
+ describe "#project_members" do
+ it "does not include project memberships for which user is a requester" do
user = create(:user)
project = create(:project, :public, :access_requestable)
project.request_access(user)
@@ -95,63 +95,63 @@ describe User do
end
end
- describe 'validations' do
- describe 'username' do
- it 'validates presence' do
+ describe "validations" do
+ describe "username" do
+ it "validates presence" do
expect(subject).to validate_presence_of(:username)
end
- it 'rejects blacklisted names' do
- user = build(:user, username: 'dashboard')
+ it "rejects blacklisted names" do
+ user = build(:user, username: "dashboard")
expect(user).not_to be_valid
- expect(user.errors.messages[:username]).to eq ['dashboard is a reserved name']
+ expect(user.errors.messages[:username]).to eq ["dashboard is a reserved name"]
end
- it 'allows child names' do
- user = build(:user, username: 'avatar')
+ it "allows child names" do
+ user = build(:user, username: "avatar")
expect(user).to be_valid
end
- it 'allows wildcard names' do
- user = build(:user, username: 'blob')
+ it "allows wildcard names" do
+ user = build(:user, username: "blob")
expect(user).to be_valid
end
- context 'when username is changed' do
- let(:user) { build_stubbed(:user, username: 'old_path', namespace: build_stubbed(:namespace)) }
+ context "when username is changed" do
+ let(:user) { build_stubbed(:user, username: "old_path", namespace: build_stubbed(:namespace)) }
- it 'validates move_dir is allowed for the namespace' do
+ it "validates move_dir is allowed for the namespace" do
expect(user.namespace).to receive(:any_project_has_container_registry_tags?).and_return(true)
- user.username = 'new_path'
+ user.username = "new_path"
expect(user).to be_invalid
- expect(user.errors.messages[:username].first).to match('cannot be changed if a personal project has container registry tags')
+ expect(user.errors.messages[:username].first).to match("cannot be changed if a personal project has container registry tags")
end
end
- context 'when the username is in use by another user' do
- let(:username) { 'foo' }
+ context "when the username is in use by another user" do
+ let(:username) { "foo" }
let!(:other_user) { create(:user, username: username) }
- it 'is invalid' do
+ it "is invalid" do
user = build(:user, username: username)
expect(user).not_to be_valid
- expect(user.errors.full_messages).to eq(['Username has already been taken'])
+ expect(user.errors.full_messages).to eq(["Username has already been taken"])
end
end
end
- it 'has a DB-level NOT NULL constraint on projects_limit' do
+ it "has a DB-level NOT NULL constraint on projects_limit" do
user = create(:user)
expect(user.persisted?).to eq(true)
- expect do
+ expect {
user.update_columns(projects_limit: nil)
- end.to raise_error(ActiveRecord::StatementInvalid)
+ }.to raise_error(ActiveRecord::StatementInvalid)
end
it { is_expected.to validate_presence_of(:projects_limit) }
@@ -162,23 +162,23 @@ describe User do
it { is_expected.to validate_length_of(:bio).is_at_most(255) }
- it_behaves_like 'an object with email-formated attributes', :email do
+ it_behaves_like "an object with email-formated attributes", :email do
subject { build(:user) }
end
- it_behaves_like 'an object with email-formated attributes', :public_email, :notification_email do
+ it_behaves_like "an object with email-formated attributes", :public_email, :notification_email do
subject { build(:user).tap { |user| user.emails << build(:email, email: email_value) } }
end
- describe '#commit_email' do
+ describe "#commit_email" do
subject(:user) { create(:user) }
- it 'defaults to the primary email' do
+ it "defaults to the primary email" do
expect(user.email).to be_present
expect(user.commit_email).to eq(user.email)
end
- it 'defaults to the primary email when the column in the database is null' do
+ it "defaults to the primary email when the column in the database is null" do
user.update_column(:commit_email, nil)
found_user = described_class.find_by(id: user.id)
@@ -186,13 +186,13 @@ describe User do
expect(found_user.commit_email).to eq(user.email)
end
- it 'returns the private commit email when commit_email has _private' do
+ it "returns the private commit email when commit_email has _private" do
user.update_column(:commit_email, Gitlab::PrivateCommitEmail::TOKEN)
expect(user.commit_email).to eq(user.private_commit_email)
end
- it 'can be set to a confirmed email' do
+ it "can be set to a confirmed email" do
confirmed = create(:email, :confirmed, user: user)
user.commit_email = confirmed.email
@@ -200,7 +200,7 @@ describe User do
expect(user.commit_email).to eq(confirmed.email)
end
- it 'can not be set to an unconfirmed email' do
+ it "can not be set to an unconfirmed email" do
unconfirmed = create(:email, user: user)
user.commit_email = unconfirmed.email
@@ -209,168 +209,168 @@ describe User do
expect(user.commit_email).to eq(user.email)
end
- it 'can not be set to a non-existent email' do
- user.commit_email = 'non-existent-email@nonexistent.nonexistent'
+ it "can not be set to a non-existent email" do
+ user.commit_email = "non-existent-email@nonexistent.nonexistent"
# This should set the commit_email attribute to the primary email
expect(user).to be_valid
expect(user.commit_email).to eq(user.email)
end
- it 'can not be set to an invalid email, even if confirmed' do
- confirmed = create(:email, :confirmed, :skip_validate, user: user, email: 'invalid')
+ it "can not be set to an invalid email, even if confirmed" do
+ confirmed = create(:email, :confirmed, :skip_validate, user: user, email: "invalid")
user.commit_email = confirmed.email
expect(user).not_to be_valid
end
end
- describe 'email' do
- context 'when no signup domains whitelisted' do
+ describe "email" do
+ context "when no signup domains whitelisted" do
before do
allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return([])
end
- it 'accepts any email' do
+ it "accepts any email" do
user = build(:user, email: "info@example.com")
expect(user).to be_valid
end
end
- context 'when a signup domain is whitelisted and subdomains are allowed' do
+ context "when a signup domain is whitelisted and subdomains are allowed" do
before do
- allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['example.com', '*.example.com'])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(["example.com", "*.example.com"])
end
- it 'accepts info@example.com' do
+ it "accepts info@example.com" do
user = build(:user, email: "info@example.com")
expect(user).to be_valid
end
- it 'accepts info@test.example.com' do
+ it "accepts info@test.example.com" do
user = build(:user, email: "info@test.example.com")
expect(user).to be_valid
end
- it 'rejects example@test.com' do
+ it "rejects example@test.com" do
user = build(:user, email: "example@test.com")
expect(user).to be_invalid
end
end
- context 'when a signup domain is whitelisted and subdomains are not allowed' do
+ context "when a signup domain is whitelisted and subdomains are not allowed" do
before do
- allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['example.com'])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(["example.com"])
end
- it 'accepts info@example.com' do
+ it "accepts info@example.com" do
user = build(:user, email: "info@example.com")
expect(user).to be_valid
end
- it 'rejects info@test.example.com' do
+ it "rejects info@test.example.com" do
user = build(:user, email: "info@test.example.com")
expect(user).to be_invalid
end
- it 'rejects example@test.com' do
+ it "rejects example@test.com" do
user = build(:user, email: "example@test.com")
expect(user).to be_invalid
end
- it 'accepts example@test.com when added by another user' do
+ it "accepts example@test.com when added by another user" do
user = build(:user, email: "example@test.com", created_by_id: 1)
expect(user).to be_valid
end
end
- context 'domain blacklist' do
+ context "domain blacklist" do
before do
allow_any_instance_of(ApplicationSetting).to receive(:domain_blacklist_enabled?).and_return(true)
- allow_any_instance_of(ApplicationSetting).to receive(:domain_blacklist).and_return(['example.com'])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_blacklist).and_return(["example.com"])
end
- context 'when a signup domain is blacklisted' do
- it 'accepts info@test.com' do
- user = build(:user, email: 'info@test.com')
+ context "when a signup domain is blacklisted" do
+ it "accepts info@test.com" do
+ user = build(:user, email: "info@test.com")
expect(user).to be_valid
end
- it 'rejects info@example.com' do
- user = build(:user, email: 'info@example.com')
+ it "rejects info@example.com" do
+ user = build(:user, email: "info@example.com")
expect(user).not_to be_valid
end
- it 'accepts info@example.com when added by another user' do
- user = build(:user, email: 'info@example.com', created_by_id: 1)
+ it "accepts info@example.com when added by another user" do
+ user = build(:user, email: "info@example.com", created_by_id: 1)
expect(user).to be_valid
end
end
- context 'when a signup domain is blacklisted but a wildcard subdomain is allowed' do
+ context "when a signup domain is blacklisted but a wildcard subdomain is allowed" do
before do
- allow_any_instance_of(ApplicationSetting).to receive(:domain_blacklist).and_return(['test.example.com'])
- allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['*.example.com'])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_blacklist).and_return(["test.example.com"])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(["*.example.com"])
end
- it 'gives priority to whitelist and allow info@test.example.com' do
- user = build(:user, email: 'info@test.example.com')
+ 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
end
- context 'with both lists containing a domain' do
+ context "with both lists containing a domain" do
before do
- allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(['test.com'])
+ allow_any_instance_of(ApplicationSetting).to receive(:domain_whitelist).and_return(["test.com"])
end
- it 'accepts info@test.com' do
- user = build(:user, email: 'info@test.com')
+ it "accepts info@test.com" do
+ user = build(:user, email: "info@test.com")
expect(user).to be_valid
end
- it 'rejects info@example.com' do
- user = build(:user, email: 'info@example.com')
+ it "rejects info@example.com" do
+ user = build(:user, email: "info@example.com")
expect(user).not_to be_valid
end
end
end
- context 'owns_notification_email' do
- it 'accepts temp_oauth_email emails' do
+ context "owns_notification_email" do
+ it "accepts temp_oauth_email emails" do
user = build(:user, email: "temp-email-for-oauth@example.com")
expect(user).to be_valid
end
end
- context 'set_commit_email' do
- it 'keeps commit email when private commit email is being used' do
+ context "set_commit_email" do
+ it "keeps commit email when private commit email is being used" do
user = create(:user, commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(user.read_attribute(:commit_email)).to eq(Gitlab::PrivateCommitEmail::TOKEN)
end
- it 'keeps the commit email when nil' do
+ it "keeps the commit email when nil" do
user = create(:user, commit_email: nil)
expect(user.read_attribute(:commit_email)).to be_nil
end
- it 'reverts to nil when email is not verified' do
+ it "reverts to nil when email is not verified" do
user = create(:user, commit_email: "foo@bar.com")
expect(user.read_attribute(:commit_email)).to be_nil
end
end
- context 'owns_commit_email' do
- it 'accepts private commit email' do
+ context "owns_commit_email" do
+ it "accepts private commit email" do
user = build(:user, commit_email: Gitlab::PrivateCommitEmail::TOKEN)
expect(user).to be_valid
end
- it 'accepts nil commit email' do
+ it "accepts nil commit email" do
user = build(:user, commit_email: nil)
expect(user).to be_valid
@@ -408,7 +408,7 @@ describe User do
expect(users_with_two_factor).not_to include(user_without_2fa.id)
end
- it 'works with ORDER BY' do
+ it "works with ORDER BY" do
user_with_2fa = create(:user, :two_factor_via_otp, :two_factor_via_u2f)
expect(described_class
@@ -446,8 +446,8 @@ describe User do
end
end
- describe '.limit_to_todo_authors' do
- context 'when filtering by todo authors' do
+ describe ".limit_to_todo_authors" do
+ context "when filtering by todo authors" do
let(:user1) { create(:user) }
let(:user2) { create(:user) }
@@ -456,7 +456,7 @@ describe User do
create(:todo, user: user2, author: user2, state: :pending)
end
- it 'only returns users that have authored todos' do
+ it "only returns users that have authored todos" do
users = described_class.limit_to_todo_authors(
user: user2,
with_todos: true,
@@ -466,7 +466,7 @@ describe User do
expect(users).to eq([user2])
end
- it 'ignores users that do not have a todo in the matching state' do
+ it "ignores users that do not have a todo in the matching state" do
users = described_class.limit_to_todo_authors(
user: user1,
with_todos: true,
@@ -477,8 +477,8 @@ describe User do
end
end
- context 'when not filtering by todo authors' do
- it 'returns the input relation' do
+ context "when not filtering by todo authors" do
+ it "returns the input relation" do
user1 = create(:user)
user2 = create(:user)
rel = described_class.limit_to_todo_authors(user: user1)
@@ -487,8 +487,8 @@ describe User do
end
end
- context 'when no user is provided' do
- it 'returns the input relation' do
+ context "when no user is provided" do
+ it "returns the input relation" do
user1 = create(:user)
user2 = create(:user)
rel = described_class.limit_to_todo_authors
@@ -498,19 +498,19 @@ describe User do
end
end
- describe '.by_username' do
- it 'finds users regardless of the case passed' do
- user = create(:user, username: 'CaMeLcAsEd')
- user2 = create(:user, username: 'UPPERCASE')
+ describe ".by_username" do
+ it "finds users regardless of the case passed" do
+ user = create(:user, username: "CaMeLcAsEd")
+ user2 = create(:user, username: "UPPERCASE")
- expect(described_class.by_username(%w(CAMELCASED uppercase)))
+ expect(described_class.by_username(%w[CAMELCASED uppercase]))
.to contain_exactly(user, user2)
end
- it 'finds a single user regardless of the case passed' do
- user = create(:user, username: 'CaMeLcAsEd')
+ it "finds a single user regardless of the case passed" do
+ user = create(:user, username: "CaMeLcAsEd")
- expect(described_class.by_username('CAMELCASED'))
+ expect(described_class.by_username("CAMELCASED"))
.to contain_exactly(user)
end
end
@@ -522,8 +522,8 @@ describe User do
it { is_expected.to respond_to(:external?) }
end
- describe 'before save hook' do
- context 'when saving an external user' do
+ describe "before save hook" do
+ context "when saving an external user" do
let(:user) { create(:user) }
let(:external_user) { create(:user, external: true) }
@@ -534,11 +534,11 @@ describe User do
end
end
- describe '#check_for_verified_email' do
+ describe "#check_for_verified_email" do
let(:user) { create(:user) }
- let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user) }
+ let(:secondary) { create(:email, :confirmed, email: "secondary@example.com", user: user) }
- it 'allows a verfied secondary email to be used as the primary without needing reconfirmation' do
+ it "allows a verfied secondary email to be used as the primary without needing reconfirmation" do
user.update!(email: secondary.email)
user.reload
expect(user.email).to eq secondary.email
@@ -548,39 +548,39 @@ describe User do
end
end
- describe 'after commit hook' do
- describe '#update_emails_with_primary_email' do
+ describe "after commit hook" do
+ describe "#update_emails_with_primary_email" do
before do
- @user = create(:user, email: 'primary@example.com').tap do |user|
+ @user = create(:user, email: "primary@example.com").tap do |user|
user.skip_reconfirmation!
end
- @secondary = create :email, email: 'secondary@example.com', user: @user
+ @secondary = create :email, email: "secondary@example.com", user: @user
@user.reload
end
- it 'gets called when email updated' do
+ it "gets called when email updated" do
expect(@user).to receive(:update_emails_with_primary_email)
- @user.update!(email: 'new_primary@example.com')
+ @user.update!(email: "new_primary@example.com")
end
- it 'adds old primary to secondary emails when secondary is a new email ' do
- @user.update!(email: 'new_primary@example.com')
+ it "adds old primary to secondary emails when secondary is a new email " do
+ @user.update!(email: "new_primary@example.com")
@user.reload
expect(@user.emails.count).to eq 2
- expect(@user.emails.pluck(:email)).to match_array([@secondary.email, 'primary@example.com'])
+ expect(@user.emails.pluck(:email)).to match_array([@secondary.email, "primary@example.com"])
end
- it 'adds old primary to secondary emails if secondary is becoming a primary' do
+ it "adds old primary to secondary emails if secondary is becoming a primary" do
@user.update!(email: @secondary.email)
@user.reload
expect(@user.emails.count).to eq 1
- expect(@user.emails.first.email).to eq 'primary@example.com'
+ expect(@user.emails.first.email).to eq "primary@example.com"
end
- it 'transfers old confirmation values into new secondary' do
+ it "transfers old confirmation values into new secondary" do
@user.update!(email: @secondary.email)
@user.reload
@@ -589,177 +589,177 @@ describe User do
end
end
- describe '#update_notification_email' do
+ describe "#update_notification_email" do
# Regression: https://gitlab.com/gitlab-org/gitlab-ce/issues/22846
- context 'when changing :email' do
+ context "when changing :email" do
let(:user) { create(:user) }
- let(:new_email) { 'new-email@example.com' }
+ let(:new_email) { "new-email@example.com" }
- it 'sets :unconfirmed_email' do
- expect do
+ it "sets :unconfirmed_email" do
+ expect {
user.tap { |u| u.update!(email: new_email) }.reload
- end.to change(user, :unconfirmed_email).to(new_email)
+ }.to change(user, :unconfirmed_email).to(new_email)
end
- it 'does not change :notification_email' do
- expect do
+ it "does not change :notification_email" do
+ expect {
user.tap { |u| u.update!(email: new_email) }.reload
- end.not_to change(user, :notification_email)
+ }.not_to change(user, :notification_email)
end
- it 'updates :notification_email to the new email once confirmed' do
+ it "updates :notification_email to the new email once confirmed" do
user.update!(email: new_email)
- expect do
+ expect {
user.tap(&:confirm).reload
- end.to change(user, :notification_email).to eq(new_email)
+ }.to change(user, :notification_email).to eq(new_email)
end
- context 'and :notification_email is set to a secondary email' do
+ context "and :notification_email is set to a secondary email" do
let!(:email_attrs) { attributes_for(:email, :confirmed, user: user) }
- let(:secondary) { create(:email, :confirmed, email: 'secondary@example.com', user: user) }
+ let(:secondary) { create(:email, :confirmed, email: "secondary@example.com", user: user) }
before do
user.emails.create(email_attrs)
user.tap { |u| u.update!(notification_email: email_attrs[:email]) }.reload
end
- it 'does not change :notification_email to :email' do
- expect do
+ it "does not change :notification_email to :email" do
+ expect {
user.tap { |u| u.update!(email: new_email) }.reload
- end.not_to change(user, :notification_email)
+ }.not_to change(user, :notification_email)
end
- it 'does not change :notification_email to :email once confirmed' do
+ it "does not change :notification_email to :email once confirmed" do
user.update!(email: new_email)
- expect do
+ expect {
user.tap(&:confirm).reload
- end.not_to change(user, :notification_email)
+ }.not_to change(user, :notification_email)
end
end
end
end
- describe '#update_invalid_gpg_signatures' do
+ describe "#update_invalid_gpg_signatures" do
let(:user) do
- create(:user, email: 'tula.torphy@abshire.ca').tap do |user|
+ create(:user, email: "tula.torphy@abshire.ca").tap do |user|
user.skip_reconfirmation!
end
end
- it 'does nothing when the name is updated' do
+ it "does nothing when the name is updated" do
expect(user).not_to receive(:update_invalid_gpg_signatures)
- user.update!(name: 'Bette')
+ user.update!(name: "Bette")
end
- it 'synchronizes the gpg keys when the email is updated' do
+ it "synchronizes the gpg keys when the email is updated" do
expect(user).to receive(:update_invalid_gpg_signatures).at_most(:twice)
- user.update!(email: 'shawnee.ritchie@denesik.com')
+ user.update!(email: "shawnee.ritchie@denesik.com")
end
end
end
- describe '#update_tracked_fields!', :clean_gitlab_redis_shared_state do
+ describe "#update_tracked_fields!", :clean_gitlab_redis_shared_state do
let(:request) { OpenStruct.new(remote_ip: "127.0.0.1") }
let(:user) { create(:user) }
- it 'writes trackable attributes' do
- expect do
+ it "writes trackable attributes" do
+ expect {
user.update_tracked_fields!(request)
- end.to change { user.reload.current_sign_in_at }
+ }.to change { user.reload.current_sign_in_at }
end
- it 'does not write trackable attributes when called a second time within the hour' do
+ it "does not write trackable attributes when called a second time within the hour" do
user.update_tracked_fields!(request)
- expect do
+ expect {
user.update_tracked_fields!(request)
- end.not_to change { user.reload.current_sign_in_at }
+ }.not_to change { user.reload.current_sign_in_at }
end
- it 'writes trackable attributes for a different user' do
+ it "writes trackable attributes for a different user" do
user2 = create(:user)
user.update_tracked_fields!(request)
- expect do
+ expect {
user2.update_tracked_fields!(request)
- end.to change { user2.reload.current_sign_in_at }
+ }.to change { user2.reload.current_sign_in_at }
end
- it 'does not write if the DB is in read-only mode' do
+ it "does not write if the DB is in read-only mode" do
expect(Gitlab::Database).to receive(:read_only?).and_return(true)
- expect do
+ expect {
user.update_tracked_fields!(request)
- end.not_to change { user.reload.current_sign_in_at }
+ }.not_to change { user.reload.current_sign_in_at }
end
end
- shared_context 'user keys' do
+ shared_context "user keys" do
let(:user) { create(:user) }
let!(:key) { create(:key, user: user) }
let!(:deploy_key) { create(:deploy_key, user: user) }
end
- describe '#keys' do
- include_context 'user keys'
+ describe "#keys" do
+ include_context "user keys"
- context 'with key and deploy key stored' do
- it 'returns stored key, but not deploy_key' do
+ context "with key and deploy key stored" do
+ it "returns stored key, but not deploy_key" do
expect(user.keys).to include key
expect(user.keys).not_to include deploy_key
end
end
end
- describe '#deploy_keys' do
- include_context 'user keys'
+ describe "#deploy_keys" do
+ include_context "user keys"
- context 'with key and deploy key stored' do
- it 'returns stored deploy key, but not normal key' do
+ context "with key and deploy key stored" do
+ it "returns stored deploy key, but not normal key" do
expect(user.deploy_keys).to include deploy_key
expect(user.deploy_keys).not_to include key
end
end
end
- describe '#confirm' do
+ describe "#confirm" do
before do
allow_any_instance_of(ApplicationSetting).to receive(:send_user_confirmation_email).and_return(true)
end
- let(:user) { create(:user, confirmed_at: nil, unconfirmed_email: 'test@gitlab.com') }
+ let(:user) { create(:user, confirmed_at: nil, unconfirmed_email: "test@gitlab.com") }
- it 'returns unconfirmed' do
+ it "returns unconfirmed" do
expect(user.confirmed?).to be_falsey
end
- it 'confirms a user' do
+ it "confirms a user" do
user.confirm
expect(user.confirmed?).to be_truthy
end
end
- describe '#to_reference' do
+ describe "#to_reference" do
let(:user) { create(:user) }
- it 'returns a String reference to the object' do
+ it "returns a String reference to the object" do
expect(user.to_reference).to eq "@#{user.username}"
end
end
- describe '#generate_password' do
+ describe "#generate_password" do
it "does not generate password by default" do
- user = create(:user, password: 'abcdefghe')
+ user = create(:user, password: "abcdefghe")
- expect(user.password).to eq('abcdefghe')
+ expect(user.password).to eq("abcdefghe")
end
end
- describe 'ensure user preference' do
- it 'has user preference upon user initialization' do
+ describe "ensure user preference" do
+ it "has user preference upon user initialization" do
user = build(:user)
expect(user.user_preference).to be_present
@@ -767,33 +767,33 @@ describe User do
end
end
- describe 'ensure incoming email token' do
- it 'has incoming email token' do
+ describe "ensure incoming email token" do
+ it "has incoming email token" do
user = create(:user)
expect(user.incoming_email_token).not_to be_blank
end
- it 'uses SecureRandom to generate the incoming email token' do
- expect(SecureRandom).to receive(:hex).and_return('3b8ca303')
+ it "uses SecureRandom to generate the incoming email token" do
+ expect(SecureRandom).to receive(:hex).and_return("3b8ca303")
user = create(:user)
- expect(user.incoming_email_token).to eql('gitlab')
+ expect(user.incoming_email_token).to eql("gitlab")
end
end
- describe '#ensure_user_rights_and_limits' do
- describe 'with external user' do
+ describe "#ensure_user_rights_and_limits" do
+ describe "with external user" do
let(:user) { create(:user, external: true) }
- it 'receives callback when external changes' do
+ it "receives callback when external changes" do
expect(user).to receive(:ensure_user_rights_and_limits)
user.update(external: false)
end
- it 'ensures correct rights and limits for user' do
+ it "ensures correct rights and limits for user" do
stub_config_setting(default_can_create_group: true)
expect { user.update(external: false) }.to change { user.can_create_group }.to(true)
@@ -801,24 +801,24 @@ describe User do
end
end
- describe 'without external user' do
+ describe "without external user" do
let(:user) { create(:user, external: false) }
- it 'receives callback when external changes' do
+ it "receives callback when external changes" do
expect(user).to receive(:ensure_user_rights_and_limits)
user.update(external: true)
end
- it 'ensures correct rights and limits for user' do
+ it "ensures correct rights and limits for user" do
expect { user.update(external: true) }.to change { user.can_create_group }.to(false)
.and change { user.projects_limit }.to(0)
end
end
end
- describe 'feed token' do
- it 'ensures a feed token on read' do
+ describe "feed token" do
+ it "ensures a feed token on read" do
user = create(:user, feed_token: nil)
feed_token = user.feed_token
@@ -827,28 +827,28 @@ describe User do
end
end
- describe '#recently_sent_password_reset?' do
- it 'is false when reset_password_sent_at is nil' do
+ describe "#recently_sent_password_reset?" do
+ it "is false when reset_password_sent_at is nil" do
user = build_stubbed(:user, reset_password_sent_at: nil)
expect(user.recently_sent_password_reset?).to eq false
end
- it 'is false when sent more than one minute ago' do
+ it "is false when sent more than one minute ago" do
user = build_stubbed(:user, reset_password_sent_at: 5.minutes.ago)
expect(user.recently_sent_password_reset?).to eq false
end
- it 'is true when sent less than one minute ago' do
+ it "is true when sent less than one minute ago" do
user = build_stubbed(:user, reset_password_sent_at: Time.now)
expect(user.recently_sent_password_reset?).to eq true
end
end
- describe '#disable_two_factor!' do
- it 'clears all 2FA-related fields' do
+ describe "#disable_two_factor!" do
+ it "clears all 2FA-related fields" do
user = create(:user, :two_factor)
expect(user).to be_two_factor_enabled
@@ -867,17 +867,17 @@ describe User do
end
end
- describe 'projects' do
+ describe "projects" do
before do
@user = create(:user)
@project = create(:project, namespace: @user.namespace)
- @project_2 = create(:project, group: create(:group)) do |project|
+ @project_2 = create(:project, group: create(:group)) { |project|
project.add_maintainer(@user)
- end
- @project_3 = create(:project, group: create(:group)) do |project|
+ }
+ @project_3 = create(:project, group: create(:group)) { |project|
project.add_developer(@user)
- end
+ }
end
it { expect(@user.authorized_projects).to include(@project) }
@@ -891,7 +891,7 @@ describe User do
it { expect(@user.personal_projects).not_to include(@project_3) }
end
- describe 'groups' do
+ describe "groups" do
let(:user) { create(:user) }
let(:group) { create(:group) }
@@ -905,45 +905,45 @@ describe User do
it { expect(user.namespaces).to contain_exactly(user.namespace, group) }
it { expect(user.manageable_namespaces).to contain_exactly(user.namespace, group) }
- context 'with child groups', :nested_groups do
+ context "with child groups", :nested_groups do
let!(:subgroup) { create(:group, parent: group) }
- describe '#manageable_namespaces' do
- it 'includes all the namespaces the user can manage' do
+ describe "#manageable_namespaces" do
+ it "includes all the namespaces the user can manage" do
expect(user.manageable_namespaces).to contain_exactly(user.namespace, group, subgroup)
end
end
- describe '#manageable_groups' do
- it 'includes all the namespaces the user can manage' do
+ describe "#manageable_groups" do
+ it "includes all the namespaces the user can manage" do
expect(user.manageable_groups).to contain_exactly(group, subgroup)
end
- it 'does not include duplicates if a membership was added for the subgroup' do
+ it "does not include duplicates if a membership was added for the subgroup" do
subgroup.add_owner(user)
expect(user.manageable_groups).to contain_exactly(group, subgroup)
end
end
- describe '#manageable_groups_with_routes' do
- it 'eager loads routes from manageable groups' do
+ describe "#manageable_groups_with_routes" do
+ it "eager loads routes from manageable groups" do
control_count =
- ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ ActiveRecord::QueryRecorder.new(skip_cached: false) {
user.manageable_groups_with_routes.map(&:route)
- end.count
+ }.count
create(:group, parent: subgroup)
- expect do
+ expect {
user.manageable_groups_with_routes.map(&:route)
- end.not_to exceed_all_query_limit(control_count)
+ }.not_to exceed_all_query_limit(control_count)
end
end
end
end
- describe 'group multiple owners' do
+ describe "group multiple owners" do
before do
@user = create :user
@user2 = create :user
@@ -956,7 +956,7 @@ describe User do
it { expect(@user2.several_namespaces?).to be_truthy }
end
- describe 'namespaced' do
+ describe "namespaced" do
before do
@user = create :user
@project = create(:project, namespace: @user.namespace)
@@ -966,8 +966,8 @@ describe User do
it { expect(@user.namespaces).to eq([@user.namespace]) }
end
- describe 'blocking user' do
- let(:user) { create(:user, name: 'John Smith') }
+ describe "blocking user" do
+ let(:user) { create(:user, name: "John Smith") }
it "blocks user" do
user.block
@@ -976,47 +976,47 @@ describe User do
end
end
- describe '.filter_items' do
+ describe ".filter_items" do
let(:user) { double }
- it 'filters by active users by default' do
+ it "filters by active users by default" do
expect(described_class).to receive(:active).and_return([user])
expect(described_class.filter_items(nil)).to include user
end
- it 'filters by admins' do
+ it "filters by admins" do
expect(described_class).to receive(:admins).and_return([user])
- expect(described_class.filter_items('admins')).to include user
+ expect(described_class.filter_items("admins")).to include user
end
- it 'filters by blocked' do
+ it "filters by blocked" do
expect(described_class).to receive(:blocked).and_return([user])
- expect(described_class.filter_items('blocked')).to include user
+ expect(described_class.filter_items("blocked")).to include user
end
- it 'filters by two_factor_disabled' do
+ it "filters by two_factor_disabled" do
expect(described_class).to receive(:without_two_factor).and_return([user])
- expect(described_class.filter_items('two_factor_disabled')).to include user
+ expect(described_class.filter_items("two_factor_disabled")).to include user
end
- it 'filters by two_factor_enabled' do
+ it "filters by two_factor_enabled" do
expect(described_class).to receive(:with_two_factor).and_return([user])
- expect(described_class.filter_items('two_factor_enabled')).to include user
+ expect(described_class.filter_items("two_factor_enabled")).to include user
end
- it 'filters by wop' do
+ it "filters by wop" do
expect(described_class).to receive(:without_projects).and_return([user])
- expect(described_class.filter_items('wop')).to include user
+ expect(described_class.filter_items("wop")).to include user
end
end
- describe '.without_projects' do
+ describe ".without_projects" do
let!(:project) { create(:project, :public, :access_requestable) }
let!(:user) { create(:user) }
let!(:user_without_project) { create(:user) }
@@ -1027,7 +1027,7 @@ describe User do
project.add_maintainer(user)
# create invite to projet
- create(:project_member, :developer, project: project, invite_token: '1234', invite_email: 'inviteduser1@example.com')
+ create(:project_member, :developer, project: project, invite_token: "1234", invite_email: "inviteduser1@example.com")
# create request to join project
project.request_access(user_without_project2)
@@ -1038,19 +1038,19 @@ describe User do
it { expect(described_class.without_projects).to include user_without_project2 }
end
- describe 'user creation' do
- describe 'normal user' do
- let(:user) { create(:user, name: 'John Smith') }
+ describe "user creation" do
+ describe "normal user" do
+ let(:user) { create(:user, name: "John Smith") }
it { expect(user.admin?).to be_falsey }
it { expect(user.require_ssh_key?).to be_truthy }
it { expect(user.can_create_group?).to be_truthy }
it { expect(user.can_create_project?).to be_truthy }
- it { expect(user.first_name).to eq('John') }
+ it { expect(user.first_name).to eq("John") }
it { expect(user.external).to be_falsey }
end
- describe 'with defaults' do
+ describe "with defaults" do
let(:user) { described_class.new }
it "applies defaults to user" do
@@ -1061,7 +1061,7 @@ describe User do
end
end
- describe 'with default overrides' do
+ describe "with default overrides" do
let(:user) { described_class.new(projects_limit: 123, can_create_group: false, can_create_team: true) }
it "applies defaults to user" do
@@ -1070,7 +1070,7 @@ describe User do
expect(user.theme_id).to eq(1)
end
- it 'does not undo projects_limit setting if it matches old DB default of 10' do
+ it "does not undo projects_limit setting if it matches old DB default of 10" do
# If the real default project limit is 10 then this test is worthless
expect(Gitlab.config.gitlab.default_projects_limit).not_to eq(10)
user = described_class.new(projects_limit: 10)
@@ -1078,7 +1078,7 @@ describe User do
end
end
- context 'when Gitlab::CurrentSettings.user_default_external is true' do
+ context "when Gitlab::CurrentSettings.user_default_external is true" do
before do
stub_application_setting(user_default_external: true)
end
@@ -1091,7 +1091,7 @@ describe User do
expect(user.projects_limit).to be 0
end
- describe 'with default overrides' do
+ describe "with default overrides" do
it "creates a non-external user" do
user = create(:user, external: false)
@@ -1100,11 +1100,11 @@ describe User do
end
end
- describe '#require_ssh_key?', :use_clean_rails_memory_store_caching do
+ describe "#require_ssh_key?", :use_clean_rails_memory_store_caching do
protocol_and_expectation = {
- 'http' => false,
- 'ssh' => true,
- '' => true
+ "http" => false,
+ "ssh" => true,
+ "" => true,
}
protocol_and_expectation.each do |protocol, expected|
@@ -1116,7 +1116,7 @@ describe User do
end
end
- it 'returns false when the user has 1 or more SSH keys' do
+ it "returns false when the user has 1 or more SSH keys" do
key = create(:personal_key)
expect(key.user.require_ssh_key?).to eq(false)
@@ -1124,16 +1124,16 @@ describe User do
end
end
- describe '.find_for_database_authentication' do
- it 'strips whitespace from login' do
+ describe ".find_for_database_authentication" do
+ it "strips whitespace from login" do
user = create(:user)
- expect(described_class.find_for_database_authentication({ login: " #{user.username} " })).to eq user
+ expect(described_class.find_for_database_authentication({login: " #{user.username} "})).to eq user
end
end
- describe '.find_by_any_email' do
- it 'finds user through private commit email' do
+ describe ".find_by_any_email" do
+ it "finds user through private commit email" do
user = create(:user)
private_email = user.private_commit_email
@@ -1141,85 +1141,85 @@ describe User do
expect(described_class.find_by_any_email(private_email, confirmed: true)).to eq(user)
end
- it 'finds by primary email' do
- user = create(:user, email: 'foo@example.com')
+ it "finds by primary email" do
+ user = create(:user, email: "foo@example.com")
expect(described_class.find_by_any_email(user.email)).to eq user
expect(described_class.find_by_any_email(user.email, confirmed: true)).to eq user
end
- it 'finds by uppercased email' do
- user = create(:user, email: 'foo@example.com')
+ it "finds by uppercased email" do
+ user = create(:user, email: "foo@example.com")
expect(described_class.find_by_any_email(user.email.upcase)).to eq user
expect(described_class.find_by_any_email(user.email.upcase, confirmed: true)).to eq user
end
- context 'finds by secondary email' do
+ context "finds by secondary email" do
let(:user) { email.user }
- context 'primary email confirmed' do
- context 'secondary email confirmed' do
- let!(:email) { create(:email, :confirmed, email: 'foo@example.com') }
+ context "primary email confirmed" do
+ context "secondary email confirmed" do
+ let!(:email) { create(:email, :confirmed, email: "foo@example.com") }
- it 'finds user respecting the confirmed flag' do
+ it "finds user respecting the confirmed flag" do
expect(described_class.find_by_any_email(email.email)).to eq user
expect(described_class.find_by_any_email(email.email, confirmed: true)).to eq user
end
end
- context 'secondary email not confirmed' do
- let!(:email) { create(:email, email: 'foo@example.com') }
+ context "secondary email not confirmed" do
+ let!(:email) { create(:email, email: "foo@example.com") }
- it 'finds user respecting the confirmed flag' do
+ it "finds user respecting the confirmed flag" do
expect(described_class.find_by_any_email(email.email)).to eq user
expect(described_class.find_by_any_email(email.email, confirmed: true)).to be_nil
end
end
end
- context 'primary email not confirmed' do
+ context "primary email not confirmed" do
let(:user) { create(:user, confirmed_at: nil) }
- let!(:email) { create(:email, :confirmed, user: user, email: 'foo@example.com') }
+ let!(:email) { create(:email, :confirmed, user: user, email: "foo@example.com") }
- it 'finds user respecting the confirmed flag' do
+ it "finds user respecting the confirmed flag" do
expect(described_class.find_by_any_email(email.email)).to eq user
expect(described_class.find_by_any_email(email.email, confirmed: true)).to be_nil
end
end
end
- it 'returns nil when nothing found' do
- expect(described_class.find_by_any_email('')).to be_nil
+ it "returns nil when nothing found" do
+ expect(described_class.find_by_any_email("")).to be_nil
end
- it 'returns nil when user is not confirmed' do
- user = create(:user, email: 'foo@example.com', confirmed_at: nil)
+ it "returns nil when user is not confirmed" do
+ user = create(:user, email: "foo@example.com", confirmed_at: nil)
expect(described_class.find_by_any_email(user.email, confirmed: false)).to eq(user)
expect(described_class.find_by_any_email(user.email, confirmed: true)).to be_nil
end
end
- describe '.by_any_email' do
- it 'returns an ActiveRecord::Relation' do
- expect(described_class.by_any_email('foo@example.com'))
+ describe ".by_any_email" do
+ it "returns an ActiveRecord::Relation" do
+ expect(described_class.by_any_email("foo@example.com"))
.to be_a_kind_of(ActiveRecord::Relation)
end
- it 'returns a relation of users' do
+ it "returns a relation of users" do
user = create(:user)
expect(described_class.by_any_email(user.email)).to eq([user])
end
- it 'returns a relation of users for confirmed users' do
+ it "returns a relation of users for confirmed users" do
user = create(:user)
expect(described_class.by_any_email(user.email, confirmed: true)).to eq([user])
end
- it 'finds user through a private commit email' do
+ it "finds user through a private commit email" do
user = create(:user)
private_email = user.private_commit_email
@@ -1227,7 +1227,7 @@ describe User do
expect(described_class.by_any_email(private_email, confirmed: true)).to eq([user])
end
- it 'finds user through a private commit email in an array' do
+ it "finds user through a private commit email in an array" do
user = create(:user)
private_email = user.private_commit_email
@@ -1236,268 +1236,268 @@ describe User do
end
end
- describe '.search' do
- let!(:user) { create(:user, name: 'user', username: 'usern', email: 'email@gmail.com') }
- let!(:user2) { create(:user, name: 'user name', username: 'username', email: 'someemail@gmail.com') }
- let!(:user3) { create(:user, name: 'us', username: 'se', email: 'foo@gmail.com') }
+ describe ".search" do
+ let!(:user) { create(:user, name: "user", username: "usern", email: "email@gmail.com") }
+ let!(:user2) { create(:user, name: "user name", username: "username", email: "someemail@gmail.com") }
+ let!(:user3) { create(:user, name: "us", username: "se", email: "foo@gmail.com") }
- describe 'name matching' do
- it 'returns users with a matching name with exact match first' do
+ describe "name matching" do
+ it "returns users with a matching name with exact match first" do
expect(described_class.search(user.name)).to eq([user, user2])
end
- it 'returns users with a partially matching name' do
+ it "returns users with a partially matching name" do
expect(described_class.search(user.name[0..2])).to eq([user, user2])
end
- it 'returns users with a matching name regardless of the casing' do
+ it "returns users with a matching name regardless of the casing" do
expect(described_class.search(user2.name.upcase)).to eq([user2])
end
- it 'returns users with a exact matching name shorter than 3 chars' do
+ it "returns users with a exact matching name shorter than 3 chars" do
expect(described_class.search(user3.name)).to eq([user3])
end
- it 'returns users with a exact matching name shorter than 3 chars regardless of the casing' do
+ it "returns users with a exact matching name shorter than 3 chars regardless of the casing" do
expect(described_class.search(user3.name.upcase)).to eq([user3])
end
end
- describe 'email matching' do
- it 'returns users with a matching Email' do
+ describe "email matching" do
+ it "returns users with a matching Email" do
expect(described_class.search(user.email)).to eq([user])
end
- it 'does not return users with a partially matching Email' do
+ it "does not return users with a partially matching Email" do
expect(described_class.search(user.email[0..2])).not_to include(user, user2)
end
- it 'returns users with a matching Email regardless of the casing' do
+ it "returns users with a matching Email regardless of the casing" do
expect(described_class.search(user2.email.upcase)).to eq([user2])
end
end
- describe 'username matching' do
- it 'returns users with a matching username' do
+ describe "username matching" do
+ it "returns users with a matching username" do
expect(described_class.search(user.username)).to eq([user, user2])
end
- it 'returns users with a partially matching username' do
+ it "returns users with a partially matching username" do
expect(described_class.search(user.username[0..2])).to eq([user, user2])
end
- it 'returns users with a matching username regardless of the casing' do
+ it "returns users with a matching username regardless of the casing" do
expect(described_class.search(user2.username.upcase)).to eq([user2])
end
- it 'returns users with a exact matching username shorter than 3 chars' do
+ it "returns users with a exact matching username shorter than 3 chars" do
expect(described_class.search(user3.username)).to eq([user3])
end
- it 'returns users with a exact matching username shorter than 3 chars regardless of the casing' do
+ it "returns users with a exact matching username shorter than 3 chars regardless of the casing" do
expect(described_class.search(user3.username.upcase)).to eq([user3])
end
end
- it 'returns no matches for an empty string' do
- expect(described_class.search('')).to be_empty
+ it "returns no matches for an empty string" do
+ expect(described_class.search("")).to be_empty
end
- it 'returns no matches for nil' do
+ it "returns no matches for nil" do
expect(described_class.search(nil)).to be_empty
end
end
- describe '.search_with_secondary_emails' do
+ describe ".search_with_secondary_emails" do
delegate :search_with_secondary_emails, to: :described_class
- let!(:user) { create(:user, name: 'John Doe', username: 'john.doe', email: 'john.doe@example.com' ) }
- let!(:another_user) { create(:user, name: 'Albert Smith', username: 'albert.smith', email: 'albert.smith@example.com' ) }
+ let!(:user) { create(:user, name: "John Doe", username: "john.doe", email: "john.doe@example.com") }
+ let!(:another_user) { create(:user, name: "Albert Smith", username: "albert.smith", email: "albert.smith@example.com") }
let!(:email) do
- create(:email, user: another_user, email: 'alias@example.com')
+ create(:email, user: another_user, email: "alias@example.com")
end
- it 'returns users with a matching name' do
+ it "returns users with a matching name" do
expect(search_with_secondary_emails(user.name)).to eq([user])
end
- it 'returns users with a partially matching name' do
+ it "returns users with a partially matching name" do
expect(search_with_secondary_emails(user.name[0..2])).to eq([user])
end
- it 'returns users with a matching name regardless of the casing' do
+ it "returns users with a matching name regardless of the casing" do
expect(search_with_secondary_emails(user.name.upcase)).to eq([user])
end
- it 'returns users with a matching email' do
+ it "returns users with a matching email" do
expect(search_with_secondary_emails(user.email)).to eq([user])
end
- it 'does not return users with a partially matching email' do
+ it "does not return users with a partially matching email" do
expect(search_with_secondary_emails(user.email[0..2])).not_to include([user])
end
- it 'returns users with a matching email regardless of the casing' do
+ it "returns users with a matching email regardless of the casing" do
expect(search_with_secondary_emails(user.email.upcase)).to eq([user])
end
- it 'returns users with a matching username' do
+ it "returns users with a matching username" do
expect(search_with_secondary_emails(user.username)).to eq([user])
end
- it 'returns users with a partially matching username' do
+ it "returns users with a partially matching username" do
expect(search_with_secondary_emails(user.username[0..2])).to eq([user])
end
- it 'returns users with a matching username regardless of the casing' do
+ it "returns users with a matching username regardless of the casing" do
expect(search_with_secondary_emails(user.username.upcase)).to eq([user])
end
- it 'returns users with a matching whole secondary email' do
+ it "returns users with a matching whole secondary email" do
expect(search_with_secondary_emails(email.email)).to eq([email.user])
end
- it 'does not return users with a matching part of secondary email' do
+ it "does not return users with a matching part of secondary email" do
expect(search_with_secondary_emails(email.email[1..4])).not_to include([email.user])
end
- it 'returns no matches for an empty string' do
- expect(search_with_secondary_emails('')).to be_empty
+ it "returns no matches for an empty string" do
+ expect(search_with_secondary_emails("")).to be_empty
end
- it 'returns no matches for nil' do
+ it "returns no matches for nil" do
expect(search_with_secondary_emails(nil)).to be_empty
end
end
- describe '.find_by_ssh_key_id' do
- context 'using an existing SSH key ID' do
+ describe ".find_by_ssh_key_id" do
+ context "using an existing SSH key ID" do
let(:user) { create(:user) }
let(:key) { create(:key, user: user) }
- it 'returns the corresponding User' do
+ it "returns the corresponding User" do
expect(described_class.find_by_ssh_key_id(key.id)).to eq(user)
end
end
- context 'using an invalid SSH key ID' do
- it 'returns nil' do
+ context "using an invalid SSH key ID" do
+ it "returns nil" do
expect(described_class.find_by_ssh_key_id(-1)).to be_nil
end
end
end
- describe '.by_login' do
- let(:username) { 'John' }
+ describe ".by_login" do
+ let(:username) { "John" }
let!(:user) { create(:user, username: username) }
- it 'gets the correct user' do
+ it "gets the correct user" do
expect(described_class.by_login(user.email.upcase)).to eq user
expect(described_class.by_login(user.email)).to eq user
expect(described_class.by_login(username.downcase)).to eq user
expect(described_class.by_login(username)).to eq user
expect(described_class.by_login(nil)).to be_nil
- expect(described_class.by_login('')).to be_nil
+ expect(described_class.by_login("")).to be_nil
end
end
- describe '.find_by_username' do
- it 'returns nil if not found' do
- expect(described_class.find_by_username('JohnDoe')).to be_nil
+ describe ".find_by_username" do
+ it "returns nil if not found" do
+ expect(described_class.find_by_username("JohnDoe")).to be_nil
end
- it 'is case-insensitive' do
- user = create(:user, username: 'JohnDoe')
+ it "is case-insensitive" do
+ user = create(:user, username: "JohnDoe")
- expect(described_class.find_by_username('JOHNDOE')).to eq user
+ expect(described_class.find_by_username("JOHNDOE")).to eq user
end
end
- describe '.find_by_username!' do
- it 'raises RecordNotFound' do
- expect { described_class.find_by_username!('JohnDoe') }
+ describe ".find_by_username!" do
+ it "raises RecordNotFound" do
+ expect { described_class.find_by_username!("JohnDoe") }
.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'is case-insensitive' do
- user = create(:user, username: 'JohnDoe')
+ it "is case-insensitive" do
+ user = create(:user, username: "JohnDoe")
- expect(described_class.find_by_username!('JOHNDOE')).to eq user
+ expect(described_class.find_by_username!("JOHNDOE")).to eq user
end
end
- describe '.find_by_full_path' do
+ describe ".find_by_full_path" do
let!(:user) { create(:user) }
- context 'with a route matching the given path' do
+ context "with a route matching the given path" do
let!(:route) { user.namespace.route }
- it 'returns the user' do
+ it "returns the user" do
expect(described_class.find_by_full_path(route.path)).to eq(user)
end
- it 'is case-insensitive' do
+ it "is case-insensitive" do
expect(described_class.find_by_full_path(route.path.upcase)).to eq(user)
expect(described_class.find_by_full_path(route.path.downcase)).to eq(user)
end
end
- context 'with a redirect route matching the given path' do
- let!(:redirect_route) { user.namespace.redirect_routes.create(path: 'foo') }
+ context "with a redirect route matching the given path" do
+ let!(:redirect_route) { user.namespace.redirect_routes.create(path: "foo") }
- context 'without the follow_redirects option' do
- it 'returns nil' do
+ context "without the follow_redirects option" do
+ it "returns nil" do
expect(described_class.find_by_full_path(redirect_route.path)).to eq(nil)
end
end
- context 'with the follow_redirects option set to true' do
- it 'returns the user' do
+ context "with the follow_redirects option set to true" do
+ it "returns the user" do
expect(described_class.find_by_full_path(redirect_route.path, follow_redirects: true)).to eq(user)
end
- it 'is case-insensitive' do
+ it "is case-insensitive" do
expect(described_class.find_by_full_path(redirect_route.path.upcase, follow_redirects: true)).to eq(user)
expect(described_class.find_by_full_path(redirect_route.path.downcase, follow_redirects: true)).to eq(user)
end
end
end
- context 'without a route or a redirect route matching the given path' do
- context 'without the follow_redirects option' do
- it 'returns nil' do
- expect(described_class.find_by_full_path('unknown')).to eq(nil)
+ context "without a route or a redirect route matching the given path" do
+ context "without the follow_redirects option" do
+ it "returns nil" do
+ expect(described_class.find_by_full_path("unknown")).to eq(nil)
end
end
- context 'with the follow_redirects option set to true' do
- it 'returns nil' do
- expect(described_class.find_by_full_path('unknown', follow_redirects: true)).to eq(nil)
+ context "with the follow_redirects option set to true" do
+ it "returns nil" do
+ expect(described_class.find_by_full_path("unknown", follow_redirects: true)).to eq(nil)
end
end
end
- context 'with a group route matching the given path' do
- let!(:group) { create(:group, path: 'group_path') }
+ context "with a group route matching the given path" do
+ let!(:group) { create(:group, path: "group_path") }
- context 'when the group namespace has an owner_id (legacy data)' do
+ context "when the group namespace has an owner_id (legacy data)" do
before do
group.update!(owner_id: user.id)
end
- it 'returns nil' do
- expect(described_class.find_by_full_path('group_path')).to eq(nil)
+ it "returns nil" do
+ expect(described_class.find_by_full_path("group_path")).to eq(nil)
end
end
- context 'when the group namespace does not have an owner_id' do
- it 'returns nil' do
- expect(described_class.find_by_full_path('group_path')).to eq(nil)
+ context "when the group namespace does not have an owner_id" do
+ it "returns nil" do
+ expect(described_class.find_by_full_path("group_path")).to eq(nil)
end
end
end
end
- describe 'all_ssh_keys' do
+ describe "all_ssh_keys" do
it { is_expected.to have_many(:keys).dependent(:destroy) }
it "has all ssh keys" do
@@ -1508,41 +1508,41 @@ describe User do
end
end
- describe '#avatar_type' do
+ describe "#avatar_type" do
let(:user) { create(:user) }
- it 'is true if avatar is image' do
- user.update_attribute(:avatar, 'uploads/avatar.png')
+ it "is true if avatar is image" do
+ user.update_attribute(:avatar, "uploads/avatar.png")
expect(user.avatar_type).to be_truthy
end
- it 'is false if avatar is html page' do
- user.update_attribute(:avatar, 'uploads/avatar.html')
+ it "is false if avatar is html page" do
+ user.update_attribute(:avatar, "uploads/avatar.html")
- expect(user.avatar_type).to eq(['file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico'])
+ expect(user.avatar_type).to eq(["file format is not supported. Please try one of the following supported formats: png, jpg, jpeg, gif, bmp, tiff, ico"])
end
end
- describe '#avatar_url' do
+ describe "#avatar_url" do
let(:user) { create(:user, :with_avatar) }
- context 'when avatar file is uploaded' do
- it 'shows correct avatar url' do
+ context "when avatar file is uploaded" do
+ it "shows correct avatar url" do
expect(user.avatar_url).to eq(user.avatar.url)
expect(user.avatar_url(only_path: false)).to eq([Gitlab.config.gitlab.url, user.avatar.url].join)
end
end
end
- describe '#accept_pending_invitations!' do
- let(:user) { create(:user, email: 'user@email.com') }
+ describe "#accept_pending_invitations!" do
+ let(:user) { create(:user, email: "user@email.com") }
let!(:project_member_invite) { create(:project_member, :invited, invite_email: user.email) }
let!(:group_member_invite) { create(:group_member, :invited, invite_email: user.email) }
- let!(:external_project_member_invite) { create(:project_member, :invited, invite_email: 'external@email.com') }
- let!(:external_group_member_invite) { create(:group_member, :invited, invite_email: 'external@email.com') }
+ let!(:external_project_member_invite) { create(:project_member, :invited, invite_email: "external@email.com") }
+ let!(:external_group_member_invite) { create(:group_member, :invited, invite_email: "external@email.com") }
- it 'accepts all the user members pending invitations and returns the accepted_members' do
+ it "accepts all the user members pending invitations and returns the accepted_members" do
accepted_members = user.accept_pending_invitations!
expect(accepted_members).to match_array([project_member_invite, group_member_invite])
@@ -1553,10 +1553,10 @@ describe User do
end
end
- describe '#all_emails' do
+ describe "#all_emails" do
let(:user) { create(:user) }
- it 'returns all emails' do
+ it "returns all emails" do
email_confirmed = create :email, user: user, confirmed_at: Time.now
email_unconfirmed = create :email, user: user
user.reload
@@ -1570,10 +1570,10 @@ describe User do
end
end
- describe '#verified_emails' do
+ describe "#verified_emails" do
let(:user) { create(:user) }
- it 'returns only confirmed emails' do
+ it "returns only confirmed emails" do
email_confirmed = create :email, user: user, confirmed_at: Time.now
create :email, user: user
@@ -1585,10 +1585,10 @@ describe User do
end
end
- describe '#verified_email?' do
+ describe "#verified_email?" do
let(:user) { create(:user) }
- it 'returns true when the email is verified/confirmed' do
+ it "returns true when the email is verified/confirmed" do
email_confirmed = create :email, user: user, confirmed_at: Time.now
create :email, user: user
user.reload
@@ -1597,19 +1597,19 @@ describe User do
expect(user.verified_email?(email_confirmed.email.titlecase)).to be_truthy
end
- it 'returns true when user is found through private commit email' do
+ it "returns true when user is found through private commit email" do
expect(user.verified_email?(user.private_commit_email)).to be_truthy
end
- it 'returns true for an outdated private commit email' do
+ it "returns true for an outdated private commit email" do
old_email = user.private_commit_email
- user.update!(username: 'changed-username')
+ user.update!(username: "changed-username")
expect(user.verified_email?(old_email)).to be_truthy
end
- it 'returns false when the email is not verified/confirmed' do
+ it "returns false when the email is not verified/confirmed" do
email_unconfirmed = create :email, user: user
user.reload
@@ -1617,10 +1617,10 @@ describe User do
end
end
- describe '#requires_ldap_check?' do
+ describe "#requires_ldap_check?" do
let(:user) { described_class.new }
- it 'is false when LDAP is disabled' do
+ it "is false when LDAP is disabled" do
# Create a condition which would otherwise cause 'true' to be returned
allow(user).to receive(:ldap_user?).and_return(true)
user.last_credential_check_at = nil
@@ -1628,29 +1628,29 @@ describe User do
expect(user.requires_ldap_check?).to be_falsey
end
- context 'when LDAP is enabled' do
+ context "when LDAP is enabled" do
before do
allow(Gitlab.config.ldap).to receive(:enabled).and_return(true)
end
- it 'is false for non-LDAP users' do
+ it "is false for non-LDAP users" do
allow(user).to receive(:ldap_user?).and_return(false)
expect(user.requires_ldap_check?).to be_falsey
end
- context 'and when the user is an LDAP user' do
+ context "and when the user is an LDAP user" do
before do
allow(user).to receive(:ldap_user?).and_return(true)
end
- it 'is true when the user has never had an LDAP check before' do
+ it "is true when the user has never had an LDAP check before" do
user.last_credential_check_at = nil
expect(user.requires_ldap_check?).to be_truthy
end
- it 'is true when the last LDAP check happened over 1 hour ago' do
+ it "is true when the last LDAP check happened over 1 hour ago" do
user.last_credential_check_at = 2.hours.ago
expect(user.requires_ldap_check?).to be_truthy
@@ -1659,39 +1659,39 @@ describe User do
end
end
- context 'ldap synchronized user' do
- describe '#ldap_user?' do
- it 'is true if provider name starts with ldap' do
- user = create(:omniauth_user, provider: 'ldapmain')
+ context "ldap synchronized user" do
+ describe "#ldap_user?" do
+ it "is true if provider name starts with ldap" do
+ user = create(:omniauth_user, provider: "ldapmain")
expect(user.ldap_user?).to be_truthy
end
- it 'is false for other providers' do
- user = create(:omniauth_user, provider: 'other-provider')
+ it "is false for other providers" do
+ user = create(:omniauth_user, provider: "other-provider")
expect(user.ldap_user?).to be_falsey
end
- it 'is false if no extern_uid is provided' do
+ it "is false if no extern_uid is provided" do
user = create(:omniauth_user, extern_uid: nil)
expect(user.ldap_user?).to be_falsey
end
end
- describe '#ldap_identity' do
- it 'returns ldap identity' do
+ describe "#ldap_identity" do
+ it "returns ldap identity" do
user = create :omniauth_user
expect(user.ldap_identity.provider).not_to be_empty
end
end
- describe '#ldap_block' do
- let(:user) { create(:omniauth_user, provider: 'ldapmain', name: 'John Smith') }
+ describe "#ldap_block" do
+ let(:user) { create(:omniauth_user, provider: "ldapmain", name: "John Smith") }
- it 'blocks user flaging the action caming from ldap' do
+ it "blocks user flaging the action caming from ldap" do
user.ldap_block
expect(user.blocked?).to be_truthy
@@ -1700,64 +1700,64 @@ describe User do
end
end
- describe '#full_website_url' do
+ describe "#full_website_url" do
let(:user) { create(:user) }
- it 'begins with http if website url omits it' do
- user.website_url = 'test.com'
+ it "begins with http if website url omits it" do
+ user.website_url = "test.com"
- expect(user.full_website_url).to eq 'http://test.com'
+ expect(user.full_website_url).to eq "http://test.com"
end
- it 'begins with http if website url begins with http' do
- user.website_url = 'http://test.com'
+ it "begins with http if website url begins with http" do
+ user.website_url = "http://test.com"
- expect(user.full_website_url).to eq 'http://test.com'
+ expect(user.full_website_url).to eq "http://test.com"
end
- it 'begins with https if website url begins with https' do
- user.website_url = 'https://test.com'
+ it "begins with https if website url begins with https" do
+ user.website_url = "https://test.com"
- expect(user.full_website_url).to eq 'https://test.com'
+ expect(user.full_website_url).to eq "https://test.com"
end
end
- describe '#short_website_url' do
+ describe "#short_website_url" do
let(:user) { create(:user) }
- it 'does not begin with http if website url omits it' do
- user.website_url = 'test.com'
+ it "does not begin with http if website url omits it" do
+ user.website_url = "test.com"
- expect(user.short_website_url).to eq 'test.com'
+ expect(user.short_website_url).to eq "test.com"
end
- it 'does not begin with http if website url begins with http' do
- user.website_url = 'http://test.com'
+ it "does not begin with http if website url begins with http" do
+ user.website_url = "http://test.com"
- expect(user.short_website_url).to eq 'test.com'
+ expect(user.short_website_url).to eq "test.com"
end
- it 'does not begin with https if website url begins with https' do
- user.website_url = 'https://test.com'
+ it "does not begin with https if website url begins with https" do
+ user.website_url = "https://test.com"
- expect(user.short_website_url).to eq 'test.com'
+ expect(user.short_website_url).to eq "test.com"
end
end
- describe '#sanitize_attrs' do
- let(:user) { build(:user, name: 'test & user', skype: 'test&user') }
+ describe "#sanitize_attrs" do
+ let(:user) { build(:user, name: "test & user", skype: "test&user") }
- it 'encodes HTML entities in the Skype attribute' do
- expect { user.sanitize_attrs }.to change { user.skype }.to('test&amp;user')
+ it "encodes HTML entities in the Skype attribute" do
+ expect { user.sanitize_attrs }.to change { user.skype }.to("test&amp;user")
end
- it 'does not encode HTML entities in the name attribute' do
+ it "does not encode HTML entities in the name attribute" do
expect { user.sanitize_attrs }.not_to change { user.name }
end
end
- describe '#starred?' do
- it 'determines if user starred a project' do
+ describe "#starred?" do
+ it "determines if user starred a project" do
user = create :user
project1 = create(:project, :public)
project2 = create(:project, :public)
@@ -1787,8 +1787,8 @@ describe User do
end
end
- describe '#toggle_star' do
- it 'toggles stars' do
+ describe "#toggle_star" do
+ it "toggles stars" do
user = create :user
project = create(:project, :public)
@@ -1804,67 +1804,67 @@ describe User do
end
end
- describe '.find_by_private_commit_email' do
- context 'with email' do
+ describe ".find_by_private_commit_email" do
+ context "with email" do
set(:user) { create(:user) }
- it 'returns user through private commit email' do
+ it "returns user through private commit email" do
expect(described_class.find_by_private_commit_email(user.private_commit_email)).to eq(user)
end
- it 'returns nil when email other than private_commit_email is used' do
+ it "returns nil when email other than private_commit_email is used" do
expect(described_class.find_by_private_commit_email(user.email)).to be_nil
end
end
- it 'returns nil when email is nil' do
+ it "returns nil when email is nil" do
expect(described_class.find_by_private_commit_email(nil)).to be_nil
end
end
- describe '#sort_by_attribute' do
+ describe "#sort_by_attribute" do
before do
described_class.delete_all
- @user = create :user, created_at: Date.today, current_sign_in_at: Date.today, name: 'Alpha'
- @user1 = create :user, created_at: Date.today - 1, current_sign_in_at: Date.today - 1, name: 'Omega'
- @user2 = create :user, created_at: Date.today - 2, name: 'Beta'
+ @user = create :user, created_at: Date.today, current_sign_in_at: Date.today, name: "Alpha"
+ @user1 = create :user, created_at: Date.today - 1, current_sign_in_at: Date.today - 1, name: "Omega"
+ @user2 = create :user, created_at: Date.today - 2, name: "Beta"
end
- context 'when sort by recent_sign_in' do
- let(:users) { described_class.sort_by_attribute('recent_sign_in') }
+ context "when sort by recent_sign_in" do
+ let(:users) { described_class.sort_by_attribute("recent_sign_in") }
- it 'sorts users by recent sign-in time' do
+ it "sorts users by recent sign-in time" do
expect(users.first).to eq(@user)
expect(users.second).to eq(@user1)
end
- it 'pushes users who never signed in to the end' do
+ it "pushes users who never signed in to the end" do
expect(users.third).to eq(@user2)
end
end
- context 'when sort by oldest_sign_in' do
- let(:users) { described_class.sort_by_attribute('oldest_sign_in') }
+ context "when sort by oldest_sign_in" do
+ let(:users) { described_class.sort_by_attribute("oldest_sign_in") }
- it 'sorts users by the oldest sign-in time' do
+ it "sorts users by the oldest sign-in time" do
expect(users.first).to eq(@user1)
expect(users.second).to eq(@user)
end
- it 'pushes users who never signed in to the end' do
+ it "pushes users who never signed in to the end" do
expect(users.third).to eq(@user2)
end
end
- it 'sorts users in descending order by their creation time' do
- expect(described_class.sort_by_attribute('created_desc').first).to eq(@user)
+ it "sorts users in descending order by their creation time" do
+ expect(described_class.sort_by_attribute("created_desc").first).to eq(@user)
end
- it 'sorts users in ascending order by their creation time' do
- expect(described_class.sort_by_attribute('created_asc').first).to eq(@user2)
+ it "sorts users in ascending order by their creation time" do
+ expect(described_class.sort_by_attribute("created_asc").first).to eq(@user2)
end
- it 'sorts users by id in descending order when nil is passed' do
+ it "sorts users by id in descending order when nil is passed" do
expect(described_class.sort_by_attribute(nil).first).to eq(@user2)
end
end
@@ -1896,7 +1896,7 @@ describe User do
end
end
- describe '#fork_of' do
+ describe "#fork_of" do
let(:user) { create(:user) }
it "returns a user's fork of a project" do
@@ -1906,21 +1906,21 @@ describe User do
expect(user.fork_of(project)).to eq(user_fork)
end
- it 'returns nil if the project does not have a fork network' do
+ it "returns nil if the project does not have a fork network" do
project = create(:project)
expect(user.fork_of(project)).to be_nil
end
end
- describe '#can_be_removed?' do
+ describe "#can_be_removed?" do
subject { create(:user) }
- context 'no owned groups' do
+ context "no owned groups" do
it { expect(subject.can_be_removed?).to be_truthy }
end
- context 'has owned groups' do
+ context "has owned groups" do
before do
group = create(:group)
group.add_owner(subject)
@@ -1935,7 +1935,7 @@ describe User do
let(:project) { build(:project) }
let(:event) { build(:push_event) }
- it 'returns the last push event for the user' do
+ it "returns the last push event for the user" do
expect_any_instance_of(Users::LastPushEventService)
.to receive(:last_event_for_user)
.and_return(event)
@@ -1943,7 +1943,7 @@ describe User do
expect(user.recent_push).to eq(event)
end
- it 'returns the last push event for a project when one is given' do
+ it "returns the last push event for a project when one is given" do
expect_any_instance_of(Users::LastPushEventService)
.to receive(:last_event_for_project)
.and_return(event)
@@ -1952,7 +1952,7 @@ describe User do
end
end
- describe '#authorized_groups' do
+ describe "#authorized_groups" do
let!(:user) { create(:user) }
let!(:private_group) { create(:group) }
let!(:child_group) { create(:group, parent: private_group) }
@@ -1970,7 +1970,7 @@ describe User do
it { is_expected.to contain_exactly private_group, project_group }
end
- describe '#membership_groups' do
+ describe "#membership_groups" do
let!(:user) { create(:user) }
let!(:parent_group) { create(:group) }
let!(:child_group) { create(:group, parent: parent_group) }
@@ -1988,11 +1988,11 @@ describe User do
end
end
- describe '#authorizations_for_projects' do
+ describe "#authorizations_for_projects" do
let!(:user) { create(:user) }
subject { Project.where("EXISTS (?)", user.authorizations_for_projects) }
- it 'includes projects that belong to a user, but no other projects' do
+ it "includes projects that belong to a user, but no other projects" do
owned = create(:project, :private, namespace: user.namespace)
member = create(:project, :private).tap { |p| p.add_maintainer(user) }
other = create(:project)
@@ -2002,18 +2002,18 @@ describe User do
expect(subject).not_to include(other)
end
- it 'includes projects a user has access to, but no other projects' do
+ it "includes projects a user has access to, but no other projects" do
other_user = create(:user)
- accessible = create(:project, :private, namespace: other_user.namespace) do |project|
+ accessible = create(:project, :private, namespace: other_user.namespace) { |project|
project.add_developer(user)
- end
+ }
other = create(:project)
expect(subject).to include(accessible)
expect(subject).not_to include(other)
end
- context 'with min_access_level' do
+ context "with min_access_level" do
let!(:user) { create(:user) }
let!(:project) { create(:project, :private, namespace: user.namespace) }
@@ -2023,27 +2023,27 @@ describe User do
subject { Project.where("EXISTS (?)", user.authorizations_for_projects(min_access_level: min_access_level)) }
- context 'when developer access' do
+ context "when developer access" do
let(:min_access_level) { Gitlab::Access::DEVELOPER }
- it 'includes projects a user has access to' do
+ it "includes projects a user has access to" do
expect(subject).to include(project)
end
end
- context 'when owner access' do
+ context "when owner access" do
let(:min_access_level) { Gitlab::Access::OWNER }
- it 'does not include projects with higher access level' do
+ it "does not include projects with higher access level" do
expect(subject).not_to include(project)
end
end
end
end
- describe '#authorized_projects', :delete do
- context 'with a minimum access level' do
- it 'includes projects for which the user is an owner' do
+ describe "#authorized_projects", :delete do
+ context "with a minimum access level" do
+ it "includes projects for which the user is an owner" do
user = create(:user)
project = create(:project, :private, namespace: user.namespace)
@@ -2051,7 +2051,7 @@ describe User do
.to contain_exactly(project)
end
- it 'includes projects for which the user is a maintainer' do
+ it "includes projects for which the user is a maintainer" do
user = create(:user)
project = create(:project, :private)
@@ -2143,10 +2143,10 @@ describe User do
end
end
- describe '#projects_where_can_admin_issues' do
+ describe "#projects_where_can_admin_issues" do
let(:user) { create(:user) }
- it 'includes projects for which the user access level is above or equal to reporter' do
+ it "includes projects for which the user access level is above or equal to reporter" do
reporter_project = create(:project) { |p| p.add_reporter(user) }
developer_project = create(:project) { |p| p.add_developer(user) }
maintainer_project = create(:project) { |p| p.add_maintainer(user) }
@@ -2157,7 +2157,7 @@ describe User do
expect(user.can?(:admin_issue, reporter_project)).to eq(true)
end
- it 'does not include for which the user access level is below reporter' do
+ it "does not include for which the user access level is below reporter" do
project = create(:project)
guest_project = create(:project) { |p| p.add_guest(user) }
@@ -2166,14 +2166,14 @@ describe User do
expect(user.can?(:admin_issue, project)).to eq(false)
end
- it 'does not include archived projects' do
+ it "does not include archived projects" do
project = create(:project, :archived)
expect(user.projects_where_can_admin_issues.to_a).to be_empty
expect(user.can?(:admin_issue, project)).to eq(false)
end
- it 'does not include projects for which issues are disabled' do
+ it "does not include projects for which issues are disabled" do
project = create(:project, :issues_disabled)
expect(user.projects_where_can_admin_issues.to_a).to be_empty
@@ -2181,27 +2181,27 @@ describe User do
end
end
- describe '#ci_owned_runners' do
+ describe "#ci_owned_runners" do
let(:user) { create(:user) }
let!(:project) { create(:project) }
let(:runner) { create(:ci_runner, :project, projects: [project]) }
- context 'without any projects nor groups' do
- it 'does not load' do
+ context "without any projects nor groups" do
+ it "does not load" do
expect(user.ci_owned_runners).to be_empty
end
end
- context 'with personal projects runners' do
+ context "with personal projects runners" do
let(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
- it 'loads' do
+ it "loads" do
expect(user.ci_owned_runners).to contain_exactly(runner)
end
end
- context 'with personal group runner' do
+ context "with personal group runner" do
let!(:project) { create(:project) }
let(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:group) do
@@ -2210,12 +2210,12 @@ describe User do
end
end
- it 'loads' do
+ it "loads" do
expect(user.ci_owned_runners).to contain_exactly(group_runner)
end
end
- context 'with personal project and group runner' do
+ context "with personal project and group runner" do
let(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
let!(:group_runner) { create(:ci_runner, :group, groups: [group]) }
@@ -2226,34 +2226,34 @@ describe User do
end
end
- it 'loads' do
+ it "loads" do
expect(user.ci_owned_runners).to contain_exactly(runner, group_runner)
end
end
shared_examples :member do
- context 'when the user is a maintainer' do
+ context "when the user is a maintainer" do
before do
add_user(:maintainer)
end
- it 'loads' do
+ it "loads" do
expect(user.ci_owned_runners).to contain_exactly(runner)
end
end
- context 'when the user is a developer' do
+ context "when the user is a developer" do
before do
add_user(:developer)
end
- it 'does not load' do
+ it "does not load" do
expect(user.ci_owned_runners).to be_empty
end
end
end
- context 'with groups projects runners' do
+ context "with groups projects runners" do
let(:group) { create(:group) }
let!(:project) { create(:project, group: group) }
@@ -2264,7 +2264,7 @@ describe User do
it_behaves_like :member
end
- context 'with groups runners' do
+ context "with groups runners" do
let!(:runner) { create(:ci_runner, :group, groups: [group]) }
let!(:group) { create(:group) }
@@ -2275,7 +2275,7 @@ describe User do
it_behaves_like :member
end
- context 'with other projects runners' do
+ context "with other projects runners" do
let!(:project) { create(:project) }
def add_user(access)
@@ -2285,7 +2285,7 @@ describe User do
it_behaves_like :member
end
- context 'with subgroup with different owner for project runner', :nested_groups do
+ context "with subgroup with different owner for project runner", :nested_groups do
let(:group) { create(:group) }
let(:another_user) { create(:user) }
let(:subgroup) { create(:group, parent: group) }
@@ -2301,7 +2301,7 @@ describe User do
end
end
- describe '#projects_with_reporter_access_limited_to' do
+ describe "#projects_with_reporter_access_limited_to" do
let(:project1) { create(:project) }
let(:project2) { create(:project) }
let(:user) { create(:user) }
@@ -2311,33 +2311,33 @@ describe User do
project2.add_guest(user)
end
- it 'returns the projects when using a single project ID' do
+ it "returns the projects when using a single project ID" do
projects = user.projects_with_reporter_access_limited_to(project1.id)
expect(projects).to eq([project1])
end
- it 'returns the projects when using an Array of project IDs' do
+ it "returns the projects when using an Array of project IDs" do
projects = user.projects_with_reporter_access_limited_to([project1.id])
expect(projects).to eq([project1])
end
- it 'returns the projects when using an ActiveRecord relation' do
+ it "returns the projects when using an ActiveRecord relation" do
projects = user
.projects_with_reporter_access_limited_to(Project.select(:id))
expect(projects).to eq([project1])
end
- it 'does not return projects you do not have reporter access to' do
+ it "does not return projects you do not have reporter access to" do
projects = user.projects_with_reporter_access_limited_to(project2.id)
expect(projects).to be_empty
end
end
- describe '#all_expanded_groups' do
+ describe "#all_expanded_groups" do
# foo/bar would also match foo/barbaz instead of just foo/bar and foo/bar/baz
let!(:user) { create(:user) }
@@ -2353,20 +2353,20 @@ describe User do
# (baz) (baz)
#
let!(:group) { create :group }
- let!(:nested_group_1) { create :group, parent: group, name: 'bar' }
- let!(:nested_group_1_1) { create :group, parent: nested_group_1, name: 'baz' }
- let!(:nested_group_2) { create :group, parent: group, name: 'barbaz' }
- let!(:nested_group_2_1) { create :group, parent: nested_group_2, name: 'baz' }
+ let!(:nested_group_1) { create :group, parent: group, name: "bar" }
+ let!(:nested_group_1_1) { create :group, parent: nested_group_1, name: "baz" }
+ let!(:nested_group_2) { create :group, parent: group, name: "barbaz" }
+ let!(:nested_group_2_1) { create :group, parent: nested_group_2, name: "baz" }
subject { user.all_expanded_groups }
- context 'user is not a member of any group' do
- it 'returns an empty array' do
+ context "user is not a member of any group" do
+ it "returns an empty array" do
is_expected.to eq([])
end
end
- context 'user is member of all groups' do
+ context "user is member of all groups" do
before do
group.add_reporter(user)
nested_group_1.add_developer(user)
@@ -2375,76 +2375,76 @@ describe User do
nested_group_2_1.add_maintainer(user)
end
- it 'returns all groups' do
+ it "returns all groups" do
is_expected.to match_array [
group,
nested_group_1, nested_group_1_1,
- nested_group_2, nested_group_2_1
+ nested_group_2, nested_group_2_1,
]
end
end
- context 'user is member of the top group' do
+ context "user is member of the top group" do
before do
group.add_owner(user)
end
if Group.supports_nested_objects?
- it 'returns all groups' do
+ it "returns all groups" do
is_expected.to match_array [
group,
nested_group_1, nested_group_1_1,
- nested_group_2, nested_group_2_1
+ nested_group_2, nested_group_2_1,
]
end
else
- it 'returns the top-level groups' do
+ it "returns the top-level groups" do
is_expected.to match_array [group]
end
end
end
- context 'user is member of the first child (internal node), branch 1', :nested_groups do
+ context "user is member of the first child (internal node), branch 1", :nested_groups do
before do
nested_group_1.add_owner(user)
end
- it 'returns the groups in the hierarchy' do
+ it "returns the groups in the hierarchy" do
is_expected.to match_array [
group,
- nested_group_1, nested_group_1_1
+ nested_group_1, nested_group_1_1,
]
end
end
- context 'user is member of the first child (internal node), branch 2', :nested_groups do
+ context "user is member of the first child (internal node), branch 2", :nested_groups do
before do
nested_group_2.add_owner(user)
end
- it 'returns the groups in the hierarchy' do
+ it "returns the groups in the hierarchy" do
is_expected.to match_array [
group,
- nested_group_2, nested_group_2_1
+ nested_group_2, nested_group_2_1,
]
end
end
- context 'user is member of the last child (leaf node)', :nested_groups do
+ context "user is member of the last child (leaf node)", :nested_groups do
before do
nested_group_1_1.add_owner(user)
end
- it 'returns the groups in the hierarchy' do
+ it "returns the groups in the hierarchy" do
is_expected.to match_array [
group,
- nested_group_1, nested_group_1_1
+ nested_group_1, nested_group_1_1,
]
end
end
end
- describe '#refresh_authorized_projects', :clean_gitlab_redis_shared_state do
+ describe "#refresh_authorized_projects", :clean_gitlab_redis_shared_state do
let(:project1) { create(:project) }
let(:project2) { create(:project) }
let(:user) { create(:user) }
@@ -2457,20 +2457,20 @@ describe User do
user.refresh_authorized_projects
end
- it 'refreshes the list of authorized projects' do
+ it "refreshes the list of authorized projects" do
expect(user.project_authorizations.count).to eq(2)
end
- it 'stores the correct access levels' do
+ it "stores the correct access levels" do
expect(user.project_authorizations.where(access_level: Gitlab::Access::GUEST).exists?).to eq(true)
expect(user.project_authorizations.where(access_level: Gitlab::Access::REPORTER).exists?).to eq(true)
end
end
- describe '#access_level=' do
+ describe "#access_level=" do
let(:user) { build(:user) }
- it 'does nothing for an invalid access level' do
+ it "does nothing for an invalid access level" do
user.access_level = :invalid_access_level
expect(user.access_level).to eq(:regular)
@@ -2493,28 +2493,28 @@ describe User do
end
it "accepts string values in addition to symbols" do
- user.access_level = 'admin'
+ user.access_level = "admin"
expect(user.access_level).to eq(:admin)
expect(user.admin).to be true
end
end
- describe '#full_private_access?' do
- it 'returns false for regular user' do
+ describe "#full_private_access?" do
+ it "returns false for regular user" do
user = build(:user)
expect(user.full_private_access?).to be_falsy
end
- it 'returns true for admin user' do
+ it "returns true for admin user" do
user = build(:user, :admin)
expect(user.full_private_access?).to be_truthy
end
end
- describe '.ghost' do
+ describe ".ghost" do
it "creates a ghost user if one isn't already present" do
ghost = described_class.ghost
@@ -2525,48 +2525,48 @@ describe User do
end
it "does not create a second ghost user if one is already present" do
- expect do
+ expect {
described_class.ghost
described_class.ghost
- end.to change { described_class.count }.by(1)
+ }.to change { described_class.count }.by(1)
expect(described_class.ghost).to eq(described_class.ghost)
end
context "when a regular user exists with the username 'ghost'" do
it "creates a ghost user with a non-conflicting username" do
- create(:user, username: 'ghost')
+ create(:user, username: "ghost")
ghost = described_class.ghost
expect(ghost).to be_persisted
- expect(ghost.username).to eq('ghost1')
+ expect(ghost.username).to eq("ghost1")
end
end
context "when a regular user exists with the email 'ghost@example.com'" do
it "creates a ghost user with a non-conflicting email" do
- create(:user, email: 'ghost@example.com')
+ create(:user, email: "ghost@example.com")
ghost = described_class.ghost
expect(ghost).to be_persisted
- expect(ghost.email).to eq('ghost1@example.com')
+ expect(ghost.email).to eq("ghost1@example.com")
end
end
- context 'when a domain whitelist is in place' do
+ context "when a domain whitelist is in place" do
before do
- stub_application_setting(domain_whitelist: ['gitlab.com'])
+ stub_application_setting(domain_whitelist: ["gitlab.com"])
end
- it 'creates a ghost user' do
+ it "creates a ghost user" do
expect(described_class.ghost).to be_persisted
end
end
end
- describe '#update_two_factor_requirement' do
+ describe "#update_two_factor_requirement" do
let(:user) { create :user }
- context 'with 2FA requirement on groups' do
+ context "with 2FA requirement on groups" do
let(:group1) { create :group, require_two_factor_authentication: true, two_factor_grace_period: 23 }
let(:group2) { create :group, require_two_factor_authentication: true, two_factor_grace_period: 32 }
@@ -2577,16 +2577,16 @@ describe User do
user.update_two_factor_requirement
end
- it 'requires 2FA' do
+ it "requires 2FA" do
expect(user.require_two_factor_authentication_from_group).to be true
end
- it 'uses the shortest grace period' do
+ it "uses the shortest grace period" do
expect(user.two_factor_grace_period).to be 23
end
end
- context 'with 2FA requirement on nested parent group', :nested_groups do
+ context "with 2FA requirement on nested parent group", :nested_groups do
let!(:group1) { create :group, require_two_factor_authentication: true }
let!(:group1a) { create :group, require_two_factor_authentication: false, parent: group1 }
@@ -2596,12 +2596,12 @@ describe User do
user.update_two_factor_requirement
end
- it 'requires 2FA' do
+ it "requires 2FA" do
expect(user.require_two_factor_authentication_from_group).to be true
end
end
- context 'with 2FA requirement on nested child group', :nested_groups do
+ context "with 2FA requirement on nested child group", :nested_groups do
let!(:group1) { create :group, require_two_factor_authentication: false }
let!(:group1a) { create :group, require_two_factor_authentication: true, parent: group1 }
@@ -2611,12 +2611,12 @@ describe User do
user.update_two_factor_requirement
end
- it 'requires 2FA' do
+ it "requires 2FA" do
expect(user.require_two_factor_authentication_from_group).to be true
end
end
- context 'without 2FA requirement on groups' do
+ context "without 2FA requirement on groups" do
let(:group) { create :group }
before do
@@ -2625,43 +2625,43 @@ describe User do
user.update_two_factor_requirement
end
- it 'does not require 2FA' do
+ it "does not require 2FA" do
expect(user.require_two_factor_authentication_from_group).to be false
end
- it 'falls back to the default grace period' do
+ it "falls back to the default grace period" do
expect(user.two_factor_grace_period).to be 48
end
end
end
- context '.active' do
+ context ".active" do
before do
described_class.ghost
- create(:user, name: 'user', state: 'active')
- create(:user, name: 'user', state: 'blocked')
+ create(:user, name: "user", state: "active")
+ create(:user, name: "user", state: "blocked")
end
- it 'only counts active and non internal users' do
+ it "only counts active and non internal users" do
expect(described_class.active.count).to eq(1)
end
end
- describe 'preferred language' do
- it 'is English by default' do
+ describe "preferred language" do
+ it "is English by default" do
user = create(:user)
- expect(user.preferred_language).to eq('en')
+ expect(user.preferred_language).to eq("en")
end
end
- context '#invalidate_issue_cache_counts' do
+ context "#invalidate_issue_cache_counts" do
let(:user) { build_stubbed(:user) }
- it 'invalidates cache for issue counter' do
+ it "invalidates cache for issue counter" do
cache_mock = double
- expect(cache_mock).to receive(:delete).with(['users', user.id, 'assigned_open_issues_count'])
+ expect(cache_mock).to receive(:delete).with(["users", user.id, "assigned_open_issues_count"])
allow(Rails).to receive(:cache).and_return(cache_mock)
@@ -2669,13 +2669,13 @@ describe User do
end
end
- context '#invalidate_merge_request_cache_counts' do
+ context "#invalidate_merge_request_cache_counts" do
let(:user) { build_stubbed(:user) }
- it 'invalidates cache for Merge Request counter' do
+ it "invalidates cache for Merge Request counter" do
cache_mock = double
- expect(cache_mock).to receive(:delete).with(['users', user.id, 'assigned_open_merge_requests_count'])
+ expect(cache_mock).to receive(:delete).with(["users", user.id, "assigned_open_merge_requests_count"])
allow(Rails).to receive(:cache).and_return(cache_mock)
@@ -2683,13 +2683,13 @@ describe User do
end
end
- context '#invalidate_personal_projects_count' do
+ context "#invalidate_personal_projects_count" do
let(:user) { build_stubbed(:user) }
- it 'invalidates cache for personal projects counter' do
+ it "invalidates cache for personal projects counter" do
cache_mock = double
- expect(cache_mock).to receive(:delete).with(['users', user.id, 'personal_projects_count'])
+ expect(cache_mock).to receive(:delete).with(["users", user.id, "personal_projects_count"])
allow(Rails).to receive(:cache).and_return(cache_mock)
@@ -2697,52 +2697,52 @@ describe User do
end
end
- describe '#allow_password_authentication_for_web?' do
- context 'regular user' do
+ describe "#allow_password_authentication_for_web?" do
+ context "regular user" do
let(:user) { build(:user) }
- it 'returns true when password authentication is enabled for the web interface' do
+ it "returns true when password authentication is enabled for the web interface" do
expect(user.allow_password_authentication_for_web?).to be_truthy
end
- it 'returns false when password authentication is disabled for the web interface' do
+ it "returns false when password authentication is disabled for the web interface" do
stub_application_setting(password_authentication_enabled_for_web: false)
expect(user.allow_password_authentication_for_web?).to be_falsey
end
end
- it 'returns false for ldap user' do
- user = create(:omniauth_user, provider: 'ldapmain')
+ it "returns false for ldap user" do
+ user = create(:omniauth_user, provider: "ldapmain")
expect(user.allow_password_authentication_for_web?).to be_falsey
end
end
- describe '#allow_password_authentication_for_git?' do
- context 'regular user' do
+ describe "#allow_password_authentication_for_git?" do
+ context "regular user" do
let(:user) { build(:user) }
- it 'returns true when password authentication is enabled for Git' do
+ it "returns true when password authentication is enabled for Git" do
expect(user.allow_password_authentication_for_git?).to be_truthy
end
- it 'returns false when password authentication is disabled Git' do
+ it "returns false when password authentication is disabled Git" do
stub_application_setting(password_authentication_enabled_for_git: false)
expect(user.allow_password_authentication_for_git?).to be_falsey
end
end
- it 'returns false for ldap user' do
- user = create(:omniauth_user, provider: 'ldapmain')
+ it "returns false for ldap user" do
+ user = create(:omniauth_user, provider: "ldapmain")
expect(user.allow_password_authentication_for_git?).to be_falsey
end
end
- describe '#assigned_open_merge_requests_count' do
- it 'returns number of open merge requests from non-archived projects' do
+ describe "#assigned_open_merge_requests_count" do
+ it "returns number of open merge requests from non-archived projects" do
user = create(:user)
project = create(:project, :public)
archived_project = create(:project, :public, :archived)
@@ -2755,8 +2755,8 @@ describe User do
end
end
- describe '#assigned_open_issues_count' do
- it 'returns number of open issues from non-archived projects' do
+ describe "#assigned_open_issues_count" do
+ it "returns number of open issues from non-archived projects" do
user = create(:user)
project = create(:project, :public)
archived_project = create(:project, :public, :archived)
@@ -2769,8 +2769,8 @@ describe User do
end
end
- describe '#personal_projects_count' do
- it 'returns the number of personal projects using a single query' do
+ describe "#personal_projects_count" do
+ it "returns the number of personal projects using a single query" do
user = build(:user)
projects = double(:projects, count: 1)
@@ -2780,8 +2780,8 @@ describe User do
end
end
- describe '#projects_limit_left' do
- it 'returns the number of projects that can be created by the user' do
+ describe "#projects_limit_left" do
+ it "returns the number of projects that can be created by the user" do
user = build(:user)
allow(user).to receive(:projects_limit).and_return(10)
@@ -2791,11 +2791,11 @@ describe User do
end
end
- describe '#ensure_namespace_correct' do
- context 'for a new user' do
+ describe "#ensure_namespace_correct" do
+ context "for a new user" do
let(:user) { build(:user) }
- it 'creates the namespace' do
+ it "creates the namespace" do
expect(user.namespace).to be_nil
user.save!
@@ -2804,79 +2804,79 @@ describe User do
end
end
- context 'for an existing user' do
- let(:username) { 'foo' }
+ context "for an existing user" do
+ let(:username) { "foo" }
let(:user) { create(:user, username: username) }
- context 'when the user is updated' do
- context 'when the username is changed' do
- let(:new_username) { 'bar' }
+ context "when the user is updated" do
+ context "when the username is changed" do
+ let(:new_username) { "bar" }
- it 'changes the namespace (just to compare to when username is not changed)' do
- expect do
+ it "changes the namespace (just to compare to when username is not changed)" do
+ expect {
Timecop.freeze(1.second.from_now) do
user.update!(username: new_username)
end
- end.to change { user.namespace.updated_at }
+ }.to change { user.namespace.updated_at }
end
- it 'updates the namespace name' do
+ it "updates the namespace name" do
user.update!(username: new_username)
expect(user.namespace.name).to eq(new_username)
end
- it 'updates the namespace path' do
+ it "updates the namespace path" do
user.update!(username: new_username)
expect(user.namespace.path).to eq(new_username)
end
- context 'when there is a validation error (namespace name taken) while updating namespace' do
+ context "when there is a validation error (namespace name taken) while updating namespace" do
let!(:conflicting_namespace) { create(:group, path: new_username) }
- it 'causes the user save to fail' do
+ it "causes the user save to fail" do
expect(user.update(username: new_username)).to be_falsey
- expect(user.namespace.errors.messages[:path].first).to eq('has already been taken')
+ expect(user.namespace.errors.messages[:path].first).to eq("has already been taken")
end
- it 'adds the namespace errors to the user' do
+ it "adds the namespace errors to the user" do
user.update(username: new_username)
- expect(user.errors.full_messages.first).to eq('Username has already been taken')
+ expect(user.errors.full_messages.first).to eq("Username has already been taken")
end
end
end
- context 'when the username is not changed' do
- it 'does not change the namespace' do
- expect do
- user.update!(email: 'asdf@asdf.com')
- end.not_to change { user.namespace.updated_at }
+ context "when the username is not changed" do
+ it "does not change the namespace" do
+ expect {
+ user.update!(email: "asdf@asdf.com")
+ }.not_to change { user.namespace.updated_at }
end
end
end
end
end
- describe '#username_changed_hook' do
- context 'for a new user' do
+ describe "#username_changed_hook" do
+ context "for a new user" do
let(:user) { build(:user) }
- it 'does not trigger system hook' do
+ it "does not trigger system hook" do
expect(user).not_to receive(:system_hook_service)
user.save!
end
end
- context 'for an existing user' do
- let(:user) { create(:user, username: 'old-username') }
+ context "for an existing user" do
+ let(:user) { create(:user, username: "old-username") }
- context 'when the username is changed' do
- let(:new_username) { 'very-new-name' }
+ context "when the username is changed" do
+ let(:new_username) { "very-new-name" }
- it 'triggers the rename system hook' do
+ it "triggers the rename system hook" do
system_hook_service = SystemHooksService.new
expect(system_hook_service).to receive(:execute_hooks_for).with(user, :rename)
expect(user).to receive(:system_hook_service).and_return(system_hook_service)
@@ -2885,57 +2885,57 @@ describe User do
end
end
- context 'when the username is not changed' do
- it 'does not trigger system hook' do
+ context "when the username is not changed" do
+ it "does not trigger system hook" do
expect(user).not_to receive(:system_hook_service)
- user.update!(email: 'asdf@asdf.com')
+ user.update!(email: "asdf@asdf.com")
end
end
end
end
- describe '#sync_attribute?' do
+ describe "#sync_attribute?" do
let(:user) { described_class.new }
- context 'oauth user' do
- it 'returns true if name can be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(name location))
+ context "oauth user" do
+ it "returns true if name can be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[name location])
expect(user.sync_attribute?(:name)).to be_truthy
end
- it 'returns true if email can be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(name email))
+ it "returns true if email can be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[name email])
expect(user.sync_attribute?(:email)).to be_truthy
end
- it 'returns true if location can be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(location email))
+ it "returns true if location can be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[location email])
expect(user.sync_attribute?(:email)).to be_truthy
end
- it 'returns false if name can not be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(location email))
+ it "returns false if name can not be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[location email])
expect(user.sync_attribute?(:name)).to be_falsey
end
- it 'returns false if email can not be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(location email))
+ it "returns false if email can not be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[location email])
expect(user.sync_attribute?(:name)).to be_falsey
end
- it 'returns false if location can not be synced' do
- stub_omniauth_setting(sync_profile_attributes: %w(location email))
+ it "returns false if location can not be synced" do
+ stub_omniauth_setting(sync_profile_attributes: %w[location email])
expect(user.sync_attribute?(:name)).to be_falsey
end
- it 'returns true for all syncable attributes if all syncable attributes can be synced' do
+ it "returns true for all syncable attributes if all syncable attributes can be synced" do
stub_omniauth_setting(sync_profile_attributes: true)
expect(user.sync_attribute?(:name)).to be_truthy
@@ -2943,15 +2943,15 @@ describe User do
expect(user.sync_attribute?(:location)).to be_truthy
end
- it 'returns false for all syncable attributes but email if no syncable attributes are declared' do
+ it "returns false for all syncable attributes but email if no syncable attributes are declared" do
expect(user.sync_attribute?(:name)).to be_falsey
expect(user.sync_attribute?(:email)).to be_truthy
expect(user.sync_attribute?(:location)).to be_falsey
end
end
- context 'ldap user' do
- it 'returns true for email if ldap user' do
+ context "ldap user" do
+ it "returns true for email if ldap user" do
allow(user).to receive(:ldap_user?).and_return(true)
expect(user.sync_attribute?(:name)).to be_falsey
@@ -2959,9 +2959,9 @@ describe User do
expect(user.sync_attribute?(:location)).to be_falsey
end
- it 'returns true for email and location if ldap user and location declared as syncable' do
+ it "returns true for email and location if ldap user and location declared as syncable" do
allow(user).to receive(:ldap_user?).and_return(true)
- stub_omniauth_setting(sync_profile_attributes: %w(location))
+ stub_omniauth_setting(sync_profile_attributes: %w[location])
expect(user.sync_attribute?(:name)).to be_falsey
expect(user.sync_attribute?(:email)).to be_truthy
@@ -2970,7 +2970,7 @@ describe User do
end
end
- describe '#confirm_deletion_with_password?' do
+ describe "#confirm_deletion_with_password?" do
where(
password_automatically_set: [true, false],
ldap_user: [true, false],
@@ -2989,25 +2989,25 @@ describe User do
stub_application_setting(password_authentication_enabled_for_git: !password_authentication_disabled)
end
- it 'returns false unless all inputs are true' do
+ it "returns false unless all inputs are true" do
expect(user.confirm_deletion_with_password?).to eq(expected)
end
end
end
- describe '#delete_async' do
+ describe "#delete_async" do
let(:user) { create(:user) }
let(:deleted_by) { create(:user) }
- it 'blocks the user then schedules them for deletion if a hard delete is specified' do
+ it "blocks the user then schedules them for deletion if a hard delete is specified" do
expect(DeleteUserWorker).to receive(:perform_async).with(deleted_by.id, user.id, hard_delete: true)
- user.delete_async(deleted_by: deleted_by, params: { hard_delete: true })
+ user.delete_async(deleted_by: deleted_by, params: {hard_delete: true})
expect(user).to be_blocked
end
- it 'schedules user for deletion without blocking them' do
+ it "schedules user for deletion without blocking them" do
expect(DeleteUserWorker).to receive(:perform_async).with(deleted_by.id, user.id, {})
user.delete_async(deleted_by: deleted_by)
@@ -3016,8 +3016,8 @@ describe User do
end
end
- describe '#max_member_access_for_project_ids' do
- shared_examples 'max member access for projects' do
+ describe "#max_member_access_for_project_ids" do
+ shared_examples "max member access for projects" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:owner_project) { create(:project, group: group) }
@@ -3038,7 +3038,7 @@ describe User do
reporter_project.id => Gitlab::Access::REPORTER,
developer_project.id => Gitlab::Access::DEVELOPER,
guest_project.id => Gitlab::Access::GUEST,
- no_access_project.id => Gitlab::Access::NO_ACCESS
+ no_access_project.id => Gitlab::Access::NO_ACCESS,
}
end
@@ -3050,19 +3050,19 @@ describe User do
guest_project.add_guest(user)
end
- it 'returns correct roles for different projects' do
+ it "returns correct roles for different projects" do
expect(user.max_member_access_for_project_ids(projects)).to eq(expected)
end
end
- context 'with RequestStore enabled', :request_store do
- include_examples 'max member access for projects'
+ context "with RequestStore enabled", :request_store do
+ include_examples "max member access for projects"
def access_levels(projects)
user.max_member_access_for_project_ids(projects)
end
- it 'does not perform extra queries when asked for projects who have already been found' do
+ it "does not perform extra queries when asked for projects who have already been found" do
access_levels(projects)
expect { access_levels(projects) }.not_to exceed_query_limit(0)
@@ -3070,7 +3070,7 @@ describe User do
expect(access_levels(projects)).to eq(expected)
end
- it 'only requests the extra projects when uncached projects are passed' do
+ it "only requests the extra projects when uncached projects are passed" do
second_maintainer_project = create(:project)
second_developer_project = create(:project)
second_maintainer_project.add_maintainer(user)
@@ -3091,13 +3091,13 @@ describe User do
end
end
- context 'with RequestStore disabled' do
- include_examples 'max member access for projects'
+ context "with RequestStore disabled" do
+ include_examples "max member access for projects"
end
end
- describe '#max_member_access_for_group_ids' do
- shared_examples 'max member access for groups' do
+ describe "#max_member_access_for_group_ids" do
+ shared_examples "max member access for groups" do
let(:user) { create(:user) }
let(:owner_group) { create(:group) }
let(:maintainer_group) { create(:group) }
@@ -3117,7 +3117,7 @@ describe User do
reporter_group.id => Gitlab::Access::REPORTER,
developer_group.id => Gitlab::Access::DEVELOPER,
guest_group.id => Gitlab::Access::GUEST,
- no_access_group.id => Gitlab::Access::NO_ACCESS
+ no_access_group.id => Gitlab::Access::NO_ACCESS,
}
end
@@ -3129,19 +3129,19 @@ describe User do
guest_group.add_guest(user)
end
- it 'returns correct roles for different groups' do
+ it "returns correct roles for different groups" do
expect(user.max_member_access_for_group_ids(groups)).to eq(expected)
end
end
- context 'with RequestStore enabled', :request_store do
- include_examples 'max member access for groups'
+ context "with RequestStore enabled", :request_store do
+ include_examples "max member access for groups"
def access_levels(groups)
user.max_member_access_for_group_ids(groups)
end
- it 'does not perform extra queries when asked for groups who have already been found' do
+ it "does not perform extra queries when asked for groups who have already been found" do
access_levels(groups)
expect { access_levels(groups) }.not_to exceed_query_limit(0)
@@ -3149,7 +3149,7 @@ describe User do
expect(access_levels(groups)).to eq(expected)
end
- it 'only requests the extra groups when uncached groups are passed' do
+ it "only requests the extra groups when uncached groups are passed" do
second_maintainer_group = create(:group)
second_developer_group = create(:group)
second_maintainer_group.add_maintainer(user)
@@ -3170,28 +3170,28 @@ describe User do
end
end
- context 'with RequestStore disabled' do
- include_examples 'max member access for groups'
+ context "with RequestStore disabled" do
+ include_examples "max member access for groups"
end
end
- context 'changing a username' do
- let(:user) { create(:user, username: 'foo') }
+ context "changing a username" do
+ let(:user) { create(:user, username: "foo") }
- it 'creates a redirect route' do
- expect { user.update!(username: 'bar') }
- .to change { RedirectRoute.where(path: 'foo').count }.by(1)
+ it "creates a redirect route" do
+ expect { user.update!(username: "bar") }
+ .to change { RedirectRoute.where(path: "foo").count }.by(1)
end
- it 'deletes the redirect when a user with the old username was created' do
- user.update!(username: 'bar')
+ it "deletes the redirect when a user with the old username was created" do
+ user.update!(username: "bar")
- expect { create(:user, username: 'foo') }
- .to change { RedirectRoute.where(path: 'foo').count }.by(-1)
+ expect { create(:user, username: "foo") }
+ .to change { RedirectRoute.where(path: "foo").count }.by(-1)
end
end
- describe '#required_terms_not_accepted?' do
+ describe "#required_terms_not_accepted?" do
let(:user) { build(:user) }
subject { user.required_terms_not_accepted? }
@@ -3217,81 +3217,81 @@ describe User do
end
end
- describe '#increment_failed_attempts!' do
+ describe "#increment_failed_attempts!" do
subject(:user) { create(:user, failed_attempts: 0) }
- it 'logs failed sign-in attempts' do
+ it "logs failed sign-in attempts" do
expect { user.increment_failed_attempts! }.to change(user, :failed_attempts).from(0).to(1)
end
- it 'does not log failed sign-in attempts when in a GitLab read-only instance' do
+ it "does not log failed sign-in attempts when in a GitLab read-only instance" do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect { user.increment_failed_attempts! }.not_to change(user, :failed_attempts)
end
end
- describe '#requires_usage_stats_consent?' do
+ describe "#requires_usage_stats_consent?" do
let(:user) { create(:user, created_at: 8.days.ago) }
before do
allow(user).to receive(:has_current_license?).and_return false
end
- context 'in single-user environment' do
- it 'requires user consent after one week' do
+ context "in single-user environment" do
+ it "requires user consent after one week" do
create(:user, ghost: true)
expect(user.requires_usage_stats_consent?).to be true
end
- it 'requires user consent after one week if there is another ghost user' do
+ it "requires user consent after one week if there is another ghost user" do
expect(user.requires_usage_stats_consent?).to be true
end
- it 'does not require consent in the first week' do
+ it "does not require consent in the first week" do
user.created_at = 6.days.ago
expect(user.requires_usage_stats_consent?).to be false
end
- it 'does not require consent if usage stats were set by this user' do
+ it "does not require consent if usage stats were set by this user" do
allow(Gitlab::CurrentSettings).to receive(:usage_stats_set_by_user_id).and_return(user.id)
expect(user.requires_usage_stats_consent?).to be false
end
end
- context 'in multi-user environment' do
+ context "in multi-user environment" do
before do
create(:user)
end
- it 'does not require consent' do
+ it "does not require consent" do
expect(user.requires_usage_stats_consent?).to be false
end
end
end
- context 'with uploads' do
- it_behaves_like 'model with uploads', false do
+ context "with uploads" do
+ it_behaves_like "model with uploads", false do
let(:model_object) { create(:user, :with_avatar) }
let(:upload_attribute) { :avatar }
let(:uploader_class) { AttachmentUploader }
end
end
- describe '.union_with_user' do
- context 'when no user ID is provided' do
- it 'returns the input relation' do
+ describe ".union_with_user" do
+ context "when no user ID is provided" do
+ it "returns the input relation" do
user = create(:user)
expect(described_class.union_with_user).to eq([user])
end
end
- context 'when a user ID is provided' do
- it 'includes the user object in the returned relation' do
+ context "when a user ID is provided" do
+ it "includes the user object in the returned relation" do
user1 = create(:user)
user2 = create(:user)
users = described_class.where(id: user1.id).union_with_user(user2.id)
@@ -3300,7 +3300,7 @@ describe User do
expect(users).to include(user2)
end
- it 'does not re-apply any WHERE conditions on the outer query' do
+ it "does not re-apply any WHERE conditions on the outer query" do
relation = described_class.where(id: 1).union_with_user(2)
expect(relation.arel.where_sql).to be_nil
@@ -3308,25 +3308,25 @@ describe User do
end
end
- describe '.optionally_search' do
- context 'using nil as the argument' do
- it 'returns the current relation' do
+ describe ".optionally_search" do
+ context "using nil as the argument" do
+ it "returns the current relation" do
user = create(:user)
expect(described_class.optionally_search).to eq([user])
end
end
- context 'using an empty String as the argument' do
- it 'returns the current relation' do
+ context "using an empty String as the argument" do
+ it "returns the current relation" do
user = create(:user)
- expect(described_class.optionally_search('')).to eq([user])
+ expect(described_class.optionally_search("")).to eq([user])
end
end
- context 'using a non-empty String' do
- it 'returns users matching the search query' do
+ context "using a non-empty String" do
+ it "returns users matching the search query" do
user1 = create(:user)
create(:user)
@@ -3335,17 +3335,17 @@ describe User do
end
end
- describe '.where_not_in' do
- context 'without an argument' do
- it 'returns the current relation' do
+ describe ".where_not_in" do
+ context "without an argument" do
+ it "returns the current relation" do
user = create(:user)
expect(described_class.where_not_in).to eq([user])
end
end
- context 'using a list of user IDs' do
- it 'excludes the users from the returned relation' do
+ context "using a list of user IDs" do
+ it "excludes the users from the returned relation" do
user1 = create(:user)
user2 = create(:user)
@@ -3354,10 +3354,10 @@ describe User do
end
end
- describe '.reorder_by_name' do
- it 'reorders the input relation' do
- user1 = create(:user, name: 'A')
- user2 = create(:user, name: 'B')
+ describe ".reorder_by_name" do
+ it "reorders the input relation" do
+ user1 = create(:user, name: "A")
+ user2 = create(:user, name: "B")
expect(described_class.reorder_by_name).to eq([user1, user2])
end
diff --git a/spec/models/user_status_spec.rb b/spec/models/user_status_spec.rb
index fcc01cdae3d..b6f44d56e1f 100644
--- a/spec/models/user_status_spec.rb
+++ b/spec/models/user_status_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe UserStatus do
it { is_expected.to validate_presence_of(:user) }
- it { is_expected.to allow_value('smirk').for(:emoji) }
- it { is_expected.not_to allow_value('hello world').for(:emoji) }
- it { is_expected.not_to allow_value('').for(:emoji) }
+ it { is_expected.to allow_value("smirk").for(:emoji) }
+ it { is_expected.not_to allow_value("hello world").for(:emoji) }
+ it { is_expected.not_to allow_value("").for(:emoji) }
it { is_expected.to validate_length_of(:message).is_at_most(100) }
- it { is_expected.to allow_value('').for(:message) }
+ it { is_expected.to allow_value("").for(:message) }
- it 'is expected to be deleted when the user is deleted' do
+ it "is expected to be deleted when the user is deleted" do
status = create(:user_status)
expect { status.user.destroy }.to change { described_class.count }.from(1).to(0)
diff --git a/spec/models/wiki_directory_spec.rb b/spec/models/wiki_directory_spec.rb
index fb8575cfe2b..c3bbf879674 100644
--- a/spec/models/wiki_directory_spec.rb
+++ b/spec/models/wiki_directory_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
RSpec.describe WikiDirectory do
- describe 'validations' do
+ describe "validations" do
subject { build(:wiki_directory) }
it { is_expected.to validate_presence_of(:slug) }
end
- describe '#initialize' do
- context 'when there are pages' do
+ describe "#initialize" do
+ context "when there are pages" do
let(:pages) { [build(:wiki_page)] }
- let(:directory) { described_class.new('/path_up_to/dir', pages) }
+ let(:directory) { described_class.new("/path_up_to/dir", pages) }
- it 'sets the slug attribute' do
- expect(directory.slug).to eq('/path_up_to/dir')
+ it "sets the slug attribute" do
+ expect(directory.slug).to eq("/path_up_to/dir")
end
- it 'sets the pages attribute' do
+ it "sets the pages attribute" do
expect(directory.pages).to eq(pages)
end
end
- context 'when there are no pages' do
- let(:directory) { described_class.new('/path_up_to/dir') }
+ context "when there are no pages" do
+ let(:directory) { described_class.new("/path_up_to/dir") }
- it 'sets the slug attribute' do
- expect(directory.slug).to eq('/path_up_to/dir')
+ it "sets the slug attribute" do
+ expect(directory.slug).to eq("/path_up_to/dir")
end
- it 'sets the pages attribute to an empty array' do
+ it "sets the pages attribute to an empty array" do
expect(directory.pages).to eq([])
end
end
end
- describe '#to_partial_path' do
- it 'returns the relative path to the partial to be used' do
+ describe "#to_partial_path" do
+ it "returns the relative path to the partial to be used" do
directory = build(:wiki_directory)
- expect(directory.to_partial_path).to eq('projects/wikis/wiki_directory')
+ expect(directory.to_partial_path).to eq("projects/wikis/wiki_directory")
end
end
end
diff --git a/spec/models/wiki_page_spec.rb b/spec/models/wiki_page_spec.rb
index cba22b2cc4e..93389ef0665 100644
--- a/spec/models/wiki_page_spec.rb
+++ b/spec/models/wiki_page_spec.rb
@@ -7,36 +7,36 @@ describe WikiPage do
subject { described_class.new(wiki) }
- describe '.group_by_directory' do
- context 'when there are no pages' do
- it 'returns an empty array' do
+ describe ".group_by_directory" do
+ context "when there are no pages" do
+ it "returns an empty array" do
expect(described_class.group_by_directory(nil)).to eq([])
expect(described_class.group_by_directory([])).to eq([])
end
end
- context 'when there are pages' do
+ context "when there are pages" do
before do
- create_page('dir_1/dir_1_1/page_3', 'content')
- create_page('dir_1/page_2', 'content')
- create_page('dir_2/page_5', 'content')
- create_page('dir_2/page_4', 'content')
- create_page('page_1', 'content')
+ create_page("dir_1/dir_1_1/page_3", "content")
+ create_page("dir_1/page_2", "content")
+ create_page("dir_2/page_5", "content")
+ create_page("dir_2/page_4", "content")
+ create_page("page_1", "content")
end
- let(:page_1) { wiki.find_page('page_1') }
+ let(:page_1) { wiki.find_page("page_1") }
let(:dir_1) do
- WikiDirectory.new('dir_1', [wiki.find_page('dir_1/page_2')])
+ WikiDirectory.new("dir_1", [wiki.find_page("dir_1/page_2")])
end
let(:dir_1_1) do
- WikiDirectory.new('dir_1/dir_1_1', [wiki.find_page('dir_1/dir_1_1/page_3')])
+ WikiDirectory.new("dir_1/dir_1_1", [wiki.find_page("dir_1/dir_1_1/page_3")])
end
let(:dir_2) do
- pages = [wiki.find_page('dir_2/page_5'),
- wiki.find_page('dir_2/page_4')]
- WikiDirectory.new('dir_2', pages)
+ pages = [wiki.find_page("dir_2/page_5"),
+ wiki.find_page("dir_2/page_4"),]
+ WikiDirectory.new("dir_2", pages)
end
- it 'returns an array with pages and directories' do
+ it "returns an array with pages and directories" do
expected_grouped_entries = [page_1, dir_1, dir_1_1, dir_2]
grouped_entries = described_class.group_by_directory(wiki.pages)
@@ -50,29 +50,29 @@ describe WikiPage do
end
end
- it 'returns an array sorted by alphabetical position' do
+ it "returns an array sorted by alphabetical position" do
# Directories and pages within directories are sorted alphabetically.
# Pages at root come before everything.
- expected_order = ['page_1', 'dir_1/page_2', 'dir_1/dir_1_1/page_3',
- 'dir_2/page_4', 'dir_2/page_5']
+ expected_order = ["page_1", "dir_1/page_2", "dir_1/dir_1_1/page_3",
+ "dir_2/page_4", "dir_2/page_5",]
grouped_entries = described_class.group_by_directory(wiki.pages)
actual_order =
- grouped_entries.map do |page_or_dir|
+ grouped_entries.map { |page_or_dir|
get_slugs(page_or_dir)
- end
- .flatten
+ }
+ .flatten
expect(actual_order).to eq(expected_order)
end
end
end
- describe '.unhyphenize' do
- it 'removes hyphens from a name' do
- name = 'a-name--with-hyphens'
+ describe ".unhyphenize" do
+ it "removes hyphens from a name" do
+ name = "a-name--with-hyphens"
- expect(described_class.unhyphenize(name)).to eq('a name with hyphens')
+ expect(described_class.unhyphenize(name)).to eq("a name with hyphens")
end
end
@@ -112,7 +112,7 @@ describe WikiPage do
describe "validations" do
before do
- subject.attributes = { title: 'title', content: 'content' }
+ subject.attributes = {title: "title", content: "content"}
end
it "validates presence of title" do
@@ -132,7 +132,7 @@ describe WikiPage do
title: "Index",
content: "Home Page",
format: "markdown",
- message: 'Custom Commit Message'
+ message: "Custom Commit Message",
}
end
@@ -150,19 +150,19 @@ describe WikiPage do
expect(subject.create(wiki_attr)).to eq(true)
end
- it 'saves the wiki page with message' do
+ it "saves the wiki page with message" do
subject.create(wiki_attr)
- expect(wiki.find_page("Index").message).to eq 'Custom Commit Message'
+ expect(wiki.find_page("Index").message).to eq "Custom Commit Message"
end
end
end
describe "dot in the title" do
- let(:title) { 'Index v1.2.3' }
+ let(:title) { "Index v1.2.3" }
before do
- @wiki_attr = { title: title, content: "Home Page", format: "markdown" }
+ @wiki_attr = {title: title, content: "Home Page", format: "markdown"}
end
describe "#create" do
@@ -199,24 +199,24 @@ describe WikiPage do
end
end
- describe '#create' do
- context 'with valid attributes' do
- it 'raises an error if a page with the same path already exists' do
- create_page('New Page', 'content')
- create_page('foo/bar', 'content')
- expect { create_page('New Page', 'other content') }.to raise_error Gitlab::Git::Wiki::DuplicatePageError
- expect { create_page('foo/bar', 'other content') }.to raise_error Gitlab::Git::Wiki::DuplicatePageError
+ describe "#create" do
+ context "with valid attributes" do
+ it "raises an error if a page with the same path already exists" do
+ create_page("New Page", "content")
+ create_page("foo/bar", "content")
+ expect { create_page("New Page", "other content") }.to raise_error Gitlab::Git::Wiki::DuplicatePageError
+ expect { create_page("foo/bar", "other content") }.to raise_error Gitlab::Git::Wiki::DuplicatePageError
- destroy_page('New Page')
- destroy_page('bar', 'foo')
+ destroy_page("New Page")
+ destroy_page("bar", "foo")
end
- it 'if the title is preceded by a / it is removed' do
- create_page('/New Page', 'content')
+ it "if the title is preceded by a / it is removed" do
+ create_page("/New Page", "content")
- expect(wiki.find_page('New Page')).not_to be_nil
+ expect(wiki.find_page("New Page")).not_to be_nil
- destroy_page('New Page')
+ destroy_page("New Page")
end
end
end
@@ -255,32 +255,32 @@ describe WikiPage do
end
end
- context 'with same last commit sha' do
- it 'returns true' do
- expect(@page.update(content: 'more content', last_commit_sha: @page.last_commit_sha)).to be_truthy
+ context "with same last commit sha" do
+ it "returns true" do
+ expect(@page.update(content: "more content", last_commit_sha: @page.last_commit_sha)).to be_truthy
end
end
- context 'with different last commit sha' do
- it 'raises exception' do
- expect { @page.update(content: 'more content', last_commit_sha: 'xxx') }.to raise_error(WikiPage::PageChangedError)
+ context "with different last commit sha" do
+ it "raises exception" do
+ expect { @page.update(content: "more content", last_commit_sha: "xxx") }.to raise_error(WikiPage::PageChangedError)
end
end
- context 'when renaming a page' do
- it 'raises an error if the page already exists' do
- create_page('Existing Page', 'content')
+ context "when renaming a page" do
+ it "raises an error if the page already exists" do
+ create_page("Existing Page", "content")
- expect { @page.update(title: 'Existing Page', content: 'new_content') }.to raise_error(WikiPage::PageRenameError)
- expect(@page.title).to eq 'Update'
- expect(@page.content).to eq 'new_content'
+ expect { @page.update(title: "Existing Page", content: "new_content") }.to raise_error(WikiPage::PageRenameError)
+ expect(@page.title).to eq "Update"
+ expect(@page.content).to eq "new_content"
- destroy_page('Existing Page')
+ destroy_page("Existing Page")
end
- it 'updates the content and rename the file' do
- new_title = 'Renamed Page'
- new_content = 'updated content'
+ it "updates the content and rename the file" do
+ new_title = "Renamed Page"
+ new_content = "updated content"
expect(@page.update(title: new_title, content: new_content)).to be_truthy
@@ -291,20 +291,20 @@ describe WikiPage do
end
end
- context 'when moving a page' do
- it 'raises an error if the page already exists' do
- create_page('foo/Existing Page', 'content')
+ context "when moving a page" do
+ it "raises an error if the page already exists" do
+ create_page("foo/Existing Page", "content")
- expect { @page.update(title: 'foo/Existing Page', content: 'new_content') }.to raise_error(WikiPage::PageRenameError)
- expect(@page.title).to eq 'Update'
- expect(@page.content).to eq 'new_content'
+ expect { @page.update(title: "foo/Existing Page", content: "new_content") }.to raise_error(WikiPage::PageRenameError)
+ expect(@page.title).to eq "Update"
+ expect(@page.content).to eq "new_content"
- destroy_page('Existing Page', 'foo')
+ destroy_page("Existing Page", "foo")
end
- it 'updates the content and moves the file' do
- new_title = 'foo/Other Page'
- new_content = 'new_content'
+ it "updates the content and moves the file" do
+ new_title = "foo/Other Page"
+ new_content = "new_content"
expect(@page.update(title: new_title, content: new_content)).to be_truthy
@@ -314,45 +314,45 @@ describe WikiPage do
expect(page.content).to eq new_content
end
- context 'in subdir' do
+ context "in subdir" do
before do
- create_page('foo/Existing Page', 'content')
- @page = wiki.find_page('foo/Existing Page')
+ create_page("foo/Existing Page", "content")
+ @page = wiki.find_page("foo/Existing Page")
end
- it 'moves the page to the root folder if the title is preceded by /' do
- expect(@page.slug).to eq 'foo/Existing-Page'
- expect(@page.update(title: '/Existing Page', content: 'new_content')).to be_truthy
- expect(@page.slug).to eq 'Existing-Page'
+ it "moves the page to the root folder if the title is preceded by /" do
+ expect(@page.slug).to eq "foo/Existing-Page"
+ expect(@page.update(title: "/Existing Page", content: "new_content")).to be_truthy
+ expect(@page.slug).to eq "Existing-Page"
end
- it 'does nothing if it has the same title' do
+ it "does nothing if it has the same title" do
original_path = @page.slug
- expect(@page.update(title: 'Existing Page', content: 'new_content')).to be_truthy
+ expect(@page.update(title: "Existing Page", content: "new_content")).to be_truthy
expect(@page.slug).to eq original_path
end
end
- context 'in root dir' do
- it 'does nothing if the title is preceded by /' do
+ context "in root dir" do
+ it "does nothing if the title is preceded by /" do
original_path = @page.slug
- expect(@page.update(title: '/Update', content: 'new_content')).to be_truthy
+ expect(@page.update(title: "/Update", content: "new_content")).to be_truthy
expect(@page.slug).to eq original_path
end
end
end
context "with invalid attributes" do
- it 'aborts update if title blank' do
- expect(@page.update(title: '', content: 'new_content')).to be_falsey
- expect(@page.content).to eq 'new_content'
+ it "aborts update if title blank" do
+ expect(@page.update(title: "", content: "new_content")).to be_falsey
+ expect(@page.content).to eq "new_content"
- page = wiki.find_page('Update')
- expect(page.content).to eq 'content'
+ page = wiki.find_page("Update")
+ expect(page.content).to eq "content"
- @page.title = 'Update'
+ @page.title = "Update"
end
end
end
@@ -390,8 +390,8 @@ describe WikiPage do
expect(page.versions.count).to eq(4)
end
- it 'returns instances of WikiPageVersion' do
- expect(page.versions).to all( be_a(Gitlab::Git::WikiPageVersion) )
+ it "returns instances of WikiPageVersion" do
+ expect(page.versions).to all(be_a(Gitlab::Git::WikiPageVersion))
end
end
@@ -410,97 +410,97 @@ describe WikiPage do
expect(@page.title).to eq("Import existing repositories into GitLab")
end
- it 'unescapes html' do
- @page.title = 'foo &amp; bar'
+ it "unescapes html" do
+ @page.title = "foo &amp; bar"
- expect(@page.title).to eq('foo & bar')
+ expect(@page.title).to eq("foo & bar")
end
end
- describe '#directory' do
- context 'when the page is at the root directory' do
- it 'returns an empty string' do
- create_page('file', 'content')
- page = wiki.find_page('file')
+ describe "#directory" do
+ context "when the page is at the root directory" do
+ it "returns an empty string" do
+ create_page("file", "content")
+ page = wiki.find_page("file")
- expect(page.directory).to eq('')
+ expect(page.directory).to eq("")
end
end
- context 'when the page is inside an actual directory' do
- it 'returns the full directory hierarchy' do
- create_page('dir_1/dir_1_1/file', 'content')
- page = wiki.find_page('dir_1/dir_1_1/file')
+ context "when the page is inside an actual directory" do
+ it "returns the full directory hierarchy" do
+ create_page("dir_1/dir_1_1/file", "content")
+ page = wiki.find_page("dir_1/dir_1_1/file")
- expect(page.directory).to eq('dir_1/dir_1_1')
+ expect(page.directory).to eq("dir_1/dir_1_1")
end
end
end
- describe '#historical?' do
- let(:page) { wiki.find_page('Update') }
+ describe "#historical?" do
+ let(:page) { wiki.find_page("Update") }
let(:old_version) { page.versions.last.id }
- let(:old_page) { wiki.find_page('Update', old_version) }
+ let(:old_page) { wiki.find_page("Update", old_version) }
let(:latest_version) { page.versions.first.id }
- let(:latest_page) { wiki.find_page('Update', latest_version) }
+ let(:latest_page) { wiki.find_page("Update", latest_version) }
before do
- create_page('Update', 'content')
- @page = wiki.find_page('Update')
+ create_page("Update", "content")
+ @page = wiki.find_page("Update")
3.times { |i| @page.update(content: "content #{i}") }
end
after do
- destroy_page('Update')
+ destroy_page("Update")
end
- it 'returns true when requesting an old version' do
+ it "returns true when requesting an old version" do
expect(old_page.historical?).to be_truthy
end
- it 'returns false when requesting latest version' do
+ it "returns false when requesting latest version" do
expect(latest_page.historical?).to be_falsy
end
- it 'returns false when version is nil' do
+ it "returns false when version is nil" do
expect(latest_page.historical?).to be_falsy
end
- it 'returns false when the last version is nil' do
+ it "returns false when the last version is nil" do
expect(old_page).to receive(:last_version) { nil }
expect(old_page.historical?).to be_falsy
end
- it 'returns false when the version is nil' do
+ it "returns false when the version is nil" do
expect(old_page).to receive(:version) { nil }
expect(old_page.historical?).to be_falsy
end
end
- describe '#to_partial_path' do
- it 'returns the relative path to the partial to be used' do
+ describe "#to_partial_path" do
+ it "returns the relative path to the partial to be used" do
page = build(:wiki_page)
- expect(page.to_partial_path).to eq('projects/wikis/wiki_page')
+ expect(page.to_partial_path).to eq("projects/wikis/wiki_page")
end
end
- describe '#==' do
+ describe "#==" do
let(:original_wiki_page) { create(:wiki_page) }
- it 'returns true for identical wiki page' do
+ it "returns true for identical wiki page" do
expect(original_wiki_page).to eq(original_wiki_page)
end
- it 'returns false for updated wiki page' do
+ it "returns false for updated wiki page" do
updated_wiki_page = original_wiki_page.update(content: "Updated content")
expect(original_wiki_page).not_to eq(updated_wiki_page)
end
end
- describe '#last_commit_sha' do
+ describe "#last_commit_sha" do
before do
create_page("Update", "content")
@page = wiki.find_page("Update")
@@ -510,11 +510,11 @@ describe WikiPage do
destroy_page("Update")
end
- it 'returns commit sha' do
+ it "returns commit sha" do
expect(@page.last_commit_sha).to eq @page.last_version.sha
end
- it 'is changed after page updated' do
+ it "is changed after page updated" do
last_commit_sha_before_update = @page.last_commit_sha
@page.update(content: "new content")
@@ -524,24 +524,24 @@ describe WikiPage do
end
end
- describe '#formatted_content' do
- it 'returns processed content of the page' do
- subject.create({ title: "RDoc", content: "*bold*", format: "rdoc" })
- page = wiki.find_page('RDoc')
+ describe "#formatted_content" do
+ it "returns processed content of the page" do
+ subject.create({title: "RDoc", content: "*bold*", format: "rdoc"})
+ page = wiki.find_page("RDoc")
expect(page.formatted_content).to eq("\n<p><strong>bold</strong></p>\n")
- destroy_page('RDoc')
+ destroy_page("RDoc")
end
end
- describe '#hook_attrs' do
- it 'adds absolute urls for images in the content' do
+ describe "#hook_attrs" do
+ it "adds absolute urls for images in the content" do
create_page("test page", "test![WikiPage_Image](/uploads/abc/WikiPage_Image.png)")
page = wiki.wiki.page(title: "test page")
wiki_page = described_class.new(wiki, page, true)
- expect(wiki_page.hook_attrs['content']).to eq("test![WikiPage_Image](#{Settings.gitlab.url}/uploads/abc/WikiPage_Image.png)")
+ expect(wiki_page.hook_attrs["content"]).to eq("test![WikiPage_Image](#{Settings.gitlab.url}/uploads/abc/WikiPage_Image.png)")
end
end
@@ -559,7 +559,7 @@ describe WikiPage do
wiki.wiki.write_page(name, :markdown, content, commit_details)
end
- def destroy_page(title, dir = '')
+ def destroy_page(title, dir = "")
page = wiki.wiki.page(title: title, dir: dir)
wiki.delete_page(page, "test commit")
end
diff --git a/spec/policies/application_setting/term_policy_spec.rb b/spec/policies/application_setting/term_policy_spec.rb
index 93b5ebf5f72..7f7fce19dc6 100644
--- a/spec/policies/application_setting/term_policy_spec.rb
+++ b/spec/policies/application_setting/term_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ApplicationSetting::TermPolicy do
include TermsHelper
@@ -9,40 +9,40 @@ describe ApplicationSetting::TermPolicy do
subject(:policy) { described_class.new(user, term) }
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
- it 'has the correct permissions', :aggregate_failures do
+ it "has the correct permissions", :aggregate_failures do
is_expected.to be_allowed(:accept_terms)
is_expected.to be_allowed(:decline_terms)
end
- context 'for anonymous users' do
+ context "for anonymous users" do
let(:user) { nil }
- it 'has the correct permissions', :aggregate_failures do
+ it "has the correct permissions", :aggregate_failures do
is_expected.to be_disallowed(:accept_terms)
is_expected.to be_disallowed(:decline_terms)
end
end
- context 'when the terms are not current' do
+ context "when the terms are not current" do
before do
create(:term)
end
- it 'has the correct permissions', :aggregate_failures do
+ it "has the correct permissions", :aggregate_failures do
is_expected.to be_disallowed(:accept_terms)
is_expected.to be_disallowed(:decline_terms)
end
end
- context 'when the user already accepted the terms' do
+ context "when the user already accepted the terms" do
before do
accept_terms(user)
end
- it 'has the correct permissions', :aggregate_failures do
+ it "has the correct permissions", :aggregate_failures do
is_expected.to be_disallowed(:accept_terms)
is_expected.to be_allowed(:decline_terms)
end
diff --git a/spec/policies/base_policy_spec.rb b/spec/policies/base_policy_spec.rb
index c03d95b34db..9a8f744878d 100644
--- a/spec/policies/base_policy_spec.rb
+++ b/spec/policies/base_policy_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe BasePolicy do
- describe '.class_for' do
- it 'detects policy class based on the subject ancestors' do
+ describe ".class_for" do
+ it "detects policy class based on the subject ancestors" do
expect(DeclarativePolicy.class_for(GenericCommitStatus.new)).to eq(CommitStatusPolicy)
end
- it 'detects policy class for a presented subject' do
+ it "detects policy class for a presented subject" do
presentee = Ci::BuildPresenter.new(Ci::Build.new)
expect(DeclarativePolicy.class_for(presentee)).to eq(Ci::BuildPolicy)
end
- it 'uses GlobalPolicy when :global is given' do
+ it "uses GlobalPolicy when :global is given" do
expect(DeclarativePolicy.class_for(:global)).to eq(GlobalPolicy)
end
end
diff --git a/spec/policies/board_policy_spec.rb b/spec/policies/board_policy_spec.rb
index 4b76d65ef69..2285be03b80 100644
--- a/spec/policies/board_policy_spec.rb
+++ b/spec/policies/board_policy_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BoardPolicy do
let(:user) { create(:user) }
@@ -13,7 +13,7 @@ describe BoardPolicy do
[
:read_parent,
:read_milestone,
- :read_issue
+ :read_issue,
]
end
@@ -25,10 +25,10 @@ describe BoardPolicy do
permissions.each { |p| is_expected.not_to be_allowed(p) }
end
- context 'group board' do
+ context "group board" do
subject { described_class.new(user, group_board) }
- context 'user has access' do
+ context "user has access" do
before do
group.add_developer(user)
end
@@ -38,17 +38,17 @@ describe BoardPolicy do
end
end
- context 'user does not have access' do
+ context "user does not have access" do
it do
expect_disallowed(*board_permissions)
end
end
end
- context 'project board' do
+ context "project board" do
subject { described_class.new(user, project_board) }
- context 'user has access' do
+ context "user has access" do
before do
project.add_developer(user)
end
@@ -58,7 +58,7 @@ describe BoardPolicy do
end
end
- context 'user does not have access' do
+ context "user does not have access" do
it do
expect_disallowed(*board_permissions)
end
diff --git a/spec/policies/ci/build_policy_spec.rb b/spec/policies/ci/build_policy_spec.rb
index 79a616899fa..9275d6fec32 100644
--- a/spec/policies/ci/build_policy_spec.rb
+++ b/spec/policies/ci/build_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildPolicy do
let(:user) { create(:user) }
@@ -9,97 +9,97 @@ describe Ci::BuildPolicy do
described_class.new(user, build)
end
- shared_context 'public pipelines disabled' do
+ shared_context "public pipelines disabled" do
before do
project.update_attribute(:public_builds, false)
end
end
- describe '#rules' do
- context 'when user does not have access to the project' do
+ describe "#rules" do
+ context "when user does not have access to the project" do
let(:project) { create(:project, :private) }
- context 'when public builds are enabled' do
- it 'does not include ability to read build' do
+ context "when public builds are enabled" do
+ it "does not include ability to read build" do
expect(policy).not_to be_allowed :read_build
end
end
- context 'when public builds are disabled' do
- include_context 'public pipelines disabled'
+ context "when public builds are disabled" do
+ include_context "public pipelines disabled"
- it 'does not include ability to read build' do
+ it "does not include ability to read build" do
expect(policy).not_to be_allowed :read_build
end
end
end
- context 'when anonymous user has access to the project' do
+ context "when anonymous user has access to the project" do
let(:project) { create(:project, :public) }
- context 'when public builds are enabled' do
- it 'includes ability to read build' do
+ context "when public builds are enabled" do
+ it "includes ability to read build" do
expect(policy).to be_allowed :read_build
end
end
- context 'when public builds are disabled' do
- include_context 'public pipelines disabled'
+ context "when public builds are disabled" do
+ include_context "public pipelines disabled"
- it 'does not include ability to read build' do
+ it "does not include ability to read build" do
expect(policy).not_to be_allowed :read_build
end
end
end
- context 'when team member has access to the project' do
+ context "when team member has access to the project" do
let(:project) { create(:project, :public) }
- context 'team member is a guest' do
+ context "team member is a guest" do
before do
project.add_guest(user)
end
- context 'when public builds are enabled' do
- it 'includes ability to read build' do
+ context "when public builds are enabled" do
+ it "includes ability to read build" do
expect(policy).to be_allowed :read_build
end
end
- context 'when public builds are disabled' do
- include_context 'public pipelines disabled'
+ context "when public builds are disabled" do
+ include_context "public pipelines disabled"
- it 'does not include ability to read build' do
+ it "does not include ability to read build" do
expect(policy).not_to be_allowed :read_build
end
end
end
- context 'team member is a reporter' do
+ context "team member is a reporter" do
before do
project.add_reporter(user)
end
- context 'when public builds are enabled' do
- it 'includes ability to read build' do
+ context "when public builds are enabled" do
+ it "includes ability to read build" do
expect(policy).to be_allowed :read_build
end
end
- context 'when public builds are disabled' do
- include_context 'public pipelines disabled'
+ context "when public builds are disabled" do
+ include_context "public pipelines disabled"
- it 'does not include ability to read build' do
+ it "does not include ability to read build" do
expect(policy).to be_allowed :read_build
end
end
end
- context 'when maintainer is allowed to push to pipeline branch' do
+ context "when maintainer is allowed to push to pipeline branch" do
let(:project) { create(:project, :public) }
let(:owner) { user }
- it 'enables update_build if user is maintainer' do
+ it "enables update_build if user is maintainer" do
allow_any_instance_of(Project).to receive(:empty_repo?).and_return(false)
allow_any_instance_of(Project).to receive(:branch_allows_collaboration?).and_return(true)
@@ -109,131 +109,131 @@ describe Ci::BuildPolicy do
end
end
- describe 'rules for protected ref' do
+ describe "rules for protected ref" do
let(:project) { create(:project, :repository) }
- let(:build) { create(:ci_build, ref: 'some-ref', pipeline: pipeline) }
+ let(:build) { create(:ci_build, ref: "some-ref", pipeline: pipeline) }
before do
project.add_developer(user)
end
- context 'when no one can push or merge to the branch' do
+ context "when no one can push or merge to the branch" do
before do
create(:protected_branch, :no_one_can_push,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'does not include ability to update build' do
+ it "does not include ability to update build" do
expect(policy).to be_disallowed :update_build
end
end
- context 'when developers can push to the branch' do
+ context "when developers can push to the branch" do
before do
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'includes ability to update build' do
+ it "includes ability to update build" do
expect(policy).to be_allowed :update_build
end
end
- context 'when no one can create the tag' do
+ context "when no one can create the tag" do
before do
create(:protected_tag, :no_one_can_create,
- name: build.ref, project: project)
+ name: build.ref, project: project)
build.update(tag: true)
end
- it 'does not include ability to update build' do
+ it "does not include ability to update build" do
expect(policy).to be_disallowed :update_build
end
end
- context 'when no one can create the tag but it is not a tag' do
+ context "when no one can create the tag but it is not a tag" do
before do
create(:protected_tag, :no_one_can_create,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'includes ability to update build' do
+ it "includes ability to update build" do
expect(policy).to be_allowed :update_build
end
end
end
- describe 'rules for erase build' do
+ describe "rules for erase build" do
let(:project) { create(:project, :repository) }
- let(:build) { create(:ci_build, pipeline: pipeline, ref: 'some-ref', user: owner) }
+ let(:build) { create(:ci_build, pipeline: pipeline, ref: "some-ref", user: owner) }
- context 'when a developer erases a build' do
+ context "when a developer erases a build" do
before do
project.add_developer(user)
end
- context 'when developers can push to the branch' do
+ context "when developers can push to the branch" do
before do
create(:protected_branch, :developers_can_push,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- context 'when the build was created by the developer' do
+ context "when the build was created by the developer" do
let(:owner) { user }
it { expect(policy).to be_allowed :erase_build }
end
- context 'when the build was created by the other' do
+ context "when the build was created by the other" do
let(:owner) { create(:user) }
it { expect(policy).to be_disallowed :erase_build }
end
end
- context 'when no one can push or merge to the branch' do
+ context "when no one can push or merge to the branch" do
let(:owner) { user }
before do
create(:protected_branch, :no_one_can_push, :no_one_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
it { expect(policy).to be_disallowed :erase_build }
end
end
- context 'when a maintainer erases a build' do
+ context "when a maintainer erases a build" do
before do
project.add_maintainer(user)
end
- context 'when maintainers can push to the branch' do
+ context "when maintainers can push to the branch" do
before do
create(:protected_branch, :maintainers_can_push,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- context 'when the build was created by the maintainer' do
+ context "when the build was created by the maintainer" do
let(:owner) { user }
it { expect(policy).to be_allowed :erase_build }
end
- context 'when the build was created by the other' do
+ context "when the build was created by the other" do
let(:owner) { create(:user) }
it { expect(policy).to be_allowed :erase_build }
end
end
- context 'when no one can push or merge to the branch' do
+ context "when no one can push or merge to the branch" do
let(:owner) { user }
before do
create(:protected_branch, :no_one_can_push, :no_one_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
it { expect(policy).to be_disallowed :erase_build }
diff --git a/spec/policies/ci/pipeline_policy_spec.rb b/spec/policies/ci/pipeline_policy_spec.rb
index 844d96017de..69cd561748f 100644
--- a/spec/policies/ci/pipeline_policy_spec.rb
+++ b/spec/policies/ci/pipeline_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelinePolicy, :models do
let(:user) { create(:user) }
@@ -8,66 +8,66 @@ describe Ci::PipelinePolicy, :models do
described_class.new(user, pipeline)
end
- describe 'rules' do
- describe 'rules for protected ref' do
+ describe "rules" do
+ describe "rules for protected ref" do
let(:project) { create(:project, :repository) }
before do
project.add_developer(user)
end
- context 'when no one can push or merge to the branch' do
+ context "when no one can push or merge to the branch" do
before do
create(:protected_branch, :no_one_can_push,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- it 'does not include ability to update pipeline' do
+ it "does not include ability to update pipeline" do
expect(policy).to be_disallowed :update_pipeline
end
end
- context 'when developers can push to the branch' do
+ context "when developers can push to the branch" do
before do
create(:protected_branch, :developers_can_merge,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- it 'includes ability to update pipeline' do
+ it "includes ability to update pipeline" do
expect(policy).to be_allowed :update_pipeline
end
end
- context 'when no one can create the tag' do
+ context "when no one can create the tag" do
before do
create(:protected_tag, :no_one_can_create,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
pipeline.update(tag: true)
end
- it 'does not include ability to update pipeline' do
+ it "does not include ability to update pipeline" do
expect(policy).to be_disallowed :update_pipeline
end
end
- context 'when no one can create the tag but it is not a tag' do
+ context "when no one can create the tag but it is not a tag" do
before do
create(:protected_tag, :no_one_can_create,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- it 'includes ability to update pipeline' do
+ it "includes ability to update pipeline" do
expect(policy).to be_allowed :update_pipeline
end
end
end
- context 'when maintainer is allowed to push to pipeline branch' do
+ context "when maintainer is allowed to push to pipeline branch" do
let(:project) { create(:project, :public) }
let(:owner) { user }
- it 'enables update_pipeline if user is maintainer' do
+ it "enables update_pipeline if user is maintainer" do
allow_any_instance_of(Project).to receive(:empty_repo?).and_return(false)
allow_any_instance_of(Project).to receive(:branch_allows_collaboration?).and_return(true)
@@ -75,27 +75,27 @@ describe Ci::PipelinePolicy, :models do
end
end
- context 'when user does not have access to internal CI' do
+ context "when user does not have access to internal CI" do
let(:project) { create(:project, :builds_disabled, :public) }
- it 'disallows the user from reading the pipeline' do
+ it "disallows the user from reading the pipeline" do
expect(policy).to be_disallowed :read_pipeline
end
end
- describe 'destroy_pipeline' do
+ describe "destroy_pipeline" do
let(:project) { create(:project, :public) }
- context 'when user has owner access' do
+ context "when user has owner access" do
let(:user) { project.owner }
- it 'is enabled' do
+ it "is enabled" do
expect(policy).to be_allowed :destroy_pipeline
end
end
- context 'when user is not owner' do
- it 'is disabled' do
+ context "when user is not owner" do
+ it "is disabled" do
expect(policy).not_to be_allowed :destroy_pipeline
end
end
diff --git a/spec/policies/ci/pipeline_schedule_policy_spec.rb b/spec/policies/ci/pipeline_schedule_policy_spec.rb
index 5a56e91cd69..8716e0839c4 100644
--- a/spec/policies/ci/pipeline_schedule_policy_spec.rb
+++ b/spec/policies/ci/pipeline_schedule_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelineSchedulePolicy, :models do
set(:user) { create(:user) }
@@ -9,87 +9,87 @@ describe Ci::PipelineSchedulePolicy, :models do
described_class.new(user, pipeline_schedule)
end
- describe 'rules' do
- describe 'rules for protected ref' do
+ describe "rules" do
+ describe "rules for protected ref" do
before do
project.add_developer(user)
end
- context 'when no one can push or merge to the branch' do
+ context "when no one can push or merge to the branch" do
before do
create(:protected_branch, :no_one_can_push,
- name: pipeline_schedule.ref, project: project)
+ name: pipeline_schedule.ref, project: project)
end
- it 'does not include ability to play pipeline schedule' do
+ it "does not include ability to play pipeline schedule" do
expect(policy).to be_disallowed :play_pipeline_schedule
end
end
- context 'when developers can push to the branch' do
+ context "when developers can push to the branch" do
before do
create(:protected_branch, :developers_can_merge,
- name: pipeline_schedule.ref, project: project)
+ name: pipeline_schedule.ref, project: project)
end
- it 'includes ability to update pipeline' do
+ it "includes ability to update pipeline" do
expect(policy).to be_allowed :play_pipeline_schedule
end
end
- context 'when no one can create the tag' do
- let(:tag) { 'v1.0.0' }
+ context "when no one can create the tag" do
+ let(:tag) { "v1.0.0" }
before do
pipeline_schedule.update(ref: tag)
create(:protected_tag, :no_one_can_create,
- name: pipeline_schedule.ref, project: project)
+ name: pipeline_schedule.ref, project: project)
end
- it 'does not include ability to play pipeline schedule' do
+ it "does not include ability to play pipeline schedule" do
expect(policy).to be_disallowed :play_pipeline_schedule
end
end
- context 'when no one can create the tag but it is not a tag' do
+ context "when no one can create the tag but it is not a tag" do
before do
create(:protected_tag, :no_one_can_create,
- name: pipeline_schedule.ref, project: project)
+ name: pipeline_schedule.ref, project: project)
end
- it 'includes ability to play pipeline schedule' do
+ it "includes ability to play pipeline schedule" do
expect(policy).to be_allowed :play_pipeline_schedule
end
end
end
- describe 'rules for owner of schedule' do
+ describe "rules for owner of schedule" do
before do
project.add_developer(user)
pipeline_schedule.update(owner: user)
end
- it 'includes abilities to do all operations on pipeline schedule' do
+ it "includes abilities to do all operations on pipeline schedule" do
expect(policy).to be_allowed :play_pipeline_schedule
expect(policy).to be_allowed :update_pipeline_schedule
expect(policy).to be_allowed :admin_pipeline_schedule
end
end
- describe 'rules for a maintainer' do
+ describe "rules for a maintainer" do
before do
project.add_maintainer(user)
end
- it 'includes abilities to do all operations on pipeline schedule' do
+ it "includes abilities to do all operations on pipeline schedule" do
expect(policy).to be_allowed :play_pipeline_schedule
expect(policy).to be_allowed :update_pipeline_schedule
expect(policy).to be_allowed :admin_pipeline_schedule
end
end
- describe 'rules for non-owner of schedule' do
+ describe "rules for non-owner of schedule" do
let(:owner) { create(:user) }
before do
@@ -98,7 +98,7 @@ describe Ci::PipelineSchedulePolicy, :models do
pipeline_schedule.update(owner: owner)
end
- it 'includes abilities to take ownership' do
+ it "includes abilities to take ownership" do
expect(policy).to be_allowed :take_ownership_pipeline_schedule
end
end
diff --git a/spec/policies/ci/trigger_policy_spec.rb b/spec/policies/ci/trigger_policy_spec.rb
index d8a63066265..e68f68cddd4 100644
--- a/spec/policies/ci/trigger_policy_spec.rb
+++ b/spec/policies/ci/trigger_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::TriggerPolicy do
let(:user) { create(:user) }
@@ -9,94 +9,94 @@ describe Ci::TriggerPolicy do
described_class.new(user, trigger)
end
- shared_examples 'allows to admin and manage trigger' do
- it 'does include ability to admin trigger' do
+ shared_examples "allows to admin and manage trigger" do
+ it "does include ability to admin trigger" do
expect(policies).to be_allowed :admin_trigger
end
- it 'does include ability to manage trigger' do
+ it "does include ability to manage trigger" do
expect(policies).to be_allowed :manage_trigger
end
end
- shared_examples 'allows to manage trigger' do
- it 'does not include ability to admin trigger' do
+ shared_examples "allows to manage trigger" do
+ it "does not include ability to admin trigger" do
expect(policies).not_to be_allowed :admin_trigger
end
- it 'does include ability to manage trigger' do
+ it "does include ability to manage trigger" do
expect(policies).to be_allowed :manage_trigger
end
end
- shared_examples 'disallows to admin and manage trigger' do
- it 'does not include ability to admin trigger' do
+ shared_examples "disallows to admin and manage trigger" do
+ it "does not include ability to admin trigger" do
expect(policies).not_to be_allowed :admin_trigger
end
- it 'does not include ability to manage trigger' do
+ it "does not include ability to manage trigger" do
expect(policies).not_to be_allowed :manage_trigger
end
end
- describe '#rules' do
- context 'when owner is undefined' do
+ describe "#rules" do
+ context "when owner is undefined" do
let(:owner) { nil }
- context 'when user is maintainer of the project' do
+ context "when user is maintainer of the project" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'allows to admin and manage trigger'
+ it_behaves_like "allows to admin and manage trigger"
end
- context 'when user is developer of the project' do
+ context "when user is developer of the project" do
before do
project.add_developer(user)
end
- it_behaves_like 'disallows to admin and manage trigger'
+ it_behaves_like "disallows to admin and manage trigger"
end
- context 'when user is not member of the project' do
- it_behaves_like 'disallows to admin and manage trigger'
+ context "when user is not member of the project" do
+ it_behaves_like "disallows to admin and manage trigger"
end
end
- context 'when owner is an user' do
+ context "when owner is an user" do
let(:owner) { user }
- context 'when user is maintainer of the project' do
+ context "when user is maintainer of the project" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'allows to admin and manage trigger'
+ it_behaves_like "allows to admin and manage trigger"
end
end
- context 'when owner is another user' do
+ context "when owner is another user" do
let(:owner) { create(:user) }
- context 'when user is maintainer of the project' do
+ context "when user is maintainer of the project" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'allows to manage trigger'
+ it_behaves_like "allows to manage trigger"
end
- context 'when user is developer of the project' do
+ context "when user is developer of the project" do
before do
project.add_developer(user)
end
- it_behaves_like 'disallows to admin and manage trigger'
+ it_behaves_like "disallows to admin and manage trigger"
end
- context 'when user is not member of the project' do
- it_behaves_like 'disallows to admin and manage trigger'
+ context "when user is not member of the project" do
+ it_behaves_like "disallows to admin and manage trigger"
end
end
end
diff --git a/spec/policies/clusters/cluster_policy_spec.rb b/spec/policies/clusters/cluster_policy_spec.rb
index b2f0ca1bc30..5930da861f2 100644
--- a/spec/policies/clusters/cluster_policy_spec.rb
+++ b/spec/policies/clusters/cluster_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::ClusterPolicy, :models do
let(:cluster) { create(:cluster, :project) }
@@ -6,8 +6,8 @@ describe Clusters::ClusterPolicy, :models do
let(:user) { create(:user) }
let(:policy) { described_class.new(user, cluster) }
- describe 'rules' do
- context 'when developer' do
+ describe "rules" do
+ context "when developer" do
before do
project.add_developer(user)
end
@@ -16,7 +16,7 @@ describe Clusters::ClusterPolicy, :models do
it { expect(policy).to be_disallowed :admin_cluster }
end
- context 'when maintainer' do
+ context "when maintainer" do
before do
project.add_maintainer(user)
end
@@ -25,12 +25,12 @@ describe Clusters::ClusterPolicy, :models do
it { expect(policy).to be_allowed :admin_cluster }
end
- context 'group cluster' do
+ context "group cluster" do
let(:cluster) { create(:cluster, :group) }
let(:group) { cluster.group }
let(:project) { create(:project, namespace: group) }
- context 'when group developer' do
+ context "when group developer" do
before do
group.add_developer(user)
end
@@ -39,7 +39,7 @@ describe Clusters::ClusterPolicy, :models do
it { expect(policy).to be_disallowed :admin_cluster }
end
- context 'when group maintainer' do
+ context "when group maintainer" do
before do
group.add_maintainer(user)
end
@@ -48,7 +48,7 @@ describe Clusters::ClusterPolicy, :models do
it { expect(policy).to be_allowed :admin_cluster }
end
- context 'when project maintainer' do
+ context "when project maintainer" do
before do
project.add_maintainer(user)
end
@@ -57,7 +57,7 @@ describe Clusters::ClusterPolicy, :models do
it { expect(policy).to be_disallowed :admin_cluster }
end
- context 'when project developer' do
+ context "when project developer" do
before do
project.add_developer(user)
end
diff --git a/spec/policies/concerns/policy_actor_spec.rb b/spec/policies/concerns/policy_actor_spec.rb
index 27db9710a38..68d8c38755f 100644
--- a/spec/policies/concerns/policy_actor_spec.rb
+++ b/spec/policies/concerns/policy_actor_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe PolicyActor do
- it 'implements all the methods from user' do
+ it "implements all the methods from user" do
methods = subject.instance_methods
# User.instance_methods do not return all methods until an instance is
diff --git a/spec/policies/deploy_key_policy_spec.rb b/spec/policies/deploy_key_policy_spec.rb
index e7263d49613..d81afb37ef3 100644
--- a/spec/policies/deploy_key_policy_spec.rb
+++ b/spec/policies/deploy_key_policy_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployKeyPolicy do
subject { described_class.new(current_user, deploy_key) }
- describe 'updating a deploy_key' do
- context 'when a regular user' do
+ describe "updating a deploy_key" do
+ context "when a regular user" do
let(:current_user) { create(:user) }
- context 'tries to update private deploy key attached to project' do
+ context "tries to update private deploy key attached to project" do
let(:deploy_key) { create(:deploy_key, public: false) }
let(:project) { create(:project_empty_repo) }
@@ -19,7 +19,7 @@ describe DeployKeyPolicy do
it { is_expected.to be_allowed(:update_deploy_key) }
end
- context 'tries to update private deploy key attached to other project' do
+ context "tries to update private deploy key attached to other project" do
let(:deploy_key) { create(:deploy_key, public: false) }
let(:other_project) { create(:project_empty_repo) }
@@ -30,23 +30,23 @@ describe DeployKeyPolicy do
it { is_expected.to be_disallowed(:update_deploy_key) }
end
- context 'tries to update public deploy key' do
+ context "tries to update public deploy key" do
let(:deploy_key) { create(:another_deploy_key, public: true) }
it { is_expected.to be_disallowed(:update_deploy_key) }
end
end
- context 'when an admin user' do
+ context "when an admin user" do
let(:current_user) { create(:user, :admin) }
- context ' tries to update private deploy key' do
+ context " tries to update private deploy key" do
let(:deploy_key) { create(:deploy_key, public: false) }
it { is_expected.to be_allowed(:update_deploy_key) }
end
- context 'when an admin user tries to update public deploy key' do
+ context "when an admin user tries to update public deploy key" do
let(:deploy_key) { create(:another_deploy_key, public: true) }
it { is_expected.to be_allowed(:update_deploy_key) }
diff --git a/spec/policies/deploy_token_policy_spec.rb b/spec/policies/deploy_token_policy_spec.rb
index cef5a4a22bc..0fd444fcaba 100644
--- a/spec/policies/deploy_token_policy_spec.rb
+++ b/spec/policies/deploy_token_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployTokenPolicy do
let(:current_user) { create(:user) }
@@ -7,8 +7,8 @@ describe DeployTokenPolicy do
subject { described_class.new(current_user, deploy_token) }
- describe 'creating a deploy key' do
- context 'when user is maintainer' do
+ describe "creating a deploy key" do
+ context "when user is maintainer" do
before do
project.add_maintainer(current_user)
end
@@ -16,7 +16,7 @@ describe DeployTokenPolicy do
it { is_expected.to be_allowed(:create_deploy_token) }
end
- context 'when user is not maintainer' do
+ context "when user is not maintainer" do
before do
project.add_developer(current_user)
end
@@ -25,8 +25,8 @@ describe DeployTokenPolicy do
end
end
- describe 'updating a deploy key' do
- context 'when user is maintainer' do
+ describe "updating a deploy key" do
+ context "when user is maintainer" do
before do
project.add_maintainer(current_user)
end
@@ -34,7 +34,7 @@ describe DeployTokenPolicy do
it { is_expected.to be_allowed(:update_deploy_token) }
end
- context 'when user is not maintainer' do
+ context "when user is not maintainer" do
before do
project.add_developer(current_user)
end
diff --git a/spec/policies/environment_policy_spec.rb b/spec/policies/environment_policy_spec.rb
index 0442b032e89..c6ea02609eb 100644
--- a/spec/policies/environment_policy_spec.rb
+++ b/spec/policies/environment_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentPolicy do
using RSpec::Parameterized::TableSyntax
@@ -9,9 +9,9 @@ describe EnvironmentPolicy do
described_class.new(user, environment)
end
- describe '#rules' do
- shared_examples 'project permissions' do
- context 'with stop action' do
+ describe "#rules" do
+ shared_examples "project permissions" do
+ context "with stop action" do
let(:environment) do
create(:environment, :with_review_app, project: project)
end
@@ -32,24 +32,24 @@ describe EnvironmentPolicy do
it { expect(policy.allowed?(:stop_environment)).to be allowed? }
end
- context 'when an admin user' do
+ context "when an admin user" do
let(:user) { create(:user, :admin) }
it { expect(policy).to be_allowed :stop_environment }
end
- context 'with protected branch' do
+ context "with protected branch" do
with_them do
before do
project.add_user(user, access_level) unless access_level.nil?
create(:protected_branch, :no_one_can_push,
- name: 'master', project: project)
+ name: "master", project: project)
end
it { expect(policy).to be_disallowed :stop_environment }
end
- context 'when an admin user' do
+ context "when an admin user" do
let(:user) { create(:user, :admin) }
it { expect(policy).to be_allowed :stop_environment }
@@ -57,7 +57,7 @@ describe EnvironmentPolicy do
end
end
- context 'without stop action' do
+ context "without stop action" do
let(:environment) do
create(:environment, project: project)
end
@@ -78,7 +78,7 @@ describe EnvironmentPolicy do
it { expect(policy.allowed?(:stop_environment)).to be allowed? }
end
- context 'when an admin user' do
+ context "when an admin user" do
let(:user) { create(:user, :admin) }
it { expect(policy).to be_allowed :stop_environment }
@@ -86,16 +86,16 @@ describe EnvironmentPolicy do
end
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :public, :repository) }
- include_examples 'project permissions'
+ include_examples "project permissions"
end
- context 'when project is private' do
+ context "when project is private" do
let(:project) { create(:project, :private, :repository) }
- include_examples 'project permissions'
+ include_examples "project permissions"
end
end
end
diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb
index 30d68e7dc9d..c2ba4ad7ebc 100644
--- a/spec/policies/global_policy_spec.rb
+++ b/spec/policies/global_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GlobalPolicy do
include TermsHelper
@@ -77,13 +77,13 @@ describe GlobalPolicy do
end
end
- describe 'custom attributes' do
- context 'regular user' do
+ describe "custom attributes" do
+ context "regular user" do
it { is_expected.not_to be_allowed(:read_custom_attribute) }
it { is_expected.not_to be_allowed(:update_custom_attribute) }
end
- context 'admin' do
+ context "admin" do
let(:current_user) { create(:user, :admin) }
it { is_expected.to be_allowed(:read_custom_attribute) }
@@ -91,7 +91,7 @@ describe GlobalPolicy do
end
end
- shared_examples 'access allowed when terms accepted' do |ability|
+ shared_examples "access allowed when terms accepted" do |ability|
it { is_expected.not_to be_allowed(ability) }
it "allows #{ability} when the user accepted the terms" do
@@ -101,39 +101,39 @@ describe GlobalPolicy do
end
end
- describe 'API access' do
- context 'regular user' do
+ describe "API access" do
+ context "regular user" do
it { is_expected.to be_allowed(:access_api) }
end
- context 'admin' do
+ context "admin" do
let(:current_user) { create(:admin) }
it { is_expected.to be_allowed(:access_api) }
end
- context 'anonymous' do
+ context "anonymous" do
let(:current_user) { nil }
it { is_expected.to be_allowed(:access_api) }
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- context 'regular user' do
- it_behaves_like 'access allowed when terms accepted', :access_api
+ context "regular user" do
+ it_behaves_like "access allowed when terms accepted", :access_api
end
- context 'admin' do
+ context "admin" do
let(:current_user) { create(:admin) }
- it_behaves_like 'access allowed when terms accepted', :access_api
+ it_behaves_like "access allowed when terms accepted", :access_api
end
- context 'anonymous' do
+ context "anonymous" do
let(:current_user) { nil }
it { is_expected.to be_allowed(:access_api) }
@@ -141,39 +141,39 @@ describe GlobalPolicy do
end
end
- describe 'git access' do
- describe 'regular user' do
+ describe "git access" do
+ describe "regular user" do
it { is_expected.to be_allowed(:access_git) }
end
- describe 'admin' do
+ describe "admin" do
let(:current_user) { create(:admin) }
it { is_expected.to be_allowed(:access_git) }
end
- describe 'anonymous' do
+ describe "anonymous" do
let(:current_user) { nil }
it { is_expected.to be_allowed(:access_git) }
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
end
- context 'regular user' do
- it_behaves_like 'access allowed when terms accepted', :access_git
+ context "regular user" do
+ it_behaves_like "access allowed when terms accepted", :access_git
end
- context 'admin' do
+ context "admin" do
let(:current_user) { create(:admin) }
- it_behaves_like 'access allowed when terms accepted', :access_git
+ it_behaves_like "access allowed when terms accepted", :access_git
end
- context 'anonymous' do
+ context "anonymous" do
let(:current_user) { nil }
it { is_expected.to be_allowed(:access_git) }
@@ -181,11 +181,11 @@ describe GlobalPolicy do
end
end
- describe 'read instance statistics' do
- context 'regular user' do
+ describe "read instance statistics" do
+ context "regular user" do
it { is_expected.to be_allowed(:read_instance_statistics) }
- context 'when instance statistics are set to private' do
+ context "when instance statistics are set to private" do
before do
stub_application_setting(instance_statistics_visibility_private: true)
end
@@ -194,12 +194,12 @@ describe GlobalPolicy do
end
end
- context 'admin' do
+ context "admin" do
let(:current_user) { create(:admin) }
it { is_expected.to be_allowed(:read_instance_statistics) }
- context 'when instance statistics are set to private' do
+ context "when instance statistics are set to private" do
before do
stub_application_setting(instance_statistics_visibility_private: true)
end
@@ -208,7 +208,7 @@ describe GlobalPolicy do
end
end
- context 'anonymous' do
+ context "anonymous" do
let(:current_user) { nil }
it { is_expected.not_to be_allowed(:read_instance_statistics) }
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb
index af6d6f084a9..cb49ed61efc 100644
--- a/spec/policies/group_policy_spec.rb
+++ b/spec/policies/group_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupPolicy do
let(:guest) { create(:user) }
@@ -12,7 +12,7 @@ describe GroupPolicy do
let(:guest_permissions) do
[:read_label, :read_group, :upload_file, :read_namespace, :read_group_activity,
:read_group_issues, :read_group_boards, :read_group_labels, :read_group_milestones,
- :read_group_merge_requests]
+ :read_group_merge_requests,]
end
let(:reporter_permissions) { [:admin_label] }
@@ -26,7 +26,7 @@ describe GroupPolicy do
:create_cluster,
:update_cluster,
:admin_cluster,
- :add_cluster
+ :add_cluster,
]
end
@@ -37,7 +37,7 @@ describe GroupPolicy do
:admin_group_member,
:change_visibility_level,
:set_note_created_at,
- (Gitlab::Database.postgresql? ? :create_subgroup : nil)
+ (Gitlab::Database.postgresql? ? :create_subgroup : nil),
].compact
end
@@ -59,7 +59,7 @@ describe GroupPolicy do
permissions.each { |p| is_expected.not_to be_allowed(p) }
end
- context 'with no user' do
+ context "with no user" do
let(:group) { create(:group, :public) }
let(:current_user) { nil }
@@ -74,7 +74,7 @@ describe GroupPolicy do
end
end
- context 'has projects' do
+ context "has projects" do
let(:current_user) { create(:user) }
let(:project) { create(:project, namespace: group) }
@@ -86,7 +86,7 @@ describe GroupPolicy do
expect_allowed(:read_group, :read_list, :read_label)
end
- context 'in subgroups', :nested_groups do
+ context "in subgroups", :nested_groups do
let(:subgroup) { create(:group, :private, parent: group) }
let(:project) { create(:project, namespace: subgroup) }
@@ -96,7 +96,7 @@ describe GroupPolicy do
end
end
- context 'guests' do
+ context "guests" do
let(:current_user) { guest }
it do
@@ -108,7 +108,7 @@ describe GroupPolicy do
end
end
- context 'reporter' do
+ context "reporter" do
let(:current_user) { reporter }
it do
@@ -120,7 +120,7 @@ describe GroupPolicy do
end
end
- context 'developer' do
+ context "developer" do
let(:current_user) { developer }
it do
@@ -132,7 +132,7 @@ describe GroupPolicy do
end
end
- context 'maintainer' do
+ context "maintainer" do
let(:current_user) { maintainer }
it do
@@ -144,7 +144,7 @@ describe GroupPolicy do
end
end
- context 'owner' do
+ context "owner" do
let(:current_user) { owner }
it do
@@ -158,7 +158,7 @@ describe GroupPolicy do
end
end
- context 'admin' do
+ context "admin" do
let(:current_user) { admin }
it do
@@ -172,15 +172,15 @@ describe GroupPolicy do
end
end
- describe 'when nested group support feature is disabled' do
+ describe "when nested group support feature is disabled" do
before do
allow(Group).to receive(:supports_nested_objects?).and_return(false)
end
- context 'admin' do
+ context "admin" do
let(:current_user) { admin }
- it 'allows every owner permission except creating subgroups' do
+ it "allows every owner permission except creating subgroups" do
create_subgroup_permission = [:create_subgroup]
updated_owner_permissions = owner_permissions - create_subgroup_permission
@@ -189,10 +189,10 @@ describe GroupPolicy do
end
end
- context 'owner' do
+ context "owner" do
let(:current_user) { owner }
- it 'allows every owner permission except creating subgroups' do
+ it "allows every owner permission except creating subgroups" do
create_subgroup_permission = [:create_subgroup]
updated_owner_permissions = owner_permissions - create_subgroup_permission
@@ -202,7 +202,7 @@ describe GroupPolicy do
end
end
- describe 'private nested group use the highest access level from the group and inherited permissions', :nested_groups do
+ describe "private nested group use the highest access level from the group and inherited permissions", :nested_groups do
let(:nested_group) { create(:group, :private, parent: group) }
before do
@@ -219,7 +219,7 @@ describe GroupPolicy do
subject { described_class.new(current_user, nested_group) }
- context 'with no user' do
+ context "with no user" do
let(:current_user) { nil }
it do
@@ -231,7 +231,7 @@ describe GroupPolicy do
end
end
- context 'guests' do
+ context "guests" do
let(:current_user) { guest }
it do
@@ -243,7 +243,7 @@ describe GroupPolicy do
end
end
- context 'reporter' do
+ context "reporter" do
let(:current_user) { reporter }
it do
@@ -255,7 +255,7 @@ describe GroupPolicy do
end
end
- context 'developer' do
+ context "developer" do
let(:current_user) { developer }
it do
@@ -267,7 +267,7 @@ describe GroupPolicy do
end
end
- context 'maintainer' do
+ context "maintainer" do
let(:current_user) { maintainer }
it do
@@ -279,7 +279,7 @@ describe GroupPolicy do
end
end
- context 'owner' do
+ context "owner" do
let(:current_user) { owner }
it do
@@ -294,26 +294,26 @@ describe GroupPolicy do
end
end
- describe 'change_share_with_group_lock' do
- context 'when the current_user owns the group' do
+ describe "change_share_with_group_lock" do
+ context "when the current_user owns the group" do
let(:current_user) { owner }
- context 'when the group share_with_group_lock is enabled' do
+ context "when the group share_with_group_lock is enabled" do
let(:group) { create(:group, share_with_group_lock: true, parent: parent) }
- context 'when the parent group share_with_group_lock is enabled' do
- context 'when the group has a grandparent' do
+ context "when the parent group share_with_group_lock is enabled" do
+ context "when the group has a grandparent" do
let(:parent) { create(:group, share_with_group_lock: true, parent: grandparent) }
- context 'when the grandparent share_with_group_lock is enabled' do
+ context "when the grandparent share_with_group_lock is enabled" do
let(:grandparent) { create(:group, share_with_group_lock: true) }
- context 'when the current_user owns the parent' do
+ context "when the current_user owns the parent" do
before do
parent.add_owner(current_user)
end
- context 'when the current_user owns the grandparent' do
+ context "when the current_user owns the grandparent" do
before do
grandparent.add_owner(current_user)
end
@@ -321,20 +321,20 @@ describe GroupPolicy do
it { expect_allowed(:change_share_with_group_lock) }
end
- context 'when the current_user does not own the grandparent' do
+ context "when the current_user does not own the grandparent" do
it { expect_disallowed(:change_share_with_group_lock) }
end
end
- context 'when the current_user does not own the parent' do
+ context "when the current_user does not own the parent" do
it { expect_disallowed(:change_share_with_group_lock) }
end
end
- context 'when the grandparent share_with_group_lock is disabled' do
+ context "when the grandparent share_with_group_lock is disabled" do
let(:grandparent) { create(:group) }
- context 'when the current_user owns the parent' do
+ context "when the current_user owns the parent" do
before do
parent.add_owner(current_user)
end
@@ -342,16 +342,16 @@ describe GroupPolicy do
it { expect_allowed(:change_share_with_group_lock) }
end
- context 'when the current_user does not own the parent' do
+ context "when the current_user does not own the parent" do
it { expect_disallowed(:change_share_with_group_lock) }
end
end
end
- context 'when the group does not have a grandparent' do
+ context "when the group does not have a grandparent" do
let(:parent) { create(:group, share_with_group_lock: true) }
- context 'when the current_user owns the parent' do
+ context "when the current_user owns the parent" do
before do
parent.add_owner(current_user)
end
@@ -359,38 +359,38 @@ describe GroupPolicy do
it { expect_allowed(:change_share_with_group_lock) }
end
- context 'when the current_user does not own the parent' do
+ context "when the current_user does not own the parent" do
it { expect_disallowed(:change_share_with_group_lock) }
end
end
end
- context 'when the parent group share_with_group_lock is disabled' do
+ context "when the parent group share_with_group_lock is disabled" do
let(:parent) { create(:group) }
it { expect_allowed(:change_share_with_group_lock) }
end
end
- context 'when the group share_with_group_lock is disabled' do
+ context "when the group share_with_group_lock is disabled" do
it { expect_allowed(:change_share_with_group_lock) }
end
end
- context 'when the current_user does not own the group' do
+ context "when the current_user does not own the group" do
let(:current_user) { create(:user) }
it { expect_disallowed(:change_share_with_group_lock) }
end
end
- it_behaves_like 'clusterable policies' do
+ it_behaves_like "clusterable policies" do
let(:clusterable) { create(:group) }
let(:cluster) do
create(:cluster,
- :provided_by_gcp,
- :group,
- groups: [clusterable])
+ :provided_by_gcp,
+ :group,
+ groups: [clusterable])
end
end
end
diff --git a/spec/policies/issuable_policy_spec.rb b/spec/policies/issuable_policy_spec.rb
index db3df760472..fbd3b6e40aa 100644
--- a/spec/policies/issuable_policy_spec.rb
+++ b/spec/policies/issuable_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IssuablePolicy, models: true do
let(:user) { create(:user) }
@@ -6,49 +6,49 @@ describe IssuablePolicy, models: true do
let(:issue) { create(:issue, project: project) }
let(:policies) { described_class.new(user, issue) }
- describe '#rules' do
- context 'when user is author of issuable' do
+ describe "#rules" do
+ context "when user is author of issuable" do
let(:merge_request) { create(:merge_request, source_project: project, author: user) }
let(:policies) { described_class.new(user, merge_request) }
- context 'when user is able to read project' do
- it 'enables user to read and update issuables' do
+ context "when user is able to read project" do
+ it "enables user to read and update issuables" do
expect(policies).to be_allowed(:read_issue, :update_issue, :reopen_issue, :read_merge_request, :update_merge_request)
end
end
- context 'when project is private' do
+ context "when project is private" do
let(:project) { create(:project, :private) }
- context 'when user belongs to the projects team' do
- it 'enables user to read and update issuables' do
+ context "when user belongs to the projects team" do
+ it "enables user to read and update issuables" do
project.add_maintainer(user)
expect(policies).to be_allowed(:read_issue, :update_issue, :reopen_issue, :read_merge_request, :update_merge_request)
end
end
- it 'disallows user from reading and updating issuables from that project' do
+ it "disallows user from reading and updating issuables from that project" do
expect(policies).to be_disallowed(:read_issue, :update_issue, :reopen_issue, :read_merge_request, :update_merge_request)
end
end
end
- context 'when discussion is locked for the issuable' do
+ context "when discussion is locked for the issuable" do
let(:issue) { create(:issue, project: project, discussion_locked: true) }
- context 'when the user is not a project member' do
- it 'can not create a note' do
+ context "when the user is not a project member" do
+ it "can not create a note" do
expect(policies).to be_disallowed(:create_note)
end
end
- context 'when the user is a project member' do
+ context "when the user is a project member" do
before do
project.add_guest(user)
end
- it 'can create a note' do
+ it "can create a note" do
expect(policies).to be_allowed(:create_note)
end
end
diff --git a/spec/policies/issue_policy_spec.rb b/spec/policies/issue_policy_spec.rb
index 008d118b557..54a4959c6c2 100644
--- a/spec/policies/issue_policy_spec.rb
+++ b/spec/policies/issue_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IssuePolicy do
let(:guest) { create(:user) }
@@ -12,7 +12,7 @@ describe IssuePolicy do
described_class.new(user, issue)
end
- context 'a private project' do
+ context "a private project" do
let(:non_member) { create(:user) }
let(:project) { create(:project, :private) }
let(:issue) { create(:issue, project: project, assignees: [assignee], author: author) }
@@ -29,12 +29,12 @@ describe IssuePolicy do
create(:project_group_link, group: group, project: project)
end
- it 'does not allow non-members to read issues' do
+ it "does not allow non-members to read issues" do
expect(permissions(non_member, issue)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(non_member, issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows guests to read issues' do
+ it "allows guests to read issues" do
expect(permissions(guest, issue)).to be_allowed(:read_issue, :read_issue_iid)
expect(permissions(guest, issue)).to be_disallowed(:update_issue, :admin_issue)
@@ -42,17 +42,17 @@ describe IssuePolicy do
expect(permissions(guest, issue_no_assignee)).to be_disallowed(:update_issue, :admin_issue)
end
- it 'allows reporters to read, update, and admin issues' do
+ it "allows reporters to read, update, and admin issues" do
expect(permissions(reporter, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter, issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows reporters from group links to read, update, and admin issues' do
+ it "allows reporters from group links to read, update, and admin issues" do
expect(permissions(reporter_from_group_link, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter_from_group_link, issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows issue authors to read and update their issues' do
+ it "allows issue authors to read and update their issues" do
expect(permissions(author, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(author, issue)).to be_disallowed(:admin_issue)
@@ -60,7 +60,7 @@ describe IssuePolicy do
expect(permissions(author, issue_no_assignee)).to be_disallowed(:update_issue, :admin_issue)
end
- it 'allows issue assignees to read and update their issues' do
+ it "allows issue assignees to read and update their issues" do
expect(permissions(assignee, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(assignee, issue)).to be_disallowed(:admin_issue)
@@ -68,38 +68,38 @@ describe IssuePolicy do
expect(permissions(assignee, issue_no_assignee)).to be_disallowed(:update_issue, :admin_issue)
end
- context 'with confidential issues' do
+ context "with confidential issues" do
let(:confidential_issue) { create(:issue, :confidential, project: project, assignees: [assignee], author: author) }
let(:confidential_issue_no_assignee) { create(:issue, :confidential, project: project) }
- it 'does not allow non-members to read confidential issues' do
+ it "does not allow non-members to read confidential issues" do
expect(permissions(non_member, confidential_issue)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(non_member, confidential_issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'does not allow guests to read confidential issues' do
+ it "does not allow guests to read confidential issues" do
expect(permissions(guest, confidential_issue)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(guest, confidential_issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows reporters to read, update, and admin confidential issues' do
+ it "allows reporters to read, update, and admin confidential issues" do
expect(permissions(reporter, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter, confidential_issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows reporters from group links to read, update, and admin confidential issues' do
+ it "allows reporters from group links to read, update, and admin confidential issues" do
expect(permissions(reporter_from_group_link, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter_from_group_link, confidential_issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows issue authors to read and update their confidential issues' do
+ it "allows issue authors to read and update their confidential issues" do
expect(permissions(author, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(author, confidential_issue)).to be_disallowed(:admin_issue)
expect(permissions(author, confidential_issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows issue assignees to read and update their confidential issues' do
+ it "allows issue assignees to read and update their confidential issues" do
expect(permissions(assignee, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(assignee, confidential_issue)).to be_disallowed(:admin_issue)
@@ -108,7 +108,7 @@ describe IssuePolicy do
end
end
- context 'a public project' do
+ context "a public project" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, assignees: [assignee], author: author) }
let(:issue_no_assignee) { create(:issue, project: project) }
@@ -123,7 +123,7 @@ describe IssuePolicy do
create(:project_group_link, group: group, project: project)
end
- it 'allows guests to read issues' do
+ it "allows guests to read issues" do
expect(permissions(guest, issue)).to be_allowed(:read_issue, :read_issue_iid)
expect(permissions(guest, issue)).to be_disallowed(:update_issue, :admin_issue, :reopen_issue)
@@ -134,21 +134,21 @@ describe IssuePolicy do
expect(permissions(guest, issue_locked)).to be_disallowed(:update_issue, :admin_issue, :reopen_issue)
end
- it 'allows reporters to read, update, reopen, and admin issues' do
+ it "allows reporters to read, update, reopen, and admin issues" do
expect(permissions(reporter, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :reopen_issue)
expect(permissions(reporter, issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :reopen_issue)
expect(permissions(reporter, issue_locked)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter, issue_locked)).to be_disallowed(:reopen_issue)
end
- it 'allows reporters from group links to read, update, reopen and admin issues' do
+ it "allows reporters from group links to read, update, reopen and admin issues" do
expect(permissions(reporter_from_group_link, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :reopen_issue)
expect(permissions(reporter_from_group_link, issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue, :reopen_issue)
expect(permissions(reporter_from_group_link, issue_locked)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter_from_group_link, issue_locked)).to be_disallowed(:reopen_issue)
end
- it 'allows issue authors to read, reopen and update their issues' do
+ it "allows issue authors to read, reopen and update their issues" do
expect(permissions(author, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :reopen_issue)
expect(permissions(author, issue)).to be_disallowed(:admin_issue)
@@ -159,7 +159,7 @@ describe IssuePolicy do
expect(permissions(author, issue_locked)).to be_disallowed(:admin_issue, :reopen_issue)
end
- it 'allows issue assignees to read, reopen and update their issues' do
+ it "allows issue assignees to read, reopen and update their issues" do
expect(permissions(assignee, issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :reopen_issue)
expect(permissions(assignee, issue)).to be_disallowed(:admin_issue)
@@ -170,33 +170,33 @@ describe IssuePolicy do
expect(permissions(assignee, issue_locked)).to be_disallowed(:admin_issue, :reopen_issue)
end
- context 'with confidential issues' do
+ context "with confidential issues" do
let(:confidential_issue) { create(:issue, :confidential, project: project, assignees: [assignee], author: author) }
let(:confidential_issue_no_assignee) { create(:issue, :confidential, project: project) }
- it 'does not allow guests to read confidential issues' do
+ it "does not allow guests to read confidential issues" do
expect(permissions(guest, confidential_issue)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(guest, confidential_issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows reporters to read, update, and admin confidential issues' do
+ it "allows reporters to read, update, and admin confidential issues" do
expect(permissions(reporter, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter, confidential_issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows reporter from group links to read, update, and admin confidential issues' do
+ it "allows reporter from group links to read, update, and admin confidential issues" do
expect(permissions(reporter_from_group_link, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
expect(permissions(reporter_from_group_link, confidential_issue_no_assignee)).to be_allowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows issue authors to read and update their confidential issues' do
+ it "allows issue authors to read and update their confidential issues" do
expect(permissions(author, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(author, confidential_issue)).to be_disallowed(:admin_issue)
expect(permissions(author, confidential_issue_no_assignee)).to be_disallowed(:read_issue, :read_issue_iid, :update_issue, :admin_issue)
end
- it 'allows issue assignees to read and update their confidential issues' do
+ it "allows issue assignees to read and update their confidential issues" do
expect(permissions(assignee, confidential_issue)).to be_allowed(:read_issue, :read_issue_iid, :update_issue)
expect(permissions(assignee, confidential_issue)).to be_disallowed(:admin_issue)
diff --git a/spec/policies/namespace_policy_spec.rb b/spec/policies/namespace_policy_spec.rb
index 1fdf95ad716..23e75d91fe7 100644
--- a/spec/policies/namespace_policy_spec.rb
+++ b/spec/policies/namespace_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NamespacePolicy do
let(:user) { create(:user) }
@@ -10,31 +10,31 @@ describe NamespacePolicy do
subject { described_class.new(current_user, namespace) }
- context 'with no user' do
+ context "with no user" do
let(:current_user) { nil }
it { is_expected.to be_banned }
end
- context 'regular user' do
+ context "regular user" do
let(:current_user) { user }
it { is_expected.to be_disallowed(*owner_permissions) }
end
- context 'owner' do
+ context "owner" do
let(:current_user) { owner }
it { is_expected.to be_allowed(*owner_permissions) }
- context 'user who has exceeded project limit' do
+ context "user who has exceeded project limit" do
let(:owner) { create(:user, projects_limit: 0) }
it { is_expected.not_to be_allowed(:create_projects) }
end
end
- context 'admin' do
+ context "admin" do
let(:current_user) { admin }
it { is_expected.to be_allowed(*owner_permissions) }
diff --git a/spec/policies/note_policy_spec.rb b/spec/policies/note_policy_spec.rb
index 0e848c74659..ed9d88d3b9d 100644
--- a/spec/policies/note_policy_spec.rb
+++ b/spec/policies/note_policy_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe NotePolicy, mdoels: true do
- describe '#rules' do
+ describe "#rules" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
@@ -11,20 +11,20 @@ describe NotePolicy, mdoels: true do
noteable ||= issue
note = if noteable.is_a?(Commit)
- create(:note_on_commit, commit_id: noteable.id, author: user, project: project)
- else
- create(:note, noteable: noteable, author: user, project: project)
- end
+ create(:note_on_commit, commit_id: noteable.id, author: user, project: project)
+ else
+ create(:note, noteable: noteable, author: user, project: project)
+ end
@policies = described_class.new(user, note)
end
- shared_examples_for 'a discussion with a private noteable' do
+ shared_examples_for "a discussion with a private noteable" do
let(:noteable) { issue }
let(:policy) { policies(noteable) }
- context 'when the note author can no longer see the noteable' do
- it 'can not edit nor read the note' do
+ context "when the note author can no longer see the noteable" do
+ it "can not edit nor read the note" do
expect(policy).to be_disallowed(:admin_note)
expect(policy).to be_disallowed(:resolve_note)
expect(policy).to be_disallowed(:read_note)
@@ -32,12 +32,12 @@ describe NotePolicy, mdoels: true do
end
end
- context 'when the note author can still see the noteable' do
+ context "when the note author can still see the noteable" do
before do
project.add_developer(user)
end
- it 'can edit the note' do
+ it "can edit the note" do
expect(policy).to be_allowed(:admin_note)
expect(policy).to be_allowed(:resolve_note)
expect(policy).to be_allowed(:read_note)
@@ -46,27 +46,27 @@ describe NotePolicy, mdoels: true do
end
end
- context 'when the project is private' do
+ context "when the project is private" do
let(:project) { create(:project, :private, :repository) }
- context 'when the noteable is a commit' do
- it_behaves_like 'a discussion with a private noteable' do
+ context "when the noteable is a commit" do
+ it_behaves_like "a discussion with a private noteable" do
let(:noteable) { project.repository.head_commit }
end
end
end
- context 'when the project is public' do
- context 'when the note author is not a project member' do
- it 'can edit a note' do
+ context "when the project is public" do
+ context "when the note author is not a project member" do
+ it "can edit a note" do
expect(policies).to be_allowed(:admin_note)
expect(policies).to be_allowed(:resolve_note)
expect(policies).to be_allowed(:read_note)
end
end
- context 'when the noteable is a project snippet' do
- it 'can edit note' do
+ context "when the noteable is a project snippet" do
+ it "can edit note" do
policies = policies(create(:project_snippet, :public, project: project))
expect(policies).to be_allowed(:admin_note)
@@ -74,15 +74,15 @@ describe NotePolicy, mdoels: true do
expect(policies).to be_allowed(:read_note)
end
- context 'when it is private' do
- it_behaves_like 'a discussion with a private noteable' do
+ context "when it is private" do
+ it_behaves_like "a discussion with a private noteable" do
let(:noteable) { create(:project_snippet, :private, project: project) }
end
end
end
- context 'when the noteable is a personal snippet' do
- it 'can edit note' do
+ context "when the noteable is a personal snippet" do
+ it "can edit note" do
policies = policies(create(:personal_snippet, :public))
expect(policies).to be_allowed(:admin_note)
@@ -90,8 +90,8 @@ describe NotePolicy, mdoels: true do
expect(policies).to be_allowed(:read_note)
end
- context 'when it is private' do
- it 'can not edit nor read the note' do
+ context "when it is private" do
+ it "can not edit nor read the note" do
policies = policies(create(:personal_snippet, :private))
expect(policies).to be_disallowed(:admin_note)
@@ -101,38 +101,38 @@ describe NotePolicy, mdoels: true do
end
end
- context 'when a discussion is confidential' do
+ context "when a discussion is confidential" do
before do
issue.update_attribute(:confidential, true)
end
- it_behaves_like 'a discussion with a private noteable'
+ it_behaves_like "a discussion with a private noteable"
end
- context 'when a discussion is locked' do
+ context "when a discussion is locked" do
before do
issue.update_attribute(:discussion_locked, true)
end
- context 'when the note author is a project member' do
+ context "when the note author is a project member" do
before do
project.add_developer(user)
end
- it 'can edit a note' do
+ it "can edit a note" do
expect(policies).to be_allowed(:admin_note)
expect(policies).to be_allowed(:resolve_note)
expect(policies).to be_allowed(:read_note)
end
end
- context 'when the note author is not a project member' do
- it 'can not edit a note' do
+ context "when the note author is not a project member" do
+ it "can not edit a note" do
expect(policies).to be_disallowed(:admin_note)
expect(policies).to be_disallowed(:resolve_note)
end
- it 'can read a note' do
+ it "can read a note" do
expect(policies).to be_allowed(:read_note)
end
end
diff --git a/spec/policies/personal_snippet_policy_spec.rb b/spec/policies/personal_snippet_policy_spec.rb
index a38e0dbd797..1e71d4b94ea 100644
--- a/spec/policies/personal_snippet_policy_spec.rb
+++ b/spec/policies/personal_snippet_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Snippet visibility scenarios are included in more details in spec/support/snippet_visibility.rb
describe PersonalSnippetPolicy do
@@ -10,14 +10,14 @@ describe PersonalSnippetPolicy do
[
:update_personal_snippet,
:admin_personal_snippet,
- :destroy_personal_snippet
+ :destroy_personal_snippet,
]
end
let(:comment_permissions) do
[
:comment_personal_snippet,
- :create_note
+ :create_note,
]
end
@@ -25,10 +25,10 @@ describe PersonalSnippetPolicy do
described_class.new(user, snippet)
end
- context 'public snippet' do
+ context "public snippet" do
let(:snippet) { create(:personal_snippet, :public) }
- context 'no user' do
+ context "no user" do
subject { permissions(nil) }
it do
@@ -39,7 +39,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { permissions(regular_user) }
it do
@@ -50,7 +50,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'author' do
+ context "author" do
subject { permissions(snippet.author) }
it do
@@ -62,10 +62,10 @@ describe PersonalSnippetPolicy do
end
end
- context 'internal snippet' do
+ context "internal snippet" do
let(:snippet) { create(:personal_snippet, :internal) }
- context 'no user' do
+ context "no user" do
subject { permissions(nil) }
it do
@@ -76,7 +76,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { permissions(regular_user) }
it do
@@ -87,7 +87,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'external user' do
+ context "external user" do
subject { permissions(external_user) }
it do
@@ -98,7 +98,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'snippet author' do
+ context "snippet author" do
subject { permissions(snippet.author) }
it do
@@ -110,10 +110,10 @@ describe PersonalSnippetPolicy do
end
end
- context 'private snippet' do
+ context "private snippet" do
let(:snippet) { create(:project_snippet, :private) }
- context 'no user' do
+ context "no user" do
subject { permissions(nil) }
it do
@@ -124,7 +124,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { permissions(regular_user) }
it do
@@ -135,7 +135,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'admin user' do
+ context "admin user" do
subject { permissions(admin_user) }
it do
@@ -146,7 +146,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'external user' do
+ context "external user" do
subject { permissions(external_user) }
it do
@@ -157,7 +157,7 @@ describe PersonalSnippetPolicy do
end
end
- context 'snippet author' do
+ context "snippet author" do
subject { permissions(snippet.author) }
it do
diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb
index 997bdc82af6..e56eb6a2cb5 100644
--- a/spec/policies/project_policy_spec.rb
+++ b/spec/policies/project_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectPolicy do
set(:guest) { create(:user) }
@@ -93,7 +93,7 @@ describe ProjectPolicy do
permissions.each { |p| is_expected.not_to be_allowed(p) }
end
- it 'does not include the read_issue permission when the issue author is not a member of the private project' do
+ it "does not include the read_issue permission when the issue author is not a member of the private project" do
project = create(:project, :private)
issue = create(:issue, project: project, author: create(:user))
user = issue.author
@@ -103,22 +103,22 @@ describe ProjectPolicy do
expect(Ability).not_to be_allowed(user, :read_issue, project)
end
- context 'wiki feature' do
- let(:permissions) { %i(read_wiki create_wiki update_wiki admin_wiki download_wiki_code) }
+ context "wiki feature" do
+ let(:permissions) { %i[read_wiki create_wiki update_wiki admin_wiki download_wiki_code] }
subject { described_class.new(owner, project) }
- context 'when the feature is disabled' do
+ context "when the feature is disabled" do
before do
project.project_feature.update_attribute(:wiki_access_level, ProjectFeature::DISABLED)
end
- it 'does not include the wiki permissions' do
+ it "does not include the wiki permissions" do
expect_disallowed(*permissions)
end
- context 'when there is an external wiki' do
- it 'does not include the wiki permissions' do
+ context "when there is an external wiki" do
+ it "does not include the wiki permissions" do
allow(project).to receive(:has_external_wiki?).and_return(true)
expect_disallowed(*permissions)
@@ -127,11 +127,11 @@ describe ProjectPolicy do
end
end
- context 'issues feature' do
+ context "issues feature" do
subject { described_class.new(owner, project) }
- context 'when the feature is disabled' do
- it 'does not include the issues permissions' do
+ context "when the feature is disabled" do
+ it "does not include the issues permissions" do
project.issues_enabled = false
project.save!
@@ -139,8 +139,8 @@ describe ProjectPolicy do
end
end
- context 'when the feature is disabled and external tracker configured' do
- it 'does not include the issues permissions' do
+ context "when the feature is disabled and external tracker configured" do
+ it "does not include the issues permissions" do
create(:jira_service, project: project)
project.issues_enabled = false
@@ -151,62 +151,62 @@ describe ProjectPolicy do
end
end
- context 'merge requests feature' do
+ context "merge requests feature" do
subject { described_class.new(owner, project) }
- it 'disallows all permissions when the feature is disabled' do
+ it "disallows all permissions when the feature is disabled" do
project.project_feature.update(merge_requests_access_level: ProjectFeature::DISABLED)
mr_permissions = [:create_merge_request_from, :read_merge_request,
:update_merge_request, :admin_merge_request,
- :create_merge_request_in]
+ :create_merge_request_in,]
expect_disallowed(*mr_permissions)
end
end
- context 'for a guest in a private project' do
+ context "for a guest in a private project" do
let(:project) { create(:project, :private) }
subject { described_class.new(guest, project) }
- it 'disallows the guest from reading the merge request and merge request iid' do
+ it "disallows the guest from reading the merge request and merge request iid" do
expect_disallowed(:read_merge_request)
expect_disallowed(:read_merge_request_iid)
end
end
- context 'builds feature' do
- context 'when builds are disabled' do
+ context "builds feature" do
+ context "when builds are disabled" do
subject { described_class.new(owner, project) }
before do
project.project_feature.update(builds_access_level: ProjectFeature::DISABLED)
end
- it 'disallows all permissions except pipeline when the feature is disabled' do
+ it "disallows all permissions except pipeline when the feature is disabled" do
builds_permissions = [
:create_build, :read_build, :update_build, :admin_build, :destroy_build,
:create_pipeline_schedule, :read_pipeline_schedule, :update_pipeline_schedule, :admin_pipeline_schedule, :destroy_pipeline_schedule,
:create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment,
:create_cluster, :read_cluster, :update_cluster, :admin_cluster, :destroy_cluster,
- :create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment
+ :create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment,
]
expect_disallowed(*builds_permissions)
end
end
- context 'when builds are disabled only for some users' do
+ context "when builds are disabled only for some users" do
subject { described_class.new(guest, project) }
before do
project.project_feature.update(builds_access_level: ProjectFeature::PRIVATE)
end
- it 'disallows pipeline and commit_status permissions' do
+ it "disallows pipeline and commit_status permissions" do
builds_permissions = [
:create_pipeline, :update_pipeline, :admin_pipeline, :destroy_pipeline,
- :create_commit_status, :update_commit_status, :admin_commit_status, :destroy_commit_status
+ :create_commit_status, :update_commit_status, :admin_commit_status, :destroy_commit_status,
]
expect_disallowed(*builds_permissions)
@@ -214,10 +214,10 @@ describe ProjectPolicy do
end
end
- context 'repository feature' do
+ context "repository feature" do
subject { described_class.new(owner, project) }
- it 'disallows all permissions when the feature is disabled' do
+ it "disallows all permissions when the feature is disabled" do
project.project_feature.update(repository_access_level: ProjectFeature::DISABLED)
repository_permissions = [
@@ -227,14 +227,14 @@ describe ProjectPolicy do
:create_environment, :read_environment, :update_environment, :admin_environment, :destroy_environment,
:create_cluster, :read_cluster, :update_cluster, :admin_cluster,
:create_deployment, :read_deployment, :update_deployment, :admin_deployment, :destroy_deployment,
- :destroy_release
+ :destroy_release,
]
expect_disallowed(*repository_permissions)
end
end
- shared_examples 'archived project policies' do
+ shared_examples "archived project policies" do
let(:feature_write_abilities) do
described_class::READONLY_FEATURES_WHEN_ARCHIVED.flat_map do |feature|
described_class.create_update_admin_destroy(feature)
@@ -254,28 +254,28 @@ describe ProjectPolicy do
]
end
- context 'when the project is archived' do
+ context "when the project is archived" do
before do
project.archived = true
end
- it 'disables write actions on all relevant project features' do
+ it "disables write actions on all relevant project features" do
expect_disallowed(*feature_write_abilities)
end
- it 'disables some other important write actions' do
+ it "disables some other important write actions" do
expect_disallowed(*other_write_abilities)
end
- it 'does not disable other abilities' do
+ it "does not disable other abilities" do
expect_allowed(*(regular_abilities - feature_write_abilities - other_write_abilities))
end
end
end
- shared_examples 'project policies as anonymous' do
- context 'abilities for public projects' do
- context 'when a project has pending invites' do
+ shared_examples "project policies as anonymous" do
+ context "abilities for public projects" do
+ context "when a project has pending invites" do
let(:group) { create(:group, :public) }
let(:project) { create(:project, :public, namespace: group) }
let(:user_permissions) { [:create_merge_request_in, :create_project, :create_issue, :create_note, :upload_file, :award_emoji] }
@@ -287,18 +287,18 @@ describe ProjectPolicy do
create(:group_member, :invited, group: group)
end
- it 'does not grant owner access' do
+ it "does not grant owner access" do
expect_allowed(*anonymous_permissions)
expect_disallowed(*user_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { anonymous_permissions }
end
end
end
- context 'abilities for non-public projects' do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(nil, project) }
@@ -307,10 +307,10 @@ describe ProjectPolicy do
end
end
- shared_examples 'project policies as guest' do
+ shared_examples "project policies as guest" do
subject { described_class.new(guest, project) }
- context 'abilities for non-public projects' do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
let(:reporter_public_build_permissions) do
reporter_permissions - [:read_build, :read_pipeline]
@@ -325,18 +325,18 @@ describe ProjectPolicy do
expect_disallowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { guest_permissions }
end
- context 'public builds enabled' do
+ context "public builds enabled" do
it do
expect_allowed(*guest_permissions)
expect_allowed(:read_build, :read_pipeline)
end
end
- context 'when public builds disabled' do
+ context "when public builds disabled" do
before do
project.update(public_builds: false)
end
@@ -347,7 +347,7 @@ describe ProjectPolicy do
end
end
- context 'when builds are disabled' do
+ context "when builds are disabled" do
before do
project.project_feature.update(builds_access_level: ProjectFeature::DISABLED)
end
@@ -360,8 +360,8 @@ describe ProjectPolicy do
end
end
- shared_examples 'project policies as reporter' do
- context 'abilities for non-public projects' do
+ shared_examples "project policies as reporter" do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(reporter, project) }
@@ -375,14 +375,14 @@ describe ProjectPolicy do
expect_disallowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { reporter_permissions }
end
end
end
- shared_examples 'project policies as developer' do
- context 'abilities for non-public projects' do
+ shared_examples "project policies as developer" do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(developer, project) }
@@ -396,14 +396,14 @@ describe ProjectPolicy do
expect_disallowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { developer_permissions }
end
end
end
- shared_examples 'project policies as maintainer' do
- context 'abilities for non-public projects' do
+ shared_examples "project policies as maintainer" do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(maintainer, project) }
@@ -417,14 +417,14 @@ describe ProjectPolicy do
expect_disallowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { maintainer_permissions }
end
end
end
- shared_examples 'project policies as owner' do
- context 'abilities for non-public projects' do
+ shared_examples "project policies as owner" do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(owner, project) }
@@ -438,14 +438,14 @@ describe ProjectPolicy do
expect_allowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { owner_permissions }
end
end
end
- shared_examples 'project policies as admin' do
- context 'abilities for non-public projects' do
+ shared_examples "project policies as admin" do
+ context "abilities for non-public projects" do
let(:project) { create(:project, namespace: owner.namespace) }
subject { described_class.new(admin, project) }
@@ -459,21 +459,21 @@ describe ProjectPolicy do
expect_allowed(*owner_permissions)
end
- it_behaves_like 'archived project policies' do
+ it_behaves_like "archived project policies" do
let(:regular_abilities) { owner_permissions }
end
end
end
- it_behaves_like 'project policies as anonymous'
- it_behaves_like 'project policies as guest'
- it_behaves_like 'project policies as reporter'
- it_behaves_like 'project policies as developer'
- it_behaves_like 'project policies as maintainer'
- it_behaves_like 'project policies as owner'
- it_behaves_like 'project policies as admin'
+ it_behaves_like "project policies as anonymous"
+ it_behaves_like "project policies as guest"
+ it_behaves_like "project policies as reporter"
+ it_behaves_like "project policies as developer"
+ it_behaves_like "project policies as maintainer"
+ it_behaves_like "project policies as owner"
+ it_behaves_like "project policies as admin"
- context 'when a public project has merge requests allowing access' do
+ context "when a public project has merge requests allowing access" do
include ProjectForksHelper
let(:user) { create(:user) }
let(:target_project) { create(:project, :public) }
@@ -487,22 +487,22 @@ describe ProjectPolicy do
)
end
let(:maintainer_abilities) do
- %w(create_build create_pipeline)
+ %w[create_build create_pipeline]
end
subject { described_class.new(user, project) }
- it 'does not allow pushing code' do
+ it "does not allow pushing code" do
expect_disallowed(*maintainer_abilities)
end
- it 'allows pushing if the user is a member with push access to the target project' do
+ it "allows pushing if the user is a member with push access to the target project" do
target_project.add_developer(user)
expect_allowed(*maintainer_abilities)
end
- it 'dissallows abilities to a maintainer if the merge request was closed' do
+ it "dissallows abilities to a maintainer if the merge request was closed" do
target_project.add_developer(user)
merge_request.close!
@@ -510,13 +510,13 @@ describe ProjectPolicy do
end
end
- it_behaves_like 'clusterable policies' do
+ it_behaves_like "clusterable policies" do
let(:clusterable) { create(:project, :repository) }
let(:cluster) do
create(:cluster,
- :provided_by_gcp,
- :project,
- projects: [clusterable])
+ :provided_by_gcp,
+ :project,
+ projects: [clusterable])
end
end
end
diff --git a/spec/policies/project_snippet_policy_spec.rb b/spec/policies/project_snippet_policy_spec.rb
index d6329e84579..d0e32ea6f75 100644
--- a/spec/policies/project_snippet_policy_spec.rb
+++ b/spec/policies/project_snippet_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Snippet visibility scenarios are included in more details in spec/support/snippet_visibility.rb
describe ProjectSnippetPolicy do
@@ -9,7 +9,7 @@ describe ProjectSnippetPolicy do
let(:author_permissions) do
[
:update_project_snippet,
- :admin_project_snippet
+ :admin_project_snippet,
]
end
@@ -27,8 +27,8 @@ describe ProjectSnippetPolicy do
permissions.each { |p| is_expected.not_to be_allowed(p) }
end
- context 'public snippet' do
- context 'no user' do
+ context "public snippet" do
+ context "no user" do
subject { abilities(nil, :public) }
it do
@@ -37,7 +37,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { abilities(regular_user, :public) }
it do
@@ -46,7 +46,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'external user' do
+ context "external user" do
subject { abilities(external_user, :public) }
it do
@@ -56,8 +56,8 @@ describe ProjectSnippetPolicy do
end
end
- context 'internal snippet' do
- context 'no user' do
+ context "internal snippet" do
+ context "no user" do
subject { abilities(nil, :internal) }
it do
@@ -66,7 +66,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { abilities(regular_user, :internal) }
it do
@@ -75,7 +75,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'external user' do
+ context "external user" do
subject { abilities(external_user, :internal) }
it do
@@ -84,7 +84,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'project team member external user' do
+ context "project team member external user" do
subject { abilities(external_user, :internal) }
before do
@@ -98,8 +98,8 @@ describe ProjectSnippetPolicy do
end
end
- context 'private snippet' do
- context 'no user' do
+ context "private snippet" do
+ context "no user" do
subject { abilities(nil, :private) }
it do
@@ -108,7 +108,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'regular user' do
+ context "regular user" do
subject { abilities(regular_user, :private) }
it do
@@ -117,7 +117,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'snippet author' do
+ context "snippet author" do
let(:snippet) { create(:project_snippet, :private, author: regular_user, project: project) }
subject { described_class.new(regular_user, snippet) }
@@ -128,7 +128,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'project team member normal user' do
+ context "project team member normal user" do
subject { abilities(regular_user, :private) }
before do
@@ -141,7 +141,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'project team member external user' do
+ context "project team member external user" do
subject { abilities(external_user, :private) }
before do
@@ -154,7 +154,7 @@ describe ProjectSnippetPolicy do
end
end
- context 'admin user' do
+ context "admin user" do
subject { abilities(create(:admin), :private) }
it do
diff --git a/spec/policies/protected_branch_policy_spec.rb b/spec/policies/protected_branch_policy_spec.rb
index 1587196754d..ae62c4e5fae 100644
--- a/spec/policies/protected_branch_policy_spec.rb
+++ b/spec/policies/protected_branch_policy_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranchPolicy do
let(:user) { create(:user) }
- let(:name) { 'feature' }
+ let(:name) { "feature" }
let(:protected_branch) { create(:protected_branch, name: name) }
let(:project) { protected_branch.project }
subject { described_class.new(user, protected_branch) }
- it 'branches can be updated via project maintainers' do
+ it "branches can be updated via project maintainers" do
project.add_maintainer(user)
is_expected.to be_allowed(:update_protected_branch)
diff --git a/spec/policies/user_policy_spec.rb b/spec/policies/user_policy_spec.rb
index 7e0a1824200..b85f4e35f86 100644
--- a/spec/policies/user_policy_spec.rb
+++ b/spec/policies/user_policy_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UserPolicy do
let(:current_user) { create(:user) }
@@ -10,7 +10,7 @@ describe UserPolicy do
it { is_expected.to be_allowed(:read_user) }
end
- shared_examples 'changing a user' do |ability|
+ shared_examples "changing a user" do |ability|
context "when a regular user tries to destroy another regular user" do
it { is_expected.not_to be_allowed(ability) }
end
@@ -36,14 +36,14 @@ describe UserPolicy do
end
describe "updating a user's status" do
- it_behaves_like 'changing a user', :update_user_status
+ it_behaves_like "changing a user", :update_user_status
end
describe "destroying a user" do
- it_behaves_like 'changing a user', :destroy_user
+ it_behaves_like "changing a user", :destroy_user
end
describe "updating a user" do
- it_behaves_like 'changing a user', :update_user
+ it_behaves_like "changing a user", :update_user
end
end
diff --git a/spec/presenters/blob_presenter_spec.rb b/spec/presenters/blob_presenter_spec.rb
index bb1db9a3d51..cbaf99482a1 100644
--- a/spec/presenters/blob_presenter_spec.rb
+++ b/spec/presenters/blob_presenter_spec.rb
@@ -1,41 +1,41 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe BlobPresenter, :seed_helper do
- let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH, '', 'group/project') }
+ let(:repository) { Gitlab::Git::Repository.new("default", TEST_REPO_PATH, "", "group/project") }
let(:git_blob) do
Gitlab::Git::Blob.find(
repository,
- 'fa1b1e6c004a68b7d8763b86455da9e6b23e36d6',
- 'files/ruby/regex.rb'
+ "fa1b1e6c004a68b7d8763b86455da9e6b23e36d6",
+ "files/ruby/regex.rb"
)
end
let(:blob) { Blob.new(git_blob) }
- describe '#highlight' do
+ describe "#highlight" do
subject { described_class.new(blob) }
- it 'returns highlighted content' do
- expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', git_blob.data, plain: nil, language: nil)
+ it "returns highlighted content" do
+ expect(Gitlab::Highlight).to receive(:highlight).with("files/ruby/regex.rb", git_blob.data, plain: nil, language: nil)
subject.highlight
end
- it 'returns plain content when :plain is true' do
- expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', git_blob.data, plain: true, language: nil)
+ it "returns plain content when :plain is true" do
+ expect(Gitlab::Highlight).to receive(:highlight).with("files/ruby/regex.rb", git_blob.data, plain: true, language: nil)
subject.highlight(plain: true)
end
- context 'gitlab-language contains a match' do
+ context "gitlab-language contains a match" do
before do
- allow(blob).to receive(:language_from_gitattributes).and_return('ruby')
+ allow(blob).to receive(:language_from_gitattributes).and_return("ruby")
end
- it 'passes language to inner call' do
- expect(Gitlab::Highlight).to receive(:highlight).with('files/ruby/regex.rb', git_blob.data, plain: nil, language: 'ruby')
+ it "passes language to inner call" do
+ expect(Gitlab::Highlight).to receive(:highlight).with("files/ruby/regex.rb", git_blob.data, plain: nil, language: "ruby")
subject.highlight
end
diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb
index 676835b3880..c82f623f3a1 100644
--- a/spec/presenters/ci/build_presenter_spec.rb
+++ b/spec/presenters/ci/build_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildPresenter do
let(:project) { create(:project) }
@@ -9,208 +9,208 @@ describe Ci::BuildPresenter do
described_class.new(build)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.ancestors).to include(Gitlab::View::Presenter::Delegated)
end
- describe '#initialize' do
- it 'takes a build and optional params' do
+ describe "#initialize" do
+ it "takes a build and optional params" do
expect { presenter }.not_to raise_error
end
- it 'exposes build' do
+ it "exposes build" do
expect(presenter.build).to eq(build)
end
- it 'forwards missing methods to build' do
- expect(presenter.ref).to eq('master')
+ it "forwards missing methods to build" do
+ expect(presenter.ref).to eq("master")
end
end
- describe '#erased_by_user?' do
- it 'takes a build and optional params' do
+ describe "#erased_by_user?" do
+ it "takes a build and optional params" do
expect(presenter).not_to be_erased_by_user
end
end
- describe '#erased_by_name' do
- context 'when build is not erased' do
+ describe "#erased_by_name" do
+ context "when build is not erased" do
before do
expect(presenter).to receive(:erased_by_user?).and_return(false)
end
- it 'returns nil' do
+ it "returns nil" do
expect(presenter.erased_by_name).to be_nil
end
end
- context 'when build is erased' do
+ context "when build is erased" do
before do
expect(presenter).to receive(:erased_by_user?).and_return(true)
expect(build).to receive(:erased_by)
- .and_return(double(:user, name: 'John Doe'))
+ .and_return(double(:user, name: "John Doe"))
end
- it 'returns the name of the eraser' do
- expect(presenter.erased_by_name).to eq('John Doe')
+ it "returns the name of the eraser" do
+ expect(presenter.erased_by_name).to eq("John Doe")
end
end
end
- describe '#status_title' do
- context 'when build is auto-canceled' do
+ describe "#status_title" do
+ context "when build is auto-canceled" do
before do
expect(build).to receive(:auto_canceled?).and_return(true)
expect(build).to receive(:auto_canceled_by_id).and_return(1)
end
- it 'shows that the build is auto-canceled' do
+ it "shows that the build is auto-canceled" do
status_title = presenter.status_title
- expect(status_title).to include('auto-canceled')
- expect(status_title).to include('Pipeline #1')
+ expect(status_title).to include("auto-canceled")
+ expect(status_title).to include("Pipeline #1")
end
end
- context 'when build failed' do
+ context "when build failed" do
let(:build) { create(:ci_build, :failed, pipeline: pipeline) }
- it 'returns the reason of failure' do
+ it "returns the reason of failure" do
status_title = presenter.status_title
- expect(status_title).to eq('Failed - (unknown failure)')
+ expect(status_title).to eq("Failed - (unknown failure)")
end
end
- context 'when build has failed && retried' do
+ context "when build has failed && retried" do
let(:build) { create(:ci_build, :failed, :retried, pipeline: pipeline) }
- it 'does not include retried title' do
+ it "does not include retried title" do
status_title = presenter.status_title
- expect(status_title).not_to include('(retried)')
- expect(status_title).to eq('Failed - (unknown failure)')
+ expect(status_title).not_to include("(retried)")
+ expect(status_title).to eq("Failed - (unknown failure)")
end
end
- context 'when build has failed and is allowed to' do
+ context "when build has failed and is allowed to" do
let(:build) { create(:ci_build, :failed, :allowed_to_fail, pipeline: pipeline) }
- it 'returns the reason of failure' do
+ it "returns the reason of failure" do
status_title = presenter.status_title
- expect(status_title).to eq('Failed - (unknown failure)')
+ expect(status_title).to eq("Failed - (unknown failure)")
end
end
- context 'For any other build' do
+ context "For any other build" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
- it 'returns the status' do
+ it "returns the status" do
tooltip_description = presenter.status_title
- expect(tooltip_description).to eq('Success')
+ expect(tooltip_description).to eq("Success")
end
end
end
- describe 'quack like a Ci::Build permission-wise' do
- context 'user is not allowed' do
+ describe "quack like a Ci::Build permission-wise" do
+ context "user is not allowed" do
let(:project) { create(:project, public_builds: false) }
- it 'returns false' do
+ it "returns false" do
expect(presenter.can?(nil, :read_build)).to be_falsy
end
end
- context 'user is allowed' do
+ context "user is allowed" do
let(:project) { create(:project, :public) }
- it 'returns true' do
+ it "returns true" do
expect(presenter.can?(nil, :read_build)).to be_truthy
end
end
end
- describe '#trigger_variables' do
+ describe "#trigger_variables" do
let(:build) { create(:ci_build, pipeline: pipeline, trigger_request: trigger_request) }
let(:trigger) { create(:ci_trigger, project: project) }
let(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, trigger: trigger) }
- context 'when variable is stored in ci_pipeline_variables' do
+ context "when variable is stored in ci_pipeline_variables" do
let!(:pipeline_variable) { create(:ci_pipeline_variable, pipeline: pipeline) }
- context 'when pipeline is triggered by trigger API' do
- it 'returns variables' do
+ context "when pipeline is triggered by trigger API" do
+ it "returns variables" do
expect(presenter.trigger_variables).to eq([pipeline_variable.to_runner_variable])
end
end
- context 'when pipeline is not triggered by trigger API' do
+ context "when pipeline is not triggered by trigger API" do
let(:build) { create(:ci_build, pipeline: pipeline) }
- it 'does not return variables' do
+ it "does not return variables" do
expect(presenter.trigger_variables).to eq([])
end
end
end
- context 'when variable is stored in ci_trigger_requests.variables' do
+ context "when variable is stored in ci_trigger_requests.variables" do
before do
- trigger_request.update_attribute(:variables, { 'TRIGGER_KEY_1' => 'TRIGGER_VALUE_1' } )
+ trigger_request.update_attribute(:variables, {"TRIGGER_KEY_1" => "TRIGGER_VALUE_1"})
end
- it 'returns variables' do
+ it "returns variables" do
expect(presenter.trigger_variables).to eq(trigger_request.user_variables)
end
end
end
- describe '#tooltip_message' do
- context 'When build has failed' do
+ describe "#tooltip_message" do
+ context "When build has failed" do
let(:build) { create(:ci_build, :script_failure, pipeline: pipeline) }
- it 'returns the reason of failure' do
+ it "returns the reason of failure" do
tooltip = subject.tooltip_message
expect(tooltip).to eq("#{build.name} - failed - (script failure)")
end
end
- context 'When build has failed and retried' do
+ context "When build has failed and retried" do
let(:build) { create(:ci_build, :script_failure, :retried, pipeline: pipeline) }
- it 'should include the reason of failure and the retried title' do
+ it "should include the reason of failure and the retried title" do
tooltip = subject.tooltip_message
expect(tooltip).to eq("#{build.name} - failed - (script failure) (retried)")
end
end
- context 'When build has failed and is allowed to' do
+ context "When build has failed and is allowed to" do
let(:build) { create(:ci_build, :script_failure, :allowed_to_fail, pipeline: pipeline) }
- it 'should include the reason of failure' do
+ it "should include the reason of failure" do
tooltip = subject.tooltip_message
expect(tooltip).to eq("#{build.name} - failed - (script failure) (allowed to fail)")
end
end
- context 'For any other build (no retried)' do
+ context "For any other build (no retried)" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
- it 'should include build name and status' do
+ it "should include build name and status" do
tooltip = subject.tooltip_message
expect(tooltip).to eq("#{build.name} - passed")
end
end
- context 'For any other build (retried)' do
+ context "For any other build (retried)" do
let(:build) { create(:ci_build, :success, :retried, pipeline: pipeline) }
- it 'should include build name and status' do
+ it "should include build name and status" do
tooltip = subject.tooltip_message
expect(tooltip).to eq("#{build.name} - passed (retried)")
@@ -218,24 +218,24 @@ describe Ci::BuildPresenter do
end
end
- describe '#execute_in' do
+ describe "#execute_in" do
subject { presenter.execute_in }
- context 'when build is scheduled' do
- context 'when schedule is not expired' do
+ context "when build is scheduled" do
+ context "when schedule is not expired" do
let(:build) { create(:ci_build, :scheduled) }
- it 'returns execution time' do
+ it "returns execution time" do
Timecop.freeze do
is_expected.to be_like_time(60.0)
end
end
end
- context 'when schedule is expired' do
+ context "when schedule is expired" do
let(:build) { create(:ci_build, :expired_scheduled) }
- it 'returns execution time' do
+ it "returns execution time" do
Timecop.freeze do
is_expected.to eq(0)
end
@@ -243,10 +243,10 @@ describe Ci::BuildPresenter do
end
end
- context 'when build is not delayed' do
+ context "when build is not delayed" do
let(:build) { create(:ci_build) }
- it 'does not return execution time' do
+ it "does not return execution time" do
Timecop.freeze do
is_expected.to be_falsy
end
@@ -254,22 +254,22 @@ describe Ci::BuildPresenter do
end
end
- describe '#callout_failure_message' do
+ describe "#callout_failure_message" do
let(:build) { create(:ci_build, :failed, :api_failure) }
- it 'returns a verbose failure reason' do
+ it "returns a verbose failure reason" do
description = subject.callout_failure_message
- expect(description).to eq('There has been an API failure, please try again')
+ expect(description).to eq("There has been an API failure, please try again")
end
end
- describe '#recoverable?' do
+ describe "#recoverable?" do
let(:build) { create(:ci_build, :failed, :script_failure) }
- context 'when is a script or missing dependency failure' do
- let(:failure_reasons) { %w(script_failure missing_dependency_failure archived_failure) }
+ context "when is a script or missing dependency failure" do
+ let(:failure_reasons) { %w[script_failure missing_dependency_failure archived_failure] }
- it 'should return false' do
+ it "should return false" do
failure_reasons.each do |failure_reason|
build.update_attribute(:failure_reason, failure_reason)
expect(presenter.recoverable?).to be_falsy
@@ -277,10 +277,10 @@ describe Ci::BuildPresenter do
end
end
- context 'when is any other failure type' do
- let(:failure_reasons) { %w(unknown_failure api_failure stuck_or_timeout_failure runner_system_failure) }
+ context "when is any other failure type" do
+ let(:failure_reasons) { %w[unknown_failure api_failure stuck_or_timeout_failure runner_system_failure] }
- it 'should return true' do
+ it "should return true" do
failure_reasons.each do |failure_reason|
build.update_attribute(:failure_reason, failure_reason)
expect(presenter.recoverable?).to be_truthy
diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb
index f50bcf54b46..5a64d1d1e2d 100644
--- a/spec/presenters/ci/build_runner_presenter_spec.rb
+++ b/spec/presenters/ci/build_runner_presenter_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildRunnerPresenter do
let(:presenter) { described_class.new(build) }
- let(:archive) { { paths: ['sample.txt'] } }
+ let(:archive) { {paths: ["sample.txt"]} }
let(:archive_expectation) do
{
artifact_type: :archive,
artifact_format: :zip,
paths: archive[:paths],
- untracked: archive[:untracked]
+ untracked: archive[:untracked],
}
end
- describe '#artifacts' do
+ describe "#artifacts" do
context "when option contains archive-type artifacts" do
- let(:build) { create(:ci_build, options: { artifacts: archive } ) }
+ let(:build) { create(:ci_build, options: {artifacts: archive}) }
- it 'presents correct hash' do
+ it "presents correct hash" do
expect(presenter.artifacts.first).to include(archive_expectation)
end
context "when untracked is specified" do
- let(:archive) { { untracked: true } }
+ let(:archive) { {untracked: true} }
- it 'presents correct hash' do
+ it "presents correct hash" do
expect(presenter.artifacts.first).to include(archive_expectation)
end
end
context "when untracked and paths are missing" do
- let(:archive) { { when: 'always' } }
+ let(:archive) { {when: "always"} }
- it 'does not present hash' do
+ it "does not present hash" do
expect(presenter.artifacts).to be_empty
end
end
@@ -41,8 +41,8 @@ describe Ci::BuildRunnerPresenter do
context "with reports" do
Ci::JobArtifact::DEFAULT_FILE_NAMES.each do |file_type, filename|
context file_type.to_s do
- let(:report) { { "#{file_type}": [filename] } }
- let(:build) { create(:ci_build, options: { artifacts: { reports: report } } ) }
+ let(:report) { {:"#{file_type}" => [filename]} }
+ let(:build) { create(:ci_build, options: {artifacts: {reports: report}}) }
let(:report_expectation) do
{
@@ -50,11 +50,11 @@ describe Ci::BuildRunnerPresenter do
artifact_type: :"#{file_type}",
artifact_format: Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.fetch(file_type),
paths: [filename],
- when: 'always'
+ when: "always",
}
end
- it 'presents correct hash' do
+ it "presents correct hash" do
expect(presenter.artifacts.first).to include(report_expectation)
end
end
@@ -62,30 +62,30 @@ describe Ci::BuildRunnerPresenter do
end
context "when option has both archive and reports specification" do
- let(:report) { { junit: ['junit.xml'] } }
- let(:build) { create(:ci_build, options: { script: 'echo', artifacts: { **archive, reports: report } } ) }
+ let(:report) { {junit: ["junit.xml"]} }
+ let(:build) { create(:ci_build, options: {script: "echo", artifacts: {**archive, reports: report}}) }
let(:report_expectation) do
{
- name: 'junit.xml',
+ name: "junit.xml",
artifact_type: :junit,
artifact_format: :gzip,
- paths: ['junit.xml'],
- when: 'always'
+ paths: ["junit.xml"],
+ when: "always",
}
end
- it 'presents correct hash' do
+ it "presents correct hash" do
expect(presenter.artifacts.first).to include(archive_expectation)
expect(presenter.artifacts.second).to include(report_expectation)
end
context "when archive specifies 'expire_in' keyword" do
- let(:archive) { { paths: ['sample.txt'], expire_in: '3 mins 4 sec' } }
+ let(:archive) { {paths: ["sample.txt"], expire_in: "3 mins 4 sec"} }
- it 'inherits expire_in from archive' do
- expect(presenter.artifacts.first).to include({ **archive_expectation, expire_in: '3 mins 4 sec' })
- expect(presenter.artifacts.second).to include({ **report_expectation, expire_in: '3 mins 4 sec' })
+ it "inherits expire_in from archive" do
+ expect(presenter.artifacts.first).to include({**archive_expectation, expire_in: "3 mins 4 sec"})
+ expect(presenter.artifacts.second).to include({**report_expectation, expire_in: "3 mins 4 sec"})
end
end
end
@@ -93,74 +93,74 @@ describe Ci::BuildRunnerPresenter do
context "when option has no artifact keywords" do
let(:build) { create(:ci_build, :no_options) }
- it 'does not present hash' do
+ it "does not present hash" do
expect(presenter.artifacts).to be_nil
end
end
end
- describe '#ref_type' do
+ describe "#ref_type" do
subject { presenter.ref_type }
let(:build) { create(:ci_build, tag: tag) }
let(:tag) { true }
- it 'returns the correct ref type' do
- is_expected.to eq('tag')
+ it "returns the correct ref type" do
+ is_expected.to eq("tag")
end
- context 'when tag is false' do
+ context "when tag is false" do
let(:tag) { false }
- it 'returns the correct ref type' do
- is_expected.to eq('branch')
+ it "returns the correct ref type" do
+ is_expected.to eq("branch")
end
end
end
- describe '#git_depth' do
+ describe "#git_depth" do
subject { presenter.git_depth }
let(:build) { create(:ci_build) }
- it 'returns the correct git depth' do
+ it "returns the correct git depth" do
is_expected.to eq(0)
end
- context 'when GIT_DEPTH variable is specified' do
+ context "when GIT_DEPTH variable is specified" do
before do
- create(:ci_pipeline_variable, key: 'GIT_DEPTH', value: 1, pipeline: build.pipeline)
+ create(:ci_pipeline_variable, key: "GIT_DEPTH", value: 1, pipeline: build.pipeline)
end
- it 'returns the correct git depth' do
+ it "returns the correct git depth" do
is_expected.to eq(1)
end
end
end
- describe '#refspecs' do
+ describe "#refspecs" do
subject { presenter.refspecs }
let(:build) { create(:ci_build) }
- it 'returns the correct refspecs' do
- is_expected.to contain_exactly('+refs/tags/*:refs/tags/*',
- '+refs/heads/*:refs/remotes/origin/*')
+ it "returns the correct refspecs" do
+ is_expected.to contain_exactly("+refs/tags/*:refs/tags/*",
+ "+refs/heads/*:refs/remotes/origin/*")
end
- context 'when GIT_DEPTH variable is specified' do
+ context "when GIT_DEPTH variable is specified" do
before do
- create(:ci_pipeline_variable, key: 'GIT_DEPTH', value: 1, pipeline: build.pipeline)
+ create(:ci_pipeline_variable, key: "GIT_DEPTH", value: 1, pipeline: build.pipeline)
end
- it 'returns the correct refspecs' do
+ it "returns the correct refspecs" do
is_expected.to contain_exactly("+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}")
end
- context 'when ref is tag' do
+ context "when ref is tag" do
let(:build) { create(:ci_build, :tag) }
- it 'returns the correct refspecs' do
+ it "returns the correct refspecs" do
is_expected.to contain_exactly("+refs/tags/#{build.ref}:refs/tags/#{build.ref}")
end
end
diff --git a/spec/presenters/ci/group_variable_presenter_spec.rb b/spec/presenters/ci/group_variable_presenter_spec.rb
index cb58a757564..9b5ffa000b9 100644
--- a/spec/presenters/ci/group_variable_presenter_spec.rb
+++ b/spec/presenters/ci/group_variable_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::GroupVariablePresenter do
include Gitlab::Routing.url_helpers
@@ -10,43 +10,43 @@ describe Ci::GroupVariablePresenter do
described_class.new(variable)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
- describe '#initialize' do
- it 'takes a variable and optional params' do
+ describe "#initialize" do
+ it "takes a variable and optional params" do
expect { presenter }.not_to raise_error
end
- it 'exposes variable' do
+ it "exposes variable" do
expect(presenter.variable).to eq(variable)
end
- it 'forwards missing methods to variable' do
+ it "forwards missing methods to variable" do
expect(presenter.key).to eq(variable.key)
end
end
- describe '#placeholder' do
+ describe "#placeholder" do
subject { described_class.new(variable).placeholder }
- it { is_expected.to eq('GROUP_VARIABLE') }
+ it { is_expected.to eq("GROUP_VARIABLE") }
end
- describe '#form_path' do
+ describe "#form_path" do
subject { described_class.new(variable).form_path }
it { is_expected.to eq(group_settings_ci_cd_path(group)) }
end
- describe '#edit_path' do
+ describe "#edit_path" do
subject { described_class.new(variable).edit_path }
it { is_expected.to eq(group_variables_path(group)) }
end
- describe '#delete_path' do
+ describe "#delete_path" do
subject { described_class.new(variable).delete_path }
it { is_expected.to eq(group_variables_path(group)) }
diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb
index f7ceaf844be..d1d0568af1c 100644
--- a/spec/presenters/ci/pipeline_presenter_spec.rb
+++ b/spec/presenters/ci/pipeline_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelinePresenter do
let(:project) { create(:project) }
@@ -8,62 +8,62 @@ describe Ci::PipelinePresenter do
described_class.new(pipeline)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
- describe '#initialize' do
- it 'takes a pipeline and optional params' do
+ describe "#initialize" do
+ it "takes a pipeline and optional params" do
expect { presenter }.not_to raise_error
end
- it 'exposes pipeline' do
+ it "exposes pipeline" do
expect(presenter.pipeline).to eq(pipeline)
end
- it 'forwards missing methods to pipeline' do
+ it "forwards missing methods to pipeline" do
expect(presenter.ref).to eq(pipeline.ref)
end
end
- describe '#status_title' do
- context 'when pipeline is auto-canceled' do
+ describe "#status_title" do
+ context "when pipeline is auto-canceled" do
before do
expect(pipeline).to receive(:auto_canceled?).and_return(true)
expect(pipeline).to receive(:auto_canceled_by_id).and_return(1)
end
- it 'shows that the pipeline is auto-canceled' do
+ it "shows that the pipeline is auto-canceled" do
status_title = presenter.status_title
- expect(status_title).to include('auto-canceled')
- expect(status_title).to include('Pipeline #1')
+ expect(status_title).to include("auto-canceled")
+ expect(status_title).to include("Pipeline #1")
end
end
- context 'when pipeline is not auto-canceled' do
+ context "when pipeline is not auto-canceled" do
before do
expect(pipeline).to receive(:auto_canceled?).and_return(false)
end
- it 'does not have a status title' do
+ it "does not have a status title" do
expect(presenter.status_title).to be_nil
end
end
end
- context '#failure_reason' do
- context 'when pipeline has failure reason' do
- it 'represents a failure reason sentence' do
+ context "#failure_reason" do
+ context "when pipeline has failure reason" do
+ it "represents a failure reason sentence" do
pipeline.failure_reason = :config_error
expect(presenter.failure_reason)
- .to eq 'CI/CD YAML configuration error!'
+ .to eq "CI/CD YAML configuration error!"
end
end
- context 'when pipeline does not have failure reason' do
- it 'returns nil' do
+ context "when pipeline does not have failure reason" do
+ it "returns nil" do
expect(presenter.failure_reason).to be_nil
end
end
diff --git a/spec/presenters/ci/trigger_presenter_spec.rb b/spec/presenters/ci/trigger_presenter_spec.rb
index 231b539c188..03d140898cc 100644
--- a/spec/presenters/ci/trigger_presenter_spec.rb
+++ b/spec/presenters/ci/trigger_presenter_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::TriggerPresenter do
set(:user) { create(:user) }
set(:project) { create(:project) }
set(:trigger) do
- create(:ci_trigger, token: '123456789abcd', project: project)
+ create(:ci_trigger, token: "123456789abcd", project: project)
end
subject do
@@ -16,34 +16,34 @@ describe Ci::TriggerPresenter do
project.add_maintainer(user)
end
- context 'when user is not a trigger owner' do
- describe '#token' do
- it 'exposes only short token' do
+ context "when user is not a trigger owner" do
+ describe "#token" do
+ it "exposes only short token" do
expect(subject.token).not_to eq trigger.token
- expect(subject.token).to eq '1234'
+ expect(subject.token).to eq "1234"
end
end
- describe '#has_token_exposed?' do
- it 'does not have token exposed' do
+ describe "#has_token_exposed?" do
+ it "does not have token exposed" do
expect(subject).not_to have_token_exposed
end
end
end
- context 'when user is a trigger owner and builds admin' do
+ context "when user is a trigger owner and builds admin" do
before do
trigger.update(owner: user)
end
- describe '#token' do
- it 'exposes full token' do
+ describe "#token" do
+ it "exposes full token" do
expect(subject.token).to eq trigger.token
end
end
- describe '#has_token_exposed?' do
- it 'has token exposed' do
+ describe "#has_token_exposed?" do
+ it "has token exposed" do
expect(subject).to have_token_exposed
end
end
diff --git a/spec/presenters/ci/variable_presenter_spec.rb b/spec/presenters/ci/variable_presenter_spec.rb
index e3ce88372ea..c61d07a5761 100644
--- a/spec/presenters/ci/variable_presenter_spec.rb
+++ b/spec/presenters/ci/variable_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::VariablePresenter do
include Gitlab::Routing.url_helpers
@@ -10,43 +10,43 @@ describe Ci::VariablePresenter do
described_class.new(variable)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
- describe '#initialize' do
- it 'takes a variable and optional params' do
+ describe "#initialize" do
+ it "takes a variable and optional params" do
expect { presenter }.not_to raise_error
end
- it 'exposes variable' do
+ it "exposes variable" do
expect(presenter.variable).to eq(variable)
end
- it 'forwards missing methods to variable' do
+ it "forwards missing methods to variable" do
expect(presenter.key).to eq(variable.key)
end
end
- describe '#placeholder' do
+ describe "#placeholder" do
subject { described_class.new(variable).placeholder }
- it { is_expected.to eq('PROJECT_VARIABLE') }
+ it { is_expected.to eq("PROJECT_VARIABLE") }
end
- describe '#form_path' do
+ describe "#form_path" do
subject { described_class.new(variable).form_path }
it { is_expected.to eq(project_settings_ci_cd_path(project)) }
end
- describe '#edit_path' do
+ describe "#edit_path" do
subject { described_class.new(variable).edit_path }
it { is_expected.to eq(project_variables_path(project)) }
end
- describe '#delete_path' do
+ describe "#delete_path" do
subject { described_class.new(variable).delete_path }
it { is_expected.to eq(project_variables_path(project)) }
diff --git a/spec/presenters/clusterable_presenter_spec.rb b/spec/presenters/clusterable_presenter_spec.rb
index 05afe5347d1..e239552a8f3 100644
--- a/spec/presenters/clusterable_presenter_spec.rb
+++ b/spec/presenters/clusterable_presenter_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ClusterablePresenter do
include Gitlab::Routing.url_helpers
- describe '.fabricate' do
+ describe ".fabricate" do
let(:project) { create(:project) }
subject { described_class.fabricate(project) }
- it 'creates an object from a descendant presenter' do
+ it "creates an object from a descendant presenter" do
expect(subject).to be_kind_of(ProjectClusterablePresenter)
end
end
- shared_examples 'appropriate member permissions' do
- context 'with a developer' do
+ shared_examples "appropriate member permissions" do
+ context "with a developer" do
before do
clusterable.add_developer(user)
end
@@ -24,7 +24,7 @@ describe ClusterablePresenter do
it { is_expected.to be_falsy }
end
- context 'with a maintainer' do
+ context "with a maintainer" do
before do
clusterable.add_maintainer(user)
end
@@ -33,7 +33,7 @@ describe ClusterablePresenter do
end
end
- describe '#can_create_cluster?' do
+ describe "#can_create_cluster?" do
let(:user) { create(:user) }
subject { described_class.new(clusterable).can_create_cluster? }
@@ -42,20 +42,20 @@ describe ClusterablePresenter do
allow(clusterable).to receive(:current_user).and_return(user)
end
- context 'when clusterable is a group' do
+ context "when clusterable is a group" do
let(:clusterable) { create(:group) }
- it_behaves_like 'appropriate member permissions'
+ it_behaves_like "appropriate member permissions"
end
- context 'when clusterable is a project' do
+ context "when clusterable is a project" do
let(:clusterable) { create(:project, :repository) }
- it_behaves_like 'appropriate member permissions'
+ it_behaves_like "appropriate member permissions"
end
end
- describe '#can_add_cluster?' do
+ describe "#can_add_cluster?" do
let(:user) { create(:user) }
subject { described_class.new(clusterable).can_add_cluster? }
@@ -66,16 +66,16 @@ describe ClusterablePresenter do
allow(clusterable).to receive(:current_user).and_return(user)
end
- context 'when clusterable is a group' do
+ context "when clusterable is a group" do
let(:clusterable) { create(:group) }
- it_behaves_like 'appropriate member permissions'
+ it_behaves_like "appropriate member permissions"
end
- context 'when clusterable is a project' do
+ context "when clusterable is a project" do
let(:clusterable) { create(:project, :repository) }
- it_behaves_like 'appropriate member permissions'
+ it_behaves_like "appropriate member permissions"
end
end
end
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb
index 754ba0a594c..dadf3b59545 100644
--- a/spec/presenters/clusters/cluster_presenter_spec.rb
+++ b/spec/presenters/clusters/cluster_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::ClusterPresenter do
include Gitlab::Routing.url_helpers
@@ -10,90 +10,90 @@ describe Clusters::ClusterPresenter do
described_class.new(cluster, current_user: user)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
- describe '#initialize' do
- it 'takes a cluster and optional params' do
+ describe "#initialize" do
+ it "takes a cluster and optional params" do
expect { presenter }.not_to raise_error
end
- it 'exposes cluster' do
+ it "exposes cluster" do
expect(presenter.cluster).to eq(cluster)
end
- it 'forwards missing methods to cluster' do
+ it "forwards missing methods to cluster" do
expect(presenter.status).to eq(cluster.status)
end
end
- describe '#item_link' do
- let(:clusterable_presenter) { double('ClusterablePresenter', subject: clusterable) }
+ describe "#item_link" do
+ let(:clusterable_presenter) { double("ClusterablePresenter", subject: clusterable) }
subject { presenter.item_link(clusterable_presenter) }
- context 'for a group cluster' do
+ context "for a group cluster" do
let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [group]) }
- let(:group) { create(:group, name: 'Foo') }
+ let(:group) { create(:group, name: "Foo") }
let(:cluster_link) { "<a href=\"#{group_cluster_path(cluster.group, cluster)}\">#{cluster.name}</a>" }
before do
group.add_maintainer(user)
end
- shared_examples 'ancestor clusters' do
- context 'ancestor clusters', :nested_groups do
- let(:root_group) { create(:group, name: 'Root Group') }
- let(:parent) { create(:group, name: 'parent', parent: root_group) }
- let(:child) { create(:group, name: 'child', parent: parent) }
- let(:group) { create(:group, name: 'group', parent: child) }
+ shared_examples "ancestor clusters" do
+ context "ancestor clusters", :nested_groups do
+ let(:root_group) { create(:group, name: "Root Group") }
+ let(:parent) { create(:group, name: "parent", parent: root_group) }
+ let(:child) { create(:group, name: "child", parent: parent) }
+ let(:group) { create(:group, name: "group", parent: child) }
before do
root_group.add_maintainer(user)
end
- context 'top level group cluster' do
+ context "top level group cluster" do
let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [root_group]) }
- it 'returns full group names and link for cluster' do
+ it "returns full group names and link for cluster" do
expect(subject).to eq("Root Group / #{cluster_link}")
end
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group').and_call_original
+ it "is html safe" do
+ expect(presenter).to receive(:sanitize).with("Root Group").and_call_original
expect(subject).to be_html_safe
end
end
- context 'first level group cluster' do
+ context "first level group cluster" do
let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [parent]) }
- it 'returns full group names and link for cluster' do
+ it "returns full group names and link for cluster" do
expect(subject).to eq("Root Group / parent / #{cluster_link}")
end
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group / parent').and_call_original
+ it "is html safe" do
+ expect(presenter).to receive(:sanitize).with("Root Group / parent").and_call_original
expect(subject).to be_html_safe
end
end
- context 'second level group cluster' do
+ context "second level group cluster" do
let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [child]) }
let(:ellipsis_h) do
/.*ellipsis_h.*/
end
- it 'returns clipped group names and link for cluster' do
+ it "returns clipped group names and link for cluster" do
expect(subject).to match("Root Group / #{ellipsis_h} / child / #{cluster_link}")
end
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group / parent / child').and_call_original
+ it "is html safe" do
+ expect(presenter).to receive(:sanitize).with("Root Group / parent / child").and_call_original
expect(subject).to be_html_safe
end
@@ -101,39 +101,39 @@ describe Clusters::ClusterPresenter do
end
end
- context 'for a project clusterable' do
+ context "for a project clusterable" do
let(:clusterable) { project }
let(:project) { create(:project, group: group) }
- it 'returns the group name and the link for cluster' do
+ it "returns the group name and the link for cluster" do
expect(subject).to eq("Foo / #{cluster_link}")
end
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Foo').and_call_original
+ it "is html safe" do
+ expect(presenter).to receive(:sanitize).with("Foo").and_call_original
expect(subject).to be_html_safe
end
- include_examples 'ancestor clusters'
+ include_examples "ancestor clusters"
end
- context 'for the group clusterable for the cluster' do
+ context "for the group clusterable for the cluster" do
let(:clusterable) { group }
- it 'returns link for cluster' do
+ it "returns link for cluster" do
expect(subject).to eq(cluster_link)
end
- include_examples 'ancestor clusters'
+ include_examples "ancestor clusters"
- it 'is html safe' do
+ it "is html safe" do
expect(subject).to be_html_safe
end
end
end
- context 'for a project cluster' do
+ context "for a project cluster" do
let(:cluster) { create(:cluster, :project) }
let(:cluster_link) { "<a href=\"#{project_cluster_path(cluster.project, cluster)}\">#{cluster.name}</a>" }
@@ -141,24 +141,24 @@ describe Clusters::ClusterPresenter do
cluster.project.add_maintainer(user)
end
- context 'for the project clusterable' do
+ context "for the project clusterable" do
let(:clusterable) { cluster.project }
- it 'returns link for cluster' do
+ it "returns link for cluster" do
expect(subject).to eq(cluster_link)
end
end
end
end
- describe '#gke_cluster_url' do
+ describe "#gke_cluster_url" do
subject { described_class.new(cluster).gke_cluster_url }
it { is_expected.to include(cluster.provider.zone) }
it { is_expected.to include(cluster.name) }
end
- describe '#can_toggle_cluster' do
+ describe "#can_toggle_cluster" do
let(:user) { create(:user) }
before do
@@ -167,12 +167,12 @@ describe Clusters::ClusterPresenter do
subject { described_class.new(cluster).can_toggle_cluster? }
- context 'when user can update' do
+ context "when user can update" do
before do
allow_any_instance_of(described_class).to receive(:can?).with(user, :update_cluster, cluster).and_return(true)
end
- context 'when cluster is created' do
+ context "when cluster is created" do
before do
allow(cluster).to receive(:created?).and_return(true)
end
@@ -180,7 +180,7 @@ describe Clusters::ClusterPresenter do
it { is_expected.to eq(true) }
end
- context 'when cluster is not created' do
+ context "when cluster is not created" do
before do
allow(cluster).to receive(:created?).and_return(false)
end
@@ -189,7 +189,7 @@ describe Clusters::ClusterPresenter do
end
end
- context 'when user can not update' do
+ context "when user can not update" do
before do
allow_any_instance_of(described_class).to receive(:can?).with(user, :update_cluster, cluster).and_return(false)
end
@@ -198,30 +198,30 @@ describe Clusters::ClusterPresenter do
end
end
- describe '#cluster_type_description' do
+ describe "#cluster_type_description" do
subject { described_class.new(cluster).cluster_type_description }
- context 'project_type cluster' do
- it { is_expected.to eq('Project cluster') }
+ context "project_type cluster" do
+ it { is_expected.to eq("Project cluster") }
end
- context 'group_type cluster' do
+ context "group_type cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
- it { is_expected.to eq('Group cluster') }
+ it { is_expected.to eq("Group cluster") }
end
end
- describe '#show_path' do
+ describe "#show_path" do
subject { described_class.new(cluster).show_path }
- context 'project_type cluster' do
+ context "project_type cluster" do
let(:project) { cluster.project }
it { is_expected.to eq(project_cluster_path(project, cluster)) }
end
- context 'group_type cluster' do
+ context "group_type cluster" do
let(:group) { cluster.group }
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
diff --git a/spec/presenters/commit_presenter_spec.rb b/spec/presenters/commit_presenter_spec.rb
index 4a0d3a28c32..67e7fa5b65a 100644
--- a/spec/presenters/commit_presenter_spec.rb
+++ b/spec/presenters/commit_presenter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe CommitPresenter do
let(:project) { create(:project, :repository) }
@@ -8,45 +8,45 @@ describe CommitPresenter do
let(:user) { create(:user) }
let(:presenter) { described_class.new(commit, current_user: user) }
- describe '#status_for' do
- subject { presenter.status_for('ref') }
+ describe "#status_for" do
+ subject { presenter.status_for("ref") }
- context 'when user can read_commit_status' do
+ context "when user can read_commit_status" do
before do
allow(presenter).to receive(:can?).with(user, :read_commit_status, project).and_return(true)
end
- it 'returns commit status for ref' do
- expect(commit).to receive(:status).with('ref').and_return('test')
+ it "returns commit status for ref" do
+ expect(commit).to receive(:status).with("ref").and_return("test")
- expect(subject).to eq('test')
+ expect(subject).to eq("test")
end
end
- context 'when user can not read_commit_status' do
- it 'is false' do
+ context "when user can not read_commit_status" do
+ it "is false" do
is_expected.to eq(false)
end
end
end
- describe '#any_pipelines?' do
+ describe "#any_pipelines?" do
subject { presenter.any_pipelines? }
- context 'when user can read pipeline' do
+ context "when user can read pipeline" do
before do
allow(presenter).to receive(:can?).with(user, :read_pipeline, project).and_return(true)
end
- it 'returns if there are any pipelines for commit' do
+ it "returns if there are any pipelines for commit" do
expect(commit).to receive_message_chain(:pipelines, :any?).and_return(true)
expect(subject).to eq(true)
end
end
- context 'when user can not read pipeline' do
- it 'is false' do
+ context "when user can not read pipeline" do
+ it "is false" do
is_expected.to eq(false)
end
end
diff --git a/spec/presenters/commit_status_presenter_spec.rb b/spec/presenters/commit_status_presenter_spec.rb
index 2b7742ddbb8..432574d6668 100644
--- a/spec/presenters/commit_status_presenter_spec.rb
+++ b/spec/presenters/commit_status_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe CommitStatusPresenter do
let(:project) { create(:project) }
@@ -9,11 +9,11 @@ describe CommitStatusPresenter do
described_class.new(build)
end
- it 'inherits from Gitlab::View::Presenter::Delegated' do
+ it "inherits from Gitlab::View::Presenter::Delegated" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
- describe 'covers all failure reasons' do
+ describe "covers all failure reasons" do
let(:message) { presenter.callout_failure_message }
CommitStatus.failure_reasons.keys.each do |failure_reason|
@@ -28,9 +28,9 @@ describe CommitStatusPresenter do
end
end
- context 'invalid failure message' do
+ context "invalid failure message" do
before do
- expect(build).to receive(:failure_reason) { 'invalid failure message' }
+ expect(build).to receive(:failure_reason) { "invalid failure message" }
end
it "is an invalid status" do
diff --git a/spec/presenters/conversational_development_index/metric_presenter_spec.rb b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
index 81eb05a9a6b..a5d1d06e2ce 100644
--- a/spec/presenters/conversational_development_index/metric_presenter_spec.rb
+++ b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe ConversationalDevelopmentIndex::MetricPresenter do
subject { described_class.new(metric) }
let(:metric) { build(:conversational_development_index_metric) }
- describe '#cards' do
- it 'includes instance score, leader score and percentage score' do
+ describe "#cards" do
+ it "includes instance score, leader score and percentage score" do
issues_card = subject.cards.first
expect(issues_card.instance_score).to eq(1.234)
@@ -14,22 +14,22 @@ describe ConversationalDevelopmentIndex::MetricPresenter do
end
end
- describe '#idea_to_production_steps' do
- it 'returns percentage score when it depends on a single feature' do
+ describe "#idea_to_production_steps" do
+ it "returns percentage score when it depends on a single feature" do
code_step = subject.idea_to_production_steps.fourth
expect(code_step.percentage_score).to be_within(0.1).of(50.0)
end
- it 'returns percentage score when it depends on two features' do
+ it "returns percentage score when it depends on two features" do
issue_step = subject.idea_to_production_steps.second
expect(issue_step.percentage_score).to be_within(0.1).of(53.0)
end
end
- describe '#average_percentage_score' do
- it 'calculates an average value across all the features' do
+ describe "#average_percentage_score" do
+ it "calculates an average value across all the features" do
expect(subject.average_percentage_score).to be_within(0.1).of(55.8)
end
end
diff --git a/spec/presenters/group_clusterable_presenter_spec.rb b/spec/presenters/group_clusterable_presenter_spec.rb
index 205160742bf..defef1e0c2c 100644
--- a/spec/presenters/group_clusterable_presenter_spec.rb
+++ b/spec/presenters/group_clusterable_presenter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe GroupClusterablePresenter do
include Gitlab::Routing.url_helpers
@@ -9,7 +9,7 @@ describe GroupClusterablePresenter do
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { cluster.group }
- describe '#can_create_cluster?' do
+ describe "#can_create_cluster?" do
let(:user) { create(:user) }
subject { presenter.can_create_cluster? }
@@ -18,7 +18,7 @@ describe GroupClusterablePresenter do
allow(presenter).to receive(:current_user).and_return(user)
end
- context 'when user can create' do
+ context "when user can create" do
before do
group.add_maintainer(user)
end
@@ -26,42 +26,42 @@ describe GroupClusterablePresenter do
it { is_expected.to be_truthy }
end
- context 'when user cannot create' do
+ context "when user cannot create" do
it { is_expected.to be_falsey }
end
end
- describe '#index_path' do
+ describe "#index_path" do
subject { presenter.index_path }
it { is_expected.to eq(group_clusters_path(group)) }
end
- describe '#new_path' do
+ describe "#new_path" do
subject { presenter.new_path }
it { is_expected.to eq(new_group_cluster_path(group)) }
end
- describe '#create_user_clusters_path' do
+ describe "#create_user_clusters_path" do
subject { presenter.create_user_clusters_path }
it { is_expected.to eq(create_user_group_clusters_path(group)) }
end
- describe '#create_gcp_clusters_path' do
+ describe "#create_gcp_clusters_path" do
subject { presenter.create_gcp_clusters_path }
it { is_expected.to eq(create_gcp_group_clusters_path(group)) }
end
- describe '#cluster_status_cluster_path' do
+ describe "#cluster_status_cluster_path" do
subject { presenter.cluster_status_cluster_path(cluster) }
it { is_expected.to eq(cluster_status_group_cluster_path(group, cluster)) }
end
- describe '#install_applications_cluster_path' do
+ describe "#install_applications_cluster_path" do
let(:application) { :helm }
subject { presenter.install_applications_cluster_path(cluster, application) }
@@ -69,7 +69,7 @@ describe GroupClusterablePresenter do
it { is_expected.to eq(install_applications_group_cluster_path(group, cluster, application)) }
end
- describe '#cluster_path' do
+ describe "#cluster_path" do
subject { presenter.cluster_path(cluster) }
it { is_expected.to eq(group_cluster_path(group, cluster)) }
diff --git a/spec/presenters/group_member_presenter_spec.rb b/spec/presenters/group_member_presenter_spec.rb
index bb66523a83d..1a6d74b5430 100644
--- a/spec/presenters/group_member_presenter_spec.rb
+++ b/spec/presenters/group_member_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupMemberPresenter do
let(:user) { double(:user) }
@@ -6,13 +6,13 @@ describe GroupMemberPresenter do
let(:group_member) { double(:group_member, source: group) }
let(:presenter) { described_class.new(group_member, current_user: user) }
- describe '#can_resend_invite?' do
- context 'when group_member is invited' do
+ describe "#can_resend_invite?" do
+ context "when group_member is invited" do
before do
expect(group_member).to receive(:invite?).and_return(true)
end
- context 'and user can admin_group_member' do
+ context "and user can admin_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_group_member, group).and_return(true)
end
@@ -20,7 +20,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_resend_invite?).to eq(true) }
end
- context 'and user cannot admin_group_member' do
+ context "and user cannot admin_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_group_member, group).and_return(false)
end
@@ -29,12 +29,12 @@ describe GroupMemberPresenter do
end
end
- context 'when group_member is not invited' do
+ context "when group_member is not invited" do
before do
expect(group_member).to receive(:invite?).and_return(false)
end
- context 'and user can admin_group_member' do
+ context "and user can admin_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_group_member, group).and_return(true)
end
@@ -42,7 +42,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_resend_invite?).to eq(false) }
end
- context 'and user cannot admin_group_member' do
+ context "and user cannot admin_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_group_member, group).and_return(false)
end
@@ -52,8 +52,8 @@ describe GroupMemberPresenter do
end
end
- describe '#can_update?' do
- context 'when user can update_group_member' do
+ describe "#can_update?" do
+ context "when user can update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(true)
end
@@ -61,7 +61,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_update?).to eq(true) }
end
- context 'when user cannot update_group_member' do
+ context "when user cannot update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(false)
allow(presenter).to receive(:can?).with(user, :override_group_member, presenter).and_return(false)
@@ -71,8 +71,8 @@ describe GroupMemberPresenter do
end
end
- describe '#can_remove?' do
- context 'when user can destroy_group_member' do
+ describe "#can_remove?" do
+ context "when user can destroy_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :destroy_group_member, presenter).and_return(true)
end
@@ -80,7 +80,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_remove?).to eq(true) }
end
- context 'when user cannot destroy_group_member' do
+ context "when user cannot destroy_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :destroy_group_member, presenter).and_return(false)
end
@@ -89,13 +89,13 @@ describe GroupMemberPresenter do
end
end
- describe '#can_approve?' do
- context 'when group_member has request an invite' do
+ describe "#can_approve?" do
+ context "when group_member has request an invite" do
before do
expect(group_member).to receive(:request?).and_return(true)
end
- context 'when user can update_group_member' do
+ context "when user can update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(true)
end
@@ -103,7 +103,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_approve?).to eq(true) }
end
- context 'when user cannot update_group_member' do
+ context "when user cannot update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(false)
allow(presenter).to receive(:can?).with(user, :override_group_member, presenter).and_return(false)
@@ -113,12 +113,12 @@ describe GroupMemberPresenter do
end
end
- context 'when group_member did not request an invite' do
+ context "when group_member did not request an invite" do
before do
expect(group_member).to receive(:request?).and_return(false)
end
- context 'when user can update_group_member' do
+ context "when user can update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(true)
end
@@ -126,7 +126,7 @@ describe GroupMemberPresenter do
it { expect(presenter.can_approve?).to eq(false) }
end
- context 'when user cannot update_group_member' do
+ context "when user cannot update_group_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_group_member, presenter).and_return(false)
end
@@ -136,8 +136,8 @@ describe GroupMemberPresenter do
end
end
- it_behaves_like '#valid_level_roles', :group do
- let(:expected_roles) { { 'Developer' => 30, 'Maintainer' => 40, 'Owner' => 50, 'Reporter' => 20 } }
+ it_behaves_like "#valid_level_roles", :group do
+ let(:expected_roles) { {"Developer" => 30, "Maintainer" => 40, "Owner" => 50, "Reporter" => 20} }
before do
entity.parent = group
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb
index bafcddebbb7..3d08d5a0e33 100644
--- a/spec/presenters/merge_request_presenter_spec.rb
+++ b/spec/presenters/merge_request_presenter_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestPresenter do
let(:resource) { create :merge_request, source_project: project }
let(:project) { create :project }
let(:user) { create(:user) }
- describe '#ci_status' do
+ describe "#ci_status" do
subject { described_class.new(resource).ci_status }
- context 'when no head pipeline' do
- it 'return status using CiService' do
+ context "when no head pipeline" do
+ it "return status using CiService" do
ci_service = double(MockCiService)
ci_status = double
@@ -27,36 +27,36 @@ describe MergeRequestPresenter do
end
end
- context 'when head pipeline present' do
+ context "when head pipeline present" do
let(:pipeline) { build_stubbed(:ci_pipeline) }
before do
allow(resource).to receive(:actual_head_pipeline).and_return(pipeline)
end
- context 'success with warnings' do
+ context "success with warnings" do
before do
allow(pipeline).to receive(:success?) { true }
allow(pipeline).to receive(:has_warnings?) { true }
end
it 'returns "success_with_warnings"' do
- is_expected.to eq('success_with_warnings')
+ is_expected.to eq("success_with_warnings")
end
end
- context 'pipeline HAS status AND its not success with warnings' do
+ context "pipeline HAS status AND its not success with warnings" do
before do
allow(pipeline).to receive(:success?) { false }
allow(pipeline).to receive(:has_warnings?) { false }
end
- it 'returns pipeline status' do
- is_expected.to eq('pending')
+ it "returns pipeline status" do
+ is_expected.to eq("pending")
end
end
- context 'pipeline has NO status AND its not success with warnings' do
+ context "pipeline has NO status AND its not success with warnings" do
before do
allow(pipeline).to receive(:status) { nil }
allow(pipeline).to receive(:success?) { false }
@@ -64,28 +64,28 @@ describe MergeRequestPresenter do
end
it 'returns "preparing"' do
- is_expected.to eq('preparing')
+ is_expected.to eq("preparing")
end
end
end
end
- describe '#conflict_resolution_path' do
+ describe "#conflict_resolution_path" do
let(:project) { create :project }
let(:user) { create :user }
let(:presenter) { described_class.new(resource, current_user: user) }
let(:path) { presenter.conflict_resolution_path }
- context 'when MR cannot be resolved in UI' do
- it 'does not return conflict resolution path' do
+ context "when MR cannot be resolved in UI" do
+ it "does not return conflict resolution path" do
allow(presenter).to receive_message_chain(:conflicts, :can_be_resolved_in_ui?) { false }
expect(path).to be_nil
end
end
- context 'when conflicts cannot be resolved by user' do
- it 'does not return conflict resolution path' do
+ context "when conflicts cannot be resolved by user" do
+ it "does not return conflict resolution path" do
allow(presenter).to receive_message_chain(:conflicts, :can_be_resolved_in_ui?) { true }
allow(presenter).to receive_message_chain(:conflicts, :can_be_resolved_by?).with(user) { false }
@@ -93,8 +93,8 @@ describe MergeRequestPresenter do
end
end
- context 'when able to access conflict resolution UI' do
- it 'does return conflict resolution path' do
+ context "when able to access conflict resolution UI" do
+ it "does return conflict resolution path" do
allow(presenter).to receive_message_chain(:conflicts, :can_be_resolved_in_ui?) { true }
allow(presenter).to receive_message_chain(:conflicts, :can_be_resolved_by?).with(user) { true }
@@ -104,15 +104,15 @@ describe MergeRequestPresenter do
end
end
- context 'issues links' do
+ context "issues links" do
let(:project) { create(:project, :private, :repository, creator: user, namespace: user.namespace) }
let(:issue_a) { create(:issue, project: project) }
let(:issue_b) { create(:issue, project: project) }
let(:resource) do
create(:merge_request,
- source_project: project, target_project: project,
- description: "Fixes #{issue_a.to_reference} Related #{issue_b.to_reference}")
+ source_project: project, target_project: project,
+ description: "Fixes #{issue_a.to_reference} Related #{issue_b.to_reference}")
end
before do
@@ -122,44 +122,44 @@ describe MergeRequestPresenter do
resource.cache_merge_request_closes_issues!
end
- describe '#closing_issues_links' do
+ describe "#closing_issues_links" do
subject { described_class.new(resource, current_user: user).closing_issues_links }
- it 'presents closing issues links' do
+ it "presents closing issues links" do
is_expected.to match("#{project.full_path}/issues/#{issue_a.iid}")
end
- it 'does not present related issues links' do
+ it "does not present related issues links" do
is_expected.not_to match("#{project.full_path}/issues/#{issue_b.iid}")
end
- it 'appends status when closing issue is already closed' do
+ it "appends status when closing issue is already closed" do
issue_a.close
- is_expected.to match('(closed)')
+ is_expected.to match("(closed)")
end
end
- describe '#mentioned_issues_links' do
+ describe "#mentioned_issues_links" do
subject do
described_class.new(resource, current_user: user)
.mentioned_issues_links
end
- it 'presents related issues links' do
+ it "presents related issues links" do
is_expected.to match("#{project.full_path}/issues/#{issue_b.iid}")
end
- it 'does not present closing issues links' do
+ it "does not present closing issues links" do
is_expected.not_to match("#{project.full_path}/issues/#{issue_a.iid}")
end
- it 'appends status when mentioned issue is already closed' do
+ it "appends status when mentioned issue is already closed" do
issue_b.close
- is_expected.to match('(closed)')
+ is_expected.to match("(closed)")
end
end
- describe '#assign_to_closing_issues_link' do
+ describe "#assign_to_closing_issues_link" do
subject do
described_class.new(resource, current_user: user)
.assign_to_closing_issues_link
@@ -171,11 +171,11 @@ describe MergeRequestPresenter do
.and_return(assign_issues_service)
end
- context 'single closing issue' do
+ context "single closing issue" do
let(:issue) { create(:issue) }
let(:assignable_issues) { [issue] }
- it 'returns correct link with correct text' do
+ it "returns correct link with correct text" do
is_expected
.to match("#{project.full_path}/merge_requests/#{resource.iid}/assign_related_issues")
@@ -184,11 +184,11 @@ describe MergeRequestPresenter do
end
end
- context 'multiple closing issues' do
+ context "multiple closing issues" do
let(:issues) { create_list(:issue, 2) }
let(:assignable_issues) { issues }
- it 'returns correct link with correct text' do
+ it "returns correct link with correct text" do
is_expected
.to match("#{project.full_path}/merge_requests/#{resource.iid}/assign_related_issues")
@@ -197,24 +197,24 @@ describe MergeRequestPresenter do
end
end
- context 'no closing issue' do
+ context "no closing issue" do
let(:assignable_issues) { [] }
- it 'returns correct link with correct text' do
+ it "returns correct link with correct text" do
is_expected.to be_nil
end
end
end
end
- describe '#cancel_merge_when_pipeline_succeeds_path' do
+ describe "#cancel_merge_when_pipeline_succeeds_path" do
subject do
described_class.new(resource, current_user: user)
.cancel_merge_when_pipeline_succeeds_path
end
- context 'when can cancel mwps' do
- it 'returns path' do
+ context "when can cancel mwps" do
+ it "returns path" do
allow(resource).to receive(:can_cancel_merge_when_pipeline_succeeds?)
.with(user)
.and_return(true)
@@ -223,8 +223,8 @@ describe MergeRequestPresenter do
end
end
- context 'when cannot cancel mwps' do
- it 'returns nil' do
+ context "when cannot cancel mwps" do
+ it "returns nil" do
allow(resource).to receive(:can_cancel_merge_when_pipeline_succeeds?)
.with(user)
.and_return(false)
@@ -234,13 +234,13 @@ describe MergeRequestPresenter do
end
end
- describe '#merge_path' do
+ describe "#merge_path" do
subject do
described_class.new(resource, current_user: user).merge_path
end
- context 'when can be merged by user' do
- it 'returns path' do
+ context "when can be merged by user" do
+ it "returns path" do
allow(resource).to receive(:can_be_merged_by?)
.with(user)
.and_return(true)
@@ -250,8 +250,8 @@ describe MergeRequestPresenter do
end
end
- context 'when cannot be merged by user' do
- it 'returns nil' do
+ context "when cannot be merged by user" do
+ it "returns nil" do
allow(resource).to receive(:can_be_merged_by?)
.with(user)
.and_return(false)
@@ -261,14 +261,14 @@ describe MergeRequestPresenter do
end
end
- describe '#create_issue_to_resolve_discussions_path' do
+ describe "#create_issue_to_resolve_discussions_path" do
subject do
described_class.new(resource, current_user: user)
.create_issue_to_resolve_discussions_path
end
- context 'when can create issue and issues enabled' do
- it 'returns path' do
+ context "when can create issue and issues enabled" do
+ it "returns path" do
allow(project).to receive(:issues_enabled?) { true }
project.add_maintainer(user)
@@ -277,16 +277,16 @@ describe MergeRequestPresenter do
end
end
- context 'when cannot create issue' do
- it 'returns nil' do
+ context "when cannot create issue" do
+ it "returns nil" do
allow(project).to receive(:issues_enabled?) { true }
is_expected.to be_nil
end
end
- context 'when issues disabled' do
- it 'returns nil' do
+ context "when issues disabled" do
+ it "returns nil" do
allow(project).to receive(:issues_enabled?) { false }
project.add_maintainer(user)
@@ -295,7 +295,7 @@ describe MergeRequestPresenter do
end
end
- describe '#remove_wip_path' do
+ describe "#remove_wip_path" do
subject do
described_class.new(resource, current_user: user).remove_wip_path
end
@@ -304,8 +304,8 @@ describe MergeRequestPresenter do
allow(resource).to receive(:work_in_progress?).and_return(true)
end
- context 'when merge request enabled and has permission' do
- it 'has remove_wip_path' do
+ context "when merge request enabled and has permission" do
+ it "has remove_wip_path" do
allow(project).to receive(:merge_requests_enabled?) { true }
project.add_maintainer(user)
@@ -314,21 +314,21 @@ describe MergeRequestPresenter do
end
end
- context 'when has no permission' do
- it 'returns nil' do
+ context "when has no permission" do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- describe '#target_branch_commits_path' do
+ describe "#target_branch_commits_path" do
subject do
described_class.new(resource, current_user: user)
.target_branch_commits_path
end
- context 'when target branch exists' do
- it 'returns path' do
+ context "when target branch exists" do
+ it "returns path" do
allow(resource).to receive(:target_branch_exists?) { true }
is_expected
@@ -336,8 +336,8 @@ describe MergeRequestPresenter do
end
end
- context 'when target branch does not exist' do
- it 'returns nil' do
+ context "when target branch does not exist" do
+ it "returns nil" do
allow(resource).to receive(:target_branch_exists?) { false }
is_expected.to be_nil
@@ -345,14 +345,14 @@ describe MergeRequestPresenter do
end
end
- describe '#target_branch_tree_path' do
+ describe "#target_branch_tree_path" do
subject do
described_class.new(resource, current_user: user)
.target_branch_tree_path
end
- context 'when target branch exists' do
- it 'returns path' do
+ context "when target branch exists" do
+ it "returns path" do
allow(resource).to receive(:target_branch_exists?) { true }
is_expected
@@ -360,8 +360,8 @@ describe MergeRequestPresenter do
end
end
- context 'when target branch does not exist' do
- it 'returns nil' do
+ context "when target branch does not exist" do
+ it "returns nil" do
allow(resource).to receive(:target_branch_exists?) { false }
is_expected.to be_nil
@@ -369,13 +369,13 @@ describe MergeRequestPresenter do
end
end
- describe '#source_branch_path' do
+ describe "#source_branch_path" do
subject do
described_class.new(resource, current_user: user).source_branch_path
end
- context 'when source branch exists' do
- it 'returns path' do
+ context "when source branch exists" do
+ it "returns path" do
allow(resource).to receive(:source_branch_exists?) { true }
is_expected
@@ -383,8 +383,8 @@ describe MergeRequestPresenter do
end
end
- context 'when source branch does not exist' do
- it 'returns nil' do
+ context "when source branch does not exist" do
+ it "returns nil" do
allow(resource).to receive(:source_branch_exists?) { false }
is_expected.to be_nil
@@ -392,19 +392,19 @@ describe MergeRequestPresenter do
end
end
- describe '#source_branch_with_namespace_link' do
+ describe "#source_branch_with_namespace_link" do
subject do
described_class.new(resource, current_user: user).source_branch_with_namespace_link
end
- it 'returns link' do
+ it "returns link" do
allow(resource).to receive(:source_branch_exists?) { true }
is_expected
.to eq("<a href=\"/#{resource.source_project.full_path}/tree/#{resource.source_branch}\">#{resource.source_branch}</a>")
end
- it 'escapes html, when source_branch does not exist' do
+ it "escapes html, when source_branch does not exist" do
xss_attempt = "<img src='x' onerror=alert('bad stuff') />"
allow(resource).to receive(:source_branch) { xss_attempt }
@@ -414,7 +414,7 @@ describe MergeRequestPresenter do
end
end
- describe '#rebase_path' do
+ describe "#rebase_path" do
before do
allow(resource).to receive(:rebase_in_progress?) { rebase_in_progress }
allow(resource).to receive(:should_be_rebased?) { should_be_rebased }
@@ -429,7 +429,7 @@ describe MergeRequestPresenter do
described_class.new(resource, current_user: user).rebase_path
end
- context 'when can rebase' do
+ context "when can rebase" do
let(:rebase_in_progress) { false }
let(:can_push_to_branch) { true }
let(:should_be_rebased) { true }
@@ -438,39 +438,39 @@ describe MergeRequestPresenter do
allow(resource).to receive(:source_branch_exists?) { true }
end
- it 'returns path' do
+ it "returns path" do
is_expected
.to eq("/#{project.full_path}/merge_requests/#{resource.iid}/rebase")
end
end
- context 'when cannot rebase' do
- context 'when rebase in progress' do
+ context "when cannot rebase" do
+ context "when rebase in progress" do
let(:rebase_in_progress) { true }
let(:can_push_to_branch) { true }
let(:should_be_rebased) { true }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
- context 'when user cannot merge' do
+ context "when user cannot merge" do
let(:rebase_in_progress) { false }
let(:can_push_to_branch) { false }
let(:should_be_rebased) { true }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
- context 'should not be rebased' do
+ context "should not be rebased" do
let(:rebase_in_progress) { false }
let(:can_push_to_branch) { true }
let(:should_be_rebased) { false }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
diff --git a/spec/presenters/project_clusterable_presenter_spec.rb b/spec/presenters/project_clusterable_presenter_spec.rb
index c50d90ae1e8..2389f44f26e 100644
--- a/spec/presenters/project_clusterable_presenter_spec.rb
+++ b/spec/presenters/project_clusterable_presenter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectClusterablePresenter do
include Gitlab::Routing.url_helpers
@@ -9,7 +9,7 @@ describe ProjectClusterablePresenter do
let(:project) { create(:project) }
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
- describe '#can_create_cluster?' do
+ describe "#can_create_cluster?" do
let(:user) { create(:user) }
subject { presenter.can_create_cluster? }
@@ -18,7 +18,7 @@ describe ProjectClusterablePresenter do
allow(presenter).to receive(:current_user).and_return(user)
end
- context 'when user can create' do
+ context "when user can create" do
before do
project.add_maintainer(user)
end
@@ -26,42 +26,42 @@ describe ProjectClusterablePresenter do
it { is_expected.to be_truthy }
end
- context 'when user cannot create' do
+ context "when user cannot create" do
it { is_expected.to be_falsey }
end
end
- describe '#index_path' do
+ describe "#index_path" do
subject { presenter.index_path }
it { is_expected.to eq(project_clusters_path(project)) }
end
- describe '#new_path' do
+ describe "#new_path" do
subject { presenter.new_path }
it { is_expected.to eq(new_project_cluster_path(project)) }
end
- describe '#create_user_clusters_path' do
+ describe "#create_user_clusters_path" do
subject { presenter.create_user_clusters_path }
it { is_expected.to eq(create_user_project_clusters_path(project)) }
end
- describe '#create_gcp_clusters_path' do
+ describe "#create_gcp_clusters_path" do
subject { presenter.create_gcp_clusters_path }
it { is_expected.to eq(create_gcp_project_clusters_path(project)) }
end
- describe '#cluster_status_cluster_path' do
+ describe "#cluster_status_cluster_path" do
subject { presenter.cluster_status_cluster_path(cluster) }
it { is_expected.to eq(cluster_status_project_cluster_path(project, cluster)) }
end
- describe '#install_applications_cluster_path' do
+ describe "#install_applications_cluster_path" do
let(:application) { :helm }
subject { presenter.install_applications_cluster_path(cluster, application) }
@@ -69,7 +69,7 @@ describe ProjectClusterablePresenter do
it { is_expected.to eq(install_applications_project_cluster_path(project, cluster, application)) }
end
- describe '#cluster_path' do
+ describe "#cluster_path" do
subject { presenter.cluster_path(cluster) }
it { is_expected.to eq(project_cluster_path(project, cluster)) }
diff --git a/spec/presenters/project_member_presenter_spec.rb b/spec/presenters/project_member_presenter_spec.rb
index 73ef113a1c5..3881c9fdf95 100644
--- a/spec/presenters/project_member_presenter_spec.rb
+++ b/spec/presenters/project_member_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectMemberPresenter do
let(:user) { double(:user) }
@@ -6,13 +6,13 @@ describe ProjectMemberPresenter do
let(:project_member) { double(:project_member, source: project) }
let(:presenter) { described_class.new(project_member, current_user: user) }
- describe '#can_resend_invite?' do
- context 'when project_member is invited' do
+ describe "#can_resend_invite?" do
+ context "when project_member is invited" do
before do
expect(project_member).to receive(:invite?).and_return(true)
end
- context 'and user can admin_project_member' do
+ context "and user can admin_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_project_member, project).and_return(true)
end
@@ -20,7 +20,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_resend_invite?).to eq(true) }
end
- context 'and user cannot admin_project_member' do
+ context "and user cannot admin_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_project_member, project).and_return(false)
end
@@ -29,12 +29,12 @@ describe ProjectMemberPresenter do
end
end
- context 'when project_member is not invited' do
+ context "when project_member is not invited" do
before do
expect(project_member).to receive(:invite?).and_return(false)
end
- context 'and user can admin_project_member' do
+ context "and user can admin_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_project_member, project).and_return(true)
end
@@ -42,7 +42,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_resend_invite?).to eq(false) }
end
- context 'and user cannot admin_project_member' do
+ context "and user cannot admin_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :admin_project_member, project).and_return(false)
end
@@ -52,8 +52,8 @@ describe ProjectMemberPresenter do
end
end
- describe '#can_update?' do
- context 'when user can update_project_member' do
+ describe "#can_update?" do
+ context "when user can update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(true)
end
@@ -61,7 +61,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_update?).to eq(true) }
end
- context 'when user cannot update_project_member' do
+ context "when user cannot update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(false)
allow(presenter).to receive(:can?).with(user, :override_project_member, presenter).and_return(false)
@@ -71,8 +71,8 @@ describe ProjectMemberPresenter do
end
end
- describe '#can_remove?' do
- context 'when user can destroy_project_member' do
+ describe "#can_remove?" do
+ context "when user can destroy_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :destroy_project_member, presenter).and_return(true)
end
@@ -80,7 +80,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_remove?).to eq(true) }
end
- context 'when user cannot destroy_project_member' do
+ context "when user cannot destroy_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :destroy_project_member, presenter).and_return(false)
end
@@ -89,13 +89,13 @@ describe ProjectMemberPresenter do
end
end
- describe '#can_approve?' do
- context 'when project_member has request an invite' do
+ describe "#can_approve?" do
+ context "when project_member has request an invite" do
before do
expect(project_member).to receive(:request?).and_return(true)
end
- context 'and user can update_project_member' do
+ context "and user can update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(true)
end
@@ -103,7 +103,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_approve?).to eq(true) }
end
- context 'and user cannot update_project_member' do
+ context "and user cannot update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(false)
allow(presenter).to receive(:can?).with(user, :override_project_member, presenter).and_return(false)
@@ -113,12 +113,12 @@ describe ProjectMemberPresenter do
end
end
- context 'when project_member did not request an invite' do
+ context "when project_member did not request an invite" do
before do
expect(project_member).to receive(:request?).and_return(false)
end
- context 'and user can update_project_member' do
+ context "and user can update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(true)
end
@@ -126,7 +126,7 @@ describe ProjectMemberPresenter do
it { expect(presenter.can_approve?).to eq(false) }
end
- context 'and user cannot update_project_member' do
+ context "and user cannot update_project_member" do
before do
allow(presenter).to receive(:can?).with(user, :update_project_member, presenter).and_return(false)
end
@@ -136,7 +136,7 @@ describe ProjectMemberPresenter do
end
end
- it_behaves_like '#valid_level_roles', :project do
+ it_behaves_like "#valid_level_roles", :project do
before do
entity.group = group
end
diff --git a/spec/presenters/project_presenter_spec.rb b/spec/presenters/project_presenter_spec.rb
index 456de5f1b9a..a8a28654161 100644
--- a/spec/presenters/project_presenter_spec.rb
+++ b/spec/presenters/project_presenter_spec.rb
@@ -1,156 +1,156 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectPresenter do
let(:user) { create(:user) }
- describe '#license_short_name' do
+ describe "#license_short_name" do
let(:project) { create(:project) }
let(:presenter) { described_class.new(project, current_user: user) }
- context 'when project.repository has a license_key' do
- it 'returns the nickname of the license if present' do
- allow(project.repository).to receive(:license_key).and_return('agpl-3.0')
+ context "when project.repository has a license_key" do
+ it "returns the nickname of the license if present" do
+ allow(project.repository).to receive(:license_key).and_return("agpl-3.0")
- expect(presenter.license_short_name).to eq('GNU AGPLv3')
+ expect(presenter.license_short_name).to eq("GNU AGPLv3")
end
- it 'returns the name of the license if nickname is not present' do
- allow(project.repository).to receive(:license_key).and_return('mit')
+ it "returns the name of the license if nickname is not present" do
+ allow(project.repository).to receive(:license_key).and_return("mit")
- expect(presenter.license_short_name).to eq('MIT License')
+ expect(presenter.license_short_name).to eq("MIT License")
end
end
- context 'when project.repository has no license_key but a license_blob' do
- it 'returns LICENSE' do
+ context "when project.repository has no license_key but a license_blob" do
+ it "returns LICENSE" do
allow(project.repository).to receive(:license_key).and_return(nil)
- expect(presenter.license_short_name).to eq('LICENSE')
+ expect(presenter.license_short_name).to eq("LICENSE")
end
end
end
- describe '#default_view' do
+ describe "#default_view" do
let(:presenter) { described_class.new(project, current_user: user) }
- context 'user not signed in' do
+ context "user not signed in" do
let(:user) { nil }
- context 'when repository is empty' do
+ context "when repository is empty" do
let(:project) { create(:project_empty_repo, :public) }
- it 'returns activity if user has repository access' do
+ it "returns activity if user has repository access" do
allow(presenter).to receive(:can?).with(nil, :download_code, project).and_return(true)
- expect(presenter.default_view).to eq('activity')
+ expect(presenter.default_view).to eq("activity")
end
- it 'returns activity if user does not have repository access' do
+ it "returns activity if user does not have repository access" do
allow(project).to receive(:can?).with(nil, :download_code, project).and_return(false)
- expect(presenter.default_view).to eq('activity')
+ expect(presenter.default_view).to eq("activity")
end
end
- context 'when repository is not empty' do
+ context "when repository is not empty" do
let(:project) { create(:project, :public, :repository) }
- it 'returns files and readme if user has repository access' do
+ it "returns files and readme if user has repository access" do
allow(presenter).to receive(:can?).with(nil, :download_code, project).and_return(true)
- expect(presenter.default_view).to eq('files')
+ expect(presenter.default_view).to eq("files")
end
- it 'returns activity if user does not have repository access' do
+ it "returns activity if user does not have repository access" do
allow(presenter).to receive(:can?).with(nil, :download_code, project).and_return(false)
- expect(presenter.default_view).to eq('activity')
+ expect(presenter.default_view).to eq("activity")
end
end
end
- context 'user signed in' do
+ context "user signed in" do
let(:user) { create(:user, :readme) }
let(:project) { create(:project, :public, :repository) }
- context 'when the user is allowed to see the code' do
- it 'returns the project view' do
+ context "when the user is allowed to see the code" do
+ it "returns the project view" do
allow(presenter).to receive(:can?).with(user, :download_code, project).and_return(true)
- expect(presenter.default_view).to eq('readme')
+ expect(presenter.default_view).to eq("readme")
end
end
- context 'with wikis enabled and the right policy for the user' do
+ context "with wikis enabled and the right policy for the user" do
before do
project.project_feature.update_attribute(:issues_access_level, 0)
allow(presenter).to receive(:can?).with(user, :download_code, project).and_return(false)
end
- it 'returns wiki if the user has the right policy' do
+ it "returns wiki if the user has the right policy" do
allow(presenter).to receive(:can?).with(user, :read_wiki, project).and_return(true)
- expect(presenter.default_view).to eq('wiki')
+ expect(presenter.default_view).to eq("wiki")
end
- it 'returns customize_workflow if the user does not have the right policy' do
+ it "returns customize_workflow if the user does not have the right policy" do
allow(presenter).to receive(:can?).with(user, :read_wiki, project).and_return(false)
- expect(presenter.default_view).to eq('customize_workflow')
+ expect(presenter.default_view).to eq("customize_workflow")
end
end
- context 'with issues as a feature available' do
- it 'return issues' do
+ context "with issues as a feature available" do
+ it "return issues" do
allow(presenter).to receive(:can?).with(user, :download_code, project).and_return(false)
allow(presenter).to receive(:can?).with(user, :read_wiki, project).and_return(false)
- expect(presenter.default_view).to eq('projects/issues/issues')
+ expect(presenter.default_view).to eq("projects/issues/issues")
end
end
- context 'with no activity, no wikies and no issues' do
- it 'returns customize_workflow as default' do
+ context "with no activity, no wikies and no issues" do
+ it "returns customize_workflow as default" do
project.project_feature.update_attribute(:issues_access_level, 0)
allow(presenter).to receive(:can?).with(user, :download_code, project).and_return(false)
allow(presenter).to receive(:can?).with(user, :read_wiki, project).and_return(false)
- expect(presenter.default_view).to eq('customize_workflow')
+ expect(presenter.default_view).to eq("customize_workflow")
end
end
end
end
- describe '#can_current_user_push_code?' do
+ describe "#can_current_user_push_code?" do
let(:project) { create(:project, :repository) }
let(:presenter) { described_class.new(project, current_user: user) }
- context 'empty repo' do
+ context "empty repo" do
let(:project) { create(:project) }
- it 'returns true if user can push_code' do
+ it "returns true if user can push_code" do
project.add_developer(user)
expect(presenter.can_current_user_push_code?).to be(true)
end
- it 'returns false if user cannot push_code' do
+ it "returns false if user cannot push_code" do
project.add_reporter(user)
expect(presenter.can_current_user_push_code?).to be(false)
end
end
- context 'not empty repo' do
+ context "not empty repo" do
let(:project) { create(:project, :repository) }
- it 'returns true if user can push to default branch' do
+ it "returns true if user can push to default branch" do
project.add_developer(user)
expect(presenter.can_current_user_push_code?).to be(true)
end
- it 'returns false if default branch is protected' do
+ it "returns false if default branch is protected" do
project.add_developer(user)
create(:protected_branch, project: project, name: project.default_branch)
@@ -159,98 +159,98 @@ describe ProjectPresenter do
end
end
- context 'statistics anchors (empty repo)' do
+ context "statistics anchors (empty repo)" do
let(:project) { create(:project, :empty_repo) }
let(:presenter) { described_class.new(project, current_user: user) }
- describe '#files_anchor_data' do
- it 'returns files data' do
+ describe "#files_anchor_data" do
+ it "returns files data" do
expect(presenter.files_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0 Bytes'),
+ label: a_string_including("0 Bytes"),
link: nil)
end
end
- describe '#commits_anchor_data' do
- it 'returns commits data' do
+ describe "#commits_anchor_data" do
+ it "returns commits data" do
expect(presenter.commits_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0'),
+ label: a_string_including("0"),
link: nil)
end
end
- describe '#branches_anchor_data' do
- it 'returns branches data' do
+ describe "#branches_anchor_data" do
+ it "returns branches data" do
expect(presenter.branches_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0'),
+ label: a_string_including("0"),
link: nil)
end
end
- describe '#tags_anchor_data' do
- it 'returns tags data' do
+ describe "#tags_anchor_data" do
+ it "returns tags data" do
expect(presenter.tags_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0'),
+ label: a_string_including("0"),
link: nil)
end
end
end
- context 'statistics anchors' do
+ context "statistics anchors" do
let(:project) { create(:project, :repository) }
let(:presenter) { described_class.new(project, current_user: user) }
- describe '#files_anchor_data' do
- it 'returns files data' do
+ describe "#files_anchor_data" do
+ it "returns files data" do
expect(presenter.files_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0 Bytes'),
+ label: a_string_including("0 Bytes"),
link: presenter.project_tree_path(project))
end
end
- describe '#commits_anchor_data' do
- it 'returns commits data' do
+ describe "#commits_anchor_data" do
+ it "returns commits data" do
expect(presenter.commits_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('0'),
+ label: a_string_including("0"),
link: presenter.project_commits_path(project, project.repository.root_ref))
end
end
- describe '#branches_anchor_data' do
- it 'returns branches data' do
+ describe "#branches_anchor_data" do
+ it "returns branches data" do
expect(presenter.branches_anchor_data).to have_attributes(is_link: true,
- label: a_string_including("#{project.repository.branches.size}"),
+ label: a_string_including(project.repository.branches.size.to_s),
link: presenter.project_branches_path(project))
end
end
- describe '#tags_anchor_data' do
- it 'returns tags data' do
+ describe "#tags_anchor_data" do
+ it "returns tags data" do
expect(presenter.tags_anchor_data).to have_attributes(is_link: true,
- label: a_string_including("#{project.repository.tags.size}"),
+ label: a_string_including(project.repository.tags.size.to_s),
link: presenter.project_tags_path(project))
end
end
- describe '#new_file_anchor_data' do
- it 'returns new file data if user can push' do
+ describe "#new_file_anchor_data" do
+ it "returns new file data if user can push" do
project.add_developer(user)
expect(presenter.new_file_anchor_data).to have_attributes(is_link: false,
label: a_string_including("New file"),
- link: presenter.project_new_blob_path(project, 'master'),
- class_modifier: 'success')
+ link: presenter.project_new_blob_path(project, "master"),
+ class_modifier: "success")
end
- it 'returns nil if user cannot push' do
+ it "returns nil if user cannot push" do
expect(presenter.new_file_anchor_data).to be_nil
end
- context 'when the project is empty' do
+ context "when the project is empty" do
let(:project) { create(:project, :empty_repo) }
# Since we protect the default branch for empty repos
- it 'is empty for a developer' do
+ it "is empty for a developer" do
project.add_developer(user)
expect(presenter.new_file_anchor_data).to be_nil
@@ -258,67 +258,67 @@ describe ProjectPresenter do
end
end
- describe '#readme_anchor_data' do
- context 'when user can push and README does not exists' do
- it 'returns anchor data' do
+ describe "#readme_anchor_data" do
+ context "when user can push and README does not exists" do
+ it "returns anchor data" do
project.add_developer(user)
allow(project.repository).to receive(:readme).and_return(nil)
expect(presenter.readme_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Add README'),
+ label: a_string_including("Add README"),
link: presenter.add_readme_path)
end
end
- context 'when README exists' do
- it 'returns anchor data' do
- allow(project.repository).to receive(:readme).and_return(double(name: 'readme'))
+ context "when README exists" do
+ it "returns anchor data" do
+ allow(project.repository).to receive(:readme).and_return(double(name: "readme"))
expect(presenter.readme_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('README'),
+ label: a_string_including("README"),
link: presenter.readme_path)
end
end
end
- describe '#changelog_anchor_data' do
- context 'when user can push and CHANGELOG does not exist' do
- it 'returns anchor data' do
+ describe "#changelog_anchor_data" do
+ context "when user can push and CHANGELOG does not exist" do
+ it "returns anchor data" do
project.add_developer(user)
allow(project.repository).to receive(:changelog).and_return(nil)
expect(presenter.changelog_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Add CHANGELOG'),
+ label: a_string_including("Add CHANGELOG"),
link: presenter.add_changelog_path)
end
end
- context 'when CHANGELOG exists' do
- it 'returns anchor data' do
- allow(project.repository).to receive(:changelog).and_return(double(name: 'foo'))
+ context "when CHANGELOG exists" do
+ it "returns anchor data" do
+ allow(project.repository).to receive(:changelog).and_return(double(name: "foo"))
expect(presenter.changelog_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('CHANGELOG'),
+ label: a_string_including("CHANGELOG"),
link: presenter.changelog_path)
end
end
end
- describe '#license_anchor_data' do
- context 'when user can push and LICENSE does not exist' do
- it 'returns anchor data' do
+ describe "#license_anchor_data" do
+ context "when user can push and LICENSE does not exist" do
+ it "returns anchor data" do
project.add_developer(user)
allow(project.repository).to receive(:license_blob).and_return(nil)
expect(presenter.license_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('Add license'),
+ label: a_string_including("Add license"),
link: presenter.add_license_path)
end
end
- context 'when LICENSE exists' do
- it 'returns anchor data' do
- allow(project.repository).to receive(:license_blob).and_return(double(name: 'foo'))
+ context "when LICENSE exists" do
+ it "returns anchor data" do
+ allow(project.repository).to receive(:license_blob).and_return(double(name: "foo"))
expect(presenter.license_anchor_data).to have_attributes(is_link: true,
label: a_string_including(presenter.license_short_name),
@@ -327,85 +327,85 @@ describe ProjectPresenter do
end
end
- describe '#contribution_guide_anchor_data' do
- context 'when user can push and CONTRIBUTING does not exist' do
- it 'returns anchor data' do
+ describe "#contribution_guide_anchor_data" do
+ context "when user can push and CONTRIBUTING does not exist" do
+ it "returns anchor data" do
project.add_developer(user)
allow(project.repository).to receive(:contribution_guide).and_return(nil)
expect(presenter.contribution_guide_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Add CONTRIBUTING'),
+ label: a_string_including("Add CONTRIBUTING"),
link: presenter.add_contribution_guide_path)
end
end
- context 'when CONTRIBUTING exists' do
- it 'returns anchor data' do
- allow(project.repository).to receive(:contribution_guide).and_return(double(name: 'foo'))
+ context "when CONTRIBUTING exists" do
+ it "returns anchor data" do
+ allow(project.repository).to receive(:contribution_guide).and_return(double(name: "foo"))
expect(presenter.contribution_guide_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('CONTRIBUTING'),
+ label: a_string_including("CONTRIBUTING"),
link: presenter.contribution_guide_path)
end
end
end
- describe '#autodevops_anchor_data' do
- context 'when Auto Devops is enabled' do
- it 'returns anchor data' do
+ describe "#autodevops_anchor_data" do
+ context "when Auto Devops is enabled" do
+ it "returns anchor data" do
allow(project).to receive(:auto_devops_enabled?).and_return(true)
expect(presenter.autodevops_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Auto DevOps enabled'),
+ label: a_string_including("Auto DevOps enabled"),
link: nil)
end
end
- context 'when user can admin pipeline and CI yml does not exist' do
- it 'returns anchor data' do
+ context "when user can admin pipeline and CI yml does not exist" do
+ it "returns anchor data" do
project.add_maintainer(user)
allow(project).to receive(:auto_devops_enabled?).and_return(false)
allow(project.repository).to receive(:gitlab_ci_yml).and_return(nil)
expect(presenter.autodevops_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Enable Auto DevOps'),
- link: presenter.project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
+ label: a_string_including("Enable Auto DevOps"),
+ link: presenter.project_settings_ci_cd_path(project, anchor: "autodevops-settings"))
end
end
end
- describe '#kubernetes_cluster_anchor_data' do
- context 'when user can create Kubernetes cluster' do
- it 'returns link to cluster if only one exists' do
+ describe "#kubernetes_cluster_anchor_data" do
+ context "when user can create Kubernetes cluster" do
+ it "returns link to cluster if only one exists" do
project.add_maintainer(user)
cluster = create(:cluster, projects: [project])
expect(presenter.kubernetes_cluster_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Kubernetes configured'),
+ label: a_string_including("Kubernetes configured"),
link: presenter.project_cluster_path(project, cluster))
end
- it 'returns link to clusters page if more than one exists' do
+ it "returns link to clusters page if more than one exists" do
project.add_maintainer(user)
create(:cluster, :production_environment, projects: [project])
create(:cluster, projects: [project])
expect(presenter.kubernetes_cluster_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Kubernetes configured'),
+ label: a_string_including("Kubernetes configured"),
link: presenter.project_clusters_path(project))
end
- it 'returns link to create a cluster if no cluster exists' do
+ it "returns link to create a cluster if no cluster exists" do
project.add_maintainer(user)
expect(presenter.kubernetes_cluster_anchor_data).to have_attributes(is_link: false,
- label: a_string_including('Add Kubernetes cluster'),
+ label: a_string_including("Add Kubernetes cluster"),
link: presenter.new_project_cluster_path(project))
end
end
- context 'when user cannot create Kubernetes cluster' do
- it 'returns nil' do
+ context "when user cannot create Kubernetes cluster" do
+ it "returns nil" do
expect(presenter.kubernetes_cluster_anchor_data).to be_nil
end
end
diff --git a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
index 001545bb5df..eaa927bc850 100644
--- a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
+++ b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::Settings::DeployKeysPresenter do
let(:project) { create(:project) }
@@ -13,29 +13,29 @@ describe Projects::Settings::DeployKeysPresenter do
described_class.new(project, current_user: user)
end
- it 'inherits from Gitlab::View::Presenter::Simple' do
+ it "inherits from Gitlab::View::Presenter::Simple" do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Simple)
end
- describe '#enabled_keys' do
- it 'returns currently enabled keys' do
+ describe "#enabled_keys" do
+ it "returns currently enabled keys" do
expect(presenter.enabled_keys).to eq [deploy_keys_project.deploy_key]
end
- it 'does not contain enabled_keys inside available_keys' do
+ it "does not contain enabled_keys inside available_keys" do
expect(presenter.available_keys).not_to include deploy_key
end
- it 'returns the enabled_keys size' do
+ it "returns the enabled_keys size" do
expect(presenter.enabled_keys_size).to eq(1)
end
- it 'returns true if there is any enabled_keys' do
+ it "returns true if there is any enabled_keys" do
expect(presenter.any_keys_enabled?).to eq(true)
end
end
- describe '#available_keys/#available_project_keys' do
+ describe "#available_keys/#available_project_keys" do
let(:other_deploy_key) { create(:another_deploy_key) }
before do
@@ -43,19 +43,19 @@ describe Projects::Settings::DeployKeysPresenter do
project_key.project.add_developer(user)
end
- it 'returns the current available_keys' do
+ it "returns the current available_keys" do
expect(presenter.available_keys).not_to be_empty
end
- it 'returns the current available_project_keys' do
+ it "returns the current available_project_keys" do
expect(presenter.available_project_keys).not_to be_empty
end
- it 'returns the available_project_keys size' do
+ it "returns the available_project_keys size" do
expect(presenter.available_project_keys_size).to eq(1)
end
- it 'shows if there is an available key' do
+ it "shows if there is an available key" do
expect(presenter.key_available?(deploy_key)).to eq(false)
end
end
diff --git a/spec/rack_servers/configs/config.ru b/spec/rack_servers/configs/config.ru
index 63daeb9eec5..856ff9dacff 100644
--- a/spec/rack_servers/configs/config.ru
+++ b/spec/rack_servers/configs/config.ru
@@ -1,11 +1,11 @@
# frozen_string_literal: true
app = proc do |env|
- if env['REQUEST_METHOD'] == 'GET'
- [200, {}, ["#{Process.pid}"]]
+ if env["REQUEST_METHOD"] == "GET"
+ [200, {}, [Process.pid.to_s]]
else
- Process.kill(env['QUERY_STRING'], Process.pid)
- [200, {}, ['Bye!']]
+ Process.kill(env["QUERY_STRING"], Process.pid)
+ [200, {}, ["Bye!"]]
end
end
diff --git a/spec/rack_servers/configs/puma.rb b/spec/rack_servers/configs/puma.rb
index d6b6d83d648..3b8f5a73ee3 100644
--- a/spec/rack_servers/configs/puma.rb
+++ b/spec/rack_servers/configs/puma.rb
@@ -4,11 +4,11 @@
# Note: as per the convention in `config/puma.example.development.rb`,
# this file will replace `/home/git` with the actual working directory
-directory '/home/git'
+directory "/home/git"
threads 1, 10
queue_requests false
-pidfile '/home/git/gitlab/tmp/pids/puma.pid'
-bind 'unix:///home/git/gitlab/tmp/tests/puma.socket'
+pidfile "/home/git/gitlab/tmp/pids/puma.pid"
+bind "unix:///home/git/gitlab/tmp/tests/puma.socket"
workers 1
preload_app!
worker_timeout 60
@@ -24,7 +24,7 @@ end
Gitlab::Cluster::LifecycleEvents.set_puma_options @config.options
on_worker_boot do
Gitlab::Cluster::LifecycleEvents.do_worker_start
- File.write('/home/git/gitlab/tmp/tests/puma-worker-ready', Process.pid)
+ File.write("/home/git/gitlab/tmp/tests/puma-worker-ready", Process.pid)
end
on_restart do
diff --git a/spec/rack_servers/puma_spec.rb b/spec/rack_servers/puma_spec.rb
index 431fab87857..c7f3df0a6c8 100644
--- a/spec/rack_servers/puma_spec.rb
+++ b/spec/rack_servers/puma_spec.rb
@@ -1,33 +1,33 @@
# frozen_string_literal: true
-require 'fileutils'
+require "fileutils"
-require 'excon'
+require "excon"
-require 'spec_helper'
+require "spec_helper"
-describe 'Puma' do
+describe "Puma" do
before(:all) do
- project_root = File.expand_path('../..', __dir__)
+ project_root = File.expand_path("../..", __dir__)
- config_lines = File.read('spec/rack_servers/configs/puma.rb')
- .gsub('/home/git/gitlab', project_root)
- .gsub('/home/git', project_root)
+ config_lines = File.read("spec/rack_servers/configs/puma.rb")
+ .gsub("/home/git/gitlab", project_root)
+ .gsub("/home/git", project_root)
config_path = File.join(project_root, "tmp/tests/puma.rb")
- @socket_path = File.join(project_root, 'tmp/tests/puma.socket')
+ @socket_path = File.join(project_root, "tmp/tests/puma.socket")
File.write(config_path, config_lines)
- cmd = %W[puma -e test -C #{config_path} #{File.join(__dir__, 'configs/config.ru')}]
+ cmd = %W[puma -e test -C #{config_path} #{File.join(__dir__, "configs/config.ru")}]
@puma_master_pid = spawn(*cmd)
- wait_puma_boot!(@puma_master_pid, File.join(project_root, 'tmp/tests/puma-worker-ready'))
+ wait_puma_boot!(@puma_master_pid, File.join(project_root, "tmp/tests/puma-worker-ready"))
WebMock.allow_net_connect!
end
%w[SIGQUIT SIGTERM SIGKILL].each do |signal|
it "has a worker that self-terminates on signal #{signal}" do
- response = Excon.get('unix://', socket: @socket_path)
+ response = Excon.get("unix://", socket: @socket_path)
expect(response.status).to eq(200)
worker_pid = response.body.to_i
@@ -44,11 +44,9 @@ describe 'Puma' do
end
after(:all) do
- begin
- WebMock.disable_net_connect!(allow_localhost: true)
- Process.kill('TERM', @puma_master_pid)
- rescue Errno::ESRCH
- end
+ WebMock.disable_net_connect!(allow_localhost: true)
+ Process.kill("TERM", @puma_master_pid)
+ rescue Errno::ESRCH
end
def wait_puma_boot!(master_pid, ready_file)
diff --git a/spec/rack_servers/unicorn_spec.rb b/spec/rack_servers/unicorn_spec.rb
index 6a02ebcd048..c43c7276d16 100644
--- a/spec/rack_servers/unicorn_spec.rb
+++ b/spec/rack_servers/unicorn_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'fileutils'
+require "fileutils"
-require 'excon'
+require "excon"
-require 'spec_helper'
+require "spec_helper"
-describe 'Unicorn' do
+describe "Unicorn" do
before(:all) do
- project_root = File.expand_path('../..', __dir__)
+ project_root = File.expand_path("../..", __dir__)
- config_lines = File.read('config/unicorn.rb.example')
- .gsub('/home/git/gitlab', project_root)
- .gsub('/home/git', project_root)
+ config_lines = File.read("config/unicorn.rb.example")
+ .gsub("/home/git/gitlab", project_root)
+ .gsub("/home/git", project_root)
.split("\n")
# Remove these because they make setup harder.
- config_lines = config_lines.reject do |line|
+ config_lines = config_lines.reject { |line|
%w[
worker_processes
listen
@@ -24,23 +24,23 @@ describe 'Unicorn' do
stderr_path
stdout_path
].any? { |prefix| line.start_with?(prefix) }
- end
+ }
config_lines << "working_directory '#{Rails.root}'"
# We want to have exactly 1 worker process because that makes it
# predictable which process will handle our requests.
- config_lines << 'worker_processes 1'
+ config_lines << "worker_processes 1"
- @socket_path = File.join(project_root, 'tmp/tests/unicorn.socket')
+ @socket_path = File.join(project_root, "tmp/tests/unicorn.socket")
config_lines << "listen '#{@socket_path}'"
- ready_file = File.join(project_root, 'tmp/tests/unicorn-worker-ready')
+ ready_file = File.join(project_root, "tmp/tests/unicorn-worker-ready")
FileUtils.rm_f(ready_file)
- after_fork_index = config_lines.index { |l| l.start_with?('after_fork') }
+ after_fork_index = config_lines.index { |l| l.start_with?("after_fork") }
config_lines.insert(after_fork_index + 1, "File.write('#{ready_file}', Process.pid)")
- config_path = File.join(project_root, 'tmp/tests/unicorn.rb')
+ config_path = File.join(project_root, "tmp/tests/unicorn.rb")
File.write(config_path, config_lines.join("\n") + "\n")
cmd = %W[unicorn -E test -c #{config_path} spec/rack_servers/configs/config.ru]
@@ -51,7 +51,7 @@ describe 'Unicorn' do
%w[SIGQUIT SIGTERM SIGKILL].each do |signal|
it "has a worker that self-terminates on signal #{signal}" do
- response = Excon.get('unix://', socket: @socket_path)
+ response = Excon.get("unix://", socket: @socket_path)
expect(response.status).to eq(200)
worker_pid = response.body.to_i
@@ -69,7 +69,7 @@ describe 'Unicorn' do
after(:all) do
WebMock.disable_net_connect!(allow_localhost: true)
- Process.kill('TERM', @unicorn_master_pid)
+ Process.kill("TERM", @unicorn_master_pid)
end
def wait_unicorn_boot!(master_pid, ready_file)
diff --git a/spec/rake_helper.rb b/spec/rake_helper.rb
index 298a520f5ca..3548592ab6b 100644
--- a/spec/rake_helper.rb
+++ b/spec/rake_helper.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'rake'
+require "spec_helper"
+require "rake"
RSpec.configure do |config|
config.include RakeHelpers
@@ -8,7 +8,7 @@ RSpec.configure do |config|
config.before(:all) do
$stdout = StringIO.new
- Rake.application.rake_require 'tasks/gitlab/helpers'
+ Rake.application.rake_require "tasks/gitlab/helpers"
Rake::Task.define_task :environment
end
diff --git a/spec/requests/api/access_requests_spec.rb b/spec/requests/api/access_requests_spec.rb
index 1af6602ea9e..117fb672448 100644
--- a/spec/requests/api/access_requests_spec.rb
+++ b/spec/requests/api/access_requests_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::AccessRequests do
set(:maintainer) { create(:user) }
@@ -22,16 +22,16 @@ describe API::AccessRequests do
end
end
- shared_examples 'GET /:sources/:id/access_requests' do |source_type|
+ shared_examples "GET /:sources/:id/access_requests" do |source_type|
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { get api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) }
end
- context 'when authenticated as a non-maintainer/owner' do
+ context "when authenticated as a non-maintainer/owner" do
%i[developer access_requester stranger].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
@@ -41,8 +41,8 @@ describe API::AccessRequests do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'returns access requesters' do
+ context "when authenticated as a maintainer/owner" do
+ it "returns access requesters" do
get api("/#{source_type.pluralize}/#{source.id}/access_requests", maintainer)
expect(response).to have_gitlab_http_status(200)
@@ -54,84 +54,84 @@ describe API::AccessRequests do
end
end
- shared_examples 'POST /:sources/:id/access_requests' do |source_type|
+ shared_examples "POST /:sources/:id/access_requests" do |source_type|
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger) }
end
- context 'when authenticated as a member' do
+ context "when authenticated as a member" do
%i[developer maintainer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
- expect do
+ it "returns 403" do
+ expect {
user = public_send(type)
post api("/#{source_type.pluralize}/#{source.id}/access_requests", user)
expect(response).to have_gitlab_http_status(403)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
end
end
- context 'when authenticated as an access requester' do
- it 'returns 400' do
- expect do
+ context "when authenticated as an access requester" do
+ it "returns 400" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/access_requests", access_requester)
expect(response).to have_gitlab_http_status(400)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
- context 'when authenticated as a stranger' do
+ context "when authenticated as a stranger" do
context "when access request is disabled for the #{source_type}" do
before do
source.update(request_access_enabled: false)
end
- it 'returns 403' do
- expect do
+ it "returns 403" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
expect(response).to have_gitlab_http_status(403)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
- it 'returns 201' do
- expect do
+ it "returns 201" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/access_requests", stranger)
expect(response).to have_gitlab_http_status(201)
- end.to change { source.requesters.count }.by(1)
+ }.to change { source.requesters.count }.by(1)
# User attributes
- expect(json_response['id']).to eq(stranger.id)
- expect(json_response['name']).to eq(stranger.name)
- expect(json_response['username']).to eq(stranger.username)
- expect(json_response['state']).to eq(stranger.state)
- expect(json_response['avatar_url']).to eq(stranger.avatar_url)
- expect(json_response['web_url']).to eq(Gitlab::Routing.url_helpers.user_url(stranger))
+ expect(json_response["id"]).to eq(stranger.id)
+ expect(json_response["name"]).to eq(stranger.name)
+ expect(json_response["username"]).to eq(stranger.username)
+ expect(json_response["state"]).to eq(stranger.state)
+ expect(json_response["avatar_url"]).to eq(stranger.avatar_url)
+ expect(json_response["web_url"]).to eq(Gitlab::Routing.url_helpers.user_url(stranger))
# Member attributes
- expect(json_response['requested_at']).to be_present
+ expect(json_response["requested_at"]).to be_present
end
end
end
end
- shared_examples 'PUT /:sources/:id/access_requests/:user_id/approve' do |source_type|
+ shared_examples "PUT /:sources/:id/access_requests/:user_id/approve" do |source_type|
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", stranger) }
end
- context 'when authenticated as a non-maintainer/owner' do
+ context "when authenticated as a non-maintainer/owner" do
%i[developer access_requester stranger].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", user)
@@ -141,49 +141,49 @@ describe API::AccessRequests do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'returns 201' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ it "returns 201" do
+ expect {
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}/approve", maintainer),
- params: { access_level: Member::MAINTAINER }
+ params: {access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(201)
- end.to change { source.members.count }.by(1)
+ }.to change { source.members.count }.by(1)
# User attributes
- expect(json_response['id']).to eq(access_requester.id)
- expect(json_response['name']).to eq(access_requester.name)
- expect(json_response['username']).to eq(access_requester.username)
- expect(json_response['state']).to eq(access_requester.state)
- expect(json_response['avatar_url']).to eq(access_requester.avatar_url)
- expect(json_response['web_url']).to eq(Gitlab::Routing.url_helpers.user_url(access_requester))
+ expect(json_response["id"]).to eq(access_requester.id)
+ expect(json_response["name"]).to eq(access_requester.name)
+ expect(json_response["username"]).to eq(access_requester.username)
+ expect(json_response["state"]).to eq(access_requester.state)
+ expect(json_response["avatar_url"]).to eq(access_requester.avatar_url)
+ expect(json_response["web_url"]).to eq(Gitlab::Routing.url_helpers.user_url(access_requester))
# Member attributes
- expect(json_response['access_level']).to eq(Member::MAINTAINER)
+ expect(json_response["access_level"]).to eq(Member::MAINTAINER)
end
- context 'user_id does not match an existing access requester' do
- it 'returns 404' do
- expect do
+ context "user_id does not match an existing access requester" do
+ it "returns 404" do
+ expect {
put api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}/approve", maintainer)
expect(response).to have_gitlab_http_status(404)
- end.not_to change { source.members.count }
+ }.not_to change { source.members.count }
end
end
end
end
end
- shared_examples 'DELETE /:sources/:id/access_requests/:user_id' do |source_type|
+ shared_examples "DELETE /:sources/:id/access_requests/:user_id" do |source_type|
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", stranger) }
end
- context 'when authenticated as a non-maintainer/owner' do
+ context "when authenticated as a non-maintainer/owner" do
%i[developer stranger].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", user)
@@ -193,77 +193,77 @@ describe API::AccessRequests do
end
end
- context 'when authenticated as the access requester' do
- it 'deletes the access requester' do
- expect do
+ context "when authenticated as the access requester" do
+ it "deletes the access requester" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", access_requester)
expect(response).to have_gitlab_http_status(204)
- end.to change { source.requesters.count }.by(-1)
+ }.to change { source.requesters.count }.by(-1)
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'deletes the access requester' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ it "deletes the access requester" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{access_requester.id}", maintainer)
expect(response).to have_gitlab_http_status(204)
- end.to change { source.requesters.count }.by(-1)
+ }.to change { source.requesters.count }.by(-1)
end
- context 'user_id matches a member, not an access requester' do
- it 'returns 404' do
- expect do
+ context "user_id matches a member, not an access requester" do
+ it "returns 404" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{developer.id}", maintainer)
expect(response).to have_gitlab_http_status(404)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
- context 'user_id does not match an existing access requester' do
- it 'returns 404' do
- expect do
+ context "user_id does not match an existing access requester" do
+ it "returns 404" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/access_requests/#{stranger.id}", maintainer)
expect(response).to have_gitlab_http_status(404)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
end
end
end
- it_behaves_like 'GET /:sources/:id/access_requests', 'project' do
+ it_behaves_like "GET /:sources/:id/access_requests", "project" do
let(:source) { project }
end
- it_behaves_like 'GET /:sources/:id/access_requests', 'group' do
+ it_behaves_like "GET /:sources/:id/access_requests", "group" do
let(:source) { group }
end
- it_behaves_like 'POST /:sources/:id/access_requests', 'project' do
+ it_behaves_like "POST /:sources/:id/access_requests", "project" do
let(:source) { project }
end
- it_behaves_like 'POST /:sources/:id/access_requests', 'group' do
+ it_behaves_like "POST /:sources/:id/access_requests", "group" do
let(:source) { group }
end
- it_behaves_like 'PUT /:sources/:id/access_requests/:user_id/approve', 'project' do
+ it_behaves_like "PUT /:sources/:id/access_requests/:user_id/approve", "project" do
let(:source) { project }
end
- it_behaves_like 'PUT /:sources/:id/access_requests/:user_id/approve', 'group' do
+ it_behaves_like "PUT /:sources/:id/access_requests/:user_id/approve", "group" do
let(:source) { group }
end
- it_behaves_like 'DELETE /:sources/:id/access_requests/:user_id', 'project' do
+ it_behaves_like "DELETE /:sources/:id/access_requests/:user_id", "project" do
let(:source) { project }
end
- it_behaves_like 'DELETE /:sources/:id/access_requests/:user_id', 'group' do
+ it_behaves_like "DELETE /:sources/:id/access_requests/:user_id", "group" do
let(:source) { group }
end
end
diff --git a/spec/requests/api/applications_spec.rb b/spec/requests/api/applications_spec.rb
index e47166544d9..1817d8638cf 100644
--- a/spec/requests/api/applications_spec.rb
+++ b/spec/requests/api/applications_spec.rb
@@ -1,148 +1,148 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Applications, :api do
include ApiHelpers
let(:admin_user) { create(:user, admin: true) }
let(:user) { create(:user, admin: false) }
- let!(:application) { create(:application, name: 'another_application', redirect_uri: 'http://other_application.url', scopes: '') }
+ let!(:application) { create(:application, name: "another_application", redirect_uri: "http://other_application.url", scopes: "") }
- describe 'POST /applications' do
- context 'authenticated and authorized user' do
- it 'creates and returns an OAuth application' do
- expect do
- post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '' }
- end.to change { Doorkeeper::Application.count }.by 1
+ describe "POST /applications" do
+ context "authenticated and authorized user" do
+ it "creates and returns an OAuth application" do
+ expect {
+ post api("/applications", admin_user), params: {name: "application_name", redirect_uri: "http://application.url", scopes: ""}
+ }.to change { Doorkeeper::Application.count }.by 1
- application = Doorkeeper::Application.find_by(name: 'application_name', redirect_uri: 'http://application.url')
+ application = Doorkeeper::Application.find_by(name: "application_name", redirect_uri: "http://application.url")
expect(response).to have_gitlab_http_status(201)
expect(json_response).to be_a Hash
- expect(json_response['application_id']).to eq application.uid
- expect(json_response['secret']).to eq application.secret
- expect(json_response['callback_url']).to eq application.redirect_uri
+ expect(json_response["application_id"]).to eq application.uid
+ expect(json_response["secret"]).to eq application.secret
+ expect(json_response["callback_url"]).to eq application.redirect_uri
end
- it 'does not allow creating an application with the wrong redirect_uri format' do
- expect do
- post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://', scopes: '' }
- end.not_to change { Doorkeeper::Application.count }
+ it "does not allow creating an application with the wrong redirect_uri format" do
+ expect {
+ post api("/applications", admin_user), params: {name: "application_name", redirect_uri: "http://", scopes: ""}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(json_response).to be_a Hash
- expect(json_response['message']['redirect_uri'][0]).to eq('must be an absolute URI.')
+ expect(json_response["message"]["redirect_uri"][0]).to eq("must be an absolute URI.")
end
- it 'does not allow creating an application with a forbidden URI format' do
- expect do
- post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'javascript://alert()', scopes: '' }
- end.not_to change { Doorkeeper::Application.count }
+ it "does not allow creating an application with a forbidden URI format" do
+ expect {
+ post api("/applications", admin_user), params: {name: "application_name", redirect_uri: "javascript://alert()", scopes: ""}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(json_response).to be_a Hash
- expect(json_response['message']['redirect_uri'][0]).to eq('is forbidden by the server.')
+ expect(json_response["message"]["redirect_uri"][0]).to eq("is forbidden by the server.")
end
- it 'does not allow creating an application without a name' do
- expect do
- post api('/applications', admin_user), params: { redirect_uri: 'http://application.url', scopes: '' }
- end.not_to change { Doorkeeper::Application.count }
+ it "does not allow creating an application without a name" do
+ expect {
+ post api("/applications", admin_user), params: {redirect_uri: "http://application.url", scopes: ""}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(json_response).to be_a Hash
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response["error"]).to eq("name is missing")
end
- it 'does not allow creating an application without a redirect_uri' do
- expect do
- post api('/applications', admin_user), params: { name: 'application_name', scopes: '' }
- end.not_to change { Doorkeeper::Application.count }
+ it "does not allow creating an application without a redirect_uri" do
+ expect {
+ post api("/applications", admin_user), params: {name: "application_name", scopes: ""}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(json_response).to be_a Hash
- expect(json_response['error']).to eq('redirect_uri is missing')
+ expect(json_response["error"]).to eq("redirect_uri is missing")
end
- it 'does not allow creating an application without scopes' do
- expect do
- post api('/applications', admin_user), params: { name: 'application_name', redirect_uri: 'http://application.url' }
- end.not_to change { Doorkeeper::Application.count }
+ it "does not allow creating an application without scopes" do
+ expect {
+ post api("/applications", admin_user), params: {name: "application_name", redirect_uri: "http://application.url"}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(400)
expect(json_response).to be_a Hash
- expect(json_response['error']).to eq('scopes is missing')
+ expect(json_response["error"]).to eq("scopes is missing")
end
end
- context 'authorized user without authorization' do
- it 'does not create application' do
- expect do
- post api('/applications', user), params: { name: 'application_name', redirect_uri: 'http://application.url', scopes: '' }
- end.not_to change { Doorkeeper::Application.count }
+ context "authorized user without authorization" do
+ it "does not create application" do
+ expect {
+ post api("/applications", user), params: {name: "application_name", redirect_uri: "http://application.url", scopes: ""}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(403)
end
end
- context 'non-authenticated user' do
- it 'does not create application' do
- expect do
- post api('/applications'), params: { name: 'application_name', redirect_uri: 'http://application.url' }
- end.not_to change { Doorkeeper::Application.count }
+ context "non-authenticated user" do
+ it "does not create application" do
+ expect {
+ post api("/applications"), params: {name: "application_name", redirect_uri: "http://application.url"}
+ }.not_to change { Doorkeeper::Application.count }
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'GET /applications' do
- context 'authenticated and authorized user' do
- it 'can list application' do
- get api('/applications', admin_user)
+ describe "GET /applications" do
+ context "authenticated and authorized user" do
+ it "can list application" do
+ get api("/applications", admin_user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a(Array)
end
end
- context 'authorized user without authorization' do
- it 'cannot list application' do
- get api('/applications', user)
+ context "authorized user without authorization" do
+ it "cannot list application" do
+ get api("/applications", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'non-authenticated user' do
- it 'cannot list application' do
- get api('/applications')
+ context "non-authenticated user" do
+ it "cannot list application" do
+ get api("/applications")
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'DELETE /applications/:id' do
- context 'authenticated and authorized user' do
- it 'can delete an application' do
- expect do
+ describe "DELETE /applications/:id" do
+ context "authenticated and authorized user" do
+ it "can delete an application" do
+ expect {
delete api("/applications/#{application.id}", admin_user)
- end.to change { Doorkeeper::Application.count }.by(-1)
+ }.to change { Doorkeeper::Application.count }.by(-1)
expect(response).to have_gitlab_http_status(204)
end
end
- context 'authorized user without authorization' do
- it 'cannot delete an application' do
+ context "authorized user without authorization" do
+ it "cannot delete an application" do
delete api("/applications/#{application.id}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'non-authenticated user' do
- it 'cannot delete an application' do
+ context "non-authenticated user" do
+ it "cannot delete an application" do
delete api("/applications/#{application.id}")
expect(response).to have_gitlab_http_status(401)
diff --git a/spec/requests/api/avatar_spec.rb b/spec/requests/api/avatar_spec.rb
index 9bc49bd5982..bbf73ec5107 100644
--- a/spec/requests/api/avatar_spec.rb
+++ b/spec/requests/api/avatar_spec.rb
@@ -1,46 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Avatar do
- let(:gravatar_service) { double('GravatarService') }
+ let(:gravatar_service) { double("GravatarService") }
- describe 'GET /avatar' do
- context 'avatar uploaded to GitLab' do
- context 'user with matching public email address' do
- let(:user) { create(:user, :with_avatar, email: 'public@example.com', public_email: 'public@example.com') }
+ describe "GET /avatar" do
+ context "avatar uploaded to GitLab" do
+ context "user with matching public email address" do
+ let(:user) { create(:user, :with_avatar, email: "public@example.com", public_email: "public@example.com") }
before do
user
end
- it 'returns the avatar url' do
- get api('/avatar'), params: { email: 'public@example.com' }
+ it "returns the avatar url" do
+ get api("/avatar"), params: {email: "public@example.com"}
expect(response.status).to eq 200
- expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
+ expect(json_response["avatar_url"]).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
end
end
- context 'no user with matching public email address' do
+ context "no user with matching public email address" do
before do
expect(GravatarService).to receive(:new).and_return(gravatar_service)
expect(gravatar_service).to(
receive(:execute)
- .with('private@example.com', nil, 2, { username: nil })
- .and_return('https://gravatar'))
+ .with("private@example.com", nil, 2, {username: nil})
+ .and_return("https://gravatar")
+ )
end
- it 'returns the avatar url from Gravatar' do
- get api('/avatar'), params: { email: 'private@example.com' }
+ it "returns the avatar url from Gravatar" do
+ get api("/avatar"), params: {email: "private@example.com"}
expect(response.status).to eq 200
- expect(json_response['avatar_url']).to eq('https://gravatar')
+ expect(json_response["avatar_url"]).to eq("https://gravatar")
end
end
end
- context 'avatar uploaded to Gravatar' do
- context 'user with matching public email address' do
- let(:user) { create(:user, email: 'public@example.com', public_email: 'public@example.com') }
+ context "avatar uploaded to Gravatar" do
+ context "user with matching public email address" do
+ let(:user) { create(:user, email: "public@example.com", public_email: "public@example.com") }
before do
user
@@ -48,37 +49,39 @@ describe API::Avatar do
expect(GravatarService).to receive(:new).and_return(gravatar_service)
expect(gravatar_service).to(
receive(:execute)
- .with('public@example.com', nil, 2, { username: user.username })
- .and_return('https://gravatar'))
+ .with("public@example.com", nil, 2, {username: user.username})
+ .and_return("https://gravatar")
+ )
end
- it 'returns the avatar url from Gravatar' do
- get api('/avatar'), params: { email: 'public@example.com' }
+ it "returns the avatar url from Gravatar" do
+ get api("/avatar"), params: {email: "public@example.com"}
expect(response.status).to eq 200
- expect(json_response['avatar_url']).to eq('https://gravatar')
+ expect(json_response["avatar_url"]).to eq("https://gravatar")
end
end
- context 'no user with matching public email address' do
+ context "no user with matching public email address" do
before do
expect(GravatarService).to receive(:new).and_return(gravatar_service)
expect(gravatar_service).to(
receive(:execute)
- .with('private@example.com', nil, 2, { username: nil })
- .and_return('https://gravatar'))
+ .with("private@example.com", nil, 2, {username: nil})
+ .and_return("https://gravatar")
+ )
end
- it 'returns the avatar url from Gravatar' do
- get api('/avatar'), params: { email: 'private@example.com' }
+ it "returns the avatar url from Gravatar" do
+ get api("/avatar"), params: {email: "private@example.com"}
expect(response.status).to eq 200
- expect(json_response['avatar_url']).to eq('https://gravatar')
+ expect(json_response["avatar_url"]).to eq("https://gravatar")
end
end
- context 'public visibility level restricted' do
- let(:user) { create(:user, :with_avatar, email: 'public@example.com', public_email: 'public@example.com') }
+ context "public visibility level restricted" do
+ let(:user) { create(:user, :with_avatar, email: "public@example.com", public_email: "public@example.com") }
before do
user
@@ -86,18 +89,18 @@ describe API::Avatar do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- context 'when authenticated' do
- it 'returns the avatar url' do
- get api('/avatar', user), params: { email: 'public@example.com' }
+ context "when authenticated" do
+ it "returns the avatar url" do
+ get api("/avatar", user), params: {email: "public@example.com"}
expect(response.status).to eq 200
- expect(json_response['avatar_url']).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
+ expect(json_response["avatar_url"]).to eql("#{::Settings.gitlab.base_url}#{user.avatar.local_url}")
end
end
- context 'when unauthenticated' do
- it_behaves_like '403 response' do
- let(:request) { get api('/avatar'), params: { email: 'public@example.com' } }
+ context "when unauthenticated" do
+ it_behaves_like "403 response" do
+ let(:request) { get api("/avatar"), params: {email: "public@example.com"} }
end
end
end
diff --git a/spec/requests/api/award_emoji_spec.rb b/spec/requests/api/award_emoji_spec.rb
index 6c67d84b59b..08d20bd3bf6 100644
--- a/spec/requests/api/award_emoji_spec.rb
+++ b/spec/requests/api/award_emoji_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::AwardEmoji do
set(:user) { create(:user) }
@@ -14,13 +14,13 @@ describe API::AwardEmoji do
end
describe "GET /projects/:id/awardable/:awardable_id/award_emoji" do
- context 'on an issue' do
+ context "on an issue" do
it "returns an array of award_emoji" do
get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first['name']).to eq(award_emoji.name)
+ expect(json_response.first["name"]).to eq(award_emoji.name)
end
it "returns a 404 error when issue id not found" do
@@ -30,32 +30,32 @@ describe API::AwardEmoji do
end
end
- context 'on a merge request' do
+ context "on a merge request" do
it "returns an array of award_emoji" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['name']).to eq(downvote.name)
+ expect(json_response.first["name"]).to eq(downvote.name)
end
end
- context 'on a snippet' do
+ context "on a snippet" do
let(:snippet) { create(:project_snippet, :public, project: project) }
let!(:award) { create(:award_emoji, awardable: snippet) }
- it 'returns the awarded emoji' do
+ it "returns the awarded emoji" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first['name']).to eq(award.name)
+ expect(json_response.first["name"]).to eq(award.name)
end
end
- context 'when the user has no access' do
- it 'returns a status code 404' do
+ context "when the user has no access" do
+ it "returns a status code 404" do
user1 = create(:user)
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji", user1)
@@ -65,27 +65,27 @@ describe API::AwardEmoji do
end
end
- describe 'GET /projects/:id/awardable/:awardable_id/notes/:note_id/award_emoji' do
- let!(:rocket) { create(:award_emoji, awardable: note, name: 'rocket') }
+ describe "GET /projects/:id/awardable/:awardable_id/notes/:note_id/award_emoji" do
+ let!(:rocket) { create(:award_emoji, awardable: note, name: "rocket") }
- it 'returns an array of award emoji' do
+ it "returns an array of award emoji" do
get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first['name']).to eq(rocket.name)
+ expect(json_response.first["name"]).to eq(rocket.name)
end
end
describe "GET /projects/:id/awardable/:awardable_id/award_emoji/:award_id" do
- context 'on an issue' do
+ context "on an issue" do
it "returns the award emoji" do
get api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(award_emoji.name)
- expect(json_response['awardable_id']).to eq(issue.id)
- expect(json_response['awardable_type']).to eq("Issue")
+ expect(json_response["name"]).to eq(award_emoji.name)
+ expect(json_response["awardable_id"]).to eq(issue.id)
+ expect(json_response["awardable_type"]).to eq("Issue")
end
it "returns a 404 error if the award is not found" do
@@ -95,33 +95,33 @@ describe API::AwardEmoji do
end
end
- context 'on a merge request' do
- it 'returns the award emoji' do
+ context "on a merge request" do
+ it "returns the award emoji" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(downvote.name)
- expect(json_response['awardable_id']).to eq(merge_request.id)
- expect(json_response['awardable_type']).to eq("MergeRequest")
+ expect(json_response["name"]).to eq(downvote.name)
+ expect(json_response["awardable_id"]).to eq(merge_request.id)
+ expect(json_response["awardable_type"]).to eq("MergeRequest")
end
end
- context 'on a snippet' do
+ context "on a snippet" do
let(:snippet) { create(:project_snippet, :public, project: project) }
let!(:award) { create(:award_emoji, awardable: snippet) }
- it 'returns the awarded emoji' do
+ it "returns the awarded emoji" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(award.name)
- expect(json_response['awardable_id']).to eq(snippet.id)
- expect(json_response['awardable_type']).to eq("Snippet")
+ expect(json_response["name"]).to eq(award.name)
+ expect(json_response["awardable_id"]).to eq(snippet.id)
+ expect(json_response["awardable_type"]).to eq("Snippet")
end
end
- context 'when the user has no access' do
- it 'returns a status code 404' do
+ context "when the user has no access" do
+ it "returns a status code 404" do
user1 = create(:user)
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user1)
@@ -131,15 +131,15 @@ describe API::AwardEmoji do
end
end
- describe 'GET /projects/:id/awardable/:awardable_id/notes/:note_id/award_emoji/:award_id' do
- let!(:rocket) { create(:award_emoji, awardable: note, name: 'rocket') }
+ describe "GET /projects/:id/awardable/:awardable_id/notes/:note_id/award_emoji/:award_id" do
+ let!(:rocket) { create(:award_emoji, awardable: note, name: "rocket") }
- it 'returns an award emoji' do
+ it "returns an award emoji" do
get api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).not_to be_an Array
- expect(json_response['name']).to eq(rocket.name)
+ expect(json_response["name"]).to eq(rocket.name)
end
end
@@ -148,11 +148,11 @@ describe API::AwardEmoji do
context "on an issue" do
it "creates a new award emoji" do
- post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'blowfish' }
+ post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: {name: "blowfish"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('blowfish')
- expect(json_response['user']['username']).to eq(user.username)
+ expect(json_response["name"]).to eq("blowfish")
+ expect(json_response["user"]["username"]).to eq(user.username)
end
it "returns a 400 bad request error if the name is not given" do
@@ -162,21 +162,21 @@ describe API::AwardEmoji do
end
it "returns a 401 unauthorized error if the user is not authenticated" do
- post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), params: { name: 'thumbsup' }
+ post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji"), params: {name: "thumbsup"}
expect(response).to have_gitlab_http_status(401)
end
it "normalizes +1 as thumbsup award" do
- post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: '+1' }
+ post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: {name: "+1"}
expect(issue.award_emoji.last.name).to eq("thumbsup")
end
- context 'when the emoji already has been awarded' do
- it 'returns a 404 status code' do
- post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'thumbsup' }
- post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: { name: 'thumbsup' }
+ context "when the emoji already has been awarded" do
+ it "returns a 404 status code" do
+ post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: {name: "thumbsup"}
+ post api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji", user), params: {name: "thumbsup"}
expect(response).to have_gitlab_http_status(404)
expect(json_response["message"]).to match("has already been taken")
@@ -184,15 +184,15 @@ describe API::AwardEmoji do
end
end
- context 'on a snippet' do
- it 'creates a new award emoji' do
+ context "on a snippet" do
+ it "creates a new award emoji" do
snippet = create(:project_snippet, :public, project: project)
- post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), params: { name: 'blowfish' }
+ post api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji", user), params: {name: "blowfish"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('blowfish')
- expect(json_response['user']['username']).to eq(user.username)
+ expect(json_response["name"]).to eq("blowfish")
+ expect(json_response["user"]["username"]).to eq(user.username)
end
end
end
@@ -200,25 +200,25 @@ describe API::AwardEmoji do
describe "POST /projects/:id/awardable/:awardable_id/notes/:note_id/award_emoji" do
let(:note2) { create(:note, project: project, noteable: issue, author: user) }
- it 'creates a new award emoji' do
- expect do
- post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' }
- end.to change { note.award_emoji.count }.from(0).to(1)
+ it "creates a new award emoji" do
+ expect {
+ post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: {name: "rocket"}
+ }.to change { note.award_emoji.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['user']['username']).to eq(user.username)
+ expect(json_response["user"]["username"]).to eq(user.username)
end
it "normalizes +1 as thumbsup award" do
- post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: '+1' }
+ post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: {name: "+1"}
expect(note.award_emoji.last.name).to eq("thumbsup")
end
- context 'when the emoji already has been awarded' do
- it 'returns a 404 status code' do
- post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' }
- post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: { name: 'rocket' }
+ context "when the emoji already has been awarded" do
+ it "returns a 404 status code" do
+ post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: {name: "rocket"}
+ post api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji", user), params: {name: "rocket"}
expect(response).to have_gitlab_http_status(404)
expect(json_response["message"]).to match("has already been taken")
@@ -226,77 +226,77 @@ describe API::AwardEmoji do
end
end
- describe 'DELETE /projects/:id/awardable/:awardable_id/award_emoji/:award_id' do
- context 'when the awardable is an Issue' do
- it 'deletes the award' do
- expect do
+ describe "DELETE /projects/:id/awardable/:awardable_id/award_emoji/:award_id" do
+ context "when the awardable is an Issue" do
+ it "deletes the award" do
+ expect {
delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { issue.award_emoji.count }.from(1).to(0)
+ }.to change { issue.award_emoji.count }.from(1).to(0)
end
- it 'returns a 404 error when the award emoji can not be found' do
+ it "returns a 404 error when the award emoji can not be found" do
delete api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/12345", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}/award_emoji/#{award_emoji.id}", user) }
end
end
- context 'when the awardable is a Merge Request' do
- it 'deletes the award' do
- expect do
+ context "when the awardable is a Merge Request" do
+ it "deletes the award" do
+ expect {
delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { merge_request.award_emoji.count }.from(1).to(0)
+ }.to change { merge_request.award_emoji.count }.from(1).to(0)
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
delete api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes/12345", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/award_emoji/#{downvote.id}", user) }
end
end
- context 'when the awardable is a Snippet' do
+ context "when the awardable is a Snippet" do
let(:snippet) { create(:project_snippet, :public, project: project) }
let!(:award) { create(:award_emoji, awardable: snippet, user: user) }
- it 'deletes the award' do
- expect do
+ it "deletes the award" do
+ expect {
delete api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { snippet.award_emoji.count }.from(1).to(0)
+ }.to change { snippet.award_emoji.count }.from(1).to(0)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/snippets/#{snippet.id}/award_emoji/#{award.id}", user) }
end
end
end
- describe 'DELETE /projects/:id/awardable/:awardable_id/award_emoji/:award_emoji_id' do
- let!(:rocket) { create(:award_emoji, awardable: note, name: 'rocket', user: user) }
+ describe "DELETE /projects/:id/awardable/:awardable_id/award_emoji/:award_emoji_id" do
+ let!(:rocket) { create(:award_emoji, awardable: note, name: "rocket", user: user) }
- it 'deletes the award' do
- expect do
+ it "deletes the award" do
+ expect {
delete api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { note.award_emoji.count }.from(1).to(0)
+ }.to change { note.award_emoji.count }.from(1).to(0)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}/notes/#{note.id}/award_emoji/#{rocket.id}", user) }
end
end
diff --git a/spec/requests/api/badges_spec.rb b/spec/requests/api/badges_spec.rb
index 1271324a2ba..9578905d8fc 100644
--- a/spec/requests/api/badges_spec.rb
+++ b/spec/requests/api/badges_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Badges do
- let(:maintainer) { create(:user, username: 'maintainer_user') }
+ let(:maintainer) { create(:user, username: "maintainer_user") }
let(:developer) { create(:user) }
let(:access_requester) { create(:user) }
let(:stranger) { create(:user) }
@@ -9,27 +9,27 @@ describe API::Badges do
let(:project) { setup_project }
let!(:group) { setup_group }
- shared_context 'source helpers' do
+ shared_context "source helpers" do
def get_source(source_type)
- source_type == 'project' ? project : group
+ source_type == "project" ? project : group
end
end
- shared_examples 'GET /:sources/:id/badges' do |source_type|
- include_context 'source helpers'
+ shared_examples "GET /:sources/:id/badges" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { get api("/#{source_type.pluralize}/#{source.id}/badges", stranger) }
end
%i[maintainer developer access_requester stranger].each do |type|
context "when authenticated as a #{type}" do
- it 'returns 200' do
+ it "returns 200" do
user = public_send(type)
- badges_count = source_type == 'project' ? 3 : 2
+ badges_count = source_type == "project" ? 3 : 2
get api("/#{source_type.pluralize}/#{source.id}/badges", user)
@@ -41,50 +41,50 @@ describe API::Badges do
end
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
# Establish baseline
get api("/#{source_type.pluralize}/#{source.id}/badges", maintainer)
- control = ActiveRecord::QueryRecorder.new do
+ control = ActiveRecord::QueryRecorder.new {
get api("/#{source_type.pluralize}/#{source.id}/badges", maintainer)
- end
+ }
project.add_developer(create(:user))
- expect do
+ expect {
get api("/#{source_type.pluralize}/#{source.id}/badges", maintainer)
- end.not_to exceed_query_limit(control)
+ }.not_to exceed_query_limit(control)
end
end
end
- shared_examples 'GET /:sources/:id/badges/:badge_id' do |source_type|
- include_context 'source helpers'
+ shared_examples "GET /:sources/:id/badges/:badge_id" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { get api("/#{source_type.pluralize}/#{source.id}/badges/#{developer.id}", stranger) }
end
- context 'when authenticated as a non-member' do
+ context "when authenticated as a non-member" do
%i[maintainer developer access_requester stranger].each do |type|
let(:badge) { source.badges.first }
context "as a #{type}" do
- it 'returns 200' do
+ it "returns 200" do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(badge.id)
- expect(json_response['link_url']).to eq(badge.link_url)
- expect(json_response['rendered_link_url']).to eq(badge.rendered_link_url)
- expect(json_response['image_url']).to eq(badge.image_url)
- expect(json_response['rendered_image_url']).to eq(badge.rendered_image_url)
- expect(json_response['kind']).to eq source_type
+ expect(json_response["id"]).to eq(badge.id)
+ expect(json_response["link_url"]).to eq(badge.link_url)
+ expect(json_response["rendered_link_url"]).to eq(badge.rendered_link_url)
+ expect(json_response["image_url"]).to eq(badge.image_url)
+ expect(json_response["rendered_image_url"]).to eq(badge.rendered_image_url)
+ expect(json_response["kind"]).to eq source_type
end
end
end
@@ -92,29 +92,29 @@ describe API::Badges do
end
end
- shared_examples 'POST /:sources/:id/badges' do |source_type|
- include_context 'source helpers'
+ shared_examples "POST /:sources/:id/badges" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
- let(:example_url) { 'http://www.example.com' }
- let(:example_url2) { 'http://www.example1.com' }
+ let(:example_url) { "http://www.example.com" }
+ let(:example_url2) { "http://www.example1.com" }
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) do
post api("/#{source_type.pluralize}/#{source.id}/badges", stranger),
- params: { link_url: example_url, image_url: example_url2 }
+ params: {link_url: example_url, image_url: example_url2}
end
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger developer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
post api("/#{source_type.pluralize}/#{source.id}/badges", user),
- params: { link_url: example_url, image_url: example_url2 }
+ params: {link_url: example_url, image_url: example_url2}
expect(response).to have_gitlab_http_status(403)
end
@@ -122,69 +122,69 @@ describe API::Badges do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'creates a new badge' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ it "creates a new badge" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
- params: { link_url: example_url, image_url: example_url2 }
+ params: {link_url: example_url, image_url: example_url2}
expect(response).to have_gitlab_http_status(201)
- end.to change { source.badges.count }.by(1)
+ }.to change { source.badges.count }.by(1)
- expect(json_response['link_url']).to eq(example_url)
- expect(json_response['image_url']).to eq(example_url2)
- expect(json_response['kind']).to eq source_type
+ expect(json_response["link_url"]).to eq(example_url)
+ expect(json_response["image_url"]).to eq(example_url2)
+ expect(json_response["kind"]).to eq source_type
end
end
- it 'returns 400 when link_url is not given' do
+ it "returns 400 when link_url is not given" do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
- params: { link_url: example_url }
+ params: {link_url: example_url}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when image_url is not given' do
+ it "returns 400 when image_url is not given" do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
- params: { image_url: example_url2 }
+ params: {image_url: example_url2}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when link_url or image_url is not valid' do
+ it "returns 400 when link_url or image_url is not valid" do
post api("/#{source_type.pluralize}/#{source.id}/badges", maintainer),
- params: { link_url: 'whatever', image_url: 'whatever' }
+ params: {link_url: "whatever", image_url: "whatever"}
expect(response).to have_gitlab_http_status(400)
end
end
end
- shared_examples 'PUT /:sources/:id/badges/:badge_id' do |source_type|
- include_context 'source helpers'
+ shared_examples "PUT /:sources/:id/badges/:badge_id" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
context "with :sources == #{source_type.pluralize}" do
let(:badge) { source.badges.first }
- let(:example_url) { 'http://www.example.com' }
- let(:example_url2) { 'http://www.example1.com' }
+ let(:example_url) { "http://www.example.com" }
+ let(:example_url2) { "http://www.example1.com" }
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", stranger),
- params: { link_url: example_url }
+ params: {link_url: example_url}
end
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger developer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user),
- params: { link_url: example_url }
+ params: {link_url: example_url}
expect(response).to have_gitlab_http_status(403)
end
@@ -192,43 +192,43 @@ describe API::Badges do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'updates the member' do
+ context "when authenticated as a maintainer/owner" do
+ it "updates the member" do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer),
- params: { link_url: example_url, image_url: example_url2 }
+ params: {link_url: example_url, image_url: example_url2}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['link_url']).to eq(example_url)
- expect(json_response['image_url']).to eq(example_url2)
- expect(json_response['kind']).to eq source_type
+ expect(json_response["link_url"]).to eq(example_url)
+ expect(json_response["image_url"]).to eq(example_url2)
+ expect(json_response["kind"]).to eq source_type
end
end
- it 'returns 400 when link_url or image_url is not valid' do
+ it "returns 400 when link_url or image_url is not valid" do
put api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer),
- params: { link_url: 'whatever', image_url: 'whatever' }
+ params: {link_url: "whatever", image_url: "whatever"}
expect(response).to have_gitlab_http_status(400)
end
end
end
- shared_examples 'DELETE /:sources/:id/badges/:badge_id' do |source_type|
- include_context 'source helpers'
+ shared_examples "DELETE /:sources/:id/badges/:badge_id" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
context "with :sources == #{source_type.pluralize}" do
let(:badge) { source.badges.first }
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { delete api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", stranger) }
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester developer stranger].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
delete api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", user)
@@ -239,21 +239,21 @@ describe API::Badges do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'deletes the badge' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ it "deletes the badge" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer)
expect(response).to have_gitlab_http_status(204)
- end.to change { source.badges.count }.by(-1)
+ }.to change { source.badges.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/#{source_type.pluralize}/#{source.id}/badges/#{badge.id}", maintainer) }
end
end
- it 'returns 404 if badge does not exist' do
+ it "returns 404 if badge does not exist" do
delete api("/#{source_type.pluralize}/#{source.id}/badges/123", maintainer)
expect(response).to have_gitlab_http_status(404)
@@ -261,24 +261,24 @@ describe API::Badges do
end
end
- shared_examples 'GET /:sources/:id/badges/render' do |source_type|
- include_context 'source helpers'
+ shared_examples "GET /:sources/:id/badges/render" do |source_type|
+ include_context "source helpers"
let(:source) { get_source(source_type) }
- let(:example_url) { 'http://www.example.com' }
- let(:example_url2) { 'http://www.example1.com' }
+ let(:example_url) { "http://www.example.com" }
+ let(:example_url2) { "http://www.example1.com" }
context "with :sources == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}&image_url=#{example_url2}", stranger)
end
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger developer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}&image_url=#{example_url2}", user)
@@ -289,33 +289,33 @@ describe API::Badges do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'gets the rendered badge values' do
+ context "when authenticated as a maintainer/owner" do
+ it "gets the rendered badge values" do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}&image_url=#{example_url2}", maintainer)
expect(response).to have_gitlab_http_status(200)
- expect(json_response.keys).to contain_exactly('link_url', 'rendered_link_url', 'image_url', 'rendered_image_url')
- expect(json_response['link_url']).to eq(example_url)
- expect(json_response['image_url']).to eq(example_url2)
- expect(json_response['rendered_link_url']).to eq(example_url)
- expect(json_response['rendered_image_url']).to eq(example_url2)
+ expect(json_response.keys).to contain_exactly("link_url", "rendered_link_url", "image_url", "rendered_image_url")
+ expect(json_response["link_url"]).to eq(example_url)
+ expect(json_response["image_url"]).to eq(example_url2)
+ expect(json_response["rendered_link_url"]).to eq(example_url)
+ expect(json_response["rendered_image_url"]).to eq(example_url2)
end
end
- it 'returns 400 when link_url is not given' do
+ it "returns 400 when link_url is not given" do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=#{example_url}", maintainer)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when image_url is not given' do
+ it "returns 400 when image_url is not given" do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?image_url=#{example_url}", maintainer)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when link_url or image_url is not valid' do
+ it "returns 400 when link_url or image_url is not valid" do
get api("/#{source_type.pluralize}/#{source.id}/badges/render?link_url=whatever&image_url=whatever", maintainer)
expect(response).to have_gitlab_http_status(400)
@@ -323,9 +323,9 @@ describe API::Badges do
end
end
- context 'when deleting a badge' do
- context 'and the source is a project' do
- it 'cannot delete badges owned by the project group' do
+ context "when deleting a badge" do
+ context "and the source is a project" do
+ it "cannot delete badges owned by the project group" do
delete api("/projects/#{project.id}/badges/#{project_group.badges.first.id}", maintainer)
expect(response).to have_gitlab_http_status(403)
@@ -333,14 +333,14 @@ describe API::Badges do
end
end
- describe 'Endpoints' do
- %w(project group).each do |source_type|
- it_behaves_like 'GET /:sources/:id/badges', source_type
- it_behaves_like 'GET /:sources/:id/badges/:badge_id', source_type
- it_behaves_like 'GET /:sources/:id/badges/render', source_type
- it_behaves_like 'POST /:sources/:id/badges', source_type
- it_behaves_like 'PUT /:sources/:id/badges/:badge_id', source_type
- it_behaves_like 'DELETE /:sources/:id/badges/:badge_id', source_type
+ describe "Endpoints" do
+ %w[project group].each do |source_type|
+ it_behaves_like "GET /:sources/:id/badges", source_type
+ it_behaves_like "GET /:sources/:id/badges/:badge_id", source_type
+ it_behaves_like "GET /:sources/:id/badges/render", source_type
+ it_behaves_like "POST /:sources/:id/badges", source_type
+ it_behaves_like "PUT /:sources/:id/badges/:badge_id", source_type
+ it_behaves_like "DELETE /:sources/:id/badges/:badge_id", source_type
end
end
diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb
index de79e8c4c5c..e80df38b954 100644
--- a/spec/requests/api/boards_spec.rb
+++ b/spec/requests/api/boards_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Boards do
set(:user) { create(:user) }
set(:non_member) { create(:user) }
set(:guest) { create(:user) }
set(:admin) { create(:user, :admin) }
- set(:board_parent) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
+ set(:board_parent) { create(:project, :public, creator_id: user.id, namespace: user.namespace) }
set(:dev_label) do
- create(:label, title: 'Development', color: '#FFAABB', project: board_parent)
+ create(:label, title: "Development", color: "#FFAABB", project: board_parent)
end
set(:test_label) do
- create(:label, title: 'Testing', color: '#FFAACC', project: board_parent)
+ create(:label, title: "Testing", color: "#FFAACC", project: board_parent)
end
set(:ux_label) do
- create(:label, title: 'UX', color: '#FF0000', project: board_parent)
+ create(:label, title: "UX", color: "#FF0000", project: board_parent)
end
set(:dev_list) do
@@ -31,24 +31,24 @@ describe API::Boards do
set(:board_label) { create(:label, project: board_parent) }
set(:board) { create(:board, project: board_parent, lists: [dev_list, test_list]) }
- it_behaves_like 'group and project boards', "/projects/:id/boards"
+ it_behaves_like "group and project boards", "/projects/:id/boards"
describe "POST /projects/:id/boards/lists" do
let(:url) { "/projects/#{board_parent.id}/boards/#{board.id}/lists" }
- it 'creates a new issue board list for group labels' do
+ it "creates a new issue board list for group labels" do
group = create(:group)
group_label = create(:group_label, group: group)
board_parent.update(group: group)
- post api(url, user), params: { label_id: group_label.id }
+ post api(url, user), params: {label_id: group_label.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['label']['name']).to eq(group_label.title)
- expect(json_response['position']).to eq(3)
+ expect(json_response["label"]["name"]).to eq(group_label.title)
+ expect(json_response["position"]).to eq(3)
end
- it 'creates a new board list for ancestor group labels' do
+ it "creates a new board list for ancestor group labels" do
group = create(:group)
sub_group = create(:group, parent: group)
group_label = create(:group_label, group: group)
@@ -56,27 +56,27 @@ describe API::Boards do
group.add_developer(user)
sub_group.add_developer(user)
- post api(url, user), params: { label_id: group_label.id }
+ post api(url, user), params: {label_id: group_label.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['label']['name']).to eq(group_label.title)
+ expect(json_response["label"]["name"]).to eq(group_label.title)
end
end
describe "POST /groups/:id/boards/lists", :nested_groups do
set(:group) { create(:group) }
- set(:board_parent) { create(:group, parent: group ) }
+ set(:board_parent) { create(:group, parent: group) }
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
set(:board) { create(:board, group: board_parent) }
- it 'creates a new board list for ancestor group labels' do
+ it "creates a new board list for ancestor group labels" do
group.add_developer(user)
group_label = create(:group_label, group: group)
- post api(url, user), params: { label_id: group_label.id }
+ post api(url, user), params: {label_id: group_label.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['label']['name']).to eq(group_label.title)
+ expect(json_response["label"]["name"]).to eq(group_label.title)
end
end
end
diff --git a/spec/requests/api/branches_spec.rb b/spec/requests/api/branches_spec.rb
index b38cd66986f..fa191105fc6 100644
--- a/spec/requests/api/branches_spec.rb
+++ b/spec/requests/api/branches_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Branches do
set(:user) { create(:user) }
- let(:project) { create(:project, :repository, creator: user, path: 'my.project') }
+ let(:project) { create(:project, :repository, creator: user, path: "my.project") }
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
- let(:branch_name) { 'feature' }
- let(:branch_sha) { '0b4bc9a49b562e85de7cc9e834518ea6828729b9' }
- let(:branch_with_dot) { project.repository.find_branch('ends-with.json') }
- let(:branch_with_slash) { project.repository.find_branch('improve/awesome') }
+ let(:branch_name) { "feature" }
+ let(:branch_sha) { "0b4bc9a49b562e85de7cc9e834518ea6828729b9" }
+ let(:branch_with_dot) { project.repository.find_branch("ends-with.json") }
+ let(:branch_with_slash) { project.repository.find_branch("improve/awesome") }
let(:project_id) { project.id }
let(:current_user) { nil }
@@ -19,88 +19,88 @@ describe API::Branches do
describe "GET /projects/:id/repository/branches" do
let(:route) { "/projects/#{project_id}/repository/branches" }
- shared_examples_for 'repository branches' do
+ shared_examples_for "repository branches" do
RSpec::Matchers.define :has_merged_branch_names_count do |expected|
match do |actual|
actual[:merged_branch_names].count == expected
end
end
- it 'returns the repository branches' do
- get api(route, current_user), params: { per_page: 100 }
+ it "returns the repository branches" do
+ get api(route, current_user), params: {per_page: 100}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branches')
+ expect(response).to match_response_schema("public_api/v4/branches")
expect(response).to include_pagination_headers
- branch_names = json_response.map { |x| x['name'] }
+ branch_names = json_response.map { |x| x["name"] }
expect(branch_names).to match_array(project.repository.branch_names)
end
- it 'determines only a limited number of merged branch names' do
+ it "determines only a limited number of merged branch names" do
expect(API::Entities::Branch).to receive(:represent).with(anything, has_merged_branch_names_count(2))
- get api(route, current_user), params: { per_page: 2 }
+ get api(route, current_user), params: {per_page: 2}
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when search parameter is passed' do
- context 'and branch exists' do
- it 'returns correct branches' do
- get api(route, user), params: { per_page: 100, search: branch_name }
+ context "when search parameter is passed" do
+ context "and branch exists" do
+ it "returns correct branches" do
+ get api(route, user), params: {per_page: 100, search: branch_name}
- searched_branch_names = json_response.map { |branch| branch['name'] }
+ searched_branch_names = json_response.map { |branch| branch["name"] }
project_branch_names = project.repository.branch_names.grep(/#{branch_name}/)
expect(searched_branch_names).to match_array(project_branch_names)
end
end
- context 'and branch does not exist' do
- it 'returns an empty array' do
- get api(route, user), params: { per_page: 100, search: 'no_such_branch_name_entropy_of_jabadabadu' }
+ context "and branch does not exist" do
+ it "returns an empty array" do
+ get api(route, user), params: {per_page: 100, search: "no_such_branch_name_entropy_of_jabadabadu"}
expect(json_response).to eq []
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
before do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it_behaves_like 'repository branches'
+ it_behaves_like "repository branches"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository branches'
+ it_behaves_like "repository branches"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository branches'
+ it_behaves_like "repository branches"
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
@@ -109,16 +109,16 @@ describe API::Branches do
describe "GET /projects/:id/repository/branches/:branch" do
let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}" }
- shared_examples_for 'repository branch' do
- context 'HEAD request' do
- it 'returns 204 No Content' do
+ shared_examples_for "repository branch" do
+ context "HEAD request" do
+ it "returns 204 No Content" do
head api(route, user)
expect(response).to have_gitlab_http_status(204)
expect(response.body).to be_empty
end
- it 'returns 404 Not Found' do
+ it "returns 404 Not Found" do
head api("/projects/#{project_id}/repository/branches/unknown", user)
expect(response).to have_gitlab_http_status(404)
@@ -126,107 +126,107 @@ describe API::Branches do
end
end
- it 'returns the repository branch' do
+ it "returns the repository branch" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
end
- context 'when branch does not exist' do
- let(:branch_name) { 'unknown' }
+ context "when branch does not exist" do
+ let(:branch_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Branch Not Found' }
+ let(:message) { "404 Branch Not Found" }
end
end
- context 'when the branch refname is invalid' do
- let(:branch_name) { 'branch*' }
- let(:message) { 'The branch refname is invalid' }
+ context "when the branch refname is invalid" do
+ let(:branch_name) { "branch*" }
+ let(:message) { "The branch refname is invalid" }
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
before do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
- it 'returns that the current user cannot push' do
+ it "returns that the current user cannot push" do
get api(route, current_user)
- expect(json_response['can_push']).to eq(false)
+ expect(json_response["can_push"]).to eq(false)
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
- it 'returns that the current user can push' do
+ it "returns that the current user can push" do
get api(route, current_user)
- expect(json_response['can_push']).to eq(true)
+ expect(json_response["can_push"]).to eq(true)
end
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:branch_name) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:branch_name) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
end
end
end
- context 'when authenticated', 'as a developer and branch is protected' do
+ context "when authenticated", "as a developer and branch is protected" do
let(:current_user) { create(:user) }
let!(:protected_branch) { create(:protected_branch, project: project, name: branch_name) }
@@ -234,408 +234,408 @@ describe API::Branches do
project.add_developer(current_user)
end
- it_behaves_like 'repository branch'
+ it_behaves_like "repository branch"
- it 'returns that the current user cannot push' do
+ it "returns that the current user cannot push" do
get api(route, current_user)
- expect(json_response['can_push']).to eq(false)
+ expect(json_response["can_push"]).to eq(false)
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
end
- describe 'PUT /projects/:id/repository/branches/:branch/protect' do
+ describe "PUT /projects/:id/repository/branches/:branch/protect" do
let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}/protect" }
- shared_examples_for 'repository new protected branch' do
- it 'protects a single branch' do
+ shared_examples_for "repository new protected branch" do
+ it "protects a single branch" do
put api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
- expect(json_response['protected']).to eq(true)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
+ expect(json_response["protected"]).to eq(true)
end
- it 'protects a single branch and developers can push' do
- put api(route, current_user), params: { developers_can_push: true }
+ it "protects a single branch and developers can push" do
+ put api(route, current_user), params: {developers_can_push: true}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
- expect(json_response['protected']).to eq(true)
- expect(json_response['developers_can_push']).to eq(true)
- expect(json_response['developers_can_merge']).to eq(false)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
+ expect(json_response["protected"]).to eq(true)
+ expect(json_response["developers_can_push"]).to eq(true)
+ expect(json_response["developers_can_merge"]).to eq(false)
end
- it 'protects a single branch and developers can merge' do
- put api(route, current_user), params: { developers_can_merge: true }
+ it "protects a single branch and developers can merge" do
+ put api(route, current_user), params: {developers_can_merge: true}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
- expect(json_response['protected']).to eq(true)
- expect(json_response['developers_can_push']).to eq(false)
- expect(json_response['developers_can_merge']).to eq(true)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
+ expect(json_response["protected"]).to eq(true)
+ expect(json_response["developers_can_push"]).to eq(false)
+ expect(json_response["developers_can_merge"]).to eq(true)
end
- it 'protects a single branch and developers can push and merge' do
- put api(route, current_user), params: { developers_can_push: true, developers_can_merge: true }
+ it "protects a single branch and developers can push and merge" do
+ put api(route, current_user), params: {developers_can_push: true, developers_can_merge: true}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
- expect(json_response['protected']).to eq(true)
- expect(json_response['developers_can_push']).to eq(true)
- expect(json_response['developers_can_merge']).to eq(true)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
+ expect(json_response["protected"]).to eq(true)
+ expect(json_response["developers_can_push"]).to eq(true)
+ expect(json_response["developers_can_merge"]).to eq(true)
end
- context 'when branch does not exist' do
- let(:branch_name) { 'unknown' }
+ context "when branch does not exist" do
+ let(:branch_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { put api(route, current_user) }
- let(:message) { '404 Branch Not Found' }
+ let(:message) { "404 Branch Not Found" }
end
end
- context 'when the branch refname is invalid' do
- let(:branch_name) { 'branch*' }
- let(:message) { 'The branch refname is invalid' }
+ context "when the branch refname is invalid" do
+ let(:branch_name) { "branch*" }
+ let(:message) { "The branch refname is invalid" }
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) { put api(route, current_user) }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { put api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { put api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { put api(route, guest) }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
context "when a protected branch doesn't already exist" do
- it_behaves_like 'repository new protected branch'
+ it_behaves_like "repository new protected branch"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository new protected branch'
+ it_behaves_like "repository new protected branch"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:branch_name) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { put api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:branch_name) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'repository new protected branch'
+ it_behaves_like "repository new protected branch"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository new protected branch'
+ it_behaves_like "repository new protected branch"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository new protected branch'
+ it_behaves_like "repository new protected branch"
end
end
end
- context 'when protected branch already exists' do
+ context "when protected branch already exists" do
before do
- project.repository.add_branch(user, protected_branch.name, 'master')
+ project.repository.add_branch(user, protected_branch.name, "master")
end
- context 'when developers can push and merge' do
- let(:protected_branch) { create(:protected_branch, :developers_can_push, :developers_can_merge, project: project, name: 'protected_branch') }
+ context "when developers can push and merge" do
+ let(:protected_branch) { create(:protected_branch, :developers_can_push, :developers_can_merge, project: project, name: "protected_branch") }
- it 'updates that a developer cannot push or merge' do
+ it "updates that a developer cannot push or merge" do
put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user),
- params: { developers_can_push: false, developers_can_merge: false }
+ params: {developers_can_push: false, developers_can_merge: false}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(protected_branch.name)
- expect(json_response['protected']).to eq(true)
- expect(json_response['developers_can_push']).to eq(false)
- expect(json_response['developers_can_merge']).to eq(false)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(protected_branch.name)
+ expect(json_response["protected"]).to eq(true)
+ expect(json_response["developers_can_push"]).to eq(false)
+ expect(json_response["developers_can_merge"]).to eq(false)
expect(protected_branch.reload.push_access_levels.first.access_level).to eq(Gitlab::Access::MAINTAINER)
expect(protected_branch.reload.merge_access_levels.first.access_level).to eq(Gitlab::Access::MAINTAINER)
end
end
- context 'when developers cannot push or merge' do
- let(:protected_branch) { create(:protected_branch, project: project, name: 'protected_branch') }
+ context "when developers cannot push or merge" do
+ let(:protected_branch) { create(:protected_branch, project: project, name: "protected_branch") }
- it 'updates that a developer can push and merge' do
+ it "updates that a developer can push and merge" do
put api("/projects/#{project.id}/repository/branches/#{protected_branch.name}/protect", user),
- params: { developers_can_push: true, developers_can_merge: true }
+ params: {developers_can_push: true, developers_can_merge: true}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(protected_branch.name)
- expect(json_response['protected']).to eq(true)
- expect(json_response['developers_can_push']).to eq(true)
- expect(json_response['developers_can_merge']).to eq(true)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(protected_branch.name)
+ expect(json_response["protected"]).to eq(true)
+ expect(json_response["developers_can_push"]).to eq(true)
+ expect(json_response["developers_can_merge"]).to eq(true)
end
end
end
end
end
- describe 'PUT /projects/:id/repository/branches/:branch/unprotect' do
+ describe "PUT /projects/:id/repository/branches/:branch/unprotect" do
let(:route) { "/projects/#{project_id}/repository/branches/#{branch_name}/unprotect" }
- shared_examples_for 'repository unprotected branch' do
- it 'unprotects a single branch' do
+ shared_examples_for "repository unprotected branch" do
+ it "unprotects a single branch" do
put api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq(CGI.unescape(branch_name))
- expect(json_response['protected']).to eq(false)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq(CGI.unescape(branch_name))
+ expect(json_response["protected"]).to eq(false)
end
- context 'when branch does not exist' do
- let(:branch_name) { 'unknown' }
+ context "when branch does not exist" do
+ let(:branch_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { put api(route, current_user) }
- let(:message) { '404 Branch Not Found' }
+ let(:message) { "404 Branch Not Found" }
end
end
- context 'when the branch refname is invalid' do
- let(:branch_name) { 'branch*' }
- let(:message) { 'The branch refname is invalid' }
+ context "when the branch refname is invalid" do
+ let(:branch_name) { "branch*" }
+ let(:message) { "The branch refname is invalid" }
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) { put api(route, current_user) }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { put api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { put api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { put api(route, guest) }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
context "when a protected branch doesn't already exist" do
- it_behaves_like 'repository unprotected branch'
+ it_behaves_like "repository unprotected branch"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository unprotected branch'
+ it_behaves_like "repository unprotected branch"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:branch_name) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { put api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:branch_name) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'repository unprotected branch'
+ it_behaves_like "repository unprotected branch"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository unprotected branch'
+ it_behaves_like "repository unprotected branch"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:branch_name) { branch_with_dot.name }
- it_behaves_like 'repository unprotected branch'
+ it_behaves_like "repository unprotected branch"
end
end
end
end
end
- describe 'POST /projects/:id/repository/branches' do
+ describe "POST /projects/:id/repository/branches" do
let(:route) { "/projects/#{project_id}/repository/branches" }
- shared_examples_for 'repository new branch' do
- it 'creates a new branch' do
- post api(route, current_user), params: { branch: 'feature1', ref: branch_sha }
+ shared_examples_for "repository new branch" do
+ it "creates a new branch" do
+ post api(route, current_user), params: {branch: "feature1", ref: branch_sha}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/branch')
- expect(json_response['name']).to eq('feature1')
- expect(json_response['commit']['id']).to eq(branch_sha)
+ expect(response).to match_response_schema("public_api/v4/branch")
+ expect(json_response["name"]).to eq("feature1")
+ expect(json_response["commit"]["id"]).to eq(branch_sha)
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { post api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { post api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { post api(route, guest) }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
context "when a protected branch doesn't already exist" do
- it_behaves_like 'repository new branch'
+ it_behaves_like "repository new branch"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository new branch'
+ it_behaves_like "repository new branch"
end
end
end
- it 'returns 400 if branch name is invalid' do
- post api(route, user), params: { branch: 'new design', ref: branch_sha }
+ it "returns 400 if branch name is invalid" do
+ post api(route, user), params: {branch: "new design", ref: branch_sha}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Branch name is invalid')
+ expect(json_response["message"]).to eq("Branch name is invalid")
end
- it 'returns 400 if branch already exists' do
- post api(route, user), params: { branch: 'new_design1', ref: branch_sha }
+ it "returns 400 if branch already exists" do
+ post api(route, user), params: {branch: "new_design1", ref: branch_sha}
expect(response).to have_gitlab_http_status(201)
- post api(route, user), params: { branch: 'new_design1', ref: branch_sha }
+ post api(route, user), params: {branch: "new_design1", ref: branch_sha}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Branch already exists')
+ expect(json_response["message"]).to eq("Branch already exists")
end
- it 'returns 400 if ref name is invalid' do
- post api(route, user), params: { branch: 'new_design3', ref: 'foo' }
+ it "returns 400 if ref name is invalid" do
+ post api(route, user), params: {branch: "new_design3", ref: "foo"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Invalid reference name')
+ expect(json_response["message"]).to eq("Invalid reference name")
end
end
- describe 'DELETE /projects/:id/repository/branches/:branch' do
+ describe "DELETE /projects/:id/repository/branches/:branch" do
before do
allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true)
end
- it 'removes branch' do
+ it "removes branch" do
delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user)
expect(response).to have_gitlab_http_status(204)
end
- it 'removes a branch with dots in the branch name' do
+ it "removes a branch with dots in the branch name" do
delete api("/projects/#{project.id}/repository/branches/#{branch_with_dot.name}", user)
expect(response).to have_gitlab_http_status(204)
end
- it 'returns 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_gitlab_http_status(404)
end
- context 'when the branch refname is invalid' do
- let(:branch_name) { 'branch*' }
- let(:message) { 'The branch refname is invalid' }
+ context "when the branch refname is invalid" do
+ let(:branch_name) { "branch*" }
+ let(:message) { "The branch refname is invalid" }
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) { delete api("/projects/#{project.id}/repository/branches/#{branch_name}", user) }
end
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/repository/branches/#{branch_name}", user) }
end
end
- describe 'DELETE /projects/:id/repository/merged_branches' do
+ describe "DELETE /projects/:id/repository/merged_branches" do
before do
allow_any_instance_of(Repository).to receive(:rm_branch).and_return(true)
end
- it 'returns 202 with json body' do
+ it "returns 202 with json body" do
delete api("/projects/#{project.id}/repository/merged_branches", user)
expect(response).to have_gitlab_http_status(202)
- expect(json_response['message']).to eql('202 Accepted')
+ expect(json_response["message"]).to eql("202 Accepted")
end
- it 'returns a 403 error if guest' do
+ it "returns a 403 error if guest" do
delete api("/projects/#{project.id}/repository/merged_branches", guest)
expect(response).to have_gitlab_http_status(403)
diff --git a/spec/requests/api/broadcast_messages_spec.rb b/spec/requests/api/broadcast_messages_spec.rb
index 0b48b79219c..bb5598431b3 100644
--- a/spec/requests/api/broadcast_messages_spec.rb
+++ b/spec/requests/api/broadcast_messages_spec.rb
@@ -1,181 +1,181 @@
-require 'spec_helper'
+require "spec_helper"
describe API::BroadcastMessages do
set(:user) { create(:user) }
set(:admin) { create(:admin) }
set(:message) { create(:broadcast_message) }
- describe 'GET /broadcast_messages' do
- it 'returns a 401 for anonymous users' do
- get api('/broadcast_messages')
+ describe "GET /broadcast_messages" do
+ it "returns a 401 for anonymous users" do
+ get api("/broadcast_messages")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
- get api('/broadcast_messages', user)
+ it "returns a 403 for users" do
+ get api("/broadcast_messages", user)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns an Array of BroadcastMessages for admins' do
+ it "returns an Array of BroadcastMessages for admins" do
create(:broadcast_message)
- get api('/broadcast_messages', admin)
+ get api("/broadcast_messages", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_kind_of(Array)
expect(json_response.first.keys)
- .to match_array(%w(id message starts_at ends_at color font active))
+ .to match_array(%w[id message starts_at ends_at color font active])
end
end
- describe 'GET /broadcast_messages/:id' do
- it 'returns a 401 for anonymous users' do
+ describe "GET /broadcast_messages/:id" do
+ it "returns a 401 for anonymous users" do
get api("/broadcast_messages/#{message.id}")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
+ it "returns a 403 for users" do
get api("/broadcast_messages/#{message.id}", user)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns the specified message for admins' do
+ it "returns the specified message for admins" do
get api("/broadcast_messages/#{message.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq message.id
+ expect(json_response["id"]).to eq message.id
expect(json_response.keys)
- .to match_array(%w(id message starts_at ends_at color font active))
+ .to match_array(%w[id message starts_at ends_at color font active])
end
end
- describe 'POST /broadcast_messages' do
- it 'returns a 401 for anonymous users' do
- post api('/broadcast_messages'), params: attributes_for(:broadcast_message)
+ describe "POST /broadcast_messages" do
+ it "returns a 401 for anonymous users" do
+ post api("/broadcast_messages"), params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
- post api('/broadcast_messages', user), params: attributes_for(:broadcast_message)
+ it "returns a 403 for users" do
+ post api("/broadcast_messages", user), params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
end
- context 'as an admin' do
- it 'requires the `message` parameter' do
+ context "as an admin" do
+ it "requires the `message` parameter" do
attrs = attributes_for(:broadcast_message)
attrs.delete(:message)
- post api('/broadcast_messages', admin), params: attrs
+ post api("/broadcast_messages", admin), params: attrs
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq 'message is missing'
+ expect(json_response["error"]).to eq "message is missing"
end
- it 'defines sane default start and end times' do
- time = Time.zone.parse('2016-07-02 10:11:12')
+ it "defines sane default start and end times" do
+ time = Time.zone.parse("2016-07-02 10:11:12")
travel_to(time) do
- post api('/broadcast_messages', admin), params: { message: 'Test message' }
+ post api("/broadcast_messages", admin), params: {message: "Test message"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z'
- expect(json_response['ends_at']).to eq '2016-07-02T11:11:12.000Z'
+ expect(json_response["starts_at"]).to eq "2016-07-02T10:11:12.000Z"
+ expect(json_response["ends_at"]).to eq "2016-07-02T11:11:12.000Z"
end
end
- it 'accepts a custom background and foreground color' do
- attrs = attributes_for(:broadcast_message, color: '#000000', font: '#cecece')
+ it "accepts a custom background and foreground color" do
+ attrs = attributes_for(:broadcast_message, color: "#000000", font: "#cecece")
- post api('/broadcast_messages', admin), params: attrs
+ post api("/broadcast_messages", admin), params: attrs
expect(response).to have_gitlab_http_status(201)
- expect(json_response['color']).to eq attrs[:color]
- expect(json_response['font']).to eq attrs[:font]
+ expect(json_response["color"]).to eq attrs[:color]
+ expect(json_response["font"]).to eq attrs[:font]
end
end
end
- describe 'PUT /broadcast_messages/:id' do
- it 'returns a 401 for anonymous users' do
+ describe "PUT /broadcast_messages/:id" do
+ it "returns a 401 for anonymous users" do
put api("/broadcast_messages/#{message.id}"),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
+ it "returns a 403 for users" do
put api("/broadcast_messages/#{message.id}", user),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
end
- context 'as an admin' do
- it 'accepts new background and foreground colors' do
- attrs = { color: '#000000', font: '#cecece' }
+ context "as an admin" do
+ it "accepts new background and foreground colors" do
+ attrs = {color: "#000000", font: "#cecece"}
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
- expect(json_response['color']).to eq attrs[:color]
- expect(json_response['font']).to eq attrs[:font]
+ expect(json_response["color"]).to eq attrs[:color]
+ expect(json_response["font"]).to eq attrs[:font]
end
- it 'accepts new start and end times' do
- time = Time.zone.parse('2016-07-02 10:11:12')
+ it "accepts new start and end times" do
+ time = Time.zone.parse("2016-07-02 10:11:12")
travel_to(time) do
- attrs = { starts_at: Time.zone.now, ends_at: 3.hours.from_now }
+ attrs = {starts_at: Time.zone.now, ends_at: 3.hours.from_now}
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
- expect(json_response['starts_at']).to eq '2016-07-02T10:11:12.000Z'
- expect(json_response['ends_at']).to eq '2016-07-02T13:11:12.000Z'
+ expect(json_response["starts_at"]).to eq "2016-07-02T10:11:12.000Z"
+ expect(json_response["ends_at"]).to eq "2016-07-02T13:11:12.000Z"
end
end
- it 'accepts a new message' do
- attrs = { message: 'new message' }
+ it "accepts a new message" do
+ attrs = {message: "new message"}
put api("/broadcast_messages/#{message.id}", admin), params: attrs
expect(response).to have_gitlab_http_status(200)
- expect { message.reload }.to change { message.message }.to('new message')
+ expect { message.reload }.to change { message.message }.to("new message")
end
end
end
- describe 'DELETE /broadcast_messages/:id' do
- it 'returns a 401 for anonymous users' do
+ describe "DELETE /broadcast_messages/:id" do
+ it "returns a 401 for anonymous users" do
delete api("/broadcast_messages/#{message.id}"),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
+ it "returns a 403 for users" do
delete api("/broadcast_messages/#{message.id}", user),
params: attributes_for(:broadcast_message)
expect(response).to have_gitlab_http_status(403)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/broadcast_messages/#{message.id}", admin) }
end
- it 'deletes the broadcast message for admins' do
- expect do
+ it "deletes the broadcast message for admins" do
+ expect {
delete api("/broadcast_messages/#{message.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { BroadcastMessage.count }.by(-1)
+ }.to change { BroadcastMessage.count }.by(-1)
end
end
end
diff --git a/spec/requests/api/circuit_breakers_spec.rb b/spec/requests/api/circuit_breakers_spec.rb
index 6c7cb151c74..105aaed4acb 100644
--- a/spec/requests/api/circuit_breakers_spec.rb
+++ b/spec/requests/api/circuit_breakers_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe API::CircuitBreakers do
set(:user) { create(:user) }
set(:admin) { create(:admin) }
- describe 'GET circuit_breakers/repository_storage' do
- it 'returns a 401 for anonymous users' do
- get api('/circuit_breakers/repository_storage')
+ describe "GET circuit_breakers/repository_storage" do
+ it "returns a 401 for anonymous users" do
+ get api("/circuit_breakers/repository_storage")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
- get api('/circuit_breakers/repository_storage', user)
+ it "returns a 403 for users" do
+ get api("/circuit_breakers/repository_storage", user)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns an Array of storages' do
- get api('/circuit_breakers/repository_storage', admin)
+ it "returns an Array of storages" do
+ get api("/circuit_breakers/repository_storage", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_kind_of(Array)
expect(json_response).to be_empty
end
- describe 'GET circuit_breakers/repository_storage/failing' do
- it 'returns an array of failing storages' do
- get api('/circuit_breakers/repository_storage/failing', admin)
+ describe "GET circuit_breakers/repository_storage/failing" do
+ it "returns an array of failing storages" do
+ get api("/circuit_breakers/repository_storage/failing", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_kind_of(Array)
@@ -36,9 +36,9 @@ describe API::CircuitBreakers do
end
end
- describe 'DELETE circuit_breakers/repository_storage' do
- it 'clears all circuit_breakers' do
- delete api('/circuit_breakers/repository_storage', admin)
+ describe "DELETE circuit_breakers/repository_storage" do
+ it "clears all circuit_breakers" do
+ delete api("/circuit_breakers/repository_storage", admin)
expect(response).to have_gitlab_http_status(204)
end
diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb
index 9388343c392..33987da94ab 100644
--- a/spec/requests/api/commit_statuses_spec.rb
+++ b/spec/requests/api/commit_statuses_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::CommitStatuses do
let!(:project) { create(:project, :repository) }
@@ -15,61 +15,61 @@ describe API::CommitStatuses do
describe "GET /projects/:id/repository/commits/:sha/statuses" do
let(:get_url) { "/projects/#{project.id}/repository/commits/#{sha}/statuses" }
- context 'ci commit exists' do
- let!(:master) { project.ci_pipelines.create(source: :push, sha: commit.id, ref: 'master', protected: false) }
- let!(:develop) { project.ci_pipelines.create(source: :push, sha: commit.id, ref: 'develop', protected: false) }
+ context "ci commit exists" do
+ let!(:master) { project.ci_pipelines.create(source: :push, sha: commit.id, ref: "master", protected: false) }
+ let!(:develop) { project.ci_pipelines.create(source: :push, sha: commit.id, ref: "develop", protected: false) }
context "reporter user" do
- let(:statuses_id) { json_response.map { |status| status['id'] } }
+ let(:statuses_id) { json_response.map { |status| status["id"] } }
def create_status(commit, opts = {})
- create(:commit_status, { pipeline: commit, ref: commit.ref }.merge(opts))
+ create(:commit_status, {pipeline: commit, ref: commit.ref}.merge(opts))
end
- let!(:status1) { create_status(master, status: 'running', retried: true) }
- let!(:status2) { create_status(master, name: 'coverage', status: 'pending', retried: true) }
- let!(:status3) { create_status(develop, status: 'running', allow_failure: true) }
- let!(:status4) { create_status(master, name: 'coverage', status: 'success') }
- let!(:status5) { create_status(develop, name: 'coverage', status: 'success') }
- let!(:status6) { create_status(master, status: 'success') }
+ let!(:status1) { create_status(master, status: "running", retried: true) }
+ let!(:status2) { create_status(master, name: "coverage", status: "pending", retried: true) }
+ let!(:status3) { create_status(develop, status: "running", allow_failure: true) }
+ let!(:status4) { create_status(master, name: "coverage", status: "success") }
+ let!(:status5) { create_status(develop, name: "coverage", status: "success") }
+ let!(:status6) { create_status(master, status: "success") }
- context 'latest commit statuses' do
+ context "latest commit statuses" do
before do
get api(get_url, reporter)
end
- it 'returns latest commit statuses' do
+ it "returns latest commit statuses" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status3.id, status4.id, status5.id, status6.id)
- json_response.sort_by! { |status| status['id'] }
- expect(json_response.map { |status| status['allow_failure'] }).to eq([true, false, false, false])
+ json_response.sort_by! { |status| status["id"] }
+ expect(json_response.map { |status| status["allow_failure"] }).to eq([true, false, false, false])
end
end
- context 'all commit statuses' do
+ context "all commit statuses" do
before do
- get api(get_url, reporter), params: { all: 1 }
+ get api(get_url, reporter), params: {all: 1}
end
- it 'returns all commit statuses' do
+ it "returns all commit statuses" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(statuses_id).to contain_exactly(status1.id, status2.id,
- status3.id, status4.id,
- status5.id, status6.id)
+ status3.id, status4.id,
+ status5.id, status6.id)
end
end
- context 'latest commit statuses for specific ref' do
+ context "latest commit statuses for specific ref" do
before do
- get api(get_url, reporter), params: { ref: 'develop' }
+ get api(get_url, reporter), params: {ref: "develop"}
end
- it 'returns latest commit statuses for specific ref' do
+ it "returns latest commit statuses for specific ref" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
@@ -77,12 +77,12 @@ describe API::CommitStatuses do
end
end
- context 'latest commit statues for specific name' do
+ context "latest commit statues for specific name" do
before do
- get api(get_url, reporter), params: { name: 'coverage' }
+ get api(get_url, reporter), params: {name: "coverage"}
end
- it 'return latest commit statuses for specific name' do
+ it "return latest commit statuses for specific name" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
@@ -92,12 +92,12 @@ describe API::CommitStatuses do
end
end
- context 'ci commit does not exist' do
+ context "ci commit does not exist" do
before do
get api(get_url, reporter)
end
- it 'returns empty array' do
+ it "returns empty array" do
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response).to be_empty
@@ -125,77 +125,77 @@ describe API::CommitStatuses do
end
end
- describe 'POST /projects/:id/statuses/:sha' do
+ describe "POST /projects/:id/statuses/:sha" do
let(:post_url) { "/projects/#{project.id}/statuses/#{sha}" }
- context 'developer user' do
+ context "developer user" do
%w[pending running success failed canceled].each do |status|
context "for #{status}" do
- context 'uses only required parameters' do
- it 'creates commit status' do
- post api(post_url, developer), params: { state: status }
+ context "uses only required parameters" do
+ it "creates commit status" do
+ post api(post_url, developer), params: {state: status}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['sha']).to eq(commit.id)
- expect(json_response['status']).to eq(status)
- expect(json_response['name']).to eq('default')
- expect(json_response['ref']).not_to be_empty
- expect(json_response['target_url']).to be_nil
- expect(json_response['description']).to be_nil
-
- if status == 'failed'
- expect(CommitStatus.find(json_response['id'])).to be_api_failure
+ expect(json_response["sha"]).to eq(commit.id)
+ expect(json_response["status"]).to eq(status)
+ expect(json_response["name"]).to eq("default")
+ expect(json_response["ref"]).not_to be_empty
+ expect(json_response["target_url"]).to be_nil
+ expect(json_response["description"]).to be_nil
+
+ if status == "failed"
+ expect(CommitStatus.find(json_response["id"])).to be_api_failure
end
end
end
end
end
- context 'transitions status from pending' do
+ context "transitions status from pending" do
before do
- post api(post_url, developer), params: { state: 'pending' }
+ post api(post_url, developer), params: {state: "pending"}
end
%w[running success failed canceled].each do |status|
it "to #{status}" do
- expect { post api(post_url, developer), params: { state: status } }.not_to change { CommitStatus.count }
+ expect { post api(post_url, developer), params: {state: status} }.not_to change { CommitStatus.count }
expect(response).to have_gitlab_http_status(201)
- expect(json_response['status']).to eq(status)
+ expect(json_response["status"]).to eq(status)
end
end
end
- context 'with all optional parameters' do
- context 'when creating a commit status' do
+ context "with all optional parameters" do
+ context "when creating a commit status" do
subject do
post api(post_url, developer), params: {
- state: 'success',
- context: 'coverage',
- ref: 'master',
- description: 'test',
+ state: "success",
+ context: "coverage",
+ ref: "master",
+ description: "test",
coverage: 80.0,
- target_url: 'http://gitlab.com/status'
+ target_url: "http://gitlab.com/status",
}
end
- it 'creates commit status' do
+ it "creates commit status" do
subject
expect(response).to have_gitlab_http_status(201)
- expect(json_response['sha']).to eq(commit.id)
- expect(json_response['status']).to eq('success')
- expect(json_response['name']).to eq('coverage')
- expect(json_response['ref']).to eq('master')
- expect(json_response['coverage']).to eq(80.0)
- expect(json_response['description']).to eq('test')
- expect(json_response['target_url']).to eq('http://gitlab.com/status')
+ expect(json_response["sha"]).to eq(commit.id)
+ expect(json_response["status"]).to eq("success")
+ expect(json_response["name"]).to eq("coverage")
+ expect(json_response["ref"]).to eq("master")
+ expect(json_response["coverage"]).to eq(80.0)
+ expect(json_response["description"]).to eq("test")
+ expect(json_response["target_url"]).to eq("http://gitlab.com/status")
end
- context 'when merge request exists for given branch' do
- let!(:merge_request) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'develop') }
+ context "when merge request exists for given branch" do
+ let!(:merge_request) { create(:merge_request, source_project: project, source_branch: "master", target_branch: "develop") }
- it 'sets head pipeline' do
+ it "sets head pipeline" do
subject
expect(response).to have_gitlab_http_status(201)
@@ -204,139 +204,139 @@ describe API::CommitStatuses do
end
end
- context 'when updatig a commit status' do
+ context "when updatig a commit status" do
before do
post api(post_url, developer), params: {
- state: 'running',
- context: 'coverage',
- ref: 'master',
- description: 'coverage test',
+ state: "running",
+ context: "coverage",
+ ref: "master",
+ description: "coverage test",
coverage: 0.0,
- target_url: 'http://gitlab.com/status'
+ target_url: "http://gitlab.com/status",
}
post api(post_url, developer), params: {
- state: 'success',
- name: 'coverage',
- ref: 'master',
- description: 'new description',
- coverage: 90.0
+ state: "success",
+ name: "coverage",
+ ref: "master",
+ description: "new description",
+ coverage: 90.0,
}
end
- it 'updates a commit status' do
+ it "updates a commit status" do
expect(response).to have_gitlab_http_status(201)
- expect(json_response['sha']).to eq(commit.id)
- expect(json_response['status']).to eq('success')
- expect(json_response['name']).to eq('coverage')
- expect(json_response['ref']).to eq('master')
- expect(json_response['coverage']).to eq(90.0)
- expect(json_response['description']).to eq('new description')
- expect(json_response['target_url']).to eq('http://gitlab.com/status')
+ expect(json_response["sha"]).to eq(commit.id)
+ expect(json_response["status"]).to eq("success")
+ expect(json_response["name"]).to eq("coverage")
+ expect(json_response["ref"]).to eq("master")
+ expect(json_response["coverage"]).to eq(90.0)
+ expect(json_response["description"]).to eq("new description")
+ expect(json_response["target_url"]).to eq("http://gitlab.com/status")
end
- it 'does not create a new commit status' do
+ it "does not create a new commit status" do
expect(CommitStatus.count).to eq 1
end
end
end
- context 'when retrying a commit status' do
+ context "when retrying a commit status" do
before do
post api(post_url, developer),
- params: { state: 'failed', name: 'test', ref: 'master' }
+ params: {state: "failed", name: "test", ref: "master"}
post api(post_url, developer),
- params: { state: 'success', name: 'test', ref: 'master' }
+ params: {state: "success", name: "test", ref: "master"}
end
- it 'correctly posts a new commit status' do
+ it "correctly posts a new commit status" do
expect(response).to have_gitlab_http_status(201)
- expect(json_response['sha']).to eq(commit.id)
- expect(json_response['status']).to eq('success')
+ expect(json_response["sha"]).to eq(commit.id)
+ expect(json_response["status"]).to eq("success")
end
- it 'retries a commit status' do
+ it "retries a commit status" do
expect(CommitStatus.count).to eq 2
expect(CommitStatus.first).to be_retried
expect(CommitStatus.last.pipeline).to be_success
end
end
- context 'when status is invalid' do
+ context "when status is invalid" do
before do
- post api(post_url, developer), params: { state: 'invalid' }
+ post api(post_url, developer), params: {state: "invalid"}
end
- it 'does not create commit status' do
+ it "does not create commit status" do
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when request without a state made' do
+ context "when request without a state made" do
before do
post api(post_url, developer)
end
- it 'does not create commit status' do
+ it "does not create commit status" do
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when commit SHA is invalid' do
- let(:sha) { 'invalid_sha' }
+ context "when commit SHA is invalid" do
+ let(:sha) { "invalid_sha" }
before do
- post api(post_url, developer), params: { state: 'running' }
+ post api(post_url, developer), params: {state: "running"}
end
- it 'returns not found error' do
+ it "returns not found error" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when target URL is an invalid address' do
+ context "when target URL is an invalid address" do
before do
post api(post_url, developer), params: {
- state: 'pending',
- target_url: 'invalid url'
- }
+ state: "pending",
+ target_url: "invalid url",
+ }
end
- it 'responds with bad request status and validation errors' do
+ it "responds with bad request status and validation errors" do
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['target_url'])
- .to include 'is blocked: Only allowed protocols are http, https'
+ expect(json_response["message"]["target_url"])
+ .to include "is blocked: Only allowed protocols are http, https"
end
end
end
- context 'reporter user' do
+ context "reporter user" do
before do
- post api(post_url, reporter), params: { state: 'running' }
+ post api(post_url, reporter), params: {state: "running"}
end
- it 'does not create commit status' do
+ it "does not create commit status" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'guest user' do
+ context "guest user" do
before do
- post api(post_url, guest), params: { state: 'running' }
+ post api(post_url, guest), params: {state: "running"}
end
- it 'does not create commit status' do
+ it "does not create commit status" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
before do
post api(post_url)
end
- it 'does not create commit status' do
+ it "does not create commit status" do
expect(response).to have_gitlab_http_status(401)
end
end
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 066f1d6862a..97471b17528 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
-require 'mime/types'
+require "spec_helper"
+require "mime/types"
describe API::Commits do
let(:user) { create(:user) }
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
- let(:project) { create(:project, :repository, creator: user, path: 'my.project') }
- let(:branch_with_dot) { project.repository.find_branch('ends-with.json') }
- let(:branch_with_slash) { project.repository.find_branch('improve/awesome') }
+ let(:project) { create(:project, :repository, creator: user, path: "my.project") }
+ let(:branch_with_dot) { project.repository.find_branch("ends-with.json") }
+ let(:branch_with_slash) { project.repository.find_branch("improve/awesome") }
let(:project_id) { project.id }
let(:current_user) { nil }
@@ -15,10 +15,10 @@ describe API::Commits do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/repository/commits' do
+ describe "GET /projects/:id/repository/commits" do
let(:route) { "/projects/#{project_id}/repository/commits" }
- shared_examples_for 'project commits' do |schema: 'public_api/v4/commits'|
+ shared_examples_for "project commits" do |schema: "public_api/v4/commits"|
it "returns project commits" do
commit = project.repository.commit
@@ -26,39 +26,39 @@ describe API::Commits do
expect(response).to have_gitlab_http_status(200)
expect(response).to match_response_schema(schema)
- expect(json_response.first['id']).to eq(commit.id)
- expect(json_response.first['committer_name']).to eq(commit.committer_name)
- expect(json_response.first['committer_email']).to eq(commit.committer_email)
+ expect(json_response.first["id"]).to eq(commit.id)
+ expect(json_response.first["committer_name"]).to eq(commit.committer_name)
+ expect(json_response.first["committer_email"]).to eq(commit.committer_email)
end
- it 'include correct pagination headers' do
- commit_count = project.repository.count_commits(ref: 'master').to_s
+ it "include correct pagination headers" do
+ commit_count = project.repository.count_commits(ref: "master").to_s
get api(route, current_user)
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
- expect(response.headers['X-Page']).to eql('1')
+ expect(response.headers["X-Total"]).to eq(commit_count)
+ expect(response.headers["X-Page"]).to eql("1")
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'project commits'
+ it_behaves_like "project commits"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'project commits'
+ it_behaves_like "project commits"
context "since optional parameter" do
it "returns project commits since provided parameter" do
@@ -72,16 +72,16 @@ describe API::Commits do
expect(json_response.second["id"]).to eq(commits.second.id)
end
- it 'include correct pagination headers' do
+ it "include correct pagination headers" do
commits = project.repository.commits("master", limit: 2)
after = commits.second.created_at
- commit_count = project.repository.count_commits(ref: 'master', after: after).to_s
+ commit_count = project.repository.count_commits(ref: "master", after: after).to_s
get api("/projects/#{project_id}/repository/commits?since=#{after.utc.iso8601}", user)
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
- expect(response.headers['X-Page']).to eql('1')
+ expect(response.headers["X-Total"]).to eq(commit_count)
+ expect(response.headers["X-Page"]).to eql("1")
end
end
@@ -102,16 +102,16 @@ describe API::Commits do
expect(json_response.second["id"]).to eq(commits.third.id)
end
- it 'include correct pagination headers' do
+ it "include correct pagination headers" do
commits = project.repository.commits("master", limit: 2)
before = commits.second.created_at
- commit_count = project.repository.count_commits(ref: 'master', before: before).to_s
+ commit_count = project.repository.count_commits(ref: "master", before: before).to_s
get api("/projects/#{project_id}/repository/commits?until=#{before.utc.iso8601}", user)
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
- expect(response.headers['X-Page']).to eql('1')
+ expect(response.headers["X-Total"]).to eq(commit_count)
+ expect(response.headers["X-Page"]).to eql("1")
end
end
@@ -120,101 +120,101 @@ describe API::Commits do
get api("/projects/#{project_id}/repository/commits?since=invalid-date", user)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('since is invalid')
+ expect(json_response["error"]).to eq("since is invalid")
end
end
context "path optional parameter" do
it "returns project commits matching provided path parameter" do
- path = 'files/ruby/popen.rb'
- commit_count = project.repository.count_commits(ref: 'master', path: path).to_s
+ path = "files/ruby/popen.rb"
+ commit_count = project.repository.count_commits(ref: "master", path: path).to_s
get api("/projects/#{project_id}/repository/commits?path=#{path}", user)
expect(json_response.size).to eq(3)
expect(json_response.first["id"]).to eq("570e7b2abdd848b95f2f578043fc23bd6f6fd24d")
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
+ expect(response.headers["X-Total"]).to eq(commit_count)
end
- it 'include correct pagination headers' do
- path = 'files/ruby/popen.rb'
- commit_count = project.repository.count_commits(ref: 'master', path: path).to_s
+ it "include correct pagination headers" do
+ path = "files/ruby/popen.rb"
+ commit_count = project.repository.count_commits(ref: "master", path: path).to_s
get api("/projects/#{project_id}/repository/commits?path=#{path}", user)
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
- expect(response.headers['X-Page']).to eql('1')
+ expect(response.headers["X-Total"]).to eq(commit_count)
+ expect(response.headers["X-Page"]).to eql("1")
end
end
- context 'all optional parameter' do
- it 'returns all project commits' do
+ context "all optional parameter" do
+ it "returns all project commits" do
commit_count = project.repository.count_commits(all: true)
get api("/projects/#{project_id}/repository/commits?all=true", user)
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count.to_s)
- expect(response.headers['X-Page']).to eql('1')
+ expect(response.headers["X-Total"]).to eq(commit_count.to_s)
+ expect(response.headers["X-Page"]).to eql("1")
end
end
- context 'with_stats optional parameter' do
+ context "with_stats optional parameter" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'project commits', schema: 'public_api/v4/commits_with_stats' do
+ it_behaves_like "project commits", schema: "public_api/v4/commits_with_stats" do
let(:route) { "/projects/#{project_id}/repository/commits?with_stats=true" }
- it 'include commits details' do
+ it "include commits details" do
commit = project.repository.commit
get api(route, current_user)
- expect(json_response.first['stats']['additions']).to eq(commit.stats.additions)
- expect(json_response.first['stats']['deletions']).to eq(commit.stats.deletions)
- expect(json_response.first['stats']['total']).to eq(commit.stats.total)
+ expect(json_response.first["stats"]["additions"]).to eq(commit.stats.additions)
+ expect(json_response.first["stats"]["deletions"]).to eq(commit.stats.deletions)
+ expect(json_response.first["stats"]["total"]).to eq(commit.stats.total)
end
end
end
- context 'with pagination params' do
+ context "with pagination params" do
let(:page) { 1 }
let(:per_page) { 5 }
- let(:ref_name) { 'master' }
+ let(:ref_name) { "master" }
let!(:request) do
get api("/projects/#{project_id}/repository/commits?page=#{page}&per_page=#{per_page}&ref_name=#{ref_name}", user)
end
- it 'returns correct headers' do
+ it "returns correct headers" do
commit_count = project.repository.count_commits(ref: ref_name).to_s
expect(response).to include_pagination_headers
- expect(response.headers['X-Total']).to eq(commit_count)
- expect(response.headers['X-Page']).to eq('1')
- expect(response.headers['Link']).to match(/page=1&per_page=5/)
- expect(response.headers['Link']).to match(/page=2&per_page=5/)
+ expect(response.headers["X-Total"]).to eq(commit_count)
+ expect(response.headers["X-Page"]).to eq("1")
+ expect(response.headers["Link"]).to match(/page=1&per_page=5/)
+ expect(response.headers["Link"]).to match(/page=2&per_page=5/)
end
- context 'viewing the first page' do
- it 'returns the first 5 commits' do
+ context "viewing the first page" do
+ it "returns the first 5 commits" do
commit = project.repository.commit
expect(json_response.size).to eq(per_page)
- expect(json_response.first['id']).to eq(commit.id)
- expect(response.headers['X-Page']).to eq('1')
+ expect(json_response.first["id"]).to eq(commit.id)
+ expect(response.headers["X-Page"]).to eq("1")
end
end
- context 'viewing the third page' do
+ context "viewing the third page" do
let(:page) { 3 }
- it 'returns the third 5 commits' do
- commit = project.repository.commits('HEAD', limit: per_page, offset: (page - 1) * per_page).first
+ it "returns the third 5 commits" do
+ commit = project.repository.commits("HEAD", limit: per_page, offset: (page - 1) * per_page).first
expect(json_response.size).to eq(per_page)
- expect(json_response.first['id']).to eq(commit.id)
- expect(response.headers['X-Page']).to eq('3')
+ expect(json_response.first["id"]).to eq(commit.id)
+ expect(response.headers["X-Page"]).to eq("3")
end
end
end
@@ -224,94 +224,94 @@ describe API::Commits do
describe "POST /projects/:id/repository/commits" do
let!(:url) { "/projects/#{project_id}/repository/commits" }
- it 'returns a 403 unauthorized for user without permissions' do
+ it "returns a 403 unauthorized for user without permissions" do
post api(url, guest)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns a 400 bad request if no params are given' do
+ it "returns a 400 bad request if no params are given" do
post api(url, user)
expect(response).to have_gitlab_http_status(400)
end
- describe 'create' do
- let(:message) { 'Created a new file with a very very looooooooooooooooooooooooooooooooooooooooooooooong commit message' }
+ describe "create" do
+ let(:message) { "Created a new file with a very very looooooooooooooooooooooooooooooooooooooooooooooong commit message" }
let(:invalid_c_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'create',
- file_path: 'files/ruby/popen.rb',
- content: 'puts 8'
- }
- ]
+ action: "create",
+ file_path: "files/ruby/popen.rb",
+ content: "puts 8",
+ },
+ ],
}
end
let(:valid_c_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'create',
- file_path: 'foo/bar/baz.txt',
- content: 'puts 8'
- }
- ]
+ action: "create",
+ file_path: "foo/bar/baz.txt",
+ content: "puts 8",
+ },
+ ],
}
end
let(:valid_utf8_c_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'create',
- file_path: 'foo/bar/baz.txt',
- content: 'puts 🦊'
- }
- ]
+ action: "create",
+ file_path: "foo/bar/baz.txt",
+ content: "puts 🦊",
+ },
+ ],
}
end
- it 'does not increment the usage counters using access token authentication' do
+ it "does not increment the usage counters using access token authentication" do
expect(::Gitlab::WebIdeCommitsCounter).not_to receive(:increment)
post api(url, user), params: valid_c_params
end
- it 'a new file in project repo' do
+ it "a new file in project repo" do
post api(url, user), params: valid_c_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
- expect(json_response['committer_name']).to eq(user.name)
- expect(json_response['committer_email']).to eq(user.email)
+ expect(json_response["title"]).to eq(message)
+ expect(json_response["committer_name"]).to eq(user.name)
+ expect(json_response["committer_email"]).to eq(user.email)
end
- it 'a new file with utf8 chars in project repo' do
+ it "a new file with utf8 chars in project repo" do
post api(url, user), params: valid_utf8_c_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
- expect(json_response['committer_name']).to eq(user.name)
- expect(json_response['committer_email']).to eq(user.email)
+ expect(json_response["title"]).to eq(message)
+ expect(json_response["committer_name"]).to eq(user.name)
+ expect(json_response["committer_email"]).to eq(user.email)
end
- it 'returns a 400 bad request if file exists' do
+ it "returns a 400 bad request if file exists" do
post api(url, user), params: invalid_c_params
expect(response).to have_gitlab_http_status(400)
end
- context 'with project path containing a dot in URL' do
+ context "with project path containing a dot in URL" do
let(:url) { "/projects/#{CGI.escape(project.full_path)}/repository/commits" }
- it 'a new file in project repo' do
+ it "a new file in project repo" do
post api(url, user), params: valid_c_params
expect(response).to have_gitlab_http_status(201)
@@ -319,1131 +319,1131 @@ describe API::Commits do
end
end
- describe 'delete' do
- let(:message) { 'Deleted file' }
+ describe "delete" do
+ let(:message) { "Deleted file" }
let(:invalid_d_params) do
{
- branch: 'markdown',
+ branch: "markdown",
commit_message: message,
actions: [
{
- action: 'delete',
- file_path: 'doc/api/projects.md'
- }
- ]
+ action: "delete",
+ file_path: "doc/api/projects.md",
+ },
+ ],
}
end
let(:valid_d_params) do
{
- branch: 'markdown',
+ branch: "markdown",
commit_message: message,
actions: [
{
- action: 'delete',
- file_path: 'doc/api/users.md'
- }
- ]
+ action: "delete",
+ file_path: "doc/api/users.md",
+ },
+ ],
}
end
- it 'an existing file in project repo' do
+ it "an existing file in project repo" do
post api(url, user), params: valid_d_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
- it 'returns a 400 bad request if file does not exist' do
+ it "returns a 400 bad request if file does not exist" do
post api(url, user), params: invalid_d_params
expect(response).to have_gitlab_http_status(400)
end
end
- describe 'move' do
- let(:message) { 'Moved file' }
+ describe "move" do
+ let(:message) { "Moved file" }
let(:invalid_m_params) do
{
- branch: 'feature',
+ branch: "feature",
commit_message: message,
actions: [
{
- action: 'move',
- file_path: 'CHANGELOG',
- previous_path: 'VERSION',
- content: '6.7.0.pre'
- }
- ]
+ action: "move",
+ file_path: "CHANGELOG",
+ previous_path: "VERSION",
+ content: "6.7.0.pre",
+ },
+ ],
}
end
let(:valid_m_params) do
{
- branch: 'feature',
+ branch: "feature",
commit_message: message,
actions: [
{
- action: 'move',
- file_path: 'VERSION.txt',
- previous_path: 'VERSION',
- content: '6.7.0.pre'
- }
- ]
+ action: "move",
+ file_path: "VERSION.txt",
+ previous_path: "VERSION",
+ content: "6.7.0.pre",
+ },
+ ],
}
end
- it 'an existing file in project repo' do
+ it "an existing file in project repo" do
post api(url, user), params: valid_m_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
- it 'returns a 400 bad request if file does not exist' do
+ it "returns a 400 bad request if file does not exist" do
post api(url, user), params: invalid_m_params
expect(response).to have_gitlab_http_status(400)
end
end
- describe 'update' do
- let(:message) { 'Updated file' }
+ describe "update" do
+ let(:message) { "Updated file" }
let(:invalid_u_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'update',
- file_path: 'foo/bar.baz',
- content: 'puts 8'
- }
- ]
+ action: "update",
+ file_path: "foo/bar.baz",
+ content: "puts 8",
+ },
+ ],
}
end
let(:valid_u_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'update',
- file_path: 'files/ruby/popen.rb',
- content: 'puts 8'
- }
- ]
+ action: "update",
+ file_path: "files/ruby/popen.rb",
+ content: "puts 8",
+ },
+ ],
}
end
- it 'an existing file in project repo' do
+ it "an existing file in project repo" do
post api(url, user), params: valid_u_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
- it 'returns a 400 bad request if file does not exist' do
+ it "returns a 400 bad request if file does not exist" do
post api(url, user), params: invalid_u_params
expect(response).to have_gitlab_http_status(400)
end
end
- describe 'chmod' do
- let(:message) { 'Chmod +x file' }
- let(:file_path) { 'files/ruby/popen.rb' }
+ describe "chmod" do
+ let(:message) { "Chmod +x file" }
+ let(:file_path) { "files/ruby/popen.rb" }
let(:execute_filemode) { true }
let(:params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'chmod',
+ action: "chmod",
file_path: file_path,
- execute_filemode: execute_filemode
- }
- ]
+ execute_filemode: execute_filemode,
+ },
+ ],
}
end
- it 'responds with success' do
+ it "responds with success" do
post api(url, user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
- context 'when execute_filemode is false' do
+ context "when execute_filemode is false" do
let(:execute_filemode) { false }
- it 'responds with success' do
+ it "responds with success" do
post api(url, user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
end
context "when the file doesn't exists" do
- let(:file_path) { 'foo/bar.baz' }
+ let(:file_path) { "foo/bar.baz" }
it "responds with 400" do
post api(url, user), params: params
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq("A file with this name doesn't exist")
+ expect(json_response["message"]).to eq("A file with this name doesn't exist")
end
end
end
- describe 'multiple operations' do
- let(:message) { 'Multiple actions' }
+ describe "multiple operations" do
+ let(:message) { "Multiple actions" }
let(:invalid_mo_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'create',
- file_path: 'files/ruby/popen.rb',
- content: 'puts 8'
+ action: "create",
+ file_path: "files/ruby/popen.rb",
+ content: "puts 8",
},
{
- action: 'delete',
- file_path: 'doc/api/projects.md'
+ action: "delete",
+ file_path: "doc/api/projects.md",
},
{
- action: 'move',
- file_path: 'CHANGELOG',
- previous_path: 'VERSION',
- content: '6.7.0.pre'
+ action: "move",
+ file_path: "CHANGELOG",
+ previous_path: "VERSION",
+ content: "6.7.0.pre",
},
{
- action: 'update',
- file_path: 'foo/bar.baz',
- content: 'puts 8'
+ action: "update",
+ file_path: "foo/bar.baz",
+ content: "puts 8",
},
{
- action: 'chmod',
- file_path: 'files/ruby/popen.rb',
- execute_filemode: true
- }
- ]
+ action: "chmod",
+ file_path: "files/ruby/popen.rb",
+ execute_filemode: true,
+ },
+ ],
}
end
let(:valid_mo_params) do
{
- branch: 'master',
+ branch: "master",
commit_message: message,
actions: [
{
- action: 'create',
- file_path: 'foo/bar/baz.txt',
- content: 'puts 8'
+ action: "create",
+ file_path: "foo/bar/baz.txt",
+ content: "puts 8",
},
{
- action: 'delete',
- file_path: 'Gemfile.zip'
+ action: "delete",
+ file_path: "Gemfile.zip",
},
{
- action: 'move',
- file_path: 'VERSION.txt',
- previous_path: 'VERSION',
- content: '6.7.0.pre'
+ action: "move",
+ file_path: "VERSION.txt",
+ previous_path: "VERSION",
+ content: "6.7.0.pre",
},
{
- action: 'update',
- file_path: 'files/ruby/popen.rb',
- content: 'puts 8'
+ action: "update",
+ file_path: "files/ruby/popen.rb",
+ content: "puts 8",
},
{
- action: 'chmod',
- file_path: 'files/ruby/popen.rb',
- execute_filemode: true
- }
- ]
+ action: "chmod",
+ file_path: "files/ruby/popen.rb",
+ execute_filemode: true,
+ },
+ ],
}
end
- it 'are committed as one in project repo' do
+ it "are committed as one in project repo" do
post api(url, user), params: valid_mo_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(message)
+ expect(json_response["title"]).to eq(message)
end
- it 'includes the commit stats' do
+ it "includes the commit stats" do
post api(url, user), params: valid_mo_params
expect(response).to have_gitlab_http_status(201)
- expect(json_response).to include 'stats'
+ expect(json_response).to include "stats"
end
it "doesn't include the commit stats when stats is false" do
post api(url, user), params: valid_mo_params.merge(stats: false)
expect(response).to have_gitlab_http_status(201)
- expect(json_response).not_to include 'stats'
+ expect(json_response).not_to include "stats"
end
- it 'return a 400 bad request if there are any issues' do
+ it "return a 400 bad request if there are any issues" do
post api(url, user), params: invalid_mo_params
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when committing into a fork as a maintainer' do
- include_context 'merge request allowing collaboration'
+ context "when committing into a fork as a maintainer" do
+ include_context "merge request allowing collaboration"
let(:project_id) { forked_project.id }
def push_params(branch_name)
{
branch: branch_name,
- commit_message: 'Hello world',
+ commit_message: "Hello world",
actions: [
{
- action: 'create',
- file_path: 'foo/bar/baz.txt',
- content: 'puts 8'
- }
- ]
+ action: "create",
+ file_path: "foo/bar/baz.txt",
+ content: "puts 8",
+ },
+ ],
}
end
- it 'allows pushing to the source branch of the merge request' do
- post api(url, user), params: push_params('feature')
+ it "allows pushing to the source branch of the merge request" do
+ post api(url, user), params: push_params("feature")
expect(response).to have_gitlab_http_status(:created)
end
- it 'denies pushing to another branch' do
- post api(url, user), params: push_params('other-branch')
+ it "denies pushing to another branch" do
+ post api(url, user), params: push_params("other-branch")
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
- describe 'GET /projects/:id/repository/commits/:sha/refs' do
+ describe "GET /projects/:id/repository/commits/:sha/refs" do
let(:project) { create(:project, :public, :repository) }
- let(:tag) { project.repository.find_tag('v1.1.0') }
+ let(:tag) { project.repository.find_tag("v1.1.0") }
let(:commit_id) { tag.dereferenced_target.id }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/refs" }
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Commit Not Found' }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'for a valid commit' do
- it 'returns all refs with no scope' do
- get api(route, current_user), params: { per_page: 100 }
+ context "for a valid commit" do
+ it "returns all refs with no scope" do
+ get api(route, current_user), params: {per_page: 100}
- refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
- refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]})
+ refs = project.repository.branch_names_contains(commit_id).map {|name| ["branch", name]}
+ refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ["tag", name]})
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
+ expect(json_response.map { |r| [r["type"], r["name"]] }.compact).to eq(refs)
end
- it 'returns all refs' do
- get api(route, current_user), params: { type: 'all', per_page: 100 }
+ it "returns all refs" do
+ get api(route, current_user), params: {type: "all", per_page: 100}
- refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
- refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]})
+ refs = project.repository.branch_names_contains(commit_id).map {|name| ["branch", name]}
+ refs.concat(project.repository.tag_names_contains(commit_id).map {|name| ["tag", name]})
expect(response).to have_gitlab_http_status(200)
- expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
+ expect(json_response.map { |r| [r["type"], r["name"]] }.compact).to eq(refs)
end
- it 'returns the branch refs' do
- get api(route, current_user), params: { type: 'branch', per_page: 100 }
+ it "returns the branch refs" do
+ get api(route, current_user), params: {type: "branch", per_page: 100}
- refs = project.repository.branch_names_contains(commit_id).map {|name| ['branch', name]}
+ refs = project.repository.branch_names_contains(commit_id).map {|name| ["branch", name]}
expect(response).to have_gitlab_http_status(200)
- expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
+ expect(json_response.map { |r| [r["type"], r["name"]] }.compact).to eq(refs)
end
- it 'returns the tag refs' do
- get api(route, current_user), params: { type: 'tag', per_page: 100 }
+ it "returns the tag refs" do
+ get api(route, current_user), params: {type: "tag", per_page: 100}
- refs = project.repository.tag_names_contains(commit_id).map {|name| ['tag', name]}
+ refs = project.repository.tag_names_contains(commit_id).map {|name| ["tag", name]}
expect(response).to have_gitlab_http_status(200)
- expect(json_response.map { |r| [r['type'], r['name']] }.compact).to eq(refs)
+ expect(json_response.map { |r| [r["type"], r["name"]] }.compact).to eq(refs)
end
end
end
- describe 'GET /projects/:id/repository/commits/:sha' do
+ describe "GET /projects/:id/repository/commits/:sha" do
let(:commit) { project.repository.commit }
let(:commit_id) { commit.id }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}" }
- shared_examples_for 'ref commit' do
- it 'returns the ref last commit' do
+ shared_examples_for "ref commit" do
+ it "returns the ref last commit" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/commit/detail')
- expect(json_response['id']).to eq(commit.id)
- expect(json_response['short_id']).to eq(commit.short_id)
- expect(json_response['title']).to eq(commit.title)
- expect(json_response['message']).to eq(commit.safe_message)
- expect(json_response['author_name']).to eq(commit.author_name)
- expect(json_response['author_email']).to eq(commit.author_email)
- expect(json_response['authored_date']).to eq(commit.authored_date.iso8601(3))
- expect(json_response['committer_name']).to eq(commit.committer_name)
- expect(json_response['committer_email']).to eq(commit.committer_email)
- expect(json_response['committed_date']).to eq(commit.committed_date.iso8601(3))
- expect(json_response['parent_ids']).to eq(commit.parent_ids)
- expect(json_response['stats']['additions']).to eq(commit.stats.additions)
- expect(json_response['stats']['deletions']).to eq(commit.stats.deletions)
- expect(json_response['stats']['total']).to eq(commit.stats.total)
- expect(json_response['status']).to be_nil
- expect(json_response['last_pipeline']).to be_nil
- end
-
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
-
- it_behaves_like '404 response' do
+ expect(response).to match_response_schema("public_api/v4/commit/detail")
+ expect(json_response["id"]).to eq(commit.id)
+ expect(json_response["short_id"]).to eq(commit.short_id)
+ expect(json_response["title"]).to eq(commit.title)
+ expect(json_response["message"]).to eq(commit.safe_message)
+ expect(json_response["author_name"]).to eq(commit.author_name)
+ expect(json_response["author_email"]).to eq(commit.author_email)
+ expect(json_response["authored_date"]).to eq(commit.authored_date.iso8601(3))
+ expect(json_response["committer_name"]).to eq(commit.committer_name)
+ expect(json_response["committer_email"]).to eq(commit.committer_email)
+ expect(json_response["committed_date"]).to eq(commit.committed_date.iso8601(3))
+ expect(json_response["parent_ids"]).to eq(commit.parent_ids)
+ expect(json_response["stats"]["additions"]).to eq(commit.stats.additions)
+ expect(json_response["stats"]["deletions"]).to eq(commit.stats.deletions)
+ expect(json_response["stats"]["total"]).to eq(commit.stats.total)
+ expect(json_response["status"]).to be_nil
+ expect(json_response["last_pipeline"]).to be_nil
+ end
+
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
+
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Commit Not Found' }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when stat param' do
+ context "when stat param" do
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}" }
- it 'is not present return stats by default' do
+ it "is not present return stats by default" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include 'stats'
+ expect(json_response).to include "stats"
end
it "is false it does not include stats" do
- get api(route, user), params: { stats: false }
+ get api(route, user), params: {stats: false}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).not_to include 'stats'
+ expect(json_response).not_to include "stats"
end
it "is true it includes stats" do
- get api(route, user), params: { stats: true }
+ get api(route, user), params: {stats: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include 'stats'
+ expect(json_response).to include "stats"
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:commit_id) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:commit) { project.repository.commit(branch_with_slash.name) }
let(:commit_id) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref commit'
+ it_behaves_like "ref commit"
end
end
- context 'when the ref has a pipeline' do
- let!(:pipeline) { project.ci_pipelines.create(source: :push, ref: 'master', sha: commit.sha, protected: false) }
+ context "when the ref has a pipeline" do
+ let!(:pipeline) { project.ci_pipelines.create(source: :push, ref: "master", sha: commit.sha, protected: false) }
it 'includes a "created" status' do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/commit/detail')
- expect(json_response['status']).to eq('created')
- expect(json_response['last_pipeline']['id']).to eq(pipeline.id)
- expect(json_response['last_pipeline']['ref']).to eq(pipeline.ref)
- expect(json_response['last_pipeline']['sha']).to eq(pipeline.sha)
- expect(json_response['last_pipeline']['status']).to eq(pipeline.status)
+ expect(response).to match_response_schema("public_api/v4/commit/detail")
+ expect(json_response["status"]).to eq("created")
+ expect(json_response["last_pipeline"]["id"]).to eq(pipeline.id)
+ expect(json_response["last_pipeline"]["ref"]).to eq(pipeline.ref)
+ expect(json_response["last_pipeline"]["sha"]).to eq(pipeline.sha)
+ expect(json_response["last_pipeline"]["status"]).to eq(pipeline.status)
end
- context 'when pipeline succeeds' do
+ context "when pipeline succeeds" do
before do
- pipeline.update(status: 'success')
+ pipeline.update(status: "success")
end
it 'includes a "success" status' do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/commit/detail')
- expect(json_response['status']).to eq('success')
+ expect(response).to match_response_schema("public_api/v4/commit/detail")
+ expect(json_response["status"]).to eq("success")
end
end
end
end
end
- describe 'GET /projects/:id/repository/commits/:sha/diff' do
+ describe "GET /projects/:id/repository/commits/:sha/diff" do
let(:commit) { project.repository.commit }
let(:commit_id) { commit.id }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/diff" }
- shared_examples_for 'ref diff' do
- it 'returns the diff of the selected commit' do
+ shared_examples_for "ref diff" do
+ it "returns the diff of the selected commit" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to be >= 1
- expect(json_response.first.keys).to include 'diff'
+ expect(json_response.first.keys).to include "diff"
end
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Commit Not Found' }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:commit_id) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:commit_id) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
end
end
- context 'when binary diff are treated as text' do
- let(:commit_id) { TestEnv::BRANCH_SHA['add-pdf-text-binary'] }
+ context "when binary diff are treated as text" do
+ let(:commit_id) { TestEnv::BRANCH_SHA["add-pdf-text-binary"] }
- it_behaves_like 'ref diff'
+ it_behaves_like "ref diff"
end
end
end
- describe 'GET /projects/:id/repository/commits/:sha/comments' do
+ describe "GET /projects/:id/repository/commits/:sha/comments" do
let(:commit) { project.repository.commit }
let(:commit_id) { commit.id }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/comments" }
- shared_examples_for 'ref comments' do
- context 'when ref exists' do
+ shared_examples_for "ref comments" do
+ context "when ref exists" do
before do
- create(:note_on_commit, author: user, project: project, commit_id: commit.id, note: 'a comment on a commit')
- create(:note_on_commit, author: user, project: project, commit_id: commit.id, note: 'another comment on a commit')
+ create(:note_on_commit, author: user, project: project, commit_id: commit.id, note: "a comment on a commit")
+ create(:note_on_commit, author: user, project: project, commit_id: commit.id, note: "another comment on a commit")
end
- it 'returns the diff of the selected commit' do
+ it "returns the diff of the selected commit" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/commit_notes')
+ expect(response).to match_response_schema("public_api/v4/commit_notes")
expect(json_response.size).to eq(2)
- expect(json_response.first['note']).to eq('a comment on a commit')
- expect(json_response.first['author']['id']).to eq(user.id)
+ expect(json_response.first["note"]).to eq("a comment on a commit")
+ expect(json_response.first["author"]["id"]).to eq(user.id)
end
end
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Commit Not Found' }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
end
- context 'when branch contains a slash' do
+ context "when branch contains a slash" do
let(:commit) { project.repository.commit(branch_with_slash.name) }
let(:commit_id) { branch_with_slash.name }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when branch contains an escaped slash' do
+ context "when branch contains an escaped slash" do
let(:commit) { project.repository.commit(branch_with_slash.name) }
let(:commit_id) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
- context 'when branch contains a dot' do
+ context "when branch contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref comments'
+ it_behaves_like "ref comments"
end
end
end
- context 'when the commit is present on two projects' do
+ context "when the commit is present on two projects" do
let(:forked_project) { create(:project, :repository, creator: guest, namespace: guest.namespace) }
- let!(:forked_project_note) { create(:note_on_commit, author: guest, project: forked_project, commit_id: forked_project.repository.commit.id, note: 'a comment on a commit for fork') }
+ let!(:forked_project_note) { create(:note_on_commit, author: guest, project: forked_project, commit_id: forked_project.repository.commit.id, note: "a comment on a commit for fork") }
let(:project_id) { forked_project.id }
let(:commit_id) { forked_project.repository.commit.id }
- it 'returns the comments for the target project' do
+ it "returns the comments for the target project" do
get api(route, guest)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/commit_notes')
+ expect(response).to match_response_schema("public_api/v4/commit_notes")
expect(json_response.size).to eq(1)
- expect(json_response.first['note']).to eq('a comment on a commit for fork')
- expect(json_response.first['author']['id']).to eq(guest.id)
+ expect(json_response.first["note"]).to eq("a comment on a commit for fork")
+ expect(json_response.first["author"]["id"]).to eq(guest.id)
end
end
end
- describe 'POST :id/repository/commits/:sha/cherry_pick' do
- let(:commit) { project.commit('7d3b0f7cff5f37573aea97cebfd5692ea1689924') }
+ describe "POST :id/repository/commits/:sha/cherry_pick" do
+ let(:commit) { project.commit("7d3b0f7cff5f37573aea97cebfd5692ea1689924") }
let(:commit_id) { commit.id }
- let(:branch) { 'master' }
+ let(:branch) { "master" }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/cherry_pick" }
- shared_examples_for 'ref cherry-pick' do
- context 'when ref exists' do
- it 'cherry-picks the ref commit' do
- post api(route, current_user), params: { branch: branch }
+ shared_examples_for "ref cherry-pick" do
+ context "when ref exists" do
+ it "cherry-picks the ref commit" do
+ post api(route, current_user), params: {branch: branch}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/commit/basic')
- expect(json_response['title']).to eq(commit.title)
- expect(json_response['message']).to eq(commit.cherry_pick_message(user))
- expect(json_response['author_name']).to eq(commit.author_name)
- expect(json_response['committer_name']).to eq(user.name)
+ expect(response).to match_response_schema("public_api/v4/commit/basic")
+ expect(json_response["title"]).to eq(commit.title)
+ expect(json_response["message"]).to eq(commit.cherry_pick_message(user))
+ expect(json_response["author_name"]).to eq(commit.author_name)
+ expect(json_response["committer_name"]).to eq(user.name)
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
- let(:request) { post api(route, current_user), params: { branch: 'master' } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route, current_user), params: {branch: "master"} }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like '403 response' do
- let(:request) { post api(route), params: { branch: 'master' } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route), params: {branch: "master"} }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
- let(:request) { post api(route), params: { branch: 'master' } }
- let(:message) { '404 Project Not Found' }
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
+ let(:request) { post api(route), params: {branch: "master"} }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as an owner' do
+ context "when authenticated", "as an owner" do
let(:current_user) { user }
- it_behaves_like 'ref cherry-pick'
+ it_behaves_like "ref cherry-pick"
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { branch: 'master' } }
- let(:message) { '404 Commit Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {branch: "master"} }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when branch is missing' do
- it_behaves_like '400 response' do
+ context "when branch is missing" do
+ it_behaves_like "400 response" do
let(:request) { post api(route, current_user) }
end
end
- context 'when branch is empty' do
- ['', ' '].each do |branch|
- it_behaves_like '400 response' do
- let(:request) { post api(route, current_user), params: { branch: branch } }
+ context "when branch is empty" do
+ ["", " "].each do |branch|
+ it_behaves_like "400 response" do
+ let(:request) { post api(route, current_user), params: {branch: branch} }
end
end
end
- context 'when branch does not exist' do
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { branch: 'foo' } }
- let(:message) { '404 Branch Not Found' }
+ context "when branch does not exist" do
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {branch: "foo"} }
+ let(:message) { "404 Branch Not Found" }
end
end
- context 'when commit is already included in the target branch' do
- it_behaves_like '400 response' do
- let(:request) { post api(route, current_user), params: { branch: 'markdown' } }
+ context "when commit is already included in the target branch" do
+ it_behaves_like "400 response" do
+ let(:request) { post api(route, current_user), params: {branch: "markdown"} }
end
end
- context 'when ref contains a dot' do
+ context "when ref contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref cherry-pick'
+ it_behaves_like "ref cherry-pick"
end
- context 'when ref contains a slash' do
+ context "when ref contains a slash" do
let(:commit_id) { branch_with_slash.name }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { branch: 'master' } }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {branch: "master"} }
end
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'ref cherry-pick'
+ it_behaves_like "ref cherry-pick"
- context 'when ref contains a dot' do
+ context "when ref contains a dot" do
let(:commit) { project.repository.commit(branch_with_dot.name) }
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref cherry-pick'
+ it_behaves_like "ref cherry-pick"
end
end
end
- context 'when authenticated', 'as a developer' do
+ context "when authenticated", "as a developer" do
let(:current_user) { guest }
before do
project.add_developer(guest)
end
- context 'when branch is protected' do
+ context "when branch is protected" do
before do
- create(:protected_branch, project: project, name: 'feature')
+ create(:protected_branch, project: project, name: "feature")
end
- it 'returns 400 if you are not allowed to push to the target branch' do
- post api(route, current_user), params: { branch: 'feature' }
+ it "returns 400 if you are not allowed to push to the target branch" do
+ post api(route, current_user), params: {branch: "feature"}
expect(response).to have_gitlab_http_status(:forbidden)
- expect(json_response['message']).to match(/You are not allowed to push into this branch/)
+ expect(json_response["message"]).to match(/You are not allowed to push into this branch/)
end
end
end
- context 'when cherry picking to a fork as a maintainer' do
- include_context 'merge request allowing collaboration'
+ context "when cherry picking to a fork as a maintainer" do
+ include_context "merge request allowing collaboration"
let(:project_id) { forked_project.id }
- it 'allows access from a maintainer that to the source branch' do
- post api(route, user), params: { branch: 'feature' }
+ it "allows access from a maintainer that to the source branch" do
+ post api(route, user), params: {branch: "feature"}
expect(response).to have_gitlab_http_status(:created)
end
- it 'denies cherry picking to another branch' do
- post api(route, user), params: { branch: 'master' }
+ it "denies cherry picking to another branch" do
+ post api(route, user), params: {branch: "master"}
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
- describe 'POST :id/repository/commits/:sha/revert' do
- let(:commit_id) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
+ describe "POST :id/repository/commits/:sha/revert" do
+ let(:commit_id) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
let(:commit) { project.commit(commit_id) }
- let(:branch) { 'master' }
+ let(:branch) { "master" }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/revert" }
- shared_examples_for 'ref revert' do
- context 'when ref exists' do
- it 'reverts the ref commit' do
- post api(route, current_user), params: { branch: branch }
+ shared_examples_for "ref revert" do
+ context "when ref exists" do
+ it "reverts the ref commit" do
+ post api(route, current_user), params: {branch: branch}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/commit/basic')
+ expect(response).to match_response_schema("public_api/v4/commit/basic")
- expect(json_response['message']).to eq(commit.revert_message(user))
- expect(json_response['author_name']).to eq(user.name)
- expect(json_response['committer_name']).to eq(user.name)
- expect(json_response['parent_ids']).to contain_exactly(commit_id)
+ expect(json_response["message"]).to eq(commit.revert_message(user))
+ expect(json_response["author_name"]).to eq(user.name)
+ expect(json_response["committer_name"]).to eq(user.name)
+ expect(json_response["parent_ids"]).to contain_exactly(commit_id)
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
- let(:request) { post api(route, current_user), params: { branch: branch } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route, current_user), params: {branch: branch} }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like '403 response' do
- let(:request) { post api(route), params: { branch: branch } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route), params: {branch: branch} }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
- let(:request) { post api(route), params: { branch: branch } }
- let(:message) { '404 Project Not Found' }
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
+ let(:request) { post api(route), params: {branch: branch} }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as an owner' do
+ context "when authenticated", "as an owner" do
let(:current_user) { user }
- it_behaves_like 'ref revert'
+ it_behaves_like "ref revert"
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { branch: branch } }
- let(:message) { '404 Commit Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {branch: branch} }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'when branch is missing' do
- it_behaves_like '400 response' do
+ context "when branch is missing" do
+ it_behaves_like "400 response" do
let(:request) { post api(route, current_user) }
end
end
- context 'when branch is empty' do
- ['', ' '].each do |branch|
- it_behaves_like '400 response' do
- let(:request) { post api(route, current_user), params: { branch: branch } }
+ context "when branch is empty" do
+ ["", " "].each do |branch|
+ it_behaves_like "400 response" do
+ let(:request) { post api(route, current_user), params: {branch: branch} }
end
end
end
- context 'when branch does not exist' do
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { branch: 'foo' } }
- let(:message) { '404 Branch Not Found' }
+ context "when branch does not exist" do
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {branch: "foo"} }
+ let(:message) { "404 Branch Not Found" }
end
end
- context 'when ref contains a dot' do
+ context "when ref contains a dot" do
let(:commit_id) { branch_with_dot.name }
let(:commit) { project.repository.commit(commit_id) }
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) { post api(route, current_user) }
end
end
end
- context 'when authenticated', 'as a developer' do
+ context "when authenticated", "as a developer" do
let(:current_user) { user }
before do
project.add_developer(user)
end
- context 'when branch is protected' do
+ context "when branch is protected" do
before do
- create(:protected_branch, project: project, name: 'feature')
+ create(:protected_branch, project: project, name: "feature")
end
- it 'returns 400 if you are not allowed to push to the target branch' do
- post api(route, current_user), params: { branch: 'feature' }
+ it "returns 400 if you are not allowed to push to the target branch" do
+ post api(route, current_user), params: {branch: "feature"}
expect(response).to have_gitlab_http_status(:forbidden)
- expect(json_response['message']).to match(/You are not allowed to push into this branch/)
+ expect(json_response["message"]).to match(/You are not allowed to push into this branch/)
end
end
end
end
- describe 'POST /projects/:id/repository/commits/:sha/comments' do
+ describe "POST /projects/:id/repository/commits/:sha/comments" do
let(:commit) { project.repository.commit }
let(:commit_id) { commit.id }
- let(:note) { 'My comment' }
+ let(:note) { "My comment" }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/comments" }
- shared_examples_for 'ref new comment' do
- context 'when ref exists' do
- it 'creates the comment' do
- post api(route, current_user), params: { note: note }
+ shared_examples_for "ref new comment" do
+ context "when ref exists" do
+ it "creates the comment" do
+ post api(route, current_user), params: {note: note}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/commit_note')
- expect(json_response['note']).to eq('My comment')
- expect(json_response['path']).to be_nil
- expect(json_response['line']).to be_nil
- expect(json_response['line_type']).to be_nil
+ expect(response).to match_response_schema("public_api/v4/commit_note")
+ expect(json_response["note"]).to eq("My comment")
+ expect(json_response["path"]).to be_nil
+ expect(json_response["line"]).to be_nil
+ expect(json_response["line_type"]).to be_nil
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
- let(:request) { post api(route, current_user), params: { note: 'My comment' } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route, current_user), params: {note: "My comment"} }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like '400 response' do
- let(:request) { post api(route), params: { note: 'My comment' } }
+ it_behaves_like "400 response" do
+ let(:request) { post api(route), params: {note: "My comment"} }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
- let(:request) { post api(route), params: { note: 'My comment' } }
- let(:message) { '404 Project Not Found' }
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
+ let(:request) { post api(route), params: {note: "My comment"} }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as an owner' do
+ context "when authenticated", "as an owner" do
let(:current_user) { user }
- it_behaves_like 'ref new comment'
+ it_behaves_like "ref new comment"
- it 'returns the inline comment' do
- post api(route, current_user), params: { note: 'My comment', path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: 'new' }
+ it "returns the inline comment" do
+ post api(route, current_user), params: {note: "My comment", path: project.repository.commit.raw_diffs.first.new_path, line: 1, line_type: "new"}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/commit_note')
- expect(json_response['note']).to eq('My comment')
- expect(json_response['path']).to eq(project.repository.commit.raw_diffs.first.new_path)
- expect(json_response['line']).to eq(1)
- expect(json_response['line_type']).to eq('new')
+ expect(response).to match_response_schema("public_api/v4/commit_note")
+ expect(json_response["note"]).to eq("My comment")
+ expect(json_response["path"]).to eq(project.repository.commit.raw_diffs.first.new_path)
+ expect(json_response["line"]).to eq(1)
+ expect(json_response["line_type"]).to eq("new")
end
- context 'when ref does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when ref does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { note: 'My comment' } }
- let(:message) { '404 Commit Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {note: "My comment"} }
+ let(:message) { "404 Commit Not Found" }
end
end
- it 'returns 400 if note is missing' do
+ it "returns 400 if note is missing" do
post api(route, current_user)
expect(response).to have_gitlab_http_status(400)
end
- context 'when ref contains a dot' do
+ context "when ref contains a dot" do
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref new comment'
+ it_behaves_like "ref new comment"
end
- context 'when ref contains a slash' do
+ context "when ref contains a slash" do
let(:commit_id) { branch_with_slash.name }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { note: 'My comment' } }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {note: "My comment"} }
end
end
- context 'when ref contains an escaped slash' do
+ context "when ref contains an escaped slash" do
let(:commit_id) { CGI.escape(branch_with_slash.name) }
- it_behaves_like 'ref new comment'
+ it_behaves_like "ref new comment"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'ref new comment'
+ it_behaves_like "ref new comment"
- context 'when ref contains a dot' do
+ context "when ref contains a dot" do
let(:commit_id) { branch_with_dot.name }
- it_behaves_like 'ref new comment'
+ it_behaves_like "ref new comment"
end
end
end
end
- describe 'GET /projects/:id/repository/commits/:sha/merge_requests' do
+ describe "GET /projects/:id/repository/commits/:sha/merge_requests" do
let!(:project) { create(:project, :repository, :private) }
- let!(:merged_mr) { create(:merge_request, source_project: project, source_branch: 'master', target_branch: 'feature') }
+ let!(:merged_mr) { create(:merge_request, source_project: project, source_branch: "master", target_branch: "feature") }
let(:commit) { merged_mr.merge_request_diff.commits.last }
- it 'returns the correct merge request' do
+ it "returns the correct merge request" do
get api("/projects/#{project.id}/repository/commits/#{commit.id}/merge_requests", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(1)
- expect(json_response[0]['id']).to eq(merged_mr.id)
+ expect(json_response[0]["id"]).to eq(merged_mr.id)
end
- it 'returns 403 for an unauthorized user' do
+ it "returns 403 for an unauthorized user" do
project.add_guest(user)
get api("/projects/#{project.id}/repository/commits/#{commit.id}/merge_requests", user)
@@ -1451,47 +1451,47 @@ describe API::Commits do
expect(response).to have_gitlab_http_status(403)
end
- it 'responds 404 when the commit does not exist' do
+ it "responds 404 when the commit does not exist" do
get api("/projects/#{project.id}/repository/commits/a7d26f00c35b/merge_requests", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET /projects/:id/repository/commits/:sha/signature' do
+ describe "GET /projects/:id/repository/commits/:sha/signature" do
let!(:project) { create(:project, :repository, :public) }
let(:project_id) { project.id }
let(:commit_id) { project.repository.commit.id }
let(:route) { "/projects/#{project_id}/repository/commits/#{commit_id}/signature" }
- context 'when commit does not exist' do
- let(:commit_id) { 'unknown' }
+ context "when commit does not exist" do
+ let(:commit_id) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Commit Not Found' }
+ let(:message) { "404 Commit Not Found" }
end
end
- context 'unsigned commit' do
- it_behaves_like '404 response' do
+ context "unsigned commit" do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 GPG Signature Not Found'}
+ let(:message) { "404 GPG Signature Not Found"}
end
end
- context 'signed commit' do
+ context "signed commit" do
let(:commit) { project.repository.commit(GpgHelpers::SIGNED_COMMIT_SHA) }
let(:commit_id) { commit.id }
- it 'returns correct JSON' do
+ it "returns correct JSON" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['gpg_key_id']).to eq(commit.signature.gpg_key_id)
- expect(json_response['gpg_key_subkey_id']).to eq(commit.signature.gpg_key_subkey_id)
- expect(json_response['gpg_key_primary_keyid']).to eq(commit.signature.gpg_key_primary_keyid)
- expect(json_response['verification_status']).to eq(commit.signature.verification_status)
+ expect(json_response["gpg_key_id"]).to eq(commit.signature.gpg_key_id)
+ expect(json_response["gpg_key_subkey_id"]).to eq(commit.signature.gpg_key_subkey_id)
+ expect(json_response["gpg_key_primary_keyid"]).to eq(commit.signature.gpg_key_primary_keyid)
+ expect(json_response["verification_status"]).to eq(commit.signature.verification_status)
end
end
end
diff --git a/spec/requests/api/container_registry_spec.rb b/spec/requests/api/container_registry_spec.rb
index ea035a8be4a..f9f992b8438 100644
--- a/spec/requests/api/container_registry_spec.rb
+++ b/spec/requests/api/container_registry_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ContainerRegistry do
set(:project) { create(:project, :private) }
@@ -25,11 +25,11 @@ describe API::ContainerRegistry do
test_repository
end
- shared_examples 'being disallowed' do |param|
+ shared_examples "being disallowed" do |param|
context "for #{param}" do
let(:api_user) { public_send(param) }
- it 'returns access denied' do
+ it "returns access denied" do
subject
expect(response).to have_gitlab_http_status(:forbidden)
@@ -39,7 +39,7 @@ describe API::ContainerRegistry do
context "for anonymous" do
let(:api_user) { nil }
- it 'returns not found' do
+ it "returns not found" do
subject
expect(response).to have_gitlab_http_status(:not_found)
@@ -47,40 +47,41 @@ describe API::ContainerRegistry do
end
end
- describe 'GET /projects/:id/registry/repositories' do
+ describe "GET /projects/:id/registry/repositories" do
subject { get api("/projects/#{project.id}/registry/repositories", api_user) }
- it_behaves_like 'being disallowed', :guest
+ it_behaves_like "being disallowed", :guest
- context 'for reporter' do
+ context "for reporter" do
let(:api_user) { reporter }
- it 'returns a list of repositories' do
+ it "returns a list of repositories" do
subject
expect(json_response.length).to eq(2)
- expect(json_response.map { |repository| repository['id'] }).to contain_exactly(
- root_repository.id, test_repository.id)
+ expect(json_response.map { |repository| repository["id"] }).to contain_exactly(
+ root_repository.id, test_repository.id
+ )
end
- it 'returns a matching schema' do
+ it "returns a matching schema" do
subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/repositories')
+ expect(response).to match_response_schema("registry/repositories")
end
end
end
- describe 'DELETE /projects/:id/registry/repositories/:repository_id' do
+ describe "DELETE /projects/:id/registry/repositories/:repository_id" do
subject { delete api("/projects/#{project.id}/registry/repositories/#{root_repository.id}", api_user) }
- it_behaves_like 'being disallowed', :developer
+ it_behaves_like "being disallowed", :developer
- context 'for maintainer' do
+ context "for maintainer" do
let(:api_user) { maintainer }
- it 'schedules removal of repository' do
+ it "schedules removal of repository" do
expect(DeleteContainerRepositoryWorker).to receive(:perform_async)
.with(maintainer.id, root_repository.id)
@@ -91,71 +92,71 @@ describe API::ContainerRegistry do
end
end
- describe 'GET /projects/:id/registry/repositories/:repository_id/tags' do
+ describe "GET /projects/:id/registry/repositories/:repository_id/tags" do
subject { get api("/projects/#{project.id}/registry/repositories/#{root_repository.id}/tags", api_user) }
- it_behaves_like 'being disallowed', :guest
+ it_behaves_like "being disallowed", :guest
- context 'for reporter' do
+ context "for reporter" do
let(:api_user) { reporter }
before do
- stub_container_registry_tags(repository: root_repository.path, tags: %w(rootA latest))
+ stub_container_registry_tags(repository: root_repository.path, tags: %w[rootA latest])
end
- it 'returns a list of tags' do
+ it "returns a list of tags" do
subject
expect(json_response.length).to eq(2)
- expect(json_response.map { |repository| repository['name'] }).to eq %w(latest rootA)
+ expect(json_response.map { |repository| repository["name"] }).to eq %w[latest rootA]
end
- it 'returns a matching schema' do
+ it "returns a matching schema" do
subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/tags')
+ expect(response).to match_response_schema("registry/tags")
end
end
end
- describe 'DELETE /projects/:id/registry/repositories/:repository_id/tags' do
+ describe "DELETE /projects/:id/registry/repositories/:repository_id/tags" do
subject { delete api("/projects/#{project.id}/registry/repositories/#{root_repository.id}/tags", api_user), params: params }
- it_behaves_like 'being disallowed', :developer do
+ it_behaves_like "being disallowed", :developer do
let(:params) do
- { name_regex: 'v10.*' }
+ {name_regex: "v10.*"}
end
end
- context 'for maintainer' do
+ context "for maintainer" do
let(:api_user) { maintainer }
- context 'without required parameters' do
+ context "without required parameters" do
let(:params) { }
- it 'returns bad request' do
+ it "returns bad request" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'passes all declared parameters' do
+ context "passes all declared parameters" do
let(:params) do
- { name_regex: 'v10.*',
- keep_n: 100,
- older_than: '1 day',
- other: 'some value' }
+ {name_regex: "v10.*",
+ keep_n: 100,
+ older_than: "1 day",
+ other: "some value",}
end
let(:worker_params) do
- { name_regex: 'v10.*',
- keep_n: 100,
- older_than: '1 day' }
+ {name_regex: "v10.*",
+ keep_n: 100,
+ older_than: "1 day",}
end
- it 'schedules cleanup of tags repository' do
+ it "schedules cleanup of tags repository" do
expect(CleanupContainerRepositoryWorker).to receive(:perform_async)
.with(maintainer.id, root_repository.id, worker_params)
@@ -167,53 +168,54 @@ describe API::ContainerRegistry do
end
end
- describe 'GET /projects/:id/registry/repositories/:repository_id/tags/:tag_name' do
+ describe "GET /projects/:id/registry/repositories/:repository_id/tags/:tag_name" do
subject { get api("/projects/#{project.id}/registry/repositories/#{root_repository.id}/tags/rootA", api_user) }
- it_behaves_like 'being disallowed', :guest
+ it_behaves_like "being disallowed", :guest
- context 'for reporter' do
+ context "for reporter" do
let(:api_user) { reporter }
before do
- stub_container_registry_tags(repository: root_repository.path, tags: %w(rootA), with_manifest: true)
+ stub_container_registry_tags(repository: root_repository.path, tags: %w[rootA], with_manifest: true)
end
- it 'returns a details of tag' do
+ it "returns a details of tag" do
subject
expect(json_response).to include(
- 'name' => 'rootA',
- 'digest' => 'sha256:4c8e63ca4cb663ce6c688cb06f1c372b088dac5b6d7ad7d49cd620d85cf72a15',
- 'revision' => 'd7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac',
- 'total_size' => 2319870)
+ "name" => "rootA",
+ "digest" => "sha256:4c8e63ca4cb663ce6c688cb06f1c372b088dac5b6d7ad7d49cd620d85cf72a15",
+ "revision" => "d7a513a663c1a6dcdba9ed832ca53c02ac2af0c333322cd6ca92936d1d9917ac",
+ "total_size" => 2319870
+ )
end
- it 'returns a matching schema' do
+ it "returns a matching schema" do
subject
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('registry/tag')
+ expect(response).to match_response_schema("registry/tag")
end
end
end
- describe 'DELETE /projects/:id/registry/repositories/:repository_id/tags/:tag_name' do
+ describe "DELETE /projects/:id/registry/repositories/:repository_id/tags/:tag_name" do
subject { delete api("/projects/#{project.id}/registry/repositories/#{root_repository.id}/tags/rootA", api_user) }
- it_behaves_like 'being disallowed', :developer
+ it_behaves_like "being disallowed", :developer
- context 'for maintainer' do
+ context "for maintainer" do
let(:api_user) { maintainer }
before do
- stub_container_registry_tags(repository: root_repository.path, tags: %w(rootA), with_manifest: true)
+ stub_container_registry_tags(repository: root_repository.path, tags: %w[rootA], with_manifest: true)
end
- it 'properly removes tag' do
+ it "properly removes tag" do
expect_any_instance_of(ContainerRegistry::Client)
.to receive(:delete_repository_tag).with(root_repository.path,
- 'sha256:4c8e63ca4cb663ce6c688cb06f1c372b088dac5b6d7ad7d49cd620d85cf72a15')
+ "sha256:4c8e63ca4cb663ce6c688cb06f1c372b088dac5b6d7ad7d49cd620d85cf72a15")
subject
diff --git a/spec/requests/api/deploy_keys_spec.rb b/spec/requests/api/deploy_keys_spec.rb
index b93ee148736..2977f33e08a 100644
--- a/spec/requests/api/deploy_keys_spec.rb
+++ b/spec/requests/api/deploy_keys_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::DeployKeys do
let(:user) { create(:user) }
@@ -11,239 +11,239 @@ describe API::DeployKeys do
create(:deploy_keys_project, project: project, deploy_key: deploy_key)
end
- describe 'GET /deploy_keys' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- get api('/deploy_keys')
+ describe "GET /deploy_keys" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ get api("/deploy_keys")
expect(response.status).to eq(401)
end
end
- context 'when authenticated as non-admin user' do
- it 'returns a 403 error' do
- get api('/deploy_keys', user)
+ context "when authenticated as non-admin user" do
+ it "returns a 403 error" do
+ get api("/deploy_keys", user)
expect(response.status).to eq(403)
end
end
- context 'when authenticated as admin' do
- it 'returns all deploy keys' do
- get api('/deploy_keys', admin)
+ context "when authenticated as admin" do
+ it "returns all deploy keys" do
+ get api("/deploy_keys", admin)
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(deploy_keys_project.deploy_key.id)
+ expect(json_response.first["id"]).to eq(deploy_keys_project.deploy_key.id)
end
end
end
- describe 'GET /projects/:id/deploy_keys' do
+ describe "GET /projects/:id/deploy_keys" do
before do
deploy_key
end
- it 'returns array of ssh keys' do
+ it "returns array of ssh keys" do
get api("/projects/#{project.id}/deploy_keys", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['title']).to eq(deploy_key.title)
+ expect(json_response.first["title"]).to eq(deploy_key.title)
end
end
- describe 'GET /projects/:id/deploy_keys/:key_id' do
- it 'returns a single key' do
+ describe "GET /projects/:id/deploy_keys/:key_id" do
+ it "returns a single key" do
get api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(deploy_key.title)
+ expect(json_response["title"]).to eq(deploy_key.title)
end
- it 'returns 404 Not Found with invalid ID' do
+ it "returns 404 Not Found with invalid ID" do
get api("/projects/#{project.id}/deploy_keys/404", admin)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'POST /projects/:id/deploy_keys' do
- it 'does not create an invalid ssh key' do
- post api("/projects/#{project.id}/deploy_keys", admin), params: { title: 'invalid key' }
+ describe "POST /projects/:id/deploy_keys" do
+ it "does not create an invalid ssh key" do
+ post api("/projects/#{project.id}/deploy_keys", admin), params: {title: "invalid key"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('key is missing')
+ expect(json_response["error"]).to eq("key is missing")
end
- it 'does not create a key without title' do
- post api("/projects/#{project.id}/deploy_keys", admin), params: { key: 'some key' }
+ it "does not create a key without title" do
+ post api("/projects/#{project.id}/deploy_keys", admin), params: {key: "some key"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('title is missing')
+ expect(json_response["error"]).to eq("title is missing")
end
- it 'creates new ssh key' do
+ it "creates new ssh key" do
key_attrs = attributes_for :another_key
- expect do
+ expect {
post api("/projects/#{project.id}/deploy_keys", admin), params: key_attrs
- end.to change { project.deploy_keys.count }.by(1)
+ }.to change { project.deploy_keys.count }.by(1)
new_key = project.deploy_keys.last
expect(new_key.key).to eq(key_attrs[:key])
expect(new_key.user).to eq(admin)
end
- it 'returns an existing ssh key when attempting to add a duplicate' do
- expect do
- post api("/projects/#{project.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title }
- end.not_to change { project.deploy_keys.count }
+ it "returns an existing ssh key when attempting to add a duplicate" do
+ expect {
+ post api("/projects/#{project.id}/deploy_keys", admin), params: {key: deploy_key.key, title: deploy_key.title}
+ }.not_to change { project.deploy_keys.count }
expect(response).to have_gitlab_http_status(201)
end
- it 'joins an existing ssh key to a new project' do
- expect do
- post api("/projects/#{project2.id}/deploy_keys", admin), params: { key: deploy_key.key, title: deploy_key.title }
- end.to change { project2.deploy_keys.count }.by(1)
+ it "joins an existing ssh key to a new project" do
+ expect {
+ post api("/projects/#{project2.id}/deploy_keys", admin), params: {key: deploy_key.key, title: deploy_key.title}
+ }.to change { project2.deploy_keys.count }.by(1)
expect(response).to have_gitlab_http_status(201)
end
- it 'accepts can_push parameter' do
+ it "accepts can_push parameter" do
key_attrs = attributes_for(:another_key).merge(can_push: true)
post api("/projects/#{project.id}/deploy_keys", admin), params: key_attrs
expect(response).to have_gitlab_http_status(201)
- expect(json_response['can_push']).to eq(true)
+ expect(json_response["can_push"]).to eq(true)
end
end
- describe 'PUT /projects/:id/deploy_keys/:key_id' do
+ describe "PUT /projects/:id/deploy_keys/:key_id" do
let(:private_deploy_key) { create(:another_deploy_key, public: false) }
let(:project_private_deploy_key) do
create(:deploy_keys_project, project: project, deploy_key: private_deploy_key)
end
- it 'updates a public deploy key as admin' do
- expect do
- put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), params: { title: 'new title' }
- end.not_to change(deploy_key, :title)
+ it "updates a public deploy key as admin" do
+ expect {
+ put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin), params: {title: "new title"}
+ }.not_to change(deploy_key, :title)
expect(response).to have_gitlab_http_status(200)
end
- it 'does not update a public deploy key as non admin' do
- expect do
- put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), params: { title: 'new title' }
- end.not_to change(deploy_key, :title)
+ it "does not update a public deploy key as non admin" do
+ expect {
+ put api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", user), params: {title: "new title"}
+ }.not_to change(deploy_key, :title)
expect(response).to have_gitlab_http_status(404)
end
- it 'does not update a private key with invalid title' do
+ it "does not update a private key with invalid title" do
project_private_deploy_key
- expect do
- put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: { title: '' }
- end.not_to change(deploy_key, :title)
+ expect {
+ put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: {title: ""}
+ }.not_to change(deploy_key, :title)
expect(response).to have_gitlab_http_status(400)
end
- it 'updates a private ssh key with correct attributes' do
+ it "updates a private ssh key with correct attributes" do
project_private_deploy_key
- put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: { title: 'new title', can_push: true }
+ put api("/projects/#{project.id}/deploy_keys/#{private_deploy_key.id}", admin), params: {title: "new title", can_push: true}
- expect(json_response['id']).to eq(private_deploy_key.id)
- expect(json_response['title']).to eq('new title')
- expect(json_response['can_push']).to eq(true)
+ expect(json_response["id"]).to eq(private_deploy_key.id)
+ expect(json_response["title"]).to eq("new title")
+ expect(json_response["can_push"]).to eq(true)
end
end
- describe 'DELETE /projects/:id/deploy_keys/:key_id' do
+ describe "DELETE /projects/:id/deploy_keys/:key_id" do
before do
deploy_key
end
- it 'removes existing key from project' do
- expect do
+ it "removes existing key from project" do
+ expect {
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { project.deploy_keys.count }.by(-1)
+ }.to change { project.deploy_keys.count }.by(-1)
end
- context 'when the deploy key is public' do
- it 'does not delete the deploy key' do
- expect do
+ context "when the deploy key is public" do
+ it "does not delete the deploy key" do
+ expect {
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.not_to change { DeployKey.count }
+ }.not_to change { DeployKey.count }
end
end
- context 'when the deploy key is not public' do
+ context "when the deploy key is not public" do
let!(:deploy_key) { create(:deploy_key, public: false) }
- context 'when the deploy key is only used by this project' do
- it 'deletes the deploy key' do
- expect do
+ context "when the deploy key is only used by this project" do
+ it "deletes the deploy key" do
+ expect {
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { DeployKey.count }.by(-1)
+ }.to change { DeployKey.count }.by(-1)
end
end
- context 'when the deploy key is used by other projects' do
+ context "when the deploy key is used by other projects" do
before do
create(:deploy_keys_project, project: project2, deploy_key: deploy_key)
end
- it 'does not delete the deploy key' do
- expect do
+ it "does not delete the deploy key" do
+ expect {
delete api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.not_to change { DeployKey.count }
+ }.not_to change { DeployKey.count }
end
end
end
- it 'returns 404 Not Found with invalid ID' do
+ it "returns 404 Not Found with invalid ID" do
delete api("/projects/#{project.id}/deploy_keys/404", admin)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/deploy_keys/#{deploy_key.id}", admin) }
end
end
- describe 'POST /projects/:id/deploy_keys/:key_id/enable' do
+ describe "POST /projects/:id/deploy_keys/:key_id/enable" do
let(:project2) { create(:project) }
- context 'when the user can admin the project' do
- it 'enables the key' do
- expect do
+ context "when the user can admin the project" do
+ it "enables the key" do
+ expect {
post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", admin)
- end.to change { project2.deploy_keys.count }.from(0).to(1)
+ }.to change { project2.deploy_keys.count }.from(0).to(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(deploy_key.id)
+ expect(json_response["id"]).to eq(deploy_key.id)
end
end
- context 'when authenticated as non-admin user' do
- it 'returns a 404 error' do
+ context "when authenticated as non-admin user" do
+ it "returns a 404 error" do
post api("/projects/#{project2.id}/deploy_keys/#{deploy_key.id}/enable", user)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/deployments_spec.rb b/spec/requests/api/deployments_spec.rb
index 3dac7225b7a..d774e008292 100644
--- a/spec/requests/api/deployments_spec.rb
+++ b/spec/requests/api/deployments_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Deployments do
let(:user) { create(:user) }
@@ -8,27 +8,27 @@ describe API::Deployments do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/deployments' do
+ describe "GET /projects/:id/deployments" do
let(:project) { create(:project) }
- let!(:deployment_1) { create(:deployment, :success, project: project, iid: 11, ref: 'master', created_at: Time.now) }
- let!(:deployment_2) { create(:deployment, :success, project: project, iid: 12, ref: 'feature', created_at: 1.day.ago) }
- let!(:deployment_3) { create(:deployment, :success, project: project, iid: 8, ref: 'patch', created_at: 2.days.ago) }
+ let!(:deployment_1) { create(:deployment, :success, project: project, iid: 11, ref: "master", created_at: Time.now) }
+ let!(:deployment_2) { create(:deployment, :success, project: project, iid: 12, ref: "feature", created_at: 1.day.ago) }
+ let!(:deployment_3) { create(:deployment, :success, project: project, iid: 8, ref: "patch", created_at: 2.days.ago) }
- context 'as member of the project' do
- it 'returns projects deployments sorted by id asc' do
+ context "as member of the project" do
+ it "returns projects deployments sorted by id asc" do
get api("/projects/#{project.id}/deployments", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
- expect(json_response.first['iid']).to eq(deployment_1.iid)
- expect(json_response.first['sha']).to match /\A\h{40}\z/
- expect(json_response.second['iid']).to eq(deployment_2.iid)
- expect(json_response.last['iid']).to eq(deployment_3.iid)
+ expect(json_response.first["iid"]).to eq(deployment_1.iid)
+ expect(json_response.first["sha"]).to match /\A\h{40}\z/
+ expect(json_response.second["iid"]).to eq(deployment_2.iid)
+ expect(json_response.last["iid"]).to eq(deployment_3.iid)
end
- describe 'ordering' do
+ describe "ordering" do
using RSpec::Parameterized::TableSyntax
let(:order_by) { nil }
@@ -38,7 +38,7 @@ describe API::Deployments do
def expect_deployments(ordered_deployments)
json_response.each_with_index do |deployment_json, index|
- expect(deployment_json['id']).to eq(public_send(ordered_deployments[index]).id)
+ expect(deployment_json["id"]).to eq(public_send(ordered_deployments[index]).id)
end
end
@@ -47,26 +47,26 @@ describe API::Deployments do
end
where(:order_by, :sort, :ordered_deployments) do
- 'created_at' | 'asc' | [:deployment_3, :deployment_2, :deployment_1]
- 'created_at' | 'desc' | [:deployment_1, :deployment_2, :deployment_3]
- 'id' | 'asc' | [:deployment_1, :deployment_2, :deployment_3]
- 'id' | 'desc' | [:deployment_3, :deployment_2, :deployment_1]
- 'iid' | 'asc' | [:deployment_3, :deployment_1, :deployment_2]
- 'iid' | 'desc' | [:deployment_2, :deployment_1, :deployment_3]
- 'ref' | 'asc' | [:deployment_2, :deployment_1, :deployment_3]
- 'ref' | 'desc' | [:deployment_3, :deployment_1, :deployment_2]
+ "created_at" | "asc" | [:deployment_3, :deployment_2, :deployment_1]
+ "created_at" | "desc" | [:deployment_1, :deployment_2, :deployment_3]
+ "id" | "asc" | [:deployment_1, :deployment_2, :deployment_3]
+ "id" | "desc" | [:deployment_3, :deployment_2, :deployment_1]
+ "iid" | "asc" | [:deployment_3, :deployment_1, :deployment_2]
+ "iid" | "desc" | [:deployment_2, :deployment_1, :deployment_3]
+ "ref" | "asc" | [:deployment_2, :deployment_1, :deployment_3]
+ "ref" | "desc" | [:deployment_3, :deployment_1, :deployment_2]
end
with_them do
- it 'returns the deployments ordered' do
+ it "returns the deployments ordered" do
expect_deployments(ordered_deployments)
end
end
end
end
- context 'as non member' do
- it 'returns a 404 status code' do
+ context "as non member" do
+ it "returns a 404 status code" do
get api("/projects/#{project.id}/deployments", non_member)
expect(response).to have_gitlab_http_status(404)
@@ -74,22 +74,22 @@ describe API::Deployments do
end
end
- describe 'GET /projects/:id/deployments/:deployment_id' do
+ describe "GET /projects/:id/deployments/:deployment_id" do
let(:project) { deployment.environment.project }
let!(:deployment) { create(:deployment, :success) }
- context 'as a member of the project' do
- it 'returns the projects deployment' do
+ context "as a member of the project" do
+ it "returns the projects deployment" do
get api("/projects/#{project.id}/deployments/#{deployment.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['sha']).to match /\A\h{40}\z/
- expect(json_response['id']).to eq(deployment.id)
+ expect(json_response["sha"]).to match /\A\h{40}\z/
+ expect(json_response["id"]).to eq(deployment.id)
end
end
- context 'as non member' do
- it 'returns a 404 status code' do
+ context "as non member" do
+ it "returns a 404 status code" do
get api("/projects/#{project.id}/deployments/#{deployment.id}", non_member)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/discussions_spec.rb b/spec/requests/api/discussions_spec.rb
index 35c448d187d..2d853e841d0 100644
--- a/spec/requests/api/discussions_spec.rb
+++ b/spec/requests/api/discussions_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Discussions do
let(:user) { create(:user) }
@@ -9,46 +9,46 @@ describe API::Discussions do
project.add_developer(user)
end
- context 'when noteable is an Issue' do
+ context "when noteable is an Issue" do
let!(:issue) { create(:issue, project: project, author: user) }
let!(:issue_note) { create(:discussion_note_on_issue, noteable: issue, project: project, author: user) }
- it_behaves_like 'discussions API', 'projects', 'issues', 'iid' do
+ it_behaves_like "discussions API", "projects", "issues", "iid" do
let(:parent) { project }
let(:noteable) { issue }
let(:note) { issue_note }
end
end
- context 'when noteable is a Snippet' do
+ context "when noteable is a Snippet" do
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let!(:snippet_note) { create(:discussion_note_on_snippet, noteable: snippet, project: project, author: user) }
- it_behaves_like 'discussions API', 'projects', 'snippets', 'id' do
+ it_behaves_like "discussions API", "projects", "snippets", "id" do
let(:parent) { project }
let(:noteable) { snippet }
let(:note) { snippet_note }
end
end
- context 'when noteable is a Merge Request' do
+ context "when noteable is a Merge Request" do
let!(:noteable) { create(:merge_request_with_diffs, source_project: project, target_project: project, author: user) }
let!(:note) { create(:discussion_note_on_merge_request, noteable: noteable, project: project, author: user) }
let!(:diff_note) { create(:diff_note_on_merge_request, noteable: noteable, project: project, author: user) }
let(:parent) { project }
- it_behaves_like 'discussions API', 'projects', 'merge_requests', 'iid'
- it_behaves_like 'diff discussions API', 'projects', 'merge_requests', 'iid'
- it_behaves_like 'resolvable discussions API', 'projects', 'merge_requests', 'iid'
+ it_behaves_like "discussions API", "projects", "merge_requests", "iid"
+ it_behaves_like "diff discussions API", "projects", "merge_requests", "iid"
+ it_behaves_like "resolvable discussions API", "projects", "merge_requests", "iid"
end
- context 'when noteable is a Commit' do
+ context "when noteable is a Commit" do
let!(:noteable) { create(:commit, project: project, author: user) }
let!(:note) { create(:discussion_note_on_commit, commit_id: noteable.id, project: project, author: user) }
let!(:diff_note) { create(:diff_note_on_commit, commit_id: noteable.id, project: project, author: user) }
let(:parent) { project }
- it_behaves_like 'discussions API', 'projects', 'repository/commits', 'id'
- it_behaves_like 'diff discussions API', 'projects', 'repository/commits', 'id'
+ it_behaves_like "discussions API", "projects", "repository/commits", "id"
+ it_behaves_like "diff discussions API", "projects", "repository/commits", "id"
end
end
diff --git a/spec/requests/api/doorkeeper_access_spec.rb b/spec/requests/api/doorkeeper_access_spec.rb
index d74484c8d29..52ec87d15bf 100644
--- a/spec/requests/api/doorkeeper_access_spec.rb
+++ b/spec/requests/api/doorkeeper_access_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'doorkeeper access' do
+describe "doorkeeper access" do
let!(:user) { create(:user) }
let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "api" }
describe "unauthenticated" do
it "returns authentication success" do
- get api("/user"), params: { access_token: token.token }
+ get api("/user"), params: {access_token: token.token}
expect(response).to have_gitlab_http_status(200)
end
- include_examples 'user login request with unique ip limit' do
+ include_examples "user login request with unique ip limit" do
def request
- get api('/user'), params: { access_token: token.token }
+ get api("/user"), params: {access_token: token.token}
end
end
end
describe "when token invalid" do
it "returns authentication error" do
- get api("/user"), params: { access_token: "123a" }
+ get api("/user"), params: {access_token: "123a"}
expect(response).to have_gitlab_http_status(401)
end
end
@@ -31,9 +31,9 @@ describe 'doorkeeper access' do
expect(response).to have_gitlab_http_status(200)
end
- include_examples 'user login request with unique ip limit' do
+ include_examples "user login request with unique ip limit" do
def request
- get api('/user', user)
+ get api("/user", user)
end
end
end
@@ -41,7 +41,7 @@ describe 'doorkeeper access' do
describe "when user is blocked" do
it "returns authorization error" do
user.block
- get api("/user"), params: { access_token: token.token }
+ get api("/user"), params: {access_token: token.token}
expect(response).to have_gitlab_http_status(403)
end
@@ -50,7 +50,7 @@ describe 'doorkeeper access' do
describe "when user is ldap_blocked" do
it "returns authorization error" do
user.ldap_block
- get api("/user"), params: { access_token: token.token }
+ get api("/user"), params: {access_token: token.token}
expect(response).to have_gitlab_http_status(403)
end
diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb
index 493d3642255..711f8b97304 100644
--- a/spec/requests/api/environments_spec.rb
+++ b/spec/requests/api/environments_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Environments do
let(:user) { create(:user) }
@@ -10,10 +10,10 @@ describe API::Environments do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/environments' do
- context 'as member of the project' do
- it 'returns project environments' do
- project_data_keys = %w(
+ describe "GET /projects/:id/environments" do
+ context "as member of the project" do
+ it "returns project environments" do
+ project_data_keys = %w[
id description default_branch tag_list
ssh_url_to_repo http_url_to_repo web_url readme_url
name name_with_namespace
@@ -21,7 +21,7 @@ describe API::Environments do
star_count forks_count
created_at last_activity_at
avatar_url namespace
- )
+ ]
get api("/projects/#{project.id}/environments", user)
@@ -29,14 +29,14 @@ describe API::Environments do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response.first['name']).to eq(environment.name)
- expect(json_response.first['external_url']).to eq(environment.external_url)
- expect(json_response.first['project'].keys).to contain_exactly(*project_data_keys)
+ expect(json_response.first["name"]).to eq(environment.name)
+ expect(json_response.first["external_url"]).to eq(environment.external_url)
+ expect(json_response.first["project"].keys).to contain_exactly(*project_data_keys)
end
end
- context 'as non member' do
- it 'returns a 404 status code' do
+ context "as non member" do
+ it "returns a 404 status code" do
get api("/projects/#{project.id}/environments", non_member)
expect(response).to have_gitlab_http_status(404)
@@ -44,65 +44,65 @@ describe API::Environments do
end
end
- describe 'POST /projects/:id/environments' do
- context 'as a member' do
- it 'creates a environment with valid params' do
- post api("/projects/#{project.id}/environments", user), params: { name: "mepmep" }
+ describe "POST /projects/:id/environments" do
+ context "as a member" do
+ it "creates a environment with valid params" do
+ post api("/projects/#{project.id}/environments", user), params: {name: "mepmep"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('mepmep')
- expect(json_response['slug']).to eq('mepmep')
- expect(json_response['external']).to be nil
+ expect(json_response["name"]).to eq("mepmep")
+ expect(json_response["slug"]).to eq("mepmep")
+ expect(json_response["external"]).to be nil
end
- it 'requires name to be passed' do
- post api("/projects/#{project.id}/environments", user), params: { external_url: 'test.gitlab.com' }
+ it "requires name to be passed" do
+ post api("/projects/#{project.id}/environments", user), params: {external_url: "test.gitlab.com"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 if environment already exists' do
- post api("/projects/#{project.id}/environments", user), params: { name: environment.name }
+ it "returns a 400 if environment already exists" do
+ post api("/projects/#{project.id}/environments", user), params: {name: environment.name}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 if slug is specified' do
- post api("/projects/#{project.id}/environments", user), params: { name: "foo", slug: "foo" }
+ it "returns a 400 if slug is specified" do
+ post api("/projects/#{project.id}/environments", user), params: {name: "foo", slug: "foo"}
expect(response).to have_gitlab_http_status(400)
expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed")
end
end
- context 'a non member' do
- it 'rejects the request' do
- post api("/projects/#{project.id}/environments", non_member), params: { name: 'gitlab.com' }
+ context "a non member" do
+ it "rejects the request" do
+ post api("/projects/#{project.id}/environments", non_member), params: {name: "gitlab.com"}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 400 when the required params are missing' do
- post api("/projects/12345/environments", non_member), params: { external_url: 'http://env.git.com' }
+ it "returns a 400 when the required params are missing" do
+ post api("/projects/12345/environments", non_member), params: {external_url: "http://env.git.com"}
end
end
end
- describe 'PUT /projects/:id/environments/:environment_id' do
- it 'returns a 200 if name and external_url are changed' do
- url = 'https://mepmep.whatever.ninja'
+ describe "PUT /projects/:id/environments/:environment_id" do
+ it "returns a 200 if name and external_url are changed" do
+ url = "https://mepmep.whatever.ninja"
put api("/projects/#{project.id}/environments/#{environment.id}", user),
- params: { name: 'Mepmep', external_url: url }
+ params: {name: "Mepmep", external_url: url}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq('Mepmep')
- expect(json_response['external_url']).to eq(url)
+ expect(json_response["name"]).to eq("Mepmep")
+ expect(json_response["external_url"]).to eq(url)
end
it "won't allow slug to be changed" do
slug = environment.slug
api_url = api("/projects/#{project.id}/environments/#{environment.id}", user)
- put api_url, params: { slug: slug + "-foo" }
+ put api_url, params: {slug: slug + "-foo"}
expect(response).to have_gitlab_http_status(400)
expect(json_response["error"]).to eq("slug is automatically generated and cannot be changed")
@@ -111,42 +111,42 @@ describe API::Environments do
it "won't update the external_url if only the name is passed" do
url = environment.external_url
put api("/projects/#{project.id}/environments/#{environment.id}", user),
- params: { name: 'Mepmep' }
+ params: {name: "Mepmep"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq('Mepmep')
- expect(json_response['external_url']).to eq(url)
+ expect(json_response["name"]).to eq("Mepmep")
+ expect(json_response["external_url"]).to eq(url)
end
- it 'returns a 404 if the environment does not exist' do
+ it "returns a 404 if the environment does not exist" do
put api("/projects/#{project.id}/environments/12345", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'DELETE /projects/:id/environments/:environment_id' do
- context 'as a maintainer' do
- it 'returns a 200 for an existing environment' do
+ describe "DELETE /projects/:id/environments/:environment_id" do
+ context "as a maintainer" do
+ it "returns a 200 for an existing environment" do
delete api("/projects/#{project.id}/environments/#{environment.id}", user)
expect(response).to have_gitlab_http_status(204)
end
- it 'returns a 404 for non existing id' do
+ it "returns a 404 for non existing id" do
delete api("/projects/#{project.id}/environments/12345", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Not found')
+ expect(json_response["message"]).to eq("404 Not found")
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/environments/#{environment.id}", user) }
end
end
- context 'a non member' do
- it 'rejects the request' do
+ context "a non member" do
+ it "rejects the request" do
delete api("/projects/#{project.id}/environments/#{environment.id}", non_member)
expect(response).to have_gitlab_http_status(404)
@@ -154,34 +154,34 @@ describe API::Environments do
end
end
- describe 'POST /projects/:id/environments/:environment_id/stop' do
- context 'as a maintainer' do
- context 'with a stoppable environment' do
+ describe "POST /projects/:id/environments/:environment_id/stop" do
+ context "as a maintainer" do
+ context "with a stoppable environment" do
before do
environment.update(state: :available)
post api("/projects/#{project.id}/environments/#{environment.id}/stop", user)
end
- it 'returns a 200' do
+ it "returns a 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'actually stops the environment' do
+ it "actually stops the environment" do
expect(environment.reload).to be_stopped
end
end
- it 'returns a 404 for non existing id' do
+ it "returns a 404 for non existing id" do
post api("/projects/#{project.id}/environments/12345/stop", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Not found')
+ expect(json_response["message"]).to eq("404 Not found")
end
end
- context 'a non member' do
- it 'rejects the request' do
+ context "a non member" do
+ it "rejects the request" do
post api("/projects/#{project.id}/environments/#{environment.id}/stop", non_member)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/events_spec.rb b/spec/requests/api/events_spec.rb
index 0ac23505de7..5eefa0e1bda 100644
--- a/spec/requests/api/events_spec.rb
+++ b/spec/requests/api/events_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Events do
include ApiHelpers
@@ -9,18 +9,18 @@ describe API::Events do
let(:closed_issue) { create(:closed_issue, project: private_project, author: user) }
let!(:closed_issue_event) { create(:event, project: private_project, author: user, target: closed_issue, action: Event::CLOSED, created_at: Date.new(2016, 12, 30)) }
- describe 'GET /events' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- get api('/events')
+ describe "GET /events" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ get api("/events")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'returns users events' do
- get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', user)
+ context "when authenticated" do
+ it "returns users events" do
+ get api("/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -30,10 +30,10 @@ describe API::Events do
end
context 'when the requesting token has "read_user" scope' do
- let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) }
+ let(:token) { create(:personal_access_token, scopes: ["read_user"], user: user) }
- it 'returns users events' do
- get api('/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31', personal_access_token: token)
+ it "returns users events" do
+ get api("/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", personal_access_token: token)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -43,17 +43,17 @@ describe API::Events do
end
context 'when the requesting token does not have "read_user" or "api" scope' do
- let(:token_without_scopes) { create(:personal_access_token, scopes: ['read_repository'], user: user) }
+ let(:token_without_scopes) { create(:personal_access_token, scopes: ["read_repository"], user: user) }
it 'returns a "403" response' do
- get api('/events', personal_access_token: token_without_scopes)
+ get api("/events", personal_access_token: token_without_scopes)
expect(response).to have_gitlab_http_status(403)
end
end
end
- describe 'GET /users/:id/events' do
+ describe "GET /users/:id/events" do
context "as a user that cannot see another user" do
it 'returns a "404" response' do
allow(Ability).to receive(:allowed?).and_call_original
@@ -67,7 +67,7 @@ describe API::Events do
end
context "as a user token that cannot see another user" do
- let(:non_member_token) { create(:personal_access_token, scopes: ['read_user'], user: non_member) }
+ let(:non_member_token) { create(:personal_access_token, scopes: ["read_user"], user: non_member) }
it 'returns a "404" response' do
allow(Ability).to receive(:allowed?).and_call_original
@@ -81,7 +81,7 @@ describe API::Events do
end
context "as a user that can see the event's project" do
- it 'accepts a username' do
+ it "accepts a username" do
get api("/users/#{user.username}/events", user)
expect(response).to have_gitlab_http_status(200)
@@ -90,7 +90,7 @@ describe API::Events do
expect(json_response.size).to eq(1)
end
- it 'returns the events' do
+ it "returns the events" do
get api("/users/#{user.id}/events", user)
expect(response).to have_gitlab_http_status(200)
@@ -99,35 +99,35 @@ describe API::Events do
expect(json_response.size).to eq(1)
end
- context 'when the list of events includes push events' do
+ context "when the list of events includes push events" do
let(:event) do
create(:push_event, author: user, project: private_project)
end
let!(:payload) { create(:push_event_payload, event: event) }
- let(:payload_hash) { json_response[0]['push_data'] }
+ let(:payload_hash) { json_response[0]["push_data"] }
before do
get api("/users/#{user.id}/events?action=pushed", user)
end
- it 'responds with HTTP 200 OK' do
+ it "responds with HTTP 200 OK" do
expect(response).to have_gitlab_http_status(200)
end
- it 'includes the push payload as a Hash' do
+ it "includes the push payload as a Hash" do
expect(payload_hash).to be_an_instance_of(Hash)
end
- it 'includes the push payload details' do
- expect(payload_hash['commit_count']).to eq(payload.commit_count)
- expect(payload_hash['action']).to eq(payload.action)
- expect(payload_hash['ref_type']).to eq(payload.ref_type)
- expect(payload_hash['commit_to']).to eq(payload.commit_to)
+ it "includes the push payload details" do
+ expect(payload_hash["commit_count"]).to eq(payload.commit_count)
+ expect(payload_hash["action"]).to eq(payload.action)
+ expect(payload_hash["ref_type"]).to eq(payload.ref_type)
+ expect(payload_hash["commit_to"]).to eq(payload.commit_to)
end
end
- context 'when there are multiple events from different projects' do
+ context "when there are multiple events from different projects" do
let(:second_note) { create(:note_on_issue, project: create(:project)) }
before do
@@ -138,42 +138,42 @@ describe API::Events do
end
end
- it 'returns events in the correct order (from newest to oldest)' do
+ it "returns events in the correct order (from newest to oldest)" do
get api("/users/#{user.id}/events", user)
- comment_events = json_response.select { |e| e['action_name'] == 'commented on' }
- close_events = json_response.select { |e| e['action_name'] == 'closed' }
+ comment_events = json_response.select { |e| e["action_name"] == "commented on" }
+ close_events = json_response.select { |e| e["action_name"] == "closed" }
- expect(comment_events[0]['target_id']).to eq(second_note.id)
- expect(close_events[0]['target_id']).to eq(closed_issue.id)
+ expect(comment_events[0]["target_id"]).to eq(second_note.id)
+ expect(close_events[0]["target_id"]).to eq(closed_issue.id)
end
- it 'accepts filter parameters' do
+ it "accepts filter parameters" do
get api("/users/#{user.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user)
expect(json_response.size).to eq(1)
- expect(json_response[0]['target_id']).to eq(closed_issue.id)
+ expect(json_response[0]["target_id"]).to eq(closed_issue.id)
end
end
end
- it 'returns a 404 error if not found' do
- get api('/users/42/events', user)
+ it "returns a 404 error if not found" do
+ get api("/users/42/events", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
end
- describe 'GET /projects/:id/events' do
- context 'when unauthenticated ' do
- it 'returns 404 for private project' do
+ describe "GET /projects/:id/events" do
+ context "when unauthenticated " do
+ it "returns 404 for private project" do
get api("/projects/#{private_project.id}/events")
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 200 status for a public project' do
+ it "returns 200 status for a public project" do
public_project = create(:project, :public)
get api("/projects/#{public_project.id}/events")
@@ -182,21 +182,21 @@ describe API::Events do
end
end
- context 'with inaccessible events' do
+ context "with inaccessible events" do
let(:public_project) { create(:project, :public, creator_id: user.id, namespace: user.namespace) }
let(:confidential_issue) { create(:closed_issue, confidential: true, project: public_project, author: user) }
let!(:confidential_event) { create(:event, project: public_project, author: user, target: confidential_issue, action: Event::CLOSED) }
let(:public_issue) { create(:closed_issue, project: public_project, author: user) }
let!(:public_event) { create(:event, project: public_project, author: user, target: public_issue, action: Event::CLOSED) }
- it 'returns only accessible events' do
+ it "returns only accessible events" do
get api("/projects/#{public_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(1)
end
- it 'returns all events when the user has access' do
+ it "returns all events when the user has access" do
get api("/projects/#{public_project.id}/events", user)
expect(response).to have_gitlab_http_status(200)
@@ -204,56 +204,56 @@ describe API::Events do
end
end
- context 'pagination' do
+ context "pagination" do
let(:public_project) { create(:project, :public) }
before do
create(:event,
- project: public_project,
- target: create(:issue, project: public_project, title: 'Issue 1'),
- action: Event::CLOSED,
- created_at: Date.parse('2018-12-10'))
+ project: public_project,
+ target: create(:issue, project: public_project, title: "Issue 1"),
+ action: Event::CLOSED,
+ created_at: Date.parse("2018-12-10"))
create(:event,
- project: public_project,
- target: create(:issue, confidential: true, project: public_project, title: 'Confidential event'),
- action: Event::CLOSED,
- created_at: Date.parse('2018-12-11'))
+ project: public_project,
+ target: create(:issue, confidential: true, project: public_project, title: "Confidential event"),
+ action: Event::CLOSED,
+ created_at: Date.parse("2018-12-11"))
create(:event,
- project: public_project,
- target: create(:issue, project: public_project, title: 'Issue 2'),
- action: Event::CLOSED,
- created_at: Date.parse('2018-12-12'))
+ project: public_project,
+ target: create(:issue, project: public_project, title: "Issue 2"),
+ action: Event::CLOSED,
+ created_at: Date.parse("2018-12-12"))
end
- it 'correctly returns the second page without inaccessible events' do
- get api("/projects/#{public_project.id}/events", user), params: { per_page: 2, page: 2 }
+ it "correctly returns the second page without inaccessible events" do
+ get api("/projects/#{public_project.id}/events", user), params: {per_page: 2, page: 2}
- titles = json_response.map { |event| event['target_title'] }
+ titles = json_response.map { |event| event["target_title"] }
- expect(titles.first).to eq('Issue 1')
- expect(titles).not_to include('Confidential event')
+ expect(titles.first).to eq("Issue 1")
+ expect(titles).not_to include("Confidential event")
end
- it 'correctly returns the first page without inaccessible events' do
- get api("/projects/#{public_project.id}/events", user), params: { per_page: 2, page: 1 }
+ it "correctly returns the first page without inaccessible events" do
+ get api("/projects/#{public_project.id}/events", user), params: {per_page: 2, page: 1}
- titles = json_response.map { |event| event['target_title'] }
+ titles = json_response.map { |event| event["target_title"] }
- expect(titles.first).to eq('Issue 2')
- expect(titles).not_to include('Confidential event')
+ expect(titles.first).to eq("Issue 2")
+ expect(titles).not_to include("Confidential event")
end
end
- context 'when not permitted to read' do
- it 'returns 404' do
+ context "when not permitted to read" do
+ it "returns 404" do
get api("/projects/#{private_project.id}/events", non_member)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when authenticated' do
- it 'returns project events' do
+ context "when authenticated" do
+ it "returns project events" do
get api("/projects/#{private_project.id}/events?action=closed&target_type=issue&after=2016-12-1&before=2016-12-31", user)
expect(response).to have_gitlab_http_status(200)
@@ -262,36 +262,36 @@ describe API::Events do
expect(json_response.size).to eq(1)
end
- it 'returns 404 if project does not exist' do
+ it "returns 404 if project does not exist" do
get api("/projects/1234/events", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when exists some events' do
- let(:merge_request1) { create(:merge_request, :closed, author: user, assignee: user, source_project: private_project, title: 'Test') }
- let(:merge_request2) { create(:merge_request, :closed, author: user, assignee: user, source_project: private_project, title: 'Test') }
+ context "when exists some events" do
+ let(:merge_request1) { create(:merge_request, :closed, author: user, assignee: user, source_project: private_project, title: "Test") }
+ let(:merge_request2) { create(:merge_request, :closed, author: user, assignee: user, source_project: private_project, title: "Test") }
before do
create_event(merge_request1)
end
- it 'avoids N+1 queries' do
- control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
- get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request }
- end.count
+ it "avoids N+1 queries" do
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) {
+ get api("/projects/#{private_project.id}/events", user), params: {target_type: :merge_request}
+ }.count
create_event(merge_request2)
- expect do
- get api("/projects/#{private_project.id}/events", user), params: { target_type: :merge_request }
- end.not_to exceed_all_query_limit(control_count)
+ expect {
+ get api("/projects/#{private_project.id}/events", user), params: {target_type: :merge_request}
+ }.not_to exceed_all_query_limit(control_count)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to eq(2)
- expect(json_response.map { |r| r['target_id'] }).to match_array([merge_request1.id, merge_request2.id])
+ expect(json_response.map { |r| r["target_id"] }).to match_array([merge_request1.id, merge_request2.id])
end
def create_event(target)
diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb
index 57a57e69a00..51ef549f531 100644
--- a/spec/requests/api/features_spec.rb
+++ b/spec/requests/api/features_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Features do
set(:user) { create(:user) }
@@ -11,343 +11,357 @@ describe API::Features do
end
end
- describe 'GET /features' do
+ describe "GET /features" do
let(:expected_features) do
[
{
- 'name' => 'feature_1',
- 'state' => 'on',
- 'gates' => [{ 'key' => 'boolean', 'value' => true }]
+ "name" => "feature_1",
+ "state" => "on",
+ "gates" => [{"key" => "boolean", "value" => true}],
},
{
- 'name' => 'feature_2',
- 'state' => 'off',
- 'gates' => [{ 'key' => 'boolean', 'value' => false }]
+ "name" => "feature_2",
+ "state" => "off",
+ "gates" => [{"key" => "boolean", "value" => false}],
},
{
- 'name' => 'feature_3',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'groups', 'value' => ['perf_team'] }
- ]
- }
+ "name" => "feature_3",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "groups", "value" => ["perf_team"]},
+ ],
+ },
]
end
before do
- Feature.get('feature_1').enable
- Feature.get('feature_2').disable
- Feature.get('feature_3').enable Feature.group(:perf_team)
+ Feature.get("feature_1").enable
+ Feature.get("feature_2").disable
+ Feature.get("feature_3").enable Feature.group(:perf_team)
end
- it 'returns a 401 for anonymous users' do
- get api('/features')
+ it "returns a 401 for anonymous users" do
+ get api("/features")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
- get api('/features', user)
+ it "returns a 403 for users" do
+ get api("/features", user)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns the feature list for admins' do
- get api('/features', admin)
+ it "returns the feature list for admins" do
+ get api("/features", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to match_array(expected_features)
end
end
- describe 'POST /feature' do
- let(:feature_name) { 'my_feature' }
+ describe "POST /feature" do
+ let(:feature_name) { "my_feature" }
- context 'when the feature does not exist' do
- it 'returns a 401 for anonymous users' do
+ context "when the feature does not exist" do
+ it "returns a 401 for anonymous users" do
post api("/features/#{feature_name}")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
+ it "returns a 403 for users" do
post api("/features/#{feature_name}", user)
expect(response).to have_gitlab_http_status(403)
end
- context 'when passed value=true' do
- it 'creates an enabled feature' do
- post api("/features/#{feature_name}", admin), params: { value: 'true' }
+ context "when passed value=true" do
+ it "creates an enabled feature" do
+ post api("/features/#{feature_name}", admin), params: {value: "true"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'on',
- 'gates' => [{ 'key' => 'boolean', 'value' => true }])
+ "name" => "my_feature",
+ "state" => "on",
+ "gates" => [{"key" => "boolean", "value" => true}]
+ )
end
- it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' }
+ it "creates an enabled feature for the given Flipper group when passed feature_group=perf_team" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", feature_group: "perf_team"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'groups', 'value' => ['perf_team'] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "groups", "value" => ["perf_team"]},
+ ]
+ )
end
- it 'creates an enabled feature for the given user when passed user=username' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username }
+ it "creates an enabled feature for the given user when passed user=username" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", user: user.username}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'actors', 'value' => ["User:#{user.id}"] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "actors", "value" => ["User:#{user.id}"]},
+ ]
+ )
end
- it 'creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username, feature_group: 'perf_team' }
+ it "creates an enabled feature for the given user and feature group when passed user=username and feature_group=perf_team" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", user: user.username, feature_group: "perf_team"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'groups', 'value' => ['perf_team'] },
- { 'key' => 'actors', 'value' => ["User:#{user.id}"] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "groups", "value" => ["perf_team"]},
+ {"key" => "actors", "value" => ["User:#{user.id}"]},
+ ]
+ )
end
end
- context 'when enabling for a project by path' do
- context 'when the project exists' do
+ context "when enabling for a project by path" do
+ context "when the project exists" do
let!(:project) { create(:project) }
- it 'sets the feature gate' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', project: project.full_path }
+ it "sets the feature gate" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", project: project.full_path}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'actors', 'value' => ["Project:#{project.id}"] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "actors", "value" => ["Project:#{project.id}"]},
+ ]
+ )
end
end
- context 'when the project does not exist' do
- it 'sets no new values' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', project: 'mep/to/the/mep/mep' }
+ context "when the project does not exist" do
+ it "sets no new values" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", project: "mep/to/the/mep/mep"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
"name" => "my_feature",
"state" => "off",
"gates" => [
- { "key" => "boolean", "value" => false }
+ {"key" => "boolean", "value" => false},
]
)
end
end
end
- context 'when enabling for a group by path' do
- context 'when the group exists' do
- it 'sets the feature gate' do
+ context "when enabling for a group by path" do
+ context "when the group exists" do
+ it "sets the feature gate" do
group = create(:group)
- post api("/features/#{feature_name}", admin), params: { value: 'true', group: group.full_path }
+ post api("/features/#{feature_name}", admin), params: {value: "true", group: group.full_path}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'actors', 'value' => ["Group:#{group.id}"] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "actors", "value" => ["Group:#{group.id}"]},
+ ]
+ )
end
end
- context 'when the group does not exist' do
- it 'sets no new values and keeps the feature disabled' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', group: 'not/a/group' }
+ context "when the group does not exist" do
+ it "sets no new values and keeps the feature disabled" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", group: "not/a/group"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
"name" => "my_feature",
"state" => "off",
"gates" => [
- { "key" => "boolean", "value" => false }
+ {"key" => "boolean", "value" => false},
]
)
end
end
end
- it 'creates a feature with the given percentage if passed an integer' do
- post api("/features/#{feature_name}", admin), params: { value: '50' }
+ it "creates a feature with the given percentage if passed an integer" do
+ post api("/features/#{feature_name}", admin), params: {value: "50"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'percentage_of_time', 'value' => 50 }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "percentage_of_time", "value" => 50},
+ ]
+ )
end
end
- context 'when the feature exists' do
+ context "when the feature exists" do
let(:feature) { Feature.get(feature_name) }
before do
feature.disable # This also persists the feature on the DB
end
- context 'when passed value=true' do
- it 'enables the feature' do
- post api("/features/#{feature_name}", admin), params: { value: 'true' }
+ context "when passed value=true" do
+ it "enables the feature" do
+ post api("/features/#{feature_name}", admin), params: {value: "true"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'on',
- 'gates' => [{ 'key' => 'boolean', 'value' => true }])
+ "name" => "my_feature",
+ "state" => "on",
+ "gates" => [{"key" => "boolean", "value" => true}]
+ )
end
- it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', feature_group: 'perf_team' }
+ it "enables the feature for the given Flipper group when passed feature_group=perf_team" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", feature_group: "perf_team"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'groups', 'value' => ['perf_team'] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "groups", "value" => ["perf_team"]},
+ ]
+ )
end
- it 'enables the feature for the given user when passed user=username' do
- post api("/features/#{feature_name}", admin), params: { value: 'true', user: user.username }
+ it "enables the feature for the given user when passed user=username" do
+ post api("/features/#{feature_name}", admin), params: {value: "true", user: user.username}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'actors', 'value' => ["User:#{user.id}"] }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "actors", "value" => ["User:#{user.id}"]},
+ ]
+ )
end
end
- context 'when feature is enabled and value=false is passed' do
- it 'disables the feature' do
+ context "when feature is enabled and value=false is passed" do
+ it "disables the feature" do
feature.enable
expect(feature).to be_enabled
- post api("/features/#{feature_name}", admin), params: { value: 'false' }
+ post api("/features/#{feature_name}", admin), params: {value: "false"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'off',
- 'gates' => [{ 'key' => 'boolean', 'value' => false }])
+ "name" => "my_feature",
+ "state" => "off",
+ "gates" => [{"key" => "boolean", "value" => false}]
+ )
end
- it 'disables the feature for the given Flipper group when passed feature_group=perf_team' do
+ it "disables the feature for the given Flipper group when passed feature_group=perf_team" do
feature.enable(Feature.group(:perf_team))
expect(Feature.get(feature_name).enabled?(admin)).to be_truthy
- post api("/features/#{feature_name}", admin), params: { value: 'false', feature_group: 'perf_team' }
+ post api("/features/#{feature_name}", admin), params: {value: "false", feature_group: "perf_team"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'off',
- 'gates' => [{ 'key' => 'boolean', 'value' => false }])
+ "name" => "my_feature",
+ "state" => "off",
+ "gates" => [{"key" => "boolean", "value" => false}]
+ )
end
- it 'disables the feature for the given user when passed user=username' do
+ it "disables the feature for the given user when passed user=username" do
feature.enable(user)
expect(Feature.get(feature_name).enabled?(user)).to be_truthy
- post api("/features/#{feature_name}", admin), params: { value: 'false', user: user.username }
+ post api("/features/#{feature_name}", admin), params: {value: "false", user: user.username}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'off',
- 'gates' => [{ 'key' => 'boolean', 'value' => false }])
+ "name" => "my_feature",
+ "state" => "off",
+ "gates" => [{"key" => "boolean", "value" => false}]
+ )
end
end
- context 'with a pre-existing percentage value' do
+ context "with a pre-existing percentage value" do
before do
feature.enable_percentage_of_time(50)
end
- it 'updates the percentage of time if passed an integer' do
- post api("/features/#{feature_name}", admin), params: { value: '30' }
+ it "updates the percentage of time if passed an integer" do
+ post api("/features/#{feature_name}", admin), params: {value: "30"}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to eq(
- 'name' => 'my_feature',
- 'state' => 'conditional',
- 'gates' => [
- { 'key' => 'boolean', 'value' => false },
- { 'key' => 'percentage_of_time', 'value' => 30 }
- ])
+ "name" => "my_feature",
+ "state" => "conditional",
+ "gates" => [
+ {"key" => "boolean", "value" => false},
+ {"key" => "percentage_of_time", "value" => 30},
+ ]
+ )
end
end
end
end
- describe 'DELETE /feature/:name' do
- let(:feature_name) { 'my_feature' }
+ describe "DELETE /feature/:name" do
+ let(:feature_name) { "my_feature" }
- context 'when the user has no access' do
- it 'returns a 401 for anonymous users' do
+ context "when the user has no access" do
+ it "returns a 401 for anonymous users" do
delete api("/features/#{feature_name}")
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 403 for users' do
+ it "returns a 403 for users" do
delete api("/features/#{feature_name}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when the user has access' do
- it 'returns 204 when the value is not set' do
+ context "when the user has access" do
+ it "returns 204 when the value is not set" do
delete api("/features/#{feature_name}", admin)
expect(response).to have_gitlab_http_status(204)
end
- context 'when the gate value was set' do
+ context "when the gate value was set" do
before do
Feature.get(feature_name).enable
end
- it 'deletes an enabled feature' do
+ it "deletes an enabled feature" do
delete api("/features/#{feature_name}", admin)
expect(response).to have_gitlab_http_status(204)
diff --git a/spec/requests/api/files_spec.rb b/spec/requests/api/files_spec.rb
index 1ad536258ba..c328593e820 100644
--- a/spec/requests/api/files_spec.rb
+++ b/spec/requests/api/files_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Files do
let(:user) { create(:user) }
- let!(:project) { create(:project, :repository, namespace: user.namespace ) }
+ let!(:project) { create(:project, :repository, namespace: user.namespace) }
let(:guest) { create(:user) { |u| project.add_guest(u) } }
let(:file_path) { "files%2Fruby%2Fpopen%2Erb" }
let(:params) do
{
- ref: 'master'
+ ref: "master",
}
end
- let(:author_email) { 'user@example.org' }
- let(:author_name) { 'John Doe' }
+ let(:author_email) { "user@example.org" }
+ let(:author_name) { "John Doe" }
let(:helper) do
- fake_class = Class.new do
+ fake_class = Class.new {
include ::API::Helpers::HeadersHelpers
attr_reader :headers
@@ -26,7 +26,7 @@ describe API::Files do
def header(key, value)
@headers[key] = value
end
- end
+ }
fake_class.new
end
@@ -39,31 +39,31 @@ describe API::Files do
"/projects/#{project.id}/repository/files/#{file_path}"
end
- context 'http headers' do
- it 'converts value into string' do
+ context "http headers" do
+ it "converts value into string" do
helper.set_http_headers(test: 1)
- expect(helper.headers).to eq({ 'X-Gitlab-Test' => '1' })
+ expect(helper.headers).to eq({"X-Gitlab-Test" => "1"})
end
- it 'raises exception if value is an Enumerable' do
+ it "raises exception if value is an Enumerable" do
expect { helper.set_http_headers(test: [1]) }.to raise_error(ArgumentError)
end
end
describe "HEAD /projects/:id/repository/files/:file_path" do
- shared_examples_for 'repository files' do
- it 'returns file attributes in headers' do
+ shared_examples_for "repository files" do
+ it "returns file attributes in headers" do
head api(route(file_path), current_user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(response.headers['X-Gitlab-File-Path']).to eq(CGI.unescape(file_path))
- expect(response.headers['X-Gitlab-File-Name']).to eq('popen.rb')
- expect(response.headers['X-Gitlab-Last-Commit-Id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
- expect(response.headers['X-Gitlab-Content-Sha256']).to eq('c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887')
+ expect(response.headers["X-Gitlab-File-Path"]).to eq(CGI.unescape(file_path))
+ expect(response.headers["X-Gitlab-File-Name"]).to eq("popen.rb")
+ expect(response.headers["X-Gitlab-Last-Commit-Id"]).to eq("570e7b2abdd848b95f2f578043fc23bd6f6fd24d")
+ expect(response.headers["X-Gitlab-Content-Sha256"]).to eq("c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887")
end
- it 'returns file by commit sha' do
+ it "returns file by commit sha" do
# This file is deleted on HEAD
file_path = "files%2Fjs%2Fcommit%2Ejs%2Ecoffee"
params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
@@ -71,11 +71,11 @@ describe API::Files do
head api(route(file_path), current_user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(response.headers['X-Gitlab-File-Name']).to eq('commit.js.coffee')
- expect(response.headers['X-Gitlab-Content-Sha256']).to eq('08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929')
+ expect(response.headers["X-Gitlab-File-Name"]).to eq("commit.js.coffee")
+ expect(response.headers["X-Gitlab-Content-Sha256"]).to eq("08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929")
end
- context 'when mandatory params are not given' do
+ context "when mandatory params are not given" do
it "responds with a 400 status" do
head api(route("any%2Ffile"), current_user)
@@ -83,18 +83,18 @@ describe API::Files do
end
end
- context 'when file_path does not exist' do
+ context "when file_path does not exist" do
it "responds with a 404 status" do
- params[:ref] = 'master'
+ params[:ref] = "master"
- head api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params
+ head api(route("app%2Fmodels%2Fapplication%2Erb"), current_user), params: params
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when file_path does not exist' do
- include_context 'disabled repository'
+ context "when file_path does not exist" do
+ include_context "disabled repository"
it "responds with a 403 status" do
head api(route(file_path), current_user), params: params
@@ -104,14 +104,14 @@ describe API::Files do
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository files' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository files" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
+ context "when unauthenticated", "and project is private" do
it "responds with a 404 status" do
current_user = nil
@@ -121,49 +121,49 @@ describe API::Files do
end
end
- context 'when PATs are used' do
- it_behaves_like 'repository files' do
- let(:token) { create(:personal_access_token, scopes: ['read_repository'], user: user) }
- let(:current_user) { { personal_access_token: token } }
+ context "when PATs are used" do
+ it_behaves_like "repository files" do
+ let(:token) { create(:personal_access_token, scopes: ["read_repository"], user: user) }
+ let(:current_user) { {personal_access_token: token} }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository files' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository files" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { head api(route(file_path), guest), params: params }
end
end
end
describe "GET /projects/:id/repository/files/:file_path" do
- shared_examples_for 'repository files' do
- it 'returns file attributes as json' do
+ shared_examples_for "repository files" do
+ it "returns file attributes as json" do
get api(route(file_path), current_user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['file_path']).to eq(CGI.unescape(file_path))
- expect(json_response['file_name']).to eq('popen.rb')
- expect(json_response['last_commit_id']).to eq('570e7b2abdd848b95f2f578043fc23bd6f6fd24d')
- expect(json_response['content_sha256']).to eq('c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887')
- expect(Base64.decode64(json_response['content']).lines.first).to eq("require 'fileutils'\n")
+ expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
+ expect(json_response["file_name"]).to eq("popen.rb")
+ expect(json_response["last_commit_id"]).to eq("570e7b2abdd848b95f2f578043fc23bd6f6fd24d")
+ expect(json_response["content_sha256"]).to eq("c440cd09bae50c4632cc58638ad33c6aa375b6109d811e76a9cc3a613c1e8887")
+ expect(Base64.decode64(json_response["content"]).lines.first).to eq("require 'fileutils'\n")
end
- it 'returns json when file has txt extension' do
+ it "returns json when file has txt extension" do
file_path = "bar%2Fbranch-test.txt"
get api(route(file_path), current_user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq('application/json')
+ expect(response.content_type).to eq("application/json")
end
- it 'returns file by commit sha' do
+ it "returns file by commit sha" do
# This file is deleted on HEAD
file_path = "files%2Fjs%2Fcommit%2Ejs%2Ecoffee"
params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
@@ -171,12 +171,12 @@ describe API::Files do
get api(route(file_path), current_user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['file_name']).to eq('commit.js.coffee')
- expect(json_response['content_sha256']).to eq('08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929')
- expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n")
+ expect(json_response["file_name"]).to eq("commit.js.coffee")
+ expect(json_response["content_sha256"]).to eq("08785f04375b47f81f46e68cc125d5ef368aa20576ddb53f91f4d83f1d04b929")
+ expect(Base64.decode64(json_response["content"]).lines.first).to eq("class Commit\n")
end
- it 'returns raw file info' do
+ it "returns raw file info" do
url = route(file_path) + "/raw"
expect(Gitlab::Workhorse).to receive(:send_git_blob)
@@ -186,75 +186,75 @@ describe API::Files do
expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
- it 'sets inline content disposition by default' do
+ it "sets inline content disposition by default" do
url = route(file_path) + "/raw"
get api(url, current_user), params: params
- expect(headers['Content-Disposition']).to eq(%q(inline; filename="popen.rb"; filename*=UTF-8''popen.rb))
+ expect(headers["Content-Disposition"]).to eq(%q(inline; filename="popen.rb"; filename*=UTF-8''popen.rb))
end
- context 'when mandatory params are not given' do
- it_behaves_like '400 response' do
+ context "when mandatory params are not given" do
+ it_behaves_like "400 response" do
let(:request) { get api(route("any%2Ffile"), current_user) }
end
end
- context 'when file_path does not exist' do
- let(:params) { { ref: 'master' } }
+ context "when file_path does not exist" do
+ let(:params) { {ref: "master"} }
- it_behaves_like '404 response' do
- let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params }
- let(:message) { '404 File Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { get api(route("app%2Fmodels%2Fapplication%2Erb"), current_user), params: params }
+ let(:message) { "404 File Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route(file_path), current_user), params: params }
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository files' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository files" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when PATs are used' do
- it_behaves_like 'repository files' do
- let(:token) { create(:personal_access_token, scopes: ['read_repository'], user: user) }
- let(:current_user) { { personal_access_token: token } }
+ context "when PATs are used" do
+ it_behaves_like "repository files" do
+ let(:token) { create(:personal_access_token, scopes: ["read_repository"], user: user) }
+ let(:current_user) { {personal_access_token: token} }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route(file_path)), params: params }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository files' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository files" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route(file_path), guest), params: params }
end
end
end
describe "GET /projects/:id/repository/files/:file_path/raw" do
- shared_examples_for 'repository raw files' do
- it 'returns raw file info' do
+ shared_examples_for "repository raw files" do
+ it "returns raw file info" do
url = route(file_path) + "/raw"
expect(Gitlab::Workhorse).to receive(:send_git_blob)
@@ -263,8 +263,8 @@ describe API::Files do
expect(response).to have_gitlab_http_status(200)
end
- it 'returns raw file info for files with dots' do
- url = route('.gitignore') + "/raw"
+ it "returns raw file info for files with dots" do
+ url = route(".gitignore") + "/raw"
expect(Gitlab::Workhorse).to receive(:send_git_blob)
get api(url, current_user), params: params
@@ -272,7 +272,7 @@ describe API::Files do
expect(response).to have_gitlab_http_status(200)
end
- it 'returns file by commit sha' do
+ it "returns file by commit sha" do
# This file is deleted on HEAD
file_path = "files%2Fjs%2Fcommit%2Ejs%2Ecoffee"
params[:ref] = "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9"
@@ -283,59 +283,59 @@ describe API::Files do
expect(response).to have_gitlab_http_status(200)
end
- context 'when mandatory params are not given' do
- it_behaves_like '400 response' do
+ context "when mandatory params are not given" do
+ it_behaves_like "400 response" do
let(:request) { get api(route("any%2Ffile"), current_user) }
end
end
- context 'when file_path does not exist' do
- let(:params) { { ref: 'master' } }
+ context "when file_path does not exist" do
+ let(:params) { {ref: "master"} }
- it_behaves_like '404 response' do
- let(:request) { get api(route('app%2Fmodels%2Fapplication%2Erb'), current_user), params: params }
- let(:message) { '404 File Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { get api(route("app%2Fmodels%2Fapplication%2Erb"), current_user), params: params }
+ let(:message) { "404 File Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route(file_path), current_user), params: params }
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository raw files' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository raw files" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route(file_path)), params: params }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository raw files' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository raw files" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route(file_path), guest), params: params }
end
end
- context 'when PATs are used' do
- it 'returns file by commit sha' do
- token = create(:personal_access_token, scopes: ['read_repository'], user: user)
+ context "when PATs are used" do
+ it "returns file by commit sha" do
+ token = create(:personal_access_token, scopes: ["read_repository"], user: user)
# This file is deleted on HEAD
file_path = "files%2Fjs%2Fcommit%2Ejs%2Ecoffee"
@@ -355,7 +355,7 @@ describe API::Files do
{
branch: "master",
content: "puts 8",
- commit_message: "Added newfile"
+ commit_message: "Added newfile",
}
end
@@ -375,8 +375,8 @@ describe API::Files do
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 bad request if the commit message is empty' do
- params[:commit_message] = ''
+ it "returns a 400 bad request if the commit message is empty" do
+ params[:commit_message] = ""
post api(route(file_path), user), params: params
@@ -385,24 +385,24 @@ describe API::Files do
it "returns a 400 if editor fails to create file" do
allow_any_instance_of(Repository).to receive(:create_file)
- .and_raise(Gitlab::Git::CommitError, 'Cannot create file')
+ .and_raise(Gitlab::Git::CommitError, "Cannot create file")
post api(route("any%2Etxt"), user), params: params
expect(response).to have_gitlab_http_status(400)
end
- context 'with PATs' do
- it 'returns 403 with `read_repository` scope' do
- token = create(:personal_access_token, scopes: ['read_repository'], user: user)
+ context "with PATs" do
+ it "returns 403 with `read_repository` scope" do
+ token = create(:personal_access_token, scopes: ["read_repository"], user: user)
post api(route(file_path), personal_access_token: token), params: params
expect(response).to have_gitlab_http_status(403)
end
- it 'returns 201 with `api` scope' do
- token = create(:personal_access_token, scopes: ['api'], user: user)
+ it "returns 201 with `api` scope" do
+ token = create(:personal_access_token, scopes: ["api"], user: user)
post api(route(file_path), personal_access_token: token), params: params
@@ -417,21 +417,21 @@ describe API::Files do
post api(route("new_file_with_author%2Etxt"), user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(response.content_type).to eq('application/json')
+ expect(response.content_type).to eq("application/json")
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(author_email)
expect(last_commit.author_name).to eq(author_name)
end
end
- context 'when the repo is empty' do
- let!(:project) { create(:project_empty_repo, namespace: user.namespace ) }
+ context "when the repo is empty" do
+ let!(:project) { create(:project_empty_repo, namespace: user.namespace) }
it "creates a new file in project repo" do
post api(route("newfile%2Erb"), user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['file_path']).to eq('newfile.rb')
+ expect(json_response["file_path"]).to eq("newfile.rb")
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
expect(last_commit.author_name).to eq(user.name)
@@ -442,9 +442,9 @@ describe API::Files do
describe "PUT /projects/:id/repository/files" do
let(:params) do
{
- branch: 'master',
- content: 'puts 8',
- commit_message: 'Changed file'
+ branch: "master",
+ content: "puts 8",
+ commit_message: "Changed file",
}
end
@@ -452,14 +452,14 @@ describe API::Files do
put api(route(file_path), user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['file_path']).to eq(CGI.unescape(file_path))
+ expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
last_commit = project.repository.commit.raw
expect(last_commit.author_email).to eq(user.email)
expect(last_commit.author_name).to eq(user.name)
end
- it 'returns a 400 bad request if the commit message is empty' do
- params[:commit_message] = ''
+ it "returns a 400 bad request if the commit message is empty" do
+ params[:commit_message] = ""
put api(route(file_path), user), params: params
@@ -467,17 +467,17 @@ describe API::Files do
end
it "returns a 400 bad request if update existing file with stale last commit id" do
- params_with_stale_id = params.merge(last_commit_id: 'stale')
+ params_with_stale_id = params.merge(last_commit_id: "stale")
put api(route(file_path), user), params: params_with_stale_id
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('You are attempting to update a file that has changed since you started editing it.')
+ expect(json_response["message"]).to eq("You are attempting to update a file that has changed since you started editing it.")
end
it "updates existing file in project repo with accepts correct last commit id" do
last_commit = Gitlab::Git::Commit
- .last_for_path(project.repository, 'master', URI.unescape(file_path))
+ .last_for_path(project.repository, "master", URI.unescape(file_path))
params_with_correct_id = params.merge(last_commit_id: last_commit.id)
put api(route(file_path), user), params: params_with_correct_id
@@ -508,8 +508,8 @@ describe API::Files do
describe "DELETE /projects/:id/repository/files" do
let(:params) do
{
- branch: 'master',
- commit_message: 'Changed file'
+ branch: "master",
+ commit_message: "Changed file",
}
end
@@ -525,8 +525,8 @@ describe API::Files do
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 bad request if the commit message is empty' do
- params[:commit_message] = ''
+ it "returns a 400 bad request if the commit message is empty" do
+ params[:commit_message] = ""
delete api(route(file_path), user), params: params
@@ -534,7 +534,7 @@ describe API::Files do
end
it "returns a 400 if fails to delete file" do
- allow_any_instance_of(Repository).to receive(:delete_file).and_raise(Gitlab::Git::CommitError, 'Cannot delete file')
+ allow_any_instance_of(Repository).to receive(:delete_file).and_raise(Gitlab::Git::CommitError, "Cannot delete file")
delete api(route(file_path), user), params: params
@@ -553,18 +553,18 @@ describe API::Files do
end
describe "POST /projects/:id/repository/files with binary file" do
- let(:file_path) { 'test%2Ebin' }
+ let(:file_path) { "test%2Ebin" }
let(:put_params) do
{
- branch: 'master',
- content: 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=',
+ branch: "master",
+ content: "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII=",
commit_message: 'Binary file with a \n should not be touched',
- encoding: 'base64'
+ encoding: "base64",
}
end
let(:get_params) do
{
- ref: 'master'
+ ref: "master",
}
end
@@ -576,9 +576,9 @@ describe API::Files do
get api(route(file_path), user), params: get_params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['file_path']).to eq(CGI.unescape(file_path))
- expect(json_response['file_name']).to eq(CGI.unescape(file_path))
- expect(json_response['content']).to eq(put_params[:content])
+ expect(json_response["file_path"]).to eq(CGI.unescape(file_path))
+ expect(json_response["file_name"]).to eq(CGI.unescape(file_path))
+ expect(json_response["content"]).to eq(put_params[:content])
end
end
end
diff --git a/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb b/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb
index 8f427d71a32..4b4fda22721 100644
--- a/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb
+++ b/spec/requests/api/graphql/mutations/merge_requests/set_wip_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Setting WIP status of a merge request' do
+describe "Setting WIP status of a merge request" do
include GraphqlHelpers
let(:current_user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:project) { merge_request.project }
- let(:input) { { wip: true } }
+ let(:input) { {wip: true} }
let(:mutation) do
variables = {
project_path: project.full_path,
- iid: merge_request.iid
+ iid: merge_request.iid,
}
graphql_mutation(:merge_request_set_wip, variables.merge(input))
end
@@ -24,45 +24,45 @@ describe 'Setting WIP status of a merge request' do
project.add_developer(current_user)
end
- it 'returns an error if the user is not allowed to update the merge request' do
+ it "returns an error if the user is not allowed to update the merge request" do
post_graphql_mutation(mutation, current_user: create(:user))
expect(graphql_errors).not_to be_empty
end
- it 'marks the merge request as WIP' do
+ it "marks the merge request as WIP" do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
- expect(mutation_response['mergeRequest']['title']).to start_with('WIP:')
+ expect(mutation_response["mergeRequest"]["title"]).to start_with("WIP:")
end
- it 'does not do anything if the merge request was already marked `WIP`' do
- merge_request.update!(title: 'wip: hello world')
+ it "does not do anything if the merge request was already marked `WIP`" do
+ merge_request.update!(title: "wip: hello world")
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
- expect(mutation_response['mergeRequest']['title']).to start_with('wip:')
+ expect(mutation_response["mergeRequest"]["title"]).to start_with("wip:")
end
- context 'when passing WIP false as input' do
- let(:input) { { wip: false } }
+ context "when passing WIP false as input" do
+ let(:input) { {wip: false} }
- it 'does not do anything if the merge reqeust was not marked wip' do
+ it "does not do anything if the merge reqeust was not marked wip" do
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
- expect(mutation_response['mergeRequest']['title']).not_to start_with(/wip\:/)
+ expect(mutation_response["mergeRequest"]["title"]).not_to start_with(/wip\:/)
end
- it 'unmarks the merge request as `WIP`' do
- merge_request.update!(title: 'wip: hello world')
+ it "unmarks the merge request as `WIP`" do
+ merge_request.update!(title: "wip: hello world")
post_graphql_mutation(mutation, current_user: current_user)
expect(response).to have_gitlab_http_status(:success)
- expect(mutation_response['mergeRequest']['title']).not_to start_with('/wip\:/')
+ expect(mutation_response["mergeRequest"]["title"]).not_to start_with('/wip\:/')
end
end
end
diff --git a/spec/requests/api/graphql/project/issues_spec.rb b/spec/requests/api/graphql/project/issues_spec.rb
index c2934430821..3493fa00509 100644
--- a/spec/requests/api/graphql/project/issues_spec.rb
+++ b/spec/requests/api/graphql/project/issues_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'getting an issue list for a project' do
+describe "getting an issue list for a project" do
include GraphqlHelpers
let(:project) { create(:project, :repository, :public) }
let(:current_user) { create(:user) }
- let(:issues_data) { graphql_data['project']['issues']['edges'] }
+ let(:issues_data) { graphql_data["project"]["issues"]["edges"] }
let!(:issues) do
create(:issue, project: project, discussion_locked: true)
create(:issue, project: project)
end
let(:fields) do
<<~QUERY
- edges {
- node {
- #{all_graphql_fields_for('issues'.classify)}
+ edges {
+ node {
+ #{all_graphql_fields_for("issues".classify)}
+ }
}
- }
QUERY
end
let(:query) do
graphql_query_for(
- 'project',
- { 'fullPath' => project.full_path },
- query_graphql_field('issues', {}, fields)
+ "project",
+ {"fullPath" => project.full_path},
+ query_graphql_field("issues", {}, fields)
)
end
- it_behaves_like 'a working graphql query' do
+ it_behaves_like "a working graphql query" do
before do
post_graphql(query, current_user: current_user)
end
end
- it 'includes a web_url' do
+ it "includes a web_url" do
post_graphql(query, current_user: current_user)
- expect(issues_data[0]['node']['webUrl']).to be_present
+ expect(issues_data[0]["node"]["webUrl"]).to be_present
end
- it 'includes discussion locked' do
+ it "includes discussion locked" do
post_graphql(query, current_user: current_user)
- expect(issues_data[0]['node']['discussionLocked']).to eq false
- expect(issues_data[1]['node']['discussionLocked']).to eq true
+ expect(issues_data[0]["node"]["discussionLocked"]).to eq false
+ expect(issues_data[1]["node"]["discussionLocked"]).to eq true
end
- context 'when the user does not have access to the issue' do
- it 'returns nil' do
+ context "when the user does not have access to the issue" do
+ it "returns nil" do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
post_graphql(query)
@@ -57,34 +57,34 @@ describe 'getting an issue list for a project' do
end
end
- context 'when there is a confidential issue' do
+ context "when there is a confidential issue" do
let!(:confidential_issue) do
create(:issue, :confidential, project: project)
end
- context 'when the user cannot see confidential issues' do
- it 'returns issues without confidential issues' do
+ context "when the user cannot see confidential issues" do
+ it "returns issues without confidential issues" do
post_graphql(query, current_user: current_user)
expect(issues_data.size).to eq(2)
issues_data.each do |issue|
- expect(issue.dig('node', 'confidential')).to eq(false)
+ expect(issue.dig("node", "confidential")).to eq(false)
end
end
end
- context 'when the user can see confidential issues' do
- it 'returns issues with confidential issues' do
+ context "when the user can see confidential issues" do
+ it "returns issues with confidential issues" do
project.add_developer(current_user)
post_graphql(query, current_user: current_user)
expect(issues_data.size).to eq(3)
- confidentials = issues_data.map do |issue|
- issue.dig('node', 'confidential')
- end
+ confidentials = issues_data.map { |issue|
+ issue.dig("node", "confidential")
+ }
expect(confidentials).to eq([true, false, false])
end
diff --git a/spec/requests/api/graphql/project/merge_request_spec.rb b/spec/requests/api/graphql/project/merge_request_spec.rb
index deb6abbc026..b45f32eefbb 100644
--- a/spec/requests/api/graphql/project/merge_request_spec.rb
+++ b/spec/requests/api/graphql/project/merge_request_spec.rb
@@ -1,65 +1,65 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'getting merge request information nested in a project' do
+describe "getting merge request information nested in a project" do
include GraphqlHelpers
let(:project) { create(:project, :repository, :public) }
let(:current_user) { create(:user) }
- let(:merge_request_graphql_data) { graphql_data['project']['mergeRequest'] }
+ let(:merge_request_graphql_data) { graphql_data["project"]["mergeRequest"] }
let!(:merge_request) { create(:merge_request, source_project: project) }
let(:query) do
graphql_query_for(
- 'project',
- { 'fullPath' => project.full_path },
- query_graphql_field('mergeRequest', iid: merge_request.iid)
+ "project",
+ {"fullPath" => project.full_path},
+ query_graphql_field("mergeRequest", iid: merge_request.iid)
)
end
- it_behaves_like 'a working graphql query' do
+ it_behaves_like "a working graphql query" do
before do
post_graphql(query, current_user: current_user)
end
end
- it 'contains merge request information' do
+ it "contains merge request information" do
post_graphql(query, current_user: current_user)
expect(merge_request_graphql_data).not_to be_nil
end
# This is a field coming from the `MergeRequestPresenter`
- it 'includes a web_url' do
+ it "includes a web_url" do
post_graphql(query, current_user: current_user)
- expect(merge_request_graphql_data['webUrl']).to be_present
+ expect(merge_request_graphql_data["webUrl"]).to be_present
end
- context 'permissions on the merge request' do
- it 'includes the permissions for the current user on a public project' do
+ context "permissions on the merge request" do
+ it "includes the permissions for the current user on a public project" do
expected_permissions = {
- 'readMergeRequest' => true,
- 'adminMergeRequest' => false,
- 'createNote' => true,
- 'pushToSourceBranch' => false,
- 'removeSourceBranch' => false,
- 'cherryPickOnCurrentMergeRequest' => false,
- 'revertOnCurrentMergeRequest' => false,
- 'updateMergeRequest' => false
+ "readMergeRequest" => true,
+ "adminMergeRequest" => false,
+ "createNote" => true,
+ "pushToSourceBranch" => false,
+ "removeSourceBranch" => false,
+ "cherryPickOnCurrentMergeRequest" => false,
+ "revertOnCurrentMergeRequest" => false,
+ "updateMergeRequest" => false,
}
post_graphql(query, current_user: current_user)
- permission_data = merge_request_graphql_data['userPermissions']
+ permission_data = merge_request_graphql_data["userPermissions"]
expect(permission_data).to be_present
expect(permission_data).to eq(expected_permissions)
end
end
- context 'when the user does not have access to the merge request' do
+ context "when the user does not have access to the merge request" do
let(:project) { create(:project, :public, :repository) }
- it 'returns nil' do
+ it "returns nil" do
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
post_graphql(query)
@@ -68,7 +68,7 @@ describe 'getting merge request information nested in a project' do
end
end
- context 'when there are pipelines' do
+ context "when there are pipelines" do
before do
pipeline = create(
:ci_pipeline,
@@ -79,16 +79,16 @@ describe 'getting merge request information nested in a project' do
merge_request.update!(head_pipeline: pipeline)
end
- it 'has a head pipeline' do
+ it "has a head pipeline" do
post_graphql(query, current_user: current_user)
- expect(merge_request_graphql_data['headPipeline']).to be_present
+ expect(merge_request_graphql_data["headPipeline"]).to be_present
end
- it 'has pipeline connections' do
+ it "has pipeline connections" do
post_graphql(query, current_user: current_user)
- expect(merge_request_graphql_data['pipelines']['edges'].size).to eq(1)
+ expect(merge_request_graphql_data["pipelines"]["edges"].size).to eq(1)
end
end
end
diff --git a/spec/requests/api/graphql/project_query_spec.rb b/spec/requests/api/graphql/project_query_spec.rb
index 0727ada4691..523efe365e3 100644
--- a/spec/requests/api/graphql/project_query_spec.rb
+++ b/spec/requests/api/graphql/project_query_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'getting project information' do
+describe "getting project information" do
include GraphqlHelpers
let(:project) { create(:project, :repository) }
let(:current_user) { create(:user) }
let(:query) do
- graphql_query_for('project', 'fullPath' => project.full_path)
+ graphql_query_for("project", "fullPath" => project.full_path)
end
- context 'when the user has access to the project' do
+ context "when the user has access to the project" do
before do
project.add_developer(current_user)
end
- it 'includes the project' do
+ it "includes the project" do
post_graphql(query, current_user: current_user)
- expect(graphql_data['project']).not_to be_nil
+ expect(graphql_data["project"]).not_to be_nil
end
- it_behaves_like 'a working graphql query' do
+ it_behaves_like "a working graphql query" do
before do
post_graphql(query, current_user: current_user)
end
end
- context 'when there are pipelines present' do
+ context "when there are pipelines present" do
before do
create(:ci_pipeline, project: project)
end
- it 'is included in the pipelines connection' do
+ it "is included in the pipelines connection" do
post_graphql(query, current_user: current_user)
- expect(graphql_data['project']['pipelines']['edges'].size).to eq(1)
+ expect(graphql_data["project"]["pipelines"]["edges"].size).to eq(1)
end
end
end
- context 'when the user does not have access to the project' do
- it 'returns an empty field' do
+ context "when the user does not have access to the project" do
+ it "returns an empty field" do
post_graphql(query, current_user: current_user)
- expect(graphql_data['project']).to be_nil
+ expect(graphql_data["project"]).to be_nil
end
- it_behaves_like 'a working graphql query' do
+ it_behaves_like "a working graphql query" do
before do
post_graphql(query, current_user: current_user)
end
diff --git a/spec/requests/api/group_boards_spec.rb b/spec/requests/api/group_boards_spec.rb
index b400a7f55ef..7629f7a197e 100644
--- a/spec/requests/api/group_boards_spec.rb
+++ b/spec/requests/api/group_boards_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::GroupBoards do
set(:user) { create(:user) }
@@ -11,18 +11,18 @@ describe API::GroupBoards do
board_parent.add_owner(user)
end
- set(:project) { create(:project, :public, namespace: board_parent ) }
+ set(:project) { create(:project, :public, namespace: board_parent) }
set(:dev_label) do
- create(:group_label, title: 'Development', color: '#FFAABB', group: board_parent)
+ create(:group_label, title: "Development", color: "#FFAABB", group: board_parent)
end
set(:test_label) do
- create(:group_label, title: 'Testing', color: '#FFAACC', group: board_parent)
+ create(:group_label, title: "Testing", color: "#FFAACC", group: board_parent)
end
set(:ux_label) do
- create(:group_label, title: 'UX', color: '#FF0000', group: board_parent)
+ create(:group_label, title: "UX", color: "#FF0000", group: board_parent)
end
set(:dev_list) do
@@ -38,15 +38,15 @@ describe API::GroupBoards do
set(:board) { create(:board, group: board_parent, lists: [dev_list, test_list]) }
- it_behaves_like 'group and project boards', "/groups/:id/boards", false
+ it_behaves_like "group and project boards", "/groups/:id/boards", false
- describe 'POST /groups/:id/boards/lists' do
+ describe "POST /groups/:id/boards/lists" do
let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" }
- it 'does not create lists for child project labels' do
+ it "does not create lists for child project labels" do
project_label = create(:label, project: project)
- post api(url, user), params: { label_id: project_label.id }
+ post api(url, user), params: {label_id: project_label.id}
expect(response).to have_gitlab_http_status(400)
end
diff --git a/spec/requests/api/group_labels_spec.rb b/spec/requests/api/group_labels_spec.rb
index 3769f8b78e4..6c5087b6318 100644
--- a/spec/requests/api/group_labels_spec.rb
+++ b/spec/requests/api/group_labels_spec.rb
@@ -1,94 +1,94 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::GroupLabels do
let(:user) { create(:user) }
let(:group) { create(:group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- let!(:label1) { create(:group_label, title: 'feature', group: group) }
- let!(:label2) { create(:group_label, title: 'bug', group: group) }
+ let!(:label1) { create(:group_label, title: "feature", group: group) }
+ let!(:label2) { create(:group_label, title: "bug", group: group) }
- describe 'GET :id/labels' do
- it 'returns all available labels for the group' do
+ describe "GET :id/labels" do
+ it "returns all available labels for the group" do
get api("/groups/#{group.id}/labels", user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/group_labels')
+ expect(response).to match_response_schema("public_api/v4/group_labels")
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
- expect(json_response.map {|r| r['name'] }).to contain_exactly('feature', 'bug')
+ expect(json_response.map {|r| r["name"] }).to contain_exactly("feature", "bug")
end
end
- describe 'POST /groups/:id/labels' do
- it 'returns created label when all params are given' do
+ describe "POST /groups/:id/labels" do
+ it "returns created label when all params are given" do
post api("/groups/#{group.id}/labels", user),
- params: {
- name: 'Foo',
- color: '#FFAABB',
- description: 'test'
- }
+ params: {
+ name: "Foo",
+ color: "#FFAABB",
+ description: "test",
+ }
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('Foo')
- expect(json_response['color']).to eq('#FFAABB')
- expect(json_response['description']).to eq('test')
+ expect(json_response["name"]).to eq("Foo")
+ expect(json_response["color"]).to eq("#FFAABB")
+ expect(json_response["description"]).to eq("test")
end
- it 'returns created label when only required params are given' do
+ it "returns created label when only required params are given" do
post api("/groups/#{group.id}/labels", user),
- params: {
- name: 'Foo & Bar',
- color: '#FFAABB'
- }
+ params: {
+ name: "Foo & Bar",
+ color: "#FFAABB",
+ }
expect(response.status).to eq(201)
- expect(json_response['name']).to eq('Foo & Bar')
- expect(json_response['color']).to eq('#FFAABB')
- expect(json_response['description']).to be_nil
+ expect(json_response["name"]).to eq("Foo & Bar")
+ expect(json_response["color"]).to eq("#FFAABB")
+ expect(json_response["description"]).to be_nil
end
- it 'returns a 400 bad request if name not given' do
- post api("/groups/#{group.id}/labels", user), params: { color: '#FFAABB' }
+ it "returns a 400 bad request if name not given" do
+ post api("/groups/#{group.id}/labels", user), params: {color: "#FFAABB"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 bad request if color is not given' do
- post api("/groups/#{group.id}/labels", user), params: { name: 'Foobar' }
+ it "returns a 400 bad request if color is not given" do
+ post api("/groups/#{group.id}/labels", user), params: {name: "Foobar"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 409 if label already exists' do
+ it "returns 409 if label already exists" do
post api("/groups/#{group.id}/labels", user),
- params: {
- name: label1.name,
- color: '#FFAABB'
- }
+ params: {
+ name: label1.name,
+ color: "#FFAABB",
+ }
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Label already exists')
+ expect(json_response["message"]).to eq("Label already exists")
end
end
- describe 'DELETE /groups/:id/labels' do
- it 'returns 204 for existing label' do
- delete api("/groups/#{group.id}/labels", user), params: { name: label1.name }
+ describe "DELETE /groups/:id/labels" do
+ it "returns 204 for existing label" do
+ delete api("/groups/#{group.id}/labels", user), params: {name: label1.name}
expect(response).to have_gitlab_http_status(204)
end
- it 'returns 404 for non existing label' do
- delete api("/groups/#{group.id}/labels", user), params: { name: 'label2' }
+ it "returns 404 for non existing label" do
+ delete api("/groups/#{group.id}/labels", user), params: {name: "label2"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Label Not Found')
+ expect(json_response["message"]).to eq("404 Label Not Found")
end
- it 'returns 400 for wrong parameters' do
+ it "returns 400 for wrong parameters" do
delete api("/groups/#{group.id}/labels", user)
expect(response).to have_gitlab_http_status(400)
@@ -96,113 +96,113 @@ describe API::GroupLabels do
it "does not delete parent's group labels", :nested_groups do
subgroup = create(:group, parent: group)
- subgroup_label = create(:group_label, title: 'feature', group: subgroup)
+ subgroup_label = create(:group_label, title: "feature", group: subgroup)
- delete api("/groups/#{subgroup.id}/labels", user), params: { name: subgroup_label.name }
+ delete api("/groups/#{subgroup.id}/labels", user), params: {name: subgroup_label.name}
expect(response).to have_gitlab_http_status(204)
expect(subgroup.labels.size).to eq(0)
expect(group.labels).to include(label1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/groups/#{group.id}/labels", user) }
- let(:params) { { name: label1.name } }
+ let(:params) { {name: label1.name} }
end
end
- describe 'PUT /groups/:id/labels' do
- it 'returns 200 if name and colors and description are changed' do
+ describe "PUT /groups/:id/labels" do
+ it "returns 200 if name and colors and description are changed" do
put api("/groups/#{group.id}/labels", user),
- params: {
- name: label1.name,
- new_name: 'New Label',
- color: '#FFFFFF',
- description: 'test'
- }
+ params: {
+ name: label1.name,
+ new_name: "New Label",
+ color: "#FFFFFF",
+ description: "test",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq('New Label')
- expect(json_response['color']).to eq('#FFFFFF')
- expect(json_response['description']).to eq('test')
+ expect(json_response["name"]).to eq("New Label")
+ expect(json_response["color"]).to eq("#FFFFFF")
+ expect(json_response["description"]).to eq("test")
end
it "does not update parent's group label", :nested_groups do
subgroup = create(:group, parent: group)
- subgroup_label = create(:group_label, title: 'feature', group: subgroup)
+ subgroup_label = create(:group_label, title: "feature", group: subgroup)
put api("/groups/#{subgroup.id}/labels", user),
- params: {
- name: subgroup_label.name,
- new_name: 'New Label'
- }
+ params: {
+ name: subgroup_label.name,
+ new_name: "New Label",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(subgroup.labels[0].name).to eq('New Label')
- expect(label1.name).to eq('feature')
+ expect(subgroup.labels[0].name).to eq("New Label")
+ expect(label1.name).to eq("feature")
end
- it 'returns 404 if label does not exist' do
+ it "returns 404 if label does not exist" do
put api("/groups/#{group.id}/labels", user),
- params: {
- name: 'label2',
- new_name: 'label3'
- }
+ params: {
+ name: "label2",
+ new_name: "label3",
+ }
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 400 if no label name given' do
- put api("/groups/#{group.id}/labels", user), params: { new_name: label1.name }
+ it "returns 400 if no label name given" do
+ put api("/groups/#{group.id}/labels", user), params: {new_name: label1.name}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response["error"]).to eq("name is missing")
end
- it 'returns 400 if no new parameters given' do
- put api("/groups/#{group.id}/labels", user), params: { name: label1.name }
+ it "returns 400 if no new parameters given" do
+ put api("/groups/#{group.id}/labels", user), params: {name: label1.name}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('new_name, color, description are missing, '\
- 'at least one parameter must be provided')
+ expect(json_response["error"]).to eq("new_name, color, description are missing, "\
+ "at least one parameter must be provided")
end
end
- describe 'POST /groups/:id/labels/:label_id/subscribe' do
- context 'when label_id is a label title' do
- it 'subscribes to the label' do
+ describe "POST /groups/:id/labels/:label_id/subscribe" do
+ context "when label_id is a label title" do
+ it "subscribes to the label" do
post api("/groups/#{group.id}/labels/#{label1.title}/subscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(label1.title)
- expect(json_response['subscribed']).to be_truthy
+ expect(json_response["name"]).to eq(label1.title)
+ expect(json_response["subscribed"]).to be_truthy
end
end
- context 'when label_id is a label ID' do
- it 'subscribes to the label' do
+ context "when label_id is a label ID" do
+ it "subscribes to the label" do
post api("/groups/#{group.id}/labels/#{label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(label1.title)
- expect(json_response['subscribed']).to be_truthy
+ expect(json_response["name"]).to eq(label1.title)
+ expect(json_response["subscribed"]).to be_truthy
end
end
- context 'when user is already subscribed to label' do
+ context "when user is already subscribed to label" do
before do
label1.subscribe(user)
end
- it 'returns 304' do
+ it "returns 304" do
post api("/groups/#{group.id}/labels/#{label1.id}/subscribe", user)
expect(response).to have_gitlab_http_status(304)
end
end
- context 'when label ID is not found' do
- it 'returns 404 error' do
+ context "when label ID is not found" do
+ it "returns 404 error" do
post api("/groups/#{group.id}/labels/1234/subscribe", user)
expect(response).to have_gitlab_http_status(404)
@@ -210,45 +210,45 @@ describe API::GroupLabels do
end
end
- describe 'POST /groups/:id/labels/:label_id/unsubscribe' do
+ describe "POST /groups/:id/labels/:label_id/unsubscribe" do
before do
label1.subscribe(user)
end
- context 'when label_id is a label title' do
- it 'unsubscribes from the label' do
+ context "when label_id is a label title" do
+ it "unsubscribes from the label" do
post api("/groups/#{group.id}/labels/#{label1.title}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(label1.title)
- expect(json_response['subscribed']).to be_falsey
+ expect(json_response["name"]).to eq(label1.title)
+ expect(json_response["subscribed"]).to be_falsey
end
end
- context 'when label_id is a label ID' do
- it 'unsubscribes from the label' do
+ context "when label_id is a label ID" do
+ it "unsubscribes from the label" do
post api("/groups/#{group.id}/labels/#{label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(label1.title)
- expect(json_response['subscribed']).to be_falsey
+ expect(json_response["name"]).to eq(label1.title)
+ expect(json_response["subscribed"]).to be_falsey
end
end
- context 'when user is already unsubscribed from label' do
+ context "when user is already unsubscribed from label" do
before do
label1.unsubscribe(user)
end
- it 'returns 304' do
+ it "returns 304" do
post api("/groups/#{group.id}/labels/#{label1.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(304)
end
end
- context 'when label ID is not found' do
- it 'returns 404 error' do
+ context "when label ID is not found" do
+ it "returns 404 error" do
post api("/groups/#{group.id}/labels/1234/unsubscribe", user)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/group_milestones_spec.rb b/spec/requests/api/group_milestones_spec.rb
index 6980eb7f55d..329679bf51b 100644
--- a/spec/requests/api/group_milestones_spec.rb
+++ b/spec/requests/api/group_milestones_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe API::GroupMilestones do
let(:user) { create(:user) }
let(:group) { create(:group, :private) }
let(:project) { create(:project, namespace: group) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- let!(:closed_milestone) { create(:closed_milestone, group: group, title: 'version1', description: 'closed milestone') }
- let!(:milestone) { create(:milestone, group: group, title: 'version2', description: 'open milestone') }
+ let!(:closed_milestone) { create(:closed_milestone, group: group, title: "version1", description: "closed milestone") }
+ let!(:milestone) { create(:milestone, group: group, title: "version2", description: "open milestone") }
- it_behaves_like 'group and project milestones', "/groups/:id/milestones" do
+ it_behaves_like "group and project milestones", "/groups/:id/milestones" do
let(:route) { "/groups/#{group.id}/milestones" }
end
diff --git a/spec/requests/api/group_variables_spec.rb b/spec/requests/api/group_variables_spec.rb
index 66b9aae4b58..19c9cb5bb59 100644
--- a/spec/requests/api/group_variables_spec.rb
+++ b/spec/requests/api/group_variables_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe API::GroupVariables do
let(:group) { create(:group) }
let(:user) { create(:user) }
- describe 'GET /groups/:id/variables' do
+ describe "GET /groups/:id/variables" do
let!(:variable) { create(:ci_group_variable, group: group) }
- context 'authorized user with proper permissions' do
+ context "authorized user with proper permissions" do
before do
group.add_maintainer(user)
end
- it 'returns group variables' do
+ it "returns group variables" do
get api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(200)
@@ -20,16 +20,16 @@ describe API::GroupVariables do
end
end
- context 'authorized user with invalid permissions' do
- it 'does not return group variables' do
+ context "authorized user with invalid permissions" do
+ it "does not return group variables" do
get api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not return group variables' do
+ context "unauthorized user" do
+ it "does not return group variables" do
get api("/groups/#{group.id}/variables")
expect(response).to have_gitlab_http_status(401)
@@ -37,39 +37,39 @@ describe API::GroupVariables do
end
end
- describe 'GET /groups/:id/variables/:key' do
+ describe "GET /groups/:id/variables/:key" do
let!(:variable) { create(:ci_group_variable, group: group) }
- context 'authorized user with proper permissions' do
+ context "authorized user with proper permissions" do
before do
group.add_maintainer(user)
end
- it 'returns group variable details' do
+ it "returns group variable details" do
get api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['value']).to eq(variable.value)
- expect(json_response['protected']).to eq(variable.protected?)
+ expect(json_response["value"]).to eq(variable.value)
+ expect(json_response["protected"]).to eq(variable.protected?)
end
- it 'responds with 404 Not Found if requesting non-existing variable' do
+ it "responds with 404 Not Found if requesting non-existing variable" do
get api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not return group variable details' do
+ context "authorized user with invalid permissions" do
+ it "does not return group variable details" do
get api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not return group variable details' do
+ context "unauthorized user" do
+ it "does not return group variable details" do
get api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
@@ -77,55 +77,55 @@ describe API::GroupVariables do
end
end
- describe 'POST /groups/:id/variables' do
- context 'authorized user with proper permissions' do
+ describe "POST /groups/:id/variables" do
+ context "authorized user with proper permissions" do
let!(:variable) { create(:ci_group_variable, group: group) }
before do
group.add_maintainer(user)
end
- it 'creates variable' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true }
- end.to change {group.variables.count}.by(1)
+ it "creates variable" do
+ expect {
+ post api("/groups/#{group.id}/variables", user), params: {key: "TEST_VARIABLE_2", value: "PROTECTED_VALUE_2", protected: true}
+ }.to change {group.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('PROTECTED_VALUE_2')
- expect(json_response['protected']).to be_truthy
+ expect(json_response["key"]).to eq("TEST_VARIABLE_2")
+ expect(json_response["value"]).to eq("PROTECTED_VALUE_2")
+ expect(json_response["protected"]).to be_truthy
end
- it 'creates variable with optional attributes' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
- end.to change {group.variables.count}.by(1)
+ it "creates variable with optional attributes" do
+ expect {
+ post api("/groups/#{group.id}/variables", user), params: {key: "TEST_VARIABLE_2", value: "VALUE_2"}
+ }.to change {group.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['protected']).to be_falsey
+ expect(json_response["key"]).to eq("TEST_VARIABLE_2")
+ expect(json_response["value"]).to eq("VALUE_2")
+ expect(json_response["protected"]).to be_falsey
end
- it 'does not allow to duplicate variable key' do
- expect do
- post api("/groups/#{group.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
- end.to change {group.variables.count}.by(0)
+ it "does not allow to duplicate variable key" do
+ expect {
+ post api("/groups/#{group.id}/variables", user), params: {key: variable.key, value: "VALUE_2"}
+ }.to change {group.variables.count}.by(0)
expect(response).to have_gitlab_http_status(400)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not create variable' do
+ context "authorized user with invalid permissions" do
+ it "does not create variable" do
post api("/groups/#{group.id}/variables", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not create variable' do
+ context "unauthorized user" do
+ it "does not create variable" do
post api("/groups/#{group.id}/variables")
expect(response).to have_gitlab_http_status(401)
@@ -133,45 +133,45 @@ describe API::GroupVariables do
end
end
- describe 'PUT /groups/:id/variables/:key' do
+ describe "PUT /groups/:id/variables/:key" do
let!(:variable) { create(:ci_group_variable, group: group) }
- context 'authorized user with proper permissions' do
+ context "authorized user with proper permissions" do
before do
group.add_maintainer(user)
end
- it 'updates variable data' do
+ it "updates variable data" do
initial_variable = group.variables.reload.first
value_before = initial_variable.value
- put api("/groups/#{group.id}/variables/#{variable.key}", user), params: { value: 'VALUE_1_UP', protected: true }
+ put api("/groups/#{group.id}/variables/#{variable.key}", user), params: {value: "VALUE_1_UP", protected: true}
updated_variable = group.variables.reload.first
expect(response).to have_gitlab_http_status(200)
expect(value_before).to eq(variable.value)
- expect(updated_variable.value).to eq('VALUE_1_UP')
+ expect(updated_variable.value).to eq("VALUE_1_UP")
expect(updated_variable).to be_protected
end
- it 'responds with 404 Not Found if requesting non-existing variable' do
+ it "responds with 404 Not Found if requesting non-existing variable" do
put api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not update variable' do
+ context "authorized user with invalid permissions" do
+ it "does not update variable" do
put api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not update variable' do
+ context "unauthorized user" do
+ it "does not update variable" do
put api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
@@ -179,43 +179,43 @@ describe API::GroupVariables do
end
end
- describe 'DELETE /groups/:id/variables/:key' do
+ describe "DELETE /groups/:id/variables/:key" do
let!(:variable) { create(:ci_group_variable, group: group) }
- context 'authorized user with proper permissions' do
+ context "authorized user with proper permissions" do
before do
group.add_maintainer(user)
end
- it 'deletes variable' do
- expect do
+ it "deletes variable" do
+ expect {
delete api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change {group.variables.count}.by(-1)
+ }.to change {group.variables.count}.by(-1)
end
- it 'responds with 404 Not Found if requesting non-existing variable' do
+ it "responds with 404 Not Found if requesting non-existing variable" do
delete api("/groups/#{group.id}/variables/non_existing_variable", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/groups/#{group.id}/variables/#{variable.key}", user) }
end
end
- context 'authorized user with invalid permissions' do
- it 'does not delete variable' do
+ context "authorized user with invalid permissions" do
+ it "does not delete variable" do
delete api("/groups/#{group.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not delete variable' do
+ context "unauthorized user" do
+ it "does not delete variable" do
delete api("/groups/#{group.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index 7176bc23e34..aa2aa59688b 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Groups do
include UploadHelpers
@@ -11,7 +11,7 @@ describe API::Groups do
let!(:group2) { create(:group, :private) }
let!(:project1) { create(:project, namespace: group1) }
let!(:project2) { create(:project, namespace: group2) }
- let!(:project3) { create(:project, namespace: group1, path: 'test', visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
+ let!(:project3) { create(:project, namespace: group1, path: "test", visibility_level: Gitlab::VisibilityLevel::PRIVATE) }
before do
group1.add_owner(user1)
@@ -28,22 +28,22 @@ describe API::Groups do
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
expect(json_response)
- .to satisfy_one { |group| group['name'] == group1.name }
+ .to satisfy_one { |group| group["name"] == group1.name }
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
# Establish baseline
get api("/groups", admin)
- control = ActiveRecord::QueryRecorder.new do
+ control = ActiveRecord::QueryRecorder.new {
get api("/groups", admin)
- end
+ }
create(:group)
- expect do
+ expect {
get api("/groups", admin)
- end.not_to exceed_query_limit(control)
+ }.not_to exceed_query_limit(control)
end
end
@@ -56,16 +56,16 @@ describe API::Groups do
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
expect(json_response)
- .to satisfy_one { |group| group['name'] == group1.name }
+ .to satisfy_one { |group| group["name"] == group1.name }
end
it "does not include statistics" do
- get api("/groups", user1), params: { statistics: true }
+ get api("/groups", user1), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).not_to include 'statistics'
+ expect(json_response.first).not_to include "statistics"
end
end
@@ -85,7 +85,7 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).not_to include('statistics')
+ expect(json_response.first).not_to include("statistics")
end
it "includes statistics if requested" do
@@ -93,26 +93,26 @@ describe API::Groups do
storage_size: 702,
repository_size: 123,
lfs_objects_size: 234,
- build_artifacts_size: 345
+ build_artifacts_size: 345,
}.stringify_keys
exposed_attributes = attributes.dup
- exposed_attributes['job_artifacts_size'] = exposed_attributes.delete('build_artifacts_size')
+ exposed_attributes["job_artifacts_size"] = exposed_attributes.delete("build_artifacts_size")
project1.statistics.update!(attributes)
- get api("/groups", admin), params: { statistics: true }
+ get api("/groups", admin), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response)
- .to satisfy_one { |group| group['statistics'] == exposed_attributes }
+ .to satisfy_one { |group| group["statistics"] == exposed_attributes }
end
end
context "when using skip_groups in request" do
it "returns all groups excluding skipped groups" do
- get api("/groups", admin), params: { skip_groups: [group2.id] }
+ get api("/groups", admin), params: {skip_groups: [group2.id]}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -122,12 +122,12 @@ describe API::Groups do
end
context "when using all_available in request" do
- let(:response_groups) { json_response.map { |group| group['name'] } }
+ let(:response_groups) { json_response.map { |group| group["name"] } }
it "returns all groups you have access to" do
public_group = create :group, :public
- get api("/groups", user1), params: { all_available: true }
+ get api("/groups", user1), params: {all_available: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -140,8 +140,8 @@ describe API::Groups do
let(:group3) { create(:group, name: "a#{group1.name}", path: "z#{group1.path}") }
let(:group4) { create(:group, name: "same-name", path: "y#{group1.path}") }
let(:group5) { create(:group, name: "same-name") }
- let(:response_groups) { json_response.map { |group| group['name'] } }
- let(:response_groups_ids) { json_response.map { |group| group['id'] } }
+ let(:response_groups) { json_response.map { |group| group["name"] } }
+ let(:response_groups_ids) { json_response.map { |group| group["id"] } }
before do
group3.add_owner(user1)
@@ -159,7 +159,7 @@ describe API::Groups do
end
it "sorts in descending order when passed" do
- get api("/groups", user1), params: { sort: "desc" }
+ get api("/groups", user1), params: {sort: "desc"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -168,7 +168,7 @@ describe API::Groups do
end
it "sorts by path in order_by param" do
- get api("/groups", user1), params: { order_by: "path" }
+ get api("/groups", user1), params: {order_by: "path"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -177,7 +177,7 @@ describe API::Groups do
end
it "sorts by id in the order_by param" do
- get api("/groups", user1), params: { order_by: "id" }
+ get api("/groups", user1), params: {order_by: "id"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -186,7 +186,7 @@ describe API::Groups do
end
it "sorts also by descending id with pagination fix" do
- get api("/groups", user1), params: { order_by: "id", sort: "desc" }
+ get api("/groups", user1), params: {order_by: "id", sort: "desc"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -195,21 +195,21 @@ describe API::Groups do
end
it "sorts identical keys by id for good pagination" do
- get api("/groups", user1), params: { search: "same-name", order_by: "name" }
+ get api("/groups", user1), params: {search: "same-name", order_by: "name"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort)
+ expect(response_groups_ids).to eq(Group.select { |group| group["name"] == "same-name" }.map { |group| group["id"] }.sort)
end
it "sorts descending identical keys by id for good pagination" do
- get api("/groups", user1), params: { search: "same-name", order_by: "name", sort: "desc" }
+ get api("/groups", user1), params: {search: "same-name", order_by: "name", sort: "desc"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(response_groups_ids).to eq(Group.select { |group| group['name'] == 'same-name' }.map { |group| group['id'] }.sort)
+ expect(response_groups_ids).to eq(Group.select { |group| group["name"] == "same-name" }.map { |group| group["id"] }.sort)
end
def groups_visible_to_user(user)
@@ -217,31 +217,31 @@ describe API::Groups do
end
end
- context 'when using owned in the request' do
- it 'returns an array of groups the user owns' do
+ context "when using owned in the request" do
+ it "returns an array of groups the user owns" do
group1.add_maintainer(user2)
- get api('/groups', user2), params: { owned: true }
+ get api("/groups", user2), params: {owned: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(group2.name)
+ expect(json_response.first["name"]).to eq(group2.name)
end
end
- context 'when using min_access_level in the request' do
+ context "when using min_access_level in the request" do
let!(:group3) { create(:group, :private) }
- let(:response_groups) { json_response.map { |group| group['id'] } }
+ let(:response_groups) { json_response.map { |group| group["id"] } }
before do
group1.add_developer(user2)
group3.add_master(user2)
end
- it 'returns an array of groups the user has at least master access' do
- get api('/groups', user2), params: { min_access_level: 40 }
+ it "returns an array of groups the user has at least master access" do
+ get api("/groups", user2), params: {min_access_level: 40}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -260,9 +260,9 @@ describe API::Groups do
# Returns a Hash of visibility_level => Project pairs
def add_projects_to_group(group, share_with: nil)
projects = {
- public: create(:project, :public, namespace: group),
+ public: create(:project, :public, namespace: group),
internal: create(:project, :internal, namespace: group),
- private: create(:project, :private, namespace: group)
+ private: create(:project, :private, namespace: group),
}
if share_with
@@ -276,79 +276,79 @@ describe API::Groups do
def response_project_ids(json_response, key)
json_response[key].map do |project|
- project['id'].to_i
+ project["id"].to_i
end
end
- context 'when unauthenticated' do
- it 'returns 404 for a private group' do
+ context "when unauthenticated" do
+ it "returns 404 for a private group" do
get api("/groups/#{group2.id}")
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 200 for a public group' do
+ it "returns 200 for a public group" do
get api("/groups/#{group1.id}")
expect(response).to have_gitlab_http_status(200)
end
- it 'returns only public projects in the group' do
+ it "returns only public projects in the group" do
public_group = create(:group, :public)
projects = add_projects_to_group(public_group)
get api("/groups/#{public_group.id}")
- expect(response_project_ids(json_response, 'projects'))
+ expect(response_project_ids(json_response, "projects"))
.to contain_exactly(projects[:public].id)
end
- it 'returns only public projects shared with the group' do
+ it "returns only public projects shared with the group" do
public_group = create(:group, :public)
projects = add_projects_to_group(public_group, share_with: group1)
get api("/groups/#{group1.id}")
- expect(response_project_ids(json_response, 'shared_projects'))
+ expect(response_project_ids(json_response, "shared_projects"))
.to contain_exactly(projects[:public].id)
end
end
context "when authenticated as user" do
it "returns one of user1's groups" do
- project = create(:project, namespace: group2, path: 'Foo')
+ project = create(:project, namespace: group2, path: "Foo")
create(:project_group_link, project: project, group: group1)
get api("/groups/#{group1.id}", user1)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(group1.id)
- expect(json_response['name']).to eq(group1.name)
- expect(json_response['path']).to eq(group1.path)
- expect(json_response['description']).to eq(group1.description)
- expect(json_response['visibility']).to eq(Gitlab::VisibilityLevel.string_level(group1.visibility_level))
- expect(json_response['avatar_url']).to eq(group1.avatar_url(only_path: false))
- expect(json_response['web_url']).to eq(group1.web_url)
- expect(json_response['request_access_enabled']).to eq(group1.request_access_enabled)
- expect(json_response['full_name']).to eq(group1.full_name)
- expect(json_response['full_path']).to eq(group1.full_path)
- expect(json_response['parent_id']).to eq(group1.parent_id)
- expect(json_response['projects']).to be_an Array
- expect(json_response['projects'].length).to eq(2)
- expect(json_response['shared_projects']).to be_an Array
- expect(json_response['shared_projects'].length).to eq(1)
- expect(json_response['shared_projects'][0]['id']).to eq(project.id)
+ expect(json_response["id"]).to eq(group1.id)
+ expect(json_response["name"]).to eq(group1.name)
+ expect(json_response["path"]).to eq(group1.path)
+ expect(json_response["description"]).to eq(group1.description)
+ expect(json_response["visibility"]).to eq(Gitlab::VisibilityLevel.string_level(group1.visibility_level))
+ expect(json_response["avatar_url"]).to eq(group1.avatar_url(only_path: false))
+ expect(json_response["web_url"]).to eq(group1.web_url)
+ expect(json_response["request_access_enabled"]).to eq(group1.request_access_enabled)
+ expect(json_response["full_name"]).to eq(group1.full_name)
+ expect(json_response["full_path"]).to eq(group1.full_path)
+ expect(json_response["parent_id"]).to eq(group1.parent_id)
+ expect(json_response["projects"]).to be_an Array
+ expect(json_response["projects"].length).to eq(2)
+ expect(json_response["shared_projects"]).to be_an Array
+ expect(json_response["shared_projects"].length).to eq(1)
+ expect(json_response["shared_projects"][0]["id"]).to eq(project.id)
end
it "returns one of user1's groups without projects when with_projects option is set to false" do
- project = create(:project, namespace: group2, path: 'Foo')
+ project = create(:project, namespace: group2, path: "Foo")
create(:project_group_link, project: project, group: group1)
- get api("/groups/#{group1.id}", user1), params: { with_projects: false }
+ get api("/groups/#{group1.id}", user1), params: {with_projects: false}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['projects']).to be_nil
- expect(json_response['shared_projects']).to be_nil
+ expect(json_response["projects"]).to be_nil
+ expect(json_response["shared_projects"]).to be_nil
end
it "does not return a non existing group" do
@@ -363,38 +363,38 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(404)
end
- it 'returns only public and internal projects in the group' do
+ it "returns only public and internal projects in the group" do
public_group = create(:group, :public)
projects = add_projects_to_group(public_group)
get api("/groups/#{public_group.id}", user2)
- expect(response_project_ids(json_response, 'projects'))
+ expect(response_project_ids(json_response, "projects"))
.to contain_exactly(projects[:public].id, projects[:internal].id)
end
- it 'returns only public and internal projects shared with the group' do
+ it "returns only public and internal projects shared with the group" do
public_group = create(:group, :public)
projects = add_projects_to_group(public_group, share_with: group1)
get api("/groups/#{group1.id}", user2)
- expect(response_project_ids(json_response, 'shared_projects'))
+ expect(response_project_ids(json_response, "shared_projects"))
.to contain_exactly(projects[:public].id, projects[:internal].id)
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
get api("/groups/#{group1.id}", admin)
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
get api("/groups/#{group1.id}", admin)
- end.count
+ }.count
create(:project, namespace: group1)
- expect do
+ expect {
get api("/groups/#{group1.id}", admin)
- end.not_to exceed_query_limit(control_count)
+ }.not_to exceed_query_limit(control_count)
end
end
@@ -403,7 +403,7 @@ describe API::Groups do
get api("/groups/#{group2.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(group2.name)
+ expect(json_response["name"]).to eq(group2.name)
end
it "does not return a non existing group" do
@@ -413,21 +413,21 @@ describe API::Groups do
end
end
- context 'when using group path in URL' do
- it 'returns any existing group' do
+ context "when using group path in URL" do
+ it "returns any existing group" do
get api("/groups/#{group1.path}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(group1.name)
+ expect(json_response["name"]).to eq(group1.name)
end
- it 'does not return a non existing group' do
- get api('/groups/unknown', admin)
+ it "does not return a non existing group" do
+ get api("/groups/unknown", admin)
expect(response).to have_gitlab_http_status(404)
end
- it 'does 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_gitlab_http_status(404)
@@ -435,45 +435,45 @@ describe API::Groups do
end
end
- describe 'PUT /groups/:id' do
- let(:new_group_name) { 'New Group'}
+ describe "PUT /groups/:id" do
+ let(:new_group_name) { "New Group"}
- context 'when authenticated as the group owner' do
- it 'updates the group' do
- put api("/groups/#{group1.id}", user1), params: { name: new_group_name, request_access_enabled: true }
+ context "when authenticated as the group owner" do
+ it "updates the group" do
+ put api("/groups/#{group1.id}", user1), params: {name: new_group_name, request_access_enabled: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(new_group_name)
- expect(json_response['request_access_enabled']).to eq(true)
+ expect(json_response["name"]).to eq(new_group_name)
+ expect(json_response["request_access_enabled"]).to eq(true)
end
- it 'returns 404 for a non existing group' do
- put api('/groups/1328', user1), params: { name: new_group_name }
+ it "returns 404 for a non existing group" do
+ put api("/groups/1328", user1), params: {name: new_group_name}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when authenticated as the admin' do
- it 'updates the group' do
- put api("/groups/#{group1.id}", admin), params: { name: new_group_name }
+ context "when authenticated as the admin" do
+ it "updates the group" do
+ put api("/groups/#{group1.id}", admin), params: {name: new_group_name}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(new_group_name)
+ expect(json_response["name"]).to eq(new_group_name)
end
end
- context 'when authenticated as an user that can see the group' do
- it 'does not updates the group' do
- put api("/groups/#{group1.id}", user2), params: { name: new_group_name }
+ context "when authenticated as an user that can see the group" do
+ it "does not updates the group" do
+ put api("/groups/#{group1.id}", user2), params: {name: new_group_name}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when authenticated as an user that cannot see the group' do
- it 'returns 404 when trying to update the group' do
- put api("/groups/#{group2.id}", user1), params: { name: new_group_name }
+ context "when authenticated as an user that cannot see the group" do
+ it "returns 404 when trying to update the group" do
+ put api("/groups/#{group2.id}", user1), params: {name: new_group_name}
expect(response).to have_gitlab_http_status(404)
end
@@ -488,32 +488,32 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(2)
- project_names = json_response.map { |proj| proj['name'] }
+ project_names = json_response.map { |proj| proj["name"] }
expect(project_names).to match_array([project1.name, project3.name])
- expect(json_response.first['visibility']).to be_present
+ expect(json_response.first["visibility"]).to be_present
end
it "returns the group's projects with simple representation" do
- get api("/groups/#{group1.id}/projects", user1), params: { simple: true }
+ get api("/groups/#{group1.id}/projects", user1), params: {simple: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(2)
- project_names = json_response.map { |proj| proj['name'] }
+ project_names = json_response.map { |proj| proj["name"] }
expect(project_names).to match_array([project1.name, project3.name])
- expect(json_response.first['visibility']).not_to be_present
+ expect(json_response.first["visibility"]).not_to be_present
end
it "filters the groups projects" do
- public_project = create(:project, :public, path: 'test1', group: group1)
+ public_project = create(:project, :public, path: "test1", group: group1)
- get api("/groups/#{group1.id}/projects", user1), params: { visibility: 'public' }
+ get api("/groups/#{group1.id}/projects", user1), params: {visibility: "public"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an(Array)
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(public_project.name)
+ expect(json_response.first["name"]).to eq(public_project.name)
end
it "returns projects excluding shared" do
@@ -521,7 +521,7 @@ describe API::Groups do
create(:project_group_link, project: create(:project), group: group1)
create(:project_group_link, project: create(:project), group: group1)
- get api("/groups/#{group1.id}/projects", user1), params: { with_shared: false }
+ get api("/groups/#{group1.id}/projects", user1), params: {with_shared: false}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -534,7 +534,7 @@ describe API::Groups do
create(:project, group: subgroup)
create(:project, group: subgroup)
- get api("/groups/#{group1.id}/projects", user1), params: { include_subgroups: true }
+ get api("/groups/#{group1.id}/projects", user1), params: {include_subgroups: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -562,27 +562,27 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(project3.name)
+ expect(json_response.first["name"]).to eq(project3.name)
end
- it 'only returns the projects owned by user' do
+ it "only returns the projects owned by user" do
project2.group.add_owner(user3)
- get api("/groups/#{project2.group.id}/projects", user3), params: { owned: true }
+ get api("/groups/#{project2.group.id}/projects", user3), params: {owned: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(project2.name)
+ expect(json_response.first["name"]).to eq(project2.name)
end
- it 'only returns the projects starred by user' do
+ it "only returns the projects starred by user" do
user1.starred_projects = [project1]
- get api("/groups/#{group1.id}/projects", user1), params: { starred: true }
+ get api("/groups/#{group1.id}/projects", user1), params: {starred: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(project1.name)
+ expect(json_response.first["name"]).to eq(project1.name)
end
end
@@ -593,7 +593,7 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(1)
- expect(json_response.first['name']).to eq(project2.name)
+ expect(json_response.first["name"]).to eq(project2.name)
end
it "does not return a non existing group" do
@@ -602,38 +602,38 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(404)
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
get api("/groups/#{group1.id}/projects", admin)
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
get api("/groups/#{group1.id}/projects", admin)
- end.count
+ }.count
create(:project, namespace: group1)
- expect do
+ expect {
get api("/groups/#{group1.id}/projects", admin)
- end.not_to exceed_query_limit(control_count)
+ }.not_to exceed_query_limit(control_count)
end
end
- context 'when using group path in URL' do
- it 'returns any existing group' do
+ context "when using group path in URL" do
+ it "returns any existing group" do
get api("/groups/#{group1.path}/projects", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- project_names = json_response.map { |proj| proj['name'] }
+ project_names = json_response.map { |proj| proj["name"] }
expect(project_names).to match_array([project1.name, project3.name])
end
- it 'does not return a non existing group' do
- get api('/groups/unknown/projects', admin)
+ it "does not return a non existing group" do
+ get api("/groups/unknown/projects", admin)
expect(response).to have_gitlab_http_status(404)
end
- it 'does 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_gitlab_http_status(404)
@@ -641,33 +641,33 @@ describe API::Groups do
end
end
- describe 'GET /groups/:id/subgroups', :nested_groups do
+ describe "GET /groups/:id/subgroups", :nested_groups do
let!(:subgroup1) { create(:group, parent: group1) }
let!(:subgroup2) { create(:group, :private, parent: group1) }
let!(:subgroup3) { create(:group, :private, parent: group2) }
- context 'when unauthenticated' do
- it 'returns only public subgroups' do
+ context "when unauthenticated" do
+ it "returns only public subgroups" do
get api("/groups/#{group1.id}/subgroups")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(subgroup1.id)
- expect(json_response.first['parent_id']).to eq(group1.id)
+ expect(json_response.first["id"]).to eq(subgroup1.id)
+ expect(json_response.first["parent_id"]).to eq(group1.id)
end
- it 'returns 404 for a private group' do
+ it "returns 404 for a private group" do
get api("/groups/#{group2.id}/subgroups")
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when authenticated as user' do
- context 'when user is not member of a public group' do
- it 'returns no subgroups for the public group' do
+ context "when authenticated as user" do
+ context "when user is not member of a public group" do
+ it "returns no subgroups for the public group" do
get api("/groups/#{group1.id}/subgroups", user2)
expect(response).to have_gitlab_http_status(200)
@@ -675,75 +675,75 @@ describe API::Groups do
expect(json_response.length).to eq(0)
end
- context 'when using all_available in request' do
- it 'returns public subgroups' do
- get api("/groups/#{group1.id}/subgroups", user2), params: { all_available: true }
+ context "when using all_available in request" do
+ it "returns public subgroups" do
+ get api("/groups/#{group1.id}/subgroups", user2), params: {all_available: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response[0]['id']).to eq(subgroup1.id)
- expect(json_response[0]['parent_id']).to eq(group1.id)
+ expect(json_response[0]["id"]).to eq(subgroup1.id)
+ expect(json_response[0]["parent_id"]).to eq(group1.id)
end
end
end
- context 'when user is not member of a private group' do
- it 'returns 404 for the private group' do
+ context "when user is not member of a private group" do
+ it "returns 404 for the private group" do
get api("/groups/#{group2.id}/subgroups", user1)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user is member of public group' do
+ context "when user is member of public group" do
before do
group1.add_guest(user2)
end
- it 'returns private subgroups' do
+ it "returns private subgroups" do
get api("/groups/#{group1.id}/subgroups", user2)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- private_subgroups = json_response.select { |group| group['visibility'] == 'private' }
+ private_subgroups = json_response.select { |group| group["visibility"] == "private" }
expect(private_subgroups.length).to eq(1)
- expect(private_subgroups.first['id']).to eq(subgroup2.id)
- expect(private_subgroups.first['parent_id']).to eq(group1.id)
+ expect(private_subgroups.first["id"]).to eq(subgroup2.id)
+ expect(private_subgroups.first["parent_id"]).to eq(group1.id)
end
- context 'when using statistics in request' do
- it 'does not include statistics' do
- get api("/groups/#{group1.id}/subgroups", user2), params: { statistics: true }
+ context "when using statistics in request" do
+ it "does not include statistics" do
+ get api("/groups/#{group1.id}/subgroups", user2), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first).not_to include 'statistics'
+ expect(json_response.first).not_to include "statistics"
end
end
end
- context 'when user is member of private group' do
+ context "when user is member of private group" do
before do
group2.add_guest(user1)
end
- it 'returns subgroups' do
+ it "returns subgroups" do
get api("/groups/#{group2.id}/subgroups", user1)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(subgroup3.id)
- expect(json_response.first['parent_id']).to eq(group2.id)
+ expect(json_response.first["id"]).to eq(subgroup3.id)
+ expect(json_response.first["parent_id"]).to eq(group2.id)
end
end
end
- context 'when authenticated as admin' do
- it 'returns private subgroups of a public group' do
+ context "when authenticated as admin" do
+ it "returns private subgroups of a public group" do
get api("/groups/#{group1.id}/subgroups", admin)
expect(response).to have_gitlab_http_status(200)
@@ -751,7 +751,7 @@ describe API::Groups do
expect(json_response.length).to eq(2)
end
- it 'returns subgroups of a private group' do
+ it "returns subgroups of a private group" do
get api("/groups/#{group2.id}/subgroups", admin)
expect(response).to have_gitlab_http_status(200)
@@ -759,20 +759,20 @@ describe API::Groups do
expect(json_response.length).to eq(1)
end
- it 'does not include statistics by default' do
+ it "does not include statistics by default" do
get api("/groups/#{group1.id}/subgroups", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first).not_to include('statistics')
+ expect(json_response.first).not_to include("statistics")
end
- it 'includes statistics if requested' do
- get api("/groups/#{group1.id}/subgroups", admin), params: { statistics: true }
+ it "includes statistics if requested" do
+ get api("/groups/#{group1.id}/subgroups", admin), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.first).to include('statistics')
+ expect(json_response.first).to include("statistics")
end
end
end
@@ -785,25 +785,25 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(403)
end
- context 'as owner', :nested_groups do
+ context "as owner", :nested_groups do
before do
group2.add_owner(user1)
end
- it 'can create subgroups' do
- post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' }
+ it "can create subgroups" do
+ post api("/groups", user1), params: {parent_id: group2.id, name: "foo", path: "foo"}
expect(response).to have_gitlab_http_status(201)
end
end
- context 'as maintainer', :nested_groups do
+ context "as maintainer", :nested_groups do
before do
group2.add_maintainer(user1)
end
- it 'cannot create subgroups' do
- post api("/groups", user1), params: { parent_id: group2.id, name: 'foo', path: 'foo' }
+ it "cannot create subgroups" do
+ post api("/groups", user1), params: {parent_id: group2.id, name: "foo", path: "foo"}
expect(response).to have_gitlab_http_status(403)
end
@@ -812,7 +812,7 @@ describe API::Groups do
context "when authenticated as user with group permissions" do
it "creates group" do
- group = attributes_for(:group, { request_access_enabled: false })
+ group = attributes_for(:group, {request_access_enabled: false})
post api("/groups", user3), params: group
@@ -827,7 +827,7 @@ describe API::Groups do
it "creates a nested group", :nested_groups do
parent = create(:group)
parent.add_owner(user3)
- group = attributes_for(:group, { parent_id: parent.id })
+ group = attributes_for(:group, {parent_id: parent.id})
post api("/groups", user3), params: group
@@ -838,20 +838,20 @@ describe API::Groups do
end
it "does not create group, duplicate" do
- post api("/groups", user3), params: { name: 'Duplicate Test', path: group2.path }
+ post api("/groups", user3), params: {name: "Duplicate Test", path: group2.path}
expect(response).to have_gitlab_http_status(400)
expect(response.message).to eq("Bad Request")
end
it "returns 400 bad request error if name not given" do
- post api("/groups", user3), params: { path: group2.path }
+ post api("/groups", user3), params: {path: group2.path}
expect(response).to have_gitlab_http_status(400)
end
it "returns 400 bad request error if path not given" do
- post api("/groups", user3), params: { name: 'test' }
+ post api("/groups", user3), params: {name: "test"}
expect(response).to have_gitlab_http_status(400)
end
@@ -868,7 +868,7 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(202)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/groups/#{group1.id}", user1) }
let(:success_status) { 202 }
end
@@ -934,8 +934,8 @@ describe API::Groups do
expect(response).to have_gitlab_http_status(201)
end
- context 'when using project path in URL' do
- context 'with a valid project path' do
+ context "when using project path in URL" do
+ context "with a valid project path" do
it "transfers project to group" do
post api("/groups/#{group1.id}/projects/#{project_path}", admin)
@@ -943,7 +943,7 @@ describe API::Groups do
end
end
- context 'with a non-existent project path' do
+ context "with a non-existent project path" do
it "does not transfer project to group" do
post api("/groups/#{group1.id}/projects/nogroup%2Fnoproject", admin)
@@ -952,8 +952,8 @@ describe API::Groups do
end
end
- context 'when using a group path in URL' do
- context 'with a valid group path' do
+ context "when using a group path in URL" do
+ context "with a valid group path" do
it "transfers project to group" do
post api("/groups/#{group1.path}/projects/#{project_path}", admin)
@@ -961,7 +961,7 @@ describe API::Groups do
end
end
- context 'with a non-existent group path' do
+ context "with a non-existent group path" do
it "does not transfer project to group" do
post api("/groups/noexist/projects/#{project_path}", admin)
@@ -972,7 +972,7 @@ describe API::Groups do
end
end
- it_behaves_like 'custom attributes endpoints', 'groups' do
+ it_behaves_like "custom attributes endpoints", "groups" do
let(:attributable) { group1 }
let(:other_attributable) { group2 }
let(:user) { user1 }
diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb
index a0c64d295c0..0b2d29f98e6 100644
--- a/spec/requests/api/helpers_spec.rb
+++ b/spec/requests/api/helpers_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
-require 'raven/transports/dummy'
-require_relative '../../../config/initializers/sentry'
+require "spec_helper"
+require "raven/transports/dummy"
+require_relative "../../../config/initializers/sentry"
describe API::Helpers do
include API::APIGuard::HelperMethods
@@ -14,12 +14,12 @@ describe API::Helpers do
let(:csrf_token) { SecureRandom.base64(ActionController::RequestForgeryProtection::AUTHENTICITY_TOKEN_LENGTH) }
let(:env) do
{
- 'rack.input' => '',
- 'rack.session' => {
- _csrf_token: csrf_token
+ "rack.input" => "",
+ "rack.session" => {
+ _csrf_token: csrf_token,
},
- 'REQUEST_METHOD' => 'GET',
- 'CONTENT_TYPE' => 'text/plain;charset=utf-8'
+ "REQUEST_METHOD" => "GET",
+ "CONTENT_TYPE" => "text/plain;charset=utf-8",
}
end
let(:header) { }
@@ -32,7 +32,7 @@ describe API::Helpers do
def warden_authenticate_returns(value)
warden = double("warden", authenticate: value)
- env['warden'] = warden
+ env["warden"] = warden
end
def error!(message, status, header)
@@ -50,7 +50,7 @@ describe API::Helpers do
context "with invalid credentials" do
context "GET request" do
before do
- env['REQUEST_METHOD'] = 'GET'
+ env["REQUEST_METHOD"] = "GET"
end
it { is_expected.to be_nil }
@@ -64,21 +64,21 @@ describe API::Helpers do
context "GET request" do
before do
- env['REQUEST_METHOD'] = 'GET'
+ env["REQUEST_METHOD"] = "GET"
end
it { is_expected.to eq(user) }
- it 'sets the environment with data of the current user' do
+ it "sets the environment with data of the current user" do
subject
- expect(env[API::Helpers::API_USER_ENV]).to eq({ user_id: subject.id, username: subject.username })
+ expect(env[API::Helpers::API_USER_ENV]).to eq({user_id: subject.id, username: subject.username})
end
end
context "HEAD request" do
before do
- env['REQUEST_METHOD'] = 'HEAD'
+ env["REQUEST_METHOD"] = "HEAD"
end
it { is_expected.to eq(user) }
@@ -86,16 +86,16 @@ describe API::Helpers do
context "PUT request" do
before do
- env['REQUEST_METHOD'] = 'PUT'
+ env["REQUEST_METHOD"] = "PUT"
end
- context 'without CSRF token' do
+ context "without CSRF token" do
it { is_expected.to be_nil }
end
- context 'with CSRF token' do
+ context "with CSRF token" do
before do
- env['HTTP_X_CSRF_TOKEN'] = csrf_token
+ env["HTTP_X_CSRF_TOKEN"] = csrf_token
end
it { is_expected.to eq(user) }
@@ -104,16 +104,16 @@ describe API::Helpers do
context "POST request" do
before do
- env['REQUEST_METHOD'] = 'POST'
+ env["REQUEST_METHOD"] = "POST"
end
- context 'without CSRF token' do
+ context "without CSRF token" do
it { is_expected.to be_nil }
end
- context 'with CSRF token' do
+ context "with CSRF token" do
before do
- env['HTTP_X_CSRF_TOKEN'] = csrf_token
+ env["HTTP_X_CSRF_TOKEN"] = csrf_token
end
it { is_expected.to eq(user) }
@@ -122,16 +122,16 @@ describe API::Helpers do
context "DELETE request" do
before do
- env['REQUEST_METHOD'] = 'DELETE'
+ env["REQUEST_METHOD"] = "DELETE"
end
- context 'without CSRF token' do
+ context "without CSRF token" do
it { is_expected.to be_nil }
end
- context 'with CSRF token' do
+ context "with CSRF token" do
before do
- env['HTTP_X_CSRF_TOKEN'] = csrf_token
+ env["HTTP_X_CSRF_TOKEN"] = csrf_token
end
it { is_expected.to eq(user) }
@@ -144,7 +144,7 @@ describe API::Helpers do
let(:personal_access_token) { create(:personal_access_token, user: user) }
it "returns a 401 response for an invalid token" do
- env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = 'invalid token'
+ env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = "invalid token"
expect { current_user }.to raise_error /401/
end
@@ -156,24 +156,24 @@ describe API::Helpers do
expect { current_user }.to raise_error /403/
end
- it 'returns a 403 response for a user who is blocked' do
+ it "returns a 403 response for a user who is blocked" do
user.block!
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect { current_user }.to raise_error /403/
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
before do
enforce_terms
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
end
- it 'returns a 403 when a user has not accepted the terms' do
+ it "returns a 403 when a user has not accepted the terms" do
expect { current_user }.to raise_error /must accept the Terms of Service/
end
- it 'sets the current user when the user accepted the terms' do
+ it "sets the current user when the user accepted the terms" do
accept_terms(user)
expect(current_user).to eq(user)
@@ -186,27 +186,27 @@ describe API::Helpers do
end
it "does not allow tokens without the appropriate scope" do
- personal_access_token = create(:personal_access_token, user: user, scopes: ['read_user'])
+ personal_access_token = create(:personal_access_token, user: user, scopes: ["read_user"])
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect { current_user }.to raise_error Gitlab::Auth::InsufficientScopeError
end
- it 'does not allow revoked tokens' do
+ it "does not allow revoked tokens" do
personal_access_token.revoke!
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect { current_user }.to raise_error Gitlab::Auth::RevokedError
end
- it 'does not allow expired tokens' do
+ it "does not allow expired tokens" do
personal_access_token.update!(expires_at: 1.day.ago)
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
expect { current_user }.to raise_error Gitlab::Auth::ExpiredError
end
- context 'when impersonation is disabled' do
+ context "when impersonation is disabled" do
let(:personal_access_token) { create(:personal_access_token, :impersonation, user: user) }
before do
@@ -214,14 +214,14 @@ describe API::Helpers do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = personal_access_token.token
end
- it 'does not allow impersonation tokens' do
+ it "does not allow impersonation tokens" do
expect { current_user }.to raise_error Gitlab::Auth::ImpersonationDisabled
end
end
end
end
- describe '.handle_api_exception' do
+ describe ".handle_api_exception" do
before do
allow_any_instance_of(self.class).to receive(:rack_response)
allow(Gitlab::Sentry).to receive(:enabled?).and_return(true)
@@ -231,11 +231,11 @@ describe API::Helpers do
sentry_dsn: "dummy://12345:67890@sentry.localdomain/sentry/42"
)
configure_sentry
- Raven.client.configuration.encoding = 'json'
+ Raven.client.configuration.encoding = "json"
end
- it 'does not report a MethodNotAllowed exception to Sentry' do
- exception = Grape::Exceptions::MethodNotAllowed.new({ 'X-GitLab-Test' => '1' })
+ it "does not report a MethodNotAllowed exception to Sentry" do
+ exception = Grape::Exceptions::MethodNotAllowed.new({"X-GitLab-Test" => "1"})
allow(exception).to receive(:backtrace).and_return(caller)
expect(Raven).not_to receive(:capture_exception).with(exception)
@@ -243,62 +243,62 @@ describe API::Helpers do
handle_api_exception(exception)
end
- it 'does report RuntimeError to Sentry' do
- exception = RuntimeError.new('test error')
+ it "does report RuntimeError to Sentry" do
+ exception = RuntimeError.new("test error")
allow(exception).to receive(:backtrace).and_return(caller)
expect(Raven).to receive(:capture_exception).with(exception, tags: {
- correlation_id: 'new-correlation-id'
+ correlation_id: "new-correlation-id",
}, extra: {})
- Gitlab::CorrelationId.use_id('new-correlation-id') do
+ Gitlab::CorrelationId.use_id("new-correlation-id") do
handle_api_exception(exception)
end
end
- context 'with a personal access token given' do
- let(:token) { create(:personal_access_token, scopes: ['api'], user: user) }
+ context "with a personal access token given" do
+ let(:token) { create(:personal_access_token, scopes: ["api"], user: user) }
# Regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/38571
- it 'does not raise an additional exception because of missing `request`' do
+ it "does not raise an additional exception because of missing `request`" do
# We need to stub at a lower level than #sentry_enabled? otherwise
# Sentry is not enabled when the request below is made, and the test
# would pass even without the fix
- expect(ProjectsFinder).to receive(:new).and_raise('Runtime Error!')
+ expect(ProjectsFinder).to receive(:new).and_raise("Runtime Error!")
- get api('/projects', personal_access_token: token)
+ get api("/projects", personal_access_token: token)
# The 500 status is expected as we're testing a case where an exception
# is raised, but Grape shouldn't raise an additional exception
expect(response).to have_gitlab_http_status(500)
- expect(json_response['message']).not_to include("undefined local variable or method `request'")
- expect(json_response['message']).to start_with("\nRuntimeError (Runtime Error!):")
+ expect(json_response["message"]).not_to include("undefined local variable or method `request'")
+ expect(json_response["message"]).to start_with("\nRuntimeError (Runtime Error!):")
end
end
- context 'extra information' do
+ context "extra information" do
# Sentry events are an array of the form [auth_header, data, options]
let(:event_data) { Raven.client.transport.events.first[1] }
- it 'sends the params, excluding confidential values' do
- expect(ProjectsFinder).to receive(:new).and_raise('Runtime Error!')
+ it "sends the params, excluding confidential values" do
+ expect(ProjectsFinder).to receive(:new).and_raise("Runtime Error!")
- get api('/projects', user), params: { password: 'dont_send_this', other_param: 'send_this' }
+ get api("/projects", user), params: {password: "dont_send_this", other_param: "send_this"}
- expect(event_data).to include('other_param=send_this')
- expect(event_data).to include('password=********')
+ expect(event_data).to include("other_param=send_this")
+ expect(event_data).to include("password=********")
end
end
end
- describe '.authenticate_non_get!' do
+ describe ".authenticate_non_get!" do
%w[HEAD GET].each do |method_name|
context "method is #{method_name}" do
before do
expect_any_instance_of(self.class).to receive(:route).and_return(double(request_method: method_name))
end
- it 'does not raise an error' do
+ it "does not raise an error" do
expect_any_instance_of(self.class).not_to receive(:authenticate!)
expect { authenticate_non_get! }.not_to raise_error
@@ -312,7 +312,7 @@ describe API::Helpers do
expect_any_instance_of(self.class).to receive(:route).and_return(double(request_method: method_name))
end
- it 'calls authenticate!' do
+ it "calls authenticate!" do
expect_any_instance_of(self.class).to receive(:authenticate!)
authenticate_non_get!
@@ -321,120 +321,120 @@ describe API::Helpers do
end
end
- describe '.authenticate!' do
- context 'current_user is nil' do
+ describe ".authenticate!" do
+ context "current_user is nil" do
before do
expect_any_instance_of(self.class).to receive(:current_user).and_return(nil)
end
- it 'returns a 401 response' do
+ it "returns a 401 response" do
expect { authenticate! }.to raise_error /401/
end
end
- context 'current_user is present' do
+ context "current_user is present" do
let(:user) { build(:user) }
before do
expect_any_instance_of(self.class).to receive(:current_user).and_return(user)
end
- it 'does not raise an error' do
+ it "does not raise an error" do
expect { authenticate! }.not_to raise_error
end
end
end
- context 'sudo' do
- shared_examples 'successful sudo' do
- it 'sets current_user' do
+ context "sudo" do
+ shared_examples "successful sudo" do
+ it "sets current_user" do
expect(current_user).to eq(user)
end
- it 'sets sudo?' do
+ it "sets sudo?" do
expect(sudo?).to be_truthy
end
end
- shared_examples 'sudo' do
- context 'when admin' do
+ shared_examples "sudo" do
+ context "when admin" do
before do
token.user = admin
token.save!
end
- context 'when token has sudo scope' do
+ context "when token has sudo scope" do
before do
token.scopes = %w[sudo]
token.save!
end
- context 'when user exists' do
- context 'when using header' do
- context 'when providing username' do
+ context "when user exists" do
+ context "when using header" do
+ context "when providing username" do
before do
env[API::Helpers::SUDO_HEADER] = user.username
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
- context 'when providing username (case insensitive)' do
+ context "when providing username (case insensitive)" do
before do
env[API::Helpers::SUDO_HEADER] = user.username.upcase
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
- context 'when providing user ID' do
+ context "when providing user ID" do
before do
env[API::Helpers::SUDO_HEADER] = user.id.to_s
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
end
- context 'when using param' do
- context 'when providing username' do
+ context "when using param" do
+ context "when providing username" do
before do
set_param(API::Helpers::SUDO_PARAM, user.username)
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
- context 'when providing username (case insensitive)' do
+ context "when providing username (case insensitive)" do
before do
set_param(API::Helpers::SUDO_PARAM, user.username.upcase)
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
- context 'when providing user ID' do
+ context "when providing user ID" do
before do
set_param(API::Helpers::SUDO_PARAM, user.id.to_s)
end
- it_behaves_like 'successful sudo'
+ it_behaves_like "successful sudo"
end
end
end
- context 'when user does not exist' do
+ context "when user does not exist" do
before do
- set_param(API::Helpers::SUDO_PARAM, 'nonexistent')
+ set_param(API::Helpers::SUDO_PARAM, "nonexistent")
end
- it 'raises an error' do
+ it "raises an error" do
expect { current_user }.to raise_error /User with ID or username 'nonexistent' Not Found/
end
end
end
- context 'when token does not have sudo scope' do
+ context "when token does not have sudo scope" do
before do
token.scopes = %w[api]
token.save!
@@ -442,13 +442,13 @@ describe API::Helpers do
set_param(API::Helpers::SUDO_PARAM, user.id.to_s)
end
- it 'raises an error' do
+ it "raises an error" do
expect { current_user }.to raise_error Gitlab::Auth::InsufficientScopeError
end
end
end
- context 'when not admin' do
+ context "when not admin" do
before do
token.user = user
token.save!
@@ -456,49 +456,49 @@ describe API::Helpers do
set_param(API::Helpers::SUDO_PARAM, user.id.to_s)
end
- it 'raises an error' do
+ it "raises an error" do
expect { current_user }.to raise_error /Must be admin to use sudo/
end
end
end
- context 'using an OAuth token' do
+ context "using an OAuth token" do
let(:token) { create(:oauth_access_token) }
before do
- env['HTTP_AUTHORIZATION'] = "Bearer #{token.token}"
+ env["HTTP_AUTHORIZATION"] = "Bearer #{token.token}"
end
- it_behaves_like 'sudo'
+ it_behaves_like "sudo"
end
- context 'using a personal access token' do
+ context "using a personal access token" do
let(:token) { create(:personal_access_token) }
- context 'passed as param' do
+ context "passed as param" do
before do
set_param(Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_PARAM, token.token)
end
- it_behaves_like 'sudo'
+ it_behaves_like "sudo"
end
- context 'passed as header' do
+ context "passed as header" do
before do
env[Gitlab::Auth::UserAuthFinders::PRIVATE_TOKEN_HEADER] = token.token
end
- it_behaves_like 'sudo'
+ it_behaves_like "sudo"
end
end
- context 'using warden authentication' do
+ context "using warden authentication" do
before do
warden_authenticate_returns admin
env[API::Helpers::SUDO_HEADER] = user.username
end
- it 'raises an error' do
+ it "raises an error" do
expect { current_user }.to raise_error /Must be authenticated using an OAuth or Personal Access Token to use sudo/
end
end
diff --git a/spec/requests/api/import_github_spec.rb b/spec/requests/api/import_github_spec.rb
index aceff9b4aa6..8c87bf3ca25 100644
--- a/spec/requests/api/import_github_spec.rb
+++ b/spec/requests/api/import_github_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ImportGithub do
include ApiHelpers
let(:token) { "asdasd12345" }
let(:provider) { :github }
- let(:access_params) { { github_access_token: token } }
+ let(:access_params) { {github_access_token: token} }
describe "POST /import/github" do
let(:user) { create(:user) }
@@ -14,7 +14,7 @@ describe API::ImportGithub do
let(:provider_user) { OpenStruct.new(login: provider_username) }
let(:provider_repo) do
OpenStruct.new(
- name: 'vim',
+ name: "vim",
full_name: "#{provider_username}/vim",
owner: OpenStruct.new(login: provider_username)
)
@@ -22,32 +22,32 @@ describe API::ImportGithub do
before do
Grape::Endpoint.before_each do |endpoint|
- allow(endpoint).to receive(:client).and_return(double('client', user: provider_user, repo: provider_repo).as_null_object)
+ allow(endpoint).to receive(:client).and_return(double("client", user: provider_user, repo: provider_repo).as_null_object)
end
end
- it 'returns 201 response when the project is imported successfully' do
+ it "returns 201 response when the project is imported successfully" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post api("/import/github", user), params: {
target_namespace: user.namespace_path,
personal_access_token: token,
- repo_id: 1234
+ repo_id: 1234,
}
expect(response).to have_gitlab_http_status(201)
expect(json_response).to be_a Hash
- expect(json_response['name']).to eq(project.name)
+ expect(json_response["name"]).to eq(project.name)
end
- it 'returns 422 response when user can not create projects in the chosen namespace' do
- other_namespace = create(:group, name: 'other_namespace')
+ it "returns 422 response when user can not create projects in the chosen namespace" do
+ other_namespace = create(:group, name: "other_namespace")
post api("/import/github", user), params: {
target_namespace: other_namespace.name,
personal_access_token: token,
- repo_id: 1234
+ repo_id: 1234,
}
expect(response).to have_gitlab_http_status(422)
diff --git a/spec/requests/api/internal_spec.rb b/spec/requests/api/internal_spec.rb
index cd85151ec1b..4b272380d40 100644
--- a/spec/requests/api/internal_spec.rb
+++ b/spec/requests/api/internal_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Internal do
set(:user) { create(:user) }
@@ -6,54 +6,54 @@ describe API::Internal do
set(:project) { create(:project, :repository, :wiki_repo) }
let(:secret_token) { Gitlab::Shell.secret_token }
let(:gl_repository) { "project-#{project.id}" }
- let(:reference_counter) { double('ReferenceCounter') }
+ let(:reference_counter) { double("ReferenceCounter") }
describe "GET /internal/check" do
it do
- expect_any_instance_of(Redis).to receive(:ping).and_return('PONG')
+ expect_any_instance_of(Redis).to receive(:ping).and_return("PONG")
- get api("/internal/check"), params: { secret_token: secret_token }
+ get api("/internal/check"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['api_version']).to eq(API::API.version)
- expect(json_response['redis']).to be(true)
+ expect(json_response["api_version"]).to eq(API::API.version)
+ expect(json_response["redis"]).to be(true)
end
- it 'returns false for field `redis` when redis is unavailable' do
+ it "returns false for field `redis` when redis is unavailable" do
expect_any_instance_of(Redis).to receive(:ping).and_raise(Errno::ENOENT)
- get api("/internal/check"), params: { secret_token: secret_token }
+ get api("/internal/check"), params: {secret_token: secret_token}
- expect(json_response['redis']).to be(false)
+ expect(json_response["redis"]).to be(false)
end
end
- describe 'GET /internal/broadcast_message' do
- context 'broadcast message exists' do
- let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
+ describe "GET /internal/broadcast_message" do
+ context "broadcast message exists" do
+ let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now) }
- it 'returns one broadcast message' do
- get api('/internal/broadcast_message'), params: { secret_token: secret_token }
+ it "returns one broadcast message" do
+ get api("/internal/broadcast_message"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['message']).to eq(broadcast_message.message)
+ expect(json_response["message"]).to eq(broadcast_message.message)
end
end
- context 'broadcast message does not exist' do
- it 'returns nothing' do
- get api('/internal/broadcast_message'), params: { secret_token: secret_token }
+ context "broadcast message does not exist" do
+ it "returns nothing" do
+ get api("/internal/broadcast_message"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
end
end
- context 'nil broadcast message' do
- it 'returns nothing' do
+ context "nil broadcast message" do
+ it "returns nothing" do
allow(BroadcastMessage).to receive(:current).and_return(nil)
- get api('/internal/broadcast_message'), params: { secret_token: secret_token }
+ get api("/internal/broadcast_message"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
@@ -61,21 +61,21 @@ describe API::Internal do
end
end
- describe 'GET /internal/broadcast_messages' do
- context 'broadcast message(s) exist' do
- let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
+ describe "GET /internal/broadcast_messages" do
+ context "broadcast message(s) exist" do
+ let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now) }
- it 'returns active broadcast message(s)' do
- get api('/internal/broadcast_messages'), params: { secret_token: secret_token }
+ it "returns active broadcast message(s)" do
+ get api("/internal/broadcast_messages"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
- expect(json_response[0]['message']).to eq(broadcast_message.message)
+ expect(json_response[0]["message"]).to eq(broadcast_message.message)
end
end
- context 'broadcast message does not exist' do
- it 'returns nothing' do
- get api('/internal/broadcast_messages'), params: { secret_token: secret_token }
+ context "broadcast message does not exist" do
+ it "returns nothing" do
+ get api("/internal/broadcast_messages"), params: {secret_token: secret_token}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_empty
@@ -83,74 +83,74 @@ describe API::Internal do
end
end
- describe 'GET /internal/two_factor_recovery_codes' do
- it 'returns an error message when the key does not exist' do
- post api('/internal/two_factor_recovery_codes'),
- params: {
- secret_token: secret_token,
- key_id: 12345
- }
+ describe "GET /internal/two_factor_recovery_codes" do
+ it "returns an error message when the key does not exist" do
+ post api("/internal/two_factor_recovery_codes"),
+ params: {
+ secret_token: secret_token,
+ key_id: 12345,
+ }
- expect(json_response['success']).to be_falsey
- expect(json_response['message']).to eq('Could not find the given key')
+ expect(json_response["success"]).to be_falsey
+ expect(json_response["message"]).to eq("Could not find the given key")
end
- it 'returns an error message when the key is a deploy key' do
+ it "returns an error message when the key is a deploy key" do
deploy_key = create(:deploy_key)
- post api('/internal/two_factor_recovery_codes'),
- params: {
- secret_token: secret_token,
- key_id: deploy_key.id
- }
+ post api("/internal/two_factor_recovery_codes"),
+ params: {
+ secret_token: secret_token,
+ key_id: deploy_key.id,
+ }
- expect(json_response['success']).to be_falsey
- expect(json_response['message']).to eq('Deploy keys cannot be used to retrieve recovery codes')
+ expect(json_response["success"]).to be_falsey
+ expect(json_response["message"]).to eq("Deploy keys cannot be used to retrieve recovery codes")
end
- it 'returns an error message when the user does not exist' do
+ it "returns an error message when the user does not exist" do
key_without_user = create(:key, user: nil)
- post api('/internal/two_factor_recovery_codes'),
- params: {
- secret_token: secret_token,
- key_id: key_without_user.id
- }
+ post api("/internal/two_factor_recovery_codes"),
+ params: {
+ secret_token: secret_token,
+ key_id: key_without_user.id,
+ }
- expect(json_response['success']).to be_falsey
- expect(json_response['message']).to eq('Could not find a user for the given key')
- expect(json_response['recovery_codes']).to be_nil
+ expect(json_response["success"]).to be_falsey
+ expect(json_response["message"]).to eq("Could not find a user for the given key")
+ expect(json_response["recovery_codes"]).to be_nil
end
- context 'when two-factor is enabled' do
- it 'returns new recovery codes when the user exists' do
+ context "when two-factor is enabled" do
+ it "returns new recovery codes when the user exists" do
allow_any_instance_of(User).to receive(:two_factor_enabled?).and_return(true)
allow_any_instance_of(User)
- .to receive(:generate_otp_backup_codes!).and_return(%w(119135e5a3ebce8e 34bd7b74adbc8861))
+ .to receive(:generate_otp_backup_codes!).and_return(%w[119135e5a3ebce8e 34bd7b74adbc8861])
- post api('/internal/two_factor_recovery_codes'),
- params: {
- secret_token: secret_token,
- key_id: key.id
- }
+ post api("/internal/two_factor_recovery_codes"),
+ params: {
+ secret_token: secret_token,
+ key_id: key.id,
+ }
- expect(json_response['success']).to be_truthy
- expect(json_response['recovery_codes']).to match_array(%w(119135e5a3ebce8e 34bd7b74adbc8861))
+ expect(json_response["success"]).to be_truthy
+ expect(json_response["recovery_codes"]).to match_array(%w[119135e5a3ebce8e 34bd7b74adbc8861])
end
end
- context 'when two-factor is not enabled' do
- it 'returns an error message' do
+ context "when two-factor is not enabled" do
+ it "returns an error message" do
allow_any_instance_of(User).to receive(:two_factor_enabled?).and_return(false)
- post api('/internal/two_factor_recovery_codes'),
- params: {
- secret_token: secret_token,
- key_id: key.id
- }
+ post api("/internal/two_factor_recovery_codes"),
+ params: {
+ secret_token: secret_token,
+ key_id: key.id,
+ }
- expect(json_response['success']).to be_falsey
- expect(json_response['recovery_codes']).to be_nil
+ expect(json_response["success"]).to be_falsey
+ expect(json_response["recovery_codes"]).to be_nil
end
end
end
@@ -160,89 +160,89 @@ describe API::Internal do
project.add_developer(user)
end
- context 'user key' do
- it 'returns the correct information about the key' do
+ context "user key" do
+ it "returns the correct information about the key" do
lfs_auth_key(key.id, project)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['username']).to eq(user.username)
- expect(json_response['repository_http_path']).to eq(project.http_url_to_repo)
- expect(json_response['expires_in']).to eq(Gitlab::LfsToken::DEFAULT_EXPIRE_TIME)
- expect(Gitlab::LfsToken.new(key).token_valid?(json_response['lfs_token'])).to be_truthy
+ expect(json_response["username"]).to eq(user.username)
+ expect(json_response["repository_http_path"]).to eq(project.http_url_to_repo)
+ expect(json_response["expires_in"]).to eq(Gitlab::LfsToken::DEFAULT_EXPIRE_TIME)
+ expect(Gitlab::LfsToken.new(key).token_valid?(json_response["lfs_token"])).to be_truthy
end
- it 'returns the correct information about the user' do
+ it "returns the correct information about the user" do
lfs_auth_user(user.id, project)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['username']).to eq(user.username)
- expect(json_response['repository_http_path']).to eq(project.http_url_to_repo)
- expect(Gitlab::LfsToken.new(user).token_valid?(json_response['lfs_token'])).to be_truthy
+ expect(json_response["username"]).to eq(user.username)
+ expect(json_response["repository_http_path"]).to eq(project.http_url_to_repo)
+ expect(Gitlab::LfsToken.new(user).token_valid?(json_response["lfs_token"])).to be_truthy
end
- it 'returns a 404 when no key or user is provided' do
+ it "returns a 404 when no key or user is provided" do
lfs_auth_project(project)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when the wrong key is provided' do
+ it "returns a 404 when the wrong key is provided" do
lfs_auth_key(key.id + 12345, project)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when the wrong user is provided' do
+ it "returns a 404 when the wrong user is provided" do
lfs_auth_user(user.id + 12345, project)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'deploy key' do
+ context "deploy key" do
let(:key) { create(:deploy_key) }
- it 'returns the correct information about the key' do
+ it "returns the correct information about the key" do
lfs_auth_key(key.id, project)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['username']).to eq("lfs+deploy-key-#{key.id}")
- expect(json_response['repository_http_path']).to eq(project.http_url_to_repo)
- expect(Gitlab::LfsToken.new(key).token_valid?(json_response['lfs_token'])).to be_truthy
+ expect(json_response["username"]).to eq("lfs+deploy-key-#{key.id}")
+ expect(json_response["repository_http_path"]).to eq(project.http_url_to_repo)
+ expect(Gitlab::LfsToken.new(key).token_valid?(json_response["lfs_token"])).to be_truthy
end
end
end
describe "GET /internal/discover" do
it "finds a user by key id" do
- get(api("/internal/discover"), params: { key_id: key.id, secret_token: secret_token })
+ get(api("/internal/discover"), params: {key_id: key.id, secret_token: secret_token})
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(user.name)
+ expect(json_response["name"]).to eq(user.name)
end
it "finds a user by user id" do
- get(api("/internal/discover"), params: { user_id: user.id, secret_token: secret_token })
+ get(api("/internal/discover"), params: {user_id: user.id, secret_token: secret_token})
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(user.name)
+ expect(json_response["name"]).to eq(user.name)
end
it "finds a user by username" do
- get(api("/internal/discover"), params: { username: user.username, secret_token: secret_token })
+ get(api("/internal/discover"), params: {username: user.username, secret_token: secret_token})
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(user.name)
+ expect(json_response["name"]).to eq(user.name)
end
end
describe "GET /internal/authorized_keys" do
context "using an existing key's fingerprint" do
it "finds the key" do
- get(api('/internal/authorized_keys'), params: { fingerprint: key.fingerprint, secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {fingerprint: key.fingerprint, secret_token: secret_token})
expect(response.status).to eq(200)
expect(json_response["key"]).to eq(key.key)
@@ -251,7 +251,7 @@ describe API::Internal do
context "non existing key's fingerprint" do
it "returns 404" do
- get(api('/internal/authorized_keys'), params: { fingerprint: "no:t-:va:li:d0", secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {fingerprint: "no:t-:va:li:d0", secret_token: secret_token})
expect(response.status).to eq(404)
end
@@ -259,7 +259,7 @@ describe API::Internal do
context "using a partial fingerprint" do
it "returns 404" do
- get(api('/internal/authorized_keys'), params: { fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {fingerprint: "#{key.fingerprint[0..5]}%", secret_token: secret_token})
expect(response.status).to eq(404)
end
@@ -267,20 +267,20 @@ describe API::Internal do
context "sending the key" do
it "finds the key" do
- get(api('/internal/authorized_keys'), params: { key: key.key.split[1], secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {key: key.key.split[1], secret_token: secret_token})
expect(response.status).to eq(200)
expect(json_response["key"]).to eq(key.key)
end
it "returns 404 with a partial key" do
- get(api('/internal/authorized_keys'), params: { key: key.key.split[1][0...-3], secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {key: key.key.split[1][0...-3], secret_token: secret_token})
expect(response.status).to eq(404)
end
it "returns 404 with an not valid base64 string" do
- get(api('/internal/authorized_keys'), params: { key: "whatever!", secret_token: secret_token })
+ get(api("/internal/authorized_keys"), params: {key: "whatever!", secret_token: secret_token})
expect(response.status).to eq(404)
end
@@ -297,21 +297,21 @@ describe API::Internal do
project.add_developer(user)
end
- context 'with env passed as a JSON' do
+ context "with env passed as a JSON" do
let(:gl_repository) { project.gl_repository(is_wiki: true) }
- it 'sets env in RequestStore' do
- obj_dir_relative = './objects'
- alt_obj_dirs_relative = ['./alt-objects-1', './alt-objects-2']
+ it "sets env in RequestStore" do
+ obj_dir_relative = "./objects"
+ alt_obj_dirs_relative = ["./alt-objects-1", "./alt-objects-2"]
expect(Gitlab::Git::HookEnv).to receive(:set).with(gl_repository, {
- 'GIT_OBJECT_DIRECTORY_RELATIVE' => obj_dir_relative,
- 'GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE' => alt_obj_dirs_relative
+ "GIT_OBJECT_DIRECTORY_RELATIVE" => obj_dir_relative,
+ "GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE" => alt_obj_dirs_relative,
})
push(key, project.wiki, env: {
GIT_OBJECT_DIRECTORY_RELATIVE: obj_dir_relative,
- GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: alt_obj_dirs_relative
+ GIT_ALTERNATE_OBJECT_DIRECTORIES_RELATIVE: alt_obj_dirs_relative,
}.to_json)
expect(response).to have_gitlab_http_status(200)
@@ -319,12 +319,12 @@ describe API::Internal do
end
context "git push with project.wiki" do
- it 'responds with success' do
+ it "responds with success" do
push(key, project.wiki)
expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy
- expect(json_response["repository_path"]).to eq('/')
+ expect(json_response["repository_path"]).to eq("/")
expect(json_response["gl_project_path"]).to eq(project.wiki.full_path)
expect(json_response["gl_repository"]).to eq("wiki-#{project.id}")
expect(user.reload.last_activity_on).to be_nil
@@ -332,12 +332,12 @@ describe API::Internal do
end
context "git pull with project.wiki" do
- it 'responds with success' do
+ it "responds with success" do
pull(key, project.wiki)
expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy
- expect(json_response["repository_path"]).to eq('/')
+ expect(json_response["repository_path"]).to eq("/")
expect(json_response["gl_project_path"]).to eq(project.wiki.full_path)
expect(json_response["gl_repository"]).to eq("wiki-#{project.id}")
expect(user.reload.last_activity_on).to eql(Date.today)
@@ -350,7 +350,7 @@ describe API::Internal do
expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy
- expect(json_response["repository_path"]).to eq('/')
+ expect(json_response["repository_path"]).to eq("/")
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
expect(json_response["gl_project_path"]).to eq(project.full_path)
expect(json_response["gitaly"]).not_to be_nil
@@ -364,13 +364,13 @@ describe API::Internal do
end
context "git push" do
- context 'project as namespace/project' do
+ context "project as namespace/project" do
it do
push(key, project)
expect(response).to have_gitlab_http_status(200)
expect(json_response["status"]).to be_truthy
- expect(json_response["repository_path"]).to eq('/')
+ expect(json_response["repository_path"]).to eq("/")
expect(json_response["gl_repository"]).to eq("project-#{project.id}")
expect(json_response["gl_project_path"]).to eq(project.full_path)
expect(json_response["gitaly"]).not_to be_nil
@@ -383,8 +383,8 @@ describe API::Internal do
end
end
- context 'when receive_max_input_size has been updated' do
- it 'returns custom git config' do
+ context "when receive_max_input_size has been updated" do
+ it "returns custom git config" do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { 1 }
push(key, project)
@@ -393,8 +393,8 @@ describe API::Internal do
end
end
- context 'when receive_max_input_size is empty' do
- it 'returns an empty git config' do
+ context "when receive_max_input_size is empty" do
+ it "returns an empty git config" do
allow(Gitlab::CurrentSettings).to receive(:receive_max_input_size) { nil }
push(key, project)
@@ -433,15 +433,15 @@ describe API::Internal do
context "custom action" do
let(:access_checker) { double(Gitlab::GitAccess) }
- let(:message) { 'CustomActionError message' }
+ let(:message) { "CustomActionError message" }
let(:payload) do
{
- 'action' => 'geo_proxy_to_primary',
- 'data' => {
- 'api_endpoints' => %w{geo/proxy_git_push_ssh/info_refs geo/proxy_git_push_ssh/push},
- 'gl_username' => 'testuser',
- 'primary_repo' => 'http://localhost:3000/testuser/repo.git'
- }
+ "action" => "geo_proxy_to_primary",
+ "data" => {
+ "api_endpoints" => %w[geo/proxy_git_push_ssh/info_refs geo/proxy_git_push_ssh/push],
+ "gl_username" => "testuser",
+ "primary_repo" => "http://localhost:3000/testuser/repo.git",
+ },
}
end
@@ -452,17 +452,17 @@ describe API::Internal do
expect(Gitlab::GitAccess).to receive(:new).with(
key,
project,
- 'ssh',
+ "ssh",
{
authentication_abilities: [:read_project, :download_code, :push_code],
namespace_path: project.namespace.name,
project_path: project.path,
- redirected_path: nil
+ redirected_path: nil,
}
).and_return(access_checker)
expect(access_checker).to receive(:check).with(
- 'git-receive-pack',
- 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master'
+ "git-receive-pack",
+ "d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master"
).and_return(custom_action_result)
end
@@ -471,9 +471,9 @@ describe API::Internal do
push(key, project)
expect(response).to have_gitlab_http_status(300)
- expect(json_response['status']).to be_truthy
- expect(json_response['message']).to eql(message)
- expect(json_response['payload']).to eql(payload)
+ expect(json_response["status"]).to be_truthy
+ expect(json_response["message"]).to eql(message)
+ expect(json_response["payload"]).to eql(payload)
expect(user.reload.last_activity_on).to be_nil
end
end
@@ -507,9 +507,9 @@ describe API::Internal do
end
end
- context 'request times out' do
- context 'git push' do
- it 'responds with a gateway timeout' do
+ context "request times out" do
+ context "git push" do
+ it "responds with a gateway timeout" do
personal_project = create(:project, namespace: user.namespace)
expect_next_instance_of(Gitlab::GitAccess) do |access|
@@ -518,8 +518,8 @@ describe API::Internal do
push(key, personal_project)
expect(response).to have_gitlab_http_status(503)
- expect(json_response['status']).to be_falsey
- expect(json_response['message']).to eq("Foo")
+ expect(json_response["status"]).to be_falsey
+ expect(json_response["message"]).to eq("Foo")
expect(user.reload.last_activity_on).to be_nil
end
end
@@ -582,8 +582,8 @@ describe API::Internal do
end
end
- context 'project does not exist' do
- it 'returns a 200 response with status: false' do
+ context "project does not exist" do
+ it "returns a 200 response with status: false" do
project.destroy
pull(key, project)
@@ -593,7 +593,7 @@ describe API::Internal do
end
end
- context 'user does not exist' do
+ context "user does not exist" do
it do
pull(OpenStruct.new(id: 0), project)
@@ -602,88 +602,88 @@ describe API::Internal do
end
end
- context 'ssh access has been disabled' do
+ context "ssh access has been disabled" do
before do
- stub_application_setting(enabled_git_access_protocol: 'http')
+ stub_application_setting(enabled_git_access_protocol: "http")
end
- it 'rejects the SSH push' do
+ it "rejects the SSH push" do
push(key, project)
expect(response.status).to eq(401)
- expect(json_response['status']).to be_falsey
- expect(json_response['message']).to eq 'Git access over SSH is not allowed'
+ expect(json_response["status"]).to be_falsey
+ expect(json_response["message"]).to eq "Git access over SSH is not allowed"
end
- it 'rejects the SSH pull' do
+ it "rejects the SSH pull" do
pull(key, project)
expect(response.status).to eq(401)
- expect(json_response['status']).to be_falsey
- expect(json_response['message']).to eq 'Git access over SSH is not allowed'
+ expect(json_response["status"]).to be_falsey
+ expect(json_response["message"]).to eq "Git access over SSH is not allowed"
end
end
- context 'http access has been disabled' do
+ context "http access has been disabled" do
before do
- stub_application_setting(enabled_git_access_protocol: 'ssh')
+ stub_application_setting(enabled_git_access_protocol: "ssh")
end
- it 'rejects the HTTP push' do
- push(key, project, 'http')
+ it "rejects the HTTP push" do
+ push(key, project, "http")
expect(response.status).to eq(401)
- expect(json_response['status']).to be_falsey
- expect(json_response['message']).to eq 'Git access over HTTP is not allowed'
+ expect(json_response["status"]).to be_falsey
+ expect(json_response["message"]).to eq "Git access over HTTP is not allowed"
end
- it 'rejects the HTTP pull' do
- pull(key, project, 'http')
+ it "rejects the HTTP pull" do
+ pull(key, project, "http")
expect(response.status).to eq(401)
- expect(json_response['status']).to be_falsey
- expect(json_response['message']).to eq 'Git access over HTTP is not allowed'
+ expect(json_response["status"]).to be_falsey
+ expect(json_response["message"]).to eq "Git access over HTTP is not allowed"
end
end
- context 'web actions are always allowed' do
- it 'allows WEB push' do
- stub_application_setting(enabled_git_access_protocol: 'ssh')
+ context "web actions are always allowed" do
+ it "allows WEB push" do
+ stub_application_setting(enabled_git_access_protocol: "ssh")
project.add_developer(user)
- push(key, project, 'web')
+ push(key, project, "web")
expect(response.status).to eq(200)
- expect(json_response['status']).to be_truthy
+ expect(json_response["status"]).to be_truthy
end
end
- context 'the project path was changed' do
+ context "the project path was changed" do
let(:project) { create(:project, :repository, :legacy_storage) }
let!(:repository) { project.repository }
before do
project.add_developer(user)
- project.path = 'new_path'
+ project.path = "new_path"
project.save!
end
- it 'rejects the push' do
+ it "rejects the push" do
push(key, project)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['status']).to be_falsy
+ expect(json_response["status"]).to be_falsy
end
- it 'rejects the SSH pull' do
+ it "rejects the SSH pull" do
pull(key, project)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['status']).to be_falsy
+ expect(json_response["status"]).to be_falsy
end
end
end
- describe 'GET /internal/merge_request_urls' do
+ describe "GET /internal/merge_request_urls" do
let(:repo_name) { "#{project.namespace.name}/#{project.path}" }
let(:changes) { URI.escape("#{Gitlab::Git::BLANK_SHA} 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/new_branch") }
@@ -691,34 +691,34 @@ describe API::Internal do
project.add_developer(user)
end
- it 'returns link to create new merge request' do
- get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: { secret_token: secret_token }
+ it "returns link to create new merge request" do
+ get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: {secret_token: secret_token}
expect(json_response).to match [{
"branch_name" => "new_branch",
"url" => "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch",
- "new_merge_request" => true
+ "new_merge_request" => true,
}]
end
- it 'returns empty array if printing_merge_request_link_enabled is false' do
+ it "returns empty array if printing_merge_request_link_enabled is false" do
project.update!(printing_merge_request_link_enabled: false)
- get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: { secret_token: secret_token }
+ get api("/internal/merge_request_urls?project=#{repo_name}&changes=#{changes}"), params: {secret_token: secret_token}
expect(json_response).to eq([])
end
- context 'with a gl_repository parameter' do
+ context "with a gl_repository parameter" do
let(:gl_repository) { "project-#{project.id}" }
- it 'returns link to create new merge request' do
- get api("/internal/merge_request_urls?gl_repository=#{gl_repository}&changes=#{changes}"), params: { secret_token: secret_token }
+ it "returns link to create new merge request" do
+ get api("/internal/merge_request_urls?gl_repository=#{gl_repository}&changes=#{changes}"), params: {secret_token: secret_token}
expect(json_response).to match [{
"branch_name" => "new_branch",
"url" => "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch",
- "new_merge_request" => true
+ "new_merge_request" => true,
}]
end
end
@@ -806,8 +806,8 @@ describe API::Internal do
# end
# end
- describe 'POST /internal/post_receive', :clean_gitlab_redis_shared_state do
- let(:identifier) { 'key-123' }
+ describe "POST /internal/post_receive", :clean_gitlab_redis_shared_state do
+ let(:identifier) { "key-123" }
let(:valid_params) do
{
@@ -815,7 +815,7 @@ describe API::Internal do
secret_token: secret_token,
identifier: identifier,
changes: changes,
- push_options: push_options
+ push_options: push_options,
}
end
@@ -824,8 +824,8 @@ describe API::Internal do
end
let(:push_options) do
- ['ci.skip',
- 'another push option']
+ ["ci.skip",
+ "another push option",]
end
before do
@@ -834,75 +834,75 @@ describe API::Internal do
allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(user)
end
- it 'enqueues a PostReceive worker job' do
+ it "enqueues a PostReceive worker job" do
expect(PostReceive).to receive(:perform_async)
.with(gl_repository, identifier, changes, push_options)
post api("/internal/post_receive"), params: valid_params
end
- it 'decreases the reference counter and returns the result' do
+ it "decreases the reference counter and returns the result" do
expect(Gitlab::ReferenceCounter).to receive(:new).with(gl_repository)
.and_return(reference_counter)
expect(reference_counter).to receive(:decrease).and_return(true)
post api("/internal/post_receive"), params: valid_params
- expect(json_response['reference_counter_decreased']).to be(true)
+ expect(json_response["reference_counter_decreased"]).to be(true)
end
- it 'returns link to create new merge request' do
+ it "returns link to create new merge request" do
post api("/internal/post_receive"), params: valid_params
- expect(json_response['merge_request_urls']).to match [{
+ expect(json_response["merge_request_urls"]).to match [{
"branch_name" => "new_branch",
"url" => "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch",
- "new_merge_request" => true
+ "new_merge_request" => true,
}]
end
- it 'returns empty array if printing_merge_request_link_enabled is false' do
+ it "returns empty array if printing_merge_request_link_enabled is false" do
project.update!(printing_merge_request_link_enabled: false)
post api("/internal/post_receive"), params: valid_params
- expect(json_response['merge_request_urls']).to eq([])
+ expect(json_response["merge_request_urls"]).to eq([])
end
- context 'broadcast message exists' do
- let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now ) }
+ context "broadcast message exists" do
+ let!(:broadcast_message) { create(:broadcast_message, starts_at: 1.day.ago, ends_at: 1.day.from_now) }
- it 'returns one broadcast message' do
+ it "returns one broadcast message" do
post api("/internal/post_receive"), params: valid_params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['broadcast_message']).to eq(broadcast_message.message)
+ expect(json_response["broadcast_message"]).to eq(broadcast_message.message)
end
end
- context 'broadcast message does not exist' do
- it 'returns empty string' do
+ context "broadcast message does not exist" do
+ it "returns empty string" do
post api("/internal/post_receive"), params: valid_params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['broadcast_message']).to eq(nil)
+ expect(json_response["broadcast_message"]).to eq(nil)
end
end
- context 'nil broadcast message' do
- it 'returns empty string' do
+ context "nil broadcast message" do
+ it "returns empty string" do
allow(BroadcastMessage).to receive(:current).and_return(nil)
post api("/internal/post_receive"), params: valid_params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['broadcast_message']).to eq(nil)
+ expect(json_response["broadcast_message"]).to eq(nil)
end
end
- context 'with a redirected data' do
- it 'returns redirected message on the response' do
- project_moved = Gitlab::Checks::ProjectMoved.new(project, user, 'http', 'foo/baz')
+ context "with a redirected data" do
+ it "returns redirected message on the response" do
+ project_moved = Gitlab::Checks::ProjectMoved.new(project, user, "http", "foo/baz")
project_moved.add_message
post api("/internal/post_receive"), params: valid_params
@@ -913,9 +913,9 @@ describe API::Internal do
end
end
- context 'with new project data' do
- it 'returns new project message on the response' do
- project_created = Gitlab::Checks::ProjectCreated.new(project, user, 'http')
+ context "with new project data" do
+ it "returns new project message on the response" do
+ project_created = Gitlab::Checks::ProjectCreated.new(project, user, "http")
project_created.add_message
post api("/internal/post_receive"), params: valid_params
@@ -926,8 +926,8 @@ describe API::Internal do
end
end
- context 'with an orphaned write deploy key' do
- it 'does not try to notify that project moved' do
+ context "with an orphaned write deploy key" do
+ it "does not try to notify that project moved" do
allow_any_instance_of(Gitlab::Identifier).to receive(:identify).and_return(nil)
post api("/internal/post_receive"), params: valid_params
@@ -937,19 +937,19 @@ describe API::Internal do
end
end
- describe 'POST /internal/pre_receive' do
+ describe "POST /internal/pre_receive" do
let(:valid_params) do
- { gl_repository: gl_repository, secret_token: secret_token }
+ {gl_repository: gl_repository, secret_token: secret_token}
end
- it 'decreases the reference counter and returns the result' do
+ it "decreases the reference counter and returns the result" do
expect(Gitlab::ReferenceCounter).to receive(:new).with(gl_repository)
.and_return(reference_counter)
expect(reference_counter).to receive(:increase).and_return(true)
post api("/internal/pre_receive"), params: valid_params
- expect(json_response['reference_counter_increased']).to be(true)
+ expect(json_response["reference_counter_increased"]).to be(true)
end
end
@@ -959,35 +959,33 @@ describe API::Internal do
project_or_wiki.project.gl_repository(is_wiki: true)
when Project
project_or_wiki.gl_repository(is_wiki: false)
- else
- nil
end
end
- def pull(key, project, protocol = 'ssh')
+ def pull(key, project, protocol = "ssh")
post(
api("/internal/allowed"),
params: {
key_id: key.id,
project: project.full_path,
gl_repository: gl_repository_for(project),
- action: 'git-upload-pack',
+ action: "git-upload-pack",
secret_token: secret_token,
- protocol: protocol
+ protocol: protocol,
}
)
end
- def push(key, project, protocol = 'ssh', env: nil)
+ def push(key, project, protocol = "ssh", env: nil)
params = {
- changes: 'd14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master',
+ changes: "d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master",
key_id: key.id,
project: project.full_path,
gl_repository: gl_repository_for(project),
- action: 'git-receive-pack',
+ action: "git-receive-pack",
secret_token: secret_token,
protocol: protocol,
- env: env
+ env: env,
}
post(
@@ -1000,13 +998,13 @@ describe API::Internal do
post(
api("/internal/allowed"),
params: {
- ref: 'master',
+ ref: "master",
key_id: key.id,
project: project.full_path,
gl_repository: gl_repository_for(project),
- action: 'git-upload-archive',
+ action: "git-upload-archive",
secret_token: secret_token,
- protocol: 'ssh'
+ protocol: "ssh",
}
)
end
@@ -1016,7 +1014,7 @@ describe API::Internal do
api("/internal/lfs_authenticate"),
params: {
secret_token: secret_token,
- project: project.full_path
+ project: project.full_path,
}
)
end
@@ -1027,7 +1025,7 @@ describe API::Internal do
params: {
key_id: key_id,
secret_token: secret_token,
- project: project.full_path
+ project: project.full_path,
}
)
end
@@ -1038,7 +1036,7 @@ describe API::Internal do
params: {
user_id: user_id,
secret_token: secret_token,
- project: project.full_path
+ project: project.full_path,
}
)
end
diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb
index 01bab2a1361..dbfb1b1c567 100644
--- a/spec/requests/api/issues_spec.rb
+++ b/spec/requests/api/issues_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Issues do
set(:user) { create(:user) }
@@ -12,46 +12,46 @@ describe API::Issues do
set(:author) { create(:author) }
set(:assignee) { create(:assignee) }
let(:admin) { create(:user, :admin) }
- let(:issue_title) { 'foo' }
- let(:issue_description) { 'closed' }
+ let(:issue_title) { "foo" }
+ let(:issue_description) { "closed" }
let!(:closed_issue) do
create :closed_issue,
- author: user,
- assignees: [user],
- project: project,
- state: :closed,
- milestone: milestone,
- created_at: generate(:past_time),
- updated_at: 3.hours.ago,
- closed_at: 1.hour.ago
+ author: user,
+ assignees: [user],
+ project: project,
+ state: :closed,
+ milestone: milestone,
+ created_at: generate(:past_time),
+ updated_at: 3.hours.ago,
+ closed_at: 1.hour.ago
end
let!(:confidential_issue) do
create :issue,
- :confidential,
- project: project,
- author: author,
- assignees: [assignee],
- created_at: generate(:past_time),
- updated_at: 2.hours.ago
+ :confidential,
+ project: project,
+ author: author,
+ assignees: [assignee],
+ created_at: generate(:past_time),
+ updated_at: 2.hours.ago
end
let!(:issue) do
create :issue,
- author: user,
- assignees: [user],
- project: project,
- milestone: milestone,
- created_at: generate(:past_time),
- updated_at: 1.hour.ago,
- title: issue_title,
- description: issue_description
+ author: user,
+ assignees: [user],
+ project: project,
+ milestone: milestone,
+ created_at: generate(:past_time),
+ updated_at: 1.hour.ago,
+ title: issue_title,
+ description: issue_description
end
set(:label) do
- create(:label, title: 'label', color: '#FFAABB', project: project)
+ create(:label, title: "label", color: "#FFAABB", project: project)
end
let!(:label_link) { create(:label_link, label: label, target: issue) }
- set(:milestone) { create(:milestone, title: '1.0.0', project: project) }
+ set(:milestone) { create(:milestone, title: "1.0.0", project: project) }
set(:empty_milestone) do
- create(:milestone, title: '2.0.0', project: project)
+ create(:milestone, title: "2.0.0", project: project)
end
let!(:note) { create(:note_on_issue, author: user, project: project, noteable: issue) }
@@ -66,7 +66,7 @@ describe API::Issues do
describe "GET /issues" do
context "when unauthenticated" do
it "returns an array of all issues" do
- get api("/issues"), params: { scope: 'all' }
+ get api("/issues"), params: {scope: "all"}
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
@@ -79,13 +79,13 @@ describe API::Issues do
end
it "returns authentication error when scope is assigned-to-me" do
- get api("/issues"), params: { scope: 'assigned-to-me' }
+ get api("/issues"), params: {scope: "assigned-to-me"}
expect(response).to have_http_status(401)
end
it "returns authentication error when scope is created-by-me" do
- get api("/issues"), params: { scope: 'created-by-me' }
+ get api("/issues"), params: {scope: "created-by-me"}
expect(response).to have_http_status(401)
end
@@ -96,360 +96,360 @@ describe API::Issues do
get api("/issues", user)
expect_paginated_array_response([issue.id, closed_issue.id])
- expect(json_response.first['title']).to eq(issue.title)
- expect(json_response.last).to have_key('web_url')
+ expect(json_response.first["title"]).to eq(issue.title)
+ expect(json_response.last).to have_key("web_url")
end
- it 'returns an array of closed issues' do
- get api('/issues', user), params: { state: :closed }
+ it "returns an array of closed issues" do
+ get api("/issues", user), params: {state: :closed}
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an array of opened issues' do
- get api('/issues', user), params: { state: :opened }
+ it "returns an array of opened issues" do
+ get api("/issues", user), params: {state: :opened}
expect_paginated_array_response(issue.id)
end
- it 'returns an array of all issues' do
- get api('/issues', user), params: { state: :all }
+ it "returns an array of all issues" do
+ get api("/issues", user), params: {state: :all}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns issues assigned to me' do
+ it "returns issues assigned to me" do
issue2 = create(:issue, assignees: [user2], project: project)
- get api('/issues', user2), params: { scope: 'assigned_to_me' }
+ get api("/issues", user2), params: {scope: "assigned_to_me"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues assigned to me (kebab-case)' do
+ it "returns issues assigned to me (kebab-case)" do
issue2 = create(:issue, assignees: [user2], project: project)
- get api('/issues', user2), params: { scope: 'assigned-to-me' }
+ get api("/issues", user2), params: {scope: "assigned-to-me"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues authored by the given author id' do
+ it "returns issues authored by the given author id" do
issue2 = create(:issue, author: user2, project: project)
- get api('/issues', user), params: { author_id: user2.id, scope: 'all' }
+ get api("/issues", user), params: {author_id: user2.id, scope: "all"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues assigned to the given assignee id' do
+ it "returns issues assigned to the given assignee id" do
issue2 = create(:issue, assignees: [user2], project: project)
- get api('/issues', user), params: { assignee_id: user2.id, scope: 'all' }
+ get api("/issues", user), params: {assignee_id: user2.id, scope: "all"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues authored by the given author id and assigned to the given assignee id' do
+ it "returns issues authored by the given author id and assigned to the given assignee id" do
issue2 = create(:issue, author: user2, assignees: [user2], project: project)
- get api('/issues', user), params: { author_id: user2.id, assignee_id: user2.id, scope: 'all' }
+ get api("/issues", user), params: {author_id: user2.id, assignee_id: user2.id, scope: "all"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues with no assignee' do
+ it "returns issues with no assignee" do
issue2 = create(:issue, author: user2, project: project)
- get api('/issues', user), params: { assignee_id: 0, scope: 'all' }
+ get api("/issues", user), params: {assignee_id: 0, scope: "all"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues with no assignee' do
+ it "returns issues with no assignee" do
issue2 = create(:issue, author: user2, project: project)
- get api('/issues', user), params: { assignee_id: 'None', scope: 'all' }
+ get api("/issues", user), params: {assignee_id: "None", scope: "all"}
expect_paginated_array_response(issue2.id)
end
- it 'returns issues with any assignee' do
+ it "returns issues with any assignee" do
# This issue without assignee should not be returned
create(:issue, author: user2, project: project)
- get api('/issues', user), params: { assignee_id: 'Any', scope: 'all' }
+ get api("/issues", user), params: {assignee_id: "Any", scope: "all"}
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'returns only confidential issues' do
- get api('/issues', user), params: { confidential: true, scope: 'all' }
+ it "returns only confidential issues" do
+ get api("/issues", user), params: {confidential: true, scope: "all"}
expect_paginated_array_response(confidential_issue.id)
end
- it 'returns only public issues' do
- get api('/issues', user), params: { confidential: false }
+ it "returns only public issues" do
+ get api("/issues", user), params: {confidential: false}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns issues reacted by the authenticated user' do
+ it "returns issues reacted by the authenticated user" do
issue2 = create(:issue, project: project, author: user, assignees: [user])
- create(:award_emoji, awardable: issue2, user: user2, name: 'star')
- create(:award_emoji, awardable: issue, user: user2, name: 'thumbsup')
+ create(:award_emoji, awardable: issue2, user: user2, name: "star")
+ create(:award_emoji, awardable: issue, user: user2, name: "thumbsup")
- get api('/issues', user2), params: { my_reaction_emoji: 'Any', scope: 'all' }
+ get api("/issues", user2), params: {my_reaction_emoji: "Any", scope: "all"}
expect_paginated_array_response([issue2.id, issue.id])
end
- it 'returns issues not reacted by the authenticated user' do
+ it "returns issues not reacted by the authenticated user" do
issue2 = create(:issue, project: project, author: user, assignees: [user])
- create(:award_emoji, awardable: issue2, user: user2, name: 'star')
+ create(:award_emoji, awardable: issue2, user: user2, name: "star")
- get api('/issues', user2), params: { my_reaction_emoji: 'None', scope: 'all' }
+ get api("/issues", user2), params: {my_reaction_emoji: "None", scope: "all"}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns issues matching given search string for title' do
- get api("/issues", user), params: { search: issue.title }
+ it "returns issues matching given search string for title" do
+ get api("/issues", user), params: {search: issue.title}
expect_paginated_array_response(issue.id)
end
- it 'returns issues matching given search string for title and scoped in title' do
- get api("/issues", user), params: { search: issue.title, in: 'title' }
+ it "returns issues matching given search string for title and scoped in title" do
+ get api("/issues", user), params: {search: issue.title, in: "title"}
expect_paginated_array_response(issue.id)
end
- it 'returns an empty array if no issue matches given search string for title and scoped in description' do
- get api("/issues", user), params: { search: issue.title, in: 'description' }
+ it "returns an empty array if no issue matches given search string for title and scoped in description" do
+ get api("/issues", user), params: {search: issue.title, in: "description"}
expect_paginated_array_response([])
end
- it 'returns issues matching given search string for description' do
- get api("/issues", user), params: { search: issue.description }
+ it "returns issues matching given search string for description" do
+ get api("/issues", user), params: {search: issue.description}
expect_paginated_array_response(issue.id)
end
- context 'filtering before a specific date' do
+ context "filtering before a specific date" do
let!(:issue2) { create(:issue, project: project, author: user, created_at: Date.new(2000, 1, 1), updated_at: Date.new(2000, 1, 1)) }
- it 'returns issues created before a specific date' do
- get api('/issues?created_before=2000-01-02T00:00:00.060Z', user)
+ it "returns issues created before a specific date" do
+ get api("/issues?created_before=2000-01-02T00:00:00.060Z", user)
expect_paginated_array_response(issue2.id)
end
- it 'returns issues updated before a specific date' do
- get api('/issues?updated_before=2000-01-02T00:00:00.060Z', user)
+ it "returns issues updated before a specific date" do
+ get api("/issues?updated_before=2000-01-02T00:00:00.060Z", user)
expect_paginated_array_response(issue2.id)
end
end
- context 'filtering after a specific date' do
+ context "filtering after a specific date" do
let!(:issue2) { create(:issue, project: project, author: user, created_at: 1.week.from_now, updated_at: 1.week.from_now) }
- it 'returns issues created after a specific date' do
+ it "returns issues created after a specific date" do
get api("/issues?created_after=#{issue2.created_at}", user)
expect_paginated_array_response(issue2.id)
end
- it 'returns issues updated after a specific date' do
+ it "returns issues updated after a specific date" do
get api("/issues?updated_after=#{issue2.updated_at}", user)
expect_paginated_array_response(issue2.id)
end
end
- it 'returns an array of labeled issues' do
- get api("/issues", user), params: { labels: label.title }
+ it "returns an array of labeled issues" do
+ get api("/issues", user), params: {labels: label.title}
expect_paginated_array_response(issue.id)
- expect(json_response.first['labels']).to eq([label.title])
+ expect(json_response.first["labels"]).to eq([label.title])
end
- it 'returns an array of labeled issues when all labels matches' do
- label_b = create(:label, title: 'foo', project: project)
- label_c = create(:label, title: 'bar', project: project)
+ it "returns an array of labeled issues when all labels matches" do
+ label_b = create(:label, title: "foo", project: project)
+ label_c = create(:label, title: "bar", project: project)
create(:label_link, label: label_b, target: issue)
create(:label_link, label: label_c, target: issue)
- get api("/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" }
+ get api("/issues", user), params: {labels: "#{label.title},#{label_b.title},#{label_c.title}"}
expect_paginated_array_response(issue.id)
- expect(json_response.first['labels']).to eq([label_c.title, label_b.title, label.title])
+ expect(json_response.first["labels"]).to eq([label_c.title, label_b.title, label.title])
end
- it 'returns an empty array if no issue matches labels' do
- get api('/issues', user), params: { labels: 'foo,bar' }
+ it "returns an empty array if no issue matches labels" do
+ get api("/issues", user), params: {labels: "foo,bar"}
expect_paginated_array_response([])
end
- it 'returns an array of labeled issues matching given state' do
- get api("/issues", user), params: { labels: label.title, state: :opened }
+ it "returns an array of labeled issues matching given state" do
+ get api("/issues", user), params: {labels: label.title, state: :opened}
expect_paginated_array_response(issue.id)
- expect(json_response.first['labels']).to eq([label.title])
- expect(json_response.first['state']).to eq('opened')
+ expect(json_response.first["labels"]).to eq([label.title])
+ expect(json_response.first["state"]).to eq("opened")
end
- it 'returns an empty array if no issue matches labels and state filters' do
- get api("/issues", user), params: { labels: label.title, state: :closed }
+ it "returns an empty array if no issue matches labels and state filters" do
+ get api("/issues", user), params: {labels: label.title, state: :closed}
expect_paginated_array_response([])
end
- it 'returns an array of issues with any label' do
- get api("/issues", user), params: { labels: IssuesFinder::FILTER_ANY }
+ it "returns an array of issues with any label" do
+ get api("/issues", user), params: {labels: IssuesFinder::FILTER_ANY}
expect_paginated_array_response(issue.id)
end
- it 'returns an array of issues with no label' do
- get api("/issues", user), params: { labels: IssuesFinder::FILTER_NONE }
+ it "returns an array of issues with no label" do
+ get api("/issues", user), params: {labels: IssuesFinder::FILTER_NONE}
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an array of issues with no label when using the legacy No+Label filter' do
- get api("/issues", user), params: { labels: "No Label" }
+ it "returns an array of issues with no label when using the legacy No+Label filter" do
+ get api("/issues", user), params: {labels: "No Label"}
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an empty array if no issue matches milestone' do
+ it "returns an empty array if no issue matches milestone" do
get api("/issues?milestone=#{empty_milestone.title}", user)
expect_paginated_array_response([])
end
- it 'returns an empty array if milestone does not exist' do
+ it "returns an empty array if milestone does not exist" do
get api("/issues?milestone=foo", user)
expect_paginated_array_response([])
end
- it 'returns an array of issues in given milestone' do
+ it "returns an array of issues in given milestone" do
get api("/issues?milestone=#{milestone.title}", user)
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns an array of issues matching state in milestone' do
+ it "returns an array of issues matching state in milestone" do
get api("/issues?milestone=#{milestone.title}"\
- '&state=closed', user)
+ "&state=closed", user)
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an array of issues with no milestone' do
+ it "returns an array of issues with no milestone" do
get api("/issues?milestone=#{no_milestone_title}", author)
expect_paginated_array_response(confidential_issue.id)
end
- it 'returns an array of issues found by iids' do
- get api('/issues', user), params: { iids: [closed_issue.iid] }
+ it "returns an array of issues found by iids" do
+ get api("/issues", user), params: {iids: [closed_issue.iid]}
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an empty array if iid does not exist' do
- get api("/issues", user), params: { iids: [0] }
+ it "returns an empty array if iid does not exist" do
+ get api("/issues", user), params: {iids: [0]}
expect_paginated_array_response([])
end
- context 'without sort params' do
- it 'sorts by created_at descending by default' do
- get api('/issues', user)
+ context "without sort params" do
+ it "sorts by created_at descending by default" do
+ get api("/issues", user)
expect_paginated_array_response([issue.id, closed_issue.id])
end
- context 'with 2 issues with same created_at' do
+ context "with 2 issues with same created_at" do
let!(:closed_issue2) do
create :closed_issue,
- author: user,
- assignees: [user],
- project: project,
- milestone: milestone,
- created_at: closed_issue.created_at,
- updated_at: 1.hour.ago,
- title: issue_title,
- description: issue_description
+ author: user,
+ assignees: [user],
+ project: project,
+ milestone: milestone,
+ created_at: closed_issue.created_at,
+ updated_at: 1.hour.ago,
+ title: issue_title,
+ description: issue_description
end
- it 'page breaks first page correctly' do
- get api('/issues?per_page=2', user)
+ it "page breaks first page correctly" do
+ get api("/issues?per_page=2", user)
expect_paginated_array_response([issue.id, closed_issue2.id])
end
- it 'page breaks second page correctly' do
- get api('/issues?per_page=2&page=2', user)
+ it "page breaks second page correctly" do
+ get api("/issues?per_page=2&page=2", user)
expect_paginated_array_response([closed_issue.id])
end
end
end
- it 'sorts ascending when requested' do
- get api('/issues?sort=asc', user)
+ it "sorts ascending when requested" do
+ get api("/issues?sort=asc", user)
expect_paginated_array_response([closed_issue.id, issue.id])
end
- it 'sorts by updated_at descending when requested' do
- get api('/issues?order_by=updated_at', user)
+ it "sorts by updated_at descending when requested" do
+ get api("/issues?order_by=updated_at", user)
issue.touch(:updated_at)
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'sorts by updated_at ascending when requested' do
- get api('/issues?order_by=updated_at&sort=asc', user)
+ it "sorts by updated_at ascending when requested" do
+ get api("/issues?order_by=updated_at&sort=asc", user)
issue.touch(:updated_at)
expect_paginated_array_response([closed_issue.id, issue.id])
end
- it 'matches V4 response schema' do
- get api('/issues', user)
+ it "matches V4 response schema" do
+ get api("/issues", user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/issues')
+ expect(response).to match_response_schema("public_api/v4/issues")
end
- it 'returns a related merge request count of 0 if there are no related merge requests' do
- get api('/issues', user)
+ it "returns a related merge request count of 0 if there are no related merge requests" do
+ get api("/issues", user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/issues')
- expect(json_response.first).to include('merge_requests_count' => 0)
+ expect(response).to match_response_schema("public_api/v4/issues")
+ expect(json_response.first).to include("merge_requests_count" => 0)
end
- it 'returns a related merge request count > 0 if there are related merge requests' do
+ it "returns a related merge request count > 0 if there are related merge requests" do
create(:merge_requests_closing_issues, issue: issue)
- get api('/issues', user)
+ get api("/issues", user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/issues')
- expect(json_response.first).to include('merge_requests_count' => 1)
+ expect(response).to match_response_schema("public_api/v4/issues")
+ expect(json_response.first).to include("merge_requests_count" => 1)
end
end
end
@@ -459,47 +459,47 @@ describe API::Issues do
let!(:group_project) { create(:project, :public, creator_id: user.id, namespace: group) }
let!(:group_closed_issue) do
create :closed_issue,
- author: user,
- assignees: [user],
- project: group_project,
- state: :closed,
- milestone: group_milestone,
- updated_at: 3.hours.ago,
- created_at: 1.day.ago
+ author: user,
+ assignees: [user],
+ project: group_project,
+ state: :closed,
+ milestone: group_milestone,
+ updated_at: 3.hours.ago,
+ created_at: 1.day.ago
end
let!(:group_confidential_issue) do
create :issue,
- :confidential,
- project: group_project,
- author: author,
- assignees: [assignee],
- updated_at: 2.hours.ago,
- created_at: 2.days.ago
+ :confidential,
+ project: group_project,
+ author: author,
+ assignees: [assignee],
+ updated_at: 2.hours.ago,
+ created_at: 2.days.ago
end
let!(:group_issue) do
create :issue,
- author: user,
- assignees: [user],
- project: group_project,
- milestone: group_milestone,
- updated_at: 1.hour.ago,
- title: issue_title,
- description: issue_description,
- created_at: 5.days.ago
+ author: user,
+ assignees: [user],
+ project: group_project,
+ milestone: group_milestone,
+ updated_at: 1.hour.ago,
+ title: issue_title,
+ description: issue_description,
+ created_at: 5.days.ago
end
let!(:group_label) do
- create(:label, title: 'group_lbl', color: '#FFAABB', project: group_project)
+ create(:label, title: "group_lbl", color: "#FFAABB", project: group_project)
end
let!(:group_label_link) { create(:label_link, label: group_label, target: group_issue) }
- let!(:group_milestone) { create(:milestone, title: '3.0.0', project: group_project) }
+ let!(:group_milestone) { create(:milestone, title: "3.0.0", project: group_project) }
let!(:group_empty_milestone) do
- create(:milestone, title: '4.0.0', project: group_project)
+ create(:milestone, title: "4.0.0", project: group_project)
end
let!(:group_note) { create(:note_on_issue, author: user, project: group_project, noteable: group_issue) }
let(:base_url) { "/groups/#{group.id}/issues" }
- context 'when group has subgroups', :nested_groups do
+ context "when group has subgroups", :nested_groups do
let(:subgroup_1) { create(:group, parent: group) }
let(:subgroup_2) { create(:group, parent: subgroup_1) }
@@ -513,203 +513,203 @@ describe API::Issues do
group.add_developer(user)
end
- it 'also returns subgroups projects issues' do
+ it "also returns subgroups projects issues" do
get api(base_url, user)
expect_paginated_array_response([issue_2.id, issue_1.id, group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end
end
- context 'when user is unauthenticated' do
- it 'lists all issues in public projects' do
+ context "when user is unauthenticated" do
+ it "lists all issues in public projects" do
get api(base_url)
expect_paginated_array_response([group_closed_issue.id, group_issue.id])
end
end
- context 'when user is a group member' do
+ context "when user is a group member" do
before do
group_project.add_reporter(user)
end
- it 'returns all group issues (including opened and closed)' do
+ it "returns all group issues (including opened and closed)" do
get api(base_url, admin)
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end
- it 'returns group issues without confidential issues for non project members' do
- get api(base_url, non_member), params: { state: :opened }
+ it "returns group issues without confidential issues for non project members" do
+ get api(base_url, non_member), params: {state: :opened}
expect_paginated_array_response(group_issue.id)
end
- it 'returns group confidential issues for author' do
- get api(base_url, author), params: { state: :opened }
+ it "returns group confidential issues for author" do
+ get api(base_url, author), params: {state: :opened}
expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end
- it 'returns group confidential issues for assignee' do
- get api(base_url, assignee), params: { state: :opened }
+ it "returns group confidential issues for assignee" do
+ get api(base_url, assignee), params: {state: :opened}
expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end
- it 'returns group issues with confidential issues for project members' do
- get api(base_url, user), params: { state: :opened }
+ it "returns group issues with confidential issues for project members" do
+ get api(base_url, user), params: {state: :opened}
expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end
- it 'returns group confidential issues for admin' do
- get api(base_url, admin), params: { state: :opened }
+ it "returns group confidential issues for admin" do
+ get api(base_url, admin), params: {state: :opened}
expect_paginated_array_response([group_confidential_issue.id, group_issue.id])
end
- it 'returns only confidential issues' do
- get api(base_url, user), params: { confidential: true }
+ it "returns only confidential issues" do
+ get api(base_url, user), params: {confidential: true}
expect_paginated_array_response(group_confidential_issue.id)
end
- it 'returns only public issues' do
- get api(base_url, user), params: { confidential: false }
+ it "returns only public issues" do
+ get api(base_url, user), params: {confidential: false}
expect_paginated_array_response([group_closed_issue.id, group_issue.id])
end
- it 'returns an array of labeled group issues' do
- get api(base_url, user), params: { labels: group_label.title }
+ it "returns an array of labeled group issues" do
+ get api(base_url, user), params: {labels: group_label.title}
expect_paginated_array_response(group_issue.id)
- expect(json_response.first['labels']).to eq([group_label.title])
+ expect(json_response.first["labels"]).to eq([group_label.title])
end
- it 'returns an array of labeled group issues where all labels match' do
- get api(base_url, user), params: { labels: "#{group_label.title},foo,bar" }
+ it "returns an array of labeled group issues where all labels match" do
+ get api(base_url, user), params: {labels: "#{group_label.title},foo,bar"}
expect_paginated_array_response([])
end
- it 'returns issues matching given search string for title' do
- get api(base_url, user), params: { search: group_issue.title }
+ it "returns issues matching given search string for title" do
+ get api(base_url, user), params: {search: group_issue.title}
expect_paginated_array_response(group_issue.id)
end
- it 'returns issues matching given search string for description' do
- get api(base_url, user), params: { search: group_issue.description }
+ it "returns issues matching given search string for description" do
+ get api(base_url, user), params: {search: group_issue.description}
expect_paginated_array_response(group_issue.id)
end
- it 'returns an array of labeled issues when all labels matches' do
- label_b = create(:label, title: 'foo', project: group_project)
- label_c = create(:label, title: 'bar', project: group_project)
+ it "returns an array of labeled issues when all labels matches" do
+ label_b = create(:label, title: "foo", project: group_project)
+ label_c = create(:label, title: "bar", project: group_project)
create(:label_link, label: label_b, target: group_issue)
create(:label_link, label: label_c, target: group_issue)
- get api(base_url, user), params: { labels: "#{group_label.title},#{label_b.title},#{label_c.title}" }
+ get api(base_url, user), params: {labels: "#{group_label.title},#{label_b.title},#{label_c.title}"}
expect_paginated_array_response(group_issue.id)
- expect(json_response.first['labels']).to eq([label_c.title, label_b.title, group_label.title])
+ expect(json_response.first["labels"]).to eq([label_c.title, label_b.title, group_label.title])
end
- it 'returns an array of issues found by iids' do
- get api(base_url, user), params: { iids: [group_issue.iid] }
+ it "returns an array of issues found by iids" do
+ get api(base_url, user), params: {iids: [group_issue.iid]}
expect_paginated_array_response(group_issue.id)
- expect(json_response.first['id']).to eq(group_issue.id)
+ expect(json_response.first["id"]).to eq(group_issue.id)
end
- it 'returns an empty array if iid does not exist' do
- get api(base_url, user), params: { iids: [0] }
+ it "returns an empty array if iid does not exist" do
+ get api(base_url, user), params: {iids: [0]}
expect_paginated_array_response([])
end
- it 'returns an empty array if no group issue matches labels' do
- get api(base_url, user), params: { labels: 'foo,bar' }
+ it "returns an empty array if no group issue matches labels" do
+ get api(base_url, user), params: {labels: "foo,bar"}
expect_paginated_array_response([])
end
- it 'returns an array of group issues with any label' do
- get api(base_url, user), params: { labels: IssuesFinder::FILTER_ANY }
+ it "returns an array of group issues with any label" do
+ get api(base_url, user), params: {labels: IssuesFinder::FILTER_ANY}
expect_paginated_array_response(group_issue.id)
- expect(json_response.first['id']).to eq(group_issue.id)
+ expect(json_response.first["id"]).to eq(group_issue.id)
end
- it 'returns an array of group issues with no label' do
- get api(base_url, user), params: { labels: IssuesFinder::FILTER_NONE }
+ it "returns an array of group issues with no label" do
+ get api(base_url, user), params: {labels: IssuesFinder::FILTER_NONE}
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id])
end
- it 'returns an empty array if no issue matches milestone' do
- get api(base_url, user), params: { milestone: group_empty_milestone.title }
+ it "returns an empty array if no issue matches milestone" do
+ get api(base_url, user), params: {milestone: group_empty_milestone.title}
expect_paginated_array_response([])
end
- it 'returns an empty array if milestone does not exist' do
- get api(base_url, user), params: { milestone: 'foo' }
+ it "returns an empty array if milestone does not exist" do
+ get api(base_url, user), params: {milestone: "foo"}
expect_paginated_array_response([])
end
- it 'returns an array of issues in given milestone' do
- get api(base_url, user), params: { state: :opened, milestone: group_milestone.title }
+ it "returns an array of issues in given milestone" do
+ get api(base_url, user), params: {state: :opened, milestone: group_milestone.title}
expect_paginated_array_response(group_issue.id)
end
- it 'returns an array of issues matching state in milestone' do
- get api(base_url, user), params: { milestone: group_milestone.title, state: :closed }
+ it "returns an array of issues matching state in milestone" do
+ get api(base_url, user), params: {milestone: group_milestone.title, state: :closed}
expect_paginated_array_response(group_closed_issue.id)
end
- it 'returns an array of issues with no milestone' do
- get api(base_url, user), params: { milestone: no_milestone_title }
+ it "returns an array of issues with no milestone" do
+ get api(base_url, user), params: {milestone: no_milestone_title}
expect(response).to have_gitlab_http_status(200)
expect_paginated_array_response(group_confidential_issue.id)
end
- context 'without sort params' do
- it 'sorts by created_at descending by default' do
+ context "without sort params" do
+ it "sorts by created_at descending by default" do
get api(base_url, user)
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end
- context 'with 2 issues with same created_at' do
+ context "with 2 issues with same created_at" do
let!(:group_issue2) do
create :issue,
- author: user,
- assignees: [user],
- project: group_project,
- milestone: group_milestone,
- updated_at: 1.hour.ago,
- title: issue_title,
- description: issue_description,
- created_at: group_issue.created_at
+ author: user,
+ assignees: [user],
+ project: group_project,
+ milestone: group_milestone,
+ updated_at: 1.hour.ago,
+ title: issue_title,
+ description: issue_description,
+ created_at: group_issue.created_at
end
- it 'page breaks first page correctly' do
+ it "page breaks first page correctly" do
get api("#{base_url}?per_page=3", user)
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue2.id])
end
- it 'page breaks second page correctly' do
+ it "page breaks second page correctly" do
get api("#{base_url}?per_page=3&page=2", user)
expect_paginated_array_response([group_issue.id])
@@ -717,13 +717,13 @@ describe API::Issues do
end
end
- it 'sorts ascending when requested' do
+ it "sorts ascending when requested" do
get api("#{base_url}?sort=asc", user)
expect_paginated_array_response([group_issue.id, group_confidential_issue.id, group_closed_issue.id])
end
- it 'sorts by updated_at descending when requested' do
+ it "sorts by updated_at descending when requested" do
get api("#{base_url}?order_by=updated_at", user)
group_issue.touch(:updated_at)
@@ -731,8 +731,8 @@ describe API::Issues do
expect_paginated_array_response([group_issue.id, group_confidential_issue.id, group_closed_issue.id])
end
- it 'sorts by updated_at ascending when requested' do
- get api(base_url, user), params: { order_by: :updated_at, sort: :asc }
+ it "sorts by updated_at ascending when requested" do
+ get api(base_url, user), params: {order_by: :updated_at, sort: :asc}
expect_paginated_array_response([group_closed_issue.id, group_confidential_issue.id, group_issue.id])
end
@@ -742,30 +742,30 @@ describe API::Issues do
describe "GET /projects/:id/issues" do
let(:base_url) { "/projects/#{project.id}" }
- context 'when unauthenticated' do
- it 'returns public project issues' do
+ context "when unauthenticated" do
+ it "returns public project issues" do
get api("/projects/#{project.id}/issues")
expect_paginated_array_response([issue.id, closed_issue.id])
end
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
get api("/projects/#{project.id}/issues", user)
- control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) {
get api("/projects/#{project.id}/issues", user)
- end.count
+ }.count
create_list(:issue, 3, project: project)
- expect do
+ expect {
get api("/projects/#{project.id}/issues", user)
- end.not_to exceed_all_query_limit(control_count)
+ }.not_to exceed_all_query_limit(control_count)
end
- it 'returns 404 when project does not exist' do
- get api('/projects/1000/issues', non_member)
+ it "returns 404 when project does not exist" do
+ get api("/projects/1000/issues", non_member)
expect(response).to have_gitlab_http_status(404)
end
@@ -779,7 +779,7 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(404)
end
- it 'returns no issues when user has access to project but not issues' do
+ it "returns no issues when user has access to project but not issues" do
restricted_project = create(:project, :public, :issues_private)
create(:issue, project: restricted_project)
@@ -788,183 +788,183 @@ describe API::Issues do
expect_paginated_array_response([])
end
- it 'returns 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_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns 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_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns project confidential issues for author' do
+ it "returns project confidential issues for author" do
get api("#{base_url}/issues", author)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'returns only confidential issues' do
- get api("#{base_url}/issues", author), params: { confidential: true }
+ it "returns only confidential issues" do
+ get api("#{base_url}/issues", author), params: {confidential: true}
expect_paginated_array_response(confidential_issue.id)
end
- it 'returns only public issues' do
- get api("#{base_url}/issues", author), params: { confidential: false }
+ it "returns only public issues" do
+ get api("#{base_url}/issues", author), params: {confidential: false}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns project confidential issues for assignee' do
+ it "returns project confidential issues for assignee" do
get api("#{base_url}/issues", assignee)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'returns 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_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'returns project confidential issues for admin' do
+ it "returns project confidential issues for admin" do
get api("#{base_url}/issues", admin)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'returns an array of labeled project issues' do
- get api("#{base_url}/issues", user), params: { labels: label.title }
+ it "returns an array of labeled project issues" do
+ get api("#{base_url}/issues", user), params: {labels: label.title}
expect_paginated_array_response(issue.id)
end
- it 'returns an array of labeled issues when all labels matches' do
- label_b = create(:label, title: 'foo', project: project)
- label_c = create(:label, title: 'bar', project: project)
+ it "returns an array of labeled issues when all labels matches" do
+ label_b = create(:label, title: "foo", project: project)
+ label_c = create(:label, title: "bar", project: project)
create(:label_link, label: label_b, target: issue)
create(:label_link, label: label_c, target: issue)
- get api("#{base_url}/issues", user), params: { labels: "#{label.title},#{label_b.title},#{label_c.title}" }
+ get api("#{base_url}/issues", user), params: {labels: "#{label.title},#{label_b.title},#{label_c.title}"}
expect_paginated_array_response(issue.id)
end
- it 'returns issues matching given search string for title' do
+ it "returns issues matching given search string for title" do
get api("#{base_url}/issues?search=#{issue.title}", user)
expect_paginated_array_response(issue.id)
end
- it 'returns issues matching given search string for description' do
+ it "returns issues matching given search string for description" do
get api("#{base_url}/issues?search=#{issue.description}", user)
expect_paginated_array_response(issue.id)
end
- it 'returns an array of issues found by iids' do
- get api("#{base_url}/issues", user), params: { iids: [issue.iid] }
+ it "returns an array of issues found by iids" do
+ get api("#{base_url}/issues", user), params: {iids: [issue.iid]}
expect_paginated_array_response(issue.id)
end
- it 'returns an empty array if iid does not exist' do
- get api("#{base_url}/issues", user), params: { iids: [0] }
+ it "returns an empty array if iid does not exist" do
+ get api("#{base_url}/issues", user), params: {iids: [0]}
expect_paginated_array_response([])
end
- it 'returns an empty array if not all labels matches' do
+ it "returns an empty array if not all labels matches" do
get api("#{base_url}/issues?labels=#{label.title},foo", user)
expect_paginated_array_response([])
end
- it 'returns an array of project issues with any label' do
- get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_ANY }
+ it "returns an array of project issues with any label" do
+ get api("#{base_url}/issues", user), params: {labels: IssuesFinder::FILTER_ANY}
expect_paginated_array_response(issue.id)
end
- it 'returns an array of project issues with no label' do
- get api("#{base_url}/issues", user), params: { labels: IssuesFinder::FILTER_NONE }
+ it "returns an array of project issues with no label" do
+ get api("#{base_url}/issues", user), params: {labels: IssuesFinder::FILTER_NONE}
expect_paginated_array_response([confidential_issue.id, closed_issue.id])
end
- it 'returns an empty array if no project issue matches labels' do
- get api("#{base_url}/issues", user), params: { labels: 'foo,bar' }
+ it "returns an empty array if no project issue matches labels" do
+ get api("#{base_url}/issues", user), params: {labels: "foo,bar"}
expect_paginated_array_response([])
end
- it 'returns an empty array if no issue matches milestone' do
- get api("#{base_url}/issues", user), params: { milestone: empty_milestone.title }
+ it "returns an empty array if no issue matches milestone" do
+ get api("#{base_url}/issues", user), params: {milestone: empty_milestone.title}
expect_paginated_array_response([])
end
- it 'returns an empty array if milestone does not exist' do
- get api("#{base_url}/issues", user), params: { milestone: :foo }
+ it "returns an empty array if milestone does not exist" do
+ get api("#{base_url}/issues", user), params: {milestone: :foo}
expect_paginated_array_response([])
end
- it 'returns an array of issues in given milestone' do
- get api("#{base_url}/issues", user), params: { milestone: milestone.title }
+ it "returns an array of issues in given milestone" do
+ get api("#{base_url}/issues", user), params: {milestone: milestone.title}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- it 'returns an array of issues matching state in milestone' do
- get api("#{base_url}/issues", user), params: { milestone: milestone.title, state: :closed }
+ it "returns an array of issues matching state in milestone" do
+ get api("#{base_url}/issues", user), params: {milestone: milestone.title, state: :closed}
expect_paginated_array_response(closed_issue.id)
end
- it 'returns an array of issues with no milestone' do
- get api("#{base_url}/issues", user), params: { milestone: no_milestone_title }
+ it "returns an array of issues with no milestone" do
+ get api("#{base_url}/issues", user), params: {milestone: no_milestone_title}
expect_paginated_array_response(confidential_issue.id)
end
- it 'returns an array of issues with any milestone' do
- get api("#{base_url}/issues", user), params: { milestone: any_milestone_title }
+ it "returns an array of issues with any milestone" do
+ get api("#{base_url}/issues", user), params: {milestone: any_milestone_title}
expect_paginated_array_response([issue.id, closed_issue.id])
end
- context 'without sort params' do
- it 'sorts by created_at descending by default' do
+ context "without sort params" do
+ it "sorts by created_at descending by default" do
get api("#{base_url}/issues", user)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- context 'with 2 issues with same created_at' do
+ context "with 2 issues with same created_at" do
let!(:closed_issue2) do
create :closed_issue,
- author: user,
- assignees: [user],
- project: project,
- milestone: milestone,
- created_at: closed_issue.created_at,
- updated_at: 1.hour.ago,
- title: issue_title,
- description: issue_description
+ author: user,
+ assignees: [user],
+ project: project,
+ milestone: milestone,
+ created_at: closed_issue.created_at,
+ updated_at: 1.hour.ago,
+ title: issue_title,
+ description: issue_description
end
- it 'page breaks first page correctly' do
+ it "page breaks first page correctly" do
get api("#{base_url}/issues?per_page=3", user)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue2.id])
end
- it 'page breaks second page correctly' do
+ it "page breaks second page correctly" do
get api("#{base_url}/issues?per_page=3&page=2", user)
expect_paginated_array_response([closed_issue.id])
@@ -972,74 +972,74 @@ describe API::Issues do
end
end
- it 'sorts ascending when requested' do
- get api("#{base_url}/issues", user), params: { sort: :asc }
+ it "sorts ascending when requested" do
+ get api("#{base_url}/issues", user), params: {sort: :asc}
expect_paginated_array_response([closed_issue.id, confidential_issue.id, issue.id])
end
- it 'sorts by updated_at descending when requested' do
- get api("#{base_url}/issues", user), params: { order_by: :updated_at }
+ it "sorts by updated_at descending when requested" do
+ get api("#{base_url}/issues", user), params: {order_by: :updated_at}
issue.touch(:updated_at)
expect_paginated_array_response([issue.id, confidential_issue.id, closed_issue.id])
end
- it 'sorts by updated_at ascending when requested' do
- get api("#{base_url}/issues", user), params: { order_by: :updated_at, sort: :asc }
+ it "sorts by updated_at ascending when requested" do
+ get api("#{base_url}/issues", user), params: {order_by: :updated_at, sort: :asc}
expect_paginated_array_response([closed_issue.id, confidential_issue.id, issue.id])
end
end
describe "GET /projects/:id/issues/:issue_iid" do
- context 'when unauthenticated' do
- it 'returns public issues' do
+ context "when unauthenticated" do
+ it "returns public issues" do
get api("/projects/#{project.id}/issues/#{issue.iid}")
expect(response).to have_gitlab_http_status(200)
end
end
- it 'exposes known attributes' do
+ it "exposes known attributes" do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(issue.id)
- expect(json_response['iid']).to eq(issue.iid)
- expect(json_response['project_id']).to eq(issue.project.id)
- expect(json_response['title']).to eq(issue.title)
- expect(json_response['description']).to eq(issue.description)
- expect(json_response['state']).to eq(issue.state)
- expect(json_response['closed_at']).to be_falsy
- expect(json_response['created_at']).to be_present
- expect(json_response['updated_at']).to be_present
- expect(json_response['labels']).to eq(issue.label_names)
- expect(json_response['milestone']).to be_a Hash
- expect(json_response['assignees']).to be_a Array
- expect(json_response['assignee']).to be_a Hash
- expect(json_response['author']).to be_a Hash
- expect(json_response['confidential']).to be_falsy
+ expect(json_response["id"]).to eq(issue.id)
+ expect(json_response["iid"]).to eq(issue.iid)
+ expect(json_response["project_id"]).to eq(issue.project.id)
+ expect(json_response["title"]).to eq(issue.title)
+ expect(json_response["description"]).to eq(issue.description)
+ expect(json_response["state"]).to eq(issue.state)
+ expect(json_response["closed_at"]).to be_falsy
+ expect(json_response["created_at"]).to be_present
+ expect(json_response["updated_at"]).to be_present
+ expect(json_response["labels"]).to eq(issue.label_names)
+ expect(json_response["milestone"]).to be_a Hash
+ expect(json_response["assignees"]).to be_a Array
+ expect(json_response["assignee"]).to be_a Hash
+ expect(json_response["author"]).to be_a Hash
+ expect(json_response["confidential"]).to be_falsy
end
it "exposes the 'closed_at' attribute" do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['closed_at']).to be_present
+ expect(json_response["closed_at"]).to be_present
end
- context 'links exposure' do
- it 'exposes related resources full URIs' do
+ context "links exposure" do
+ it "exposes related resources full URIs" do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
- links = json_response['_links']
+ links = json_response["_links"]
- expect(links['self']).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}")
- expect(links['notes']).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}/notes")
- expect(links['award_emoji']).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}/award_emoji")
- expect(links['project']).to end_with("/api/v4/projects/#{project.id}")
+ expect(links["self"]).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}")
+ expect(links["notes"]).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}/notes")
+ expect(links["award_emoji"]).to end_with("/api/v4/projects/#{project.id}/issues/#{issue.iid}/award_emoji")
+ expect(links["project"]).to end_with("/api/v4/projects/#{project.id}")
end
end
@@ -1047,8 +1047,8 @@ describe API::Issues do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(issue.title)
- expect(json_response['iid']).to eq(issue.iid)
+ expect(json_response["title"]).to eq(issue.title)
+ expect(json_response["iid"]).to eq(issue.iid)
end
it "returns 404 if issue id not found" do
@@ -1062,7 +1062,7 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(404)
end
- context 'confidential issues' do
+ context "confidential issues" do
it "returns 404 for non project members" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member)
@@ -1079,206 +1079,206 @@ describe API::Issues do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(confidential_issue.title)
- expect(json_response['iid']).to eq(confidential_issue.iid)
+ expect(json_response["title"]).to eq(confidential_issue.title)
+ expect(json_response["iid"]).to eq(confidential_issue.iid)
end
it "returns confidential issue for author" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(confidential_issue.title)
- expect(json_response['iid']).to eq(confidential_issue.iid)
+ expect(json_response["title"]).to eq(confidential_issue.title)
+ expect(json_response["iid"]).to eq(confidential_issue.iid)
end
it "returns confidential issue for assignee" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", assignee)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(confidential_issue.title)
- expect(json_response['iid']).to eq(confidential_issue.iid)
+ expect(json_response["title"]).to eq(confidential_issue.title)
+ expect(json_response["iid"]).to eq(confidential_issue.iid)
end
it "returns confidential issue for admin" do
get api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(confidential_issue.title)
- expect(json_response['iid']).to eq(confidential_issue.iid)
+ expect(json_response["title"]).to eq(confidential_issue.title)
+ expect(json_response["iid"]).to eq(confidential_issue.iid)
end
end
end
describe "POST /projects/:id/issues" do
- context 'support for deprecated assignee_id' do
- it 'creates a new project issue' do
+ context "support for deprecated assignee_id" do
+ it "creates a new project issue" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', assignee_id: user2.id }
+ params: {title: "new issue", assignee_id: user2.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['assignee']['name']).to eq(user2.name)
- expect(json_response['assignees'].first['name']).to eq(user2.name)
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["assignee"]["name"]).to eq(user2.name)
+ expect(json_response["assignees"].first["name"]).to eq(user2.name)
end
- it 'creates a new project issue when assignee_id is empty' do
+ it "creates a new project issue when assignee_id is empty" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', assignee_id: '' }
+ params: {title: "new issue", assignee_id: ""}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['assignee']).to be_nil
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["assignee"]).to be_nil
end
end
- context 'single assignee restrictions' do
- it 'creates a new project issue with no more than one assignee' do
+ context "single assignee restrictions" do
+ it "creates a new project issue with no more than one assignee" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', assignee_ids: [user2.id, guest.id] }
+ params: {title: "new issue", assignee_ids: [user2.id, guest.id]}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['assignees'].count).to eq(1)
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["assignees"].count).to eq(1)
end
end
- context 'user does not have permissions to create issue' do
+ context "user does not have permissions to create issue" do
let(:not_member) { create(:user) }
before do
project.project_feature.update(issues_access_level: ProjectFeature::PRIVATE)
end
- it 'renders 403' do
- post api("/projects/#{project.id}/issues", not_member), params: { title: 'new issue' }
+ it "renders 403" do
+ post api("/projects/#{project.id}/issues", not_member), params: {title: "new issue"}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'an internal ID is provided' do
- context 'by an admin' do
- it 'sets the internal ID on the new issue' do
+ context "an internal ID is provided" do
+ context "by an admin" do
+ it "sets the internal ID on the new issue" do
post api("/projects/#{project.id}/issues", admin),
- params: { title: 'new issue', iid: 9001 }
+ params: {title: "new issue", iid: 9001}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['iid']).to eq 9001
+ expect(json_response["iid"]).to eq 9001
end
end
- context 'by an owner' do
- it 'sets the internal ID on the new issue' do
+ context "by an owner" do
+ it "sets the internal ID on the new issue" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', iid: 9001 }
+ params: {title: "new issue", iid: 9001}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['iid']).to eq 9001
+ expect(json_response["iid"]).to eq 9001
end
end
- context 'by a group owner' do
+ context "by a group owner" do
let(:group) { create(:group) }
let(:group_project) { create(:project, :public, namespace: group) }
- it 'sets the internal ID on the new issue' do
+ it "sets the internal ID on the new issue" do
group.add_owner(user2)
post api("/projects/#{group_project.id}/issues", user2),
- params: { title: 'new issue', iid: 9001 }
+ params: {title: "new issue", iid: 9001}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['iid']).to eq 9001
+ expect(json_response["iid"]).to eq 9001
end
end
- context 'by another user' do
- it 'ignores the given internal ID' do
+ context "by another user" do
+ it "ignores the given internal ID" do
post api("/projects/#{project.id}/issues", user2),
- params: { title: 'new issue', iid: 9001 }
+ params: {title: "new issue", iid: 9001}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['iid']).not_to eq 9001
+ expect(json_response["iid"]).not_to eq 9001
end
end
end
- it 'creates a new project issue' do
+ it "creates a new project issue" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', labels: 'label, label2', weight: 3, assignee_ids: [user2.id] }
+ params: {title: "new issue", labels: "label, label2", weight: 3, assignee_ids: [user2.id]}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['description']).to be_nil
- expect(json_response['labels']).to eq(%w(label label2))
- expect(json_response['confidential']).to be_falsy
- expect(json_response['assignee']['name']).to eq(user2.name)
- expect(json_response['assignees'].first['name']).to eq(user2.name)
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["description"]).to be_nil
+ expect(json_response["labels"]).to eq(%w[label label2])
+ expect(json_response["confidential"]).to be_falsy
+ expect(json_response["assignee"]["name"]).to eq(user2.name)
+ expect(json_response["assignees"].first["name"]).to eq(user2.name)
end
- it 'creates a new confidential project issue' do
+ it "creates a new confidential project issue" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', confidential: true }
+ params: {title: "new issue", confidential: true}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['confidential']).to be_truthy
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["confidential"]).to be_truthy
end
- it 'creates a new confidential project issue with a different param' do
+ it "creates a new confidential project issue with a different param" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', confidential: 'y' }
+ params: {title: "new issue", confidential: "y"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['confidential']).to be_truthy
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["confidential"]).to be_truthy
end
- it 'creates a public issue when confidential param is false' do
+ it "creates a public issue when confidential param is false" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', confidential: false }
+ params: {title: "new issue", confidential: false}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['confidential']).to be_falsy
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["confidential"]).to be_falsy
end
- it 'creates a public issue when confidential param is invalid' do
+ it "creates a public issue when confidential param is invalid" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', confidential: 'foo' }
+ params: {title: "new issue", confidential: "foo"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('confidential is invalid')
+ expect(json_response["error"]).to eq("confidential is invalid")
end
it "returns a 400 bad request if title not given" do
- post api("/projects/#{project.id}/issues", user), params: { labels: 'label, label2' }
+ post api("/projects/#{project.id}/issues", user), params: {labels: "label, label2"}
expect(response).to have_gitlab_http_status(400)
end
- it 'allows special label names' do
+ it "allows special label names" do
post api("/projects/#{project.id}/issues", user),
- params: {
- title: 'new issue',
- labels: 'label, label?, label&foo, ?, &'
- }
+ params: {
+ title: "new issue",
+ labels: "label, label?, label&foo, ?, &",
+ }
expect(response.status).to eq(201)
- expect(json_response['labels']).to include 'label'
- expect(json_response['labels']).to include 'label?'
- expect(json_response['labels']).to include 'label&foo'
- expect(json_response['labels']).to include '?'
- expect(json_response['labels']).to include '&'
+ expect(json_response["labels"]).to include "label"
+ expect(json_response["labels"]).to include "label?"
+ expect(json_response["labels"]).to include "label&foo"
+ expect(json_response["labels"]).to include "?"
+ expect(json_response["labels"]).to include "&"
end
- it 'returns 400 if title is too long' do
+ it "returns 400 if title is too long" do
post api("/projects/#{project.id}/issues", user),
- params: { title: 'g' * 256 }
+ params: {title: "g" * 256}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['title']).to eq([
- 'is too long (maximum is 255 characters)'
+ expect(json_response["message"]["title"]).to eq([
+ "is too long (maximum is 255 characters)",
])
end
- context 'resolving discussions' do
+ context "resolving discussions" do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
@@ -1287,100 +1287,100 @@ describe API::Issues do
project.add_maintainer(user)
end
- context 'resolving all discussions in a merge request' do
+ context "resolving all discussions in a merge request" do
before do
post api("/projects/#{project.id}/issues", user),
- params: {
- title: 'New Issue',
- merge_request_to_resolve_discussions_of: merge_request.iid
- }
+ params: {
+ title: "New Issue",
+ merge_request_to_resolve_discussions_of: merge_request.iid,
+ }
end
- it_behaves_like 'creating an issue resolving discussions through the API'
+ it_behaves_like "creating an issue resolving discussions through the API"
end
- context 'resolving a single discussion' do
+ context "resolving a single discussion" do
before do
post api("/projects/#{project.id}/issues", user),
- params: {
- title: 'New Issue',
- merge_request_to_resolve_discussions_of: merge_request.iid,
- discussion_to_resolve: discussion.id
- }
+ params: {
+ title: "New Issue",
+ merge_request_to_resolve_discussions_of: merge_request.iid,
+ discussion_to_resolve: discussion.id,
+ }
end
- it_behaves_like 'creating an issue resolving discussions through the API'
+ it_behaves_like "creating an issue resolving discussions through the API"
end
end
- context 'with due date' do
- it 'creates a new project issue' do
- due_date = 2.weeks.from_now.strftime('%Y-%m-%d')
+ context "with due date" do
+ it "creates a new project issue" do
+ due_date = 2.weeks.from_now.strftime("%Y-%m-%d")
post api("/projects/#{project.id}/issues", user),
- params: { title: 'new issue', due_date: due_date }
+ params: {title: "new issue", due_date: due_date}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new issue')
- expect(json_response['description']).to be_nil
- expect(json_response['due_date']).to eq(due_date)
+ expect(json_response["title"]).to eq("new issue")
+ expect(json_response["description"]).to be_nil
+ expect(json_response["due_date"]).to eq(due_date)
end
end
- context 'setting created_at' do
+ context "setting created_at" do
let(:creation_time) { 2.weeks.ago }
- let(:params) { { title: 'new issue', labels: 'label, label2', created_at: creation_time } }
+ let(:params) { {title: "new issue", labels: "label, label2", created_at: creation_time} }
- context 'by an admin' do
- it 'sets the creation time on the new issue' do
+ context "by an admin" do
+ it "sets the creation time on the new issue" do
post api("/projects/#{project.id}/issues", admin), params: params
expect(response).to have_gitlab_http_status(201)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
end
end
- context 'by a project owner' do
- it 'sets the creation time on the new issue' do
+ context "by a project owner" do
+ it "sets the creation time on the new issue" do
post api("/projects/#{project.id}/issues", user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
end
end
- context 'by a group owner' do
- it 'sets the creation time on the new issue' do
+ context "by a group owner" do
+ it "sets the creation time on the new issue" do
group = create(:group)
group_project = create(:project, :public, namespace: group)
group.add_owner(user2)
post api("/projects/#{group_project.id}/issues", user2), params: params
expect(response).to have_gitlab_http_status(201)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
end
end
- context 'by another user' do
- it 'ignores the given creation time' do
+ context "by another user" do
+ it "ignores the given creation time" do
post api("/projects/#{project.id}/issues", user2), params: params
expect(response).to have_gitlab_http_status(201)
- expect(Time.parse(json_response['created_at'])).not_to be_like_time(creation_time)
+ expect(Time.parse(json_response["created_at"])).not_to be_like_time(creation_time)
end
end
end
- context 'the user can only read the issue' do
- it 'cannot create new labels' do
- expect do
- post api("/projects/#{project.id}/issues", non_member), params: { title: 'new issue', labels: 'label, label2' }
- end.not_to change { project.labels.count }
+ context "the user can only read the issue" do
+ it "cannot create new labels" do
+ expect {
+ post api("/projects/#{project.id}/issues", non_member), params: {title: "new issue", labels: "label, label2"}
+ }.not_to change { project.labels.count }
end
end
end
- describe 'POST /projects/:id/issues with spam filtering' do
+ describe "POST /projects/:id/issues with spam filtering" do
before do
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
allow_any_instance_of(AkismetService).to receive_messages(spam?: true)
@@ -1388,128 +1388,128 @@ describe API::Issues do
let(:params) do
{
- title: 'new issue',
- description: 'content here',
- labels: 'label, label2'
+ title: "new issue",
+ description: "content here",
+ labels: "label, label2",
}
end
it "does not create a new project issue" do
expect { post api("/projects/#{project.id}/issues", user), params: params }.not_to change(Issue, :count)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
spam_logs = SpamLog.all
expect(spam_logs.count).to eq(1)
- expect(spam_logs[0].title).to eq('new issue')
- expect(spam_logs[0].description).to eq('content here')
+ expect(spam_logs[0].title).to eq("new issue")
+ expect(spam_logs[0].description).to eq("content here")
expect(spam_logs[0].user).to eq(user)
- expect(spam_logs[0].noteable_type).to eq('Issue')
+ expect(spam_logs[0].noteable_type).to eq("Issue")
end
end
describe "PUT /projects/:id/issues/:issue_iid to update only title" do
it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('updated title')
+ expect(json_response["title"]).to eq("updated title")
end
it "returns 404 error if issue iid not found" do
put api("/projects/#{project.id}/issues/44444", user),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(404)
end
it "returns 404 error if issue id is used instead of the iid" do
put api("/projects/#{project.id}/issues/#{issue.id}", user),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(404)
end
- it 'allows special label names' do
+ it "allows special label names" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: {
- title: 'updated title',
- labels: 'label, label?, label&foo, ?, &'
- }
+ params: {
+ title: "updated title",
+ labels: "label, label?, label&foo, ?, &",
+ }
expect(response.status).to eq(200)
- expect(json_response['labels']).to include 'label'
- expect(json_response['labels']).to include 'label?'
- expect(json_response['labels']).to include 'label&foo'
- expect(json_response['labels']).to include '?'
- expect(json_response['labels']).to include '&'
+ expect(json_response["labels"]).to include "label"
+ expect(json_response["labels"]).to include "label?"
+ expect(json_response["labels"]).to include "label&foo"
+ expect(json_response["labels"]).to include "?"
+ expect(json_response["labels"]).to include "&"
end
- context 'confidential issues' do
+ context "confidential issues" do
it "returns 403 for non project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", non_member),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(403)
end
it "returns 403 for project members with guest role" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", guest),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(403)
end
it "updates a confidential issue for project members" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('updated title')
+ expect(json_response["title"]).to eq("updated title")
end
it "updates a confidential issue for author" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", author),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('updated title')
+ expect(json_response["title"]).to eq("updated title")
end
it "updates a confidential issue for admin" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", admin),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('updated title')
+ expect(json_response["title"]).to eq("updated title")
end
- it 'sets an issue to confidential' do
+ it "sets an issue to confidential" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { confidential: true }
+ params: {confidential: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['confidential']).to be_truthy
+ expect(json_response["confidential"]).to be_truthy
end
- it 'makes a confidential issue public' do
+ it "makes a confidential issue public" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user),
- params: { confidential: false }
+ params: {confidential: false}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['confidential']).to be_falsy
+ expect(json_response["confidential"]).to be_falsy
end
- it 'does not update a confidential issue with wrong confidential flag' do
+ it "does not update a confidential issue with wrong confidential flag" do
put api("/projects/#{project.id}/issues/#{confidential_issue.iid}", user),
- params: { confidential: 'foo' }
+ params: {confidential: "foo"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('confidential is invalid')
+ expect(json_response["error"]).to eq("confidential is invalid")
end
end
end
- describe 'PUT /projects/:id/issues/:issue_iid with spam filtering' do
+ describe "PUT /projects/:id/issues/:issue_iid with spam filtering" do
let(:params) do
{
- title: 'updated title',
- description: 'content here',
- labels: 'label, label2'
+ title: "updated title",
+ description: "content here",
+ labels: "label, label2",
}
end
@@ -1520,120 +1520,120 @@ describe API::Issues do
put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: params
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
spam_logs = SpamLog.all
expect(spam_logs.count).to eq(1)
- expect(spam_logs[0].title).to eq('updated title')
- expect(spam_logs[0].description).to eq('content here')
+ expect(spam_logs[0].title).to eq("updated title")
+ expect(spam_logs[0].description).to eq("content here")
expect(spam_logs[0].user).to eq(user)
- expect(spam_logs[0].noteable_type).to eq('Issue')
+ expect(spam_logs[0].noteable_type).to eq("Issue")
end
end
- describe 'PUT /projects/:id/issues/:issue_iid to update assignee' do
- context 'support for deprecated assignee_id' do
- it 'removes assignee' do
+ describe "PUT /projects/:id/issues/:issue_iid to update assignee" do
+ context "support for deprecated assignee_id" do
+ it "removes assignee" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { assignee_id: 0 }
+ params: {assignee_id: 0}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['assignee']).to be_nil
+ expect(json_response["assignee"]).to be_nil
end
- it 'updates an issue with new assignee' do
+ it "updates an issue with new assignee" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { assignee_id: user2.id }
+ params: {assignee_id: user2.id}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['assignee']['name']).to eq(user2.name)
+ expect(json_response["assignee"]["name"]).to eq(user2.name)
end
end
- it 'removes assignee' do
+ it "removes assignee" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { assignee_ids: [0] }
+ params: {assignee_ids: [0]}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['assignees']).to be_empty
+ expect(json_response["assignees"]).to be_empty
end
- it 'updates an issue with new assignee' do
+ it "updates an issue with new assignee" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { assignee_ids: [user2.id] }
+ params: {assignee_ids: [user2.id]}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['assignees'].first['name']).to eq(user2.name)
+ expect(json_response["assignees"].first["name"]).to eq(user2.name)
end
- context 'single assignee restrictions' do
- it 'updates an issue with several assignees but only one has been applied' do
+ context "single assignee restrictions" do
+ it "updates an issue with several assignees but only one has been applied" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { assignee_ids: [user2.id, guest.id] }
+ params: {assignee_ids: [user2.id, guest.id]}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['assignees'].size).to eq(1)
+ expect(json_response["assignees"].size).to eq(1)
end
end
end
- describe 'PUT /projects/:id/issues/:issue_iid to update labels' do
- let!(:label) { create(:label, title: 'dummy', project: project) }
+ describe "PUT /projects/:id/issues/:issue_iid to update labels" do
+ let!(:label) { create(:label, title: "dummy", project: project) }
let!(:label_link) { create(:label_link, label: label, target: issue) }
- it 'does not update labels if not present' do
+ it "does not update labels if not present" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { title: 'updated title' }
+ params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['labels']).to eq([label.title])
+ expect(json_response["labels"]).to eq([label.title])
end
- it 'removes all labels and touches the record' do
+ it "removes all labels and touches the record" do
Timecop.travel(1.minute.from_now) do
- put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { labels: '' }
+ put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: {labels: ""}
end
expect(response).to have_gitlab_http_status(200)
- expect(json_response['labels']).to eq([])
- expect(json_response['updated_at']).to be > Time.now
+ expect(json_response["labels"]).to eq([])
+ expect(json_response["updated_at"]).to be > Time.now
end
- it 'updates labels and touches the record' do
+ it "updates labels and touches the record" do
Timecop.travel(1.minute.from_now) do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { labels: 'foo,bar' }
+ params: {labels: "foo,bar"}
end
expect(response).to have_gitlab_http_status(200)
- expect(json_response['labels']).to include 'foo'
- expect(json_response['labels']).to include 'bar'
- expect(json_response['updated_at']).to be > Time.now
+ expect(json_response["labels"]).to include "foo"
+ expect(json_response["labels"]).to include "bar"
+ expect(json_response["updated_at"]).to be > Time.now
end
- it 'allows special label names' do
+ it "allows special label names" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { labels: 'label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&' }
+ params: {labels: "label:foo, label-bar,label_bar,label/bar,label?bar,label&bar,?,&"}
expect(response.status).to eq(200)
- expect(json_response['labels']).to include 'label:foo'
- expect(json_response['labels']).to include 'label-bar'
- expect(json_response['labels']).to include 'label_bar'
- expect(json_response['labels']).to include 'label/bar'
- expect(json_response['labels']).to include 'label?bar'
- expect(json_response['labels']).to include 'label&bar'
- expect(json_response['labels']).to include '?'
- expect(json_response['labels']).to include '&'
+ expect(json_response["labels"]).to include "label:foo"
+ expect(json_response["labels"]).to include "label-bar"
+ expect(json_response["labels"]).to include "label_bar"
+ expect(json_response["labels"]).to include "label/bar"
+ expect(json_response["labels"]).to include "label?bar"
+ expect(json_response["labels"]).to include "label&bar"
+ expect(json_response["labels"]).to include "?"
+ expect(json_response["labels"]).to include "&"
end
- it 'returns 400 if title is too long' do
+ it "returns 400 if title is too long" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { title: 'g' * 256 }
+ params: {title: "g" * 256}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['title']).to eq([
- 'is too long (maximum is 255 characters)'
+ expect(json_response["message"]["title"]).to eq([
+ "is too long (maximum is 255 characters)",
])
end
end
@@ -1641,41 +1641,41 @@ describe API::Issues do
describe "PUT /projects/:id/issues/:issue_iid to update state and label" do
it "updates a project issue" do
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { labels: 'label2', state_event: "close" }
+ params: {labels: "label2", state_event: "close"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['labels']).to include 'label2'
- expect(json_response['state']).to eq "closed"
+ expect(json_response["labels"]).to include "label2"
+ expect(json_response["state"]).to eq "closed"
end
- it 'reopens a project isssue' do
- put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), params: { state_event: 'reopen' }
+ it "reopens a project isssue" do
+ put api("/projects/#{project.id}/issues/#{closed_issue.iid}", user), params: {state_event: "reopen"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['state']).to eq 'opened'
+ expect(json_response["state"]).to eq "opened"
end
- context 'when an admin or owner makes the request' do
- it 'accepts the update date to be set' do
+ context "when an admin or owner makes the request" do
+ it "accepts the update date to be set" do
update_time = 2.weeks.ago
put api("/projects/#{project.id}/issues/#{issue.iid}", user),
- params: { labels: 'label3', state_event: 'close', updated_at: update_time }
+ params: {labels: "label3", state_event: "close", updated_at: update_time}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['labels']).to include 'label3'
- expect(Time.parse(json_response['updated_at'])).to be_like_time(update_time)
+ expect(json_response["labels"]).to include "label3"
+ expect(Time.parse(json_response["updated_at"])).to be_like_time(update_time)
end
end
end
- describe 'PUT /projects/:id/issues/:issue_iid to update due date' do
- it 'creates a new project issue' do
- due_date = 2.weeks.from_now.strftime('%Y-%m-%d')
+ describe "PUT /projects/:id/issues/:issue_iid to update due date" do
+ it "creates a new project issue" do
+ due_date = 2.weeks.from_now.strftime("%Y-%m-%d")
- put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: { due_date: due_date }
+ put api("/projects/#{project.id}/issues/#{issue.iid}", user), params: {due_date: due_date}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['due_date']).to eq(due_date)
+ expect(json_response["due_date"]).to eq(due_date)
end
end
@@ -1700,208 +1700,208 @@ describe API::Issues do
expect(response).to have_gitlab_http_status(204)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/issues/#{issue.iid}", owner) }
end
end
- context 'when issue does not exist' do
- it 'returns 404 when trying to move an issue' do
+ context "when issue does not exist" do
+ it "returns 404 when trying to move an issue" do
delete api("/projects/#{project.id}/issues/123", user)
expect(response).to have_gitlab_http_status(404)
end
end
- it 'returns 404 when using the issue ID instead of IID' do
+ it "returns 404 when using the issue ID instead of IID" do
delete api("/projects/#{project.id}/issues/#{issue.id}", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe '/projects/:id/issues/:issue_iid/move' do
- let!(:target_project) { create(:project, creator_id: user.id, namespace: user.namespace ) }
- let!(:target_project2) { create(:project, creator_id: non_member.id, namespace: non_member.namespace ) }
+ describe "/projects/:id/issues/:issue_iid/move" do
+ let!(:target_project) { create(:project, creator_id: user.id, namespace: user.namespace) }
+ let!(:target_project2) { create(:project, creator_id: non_member.id, namespace: non_member.namespace) }
- it 'moves an issue' do
+ it "moves an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/move", user),
- params: { to_project_id: target_project.id }
+ params: {to_project_id: target_project.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['project_id']).to eq(target_project.id)
+ expect(json_response["project_id"]).to eq(target_project.id)
end
- context 'when source and target projects are the same' do
- it 'returns 400 when trying to move an issue' do
+ context "when source and target projects are the same" do
+ it "returns 400 when trying to move an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/move", user),
- params: { to_project_id: project.id }
+ params: {to_project_id: project.id}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Cannot move issue to project it originates from!')
+ expect(json_response["message"]).to eq("Cannot move issue to project it originates from!")
end
end
- context 'when the user does not have the permission to move issues' do
- it 'returns 400 when trying to move an issue' do
+ context "when the user does not have the permission to move issues" do
+ it "returns 400 when trying to move an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/move", user),
- params: { to_project_id: target_project2.id }
+ params: {to_project_id: target_project2.id}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!')
+ expect(json_response["message"]).to eq("Cannot move issue due to insufficient permissions!")
end
end
- it 'moves the issue to another namespace if I am admin' do
+ it "moves the issue to another namespace if I am admin" do
post api("/projects/#{project.id}/issues/#{issue.iid}/move", admin),
- params: { to_project_id: target_project2.id }
+ params: {to_project_id: target_project2.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['project_id']).to eq(target_project2.id)
+ expect(json_response["project_id"]).to eq(target_project2.id)
end
- context 'when using the issue ID instead of iid' do
- it 'returns 404 when trying to move an issue' do
+ context "when using the issue ID instead of iid" do
+ it "returns 404 when trying to move an issue" do
post api("/projects/#{project.id}/issues/#{issue.id}/move", user),
- params: { to_project_id: target_project.id }
+ params: {to_project_id: target_project.id}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Issue Not Found')
+ expect(json_response["message"]).to eq("404 Issue Not Found")
end
end
- context 'when issue does not exist' do
- it 'returns 404 when trying to move an issue' do
+ context "when issue does not exist" do
+ it "returns 404 when trying to move an issue" do
post api("/projects/#{project.id}/issues/123/move", user),
- params: { to_project_id: target_project.id }
+ params: {to_project_id: target_project.id}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Issue Not Found')
+ expect(json_response["message"]).to eq("404 Issue Not Found")
end
end
- context 'when source project does not exist' do
- it 'returns 404 when trying to move an issue' do
+ context "when source project does not exist" do
+ it "returns 404 when trying to move an issue" do
post api("/projects/0/issues/#{issue.iid}/move", user),
- params: { to_project_id: target_project.id }
+ params: {to_project_id: target_project.id}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
end
- context 'when target project does not exist' do
- it 'returns 404 when trying to move an issue' do
+ context "when target project does not exist" do
+ it "returns 404 when trying to move an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/move", user),
- params: { to_project_id: 0 }
+ params: {to_project_id: 0}
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'POST :id/issues/:issue_iid/subscribe' do
- it 'subscribes to an issue' do
+ describe "POST :id/issues/:issue_iid/subscribe" do
+ it "subscribes to an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user2)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['subscribed']).to eq(true)
+ expect(json_response["subscribed"]).to eq(true)
end
- it 'returns 304 if already subscribed' do
+ it "returns 304 if already subscribed" do
post api("/projects/#{project.id}/issues/#{issue.iid}/subscribe", user)
expect(response).to have_gitlab_http_status(304)
end
- it 'returns 404 if the issue is not found' do
+ it "returns 404 if the issue is not found" do
post api("/projects/#{project.id}/issues/123/subscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the issue ID is used instead of the iid' do
+ it "returns 404 if the issue ID is used instead of the iid" do
post api("/projects/#{project.id}/issues/#{issue.id}/subscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the issue is confidential' do
+ it "returns 404 if the issue is confidential" do
post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/subscribe", non_member)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'POST :id/issues/:issue_id/unsubscribe' do
- it 'unsubscribes from an issue' do
+ describe "POST :id/issues/:issue_id/unsubscribe" do
+ it "unsubscribes from an issue" do
post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['subscribed']).to eq(false)
+ expect(json_response["subscribed"]).to eq(false)
end
- it 'returns 304 if not subscribed' do
+ it "returns 304 if not subscribed" do
post api("/projects/#{project.id}/issues/#{issue.iid}/unsubscribe", user2)
expect(response).to have_gitlab_http_status(304)
end
- it 'returns 404 if the issue is not found' do
+ it "returns 404 if the issue is not found" do
post api("/projects/#{project.id}/issues/123/unsubscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if using the issue ID instead of iid' do
+ it "returns 404 if using the issue ID instead of iid" do
post api("/projects/#{project.id}/issues/#{issue.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the issue is confidential' do
+ it "returns 404 if the issue is confidential" do
post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/unsubscribe", non_member)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'time tracking endpoints' do
+ describe "time tracking endpoints" do
let(:issuable) { issue }
- include_examples 'time tracking endpoints', 'issue'
+ include_examples "time tracking endpoints", "issue"
end
- describe 'GET :id/issues/:issue_iid/closed_by' do
+ describe "GET :id/issues/:issue_iid/closed_by" do
let(:merge_request) do
create(:merge_request,
- :simple,
- author: user,
- source_project: project,
- target_project: project,
- description: "closes #{issue.to_reference}")
+ :simple,
+ author: user,
+ source_project: project,
+ target_project: project,
+ description: "closes #{issue.to_reference}")
end
before do
create(:merge_requests_closing_issues, issue: issue, merge_request: merge_request)
end
- context 'when unauthenticated' do
- it 'return public project issues' do
+ context "when unauthenticated" do
+ it "return public project issues" do
get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by")
expect_paginated_array_response(merge_request.id)
end
end
- it 'returns merge requests that will close issue on merge' do
+ it "returns merge requests that will close issue on merge" do
get api("/projects/#{project.id}/issues/#{issue.iid}/closed_by", user)
expect_paginated_array_response(merge_request.id)
end
- context 'when no merge requests will close issue' do
- it 'returns empty array' do
+ context "when no merge requests will close issue" do
+ it "returns empty array" do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}/closed_by", user)
expect_paginated_array_response([])
@@ -1915,7 +1915,7 @@ describe API::Issues do
end
end
- describe 'GET :id/issues/:issue_iid/related_merge_requests' do
+ describe "GET :id/issues/:issue_iid/related_merge_requests" do
def get_related_merge_requests(project_id, issue_iid, user = nil)
get api("/projects/#{project_id}/issues/#{issue_iid}/related_merge_requests", user)
end
@@ -1927,7 +1927,7 @@ describe API::Issues do
target_project: project,
source_branch: "master",
target_branch: "test",
- description: "See #{issue.to_reference}"
+ description: "See #{issue.to_reference}",
}
create(:merge_request, attributes).tap do |merge_request|
create(:note, :system, project: issue.project, noteable: issue, author: user, note: merge_request.to_reference(full: true))
@@ -1936,14 +1936,14 @@ describe API::Issues do
let!(:related_mr) { create_referencing_mr(user, project, issue) }
- context 'when unauthenticated' do
- it 'return list of referenced merge requests from issue' do
+ context "when unauthenticated" do
+ it "return list of referenced merge requests from issue" do
get_related_merge_requests(project.id, issue.iid)
expect_paginated_array_response(related_mr.id)
end
- it 'renders 404 if project is not visible' do
+ it "renders 404 if project is not visible" do
private_project = create(:project, :private)
private_issue = create(:issue, project: private_project)
create_referencing_mr(user, private_project, private_issue)
@@ -1954,20 +1954,20 @@ describe API::Issues do
end
end
- it 'returns merge requests that mentioned a issue' do
+ it "returns merge requests that mentioned a issue" do
create(:merge_request,
- :simple,
- author: user,
- source_project: project,
- target_project: project,
- description: "Some description")
+ :simple,
+ author: user,
+ source_project: project,
+ target_project: project,
+ description: "Some description")
get_related_merge_requests(project.id, issue.iid, user)
expect_paginated_array_response(related_mr.id)
end
- it 'returns merge requests cross-project wide' do
+ it "returns merge requests cross-project wide" do
project2 = create(:project, :public, creator_id: user.id, namespace: user.namespace)
merge_request = create_referencing_mr(user, project2, issue)
@@ -1976,7 +1976,7 @@ describe API::Issues do
expect_paginated_array_response([related_mr.id, merge_request.id])
end
- it 'does not generate references to projects with no access' do
+ it "does not generate references to projects with no access" do
private_project = create(:project, :private)
create_referencing_mr(private_project.creator, private_project, issue)
@@ -1985,8 +1985,8 @@ describe API::Issues do
expect_paginated_array_response(related_mr.id)
end
- context 'no merge request mentioned a issue' do
- it 'returns empty array' do
+ context "no merge request mentioned a issue" do
+ it "returns empty array" do
get_related_merge_requests(project.id, closed_issue.iid, user)
expect_paginated_array_response([])
@@ -2003,7 +2003,7 @@ describe API::Issues do
describe "GET /projects/:id/issues/:issue_iid/user_agent_detail" do
let!(:user_agent_detail) { create(:user_agent_detail, subject: issue) }
- context 'when unauthenticated' do
+ context "when unauthenticated" do
it "returns unauthorized" do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail")
@@ -2011,13 +2011,13 @@ describe API::Issues do
end
end
- it 'exposes known attributes' do
+ it "exposes known attributes" do
get api("/projects/#{project.id}/issues/#{issue.iid}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
- expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
- expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
+ expect(json_response["user_agent"]).to eq(user_agent_detail.user_agent)
+ expect(json_response["ip_address"]).to eq(user_agent_detail.ip_address)
+ expect(json_response["akismet_submitted"]).to eq(user_agent_detail.submitted)
end
it "returns unauthorized for non-admin users" do
@@ -2027,12 +2027,12 @@ describe API::Issues do
end
end
- describe 'GET projects/:id/issues/:issue_iid/participants' do
- it_behaves_like 'issuable participants endpoint' do
+ describe "GET projects/:id/issues/:issue_iid/participants" do
+ it_behaves_like "issuable participants endpoint" do
let(:entity) { issue }
end
- it 'returns 404 if the issue is confidential' do
+ it "returns 404 if the issue is confidential" do
post api("/projects/#{project.id}/issues/#{confidential_issue.iid}/participants", non_member)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/jobs_spec.rb b/spec/requests/api/jobs_spec.rb
index 3defe8bbf51..b7d9ac1bf6f 100644
--- a/spec/requests/api/jobs_spec.rb
+++ b/spec/requests/api/jobs_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Jobs do
include HttpIOHelpers
- shared_examples 'a job with artifacts and trace' do |result_is_array: true|
- context 'with artifacts and trace' do
+ shared_examples "a job with artifacts and trace" do |result_is_array: true|
+ context "with artifacts and trace" do
let!(:second_job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) }
- it 'returns artifacts and trace data', :skip_before_request do
+ it "returns artifacts and trace data", :skip_before_request do
get api(api_endpoint, api_user)
- json_job = result_is_array ? json_response.select { |job| job['id'] == second_job.id }.first : json_response
-
- expect(json_job['artifacts_file']).not_to be_nil
- expect(json_job['artifacts_file']).not_to be_empty
- expect(json_job['artifacts_file']['filename']).to eq(second_job.artifacts_file.filename)
- expect(json_job['artifacts_file']['size']).to eq(second_job.artifacts_file.size)
- expect(json_job['artifacts']).not_to be_nil
- expect(json_job['artifacts']).to be_an Array
- expect(json_job['artifacts'].size).to eq(second_job.job_artifacts.length)
- json_job['artifacts'].each do |artifact|
+ json_job = result_is_array ? json_response.select { |job| job["id"] == second_job.id }.first : json_response
+
+ expect(json_job["artifacts_file"]).not_to be_nil
+ expect(json_job["artifacts_file"]).not_to be_empty
+ expect(json_job["artifacts_file"]["filename"]).to eq(second_job.artifacts_file.filename)
+ expect(json_job["artifacts_file"]["size"]).to eq(second_job.artifacts_file.size)
+ expect(json_job["artifacts"]).not_to be_nil
+ expect(json_job["artifacts"]).to be_an Array
+ expect(json_job["artifacts"].size).to eq(second_job.job_artifacts.length)
+ json_job["artifacts"].each do |artifact|
expect(artifact).not_to be_nil
- file_type = Ci::JobArtifact.file_types[artifact['file_type']]
- expect(artifact['size']).to eq(second_job.job_artifacts.where(file_type: file_type).first.size)
- expect(artifact['filename']).to eq(second_job.job_artifacts.where(file_type: file_type).first.filename)
- expect(artifact['file_format']).to eq(second_job.job_artifacts.where(file_type: file_type).first.file_format)
+ file_type = Ci::JobArtifact.file_types[artifact["file_type"]]
+ expect(artifact["size"]).to eq(second_job.job_artifacts.where(file_type: file_type).first.size)
+ expect(artifact["filename"]).to eq(second_job.job_artifacts.where(file_type: file_type).first.filename)
+ expect(artifact["file_format"]).to eq(second_job.job_artifacts.where(file_type: file_type).first.file_format)
end
end
end
@@ -53,8 +53,8 @@ describe API::Jobs do
project.add_developer(user)
end
- describe 'GET /projects/:id/jobs' do
- let(:query) { Hash.new }
+ describe "GET /projects/:id/jobs" do
+ let(:query) { {} }
before do |example|
unless example.metadata[:skip_before_request]
@@ -62,44 +62,44 @@ describe API::Jobs do
end
end
- context 'authorized user' do
- it 'returns project jobs' do
+ context "authorized user" do
+ it "returns project jobs" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
end
- it 'returns correct values' do
+ it "returns correct values" do
expect(json_response).not_to be_empty
- expect(json_response.first['commit']['id']).to eq project.commit.id
- expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
+ expect(json_response.first["commit"]["id"]).to eq project.commit.id
+ expect(Time.parse(json_response.first["artifacts_expire_at"])).to be_like_time(job.artifacts_expire_at)
end
- context 'without artifacts and trace' do
- it 'returns no artifacts nor trace data' do
+ context "without artifacts and trace" do
+ it "returns no artifacts nor trace data" do
json_job = json_response.first
- expect(json_job['artifacts_file']).to be_nil
- expect(json_job['artifacts']).to be_an Array
- expect(json_job['artifacts']).to be_empty
+ expect(json_job["artifacts_file"]).to be_nil
+ expect(json_job["artifacts"]).to be_an Array
+ expect(json_job["artifacts"]).to be_empty
end
end
- it_behaves_like 'a job with artifacts and trace' do
+ it_behaves_like "a job with artifacts and trace" do
let(:api_endpoint) { "/projects/#{project.id}/jobs" }
end
- it 'returns pipeline data' do
+ it "returns pipeline data" do
json_job = json_response.first
- expect(json_job['pipeline']).not_to be_empty
- expect(json_job['pipeline']['id']).to eq job.pipeline.id
- expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
- expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
- expect(json_job['pipeline']['status']).to eq job.pipeline.status
+ expect(json_job["pipeline"]).not_to be_empty
+ expect(json_job["pipeline"]["id"]).to eq job.pipeline.id
+ expect(json_job["pipeline"]["ref"]).to eq job.pipeline.ref
+ expect(json_job["pipeline"]["sha"]).to eq job.pipeline.sha
+ expect(json_job["pipeline"]["status"]).to eq job.pipeline.status
end
- it 'avoids N+1 queries', :skip_before_request do
+ it "avoids N+1 queries", :skip_before_request do
first_build = create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline)
first_build.runner = create(:ci_runner)
first_build.user = create(:user)
@@ -116,8 +116,8 @@ describe API::Jobs do
expect { go }.not_to exceed_query_limit(control_count)
end
- context 'filter project with one scope element' do
- let(:query) { { 'scope' => 'pending' } }
+ context "filter project with one scope element" do
+ let(:query) { {"scope" => "pending"} }
it do
expect(response).to have_gitlab_http_status(200)
@@ -125,8 +125,8 @@ describe API::Jobs do
end
end
- context 'filter project with array of scope elements' do
- let(:query) { { scope: %w(pending running) } }
+ context "filter project with array of scope elements" do
+ let(:query) { {scope: %w[pending running]} }
it do
expect(response).to have_gitlab_http_status(200)
@@ -134,26 +134,26 @@ describe API::Jobs do
end
end
- context 'respond 400 when scope contains invalid state' do
- let(:query) { { scope: %w(unknown running) } }
+ context "respond 400 when scope contains invalid state" do
+ let(:query) { {scope: %w[unknown running]} }
it { expect(response).to have_gitlab_http_status(400) }
end
end
- context 'unauthorized user' do
- context 'when user is not logged in' do
+ context "unauthorized user" do
+ context "when user is not logged in" do
let(:api_user) { nil }
- it 'does not return project jobs' do
+ it "does not return project jobs" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when user is guest' do
+ context "when user is guest" do
let(:api_user) { guest }
- it 'does not return project jobs' do
+ it "does not return project jobs" do
expect(response).to have_gitlab_http_status(403)
end
end
@@ -164,8 +164,8 @@ describe API::Jobs do
end
end
- describe 'GET /projects/:id/pipelines/:pipeline_id/jobs' do
- let(:query) { Hash.new }
+ describe "GET /projects/:id/pipelines/:pipeline_id/jobs" do
+ let(:query) { {} }
before do |example|
unless example.metadata[:skip_before_request]
@@ -174,38 +174,38 @@ describe API::Jobs do
end
end
- context 'authorized user' do
- it 'returns pipeline jobs' do
+ context "authorized user" do
+ it "returns pipeline jobs" do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
end
- it 'returns correct values' do
+ it "returns correct values" do
expect(json_response).not_to be_empty
- expect(json_response.first['commit']['id']).to eq project.commit.id
- expect(Time.parse(json_response.first['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
- expect(json_response.first['artifacts_file']).to be_nil
- expect(json_response.first['artifacts']).to be_an Array
- expect(json_response.first['artifacts']).to be_empty
+ expect(json_response.first["commit"]["id"]).to eq project.commit.id
+ expect(Time.parse(json_response.first["artifacts_expire_at"])).to be_like_time(job.artifacts_expire_at)
+ expect(json_response.first["artifacts_file"]).to be_nil
+ expect(json_response.first["artifacts"]).to be_an Array
+ expect(json_response.first["artifacts"]).to be_empty
end
- it_behaves_like 'a job with artifacts and trace' do
+ it_behaves_like "a job with artifacts and trace" do
let(:api_endpoint) { "/projects/#{project.id}/pipelines/#{pipeline.id}/jobs" }
end
- it 'returns pipeline data' do
+ it "returns pipeline data" do
json_job = json_response.first
- expect(json_job['pipeline']).not_to be_empty
- expect(json_job['pipeline']['id']).to eq job.pipeline.id
- expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
- expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
- expect(json_job['pipeline']['status']).to eq job.pipeline.status
+ expect(json_job["pipeline"]).not_to be_empty
+ expect(json_job["pipeline"]["id"]).to eq job.pipeline.id
+ expect(json_job["pipeline"]["ref"]).to eq job.pipeline.ref
+ expect(json_job["pipeline"]["sha"]).to eq job.pipeline.sha
+ expect(json_job["pipeline"]["status"]).to eq job.pipeline.status
end
- context 'filter jobs with one scope element' do
- let(:query) { { 'scope' => 'pending' } }
+ context "filter jobs with one scope element" do
+ let(:query) { {"scope" => "pending"} }
it do
expect(response).to have_gitlab_http_status(200)
@@ -213,8 +213,8 @@ describe API::Jobs do
end
end
- context 'filter jobs with array of scope elements' do
- let(:query) { { scope: %w(pending running) } }
+ context "filter jobs with array of scope elements" do
+ let(:query) { {scope: %w[pending running]} }
it do
expect(response).to have_gitlab_http_status(200)
@@ -222,120 +222,120 @@ describe API::Jobs do
end
end
- context 'respond 400 when scope contains invalid state' do
- let(:query) { { scope: %w(unknown running) } }
+ context "respond 400 when scope contains invalid state" do
+ let(:query) { {scope: %w[unknown running]} }
it { expect(response).to have_gitlab_http_status(400) }
end
- context 'jobs in different pipelines' do
+ context "jobs in different pipelines" do
let!(:pipeline2) { create(:ci_empty_pipeline, project: project) }
let!(:job2) { create(:ci_build, pipeline: pipeline2) }
- it 'excludes jobs from other pipelines' do
- json_response.each { |job| expect(job['pipeline']['id']).to eq(pipeline.id) }
+ it "excludes jobs from other pipelines" do
+ json_response.each { |job| expect(job["pipeline"]["id"]).to eq(pipeline.id) }
end
end
- it 'avoids N+1 queries' do
- control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ it "avoids N+1 queries" do
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) {
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
- end.count
+ }.count
3.times { create(:ci_build, :trace_artifact, :artifacts, :test_reports, pipeline: pipeline) }
- expect do
+ expect {
get api("/projects/#{project.id}/pipelines/#{pipeline.id}/jobs", api_user), params: query
- end.not_to exceed_all_query_limit(control_count)
+ }.not_to exceed_all_query_limit(control_count)
end
end
- context 'unauthorized user' do
- context 'when user is not logged in' do
+ context "unauthorized user" do
+ context "when user is not logged in" do
let(:api_user) { nil }
- it 'does not return jobs' do
+ it "does not return jobs" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when user is guest' do
+ context "when user is guest" do
let(:api_user) { guest }
- it 'does not return jobs' do
+ it "does not return jobs" do
expect(response).to have_gitlab_http_status(403)
end
end
end
end
- describe 'GET /projects/:id/jobs/:job_id' do
+ describe "GET /projects/:id/jobs/:job_id" do
before do |example|
unless example.metadata[:skip_before_request]
get api("/projects/#{project.id}/jobs/#{job.id}", api_user)
end
end
- context 'authorized user' do
- it 'returns specific job data' do
+ context "authorized user" do
+ it "returns specific job data" do
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(job.id)
- expect(json_response['status']).to eq(job.status)
- expect(json_response['stage']).to eq(job.stage)
- expect(json_response['name']).to eq(job.name)
- expect(json_response['ref']).to eq(job.ref)
- expect(json_response['tag']).to eq(job.tag)
- expect(json_response['coverage']).to eq(job.coverage)
- expect(Time.parse(json_response['created_at'])).to be_like_time(job.created_at)
- expect(Time.parse(json_response['started_at'])).to be_like_time(job.started_at)
- expect(Time.parse(json_response['finished_at'])).to be_like_time(job.finished_at)
- expect(Time.parse(json_response['artifacts_expire_at'])).to be_like_time(job.artifacts_expire_at)
- expect(json_response['artifacts_file']).to be_nil
- expect(json_response['artifacts']).to be_an Array
- expect(json_response['artifacts']).to be_empty
- expect(json_response['duration']).to eq(job.duration)
- expect(json_response['web_url']).to be_present
- end
-
- it_behaves_like 'a job with artifacts and trace', result_is_array: false do
+ expect(json_response["id"]).to eq(job.id)
+ expect(json_response["status"]).to eq(job.status)
+ expect(json_response["stage"]).to eq(job.stage)
+ expect(json_response["name"]).to eq(job.name)
+ expect(json_response["ref"]).to eq(job.ref)
+ expect(json_response["tag"]).to eq(job.tag)
+ expect(json_response["coverage"]).to eq(job.coverage)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(job.created_at)
+ expect(Time.parse(json_response["started_at"])).to be_like_time(job.started_at)
+ expect(Time.parse(json_response["finished_at"])).to be_like_time(job.finished_at)
+ expect(Time.parse(json_response["artifacts_expire_at"])).to be_like_time(job.artifacts_expire_at)
+ expect(json_response["artifacts_file"]).to be_nil
+ expect(json_response["artifacts"]).to be_an Array
+ expect(json_response["artifacts"]).to be_empty
+ expect(json_response["duration"]).to eq(job.duration)
+ expect(json_response["web_url"]).to be_present
+ end
+
+ it_behaves_like "a job with artifacts and trace", result_is_array: false do
let(:api_endpoint) { "/projects/#{project.id}/jobs/#{second_job.id}" }
end
- it 'returns pipeline data' do
+ it "returns pipeline data" do
json_job = json_response
- expect(json_job['pipeline']).not_to be_empty
- expect(json_job['pipeline']['id']).to eq job.pipeline.id
- expect(json_job['pipeline']['ref']).to eq job.pipeline.ref
- expect(json_job['pipeline']['sha']).to eq job.pipeline.sha
- expect(json_job['pipeline']['status']).to eq job.pipeline.status
+ expect(json_job["pipeline"]).not_to be_empty
+ expect(json_job["pipeline"]["id"]).to eq job.pipeline.id
+ expect(json_job["pipeline"]["ref"]).to eq job.pipeline.ref
+ expect(json_job["pipeline"]["sha"]).to eq job.pipeline.sha
+ expect(json_job["pipeline"]["status"]).to eq job.pipeline.status
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not return specific job data' do
+ it "does not return specific job data" do
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'GET /projects/:id/jobs/:job_id/artifacts/:artifact_path' do
- context 'when job has artifacts' do
+ describe "GET /projects/:id/jobs/:job_id/artifacts/:artifact_path" do
+ context "when job has artifacts" do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
let(:artifact) do
- 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif'
+ "other_artifacts_0.1.2/another-subdirectory/banana_sample.gif"
end
- context 'when user is anonymous' do
+ context "when user is anonymous" do
let(:api_user) { nil }
- context 'when project is public' do
- it 'allows to access artifacts' do
+ context "when project is public" do
+ it "allows to access artifacts" do
project.update_column(:visibility_level,
- Gitlab::VisibilityLevel::PUBLIC)
+ Gitlab::VisibilityLevel::PUBLIC)
project.update_column(:public_builds, true)
get_artifact_file(artifact)
@@ -344,10 +344,10 @@ describe API::Jobs do
end
end
- context 'when project is public with builds access disabled' do
- it 'rejects access to artifacts' do
+ context "when project is public with builds access disabled" do
+ it "rejects access to artifacts" do
project.update_column(:visibility_level,
- Gitlab::VisibilityLevel::PUBLIC)
+ Gitlab::VisibilityLevel::PUBLIC)
project.update_column(:public_builds, false)
get_artifact_file(artifact)
@@ -356,10 +356,10 @@ describe API::Jobs do
end
end
- context 'when project is private' do
- it 'rejects access and hides existence of artifacts' do
+ context "when project is private" do
+ it "rejects access and hides existence of artifacts" do
project.update_column(:visibility_level,
- Gitlab::VisibilityLevel::PRIVATE)
+ Gitlab::VisibilityLevel::PRIVATE)
project.update_column(:public_builds, true)
get_artifact_file(artifact)
@@ -369,8 +369,8 @@ describe API::Jobs do
end
end
- context 'when user is authorized' do
- it 'returns a specific artifact file for a valid path' do
+ context "when user is authorized" do
+ it "returns a specific artifact file for a valid path" do
expect(Gitlab::Workhorse)
.to receive(:send_artifacts_entry)
.and_call_original
@@ -379,15 +379,15 @@ describe API::Jobs do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
- .to include('Content-Type' => 'application/json',
- 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .to include("Content-Type" => "application/json",
+ "Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
end
- context 'when job does not have artifacts' do
- it 'does not return job artifact file' do
- get_artifact_file('some/artifact')
+ context "when job does not have artifacts" do
+ it "does not return job artifact file" do
+ get_artifact_file("some/artifact")
expect(response).to have_gitlab_http_status(404)
end
@@ -399,43 +399,43 @@ describe API::Jobs do
end
end
- describe 'GET /projects/:id/jobs/:job_id/artifacts' do
- shared_examples 'downloads artifact' do
+ describe "GET /projects/:id/jobs/:job_id/artifacts" do
+ shared_examples "downloads artifact" do
let(:download_headers) do
- { 'Content-Transfer-Encoding' => 'binary',
- 'Content-Disposition' => %q(attachment; filename="ci_build_artifacts.zip"; filename*=UTF-8''ci_build_artifacts.zip) }
+ {"Content-Transfer-Encoding" => "binary",
+ "Content-Disposition" => %q(attachment; filename="ci_build_artifacts.zip"; filename*=UTF-8''ci_build_artifacts.zip),}
end
- it 'returns specific job artifacts' do
+ it "returns specific job artifacts" do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h).to include(download_headers)
expect(response.body).to match_file(job.artifacts_file.file.file)
end
end
- context 'normal authentication' do
- context 'job with artifacts' do
- context 'when artifacts are stored locally' do
+ context "normal authentication" do
+ context "job with artifacts" do
+ context "when artifacts are stored locally" do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) }
before do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
- context 'authorized user' do
- it_behaves_like 'downloads artifact'
+ context "authorized user" do
+ it_behaves_like "downloads artifact"
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not return specific job artifacts' do
+ it "does not return specific job artifacts" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when artifacts are stored remotely' do
+ context "when artifacts are stored remotely" do
let(:proxy_download) { false }
before do
@@ -451,36 +451,36 @@ describe API::Jobs do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
- context 'when proxy download is enabled' do
+ context "when proxy download is enabled" do
let(:proxy_download) { true }
- it 'responds with the workhorse send-url' do
+ it "responds with the workhorse send-url" do
expect(response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("send-url:")
end
end
- context 'when proxy download is disabled' do
- it 'returns location redirect' do
+ context "when proxy download is disabled" do
+ it "returns location redirect" do
expect(response).to have_gitlab_http_status(302)
end
end
- context 'authorized user' do
- it 'returns the file remote URL' do
+ context "authorized user" do
+ it "returns the file remote URL" do
expect(response).to redirect_to(artifact.file.url)
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not return specific job artifacts' do
+ it "does not return specific job artifacts" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- it 'does not return job artifacts if not uploaded' do
+ it "does not return job artifacts if not uploaded" do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
expect(response).to have_gitlab_http_status(:not_found)
@@ -489,7 +489,7 @@ describe API::Jobs do
end
end
- describe 'GET /projects/:id/artifacts/:ref_name/download?job=name' do
+ describe "GET /projects/:id/artifacts/:ref_name/download?job=name" do
let(:api_user) { reporter }
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
@@ -499,70 +499,70 @@ describe API::Jobs do
end
def get_for_ref(ref = pipeline.ref, job_name = job.name)
- get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), params: { job: job_name }
+ get api("/projects/#{project.id}/jobs/artifacts/#{ref}/download", api_user), params: {job: job_name}
end
- context 'when not logged in' do
+ context "when not logged in" do
let(:api_user) { nil }
before do
get_for_ref
end
- it 'does not find a resource in a private project' do
+ it "does not find a resource in a private project" do
expect(project).to be_private
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when logging as guest' do
+ context "when logging as guest" do
let(:api_user) { guest }
before do
get_for_ref
end
- it 'gives 403' do
+ it "gives 403" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'non-existing job' do
- shared_examples 'not found' do
+ context "non-existing job" do
+ shared_examples "not found" do
it { expect(response).to have_gitlab_http_status(:not_found) }
end
- context 'has no such ref' do
+ context "has no such ref" do
before do
- get_for_ref('TAIL')
+ get_for_ref("TAIL")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'has no such job' do
+ context "has no such job" do
before do
- get_for_ref(pipeline.ref, 'NOBUILD')
+ get_for_ref(pipeline.ref, "NOBUILD")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
- context 'find proper job' do
- shared_examples 'a valid file' do
- context 'when artifacts are stored locally' do
+ context "find proper job" do
+ shared_examples "a valid file" do
+ context "when artifacts are stored locally" do
let(:download_headers) do
- { 'Content-Transfer-Encoding' => 'binary',
- 'Content-Disposition' =>
- %Q(attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}) }
+ {"Content-Transfer-Encoding" => "binary",
+ "Content-Disposition" =>
+ %(attachment; filename="#{job.artifacts_file.filename}"; filename*=UTF-8''#{job.artifacts_file.filename}),}
end
it { expect(response).to have_http_status(:ok) }
it { expect(response.headers.to_h).to include(download_headers) }
end
- context 'when artifacts are stored remotely' do
+ context "when artifacts are stored remotely" do
let(:job) { create(:ci_build, pipeline: pipeline, user: api_user) }
let!(:artifact) { create(:ci_job_artifact, :archive, :remote_store, job: job) }
@@ -572,44 +572,44 @@ describe API::Jobs do
get api("/projects/#{project.id}/jobs/#{job.id}/artifacts", api_user)
end
- it 'returns location redirect' do
+ it "returns location redirect" do
expect(response).to have_http_status(:found)
end
end
end
- context 'with regular branch' do
+ context "with regular branch" do
before do
pipeline.reload
- pipeline.update(ref: 'master',
- sha: project.commit('master').sha)
+ pipeline.update(ref: "master",
+ sha: project.commit("master").sha)
- get_for_ref('master')
+ get_for_ref("master")
end
- it_behaves_like 'a valid file'
+ it_behaves_like "a valid file"
end
- context 'with branch name containing slash' do
+ context "with branch name containing slash" do
before do
pipeline.reload
- pipeline.update(ref: 'improve/awesome',
- sha: project.commit('improve/awesome').sha)
+ pipeline.update(ref: "improve/awesome",
+ sha: project.commit("improve/awesome").sha)
end
before do
- get_for_ref('improve/awesome')
+ get_for_ref("improve/awesome")
end
- it_behaves_like 'a valid file'
+ it_behaves_like "a valid file"
end
end
end
- describe 'GET id/jobs/artifacts/:ref_name/raw/*artifact_path?job=name' do
- context 'when job has artifacts' do
+ describe "GET id/jobs/artifacts/:ref_name/raw/*artifact_path?job=name" do
+ context "when job has artifacts" do
let(:job) { create(:ci_build, :artifacts, pipeline: pipeline, user: api_user) }
- let(:artifact) { 'other_artifacts_0.1.2/another-subdirectory/banana_sample.gif' }
+ let(:artifact) { "other_artifacts_0.1.2/another-subdirectory/banana_sample.gif" }
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { true }
@@ -623,129 +623,129 @@ describe API::Jobs do
get_artifact_file(artifact)
end
- context 'when user is anonymous' do
+ context "when user is anonymous" do
let(:api_user) { nil }
- context 'when project is public' do
+ context "when project is public" do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { true }
- it 'allows to access artifacts' do
+ it "allows to access artifacts" do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
- .to include('Content-Type' => 'application/json',
- 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .to include("Content-Type" => "application/json",
+ "Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
- context 'when project is public with builds access disabled' do
+ context "when project is public with builds access disabled" do
let(:visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
let(:public_builds) { false }
- it 'rejects access to artifacts' do
+ it "rejects access to artifacts" do
expect(response).to have_gitlab_http_status(403)
- expect(json_response).to have_key('message')
+ expect(json_response).to have_key("message")
expect(response.headers.to_h)
- .not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .not_to include("Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
- context 'when project is private' do
+ context "when project is private" do
let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
let(:public_builds) { true }
- it 'rejects access and hides existence of artifacts' do
+ it "rejects access and hides existence of artifacts" do
expect(response).to have_gitlab_http_status(404)
- expect(json_response).to have_key('message')
+ expect(json_response).to have_key("message")
expect(response.headers.to_h)
- .not_to include('Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .not_to include("Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
end
- context 'when user is authorized' do
+ context "when user is authorized" do
let(:visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
let(:public_builds) { true }
- it 'returns a specific artifact file for a valid path' do
+ it "returns a specific artifact file for a valid path" do
expect(Gitlab::Workhorse)
.to receive(:send_artifacts_entry)
- .and_call_original
+ .and_call_original
get_artifact_file(artifact)
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
- .to include('Content-Type' => 'application/json',
- 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .to include("Content-Type" => "application/json",
+ "Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
- context 'with branch name containing slash' do
+ context "with branch name containing slash" do
before do
pipeline.reload
- pipeline.update(ref: 'improve/awesome',
- sha: project.commit('improve/awesome').sha)
+ pipeline.update(ref: "improve/awesome",
+ sha: project.commit("improve/awesome").sha)
end
- it 'returns a specific artifact file for a valid path' do
- get_artifact_file(artifact, 'improve/awesome')
+ it "returns a specific artifact file for a valid path" do
+ get_artifact_file(artifact, "improve/awesome")
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h)
- .to include('Content-Type' => 'application/json',
- 'Gitlab-Workhorse-Send-Data' => /artifacts-entry/)
+ .to include("Content-Type" => "application/json",
+ "Gitlab-Workhorse-Send-Data" => /artifacts-entry/)
end
end
- context 'non-existing job' do
- shared_examples 'not found' do
+ context "non-existing job" do
+ shared_examples "not found" do
it { expect(response).to have_gitlab_http_status(:not_found) }
end
- context 'has no such ref' do
+ context "has no such ref" do
before do
- get_artifact_file('some/artifact', 'wrong-ref')
+ get_artifact_file("some/artifact", "wrong-ref")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
- context 'has no such job' do
+ context "has no such job" do
before do
- get_artifact_file('some/artifact', pipeline.ref, 'wrong-job-name')
+ get_artifact_file("some/artifact", pipeline.ref, "wrong-job-name")
end
- it_behaves_like 'not found'
+ it_behaves_like "not found"
end
end
end
- context 'when job does not have artifacts' do
+ context "when job does not have artifacts" do
let(:job) { create(:ci_build, pipeline: pipeline, user: api_user) }
- it 'does not return job artifact file' do
- get_artifact_file('some/artifact')
+ it "does not return job artifact file" do
+ get_artifact_file("some/artifact")
expect(response).to have_gitlab_http_status(404)
end
end
def get_artifact_file(artifact_path, ref = pipeline.ref, job_name = job.name)
- get api("/projects/#{project.id}/jobs/artifacts/#{ref}/raw/#{artifact_path}", api_user), params: { job: job_name }
+ get api("/projects/#{project.id}/jobs/artifacts/#{ref}/raw/#{artifact_path}", api_user), params: {job: job_name}
end
end
- describe 'GET /projects/:id/jobs/:job_id/trace' do
+ describe "GET /projects/:id/jobs/:job_id/trace" do
before do
get api("/projects/#{project.id}/jobs/#{job.id}/trace", api_user)
end
- context 'authorized user' do
- context 'when trace is in ObjectStorage' do
+ context "authorized user" do
+ context "when trace is in ObjectStorage" do
let!(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
- let(:url) { 'http://object-storage/trace' }
- let(:file_path) { expand_fixture_path('trace/sample_trace') }
+ let(:url) { "http://object-storage/trace" }
+ let(:file_path) { expand_fixture_path("trace/sample_trace") }
before do
stub_remote_url_206(url, file_path)
@@ -754,106 +754,106 @@ describe API::Jobs do
allow_any_instance_of(JobArtifactUploader).to receive(:size) { File.size(file_path) }
end
- it 'returns specific job trace' do
+ it "returns specific job trace" do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
- context 'when trace is artifact' do
+ context "when trace is artifact" do
let(:job) { create(:ci_build, :trace_artifact, pipeline: pipeline) }
- it 'returns specific job trace' do
+ it "returns specific job trace" do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
- context 'when trace is file' do
+ context "when trace is file" do
let(:job) { create(:ci_build, :trace_live, pipeline: pipeline) }
- it 'returns specific job trace' do
+ it "returns specific job trace" do
expect(response).to have_gitlab_http_status(200)
expect(response.body).to eq(job.trace.raw)
end
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not return specific job trace' do
+ it "does not return specific job trace" do
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'POST /projects/:id/jobs/:job_id/cancel' do
+ describe "POST /projects/:id/jobs/:job_id/cancel" do
before do
post api("/projects/#{project.id}/jobs/#{job.id}/cancel", api_user)
end
- context 'authorized user' do
- context 'user with :update_build persmission' do
- it 'cancels running or pending job' do
+ context "authorized user" do
+ context "user with :update_build persmission" do
+ it "cancels running or pending job" do
expect(response).to have_gitlab_http_status(201)
- expect(project.builds.first.status).to eq('success')
+ expect(project.builds.first.status).to eq("success")
end
end
- context 'user without :update_build permission' do
+ context "user without :update_build permission" do
let(:api_user) { reporter }
- it 'does not cancel job' do
+ it "does not cancel job" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not cancel job' do
+ it "does not cancel job" do
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'POST /projects/:id/jobs/:job_id/retry' do
+ describe "POST /projects/:id/jobs/:job_id/retry" do
let(:job) { create(:ci_build, :canceled, pipeline: pipeline) }
before do
post api("/projects/#{project.id}/jobs/#{job.id}/retry", api_user)
end
- context 'authorized user' do
- context 'user with :update_build permission' do
- it 'retries non-running job' do
+ context "authorized user" do
+ context "user with :update_build permission" do
+ it "retries non-running job" do
expect(response).to have_gitlab_http_status(201)
- expect(project.builds.first.status).to eq('canceled')
- expect(json_response['status']).to eq('pending')
+ expect(project.builds.first.status).to eq("canceled")
+ expect(json_response["status"]).to eq("pending")
end
end
- context 'user without :update_build permission' do
+ context "user without :update_build permission" do
let(:api_user) { reporter }
- it 'does not retry job' do
+ it "does not retry job" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
let(:api_user) { nil }
- it 'does not retry job' do
+ it "does not retry job" do
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'POST /projects/:id/jobs/:job_id/erase' do
+ describe "POST /projects/:id/jobs/:job_id/erase" do
let(:role) { :maintainer }
before do
@@ -862,10 +862,10 @@ describe API::Jobs do
post api("/projects/#{project.id}/jobs/#{job.id}/erase", user)
end
- context 'job is erasable' do
+ context "job is erasable" do
let(:job) { create(:ci_build, :trace_artifact, :artifacts, :test_reports, :success, project: project, pipeline: pipeline) }
- it 'erases job content' do
+ it "erases job content" do
expect(response).to have_gitlab_http_status(201)
expect(job.job_artifacts.count).to eq(0)
expect(job.trace.exist?).to be_falsy
@@ -874,7 +874,7 @@ describe API::Jobs do
expect(job.has_job_artifacts?).to be_falsy
end
- it 'updates job' do
+ it "updates job" do
job.reload
expect(job.erased_at).to be_truthy
@@ -882,25 +882,25 @@ describe API::Jobs do
end
end
- context 'job is not erasable' do
+ context "job is not erasable" do
let(:job) { create(:ci_build, :trace_live, project: project, pipeline: pipeline) }
- it 'responds with forbidden' do
+ it "responds with forbidden" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when a developer erases a build' do
+ context "when a developer erases a build" do
let(:role) { :developer }
let(:job) { create(:ci_build, :trace_artifact, :artifacts, :success, project: project, pipeline: pipeline, user: owner) }
- context 'when the build was created by the developer' do
+ context "when the build was created by the developer" do
let(:owner) { user }
it { expect(response).to have_gitlab_http_status(201) }
end
- context 'when the build was created by the other' do
+ context "when the build was created by the other" do
let(:owner) { create(:user) }
it { expect(response).to have_gitlab_http_status(403) }
@@ -908,63 +908,63 @@ describe API::Jobs do
end
end
- describe 'POST /projects/:id/jobs/:job_id/artifacts/keep' do
+ describe "POST /projects/:id/jobs/:job_id/artifacts/keep" do
before do
post api("/projects/#{project.id}/jobs/#{job.id}/artifacts/keep", user)
end
- context 'artifacts did not expire' do
+ context "artifacts did not expire" do
let(:job) do
create(:ci_build, :trace_artifact, :artifacts, :success,
- project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days)
+ project: project, pipeline: pipeline, artifacts_expire_at: Time.now + 7.days)
end
- it 'keeps artifacts' do
+ it "keeps artifacts" do
expect(response).to have_gitlab_http_status(200)
expect(job.reload.artifacts_expire_at).to be_nil
end
end
- context 'no artifacts' do
+ context "no artifacts" do
let(:job) { create(:ci_build, project: project, pipeline: pipeline) }
- it 'responds with not found' do
+ it "responds with not found" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'POST /projects/:id/jobs/:job_id/play' do
+ describe "POST /projects/:id/jobs/:job_id/play" do
before do
post api("/projects/#{project.id}/jobs/#{job.id}/play", api_user)
end
- context 'on an playable job' do
+ context "on an playable job" do
let(:job) { create(:ci_build, :manual, project: project, pipeline: pipeline) }
- context 'when user is authorized to trigger a manual action' do
- it 'plays the job' do
+ context "when user is authorized to trigger a manual action" do
+ it "plays the job" do
expect(response).to have_gitlab_http_status(200)
- expect(json_response['user']['id']).to eq(user.id)
- expect(json_response['id']).to eq(job.id)
+ expect(json_response["user"]["id"]).to eq(user.id)
+ expect(json_response["id"]).to eq(job.id)
expect(job.reload).to be_pending
end
end
- context 'when user is not authorized to trigger a manual action' do
- context 'when user does not have access to the project' do
+ context "when user is not authorized to trigger a manual action" do
+ context "when user does not have access to the project" do
let(:api_user) { create(:user) }
- it 'does not trigger a manual action' do
+ it "does not trigger a manual action" do
expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user is not allowed to trigger the manual action' do
+ context "when user is not allowed to trigger the manual action" do
let(:api_user) { reporter }
- it 'does not trigger a manual action' do
+ it "does not trigger a manual action" do
expect(job.reload).to be_manual
expect(response).to have_gitlab_http_status(403)
end
@@ -972,8 +972,8 @@ describe API::Jobs do
end
end
- context 'on a non-playable job' do
- it 'returns a status code 400, Bad Request' do
+ context "on a non-playable job" do
+ it "returns a status code 400, Bad Request" do
expect(response).to have_gitlab_http_status 400
expect(response.body).to match("Unplayable Job")
end
diff --git a/spec/requests/api/keys_spec.rb b/spec/requests/api/keys_spec.rb
index f37d84fddef..2b14f157ec1 100644
--- a/spec/requests/api/keys_spec.rb
+++ b/spec/requests/api/keys_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Keys do
let(:user) { create(:user) }
@@ -6,35 +6,35 @@ describe API::Keys do
let(:key) { create(:key, user: user) }
let(:email) { create(:email, user: user) }
- describe 'GET /keys/:uid' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ describe "GET /keys/:uid" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
get api("/keys/#{key.id}")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'returns 404 for non-existing key' do
- get api('/keys/0', admin)
+ context "when authenticated" do
+ it "returns 404 for non-existing key" do
+ get api("/keys/0", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Not found')
+ expect(json_response["message"]).to eq("404 Not found")
end
- it 'returns 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)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(key.title)
- expect(json_response['user']['id']).to eq(user.id)
- expect(json_response['user']['username']).to eq(user.username)
+ expect(json_response["title"]).to eq(key.title)
+ expect(json_response["user"]["id"]).to eq(user.id)
+ expect(json_response["user"]["username"]).to eq(user.username)
end
it "does not include the user's `is_admin` flag" do
get api("/keys/#{key.id}", admin)
- expect(json_response['user']['is_admin']).to be_nil
+ expect(json_response["user"]["is_admin"]).to be_nil
end
end
end
diff --git a/spec/requests/api/labels_spec.rb b/spec/requests/api/labels_spec.rb
index 518181e4d93..912ac5f9067 100644
--- a/spec/requests/api/labels_spec.rb
+++ b/spec/requests/api/labels_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Labels do
let(:user) { create(:user) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
- let!(:label1) { create(:label, title: 'label1', project: project) }
- let!(:priority_label) { create(:label, title: 'bug', project: project, priority: 3) }
+ let!(:label1) { create(:label, title: "label1", project: project) }
+ let!(:priority_label) { create(:label, title: "bug", project: project, priority: 3) }
before do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/labels' do
- it 'returns all available labels to the project' do
+ describe "GET /projects/:id/labels" do
+ it "returns all available labels to the project" do
group = create(:group)
- group_label = create(:group_label, title: 'feature', group: group)
+ group_label = create(:group_label, title: "feature", group: group)
project.update(group: group)
create(:labeled_issue, project: project, labels: [group_label], author: user)
create(:labeled_issue, project: project, labels: [label1], author: user, state: :closed)
- create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project )
+ create(:labeled_merge_request, labels: [priority_label], author: user, source_project: project)
- expected_keys = %w(
+ expected_keys = %w[
id name color text_color description
open_issues_count closed_issues_count open_merge_requests_count
subscribed priority is_project_label
- )
+ ]
get api("/projects/#{project.id}/labels", user)
@@ -32,339 +32,339 @@ describe API::Labels do
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
expect(json_response.first.keys).to match_array expected_keys
- expect(json_response.map { |l| l['name'] }).to match_array([group_label.name, priority_label.name, label1.name])
-
- label1_response = json_response.find { |l| l['name'] == label1.title }
- group_label_response = json_response.find { |l| l['name'] == group_label.title }
- priority_label_response = json_response.find { |l| l['name'] == priority_label.title }
-
- expect(label1_response['open_issues_count']).to eq(0)
- expect(label1_response['closed_issues_count']).to eq(1)
- expect(label1_response['open_merge_requests_count']).to eq(0)
- expect(label1_response['name']).to eq(label1.name)
- expect(label1_response['color']).to be_present
- expect(label1_response['text_color']).to be_present
- expect(label1_response['description']).to be_nil
- expect(label1_response['priority']).to be_nil
- expect(label1_response['subscribed']).to be_falsey
- expect(label1_response['is_project_label']).to be_truthy
-
- expect(group_label_response['open_issues_count']).to eq(1)
- expect(group_label_response['closed_issues_count']).to eq(0)
- expect(group_label_response['open_merge_requests_count']).to eq(0)
- expect(group_label_response['name']).to eq(group_label.name)
- expect(group_label_response['color']).to be_present
- expect(group_label_response['text_color']).to be_present
- expect(group_label_response['description']).to be_nil
- expect(group_label_response['priority']).to be_nil
- expect(group_label_response['subscribed']).to be_falsey
- expect(group_label_response['is_project_label']).to be_falsey
-
- expect(priority_label_response['open_issues_count']).to eq(0)
- expect(priority_label_response['closed_issues_count']).to eq(0)
- expect(priority_label_response['open_merge_requests_count']).to eq(1)
- expect(priority_label_response['name']).to eq(priority_label.name)
- expect(priority_label_response['color']).to be_present
- expect(priority_label_response['text_color']).to be_present
- expect(priority_label_response['description']).to be_nil
- expect(priority_label_response['priority']).to eq(3)
- expect(priority_label_response['subscribed']).to be_falsey
- expect(priority_label_response['is_project_label']).to be_truthy
+ expect(json_response.map { |l| l["name"] }).to match_array([group_label.name, priority_label.name, label1.name])
+
+ label1_response = json_response.find { |l| l["name"] == label1.title }
+ group_label_response = json_response.find { |l| l["name"] == group_label.title }
+ priority_label_response = json_response.find { |l| l["name"] == priority_label.title }
+
+ expect(label1_response["open_issues_count"]).to eq(0)
+ expect(label1_response["closed_issues_count"]).to eq(1)
+ expect(label1_response["open_merge_requests_count"]).to eq(0)
+ expect(label1_response["name"]).to eq(label1.name)
+ expect(label1_response["color"]).to be_present
+ expect(label1_response["text_color"]).to be_present
+ expect(label1_response["description"]).to be_nil
+ expect(label1_response["priority"]).to be_nil
+ expect(label1_response["subscribed"]).to be_falsey
+ expect(label1_response["is_project_label"]).to be_truthy
+
+ expect(group_label_response["open_issues_count"]).to eq(1)
+ expect(group_label_response["closed_issues_count"]).to eq(0)
+ expect(group_label_response["open_merge_requests_count"]).to eq(0)
+ expect(group_label_response["name"]).to eq(group_label.name)
+ expect(group_label_response["color"]).to be_present
+ expect(group_label_response["text_color"]).to be_present
+ expect(group_label_response["description"]).to be_nil
+ expect(group_label_response["priority"]).to be_nil
+ expect(group_label_response["subscribed"]).to be_falsey
+ expect(group_label_response["is_project_label"]).to be_falsey
+
+ expect(priority_label_response["open_issues_count"]).to eq(0)
+ expect(priority_label_response["closed_issues_count"]).to eq(0)
+ expect(priority_label_response["open_merge_requests_count"]).to eq(1)
+ expect(priority_label_response["name"]).to eq(priority_label.name)
+ expect(priority_label_response["color"]).to be_present
+ expect(priority_label_response["text_color"]).to be_present
+ expect(priority_label_response["description"]).to be_nil
+ expect(priority_label_response["priority"]).to eq(3)
+ expect(priority_label_response["subscribed"]).to be_falsey
+ expect(priority_label_response["is_project_label"]).to be_truthy
end
end
- describe 'POST /projects/:id/labels' do
- it 'returns created label when all params' do
+ describe "POST /projects/:id/labels" do
+ it "returns created label when all params" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo',
- color: '#FFAABB',
- description: 'test',
- priority: 2
- }
+ params: {
+ name: "Foo",
+ color: "#FFAABB",
+ description: "test",
+ priority: 2,
+ }
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('Foo')
- expect(json_response['color']).to eq('#FFAABB')
- expect(json_response['description']).to eq('test')
- expect(json_response['priority']).to eq(2)
+ expect(json_response["name"]).to eq("Foo")
+ expect(json_response["color"]).to eq("#FFAABB")
+ expect(json_response["description"]).to eq("test")
+ expect(json_response["priority"]).to eq(2)
end
- it 'returns created label when only required params' do
+ it "returns created label when only required params" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo & Bar',
- color: '#FFAABB'
- }
+ params: {
+ name: "Foo & Bar",
+ color: "#FFAABB",
+ }
expect(response.status).to eq(201)
- expect(json_response['name']).to eq('Foo & Bar')
- expect(json_response['color']).to eq('#FFAABB')
- expect(json_response['description']).to be_nil
- expect(json_response['priority']).to be_nil
+ expect(json_response["name"]).to eq("Foo & Bar")
+ expect(json_response["color"]).to eq("#FFAABB")
+ expect(json_response["description"]).to be_nil
+ expect(json_response["priority"]).to be_nil
end
- it 'creates a prioritized label' do
+ it "creates a prioritized label" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo & Bar',
- color: '#FFAABB',
- priority: 3
- }
+ params: {
+ name: "Foo & Bar",
+ color: "#FFAABB",
+ priority: 3,
+ }
expect(response.status).to eq(201)
- expect(json_response['name']).to eq('Foo & Bar')
- expect(json_response['color']).to eq('#FFAABB')
- expect(json_response['description']).to be_nil
- expect(json_response['priority']).to eq(3)
+ expect(json_response["name"]).to eq("Foo & Bar")
+ expect(json_response["color"]).to eq("#FFAABB")
+ expect(json_response["description"]).to be_nil
+ expect(json_response["priority"]).to eq(3)
end
- it 'returns a 400 bad request if name not given' do
- post api("/projects/#{project.id}/labels", user), params: { color: '#FFAABB' }
+ it "returns a 400 bad request if name not given" do
+ post api("/projects/#{project.id}/labels", user), params: {color: "#FFAABB"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 bad request if color not given' do
- post api("/projects/#{project.id}/labels", user), params: { name: 'Foobar' }
+ it "returns a 400 bad request if color not given" do
+ post api("/projects/#{project.id}/labels", user), params: {name: "Foobar"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 for invalid color' do
+ it "returns 400 for invalid color" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo',
- color: '#FFAA'
- }
+ params: {
+ name: "Foo",
+ color: "#FFAA",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['color']).to eq(['must be a valid color code'])
+ expect(json_response["message"]["color"]).to eq(["must be a valid color code"])
end
- it 'returns 400 for too long color code' do
+ it "returns 400 for too long color code" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo',
- color: '#FFAAFFFF'
- }
+ params: {
+ name: "Foo",
+ color: "#FFAAFFFF",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['color']).to eq(['must be a valid color code'])
+ expect(json_response["message"]["color"]).to eq(["must be a valid color code"])
end
- it 'returns 400 for invalid name' do
+ it "returns 400 for invalid name" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: ',',
- color: '#FFAABB'
- }
+ params: {
+ name: ",",
+ color: "#FFAABB",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['title']).to eq(['is invalid'])
+ expect(json_response["message"]["title"]).to eq(["is invalid"])
end
- it 'returns 409 if label already exists in group' do
+ it "returns 409 if label already exists in group" do
group = create(:group)
group_label = create(:group_label, group: group)
project.update(group: group)
post api("/projects/#{project.id}/labels", user),
- params: {
- name: group_label.name,
- color: '#FFAABB'
- }
+ params: {
+ name: group_label.name,
+ color: "#FFAABB",
+ }
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Label already exists')
+ expect(json_response["message"]).to eq("Label already exists")
end
- it 'returns 400 for invalid priority' do
+ it "returns 400 for invalid priority" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'Foo',
- color: '#FFAAFFFF',
- priority: 'foo'
- }
+ params: {
+ name: "Foo",
+ color: "#FFAAFFFF",
+ priority: "foo",
+ }
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 409 if label already exists in project' do
+ it "returns 409 if label already exists in project" do
post api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- color: '#FFAABB'
- }
+ params: {
+ name: "label1",
+ color: "#FFAABB",
+ }
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Label already exists')
+ expect(json_response["message"]).to eq("Label already exists")
end
end
- describe 'DELETE /projects/:id/labels' do
- it 'returns 204 for existing label' do
- delete api("/projects/#{project.id}/labels", user), params: { name: 'label1' }
+ describe "DELETE /projects/:id/labels" do
+ it "returns 204 for existing label" do
+ delete api("/projects/#{project.id}/labels", user), params: {name: "label1"}
expect(response).to have_gitlab_http_status(204)
end
- it 'returns 404 for non existing label' do
- delete api("/projects/#{project.id}/labels", user), params: { name: 'label2' }
+ it "returns 404 for non existing label" do
+ delete api("/projects/#{project.id}/labels", user), params: {name: "label2"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Label Not Found')
+ expect(json_response["message"]).to eq("404 Label Not Found")
end
- it 'returns 400 for wrong parameters' do
+ it "returns 400 for wrong parameters" do
delete api("/projects/#{project.id}/labels", user)
expect(response).to have_gitlab_http_status(400)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/labels", user) }
- let(:params) { { name: 'label1' } }
+ let(:params) { {name: "label1"} }
end
end
- describe 'PUT /projects/:id/labels' do
- it 'returns 200 if name and colors and description are changed' do
+ describe "PUT /projects/:id/labels" do
+ it "returns 200 if name and colors and description are changed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- new_name: 'New Label',
- color: '#FFFFFF',
- description: 'test'
- }
+ params: {
+ name: "label1",
+ new_name: "New Label",
+ color: "#FFFFFF",
+ description: "test",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq('New Label')
- expect(json_response['color']).to eq('#FFFFFF')
- expect(json_response['description']).to eq('test')
+ expect(json_response["name"]).to eq("New Label")
+ expect(json_response["color"]).to eq("#FFFFFF")
+ expect(json_response["description"]).to eq("test")
end
- it 'returns 200 if name is changed' do
+ it "returns 200 if name is changed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- new_name: 'New Label'
- }
+ params: {
+ name: "label1",
+ new_name: "New Label",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq('New Label')
- expect(json_response['color']).to eq(label1.color)
+ expect(json_response["name"]).to eq("New Label")
+ expect(json_response["color"]).to eq(label1.color)
end
- it 'returns 200 if colors is changed' do
+ it "returns 200 if colors is changed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- color: '#FFFFFF'
- }
+ params: {
+ name: "label1",
+ color: "#FFFFFF",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(label1.name)
- expect(json_response['color']).to eq('#FFFFFF')
+ expect(json_response["name"]).to eq(label1.name)
+ expect(json_response["color"]).to eq("#FFFFFF")
end
- it 'returns 200 if description is changed' do
+ it "returns 200 if description is changed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'bug',
- description: 'test'
- }
+ params: {
+ name: "bug",
+ description: "test",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(priority_label.name)
- expect(json_response['description']).to eq('test')
- expect(json_response['priority']).to eq(3)
+ expect(json_response["name"]).to eq(priority_label.name)
+ expect(json_response["description"]).to eq("test")
+ expect(json_response["priority"]).to eq(3)
end
- it 'returns 200 if priority is changed' do
+ it "returns 200 if priority is changed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'bug',
- priority: 10
- }
+ params: {
+ name: "bug",
+ priority: 10,
+ }
expect(response.status).to eq(200)
- expect(json_response['name']).to eq(priority_label.name)
- expect(json_response['priority']).to eq(10)
+ expect(json_response["name"]).to eq(priority_label.name)
+ expect(json_response["priority"]).to eq(10)
end
- it 'returns 200 if a priority is added' do
+ it "returns 200 if a priority is added" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- priority: 3
- }
+ params: {
+ name: "label1",
+ priority: 3,
+ }
expect(response.status).to eq(200)
- expect(json_response['name']).to eq(label1.name)
- expect(json_response['priority']).to eq(3)
+ expect(json_response["name"]).to eq(label1.name)
+ expect(json_response["priority"]).to eq(3)
end
- it 'returns 200 if the priority is removed' do
+ it "returns 200 if the priority is removed" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: priority_label.name,
- priority: nil
- }
+ params: {
+ name: priority_label.name,
+ priority: nil,
+ }
expect(response.status).to eq(200)
- expect(json_response['name']).to eq(priority_label.name)
- expect(json_response['priority']).to be_nil
+ expect(json_response["name"]).to eq(priority_label.name)
+ expect(json_response["priority"]).to be_nil
end
- it 'returns 404 if label does not exist' do
+ it "returns 404 if label does not exist" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label2',
- new_name: 'label3'
- }
+ params: {
+ name: "label2",
+ new_name: "label3",
+ }
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 400 if no label name given' do
- put api("/projects/#{project.id}/labels", user), params: { new_name: 'label2' }
+ it "returns 400 if no label name given" do
+ put api("/projects/#{project.id}/labels", user), params: {new_name: "label2"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response["error"]).to eq("name is missing")
end
- it 'returns 400 if no new parameters given' do
- put api("/projects/#{project.id}/labels", user), params: { name: 'label1' }
+ it "returns 400 if no new parameters given" do
+ put api("/projects/#{project.id}/labels", user), params: {name: "label1"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('new_name, color, description, priority are missing, '\
- 'at least one parameter must be provided')
+ expect(json_response["error"]).to eq("new_name, color, description, priority are missing, "\
+ "at least one parameter must be provided")
end
- it 'returns 400 for invalid name' do
+ it "returns 400 for invalid name" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- new_name: ',',
- color: '#FFFFFF'
- }
+ params: {
+ name: "label1",
+ new_name: ",",
+ color: "#FFFFFF",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['title']).to eq(['is invalid'])
+ expect(json_response["message"]["title"]).to eq(["is invalid"])
end
- it 'returns 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),
- params: {
- name: 'label1',
- color: '#FF'
- }
+ params: {
+ name: "label1",
+ color: "#FF",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['color']).to eq(['must be a valid color code'])
+ expect(json_response["message"]["color"]).to eq(["must be a valid color code"])
end
- it 'returns 400 for too long color code' do
+ it "returns 400 for too long color code" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- color: '#FFAAFFFF'
- }
+ params: {
+ name: "label1",
+ color: "#FFAAFFFF",
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['color']).to eq(['must be a valid color code'])
+ expect(json_response["message"]["color"]).to eq(["must be a valid color code"])
end
- it 'returns 400 for invalid priority' do
+ it "returns 400 for invalid priority" do
put api("/projects/#{project.id}/labels", user),
- params: {
- name: 'label1',
- priority: 'foo'
- }
+ params: {
+ name: "label1",
+ priority: "foo",
+ }
expect(response).to have_gitlab_http_status(400)
end
diff --git a/spec/requests/api/lint_spec.rb b/spec/requests/api/lint_spec.rb
index f52cdf1c459..1a8267fba1c 100644
--- a/spec/requests/api/lint_spec.rb
+++ b/spec/requests/api/lint_spec.rb
@@ -1,46 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Lint do
- describe 'POST /ci/lint' do
- context 'with valid .gitlab-ci.yaml content' do
+ describe "POST /ci/lint" do
+ context "with valid .gitlab-ci.yaml content" do
let(:yaml_content) do
- File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
end
- it 'passes validation' do
- post api('/ci/lint'), params: { content: yaml_content }
+ it "passes validation" do
+ post api("/ci/lint"), params: {content: yaml_content}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Hash
- expect(json_response['status']).to eq('valid')
- expect(json_response['errors']).to eq([])
+ expect(json_response["status"]).to eq("valid")
+ expect(json_response["errors"]).to eq([])
end
end
- context 'with an invalid .gitlab_ci.yml' do
- it 'responds with errors about invalid syntax' do
- post api('/ci/lint'), params: { content: 'invalid content' }
+ context "with an invalid .gitlab_ci.yml" do
+ it "responds with errors about invalid syntax" do
+ post api("/ci/lint"), params: {content: "invalid content"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['status']).to eq('invalid')
- expect(json_response['errors']).to eq(['Invalid configuration format'])
+ expect(json_response["status"]).to eq("invalid")
+ expect(json_response["errors"]).to eq(["Invalid configuration format"])
end
it "responds with errors about invalid configuration" do
- post api('/ci/lint'), params: { content: '{ image: "ruby:2.1", services: ["postgres"] }' }
+ post api("/ci/lint"), params: {content: '{ image: "ruby:2.1", services: ["postgres"] }'}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['status']).to eq('invalid')
- expect(json_response['errors']).to eq(['jobs config should contain at least one visible job'])
+ expect(json_response["status"]).to eq("invalid")
+ expect(json_response["errors"]).to eq(["jobs config should contain at least one visible job"])
end
end
- context 'without the content parameter' do
- it 'responds with validation error about missing content' do
- post api('/ci/lint')
+ context "without the content parameter" do
+ it "responds with validation error about missing content" do
+ post api("/ci/lint")
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('content is missing')
+ expect(json_response["error"]).to eq("content is missing")
end
end
end
diff --git a/spec/requests/api/markdown_spec.rb b/spec/requests/api/markdown_spec.rb
index 0cf5c5677b9..44b54366bfc 100644
--- a/spec/requests/api/markdown_spec.rb
+++ b/spec/requests/api/markdown_spec.rb
@@ -43,7 +43,7 @@ describe API::Markdown do
end
context "when project is not found" do
- let(:params) { { text: "Hello world!", gfm: true, project: "Dummy project" } }
+ let(:params) { {text: "Hello world!", gfm: true, project: "Dummy project"} }
it_behaves_like "404 Project Not Found"
end
@@ -56,13 +56,13 @@ describe API::Markdown do
context "when not using gfm" do
context "without project" do
- let(:params) { { text: text } }
+ let(:params) { {text: text} }
it_behaves_like "rendered markdown text without GFM"
end
context "with project" do
- let(:params) { { text: text, project: project.full_path } }
+ let(:params) { {text: text, project: project.full_path} }
context "when not authorized" do
it_behaves_like "404 Project Not Found"
@@ -78,23 +78,23 @@ describe API::Markdown do
context "when using gfm" do
context "without project" do
- let(:params) { { text: text, gfm: true } }
+ let(:params) { {text: text, gfm: true} }
it "renders markdown text" do
expect(response).to have_http_status(201)
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["html"]).to include("Hello world!")
- .and include('data-name="tada"')
- .and include('data-name="100"')
- .and include("#1")
- .and exclude("<a href=\"#{IssuesHelper.url_for_issue(issue.iid, project)}\"")
- .and exclude("#1</a>")
+ .and include('data-name="tada"')
+ .and include('data-name="100"')
+ .and include("#1")
+ .and exclude("<a href=\"#{IssuesHelper.url_for_issue(issue.iid, project)}\"")
+ .and exclude("#1</a>")
end
end
context "with project" do
- let(:params) { { text: text, gfm: true, project: project.full_path } }
+ let(:params) { {text: text, gfm: true, project: project.full_path} }
let(:user) { project.owner }
it "renders markdown text" do
@@ -102,55 +102,55 @@ describe API::Markdown do
expect(response.headers["Content-Type"]).to eq("application/json")
expect(json_response).to be_a(Hash)
expect(json_response["html"]).to include("Hello world!")
- .and include('data-name="tada"')
- .and include('data-name="100"')
- .and include("<a href=\"#{IssuesHelper.url_for_issue(issue.iid, project)}\"")
- .and include("#1</a>")
+ .and include('data-name="tada"')
+ .and include('data-name="100"')
+ .and include("<a href=\"#{IssuesHelper.url_for_issue(issue.iid, project)}\"")
+ .and include("#1</a>")
end
end
- context 'with a public project and confidential issue' do
+ context "with a public project and confidential issue" do
let(:public_project) { create(:project, :public) }
- let(:confidential_issue) { create(:issue, :confidential, project: public_project, title: 'Confidential title') }
+ let(:confidential_issue) { create(:issue, :confidential, project: public_project, title: "Confidential title") }
let(:text) { ":tada: Hello world! :100: #{confidential_issue.to_reference}" }
- let(:params) { { text: text, gfm: true, project: public_project.full_path } }
+ let(:params) { {text: text, gfm: true, project: public_project.full_path} }
- shared_examples 'user without proper access' do
- it 'does not render the title or link' do
+ shared_examples "user without proper access" do
+ it "does not render the title or link" do
expect(response).to have_http_status(201)
- expect(json_response["html"]).not_to include('Confidential title')
- expect(json_response["html"]).not_to include('<a href=')
- expect(json_response["html"]).to include('Hello world!')
- .and include('data-name="tada"')
- .and include('data-name="100"')
- .and include('#1</p>')
+ expect(json_response["html"]).not_to include("Confidential title")
+ expect(json_response["html"]).not_to include("<a href=")
+ expect(json_response["html"]).to include("Hello world!")
+ .and include('data-name="tada"')
+ .and include('data-name="100"')
+ .and include("#1</p>")
end
end
- context 'when not logged in' do
+ context "when not logged in" do
let(:user) { }
- it_behaves_like 'user without proper access'
+ it_behaves_like "user without proper access"
end
- context 'when logged in as user without access' do
+ context "when logged in as user without access" do
let(:user) { create(:user) }
- it_behaves_like 'user without proper access'
+ it_behaves_like "user without proper access"
end
- context 'when logged in as author' do
+ context "when logged in as author" do
let(:user) { confidential_issue.author }
- it 'renders the title or link' do
+ it "renders the title or link" do
expect(response).to have_http_status(201)
- expect(json_response["html"]).to include('Confidential title')
- expect(json_response["html"]).to include('Hello world!')
- .and include('data-name="tada"')
- .and include('data-name="100"')
- .and include("<a href=\"#{IssuesHelper.url_for_issue(confidential_issue.iid, public_project)}\"")
- .and include("#1</a>")
+ expect(json_response["html"]).to include("Confidential title")
+ expect(json_response["html"]).to include("Hello world!")
+ .and include('data-name="tada"')
+ .and include('data-name="100"')
+ .and include("<a href=\"#{IssuesHelper.url_for_issue(confidential_issue.iid, public_project)}\"")
+ .and include("#1</a>")
end
end
end
diff --git a/spec/requests/api/members_spec.rb b/spec/requests/api/members_spec.rb
index 79edbb301f2..92206ac76cc 100644
--- a/spec/requests/api/members_spec.rb
+++ b/spec/requests/api/members_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Members do
- let(:maintainer) { create(:user, username: 'maintainer_user') }
+ let(:maintainer) { create(:user, username: "maintainer_user") }
let(:developer) { create(:user) }
let(:access_requester) { create(:user) }
let(:stranger) { create(:user) }
@@ -22,7 +22,7 @@ describe API::Members do
end
end
- shared_examples 'GET /:source_type/:id/members/(all)' do |source_type, all|
+ shared_examples "GET /:source_type/:id/members/(all)" do |source_type, all|
let(:members_url) do
"/#{source_type.pluralize}/#{source.id}/members".tap do |url|
url << "/all" if all
@@ -30,13 +30,13 @@ describe API::Members do
end
context "with :source_type == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { get api(members_url, stranger) }
end
%i[maintainer developer access_requester stranger].each do |type|
context "when authenticated as a #{type}" do
- it 'returns 200' do
+ it "returns 200" do
user = public_send(type)
get api(members_url, user)
@@ -45,28 +45,28 @@ describe API::Members do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
- expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id]
+ expect(json_response.map { |u| u["id"] }).to match_array [maintainer.id, developer.id]
end
end
end
- it 'avoids N+1 queries' do
+ it "avoids N+1 queries" do
# Establish baseline
get api(members_url, maintainer)
- control = ActiveRecord::QueryRecorder.new do
+ control = ActiveRecord::QueryRecorder.new {
get api(members_url, maintainer)
- end
+ }
project.add_developer(create(:user))
- expect do
+ expect {
get api(members_url, maintainer)
- end.not_to exceed_query_limit(control)
+ }.not_to exceed_query_limit(control)
end
- it 'does not return invitees' do
- create(:"#{source_type}_member", invite_token: '123', invite_email: 'test@abc.com', source: source, user: nil)
+ it "does not return invitees" do
+ create(:"#{source_type}_member", invite_token: "123", invite_email: "test@abc.com", source: source, user: nil)
get api(members_url, developer)
@@ -74,32 +74,32 @@ describe API::Members do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
- expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id]
+ expect(json_response.map { |u| u["id"] }).to match_array [maintainer.id, developer.id]
end
- it 'finds members with query string' do
- get api(members_url, developer), params: { query: maintainer.username }
+ it "finds members with query string" do
+ get api(members_url, developer), params: {query: maintainer.username}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.count).to eq(1)
- expect(json_response.first['username']).to eq(maintainer.username)
+ expect(json_response.first["username"]).to eq(maintainer.username)
end
- it 'finds all members with no query specified' do
- get api(members_url, developer), params: { query: '' }
+ it "finds all members with no query specified" do
+ get api(members_url, developer), params: {query: ""}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.count).to eq(2)
- expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id]
+ expect(json_response.map { |u| u["id"] }).to match_array [maintainer.id, developer.id]
end
end
end
- describe 'GET /:source_type/:id/members/all', :nested_groups do
+ describe "GET /:source_type/:id/members/all", :nested_groups do
let(:nested_user) { create(:user) }
let(:project_user) { create(:user) }
let(:linked_group_user) { create(:user) }
@@ -123,49 +123,49 @@ describe API::Members do
end
end
- it 'finds all project members including inherited members' do
+ it "finds all project members including inherited members" do
get api("/projects/#{project.id}/members/all", developer)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id, nested_user.id, project_user.id, linked_group_user.id]
+ expect(json_response.map { |u| u["id"] }).to match_array [maintainer.id, developer.id, nested_user.id, project_user.id, linked_group_user.id]
end
- it 'finds all group members including inherited members' do
+ it "finds all group members including inherited members" do
get api("/groups/#{nested_group.id}/members/all", developer)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |u| u['id'] }).to match_array [maintainer.id, developer.id, nested_user.id]
+ expect(json_response.map { |u| u["id"] }).to match_array [maintainer.id, developer.id, nested_user.id]
end
end
- shared_examples 'GET /:source_type/:id/members/:user_id' do |source_type|
+ shared_examples "GET /:source_type/:id/members/:user_id" do |source_type|
context "with :source_type == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { get api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", stranger) }
end
- context 'when authenticated as a non-member' do
+ context "when authenticated as a non-member" do
%i[access_requester stranger].each do |type|
context "as a #{type}" do
- it 'returns 200' do
+ it "returns 200" do
user = public_send(type)
get api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user)
expect(response).to have_gitlab_http_status(200)
# User attributes
- expect(json_response['id']).to eq(developer.id)
- expect(json_response['name']).to eq(developer.name)
- expect(json_response['username']).to eq(developer.username)
- expect(json_response['state']).to eq(developer.state)
- expect(json_response['avatar_url']).to eq(developer.avatar_url)
- expect(json_response['web_url']).to eq(Gitlab::Routing.url_helpers.user_url(developer))
+ expect(json_response["id"]).to eq(developer.id)
+ expect(json_response["name"]).to eq(developer.name)
+ expect(json_response["username"]).to eq(developer.username)
+ expect(json_response["state"]).to eq(developer.state)
+ expect(json_response["avatar_url"]).to eq(developer.avatar_url)
+ expect(json_response["web_url"]).to eq(Gitlab::Routing.url_helpers.user_url(developer))
# Member attributes
- expect(json_response['access_level']).to eq(Member::DEVELOPER)
+ expect(json_response["access_level"]).to eq(Member::DEVELOPER)
end
end
end
@@ -173,22 +173,22 @@ describe API::Members do
end
end
- shared_examples 'POST /:source_type/:id/members' do |source_type|
+ shared_examples "POST /:source_type/:id/members" do |source_type|
context "with :source_type == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) do
post api("/#{source_type.pluralize}/#{source.id}/members", stranger),
- params: { user_id: access_requester.id, access_level: Member::MAINTAINER }
+ params: {user_id: access_requester.id, access_level: Member::MAINTAINER}
end
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger developer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
post api("/#{source_type.pluralize}/#{source.id}/members", user),
- params: { user_id: access_requester.id, access_level: Member::MAINTAINER }
+ params: {user_id: access_requester.id, access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(403)
end
@@ -196,36 +196,36 @@ describe API::Members do
end
end
- context 'when authenticated as a maintainer/owner' do
- context 'and new member is already a requester' do
- it 'transforms the requester into a proper member' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ context "and new member is already a requester" do
+ it "transforms the requester into a proper member" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: access_requester.id, access_level: Member::MAINTAINER }
+ params: {user_id: access_requester.id, access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(201)
- end.to change { source.members.count }.by(1)
+ }.to change { source.members.count }.by(1)
expect(source.requesters.count).to eq(0)
- expect(json_response['id']).to eq(access_requester.id)
- expect(json_response['access_level']).to eq(Member::MAINTAINER)
+ expect(json_response["id"]).to eq(access_requester.id)
+ expect(json_response["access_level"]).to eq(Member::MAINTAINER)
end
end
- it 'creates a new member' do
- expect do
+ it "creates a new member" do
+ expect {
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: '2016-08-05' }
+ params: {user_id: stranger.id, access_level: Member::DEVELOPER, expires_at: "2016-08-05"}
expect(response).to have_gitlab_http_status(201)
- end.to change { source.members.count }.by(1)
- expect(json_response['id']).to eq(stranger.id)
- expect(json_response['access_level']).to eq(Member::DEVELOPER)
- expect(json_response['expires_at']).to eq('2016-08-05')
+ }.to change { source.members.count }.by(1)
+ expect(json_response["id"]).to eq(stranger.id)
+ expect(json_response["access_level"]).to eq(Member::DEVELOPER)
+ expect(json_response["expires_at"]).to eq("2016-08-05")
end
end
- context 'access levels' do
- it 'does not create the member if group level is higher', :nested_groups do
+ context "access levels" do
+ it "does not create the member if group level is higher", :nested_groups do
parent = create(:group)
group.update(parent: parent)
@@ -233,13 +233,13 @@ describe API::Members do
parent.add_developer(stranger)
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: stranger.id, access_level: Member::REPORTER }
+ params: {user_id: stranger.id, access_level: Member::REPORTER}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['access_level']).to eq(["should be higher than Developer inherited membership from group #{parent.name}"])
+ expect(json_response["message"]["access_level"]).to eq(["should be higher than Developer inherited membership from group #{parent.name}"])
end
- it 'creates the member if group level is lower', :nested_groups do
+ it "creates the member if group level is lower", :nested_groups do
parent = create(:group)
group.update(parent: parent)
@@ -247,68 +247,68 @@ describe API::Members do
parent.add_developer(stranger)
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: stranger.id, access_level: Member::MAINTAINER }
+ params: {user_id: stranger.id, access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(stranger.id)
- expect(json_response['access_level']).to eq(Member::MAINTAINER)
+ expect(json_response["id"]).to eq(stranger.id)
+ expect(json_response["access_level"]).to eq(Member::MAINTAINER)
end
end
it "returns 409 if member already exists" do
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: maintainer.id, access_level: Member::MAINTAINER }
+ params: {user_id: maintainer.id, access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(409)
end
- it 'returns 404 when the user_id is not valid' do
+ it "returns 404 when the user_id is not valid" do
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: 0, access_level: Member::MAINTAINER }
+ params: {user_id: 0, access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 400 when user_id is not given' do
+ it "returns 400 when user_id is not given" do
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { access_level: Member::MAINTAINER }
+ params: {access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when access_level is not given' do
+ it "returns 400 when access_level is not given" do
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: stranger.id }
+ params: {user_id: stranger.id}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when access_level is not valid' do
+ it "returns 400 when access_level is not valid" do
post api("/#{source_type.pluralize}/#{source.id}/members", maintainer),
- params: { user_id: stranger.id, access_level: 1234 }
+ params: {user_id: stranger.id, access_level: 1234}
expect(response).to have_gitlab_http_status(400)
end
end
end
- shared_examples 'PUT /:source_type/:id/members/:user_id' do |source_type|
+ shared_examples "PUT /:source_type/:id/members/:user_id" do |source_type|
context "with :source_type == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) do
put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", stranger),
- params: { access_level: Member::MAINTAINER }
+ params: {access_level: Member::MAINTAINER}
end
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger developer].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user),
- params: { access_level: Member::MAINTAINER }
+ params: {access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(403)
end
@@ -316,50 +316,50 @@ describe API::Members do
end
end
- context 'when authenticated as a maintainer/owner' do
- it 'updates the member' do
+ context "when authenticated as a maintainer/owner" do
+ it "updates the member" do
put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer),
- params: { access_level: Member::MAINTAINER, expires_at: '2016-08-05' }
+ params: {access_level: Member::MAINTAINER, expires_at: "2016-08-05"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(developer.id)
- expect(json_response['access_level']).to eq(Member::MAINTAINER)
- expect(json_response['expires_at']).to eq('2016-08-05')
+ expect(json_response["id"]).to eq(developer.id)
+ expect(json_response["access_level"]).to eq(Member::MAINTAINER)
+ expect(json_response["expires_at"]).to eq("2016-08-05")
end
end
- it 'returns 409 if member does not exist' do
+ it "returns 409 if member does not exist" do
put api("/#{source_type.pluralize}/#{source.id}/members/123", maintainer),
- params: { access_level: Member::MAINTAINER }
+ params: {access_level: Member::MAINTAINER}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 400 when access_level is not given' do
+ it "returns 400 when access_level is not given" do
put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 when access level is not valid' do
+ it "returns 400 when access level is not valid" do
put api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer),
- params: { access_level: 1234 }
+ params: {access_level: 1234}
expect(response).to have_gitlab_http_status(400)
end
end
end
- shared_examples 'DELETE /:source_type/:id/members/:user_id' do |source_type|
+ shared_examples "DELETE /:source_type/:id/members/:user_id" do |source_type|
context "with :source_type == #{source_type.pluralize}" do
- it_behaves_like 'a 404 response when source is private' do
+ it_behaves_like "a 404 response when source is private" do
let(:route) { delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", stranger) }
end
- context 'when authenticated as a non-member or member with insufficient rights' do
+ context "when authenticated as a non-member or member with insufficient rights" do
%i[access_requester stranger].each do |type|
context "as a #{type}" do
- it 'returns 403' do
+ it "returns 403" do
user = public_send(type)
delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", user)
@@ -369,41 +369,41 @@ describe API::Members do
end
end
- context 'when authenticated as a member and deleting themself' do
- it 'deletes the member' do
- expect do
+ context "when authenticated as a member and deleting themself" do
+ it "deletes the member" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", developer)
expect(response).to have_gitlab_http_status(204)
- end.to change { source.members.count }.by(-1)
+ }.to change { source.members.count }.by(-1)
end
end
- context 'when authenticated as a maintainer/owner' do
- context 'and member is a requester' do
- it 'returns 404' do
- expect do
+ context "when authenticated as a maintainer/owner" do
+ context "and member is a requester" do
+ it "returns 404" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/members/#{access_requester.id}", maintainer)
expect(response).to have_gitlab_http_status(404)
- end.not_to change { source.requesters.count }
+ }.not_to change { source.requesters.count }
end
end
- it 'deletes the member' do
- expect do
+ it "deletes the member" do
+ expect {
delete api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer)
expect(response).to have_gitlab_http_status(204)
- end.to change { source.members.count }.by(-1)
+ }.to change { source.members.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/#{source_type.pluralize}/#{source.id}/members/#{developer.id}", maintainer) }
end
end
- it 'returns 404 if member does not exist' do
+ it "returns 404 if member does not exist" do
delete api("/#{source_type.pluralize}/#{source.id}/members/123", maintainer)
expect(response).to have_gitlab_http_status(404)
@@ -412,55 +412,55 @@ describe API::Members do
end
[false, true].each do |all|
- it_behaves_like 'GET /:source_type/:id/members/(all)', 'project', all do
+ it_behaves_like "GET /:source_type/:id/members/(all)", "project", all do
let(:source) { project }
end
- it_behaves_like 'GET /:source_type/:id/members/(all)', 'group', all do
+ it_behaves_like "GET /:source_type/:id/members/(all)", "group", all do
let(:source) { group }
end
end
- it_behaves_like 'GET /:source_type/:id/members/:user_id', 'project' do
+ it_behaves_like "GET /:source_type/:id/members/:user_id", "project" do
let(:source) { project }
end
- it_behaves_like 'GET /:source_type/:id/members/:user_id', 'group' do
+ it_behaves_like "GET /:source_type/:id/members/:user_id", "group" do
let(:source) { group }
end
- it_behaves_like 'POST /:source_type/:id/members', 'project' do
+ it_behaves_like "POST /:source_type/:id/members", "project" do
let(:source) { project }
end
- it_behaves_like 'POST /:source_type/:id/members', 'group' do
+ it_behaves_like "POST /:source_type/:id/members", "group" do
let(:source) { group }
end
- it_behaves_like 'PUT /:source_type/:id/members/:user_id', 'project' do
+ it_behaves_like "PUT /:source_type/:id/members/:user_id", "project" do
let(:source) { project }
end
- it_behaves_like 'PUT /:source_type/:id/members/:user_id', 'group' do
+ it_behaves_like "PUT /:source_type/:id/members/:user_id", "group" do
let(:source) { group }
end
- it_behaves_like 'DELETE /:source_type/:id/members/:user_id', 'project' do
+ it_behaves_like "DELETE /:source_type/:id/members/:user_id", "project" do
let(:source) { project }
end
- it_behaves_like 'DELETE /:source_type/:id/members/:user_id', 'group' do
+ it_behaves_like "DELETE /:source_type/:id/members/:user_id", "group" do
let(:source) { group }
end
- context 'Adding owner to project' do
- it 'returns 403' do
- expect do
+ context "Adding owner to project" do
+ it "returns 403" do
+ expect {
post api("/projects/#{project.id}/members", maintainer),
- params: { user_id: stranger.id, access_level: Member::OWNER }
+ params: {user_id: stranger.id, access_level: Member::OWNER}
expect(response).to have_gitlab_http_status(400)
- end.to change { project.members.count }.by(0)
+ }.to change { project.members.count }.by(0)
end
end
end
diff --git a/spec/requests/api/merge_request_diffs_spec.rb b/spec/requests/api/merge_request_diffs_spec.rb
index 8a67d98fc4c..806ba6d4d16 100644
--- a/spec/requests/api/merge_request_diffs_spec.rb
+++ b/spec/requests/api/merge_request_diffs_spec.rb
@@ -1,18 +1,18 @@
require "spec_helper"
-describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
+describe API::MergeRequestDiffs, "MergeRequestDiffs" do
let!(:user) { create(:user) }
let!(:merge_request) { create(:merge_request, importing: true) }
let!(:project) { merge_request.target_project }
before do
- merge_request.merge_request_diffs.create(head_commit_sha: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9')
- merge_request.merge_request_diffs.create(head_commit_sha: '5937ac0a7beb003549fc5fd26fc247adbce4a52e')
+ merge_request.merge_request_diffs.create(head_commit_sha: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9")
+ merge_request.merge_request_diffs.create(head_commit_sha: "5937ac0a7beb003549fc5fd26fc247adbce4a52e")
project.add_maintainer(user)
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/versions' do
- it 'returns 200 for a valid merge request' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/versions" do
+ it "returns 200 for a valid merge request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions", user)
merge_request_diff = merge_request.merge_request_diffs.last
@@ -20,44 +20,44 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(merge_request.merge_request_diffs.size)
- expect(json_response.first['id']).to eq(merge_request_diff.id)
- expect(json_response.first['head_commit_sha']).to eq(merge_request_diff.head_commit_sha)
+ expect(json_response.first["id"]).to eq(merge_request_diff.id)
+ expect(json_response.first["head_commit_sha"]).to eq(merge_request_diff.head_commit_sha)
end
- it 'returns a 404 when merge_request id is used instead of the iid' do
+ it "returns a 404 when merge_request id is used instead of the iid" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when merge_request_iid not found' do
+ it "returns a 404 when merge_request_iid not found" do
get api("/projects/#{project.id}/merge_requests/0/versions", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/versions/:version_id" do
let(:merge_request_diff) { merge_request.merge_request_diffs.first }
- it 'returns a 200 for a valid merge request' do
+ it "returns a 200 for a valid merge request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/#{merge_request_diff.id}", user)
expect(response.status).to eq 200
- expect(json_response['id']).to eq(merge_request_diff.id)
- expect(json_response['head_commit_sha']).to eq(merge_request_diff.head_commit_sha)
- expect(json_response['diffs'].size).to eq(merge_request_diff.diffs.size)
+ expect(json_response["id"]).to eq(merge_request_diff.id)
+ expect(json_response["head_commit_sha"]).to eq(merge_request_diff.head_commit_sha)
+ expect(json_response["diffs"].size).to eq(merge_request_diff.diffs.size)
end
- it 'returns a 404 when merge_request id is used instead of the iid' do
+ it "returns a 404 when merge_request id is used instead of the iid" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/versions/#{merge_request_diff.id}", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when merge_request version_id is not found' do
+ it "returns a 404 when merge_request version_id is not found" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/versions/0", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when merge_request_iid is not found' do
+ it "returns a 404 when merge_request_iid is not found" do
get api("/projects/#{project.id}/merge_requests/12345/versions/#{merge_request_diff.id}", user)
expect(response).to have_gitlab_http_status(404)
end
diff --git a/spec/requests/api/merge_requests_spec.rb b/spec/requests/api/merge_requests_spec.rb
index 6272bb38d59..3c0a6286a5f 100644
--- a/spec/requests/api/merge_requests_spec.rb
+++ b/spec/requests/api/merge_requests_spec.rb
@@ -8,19 +8,19 @@ describe API::MergeRequests do
let(:admin) { create(:user, :admin) }
let(:non_member) { create(:user) }
let!(:project) { create(:project, :public, :repository, creator: user, namespace: user.namespace, only_allow_merge_if_pipeline_succeeds: false) }
- let(:milestone) { create(:milestone, title: '1.0.0', project: project) }
+ let(:milestone) { create(:milestone, title: "1.0.0", project: project) }
let(:pipeline) { create(:ci_empty_pipeline) }
- let(:milestone1) { create(:milestone, title: '0.9', project: project) }
+ let(:milestone1) { create(:milestone, title: "0.9", project: project) }
let!(:merge_request) { create(:merge_request, :simple, milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Test", created_at: base_time) }
let!(:merge_request_closed) { create(:merge_request, state: "closed", milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Closed test", created_at: base_time + 1.second) }
- let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test", created_at: base_time + 2.seconds, merge_commit_sha: '9999999999999999999999999999999999999999') }
+ let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test", created_at: base_time + 2.seconds, merge_commit_sha: "9999999999999999999999999999999999999999") }
let!(:merge_request_locked) { create(:merge_request, state: "locked", milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Locked test", created_at: base_time + 1.second) }
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
let!(:note2) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "another comment on a MR") }
let!(:label) do
- create(:label, title: 'label', color: '#FFAABB', project: project)
+ create(:label, title: "label", color: "#FFAABB", project: project)
end
- let!(:label2) { create(:label, title: 'a-test', color: '#FFFFFF', project: project) }
+ let!(:label2) { create(:label, title: "a-test", color: "#FFFFFF", project: project) }
let!(:label_link) { create(:label_link, label: label, target: merge_request) }
let!(:label_link2) { create(:label_link, label: label2, target: merge_request) }
let!(:downvote) { create(:award_emoji, :downvote, awardable: merge_request) }
@@ -30,22 +30,22 @@ describe API::MergeRequests do
project.add_reporter(user)
end
- describe 'route shadowing' do
+ describe "route shadowing" do
include GrapePathHelpers::NamedRouteMatcher
- it 'does not occur' do
+ it "does not occur" do
path = api_v4_projects_merge_requests_path(id: 1)
- expect(path).to eq('/api/v4/projects/1/merge_requests')
+ expect(path).to eq("/api/v4/projects/1/merge_requests")
path = api_v4_projects_merge_requests_path(id: 1, merge_request_iid: 3)
- expect(path).to eq('/api/v4/projects/1/merge_requests/3')
+ expect(path).to eq("/api/v4/projects/1/merge_requests/3")
end
end
- describe 'GET /merge_requests' do
- context 'when unauthenticated' do
- it 'returns an array of all merge requests' do
- get api('/merge_requests', user), params: { scope: 'all' }
+ describe "GET /merge_requests" do
+ context "when unauthenticated" do
+ it "returns an array of all merge requests" do
+ get api("/merge_requests", user), params: {scope: "all"}
expect_paginated_array_response
end
@@ -57,41 +57,41 @@ describe API::MergeRequests do
end
it "returns authentication error when scope is assigned-to-me" do
- get api("/merge_requests"), params: { scope: 'assigned-to-me' }
+ get api("/merge_requests"), params: {scope: "assigned-to-me"}
expect(response).to have_gitlab_http_status(401)
end
it "returns authentication error when scope is assigned_to_me" do
- get api("/merge_requests"), params: { scope: 'assigned_to_me' }
+ get api("/merge_requests"), params: {scope: "assigned_to_me"}
expect(response).to have_gitlab_http_status(401)
end
it "returns authentication error when scope is created-by-me" do
- get api("/merge_requests"), params: { scope: 'created-by-me' }
+ get api("/merge_requests"), params: {scope: "created-by-me"}
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
+ context "when authenticated" do
let!(:project2) { create(:project, :public, namespace: user.namespace) }
let!(:merge_request2) { create(:merge_request, :simple, author: user, assignee: user, source_project: project2, target_project: project2) }
let(:user2) { create(:user) }
- it 'returns an array of all merge requests except unauthorized ones' do
- get api('/merge_requests', user), params: { scope: :all }
+ it "returns an array of all merge requests except unauthorized ones" do
+ get api("/merge_requests", user), params: {scope: :all}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |mr| mr['id'] })
+ expect(json_response.map { |mr| mr["id"] })
.to contain_exactly(merge_request.id, merge_request_closed.id, merge_request_merged.id, merge_request_locked.id, merge_request2.id)
end
it "returns an array of no merge_requests when wip=yes" do
- get api("/merge_requests", user), params: { wip: 'yes' }
+ get api("/merge_requests", user), params: {wip: "yes"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -100,188 +100,188 @@ describe API::MergeRequests do
end
it "returns an array of no merge_requests when wip=no" do
- get api("/merge_requests", user), params: { wip: 'no' }
+ get api("/merge_requests", user), params: {wip: "no"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |mr| mr['id'] })
- .to contain_exactly(merge_request.id, merge_request_closed.id, merge_request_merged.id, merge_request_locked.id, merge_request2.id)
+ expect(json_response.map { |mr| mr["id"] })
+ .to contain_exactly(merge_request.id, merge_request_closed.id, merge_request_merged.id, merge_request_locked.id, merge_request2.id)
end
- it 'does not return unauthorized merge requests' do
+ it "does not return unauthorized merge requests" do
private_project = create(:project, :private)
- merge_request3 = create(:merge_request, :simple, source_project: private_project, target_project: private_project, source_branch: 'other-branch')
+ merge_request3 = create(:merge_request, :simple, source_project: private_project, target_project: private_project, source_branch: "other-branch")
- get api('/merge_requests', user), params: { scope: :all }
+ get api("/merge_requests", user), params: {scope: :all}
expect_response_contain_exactly(merge_request2, merge_request_merged, merge_request_closed, merge_request, merge_request_locked)
- expect(json_response.map { |mr| mr['id'] }).not_to include(merge_request3.id)
+ expect(json_response.map { |mr| mr["id"] }).not_to include(merge_request3.id)
end
- it 'returns an array of merge requests created by current user if no scope is given' do
- merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests created by current user if no scope is given" do
+ merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user2)
+ get api("/merge_requests", user2)
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests authored by the given user' do
- merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests authored by the given user" do
+ merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user), params: { author_id: user2.id, scope: :all }
+ get api("/merge_requests", user), params: {author_id: user2.id, scope: :all}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests assigned to the given user' do
- merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests assigned to the given user" do
+ merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user), params: { assignee_id: user2.id, scope: :all }
+ get api("/merge_requests", user), params: {assignee_id: user2.id, scope: :all}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests with no assignee' do
- merge_request3 = create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests with no assignee" do
+ merge_request3 = create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user), params: { assignee_id: 'None', scope: :all }
+ get api("/merge_requests", user), params: {assignee_id: "None", scope: :all}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests with any assignee' do
+ it "returns an array of merge requests with any assignee" do
# This MR with no assignee should not be returned
- create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ create(:merge_request, :simple, author: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user), params: { assignee_id: 'Any', scope: :all }
+ get api("/merge_requests", user), params: {assignee_id: "Any", scope: :all}
expect_response_contain_exactly(merge_request, merge_request2, merge_request_closed, merge_request_merged, merge_request_locked)
end
- it 'returns an array of merge requests assigned to me' do
- merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests assigned to me" do
+ merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user2), params: { scope: 'assigned_to_me' }
+ get api("/merge_requests", user2), params: {scope: "assigned_to_me"}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests assigned to me (kebab-case)' do
- merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests assigned to me (kebab-case)" do
+ merge_request3 = create(:merge_request, :simple, author: user, assignee: user2, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user2), params: { scope: 'assigned-to-me' }
+ get api("/merge_requests", user2), params: {scope: "assigned-to-me"}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests created by me' do
- merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests created by me" do
+ merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user2), params: { scope: 'created_by_me' }
+ get api("/merge_requests", user2), params: {scope: "created_by_me"}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns an array of merge requests created by me (kebab-case)' do
- merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
+ it "returns an array of merge requests created by me (kebab-case)" do
+ merge_request3 = create(:merge_request, :simple, author: user2, assignee: user, source_project: project2, target_project: project2, source_branch: "other-branch")
- get api('/merge_requests', user2), params: { scope: 'created-by-me' }
+ get api("/merge_requests", user2), params: {scope: "created-by-me"}
expect_response_ordered_exactly(merge_request3)
end
- it 'returns merge requests reacted by the authenticated user by the given emoji' do
- merge_request3 = create(:merge_request, :simple, author: user, assignee: user, source_project: project2, target_project: project2, source_branch: 'other-branch')
- award_emoji = create(:award_emoji, awardable: merge_request3, user: user2, name: 'star')
+ it "returns merge requests reacted by the authenticated user by the given emoji" do
+ merge_request3 = create(:merge_request, :simple, author: user, assignee: user, source_project: project2, target_project: project2, source_branch: "other-branch")
+ award_emoji = create(:award_emoji, awardable: merge_request3, user: user2, name: "star")
- get api('/merge_requests', user2), params: { my_reaction_emoji: award_emoji.name, scope: 'all' }
+ get api("/merge_requests", user2), params: {my_reaction_emoji: award_emoji.name, scope: "all"}
expect_response_ordered_exactly(merge_request3)
end
- context 'source_branch param' do
- it 'returns merge requests with the given source branch' do
- get api('/merge_requests', user), params: { source_branch: merge_request_closed.source_branch, state: 'all' }
+ context "source_branch param" do
+ it "returns merge requests with the given source branch" do
+ get api("/merge_requests", user), params: {source_branch: merge_request_closed.source_branch, state: "all"}
expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked)
end
end
- context 'target_branch param' do
- it 'returns merge requests with the given target branch' do
- get api('/merge_requests', user), params: { target_branch: merge_request_closed.target_branch, state: 'all' }
+ context "target_branch param" do
+ it "returns merge requests with the given target branch" do
+ get api("/merge_requests", user), params: {target_branch: merge_request_closed.target_branch, state: "all"}
expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked)
end
end
- it 'returns merge requests created before a specific date' do
- merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: 'feature_1', created_at: Date.new(2000, 1, 1))
+ it "returns merge requests created before a specific date" do
+ merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: "feature_1", created_at: Date.new(2000, 1, 1))
- get api('/merge_requests?created_before=2000-01-02T00:00:00.060Z', user)
+ get api("/merge_requests?created_before=2000-01-02T00:00:00.060Z", user)
expect_response_ordered_exactly(merge_request2)
end
- it 'returns merge requests created after a specific date' do
- merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: 'feature_1', created_at: 1.week.from_now)
+ it "returns merge requests created after a specific date" do
+ merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: "feature_1", created_at: 1.week.from_now)
get api("/merge_requests?created_after=#{merge_request2.created_at}", user)
expect_response_ordered_exactly(merge_request2)
end
- it 'returns merge requests updated before a specific date' do
- merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: 'feature_1', updated_at: Date.new(2000, 1, 1))
+ it "returns merge requests updated before a specific date" do
+ merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: "feature_1", updated_at: Date.new(2000, 1, 1))
- get api('/merge_requests?updated_before=2000-01-02T00:00:00.060Z', user)
+ get api("/merge_requests?updated_before=2000-01-02T00:00:00.060Z", user)
expect_response_ordered_exactly(merge_request2)
end
- it 'returns merge requests updated after a specific date' do
- merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: 'feature_1', updated_at: 1.week.from_now)
+ it "returns merge requests updated after a specific date" do
+ merge_request2 = create(:merge_request, :simple, source_project: project, target_project: project, source_branch: "feature_1", updated_at: 1.week.from_now)
get api("/merge_requests?updated_after=#{merge_request2.updated_at}", user)
expect_response_ordered_exactly(merge_request2)
end
- context 'search params' do
+ context "search params" do
before do
- merge_request.update(title: 'Search title', description: 'Search description')
+ merge_request.update(title: "Search title", description: "Search description")
end
- it 'returns merge requests matching given search string for title' do
- get api("/merge_requests", user), params: { search: merge_request.title }
+ it "returns merge requests matching given search string for title" do
+ get api("/merge_requests", user), params: {search: merge_request.title}
expect_response_ordered_exactly(merge_request)
end
- it 'returns merge requests matching given search string for title and scoped in title' do
- get api("/merge_requests", user), params: { search: merge_request.title, in: 'title' }
+ it "returns merge requests matching given search string for title and scoped in title" do
+ get api("/merge_requests", user), params: {search: merge_request.title, in: "title"}
expect_response_ordered_exactly(merge_request)
end
- it 'returns an empty array if no merge reques matches given search string for description and scoped in title' do
- get api("/merge_requests", user), params: { search: merge_request.description, in: 'title' }
+ it "returns an empty array if no merge reques matches given search string for description and scoped in title" do
+ get api("/merge_requests", user), params: {search: merge_request.description, in: "title"}
expect_response_contain_exactly
end
- it 'returns merge requests for project matching given search string for description' do
- get api("/merge_requests", user), params: { project_id: project.id, search: merge_request.description }
+ it "returns merge requests for project matching given search string for description" do
+ get api("/merge_requests", user), params: {project_id: project.id, search: merge_request.description}
expect_response_ordered_exactly(merge_request)
end
end
- context 'state param' do
- it 'returns merge requests with the given state' do
- get api('/merge_requests', user), params: { state: 'locked' }
+ context "state param" do
+ it "returns merge requests with the given state" do
+ get api("/merge_requests", user), params: {state: "locked"}
expect_response_contain_exactly(merge_request_locked)
end
@@ -292,7 +292,7 @@ describe API::MergeRequests do
describe "GET /projects/:id/merge_requests" do
let(:endpoint_path) { "/projects/#{project.id}/merge_requests" }
- it_behaves_like 'merge requests list'
+ it_behaves_like "merge requests list"
it "returns 404 for non public projects" do
project = create(:project, :private)
@@ -303,7 +303,7 @@ describe API::MergeRequests do
end
it "returns an array of no merge_requests when wip=yes" do
- get api("/projects/#{project.id}/merge_requests", user), params: { wip: 'yes' }
+ get api("/projects/#{project.id}/merge_requests", user), params: {wip: "yes"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -312,25 +312,25 @@ describe API::MergeRequests do
end
it 'returns merge_request by "iids" array' do
- get api(endpoint_path, user), params: { iids: [merge_request.iid, merge_request_closed.iid] }
+ get api(endpoint_path, user), params: {iids: [merge_request.iid, merge_request_closed.iid]}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- expect(json_response.first['title']).to eq merge_request_closed.title
- expect(json_response.first['id']).to eq merge_request_closed.id
+ expect(json_response.first["title"]).to eq merge_request_closed.title
+ expect(json_response.first["id"]).to eq merge_request_closed.id
end
- it 'avoids N+1 queries' do
- control = ActiveRecord::QueryRecorder.new do
+ it "avoids N+1 queries" do
+ control = ActiveRecord::QueryRecorder.new {
get api("/projects/#{project.id}/merge_requests", user)
- end.count
+ }.count
create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, created_at: base_time)
- expect do
+ expect {
get api("/projects/#{project.id}/merge_requests", user)
- end.not_to exceed_query_limit(control)
+ }.not_to exceed_query_limit(control)
end
end
@@ -343,68 +343,68 @@ describe API::MergeRequests do
group.add_reporter(user)
end
- it_behaves_like 'merge requests list'
+ it_behaves_like "merge requests list"
- context 'when have subgroups', :nested_groups do
+ context "when have subgroups", :nested_groups do
let!(:group) { create(:group, :public) }
let!(:subgroup) { create(:group, parent: group) }
let!(:project) { create(:project, :public, :repository, creator: user, namespace: subgroup, only_allow_merge_if_pipeline_succeeds: false) }
- it_behaves_like 'merge requests list'
+ it_behaves_like "merge requests list"
end
end
describe "GET /projects/:id/merge_requests/:merge_request_iid" do
- it 'exposes known attributes' do
+ it "exposes known attributes" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(merge_request.id)
- expect(json_response['iid']).to eq(merge_request.iid)
- expect(json_response['project_id']).to eq(merge_request.project.id)
- expect(json_response['title']).to eq(merge_request.title)
- expect(json_response['description']).to eq(merge_request.description)
- expect(json_response['state']).to eq(merge_request.state)
- expect(json_response['created_at']).to be_present
- expect(json_response['updated_at']).to be_present
- expect(json_response['labels']).to eq(merge_request.label_names)
- expect(json_response['milestone']).to be_a Hash
- expect(json_response['assignee']).to be_a Hash
- expect(json_response['author']).to be_a Hash
- expect(json_response['target_branch']).to eq(merge_request.target_branch)
- expect(json_response['source_branch']).to eq(merge_request.source_branch)
- expect(json_response['upvotes']).to eq(1)
- expect(json_response['downvotes']).to eq(1)
- expect(json_response['source_project_id']).to eq(merge_request.source_project.id)
- expect(json_response['target_project_id']).to eq(merge_request.target_project.id)
- expect(json_response['work_in_progress']).to be_falsy
- expect(json_response['merge_when_pipeline_succeeds']).to be_falsy
- expect(json_response['merge_status']).to eq('can_be_merged')
- expect(json_response['should_close_merge_request']).to be_falsy
- expect(json_response['force_close_merge_request']).to be_falsy
- expect(json_response['changes_count']).to eq(merge_request.merge_request_diff.real_size)
- expect(json_response['merge_error']).to eq(merge_request.merge_error)
- expect(json_response['user']['can_merge']).to be_truthy
- expect(json_response).not_to include('rebase_in_progress')
- end
-
- it 'exposes description and title html when render_html is true' do
- get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { render_html: true }
+ expect(json_response["id"]).to eq(merge_request.id)
+ expect(json_response["iid"]).to eq(merge_request.iid)
+ expect(json_response["project_id"]).to eq(merge_request.project.id)
+ expect(json_response["title"]).to eq(merge_request.title)
+ expect(json_response["description"]).to eq(merge_request.description)
+ expect(json_response["state"]).to eq(merge_request.state)
+ expect(json_response["created_at"]).to be_present
+ expect(json_response["updated_at"]).to be_present
+ expect(json_response["labels"]).to eq(merge_request.label_names)
+ expect(json_response["milestone"]).to be_a Hash
+ expect(json_response["assignee"]).to be_a Hash
+ expect(json_response["author"]).to be_a Hash
+ expect(json_response["target_branch"]).to eq(merge_request.target_branch)
+ expect(json_response["source_branch"]).to eq(merge_request.source_branch)
+ expect(json_response["upvotes"]).to eq(1)
+ expect(json_response["downvotes"]).to eq(1)
+ expect(json_response["source_project_id"]).to eq(merge_request.source_project.id)
+ expect(json_response["target_project_id"]).to eq(merge_request.target_project.id)
+ expect(json_response["work_in_progress"]).to be_falsy
+ expect(json_response["merge_when_pipeline_succeeds"]).to be_falsy
+ expect(json_response["merge_status"]).to eq("can_be_merged")
+ expect(json_response["should_close_merge_request"]).to be_falsy
+ expect(json_response["force_close_merge_request"]).to be_falsy
+ expect(json_response["changes_count"]).to eq(merge_request.merge_request_diff.real_size)
+ expect(json_response["merge_error"]).to eq(merge_request.merge_error)
+ expect(json_response["user"]["can_merge"]).to be_truthy
+ expect(json_response).not_to include("rebase_in_progress")
+ end
+
+ it "exposes description and title html when render_html is true" do
+ get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {render_html: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('title_html', 'description_html')
+ expect(json_response).to include("title_html", "description_html")
end
- it 'exposes rebase_in_progress when include_rebase_in_progress is true' do
- get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { include_rebase_in_progress: true }
+ it "exposes rebase_in_progress when include_rebase_in_progress is true" do
+ get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {include_rebase_in_progress: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('rebase_in_progress')
+ expect(json_response).to include("rebase_in_progress")
end
- context 'merge_request_metrics' do
+ context "merge_request_metrics" do
before do
merge_request.metrics.update!(merged_by: user,
latest_closed_by: user,
@@ -416,40 +416,40 @@ describe API::MergeRequests do
first_deployed_to_production_at: 3.minutes.ago)
end
- it 'has fields from merge request metrics' do
+ it "has fields from merge request metrics" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user)
- expect(json_response).to include('merged_by',
- 'merged_at',
- 'closed_by',
- 'closed_at',
- 'latest_build_started_at',
- 'latest_build_finished_at',
- 'first_deployed_to_production_at',
- 'pipeline')
+ expect(json_response).to include("merged_by",
+ "merged_at",
+ "closed_by",
+ "closed_at",
+ "latest_build_started_at",
+ "latest_build_finished_at",
+ "first_deployed_to_production_at",
+ "pipeline")
end
- it 'returns correct values' do
+ it "returns correct values" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.reload.iid}", user)
- expect(json_response['merged_by']['id']).to eq(merge_request.metrics.merged_by_id)
- expect(Time.parse json_response['merged_at']).to be_like_time(merge_request.metrics.merged_at)
- expect(json_response['closed_by']['id']).to eq(merge_request.metrics.latest_closed_by_id)
- expect(Time.parse json_response['closed_at']).to be_like_time(merge_request.metrics.latest_closed_at)
- expect(json_response['pipeline']['id']).to eq(merge_request.metrics.pipeline_id)
- expect(Time.parse json_response['latest_build_started_at']).to be_like_time(merge_request.metrics.latest_build_started_at)
- expect(Time.parse json_response['latest_build_finished_at']).to be_like_time(merge_request.metrics.latest_build_finished_at)
- expect(Time.parse json_response['first_deployed_to_production_at']).to be_like_time(merge_request.metrics.first_deployed_to_production_at)
+ expect(json_response["merged_by"]["id"]).to eq(merge_request.metrics.merged_by_id)
+ expect(Time.parse(json_response["merged_at"])).to be_like_time(merge_request.metrics.merged_at)
+ expect(json_response["closed_by"]["id"]).to eq(merge_request.metrics.latest_closed_by_id)
+ expect(Time.parse(json_response["closed_at"])).to be_like_time(merge_request.metrics.latest_closed_at)
+ expect(json_response["pipeline"]["id"]).to eq(merge_request.metrics.pipeline_id)
+ expect(Time.parse(json_response["latest_build_started_at"])).to be_like_time(merge_request.metrics.latest_build_started_at)
+ expect(Time.parse(json_response["latest_build_finished_at"])).to be_like_time(merge_request.metrics.latest_build_finished_at)
+ expect(Time.parse(json_response["first_deployed_to_production_at"])).to be_like_time(merge_request.metrics.first_deployed_to_production_at)
end
end
- it 'returns the commits behind the target branch when include_diverged_commits_count is present' do
+ it "returns the commits behind the target branch when include_diverged_commits_count is present" do
allow_any_instance_of(merge_request.class).to receive(:diverged_commits_count).and_return(1)
- get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { include_diverged_commits_count: true }
+ get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {include_diverged_commits_count: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['diverged_commits_count']).to eq(1)
+ expect(json_response["diverged_commits_count"]).to eq(1)
end
it "returns a 404 error if merge_request_iid not found" do
@@ -463,74 +463,74 @@ describe API::MergeRequests do
expect(response).to have_gitlab_http_status(404)
end
- context 'Work in Progress' 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 "returns merge request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request_wip.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['work_in_progress']).to eq(true)
+ expect(json_response["work_in_progress"]).to eq(true)
end
end
- context 'when a merge request has more than the changes limit' do
+ context "when a merge request has more than the changes limit" do
it "returns a string indicating that more changes were made" do
- stub_const('Commit::DIFF_HARD_LIMIT_FILES', 5)
+ stub_const("Commit::DIFF_HARD_LIMIT_FILES", 5)
merge_request_overflow = create(:merge_request, :simple,
- author: user,
- assignee: user,
- source_project: project,
- source_branch: 'expand-collapse-files',
- target_project: project,
- target_branch: 'master')
+ author: user,
+ assignee: user,
+ source_project: project,
+ source_branch: "expand-collapse-files",
+ target_project: project,
+ target_branch: "master")
get api("/projects/#{project.id}/merge_requests/#{merge_request_overflow.iid}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['changes_count']).to eq('5+')
+ expect(json_response["changes_count"]).to eq("5+")
end
end
- context 'for forked projects' do
+ context "for forked projects" do
let(:user2) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let(:forked_project) { fork_project(project, user2, repository: true) }
let(:merge_request) do
create(:merge_request,
- source_project: forked_project,
- target_project: project,
- source_branch: 'fixes',
- allow_collaboration: true)
+ source_project: forked_project,
+ target_project: project,
+ source_branch: "fixes",
+ allow_collaboration: true)
end
- it 'includes the `allow_collaboration` field' do
+ it "includes the `allow_collaboration` field" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user)
- expect(json_response['allow_collaboration']).to be_truthy
- expect(json_response['allow_maintainer_to_push']).to be_truthy
+ expect(json_response["allow_collaboration"]).to be_truthy
+ expect(json_response["allow_maintainer_to_push"]).to be_truthy
end
end
- it 'indicates if a user cannot merge the MR' do
+ it "indicates if a user cannot merge the MR" do
user2 = create(:user)
project.add_reporter(user2)
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user2)
- expect(json_response['user']['can_merge']).to be_falsy
+ expect(json_response["user"]["can_merge"]).to be_falsy
end
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/participants' do
- it_behaves_like 'issuable participants endpoint' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/participants" do
+ it_behaves_like "issuable participants endpoint" do
let(:entity) { merge_request }
end
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/commits' do
- it 'returns a 200 when merge request is valid' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/commits" do
+ it "returns a 200 when merge request is valid" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/commits", user)
commit = merge_request.commits.first
@@ -538,73 +538,73 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(merge_request.commits.size)
- expect(json_response.first['id']).to eq(commit.id)
- expect(json_response.first['title']).to eq(commit.title)
+ expect(json_response.first["id"]).to eq(commit.id)
+ expect(json_response.first["title"]).to eq(commit.title)
end
- it 'returns a 404 when merge_request_iid not found' do
+ it "returns a 404 when merge_request_iid not found" do
get api("/projects/#{project.id}/merge_requests/0/commits", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when merge_request id is used instead of iid' do
+ it "returns a 404 when merge_request id is used instead of iid" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/commits", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/changes' do
- it 'returns the change information of the merge_request' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/changes" do
+ it "returns the change information of the merge_request" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/changes", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['changes'].size).to eq(merge_request.diffs.size)
+ expect(json_response["changes"].size).to eq(merge_request.diffs.size)
end
- it 'returns a 404 when merge_request_iid not found' do
+ it "returns a 404 when merge_request_iid not found" do
get api("/projects/#{project.id}/merge_requests/0/changes", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when merge_request id is used instead of iid' do
+ it "returns a 404 when merge_request id is used instead of iid" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.id}/changes", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET /projects/:id/merge_requests/:merge_request_iid/pipelines' do
- context 'when authorized' do
+ describe "GET /projects/:id/merge_requests/:merge_request_iid/pipelines" do
+ context "when authorized" do
let!(:pipeline) { create(:ci_empty_pipeline, project: project, user: user, ref: merge_request.source_branch, sha: merge_request.diff_head_sha) }
let!(:pipeline2) { create(:ci_empty_pipeline, project: project) }
- it 'returns a paginated array of corresponding pipelines' do
+ it "returns a paginated array of corresponding pipelines" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/pipelines")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.count).to eq(1)
- expect(json_response.first['id']).to eq(pipeline.id)
+ expect(json_response.first["id"]).to eq(pipeline.id)
end
- it 'exposes basic attributes' do
+ it "exposes basic attributes" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/pipelines")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pipelines')
+ expect(response).to match_response_schema("public_api/v4/pipelines")
end
- it 'returns 404 if MR does not exist' do
+ it "returns 404 if MR does not exist" do
get api("/projects/#{project.id}/merge_requests/777/pipelines")
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when unauthorized' do
- it 'returns 403' do
+ context "when unauthorized" do
+ it "returns 403" do
project = create(:project, public_builds: false)
merge_request = create(:merge_request, :simple, source_project: project)
guest = create(:user)
@@ -618,117 +618,117 @@ describe API::MergeRequests do
end
describe "POST /projects/:id/merge_requests" do
- context 'between branches projects' do
+ context "between branches projects" do
it "returns merge_request" do
post api("/projects/#{project.id}/merge_requests", user),
- params: {
- title: 'Test merge_request',
- source_branch: 'feature_conflict',
- target_branch: 'master',
- author: user,
- labels: 'label, label2',
- milestone_id: milestone.id,
- squash: true
- }
+ params: {
+ title: "Test merge_request",
+ source_branch: "feature_conflict",
+ target_branch: "master",
+ author: user,
+ labels: "label, label2",
+ milestone_id: milestone.id,
+ squash: true,
+ }
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('Test merge_request')
- expect(json_response['labels']).to eq(%w(label label2))
- expect(json_response['milestone']['id']).to eq(milestone.id)
- expect(json_response['squash']).to be_truthy
- expect(json_response['force_remove_source_branch']).to be_falsy
+ expect(json_response["title"]).to eq("Test merge_request")
+ expect(json_response["labels"]).to eq(%w[label label2])
+ expect(json_response["milestone"]["id"]).to eq(milestone.id)
+ expect(json_response["squash"]).to be_truthy
+ expect(json_response["force_remove_source_branch"]).to be_falsy
end
it "returns 422 when source_branch equals target_branch" do
post api("/projects/#{project.id}/merge_requests", user),
- params: { title: "Test merge_request", source_branch: "master", target_branch: "master", author: user }
+ params: {title: "Test merge_request", source_branch: "master", target_branch: "master", author: user}
expect(response).to have_gitlab_http_status(422)
end
it "returns 400 when source_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
- params: { title: "Test merge_request", target_branch: "master", author: user }
+ params: {title: "Test merge_request", target_branch: "master", author: user}
expect(response).to have_gitlab_http_status(400)
end
it "returns 400 when target_branch is missing" do
post api("/projects/#{project.id}/merge_requests", user),
- params: { title: "Test merge_request", source_branch: "markdown", author: user }
+ params: {title: "Test merge_request", source_branch: "markdown", author: user}
expect(response).to have_gitlab_http_status(400)
end
it "returns 400 when title is missing" do
post api("/projects/#{project.id}/merge_requests", user),
- params: { target_branch: 'master', source_branch: 'markdown' }
+ params: {target_branch: "master", source_branch: "markdown"}
expect(response).to have_gitlab_http_status(400)
end
- it 'allows special label names' do
+ it "allows special label names" do
post api("/projects/#{project.id}/merge_requests", user),
- params: {
- title: 'Test merge_request',
- source_branch: 'markdown',
- target_branch: 'master',
- author: user,
- labels: 'label, label?, label&foo, ?, &'
- }
+ params: {
+ title: "Test merge_request",
+ source_branch: "markdown",
+ target_branch: "master",
+ author: user,
+ labels: "label, label?, label&foo, ?, &",
+ }
expect(response).to have_gitlab_http_status(201)
- expect(json_response['labels']).to include 'label'
- expect(json_response['labels']).to include 'label?'
- expect(json_response['labels']).to include 'label&foo'
- expect(json_response['labels']).to include '?'
- expect(json_response['labels']).to include '&'
+ expect(json_response["labels"]).to include "label"
+ expect(json_response["labels"]).to include "label?"
+ expect(json_response["labels"]).to include "label&foo"
+ expect(json_response["labels"]).to include "?"
+ expect(json_response["labels"]).to include "&"
end
- context 'with existing MR' do
+ context "with existing MR" do
before do
post api("/projects/#{project.id}/merge_requests", user),
- params: {
- title: 'Test merge_request',
- source_branch: 'feature_conflict',
- target_branch: 'master',
- author: user
- }
+ params: {
+ title: "Test merge_request",
+ source_branch: "feature_conflict",
+ target_branch: "master",
+ author: user,
+ }
@mr = MergeRequest.all.last
end
- it 'returns 409 when MR already exists for source/target' do
- expect do
+ it "returns 409 when MR already exists for source/target" do
+ expect {
post api("/projects/#{project.id}/merge_requests", user),
- params: {
- title: 'New test merge_request',
- source_branch: 'feature_conflict',
- target_branch: 'master',
- author: user
- }
- end.to change { MergeRequest.count }.by(0)
+ params: {
+ title: "New test merge_request",
+ source_branch: "feature_conflict",
+ target_branch: "master",
+ author: user,
+ }
+ }.to change { MergeRequest.count }.by(0)
expect(response).to have_gitlab_http_status(409)
end
end
- context 'accepts remove_source_branch parameter' do
+ context "accepts remove_source_branch parameter" do
let(:params) do
- { title: 'Test merge_request',
- source_branch: 'markdown',
- target_branch: 'master',
- author: user }
+ {title: "Test merge_request",
+ source_branch: "markdown",
+ target_branch: "master",
+ author: user,}
end
- it 'sets force_remove_source_branch to false' do
+ it "sets force_remove_source_branch to false" do
post api("/projects/#{project.id}/merge_requests", user), params: params.merge(remove_source_branch: false)
- expect(json_response['force_remove_source_branch']).to be_falsy
+ expect(json_response["force_remove_source_branch"]).to be_falsy
end
- it 'sets force_remove_source_branch to true' do
+ it "sets force_remove_source_branch to true" do
post api("/projects/#{project.id}/merge_requests", user), params: params.merge(remove_source_branch: true)
- expect(json_response['force_remove_source_branch']).to be_truthy
+ expect(json_response["force_remove_source_branch"]).to be_truthy
end
end
end
- context 'forked projects' do
+ context "forked projects" do
let!(:user2) { create(:user) }
let(:project) { create(:project, :public, :repository) }
let!(:forked_project) { fork_project(project, user2, repository: true) }
@@ -740,10 +740,10 @@ describe API::MergeRequests do
it "returns merge_request" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { 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' }
+ params: {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"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('Test merge_request')
- expect(json_response['description']).to eq('Test description for Test merge_request')
+ expect(json_response["title"]).to eq("Test merge_request")
+ expect(json_response["description"]).to eq("Test description for Test merge_request")
end
it "does not return 422 when source_branch equals target_branch" do
@@ -751,62 +751,62 @@ describe API::MergeRequests do
expect(forked_project.forked?).to be_truthy
expect(forked_project.forked_from_project).to eq(project)
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { title: 'Test merge_request', source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id }
+ params: {title: "Test merge_request", source_branch: "master", target_branch: "master", author: user2, target_project_id: project.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('Test merge_request')
+ expect(json_response["title"]).to eq("Test merge_request")
end
- it 'returns 403 when target project has disabled merge requests' do
+ it "returns 403 when target project has disabled merge requests" do
project.project_feature.update(merge_requests_access_level: 0)
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: {
- title: 'Test',
- target_branch: 'master',
- source_branch: 'markdown',
- author: user2,
- target_project_id: project.id
- }
+ params: {
+ title: "Test",
+ target_branch: "master",
+ source_branch: "markdown",
+ author: user2,
+ target_project_id: project.id,
+ }
expect(response).to have_gitlab_http_status(403)
end
it "returns 400 when source_branch is missing" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id }
+ params: {title: "Test merge_request", target_branch: "master", author: user2, target_project_id: project.id}
expect(response).to have_gitlab_http_status(400)
end
it "returns 400 when target_branch is missing" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { title: 'Test merge_request', target_branch: "master", author: user2, target_project_id: project.id }
+ params: {title: "Test merge_request", target_branch: "master", author: user2, target_project_id: project.id}
expect(response).to have_gitlab_http_status(400)
end
it "returns 400 when title is missing" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: project.id }
+ params: {target_branch: "master", source_branch: "markdown", author: user2, target_project_id: project.id}
expect(response).to have_gitlab_http_status(400)
end
- it 'allows setting `allow_collaboration`' do
+ it "allows setting `allow_collaboration`" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { title: 'Test merge_request', source_branch: "feature_conflict", target_branch: "master", author: user2, target_project_id: project.id, allow_collaboration: true }
+ params: {title: "Test merge_request", source_branch: "feature_conflict", target_branch: "master", author: user2, target_project_id: project.id, allow_collaboration: true}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['allow_collaboration']).to be_truthy
- expect(json_response['allow_maintainer_to_push']).to be_truthy
+ expect(json_response["allow_collaboration"]).to be_truthy
+ expect(json_response["allow_maintainer_to_push"]).to be_truthy
end
- context 'when target_branch and target_project_id is specified' do
+ context "when target_branch and target_project_id is specified" do
let(:params) do
- { title: 'Test merge_request',
- target_branch: 'master',
- source_branch: 'markdown',
- author: user2,
- target_project_id: unrelated_project.id }
+ {title: "Test merge_request",
+ target_branch: "master",
+ source_branch: "markdown",
+ author: user2,
+ target_project_id: unrelated_project.id,}
end
- it 'returns 422 if targeting a different fork' do
+ it "returns 422 if targeting a different fork" do
unrelated_project.add_developer(user2)
post api("/projects/#{forked_project.id}/merge_requests", user2), params: params
@@ -814,7 +814,7 @@ describe API::MergeRequests do
expect(response).to have_gitlab_http_status(422)
end
- it 'returns 403 if targeting a different fork which user can not access' do
+ it "returns 403 if targeting a different fork which user can not access" do
post api("/projects/#{forked_project.id}/merge_requests", user2), params: params
expect(response).to have_gitlab_http_status(403)
@@ -823,7 +823,7 @@ describe API::MergeRequests do
it "returns 201 when target_branch is specified and for the same project" do
post api("/projects/#{forked_project.id}/merge_requests", user2),
- params: { title: 'Test merge_request', target_branch: 'master', source_branch: 'markdown', author: user2, target_project_id: forked_project.id }
+ params: {title: "Test merge_request", target_branch: "master", source_branch: "markdown", author: user2, target_project_id: forked_project.id}
expect(response).to have_gitlab_http_status(201)
end
end
@@ -862,7 +862,7 @@ describe API::MergeRequests do
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user) }
end
end
@@ -884,30 +884,30 @@ describe API::MergeRequests do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(406)
- expect(json_response['message']).to eq('Branch cannot be merged')
+ expect(json_response["message"]).to eq("Branch cannot be merged")
end
it "returns 405 if merge_request is not open" do
merge_request.close
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(405)
- expect(json_response['message']).to eq('405 Method Not Allowed')
+ expect(json_response["message"]).to eq("405 Method Not Allowed")
end
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.iid}/merge", user)
expect(response).to have_gitlab_http_status(405)
- expect(json_response['message']).to eq('405 Method Not Allowed')
+ expect(json_response["message"]).to eq("405 Method Not Allowed")
end
- it 'returns 405 if the build failed for a merge request that requires success' do
+ it "returns 405 if the build failed for a merge request that requires success" do
allow_any_instance_of(MergeRequest).to receive(:mergeable_ci_state?).and_return(false)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user)
expect(response).to have_gitlab_http_status(405)
- expect(json_response['message']).to eq('405 Method Not Allowed')
+ expect(json_response["message"]).to eq("405 Method Not Allowed")
end
it "returns 401 if user has no permissions to merge" do
@@ -915,26 +915,26 @@ describe API::MergeRequests do
project.add_reporter(user2)
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user2)
expect(response).to have_gitlab_http_status(401)
- expect(json_response['message']).to eq('401 Unauthorized')
+ expect(json_response["message"]).to eq("401 Unauthorized")
end
it "returns 409 if the SHA parameter doesn't match" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { sha: merge_request.diff_head_sha.reverse }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {sha: merge_request.diff_head_sha.reverse}
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to start_with('SHA does not match HEAD of source branch')
+ expect(json_response["message"]).to start_with("SHA does not match HEAD of source branch")
end
it "succeeds if the SHA parameter matches" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { sha: merge_request.diff_head_sha }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {sha: merge_request.diff_head_sha}
expect(response).to have_gitlab_http_status(200)
end
it "updates the MR's squash attribute" do
- expect do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { squash: true }
- end.to change { merge_request.reload.squash }
+ expect {
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {squash: true}
+ }.to change { merge_request.reload.squash }
expect(response).to have_gitlab_http_status(200)
end
@@ -943,11 +943,11 @@ describe API::MergeRequests do
allow_any_instance_of(MergeRequest).to receive(:head_pipeline).and_return(pipeline)
allow(pipeline).to receive(:active?).and_return(true)
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { merge_when_pipeline_succeeds: true }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {merge_when_pipeline_succeeds: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('Test')
- expect(json_response['merge_when_pipeline_succeeds']).to eq(true)
+ expect(json_response["title"]).to eq("Test")
+ expect(json_response["merge_when_pipeline_succeeds"]).to eq(true)
end
it "enables merge when pipeline succeeds if the pipeline is active and only_allow_merge_if_pipeline_succeeds is true" do
@@ -955,11 +955,11 @@ describe API::MergeRequests do
allow(pipeline).to receive(:active?).and_return(true)
project.update_attribute(:only_allow_merge_if_pipeline_succeeds, true)
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { merge_when_pipeline_succeeds: true }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {merge_when_pipeline_succeeds: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('Test')
- expect(json_response['merge_when_pipeline_succeeds']).to eq(true)
+ expect(json_response["title"]).to eq("Test")
+ expect(json_response["merge_when_pipeline_succeeds"]).to eq(true)
end
it "returns 404 for an invalid merge request IID" do
@@ -976,22 +976,22 @@ describe API::MergeRequests do
describe "the squash_commit_message param" do
let(:squash_commit) do
- project.repository.commits_between(json_response['diff_refs']['start_sha'], json_response['merge_commit_sha']).first
+ project.repository.commits_between(json_response["diff_refs"]["start_sha"], json_response["merge_commit_sha"]).first
end
it "results in a specific squash commit message when set" do
- squash_commit_message = 'My custom squash commit message'
+ squash_commit_message = "My custom squash commit message"
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {
squash: true,
- squash_commit_message: squash_commit_message
+ squash_commit_message: squash_commit_message,
}
expect(squash_commit.message.chomp).to eq(squash_commit_message)
end
it "results in a default squash commit message when not set" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: { squash: true }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user), params: {squash: true}
expect(squash_commit.message).to eq(merge_request.default_squash_commit_message)
end
@@ -1001,10 +1001,10 @@ describe API::MergeRequests do
let(:source_repository) { merge_request.source_project.repository }
let(:source_branch) { merge_request.source_branch }
- it 'removes the source branch when set' do
+ it "removes the source branch when set" do
put(
api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge", user),
- params: { should_remove_source_branch: true }
+ params: {should_remove_source_branch: true}
)
expect(response).to have_gitlab_http_status(200)
@@ -1019,37 +1019,37 @@ describe API::MergeRequests do
"/projects/#{project.id}/merge_requests/#{merge_request.iid}/merge_to_ref"
end
- it 'returns the generated ID from the merge service in case of success' do
- put api(url, user), params: { merge_commit_message: 'Custom message' }
+ it "returns the generated ID from the merge service in case of success" do
+ put api(url, user), params: {merge_commit_message: "Custom message"}
- commit = project.commit(json_response['commit_id'])
+ commit = project.commit(json_response["commit_id"])
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commit_id']).to be_present
- expect(commit.message).to eq('Custom message')
+ expect(json_response["commit_id"]).to be_present
+ expect(commit.message).to eq("Custom message")
end
it "returns 400 if branch can't be merged" do
- merge_request.update!(state: 'merged')
+ merge_request.update!(state: "merged")
put api(url, user)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message'])
+ expect(json_response["message"])
.to eq("Merge request is not mergeable to #{merge_request.merge_ref_path}")
end
- it 'returns 403 if user has no permissions to merge to the ref' do
+ it "returns 403 if user has no permissions to merge to the ref" do
user2 = create(:user)
project.add_reporter(user2)
put api(url, user2)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it 'returns 404 for an invalid merge request IID' do
+ it "returns 404 for an invalid merge request IID" do
put api("/projects/#{project.id}/merge_requests/12345/merge_to_ref", user)
expect(response).to have_gitlab_http_status(404)
@@ -1062,112 +1062,112 @@ describe API::MergeRequests do
end
it "returns 400 when merge method is not supported" do
- merge_request.project.update!(merge_method: 'ff')
+ merge_request.project.update!(merge_method: "ff")
put api(url, user)
expected_error =
- 'Fast-forward to refs/merge-requests/1/merge is currently not supported.'
+ "Fast-forward to refs/merge-requests/1/merge is currently not supported."
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq(expected_error)
+ expect(json_response["message"]).to eq(expected_error)
end
end
describe "PUT /projects/:id/merge_requests/:merge_request_iid" do
context "to close a MR" do
it "returns merge_request" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: "close" }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {state_event: "close"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['state']).to eq('closed')
+ expect(json_response["state"]).to eq("closed")
end
end
it "updates title and returns merge_request" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { title: "New title" }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {title: "New title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('New title')
+ expect(json_response["title"]).to eq("New title")
end
it "updates description and returns merge_request" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { description: "New description" }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {description: "New description"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['description']).to eq('New description')
+ expect(json_response["description"]).to eq("New description")
end
it "updates milestone_id and returns merge_request" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { milestone_id: milestone.id }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {milestone_id: milestone.id}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['milestone']['id']).to eq(milestone.id)
+ expect(json_response["milestone"]["id"]).to eq(milestone.id)
end
it "updates squash and returns merge_request" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { squash: true }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {squash: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['squash']).to be_truthy
+ expect(json_response["squash"]).to be_truthy
end
it "returns merge_request with renamed target_branch" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { target_branch: "wiki" }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {target_branch: "wiki"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['target_branch']).to eq('wiki')
+ expect(json_response["target_branch"]).to eq("wiki")
end
it "returns merge_request that removes the source branch" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { remove_source_branch: true }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {remove_source_branch: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['force_remove_source_branch']).to be_truthy
+ expect(json_response["force_remove_source_branch"]).to be_truthy
end
- it 'allows special label names' do
+ it "allows special label names" do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user),
params: {
- title: 'new issue',
- labels: 'label, label?, label&foo, ?, &'
+ title: "new issue",
+ labels: "label, label?, label&foo, ?, &",
}
expect(response.status).to eq(200)
- expect(json_response['labels']).to include 'label'
- expect(json_response['labels']).to include 'label?'
- expect(json_response['labels']).to include 'label&foo'
- expect(json_response['labels']).to include '?'
- expect(json_response['labels']).to include '&'
+ expect(json_response["labels"]).to include "label"
+ expect(json_response["labels"]).to include "label?"
+ expect(json_response["labels"]).to include "label&foo"
+ expect(json_response["labels"]).to include "?"
+ expect(json_response["labels"]).to include "&"
end
- it 'does not update state when title is empty' do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: 'close', title: nil }
+ it "does not update state when title is empty" do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {state_event: "close", title: nil}
merge_request.reload
expect(response).to have_gitlab_http_status(400)
- expect(merge_request.state).to eq('opened')
+ expect(merge_request.state).to eq("opened")
end
- it 'does not update state when target_branch is empty' do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: { state_event: 'close', target_branch: nil }
+ it "does not update state when target_branch is empty" do
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}", user), params: {state_event: "close", target_branch: nil}
merge_request.reload
expect(response).to have_gitlab_http_status(400)
- expect(merge_request.state).to eq('opened')
+ expect(merge_request.state).to eq("opened")
end
it "returns 404 for an invalid merge request IID" do
- put api("/projects/#{project.id}/merge_requests/12345", user), params: { state_event: "close" }
+ put api("/projects/#{project.id}/merge_requests/12345", user), params: {state_event: "close"}
expect(response).to have_gitlab_http_status(404)
end
it "returns 404 if the merge request id is used instead of iid" do
- put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), params: { state_event: "close" }
+ put api("/projects/#{project.id}/merge_requests/#{merge_request.id}", user), params: {state_event: "close"}
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'GET :id/merge_requests/:merge_request_iid/closes_issues' do
- it 'returns the issue that will be closed on merge' do
+ describe "GET :id/merge_requests/:merge_request_iid/closes_issues" do
+ it "returns the issue that will be closed on merge" do
issue = create(:issue, project: project)
mr = merge_request.tap do |mr|
mr.update_attribute(:description, "Closes #{issue.to_reference(mr.project)}")
@@ -1180,10 +1180,10 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(issue.id)
+ expect(json_response.first["id"]).to eq(issue.id)
end
- it 'returns an empty array when there are no issues to be closed' do
+ it "returns an empty array when there are no issues to be closed" do
get api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/closes_issues", user)
expect(response).to have_gitlab_http_status(200)
@@ -1192,8 +1192,8 @@ describe API::MergeRequests do
expect(json_response.length).to eq(0)
end
- it 'handles external issues' do
- jira_project = create(:jira_project, :public, :repository, name: 'JIR_EXT1')
+ it "handles external issues" do
+ jira_project = create(:jira_project, :public, :repository, name: "JIR_EXT1")
ext_issue = ExternalIssue.new("#{jira_project.name}-123", jira_project)
issue = create(:issue, project: jira_project)
description = "Closes #{ext_issue.to_reference(jira_project)}\ncloses #{issue.to_reference}"
@@ -1206,15 +1206,15 @@ describe API::MergeRequests do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- expect(json_response.second['title']).to eq(ext_issue.title)
- expect(json_response.second['id']).to eq(ext_issue.id)
- expect(json_response.second['confidential']).to be_nil
- expect(json_response.first['title']).to eq(issue.title)
- expect(json_response.first['id']).to eq(issue.id)
- expect(json_response.first['confidential']).not_to be_nil
+ expect(json_response.second["title"]).to eq(ext_issue.title)
+ expect(json_response.second["id"]).to eq(ext_issue.id)
+ expect(json_response.second["confidential"]).to be_nil
+ expect(json_response.first["title"]).to eq(issue.title)
+ expect(json_response.first["id"]).to eq(issue.id)
+ expect(json_response.first["confidential"]).not_to be_nil
end
- it 'returns 403 if the user has no access to the merge request' do
+ it "returns 403 if the user has no access to the merge request" do
project = create(:project, :private)
merge_request = create(:merge_request, :simple, source_project: project)
guest = create(:user)
@@ -1238,33 +1238,33 @@ describe API::MergeRequests do
end
end
- describe 'POST :id/merge_requests/:merge_request_iid/subscribe' do
- it 'subscribes to a merge request' do
+ describe "POST :id/merge_requests/:merge_request_iid/subscribe" do
+ it "subscribes to a merge request" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/subscribe", admin)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['subscribed']).to eq(true)
+ expect(json_response["subscribed"]).to eq(true)
end
- it 'returns 304 if already subscribed' do
+ it "returns 304 if already subscribed" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/subscribe", user)
expect(response).to have_gitlab_http_status(304)
end
- it 'returns 404 if the merge request is not found' do
+ it "returns 404 if the merge request is not found" do
post api("/projects/#{project.id}/merge_requests/123/subscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the merge request id is used instead of iid' do
+ it "returns 404 if the merge request id is used instead of iid" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/subscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 403 if user has no access to read code' do
+ it "returns 403 if user has no access to read code" do
guest = create(:user)
project.add_guest(guest)
@@ -1274,33 +1274,33 @@ describe API::MergeRequests do
end
end
- describe 'POST :id/merge_requests/:merge_request_iid/unsubscribe' do
- it 'unsubscribes from a merge request' do
+ describe "POST :id/merge_requests/:merge_request_iid/unsubscribe" do
+ it "unsubscribes from a merge request" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unsubscribe", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['subscribed']).to eq(false)
+ expect(json_response["subscribed"]).to eq(false)
end
- it 'returns 304 if not subscribed' do
+ it "returns 304 if not subscribed" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/unsubscribe", admin)
expect(response).to have_gitlab_http_status(304)
end
- it 'returns 404 if the merge request is not found' do
+ it "returns 404 if the merge request is not found" do
post api("/projects/#{project.id}/merge_requests/123/unsubscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the merge request id is used instead of iid' do
+ it "returns 404 if the merge request id is used instead of iid" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/unsubscribe", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 403 if user has no access to read code' do
+ it "returns 403 if user has no access to read code" do
guest = create(:user)
project.add_guest(guest)
@@ -1310,32 +1310,32 @@ describe API::MergeRequests do
end
end
- describe 'POST :id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds' do
+ describe "POST :id/merge_requests/:merge_request_iid/cancel_merge_when_pipeline_succeeds" do
before do
::MergeRequests::MergeWhenPipelineSucceedsService.new(merge_request.target_project, user).execute(merge_request)
end
- it 'removes the merge_when_pipeline_succeeds status' do
+ it "removes the merge_when_pipeline_succeeds status" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/cancel_merge_when_pipeline_succeeds", user)
expect(response).to have_gitlab_http_status(201)
end
- it 'returns 404 if the merge request is not found' do
+ it "returns 404 if the merge request is not found" do
post api("/projects/#{project.id}/merge_requests/123/cancel_merge_when_pipeline_succeeds", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 if the merge request id is used instead of iid' do
+ it "returns 404 if the merge request id is used instead of iid" do
post api("/projects/#{project.id}/merge_requests/#{merge_request.id}/cancel_merge_when_pipeline_succeeds", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'PUT :id/merge_requests/:merge_request_iid/rebase' do
- it 'enqueues a rebase of the merge request against the target branch' do
+ describe "PUT :id/merge_requests/:merge_request_iid/rebase" do
+ it "enqueues a rebase of the merge request against the target branch" do
Sidekiq::Testing.fake! do
put api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/rebase", user)
end
@@ -1344,7 +1344,7 @@ describe API::MergeRequests do
expect(RebaseWorker.jobs.size).to eq(1)
end
- it 'returns 403 if the user cannot push to the branch' do
+ it "returns 403 if the user cannot push to the branch" do
guest = create(:user)
project.add_guest(guest)
@@ -1354,10 +1354,10 @@ describe API::MergeRequests do
end
end
- describe 'Time tracking' do
+ describe "Time tracking" do
let(:issuable) { merge_request }
- include_examples 'time tracking endpoints', 'merge_request'
+ include_examples "time tracking endpoints", "merge_request"
end
def mr_with_later_created_and_updated_at_time
@@ -1379,13 +1379,13 @@ describe API::MergeRequests do
def expect_response_contain_exactly(*items)
expect_paginated_array_response
expect(json_response.length).to eq(items.size)
- expect(json_response.map { |element| element['id'] }).to contain_exactly(*items.map(&:id))
+ expect(json_response.map { |element| element["id"] }).to contain_exactly(*items.map(&:id))
end
def expect_response_ordered_exactly(*items)
expect_paginated_array_response
expect(json_response.length).to eq(items.size)
- expect(json_response.map { |element| element['id'] }).to eq(items.map(&:id))
+ expect(json_response.map { |element| element["id"] }).to eq(items.map(&:id))
end
def expect_paginated_array_response
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
index 2e376109b42..64a47f51a92 100644
--- a/spec/requests/api/namespaces_spec.rb
+++ b/spec/requests/api/namespaces_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Namespaces do
let(:admin) { create(:admin) }
let(:user) { create(:user) }
- let!(:group1) { create(:group, name: 'group.one') }
+ let!(:group1) { create(:group, name: "group.one") }
let!(:group2) { create(:group, :nested) }
describe "GET /namespaces" do
@@ -18,15 +18,15 @@ describe API::Namespaces do
it "returns correct attributes" do
get api("/namespaces", admin)
- group_kind_json_response = json_response.find { |resource| resource['kind'] == 'group' }
- user_kind_json_response = json_response.find { |resource| resource['kind'] == 'user' }
+ group_kind_json_response = json_response.find { |resource| resource["kind"] == "group" }
+ user_kind_json_response = json_response.find { |resource| resource["kind"] == "user" }
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(group_kind_json_response.keys).to include('id', 'kind', 'name', 'path', 'full_path',
- 'parent_id', 'members_count_with_descendants')
+ expect(group_kind_json_response.keys).to include("id", "kind", "name", "path", "full_path",
+ "parent_id", "members_count_with_descendants")
- expect(user_kind_json_response.keys).to include('id', 'kind', 'name', 'path', 'full_path', 'parent_id')
+ expect(user_kind_json_response.keys).to include("id", "kind", "name", "path", "full_path", "parent_id")
end
it "admin: returns an array of all namespaces" do
@@ -45,8 +45,8 @@ describe API::Namespaces do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.last['path']).to eq(group2.path)
- expect(json_response.last['full_path']).to eq(group2.full_path)
+ expect(json_response.last["path"]).to eq(group2.path)
+ expect(json_response.last["full_path"]).to eq(group2.full_path)
end
end
@@ -56,10 +56,10 @@ describe API::Namespaces do
get api("/namespaces", user)
- owned_group_response = json_response.find { |resource| resource['id'] == group1.id }
+ owned_group_response = json_response.find { |resource| resource["id"] == group1.id }
- expect(owned_group_response.keys).to include('id', 'kind', 'name', 'path', 'full_path',
- 'parent_id', 'members_count_with_descendants')
+ expect(owned_group_response.keys).to include("id", "kind", "name", "path", "full_path",
+ "parent_id", "members_count_with_descendants")
end
it "returns correct attributes when user cannot admin group" do
@@ -67,9 +67,9 @@ describe API::Namespaces do
get api("/namespaces", user)
- guest_group_response = json_response.find { |resource| resource['id'] == group1.id }
+ guest_group_response = json_response.find { |resource| resource["id"] == group1.id }
- expect(guest_group_response.keys).to include('id', 'kind', 'name', 'path', 'full_path', 'parent_id')
+ expect(guest_group_response.keys).to include("id", "kind", "name", "path", "full_path", "parent_id")
end
it "user: returns an array of namespaces" do
@@ -92,92 +92,92 @@ describe API::Namespaces do
end
end
- describe 'GET /namespaces/:id' do
+ describe "GET /namespaces/:id" do
let(:owned_group) { group1 }
let(:user2) { create(:user) }
- shared_examples 'can access namespace' do
- it 'returns namespace details' do
+ shared_examples "can access namespace" do
+ it "returns namespace details" do
get api("/namespaces/#{namespace_id}", request_actor)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(requested_namespace.id)
- expect(json_response['path']).to eq(requested_namespace.path)
- expect(json_response['name']).to eq(requested_namespace.name)
+ expect(json_response["id"]).to eq(requested_namespace.id)
+ expect(json_response["path"]).to eq(requested_namespace.path)
+ expect(json_response["name"]).to eq(requested_namespace.name)
end
end
- shared_examples 'namespace reader' do
+ shared_examples "namespace reader" do
let(:requested_namespace) { owned_group }
before do
owned_group.add_owner(request_actor)
end
- context 'when namespace exists' do
- context 'when requested by ID' do
- context 'when requesting group' do
+ context "when namespace exists" do
+ context "when requested by ID" do
+ context "when requesting group" do
let(:namespace_id) { owned_group.id }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
- context 'when requesting personal namespace' do
+ context "when requesting personal namespace" do
let(:namespace_id) { request_actor.namespace.id }
let(:requested_namespace) { request_actor.namespace }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
end
- context 'when requested by path' do
- context 'when requesting group' do
+ context "when requested by path" do
+ context "when requesting group" do
let(:namespace_id) { owned_group.path }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
- context 'when requesting personal namespace' do
+ context "when requesting personal namespace" do
let(:namespace_id) { request_actor.namespace.path }
let(:requested_namespace) { request_actor.namespace }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
end
end
context "when namespace doesn't exist" do
- it 'returns not-found' do
- get api('/namespaces/0', request_actor)
+ it "returns not-found" do
+ get api("/namespaces/0", request_actor)
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
get api("/namespaces/#{group1.id}")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated as regular user' do
+ context "when authenticated as regular user" do
let(:request_actor) { user }
- context 'when requested namespace is not owned by user' do
- context 'when requesting group' do
- it 'returns not-found' do
+ context "when requested namespace is not owned by user" do
+ context "when requesting group" do
+ it "returns not-found" do
get api("/namespaces/#{group2.id}", request_actor)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when requesting personal namespace' do
- it 'returns not-found' do
+ context "when requesting personal namespace" do
+ it "returns not-found" do
get api("/namespaces/#{user2.namespace.id}", request_actor)
expect(response).to have_gitlab_http_status(404)
@@ -185,32 +185,32 @@ describe API::Namespaces do
end
end
- context 'when requested namespace is owned by user' do
- it_behaves_like 'namespace reader'
+ context "when requested namespace is owned by user" do
+ it_behaves_like "namespace reader"
end
end
- context 'when authenticated as admin' do
+ context "when authenticated as admin" do
let(:request_actor) { admin }
- context 'when requested namespace is not owned by user' do
- context 'when requesting group' do
+ context "when requested namespace is not owned by user" do
+ context "when requesting group" do
let(:namespace_id) { group2.id }
let(:requested_namespace) { group2 }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
- context 'when requesting personal namespace' do
+ context "when requesting personal namespace" do
let(:namespace_id) { user2.namespace.id }
let(:requested_namespace) { user2.namespace }
- it_behaves_like 'can access namespace'
+ it_behaves_like "can access namespace"
end
end
- context 'when requested namespace is owned by user' do
- it_behaves_like 'namespace reader'
+ context "when requested namespace is owned by user" do
+ it_behaves_like "namespace reader"
end
end
end
diff --git a/spec/requests/api/notes_spec.rb b/spec/requests/api/notes_spec.rb
index 424f0a82e43..f0e45867629 100644
--- a/spec/requests/api/notes_spec.rb
+++ b/spec/requests/api/notes_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Notes do
let(:user) { create(:user) }
@@ -13,13 +13,13 @@ describe API::Notes do
let!(:issue) { create(:issue, project: project, author: user) }
let!(:issue_note) { create(:note, noteable: issue, project: project, author: user) }
- it_behaves_like "noteable API", 'projects', 'issues', 'iid' do
+ it_behaves_like "noteable API", "projects", "issues", "iid" do
let(:parent) { project }
let(:noteable) { issue }
let(:note) { issue_note }
end
- context 'when user does not have access to create noteable' do
+ context "when user does not have access to create noteable" do
let(:private_issue) { create(:issue, project: create(:project, :private)) }
##
@@ -28,14 +28,14 @@ describe API::Notes do
#
before do
post api("/projects/#{private_issue.project.id}/issues/#{private_issue.iid}/notes", user),
- params: { body: 'Hi!' }
+ params: {body: "Hi!"}
end
- it 'responds with resource not found error' do
+ it "responds with resource not found error" do
expect(response.status).to eq 404
end
- it 'does not create new note' do
+ it "does not create new note" do
expect(private_issue.notes.reload).to be_empty
end
end
@@ -44,7 +44,7 @@ describe API::Notes do
# For testing the cross-reference of a private issue in a public project
let(:private_project) do
create(:project, namespace: private_user.namespace)
- .tap { |p| p.add_maintainer(private_user) }
+ .tap { |p| p.add_maintainer(private_user) }
end
let(:private_issue) { create(:issue, project: private_project) }
@@ -53,9 +53,9 @@ describe API::Notes do
let!(:cross_reference_note) do
create :note,
- noteable: ext_issue, project: ext_proj,
- note: "mentioned in issue #{private_issue.to_reference(ext_proj)}",
- system: true
+ noteable: ext_issue, project: ext_proj,
+ note: "mentioned in issue #{private_issue.to_reference(ext_proj)}",
+ system: true
end
describe "GET /projects/:id/noteable/:noteable_id/notes" do
@@ -89,7 +89,7 @@ describe API::Notes do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['body']).to eq(cross_reference_note.note)
+ expect(json_response.first["body"]).to eq(cross_reference_note.note)
end
end
end
@@ -120,7 +120,7 @@ describe API::Notes do
get api("/projects/#{ext_proj.id}/issues/#{ext_issue.iid}/notes/#{cross_reference_note.id}", private_user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['body']).to eq(cross_reference_note.note)
+ expect(json_response["body"]).to eq(cross_reference_note.note)
end
end
end
@@ -131,7 +131,7 @@ describe API::Notes do
let!(:snippet) { create(:project_snippet, project: project, author: user) }
let!(:snippet_note) { create(:note, noteable: snippet, project: project, author: user) }
- it_behaves_like "noteable API", 'projects', 'snippets', 'id' do
+ it_behaves_like "noteable API", "projects", "snippets", "id" do
let(:parent) { project }
let(:noteable) { snippet }
let(:note) { snippet_note }
@@ -142,41 +142,41 @@ describe API::Notes do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, author: user) }
let!(:merge_request_note) { create(:note, noteable: merge_request, project: project, author: user) }
- it_behaves_like "noteable API", 'projects', 'merge_requests', 'iid' do
+ it_behaves_like "noteable API", "projects", "merge_requests", "iid" do
let(:parent) { project }
let(:noteable) { merge_request }
let(:note) { merge_request_note }
end
- context 'when the merge request discussion is locked' do
+ context "when the merge request discussion is locked" do
before do
merge_request.update_attribute(:discussion_locked, true)
end
- context 'when a user is a team member' do
- subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user), params: { body: 'Hi!' } }
+ context "when a user is a team member" do
+ subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", user), params: {body: "Hi!"} }
- it 'returns 200 status' do
+ it "returns 200 status" do
subject
expect(response).to have_gitlab_http_status(201)
end
- it 'creates a new note' do
+ it "creates a new note" do
expect { subject }.to change { Note.count }.by(1)
end
end
- context 'when a user is not a team member' do
- subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", private_user), params: { body: 'Hi!' } }
+ context "when a user is not a team member" do
+ subject { post api("/projects/#{project.id}/merge_requests/#{merge_request.iid}/notes", private_user), params: {body: "Hi!"} }
- it 'returns 403 status' do
+ it "returns 403 status" do
subject
expect(response).to have_gitlab_http_status(403)
end
- it 'does not create a new note' do
+ it "does not create a new note" do
expect { subject }.not_to change { Note.count }
end
end
diff --git a/spec/requests/api/notification_settings_spec.rb b/spec/requests/api/notification_settings_spec.rb
index 4ed667ad0dc..0ed4d950014 100644
--- a/spec/requests/api/notification_settings_spec.rb
+++ b/spec/requests/api/notification_settings_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::NotificationSettings do
let(:user) { create(:user) }
@@ -11,8 +11,8 @@ describe API::NotificationSettings do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
- expect(json_response['notification_email']).to eq(user.notification_email)
- expect(json_response['level']).to eq(user.global_notification_setting.level)
+ expect(json_response["notification_email"]).to eq(user.notification_email)
+ expect(json_response["level"]).to eq(user.global_notification_setting.level)
end
end
@@ -20,18 +20,18 @@ describe API::NotificationSettings do
let(:email) { create(:email, user: user) }
it "updates global notification settings for the current user" do
- put api("/notification_settings", user), params: { level: 'watch', notification_email: email.email }
+ put api("/notification_settings", user), params: {level: "watch", notification_email: email.email}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['notification_email']).to eq(email.email)
+ expect(json_response["notification_email"]).to eq(email.email)
expect(user.reload.notification_email).to eq(email.email)
- expect(json_response['level']).to eq(user.reload.global_notification_setting.level)
+ expect(json_response["level"]).to eq(user.reload.global_notification_setting.level)
end
end
describe "PUT /notification_settings" do
it "fails on non-user email address" do
- put api("/notification_settings", user), params: { notification_email: 'invalid@example.com' }
+ put api("/notification_settings", user), params: {notification_email: "invalid@example.com"}
expect(response).to have_gitlab_http_status(400)
end
@@ -43,16 +43,16 @@ describe API::NotificationSettings do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
- expect(json_response['level']).to eq(user.notification_settings_for(group).level)
+ expect(json_response["level"]).to eq(user.notification_settings_for(group).level)
end
end
describe "PUT /groups/:id/notification_settings" do
it "updates group level notification settings for the current user" do
- put api("/groups/#{group.id}/notification_settings", user), params: { level: 'watch' }
+ put api("/groups/#{group.id}/notification_settings", user), params: {level: "watch"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['level']).to eq(user.reload.notification_settings_for(group).level)
+ expect(json_response["level"]).to eq(user.reload.notification_settings_for(group).level)
end
end
@@ -62,24 +62,24 @@ describe API::NotificationSettings do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
- expect(json_response['level']).to eq(user.notification_settings_for(project).level)
+ expect(json_response["level"]).to eq(user.notification_settings_for(project).level)
end
end
describe "PUT /projects/:id/notification_settings" do
it "updates project level notification settings for the current user" do
- put api("/projects/#{project.id}/notification_settings", user), params: { level: 'custom', new_note: true }
+ put api("/projects/#{project.id}/notification_settings", user), params: {level: "custom", new_note: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['level']).to eq(user.reload.notification_settings_for(project).level)
- expect(json_response['events']['new_note']).to be_truthy
- expect(json_response['events']['new_issue']).to be_falsey
+ expect(json_response["level"]).to eq(user.reload.notification_settings_for(project).level)
+ expect(json_response["events"]["new_note"]).to be_truthy
+ expect(json_response["events"]["new_issue"]).to be_falsey
end
end
describe "PUT /projects/:id/notification_settings" do
it "fails on invalid level" do
- put api("/projects/#{project.id}/notification_settings", user), params: { level: 'invalid' }
+ put api("/projects/#{project.id}/notification_settings", user), params: {level: "invalid"}
expect(response).to have_gitlab_http_status(400)
end
diff --git a/spec/requests/api/oauth_tokens_spec.rb b/spec/requests/api/oauth_tokens_spec.rb
index 3811ec751de..b3806a220ae 100644
--- a/spec/requests/api/oauth_tokens_spec.rb
+++ b/spec/requests/api/oauth_tokens_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'OAuth tokens' do
- context 'Resource Owner Password Credentials' do
+describe "OAuth tokens" do
+ context "Resource Owner Password Credentials" do
def request_oauth_token(user)
- post '/oauth/token', params: { username: user.username, password: user.password, grant_type: 'password' }
+ post "/oauth/token", params: {username: user.username, password: user.password, grant_type: "password"}
end
- context 'when user has 2FA enabled' do
- it 'does not create an access token' do
+ context "when user has 2FA enabled" do
+ it "does not create an access token" do
user = create(:user, :two_factor)
request_oauth_token(user)
expect(response).to have_gitlab_http_status(401)
- expect(json_response['error']).to eq('invalid_grant')
+ expect(json_response["error"]).to eq("invalid_grant")
end
end
- context 'when user does not have 2FA enabled' do
- it 'creates an access token' do
+ context "when user does not have 2FA enabled" do
+ it "creates an access token" do
user = create(:user)
request_oauth_token(user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['access_token']).not_to be_nil
+ expect(json_response["access_token"]).not_to be_nil
end
end
diff --git a/spec/requests/api/pages/internal_access_spec.rb b/spec/requests/api/pages/internal_access_spec.rb
index c41eabe0a48..4a57fc83711 100644
--- a/spec/requests/api/pages/internal_access_spec.rb
+++ b/spec/requests/api/pages/internal_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Internal Project Pages Access" do
using RSpec::Parameterized::TableSyntax
@@ -25,14 +25,14 @@ describe "Internal Project Pages Access" do
end
describe "Project should be internal" do
- describe '#internal?' do
+ describe "#internal?" do
subject { project.internal? }
it { is_expected.to be_truthy }
end
end
describe "GET /projects/:id/pages_access" do
- context 'access depends on the level' do
+ context "access depends on the level" do
where(:pages_access_level, :with_user, :expected_result) do
ProjectFeature::DISABLED | "admin" | 403
ProjectFeature::DISABLED | "owner" | 403
diff --git a/spec/requests/api/pages/private_access_spec.rb b/spec/requests/api/pages/private_access_spec.rb
index c647537038e..baad0c267e9 100644
--- a/spec/requests/api/pages/private_access_spec.rb
+++ b/spec/requests/api/pages/private_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Private Project Pages Access" do
using RSpec::Parameterized::TableSyntax
@@ -25,14 +25,14 @@ describe "Private Project Pages Access" do
end
describe "Project should be private" do
- describe '#private?' do
+ describe "#private?" do
subject { project.private? }
it { is_expected.to be_truthy }
end
end
describe "GET /projects/:id/pages_access" do
- context 'access depends on the level' do
+ context "access depends on the level" do
where(:pages_access_level, :with_user, :expected_result) do
ProjectFeature::DISABLED | "admin" | 403
ProjectFeature::DISABLED | "owner" | 403
diff --git a/spec/requests/api/pages/public_access_spec.rb b/spec/requests/api/pages/public_access_spec.rb
index 16cc5697f30..8b177cd4159 100644
--- a/spec/requests/api/pages/public_access_spec.rb
+++ b/spec/requests/api/pages/public_access_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe "Public Project Pages Access" do
using RSpec::Parameterized::TableSyntax
@@ -25,14 +25,14 @@ describe "Public Project Pages Access" do
end
describe "Project should be public" do
- describe '#public?' do
+ describe "#public?" do
subject { project.public? }
it { is_expected.to be_truthy }
end
end
describe "GET /projects/:id/pages_access" do
- context 'access depends on the level' do
+ context "access depends on the level" do
where(:pages_access_level, :with_user, :expected_result) do
ProjectFeature::DISABLED | "admin" | 403
ProjectFeature::DISABLED | "owner" | 403
diff --git a/spec/requests/api/pages_domains_spec.rb b/spec/requests/api/pages_domains_spec.rb
index 3eb68a6abb6..3189b5a221b 100644
--- a/spec/requests/api/pages_domains_spec.rb
+++ b/spec/requests/api/pages_domains_spec.rb
@@ -1,22 +1,22 @@
-require 'rails_helper'
+require "rails_helper"
describe API::PagesDomains do
- set(:project) { create(:project, path: 'my.project', pages_https_only: false) }
+ set(:project) { create(:project, path: "my.project", pages_https_only: false) }
set(:user) { create(:user) }
set(:admin) { create(:admin) }
- set(:pages_domain) { create(:pages_domain, :without_key, :without_certificate, domain: 'www.domain.test', project: project) }
- set(:pages_domain_secure) { create(:pages_domain, domain: 'ssl.domain.test', project: project) }
- set(:pages_domain_expired) { create(:pages_domain, :with_expired_certificate, domain: 'expired.domain.test', project: project) }
+ set(:pages_domain) { create(:pages_domain, :without_key, :without_certificate, domain: "www.domain.test", project: project) }
+ set(:pages_domain_secure) { create(:pages_domain, domain: "ssl.domain.test", project: project) }
+ set(:pages_domain_expired) { create(:pages_domain, :with_expired_certificate, domain: "expired.domain.test", project: project) }
- let(:pages_domain_params) { build(:pages_domain, :without_key, :without_certificate, domain: 'www.other-domain.test').slice(:domain) }
- let(:pages_domain_secure_params) { build(:pages_domain, domain: 'ssl.other-domain.test', project: project).slice(:domain, :certificate, :key) }
+ let(:pages_domain_params) { build(:pages_domain, :without_key, :without_certificate, domain: "www.other-domain.test").slice(:domain) }
+ let(:pages_domain_secure_params) { build(:pages_domain, domain: "ssl.other-domain.test", project: project).slice(:domain, :certificate, :key) }
let(:pages_domain_secure_key_missmatch_params) {build(:pages_domain, :with_trusted_chain, project: project).slice(:domain, :certificate, :key) }
let(:pages_domain_secure_missing_chain_params) {build(:pages_domain, :with_missing_chain, project: project).slice(:certificate) }
let(:route) { "/projects/#{project.id}/pages/domains" }
let(:route_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain.domain}" }
- let(:route_domain_path) { "/projects/#{project.full_path.gsub('/', '%2F')}/pages/domains/#{pages_domain.domain}" }
+ let(:route_domain_path) { "/projects/#{project.full_path.gsub("/", "%2F")}/pages/domains/#{pages_domain.domain}" }
let(:route_secure_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_secure.domain}" }
let(:route_expired_domain) { "/projects/#{project.id}/pages/domains/#{pages_domain_expired.domain}" }
let(:route_vacant_domain) { "/projects/#{project.id}/pages/domains/www.vacant-domain.test" }
@@ -25,473 +25,473 @@ describe API::PagesDomains do
allow(Gitlab.config.pages).to receive(:enabled).and_return(true)
end
- describe 'GET /pages/domains' do
- context 'when pages is disabled' do
+ describe "GET /pages/domains" do
+ context "when pages is disabled" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
end
- it_behaves_like '404 response' do
- let(:request) { get api('/pages/domains', admin) }
+ it_behaves_like "404 response" do
+ let(:request) { get api("/pages/domains", admin) }
end
end
- context 'when pages is enabled' do
- context 'when authenticated as an admin' do
- it 'returns paginated all pages domains' do
- get api('/pages/domains', admin)
+ context "when pages is enabled" do
+ context "when authenticated as an admin" do
+ it "returns paginated all pages domains" do
+ get api("/pages/domains", admin)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain_basics')
+ expect(response).to match_response_schema("public_api/v4/pages_domain_basics")
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
- expect(json_response.last).to have_key('domain')
- expect(json_response.last).to have_key('project_id')
- expect(json_response.last).to have_key('certificate_expiration')
- expect(json_response.last['certificate_expiration']['expired']).to be true
- expect(json_response.first).not_to have_key('certificate_expiration')
+ expect(json_response.last).to have_key("domain")
+ expect(json_response.last).to have_key("project_id")
+ expect(json_response.last).to have_key("certificate_expiration")
+ expect(json_response.last["certificate_expiration"]["expired"]).to be true
+ expect(json_response.first).not_to have_key("certificate_expiration")
end
end
- context 'when authenticated as a non-member' do
- it_behaves_like '403 response' do
- let(:request) { get api('/pages/domains', user) }
+ context "when authenticated as a non-member" do
+ it_behaves_like "403 response" do
+ let(:request) { get api("/pages/domains", user) }
end
end
end
end
- describe 'GET /projects/:project_id/pages/domains' do
- shared_examples_for 'get pages domains' do
- it 'returns paginated pages domains' do
+ describe "GET /projects/:project_id/pages/domains" do
+ shared_examples_for "get pages domains" do
+ it "returns paginated pages domains" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domains')
+ expect(response).to match_response_schema("public_api/v4/pages_domains")
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
- expect(json_response.map { |pages_domain| pages_domain['domain'] }).to include(pages_domain.domain)
- expect(json_response.last).to have_key('domain')
+ expect(json_response.map { |pages_domain| pages_domain["domain"] }).to include(pages_domain.domain)
+ expect(json_response.last).to have_key("domain")
end
end
- context 'when pages is disabled' do
+ context "when pages is disabled" do
before do
allow(Gitlab.config.pages).to receive(:enabled).and_return(false)
project.add_maintainer(user)
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'get pages domains'
+ it_behaves_like "get pages domains"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is not a member' do
- it_behaves_like '404 response' do
+ context "when user is not a member" do
+ it_behaves_like "404 response" do
let(:request) { get api(route, user) }
end
end
end
- describe 'GET /projects/:project_id/pages/domains/:domain' do
- shared_examples_for 'get pages domain' do
- it 'returns pages domain' do
+ describe "GET /projects/:project_id/pages/domains/:domain" do
+ shared_examples_for "get pages domain" do
+ it "returns pages domain" do
get api(route_domain, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
- expect(json_response['domain']).to eq(pages_domain.domain)
- expect(json_response['url']).to eq(pages_domain.url)
- expect(json_response['certificate']).to be_nil
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
+ expect(json_response["domain"]).to eq(pages_domain.domain)
+ expect(json_response["url"]).to eq(pages_domain.url)
+ expect(json_response["certificate"]).to be_nil
end
- it 'returns pages domain with project path' do
+ it "returns pages domain with project path" do
get api(route_domain_path, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
- expect(json_response['domain']).to eq(pages_domain.domain)
- expect(json_response['url']).to eq(pages_domain.url)
- expect(json_response['certificate']).to be_nil
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
+ expect(json_response["domain"]).to eq(pages_domain.domain)
+ expect(json_response["url"]).to eq(pages_domain.url)
+ expect(json_response["certificate"]).to be_nil
end
- it 'returns pages domain with a certificate' do
+ it "returns pages domain with a certificate" do
get api(route_secure_domain, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
- expect(json_response['domain']).to eq(pages_domain_secure.domain)
- expect(json_response['url']).to eq(pages_domain_secure.url)
- expect(json_response['certificate']['subject']).to eq(pages_domain_secure.subject)
- expect(json_response['certificate']['expired']).to be false
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
+ expect(json_response["domain"]).to eq(pages_domain_secure.domain)
+ expect(json_response["url"]).to eq(pages_domain_secure.url)
+ expect(json_response["certificate"]["subject"]).to eq(pages_domain_secure.subject)
+ expect(json_response["certificate"]["expired"]).to be false
end
- it 'returns pages domain with an expired certificate' do
+ it "returns pages domain with an expired certificate" do
get api(route_expired_domain, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
- expect(json_response['certificate']['expired']).to be true
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
+ expect(json_response["certificate"]["expired"]).to be true
end
end
- context 'when domain is vacant' do
+ context "when domain is vacant" do
before do
project.add_maintainer(user)
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route_vacant_domain, user) }
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'get pages domain'
+ it_behaves_like "get pages domain"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
- context 'when user is not a member' do
- it_behaves_like '404 response' do
+ context "when user is not a member" do
+ it_behaves_like "404 response" do
let(:request) { get api(route, user) }
end
end
end
- describe 'POST /projects/:project_id/pages/domains' do
+ describe "POST /projects/:project_id/pages/domains" do
let(:params) { pages_domain_params.slice(:domain) }
let(:params_secure) { pages_domain_secure_params.slice(:domain, :certificate, :key) }
- shared_examples_for 'post pages domains' do
- it 'creates a new pages domain' do
+ shared_examples_for "post pages domains" do
+ it "creates a new pages domain" do
post api(route, user), params: params
- pages_domain = PagesDomain.find_by(domain: json_response['domain'])
+ pages_domain = PagesDomain.find_by(domain: json_response["domain"])
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain.domain).to eq(params[:domain])
expect(pages_domain.certificate).to be_nil
expect(pages_domain.key).to be_nil
end
- it 'creates a new secure pages domain' do
+ it "creates a new secure pages domain" do
post api(route, user), params: params_secure
- pages_domain = PagesDomain.find_by(domain: json_response['domain'])
+ pages_domain = PagesDomain.find_by(domain: json_response["domain"])
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain.domain).to eq(params_secure[:domain])
expect(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key])
end
- it 'fails to create pages domain without key' do
+ it "fails to create pages domain without key" do
post api(route, user), params: pages_domain_secure_params.slice(:domain, :certificate)
expect(response).to have_gitlab_http_status(400)
end
- it 'fails to create pages domain with key missmatch' do
+ it "fails to create pages domain with key missmatch" do
post api(route, user), params: pages_domain_secure_key_missmatch_params.slice(:domain, :certificate, :key)
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'post pages domains'
+ it_behaves_like "post pages domains"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { post api(route, user), params: params }
end
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { post api(route, user), params: params }
end
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { post api(route, user), params: params }
end
end
- context 'when user is not a member' do
- it_behaves_like '404 response' do
+ context "when user is not a member" do
+ it_behaves_like "404 response" do
let(:request) { post api(route, user), params: params }
end
end
end
- describe 'PUT /projects/:project_id/pages/domains/:domain' do
+ describe "PUT /projects/:project_id/pages/domains/:domain" do
let(:params_secure) { pages_domain_secure_params.slice(:certificate, :key) }
let(:params_secure_nokey) { pages_domain_secure_params.slice(:certificate) }
- shared_examples_for 'put pages domain' do
- it 'updates pages domain removing certificate' do
+ shared_examples_for "put pages domain" do
+ it "updates pages domain removing certificate" do
put api(route_secure_domain, user)
pages_domain_secure.reload
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain_secure.certificate).to be_nil
expect(pages_domain_secure.key).to be_nil
end
- it 'updates pages domain adding certificate' do
+ it "updates pages domain adding certificate" do
put api(route_domain, user), params: params_secure
pages_domain.reload
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain.certificate).to eq(params_secure[:certificate])
expect(pages_domain.key).to eq(params_secure[:key])
end
- it 'updates pages domain with expired certificate' do
+ it "updates pages domain with expired certificate" do
put api(route_expired_domain, user), params: params_secure
pages_domain_expired.reload
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain_expired.certificate).to eq(params_secure[:certificate])
expect(pages_domain_expired.key).to eq(params_secure[:key])
end
- it 'updates pages domain with expired certificate not updating key' do
+ it "updates pages domain with expired certificate not updating key" do
put api(route_secure_domain, user), params: params_secure_nokey
pages_domain_secure.reload
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/pages_domain/detail')
+ expect(response).to match_response_schema("public_api/v4/pages_domain/detail")
expect(pages_domain_secure.certificate).to eq(params_secure_nokey[:certificate])
end
- it 'fails to update pages domain adding certificate without key' do
+ it "fails to update pages domain adding certificate without key" do
put api(route_domain, user), params: params_secure_nokey
expect(response).to have_gitlab_http_status(400)
end
- it 'fails to update pages domain adding certificate with missing chain' do
+ it "fails to update pages domain adding certificate with missing chain" do
put api(route_domain, user), params: pages_domain_secure_missing_chain_params.slice(:certificate)
expect(response).to have_gitlab_http_status(400)
end
- it 'fails to update pages domain with key missmatch' do
+ it "fails to update pages domain with key missmatch" do
put api(route_secure_domain, user), params: pages_domain_secure_key_missmatch_params.slice(:certificate, :key)
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when domain is vacant' do
+ context "when domain is vacant" do
before do
project.add_maintainer(user)
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { put api(route_vacant_domain, user) }
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'put pages domain'
+ it_behaves_like "put pages domain"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { put api(route_domain, user) }
end
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { put api(route_domain, user) }
end
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { put api(route_domain, user) }
end
end
- context 'when user is not a member' do
- it_behaves_like '404 response' do
+ context "when user is not a member" do
+ it_behaves_like "404 response" do
let(:request) { put api(route_domain, user) }
end
end
end
- describe 'DELETE /projects/:project_id/pages/domains/:domain' do
- shared_examples_for 'delete pages domain' do
- it 'deletes a pages domain' do
+ describe "DELETE /projects/:project_id/pages/domains/:domain" do
+ shared_examples_for "delete pages domain" do
+ it "deletes a pages domain" do
delete api(route_domain, user)
expect(response).to have_gitlab_http_status(204)
end
end
- context 'when domain is vacant' do
+ context "when domain is vacant" do
before do
project.add_maintainer(user)
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { delete api(route_vacant_domain, user) }
end
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'delete pages domain'
+ it_behaves_like "delete pages domain"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { delete api(route_domain, user) }
end
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { delete api(route_domain, user) }
end
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { delete api(route_domain, user) }
end
end
- context 'when user is not a member' do
- it_behaves_like '404 response' do
+ context "when user is not a member" do
+ it_behaves_like "404 response" do
let(:request) { delete api(route_domain, user) }
end
end
diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb
index 870ef34437f..aa3d88dbf7b 100644
--- a/spec/requests/api/pipeline_schedules_spec.rb
+++ b/spec/requests/api/pipeline_schedules_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::PipelineSchedules do
set(:developer) { create(:user) }
@@ -9,8 +9,8 @@ describe API::PipelineSchedules do
project.add_developer(developer)
end
- describe 'GET /projects/:id/pipeline_schedules' do
- context 'authenticated user with valid permissions' do
+ describe "GET /projects/:id/pipeline_schedules" do
+ context "authenticated user with valid permissions" do
let(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: developer) }
before do
@@ -28,27 +28,27 @@ describe API::PipelineSchedules do
end
end
- it 'returns list of pipeline_schedules' do
+ it "returns list of pipeline_schedules" do
get api("/projects/#{project.id}/pipeline_schedules", developer)
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
- expect(response).to match_response_schema('pipeline_schedules')
+ expect(response).to match_response_schema("pipeline_schedules")
end
- it 'avoids N + 1 queries' do
+ it "avoids N + 1 queries" do
# We need at least two users to trigger a preload for that relation.
create_pipeline_schedules(1)
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
get api("/projects/#{project.id}/pipeline_schedules", developer)
- end.count
+ }.count
create_pipeline_schedules(10)
- expect do
+ expect {
get api("/projects/#{project.id}/pipeline_schedules", developer)
- end.not_to exceed_query_limit(control_count)
+ }.not_to exceed_query_limit(control_count)
end
%w[active inactive].each do |target|
@@ -57,29 +57,29 @@ describe API::PipelineSchedules do
create(:ci_pipeline_schedule, project: project, active: active?(target))
end
- it 'returns matched pipeline schedules' do
- get api("/projects/#{project.id}/pipeline_schedules", developer), params: { scope: target }
+ it "returns matched pipeline schedules" do
+ get api("/projects/#{project.id}/pipeline_schedules", developer), params: {scope: target}
- expect(json_response.map { |r| r['active'] }).to all(eq(active?(target)))
+ expect(json_response.map { |r| r["active"] }).to all(eq(active?(target)))
end
end
def active?(str)
- (str == 'active') ? true : false
+ str == "active"
end
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not return pipeline_schedules list' do
+ context "authenticated user with invalid permissions" do
+ it "does not return pipeline_schedules list" do
get api("/projects/#{project.id}/pipeline_schedules", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not return pipeline_schedules list' do
+ context "unauthenticated user" do
+ it "does not return pipeline_schedules list" do
get api("/projects/#{project.id}/pipeline_schedules")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -87,50 +87,50 @@ describe API::PipelineSchedules do
end
end
- describe 'GET /projects/:id/pipeline_schedules/:pipeline_schedule_id' do
+ describe "GET /projects/:id/pipeline_schedules/:pipeline_schedule_id" do
let(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: developer) }
before do
pipeline_schedule.pipelines << build(:ci_pipeline, project: project)
end
- context 'authenticated user with valid permissions' do
- it 'returns pipeline_schedule details' do
+ context "authenticated user with valid permissions" do
+ it "returns pipeline_schedule details" do
get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer)
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline_schedule')
+ expect(response).to match_response_schema("pipeline_schedule")
end
- it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
+ it "responds with 404 Not Found if requesting non-existing pipeline_schedule" do
get api("/projects/#{project.id}/pipeline_schedules/-5", developer)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not return pipeline_schedules list' do
+ context "authenticated user with invalid permissions" do
+ it "does not return pipeline_schedules list" do
get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'authenticated user with insufficient permissions' do
+ context "authenticated user with insufficient permissions" do
before do
project.add_guest(user)
end
- it 'does not return pipeline_schedules list' do
+ it "does not return pipeline_schedules list" do
get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not return pipeline_schedules list' do
+ context "unauthenticated user" do
+ it "does not return pipeline_schedules list" do
get api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -138,56 +138,56 @@ describe API::PipelineSchedules do
end
end
- describe 'POST /projects/:id/pipeline_schedules' do
+ describe "POST /projects/:id/pipeline_schedules" do
let(:params) { attributes_for(:ci_pipeline_schedule) }
- context 'authenticated user with valid permissions' do
- context 'with required parameters' do
- it 'creates pipeline_schedule' do
- expect do
+ context "authenticated user with valid permissions" do
+ context "with required parameters" do
+ it "creates pipeline_schedule" do
+ expect {
post api("/projects/#{project.id}/pipeline_schedules", developer),
params: params
- end.to change { project.pipeline_schedules.count }.by(1)
+ }.to change { project.pipeline_schedules.count }.by(1)
expect(response).to have_gitlab_http_status(:created)
- expect(response).to match_response_schema('pipeline_schedule')
- expect(json_response['description']).to eq(params[:description])
- expect(json_response['ref']).to eq(params[:ref])
- expect(json_response['cron']).to eq(params[:cron])
- expect(json_response['cron_timezone']).to eq(params[:cron_timezone])
- expect(json_response['owner']['id']).to eq(developer.id)
+ expect(response).to match_response_schema("pipeline_schedule")
+ expect(json_response["description"]).to eq(params[:description])
+ expect(json_response["ref"]).to eq(params[:ref])
+ expect(json_response["cron"]).to eq(params[:cron])
+ expect(json_response["cron_timezone"]).to eq(params[:cron_timezone])
+ expect(json_response["owner"]["id"]).to eq(developer.id)
end
end
- context 'without required parameters' do
- it 'does not create pipeline_schedule' do
+ context "without required parameters" do
+ it "does not create pipeline_schedule" do
post api("/projects/#{project.id}/pipeline_schedules", developer)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when cron has validation error' do
- it 'does not create pipeline_schedule' do
+ context "when cron has validation error" do
+ it "does not create pipeline_schedule" do
post api("/projects/#{project.id}/pipeline_schedules", developer),
- params: params.merge('cron' => 'invalid-cron')
+ params: params.merge("cron" => "invalid-cron")
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to have_key('cron')
+ expect(json_response["message"]).to have_key("cron")
end
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not create pipeline_schedule' do
+ context "authenticated user with invalid permissions" do
+ it "does not create pipeline_schedule" do
post api("/projects/#{project.id}/pipeline_schedules", user), params: params
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not create pipeline_schedule' do
+ context "unauthenticated user" do
+ it "does not create pipeline_schedule" do
post api("/projects/#{project.id}/pipeline_schedules"), params: params
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -195,42 +195,42 @@ describe API::PipelineSchedules do
end
end
- describe 'PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id' do
+ describe "PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id" do
let(:pipeline_schedule) do
create(:ci_pipeline_schedule, project: project, owner: developer)
end
- context 'authenticated user with valid permissions' do
- it 'updates cron' do
+ context "authenticated user with valid permissions" do
+ it "updates cron" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer),
- params: { cron: '1 2 3 4 *' }
+ params: {cron: "1 2 3 4 *"}
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline_schedule')
- expect(json_response['cron']).to eq('1 2 3 4 *')
+ expect(response).to match_response_schema("pipeline_schedule")
+ expect(json_response["cron"]).to eq("1 2 3 4 *")
end
- context 'when cron has validation error' do
- it 'does not update pipeline_schedule' do
+ context "when cron has validation error" do
+ it "does not update pipeline_schedule" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer),
- params: { cron: 'invalid-cron' }
+ params: {cron: "invalid-cron"}
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to have_key('cron')
+ expect(json_response["message"]).to have_key("cron")
end
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not update pipeline_schedule' do
+ context "authenticated user with invalid permissions" do
+ it "does not update pipeline_schedule" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not update pipeline_schedule' do
+ context "unauthenticated user" do
+ it "does not update pipeline_schedule" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -238,30 +238,30 @@ describe API::PipelineSchedules do
end
end
- describe 'POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/take_ownership' do
+ describe "POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/take_ownership" do
let(:pipeline_schedule) do
create(:ci_pipeline_schedule, project: project, owner: developer)
end
- context 'authenticated user with valid permissions' do
- it 'updates owner' do
+ context "authenticated user with valid permissions" do
+ it "updates owner" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", developer)
expect(response).to have_gitlab_http_status(:created)
- expect(response).to match_response_schema('pipeline_schedule')
+ expect(response).to match_response_schema("pipeline_schedule")
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not update owner' do
+ context "authenticated user with invalid permissions" do
+ it "does not update owner" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not update owner' do
+ context "unauthenticated user" do
+ it "does not update owner" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/take_ownership")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -269,7 +269,7 @@ describe API::PipelineSchedules do
end
end
- describe 'DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id' do
+ describe "DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id" do
let(:maintainer) { create(:user) }
let!(:pipeline_schedule) do
@@ -280,38 +280,38 @@ describe API::PipelineSchedules do
project.add_maintainer(maintainer)
end
- context 'authenticated user with valid permissions' do
- it 'deletes pipeline_schedule' do
- expect do
+ context "authenticated user with valid permissions" do
+ it "deletes pipeline_schedule" do
+ expect {
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer)
- end.to change { project.pipeline_schedules.count }.by(-1)
+ }.to change { project.pipeline_schedules.count }.by(-1)
expect(response).to have_gitlab_http_status(204)
end
- it 'responds with 404 Not Found if requesting non-existing pipeline_schedule' do
+ it "responds with 404 Not Found if requesting non-existing pipeline_schedule" do
delete api("/projects/#{project.id}/pipeline_schedules/-5", maintainer)
expect(response).to have_gitlab_http_status(:not_found)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", maintainer) }
end
end
- context 'authenticated user with invalid permissions' do
+ context "authenticated user with invalid permissions" do
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: maintainer) }
- it 'does not delete pipeline_schedule' do
+ it "does not delete pipeline_schedule" do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}", developer)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'unauthenticated user' do
- it 'does not delete pipeline_schedule' do
+ context "unauthenticated user" do
+ it "does not delete pipeline_schedule" do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -319,57 +319,57 @@ describe API::PipelineSchedules do
end
end
- describe 'POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables' do
+ describe "POST /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables" do
let(:params) { attributes_for(:ci_pipeline_schedule_variable) }
set(:pipeline_schedule) do
create(:ci_pipeline_schedule, project: project, owner: developer)
end
- context 'authenticated user with valid permissions' do
- context 'with required parameters' do
- it 'creates pipeline_schedule_variable' do
- expect do
+ context "authenticated user with valid permissions" do
+ context "with required parameters" do
+ it "creates pipeline_schedule_variable" do
+ expect {
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer),
params: params
- end.to change { pipeline_schedule.variables.count }.by(1)
+ }.to change { pipeline_schedule.variables.count }.by(1)
expect(response).to have_gitlab_http_status(:created)
- expect(response).to match_response_schema('pipeline_schedule_variable')
- expect(json_response['key']).to eq(params[:key])
- expect(json_response['value']).to eq(params[:value])
+ expect(response).to match_response_schema("pipeline_schedule_variable")
+ expect(json_response["key"]).to eq(params[:key])
+ expect(json_response["value"]).to eq(params[:value])
end
end
- context 'without required parameters' do
- it 'does not create pipeline_schedule_variable' do
+ context "without required parameters" do
+ it "does not create pipeline_schedule_variable" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer)
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when key has validation error' do
- it 'does not create pipeline_schedule_variable' do
+ context "when key has validation error" do
+ it "does not create pipeline_schedule_variable" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", developer),
- params: params.merge('key' => '!?!?')
+ params: params.merge("key" => "!?!?")
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to have_key('key')
+ expect(json_response["message"]).to have_key("key")
end
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not create pipeline_schedule_variable' do
+ context "authenticated user with invalid permissions" do
+ it "does not create pipeline_schedule_variable" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables", user), params: params
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not create pipeline_schedule_variable' do
+ context "unauthenticated user" do
+ it "does not create pipeline_schedule_variable" do
post api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables"), params: params
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -377,7 +377,7 @@ describe API::PipelineSchedules do
end
end
- describe 'PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ describe "PUT /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key" do
set(:pipeline_schedule) do
create(:ci_pipeline_schedule, project: project, owner: developer)
end
@@ -386,27 +386,27 @@ describe API::PipelineSchedules do
create(:ci_pipeline_schedule_variable, pipeline_schedule: pipeline_schedule)
end
- context 'authenticated user with valid permissions' do
- it 'updates pipeline_schedule_variable' do
+ context "authenticated user with valid permissions" do
+ it "updates pipeline_schedule_variable" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer),
- params: { value: 'updated_value' }
+ params: {value: "updated_value"}
expect(response).to have_gitlab_http_status(:ok)
- expect(response).to match_response_schema('pipeline_schedule_variable')
- expect(json_response['value']).to eq('updated_value')
+ expect(response).to match_response_schema("pipeline_schedule_variable")
+ expect(json_response["value"]).to eq("updated_value")
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not update pipeline_schedule_variable' do
+ context "authenticated user with invalid permissions" do
+ it "does not update pipeline_schedule_variable" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'unauthenticated user' do
- it 'does not update pipeline_schedule_variable' do
+ context "unauthenticated user" do
+ it "does not update pipeline_schedule_variable" do
put api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}")
expect(response).to have_gitlab_http_status(:unauthorized)
@@ -414,7 +414,7 @@ describe API::PipelineSchedules do
end
end
- describe 'DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key' do
+ describe "DELETE /projects/:id/pipeline_schedules/:pipeline_schedule_id/variables/:key" do
let(:maintainer) { create(:user) }
set(:pipeline_schedule) do
@@ -429,35 +429,35 @@ describe API::PipelineSchedules do
project.add_maintainer(maintainer)
end
- context 'authenticated user with valid permissions' do
- it 'deletes pipeline_schedule_variable' do
- expect do
+ context "authenticated user with valid permissions" do
+ it "deletes pipeline_schedule_variable" do
+ expect {
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", maintainer)
- end.to change { Ci::PipelineScheduleVariable.count }.by(-1)
+ }.to change { Ci::PipelineScheduleVariable.count }.by(-1)
expect(response).to have_gitlab_http_status(:accepted)
- expect(response).to match_response_schema('pipeline_schedule_variable')
+ expect(response).to match_response_schema("pipeline_schedule_variable")
end
- it 'responds with 404 Not Found if requesting non-existing pipeline_schedule_variable' do
+ it "responds with 404 Not Found if requesting non-existing pipeline_schedule_variable" do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/____", maintainer)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'authenticated user with invalid permissions' do
+ context "authenticated user with invalid permissions" do
let!(:pipeline_schedule) { create(:ci_pipeline_schedule, project: project, owner: maintainer) }
- it 'does not delete pipeline_schedule_variable' do
+ it "does not delete pipeline_schedule_variable" do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}", developer)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'unauthenticated user' do
- it 'does not delete pipeline_schedule_variable' do
+ context "unauthenticated user" do
+ it "does not delete pipeline_schedule_variable" do
delete api("/projects/#{project.id}/pipeline_schedules/#{pipeline_schedule.id}/variables/#{pipeline_schedule_variable.key}")
expect(response).to have_gitlab_http_status(:unauthorized)
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index 52599db9a9e..21ca3624ada 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Pipelines do
let(:user) { create(:user) }
@@ -14,85 +14,85 @@ describe API::Pipelines do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/pipelines ' do
- context 'authorized user' do
- it 'returns project pipelines' do
+ describe "GET /projects/:id/pipelines " do
+ context "authorized user" do
+ it "returns project pipelines" do
get api("/projects/#{project.id}/pipelines", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['sha']).to match /\A\h{40}\z/
- expect(json_response.first['id']).to eq pipeline.id
- expect(json_response.first['web_url']).to be_present
- expect(json_response.first.keys).to contain_exactly(*%w[id sha ref status web_url])
+ expect(json_response.first["sha"]).to match /\A\h{40}\z/
+ expect(json_response.first["id"]).to eq pipeline.id
+ expect(json_response.first["web_url"]).to be_present
+ expect(json_response.first.keys).to contain_exactly("id", "sha", "ref", "status", "web_url")
end
- context 'when parameter is passed' do
+ context "when parameter is passed" do
%w[running pending].each do |target|
context "when scope is #{target}" do
before do
create(:ci_pipeline, project: project, status: target)
end
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { scope: target }
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {scope: target}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- json_response.each { |r| expect(r['status']).to eq(target) }
+ json_response.each { |r| expect(r["status"]).to eq(target) }
end
end
end
- context 'when scope is finished' do
+ context "when scope is finished" do
before do
- create(:ci_pipeline, project: project, status: 'success')
- create(:ci_pipeline, project: project, status: 'failed')
- create(:ci_pipeline, project: project, status: 'canceled')
+ create(:ci_pipeline, project: project, status: "success")
+ create(:ci_pipeline, project: project, status: "failed")
+ create(:ci_pipeline, project: project, status: "canceled")
end
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { scope: 'finished' }
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {scope: "finished"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- json_response.each { |r| expect(r['status']).to be_in(%w[success failed canceled]) }
+ json_response.each { |r| expect(r["status"]).to be_in(%w[success failed canceled]) }
end
end
- context 'when scope is branches or tags' do
+ context "when scope is branches or tags" do
let!(:pipeline_branch) { create(:ci_pipeline, project: project) }
- let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: 'v1.0.0', tag: true) }
+ let!(:pipeline_tag) { create(:ci_pipeline, project: project, ref: "v1.0.0", tag: true) }
- context 'when scope is branches' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { scope: 'branches' }
+ context "when scope is branches" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {scope: "branches"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- expect(json_response.last['id']).to eq(pipeline_branch.id)
+ expect(json_response.last["id"]).to eq(pipeline_branch.id)
end
end
- context 'when scope is tags' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { scope: 'tags' }
+ context "when scope is tags" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {scope: "tags"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- expect(json_response.last['id']).to eq(pipeline_tag.id)
+ expect(json_response.last["id"]).to eq(pipeline_tag.id)
end
end
end
- context 'when scope is invalid' do
- it 'returns bad_request' do
- get api("/projects/#{project.id}/pipelines", user), params: { scope: 'invalid-scope' }
+ context "when scope is invalid" do
+ it "returns bad_request" do
+ get api("/projects/#{project.id}/pipelines", user), params: {scope: "invalid-scope"}
expect(response).to have_gitlab_http_status(:bad_request)
end
@@ -106,44 +106,44 @@ describe API::Pipelines do
create(:ci_pipeline, project: project, status: exception_status.sample)
end
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { status: target }
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {status: target}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- json_response.each { |r| expect(r['status']).to eq(target) }
+ json_response.each { |r| expect(r["status"]).to eq(target) }
end
end
end
- context 'when status is invalid' do
- it 'returns bad_request' do
- get api("/projects/#{project.id}/pipelines", user), params: { status: 'invalid-status' }
+ context "when status is invalid" do
+ it "returns bad_request" do
+ get api("/projects/#{project.id}/pipelines", user), params: {status: "invalid-status"}
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when ref is specified' do
+ context "when ref is specified" do
before do
create(:ci_pipeline, project: project)
end
- context 'when ref exists' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { ref: 'master' }
+ context "when ref exists" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {ref: "master"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
- json_response.each { |r| expect(r['ref']).to eq('master') }
+ json_response.each { |r| expect(r["ref"]).to eq("master") }
end
end
- context 'when ref does not exist' do
- it 'returns empty' do
- get api("/projects/#{project.id}/pipelines", user), params: { ref: 'invalid-ref' }
+ context "when ref does not exist" do
+ it "returns empty" do
+ get api("/projects/#{project.id}/pipelines", user), params: {ref: "invalid-ref"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
@@ -152,22 +152,22 @@ describe API::Pipelines do
end
end
- context 'when name is specified' do
+ context "when name is specified" do
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
- context 'when name exists' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { name: user.name }
+ context "when name exists" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {name: user.name}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
- expect(json_response.first['id']).to eq(pipeline.id)
+ expect(json_response.first["id"]).to eq(pipeline.id)
end
end
- context 'when name does not exist' do
- it 'returns empty' do
- get api("/projects/#{project.id}/pipelines", user), params: { name: 'invalid-name' }
+ context "when name does not exist" do
+ it "returns empty" do
+ get api("/projects/#{project.id}/pipelines", user), params: {name: "invalid-name"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
@@ -176,22 +176,22 @@ describe API::Pipelines do
end
end
- context 'when username is specified' do
+ context "when username is specified" do
let!(:pipeline) { create(:ci_pipeline, project: project, user: user) }
- context 'when username exists' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { username: user.username }
+ context "when username exists" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {username: user.username}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
- expect(json_response.first['id']).to eq(pipeline.id)
+ expect(json_response.first["id"]).to eq(pipeline.id)
end
end
- context 'when username does not exist' do
- it 'returns empty' do
- get api("/projects/#{project.id}/pipelines", user), params: { username: 'invalid-username' }
+ context "when username does not exist" do
+ it "returns empty" do
+ get api("/projects/#{project.id}/pipelines", user), params: {username: "invalid-username"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
@@ -200,72 +200,72 @@ describe API::Pipelines do
end
end
- context 'when yaml_errors is specified' do
- let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: 'Syntax error') }
+ context "when yaml_errors is specified" do
+ let!(:pipeline1) { create(:ci_pipeline, project: project, yaml_errors: "Syntax error") }
let!(:pipeline2) { create(:ci_pipeline, project: project) }
- context 'when yaml_errors is true' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: true }
+ context "when yaml_errors is true" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {yaml_errors: true}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
- expect(json_response.first['id']).to eq(pipeline1.id)
+ expect(json_response.first["id"]).to eq(pipeline1.id)
end
end
- context 'when yaml_errors is false' do
- it 'returns matched pipelines' do
- get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: false }
+ context "when yaml_errors is false" do
+ it "returns matched pipelines" do
+ get api("/projects/#{project.id}/pipelines", user), params: {yaml_errors: false}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
- expect(json_response.first['id']).to eq(pipeline2.id)
+ expect(json_response.first["id"]).to eq(pipeline2.id)
end
end
- context 'when yaml_errors is invalid' do
- it 'returns bad_request' do
- get api("/projects/#{project.id}/pipelines", user), params: { yaml_errors: 'invalid-yaml_errors' }
+ context "when yaml_errors is invalid" do
+ it "returns bad_request" do
+ get api("/projects/#{project.id}/pipelines", user), params: {yaml_errors: "invalid-yaml_errors"}
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
- context 'when order_by and sort are specified' do
- context 'when order_by user_id' do
+ context "when order_by and sort are specified" do
+ context "when order_by user_id" do
before do
3.times do
create(:ci_pipeline, project: project, user: create(:user))
end
end
- context 'when sort parameter is valid' do
- it 'sorts as user_id: :desc' do
- get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'user_id', sort: 'desc' }
+ context "when sort parameter is valid" do
+ it "sorts as user_id: :desc" do
+ get api("/projects/#{project.id}/pipelines", user), params: {order_by: "user_id", sort: "desc"}
expect(response).to have_gitlab_http_status(:ok)
expect(response).to include_pagination_headers
expect(json_response).not_to be_empty
pipeline_ids = Ci::Pipeline.all.order(user_id: :desc).pluck(:id)
- expect(json_response.map { |r| r['id'] }).to eq(pipeline_ids)
+ expect(json_response.map { |r| r["id"] }).to eq(pipeline_ids)
end
end
- context 'when sort parameter is invalid' do
- it 'returns bad_request' do
- get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'user_id', sort: 'invalid_sort' }
+ context "when sort parameter is invalid" do
+ it "returns bad_request" do
+ get api("/projects/#{project.id}/pipelines", user), params: {order_by: "user_id", sort: "invalid_sort"}
expect(response).to have_gitlab_http_status(:bad_request)
end
end
end
- context 'when order_by is invalid' do
- it 'returns bad_request' do
- get api("/projects/#{project.id}/pipelines", user), params: { order_by: 'lock_version', sort: 'asc' }
+ context "when order_by is invalid" do
+ it "returns bad_request" do
+ get api("/projects/#{project.id}/pipelines", user), params: {order_by: "lock_version", sort: "asc"}
expect(response).to have_gitlab_http_status(:bad_request)
end
@@ -274,152 +274,152 @@ describe API::Pipelines do
end
end
- context 'unauthorized user' do
- it 'does not return project pipelines' do
+ context "unauthorized user" do
+ it "does not return project pipelines" do
get api("/projects/#{project.id}/pipelines", non_member)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Project Not Found'
+ expect(json_response["message"]).to eq "404 Project Not Found"
expect(json_response).not_to be_an Array
end
end
end
- describe 'POST /projects/:id/pipeline ' do
+ describe "POST /projects/:id/pipeline " do
def expect_variables(variables, expected_variables)
variables.each_with_index do |variable, index|
expected_variable = expected_variables[index]
- expect(variable.key).to eq(expected_variable['key'])
- expect(variable.value).to eq(expected_variable['value'])
+ expect(variable.key).to eq(expected_variable["key"])
+ expect(variable.value).to eq(expected_variable["value"])
end
end
- context 'authorized user' do
- context 'with gitlab-ci.yml' do
+ context "authorized user" do
+ context "with gitlab-ci.yml" do
before do
stub_ci_pipeline_to_return_yaml_file
end
- it 'creates and returns a new pipeline' do
- expect do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
- end.to change { project.ci_pipelines.count }.by(1)
+ it "creates and returns a new pipeline" do
+ expect {
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: project.default_branch}
+ }.to change { project.ci_pipelines.count }.by(1)
expect(response).to have_gitlab_http_status(201)
expect(json_response).to be_a Hash
- expect(json_response['sha']).to eq project.commit.id
+ expect(json_response["sha"]).to eq project.commit.id
end
- context 'variables given' do
- let(:variables) { [{ 'key' => 'UPLOAD_TO_S3', 'value' => 'true' }] }
+ context "variables given" do
+ let(:variables) { [{"key" => "UPLOAD_TO_S3", "value" => "true"}] }
- it 'creates and returns a new pipeline using the given variables' do
- expect do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch, variables: variables }
- end.to change { project.ci_pipelines.count }.by(1)
+ it "creates and returns a new pipeline using the given variables" do
+ expect {
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: project.default_branch, variables: variables}
+ }.to change { project.ci_pipelines.count }.by(1)
expect_variables(project.ci_pipelines.last.variables, variables)
expect(response).to have_gitlab_http_status(201)
expect(json_response).to be_a Hash
- expect(json_response['sha']).to eq project.commit.id
- expect(json_response).not_to have_key('variables')
+ expect(json_response["sha"]).to eq project.commit.id
+ expect(json_response).not_to have_key("variables")
end
end
- describe 'using variables conditions' do
- let(:variables) { [{ 'key' => 'STAGING', 'value' => 'true' }] }
+ describe "using variables conditions" do
+ let(:variables) { [{"key" => "STAGING", "value" => "true"}] }
before do
- config = YAML.dump(test: { script: 'test', only: { variables: ['$STAGING'] } })
+ config = YAML.dump(test: {script: "test", only: {variables: ["$STAGING"]}})
stub_ci_pipeline_yaml_file(config)
end
- it 'creates and returns a new pipeline using the given variables' do
- expect do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch, variables: variables }
- end.to change { project.ci_pipelines.count }.by(1)
+ it "creates and returns a new pipeline using the given variables" do
+ expect {
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: project.default_branch, variables: variables}
+ }.to change { project.ci_pipelines.count }.by(1)
expect_variables(project.ci_pipelines.last.variables, variables)
expect(response).to have_gitlab_http_status(201)
expect(json_response).to be_a Hash
- expect(json_response['sha']).to eq project.commit.id
- expect(json_response).not_to have_key('variables')
+ expect(json_response["sha"]).to eq project.commit.id
+ expect(json_response).not_to have_key("variables")
end
- context 'condition unmatch' do
- let(:variables) { [{ 'key' => 'STAGING', 'value' => 'false' }] }
+ context "condition unmatch" do
+ let(:variables) { [{"key" => "STAGING", "value" => "false"}] }
it "doesn't create a job" do
- expect do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
- end.not_to change { project.ci_pipelines.count }
+ expect {
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: project.default_branch}
+ }.not_to change { project.ci_pipelines.count }
expect(response).to have_gitlab_http_status(400)
end
end
end
- it 'fails when using an invalid ref' do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: 'invalid_ref' }
+ it "fails when using an invalid ref" do
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: "invalid_ref"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['base'].first).to eq 'Reference not found'
+ expect(json_response["message"]["base"].first).to eq "Reference not found"
expect(json_response).not_to be_an Array
end
end
- context 'without gitlab-ci.yml' do
- context 'without auto devops enabled' do
+ context "without gitlab-ci.yml" do
+ context "without auto devops enabled" do
before do
- project.update!(auto_devops_attributes: { enabled: false })
+ project.update!(auto_devops_attributes: {enabled: false})
end
- it 'fails to create pipeline' do
- post api("/projects/#{project.id}/pipeline", user), params: { ref: project.default_branch }
+ it "fails to create pipeline" do
+ post api("/projects/#{project.id}/pipeline", user), params: {ref: project.default_branch}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['base'].first).to eq 'Missing .gitlab-ci.yml file'
+ expect(json_response["message"]["base"].first).to eq "Missing .gitlab-ci.yml file"
expect(json_response).not_to be_an Array
end
end
end
end
- context 'unauthorized user' do
- it 'does not create pipeline' do
- post api("/projects/#{project.id}/pipeline", non_member), params: { ref: project.default_branch }
+ context "unauthorized user" do
+ it "does not create pipeline" do
+ post api("/projects/#{project.id}/pipeline", non_member), params: {ref: project.default_branch}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Project Not Found'
+ expect(json_response["message"]).to eq "404 Project Not Found"
expect(json_response).not_to be_an Array
end
end
end
- describe 'GET /projects/:id/pipelines/:pipeline_id' do
- context 'authorized user' do
- it 'returns project pipelines' do
+ describe "GET /projects/:id/pipelines/:pipeline_id" do
+ context "authorized user" do
+ it "returns project pipelines" do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['sha']).to match /\A\h{40}\z/
+ expect(json_response["sha"]).to match /\A\h{40}\z/
end
- it 'returns 404 when it does not exist' do
+ it "returns 404 when it does not exist" do
get api("/projects/#{project.id}/pipelines/123456", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Not found'
- expect(json_response['id']).to be nil
+ expect(json_response["message"]).to eq "404 Not found"
+ expect(json_response["id"]).to be nil
end
- context 'with coverage' do
+ context "with coverage" do
before do
create(:ci_build, coverage: 30, pipeline: pipeline)
end
- it 'exposes the coverage' do
+ it "exposes the coverage" do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user)
expect(json_response["coverage"].to_i).to eq(30)
@@ -427,43 +427,43 @@ describe API::Pipelines do
end
end
- context 'unauthorized user' do
- it 'should not return a project pipeline' do
+ context "unauthorized user" do
+ it "should not return a project pipeline" do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Project Not Found'
- expect(json_response['id']).to be nil
+ expect(json_response["message"]).to eq "404 Project Not Found"
+ expect(json_response["id"]).to be nil
end
end
end
- describe 'DELETE /projects/:id/pipelines/:pipeline_id' do
- context 'authorized user' do
+ describe "DELETE /projects/:id/pipelines/:pipeline_id" do
+ context "authorized user" do
let(:owner) { project.owner }
- it 'destroys the pipeline' do
+ it "destroys the pipeline" do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
expect(response).to have_gitlab_http_status(204)
expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'returns 404 when it does not exist' do
+ it "returns 404 when it does not exist" do
delete api("/projects/#{project.id}/pipelines/123456", owner)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Not found'
+ expect(json_response["message"]).to eq "404 Not found"
end
- it 'does not log an audit event' do
+ it "does not log an audit event" do
expect { delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner) }.not_to change { SecurityEvent.count }
end
- context 'when the pipeline has jobs' do
+ context "when the pipeline has jobs" do
let!(:build) { create(:ci_build, project: project, pipeline: pipeline) }
- it 'destroys associated jobs' do
+ it "destroys associated jobs" do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", owner)
expect(response).to have_gitlab_http_status(204)
@@ -472,35 +472,35 @@ describe API::Pipelines do
end
end
- context 'unauthorized user' do
- context 'when user is not member' do
- it 'should return a 404' do
+ context "unauthorized user" do
+ context "when user is not member" do
+ it "should return a 404" do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", non_member)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Project Not Found'
+ expect(json_response["message"]).to eq "404 Project Not Found"
end
end
- context 'when user is developer' do
+ context "when user is developer" do
let(:developer) { create(:user) }
before do
project.add_developer(developer)
end
- it 'should return a 403' do
+ it "should return a 403" do
delete api("/projects/#{project.id}/pipelines/#{pipeline.id}", developer)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq '403 Forbidden'
+ expect(json_response["message"]).to eq "403 Forbidden"
end
end
end
end
- describe 'POST /projects/:id/pipelines/:pipeline_id/retry' do
- context 'authorized user' do
+ describe "POST /projects/:id/pipelines/:pipeline_id/retry" do
+ context "authorized user" do
let!(:pipeline) do
create(:ci_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch)
@@ -508,28 +508,28 @@ describe API::Pipelines do
let!(:build) { create(:ci_build, :failed, pipeline: pipeline) }
- it 'retries failed builds' do
- expect do
+ it "retries failed builds" do
+ expect {
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", user)
- end.to change { pipeline.builds.count }.from(1).to(2)
+ }.to change { pipeline.builds.count }.from(1).to(2)
expect(response).to have_gitlab_http_status(201)
expect(build.reload.retried?).to be true
end
end
- context 'unauthorized user' do
- it 'should not return a project pipeline' do
+ context "unauthorized user" do
+ it "should not return a project pipeline" do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/retry", non_member)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq '404 Project Not Found'
- expect(json_response['id']).to be nil
+ expect(json_response["message"]).to eq "404 Project Not Found"
+ expect(json_response["id"]).to be nil
end
end
end
- describe 'POST /projects/:id/pipelines/:pipeline_id/cancel' do
+ describe "POST /projects/:id/pipelines/:pipeline_id/cancel" do
let!(:pipeline) do
create(:ci_empty_pipeline, project: project, sha: project.commit.id,
ref: project.default_branch)
@@ -537,27 +537,27 @@ describe API::Pipelines do
let!(:build) { create(:ci_build, :running, pipeline: pipeline) }
- context 'authorized user' do
- it 'retries failed builds' do
+ context "authorized user" do
+ it "retries failed builds" do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['status']).to eq('canceled')
+ expect(json_response["status"]).to eq("canceled")
end
end
- context 'user without proper access rights' do
+ context "user without proper access rights" do
let!(:reporter) { create(:user) }
before do
project.add_reporter(reporter)
end
- it 'rejects the action' do
+ it "rejects the action" do
post api("/projects/#{project.id}/pipelines/#{pipeline.id}/cancel", reporter)
expect(response).to have_gitlab_http_status(403)
- expect(pipeline.reload.status).to eq('pending')
+ expect(pipeline.reload.status).to eq("pending")
end
end
end
diff --git a/spec/requests/api/project_clusters_spec.rb b/spec/requests/api/project_clusters_spec.rb
index 9bab1f95150..83578eb13cf 100644
--- a/spec/requests/api/project_clusters_spec.rb
+++ b/spec/requests/api/project_clusters_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectClusters do
include KubernetesHelpers
@@ -13,37 +13,37 @@ describe API::ProjectClusters do
project.add_maintainer(current_user)
end
- describe 'GET /projects/:id/clusters' do
+ describe "GET /projects/:id/clusters" do
let!(:extra_cluster) { create(:cluster, :provided_by_gcp, :project) }
let!(:clusters) do
create_list(:cluster, 5, :provided_by_gcp, :project, :production_environment,
- projects: [project])
+ projects: [project])
end
- context 'non-authorized user' do
- it 'should respond with 404' do
+ context "non-authorized user" do
+ it "should respond with 404" do
get api("/projects/#{project.id}/clusters", non_member)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
+ context "authorized user" do
before do
get api("/projects/#{project.id}/clusters", current_user)
end
- it 'should respond with 200' do
+ it "should respond with 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'should include pagination headers' do
+ it "should include pagination headers" do
expect(response).to include_pagination_headers
end
- it 'should only include authorized clusters' do
- cluster_ids = json_response.map { |cluster| cluster['id'] }
+ it "should only include authorized clusters" do
+ cluster_ids = json_response.map { |cluster| cluster["id"] }
expect(cluster_ids).to match_array(clusters.pluck(:id))
expect(cluster_ids).not_to include(extra_cluster.id)
@@ -51,102 +51,102 @@ describe API::ProjectClusters do
end
end
- describe 'GET /projects/:id/clusters/:cluster_id' do
+ describe "GET /projects/:id/clusters/:cluster_id" do
let(:cluster_id) { cluster.id }
let(:platform_kubernetes) do
create(:cluster_platform_kubernetes, :configured,
- namespace: 'project-namespace')
+ namespace: "project-namespace")
end
let(:cluster) do
create(:cluster, :project, :provided_by_gcp,
- platform_kubernetes: platform_kubernetes,
- user: current_user,
- projects: [project])
+ platform_kubernetes: platform_kubernetes,
+ user: current_user,
+ projects: [project])
end
- context 'non-authorized user' do
- it 'should respond with 404' do
+ context "non-authorized user" do
+ it "should respond with 404" do
get api("/projects/#{project.id}/clusters/#{cluster_id}", non_member)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
+ context "authorized user" do
before do
get api("/projects/#{project.id}/clusters/#{cluster_id}", current_user)
end
- it 'returns specific cluster' do
- expect(json_response['id']).to eq(cluster.id)
+ it "returns specific cluster" do
+ expect(json_response["id"]).to eq(cluster.id)
end
- it 'returns cluster information' do
- expect(json_response['provider_type']).to eq('gcp')
- expect(json_response['platform_type']).to eq('kubernetes')
- expect(json_response['environment_scope']).to eq('*')
- expect(json_response['cluster_type']).to eq('project_type')
+ it "returns cluster information" do
+ expect(json_response["provider_type"]).to eq("gcp")
+ expect(json_response["platform_type"]).to eq("kubernetes")
+ expect(json_response["environment_scope"]).to eq("*")
+ expect(json_response["cluster_type"]).to eq("project_type")
end
- it 'returns project information' do
- cluster_project = json_response['project']
+ it "returns project information" do
+ cluster_project = json_response["project"]
- expect(cluster_project['id']).to eq(project.id)
- expect(cluster_project['name']).to eq(project.name)
- expect(cluster_project['path']).to eq(project.path)
+ expect(cluster_project["id"]).to eq(project.id)
+ expect(cluster_project["name"]).to eq(project.name)
+ expect(cluster_project["path"]).to eq(project.path)
end
- it 'returns kubernetes platform information' do
- platform = json_response['platform_kubernetes']
+ it "returns kubernetes platform information" do
+ platform = json_response["platform_kubernetes"]
- expect(platform['api_url']).to eq('https://kubernetes.example.com')
- expect(platform['namespace']).to eq('project-namespace')
- expect(platform['ca_cert']).to be_present
+ expect(platform["api_url"]).to eq("https://kubernetes.example.com")
+ expect(platform["namespace"]).to eq("project-namespace")
+ expect(platform["ca_cert"]).to be_present
end
- it 'returns user information' do
- user = json_response['user']
+ it "returns user information" do
+ user = json_response["user"]
- expect(user['id']).to eq(current_user.id)
- expect(user['username']).to eq(current_user.username)
+ expect(user["id"]).to eq(current_user.id)
+ expect(user["username"]).to eq(current_user.username)
end
- it 'returns GCP provider information' do
- gcp_provider = json_response['provider_gcp']
+ it "returns GCP provider information" do
+ gcp_provider = json_response["provider_gcp"]
- expect(gcp_provider['cluster_id']).to eq(cluster.id)
- expect(gcp_provider['status_name']).to eq('created')
- expect(gcp_provider['gcp_project_id']).to eq('test-gcp-project')
- expect(gcp_provider['zone']).to eq('us-central1-a')
- expect(gcp_provider['machine_type']).to eq('n1-standard-2')
- expect(gcp_provider['num_nodes']).to eq(3)
- expect(gcp_provider['endpoint']).to eq('111.111.111.111')
+ expect(gcp_provider["cluster_id"]).to eq(cluster.id)
+ expect(gcp_provider["status_name"]).to eq("created")
+ expect(gcp_provider["gcp_project_id"]).to eq("test-gcp-project")
+ expect(gcp_provider["zone"]).to eq("us-central1-a")
+ expect(gcp_provider["machine_type"]).to eq("n1-standard-2")
+ expect(gcp_provider["num_nodes"]).to eq(3)
+ expect(gcp_provider["endpoint"]).to eq("111.111.111.111")
end
- context 'when cluster has no provider' do
+ context "when cluster has no provider" do
let(:cluster) do
create(:cluster, :project, :provided_by_user,
- projects: [project])
+ projects: [project])
end
- it 'should not include GCP provider info' do
- expect(json_response['provider_gcp']).not_to be_present
+ it "should not include GCP provider info" do
+ expect(json_response["provider_gcp"]).not_to be_present
end
end
- context 'with non-existing cluster' do
+ context "with non-existing cluster" do
let(:cluster_id) { 123 }
- it 'returns 404' do
+ it "returns 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
end
- shared_context 'kubernetes calls stubbed' do
+ shared_context "kubernetes calls stubbed" do
before do
stub_kubeclient_discover(api_url)
stub_kubeclient_get_namespace(api_url, namespace: namespace)
@@ -157,8 +157,8 @@ describe API::ProjectClusters do
api_url,
{
metadata_name: "#{namespace}-token",
- token: Base64.encode64('sample-token'),
- namespace: namespace
+ token: Base64.encode64("sample-token"),
+ namespace: namespace,
}
)
@@ -168,297 +168,297 @@ describe API::ProjectClusters do
end
end
- describe 'POST /projects/:id/clusters/user' do
- include_context 'kubernetes calls stubbed'
+ describe "POST /projects/:id/clusters/user" do
+ include_context "kubernetes calls stubbed"
- let(:api_url) { 'https://kubernetes.example.com' }
+ let(:api_url) { "https://kubernetes.example.com" }
let(:namespace) { project.path }
- let(:authorization_type) { 'rbac' }
+ let(:authorization_type) { "rbac" }
let(:platform_kubernetes_attributes) do
{
api_url: api_url,
- token: 'sample-token',
+ token: "sample-token",
namespace: namespace,
- authorization_type: authorization_type
+ authorization_type: authorization_type,
}
end
let(:cluster_params) do
{
- name: 'test-cluster',
- platform_kubernetes_attributes: platform_kubernetes_attributes
+ name: "test-cluster",
+ platform_kubernetes_attributes: platform_kubernetes_attributes,
}
end
- context 'non-authorized user' do
- it 'should respond with 404' do
+ context "non-authorized user" do
+ it "should respond with 404" do
post api("/projects/#{project.id}/clusters/user", non_member), params: cluster_params
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
+ context "authorized user" do
before do
post api("/projects/#{project.id}/clusters/user", current_user), params: cluster_params
end
- context 'with valid params' do
- it 'should respond with 201' do
+ context "with valid params" do
+ it "should respond with 201" do
expect(response).to have_gitlab_http_status(201)
end
- it 'should create a new Cluster::Cluster' do
+ it "should create a new Cluster::Cluster" do
cluster_result = Clusters::Cluster.find(json_response["id"])
platform_kubernetes = cluster_result.platform
expect(cluster_result).to be_user
expect(cluster_result).to be_kubernetes
expect(cluster_result.project).to eq(project)
- expect(cluster_result.name).to eq('test-cluster')
+ expect(cluster_result.name).to eq("test-cluster")
expect(platform_kubernetes.rbac?).to be_truthy
expect(platform_kubernetes.api_url).to eq(api_url)
expect(platform_kubernetes.namespace).to eq(namespace)
- expect(platform_kubernetes.token).to eq('sample-token')
+ expect(platform_kubernetes.token).to eq("sample-token")
end
end
- context 'when user does not indicate authorization type' do
+ context "when user does not indicate authorization type" do
let(:platform_kubernetes_attributes) do
{
api_url: api_url,
- token: 'sample-token',
- namespace: namespace
+ token: "sample-token",
+ namespace: namespace,
}
end
- it 'defaults to RBAC' do
- cluster_result = Clusters::Cluster.find(json_response['id'])
+ it "defaults to RBAC" do
+ cluster_result = Clusters::Cluster.find(json_response["id"])
expect(cluster_result.platform_kubernetes.rbac?).to be_truthy
end
end
- context 'when user sets authorization type as ABAC' do
- let(:authorization_type) { 'abac' }
+ context "when user sets authorization type as ABAC" do
+ let(:authorization_type) { "abac" }
- it 'should create an ABAC cluster' do
- cluster_result = Clusters::Cluster.find(json_response['id'])
+ it "should create an ABAC cluster" do
+ cluster_result = Clusters::Cluster.find(json_response["id"])
expect(cluster_result.platform.abac?).to be_truthy
end
end
- context 'with invalid params' do
- let(:namespace) { 'invalid_namespace' }
+ context "with invalid params" do
+ let(:namespace) { "invalid_namespace" }
- it 'should respond with 400' do
+ it "should respond with 400" do
expect(response).to have_gitlab_http_status(400)
end
- it 'should not create a new Clusters::Cluster' do
+ it "should not create a new Clusters::Cluster" do
expect(project.reload.clusters).to be_empty
end
- it 'should return validation errors' do
- expect(json_response['message']['platform_kubernetes.namespace'].first).to be_present
+ it "should return validation errors" do
+ expect(json_response["message"]["platform_kubernetes.namespace"].first).to be_present
end
end
end
- context 'when user tries to add multiple clusters' do
+ context "when user tries to add multiple clusters" do
before do
create(:cluster, :provided_by_gcp, :project,
- projects: [project])
+ projects: [project])
post api("/projects/#{project.id}/clusters/user", current_user), params: cluster_params
end
- it 'should respond with 403' do
+ it "should respond with 403" do
expect(response).to have_gitlab_http_status(403)
end
- it 'should return an appropriate message' do
- expect(json_response['message']).to include('Instance does not support multiple Kubernetes clusters')
+ it "should return an appropriate message" do
+ expect(json_response["message"]).to include("Instance does not support multiple Kubernetes clusters")
end
end
end
- describe 'PUT /projects/:id/clusters/:cluster_id' do
- include_context 'kubernetes calls stubbed'
+ describe "PUT /projects/:id/clusters/:cluster_id" do
+ include_context "kubernetes calls stubbed"
- let(:api_url) { 'https://kubernetes.example.com' }
- let(:namespace) { 'new-namespace' }
- let(:platform_kubernetes_attributes) { { namespace: namespace } }
+ let(:api_url) { "https://kubernetes.example.com" }
+ let(:namespace) { "new-namespace" }
+ let(:platform_kubernetes_attributes) { {namespace: namespace} }
let(:update_params) do
{
- platform_kubernetes_attributes: platform_kubernetes_attributes
+ platform_kubernetes_attributes: platform_kubernetes_attributes,
}
end
let!(:kubernetes_namespace) do
create(:cluster_kubernetes_namespace,
- cluster: cluster,
- project: project)
+ cluster: cluster,
+ project: project)
end
let(:cluster) do
create(:cluster, :project, :provided_by_gcp,
- projects: [project])
+ projects: [project])
end
- context 'non-authorized user' do
- it 'should respond with 404' do
+ context "non-authorized user" do
+ it "should respond with 404" do
put api("/projects/#{project.id}/clusters/#{cluster.id}", non_member), params: update_params
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
+ context "authorized user" do
before do
put api("/projects/#{project.id}/clusters/#{cluster.id}", current_user), params: update_params
cluster.reload
end
- context 'with valid params' do
- it 'should respond with 200' do
+ context "with valid params" do
+ it "should respond with 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'should update cluster attributes' do
- expect(cluster.platform_kubernetes.namespace).to eq('new-namespace')
- expect(cluster.kubernetes_namespace.namespace).to eq('new-namespace')
+ it "should update cluster attributes" do
+ expect(cluster.platform_kubernetes.namespace).to eq("new-namespace")
+ expect(cluster.kubernetes_namespace.namespace).to eq("new-namespace")
end
end
- context 'with invalid params' do
- let(:namespace) { 'invalid_namespace' }
+ context "with invalid params" do
+ let(:namespace) { "invalid_namespace" }
- it 'should respond with 400' do
+ it "should respond with 400" do
expect(response).to have_gitlab_http_status(400)
end
- it 'should not update cluster attributes' do
- expect(cluster.platform_kubernetes.namespace).not_to eq('invalid_namespace')
- expect(cluster.kubernetes_namespace.namespace).not_to eq('invalid_namespace')
+ it "should not update cluster attributes" do
+ expect(cluster.platform_kubernetes.namespace).not_to eq("invalid_namespace")
+ expect(cluster.kubernetes_namespace.namespace).not_to eq("invalid_namespace")
end
- it 'should return validation errors' do
- expect(json_response['message']['platform_kubernetes.namespace'].first).to match('can contain only lowercase letters')
+ it "should return validation errors" do
+ expect(json_response["message"]["platform_kubernetes.namespace"].first).to match("can contain only lowercase letters")
end
end
- context 'with a GCP cluster' do
- context 'when user tries to change GCP specific fields' do
+ context "with a GCP cluster" do
+ context "when user tries to change GCP specific fields" do
let(:platform_kubernetes_attributes) do
{
- api_url: 'https://new-api-url.com',
- token: 'new-sample-token'
+ api_url: "https://new-api-url.com",
+ token: "new-sample-token",
}
end
- it 'should respond with 400' do
+ it "should respond with 400" do
expect(response).to have_gitlab_http_status(400)
end
- it 'should return validation error' do
- expect(json_response['message']['platform_kubernetes.base'].first).to eq('Cannot modify managed Kubernetes cluster')
+ it "should return validation error" do
+ expect(json_response["message"]["platform_kubernetes.base"].first).to eq("Cannot modify managed Kubernetes cluster")
end
end
- context 'when user tries to change namespace' do
- let(:namespace) { 'new-namespace' }
+ context "when user tries to change namespace" do
+ let(:namespace) { "new-namespace" }
- it 'should respond with 200' do
+ it "should respond with 200" do
expect(response).to have_gitlab_http_status(200)
end
end
end
- context 'with an user cluster' do
- let(:api_url) { 'https://new-api-url.com' }
+ context "with an user cluster" do
+ let(:api_url) { "https://new-api-url.com" }
let(:cluster) do
create(:cluster, :project, :provided_by_user,
- projects: [project])
+ projects: [project])
end
let(:platform_kubernetes_attributes) do
{
api_url: api_url,
- namespace: 'new-namespace',
- token: 'new-sample-token'
+ namespace: "new-namespace",
+ token: "new-sample-token",
}
end
let(:update_params) do
{
- name: 'new-name',
- platform_kubernetes_attributes: platform_kubernetes_attributes
+ name: "new-name",
+ platform_kubernetes_attributes: platform_kubernetes_attributes,
}
end
- it 'should respond with 200' do
+ it "should respond with 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'should update platform kubernetes attributes' do
+ it "should update platform kubernetes attributes" do
platform_kubernetes = cluster.platform_kubernetes
- expect(cluster.name).to eq('new-name')
- expect(platform_kubernetes.namespace).to eq('new-namespace')
- expect(platform_kubernetes.api_url).to eq('https://new-api-url.com')
- expect(platform_kubernetes.token).to eq('new-sample-token')
+ expect(cluster.name).to eq("new-name")
+ expect(platform_kubernetes.namespace).to eq("new-namespace")
+ expect(platform_kubernetes.api_url).to eq("https://new-api-url.com")
+ expect(platform_kubernetes.token).to eq("new-sample-token")
end
end
- context 'with a cluster that does not belong to user' do
+ context "with a cluster that does not belong to user" do
let(:cluster) { create(:cluster, :project, :provided_by_user) }
- it 'should respond with 404' do
+ it "should respond with 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
end
- describe 'DELETE /projects/:id/clusters/:cluster_id' do
- let(:cluster_params) { { cluster_id: cluster.id } }
+ describe "DELETE /projects/:id/clusters/:cluster_id" do
+ let(:cluster_params) { {cluster_id: cluster.id} }
let(:cluster) do
create(:cluster, :project, :provided_by_gcp,
- projects: [project])
+ projects: [project])
end
- context 'non-authorized user' do
- it 'should respond with 404' do
+ context "non-authorized user" do
+ it "should respond with 404" do
delete api("/projects/#{project.id}/clusters/#{cluster.id}", non_member), params: cluster_params
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
+ context "authorized user" do
before do
delete api("/projects/#{project.id}/clusters/#{cluster.id}", current_user), params: cluster_params
end
- it 'should respond with 204' do
+ it "should respond with 204" do
expect(response).to have_gitlab_http_status(204)
end
- it 'should delete the cluster' do
+ it "should delete the cluster" do
expect(Clusters::Cluster.exists?(id: cluster.id)).to be_falsy
end
- context 'with a cluster that does not belong to user' do
+ context "with a cluster that does not belong to user" do
let(:cluster) { create(:cluster, :project, :provided_by_user) }
- it 'should respond with 404' do
+ it "should respond with 404" do
expect(response).to have_gitlab_http_status(404)
end
end
diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb
index 1d2f81a397d..4356cd20b44 100644
--- a/spec/requests/api/project_export_spec.rb
+++ b/spec/requests/api/project_export_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectExport do
set(:project) { create(:project) }
@@ -27,7 +27,7 @@ describe API::ProjectExport do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
# simulate exporting work directory
- FileUtils.mkdir_p File.join(project_started.export_path, 'securerandom-hex')
+ FileUtils.mkdir_p File.join(project_started.export_path, "securerandom-hex")
# simulate in after export action
FileUtils.touch Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy.lock_file_path(project_after_export)
@@ -37,73 +37,73 @@ describe API::ProjectExport do
FileUtils.rm_rf(export_path, secure: true)
end
- shared_examples_for 'when project export is disabled' do
+ shared_examples_for "when project export is disabled" do
before do
stub_application_setting(project_export_enabled?: false)
end
- it_behaves_like '404 response'
+ it_behaves_like "404 response"
end
- describe 'GET /projects/:project_id/export' do
- shared_examples_for 'get project export status not found' do
- it_behaves_like '404 response' do
+ describe "GET /projects/:project_id/export" do
+ shared_examples_for "get project export status not found" do
+ it_behaves_like "404 response" do
let(:request) { get api(path, user) }
end
end
- shared_examples_for 'get project export status denied' do
- it_behaves_like '403 response' do
+ shared_examples_for "get project export status denied" do
+ it_behaves_like "403 response" do
let(:request) { get api(path, user) }
end
end
- shared_examples_for 'get project export status ok' do
- it 'is none' do
+ shared_examples_for "get project export status ok" do
+ it "is none" do
get api(path_none, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/project/export_status')
- expect(json_response['export_status']).to eq('none')
+ expect(response).to match_response_schema("public_api/v4/project/export_status")
+ expect(json_response["export_status"]).to eq("none")
end
- it 'is started' do
+ it "is started" do
get api(path_started, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/project/export_status')
- expect(json_response['export_status']).to eq('started')
+ expect(response).to match_response_schema("public_api/v4/project/export_status")
+ expect(json_response["export_status"]).to eq("started")
end
- it 'is after_export' do
+ it "is after_export" do
get api(path_after_export, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/project/export_status')
- expect(json_response['export_status']).to eq('after_export_action')
+ expect(response).to match_response_schema("public_api/v4/project/export_status")
+ expect(json_response["export_status"]).to eq("after_export_action")
end
- it 'is finished' do
+ it "is finished" do
get api(path_finished, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/project/export_status')
- expect(json_response['export_status']).to eq('finished')
+ expect(response).to match_response_schema("public_api/v4/project/export_status")
+ expect(json_response["export_status"]).to eq("finished")
end
end
- it_behaves_like 'when project export is disabled' do
+ it_behaves_like "when project export is disabled" do
let(:request) { get api(path, admin) }
end
- context 'when project export is enabled' do
- context 'when user is an admin' do
+ context "when project export is enabled" do
+ context "when user is an admin" do
let(:user) { admin }
- it_behaves_like 'get project export status ok'
+ it_behaves_like "get project export status ok"
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
project_none.add_maintainer(user)
@@ -112,114 +112,114 @@ describe API::ProjectExport do
project_after_export.add_maintainer(user)
end
- it_behaves_like 'get project export status ok'
+ it_behaves_like "get project export status ok"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like 'get project export status denied'
+ it_behaves_like "get project export status denied"
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like 'get project export status denied'
+ it_behaves_like "get project export status denied"
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like 'get project export status denied'
+ it_behaves_like "get project export status denied"
end
- context 'when user is not a member' do
- it_behaves_like 'get project export status not found'
+ context "when user is not a member" do
+ it_behaves_like "get project export status not found"
end
end
end
- describe 'GET /projects/:project_id/export/download' do
- shared_examples_for 'get project export download not found' do
- it_behaves_like '404 response' do
+ describe "GET /projects/:project_id/export/download" do
+ shared_examples_for "get project export download not found" do
+ it_behaves_like "404 response" do
let(:request) { get api(download_path, user) }
end
end
- shared_examples_for 'get project export download denied' do
- it_behaves_like '403 response' do
+ shared_examples_for "get project export download denied" do
+ it_behaves_like "403 response" do
let(:request) { get api(download_path, user) }
end
end
- shared_examples_for 'get project export download' do
- it_behaves_like '404 response' do
+ shared_examples_for "get project export download" do
+ it_behaves_like "404 response" do
let(:request) { get api(download_path_none, user) }
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(download_path_started, user) }
end
- it 'downloads' do
+ it "downloads" do
get api(download_path_finished, user)
expect(response).to have_gitlab_http_status(200)
end
end
- shared_examples_for 'get project export upload after action' do
- context 'and is uploading' do
- it 'downloads' do
+ shared_examples_for "get project export upload after action" do
+ context "and is uploading" do
+ it "downloads" do
get api(download_path_export_action, user)
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when upload complete' do
+ context "when upload complete" do
before do
project_after_export.remove_exports
end
- it 'has removed the export' do
+ it "has removed the export" do
expect(project_after_export.export_file_exists?).to be_falsey
end
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(download_path_export_action, user) }
end
end
end
- shared_examples_for 'get project download by strategy' do
- context 'when upload strategy set' do
- it_behaves_like 'get project export upload after action'
+ shared_examples_for "get project download by strategy" do
+ context "when upload strategy set" do
+ it_behaves_like "get project export upload after action"
end
- context 'when download strategy set' do
- it_behaves_like 'get project export download'
+ context "when download strategy set" do
+ it_behaves_like "get project export download"
end
end
- it_behaves_like 'when project export is disabled' do
+ it_behaves_like "when project export is disabled" do
let(:request) { get api(download_path, admin) }
end
- context 'when project export is enabled' do
- context 'when user is an admin' do
+ context "when project export is enabled" do
+ context "when user is an admin" do
let(:user) { admin }
- it_behaves_like 'get project download by strategy'
+ it_behaves_like "get project download by strategy"
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
project_none.add_maintainer(user)
@@ -228,39 +228,39 @@ describe API::ProjectExport do
project_after_export.add_maintainer(user)
end
- it_behaves_like 'get project download by strategy'
+ it_behaves_like "get project download by strategy"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like 'get project export download denied'
+ it_behaves_like "get project export download denied"
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like 'get project export download denied'
+ it_behaves_like "get project export download denied"
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like 'get project export download denied'
+ it_behaves_like "get project export download denied"
end
- context 'when user is not a member' do
- it_behaves_like 'get project export download not found'
+ context "when user is not a member" do
+ it_behaves_like "get project export download not found"
end
end
- context 'when an uploader is used' do
+ context "when an uploader is used" do
before do
stub_uploads_object_storage(ImportExportUploader)
@@ -269,46 +269,46 @@ describe API::ProjectExport do
project_after_export.add_maintainer(user)
upload = ImportExportUpload.new(project: project)
- upload.export_file = fixture_file_upload('spec/fixtures/project_export.tar.gz', "`/tar.gz")
+ upload.export_file = fixture_file_upload("spec/fixtures/project_export.tar.gz", "`/tar.gz")
upload.save!
end
- it_behaves_like 'get project download by strategy'
+ it_behaves_like "get project download by strategy"
end
end
- describe 'POST /projects/:project_id/export' do
- shared_examples_for 'post project export start not found' do
- it_behaves_like '404 response' do
+ describe "POST /projects/:project_id/export" do
+ shared_examples_for "post project export start not found" do
+ it_behaves_like "404 response" do
let(:request) { post api(path, user) }
end
end
- shared_examples_for 'post project export start denied' do
- it_behaves_like '403 response' do
+ shared_examples_for "post project export start denied" do
+ it_behaves_like "403 response" do
let(:request) { post api(path, user) }
end
end
- shared_examples_for 'post project export start' do
- context 'with upload strategy' do
- context 'when params invalid' do
- it_behaves_like '400 response' do
- let(:request) { post(api(path, user), params: { 'upload[url]' => 'whatever' }) }
+ shared_examples_for "post project export start" do
+ context "with upload strategy" do
+ context "when params invalid" do
+ it_behaves_like "400 response" do
+ let(:request) { post(api(path, user), params: {"upload[url]" => "whatever"}) }
end
end
- it 'starts' do
+ it "starts" do
allow_any_instance_of(Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy).to receive(:send_file)
- post(api(path, user), params: { 'upload[url]' => 'http://gitlab.com' })
+ post(api(path, user), params: {"upload[url]" => "http://gitlab.com"})
expect(response).to have_gitlab_http_status(202)
end
end
- context 'with download strategy' do
- it 'starts' do
+ context "with download strategy" do
+ it "starts" do
expect_any_instance_of(Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy).not_to receive(:send_file)
post api(path, user)
@@ -318,18 +318,18 @@ describe API::ProjectExport do
end
end
- it_behaves_like 'when project export is disabled' do
+ it_behaves_like "when project export is disabled" do
let(:request) { post api(path, admin) }
end
- context 'when project export is enabled' do
- context 'when user is an admin' do
+ context "when project export is enabled" do
+ context "when user is an admin" do
let(:user) { admin }
- it_behaves_like 'post project export start'
+ it_behaves_like "post project export start"
end
- context 'when user is a maintainer' do
+ context "when user is a maintainer" do
before do
project.add_maintainer(user)
project_none.add_maintainer(user)
@@ -338,40 +338,40 @@ describe API::ProjectExport do
project_after_export.add_maintainer(user)
end
- it_behaves_like 'post project export start'
+ it_behaves_like "post project export start"
end
- context 'when user is a developer' do
+ context "when user is a developer" do
before do
project.add_developer(user)
end
- it_behaves_like 'post project export start denied'
+ it_behaves_like "post project export start denied"
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
before do
project.add_reporter(user)
end
- it_behaves_like 'post project export start denied'
+ it_behaves_like "post project export start denied"
end
- context 'when user is a guest' do
+ context "when user is a guest" do
before do
project.add_guest(user)
end
- it_behaves_like 'post project export start denied'
+ it_behaves_like "post project export start denied"
end
- context 'when user is not a member' do
- it_behaves_like 'post project export start not found'
+ context "when user is not a member" do
+ it_behaves_like "post project export start not found"
end
- context 'when overriding description' do
- it 'starts' do
- params = { description: "Foo" }
+ context "when overriding description" do
+ it "starts" do
+ params = {description: "Foo"}
expect_any_instance_of(Projects::ImportExport::ExportService).to receive(:execute)
post api(path, project.owner), params: params
diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb
index b88a8b95201..51a64195e52 100644
--- a/spec/requests/api/project_hooks_spec.rb
+++ b/spec/requests/api/project_hooks_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe API::ProjectHooks, 'ProjectHooks' do
+describe API::ProjectHooks, "ProjectHooks" do
let(:user) { create(:user) }
let(:user3) { create(:user) }
let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:hook) do
create(:project_hook,
- :all_events_enabled,
- project: project,
- url: 'http://example.com',
- enable_ssl_verification: true,
- push_events_branch_filter: 'master')
+ :all_events_enabled,
+ project: project,
+ url: "http://example.com",
+ enable_ssl_verification: true,
+ push_events_branch_filter: "master")
end
before do
@@ -27,19 +27,19 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(json_response).to be_an Array
expect(response).to include_pagination_headers
expect(json_response.count).to eq(1)
- expect(json_response.first['url']).to eq("http://example.com")
- expect(json_response.first['issues_events']).to eq(true)
- expect(json_response.first['confidential_issues_events']).to eq(true)
- expect(json_response.first['push_events']).to eq(true)
- expect(json_response.first['merge_requests_events']).to eq(true)
- expect(json_response.first['tag_push_events']).to eq(true)
- expect(json_response.first['note_events']).to eq(true)
- expect(json_response.first['confidential_note_events']).to eq(true)
- expect(json_response.first['job_events']).to eq(true)
- expect(json_response.first['pipeline_events']).to eq(true)
- expect(json_response.first['wiki_page_events']).to eq(true)
- expect(json_response.first['enable_ssl_verification']).to eq(true)
- expect(json_response.first['push_events_branch_filter']).to eq('master')
+ expect(json_response.first["url"]).to eq("http://example.com")
+ expect(json_response.first["issues_events"]).to eq(true)
+ expect(json_response.first["confidential_issues_events"]).to eq(true)
+ expect(json_response.first["push_events"]).to eq(true)
+ expect(json_response.first["merge_requests_events"]).to eq(true)
+ expect(json_response.first["tag_push_events"]).to eq(true)
+ expect(json_response.first["note_events"]).to eq(true)
+ expect(json_response.first["confidential_note_events"]).to eq(true)
+ expect(json_response.first["job_events"]).to eq(true)
+ expect(json_response.first["pipeline_events"]).to eq(true)
+ expect(json_response.first["wiki_page_events"]).to eq(true)
+ expect(json_response.first["enable_ssl_verification"]).to eq(true)
+ expect(json_response.first["push_events_branch_filter"]).to eq("master")
end
end
@@ -58,18 +58,18 @@ describe API::ProjectHooks, 'ProjectHooks' do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['url']).to eq(hook.url)
- expect(json_response['issues_events']).to eq(hook.issues_events)
- expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
- expect(json_response['push_events']).to eq(hook.push_events)
- expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
- expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
- expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events)
- expect(json_response['job_events']).to eq(hook.job_events)
- expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
- expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
- expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
+ expect(json_response["url"]).to eq(hook.url)
+ expect(json_response["issues_events"]).to eq(hook.issues_events)
+ expect(json_response["confidential_issues_events"]).to eq(hook.confidential_issues_events)
+ expect(json_response["push_events"]).to eq(hook.push_events)
+ expect(json_response["merge_requests_events"]).to eq(hook.merge_requests_events)
+ expect(json_response["tag_push_events"]).to eq(hook.tag_push_events)
+ expect(json_response["note_events"]).to eq(hook.note_events)
+ expect(json_response["confidential_note_events"]).to eq(hook.confidential_note_events)
+ expect(json_response["job_events"]).to eq(hook.job_events)
+ expect(json_response["pipeline_events"]).to eq(hook.pipeline_events)
+ expect(json_response["wiki_page_events"]).to eq(hook.wiki_page_events)
+ expect(json_response["enable_ssl_verification"]).to eq(hook.enable_ssl_verification)
end
it "returns a 404 error if hook id is not available" do
@@ -89,34 +89,34 @@ describe API::ProjectHooks, 'ProjectHooks' do
describe "POST /projects/:id/hooks" do
it "adds hook to project" do
- expect do
+ expect {
post api("/projects/#{project.id}/hooks", user),
- params: { url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: 'some-feature-branch' }
- end.to change {project.hooks.count}.by(1)
+ params: {url: "http://example.com", issues_events: true, confidential_issues_events: true, wiki_page_events: true, job_events: true, push_events_branch_filter: "some-feature-branch"}
+ }.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['url']).to eq('http://example.com')
- expect(json_response['issues_events']).to eq(true)
- expect(json_response['confidential_issues_events']).to eq(true)
- expect(json_response['push_events']).to eq(true)
- expect(json_response['merge_requests_events']).to eq(false)
- expect(json_response['tag_push_events']).to eq(false)
- expect(json_response['note_events']).to eq(false)
- expect(json_response['confidential_note_events']).to eq(nil)
- expect(json_response['job_events']).to eq(true)
- expect(json_response['pipeline_events']).to eq(false)
- expect(json_response['wiki_page_events']).to eq(true)
- expect(json_response['enable_ssl_verification']).to eq(true)
- expect(json_response['push_events_branch_filter']).to eq('some-feature-branch')
- expect(json_response).not_to include('token')
+ expect(json_response["url"]).to eq("http://example.com")
+ expect(json_response["issues_events"]).to eq(true)
+ expect(json_response["confidential_issues_events"]).to eq(true)
+ expect(json_response["push_events"]).to eq(true)
+ expect(json_response["merge_requests_events"]).to eq(false)
+ expect(json_response["tag_push_events"]).to eq(false)
+ expect(json_response["note_events"]).to eq(false)
+ expect(json_response["confidential_note_events"]).to eq(nil)
+ expect(json_response["job_events"]).to eq(true)
+ expect(json_response["pipeline_events"]).to eq(false)
+ expect(json_response["wiki_page_events"]).to eq(true)
+ expect(json_response["enable_ssl_verification"]).to eq(true)
+ expect(json_response["push_events_branch_filter"]).to eq("some-feature-branch")
+ expect(json_response).not_to include("token")
end
it "adds the token without including it in the response" do
token = "secret token"
- expect do
- post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", token: token }
- end.to change {project.hooks.count}.by(1)
+ expect {
+ post api("/projects/#{project.id}/hooks", user), params: {url: "http://example.com", token: token}
+ }.to change {project.hooks.count}.by(1)
expect(response).to have_gitlab_http_status(201)
expect(json_response["url"]).to eq("http://example.com")
@@ -134,12 +134,12 @@ describe API::ProjectHooks, 'ProjectHooks' do
end
it "returns a 422 error if url not valid" do
- post api("/projects/#{project.id}/hooks", user), params: { url: "ftp://example.com" }
+ post api("/projects/#{project.id}/hooks", user), params: {url: "ftp://example.com"}
expect(response).to have_gitlab_http_status(422)
end
it "returns a 422 error if branch filter is not valid" do
- post api("/projects/#{project.id}/hooks", user), params: { url: "http://example.com", push_events_branch_filter: '~badbranchname/' }
+ post api("/projects/#{project.id}/hooks", user), params: {url: "http://example.com", push_events_branch_filter: "~badbranchname/"}
expect(response).to have_gitlab_http_status(422)
end
end
@@ -147,27 +147,27 @@ describe API::ProjectHooks, 'ProjectHooks' do
describe "PUT /projects/:id/hooks/:hook_id" do
it "updates an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
- params: { url: 'http://example.org', push_events: false, job_events: true }
+ params: {url: "http://example.org", push_events: false, job_events: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['url']).to eq('http://example.org')
- expect(json_response['issues_events']).to eq(hook.issues_events)
- expect(json_response['confidential_issues_events']).to eq(hook.confidential_issues_events)
- expect(json_response['push_events']).to eq(false)
- expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events)
- expect(json_response['tag_push_events']).to eq(hook.tag_push_events)
- expect(json_response['note_events']).to eq(hook.note_events)
- expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events)
- expect(json_response['job_events']).to eq(hook.job_events)
- expect(json_response['pipeline_events']).to eq(hook.pipeline_events)
- expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events)
- expect(json_response['enable_ssl_verification']).to eq(hook.enable_ssl_verification)
+ expect(json_response["url"]).to eq("http://example.org")
+ expect(json_response["issues_events"]).to eq(hook.issues_events)
+ expect(json_response["confidential_issues_events"]).to eq(hook.confidential_issues_events)
+ expect(json_response["push_events"]).to eq(false)
+ expect(json_response["merge_requests_events"]).to eq(hook.merge_requests_events)
+ expect(json_response["tag_push_events"]).to eq(hook.tag_push_events)
+ expect(json_response["note_events"]).to eq(hook.note_events)
+ expect(json_response["confidential_note_events"]).to eq(hook.confidential_note_events)
+ expect(json_response["job_events"]).to eq(hook.job_events)
+ expect(json_response["pipeline_events"]).to eq(hook.pipeline_events)
+ expect(json_response["wiki_page_events"]).to eq(hook.wiki_page_events)
+ expect(json_response["enable_ssl_verification"]).to eq(hook.enable_ssl_verification)
end
it "adds the token without including it in the response" do
token = "secret token"
- put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: "http://example.org", token: token }
+ put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: {url: "http://example.org", token: token}
expect(response).to have_gitlab_http_status(200)
expect(json_response["url"]).to eq("http://example.org")
@@ -178,7 +178,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
end
it "returns 404 error if hook id not found" do
- put api("/projects/#{project.id}/hooks/1234", user), params: { url: 'http://example.org' }
+ put api("/projects/#{project.id}/hooks/1234", user), params: {url: "http://example.org"}
expect(response).to have_gitlab_http_status(404)
end
@@ -188,18 +188,18 @@ describe API::ProjectHooks, 'ProjectHooks' do
end
it "returns a 422 error if url is not valid" do
- put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: { url: 'ftp://example.com' }
+ put api("/projects/#{project.id}/hooks/#{hook.id}", user), params: {url: "ftp://example.com"}
expect(response).to have_gitlab_http_status(422)
end
end
describe "DELETE /projects/:id/hooks/:hook_id" do
it "deletes hook from project" do
- expect do
+ expect {
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change {project.hooks.count}.by(-1)
+ }.to change {project.hooks.count}.by(-1)
end
it "returns a 404 error when deleting non existent hook" do
@@ -223,7 +223,7 @@ describe API::ProjectHooks, 'ProjectHooks' do
expect(WebHook.exists?(hook.id)).to be_truthy
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/hooks/#{hook.id}", user) }
end
end
diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb
index 594b42bb6c0..e2bbbc6bc79 100644
--- a/spec/requests/api/project_import_spec.rb
+++ b/spec/requests/api/project_import_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectImport do
let(:export_path) { "#{Dir.tmpdir}/project_export_spec" }
let(:user) { create(:user) }
- let(:file) { File.join('spec', 'features', 'projects', 'import_export', 'test_project_export.tar.gz') }
+ let(:file) { File.join("spec", "features", "projects", "import_export", "test_project_export.tar.gz") }
let(:namespace) { create(:group) }
before do
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
@@ -16,130 +16,130 @@ describe API::ProjectImport do
FileUtils.rm_rf(export_path, secure: true)
end
- describe 'POST /projects/import' do
- it 'schedules an import using a namespace' do
+ describe "POST /projects/import" do
+ it "schedules an import using a namespace" do
stub_import(namespace)
- post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.id }
+ post api("/projects/import", user), params: {path: "test-import", file: fixture_file_upload(file), namespace: namespace.id}
expect(response).to have_gitlab_http_status(201)
end
- it 'schedules an import using the namespace path' do
+ it "schedules an import using the namespace path" do
stub_import(namespace)
- post api('/projects/import', user), params: { path: 'test-import', file: fixture_file_upload(file), namespace: namespace.full_path }
+ post api("/projects/import", user), params: {path: "test-import", file: fixture_file_upload(file), namespace: namespace.full_path}
expect(response).to have_gitlab_http_status(201)
end
- it 'schedules an import at the user namespace level' do
+ it "schedules an import at the user namespace level" do
stub_import(user.namespace)
- post api('/projects/import', user), params: { path: 'test-import2', file: fixture_file_upload(file) }
+ post api("/projects/import", user), params: {path: "test-import2", file: fixture_file_upload(file)}
expect(response).to have_gitlab_http_status(201)
end
- it 'does not schedule an import for a namespace that does not exist' do
+ it "does not schedule an import for a namespace that does not exist" do
expect_any_instance_of(ProjectImportState).not_to receive(:schedule)
expect(::Projects::CreateService).not_to receive(:new)
- post api('/projects/import', user), params: { namespace: 'nonexistent', path: 'test-import2', file: fixture_file_upload(file) }
+ post api("/projects/import", user), params: {namespace: "nonexistent", path: "test-import2", file: fixture_file_upload(file)}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Namespace Not Found')
+ expect(json_response["message"]).to eq("404 Namespace Not Found")
end
- it 'does not schedule an import if the user has no permission to the namespace' do
+ it "does not schedule an import if the user has no permission to the namespace" do
expect_any_instance_of(ProjectImportState).not_to receive(:schedule)
- post(api('/projects/import', create(:user)),
- params: {
- path: 'test-import3',
- file: fixture_file_upload(file),
- namespace: namespace.full_path
- })
+ post(api("/projects/import", create(:user)),
+ params: {
+ path: "test-import3",
+ file: fixture_file_upload(file),
+ namespace: namespace.full_path,
+ })
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Namespace Not Found')
+ expect(json_response["message"]).to eq("404 Namespace Not Found")
end
- it 'does not schedule an import if the user uploads no valid file' do
+ it "does not schedule an import if the user uploads no valid file" do
expect_any_instance_of(ProjectImportState).not_to receive(:schedule)
- post api('/projects/import', user), params: { path: 'test-import3', file: './random/test' }
+ post api("/projects/import", user), params: {path: "test-import3", file: "./random/test"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('file is invalid')
+ expect(json_response["error"]).to eq("file is invalid")
end
- it 'stores params that can be overridden' do
+ it "stores params that can be overridden" do
stub_import(namespace)
- override_params = { 'description' => 'Hello world' }
-
- post api('/projects/import', user),
- params: {
- path: 'test-import',
- file: fixture_file_upload(file),
- namespace: namespace.id,
- override_params: override_params
- }
- import_project = Project.find(json_response['id'])
-
- expect(import_project.import_data.data['override_params']).to eq(override_params)
+ override_params = {"description" => "Hello world"}
+
+ post api("/projects/import", user),
+ params: {
+ path: "test-import",
+ file: fixture_file_upload(file),
+ namespace: namespace.id,
+ override_params: override_params,
+ }
+ import_project = Project.find(json_response["id"])
+
+ expect(import_project.import_data.data["override_params"]).to eq(override_params)
end
- it 'does not store params that are not allowed' do
+ it "does not store params that are not allowed" do
stub_import(namespace)
- override_params = { 'not_allowed' => 'Hello world' }
-
- post api('/projects/import', user),
- params: {
- path: 'test-import',
- file: fixture_file_upload(file),
- namespace: namespace.id,
- override_params: override_params
- }
- import_project = Project.find(json_response['id'])
-
- expect(import_project.import_data.data['override_params']).to be_empty
+ override_params = {"not_allowed" => "Hello world"}
+
+ post api("/projects/import", user),
+ params: {
+ path: "test-import",
+ file: fixture_file_upload(file),
+ namespace: namespace.id,
+ override_params: override_params,
+ }
+ import_project = Project.find(json_response["id"])
+
+ expect(import_project.import_data.data["override_params"]).to be_empty
end
- it 'correctly overrides params during the import' do
- override_params = { 'description' => 'Hello world' }
+ it "correctly overrides params during the import" do
+ override_params = {"description" => "Hello world"}
perform_enqueued_jobs do
- post api('/projects/import', user),
- params: {
- path: 'test-import',
- file: fixture_file_upload(file),
- namespace: namespace.id,
- override_params: override_params
- }
+ post api("/projects/import", user),
+ params: {
+ path: "test-import",
+ file: fixture_file_upload(file),
+ namespace: namespace.id,
+ override_params: override_params,
+ }
end
- import_project = Project.find(json_response['id'])
+ import_project = Project.find(json_response["id"])
- expect(import_project.description).to eq('Hello world')
+ expect(import_project.description).to eq("Hello world")
end
- context 'when target path already exists in namespace' do
+ context "when target path already exists in namespace" do
let(:existing_project) { create(:project, namespace: user.namespace) }
- it 'does not schedule an import' do
+ it "does not schedule an import" do
expect_any_instance_of(ProjectImportState).not_to receive(:schedule)
- post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file) }
+ post api("/projects/import", user), params: {path: existing_project.path, file: fixture_file_upload(file)}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Name has already been taken')
+ expect(json_response["message"]).to eq("Name has already been taken")
end
- context 'when param overwrite is true' do
- it 'schedules an import' do
+ context "when param overwrite is true" do
+ it "schedules an import" do
stub_import(user.namespace)
- post api('/projects/import', user), params: { path: existing_project.path, file: fixture_file_upload(file), overwrite: true }
+ post api("/projects/import", user), params: {path: existing_project.path, file: fixture_file_upload(file), overwrite: true}
expect(response).to have_gitlab_http_status(201)
end
@@ -152,27 +152,27 @@ describe API::ProjectImport do
end
end
- describe 'GET /projects/:id/import' do
- it 'returns the import status' do
+ describe "GET /projects/:id/import" do
+ it "returns the import status" do
project = create(:project, :import_started)
project.add_maintainer(user)
get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('import_status' => 'started')
+ expect(json_response).to include("import_status" => "started")
end
- it 'returns the import status and the error if failed' do
+ it "returns the import status and the error if failed" do
project = create(:project, :import_failed)
project.add_maintainer(user)
- project.import_state.update(last_error: 'error')
+ project.import_state.update(last_error: "error")
get api("/projects/#{project.id}/import", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('import_status' => 'failed',
- 'import_error' => 'error')
+ expect(json_response).to include("import_status" => "failed",
+ "import_error" => "error")
end
end
end
diff --git a/spec/requests/api/project_milestones_spec.rb b/spec/requests/api/project_milestones_spec.rb
index 895f05a98e8..4b20c82688d 100644
--- a/spec/requests/api/project_milestones_spec.rb
+++ b/spec/requests/api/project_milestones_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectMilestones do
let(:user) { create(:user) }
- let!(:project) { create(:project, namespace: user.namespace ) }
- let!(:closed_milestone) { create(:closed_milestone, project: project, title: 'version1', description: 'closed milestone') }
- let!(:milestone) { create(:milestone, project: project, title: 'version2', description: 'open milestone') }
+ let!(:project) { create(:project, namespace: user.namespace) }
+ let!(:closed_milestone) { create(:closed_milestone, project: project, title: "version1", description: "closed milestone") }
+ let!(:milestone) { create(:milestone, project: project, title: "version2", description: "open milestone") }
before do
project.add_developer(user)
end
- it_behaves_like 'group and project milestones', "/projects/:id/milestones" do
+ it_behaves_like "group and project milestones", "/projects/:id/milestones" do
let(:route) { "/projects/#{project.id}/milestones" }
end
- describe 'DELETE /projects/:id/milestones/:milestone_id' do
+ describe "DELETE /projects/:id/milestones/:milestone_id" do
let(:guest) { create(:user) }
let(:reporter) { create(:user) }
@@ -22,13 +22,13 @@ describe API::ProjectMilestones do
project.add_reporter(reporter)
end
- it 'returns 404 response when the project does not exists' do
+ it "returns 404 response when the project does not exists" do
delete api("/projects/0/milestones/#{milestone.id}", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 response when the milestone does not exists' do
+ it "returns 404 response when the milestone does not exists" do
delete api("/projects/#{project.id}/milestones/0", user)
expect(response).to have_gitlab_http_status(404)
@@ -41,47 +41,47 @@ describe API::ProjectMilestones do
end
end
- describe 'PUT /projects/:id/milestones/:milestone_id to test observer on close' do
- it 'creates an activity event when an milestone is closed' do
+ describe "PUT /projects/:id/milestones/:milestone_id to test observer on close" 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),
- params: { state_event: 'close' }
+ params: {state_event: "close"}
end
end
- describe 'POST /projects/:id/milestones/:milestone_id/promote' do
+ describe "POST /projects/:id/milestones/:milestone_id/promote" do
let(:group) { create(:group) }
before do
project.update(namespace: group)
end
- context 'when user does not have permission to promote milestone' do
+ context "when user does not have permission to promote milestone" do
before do
group.add_guest(user)
end
- it 'returns 403' do
+ it "returns 403" do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when user has permission' do
+ context "when user has permission" do
before do
group.add_developer(user)
end
- it 'returns 200' do
+ it "returns 200" do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200)
expect(group.milestones.first.title).to eq(milestone.title)
end
- it 'returns 200 for closed milestone' do
+ it "returns 200 for closed milestone" do
post api("/projects/#{project.id}/milestones/#{closed_milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(200)
@@ -89,30 +89,30 @@ describe API::ProjectMilestones do
end
end
- context 'when no such resources' do
+ context "when no such resources" do
before do
group.add_developer(user)
end
- it 'returns 404 response when the project does not exist' do
+ it "returns 404 response when the project does not exist" do
post api("/projects/0/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 404 response when the milestone does not exist' do
+ it "returns 404 response when the milestone does not exist" do
post api("/projects/#{project.id}/milestones/0/promote", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when project does not belong to group' do
+ context "when project does not belong to group" do
before do
project.update(namespace: user.namespace)
end
- it 'returns 403' do
+ it "returns 403" do
post api("/projects/#{project.id}/milestones/#{milestone.id}/promote", user)
expect(response).to have_gitlab_http_status(403)
diff --git a/spec/requests/api/project_snapshots_spec.rb b/spec/requests/api/project_snapshots_spec.rb
index 44b5ee1f130..b5f065c6a28 100644
--- a/spec/requests/api/project_snapshots_spec.rb
+++ b/spec/requests/api/project_snapshots_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectSnapshots do
include WorkhorseHelpers
@@ -6,43 +6,43 @@ describe API::ProjectSnapshots do
let(:project) { create(:project) }
let(:admin) { create(:admin) }
- describe 'GET /projects/:id/snapshot' do
+ describe "GET /projects/:id/snapshot" do
def expect_snapshot_response_for(repository)
type, params = workhorse_send_data
- expect(type).to eq('git-snapshot')
+ expect(type).to eq("git-snapshot")
expect(params).to eq(
- 'GitalyServer' => {
- 'address' => Gitlab::GitalyClient.address(repository.project.repository_storage),
- 'token' => Gitlab::GitalyClient.token(repository.project.repository_storage)
+ "GitalyServer" => {
+ "address" => Gitlab::GitalyClient.address(repository.project.repository_storage),
+ "token" => Gitlab::GitalyClient.token(repository.project.repository_storage),
},
- 'GetSnapshotRequest' => Gitaly::GetSnapshotRequest.new(
+ "GetSnapshotRequest" => Gitaly::GetSnapshotRequest.new(
repository: repository.gitaly_repository
).to_json
)
end
- it 'returns authentication error as project owner' do
+ it "returns authentication error as project owner" do
get api("/projects/#{project.id}/snapshot", project.owner)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns authentication error as unauthenticated user' do
+ it "returns authentication error as unauthenticated user" do
get api("/projects/#{project.id}/snapshot", nil)
expect(response).to have_gitlab_http_status(401)
end
- it 'requests project repository raw archive as administrator' do
- get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '0' }
+ it "requests project repository raw archive as administrator" do
+ get api("/projects/#{project.id}/snapshot", admin), params: {wiki: "0"}
expect(response).to have_gitlab_http_status(200)
expect_snapshot_response_for(project.repository)
end
- it 'requests wiki repository raw archive as administrator' do
- get api("/projects/#{project.id}/snapshot", admin), params: { wiki: '1' }
+ it "requests wiki repository raw archive as administrator" do
+ get api("/projects/#{project.id}/snapshot", admin), params: {wiki: "1"}
expect(response).to have_gitlab_http_status(200)
expect_snapshot_response_for(project.wiki.repository)
diff --git a/spec/requests/api/project_snippets_spec.rb b/spec/requests/api/project_snippets_spec.rb
index 29f69b6ce20..13c7ee3322a 100644
--- a/spec/requests/api/project_snippets_spec.rb
+++ b/spec/requests/api/project_snippets_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe API::ProjectSnippets do
set(:project) { create(:project, :public) }
@@ -9,16 +9,16 @@ describe API::ProjectSnippets do
let(:snippet) { create(:project_snippet, :public, project: project) }
let!(:user_agent_detail) { create(:user_agent_detail, subject: snippet) }
- it 'exposes known attributes' do
+ it "exposes known attributes" do
get api("/projects/#{project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
- expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
- expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
+ expect(json_response["user_agent"]).to eq(user_agent_detail.user_agent)
+ expect(json_response["ip_address"]).to eq(user_agent_detail.ip_address)
+ expect(json_response["akismet_submitted"]).to eq(user_agent_detail.submitted)
end
- it 'respects project scoping' do
+ it "respects project scoping" do
other_project = create(:project)
get api("/projects/#{other_project.id}/snippets/#{snippet.id}/user_agent_detail", admin)
@@ -32,10 +32,10 @@ describe API::ProjectSnippets do
end
end
- describe 'GET /projects/:project_id/snippets/' do
+ describe "GET /projects/:project_id/snippets/" do
let(:user) { create(:user) }
- it 'returns all snippets available to team member' do
+ it "returns all snippets available to team member" do
project.add_developer(user)
public_snippet = create(:project_snippet, :public, project: project)
internal_snippet = create(:project_snippet, :internal, project: project)
@@ -47,11 +47,11 @@ describe API::ProjectSnippets do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
- expect(json_response.map { |snippet| snippet['id'] }).to include(public_snippet.id, internal_snippet.id, private_snippet.id)
- expect(json_response.last).to have_key('web_url')
+ expect(json_response.map { |snippet| snippet["id"] }).to include(public_snippet.id, internal_snippet.id, private_snippet.id)
+ expect(json_response.last).to have_key("web_url")
end
- it 'hides private snippets from regular user' do
+ it "hides private snippets from regular user" do
create(:project_snippet, :private, project: project)
get api("/projects/#{project.id}/snippets/", user)
@@ -63,44 +63,44 @@ describe API::ProjectSnippets do
end
end
- describe 'GET /projects/:project_id/snippets/:id' do
+ describe "GET /projects/:project_id/snippets/:id" do
let(:user) { create(:user) }
let(:snippet) { create(:project_snippet, :public, project: project) }
- it 'returns snippet json' do
+ it "returns snippet json" do
get api("/projects/#{project.id}/snippets/#{snippet.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(snippet.title)
- expect(json_response['description']).to eq(snippet.description)
- expect(json_response['file_name']).to eq(snippet.file_name)
+ expect(json_response["title"]).to eq(snippet.title)
+ expect(json_response["description"]).to eq(snippet.description)
+ expect(json_response["file_name"]).to eq(snippet.file_name)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
get api("/projects/#{project.id}/snippets/1234", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Not found')
+ expect(json_response["message"]).to eq("404 Not found")
end
end
- describe 'POST /projects/:project_id/snippets/' do
+ describe "POST /projects/:project_id/snippets/" do
let(:params) do
{
- title: 'Test Title',
- file_name: 'test.rb',
- description: 'test description',
+ title: "Test Title",
+ file_name: "test.rb",
+ description: "test description",
code: 'puts "hello world"',
- visibility: 'public'
+ visibility: "public",
}
end
- it 'creates a new snippet' do
+ it "creates a new snippet" do
post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(201)
- snippet = ProjectSnippet.find(json_response['id'])
+ snippet = ProjectSnippet.find(json_response["id"])
expect(snippet.content).to eq(params[:code])
expect(snippet.description).to eq(params[:description])
expect(snippet.title).to eq(params[:title])
@@ -108,7 +108,7 @@ describe API::ProjectSnippets do
expect(snippet.visibility_level).to eq(Snippet::PUBLIC)
end
- it 'returns 400 for missing parameters' do
+ it "returns 400 for missing parameters" do
params.delete(:title)
post api("/projects/#{project.id}/snippets/", admin), params: params
@@ -116,15 +116,15 @@ describe API::ProjectSnippets do
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 for empty code field' do
- params[:code] = ''
+ it "returns 400 for empty code field" do
+ params[:code] = ""
post api("/projects/#{project.id}/snippets/", admin), params: params
expect(response).to have_gitlab_http_status(400)
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
def create_snippet(project, snippet_params = {})
project.add_developer(user)
@@ -135,39 +135,39 @@ describe API::ProjectSnippets do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
- it 'creates the snippet' do
- expect { create_snippet(project, visibility: 'private') }
+ context "when the snippet is private" do
+ it "creates the snippet" do
+ expect { create_snippet(project, visibility: "private") }
.to change { Snippet.count }.by(1)
end
end
- context 'when the snippet is public' do
- it 'rejects the snippet' do
- expect { create_snippet(project, visibility: 'public') }
+ context "when the snippet is public" do
+ it "rejects the snippet" do
+ expect { create_snippet(project, visibility: "public") }
.not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
end
- it 'creates a spam log' do
- expect { create_snippet(project, visibility: 'public') }
+ it "creates a spam log" do
+ expect { create_snippet(project, visibility: "public") }
.to change { SpamLog.count }.by(1)
end
end
end
end
- describe 'PUT /projects/:project_id/snippets/:id/' do
+ describe "PUT /projects/:project_id/snippets/:id/" do
let(:visibility_level) { Snippet::PUBLIC }
let(:snippet) { create(:project_snippet, author: admin, visibility_level: visibility_level) }
- it 'updates snippet' do
- new_content = 'New content'
- new_description = 'New description'
+ it "updates snippet" do
+ new_content = "New content"
+ new_description = "New description"
- put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content, description: new_description }
+ put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: {code: new_content, description: new_description}
expect(response).to have_gitlab_http_status(200)
snippet.reload
@@ -175,28 +175,28 @@ describe API::ProjectSnippets do
expect(snippet.description).to eq(new_description)
end
- it 'returns 404 for invalid snippet id' do
- put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: { title: 'foo' }
+ it "returns 404 for invalid snippet id" do
+ put api("/projects/#{snippet.project.id}/snippets/1234", admin), params: {title: "foo"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
- it 'returns 400 for missing parameters' do
+ it "returns 400 for missing parameters" do
put api("/projects/#{project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 for empty code field' do
- new_content = ''
+ it "returns 400 for empty code field" do
+ new_content = ""
- put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: { code: new_content }
+ put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin), params: {code: new_content}
expect(response).to have_gitlab_http_status(400)
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
def update_snippet(snippet_params = {})
put api("/projects/#{snippet.project.id}/snippets/#{snippet.id}", admin), params: snippet_params
end
@@ -205,85 +205,85 @@ describe API::ProjectSnippets do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
+ context "when the snippet is private" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'creates the snippet' do
- expect { update_snippet(title: 'Foo') }
- .to change { snippet.reload.title }.to('Foo')
+ it "creates the snippet" do
+ expect { update_snippet(title: "Foo") }
+ .to change { snippet.reload.title }.to("Foo")
end
end
- context 'when the snippet is public' do
+ context "when the snippet is public" do
let(:visibility_level) { Snippet::PUBLIC }
- it 'rejects the snippet' do
- expect { update_snippet(title: 'Foo') }
+ it "rejects the snippet" do
+ expect { update_snippet(title: "Foo") }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo") }
.to change { SpamLog.count }.by(1)
end
end
- context 'when the private snippet is made public' do
+ context "when the private snippet is made public" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'rejects the snippet' do
- expect { update_snippet(title: 'Foo', visibility: 'public') }
+ it "rejects the snippet" do
+ expect { update_snippet(title: "Foo", visibility: "public") }
.not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility: 'public') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo", visibility: "public") }
.to change { SpamLog.count }.by(1)
end
end
end
end
- describe 'DELETE /projects/:project_id/snippets/:id/' do
+ describe "DELETE /projects/:project_id/snippets/:id/" do
let(:snippet) { create(:project_snippet, author: admin) }
- it 'deletes snippet' do
+ it "deletes snippet" do
delete api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin)
expect(response).to have_gitlab_http_status(204)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
delete api("/projects/#{snippet.project.id}/snippets/1234", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/", admin) }
end
end
- describe 'GET /projects/:project_id/snippets/:id/raw' do
+ describe "GET /projects/:project_id/snippets/:id/raw" do
let(:snippet) { create(:project_snippet, author: admin) }
- it 'returns raw text' do
+ it "returns raw text" do
get api("/projects/#{snippet.project.id}/snippets/#{snippet.id}/raw", admin)
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq 'text/plain'
+ expect(response.content_type).to eq "text/plain"
expect(response.body).to eq(snippet.content)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
get api("/projects/#{snippet.project.id}/snippets/1234/raw", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
end
end
diff --git a/spec/requests/api/project_statistics_spec.rb b/spec/requests/api/project_statistics_spec.rb
index 184d0a72c37..9d2c4ac4821 100644
--- a/spec/requests/api/project_statistics_spec.rb
+++ b/spec/requests/api/project_statistics_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectStatistics do
let(:maintainer) { create(:user) }
@@ -10,7 +10,7 @@ describe API::ProjectStatistics do
public_project.add_maintainer(maintainer)
end
- describe 'GET /projects/:id/statistics' do
+ describe "GET /projects/:id/statistics" do
let!(:fetch_statistics1) { create(:project_daily_statistic, project: public_project, fetch_count: 30, date: 29.days.ago) }
let!(:fetch_statistics2) { create(:project_daily_statistic, project: public_project, fetch_count: 4, date: 3.days.ago) }
let!(:fetch_statistics3) { create(:project_daily_statistic, project: public_project, fetch_count: 3, date: 2.days.ago) }
@@ -18,41 +18,41 @@ describe API::ProjectStatistics do
let!(:fetch_statistics5) { create(:project_daily_statistic, project: public_project, fetch_count: 1, date: Date.today) }
let!(:fetch_statistics_other_project) { create(:project_daily_statistic, project: create(:project), fetch_count: 29, date: 29.days.ago) }
- it 'returns the fetch statistics of the last 30 days' do
+ it "returns the fetch statistics of the last 30 days" do
get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200)
- fetches = json_response['fetches']
- expect(fetches['total']).to eq(40)
- expect(fetches['days'].length).to eq(5)
- expect(fetches['days'].first).to eq({ 'count' => fetch_statistics5.fetch_count, 'date' => fetch_statistics5.date.to_s })
- expect(fetches['days'].last).to eq({ 'count' => fetch_statistics1.fetch_count, 'date' => fetch_statistics1.date.to_s })
+ fetches = json_response["fetches"]
+ expect(fetches["total"]).to eq(40)
+ expect(fetches["days"].length).to eq(5)
+ expect(fetches["days"].first).to eq({"count" => fetch_statistics5.fetch_count, "date" => fetch_statistics5.date.to_s})
+ expect(fetches["days"].last).to eq({"count" => fetch_statistics1.fetch_count, "date" => fetch_statistics1.date.to_s})
end
- it 'excludes the fetch statistics older than 30 days' do
+ it "excludes the fetch statistics older than 30 days" do
create(:project_daily_statistic, fetch_count: 31, project: public_project, date: 30.days.ago)
get api("/projects/#{public_project.id}/statistics", maintainer)
expect(response).to have_gitlab_http_status(200)
- fetches = json_response['fetches']
- expect(fetches['total']).to eq(40)
- expect(fetches['days'].length).to eq(5)
- expect(fetches['days'].last).to eq({ 'count' => fetch_statistics1.fetch_count, 'date' => fetch_statistics1.date.to_s })
+ fetches = json_response["fetches"]
+ expect(fetches["total"]).to eq(40)
+ expect(fetches["days"].length).to eq(5)
+ expect(fetches["days"].last).to eq({"count" => fetch_statistics1.fetch_count, "date" => fetch_statistics1.date.to_s})
end
- it 'responds with 403 when the user is not a maintainer of the repository' do
+ it "responds with 403 when the user is not a maintainer of the repository" do
developer = create(:user)
public_project.add_developer(developer)
get api("/projects/#{public_project.id}/statistics", developer)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it 'responds with 404 when daily_statistics_enabled? is false' do
- stub_feature_flags(project_daily_statistics: { thing: public_project, enabled: false })
+ it "responds with 404 when daily_statistics_enabled? is false" do
+ stub_feature_flags(project_daily_statistics: {thing: public_project, enabled: false})
get api("/projects/#{public_project.id}/statistics", maintainer)
diff --git a/spec/requests/api/project_templates_spec.rb b/spec/requests/api/project_templates_spec.rb
index 80e5033dab4..978ce568e94 100644
--- a/spec/requests/api/project_templates_spec.rb
+++ b/spec/requests/api/project_templates_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProjectTemplates do
let(:public_project) { create(:project, :public) }
@@ -9,141 +9,141 @@ describe API::ProjectTemplates do
private_project.add_developer(developer)
end
- describe 'GET /projects/:id/templates/:type' do
- it 'returns dockerfiles' do
+ describe "GET /projects/:id/templates/:type" do
+ it "returns dockerfiles" do
get api("/projects/#{public_project.id}/templates/dockerfiles")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(response).to match_response_schema('public_api/v4/template_list')
- expect(json_response).to satisfy_one { |template| template['key'] == 'Binary' }
+ expect(response).to match_response_schema("public_api/v4/template_list")
+ expect(json_response).to satisfy_one { |template| template["key"] == "Binary" }
end
- it 'returns gitignores' do
+ it "returns gitignores" do
get api("/projects/#{public_project.id}/templates/gitignores")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(response).to match_response_schema('public_api/v4/template_list')
- expect(json_response).to satisfy_one { |template| template['key'] == 'Actionscript' }
+ expect(response).to match_response_schema("public_api/v4/template_list")
+ expect(json_response).to satisfy_one { |template| template["key"] == "Actionscript" }
end
- it 'returns gitlab_ci_ymls' do
+ it "returns gitlab_ci_ymls" do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(response).to match_response_schema('public_api/v4/template_list')
- expect(json_response).to satisfy_one { |template| template['key'] == 'Android' }
+ expect(response).to match_response_schema("public_api/v4/template_list")
+ expect(json_response).to satisfy_one { |template| template["key"] == "Android" }
end
- it 'returns licenses' do
+ it "returns licenses" do
get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(response).to match_response_schema('public_api/v4/template_list')
- expect(json_response).to satisfy_one { |template| template['key'] == 'mit' }
+ expect(response).to match_response_schema("public_api/v4/template_list")
+ expect(json_response).to satisfy_one { |template| template["key"] == "mit" }
end
- it 'returns 400 for an unknown template type' do
+ it "returns 400 for an unknown template type" do
get api("/projects/#{public_project.id}/templates/unknown")
expect(response).to have_gitlab_http_status(400)
end
- it 'denies access to an anonymous user on a private project' do
+ it "denies access to an anonymous user on a private project" do
get api("/projects/#{private_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(404)
end
- it 'permits access to a developer on a private project' do
+ it "permits access to a developer on a private project" do
get api("/projects/#{private_project.id}/templates/licenses", developer)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template_list')
+ expect(response).to match_response_schema("public_api/v4/template_list")
end
end
- describe 'GET /projects/:id/templates/licenses' do
- it 'returns key and name for the listed licenses' do
+ describe "GET /projects/:id/templates/licenses" do
+ it "returns key and name for the listed licenses" do
get api("/projects/#{public_project.id}/templates/licenses")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template_list')
+ expect(response).to match_response_schema("public_api/v4/template_list")
end
end
- describe 'GET /projects/:id/templates/:type/:key' do
- it 'returns a specific dockerfile' do
+ describe "GET /projects/:id/templates/:type/:key" do
+ it "returns a specific dockerfile" do
get api("/projects/#{public_project.id}/templates/dockerfiles/Binary")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template')
- expect(json_response['name']).to eq('Binary')
+ expect(response).to match_response_schema("public_api/v4/template")
+ expect(json_response["name"]).to eq("Binary")
end
- it 'returns a specific gitignore' do
+ it "returns a specific gitignore" do
get api("/projects/#{public_project.id}/templates/gitignores/Actionscript")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template')
- expect(json_response['name']).to eq('Actionscript')
+ expect(response).to match_response_schema("public_api/v4/template")
+ expect(json_response["name"]).to eq("Actionscript")
end
- it 'returns C++ gitignore' do
+ it "returns C++ gitignore" do
get api("/projects/#{public_project.id}/templates/gitignores/C++")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template')
- expect(json_response['name']).to eq('C++')
+ expect(response).to match_response_schema("public_api/v4/template")
+ expect(json_response["name"]).to eq("C++")
end
- it 'returns C++ gitignore for URL-encoded names' do
+ it "returns C++ gitignore for URL-encoded names" do
get api("/projects/#{public_project.id}/templates/gitignores/C%2B%2B")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template')
- expect(json_response['name']).to eq('C++')
+ expect(response).to match_response_schema("public_api/v4/template")
+ expect(json_response["name"]).to eq("C++")
end
- it 'returns a specific gitlab_ci_yml' do
+ it "returns a specific gitlab_ci_yml" do
get api("/projects/#{public_project.id}/templates/gitlab_ci_ymls/Android")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/template')
- expect(json_response['name']).to eq('Android')
+ expect(response).to match_response_schema("public_api/v4/template")
+ expect(json_response["name"]).to eq("Android")
end
- it 'returns a specific license' do
+ it "returns a specific license" do
get api("/projects/#{public_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/license')
+ expect(response).to match_response_schema("public_api/v4/license")
end
- it 'returns 404 for an unknown specific template' do
+ it "returns 404 for an unknown specific template" do
get api("/projects/#{public_project.id}/templates/licenses/unknown")
expect(response).to have_gitlab_http_status(404)
end
- it 'denies access to an anonymous user on a private project' do
+ it "denies access to an anonymous user on a private project" do
get api("/projects/#{private_project.id}/templates/licenses/mit")
expect(response).to have_gitlab_http_status(404)
end
- it 'permits access to a developer on a private project' do
+ it "permits access to a developer on a private project" do
get api("/projects/#{private_project.id}/templates/licenses/mit", developer)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/license')
+ expect(response).to match_response_schema("public_api/v4/license")
end
- shared_examples 'path traversal attempt' do |template_type|
- it 'rejects invalid filenames' do
+ shared_examples "path traversal attempt" do |template_type|
+ it "rejects invalid filenames" do
get api("/projects/#{public_project.id}/templates/#{template_type}/%2e%2e%2fPython%2ea")
expect(response).to have_gitlab_http_status(500)
@@ -151,24 +151,24 @@ describe API::ProjectTemplates do
end
TemplateFinder::VENDORED_TEMPLATES.each do |template_type, _|
- it_behaves_like 'path traversal attempt', template_type
+ it_behaves_like "path traversal attempt", template_type
end
end
- describe 'GET /projects/:id/templates/licenses/:key' do
- it 'fills placeholders in the license' do
+ describe "GET /projects/:id/templates/licenses/:key" do
+ it "fills placeholders in the license" do
get api("/projects/#{public_project.id}/templates/licenses/agpl-3.0"),
- params: {
- project: 'Project Placeholder',
- fullname: 'Fullname Placeholder'
- }
+ params: {
+ project: "Project Placeholder",
+ fullname: "Fullname Placeholder",
+ }
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/license')
+ expect(response).to match_response_schema("public_api/v4/license")
- content = json_response['content']
+ content = json_response["content"]
- expect(content).to include('Project Placeholder')
+ expect(content).to include("Project Placeholder")
expect(content).to include("Copyright (C) #{Time.now.year} Fullname Placeholder")
end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 856fe1bbe89..3be8b890780 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -1,19 +1,18 @@
-# -*- coding: utf-8 -*-
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'languages and percentages JSON response' do
+shared_examples "languages and percentages JSON response" do
let(:expected_languages) { project.repository.languages.map { |language| language.values_at(:label, :value)}.to_h }
before do
allow(project.repository).to receive(:languages).and_return(
- [{ value: 66.69, label: "Ruby", color: "#701516", highlight: "#701516" },
- { value: 22.98, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a" },
- { value: 7.91, label: "HTML", color: "#e34c26", highlight: "#e34c26" },
- { value: 2.42, label: "CoffeeScript", color: "#244776", highlight: "#244776" }]
+ [{value: 66.69, label: "Ruby", color: "#701516", highlight: "#701516"},
+ {value: 22.98, label: "JavaScript", color: "#f1e05a", highlight: "#f1e05a"},
+ {value: 7.91, label: "HTML", color: "#e34c26", highlight: "#e34c26"},
+ {value: 2.42, label: "CoffeeScript", color: "#244776", highlight: "#244776"},]
)
end
- it 'returns expected language values' do
+ it "returns expected language values" do
get api("/projects/#{project.id}/languages", user)
expect(response).to have_gitlab_http_status(:ok)
@@ -21,12 +20,12 @@ shared_examples 'languages and percentages JSON response' do
expect(json_response.count).to be > 1
end
- context 'when the languages were detected before' do
+ context "when the languages were detected before" do
before do
Projects::DetectRepositoryLanguagesService.new(project, project.owner).execute
end
- it 'returns the detection from the database' do
+ it "returns the detection from the database" do
# Allow this to happen once, so the expected languages can be determined
expect(project.repository).to receive(:languages).once
@@ -47,43 +46,43 @@ describe API::Projects do
let(:project) { create(:project, :repository, namespace: user.namespace) }
let(:project2) { create(:project, namespace: user.namespace) }
let(:project_member) { create(:project_member, :developer, user: user3, project: project) }
- let(:user4) { create(:user, username: 'user.with.dot') }
+ let(:user4) { create(:user, username: "user.with.dot") }
let(:project3) do
create(:project,
- :private,
- :repository,
- name: 'second_project',
- path: 'second_project',
- creator_id: user.id,
- namespace: user.namespace,
- merge_requests_enabled: false,
- issues_enabled: false, wiki_enabled: false,
- builds_enabled: false,
- snippets_enabled: false)
+ :private,
+ :repository,
+ name: "second_project",
+ path: "second_project",
+ creator_id: user.id,
+ namespace: user.namespace,
+ merge_requests_enabled: false,
+ issues_enabled: false, wiki_enabled: false,
+ builds_enabled: false,
+ snippets_enabled: false)
end
let(:project_member2) do
create(:project_member,
- user: user4,
- project: project3,
- access_level: ProjectMember::MAINTAINER)
+ user: user4,
+ project: project3,
+ access_level: ProjectMember::MAINTAINER)
end
let(:project4) do
create(:project,
- name: 'third_project',
- path: 'third_project',
- creator_id: user4.id,
- namespace: user4.namespace)
+ name: "third_project",
+ path: "third_project",
+ creator_id: user4.id,
+ namespace: user4.namespace)
end
- shared_context 'with language detection' do
- let(:ruby) { create(:programming_language, name: 'Ruby') }
- let(:javascript) { create(:programming_language, name: 'JavaScript') }
- let(:html) { create(:programming_language, name: 'HTML') }
+ shared_context "with language detection" do
+ let(:ruby) { create(:programming_language, name: "Ruby") }
+ let(:javascript) { create(:programming_language, name: "JavaScript") }
+ let(:html) { create(:programming_language, name: "HTML") }
let(:mock_repo_languages) do
{
- project => { ruby => 0.5, html => 0.5 },
- project3 => { html => 0.7, javascript => 0.3 }
+ project => {ruby => 0.5, html => 0.5},
+ project3 => {html => 0.7, javascript => 0.3},
}
end
@@ -96,29 +95,29 @@ describe API::Projects do
end
end
- describe 'GET /projects' do
- shared_examples_for 'projects response' do
- it 'returns an array of projects' do
- get api('/projects', current_user), params: filter
+ describe "GET /projects" do
+ shared_examples_for "projects response" do
+ it "returns an array of projects" do
+ get api("/projects", current_user), params: filter
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(*projects.map(&:id))
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(*projects.map(&:id))
end
- it 'returns the proper security headers' do
- get api('/projects', current_user), params: filter
+ it "returns the proper security headers" do
+ get api("/projects", current_user), params: filter
expect(response).to include_security_headers
end
end
- shared_examples_for 'projects response without N + 1 queries' do
- it 'avoids N + 1 queries' do
- control = ActiveRecord::QueryRecorder.new do
- get api('/projects', current_user)
- end
+ shared_examples_for "projects response without N + 1 queries" do
+ it "avoids N + 1 queries" do
+ control = ActiveRecord::QueryRecorder.new {
+ get api("/projects", current_user)
+ }
if defined?(additional_project)
additional_project
@@ -129,13 +128,13 @@ describe API::Projects do
# TODO: We're currently querying to detect if a project is a fork
# in 2 ways. Lower this back to 8 when `ForkedProjectLink` relation is
# removed
- expect do
- get api('/projects', current_user)
- end.not_to exceed_query_limit(control).with_threshold(9)
+ expect {
+ get api("/projects", current_user)
+ }.not_to exceed_query_limit(control).with_threshold(9)
end
end
- let!(:public_project) { create(:project, :public, name: 'public_project') }
+ let!(:public_project) { create(:project, :public, name: "public_project") }
before do
project
project2
@@ -143,156 +142,156 @@ describe API::Projects do
project4
end
- context 'when unauthenticated' do
- it_behaves_like 'projects response' do
- let(:filter) { { search: project.name } }
+ context "when unauthenticated" do
+ it_behaves_like "projects response" do
+ let(:filter) { {search: project.name} }
let(:current_user) { user }
let(:projects) { [project] }
end
- it_behaves_like 'projects response without N + 1 queries' do
+ it_behaves_like "projects response without N + 1 queries" do
let(:current_user) { nil }
end
end
- context 'when authenticated as regular user' do
- it_behaves_like 'projects response' do
+ context "when authenticated as regular user" do
+ it_behaves_like "projects response" do
let(:filter) { {} }
let(:current_user) { user }
let(:projects) { [public_project, project, project2, project3] }
end
- it_behaves_like 'projects response without N + 1 queries' do
+ it_behaves_like "projects response without N + 1 queries" do
let(:current_user) { user }
end
- context 'when some projects are in a group' do
+ context "when some projects are in a group" do
before do
create(:project, :public, group: create(:group))
end
- it_behaves_like 'projects response without N + 1 queries' do
+ it_behaves_like "projects response without N + 1 queries" do
let(:current_user) { user }
let(:additional_project) { create(:project, :public, group: create(:group)) }
end
end
- it 'includes the project labels as the tag_list' do
- get api('/projects', user)
+ it "includes the project labels as the tag_list" do
+ get api("/projects", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first.keys).to include('tag_list')
+ expect(json_response.first.keys).to include("tag_list")
end
- it 'includes open_issues_count' do
- get api('/projects', user)
+ it "includes open_issues_count" do
+ get api("/projects", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first.keys).to include('open_issues_count')
+ expect(json_response.first.keys).to include("open_issues_count")
end
- it 'does not include projects marked for deletion' do
+ it "does not include projects marked for deletion" do
project.update(pending_delete: true)
- get api('/projects', user)
+ get api("/projects", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).not_to include(project.id)
+ expect(json_response.map { |p| p["id"] }).not_to include(project.id)
end
- it 'does not include open_issues_count if issues are disabled' do
+ it "does not include open_issues_count if issues are disabled" do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
- get api('/projects', user)
+ get api("/projects", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count')
+ expect(json_response.find { |hash| hash["id"] == project.id }.keys).not_to include("open_issues_count")
end
- context 'and with_issues_enabled=true' do
- it 'only returns projects with issues enabled' do
+ context "and with_issues_enabled=true" do
+ it "only returns projects with issues enabled" do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
- get api('/projects?with_issues_enabled=true', user)
+ get api("/projects?with_issues_enabled=true", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).not_to include(project.id)
+ expect(json_response.map { |p| p["id"] }).not_to include(project.id)
end
end
it "does not include statistics by default" do
- get api('/projects', user)
+ get api("/projects", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).not_to include('statistics')
+ expect(json_response.first).not_to include("statistics")
end
it "includes statistics if requested" do
- get api('/projects', user), params: { statistics: true }
+ get api("/projects", user), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).to include 'statistics'
+ expect(json_response.first).to include "statistics"
end
it "does not include license by default" do
- get api('/projects', user)
+ get api("/projects", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).not_to include('license', 'license_url')
+ expect(json_response.first).not_to include("license", "license_url")
end
it "does not include license if requested" do
- get api('/projects', user), params: { license: true }
+ get api("/projects", user), params: {license: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first).not_to include('license', 'license_url')
+ expect(json_response.first).not_to include("license", "license_url")
end
- context 'when external issue tracker is enabled' do
+ context "when external issue tracker is enabled" do
let!(:jira_service) { create(:jira_service, project: project) }
- it 'includes open_issues_count' do
- get api('/projects', user)
+ it "includes open_issues_count" do
+ get api("/projects", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first.keys).to include('open_issues_count')
- expect(json_response.find { |hash| hash['id'] == project.id }.keys).to include('open_issues_count')
+ expect(json_response.first.keys).to include("open_issues_count")
+ expect(json_response.find { |hash| hash["id"] == project.id }.keys).to include("open_issues_count")
end
- it 'does not include open_issues_count if issues are disabled' do
+ it "does not include open_issues_count if issues are disabled" do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED)
- get api('/projects', user)
+ get api("/projects", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.find { |hash| hash['id'] == project.id }.keys).not_to include('open_issues_count')
+ expect(json_response.find { |hash| hash["id"] == project.id }.keys).not_to include("open_issues_count")
end
end
- context 'and with simple=true' do
- it 'returns a simplified version of all the projects' do
- expected_keys = %w(
+ context "and with simple=true" do
+ it "returns a simplified version of all the projects" do
+ expected_keys = %w[
id description default_branch tag_list
ssh_url_to_repo http_url_to_repo web_url readme_url
name name_with_namespace
@@ -300,9 +299,9 @@ describe API::Projects do
star_count forks_count
created_at last_activity_at
avatar_url namespace
- )
+ ]
- get api('/projects?simple=true', user)
+ get api("/projects?simple=true", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -311,123 +310,123 @@ describe API::Projects do
end
end
- context 'and using archived' do
+ context "and using archived" do
let!(:archived_project) { create(:project, creator_id: user.id, namespace: user.namespace, archived: true) }
- it 'returns archived projects' do
- get api('/projects?archived=true', user)
+ it "returns archived projects" do
+ get api("/projects?archived=true", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: true).size)
- expect(json_response.map { |project| project['id'] }).to include(archived_project.id)
+ expect(json_response.map { |project| project["id"] }).to include(archived_project.id)
end
- it 'returns non-archived projects' do
- get api('/projects?archived=false', user)
+ it "returns non-archived projects" do
+ get api("/projects?archived=false", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(Project.public_or_visible_to_user(user).where(archived: false).size)
- expect(json_response.map { |project| project['id'] }).not_to include(archived_project.id)
+ expect(json_response.map { |project| project["id"] }).not_to include(archived_project.id)
end
- it 'returns every project' do
- get api('/projects', user)
+ it "returns every project" do
+ get api("/projects", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id))
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(*Project.public_or_visible_to_user(user).pluck(:id))
end
end
- context 'and using search' do
- it_behaves_like 'projects response' do
- let(:filter) { { search: project.name } }
+ context "and using search" do
+ it_behaves_like "projects response" do
+ let(:filter) { {search: project.name} }
let(:current_user) { user }
let(:projects) { [project] }
end
end
- context 'and membership=true' do
- it_behaves_like 'projects response' do
- let(:filter) { { membership: true } }
+ context "and membership=true" do
+ it_behaves_like "projects response" do
+ let(:filter) { {membership: true} }
let(:current_user) { user }
let(:projects) { [project, project2, project3] }
end
end
- context 'and using the visibility filter' do
- it 'filters based on private visibility param' do
- get api('/projects', user), params: { visibility: 'private' }
+ context "and using the visibility filter" do
+ it "filters based on private visibility param" do
+ get api("/projects", user), params: {visibility: "private"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id, project2.id, project3.id)
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(project.id, project2.id, project3.id)
end
- it 'filters based on internal visibility param' do
+ it "filters based on internal visibility param" do
project2.update_attribute(:visibility_level, Gitlab::VisibilityLevel::INTERNAL)
- get api('/projects', user), params: { visibility: 'internal' }
+ get api("/projects", user), params: {visibility: "internal"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(project2.id)
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(project2.id)
end
- it 'filters based on public visibility param' do
- get api('/projects', user), params: { visibility: 'public' }
+ it "filters based on public visibility param" do
+ get api("/projects", user), params: {visibility: "public"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(public_project.id)
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(public_project.id)
end
end
- context 'and using the programming language filter' do
- include_context 'with language detection'
+ context "and using the programming language filter" do
+ include_context "with language detection"
- it 'filters case-insensitively by programming language' do
- get api('/projects', user), params: { with_programming_language: 'javascript' }
+ it "filters case-insensitively by programming language" do
+ get api("/projects", user), params: {with_programming_language: "javascript"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(project3.id)
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(project3.id)
end
end
- context 'and using sorting' do
- it 'returns the correct order when sorted by id' do
- get api('/projects', user), params: { order_by: 'id', sort: 'desc' }
+ context "and using sorting" do
+ it "returns the correct order when sorted by id" do
+ get api("/projects", user), params: {order_by: "id", sort: "desc"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(project3.id)
+ expect(json_response.first["id"]).to eq(project3.id)
end
end
- context 'and with owned=true' do
- it 'returns an array of projects the user owns' do
- get api('/projects', user4), params: { owned: true }
+ context "and with owned=true" do
+ it "returns an array of projects the user owns" do
+ get api("/projects", user4), params: {owned: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['name']).to eq(project4.name)
- expect(json_response.first['owner']['username']).to eq(user4.username)
+ expect(json_response.first["name"]).to eq(project4.name)
+ expect(json_response.first["owner"]["username"]).to eq(user4.username)
end
end
- context 'and with starred=true' do
+ context "and with starred=true" do
let(:public_project) { create(:project, :public) }
before do
@@ -435,99 +434,99 @@ describe API::Projects do
user3.update(starred_projects: [project, project2, project3, public_project])
end
- it 'returns the starred projects viewable by the user' do
- get api('/projects', user3), params: { starred: true }
+ it "returns the starred projects viewable by the user" do
+ get api("/projects", user3), params: {starred: true}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(project.id, public_project.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(project.id, public_project.id)
end
end
- context 'and with all query parameters' do
- let!(:project5) { create(:project, :public, path: 'gitlab5', namespace: create(:namespace)) }
+ context "and with all query parameters" do
+ let!(:project5) { create(:project, :public, path: "gitlab5", namespace: create(:namespace)) }
let!(:project6) { create(:project, :public, namespace: user.namespace) }
- let!(:project7) { create(:project, :public, path: 'gitlab7', namespace: user.namespace) }
- let!(:project8) { create(:project, path: 'gitlab8', namespace: user.namespace) }
- let!(:project9) { create(:project, :public, path: 'gitlab9') }
+ let!(:project7) { create(:project, :public, path: "gitlab7", namespace: user.namespace) }
+ let!(:project8) { create(:project, path: "gitlab8", namespace: user.namespace) }
+ let!(:project9) { create(:project, :public, path: "gitlab9") }
before do
user.update(starred_projects: [project5, project7, project8, project9])
end
- context 'including owned filter' do
- it 'returns only projects that satisfy all query parameters' do
- get api('/projects', user), params: { visibility: 'public', owned: true, starred: true, search: 'gitlab' }
+ context "including owned filter" do
+ it "returns only projects that satisfy all query parameters" do
+ get api("/projects", user), params: {visibility: "public", owned: true, starred: true, search: "gitlab"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response.first['id']).to eq(project7.id)
+ expect(json_response.first["id"]).to eq(project7.id)
end
end
- context 'including membership filter' do
+ context "including membership filter" do
before do
create(:project_member,
- user: user,
- project: project5,
- access_level: ProjectMember::MAINTAINER)
+ user: user,
+ project: project5,
+ access_level: ProjectMember::MAINTAINER)
end
- it 'returns only projects that satisfy all query parameters' do
- get api('/projects', user), params: { visibility: 'public', membership: true, starred: true, search: 'gitlab' }
+ it "returns only projects that satisfy all query parameters" do
+ get api("/projects", user), params: {visibility: "public", membership: true, starred: true, search: "gitlab"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
- expect(json_response.map { |project| project['id'] }).to contain_exactly(project5.id, project7.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(project5.id, project7.id)
end
end
end
- context 'and with min_access_level' do
+ context "and with min_access_level" do
before do
project2.add_maintainer(user2)
project3.add_developer(user2)
project4.add_reporter(user2)
end
- it 'returns an array of groups the user has at least developer access' do
- get api('/projects', user2), params: { min_access_level: 30 }
+ it "returns an array of groups the user has at least developer access" do
+ get api("/projects", user2), params: {min_access_level: 30}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(project2.id, project3.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(project2.id, project3.id)
end
end
end
- context 'when authenticated as a different user' do
- it_behaves_like 'projects response' do
+ context "when authenticated as a different user" do
+ it_behaves_like "projects response" do
let(:filter) { {} }
let(:current_user) { user2 }
let(:projects) { [public_project] }
end
- context 'and with_issues_enabled=true' do
- it 'does not return private issue projects' do
+ context "and with_issues_enabled=true" do
+ it "does not return private issue projects" do
project.project_feature.update_attribute(:issues_access_level, ProjectFeature::PRIVATE)
- get api('/projects?with_issues_enabled=true', user2)
+ get api("/projects?with_issues_enabled=true", user2)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).not_to include(project.id)
+ expect(json_response.map { |p| p["id"] }).not_to include(project.id)
end
end
end
- context 'when authenticated as admin' do
- it_behaves_like 'projects response' do
+ context "when authenticated as admin" do
+ it_behaves_like "projects response" do
let(:filter) { {} }
let(:current_user) { admin }
let(:projects) { Project.all }
@@ -535,63 +534,63 @@ describe API::Projects do
end
end
- describe 'POST /projects' do
- context 'maximum number of projects reached' do
- it 'does not create new project and respond with 403' do
+ describe "POST /projects" do
+ context "maximum number of projects reached" 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), params: { name: 'foo' } }
+ expect { post api("/projects", user2), params: {name: "foo"} }
.to change {Project.count}.by(0)
expect(response).to have_gitlab_http_status(403)
end
end
- it 'creates new project without path but with name and returns 201' do
- expect { post api('/projects', user), params: { name: 'Foo Project' } }
+ it "creates new project without path but with name and returns 201" do
+ expect { post api("/projects", user), params: {name: "Foo Project"} }
.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201)
project = Project.first
- expect(project.name).to eq('Foo Project')
- expect(project.path).to eq('foo-project')
+ expect(project.name).to eq("Foo Project")
+ expect(project.path).to eq("foo-project")
end
- it 'creates new project without name but with path and returns 201' do
- expect { post api('/projects', user), params: { path: 'foo_project' } }
+ it "creates new project without name but with path and returns 201" do
+ expect { post api("/projects", user), params: {path: "foo_project"} }
.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201)
project = Project.first
- expect(project.name).to eq('foo_project')
- expect(project.path).to eq('foo_project')
+ expect(project.name).to eq("foo_project")
+ expect(project.path).to eq("foo_project")
end
- it 'creates new project with name and path and returns 201' do
- expect { post api('/projects', user), params: { path: 'path-project-Foo', name: 'Foo Project' } }
+ it "creates new project with name and path and returns 201" do
+ expect { post api("/projects", user), params: {path: "path-project-Foo", name: "Foo Project"} }
.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201)
project = Project.first
- expect(project.name).to eq('Foo Project')
- expect(project.path).to eq('path-project-Foo')
+ expect(project.name).to eq("Foo Project")
+ expect(project.path).to eq("path-project-Foo")
end
- it 'creates 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), params: { name: 'foo' }
+ post api("/projects", user2), params: {name: "foo"}
expect(response).to have_gitlab_http_status(201)
end
- it 'does not create new project without name or path and returns 400' do
- expect { post api('/projects', user) }.not_to change { Project.count }
+ it "does not create new project without name or path and returns 400" do
+ expect { post api("/projects", user) }.not_to change { Project.count }
expect(response).to have_gitlab_http_status(400)
end
it "assigns attributes to project" do
project = attributes_for(:project, {
- path: 'camelCasePath',
+ path: "camelCasePath",
issues_enabled: false,
jobs_enabled: false,
merge_requests_enabled: false,
@@ -600,11 +599,11 @@ describe API::Projects do
only_allow_merge_if_pipeline_succeeds: false,
request_access_enabled: true,
only_allow_merge_if_all_discussions_are_resolved: false,
- ci_config_path: 'a/custom/path',
- merge_method: 'ff'
+ ci_config_path: "a/custom/path",
+ merge_method: "ff",
})
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
expect(response).to have_gitlab_http_status(201)
@@ -621,252 +620,252 @@ describe API::Projects do
expect(project.project_feature.wiki_access_level).to eq(ProjectFeature::DISABLED)
end
- it 'sets a project as public' do
- project = attributes_for(:project, visibility: 'public')
+ it "sets a project as public" do
+ project = attributes_for(:project, visibility: "public")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['visibility']).to eq('public')
+ expect(json_response["visibility"]).to eq("public")
end
- it 'sets a project as internal' do
- project = attributes_for(:project, visibility: 'internal')
+ it "sets a project as internal" do
+ project = attributes_for(:project, visibility: "internal")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['visibility']).to eq('internal')
+ expect(json_response["visibility"]).to eq("internal")
end
- it 'sets a project as private' do
- project = attributes_for(:project, visibility: 'private')
+ it "sets a project as private" do
+ project = attributes_for(:project, visibility: "private")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['visibility']).to eq('private')
+ expect(json_response["visibility"]).to eq("private")
end
- it 'creates a new project initialized with a README.md' do
- project = attributes_for(:project, initialize_with_readme: 1, name: 'somewhere')
+ it "creates a new project initialized with a README.md" do
+ project = attributes_for(:project, initialize_with_readme: 1, name: "somewhere")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['readme_url']).to eql("#{Gitlab.config.gitlab.url}/#{json_response['namespace']['full_path']}/somewhere/blob/master/README.md")
+ expect(json_response["readme_url"]).to eql("#{Gitlab.config.gitlab.url}/#{json_response["namespace"]["full_path"]}/somewhere/blob/master/README.md")
end
- it 'sets tag list to a project' do
+ it "sets tag list to a project" do
project = attributes_for(:project, tag_list: %w[tagFirst tagSecond])
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['tag_list']).to eq(%w[tagFirst tagSecond])
+ expect(json_response["tag_list"]).to eq(%w[tagFirst tagSecond])
end
- it 'uploads avatar for project a project' do
- project = attributes_for(:project, avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif'))
+ it "uploads avatar for project a project" do
+ project = attributes_for(:project, avatar: fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif"))
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- project_id = json_response['id']
- expect(json_response['avatar_url']).to eq("http://localhost/uploads/-/system/project/avatar/#{project_id}/banana_sample.gif")
+ project_id = json_response["id"]
+ expect(json_response["avatar_url"]).to eq("http://localhost/uploads/-/system/project/avatar/#{project_id}/banana_sample.gif")
end
- it 'sets a project as not allowing outdated diff discussions to automatically resolve' do
+ it "sets a project as not allowing outdated diff discussions to automatically resolve" do
project = attributes_for(:project, resolve_outdated_diff_discussions: false)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['resolve_outdated_diff_discussions']).to be_falsey
+ expect(json_response["resolve_outdated_diff_discussions"]).to be_falsey
end
- it 'sets a project as allowing outdated diff discussions to automatically resolve' do
+ it "sets a project as allowing outdated diff discussions to automatically resolve" do
project = attributes_for(:project, resolve_outdated_diff_discussions: true)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['resolve_outdated_diff_discussions']).to be_truthy
+ expect(json_response["resolve_outdated_diff_discussions"]).to be_truthy
end
- it 'sets a project as allowing merge even if build fails' do
+ it "sets a project as allowing merge even if build fails" do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey
+ expect(json_response["only_allow_merge_if_pipeline_succeeds"]).to be_falsey
end
- it 'sets a project as allowing merge only if merge_when_pipeline_succeeds' do
+ it "sets a project as allowing merge only if merge_when_pipeline_succeeds" do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: true)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy
+ expect(json_response["only_allow_merge_if_pipeline_succeeds"]).to be_truthy
end
- it 'sets a project as allowing merge even if discussions are unresolved' do
+ it "sets a project as allowing merge even if discussions are unresolved" do
project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: false)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to be_falsey
end
- it 'sets a project as allowing merge if only_allow_merge_if_all_discussions_are_resolved is nil' do
+ it "sets a project as allowing merge if only_allow_merge_if_all_discussions_are_resolved is nil" do
project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: nil)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to be_falsey
end
- it 'sets a project as allowing merge only if all discussions are resolved' do
+ it "sets a project as allowing merge only if all discussions are resolved" do
project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: true)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to be_truthy
end
- it 'sets the merge method of a project to rebase merge' do
- project = attributes_for(:project, merge_method: 'rebase_merge')
+ it "sets the merge method of a project to rebase merge" do
+ project = attributes_for(:project, merge_method: "rebase_merge")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
- expect(json_response['merge_method']).to eq('rebase_merge')
+ expect(json_response["merge_method"]).to eq("rebase_merge")
end
- it 'rejects invalid values for merge_method' do
- project = attributes_for(:project, merge_method: 'totally_not_valid_method')
+ it "rejects invalid values for merge_method" do
+ project = attributes_for(:project, merge_method: "totally_not_valid_method")
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
expect(response).to have_gitlab_http_status(400)
end
- it 'ignores import_url when it is nil' do
+ it "ignores import_url when it is nil" do
project = attributes_for(:project, import_url: nil)
- post api('/projects', user), params: project
+ post api("/projects", user), params: project
expect(response).to have_gitlab_http_status(201)
end
- context 'when a visibility level is restricted' do
- let(:project_param) { attributes_for(:project, visibility: 'public') }
+ context "when a visibility level is restricted" do
+ let(:project_param) { attributes_for(:project, visibility: "public") }
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- it 'does not allow a non-admin to use a restricted visibility level' do
- post api('/projects', user), params: project_param
+ it "does not allow a non-admin to use a restricted visibility level" do
+ post api("/projects", user), params: project_param
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['visibility_level'].first).to(
- match('restricted by your GitLab administrator')
+ expect(json_response["message"]["visibility_level"].first).to(
+ match("restricted by your GitLab administrator")
)
end
- it 'allows an admin to override restricted visibility settings' do
- post api('/projects', admin), params: project_param
+ it "allows an admin to override restricted visibility settings" do
+ post api("/projects", admin), params: project_param
- expect(json_response['visibility']).to eq('public')
+ expect(json_response["visibility"]).to eq("public")
end
end
end
- describe 'GET /users/:user_id/projects/' do
- let!(:public_project) { create(:project, :public, name: 'public_project', creator_id: user4.id, namespace: user4.namespace) }
+ describe "GET /users/:user_id/projects/" do
+ let!(:public_project) { create(:project, :public, name: "public_project", creator_id: user4.id, namespace: user4.namespace) }
- it 'returns error when user not found' do
- get api('/users/0/projects/')
+ it "returns error when user not found" do
+ get api("/users/0/projects/")
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns projects filtered by user id' do
+ it "returns projects filtered by user id" do
get api("/users/#{user4.id}/projects/", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(public_project.id)
end
- it 'returns projects filtered by username' do
+ it "returns projects filtered by username" do
get api("/users/#{user4.username}/projects/", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(public_project.id)
end
- it 'returns projects filtered by minimal access level' do
- private_project1 = create(:project, :private, name: 'private_project1', creator_id: user4.id, namespace: user4.namespace)
- private_project2 = create(:project, :private, name: 'private_project2', creator_id: user4.id, namespace: user4.namespace)
+ it "returns projects filtered by minimal access level" do
+ private_project1 = create(:project, :private, name: "private_project1", creator_id: user4.id, namespace: user4.namespace)
+ private_project2 = create(:project, :private, name: "private_project2", creator_id: user4.id, namespace: user4.namespace)
private_project1.add_developer(user2)
private_project2.add_reporter(user2)
- get api("/users/#{user4.id}/projects/", user2), params: { min_access_level: 30 }
+ get api("/users/#{user4.id}/projects/", user2), params: {min_access_level: 30}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |project| project['id'] }).to contain_exactly(private_project1.id)
+ expect(json_response.map { |project| project["id"] }).to contain_exactly(private_project1.id)
end
- context 'and using the programming language filter' do
- include_context 'with language detection'
+ context "and using the programming language filter" do
+ include_context "with language detection"
- it 'filters case-insensitively by programming language' do
- get api('/projects', user), params: { with_programming_language: 'ruby' }
+ it "filters case-insensitively by programming language" do
+ get api("/projects", user), params: {with_programming_language: "ruby"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |p| p['id'] }).to contain_exactly(project.id)
+ expect(json_response.map { |p| p["id"] }).to contain_exactly(project.id)
end
end
end
- describe 'POST /projects/user/:id' do
- it 'creates new project without path but with name and return 201' do
- expect { post api("/projects/user/#{user.id}", admin), params: { name: 'Foo Project' } }.to change { Project.count }.by(1)
+ describe "POST /projects/user/:id" do
+ it "creates new project without path but with name and return 201" do
+ expect { post api("/projects/user/#{user.id}", admin), params: {name: "Foo Project"} }.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201)
project = Project.last
- expect(project.name).to eq('Foo Project')
- expect(project.path).to eq('foo-project')
+ expect(project.name).to eq("Foo Project")
+ expect(project.path).to eq("foo-project")
end
- it 'creates new project with name and path and returns 201' do
- expect { post api("/projects/user/#{user.id}", admin), params: { path: 'path-project-Foo', name: 'Foo Project' } }
+ it "creates new project with name and path and returns 201" do
+ expect { post api("/projects/user/#{user.id}", admin), params: {path: "path-project-Foo", name: "Foo Project"} }
.to change { Project.count }.by(1)
expect(response).to have_gitlab_http_status(201)
project = Project.last
- expect(project.name).to eq('Foo Project')
- expect(project.path).to eq('path-project-Foo')
+ expect(project.name).to eq("Foo Project")
+ expect(project.path).to eq("path-project-Foo")
end
- it 'responds 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 }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response["error"]).to eq("name is missing")
end
- it 'assigns attributes to project' do
+ it "assigns attributes to project" do
project = attributes_for(:project, {
issues_enabled: false,
merge_requests_enabled: false,
wiki_enabled: false,
request_access_enabled: true,
- jobs_enabled: true
+ jobs_enabled: true,
})
post api("/projects/user/#{user.id}", admin), params: project
@@ -880,74 +879,74 @@ describe API::Projects do
end
end
- it 'sets a project as public' do
- project = attributes_for(:project, visibility: 'public')
+ it "sets a project as public" do
+ project = attributes_for(:project, visibility: "public")
post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(201)
- expect(json_response['visibility']).to eq('public')
+ expect(json_response["visibility"]).to eq("public")
end
- it 'sets a project as internal' do
- project = attributes_for(:project, visibility: 'internal')
+ it "sets a project as internal" do
+ project = attributes_for(:project, visibility: "internal")
post api("/projects/user/#{user.id}", admin), params: project
expect(response).to have_gitlab_http_status(201)
- expect(json_response['visibility']).to eq('internal')
+ expect(json_response["visibility"]).to eq("internal")
end
- it 'sets a project as private' do
- project = attributes_for(:project, visibility: 'private')
+ it "sets a project as private" do
+ project = attributes_for(:project, visibility: "private")
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['visibility']).to eq('private')
+ expect(json_response["visibility"]).to eq("private")
end
- it 'sets a project as not allowing outdated diff discussions to automatically resolve' do
+ it "sets a project as not allowing outdated diff discussions to automatically resolve" do
project = attributes_for(:project, resolve_outdated_diff_discussions: false)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['resolve_outdated_diff_discussions']).to be_falsey
+ expect(json_response["resolve_outdated_diff_discussions"]).to be_falsey
end
- it 'sets a project as allowing outdated diff discussions to automatically resolve' do
+ it "sets a project as allowing outdated diff discussions to automatically resolve" do
project = attributes_for(:project, resolve_outdated_diff_discussions: true)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['resolve_outdated_diff_discussions']).to be_truthy
+ expect(json_response["resolve_outdated_diff_discussions"]).to be_truthy
end
- it 'sets a project as allowing merge even if build fails' do
+ it "sets a project as allowing merge even if build fails" do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: false)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_falsey
+ expect(json_response["only_allow_merge_if_pipeline_succeeds"]).to be_falsey
end
- it 'sets a project as allowing merge only if pipeline succeeds' do
+ it "sets a project as allowing merge only if pipeline succeeds" do
project = attributes_for(:project, only_allow_merge_if_pipeline_succeeds: true)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['only_allow_merge_if_pipeline_succeeds']).to be_truthy
+ expect(json_response["only_allow_merge_if_pipeline_succeeds"]).to be_truthy
end
- it 'sets a project as allowing merge even if discussions are unresolved' do
+ it "sets a project as allowing merge even if discussions are unresolved" do
project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: false)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_falsey
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to be_falsey
end
- it 'sets a project as allowing merge only if all discussions are resolved' do
+ it "sets a project as allowing merge only if all discussions are resolved" do
project = attributes_for(:project, only_allow_merge_if_all_discussions_are_resolved: true)
post api("/projects/user/#{user.id}", admin), params: project
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to be_truthy
end
end
@@ -957,142 +956,142 @@ describe API::Projects do
end
it "uploads the file and returns its info" do
- post api("/projects/#{project.id}/uploads", user), params: { file: fixture_file_upload("spec/fixtures/dk.png", "image/png") }
+ post api("/projects/#{project.id}/uploads", user), params: {file: fixture_file_upload("spec/fixtures/dk.png", "image/png")}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['alt']).to eq("dk")
- expect(json_response['url']).to start_with("/uploads/")
- expect(json_response['url']).to end_with("/dk.png")
+ expect(json_response["alt"]).to eq("dk")
+ expect(json_response["url"]).to start_with("/uploads/")
+ expect(json_response["url"]).to end_with("/dk.png")
end
end
- describe 'GET /projects/:id' do
- context 'when unauthenticated' do
- it 'returns the public projects' do
+ describe "GET /projects/:id" do
+ context "when unauthenticated" do
+ it "returns the public projects" do
public_project = create(:project, :public)
get api("/projects/#{public_project.id}")
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(public_project.id)
- expect(json_response['description']).to eq(public_project.description)
- expect(json_response['default_branch']).to eq(public_project.default_branch)
- expect(json_response.keys).not_to include('permissions')
+ expect(json_response["id"]).to eq(public_project.id)
+ expect(json_response["description"]).to eq(public_project.description)
+ expect(json_response["default_branch"]).to eq(public_project.default_branch)
+ expect(json_response.keys).not_to include("permissions")
end
end
- context 'when authenticated' do
+ context "when authenticated" do
before do
project
project_member
end
- it 'returns a project by id' do
+ it "returns a project by id" do
group = create(:group)
link = create(:project_group_link, project: project, group: group)
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(project.id)
- expect(json_response['description']).to eq(project.description)
- expect(json_response['default_branch']).to eq(project.default_branch)
- expect(json_response['tag_list']).to be_an Array
- expect(json_response['archived']).to be_falsey
- expect(json_response['visibility']).to be_present
- expect(json_response['ssh_url_to_repo']).to be_present
- expect(json_response['http_url_to_repo']).to be_present
- expect(json_response['web_url']).to be_present
- expect(json_response['owner']).to be_a Hash
- expect(json_response['owner']).to be_a Hash
- expect(json_response['name']).to eq(project.name)
- expect(json_response['path']).to be_present
- expect(json_response['issues_enabled']).to be_present
- expect(json_response['merge_requests_enabled']).to be_present
- expect(json_response['wiki_enabled']).to be_present
- expect(json_response['jobs_enabled']).to be_present
- expect(json_response['snippets_enabled']).to be_present
- expect(json_response['resolve_outdated_diff_discussions']).to eq(project.resolve_outdated_diff_discussions)
- expect(json_response['container_registry_enabled']).to be_present
- expect(json_response['created_at']).to be_present
- expect(json_response['last_activity_at']).to be_present
- expect(json_response['shared_runners_enabled']).to be_present
- expect(json_response['creator_id']).to be_present
- expect(json_response['namespace']).to be_present
- expect(json_response['import_status']).to be_present
+ expect(json_response["id"]).to eq(project.id)
+ expect(json_response["description"]).to eq(project.description)
+ expect(json_response["default_branch"]).to eq(project.default_branch)
+ expect(json_response["tag_list"]).to be_an Array
+ expect(json_response["archived"]).to be_falsey
+ expect(json_response["visibility"]).to be_present
+ expect(json_response["ssh_url_to_repo"]).to be_present
+ expect(json_response["http_url_to_repo"]).to be_present
+ expect(json_response["web_url"]).to be_present
+ expect(json_response["owner"]).to be_a Hash
+ expect(json_response["owner"]).to be_a Hash
+ expect(json_response["name"]).to eq(project.name)
+ expect(json_response["path"]).to be_present
+ expect(json_response["issues_enabled"]).to be_present
+ expect(json_response["merge_requests_enabled"]).to be_present
+ expect(json_response["wiki_enabled"]).to be_present
+ expect(json_response["jobs_enabled"]).to be_present
+ expect(json_response["snippets_enabled"]).to be_present
+ expect(json_response["resolve_outdated_diff_discussions"]).to eq(project.resolve_outdated_diff_discussions)
+ expect(json_response["container_registry_enabled"]).to be_present
+ expect(json_response["created_at"]).to be_present
+ expect(json_response["last_activity_at"]).to be_present
+ expect(json_response["shared_runners_enabled"]).to be_present
+ expect(json_response["creator_id"]).to be_present
+ expect(json_response["namespace"]).to be_present
+ expect(json_response["import_status"]).to be_present
expect(json_response).to include("import_error")
- expect(json_response['avatar_url']).to be_nil
- expect(json_response['star_count']).to be_present
- expect(json_response['forks_count']).to be_present
- expect(json_response['public_jobs']).to be_present
- expect(json_response['ci_config_path']).to be_nil
- expect(json_response['shared_with_groups']).to be_an Array
- expect(json_response['shared_with_groups'].length).to eq(1)
- expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
- expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
- expect(json_response['shared_with_groups'][0]['group_full_path']).to eq(group.full_path)
- expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
- expect(json_response['shared_with_groups'][0]['expires_at']).to be_nil
- expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds)
- expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
- expect(json_response['merge_method']).to eq(project.merge_method.to_s)
- expect(json_response['readme_url']).to eq(project.readme_url)
- end
-
- it 'returns a group link with expiration date' do
+ expect(json_response["avatar_url"]).to be_nil
+ expect(json_response["star_count"]).to be_present
+ expect(json_response["forks_count"]).to be_present
+ expect(json_response["public_jobs"]).to be_present
+ expect(json_response["ci_config_path"]).to be_nil
+ expect(json_response["shared_with_groups"]).to be_an Array
+ expect(json_response["shared_with_groups"].length).to eq(1)
+ expect(json_response["shared_with_groups"][0]["group_id"]).to eq(group.id)
+ expect(json_response["shared_with_groups"][0]["group_name"]).to eq(group.name)
+ expect(json_response["shared_with_groups"][0]["group_full_path"]).to eq(group.full_path)
+ expect(json_response["shared_with_groups"][0]["group_access_level"]).to eq(link.group_access)
+ expect(json_response["shared_with_groups"][0]["expires_at"]).to be_nil
+ expect(json_response["only_allow_merge_if_pipeline_succeeds"]).to eq(project.only_allow_merge_if_pipeline_succeeds)
+ expect(json_response["only_allow_merge_if_all_discussions_are_resolved"]).to eq(project.only_allow_merge_if_all_discussions_are_resolved)
+ expect(json_response["merge_method"]).to eq(project.merge_method.to_s)
+ expect(json_response["readme_url"]).to eq(project.readme_url)
+ end
+
+ it "returns a group link with expiration date" do
group = create(:group)
expires_at = 5.days.from_now.to_date
link = create(:project_group_link, project: project, group: group, expires_at: expires_at)
get api("/projects/#{project.id}", user)
- expect(json_response['shared_with_groups']).to be_an Array
- expect(json_response['shared_with_groups'].length).to eq(1)
- expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)
- expect(json_response['shared_with_groups'][0]['group_name']).to eq(group.name)
- expect(json_response['shared_with_groups'][0]['group_full_path']).to eq(group.full_path)
- expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access)
- expect(json_response['shared_with_groups'][0]['expires_at']).to eq(expires_at.to_s)
+ expect(json_response["shared_with_groups"]).to be_an Array
+ expect(json_response["shared_with_groups"].length).to eq(1)
+ expect(json_response["shared_with_groups"][0]["group_id"]).to eq(group.id)
+ expect(json_response["shared_with_groups"][0]["group_name"]).to eq(group.name)
+ expect(json_response["shared_with_groups"][0]["group_full_path"]).to eq(group.full_path)
+ expect(json_response["shared_with_groups"][0]["group_access_level"]).to eq(link.group_access)
+ expect(json_response["shared_with_groups"][0]["expires_at"]).to eq(expires_at.to_s)
end
- it 'returns a project by path name' do
+ it "returns a project by path name" do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(project.name)
+ expect(json_response["name"]).to eq(project.name)
end
- it 'returns a 404 error if not found' do
- get api('/projects/42', user)
+ it "returns a 404 error if not found" do
+ get api("/projects/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
- it 'returns 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_gitlab_http_status(404)
end
- it 'handles users with dots' do
- dot_user = create(:user, username: 'dot.user')
+ 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)
get api("/projects/#{CGI.escape(project.full_path)}", dot_user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(project.name)
+ expect(json_response["name"]).to eq(project.name)
end
- it 'exposes namespace fields' do
+ it "exposes namespace fields" do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['namespace']).to eq({
- 'id' => user.namespace.id,
- 'name' => user.namespace.name,
- 'path' => user.namespace.path,
- 'kind' => user.namespace.kind,
- 'full_path' => user.namespace.full_path,
- 'parent_id' => nil
+ expect(json_response["namespace"]).to eq({
+ "id" => user.namespace.id,
+ "name" => user.namespace.name,
+ "path" => user.namespace.path,
+ "kind" => user.namespace.kind,
+ "full_path" => user.namespace.full_path,
+ "parent_id" => nil,
})
end
@@ -1100,19 +1099,19 @@ describe API::Projects do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).not_to include('license', 'license_url')
+ expect(json_response).not_to include("license", "license_url")
end
- it 'includes license fields when requested' do
- get api("/projects/#{project.id}", user), params: { license: true }
+ it "includes license fields when requested" do
+ get api("/projects/#{project.id}", user), params: {license: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['license']).to eq({
- 'key' => project.repository.license.key,
- 'name' => project.repository.license.name,
- 'nickname' => project.repository.license.nickname,
- 'html_url' => project.repository.license.url,
- 'source_url' => project.repository.license.meta['source']
+ expect(json_response["license"]).to eq({
+ "key" => project.repository.license.key,
+ "name" => project.repository.license.name,
+ "nickname" => project.repository.license.nickname,
+ "html_url" => project.repository.license.url,
+ "source_url" => project.repository.license.meta["source"],
})
end
@@ -1120,14 +1119,14 @@ describe API::Projects do
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).not_to include 'statistics'
+ expect(json_response).not_to include "statistics"
end
it "includes statistics if requested" do
- get api("/projects/#{project.id}", user), params: { statistics: true }
+ get api("/projects/#{project.id}", user), params: {statistics: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include 'statistics'
+ expect(json_response).to include "statistics"
end
it "includes import_error if user can admin project" do
@@ -1144,93 +1143,93 @@ describe API::Projects do
expect(json_response).not_to include("import_error")
end
- it 'returns 404 when project is marked for deletion' do
+ it "returns 404 when project is marked for deletion" do
project.update(pending_delete: true)
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
- context 'links exposure' do
- it 'exposes related resources full URIs' do
+ context "links exposure" do
+ it "exposes related resources full URIs" do
get api("/projects/#{project.id}", user)
- links = json_response['_links']
+ links = json_response["_links"]
- expect(links['self']).to end_with("/api/v4/projects/#{project.id}")
- expect(links['issues']).to end_with("/api/v4/projects/#{project.id}/issues")
- expect(links['merge_requests']).to end_with("/api/v4/projects/#{project.id}/merge_requests")
- expect(links['repo_branches']).to end_with("/api/v4/projects/#{project.id}/repository/branches")
- expect(links['labels']).to end_with("/api/v4/projects/#{project.id}/labels")
- expect(links['events']).to end_with("/api/v4/projects/#{project.id}/events")
- expect(links['members']).to end_with("/api/v4/projects/#{project.id}/members")
+ expect(links["self"]).to end_with("/api/v4/projects/#{project.id}")
+ expect(links["issues"]).to end_with("/api/v4/projects/#{project.id}/issues")
+ expect(links["merge_requests"]).to end_with("/api/v4/projects/#{project.id}/merge_requests")
+ expect(links["repo_branches"]).to end_with("/api/v4/projects/#{project.id}/repository/branches")
+ expect(links["labels"]).to end_with("/api/v4/projects/#{project.id}/labels")
+ expect(links["events"]).to end_with("/api/v4/projects/#{project.id}/events")
+ expect(links["members"]).to end_with("/api/v4/projects/#{project.id}/members")
end
- it 'filters related URIs when their feature is not enabled' do
+ it "filters related URIs when their feature is not enabled" do
project = create(:project, :public,
- :merge_requests_disabled,
- :issues_disabled,
- creator_id: user.id,
- namespace: user.namespace)
+ :merge_requests_disabled,
+ :issues_disabled,
+ creator_id: user.id,
+ namespace: user.namespace)
get api("/projects/#{project.id}", user)
- links = json_response['_links']
+ links = json_response["_links"]
- expect(links.has_key?('merge_requests')).to be_falsy
- expect(links.has_key?('issues')).to be_falsy
- expect(links['self']).to end_with("/api/v4/projects/#{project.id}")
+ expect(links.key?("merge_requests")).to be_falsy
+ expect(links.key?("issues")).to be_falsy
+ expect(links["self"]).to end_with("/api/v4/projects/#{project.id}")
end
end
- describe 'permissions' do
- context 'all projects' do
+ describe "permissions" do
+ context "all projects" do
before do
project.add_maintainer(user)
end
- it 'contains permission information' do
+ it "contains permission information" do
get api("/projects", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response.first['permissions']['project_access']['access_level'])
- .to eq(Gitlab::Access::MAINTAINER)
- expect(json_response.first['permissions']['group_access']).to be_nil
+ expect(json_response.first["permissions"]["project_access"]["access_level"])
+ .to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response.first["permissions"]["group_access"]).to be_nil
end
end
- context 'personal project' do
- it 'sets project access and returns 200' do
+ context "personal project" do
+ it "sets project access and returns 200" do
project.add_maintainer(user)
get api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['permissions']['project_access']['access_level'])
- .to eq(Gitlab::Access::MAINTAINER)
- expect(json_response['permissions']['group_access']).to be_nil
+ expect(json_response["permissions"]["project_access"]["access_level"])
+ .to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["permissions"]["group_access"]).to be_nil
end
end
- context 'group project' do
+ context "group project" do
let(:project2) { create(:project, group: create(:group)) }
before do
project2.group.add_owner(user)
end
- it 'sets the owner and return 200' do
+ it "sets the owner and return 200" do
get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['permissions']['project_access']).to be_nil
- expect(json_response['permissions']['group_access']['access_level'])
- .to eq(Gitlab::Access::OWNER)
+ expect(json_response["permissions"]["project_access"]).to be_nil
+ expect(json_response["permissions"]["group_access"]["access_level"])
+ .to eq(Gitlab::Access::OWNER)
end
end
- context 'nested group project', :nested_groups do
+ context "nested group project", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:project2) { create(:project, group: nested_group) }
@@ -1239,27 +1238,27 @@ describe API::Projects do
project2.group.parent.add_owner(user)
end
- it 'sets group access and return 200' do
+ it "sets group access and return 200" do
get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['permissions']['project_access']).to be_nil
- expect(json_response['permissions']['group_access']['access_level'])
- .to eq(Gitlab::Access::OWNER)
+ expect(json_response["permissions"]["project_access"]).to be_nil
+ expect(json_response["permissions"]["group_access"]["access_level"])
+ .to eq(Gitlab::Access::OWNER)
end
- context 'with various access levels across nested groups' do
+ context "with various access levels across nested groups" do
before do
project2.group.add_maintainer(user)
end
- it 'sets the maximum group access and return 200' do
+ it "sets the maximum group access and return 200" do
get api("/projects/#{project2.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['permissions']['project_access']).to be_nil
- expect(json_response['permissions']['group_access']['access_level'])
- .to eq(Gitlab::Access::OWNER)
+ expect(json_response["permissions"]["project_access"]).to be_nil
+ expect(json_response["permissions"]["group_access"]["access_level"])
+ .to eq(Gitlab::Access::OWNER)
end
end
end
@@ -1267,9 +1266,9 @@ describe API::Projects do
end
end
- describe 'GET /projects/:id/users' do
- shared_examples_for 'project users response' do
- it 'returns the project users' do
+ describe "GET /projects/:id/users" do
+ shared_examples_for "project users response" do
+ it "returns the project users" do
get api("/projects/#{project.id}/users", current_user)
user = project.namespace.owner
@@ -1280,34 +1279,34 @@ describe API::Projects do
expect(json_response.size).to eq(1)
first_user = json_response.first
- expect(first_user['username']).to eq(user.username)
- expect(first_user['name']).to eq(user.name)
- expect(first_user.keys).to contain_exactly(*%w[name username id state avatar_url web_url])
+ expect(first_user["username"]).to eq(user.username)
+ expect(first_user["name"]).to eq(user.name)
+ expect(first_user.keys).to contain_exactly("name", "username", "id", "state", "avatar_url", "web_url")
end
end
- context 'when unauthenticated' do
- it_behaves_like 'project users response' do
+ context "when unauthenticated" do
+ it_behaves_like "project users response" do
let(:project) { create(:project, :public) }
let(:current_user) { nil }
end
end
- context 'when authenticated' do
- context 'valid request' do
- it_behaves_like 'project users response' do
+ context "when authenticated" do
+ context "valid request" do
+ it_behaves_like "project users response" do
let(:current_user) { user }
end
end
- it 'returns a 404 error if not found' do
- get api('/projects/42/users', user)
+ it "returns a 404 error if not found" do
+ get api("/projects/42/users", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
- it 'returns 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}/users", other_user)
@@ -1317,34 +1316,34 @@ describe API::Projects do
end
end
- describe 'fork management' do
+ describe "fork management" do
let(:project_fork_target) { create(:project) }
let(:project_fork_source) { create(:project, :public) }
let(:private_project_fork_source) { create(:project, :private) }
- describe 'POST /projects/:id/fork/:forked_from_id' do
- context 'user is a developer' do
+ describe "POST /projects/:id/fork/:forked_from_id" do
+ context "user is a developer" do
before do
project_fork_target.add_developer(user)
end
- it 'denies project to be forked from an existing project' do
+ it "denies project to be forked from an existing project" do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- it 'refreshes the forks count cache' do
+ it "refreshes the forks count cache" do
expect(project_fork_source.forks_count).to be_zero
end
- context 'user is maintainer' do
+ context "user is maintainer" do
before do
project_fork_target.add_maintainer(user)
end
- it 'allows project to be forked from an existing project' do
+ it "allows project to be forked from an existing project" do
expect(project_fork_target).not_to be_forked
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", user)
@@ -1356,15 +1355,15 @@ describe API::Projects do
expect(project_fork_target).to be_forked
end
- it 'denies project to be forked from a private project' do
+ it "denies project to be forked from a private project" do
post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'user is admin' do
- it 'allows project to be forked from an existing project' do
+ context "user is admin" do
+ it "allows project to be forked from an existing project" do
expect(project_fork_target).not_to be_forked
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
@@ -1372,24 +1371,24 @@ describe API::Projects do
expect(response).to have_gitlab_http_status(201)
end
- it 'allows project to be forked from a private project' do
+ it "allows project to be forked from a private project" do
post api("/projects/#{project_fork_target.id}/fork/#{private_project_fork_source.id}", admin)
expect(response).to have_gitlab_http_status(201)
end
- it 'refreshes the forks count cachce' do
- expect do
+ it "refreshes the forks count cachce" do
+ expect {
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
- end.to change(project_fork_source, :forks_count).by(1)
+ }.to change(project_fork_source, :forks_count).by(1)
end
- it 'fails 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/0", admin)
expect(response).to have_gitlab_http_status(404)
end
- it 'fails with 409 if already forked' do
+ it "fails with 409 if already forked" do
other_project_fork_source = create(:project, :public)
Projects::ForkService.new(project_fork_source, admin).execute(project_fork_target)
@@ -1404,13 +1403,13 @@ describe API::Projects do
end
end
- describe 'DELETE /projects/:id/fork' do
+ describe "DELETE /projects/:id/fork" do
it "is not visible to users outside group" do
delete api("/projects/#{project_fork_target.id}/fork", user)
expect(response).to have_gitlab_http_status(404)
end
- context 'when users belong to project group' do
+ context "when users belong to project group" do
let(:project_fork_target) { create(:project, group: create(:group)) }
before do
@@ -1418,7 +1417,7 @@ describe API::Projects do
project_fork_target.group.add_developer user2
end
- context 'for a forked project' do
+ context "for a forked project" do
before do
post api("/projects/#{project_fork_target.id}/fork/#{project_fork_source.id}", admin)
project_fork_target.reload
@@ -1426,7 +1425,7 @@ describe API::Projects do
expect(project_fork_target).to be_forked
end
- it 'makes forked project unforked' do
+ it "makes forked project unforked" do
delete api("/projects/#{project_fork_target.id}/fork", admin)
expect(response).to have_gitlab_http_status(204)
@@ -1435,17 +1434,17 @@ describe API::Projects do
expect(project_fork_target).not_to be_forked
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project_fork_target.id}/fork", admin) }
end
end
- it 'is 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_gitlab_http_status(403)
end
- it 'is 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_gitlab_http_status(304)
@@ -1454,7 +1453,7 @@ describe API::Projects do
end
end
- describe 'GET /projects/:id/forks' do
+ describe "GET /projects/:id/forks" do
let(:private_fork) { create(:project, :private, :empty_repo) }
let(:member) { create(:user) }
let(:non_member) { create(:user) }
@@ -1463,7 +1462,7 @@ describe API::Projects do
private_fork.add_developer(member)
end
- context 'for a forked project' do
+ context "for a forked project" do
before do
post api("/projects/#{private_fork.id}/fork/#{project_fork_source.id}", admin)
private_fork.reload
@@ -1474,19 +1473,19 @@ describe API::Projects do
expect(project_fork_source.forks).to include(private_fork)
end
- context 'for a user that can access the forks' do
- it 'returns the forks' do
+ context "for a user that can access the forks" do
+ it "returns the forks" do
get api("/projects/#{project_fork_source.id}/forks", member)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.length).to eq(1)
- expect(json_response[0]['name']).to eq(private_fork.name)
+ expect(json_response[0]["name"]).to eq(private_fork.name)
end
end
- context 'for a user that cannot access the forks' do
- it 'returns an empty array' do
+ context "for a user that cannot access the forks" do
+ it "returns an empty array" do
get api("/projects/#{project_fork_source.id}/forks", non_member)
expect(response).to have_gitlab_http_status(200)
@@ -1496,8 +1495,8 @@ describe API::Projects do
end
end
- context 'for a non-forked project' do
- it 'returns an empty array' do
+ context "for a non-forked project" do
+ it "returns an empty array" do
get api("/projects/#{project_fork_source.id}/forks")
expect(response).to have_gitlab_http_status(200)
@@ -1514,94 +1513,94 @@ describe API::Projects do
it "shares project with group" do
expires_at = 10.days.from_now.to_date
- expect do
- post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at }
- end.to change { ProjectGroupLink.count }.by(1)
+ expect {
+ post api("/projects/#{project.id}/share", user), params: {group_id: group.id, group_access: Gitlab::Access::DEVELOPER, expires_at: expires_at}
+ }.to change { ProjectGroupLink.count }.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['group_id']).to eq(group.id)
- expect(json_response['group_access']).to eq(Gitlab::Access::DEVELOPER)
- expect(json_response['expires_at']).to eq(expires_at.to_s)
+ expect(json_response["group_id"]).to eq(group.id)
+ expect(json_response["group_access"]).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["expires_at"]).to eq(expires_at.to_s)
end
it "returns a 400 error when group id is not given" do
- post api("/projects/#{project.id}/share", user), params: { group_access: Gitlab::Access::DEVELOPER }
+ post api("/projects/#{project.id}/share", user), params: {group_access: Gitlab::Access::DEVELOPER}
expect(response).to have_gitlab_http_status(400)
end
it "returns a 400 error when access level is not given" do
- post api("/projects/#{project.id}/share", user), params: { group_id: group.id }
+ post api("/projects/#{project.id}/share", user), params: {group_id: group.id}
expect(response).to have_gitlab_http_status(400)
end
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), params: { group_id: group.id, group_access: Gitlab::Access::DEVELOPER }
+ post api("/projects/#{project.id}/share", user), params: {group_id: group.id, group_access: Gitlab::Access::DEVELOPER}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 404 error when user cannot read group' do
+ it "returns a 404 error when user cannot read group" do
private_group = create(:group, :private)
- post api("/projects/#{project.id}/share", user), params: { group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER }
+ post api("/projects/#{project.id}/share", user), params: {group_id: private_group.id, group_access: Gitlab::Access::DEVELOPER}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 error when group does not exist' do
- post api("/projects/#{project.id}/share", user), params: { group_id: 1234, group_access: Gitlab::Access::DEVELOPER }
+ it "returns a 404 error when group does not exist" do
+ post api("/projects/#{project.id}/share", user), params: {group_id: 1234, group_access: Gitlab::Access::DEVELOPER}
expect(response).to have_gitlab_http_status(404)
end
it "returns a 400 error when wrong params passed" do
- post api("/projects/#{project.id}/share", user), params: { group_id: group.id, group_access: 1234 }
+ post api("/projects/#{project.id}/share", user), params: {group_id: group.id, group_access: 1234}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq 'group_access does not have a valid value'
+ expect(json_response["error"]).to eq "group_access does not have a valid value"
end
end
- describe 'DELETE /projects/:id/share/:group_id' do
- context 'for a valid group' do
+ describe "DELETE /projects/:id/share/:group_id" do
+ context "for a valid group" do
let(:group) { create(:group, :public) }
before do
create(:project_group_link, group: group, project: project)
end
- it 'returns 204 when deleting a group share' do
+ it "returns 204 when deleting a group share" do
delete api("/projects/#{project.id}/share/#{group.id}", user)
expect(response).to have_gitlab_http_status(204)
expect(project.project_group_links).to be_empty
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/share/#{group.id}", user) }
end
end
- it 'returns a 400 when group id is not an integer' do
+ it "returns a 400 when group id is not an integer" do
delete api("/projects/#{project.id}/share/foo", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 404 error when group link does not exist' do
+ it "returns a 404 error when group link does not exist" do
delete api("/projects/#{project.id}/share/1234", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 error when project does not exist' do
+ it "returns a 404 error when project does not exist" do
delete api("/projects/123/share/1234", user)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'PUT /projects/:id' do
+ describe "PUT /projects/:id" do
before do
expect(project).to be_persisted
expect(user).to be_persisted
@@ -1613,18 +1612,18 @@ describe API::Projects do
expect(project_member).to be_persisted
end
- it 'returns 400 when nothing sent' do
+ it "returns 400 when nothing sent" do
project_param = {}
put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to match('at least one parameter must be provided')
+ expect(json_response["error"]).to match("at least one parameter must be provided")
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
- project_param = { name: 'bar' }
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ project_param = {name: "bar"}
put api("/projects/#{project.id}"), params: project_param
@@ -1632,9 +1631,9 @@ describe API::Projects do
end
end
- context 'when authenticated as project owner' do
- it 'updates name' do
- project_param = { name: 'bar' }
+ context "when authenticated as project owner" do
+ it "updates name" do
+ project_param = {name: "bar"}
put api("/projects/#{project.id}", user), params: project_param
@@ -1645,8 +1644,8 @@ describe API::Projects do
end
end
- it 'updates visibility_level' do
- project_param = { visibility: 'public' }
+ it "updates visibility_level" do
+ project_param = {visibility: "public"}
put api("/projects/#{project3.id}", user), params: project_param
@@ -1657,9 +1656,9 @@ describe API::Projects do
end
end
- it 'updates visibility_level from public to private' do
- project3.update({ visibility_level: Gitlab::VisibilityLevel::PUBLIC })
- project_param = { visibility: 'private' }
+ it "updates visibility_level from public to private" do
+ project3.update({visibility_level: Gitlab::VisibilityLevel::PUBLIC})
+ project_param = {visibility: "private"}
put api("/projects/#{project3.id}", user), params: project_param
@@ -1669,29 +1668,29 @@ describe API::Projects do
expect(json_response[k.to_s]).to eq(v)
end
- expect(json_response['visibility']).to eq('private')
+ expect(json_response["visibility"]).to eq("private")
end
- it 'does not update name to existing name' do
- project_param = { name: project3.name }
+ it "does not update name to existing name" do
+ project_param = {name: project3.name}
put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['name']).to eq(['has already been taken'])
+ expect(json_response["message"]["name"]).to eq(["has already been taken"])
end
- it 'updates request_access_enabled' do
- project_param = { request_access_enabled: false }
+ it "updates request_access_enabled" do
+ project_param = {request_access_enabled: false}
put api("/projects/#{project.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200)
- expect(json_response['request_access_enabled']).to eq(false)
+ expect(json_response["request_access_enabled"]).to eq(false)
end
- it 'updates path & name to existing path & name in different namespace' do
- project_param = { path: project4.path, name: project4.name }
+ 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), params: project_param
@@ -1702,8 +1701,8 @@ describe API::Projects do
end
end
- it 'updates jobs_enabled' do
- project_param = { jobs_enabled: true }
+ it "updates jobs_enabled" do
+ project_param = {jobs_enabled: true}
put api("/projects/#{project3.id}", user), params: project_param
@@ -1714,8 +1713,8 @@ describe API::Projects do
end
end
- it 'updates merge_method' do
- project_param = { merge_method: 'ff' }
+ it "updates merge_method" do
+ project_param = {merge_method: "ff"}
put api("/projects/#{project3.id}", user), params: project_param
@@ -1726,32 +1725,32 @@ describe API::Projects do
end
end
- it 'rejects to update merge_method when merge_method is invalid' do
- project_param = { merge_method: 'invalid' }
+ it "rejects to update merge_method when merge_method is invalid" do
+ project_param = {merge_method: "invalid"}
put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(400)
end
- it 'updates avatar' do
+ it "updates avatar" do
project_param = {
- avatar: fixture_file_upload('spec/fixtures/banana_sample.gif',
- 'image/gif')
+ avatar: fixture_file_upload("spec/fixtures/banana_sample.gif",
+ "image/gif"),
}
put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(200)
- expect(json_response['avatar_url']).to eq('http://localhost/uploads/'\
- '-/system/project/avatar/'\
+ expect(json_response["avatar_url"]).to eq("http://localhost/uploads/"\
+ "-/system/project/avatar/"\
"#{project3.id}/banana_sample.gif")
end
end
- context 'when authenticated as project maintainer' do
- it 'updates path' do
- project_param = { path: 'bar' }
+ context "when authenticated as project maintainer" do
+ it "updates path" do
+ project_param = {path: "bar"}
put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(200)
project_param.each_pair do |k, v|
@@ -1759,13 +1758,13 @@ describe API::Projects do
end
end
- it 'updates other attributes' do
- project_param = { issues_enabled: true,
- wiki_enabled: true,
- snippets_enabled: true,
- merge_requests_enabled: true,
- merge_method: 'ff',
- description: 'new description' }
+ it "updates other attributes" do
+ project_param = {issues_enabled: true,
+ wiki_enabled: true,
+ snippets_enabled: true,
+ merge_requests_enabled: true,
+ merge_method: "ff",
+ description: "new description",}
put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(200)
@@ -1774,70 +1773,70 @@ describe API::Projects do
end
end
- it 'does not update path to existing path' do
- project_param = { path: project.path }
+ it "does not update path to existing path" do
+ project_param = {path: project.path}
put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['path']).to eq(['has already been taken'])
+ expect(json_response["message"]["path"]).to eq(["has already been taken"])
end
- it 'does not update name' do
- project_param = { name: 'bar' }
+ it "does not update name" do
+ project_param = {name: "bar"}
put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(403)
end
- it 'does not update visibility_level' do
- project_param = { visibility: 'public' }
+ it "does not update visibility_level" do
+ project_param = {visibility: "public"}
put api("/projects/#{project3.id}", user4), params: project_param
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when authenticated as project developer' do
- it 'does not update other attributes' do
- project_param = { path: 'bar',
- issues_enabled: true,
- wiki_enabled: true,
- snippets_enabled: true,
- merge_requests_enabled: true,
- description: 'new description',
- request_access_enabled: true }
+ context "when authenticated as project developer" do
+ it "does not update other attributes" do
+ project_param = {path: "bar",
+ issues_enabled: true,
+ wiki_enabled: true,
+ snippets_enabled: true,
+ merge_requests_enabled: true,
+ description: "new description",
+ request_access_enabled: true,}
put api("/projects/#{project.id}", user3), params: project_param
expect(response).to have_gitlab_http_status(403)
end
end
end
- describe 'POST /projects/:id/archive' do
- context 'on an unarchived project' do
- it 'archives the project' do
+ describe "POST /projects/:id/archive" do
+ context "on an unarchived project" do
+ it "archives the project" do
post api("/projects/#{project.id}/archive", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['archived']).to be_truthy
+ expect(json_response["archived"]).to be_truthy
end
end
- context 'on an archived project' do
+ context "on an archived project" do
before do
::Projects::UpdateService.new(project, user, archived: true).execute
end
- it 'remains archived' do
+ it "remains archived" do
post api("/projects/#{project.id}/archive", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['archived']).to be_truthy
+ expect(json_response["archived"]).to be_truthy
end
end
- context 'user without archiving rights to the project' do
+ context "user without archiving rights to the project" do
before do
project.add_developer(user3)
end
- it 'rejects the action' do
+ it "rejects the action" do
post api("/projects/#{project.id}/archive", user3)
expect(response).to have_gitlab_http_status(403)
@@ -1845,35 +1844,35 @@ describe API::Projects do
end
end
- describe 'POST /projects/:id/unarchive' do
- context 'on an unarchived project' do
- it 'remains unarchived' do
+ describe "POST /projects/:id/unarchive" do
+ context "on an unarchived project" do
+ it "remains unarchived" do
post api("/projects/#{project.id}/unarchive", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['archived']).to be_falsey
+ expect(json_response["archived"]).to be_falsey
end
end
- context 'on an archived project' do
+ context "on an archived project" do
before do
::Projects::UpdateService.new(project, user, archived: true).execute
end
- it 'unarchives the project' do
+ it "unarchives the project" do
post api("/projects/#{project.id}/unarchive", user)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['archived']).to be_falsey
+ expect(json_response["archived"]).to be_falsey
end
end
- context 'user without archiving rights to the project' do
+ context "user without archiving rights to the project" do
before do
project.add_developer(user3)
end
- it 'rejects the action' do
+ it "rejects the action" do
post api("/projects/#{project.id}/unarchive", user3)
expect(response).to have_gitlab_http_status(403)
@@ -1881,23 +1880,23 @@ describe API::Projects do
end
end
- describe 'POST /projects/:id/star' do
- context 'on an unstarred project' do
- it 'stars the project' do
+ describe "POST /projects/:id/star" do
+ context "on an unstarred project" do
+ it "stars the project" do
expect { post api("/projects/#{project.id}/star", user) }.to change { project.reload.star_count }.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['star_count']).to eq(1)
+ expect(json_response["star_count"]).to eq(1)
end
end
- context 'on a starred project' do
+ context "on a starred project" do
before do
user.toggle_star(project)
project.reload
end
- it 'does not modify the star count' do
+ it "does not modify the star count" do
expect { post api("/projects/#{project.id}/star", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304)
@@ -1905,23 +1904,23 @@ describe API::Projects do
end
end
- describe 'POST /projects/:id/unstar' do
- context 'on a starred project' do
+ describe "POST /projects/:id/unstar" do
+ context "on a starred project" do
before do
user.toggle_star(project)
project.reload
end
- it 'unstars the project' do
+ it "unstars the project" do
expect { post api("/projects/#{project.id}/unstar", user) }.to change { project.reload.star_count }.by(-1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['star_count']).to eq(0)
+ expect(json_response["star_count"]).to eq(0)
end
end
- context 'on an unstarred project' do
- it 'does not modify the star count' do
+ context "on an unstarred project" do
+ it "does not modify the star count" do
expect { post api("/projects/#{project.id}/unstar", user) }.not_to change { project.reload.star_count }
expect(response).to have_gitlab_http_status(304)
@@ -1929,35 +1928,35 @@ describe API::Projects do
end
end
- describe 'GET /projects/:id/languages' do
- context 'with an authorized user' do
- it_behaves_like 'languages and percentages JSON response' do
+ describe "GET /projects/:id/languages" do
+ context "with an authorized user" do
+ it_behaves_like "languages and percentages JSON response" do
let(:project) { project3 }
end
- it 'returns not_found(404) for not existing project' do
+ it "returns not_found(404) for not existing project" do
get api("/projects/0/languages", user)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'with not authorized user' do
- it 'returns not_found for existing but unauthorized project' do
+ context "with not authorized user" do
+ it "returns not_found for existing but unauthorized project" do
get api("/projects/#{project3.id}/languages", user3)
expect(response).to have_gitlab_http_status(:not_found)
end
end
- context 'without user' do
+ context "without user" do
let(:project_public) { create(:project, :public, :repository) }
- it_behaves_like 'languages and percentages JSON response' do
+ it_behaves_like "languages and percentages JSON response" do
let(:project) { project_public }
end
- it 'returns not_found for existing but unauthorized project' do
+ it "returns not_found for existing but unauthorized project" do
get api("/projects/#{project3.id}/languages", nil)
expect(response).to have_gitlab_http_status(:not_found)
@@ -1965,59 +1964,59 @@ describe API::Projects do
end
end
- describe 'DELETE /projects/:id' do
- context 'when authenticated as user' do
- it 'removes project' do
+ describe "DELETE /projects/:id" do
+ context "when authenticated as user" do
+ it "removes project" do
delete api("/projects/#{project.id}", user)
expect(response).to have_gitlab_http_status(202)
- expect(json_response['message']).to eql('202 Accepted')
+ expect(json_response["message"]).to eql("202 Accepted")
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:success_status) { 202 }
let(:request) { api("/projects/#{project.id}", user) }
end
- it 'does not remove a project if not an owner' do
+ it "does not remove a project if not an owner" do
user3 = create(:user)
project.add_developer(user3)
delete api("/projects/#{project.id}", user3)
expect(response).to have_gitlab_http_status(403)
end
- it 'does not remove a non existing project' do
- delete api('/projects/1328', user)
+ it "does not remove a non existing project" do
+ delete api("/projects/1328", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'does 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_gitlab_http_status(404)
end
end
- context 'when authenticated as admin' do
- it 'removes any existing project' do
+ context "when authenticated as admin" do
+ it "removes any existing project" do
delete api("/projects/#{project.id}", admin)
expect(response).to have_gitlab_http_status(202)
- expect(json_response['message']).to eql('202 Accepted')
+ expect(json_response["message"]).to eql("202 Accepted")
end
- it 'does not remove a non existing project' do
- delete api('/projects/1328', admin)
+ it "does not remove a non existing project" do
+ delete api("/projects/1328", admin)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:success_status) { 202 }
let(:request) { api("/projects/#{project.id}", admin) }
end
end
end
- describe 'POST /projects/:id/fork' do
+ describe "POST /projects/:id/fork" do
let(:project) do
create(:project, :repository, creator: user, namespace: user.namespace)
end
@@ -2028,13 +2027,13 @@ describe API::Projects do
let(:group) { create(:group) }
let(:group2) do
- group = create(:group, name: 'group2_name')
+ group = create(:group, name: "group2_name")
group.add_maintainer(user2)
group
end
let(:group3) do
- group = create(:group, name: 'group3_name', parent: group2)
+ group = create(:group, name: "group3_name", parent: group2)
group.add_owner(user2)
group
end
@@ -2044,181 +2043,181 @@ describe API::Projects do
project2.add_reporter(user2)
end
- context 'when authenticated' do
- it 'forks if user has sufficient access to project' do
+ context "when authenticated" do
+ it "forks if user has sufficient access to project" do
post api("/projects/#{project.id}/fork", user2)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(project.name)
- expect(json_response['path']).to eq(project.path)
- expect(json_response['owner']['id']).to eq(user2.id)
- expect(json_response['namespace']['id']).to eq(user2.namespace.id)
- expect(json_response['forked_from_project']['id']).to eq(project.id)
- expect(json_response['import_status']).to eq('scheduled')
+ expect(json_response["name"]).to eq(project.name)
+ expect(json_response["path"]).to eq(project.path)
+ expect(json_response["owner"]["id"]).to eq(user2.id)
+ expect(json_response["namespace"]["id"]).to eq(user2.namespace.id)
+ expect(json_response["forked_from_project"]["id"]).to eq(project.id)
+ expect(json_response["import_status"]).to eq("scheduled")
expect(json_response).to include("import_error")
end
- it 'forks if user is admin' do
+ it "forks if user is admin" do
post api("/projects/#{project.id}/fork", admin)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(project.name)
- expect(json_response['path']).to eq(project.path)
- expect(json_response['owner']['id']).to eq(admin.id)
- expect(json_response['namespace']['id']).to eq(admin.namespace.id)
- expect(json_response['forked_from_project']['id']).to eq(project.id)
- expect(json_response['import_status']).to eq('scheduled')
+ expect(json_response["name"]).to eq(project.name)
+ expect(json_response["path"]).to eq(project.path)
+ expect(json_response["owner"]["id"]).to eq(admin.id)
+ expect(json_response["namespace"]["id"]).to eq(admin.namespace.id)
+ expect(json_response["forked_from_project"]["id"]).to eq(project.id)
+ expect(json_response["import_status"]).to eq("scheduled")
expect(json_response).to include("import_error")
end
- it 'fails on missing project access for the project to fork' do
+ it "fails on missing project access for the project to fork" do
new_user = create(:user)
post api("/projects/#{project.id}/fork", new_user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
- it 'fails if forked project exists in the user namespace' do
+ it "fails if forked project exists in the user namespace" do
post api("/projects/#{project.id}/fork", user)
expect(response).to have_gitlab_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'])
+ expect(json_response["message"]["name"]).to eq(["has already been taken"])
+ expect(json_response["message"]["path"]).to eq(["has already been taken"])
end
- it 'fails if project to fork from does not exist' do
- post api('/projects/424242/fork', user)
+ it "fails if project to fork from does not exist" do
+ post api("/projects/424242/fork", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
- it 'forks with explicit own user namespace id' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: user2.namespace.id }
+ it "forks with explicit own user namespace id" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: user2.namespace.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['owner']['id']).to eq(user2.id)
+ expect(json_response["owner"]["id"]).to eq(user2.id)
end
- it 'forks with explicit own user name as namespace' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: user2.username }
+ it "forks with explicit own user name as namespace" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: user2.username}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['owner']['id']).to eq(user2.id)
+ expect(json_response["owner"]["id"]).to eq(user2.id)
end
- it 'forks to another user when admin' do
- post api("/projects/#{project.id}/fork", admin), params: { namespace: user2.username }
+ it "forks to another user when admin" do
+ post api("/projects/#{project.id}/fork", admin), params: {namespace: user2.username}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['owner']['id']).to eq(user2.id)
+ expect(json_response["owner"]["id"]).to eq(user2.id)
end
- it 'fails if trying to fork to another user when not admin' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: admin.namespace.id }
+ it "fails if trying to fork to another user when not admin" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: admin.namespace.id}
expect(response).to have_gitlab_http_status(404)
end
- it 'fails if trying to fork to non-existent namespace' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: 42424242 }
+ it "fails if trying to fork to non-existent namespace" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: 42424242}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Target Namespace Not Found')
+ expect(json_response["message"]).to eq("404 Target Namespace Not Found")
end
- it 'forks to owned group' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: group2.name }
+ it "forks to owned group" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: group2.name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['namespace']['name']).to eq(group2.name)
+ expect(json_response["namespace"]["name"]).to eq(group2.name)
end
- it 'forks to owned subgroup' do
+ it "forks to owned subgroup" do
full_path = "#{group2.path}/#{group3.path}"
- post api("/projects/#{project.id}/fork", user2), params: { namespace: full_path }
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: full_path}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['namespace']['name']).to eq(group3.name)
- expect(json_response['namespace']['full_path']).to eq(full_path)
+ expect(json_response["namespace"]["name"]).to eq(group3.name)
+ expect(json_response["namespace"]["full_path"]).to eq(full_path)
end
- it 'fails to fork to not owned group' do
- post api("/projects/#{project.id}/fork", user2), params: { namespace: group.name }
+ it "fails to fork to not owned group" do
+ post api("/projects/#{project.id}/fork", user2), params: {namespace: group.name}
expect(response).to have_gitlab_http_status(404)
end
- it 'forks to not owned group when admin' do
- post api("/projects/#{project.id}/fork", admin), params: { namespace: group.name }
+ it "forks to not owned group when admin" do
+ post api("/projects/#{project.id}/fork", admin), params: {namespace: group.name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['namespace']['name']).to eq(group.name)
+ expect(json_response["namespace"]["name"]).to eq(group.name)
end
- it 'accepts a path for the target project' do
- post api("/projects/#{project.id}/fork", user2), params: { path: 'foobar' }
+ it "accepts a path for the target project" do
+ post api("/projects/#{project.id}/fork", user2), params: {path: "foobar"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(project.name)
- expect(json_response['path']).to eq('foobar')
- expect(json_response['owner']['id']).to eq(user2.id)
- expect(json_response['namespace']['id']).to eq(user2.namespace.id)
- expect(json_response['forked_from_project']['id']).to eq(project.id)
- expect(json_response['import_status']).to eq('scheduled')
+ expect(json_response["name"]).to eq(project.name)
+ expect(json_response["path"]).to eq("foobar")
+ expect(json_response["owner"]["id"]).to eq(user2.id)
+ expect(json_response["namespace"]["id"]).to eq(user2.namespace.id)
+ expect(json_response["forked_from_project"]["id"]).to eq(project.id)
+ expect(json_response["import_status"]).to eq("scheduled")
expect(json_response).to include("import_error")
end
- it 'fails to fork if path is already taken' do
- post api("/projects/#{project.id}/fork", user2), params: { path: 'foobar' }
- post api("/projects/#{project2.id}/fork", user2), params: { path: 'foobar' }
+ it "fails to fork if path is already taken" do
+ post api("/projects/#{project.id}/fork", user2), params: {path: "foobar"}
+ post api("/projects/#{project2.id}/fork", user2), params: {path: "foobar"}
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']['path']).to eq(['has already been taken'])
+ expect(json_response["message"]["path"]).to eq(["has already been taken"])
end
- it 'accepts a name for the target project' do
- post api("/projects/#{project.id}/fork", user2), params: { name: 'My Random Project' }
+ it "accepts a name for the target project" do
+ post api("/projects/#{project.id}/fork", user2), params: {name: "My Random Project"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq('My Random Project')
- expect(json_response['path']).to eq(project.path)
- expect(json_response['owner']['id']).to eq(user2.id)
- expect(json_response['namespace']['id']).to eq(user2.namespace.id)
- expect(json_response['forked_from_project']['id']).to eq(project.id)
- expect(json_response['import_status']).to eq('scheduled')
+ expect(json_response["name"]).to eq("My Random Project")
+ expect(json_response["path"]).to eq(project.path)
+ expect(json_response["owner"]["id"]).to eq(user2.id)
+ expect(json_response["namespace"]["id"]).to eq(user2.namespace.id)
+ expect(json_response["forked_from_project"]["id"]).to eq(project.id)
+ expect(json_response["import_status"]).to eq("scheduled")
expect(json_response).to include("import_error")
end
- it 'fails to fork if name is already taken' do
- post api("/projects/#{project.id}/fork", user2), params: { name: 'My Random Project' }
- post api("/projects/#{project2.id}/fork", user2), params: { name: 'My Random Project' }
+ it "fails to fork if name is already taken" do
+ post api("/projects/#{project.id}/fork", user2), params: {name: "My Random Project"}
+ post api("/projects/#{project2.id}/fork", user2), params: {name: "My Random Project"}
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']['name']).to eq(['has already been taken'])
+ expect(json_response["message"]["name"]).to eq(["has already been taken"])
end
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
post api("/projects/#{project.id}/fork")
expect(response).to have_gitlab_http_status(401)
- expect(json_response['message']).to eq('401 Unauthorized')
+ expect(json_response["message"]).to eq("401 Unauthorized")
end
end
end
- describe 'POST /projects/:id/housekeeping' do
+ describe "POST /projects/:id/housekeeping" do
let(:housekeeping) { Projects::HousekeepingService.new(project) }
before do
allow(Projects::HousekeepingService).to receive(:new).with(project).and_return(housekeeping)
end
- context 'when authenticated as owner' do
- it 'starts the housekeeping process' do
+ context "when authenticated as owner" do
+ it "starts the housekeeping process" do
expect(housekeeping).to receive(:execute).once
post api("/projects/#{project.id}/housekeeping", user)
@@ -2226,32 +2225,32 @@ describe API::Projects do
expect(response).to have_gitlab_http_status(201)
end
- context 'when housekeeping lease is taken' do
- it 'returns conflict' do
+ context "when housekeeping lease is taken" do
+ it "returns conflict" do
expect(housekeeping).to receive(:execute).once.and_raise(Projects::HousekeepingService::LeaseTaken)
post api("/projects/#{project.id}/housekeeping", user)
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to match(/Somebody already triggered housekeeping for this project/)
+ expect(json_response["message"]).to match(/Somebody already triggered housekeeping for this project/)
end
end
end
- context 'when authenticated as developer' do
+ context "when authenticated as developer" do
before do
project_member
end
- it 'returns forbidden error' do
+ it "returns forbidden error" do
post api("/projects/#{project.id}/housekeeping", user3)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
post api("/projects/#{project.id}/housekeeping")
expect(response).to have_gitlab_http_status(401)
@@ -2259,31 +2258,31 @@ describe API::Projects do
end
end
- describe 'PUT /projects/:id/transfer' do
- context 'when authenticated as owner' do
+ describe "PUT /projects/:id/transfer" do
+ context "when authenticated as owner" do
let(:group) { create :group }
- it 'transfers the project to the new namespace' do
+ it "transfers the project to the new namespace" do
group.add_owner(user)
- put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id }
+ put api("/projects/#{project.id}/transfer", user), params: {namespace: group.id}
expect(response).to have_gitlab_http_status(200)
end
- it 'fails when transferring to a non owned namespace' do
- put api("/projects/#{project.id}/transfer", user), params: { namespace: group.id }
+ it "fails when transferring to a non owned namespace" do
+ put api("/projects/#{project.id}/transfer", user), params: {namespace: group.id}
expect(response).to have_gitlab_http_status(404)
end
- it 'fails when transferring to an unknown namespace' do
- put api("/projects/#{project.id}/transfer", user), params: { namespace: 'unknown' }
+ it "fails when transferring to an unknown namespace" do
+ put api("/projects/#{project.id}/transfer", user), params: {namespace: "unknown"}
expect(response).to have_gitlab_http_status(404)
end
- it 'fails on missing namespace' do
+ it "fails on missing namespace" do
put api("/projects/#{project.id}/transfer", user)
expect(response).to have_gitlab_http_status(400)
@@ -2291,7 +2290,7 @@ describe API::Projects do
end
end
- it_behaves_like 'custom attributes endpoints', 'projects' do
+ it_behaves_like "custom attributes endpoints", "projects" do
let(:attributable) { project }
let(:other_attributable) { project2 }
end
diff --git a/spec/requests/api/protected_branches_spec.rb b/spec/requests/api/protected_branches_spec.rb
index f90558d77a9..21f7417f33a 100644
--- a/spec/requests/api/protected_branches_spec.rb
+++ b/spec/requests/api/protected_branches_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProtectedBranches do
let(:user) { create(:user) }
let!(:project) { create(:project, :repository) }
- let(:protected_name) { 'feature' }
+ let(:protected_name) { "feature" }
let(:branch_name) { protected_name }
let!(:protected_branch) do
create(:protected_branch, project: project, name: protected_name)
@@ -12,34 +12,34 @@ describe API::ProtectedBranches do
describe "GET /projects/:id/protected_branches" do
let(:route) { "/projects/#{project.id}/protected_branches" }
- shared_examples_for 'protected branches' do
- it 'returns the protected branches' do
- get api(route, user), params: { per_page: 100 }
+ shared_examples_for "protected branches" do
+ it "returns the protected branches" do
+ get api(route, user), params: {per_page: 100}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- protected_branch_names = json_response.map { |x| x['name'] }
- expected_branch_names = project.protected_branches.map { |x| x['name'] }
+ protected_branch_names = json_response.map { |x| x["name"] }
+ expected_branch_names = project.protected_branches.map { |x| x["name"] }
expect(protected_branch_names).to match_array(expected_branch_names)
end
end
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'protected branches'
+ it_behaves_like "protected branches"
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
@@ -48,173 +48,173 @@ describe API::ProtectedBranches do
describe "GET /projects/:id/protected_branches/:branch" do
let(:route) { "/projects/#{project.id}/protected_branches/#{branch_name}" }
- shared_examples_for 'protected branch' do
- it 'returns the protected branch' do
+ shared_examples_for "protected branch" do
+ it "returns the protected branch" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(::Gitlab::Access::MAINTAINER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(::Gitlab::Access::MAINTAINER)
end
- context 'when protected branch does not exist' do
- let(:branch_name) { 'unknown' }
+ context "when protected branch does not exist" do
+ let(:branch_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, user) }
- let(:message) { '404 Not found' }
+ let(:message) { "404 Not found" }
end
end
end
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'protected branch'
+ it_behaves_like "protected branch"
- context 'when protected branch contains a wildcard' do
- let(:protected_name) { 'feature*' }
+ context "when protected branch contains a wildcard" do
+ let(:protected_name) { "feature*" }
- it_behaves_like 'protected branch'
+ it_behaves_like "protected branch"
end
- context 'when protected branch contains a period' do
- let(:protected_name) { 'my.feature' }
+ context "when protected branch contains a period" do
+ let(:protected_name) { "my.feature" }
- it_behaves_like 'protected branch'
+ it_behaves_like "protected branch"
end
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
end
- describe 'POST /projects/:id/protected_branches' do
- let(:branch_name) { 'new_branch' }
+ describe "POST /projects/:id/protected_branches" do
+ let(:branch_name) { "new_branch" }
let(:post_endpoint) { api("/projects/#{project.id}/protected_branches", user) }
def expect_protection_to_be_successful
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
+ expect(json_response["name"]).to eq(branch_name)
end
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it 'protects a single branch' do
- post post_endpoint, params: { name: branch_name }
+ it "protects a single branch" do
+ post post_endpoint, params: {name: branch_name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
- it 'protects a single branch and developers can push' do
- post post_endpoint, params: { name: branch_name, push_access_level: 30 }
+ it "protects a single branch and developers can push" do
+ post post_endpoint, params: {name: branch_name, push_access_level: 30}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
- it 'protects a single branch and developers can merge' do
- post post_endpoint, params: { name: branch_name, merge_access_level: 30 }
+ it "protects a single branch and developers can merge" do
+ post post_endpoint, params: {name: branch_name, merge_access_level: 30}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::DEVELOPER)
end
- it 'protects a single branch and developers can push and merge' do
- post post_endpoint, params: { name: branch_name, push_access_level: 30, merge_access_level: 30 }
+ it "protects a single branch and developers can push and merge" do
+ post post_endpoint, params: {name: branch_name, push_access_level: 30, merge_access_level: 30}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::DEVELOPER)
end
- it 'protects a single branch and no one can push' do
- post post_endpoint, params: { name: branch_name, push_access_level: 0 }
+ it "protects a single branch and no one can push" do
+ post post_endpoint, params: {name: branch_name, push_access_level: 0}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::NO_ACCESS)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
- it 'protects a single branch and no one can merge' do
- post post_endpoint, params: { name: branch_name, merge_access_level: 0 }
+ it "protects a single branch and no one can merge" do
+ post post_endpoint, params: {name: branch_name, merge_access_level: 0}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::NO_ACCESS)
end
- it 'protects a single branch and no one can push or merge' do
- post post_endpoint, params: { name: branch_name, push_access_level: 0, merge_access_level: 0 }
+ it "protects a single branch and no one can push or merge" do
+ post post_endpoint, params: {name: branch_name, push_access_level: 0, merge_access_level: 0}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(branch_name)
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
+ expect(json_response["name"]).to eq(branch_name)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::NO_ACCESS)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::NO_ACCESS)
end
- it 'returns a 409 error if the same branch is protected twice' do
- post post_endpoint, params: { name: protected_name }
+ it "returns a 409 error if the same branch is protected twice" do
+ post post_endpoint, params: {name: protected_name}
expect(response).to have_gitlab_http_status(409)
end
- context 'when branch has a wildcard in its name' do
- let(:branch_name) { 'feature/*' }
+ context "when branch has a wildcard in its name" do
+ let(:branch_name) { "feature/*" }
it "protects multiple branches with a wildcard in the name" do
- post post_endpoint, params: { name: branch_name }
+ post post_endpoint, params: {name: branch_name}
expect_protection_to_be_successful
- expect(json_response['push_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
- expect(json_response['merge_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["push_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["merge_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
end
it "prevents deletion of the protected branch rule" do
- post post_endpoint, params: { name: branch_name }
+ post post_endpoint, params: {name: branch_name}
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
it "returns a 403 error if guest" do
- post post_endpoint, params: { name: branch_name }
+ post post_endpoint, params: {name: branch_name}
expect(response).to have_gitlab_http_status(403)
end
@@ -234,7 +234,7 @@ describe API::ProtectedBranches do
expect(response).to have_gitlab_http_status(204)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { delete_endpoint }
end
@@ -244,7 +244,7 @@ describe API::ProtectedBranches do
expect(response).to have_gitlab_http_status(404)
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
@@ -257,8 +257,8 @@ describe API::ProtectedBranches do
end
end
- context 'when branch has a wildcard in its name' do
- let(:protected_name) { 'feature*' }
+ context "when branch has a wildcard in its name" do
+ let(:protected_name) { "feature*" }
it "unprotects a wildcard branch" do
delete delete_endpoint
diff --git a/spec/requests/api/protected_tags_spec.rb b/spec/requests/api/protected_tags_spec.rb
index 41363dcc1c3..cb647e2e281 100644
--- a/spec/requests/api/protected_tags_spec.rb
+++ b/spec/requests/api/protected_tags_spec.rb
@@ -1,185 +1,185 @@
-require 'spec_helper'
+require "spec_helper"
describe API::ProtectedTags do
let(:user) { create(:user) }
let!(:project) { create(:project, :repository) }
- let(:project2) { create(:project, path: 'project2', namespace: user.namespace) }
- let(:protected_name) { 'feature' }
+ let(:project2) { create(:project, path: "project2", namespace: user.namespace) }
+ let(:protected_name) { "feature" }
let(:tag_name) { protected_name }
let!(:protected_tag) do
create(:protected_tag, project: project, name: protected_name)
end
- describe 'GET /projects/:id/protected_tags' do
+ describe "GET /projects/:id/protected_tags" do
let(:route) { "/projects/#{project.id}/protected_tags" }
- shared_examples_for 'protected tags' do
- it 'returns the protected tags' do
- get api(route, user), params: { per_page: 100 }
+ shared_examples_for "protected tags" do
+ it "returns the protected tags" do
+ get api(route, user), params: {per_page: 100}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- protected_tag_names = json_response.map { |x| x['name'] }
- expected_tags_names = project.protected_tags.map { |x| x['name'] }
+ protected_tag_names = json_response.map { |x| x["name"] }
+ expected_tags_names = project.protected_tags.map { |x| x["name"] }
expect(protected_tag_names).to match_array(expected_tags_names)
end
end
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'protected tags'
+ it_behaves_like "protected tags"
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
end
- describe 'GET /projects/:id/protected_tags/:tag' do
+ describe "GET /projects/:id/protected_tags/:tag" do
let(:route) { "/projects/#{project.id}/protected_tags/#{tag_name}" }
- shared_examples_for 'protected tag' do
- it 'returns the protected tag' do
+ shared_examples_for "protected tag" do
+ it "returns the protected tag" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['create_access_levels'][0]['access_level']).to eq(::Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["create_access_levels"][0]["access_level"]).to eq(::Gitlab::Access::MAINTAINER)
end
- context 'when protected tag does not exist' do
- let(:tag_name) { 'unknown' }
+ context "when protected tag does not exist" do
+ let(:tag_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, user) }
- let(:message) { '404 Not found' }
+ let(:message) { "404 Not found" }
end
end
end
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it_behaves_like 'protected tag'
+ it_behaves_like "protected tag"
- context 'when protected tag contains a wildcard' do
- let(:protected_name) { 'feature*' }
+ context "when protected tag contains a wildcard" do
+ let(:protected_name) { "feature*" }
- it_behaves_like 'protected tag'
+ it_behaves_like "protected tag"
end
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, user) }
end
end
end
- describe 'POST /projects/:id/protected_tags' do
- let(:tag_name) { 'new_tag' }
+ describe "POST /projects/:id/protected_tags" do
+ let(:tag_name) { "new_tag" }
- context 'when authenticated as a maintainer' do
+ context "when authenticated as a maintainer" do
before do
project.add_maintainer(user)
end
- it 'protects a single tag with maintainers can create tags' do
- post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
+ it "protects a single tag with maintainers can create tags" do
+ post api("/projects/#{project.id}/protected_tags", user), params: {name: tag_name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["create_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
- it 'protects a single tag with developers can create tags' do
+ it "protects a single tag with developers can create tags" do
post api("/projects/#{project.id}/protected_tags", user),
- params: { name: tag_name, create_access_level: 30 }
+ params: {name: tag_name, create_access_level: 30}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::DEVELOPER)
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["create_access_levels"][0]["access_level"]).to eq(Gitlab::Access::DEVELOPER)
end
- it 'protects a single tag with no one can create tags' do
+ it "protects a single tag with no one can create tags" do
post api("/projects/#{project.id}/protected_tags", user),
- params: { name: tag_name, create_access_level: 0 }
+ params: {name: tag_name, create_access_level: 0}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::NO_ACCESS)
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["create_access_levels"][0]["access_level"]).to eq(Gitlab::Access::NO_ACCESS)
end
- it 'returns a 422 error if the same tag is protected twice' do
- post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
+ it "returns a 422 error if the same tag is protected twice" do
+ post api("/projects/#{project.id}/protected_tags", user), params: {name: protected_name}
expect(response).to have_gitlab_http_status(422)
- expect(json_response['message'][0]).to eq('Name has already been taken')
+ expect(json_response["message"][0]).to eq("Name has already been taken")
end
- it 'returns 201 if the same tag is proteted on different projects' do
- post api("/projects/#{project.id}/protected_tags", user), params: { name: protected_name }
- post api("/projects/#{project2.id}/protected_tags", user), params: { name: protected_name }
+ it "returns 201 if the same tag is proteted on different projects" do
+ post api("/projects/#{project.id}/protected_tags", user), params: {name: protected_name}
+ post api("/projects/#{project2.id}/protected_tags", user), params: {name: protected_name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(protected_name)
+ expect(json_response["name"]).to eq(protected_name)
end
- context 'when tag has a wildcard in its name' do
- let(:tag_name) { 'feature/*' }
+ context "when tag has a wildcard in its name" do
+ let(:tag_name) { "feature/*" }
- it 'protects multiple tags with a wildcard in the name' do
- post api("/projects/#{project.id}/protected_tags", user), params: { name: tag_name }
+ it "protects multiple tags with a wildcard in the name" do
+ post api("/projects/#{project.id}/protected_tags", user), params: {name: tag_name}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['create_access_levels'][0]['access_level']).to eq(Gitlab::Access::MAINTAINER)
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["create_access_levels"][0]["access_level"]).to eq(Gitlab::Access::MAINTAINER)
end
end
end
- context 'when authenticated as a guest' do
+ context "when authenticated as a guest" do
before do
project.add_guest(user)
end
- it 'returns a 403 error if guest' do
- post api("/projects/#{project.id}/protected_tags/", user), params: { name: tag_name }
+ it "returns a 403 error if guest" do
+ post api("/projects/#{project.id}/protected_tags/", user), params: {name: tag_name}
expect(response).to have_gitlab_http_status(403)
end
end
end
- describe 'DELETE /projects/:id/protected_tags/unprotect/:tag' do
+ describe "DELETE /projects/:id/protected_tags/unprotect/:tag" do
before do
project.add_maintainer(user)
end
- it 'unprotects a single tag' do
+ it "unprotects a single tag" do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/protected_tags/#{tag_name}", user) }
end
@@ -189,10 +189,10 @@ describe API::ProtectedTags do
expect(response).to have_gitlab_http_status(404)
end
- context 'when tag has a wildcard in its name' do
- let(:protected_name) { 'feature*' }
+ context "when tag has a wildcard in its name" do
+ let(:protected_name) { "feature*" }
- it 'unprotects a wildcard tag' do
+ it "unprotects a wildcard tag" do
delete api("/projects/#{project.id}/protected_tags/#{tag_name}", user)
expect(response).to have_gitlab_http_status(204)
diff --git a/spec/requests/api/release/links_spec.rb b/spec/requests/api/release/links_spec.rb
index ba948e37e2f..6341b6cbfc9 100644
--- a/spec/requests/api/release/links_spec.rb
+++ b/spec/requests/api/release/links_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::Release::Links do
let(:project) { create(:project, :repository, :private) }
@@ -11,63 +11,63 @@ describe API::Release::Links do
let!(:release) do
create(:release,
- project: project,
- tag: 'v0.1',
- author: maintainer)
+ project: project,
+ tag: "v0.1",
+ author: maintainer)
end
before do
project.add_maintainer(maintainer)
project.add_reporter(reporter)
- project.repository.add_tag(maintainer, 'v0.1', commit.id)
+ project.repository.add_tag(maintainer, "v0.1", commit.id)
end
- describe 'GET /projects/:id/releases/:tag_name/assets/links' do
- context 'when there are two release links' do
+ describe "GET /projects/:id/releases/:tag_name/assets/links" do
+ context "when there are two release links" do
let!(:release_link_1) { create(:release_link, release: release, created_at: 2.days.ago) }
let!(:release_link_2) { create(:release_link, release: release, created_at: 1.day.ago) }
- it 'returns 200 HTTP status' do
+ it "returns 200 HTTP status" do
get api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns release links ordered by created_at' do
+ it "returns release links ordered by created_at" do
get api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer)
expect(json_response.count).to eq(2)
- expect(json_response.first['name']).to eq(release_link_2.name)
- expect(json_response.second['name']).to eq(release_link_1.name)
+ expect(json_response.first["name"]).to eq(release_link_2.name)
+ expect(json_response.second["name"]).to eq(release_link_1.name)
end
- it 'matches response schema' do
+ it "matches response schema" do
get api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer)
- expect(response).to match_response_schema('release/links')
+ expect(response).to match_response_schema("release/links")
end
end
- context 'when release does not exist' do
+ context "when release does not exist" do
let!(:release) { }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer) }
- let(:message) { '404 Not found' }
+ let(:message) { "404 Not found" }
end
end
- context 'when user is not a project member' do
- it_behaves_like '404 response' do
+ context "when user is not a project member" do
+ it_behaves_like "404 response" do
let(:request) { get api("/projects/#{project.id}/releases/v0.1/assets/links", non_project_member) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'allows the request' do
+ it "allows the request" do
get api("/projects/#{project.id}/releases/v0.1/assets/links", non_project_member)
expect(response).to have_gitlab_http_status(:ok)
@@ -76,43 +76,43 @@ describe API::Release::Links do
end
end
- describe 'GET /projects/:id/releases/:tag_name/assets/links/:link_id' do
+ describe "GET /projects/:id/releases/:tag_name/assets/links/:link_id" do
let!(:release_link) { create(:release_link, release: release) }
- it 'returns 200 HTTP status' do
+ it "returns 200 HTTP status" do
get api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns a link entry' do
+ it "returns a link entry" do
get api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
- expect(json_response['name']).to eq(release_link.name)
- expect(json_response['url']).to eq(release_link.url)
+ expect(json_response["name"]).to eq(release_link.name)
+ expect(json_response["url"]).to eq(release_link.url)
end
- it 'matches response schema' do
+ it "matches response schema" do
get api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
- expect(response).to match_response_schema('release/link')
+ expect(response).to match_response_schema("release/link")
end
- context 'when specified tag is not found in the project' do
- it_behaves_like '404 response' do
+ context "when specified tag is not found in the project" do
+ it_behaves_like "404 response" do
let(:request) { get api("/projects/#{project.id}/releases/non_existing_tag/assets/links/#{release_link.id}", maintainer) }
end
end
- context 'when user is not a project member' do
- it_behaves_like '404 response' do
+ context "when user is not a project member" do
+ it_behaves_like "404 response" do
let(:request) { get api("/projects/#{project.id}/releases/non_existing_tag/assets/links/#{release_link.id}", non_project_member) }
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'allows the request' do
+ it "allows the request" do
get api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", non_project_member)
expect(response).to have_gitlab_http_status(:ok)
@@ -121,234 +121,234 @@ describe API::Release::Links do
end
end
- describe 'POST /projects/:id/releases/:tag_name/assets/links' do
+ describe "POST /projects/:id/releases/:tag_name/assets/links" do
let(:params) do
{
- name: 'awesome-app.dmg',
- url: 'https://example.com/download/awesome-app.dmg'
+ name: "awesome-app.dmg",
+ url: "https://example.com/download/awesome-app.dmg",
}
end
- it 'accepts the request' do
+ it "accepts the request" do
post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer), params: params
expect(response).to have_gitlab_http_status(:created)
end
- it 'creates a new release' do
- expect do
+ it "creates a new release" do
+ expect {
post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer), params: params
- end.to change { Releases::Link.count }.by(1)
+ }.to change { Releases::Link.count }.by(1)
release.reload
- expect(release.links.last.name).to eq('awesome-app.dmg')
- expect(release.links.last.url).to eq('https://example.com/download/awesome-app.dmg')
+ expect(release.links.last.name).to eq("awesome-app.dmg")
+ expect(release.links.last.url).to eq("https://example.com/download/awesome-app.dmg")
end
- it 'matches response schema' do
+ it "matches response schema" do
post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer), params: params
- expect(response).to match_response_schema('release/link')
+ expect(response).to match_response_schema("release/link")
end
- context 'when name is empty' do
+ context "when name is empty" do
let(:params) do
{
- name: '',
- url: 'https://example.com/download/awesome-app.dmg'
+ name: "",
+ url: "https://example.com/download/awesome-app.dmg",
}
end
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) do
post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer),
- params: params
+ params: params
end
end
end
- context 'when user is a reporter' do
- it_behaves_like '403 response' do
+ context "when user is a reporter" do
+ it_behaves_like "403 response" do
let(:request) do
post api("/projects/#{project.id}/releases/v0.1/assets/links", reporter),
- params: params
+ params: params
end
end
end
- context 'when user is not a project member' do
- it 'forbids the request' do
+ context "when user is not a project member" do
+ it "forbids the request" do
post api("/projects/#{project.id}/releases/v0.1/assets/links", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'forbids the request' do
+ it "forbids the request" do
post api("/projects/#{project.id}/releases/v0.1/assets/links", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
end
- context 'when the same link already exists' do
+ context "when the same link already exists" do
before do
create(:release_link,
- release: release,
- name: 'awesome-app.dmg',
- url: 'https://example.com/download/awesome-app.dmg')
+ release: release,
+ name: "awesome-app.dmg",
+ url: "https://example.com/download/awesome-app.dmg")
end
- it_behaves_like '400 response' do
+ it_behaves_like "400 response" do
let(:request) do
post api("/projects/#{project.id}/releases/v0.1/assets/links", maintainer),
- params: params
+ params: params
end
end
end
end
- describe 'PUT /projects/:id/releases/:tag_name/assets/links/:link_id' do
- let(:params) { { name: 'awesome-app.msi' } }
+ describe "PUT /projects/:id/releases/:tag_name/assets/links/:link_id" do
+ let(:params) { {name: "awesome-app.msi"} }
let!(:release_link) { create(:release_link, release: release) }
- it 'accepts the request' do
+ it "accepts the request" do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:ok)
end
- it 'updates the name' do
+ it "updates the name" do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer),
- params: params
+ params: params
- expect(json_response['name']).to eq('awesome-app.msi')
+ expect(json_response["name"]).to eq("awesome-app.msi")
end
- it 'does not update the url' do
+ it "does not update the url" do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer),
- params: params
+ params: params
- expect(json_response['url']).to eq(release_link.url)
+ expect(json_response["url"]).to eq(release_link.url)
end
- it 'matches response schema' do
+ it "matches response schema" do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer),
- params: params
+ params: params
- expect(response).to match_response_schema('release/link')
+ expect(response).to match_response_schema("release/link")
end
- context 'when params is empty' do
+ context "when params is empty" do
let(:params) { {} }
- it 'does not allow the request' do
+ it "does not allow the request" do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when there are no corresponding release link' do
+ context "when there are no corresponding release link" do
let!(:release_link) { }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) do
put api("/projects/#{project.id}/releases/v0.1/assets/links/1", maintainer),
- params: params
+ params: params
end
end
end
- context 'when user is a reporter' do
- it_behaves_like '403 response' do
+ context "when user is a reporter" do
+ it_behaves_like "403 response" do
let(:request) do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", reporter),
- params: params
+ params: params
end
end
end
- context 'when user is not a project member' do
- it_behaves_like '404 response' do
+ context "when user is not a project member" do
+ it_behaves_like "404 response" do
let(:request) do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", non_project_member),
- params: params
+ params: params
end
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) do
put api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", non_project_member),
- params: params
+ params: params
end
end
end
end
end
- describe 'DELETE /projects/:id/releases/:tag_name/assets/links/:link_id' do
+ describe "DELETE /projects/:id/releases/:tag_name/assets/links/:link_id" do
let!(:release_link) do
create(:release_link, release: release)
end
- it 'accepts the request' do
+ it "accepts the request" do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'destroys the release link' do
- expect do
+ it "destroys the release link" do
+ expect {
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
- end.to change { Releases::Link.count }.by(-1)
+ }.to change { Releases::Link.count }.by(-1)
end
- it 'matches response schema' do
+ it "matches response schema" do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", maintainer)
- expect(response).to match_response_schema('release/link')
+ expect(response).to match_response_schema("release/link")
end
- context 'when there are no corresponding release link' do
+ context "when there are no corresponding release link" do
let!(:release_link) { }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/1", maintainer)
end
end
end
- context 'when user is a reporter' do
- it_behaves_like '403 response' do
+ context "when user is a reporter" do
+ it_behaves_like "403 response" do
let(:request) do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", reporter)
end
end
end
- context 'when user is not a project member' do
- it_behaves_like '404 response' do
+ context "when user is not a project member" do
+ it_behaves_like "404 response" do
let(:request) do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", non_project_member)
end
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) do
delete api("/projects/#{project.id}/releases/v0.1/assets/links/#{release_link.id}", non_project_member)
end
diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb
index 1f317971a66..8bd96c5be42 100644
--- a/spec/requests/api/releases_spec.rb
+++ b/spec/requests/api/releases_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Releases do
let(:project) { create(:project, :repository, :private) }
@@ -11,72 +11,72 @@ describe API::Releases do
project.add_maintainer(maintainer)
project.add_reporter(reporter)
- project.repository.add_tag(maintainer, 'v0.1', commit.id)
- project.repository.add_tag(maintainer, 'v0.2', commit.id)
+ project.repository.add_tag(maintainer, "v0.1", commit.id)
+ project.repository.add_tag(maintainer, "v0.2", commit.id)
end
- describe 'GET /projects/:id/releases' do
- context 'when there are two releases' do
+ describe "GET /projects/:id/releases" do
+ context "when there are two releases" do
let!(:release_1) do
create(:release,
- project: project,
- tag: 'v0.1',
- author: maintainer,
- created_at: 2.days.ago)
+ project: project,
+ tag: "v0.1",
+ author: maintainer,
+ created_at: 2.days.ago)
end
let!(:release_2) do
create(:release,
- project: project,
- tag: 'v0.2',
- author: maintainer,
- created_at: 1.day.ago)
+ project: project,
+ tag: "v0.2",
+ author: maintainer,
+ created_at: 1.day.ago)
end
- it 'returns 200 HTTP status' do
+ it "returns 200 HTTP status" do
get api("/projects/#{project.id}/releases", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns releases ordered by created_at' do
+ it "returns releases ordered by created_at" do
get api("/projects/#{project.id}/releases", maintainer)
expect(json_response.count).to eq(2)
- expect(json_response.first['tag_name']).to eq(release_2.tag)
- expect(json_response.second['tag_name']).to eq(release_1.tag)
+ expect(json_response.first["tag_name"]).to eq(release_2.tag)
+ expect(json_response.second["tag_name"]).to eq(release_1.tag)
end
- it 'matches response schema' do
+ it "matches response schema" do
get api("/projects/#{project.id}/releases", maintainer)
- expect(response).to match_response_schema('releases')
+ expect(response).to match_response_schema("releases")
end
end
- context 'when tag does not exist in git repository' do
- let!(:release) { create(:release, project: project, tag: 'v1.1.5') }
+ context "when tag does not exist in git repository" do
+ let!(:release) { create(:release, project: project, tag: "v1.1.5") }
- it 'returns the tag' do
+ it "returns the tag" do
get api("/projects/#{project.id}/releases", maintainer)
expect(json_response.count).to eq(1)
- expect(json_response.first['tag_name']).to eq('v1.1.5')
+ expect(json_response.first["tag_name"]).to eq("v1.1.5")
expect(release).to be_tag_missing
end
end
- context 'when user is not a project member' do
- it 'cannot find the project' do
+ context "when user is not a project member" do
+ it "cannot find the project" do
get api("/projects/#{project.id}/releases", non_project_member)
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'allows the request' do
+ it "allows the request" do
get api("/projects/#{project.id}/releases", non_project_member)
expect(response).to have_gitlab_http_status(:ok)
@@ -85,133 +85,133 @@ describe API::Releases do
end
end
- describe 'GET /projects/:id/releases/:tag_name' do
- context 'when there is a release' do
+ describe "GET /projects/:id/releases/:tag_name" do
+ context "when there is a release" do
let!(:release) do
create(:release,
- project: project,
- tag: 'v0.1',
- sha: commit.id,
- author: maintainer,
- description: 'This is v0.1')
+ project: project,
+ tag: "v0.1",
+ sha: commit.id,
+ author: maintainer,
+ description: "This is v0.1")
end
- it 'returns 200 HTTP status' do
+ it "returns 200 HTTP status" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'returns a release entry' do
+ it "returns a release entry" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(json_response['tag_name']).to eq(release.tag)
- expect(json_response['description']).to eq('This is v0.1')
- expect(json_response['author']['name']).to eq(maintainer.name)
- expect(json_response['commit']['id']).to eq(commit.id)
- expect(json_response['assets']['count']).to eq(4)
+ expect(json_response["tag_name"]).to eq(release.tag)
+ expect(json_response["description"]).to eq("This is v0.1")
+ expect(json_response["author"]["name"]).to eq(maintainer.name)
+ expect(json_response["commit"]["id"]).to eq(commit.id)
+ expect(json_response["assets"]["count"]).to eq(4)
end
- it 'matches response schema' do
+ it "matches response schema" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(response).to match_response_schema('release')
+ expect(response).to match_response_schema("release")
end
- it 'contains source information as assets' do
+ it "contains source information as assets" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(json_response['assets']['sources'].map { |h| h['format'] })
+ expect(json_response["assets"]["sources"].map { |h| h["format"] })
.to match_array(release.sources.map(&:format))
- expect(json_response['assets']['sources'].map { |h| h['url'] })
+ expect(json_response["assets"]["sources"].map { |h| h["url"] })
.to match_array(release.sources.map(&:url))
end
context "when release description contains confidential issue's link" do
let(:confidential_issue) do
create(:issue,
- :confidential,
- project: project,
- title: 'A vulnerability')
+ :confidential,
+ project: project,
+ title: "A vulnerability")
end
let!(:release) do
create(:release,
- project: project,
- tag: 'v0.1',
- sha: commit.id,
- author: maintainer,
- description: "This is confidential #{confidential_issue.to_reference}")
+ project: project,
+ tag: "v0.1",
+ sha: commit.id,
+ author: maintainer,
+ description: "This is confidential #{confidential_issue.to_reference}")
end
it "does not expose confidential issue's title" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(json_response['description_html']).to include(confidential_issue.to_reference)
- expect(json_response['description_html']).not_to include('A vulnerability')
+ expect(json_response["description_html"]).to include(confidential_issue.to_reference)
+ expect(json_response["description_html"]).not_to include("A vulnerability")
end
end
- context 'when release has link asset' do
+ context "when release has link asset" do
let!(:link) do
create(:release_link,
- release: release,
- name: 'release-18.04.dmg',
- url: url)
+ release: release,
+ name: "release-18.04.dmg",
+ url: url)
end
- let(:url) { 'https://my-external-hosting.example.com/scrambled-url/app.zip' }
+ let(:url) { "https://my-external-hosting.example.com/scrambled-url/app.zip" }
- it 'contains link information as assets' do
+ it "contains link information as assets" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(json_response['assets']['links'].count).to eq(1)
- expect(json_response['assets']['links'].first['id']).to eq(link.id)
- expect(json_response['assets']['links'].first['name'])
- .to eq('release-18.04.dmg')
- expect(json_response['assets']['links'].first['url'])
- .to eq('https://my-external-hosting.example.com/scrambled-url/app.zip')
- expect(json_response['assets']['links'].first['external'])
+ expect(json_response["assets"]["links"].count).to eq(1)
+ expect(json_response["assets"]["links"].first["id"]).to eq(link.id)
+ expect(json_response["assets"]["links"].first["name"])
+ .to eq("release-18.04.dmg")
+ expect(json_response["assets"]["links"].first["url"])
+ .to eq("https://my-external-hosting.example.com/scrambled-url/app.zip")
+ expect(json_response["assets"]["links"].first["external"])
.to be_truthy
end
- context 'when link is internal' do
+ context "when link is internal" do
let(:url) do
"#{project.web_url}/-/jobs/artifacts/v11.6.0-rc4/download?" \
"job=rspec-mysql+41%2F50"
end
- it 'has external false' do
+ it "has external false" do
get api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(json_response['assets']['links'].first['external'])
+ expect(json_response["assets"]["links"].first["external"])
.to be_falsy
end
end
end
end
- context 'when specified tag is not found in the project' do
- it 'cannot find the release entry' do
+ context "when specified tag is not found in the project" do
+ it "cannot find the release entry" do
get api("/projects/#{project.id}/releases/non_exist_tag", maintainer)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is not a project member' do
- let!(:release) { create(:release, tag: 'v0.1', project: project) }
+ context "when user is not a project member" do
+ let!(:release) { create(:release, tag: "v0.1", project: project) }
- it 'cannot find the project' do
+ it "cannot find the project" do
get api("/projects/#{project.id}/releases/v0.1", non_project_member)
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'allows the request' do
+ it "allows the request" do
get api("/projects/#{project.id}/releases/v0.1", non_project_member)
expect(response).to have_gitlab_http_status(:ok)
@@ -220,166 +220,166 @@ describe API::Releases do
end
end
- describe 'POST /projects/:id/releases' do
+ describe "POST /projects/:id/releases" do
let(:params) do
{
- name: 'New release',
- tag_name: 'v0.1',
- description: 'Super nice release'
+ name: "New release",
+ tag_name: "v0.1",
+ description: "Super nice release",
}
end
- it 'accepts the request' do
+ it "accepts the request" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:created)
end
- it 'creates a new release' do
- expect do
+ it "creates a new release" do
+ expect {
post api("/projects/#{project.id}/releases", maintainer), params: params
- end.to change { Release.count }.by(1)
+ }.to change { Release.count }.by(1)
- expect(project.releases.last.name).to eq('New release')
- expect(project.releases.last.tag).to eq('v0.1')
- expect(project.releases.last.description).to eq('Super nice release')
+ expect(project.releases.last.name).to eq("New release")
+ expect(project.releases.last.tag).to eq("v0.1")
+ expect(project.releases.last.description).to eq("Super nice release")
end
- context 'when description is empty' do
+ context "when description is empty" do
let(:params) do
{
- name: 'New release',
- tag_name: 'v0.1',
- description: ''
+ name: "New release",
+ tag_name: "v0.1",
+ description: "",
}
end
- it 'returns an error as validation failure' do
- expect do
+ it "returns an error as validation failure" do
+ expect {
post api("/projects/#{project.id}/releases", maintainer), params: params
- end.not_to change { Release.count }
+ }.not_to change { Release.count }
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message'])
+ expect(json_response["message"])
.to eq("Validation failed: Description can't be blank")
end
end
- it 'matches response schema' do
+ it "matches response schema" do
post api("/projects/#{project.id}/releases", maintainer), params: params
- expect(response).to match_response_schema('release')
+ expect(response).to match_response_schema("release")
end
- it 'does not create a new tag' do
- expect do
+ it "does not create a new tag" do
+ expect {
post api("/projects/#{project.id}/releases", maintainer), params: params
- end.not_to change { Project.find_by_id(project.id).repository.tag_count }
+ }.not_to change { Project.find_by_id(project.id).repository.tag_count }
end
- context 'when user is a reporter' do
- it 'forbids the request' do
+ context "when user is a reporter" do
+ it "forbids the request" do
post api("/projects/#{project.id}/releases", reporter), params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is not a project member' do
- it 'forbids the request' do
+ context "when user is not a project member" do
+ it "forbids the request" do
post api("/projects/#{project.id}/releases", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'forbids the request' do
+ it "forbids the request" do
post api("/projects/#{project.id}/releases", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when create assets altogether' do
+ context "when create assets altogether" do
let(:base_params) do
{
- name: 'New release',
- tag_name: 'v0.1',
- description: 'Super nice release'
+ name: "New release",
+ tag_name: "v0.1",
+ description: "Super nice release",
}
end
- context 'when create one asset' do
+ context "when create one asset" do
let(:params) do
base_params.merge({
assets: {
- links: [{ name: 'beta', url: 'https://dosuken.example.com/inspection.exe' }]
- }
+ links: [{name: "beta", url: "https://dosuken.example.com/inspection.exe"}],
+ },
})
end
- it 'accepts the request' do
+ it "accepts the request" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:created)
end
- it 'creates an asset with specified parameters' do
+ it "creates an asset with specified parameters" do
post api("/projects/#{project.id}/releases", maintainer), params: params
- expect(json_response['assets']['links'].count).to eq(1)
- expect(json_response['assets']['links'].first['name']).to eq('beta')
- expect(json_response['assets']['links'].first['url'])
- .to eq('https://dosuken.example.com/inspection.exe')
+ expect(json_response["assets"]["links"].count).to eq(1)
+ expect(json_response["assets"]["links"].first["name"]).to eq("beta")
+ expect(json_response["assets"]["links"].first["url"])
+ .to eq("https://dosuken.example.com/inspection.exe")
end
- it 'matches response schema' do
+ it "matches response schema" do
post api("/projects/#{project.id}/releases", maintainer), params: params
- expect(response).to match_response_schema('release')
+ expect(response).to match_response_schema("release")
end
end
- context 'when create two assets' do
+ context "when create two assets" do
let(:params) do
base_params.merge({
assets: {
links: [
- { name: 'alpha', url: 'https://dosuken.example.com/alpha.exe' },
- { name: 'beta', url: 'https://dosuken.example.com/beta.exe' }
- ]
- }
+ {name: "alpha", url: "https://dosuken.example.com/alpha.exe"},
+ {name: "beta", url: "https://dosuken.example.com/beta.exe"},
+ ],
+ },
})
end
- it 'creates two assets with specified parameters' do
+ it "creates two assets with specified parameters" do
post api("/projects/#{project.id}/releases", maintainer), params: params
- expect(json_response['assets']['links'].count).to eq(2)
- expect(json_response['assets']['links'].map { |h| h['name'] })
+ expect(json_response["assets"]["links"].count).to eq(2)
+ expect(json_response["assets"]["links"].map { |h| h["name"] })
.to match_array(%w[alpha beta])
- expect(json_response['assets']['links'].map { |h| h['url'] })
+ expect(json_response["assets"]["links"].map { |h| h["url"] })
.to match_array(%w[https://dosuken.example.com/alpha.exe
https://dosuken.example.com/beta.exe])
end
- context 'when link names are duplicates' do
+ context "when link names are duplicates" do
let(:params) do
base_params.merge({
assets: {
links: [
- { name: 'alpha', url: 'https://dosuken.example.com/alpha.exe' },
- { name: 'alpha', url: 'https://dosuken.example.com/beta.exe' }
- ]
- }
+ {name: "alpha", url: "https://dosuken.example.com/alpha.exe"},
+ {name: "alpha", url: "https://dosuken.example.com/beta.exe"},
+ ],
+ },
})
end
- it 'recognizes as a bad request' do
+ it "recognizes as a bad request" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:bad_request)
@@ -389,71 +389,72 @@ describe API::Releases do
end
end
- context 'when tag does not exist in git repository' do
+ context "when tag does not exist in git repository" do
let(:params) do
{
- name: 'Android ~ Ice Cream Sandwich ~',
+ name: "Android ~ Ice Cream Sandwich ~",
tag_name: tag_name,
description: 'Android 4.0–4.0.4 "Ice Cream Sandwich" is the ninth' \
- 'version of the Android mobile operating system developed' \
- 'by Google.',
- ref: 'master'
+ "version of the Android mobile operating system developed" \
+ "by Google.",
+ ref: "master",
}
end
- let(:tag_name) { 'v4.0' }
+ let(:tag_name) { "v4.0" }
- it 'creates a new tag' do
- expect do
+ it "creates a new tag" do
+ expect {
post api("/projects/#{project.id}/releases", maintainer), params: params
- end.to change { Project.find_by_id(project.id).repository.tag_count }.by(1)
+ }.to change { Project.find_by_id(project.id).repository.tag_count }.by(1)
- expect(project.repository.find_tag('v4.0').dereferenced_target.id)
- .to eq(project.repository.commit('master').id)
+ expect(project.repository.find_tag("v4.0").dereferenced_target.id)
+ .to eq(project.repository.commit("master").id)
end
- it 'creates a new release' do
- expect do
+ it "creates a new release" do
+ expect {
post api("/projects/#{project.id}/releases", maintainer), params: params
- end.to change { Release.count }.by(1)
+ }.to change { Release.count }.by(1)
- expect(project.releases.last.name).to eq('Android ~ Ice Cream Sandwich ~')
- expect(project.releases.last.tag).to eq('v4.0')
+ expect(project.releases.last.name).to eq("Android ~ Ice Cream Sandwich ~")
+ expect(project.releases.last.tag).to eq("v4.0")
expect(project.releases.last.description).to eq(
'Android 4.0–4.0.4 "Ice Cream Sandwich" is the ninth' \
- 'version of the Android mobile operating system developed' \
- 'by Google.')
+ "version of the Android mobile operating system developed" \
+ "by Google."
+ )
end
- context 'when tag name is HEAD' do
- let(:tag_name) { 'HEAD' }
+ context "when tag name is HEAD" do
+ let(:tag_name) { "HEAD" }
- it 'returns an error as failure on tag creation' do
+ it "returns an error as failure on tag creation" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:internal_server_error)
- expect(json_response['message']).to eq('Tag name invalid')
+ expect(json_response["message"]).to eq("Tag name invalid")
end
end
- context 'when tag name is empty' do
- let(:tag_name) { '' }
+ context "when tag name is empty" do
+ let(:tag_name) { "" }
- it 'returns an error as failure on tag creation' do
+ it "returns an error as failure on tag creation" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:internal_server_error)
- expect(json_response['message']).to eq('Tag name invalid')
+ expect(json_response["message"]).to eq("Tag name invalid")
end
end
end
- context 'when release already exists' do
+ context "when release already exists" do
before do
- create(:release, project: project, tag: 'v0.1', name: 'New release')
+ create(:release, project: project, tag: "v0.1", name: "New release")
end
- it 'returns an error as conflicted request' do
+ it "returns an error as conflicted request" do
post api("/projects/#{project.id}/releases", maintainer), params: params
expect(response).to have_gitlab_http_status(:conflict)
@@ -461,94 +462,94 @@ describe API::Releases do
end
end
- describe 'PUT /projects/:id/releases/:tag_name' do
- let(:params) { { description: 'Best release ever!' } }
+ describe "PUT /projects/:id/releases/:tag_name" do
+ let(:params) { {description: "Best release ever!"} }
let!(:release) do
create(:release,
- project: project,
- tag: 'v0.1',
- name: 'New release',
- description: 'Super nice release')
+ project: project,
+ tag: "v0.1",
+ name: "New release",
+ description: "Super nice release")
end
- it 'accepts the request' do
+ it "accepts the request" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
expect(response).to have_gitlab_http_status(:ok)
end
- it 'updates the description' do
+ it "updates the description" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
- expect(project.releases.last.description).to eq('Best release ever!')
+ expect(project.releases.last.description).to eq("Best release ever!")
end
- it 'does not change other attributes' do
+ it "does not change other attributes" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
- expect(project.releases.last.tag).to eq('v0.1')
- expect(project.releases.last.name).to eq('New release')
+ expect(project.releases.last.tag).to eq("v0.1")
+ expect(project.releases.last.name).to eq("New release")
end
- it 'matches response schema' do
+ it "matches response schema" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
- expect(response).to match_response_schema('release')
+ expect(response).to match_response_schema("release")
end
- context 'when user tries to update sha' do
- let(:params) { { sha: 'xxx' } }
+ context "when user tries to update sha" do
+ let(:params) { {sha: "xxx"} }
- it 'does not allow the request' do
+ it "does not allow the request" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when params is empty' do
+ context "when params is empty" do
let(:params) { {} }
- it 'does not allow the request' do
+ it "does not allow the request" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'when there are no corresponding releases' do
+ context "when there are no corresponding releases" do
let!(:release) { }
- it 'forbids the request' do
+ it "forbids the request" do
put api("/projects/#{project.id}/releases/v0.1", maintainer), params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is a reporter' do
- it 'forbids the request' do
+ context "when user is a reporter" do
+ it "forbids the request" do
put api("/projects/#{project.id}/releases/v0.1", reporter), params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is not a project member' do
- it 'forbids the request' do
+ context "when user is not a project member" do
+ it "forbids the request" do
put api("/projects/#{project.id}/releases/v0.1", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'forbids the request' do
+ it "forbids the request" do
put api("/projects/#{project.id}/releases/v0.1", non_project_member),
- params: params
+ params: params
expect(response).to have_gitlab_http_status(:forbidden)
end
@@ -556,68 +557,68 @@ describe API::Releases do
end
end
- describe 'DELETE /projects/:id/releases/:tag_name' do
+ describe "DELETE /projects/:id/releases/:tag_name" do
let!(:release) do
create(:release,
- project: project,
- tag: 'v0.1',
- name: 'New release',
- description: 'Super nice release')
+ project: project,
+ tag: "v0.1",
+ name: "New release",
+ description: "Super nice release")
end
- it 'accepts the request' do
+ it "accepts the request" do
delete api("/projects/#{project.id}/releases/v0.1", maintainer)
expect(response).to have_gitlab_http_status(:ok)
end
- it 'destroys the release' do
- expect do
+ it "destroys the release" do
+ expect {
delete api("/projects/#{project.id}/releases/v0.1", maintainer)
- end.to change { Release.count }.by(-1)
+ }.to change { Release.count }.by(-1)
end
- it 'does not remove a tag in repository' do
- expect do
+ it "does not remove a tag in repository" do
+ expect {
delete api("/projects/#{project.id}/releases/v0.1", maintainer)
- end.not_to change { Project.find_by_id(project.id).repository.tag_count }
+ }.not_to change { Project.find_by_id(project.id).repository.tag_count }
end
- it 'matches response schema' do
+ it "matches response schema" do
delete api("/projects/#{project.id}/releases/v0.1", maintainer)
- expect(response).to match_response_schema('release')
+ expect(response).to match_response_schema("release")
end
- context 'when there are no corresponding releases' do
+ context "when there are no corresponding releases" do
let!(:release) { }
- it 'forbids the request' do
+ it "forbids the request" do
delete api("/projects/#{project.id}/releases/v0.1", maintainer)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is a reporter' do
- it 'forbids the request' do
+ context "when user is a reporter" do
+ it "forbids the request" do
delete api("/projects/#{project.id}/releases/v0.1", reporter)
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'when user is not a project member' do
- it 'forbids the request' do
+ context "when user is not a project member" do
+ it "forbids the request" do
delete api("/projects/#{project.id}/releases/v0.1", non_project_member)
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'when project is public' do
+ context "when project is public" do
let(:project) { create(:project, :repository, :public) }
- it 'forbids the request' do
+ it "forbids the request" do
delete api("/projects/#{project.id}/releases/v0.1", non_project_member)
expect(response).to have_gitlab_http_status(:forbidden)
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index 0adc95cfbeb..0bb0af3f8b3 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -1,5 +1,5 @@
-require 'spec_helper'
-require 'mime/types'
+require "spec_helper"
+require "mime/types"
describe API::Repositories do
include RepoHelpers
@@ -13,8 +13,8 @@ describe API::Repositories do
describe "GET /projects/:id/repository/tree" do
let(:route) { "/projects/#{project.id}/repository/tree" }
- shared_examples_for 'repository tree' do
- it 'returns the repository tree' do
+ shared_examples_for "repository tree" do
+ it "returns the repository tree" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
@@ -22,78 +22,78 @@ describe API::Repositories do
expect(json_response).to be_an Array
first_commit = json_response.first
- expect(first_commit['name']).to eq('bar')
- expect(first_commit['type']).to eq('tree')
- expect(first_commit['mode']).to eq('040000')
+ expect(first_commit["name"]).to eq("bar")
+ expect(first_commit["type"]).to eq("tree")
+ expect(first_commit["mode"]).to eq("040000")
end
- context 'when ref does not exist' do
- it_behaves_like '404 response' do
+ context "when ref does not exist" do
+ it_behaves_like "404 response" do
let(:request) { get api("#{route}?ref=foo", current_user) }
- let(:message) { '404 Tree Not Found' }
+ let(:message) { "404 Tree Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'with recursive=1' do
- it 'returns recursive project paths tree' do
+ context "with recursive=1" do
+ it "returns recursive project paths tree" do
get api("#{route}?recursive=1", current_user)
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(response).to include_pagination_headers
- expect(json_response[4]['name']).to eq('html')
- expect(json_response[4]['path']).to eq('files/html')
- expect(json_response[4]['type']).to eq('tree')
- expect(json_response[4]['mode']).to eq('040000')
+ expect(json_response[4]["name"]).to eq("html")
+ expect(json_response[4]["path"]).to eq("files/html")
+ expect(json_response[4]["type"]).to eq("tree")
+ expect(json_response[4]["mode"]).to eq("040000")
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
- context 'when ref does not exist' do
- it_behaves_like '404 response' do
+ context "when ref does not exist" do
+ it_behaves_like "404 response" do
let(:request) { get api("#{route}?recursive=1&ref=foo", current_user) }
- let(:message) { '404 Tree Not Found' }
+ let(:message) { "404 Tree Not Found" }
end
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository tree' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository tree" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository tree' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository tree" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
@@ -102,55 +102,55 @@ describe API::Repositories do
describe "GET /projects/:id/repository/blobs/:sha" do
let(:route) { "/projects/#{project.id}/repository/blobs/#{sample_blob.oid}" }
- shared_examples_for 'repository blob' do
- it 'returns blob attributes as json' do
+ shared_examples_for "repository blob" do
+ it "returns blob attributes as json" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['size']).to eq(111)
- expect(json_response['encoding']).to eq("base64")
- expect(Base64.decode64(json_response['content']).lines.first).to eq("class Commit\n")
- expect(json_response['sha']).to eq(sample_blob.oid)
+ expect(json_response["size"]).to eq(111)
+ expect(json_response["encoding"]).to eq("base64")
+ expect(Base64.decode64(json_response["content"]).lines.first).to eq("class Commit\n")
+ expect(json_response["sha"]).to eq(sample_blob.oid)
end
- context 'when sha does not exist' do
- it_behaves_like '404 response' do
- let(:request) { get api(route.sub(sample_blob.oid, '123456'), current_user) }
- let(:message) { '404 Blob Not Found' }
+ context "when sha does not exist" do
+ it_behaves_like "404 response" do
+ let(:request) { get api(route.sub(sample_blob.oid, "123456"), current_user) }
+ let(:message) { "404 Blob Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository blob' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository blob" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository blob' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository blob" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
@@ -159,8 +159,8 @@ describe API::Repositories do
describe "GET /projects/:id/repository/blobs/:sha/raw" do
let(:route) { "/projects/#{project.id}/repository/blobs/#{sample_blob.oid}/raw" }
- shared_examples_for 'repository raw blob' do
- it 'returns the repository raw blob' do
+ shared_examples_for "repository raw blob" do
+ it "returns the repository raw blob" do
expect(Gitlab::Workhorse).to receive(:send_git_blob)
get api(route, current_user)
@@ -169,50 +169,50 @@ describe API::Repositories do
expect(headers[Gitlab::Workhorse::DETECT_HEADER]).to eq "true"
end
- it 'sets inline content disposition by default' do
+ it "sets inline content disposition by default" do
get api(route, current_user)
- expect(headers['Content-Disposition']).to eq 'inline'
+ expect(headers["Content-Disposition"]).to eq "inline"
end
- context 'when sha does not exist' do
- it_behaves_like '404 response' do
- let(:request) { get api(route.sub(sample_blob.oid, '123456'), current_user) }
- let(:message) { '404 Blob Not Found' }
+ context "when sha does not exist" do
+ it_behaves_like "404 response" do
+ let(:request) { get api(route.sub(sample_blob.oid, "123456"), current_user) }
+ let(:message) { "404 Blob Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository raw blob' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository raw blob" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository raw blob' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository raw blob" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
@@ -221,179 +221,179 @@ describe API::Repositories do
describe "GET /projects/:id/repository/archive(.:format)?:sha" do
let(:route) { "/projects/#{project.id}/repository/archive" }
- shared_examples_for 'repository archive' do
- it 'returns the repository archive' do
+ shared_examples_for "repository archive" do
+ it "returns the repository archive" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
type, params = workhorse_send_data
- expect(type).to eq('git-archive')
- expect(params['ArchivePath']).to match(/#{project.path}\-[^\.]+\.tar.gz/)
+ expect(type).to eq("git-archive")
+ expect(params["ArchivePath"]).to match(/#{project.path}\-[^\.]+\.tar.gz/)
end
- it 'returns the repository archive archive.zip' do
+ it "returns the repository archive archive.zip" do
get api("/projects/#{project.id}/repository/archive.zip", user)
expect(response).to have_gitlab_http_status(200)
type, params = workhorse_send_data
- expect(type).to eq('git-archive')
- expect(params['ArchivePath']).to match(/#{project.path}\-[^\.]+\.zip/)
+ expect(type).to eq("git-archive")
+ expect(params["ArchivePath"]).to match(/#{project.path}\-[^\.]+\.zip/)
end
- it 'returns the repository archive archive.tar.bz2' do
+ it "returns the repository archive archive.tar.bz2" do
get api("/projects/#{project.id}/repository/archive.tar.bz2", user)
expect(response).to have_gitlab_http_status(200)
type, params = workhorse_send_data
- expect(type).to eq('git-archive')
- expect(params['ArchivePath']).to match(/#{project.path}\-[^\.]+\.tar.bz2/)
+ expect(type).to eq("git-archive")
+ expect(params["ArchivePath"]).to match(/#{project.path}\-[^\.]+\.tar.bz2/)
end
- context 'when sha does not exist' do
- it_behaves_like '404 response' do
+ context "when sha does not exist" do
+ it_behaves_like "404 response" do
let(:request) { get api("#{route}?sha=xxx", current_user) }
- let(:message) { '404 File Not Found' }
+ let(:message) { "404 File Not Found" }
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository archive' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository archive" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository archive' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository archive" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
end
- describe 'GET /projects/:id/repository/compare' do
+ describe "GET /projects/:id/repository/compare" do
let(:route) { "/projects/#{project.id}/repository/compare" }
- shared_examples_for 'repository compare' do
+ shared_examples_for "repository compare" do
it "compares branches" do
expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, {
- straight: false
+ straight: false,
}).and_call_original
- get api(route, current_user), params: { from: 'master', to: 'feature' }
+ get api(route, current_user), params: {from: "master", to: "feature"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_present
- expect(json_response['diffs']).to be_present
+ expect(json_response["commits"]).to be_present
+ expect(json_response["diffs"]).to be_present
end
it "compares branches with explicit merge-base mode" do
expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, {
- straight: false
+ straight: false,
}).and_call_original
- get api(route, current_user), params: { from: 'master', to: 'feature', straight: false }
+ get api(route, current_user), params: {from: "master", to: "feature", straight: false}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_present
- expect(json_response['diffs']).to be_present
+ expect(json_response["commits"]).to be_present
+ expect(json_response["diffs"]).to be_present
end
it "compares branches with explicit straight mode" do
expect(::Gitlab::Git::Compare).to receive(:new).with(anything, anything, anything, {
- straight: true
+ straight: true,
}).and_call_original
- get api(route, current_user), params: { from: 'master', to: 'feature', straight: true }
+ get api(route, current_user), params: {from: "master", to: "feature", straight: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_present
- expect(json_response['diffs']).to be_present
+ expect(json_response["commits"]).to be_present
+ expect(json_response["diffs"]).to be_present
end
it "compares tags" do
- get api(route, current_user), params: { from: 'v1.0.0', to: 'v1.1.0' }
+ get api(route, current_user), params: {from: "v1.0.0", to: "v1.1.0"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_present
- expect(json_response['diffs']).to be_present
+ expect(json_response["commits"]).to be_present
+ expect(json_response["diffs"]).to be_present
end
it "compares commits" do
- get api(route, current_user), params: { from: sample_commit.id, to: sample_commit.parent_id }
+ get api(route, current_user), params: {from: sample_commit.id, to: sample_commit.parent_id}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_empty
- expect(json_response['diffs']).to be_empty
- expect(json_response['compare_same_ref']).to be_falsey
+ expect(json_response["commits"]).to be_empty
+ expect(json_response["diffs"]).to be_empty
+ expect(json_response["compare_same_ref"]).to be_falsey
end
it "compares commits in reverse order" do
- get api(route, current_user), params: { from: sample_commit.parent_id, to: sample_commit.id }
+ get api(route, current_user), params: {from: sample_commit.parent_id, to: sample_commit.id}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_present
- expect(json_response['diffs']).to be_present
+ expect(json_response["commits"]).to be_present
+ expect(json_response["diffs"]).to be_present
end
it "compares same refs" do
- get api(route, current_user), params: { from: 'master', to: 'master' }
+ get api(route, current_user), params: {from: "master", to: "master"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['commits']).to be_empty
- expect(json_response['diffs']).to be_empty
- expect(json_response['compare_same_ref']).to be_truthy
+ expect(json_response["commits"]).to be_empty
+ expect(json_response["diffs"]).to be_empty
+ expect(json_response["compare_same_ref"]).to be_truthy
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository compare' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository compare" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository compare' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository compare" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
end
- describe 'GET /projects/:id/repository/contributors' do
+ describe "GET /projects/:id/repository/contributors" do
let(:route) { "/projects/#{project.id}/repository/contributors" }
- shared_examples_for 'repository contributors' do
- it 'returns valid data' do
+ shared_examples_for "repository contributors" do
+ it "returns valid data" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
@@ -401,147 +401,147 @@ describe API::Repositories do
expect(json_response).to be_an Array
first_contributor = json_response.first
- expect(first_contributor['email']).to eq('tiagonbotelho@hotmail.com')
- expect(first_contributor['name']).to eq('tiagonbotelho')
- expect(first_contributor['commits']).to eq(1)
- expect(first_contributor['additions']).to eq(0)
- expect(first_contributor['deletions']).to eq(0)
+ expect(first_contributor["email"]).to eq("tiagonbotelho@hotmail.com")
+ expect(first_contributor["name"]).to eq("tiagonbotelho")
+ expect(first_contributor["commits"]).to eq(1)
+ expect(first_contributor["additions"]).to eq(0)
+ expect(first_contributor["deletions"]).to eq(0)
end
- context 'using sorting' do
- context 'by commits desc' do
- it 'returns the repository contribuors sorted by commits desc' do
- get api(route, current_user), params: { order_by: 'commits', sort: 'desc' }
+ context "using sorting" do
+ context "by commits desc" do
+ it "returns the repository contribuors sorted by commits desc" do
+ get api(route, current_user), params: {order_by: "commits", sort: "desc"}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('contributors')
- expect(json_response.first['commits']).to be > json_response.last['commits']
+ expect(response).to match_response_schema("contributors")
+ expect(json_response.first["commits"]).to be > json_response.last["commits"]
end
end
- context 'by name desc' do
- it 'returns the repository contribuors sorted by name asc case insensitive' do
- get api(route, current_user), params: { order_by: 'name', sort: 'asc' }
+ context "by name desc" do
+ it "returns the repository contribuors sorted by name asc case insensitive" do
+ get api(route, current_user), params: {order_by: "name", sort: "asc"}
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('contributors')
- expect(json_response.first['name'].downcase).to be < json_response.last['name'].downcase
+ expect(response).to match_response_schema("contributors")
+ expect(json_response.first["name"].downcase).to be < json_response.last["name"].downcase
end
end
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'repository contributors' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "repository contributors" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'repository contributors' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "repository contributors" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
# Regression: https://gitlab.com/gitlab-org/gitlab-ce/issues/45363
- describe 'Links header contains working URLs when no `order_by` nor `sort` is given' do
+ describe "Links header contains working URLs when no `order_by` nor `sort` is given" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
- it 'returns `Link` header that includes URLs with default value for `order_by` & `sort`' do
+ it "returns `Link` header that includes URLs with default value for `order_by` & `sort`" do
get api(route, current_user)
- first_link_url = response.headers['Link'].split(';').first
+ first_link_url = response.headers["Link"].split(";").first
- expect(first_link_url).to include('order_by=commits')
- expect(first_link_url).to include('sort=asc')
+ expect(first_link_url).to include("order_by=commits")
+ expect(first_link_url).to include("sort=asc")
end
end
end
- describe 'GET :id/repository/merge_base' do
+ describe "GET :id/repository/merge_base" do
let(:refs) do
- %w(304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209 570e7b2abdd848b95f2f578043fc23bd6f6fd24d)
+ %w[304d257dcb821665ab5110318fc58a007bd104ed 0031876facac3f2b2702a0e53a26e89939a42209 570e7b2abdd848b95f2f578043fc23bd6f6fd24d]
end
subject(:request) do
- get(api("/projects/#{project.id}/repository/merge_base", current_user), params: { refs: refs })
+ get(api("/projects/#{project.id}/repository/merge_base", current_user), params: {refs: refs})
end
- shared_examples 'merge base' do
- it 'returns the common ancestor' do
+ shared_examples "merge base" do
+ it "returns the common ancestor" do
request
expect(response).to have_gitlab_http_status(:success)
- expect(json_response['id']).to be_present
+ expect(json_response["id"]).to be_present
end
end
- context 'when unauthenticated', 'and project is public' do
- it_behaves_like 'merge base' do
+ context "when unauthenticated", "and project is public" do
+ it_behaves_like "merge base" do
let(:project) { create(:project, :public, :repository) }
let(:current_user) { nil }
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:current_user) { nil }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a developer' do
- it_behaves_like 'merge base' do
+ context "when authenticated", "as a developer" do
+ it_behaves_like "merge base" do
let(:current_user) { user }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:current_user) { guest }
end
end
- context 'when passing refs that do not exist' do
- it_behaves_like '400 response' do
- let(:refs) { %w(304d257dcb821665ab5110318fc58a007bd104ed missing) }
+ context "when passing refs that do not exist" do
+ it_behaves_like "400 response" do
+ let(:refs) { %w[304d257dcb821665ab5110318fc58a007bd104ed missing] }
let(:current_user) { user }
- let(:message) { 'Could not find ref: missing' }
+ let(:message) { "Could not find ref: missing" }
end
end
- context 'when passing refs that do not have a merge base' do
- it_behaves_like '404 response' do
- let(:refs) { ['304d257dcb821665ab5110318fc58a007bd104ed', TestEnv::BRANCH_SHA['orphaned-branch']] }
+ context "when passing refs that do not have a merge base" do
+ it_behaves_like "404 response" do
+ let(:refs) { ["304d257dcb821665ab5110318fc58a007bd104ed", TestEnv::BRANCH_SHA["orphaned-branch"]] }
let(:current_user) { user }
- let(:message) { '404 Merge Base Not Found' }
+ let(:message) { "404 Merge Base Not Found" }
end
end
- context 'when not enough refs are passed' do
- let(:refs) { %w(only-one) }
+ context "when not enough refs are passed" do
+ let(:refs) { %w[only-one] }
let(:current_user) { user }
- it 'renders a bad request error' do
+ it "renders a bad request error" do
request
expect(response).to have_gitlab_http_status(:bad_request)
- expect(json_response['message']).to eq('Provide at least 2 refs')
+ expect(json_response["message"]).to eq("Provide at least 2 refs")
end
end
end
diff --git a/spec/requests/api/resource_label_events_spec.rb b/spec/requests/api/resource_label_events_spec.rb
index 37b46eaeb86..4c8ae3cf6a9 100644
--- a/spec/requests/api/resource_label_events_spec.rb
+++ b/spec/requests/api/resource_label_events_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::ResourceLabelEvents do
set(:user) { create(:user) }
@@ -11,7 +11,7 @@ describe API::ResourceLabelEvents do
project.add_developer(user)
end
- shared_examples 'resource_label_events API' do |parent_type, eventable_type, id_name|
+ shared_examples "resource_label_events API" do |parent_type, eventable_type, id_name|
describe "GET /#{parent_type}/:id/#{eventable_type}/:noteable_id/resource_label_events" do
it "returns an array of resource label events" do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events", user)
@@ -19,7 +19,7 @@ describe API::ResourceLabelEvents do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(event.id)
+ expect(json_response.first["id"]).to eq(event.id)
end
it "returns a 404 error when eventable id not found" do
@@ -42,7 +42,7 @@ describe API::ResourceLabelEvents do
get api("/#{parent_type}/#{parent.id}/#{eventable_type}/#{eventable[id_name]}/resource_label_events/#{event.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(event.id)
+ expect(json_response["id"]).to eq(event.id)
end
it "returns a 404 error if resource label event not found" do
@@ -53,20 +53,20 @@ describe API::ResourceLabelEvents do
end
end
- context 'when eventable is an Issue' do
+ context "when eventable is an Issue" do
let(:issue) { create(:issue, project: project, author: user) }
- it_behaves_like 'resource_label_events API', 'projects', 'issues', 'iid' do
+ it_behaves_like "resource_label_events API", "projects", "issues", "iid" do
let(:parent) { project }
let(:eventable) { issue }
let!(:event) { create(:resource_label_event, issue: issue) }
end
end
- context 'when eventable is a Merge Request' do
+ context "when eventable is a Merge Request" do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, author: user) }
- it_behaves_like 'resource_label_events API', 'projects', 'merge_requests', 'iid' do
+ it_behaves_like "resource_label_events API", "projects", "merge_requests", "iid" do
let(:parent) { project }
let(:eventable) { merge_request }
let!(:event) { create(:resource_label_event, merge_request: merge_request) }
diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb
index 43c06f7c973..7f87a1a4f60 100644
--- a/spec/requests/api/runner_spec.rb
+++ b/spec/requests/api/runner_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Runner, :clean_gitlab_redis_shared_state do
include StubGitlabCalls
include RedisHelpers
- let(:registration_token) { 'abcdefg123456' }
+ let(:registration_token) { "abcdefg123456" }
before do
stub_feature_flags(ci_enable_live_trace: true)
@@ -13,44 +13,44 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
allow_any_instance_of(Ci::Runner).to receive(:cache_attributes)
end
- describe '/api/v4/runners' do
- describe 'POST /api/v4/runners' do
- context 'when no token is provided' do
- it 'returns 400 error' do
- post api('/runners')
+ describe "/api/v4/runners" do
+ describe "POST /api/v4/runners" do
+ context "when no token is provided" do
+ it "returns 400 error" do
+ post api("/runners")
expect(response).to have_gitlab_http_status 400
end
end
- context 'when invalid token is provided' do
- it 'returns 403 error' do
- post api('/runners'), params: { token: 'invalid' }
+ context "when invalid token is provided" do
+ it "returns 403 error" do
+ post api("/runners"), params: {token: "invalid"}
expect(response).to have_gitlab_http_status 403
end
end
- context 'when valid token is provided' do
- it 'creates runner with default values' do
- post api('/runners'), params: { token: registration_token }
+ context "when valid token is provided" do
+ it "creates runner with default values" do
+ post api("/runners"), params: {token: registration_token}
runner = Ci::Runner.first
expect(response).to have_gitlab_http_status 201
- expect(json_response['id']).to eq(runner.id)
- expect(json_response['token']).to eq(runner.token)
+ expect(json_response["id"]).to eq(runner.id)
+ expect(json_response["token"]).to eq(runner.token)
expect(runner.run_untagged).to be true
expect(runner.active).to be true
expect(runner.token).not_to eq(registration_token)
expect(runner).to be_instance_type
end
- context 'when project token is used' do
+ context "when project token is used" do
let(:project) { create(:project) }
- it 'creates project runner' do
- post api('/runners'), params: { token: project.runners_token }
+ it "creates project runner" do
+ post api("/runners"), params: {token: project.runners_token}
expect(response).to have_gitlab_http_status 201
expect(project.runners.size).to eq(1)
@@ -61,11 +61,11 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when group token is used' do
+ context "when group token is used" do
let(:group) { create(:group) }
- it 'creates a group runner' do
- post api('/runners'), params: { token: group.runners_token }
+ it "creates a group runner" do
+ post api("/runners"), params: {token: group.runners_token}
expect(response).to have_http_status 201
expect(group.runners.size).to eq(1)
@@ -77,90 +77,91 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when runner description is provided' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- description: 'server.hostname'
- }
+ context "when runner description is provided" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ description: "server.hostname",
+ }
expect(response).to have_gitlab_http_status 201
- expect(Ci::Runner.first.description).to eq('server.hostname')
+ expect(Ci::Runner.first.description).to eq("server.hostname")
end
end
- context 'when runner tags are provided' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- tag_list: 'tag1, tag2'
- }
+ context "when runner tags are provided" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ tag_list: "tag1, tag2",
+ }
expect(response).to have_gitlab_http_status 201
- expect(Ci::Runner.first.tag_list.sort).to eq(%w(tag1 tag2))
+ expect(Ci::Runner.first.tag_list.sort).to eq(%w[tag1 tag2])
end
end
- context 'when option for running untagged jobs is provided' do
- context 'when tags are provided' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- run_untagged: false,
- tag_list: ['tag']
- }
+ context "when option for running untagged jobs is provided" do
+ context "when tags are provided" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ run_untagged: false,
+ tag_list: ["tag"],
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.run_untagged).to be false
- expect(Ci::Runner.first.tag_list.sort).to eq(['tag'])
+ expect(Ci::Runner.first.tag_list.sort).to eq(["tag"])
end
end
- context 'when tags are not provided' do
- it 'returns 400 error' do
- post api('/runners'), params: {
- token: registration_token,
- run_untagged: false
- }
+ context "when tags are not provided" do
+ it "returns 400 error" do
+ post api("/runners"), params: {
+ token: registration_token,
+ run_untagged: false,
+ }
expect(response).to have_gitlab_http_status 400
- expect(json_response['message']).to include(
- 'tags_list' => ['can not be empty when runner is not allowed to pick untagged jobs'])
+ expect(json_response["message"]).to include(
+ "tags_list" => ["can not be empty when runner is not allowed to pick untagged jobs"]
+ )
end
end
end
- context 'when option for locking Runner is provided' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- locked: true
- }
+ context "when option for locking Runner is provided" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ locked: true,
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.locked).to be true
end
end
- context 'when option for activating a Runner is provided' do
- context 'when active is set to true' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- active: true
- }
+ context "when option for activating a Runner is provided" do
+ context "when active is set to true" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ active: true,
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.active).to be true
end
end
- context 'when active is set to false' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- active: false
- }
+ context "when active is set to false" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ active: false,
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.active).to be false
@@ -168,23 +169,23 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when maximum job timeout is specified' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- maximum_timeout: 9000
- }
+ context "when maximum job timeout is specified" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ maximum_timeout: 9000,
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.maximum_timeout).to eq(9000)
end
- context 'when maximum job timeout is empty' do
- it 'creates runner' do
- post api('/runners'), params: {
- token: registration_token,
- maximum_timeout: ''
- }
+ context "when maximum job timeout is empty" do
+ it "creates runner" do
+ post api("/runners"), params: {
+ token: registration_token,
+ maximum_timeout: "",
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.maximum_timeout).to be_nil
@@ -192,15 +193,15 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- %w(name version revision platform architecture).each do |param|
+ %w[name version revision platform architecture].each do |param|
context "when info parameter '#{param}' info is present" do
let(:value) { "#{param}_value" }
it "updates provided Runner's parameter" do
- post api('/runners'), params: {
- token: registration_token,
- info: { param => value }
- }
+ post api("/runners"), params: {
+ token: registration_token,
+ info: {param => value},
+ }
expect(response).to have_gitlab_http_status 201
expect(Ci::Runner.first.read_attribute(param.to_sym)).to eq(value)
@@ -209,71 +210,71 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it "sets the runner's ip_address" do
- post api('/runners'),
- params: { token: registration_token },
- headers: { 'X-Forwarded-For' => '123.111.123.111' }
+ post api("/runners"),
+ params: {token: registration_token},
+ headers: {"X-Forwarded-For" => "123.111.123.111"}
expect(response).to have_gitlab_http_status 201
- expect(Ci::Runner.first.ip_address).to eq('123.111.123.111')
+ expect(Ci::Runner.first.ip_address).to eq("123.111.123.111")
end
end
- describe 'DELETE /api/v4/runners' do
- context 'when no token is provided' do
- it 'returns 400 error' do
- delete api('/runners')
+ describe "DELETE /api/v4/runners" do
+ context "when no token is provided" do
+ it "returns 400 error" do
+ delete api("/runners")
expect(response).to have_gitlab_http_status 400
end
end
- context 'when invalid token is provided' do
- it 'returns 403 error' do
- delete api('/runners'), params: { token: 'invalid' }
+ context "when invalid token is provided" do
+ it "returns 403 error" do
+ delete api("/runners"), params: {token: "invalid"}
expect(response).to have_gitlab_http_status 403
end
end
- context 'when valid token is provided' do
+ context "when valid token is provided" do
let(:runner) { create(:ci_runner) }
- it 'deletes Runner' do
- delete api('/runners'), params: { token: runner.token }
+ it "deletes Runner" do
+ delete api("/runners"), params: {token: runner.token}
expect(response).to have_gitlab_http_status 204
expect(Ci::Runner.count).to eq(0)
end
- it_behaves_like '412 response' do
- let(:request) { api('/runners') }
- let(:params) { { token: runner.token } }
+ it_behaves_like "412 response" do
+ let(:request) { api("/runners") }
+ let(:params) { {token: runner.token} }
end
end
end
- describe 'POST /api/v4/runners/verify' do
+ describe "POST /api/v4/runners/verify" do
let(:runner) { create(:ci_runner) }
- context 'when no token is provided' do
- it 'returns 400 error' do
- post api('/runners/verify')
+ context "when no token is provided" do
+ it "returns 400 error" do
+ post api("/runners/verify")
expect(response).to have_gitlab_http_status :bad_request
end
end
- context 'when invalid token is provided' do
- it 'returns 403 error' do
- post api('/runners/verify'), params: { token: 'invalid-token' }
+ context "when invalid token is provided" do
+ it "returns 403 error" do
+ post api("/runners/verify"), params: {token: "invalid-token"}
expect(response).to have_gitlab_http_status 403
end
end
- context 'when valid token is provided' do
- it 'verifies Runner credentials' do
- post api('/runners/verify'), params: { token: runner.token }
+ context "when valid token is provided" do
+ it "verifies Runner credentials" do
+ post api("/runners/verify"), params: {token: runner.token}
expect(response).to have_gitlab_http_status 200
end
@@ -281,309 +282,309 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- describe '/api/v4/jobs' do
+ describe "/api/v4/jobs" do
let(:project) { create(:project, shared_runners_enabled: false) }
- let(:pipeline) { create(:ci_pipeline_without_jobs, project: project, ref: 'master') }
+ let(:pipeline) { create(:ci_pipeline_without_jobs, project: project, ref: "master") }
let(:runner) { create(:ci_runner, :project, projects: [project]) }
let(:job) do
create(:ci_build, :artifacts, :extended_options,
- pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0)
+ pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0)
end
- describe 'POST /api/v4/jobs/request' do
+ describe "POST /api/v4/jobs/request" do
let!(:last_update) {}
let!(:new_update) { }
- let(:user_agent) { 'gitlab-runner 9.0.0 (9-0-stable; go1.7.4; linux/amd64)' }
+ let(:user_agent) { "gitlab-runner 9.0.0 (9-0-stable; go1.7.4; linux/amd64)" }
before do
job
stub_container_registry_config(enabled: false)
end
- shared_examples 'no jobs available' do
+ shared_examples "no jobs available" do
before do
request_job
end
- context 'when runner sends version in User-Agent' do
- context 'for stable version' do
- it 'gives 204 and set X-GitLab-Last-Update' do
+ context "when runner sends version in User-Agent" do
+ context "for stable version" do
+ it "gives 204 and set X-GitLab-Last-Update" do
expect(response).to have_gitlab_http_status(204)
- expect(response.header).to have_key('X-GitLab-Last-Update')
+ expect(response.header).to have_key("X-GitLab-Last-Update")
end
end
- context 'when last_update is up-to-date' do
+ context "when last_update is up-to-date" do
let(:last_update) { runner.ensure_runner_queue_value }
- it 'gives 204 and set the same X-GitLab-Last-Update' do
+ it "gives 204 and set the same X-GitLab-Last-Update" do
expect(response).to have_gitlab_http_status(204)
- expect(response.header['X-GitLab-Last-Update']).to eq(last_update)
+ expect(response.header["X-GitLab-Last-Update"]).to eq(last_update)
end
end
- context 'when last_update is outdated' do
+ context "when last_update is outdated" do
let(:last_update) { runner.ensure_runner_queue_value }
let(:new_update) { runner.tick_runner_queue }
- it 'gives 204 and set a new X-GitLab-Last-Update' do
+ it "gives 204 and set a new X-GitLab-Last-Update" do
expect(response).to have_gitlab_http_status(204)
- expect(response.header['X-GitLab-Last-Update']).to eq(new_update)
+ expect(response.header["X-GitLab-Last-Update"]).to eq(new_update)
end
end
- context 'when beta version is sent' do
- let(:user_agent) { 'gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)' }
+ context "when beta version is sent" do
+ let(:user_agent) { "gitlab-runner 9.0.0~beta.167.g2b2bacc (master; go1.7.4; linux/amd64)" }
it { expect(response).to have_gitlab_http_status(204) }
end
- context 'when pre-9-0 version is sent' do
- let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)' }
+ context "when pre-9-0 version is sent" do
+ let(:user_agent) { "gitlab-ci-multi-runner 1.6.0 (1-6-stable; go1.6.3; linux/amd64)" }
it { expect(response).to have_gitlab_http_status(204) }
end
- context 'when pre-9-0 beta version is sent' do
- let(:user_agent) { 'gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)' }
+ context "when pre-9-0 beta version is sent" do
+ let(:user_agent) { "gitlab-ci-multi-runner 1.6.0~beta.167.g2b2bacc (master; go1.6.3; linux/amd64)" }
it { expect(response).to have_gitlab_http_status(204) }
end
end
end
- context 'when no token is provided' do
- it 'returns 400 error' do
- post api('/jobs/request')
+ context "when no token is provided" do
+ it "returns 400 error" do
+ post api("/jobs/request")
expect(response).to have_gitlab_http_status 400
end
end
- context 'when invalid token is provided' do
- it 'returns 403 error' do
- post api('/jobs/request'), params: { token: 'invalid' }
+ context "when invalid token is provided" do
+ it "returns 403 error" do
+ post api("/jobs/request"), params: {token: "invalid"}
expect(response).to have_gitlab_http_status 403
end
end
- context 'when valid token is provided' do
- context 'when Runner is not active' do
+ context "when valid token is provided" do
+ context "when Runner is not active" do
let(:runner) { create(:ci_runner, :inactive) }
let(:update_value) { runner.ensure_runner_queue_value }
- it 'returns 204 error' do
+ it "returns 204 error" do
request_job
expect(response).to have_gitlab_http_status(204)
- expect(response.header['X-GitLab-Last-Update']).to eq(update_value)
+ expect(response.header["X-GitLab-Last-Update"]).to eq(update_value)
end
end
- context 'when jobs are finished' do
+ context "when jobs are finished" do
before do
job.success
end
- it_behaves_like 'no jobs available'
+ it_behaves_like "no jobs available"
end
- context 'when other projects have pending jobs' do
+ context "when other projects have pending jobs" do
before do
job.success
create(:ci_build, :pending)
end
- it_behaves_like 'no jobs available'
+ it_behaves_like "no jobs available"
end
- context 'when shared runner requests job for project without shared_runners_enabled' do
+ context "when shared runner requests job for project without shared_runners_enabled" do
let(:runner) { create(:ci_runner, :instance) }
- it_behaves_like 'no jobs available'
+ it_behaves_like "no jobs available"
end
- context 'when there is a pending job' do
+ context "when there is a pending job" do
let(:expected_job_info) do
- { 'name' => job.name,
- 'stage' => job.stage,
- 'project_id' => job.project.id,
- 'project_name' => job.project.name }
+ {"name" => job.name,
+ "stage" => job.stage,
+ "project_id" => job.project.id,
+ "project_name" => job.project.name,}
end
let(:expected_git_info) do
- { 'repo_url' => job.repo_url,
- 'ref' => job.ref,
- 'sha' => job.sha,
- 'before_sha' => job.before_sha,
- 'ref_type' => 'branch',
- 'refspecs' => %w[+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*],
- 'depth' => 0 }
+ {"repo_url" => job.repo_url,
+ "ref" => job.ref,
+ "sha" => job.sha,
+ "before_sha" => job.before_sha,
+ "ref_type" => "branch",
+ "refspecs" => %w[+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*],
+ "depth" => 0,}
end
let(:expected_steps) do
- [{ 'name' => 'script',
- 'script' => %w(echo),
- 'timeout' => job.metadata_timeout,
- 'when' => 'on_success',
- 'allow_failure' => false },
- { 'name' => 'after_script',
- 'script' => %w(ls date),
- 'timeout' => job.metadata_timeout,
- 'when' => 'always',
- 'allow_failure' => true }]
+ [{"name" => "script",
+ "script" => %w[echo],
+ "timeout" => job.metadata_timeout,
+ "when" => "on_success",
+ "allow_failure" => false,},
+ {"name" => "after_script",
+ "script" => %w[ls date],
+ "timeout" => job.metadata_timeout,
+ "when" => "always",
+ "allow_failure" => true,},]
end
let(:expected_variables) do
- [{ 'key' => 'CI_JOB_NAME', 'value' => 'spinach', 'public' => true, 'masked' => false },
- { 'key' => 'CI_JOB_STAGE', 'value' => 'test', 'public' => true, 'masked' => false },
- { 'key' => 'DB_NAME', 'value' => 'postgres', 'public' => true, 'masked' => false }]
+ [{"key" => "CI_JOB_NAME", "value" => "spinach", "public" => true, "masked" => false},
+ {"key" => "CI_JOB_STAGE", "value" => "test", "public" => true, "masked" => false},
+ {"key" => "DB_NAME", "value" => "postgres", "public" => true, "masked" => false},]
end
let(:expected_artifacts) do
- [{ 'name' => 'artifacts_file',
- 'untracked' => false,
- 'paths' => %w(out/),
- 'when' => 'always',
- 'expire_in' => '7d',
- "artifact_type" => "archive",
- "artifact_format" => "zip" }]
+ [{"name" => "artifacts_file",
+ "untracked" => false,
+ "paths" => %w[out/],
+ "when" => "always",
+ "expire_in" => "7d",
+ "artifact_type" => "archive",
+ "artifact_format" => "zip",}]
end
let(:expected_cache) do
- [{ 'key' => 'cache_key',
- 'untracked' => false,
- 'paths' => ['vendor/*'],
- 'policy' => 'pull-push' }]
+ [{"key" => "cache_key",
+ "untracked" => false,
+ "paths" => ["vendor/*"],
+ "policy" => "pull-push",}]
end
- let(:expected_features) { { 'trace_sections' => true } }
+ let(:expected_features) { {"trace_sections" => true} }
- it 'picks a job' do
- request_job info: { platform: :darwin }
+ it "picks a job" do
+ request_job info: {platform: :darwin}
expect(response).to have_gitlab_http_status(201)
- expect(response.headers).not_to have_key('X-GitLab-Last-Update')
- expect(runner.reload.platform).to eq('darwin')
- expect(json_response['id']).to eq(job.id)
- expect(json_response['token']).to eq(job.token)
- expect(json_response['job_info']).to eq(expected_job_info)
- expect(json_response['git_info']).to eq(expected_git_info)
- expect(json_response['image']).to eq({ 'name' => 'ruby:2.1', 'entrypoint' => '/bin/sh' })
- expect(json_response['services']).to eq([{ 'name' => 'postgres', 'entrypoint' => nil,
- 'alias' => nil, 'command' => nil },
- { 'name' => 'docker:stable-dind', 'entrypoint' => '/bin/sh',
- 'alias' => 'docker', 'command' => 'sleep 30' }])
- expect(json_response['steps']).to eq(expected_steps)
- expect(json_response['artifacts']).to eq(expected_artifacts)
- expect(json_response['cache']).to eq(expected_cache)
- expect(json_response['variables']).to include(*expected_variables)
- expect(json_response['features']).to eq(expected_features)
- end
-
- context 'when job is made for tag' do
- let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
-
- it 'sets branch as ref_type' do
+ expect(response.headers).not_to have_key("X-GitLab-Last-Update")
+ expect(runner.reload.platform).to eq("darwin")
+ expect(json_response["id"]).to eq(job.id)
+ expect(json_response["token"]).to eq(job.token)
+ expect(json_response["job_info"]).to eq(expected_job_info)
+ expect(json_response["git_info"]).to eq(expected_git_info)
+ expect(json_response["image"]).to eq({"name" => "ruby:2.1", "entrypoint" => "/bin/sh"})
+ expect(json_response["services"]).to eq([{"name" => "postgres", "entrypoint" => nil,
+ "alias" => nil, "command" => nil,},
+ {"name" => "docker:stable-dind", "entrypoint" => "/bin/sh",
+ "alias" => "docker", "command" => "sleep 30",},])
+ expect(json_response["steps"]).to eq(expected_steps)
+ expect(json_response["artifacts"]).to eq(expected_artifacts)
+ expect(json_response["cache"]).to eq(expected_cache)
+ expect(json_response["variables"]).to include(*expected_variables)
+ expect(json_response["features"]).to eq(expected_features)
+ end
+
+ context "when job is made for tag" do
+ let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0) }
+
+ it "sets branch as ref_type" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['ref_type']).to eq('tag')
+ expect(json_response["git_info"]["ref_type"]).to eq("tag")
end
- context 'when GIT_DEPTH is specified' do
+ context "when GIT_DEPTH is specified" do
before do
- create(:ci_pipeline_variable, key: 'GIT_DEPTH', value: 1, pipeline: pipeline)
+ create(:ci_pipeline_variable, key: "GIT_DEPTH", value: 1, pipeline: pipeline)
end
- it 'specifies refspecs' do
+ it "specifies refspecs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['refspecs']).to include("+refs/tags/#{job.ref}:refs/tags/#{job.ref}")
+ expect(json_response["git_info"]["refspecs"]).to include("+refs/tags/#{job.ref}:refs/tags/#{job.ref}")
end
end
- context 'when GIT_DEPTH is not specified' do
- it 'specifies refspecs' do
+ context "when GIT_DEPTH is not specified" do
+ it "specifies refspecs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['refspecs'])
- .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*')
+ expect(json_response["git_info"]["refspecs"])
+ .to contain_exactly("+refs/tags/*:refs/tags/*", "+refs/heads/*:refs/remotes/origin/*")
end
end
end
- context 'when job is made for branch' do
- it 'sets tag as ref_type' do
+ context "when job is made for branch" do
+ it "sets tag as ref_type" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['ref_type']).to eq('branch')
+ expect(json_response["git_info"]["ref_type"]).to eq("branch")
end
- context 'when GIT_DEPTH is specified' do
+ context "when GIT_DEPTH is specified" do
before do
- create(:ci_pipeline_variable, key: 'GIT_DEPTH', value: 1, pipeline: pipeline)
+ create(:ci_pipeline_variable, key: "GIT_DEPTH", value: 1, pipeline: pipeline)
end
- it 'specifies refspecs' do
+ it "specifies refspecs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['refspecs']).to include("+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}")
+ expect(json_response["git_info"]["refspecs"]).to include("+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}")
end
end
- context 'when GIT_DEPTH is not specified' do
- it 'specifies refspecs' do
+ context "when GIT_DEPTH is not specified" do
+ it "specifies refspecs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['refspecs'])
- .to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*')
+ expect(json_response["git_info"]["refspecs"])
+ .to contain_exactly("+refs/tags/*:refs/tags/*", "+refs/heads/*:refs/remotes/origin/*")
end
end
end
- context 'when job is made for merge request' do
- let(:pipeline) { create(:ci_pipeline_without_jobs, source: :merge_request, project: project, ref: 'feature', merge_request: merge_request) }
- let!(:job) { create(:ci_build, pipeline: pipeline, name: 'spinach', ref: 'feature', stage: 'test', stage_idx: 0) }
+ context "when job is made for merge request" do
+ let(:pipeline) { create(:ci_pipeline_without_jobs, source: :merge_request, project: project, ref: "feature", merge_request: merge_request) }
+ let!(:job) { create(:ci_build, pipeline: pipeline, name: "spinach", ref: "feature", stage: "test", stage_idx: 0) }
let(:merge_request) { create(:merge_request) }
- it 'sets branch as ref_type' do
+ it "sets branch as ref_type" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['ref_type']).to eq('branch')
+ expect(json_response["git_info"]["ref_type"]).to eq("branch")
end
- context 'when GIT_DEPTH is specified' do
+ context "when GIT_DEPTH is specified" do
before do
- create(:ci_pipeline_variable, key: 'GIT_DEPTH', value: 1, pipeline: pipeline)
+ create(:ci_pipeline_variable, key: "GIT_DEPTH", value: 1, pipeline: pipeline)
end
- it 'returns the overwritten git depth for merge request refspecs' do
+ it "returns the overwritten git depth for merge request refspecs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['git_info']['depth']).to eq(1)
+ expect(json_response["git_info"]["depth"]).to eq(1)
end
end
end
- it 'updates runner info' do
+ it "updates runner info" do
expect { request_job }.to change { runner.reload.contacted_at }
end
- %w(version revision platform architecture).each do |param|
+ %w[version revision platform architecture].each do |param|
context "when info parameter '#{param}' is present" do
let(:value) { "#{param}_value" }
it "updates provided Runner's parameter" do
- request_job info: { param => value }
+ request_job info: {param => value}
expect(response).to have_gitlab_http_status(201)
expect(runner.reload.read_attribute(param.to_sym)).to eq(value)
@@ -592,86 +593,88 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
it "sets the runner's ip_address" do
- post api('/jobs/request'),
- params: { token: runner.token },
- headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222' }
+ post api("/jobs/request"),
+ params: {token: runner.token},
+ headers: {"User-Agent" => user_agent, "X-Forwarded-For" => "123.222.123.222"}
expect(response).to have_gitlab_http_status 201
- expect(runner.reload.ip_address).to eq('123.222.123.222')
+ expect(runner.reload.ip_address).to eq("123.222.123.222")
end
it "handles multiple X-Forwarded-For addresses" do
- post api('/jobs/request'),
- params: { token: runner.token },
- headers: { 'User-Agent' => user_agent, 'X-Forwarded-For' => '123.222.123.222, 127.0.0.1' }
+ post api("/jobs/request"),
+ params: {token: runner.token},
+ headers: {"User-Agent" => user_agent, "X-Forwarded-For" => "123.222.123.222, 127.0.0.1"}
expect(response).to have_gitlab_http_status 201
- expect(runner.reload.ip_address).to eq('123.222.123.222')
+ expect(runner.reload.ip_address).to eq("123.222.123.222")
end
- context 'when concurrently updating a job' do
+ context "when concurrently updating a job" do
before do
expect_any_instance_of(Ci::Build).to receive(:run!)
- .and_raise(ActiveRecord::StaleObjectError.new(nil, nil))
+ .and_raise(ActiveRecord::StaleObjectError.new(nil, nil))
end
- it 'returns a conflict' do
+ it "returns a conflict" do
request_job
expect(response).to have_gitlab_http_status(409)
- expect(response.headers).not_to have_key('X-GitLab-Last-Update')
+ expect(response.headers).not_to have_key("X-GitLab-Last-Update")
end
end
- context 'when project and pipeline have multiple jobs' do
- let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
- let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
- let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) }
+ context "when project and pipeline have multiple jobs" do
+ let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0) }
+ let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: "rubocop", stage: "test", stage_idx: 0) }
+ let!(:test_job) { create(:ci_build, pipeline: pipeline, name: "deploy", stage: "deploy", stage_idx: 1) }
before do
job.success
job2.success
end
- it 'returns dependent jobs' do
+ it "returns dependent jobs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(test_job.id)
- expect(json_response['dependencies'].count).to eq(2)
- expect(json_response['dependencies']).to include(
- { 'id' => job.id, 'name' => job.name, 'token' => job.token },
- { 'id' => job2.id, 'name' => job2.name, 'token' => job2.token })
+ expect(json_response["id"]).to eq(test_job.id)
+ expect(json_response["dependencies"].count).to eq(2)
+ expect(json_response["dependencies"]).to include(
+ {"id" => job.id, "name" => job.name, "token" => job.token},
+ {"id" => job2.id, "name" => job2.name, "token" => job2.token}
+ )
end
end
- context 'when pipeline have jobs with artifacts' do
- let!(:job) { create(:ci_build, :tag, :artifacts, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
- let!(:test_job) { create(:ci_build, pipeline: pipeline, name: 'deploy', stage: 'deploy', stage_idx: 1) }
+ context "when pipeline have jobs with artifacts" do
+ let!(:job) { create(:ci_build, :tag, :artifacts, pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0) }
+ let!(:test_job) { create(:ci_build, pipeline: pipeline, name: "deploy", stage: "deploy", stage_idx: 1) }
before do
job.success
end
- it 'returns dependent jobs' do
+ it "returns dependent jobs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(test_job.id)
- expect(json_response['dependencies'].count).to eq(1)
- expect(json_response['dependencies']).to include(
- { 'id' => job.id, 'name' => job.name, 'token' => job.token,
- 'artifacts_file' => { 'filename' => 'ci_build_artifacts.zip', 'size' => 106365 } })
+ expect(json_response["id"]).to eq(test_job.id)
+ expect(json_response["dependencies"].count).to eq(1)
+ expect(json_response["dependencies"]).to include(
+ {"id" => job.id, "name" => job.name, "token" => job.token,
+ "artifacts_file" => {"filename" => "ci_build_artifacts.zip", "size" => 106365},}
+ )
end
end
- context 'when explicit dependencies are defined' do
- let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
- let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
+ context "when explicit dependencies are defined" do
+ let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0) }
+ let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: "rubocop", stage: "test", stage_idx: 0) }
let!(:test_job) do
- create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'deploy',
- stage: 'deploy', stage_idx: 1,
- options: { script: ['bash'], dependencies: [job2.name] })
+ create(:ci_build, pipeline: pipeline, token: "test-job-token", name: "deploy",
+ stage: "deploy", stage_idx: 1,
+ options: {script: ["bash"], dependencies: [job2.name]})
end
before do
@@ -679,23 +682,23 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
job2.success
end
- it 'returns dependent jobs' do
+ it "returns dependent jobs" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(test_job.id)
- expect(json_response['dependencies'].count).to eq(1)
- expect(json_response['dependencies'][0]).to include('id' => job2.id, 'name' => job2.name, 'token' => job2.token)
+ expect(json_response["id"]).to eq(test_job.id)
+ expect(json_response["dependencies"].count).to eq(1)
+ expect(json_response["dependencies"][0]).to include("id" => job2.id, "name" => job2.name, "token" => job2.token)
end
end
- context 'when dependencies is an empty array' do
- let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: 'spinach', stage: 'test', stage_idx: 0) }
- let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: 'rubocop', stage: 'test', stage_idx: 0) }
+ context "when dependencies is an empty array" do
+ let!(:job) { create(:ci_build, :tag, pipeline: pipeline, name: "spinach", stage: "test", stage_idx: 0) }
+ let!(:job2) { create(:ci_build, :tag, pipeline: pipeline, name: "rubocop", stage: "test", stage_idx: 0) }
let!(:empty_dependencies_job) do
- create(:ci_build, pipeline: pipeline, token: 'test-job-token', name: 'empty_dependencies_job',
- stage: 'deploy', stage_idx: 1,
- options: { script: ['bash'], dependencies: [] })
+ create(:ci_build, pipeline: pipeline, token: "test-job-token", name: "empty_dependencies_job",
+ stage: "deploy", stage_idx: 1,
+ options: {script: ["bash"], dependencies: []})
end
before do
@@ -703,150 +706,150 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
job2.success
end
- it 'returns an empty array' do
+ it "returns an empty array" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(empty_dependencies_job.id)
- expect(json_response['dependencies'].count).to eq(0)
+ expect(json_response["id"]).to eq(empty_dependencies_job.id)
+ expect(json_response["dependencies"].count).to eq(0)
end
end
- context 'when job has no tags' do
+ context "when job has no tags" do
before do
job.update(tags: [])
end
- context 'when runner is allowed to pick untagged jobs' do
+ context "when runner is allowed to pick untagged jobs" do
before do
runner.update_column(:run_untagged, true)
end
- it 'picks job' do
+ it "picks job" do
request_job
expect(response).to have_gitlab_http_status 201
end
end
- context 'when runner is not allowed to pick untagged jobs' do
+ context "when runner is not allowed to pick untagged jobs" do
before do
runner.update_column(:run_untagged, false)
end
- it_behaves_like 'no jobs available'
+ it_behaves_like "no jobs available"
end
end
- context 'when triggered job is available' do
+ context "when triggered job is available" do
let(:expected_variables) do
- [{ 'key' => 'CI_JOB_NAME', 'value' => 'spinach', 'public' => true, 'masked' => false },
- { 'key' => 'CI_JOB_STAGE', 'value' => 'test', 'public' => true, 'masked' => false },
- { 'key' => 'CI_PIPELINE_TRIGGERED', 'value' => 'true', 'public' => true, 'masked' => false },
- { 'key' => 'DB_NAME', 'value' => 'postgres', 'public' => true, 'masked' => false },
- { 'key' => 'SECRET_KEY', 'value' => 'secret_value', 'public' => false, 'masked' => false },
- { 'key' => 'TRIGGER_KEY_1', 'value' => 'TRIGGER_VALUE_1', 'public' => false, 'masked' => false }]
+ [{"key" => "CI_JOB_NAME", "value" => "spinach", "public" => true, "masked" => false},
+ {"key" => "CI_JOB_STAGE", "value" => "test", "public" => true, "masked" => false},
+ {"key" => "CI_PIPELINE_TRIGGERED", "value" => "true", "public" => true, "masked" => false},
+ {"key" => "DB_NAME", "value" => "postgres", "public" => true, "masked" => false},
+ {"key" => "SECRET_KEY", "value" => "secret_value", "public" => false, "masked" => false},
+ {"key" => "TRIGGER_KEY_1", "value" => "TRIGGER_VALUE_1", "public" => false, "masked" => false},]
end
let(:trigger) { create(:ci_trigger, project: project) }
let!(:trigger_request) { create(:ci_trigger_request, pipeline: pipeline, builds: [job], trigger: trigger) }
before do
- project.variables << Ci::Variable.new(key: 'SECRET_KEY', value: 'secret_value')
+ project.variables << Ci::Variable.new(key: "SECRET_KEY", value: "secret_value")
end
- shared_examples 'expected variables behavior' do
- it 'returns variables for triggers' do
+ shared_examples "expected variables behavior" do
+ it "returns variables for triggers" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['variables']).to include(*expected_variables)
+ expect(json_response["variables"]).to include(*expected_variables)
end
end
- context 'when variables are stored in trigger_request' do
+ context "when variables are stored in trigger_request" do
before do
- trigger_request.update_attribute(:variables, { TRIGGER_KEY_1: 'TRIGGER_VALUE_1' } )
+ trigger_request.update_attribute(:variables, {TRIGGER_KEY_1: "TRIGGER_VALUE_1"})
end
- it_behaves_like 'expected variables behavior'
+ it_behaves_like "expected variables behavior"
end
- context 'when variables are stored in pipeline_variables' do
+ context "when variables are stored in pipeline_variables" do
before do
- create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: 'TRIGGER_VALUE_1')
+ create(:ci_pipeline_variable, pipeline: pipeline, key: :TRIGGER_KEY_1, value: "TRIGGER_VALUE_1")
end
- it_behaves_like 'expected variables behavior'
+ it_behaves_like "expected variables behavior"
end
end
- describe 'registry credentials support' do
- let(:registry_url) { 'registry.example.com:5005' }
+ describe "registry credentials support" do
+ let(:registry_url) { "registry.example.com:5005" }
let(:registry_credentials) do
- { 'type' => 'registry',
- 'url' => registry_url,
- 'username' => 'gitlab-ci-token',
- 'password' => job.token }
+ {"type" => "registry",
+ "url" => registry_url,
+ "username" => "gitlab-ci-token",
+ "password" => job.token,}
end
- context 'when registry is enabled' do
+ context "when registry is enabled" do
before do
stub_container_registry_config(enabled: true, host_port: registry_url)
end
- it 'sends registry credentials key' do
+ it "sends registry credentials key" do
request_job
- expect(json_response).to have_key('credentials')
- expect(json_response['credentials']).to include(registry_credentials)
+ expect(json_response).to have_key("credentials")
+ expect(json_response["credentials"]).to include(registry_credentials)
end
end
- context 'when registry is disabled' do
+ context "when registry is disabled" do
before do
stub_container_registry_config(enabled: false, host_port: registry_url)
end
- it 'does not send registry credentials' do
+ it "does not send registry credentials" do
request_job
- expect(json_response).to have_key('credentials')
- expect(json_response['credentials']).not_to include(registry_credentials)
+ expect(json_response).to have_key("credentials")
+ expect(json_response["credentials"]).not_to include(registry_credentials)
end
end
end
- describe 'timeout support' do
- context 'when project specifies job timeout' do
+ describe "timeout support" do
+ context "when project specifies job timeout" do
let(:project) { create(:project, shared_runners_enabled: false, build_timeout: 1234) }
- it 'contains info about timeout taken from project' do
+ it "contains info about timeout taken from project" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['runner_info']).to include({ 'timeout' => 1234 })
+ expect(json_response["runner_info"]).to include({"timeout" => 1234})
end
- context 'when runner specifies lower timeout' do
+ context "when runner specifies lower timeout" do
let(:runner) { create(:ci_runner, :project, maximum_timeout: 1000, projects: [project]) }
- it 'contains info about timeout overridden by runner' do
+ it "contains info about timeout overridden by runner" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['runner_info']).to include({ 'timeout' => 1000 })
+ expect(json_response["runner_info"]).to include({"timeout" => 1000})
end
end
- context 'when runner specifies bigger timeout' do
+ context "when runner specifies bigger timeout" do
let(:runner) { create(:ci_runner, :project, maximum_timeout: 2000, projects: [project]) }
- it 'contains info about timeout not overridden by runner' do
+ it "contains info about timeout not overridden by runner" do
request_job
expect(response).to have_gitlab_http_status(201)
- expect(json_response['runner_info']).to include({ 'timeout' => 1234 })
+ expect(json_response["runner_info"]).to include({"timeout" => 1234})
end
end
end
@@ -855,64 +858,64 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
def request_job(token = runner.token, **params)
new_params = params.merge(token: token, last_update: last_update)
- post api('/jobs/request'), params: new_params, headers: { 'User-Agent' => user_agent }
+ post api("/jobs/request"), params: new_params, headers: {"User-Agent" => user_agent}
end
end
end
- describe 'PUT /api/v4/jobs/:id' do
+ describe "PUT /api/v4/jobs/:id" do
let(:job) { create(:ci_build, :pending, :trace_live, pipeline: pipeline, runner_id: runner.id) }
before do
job.run!
end
- context 'when status is given' do
- it 'mark job as succeeded' do
- update_job(state: 'success')
+ context "when status is given" do
+ it "mark job as succeeded" do
+ update_job(state: "success")
job.reload
expect(job).to be_success
end
- it 'mark job as failed' do
- update_job(state: 'failed')
+ it "mark job as failed" do
+ update_job(state: "failed")
job.reload
expect(job).to be_failed
expect(job).to be_unknown_failure
end
- context 'when failure_reason is script_failure' do
+ context "when failure_reason is script_failure" do
before do
- update_job(state: 'failed', failure_reason: 'script_failure')
+ update_job(state: "failed", failure_reason: "script_failure")
job.reload
end
it { expect(job).to be_script_failure }
end
- context 'when failure_reason is runner_system_failure' do
+ context "when failure_reason is runner_system_failure" do
before do
- update_job(state: 'failed', failure_reason: 'runner_system_failure')
+ update_job(state: "failed", failure_reason: "runner_system_failure")
job.reload
end
it { expect(job).to be_runner_system_failure }
end
- context 'when failure_reason is unrecognized value' do
+ context "when failure_reason is unrecognized value" do
before do
- update_job(state: 'failed', failure_reason: 'what_is_this')
+ update_job(state: "failed", failure_reason: "what_is_this")
job.reload
end
it { expect(job).to be_unknown_failure }
end
- context 'when failure_reason is job_execution_timeout' do
+ context "when failure_reason is job_execution_timeout" do
before do
- update_job(state: 'failed', failure_reason: 'job_execution_timeout')
+ update_job(state: "failed", failure_reason: "job_execution_timeout")
job.reload
end
@@ -920,76 +923,76 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when trace is given' do
- it 'creates a trace artifact' do
+ context "when trace is given" do
+ it "creates a trace artifact" do
allow(BuildFinishedWorker).to receive(:perform_async).with(job.id) do
ArchiveTraceWorker.new.perform(job.id)
end
- update_job(state: 'success', trace: 'BUILD TRACE UPDATED')
+ update_job(state: "success", trace: "BUILD TRACE UPDATED")
job.reload
expect(response).to have_gitlab_http_status(200)
- expect(job.trace.raw).to eq 'BUILD TRACE UPDATED'
- expect(job.job_artifacts_trace.open.read).to eq 'BUILD TRACE UPDATED'
+ expect(job.trace.raw).to eq "BUILD TRACE UPDATED"
+ expect(job.job_artifacts_trace.open.read).to eq "BUILD TRACE UPDATED"
end
- context 'when concurrent update of trace is happening' do
+ context "when concurrent update of trace is happening" do
before do
- job.trace.write('wb') do
- update_job(state: 'success', trace: 'BUILD TRACE UPDATED')
+ job.trace.write("wb") do
+ update_job(state: "success", trace: "BUILD TRACE UPDATED")
end
end
- it 'returns that operation conflicts' do
+ it "returns that operation conflicts" do
expect(response.status).to eq(409)
end
end
end
- context 'when no trace is given' do
- it 'does not override trace information' do
+ context "when no trace is given" do
+ it "does not override trace information" do
update_job
- expect(job.reload.trace.raw).to eq 'BUILD TRACE'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE"
end
- context 'when running state is sent' do
- it 'updates update_at value' do
+ context "when running state is sent" do
+ it "updates update_at value" do
expect { update_job_after_time }.to change { job.reload.updated_at }
end
end
- context 'when other state is sent' do
+ context "when other state is sent" do
it "doesn't update update_at value" do
- expect { update_job_after_time(20.minutes, state: 'success') }.not_to change { job.reload.updated_at }
+ expect { update_job_after_time(20.minutes, state: "success") }.not_to change { job.reload.updated_at }
end
end
end
- context 'when job has been erased' do
+ context "when job has been erased" do
let(:job) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) }
- it 'responds with forbidden' do
+ it "responds with forbidden" do
update_job
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when job has already been finished' do
+ context "when job has already been finished" do
before do
- job.trace.set('Job failed')
+ job.trace.set("Job failed")
job.drop!(:script_failure)
end
- it 'does not update job status and job trace' do
- update_job(state: 'success', trace: 'BUILD TRACE UPDATED')
+ it "does not update job status and job trace" do
+ update_job(state: "success", trace: "BUILD TRACE UPDATED")
job.reload
expect(response).to have_gitlab_http_status(403)
- expect(response.header['Job-Status']).to eq 'failed'
- expect(job.trace.raw).to eq 'Job failed'
+ expect(response.header["Job-Status"]).to eq "failed"
+ expect(job.trace.raw).to eq "Job failed"
expect(job).to be_failed
end
end
@@ -999,219 +1002,219 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
put api("/jobs/#{job.id}"), params: new_params
end
- def update_job_after_time(update_interval = 20.minutes, state = 'running')
+ def update_job_after_time(update_interval = 20.minutes, state = "running")
Timecop.travel(job.updated_at + update_interval) do
update_job(job.token, state: state)
end
end
end
- describe 'PATCH /api/v4/jobs/:id/trace' do
+ describe "PATCH /api/v4/jobs/:id/trace" do
let(:job) { create(:ci_build, :running, :trace_live, runner_id: runner.id, pipeline: pipeline) }
- let(:headers) { { API::Helpers::Runner::JOB_TOKEN_HEADER => job.token, 'Content-Type' => 'text/plain' } }
- let(:headers_with_range) { headers.merge({ 'Content-Range' => '11-20' }) }
+ let(:headers) { {API::Helpers::Runner::JOB_TOKEN_HEADER => job.token, "Content-Type" => "text/plain"} }
+ let(:headers_with_range) { headers.merge({"Content-Range" => "11-20"}) }
let(:update_interval) { 10.seconds.to_i }
before do
initial_patch_the_trace
end
- context 'when request is valid' do
- it 'gets correct response' do
+ context "when request is valid" do
+ it "gets correct response" do
expect(response.status).to eq 202
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
- expect(response.header).to have_key 'Range'
- expect(response.header).to have_key 'Job-Status'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended"
+ expect(response.header).to have_key "Range"
+ expect(response.header).to have_key "Job-Status"
end
- context 'when job has been updated recently' do
+ context "when job has been updated recently" do
it { expect { patch_the_trace }.not_to change { job.updated_at }}
it "changes the job's trace" do
patch_the_trace
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended appended"
end
- context 'when Runner makes a force-patch' do
+ context "when Runner makes a force-patch" do
it { expect { force_patch_the_trace }.not_to change { job.updated_at }}
it "doesn't change the build.trace" do
force_patch_the_trace
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended"
end
end
end
- context 'when job was not updated recently' do
+ context "when job was not updated recently" do
let(:update_interval) { 15.minutes.to_i }
it { expect { patch_the_trace }.to change { job.updated_at } }
- it 'changes the job.trace' do
+ it "changes the job.trace" do
patch_the_trace
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended appended"
end
- context 'when Runner makes a force-patch' do
+ context "when Runner makes a force-patch" do
it { expect { force_patch_the_trace }.to change { job.updated_at } }
it "doesn't change the job.trace" do
force_patch_the_trace
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended"
end
end
end
- context 'when project for the build has been deleted' do
+ context "when project for the build has been deleted" do
let(:job) do
create(:ci_build, :running, :trace_live, runner_id: runner.id, pipeline: pipeline) do |job|
job.project.update(pending_delete: true)
end
end
- it 'responds with forbidden' do
+ it "responds with forbidden" do
expect(response.status).to eq(403)
end
end
- context 'when trace is patched' do
+ context "when trace is patched" do
before do
patch_the_trace
end
- it 'has valid trace' do
+ it "has valid trace" do
expect(response.status).to eq(202)
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended appended"
end
- context 'when job is cancelled' do
+ context "when job is cancelled" do
before do
job.cancel
end
- context 'when trace is patched' do
+ context "when trace is patched" do
before do
patch_the_trace
end
- it 'returns Forbidden ' do
+ it "returns Forbidden " do
expect(response.status).to eq(403)
end
end
end
- context 'when redis data are flushed' do
+ context "when redis data are flushed" do
before do
redis_shared_state_cleanup!
end
- it 'has empty trace' do
- expect(job.reload.trace.raw).to eq ''
+ it "has empty trace" do
+ expect(job.reload.trace.raw).to eq ""
end
- context 'when we perform partial patch' do
+ context "when we perform partial patch" do
before do
- patch_the_trace('hello', headers.merge({ 'Content-Range' => "28-32/5" }))
+ patch_the_trace("hello", headers.merge({"Content-Range" => "28-32/5"}))
end
- it 'returns an error' do
+ it "returns an error" do
expect(response.status).to eq(416)
- expect(response.header['Range']).to eq('0-0')
+ expect(response.header["Range"]).to eq("0-0")
end
end
- context 'when we resend full trace' do
+ context "when we resend full trace" do
before do
- patch_the_trace('BUILD TRACE appended appended hello', headers.merge({ 'Content-Range' => "0-34/35" }))
+ patch_the_trace("BUILD TRACE appended appended hello", headers.merge({"Content-Range" => "0-34/35"}))
end
- it 'succeeds with updating trace' do
+ it "succeeds with updating trace" do
expect(response.status).to eq(202)
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended appended hello'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended appended hello"
end
end
end
end
- context 'when concurrent update of trace is happening' do
+ context "when concurrent update of trace is happening" do
before do
- job.trace.write('wb') do
+ job.trace.write("wb") do
patch_the_trace
end
end
- it 'returns that operation conflicts' do
+ it "returns that operation conflicts" do
expect(response.status).to eq(409)
end
end
- context 'when the job is canceled' do
+ context "when the job is canceled" do
before do
job.cancel
patch_the_trace
end
- it 'receives status in header' do
- expect(response.header['Job-Status']).to eq 'canceled'
+ it "receives status in header" do
+ expect(response.header["Job-Status"]).to eq "canceled"
end
end
end
- context 'when Runner makes a force-patch' do
+ context "when Runner makes a force-patch" do
before do
force_patch_the_trace
end
- it 'gets correct response' do
+ it "gets correct response" do
expect(response.status).to eq 202
- expect(job.reload.trace.raw).to eq 'BUILD TRACE appended'
- expect(response.header).to have_key 'Range'
- expect(response.header).to have_key 'Job-Status'
+ expect(job.reload.trace.raw).to eq "BUILD TRACE appended"
+ expect(response.header).to have_key "Range"
+ expect(response.header).to have_key "Job-Status"
end
end
- context 'when content-range start is too big' do
- let(:headers_with_range) { headers.merge({ 'Content-Range' => '15-20/6' }) }
+ context "when content-range start is too big" do
+ let(:headers_with_range) { headers.merge({"Content-Range" => "15-20/6"}) }
- it 'gets 416 error response with range headers' do
+ it "gets 416 error response with range headers" do
expect(response.status).to eq 416
- expect(response.header).to have_key 'Range'
- expect(response.header['Range']).to eq '0-11'
+ expect(response.header).to have_key "Range"
+ expect(response.header["Range"]).to eq "0-11"
end
end
- context 'when content-range start is too small' do
- let(:headers_with_range) { headers.merge({ 'Content-Range' => '8-20/13' }) }
+ context "when content-range start is too small" do
+ let(:headers_with_range) { headers.merge({"Content-Range" => "8-20/13"}) }
- it 'gets 416 error response with range headers' do
+ it "gets 416 error response with range headers" do
expect(response.status).to eq 416
- expect(response.header).to have_key 'Range'
- expect(response.header['Range']).to eq '0-11'
+ expect(response.header).to have_key "Range"
+ expect(response.header["Range"]).to eq "0-11"
end
end
- context 'when Content-Range header is missing' do
+ context "when Content-Range header is missing" do
let(:headers_with_range) { headers }
it { expect(response.status).to eq 400 }
end
- context 'when job has been errased' do
+ context "when job has been errased" do
let(:job) { create(:ci_build, runner_id: runner.id, erased_at: Time.now) }
it { expect(response.status).to eq 403 }
end
- def patch_the_trace(content = ' appended', request_headers = nil)
+ def patch_the_trace(content = " appended", request_headers = nil)
unless request_headers
job.trace.read do |stream|
offset = stream.size
limit = offset + content.length - 1
- request_headers = headers.merge({ 'Content-Range' => "#{offset}-#{limit}" })
+ request_headers = headers.merge({"Content-Range" => "#{offset}-#{limit}"})
end
end
@@ -1222,80 +1225,80 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
def initial_patch_the_trace
- patch_the_trace(' appended', headers_with_range)
+ patch_the_trace(" appended", headers_with_range)
end
def force_patch_the_trace
- 2.times { patch_the_trace('') }
+ 2.times { patch_the_trace("") }
end
end
- describe 'artifacts' do
+ describe "artifacts" do
let(:job) { create(:ci_build, :pending, pipeline: pipeline, runner_id: runner.id) }
- let(:jwt_token) { JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256') }
- let(:headers) { { 'GitLab-Workhorse' => '1.0', Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER => jwt_token } }
+ let(:jwt_token) { JWT.encode({"iss" => "gitlab-workhorse"}, Gitlab::Workhorse.secret, "HS256") }
+ let(:headers) { {"GitLab-Workhorse" => "1.0", Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER => jwt_token} }
let(:headers_with_token) { headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.token) }
- let(:file_upload) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
- let(:file_upload2) { fixture_file_upload('spec/fixtures/dk.png', 'image/gif') }
+ let(:file_upload) { fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif") }
+ let(:file_upload2) { fixture_file_upload("spec/fixtures/dk.png", "image/gif") }
before do
stub_artifacts_object_storage
job.run!
end
- describe 'POST /api/v4/jobs/:id/artifacts/authorize' do
- context 'when using token as parameter' do
- context 'posting artifacts to running job' do
+ describe "POST /api/v4/jobs/:id/artifacts/authorize" do
+ context "when using token as parameter" do
+ context "posting artifacts to running job" do
subject do
authorize_artifacts_with_token_in_params
end
- shared_examples 'authorizes local file' do
- it 'succeeds' do
+ shared_examples "authorizes local file" do
+ it "succeeds" do
subject
expect(response).to have_gitlab_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
- expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to be_nil
+ expect(json_response["TempPath"]).to eq(JobArtifactUploader.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to be_nil
end
end
- context 'when using local storage' do
- it_behaves_like 'authorizes local file'
+ context "when using local storage" do
+ it_behaves_like "authorizes local file"
end
- context 'when using remote storage' do
- context 'when direct upload is enabled' do
+ context "when using remote storage" do
+ context "when direct upload is enabled" do
before do
stub_artifacts_object_storage(enabled: true, direct_upload: true)
end
- it 'succeeds' do
+ it "succeeds" do
subject
expect(response).to have_gitlab_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
- expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to have_key('ID')
- expect(json_response['RemoteObject']).to have_key('GetURL')
- expect(json_response['RemoteObject']).to have_key('StoreURL')
- expect(json_response['RemoteObject']).to have_key('DeleteURL')
- expect(json_response['RemoteObject']).to have_key('MultipartUpload')
+ expect(json_response["TempPath"]).to eq(JobArtifactUploader.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to have_key("ID")
+ expect(json_response["RemoteObject"]).to have_key("GetURL")
+ expect(json_response["RemoteObject"]).to have_key("StoreURL")
+ expect(json_response["RemoteObject"]).to have_key("DeleteURL")
+ expect(json_response["RemoteObject"]).to have_key("MultipartUpload")
end
end
- context 'when direct upload is disabled' do
+ context "when direct upload is disabled" do
before do
stub_artifacts_object_storage(enabled: true, direct_upload: false)
end
- it_behaves_like 'authorizes local file'
+ it_behaves_like "authorizes local file"
end
end
end
- it 'fails to post too large artifact' do
+ it "fails to post too large artifact" do
stub_application_setting(max_artifacts_size: 0)
authorize_artifacts_with_token_in_params(filesize: 100)
@@ -1304,16 +1307,16 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when using token as header' do
- it 'authorizes posting artifacts to running job' do
+ context "when using token as header" do
+ it "authorizes posting artifacts to running job" do
authorize_artifacts_with_token_in_headers
expect(response).to have_gitlab_http_status(200)
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
- expect(json_response['TempPath']).not_to be_nil
+ expect(json_response["TempPath"]).not_to be_nil
end
- it 'fails to post too large artifact' do
+ it "fails to post too large artifact" do
stub_application_setting(max_artifacts_size: 0)
authorize_artifacts_with_token_in_headers(filesize: 100)
@@ -1322,15 +1325,15 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when using runners token' do
- it 'fails to authorize artifacts posting' do
+ context "when using runners token" do
+ it "fails to authorize artifacts posting" do
authorize_artifacts(token: job.project.runners_token)
expect(response).to have_gitlab_http_status(403)
end
end
- it 'reject requests that did not go through gitlab-workhorse' do
+ it "reject requests that did not go through gitlab-workhorse" do
headers.delete(Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER)
authorize_artifacts
@@ -1338,9 +1341,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(response).to have_gitlab_http_status(500)
end
- context 'authorization token is invalid' do
- it 'responds with forbidden' do
- authorize_artifacts(token: 'invalid', filesize: 100 )
+ context "authorization token is invalid" do
+ it "responds with forbidden" do
+ authorize_artifacts(token: "invalid", filesize: 100)
expect(response).to have_gitlab_http_status(403)
end
@@ -1360,77 +1363,77 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- describe 'POST /api/v4/jobs/:id/artifacts' do
- context 'when artifacts are being stored inside of tmp path' do
+ describe "POST /api/v4/jobs/:id/artifacts" do
+ context "when artifacts are being stored inside of tmp path" do
before do
# by configuring this path we allow to pass temp file from any path
- allow(JobArtifactUploader).to receive(:workhorse_upload_path).and_return('/')
+ allow(JobArtifactUploader).to receive(:workhorse_upload_path).and_return("/")
end
- context 'when job has been erased' do
+ context "when job has been erased" do
let(:job) { create(:ci_build, erased_at: Time.now) }
before do
upload_artifacts(file_upload, headers_with_token)
end
- it 'responds with forbidden' do
+ it "responds with forbidden" do
upload_artifacts(file_upload, headers_with_token)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when job is running' do
- shared_examples 'successful artifacts upload' do
- it 'updates successfully' do
+ context "when job is running" do
+ shared_examples "successful artifacts upload" do
+ it "updates successfully" do
expect(response).to have_gitlab_http_status(201)
end
end
- context 'when uses accelerated file post' do
- context 'for file stored locally' do
+ context "when uses accelerated file post" do
+ context "for file stored locally" do
before do
upload_artifacts(file_upload, headers_with_token)
end
- it_behaves_like 'successful artifacts upload'
+ it_behaves_like "successful artifacts upload"
end
- context 'for file stored remotelly' do
+ context "for file stored remotelly" do
let!(:fog_connection) do
stub_artifacts_object_storage(direct_upload: true)
end
before do
- fog_connection.directories.new(key: 'artifacts').files.create(
- key: 'tmp/uploads/12312300',
- body: 'content'
+ fog_connection.directories.new(key: "artifacts").files.create(
+ key: "tmp/uploads/12312300",
+ body: "content"
)
upload_artifacts(file_upload, headers_with_token,
- { 'file.remote_id' => remote_id })
+ {"file.remote_id" => remote_id})
end
- context 'when valid remote_id is used' do
- let(:remote_id) { '12312300' }
+ context "when valid remote_id is used" do
+ let(:remote_id) { "12312300" }
- it_behaves_like 'successful artifacts upload'
+ it_behaves_like "successful artifacts upload"
end
- context 'when invalid remote_id is used' do
- let(:remote_id) { 'invalid id' }
+ context "when invalid remote_id is used" do
+ let(:remote_id) { "invalid id" }
- it 'responds with bad request' do
+ it "responds with bad request" do
expect(response).to have_gitlab_http_status(500)
- expect(json_response['message']).to eq("Missing file")
+ expect(json_response["message"]).to eq("Missing file")
end
end
end
end
- context 'when using runners token' do
- it 'responds with forbidden' do
+ context "when using runners token" do
+ it "responds with forbidden" do
upload_artifacts(file_upload, headers.merge(API::Helpers::Runner::JOB_TOKEN_HEADER => job.project.runners_token))
expect(response).to have_gitlab_http_status(403)
@@ -1438,8 +1441,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifacts file is too large' do
- it 'fails to post too large artifact' do
+ context "when artifacts file is too large" do
+ it "fails to post too large artifact" do
stub_application_setting(max_artifacts_size: 0)
upload_artifacts(file_upload, headers_with_token)
@@ -1448,28 +1451,28 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifacts post request does not contain file' do
- it 'fails to post artifacts without file' do
+ context "when artifacts post request does not contain file" do
+ it "fails to post artifacts without file" do
post api("/jobs/#{job.id}/artifacts"), params: {}, headers: headers_with_token
expect(response).to have_gitlab_http_status(400)
end
end
- context 'GitLab Workhorse is not configured' do
- it 'fails to post artifacts without GitLab-Workhorse' do
- post api("/jobs/#{job.id}/artifacts"), params: { token: job.token }, headers: {}
+ context "GitLab Workhorse is not configured" do
+ it "fails to post artifacts without GitLab-Workhorse" do
+ post api("/jobs/#{job.id}/artifacts"), params: {token: job.token}, headers: {}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when setting an expire date' do
+ context "when setting an expire date" do
let(:default_artifacts_expire_in) {}
let(:post_data) do
- { 'file.path' => file_upload.path,
- 'file.name' => file_upload.original_filename,
- 'expire_in' => expire_in }
+ {"file.path" => file_upload.path,
+ "file.name" => file_upload.original_filename,
+ "expire_in" => expire_in,}
end
before do
@@ -1478,37 +1481,37 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
post(api("/jobs/#{job.id}/artifacts"), params: post_data, headers: headers_with_token)
end
- context 'when an expire_in is given' do
- let(:expire_in) { '7 days' }
+ context "when an expire_in is given" do
+ let(:expire_in) { "7 days" }
- it 'updates when specified' do
+ it "updates when specified" do
expect(response).to have_gitlab_http_status(201)
expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(7.days.from_now)
end
end
- context 'when no expire_in is given' do
+ context "when no expire_in is given" do
let(:expire_in) { nil }
- it 'ignores if not specified' do
+ it "ignores if not specified" do
expect(response).to have_gitlab_http_status(201)
expect(job.reload.artifacts_expire_at).to be_nil
end
- context 'with application default' do
- context 'when default is 5 days' do
- let(:default_artifacts_expire_in) { '5 days' }
+ context "with application default" do
+ context "when default is 5 days" do
+ let(:default_artifacts_expire_in) { "5 days" }
- it 'sets to application default' do
+ it "sets to application default" do
expect(response).to have_gitlab_http_status(201)
expect(job.reload.artifacts_expire_at).to be_within(5.minutes).of(5.days.from_now)
end
end
- context 'when default is 0' do
- let(:default_artifacts_expire_in) { '0' }
+ context "when default is 0" do
+ let(:default_artifacts_expire_in) { "0" }
- it 'does not set expire_in' do
+ it "does not set expire_in" do
expect(response).to have_gitlab_http_status(201)
expect(job.reload.artifacts_expire_at).to be_nil
end
@@ -1517,7 +1520,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'posts artifacts file and metadata file' do
+ context "posts artifacts file and metadata file" do
let!(:artifacts) { file_upload }
let!(:artifacts_sha256) { Digest::SHA256.file(artifacts.path).hexdigest }
let!(:metadata) { file_upload2 }
@@ -1533,17 +1536,17 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
post(api("/jobs/#{job.id}/artifacts"), params: post_data, headers: headers_with_token)
end
- context 'when posts data accelerated by workhorse is correct' do
+ context "when posts data accelerated by workhorse is correct" do
let(:post_data) do
- { 'file.path' => artifacts.path,
- 'file.name' => artifacts.original_filename,
- 'file.sha256' => artifacts_sha256,
- 'metadata.path' => metadata.path,
- 'metadata.name' => metadata.original_filename,
- 'metadata.sha256' => metadata_sha256 }
+ {"file.path" => artifacts.path,
+ "file.name" => artifacts.original_filename,
+ "file.sha256" => artifacts_sha256,
+ "metadata.path" => metadata.path,
+ "metadata.name" => metadata.original_filename,
+ "metadata.sha256" => metadata_sha256,}
end
- it 'stores artifacts and artifacts metadata' do
+ it "stores artifacts and artifacts metadata" do
expect(response).to have_gitlab_http_status(201)
expect(stored_artifacts_file.original_filename).to eq(artifacts.original_filename)
expect(stored_metadata_file.original_filename).to eq(metadata.original_filename)
@@ -1553,26 +1556,26 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when there is no artifacts file in post data' do
+ context "when there is no artifacts file in post data" do
let(:post_data) do
- { 'metadata' => metadata }
+ {"metadata" => metadata}
end
- it 'is expected to respond with bad request' do
+ it "is expected to respond with bad request" do
expect(response).to have_gitlab_http_status(400)
end
- it 'does not store metadata' do
+ it "does not store metadata" do
expect(stored_metadata_file).to be_nil
end
end
end
- context 'when artifact_type is archive' do
- context 'when artifact_format is zip' do
- let(:params) { { artifact_type: :archive, artifact_format: :zip } }
+ context "when artifact_type is archive" do
+ context "when artifact_format is zip" do
+ let(:params) { {artifact_type: :archive, artifact_format: :zip} }
- it 'stores junit test report' do
+ it "stores junit test report" do
upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201)
@@ -1580,10 +1583,10 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifact_format is gzip' do
- let(:params) { { artifact_type: :archive, artifact_format: :gzip } }
+ context "when artifact_format is gzip" do
+ let(:params) { {artifact_type: :archive, artifact_format: :gzip} }
- it 'returns an error' do
+ it "returns an error" do
upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400)
@@ -1592,12 +1595,12 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifact_type is junit' do
- context 'when artifact_format is gzip' do
- let(:file_upload) { fixture_file_upload('spec/fixtures/junit/junit.xml.gz') }
- let(:params) { { artifact_type: :junit, artifact_format: :gzip } }
+ context "when artifact_type is junit" do
+ context "when artifact_format is gzip" do
+ let(:file_upload) { fixture_file_upload("spec/fixtures/junit/junit.xml.gz") }
+ let(:params) { {artifact_type: :junit, artifact_format: :gzip} }
- it 'stores junit test report' do
+ it "stores junit test report" do
upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(201)
@@ -1605,11 +1608,11 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifact_format is raw' do
- let(:file_upload) { fixture_file_upload('spec/fixtures/junit/junit.xml.gz') }
- let(:params) { { artifact_type: :junit, artifact_format: :raw } }
+ context "when artifact_format is raw" do
+ let(:file_upload) { fixture_file_upload("spec/fixtures/junit/junit.xml.gz") }
+ let(:params) { {artifact_type: :junit, artifact_format: :raw} }
- it 'returns an error' do
+ it "returns an error" do
upload_artifacts(file_upload, headers_with_token, params)
expect(response).to have_gitlab_http_status(400)
@@ -1619,7 +1622,7 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
end
end
- context 'when artifacts are being stored outside of tmp path' do
+ context "when artifacts are being stored outside of tmp path" do
let(:new_tmpdir) { Dir.mktmpdir }
before do
@@ -1644,18 +1647,18 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
def upload_artifacts(file, headers = {}, params = {})
params = params.merge({
- 'file.path' => file.path,
- 'file.name' => file.original_filename
+ "file.path" => file.path,
+ "file.name" => file.original_filename,
})
post api("/jobs/#{job.id}/artifacts"), params: params, headers: headers
end
end
- describe 'GET /api/v4/jobs/:id/artifacts' do
+ describe "GET /api/v4/jobs/:id/artifacts" do
let(:token) { job.token }
- context 'when job has artifacts' do
+ context "when job has artifacts" do
let(:job) { create(:ci_build) }
let(:store) { JobArtifactUploader::Store::LOCAL }
@@ -1663,67 +1666,68 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
create(:ci_job_artifact, :archive, file_store: store, job: job)
end
- context 'when using job token' do
- context 'when artifacts are stored locally' do
+ context "when using job token" do
+ context "when artifacts are stored locally" do
let(:download_headers) do
- { 'Content-Transfer-Encoding' => 'binary',
- 'Content-Disposition' => %q(attachment; filename="ci_build_artifacts.zip"; filename*=UTF-8''ci_build_artifacts.zip) }
+ {"Content-Transfer-Encoding" => "binary",
+ "Content-Disposition" => %q(attachment; filename="ci_build_artifacts.zip"; filename*=UTF-8''ci_build_artifacts.zip),}
end
before do
download_artifact
end
- it 'download artifacts' do
+ it "download artifacts" do
expect(response).to have_http_status(200)
expect(response.headers.to_h).to include download_headers
end
end
- context 'when artifacts are stored remotely' do
+ context "when artifacts are stored remotely" do
let(:store) { JobArtifactUploader::Store::REMOTE }
let!(:job) { create(:ci_build) }
- context 'when proxy download is being used' do
+ context "when proxy download is being used" do
before do
download_artifact(direct_download: false)
end
- it 'uses workhorse send-url' do
+ it "uses workhorse send-url" do
expect(response).to have_gitlab_http_status(200)
expect(response.headers.to_h).to include(
- 'Gitlab-Workhorse-Send-Data' => /send-url:/)
+ "Gitlab-Workhorse-Send-Data" => /send-url:/
+ )
end
end
- context 'when direct download is being used' do
+ context "when direct download is being used" do
before do
download_artifact(direct_download: true)
end
- it 'receive redirect for downloading artifacts' do
+ it "receive redirect for downloading artifacts" do
expect(response).to have_gitlab_http_status(302)
- expect(response.headers).to include('Location')
+ expect(response.headers).to include("Location")
end
end
end
end
- context 'when using runnners token' do
+ context "when using runnners token" do
let(:token) { job.project.runners_token }
before do
download_artifact
end
- it 'responds with forbidden' do
+ it "responds with forbidden" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'when job does not has artifacts' do
- it 'responds with not found' do
+ context "when job does not has artifacts" do
+ it "responds with not found" do
download_artifact
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index 5548e3fd01a..9194ed70e78 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Runners do
let(:admin) { create(:user, :admin) }
@@ -11,10 +11,10 @@ describe API::Runners do
let(:group) { create(:group).tap { |group| group.add_owner(user) } }
let(:group2) { create(:group).tap { |group| group.add_owner(user) } }
- let!(:shared_runner) { create(:ci_runner, :instance, description: 'Shared runner') }
- let!(:project_runner) { create(:ci_runner, :project, description: 'Project runner', projects: [project]) }
- let!(:two_projects_runner) { create(:ci_runner, :project, description: 'Two projects runner', projects: [project, project2]) }
- let!(:group_runner) { create(:ci_runner, :group, description: 'Group runner', groups: [group]) }
+ let!(:shared_runner) { create(:ci_runner, :instance, description: "Shared runner") }
+ let!(:project_runner) { create(:ci_runner, :project, description: "Project runner", projects: [project]) }
+ let!(:two_projects_runner) { create(:ci_runner, :project, description: "Two projects runner", projects: [project, project2]) }
+ let!(:group_runner) { create(:ci_runner, :group, description: "Group runner", groups: [group]) }
before do
# Set project access for users
@@ -23,228 +23,228 @@ describe API::Runners do
create(:project_member, :reporter, user: user2, project: project)
end
- describe 'GET /runners' do
- context 'authorized user' do
- it 'returns response status and headers' do
- get api('/runners', user)
+ describe "GET /runners" do
+ context "authorized user" do
+ it "returns response status and headers" do
+ get api("/runners", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
end
- it 'returns user available runners' do
- get api('/runners', user)
+ it "returns user available runners" do
+ get api("/runners", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner'),
- a_hash_including('description' => 'Group runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
+ a_hash_including("description" => "Group runner"),
]
end
- it 'filters runners by scope' do
- create(:ci_runner, :project, :inactive, description: 'Inactive project runner', projects: [project])
+ it "filters runners by scope" do
+ create(:ci_runner, :project, :inactive, description: "Inactive project runner", projects: [project])
- get api('/runners?scope=paused', user)
+ get api("/runners?scope=paused", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to match_array [
- a_hash_including('description' => 'Inactive project runner')
+ a_hash_including("description" => "Inactive project runner"),
]
end
- it 'avoids filtering if scope is invalid' do
- get api('/runners?scope=unknown', user)
+ it "avoids filtering if scope is invalid" do
+ get api("/runners?scope=unknown", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by type' do
- get api('/runners?type=project_type', user)
+ it "filters runners by type" do
+ get api("/runners?type=project_type", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
]
end
- it 'does not filter by invalid type' do
- get api('/runners?type=bogus', user)
+ it "does not filter by invalid type" do
+ get api("/runners?type=bogus", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by status' do
- create(:ci_runner, :project, :inactive, description: 'Inactive project runner', projects: [project])
+ it "filters runners by status" do
+ create(:ci_runner, :project, :inactive, description: "Inactive project runner", projects: [project])
- get api('/runners?status=paused', user)
+ get api("/runners?status=paused", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Inactive project runner')
+ a_hash_including("description" => "Inactive project runner"),
]
end
- it 'does not filter by invalid status' do
- get api('/runners?status=bogus', user)
+ it "does not filter by invalid status" do
+ get api("/runners?status=bogus", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by tag_list' do
- create(:ci_runner, :project, description: 'Runner tagged with tag1 and tag2', projects: [project], tag_list: %w[tag1 tag2])
- create(:ci_runner, :project, description: 'Runner tagged with tag2', projects: [project], tag_list: ['tag2'])
+ it "filters runners by tag_list" do
+ create(:ci_runner, :project, description: "Runner tagged with tag1 and tag2", projects: [project], tag_list: %w[tag1 tag2])
+ create(:ci_runner, :project, description: "Runner tagged with tag2", projects: [project], tag_list: ["tag2"])
- get api('/runners?tag_list=tag1,tag2', user)
+ get api("/runners?tag_list=tag1,tag2", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Runner tagged with tag1 and tag2')
+ a_hash_including("description" => "Runner tagged with tag1 and tag2"),
]
end
end
- context 'unauthorized user' do
- it 'does not return runners' do
- get api('/runners')
+ context "unauthorized user" do
+ it "does not return runners" do
+ get api("/runners")
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'GET /runners/all' do
- context 'authorized user' do
- context 'with admin privileges' do
- it 'returns response status and headers' do
- get api('/runners/all', admin)
+ describe "GET /runners/all" do
+ context "authorized user" do
+ context "with admin privileges" do
+ it "returns response status and headers" do
+ get api("/runners/all", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
end
- it 'returns all runners' do
- get api('/runners/all', admin)
+ it "returns all runners" do
+ get api("/runners/all", admin)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner'),
- a_hash_including('description' => 'Group runner'),
- a_hash_including('description' => 'Shared runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
+ a_hash_including("description" => "Group runner"),
+ a_hash_including("description" => "Shared runner"),
]
end
- it 'filters runners by scope' do
- get api('/runners/all?scope=shared', admin)
+ it "filters runners by scope" do
+ get api("/runners/all?scope=shared", admin)
- shared = json_response.all? { |r| r['is_shared'] }
+ shared = json_response.all? { |r| r["is_shared"] }
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response[0]).to have_key('ip_address')
+ expect(json_response[0]).to have_key("ip_address")
expect(shared).to be_truthy
end
- it 'filters runners by scope' do
- get api('/runners/all?scope=specific', admin)
+ it "filters runners by scope" do
+ get api("/runners/all?scope=specific", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner'),
- a_hash_including('description' => 'Group runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
+ a_hash_including("description" => "Group runner"),
]
end
- it 'avoids filtering if scope is invalid' do
- get api('/runners/all?scope=unknown', admin)
+ it "avoids filtering if scope is invalid" do
+ get api("/runners/all?scope=unknown", admin)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by type' do
- get api('/runners/all?type=project_type', admin)
+ it "filters runners by type" do
+ get api("/runners/all?type=project_type", admin)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
]
end
- it 'does not filter by invalid type' do
- get api('/runners/all?type=bogus', admin)
+ it "does not filter by invalid type" do
+ get api("/runners/all?type=bogus", admin)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by status' do
- create(:ci_runner, :project, :inactive, description: 'Inactive project runner', projects: [project])
+ it "filters runners by status" do
+ create(:ci_runner, :project, :inactive, description: "Inactive project runner", projects: [project])
- get api('/runners/all?status=paused', admin)
+ get api("/runners/all?status=paused", admin)
expect(json_response).to match_array [
- a_hash_including('description' => 'Inactive project runner')
+ a_hash_including("description" => "Inactive project runner"),
]
end
- it 'does not filter by invalid status' do
- get api('/runners/all?status=bogus', admin)
+ it "does not filter by invalid status" do
+ get api("/runners/all?status=bogus", admin)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by tag_list' do
- create(:ci_runner, :project, description: 'Runner tagged with tag1 and tag2', projects: [project], tag_list: %w[tag1 tag2])
- create(:ci_runner, :project, description: 'Runner tagged with tag2', projects: [project], tag_list: ['tag2'])
+ it "filters runners by tag_list" do
+ create(:ci_runner, :project, description: "Runner tagged with tag1 and tag2", projects: [project], tag_list: %w[tag1 tag2])
+ create(:ci_runner, :project, description: "Runner tagged with tag2", projects: [project], tag_list: ["tag2"])
- get api('/runners/all?tag_list=tag1,tag2', admin)
+ get api("/runners/all?tag_list=tag1,tag2", admin)
expect(json_response).to match_array [
- a_hash_including('description' => 'Runner tagged with tag1 and tag2')
+ a_hash_including("description" => "Runner tagged with tag1 and tag2"),
]
end
end
- context 'without admin privileges' do
- it 'does not return runners list' do
- get api('/runners/all', user)
+ context "without admin privileges" do
+ it "does not return runners list" do
+ get api("/runners/all", user)
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'unauthorized user' do
- it 'does not return runners' do
- get api('/runners')
+ context "unauthorized user" do
+ it "does not return runners" do
+ get api("/runners")
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'GET /runners/:id' do
- context 'admin user' do
- context 'when runner is shared' do
+ describe "GET /runners/:id" do
+ context "admin user" do
+ context "when runner is shared" do
it "returns runner's details" do
get api("/runners/#{shared_runner.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['description']).to eq(shared_runner.description)
- expect(json_response['maximum_timeout']).to be_nil
+ expect(json_response["description"]).to eq(shared_runner.description)
+ expect(json_response["maximum_timeout"]).to be_nil
end
end
- context 'when runner is not shared' do
- context 'when unused runner is present' do
+ context "when runner is not shared" do
+ context "when unused runner is present" do
let!(:unused_project_runner) { create(:ci_runner, :project, :without_projects) }
- it 'deletes unused runner' do
- expect do
+ it "deletes unused runner" do
+ expect {
delete api("/runners/#{unused_project_runner.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { Ci::Runner.project_type.count }.by(-1)
+ }.to change { Ci::Runner.project_type.count }.by(-1)
end
end
@@ -252,44 +252,44 @@ describe API::Runners do
get api("/runners/#{project_runner.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['description']).to eq(project_runner.description)
+ expect(json_response["description"]).to eq(project_runner.description)
end
it "returns the project's details for a project runner" do
get api("/runners/#{project_runner.id}", admin)
- expect(json_response['projects'].first['id']).to eq(project.id)
+ expect(json_response["projects"].first["id"]).to eq(project.id)
end
end
- it 'returns 404 if runner does not exists' do
- get api('/runners/0', admin)
+ it "returns 404 if runner does not exists" do
+ get api("/runners/0", admin)
expect(response).to have_gitlab_http_status(404)
end
end
context "runner project's administrative user" do
- context 'when runner is not shared' do
+ context "when runner is not shared" do
it "returns runner's details" do
get api("/runners/#{project_runner.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['description']).to eq(project_runner.description)
+ expect(json_response["description"]).to eq(project_runner.description)
end
end
- context 'when runner is shared' do
+ context "when runner is shared" do
it "returns runner's details" do
get api("/runners/#{shared_runner.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['description']).to eq(shared_runner.description)
+ expect(json_response["description"]).to eq(shared_runner.description)
end
end
end
- context 'other authorized user' do
+ context "other authorized user" do
it "does not return project runner's details" do
get api("/runners/#{project_runner.id}", user2)
@@ -297,7 +297,7 @@ describe API::Runners do
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
it "does not return project runner's details" do
get api("/runners/#{project_runner.id}")
@@ -306,11 +306,11 @@ describe API::Runners do
end
end
- describe 'PUT /runners/:id' do
- context 'admin user' do
+ describe "PUT /runners/:id" do
+ context "admin user" do
# see https://gitlab.com/gitlab-org/gitlab-ce/issues/48625
- context 'single parameter update' do
- it 'runner description' do
+ context "single parameter update" do
+ it "runner description" do
description = shared_runner.description
update_runner(shared_runner.id, admin, description: "#{description}_updated")
@@ -318,7 +318,7 @@ describe API::Runners do
expect(shared_runner.reload.description).to eq("#{description}_updated")
end
- it 'runner active state' do
+ it "runner active state" do
active = shared_runner.active
update_runner(shared_runner.id, admin, active: !active)
@@ -326,44 +326,44 @@ describe API::Runners do
expect(shared_runner.reload.active).to eq(!active)
end
- it 'runner tag list' do
- update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql'])
+ it "runner tag list" do
+ update_runner(shared_runner.id, admin, tag_list: ["ruby2.1", "pgsql", "mysql"])
expect(response).to have_gitlab_http_status(200)
- expect(shared_runner.reload.tag_list).to include('ruby2.1', 'pgsql', 'mysql')
+ expect(shared_runner.reload.tag_list).to include("ruby2.1", "pgsql", "mysql")
end
- it 'runner untagged flag' do
+ it "runner untagged flag" do
# Ensure tag list is non-empty before setting untagged to false.
- update_runner(shared_runner.id, admin, tag_list: ['ruby2.1', 'pgsql', 'mysql'])
- update_runner(shared_runner.id, admin, run_untagged: 'false')
+ update_runner(shared_runner.id, admin, tag_list: ["ruby2.1", "pgsql", "mysql"])
+ update_runner(shared_runner.id, admin, run_untagged: "false")
expect(response).to have_gitlab_http_status(200)
expect(shared_runner.reload.run_untagged?).to be(false)
end
- it 'runner unlocked flag' do
- update_runner(shared_runner.id, admin, locked: 'true')
+ it "runner unlocked flag" do
+ update_runner(shared_runner.id, admin, locked: "true")
expect(response).to have_gitlab_http_status(200)
expect(shared_runner.reload.locked?).to be(true)
end
- it 'runner access level' do
- update_runner(shared_runner.id, admin, access_level: 'ref_protected')
+ it "runner access level" do
+ update_runner(shared_runner.id, admin, access_level: "ref_protected")
expect(response).to have_gitlab_http_status(200)
expect(shared_runner.reload.ref_protected?).to be_truthy
end
- it 'runner maximum timeout' do
+ it "runner maximum timeout" do
update_runner(shared_runner.id, admin, maximum_timeout: 1234)
expect(response).to have_gitlab_http_status(200)
expect(shared_runner.reload.maximum_timeout).to eq(1234)
end
- it 'fails with no parameters' do
+ it "fails with no parameters" do
put api("/runners/#{shared_runner.id}", admin)
shared_runner.reload
@@ -371,25 +371,25 @@ describe API::Runners do
end
end
- context 'when runner is shared' do
- it 'updates runner' do
+ context "when runner is shared" do
+ it "updates runner" do
description = shared_runner.description
active = shared_runner.active
runner_queue_value = shared_runner.ensure_runner_queue_value
update_runner(shared_runner.id, admin, description: "#{description}_updated",
active: !active,
- tag_list: ['ruby2.1', 'pgsql', 'mysql'],
- run_untagged: 'false',
- locked: 'true',
- access_level: 'ref_protected',
+ tag_list: ["ruby2.1", "pgsql", "mysql"],
+ run_untagged: "false",
+ locked: "true",
+ access_level: "ref_protected",
maximum_timeout: 1234)
shared_runner.reload
expect(response).to have_gitlab_http_status(200)
expect(shared_runner.description).to eq("#{description}_updated")
expect(shared_runner.active).to eq(!active)
- expect(shared_runner.tag_list).to include('ruby2.1', 'pgsql', 'mysql')
+ expect(shared_runner.tag_list).to include("ruby2.1", "pgsql", "mysql")
expect(shared_runner.run_untagged?).to be(false)
expect(shared_runner.locked?).to be(true)
expect(shared_runner.ref_protected?).to be_truthy
@@ -399,24 +399,24 @@ describe API::Runners do
end
end
- context 'when runner is not shared' do
- it 'updates runner' do
+ context "when runner is not shared" do
+ it "updates runner" do
description = project_runner.description
runner_queue_value = project_runner.ensure_runner_queue_value
- update_runner(project_runner.id, admin, description: 'test')
+ update_runner(project_runner.id, admin, description: "test")
project_runner.reload
expect(response).to have_gitlab_http_status(200)
- expect(project_runner.description).to eq('test')
+ expect(project_runner.description).to eq("test")
expect(project_runner.description).not_to eq(description)
expect(project_runner.ensure_runner_queue_value)
.not_to eq(runner_queue_value)
end
end
- it 'returns 404 if runner does not exists' do
- update_runner(0, admin, description: 'test')
+ it "returns 404 if runner does not exists" do
+ update_runner(0, admin, description: "test")
expect(response).to have_gitlab_http_status(404)
end
@@ -426,36 +426,36 @@ describe API::Runners do
end
end
- context 'authorized user' do
- context 'when runner is shared' do
- it 'does not update runner' do
- put api("/runners/#{shared_runner.id}", user), params: { description: 'test' }
+ context "authorized user" do
+ context "when runner is shared" do
+ it "does not update runner" do
+ put api("/runners/#{shared_runner.id}", user), params: {description: "test"}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when runner is not shared' do
- it 'does not update project runner without access to it' do
- put api("/runners/#{project_runner.id}", user2), params: { description: 'test' }
+ context "when runner is not shared" do
+ it "does not update project runner without access to it" do
+ put api("/runners/#{project_runner.id}", user2), params: {description: "test"}
expect(response).to have_http_status(403)
end
- it 'updates project runner with access to it' do
+ it "updates project runner with access to it" do
description = project_runner.description
- put api("/runners/#{project_runner.id}", admin), params: { description: 'test' }
+ put api("/runners/#{project_runner.id}", admin), params: {description: "test"}
project_runner.reload
expect(response).to have_gitlab_http_status(200)
- expect(project_runner.description).to eq('test')
+ expect(project_runner.description).to eq("test")
expect(project_runner.description).not_to eq(description)
end
end
end
- context 'unauthorized user' do
- it 'does not delete project runner' do
+ context "unauthorized user" do
+ it "does not delete project runner" do
put api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401)
@@ -463,74 +463,74 @@ describe API::Runners do
end
end
- describe 'DELETE /runners/:id' do
- context 'admin user' do
- context 'when runner is shared' do
- it 'deletes runner' do
- expect do
+ describe "DELETE /runners/:id" do
+ context "admin user" do
+ context "when runner is shared" do
+ it "deletes runner" do
+ expect {
delete api("/runners/#{shared_runner.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { Ci::Runner.instance_type.count }.by(-1)
+ }.to change { Ci::Runner.instance_type.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/runners/#{shared_runner.id}", admin) }
end
end
- context 'when runner is not shared' do
- it 'deletes used project runner' do
- expect do
+ context "when runner is not shared" do
+ it "deletes used project runner" do
+ expect {
delete api("/runners/#{project_runner.id}", admin)
expect(response).to have_http_status(204)
- end.to change { Ci::Runner.project_type.count }.by(-1)
+ }.to change { Ci::Runner.project_type.count }.by(-1)
end
end
- it 'returns 404 if runner does not exists' do
- delete api('/runners/0', admin)
+ it "returns 404 if runner does not exists" do
+ delete api("/runners/0", admin)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user' do
- context 'when runner is shared' do
- it 'does not delete runner' do
+ context "authorized user" do
+ context "when runner is shared" do
+ it "does not delete runner" do
delete api("/runners/#{shared_runner.id}", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when runner is not shared' do
- it 'does not delete runner without access to it' do
+ context "when runner is not shared" do
+ it "does not delete runner without access to it" do
delete api("/runners/#{project_runner.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
- it 'does not delete project runner with more than one associated project' do
+ it "does not delete project runner with more than one associated project" do
delete api("/runners/#{two_projects_runner.id}", user)
expect(response).to have_gitlab_http_status(403)
end
- it 'deletes project runner for one owned project' do
- expect do
+ it "deletes project runner for one owned project" do
+ expect {
delete api("/runners/#{project_runner.id}", user)
expect(response).to have_http_status(204)
- end.to change { Ci::Runner.project_type.count }.by(-1)
+ }.to change { Ci::Runner.project_type.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/runners/#{project_runner.id}", user) }
end
end
end
- context 'unauthorized user' do
- it 'does not delete project runner' do
+ context "unauthorized user" do
+ it "does not delete project runner" do
delete api("/runners/#{project_runner.id}")
expect(response).to have_http_status(401)
@@ -538,17 +538,17 @@ describe API::Runners do
end
end
- describe 'GET /runners/:id/jobs' do
+ describe "GET /runners/:id/jobs" do
set(:job_1) { create(:ci_build) }
let!(:job_2) { create(:ci_build, :running, runner: shared_runner, project: project) }
let!(:job_3) { create(:ci_build, :failed, runner: shared_runner, project: project) }
let!(:job_4) { create(:ci_build, :running, runner: project_runner, project: project) }
let!(:job_5) { create(:ci_build, :failed, runner: project_runner, project: project) }
- context 'admin user' do
- context 'when runner exists' do
- context 'when runner is shared' do
- it 'return jobs' do
+ context "admin user" do
+ context "when runner exists" do
+ context "when runner is shared" do
+ it "return jobs" do
get api("/runners/#{shared_runner.id}/jobs", admin)
expect(response).to have_gitlab_http_status(200)
@@ -559,8 +559,8 @@ describe API::Runners do
end
end
- context 'when runner is specific' do
- it 'return jobs' do
+ context "when runner is specific" do
+ it "return jobs" do
get api("/runners/#{project_runner.id}/jobs", admin)
expect(response).to have_gitlab_http_status(200)
@@ -571,8 +571,8 @@ describe API::Runners do
end
end
- context 'when valid status is provided' do
- it 'return filtered jobs' do
+ context "when valid status is provided" do
+ it "return filtered jobs" do
get api("/runners/#{project_runner.id}/jobs?status=failed", admin)
expect(response).to have_gitlab_http_status(200)
@@ -580,12 +580,12 @@ describe API::Runners do
expect(json_response).to be_an(Array)
expect(json_response.length).to eq(1)
- expect(json_response.first).to include('id' => job_5.id)
+ expect(json_response.first).to include("id" => job_5.id)
end
end
- context 'when invalid status is provided' do
- it 'return 400' do
+ context "when invalid status is provided" do
+ it "return 400" do
get api("/runners/#{project_runner.id}/jobs?status=non-existing", admin)
expect(response).to have_gitlab_http_status(400)
@@ -594,8 +594,8 @@ describe API::Runners do
end
context "when runner doesn't exist" do
- it 'returns 404' do
- get api('/runners/0/jobs', admin)
+ it "returns 404" do
+ get api("/runners/0/jobs", admin)
expect(response).to have_gitlab_http_status(404)
end
@@ -603,17 +603,17 @@ describe API::Runners do
end
context "runner project's administrative user" do
- context 'when runner exists' do
- context 'when runner is shared' do
- it 'returns 403' do
+ context "when runner exists" do
+ context "when runner is shared" do
+ it "returns 403" do
get api("/runners/#{shared_runner.id}/jobs", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when runner is specific' do
- it 'return jobs' do
+ context "when runner is specific" do
+ it "return jobs" do
get api("/runners/#{project_runner.id}/jobs", user)
expect(response).to have_gitlab_http_status(200)
@@ -624,8 +624,8 @@ describe API::Runners do
end
end
- context 'when valid status is provided' do
- it 'return filtered jobs' do
+ context "when valid status is provided" do
+ it "return filtered jobs" do
get api("/runners/#{project_runner.id}/jobs?status=failed", user)
expect(response).to have_gitlab_http_status(200)
@@ -633,12 +633,12 @@ describe API::Runners do
expect(json_response).to be_an(Array)
expect(json_response.length).to eq(1)
- expect(json_response.first).to include('id' => job_5.id)
+ expect(json_response.first).to include("id" => job_5.id)
end
end
- context 'when invalid status is provided' do
- it 'return 400' do
+ context "when invalid status is provided" do
+ it "return 400" do
get api("/runners/#{project_runner.id}/jobs?status=non-existing", user)
expect(response).to have_gitlab_http_status(400)
@@ -647,24 +647,24 @@ describe API::Runners do
end
context "when runner doesn't exist" do
- it 'returns 404' do
- get api('/runners/0/jobs', user)
+ it "returns 404" do
+ get api("/runners/0/jobs", user)
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'other authorized user' do
- it 'does not return jobs' do
+ context "other authorized user" do
+ it "does not return jobs" do
get api("/runners/#{project_runner.id}/jobs", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not return jobs' do
+ context "unauthorized user" do
+ it "does not return jobs" do
get api("/runners/#{project_runner.id}/jobs")
expect(response).to have_gitlab_http_status(401)
@@ -672,86 +672,86 @@ describe API::Runners do
end
end
- describe 'GET /projects/:id/runners' do
- context 'authorized user with maintainer privileges' do
- it 'returns response status and headers' do
- get api('/runners/all', admin)
+ describe "GET /projects/:id/runners" do
+ context "authorized user with maintainer privileges" do
+ it "returns response status and headers" do
+ get api("/runners/all", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
end
- it 'returns all runners' do
+ it "returns all runners" do
get api("/projects/#{project.id}/runners", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner'),
- a_hash_including('description' => 'Shared runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
+ a_hash_including("description" => "Shared runner"),
]
end
- it 'filters runners by scope' do
+ it "filters runners by scope" do
get api("/projects/#{project.id}/runners?scope=specific", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
]
end
- it 'avoids filtering if scope is invalid' do
+ it "avoids filtering if scope is invalid" do
get api("/projects/#{project.id}/runners?scope=unknown", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by type' do
+ it "filters runners by type" do
get api("/projects/#{project.id}/runners?type=project_type", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Project runner'),
- a_hash_including('description' => 'Two projects runner')
+ a_hash_including("description" => "Project runner"),
+ a_hash_including("description" => "Two projects runner"),
]
end
- it 'does not filter by invalid type' do
+ it "does not filter by invalid type" do
get api("/projects/#{project.id}/runners?type=bogus", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by status' do
- create(:ci_runner, :project, :inactive, description: 'Inactive project runner', projects: [project])
+ it "filters runners by status" do
+ create(:ci_runner, :project, :inactive, description: "Inactive project runner", projects: [project])
get api("/projects/#{project.id}/runners?status=paused", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Inactive project runner')
+ a_hash_including("description" => "Inactive project runner"),
]
end
- it 'does not filter by invalid status' do
+ it "does not filter by invalid status" do
get api("/projects/#{project.id}/runners?status=bogus", user)
expect(response).to have_gitlab_http_status(400)
end
- it 'filters runners by tag_list' do
- create(:ci_runner, :project, description: 'Runner tagged with tag1 and tag2', projects: [project], tag_list: %w[tag1 tag2])
- create(:ci_runner, :project, description: 'Runner tagged with tag2', projects: [project], tag_list: ['tag2'])
+ it "filters runners by tag_list" do
+ create(:ci_runner, :project, description: "Runner tagged with tag1 and tag2", projects: [project], tag_list: %w[tag1 tag2])
+ create(:ci_runner, :project, description: "Runner tagged with tag2", projects: [project], tag_list: ["tag2"])
get api("/projects/#{project.id}/runners?tag_list=tag1,tag2", user)
expect(json_response).to match_array [
- a_hash_including('description' => 'Runner tagged with tag1 and tag2')
+ a_hash_including("description" => "Runner tagged with tag1 and tag2"),
]
end
end
- context 'authorized user without maintainer privileges' do
+ context "authorized user without maintainer privileges" do
it "does not return project's runners" do
get api("/projects/#{project.id}/runners", user2)
@@ -759,7 +759,7 @@ describe API::Runners do
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
it "does not return project's runners" do
get api("/projects/#{project.id}/runners")
@@ -768,95 +768,95 @@ describe API::Runners do
end
end
- describe 'POST /projects/:id/runners' do
- context 'authorized user' do
+ describe "POST /projects/:id/runners" do
+ context "authorized user" do
let(:project_runner2) { create(:ci_runner, :project, projects: [project2]) }
- it 'enables specific runner' do
- expect do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id }
- end.to change { project.runners.count }.by(+1)
+ it "enables specific runner" do
+ expect {
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: project_runner2.id}
+ }.to change { project.runners.count }.by(+1)
expect(response).to have_gitlab_http_status(201)
end
- it 'avoids changes when enabling already enabled runner' do
- expect do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner.id }
- end.to change { project.runners.count }.by(0)
+ it "avoids changes when enabling already enabled runner" do
+ expect {
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: project_runner.id}
+ }.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(400)
end
- it 'does not enable locked runner' do
+ it "does not enable locked runner" do
project_runner2.update(locked: true)
- expect do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: project_runner2.id }
- end.to change { project.runners.count }.by(0)
+ expect {
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: project_runner2.id}
+ }.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(403)
end
- it 'does not enable shared runner' do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: shared_runner.id }
+ it "does not enable shared runner" do
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: shared_runner.id}
expect(response).to have_gitlab_http_status(403)
end
- it 'does not enable group runner' do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: group_runner.id }
+ it "does not enable group runner" do
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: group_runner.id}
expect(response).to have_http_status(403)
end
- context 'user is admin' do
- context 'when project runner is used' do
+ context "user is admin" do
+ context "when project runner is used" do
let!(:new_project_runner) { create(:ci_runner, :project) }
- it 'enables any specific runner' do
- expect do
- post api("/projects/#{project.id}/runners", admin), params: { runner_id: new_project_runner.id }
- end.to change { project.runners.count }.by(+1)
+ it "enables any specific runner" do
+ expect {
+ post api("/projects/#{project.id}/runners", admin), params: {runner_id: new_project_runner.id}
+ }.to change { project.runners.count }.by(+1)
expect(response).to have_gitlab_http_status(201)
end
end
- it 'enables a instance type runner' do
- expect do
- post api("/projects/#{project.id}/runners", admin), params: { runner_id: shared_runner.id }
- end.to change { project.runners.count }.by(1)
+ it "enables a instance type runner" do
+ expect {
+ post api("/projects/#{project.id}/runners", admin), params: {runner_id: shared_runner.id}
+ }.to change { project.runners.count }.by(1)
expect(shared_runner.reload).not_to be_instance_type
expect(response).to have_gitlab_http_status(201)
end
end
- it 'raises 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_gitlab_http_status(400)
end
end
- context 'user is not admin' do
+ context "user is not admin" do
let!(:new_project_runner) { create(:ci_runner, :project) }
- it 'does not enable runner without access to' do
- post api("/projects/#{project.id}/runners", user), params: { runner_id: new_project_runner.id }
+ it "does not enable runner without access to" do
+ post api("/projects/#{project.id}/runners", user), params: {runner_id: new_project_runner.id}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'authorized user without permissions' do
- it 'does not enable runner' do
+ context "authorized user without permissions" do
+ it "does not enable runner" do
post api("/projects/#{project.id}/runners", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not enable runner' do
+ context "unauthorized user" do
+ it "does not enable runner" do
post api("/projects/#{project.id}/runners")
expect(response).to have_gitlab_http_status(401)
@@ -864,39 +864,39 @@ describe API::Runners do
end
end
- describe 'DELETE /projects/:id/runners/:runner_id' do
- context 'authorized user' do
- context 'when runner have more than one associated projects' do
+ describe "DELETE /projects/:id/runners/:runner_id" do
+ context "authorized user" do
+ context "when runner have more than one associated projects" do
it "disables project's runner" do
- expect do
+ expect {
delete api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { project.runners.count }.by(-1)
+ }.to change { project.runners.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/runners/#{two_projects_runner.id}", user) }
end
end
- context 'when runner have one associated projects' do
+ context "when runner have one associated projects" do
it "does not disable project's runner" do
- expect do
+ expect {
delete api("/projects/#{project.id}/runners/#{project_runner.id}", user)
- end.to change { project.runners.count }.by(0)
+ }.to change { project.runners.count }.by(0)
expect(response).to have_gitlab_http_status(403)
end
end
- it 'returns 404 is runner is not found' do
+ it "returns 404 is runner is not found" do
delete api("/projects/#{project.id}/runners/0", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authorized user without permissions' do
+ context "authorized user without permissions" do
it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{project_runner.id}", user2)
@@ -904,7 +904,7 @@ describe API::Runners do
end
end
- context 'unauthorized user' do
+ context "unauthorized user" do
it "does not disable project's runner" do
delete api("/projects/#{project.id}/runners/#{project_runner.id}")
diff --git a/spec/requests/api/search_spec.rb b/spec/requests/api/search_spec.rb
index c48ca832c85..5c430e2ed46 100644
--- a/spec/requests/api/search_spec.rb
+++ b/spec/requests/api/search_spec.rb
@@ -1,336 +1,336 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Search do
set(:user) { create(:user) }
set(:group) { create(:group) }
- set(:project) { create(:project, :wiki_repo, :public, name: 'awesome project', group: group) }
+ set(:project) { create(:project, :wiki_repo, :public, name: "awesome project", group: group) }
set(:repo_project) { create(:project, :public, :repository, group: group) }
- shared_examples 'response is correct' do |schema:, size: 1|
+ shared_examples "response is correct" do |schema:, size: 1|
it { expect(response).to have_gitlab_http_status(200) }
it { expect(response).to match_response_schema(schema) }
it { expect(response).to include_limited_pagination_headers }
it { expect(json_response.size).to eq(size) }
end
- describe 'GET /search' do
- context 'when user is not authenticated' do
- it 'returns 401 error' do
- get api('/search'), params: { scope: 'projects', search: 'awesome' }
+ describe "GET /search" do
+ context "when user is not authenticated" do
+ it "returns 401 error" do
+ get api("/search"), params: {scope: "projects", search: "awesome"}
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when scope is not supported' do
- it 'returns 400 error' do
- get api('/search', user), params: { scope: 'unsupported', search: 'awesome' }
+ context "when scope is not supported" do
+ it "returns 400 error" do
+ get api("/search", user), params: {scope: "unsupported", search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when scope is missing' do
- it 'returns 400 error' do
- get api('/search', user), params: { search: 'awesome' }
+ context "when scope is missing" do
+ it "returns 400 error" do
+ get api("/search", user), params: {search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'with correct params' do
- context 'for projects scope' do
+ context "with correct params" do
+ context "for projects scope" do
before do
- get api('/search', user), params: { scope: 'projects', search: 'awesome' }
+ get api("/search", user), params: {scope: "projects", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
+ it_behaves_like "response is correct", schema: "public_api/v4/projects"
end
- context 'for issues scope' do
+ context "for issues scope" do
before do
- create(:issue, project: project, title: 'awesome issue')
+ create(:issue, project: project, title: "awesome issue")
- get api('/search', user), params: { scope: 'issues', search: 'awesome' }
+ get api("/search", user), params: {scope: "issues", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
+ it_behaves_like "response is correct", schema: "public_api/v4/issues"
end
- context 'for merge_requests scope' do
+ context "for merge_requests scope" do
before do
- create(:merge_request, source_project: repo_project, title: 'awesome mr')
+ create(:merge_request, source_project: repo_project, title: "awesome mr")
- get api('/search', user), params: { scope: 'merge_requests', search: 'awesome' }
+ get api("/search", user), params: {scope: "merge_requests", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
+ it_behaves_like "response is correct", schema: "public_api/v4/merge_requests"
end
- context 'for milestones scope' do
+ context "for milestones scope" do
before do
- create(:milestone, project: project, title: 'awesome milestone')
+ create(:milestone, project: project, title: "awesome milestone")
- get api('/search', user), params: { scope: 'milestones', search: 'awesome' }
+ get api("/search", user), params: {scope: "milestones", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
+ it_behaves_like "response is correct", schema: "public_api/v4/milestones"
end
- context 'for snippet_titles scope' do
+ context "for snippet_titles scope" do
before do
- create(:snippet, :public, title: 'awesome snippet', content: 'snippet content')
+ create(:snippet, :public, title: "awesome snippet", content: "snippet content")
- get api('/search', user), params: { scope: 'snippet_titles', search: 'awesome' }
+ get api("/search", user), params: {scope: "snippet_titles", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/snippets'
+ it_behaves_like "response is correct", schema: "public_api/v4/snippets"
end
- context 'for snippet_blobs scope' do
+ context "for snippet_blobs scope" do
before do
- create(:snippet, :public, title: 'awesome snippet', content: 'snippet content')
+ create(:snippet, :public, title: "awesome snippet", content: "snippet content")
- get api('/search', user), params: { scope: 'snippet_blobs', search: 'content' }
+ get api("/search", user), params: {scope: "snippet_blobs", search: "content"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/snippets'
+ it_behaves_like "response is correct", schema: "public_api/v4/snippets"
end
end
end
describe "GET /groups/:id/search" do
- context 'when user is not authenticated' do
- it 'returns 401 error' do
- get api("/groups/#{group.id}/search"), params: { scope: 'projects', search: 'awesome' }
+ context "when user is not authenticated" do
+ it "returns 401 error" do
+ get api("/groups/#{group.id}/search"), params: {scope: "projects", search: "awesome"}
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when scope is not supported' do
- it 'returns 400 error' do
- get api("/groups/#{group.id}/search", user), params: { scope: 'unsupported', search: 'awesome' }
+ context "when scope is not supported" do
+ it "returns 400 error" do
+ get api("/groups/#{group.id}/search", user), params: {scope: "unsupported", search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when scope is missing' do
- it 'returns 400 error' do
- get api("/groups/#{group.id}/search", user), params: { search: 'awesome' }
+ context "when scope is missing" do
+ it "returns 400 error" do
+ get api("/groups/#{group.id}/search", user), params: {search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when group does not exist' do
- it 'returns 404 error' do
- get api('/groups/0/search', user), params: { scope: 'issues', search: 'awesome' }
+ context "when group does not exist" do
+ it "returns 404 error" do
+ get api("/groups/0/search", user), params: {scope: "issues", search: "awesome"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user does can not see the group' do
- it 'returns 404 error' do
+ context "when user does can not see the group" do
+ it "returns 404 error" do
private_group = create(:group, :private)
- get api("/groups/#{private_group.id}/search", user), params: { scope: 'issues', search: 'awesome' }
+ get api("/groups/#{private_group.id}/search", user), params: {scope: "issues", search: "awesome"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with correct params' do
- context 'for projects scope' do
+ context "with correct params" do
+ context "for projects scope" do
before do
- get api("/groups/#{group.id}/search", user), params: { scope: 'projects', search: 'awesome' }
+ get api("/groups/#{group.id}/search", user), params: {scope: "projects", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/projects'
+ it_behaves_like "response is correct", schema: "public_api/v4/projects"
end
- context 'for issues scope' do
+ context "for issues scope" do
before do
- create(:issue, project: project, title: 'awesome issue')
+ create(:issue, project: project, title: "awesome issue")
- get api("/groups/#{group.id}/search", user), params: { scope: 'issues', search: 'awesome' }
+ get api("/groups/#{group.id}/search", user), params: {scope: "issues", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
+ it_behaves_like "response is correct", schema: "public_api/v4/issues"
end
- context 'for merge_requests scope' do
+ context "for merge_requests scope" do
before do
- create(:merge_request, source_project: repo_project, title: 'awesome mr')
+ create(:merge_request, source_project: repo_project, title: "awesome mr")
- get api("/groups/#{group.id}/search", user), params: { scope: 'merge_requests', search: 'awesome' }
+ get api("/groups/#{group.id}/search", user), params: {scope: "merge_requests", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
+ it_behaves_like "response is correct", schema: "public_api/v4/merge_requests"
end
- context 'for milestones scope' do
+ context "for milestones scope" do
before do
- create(:milestone, project: project, title: 'awesome milestone')
+ create(:milestone, project: project, title: "awesome milestone")
- get api("/groups/#{group.id}/search", user), params: { scope: 'milestones', search: 'awesome' }
+ get api("/groups/#{group.id}/search", user), params: {scope: "milestones", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
+ it_behaves_like "response is correct", schema: "public_api/v4/milestones"
end
- context 'for milestones scope with group path as id' do
+ context "for milestones scope with group path as id" do
before do
another_project = create(:project, :public)
- create(:milestone, project: project, title: 'awesome milestone')
- create(:milestone, project: another_project, title: 'awesome milestone other project')
+ create(:milestone, project: project, title: "awesome milestone")
+ create(:milestone, project: another_project, title: "awesome milestone other project")
- get api("/groups/#{CGI.escape(group.full_path)}/search", user), params: { scope: 'milestones', search: 'awesome' }
+ get api("/groups/#{CGI.escape(group.full_path)}/search", user), params: {scope: "milestones", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
+ it_behaves_like "response is correct", schema: "public_api/v4/milestones"
end
end
end
describe "GET /projects/:id/search" do
- context 'when user is not authenticated' do
- it 'returns 401 error' do
- get api("/projects/#{project.id}/search"), params: { scope: 'issues', search: 'awesome' }
+ context "when user is not authenticated" do
+ it "returns 401 error" do
+ get api("/projects/#{project.id}/search"), params: {scope: "issues", search: "awesome"}
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when scope is not supported' do
- it 'returns 400 error' do
- get api("/projects/#{project.id}/search", user), params: { scope: 'unsupported', search: 'awesome' }
+ context "when scope is not supported" do
+ it "returns 400 error" do
+ get api("/projects/#{project.id}/search", user), params: {scope: "unsupported", search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when scope is missing' do
- it 'returns 400 error' do
- get api("/projects/#{project.id}/search", user), params: { search: 'awesome' }
+ context "when scope is missing" do
+ it "returns 400 error" do
+ get api("/projects/#{project.id}/search", user), params: {search: "awesome"}
expect(response).to have_gitlab_http_status(400)
end
end
- context 'when project does not exist' do
- it 'returns 404 error' do
- get api('/projects/0/search', user), params: { scope: 'issues', search: 'awesome' }
+ context "when project does not exist" do
+ it "returns 404 error" do
+ get api("/projects/0/search", user), params: {scope: "issues", search: "awesome"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user does can not see the project' do
- it 'returns 404 error' do
+ context "when user does can not see the project" do
+ it "returns 404 error" do
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' }
+ get api("/projects/#{project.id}/search", user), params: {scope: "issues", search: "awesome"}
expect(response).to have_gitlab_http_status(404)
end
end
- context 'with correct params' do
- context 'for issues scope' do
+ context "with correct params" do
+ context "for issues scope" do
before do
- create(:issue, project: project, title: 'awesome issue')
+ create(:issue, project: project, title: "awesome issue")
- get api("/projects/#{project.id}/search", user), params: { scope: 'issues', search: 'awesome' }
+ get api("/projects/#{project.id}/search", user), params: {scope: "issues", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/issues'
+ it_behaves_like "response is correct", schema: "public_api/v4/issues"
end
- context 'for merge_requests scope' do
+ context "for merge_requests scope" do
before do
- create(:merge_request, source_project: repo_project, title: 'awesome mr')
+ create(:merge_request, source_project: repo_project, title: "awesome mr")
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'merge_requests', search: 'awesome' }
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "merge_requests", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/merge_requests'
+ it_behaves_like "response is correct", schema: "public_api/v4/merge_requests"
end
- context 'for milestones scope' do
+ context "for milestones scope" do
before do
- create(:milestone, project: project, title: 'awesome milestone')
+ create(:milestone, project: project, title: "awesome milestone")
- get api("/projects/#{project.id}/search", user), params: { scope: 'milestones', search: 'awesome' }
+ get api("/projects/#{project.id}/search", user), params: {scope: "milestones", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/milestones'
+ it_behaves_like "response is correct", schema: "public_api/v4/milestones"
end
- context 'for notes scope' do
+ context "for notes scope" do
before do
- create(:note_on_merge_request, project: project, note: 'awesome note')
+ create(:note_on_merge_request, project: project, note: "awesome note")
- get api("/projects/#{project.id}/search", user), params: { scope: 'notes', search: 'awesome' }
+ get api("/projects/#{project.id}/search", user), params: {scope: "notes", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/notes'
+ it_behaves_like "response is correct", schema: "public_api/v4/notes"
end
- context 'for wiki_blobs scope' do
+ context "for wiki_blobs scope" do
before do
wiki = create(:project_wiki, project: project)
- create(:wiki_page, wiki: wiki, attrs: { title: 'home', content: "Awesome page" })
+ create(:wiki_page, wiki: wiki, attrs: {title: "home", content: "Awesome page"})
- get api("/projects/#{project.id}/search", user), params: { scope: 'wiki_blobs', search: 'awesome' }
+ get api("/projects/#{project.id}/search", user), params: {scope: "wiki_blobs", search: "awesome"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/blobs'
+ it_behaves_like "response is correct", schema: "public_api/v4/blobs"
end
- context 'for commits scope' do
+ context "for commits scope" do
before do
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' }
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "commits", search: "498214de67004b1da3d820901307bed2a68a8ef6"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
+ it_behaves_like "response is correct", schema: "public_api/v4/commits_details"
end
- context 'for commits scope with project path as id' do
+ context "for commits scope with project path as id" do
before do
- get api("/projects/#{CGI.escape(repo_project.full_path)}/search", user), params: { scope: 'commits', search: '498214de67004b1da3d820901307bed2a68a8ef6' }
+ get api("/projects/#{CGI.escape(repo_project.full_path)}/search", user), params: {scope: "commits", search: "498214de67004b1da3d820901307bed2a68a8ef6"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/commits_details'
+ it_behaves_like "response is correct", schema: "public_api/v4/commits_details"
end
- context 'for blobs scope' do
+ context "for blobs scope" do
before do
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'monitors' }
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "blobs", search: "monitors"}
end
- it_behaves_like 'response is correct', schema: 'public_api/v4/blobs', size: 2
+ it_behaves_like "response is correct", schema: "public_api/v4/blobs", size: 2
- context 'filters' do
- it 'by filename' do
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon filename:PROCESS.md' }
+ context "filters" do
+ it "by filename" do
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "blobs", search: "mon filename:PROCESS.md"}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(2)
- expect(json_response.first['filename']).to eq('PROCESS.md')
+ expect(json_response.first["filename"]).to eq("PROCESS.md")
end
- it 'by path' do
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon path:markdown' }
+ it "by path" do
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "blobs", search: "mon path:markdown"}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(8)
end
- it 'by extension' do
- get api("/projects/#{repo_project.id}/search", user), params: { scope: 'blobs', search: 'mon extension:md' }
+ it "by extension" do
+ get api("/projects/#{repo_project.id}/search", user), params: {scope: "blobs", search: "mon extension:md"}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(11)
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index e260aa21e25..cb9552b0fe7 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -31,11 +31,11 @@ describe API::Services do
it "returns if required fields missing" do
attrs = service_attrs
- required_attributes = service_attrs_list.select do |attr|
+ required_attributes = service_attrs_list.select { |attr|
service_klass.validators_on(attr).any? do |v|
v.class == ActiveRecord::Validations::PresenceValidator
end
- end
+ }
if required_attributes.empty?
expected_code = 200
@@ -74,7 +74,7 @@ describe API::Services do
initialize_service(service)
end
- it 'returns authentication error when unauthenticated' do
+ it "returns authentication error when unauthenticated" do
get api("/projects/#{project.id}/services/#{dashed_service}")
expect(response).to have_gitlab_http_status(401)
end
@@ -83,14 +83,14 @@ describe API::Services do
get api("/projects/#{project.id}/services/#{dashed_service}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['properties'].keys).to match_array(service_instance.api_field_names)
+ expect(json_response["properties"].keys).to match_array(service_instance.api_field_names)
end
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_gitlab_http_status(200)
- expect(json_response['properties'].keys).to match_array(service_instance.api_field_names)
+ expect(json_response["properties"].keys).to match_array(service_instance.api_field_names)
end
it "returns error when authenticated but not a project owner" do
@@ -102,12 +102,12 @@ describe API::Services do
end
end
- describe 'POST /projects/:id/services/:slug/trigger' do
- describe 'Mattermost Service' do
- let(:service_name) { 'mattermost_slash_commands' }
+ describe "POST /projects/:id/services/:slug/trigger" do
+ describe "Mattermost Service" do
+ let(:service_name) { "mattermost_slash_commands" }
- context 'no service is available' do
- it 'returns a not found message' do
+ context "no service is available" do
+ it "returns a not found message" do
post api("/projects/#{project.id}/services/idonotexist/trigger")
expect(response).to have_gitlab_http_status(404)
@@ -115,10 +115,10 @@ describe API::Services do
end
end
- context 'the service exists' do
- let(:params) { { token: 'token' } }
+ context "the service exists" do
+ let(:params) { {token: "token"} }
- context 'the service is not active' do
+ context "the service is not active" do
before do
project.create_mattermost_slash_commands_service(
active: false,
@@ -126,14 +126,14 @@ describe API::Services do
)
end
- it 'when the service is inactive' do
+ it "when the service is inactive" do
post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(404)
end
end
- context 'the service is active' do
+ context "the service is active" do
before do
project.create_mattermost_slash_commands_service(
active: true,
@@ -141,15 +141,15 @@ describe API::Services do
)
end
- it 'returns status 200' do
+ it "returns status 200" do
post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(200)
end
end
- context 'when the project can not be found' do
- it 'returns a generic 404' do
+ context "when the project can not be found" do
+ it "returns a generic 404" do
post api("/projects/404/services/#{service_name}/trigger"), params: params
expect(response).to have_gitlab_http_status(404)
@@ -159,29 +159,29 @@ describe API::Services do
end
end
- describe 'Slack Service' do
- let(:service_name) { 'slack_slash_commands' }
+ describe "Slack Service" do
+ let(:service_name) { "slack_slash_commands" }
before do
project.create_slack_slash_commands_service(
active: true,
- properties: { token: 'token' }
+ properties: {token: "token"}
)
end
- it 'returns status 200' do
- post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: { token: 'token', text: 'help' }
+ it "returns status 200" do
+ post api("/projects/#{project.id}/services/#{service_name}/trigger"), params: {token: "token", text: "help"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['response_type']).to eq("ephemeral")
+ expect(json_response["response_type"]).to eq("ephemeral")
end
end
end
- describe 'Mattermost service' do
- let(:service_name) { 'mattermost' }
+ describe "Mattermost service" do
+ let(:service_name) { "mattermost" }
let(:params) do
- { webhook: 'https://hook.example.com', username: 'username' }
+ {webhook: "https://hook.example.com", username: "username"}
end
before do
@@ -191,11 +191,11 @@ describe API::Services do
)
end
- it 'accepts a username for update' do
- put api("/projects/#{project.id}/services/mattermost", user), params: params.merge(username: 'new_username')
+ it "accepts a username for update" do
+ put api("/projects/#{project.id}/services/mattermost", user), params: params.merge(username: "new_username")
expect(response).to have_gitlab_http_status(200)
- expect(json_response['properties']['username']).to eq('new_username')
+ expect(json_response["properties"]["username"]).to eq("new_username")
end
end
end
diff --git a/spec/requests/api/settings_spec.rb b/spec/requests/api/settings_spec.rb
index f33eb5b9e02..68da45e2484 100644
--- a/spec/requests/api/settings_spec.rb
+++ b/spec/requests/api/settings_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe API::Settings, 'Settings' do
+describe API::Settings, "Settings" do
let(:user) { create(:user) }
set(:admin) { create(:admin) }
@@ -10,22 +10,22 @@ describe API::Settings, 'Settings' do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Hash
- expect(json_response['default_projects_limit']).to eq(42)
- expect(json_response['password_authentication_enabled_for_web']).to be_truthy
- expect(json_response['repository_storages']).to eq(['default'])
- expect(json_response['plantuml_enabled']).to be_falsey
- expect(json_response['plantuml_url']).to be_nil
- expect(json_response['default_project_visibility']).to be_a String
- expect(json_response['default_snippet_visibility']).to be_a String
- expect(json_response['default_group_visibility']).to be_a String
- expect(json_response['rsa_key_restriction']).to eq(0)
- expect(json_response['dsa_key_restriction']).to eq(0)
- expect(json_response['ecdsa_key_restriction']).to eq(0)
- expect(json_response['ed25519_key_restriction']).to eq(0)
- expect(json_response['performance_bar_allowed_group_id']).to be_nil
- expect(json_response['instance_statistics_visibility_private']).to be(false)
- expect(json_response).not_to have_key('performance_bar_allowed_group_path')
- expect(json_response).not_to have_key('performance_bar_enabled')
+ expect(json_response["default_projects_limit"]).to eq(42)
+ expect(json_response["password_authentication_enabled_for_web"]).to be_truthy
+ expect(json_response["repository_storages"]).to eq(["default"])
+ expect(json_response["plantuml_enabled"]).to be_falsey
+ expect(json_response["plantuml_url"]).to be_nil
+ expect(json_response["default_project_visibility"]).to be_a String
+ expect(json_response["default_snippet_visibility"]).to be_a String
+ expect(json_response["default_group_visibility"]).to be_a String
+ expect(json_response["rsa_key_restriction"]).to eq(0)
+ expect(json_response["dsa_key_restriction"]).to eq(0)
+ expect(json_response["ecdsa_key_restriction"]).to eq(0)
+ expect(json_response["ed25519_key_restriction"]).to eq(0)
+ expect(json_response["performance_bar_allowed_group_id"]).to be_nil
+ expect(json_response["instance_statistics_visibility_private"]).to be(false)
+ expect(json_response).not_to have_key("performance_bar_allowed_group_path")
+ expect(json_response).not_to have_key("performance_bar_enabled")
end
end
@@ -36,7 +36,7 @@ describe API::Settings, 'Settings' do
before do
# Add a possible storage to the config
storages = Gitlab.config.repositories.storages
- .merge({ 'custom' => 'tmp/tests/custom_repositories' })
+ .merge({"custom" => "tmp/tests/custom_repositories"})
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
@@ -45,81 +45,81 @@ describe API::Settings, 'Settings' do
params: {
default_projects_limit: 3,
password_authentication_enabled_for_web: false,
- repository_storages: ['custom'],
+ repository_storages: ["custom"],
plantuml_enabled: true,
- plantuml_url: 'http://plantuml.example.com',
- default_snippet_visibility: 'internal',
- restricted_visibility_levels: ['public'],
- default_artifacts_expire_in: '2 days',
- help_page_text: 'custom help text',
+ plantuml_url: "http://plantuml.example.com",
+ default_snippet_visibility: "internal",
+ restricted_visibility_levels: ["public"],
+ default_artifacts_expire_in: "2 days",
+ help_page_text: "custom help text",
help_page_hide_commercial_content: true,
- help_page_support_url: 'http://example.com/help',
+ help_page_support_url: "http://example.com/help",
project_export_enabled: false,
rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE,
dsa_key_restriction: 2048,
ecdsa_key_restriction: 384,
ed25519_key_restriction: 256,
enforce_terms: true,
- terms: 'Hello world!',
+ terms: "Hello world!",
performance_bar_allowed_group_path: group.full_path,
instance_statistics_visibility_private: true,
diff_max_patch_bytes: 150_000,
default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_MERGE,
- local_markdown_version: 3
+ local_markdown_version: 3,
}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['default_projects_limit']).to eq(3)
- expect(json_response['password_authentication_enabled_for_web']).to be_falsey
- expect(json_response['repository_storages']).to eq(['custom'])
- expect(json_response['plantuml_enabled']).to be_truthy
- expect(json_response['plantuml_url']).to eq('http://plantuml.example.com')
- expect(json_response['default_snippet_visibility']).to eq('internal')
- expect(json_response['restricted_visibility_levels']).to eq(['public'])
- expect(json_response['default_artifacts_expire_in']).to eq('2 days')
- expect(json_response['help_page_text']).to eq('custom help text')
- expect(json_response['help_page_hide_commercial_content']).to be_truthy
- expect(json_response['help_page_support_url']).to eq('http://example.com/help')
- expect(json_response['project_export_enabled']).to be_falsey
- expect(json_response['rsa_key_restriction']).to eq(ApplicationSetting::FORBIDDEN_KEY_VALUE)
- expect(json_response['dsa_key_restriction']).to eq(2048)
- expect(json_response['ecdsa_key_restriction']).to eq(384)
- expect(json_response['ed25519_key_restriction']).to eq(256)
- expect(json_response['enforce_terms']).to be(true)
- expect(json_response['terms']).to eq('Hello world!')
- expect(json_response['performance_bar_allowed_group_id']).to eq(group.id)
- expect(json_response['instance_statistics_visibility_private']).to be(true)
- expect(json_response['diff_max_patch_bytes']).to eq(150_000)
- expect(json_response['default_branch_protection']).to eq(Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
- expect(json_response['local_markdown_version']).to eq(3)
+ expect(json_response["default_projects_limit"]).to eq(3)
+ expect(json_response["password_authentication_enabled_for_web"]).to be_falsey
+ expect(json_response["repository_storages"]).to eq(["custom"])
+ expect(json_response["plantuml_enabled"]).to be_truthy
+ expect(json_response["plantuml_url"]).to eq("http://plantuml.example.com")
+ expect(json_response["default_snippet_visibility"]).to eq("internal")
+ expect(json_response["restricted_visibility_levels"]).to eq(["public"])
+ expect(json_response["default_artifacts_expire_in"]).to eq("2 days")
+ expect(json_response["help_page_text"]).to eq("custom help text")
+ expect(json_response["help_page_hide_commercial_content"]).to be_truthy
+ expect(json_response["help_page_support_url"]).to eq("http://example.com/help")
+ expect(json_response["project_export_enabled"]).to be_falsey
+ expect(json_response["rsa_key_restriction"]).to eq(ApplicationSetting::FORBIDDEN_KEY_VALUE)
+ expect(json_response["dsa_key_restriction"]).to eq(2048)
+ expect(json_response["ecdsa_key_restriction"]).to eq(384)
+ expect(json_response["ed25519_key_restriction"]).to eq(256)
+ expect(json_response["enforce_terms"]).to be(true)
+ expect(json_response["terms"]).to eq("Hello world!")
+ expect(json_response["performance_bar_allowed_group_id"]).to eq(group.id)
+ expect(json_response["instance_statistics_visibility_private"]).to be(true)
+ expect(json_response["diff_max_patch_bytes"]).to eq(150_000)
+ expect(json_response["default_branch_protection"]).to eq(Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
+ expect(json_response["local_markdown_version"]).to eq(3)
end
end
it "supports legacy performance_bar_allowed_group_id" do
put api("/application/settings", admin),
- params: { performance_bar_allowed_group_id: group.full_path }
+ params: {performance_bar_allowed_group_id: group.full_path}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['performance_bar_allowed_group_id']).to eq(group.id)
+ expect(json_response["performance_bar_allowed_group_id"]).to eq(group.id)
end
it "supports legacy performance_bar_enabled" do
put api("/application/settings", admin),
params: {
performance_bar_enabled: false,
- performance_bar_allowed_group_id: group.full_path
+ performance_bar_allowed_group_id: group.full_path,
}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['performance_bar_allowed_group_id']).to be_nil
+ expect(json_response["performance_bar_allowed_group_id"]).to be_nil
end
context "missing plantuml_url value when plantuml_enabled is true" do
it "returns a blank parameter error message" do
- put api("/application/settings", admin), params: { plantuml_enabled: true }
+ put api("/application/settings", admin), params: {plantuml_enabled: true}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('plantuml_url is missing')
+ expect(json_response["error"]).to eq("plantuml_url is missing")
end
end
end
diff --git a/spec/requests/api/sidekiq_metrics_spec.rb b/spec/requests/api/sidekiq_metrics_spec.rb
index fff9adb7f57..230a2f14947 100644
--- a/spec/requests/api/sidekiq_metrics_spec.rb
+++ b/spec/requests/api/sidekiq_metrics_spec.rb
@@ -1,38 +1,38 @@
-require 'spec_helper'
+require "spec_helper"
describe API::SidekiqMetrics do
let(:admin) { create(:user, :admin) }
- describe 'GET sidekiq/*' do
- it 'defines the `queue_metrics` endpoint' do
- get api('/sidekiq/queue_metrics', admin)
+ describe "GET sidekiq/*" do
+ it "defines the `queue_metrics` endpoint" do
+ get api("/sidekiq/queue_metrics", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
end
- it 'defines the `process_metrics` endpoint' do
- get api('/sidekiq/process_metrics', admin)
+ it "defines the `process_metrics` endpoint" do
+ get api("/sidekiq/process_metrics", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['processes']).to be_an Array
+ expect(json_response["processes"]).to be_an Array
end
- it 'defines the `job_stats` endpoint' do
- get api('/sidekiq/job_stats', admin)
+ it "defines the `job_stats` endpoint" do
+ get api("/sidekiq/job_stats", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
end
- it 'defines the `compound_metrics` endpoint' do
- get api('/sidekiq/compound_metrics', admin)
+ it "defines the `compound_metrics` endpoint" do
+ get api("/sidekiq/compound_metrics", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a Hash
- expect(json_response['queues']).to be_a Hash
- expect(json_response['processes']).to be_an Array
- expect(json_response['jobs']).to be_a Hash
+ expect(json_response["queues"]).to be_a Hash
+ expect(json_response["processes"]).to be_an Array
+ expect(json_response["jobs"]).to be_a Hash
end
end
end
diff --git a/spec/requests/api/snippets_spec.rb b/spec/requests/api/snippets_spec.rb
index 7c8512f7589..b57a92b54eb 100644
--- a/spec/requests/api/snippets_spec.rb
+++ b/spec/requests/api/snippets_spec.rb
@@ -1,10 +1,10 @@
-require 'rails_helper'
+require "rails_helper"
describe API::Snippets do
let!(:user) { create(:user) }
- describe 'GET /snippets/' do
- it 'returns snippets available' do
+ describe "GET /snippets/" do
+ it "returns snippets available" do
public_snippet = create(:personal_snippet, :public, author: user)
private_snippet = create(:personal_snippet, :private, author: user)
internal_snippet = create(:personal_snippet, :internal, author: user)
@@ -14,16 +14,17 @@ describe API::Snippets do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
+ expect(json_response.map { |snippet| snippet["id"]}).to contain_exactly(
public_snippet.id,
internal_snippet.id,
- private_snippet.id)
- expect(json_response.last).to have_key('web_url')
- expect(json_response.last).to have_key('raw_url')
- expect(json_response.last).to have_key('visibility')
+ private_snippet.id
+ )
+ expect(json_response.last).to have_key("web_url")
+ expect(json_response.last).to have_key("raw_url")
+ expect(json_response.last).to have_key("visibility")
end
- it 'hides private snippets from regular user' do
+ it "hides private snippets from regular user" do
create(:personal_snippet, :private)
get api("/snippets/", user)
@@ -34,7 +35,7 @@ describe API::Snippets do
expect(json_response.size).to eq(0)
end
- it 'returns 404 for non-authenticated' do
+ it "returns 404 for non-authenticated" do
create(:personal_snippet, :internal)
get api("/snippets/")
@@ -42,7 +43,7 @@ describe API::Snippets do
expect(response).to have_gitlab_http_status(401)
end
- it 'does not return snippets related to a project with disable feature visibility' do
+ it "does not return snippets related to a project with disable feature visibility" do
project = create(:project)
create(:project_member, project: project, user: user)
public_snippet = create(:personal_snippet, :public, author: user, project: project)
@@ -56,7 +57,7 @@ describe API::Snippets do
end
end
- describe 'GET /snippets/public' do
+ describe "GET /snippets/public" do
let!(:other_user) { create(:user) }
let!(:public_snippet) { create(:personal_snippet, :public, author: user) }
let!(:private_snippet) { create(:personal_snippet, :private, author: user) }
@@ -65,95 +66,98 @@ describe API::Snippets do
let!(:private_snippet_other) { create(:personal_snippet, :private, author: other_user) }
let!(:internal_snippet_other) { create(:personal_snippet, :internal, author: other_user) }
- it 'returns all snippets with public visibility from all users' do
+ it "returns all snippets with public visibility from all users" do
get api("/snippets/public", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |snippet| snippet['id']} ).to contain_exactly(
+ expect(json_response.map { |snippet| snippet["id"]}).to contain_exactly(
public_snippet.id,
- public_snippet_other.id)
- expect(json_response.map { |snippet| snippet['web_url']} ).to include(
+ public_snippet_other.id
+ )
+ expect(json_response.map { |snippet| snippet["web_url"]}).to include(
"http://localhost/snippets/#{public_snippet.id}",
- "http://localhost/snippets/#{public_snippet_other.id}")
- expect(json_response.map { |snippet| snippet['raw_url']} ).to include(
+ "http://localhost/snippets/#{public_snippet_other.id}"
+ )
+ expect(json_response.map { |snippet| snippet["raw_url"]}).to include(
"http://localhost/snippets/#{public_snippet.id}/raw",
- "http://localhost/snippets/#{public_snippet_other.id}/raw")
+ "http://localhost/snippets/#{public_snippet_other.id}/raw"
+ )
end
end
- describe 'GET /snippets/:id/raw' do
+ describe "GET /snippets/:id/raw" do
let(:snippet) { create(:personal_snippet, author: user) }
- it 'returns raw text' do
+ it "returns raw text" do
get api("/snippets/#{snippet.id}/raw", user)
expect(response).to have_gitlab_http_status(200)
- expect(response.content_type).to eq 'text/plain'
+ expect(response.content_type).to eq "text/plain"
expect(response.body).to eq(snippet.content)
end
- it 'forces attachment content disposition' do
+ it "forces attachment content disposition" do
get api("/snippets/#{snippet.id}/raw", user)
- expect(headers['Content-Disposition']).to match(/^attachment/)
+ expect(headers["Content-Disposition"]).to match(/^attachment/)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
get api("/snippets/1234/raw", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
end
- describe 'GET /snippets/:id' do
+ describe "GET /snippets/:id" do
let(:snippet) { create(:personal_snippet, author: user) }
- it 'returns snippet json' do
+ it "returns snippet json" do
get api("/snippets/#{snippet.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(snippet.title)
- expect(json_response['description']).to eq(snippet.description)
- expect(json_response['file_name']).to eq(snippet.file_name)
- expect(json_response['visibility']).to eq(snippet.visibility)
+ expect(json_response["title"]).to eq(snippet.title)
+ expect(json_response["description"]).to eq(snippet.description)
+ expect(json_response["file_name"]).to eq(snippet.file_name)
+ expect(json_response["visibility"]).to eq(snippet.visibility)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
get api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Not found')
+ expect(json_response["message"]).to eq("404 Not found")
end
end
- describe 'POST /snippets/' do
+ describe "POST /snippets/" do
let(:params) do
{
- title: 'Test Title',
- file_name: 'test.rb',
- description: 'test description',
+ title: "Test Title",
+ file_name: "test.rb",
+ description: "test description",
content: 'puts "hello world"',
- visibility: 'public'
+ visibility: "public",
}
end
- it 'creates a new snippet' do
- expect do
+ it "creates a new snippet" do
+ expect {
post api("/snippets/", user), params: params
- end.to change { PersonalSnippet.count }.by(1)
+ }.to change { PersonalSnippet.count }.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq(params[:title])
- expect(json_response['description']).to eq(params[:description])
- expect(json_response['file_name']).to eq(params[:file_name])
- expect(json_response['visibility']).to eq(params[:visibility])
+ expect(json_response["title"]).to eq(params[:title])
+ expect(json_response["description"]).to eq(params[:description])
+ expect(json_response["file_name"]).to eq(params[:file_name])
+ expect(json_response["visibility"]).to eq(params[:visibility])
end
- it 'returns 400 for missing parameters' do
+ it "returns 400 for missing parameters" do
params.delete(:title)
post api("/snippets/", user), params: params
@@ -161,51 +165,51 @@ describe API::Snippets do
expect(response).to have_gitlab_http_status(400)
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
def create_snippet(snippet_params = {})
- post api('/snippets', user), params: params.merge(snippet_params)
+ post api("/snippets", user), params: params.merge(snippet_params)
end
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
- it 'creates the snippet' do
- expect { create_snippet(visibility: 'private') }
+ context "when the snippet is private" do
+ it "creates the snippet" do
+ expect { create_snippet(visibility: "private") }
.to change { Snippet.count }.by(1)
end
end
- context 'when the snippet is public' do
- it 'rejects the shippet' do
- expect { create_snippet(visibility: 'public') }
+ context "when the snippet is public" do
+ it "rejects the shippet" do
+ expect { create_snippet(visibility: "public") }
.not_to change { Snippet.count }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
end
- it 'creates a spam log' do
- expect { create_snippet(visibility: 'public') }
+ it "creates a spam log" do
+ expect { create_snippet(visibility: "public") }
.to change { SpamLog.count }.by(1)
end
end
end
end
- describe 'PUT /snippets/:id' do
+ describe "PUT /snippets/:id" do
let(:visibility_level) { Snippet::PUBLIC }
let(:other_user) { create(:user) }
let(:snippet) do
create(:personal_snippet, author: user, visibility_level: visibility_level)
end
- it 'updates snippet' do
- new_content = 'New content'
- new_description = 'New description'
+ it "updates snippet" do
+ new_content = "New content"
+ new_description = "New description"
- put api("/snippets/#{snippet.id}", user), params: { content: new_content, description: new_description }
+ put api("/snippets/#{snippet.id}", user), params: {content: new_content, description: new_description}
expect(response).to have_gitlab_http_status(200)
snippet.reload
@@ -213,27 +217,27 @@ describe API::Snippets do
expect(snippet.description).to eq(new_description)
end
- it 'returns 404 for invalid snippet id' do
- put api("/snippets/1234", user), params: { title: 'foo' }
+ it "returns 404 for invalid snippet id" do
+ put api("/snippets/1234", user), params: {title: "foo"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
it "returns 404 for another user's snippet" do
- put api("/snippets/#{snippet.id}", other_user), params: { title: 'fubar' }
+ put api("/snippets/#{snippet.id}", other_user), params: {title: "fubar"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
- it 'returns 400 for missing parameters' do
+ it "returns 400 for missing parameters" do
put api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(400)
end
- context 'when the snippet is spam' do
+ context "when the snippet is spam" do
def update_snippet(snippet_params = {})
put api("/snippets/#{snippet.id}", user), params: snippet_params
end
@@ -242,66 +246,66 @@ describe API::Snippets do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- context 'when the snippet is private' do
+ context "when the snippet is private" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'updates the snippet' do
- expect { update_snippet(title: 'Foo') }
- .to change { snippet.reload.title }.to('Foo')
+ it "updates the snippet" do
+ expect { update_snippet(title: "Foo") }
+ .to change { snippet.reload.title }.to("Foo")
end
end
- context 'when the snippet is public' do
+ context "when the snippet is public" do
let(:visibility_level) { Snippet::PUBLIC }
- it 'rejects the shippet' do
- expect { update_snippet(title: 'Foo') }
+ it "rejects the shippet" do
+ expect { update_snippet(title: "Foo") }
.not_to change { snippet.reload.title }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq({ "error" => "Spam detected" })
+ expect(json_response["message"]).to eq({"error" => "Spam detected"})
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo") }
.to change { SpamLog.count }.by(1)
end
end
- context 'when a private snippet is made public' do
+ context "when a private snippet is made public" do
let(:visibility_level) { Snippet::PRIVATE }
- it 'rejects the snippet' do
- expect { update_snippet(title: 'Foo', visibility: 'public') }
+ it "rejects the snippet" do
+ expect { update_snippet(title: "Foo", visibility: "public") }
.not_to change { snippet.reload.title }
end
- it 'creates a spam log' do
- expect { update_snippet(title: 'Foo', visibility: 'public') }
+ it "creates a spam log" do
+ expect { update_snippet(title: "Foo", visibility: "public") }
.to change { SpamLog.count }.by(1)
end
end
end
end
- describe 'DELETE /snippets/:id' do
+ describe "DELETE /snippets/:id" do
let!(:public_snippet) { create(:personal_snippet, :public, author: user) }
- it 'deletes snippet' do
- expect do
+ it "deletes snippet" do
+ expect {
delete api("/snippets/#{public_snippet.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { PersonalSnippet.count }.by(-1)
+ }.to change { PersonalSnippet.count }.by(-1)
end
- it 'returns 404 for invalid snippet id' do
+ it "returns 404 for invalid snippet id" do
delete api("/snippets/1234", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Snippet Not Found')
+ expect(json_response["message"]).to eq("404 Snippet Not Found")
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/snippets/#{public_snippet.id}", user) }
end
end
@@ -311,13 +315,13 @@ describe API::Snippets do
let(:snippet) { create(:personal_snippet, :public, author: user) }
let!(:user_agent_detail) { create(:user_agent_detail, subject: snippet) }
- it 'exposes known attributes' do
+ it "exposes known attributes" do
get api("/snippets/#{snippet.id}/user_agent_detail", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['user_agent']).to eq(user_agent_detail.user_agent)
- expect(json_response['ip_address']).to eq(user_agent_detail.ip_address)
- expect(json_response['akismet_submitted']).to eq(user_agent_detail.submitted)
+ expect(json_response["user_agent"]).to eq(user_agent_detail.user_agent)
+ expect(json_response["ip_address"]).to eq(user_agent_detail.ip_address)
+ expect(json_response["akismet_submitted"]).to eq(user_agent_detail.submitted)
end
it "returns unauthorized for non-admin users" do
diff --git a/spec/requests/api/submodules_spec.rb b/spec/requests/api/submodules_spec.rb
index 064392fb185..c0c77888509 100644
--- a/spec/requests/api/submodules_spec.rb
+++ b/spec/requests/api/submodules_spec.rb
@@ -1,22 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::Submodules do
let(:user) { create(:user) }
- let!(:project) { create(:project, :repository, namespace: user.namespace ) }
+ let!(:project) { create(:project, :repository, namespace: user.namespace) }
let(:guest) { create(:user) { |u| project.add_guest(u) } }
- let(:submodule) { 'six' }
- let(:commit_sha) { 'e25eda1fece24ac7a03624ed1320f82396f35bd8' }
- let(:branch) { 'master' }
- let(:commit_message) { 'whatever' }
+ let(:submodule) { "six" }
+ let(:commit_sha) { "e25eda1fece24ac7a03624ed1320f82396f35bd8" }
+ let(:branch) { "master" }
+ let(:commit_message) { "whatever" }
let(:params) do
{
submodule: submodule,
commit_sha: commit_sha,
branch: branch,
- commit_message: commit_message
+ commit_message: commit_message,
}
end
@@ -29,68 +29,68 @@ describe API::Submodules do
end
describe "PUT /projects/:id/repository/submodule/:submodule" do
- context 'when unauthenticated' do
- it 'returns 401' do
+ context "when unauthenticated" do
+ it "returns 401" do
put api(route(submodule)), params: params
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated', 'as a guest' do
- it 'returns 403' do
+ context "when authenticated", "as a guest" do
+ it "returns 403" do
put api(route(submodule), guest), params: params
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when authenticated', 'as a developer' do
- it 'returns 400 if params is missing' do
+ context "when authenticated", "as a developer" do
+ it "returns 400 if params is missing" do
put api(route(submodule), user)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 if branch is missing' do
+ it "returns 400 if branch is missing" do
put api(route(submodule), user), params: params.except(:branch)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 if commit_sha is missing' do
+ it "returns 400 if commit_sha is missing" do
put api(route(submodule), user), params: params.except(:commit_sha)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns the commit' do
+ it "returns the commit" do
head_commit = project.repository.commit.id
put api(route(submodule), user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['message']).to eq commit_message
- expect(json_response['author_name']).to eq user.name
- expect(json_response['committer_name']).to eq user.name
- expect(json_response['parent_ids'].first).to eq head_commit
+ expect(json_response["message"]).to eq commit_message
+ expect(json_response["author_name"]).to eq user.name
+ expect(json_response["committer_name"]).to eq user.name
+ expect(json_response["parent_ids"].first).to eq head_commit
end
- context 'when the submodule name is urlencoded' do
- let(:submodule) { 'test_inside_folder/another_folder/six' }
- let(:branch) { 'submodule_inside_folder' }
+ context "when the submodule name is urlencoded" do
+ let(:submodule) { "test_inside_folder/another_folder/six" }
+ let(:branch) { "submodule_inside_folder" }
let(:encoded_submodule) { CGI.escape(submodule) }
- it 'returns the commit' do
+ it "returns the commit" do
expect(Submodules::UpdateService)
.to receive(:new)
- .with(any_args, hash_including(submodule: submodule))
- .and_call_original
+ .with(any_args, hash_including(submodule: submodule))
+ .and_call_original
put api(route(encoded_submodule), user), params: params
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq project.repository.commit(branch).id
+ expect(json_response["id"]).to eq project.repository.commit(branch).id
expect(project.repository.blob_at(branch, submodule).id).to eq commit_sha
end
end
diff --git a/spec/requests/api/suggestions_spec.rb b/spec/requests/api/suggestions_spec.rb
index 3c2842e5725..b0def1ee6d4 100644
--- a/spec/requests/api/suggestions_spec.rb
+++ b/spec/requests/api/suggestions_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe API::Suggestions do
let(:project) { create(:project, :repository) }
@@ -28,55 +28,55 @@ describe API::Suggestions do
describe "PUT /suggestions/:id/apply" do
let(:url) { "/suggestions/#{suggestion.id}/apply" }
- context 'when successfully applies patch' do
+ context "when successfully applies patch" do
let(:suggestion) do
create(:suggestion, note: diff_note,
from_content: " raise RuntimeError, \"System commands must be given as an array of strings\"\n",
to_content: " raise RuntimeError, 'Explosion'\n # explosion?")
end
- it 'returns 200 with json content' do
+ it "returns 200 with json content" do
project.add_maintainer(user)
- put api(url, user), params: { id: suggestion.id }
+ put api(url, user), params: {id: suggestion.id}
expect(response).to have_gitlab_http_status(200)
expect(json_response)
- .to include('id', 'from_original_line', 'to_original_line',
- 'from_line', 'to_line', 'appliable', 'applied',
- 'from_content', 'to_content')
+ .to include("id", "from_original_line", "to_original_line",
+ "from_line", "to_line", "appliable", "applied",
+ "from_content", "to_content")
end
end
- context 'when not able to apply patch' do
+ context "when not able to apply patch" do
let(:suggestion) do
create(:suggestion, :unappliable, note: diff_note)
end
- it 'returns 400 with json content' do
+ it "returns 400 with json content" do
project.add_maintainer(user)
- put api(url, user), params: { id: suggestion.id }
+ put api(url, user), params: {id: suggestion.id}
expect(response).to have_gitlab_http_status(400)
- expect(json_response).to eq({ 'message' => 'Suggestion is not appliable' })
+ expect(json_response).to eq({"message" => "Suggestion is not appliable"})
end
end
- context 'when unauthorized' do
+ context "when unauthorized" do
let(:suggestion) do
create(:suggestion, note: diff_note,
from_content: " raise RuntimeError, \"System commands must be given as an array of strings\"\n",
to_content: " raise RuntimeError, 'Explosion'\n # explosion?")
end
- it 'returns 403 with json content' do
+ it "returns 403 with json content" do
project.add_reporter(user)
- put api(url, user), params: { id: suggestion.id }
+ put api(url, user), params: {id: suggestion.id}
expect(response).to have_gitlab_http_status(403)
- expect(json_response).to eq({ 'message' => '403 Forbidden' })
+ expect(json_response).to eq({"message" => "403 Forbidden"})
end
end
end
diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb
index b6e8d74c2e9..7fca7a8be8a 100644
--- a/spec/requests/api/system_hooks_spec.rb
+++ b/spec/requests/api/system_hooks_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::SystemHooks do
let(:user) { create(:user) }
@@ -33,20 +33,20 @@ describe API::SystemHooks do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['url']).to eq(hook.url)
- expect(json_response.first['push_events']).to be false
- expect(json_response.first['tag_push_events']).to be false
- expect(json_response.first['merge_requests_events']).to be false
- expect(json_response.first['repository_update_events']).to be true
+ expect(json_response.first["url"]).to eq(hook.url)
+ expect(json_response.first["push_events"]).to be false
+ expect(json_response.first["tag_push_events"]).to be false
+ expect(json_response.first["merge_requests_events"]).to be false
+ expect(json_response.first["repository_update_events"]).to be true
end
end
end
describe "POST /hooks" do
it "creates new hook" do
- expect do
- post api("/hooks", admin), params: { url: 'http://example.com' }
- end.to change { SystemHook.count }.by(1)
+ expect {
+ post api("/hooks", admin), params: {url: "http://example.com"}
+ }.to change { SystemHook.count }.by(1)
end
it "responds with 400 if url not given" do
@@ -56,42 +56,42 @@ describe API::SystemHooks do
end
it "responds with 400 if url is invalid" do
- post api("/hooks", admin), params: { url: 'hp://mep.mep' }
+ post api("/hooks", admin), params: {url: "hp://mep.mep"}
expect(response).to have_gitlab_http_status(400)
end
it "does not create new hook without url" do
- expect do
+ expect {
post api("/hooks", admin)
- end.not_to change { SystemHook.count }
+ }.not_to change { SystemHook.count }
end
- it 'sets default values for events' do
- post api('/hooks', admin), params: { url: 'http://mep.mep' }
+ it "sets default values for events" do
+ post api("/hooks", admin), params: {url: "http://mep.mep"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['enable_ssl_verification']).to be true
- expect(json_response['push_events']).to be false
- expect(json_response['tag_push_events']).to be false
- expect(json_response['merge_requests_events']).to be false
+ expect(json_response["enable_ssl_verification"]).to be true
+ expect(json_response["push_events"]).to be false
+ expect(json_response["tag_push_events"]).to be false
+ expect(json_response["merge_requests_events"]).to be false
end
- it 'sets explicit values for events' do
- post api('/hooks', admin),
+ it "sets explicit values for events" do
+ post api("/hooks", admin),
params: {
- url: 'http://mep.mep',
+ url: "http://mep.mep",
enable_ssl_verification: false,
push_events: true,
tag_push_events: true,
- merge_requests_events: true
+ merge_requests_events: true,
}
expect(response).to have_http_status(201)
- expect(json_response['enable_ssl_verification']).to be false
- expect(json_response['push_events']).to be true
- expect(json_response['tag_push_events']).to be true
- expect(json_response['merge_requests_events']).to be true
+ expect(json_response["enable_ssl_verification"]).to be false
+ expect(json_response["push_events"]).to be true
+ expect(json_response["tag_push_events"]).to be true
+ expect(json_response["merge_requests_events"]).to be true
end
end
@@ -99,7 +99,7 @@ describe API::SystemHooks do
it "returns hook by id" do
get api("/hooks/#{hook.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['event_name']).to eq('project_create')
+ expect(json_response["event_name"]).to eq("project_create")
end
it "returns 404 on failure" do
@@ -110,20 +110,20 @@ describe API::SystemHooks do
describe "DELETE /hooks/:id" do
it "deletes a hook" do
- expect do
+ expect {
delete api("/hooks/#{hook.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { SystemHook.count }.by(-1)
+ }.to change { SystemHook.count }.by(-1)
end
- it 'returns 404 if the system hook does not exist' do
- delete api('/hooks/12345', admin)
+ it "returns 404 if the system hook does not exist" do
+ delete api("/hooks/12345", admin)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/hooks/#{hook.id}", admin) }
end
end
diff --git a/spec/requests/api/tags_spec.rb b/spec/requests/api/tags_spec.rb
index fffe878ddbd..47cea7eb0a9 100644
--- a/spec/requests/api/tags_spec.rb
+++ b/spec/requests/api/tags_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Tags do
let(:user) { create(:user) }
let(:guest) { create(:user).tap { |u| project.add_guest(u) } }
- let(:project) { create(:project, :repository, creator: user, path: 'my.project') }
- let(:tag_name) { project.repository.find_tag('v1.1.0').name }
+ let(:project) { create(:project, :repository, creator: user, path: "my.project") }
+ let(:tag_name) { project.repository.find_tag("v1.1.0").name }
let(:project_id) { project.id }
let(:current_user) { nil }
@@ -13,475 +13,475 @@ describe API::Tags do
project.add_maintainer(user)
end
- describe 'GET /projects/:id/repository/tags' do
+ describe "GET /projects/:id/repository/tags" do
let(:route) { "/projects/#{project_id}/repository/tags" }
- context 'sorting' do
+ context "sorting" do
let(:current_user) { user }
- it 'sorts by descending order by default' do
+ it "sorts by descending order by default" do
get api(route, current_user)
desc_order_tags = project.repository.tags.sort_by { |tag| tag.dereferenced_target.committed_date }
desc_order_tags.reverse!.map! { |tag| tag.dereferenced_target.id }
- expect(json_response.map { |tag| tag['commit']['id'] }).to eq(desc_order_tags)
+ expect(json_response.map { |tag| tag["commit"]["id"] }).to eq(desc_order_tags)
end
- it 'sorts by ascending order if specified' do
+ it "sorts by ascending order if specified" do
get api("#{route}?sort=asc", current_user)
asc_order_tags = project.repository.tags.sort_by { |tag| tag.dereferenced_target.committed_date }
asc_order_tags.map! { |tag| tag.dereferenced_target.id }
- expect(json_response.map { |tag| tag['commit']['id'] }).to eq(asc_order_tags)
+ expect(json_response.map { |tag| tag["commit"]["id"] }).to eq(asc_order_tags)
end
- it 'sorts by name in descending order when requested' do
+ it "sorts by name in descending order when requested" do
get api("#{route}?order_by=name", current_user)
ordered_by_name = project.repository.tags.map { |tag| tag.name }.sort.reverse
- expect(json_response.map { |tag| tag['name'] }).to eq(ordered_by_name)
+ expect(json_response.map { |tag| tag["name"] }).to eq(ordered_by_name)
end
- it 'sorts by name in ascending order when requested' do
+ it "sorts by name in ascending order when requested" do
get api("#{route}?order_by=name&sort=asc", current_user)
ordered_by_name = project.repository.tags.map { |tag| tag.name }.sort
- expect(json_response.map { |tag| tag['name'] }).to eq(ordered_by_name)
+ expect(json_response.map { |tag| tag["name"] }).to eq(ordered_by_name)
end
end
- context 'searching' do
- it 'only returns searched tags' do
- get api("#{route}", user), params: { search: 'v1.1.0' }
+ context "searching" do
+ it "only returns searched tags" do
+ get api(route.to_s, user), params: {search: "v1.1.0"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response[0]['name']).to eq('v1.1.0')
+ expect(json_response[0]["name"]).to eq("v1.1.0")
end
end
- shared_examples_for 'repository tags' do
- it 'returns the repository tags' do
+ shared_examples_for "repository tags" do
+ it "returns the repository tags" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/tags')
+ expect(response).to match_response_schema("public_api/v4/tags")
expect(response).to include_pagination_headers
- expect(json_response.first['name']).to eq(tag_name)
+ expect(json_response.first["name"]).to eq(tag_name)
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'repository tags'
+ it_behaves_like "repository tags"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository tags'
+ it_behaves_like "repository tags"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository tags'
+ it_behaves_like "repository tags"
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
- context 'with releases' do
- let(:description) { 'Awesome release!' }
+ context "with releases" do
+ let(:description) { "Awesome release!" }
let!(:release) do
create(:release,
- :legacy,
- project: project,
- tag: tag_name,
- description: description)
+ :legacy,
+ project: project,
+ tag: tag_name,
+ description: description)
end
- it 'returns an array of project tags with release info' do
+ it "returns an array of project tags with release info" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/tags')
+ expect(response).to match_response_schema("public_api/v4/tags")
expect(response).to include_pagination_headers
- expect(json_response.first['name']).to eq(tag_name)
- expect(json_response.first['message']).to eq('Version 1.1.0')
- expect(json_response.first['release']['description']).to eq(description)
+ expect(json_response.first["name"]).to eq(tag_name)
+ expect(json_response.first["message"]).to eq("Version 1.1.0")
+ expect(json_response.first["release"]["description"]).to eq(description)
end
end
end
- describe 'GET /projects/:id/repository/tags/:tag_name' do
+ describe "GET /projects/:id/repository/tags/:tag_name" do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}" }
- shared_examples_for 'repository tag' do
- it 'returns the repository branch' do
+ shared_examples_for "repository tag" do
+ it "returns the repository branch" do
get api(route, current_user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/tag')
- expect(json_response['name']).to eq(tag_name)
+ expect(response).to match_response_schema("public_api/v4/tag")
+ expect(json_response["name"]).to eq(tag_name)
end
- context 'when tag does not exist' do
- let(:tag_name) { 'unknown' }
+ context "when tag does not exist" do
+ let(:tag_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { get api(route, current_user) }
- let(:message) { '404 Tag Not Found' }
+ let(:message) { "404 Tag Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { get api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is public' do
+ context "when unauthenticated", "and project is public" do
let(:project) { create(:project, :public, :repository) }
- it_behaves_like 'repository tag'
+ it_behaves_like "repository tag"
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { get api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository tag'
+ it_behaves_like "repository tag"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository tag'
+ it_behaves_like "repository tag"
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { get api(route, guest) }
end
end
end
- describe 'POST /projects/:id/repository/tags' do
- let(:tag_name) { 'new_tag' }
+ describe "POST /projects/:id/repository/tags" do
+ let(:tag_name) { "new_tag" }
let(:route) { "/projects/#{project_id}/repository/tags" }
- shared_examples_for 'repository new tag' do
- it 'creates a new tag' do
- post api(route, current_user), params: { tag_name: tag_name, ref: 'master' }
+ shared_examples_for "repository new tag" do
+ it "creates a new tag" do
+ post api(route, current_user), params: {tag_name: tag_name, ref: "master"}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/tag')
- expect(json_response['name']).to eq(tag_name)
+ expect(response).to match_response_schema("public_api/v4/tag")
+ expect(json_response["name"]).to eq(tag_name)
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { post api(route, current_user) }
end
end
end
- context 'when unauthenticated', 'and project is private' do
- it_behaves_like '404 response' do
+ context "when unauthenticated", "and project is private" do
+ it_behaves_like "404 response" do
let(:request) { post api(route) }
- let(:message) { '404 Project Not Found' }
+ let(:message) { "404 Project Not Found" }
end
end
- context 'when authenticated', 'as a guest' do
- it_behaves_like '403 response' do
+ context "when authenticated", "as a guest" do
+ it_behaves_like "403 response" do
let(:request) { post api(route, guest) }
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
context "when a protected branch doesn't already exist" do
- it_behaves_like 'repository new tag'
+ it_behaves_like "repository new tag"
- context 'when tag contains a dot' do
- let(:tag_name) { 'v7.0.1' }
+ context "when tag contains a dot" do
+ let(:tag_name) { "v7.0.1" }
- it_behaves_like 'repository new tag'
+ it_behaves_like "repository new tag"
end
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository new tag'
+ it_behaves_like "repository new tag"
- context 'when tag contains a dot' do
- let(:tag_name) { 'v7.0.1' }
+ context "when tag contains a dot" do
+ let(:tag_name) { "v7.0.1" }
- it_behaves_like 'repository new tag'
+ it_behaves_like "repository new tag"
end
end
end
- it 'returns 400 if tag name is invalid' do
- post api(route, current_user), params: { tag_name: 'new design', ref: 'master' }
+ it "returns 400 if tag name is invalid" do
+ post api(route, current_user), params: {tag_name: "new design", ref: "master"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Tag name invalid')
+ expect(json_response["message"]).to eq("Tag name invalid")
end
- it 'returns 400 if tag already exists' do
- post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
+ it "returns 400 if tag already exists" do
+ post api(route, current_user), params: {tag_name: "new_design1", ref: "master"}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/tag')
+ expect(response).to match_response_schema("public_api/v4/tag")
- post api(route, current_user), params: { tag_name: 'new_design1', ref: 'master' }
+ post api(route, current_user), params: {tag_name: "new_design1", ref: "master"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Tag new_design1 already exists')
+ expect(json_response["message"]).to eq("Tag new_design1 already exists")
end
- it 'returns 400 if ref name is invalid' do
- post api(route, current_user), params: { tag_name: 'new_design3', ref: 'foo' }
+ it "returns 400 if ref name is invalid" do
+ post api(route, current_user), params: {tag_name: "new_design3", ref: "foo"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('Target foo is invalid')
+ expect(json_response["message"]).to eq("Target foo is invalid")
end
- context 'lightweight tags with release notes' do
- it 'creates a new tag' do
- post api(route, current_user), params: { tag_name: tag_name, ref: 'master', release_description: 'Wow' }
+ context "lightweight tags with release notes" do
+ it "creates a new tag" do
+ post api(route, current_user), params: {tag_name: tag_name, ref: "master", release_description: "Wow"}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/tag')
- expect(json_response['name']).to eq(tag_name)
- expect(json_response['release']['description']).to eq('Wow')
+ expect(response).to match_response_schema("public_api/v4/tag")
+ expect(json_response["name"]).to eq(tag_name)
+ expect(json_response["release"]["description"]).to eq("Wow")
end
end
- context 'annotated tag' do
- it 'creates a new annotated tag' do
+ context "annotated tag" do
+ it "creates a new annotated tag" do
# Identity must be set in .gitconfig to create annotated tag.
- repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
project.repository.path_to_repo
- end
+ }
- system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.name #{user.name}))
- system(*%W(#{Gitlab.config.git.bin_path} --git-dir=#{repo_path} config user.email #{user.email}))
+ system(Gitlab.config.git.bin_path.to_s, "--git-dir=#{repo_path}", "config", "user.name", user.name.to_s)
+ system(Gitlab.config.git.bin_path.to_s, "--git-dir=#{repo_path}", "config", "user.email", user.email.to_s)
- post api(route, current_user), params: { tag_name: 'v7.1.0', ref: 'master', message: 'Release 7.1.0' }
+ post api(route, current_user), params: {tag_name: "v7.1.0", ref: "master", message: "Release 7.1.0"}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/tag')
- expect(json_response['name']).to eq('v7.1.0')
- expect(json_response['message']).to eq('Release 7.1.0')
+ expect(response).to match_response_schema("public_api/v4/tag")
+ expect(json_response["name"]).to eq("v7.1.0")
+ expect(json_response["message"]).to eq("Release 7.1.0")
end
end
end
end
- describe 'DELETE /projects/:id/repository/tags/:tag_name' do
+ describe "DELETE /projects/:id/repository/tags/:tag_name" do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}" }
before do
allow_any_instance_of(Repository).to receive(:rm_tag).and_return(true)
end
- shared_examples_for 'repository delete tag' do
- it 'deletes a tag' do
+ shared_examples_for "repository delete tag" do
+ it "deletes a tag" do
delete api(route, current_user)
expect(response).to have_gitlab_http_status(204)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api(route, current_user) }
end
- context 'when tag does not exist' do
- let(:tag_name) { 'unknown' }
+ context "when tag does not exist" do
+ let(:tag_name) { "unknown" }
- it_behaves_like '404 response' do
+ it_behaves_like "404 response" do
let(:request) { delete api(route, current_user) }
- let(:message) { '404 Tag Not Found' }
+ let(:message) { "404 Tag Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
+ it_behaves_like "403 response" do
let(:request) { delete api(route, current_user) }
end
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository delete tag'
+ it_behaves_like "repository delete tag"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository delete tag'
+ it_behaves_like "repository delete tag"
end
end
end
- describe 'POST /projects/:id/repository/tags/:tag_name/release' do
+ describe "POST /projects/:id/repository/tags/:tag_name/release" do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}/release" }
- let(:description) { 'Awesome release!' }
+ let(:description) { "Awesome release!" }
- shared_examples_for 'repository new release' do
- it 'creates description for existing git tag' do
- post api(route, user), params: { description: description }
+ shared_examples_for "repository new release" do
+ it "creates description for existing git tag" do
+ post api(route, user), params: {description: description}
expect(response).to have_gitlab_http_status(201)
- expect(response).to match_response_schema('public_api/v4/release')
- expect(json_response['tag_name']).to eq(tag_name)
- expect(json_response['description']).to eq(description)
+ expect(response).to match_response_schema("public_api/v4/release")
+ expect(json_response["tag_name"]).to eq(tag_name)
+ expect(json_response["description"]).to eq(description)
end
- context 'when tag does not exist' do
- let(:tag_name) { 'unknown' }
+ context "when tag does not exist" do
+ let(:tag_name) { "unknown" }
- it_behaves_like '404 response' do
- let(:request) { post api(route, current_user), params: { description: description } }
- let(:message) { '404 Tag Not Found' }
+ it_behaves_like "404 response" do
+ let(:request) { post api(route, current_user), params: {description: description} }
+ let(:message) { "404 Tag Not Found" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
- let(:request) { post api(route, current_user), params: { description: description } }
+ it_behaves_like "403 response" do
+ let(:request) { post api(route, current_user), params: {description: description} }
end
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository new release'
+ it_behaves_like "repository new release"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository new release'
+ it_behaves_like "repository new release"
end
- context 'on tag with existing release' do
+ context "on tag with existing release" do
let!(:release) { create(:release, :legacy, project: project, tag: tag_name, description: description) }
- it 'returns 409 if there is already a release' do
- post api(route, user), params: { description: description }
+ it "returns 409 if there is already a release" do
+ post api(route, user), params: {description: description}
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Release already exists')
+ expect(json_response["message"]).to eq("Release already exists")
end
end
end
end
- describe 'PUT id/repository/tags/:tag_name/release' do
+ describe "PUT id/repository/tags/:tag_name/release" do
let(:route) { "/projects/#{project_id}/repository/tags/#{tag_name}/release" }
- let(:description) { 'Awesome release!' }
- let(:new_description) { 'The best release!' }
+ let(:description) { "Awesome release!" }
+ let(:new_description) { "The best release!" }
- shared_examples_for 'repository update release' do
- context 'on tag with existing release' do
+ shared_examples_for "repository update release" do
+ context "on tag with existing release" do
let!(:release) do
create(:release,
- :legacy,
- project: project,
- tag: tag_name,
- description: description)
+ :legacy,
+ project: project,
+ tag: tag_name,
+ description: description)
end
- it 'updates the release description' do
- put api(route, current_user), params: { description: new_description }
+ it "updates the release description" do
+ put api(route, current_user), params: {description: new_description}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['tag_name']).to eq(tag_name)
- expect(json_response['description']).to eq(new_description)
+ expect(json_response["tag_name"]).to eq(tag_name)
+ expect(json_response["description"]).to eq(new_description)
end
end
- context 'when tag does not exist' do
- let(:tag_name) { 'unknown' }
+ context "when tag does not exist" do
+ let(:tag_name) { "unknown" }
- it_behaves_like '403 response' do
- let(:request) { put api(route, current_user), params: { description: new_description } }
- let(:message) { '403 Forbidden' }
+ it_behaves_like "403 response" do
+ let(:request) { put api(route, current_user), params: {description: new_description} }
+ let(:message) { "403 Forbidden" }
end
end
- context 'when repository is disabled' do
- include_context 'disabled repository'
+ context "when repository is disabled" do
+ include_context "disabled repository"
- it_behaves_like '403 response' do
- let(:request) { put api(route, current_user), params: { description: new_description } }
+ it_behaves_like "403 response" do
+ let(:request) { put api(route, current_user), params: {description: new_description} }
end
end
end
- context 'when authenticated', 'as a maintainer' do
+ context "when authenticated", "as a maintainer" do
let(:current_user) { user }
- it_behaves_like 'repository update release'
+ it_behaves_like "repository update release"
- context 'requesting with the escaped project full path' do
+ context "requesting with the escaped project full path" do
let(:project_id) { CGI.escape(project.full_path) }
- it_behaves_like 'repository update release'
+ it_behaves_like "repository update release"
end
- context 'when release does not exist' do
- it_behaves_like '403 response' do
- let(:request) { put api(route, current_user), params: { description: new_description } }
- let(:message) { '403 Forbidden' }
+ context "when release does not exist" do
+ it_behaves_like "403 response" do
+ let(:request) { put api(route, current_user), params: {description: new_description} }
+ let(:message) { "403 Forbidden" }
end
end
end
diff --git a/spec/requests/api/templates_spec.rb b/spec/requests/api/templates_spec.rb
index d1e16ab9ca9..3ac7018d860 100644
--- a/spec/requests/api/templates_spec.rb
+++ b/spec/requests/api/templates_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Templates do
- context 'the Template Entity' do
+ context "the Template Entity" do
before do
- get api('/templates/gitignores/Ruby')
+ get api("/templates/gitignores/Ruby")
end
- it { expect(json_response['name']).to eq('Ruby') }
- it { expect(json_response['content']).to include('*.gem') }
+ it { expect(json_response["name"]).to eq("Ruby") }
+ it { expect(json_response["content"]).to include("*.gem") }
end
- context 'the TemplateList Entity' do
+ context "the TemplateList Entity" do
before do
- get api('/templates/gitignores')
+ get api("/templates/gitignores")
end
- it { expect(json_response.first['name']).not_to be_nil }
- it { expect(json_response.first['content']).to be_nil }
+ it { expect(json_response.first["name"]).not_to be_nil }
+ it { expect(json_response.first["content"]).to be_nil }
end
- context 'requesting gitignores' do
- it 'returns a list of available gitignore templates' do
- get api('/templates/gitignores')
+ context "requesting gitignores" do
+ it "returns a list of available gitignore templates" do
+ get api("/templates/gitignores")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
@@ -30,161 +30,161 @@ describe API::Templates do
end
end
- context 'requesting gitlab-ci-ymls' do
- it 'returns a list of available gitlab_ci_ymls' do
- get api('/templates/gitlab_ci_ymls')
+ context "requesting gitlab-ci-ymls" do
+ it "returns a list of available gitlab_ci_ymls" do
+ get api("/templates/gitlab_ci_ymls")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['name']).not_to be_nil
+ expect(json_response.first["name"]).not_to be_nil
end
end
- context 'requesting gitlab-ci-yml for Ruby' do
- it 'adds a disclaimer on the top' do
- get api('/templates/gitlab_ci_ymls/Ruby')
+ context "requesting gitlab-ci-yml for Ruby" do
+ it "adds a disclaimer on the top" do
+ get api("/templates/gitlab_ci_ymls/Ruby")
expect(response).to have_gitlab_http_status(200)
- expect(json_response['content']).to start_with("# This file is a template,")
+ expect(json_response["content"]).to start_with("# This file is a template,")
end
end
- context 'the License Template Entity' do
+ context "the License Template Entity" do
before do
- get api('/templates/licenses/mit')
+ get api("/templates/licenses/mit")
end
- it 'returns a license template' do
+ it "returns a license template" do
expect(response).to have_gitlab_http_status(200)
- expect(json_response['key']).to eq('mit')
- expect(json_response['name']).to eq('MIT License')
- expect(json_response['nickname']).to be_nil
- expect(json_response['popular']).to be true
- expect(json_response['html_url']).to eq('http://choosealicense.com/licenses/mit/')
- expect(json_response['source_url']).to eq('https://opensource.org/licenses/MIT')
- expect(json_response['description']).to include('A short and simple permissive license with conditions')
- expect(json_response['conditions']).to eq(%w[include-copyright])
- expect(json_response['permissions']).to eq(%w[commercial-use modifications distribution private-use])
- expect(json_response['limitations']).to eq(%w[liability warranty])
- expect(json_response['content']).to include('MIT License')
+ expect(json_response["key"]).to eq("mit")
+ expect(json_response["name"]).to eq("MIT License")
+ expect(json_response["nickname"]).to be_nil
+ expect(json_response["popular"]).to be true
+ expect(json_response["html_url"]).to eq("http://choosealicense.com/licenses/mit/")
+ expect(json_response["source_url"]).to eq("https://opensource.org/licenses/MIT")
+ expect(json_response["description"]).to include("A short and simple permissive license with conditions")
+ expect(json_response["conditions"]).to eq(%w[include-copyright])
+ expect(json_response["permissions"]).to eq(%w[commercial-use modifications distribution private-use])
+ expect(json_response["limitations"]).to eq(%w[liability warranty])
+ expect(json_response["content"]).to include("MIT License")
end
end
- context 'GET templates/licenses' do
- it 'returns a list of available license templates' do
- get api('/templates/licenses')
+ context "GET templates/licenses" do
+ it "returns a list of available license templates" do
+ get api("/templates/licenses")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(12)
- expect(json_response.map { |l| l['key'] }).to include('agpl-3.0')
+ expect(json_response.map { |l| l["key"] }).to include("agpl-3.0")
end
- describe 'the popular parameter' do
- context 'with popular=1' do
- it 'returns a list of available popular license templates' do
- get api('/templates/licenses?popular=1')
+ describe "the popular parameter" do
+ context "with popular=1" do
+ it "returns a list of available popular license templates" do
+ get api("/templates/licenses?popular=1")
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(3)
- expect(json_response.map { |l| l['key'] }).to include('apache-2.0')
+ expect(json_response.map { |l| l["key"] }).to include("apache-2.0")
end
end
end
end
- context 'GET templates/licenses/:name' do
- context 'with :project and :fullname given' do
+ context "GET templates/licenses/:name" do
+ context "with :project and :fullname given" do
before do
get api("/templates/licenses/#{license_type}?project=My+Awesome+Project&fullname=Anton+#{license_type.upcase}")
end
- context 'for the mit license' do
- let(:license_type) { 'mit' }
+ context "for the mit license" do
+ let(:license_type) { "mit" }
- it 'returns the license text' do
- expect(json_response['content']).to include('MIT License')
+ it "returns the license text" do
+ expect(json_response["content"]).to include("MIT License")
end
- it 'replaces placeholder values' do
- expect(json_response['content']).to include("Copyright (c) #{Time.now.year} Anton")
+ it "replaces placeholder values" do
+ expect(json_response["content"]).to include("Copyright (c) #{Time.now.year} Anton")
end
end
- context 'for the agpl-3.0 license' do
- let(:license_type) { 'agpl-3.0' }
+ context "for the agpl-3.0 license" do
+ let(:license_type) { "agpl-3.0" }
- it 'returns the license text' do
- expect(json_response['content']).to include('GNU AFFERO GENERAL PUBLIC LICENSE')
+ it "returns the license text" do
+ expect(json_response["content"]).to include("GNU AFFERO GENERAL PUBLIC LICENSE")
end
- it 'replaces placeholder values' do
- expect(json_response['content']).to include('My Awesome Project')
- expect(json_response['content']).to include("Copyright (C) #{Time.now.year} Anton")
+ it "replaces placeholder values" do
+ expect(json_response["content"]).to include("My Awesome Project")
+ expect(json_response["content"]).to include("Copyright (C) #{Time.now.year} Anton")
end
end
- context 'for the gpl-3.0 license' do
- let(:license_type) { 'gpl-3.0' }
+ context "for the gpl-3.0 license" do
+ let(:license_type) { "gpl-3.0" }
- it 'returns the license text' do
- expect(json_response['content']).to include('GNU GENERAL PUBLIC LICENSE')
+ it "returns the license text" do
+ expect(json_response["content"]).to include("GNU GENERAL PUBLIC LICENSE")
end
- it 'replaces placeholder values' do
- expect(json_response['content']).to include('My Awesome Project')
- expect(json_response['content']).to include("Copyright (C) #{Time.now.year} Anton")
+ it "replaces placeholder values" do
+ expect(json_response["content"]).to include("My Awesome Project")
+ expect(json_response["content"]).to include("Copyright (C) #{Time.now.year} Anton")
end
end
- context 'for the gpl-2.0 license' do
- let(:license_type) { 'gpl-2.0' }
+ context "for the gpl-2.0 license" do
+ let(:license_type) { "gpl-2.0" }
- it 'returns the license text' do
- expect(json_response['content']).to include('GNU GENERAL PUBLIC LICENSE')
+ it "returns the license text" do
+ expect(json_response["content"]).to include("GNU GENERAL PUBLIC LICENSE")
end
- it 'replaces placeholder values' do
- expect(json_response['content']).to include('My Awesome Project')
- expect(json_response['content']).to include("Copyright (C) #{Time.now.year} Anton")
+ it "replaces placeholder values" do
+ expect(json_response["content"]).to include("My Awesome Project")
+ expect(json_response["content"]).to include("Copyright (C) #{Time.now.year} Anton")
end
end
- context 'for the apache-2.0 license' do
- let(:license_type) { 'apache-2.0' }
+ context "for the apache-2.0 license" do
+ let(:license_type) { "apache-2.0" }
- it 'returns the license text' do
- expect(json_response['content']).to include('Apache License')
+ it "returns the license text" do
+ expect(json_response["content"]).to include("Apache License")
end
- it 'replaces placeholder values' do
- expect(json_response['content']).to include("Copyright #{Time.now.year} Anton")
+ it "replaces placeholder values" do
+ expect(json_response["content"]).to include("Copyright #{Time.now.year} Anton")
end
end
- context 'for an uknown license' do
- let(:license_type) { 'muth-over9000' }
+ context "for an uknown license" do
+ let(:license_type) { "muth-over9000" }
- it 'returns a 404' do
+ it "returns a 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'with no :fullname given' do
- context 'with an authenticated user' do
+ context "with no :fullname given" do
+ context "with an authenticated user" do
let(:user) { create(:user) }
- it 'replaces the copyright owner placeholder with the name of the current user' do
- get api('/templates/licenses/mit', user)
+ it "replaces the copyright owner placeholder with the name of the current user" do
+ get api("/templates/licenses/mit", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['content']).to include("Copyright (c) #{Time.now.year} #{user.name}")
+ expect(json_response["content"]).to include("Copyright (c) #{Time.now.year} #{user.name}")
end
end
end
diff --git a/spec/requests/api/todos_spec.rb b/spec/requests/api/todos_spec.rb
index f121a1d3b78..22219a5fd03 100644
--- a/spec/requests/api/todos_spec.rb
+++ b/spec/requests/api/todos_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Todos do
let(:group) { create(:group) }
@@ -6,7 +6,7 @@ describe API::Todos do
let(:project_2) { create(:project) }
let(:author_1) { create(:user) }
let(:author_2) { create(:user) }
- let(:john_doe) { create(:user, username: 'john_doe') }
+ let(:john_doe) { create(:user, username: "john_doe") }
let(:merge_request) { create(:merge_request, source_project: project_1) }
let!(:pending_1) { create(:todo, :mentioned, project: project_1, author: author_1, user: john_doe) }
let!(:pending_2) { create(:todo, project: project_2, author: author_2, user: john_doe) }
@@ -18,38 +18,38 @@ describe API::Todos do
project_2.add_developer(john_doe)
end
- describe 'GET /todos' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- get api('/todos')
+ describe "GET /todos" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ get api("/todos")
expect(response.status).to eq(401)
end
end
- context 'when authenticated' do
- it 'returns an array of pending todos for current user' do
- get api('/todos', john_doe)
+ context "when authenticated" do
+ it "returns an array of pending todos for current user" do
+ get api("/todos", john_doe)
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(3)
- expect(json_response[0]['id']).to eq(pending_3.id)
- expect(json_response[0]['project']).to be_a Hash
- expect(json_response[0]['author']).to be_a Hash
- expect(json_response[0]['target_type']).to be_present
- expect(json_response[0]['target']).to be_a Hash
- expect(json_response[0]['target_url']).to be_present
- expect(json_response[0]['body']).to be_present
- expect(json_response[0]['state']).to eq('pending')
- expect(json_response[0]['action_name']).to eq('assigned')
- expect(json_response[0]['created_at']).to be_present
- end
-
- context 'and using the author filter' do
- it 'filters based on author_id param' do
- get api('/todos', john_doe), params: { author_id: author_2.id }
+ expect(json_response[0]["id"]).to eq(pending_3.id)
+ expect(json_response[0]["project"]).to be_a Hash
+ expect(json_response[0]["author"]).to be_a Hash
+ expect(json_response[0]["target_type"]).to be_present
+ expect(json_response[0]["target"]).to be_a Hash
+ expect(json_response[0]["target_url"]).to be_present
+ expect(json_response[0]["body"]).to be_present
+ expect(json_response[0]["state"]).to eq("pending")
+ expect(json_response[0]["action_name"]).to eq("assigned")
+ expect(json_response[0]["created_at"]).to be_present
+ end
+
+ context "and using the author filter" do
+ it "filters based on author_id param" do
+ get api("/todos", john_doe), params: {author_id: author_2.id}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -58,11 +58,11 @@ describe API::Todos do
end
end
- context 'and using the type filter' do
- it 'filters based on type param' do
+ context "and using the type filter" do
+ it "filters based on type param" do
create(:todo, project: project_1, author: author_2, user: john_doe, target: merge_request)
- get api('/todos', john_doe), params: { type: 'MergeRequest' }
+ get api("/todos", john_doe), params: {type: "MergeRequest"}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -71,9 +71,9 @@ describe API::Todos do
end
end
- context 'and using the state filter' do
- it 'filters based on state param' do
- get api('/todos', john_doe), params: { state: 'done' }
+ context "and using the state filter" do
+ it "filters based on state param" do
+ get api("/todos", john_doe), params: {state: "done"}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -82,9 +82,9 @@ describe API::Todos do
end
end
- context 'and using the project filter' do
- it 'filters based on project_id param' do
- get api('/todos', john_doe), params: { project_id: project_2.id }
+ context "and using the project filter" do
+ it "filters based on project_id param" do
+ get api("/todos", john_doe), params: {project_id: project_2.id}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -93,9 +93,9 @@ describe API::Todos do
end
end
- context 'and using the group filter' do
- it 'filters based on project_id param' do
- get api('/todos', john_doe), params: { group_id: group.id, sort: :target_id }
+ context "and using the group filter" do
+ it "filters based on project_id param" do
+ get api("/todos", john_doe), params: {group_id: group.id, sort: :target_id}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -104,9 +104,9 @@ describe API::Todos do
end
end
- context 'and using the action filter' do
- it 'filters based on action param' do
- get api('/todos', john_doe), params: { action: 'mentioned' }
+ context "and using the action filter" do
+ it "filters based on action param" do
+ get api("/todos", john_doe), params: {action: "mentioned"}
expect(response.status).to eq(200)
expect(response).to include_pagination_headers
@@ -117,32 +117,32 @@ describe API::Todos do
end
end
- describe 'POST /todos/:id/mark_as_done' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ describe "POST /todos/:id/mark_as_done" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
post api("/todos/#{pending_1.id}/mark_as_done")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'marks a todo as done' do
+ context "when authenticated" do
+ it "marks a todo as done" do
post api("/todos/#{pending_1.id}/mark_as_done", john_doe)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['id']).to eq(pending_1.id)
- expect(json_response['state']).to eq('done')
+ expect(json_response["id"]).to eq(pending_1.id)
+ expect(json_response["state"]).to eq("done")
expect(pending_1.reload).to be_done
end
- it 'updates todos cache' do
+ it "updates todos cache" do
expect_any_instance_of(User).to receive(:update_todos_count_cache).and_call_original
post api("/todos/#{pending_1.id}/mark_as_done", john_doe)
end
- it 'returns 404 if the todo does not belong to the current user' do
+ it "returns 404 if the todo does not belong to the current user" do
post api("/todos/#{pending_1.id}/mark_as_done", author_1)
expect(response.status).to eq(404)
@@ -150,18 +150,18 @@ describe API::Todos do
end
end
- describe 'POST /mark_as_done' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- post api('/todos/mark_as_done')
+ describe "POST /mark_as_done" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ post api("/todos/mark_as_done")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'marks all todos as done' do
- post api('/todos/mark_as_done', john_doe)
+ context "when authenticated" do
+ it "marks all todos as done" do
+ post api("/todos/mark_as_done", john_doe)
expect(response).to have_gitlab_http_status(204)
expect(pending_1.reload).to be_done
@@ -169,7 +169,7 @@ describe API::Todos do
expect(pending_3.reload).to be_done
end
- it 'updates todos cache' do
+ it "updates todos cache" do
expect_any_instance_of(User).to receive(:update_todos_count_cache).and_call_original
post api("/todos/mark_as_done", john_doe)
@@ -177,23 +177,23 @@ describe API::Todos do
end
end
- shared_examples 'an issuable' do |issuable_type|
- it 'creates a todo on an issuable' do
+ shared_examples "an issuable" do |issuable_type|
+ it "creates a todo on an issuable" do
post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", john_doe)
expect(response.status).to eq(201)
- expect(json_response['project']).to be_a Hash
- expect(json_response['author']).to be_a Hash
- expect(json_response['target_type']).to eq(issuable.class.name)
- expect(json_response['target']).to be_a Hash
- expect(json_response['target_url']).to be_present
- expect(json_response['body']).to be_present
- expect(json_response['state']).to eq('pending')
- expect(json_response['action_name']).to eq('marked')
- expect(json_response['created_at']).to be_present
+ expect(json_response["project"]).to be_a Hash
+ expect(json_response["author"]).to be_a Hash
+ expect(json_response["target_type"]).to eq(issuable.class.name)
+ expect(json_response["target"]).to be_a Hash
+ expect(json_response["target_url"]).to be_present
+ expect(json_response["body"]).to be_present
+ expect(json_response["state"]).to eq("pending")
+ expect(json_response["action_name"]).to eq("marked")
+ expect(json_response["created_at"]).to be_present
end
- it 'returns 304 there already exist a todo on that issuable' do
+ it "returns 304 there already exist a todo on that issuable" do
create(:todo, project: project_1, author: author_1, user: john_doe, target: issuable)
post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", john_doe)
@@ -201,19 +201,19 @@ describe API::Todos do
expect(response.status).to eq(304)
end
- it 'returns 404 if the issuable is not found' do
+ it "returns 404 if the issuable is not found" do
post api("/projects/#{project_1.id}/#{issuable_type}/123/todo", john_doe)
expect(response.status).to eq(404)
end
- it 'returns an error if the issuable is not accessible' do
+ it "returns an error if the issuable is not accessible" do
guest = create(:user)
project_1.add_guest(guest)
post api("/projects/#{project_1.id}/#{issuable_type}/#{issuable.iid}/todo", guest)
- if issuable_type == 'merge_requests'
+ if issuable_type == "merge_requests"
expect(response).to have_gitlab_http_status(403)
else
expect(response).to have_gitlab_http_status(404)
@@ -221,15 +221,15 @@ describe API::Todos do
end
end
- describe 'POST :id/issuable_type/:issueable_id/todo' do
- context 'for an issue' do
- it_behaves_like 'an issuable', 'issues' do
+ describe "POST :id/issuable_type/:issueable_id/todo" do
+ context "for an issue" do
+ it_behaves_like "an issuable", "issues" do
let(:issuable) { create(:issue, :confidential, author: author_1, project: project_1) }
end
end
- context 'for a merge request' do
- it_behaves_like 'an issuable', 'merge_requests' do
+ context "for a merge request" do
+ it_behaves_like "an issuable", "merge_requests" do
let(:issuable) { merge_request }
end
end
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index f0f01e97f1d..77ff4e3051d 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Triggers do
set(:user) { create(:user) }
set(:user2) { create(:user) }
- let!(:trigger_token) { 'secure_token' }
- let!(:trigger_token_2) { 'secure_token_2' }
+ let!(:trigger_token) { "secure_token" }
+ let!(:trigger_token_2) { "secure_token_2" }
let!(:project) { create(:project, :repository, creator: user) }
let!(:maintainer) { create(:project_member, :maintainer, user: user, project: project) }
let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:trigger) { create(:ci_trigger, project: project, token: trigger_token, owner: user) }
let!(:trigger2) { create(:ci_trigger, project: project, token: trigger_token_2, owner: user2) }
- let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: '2015-01-01 12:13:14') }
+ let!(:trigger_request) { create(:ci_trigger_request, trigger: trigger, created_at: "2015-01-01 12:13:14") }
- describe 'POST /projects/:project_id/trigger/pipeline' do
+ describe "POST /projects/:project_id/trigger/pipeline" do
let!(:project2) { create(:project, :repository) }
let(:options) do
{
- token: trigger_token
+ token: trigger_token,
}
end
@@ -25,77 +25,77 @@ describe API::Triggers do
stub_ci_pipeline_to_return_yaml_file
end
- context 'Handles errors' do
- it 'returns bad request if token is missing' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: { ref: 'master' }
+ context "Handles errors" do
+ it "returns bad request if token is missing" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: {ref: "master"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns not found if project is not found' do
- post api('/projects/0/trigger/pipeline'), params: options.merge(ref: 'master')
+ it "returns not found if project is not found" do
+ post api("/projects/0/trigger/pipeline"), params: options.merge(ref: "master")
expect(response).to have_gitlab_http_status(404)
end
end
- context 'Have a commit' do
+ context "Have a commit" do
let(:pipeline) { project.ci_pipelines.last }
- it 'creates pipeline' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master')
+ it "creates pipeline" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: "master")
expect(response).to have_gitlab_http_status(201)
- expect(json_response).to include('id' => pipeline.id)
+ expect(json_response).to include("id" => pipeline.id)
pipeline.builds.reload
expect(pipeline.builds.pending.size).to eq(2)
expect(pipeline.builds.size).to eq(5)
end
- it 'returns bad request with no pipeline created if there\'s no commit for that ref' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'other-branch')
+ it "returns bad request with no pipeline created if there's no commit for that ref" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: "other-branch")
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('base' => ["Reference not found"])
+ expect(json_response["message"]).to eq("base" => ["Reference not found"])
end
- context 'Validates variables' do
+ context "Validates variables" do
let(:variables) do
- { 'TRIGGER_KEY' => 'TRIGGER_VALUE' }
+ {"TRIGGER_KEY" => "TRIGGER_VALUE"}
end
- it 'validates variables to be a hash' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: 'value', ref: 'master')
+ it "validates variables to be a hash" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: "value", ref: "master")
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('variables is invalid')
+ expect(json_response["error"]).to eq("variables is invalid")
end
- it 'validates variables needs to be a map of key-valued strings' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: { key: %w(1 2) }, ref: 'master')
+ it "validates variables needs to be a map of key-valued strings" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: {key: %w[1 2]}, ref: "master")
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']).to eq('variables needs to be a map of key-valued strings')
+ expect(json_response["message"]).to eq("variables needs to be a map of key-valued strings")
end
- it 'creates trigger request with variables' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: variables, ref: 'master')
+ it "creates trigger request with variables" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(variables: variables, ref: "master")
expect(response).to have_gitlab_http_status(201)
- expect(pipeline.variables.map { |v| { v.key => v.value } }.last).to eq(variables)
+ expect(pipeline.variables.map { |v| {v.key => v.value} }.last).to eq(variables)
end
end
- context 'when legacy trigger' do
+ context "when legacy trigger" do
before do
trigger.update(owner: nil)
end
- it 'creates pipeline' do
- post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: 'master')
+ it "creates pipeline" do
+ post api("/projects/#{project.id}/trigger/pipeline"), params: options.merge(ref: "master")
expect(response).to have_gitlab_http_status(201)
- expect(json_response).to include('id' => pipeline.id)
+ expect(json_response).to include("id" => pipeline.id)
pipeline.builds.reload
expect(pipeline.builds.pending.size).to eq(2)
expect(pipeline.builds.size).to eq(5)
@@ -103,28 +103,28 @@ describe API::Triggers do
end
end
- context 'when triggering a pipeline from a trigger token' do
- it 'does not leak the presence of project when token is for different project' do
- post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
+ context "when triggering a pipeline from a trigger token" do
+ it "does not leak the presence of project when token is for different project" do
+ post api("/projects/#{project2.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: {ref: "refs/heads/other-branch"}
expect(response).to have_gitlab_http_status(404)
end
- it 'creates builds from the ref given in the URL, not in the body' do
- expect do
- post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
- end.to change(project.builds, :count).by(5)
+ it "creates builds from the ref given in the URL, not in the body" do
+ expect {
+ post api("/projects/#{project.id}/ref/master/trigger/pipeline?token=#{trigger_token}"), params: {ref: "refs/heads/other-branch"}
+ }.to change(project.builds, :count).by(5)
expect(response).to have_gitlab_http_status(201)
end
- context 'when ref contains a dot' do
- it 'creates builds from the ref given in the URL, not in the body' do
- project.repository.create_file(user, '.gitlab/gitlabhq/new_feature.md', 'something valid', message: 'new_feature', branch_name: 'v.1-branch')
+ context "when ref contains a dot" do
+ it "creates builds from the ref given in the URL, not in the body" do
+ project.repository.create_file(user, ".gitlab/gitlabhq/new_feature.md", "something valid", message: "new_feature", branch_name: "v.1-branch")
- expect do
- post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), params: { ref: 'refs/heads/other-branch' }
- end.to change(project.builds, :count).by(4)
+ expect {
+ post api("/projects/#{project.id}/ref/v.1-branch/trigger/pipeline?token=#{trigger_token}"), params: {ref: "refs/heads/other-branch"}
+ }.to change(project.builds, :count).by(4)
expect(response).to have_gitlab_http_status(201)
end
@@ -132,9 +132,9 @@ describe API::Triggers do
end
end
- describe 'GET /projects/:id/triggers' do
- context 'authenticated user who can access triggers' do
- it 'returns a list of triggers with tokens exposed correctly' do
+ describe "GET /projects/:id/triggers" do
+ context "authenticated user who can access triggers" do
+ it "returns a list of triggers with tokens exposed correctly" do
get api("/projects/#{project.id}/triggers", user)
expect(response).to have_gitlab_http_status(200)
@@ -142,21 +142,21 @@ describe API::Triggers do
expect(json_response).to be_a(Array)
expect(json_response.size).to eq 2
- expect(json_response.dig(0, 'token')).to eq trigger_token
- expect(json_response.dig(1, 'token')).to eq trigger_token_2[0..3]
+ expect(json_response.dig(0, "token")).to eq trigger_token
+ expect(json_response.dig(1, "token")).to eq trigger_token_2[0..3]
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not return triggers list' do
+ context "authenticated user with invalid permissions" do
+ it "does not return triggers list" do
get api("/projects/#{project.id}/triggers", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not return triggers list' do
+ context "unauthenticated user" do
+ it "does not return triggers list" do
get api("/projects/#{project.id}/triggers")
expect(response).to have_gitlab_http_status(401)
@@ -164,32 +164,32 @@ describe API::Triggers do
end
end
- describe 'GET /projects/:id/triggers/:trigger_id' do
- context 'authenticated user with valid permissions' do
- it 'returns trigger details' do
+ describe "GET /projects/:id/triggers/:trigger_id" do
+ context "authenticated user with valid permissions" do
+ it "returns trigger details" do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_a(Hash)
end
- it 'responds 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/-5", user)
expect(response).to have_gitlab_http_status(404)
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not return triggers list' do
+ context "authenticated user with invalid permissions" do
+ it "does not return triggers list" do
get api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not return triggers list' do
+ context "unauthenticated user" do
+ it "does not return triggers list" do
get api("/projects/#{project.id}/triggers/#{trigger.id}")
expect(response).to have_gitlab_http_status(401)
@@ -197,22 +197,22 @@ describe API::Triggers do
end
end
- describe 'POST /projects/:id/triggers' do
- context 'authenticated user with valid permissions' do
- context 'with required parameters' do
- it 'creates trigger' do
- expect do
+ describe "POST /projects/:id/triggers" do
+ context "authenticated user with valid permissions" do
+ context "with required parameters" do
+ it "creates trigger" do
+ expect {
post api("/projects/#{project.id}/triggers", user),
- params: { description: 'trigger' }
- end.to change {project.triggers.count}.by(1)
+ params: {description: "trigger"}
+ }.to change {project.triggers.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response).to include('description' => 'trigger')
+ expect(json_response).to include("description" => "trigger")
end
end
- context 'without required parameters' do
- it 'does not create trigger' do
+ context "without required parameters" do
+ it "does not create trigger" do
post api("/projects/#{project.id}/triggers", user)
expect(response).to have_gitlab_http_status(:bad_request)
@@ -220,49 +220,49 @@ describe API::Triggers do
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not create trigger' do
+ context "authenticated user with invalid permissions" do
+ it "does not create trigger" do
post api("/projects/#{project.id}/triggers", user2),
- params: { description: 'trigger' }
+ params: {description: "trigger"}
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not create trigger' do
+ context "unauthenticated user" do
+ it "does not create trigger" do
post api("/projects/#{project.id}/triggers"),
- params: { description: 'trigger' }
+ params: {description: "trigger"}
expect(response).to have_gitlab_http_status(401)
end
end
end
- describe 'PUT /projects/:id/triggers/:trigger_id' do
- context 'authenticated user with valid permissions' do
- let(:new_description) { 'new description' }
+ describe "PUT /projects/:id/triggers/:trigger_id" do
+ context "authenticated user with valid permissions" do
+ let(:new_description) { "new description" }
- it 'updates description' do
+ it "updates description" do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user),
- params: { description: new_description }
+ params: {description: new_description}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('description' => new_description)
+ expect(json_response).to include("description" => new_description)
expect(trigger.reload.description).to eq(new_description)
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not update trigger' do
+ context "authenticated user with invalid permissions" do
+ it "does not update trigger" do
put api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not update trigger' do
+ context "unauthenticated user" do
+ it "does not update trigger" do
put api("/projects/#{project.id}/triggers/#{trigger.id}")
expect(response).to have_gitlab_http_status(401)
@@ -270,27 +270,27 @@ describe API::Triggers do
end
end
- describe 'POST /projects/:id/triggers/:trigger_id/take_ownership' do
- context 'authenticated user with valid permissions' do
- it 'updates owner' do
+ describe "POST /projects/:id/triggers/:trigger_id/take_ownership" do
+ context "authenticated user with valid permissions" do
+ it "updates owner" do
post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to include('owner')
+ expect(json_response).to include("owner")
expect(trigger.reload.owner).to eq(user)
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not update owner' do
+ context "authenticated user with invalid permissions" do
+ it "does not update owner" do
post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not update owner' do
+ context "unauthenticated user" do
+ it "does not update owner" do
post api("/projects/#{project.id}/triggers/#{trigger.id}/take_ownership")
expect(response).to have_gitlab_http_status(401)
@@ -298,37 +298,37 @@ describe API::Triggers do
end
end
- describe 'DELETE /projects/:id/triggers/:trigger_id' do
- context 'authenticated user with valid permissions' do
- it 'deletes trigger' do
- expect do
+ describe "DELETE /projects/:id/triggers/:trigger_id" do
+ context "authenticated user with valid permissions" do
+ it "deletes trigger" do
+ expect {
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change {project.triggers.count}.by(-1)
+ }.to change {project.triggers.count}.by(-1)
end
- it 'responds 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/-5", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/projects/#{project.id}/triggers/#{trigger.id}", user) }
end
end
- context 'authenticated user with invalid permissions' do
- it 'does not delete trigger' do
+ context "authenticated user with invalid permissions" do
+ it "does not delete trigger" do
delete api("/projects/#{project.id}/triggers/#{trigger.id}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthenticated user' do
- it 'does not delete trigger' do
+ context "unauthenticated user" do
+ it "does not delete trigger" do
delete api("/projects/#{project.id}/triggers/#{trigger.id}")
expect(response).to have_gitlab_http_status(401)
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb
index a879426589d..88372d6d9e5 100644
--- a/spec/requests/api/users_spec.rb
+++ b/spec/requests/api/users_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Users do
- let(:user) { create(:user, username: 'user.with.dot') }
+ let(:user) { create(:user, username: "user.with.dot") }
let(:admin) { create(:admin) }
let(:key) { create(:key, user: user) }
let(:gpg_key) { create(:gpg_key, user: user) }
let(:email) { create(:email, user: user) }
let(:omniauth_user) { create(:omniauth_user) }
- let(:ldap_user) { create(:omniauth_user, provider: 'ldapmain') }
- let(:ldap_blocked_user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') }
- let(:not_existing_user_id) { (User.maximum('id') || 0 ) + 10 }
- let(:not_existing_pat_id) { (PersonalAccessToken.maximum('id') || 0 ) + 10 }
+ let(:ldap_user) { create(:omniauth_user, provider: "ldapmain") }
+ let(:ldap_blocked_user) { create(:omniauth_user, provider: "ldapmain", state: "ldap_blocked") }
+ let(:not_existing_user_id) { (User.maximum("id") || 0) + 10 }
+ let(:not_existing_pat_id) { (PersonalAccessToken.maximum("id") || 0) + 10 }
let(:private_user) { create(:user, private_profile: true) }
- shared_examples 'rendering user status' do
- it 'returns the status if there was one' do
+ shared_examples "rendering user status" do
+ it "returns the status if there was one" do
create(:user_status, user: user)
get api(path, user)
expect(response).to have_gitlab_http_status(:success)
- expect(json_response['message']).to be_present
- expect(json_response['message_html']).to be_present
- expect(json_response['emoji']).to be_present
+ expect(json_response["message"]).to be_present
+ expect(json_response["message_html"]).to be_present
+ expect(json_response["emoji"]).to be_present
end
- it 'returns an empty response if there was no status' do
+ it "returns an empty response if there was no status" do
get api(path, user)
expect(response).to have_gitlab_http_status(:success)
- expect(json_response['message']).to be_nil
- expect(json_response['emoji']).to be_nil
+ expect(json_response["message"]).to be_nil
+ expect(json_response["emoji"]).to be_nil
end
end
- describe 'GET /users' do
+ describe "GET /users" do
context "when unauthenticated" do
it "returns authorization error when the `username` parameter is not passed" do
get api("/users")
@@ -43,25 +43,25 @@ describe API::Users do
end
it "returns the user when a valid `username` parameter is passed" do
- get api("/users"), params: { username: user.username }
+ get api("/users"), params: {username: user.username}
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(json_response.size).to eq(1)
- expect(json_response[0]['id']).to eq(user.id)
- expect(json_response[0]['username']).to eq(user.username)
+ expect(json_response[0]["id"]).to eq(user.id)
+ expect(json_response[0]["username"]).to eq(user.username)
end
it "returns the user when a valid `username` parameter is passed (case insensitive)" do
- get api("/users"), params: { username: user.username.upcase }
+ get api("/users"), params: {username: user.username.upcase}
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(json_response.size).to eq(1)
- expect(json_response[0]['id']).to eq(user.id)
- expect(json_response[0]['username']).to eq(user.username)
+ expect(json_response[0]["id"]).to eq(user.id)
+ expect(json_response[0]["username"]).to eq(user.username)
end
it "returns an empty response when an invalid `username` parameter is passed" do
- get api("/users"), params: { username: 'invalid' }
+ get api("/users"), params: {username: "invalid"}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
@@ -74,7 +74,7 @@ describe API::Users do
end
it "returns authorization error when the `username` parameter refers to an inaccessible user" do
- get api("/users"), params: { username: user.username }
+ get api("/users"), params: {username: user.username}
expect(response).to have_gitlab_http_status(403)
end
@@ -94,19 +94,19 @@ describe API::Users do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- context 'when authenticate as a regular user' do
+ context "when authenticate as a regular user" do
it "renders 200" do
get api("/users", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
end
end
- context 'when authenticate as an admin' do
+ context "when authenticate as an admin" do
it "renders 200" do
get api("/users", admin)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
end
end
end
@@ -114,39 +114,39 @@ describe API::Users do
it "returns an array of users" do
get api("/users", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(response).to include_pagination_headers
username = user.username
- expect(json_response.detect do |user|
- user['username'] == username
- end['username']).to eq(username)
+ expect(json_response.detect { |user|
+ user["username"] == username
+ }["username"]).to eq(username)
end
it "returns an array of blocked users" do
ldap_blocked_user
- create(:user, state: 'blocked')
+ create(:user, state: "blocked")
get api("/users?blocked=true", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(response).to include_pagination_headers
- expect(json_response).to all(include('state' => /(blocked|ldap_blocked)/))
+ expect(json_response).to all(include("state" => /(blocked|ldap_blocked)/))
end
it "returns one user" do
get api("/users?username=#{omniauth_user.username}", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(response).to include_pagination_headers
- expect(json_response.first['username']).to eq(omniauth_user.username)
+ expect(json_response.first["username"]).to eq(omniauth_user.username)
end
it "returns one user (case insensitive)" do
get api("/users?username=#{omniauth_user.username.upcase}", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
+ expect(response).to match_response_schema("public_api/v4/user/basics")
expect(response).to include_pagination_headers
- expect(json_response.first['username']).to eq(omniauth_user.username)
+ expect(json_response.first["username"]).to eq(omniauth_user.username)
end
it "returns a 403 when non-admin user searches by external UID" do
@@ -155,17 +155,17 @@ describe API::Users do
expect(response).to have_gitlab_http_status(403)
end
- it 'does not reveal the `is_admin` flag of the user' do
- get api('/users', user)
+ it "does not reveal the `is_admin` flag of the user" do
+ get api("/users", user)
- expect(response).to match_response_schema('public_api/v4/user/basics')
- expect(json_response.first.keys).not_to include 'is_admin'
+ expect(response).to match_response_schema("public_api/v4/user/basics")
+ expect(json_response.first.keys).not_to include "is_admin"
end
end
context "when admin" do
- context 'when sudo is defined' do
- it 'does not return 500' do
+ context "when sudo is defined" do
+ it "does not return 500" do
admin_personal_access_token = create(:personal_access_token, user: admin, scopes: [:sudo])
get api("/users?sudo=#{user.id}", admin, personal_access_token: admin_personal_access_token)
@@ -176,7 +176,7 @@ describe API::Users do
it "returns an array of users" do
get api("/users", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(response).to include_pagination_headers
end
@@ -185,17 +185,17 @@ describe API::Users do
get api("/users?external=true", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(response).to include_pagination_headers
- expect(json_response).to all(include('external' => true))
+ expect(json_response).to all(include("external" => true))
end
it "returns one user by external UID" do
get api("/users?extern_uid=#{omniauth_user.identities.first.extern_uid}&provider=#{omniauth_user.identities.first.provider}", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(1)
- expect(json_response.first['username']).to eq(omniauth_user.username)
+ expect(json_response.first["username"]).to eq(omniauth_user.username)
end
it "returns 400 error if provider with no extern_uid" do
@@ -215,9 +215,9 @@ describe API::Users do
get api("/users?created_before=2000-01-02T00:00:00.060Z", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(1)
- expect(json_response.first['username']).to eq(user.username)
+ expect(json_response.first["username"]).to eq(user.username)
end
it "returns no users created before a specific date" do
@@ -225,7 +225,7 @@ describe API::Users do
get api("/users?created_before=2000-01-02T00:00:00.060Z", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(0)
end
@@ -234,37 +234,37 @@ describe API::Users do
get api("/users?created_before=2001-01-02T00:00:00.060Z&created_after=1999-01-02T00:00:00.060", admin)
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(1)
- expect(json_response.first['username']).to eq(user.username)
+ expect(json_response.first["username"]).to eq(user.username)
end
- it 'returns the correct order when sorted by id' do
+ it "returns the correct order when sorted by id" do
admin
user
- get api('/users', admin), params: { order_by: 'id', sort: 'asc' }
+ get api("/users", admin), params: {order_by: "id", sort: "asc"}
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(2)
- expect(json_response.first['id']).to eq(admin.id)
- expect(json_response.last['id']).to eq(user.id)
+ expect(json_response.first["id"]).to eq(admin.id)
+ expect(json_response.last["id"]).to eq(user.id)
end
- it 'returns users with 2fa enabled' do
+ it "returns users with 2fa enabled" do
admin
user
user_with_2fa = create(:user, :two_factor_via_otp)
- get api('/users', admin), params: { two_factor: 'enabled' }
+ get api("/users", admin), params: {two_factor: "enabled"}
- expect(response).to match_response_schema('public_api/v4/user/admins')
+ expect(response).to match_response_schema("public_api/v4/user/admins")
expect(json_response.size).to eq(1)
- expect(json_response.first['id']).to eq(user_with_2fa.id)
+ expect(json_response.first["id"]).to eq(user_with_2fa.id)
end
- it 'returns 400 when provided incorrect sort params' do
- get api('/users', admin), params: { order_by: 'magic', sort: 'asc' }
+ it "returns 400 when provided incorrect sort params" do
+ get api("/users", admin), params: {order_by: "magic", sort: "asc"}
expect(response).to have_gitlab_http_status(400)
end
@@ -275,39 +275,39 @@ describe API::Users do
it "returns a user by id" do
get api("/users/#{user.id}", user)
- expect(response).to match_response_schema('public_api/v4/user/basic')
- expect(json_response['username']).to eq(user.username)
+ expect(response).to match_response_schema("public_api/v4/user/basic")
+ expect(json_response["username"]).to eq(user.username)
end
it "does not return the user's `is_admin` flag" do
get api("/users/#{user.id}", user)
- expect(response).to match_response_schema('public_api/v4/user/basic')
- expect(json_response.keys).not_to include 'is_admin'
+ expect(response).to match_response_schema("public_api/v4/user/basic")
+ expect(json_response.keys).not_to include "is_admin"
end
- context 'when authenticated as admin' do
- it 'includes the `is_admin` field' do
+ context "when authenticated as admin" do
+ it "includes the `is_admin` field" do
get api("/users/#{user.id}", admin)
- expect(response).to match_response_schema('public_api/v4/user/admin')
- expect(json_response['is_admin']).to be(false)
+ expect(response).to match_response_schema("public_api/v4/user/admin")
+ expect(json_response["is_admin"]).to be(false)
end
it "includes the `created_at` field for private users" do
get api("/users/#{private_user.id}", admin)
- expect(response).to match_response_schema('public_api/v4/user/admin')
- expect(json_response.keys).to include 'created_at'
+ expect(response).to match_response_schema("public_api/v4/user/admin")
+ expect(json_response.keys).to include "created_at"
end
end
- context 'for an anonymous user' do
+ context "for an anonymous user" do
it "returns a user by id" do
get api("/users/#{user.id}")
- expect(response).to match_response_schema('public_api/v4/user/basic')
- expect(json_response['username']).to eq(user.username)
+ expect(response).to match_response_schema("public_api/v4/user/basic")
+ expect(json_response["username"]).to eq(user.username)
end
it "returns a 404 if the target user is present but inaccessible" do
@@ -322,15 +322,15 @@ describe API::Users do
it "returns the `created_at` field for public users" do
get api("/users/#{user.id}")
- expect(response).to match_response_schema('public_api/v4/user/basic')
- expect(json_response.keys).to include 'created_at'
+ expect(response).to match_response_schema("public_api/v4/user/basic")
+ expect(json_response.keys).to include "created_at"
end
it "does not return the `created_at` field for private users" do
get api("/users/#{private_user.id}")
- expect(response).to match_response_schema('public_api/v4/user/basic')
- expect(json_response.keys).not_to include 'created_at'
+ expect(response).to match_response_schema("public_api/v4/user/basic")
+ expect(json_response.keys).not_to include "created_at"
end
end
@@ -338,7 +338,7 @@ describe API::Users do
get api("/users/0", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
it "returns a 404 for invalid ID" do
@@ -348,21 +348,21 @@ describe API::Users do
end
end
- describe 'GET /users/:id_or_username/status' do
- context 'when finding the user by id' do
- it_behaves_like 'rendering user status' do
+ describe "GET /users/:id_or_username/status" do
+ context "when finding the user by id" do
+ it_behaves_like "rendering user status" do
let(:path) { "/users/#{user.id}/status" }
end
end
- context 'when finding the user by username' do
- it_behaves_like 'rendering user status' do
+ context "when finding the user by username" do
+ it_behaves_like "rendering user status" do
let(:path) { "/users/#{user.username}/status" }
end
end
- context 'when finding the user by username (case insensitive)' do
- it_behaves_like 'rendering user status' do
+ context "when finding the user by username (case insensitive)" do
+ it_behaves_like "rendering user status" do
let(:path) { "/users/#{user.username.upcase}/status" }
end
end
@@ -374,15 +374,15 @@ describe API::Users do
end
it "creates user" do
- expect do
+ expect {
post api("/users", admin), params: attributes_for(:user, projects_limit: 3)
- end.to change { User.count }.by(1)
+ }.to change { User.count }.by(1)
end
it "creates user with correct attributes" do
- post api('/users', admin), params: attributes_for(:user, admin: true, can_create_group: true)
+ post api("/users", admin), params: attributes_for(:user, admin: true, can_create_group: true)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
expect(new_user.admin).to eq(true)
@@ -390,18 +390,18 @@ describe API::Users do
end
it "creates user with optional attributes" do
- optional_attributes = { confirm: true }
+ optional_attributes = {confirm: true}
attributes = attributes_for(:user).merge(optional_attributes)
- post api('/users', admin), params: attributes
+ post api("/users", admin), params: attributes
expect(response).to have_gitlab_http_status(201)
end
it "creates non-admin user" do
- post api('/users', admin), params: attributes_for(:user, admin: false, can_create_group: false)
+ post api("/users", admin), params: attributes_for(:user, admin: false, can_create_group: false)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
expect(new_user.admin).to eq(false)
@@ -409,9 +409,9 @@ describe API::Users do
end
it "creates non-admin users by default" do
- post api('/users', admin), params: attributes_for(:user)
+ post api("/users", admin), params: attributes_for(:user)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
expect(new_user.admin).to eq(false)
@@ -422,32 +422,32 @@ describe API::Users do
expect(response).to have_gitlab_http_status(201)
end
- it 'creates non-external users by default' do
+ it "creates non-external users by default" do
post api("/users", admin), params: attributes_for(:user)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq nil
expect(new_user.external).to be_falsy
end
- it 'allows an external user to be created' do
+ it "allows an external user to be created" do
post api("/users", admin), params: attributes_for(:user, external: true)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq nil
expect(new_user.external).to be_truthy
end
it "creates user with reset password" do
- post api('/users', admin), params: attributes_for(:user, reset_password: true).except(:password)
+ post api("/users", admin), params: attributes_for(:user, reset_password: true).except(:password)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
@@ -455,11 +455,11 @@ describe API::Users do
end
it "creates user with private profile" do
- post api('/users', admin), params: attributes_for(:user, private_profile: true)
+ post api("/users", admin), params: attributes_for(:user, private_profile: true)
expect(response).to have_gitlab_http_status(201)
- user_id = json_response['id']
+ user_id = json_response["id"]
new_user = User.find(user_id)
expect(new_user).not_to eq(nil)
@@ -467,53 +467,53 @@ describe API::Users do
end
it "does not create user with invalid email" do
- post api('/users', admin),
- params: {
- email: 'invalid email',
- password: 'password',
- name: 'test'
- }
+ post api("/users", admin),
+ params: {
+ email: "invalid email",
+ password: "password",
+ name: "test",
+ }
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 error if name not given' do
- post api('/users', admin), params: attributes_for(:user).except(:name)
+ it "returns 400 error if name not given" do
+ post api("/users", admin), params: attributes_for(:user).except(:name)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 error if password not given' do
- post api('/users', admin), params: attributes_for(:user).except(:password)
+ it "returns 400 error if password not given" do
+ post api("/users", admin), params: attributes_for(:user).except(:password)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 error if email not given' do
- post api('/users', admin), params: attributes_for(:user).except(:email)
+ it "returns 400 error if email not given" do
+ post api("/users", admin), params: attributes_for(:user).except(:email)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 error if username not given' do
- post api('/users', admin), params: attributes_for(:user).except(:username)
+ it "returns 400 error if username not given" do
+ post api("/users", admin), params: attributes_for(:user).except(:username)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 error if user does not validate' do
- post api('/users', admin),
- params: {
- password: 'pass',
- email: 'test@example.com',
- username: 'test!',
- name: 'test',
- bio: 'g' * 256,
- projects_limit: -1
- }
+ it "returns 400 error if user does not validate" do
+ post api("/users", admin),
+ params: {
+ password: "pass",
+ email: "test@example.com",
+ username: "test!",
+ name: "test",
+ bio: "g" * 256,
+ projects_limit: -1,
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['password'])
- .to eq(['is too short (minimum is 8 characters)'])
- expect(json_response['message']['bio'])
- .to eq(['is too long (maximum is 255 characters)'])
- expect(json_response['message']['projects_limit'])
- .to eq(['must be greater than or equal to 0'])
- expect(json_response['message']['username'])
+ expect(json_response["message"]["password"])
+ .to eq(["is too short (minimum is 8 characters)"])
+ expect(json_response["message"]["bio"])
+ .to eq(["is too long (maximum is 255 characters)"])
+ expect(json_response["message"]["projects_limit"])
+ .to eq(["must be greater than or equal to 0"])
+ expect(json_response["message"]["username"])
.to eq([Gitlab::PathRegex.namespace_format_message])
end
@@ -522,71 +522,71 @@ describe API::Users do
expect(response).to have_gitlab_http_status(403)
end
- context 'with existing user' do
+ context "with existing user" do
before do
- post api('/users', admin),
- params: {
- email: 'test@example.com',
- password: 'password',
- username: 'test',
- name: 'foo'
- }
- end
-
- it 'returns 409 conflict error if user with same email exists' do
- expect do
- post api('/users', admin),
- params: {
- name: 'foo',
- email: 'test@example.com',
- password: 'password',
- username: 'foo'
- }
- end.to change { User.count }.by(0)
+ post api("/users", admin),
+ params: {
+ email: "test@example.com",
+ password: "password",
+ username: "test",
+ name: "foo",
+ }
+ end
+
+ it "returns 409 conflict error if user with same email exists" do
+ expect {
+ post api("/users", admin),
+ params: {
+ name: "foo",
+ email: "test@example.com",
+ password: "password",
+ username: "foo",
+ }
+ }.to change { User.count }.by(0)
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Email has already been taken')
- end
-
- it 'returns 409 conflict error if same username exists' do
- expect do
- post api('/users', admin),
- params: {
- name: 'foo',
- email: 'foo@example.com',
- password: 'password',
- username: 'test'
- }
- end.to change { User.count }.by(0)
+ expect(json_response["message"]).to eq("Email has already been taken")
+ end
+
+ it "returns 409 conflict error if same username exists" do
+ expect {
+ post api("/users", admin),
+ params: {
+ name: "foo",
+ email: "foo@example.com",
+ password: "password",
+ username: "test",
+ }
+ }.to change { User.count }.by(0)
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Username has already been taken')
- end
-
- it 'returns 409 conflict error if same username exists (case insensitive)' do
- expect do
- post api('/users', admin),
- params: {
- name: 'foo',
- email: 'foo@example.com',
- password: 'password',
- username: 'TEST'
- }
- end.to change { User.count }.by(0)
+ expect(json_response["message"]).to eq("Username has already been taken")
+ end
+
+ it "returns 409 conflict error if same username exists (case insensitive)" do
+ expect {
+ post api("/users", admin),
+ params: {
+ name: "foo",
+ email: "foo@example.com",
+ password: "password",
+ username: "TEST",
+ }
+ }.to change { User.count }.by(0)
expect(response).to have_gitlab_http_status(409)
- expect(json_response['message']).to eq('Username has already been taken')
+ expect(json_response["message"]).to eq("Username has already been taken")
end
- it 'creates user with new identity' do
- post api("/users", admin), params: attributes_for(:user, provider: 'github', extern_uid: '67890')
+ it "creates user with new identity" do
+ post api("/users", admin), params: attributes_for(:user, provider: "github", extern_uid: "67890")
expect(response).to have_gitlab_http_status(201)
- expect(json_response['identities'].first['extern_uid']).to eq('67890')
- expect(json_response['identities'].first['provider']).to eq('github')
+ expect(json_response["identities"].first["extern_uid"]).to eq("67890")
+ expect(json_response["identities"].first["provider"]).to eq("github")
end
end
context "scopes" do
let(:user) { admin }
- let(:path) { '/users' }
+ let(:path) { "/users" }
let(:api_call) { method(:api) }
include_examples 'does not allow the "read_user" scope'
@@ -605,42 +605,42 @@ describe API::Users do
let!(:admin_user) { create(:admin) }
it "updates user with new bio" do
- put api("/users/#{user.id}", admin), params: { bio: 'new test bio' }
+ put api("/users/#{user.id}", admin), params: {bio: "new test bio"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['bio']).to eq('new test bio')
- expect(user.reload.bio).to eq('new test bio')
+ expect(json_response["bio"]).to eq("new test bio")
+ expect(user.reload.bio).to eq("new test bio")
end
it "updates user with new password and forces reset on next login" do
- put api("/users/#{user.id}", admin), params: { password: '12345678' }
+ put api("/users/#{user.id}", admin), params: {password: "12345678"}
expect(response).to have_gitlab_http_status(200)
expect(user.reload.password_expires_at).to be <= Time.now
end
it "updates user with organization" do
- put api("/users/#{user.id}", admin), params: { organization: 'GitLab' }
+ put api("/users/#{user.id}", admin), params: {organization: "GitLab"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['organization']).to eq('GitLab')
- expect(user.reload.organization).to eq('GitLab')
+ expect(json_response["organization"]).to eq("GitLab")
+ expect(user.reload.organization).to eq("GitLab")
end
- it 'updates user with avatar' do
- put api("/users/#{user.id}", admin), params: { avatar: fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
+ it "updates user with avatar" do
+ put api("/users/#{user.id}", admin), params: {avatar: fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif")}
user.reload
expect(user.avatar).to be_present
expect(response).to have_gitlab_http_status(200)
- expect(json_response['avatar_url']).to include(user.avatar_path)
+ expect(json_response["avatar_url"]).to include(user.avatar_path)
end
- it 'updates user with a new email' do
+ it "updates user with a new email" do
old_email = user.email
old_notification_email = user.notification_email
- put api("/users/#{user.id}", admin), params: { email: 'new@email.com' }
+ put api("/users/#{user.id}", admin), params: {email: "new@email.com"}
user.reload
@@ -648,66 +648,66 @@ describe API::Users do
expect(user).to be_confirmed
expect(user.email).to eq(old_email)
expect(user.notification_email).to eq(old_notification_email)
- expect(user.unconfirmed_email).to eq('new@email.com')
+ expect(user.unconfirmed_email).to eq("new@email.com")
end
- it 'skips reconfirmation when requested' do
- put api("/users/#{user.id}", admin), params: { email: 'new@email.com', skip_reconfirmation: true }
+ it "skips reconfirmation when requested" do
+ put api("/users/#{user.id}", admin), params: {email: "new@email.com", skip_reconfirmation: true}
user.reload
expect(response).to have_gitlab_http_status(200)
expect(user).to be_confirmed
- expect(user.email).to eq('new@email.com')
+ expect(user.email).to eq("new@email.com")
end
- it 'updates user with his own username' do
- put api("/users/#{user.id}", admin), params: { username: user.username }
+ it "updates user with his own username" do
+ put api("/users/#{user.id}", admin), params: {username: user.username}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['username']).to eq(user.username)
+ expect(json_response["username"]).to eq(user.username)
expect(user.reload.username).to eq(user.username)
end
it "updates user's existing identity" do
- put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldapmain', extern_uid: '654321' }
+ put api("/users/#{omniauth_user.id}", admin), params: {provider: "ldapmain", extern_uid: "654321"}
expect(response).to have_gitlab_http_status(200)
- expect(omniauth_user.reload.identities.first.extern_uid).to eq('654321')
+ expect(omniauth_user.reload.identities.first.extern_uid).to eq("654321")
end
- it 'updates user with new identity' do
- put api("/users/#{user.id}", admin), params: { provider: 'github', extern_uid: 'john' }
+ it "updates user with new identity" do
+ put api("/users/#{user.id}", admin), params: {provider: "github", extern_uid: "john"}
expect(response).to have_gitlab_http_status(200)
- expect(user.reload.identities.first.extern_uid).to eq('john')
- expect(user.reload.identities.first.provider).to eq('github')
+ expect(user.reload.identities.first.extern_uid).to eq("john")
+ expect(user.reload.identities.first.provider).to eq("github")
end
it "updates admin status" do
- put api("/users/#{user.id}", admin), params: { admin: true }
+ put api("/users/#{user.id}", admin), params: {admin: true}
expect(response).to have_gitlab_http_status(200)
expect(user.reload.admin).to eq(true)
end
it "updates external status" do
- put api("/users/#{user.id}", admin), params: { external: true }
+ put api("/users/#{user.id}", admin), params: {external: true}
expect(response.status).to eq 200
- expect(json_response['external']).to eq(true)
+ expect(json_response["external"]).to eq(true)
expect(user.reload.external?).to be_truthy
end
it "updates private profile" do
- put api("/users/#{user.id}", admin), params: { private_profile: true }
+ put api("/users/#{user.id}", admin), params: {private_profile: true}
expect(response).to have_gitlab_http_status(200)
expect(user.reload.private_profile).to eq(true)
end
it "does not update admin status" do
- put api("/users/#{admin_user.id}", admin), params: { can_create_group: false }
+ put api("/users/#{admin_user.id}", admin), params: {can_create_group: false}
expect(response).to have_gitlab_http_status(200)
expect(admin_user.reload.admin).to eq(true)
@@ -715,27 +715,27 @@ describe API::Users do
end
it "does not allow invalid update" do
- put api("/users/#{user.id}", admin), params: { email: 'invalid email' }
+ put api("/users/#{user.id}", admin), params: {email: "invalid email"}
expect(response).to have_gitlab_http_status(400)
- expect(user.reload.email).not_to eq('invalid email')
+ expect(user.reload.email).not_to eq("invalid email")
end
- context 'when the current user is not an admin' do
+ context "when the current user is not an admin" do
it "is not available" do
- expect do
+ expect {
put api("/users/#{user.id}", user), params: attributes_for(:user)
- end.not_to change { user.reload.attributes }
+ }.not_to change { user.reload.attributes }
expect(response).to have_gitlab_http_status(403)
end
end
it "returns 404 for non-existing user" do
- put api("/users/0", admin), params: { bio: 'update should fail' }
+ put api("/users/0", admin), params: {bio: "update should fail"}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
it "returns a 404 if invalid ID" do
@@ -744,64 +744,64 @@ describe API::Users do
expect(response).to have_gitlab_http_status(404)
end
- it 'returns 400 error if user does not validate' do
+ it "returns 400 error if user does not validate" do
put api("/users/#{user.id}", admin),
- params: {
- password: 'pass',
- email: 'test@example.com',
- username: 'test!',
- name: 'test',
- bio: 'g' * 256,
- projects_limit: -1
- }
+ params: {
+ password: "pass",
+ email: "test@example.com",
+ username: "test!",
+ name: "test",
+ bio: "g" * 256,
+ projects_limit: -1,
+ }
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['password'])
- .to eq(['is too short (minimum is 8 characters)'])
- expect(json_response['message']['bio'])
- .to eq(['is too long (maximum is 255 characters)'])
- expect(json_response['message']['projects_limit'])
- .to eq(['must be greater than or equal to 0'])
- expect(json_response['message']['username'])
+ expect(json_response["message"]["password"])
+ .to eq(["is too short (minimum is 8 characters)"])
+ expect(json_response["message"]["bio"])
+ .to eq(["is too long (maximum is 255 characters)"])
+ expect(json_response["message"]["projects_limit"])
+ .to eq(["must be greater than or equal to 0"])
+ expect(json_response["message"]["username"])
.to eq([Gitlab::PathRegex.namespace_format_message])
end
- it 'returns 400 if provider is missing for identity update' do
- put api("/users/#{omniauth_user.id}", admin), params: { extern_uid: '654321' }
+ it "returns 400 if provider is missing for identity update" do
+ put api("/users/#{omniauth_user.id}", admin), params: {extern_uid: "654321"}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 400 if external UID is missing for identity update' do
- put api("/users/#{omniauth_user.id}", admin), params: { provider: 'ldap' }
+ it "returns 400 if external UID is missing for identity update" do
+ put api("/users/#{omniauth_user.id}", admin), params: {provider: "ldap"}
expect(response).to have_gitlab_http_status(400)
end
context "with existing user" do
before do
- post api("/users", admin), params: { email: 'test@example.com', password: 'password', username: 'test', name: 'test' }
- post api("/users", admin), params: { email: 'foo@bar.com', password: 'password', username: 'john', name: 'john' }
+ post api("/users", admin), params: {email: "test@example.com", password: "password", username: "test", name: "test"}
+ post api("/users", admin), params: {email: "foo@bar.com", password: "password", username: "john", name: "john"}
@user = User.all.last
end
- it 'returns 409 conflict error if email address exists' do
- put api("/users/#{@user.id}", admin), params: { email: 'test@example.com' }
+ it "returns 409 conflict error if email address exists" do
+ put api("/users/#{@user.id}", admin), params: {email: "test@example.com"}
expect(response).to have_gitlab_http_status(409)
expect(@user.reload.email).to eq(@user.email)
end
- it 'returns 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), params: { username: 'test' }
+ put api("/users/#{@user.id}", admin), params: {username: "test"}
expect(response).to have_gitlab_http_status(409)
expect(@user.reload.username).to eq(@user.username)
end
- it 'returns 409 conflict error if username taken (case insensitive)' do
+ it "returns 409 conflict error if username taken (case insensitive)" do
@user_id = User.all.last.id
- put api("/users/#{@user.id}", admin), params: { username: 'TEST' }
+ put api("/users/#{@user.id}", admin), params: {username: "TEST"}
expect(response).to have_gitlab_http_status(409)
expect(@user.reload.username).to eq(@user.username)
@@ -815,24 +815,24 @@ describe API::Users do
end
it "does not create invalid ssh key" do
- post api("/users/#{user.id}/keys", admin), params: { title: "invalid key" }
+ post api("/users/#{user.id}/keys", admin), params: {title: "invalid key"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('key is missing')
+ expect(json_response["error"]).to eq("key is missing")
end
- it 'does not create key without title' do
- post api("/users/#{user.id}/keys", admin), params: { key: 'some key' }
+ it "does not create key without title" do
+ post api("/users/#{user.id}/keys", admin), params: {key: "some key"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('title is missing')
+ expect(json_response["error"]).to eq("title is missing")
end
it "creates ssh key" do
key_attrs = attributes_for :key
- expect do
+ expect {
post api("/users/#{user.id}/keys", admin), params: key_attrs
- end.to change { user.keys.count }.by(1)
+ }.to change { user.keys.count }.by(1)
end
it "returns 400 for invalid ID" do
@@ -841,17 +841,17 @@ describe API::Users do
end
end
- describe 'GET /user/:id/keys' do
- it 'returns 404 for non-existing user' do
+ describe "GET /user/:id/keys" do
+ it "returns 404 for non-existing user" do
user_id = not_existing_user_id
get api("/users/#{user_id}/keys")
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns array of ssh keys' do
+ it "returns array of ssh keys" do
user.keys << key
user.save
@@ -860,111 +860,111 @@ describe API::Users do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['title']).to eq(key.title)
+ expect(json_response.first["title"]).to eq(key.title)
end
end
- describe 'DELETE /user/:id/keys/:key_id' do
+ describe "DELETE /user/:id/keys/:key_id" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
delete api("/users/#{user.id}/keys/42")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'deletes existing key' do
+ context "when authenticated" do
+ it "deletes existing key" do
user.keys << key
user.save
- expect do
+ expect {
delete api("/users/#{user.id}/keys/#{key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.keys.count }.by(-1)
+ }.to change { user.keys.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/users/#{user.id}/keys/#{key.id}", admin) }
end
- it 'returns 404 error if user not found' do
+ it "returns 404 error if user not found" do
user.keys << key
user.save
delete api("/users/0/keys/#{key.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 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_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Key Not Found')
+ expect(json_response["message"]).to eq("404 Key Not Found")
end
end
end
- describe 'POST /users/:id/keys' do
+ describe "POST /users/:id/keys" do
before do
admin
end
- it 'does not create invalid GPG key' do
+ it "does not create invalid GPG key" do
post api("/users/#{user.id}/gpg_keys", admin)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('key is missing')
+ expect(json_response["error"]).to eq("key is missing")
end
- it 'creates GPG key' do
+ it "creates GPG key" do
key_attrs = attributes_for :gpg_key
- expect do
+ expect {
post api("/users/#{user.id}/gpg_keys", admin), params: key_attrs
expect(response).to have_gitlab_http_status(201)
- end.to change { user.gpg_keys.count }.by(1)
+ }.to change { user.gpg_keys.count }.by(1)
end
- it 'returns 400 for invalid ID' do
- post api('/users/0/gpg_keys', admin)
+ it "returns 400 for invalid ID" do
+ post api("/users/0/gpg_keys", admin)
expect(response).to have_gitlab_http_status(400)
end
end
- describe 'GET /user/:id/gpg_keys' do
+ describe "GET /user/:id/gpg_keys" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
get api("/users/#{user.id}/gpg_keys")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'returns 404 for non-existing user' do
- get api('/users/0/gpg_keys', admin)
+ context "when authenticated" do
+ it "returns 404 for non-existing user" do
+ get api("/users/0/gpg_keys", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 404 error if key not foud' do
+ it "returns 404 error if key not foud" do
delete api("/users/#{user.id}/gpg_keys/42", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
- it 'returns array of GPG keys' do
+ it "returns array of GPG keys" do
user.gpg_keys << gpg_key
user.save
@@ -973,95 +973,95 @@ describe API::Users do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['key']).to eq(gpg_key.key)
+ expect(json_response.first["key"]).to eq(gpg_key.key)
end
end
end
- describe 'DELETE /user/:id/gpg_keys/:key_id' do
+ describe "DELETE /user/:id/gpg_keys/:key_id" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
delete api("/users/#{user.id}/keys/42")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'deletes existing key' do
+ context "when authenticated" do
+ it "deletes existing key" do
user.gpg_keys << gpg_key
user.save
- expect do
+ expect {
delete api("/users/#{user.id}/gpg_keys/#{gpg_key.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.gpg_keys.count }.by(-1)
+ }.to change { user.gpg_keys.count }.by(-1)
end
- it 'returns 404 error if user not found' do
+ it "returns 404 error if user not found" do
user.keys << key
user.save
delete api("/users/0/gpg_keys/#{gpg_key.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 404 error if key not foud' do
+ it "returns 404 error if key not foud" do
delete api("/users/#{user.id}/gpg_keys/42", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
end
end
- describe 'POST /user/:id/gpg_keys/:key_id/revoke' do
+ describe "POST /user/:id/gpg_keys/:key_id/revoke" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
post api("/users/#{user.id}/gpg_keys/42/revoke")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'revokes existing key' do
+ context "when authenticated" do
+ it "revokes existing key" do
user.gpg_keys << gpg_key
user.save
- expect do
+ expect {
post api("/users/#{user.id}/gpg_keys/#{gpg_key.id}/revoke", admin)
expect(response).to have_gitlab_http_status(:accepted)
- end.to change { user.gpg_keys.count }.by(-1)
+ }.to change { user.gpg_keys.count }.by(-1)
end
- it 'returns 404 error if user not found' do
+ it "returns 404 error if user not found" do
user.gpg_keys << gpg_key
user.save
post api("/users/0/gpg_keys/#{gpg_key.id}/revoke", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 404 error if key not foud' do
+ it "returns 404 error if key not foud" do
post api("/users/#{user.id}/gpg_keys/42/revoke", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
end
end
@@ -1075,14 +1075,14 @@ describe API::Users do
post api("/users/#{user.id}/emails", admin), params: {}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('email is missing')
+ expect(json_response["error"]).to eq("email is missing")
end
it "creates unverified email" do
email_attrs = attributes_for :email
- expect do
+ expect {
post api("/users/#{user.id}/emails", admin), params: email_attrs
- end.to change { user.emails.count }.by(1)
+ }.to change { user.emails.count }.by(1)
email = Email.find_by(user_id: user.id, email: email_attrs[:email])
expect(email).not_to be_confirmed
@@ -1107,26 +1107,26 @@ describe API::Users do
end
end
- describe 'GET /user/:id/emails' do
+ describe "GET /user/:id/emails" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
get api("/users/#{user.id}/emails")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'returns 404 for non-existing user' do
- get api('/users/0/emails', admin)
+ context "when authenticated" do
+ it "returns 404 for non-existing user" do
+ get api("/users/0/emails", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns array of emails' do
+ it "returns array of emails" do
user.emails << email
user.save
@@ -1135,7 +1135,7 @@ describe API::Users do
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['email']).to eq(email.email)
+ expect(json_response.first["email"]).to eq(email.email)
end
it "returns a 404 for invalid ID" do
@@ -1146,46 +1146,46 @@ describe API::Users do
end
end
- describe 'DELETE /user/:id/emails/:email_id' do
+ describe "DELETE /user/:id/emails/:email_id" do
before do
admin
end
- context 'when unauthenticated' do
- it 'returns authentication error' do
+ context "when unauthenticated" do
+ it "returns authentication error" do
delete api("/users/#{user.id}/emails/42")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'deletes existing email' do
+ context "when authenticated" do
+ it "deletes existing email" do
user.emails << email
user.save
- expect do
+ expect {
delete api("/users/#{user.id}/emails/#{email.id}", admin)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.emails.count }.by(-1)
+ }.to change { user.emails.count }.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/users/#{user.id}/emails/#{email.id}", admin) }
end
- it 'returns 404 error if user not found' do
+ it "returns 404 error if user not found" do
user.emails << email
user.save
delete api("/users/0/emails/#{email.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns 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_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Email Not Found')
+ expect(json_response["message"]).to eq("404 Email Not Found")
end
it "returns a 404 for invalid ID" do
@@ -1212,7 +1212,7 @@ describe API::Users do
expect { Namespace.find(namespace.id) }.to raise_error ActiveRecord::RecordNotFound
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/users/#{user.id}", admin) }
end
@@ -1229,7 +1229,7 @@ describe API::Users do
it "returns 404 for non-existing user" do
perform_enqueued_jobs { delete api("/users/0", admin) }
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
it "returns a 404 for invalid ID" do
@@ -1261,22 +1261,22 @@ describe API::Users do
describe "GET /user" do
let(:personal_access_token) { create(:personal_access_token, user: user).token }
- shared_examples 'get user info' do |version|
- context 'with regular user' do
- context 'with personal access token' do
- it 'returns 403 without private token when sudo is defined' do
+ shared_examples "get user info" do |version|
+ context "with regular user" do
+ context "with personal access token" do
+ it "returns 403 without private token when sudo is defined" do
get api("/user?private_token=#{personal_access_token}&sudo=123", version: version)
expect(response).to have_gitlab_http_status(403)
end
end
- it 'returns current user without private token when sudo not defined' do
+ it "returns current user without private token when sudo not defined" do
get api("/user", user, version: version)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/user/public')
- expect(json_response['id']).to eq(user.id)
+ expect(response).to match_response_schema("public_api/v4/user/public")
+ expect(json_response["id"]).to eq(user.id)
end
context "scopes" do
@@ -1287,27 +1287,27 @@ describe API::Users do
end
end
- context 'with admin' do
+ context "with admin" do
let(:admin_personal_access_token) { create(:personal_access_token, user: admin).token }
- context 'with personal access token' do
- it 'returns 403 without private token when sudo defined' do
+ context "with personal access token" do
+ it "returns 403 without private token when sudo defined" do
get api("/user?private_token=#{admin_personal_access_token}&sudo=#{user.id}", version: version)
expect(response).to have_gitlab_http_status(403)
end
- it 'returns initial current user without private token but with is_admin when sudo not defined' do
+ it "returns initial current user without private token but with is_admin when sudo not defined" do
get api("/user?private_token=#{admin_personal_access_token}", version: version)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/user/admin')
- expect(json_response['id']).to eq(admin.id)
+ expect(response).to match_response_schema("public_api/v4/user/admin")
+ expect(json_response["id"]).to eq(admin.id)
end
end
end
- context 'with unauthenticated user' do
+ context "with unauthenticated user" do
it "returns 401 error if user is unauthenticated" do
get api("/user", version: version)
@@ -1316,8 +1316,8 @@ describe API::Users do
end
end
- it_behaves_like 'get user info', 'v3'
- it_behaves_like 'get user info', 'v4'
+ it_behaves_like "get user info", "v3"
+ it_behaves_like "get user info", "v4"
end
describe "GET /user/keys" do
@@ -1363,7 +1363,7 @@ describe API::Users do
get api("/user/keys/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Key Not Found')
+ expect(json_response["message"]).to eq("404 Key Not Found")
end
it "returns 404 error if admin accesses user's ssh key" do
@@ -1372,7 +1372,7 @@ describe API::Users do
admin
get api("/user/keys/#{key.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Key Not Found')
+ expect(json_response["message"]).to eq("404 Key Not Found")
end
it "returns 404 for invalid ID" do
@@ -1392,33 +1392,33 @@ describe API::Users do
describe "POST /user/keys" do
it "creates ssh key" do
key_attrs = attributes_for :key
- expect do
+ expect {
post api("/user/keys", user), params: key_attrs
- end.to change { user.keys.count }.by(1)
+ }.to change { user.keys.count }.by(1)
expect(response).to have_gitlab_http_status(201)
end
it "returns a 401 error if unauthorized" do
- post api("/user/keys"), params: { title: 'some title', key: 'some key' }
+ post api("/user/keys"), params: {title: "some title", key: "some key"}
expect(response).to have_gitlab_http_status(401)
end
it "does not create ssh key without key" do
- post api("/user/keys", user), params: { title: 'title' }
+ post api("/user/keys", user), params: {title: "title"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('key is missing')
+ expect(json_response["error"]).to eq("key is missing")
end
- it 'does not create ssh key without title' do
- post api('/user/keys', user), params: { key: 'some key' }
+ it "does not create ssh key without title" do
+ post api("/user/keys", user), params: {key: "some key"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('title is missing')
+ expect(json_response["error"]).to eq("title is missing")
end
it "does not create ssh key without title" do
- post api("/user/keys", user), params: { key: "somekey" }
+ post api("/user/keys", user), params: {key: "somekey"}
expect(response).to have_gitlab_http_status(400)
end
end
@@ -1428,14 +1428,14 @@ describe API::Users do
user.keys << key
user.save
- expect do
+ expect {
delete api("/user/keys/#{key.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.keys.count}.by(-1)
+ }.to change { user.keys.count}.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/user/keys/#{key.id}", user) }
end
@@ -1443,7 +1443,7 @@ describe API::Users do
delete api("/user/keys/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Key Not Found')
+ expect(json_response["message"]).to eq("404 Key Not Found")
end
it "returns 401 error if unauthorized" do
@@ -1460,30 +1460,30 @@ describe API::Users do
end
end
- describe 'GET /user/gpg_keys' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- get api('/user/gpg_keys')
+ describe "GET /user/gpg_keys" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ get api("/user/gpg_keys")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
- it 'returns array of GPG keys' do
+ context "when authenticated" do
+ it "returns array of GPG keys" do
user.gpg_keys << gpg_key
user.save
- get api('/user/gpg_keys', user)
+ get api("/user/gpg_keys", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['key']).to eq(gpg_key.key)
+ expect(json_response.first["key"]).to eq(gpg_key.key)
end
- context 'scopes' do
- let(:path) { '/user/gpg_keys' }
+ context "scopes" do
+ let(:path) { "/user/gpg_keys" }
let(:api_call) { method(:api) }
include_examples 'allows the "read_user" scope'
@@ -1491,22 +1491,22 @@ describe API::Users do
end
end
- describe 'GET /user/gpg_keys/:key_id' do
- it 'returns a single key' do
+ describe "GET /user/gpg_keys/:key_id" do
+ it "returns a single key" do
user.gpg_keys << gpg_key
user.save
get api("/user/gpg_keys/#{gpg_key.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['key']).to eq(gpg_key.key)
+ expect(json_response["key"]).to eq(gpg_key.key)
end
- it 'returns 404 Not Found within invalid ID' do
- get api('/user/gpg_keys/42', user)
+ it "returns 404 Not Found within invalid ID" do
+ get api("/user/gpg_keys/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
it "returns 404 error if admin accesses user's GPG key" do
@@ -1516,16 +1516,16 @@ describe API::Users do
get api("/user/gpg_keys/#{gpg_key.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
- it 'returns 404 for invalid ID' do
- get api('/users/gpg_keys/ASDF', admin)
+ it "returns 404 for invalid ID" do
+ get api("/users/gpg_keys/ASDF", admin)
expect(response).to have_gitlab_http_status(404)
end
- context 'scopes' do
+ context "scopes" do
let(:path) { "/user/gpg_keys/#{gpg_key.id}" }
let(:api_call) { method(:api) }
@@ -1533,50 +1533,50 @@ describe API::Users do
end
end
- describe 'POST /user/gpg_keys' do
- it 'creates a GPG key' do
+ describe "POST /user/gpg_keys" do
+ it "creates a GPG key" do
key_attrs = attributes_for :gpg_key
- expect do
- post api('/user/gpg_keys', user), params: key_attrs
+ expect {
+ post api("/user/gpg_keys", user), params: key_attrs
expect(response).to have_gitlab_http_status(201)
- end.to change { user.gpg_keys.count }.by(1)
+ }.to change { user.gpg_keys.count }.by(1)
end
- it 'returns a 401 error if unauthorized' do
- post api('/user/gpg_keys'), params: { key: 'some key' }
+ it "returns a 401 error if unauthorized" do
+ post api("/user/gpg_keys"), params: {key: "some key"}
expect(response).to have_gitlab_http_status(401)
end
- it 'does not create GPG key without key' do
- post api('/user/gpg_keys', user)
+ it "does not create GPG key without key" do
+ post api("/user/gpg_keys", user)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('key is missing')
+ expect(json_response["error"]).to eq("key is missing")
end
end
- describe 'POST /user/gpg_keys/:key_id/revoke' do
- it 'revokes existing GPG key' do
+ describe "POST /user/gpg_keys/:key_id/revoke" do
+ it "revokes existing GPG key" do
user.gpg_keys << gpg_key
user.save
- expect do
+ expect {
post api("/user/gpg_keys/#{gpg_key.id}/revoke", user)
expect(response).to have_gitlab_http_status(:accepted)
- end.to change { user.gpg_keys.count}.by(-1)
+ }.to change { user.gpg_keys.count}.by(-1)
end
- it 'returns 404 if key ID not found' do
- post api('/user/gpg_keys/42/revoke', user)
+ it "returns 404 if key ID not found" do
+ post api("/user/gpg_keys/42/revoke", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
- it 'returns 401 error if unauthorized' do
+ it "returns 401 error if unauthorized" do
user.gpg_keys << gpg_key
user.save
@@ -1585,33 +1585,33 @@ describe API::Users do
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 404 for invalid ID' do
- post api('/users/gpg_keys/ASDF/revoke', admin)
+ it "returns a 404 for invalid ID" do
+ post api("/users/gpg_keys/ASDF/revoke", admin)
expect(response).to have_gitlab_http_status(404)
end
end
- describe 'DELETE /user/gpg_keys/:key_id' do
- it 'deletes existing GPG key' do
+ describe "DELETE /user/gpg_keys/:key_id" do
+ it "deletes existing GPG key" do
user.gpg_keys << gpg_key
user.save
- expect do
+ expect {
delete api("/user/gpg_keys/#{gpg_key.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.gpg_keys.count}.by(-1)
+ }.to change { user.gpg_keys.count}.by(-1)
end
- it 'returns 404 if key ID not found' do
- delete api('/user/gpg_keys/42', user)
+ it "returns 404 if key ID not found" do
+ delete api("/user/gpg_keys/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 GPG Key Not Found')
+ expect(json_response["message"]).to eq("404 GPG Key Not Found")
end
- it 'returns 401 error if unauthorized' do
+ it "returns 401 error if unauthorized" do
user.gpg_keys << gpg_key
user.save
@@ -1620,8 +1620,8 @@ describe API::Users do
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 404 for invalid ID' do
- delete api('/users/gpg_keys/ASDF', admin)
+ it "returns a 404 for invalid ID" do
+ delete api("/users/gpg_keys/ASDF", admin)
expect(response).to have_gitlab_http_status(404)
end
@@ -1669,7 +1669,7 @@ describe API::Users do
it "returns 404 Not Found within invalid ID" do
get api("/user/emails/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Email Not Found')
+ expect(json_response["message"]).to eq("404 Email Not Found")
end
it "returns 404 error if admin accesses user's email" do
@@ -1678,7 +1678,7 @@ describe API::Users do
admin
get api("/user/emails/#{email.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Email Not Found')
+ expect(json_response["message"]).to eq("404 Email Not Found")
end
it "returns 404 for invalid ID" do
@@ -1698,14 +1698,14 @@ describe API::Users do
describe "POST /user/emails" do
it "creates email" do
email_attrs = attributes_for :email
- expect do
+ expect {
post api("/user/emails", user), params: email_attrs
- end.to change { user.emails.count }.by(1)
+ }.to change { user.emails.count }.by(1)
expect(response).to have_gitlab_http_status(201)
end
it "returns a 401 error if unauthorized" do
- post api("/user/emails"), params: { email: 'some email' }
+ post api("/user/emails"), params: {email: "some email"}
expect(response).to have_gitlab_http_status(401)
end
@@ -1713,7 +1713,7 @@ describe API::Users do
post api("/user/emails", user), params: {}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('email is missing')
+ expect(json_response["error"]).to eq("email is missing")
end
end
@@ -1722,14 +1722,14 @@ describe API::Users do
user.emails << email
user.save
- expect do
+ expect {
delete api("/user/emails/#{email.id}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change { user.emails.count}.by(-1)
+ }.to change { user.emails.count}.by(-1)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/user/emails/#{email.id}", user) }
end
@@ -1737,7 +1737,7 @@ describe API::Users do
delete api("/user/emails/42", user)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Email Not Found')
+ expect(json_response["message"]).to eq("404 Email Not Found")
end
it "returns 401 error if unauthorized" do
@@ -1754,71 +1754,71 @@ describe API::Users do
end
end
- describe 'POST /users/:id/block' do
+ describe "POST /users/:id/block" do
before do
admin
end
- it 'blocks existing user' do
+ it "blocks existing user" do
post api("/users/#{user.id}/block", admin)
expect(response).to have_gitlab_http_status(201)
- expect(user.reload.state).to eq('blocked')
+ expect(user.reload.state).to eq("blocked")
end
- it 'does not re-block ldap blocked users' do
+ it "does not re-block ldap blocked users" do
post api("/users/#{ldap_blocked_user.id}/block", admin)
expect(response).to have_gitlab_http_status(403)
- expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
+ expect(ldap_blocked_user.reload.state).to eq("ldap_blocked")
end
- it 'does not be available for non admin users' do
+ it "does not be available for non admin users" do
post api("/users/#{user.id}/block", user)
expect(response).to have_gitlab_http_status(403)
- expect(user.reload.state).to eq('active')
+ expect(user.reload.state).to eq("active")
end
- it 'returns a 404 error if user id not found' do
- post api('/users/0/block', admin)
+ it "returns a 404 error if user id not found" do
+ post api("/users/0/block", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
end
- describe 'POST /users/:id/unblock' do
- let(:blocked_user) { create(:user, state: 'blocked') }
+ describe "POST /users/:id/unblock" do
+ let(:blocked_user) { create(:user, state: "blocked") }
before do
admin
end
- it 'unblocks existing user' do
+ it "unblocks existing user" do
post api("/users/#{user.id}/unblock", admin)
expect(response).to have_gitlab_http_status(201)
- expect(user.reload.state).to eq('active')
+ expect(user.reload.state).to eq("active")
end
- it 'unblocks a blocked user' do
+ it "unblocks a blocked user" do
post api("/users/#{blocked_user.id}/unblock", admin)
expect(response).to have_gitlab_http_status(201)
- expect(blocked_user.reload.state).to eq('active')
+ expect(blocked_user.reload.state).to eq("active")
end
- it 'does not unblock ldap blocked users' do
+ it "does not unblock ldap blocked users" do
post api("/users/#{ldap_blocked_user.id}/unblock", admin)
expect(response).to have_gitlab_http_status(403)
- expect(ldap_blocked_user.reload.state).to eq('ldap_blocked')
+ expect(ldap_blocked_user.reload.state).to eq("ldap_blocked")
end
- it 'does not be available for non admin users' do
+ it "does not be available for non admin users" do
post api("/users/#{user.id}/unblock", user)
expect(response).to have_gitlab_http_status(403)
- expect(user.reload.state).to eq('active')
+ expect(user.reload.state).to eq("active")
end
- it 'returns a 404 error if user id not found' do
- post api('/users/0/block', admin)
+ it "returns a 404 error if user id not found" do
+ post api("/users/0/block", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
it "returns a 404 for invalid ID" do
@@ -1832,16 +1832,16 @@ describe API::Users do
let!(:old_active_user) { create(:user, last_activity_on: Time.utc(2000, 1, 1)) }
let!(:newly_active_user) { create(:user, last_activity_on: 2.days.ago.midday) }
- context 'last activity as normal user' do
- it 'has no permission' do
+ context "last activity as normal user" do
+ it "has no permission" do
get api("/user/activities", user)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'as admin' do
- it 'returns the activities from the last 6 months' do
+ context "as admin" do
+ it "returns the activities from the last 6 months" do
get api("/user/activities", admin)
expect(response).to include_pagination_headers
@@ -1849,13 +1849,13 @@ describe API::Users do
activity = json_response.last
- expect(activity['username']).to eq(newly_active_user.username)
- expect(activity['last_activity_on']).to eq(2.days.ago.to_date.to_s)
- expect(activity['last_activity_at']).to eq(2.days.ago.to_date.to_s)
+ expect(activity["username"]).to eq(newly_active_user.username)
+ expect(activity["last_activity_on"]).to eq(2.days.ago.to_date.to_s)
+ expect(activity["last_activity_at"]).to eq(2.days.ago.to_date.to_s)
end
- context 'passing a :from parameter' do
- it 'returns the activities from the given date' do
+ context "passing a :from parameter" do
+ it "returns the activities from the given date" do
get api("/user/activities?from=2000-1-1", admin)
expect(response).to include_pagination_headers
@@ -1863,64 +1863,64 @@ describe API::Users do
activity = json_response.first
- expect(activity['username']).to eq(old_active_user.username)
- expect(activity['last_activity_on']).to eq(Time.utc(2000, 1, 1).to_date.to_s)
- expect(activity['last_activity_at']).to eq(Time.utc(2000, 1, 1).to_date.to_s)
+ expect(activity["username"]).to eq(old_active_user.username)
+ expect(activity["last_activity_on"]).to eq(Time.utc(2000, 1, 1).to_date.to_s)
+ expect(activity["last_activity_at"]).to eq(Time.utc(2000, 1, 1).to_date.to_s)
end
end
end
end
- describe 'GET /user/status' do
- let(:path) { '/user/status' }
- it_behaves_like 'rendering user status'
+ describe "GET /user/status" do
+ let(:path) { "/user/status" }
+ it_behaves_like "rendering user status"
end
- describe 'PUT /user/status' do
- it 'saves the status' do
- put api('/user/status', user), params: { emoji: 'smirk', message: 'hello world' }
+ describe "PUT /user/status" do
+ it "saves the status" do
+ put api("/user/status", user), params: {emoji: "smirk", message: "hello world"}
expect(response).to have_gitlab_http_status(:success)
- expect(json_response['emoji']).to eq('smirk')
+ expect(json_response["emoji"]).to eq("smirk")
end
- it 'renders errors when the status was invalid' do
- put api('/user/status', user), params: { emoji: 'does not exist', message: 'hello world' }
+ it "renders errors when the status was invalid" do
+ put api("/user/status", user), params: {emoji: "does not exist", message: "hello world"}
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['emoji']).to be_present
+ expect(json_response["message"]["emoji"]).to be_present
end
- it 'deletes the status when passing empty values' do
- put api('/user/status', user)
+ it "deletes the status when passing empty values" do
+ put api("/user/status", user)
expect(response).to have_gitlab_http_status(:success)
expect(user.reload.status).to be_nil
end
end
- describe 'GET /users/:user_id/impersonation_tokens' do
+ describe "GET /users/:user_id/impersonation_tokens" do
let!(:active_personal_access_token) { create(:personal_access_token, user: user) }
let!(:revoked_personal_access_token) { create(:personal_access_token, :revoked, user: user) }
let!(:expired_personal_access_token) { create(:personal_access_token, :expired, user: user) }
let!(:impersonation_token) { create(:personal_access_token, :impersonation, user: user) }
let!(:revoked_impersonation_token) { create(:personal_access_token, :impersonation, :revoked, user: user) }
- it 'returns a 404 error if user not found' do
+ it "returns a 404 error if user not found" do
get api("/users/#{not_existing_user_id}/impersonation_tokens", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns a 403 error when authenticated as normal user' do
+ it "returns a 403 error when authenticated as normal user" do
get api("/users/#{not_existing_user_id}/impersonation_tokens", user)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it 'returns an array of all impersonated tokens' do
+ it "returns an array of all impersonated tokens" do
get api("/users/#{user.id}/impersonation_tokens", admin)
expect(response).to have_gitlab_http_status(200)
@@ -1929,161 +1929,161 @@ describe API::Users do
expect(json_response.size).to eq(2)
end
- it 'returns an array of active impersonation tokens if state active' do
+ it "returns an array of active impersonation tokens if state active" do
get api("/users/#{user.id}/impersonation_tokens?state=active", admin)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response).to all(include('active' => true))
+ expect(json_response).to all(include("active" => true))
end
- it 'returns an array of inactive personal access tokens if active is set to false' do
+ it "returns an array of inactive personal access tokens if active is set to false" do
get api("/users/#{user.id}/impersonation_tokens?state=inactive", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response).to all(include('active' => false))
+ expect(json_response).to all(include("active" => false))
end
end
- describe 'POST /users/:user_id/impersonation_tokens' do
- let(:name) { 'my new pat' }
- let(:expires_at) { '2016-12-28' }
- let(:scopes) { %w(api read_user) }
+ describe "POST /users/:user_id/impersonation_tokens" do
+ let(:name) { "my new pat" }
+ let(:expires_at) { "2016-12-28" }
+ let(:scopes) { %w[api read_user] }
let(:impersonation) { true }
- it 'returns validation error if impersonation token misses some attributes' do
+ it "returns validation error if impersonation token misses some attributes" do
post api("/users/#{user.id}/impersonation_tokens", admin)
expect(response).to have_gitlab_http_status(400)
- expect(json_response['error']).to eq('name is missing')
+ expect(json_response["error"]).to eq("name is missing")
end
- it 'returns a 404 error if user not found' do
+ it "returns a 404 error if user not found" do
post api("/users/#{not_existing_user_id}/impersonation_tokens", admin),
params: {
name: name,
- expires_at: expires_at
+ expires_at: expires_at,
}
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns a 403 error when authenticated as normal user' do
+ it "returns a 403 error when authenticated as normal user" do
post api("/users/#{user.id}/impersonation_tokens", user),
params: {
name: name,
- expires_at: expires_at
+ expires_at: expires_at,
}
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it 'creates a impersonation token' do
+ it "creates a impersonation token" do
post api("/users/#{user.id}/impersonation_tokens", admin),
params: {
name: name,
expires_at: expires_at,
scopes: scopes,
- impersonation: impersonation
+ impersonation: impersonation,
}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['name']).to eq(name)
- expect(json_response['scopes']).to eq(scopes)
- expect(json_response['expires_at']).to eq(expires_at)
- expect(json_response['id']).to be_present
- expect(json_response['created_at']).to be_present
- expect(json_response['active']).to be_falsey
- expect(json_response['revoked']).to be_falsey
- expect(json_response['token']).to be_present
- expect(json_response['impersonation']).to eq(impersonation)
+ expect(json_response["name"]).to eq(name)
+ expect(json_response["scopes"]).to eq(scopes)
+ expect(json_response["expires_at"]).to eq(expires_at)
+ expect(json_response["id"]).to be_present
+ expect(json_response["created_at"]).to be_present
+ expect(json_response["active"]).to be_falsey
+ expect(json_response["revoked"]).to be_falsey
+ expect(json_response["token"]).to be_present
+ expect(json_response["impersonation"]).to eq(impersonation)
end
end
- describe 'GET /users/:user_id/impersonation_tokens/:impersonation_token_id' do
+ describe "GET /users/:user_id/impersonation_tokens/:impersonation_token_id" do
let!(:personal_access_token) { create(:personal_access_token, user: user) }
let!(:impersonation_token) { create(:personal_access_token, :impersonation, user: user) }
- it 'returns 404 error if user not found' do
+ it "returns 404 error if user not found" do
get api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns a 404 error if impersonation token not found' do
+ it "returns a 404 error if impersonation token not found" do
get api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Impersonation Token Not Found')
+ expect(json_response["message"]).to eq("404 Impersonation Token Not Found")
end
- it 'returns a 404 error if token is not impersonation token' do
+ it "returns a 404 error if token is not impersonation token" do
get api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Impersonation Token Not Found')
+ expect(json_response["message"]).to eq("404 Impersonation Token Not Found")
end
- it 'returns a 403 error when authenticated as normal user' do
+ it "returns a 403 error when authenticated as normal user" do
get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it 'returns an impersonation token' do
+ it "returns an impersonation token" do
get api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['token']).not_to be_present
- expect(json_response['impersonation']).to be_truthy
+ expect(json_response["token"]).not_to be_present
+ expect(json_response["impersonation"]).to be_truthy
end
end
- describe 'DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id' do
+ describe "DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id" do
let!(:personal_access_token) { create(:personal_access_token, user: user) }
let!(:impersonation_token) { create(:personal_access_token, :impersonation, user: user) }
- it 'returns a 404 error if user not found' do
+ it "returns a 404 error if user not found" do
delete api("/users/#{not_existing_user_id}/impersonation_tokens/1", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 User Not Found')
+ expect(json_response["message"]).to eq("404 User Not Found")
end
- it 'returns a 404 error if impersonation token not found' do
+ it "returns a 404 error if impersonation token not found" do
delete api("/users/#{user.id}/impersonation_tokens/#{not_existing_pat_id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Impersonation Token Not Found')
+ expect(json_response["message"]).to eq("404 Impersonation Token Not Found")
end
- it 'returns a 404 error if token is not impersonation token' do
+ it "returns a 404 error if token is not impersonation token" do
delete api("/users/#{user.id}/impersonation_tokens/#{personal_access_token.id}", admin)
expect(response).to have_gitlab_http_status(404)
- expect(json_response['message']).to eq('404 Impersonation Token Not Found')
+ expect(json_response["message"]).to eq("404 Impersonation Token Not Found")
end
- it 'returns a 403 error when authenticated as normal user' do
+ it "returns a 403 error when authenticated as normal user" do
delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", user)
expect(response).to have_gitlab_http_status(403)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin) }
end
- it 'revokes a impersonation token' do
+ it "revokes a impersonation token" do
delete api("/users/#{user.id}/impersonation_tokens/#{impersonation_token.id}", admin)
expect(response).to have_gitlab_http_status(204)
@@ -2092,7 +2092,7 @@ describe API::Users do
end
end
- it_behaves_like 'custom attributes endpoints', 'users' do
+ it_behaves_like "custom attributes endpoints", "users" do
let(:attributable) { user }
let(:other_attributable) { admin }
end
diff --git a/spec/requests/api/variables_spec.rb b/spec/requests/api/variables_spec.rb
index 5df6baf0ddf..05e77d674f0 100644
--- a/spec/requests/api/variables_spec.rb
+++ b/spec/requests/api/variables_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Variables do
let(:user) { create(:user) }
@@ -8,9 +8,9 @@ describe API::Variables do
let!(:developer) { create(:project_member, :developer, user: user2, project: project) }
let!(:variable) { create(:ci_variable, project: project) }
- describe 'GET /projects/:id/variables' do
- context 'authorized user with proper permissions' do
- it 'returns project variables' do
+ describe "GET /projects/:id/variables" do
+ context "authorized user with proper permissions" do
+ it "returns project variables" do
get api("/projects/#{project.id}/variables", user)
expect(response).to have_gitlab_http_status(200)
@@ -18,16 +18,16 @@ describe API::Variables do
end
end
- context 'authorized user with invalid permissions' do
- it 'does not return project variables' do
+ context "authorized user with invalid permissions" do
+ it "does not return project variables" do
get api("/projects/#{project.id}/variables", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not return project variables' do
+ context "unauthorized user" do
+ it "does not return project variables" do
get api("/projects/#{project.id}/variables")
expect(response).to have_gitlab_http_status(401)
@@ -35,33 +35,33 @@ describe API::Variables do
end
end
- describe 'GET /projects/:id/variables/:key' do
- context 'authorized user with proper permissions' do
- it 'returns project variable details' do
+ describe "GET /projects/:id/variables/:key" do
+ context "authorized user with proper permissions" do
+ it "returns project variable details" do
get api("/projects/#{project.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['value']).to eq(variable.value)
- expect(json_response['protected']).to eq(variable.protected?)
+ expect(json_response["value"]).to eq(variable.value)
+ expect(json_response["protected"]).to eq(variable.protected?)
end
- it 'responds 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_gitlab_http_status(404)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not return project variable details' do
+ context "authorized user with invalid permissions" do
+ it "does not return project variable details" do
get api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not return project variable details' do
+ context "unauthorized user" do
+ it "does not return project variable details" do
get api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
@@ -69,49 +69,49 @@ describe API::Variables do
end
end
- describe 'POST /projects/:id/variables' do
- context 'authorized user with proper permissions' do
- it 'creates variable' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'PROTECTED_VALUE_2', protected: true }
- end.to change {project.variables.count}.by(1)
+ describe "POST /projects/:id/variables" do
+ context "authorized user with proper permissions" do
+ it "creates variable" do
+ expect {
+ post api("/projects/#{project.id}/variables", user), params: {key: "TEST_VARIABLE_2", value: "PROTECTED_VALUE_2", protected: true}
+ }.to change {project.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('PROTECTED_VALUE_2')
- expect(json_response['protected']).to be_truthy
+ expect(json_response["key"]).to eq("TEST_VARIABLE_2")
+ expect(json_response["value"]).to eq("PROTECTED_VALUE_2")
+ expect(json_response["protected"]).to be_truthy
end
- it 'creates variable with optional attributes' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: 'TEST_VARIABLE_2', value: 'VALUE_2' }
- end.to change {project.variables.count}.by(1)
+ it "creates variable with optional attributes" do
+ expect {
+ post api("/projects/#{project.id}/variables", user), params: {key: "TEST_VARIABLE_2", value: "VALUE_2"}
+ }.to change {project.variables.count}.by(1)
expect(response).to have_gitlab_http_status(201)
- expect(json_response['key']).to eq('TEST_VARIABLE_2')
- expect(json_response['value']).to eq('VALUE_2')
- expect(json_response['protected']).to be_falsey
+ expect(json_response["key"]).to eq("TEST_VARIABLE_2")
+ expect(json_response["value"]).to eq("VALUE_2")
+ expect(json_response["protected"]).to be_falsey
end
- it 'does not allow to duplicate variable key' do
- expect do
- post api("/projects/#{project.id}/variables", user), params: { key: variable.key, value: 'VALUE_2' }
- end.to change {project.variables.count}.by(0)
+ it "does not allow to duplicate variable key" do
+ expect {
+ post api("/projects/#{project.id}/variables", user), params: {key: variable.key, value: "VALUE_2"}
+ }.to change {project.variables.count}.by(0)
expect(response).to have_gitlab_http_status(400)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not create variable' do
+ context "authorized user with invalid permissions" do
+ it "does not create variable" do
post api("/projects/#{project.id}/variables", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not create variable' do
+ context "unauthorized user" do
+ it "does not create variable" do
post api("/projects/#{project.id}/variables")
expect(response).to have_gitlab_http_status(401)
@@ -119,39 +119,39 @@ describe API::Variables do
end
end
- describe 'PUT /projects/:id/variables/:key' do
- context 'authorized user with proper permissions' do
- it 'updates variable data' do
+ describe "PUT /projects/:id/variables/:key" do
+ context "authorized user with proper permissions" do
+ it "updates variable data" do
initial_variable = project.variables.reload.first
value_before = initial_variable.value
- put api("/projects/#{project.id}/variables/#{variable.key}", user), params: { value: 'VALUE_1_UP', protected: true }
+ put api("/projects/#{project.id}/variables/#{variable.key}", user), params: {value: "VALUE_1_UP", protected: true}
updated_variable = project.variables.reload.first
expect(response).to have_gitlab_http_status(200)
expect(value_before).to eq(variable.value)
- expect(updated_variable.value).to eq('VALUE_1_UP')
+ expect(updated_variable.value).to eq("VALUE_1_UP")
expect(updated_variable).to be_protected
end
- it 'responds 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_gitlab_http_status(404)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not update variable' do
+ context "authorized user with invalid permissions" do
+ it "does not update variable" do
put api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not update variable' do
+ context "unauthorized user" do
+ it "does not update variable" do
put api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
@@ -159,33 +159,33 @@ describe API::Variables do
end
end
- describe 'DELETE /projects/:id/variables/:key' do
- context 'authorized user with proper permissions' do
- it 'deletes variable' do
- expect do
+ describe "DELETE /projects/:id/variables/:key" do
+ context "authorized user with proper permissions" do
+ it "deletes variable" do
+ expect {
delete api("/projects/#{project.id}/variables/#{variable.key}", user)
expect(response).to have_gitlab_http_status(204)
- end.to change {project.variables.count}.by(-1)
+ }.to change {project.variables.count}.by(-1)
end
- it 'responds 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_gitlab_http_status(404)
end
end
- context 'authorized user with invalid permissions' do
- it 'does not delete variable' do
+ context "authorized user with invalid permissions" do
+ it "does not delete variable" do
delete api("/projects/#{project.id}/variables/#{variable.key}", user2)
expect(response).to have_gitlab_http_status(403)
end
end
- context 'unauthorized user' do
- it 'does not delete variable' do
+ context "unauthorized user" do
+ it "does not delete variable" do
delete api("/projects/#{project.id}/variables/#{variable.key}")
expect(response).to have_gitlab_http_status(401)
diff --git a/spec/requests/api/version_spec.rb b/spec/requests/api/version_spec.rb
index 38b618191fb..645acf4f833 100644
--- a/spec/requests/api/version_spec.rb
+++ b/spec/requests/api/version_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe API::Version do
- describe 'GET /version' do
- context 'when unauthenticated' do
- it 'returns authentication error' do
- get api('/version')
+ describe "GET /version" do
+ context "when unauthenticated" do
+ it "returns authentication error" do
+ get api("/version")
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when authenticated' do
+ context "when authenticated" do
let(:user) { create(:user) }
- it 'returns the version information' do
- get api('/version', user)
+ it "returns the version information" do
+ get api("/version", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['version']).to eq(Gitlab::VERSION)
- expect(json_response['revision']).to eq(Gitlab.revision)
+ expect(json_response["version"]).to eq(Gitlab::VERSION)
+ expect(json_response["revision"]).to eq(Gitlab.revision)
end
end
end
diff --git a/spec/requests/api/wikis_spec.rb b/spec/requests/api/wikis_spec.rb
index d1b58aac104..1cd3e8a2ec4 100644
--- a/spec/requests/api/wikis_spec.rb
+++ b/spec/requests/api/wikis_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# For every API endpoint we test 3 states of wikis:
# - disabled
@@ -14,18 +14,18 @@ describe API::Wikis do
let(:user) { create(:user) }
let(:group) { create(:group).tap { |g| g.add_owner(user) } }
let(:project_wiki) { create(:project_wiki, project: project, user: user) }
- let(:payload) { { content: 'content', format: 'rdoc', title: 'title' } }
- let(:expected_keys_with_content) { %w(content format slug title) }
- let(:expected_keys_without_content) { %w(format slug title) }
+ let(:payload) { {content: "content", format: "rdoc", title: "title"} }
+ let(:expected_keys_with_content) { %w[content format slug title] }
+ let(:expected_keys_without_content) { %w[format slug title] }
- shared_examples_for 'returns list of wiki pages' do
- context 'when wiki has pages' do
+ shared_examples_for "returns list of wiki pages" do
+ context "when wiki has pages" do
let!(:pages) do
- [create(:wiki_page, wiki: project_wiki, attrs: { title: 'page1', content: 'content of page1' }),
- create(:wiki_page, wiki: project_wiki, attrs: { title: 'page2.with.dot', content: 'content of page2' })]
+ [create(:wiki_page, wiki: project_wiki, attrs: {title: "page1", content: "content of page1"}),
+ create(:wiki_page, wiki: project_wiki, attrs: {title: "page2.with.dot", content: "content of page2"}),]
end
- it 'returns the list of wiki pages without content' do
+ it "returns the list of wiki pages without content" do
get api(url, user)
expect(response).to have_gitlab_http_status(200)
@@ -33,27 +33,27 @@ describe API::Wikis do
json_response.each_with_index do |page, index|
expect(page.keys).to match_array(expected_keys_without_content)
- expect(page['slug']).to eq(pages[index].slug)
- expect(page['title']).to eq(pages[index].title)
+ expect(page["slug"]).to eq(pages[index].slug)
+ expect(page["title"]).to eq(pages[index].title)
end
end
- it 'returns the list of wiki pages with content' do
- get api(url, user), params: { with_content: 1 }
+ it "returns the list of wiki pages with content" do
+ get api(url, user), params: {with_content: 1}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(2)
json_response.each_with_index do |page, index|
expect(page.keys).to match_array(expected_keys_with_content)
- expect(page['content']).to eq(pages[index].content)
- expect(page['slug']).to eq(pages[index].slug)
- expect(page['title']).to eq(pages[index].title)
+ expect(page["content"]).to eq(pages[index].content)
+ expect(page["slug"]).to eq(pages[index].slug)
+ expect(page["title"]).to eq(pages[index].title)
end
end
end
- it 'return the empty list of wiki pages' do
+ it "return the empty list of wiki pages" do
get api(url, user)
expect(response).to have_gitlab_http_status(200)
@@ -61,28 +61,28 @@ describe API::Wikis do
end
end
- shared_examples_for 'returns wiki page' do
- it 'returns the wiki page' do
+ shared_examples_for "returns wiki page" do
+ it "returns the wiki page" do
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
- expect(json_response['content']).to eq(page.content)
- expect(json_response['slug']).to eq(page.slug)
- expect(json_response['title']).to eq(page.title)
+ expect(json_response["content"]).to eq(page.content)
+ expect(json_response["slug"]).to eq(page.slug)
+ expect(json_response["title"]).to eq(page.title)
end
end
- shared_examples_for 'creates wiki page' do
- it 'creates the wiki page' do
+ shared_examples_for "creates wiki page" do
+ it "creates the wiki page" do
post(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(201)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
- expect(json_response['content']).to eq(payload[:content])
- expect(json_response['slug']).to eq(payload[:title].tr(' ', '-'))
- expect(json_response['title']).to eq(payload[:title])
- expect(json_response['rdoc']).to eq(payload[:rdoc])
+ expect(json_response["content"]).to eq(payload[:content])
+ expect(json_response["slug"]).to eq(payload[:title].tr(" ", "-"))
+ expect(json_response["title"]).to eq(payload[:title])
+ expect(json_response["rdoc"]).to eq(payload[:rdoc])
end
[:title, :content].each do |part|
@@ -93,21 +93,21 @@ describe API::Wikis do
expect(response).to have_gitlab_http_status(400)
expect(json_response.size).to eq(1)
- expect(json_response['error']).to eq("#{part} is missing")
+ expect(json_response["error"]).to eq("#{part} is missing")
end
end
end
- shared_examples_for 'updates wiki page' do
- it 'updates the wiki page' do
+ shared_examples_for "updates wiki page" do
+ it "updates the wiki page" do
put(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to eq(4)
expect(json_response.keys).to match_array(expected_keys_with_content)
- expect(json_response['content']).to eq(payload[:content])
- expect(json_response['slug']).to eq(payload[:title].tr(' ', '-'))
- expect(json_response['title']).to eq(payload[:title])
+ expect(json_response["content"]).to eq(payload[:content])
+ expect(json_response["slug"]).to eq(payload[:title].tr(" ", "-"))
+ expect(json_response["title"]).to eq(payload[:title])
end
[:title, :content, :format].each do |part|
@@ -121,39 +121,39 @@ describe API::Wikis do
end
end
- shared_examples_for '403 Forbidden' do
- it 'returns 403 Forbidden' do
+ shared_examples_for "403 Forbidden" do
+ it "returns 403 Forbidden" do
expect(response).to have_gitlab_http_status(403)
expect(json_response.size).to eq(1)
- expect(json_response['message']).to eq('403 Forbidden')
+ expect(json_response["message"]).to eq("403 Forbidden")
end
end
- shared_examples_for '404 Wiki Page Not Found' do
- it 'returns 404 Wiki Page Not Found' do
+ shared_examples_for "404 Wiki Page Not Found" do
+ it "returns 404 Wiki Page Not Found" do
expect(response).to have_gitlab_http_status(404)
expect(json_response.size).to eq(1)
- expect(json_response['message']).to eq('404 Wiki Page Not Found')
+ expect(json_response["message"]).to eq("404 Wiki Page Not Found")
end
end
- shared_examples_for '404 Project Not Found' do
- it 'returns 404 Project Not Found' do
+ shared_examples_for "404 Project Not Found" do
+ it "returns 404 Project Not Found" do
expect(response).to have_gitlab_http_status(404)
expect(json_response.size).to eq(1)
- expect(json_response['message']).to eq('404 Project Not Found')
+ expect(json_response["message"]).to eq("404 Project Not Found")
end
end
- shared_examples_for '204 No Content' do
- it 'returns 204 No Content' do
+ shared_examples_for "204 No Content" do
+ it "returns 204 No Content" do
expect(response).to have_gitlab_http_status(204)
end
end
- shared_examples_for 'uploads wiki attachment' do
- it 'pushes attachment to the wiki repository' do
- allow(SecureRandom).to receive(:hex).and_return('fixed_hex')
+ shared_examples_for "uploads wiki attachment" do
+ it "pushes attachment to the wiki repository" do
+ allow(SecureRandom).to receive(:hex).and_return("fixed_hex")
post(api(url, user), params: payload)
@@ -161,690 +161,690 @@ describe API::Wikis do
expect(json_response).to eq result_hash.deep_stringify_keys
end
- it 'responds with validation error on empty file' do
+ it "responds with validation error on empty file" do
payload.delete(:file)
post(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(400)
expect(json_response.size).to eq(1)
- expect(json_response['error']).to eq('file is missing')
+ expect(json_response["error"]).to eq("file is missing")
end
- it 'responds with validation error on invalid temp file' do
- payload[:file] = { tempfile: '/etc/hosts' }
+ it "responds with validation error on invalid temp file" do
+ payload[:file] = {tempfile: "/etc/hosts"}
post(api(url, user), params: payload)
expect(response).to have_gitlab_http_status(400)
expect(json_response.size).to eq(1)
- expect(json_response['error']).to eq('file is invalid')
+ expect(json_response["error"]).to eq("file is invalid")
end
end
- describe 'GET /projects/:id/wikis' do
+ describe "GET /projects/:id/wikis" do
let(:url) { "/projects/#{project.id}/wikis" }
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_repo, :wiki_disabled) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
get api(url, user)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
get api(url, user)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_repo, :wiki_private) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'returns list of wiki pages'
+ include_examples "returns list of wiki pages"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'returns list of wiki pages'
+ include_examples "returns list of wiki pages"
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'returns list of wiki pages'
+ include_examples "returns list of wiki pages"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'returns list of wiki pages'
+ include_examples "returns list of wiki pages"
end
end
end
- describe 'GET /projects/:id/wikis/:slug' do
+ describe "GET /projects/:id/wikis/:slug" do
let(:page) { create(:wiki_page, wiki: project.wiki) }
let(:url) { "/projects/#{project.id}/wikis/#{page.slug}" }
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_repo, :wiki_disabled) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
get api(url, user)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
get api(url, user)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_repo, :wiki_private) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
get api(url, user)
end
- include_examples 'returns wiki page'
+ include_examples "returns wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
get api(url, user)
end
- include_examples 'returns wiki page'
+ include_examples "returns wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
get api(url)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
get api(url, user)
end
- include_examples 'returns wiki page'
+ include_examples "returns wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
get api(url, user)
end
- include_examples 'returns wiki page'
+ include_examples "returns wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
end
end
- describe 'POST /projects/:id/wikis' do
- let(:payload) { { title: 'title', content: 'content' } }
+ describe "POST /projects/:id/wikis" do
+ let(:payload) { {title: "title", content: "content"} }
let(:url) { "/projects/#{project.id}/wikis" }
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_disabled, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
post(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
post(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_private, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'creates wiki page'
+ include_examples "creates wiki page"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'creates wiki page'
+ include_examples "creates wiki page"
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'creates wiki page'
+ include_examples "creates wiki page"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'creates wiki page'
+ include_examples "creates wiki page"
end
end
end
- describe 'PUT /projects/:id/wikis/:slug' do
+ describe "PUT /projects/:id/wikis/:slug" do
let(:page) { create(:wiki_page, wiki: project_wiki) }
- let(:payload) { { title: 'new title', content: 'new content' } }
+ let(:payload) { {title: "new title", content: "new content"} }
let(:url) { "/projects/#{project.id}/wikis/#{page.slug}" }
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_disabled, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
put(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
put(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
put(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_private, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
put(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'updates wiki page'
+ include_examples "updates wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
before do
put(api(url, user), params: payload)
end
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'updates wiki page'
+ include_examples "updates wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
before do
put(api(url, user), params: payload)
end
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
put(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'updates wiki page'
+ include_examples "updates wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
before do
put(api(url, user), params: payload)
end
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'updates wiki page'
+ include_examples "updates wiki page"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
before do
put(api(url, user), params: payload)
end
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
end
- context 'when wiki belongs to a group project' do
+ context "when wiki belongs to a group project" do
let(:project) { create(:project, :wiki_repo, namespace: group) }
- include_examples 'updates wiki page'
+ include_examples "updates wiki page"
end
end
- describe 'DELETE /projects/:id/wikis/:slug' do
+ describe "DELETE /projects/:id/wikis/:slug" do
let(:page) { create(:wiki_page, wiki: project_wiki) }
let(:url) { "/projects/#{project.id}/wikis/#{page.slug}" }
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_disabled, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
delete(api(url))
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
delete(api(url, user))
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
delete(api(url, user))
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_private, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
delete(api(url))
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
delete(api(url, user))
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
delete(api(url, user))
end
- include_examples '204 No Content'
+ include_examples "204 No Content"
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
delete(api(url))
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
delete(api(url, user))
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
delete(api(url, user))
end
- include_examples '204 No Content'
+ include_examples "204 No Content"
- context 'when page is not existing' do
+ context "when page is not existing" do
let(:url) { "/projects/#{project.id}/wikis/unknown" }
- include_examples '404 Wiki Page Not Found'
+ include_examples "404 Wiki Page Not Found"
end
end
end
- context 'when wiki belongs to a group project' do
+ context "when wiki belongs to a group project" do
let(:project) { create(:project, :wiki_repo, namespace: group) }
before do
delete(api(url, user))
end
- include_examples '204 No Content'
+ include_examples "204 No Content"
end
end
- describe 'POST /projects/:id/wikis/attachments' do
- let(:payload) { { file: fixture_file_upload('spec/fixtures/dk.png') } }
+ describe "POST /projects/:id/wikis/attachments" do
+ let(:payload) { {file: fixture_file_upload("spec/fixtures/dk.png")} }
let(:url) { "/projects/#{project.id}/wikis/attachments" }
let(:file_path) { "#{Wikis::CreateAttachmentService::ATTACHMENT_PATH}/fixed_hex/dk.png" }
let(:result_hash) do
{
- file_name: 'dk.png',
+ file_name: "dk.png",
file_path: file_path,
- branch: 'master',
+ branch: "master",
link: {
url: file_path,
- markdown: "![dk](#{file_path})"
- }
+ markdown: "![dk](#{file_path})",
+ },
}
end
- context 'when wiki is disabled' do
+ context "when wiki is disabled" do
let(:project) { create(:project, :wiki_disabled, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
post(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
post(api(url, user), params: payload)
end
- include_examples '403 Forbidden'
+ include_examples "403 Forbidden"
end
end
- context 'when wiki is available only for team members' do
+ context "when wiki is available only for team members" do
let(:project) { create(:project, :wiki_private, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'uploads wiki attachment'
+ include_examples "uploads wiki attachment"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'uploads wiki attachment'
+ include_examples "uploads wiki attachment"
end
end
- context 'when wiki is available for everyone with access' do
+ context "when wiki is available for everyone with access" do
let(:project) { create(:project, :wiki_repo) }
- context 'when user is guest' do
+ context "when user is guest" do
before do
post(api(url), params: payload)
end
- include_examples '404 Project Not Found'
+ include_examples "404 Project Not Found"
end
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- include_examples 'uploads wiki attachment'
+ include_examples "uploads wiki attachment"
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
before do
project.add_maintainer(user)
end
- include_examples 'uploads wiki attachment'
+ include_examples "uploads wiki attachment"
end
end
end
diff --git a/spec/requests/git_http_spec.rb b/spec/requests/git_http_spec.rb
index 5b625fd47be..fb027f18685 100644
--- a/spec/requests/git_http_spec.rb
+++ b/spec/requests/git_http_spec.rb
@@ -1,17 +1,17 @@
require "spec_helper"
-describe 'Git HTTP requests' do
+describe "Git HTTP requests" do
include ProjectForksHelper
include TermsHelper
include GitHttpHelpers
include WorkhorseHelpers
- shared_examples 'pulls require Basic HTTP Authentication' do
+ shared_examples "pulls require Basic HTTP Authentication" do
context "when no credentials are provided" do
it "responds to downloads with status 401 Unauthorized (no project existence information leak)" do
download(path) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -20,7 +20,7 @@ describe 'Git HTTP requests' do
it "responds to downloads with status 401 Unauthorized" do
download(path, user: user.username) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -30,7 +30,7 @@ describe 'Git HTTP requests' do
it "responds to downloads with status 401 Unauthorized" do
download(path, user: user.username, password: "wrong-password") do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -39,19 +39,19 @@ describe 'Git HTTP requests' do
it "does not respond to downloads with status 401 Unauthorized" do
download(path, user: user.username, password: user.password) do |response|
expect(response).not_to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to be_nil
+ expect(response.header["WWW-Authenticate"]).to be_nil
end
end
end
end
end
- shared_examples 'pushes require Basic HTTP Authentication' do
+ shared_examples "pushes require Basic HTTP Authentication" do
context "when no credentials are provided" do
it "responds to uploads with status 401 Unauthorized (no project existence information leak)" do
upload(path) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -60,7 +60,7 @@ describe 'Git HTTP requests' do
it "responds to uploads with status 401 Unauthorized" do
upload(path, user: user.username) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -70,7 +70,7 @@ describe 'Git HTTP requests' do
it "responds to uploads with status 401 Unauthorized" do
upload(path, user: user.username, password: "wrong-password") do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to start_with('Basic ')
+ expect(response.header["WWW-Authenticate"]).to start_with("Basic ")
end
end
end
@@ -79,14 +79,14 @@ describe 'Git HTTP requests' do
it "does not respond to uploads with status 401 Unauthorized" do
upload(path, user: user.username, password: user.password) do |response|
expect(response).not_to have_gitlab_http_status(:unauthorized)
- expect(response.header['WWW-Authenticate']).to be_nil
+ expect(response.header["WWW-Authenticate"]).to be_nil
end
end
end
end
end
- shared_examples_for 'pulls are allowed' do
+ shared_examples_for "pulls are allowed" do
it do
download(path, env) do |response|
expect(response).to have_gitlab_http_status(:ok)
@@ -95,7 +95,7 @@ describe 'Git HTTP requests' do
end
end
- shared_examples_for 'pushes are allowed' do
+ shared_examples_for "pushes are allowed" do
it do
upload(path, env) do |response|
expect(response).to have_gitlab_http_status(:ok)
@@ -109,13 +109,13 @@ describe 'Git HTTP requests' do
context "when the project doesn't exist" do
context "when namespace doesn't exist" do
- let(:path) { 'doesnt/exist.git' }
+ let(:path) { "doesnt/exist.git" }
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
- context 'when authenticated' do
- it 'rejects downloads and uploads with 404 Not Found' do
+ context "when authenticated" do
+ it "rejects downloads and uploads with 404 Not Found" do
download_or_upload(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -123,19 +123,19 @@ describe 'Git HTTP requests' do
end
end
- context 'when namespace exists' do
+ context "when namespace exists" do
let(:path) { "#{user.namespace.path}/new-project.git"}
- context 'when authenticated' do
- it 'creates a new project under the existing namespace' do
- expect do
+ context "when authenticated" do
+ it "creates a new project under the existing namespace" do
+ expect {
upload(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
- end.to change { user.projects.count }.by(1)
+ }.to change { user.projects.count }.by(1)
end
- it 'rejects push with 422 Unprocessable Entity when project is invalid' do
+ it "rejects push with 422 Unprocessable Entity when project is invalid" do
path = "#{user.namespace.path}/new.git"
push_get(path, user: user.username, password: user.password)
@@ -153,42 +153,42 @@ describe 'Git HTTP requests' do
context "when the project is public" do
let(:project) { create(:project, :wiki_repo, :public, :wiki_enabled) }
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pushes require Basic HTTP Authentication"
- context 'when unauthenticated' do
+ context "when unauthenticated" do
let(:env) { {} }
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
it "responds to pulls with the wiki's repo" do
download(path) do |response|
json_body = ActiveSupport::JSON.decode(response.body)
- expect(json_body['Repository']['relative_path']).to eq(wiki.repository.relative_path)
+ expect(json_body["Repository"]["relative_path"]).to eq(wiki.repository.relative_path)
end
end
end
- context 'when authenticated' do
- let(:env) { { user: user.username, password: user.password } }
+ context "when authenticated" do
+ let(:env) { {user: user.username, password: user.password} }
- context 'and as a developer on the team' do
+ context "and as a developer on the team" do
before do
project.add_developer(user)
end
- context 'but the repo is disabled' do
+ context "but the repo is disabled" do
let(:project) { create(:project, :wiki_repo, :public, :repository_disabled, :wiki_enabled) }
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
end
end
- context 'and not on the team' do
- it_behaves_like 'pulls are allowed'
+ context "and not on the team" do
+ it_behaves_like "pulls are allowed"
- it 'rejects pushes with 403 Forbidden' do
+ it "rejects pushes with 403 Forbidden" do
upload(path, env) do |response|
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_wiki_error(:write_to_wiki))
@@ -201,25 +201,25 @@ describe 'Git HTTP requests' do
context "when the project is private" do
let(:project) { create(:project, :wiki_repo, :private, :wiki_enabled) }
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
- context 'when authenticated' do
- context 'and as a developer on the team' do
+ context "when authenticated" do
+ context "and as a developer on the team" do
before do
project.add_developer(user)
end
- context 'but the repo is disabled' do
+ context "but the repo is disabled" do
let(:project) { create(:project, :wiki_repo, :private, :repository_disabled, :wiki_enabled) }
- it 'allows clones' do
+ it "allows clones" do
download(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
end
- it 'pushes are allowed' do
+ it "pushes are allowed" do
upload(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
@@ -227,15 +227,15 @@ describe 'Git HTTP requests' do
end
end
- context 'and not on the team' do
- it 'rejects clones with 404 Not Found' do
+ context "and not on the team" do
+ it "rejects clones with 404 Not Found" do
download(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to eq(git_access_error(:project_not_found))
end
end
- it 'rejects pushes with 404 Not Found' do
+ it "rejects pushes with 404 Not Found" do
upload(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:not_found)
expect(response.body).to eq(git_access_error(:project_not_found))
@@ -252,31 +252,31 @@ describe 'Git HTTP requests' do
context "when the project is public" do
let(:project) { create(:project, :repository, :public) }
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pushes require Basic HTTP Authentication"
- context 'when not authenticated' do
+ context "when not authenticated" do
let(:env) { {} }
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
end
context "when authenticated" do
- let(:env) { { user: user.username, password: user.password } }
+ let(:env) { {user: user.username, password: user.password} }
- context 'as a developer on the team' do
+ context "as a developer on the team" do
before do
project.add_developer(user)
end
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
- context 'but git-receive-pack over HTTP is disabled in config' do
+ context "but git-receive-pack over HTTP is disabled in config" do
before do
allow(Gitlab.config.gitlab_shell).to receive(:receive_pack).and_return(false)
end
- it 'rejects pushes with 403 Forbidden' do
+ it "rejects pushes with 403 Forbidden" do
upload(path, env) do |response|
expect(response).to have_gitlab_http_status(:forbidden)
expect(response.body).to eq(git_access_error(:receive_pack_disabled_over_http))
@@ -284,7 +284,7 @@ describe 'Git HTTP requests' do
end
end
- context 'but git-upload-pack over HTTP is disabled in config' do
+ context "but git-upload-pack over HTTP is disabled in config" do
it "rejects pushes with 403 Forbidden" do
allow(Gitlab.config.gitlab_shell).to receive(:upload_pack).and_return(false)
@@ -296,73 +296,73 @@ describe 'Git HTTP requests' do
end
end
- context 'and not a member of the team' do
- it_behaves_like 'pulls are allowed'
+ context "and not a member of the team" do
+ it_behaves_like "pulls are allowed"
- it 'rejects pushes with 403 Forbidden' do
+ it "rejects pushes with 403 Forbidden" do
upload(path, env) do |response|
expect(response).to have_gitlab_http_status(:forbidden)
- expect(response.body).to eq('You are not allowed to push code to this project.')
+ expect(response.body).to eq("You are not allowed to push code to this project.")
end
end
- context 'when merge requests are open that allow maintainer access' do
+ context "when merge requests are open that allow maintainer access" do
let(:canonical_project) { create(:project, :public, :repository) }
let(:project) { fork_project(canonical_project, nil, repository: true) }
before do
canonical_project.add_maintainer(user)
create(:merge_request,
- source_project: project,
- target_project: canonical_project,
- source_branch: 'fixes',
- allow_collaboration: true)
+ source_project: project,
+ target_project: canonical_project,
+ source_branch: "fixes",
+ allow_collaboration: true)
end
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pushes are allowed"
end
end
end
- context 'when the request is not from gitlab-workhorse' do
- it 'raises an exception' do
- expect do
+ context "when the request is not from gitlab-workhorse" do
+ it "raises an exception" do
+ expect {
get("/#{project.full_path}.git/info/refs?service=git-upload-pack")
- end.to raise_error(JWT::DecodeError)
+ }.to raise_error(JWT::DecodeError)
end
end
- context 'when the repo is public' do
- context 'but the repo is disabled' do
+ context "when the repo is public" do
+ context "but the repo is disabled" do
let(:project) { create(:project, :public, :repository, :repository_disabled) }
let(:path) { "#{project.full_path}.git" }
let(:env) { {} }
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
end
- context 'but the repo is enabled' do
+ context "but the repo is enabled" do
let(:project) { create(:project, :public, :repository, :repository_enabled) }
let(:path) { "#{project.full_path}.git" }
let(:env) { {} }
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
end
- context 'but only project members are allowed' do
+ context "but only project members are allowed" do
let(:project) { create(:project, :public, :repository, :repository_private) }
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
end
end
- context 'and the user requests a redirected path' do
- let!(:redirect) { project.route.create_redirect('foo/bar') }
+ context "and the user requests a redirected path" do
+ let!(:redirect) { project.route.create_redirect("foo/bar") }
let(:path) { "#{redirect.path}.git" }
- it 'downloads get status 200 for redirects' do
+ it "downloads get status 200 for redirects" do
clone_get(path, {})
expect(response).to have_gitlab_http_status(:ok)
@@ -373,21 +373,21 @@ describe 'Git HTTP requests' do
context "when the project is private" do
let(:project) { create(:project, :repository, :private) }
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
context "when username and password are provided" do
- let(:env) { { user: user.username, password: 'nope' } }
+ let(:env) { {user: user.username, password: "nope"} }
context "when authentication fails" do
context "when the user is IP banned" do
before do
- Gitlab.config.rack_attack.git_basic_auth['enabled'] = true
+ Gitlab.config.rack_attack.git_basic_auth["enabled"] = true
end
it "responds with status 401" do
expect(Rack::Attack::Allow2Ban).to receive(:filter).and_return(true)
- allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return('1.2.3.4')
+ allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return("1.2.3.4")
clone_get(path, env)
@@ -397,7 +397,7 @@ describe 'Git HTTP requests' do
end
context "when authentication succeeds" do
- let(:env) { { user: user.username, password: user.password } }
+ let(:env) { {user: user.username, password: user.password} }
context "when the user has access to the project" do
before do
@@ -417,7 +417,7 @@ describe 'Git HTTP requests' do
it "rejects pulls with 401 Unauthorized for unknown projects (no project existence information leak)" do
user.block
- download('doesnt/exist.git', env) do |response|
+ download("doesnt/exist.git", env) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
end
end
@@ -425,7 +425,7 @@ describe 'Git HTTP requests' do
context "when the user isn't blocked" do
before do
- Gitlab.config.rack_attack.git_basic_auth['enabled'] = true
+ Gitlab.config.rack_attack.git_basic_auth["enabled"] = true
end
it "resets the IP in Rack Attack on download" do
@@ -446,7 +446,7 @@ describe 'Git HTTP requests' do
end
end
- it 'updates the user last activity', :clean_gitlab_redis_shared_state do
+ it "updates the user last activity", :clean_gitlab_redis_shared_state do
expect(user.last_activity_on).to be_nil
download(path, env) do |response|
@@ -462,13 +462,13 @@ describe 'Git HTTP requests' do
end
let(:path) { "#{project.full_path}.git" }
- let(:env) { { user: 'oauth2', password: @token.token } }
+ let(:env) { {user: "oauth2", password: @token.token} }
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
end
- context 'when user has 2FA enabled' do
+ context "when user has 2FA enabled" do
let(:user) { create(:user, :two_factor) }
let(:access_token) { create(:personal_access_token, user: user) }
let(:path) { "#{project.full_path}.git" }
@@ -477,60 +477,60 @@ describe 'Git HTTP requests' do
project.add_maintainer(user)
end
- context 'when username and password are provided' do
- it 'rejects pulls with personal access token error message' do
+ context "when username and password are provided" do
+ it "rejects pulls with personal access token error message" do
download(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
- it 'rejects the push attempt with personal access token error message' do
+ it "rejects the push attempt with personal access token error message" do
upload(path, user: user.username, password: user.password) do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
end
- context 'when username and personal access token are provided' do
- let(:env) { { user: user.username, password: access_token.token } }
+ context "when username and personal access token are provided" do
+ let(:env) { {user: user.username, password: access_token.token} }
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
end
end
- context 'when internal auth is disabled' do
+ context "when internal auth is disabled" do
before do
allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled_for_git?) { false }
end
- it 'rejects pulls with personal access token error message' do
- download(path, user: 'foo', password: 'bar') do |response|
+ it "rejects pulls with personal access token error message" do
+ download(path, user: "foo", password: "bar") do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
- it 'rejects pushes with personal access token error message' do
- upload(path, user: 'foo', password: 'bar') do |response|
+ it "rejects pushes with personal access token error message" do
+ upload(path, user: "foo", password: "bar") do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
- context 'when LDAP is configured' do
+ context "when LDAP is configured" do
before do
allow(Gitlab::Auth::LDAP::Config).to receive(:enabled?).and_return(true)
allow_any_instance_of(Gitlab::Auth::LDAP::Authentication)
.to receive(:login).and_return(nil)
end
- it 'does not display the personal access token error message' do
- upload(path, user: 'foo', password: 'bar') do |response|
+ it "does not display the personal access token error message" do
+ upload(path, user: "foo", password: "bar") do |response|
expect(response).to have_gitlab_http_status(:unauthorized)
- expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).not_to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
end
@@ -546,7 +546,7 @@ describe 'Git HTTP requests' do
it "repeated attempts followed by successful attempt" do
options = Gitlab.config.rack_attack.git_basic_auth
maxretry = options[:maxretry] - 1
- ip = '1.2.3.4'
+ ip = "1.2.3.4"
allow_any_instance_of(ActionDispatch::Request).to receive(:ip).and_return(ip)
Rack::Attack::Allow2Ban.reset(ip, options)
@@ -566,8 +566,8 @@ describe 'Git HTTP requests' do
end
end
- context 'and the user requests a redirected path' do
- let!(:redirect) { project.route.create_redirect('foo/bar') }
+ context "and the user requests a redirected path" do
+ let!(:redirect) { project.route.create_redirect("foo/bar") }
let(:path) { "#{redirect.path}.git" }
let(:project_moved_message) do
<<-MSG.strip_heredoc
@@ -579,7 +579,7 @@ describe 'Git HTTP requests' do
MSG
end
- it 'downloads get status 200' do
+ it "downloads get status 200" do
clone_get(path, env)
expect(response).to have_gitlab_http_status(:ok)
@@ -618,11 +618,11 @@ describe 'Git HTTP requests' do
build.update!(project: project) # can't associate it on factory create
end
- context 'when build created by system is authenticated' do
+ context "when build created by system is authenticated" do
let(:path) { "#{project.full_path}.git" }
- let(:env) { { user: 'gitlab-ci-token', password: build.token } }
+ let(:env) { {user: "gitlab-ci-token", password: build.token} }
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
# A non-401 here is not an information leak since the system is
# "authenticated" as CI using the correct token. It does not have
@@ -648,22 +648,22 @@ describe 'Git HTTP requests' do
end
end
- context 'and build created by' do
+ context "and build created by" do
before do
build.update(user: user)
project.add_reporter(user)
end
- shared_examples 'can download code only' do
+ shared_examples "can download code only" do
let(:path) { "#{project.full_path}.git" }
- let(:env) { { user: 'gitlab-ci-token', password: build.token } }
+ let(:env) { {user: "gitlab-ci-token", password: build.token} }
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
- context 'when the repo does not exist' do
+ context "when the repo does not exist" do
let(:project) { create(:project) }
- it 'rejects pulls with 404 Not Found' do
+ it "rejects pulls with 404 Not Found" do
clone_get path, env
expect(response).to have_gitlab_http_status(:not_found)
@@ -671,7 +671,7 @@ describe 'Git HTTP requests' do
end
end
- it 'rejects pushes with 403 Forbidden' do
+ it "rejects pushes with 403 Forbidden" do
push_get path, env
expect(response).to have_gitlab_http_status(:forbidden)
@@ -679,25 +679,25 @@ describe 'Git HTTP requests' do
end
end
- context 'administrator' do
+ context "administrator" do
let(:user) { create(:admin) }
- it_behaves_like 'can download code only'
+ it_behaves_like "can download code only"
- it 'downloads from other project get status 403' do
- clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token
+ it "downloads from other project get status 403" do
+ clone_get "#{other_project.full_path}.git", user: "gitlab-ci-token", password: build.token
expect(response).to have_gitlab_http_status(:forbidden)
end
end
- context 'regular user' do
+ context "regular user" do
let(:user) { create(:user) }
- it_behaves_like 'can download code only'
+ it_behaves_like "can download code only"
- it 'downloads from other project get status 404' do
- clone_get "#{other_project.full_path}.git", user: 'gitlab-ci-token', password: build.token
+ it "downloads from other project get status 404" do
+ clone_get "#{other_project.full_path}.git", user: "gitlab-ci-token", password: build.token
expect(response).to have_gitlab_http_status(:not_found)
end
@@ -707,7 +707,7 @@ describe 'Git HTTP requests' do
end
context "when the project path doesn't end in .git" do
- let(:project) { create(:project, :repository, :public, path: 'project.git-project') }
+ let(:project) { create(:project, :repository, :public, path: "project.git-project") }
context "GET info/refs" do
let(:path) { "/#{project.full_path}/info/refs" }
@@ -723,7 +723,7 @@ describe 'Git HTTP requests' do
end
context "when the upload-pack service is requested" do
- let(:params) { { service: 'git-upload-pack' } }
+ let(:params) { {service: "git-upload-pack"} }
before do
get path, params: params
@@ -735,7 +735,7 @@ describe 'Git HTTP requests' do
end
context "when the receive-pack service is requested" do
- let(:params) { { service: 'git-receive-pack' } }
+ let(:params) { {service: "git-receive-pack"} }
before do
get path, params: params
@@ -747,7 +747,7 @@ describe 'Git HTTP requests' do
end
context "when the params are anything else" do
- let(:params) { { service: 'git-implode-pack' } }
+ let(:params) { {service: "git-implode-pack"} }
before do
get path, params: params
@@ -779,8 +779,8 @@ describe 'Git HTTP requests' do
before do
# Provide a dummy file in its place
allow_any_instance_of(Repository).to receive(:blob_at).and_call_original
- allow_any_instance_of(Repository).to receive(:blob_at).with('b83d6e391c22777fca1ed3012fce84f633d7fed0', 'info/refs') do
- Blob.decorate(Gitlab::Git::Blob.find(project.repository, 'master', 'bar/branch-test.txt'), project)
+ allow_any_instance_of(Repository).to receive(:blob_at).with("b83d6e391c22777fca1ed3012fce84f633d7fed0", "info/refs") do
+ Blob.decorate(Gitlab::Git::Blob.find(project.repository, "master", "bar/branch-test.txt"), project)
end
get "/#{project.full_path}/blob/master/info/refs"
@@ -806,8 +806,8 @@ describe 'Git HTTP requests' do
describe "User with LDAP identity" do
let(:user) { create(:omniauth_user, extern_uid: dn) }
- let(:dn) { 'uid=john,ou=people,dc=example,dc=com' }
- let(:path) { 'doesnt/exist.git' }
+ let(:dn) { "uid=john,ou=people,dc=example,dc=com" }
+ let(:path) { "doesnt/exist.git" }
before do
allow(Gitlab::Auth::OAuth::Provider).to receive(:enabled?).and_return(true)
@@ -815,8 +815,8 @@ describe 'Git HTTP requests' do
allow_any_instance_of(Gitlab::Auth::LDAP::Authentication).to receive(:login).with(user.username, user.password).and_return(user)
end
- it_behaves_like 'pulls require Basic HTTP Authentication'
- it_behaves_like 'pushes require Basic HTTP Authentication'
+ it_behaves_like "pulls require Basic HTTP Authentication"
+ it_behaves_like "pushes require Basic HTTP Authentication"
context "when authentication succeeds" do
context "when the project doesn't exist" do
@@ -830,9 +830,9 @@ describe 'Git HTTP requests' do
context "when the project exists" do
let(:project) { create(:project, :repository) }
let(:path) { "#{project.full_path}.git" }
- let(:env) { { user: user.username, password: user.password } }
+ let(:env) { {user: user.username, password: user.password} }
- context 'and the user is on the team' do
+ context "and the user is on the team" do
before do
project.add_maintainer(user)
end
@@ -843,25 +843,25 @@ describe 'Git HTTP requests' do
end
end
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
end
end
end
end
- context 'when terms are enforced' do
+ context "when terms are enforced" do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:path) { "#{project.full_path}.git" }
- let(:env) { { user: user.username, password: user.password } }
+ let(:env) { {user: user.username, password: user.password} }
before do
project.add_maintainer(user)
enforce_terms
end
- it 'blocks git access when the user did not accept terms', :aggregate_failures do
+ it "blocks git access when the user did not accept terms", :aggregate_failures do
clone_get(path, env) do |response|
expect(response).to have_gitlab_http_status(:forbidden)
end
@@ -875,30 +875,30 @@ describe 'Git HTTP requests' do
end
end
- context 'when the user accepted the terms' do
+ context "when the user accepted the terms" do
before do
accept_terms(user)
end
- it 'allows clones' do
+ it "allows clones" do
clone_get(path, env) do |response|
expect(response).to have_gitlab_http_status(:ok)
end
end
- it_behaves_like 'pulls are allowed'
- it_behaves_like 'pushes are allowed'
+ it_behaves_like "pulls are allowed"
+ it_behaves_like "pushes are allowed"
end
- context 'from CI' do
+ context "from CI" do
let(:build) { create(:ci_build, :running) }
- let(:env) { { user: 'gitlab-ci-token', password: build.token } }
+ let(:env) { {user: "gitlab-ci-token", password: build.token} }
before do
build.update!(user: user, project: project)
end
- it_behaves_like 'pulls are allowed'
+ it_behaves_like "pulls are allowed"
end
end
end
diff --git a/spec/requests/jwt_controller_spec.rb b/spec/requests/jwt_controller_spec.rb
index 4bb3b848e17..14debcd4075 100644
--- a/spec/requests/jwt_controller_spec.rb
+++ b/spec/requests/jwt_controller_spec.rb
@@ -1,155 +1,155 @@
-require 'spec_helper'
+require "spec_helper"
describe JwtController do
let(:service) { double(execute: {}) }
let(:service_class) { double(new: service) }
- let(:service_name) { 'test' }
- let(:parameters) { { service: service_name } }
+ let(:service_name) { "test" }
+ let(:parameters) { {service: service_name} }
before do
- stub_const('JwtController::SERVICES', service_name => service_class)
+ stub_const("JwtController::SERVICES", service_name => service_class)
end
- context 'existing service' do
- subject! { get '/jwt/auth', params: parameters }
+ context "existing service" do
+ subject! { get "/jwt/auth", params: parameters }
it { expect(response).to have_gitlab_http_status(200) }
- context 'returning custom http code' do
- let(:service) { double(execute: { http_status: 505 }) }
+ context "returning custom http code" do
+ let(:service) { double(execute: {http_status: 505}) }
it { expect(response).to have_gitlab_http_status(505) }
end
end
- context 'when using authenticated request' do
- context 'using CI token' do
+ context "when using authenticated request" do
+ context "using CI token" do
let(:build) { create(:ci_build, :running) }
let(:project) { build.project }
- let(:headers) { { authorization: credentials('gitlab-ci-token', build.token) } }
+ let(:headers) { {authorization: credentials("gitlab-ci-token", build.token)} }
- context 'project with enabled CI' do
- subject! { get '/jwt/auth', params: parameters, headers: headers }
+ context "project with enabled CI" do
+ subject! { get "/jwt/auth", params: parameters, headers: headers }
it { expect(service_class).to have_received(:new).with(project, nil, ActionController::Parameters.new(parameters).permit!) }
end
- context 'project with disabled CI' do
+ context "project with disabled CI" do
before do
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end
- subject! { get '/jwt/auth', params: parameters, headers: headers }
+ subject! { get "/jwt/auth", params: parameters, headers: headers }
it { expect(response).to have_gitlab_http_status(401) }
end
- context 'using personal access tokens' do
+ context "using personal access tokens" do
let(:user) { create(:user) }
- let(:pat) { create(:personal_access_token, user: user, scopes: ['read_registry']) }
- let(:headers) { { authorization: credentials('personal_access_token', pat.token) } }
+ let(:pat) { create(:personal_access_token, user: user, scopes: ["read_registry"]) }
+ let(:headers) { {authorization: credentials("personal_access_token", pat.token)} }
before do
stub_container_registry_config(enabled: true)
end
- subject! { get '/jwt/auth', params: parameters, headers: headers }
+ subject! { get "/jwt/auth", params: parameters, headers: headers }
- it 'authenticates correctly' do
+ it "authenticates correctly" do
expect(response).to have_gitlab_http_status(200)
expect(service_class).to have_received(:new).with(nil, user, ActionController::Parameters.new(parameters).permit!)
end
end
end
- context 'using User login' do
+ context "using User login" do
let(:user) { create(:user) }
- let(:headers) { { authorization: credentials(user.username, user.password) } }
+ let(:headers) { {authorization: credentials(user.username, user.password)} }
- subject! { get '/jwt/auth', params: parameters, headers: headers }
+ subject! { get "/jwt/auth", params: parameters, headers: headers }
it { expect(service_class).to have_received(:new).with(nil, user, ActionController::Parameters.new(parameters).permit!) }
- context 'when passing a flat array of scopes' do
+ context "when passing a flat array of scopes" do
# We use this trick to make rails to generate a query_string:
# scope=scope1&scope=scope2
# It works because :scope and 'scope' are the same as string, but different objects
let(:parameters) do
{
:service => service_name,
- :scope => 'scope1',
- 'scope' => 'scope2'
+ :scope => "scope1",
+ "scope" => "scope2",
}
end
let(:service_parameters) do
- ActionController::Parameters.new({ service: service_name, scopes: %w(scope1 scope2) }).permit!
+ ActionController::Parameters.new({service: service_name, scopes: %w[scope1 scope2]}).permit!
end
it { expect(service_class).to have_received(:new).with(nil, user, service_parameters) }
end
- context 'when user has 2FA enabled' do
+ context "when user has 2FA enabled" do
let(:user) { create(:user, :two_factor) }
- context 'without personal token' do
- it 'rejects the authorization attempt' do
+ context "without personal token" do
+ it "rejects the authorization attempt" do
expect(response).to have_gitlab_http_status(401)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
- context 'with personal token' do
+ context "with personal token" do
let(:access_token) { create(:personal_access_token, user: user) }
- let(:headers) { { authorization: credentials(user.username, access_token.token) } }
+ let(:headers) { {authorization: credentials(user.username, access_token.token)} }
- it 'accepts the authorization attempt' do
+ it "accepts the authorization attempt" do
expect(response).to have_gitlab_http_status(200)
end
end
end
end
- context 'using invalid login' do
- let(:headers) { { authorization: credentials('invalid', 'password') } }
+ context "using invalid login" do
+ let(:headers) { {authorization: credentials("invalid", "password")} }
- context 'when internal auth is enabled' do
- it 'rejects the authorization attempt' do
- get '/jwt/auth', params: parameters, headers: headers
+ context "when internal auth is enabled" do
+ it "rejects the authorization attempt" do
+ get "/jwt/auth", params: parameters, headers: headers
expect(response).to have_gitlab_http_status(401)
- expect(response.body).not_to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).not_to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
- context 'when internal auth is disabled' do
- it 'rejects the authorization attempt with personal access token message' do
+ context "when internal auth is disabled" do
+ it "rejects the authorization attempt with personal access token message" do
allow_any_instance_of(ApplicationSetting).to receive(:password_authentication_enabled_for_git?) { false }
- get '/jwt/auth', params: parameters, headers: headers
+ get "/jwt/auth", params: parameters, headers: headers
expect(response).to have_gitlab_http_status(401)
- expect(response.body).to include('You must use a personal access token with \'api\' scope for Git over HTTP')
+ expect(response.body).to include("You must use a personal access token with 'api' scope for Git over HTTP")
end
end
end
end
- context 'when using unauthenticated request' do
- it 'accepts the authorization attempt' do
- get '/jwt/auth', params: parameters
+ context "when using unauthenticated request" do
+ it "accepts the authorization attempt" do
+ get "/jwt/auth", params: parameters
expect(response).to have_gitlab_http_status(200)
end
- it 'allows read access' do
+ it "allows read access" do
expect(service).to receive(:execute).with(authentication_abilities: Gitlab::Auth.read_authentication_abilities)
- get '/jwt/auth', params: parameters
+ get "/jwt/auth", params: parameters
end
end
- context 'unknown service' do
- subject! { get '/jwt/auth', params: { service: 'unknown' } }
+ context "unknown service" do
+ subject! { get "/jwt/auth", params: {service: "unknown"} }
it { expect(response).to have_gitlab_http_status(404) }
end
diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb
index 1781759c54b..dfaf813aff0 100644
--- a/spec/requests/lfs_http_spec.rb
+++ b/spec/requests/lfs_http_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Git LFS API and storage' do
+describe "Git LFS API and storage" do
include WorkhorseHelpers
include ProjectForksHelper
@@ -9,8 +9,8 @@ describe 'Git LFS API and storage' do
let(:headers) do
{
- 'Authorization' => authorization,
- 'X-Sendfile-Type' => sendfile
+ "Authorization" => authorization,
+ "X-Sendfile-Type" => sendfile,
}.compact
end
let(:authorization) { }
@@ -20,17 +20,17 @@ describe 'Git LFS API and storage' do
let(:sample_oid) { lfs_object.oid }
let(:sample_size) { lfs_object.size }
- describe 'when lfs is disabled' do
+ describe "when lfs is disabled" do
let(:project) { create(:project) }
let(:body) do
{
- 'objects' => [
- { 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078 },
- { 'oid' => sample_oid,
- 'size' => sample_size }
+ "objects" => [
+ {"oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,},
+ {"oid" => sample_oid,
+ "size" => sample_size,},
],
- 'operation' => 'upload'
+ "operation" => "upload",
}
end
let(:authorization) { authorize_user }
@@ -40,63 +40,63 @@ describe 'Git LFS API and storage' do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
end
- it 'responds with 501' do
+ it "responds with 501" do
expect(response).to have_gitlab_http_status(501)
- expect(json_response).to include('message' => 'Git LFS is not enabled on this GitLab server, contact your admin.')
+ expect(json_response).to include("message" => "Git LFS is not enabled on this GitLab server, contact your admin.")
end
end
- context 'project specific LFS settings' do
+ context "project specific LFS settings" do
let(:project) { create(:project) }
let(:body) do
{
- 'objects' => [
- { 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078 },
- { 'oid' => sample_oid,
- 'size' => sample_size }
+ "objects" => [
+ {"oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,},
+ {"oid" => sample_oid,
+ "size" => sample_size,},
],
- 'operation' => 'upload'
+ "operation" => "upload",
}
end
let(:authorization) { authorize_user }
- context 'with LFS disabled globally' do
+ context "with LFS disabled globally" do
before do
project.add_maintainer(user)
allow(Gitlab.config.lfs).to receive(:enabled).and_return(false)
end
- describe 'LFS disabled in project' do
+ describe "LFS disabled in project" do
before do
project.update_attribute(:lfs_enabled, false)
end
- it 'responds with a 501 message on upload' do
+ it "responds with a 501 message on upload" do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
expect(response).to have_gitlab_http_status(501)
end
- it 'responds with a 501 message on download' do
+ it "responds with a 501 message on download" do
get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers
expect(response).to have_gitlab_http_status(501)
end
end
- describe 'LFS enabled in project' do
+ describe "LFS enabled in project" do
before do
project.update_attribute(:lfs_enabled, true)
end
- it 'responds with a 501 message on upload' do
+ it "responds with a 501 message on upload" do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
expect(response).to have_gitlab_http_status(501)
end
- it 'responds with a 501 message on download' do
+ it "responds with a 501 message on download" do
get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers
expect(response).to have_gitlab_http_status(501)
@@ -104,45 +104,45 @@ describe 'Git LFS API and storage' do
end
end
- context 'with LFS enabled globally' do
+ context "with LFS enabled globally" do
before do
project.add_maintainer(user)
enable_lfs
end
- describe 'LFS disabled in project' do
+ describe "LFS disabled in project" do
before do
project.update_attribute(:lfs_enabled, false)
end
- it 'responds with a 403 message on upload' do
+ it "responds with a 403 message on upload" do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
expect(response).to have_gitlab_http_status(403)
- expect(json_response).to include('message' => 'Access forbidden. Check your access level.')
+ expect(json_response).to include("message" => "Access forbidden. Check your access level.")
end
- it 'responds with a 403 message on download' do
+ it "responds with a 403 message on download" do
get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers
expect(response).to have_gitlab_http_status(403)
- expect(json_response).to include('message' => 'Access forbidden. Check your access level.')
+ expect(json_response).to include("message" => "Access forbidden. Check your access level.")
end
end
- describe 'LFS enabled in project' do
+ describe "LFS enabled in project" do
before do
project.update_attribute(:lfs_enabled, true)
end
- it 'responds with a 200 message on upload' do
+ it "responds with a 200 message on upload" do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
expect(response).to have_gitlab_http_status(200)
- expect(json_response['objects'].first['size']).to eq(1575078)
+ expect(json_response["objects"].first["size"]).to eq(1575078)
end
- it 'responds with a 200 message on download' do
+ it "responds with a 200 message on download" do
get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers
expect(response).to have_gitlab_http_status(200)
@@ -151,44 +151,44 @@ describe 'Git LFS API and storage' do
end
end
- describe 'deprecated API' do
+ describe "deprecated API" do
let(:project) { create(:project) }
before do
enable_lfs
end
- shared_examples 'a deprecated' do
- it 'responds with 501' do
+ shared_examples "a deprecated" do
+ it "responds with 501" do
expect(response).to have_gitlab_http_status(501)
end
- it 'returns deprecated message' do
- expect(json_response).to include('message' => 'Server supports batch API only, please update your Git LFS client to version 1.0.1 and up.')
+ it "returns deprecated message" do
+ expect(json_response).to include("message" => "Server supports batch API only, please update your Git LFS client to version 1.0.1 and up.")
end
end
- context 'when fetching lfs object using deprecated API' do
+ context "when fetching lfs object using deprecated API" do
let(:authorization) { authorize_user }
before do
get "#{project.http_url_to_repo}/info/lfs/objects/#{sample_oid}", params: {}, headers: headers
end
- it_behaves_like 'a deprecated'
+ it_behaves_like "a deprecated"
end
- context 'when handling lfs request using deprecated API' do
+ context "when handling lfs request using deprecated API" do
let(:authorization) { authorize_user }
before do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects", nil, headers
end
- it_behaves_like 'a deprecated'
+ it_behaves_like "a deprecated"
end
end
- describe 'when fetching lfs object' do
+ describe "when fetching lfs object" do
let(:project) { create(:project) }
let(:update_permissions) { }
let(:before_get) { }
@@ -200,75 +200,75 @@ describe 'Git LFS API and storage' do
get "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}", params: {}, headers: headers
end
- context 'and request comes from gitlab-workhorse' do
- context 'without user being authorized' do
- it 'responds with status 401' do
+ context "and request comes from gitlab-workhorse" do
+ context "without user being authorized" do
+ it "responds with status 401" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'with required headers' do
- shared_examples 'responds with a file' do
- let(:sendfile) { 'X-Sendfile' }
+ context "with required headers" do
+ shared_examples "responds with a file" do
+ let(:sendfile) { "X-Sendfile" }
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with the file location' do
- expect(response.headers['Content-Type']).to eq('application/octet-stream')
- expect(response.headers['X-Sendfile']).to eq(lfs_object.file.path)
+ it "responds with the file location" do
+ expect(response.headers["Content-Type"]).to eq("application/octet-stream")
+ expect(response.headers["X-Sendfile"]).to eq(lfs_object.file.path)
end
end
- context 'with user is authorized' do
+ context "with user is authorized" do
let(:authorization) { authorize_user }
- context 'and does not have project access' do
+ context "and does not have project access" do
let(:update_permissions) do
project.lfs_objects << lfs_object
end
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'and does have project access' do
+ context "and does have project access" do
let(:update_permissions) do
project.add_maintainer(user)
project.lfs_objects << lfs_object
end
- it_behaves_like 'responds with a file'
+ it_behaves_like "responds with a file"
- context 'when LFS uses object storage' do
- context 'when proxy download is enabled' do
+ context "when LFS uses object storage" do
+ context "when proxy download is enabled" do
let(:before_get) do
stub_lfs_object_storage(proxy_download: true)
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
end
- it 'responds with redirect' do
+ it "responds with redirect" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with the workhorse send-url' do
+ it "responds with the workhorse send-url" do
expect(response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("send-url:")
end
end
- context 'when proxy download is disabled' do
+ context "when proxy download is disabled" do
let(:before_get) do
stub_lfs_object_storage(proxy_download: false)
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
end
- it 'responds with redirect' do
+ it "responds with redirect" do
expect(response).to have_gitlab_http_status(302)
end
- it 'responds with the file location' do
+ it "responds with the file location" do
expect(response.location).to include(lfs_object.reload.file.path)
end
end
@@ -276,7 +276,7 @@ describe 'Git LFS API and storage' do
end
end
- context 'when deploy key is authorized' do
+ context "when deploy key is authorized" do
let(:key) { create(:deploy_key) }
let(:authorization) { authorize_deploy_key }
@@ -285,47 +285,47 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- it_behaves_like 'responds with a file'
+ it_behaves_like "responds with a file"
end
- describe 'when using a user key' do
+ describe "when using a user key" do
let(:authorization) { authorize_user_key }
- context 'when user allowed' do
+ context "when user allowed" do
let(:update_permissions) do
project.add_maintainer(user)
project.lfs_objects << lfs_object
end
- it_behaves_like 'responds with a file'
+ it_behaves_like "responds with a file"
end
- context 'when user not allowed' do
+ context "when user not allowed" do
let(:update_permissions) do
project.lfs_objects << lfs_object
end
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when build is authorized as' do
+ context "when build is authorized as" do
let(:authorization) { authorize_ci_project }
- shared_examples 'can download LFS only from own projects' do
- context 'for owned project' do
+ shared_examples "can download LFS only from own projects" do
+ context "for owned project" do
let(:project) { create(:project, namespace: user.namespace) }
let(:update_permissions) do
project.lfs_objects << lfs_object
end
- it_behaves_like 'responds with a file'
+ it_behaves_like "responds with a file"
end
- context 'for member of project' do
+ context "for member of project" do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:update_permissions) do
@@ -333,10 +333,10 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- it_behaves_like 'responds with a file'
+ it_behaves_like "responds with a file"
end
- context 'for other project' do
+ context "for other project" do
let(:other_project) { create(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: other_project) }
@@ -344,36 +344,36 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- it 'rejects downloading code' do
+ it "rejects downloading code" do
expect(response).to have_gitlab_http_status(other_project_status)
end
end
end
- context 'administrator' do
+ context "administrator" do
let(:user) { create(:admin) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 403, because administrator does have normally access
let(:other_project_status) { 403 }
end
end
- context 'regular user' do
+ context "regular user" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 404, to prevent data leakage about existence of the project
let(:other_project_status) { 404 }
end
end
- context 'does not have user' do
+ context "does not have user" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 404, to prevent data leakage about existence of the project
let(:other_project_status) { 404 }
end
@@ -381,17 +381,17 @@ describe 'Git LFS API and storage' do
end
end
- context 'without required headers' do
+ context "without required headers" do
let(:authorization) { authorize_user }
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
end
- describe 'when handling lfs batch request' do
+ describe "when handling lfs batch request" do
let(:update_lfs_permissions) { }
let(:update_user_permissions) { }
@@ -402,113 +402,113 @@ describe 'Git LFS API and storage' do
post_lfs_json "#{project.http_url_to_repo}/info/lfs/objects/batch", body, headers
end
- describe 'download' do
+ describe "download" do
let(:project) { create(:project) }
let(:body) do
{
- 'operation' => 'download',
- 'objects' => [
- { 'oid' => sample_oid,
- 'size' => sample_size }
- ]
+ "operation" => "download",
+ "objects" => [
+ {"oid" => sample_oid,
+ "size" => sample_size,},
+ ],
}
end
- shared_examples 'an authorized requests' do
- context 'when downloading an lfs object that is assigned to our project' do
+ shared_examples "an authorized requests" do
+ context "when downloading an lfs object that is assigned to our project" do
let(:update_lfs_permissions) do
project.lfs_objects << lfs_object
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'with href to download' do
+ it "with href to download" do
expect(json_response).to eq({
- 'objects' => [
+ "objects" => [
{
- 'oid' => sample_oid,
- 'size' => sample_size,
- 'actions' => {
- 'download' => {
- 'href' => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
- 'header' => { 'Authorization' => authorization }
- }
- }
- }
- ]
+ "oid" => sample_oid,
+ "size" => sample_size,
+ "actions" => {
+ "download" => {
+ "href" => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
+ "header" => {"Authorization" => authorization},
+ },
+ },
+ },
+ ],
})
end
end
- context 'when downloading an lfs object that is assigned to other project' do
+ context "when downloading an lfs object that is assigned to other project" do
let(:other_project) { create(:project) }
let(:update_lfs_permissions) do
other_project.lfs_objects << lfs_object
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'with href to download' do
+ it "with href to download" do
expect(json_response).to eq({
- 'objects' => [
+ "objects" => [
{
- 'oid' => sample_oid,
- 'size' => sample_size,
- 'error' => {
- 'code' => 404,
- 'message' => "Object does not exist on the server or you don't have permissions to access it"
- }
- }
- ]
+ "oid" => sample_oid,
+ "size" => sample_size,
+ "error" => {
+ "code" => 404,
+ "message" => "Object does not exist on the server or you don't have permissions to access it",
+ },
+ },
+ ],
})
end
end
- context 'when downloading a lfs object that does not exist' do
+ context "when downloading a lfs object that does not exist" do
let(:body) do
{
- 'operation' => 'download',
- 'objects' => [
- { 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078 }
- ]
+ "operation" => "download",
+ "objects" => [
+ {"oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,},
+ ],
}
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'with an 404 for specific object' do
+ it "with an 404 for specific object" do
expect(json_response).to eq({
- 'objects' => [
+ "objects" => [
{
- 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078,
- 'error' => {
- 'code' => 404,
- 'message' => "Object does not exist on the server or you don't have permissions to access it"
- }
- }
- ]
+ "oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,
+ "error" => {
+ "code" => 404,
+ "message" => "Object does not exist on the server or you don't have permissions to access it",
+ },
+ },
+ ],
})
end
end
- context 'when downloading one new and one existing lfs object' do
+ context "when downloading one new and one existing lfs object" do
let(:body) do
{
- 'operation' => 'download',
- 'objects' => [
- { 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078 },
- { 'oid' => sample_oid,
- 'size' => sample_size }
- ]
+ "operation" => "download",
+ "objects" => [
+ {"oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,},
+ {"oid" => sample_oid,
+ "size" => sample_size,},
+ ],
}
end
@@ -516,66 +516,66 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with upload hypermedia link for the new object' do
+ it "responds with upload hypermedia link for the new object" do
expect(json_response).to eq({
- 'objects' => [
+ "objects" => [
{
- 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078,
- 'error' => {
- 'code' => 404,
- 'message' => "Object does not exist on the server or you don't have permissions to access it"
- }
+ "oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,
+ "error" => {
+ "code" => 404,
+ "message" => "Object does not exist on the server or you don't have permissions to access it",
+ },
},
{
- 'oid' => sample_oid,
- 'size' => sample_size,
- 'actions' => {
- 'download' => {
- 'href' => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
- 'header' => { 'Authorization' => authorization }
- }
- }
- }
- ]
+ "oid" => sample_oid,
+ "size" => sample_size,
+ "actions" => {
+ "download" => {
+ "href" => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
+ "header" => {"Authorization" => authorization},
+ },
+ },
+ },
+ ],
})
end
end
end
- context 'when user is authenticated' do
+ context "when user is authenticated" do
let(:authorization) { authorize_user }
let(:update_user_permissions) do
project.add_role(user, role)
end
- it_behaves_like 'an authorized requests' do
+ it_behaves_like "an authorized requests" do
let(:role) { :reporter }
end
- context 'when user does is not member of the project' do
+ context "when user does is not member of the project" do
let(:update_user_permissions) { nil }
- it 'responds with 404' do
+ it "responds with 404" do
expect(response).to have_gitlab_http_status(404)
end
end
- context 'when user does not have download access' do
+ context "when user does not have download access" do
let(:role) { :guest }
- it 'responds with 403' do
+ it "responds with 403" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'when using Deploy Tokens' do
+ context "when using Deploy Tokens" do
let(:project) { create(:project, :repository) }
let(:authorization) { authorize_deploy_token }
let(:update_user_permissions) { nil }
@@ -584,201 +584,201 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- context 'when Deploy Token is valid' do
+ context "when Deploy Token is valid" do
let(:deploy_token) { create(:deploy_token, projects: [project]) }
- it_behaves_like 'an authorized requests'
+ it_behaves_like "an authorized requests"
end
- context 'when Deploy Token is not valid' do
+ context "when Deploy Token is not valid" do
let(:deploy_token) { create(:deploy_token, projects: [project], read_repository: false) }
- it 'responds with access denied' do
+ it "responds with access denied" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when Deploy Token is not related to the project' do
+ context "when Deploy Token is not related to the project" do
let(:another_project) { create(:project, :repository) }
let(:deploy_token) { create(:deploy_token, projects: [another_project]) }
- it 'responds with access forbidden' do
+ it "responds with access forbidden" do
# We render 404, to prevent data leakage about existence of the project
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'when build is authorized as' do
+ context "when build is authorized as" do
let(:authorization) { authorize_ci_project }
let(:update_lfs_permissions) do
project.lfs_objects << lfs_object
end
- shared_examples 'can download LFS only from own projects' do
- context 'for own project' do
+ shared_examples "can download LFS only from own projects" do
+ context "for own project" do
let(:pipeline) { create(:ci_empty_pipeline, project: project) }
let(:update_user_permissions) do
project.add_reporter(user)
end
- it_behaves_like 'an authorized requests'
+ it_behaves_like "an authorized requests"
end
- context 'for other project' do
+ context "for other project" do
let(:other_project) { create(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: other_project) }
- it 'rejects downloading code' do
+ it "rejects downloading code" do
expect(response).to have_gitlab_http_status(other_project_status)
end
end
end
- context 'administrator' do
+ context "administrator" do
let(:user) { create(:admin) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 403, because administrator does have normally access
let(:other_project_status) { 403 }
end
end
- context 'regular user' do
+ context "regular user" do
let(:user) { create(:user) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 404, to prevent data leakage about existence of the project
let(:other_project_status) { 404 }
end
end
- context 'does not have user' do
+ context "does not have user" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
- it_behaves_like 'can download LFS only from own projects' do
+ it_behaves_like "can download LFS only from own projects" do
# We render 404, to prevent data leakage about existence of the project
let(:other_project_status) { 404 }
end
end
end
- context 'when user is not authenticated' do
- describe 'is accessing public project' do
+ context "when user is not authenticated" do
+ describe "is accessing public project" do
let(:project) { create(:project, :public) }
let(:update_lfs_permissions) do
project.lfs_objects << lfs_object
end
- it 'responds with status 200 and href to download' do
+ it "responds with status 200 and href to download" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with status 200 and href to download' do
+ it "responds with status 200 and href to download" do
expect(json_response).to eq({
- 'objects' => [
+ "objects" => [
{
- 'oid' => sample_oid,
- 'size' => sample_size,
- 'authenticated' => true,
- 'actions' => {
- 'download' => {
- 'href' => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
- 'header' => {}
- }
- }
- }
- ]
+ "oid" => sample_oid,
+ "size" => sample_size,
+ "authenticated" => true,
+ "actions" => {
+ "download" => {
+ "href" => "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}",
+ "header" => {},
+ },
+ },
+ },
+ ],
})
end
end
- describe 'is accessing non-public project' do
+ describe "is accessing non-public project" do
let(:update_lfs_permissions) do
project.lfs_objects << lfs_object
end
- it 'responds with authorization required' do
+ it "responds with authorization required" do
expect(response).to have_gitlab_http_status(401)
end
end
end
end
- describe 'upload' do
+ describe "upload" do
let(:project) { create(:project, :public) }
let(:body) do
{
- 'operation' => 'upload',
- 'objects' => [
- { 'oid' => sample_oid,
- 'size' => sample_size }
- ]
+ "operation" => "upload",
+ "objects" => [
+ {"oid" => sample_oid,
+ "size" => sample_size,},
+ ],
}
end
- shared_examples 'pushes new LFS objects' do
+ shared_examples "pushes new LFS objects" do
let(:sample_size) { 150.megabytes }
- let(:sample_oid) { '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' }
+ let(:sample_oid) { "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897" }
- it 'responds with upload hypermedia link' do
+ it "responds with upload hypermedia link" do
expect(response).to have_gitlab_http_status(200)
- expect(json_response['objects']).to be_kind_of(Array)
- expect(json_response['objects'].first['oid']).to eq(sample_oid)
- expect(json_response['objects'].first['size']).to eq(sample_size)
- expect(json_response['objects'].first['actions']['upload']['href']).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}.git/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
- expect(json_response['objects'].first['actions']['upload']['header']).to eq({ 'Authorization' => authorization, 'Content-Type' => 'application/octet-stream' })
+ expect(json_response["objects"]).to be_kind_of(Array)
+ expect(json_response["objects"].first["oid"]).to eq(sample_oid)
+ expect(json_response["objects"].first["size"]).to eq(sample_size)
+ expect(json_response["objects"].first["actions"]["upload"]["href"]).to eq("#{Gitlab.config.gitlab.url}/#{project.full_path}.git/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
+ expect(json_response["objects"].first["actions"]["upload"]["header"]).to eq({"Authorization" => authorization, "Content-Type" => "application/octet-stream"})
end
end
- describe 'when request is authenticated' do
- describe 'when user has project push access' do
+ describe "when request is authenticated" do
+ describe "when user has project push access" do
let(:authorization) { authorize_user }
let(:update_user_permissions) do
project.add_developer(user)
end
- context 'when pushing an lfs object that already exists' do
+ context "when pushing an lfs object that already exists" do
let(:other_project) { create(:project) }
let(:update_lfs_permissions) do
other_project.lfs_objects << lfs_object
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with links the object to the project' do
- expect(json_response['objects']).to be_kind_of(Array)
- expect(json_response['objects'].first['oid']).to eq(sample_oid)
- expect(json_response['objects'].first['size']).to eq(sample_size)
+ it "responds with links the object to the project" do
+ expect(json_response["objects"]).to be_kind_of(Array)
+ expect(json_response["objects"].first["oid"]).to eq(sample_oid)
+ expect(json_response["objects"].first["size"]).to eq(sample_size)
expect(lfs_object.projects.pluck(:id)).not_to include(project.id)
expect(lfs_object.projects.pluck(:id)).to include(other_project.id)
- expect(json_response['objects'].first['actions']['upload']['href']).to eq("#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
- expect(json_response['objects'].first['actions']['upload']['header']).to eq({ 'Authorization' => authorization, 'Content-Type' => 'application/octet-stream' })
+ expect(json_response["objects"].first["actions"]["upload"]["href"]).to eq("#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}")
+ expect(json_response["objects"].first["actions"]["upload"]["header"]).to eq({"Authorization" => authorization, "Content-Type" => "application/octet-stream"})
end
end
- context 'when pushing a lfs object that does not exist' do
- it_behaves_like 'pushes new LFS objects'
+ context "when pushing a lfs object that does not exist" do
+ it_behaves_like "pushes new LFS objects"
end
- context 'when pushing one new and one existing lfs object' do
+ context "when pushing one new and one existing lfs object" do
let(:body) do
{
- 'operation' => 'upload',
- 'objects' => [
- { 'oid' => '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897',
- 'size' => 1575078 },
- { 'oid' => sample_oid,
- 'size' => sample_size }
- ]
+ "operation" => "upload",
+ "objects" => [
+ {"oid" => "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ "size" => 1575078,},
+ {"oid" => sample_oid,
+ "size" => sample_size,},
+ ],
}
end
@@ -786,69 +786,69 @@ describe 'Git LFS API and storage' do
project.lfs_objects << lfs_object
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with upload hypermedia link for the new object' do
- expect(json_response['objects']).to be_kind_of(Array)
+ it "responds with upload hypermedia link for the new object" do
+ expect(json_response["objects"]).to be_kind_of(Array)
- expect(json_response['objects'].first['oid']).to eq("91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897")
- expect(json_response['objects'].first['size']).to eq(1575078)
- expect(json_response['objects'].first['actions']['upload']['href']).to eq("#{project.http_url_to_repo}/gitlab-lfs/objects/91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897/1575078")
- expect(json_response['objects'].first['actions']['upload']['header']).to eq({ 'Authorization' => authorization, 'Content-Type' => 'application/octet-stream' })
+ expect(json_response["objects"].first["oid"]).to eq("91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897")
+ expect(json_response["objects"].first["size"]).to eq(1575078)
+ expect(json_response["objects"].first["actions"]["upload"]["href"]).to eq("#{project.http_url_to_repo}/gitlab-lfs/objects/91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897/1575078")
+ expect(json_response["objects"].first["actions"]["upload"]["header"]).to eq({"Authorization" => authorization, "Content-Type" => "application/octet-stream"})
- expect(json_response['objects'].last['oid']).to eq(sample_oid)
- expect(json_response['objects'].last['size']).to eq(sample_size)
- expect(json_response['objects'].last).not_to have_key('actions')
+ expect(json_response["objects"].last["oid"]).to eq(sample_oid)
+ expect(json_response["objects"].last["size"]).to eq(sample_size)
+ expect(json_response["objects"].last).not_to have_key("actions")
end
end
end
- context 'when user does not have push access' do
+ context "when user does not have push access" do
let(:authorization) { authorize_user }
- it 'responds with 403' do
+ it "responds with 403" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'when build is authorized' do
+ context "when build is authorized" do
let(:authorization) { authorize_ci_project }
- context 'build has an user' do
+ context "build has an user" do
let(:user) { create(:user) }
- context 'tries to push to own project' do
+ context "tries to push to own project" do
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'tries to push to other project' do
+ context "tries to push to other project" do
let(:other_project) { create(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: other_project) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
# I'm not sure what this tests that is different from the previous test
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'does not have user' do
+ context "does not have user" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'when deploy key has project push access' do
+ context "when deploy key has project push access" do
let(:key) { create(:deploy_key) }
let(:authorization) { authorize_deploy_key }
@@ -856,54 +856,54 @@ describe 'Git LFS API and storage' do
project.deploy_keys_projects.create(deploy_key: key, can_push: true)
end
- it_behaves_like 'pushes new LFS objects'
+ it_behaves_like "pushes new LFS objects"
end
end
- context 'when user is not authenticated' do
- context 'when user has push access' do
+ context "when user is not authenticated" do
+ context "when user has push access" do
let(:update_user_permissions) do
project.add_maintainer(user)
end
- it 'responds with status 401' do
+ it "responds with status 401" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'when user does not have push access' do
- it 'responds with status 401' do
+ context "when user does not have push access" do
+ it "responds with status 401" do
expect(response).to have_gitlab_http_status(401)
end
end
end
end
- describe 'unsupported' do
+ describe "unsupported" do
let(:project) { create(:project) }
let(:authorization) { authorize_user }
let(:body) do
{
- 'operation' => 'other',
- 'objects' => [
- { 'oid' => sample_oid,
- 'size' => sample_size }
- ]
+ "operation" => "other",
+ "objects" => [
+ {"oid" => sample_oid,
+ "size" => sample_size,},
+ ],
}
end
- it 'responds with status 404' do
+ it "responds with status 404" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- describe 'when handling lfs batch request on a read-only GitLab instance' do
+ describe "when handling lfs batch request on a read-only GitLab instance" do
let(:authorization) { authorize_user }
let(:project) { create(:project) }
let(:path) { "#{project.http_url_to_repo}/info/lfs/objects/batch" }
let(:body) do
- { 'objects' => [{ 'oid' => sample_oid, 'size' => sample_size }] }
+ {"objects" => [{"oid" => sample_oid, "size" => sample_size}]}
end
before do
@@ -912,192 +912,192 @@ describe 'Git LFS API and storage' do
enable_lfs
end
- it 'responds with a 200 message on download' do
- post_lfs_json path, body.merge('operation' => 'download'), headers
+ it "responds with a 200 message on download" do
+ post_lfs_json path, body.merge("operation" => "download"), headers
expect(response).to have_gitlab_http_status(200)
end
- it 'responds with a 403 message on upload' do
- post_lfs_json path, body.merge('operation' => 'upload'), headers
+ it "responds with a 403 message on upload" do
+ post_lfs_json path, body.merge("operation" => "upload"), headers
expect(response).to have_gitlab_http_status(403)
- expect(json_response).to include('message' => 'You cannot write to this read-only GitLab instance.')
+ expect(json_response).to include("message" => "You cannot write to this read-only GitLab instance.")
end
end
- describe 'when pushing a lfs object' do
+ describe "when pushing a lfs object" do
before do
enable_lfs
end
- shared_examples 'unauthorized' do
- context 'and request is sent by gitlab-workhorse to authorize the request' do
+ shared_examples "unauthorized" do
+ context "and request is sent by gitlab-workhorse to authorize the request" do
before do
put_authorize
end
- it 'responds with status 401' do
+ it "responds with status 401" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'and request is sent by gitlab-workhorse to finalize the upload' do
+ context "and request is sent by gitlab-workhorse to finalize the upload" do
before do
put_finalize
end
- it 'responds with status 401' do
+ it "responds with status 401" do
expect(response).to have_gitlab_http_status(401)
end
end
- context 'and request is sent with a malformed headers' do
+ context "and request is sent with a malformed headers" do
before do
- put_finalize('/etc/passwd')
+ put_finalize("/etc/passwd")
end
- it 'does not recognize it as a valid lfs command' do
+ it "does not recognize it as a valid lfs command" do
expect(response).to have_gitlab_http_status(401)
end
end
end
- shared_examples 'forbidden' do
- context 'and request is sent by gitlab-workhorse to authorize the request' do
+ shared_examples "forbidden" do
+ context "and request is sent by gitlab-workhorse to authorize the request" do
before do
put_authorize
end
- it 'responds with 403' do
+ it "responds with 403" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'and request is sent by gitlab-workhorse to finalize the upload' do
+ context "and request is sent by gitlab-workhorse to finalize the upload" do
before do
put_finalize
end
- it 'responds with 403' do
+ it "responds with 403" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'and request is sent with a malformed headers' do
+ context "and request is sent with a malformed headers" do
before do
- put_finalize('/etc/passwd')
+ put_finalize("/etc/passwd")
end
- it 'does not recognize it as a valid lfs command' do
+ it "does not recognize it as a valid lfs command" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- describe 'to one project' do
+ describe "to one project" do
let(:project) { create(:project) }
- describe 'when user is authenticated' do
+ describe "when user is authenticated" do
let(:authorization) { authorize_user }
- describe 'when user has push access to the project' do
+ describe "when user has push access to the project" do
before do
project.add_developer(user)
end
- context 'and the request bypassed workhorse' do
- it 'raises an exception' do
+ context "and the request bypassed workhorse" do
+ it "raises an exception" do
expect { put_authorize(verified: false) }.to raise_error JWT::DecodeError
end
end
- context 'and request is sent by gitlab-workhorse to authorize the request' do
- shared_examples 'a valid response' do
+ context "and request is sent by gitlab-workhorse to authorize the request" do
+ shared_examples "a valid response" do
before do
put_authorize
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'uses the gitlab-workhorse content type' do
+ it "uses the gitlab-workhorse content type" do
expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end
end
- shared_examples 'a local file' do
- it_behaves_like 'a valid response' do
- it 'responds with status 200, location of lfs store and object details' do
- expect(json_response['TempPath']).to eq(LfsObjectUploader.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to be_nil
- expect(json_response['LfsOid']).to eq(sample_oid)
- expect(json_response['LfsSize']).to eq(sample_size)
+ shared_examples "a local file" do
+ it_behaves_like "a valid response" do
+ it "responds with status 200, location of lfs store and object details" do
+ expect(json_response["TempPath"]).to eq(LfsObjectUploader.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to be_nil
+ expect(json_response["LfsOid"]).to eq(sample_oid)
+ expect(json_response["LfsSize"]).to eq(sample_size)
end
end
end
- context 'when using local storage' do
- it_behaves_like 'a local file'
+ context "when using local storage" do
+ it_behaves_like "a local file"
end
- context 'when using remote storage' do
- context 'when direct upload is enabled' do
+ context "when using remote storage" do
+ context "when direct upload is enabled" do
before do
stub_lfs_object_storage(enabled: true, direct_upload: true)
end
- it_behaves_like 'a valid response' do
- it 'responds with status 200, location of lfs remote store and object details' do
- expect(json_response['TempPath']).to eq(LfsObjectUploader.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to have_key('ID')
- expect(json_response['RemoteObject']).to have_key('GetURL')
- expect(json_response['RemoteObject']).to have_key('StoreURL')
- expect(json_response['RemoteObject']).to have_key('DeleteURL')
- expect(json_response['RemoteObject']).not_to have_key('MultipartUpload')
- expect(json_response['LfsOid']).to eq(sample_oid)
- expect(json_response['LfsSize']).to eq(sample_size)
+ it_behaves_like "a valid response" do
+ it "responds with status 200, location of lfs remote store and object details" do
+ expect(json_response["TempPath"]).to eq(LfsObjectUploader.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to have_key("ID")
+ expect(json_response["RemoteObject"]).to have_key("GetURL")
+ expect(json_response["RemoteObject"]).to have_key("StoreURL")
+ expect(json_response["RemoteObject"]).to have_key("DeleteURL")
+ expect(json_response["RemoteObject"]).not_to have_key("MultipartUpload")
+ expect(json_response["LfsOid"]).to eq(sample_oid)
+ expect(json_response["LfsSize"]).to eq(sample_size)
end
end
end
- context 'when direct upload is disabled' do
+ context "when direct upload is disabled" do
before do
stub_lfs_object_storage(enabled: true, direct_upload: false)
end
- it_behaves_like 'a local file'
+ it_behaves_like "a local file"
end
end
end
- context 'and request is sent by gitlab-workhorse to finalize the upload' do
+ context "and request is sent by gitlab-workhorse to finalize the upload" do
before do
put_finalize
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'lfs object is linked to the project' do
+ it "lfs object is linked to the project" do
expect(lfs_object.projects.pluck(:id)).to include(project.id)
end
end
- context 'and request to finalize the upload is not sent by gitlab-workhorse' do
- it 'fails with a JWT decode error' do
+ context "and request to finalize the upload is not sent by gitlab-workhorse" do
+ it "fails with a JWT decode error" do
expect { put_finalize(lfs_tmp_file, verified: false) }.to raise_error(JWT::DecodeError)
end
end
- context 'and workhorse requests upload finalize for a new lfs object' do
+ context "and workhorse requests upload finalize for a new lfs object" do
before do
lfs_object.destroy
end
- context 'with object storage disabled' do
+ context "with object storage disabled" do
it "doesn't attempt to migrate file to object storage" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
@@ -1105,21 +1105,21 @@ describe 'Git LFS API and storage' do
end
end
- context 'with object storage enabled' do
- context 'and direct upload enabled' do
+ context "with object storage enabled" do
+ context "and direct upload enabled" do
let!(:fog_connection) do
stub_lfs_object_storage(direct_upload: true)
end
- ['123123', '../../123123'].each do |remote_id|
+ ["123123", "../../123123"].each do |remote_id|
context "with invalid remote_id: #{remote_id}" do
subject do
put_finalize(with_tempfile: true, args: {
- 'file.remote_id' => remote_id
+ "file.remote_id" => remote_id,
})
end
- it 'responds with status 403' do
+ it "responds with status 403" do
subject
expect(response).to have_gitlab_http_status(403)
@@ -1127,34 +1127,34 @@ describe 'Git LFS API and storage' do
end
end
- context 'with valid remote_id' do
+ context "with valid remote_id" do
before do
- fog_connection.directories.new(key: 'lfs-objects').files.create(
- key: 'tmp/uploads/12312300',
- body: 'content'
+ fog_connection.directories.new(key: "lfs-objects").files.create(
+ key: "tmp/uploads/12312300",
+ body: "content"
)
end
subject do
put_finalize(with_tempfile: true, args: {
- 'file.remote_id' => '12312300',
- 'file.name' => 'name'
+ "file.remote_id" => "12312300",
+ "file.name" => "name",
})
end
- it 'responds with status 200' do
+ it "responds with status 200" do
subject
expect(response).to have_gitlab_http_status(200)
end
- it 'schedules migration of file to object storage' do
+ it "schedules migration of file to object storage" do
subject
expect(LfsObject.last.projects).to include(project)
end
- it 'have valid file' do
+ it "have valid file" do
subject
expect(LfsObject.last.file_store).to eq(ObjectStorage::Store::REMOTE)
@@ -1163,13 +1163,13 @@ describe 'Git LFS API and storage' do
end
end
- context 'and background upload enabled' do
+ context "and background upload enabled" do
before do
stub_lfs_object_storage(background_upload: true)
end
- it 'schedules migration of file to object storage' do
- expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with('LfsObjectUploader', 'LfsObject', :file, kind_of(Numeric))
+ it "schedules migration of file to object storage" do
+ expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with("LfsObjectUploader", "LfsObject", :file, kind_of(Numeric))
put_finalize(with_tempfile: true)
end
@@ -1177,34 +1177,34 @@ describe 'Git LFS API and storage' do
end
end
- context 'invalid tempfiles' do
+ context "invalid tempfiles" do
before do
lfs_object.destroy
end
- it 'rejects slashes in the tempfile name (path traversal)' do
- put_finalize('../bar', with_tempfile: true)
+ it "rejects slashes in the tempfile name (path traversal)" do
+ put_finalize("../bar", with_tempfile: true)
expect(response).to have_gitlab_http_status(403)
end
end
end
- describe 'and user does not have push access' do
+ describe "and user does not have push access" do
before do
project.add_reporter(user)
end
- it_behaves_like 'forbidden'
+ it_behaves_like "forbidden"
end
end
- context 'when build is authorized' do
+ context "when build is authorized" do
let(:authorization) { authorize_ci_project }
- context 'build has an user' do
+ context "build has an user" do
let(:user) { create(:user) }
- context 'tries to push to own project' do
+ context "tries to push to own project" do
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
before do
@@ -1212,12 +1212,12 @@ describe 'Git LFS API and storage' do
put_authorize
end
- it 'responds with 403 (not 404 because the build user can read the project)' do
+ it "responds with 403 (not 404 because the build user can read the project)" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'tries to push to other project' do
+ context "tries to push to other project" do
let(:other_project) { create(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: other_project) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
@@ -1226,123 +1226,123 @@ describe 'Git LFS API and storage' do
put_authorize
end
- it 'responds with 404 (do not leak non-public project existence)' do
+ it "responds with 404 (do not leak non-public project existence)" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'does not have user' do
+ context "does not have user" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
before do
put_authorize
end
- it 'responds with 404 (do not leak non-public project existence)' do
+ it "responds with 404 (do not leak non-public project existence)" do
expect(response).to have_gitlab_http_status(404)
end
end
end
- context 'for unauthenticated' do
- it_behaves_like 'unauthorized'
+ context "for unauthenticated" do
+ it_behaves_like "unauthorized"
end
end
- describe 'to a forked project' do
+ describe "to a forked project" do
let(:upstream_project) { create(:project, :public) }
let(:project_owner) { create(:user) }
let(:project) { fork_project(upstream_project, project_owner) }
- describe 'when user is authenticated' do
+ describe "when user is authenticated" do
let(:authorization) { authorize_user }
- describe 'when user has push access to the project' do
+ describe "when user has push access to the project" do
before do
project.add_developer(user)
end
- context 'and request is sent by gitlab-workhorse to authorize the request' do
+ context "and request is sent by gitlab-workhorse to authorize the request" do
before do
put_authorize
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'with location of lfs store and object details' do
- expect(json_response['TempPath']).to eq(LfsObjectUploader.workhorse_local_upload_path)
- expect(json_response['LfsOid']).to eq(sample_oid)
- expect(json_response['LfsSize']).to eq(sample_size)
+ it "with location of lfs store and object details" do
+ expect(json_response["TempPath"]).to eq(LfsObjectUploader.workhorse_local_upload_path)
+ expect(json_response["LfsOid"]).to eq(sample_oid)
+ expect(json_response["LfsSize"]).to eq(sample_size)
end
end
- context 'and request is sent by gitlab-workhorse to finalize the upload' do
+ context "and request is sent by gitlab-workhorse to finalize the upload" do
before do
put_finalize
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'lfs object is linked to the source project' do
+ it "lfs object is linked to the source project" do
expect(lfs_object.projects.pluck(:id)).to include(upstream_project.id)
end
end
end
- describe 'and user does not have push access' do
- it_behaves_like 'forbidden'
+ describe "and user does not have push access" do
+ it_behaves_like "forbidden"
end
end
- context 'when build is authorized' do
+ context "when build is authorized" do
let(:authorization) { authorize_ci_project }
before do
put_authorize
end
- context 'build has an user' do
+ context "build has an user" do
let(:user) { create(:user) }
- context 'tries to push to own project' do
+ context "tries to push to own project" do
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
- context 'tries to push to other project' do
+ context "tries to push to other project" do
let(:other_project) { create(:project) }
let(:pipeline) { create(:ci_empty_pipeline, project: other_project) }
let(:build) { create(:ci_build, :running, pipeline: pipeline, user: user) }
# I'm not sure what this tests that is different from the previous test
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'does not have user' do
+ context "does not have user" do
let(:build) { create(:ci_build, :running, pipeline: pipeline) }
- it 'responds with 403 (not 404 because project is public)' do
+ it "responds with 403 (not 404 because project is public)" do
expect(response).to have_gitlab_http_status(403)
end
end
end
- context 'for unauthenticated' do
- it_behaves_like 'unauthorized'
+ context "for unauthenticated" do
+ it_behaves_like "unauthorized"
end
- describe 'and second project not related to fork or a source project' do
+ describe "and second project not related to fork or a source project" do
let(:second_project) { create(:project) }
let(:authorization) { authorize_user }
@@ -1351,22 +1351,22 @@ describe 'Git LFS API and storage' do
upstream_project.lfs_objects << lfs_object
end
- context 'when pushing the same lfs object to the second project' do
+ context "when pushing the same lfs object to the second project" do
before do
finalize_headers = headers
- .merge('X-Gitlab-Lfs-Tmp' => lfs_tmp_file)
+ .merge("X-Gitlab-Lfs-Tmp" => lfs_tmp_file)
.merge(workhorse_internal_api_request_header)
put "#{second_project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}",
- params: {},
- headers: finalize_headers
+ params: {},
+ headers: finalize_headers
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'links the lfs object to the project' do
+ it "links the lfs object to the project" do
expect(lfs_object.projects.pluck(:id)).to include(second_project.id, upstream_project.id)
end
end
@@ -1382,7 +1382,7 @@ describe 'Git LFS API and storage' do
def put_finalize(lfs_tmp = lfs_tmp_file, with_tempfile: false, verified: true, args: {})
upload_path = LfsObjectUploader.workhorse_local_upload_path
- file_path = upload_path + '/' + lfs_tmp if lfs_tmp
+ file_path = upload_path + "/" + lfs_tmp if lfs_tmp
if with_tempfile
FileUtils.mkdir_p(upload_path)
@@ -1390,8 +1390,8 @@ describe 'Git LFS API and storage' do
end
extra_args = {
- 'file.path' => file_path,
- 'file.name' => File.basename(file_path)
+ "file.path" => file_path,
+ "file.name" => File.basename(file_path),
}
put_finalize_with_args(args.merge(extra_args).compact, verified: verified)
@@ -1414,7 +1414,7 @@ describe 'Git LFS API and storage' do
end
def authorize_ci_project
- ActionController::HttpAuthentication::Basic.encode_credentials('gitlab-ci-token', build.token)
+ ActionController::HttpAuthentication::Basic.encode_credentials("gitlab-ci-token", build.token)
end
def authorize_user
@@ -1435,7 +1435,7 @@ describe 'Git LFS API and storage' do
def post_lfs_json(url, body = nil, headers = nil)
params = body.try(:to_json)
- headers = (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE)
+ headers = (headers || {}).merge("Content-Type" => LfsRequest::CONTENT_TYPE)
post(url, params: params, headers: headers)
end
diff --git a/spec/requests/lfs_locks_api_spec.rb b/spec/requests/lfs_locks_api_spec.rb
index 5b7b3d2fdd6..6cdf3456b94 100644
--- a/spec/requests/lfs_locks_api_spec.rb
+++ b/spec/requests/lfs_locks_api_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Git LFS File Locking API' do
+describe "Git LFS File Locking API" do
include WorkhorseHelpers
let(:project) { create(:project) }
let(:maintainer) { create(:user) }
let(:developer) { create(:user) }
let(:guest) { create(:user) }
- let(:path) { 'README.md' }
+ let(:path) { "README.md" }
let(:headers) do
{
- 'Authorization' => authorization
+ "Authorization" => authorization,
}.compact
end
- shared_examples 'unauthorized request' do
- context 'when user is not authorized' do
+ shared_examples "unauthorized request" do
+ context "when user is not authorized" do
let(:authorization) { authorize_user(guest) }
- it 'returns a forbidden 403 response' do
+ it "returns a forbidden 403 response" do
post_lfs_json url, body, headers
expect(response).to have_gitlab_http_status(403)
@@ -34,111 +34,111 @@ describe 'Git LFS File Locking API' do
project.add_guest(guest)
end
- describe 'Create File Lock endpoint' do
+ describe "Create File Lock endpoint" do
let(:url) { "#{project.http_url_to_repo}/info/lfs/locks" }
let(:authorization) { authorize_user(developer) }
- let(:body) { { path: path } }
+ let(:body) { {path: path} }
- include_examples 'unauthorized request'
+ include_examples "unauthorized request"
- context 'with an existent lock' do
+ context "with an existent lock" do
before do
- lock_file('README.md', developer)
+ lock_file("README.md", developer)
end
- it 'return an error message' do
+ it "return an error message" do
post_lfs_json url, body, headers
expect(response).to have_gitlab_http_status(409)
- expect(json_response.keys).to match_array(%w(lock message documentation_url))
- expect(json_response['message']).to match(/already locked/)
+ expect(json_response.keys).to match_array(%w[lock message documentation_url])
+ expect(json_response["message"]).to match(/already locked/)
end
- it 'returns the existen lock' do
+ it "returns the existen lock" do
post_lfs_json url, body, headers
- expect(json_response['lock']['path']).to eq('README.md')
+ expect(json_response["lock"]["path"]).to eq("README.md")
end
end
- context 'without an existent lock' do
- it 'creates the lock' do
+ context "without an existent lock" do
+ it "creates the lock" do
post_lfs_json url, body, headers
expect(response).to have_gitlab_http_status(201)
- expect(json_response['lock'].keys).to match_array(%w(id path locked_at owner))
+ expect(json_response["lock"].keys).to match_array(%w[id path locked_at owner])
end
end
end
- describe 'Listing File Locks endpoint' do
+ describe "Listing File Locks endpoint" do
let(:url) { "#{project.http_url_to_repo}/info/lfs/locks" }
let(:authorization) { authorize_user(developer) }
- include_examples 'unauthorized request'
+ include_examples "unauthorized request"
- it 'returns the list of locked files' do
- lock_file('README.md', developer)
- lock_file('README', developer)
+ it "returns the list of locked files" do
+ lock_file("README.md", developer)
+ lock_file("README", developer)
do_get url, nil, headers
expect(response).to have_gitlab_http_status(200)
- expect(json_response['locks'].size).to eq(2)
- expect(json_response['locks'].first.keys).to match_array(%w(id path locked_at owner))
+ expect(json_response["locks"].size).to eq(2)
+ expect(json_response["locks"].first.keys).to match_array(%w[id path locked_at owner])
end
end
- describe 'List File Locks for verification endpoint' do
+ describe "List File Locks for verification endpoint" do
let(:url) { "#{project.http_url_to_repo}/info/lfs/locks/verify" }
let(:authorization) { authorize_user(developer) }
- include_examples 'unauthorized request'
+ include_examples "unauthorized request"
- it 'returns the list of locked files grouped by owner' do
- lock_file('README.md', maintainer)
- lock_file('README', developer)
+ it "returns the list of locked files grouped by owner" do
+ lock_file("README.md", maintainer)
+ lock_file("README", developer)
post_lfs_json url, nil, headers
expect(response).to have_gitlab_http_status(200)
- expect(json_response['ours'].size).to eq(1)
- expect(json_response['ours'].first['path']).to eq('README')
- expect(json_response['theirs'].size).to eq(1)
- expect(json_response['theirs'].first['path']).to eq('README.md')
+ expect(json_response["ours"].size).to eq(1)
+ expect(json_response["ours"].first["path"]).to eq("README")
+ expect(json_response["theirs"].size).to eq(1)
+ expect(json_response["theirs"].first["path"]).to eq("README.md")
end
end
- describe 'Delete File Lock endpoint' do
- let!(:lock) { lock_file('README.md', developer) }
+ describe "Delete File Lock endpoint" do
+ let!(:lock) { lock_file("README.md", developer) }
let(:url) { "#{project.http_url_to_repo}/info/lfs/locks/#{lock[:id]}/unlock" }
let(:authorization) { authorize_user(developer) }
- include_examples 'unauthorized request'
+ include_examples "unauthorized request"
- context 'with an existent lock' do
- it 'deletes the lock' do
+ context "with an existent lock" do
+ it "deletes the lock" do
post_lfs_json url, nil, headers
expect(response).to have_gitlab_http_status(200)
end
- it 'returns the deleted lock' do
+ it "returns the deleted lock" do
post_lfs_json url, nil, headers
- expect(json_response['lock'].keys).to match_array(%w(id path locked_at owner))
+ expect(json_response["lock"].keys).to match_array(%w[id path locked_at owner])
end
- context 'when a maintainer uses force' do
+ context "when a maintainer uses force" do
let(:authorization) { authorize_user(maintainer) }
- it 'deletes the lock' do
+ it "deletes the lock" do
project.add_maintainer(maintainer)
- post_lfs_json url, { force: true }, headers
+ post_lfs_json url, {force: true}, headers
expect(response).to have_gitlab_http_status(200)
end
@@ -147,7 +147,7 @@ describe 'Git LFS File Locking API' do
end
def lock_file(path, author)
- result = Lfs::LockFileService.new(project, author, { path: path }).execute
+ result = Lfs::LockFileService.new(project, author, {path: path}).execute
result[:lock]
end
@@ -157,11 +157,11 @@ describe 'Git LFS File Locking API' do
end
def post_lfs_json(url, body = nil, headers = nil)
- post(url, params: body.try(:to_json), headers: (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE))
+ post(url, params: body.try(:to_json), headers: (headers || {}).merge("Content-Type" => LfsRequest::CONTENT_TYPE))
end
def do_get(url, params = nil, headers = nil)
- get(url, params: (params || {}), headers: (headers || {}).merge('Content-Type' => LfsRequest::CONTENT_TYPE))
+ get(url, params: (params || {}), headers: (headers || {}).merge("Content-Type" => LfsRequest::CONTENT_TYPE))
end
def json_response
diff --git a/spec/requests/oauth_tokens_spec.rb b/spec/requests/oauth_tokens_spec.rb
index 3873e754060..9174a0c9789 100644
--- a/spec/requests/oauth_tokens_spec.rb
+++ b/spec/requests/oauth_tokens_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'OAuth Tokens requests' do
+describe "OAuth Tokens requests" do
let(:user) { create :user }
- let(:application) { create :oauth_application, scopes: 'api' }
+ let(:application) { create :oauth_application, scopes: "api" }
def request_access_token(user)
- post '/oauth/token',
+ post "/oauth/token",
params: {
- grant_type: 'authorization_code',
+ grant_type: "authorization_code",
code: generate_access_grant(user).token,
redirect_uri: application.redirect_uri,
client_id: application.uid,
- client_secret: application.secret
+ client_secret: application.secret,
}
end
@@ -19,39 +19,39 @@ describe 'OAuth Tokens requests' do
create :oauth_access_grant, application: application, resource_owner_id: user.id
end
- context 'when there is already a token for the application' do
+ context "when there is already a token for the application" do
let!(:existing_token) { create :oauth_access_token, application: application, resource_owner_id: user.id }
- context 'and the request is done by the resource owner' do
- it 'reuses and returns the stored token' do
- expect do
+ context "and the request is done by the resource owner" do
+ it "reuses and returns the stored token" do
+ expect {
request_access_token(user)
- end.not_to change { Doorkeeper::AccessToken.count }
+ }.not_to change { Doorkeeper::AccessToken.count }
- expect(json_response['access_token']).to eq existing_token.token
+ expect(json_response["access_token"]).to eq existing_token.token
end
end
- context 'and the request is done by a different user' do
+ context "and the request is done by a different user" do
let(:other_user) { create :user }
- it 'generates and returns a different token for a different owner' do
- expect do
+ it "generates and returns a different token for a different owner" do
+ expect {
request_access_token(other_user)
- end.to change { Doorkeeper::AccessToken.count }.by(1)
+ }.to change { Doorkeeper::AccessToken.count }.by(1)
- expect(json_response['access_token']).not_to be_nil
+ expect(json_response["access_token"]).not_to be_nil
end
end
end
- context 'when there is no token stored for the application' do
- it 'generates and returns a new token' do
- expect do
+ context "when there is no token stored for the application" do
+ it "generates and returns a new token" do
+ expect {
request_access_token(user)
- end.to change { Doorkeeper::AccessToken.count }.by(1)
+ }.to change { Doorkeeper::AccessToken.count }.by(1)
- expect(json_response['access_token']).not_to be_nil
+ expect(json_response["access_token"]).not_to be_nil
end
end
end
diff --git a/spec/requests/openid_connect_spec.rb b/spec/requests/openid_connect_spec.rb
index 2a455523e2c..c32cf0de55a 100644
--- a/spec/requests/openid_connect_spec.rb
+++ b/spec/requests/openid_connect_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'OpenID Connect requests' do
+describe "OpenID Connect requests" do
let(:user) do
create(
:user,
- name: 'Alice',
- username: 'alice',
- email: 'private@example.com',
+ name: "Alice",
+ username: "alice",
+ email: "private@example.com",
emails: [public_email],
public_email: public_email.email,
- website_url: 'https://example.com',
- avatar: fixture_file_upload('spec/fixtures/dk.png')
+ website_url: "https://example.com",
+ avatar: fixture_file_upload("spec/fixtures/dk.png")
)
end
- let(:public_email) { build :email, email: 'public@example.com' }
+ let(:public_email) { build :email, email: "public@example.com" }
let(:access_grant) { create :oauth_access_grant, application: application, resource_owner_id: user.id }
let(:access_token) { create :oauth_access_token, application: application, resource_owner_id: user.id }
@@ -25,52 +25,52 @@ describe 'OpenID Connect requests' do
let(:id_token_claims) do
{
- 'sub' => user.id.to_s,
- 'sub_legacy' => hashed_subject
+ "sub" => user.id.to_s,
+ "sub_legacy" => hashed_subject,
}
end
let(:user_info_claims) do
{
- 'name' => 'Alice',
- 'nickname' => 'alice',
- 'email' => 'public@example.com',
- 'email_verified' => false,
- 'website' => 'https://example.com',
- 'profile' => 'http://localhost/alice',
- 'picture' => "http://localhost/uploads/-/system/user/avatar/#{user.id}/dk.png",
- 'groups' => kind_of(Array)
+ "name" => "Alice",
+ "nickname" => "alice",
+ "email" => "public@example.com",
+ "email_verified" => false,
+ "website" => "https://example.com",
+ "profile" => "http://localhost/alice",
+ "picture" => "http://localhost/uploads/-/system/user/avatar/#{user.id}/dk.png",
+ "groups" => kind_of(Array),
}
end
def request_access_token!
login_as user
- post '/oauth/token',
+ post "/oauth/token",
params: {
- grant_type: 'authorization_code',
+ grant_type: "authorization_code",
code: access_grant.token,
redirect_uri: application.redirect_uri,
client_id: application.uid,
- client_secret: application.secret
+ client_secret: application.secret,
}
end
def request_user_info!
- get '/oauth/userinfo', params: {}, headers: { 'Authorization' => "Bearer #{access_token.token}" }
+ get "/oauth/userinfo", params: {}, headers: {"Authorization" => "Bearer #{access_token.token}"}
end
- context 'Application without OpenID scope' do
- let(:application) { create :oauth_application, scopes: 'api' }
+ context "Application without OpenID scope" do
+ let(:application) { create :oauth_application, scopes: "api" }
- it 'token response does not include an ID token' do
+ it "token response does not include an ID token" do
request_access_token!
- expect(json_response).to include 'access_token'
- expect(json_response).not_to include 'id_token'
+ expect(json_response).to include "access_token"
+ expect(json_response).not_to include "id_token"
end
- it 'userinfo response is unauthorized' do
+ it "userinfo response is unauthorized" do
request_user_info!
expect(response).to have_gitlab_http_status 403
@@ -78,16 +78,16 @@ describe 'OpenID Connect requests' do
end
end
- context 'Application with OpenID scope' do
- let(:application) { create :oauth_application, scopes: 'openid' }
+ context "Application with OpenID scope" do
+ let(:application) { create :oauth_application, scopes: "openid" }
- it 'token response includes an ID token' do
+ it "token response includes an ID token" do
request_access_token!
- expect(json_response).to include 'id_token'
+ expect(json_response).to include "id_token"
end
- context 'UserInfo payload' do
+ context "UserInfo payload" do
let!(:group1) { create :group }
let!(:group2) { create :group }
let!(:group3) { create :group, parent: group2 }
@@ -100,50 +100,50 @@ describe 'OpenID Connect requests' do
request_user_info!
end
- it 'includes all user information and group memberships' do
+ it "includes all user information and group memberships" do
expect(json_response).to match(id_token_claims.merge(user_info_claims))
expected_groups = [group1.full_path, group3.full_path]
expected_groups << group4.full_path if Group.supports_nested_objects?
- expect(json_response['groups']).to match_array(expected_groups)
+ expect(json_response["groups"]).to match_array(expected_groups)
end
- it 'does not include any unknown claims' do
+ it "does not include any unknown claims" do
expect(json_response.keys).to eq %w[sub sub_legacy] + user_info_claims.keys
end
- it 'includes email and email_verified claims' do
- expect(json_response.keys).to include('email', 'email_verified')
+ it "includes email and email_verified claims" do
+ expect(json_response.keys).to include("email", "email_verified")
end
- it 'has public email in email claim' do
- expect(json_response['email']).to eq(user.public_email)
+ it "has public email in email claim" do
+ expect(json_response["email"]).to eq(user.public_email)
end
- it 'has false in email_verified claim' do
- expect(json_response['email_verified']).to eq(false)
+ it "has false in email_verified claim" do
+ expect(json_response["email_verified"]).to eq(false)
end
end
- context 'ID token payload' do
+ context "ID token payload" do
before do
request_access_token!
- @payload = JSON::JWT.decode(json_response['id_token'], :skip_verification)
+ @payload = JSON::JWT.decode(json_response["id_token"], :skip_verification)
end
- it 'includes the subject claims' do
+ it "includes the subject claims" do
expect(@payload).to match(a_hash_including(id_token_claims))
end
- it 'includes the GitLab root URL' do
- expect(@payload['iss']).to eq Gitlab.config.gitlab.url
+ it "includes the GitLab root URL" do
+ expect(@payload["iss"]).to eq Gitlab.config.gitlab.url
end
- it 'includes the time of the last authentication', :clean_gitlab_redis_shared_state do
- expect(@payload['auth_time']).to eq user.current_sign_in_at.to_i
+ it "includes the time of the last authentication", :clean_gitlab_redis_shared_state do
+ expect(@payload["auth_time"]).to eq user.current_sign_in_at.to_i
end
- it 'does not include any unknown properties' do
+ it "does not include any unknown properties" do
expect(@payload.keys).to eq %w[iss sub aud exp iat auth_time sub_legacy]
end
end
@@ -157,64 +157,64 @@ describe 'OpenID Connect requests' do
# When the patch gets merged and we update Warden, these specs will need to
# updated to check the response instead of a raised exception.
# https://gitlab.com/gitlab-org/gitlab-ce/issues/40218
- context 'when user is blocked' do
- it 'returns authentication error' do
+ context "when user is blocked" do
+ it "returns authentication error" do
access_grant
user.block!
- expect do
+ expect {
request_access_token!
- end.to raise_error UncaughtThrowError
+ }.to raise_error UncaughtThrowError
end
end
- context 'when user is ldap_blocked' do
- it 'returns authentication error' do
+ context "when user is ldap_blocked" do
+ it "returns authentication error" do
access_grant
user.ldap_block!
- expect do
+ expect {
request_access_token!
- end.to raise_error UncaughtThrowError
+ }.to raise_error UncaughtThrowError
end
end
end
- context 'OpenID configuration information' do
- it 'correctly returns the configuration' do
- get '/.well-known/openid-configuration'
+ context "OpenID configuration information" do
+ it "correctly returns the configuration" do
+ get "/.well-known/openid-configuration"
expect(response).to have_gitlab_http_status(200)
- expect(json_response['issuer']).to eq('http://localhost')
- expect(json_response['jwks_uri']).to eq('http://www.example.com/oauth/discovery/keys')
- expect(json_response['scopes_supported']).to eq(%w[api read_user sudo read_repository openid profile email])
+ expect(json_response["issuer"]).to eq("http://localhost")
+ expect(json_response["jwks_uri"]).to eq("http://www.example.com/oauth/discovery/keys")
+ expect(json_response["scopes_supported"]).to eq(%w[api read_user sudo read_repository openid profile email])
end
end
- context 'Application with OpenID and email scopes' do
- let(:application) { create :oauth_application, scopes: 'openid email' }
+ context "Application with OpenID and email scopes" do
+ let(:application) { create :oauth_application, scopes: "openid email" }
- it 'token response includes an ID token' do
+ it "token response includes an ID token" do
request_access_token!
- expect(json_response).to include 'id_token'
+ expect(json_response).to include "id_token"
end
- context 'UserInfo payload' do
+ context "UserInfo payload" do
before do
request_user_info!
end
- it 'includes the email and email_verified claims' do
- expect(json_response.keys).to include('email', 'email_verified')
+ it "includes the email and email_verified claims" do
+ expect(json_response.keys).to include("email", "email_verified")
end
- it 'has private email in email claim' do
- expect(json_response['email']).to eq(user.email)
+ it "has private email in email claim" do
+ expect(json_response["email"]).to eq(user.email)
end
- it 'has true in email_verified claim' do
- expect(json_response['email_verified']).to eq(true)
+ it "has true in email_verified claim" do
+ expect(json_response["email_verified"]).to eq(true)
end
end
end
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb
index 49412b628b3..d5061a7064b 100644
--- a/spec/requests/projects/cycle_analytics_events_spec.rb
+++ b/spec/requests/projects/cycle_analytics_events_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'cycle analytics events' do
+describe "cycle analytics events" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, public_builds: false) }
let(:issue) { create(:issue, project: project, created_at: 2.days.ago) }
- describe 'GET /:namespace/:project/cycle_analytics/events/issues' do
+ describe "GET /:namespace/:project/cycle_analytics/events/issues" do
before do
project.add_developer(user)
@@ -20,95 +20,95 @@ describe 'cycle analytics events' do
login_as(user)
end
- it 'lists the issue events' do
+ it "lists the issue events" do
get project_cycle_analytics_issue_path(project, format: :json)
first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['iid']).to eq(first_issue_iid)
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["iid"]).to eq(first_issue_iid)
end
- it 'lists the plan events' do
+ it "lists the plan events" do
get project_cycle_analytics_plan_path(project, format: :json)
first_mr_short_sha = project.merge_requests.sort_by_attribute(:created_asc).first.commits.first.short_id
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['short_sha']).to eq(first_mr_short_sha)
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["short_sha"]).to eq(first_mr_short_sha)
end
- it 'lists the code events' do
+ it "lists the code events" do
get project_cycle_analytics_code_path(project, format: :json)
- expect(json_response['events']).not_to be_empty
+ expect(json_response["events"]).not_to be_empty
first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
- expect(json_response['events'].first['iid']).to eq(first_mr_iid)
+ expect(json_response["events"].first["iid"]).to eq(first_mr_iid)
end
- it 'lists the test events' do
+ it "lists the test events" do
get project_cycle_analytics_test_path(project, format: :json)
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['date']).not_to be_empty
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["date"]).not_to be_empty
end
- it 'lists the review events' do
+ it "lists the review events" do
get project_cycle_analytics_review_path(project, format: :json)
first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['iid']).to eq(first_mr_iid)
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["iid"]).to eq(first_mr_iid)
end
- it 'lists the staging events' do
+ it "lists the staging events" do
get project_cycle_analytics_staging_path(project, format: :json)
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['date']).not_to be_empty
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["date"]).not_to be_empty
end
- it 'lists the production events' do
+ it "lists the production events" do
get project_cycle_analytics_production_path(project, format: :json)
first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['iid']).to eq(first_issue_iid)
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["iid"]).to eq(first_issue_iid)
end
- context 'specific branch' do
- it 'lists the test events' do
+ context "specific branch" do
+ it "lists the test events" do
branch = project.merge_requests.first.source_branch
get project_cycle_analytics_test_path(project, format: :json, branch: branch)
- expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['date']).not_to be_empty
+ expect(json_response["events"]).not_to be_empty
+ expect(json_response["events"].first["date"]).not_to be_empty
end
end
- context 'with private project and builds' do
+ context "with private project and builds" do
before do
project.members.last.update(access_level: Gitlab::Access::GUEST)
end
- it 'does not list the test events' do
+ it "does not list the test events" do
get project_cycle_analytics_test_path(project, format: :json)
expect(response).to have_gitlab_http_status(:not_found)
end
- it 'does not list the staging events' do
+ it "does not list the staging events" do
get project_cycle_analytics_staging_path(project, format: :json)
expect(response).to have_gitlab_http_status(:not_found)
end
- it 'lists the issue events' do
+ it "lists the issue events" do
get project_cycle_analytics_issue_path(project, format: :json)
expect(response).to have_gitlab_http_status(:ok)
@@ -121,7 +121,7 @@ describe 'cycle analytics events' do
issue.update(milestone: milestone)
mr = create_merge_request_closing_issue(user, project, issue, commit_message: "References #{issue.to_reference}")
- pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr)
+ pipeline = create(:ci_empty_pipeline, status: "created", project: project, ref: mr.source_branch, sha: mr.source_branch_sha, head_pipeline_of: mr)
pipeline.run
create(:ci_build, pipeline: pipeline, status: :success, author: user)
diff --git a/spec/requests/rack_attack_global_spec.rb b/spec/requests/rack_attack_global_spec.rb
index 49021f5d1b7..afb64ae6626 100644
--- a/spec/requests/rack_attack_global_spec.rb
+++ b/spec/requests/rack_attack_global_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Rack Attack global throttles' do
+describe "Rack Attack global throttles" do
let(:settings) { Gitlab::CurrentSettings.current_application_settings }
# Start with really high limits and override them with low limits to ensure
@@ -12,7 +12,7 @@ describe 'Rack Attack global throttles' do
throttle_authenticated_api_requests_per_period: 100,
throttle_authenticated_api_period_in_seconds: 1,
throttle_authenticated_web_requests_per_period: 100,
- throttle_authenticated_web_period_in_seconds: 1
+ throttle_authenticated_web_period_in_seconds: 1,
}
end
@@ -20,10 +20,10 @@ describe 'Rack Attack global throttles' do
let(:period_in_seconds) { 10000 }
let(:period) { period_in_seconds.seconds }
- let(:url_that_does_not_require_authentication) { '/users/sign_in' }
- let(:url_that_requires_authentication) { '/dashboard/snippets' }
- let(:url_api_internal) { '/api/v4/internal/check' }
- let(:api_partial_url) { '/todos' }
+ let(:url_that_does_not_require_authentication) { "/users/sign_in" }
+ let(:url_that_requires_authentication) { "/dashboard/snippets" }
+ let(:url_api_internal) { "/api/v4/internal/check" }
+ let(:api_partial_url) { "/todos" }
around do |example|
# Instead of test environment's :null_store so the throttles can increment
@@ -39,20 +39,20 @@ describe 'Rack Attack global throttles' do
# * throttle_setting_prefix (e.g. "throttle_authenticated_api" or "throttle_authenticated_web")
# * get_args
# * other_user_get_args
- shared_examples_for 'rate-limited token-authenticated requests' do
+ shared_examples_for "rate-limited token-authenticated requests" do
before do
# Set low limits
settings_to_set[:"#{throttle_setting_prefix}_requests_per_period"] = requests_per_period
settings_to_set[:"#{throttle_setting_prefix}_period_in_seconds"] = period_in_seconds
end
- context 'when the throttle is enabled' do
+ context "when the throttle is enabled" do
before do
settings_to_set[:"#{throttle_setting_prefix}_enabled"] = true
stub_application_setting(settings_to_set)
end
- it 'rejects requests over the rate limit' do
+ it "rejects requests over the rate limit" do
# At first, allow requests under the rate limit.
requests_per_period.times do
get(*get_args)
@@ -63,7 +63,7 @@ describe 'Rack Attack global throttles' do
expect_rejection { get(*get_args) }
end
- it 'allows requests after throttling and then waiting for the next period' do
+ it "allows requests after throttling and then waiting for the next period" do
requests_per_period.times do
get(*get_args)
expect(response).to have_http_status 200
@@ -81,7 +81,7 @@ describe 'Rack Attack global throttles' do
end
end
- it 'counts requests from different users separately, even from the same IP' do
+ it "counts requests from different users separately, even from the same IP" do
requests_per_period.times do
get(*get_args)
expect(response).to have_http_status 200
@@ -92,25 +92,25 @@ describe 'Rack Attack global throttles' do
expect(response).to have_http_status 200
end
- it 'counts all requests from the same user, even via different IPs' do
+ it "counts all requests from the same user, even via different IPs" do
requests_per_period.times do
get(*get_args)
expect(response).to have_http_status 200
end
- expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
+ expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return("1.2.3.4")
expect_rejection { get(*get_args) }
end
end
- context 'when the throttle is disabled' do
+ context "when the throttle is disabled" do
before do
settings_to_set[:"#{throttle_setting_prefix}_enabled"] = false
stub_application_setting(settings_to_set)
end
- it 'allows requests over the rate limit' do
+ it "allows requests over the rate limit" do
(1 + requests_per_period).times do
get(*get_args)
expect(response).to have_http_status 200
@@ -119,20 +119,20 @@ describe 'Rack Attack global throttles' do
end
end
- describe 'unauthenticated requests' do
+ describe "unauthenticated requests" do
before do
# Set low limits
settings_to_set[:throttle_unauthenticated_requests_per_period] = requests_per_period
settings_to_set[:throttle_unauthenticated_period_in_seconds] = period_in_seconds
end
- context 'when the throttle is enabled' do
+ context "when the throttle is enabled" do
before do
settings_to_set[:throttle_unauthenticated_enabled] = true
stub_application_setting(settings_to_set)
end
- it 'rejects requests over the rate limit' do
+ it "rejects requests over the rate limit" do
# At first, allow requests under the rate limit.
requests_per_period.times do
get url_that_does_not_require_authentication
@@ -143,7 +143,7 @@ describe 'Rack Attack global throttles' do
expect_rejection { get url_that_does_not_require_authentication }
end
- it 'allows requests after throttling and then waiting for the next period' do
+ it "allows requests after throttling and then waiting for the next period" do
requests_per_period.times do
get url_that_does_not_require_authentication
expect(response).to have_http_status 200
@@ -161,36 +161,36 @@ describe 'Rack Attack global throttles' do
end
end
- it 'counts requests from different IPs separately' do
+ it "counts requests from different IPs separately" do
requests_per_period.times do
get url_that_does_not_require_authentication
expect(response).to have_http_status 200
end
- expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
+ expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return("1.2.3.4")
# would be over limit for the same IP
get url_that_does_not_require_authentication
expect(response).to have_http_status 200
end
- context 'when the request is to the api internal endpoints' do
- it 'allows requests over the rate limit' do
+ context "when the request is to the api internal endpoints" do
+ it "allows requests over the rate limit" do
(1 + requests_per_period).times do
- get url_api_internal, params: { secret_token: Gitlab::Shell.secret_token }
+ get url_api_internal, params: {secret_token: Gitlab::Shell.secret_token}
expect(response).to have_http_status 200
end
end
end
end
- context 'when the throttle is disabled' do
+ context "when the throttle is disabled" do
before do
settings_to_set[:throttle_unauthenticated_enabled] = false
stub_application_setting(settings_to_set)
end
- it 'allows requests over the rate limit' do
+ it "allows requests over the rate limit" do
(1 + requests_per_period).times do
get url_that_does_not_require_authentication
expect(response).to have_http_status 200
@@ -199,66 +199,66 @@ describe 'Rack Attack global throttles' do
end
end
- describe 'API requests authenticated with personal access token', :api do
+ describe "API requests authenticated with personal access token", :api do
let(:user) { create(:user) }
let(:token) { create(:personal_access_token, user: user) }
let(:other_user) { create(:user) }
let(:other_user_token) { create(:personal_access_token, user: other_user) }
- let(:throttle_setting_prefix) { 'throttle_authenticated_api' }
+ let(:throttle_setting_prefix) { "throttle_authenticated_api" }
- context 'with the token in the query string' do
+ context "with the token in the query string" do
let(:get_args) { [api(api_partial_url, personal_access_token: token)] }
let(:other_user_get_args) { [api(api_partial_url, personal_access_token: other_user_token)] }
- it_behaves_like 'rate-limited token-authenticated requests'
+ it_behaves_like "rate-limited token-authenticated requests"
end
- context 'with the token in the headers' do
+ context "with the token in the headers" do
let(:get_args) { api_get_args_with_token_headers(api_partial_url, personal_access_token_headers(token)) }
let(:other_user_get_args) { api_get_args_with_token_headers(api_partial_url, personal_access_token_headers(other_user_token)) }
- it_behaves_like 'rate-limited token-authenticated requests'
+ it_behaves_like "rate-limited token-authenticated requests"
end
end
- describe 'API requests authenticated with OAuth token', :api do
+ describe "API requests authenticated with OAuth token", :api do
let(:user) { create(:user) }
let(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
let(:token) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: user.id, scopes: "api") }
let(:other_user) { create(:user) }
let(:other_user_application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: other_user) }
let(:other_user_token) { Doorkeeper::AccessToken.create!(application_id: application.id, resource_owner_id: other_user.id, scopes: "api") }
- let(:throttle_setting_prefix) { 'throttle_authenticated_api' }
+ let(:throttle_setting_prefix) { "throttle_authenticated_api" }
- context 'with the token in the query string' do
+ context "with the token in the query string" do
let(:get_args) { [api(api_partial_url, oauth_access_token: token)] }
let(:other_user_get_args) { [api(api_partial_url, oauth_access_token: other_user_token)] }
- it_behaves_like 'rate-limited token-authenticated requests'
+ it_behaves_like "rate-limited token-authenticated requests"
end
- context 'with the token in the headers' do
+ context "with the token in the headers" do
let(:get_args) { api_get_args_with_token_headers(api_partial_url, oauth_token_headers(token)) }
let(:other_user_get_args) { api_get_args_with_token_headers(api_partial_url, oauth_token_headers(other_user_token)) }
- it_behaves_like 'rate-limited token-authenticated requests'
+ it_behaves_like "rate-limited token-authenticated requests"
end
end
describe '"web" (non-API) requests authenticated with RSS token' do
let(:user) { create(:user) }
let(:other_user) { create(:user) }
- let(:throttle_setting_prefix) { 'throttle_authenticated_web' }
+ let(:throttle_setting_prefix) { "throttle_authenticated_web" }
- context 'with the token in the query string' do
+ context "with the token in the query string" do
let(:get_args) { [rss_url(user), nil] }
let(:other_user_get_args) { [rss_url(other_user), nil] }
- it_behaves_like 'rate-limited token-authenticated requests'
+ it_behaves_like "rate-limited token-authenticated requests"
end
end
- describe 'web requests authenticated with regular login' do
+ describe "web requests authenticated with regular login" do
let(:user) { create(:user) }
before do
@@ -269,13 +269,13 @@ describe 'Rack Attack global throttles' do
settings_to_set[:throttle_authenticated_web_period_in_seconds] = period_in_seconds
end
- context 'when the throttle is enabled' do
+ context "when the throttle is enabled" do
before do
settings_to_set[:throttle_authenticated_web_enabled] = true
stub_application_setting(settings_to_set)
end
- it 'rejects requests over the rate limit' do
+ it "rejects requests over the rate limit" do
# At first, allow requests under the rate limit.
requests_per_period.times do
get url_that_requires_authentication
@@ -286,7 +286,7 @@ describe 'Rack Attack global throttles' do
expect_rejection { get url_that_requires_authentication }
end
- it 'allows requests after throttling and then waiting for the next period' do
+ it "allows requests after throttling and then waiting for the next period" do
requests_per_period.times do
get url_that_requires_authentication
expect(response).to have_http_status 200
@@ -304,7 +304,7 @@ describe 'Rack Attack global throttles' do
end
end
- it 'counts requests from different users separately, even from the same IP' do
+ it "counts requests from different users separately, even from the same IP" do
requests_per_period.times do
get url_that_requires_authentication
expect(response).to have_http_status 200
@@ -317,25 +317,25 @@ describe 'Rack Attack global throttles' do
expect(response).to have_http_status 200
end
- it 'counts all requests from the same user, even via different IPs' do
+ it "counts all requests from the same user, even via different IPs" do
requests_per_period.times do
get url_that_requires_authentication
expect(response).to have_http_status 200
end
- expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return('1.2.3.4')
+ expect_any_instance_of(Rack::Attack::Request).to receive(:ip).and_return("1.2.3.4")
expect_rejection { get url_that_requires_authentication }
end
end
- context 'when the throttle is disabled' do
+ context "when the throttle is disabled" do
before do
settings_to_set[:throttle_authenticated_web_enabled] = false
stub_application_setting(settings_to_set)
end
- it 'allows requests over the rate limit' do
+ it "allows requests over the rate limit" do
(1 + requests_per_period).times do
get url_that_requires_authentication
expect(response).to have_http_status 200
@@ -353,15 +353,15 @@ describe 'Rack Attack global throttles' do
end
def private_token_headers(user)
- { 'HTTP_PRIVATE_TOKEN' => user.private_token }
+ {"HTTP_PRIVATE_TOKEN" => user.private_token}
end
def personal_access_token_headers(personal_access_token)
- { 'HTTP_PRIVATE_TOKEN' => personal_access_token.token }
+ {"HTTP_PRIVATE_TOKEN" => personal_access_token.token}
end
def oauth_token_headers(oauth_access_token)
- { 'AUTHORIZATION' => "Bearer #{oauth_access_token.token}" }
+ {"AUTHORIZATION" => "Bearer #{oauth_access_token.token}"}
end
def expect_rejection(&block)
diff --git a/spec/requests/request_profiler_spec.rb b/spec/requests/request_profiler_spec.rb
index 75b22b1879b..cf23033b1d3 100644
--- a/spec/requests/request_profiler_spec.rb
+++ b/spec/requests/request_profiler_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Request Profiler' do
+describe "Request Profiler" do
let(:user) { create(:user) }
- shared_examples 'profiling a request' do
+ shared_examples "profiling a request" do
before do
allow(Rails).to receive(:cache).and_return(ActiveSupport::Cache::MemoryStore.new)
allow(RubyProf::Profile).to receive(:profile) do |&blk|
@@ -12,16 +12,16 @@ describe 'Request Profiler' do
end
end
- it 'creates a profile of the request' do
+ it "creates a profile of the request" do
project = create(:project, namespace: user.namespace)
time = Time.now
path = "/#{project.full_path}"
Timecop.freeze(time) do
- get path, params: {}, headers: { 'X-Profile-Token' => Gitlab::RequestProfiler.profile_token }
+ get path, params: {}, headers: {"X-Profile-Token" => Gitlab::RequestProfiler.profile_token}
end
- profile_path = "#{Gitlab.config.shared.path}/tmp/requests_profiles/#{path.tr('/', '|')}_#{time.to_i}.html"
+ profile_path = "#{Gitlab.config.shared.path}/tmp/requests_profiles/#{path.tr("/", "|")}_#{time.to_i}.html"
expect(File.exist?(profile_path)).to be true
end
@@ -35,10 +35,10 @@ describe 'Request Profiler' do
login_as(user)
end
- include_examples 'profiling a request'
+ include_examples "profiling a request"
end
context "when user is not logged-in" do
- include_examples 'profiling a request'
+ include_examples "profiling a request"
end
end
diff --git a/spec/requests/user_activity_spec.rb b/spec/requests/user_activity_spec.rb
index 15666e00b9f..85f74f254a2 100644
--- a/spec/requests/user_activity_spec.rb
+++ b/spec/requests/user_activity_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Update of user activity' do
+describe "Update of user activity" do
let(:user) { create(:user, last_activity_on: nil) }
before do
- group = create(:group, name: 'group')
- project = create(:project, :public, namespace: group, name: 'project')
+ group = create(:group, name: "group")
+ project = create(:project, :public, namespace: group, name: "project")
create(:issue, project: project, iid: 10)
create(:merge_request, source_project: project, iid: 15)
@@ -16,44 +16,44 @@ describe 'Update of user activity' do
end
paths_to_visit = [
- '/group',
- '/group/project',
- '/groups/group/-/issues',
- '/groups/group/-/boards',
- '/dashboard/projects',
- '/dashboard/snippets',
- '/dashboard/groups',
- '/dashboard/todos',
- '/group/project/issues',
- '/group/project/issues/10',
- '/group/project/merge_requests',
- '/group/project/merge_requests/15'
+ "/group",
+ "/group/project",
+ "/groups/group/-/issues",
+ "/groups/group/-/boards",
+ "/dashboard/projects",
+ "/dashboard/snippets",
+ "/dashboard/groups",
+ "/dashboard/todos",
+ "/group/project/issues",
+ "/group/project/issues/10",
+ "/group/project/merge_requests",
+ "/group/project/merge_requests/15",
]
- context 'without an authenticated user' do
- it 'does not set the last activity cookie' do
+ context "without an authenticated user" do
+ it "does not set the last activity cookie" do
get "/group/project"
- expect(response.cookies['user_last_activity_on']).to be_nil
+ expect(response.cookies["user_last_activity_on"]).to be_nil
end
end
- context 'with an authenticated user' do
+ context "with an authenticated user" do
before do
login_as(user)
end
- context 'with a POST request' do
- it 'does not set the last activity cookie' do
+ context "with a POST request" do
+ it "does not set the last activity cookie" do
post "/group/project/archive"
- expect(response.cookies['user_last_activity_on']).to be_nil
+ expect(response.cookies["user_last_activity_on"]).to be_nil
end
end
paths_to_visit.each do |path|
context "on GET to #{path}" do
- it 'updates the last activity date' do
+ it "updates the last activity date" do
expect(Users::ActivityService).to receive(:new).and_call_original
get path
@@ -61,8 +61,8 @@ describe 'Update of user activity' do
expect(user.last_activity_on).to eq(Date.today)
end
- context 'when calling it twice' do
- it 'updates last_activity_on just once' do
+ context "when calling it twice" do
+ it "updates last_activity_on just once" do
expect(Users::ActivityService).to receive(:new).once.and_call_original
2.times do
@@ -71,12 +71,12 @@ describe 'Update of user activity' do
end
end
- context 'when last_activity_on is nil' do
+ context "when last_activity_on is nil" do
before do
user.update_attribute(:last_activity_on, nil)
end
- it 'updates the last activity date' do
+ it "updates the last activity date" do
expect(user.last_activity_on).to be_nil
get path
@@ -85,24 +85,24 @@ describe 'Update of user activity' do
end
end
- context 'when last_activity_on is stale' do
+ context "when last_activity_on is stale" do
before do
user.update_attribute(:last_activity_on, 2.days.ago.to_date)
end
- it 'updates the last activity date' do
+ it "updates the last activity date" do
get path
expect(user.last_activity_on).to eq(Date.today)
end
end
- context 'when last_activity_on is up to date' do
+ context "when last_activity_on is up to date" do
before do
user.update_attribute(:last_activity_on, Date.today)
end
- it 'does not try to update it' do
+ it "does not try to update it" do
expect(Users::ActivityService).not_to receive(:new)
get path
diff --git a/spec/routing/admin_routing_spec.rb b/spec/routing/admin_routing_spec.rb
index 77baaef7afd..16659f00735 100644
--- a/spec/routing/admin_routing_spec.rb
+++ b/spec/routing/admin_routing_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# block_admin_user PUT /admin/users/:id/block(.:format) admin/users#block
# unblock_admin_user PUT /admin/users/:id/unblock(.:format) admin/users#unblock
@@ -11,43 +11,43 @@ require 'spec_helper'
# DELETE /admin/users/:id(.:format) admin/users#destroy
describe Admin::UsersController, "routing" do
it "to #block" do
- expect(put("/admin/users/1/block")).to route_to('admin/users#block', id: '1')
+ expect(put("/admin/users/1/block")).to route_to("admin/users#block", id: "1")
end
it "to #unblock" do
- expect(put("/admin/users/1/unblock")).to route_to('admin/users#unblock', id: '1')
+ expect(put("/admin/users/1/unblock")).to route_to("admin/users#unblock", id: "1")
end
it "to #index" do
- expect(get("/admin/users")).to route_to('admin/users#index')
+ expect(get("/admin/users")).to route_to("admin/users#index")
end
it "to #show" do
- expect(get("/admin/users/1")).to route_to('admin/users#show', id: '1')
+ expect(get("/admin/users/1")).to route_to("admin/users#show", id: "1")
end
it "to #create" do
- expect(post("/admin/users")).to route_to('admin/users#create')
+ expect(post("/admin/users")).to route_to("admin/users#create")
end
it "to #new" do
- expect(get("/admin/users/new")).to route_to('admin/users#new')
+ expect(get("/admin/users/new")).to route_to("admin/users#new")
end
it "to #edit" do
- expect(get("/admin/users/1/edit")).to route_to('admin/users#edit', id: '1')
+ expect(get("/admin/users/1/edit")).to route_to("admin/users#edit", id: "1")
end
it "to #show" do
- expect(get("/admin/users/1")).to route_to('admin/users#show', id: '1')
+ expect(get("/admin/users/1")).to route_to("admin/users#show", id: "1")
end
it "to #update" do
- expect(put("/admin/users/1")).to route_to('admin/users#update', id: '1')
+ expect(put("/admin/users/1")).to route_to("admin/users#update", id: "1")
end
it "to #destroy" do
- expect(delete("/admin/users/1")).to route_to('admin/users#destroy', id: '1')
+ expect(delete("/admin/users/1")).to route_to("admin/users#destroy", id: "1")
end
end
@@ -62,12 +62,12 @@ end
# DELETE /admin/projects/:id(.:format) admin/projects#destroy {id: /[^\/]+/}
describe Admin::ProjectsController, "routing" do
it "to #index" do
- expect(get("/admin/projects")).to route_to('admin/projects#index')
+ expect(get("/admin/projects")).to route_to("admin/projects#index")
end
it "to #show" do
- expect(get("/admin/projects/gitlab/gitlab-ce")).to route_to('admin/projects#show', namespace_id: 'gitlab', id: 'gitlab-ce')
- expect(get("/admin/projects/gitlab/subgroup/gitlab-ce")).to route_to('admin/projects#show', namespace_id: 'gitlab/subgroup', id: 'gitlab-ce')
+ expect(get("/admin/projects/gitlab/gitlab-ce")).to route_to("admin/projects#show", namespace_id: "gitlab", id: "gitlab-ce")
+ expect(get("/admin/projects/gitlab/subgroup/gitlab-ce")).to route_to("admin/projects#show", namespace_id: "gitlab/subgroup", id: "gitlab-ce")
end
end
@@ -79,83 +79,83 @@ end
# edit_admin_hook GET /admin/hooks/:id(.:format) admin/hooks#edit
describe Admin::HooksController, "routing" do
it "to #test" do
- expect(post("/admin/hooks/1/test")).to route_to('admin/hooks#test', id: '1')
+ expect(post("/admin/hooks/1/test")).to route_to("admin/hooks#test", id: "1")
end
it "to #index" do
- expect(get("/admin/hooks")).to route_to('admin/hooks#index')
+ expect(get("/admin/hooks")).to route_to("admin/hooks#index")
end
it "to #create" do
- expect(post("/admin/hooks")).to route_to('admin/hooks#create')
+ expect(post("/admin/hooks")).to route_to("admin/hooks#create")
end
it "to #edit" do
- expect(get("/admin/hooks/1/edit")).to route_to('admin/hooks#edit', id: '1')
+ expect(get("/admin/hooks/1/edit")).to route_to("admin/hooks#edit", id: "1")
end
it "to #update" do
- expect(put("/admin/hooks/1")).to route_to('admin/hooks#update', id: '1')
+ expect(put("/admin/hooks/1")).to route_to("admin/hooks#update", id: "1")
end
it "to #destroy" do
- expect(delete("/admin/hooks/1")).to route_to('admin/hooks#destroy', id: '1')
+ expect(delete("/admin/hooks/1")).to route_to("admin/hooks#destroy", id: "1")
end
end
# admin_hook_hook_log_retry POST /admin/hooks/:hook_id/hook_logs/:id/retry(.:format) admin/hook_logs#retry
# admin_hook_hook_log GET /admin/hooks/:hook_id/hook_logs/:id(.:format) admin/hook_logs#show
-describe Admin::HookLogsController, 'routing' do
- it 'to #retry' do
- expect(post('/admin/hooks/1/hook_logs/1/retry')).to route_to('admin/hook_logs#retry', hook_id: '1', id: '1')
+describe Admin::HookLogsController, "routing" do
+ it "to #retry" do
+ expect(post("/admin/hooks/1/hook_logs/1/retry")).to route_to("admin/hook_logs#retry", hook_id: "1", id: "1")
end
- it 'to #show' do
- expect(get('/admin/hooks/1/hook_logs/1')).to route_to('admin/hook_logs#show', hook_id: '1', id: '1')
+ it "to #show" do
+ expect(get("/admin/hooks/1/hook_logs/1")).to route_to("admin/hook_logs#show", hook_id: "1", id: "1")
end
end
# admin_logs GET /admin/logs(.:format) admin/logs#show
describe Admin::LogsController, "routing" do
it "to #show" do
- expect(get("/admin/logs")).to route_to('admin/logs#show')
+ expect(get("/admin/logs")).to route_to("admin/logs#show")
end
end
# admin_background_jobs GET /admin/background_jobs(.:format) admin/background_jobs#show
describe Admin::BackgroundJobsController, "routing" do
it "to #show" do
- expect(get("/admin/background_jobs")).to route_to('admin/background_jobs#show')
+ expect(get("/admin/background_jobs")).to route_to("admin/background_jobs#show")
end
end
# admin_root /admin(.:format) admin/dashboard#index
describe Admin::DashboardController, "routing" do
it "to #index" do
- expect(get("/admin")).to route_to('admin/dashboard#index')
+ expect(get("/admin")).to route_to("admin/dashboard#index")
end
end
# admin_health_check GET /admin/health_check(.:format) admin/health_check#show
describe Admin::HealthCheckController, "routing" do
it "to #show" do
- expect(get("/admin/health_check")).to route_to('admin/health_check#show')
+ expect(get("/admin/health_check")).to route_to("admin/health_check#show")
end
end
describe Admin::GroupsController, "routing" do
- let(:name) { 'complex.group-namegit' }
+ let(:name) { "complex.group-namegit" }
it "to #index" do
- expect(get("/admin/groups")).to route_to('admin/groups#index')
+ expect(get("/admin/groups")).to route_to("admin/groups#index")
end
it "to #show" do
- expect(get("/admin/groups/#{name}")).to route_to('admin/groups#show', id: name)
- expect(get("/admin/groups/#{name}/subgroup")).to route_to('admin/groups#show', id: "#{name}/subgroup")
+ expect(get("/admin/groups/#{name}")).to route_to("admin/groups#show", id: name)
+ expect(get("/admin/groups/#{name}/subgroup")).to route_to("admin/groups#show", id: "#{name}/subgroup")
end
it "to #edit" do
- expect(get("/admin/groups/#{name}/edit")).to route_to('admin/groups#edit', id: name)
+ expect(get("/admin/groups/#{name}/edit")).to route_to("admin/groups#edit", id: name)
end
end
diff --git a/spec/routing/api_routing_spec.rb b/spec/routing/api_routing_spec.rb
index 5fde4bd885b..b89669172f1 100644
--- a/spec/routing/api_routing_spec.rb
+++ b/spec/routing/api_routing_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'api', 'routing' do
- context 'when graphql is disabled' do
+describe "api", "routing" do
+ context "when graphql is disabled" do
before do
stub_feature_flags(graphql: false)
end
- it 'does not route to the GraphqlController' do
- expect(get('/api/graphql')).not_to route_to('graphql#execute')
+ it "does not route to the GraphqlController" do
+ expect(get("/api/graphql")).not_to route_to("graphql#execute")
end
- it 'does not expose graphiql' do
- expect(get('/-/graphql-explorer')).not_to route_to('graphiql/rails/editors#show')
+ it "does not expose graphiql" do
+ expect(get("/-/graphql-explorer")).not_to route_to("graphiql/rails/editors#show")
end
end
- context 'when graphql is disabled' do
+ context "when graphql is disabled" do
before do
stub_feature_flags(graphql: true)
end
- it 'routes to the GraphqlController' do
- expect(get('/api/graphql')).not_to route_to('graphql#execute')
+ it "routes to the GraphqlController" do
+ expect(get("/api/graphql")).not_to route_to("graphql#execute")
end
- it 'exposes graphiql' do
- expect(get('/-/graphql-explorer')).not_to route_to('graphiql/rails/editors#show')
+ it "exposes graphiql" do
+ expect(get("/-/graphql-explorer")).not_to route_to("graphiql/rails/editors#show")
end
end
end
diff --git a/spec/routing/environments_spec.rb b/spec/routing/environments_spec.rb
index aacbe300966..a6843c557f5 100644
--- a/spec/routing/environments_spec.rb
+++ b/spec/routing/environments_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'environments routing' do
+describe "environments routing" do
let(:project) { create(:project) }
let(:environment) do
create(:environment, project: project,
- name: 'staging-1.0/review')
+ name: "staging-1.0/review")
end
let(:environments_route) do
"#{project.namespace.name}/#{project.name}/environments/"
end
- describe 'routing environment folders' do
- context 'when using JSON format' do
- it 'correctly matches environment name and JSON format' do
- expect(get_folder('staging-1.0.json'))
- .to route_to(*folder_action(id: 'staging-1.0', format: 'json'))
+ describe "routing environment folders" do
+ context "when using JSON format" do
+ it "correctly matches environment name and JSON format" do
+ expect(get_folder("staging-1.0.json"))
+ .to route_to(*folder_action(id: "staging-1.0", format: "json"))
end
end
- context 'when using HTML format' do
- it 'correctly matches environment name and HTML format' do
- expect(get_folder('staging-1.0.html'))
- .to route_to(*folder_action(id: 'staging-1.0', format: 'html'))
+ context "when using HTML format" do
+ it "correctly matches environment name and HTML format" do
+ expect(get_folder("staging-1.0.html"))
+ .to route_to(*folder_action(id: "staging-1.0", format: "html"))
end
end
- context 'when using implicit format' do
- it 'correctly matches environment name' do
- expect(get_folder('staging-1.0'))
- .to route_to(*folder_action(id: 'staging-1.0'))
+ context "when using implicit format" do
+ it "correctly matches environment name" do
+ expect(get_folder("staging-1.0"))
+ .to route_to(*folder_action(id: "staging-1.0"))
end
end
end
@@ -41,9 +41,9 @@ describe 'environments routing' do
end
def folder_action(**opts)
- options = { namespace_id: project.namespace.name,
- project_id: project.name }
+ options = {namespace_id: project.namespace.name,
+ project_id: project.name,}
- ['projects/environments#folder', options.merge(opts)]
+ ["projects/environments#folder", options.merge(opts)]
end
end
diff --git a/spec/routing/group_routing_spec.rb b/spec/routing/group_routing_spec.rb
index 71788028cbf..30863bcb8c3 100644
--- a/spec/routing/group_routing_spec.rb
+++ b/spec/routing/group_routing_spec.rb
@@ -1,132 +1,132 @@
-require 'spec_helper'
+require "spec_helper"
describe "Groups", "routing" do
- let(:group_path) { 'complex.group-namegit' }
+ let(:group_path) { "complex.group-namegit" }
let!(:group) { create(:group, path: group_path) }
it "to #show" do
- expect(get("/groups/#{group_path}")).to route_to('groups#show', id: group_path)
+ expect(get("/groups/#{group_path}")).to route_to("groups#show", id: group_path)
end
it "also supports nested groups" do
nested_group = create(:group, parent: group)
- expect(get("/#{group_path}/#{nested_group.path}")).to route_to('groups#show', id: "#{group_path}/#{nested_group.path}")
+ expect(get("/#{group_path}/#{nested_group.path}")).to route_to("groups#show", id: "#{group_path}/#{nested_group.path}")
end
it "also display group#show on the short path" do
- expect(get("/#{group_path}")).to route_to('groups#show', id: group_path)
+ expect(get("/#{group_path}")).to route_to("groups#show", id: group_path)
end
it "to #activity" do
- expect(get("/groups/#{group_path}/-/activity")).to route_to('groups#activity', id: group_path)
+ expect(get("/groups/#{group_path}/-/activity")).to route_to("groups#activity", id: group_path)
end
it "to #issues" do
- expect(get("/groups/#{group_path}/-/issues")).to route_to('groups#issues', id: group_path)
+ expect(get("/groups/#{group_path}/-/issues")).to route_to("groups#issues", id: group_path)
end
it "to #members" do
- expect(get("/groups/#{group_path}/-/group_members")).to route_to('groups/group_members#index', group_id: group_path)
+ expect(get("/groups/#{group_path}/-/group_members")).to route_to("groups/group_members#index", group_id: group_path)
end
it "to #labels" do
- expect(get("/groups/#{group_path}/-/labels")).to route_to('groups/labels#index', group_id: group_path)
+ expect(get("/groups/#{group_path}/-/labels")).to route_to("groups/labels#index", group_id: group_path)
end
it "to #milestones" do
- expect(get("/groups/#{group_path}/-/milestones")).to route_to('groups/milestones#index', group_id: group_path)
+ expect(get("/groups/#{group_path}/-/milestones")).to route_to("groups/milestones#index", group_id: group_path)
end
- describe 'legacy redirection' do
- describe 'labels' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/labels", "/groups/complex.group-namegit/-/labels" do
- let(:resource) { create(:group, parent: group, path: 'labels') }
+ describe "legacy redirection" do
+ describe "labels" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/labels", "/groups/complex.group-namegit/-/labels" do
+ let(:resource) { create(:group, parent: group, path: "labels") }
end
- context 'when requesting JSON' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/labels.json", "/groups/complex.group-namegit/-/labels.json" do
- let(:resource) { create(:group, parent: group, path: 'labels') }
+ context "when requesting JSON" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/labels.json", "/groups/complex.group-namegit/-/labels.json" do
+ let(:resource) { create(:group, parent: group, path: "labels") }
end
end
end
- describe 'group_members' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/group_members", "/groups/complex.group-namegit/-/group_members" do
- let(:resource) { create(:group, parent: group, path: 'group_members') }
+ describe "group_members" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/group_members", "/groups/complex.group-namegit/-/group_members" do
+ let(:resource) { create(:group, parent: group, path: "group_members") }
end
end
- describe 'avatar' do
- it 'routes to the avatars controller' do
+ describe "avatar" do
+ it "routes to the avatars controller" do
expect(delete("/groups/#{group_path}/-/avatar"))
.to route_to(group_id: group_path,
- controller: 'groups/avatars',
- action: 'destroy')
+ controller: "groups/avatars",
+ action: "destroy")
end
end
- describe 'milestones' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones", "/groups/complex.group-namegit/-/milestones" do
- let(:resource) { create(:group, parent: group, path: 'milestones') }
+ describe "milestones" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/milestones", "/groups/complex.group-namegit/-/milestones" do
+ let(:resource) { create(:group, parent: group, path: "milestones") }
end
- context 'nested routes' do
+ context "nested routes" do
include RSpec::Rails::RequestExampleGroup
let(:milestone) { create(:milestone, group: group) }
- it 'redirects the nested routes' do
+ it "redirects the nested routes" do
request = get("/groups/#{group_path}/milestones/#{milestone.id}/merge_requests")
expect(request).to redirect_to("/groups/#{group_path}/-/milestones/#{milestone.id}/merge_requests")
end
end
- context 'with a query string' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones?hello=world", "/groups/complex.group-namegit/-/milestones?hello=world" do
- let(:resource) { create(:group, parent: group, path: 'milestones') }
+ context "with a query string" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/milestones?hello=world", "/groups/complex.group-namegit/-/milestones?hello=world" do
+ let(:resource) { create(:group, parent: group, path: "milestones") }
end
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/milestones?milestones=/milestones", "/groups/complex.group-namegit/-/milestones?milestones=/milestones" do
- let(:resource) { create(:group, parent: group, path: 'milestones') }
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/milestones?milestones=/milestones", "/groups/complex.group-namegit/-/milestones?milestones=/milestones" do
+ let(:resource) { create(:group, parent: group, path: "milestones") }
end
end
end
- describe 'edit' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/edit", "/groups/complex.group-namegit/-/edit" do
+ describe "edit" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/edit", "/groups/complex.group-namegit/-/edit" do
let(:resource) do
- pending('still rejected because of the wildcard reserved word')
- create(:group, parent: group, path: 'edit')
+ pending("still rejected because of the wildcard reserved word")
+ create(:group, parent: group, path: "edit")
end
end
end
- describe 'issues' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/issues", "/groups/complex.group-namegit/-/issues" do
- let(:resource) { create(:group, parent: group, path: 'issues') }
+ describe "issues" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/issues", "/groups/complex.group-namegit/-/issues" do
+ let(:resource) { create(:group, parent: group, path: "issues") }
end
end
- describe 'merge_requests' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/merge_requests", "/groups/complex.group-namegit/-/merge_requests" do
- let(:resource) { create(:group, parent: group, path: 'merge_requests') }
+ describe "merge_requests" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/merge_requests", "/groups/complex.group-namegit/-/merge_requests" do
+ let(:resource) { create(:group, parent: group, path: "merge_requests") }
end
end
- describe 'projects' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/projects", "/groups/complex.group-namegit/-/projects" do
- let(:resource) { create(:group, parent: group, path: 'projects') }
+ describe "projects" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/projects", "/groups/complex.group-namegit/-/projects" do
+ let(:resource) { create(:group, parent: group, path: "projects") }
end
end
- describe 'activity' do
- it_behaves_like 'redirecting a legacy path', "/groups/complex.group-namegit/activity", "/groups/complex.group-namegit/-/activity" do
- let(:resource) { create(:group, parent: group, path: 'activity') }
+ describe "activity" do
+ it_behaves_like "redirecting a legacy path", "/groups/complex.group-namegit/activity", "/groups/complex.group-namegit/-/activity" do
+ let(:resource) { create(:group, parent: group, path: "activity") }
end
- it_behaves_like 'redirecting a legacy path', "/groups/activity/activity", "/groups/activity/-/activity" do
- let!(:parent) { create(:group, path: 'activity') }
- let(:resource) { create(:group, parent: parent, path: 'activity') }
+ it_behaves_like "redirecting a legacy path", "/groups/activity/activity", "/groups/activity/-/activity" do
+ let!(:parent) { create(:group, path: "activity") }
+ let(:resource) { create(:group, parent: parent, path: "activity") }
end
end
end
diff --git a/spec/routing/import_routing_spec.rb b/spec/routing/import_routing_spec.rb
index 106f92082e4..0923770ef52 100644
--- a/spec/routing/import_routing_spec.rb
+++ b/spec/routing/import_routing_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# Shared examples for a resource inside a Project
#
@@ -21,7 +21,7 @@ require 'spec_helper'
# let(:actions) { [:index] }
# let(:controller) { 'issues' }
# end
-shared_examples 'importer routing' do
+shared_examples "importer routing" do
let(:except_actions) { [] }
let(:is_realtime) { false }
@@ -29,27 +29,27 @@ shared_examples 'importer routing' do
except_actions.push(is_realtime ? :jobs : :realtime_changes)
end
- it 'to #create' do
+ it "to #create" do
expect(post("/import/#{provider}")).to route_to("import/#{provider}#create") unless except_actions.include?(:create)
end
- it 'to #new' do
+ it "to #new" do
expect(get("/import/#{provider}/new")).to route_to("import/#{provider}#new") unless except_actions.include?(:new)
end
- it 'to #status' do
+ it "to #status" do
expect(get("/import/#{provider}/status")).to route_to("import/#{provider}#status") unless except_actions.include?(:status)
end
- it 'to #callback' do
+ it "to #callback" do
expect(get("/import/#{provider}/callback")).to route_to("import/#{provider}#callback") unless except_actions.include?(:callback)
end
- it 'to #jobs' do
+ it "to #jobs" do
expect(get("/import/#{provider}/jobs")).to route_to("import/#{provider}#jobs") unless except_actions.include?(:jobs)
end
- it 'to #realtime_changes' do
+ it "to #realtime_changes" do
expect(get("/import/#{provider}/realtime_changes")).to route_to("import/#{provider}#realtime_changes") unless except_actions.include?(:realtime_changes)
end
end
@@ -60,14 +60,14 @@ end
# realtime_changes_import_github GET /import/github/realtime_changes(.:format) import/github#jobs
# import_github POST /import/github(.:format) import/github#create
# new_import_github GET /import/github/new(.:format) import/github#new
-describe Import::GithubController, 'routing' do
- it_behaves_like 'importer routing' do
- let(:provider) { 'github' }
+describe Import::GithubController, "routing" do
+ it_behaves_like "importer routing" do
+ let(:provider) { "github" }
let(:is_realtime) { true }
end
- it 'to #personal_access_token' do
- expect(post('/import/github/personal_access_token')).to route_to('import/github#personal_access_token')
+ it "to #personal_access_token" do
+ expect(post("/import/github/personal_access_token")).to route_to("import/github#personal_access_token")
end
end
@@ -76,15 +76,15 @@ end
# realtime_changes_import_gitea GET /import/gitea/realtime_changes(.:format) import/gitea#jobs
# import_gitea POST /import/gitea(.:format) import/gitea#create
# new_import_gitea GET /import/gitea/new(.:format) import/gitea#new
-describe Import::GiteaController, 'routing' do
- it_behaves_like 'importer routing' do
+describe Import::GiteaController, "routing" do
+ it_behaves_like "importer routing" do
let(:except_actions) { [:callback] }
- let(:provider) { 'gitea' }
+ let(:provider) { "gitea" }
let(:is_realtime) { true }
end
- it 'to #personal_access_token' do
- expect(post('/import/gitea/personal_access_token')).to route_to('import/gitea#personal_access_token')
+ it "to #personal_access_token" do
+ expect(post("/import/gitea/personal_access_token")).to route_to("import/gitea#personal_access_token")
end
end
@@ -92,10 +92,10 @@ end
# callback_import_gitlab GET /import/gitlab/callback(.:format) import/gitlab#callback
# jobs_import_gitlab GET /import/gitlab/jobs(.:format) import/gitlab#jobs
# import_gitlab POST /import/gitlab(.:format) import/gitlab#create
-describe Import::GitlabController, 'routing' do
- it_behaves_like 'importer routing' do
+describe Import::GitlabController, "routing" do
+ it_behaves_like "importer routing" do
let(:except_actions) { [:new] }
- let(:provider) { 'gitlab' }
+ let(:provider) { "gitlab" }
end
end
@@ -103,10 +103,10 @@ end
# callback_import_bitbucket GET /import/bitbucket/callback(.:format) import/bitbucket#callback
# jobs_import_bitbucket GET /import/bitbucket/jobs(.:format) import/bitbucket#jobs
# import_bitbucket POST /import/bitbucket(.:format) import/bitbucket#create
-describe Import::BitbucketController, 'routing' do
- it_behaves_like 'importer routing' do
+describe Import::BitbucketController, "routing" do
+ it_behaves_like "importer routing" do
let(:except_actions) { [:new] }
- let(:provider) { 'bitbucket' }
+ let(:provider) { "bitbucket" }
end
end
@@ -117,22 +117,22 @@ end
# create_user_map_import_google_code POST /import/google_code/user_map(.:format) import/google_code#create_user_map
# import_google_code POST /import/google_code(.:format) import/google_code#create
# new_import_google_code GET /import/google_code/new(.:format) import/google_code#new
-describe Import::GoogleCodeController, 'routing' do
- it_behaves_like 'importer routing' do
+describe Import::GoogleCodeController, "routing" do
+ it_behaves_like "importer routing" do
let(:except_actions) { [:callback] }
- let(:provider) { 'google_code' }
+ let(:provider) { "google_code" }
end
- it 'to #callback' do
+ it "to #callback" do
expect(post("/import/google_code/callback")).to route_to("import/google_code#callback")
end
- it 'to #new_user_map' do
- expect(get('/import/google_code/user_map')).to route_to('import/google_code#new_user_map')
+ it "to #new_user_map" do
+ expect(get("/import/google_code/user_map")).to route_to("import/google_code#new_user_map")
end
- it 'to #create_user_map' do
- expect(post('/import/google_code/user_map')).to route_to('import/google_code#create_user_map')
+ it "to #create_user_map" do
+ expect(post("/import/google_code/user_map")).to route_to("import/google_code#create_user_map")
end
end
@@ -143,34 +143,34 @@ end
# create_user_map_import_fogbugz POST /import/fogbugz/user_map(.:format) import/fogbugz#create_user_map
# import_fogbugz POST /import/fogbugz(.:format) import/fogbugz#create
# new_import_fogbugz GET /import/fogbugz/new(.:format) import/fogbugz#new
-describe Import::FogbugzController, 'routing' do
- it_behaves_like 'importer routing' do
+describe Import::FogbugzController, "routing" do
+ it_behaves_like "importer routing" do
let(:except_actions) { [:callback] }
- let(:provider) { 'fogbugz' }
+ let(:provider) { "fogbugz" }
end
- it 'to #callback' do
+ it "to #callback" do
expect(post("/import/fogbugz/callback")).to route_to("import/fogbugz#callback")
end
- it 'to #new_user_map' do
- expect(get('/import/fogbugz/user_map')).to route_to('import/fogbugz#new_user_map')
+ it "to #new_user_map" do
+ expect(get("/import/fogbugz/user_map")).to route_to("import/fogbugz#new_user_map")
end
- it 'to #create_user_map' do
- expect(post('/import/fogbugz/user_map')).to route_to('import/fogbugz#create_user_map')
+ it "to #create_user_map" do
+ expect(post("/import/fogbugz/user_map")).to route_to("import/fogbugz#create_user_map")
end
end
# import_gitlab_project POST /import/gitlab_project(.:format) import/gitlab_projects#create
# POST /import/gitlab_project(.:format) import/gitlab_projects#create
# new_import_gitlab_project GET /import/gitlab_project/new(.:format) import/gitlab_projects#new
-describe Import::GitlabProjectsController, 'routing' do
- it 'to #create' do
- expect(post('/import/gitlab_project')).to route_to('import/gitlab_projects#create')
+describe Import::GitlabProjectsController, "routing" do
+ it "to #create" do
+ expect(post("/import/gitlab_project")).to route_to("import/gitlab_projects#create")
end
- it 'to #new' do
- expect(get('/import/gitlab_project/new')).to route_to('import/gitlab_projects#new')
+ it "to #new" do
+ expect(get("/import/gitlab_project/new")).to route_to("import/gitlab_projects#new")
end
end
diff --git a/spec/routing/instance_statistics_routing_spec.rb b/spec/routing/instance_statistics_routing_spec.rb
index b94faabfa1d..142cbe9d949 100644
--- a/spec/routing/instance_statistics_routing_spec.rb
+++ b/spec/routing/instance_statistics_routing_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'Instance Statistics', 'routing' do
+describe "Instance Statistics", "routing" do
include RSpec::Rails::RequestExampleGroup
it "routes '/-/instance_statistics' to conversational development index" do
- expect(get('/-/instance_statistics')).to redirect_to('/-/instance_statistics/conversational_development_index')
+ expect(get("/-/instance_statistics")).to redirect_to("/-/instance_statistics/conversational_development_index")
end
end
diff --git a/spec/routing/openid_connect_spec.rb b/spec/routing/openid_connect_spec.rb
index 2c3bc08f1a1..672c5511201 100644
--- a/spec/routing/openid_connect_spec.rb
+++ b/spec/routing/openid_connect_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
# oauth_discovery_keys GET /oauth/discovery/keys(.:format) doorkeeper/openid_connect/discovery#keys
# oauth_discovery_provider GET /.well-known/openid-configuration(.:format) doorkeeper/openid_connect/discovery#provider
# oauth_discovery_webfinger GET /.well-known/webfinger(.:format) doorkeeper/openid_connect/discovery#webfinger
-describe Doorkeeper::OpenidConnect::DiscoveryController, 'routing' do
+describe Doorkeeper::OpenidConnect::DiscoveryController, "routing" do
it "to #provider" do
- expect(get('/.well-known/openid-configuration')).to route_to('doorkeeper/openid_connect/discovery#provider')
+ expect(get("/.well-known/openid-configuration")).to route_to("doorkeeper/openid_connect/discovery#provider")
end
it "to #webfinger" do
- expect(get('/.well-known/webfinger')).to route_to('doorkeeper/openid_connect/discovery#webfinger')
+ expect(get("/.well-known/webfinger")).to route_to("doorkeeper/openid_connect/discovery#webfinger")
end
it "to #keys" do
- expect(get('/oauth/discovery/keys')).to route_to('doorkeeper/openid_connect/discovery#keys')
+ expect(get("/oauth/discovery/keys")).to route_to("doorkeeper/openid_connect/discovery#keys")
end
end
# oauth_userinfo GET /oauth/userinfo(.:format) doorkeeper/openid_connect/userinfo#show
# POST /oauth/userinfo(.:format) doorkeeper/openid_connect/userinfo#show
-describe Doorkeeper::OpenidConnect::UserinfoController, 'routing' do
+describe Doorkeeper::OpenidConnect::UserinfoController, "routing" do
it "to #show" do
- expect(get('/oauth/userinfo')).to route_to('doorkeeper/openid_connect/userinfo#show')
+ expect(get("/oauth/userinfo")).to route_to("doorkeeper/openid_connect/userinfo#show")
end
it "to #show" do
- expect(post('/oauth/userinfo')).to route_to('doorkeeper/openid_connect/userinfo#show')
+ expect(post("/oauth/userinfo")).to route_to("doorkeeper/openid_connect/userinfo#show")
end
end
diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb
index a0d01fc8263..1853e65ef1e 100644
--- a/spec/routing/project_routing_spec.rb
+++ b/spec/routing/project_routing_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'project routing' do
+describe "project routing" do
before do
allow(Project).to receive(:find_by_full_path).and_return(false)
- allow(Project).to receive(:find_by_full_path).with('gitlab/gitlabhq', any_args).and_return(true)
+ allow(Project).to receive(:find_by_full_path).with("gitlab/gitlabhq", any_args).and_return(true)
end
# Shared examples for a resource inside a Project
@@ -33,36 +33,36 @@ describe 'project routing' do
# let(:controller) { 'pages_domains' }
# let(:controller_path) { 'pages/domains' }
# end
- shared_examples 'RESTful project resources' do
+ shared_examples "RESTful project resources" do
let(:actions) { [:index, :create, :new, :edit, :show, :update, :destroy] }
let(:controller_path) { controller }
- it 'to #index' do
- expect(get("/gitlab/gitlabhq/#{controller_path}")).to route_to("projects/#{controller}#index", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:index)
+ it "to #index" do
+ expect(get("/gitlab/gitlabhq/#{controller_path}")).to route_to("projects/#{controller}#index", namespace_id: "gitlab", project_id: "gitlabhq") if actions.include?(:index)
end
- it 'to #create' do
- expect(post("/gitlab/gitlabhq/#{controller_path}")).to route_to("projects/#{controller}#create", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:create)
+ it "to #create" do
+ expect(post("/gitlab/gitlabhq/#{controller_path}")).to route_to("projects/#{controller}#create", namespace_id: "gitlab", project_id: "gitlabhq") if actions.include?(:create)
end
- it 'to #new' do
- expect(get("/gitlab/gitlabhq/#{controller_path}/new")).to route_to("projects/#{controller}#new", namespace_id: 'gitlab', project_id: 'gitlabhq') if actions.include?(:new)
+ it "to #new" do
+ expect(get("/gitlab/gitlabhq/#{controller_path}/new")).to route_to("projects/#{controller}#new", namespace_id: "gitlab", project_id: "gitlabhq") if actions.include?(:new)
end
- it 'to #edit' do
- expect(get("/gitlab/gitlabhq/#{controller_path}/1/edit")).to route_to("projects/#{controller}#edit", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:edit)
+ it "to #edit" do
+ expect(get("/gitlab/gitlabhq/#{controller_path}/1/edit")).to route_to("projects/#{controller}#edit", namespace_id: "gitlab", project_id: "gitlabhq", id: "1") if actions.include?(:edit)
end
- it 'to #show' do
- expect(get("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#show", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:show)
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1") if actions.include?(:show)
end
- it 'to #update' do
- expect(put("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#update", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:update)
+ it "to #update" do
+ expect(put("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#update", namespace_id: "gitlab", project_id: "gitlabhq", id: "1") if actions.include?(:update)
end
- it 'to #destroy' do
- expect(delete("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#destroy", namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1') if actions.include?(:destroy)
+ it "to #destroy" do
+ expect(delete("/gitlab/gitlabhq/#{controller_path}/1")).to route_to("projects/#{controller}#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "1") if actions.include?(:destroy)
end
end
@@ -74,57 +74,57 @@ describe 'project routing' do
# PUT /:id(.:format) projects#update
# DELETE /:id(.:format) projects#destroy
# preview_markdown_project POST /:id/preview_markdown(.:format) projects#preview_markdown
- describe ProjectsController, 'routing' do
- it 'to #create' do
- expect(post('/projects')).to route_to('projects#create')
+ describe ProjectsController, "routing" do
+ it "to #create" do
+ expect(post("/projects")).to route_to("projects#create")
end
- it 'to #new' do
- expect(get('/projects/new')).to route_to('projects#new')
+ it "to #new" do
+ expect(get("/projects/new")).to route_to("projects#new")
end
- it 'to #edit' do
- expect(get('/gitlab/gitlabhq/edit')).to route_to('projects#edit', namespace_id: 'gitlab', id: 'gitlabhq')
+ it "to #edit" do
+ expect(get("/gitlab/gitlabhq/edit")).to route_to("projects#edit", namespace_id: "gitlab", id: "gitlabhq")
end
- describe 'to #show' do
- context 'regular name' do
- it { expect(get('/gitlab/gitlabhq')).to route_to('projects#show', namespace_id: 'gitlab', id: 'gitlabhq') }
+ describe "to #show" do
+ context "regular name" do
+ it { expect(get("/gitlab/gitlabhq")).to route_to("projects#show", namespace_id: "gitlab", id: "gitlabhq") }
end
- context 'name with dot' do
+ context "name with dot" do
before do
- allow(Project).to receive(:find_by_full_path).with('gitlab/gitlabhq.keys', any_args).and_return(true)
+ allow(Project).to receive(:find_by_full_path).with("gitlab/gitlabhq.keys", any_args).and_return(true)
end
- it { expect(get('/gitlab/gitlabhq.keys')).to route_to('projects#show', namespace_id: 'gitlab', id: 'gitlabhq.keys') }
+ it { expect(get("/gitlab/gitlabhq.keys")).to route_to("projects#show", namespace_id: "gitlab", id: "gitlabhq.keys") }
end
- context 'with nested group' do
+ context "with nested group" do
before do
- allow(Project).to receive(:find_by_full_path).with('gitlab/subgroup/gitlabhq', any_args).and_return(true)
+ allow(Project).to receive(:find_by_full_path).with("gitlab/subgroup/gitlabhq", any_args).and_return(true)
end
- it { expect(get('/gitlab/subgroup/gitlabhq')).to route_to('projects#show', namespace_id: 'gitlab/subgroup', id: 'gitlabhq') }
+ it { expect(get("/gitlab/subgroup/gitlabhq")).to route_to("projects#show", namespace_id: "gitlab/subgroup", id: "gitlabhq") }
end
end
- it 'to #update' do
- expect(put('/gitlab/gitlabhq')).to route_to('projects#update', namespace_id: 'gitlab', id: 'gitlabhq')
+ it "to #update" do
+ expect(put("/gitlab/gitlabhq")).to route_to("projects#update", namespace_id: "gitlab", id: "gitlabhq")
end
- it 'to #destroy' do
- expect(delete('/gitlab/gitlabhq')).to route_to('projects#destroy', namespace_id: 'gitlab', id: 'gitlabhq')
+ it "to #destroy" do
+ expect(delete("/gitlab/gitlabhq")).to route_to("projects#destroy", namespace_id: "gitlab", id: "gitlabhq")
end
- it 'to #preview_markdown' do
- expect(post('/gitlab/gitlabhq/preview_markdown')).to(
- route_to('projects#preview_markdown', namespace_id: 'gitlab', id: 'gitlabhq')
+ it "to #preview_markdown" do
+ expect(post("/gitlab/gitlabhq/preview_markdown")).to(
+ route_to("projects#preview_markdown", namespace_id: "gitlab", id: "gitlabhq")
)
end
- it 'to #resolve' do
- expect(get('/projects/1')).to route_to('projects#resolve', id: '1')
+ it "to #resolve" do
+ expect(get("/projects/1")).to route_to("projects#resolve", id: "1")
end
end
@@ -135,10 +135,10 @@ describe 'project routing' do
# milestones_namespace_project_autocomplete_sources_path GET /:project_id/autocomplete_sources/milestones(.:format) projects/autocomplete_sources#milestones
# commands_namespace_project_autocomplete_sources_path GET /:project_id/autocomplete_sources/commands(.:format) projects/autocomplete_sources#commands
# snippets_namespace_project_autocomplete_sources_path GET /:project_id/autocomplete_sources/snippets(.:format) projects/autocomplete_sources#snippets
- describe Projects::AutocompleteSourcesController, 'routing' do
+ describe Projects::AutocompleteSourcesController, "routing" do
[:members, :issues, :merge_requests, :labels, :milestones, :commands, :snippets].each do |action|
it "to ##{action}" do
- expect(get("/gitlab/gitlabhq/autocomplete_sources/#{action}")).to route_to("projects/autocomplete_sources##{action}", namespace_id: 'gitlab', project_id: 'gitlabhq')
+ expect(get("/gitlab/gitlabhq/autocomplete_sources/#{action}")).to route_to("projects/autocomplete_sources##{action}", namespace_id: "gitlab", project_id: "gitlabhq")
end
end
end
@@ -149,18 +149,18 @@ describe 'project routing' do
# edit_project_wiki GET /:project_id/wikis/:id/edit(.:format) projects/wikis#edit
# project_wiki GET /:project_id/wikis/:id(.:format) projects/wikis#show
# DELETE /:project_id/wikis/:id(.:format) projects/wikis#destroy
- describe Projects::WikisController, 'routing' do
- it 'to #pages' do
- expect(get('/gitlab/gitlabhq/wikis/pages')).to route_to('projects/wikis#pages', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::WikisController, "routing" do
+ it "to #pages" do
+ expect(get("/gitlab/gitlabhq/wikis/pages")).to route_to("projects/wikis#pages", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #history' do
- expect(get('/gitlab/gitlabhq/wikis/1/history')).to route_to('projects/wikis#history', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it "to #history" do
+ expect(get("/gitlab/gitlabhq/wikis/1/history")).to route_to("projects/wikis#history", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it_behaves_like 'RESTful project resources' do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:create, :edit, :show, :destroy] }
- let(:controller) { 'wikis' }
+ let(:controller) { "wikis" }
end
end
@@ -168,61 +168,61 @@ describe 'project routing' do
# tags_project_repository GET /:project_id/repository/tags(.:format) projects/repositories#tags
# archive_project_repository GET /:project_id/repository/archive(.:format) projects/repositories#archive
# edit_project_repository GET /:project_id/repository/edit(.:format) projects/repositories#edit
- describe Projects::RepositoriesController, 'routing' do
- it 'to #archive format:zip' do
- expect(get('/gitlab/gitlabhq/-/archive/master/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip', id: 'master/archive')
+ describe Projects::RepositoriesController, "routing" do
+ it "to #archive format:zip" do
+ expect(get("/gitlab/gitlabhq/-/archive/master/archive.zip")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", format: "zip", id: "master/archive")
end
- it 'to #archive format:tar.bz2' do
- expect(get('/gitlab/gitlabhq/-/archive/master/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2', id: 'master/archive')
+ it "to #archive format:tar.bz2" do
+ expect(get("/gitlab/gitlabhq/-/archive/master/archive.tar.bz2")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", format: "tar.bz2", id: "master/archive")
end
it 'to #archive with "/" in route' do
- expect(get('/gitlab/gitlabhq/-/archive/improve/awesome/gitlabhq-improve-awesome.tar.gz')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.gz', id: 'improve/awesome/gitlabhq-improve-awesome')
+ expect(get("/gitlab/gitlabhq/-/archive/improve/awesome/gitlabhq-improve-awesome.tar.gz")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", format: "tar.gz", id: "improve/awesome/gitlabhq-improve-awesome")
end
- it 'to #archive_alternative' do
- expect(get('/gitlab/gitlabhq/repository/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', append_sha: true)
+ it "to #archive_alternative" do
+ expect(get("/gitlab/gitlabhq/repository/archive")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", append_sha: true)
end
- it 'to #archive_deprecated' do
- expect(get('/gitlab/gitlabhq/repository/master/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', append_sha: true)
+ it "to #archive_deprecated" do
+ expect(get("/gitlab/gitlabhq/repository/master/archive")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", id: "master", append_sha: true)
end
- it 'to #archive_deprecated format:zip' do
- expect(get('/gitlab/gitlabhq/repository/master/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip', id: 'master', append_sha: true)
+ it "to #archive_deprecated format:zip" do
+ expect(get("/gitlab/gitlabhq/repository/master/archive.zip")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", format: "zip", id: "master", append_sha: true)
end
- it 'to #archive_deprecated format:tar.bz2' do
- expect(get('/gitlab/gitlabhq/repository/master/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2', id: 'master', append_sha: true)
+ it "to #archive_deprecated format:tar.bz2" do
+ expect(get("/gitlab/gitlabhq/repository/master/archive.tar.bz2")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", format: "tar.bz2", id: "master", append_sha: true)
end
it 'to #archive_deprecated with "/" in route' do
- expect(get('/gitlab/gitlabhq/repository/improve/awesome/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'improve/awesome', append_sha: true)
+ expect(get("/gitlab/gitlabhq/repository/improve/awesome/archive")).to route_to("projects/repositories#archive", namespace_id: "gitlab", project_id: "gitlabhq", id: "improve/awesome", append_sha: true)
end
end
- describe Projects::BranchesController, 'routing' do
- it 'to #branches' do
- expect(get('/gitlab/gitlabhq/branches')).to route_to('projects/branches#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
- expect(delete('/gitlab/gitlabhq/branches/feature%2345')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
- expect(delete('/gitlab/gitlabhq/branches/feature%2B45')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
- expect(delete('/gitlab/gitlabhq/branches/feature@45')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
- expect(delete('/gitlab/gitlabhq/branches/feature%2345/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45/foo/bar/baz')
- expect(delete('/gitlab/gitlabhq/branches/feature%2B45/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45/foo/bar/baz')
- expect(delete('/gitlab/gitlabhq/branches/feature@45/foo/bar/baz')).to route_to('projects/branches#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45/foo/bar/baz')
+ describe Projects::BranchesController, "routing" do
+ it "to #branches" do
+ expect(get("/gitlab/gitlabhq/branches")).to route_to("projects/branches#index", namespace_id: "gitlab", project_id: "gitlabhq")
+ expect(delete("/gitlab/gitlabhq/branches/feature%2345")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45")
+ expect(delete("/gitlab/gitlabhq/branches/feature%2B45")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45")
+ expect(delete("/gitlab/gitlabhq/branches/feature@45")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45")
+ expect(delete("/gitlab/gitlabhq/branches/feature%2345/foo/bar/baz")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45/foo/bar/baz")
+ expect(delete("/gitlab/gitlabhq/branches/feature%2B45/foo/bar/baz")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45/foo/bar/baz")
+ expect(delete("/gitlab/gitlabhq/branches/feature@45/foo/bar/baz")).to route_to("projects/branches#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45/foo/bar/baz")
end
end
- describe Projects::TagsController, 'routing' do
- it 'to #tags' do
- expect(get('/gitlab/gitlabhq/tags')).to route_to('projects/tags#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
- expect(delete('/gitlab/gitlabhq/tags/feature%2345')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
- expect(delete('/gitlab/gitlabhq/tags/feature%2B45')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
- expect(delete('/gitlab/gitlabhq/tags/feature@45')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
- expect(delete('/gitlab/gitlabhq/tags/feature%2345/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45/foo/bar/baz')
- expect(delete('/gitlab/gitlabhq/tags/feature%2B45/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45/foo/bar/baz')
- expect(delete('/gitlab/gitlabhq/tags/feature@45/foo/bar/baz')).to route_to('projects/tags#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45/foo/bar/baz')
+ describe Projects::TagsController, "routing" do
+ it "to #tags" do
+ expect(get("/gitlab/gitlabhq/tags")).to route_to("projects/tags#index", namespace_id: "gitlab", project_id: "gitlabhq")
+ expect(delete("/gitlab/gitlabhq/tags/feature%2345")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45")
+ expect(delete("/gitlab/gitlabhq/tags/feature%2B45")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45")
+ expect(delete("/gitlab/gitlabhq/tags/feature@45")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45")
+ expect(delete("/gitlab/gitlabhq/tags/feature%2345/foo/bar/baz")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45/foo/bar/baz")
+ expect(delete("/gitlab/gitlabhq/tags/feature%2B45/foo/bar/baz")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45/foo/bar/baz")
+ expect(delete("/gitlab/gitlabhq/tags/feature@45/foo/bar/baz")).to route_to("projects/tags#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45/foo/bar/baz")
end
end
@@ -233,111 +233,111 @@ describe 'project routing' do
# edit_project_deploy_key GET /:project_id/deploy_keys/:id/edit(.:format) deploy_keys#edit
# project_deploy_key PATCH /:project_id/deploy_keys/:id(.:format) deploy_keys#update
# DELETE /:project_id/deploy_keys/:id(.:format) deploy_keys#destroy
- describe Projects::DeployKeysController, 'routing' do
- it_behaves_like 'RESTful project resources' do
+ describe Projects::DeployKeysController, "routing" do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:index, :new, :create, :edit, :update] }
- let(:controller) { 'deploy_keys' }
+ let(:controller) { "deploy_keys" }
end
end
# project_protected_branches GET /:project_id/protected_branches(.:format) protected_branches#index
# POST /:project_id/protected_branches(.:format) protected_branches#create
# project_protected_branch DELETE /:project_id/protected_branches/:id(.:format) protected_branches#destroy
- describe Projects::ProtectedBranchesController, 'routing' do
- it_behaves_like 'RESTful project resources' do
+ describe Projects::ProtectedBranchesController, "routing" do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:index, :create, :destroy] }
- let(:controller) { 'protected_branches' }
+ let(:controller) { "protected_branches" }
end
end
# switch_project_refs GET /:project_id/refs/switch(.:format) refs#switch
# logs_tree_project_ref GET /:project_id/refs/:id/logs_tree(.:format) refs#logs_tree
# logs_file_project_ref GET /:project_id/refs/:id/logs_tree/:path(.:format) refs#logs_tree
- describe Projects::RefsController, 'routing' do
- it 'to #switch' do
- expect(get('/gitlab/gitlabhq/refs/switch')).to route_to('projects/refs#switch', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::RefsController, "routing" do
+ it "to #switch" do
+ expect(get("/gitlab/gitlabhq/refs/switch")).to route_to("projects/refs#switch", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #logs_tree' do
- expect(get('/gitlab/gitlabhq/refs/stable/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable')
- expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45')
- expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45')
- expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45')
- expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'foo/bar/baz')
- expect(get('/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature#45', path: 'foo/bar/baz')
- expect(get('/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature+45', path: 'foo/bar/baz')
- expect(get('/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'feature@45', path: 'foo/bar/baz')
- expect(get('/gitlab/gitlabhq/refs/stable/logs_tree/files.scss')).to route_to('projects/refs#logs_tree', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'stable', path: 'files.scss')
+ it "to #logs_tree" do
+ expect(get("/gitlab/gitlabhq/refs/stable/logs_tree")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "stable")
+ expect(get("/gitlab/gitlabhq/refs/feature%2345/logs_tree")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45")
+ expect(get("/gitlab/gitlabhq/refs/feature%2B45/logs_tree")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45")
+ expect(get("/gitlab/gitlabhq/refs/feature@45/logs_tree")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45")
+ expect(get("/gitlab/gitlabhq/refs/stable/logs_tree/foo/bar/baz")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "stable", path: "foo/bar/baz")
+ expect(get("/gitlab/gitlabhq/refs/feature%2345/logs_tree/foo/bar/baz")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature#45", path: "foo/bar/baz")
+ expect(get("/gitlab/gitlabhq/refs/feature%2B45/logs_tree/foo/bar/baz")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature+45", path: "foo/bar/baz")
+ expect(get("/gitlab/gitlabhq/refs/feature@45/logs_tree/foo/bar/baz")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "feature@45", path: "foo/bar/baz")
+ expect(get("/gitlab/gitlabhq/refs/stable/logs_tree/files.scss")).to route_to("projects/refs#logs_tree", namespace_id: "gitlab", project_id: "gitlabhq", id: "stable", path: "files.scss")
end
end
- describe Projects::MergeRequestsController, 'routing' do
- it 'to #commits' do
- expect(get('/gitlab/gitlabhq/merge_requests/1/commits.json')).to route_to('projects/merge_requests#commits', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'json')
+ describe Projects::MergeRequestsController, "routing" do
+ it "to #commits" do
+ expect(get("/gitlab/gitlabhq/merge_requests/1/commits.json")).to route_to("projects/merge_requests#commits", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", format: "json")
end
- it 'to #pipelines' do
- expect(get('/gitlab/gitlabhq/merge_requests/1/pipelines.json')).to route_to('projects/merge_requests#pipelines', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'json')
+ it "to #pipelines" do
+ expect(get("/gitlab/gitlabhq/merge_requests/1/pipelines.json")).to route_to("projects/merge_requests#pipelines", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", format: "json")
end
- it 'to #merge' do
- expect(post('/gitlab/gitlabhq/merge_requests/1/merge')).to route_to(
- 'projects/merge_requests#merge',
- namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1'
+ it "to #merge" do
+ expect(post("/gitlab/gitlabhq/merge_requests/1/merge")).to route_to(
+ "projects/merge_requests#merge",
+ namespace_id: "gitlab", project_id: "gitlabhq", id: "1"
)
end
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/merge_requests/1.diff')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'diff')
- expect(get('/gitlab/gitlabhq/merge_requests/1.patch')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'patch')
- expect(get('/gitlab/gitlabhq/merge_requests/1/diffs')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', tab: 'diffs')
- expect(get('/gitlab/gitlabhq/merge_requests/1/commits')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', tab: 'commits')
- expect(get('/gitlab/gitlabhq/merge_requests/1/pipelines')).to route_to('projects/merge_requests#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', tab: 'pipelines')
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/merge_requests/1.diff")).to route_to("projects/merge_requests#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", format: "diff")
+ expect(get("/gitlab/gitlabhq/merge_requests/1.patch")).to route_to("projects/merge_requests#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", format: "patch")
+ expect(get("/gitlab/gitlabhq/merge_requests/1/diffs")).to route_to("projects/merge_requests#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", tab: "diffs")
+ expect(get("/gitlab/gitlabhq/merge_requests/1/commits")).to route_to("projects/merge_requests#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", tab: "commits")
+ expect(get("/gitlab/gitlabhq/merge_requests/1/pipelines")).to route_to("projects/merge_requests#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", tab: "pipelines")
end
- it_behaves_like 'RESTful project resources' do
- let(:controller) { 'merge_requests' }
+ it_behaves_like "RESTful project resources" do
+ let(:controller) { "merge_requests" }
let(:actions) { [:index, :edit, :show, :update] }
end
end
- describe Projects::MergeRequests::CreationsController, 'routing' do
- it 'to #new' do
- expect(get('/gitlab/gitlabhq/merge_requests/new')).to route_to('projects/merge_requests/creations#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
- expect(get('/gitlab/gitlabhq/merge_requests/new/diffs')).to route_to('projects/merge_requests/creations#new', namespace_id: 'gitlab', project_id: 'gitlabhq', tab: 'diffs')
- expect(get('/gitlab/gitlabhq/merge_requests/new/pipelines')).to route_to('projects/merge_requests/creations#new', namespace_id: 'gitlab', project_id: 'gitlabhq', tab: 'pipelines')
+ describe Projects::MergeRequests::CreationsController, "routing" do
+ it "to #new" do
+ expect(get("/gitlab/gitlabhq/merge_requests/new")).to route_to("projects/merge_requests/creations#new", namespace_id: "gitlab", project_id: "gitlabhq")
+ expect(get("/gitlab/gitlabhq/merge_requests/new/diffs")).to route_to("projects/merge_requests/creations#new", namespace_id: "gitlab", project_id: "gitlabhq", tab: "diffs")
+ expect(get("/gitlab/gitlabhq/merge_requests/new/pipelines")).to route_to("projects/merge_requests/creations#new", namespace_id: "gitlab", project_id: "gitlabhq", tab: "pipelines")
end
- it 'to #create' do
- expect(post('/gitlab/gitlabhq/merge_requests')).to route_to('projects/merge_requests/creations#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #create" do
+ expect(post("/gitlab/gitlabhq/merge_requests")).to route_to("projects/merge_requests/creations#create", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #branch_from' do
- expect(get('/gitlab/gitlabhq/merge_requests/new/branch_from')).to route_to('projects/merge_requests/creations#branch_from', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #branch_from" do
+ expect(get("/gitlab/gitlabhq/merge_requests/new/branch_from")).to route_to("projects/merge_requests/creations#branch_from", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #branch_to' do
- expect(get('/gitlab/gitlabhq/merge_requests/new/branch_to')).to route_to('projects/merge_requests/creations#branch_to', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #branch_to" do
+ expect(get("/gitlab/gitlabhq/merge_requests/new/branch_to")).to route_to("projects/merge_requests/creations#branch_to", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #pipelines' do
- expect(get('/gitlab/gitlabhq/merge_requests/new/pipelines.json')).to route_to('projects/merge_requests/creations#pipelines', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'json')
+ it "to #pipelines" do
+ expect(get("/gitlab/gitlabhq/merge_requests/new/pipelines.json")).to route_to("projects/merge_requests/creations#pipelines", namespace_id: "gitlab", project_id: "gitlabhq", format: "json")
end
- it 'to #diffs' do
- expect(get('/gitlab/gitlabhq/merge_requests/new/diffs.json')).to route_to('projects/merge_requests/creations#diffs', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'json')
+ it "to #diffs" do
+ expect(get("/gitlab/gitlabhq/merge_requests/new/diffs.json")).to route_to("projects/merge_requests/creations#diffs", namespace_id: "gitlab", project_id: "gitlabhq", format: "json")
end
end
- describe Projects::MergeRequests::DiffsController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/merge_requests/1/diffs.json')).to route_to('projects/merge_requests/diffs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1', format: 'json')
+ describe Projects::MergeRequests::DiffsController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/merge_requests/1/diffs.json")).to route_to("projects/merge_requests/diffs#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1", format: "json")
end
end
- describe Projects::MergeRequests::ConflictsController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/merge_requests/1/conflicts')).to route_to('projects/merge_requests/conflicts#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ describe Projects::MergeRequests::ConflictsController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/merge_requests/1/conflicts")).to route_to("projects/merge_requests/conflicts#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
end
# raw_project_snippet GET /:project_id/snippets/:id/raw(.:format) snippets#raw
@@ -348,37 +348,37 @@ describe 'project routing' do
# project_snippet GET /:project_id/snippets/:id(.:format) snippets#show
# PUT /:project_id/snippets/:id(.:format) snippets#update
# DELETE /:project_id/snippets/:id(.:format) snippets#destroy
- describe SnippetsController, 'routing' do
- it 'to #raw' do
- expect(get('/gitlab/gitlabhq/snippets/1/raw')).to route_to('projects/snippets#raw', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ describe SnippetsController, "routing" do
+ it "to #raw" do
+ expect(get("/gitlab/gitlabhq/snippets/1/raw")).to route_to("projects/snippets#raw", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it 'to #index' do
- expect(get('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #index" do
+ expect(get("/gitlab/gitlabhq/snippets")).to route_to("projects/snippets#index", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #create' do
- expect(post('/gitlab/gitlabhq/snippets')).to route_to('projects/snippets#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #create" do
+ expect(post("/gitlab/gitlabhq/snippets")).to route_to("projects/snippets#create", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #new' do
- expect(get('/gitlab/gitlabhq/snippets/new')).to route_to('projects/snippets#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #new" do
+ expect(get("/gitlab/gitlabhq/snippets/new")).to route_to("projects/snippets#new", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #edit' do
- expect(get('/gitlab/gitlabhq/snippets/1/edit')).to route_to('projects/snippets#edit', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it "to #edit" do
+ expect(get("/gitlab/gitlabhq/snippets/1/edit")).to route_to("projects/snippets#edit", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/snippets/1")).to route_to("projects/snippets#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it 'to #update' do
- expect(put('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#update', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it "to #update" do
+ expect(put("/gitlab/gitlabhq/snippets/1")).to route_to("projects/snippets#update", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it 'to #destroy' do
- expect(delete('/gitlab/gitlabhq/snippets/1')).to route_to('projects/snippets#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ it "to #destroy" do
+ expect(delete("/gitlab/gitlabhq/snippets/1")).to route_to("projects/snippets#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
end
@@ -388,36 +388,36 @@ describe 'project routing' do
# edit_project_hook GET /:project_id/hooks/:id/edit(.:format) hooks#edit
# project_hook PUT /:project_id/hooks/:id(.:format) hooks#update
# DELETE /:project_id/hooks/:id(.:format) hooks#destroy
- describe Projects::HooksController, 'routing' do
- it 'to #test' do
- expect(post('/gitlab/gitlabhq/hooks/1/test')).to route_to('projects/hooks#test', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '1')
+ describe Projects::HooksController, "routing" do
+ it "to #test" do
+ expect(post("/gitlab/gitlabhq/hooks/1/test")).to route_to("projects/hooks#test", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
- it_behaves_like 'RESTful project resources' do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:index, :create, :destroy, :edit, :update] }
- let(:controller) { 'hooks' }
+ let(:controller) { "hooks" }
end
end
# retry_namespace_project_hook_hook_log POST /:project_id/hooks/:hook_id/hook_logs/:id/retry(.:format) projects/hook_logs#retry
# namespace_project_hook_hook_log GET /:project_id/hooks/:hook_id/hook_logs/:id(.:format) projects/hook_logs#show
- describe Projects::HookLogsController, 'routing' do
- it 'to #retry' do
- expect(post('/gitlab/gitlabhq/hooks/1/hook_logs/1/retry')).to route_to('projects/hook_logs#retry', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
+ describe Projects::HookLogsController, "routing" do
+ it "to #retry" do
+ expect(post("/gitlab/gitlabhq/hooks/1/hook_logs/1/retry")).to route_to("projects/hook_logs#retry", namespace_id: "gitlab", project_id: "gitlabhq", hook_id: "1", id: "1")
end
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/hooks/1/hook_logs/1')).to route_to('projects/hook_logs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', hook_id: '1', id: '1')
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/hooks/1/hook_logs/1")).to route_to("projects/hook_logs#show", namespace_id: "gitlab", project_id: "gitlabhq", hook_id: "1", id: "1")
end
end
# project_commit GET /:project_id/commit/:id(.:format) commit#show {id: /\h{7,40}/, project_id: /[^\/]+/}
- describe Projects::CommitController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/commit/4246fbd')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd')
- expect(get('/gitlab/gitlabhq/commit/4246fbd.diff')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'diff')
- expect(get('/gitlab/gitlabhq/commit/4246fbd.patch')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd', format: 'patch')
- expect(get('/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5')).to route_to('projects/commit#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: '4246fbd13872934f72a8fd0d6fb1317b47b59cb5')
+ describe Projects::CommitController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/commit/4246fbd")).to route_to("projects/commit#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "4246fbd")
+ expect(get("/gitlab/gitlabhq/commit/4246fbd.diff")).to route_to("projects/commit#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "4246fbd", format: "diff")
+ expect(get("/gitlab/gitlabhq/commit/4246fbd.patch")).to route_to("projects/commit#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "4246fbd", format: "patch")
+ expect(get("/gitlab/gitlabhq/commit/4246fbd13872934f72a8fd0d6fb1317b47b59cb5")).to route_to("projects/commit#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "4246fbd13872934f72a8fd0d6fb1317b47b59cb5")
end
end
@@ -425,14 +425,14 @@ describe 'project routing' do
# project_commits GET /:project_id/commits(.:format) commits#index
# POST /:project_id/commits(.:format) commits#create
# project_commit GET /:project_id/commits/:id(.:format) commits#show
- describe Projects::CommitsController, 'routing' do
- it_behaves_like 'RESTful project resources' do
+ describe Projects::CommitsController, "routing" do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:show] }
- let(:controller) { 'commits' }
+ let(:controller) { "commits" }
end
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/commits/master.atom')).to route_to('projects/commits#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.atom')
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/commits/master.atom")).to route_to("projects/commits#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master.atom")
end
end
@@ -440,10 +440,10 @@ describe 'project routing' do
# POST /:project_id/project_members(.:format) project_members#create
# PUT /:project_id/project_members/:id(.:format) project_members#update
# DELETE /:project_id/project_members/:id(.:format) project_members#destroy
- describe Projects::ProjectMembersController, 'routing' do
- it_behaves_like 'RESTful project resources' do
+ describe Projects::ProjectMembersController, "routing" do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:index, :create, :update, :destroy] }
- let(:controller) { 'project_members' }
+ let(:controller) { "project_members" }
end
end
@@ -455,21 +455,21 @@ describe 'project routing' do
# PUT /:project_id/milestones/:id(.:format) milestones#update
# DELETE /:project_id/milestones/:id(.:format) milestones#destroy
# promote_project_milestone POST /:project_id/milestones/:id/promote milestones#promote
- describe Projects::MilestonesController, 'routing' do
- it_behaves_like 'RESTful project resources' do
- let(:controller) { 'milestones' }
+ describe Projects::MilestonesController, "routing" do
+ it_behaves_like "RESTful project resources" do
+ let(:controller) { "milestones" }
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
end
- it 'to #promote' do
- expect(post('/gitlab/gitlabhq/milestones/1/promote')).to route_to('projects/milestones#promote', namespace_id: 'gitlab', project_id: 'gitlabhq', id: "1")
+ it "to #promote" do
+ expect(post("/gitlab/gitlabhq/milestones/1/promote")).to route_to("projects/milestones#promote", namespace_id: "gitlab", project_id: "gitlabhq", id: "1")
end
end
# project_labels GET /:project_id/labels(.:format) labels#index
- describe Projects::LabelsController, 'routing' do
- it 'to #index' do
- expect(get('/gitlab/gitlabhq/labels')).to route_to('projects/labels#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::LabelsController, "routing" do
+ it "to #index" do
+ expect(get("/gitlab/gitlabhq/labels")).to route_to("projects/labels#index", namespace_id: "gitlab", project_id: "gitlabhq")
end
end
@@ -483,13 +483,13 @@ describe 'project routing' do
# project_issue GET /:project_id/issues/:id(.:format) issues#show
# PUT /:project_id/issues/:id(.:format) issues#update
# DELETE /:project_id/issues/:id(.:format) issues#destroy
- describe Projects::IssuesController, 'routing' do
- it 'to #bulk_update' do
- expect(post('/gitlab/gitlabhq/issues/bulk_update')).to route_to('projects/issues#bulk_update', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::IssuesController, "routing" do
+ it "to #bulk_update" do
+ expect(post("/gitlab/gitlabhq/issues/bulk_update")).to route_to("projects/issues#bulk_update", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it_behaves_like 'RESTful project resources' do
- let(:controller) { 'issues' }
+ it_behaves_like "RESTful project resources" do
+ let(:controller) { "issues" }
let(:actions) { [:index, :create, :new, :edit, :show, :update] }
end
end
@@ -497,167 +497,170 @@ describe 'project routing' do
# project_noteable_notes GET /:project_id/noteable/:target_type/:target_id/notes notes#index
# POST /:project_id/notes(.:format) notes#create
# project_note DELETE /:project_id/notes/:id(.:format) notes#destroy
- describe Projects::NotesController, 'routing' do
- it 'to #index' do
- expect(get('/gitlab/gitlabhq/noteable/issue/1/notes')).to route_to(
- 'projects/notes#index',
- namespace_id: 'gitlab',
- project_id: 'gitlabhq',
- target_type: 'issue',
- target_id: '1'
+ describe Projects::NotesController, "routing" do
+ it "to #index" do
+ expect(get("/gitlab/gitlabhq/noteable/issue/1/notes")).to route_to(
+ "projects/notes#index",
+ namespace_id: "gitlab",
+ project_id: "gitlabhq",
+ target_type: "issue",
+ target_id: "1"
)
end
- it_behaves_like 'RESTful project resources' do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:create, :destroy] }
- let(:controller) { 'notes' }
+ let(:controller) { "notes" }
end
end
# project_blame GET /:project_id/blame/:id(.:format) blame#show {id: /.+/, project_id: /[^\/]+/}
- describe Projects::BlameController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/blame/master/app/models/project.rb')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
- expect(get('/gitlab/gitlabhq/blame/master/files.scss')).to route_to('projects/blame#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
+ describe Projects::BlameController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/blame/master/app/models/project.rb")).to route_to("projects/blame#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/app/models/project.rb")
+ expect(get("/gitlab/gitlabhq/blame/master/files.scss")).to route_to("projects/blame#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/files.scss")
end
end
# project_blob GET /:project_id/blob/:id(.:format) blob#show {id: /.+/, project_id: /[^\/]+/}
- describe Projects::BlobController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/blob/master/app/models/project.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
- expect(get('/gitlab/gitlabhq/blob/master/app/models/compare.rb')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/compare.rb')
- expect(get('/gitlab/gitlabhq/blob/master/app/models/diff.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/diff.js')
- expect(get('/gitlab/gitlabhq/blob/master/files.scss')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
- expect(get('/gitlab/gitlabhq/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/blob/index.js')
- expect(get('/gitlab/gitlabhq/blob/blob/master/blob/index.js')).to route_to('projects/blob#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'blob/master/blob/index.js')
+ describe Projects::BlobController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/blob/master/app/models/project.rb")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/app/models/project.rb")
+ expect(get("/gitlab/gitlabhq/blob/master/app/models/compare.rb")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/app/models/compare.rb")
+ expect(get("/gitlab/gitlabhq/blob/master/app/models/diff.js")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/app/models/diff.js")
+ expect(get("/gitlab/gitlabhq/blob/master/files.scss")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/files.scss")
+ expect(get("/gitlab/gitlabhq/blob/master/blob/index.js")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/blob/index.js")
+ expect(get("/gitlab/gitlabhq/blob/blob/master/blob/index.js")).to route_to("projects/blob#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "blob/master/blob/index.js")
end
end
# project_tree GET /:project_id/tree/:id(.:format) tree#show {id: /.+/, project_id: /[^\/]+/}
- describe Projects::TreeController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/tree/master/app/models/project.rb')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/app/models/project.rb')
- expect(get('/gitlab/gitlabhq/tree/master/files.scss')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/files.scss')
- expect(get('/gitlab/gitlabhq/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master/tree/files')
- expect(get('/gitlab/gitlabhq/tree/tree/master/tree/files')).to route_to('projects/tree#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'tree/master/tree/files')
+ describe Projects::TreeController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/tree/master/app/models/project.rb")).to route_to("projects/tree#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/app/models/project.rb")
+ expect(get("/gitlab/gitlabhq/tree/master/files.scss")).to route_to("projects/tree#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/files.scss")
+ expect(get("/gitlab/gitlabhq/tree/master/tree/files")).to route_to("projects/tree#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master/tree/files")
+ expect(get("/gitlab/gitlabhq/tree/tree/master/tree/files")).to route_to("projects/tree#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "tree/master/tree/files")
end
end
# project_find_file GET /:namespace_id/:project_id/find_file/*id(.:format) projects/find_file#show {:id=>/.+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/html/}
# project_files GET /:namespace_id/:project_id/files/*id(.:format) projects/find_file#list {:id=>/(?:[^.]|\.(?!json$))+/, :namespace_id=>/[a-zA-Z.0-9_\-]+/, :project_id=>/[a-zA-Z.0-9_\-]+(?<!\.atom)/, :format=>/json/}
- describe Projects::FindFileController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/find_file/master')).to route_to('projects/find_file#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
+ describe Projects::FindFileController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/find_file/master")).to route_to("projects/find_file#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master")
end
- it 'to #list' do
- expect(get('/gitlab/gitlabhq/files/master.json')).to route_to('projects/find_file#list', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master.json')
+ it "to #list" do
+ expect(get("/gitlab/gitlabhq/files/master.json")).to route_to("projects/find_file#list", namespace_id: "gitlab", project_id: "gitlabhq", id: "master.json")
end
end
- describe Projects::BlobController, 'routing' do
- it 'to #edit' do
- expect(get('/gitlab/gitlabhq/edit/master/app/models/project.rb')).to(
- route_to('projects/blob#edit',
- namespace_id: 'gitlab', project_id: 'gitlabhq',
- id: 'master/app/models/project.rb'))
+ describe Projects::BlobController, "routing" do
+ it "to #edit" do
+ expect(get("/gitlab/gitlabhq/edit/master/app/models/project.rb")).to(
+ route_to("projects/blob#edit",
+ namespace_id: "gitlab", project_id: "gitlabhq",
+ id: "master/app/models/project.rb")
+ )
end
- it 'to #preview' do
- expect(post('/gitlab/gitlabhq/preview/master/app/models/project.rb')).to(
- route_to('projects/blob#preview',
- namespace_id: 'gitlab', project_id: 'gitlabhq',
- id: 'master/app/models/project.rb'))
+ it "to #preview" do
+ expect(post("/gitlab/gitlabhq/preview/master/app/models/project.rb")).to(
+ route_to("projects/blob#preview",
+ namespace_id: "gitlab", project_id: "gitlabhq",
+ id: "master/app/models/project.rb")
+ )
end
end
# project_compare_index GET /:project_id/compare(.:format) compare#index {id: /[^\/]+/, project_id: /[^\/]+/}
# POST /:project_id/compare(.:format) compare#create {id: /[^\/]+/, project_id: /[^\/]+/}
# project_compare /:project_id/compare/:from...:to(.:format) compare#show {from: /.+/, to: /.+/, id: /[^\/]+/, project_id: /[^\/]+/}
- describe Projects::CompareController, 'routing' do
- it 'to #index' do
- expect(get('/gitlab/gitlabhq/compare')).to route_to('projects/compare#index', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::CompareController, "routing" do
+ it "to #index" do
+ expect(get("/gitlab/gitlabhq/compare")).to route_to("projects/compare#index", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #compare' do
- expect(post('/gitlab/gitlabhq/compare')).to route_to('projects/compare#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #compare" do
+ expect(post("/gitlab/gitlabhq/compare")).to route_to("projects/compare#create", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/compare/master...stable')).to route_to('projects/compare#show', namespace_id: 'gitlab', project_id: 'gitlabhq', from: 'master', to: 'stable')
- expect(get('/gitlab/gitlabhq/compare/issue/1234...stable')).to route_to('projects/compare#show', namespace_id: 'gitlab', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable')
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/compare/master...stable")).to route_to("projects/compare#show", namespace_id: "gitlab", project_id: "gitlabhq", from: "master", to: "stable")
+ expect(get("/gitlab/gitlabhq/compare/issue/1234...stable")).to route_to("projects/compare#show", namespace_id: "gitlab", project_id: "gitlabhq", from: "issue/1234", to: "stable")
end
end
- describe Projects::NetworkController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/network/master')).to route_to('projects/network#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
- expect(get('/gitlab/gitlabhq/network/ends-with.json')).to route_to('projects/network#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'ends-with.json')
- expect(get('/gitlab/gitlabhq/network/master?format=json')).to route_to('projects/network#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', format: 'json')
+ describe Projects::NetworkController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/network/master")).to route_to("projects/network#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master")
+ expect(get("/gitlab/gitlabhq/network/ends-with.json")).to route_to("projects/network#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "ends-with.json")
+ expect(get("/gitlab/gitlabhq/network/master?format=json")).to route_to("projects/network#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master", format: "json")
end
end
- describe Projects::GraphsController, 'routing' do
- it 'to #show' do
- expect(get('/gitlab/gitlabhq/graphs/master')).to route_to('projects/graphs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master')
- expect(get('/gitlab/gitlabhq/graphs/ends-with.json')).to route_to('projects/graphs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'ends-with.json')
- expect(get('/gitlab/gitlabhq/graphs/master?format=json')).to route_to('projects/graphs#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', format: 'json')
+ describe Projects::GraphsController, "routing" do
+ it "to #show" do
+ expect(get("/gitlab/gitlabhq/graphs/master")).to route_to("projects/graphs#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master")
+ expect(get("/gitlab/gitlabhq/graphs/ends-with.json")).to route_to("projects/graphs#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "ends-with.json")
+ expect(get("/gitlab/gitlabhq/graphs/master?format=json")).to route_to("projects/graphs#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "master", format: "json")
end
end
- describe Projects::ForksController, 'routing' do
- it 'to #new' do
- expect(get('/gitlab/gitlabhq/forks/new')).to route_to('projects/forks#new', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::ForksController, "routing" do
+ it "to #new" do
+ expect(get("/gitlab/gitlabhq/forks/new")).to route_to("projects/forks#new", namespace_id: "gitlab", project_id: "gitlabhq")
end
- it 'to #create' do
- expect(post('/gitlab/gitlabhq/forks')).to route_to('projects/forks#create', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ it "to #create" do
+ expect(post("/gitlab/gitlabhq/forks")).to route_to("projects/forks#create", namespace_id: "gitlab", project_id: "gitlabhq")
end
end
# project_avatar DELETE /project/avatar(.:format) projects/avatars#destroy
- describe Projects::AvatarsController, 'routing' do
- it 'to #destroy' do
- expect(delete('/gitlab/gitlabhq/avatar')).to route_to(
- 'projects/avatars#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq')
+ describe Projects::AvatarsController, "routing" do
+ it "to #destroy" do
+ expect(delete("/gitlab/gitlabhq/avatar")).to route_to(
+ "projects/avatars#destroy", namespace_id: "gitlab", project_id: "gitlabhq"
+ )
end
end
- describe Projects::PagesDomainsController, 'routing' do
- it_behaves_like 'RESTful project resources' do
+ describe Projects::PagesDomainsController, "routing" do
+ it_behaves_like "RESTful project resources" do
let(:actions) { [:show, :new, :create, :destroy] }
- let(:controller) { 'pages_domains' }
- let(:controller_path) { 'pages/domains' }
+ let(:controller) { "pages_domains" }
+ let(:controller_path) { "pages/domains" }
end
- it 'to #destroy with a valid domain name' do
- expect(delete('/gitlab/gitlabhq/pages/domains/my.domain.com')).to route_to('projects/pages_domains#destroy', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'my.domain.com')
+ it "to #destroy with a valid domain name" do
+ expect(delete("/gitlab/gitlabhq/pages/domains/my.domain.com")).to route_to("projects/pages_domains#destroy", namespace_id: "gitlab", project_id: "gitlabhq", id: "my.domain.com")
end
- it 'to #show with a valid domain' do
- expect(get('/gitlab/gitlabhq/pages/domains/my.domain.com')).to route_to('projects/pages_domains#show', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'my.domain.com')
+ it "to #show with a valid domain" do
+ expect(get("/gitlab/gitlabhq/pages/domains/my.domain.com")).to route_to("projects/pages_domains#show", namespace_id: "gitlab", project_id: "gitlabhq", id: "my.domain.com")
end
end
- describe Projects::Registry::TagsController, 'routing' do
- describe '#destroy' do
- it 'correctly routes to a destroy action' do
- expect(delete('/gitlab/gitlabhq/registry/repository/1/tags/rc1'))
- .to route_to('projects/registry/tags#destroy',
- namespace_id: 'gitlab',
- project_id: 'gitlabhq',
- repository_id: '1',
- id: 'rc1')
+ describe Projects::Registry::TagsController, "routing" do
+ describe "#destroy" do
+ it "correctly routes to a destroy action" do
+ expect(delete("/gitlab/gitlabhq/registry/repository/1/tags/rc1"))
+ .to route_to("projects/registry/tags#destroy",
+ namespace_id: "gitlab",
+ project_id: "gitlabhq",
+ repository_id: "1",
+ id: "rc1")
end
- it 'takes registry tag name constrains into account' do
- expect(delete('/gitlab/gitlabhq/registry/repository/1/tags/-rc1'))
- .not_to route_to('projects/registry/tags#destroy',
- namespace_id: 'gitlab',
- project_id: 'gitlabhq',
- repository_id: '1',
- id: '-rc1')
+ it "takes registry tag name constrains into account" do
+ expect(delete("/gitlab/gitlabhq/registry/repository/1/tags/-rc1"))
+ .not_to route_to("projects/registry/tags#destroy",
+ namespace_id: "gitlab",
+ project_id: "gitlabhq",
+ repository_id: "1",
+ id: "-rc1")
end
end
end
diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb
index a170bb14144..2e427eac600 100644
--- a/spec/routing/routing_spec.rb
+++ b/spec/routing/routing_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
# user GET /u/:username/
# user_groups GET /u/:username/groups(.:format)
@@ -11,46 +11,46 @@ describe UsersController, "routing" do
it "to #show" do
allow_any_instance_of(::Constraints::UserUrlConstrainer).to receive(:matches?).and_return(true)
- expect(get("/User")).to route_to('users#show', username: 'User')
+ expect(get("/User")).to route_to("users#show", username: "User")
end
it "to #groups" do
- expect(get("/users/User/groups")).to route_to('users#groups', username: 'User')
+ expect(get("/users/User/groups")).to route_to("users#groups", username: "User")
end
it "to #projects" do
- expect(get("/users/User/projects")).to route_to('users#projects', username: 'User')
+ expect(get("/users/User/projects")).to route_to("users#projects", username: "User")
end
it "to #contributed" do
- expect(get("/users/User/contributed")).to route_to('users#contributed', username: 'User')
+ expect(get("/users/User/contributed")).to route_to("users#contributed", username: "User")
end
it "to #snippets" do
- expect(get("/users/User/snippets")).to route_to('users#snippets', username: 'User')
+ expect(get("/users/User/snippets")).to route_to("users#snippets", username: "User")
end
it "to #calendar" do
- expect(get("/users/User/calendar")).to route_to('users#calendar', username: 'User')
+ expect(get("/users/User/calendar")).to route_to("users#calendar", username: "User")
end
it "to #calendar_activities" do
- expect(get("/users/User/calendar_activities")).to route_to('users#calendar_activities', username: 'User')
+ expect(get("/users/User/calendar_activities")).to route_to("users#calendar_activities", username: "User")
end
- describe 'redirect alias routes' do
+ describe "redirect alias routes" do
include RSpec::Rails::RequestExampleGroup
- it '/u/user1 redirects to /user1' do
- expect(get("/u/user1")).to redirect_to('/user1')
+ it "/u/user1 redirects to /user1" do
+ expect(get("/u/user1")).to redirect_to("/user1")
end
- it '/u/user1/groups redirects to /user1/groups' do
- expect(get("/u/user1/groups")).to redirect_to('/users/user1/groups')
+ it "/u/user1/groups redirects to /user1/groups" do
+ expect(get("/u/user1/groups")).to redirect_to("/users/user1/groups")
end
- it '/u/user1/projects redirects to /user1/projects' do
- expect(get("/u/user1/projects")).to redirect_to('/users/user1/projects')
+ it "/u/user1/projects redirects to /user1/projects" do
+ expect(get("/u/user1/projects")).to redirect_to("/users/user1/projects")
end
end
end
@@ -58,7 +58,7 @@ end
# search GET /search(.:format) search#show
describe SearchController, "routing" do
it "to #show" do
- expect(get("/search")).to route_to('search#show')
+ expect(get("/search")).to route_to("search#show")
end
end
@@ -83,35 +83,35 @@ end
# DELETE /snippets/:id(.:format) snippets#destroy
describe SnippetsController, "routing" do
it "to #raw" do
- expect(get("/snippets/1/raw")).to route_to('snippets#raw', id: '1')
+ expect(get("/snippets/1/raw")).to route_to("snippets#raw", id: "1")
end
it "to #index" do
- expect(get("/snippets")).to route_to('snippets#index')
+ expect(get("/snippets")).to route_to("snippets#index")
end
it "to #create" do
- expect(post("/snippets")).to route_to('snippets#create')
+ expect(post("/snippets")).to route_to("snippets#create")
end
it "to #new" do
- expect(get("/snippets/new")).to route_to('snippets#new')
+ expect(get("/snippets/new")).to route_to("snippets#new")
end
it "to #edit" do
- expect(get("/snippets/1/edit")).to route_to('snippets#edit', id: '1')
+ expect(get("/snippets/1/edit")).to route_to("snippets#edit", id: "1")
end
it "to #show" do
- expect(get("/snippets/1")).to route_to('snippets#show', id: '1')
+ expect(get("/snippets/1")).to route_to("snippets#show", id: "1")
end
it "to #update" do
- expect(put("/snippets/1")).to route_to('snippets#update', id: '1')
+ expect(put("/snippets/1")).to route_to("snippets#update", id: "1")
end
it "to #destroy" do
- expect(delete("/snippets/1")).to route_to('snippets#destroy', id: '1')
+ expect(delete("/snippets/1")).to route_to("snippets#destroy", id: "1")
end
end
@@ -121,22 +121,22 @@ end
# help_ui GET /help/ui(.:format) help#ui
describe HelpController, "routing" do
it "to #index" do
- expect(get("/help")).to route_to('help#index')
+ expect(get("/help")).to route_to("help#index")
end
- it 'to #show' do
- path = '/help/user/markdown.md'
- expect(get(path)).to route_to('help#show',
- path: 'user/markdown',
- format: 'md')
+ it "to #show" do
+ path = "/help/user/markdown.md"
+ expect(get(path)).to route_to("help#show",
+ path: "user/markdown",
+ format: "md")
- path = '/help/workflow/protected_branches/protected_branches1.png'
- expect(get(path)).to route_to('help#show',
- path: 'workflow/protected_branches/protected_branches1',
- format: 'png')
+ path = "/help/workflow/protected_branches/protected_branches1.png"
+ expect(get(path)).to route_to("help#show",
+ path: "workflow/protected_branches/protected_branches1",
+ format: "png")
- path = '/help/ui'
- expect(get(path)).to route_to('help#ui')
+ path = "/help/ui"
+ expect(get(path)).to route_to("help#ui")
end
end
@@ -148,33 +148,33 @@ end
# profile_update PUT /profile/update(.:format) profile#update
describe ProfilesController, "routing" do
it "to #account" do
- expect(get("/profile/account")).to route_to('profiles/accounts#show')
+ expect(get("/profile/account")).to route_to("profiles/accounts#show")
end
it "to #audit_log" do
- expect(get("/profile/audit_log")).to route_to('profiles#audit_log')
+ expect(get("/profile/audit_log")).to route_to("profiles#audit_log")
end
it "to #reset_feed_token" do
- expect(put("/profile/reset_feed_token")).to route_to('profiles#reset_feed_token')
+ expect(put("/profile/reset_feed_token")).to route_to("profiles#reset_feed_token")
end
it "to #show" do
- expect(get("/profile")).to route_to('profiles#show')
+ expect(get("/profile")).to route_to("profiles#show")
end
end
# profile_preferences GET /profile/preferences(.:format) profiles/preferences#show
# PATCH /profile/preferences(.:format) profiles/preferences#update
# PUT /profile/preferences(.:format) profiles/preferences#update
-describe Profiles::PreferencesController, 'routing' do
- it 'to #show' do
- expect(get('/profile/preferences')).to route_to('profiles/preferences#show')
+describe Profiles::PreferencesController, "routing" do
+ it "to #show" do
+ expect(get("/profile/preferences")).to route_to("profiles/preferences#show")
end
- it 'to #update' do
- expect(put('/profile/preferences')).to route_to('profiles/preferences#update')
- expect(patch('/profile/preferences')).to route_to('profiles/preferences#update')
+ it "to #update" do
+ expect(put("/profile/preferences")).to route_to("profiles/preferences#update")
+ expect(patch("/profile/preferences")).to route_to("profiles/preferences#update")
end
end
@@ -186,26 +186,26 @@ end
# DELETE /keys/:id(.:format) keys#destroy
describe Profiles::KeysController, "routing" do
it "to #index" do
- expect(get("/profile/keys")).to route_to('profiles/keys#index')
+ expect(get("/profile/keys")).to route_to("profiles/keys#index")
end
it "to #create" do
- expect(post("/profile/keys")).to route_to('profiles/keys#create')
+ expect(post("/profile/keys")).to route_to("profiles/keys#create")
end
it "to #show" do
- expect(get("/profile/keys/1")).to route_to('profiles/keys#show', id: '1')
+ expect(get("/profile/keys/1")).to route_to("profiles/keys#show", id: "1")
end
it "to #destroy" do
- expect(delete("/profile/keys/1")).to route_to('profiles/keys#destroy', id: '1')
+ expect(delete("/profile/keys/1")).to route_to("profiles/keys#destroy", id: "1")
end
# get all the ssh-keys of a user
it "to #get_keys" do
allow_any_instance_of(::Constraints::UserUrlConstrainer).to receive(:matches?).and_return(true)
- expect(get("/foo.keys")).to route_to('profiles/keys#get_keys', username: 'foo')
+ expect(get("/foo.keys")).to route_to("profiles/keys#get_keys", username: "foo")
end
end
@@ -214,22 +214,22 @@ end
# DELETE /keys/:id(.:format) keys#destroy
describe Profiles::EmailsController, "routing" do
it "to #index" do
- expect(get("/profile/emails")).to route_to('profiles/emails#index')
+ expect(get("/profile/emails")).to route_to("profiles/emails#index")
end
it "to #create" do
- expect(post("/profile/emails")).to route_to('profiles/emails#create')
+ expect(post("/profile/emails")).to route_to("profiles/emails#create")
end
it "to #destroy" do
- expect(delete("/profile/emails/1")).to route_to('profiles/emails#destroy', id: '1')
+ expect(delete("/profile/emails/1")).to route_to("profiles/emails#destroy", id: "1")
end
end
# profile_avatar DELETE /profile/avatar(.:format) profiles/avatars#destroy
describe Profiles::AvatarsController, "routing" do
it "to #destroy" do
- expect(delete("/profile/avatar")).to route_to('profiles/avatars#destroy')
+ expect(delete("/profile/avatar")).to route_to("profiles/avatars#destroy")
end
end
@@ -238,67 +238,67 @@ end
# dashboard_merge_requests GET /dashboard/merge_requests(.:format) dashboard#merge_requests
describe DashboardController, "routing" do
it "to #index" do
- expect(get("/dashboard")).to route_to('dashboard/projects#index')
+ expect(get("/dashboard")).to route_to("dashboard/projects#index")
end
it "to #issues" do
- expect(get("/dashboard/issues.html")).to route_to('dashboard#issues', format: 'html')
+ expect(get("/dashboard/issues.html")).to route_to("dashboard#issues", format: "html")
end
it "to #calendar_issues" do
- expect(get("/dashboard/issues.ics")).to route_to('dashboard#issues_calendar', format: 'ics')
+ expect(get("/dashboard/issues.ics")).to route_to("dashboard#issues_calendar", format: "ics")
end
it "to #merge_requests" do
- expect(get("/dashboard/merge_requests")).to route_to('dashboard#merge_requests')
+ expect(get("/dashboard/merge_requests")).to route_to("dashboard#merge_requests")
end
end
# root / root#show
-describe RootController, 'routing' do
- it 'to #index' do
- expect(get('/')).to route_to('root#index')
+describe RootController, "routing" do
+ it "to #index" do
+ expect(get("/")).to route_to("root#index")
end
end
describe "Authentication", "routing" do
it "GET /users/sign_in" do
- expect(get("/users/sign_in")).to route_to('sessions#new')
+ expect(get("/users/sign_in")).to route_to("sessions#new")
end
it "POST /users/sign_in" do
- expect(post("/users/sign_in")).to route_to('sessions#create')
+ expect(post("/users/sign_in")).to route_to("sessions#create")
end
# sign_out with GET instead of DELETE facilitates ad-hoc single-sign-out processes
# (https://gitlab.com/gitlab-org/gitlab-ce/issues/39708)
it "GET /users/sign_out" do
- expect(get("/users/sign_out")).to route_to('sessions#destroy')
+ expect(get("/users/sign_out")).to route_to("sessions#destroy")
end
it "POST /users/password" do
- expect(post("/users/password")).to route_to('passwords#create')
+ expect(post("/users/password")).to route_to("passwords#create")
end
it "GET /users/password/new" do
- expect(get("/users/password/new")).to route_to('passwords#new')
+ expect(get("/users/password/new")).to route_to("passwords#new")
end
it "GET /users/password/edit" do
- expect(get("/users/password/edit")).to route_to('passwords#edit')
+ expect(get("/users/password/edit")).to route_to("passwords#edit")
end
it "PUT /users/password" do
- expect(put("/users/password")).to route_to('passwords#update')
+ expect(put("/users/password")).to route_to("passwords#update")
end
end
-describe HealthCheckController, 'routing' do
- it 'to #index' do
- expect(get('/health_check')).to route_to('health_check#index')
+describe HealthCheckController, "routing" do
+ it "to #index" do
+ expect(get("/health_check")).to route_to("health_check#index")
end
- it 'also supports passing checks in the url' do
- expect(get('/health_check/email')).to route_to('health_check#index', checks: 'email')
+ it "also supports passing checks in the url" do
+ expect(get("/health_check/email")).to route_to("health_check#index", checks: "email")
end
end
diff --git a/spec/rubocop/code_reuse_helpers_spec.rb b/spec/rubocop/code_reuse_helpers_spec.rb
index 2720141aad2..122c9935e57 100644
--- a/spec/rubocop/code_reuse_helpers_spec.rb
+++ b/spec/rubocop/code_reuse_helpers_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'parser/current'
-require_relative '../../rubocop/code_reuse_helpers'
+require "spec_helper"
+require "rubocop"
+require "parser/current"
+require_relative "../../rubocop/code_reuse_helpers"
describe RuboCop::CodeReuseHelpers do
- def parse_source(source, path = 'foo.rb')
+ def parse_source(source, path = "foo.rb")
buffer = Parser::Source::Buffer.new(path)
buffer.source = source
@@ -17,186 +17,186 @@ describe RuboCop::CodeReuseHelpers do
end
let(:cop) do
- Class.new do
+ Class.new {
include RuboCop::CodeReuseHelpers
- end.new
+ }.new
end
- describe '#send_to_constant?' do
- it 'returns true when sending to a constant' do
- node = parse_source('Foo.bar')
+ describe "#send_to_constant?" do
+ it "returns true when sending to a constant" do
+ node = parse_source("Foo.bar")
expect(cop.send_to_constant?(node)).to eq(true)
end
- it 'returns false when sending to something other than a constant' do
- node = parse_source('10')
+ it "returns false when sending to something other than a constant" do
+ node = parse_source("10")
expect(cop.send_to_constant?(node)).to eq(false)
end
end
- describe '#send_receiver_name_ends_with?' do
- it 'returns true when the receiver ends with a suffix' do
- node = parse_source('FooFinder.new')
+ describe "#send_receiver_name_ends_with?" do
+ it "returns true when the receiver ends with a suffix" do
+ node = parse_source("FooFinder.new")
- expect(cop.send_receiver_name_ends_with?(node, 'Finder')).to eq(true)
+ expect(cop.send_receiver_name_ends_with?(node, "Finder")).to eq(true)
end
- it 'returns false when the receiver is the same as a suffix' do
- node = parse_source('Finder.new')
+ it "returns false when the receiver is the same as a suffix" do
+ node = parse_source("Finder.new")
- expect(cop.send_receiver_name_ends_with?(node, 'Finder')).to eq(false)
+ expect(cop.send_receiver_name_ends_with?(node, "Finder")).to eq(false)
end
end
- describe '#file_path_for_node' do
- it 'returns the file path of a node' do
- node = parse_source('10')
+ describe "#file_path_for_node" do
+ it "returns the file path of a node" do
+ node = parse_source("10")
path = cop.file_path_for_node(node)
- expect(path).to eq('foo.rb')
+ expect(path).to eq("foo.rb")
end
end
- describe '#name_of_constant' do
- it 'returns the name of a constant' do
- node = parse_source('Foo')
+ describe "#name_of_constant" do
+ it "returns the name of a constant" do
+ node = parse_source("Foo")
expect(cop.name_of_constant(node)).to eq(:Foo)
end
end
- describe '#in_finder?' do
- it 'returns true for a node in the finders directory' do
- node = parse_source('10', Rails.root.join('app', 'finders', 'foo.rb'))
+ describe "#in_finder?" do
+ it "returns true for a node in the finders directory" do
+ node = parse_source("10", Rails.root.join("app", "finders", "foo.rb"))
expect(cop.in_finder?(node)).to eq(true)
end
- it 'returns false for a node outside the finders directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the finders directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_finder?(node)).to eq(false)
end
end
- describe '#in_model?' do
- it 'returns true for a node in the models directory' do
- node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb'))
+ describe "#in_model?" do
+ it "returns true for a node in the models directory" do
+ node = parse_source("10", Rails.root.join("app", "models", "foo.rb"))
expect(cop.in_model?(node)).to eq(true)
end
- it 'returns false for a node outside the models directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the models directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_model?(node)).to eq(false)
end
end
- describe '#in_service_class?' do
- it 'returns true for a node in the services directory' do
- node = parse_source('10', Rails.root.join('app', 'services', 'foo.rb'))
+ describe "#in_service_class?" do
+ it "returns true for a node in the services directory" do
+ node = parse_source("10", Rails.root.join("app", "services", "foo.rb"))
expect(cop.in_service_class?(node)).to eq(true)
end
- it 'returns false for a node outside the services directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the services directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_service_class?(node)).to eq(false)
end
end
- describe '#in_presenter?' do
- it 'returns true for a node in the presenters directory' do
- node = parse_source('10', Rails.root.join('app', 'presenters', 'foo.rb'))
+ describe "#in_presenter?" do
+ it "returns true for a node in the presenters directory" do
+ node = parse_source("10", Rails.root.join("app", "presenters", "foo.rb"))
expect(cop.in_presenter?(node)).to eq(true)
end
- it 'returns false for a node outside the presenters directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the presenters directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_presenter?(node)).to eq(false)
end
end
- describe '#in_serializer?' do
- it 'returns true for a node in the serializers directory' do
- node = parse_source('10', Rails.root.join('app', 'serializers', 'foo.rb'))
+ describe "#in_serializer?" do
+ it "returns true for a node in the serializers directory" do
+ node = parse_source("10", Rails.root.join("app", "serializers", "foo.rb"))
expect(cop.in_serializer?(node)).to eq(true)
end
- it 'returns false for a node outside the serializers directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the serializers directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_serializer?(node)).to eq(false)
end
end
- describe '#in_worker?' do
- it 'returns true for a node in the workers directory' do
- node = parse_source('10', Rails.root.join('app', 'workers', 'foo.rb'))
+ describe "#in_worker?" do
+ it "returns true for a node in the workers directory" do
+ node = parse_source("10", Rails.root.join("app", "workers", "foo.rb"))
expect(cop.in_worker?(node)).to eq(true)
end
- it 'returns false for a node outside the workers directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the workers directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_worker?(node)).to eq(false)
end
end
- describe '#in_api?' do
- it 'returns true for a node in the API directory' do
- node = parse_source('10', Rails.root.join('lib', 'api', 'foo.rb'))
+ describe "#in_api?" do
+ it "returns true for a node in the API directory" do
+ node = parse_source("10", Rails.root.join("lib", "api", "foo.rb"))
expect(cop.in_api?(node)).to eq(true)
end
- it 'returns false for a node outside the API directory' do
- node = parse_source('10', Rails.root.join('lib', 'foo', 'foo.rb'))
+ it "returns false for a node outside the API directory" do
+ node = parse_source("10", Rails.root.join("lib", "foo", "foo.rb"))
expect(cop.in_api?(node)).to eq(false)
end
end
- describe '#in_directory?' do
- it 'returns true for a directory in the CE app/ directory' do
- node = parse_source('10', Rails.root.join('app', 'models', 'foo.rb'))
+ describe "#in_directory?" do
+ it "returns true for a directory in the CE app/ directory" do
+ node = parse_source("10", Rails.root.join("app", "models", "foo.rb"))
- expect(cop.in_directory?(node, 'models')).to eq(true)
+ expect(cop.in_directory?(node, "models")).to eq(true)
end
- it 'returns true for a directory in the EE app/ directory' do
+ it "returns true for a directory in the EE app/ directory" do
node =
- parse_source('10', Rails.root.join('ee', 'app', 'models', 'foo.rb'))
+ parse_source("10", Rails.root.join("ee", "app", "models", "foo.rb"))
- expect(cop.in_directory?(node, 'models')).to eq(true)
+ expect(cop.in_directory?(node, "models")).to eq(true)
end
- it 'returns false for a directory in the lib/ directory' do
+ it "returns false for a directory in the lib/ directory" do
node =
- parse_source('10', Rails.root.join('lib', 'models', 'foo.rb'))
+ parse_source("10", Rails.root.join("lib", "models", "foo.rb"))
- expect(cop.in_directory?(node, 'models')).to eq(false)
+ expect(cop.in_directory?(node, "models")).to eq(false)
end
end
- describe '#name_of_receiver' do
- it 'returns the name of a send receiver' do
- node = parse_source('Foo.bar')
+ describe "#name_of_receiver" do
+ it "returns the name of a send receiver" do
+ node = parse_source("Foo.bar")
- expect(cop.name_of_receiver(node)).to eq('Foo')
+ expect(cop.name_of_receiver(node)).to eq("Foo")
end
end
- describe '#each_class_method' do
- it 'yields every class method to the supplied block' do
+ describe "#each_class_method" do
+ it "yields every class method to the supplied block" do
node = parse_source(<<~RUBY)
class Foo
class << self
@@ -218,8 +218,8 @@ describe RuboCop::CodeReuseHelpers do
end
end
- describe '#each_send_node' do
- it 'yields every send node to the supplied block' do
+ describe "#each_send_node" do
+ it "yields every send node to the supplied block" do
node = parse_source("foo\nbar")
nodes = cop.each_send_node(node).to_a
@@ -229,8 +229,8 @@ describe RuboCop::CodeReuseHelpers do
end
end
- describe '#disallow_send_to' do
- it 'disallows sending a message to a constant' do
+ describe "#disallow_send_to" do
+ it "disallows sending a message to a constant" do
def_node = parse_source(<<~RUBY)
def foo
FooFinder.new
@@ -241,9 +241,9 @@ describe RuboCop::CodeReuseHelpers do
expect(cop)
.to receive(:add_offense)
- .with(send_node, location: :expression, message: 'oops')
+ .with(send_node, location: :expression, message: "oops")
- cop.disallow_send_to(def_node, 'Finder', 'oops')
+ cop.disallow_send_to(def_node, "Finder", "oops")
end
end
end
diff --git a/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb b/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb
index ac7b1575ec0..cd6a24ccc24 100644
--- a/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb
+++ b/spec/rubocop/cop/avoid_break_from_strong_memoize_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/avoid_break_from_strong_memoize'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/avoid_break_from_strong_memoize"
describe RuboCop::Cop::AvoidBreakFromStrongMemoize do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags violation for break inside strong_memoize' do
+ it "flags violation for break inside strong_memoize" do
expect_offense(<<~RUBY)
strong_memoize(:result) do
break if something
@@ -19,7 +19,7 @@ describe RuboCop::Cop::AvoidBreakFromStrongMemoize do
RUBY
end
- it 'flags violation for break inside strong_memoize nested blocks' do
+ it "flags violation for break inside strong_memoize nested blocks" do
expect_offense(<<~RUBY)
strong_memoize do
items.each do |item|
diff --git a/spec/rubocop/cop/avoid_return_from_blocks_spec.rb b/spec/rubocop/cop/avoid_return_from_blocks_spec.rb
index a5c280a7adc..c32e8ece05c 100644
--- a/spec/rubocop/cop/avoid_return_from_blocks_spec.rb
+++ b/spec/rubocop/cop/avoid_return_from_blocks_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/avoid_return_from_blocks'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/avoid_return_from_blocks"
describe RuboCop::Cop::AvoidReturnFromBlocks do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags violation for return inside a block' do
+ it "flags violation for return inside a block" do
expect_offense(<<~RUBY)
call do
do_something
@@ -32,7 +32,7 @@ describe RuboCop::Cop::AvoidReturnFromBlocks do
inspect_source(source)
end
- it 'flags violation for return inside included > def > block' do
+ it "flags violation for return inside included > def > block" do
expect_offense(<<~RUBY)
included do
def a_method
@@ -47,7 +47,7 @@ describe RuboCop::Cop::AvoidReturnFromBlocks do
RUBY
end
- shared_examples 'examples with whitelisted method' do |whitelisted_method|
+ shared_examples "examples with whitelisted method" do |whitelisted_method|
it "doesn't flag violation for return inside #{whitelisted_method}" do
expect_no_offenses(<<~RUBY)
items.#{whitelisted_method} do |item|
@@ -59,10 +59,10 @@ describe RuboCop::Cop::AvoidReturnFromBlocks do
end
%i[each each_filename times loop].each do |whitelisted_method|
- it_behaves_like 'examples with whitelisted method', whitelisted_method
+ it_behaves_like "examples with whitelisted method", whitelisted_method
end
- shared_examples 'examples with def methods' do |def_method|
+ shared_examples "examples with def methods" do |def_method|
it "doesn't flag violation for return inside #{def_method}" do
expect_no_offenses(<<~RUBY)
helpers do
@@ -77,7 +77,7 @@ describe RuboCop::Cop::AvoidReturnFromBlocks do
end
%i[define_method lambda].each do |def_method|
- it_behaves_like 'examples with def methods', def_method
+ it_behaves_like "examples with def methods", def_method
end
it "doesn't flag violation for return inside a lambda" do
diff --git a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb
index c9eb61ccc72..23a8153bc70 100644
--- a/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb
+++ b/spec/rubocop/cop/avoid_route_redirect_leading_slash_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require_relative '../../../rubocop/cop/avoid_route_redirect_leading_slash'
+require "spec_helper"
+require "rubocop"
+require_relative "../../../rubocop/cop/avoid_route_redirect_leading_slash"
describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash do
include CopHelper
@@ -13,20 +13,20 @@ describe RuboCop::Cop::AvoidRouteRedirectLeadingSlash do
allow(cop).to receive(:in_routes?).and_return(true)
end
- it 'registers an offense when redirect has a leading slash' do
+ it "registers an offense when redirect has a leading slash" do
expect_offense(<<~PATTERN.strip_indent)
root to: redirect("/-/route")
^^^^^^^^^^^^^^^^^^^^ Do not use a leading "/" in route redirects
PATTERN
end
- it 'does not register an offense when redirect does not have a leading slash' do
+ it "does not register an offense when redirect does not have a leading slash" do
expect_no_offenses(<<~PATTERN.strip_indent)
root to: redirect("-/route")
PATTERN
end
- it 'autocorrect `/-/route` to `-/route`' do
+ it "autocorrect `/-/route` to `-/route`" do
expect(autocorrect_source('redirect("/-/route")')).to eq('redirect("-/route")')
end
end
diff --git a/spec/rubocop/cop/code_reuse/active_record_spec.rb b/spec/rubocop/cop/code_reuse/active_record_spec.rb
index a30fc52d26f..ff0b615a788 100644
--- a/spec/rubocop/cop/code_reuse/active_record_spec.rb
+++ b/spec/rubocop/cop/code_reuse/active_record_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/active_record'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/active_record"
describe RuboCop::Cop::CodeReuse::ActiveRecord do
include CopHelper
@@ -12,127 +12,127 @@ describe RuboCop::Cop::CodeReuse::ActiveRecord do
it 'flags the use of "where" without any arguments' do
expect_offense(<<~SOURCE)
- def foo
- User.where
- ^^^^^ This method can only be used inside an ActiveRecord model
- end
+ def foo
+ User.where
+ ^^^^^ This method can only be used inside an ActiveRecord model
+ end
SOURCE
end
it 'flags the use of "where" with arguments' do
expect_offense(<<~SOURCE)
- def foo
- User.where(id: 10)
- ^^^^^ This method can only be used inside an ActiveRecord model
- end
+ def foo
+ User.where(id: 10)
+ ^^^^^ This method can only be used inside an ActiveRecord model
+ end
SOURCE
end
it 'does not flag the use of "group" without any arguments' do
expect_no_offenses(<<~SOURCE)
- def foo
- project.group
- end
+ def foo
+ project.group
+ end
SOURCE
end
it 'flags the use of "group" with arguments' do
expect_offense(<<~SOURCE)
- def foo
- project.group(:name)
- ^^^^^ This method can only be used inside an ActiveRecord model
- end
+ def foo
+ project.group(:name)
+ ^^^^^ This method can only be used inside an ActiveRecord model
+ end
SOURCE
end
- it 'does not flag the use of ActiveRecord models in a model' do
- path = Rails.root.join('app', 'models', 'foo.rb').to_s
+ it "does not flag the use of ActiveRecord models in a model" do
+ path = Rails.root.join("app", "models", "foo.rb").to_s
expect_no_offenses(<<~SOURCE, path)
- def foo
- project.group(:name)
- end
+ def foo
+ project.group(:name)
+ end
SOURCE
end
- it 'does not flag the use of ActiveRecord models in a spec' do
- path = Rails.root.join('spec', 'foo_spec.rb').to_s
+ it "does not flag the use of ActiveRecord models in a spec" do
+ path = Rails.root.join("spec", "foo_spec.rb").to_s
expect_no_offenses(<<~SOURCE, path)
- def foo
- project.group(:name)
- end
+ def foo
+ project.group(:name)
+ end
SOURCE
end
- it 'does not flag the use of ActiveRecord models in a background migration' do
+ it "does not flag the use of ActiveRecord models in a background migration" do
path = Rails
.root
- .join('lib', 'gitlab', 'background_migration', 'foo.rb')
+ .join("lib", "gitlab", "background_migration", "foo.rb")
.to_s
expect_no_offenses(<<~SOURCE, path)
- def foo
- project.group(:name)
- end
+ def foo
+ project.group(:name)
+ end
SOURCE
end
- it 'does not flag the use of ActiveRecord models in lib/gitlab/database' do
- path = Rails.root.join('lib', 'gitlab', 'database', 'foo.rb').to_s
+ it "does not flag the use of ActiveRecord models in lib/gitlab/database" do
+ path = Rails.root.join("lib", "gitlab", "database", "foo.rb").to_s
expect_no_offenses(<<~SOURCE, path)
- def foo
- project.group(:name)
- end
+ def foo
+ project.group(:name)
+ end
SOURCE
end
- it 'autocorrects offenses in instance methods by whitelisting them' do
+ it "autocorrects offenses in instance methods by whitelisting them" do
corrected = autocorrect_source(<<~SOURCE)
- def foo
- User.where
- end
+ def foo
+ User.where
+ end
SOURCE
expect(corrected).to eq(<<~SOURCE)
- # rubocop: disable CodeReuse/ActiveRecord
- def foo
- User.where
- end
- # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
+ def foo
+ User.where
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
SOURCE
end
- it 'autocorrects offenses in class methods by whitelisting them' do
+ it "autocorrects offenses in class methods by whitelisting them" do
corrected = autocorrect_source(<<~SOURCE)
- def self.foo
- User.where
- end
+ def self.foo
+ User.where
+ end
SOURCE
expect(corrected).to eq(<<~SOURCE)
- # rubocop: disable CodeReuse/ActiveRecord
- def self.foo
- User.where
- end
- # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
+ def self.foo
+ User.where
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
SOURCE
end
- it 'autocorrects offenses in blocks by whitelisting them' do
+ it "autocorrects offenses in blocks by whitelisting them" do
corrected = autocorrect_source(<<~SOURCE)
- get '/' do
- User.where
- end
+ get '/' do
+ User.where
+ end
SOURCE
expect(corrected).to eq(<<~SOURCE)
- # rubocop: disable CodeReuse/ActiveRecord
- get '/' do
- User.where
- end
- # rubocop: enable CodeReuse/ActiveRecord
+ # rubocop: disable CodeReuse/ActiveRecord
+ get '/' do
+ User.where
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
SOURCE
end
end
diff --git a/spec/rubocop/cop/code_reuse/finder_spec.rb b/spec/rubocop/cop/code_reuse/finder_spec.rb
index b04e053a4c3..197cec55e20 100644
--- a/spec/rubocop/cop/code_reuse/finder_spec.rb
+++ b/spec/rubocop/cop/code_reuse/finder_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/finder'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/finder"
describe RuboCop::Cop::CodeReuse::Finder do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of a Finder inside another Finder' do
+ it "flags the use of a Finder inside another Finder" do
allow(cop)
.to receive(:in_finder?)
.and_return(true)
@@ -27,7 +27,7 @@ describe RuboCop::Cop::CodeReuse::Finder do
expect(cop.offenses.size).to eq(1)
end
- it 'flags the use of a Finder inside a model class method' do
+ it "flags the use of a Finder inside a model class method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -49,7 +49,7 @@ describe RuboCop::Cop::CodeReuse::Finder do
SOURCE
end
- it 'does not flag the use of a Finder in a non Finder file' do
+ it "does not flag the use of a Finder in a non Finder file" do
expect_no_offenses(<<~SOURCE)
class FooFinder
def execute
@@ -59,7 +59,7 @@ describe RuboCop::Cop::CodeReuse::Finder do
SOURCE
end
- it 'does not flag the use of a Finder in a regular class method' do
+ it "does not flag the use of a Finder in a regular class method" do
expect_no_offenses(<<~SOURCE)
class User
class << self
diff --git a/spec/rubocop/cop/code_reuse/presenter_spec.rb b/spec/rubocop/cop/code_reuse/presenter_spec.rb
index 4fe72619273..65873598133 100644
--- a/spec/rubocop/cop/code_reuse/presenter_spec.rb
+++ b/spec/rubocop/cop/code_reuse/presenter_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/presenter'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/presenter"
describe RuboCop::Cop::CodeReuse::Presenter do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of a Presenter in a Service class' do
+ it "flags the use of a Presenter in a Service class" do
allow(cop)
.to receive(:in_service_class?)
.and_return(true)
@@ -25,7 +25,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Presenter in a Finder' do
+ it "flags the use of a Presenter in a Finder" do
allow(cop)
.to receive(:in_finder?)
.and_return(true)
@@ -40,7 +40,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Service class in a Presenter' do
+ it "flags the use of a Service class in a Presenter" do
allow(cop)
.to receive(:in_presenter?)
.and_return(true)
@@ -55,7 +55,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Presenter in a Serializer' do
+ it "flags the use of a Presenter in a Serializer" do
allow(cop)
.to receive(:in_serializer?)
.and_return(true)
@@ -70,7 +70,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Presenter in a model instance method' do
+ it "flags the use of a Presenter in a model instance method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -85,7 +85,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Presenter in a model class method' do
+ it "flags the use of a Presenter in a model class method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -100,7 +100,7 @@ describe RuboCop::Cop::CodeReuse::Presenter do
SOURCE
end
- it 'flags the use of a Presenter in a worker' do
+ it "flags the use of a Presenter in a worker" do
allow(cop)
.to receive(:in_worker?)
.and_return(true)
diff --git a/spec/rubocop/cop/code_reuse/serializer_spec.rb b/spec/rubocop/cop/code_reuse/serializer_spec.rb
index 4530b15eed7..413c63404e8 100644
--- a/spec/rubocop/cop/code_reuse/serializer_spec.rb
+++ b/spec/rubocop/cop/code_reuse/serializer_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/serializer'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/serializer"
describe RuboCop::Cop::CodeReuse::Serializer do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of a Serializer in a Service class' do
+ it "flags the use of a Serializer in a Service class" do
allow(cop)
.to receive(:in_service_class?)
.and_return(true)
@@ -25,7 +25,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a Finder' do
+ it "flags the use of a Serializer in a Finder" do
allow(cop)
.to receive(:in_finder?)
.and_return(true)
@@ -40,7 +40,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a Presenter' do
+ it "flags the use of a Serializer in a Presenter" do
allow(cop)
.to receive(:in_presenter?)
.and_return(true)
@@ -55,7 +55,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a Serializer' do
+ it "flags the use of a Serializer in a Serializer" do
allow(cop)
.to receive(:in_serializer?)
.and_return(true)
@@ -70,7 +70,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a model instance method' do
+ it "flags the use of a Serializer in a model instance method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -85,7 +85,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a model class method' do
+ it "flags the use of a Serializer in a model class method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -100,7 +100,7 @@ describe RuboCop::Cop::CodeReuse::Serializer do
SOURCE
end
- it 'flags the use of a Serializer in a worker' do
+ it "flags the use of a Serializer in a worker" do
allow(cop)
.to receive(:in_worker?)
.and_return(true)
diff --git a/spec/rubocop/cop/code_reuse/service_class_spec.rb b/spec/rubocop/cop/code_reuse/service_class_spec.rb
index 7b8d82f332e..9b575d0345e 100644
--- a/spec/rubocop/cop/code_reuse/service_class_spec.rb
+++ b/spec/rubocop/cop/code_reuse/service_class_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/service_class'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/service_class"
describe RuboCop::Cop::CodeReuse::ServiceClass do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of a Service class in a Finder' do
+ it "flags the use of a Service class in a Finder" do
allow(cop)
.to receive(:in_finder?)
.and_return(true)
@@ -25,7 +25,7 @@ describe RuboCop::Cop::CodeReuse::ServiceClass do
SOURCE
end
- it 'flags the use of a Service class in a Presenter' do
+ it "flags the use of a Service class in a Presenter" do
allow(cop)
.to receive(:in_presenter?)
.and_return(true)
@@ -40,7 +40,7 @@ describe RuboCop::Cop::CodeReuse::ServiceClass do
SOURCE
end
- it 'flags the use of a Service class in a Serializer' do
+ it "flags the use of a Service class in a Serializer" do
allow(cop)
.to receive(:in_serializer?)
.and_return(true)
@@ -55,7 +55,7 @@ describe RuboCop::Cop::CodeReuse::ServiceClass do
SOURCE
end
- it 'flags the use of a Service class in a model' do
+ it "flags the use of a Service class in a model" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
@@ -77,7 +77,7 @@ describe RuboCop::Cop::CodeReuse::ServiceClass do
SOURCE
end
- it 'does not flag the use of a Service class in a regular class' do
+ it "does not flag the use of a Service class in a regular class" do
expect_no_offenses(<<~SOURCE)
class Foo
def execute
diff --git a/spec/rubocop/cop/code_reuse/worker_spec.rb b/spec/rubocop/cop/code_reuse/worker_spec.rb
index 97acaeb7643..379f6562acf 100644
--- a/spec/rubocop/cop/code_reuse/worker_spec.rb
+++ b/spec/rubocop/cop/code_reuse/worker_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/code_reuse/worker'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/code_reuse/worker"
describe RuboCop::Cop::CodeReuse::Worker do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of a worker in a controller' do
+ it "flags the use of a worker in a controller" do
allow(cop)
.to receive(:in_controller?)
.and_return(true)
@@ -25,7 +25,7 @@ describe RuboCop::Cop::CodeReuse::Worker do
SOURCE
end
- it 'flags the use of a worker in an API' do
+ it "flags the use of a worker in an API" do
allow(cop)
.to receive(:in_api?)
.and_return(true)
@@ -42,7 +42,7 @@ describe RuboCop::Cop::CodeReuse::Worker do
SOURCE
end
- it 'flags the use of a worker in a Finder' do
+ it "flags the use of a worker in a Finder" do
allow(cop)
.to receive(:in_finder?)
.and_return(true)
@@ -57,7 +57,7 @@ describe RuboCop::Cop::CodeReuse::Worker do
SOURCE
end
- it 'flags the use of a worker in a Presenter' do
+ it "flags the use of a worker in a Presenter" do
allow(cop)
.to receive(:in_presenter?)
.and_return(true)
@@ -72,7 +72,7 @@ describe RuboCop::Cop::CodeReuse::Worker do
SOURCE
end
- it 'flags the use of a worker in a Serializer' do
+ it "flags the use of a worker in a Serializer" do
allow(cop)
.to receive(:in_serializer?)
.and_return(true)
@@ -87,7 +87,7 @@ describe RuboCop::Cop::CodeReuse::Worker do
SOURCE
end
- it 'flags the use of a worker in a model class method' do
+ it "flags the use of a worker in a model class method" do
allow(cop)
.to receive(:in_model?)
.and_return(true)
diff --git a/spec/rubocop/cop/destroy_all_spec.rb b/spec/rubocop/cop/destroy_all_spec.rb
index b0bc40552b3..f48983081a8 100644
--- a/spec/rubocop/cop/destroy_all_spec.rb
+++ b/spec/rubocop/cop/destroy_all_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/destroy_all'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/destroy_all"
describe RuboCop::Cop::DestroyAll do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of destroy_all with a send receiver' do
- inspect_source('foo.destroy_all # rubocop: disable DestroyAll')
+ it "flags the use of destroy_all with a send receiver" do
+ inspect_source("foo.destroy_all # rubocop: disable DestroyAll")
expect(cop.offenses.size).to eq(1)
end
- it 'flags the use of destroy_all with a constant receiver' do
- inspect_source('User.destroy_all # rubocop: disable DestroyAll')
+ it "flags the use of destroy_all with a constant receiver" do
+ inspect_source("User.destroy_all # rubocop: disable DestroyAll")
expect(cop.offenses.size).to eq(1)
end
- it 'flags the use of destroy_all when passing arguments' do
- inspect_source('User.destroy_all([])')
+ it "flags the use of destroy_all when passing arguments" do
+ inspect_source("User.destroy_all([])")
expect(cop.offenses.size).to eq(1)
end
- it 'flags the use of destroy_all with a local variable receiver' do
+ it "flags the use of destroy_all with a local variable receiver" do
inspect_source(<<~RUBY)
- users = User.all
- users.destroy_all # rubocop: disable DestroyAll
+ users = User.all
+ users.destroy_all # rubocop: disable DestroyAll
RUBY
expect(cop.offenses.size).to eq(1)
end
- it 'does not flag the use of delete_all' do
- inspect_source('foo.delete_all')
+ it "does not flag the use of delete_all" do
+ inspect_source("foo.delete_all")
expect(cop.offenses).to be_empty
end
diff --git a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
index 7f689b196c5..64fb7027a93 100644
--- a/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
+++ b/spec/rubocop/cop/gitlab/finder_with_find_by_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/gitlab/finder_with_find_by'
+require_relative "../../../../rubocop/cop/gitlab/finder_with_find_by"
describe RuboCop::Cop::Gitlab::FinderWithFindBy do
include CopHelper
subject(:cop) { described_class.new }
- context 'when calling execute.find' do
+ context "when calling execute.find" do
let(:source) do
<<~SRC
- DummyFinder.new(some_args)
- .execute
- .find_by!(1)
+ DummyFinder.new(some_args)
+ .execute
+ .find_by!(1)
SRC
end
let(:corrected_source) do
<<~SRC
- DummyFinder.new(some_args)
- .find_by!(1)
+ DummyFinder.new(some_args)
+ .find_by!(1)
SRC
end
- it 'registers an offence' do
+ it "registers an offence" do
inspect_source(source)
expect(cop.offenses.size).to eq(1)
end
- it 'can autocorrect the source' do
+ it "can autocorrect the source" do
expect(autocorrect_source(source)).to eq(corrected_source)
end
- context 'when called within the `FinderMethods` module' do
+ context "when called within the `FinderMethods` module" do
let(:source) do
<<~SRC
module FinderMethods
@@ -46,7 +46,7 @@ describe RuboCop::Cop::Gitlab::FinderWithFindBy do
SRC
end
- it 'does not register an offence' do
+ it "does not register an offence" do
inspect_source(source)
expect(cop.offenses).to be_empty
diff --git a/spec/rubocop/cop/gitlab/httparty_spec.rb b/spec/rubocop/cop/gitlab/httparty_spec.rb
index 510839a21d7..dbfb935b65d 100644
--- a/spec/rubocop/cop/gitlab/httparty_spec.rb
+++ b/spec/rubocop/cop/gitlab/httparty_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/gitlab/httparty'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/gitlab/httparty"
describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
include CopHelper
subject(:cop) { described_class.new }
- shared_examples('registering include offense') do |options|
+ shared_examples("registering include offense") do |options|
let(:offending_lines) { options[:offending_lines] }
- it 'registers an offense when the class includes HTTParty' do
+ it "registers an offense when the class includes HTTParty" do
inspect_source(source)
aggregate_failures do
@@ -21,10 +21,10 @@ describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
end
end
- shared_examples('registering call offense') do |options|
+ shared_examples("registering call offense") do |options|
let(:offending_lines) { options[:offending_lines] }
- it 'registers an offense when the class calls HTTParty' do
+ it "registers an offense when the class calls HTTParty" do
inspect_source(source)
aggregate_failures do
@@ -34,8 +34,8 @@ describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
end
end
- context 'when source is a regular module' do
- it_behaves_like 'registering include offense', offending_lines: [2] do
+ context "when source is a regular module" do
+ it_behaves_like "registering include offense", offending_lines: [2] do
let(:source) do
<<~RUBY
module M
@@ -46,8 +46,8 @@ describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
end
end
- context 'when source is a regular class' do
- it_behaves_like 'registering include offense', offending_lines: [2] do
+ context "when source is a regular class" do
+ it_behaves_like "registering include offense", offending_lines: [2] do
let(:source) do
<<~RUBY
class Foo
@@ -58,8 +58,8 @@ describe RuboCop::Cop::Gitlab::HTTParty do # rubocop:disable RSpec/FilePath
end
end
- context 'when HTTParty is called' do
- it_behaves_like 'registering call offense', offending_lines: [3] do
+ context "when HTTParty is called" do
+ it_behaves_like "registering call offense", offending_lines: [3] do
let(:source) do
<<~RUBY
class Foo
diff --git a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
index 8e2d5f70353..3f3fd52a32c 100644
--- a/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
+++ b/spec/rubocop/cop/gitlab/module_with_instance_variables_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/gitlab/module_with_instance_variables'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/gitlab/module_with_instance_variables"
describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
include CopHelper
subject(:cop) { described_class.new }
- shared_examples('registering offense') do |options|
+ shared_examples("registering offense") do |options|
let(:offending_lines) { options[:offending_lines] }
- it 'registers an offense when instance variable is used in a module' do
+ it "registers an offense when instance variable is used in a module" do
inspect_source(source)
aggregate_failures do
@@ -21,16 +21,16 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- shared_examples('not registering offense') do
- it 'does not register offenses' do
+ shared_examples("not registering offense") do
+ it "does not register offenses" do
inspect_source(source)
expect(cop.offenses).to be_empty
end
end
- context 'when source is a regular module' do
- it_behaves_like 'registering offense', offending_lines: [3] do
+ context "when source is a regular module" do
+ it_behaves_like "registering offense", offending_lines: [3] do
let(:source) do
<<~RUBY
module M
@@ -43,8 +43,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is a nested module' do
- it_behaves_like 'registering offense', offending_lines: [4] do
+ context "when source is a nested module" do
+ it_behaves_like "registering offense", offending_lines: [4] do
let(:source) do
<<~RUBY
module N
@@ -59,8 +59,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is a nested module with multiple offenses' do
- it_behaves_like 'registering offense', offending_lines: [4, 12] do
+ context "when source is a nested module with multiple offenses" do
+ it_behaves_like "registering offense", offending_lines: [4, 12] do
let(:source) do
<<~RUBY
module N
@@ -83,8 +83,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is using simple or ivar assignment' do
- it_behaves_like 'not registering offense' do
+ context "when source is using simple or ivar assignment" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
module M
@@ -97,8 +97,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is using simple ivar' do
- it_behaves_like 'not registering offense' do
+ context "when source is using simple ivar" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
module M
@@ -111,8 +111,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is defining initialize' do
- it_behaves_like 'not registering offense' do
+ context "when source is defining initialize" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
module M
@@ -126,8 +126,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is using simple or ivar assignment with other ivar' do
- it_behaves_like 'registering offense', offending_lines: [3] do
+ context "when source is using simple or ivar assignment with other ivar" do
+ it_behaves_like "registering offense", offending_lines: [3] do
let(:source) do
<<~RUBY
module M
@@ -140,8 +140,8 @@ describe RuboCop::Cop::Gitlab::ModuleWithInstanceVariables do
end
end
- context 'when source is using or ivar assignment with something else' do
- it_behaves_like 'registering offense', offending_lines: [3, 4] do
+ context "when source is using or ivar assignment with something else" do
+ it_behaves_like "registering offense", offending_lines: [3, 4] do
let(:source) do
<<~RUBY
module M
diff --git a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
index 21fc4584654..ddec2c92482 100644
--- a/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
+++ b/spec/rubocop/cop/gitlab/predicate_memoization_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/gitlab/predicate_memoization'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/gitlab/predicate_memoization"
describe RuboCop::Cop::Gitlab::PredicateMemoization do
include CopHelper
subject(:cop) { described_class.new }
- shared_examples('registering offense') do |options|
+ shared_examples("registering offense") do |options|
let(:offending_lines) { options[:offending_lines] }
- it 'registers an offense when a predicate method is memoizing via ivar' do
+ it "registers an offense when a predicate method is memoizing via ivar" do
inspect_source(source)
aggregate_failures do
@@ -21,16 +21,16 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do
end
end
- shared_examples('not registering offense') do
- it 'does not register offenses' do
+ shared_examples("not registering offense") do
+ it "does not register offenses" do
inspect_source(source)
expect(cop.offenses).to be_empty
end
end
- context 'when source is a predicate method memoizing via ivar' do
- it_behaves_like 'registering offense', offending_lines: [3] do
+ context "when source is a predicate method memoizing via ivar" do
+ it_behaves_like "registering offense", offending_lines: [3] do
let(:source) do
<<~RUBY
class C
@@ -42,7 +42,7 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do
end
end
- it_behaves_like 'registering offense', offending_lines: [4] do
+ it_behaves_like "registering offense", offending_lines: [4] do
let(:source) do
<<~RUBY
class C
@@ -56,8 +56,8 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do
end
end
- context 'when source is a predicate method using ivar with assignment' do
- it_behaves_like 'not registering offense' do
+ context "when source is a predicate method using ivar with assignment" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
class C
@@ -70,8 +70,8 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do
end
end
- context 'when source is a predicate method using local with ||=' do
- it_behaves_like 'not registering offense' do
+ context "when source is a predicate method using local with ||=" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
class C
@@ -84,8 +84,8 @@ describe RuboCop::Cop::Gitlab::PredicateMemoization do
end
end
- context 'when source is a regular method memoizing via ivar' do
- it_behaves_like 'not registering offense' do
+ context "when source is a regular method memoizing via ivar" do
+ it_behaves_like "not registering offense" do
let(:source) do
<<~RUBY
class C
diff --git a/spec/rubocop/cop/gitlab/union_spec.rb b/spec/rubocop/cop/gitlab/union_spec.rb
index 5b06f30b25f..c1bd021f3f2 100644
--- a/spec/rubocop/cop/gitlab/union_spec.rb
+++ b/spec/rubocop/cop/gitlab/union_spec.rb
@@ -1,25 +1,25 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../../rubocop/cop/gitlab/union'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../../rubocop/cop/gitlab/union"
describe RuboCop::Cop::Gitlab::Union do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of Gitlab::SQL::Union.new' do
+ it "flags the use of Gitlab::SQL::Union.new" do
expect_offense(<<~SOURCE)
- Gitlab::SQL::Union.new([foo])
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly
+ Gitlab::SQL::Union.new([foo])
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use the `FromUnion` concern, instead of using `Gitlab::SQL::Union` directly
SOURCE
end
- it 'does not flag the use of Gitlab::SQL::Union in a spec' do
+ it "does not flag the use of Gitlab::SQL::Union in a spec" do
allow(cop).to receive(:in_spec?).and_return(true)
- expect_no_offenses('Gitlab::SQL::Union.new([foo])')
+ expect_no_offenses("Gitlab::SQL::Union.new([foo])")
end
end
diff --git a/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb b/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb
index 7b5235a3da7..31d3624c38a 100644
--- a/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb
+++ b/spec/rubocop/cop/group_public_or_visible_to_user_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/group_public_or_visible_to_user'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/group_public_or_visible_to_user"
describe RuboCop::Cop::GroupPublicOrVisibleToUser do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of Group.public_or_visible_to_user with a constant receiver' do
- inspect_source('Group.public_or_visible_to_user')
+ it "flags the use of Group.public_or_visible_to_user with a constant receiver" do
+ inspect_source("Group.public_or_visible_to_user")
expect(cop.offenses.size).to eq(1)
end
- it 'does not flat the use of public_or_visible_to_user with a constant that is not Group' do
- inspect_source('Project.public_or_visible_to_user')
+ it "does not flat the use of public_or_visible_to_user with a constant that is not Group" do
+ inspect_source("Project.public_or_visible_to_user")
expect(cop.offenses.size).to eq(0)
end
- it 'does not flag the use of Group.public_or_visible_to_user with a send receiver' do
- inspect_source('foo.public_or_visible_to_user')
+ it "does not flag the use of Group.public_or_visible_to_user with a send receiver" do
+ inspect_source("foo.public_or_visible_to_user")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/include_sidekiq_worker_spec.rb b/spec/rubocop/cop/include_sidekiq_worker_spec.rb
index f5109287876..c6c4b8dc641 100644
--- a/spec/rubocop/cop/include_sidekiq_worker_spec.rb
+++ b/spec/rubocop/cop/include_sidekiq_worker_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../rubocop/cop/include_sidekiq_worker'
+require_relative "../../../rubocop/cop/include_sidekiq_worker"
describe RuboCop::Cop::IncludeSidekiqWorker do
include CopHelper
subject(:cop) { described_class.new }
- context 'when `Sidekiq::Worker` is included' do
- let(:source) { 'include Sidekiq::Worker' }
- let(:correct_source) { 'include ApplicationWorker' }
+ context "when `Sidekiq::Worker` is included" do
+ let(:source) { "include Sidekiq::Worker" }
+ let(:correct_source) { "include ApplicationWorker" }
- it 'registers an offense ' do
+ it "registers an offense " do
inspect_source(source)
aggregate_failures do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line)).to eq([1])
- expect(cop.highlights).to eq(['Sidekiq::Worker'])
+ expect(cop.highlights).to eq(["Sidekiq::Worker"])
end
end
- it 'autocorrects to the right version' do
+ it "autocorrects to the right version" do
autocorrected = autocorrect_source(source)
expect(autocorrected).to eq(correct_source)
diff --git a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
index 0ff777388e5..8811f18de81 100644
--- a/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
+++ b/spec/rubocop/cop/inject_enterprise_edition_module_spec.rb
@@ -1,168 +1,165 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/inject_enterprise_edition_module'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/inject_enterprise_edition_module"
describe RuboCop::Cop::InjectEnterpriseEditionModule do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the use of `prepend EE` in the middle of a file' do
+ it "flags the use of `prepend EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- prepend EE::Foo
- ^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ prepend EE::Foo
+ ^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'does not flag the use of `prepend EEFoo` in the middle of a file' do
+ it "does not flag the use of `prepend EEFoo` in the middle of a file" do
expect_no_offenses(<<~SOURCE)
- class Foo
- prepend EEFoo
- end
+ class Foo
+ prepend EEFoo
+ end
SOURCE
end
- it 'flags the use of `prepend EE::Foo::Bar` in the middle of a file' do
+ it "flags the use of `prepend EE::Foo::Bar` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- prepend EE::Foo::Bar
- ^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ prepend EE::Foo::Bar
+ ^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `prepend(EE::Foo::Bar)` in the middle of a file' do
+ it "flags the use of `prepend(EE::Foo::Bar)` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- prepend(EE::Foo::Bar)
- ^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ prepend(EE::Foo::Bar)
+ ^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `prepend EE::Foo::Bar::Baz` in the middle of a file' do
+ it "flags the use of `prepend EE::Foo::Bar::Baz` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- prepend EE::Foo::Bar::Baz
- ^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ prepend EE::Foo::Bar::Baz
+ ^^^^^^^^^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `prepend ::EE` in the middle of a file' do
+ it "flags the use of `prepend ::EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- prepend ::EE::Foo
- ^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ prepend ::EE::Foo
+ ^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `include EE` in the middle of a file' do
+ it "flags the use of `include EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- include EE::Foo
- ^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ include EE::Foo
+ ^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `include ::EE` in the middle of a file' do
+ it "flags the use of `include ::EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- include ::EE::Foo
- ^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ include ::EE::Foo
+ ^^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `extend EE` in the middle of a file' do
+ it "flags the use of `extend EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- extend EE::Foo
- ^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ extend EE::Foo
+ ^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'flags the use of `extend ::EE` in the middle of a file' do
+ it "flags the use of `extend ::EE` in the middle of a file" do
expect_offense(<<~SOURCE)
- class Foo
- extend ::EE::Foo
- ^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
- end
+ class Foo
+ extend ::EE::Foo
+ ^^^^^^^^^^^^^^^^ Injecting EE modules must be done on the last line of this file, outside of any class or module definitions
+ end
SOURCE
end
- it 'does not flag prepending of regular modules' do
+ it "does not flag prepending of regular modules" do
expect_no_offenses(<<~SOURCE)
- class Foo
- prepend Foo
- end
+ class Foo
+ prepend Foo
+ end
SOURCE
end
- it 'does not flag including of regular modules' do
+ it "does not flag including of regular modules" do
expect_no_offenses(<<~SOURCE)
- class Foo
- include Foo
- end
+ class Foo
+ include Foo
+ end
SOURCE
end
- it 'does not flag extending using regular modules' do
+ it "does not flag extending using regular modules" do
expect_no_offenses(<<~SOURCE)
- class Foo
- extend Foo
- end
+ class Foo
+ extend Foo
+ end
SOURCE
end
- it 'does not flag the use of `prepend EE` on the last line' do
+ it "does not flag the use of `prepend EE` on the last line" do
expect_no_offenses(<<~SOURCE)
- class Foo
- end
-
- Foo.prepend(EE::Foo)
+ class Foo
+ end
+ Foo.prepend(EE::Foo)
SOURCE
end
- it 'does not flag the use of `include EE` on the last line' do
+ it "does not flag the use of `include EE` on the last line" do
expect_no_offenses(<<~SOURCE)
- class Foo
- end
-
- Foo.include(EE::Foo)
+ class Foo
+ end
+ Foo.include(EE::Foo)
SOURCE
end
- it 'does not flag the use of `extend EE` on the last line' do
+ it "does not flag the use of `extend EE` on the last line" do
expect_no_offenses(<<~SOURCE)
- class Foo
- end
-
- Foo.extend(EE::Foo)
+ class Foo
+ end
+ Foo.extend(EE::Foo)
SOURCE
end
- it 'autocorrects offenses by just disabling the Cop' do
+ it "autocorrects offenses by just disabling the Cop" do
source = <<~SOURCE
- class Foo
- prepend EE::Foo
- include Bar
- end
+ class Foo
+ prepend EE::Foo
+ include Bar
+ end
SOURCE
expect(autocorrect_source(source)).to eq(<<~SOURCE)
- class Foo
- prepend EE::Foo # rubocop: disable Cop/InjectEnterpriseEditionModule
- include Bar
- end
+ class Foo
+ prepend EE::Foo # rubocop: disable Cop/InjectEnterpriseEditionModule
+ include Bar
+ end
SOURCE
end
end
diff --git a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb b/spec/rubocop/cop/line_break_around_conditional_block_spec.rb
index 892b393c307..91206f456d0 100644
--- a/spec/rubocop/cop/line_break_around_conditional_block_spec.rb
+++ b/spec/rubocop/cop/line_break_around_conditional_block_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/line_break_around_conditional_block'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/line_break_around_conditional_block"
describe RuboCop::Cop::LineBreakAroundConditionalBlock do
include CopHelper
subject(:cop) { described_class.new }
- shared_examples 'examples with conditional' do |conditional|
+ shared_examples "examples with conditional" do |conditional|
it "flags violation for #{conditional} without line break before" do
source = <<~RUBY
- do_something
- #{conditional} condition
- do_something_more
- end
+ do_something
+ #{conditional} condition
+ do_something_more
+ end
RUBY
inspect_source(source)
@@ -23,15 +23,15 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
expect(offense.line).to eq(2)
expect(cop.highlights).to eq(["#{conditional} condition\n do_something_more\nend"])
- expect(offense.message).to eq('Add a line break around conditional blocks')
+ expect(offense.message).to eq("Add a line break around conditional blocks")
end
it "flags violation for #{conditional} without line break after" do
source = <<~RUBY
- #{conditional} condition
- do_something
- end
- do_something_more
+ #{conditional} condition
+ do_something
+ end
+ do_something_more
RUBY
inspect_source(source)
@@ -40,14 +40,14 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
expect(offense.line).to eq(1)
expect(cop.highlights).to eq(["#{conditional} condition\n do_something\nend"])
- expect(offense.message).to eq('Add a line break around conditional blocks')
+ expect(offense.message).to eq("Add a line break around conditional blocks")
end
it "doesn't flag violation for #{conditional} with line break before and after" do
source = <<~RUBY
- #{conditional} condition
- do_something
- end
+ #{conditional} condition
+ do_something
+ end
RUBY
inspect_source(source)
@@ -56,11 +56,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a method definition" do
source = <<~RUBY
- def a_method
- #{conditional} condition
- do_something
- end
+ def a_method
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -69,11 +69,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a class definition" do
source = <<~RUBY
- class Foo
- #{conditional} condition
- do_something
- end
+ class Foo
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -82,11 +82,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a module definition" do
source = <<~RUBY
- module Foo
- #{conditional} condition
- do_something
- end
+ module Foo
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -95,11 +95,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a begin definition" do
source = <<~RUBY
- begin
- #{conditional} condition
- do_something
- end
+ begin
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -108,11 +108,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by an assign/begin definition" do
source = <<~RUBY
- @project ||= begin
- #{conditional} condition
- do_something
- end
+ @project ||= begin
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -121,11 +121,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a block definition" do
source = <<~RUBY
- on_block(param_a) do |item|
- #{conditional} condition
- do_something
- end
+ on_block(param_a) do |item|
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -134,11 +134,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a block definition using brackets" do
source = <<~RUBY
- on_block(param_a) { |item|
- #{conditional} condition
- do_something
- end
- }
+ on_block(param_a) { |item|
+ #{conditional} condition
+ do_something
+ end
+ }
RUBY
inspect_source(source)
@@ -147,10 +147,10 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a comment" do
source = <<~RUBY
- # a short comment
- #{conditional} condition
- do_something
- end
+ # a short comment
+ #{conditional} condition
+ do_something
+ end
RUBY
inspect_source(source)
@@ -159,12 +159,12 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by an assignment" do
source = <<~RUBY
- foo =
- #{conditional} condition
- do_something
- else
- do_something_more
- end
+ foo =
+ #{conditional} condition
+ do_something
+ else
+ do_something_more
+ end
RUBY
inspect_source(source)
@@ -173,12 +173,12 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a multiline comment" do
source = <<~RUBY
- =begin
- a multiline comment
- =end
- #{conditional} condition
- do_something
- end
+ =begin
+ a multiline comment
+ =end
+ #{conditional} condition
+ do_something
+ end
RUBY
inspect_source(source)
@@ -187,11 +187,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by another conditional" do
source = <<~RUBY
- #{conditional} condition_a
- #{conditional} condition_b
- do_something
- end
+ #{conditional} condition_a
+ #{conditional} condition_b
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -200,13 +200,13 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by an else" do
source = <<~RUBY
- if condition_a
- do_something
- else
- #{conditional} condition_b
- do_something_extra
- end
- end
+ if condition_a
+ do_something
+ else
+ #{conditional} condition_b
+ do_something_extra
+ end
+ end
RUBY
inspect_source(source)
@@ -215,13 +215,13 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by an elsif" do
source = <<~RUBY
- if condition_a
- do_something
- elsif condition_b
- #{conditional} condition_c
- do_something_extra
- end
- end
+ if condition_a
+ do_something
+ elsif condition_b
+ #{conditional} condition_c
+ do_something_extra
+ end
+ end
RUBY
inspect_source(source)
@@ -230,12 +230,12 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by an ensure" do
source = <<~RUBY
- def a_method
- ensure
- #{conditional} condition_c
- do_something_extra
- end
- end
+ def a_method
+ ensure
+ #{conditional} condition_c
+ do_something_extra
+ end
+ end
RUBY
inspect_source(source)
@@ -244,12 +244,12 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} preceded by a when" do
source = <<~RUBY
- case field
- when value
- #{conditional} condition_c
- do_something_extra
- end
- end
+ case field
+ when value
+ #{conditional} condition_c
+ do_something_extra
+ end
+ end
RUBY
inspect_source(source)
@@ -258,10 +258,10 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by a comment" do
source = <<~RUBY
- #{conditional} condition
- do_something
- end
- # a short comment
+ #{conditional} condition
+ do_something
+ end
+ # a short comment
RUBY
inspect_source(source)
@@ -270,12 +270,11 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by an end" do
source = <<~RUBY
- class Foo
-
- #{conditional} condition
- do_something
- end
+ class Foo
+ #{conditional} condition
+ do_something
end
+ end
RUBY
inspect_source(source)
@@ -284,13 +283,13 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by an else" do
source = <<~RUBY
- #{conditional} condition_a
- #{conditional} condition_b
- do_something
- end
- else
- do_something_extra
+ #{conditional} condition_a
+ #{conditional} condition_b
+ do_something
end
+ else
+ do_something_extra
+ end
RUBY
inspect_source(source)
@@ -299,14 +298,14 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by a when" do
source = <<~RUBY
- case
- when condition_a
- #{conditional} condition_b
- do_something
- end
- when condition_c
- do_something_extra
+ case
+ when condition_a
+ #{conditional} condition_b
+ do_something
end
+ when condition_c
+ do_something_extra
+ end
RUBY
inspect_source(source)
@@ -315,13 +314,13 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by an elsif" do
source = <<~RUBY
- if condition_a
- #{conditional} condition_b
- do_something
- end
- elsif condition_c
- do_something_extra
+ if condition_a
+ #{conditional} condition_b
+ do_something
end
+ elsif condition_c
+ do_something_extra
+ end
RUBY
inspect_source(source)
@@ -346,13 +345,13 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "doesn't flag violation for #{conditional} followed by a rescue" do
source = <<~RUBY
- def a_method
- #{conditional} condition
- do_something
- end
- rescue
- do_something_extra
- end
+ def a_method
+ #{conditional} condition
+ do_something
+ end
+ rescue
+ do_something_extra
+ end
RUBY
inspect_source(source)
@@ -361,76 +360,72 @@ describe RuboCop::Cop::LineBreakAroundConditionalBlock do
it "autocorrects #{conditional} without line break before" do
source = <<~RUBY
- do_something
- #{conditional} condition
- do_something_more
- end
+ do_something
+ #{conditional} condition
+ do_something_more
+ end
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
- do_something
-
- #{conditional} condition
- do_something_more
- end
+ do_something
+ #{conditional} condition
+ do_something_more
+ end
RUBY
expect(autocorrected).to eql(expected_source)
end
it "autocorrects #{conditional} without line break after" do
source = <<~RUBY
- #{conditional} condition
- do_something
- end
- do_something_more
+ #{conditional} condition
+ do_something
+ end
+ do_something_more
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
- #{conditional} condition
- do_something
- end
-
- do_something_more
+ #{conditional} condition
+ do_something
+ end
+ do_something_more
RUBY
expect(autocorrected).to eql(expected_source)
end
it "autocorrects #{conditional} without line break before and after" do
source = <<~RUBY
- do_something
- #{conditional} condition
- do_something_more
- end
- do_something_extra
+ do_something
+ #{conditional} condition
+ do_something_more
+ end
+ do_something_extra
RUBY
autocorrected = autocorrect_source(source)
expected_source = <<~RUBY
- do_something
-
- #{conditional} condition
- do_something_more
- end
-
- do_something_extra
+ do_something
+ #{conditional} condition
+ do_something_more
+ end
+ do_something_extra
RUBY
expect(autocorrected).to eql(expected_source)
end
end
%w[if unless].each do |example|
- it_behaves_like 'examples with conditional', example
+ it_behaves_like "examples with conditional", example
end
it "doesn't flag violation for if with elsif" do
source = <<~RUBY
- if condition
- do_something
- elsif another_condition
- do_something_more
- end
+ if condition
+ do_something
+ elsif another_condition
+ do_something_more
+ end
RUBY
inspect_source(source)
diff --git a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb
index 1df1fffb94e..9c10d32c05c 100644
--- a/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb
+++ b/spec/rubocop/cop/migration/add_concurrent_foreign_key_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/add_concurrent_foreign_key'
+require_relative "../../../../rubocop/cop/migration/add_concurrent_foreign_key"
describe RuboCop::Cop::Migration::AddConcurrentForeignKey do
include CopHelper
let(:cop) { described_class.new }
- context 'outside of a migration' do
- it 'does not register any offenses' do
- inspect_source('def up; add_foreign_key(:projects, :users, column: :user_id); end')
+ context "outside of a migration" do
+ it "does not register any offenses" do
+ inspect_source("def up; add_foreign_key(:projects, :users, column: :user_id); end")
expect(cop.offenses).to be_empty
end
end
- context 'in a migration' do
+ context "in a migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when using add_foreign_key' do
- inspect_source('def up; add_foreign_key(:projects, :users, column: :user_id); end')
+ it "registers an offense when using add_foreign_key" do
+ inspect_source("def up; add_foreign_key(:projects, :users, column: :user_id); end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
diff --git a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb
index 9c1ebcc0ced..30a5c6a8e90 100644
--- a/spec/rubocop/cop/migration/add_concurrent_index_spec.rb
+++ b/spec/rubocop/cop/migration/add_concurrent_index_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/add_concurrent_index'
+require_relative "../../../../rubocop/cop/migration/add_concurrent_index"
describe RuboCop::Cop::Migration::AddConcurrentIndex do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when add_concurrent_index is used inside a change method' do
- inspect_source('def change; add_concurrent_index :table, :column; end')
+ it "registers an offense when add_concurrent_index is used inside a change method" do
+ inspect_source("def change; add_concurrent_index :table, :column; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -24,16 +24,16 @@ describe RuboCop::Cop::Migration::AddConcurrentIndex do
end
end
- it 'registers no offense when add_concurrent_index is used inside an up method' do
- inspect_source('def up; add_concurrent_index :table, :column; end')
+ it "registers no offense when add_concurrent_index is used inside an up method" do
+ inspect_source("def up; add_concurrent_index :table, :column; end")
expect(cop.offenses.size).to eq(0)
end
end
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; add_concurrent_index :table, :column; end')
+ context "outside of migration" do
+ it "registers no offense" do
+ inspect_source("def change; add_concurrent_index :table, :column; end")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/migration/add_reference_spec.rb b/spec/rubocop/cop/migration/add_reference_spec.rb
index c348fc0efac..9d87a844f74 100644
--- a/spec/rubocop/cop/migration/add_reference_spec.rb
+++ b/spec/rubocop/cop/migration/add_reference_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/add_reference'
+require_relative "../../../../rubocop/cop/migration/add_reference"
describe RuboCop::Cop::Migration::AddReference do
include CopHelper
let(:cop) { described_class.new }
- context 'outside of a migration' do
- it 'does not register any offenses' do
+ context "outside of a migration" do
+ it "does not register any offenses" do
expect_no_offenses(<<~RUBY)
def up
add_reference(:projects, :users)
@@ -20,12 +20,12 @@ describe RuboCop::Cop::Migration::AddReference do
end
end
- context 'in a migration' do
+ context "in a migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when using add_reference without index' do
+ it "registers an offense when using add_reference without index" do
expect_offense(<<~RUBY)
call do
add_reference(:projects, :users)
@@ -34,7 +34,7 @@ describe RuboCop::Cop::Migration::AddReference do
RUBY
end
- it 'registers an offense when using add_reference index disabled' do
+ it "registers an offense when using add_reference index disabled" do
expect_offense(<<~RUBY)
def up
add_reference(:projects, :users, index: false)
@@ -43,7 +43,7 @@ describe RuboCop::Cop::Migration::AddReference do
RUBY
end
- it 'does not register an offense when using add_reference with index enabled' do
+ it "does not register an offense when using add_reference with index enabled" do
expect_no_offenses(<<~RUBY)
def up
add_reference(:projects, :users, index: true)
@@ -51,7 +51,7 @@ describe RuboCop::Cop::Migration::AddReference do
RUBY
end
- it 'does not register an offense when the index is unique' do
+ it "does not register an offense when the index is unique" do
expect_no_offenses(<<~RUBY)
def up
add_reference(:projects, :users, index: { unique: true } )
diff --git a/spec/rubocop/cop/migration/add_timestamps_spec.rb b/spec/rubocop/cop/migration/add_timestamps_spec.rb
index fae0177d5f5..2a2d95f5ea6 100644
--- a/spec/rubocop/cop/migration/add_timestamps_spec.rb
+++ b/spec/rubocop/cop/migration/add_timestamps_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/add_timestamps'
+require_relative "../../../../rubocop/cop/migration/add_timestamps"
describe RuboCop::Cop::Migration::AddTimestamps do
include CopHelper
subject(:cop) { described_class.new }
let(:migration_with_add_timestamps) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -19,11 +19,11 @@ describe RuboCop::Cop::Migration::AddTimestamps do
add_timestamps(:users)
end
end
- )
+ '
end
let(:migration_without_add_timestamps) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -31,11 +31,11 @@ describe RuboCop::Cop::Migration::AddTimestamps do
add_column(:users, :username, :text)
end
end
- )
+ '
end
let(:migration_with_add_timestamps_with_timezone) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -44,10 +44,10 @@ describe RuboCop::Cop::Migration::AddTimestamps do
add_timestamps_with_timezone(:users)
end
end
- )
+ '
end
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
@@ -78,8 +78,8 @@ describe RuboCop::Cop::Migration::AddTimestamps do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
+ context "outside of migration" do
+ it "registers no offense" do
inspect_source(migration_with_add_timestamps)
inspect_source(migration_without_add_timestamps)
inspect_source(migration_with_add_timestamps_with_timezone)
diff --git a/spec/rubocop/cop/migration/datetime_spec.rb b/spec/rubocop/cop/migration/datetime_spec.rb
index f2d9483d8d3..26d51ec6594 100644
--- a/spec/rubocop/cop/migration/datetime_spec.rb
+++ b/spec/rubocop/cop/migration/datetime_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/datetime'
+require_relative "../../../../rubocop/cop/migration/datetime"
describe RuboCop::Cop::Migration::Datetime do
include CopHelper
@@ -11,7 +11,7 @@ describe RuboCop::Cop::Migration::Datetime do
subject(:cop) { described_class.new }
let(:migration_with_datetime) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -20,11 +20,11 @@ describe RuboCop::Cop::Migration::Datetime do
add_column(:users, :last_sign_in, :datetime)
end
end
- )
+ '
end
let(:migration_with_timestamp) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -33,11 +33,11 @@ describe RuboCop::Cop::Migration::Datetime do
add_column(:users, :last_sign_in, :timestamp)
end
end
- )
+ '
end
let(:migration_without_datetime) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -45,11 +45,11 @@ describe RuboCop::Cop::Migration::Datetime do
add_column(:users, :username, :text)
end
end
- )
+ '
end
let(:migration_with_datetime_with_timezone) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -58,10 +58,10 @@ describe RuboCop::Cop::Migration::Datetime do
add_column(:users, :last_sign_in, :datetime_with_timezone)
end
end
- )
+ '
end
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
@@ -72,7 +72,7 @@ describe RuboCop::Cop::Migration::Datetime do
aggregate_failures do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line)).to eq([7])
- expect(cop.offenses.first.message).to include('datetime')
+ expect(cop.offenses.first.message).to include("datetime")
end
end
@@ -82,7 +82,7 @@ describe RuboCop::Cop::Migration::Datetime do
aggregate_failures do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line)).to eq([7])
- expect(cop.offenses.first.message).to include('timestamp')
+ expect(cop.offenses.first.message).to include("timestamp")
end
end
@@ -103,8 +103,8 @@ describe RuboCop::Cop::Migration::Datetime do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
+ context "outside of migration" do
+ it "registers no offense" do
inspect_source(migration_with_datetime)
inspect_source(migration_with_timestamp)
inspect_source(migration_without_datetime)
diff --git a/spec/rubocop/cop/migration/hash_index_spec.rb b/spec/rubocop/cop/migration/hash_index_spec.rb
index 5d53dde9a79..18d0bbdd456 100644
--- a/spec/rubocop/cop/migration/hash_index_spec.rb
+++ b/spec/rubocop/cop/migration/hash_index_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/hash_index'
+require_relative "../../../../rubocop/cop/migration/hash_index"
describe RuboCop::Cop::Migration::HashIndex do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when creating a hash index' do
- inspect_source('def change; add_index :table, :column, using: :hash; end')
+ it "registers an offense when creating a hash index" do
+ inspect_source("def change; add_index :table, :column, using: :hash; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -24,8 +24,8 @@ describe RuboCop::Cop::Migration::HashIndex do
end
end
- it 'registers an offense when creating a concurrent hash index' do
- inspect_source('def change; add_concurrent_index :table, :column, using: :hash; end')
+ it "registers an offense when creating a concurrent hash index" do
+ inspect_source("def change; add_concurrent_index :table, :column, using: :hash; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -33,8 +33,8 @@ describe RuboCop::Cop::Migration::HashIndex do
end
end
- it 'registers an offense when creating a hash index using t.index' do
- inspect_source('def change; t.index :table, :column, using: :hash; end')
+ it "registers an offense when creating a hash index using t.index" do
+ inspect_source("def change; t.index :table, :column, using: :hash; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -43,9 +43,9 @@ describe RuboCop::Cop::Migration::HashIndex do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; index :table, :column, using: :hash; end')
+ context "outside of migration" do
+ it "registers no offense" do
+ inspect_source("def change; index :table, :column, using: :hash; end")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/migration/remove_column_spec.rb b/spec/rubocop/cop/migration/remove_column_spec.rb
index f1a64f431bd..a969531eddc 100644
--- a/spec/rubocop/cop/migration/remove_column_spec.rb
+++ b/spec/rubocop/cop/migration/remove_column_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/remove_column'
+require_relative "../../../../rubocop/cop/migration/remove_column"
describe RuboCop::Cop::Migration::RemoveColumn do
include CopHelper
subject(:cop) { described_class.new }
- def source(meth = 'change')
+ def source(meth = "change")
"def #{meth}; remove_column :table, :column; end"
end
- context 'in a regular migration' do
+ context "in a regular migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
allow(cop).to receive(:in_post_deployment_migration?).and_return(false)
end
- it 'registers an offense when remove_column is used in the change method' do
- inspect_source(source('change'))
+ it "registers an offense when remove_column is used in the change method" do
+ inspect_source(source("change"))
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -29,8 +29,8 @@ describe RuboCop::Cop::Migration::RemoveColumn do
end
end
- it 'registers an offense when remove_column is used in the up method' do
- inspect_source(source('up'))
+ it "registers an offense when remove_column is used in the up method" do
+ inspect_source(source("up"))
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -38,28 +38,28 @@ describe RuboCop::Cop::Migration::RemoveColumn do
end
end
- it 'registers no offense when remove_column is used in the down method' do
- inspect_source(source('down'))
+ it "registers no offense when remove_column is used in the down method" do
+ inspect_source(source("down"))
expect(cop.offenses.size).to eq(0)
end
end
- context 'in a post-deployment migration' do
+ context "in a post-deployment migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
allow(cop).to receive(:in_post_deployment_migration?).and_return(true)
end
- it 'registers no offense' do
+ it "registers no offense" do
inspect_source(source)
expect(cop.offenses.size).to eq(0)
end
end
- context 'outside of a migration' do
- it 'registers no offense' do
+ context "outside of a migration" do
+ it "registers no offense" do
inspect_source(source)
expect(cop.offenses.size).to eq(0)
diff --git a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb
index a23d5d022e3..7ce6f8c39d8 100644
--- a/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb
+++ b/spec/rubocop/cop/migration/remove_concurrent_index_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/remove_concurrent_index'
+require_relative "../../../../rubocop/cop/migration/remove_concurrent_index"
describe RuboCop::Cop::Migration::RemoveConcurrentIndex do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when remove_concurrent_index is used inside a change method' do
- inspect_source('def change; remove_concurrent_index :table, :column; end')
+ it "registers an offense when remove_concurrent_index is used inside a change method" do
+ inspect_source("def change; remove_concurrent_index :table, :column; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -24,16 +24,16 @@ describe RuboCop::Cop::Migration::RemoveConcurrentIndex do
end
end
- it 'registers no offense when remove_concurrent_index is used inside an up method' do
- inspect_source('def up; remove_concurrent_index :table, :column; end')
+ it "registers no offense when remove_concurrent_index is used inside an up method" do
+ inspect_source("def up; remove_concurrent_index :table, :column; end")
expect(cop.offenses.size).to eq(0)
end
end
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; remove_concurrent_index :table, :column; end')
+ context "outside of migration" do
+ it "registers no offense" do
+ inspect_source("def change; remove_concurrent_index :table, :column; end")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/migration/remove_index_spec.rb b/spec/rubocop/cop/migration/remove_index_spec.rb
index bbf2227e512..c678554f1df 100644
--- a/spec/rubocop/cop/migration/remove_index_spec.rb
+++ b/spec/rubocop/cop/migration/remove_index_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/remove_index'
+require_relative "../../../../rubocop/cop/migration/remove_index"
describe RuboCop::Cop::Migration::RemoveIndex do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when remove_index is used' do
- inspect_source('def change; remove_index :table, :column; end')
+ it "registers an offense when remove_index is used" do
+ inspect_source("def change; remove_index :table, :column; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -25,9 +25,9 @@ describe RuboCop::Cop::Migration::RemoveIndex do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; remove_index :table, :column; end')
+ context "outside of migration" do
+ it "registers no offense" do
+ inspect_source("def change; remove_index :table, :column; end")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb b/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb
index ba8cd2c6c4a..e4fba697340 100644
--- a/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb
+++ b/spec/rubocop/cop/migration/reversible_add_column_with_default_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/reversible_add_column_with_default'
+require_relative "../../../../rubocop/cop/migration/reversible_add_column_with_default"
describe RuboCop::Cop::Migration::ReversibleAddColumnWithDefault do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- it 'registers an offense when add_column_with_default is used inside a change method' do
- inspect_source('def change; add_column_with_default :table, :column, default: false; end')
+ it "registers an offense when add_column_with_default is used inside a change method" do
+ inspect_source("def change; add_column_with_default :table, :column, default: false; end")
aggregate_failures do
expect(cop.offenses.size).to eq(1)
@@ -24,16 +24,16 @@ describe RuboCop::Cop::Migration::ReversibleAddColumnWithDefault do
end
end
- it 'registers no offense when add_column_with_default is used inside an up method' do
- inspect_source('def up; add_column_with_default :table, :column, default: false; end')
+ it "registers no offense when add_column_with_default is used inside an up method" do
+ inspect_source("def up; add_column_with_default :table, :column, default: false; end")
expect(cop.offenses.size).to eq(0)
end
end
- context 'outside of migration' do
- it 'registers no offense' do
- inspect_source('def change; add_column_with_default :table, :column, default: false; end')
+ context "outside of migration" do
+ it "registers no offense" do
+ inspect_source("def change; add_column_with_default :table, :column, default: false; end")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb
index 1c4f18fbcc3..f9795f04969 100644
--- a/spec/rubocop/cop/migration/safer_boolean_column_spec.rb
+++ b/spec/rubocop/cop/migration/safer_boolean_column_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/safer_boolean_column'
+require_relative "../../../../rubocop/cop/migration/safer_boolean_column"
describe RuboCop::Cop::Migration::SaferBooleanColumn do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
@@ -18,15 +18,15 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do
described_class::SMALL_TABLES.each do |table|
context "for the #{table} table" do
sources_and_offense = [
- ["add_column :#{table}, :column, :boolean, default: true", 'should disallow nulls'],
- ["add_column :#{table}, :column, :boolean, default: false", 'should disallow nulls'],
- ["add_column :#{table}, :column, :boolean, default: nil", 'should have a default and should disallow nulls'],
- ["add_column :#{table}, :column, :boolean, null: false", 'should have a default'],
- ["add_column :#{table}, :column, :boolean, null: true", 'should have a default and should disallow nulls'],
- ["add_column :#{table}, :column, :boolean", 'should have a default and should disallow nulls'],
- ["add_column :#{table}, :column, :boolean, default: nil, null: false", 'should have a default'],
- ["add_column :#{table}, :column, :boolean, default: nil, null: true", 'should have a default and should disallow nulls'],
- ["add_column :#{table}, :column, :boolean, default: false, null: true", 'should disallow nulls']
+ ["add_column :#{table}, :column, :boolean, default: true", "should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean, default: false", "should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean, default: nil", "should have a default and should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean, null: false", "should have a default"],
+ ["add_column :#{table}, :column, :boolean, null: true", "should have a default and should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean", "should have a default and should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean, default: nil, null: false", "should have a default"],
+ ["add_column :#{table}, :column, :boolean, default: nil, null: true", "should have a default and should disallow nulls"],
+ ["add_column :#{table}, :column, :boolean, default: false, null: true", "should disallow nulls"],
]
sources_and_offense.each do |source, offense|
@@ -43,7 +43,7 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do
inoffensive_sources = [
"add_column :#{table}, :column, :boolean, default: true, null: false",
- "add_column :#{table}, :column, :boolean, default: false, null: false"
+ "add_column :#{table}, :column, :boolean, default: false, null: false",
]
inoffensive_sources.each do |source|
@@ -60,13 +60,13 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do
end
end
- it 'registers no offense for tables not listed in SMALL_TABLES' do
+ it "registers no offense for tables not listed in SMALL_TABLES" do
inspect_source("add_column :large_table, :column, :boolean")
expect(cop.offenses).to be_empty
end
- it 'registers no offense for non-boolean columns' do
+ it "registers no offense for non-boolean columns" do
table = described_class::SMALL_TABLES.sample
inspect_source("add_column :#{table}, :column, :string")
@@ -74,8 +74,8 @@ describe RuboCop::Cop::Migration::SaferBooleanColumn do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
+ context "outside of migration" do
+ it "registers no offense" do
table = described_class::SMALL_TABLES.sample
inspect_source("add_column :#{table}, :column, :boolean")
diff --git a/spec/rubocop/cop/migration/timestamps_spec.rb b/spec/rubocop/cop/migration/timestamps_spec.rb
index 1812818692a..223d7a547a6 100644
--- a/spec/rubocop/cop/migration/timestamps_spec.rb
+++ b/spec/rubocop/cop/migration/timestamps_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/timestamps'
+require_relative "../../../../rubocop/cop/migration/timestamps"
describe RuboCop::Cop::Migration::Timestamps do
include CopHelper
subject(:cop) { described_class.new }
let(:migration_with_timestamps) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -22,11 +22,11 @@ describe RuboCop::Cop::Migration::Timestamps do
end
end
end
- )
+ '
end
let(:migration_without_timestamps) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -37,11 +37,11 @@ describe RuboCop::Cop::Migration::Timestamps do
end
end
end
- )
+ '
end
let(:migration_with_timestamps_with_timezone) do
- %q(
+ '
class Users < ActiveRecord::Migration[4.2]
DOWNTIME = false
@@ -53,10 +53,10 @@ describe RuboCop::Cop::Migration::Timestamps do
end
end
end
- )
+ '
end
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
@@ -87,8 +87,8 @@ describe RuboCop::Cop::Migration::Timestamps do
end
end
- context 'outside of migration' do
- it 'registers no offense' do
+ context "outside of migration" do
+ it "registers no offense" do
inspect_source(migration_with_timestamps)
inspect_source(migration_without_timestamps)
inspect_source(migration_with_timestamps_with_timezone)
diff --git a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb
index 1c8ab0ad5d2..ed3d5c7ae5f 100644
--- a/spec/rubocop/cop/migration/update_column_in_batches_spec.rb
+++ b/spec/rubocop/cop/migration/update_column_in_batches_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/update_column_in_batches'
+require_relative "../../../../rubocop/cop/migration/update_column_in_batches"
describe RuboCop::Cop::Migration::UpdateColumnInBatches do
let(:cop) { described_class.new }
- let(:tmp_rails_root) { Rails.root.join('tmp', 'rails_root') }
+ let(:tmp_rails_root) { Rails.root.join("tmp", "rails_root") }
let(:migration_code) do
<<-END
def up
@@ -25,32 +25,32 @@ describe RuboCop::Cop::Migration::UpdateColumnInBatches do
FileUtils.rm_rf(tmp_rails_root)
end
- context 'outside of a migration' do
- it 'does not register any offenses' do
+ context "outside of a migration" do
+ it "does not register any offenses" do
inspect_source(migration_code)
expect(cop.offenses).to be_empty
end
end
- let(:spec_filepath) { tmp_rails_root.join('spec', 'migrations', 'my_super_migration_spec.rb') }
+ let(:spec_filepath) { tmp_rails_root.join("spec", "migrations", "my_super_migration_spec.rb") }
- shared_context 'with a migration file' do
+ shared_context "with a migration file" do
before do
FileUtils.mkdir_p(File.dirname(migration_filepath))
- @migration_file = File.new(migration_filepath, 'w+')
+ @migration_file = File.new(migration_filepath, "w+")
end
after do
@migration_file.close
end
end
- shared_examples 'a migration file with no spec file' do
- include_context 'with a migration file'
+ shared_examples "a migration file with no spec file" do
+ include_context "with a migration file"
let(:relative_spec_filepath) { Pathname.new(spec_filepath).relative_path_from(tmp_rails_root) }
- it 'registers an offense when using update_column_in_batches' do
+ it "registers an offense when using update_column_in_batches" do
inspect_source(migration_code, @migration_file)
aggregate_failures do
@@ -62,35 +62,35 @@ describe RuboCop::Cop::Migration::UpdateColumnInBatches do
end
end
- shared_examples 'a migration file with a spec file' do
- include_context 'with a migration file'
+ shared_examples "a migration file with a spec file" do
+ include_context "with a migration file"
before do
FileUtils.mkdir_p(File.dirname(spec_filepath))
- @spec_file = File.new(spec_filepath, 'w+')
+ @spec_file = File.new(spec_filepath, "w+")
end
after do
@spec_file.close
end
- it 'does not register any offenses' do
+ it "does not register any offenses" do
inspect_source(migration_code, @migration_file)
expect(cop.offenses).to be_empty
end
end
- context 'in a migration' do
- let(:migration_filepath) { tmp_rails_root.join('db', 'migrate', '20121220064453_my_super_migration.rb') }
+ context "in a migration" do
+ let(:migration_filepath) { tmp_rails_root.join("db", "migrate", "20121220064453_my_super_migration.rb") }
- it_behaves_like 'a migration file with no spec file'
- it_behaves_like 'a migration file with a spec file'
+ it_behaves_like "a migration file with no spec file"
+ it_behaves_like "a migration file with a spec file"
end
- context 'in a post migration' do
- let(:migration_filepath) { tmp_rails_root.join('db', 'post_migrate', '20121220064453_my_super_migration.rb') }
+ context "in a post migration" do
+ let(:migration_filepath) { tmp_rails_root.join("db", "post_migrate", "20121220064453_my_super_migration.rb") }
- it_behaves_like 'a migration file with no spec file'
- it_behaves_like 'a migration file with a spec file'
+ it_behaves_like "a migration file with no spec file"
+ it_behaves_like "a migration file with a spec file"
end
end
diff --git a/spec/rubocop/cop/migration/update_large_table_spec.rb b/spec/rubocop/cop/migration/update_large_table_spec.rb
index 5e08eb4f772..c02ef63bd2c 100644
--- a/spec/rubocop/cop/migration/update_large_table_spec.rb
+++ b/spec/rubocop/cop/migration/update_large_table_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/migration/update_large_table'
+require_relative "../../../../rubocop/cop/migration/update_large_table"
describe RuboCop::Cop::Migration::UpdateLargeTable do
include CopHelper
subject(:cop) { described_class.new }
- context 'in migration' do
+ context "in migration" do
before do
allow(cop).to receive(:in_migration?).and_return(true)
end
- shared_examples 'large tables' do |update_method|
+ shared_examples "large tables" do |update_method|
described_class::LARGE_TABLES.each do |table|
it "registers an offense for the #{table} table" do
inspect_source("#{update_method} :#{table}, :column, default: true")
@@ -28,29 +28,29 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do
end
end
- context 'for the add_column_with_default method' do
- include_examples 'large tables', 'add_column_with_default'
+ context "for the add_column_with_default method" do
+ include_examples "large tables", "add_column_with_default"
end
- context 'for the change_column_type_concurrently method' do
- include_examples 'large tables', 'change_column_type_concurrently'
+ context "for the change_column_type_concurrently method" do
+ include_examples "large tables", "change_column_type_concurrently"
end
- context 'for the rename_column_concurrently method' do
- include_examples 'large tables', 'rename_column_concurrently'
+ context "for the rename_column_concurrently method" do
+ include_examples "large tables", "rename_column_concurrently"
end
- context 'for the update_column_in_batches method' do
- include_examples 'large tables', 'update_column_in_batches'
+ context "for the update_column_in_batches method" do
+ include_examples "large tables", "update_column_in_batches"
end
- it 'registers no offense for non-blacklisted tables' do
+ it "registers no offense for non-blacklisted tables" do
inspect_source("add_column_with_default :table, :column, default: true")
expect(cop.offenses).to be_empty
end
- it 'registers no offense for non-blacklisted methods' do
+ it "registers no offense for non-blacklisted methods" do
table = described_class::LARGE_TABLES.sample
inspect_source("some_other_method :#{table}, :column, default: true")
@@ -59,28 +59,28 @@ describe RuboCop::Cop::Migration::UpdateLargeTable do
end
end
- context 'outside of migration' do
+ context "outside of migration" do
let(:table) { described_class::LARGE_TABLES.sample }
- it 'registers no offense for add_column_with_default' do
+ it "registers no offense for add_column_with_default" do
inspect_source("add_column_with_default :#{table}, :column, default: true")
expect(cop.offenses).to be_empty
end
- it 'registers no offense for change_column_type_concurrently' do
+ it "registers no offense for change_column_type_concurrently" do
inspect_source("change_column_type_concurrently :#{table}, :column, default: true")
expect(cop.offenses).to be_empty
end
- it 'registers no offense for update_column_in_batches' do
+ it "registers no offense for update_column_in_batches" do
inspect_source("rename_column_concurrently :#{table}, :column, default: true")
expect(cop.offenses).to be_empty
end
- it 'registers no offense for update_column_in_batches' do
+ it "registers no offense for update_column_in_batches" do
inspect_source("add_column_with_default :#{table}, :column, default: true")
expect(cop.offenses).to be_empty
diff --git a/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb b/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
index 4739f0e6c47..5c8236d588b 100644
--- a/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
+++ b/spec/rubocop/cop/prefer_class_methods_over_module_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/prefer_class_methods_over_module'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/prefer_class_methods_over_module"
describe RuboCop::Cop::PreferClassMethodsOverModule do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags violation when using module ClassMethods' do
+ it "flags violation when using module ClassMethods" do
expect_offense(<<~RUBY)
module Foo
extend ActiveSupport::Concern
@@ -70,7 +70,7 @@ describe RuboCop::Cop::PreferClassMethodsOverModule do
RUBY
end
- it 'autocorrects ClassMethods into class_methods' do
+ it "autocorrects ClassMethods into class_methods" do
source = <<~RUBY
module Foo
extend ActiveSupport::Concern
diff --git a/spec/rubocop/cop/project_path_helper_spec.rb b/spec/rubocop/cop/project_path_helper_spec.rb
index 84e6eb7d87f..6f62834f1c8 100644
--- a/spec/rubocop/cop/project_path_helper_spec.rb
+++ b/spec/rubocop/cop/project_path_helper_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../rubocop/cop/project_path_helper'
+require_relative "../../../rubocop/cop/project_path_helper"
describe RuboCop::Cop::ProjectPathHelper do
include CopHelper
@@ -11,29 +11,29 @@ describe RuboCop::Cop::ProjectPathHelper do
subject(:cop) { described_class.new }
context "when using namespace_project with the project's namespace" do
- let(:source) { 'edit_namespace_project_issue_path(@issue.project.namespace, @issue.project, @issue)' }
- let(:correct_source) { 'edit_project_issue_path(@issue.project, @issue)' }
+ let(:source) { "edit_namespace_project_issue_path(@issue.project.namespace, @issue.project, @issue)" }
+ let(:correct_source) { "edit_project_issue_path(@issue.project, @issue)" }
- it 'registers an offense' do
+ it "registers an offense" do
inspect_source(source)
aggregate_failures do
expect(cop.offenses.size).to eq(1)
expect(cop.offenses.map(&:line)).to eq([1])
- expect(cop.highlights).to eq(['edit_namespace_project_issue_path'])
+ expect(cop.highlights).to eq(["edit_namespace_project_issue_path"])
end
end
- it 'autocorrects to the right version' do
+ it "autocorrects to the right version" do
autocorrected = autocorrect_source(source)
expect(autocorrected).to eq(correct_source)
end
end
- context 'when using namespace_project with a different namespace' do
- it 'registers no offense' do
- inspect_source('edit_namespace_project_issue_path(namespace, project)')
+ context "when using namespace_project with a different namespace" do
+ it "registers no offense" do
+ inspect_source("edit_namespace_project_issue_path(namespace, project)")
expect(cop.offenses.size).to eq(0)
end
diff --git a/spec/rubocop/cop/qa/element_with_pattern_spec.rb b/spec/rubocop/cop/qa/element_with_pattern_spec.rb
index c5beb40f9fd..7fa9c43f840 100644
--- a/spec/rubocop/cop/qa/element_with_pattern_spec.rb
+++ b/spec/rubocop/cop/qa/element_with_pattern_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/qa/element_with_pattern'
+require_relative "../../../../rubocop/cop/qa/element_with_pattern"
describe RuboCop::Cop::QA::ElementWithPattern do
include CopHelper
- let(:source_file) { 'qa/page.rb' }
+ let(:source_file) { "qa/page.rb" }
subject(:cop) { described_class.new }
- context 'in a QA file' do
+ context "in a QA file" do
before do
allow(cop).to receive(:in_qa_file?).and_return(true)
end
@@ -38,7 +38,7 @@ describe RuboCop::Cop::QA::ElementWithPattern do
end
end
- context 'outside of a migration spec file' do
+ context "outside of a migration spec file" do
it "does not register an offense" do
expect_no_offenses(<<-RUBY)
describe 'foo' do
diff --git a/spec/rubocop/cop/rspec/env_assignment_spec.rb b/spec/rubocop/cop/rspec/env_assignment_spec.rb
index 659633f6467..feb3d31548e 100644
--- a/spec/rubocop/cop/rspec/env_assignment_spec.rb
+++ b/spec/rubocop/cop/rspec/env_assignment_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/rspec/env_assignment'
+require_relative "../../../../rubocop/cop/rspec/env_assignment"
describe RuboCop::Cop::RSpec::EnvAssignment do
include CopHelper
@@ -11,11 +11,11 @@ describe RuboCop::Cop::RSpec::EnvAssignment do
OFFENSE_CALL_SINGLE_QUOTES_KEY = %(ENV['FOO'] = 'bar').freeze
OFFENSE_CALL_DOUBLE_QUOTES_KEY = %(ENV["FOO"] = 'bar').freeze
- let(:source_file) { 'spec/foo_spec.rb' }
+ let(:source_file) { "spec/foo_spec.rb" }
subject(:cop) { described_class.new }
- shared_examples 'an offensive ENV#[]= call' do |content|
+ shared_examples "an offensive ENV#[]= call" do |content|
it "registers an offense for `#{content}`" do
inspect_source(content, source_file)
@@ -25,7 +25,7 @@ describe RuboCop::Cop::RSpec::EnvAssignment do
end
end
- shared_examples 'an autocorrected ENV#[]= call' do |content, autocorrected_content|
+ shared_examples "an autocorrected ENV#[]= call" do |content, autocorrected_content|
it "registers an offense for `#{content}` and autocorrects it to `#{autocorrected_content}`" do
autocorrected = autocorrect_source(content, source_file)
@@ -33,23 +33,23 @@ describe RuboCop::Cop::RSpec::EnvAssignment do
end
end
- context 'in a spec file' do
+ context "in a spec file" do
before do
allow(cop).to receive(:in_spec?).and_return(true)
end
- context 'with a key using single quotes' do
- it_behaves_like 'an offensive ENV#[]= call', OFFENSE_CALL_SINGLE_QUOTES_KEY
- it_behaves_like 'an autocorrected ENV#[]= call', OFFENSE_CALL_SINGLE_QUOTES_KEY, %(stub_env('FOO', 'bar'))
+ context "with a key using single quotes" do
+ it_behaves_like "an offensive ENV#[]= call", OFFENSE_CALL_SINGLE_QUOTES_KEY
+ it_behaves_like "an autocorrected ENV#[]= call", OFFENSE_CALL_SINGLE_QUOTES_KEY, %(stub_env('FOO', 'bar'))
end
- context 'with a key using double quotes' do
- it_behaves_like 'an offensive ENV#[]= call', OFFENSE_CALL_DOUBLE_QUOTES_KEY
- it_behaves_like 'an autocorrected ENV#[]= call', OFFENSE_CALL_DOUBLE_QUOTES_KEY, %(stub_env("FOO", 'bar'))
+ context "with a key using double quotes" do
+ it_behaves_like "an offensive ENV#[]= call", OFFENSE_CALL_DOUBLE_QUOTES_KEY
+ it_behaves_like "an autocorrected ENV#[]= call", OFFENSE_CALL_DOUBLE_QUOTES_KEY, %(stub_env("FOO", 'bar'))
end
end
- context 'outside of a spec file' do
+ context "outside of a spec file" do
it "does not register an offense for `#{OFFENSE_CALL_SINGLE_QUOTES_KEY}` in a non-spec file" do
inspect_source(OFFENSE_CALL_SINGLE_QUOTES_KEY)
diff --git a/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
index 2763f2bda21..77a93ffb3a5 100644
--- a/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
+++ b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../../rubocop/cop/rspec/factories_in_migration_specs'
+require_relative "../../../../rubocop/cop/rspec/factories_in_migration_specs"
describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs do
include CopHelper
- let(:source_file) { 'spec/migrations/foo_spec.rb' }
+ let(:source_file) { "spec/migrations/foo_spec.rb" }
subject(:cop) { described_class.new }
- shared_examples 'an offensive factory call' do |namespace|
+ shared_examples "an offensive factory call" do |namespace|
%i[build build_list create create_list].each do |forbidden_method|
namespaced_forbidden_method = "#{namespace}#{forbidden_method}(:user)"
@@ -20,23 +20,23 @@ describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs do
expect_offense(<<-RUBY)
describe 'foo' do
let(:user) { #{namespaced_forbidden_method} }
- #{'^' * namespaced_forbidden_method.size} Don't use FactoryBot.#{forbidden_method} in migration specs, use `table` instead.
+ #{"^" * namespaced_forbidden_method.size} Don't use FactoryBot.#{forbidden_method} in migration specs, use `table` instead.
end
RUBY
end
end
end
- context 'in a migration spec file' do
+ context "in a migration spec file" do
before do
allow(cop).to receive(:in_migration_spec?).and_return(true)
end
- it_behaves_like 'an offensive factory call', ''
- it_behaves_like 'an offensive factory call', 'FactoryBot.'
+ it_behaves_like "an offensive factory call", ""
+ it_behaves_like "an offensive factory call", "FactoryBot."
end
- context 'outside of a migration spec file' do
+ context "outside of a migration spec file" do
it "does not register an offense" do
expect_no_offenses(<<-RUBY)
describe 'foo' do
diff --git a/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb b/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb
index 7bd50866577..1a55e95727a 100644
--- a/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb
+++ b/spec/rubocop/cop/ruby_interpolation_in_translation_spec.rb
@@ -1,24 +1,24 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../rubocop/cop/ruby_interpolation_in_translation'
+require_relative "../../../rubocop/cop/ruby_interpolation_in_translation"
# Disabling interpolation check as we deliberately want to have #{} in strings.
# rubocop:disable Lint/InterpolationCheck
describe RuboCop::Cop::RubyInterpolationInTranslation do
subject(:cop) { described_class.new }
- it 'does not add an offence for a regular messages' do
+ it "does not add an offence for a regular messages" do
inspect_source('_("Hello world")')
expect(cop.offenses).to be_empty
end
- it 'adds the correct offence when using interpolation in a string' do
+ it "adds the correct offence when using interpolation in a string" do
inspect_source('_("Hello #{world}")')
offense = cop.offenses.first
@@ -27,25 +27,25 @@ describe RuboCop::Cop::RubyInterpolationInTranslation do
expect(offense.message).to eq('Don\'t use ruby interpolation #{} inside translated strings, instead use %{}')
end
- it 'detects when using a ruby interpolation in the first argument of a pluralized string' do
+ it "detects when using a ruby interpolation in the first argument of a pluralized string" do
inspect_source('n_("Hello #{world}", "Hello world")')
expect(cop.offenses).not_to be_empty
end
- it 'detects when using a ruby interpolation in the second argument of a pluralized string' do
+ it "detects when using a ruby interpolation in the second argument of a pluralized string" do
inspect_source('n_("Hello world", "Hello #{world}")')
expect(cop.offenses).not_to be_empty
end
- it 'detects when using interpolation in a namespaced translation' do
+ it "detects when using interpolation in a namespaced translation" do
inspect_source('s_("Hello|#{world}")')
expect(cop.offenses).not_to be_empty
end
- it 'does not add an offence for messages defined over multiple lines' do
+ it "does not add an offence for messages defined over multiple lines" do
source = <<~SRC
_("Hello "\
"world ")
@@ -55,7 +55,7 @@ describe RuboCop::Cop::RubyInterpolationInTranslation do
expect(cop.offenses).to be_empty
end
- it 'adds an offence for violations in a message defined over multiple lines' do
+ it "adds an offence for violations in a message defined over multiple lines" do
source = <<~SRC
_("Hello "\
"\#{world} ")
diff --git a/spec/rubocop/cop/safe_params_spec.rb b/spec/rubocop/cop/safe_params_spec.rb
index 4f02b8e9008..7ad32e8dde9 100644
--- a/spec/rubocop/cop/safe_params_spec.rb
+++ b/spec/rubocop/cop/safe_params_spec.rb
@@ -1,37 +1,37 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require 'rubocop/rspec/support'
-require_relative '../../../rubocop/cop/safe_params'
+require "spec_helper"
+require "rubocop"
+require "rubocop/rspec/support"
+require_relative "../../../rubocop/cop/safe_params"
describe RuboCop::Cop::SafeParams do
include CopHelper
subject(:cop) { described_class.new }
- it 'flags the params as an argument of url_for' do
+ it "flags the params as an argument of url_for" do
expect_offense(<<~SOURCE)
url_for(params)
^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
- it 'flags the merged params as an argument of url_for' do
+ it "flags the merged params as an argument of url_for" do
expect_offense(<<~SOURCE)
url_for(params.merge(additional_params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
- it 'flags the merged params arg as an argument of url_for' do
+ it "flags the merged params arg as an argument of url_for" do
expect_offense(<<~SOURCE)
url_for(something.merge(additional).merge(params))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `safe_params` instead of `params` in url_for.
SOURCE
end
- it 'does not flag other argument of url_for' do
+ it "does not flag other argument of url_for" do
expect_no_offenses(<<~SOURCE)
url_for(something)
SOURCE
diff --git a/spec/rubocop/cop/sidekiq_options_queue_spec.rb b/spec/rubocop/cop/sidekiq_options_queue_spec.rb
index 7f237d5ffbb..e5fb89c62d2 100644
--- a/spec/rubocop/cop/sidekiq_options_queue_spec.rb
+++ b/spec/rubocop/cop/sidekiq_options_queue_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-require 'rubocop'
-require 'rubocop/rspec/support'
+require "rubocop"
+require "rubocop/rspec/support"
-require_relative '../../../rubocop/cop/sidekiq_options_queue'
+require_relative "../../../rubocop/cop/sidekiq_options_queue"
describe RuboCop::Cop::SidekiqOptionsQueue do
include CopHelper
subject(:cop) { described_class.new }
- it 'registers an offense when `sidekiq_options` is used with the `queue` option' do
+ it "registers an offense when `sidekiq_options` is used with the `queue` option" do
inspect_source('sidekiq_options queue: "some_queue"')
aggregate_failures do
@@ -20,8 +20,8 @@ describe RuboCop::Cop::SidekiqOptionsQueue do
end
end
- it 'does not register an offense when `sidekiq_options` is used with another option' do
- inspect_source('sidekiq_options retry: false')
+ it "does not register an offense when `sidekiq_options` is used with another option" do
+ inspect_source("sidekiq_options retry: false")
expect(cop.offenses).to be_empty
end
diff --git a/spec/rubocop/qa_helpers_spec.rb b/spec/rubocop/qa_helpers_spec.rb
index 26e4c1ca6f0..4eaf882b876 100644
--- a/spec/rubocop/qa_helpers_spec.rb
+++ b/spec/rubocop/qa_helpers_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rubocop'
-require_relative '../../rubocop/qa_helpers'
+require "spec_helper"
+require "rubocop"
+require_relative "../../rubocop/qa_helpers"
describe RuboCop::QAHelpers do
- def parse_source(source, path = 'foo.rb')
+ def parse_source(source, path = "foo.rb")
buffer = Parser::Source::Buffer.new(path)
buffer.source = source
@@ -16,20 +16,20 @@ describe RuboCop::QAHelpers do
end
let(:cop) do
- Class.new do
+ Class.new {
include RuboCop::QAHelpers
- end.new
+ }.new
end
- describe '#in_qa_file?' do
- it 'returns true for a node in the qa/ directory' do
- node = parse_source('10', Rails.root.join('qa', 'qa', 'page', 'dashboard', 'groups.rb'))
+ describe "#in_qa_file?" do
+ it "returns true for a node in the qa/ directory" do
+ node = parse_source("10", Rails.root.join("qa", "qa", "page", "dashboard", "groups.rb"))
expect(cop.in_qa_file?(node)).to eq(true)
end
- it 'returns false for a node outside the qa/ directory' do
- node = parse_source('10', Rails.root.join('app', 'foo', 'foo.rb'))
+ it "returns false for a node outside the qa/ directory" do
+ node = parse_source("10", Rails.root.join("app", "foo", "foo.rb"))
expect(cop.in_qa_file?(node)).to eq(false)
end
diff --git a/spec/serializers/analytics_build_entity_spec.rb b/spec/serializers/analytics_build_entity_spec.rb
index 1ff4908972a..413bc906f56 100644
--- a/spec/serializers/analytics_build_entity_spec.rb
+++ b/spec/serializers/analytics_build_entity_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsBuildEntity do
let(:entity) do
described_class.new(build, request: double)
end
- context 'build with an author' do
+ context "build with an author" do
let(:user) { create(:user) }
let(:started_at) { 2.hours.ago }
let(:finished_at) { 1.hour.ago }
@@ -17,73 +17,73 @@ describe AnalyticsBuildEntity do
Timecop.freeze { example.run }
end
- it 'contains the URL' do
+ it "contains the URL" do
expect(subject).to include(:url)
end
- it 'contains the author' do
+ it "contains the author" do
expect(subject).to include(:author)
end
- it 'does not contain sensitive information' do
+ it "does not contain sensitive information" do
expect(subject).not_to include(/token/)
expect(subject).not_to include(/variables/)
end
- it 'contains the right started at' do
- expect(subject[:date]).to eq('about 2 hours ago')
+ it "contains the right started at" do
+ expect(subject[:date]).to eq("about 2 hours ago")
end
- it 'contains the duration' do
- expect(subject[:total_time]).to eq(hours: 1 )
+ it "contains the duration" do
+ expect(subject[:total_time]).to eq(hours: 1)
end
- context 'no started at or finished at date' do
+ context "no started at or finished at date" do
let(:started_at) { nil }
let(:finished_at) { nil }
- it 'does not blow up' do
+ it "does not blow up" do
expect { subject[:date] }.not_to raise_error
end
- it 'shows the right message' do
- expect(subject[:date]).to eq('Not started')
+ it "shows the right message" do
+ expect(subject[:date]).to eq("Not started")
end
- it 'shows the right total time' do
+ it "shows the right total time" do
expect(subject[:total_time]).to eq({})
end
end
- context 'no started at date' do
+ context "no started at date" do
let(:started_at) { nil }
- it 'does not blow up' do
+ it "does not blow up" do
expect { subject[:date] }.not_to raise_error
end
- it 'shows the right message' do
- expect(subject[:date]).to eq('Not started')
+ it "shows the right message" do
+ expect(subject[:date]).to eq("Not started")
end
- it 'shows the right total time' do
+ it "shows the right total time" do
expect(subject[:total_time]).to eq({})
end
end
- context 'no finished at date' do
+ context "no finished at date" do
let(:finished_at) { nil }
- it 'does not blow up' do
+ it "does not blow up" do
expect { subject[:date] }.not_to raise_error
end
- it 'shows the right message' do
- expect(subject[:date]).to eq('about 2 hours ago')
+ it "shows the right message" do
+ expect(subject[:date]).to eq("about 2 hours ago")
end
- it 'shows the right total time' do
- expect(subject[:total_time]).to eq({ hours: 2 })
+ it "shows the right total time" do
+ expect(subject[:total_time]).to eq({hours: 2})
end
end
end
diff --git a/spec/serializers/analytics_build_serializer_spec.rb b/spec/serializers/analytics_build_serializer_spec.rb
index e3b1dd93dc2..ad80ca78add 100644
--- a/spec/serializers/analytics_build_serializer_spec.rb
+++ b/spec/serializers/analytics_build_serializer_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsBuildSerializer do
let(:resource) { create(:ci_build) }
subject { described_class.new.represent(resource) }
- context 'when there is a single object provided' do
- it 'contains important elements of analyticsBuild' do
+ context "when there is a single object provided" do
+ it "contains important elements of analyticsBuild" do
expect(subject)
.to include(:name, :branch, :short_sha, :date, :total_time, :url, :author)
end
diff --git a/spec/serializers/analytics_issue_entity_spec.rb b/spec/serializers/analytics_issue_entity_spec.rb
index 89588b4df2b..23f9816b263 100644
--- a/spec/serializers/analytics_issue_entity_spec.rb
+++ b/spec/serializers/analytics_issue_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsIssueEntity do
let(:user) { create(:user) }
@@ -9,7 +9,7 @@ describe AnalyticsIssueEntity do
iid: "1",
id: "1",
created_at: "2016-11-12 15:04:02.948604",
- author: user
+ author: user,
}
end
@@ -20,18 +20,18 @@ describe AnalyticsIssueEntity do
described_class.new(entity_hash, request: request, project: project)
end
- context 'generic entity' do
+ context "generic entity" do
subject { entity.as_json }
- it 'contains the entity URL' do
+ it "contains the entity URL" do
expect(subject).to include(:url)
end
- it 'contains the author' do
+ it "contains the author" do
expect(subject).to include(:author)
end
- it 'does not contain sensitive information' do
+ it "does not contain sensitive information" do
expect(subject).not_to include(/token/)
expect(subject).not_to include(/variables/)
end
diff --git a/spec/serializers/analytics_issue_serializer_spec.rb b/spec/serializers/analytics_issue_serializer_spec.rb
index 5befc28f4fa..5852adb627f 100644
--- a/spec/serializers/analytics_issue_serializer_spec.rb
+++ b/spec/serializers/analytics_issue_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsIssueSerializer do
subject do
@@ -16,12 +16,12 @@ describe AnalyticsIssueSerializer do
iid: "1",
id: "1",
created_at: "2016-11-12 15:04:02.948604",
- author: user
+ author: user,
}
end
- context 'when there is a single object provided' do
- it 'contains important elements of the issue' do
+ context "when there is a single object provided" do
+ it "contains important elements of the issue" do
expect(subject).to include(:title, :iid, :created_at, :total_time, :url, :author)
end
end
diff --git a/spec/serializers/analytics_merge_request_serializer_spec.rb b/spec/serializers/analytics_merge_request_serializer_spec.rb
index 62067cc0ef2..9112cec1e93 100644
--- a/spec/serializers/analytics_merge_request_serializer_spec.rb
+++ b/spec/serializers/analytics_merge_request_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsMergeRequestSerializer do
subject do
@@ -15,14 +15,14 @@ describe AnalyticsMergeRequestSerializer do
title: "Eos voluptatem inventore in sed.",
iid: "1",
id: "1",
- state: 'open',
+ state: "open",
created_at: "2016-11-12 15:04:02.948604",
- author: user
+ author: user,
}
end
- context 'when there is a single object provided' do
- it 'contains important elements of the merge request' do
+ context "when there is a single object provided" do
+ it "contains important elements of the merge request" do
expect(subject).to include(:title, :iid, :created_at, :total_time, :url, :author, :state)
end
end
diff --git a/spec/serializers/analytics_stage_serializer_spec.rb b/spec/serializers/analytics_stage_serializer_spec.rb
index be6aa7c65c3..aa843e11df7 100644
--- a/spec/serializers/analytics_stage_serializer_spec.rb
+++ b/spec/serializers/analytics_stage_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsStageSerializer do
subject do
@@ -14,11 +14,11 @@ describe AnalyticsStageSerializer do
allow_any_instance_of(Gitlab::CycleAnalytics::BaseEventFetcher).to receive(:event_result).and_return({})
end
- it 'it generates payload for single object' do
+ it "it generates payload for single object" do
expect(subject).to be_kind_of Hash
end
- it 'contains important elements of AnalyticsStage' do
+ it "contains important elements of AnalyticsStage" do
expect(subject).to include(:title, :description, :value)
end
end
diff --git a/spec/serializers/analytics_summary_serializer_spec.rb b/spec/serializers/analytics_summary_serializer_spec.rb
index 236c244b402..74d6656a913 100644
--- a/spec/serializers/analytics_summary_serializer_spec.rb
+++ b/spec/serializers/analytics_summary_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AnalyticsSummarySerializer do
subject do
@@ -18,11 +18,11 @@ describe AnalyticsSummarySerializer do
.to receive(:value).and_return(1.12)
end
- it 'it generates payload for single object' do
+ it "it generates payload for single object" do
expect(subject).to be_kind_of Hash
end
- it 'contains important elements of AnalyticsStage' do
+ it "contains important elements of AnalyticsStage" do
expect(subject).to include(:title, :value)
end
end
diff --git a/spec/serializers/blob_entity_spec.rb b/spec/serializers/blob_entity_spec.rb
index dde59ff72df..7217285cb16 100644
--- a/spec/serializers/blob_entity_spec.rb
+++ b/spec/serializers/blob_entity_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe BlobEntity do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:blob) { project.commit('master').diffs.diff_files.first.blob }
- let(:request) { EntityRequest.new(project: project, ref: 'master') }
+ let(:blob) { project.commit("master").diffs.diff_files.first.blob }
+ let(:request) { EntityRequest.new(project: project, ref: "master") }
let(:entity) do
described_class.new(blob, request: request)
end
- context 'as json' do
+ context "as json" do
subject { entity.as_json }
- it 'exposes needed attributes' do
+ it "exposes needed attributes" do
expect(subject).to include(:readable_text, :url)
end
end
diff --git a/spec/serializers/build_action_entity_spec.rb b/spec/serializers/build_action_entity_spec.rb
index ea88951ebc6..de8433e66cf 100644
--- a/spec/serializers/build_action_entity_spec.rb
+++ b/spec/serializers/build_action_entity_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildActionEntity do
- let(:job) { create(:ci_build, name: 'test_job') }
- let(:request) { double('request') }
+ let(:job) { create(:ci_build, name: "test_job") }
+ let(:request) { double("request") }
let(:entity) do
- described_class.new(job, request: spy('request'))
+ described_class.new(job, request: spy("request"))
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains original job name' do
- expect(subject[:name]).to eq 'test_job'
+ it "contains original job name" do
+ expect(subject[:name]).to eq "test_job"
end
- it 'contains path to the action play' do
+ it "contains path to the action play" do
expect(subject[:path]).to include "jobs/#{job.id}/play"
end
- it 'contains whether it is playable' do
+ it "contains whether it is playable" do
expect(subject[:playable]).to eq job.playable?
end
- context 'when job is scheduled' do
+ context "when job is scheduled" do
let(:job) { create(:ci_build, :scheduled) }
- it 'returns scheduled' do
+ it "returns scheduled" do
expect(subject[:scheduled]).to be_truthy
end
- it 'returns scheduled_at' do
+ it "returns scheduled_at" do
expect(subject[:scheduled_at]).to eq(job.scheduled_at)
end
- it 'returns unschedule path' do
+ it "returns unschedule path" do
expect(subject[:unschedule_path]).to include "jobs/#{job.id}/unschedule"
end
end
diff --git a/spec/serializers/build_artifact_entity_spec.rb b/spec/serializers/build_artifact_entity_spec.rb
index ad0d3d3839e..51e425de38a 100644
--- a/spec/serializers/build_artifact_entity_spec.rb
+++ b/spec/serializers/build_artifact_entity_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildArtifactEntity do
- let(:job) { create(:ci_build, name: 'test:job', artifacts_expire_at: 1.hour.from_now) }
+ let(:job) { create(:ci_build, name: "test:job", artifacts_expire_at: 1.hour.from_now) }
let(:entity) do
described_class.new(job, request: double)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains job name' do
- expect(subject[:name]).to eq 'test:job'
+ it "contains job name" do
+ expect(subject[:name]).to eq "test:job"
end
- it 'exposes information about expiration of artifacts' do
+ it "exposes information about expiration of artifacts" do
expect(subject).to include(:expired, :expire_at)
end
- it 'contains paths to the artifacts' do
+ it "contains paths to the artifacts" do
expect(subject[:path])
.to include "jobs/#{job.id}/artifacts/download"
diff --git a/spec/serializers/build_details_entity_spec.rb b/spec/serializers/build_details_entity_spec.rb
index f6bd6e9ede4..01e0e15f777 100644
--- a/spec/serializers/build_details_entity_spec.rb
+++ b/spec/serializers/build_details_entity_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildDetailsEntity do
include ProjectForksHelper
set(:user) { create(:admin) }
- it 'inherits from JobEntity' do
+ it "inherits from JobEntity" do
expect(described_class).to be < JobEntity
end
- describe '#as_json' do
+ describe "#as_json" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:build) { create(:ci_build, :failed, pipeline: pipeline) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:entity) do
described_class.new(build, request: request,
@@ -27,14 +27,14 @@ describe BuildDetailsEntity do
allow(request).to receive(:current_user).and_return(user)
end
- it 'contains the needed key value pairs' do
+ it "contains the needed key value pairs" do
expect(subject).to include(:coverage, :erased_at, :duration)
expect(subject).to include(:runner, :pipeline)
expect(subject).to include(:raw_path, :new_issue_path)
end
- context 'when the user has access to issues and merge requests' do
- context 'when merge request orginates from the same project' do
+ context "when the user has access to issues and merge requests" do
+ context "when merge request orginates from the same project" do
let(:merge_request) do
create(:merge_request, source_project: project, source_branch: build.ref)
end
@@ -43,21 +43,21 @@ describe BuildDetailsEntity do
allow(build).to receive(:merge_request).and_return(merge_request)
end
- it 'contains the needed key value pairs' do
+ it "contains the needed key value pairs" do
expect(subject).to include(:merge_request)
expect(subject).to include(:new_issue_path)
end
- it 'exposes correct details of the merge request' do
+ it "exposes correct details of the merge request" do
expect(subject[:merge_request][:iid]).to eq merge_request.iid
end
- it 'has a correct merge request path' do
+ it "has a correct merge request path" do
expect(subject[:merge_request][:path]).to include project.full_path
end
end
- context 'when merge request is from a fork' do
+ context "when merge request is from a fork" do
let(:forked_project) { fork_project(project) }
let(:pipeline) { create(:ci_pipeline, project: forked_project) }
@@ -72,44 +72,44 @@ describe BuildDetailsEntity do
source_branch: build.ref)
end
- it 'contains the needed key value pairs' do
+ it "contains the needed key value pairs" do
expect(subject).to include(:merge_request)
expect(subject).to include(:new_issue_path)
end
- it 'exposes details of the merge request' do
+ it "exposes details of the merge request" do
expect(subject[:merge_request][:iid]).to eq merge_request.iid
end
- it 'has a merge request path to a target project' do
+ it "has a merge request path to a target project" do
expect(subject[:merge_request][:path])
.to include project.full_path
end
end
- context 'when the build has not been erased' do
+ context "when the build has not been erased" do
let(:build) { create(:ci_build, :erasable, project: project) }
- it 'exposes a build erase path' do
+ it "exposes a build erase path" do
expect(subject).to include(:erase_path)
end
end
- context 'when the build has been erased' do
+ context "when the build has been erased" do
let(:build) { create(:ci_build, :erased, project: project) }
- it 'exposes the user who erased the build' do
+ it "exposes the user who erased the build" do
expect(subject).to include(:erased_by)
end
end
end
- context 'when the user can only read the build' do
+ context "when the user can only read the build" do
let(:user) { create(:user) }
it "won't display the paths to issues and merge requests" do
- expect(subject['new_issue_path']).to be_nil
- expect(subject['merge_request_path']).to be_nil
+ expect(subject["new_issue_path"]).to be_nil
+ expect(subject["merge_request_path"]).to be_nil
end
end
end
diff --git a/spec/serializers/build_serializer_spec.rb b/spec/serializers/build_serializer_spec.rb
index 302ef147eb2..eb5974c634d 100644
--- a/spec/serializers/build_serializer_spec.rb
+++ b/spec/serializers/build_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildSerializer do
let(:user) { create(:user) }
@@ -9,50 +9,50 @@ describe BuildSerializer do
subject { serializer.represent(resource) }
- describe '#represent' do
- context 'when a single object is being serialized' do
+ describe "#represent" do
+ context "when a single object is being serialized" do
let(:resource) { create(:ci_build) }
- it 'serializers the pipeline object' do
+ it "serializers the pipeline object" do
expect(subject[:id]).to eq resource.id
end
end
- context 'when multiple objects are being serialized' do
+ context "when multiple objects are being serialized" do
let(:resource) { create_list(:ci_build, 2) }
- it 'serializers the array of pipelines' do
+ it "serializers the array of pipelines" do
expect(subject).not_to be_empty
end
end
end
- describe '#represent_status' do
- context 'for a failed build' do
+ describe "#represent_status" do
+ context "for a failed build" do
let(:resource) { create(:ci_build, :failed) }
- let(:status) { resource.detailed_status(double('user')) }
+ let(:status) { resource.detailed_status(double("user")) }
subject { serializer.represent_status(resource) }
- it 'serializes only status' do
+ it "serializes only status" do
expect(subject[:text]).to eq(status.text)
- expect(subject[:label]).to eq('failed')
- expect(subject[:tooltip]).to eq('failed - (unknown failure)')
+ expect(subject[:label]).to eq("failed")
+ expect(subject[:tooltip]).to eq("failed - (unknown failure)")
expect(subject[:icon]).to eq(status.icon)
expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png")
end
end
- context 'for any other type of build' do
+ context "for any other type of build" do
let(:resource) { create(:ci_build, :success) }
- let(:status) { resource.detailed_status(double('user')) }
+ let(:status) { resource.detailed_status(double("user")) }
subject { serializer.represent_status(resource) }
- it 'serializes only status' do
+ it "serializes only status" do
expect(subject[:text]).to eq(status.text)
- expect(subject[:label]).to eq('passed')
- expect(subject[:tooltip]).to eq('passed')
+ expect(subject[:label]).to eq("passed")
+ expect(subject[:tooltip]).to eq("passed")
expect(subject[:icon]).to eq(status.icon)
expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.png")
end
diff --git a/spec/serializers/cluster_application_entity_spec.rb b/spec/serializers/cluster_application_entity_spec.rb
index 7e151c3744e..4de49eab006 100644
--- a/spec/serializers/cluster_application_entity_spec.rb
+++ b/spec/serializers/cluster_application_entity_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterApplicationEntity do
- describe '#as_json' do
- let(:application) { build(:clusters_applications_helm, version: '0.1.1') }
+ describe "#as_json" do
+ let(:application) { build(:clusters_applications_helm, version: "0.1.1") }
subject { described_class.new(application).as_json }
- it 'has name' do
+ it "has name" do
expect(subject[:name]).to eq(application.name)
end
- it 'has status' do
+ it "has status" do
expect(subject[:status]).to eq(:not_installable)
end
- it 'has version' do
- expect(subject[:version]).to eq('0.1.1')
+ it "has version" do
+ expect(subject[:version]).to eq("0.1.1")
end
- it 'has no status_reason' do
+ it "has no status_reason" do
expect(subject[:status_reason]).to be_nil
end
- context 'non-helm application' do
- let(:application) { build(:clusters_applications_runner, version: '0.0.0') }
+ context "non-helm application" do
+ let(:application) { build(:clusters_applications_runner, version: "0.0.0") }
- it 'has update_available' do
+ it "has update_available" do
expect(subject[:update_available]).to be_truthy
end
end
- context 'when application is errored' do
+ context "when application is errored" do
let(:application) { build(:clusters_applications_helm, :errored) }
- it 'has corresponded data' do
+ it "has corresponded data" do
expect(subject[:status]).to eq(:errored)
expect(subject[:status_reason]).not_to be_nil
expect(subject[:status_reason]).to eq(application.status_reason)
end
end
- context 'for ingress application' do
+ context "for ingress application" do
let(:application) do
build(
:clusters_applications_ingress,
:installed,
- external_ip: '111.222.111.222'
+ external_ip: "111.222.111.222"
)
end
- it 'includes external_ip' do
- expect(subject[:external_ip]).to eq('111.222.111.222')
+ it "includes external_ip" do
+ expect(subject[:external_ip]).to eq("111.222.111.222")
end
end
end
diff --git a/spec/serializers/cluster_entity_spec.rb b/spec/serializers/cluster_entity_spec.rb
index d6a43fd0f00..46483def809 100644
--- a/spec/serializers/cluster_entity_spec.rb
+++ b/spec/serializers/cluster_entity_spec.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterEntity do
- describe '#as_json' do
+ describe "#as_json" do
subject { described_class.new(cluster).as_json }
- context 'when provider type is gcp' do
+ context "when provider type is gcp" do
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
- context 'when status is creating' do
+ context "when status is creating" do
let(:provider) { create(:cluster_provider_gcp, :creating) }
- it 'has corresponded data' do
+ it "has corresponded data" do
expect(subject[:status]).to eq(:creating)
expect(subject[:status_reason]).to be_nil
end
end
- context 'when status is errored' do
+ context "when status is errored" do
let(:provider) { create(:cluster_provider_gcp, :errored) }
- it 'has corresponded data' do
+ it "has corresponded data" do
expect(subject[:status]).to eq(:errored)
expect(subject[:status_reason]).to eq(provider.status_reason)
end
end
end
- context 'when provider type is user' do
+ context "when provider type is user" do
let(:cluster) { create(:cluster, provider_type: :user) }
- it 'has corresponded data' do
+ it "has corresponded data" do
expect(subject[:status]).to eq(:created)
expect(subject[:status_reason]).to be_nil
end
end
- context 'when no application has been installed' do
+ context "when no application has been installed" do
let(:cluster) { create(:cluster) }
subject { described_class.new(cluster).as_json[:applications]}
- it 'contains helm as not_installable' do
+ it "contains helm as not_installable" do
expect(subject).not_to be_empty
helm = subject[0]
- expect(helm[:name]).to eq('helm')
+ expect(helm[:name]).to eq("helm")
expect(helm[:status]).to eq(:not_installable)
end
end
diff --git a/spec/serializers/cluster_serializer_spec.rb b/spec/serializers/cluster_serializer_spec.rb
index 5e9f7a45891..f6eaf0b9ce3 100644
--- a/spec/serializers/cluster_serializer_spec.rb
+++ b/spec/serializers/cluster_serializer_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterSerializer do
- describe '#represent_status' do
+ describe "#represent_status" do
subject { described_class.new.represent_status(cluster) }
- context 'when provider type is gcp' do
+ context "when provider type is gcp" do
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
let(:provider) { create(:cluster_provider_gcp, :errored) }
- it 'serializes only status' do
+ it "serializes only status" do
expect(subject.keys).to contain_exactly(:status, :status_reason, :applications)
end
end
- context 'when provider type is user' do
+ context "when provider type is user" do
let(:cluster) { create(:cluster, provider_type: :user) }
- it 'serializes only status' do
+ it "serializes only status" do
expect(subject.keys).to contain_exactly(:status, :status_reason, :applications)
end
end
diff --git a/spec/serializers/commit_entity_spec.rb b/spec/serializers/commit_entity_spec.rb
index b9995818e98..8be8a91a8be 100644
--- a/spec/serializers/commit_entity_spec.rb
+++ b/spec/serializers/commit_entity_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe CommitEntity do
- SIGNATURE_HTML = 'TEST'.freeze
+ SIGNATURE_HTML = "TEST".freeze
let(:entity) do
described_class.new(commit, request: request)
end
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
subject { entity.as_json }
before do
- render = double('render')
+ render = double("render")
allow(render).to receive(:call).and_return(SIGNATURE_HTML)
allow(request).to receive(:project).and_return(project)
allow(request).to receive(:render).and_return(render)
end
- context 'when commit author is a user' do
+ context "when commit author is a user" do
before do
create(:user, email: commit.author_email)
end
- it 'contains information about user' do
+ it "contains information about user" do
expect(subject.fetch(:author)).not_to be_nil
end
end
- context 'when commit author is not a user' do
- it 'does not contain author details' do
+ context "when commit author is not a user" do
+ it "does not contain author details" do
expect(subject.fetch(:author)).to be_nil
end
end
- it 'contains path to commit' do
+ it "contains path to commit" do
expect(subject).to include(:commit_path)
expect(subject[:commit_path]).to include "commit/#{commit.id}"
end
- it 'contains URL to commit' do
+ it "contains URL to commit" do
expect(subject).to include(:commit_url)
expect(subject[:commit_path]).to include "commit/#{commit.id}"
end
- it 'needs to receive project in the request' do
+ it "needs to receive project in the request" do
expect(request).to receive(:project)
.and_return(project)
subject
end
- it 'exposes gravatar url that belongs to author' do
+ it "exposes gravatar url that belongs to author" do
expect(subject.fetch(:author_gravatar_url)).to match /gravatar/
end
- context 'when type is not set' do
- it 'does not expose extra properties' do
+ context "when type is not set" do
+ it "does not expose extra properties" do
expect(subject).not_to include(:description_html)
expect(subject).not_to include(:title_html)
end
@@ -69,15 +69,15 @@ describe CommitEntity do
described_class.new(commit, request: request, type: :full, pipeline_ref: project.default_branch, pipeline_project: project)
end
- it 'exposes extra properties' do
+ it "exposes extra properties" do
expect(subject).to include(:description_html)
expect(subject).to include(:title_html)
expect(subject.fetch(:description_html)).not_to be_nil
expect(subject.fetch(:title_html)).not_to be_nil
end
- context 'when commit has signature' do
- let(:commit) { project.commit(TestEnv::BRANCH_SHA['signed-commits']) }
+ context "when commit has signature" do
+ let(:commit) { project.commit(TestEnv::BRANCH_SHA["signed-commits"]) }
it 'exposes "signature_html"' do
expect(request.render).to receive(:call)
@@ -85,7 +85,7 @@ describe CommitEntity do
end
end
- context 'when commit has pipeline' do
+ context "when commit has pipeline" do
before do
create(:ci_pipeline, project: project, sha: commit.id)
end
@@ -96,14 +96,14 @@ describe CommitEntity do
end
end
- context 'when commit_url_params is set' do
+ context "when commit_url_params is set" do
let(:entity) do
- params = { merge_request_iid: 3 }
+ params = {merge_request_iid: 3}
described_class.new(commit, request: request, commit_url_params: params)
end
- it 'adds commit_url_params to url and path' do
+ it "adds commit_url_params to url and path" do
expect(subject[:commit_path]).to include "?merge_request_iid=3"
expect(subject[:commit_url]).to include "?merge_request_iid=3"
end
diff --git a/spec/serializers/container_repository_entity_spec.rb b/spec/serializers/container_repository_entity_spec.rb
index 15466bce514..a1c8d9a7f02 100644
--- a/spec/serializers/container_repository_entity_spec.rb
+++ b/spec/serializers/container_repository_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerRepositoryEntity do
let(:entity) do
@@ -9,7 +9,7 @@ describe ContainerRepositoryEntity do
set(:user) { create(:user) }
set(:repository) { create(:container_repository, project: project) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
subject { entity.as_json }
@@ -19,22 +19,22 @@ describe ContainerRepositoryEntity do
allow(request).to receive(:current_user).and_return(user)
end
- it 'exposes required informations' do
+ it "exposes required informations" do
expect(subject).to include(:id, :path, :location, :tags_path)
end
- context 'when user can manage repositories' do
+ context "when user can manage repositories" do
before do
project.add_developer(user)
end
- it 'exposes destroy_path' do
+ it "exposes destroy_path" do
expect(subject).to include(:destroy_path)
end
end
- context 'when user cannot manage repositories' do
- it 'does not expose destroy_path' do
+ context "when user cannot manage repositories" do
+ it "does not expose destroy_path" do
expect(subject).not_to include(:destroy_path)
end
end
diff --git a/spec/serializers/container_tag_entity_spec.rb b/spec/serializers/container_tag_entity_spec.rb
index ceb828a1cc5..4bcb0678791 100644
--- a/spec/serializers/container_tag_entity_spec.rb
+++ b/spec/serializers/container_tag_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ContainerTagEntity do
let(:entity) do
@@ -7,10 +7,10 @@ describe ContainerTagEntity do
set(:project) { create(:project) }
set(:user) { create(:user) }
- set(:repository) { create(:container_repository, name: 'image', project: project) }
+ set(:repository) { create(:container_repository, name: "image", project: project) }
- let(:request) { double('request') }
- let(:tag) { repository.tag('test') }
+ let(:request) { double("request") }
+ let(:tag) { repository.tag("test") }
subject { entity.as_json }
@@ -21,22 +21,22 @@ describe ContainerTagEntity do
allow(request).to receive(:current_user).and_return(user)
end
- it 'exposes required informations' do
+ it "exposes required informations" do
expect(subject).to include(:name, :location, :revision, :short_revision, :total_size, :created_at)
end
- context 'when user can manage repositories' do
+ context "when user can manage repositories" do
before do
project.add_developer(user)
end
- it 'exposes destroy_path' do
+ it "exposes destroy_path" do
expect(subject).to include(:destroy_path)
end
end
- context 'when user cannot manage repositories' do
- it 'does not expose destroy_path' do
+ context "when user cannot manage repositories" do
+ it "does not expose destroy_path" do
expect(subject).not_to include(:destroy_path)
end
end
diff --git a/spec/serializers/deploy_key_entity_spec.rb b/spec/serializers/deploy_key_entity_spec.rb
index 01264cf7fb5..07f1521facf 100644
--- a/spec/serializers/deploy_key_entity_spec.rb
+++ b/spec/serializers/deploy_key_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployKeyEntity do
include RequestAwareEntity
@@ -14,7 +14,7 @@ describe DeployKeyEntity do
let(:entity) { described_class.new(deploy_key, user: user) }
- describe 'returns deploy keys with projects a user can read' do
+ describe "returns deploy keys with projects a user can read" do
let(:expected_result) do
{
id: deploy_key.id,
@@ -34,17 +34,17 @@ describe DeployKeyEntity do
id: project.id,
name: project.name,
full_path: project_path(project),
- full_name: project.full_name
- }
- }
- ]
+ full_name: project.full_name,
+ },
+ },
+ ],
}
end
it { expect(entity.as_json).to eq(expected_result) }
end
- describe 'returns can_edit true if user is a maintainer of project' do
+ describe "returns can_edit true if user is a maintainer of project" do
before do
project.add_maintainer(user)
end
@@ -52,7 +52,7 @@ describe DeployKeyEntity do
it { expect(entity.as_json).to include(can_edit: true) }
end
- describe 'returns can_edit true if a user admin' do
+ describe "returns can_edit true if a user admin" do
let(:user) { create(:user, :admin) }
it { expect(entity.as_json).to include(can_edit: true) }
diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb
index 894fd7a0a12..925999e84bb 100644
--- a/spec/serializers/deployment_entity_spec.rb
+++ b/spec/serializers/deployment_entity_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe DeploymentEntity do
let(:user) { developer }
let(:developer) { create(:user) }
let(:reporter) { create(:user) }
let(:project) { create(:project) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:deployment) { create(:deployment, deployable: build, project: project) }
let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
@@ -19,53 +19,53 @@ describe DeploymentEntity do
allow(request).to receive(:project).and_return(project)
end
- it 'exposes internal deployment id' do
+ it "exposes internal deployment id" do
expect(subject).to include(:iid)
end
- it 'exposes nested information about branch' do
- expect(subject[:ref][:name]).to eq 'master'
+ it "exposes nested information about branch" do
+ expect(subject[:ref][:name]).to eq "master"
end
- it 'exposes creation date' do
+ it "exposes creation date" do
expect(subject).to include(:created_at)
end
- context 'when the pipeline has another manual action' do
- let(:other_build) { create(:ci_build, :manual, name: 'another deploy', pipeline: pipeline) }
+ context "when the pipeline has another manual action" do
+ let(:other_build) { create(:ci_build, :manual, name: "another deploy", pipeline: pipeline) }
let!(:other_deployment) { create(:deployment, deployable: other_build) }
- it 'returns another manual action' do
+ it "returns another manual action" do
expect(subject[:manual_actions].count).to eq(1)
- expect(subject[:manual_actions].first[:name]).to eq('another deploy')
+ expect(subject[:manual_actions].first[:name]).to eq("another deploy")
end
- context 'when user is a reporter' do
+ context "when user is a reporter" do
let(:user) { reporter }
- it 'returns another manual action' do
+ it "returns another manual action" do
expect(subject[:manual_actions]).not_to be_present
end
end
end
- describe 'scheduled_actions' do
+ describe "scheduled_actions" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, user: user) }
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
let(:deployment) { create(:deployment, deployable: build) }
- context 'when the same pipeline has a scheduled action' do
- let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other build') }
+ context "when the same pipeline has a scheduled action" do
+ let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: "other build") }
let!(:other_deployment) { create(:deployment, deployable: other_build) }
- it 'returns other scheduled actions' do
- expect(subject[:scheduled_actions][0][:name]).to eq 'other build'
+ it "returns other scheduled actions" do
+ expect(subject[:scheduled_actions][0][:name]).to eq "other build"
end
end
- context 'when the same pipeline does not have a scheduled action' do
- it 'does not return other actions' do
+ context "when the same pipeline does not have a scheduled action" do
+ it "does not return other actions" do
expect(subject[:scheduled_actions]).to be_empty
end
end
diff --git a/spec/serializers/deployment_serializer_spec.rb b/spec/serializers/deployment_serializer_spec.rb
index 4834f5ede3c..f4f5c150e37 100644
--- a/spec/serializers/deployment_serializer_spec.rb
+++ b/spec/serializers/deployment_serializer_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe DeploymentSerializer do
set(:project) { create(:project, :repository) }
@@ -9,27 +9,27 @@ describe DeploymentSerializer do
let(:resource) { create(:deployment, project: project, sha: project.commit.id) }
let(:serializer) { described_class.new(request) }
- shared_examples 'json schema' do
+ shared_examples "json schema" do
let(:json_entity) { subject.as_json }
- it 'matches deployment entity schema' do
- expect(json_entity).to match_schema('deployment')
+ it "matches deployment entity schema" do
+ expect(json_entity).to match_schema("deployment")
end
end
- describe '#represent' do
+ describe "#represent" do
subject { serializer.represent(resource) }
- let(:request) { { project: project, current_user: user } }
+ let(:request) { {project: project, current_user: user} }
- it_behaves_like 'json schema'
+ it_behaves_like "json schema"
end
- describe '#represent_concise' do
+ describe "#represent_concise" do
subject { serializer.represent_concise(resource) }
- let(:request) { { project: project } }
+ let(:request) { {project: project} }
- it_behaves_like 'json schema'
+ it_behaves_like "json schema"
end
end
diff --git a/spec/serializers/detailed_status_entity_spec.rb b/spec/serializers/detailed_status_entity_spec.rb
index 62f57ca8689..33c70a96a09 100644
--- a/spec/serializers/detailed_status_entity_spec.rb
+++ b/spec/serializers/detailed_status_entity_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe DetailedStatusEntity do
let(:entity) { described_class.new(status) }
let(:status) do
- Gitlab::Ci::Status::Success.new(double('object'), double('user'))
+ Gitlab::Ci::Status::Success.new(double("object"), double("user"))
end
before do
allow(status).to receive(:has_details?).and_return(true)
- allow(status).to receive(:details_path).and_return('some/path')
+ allow(status).to receive(:details_path).and_return("some/path")
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains status details' do
+ it "contains status details" do
expect(subject).to include :text, :icon, :favicon, :label, :group, :tooltip
expect(subject).to include :has_details, :details_path
- expect(subject[:favicon]).to match_asset_path('/assets/ci_favicons/favicon_status_success.png')
+ expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/favicon_status_success.png")
end
end
end
diff --git a/spec/serializers/diff_file_entity_spec.rb b/spec/serializers/diff_file_entity_spec.rb
index 92b649f5b6c..4fdcbd6433c 100644
--- a/spec/serializers/diff_file_entity_spec.rb
+++ b/spec/serializers/diff_file_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffFileEntity do
include RepoHelpers
@@ -13,25 +13,25 @@ describe DiffFileEntity do
subject { entity.as_json }
- context 'when there is no merge request' do
- it_behaves_like 'diff file entity'
+ context "when there is no merge request" do
+ it_behaves_like "diff file entity"
end
- context 'when there is a merge request' do
+ context "when there is a merge request" do
let(:user) { create(:user) }
let(:request) { EntityRequest.new(project: project, current_user: user) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:entity) { described_class.new(diff_file, request: request, merge_request: merge_request) }
- let(:exposed_urls) { %i(edit_path view_path context_lines_path) }
+ let(:exposed_urls) { %i[edit_path view_path context_lines_path] }
- it_behaves_like 'diff file entity'
+ it_behaves_like "diff file entity"
- it 'exposes additional attributes' do
+ it "exposes additional attributes" do
expect(subject).to include(*exposed_urls)
expect(subject).to include(:replaced_view_path)
end
- it 'points all urls to merge request target project' do
+ it "points all urls to merge request target project" do
response = subject
exposed_urls.each do |attribute|
@@ -39,15 +39,15 @@ describe DiffFileEntity do
end
end
- it 'exposes load_collapsed_diff_url if the file viewer is collapsed' do
+ it "exposes load_collapsed_diff_url if the file viewer is collapsed" do
allow(diff_file.viewer).to receive(:collapsed?) { true }
expect(subject).to include(:load_collapsed_diff_url)
end
end
- context '#parallel_diff_lines' do
- it 'exposes parallel diff lines correctly' do
+ context "#parallel_diff_lines" do
+ it "exposes parallel diff lines correctly" do
response = subject
lines = response[:parallel_diff_lines]
@@ -57,8 +57,8 @@ describe DiffFileEntity do
expect(lines.map { |line| line[:left] }.compact).to be_present
# make sure all lines are in correct format
lines.each do |parallel_line|
- expect(parallel_line[:left].as_json).to match_schema('entities/diff_line') if parallel_line[:left]
- expect(parallel_line[:right].as_json).to match_schema('entities/diff_line') if parallel_line[:right]
+ expect(parallel_line[:left].as_json).to match_schema("entities/diff_line") if parallel_line[:left]
+ expect(parallel_line[:right].as_json).to match_schema("entities/diff_line") if parallel_line[:right]
end
end
end
diff --git a/spec/serializers/diff_line_entity_spec.rb b/spec/serializers/diff_line_entity_spec.rb
index 2549f64bcd3..e76cf4aa11b 100644
--- a/spec/serializers/diff_line_entity_spec.rb
+++ b/spec/serializers/diff_line_entity_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe DiffLineEntity do
include RepoHelpers
- let(:code) { 'hello world' }
- let(:line) { Gitlab::Diff::Line.new(code, 'new', 1, nil, 1) }
+ let(:code) { "hello world" }
+ let(:line) { Gitlab::Diff::Line.new(code, "new", 1, nil, 1) }
let(:entity) { described_class.new(line, request: {}) }
subject { entity.as_json }
- it 'exposes correct attributes' do
+ it "exposes correct attributes" do
expect(subject).to include(
:line_code, :type, :old_line, :new_line, :text, :meta_data, :rich_text
)
end
- describe '#rich_text' do
+ describe "#rich_text" do
let(:code) { '<h2 onmouseover="alert(2)">Test</h2>' }
let(:rich_text_value) { nil }
@@ -25,21 +25,21 @@ describe DiffLineEntity do
line.instance_variable_set(:@rich_text, rich_text_value)
end
- shared_examples 'escapes html tags' do
+ shared_examples "escapes html tags" do
it do
expect(subject[:rich_text]).to eq html_escape(code)
expect(subject[:rich_text]).to be_html_safe
end
end
- context 'when rich_line is present' do
+ context "when rich_line is present" do
let(:rich_text_value) { code }
- it_behaves_like 'escapes html tags'
+ it_behaves_like "escapes html tags"
end
- context 'when rich_line is not present' do
- it_behaves_like 'escapes html tags'
+ context "when rich_line is not present" do
+ it_behaves_like "escapes html tags"
end
end
end
diff --git a/spec/serializers/diff_line_serializer_spec.rb b/spec/serializers/diff_line_serializer_spec.rb
index 6dd8abd0579..82980ecf689 100644
--- a/spec/serializers/diff_line_serializer_spec.rb
+++ b/spec/serializers/diff_line_serializer_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffLineSerializer do
- let(:line) { Gitlab::Diff::Line.new('hello world', 'new', 1, nil, 1) }
+ let(:line) { Gitlab::Diff::Line.new("hello world", "new", 1, nil, 1) }
let(:serializer) { described_class.new.represent(line) }
- describe '#to_json' do
+ describe "#to_json" do
subject { serializer.to_json }
- it 'matches the schema' do
- expect(subject).to match_schema('entities/diff_line')
+ it "matches the schema" do
+ expect(subject).to match_schema("entities/diff_line")
end
- context 'when lines are parallel' do
- let(:right_line) { Gitlab::Diff::Line.new('right line', 'new', 1, nil, 1) }
- let(:left_line) { Gitlab::Diff::Line.new('left line', 'match', 1, nil, 1) }
- let(:parallel_line) { [{ right: right_line, left: left_line }] }
+ context "when lines are parallel" do
+ let(:right_line) { Gitlab::Diff::Line.new("right line", "new", 1, nil, 1) }
+ let(:left_line) { Gitlab::Diff::Line.new("left line", "match", 1, nil, 1) }
+ let(:parallel_line) { [{right: right_line, left: left_line}] }
let(:serializer) { described_class.new.represent(parallel_line, {}, DiffLineParallelEntity) }
- it 'matches the schema' do
- expect(subject).to match_schema('entities/diff_line_parallel')
+ it "matches the schema" do
+ expect(subject).to match_schema("entities/diff_line_parallel")
end
end
end
diff --git a/spec/serializers/diff_viewer_entity_spec.rb b/spec/serializers/diff_viewer_entity_spec.rb
index 66ac6ef2adc..42835079f4c 100644
--- a/spec/serializers/diff_viewer_entity_spec.rb
+++ b/spec/serializers/diff_viewer_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffViewerEntity do
include RepoHelpers
@@ -13,7 +13,7 @@ describe DiffViewerEntity do
subject { described_class.new(viewer).as_json }
- it 'serializes diff file viewer' do
- expect(subject.with_indifferent_access).to match_schema('entities/diff_viewer')
+ it "serializes diff file viewer" do
+ expect(subject.with_indifferent_access).to match_schema("entities/diff_viewer")
end
end
diff --git a/spec/serializers/diffs_entity_spec.rb b/spec/serializers/diffs_entity_spec.rb
index 19a843b0cb7..abbd521aad7 100644
--- a/spec/serializers/diffs_entity_spec.rb
+++ b/spec/serializers/diffs_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiffsEntity do
let(:user) { create(:user) }
@@ -11,10 +11,10 @@ describe DiffsEntity do
described_class.new(merge_request_diffs.first.diffs, request: request, merge_request: merge_request, merge_request_diffs: merge_request_diffs)
end
- context 'as json' do
+ context "as json" do
subject { entity.as_json }
- it 'contains needed attributes' do
+ it "contains needed attributes" do
expect(subject).to include(
:real_size, :size, :branch_name,
:target_branch_name, :commit, :merge_request_diff,
diff --git a/spec/serializers/discussion_diff_file_entity_spec.rb b/spec/serializers/discussion_diff_file_entity_spec.rb
index 101ac918a98..5d5d90c1cc1 100644
--- a/spec/serializers/discussion_diff_file_entity_spec.rb
+++ b/spec/serializers/discussion_diff_file_entity_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe DiscussionDiffFileEntity do
include RepoHelpers
@@ -15,25 +15,25 @@ describe DiscussionDiffFileEntity do
subject { entity.as_json }
- context 'when there is no merge request' do
- it_behaves_like 'diff file discussion entity'
+ context "when there is no merge request" do
+ it_behaves_like "diff file discussion entity"
end
- context 'when there is a merge request' do
+ context "when there is a merge request" do
let(:user) { create(:user) }
let(:request) { EntityRequest.new(project: project, current_user: user) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:entity) { described_class.new(diff_file, request: request, merge_request: merge_request) }
- it_behaves_like 'diff file discussion entity'
+ it_behaves_like "diff file discussion entity"
- it 'exposes additional attributes' do
+ it "exposes additional attributes" do
expect(subject).to include(:edit_path)
end
- it 'exposes no diff lines' do
+ it "exposes no diff lines" do
expect(subject).not_to include(:highlighted_diff_lines,
- :parallel_diff_lines)
+ :parallel_diff_lines)
end
end
end
diff --git a/spec/serializers/discussion_entity_spec.rb b/spec/serializers/discussion_entity_spec.rb
index 138749b0fdf..c51fc619335 100644
--- a/spec/serializers/discussion_entity_spec.rb
+++ b/spec/serializers/discussion_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DiscussionEntity do
include RepoHelpers
@@ -6,8 +6,8 @@ describe DiscussionEntity do
let(:user) { create(:user) }
let(:note) { create(:discussion_note_on_merge_request) }
let(:discussion) { note.discussion }
- let(:request) { double('request', note_entity: ProjectNoteEntity) }
- let(:controller) { double('controller') }
+ let(:request) { double("request", note_entity: ProjectNoteEntity) }
+ let(:controller) { double("controller") }
let(:entity) { described_class.new(discussion, request: request, context: controller) }
subject { entity.as_json }
@@ -18,7 +18,7 @@ describe DiscussionEntity do
allow(request).to receive(:noteable).and_return(note.noteable)
end
- it 'exposes correct attributes' do
+ it "exposes correct attributes" do
expect(subject.keys.sort).to include(
:diff_discussion,
:expanded,
@@ -36,19 +36,19 @@ describe DiscussionEntity do
)
end
- it 'resolved_by matches note_user_entity schema' do
+ it "resolved_by matches note_user_entity schema" do
Notes::ResolveService.new(note.project, user).execute(note)
expect(subject[:resolved_by].with_indifferent_access)
- .to match_schema('entities/note_user_entity')
+ .to match_schema("entities/note_user_entity")
end
- context 'when is LegacyDiffDiscussion' do
+ context "when is LegacyDiffDiscussion" do
let(:project) { create(:project) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:discussion) { create(:legacy_diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion }
- it 'exposes correct attributes' do
+ it "exposes correct attributes" do
expect(subject.keys.sort).to include(
:diff_discussion,
:expanded,
@@ -62,10 +62,10 @@ describe DiscussionEntity do
end
end
- context 'when diff file is present' do
+ context "when diff file is present" do
let(:note) { create(:diff_note_on_merge_request) }
- it 'exposes diff file attributes' do
+ it "exposes diff file attributes" do
expect(subject.keys.sort).to include(
:diff_file,
:truncated_diff_lines,
diff --git a/spec/serializers/entity_date_helper_spec.rb b/spec/serializers/entity_date_helper_spec.rb
index ae0f917415c..f9d739fccdc 100644
--- a/spec/serializers/entity_date_helper_spec.rb
+++ b/spec/serializers/entity_date_helper_spec.rb
@@ -1,79 +1,79 @@
-require 'spec_helper'
+require "spec_helper"
describe EntityDateHelper do
let(:date_helper_class) { Class.new { include EntityDateHelper }.new }
- it 'converts 0 seconds' do
+ it "converts 0 seconds" do
expect(date_helper_class.distance_of_time_as_hash(0)).to eq(seconds: 0)
end
- it 'converts 40 seconds' do
+ it "converts 40 seconds" do
expect(date_helper_class.distance_of_time_as_hash(40)).to eq(seconds: 40)
end
- it 'converts 60 seconds' do
+ it "converts 60 seconds" do
expect(date_helper_class.distance_of_time_as_hash(60)).to eq(mins: 1)
end
- it 'converts 70 seconds' do
+ it "converts 70 seconds" do
expect(date_helper_class.distance_of_time_as_hash(70)).to eq(mins: 1, seconds: 10)
end
- it 'converts 3600 seconds' do
+ it "converts 3600 seconds" do
expect(date_helper_class.distance_of_time_as_hash(3600)).to eq(hours: 1)
end
- it 'converts 3750 seconds' do
+ it "converts 3750 seconds" do
expect(date_helper_class.distance_of_time_as_hash(3750)).to eq(hours: 1, mins: 2, seconds: 30)
end
- it 'converts 86400 seconds' do
+ it "converts 86400 seconds" do
expect(date_helper_class.distance_of_time_as_hash(86400)).to eq(days: 1)
end
- it 'converts 86560 seconds' do
+ it "converts 86560 seconds" do
Rails.logger.debug date_helper_class.inspect
expect(date_helper_class.distance_of_time_as_hash(86560)).to eq(days: 1, mins: 2, seconds: 40)
end
- it 'converts 86760 seconds' do
+ it "converts 86760 seconds" do
expect(date_helper_class.distance_of_time_as_hash(99760)).to eq(days: 1, hours: 3, mins: 42, seconds: 40)
end
- it 'converts 986760 seconds' do
+ it "converts 986760 seconds" do
expect(date_helper_class.distance_of_time_as_hash(986760)).to eq(days: 11, hours: 10, mins: 6)
end
- describe '#remaining_days_in_words' do
+ describe "#remaining_days_in_words" do
around do |example|
Timecop.freeze(Time.utc(2017, 3, 17)) { example.run }
end
- context 'when less than 31 days remaining' do
+ context "when less than 31 days remaining" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words(12.days.from_now.utc.to_date) }
- it 'returns days remaining' do
+ it "returns days remaining" do
expect(milestone_remaining).to eq("<strong>12</strong> days remaining")
end
end
- context 'when less than 1 year and more than 30 days remaining' do
+ context "when less than 1 year and more than 30 days remaining" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words(2.months.from_now.utc.to_date) }
- it 'returns months remaining' do
+ it "returns months remaining" do
expect(milestone_remaining).to eq("<strong>2</strong> months remaining")
end
end
- context 'when more than 1 year remaining' do
+ context "when more than 1 year remaining" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words((1.year.from_now + 2.days).utc.to_date) }
- it 'returns years remaining' do
+ it "returns years remaining" do
expect(milestone_remaining).to eq("<strong>1</strong> year remaining")
end
end
- context 'when milestone is expired' do
+ context "when milestone is expired" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words(2.days.ago.utc.to_date) }
it 'returns "Past due"' do
@@ -81,7 +81,7 @@ describe EntityDateHelper do
end
end
- context 'when milestone has start_date in the future' do
+ context "when milestone has start_date in the future" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words(nil, 2.days.from_now.utc.to_date) }
it 'returns "Upcoming"' do
@@ -89,10 +89,10 @@ describe EntityDateHelper do
end
end
- context 'when milestone has start_date in the past' do
+ context "when milestone has start_date in the past" do
let(:milestone_remaining) { date_helper_class.remaining_days_in_words(nil, 2.days.ago.utc.to_date) }
- it 'returns days elapsed' do
+ it "returns days elapsed" do
expect(milestone_remaining).to eq("<strong>2</strong> days elapsed")
end
end
diff --git a/spec/serializers/entity_request_spec.rb b/spec/serializers/entity_request_spec.rb
index 86654adfd54..eef9a983691 100644
--- a/spec/serializers/entity_request_spec.rb
+++ b/spec/serializers/entity_request_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe EntityRequest do
subject do
- described_class.new(user: 'user', project: 'some project')
+ described_class.new(user: "user", project: "some project")
end
- describe 'methods created' do
- it 'defines accessible attributes' do
- expect(subject.user).to eq 'user'
- expect(subject.project).to eq 'some project'
+ describe "methods created" do
+ it "defines accessible attributes" do
+ expect(subject.user).to eq "user"
+ expect(subject.project).to eq "some project"
end
- it 'raises error when attribute is not defined' do
+ it "raises error when attribute is not defined" do
expect { subject.some_method }.to raise_error NoMethodError
end
end
diff --git a/spec/serializers/environment_entity_spec.rb b/spec/serializers/environment_entity_spec.rb
index 791b64dc356..53c1a2e277d 100644
--- a/spec/serializers/environment_entity_spec.rb
+++ b/spec/serializers/environment_entity_spec.rb
@@ -1,27 +1,27 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentEntity do
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:entity) do
- described_class.new(environment, request: spy('request'))
+ described_class.new(environment, request: spy("request"))
end
let(:environment) { create(:environment) }
subject { entity.as_json }
- it 'exposes latest deployment' do
+ it "exposes latest deployment" do
expect(subject).to include(:last_deployment)
end
- it 'exposes core elements of environment' do
+ it "exposes core elements of environment" do
expect(subject).to include(:id, :name, :state, :environment_path)
end
- it 'exposes folder path' do
+ it "exposes folder path" do
expect(subject).to include(:folder_path)
end
- context 'metrics disabled' do
+ context "metrics disabled" do
before do
allow(environment).to receive(:has_metrics?).and_return(false)
end
@@ -31,41 +31,41 @@ describe EnvironmentEntity do
end
end
- context 'metrics enabled' do
+ context "metrics enabled" do
before do
allow(environment).to receive(:has_metrics?).and_return(true)
end
- it 'exposes metrics path' do
+ it "exposes metrics path" do
expect(subject).to include(:metrics_path)
end
end
- context 'with deployment platform' do
+ context "with deployment platform" do
let(:project) { create(:project, :repository) }
let(:environment) { create(:environment, project: project) }
- context 'when deployment platform is a cluster' do
+ context "when deployment platform is a cluster" do
before do
create(:cluster,
- :provided_by_gcp,
- :project,
- environment_scope: '*',
- projects: [project])
+ :provided_by_gcp,
+ :project,
+ environment_scope: "*",
+ projects: [project])
end
- it 'should include cluster_type' do
+ it "should include cluster_type" do
expect(subject).to include(:cluster_type)
- expect(subject[:cluster_type]).to eq('project_type')
+ expect(subject[:cluster_type]).to eq("project_type")
end
end
- context 'when deployment platform is a Kubernetes Service' do
+ context "when deployment platform is a Kubernetes Service" do
before do
create(:kubernetes_service, project: project)
end
- it 'should not include cluster_type' do
+ it "should not include cluster_type" do
expect(subject).not_to include(:cluster_type)
end
end
diff --git a/spec/serializers/environment_serializer_spec.rb b/spec/serializers/environment_serializer_spec.rb
index 375a28a8c72..9e354e9af4a 100644
--- a/spec/serializers/environment_serializer_spec.rb
+++ b/spec/serializers/environment_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentSerializer do
let(:user) { create(:user) }
@@ -14,28 +14,28 @@ describe EnvironmentSerializer do
project.add_developer(user)
end
- context 'when there is a single object provided' do
+ context "when there is a single object provided" do
let(:project) { create(:project, :repository) }
let(:deployable) { create(:ci_build) }
let(:deployment) do
create(:deployment, :success,
- deployable: deployable,
- user: user,
- project: project,
- sha: project.commit.id)
+ deployable: deployable,
+ user: user,
+ project: project,
+ sha: project.commit.id)
end
let(:resource) { deployment.environment }
before do
- create(:ci_build, :manual, name: 'manual1', pipeline: deployable.pipeline)
+ create(:ci_build, :manual, name: "manual1", pipeline: deployable.pipeline)
end
- it 'contains important elements of environment' do
+ it "contains important elements of environment" do
expect(json)
.to include(:name, :external_url, :environment_path, :last_deployment)
end
- it 'contains relevant information about last deployment' do
+ it "contains relevant information about last deployment" do
last_deployment = json.fetch(:last_deployment)
expect(last_deployment)
@@ -43,21 +43,21 @@ describe EnvironmentSerializer do
end
end
- context 'when there is a collection of objects provided' do
+ context "when there is a collection of objects provided" do
let(:project) { create(:project) }
let(:resource) { create_list(:environment, 2) }
- it 'contains important elements of environment' do
+ it "contains important elements of environment" do
expect(json.first)
.to include(:last_deployment, :name, :external_url)
end
- it 'generates payload for collection' do
+ it "generates payload for collection" do
expect(json).to be_an_instance_of Array
end
end
- context 'when representing environments within folders' do
+ context "when representing environments within folders" do
let(:serializer) do
described_class
.new(current_user: user, project: project)
@@ -68,66 +68,66 @@ describe EnvironmentSerializer do
subject { serializer.represent(resource) }
- context 'when there is a single environment' do
+ context "when there is a single environment" do
before do
- create(:environment, name: 'staging')
+ create(:environment, name: "staging")
end
- it 'represents one standalone environment' do
+ it "represents one standalone environment" do
expect(subject.count).to eq 1
- expect(subject.first[:name]).to eq 'staging'
+ expect(subject.first[:name]).to eq "staging"
expect(subject.first[:size]).to eq 1
- expect(subject.first[:latest][:name]).to eq 'staging'
+ expect(subject.first[:latest][:name]).to eq "staging"
end
end
- context 'when there are multiple environments in folder' do
+ context "when there are multiple environments in folder" do
before do
- create(:environment, name: 'staging/my-review-1')
- create(:environment, name: 'staging/my-review-2')
+ create(:environment, name: "staging/my-review-1")
+ create(:environment, name: "staging/my-review-2")
end
- it 'represents one item that is a folder' do
+ it "represents one item that is a folder" do
expect(subject.count).to eq 1
- expect(subject.first[:name]).to eq 'staging'
+ expect(subject.first[:name]).to eq "staging"
expect(subject.first[:size]).to eq 2
- expect(subject.first[:latest][:name]).to eq 'staging/my-review-2'
- expect(subject.first[:latest][:environment_type]).to eq 'staging'
+ expect(subject.first[:latest][:name]).to eq "staging/my-review-2"
+ expect(subject.first[:latest][:environment_type]).to eq "staging"
end
end
- context 'when there are multiple folders and standalone environments' do
+ context "when there are multiple folders and standalone environments" do
before do
- create(:environment, name: 'staging/my-review-1')
- create(:environment, name: 'staging/my-review-2')
- create(:environment, name: 'production/my-review-3')
- create(:environment, name: 'testing')
+ create(:environment, name: "staging/my-review-1")
+ create(:environment, name: "staging/my-review-2")
+ create(:environment, name: "production/my-review-3")
+ create(:environment, name: "testing")
end
- it 'represents multiple items grouped within folders' do
+ it "represents multiple items grouped within folders" do
expect(subject.count).to eq 3
- expect(subject.first[:name]).to eq 'production'
+ expect(subject.first[:name]).to eq "production"
expect(subject.first[:size]).to eq 1
- expect(subject.first[:latest][:name]).to eq 'production/my-review-3'
- expect(subject.first[:latest][:environment_type]).to eq 'production'
- expect(subject.second[:name]).to eq 'staging'
+ expect(subject.first[:latest][:name]).to eq "production/my-review-3"
+ expect(subject.first[:latest][:environment_type]).to eq "production"
+ expect(subject.second[:name]).to eq "staging"
expect(subject.second[:size]).to eq 2
- expect(subject.second[:latest][:name]).to eq 'staging/my-review-2'
- expect(subject.second[:latest][:environment_type]).to eq 'staging'
- expect(subject.third[:name]).to eq 'testing'
+ expect(subject.second[:latest][:name]).to eq "staging/my-review-2"
+ expect(subject.second[:latest][:environment_type]).to eq "staging"
+ expect(subject.third[:name]).to eq "testing"
expect(subject.third[:size]).to eq 1
- expect(subject.third[:latest][:name]).to eq 'testing'
+ expect(subject.third[:latest][:name]).to eq "testing"
expect(subject.third[:latest][:environment_type]).to be_nil
end
end
end
- context 'when used with pagination' do
+ context "when used with pagination" do
let(:request) { double(url: "#{Gitlab.config.gitlab.url}:8080/api/v4/projects?#{query.to_query}", query_parameters: query) }
- let(:response) { spy('response') }
+ let(:response) { spy("response") }
let(:resource) { Environment.all }
- let(:query) { { page: 1, per_page: 2 } }
+ let(:query) { {page: 1, per_page: 2} }
let(:serializer) do
described_class
@@ -137,40 +137,40 @@ describe EnvironmentSerializer do
subject { serializer.represent(resource) }
- it 'creates a paginated serializer' do
+ it "creates a paginated serializer" do
expect(serializer).to be_paginated
end
- context 'when resource is paginatable relation' do
- context 'when there is a single environment object in relation' do
+ context "when resource is paginatable relation" do
+ context "when there is a single environment object in relation" do
before do
create(:environment)
end
- it 'serializes environments' do
+ it "serializes environments" do
expect(subject.first).to have_key :id
end
end
- context 'when multiple environment objects are serialized' do
+ context "when multiple environment objects are serialized" do
before do
create_list(:environment, 3)
end
- it 'serializes appropriate number of objects' do
+ it "serializes appropriate number of objects" do
expect(subject.count).to be 2
end
- it 'appends relevant headers' do
- expect(response).to receive(:[]=).with('X-Total', '3')
- expect(response).to receive(:[]=).with('X-Total-Pages', '2')
- expect(response).to receive(:[]=).with('X-Per-Page', '2')
+ it "appends relevant headers" do
+ expect(response).to receive(:[]=).with("X-Total", "3")
+ expect(response).to receive(:[]=).with("X-Total-Pages", "2")
+ expect(response).to receive(:[]=).with("X-Per-Page", "2")
subject
end
end
- context 'when grouping environments within folders' do
+ context "when grouping environments within folders" do
let(:serializer) do
described_class
.new(current_user: user, project: project)
@@ -179,27 +179,27 @@ describe EnvironmentSerializer do
end
before do
- create(:environment, name: 'staging/review-1')
- create(:environment, name: 'staging/review-2')
- create(:environment, name: 'production/deploy-3')
- create(:environment, name: 'testing')
+ create(:environment, name: "staging/review-1")
+ create(:environment, name: "staging/review-2")
+ create(:environment, name: "production/deploy-3")
+ create(:environment, name: "testing")
end
- it 'paginates grouped items including ordering' do
+ it "paginates grouped items including ordering" do
expect(subject.count).to eq 2
- expect(subject.first[:name]).to eq 'production'
- expect(subject.second[:name]).to eq 'staging'
+ expect(subject.first[:name]).to eq "production"
+ expect(subject.second[:name]).to eq "staging"
end
- it 'appends correct total page count header' do
+ it "appends correct total page count header" do
expect(subject).not_to be_empty
- expect(response).to have_received(:[]=).with('X-Total', '3')
+ expect(response).to have_received(:[]=).with("X-Total", "3")
end
- it 'appends correct page count headers' do
+ it "appends correct page count headers" do
expect(subject).not_to be_empty
- expect(response).to have_received(:[]=).with('X-Total-Pages', '2')
- expect(response).to have_received(:[]=).with('X-Per-Page', '2')
+ expect(response).to have_received(:[]=).with("X-Total-Pages", "2")
+ expect(response).to have_received(:[]=).with("X-Per-Page", "2")
end
end
end
diff --git a/spec/serializers/environment_status_entity_spec.rb b/spec/serializers/environment_status_entity_spec.rb
index 8a6a38fe5f8..491e9df3274 100644
--- a/spec/serializers/environment_status_entity_spec.rb
+++ b/spec/serializers/environment_status_entity_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe EnvironmentStatusEntity do
let(:user) { create(:user) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:deployment) { create(:deployment, :succeed, :review_app) }
let(:environment) { deployment.environment }
@@ -33,7 +33,7 @@ describe EnvironmentStatusEntity do
it { is_expected.not_to include(:metrics_url) }
it { is_expected.not_to include(:metrics_monitoring_url) }
- context 'when the user is project maintainer' do
+ context "when the user is project maintainer" do
before do
project.add_maintainer(user)
end
@@ -41,14 +41,14 @@ describe EnvironmentStatusEntity do
it { is_expected.to include(:stop_url) }
end
- context 'when deployment has metrics' do
- let(:prometheus_adapter) { double('prometheus_adapter', can_query?: true) }
+ context "when deployment has metrics" do
+ let(:prometheus_adapter) { double("prometheus_adapter", can_query?: true) }
let(:simple_metrics) do
{
success: true,
metrics: {},
- last_update: 42
+ last_update: 42,
}
end
@@ -59,19 +59,19 @@ describe EnvironmentStatusEntity do
allow(entity).to receive(:deployment).and_return(deployment)
end
- context 'when deployment succeeded' do
+ context "when deployment succeeded" do
let(:deployment) { create(:deployment, :succeed, :review_app) }
- it 'returns metrics url' do
+ it "returns metrics url" do
expect(subject[:metrics_url])
.to eq("/#{project.namespace.name}/#{project.name}/environments/#{environment.id}/deployments/#{deployment.iid}/metrics")
end
end
- context 'when deployment is running' do
+ context "when deployment is running" do
let(:deployment) { create(:deployment, :running, :review_app) }
- it 'does not return metrics url' do
+ it "does not return metrics url" do
expect(subject[:metrics_url]).to be_nil
end
end
diff --git a/spec/serializers/group_child_entity_spec.rb b/spec/serializers/group_child_entity_spec.rb
index d02b4c554b1..bf15e8baeb0 100644
--- a/spec/serializers/group_child_entity_spec.rb
+++ b/spec/serializers/group_child_entity_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupChildEntity do
include Gitlab::Routing.url_helpers
let(:user) { create(:user) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:entity) { described_class.new(object, request: request) }
subject(:json) { entity.as_json }
@@ -13,8 +13,8 @@ describe GroupChildEntity do
stub_commonmark_sourcepos_disabled
end
- shared_examples 'group child json' do
- it 'renders json' do
+ shared_examples "group child json" do
+ it "renders json" do
is_expected.not_to be_nil
end
@@ -36,47 +36,47 @@ describe GroupChildEntity do
end
end
- describe 'for a project' do
+ describe "for a project" do
let(:object) do
create(:project, :with_avatar,
- description: 'Awesomeness')
+ description: "Awesomeness")
end
before do
object.add_maintainer(user)
end
- it 'has the correct type' do
- expect(json[:type]).to eq('project')
+ it "has the correct type" do
+ expect(json[:type]).to eq("project")
end
- it 'includes the star count' do
+ it "includes the star count" do
expect(json[:star_count]).to be_present
end
- it 'has the correct edit path' do
+ it "has the correct edit path" do
expect(json[:edit_path]).to eq(edit_project_path(object))
end
- it_behaves_like 'group child json'
+ it_behaves_like "group child json"
end
- describe 'for a group', :nested_groups do
- let(:description) { 'Awesomeness' }
+ describe "for a group", :nested_groups do
+ let(:description) { "Awesomeness" }
let(:object) do
create(:group, :nested, :with_avatar,
- description: description)
+ description: description)
end
before do
object.add_owner(user)
end
- it 'has the correct type' do
- expect(json[:type]).to eq('group')
+ it "has the correct type" do
+ expect(json[:type]).to eq("group")
end
- it 'counts projects and subgroups as children' do
+ it "counts projects and subgroups as children" do
create(:project, namespace: object)
create(:group, parent: object)
@@ -89,24 +89,24 @@ describe GroupChildEntity do
end
end
- it 'allows an owner to leave when there is another one' do
+ it "allows an owner to leave when there is another one" do
object.add_owner(create(:user))
expect(json[:can_leave]).to be_truthy
end
- it 'has the correct edit path' do
+ it "has the correct edit path" do
expect(json[:edit_path]).to eq(edit_group_path(object))
end
- context 'emoji in description' do
- let(:description) { ':smile:' }
+ context "emoji in description" do
+ let(:description) { ":smile:" }
- it 'has the correct markdown_description' do
+ it "has the correct markdown_description" do
expect(json[:markdown_description]).to eq('<p dir="auto"><gl-emoji title="smiling face with open mouth and smiling eyes" data-name="smile" data-unicode-version="6.0">😄</gl-emoji></p>')
end
end
- it_behaves_like 'group child json'
+ it_behaves_like "group child json"
end
end
diff --git a/spec/serializers/group_child_serializer_spec.rb b/spec/serializers/group_child_serializer_spec.rb
index 5541ada3750..988beb73ac3 100644
--- a/spec/serializers/group_child_serializer_spec.rb
+++ b/spec/serializers/group_child_serializer_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupChildSerializer do
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:user) { create(:user) }
subject(:serializer) { described_class.new(current_user: user) }
- describe '#represent' do
- context 'for groups' do
- it 'can render a single group' do
+ describe "#represent" do
+ context "for groups" do
+ it "can render a single group" do
expect(serializer.represent(build(:group))).to be_kind_of(Hash)
end
- it 'can render a collection of groups' do
+ it "can render a collection of groups" do
expect(serializer.represent(build_list(:group, 2))).to be_kind_of(Array)
end
end
- context 'with a hierarchy', :nested_groups do
+ context "with a hierarchy", :nested_groups do
let(:parent) { create(:group) }
subject(:serializer) do
described_class.new(current_user: user).expand_hierarchy(parent)
end
- it 'expands the subgroups' do
+ it "expands the subgroups" do
subgroup = create(:group, parent: parent)
subsub_group = create(:group, parent: subgroup)
@@ -35,7 +35,7 @@ describe GroupChildSerializer do
expect(subsub_group_json[:id]).to eq(subsub_group.id)
end
- it 'can render a nested tree' do
+ it "can render a nested tree" do
subgroup1 = create(:group, parent: parent)
subsub_group1 = create(:group, parent: subgroup1)
subgroup2 = create(:group, parent: parent)
@@ -49,12 +49,12 @@ describe GroupChildSerializer do
expect(subsub_group1_json[:id]).to eq(subsub_group1.id)
end
- context 'without a specified parent' do
+ context "without a specified parent" do
subject(:serializer) do
described_class.new(current_user: user).expand_hierarchy
end
- it 'can render a tree' do
+ it "can render a tree" do
subgroup = create(:group, parent: parent)
json = serializer.represent([parent, subgroup])
@@ -66,23 +66,23 @@ describe GroupChildSerializer do
end
end
- context 'for projects' do
- it 'can render a single project' do
+ context "for projects" do
+ it "can render a single project" do
expect(serializer.represent(build(:project))).to be_kind_of(Hash)
end
- it 'can render a collection of projects' do
+ it "can render a collection of projects" do
expect(serializer.represent(build_list(:project, 2))).to be_kind_of(Array)
end
- context 'with a hierarchy', :nested_groups do
+ context "with a hierarchy", :nested_groups do
let(:parent) { create(:group) }
subject(:serializer) do
described_class.new(current_user: user).expand_hierarchy(parent)
end
- it 'can render a nested tree' do
+ it "can render a nested tree" do
subgroup1 = create(:group, parent: parent)
project1 = create(:project, namespace: subgroup1)
subgroup2 = create(:group, parent: parent)
@@ -96,7 +96,7 @@ describe GroupChildSerializer do
expect(project2_json[:id]).to eq(project2.id)
end
- it 'returns an array when an array of a single instance was given' do
+ it "returns an array when an array of a single instance was given" do
project = create(:project, namespace: parent)
json = serializer.represent([project])
diff --git a/spec/serializers/group_variable_entity_spec.rb b/spec/serializers/group_variable_entity_spec.rb
index f6de7d01f98..7ad0fb4abdf 100644
--- a/spec/serializers/group_variable_entity_spec.rb
+++ b/spec/serializers/group_variable_entity_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupVariableEntity do
let(:variable) { create(:ci_group_variable) }
let(:entity) { described_class.new(variable) }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains required fields' do
+ it "contains required fields" do
expect(subject).to include(:id, :key, :value, :protected)
end
end
diff --git a/spec/serializers/issue_board_entity_spec.rb b/spec/serializers/issue_board_entity_spec.rb
index f6fa2a794f6..58f1d307fa2 100644
--- a/spec/serializers/issue_board_entity_spec.rb
+++ b/spec/serializers/issue_board_entity_spec.rb
@@ -1,40 +1,40 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe IssueBoardEntity do
let(:project) { create(:project) }
let(:resource) { create(:issue, project: project) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
- let(:label) { create(:label, project: project, title: 'Test Label') }
- let(:request) { double('request', current_user: user) }
+ let(:label) { create(:label, project: project, title: "Test Label") }
+ let(:request) { double("request", current_user: user) }
subject { described_class.new(resource, request: request).as_json }
- it 'has basic attributes' do
+ it "has basic attributes" do
expect(subject).to include(:id, :iid, :title, :confidential, :due_date, :project_id, :relative_position,
- :labels, :assignees, project: hash_including(:id, :path))
+ :labels, :assignees, project: hash_including(:id, :path))
end
- it 'has path and endpoints' do
+ it "has path and endpoints" do
expect(subject).to include(:reference_path, :real_path, :issue_sidebar_endpoint,
- :toggle_subscription_endpoint, :assignable_labels_endpoint)
+ :toggle_subscription_endpoint, :assignable_labels_endpoint)
end
- it 'has milestone attributes' do
+ it "has milestone attributes" do
resource.milestone = milestone
expect(subject).to include(milestone: hash_including(:id, :title))
end
- it 'has assignee attributes' do
+ it "has assignee attributes" do
resource.assignees = [user]
expect(subject).to include(assignees: array_including(hash_including(:id, :name, :username, :avatar_url)))
end
- it 'has label attributes' do
+ it "has label attributes" do
resource.labels = [label]
expect(subject).to include(labels: array_including(hash_including(:id, :title, :color, :description, :text_color, :priority)))
diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb
index caa3e41402b..1817ea0e5e0 100644
--- a/spec/serializers/issue_entity_spec.rb
+++ b/spec/serializers/issue_entity_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe IssueEntity do
let(:project) { create(:project) }
let(:resource) { create(:issue, project: project) }
let(:user) { create(:user) }
- let(:request) { double('request', current_user: user) }
+ let(:request) { double("request", current_user: user) }
subject { described_class.new(resource, request: request).as_json }
- it 'has Issuable attributes' do
+ it "has Issuable attributes" do
expect(subject).to include(:id, :iid, :author_id, :description, :lock_version, :milestone_id,
- :title, :updated_by_id, :created_at, :updated_at, :milestone, :labels)
+ :title, :updated_by_id, :created_at, :updated_at, :milestone, :labels)
end
- it 'has time estimation attributes' do
+ it "has time estimation attributes" do
expect(subject).to include(:time_estimate, :total_time_spent, :human_time_estimate, :human_total_time_spent)
end
end
diff --git a/spec/serializers/issue_serializer_spec.rb b/spec/serializers/issue_serializer_spec.rb
index b8255e004d0..aaee7d54d1c 100644
--- a/spec/serializers/issue_serializer_spec.rb
+++ b/spec/serializers/issue_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe IssueSerializer do
let(:resource) { create(:issue) }
@@ -9,35 +9,35 @@ describe IssueSerializer do
.with_indifferent_access
end
- context 'non-sidebar issue serialization' do
+ context "non-sidebar issue serialization" do
let(:serializer) { nil }
- it 'matches issue json schema' do
- expect(json_entity).to match_schema('entities/issue')
+ it "matches issue json schema" do
+ expect(json_entity).to match_schema("entities/issue")
end
end
- context 'sidebar issue serialization' do
- let(:serializer) { 'sidebar' }
+ context "sidebar issue serialization" do
+ let(:serializer) { "sidebar" }
- it 'matches issue_sidebar json schema' do
- expect(json_entity).to match_schema('entities/issue_sidebar')
+ it "matches issue_sidebar json schema" do
+ expect(json_entity).to match_schema("entities/issue_sidebar")
end
end
- context 'sidebar extras issue serialization' do
- let(:serializer) { 'sidebar_extras' }
+ context "sidebar extras issue serialization" do
+ let(:serializer) { "sidebar_extras" }
- it 'matches issue_sidebar_extras json schema' do
- expect(json_entity).to match_schema('entities/issue_sidebar_extras')
+ it "matches issue_sidebar_extras json schema" do
+ expect(json_entity).to match_schema("entities/issue_sidebar_extras")
end
end
- context 'board issue serialization' do
- let(:serializer) { 'board' }
+ context "board issue serialization" do
+ let(:serializer) { "board" }
- it 'matches board issue json schema' do
- expect(json_entity).to match_schema('entities/issue_board')
+ it "matches board issue json schema" do
+ expect(json_entity).to match_schema("entities/issue_board")
end
end
end
diff --git a/spec/serializers/job_entity_spec.rb b/spec/serializers/job_entity_spec.rb
index 851b41a7f7e..fac67fd4605 100644
--- a/spec/serializers/job_entity_spec.rb
+++ b/spec/serializers/job_entity_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe JobEntity do
let(:user) { create(:user) }
let(:job) { create(:ci_build) }
let(:project) { job.project }
- let(:request) { double('request') }
+ let(:request) { double("request") }
before do
stub_not_protect_default_branch
@@ -19,201 +19,201 @@ describe JobEntity do
subject { entity.as_json }
- it 'contains paths to job page action' do
+ it "contains paths to job page action" do
expect(subject).to include(:build_path)
end
- it 'does not contain sensitive information' do
+ it "does not contain sensitive information" do
expect(subject).not_to include(/token/)
expect(subject).not_to include(/variables/)
end
- it 'contains whether it is playable' do
+ it "contains whether it is playable" do
expect(subject[:playable]).to eq job.playable?
end
- it 'contains timestamps' do
+ it "contains timestamps" do
expect(subject).to include(:created_at, :updated_at)
end
- it 'contains details' do
+ it "contains details" do
expect(subject).to include :status
expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip
end
- context 'when job is retryable' do
+ context "when job is retryable" do
before do
job.update(status: :failed)
end
- it 'contains cancel path' do
+ it "contains cancel path" do
expect(subject).to include(:retry_path)
end
end
- context 'when job is cancelable' do
+ context "when job is cancelable" do
before do
job.update(status: :running)
end
- it 'contains cancel path' do
+ it "contains cancel path" do
expect(subject).to include(:cancel_path)
end
end
- context 'when job is a regular job' do
- it 'does not contain path to play action' do
+ context "when job is a regular job" do
+ it "does not contain path to play action" do
expect(subject).not_to include(:play_path)
end
- it 'is not a playable build' do
+ it "is not a playable build" do
expect(subject[:playable]).to be false
end
end
- context 'when job is a manual action' do
+ context "when job is a manual action" do
let(:job) { create(:ci_build, :manual) }
- context 'when user is allowed to trigger action' do
+ context "when user is allowed to trigger action" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: job.ref, project: job.project)
+ name: job.ref, project: job.project)
end
- it 'contains path to play action' do
+ it "contains path to play action" do
expect(subject).to include(:play_path)
end
- it 'is a playable action' do
+ it "is a playable action" do
expect(subject[:playable]).to be true
end
end
- context 'when user is not allowed to trigger action' do
+ context "when user is not allowed to trigger action" do
before do
allow(job.project).to receive(:empty_repo?).and_return(false)
create(:protected_branch, :no_one_can_push,
- name: job.ref, project: job.project)
+ name: job.ref, project: job.project)
end
- it 'does not contain path to play action' do
+ it "does not contain path to play action" do
expect(subject).not_to include(:play_path)
end
- it 'is not a playable action' do
+ it "is not a playable action" do
expect(subject[:playable]).to be false
end
end
end
- context 'when job is scheduled' do
+ context "when job is scheduled" do
let(:job) { create(:ci_build, :scheduled) }
- it 'contains path to unschedule action' do
+ it "contains path to unschedule action" do
expect(subject).to include(:unschedule_path)
end
- it 'contains scheduled_at' do
+ it "contains scheduled_at" do
expect(subject[:scheduled]).to be_truthy
expect(subject[:scheduled_at]).to eq(job.scheduled_at)
end
end
- context 'when job is generic commit status' do
- let(:job) { create(:generic_commit_status, target_url: 'http://google.com') }
+ context "when job is generic commit status" do
+ let(:job) { create(:generic_commit_status, target_url: "http://google.com") }
- it 'contains paths to target action' do
+ it "contains paths to target action" do
expect(subject).to include(:build_path)
end
- it 'does not contain paths to other action paths' do
+ it "does not contain paths to other action paths" do
expect(subject).not_to include(:retry_path, :cancel_path, :play_path)
end
- it 'contains timestamps' do
+ it "contains timestamps" do
expect(subject).to include(:created_at, :updated_at)
end
- it 'contains details' do
+ it "contains details" do
expect(subject).to include :status
expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip
end
end
- context 'when job failed' do
+ context "when job failed" do
let(:job) { create(:ci_build, :api_failure) }
- it 'contains details' do
+ it "contains details" do
expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip
end
- it 'states that it failed' do
- expect(subject[:status][:label]).to eq('failed')
+ it "states that it failed" do
+ expect(subject[:status][:label]).to eq("failed")
end
- it 'should indicate the failure reason on tooltip' do
- expect(subject[:status][:tooltip]).to eq('failed - (API failure)')
+ it "should indicate the failure reason on tooltip" do
+ expect(subject[:status][:tooltip]).to eq("failed - (API failure)")
end
- it 'should include a callout message with a verbose output' do
- expect(subject[:callout_message]).to eq('There has been an API failure, please try again')
+ it "should include a callout message with a verbose output" do
+ expect(subject[:callout_message]).to eq("There has been an API failure, please try again")
end
- it 'should state that it is not recoverable' do
+ it "should state that it is not recoverable" do
expect(subject[:recoverable]).to be_truthy
end
end
- context 'when job is allowed to fail' do
+ context "when job is allowed to fail" do
let(:job) { create(:ci_build, :allowed_to_fail, :api_failure) }
- it 'contains details' do
+ it "contains details" do
expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip
end
- it 'states that it failed' do
- expect(subject[:status][:label]).to eq('failed (allowed to fail)')
+ it "states that it failed" do
+ expect(subject[:status][:label]).to eq("failed (allowed to fail)")
end
- it 'should indicate the failure reason on tooltip' do
- expect(subject[:status][:tooltip]).to eq('failed - (API failure) (allowed to fail)')
+ it "should indicate the failure reason on tooltip" do
+ expect(subject[:status][:tooltip]).to eq("failed - (API failure) (allowed to fail)")
end
- it 'should include a callout message with a verbose output' do
- expect(subject[:callout_message]).to eq('There has been an API failure, please try again')
+ it "should include a callout message with a verbose output" do
+ expect(subject[:callout_message]).to eq("There has been an API failure, please try again")
end
- it 'should state that it is not recoverable' do
+ it "should state that it is not recoverable" do
expect(subject[:recoverable]).to be_truthy
end
end
- context 'when the job failed with a script failure' do
+ context "when the job failed with a script failure" do
let(:job) { create(:ci_build, :failed, :script_failure) }
- it 'should not include callout message or recoverable keys' do
- expect(subject).not_to include('callout_message')
- expect(subject).not_to include('recoverable')
+ it "should not include callout message or recoverable keys" do
+ expect(subject).not_to include("callout_message")
+ expect(subject).not_to include("recoverable")
end
end
- context 'when job failed and is recoverable' do
+ context "when job failed and is recoverable" do
let(:job) { create(:ci_build, :api_failure) }
- it 'should state it is recoverable' do
+ it "should state it is recoverable" do
expect(subject[:recoverable]).to be_truthy
end
end
- context 'when job passed' do
+ context "when job passed" do
let(:job) { create(:ci_build, :success) }
- it 'should not include callout message or recoverable keys' do
- expect(subject).not_to include('callout_message')
- expect(subject).not_to include('recoverable')
+ it "should not include callout message or recoverable keys" do
+ expect(subject).not_to include("callout_message")
+ expect(subject).not_to include("recoverable")
end
end
end
diff --git a/spec/serializers/label_serializer_spec.rb b/spec/serializers/label_serializer_spec.rb
index c58c7da1f9e..6c9fe7a97b5 100644
--- a/spec/serializers/label_serializer_spec.rb
+++ b/spec/serializers/label_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe LabelSerializer do
let(:user) { create(:user) }
@@ -9,32 +9,32 @@ describe LabelSerializer do
subject { serializer.represent(resource) }
- describe '#represent' do
- context 'when a single object is being serialized' do
+ describe "#represent" do
+ context "when a single object is being serialized" do
let(:resource) { create(:label) }
- it 'serializes the label object' do
+ it "serializes the label object" do
expect(subject[:id]).to eq resource.id
end
end
- context 'when multiple objects are being serialized' do
+ context "when multiple objects are being serialized" do
let(:num_labels) { 2 }
let(:resource) { create_list(:label, num_labels) }
- it 'serializes the array of labels' do
+ it "serializes the array of labels" do
expect(subject.size).to eq(num_labels)
end
end
end
- describe '#represent_appearance' do
- context 'when represents only appearance' do
+ describe "#represent_appearance" do
+ context "when represents only appearance" do
let(:resource) { create(:label) }
subject { serializer.represent_appearance(resource) }
- it 'serializes only attributes used for appearance' do
+ it "serializes only attributes used for appearance" do
expect(subject.keys).to eq([:id, :title, :color, :text_color])
expect(subject[:id]).to eq(resource.id)
expect(subject[:title]).to eq(resource.title)
diff --git a/spec/serializers/lfs_file_lock_entity_spec.rb b/spec/serializers/lfs_file_lock_entity_spec.rb
index 5919f473a90..f20114106e2 100644
--- a/spec/serializers/lfs_file_lock_entity_spec.rb
+++ b/spec/serializers/lfs_file_lock_entity_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe LfsFileLockEntity do
let(:user) { create(:user) }
let(:resource) { create(:lfs_file_lock, user: user) }
- let(:request) { double('request', current_user: user) }
+ let(:request) { double("request", current_user: user) }
subject { described_class.new(resource, request: request).as_json }
- it 'exposes basic attrs of the lock' do
+ it "exposes basic attrs of the lock" do
expect(subject).to include(:id, :path, :locked_at)
end
- it 'exposes the owner info' do
+ it "exposes the owner info" do
expect(subject).to include(:owner)
expect(subject[:owner][:name]).to eq(user.name)
end
diff --git a/spec/serializers/merge_request_diff_entity_spec.rb b/spec/serializers/merge_request_diff_entity_spec.rb
index 84f6833d88a..00b4324dd95 100644
--- a/spec/serializers/merge_request_diff_entity_spec.rb
+++ b/spec/serializers/merge_request_diff_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestDiffEntity do
let(:project) { create(:project, :repository) }
@@ -10,10 +10,10 @@ describe MergeRequestDiffEntity do
described_class.new(merge_request_diffs.first, request: request, merge_request: merge_request, merge_request_diffs: merge_request_diffs)
end
- context 'as json' do
+ context "as json" do
subject { entity.as_json }
- it 'exposes needed attributes' do
+ it "exposes needed attributes" do
expect(subject).to include(
:version_index, :created_at, :commits_count,
:latest, :short_commit_sha, :version_path,
diff --git a/spec/serializers/merge_request_serializer_spec.rb b/spec/serializers/merge_request_serializer_spec.rb
index 276e0f6ff3d..8d172f51969 100644
--- a/spec/serializers/merge_request_serializer_spec.rb
+++ b/spec/serializers/merge_request_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestSerializer do
let(:user) { create(:user) }
@@ -9,43 +9,43 @@ describe MergeRequestSerializer do
.with_indifferent_access
end
- context 'widget merge request serialization' do
- let(:serializer) { 'widget' }
+ context "widget merge request serialization" do
+ let(:serializer) { "widget" }
- it 'matches issue json schema' do
- expect(json_entity).to match_schema('entities/merge_request_widget')
+ it "matches issue json schema" do
+ expect(json_entity).to match_schema("entities/merge_request_widget")
end
end
- context 'sidebar merge request serialization' do
- let(:serializer) { 'sidebar' }
+ context "sidebar merge request serialization" do
+ let(:serializer) { "sidebar" }
- it 'matches merge_request_sidebar json schema' do
- expect(json_entity).to match_schema('entities/merge_request_sidebar')
+ it "matches merge_request_sidebar json schema" do
+ expect(json_entity).to match_schema("entities/merge_request_sidebar")
end
end
- context 'sidebar_extras merge request serialization' do
- let(:serializer) { 'sidebar_extras' }
+ context "sidebar_extras merge request serialization" do
+ let(:serializer) { "sidebar_extras" }
- it 'matches merge_request_sidebar_extras json schema' do
- expect(json_entity).to match_schema('entities/merge_request_sidebar_extras')
+ it "matches merge_request_sidebar_extras json schema" do
+ expect(json_entity).to match_schema("entities/merge_request_sidebar_extras")
end
end
- context 'basic merge request serialization' do
- let(:serializer) { 'basic' }
+ context "basic merge request serialization" do
+ let(:serializer) { "basic" }
- it 'matches basic merge request json schema' do
- expect(json_entity).to match_schema('entities/merge_request_basic')
+ it "matches basic merge request json schema" do
+ expect(json_entity).to match_schema("entities/merge_request_basic")
end
end
- context 'no serializer' do
+ context "no serializer" do
let(:serializer) { nil }
- it 'falls back to the widget entity' do
- expect(json_entity).to match_schema('entities/merge_request_widget')
+ it "falls back to the widget entity" do
+ expect(json_entity).to match_schema("entities/merge_request_widget")
end
end
end
diff --git a/spec/serializers/merge_request_user_entity_spec.rb b/spec/serializers/merge_request_user_entity_spec.rb
index c91ea4aa681..b59083fee09 100644
--- a/spec/serializers/merge_request_user_entity_spec.rb
+++ b/spec/serializers/merge_request_user_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestUserEntity do
let(:user) { create(:user) }
@@ -9,10 +9,10 @@ describe MergeRequestUserEntity do
described_class.new(user, request: request)
end
- context 'as json' do
+ context "as json" do
subject { entity.as_json }
- it 'exposes needed attributes' do
+ it "exposes needed attributes" do
expect(subject).to include(:can_fork, :can_create_merge_request, :fork_path)
end
end
diff --git a/spec/serializers/merge_request_widget_commit_entity_spec.rb b/spec/serializers/merge_request_widget_commit_entity_spec.rb
index ce83978c49a..a3338c6b6c7 100644
--- a/spec/serializers/merge_request_widget_commit_entity_spec.rb
+++ b/spec/serializers/merge_request_widget_commit_entity_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestWidgetCommitEntity do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:entity) do
described_class.new(commit, request: request)
end
- context 'as json' do
+ context "as json" do
subject { entity.as_json }
it { expect(subject[:message]).to eq(commit.safe_message) }
diff --git a/spec/serializers/merge_request_widget_entity_spec.rb b/spec/serializers/merge_request_widget_entity_spec.rb
index 4dbd79f2fc0..19c70948864 100644
--- a/spec/serializers/merge_request_widget_entity_spec.rb
+++ b/spec/serializers/merge_request_widget_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequestWidgetEntity do
include ProjectForksHelper
@@ -7,19 +7,19 @@ describe MergeRequestWidgetEntity do
let(:resource) { create(:merge_request, source_project: project, target_project: project) }
let(:user) { create(:user) }
- let(:request) { double('request', current_user: user, project: project) }
+ let(:request) { double("request", current_user: user, project: project) }
subject do
described_class.new(resource, request: request).as_json
end
- describe 'source_project_full_path' do
- it 'includes the full path of the source project' do
+ describe "source_project_full_path" do
+ it "includes the full path of the source project" do
expect(subject[:source_project_full_path]).to be_present
end
- context 'when the source project is missing' do
- it 'returns `nil` for the source project' do
+ context "when the source project is missing" do
+ it "returns `nil` for the source project" do
resource.allow_broken = true
resource.update!(source_project: nil)
@@ -28,7 +28,7 @@ describe MergeRequestWidgetEntity do
end
end
- describe 'pipeline' do
+ describe "pipeline" do
let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: resource.source_branch, sha: resource.source_branch_sha, head_pipeline_of: resource) }
before do
@@ -36,13 +36,13 @@ describe MergeRequestWidgetEntity do
allow_any_instance_of(MergeRequestPresenter).to receive(:can?).with(user, :read_pipeline, anything).and_return(result)
end
- context 'when user has access to pipelines' do
+ context "when user has access to pipelines" do
let(:result) { true }
- context 'when is up to date' do
- let(:req) { double('request', current_user: user, project: project) }
+ context "when is up to date" do
+ let(:req) { double("request", current_user: user, project: project) }
- it 'returns pipeline' do
+ it "returns pipeline" do
pipeline_payload = PipelineDetailsEntity
.represent(pipeline, request: req)
.as_json
@@ -51,8 +51,8 @@ describe MergeRequestWidgetEntity do
end
end
- context 'when is not up to date' do
- it 'returns nil' do
+ context "when is not up to date" do
+ it "returns nil" do
pipeline.update(sha: "not up to date")
expect(subject[:pipeline]).to eq(nil)
@@ -60,21 +60,21 @@ describe MergeRequestWidgetEntity do
end
end
- context 'when user does not have access to pipelines' do
+ context "when user does not have access to pipelines" do
let(:result) { false }
- it 'does not have pipeline' do
+ it "does not have pipeline" do
expect(subject[:pipeline]).to eq(nil)
end
end
end
- describe 'merge_pipeline' do
- it 'returns nil' do
+ describe "merge_pipeline" do
+ it "returns nil" do
expect(subject[:merge_pipeline]).to be_nil
end
- context 'when is merged' do
+ context "when is merged" do
let(:resource) { create(:merged_merge_request, source_project: project, merge_commit_sha: project.commit.id) }
let(:pipeline) { create(:ci_empty_pipeline, project: project, ref: resource.target_branch, sha: resource.merge_commit_sha) }
@@ -82,79 +82,79 @@ describe MergeRequestWidgetEntity do
project.add_maintainer(user)
end
- it 'returns merge_pipeline' do
+ it "returns merge_pipeline" do
pipeline.reload
pipeline_payload = PipelineDetailsEntity
- .represent(pipeline, request: request)
- .as_json
+ .represent(pipeline, request: request)
+ .as_json
expect(subject[:merge_pipeline]).to eq(pipeline_payload)
end
- context 'when user cannot read pipelines on target project' do
+ context "when user cannot read pipelines on target project" do
before do
project.add_guest(user)
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject[:merge_pipeline]).to be_nil
end
end
end
end
- describe 'metrics' do
- context 'when metrics record exists with merged data' do
+ describe "metrics" do
+ context "when metrics record exists with merged data" do
before do
resource.mark_as_merged!
resource.metrics.update!(merged_by: user)
end
- it 'matches merge request metrics schema' do
+ it "matches merge request metrics schema" do
expect(subject[:metrics].with_indifferent_access)
- .to match_schema('entities/merge_request_metrics')
+ .to match_schema("entities/merge_request_metrics")
end
- it 'returns values from metrics record' do
+ it "returns values from metrics record" do
expect(subject.dig(:metrics, :merged_by, :id))
.to eq(resource.metrics.merged_by_id)
end
end
- context 'when metrics record exists with closed data' do
+ context "when metrics record exists with closed data" do
before do
resource.close!
resource.metrics.update!(latest_closed_by: user)
end
- it 'matches merge request metrics schema' do
+ it "matches merge request metrics schema" do
expect(subject[:metrics].with_indifferent_access)
- .to match_schema('entities/merge_request_metrics')
+ .to match_schema("entities/merge_request_metrics")
end
- it 'returns values from metrics record' do
+ it "returns values from metrics record" do
expect(subject.dig(:metrics, :closed_by, :id))
.to eq(resource.metrics.latest_closed_by_id)
end
end
- context 'when metrics does not exists' do
+ context "when metrics does not exists" do
before do
resource.mark_as_merged!
resource.metrics.destroy!
resource.reload
end
- context 'when events exists' do
+ context "when events exists" do
let!(:closed_event) { create(:event, :closed, project: project, target: resource) }
let!(:merge_event) { create(:event, :merged, project: project, target: resource) }
- it 'matches merge request metrics schema' do
+ it "matches merge request metrics schema" do
expect(subject[:metrics].with_indifferent_access)
- .to match_schema('entities/merge_request_metrics')
+ .to match_schema("entities/merge_request_metrics")
end
- it 'returns values from events record' do
+ it "returns values from events record" do
expect(subject.dig(:metrics, :merged_by, :id))
.to eq(merge_event.author_id)
@@ -169,38 +169,38 @@ describe MergeRequestWidgetEntity do
end
end
- context 'when events does not exists' do
- it 'matches merge request metrics schema' do
+ context "when events does not exists" do
+ it "matches merge request metrics schema" do
expect(subject[:metrics].with_indifferent_access)
- .to match_schema('entities/merge_request_metrics')
+ .to match_schema("entities/merge_request_metrics")
end
end
end
end
- it 'has email_patches_path' do
+ it "has email_patches_path" do
expect(subject[:email_patches_path])
.to eq("/#{resource.project.full_path}/merge_requests/#{resource.iid}.patch")
end
- it 'has plain_diff_path' do
+ it "has plain_diff_path" do
expect(subject[:plain_diff_path])
.to eq("/#{resource.project.full_path}/merge_requests/#{resource.iid}.diff")
end
- it 'has default_merge_commit_message_with_description' do
+ it "has default_merge_commit_message_with_description" do
expect(subject[:default_merge_commit_message_with_description])
.to eq(resource.default_merge_commit_message(include_description: true))
end
- it 'has default_squash_commit_message' do
+ it "has default_squash_commit_message" do
expect(subject[:default_squash_commit_message])
.to eq(resource.default_squash_commit_message)
end
- describe 'new_blob_path' do
- context 'when user can push to project' do
- it 'returns path' do
+ describe "new_blob_path" do
+ context "when user can push to project" do
+ it "returns path" do
project.add_developer(user)
expect(subject[:new_blob_path])
@@ -208,36 +208,36 @@ describe MergeRequestWidgetEntity do
end
end
- context 'when user cannot push to project' do
- it 'returns nil' do
+ context "when user cannot push to project" do
+ it "returns nil" do
expect(subject[:new_blob_path]).to be_nil
end
end
end
- describe 'diff_head_sha' do
+ describe "diff_head_sha" do
before do
- allow(resource).to receive(:diff_head_sha) { 'sha' }
+ allow(resource).to receive(:diff_head_sha) { "sha" }
end
- context 'when diff head commit is empty' do
- it 'returns nil' do
- allow(resource).to receive(:diff_head_sha) { '' }
+ context "when diff head commit is empty" do
+ it "returns nil" do
+ allow(resource).to receive(:diff_head_sha) { "" }
expect(subject[:diff_head_sha]).to be_nil
end
end
- context 'when diff head commit present' do
- it 'returns diff head commit short id' do
- expect(subject[:diff_head_sha]).to eq('sha')
+ context "when diff head commit present" do
+ it "returns diff head commit short id" do
+ expect(subject[:diff_head_sha]).to eq("sha")
end
end
end
- describe 'diverged_commits_count' do
- context 'when MR open and its diverging' do
- it 'returns diverged commits count' do
+ describe "diverged_commits_count" do
+ context "when MR open and its diverging" do
+ it "returns diverged commits count" do
allow(resource).to receive_messages(open?: true, diverged_from_target_branch?: true,
diverged_commits_count: 10)
@@ -245,16 +245,16 @@ describe MergeRequestWidgetEntity do
end
end
- context 'when MR is not open' do
- it 'returns 0' do
+ context "when MR is not open" do
+ it "returns 0" do
allow(resource).to receive_messages(open?: false)
expect(subject[:diverged_commits_count]).to be_zero
end
end
- context 'when MR is not diverging' do
- it 'returns 0' do
+ context "when MR is not diverging" do
+ it "returns 0" do
allow(resource).to receive_messages(open?: true, diverged_from_target_branch?: false)
expect(subject[:diverged_commits_count]).to be_zero
@@ -262,12 +262,12 @@ describe MergeRequestWidgetEntity do
end
end
- describe 'when source project is deleted' do
+ describe "when source project is deleted" do
let(:project) { create(:project, :repository) }
let(:forked_project) { fork_project(project) }
let(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project) }
- it 'returns a blank rebase_path' do
+ it "returns a blank rebase_path" do
allow(merge_request).to receive(:should_be_rebased?).and_return(true)
forked_project.destroy
merge_request.reload
@@ -278,8 +278,8 @@ describe MergeRequestWidgetEntity do
end
end
- describe 'commits_without_merge_commits' do
- it 'should not include merge commits' do
+ describe "commits_without_merge_commits" do
+ it "should not include merge commits" do
# Mock all but the first 5 commits to be merge commits
resource.commits.each_with_index do |commit, i|
expect(commit).to receive(:merge_commit?).at_least(:once).and_return(i > 4)
diff --git a/spec/serializers/move_to_project_entity_spec.rb b/spec/serializers/move_to_project_entity_spec.rb
index ac495eadb68..ba9de610378 100644
--- a/spec/serializers/move_to_project_entity_spec.rb
+++ b/spec/serializers/move_to_project_entity_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe MoveToProjectEntity do
- describe '#as_json' do
+ describe "#as_json" do
let(:project) { build(:project, id: 1) }
subject { described_class.new(project).as_json }
- it 'includes the project ID' do
+ it "includes the project ID" do
expect(subject[:id]).to eq(project.id)
end
- it 'includes the full path' do
+ it "includes the full path" do
expect(subject[:name_with_namespace]).to eq(project.name_with_namespace)
end
end
diff --git a/spec/serializers/move_to_project_serializer_spec.rb b/spec/serializers/move_to_project_serializer_spec.rb
index 841ac969eeb..9497ea3d575 100644
--- a/spec/serializers/move_to_project_serializer_spec.rb
+++ b/spec/serializers/move_to_project_serializer_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe MoveToProjectSerializer do
- describe '#represent' do
- it 'includes the name and name with namespace' do
+ describe "#represent" do
+ it "includes the name and name with namespace" do
project = build(:project, id: 1)
output = described_class.new.represent(project)
diff --git a/spec/serializers/namespace_basic_entity_spec.rb b/spec/serializers/namespace_basic_entity_spec.rb
index f8b71ceb9f3..79287d80183 100644
--- a/spec/serializers/namespace_basic_entity_spec.rb
+++ b/spec/serializers/namespace_basic_entity_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe NamespaceBasicEntity do
set(:group) { create(:group) }
@@ -8,10 +8,10 @@ describe NamespaceBasicEntity do
described_class.represent(group)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'includes required fields' do
+ it "includes required fields" do
expect(subject).to include :id, :full_path
end
end
diff --git a/spec/serializers/namespace_serializer_spec.rb b/spec/serializers/namespace_serializer_spec.rb
index 6e5bdd8c52d..d10a3376c4e 100644
--- a/spec/serializers/namespace_serializer_spec.rb
+++ b/spec/serializers/namespace_serializer_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe NamespaceSerializer do
- it 'represents NamespaceBasicEntity entities' do
+ it "represents NamespaceBasicEntity entities" do
expect(described_class.entity_class).to eq(NamespaceBasicEntity)
end
end
diff --git a/spec/serializers/note_entity_spec.rb b/spec/serializers/note_entity_spec.rb
index 13cda781cda..c3466de7490 100644
--- a/spec/serializers/note_entity_spec.rb
+++ b/spec/serializers/note_entity_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe NoteEntity do
include Gitlab::Routing
- let(:request) { double('request', current_user: user, noteable: note.noteable) }
+ let(:request) { double("request", current_user: user, noteable: note.noteable) }
let(:entity) { described_class.new(note, request: request) }
let(:note) { create(:note) }
let(:user) { create(:user) }
subject { entity.as_json }
- it_behaves_like 'note entity'
+ it_behaves_like "note entity"
end
diff --git a/spec/serializers/pipeline_details_entity_spec.rb b/spec/serializers/pipeline_details_entity_spec.rb
index 8e73a3e67c6..aef84b9dcca 100644
--- a/spec/serializers/pipeline_details_entity_spec.rb
+++ b/spec/serializers/pipeline_details_entity_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineDetailsEntity do
set(:user) { create(:user) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
- it 'inherrits from PipelineEntity' do
+ it "inherrits from PipelineEntity" do
expect(described_class).to be < PipelineEntity
end
@@ -18,13 +18,13 @@ describe PipelineDetailsEntity do
described_class.represent(pipeline, request: request)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- context 'when pipeline is empty' do
+ context "when pipeline is empty" do
let(:pipeline) { create(:ci_empty_pipeline) }
- it 'contains details' do
+ it "contains details" do
expect(subject).to include :details
expect(subject[:details])
.to include :duration, :finished_at
@@ -33,15 +33,15 @@ describe PipelineDetailsEntity do
expect(subject[:details][:status]).to include :icon, :favicon, :text, :label
end
- it 'contains flags' do
+ it "contains flags" do
expect(subject).to include :flags
expect(subject[:flags])
.to include :latest, :stuck,
- :yaml_errors, :retryable, :cancelable
+ :yaml_errors, :retryable, :cancelable
end
end
- context 'when pipeline is retryable' do
+ context "when pipeline is retryable" do
let(:project) { create(:project) }
let(:pipeline) do
@@ -52,24 +52,24 @@ describe PipelineDetailsEntity do
create(:ci_build, :failed, pipeline: pipeline)
end
- context 'user has ability to retry pipeline' do
+ context "user has ability to retry pipeline" do
before do
project.add_developer(user)
end
- it 'retryable flag is true' do
+ it "retryable flag is true" do
expect(subject[:flags][:retryable]).to eq true
end
end
- context 'user does not have ability to retry pipeline' do
- it 'retryable flag is false' do
+ context "user does not have ability to retry pipeline" do
+ it "retryable flag is false" do
expect(subject[:flags][:retryable]).to eq false
end
end
end
- context 'when pipeline is cancelable' do
+ context "when pipeline is cancelable" do
let(:project) { create(:project) }
let(:pipeline) do
@@ -80,59 +80,59 @@ describe PipelineDetailsEntity do
create(:ci_build, :pending, pipeline: pipeline)
end
- context 'user has ability to cancel pipeline' do
+ context "user has ability to cancel pipeline" do
before do
project.add_developer(user)
end
- it 'cancelable flag is true' do
+ it "cancelable flag is true" do
expect(subject[:flags][:cancelable]).to eq true
end
end
- context 'user does not have ability to cancel pipeline' do
- it 'cancelable flag is false' do
+ context "user does not have ability to cancel pipeline" do
+ it "cancelable flag is false" do
expect(subject[:flags][:cancelable]).to eq false
end
end
end
- context 'when pipeline has commit statuses' do
+ context "when pipeline has commit statuses" do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
create(:generic_commit_status, pipeline: pipeline)
end
- it 'contains stages' do
+ it "contains stages" do
expect(subject).to include(:details)
expect(subject[:details]).to include(:stages)
- expect(subject[:details][:stages].first).to include(name: 'test')
+ expect(subject[:details][:stages].first).to include(name: "test")
end
end
- context 'when pipeline has YAML errors' do
+ context "when pipeline has YAML errors" do
let(:pipeline) do
- create(:ci_pipeline, config: { rspec: { invalid: :value } })
+ create(:ci_pipeline, config: {rspec: {invalid: :value}})
end
- it 'contains information about error' do
+ it "contains information about error" do
expect(subject[:yaml_errors]).to be_present
end
- it 'contains flag that indicates there are errors' do
+ it "contains flag that indicates there are errors" do
expect(subject[:flags][:yaml_errors]).to be true
end
end
- context 'when pipeline does not have YAML errors' do
+ context "when pipeline does not have YAML errors" do
let(:pipeline) { create(:ci_empty_pipeline) }
- it 'does not contain field that normally holds an error' do
+ it "does not contain field that normally holds an error" do
expect(subject).not_to have_key(:yaml_errors)
end
- it 'contains flag that indicates there are no errors' do
+ it "contains flag that indicates there are no errors" do
expect(subject[:flags][:yaml_errors]).to be false
end
end
diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb
index 774486dcb6d..ca0d8ab42e1 100644
--- a/spec/serializers/pipeline_entity_spec.rb
+++ b/spec/serializers/pipeline_entity_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineEntity do
set(:user) { create(:user) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
before do
stub_not_protect_default_branch
@@ -14,41 +14,41 @@ describe PipelineEntity do
described_class.represent(pipeline, request: request)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- context 'when pipeline is empty' do
+ context "when pipeline is empty" do
let(:pipeline) { create(:ci_empty_pipeline) }
- it 'contains required fields' do
+ it "contains required fields" do
expect(subject).to include :id, :user, :path, :coverage, :source
expect(subject).to include :ref, :commit
expect(subject).to include :updated_at, :created_at
end
- it 'excludes coverage data when disabled' do
+ it "excludes coverage data when disabled" do
entity = described_class
.represent(pipeline, request: request, disable_coverage: true)
expect(entity.as_json).not_to include(:coverage)
end
- it 'contains details' do
+ it "contains details" do
expect(subject).to include :details
expect(subject[:details])
.to include :duration, :finished_at
expect(subject[:details][:status]).to include :icon, :favicon, :text, :label, :tooltip
end
- it 'contains flags' do
+ it "contains flags" do
expect(subject).to include :flags
expect(subject[:flags])
.to include :latest, :stuck, :auto_devops,
- :yaml_errors, :retryable, :cancelable, :merge_request
+ :yaml_errors, :retryable, :cancelable, :merge_request
end
end
- context 'when pipeline is retryable' do
+ context "when pipeline is retryable" do
let(:project) { create(:project) }
let(:pipeline) do
@@ -59,24 +59,24 @@ describe PipelineEntity do
create(:ci_build, :failed, pipeline: pipeline)
end
- context 'user has ability to retry pipeline' do
+ context "user has ability to retry pipeline" do
before do
project.add_developer(user)
end
- it 'contains retry path' do
+ it "contains retry path" do
expect(subject[:retry_path]).to be_present
end
end
- context 'user does not have ability to retry pipeline' do
- it 'does not contain retry path' do
+ context "user does not have ability to retry pipeline" do
+ it "does not contain retry path" do
expect(subject).not_to have_key(:retry_path)
end
end
end
- context 'when pipeline is cancelable' do
+ context "when pipeline is cancelable" do
let(:project) { create(:project) }
let(:pipeline) do
@@ -87,45 +87,45 @@ describe PipelineEntity do
create(:ci_build, :pending, pipeline: pipeline)
end
- context 'user has ability to cancel pipeline' do
+ context "user has ability to cancel pipeline" do
before do
project.add_developer(user)
end
- it 'contains cancel path' do
+ it "contains cancel path" do
expect(subject[:cancel_path]).to be_present
end
end
- context 'user does not have ability to cancel pipeline' do
- it 'does not contain cancel path' do
+ context "user does not have ability to cancel pipeline" do
+ it "does not contain cancel path" do
expect(subject).not_to have_key(:cancel_path)
end
end
end
- context 'when pipeline ref is empty' do
+ context "when pipeline ref is empty" do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
allow(pipeline).to receive(:ref).and_return(nil)
end
- it 'does not generate branch path' do
+ it "does not generate branch path" do
expect(subject[:ref][:path]).to be_nil
end
end
- context 'when pipeline has a failure reason set' do
+ context "when pipeline has a failure reason set" do
let(:pipeline) { create(:ci_empty_pipeline) }
before do
pipeline.drop!(:config_error)
end
- it 'has a correct failure reason' do
+ it "has a correct failure reason" do
expect(subject[:failure_reason])
- .to eq 'CI/CD YAML configuration error!'
+ .to eq "CI/CD YAML configuration error!"
end
end
end
diff --git a/spec/serializers/pipeline_serializer_spec.rb b/spec/serializers/pipeline_serializer_spec.rb
index 2bdcb2a45f6..97ce759aed7 100644
--- a/spec/serializers/pipeline_serializer_spec.rb
+++ b/spec/serializers/pipeline_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineSerializer do
set(:project) { create(:project, :repository) }
@@ -14,32 +14,32 @@ describe PipelineSerializer do
subject { serializer.represent(resource) }
- describe '#represent' do
- context 'when used without pagination' do
- it 'created a not paginated serializer' do
+ describe "#represent" do
+ context "when used without pagination" do
+ it "created a not paginated serializer" do
expect(serializer).not_to be_paginated
end
- context 'when a single object is being serialized' do
+ context "when a single object is being serialized" do
let(:resource) { create(:ci_empty_pipeline, project: project) }
- it 'serializers the pipeline object' do
+ it "serializers the pipeline object" do
expect(subject[:id]).to eq resource.id
end
end
- context 'when multiple objects are being serialized' do
+ context "when multiple objects are being serialized" do
let(:resource) { create_list(:ci_pipeline, 2, project: project) }
- it 'serializers the array of pipelines' do
+ it "serializers the array of pipelines" do
expect(subject).not_to be_empty
end
end
end
- context 'when used with pagination' do
+ context "when used with pagination" do
let(:request) { double(url: "#{Gitlab.config.gitlab.url}:8080/api/v4/projects?#{query.to_query}", query_parameters: query) }
- let(:response) { spy('response') }
+ let(:response) { spy("response") }
let(:query) { {} }
let(:serializer) do
@@ -47,49 +47,50 @@ describe PipelineSerializer do
.with_pagination(request, response)
end
- it 'created a paginated serializer' do
+ it "created a paginated serializer" do
expect(serializer).to be_paginated
end
- context 'when resource is not paginatable' do
- context 'when a single pipeline object is being serialized' do
+ context "when resource is not paginatable" do
+ context "when a single pipeline object is being serialized" do
let(:resource) { create(:ci_empty_pipeline) }
- let(:query) { { page: 1, per_page: 1 } }
+ let(:query) { {page: 1, per_page: 1} }
- it 'raises error' do
+ it "raises error" do
expect { subject }.to raise_error(
- Gitlab::Serializer::Pagination::InvalidResourceError)
+ Gitlab::Serializer::Pagination::InvalidResourceError
+ )
end
end
end
- context 'when resource is paginatable relation' do
+ context "when resource is paginatable relation" do
let(:resource) { Ci::Pipeline.all }
- let(:query) { { page: 1, per_page: 2 } }
+ let(:query) { {page: 1, per_page: 2} }
- context 'when a single pipeline object is present in relation' do
+ context "when a single pipeline object is present in relation" do
before do
create(:ci_empty_pipeline)
end
- it 'serializes pipeline relation' do
+ it "serializes pipeline relation" do
expect(subject.first).to have_key :id
end
end
- context 'when a multiple pipeline objects are being serialized' do
+ context "when a multiple pipeline objects are being serialized" do
before do
create_list(:ci_empty_pipeline, 3)
end
- it 'serializes appropriate number of objects' do
+ it "serializes appropriate number of objects" do
expect(subject.count).to be 2
end
- it 'appends relevant headers' do
- expect(response).to receive(:[]=).with('X-Total', '3')
- expect(response).to receive(:[]=).with('X-Total-Pages', '2')
- expect(response).to receive(:[]=).with('X-Per-Page', '2')
+ it "appends relevant headers" do
+ expect(response).to receive(:[]=).with("X-Total", "3")
+ expect(response).to receive(:[]=).with("X-Total-Pages", "2")
+ expect(response).to receive(:[]=).with("X-Per-Page", "2")
subject
end
@@ -97,7 +98,7 @@ describe PipelineSerializer do
end
end
- describe 'number of queries when preloaded' do
+ describe "number of queries when preloaded" do
subject { serializer.represent(resource, preload: true) }
let(:resource) { Ci::Pipeline.all }
@@ -113,10 +114,10 @@ describe PipelineSerializer do
Gitlab::GitalyClient.reset_counts
end
- context 'with the same ref' do
- let(:ref) { 'feature' }
+ context "with the same ref" do
+ let(:ref) { "feature" }
- it 'verifies number of queries', :request_store do
+ it "verifies number of queries", :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject }
expect(recorded.count).to be_within(2).of(31)
@@ -124,14 +125,14 @@ describe PipelineSerializer do
end
end
- context 'with different refs' do
+ context "with different refs" do
def ref
@sequence ||= 0
@sequence += 1
"feature-#{@sequence}"
end
- it 'verifies number of queries', :request_store do
+ it "verifies number of queries", :request_store do
recorded = ActiveRecord::QueryRecorder.new { subject }
# For each ref there is a permission check if maintainer can update
@@ -145,9 +146,9 @@ describe PipelineSerializer do
def create_pipeline(status)
create(:ci_empty_pipeline,
- project: project,
- status: status,
- ref: ref).tap do |pipeline|
+ project: project,
+ status: status,
+ ref: ref).tap do |pipeline|
Ci::Build::AVAILABLE_STATUSES.each do |status|
create_build(pipeline, status, status)
end
@@ -162,14 +163,14 @@ describe PipelineSerializer do
end
end
- describe '#represent_status' do
- context 'when represents only status' do
+ describe "#represent_status" do
+ context "when represents only status" do
let(:resource) { create(:ci_pipeline) }
- let(:status) { resource.detailed_status(double('user')) }
+ let(:status) { resource.detailed_status(double("user")) }
subject { serializer.represent_status(resource) }
- it 'serializes only status' do
+ it "serializes only status" do
expect(subject[:text]).to eq(status.text)
expect(subject[:label]).to eq(status.label)
expect(subject[:icon]).to eq(status.icon)
diff --git a/spec/serializers/project_import_entity_spec.rb b/spec/serializers/project_import_entity_spec.rb
index e476da82729..48f52637abf 100644
--- a/spec/serializers/project_import_entity_spec.rb
+++ b/spec/serializers/project_import_entity_spec.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectImportEntity do
include ImportHelper
- set(:project) { create(:project, import_status: :started, import_source: 'namespace/project') }
- let(:provider_url) { 'https://provider.com' }
+ set(:project) { create(:project, import_status: :started, import_source: "namespace/project") }
+ let(:provider_url) { "https://provider.com" }
let(:entity) { described_class.represent(project, provider_url: provider_url) }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'includes required fields' do
+ it "includes required fields" do
expect(subject[:import_source]).to eq(project.import_source)
expect(subject[:import_status]).to eq(project.import_status)
expect(subject[:human_import_status_name]).to eq(project.human_import_status_name)
diff --git a/spec/serializers/project_mirror_entity_spec.rb b/spec/serializers/project_mirror_entity_spec.rb
index ad0a8bbdff0..209069cb99f 100644
--- a/spec/serializers/project_mirror_entity_spec.rb
+++ b/spec/serializers/project_mirror_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectMirrorEntity do
let(:project) { create(:project, :repository, :remote_mirror) }
@@ -6,7 +6,7 @@ describe ProjectMirrorEntity do
subject { entity.as_json }
- it 'exposes project-specific elements' do
+ it "exposes project-specific elements" do
is_expected.to include(:id, :remote_mirrors_attributes)
end
end
diff --git a/spec/serializers/project_mirror_serializer_spec.rb b/spec/serializers/project_mirror_serializer_spec.rb
index 5e47163532a..4cefb87cf8f 100644
--- a/spec/serializers/project_mirror_serializer_spec.rb
+++ b/spec/serializers/project_mirror_serializer_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectMirrorSerializer do
- it 'represents ProjectMirror entities' do
+ it "represents ProjectMirror entities" do
expect(described_class.entity_class).to eq(ProjectMirrorEntity)
end
end
diff --git a/spec/serializers/project_note_entity_spec.rb b/spec/serializers/project_note_entity_spec.rb
index dafd1cf603e..abb90f1a7cd 100644
--- a/spec/serializers/project_note_entity_spec.rb
+++ b/spec/serializers/project_note_entity_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectNoteEntity do
include Gitlab::Routing
- let(:request) { double('request', current_user: user, noteable: note.noteable) }
+ let(:request) { double("request", current_user: user, noteable: note.noteable) }
let(:entity) { described_class.new(note, request: request) }
let(:note) { create(:note) }
let(:user) { create(:user) }
subject { entity.as_json }
- it_behaves_like 'note entity'
+ it_behaves_like "note entity"
- it 'exposes project-specific elements' do
+ it "exposes project-specific elements" do
expect(subject).to include(:human_access, :toggle_award_path, :path)
end
- context 'when note is part of resolvable discussion' do
+ context "when note is part of resolvable discussion" do
before do
allow(note).to receive(:part_of_discussion?).and_return(true)
allow(note).to receive(:resolvable?).and_return(true)
end
- it 'exposes paths to resolve note' do
+ it "exposes paths to resolve note" do
expect(subject).to include(:resolve_path, :resolve_with_issue_path)
end
end
diff --git a/spec/serializers/project_serializer_spec.rb b/spec/serializers/project_serializer_spec.rb
index 22f958fc17f..e40b8e466a5 100644
--- a/spec/serializers/project_serializer_spec.rb
+++ b/spec/serializers/project_serializer_spec.rb
@@ -1,12 +1,12 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProjectSerializer do
set(:project) { create(:project) }
- let(:provider_url) { 'http://provider.com' }
+ let(:provider_url) { "http://provider.com" }
- context 'when serializer option is :import' do
+ context "when serializer option is :import" do
subject do
described_class.new.represent(project, serializer: :import, provider_url: provider_url)
end
@@ -15,16 +15,16 @@ describe ProjectSerializer do
allow(ProjectImportEntity).to receive(:represent)
end
- it 'represents with ProjectImportEntity' do
+ it "represents with ProjectImportEntity" do
subject
expect(ProjectImportEntity)
.to have_received(:represent)
- .with(project, serializer: :import, provider_url: provider_url, request: an_instance_of(EntityRequest))
+ .with(project, serializer: :import, provider_url: provider_url, request: an_instance_of(EntityRequest))
end
end
- context 'when serializer option is omitted' do
+ context "when serializer option is omitted" do
subject do
described_class.new.represent(project)
end
@@ -33,12 +33,12 @@ describe ProjectSerializer do
allow(ProjectEntity).to receive(:represent)
end
- it 'represents with ProjectEntity' do
+ it "represents with ProjectEntity" do
subject
expect(ProjectEntity)
.to have_received(:represent)
- .with(project, request: an_instance_of(EntityRequest))
+ .with(project, request: an_instance_of(EntityRequest))
end
end
end
diff --git a/spec/serializers/provider_repo_entity_spec.rb b/spec/serializers/provider_repo_entity_spec.rb
index 9a1160d16d5..9cdb367931f 100644
--- a/spec/serializers/provider_repo_entity_spec.rb
+++ b/spec/serializers/provider_repo_entity_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProviderRepoEntity do
include ImportHelper
- let(:provider_repo) { { id: 1, full_name: 'full/name', name: 'name', owner: { login: 'owner' } } }
+ let(:provider_repo) { {id: 1, full_name: "full/name", name: "name", owner: {login: "owner"}} }
let(:provider) { :github }
- let(:provider_url) { 'https://github.com' }
+ let(:provider_url) { "https://github.com" }
let(:entity) { described_class.represent(provider_repo, provider: provider, provider_url: provider_url) }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'includes required fields' do
+ it "includes required fields" do
expect(subject[:id]).to eq(provider_repo[:id])
expect(subject[:full_name]).to eq(provider_repo[:full_name])
expect(subject[:owner_name]).to eq(provider_repo[:owner][:login])
diff --git a/spec/serializers/provider_repo_serializer_spec.rb b/spec/serializers/provider_repo_serializer_spec.rb
index f2be30c36d9..d6745779558 100644
--- a/spec/serializers/provider_repo_serializer_spec.rb
+++ b/spec/serializers/provider_repo_serializer_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ProviderRepoSerializer do
- it 'represents ProviderRepoEntity entities' do
+ it "represents ProviderRepoEntity entities" do
expect(described_class.entity_class).to eq(ProviderRepoEntity)
end
end
diff --git a/spec/serializers/remote_mirror_entity_spec.rb b/spec/serializers/remote_mirror_entity_spec.rb
index 885b0b9b423..0b65b0babca 100644
--- a/spec/serializers/remote_mirror_entity_spec.rb
+++ b/spec/serializers/remote_mirror_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RemoteMirrorEntity do
let(:project) { create(:project, :repository, :remote_mirror) }
@@ -7,7 +7,7 @@ describe RemoteMirrorEntity do
subject { entity.as_json }
- it 'exposes remote-mirror-specific elements' do
+ it "exposes remote-mirror-specific elements" do
is_expected.to include(
:id, :url, :enabled, :auth_method,
:ssh_known_hosts, :ssh_public_key, :ssh_known_hosts_fingerprints
diff --git a/spec/serializers/request_aware_entity_spec.rb b/spec/serializers/request_aware_entity_spec.rb
index aa666b961dc..3e20d94700c 100644
--- a/spec/serializers/request_aware_entity_spec.rb
+++ b/spec/serializers/request_aware_entity_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe RequestAwareEntity do
subject do
Class.new.include(described_class).new
end
- it 'includes URL helpers' do
+ it "includes URL helpers" do
expect(subject).to respond_to(:namespace_project_path)
end
- it 'includes method for checking abilities' do
+ it "includes method for checking abilities" do
expect(subject).to respond_to(:can?)
end
- it 'fetches request from options' do
+ it "fetches request from options" do
expect(subject).to receive(:options)
- .and_return({ request: 'some value' })
+ .and_return({request: "some value"})
- expect(subject.request).to eq 'some value'
+ expect(subject.request).to eq "some value"
end
end
diff --git a/spec/serializers/runner_entity_spec.rb b/spec/serializers/runner_entity_spec.rb
index ba99d568eba..b9e13f4e0f2 100644
--- a/spec/serializers/runner_entity_spec.rb
+++ b/spec/serializers/runner_entity_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe RunnerEntity do
let(:project) { create(:project) }
let(:runner) { create(:ci_runner, :project, projects: [project]) }
let(:entity) { described_class.new(runner, request: request, current_user: user) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:user) { create(:admin) }
before do
@@ -12,10 +12,10 @@ describe RunnerEntity do
allow(request).to receive(:project).and_return(project)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains required fields' do
+ it "contains required fields" do
expect(subject).to include(:id, :description)
expect(subject).to include(:edit_path)
end
diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb
index 2034c7891ef..92cbcabecc0 100644
--- a/spec/serializers/stage_entity_spec.rb
+++ b/spec/serializers/stage_entity_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe StageEntity do
let(:pipeline) { create(:ci_pipeline) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:user) { create(:user) }
let(:entity) do
@@ -10,7 +10,7 @@ describe StageEntity do
end
let(:stage) do
- build(:ci_stage, pipeline: pipeline, name: 'test')
+ build(:ci_stage, pipeline: pipeline, name: "test")
end
before do
@@ -18,51 +18,51 @@ describe StageEntity do
create(:ci_build, :success, pipeline: pipeline)
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains relevant fields' do
+ it "contains relevant fields" do
expect(subject).to include :name, :status, :path
end
- it 'contains detailed status' do
+ it "contains detailed status" do
expect(subject[:status]).to include :text, :label, :group, :icon, :tooltip
- expect(subject[:status][:label]).to eq 'passed'
+ expect(subject[:status][:label]).to eq "passed"
end
- it 'contains valid name' do
- expect(subject[:name]).to eq 'test'
+ it "contains valid name" do
+ expect(subject[:name]).to eq "test"
end
- it 'contains path to the stage' do
+ it "contains path to the stage" do
expect(subject[:path])
.to include "pipelines/#{pipeline.id}##{stage.name}"
end
- it 'contains path to the stage dropdown' do
+ it "contains path to the stage dropdown" do
expect(subject[:dropdown_path])
.to include "pipelines/#{pipeline.id}/stage.json?stage=test"
end
- it 'contains stage title' do
- expect(subject[:title]).to eq 'test: passed'
+ it "contains stage title" do
+ expect(subject[:title]).to eq "test: passed"
end
- context 'when the jobs should be grouped' do
+ context "when the jobs should be grouped" do
let(:entity) { described_class.new(stage, request: request, grouped: true) }
- it 'exposes the group key' do
+ it "exposes the group key" do
expect(subject).to include :groups
end
- context 'and contains commit status' do
+ context "and contains commit status" do
before do
- create(:generic_commit_status, pipeline: pipeline, stage: 'test')
+ create(:generic_commit_status, pipeline: pipeline, stage: "test")
end
- it 'contains commit status' do
+ it "contains commit status" do
groups = subject[:groups].map { |group| group[:name] }
- expect(groups).to include('generic')
+ expect(groups).to include("generic")
end
end
end
diff --git a/spec/serializers/suggestion_entity_spec.rb b/spec/serializers/suggestion_entity_spec.rb
index 047571f161c..e19fc173b49 100644
--- a/spec/serializers/suggestion_entity_spec.rb
+++ b/spec/serializers/suggestion_entity_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe SuggestionEntity do
include RepoHelpers
let(:user) { create(:user) }
- let(:request) { double('request', current_user: user) }
+ let(:request) { double("request", current_user: user) }
let(:suggestion) { create(:suggestion) }
let(:entity) { described_class.new(suggestion, request: request) }
subject { entity.as_json }
- it 'exposes correct attributes' do
+ it "exposes correct attributes" do
expect(subject).to include(:id, :from_original_line, :to_original_line, :from_line,
- :to_line, :appliable, :applied, :from_content, :to_content)
+ :to_line, :appliable, :applied, :from_content, :to_content)
end
- it 'exposes current user abilities' do
+ it "exposes current user abilities" do
expect(subject[:current_user]).to include(:can_apply)
end
end
diff --git a/spec/serializers/test_case_entity_spec.rb b/spec/serializers/test_case_entity_spec.rb
index a55910f98bb..9155e1db749 100644
--- a/spec/serializers/test_case_entity_spec.rb
+++ b/spec/serializers/test_case_entity_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe TestCaseEntity do
include TestReportsHelper
let(:entity) { described_class.new(test_case) }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- context 'when test case is success' do
+ context "when test case is success" do
let(:test_case) { create_test_case_rspec_success }
- it 'contains correct test case details' do
- expect(subject[:status]).to eq('success')
- expect(subject[:name]).to eq('Test#sum when a is 1 and b is 3 returns summary')
+ it "contains correct test case details" do
+ expect(subject[:status]).to eq("success")
+ expect(subject[:name]).to eq("Test#sum when a is 1 and b is 3 returns summary")
expect(subject[:execution_time]).to eq(1.11)
end
end
- context 'when test case is failed' do
+ context "when test case is failed" do
let(:test_case) { create_test_case_rspec_failed }
- it 'contains correct test case details' do
- expect(subject[:status]).to eq('failed')
- expect(subject[:name]).to eq('Test#sum when a is 2 and b is 2 returns summary')
+ it "contains correct test case details" do
+ expect(subject[:status]).to eq("failed")
+ expect(subject[:name]).to eq("Test#sum when a is 2 and b is 2 returns summary")
expect(subject[:execution_time]).to eq(2.22)
end
end
diff --git a/spec/serializers/test_reports_comparer_entity_spec.rb b/spec/serializers/test_reports_comparer_entity_spec.rb
index 59c058fe368..85c83ac0902 100644
--- a/spec/serializers/test_reports_comparer_entity_spec.rb
+++ b/spec/serializers/test_reports_comparer_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TestReportsComparerEntity do
include TestReportsHelper
@@ -8,52 +8,52 @@ describe TestReportsComparerEntity do
let(:base_reports) { Gitlab::Ci::Reports::TestReports.new }
let(:head_reports) { Gitlab::Ci::Reports::TestReports.new }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- context 'when head and base reports include two test suites' do
- context 'when the status of head report is success' do
+ context "when head and base reports include two test suites" do
+ context "when the status of head report is success" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_success)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'contains correct compared test reports details' do
- expect(subject[:status]).to eq('success')
+ it "contains correct compared test reports details" do
+ expect(subject[:status]).to eq("success")
expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 0)
- expect(subject[:suites].first[:name]).to eq('rspec')
- expect(subject[:suites].first[:status]).to eq('success')
- expect(subject[:suites].second[:name]).to eq('junit')
- expect(subject[:suites].second[:status]).to eq('success')
+ expect(subject[:suites].first[:name]).to eq("rspec")
+ expect(subject[:suites].first[:status]).to eq("success")
+ expect(subject[:suites].second[:name]).to eq("junit")
+ expect(subject[:suites].second[:status]).to eq("success")
end
end
- context 'when the status of head report is failed' do
+ context "when the status of head report is failed" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_success)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'contains correct compared test reports details' do
- expect(subject[:status]).to eq('failed')
+ it "contains correct compared test reports details" do
+ expect(subject[:status]).to eq("failed")
expect(subject[:summary]).to include(total: 2, resolved: 0, failed: 1)
- expect(subject[:suites].first[:name]).to eq('rspec')
- expect(subject[:suites].first[:status]).to eq('success')
- expect(subject[:suites].second[:name]).to eq('junit')
- expect(subject[:suites].second[:status]).to eq('failed')
+ expect(subject[:suites].first[:name]).to eq("rspec")
+ expect(subject[:suites].first[:status]).to eq("success")
+ expect(subject[:suites].second[:name]).to eq("junit")
+ expect(subject[:suites].second[:status]).to eq("failed")
end
end
- context 'when the status of head report is resolved' do
+ context "when the status of head report is resolved" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_resolved)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_resolved)
end
let(:create_test_case_java_resolved) do
@@ -62,13 +62,13 @@ describe TestReportsComparerEntity do
end
end
- it 'contains correct compared test reports details' do
- expect(subject[:status]).to eq('success')
+ it "contains correct compared test reports details" do
+ expect(subject[:status]).to eq("success")
expect(subject[:summary]).to include(total: 2, resolved: 1, failed: 0)
- expect(subject[:suites].first[:name]).to eq('rspec')
- expect(subject[:suites].first[:status]).to eq('success')
- expect(subject[:suites].second[:name]).to eq('junit')
- expect(subject[:suites].second[:status]).to eq('success')
+ expect(subject[:suites].first[:name]).to eq("rspec")
+ expect(subject[:suites].first[:status]).to eq("success")
+ expect(subject[:suites].second[:name]).to eq("junit")
+ expect(subject[:suites].second[:status]).to eq("success")
end
end
end
diff --git a/spec/serializers/test_reports_comparer_serializer_spec.rb b/spec/serializers/test_reports_comparer_serializer_spec.rb
index 9ea86c0dd83..4483bd7bbf4 100644
--- a/spec/serializers/test_reports_comparer_serializer_spec.rb
+++ b/spec/serializers/test_reports_comparer_serializer_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TestReportsComparerSerializer do
include TestReportsHelper
@@ -9,42 +9,42 @@ describe TestReportsComparerSerializer do
let(:base_reports) { Gitlab::Ci::Reports::TestReports.new }
let(:head_reports) { Gitlab::Ci::Reports::TestReports.new }
- describe '#to_json' do
+ describe "#to_json" do
subject { serializer.to_json }
- context 'when head and base reports include two test suites' do
- context 'when the status of head report is success' do
+ context "when head and base reports include two test suites" do
+ context "when the status of head report is success" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_success)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_success)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_success)
end
- it 'matches the schema' do
- expect(subject).to match_schema('entities/test_reports_comparer')
+ it "matches the schema" do
+ expect(subject).to match_schema("entities/test_reports_comparer")
end
end
- context 'when the status of head report is failed' do
+ context "when the status of head report is failed" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_success)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_success)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
end
- it 'matches the schema' do
- expect(subject).to match_schema('entities/test_reports_comparer')
+ it "matches the schema" do
+ expect(subject).to match_schema("entities/test_reports_comparer")
end
end
- context 'when the status of head report is resolved' do
+ context "when the status of head report is resolved" do
before do
- base_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- base_reports.get_suite('junit').add_test_case(create_test_case_java_failed)
- head_reports.get_suite('rspec').add_test_case(create_test_case_rspec_success)
- head_reports.get_suite('junit').add_test_case(create_test_case_java_resolved)
+ base_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ base_reports.get_suite("junit").add_test_case(create_test_case_java_failed)
+ head_reports.get_suite("rspec").add_test_case(create_test_case_rspec_success)
+ head_reports.get_suite("junit").add_test_case(create_test_case_java_resolved)
end
let(:create_test_case_java_resolved) do
@@ -53,8 +53,8 @@ describe TestReportsComparerSerializer do
end
end
- it 'matches the schema' do
- expect(subject).to match_schema('entities/test_reports_comparer')
+ it "matches the schema" do
+ expect(subject).to match_schema("entities/test_reports_comparer")
end
end
end
diff --git a/spec/serializers/test_suite_comparer_entity_spec.rb b/spec/serializers/test_suite_comparer_entity_spec.rb
index f61331f53a0..4a3ae3eca67 100644
--- a/spec/serializers/test_suite_comparer_entity_spec.rb
+++ b/spec/serializers/test_suite_comparer_entity_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe TestSuiteComparerEntity do
include TestReportsHelper
let(:entity) { described_class.new(comparer) }
let(:comparer) { Gitlab::Ci::Reports::TestSuiteComparer.new(name, base_suite, head_suite) }
- let(:name) { 'rpsec' }
+ let(:name) { "rpsec" }
let(:base_suite) { Gitlab::Ci::Reports::TestSuite.new(name) }
let(:head_suite) { Gitlab::Ci::Reports::TestSuite.new(name) }
let(:test_case_success) { create_test_case_rspec_success }
@@ -17,18 +17,18 @@ describe TestSuiteComparerEntity do
end
end
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- context 'when head sutie has a newly failed test case which does not exist in base' do
+ context "when head sutie has a newly failed test case which does not exist in base" do
before do
base_suite.add_test_case(test_case_success)
head_suite.add_test_case(test_case_failed)
end
- it 'contains correct compared test suite details' do
+ it "contains correct compared test suite details" do
expect(subject[:name]).to eq(name)
- expect(subject[:status]).to eq('failed')
+ expect(subject[:status]).to eq("failed")
expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1)
subject[:new_failures].first.tap do |new_failure|
expect(new_failure[:status]).to eq(test_case_failed.status)
@@ -41,15 +41,15 @@ describe TestSuiteComparerEntity do
end
end
- context 'when head sutie still has a failed test case which failed in base' do
+ context "when head sutie still has a failed test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_failed)
end
- it 'contains correct compared test suite details' do
+ it "contains correct compared test suite details" do
expect(subject[:name]).to eq(name)
- expect(subject[:status]).to eq('failed')
+ expect(subject[:status]).to eq("failed")
expect(subject[:summary]).to include(total: 1, resolved: 0, failed: 1)
expect(subject[:new_failures]).to be_empty
expect(subject[:resolved_failures]).to be_empty
@@ -62,15 +62,15 @@ describe TestSuiteComparerEntity do
end
end
- context 'when head sutie has a success test case which failed in base' do
+ context "when head sutie has a success test case which failed in base" do
before do
base_suite.add_test_case(test_case_failed)
head_suite.add_test_case(test_case_resolved)
end
- it 'contains correct compared test suite details' do
+ it "contains correct compared test suite details" do
expect(subject[:name]).to eq(name)
- expect(subject[:status]).to eq('success')
+ expect(subject[:status]).to eq("success")
expect(subject[:summary]).to include(total: 1, resolved: 1, failed: 0)
expect(subject[:new_failures]).to be_empty
subject[:resolved_failures].first.tap do |resolved_failure|
diff --git a/spec/serializers/trigger_variable_entity_spec.rb b/spec/serializers/trigger_variable_entity_spec.rb
index 66567c05f52..4c088b20895 100644
--- a/spec/serializers/trigger_variable_entity_spec.rb
+++ b/spec/serializers/trigger_variable_entity_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe TriggerVariableEntity do
let(:project) { create(:project) }
- let(:request) { double('request') }
+ let(:request) { double("request") }
let(:user) { create(:user) }
- let(:variable) { { key: 'TEST_KEY', value: 'TEST_VALUE' } }
+ let(:variable) { {key: "TEST_KEY", value: "TEST_VALUE"} }
subject { described_class.new(variable, request: request).as_json }
@@ -13,36 +13,36 @@ describe TriggerVariableEntity do
allow(request).to receive(:project).and_return(project)
end
- it 'exposes the variable key' do
+ it "exposes the variable key" do
expect(subject).to include(:key)
end
- context 'when user has access to the value' do
- context 'when user is maintainer' do
+ context "when user has access to the value" do
+ context "when user is maintainer" do
before do
project.team.add_maintainer(user)
end
- it 'exposes the variable value' do
+ it "exposes the variable value" do
expect(subject).to include(:value)
end
end
- context 'when user is owner' do
+ context "when user is owner" do
let(:user) { project.owner }
- it 'exposes the variable value' do
+ it "exposes the variable value" do
expect(subject).to include(:value)
end
end
end
- context 'when user does not have access to the value' do
+ context "when user does not have access to the value" do
before do
project.team.add_developer(user)
end
- it 'does not expose the variable value' do
+ it "does not expose the variable value" do
expect(subject).not_to include(:value)
end
end
diff --git a/spec/serializers/user_entity_spec.rb b/spec/serializers/user_entity_spec.rb
index cd778e49107..fa70fc8c03b 100644
--- a/spec/serializers/user_entity_spec.rb
+++ b/spec/serializers/user_entity_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UserEntity do
include Gitlab::Routing
@@ -7,23 +7,23 @@ describe UserEntity do
let(:user) { create(:user) }
subject { entity.as_json }
- it 'exposes user name and login' do
+ it "exposes user name and login" do
expect(subject).to include(:username, :name)
end
- it 'does not expose passwords' do
+ it "does not expose passwords" do
expect(subject).not_to include(/password/)
end
- it 'does not expose tokens' do
+ it "does not expose tokens" do
expect(subject).not_to include(/token/)
end
- it 'does not expose 2FA OTPs' do
+ it "does not expose 2FA OTPs" do
expect(subject).not_to include(/otp/)
end
- it 'exposes user path' do
+ it "exposes user path" do
expect(subject[:path]).to eq user_path(user)
end
end
diff --git a/spec/serializers/variable_entity_spec.rb b/spec/serializers/variable_entity_spec.rb
index effc0022633..e5e90d204c6 100644
--- a/spec/serializers/variable_entity_spec.rb
+++ b/spec/serializers/variable_entity_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe VariableEntity do
let(:variable) { create(:ci_variable) }
let(:entity) { described_class.new(variable) }
- describe '#as_json' do
+ describe "#as_json" do
subject { entity.as_json }
- it 'contains required fields' do
+ it "contains required fields" do
expect(subject).to include(:id, :key, :value, :protected)
end
end
diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb
index 38a3f522504..55ccfd81bd3 100644
--- a/spec/services/access_token_validation_service_spec.rb
+++ b/spec/services/access_token_validation_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AccessTokenValidationService do
describe ".include_any_scope?" do
@@ -32,7 +32,7 @@ describe AccessTokenValidationService do
expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true)
end
- it 'returns true if the list of required scopes is blank' do
+ it "returns true if the list of required scopes is blank" do
token = double("token", scopes: [])
scopes = []
diff --git a/spec/services/after_branch_delete_service_spec.rb b/spec/services/after_branch_delete_service_spec.rb
index bc9747d1413..815328f5bbf 100644
--- a/spec/services/after_branch_delete_service_spec.rb
+++ b/spec/services/after_branch_delete_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe AfterBranchDeleteService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- it 'stops environments attached to branch' do
+ describe "#execute" do
+ it "stops environments attached to branch" do
expect(service).to receive(:stop_environments)
- service.execute('feature')
+ service.execute("feature")
end
end
end
diff --git a/spec/services/application_settings/update_service_spec.rb b/spec/services/application_settings/update_service_spec.rb
index a4a733eff77..b5d85f52f7e 100644
--- a/spec/services/application_settings/update_service_spec.rb
+++ b/spec/services/application_settings/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ApplicationSettings::UpdateService do
let(:application_settings) { create(:application_setting) }
@@ -9,103 +9,103 @@ describe ApplicationSettings::UpdateService do
before do
# So the caching behaves like it would in production
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
# Creating these settings first ensures they're used by other factories
application_settings
end
- describe 'updating terms' do
- context 'when the passed terms are blank' do
- let(:params) { { terms: '' } }
+ describe "updating terms" do
+ context "when the passed terms are blank" do
+ let(:params) { {terms: ""} }
- it 'does not create terms' do
+ it "does not create terms" do
expect { subject.execute }.not_to change { ApplicationSetting::Term.count }
end
end
- context 'when passing terms' do
- let(:params) { { terms: 'Be nice! ' } }
+ context "when passing terms" do
+ let(:params) { {terms: "Be nice! "} }
- it 'creates the terms' do
+ it "creates the terms" do
expect { subject.execute }.to change { ApplicationSetting::Term.count }.by(1)
end
- it 'does not create terms if they are the same as the existing ones' do
- create(:term, terms: 'Be nice!')
+ it "does not create terms if they are the same as the existing ones" do
+ create(:term, terms: "Be nice!")
expect { subject.execute }.not_to change { ApplicationSetting::Term.count }
end
- it 'updates terms if they already existed' do
- create(:term, terms: 'Other terms')
+ it "updates terms if they already existed" do
+ create(:term, terms: "Other terms")
subject.execute
- expect(application_settings.terms).to eq('Be nice!')
+ expect(application_settings.terms).to eq("Be nice!")
end
- it 'Only queries once when the terms are changed' do
- create(:term, terms: 'Other terms')
- expect(application_settings.terms).to eq('Other terms')
+ it "Only queries once when the terms are changed" do
+ create(:term, terms: "Other terms")
+ expect(application_settings.terms).to eq("Other terms")
subject.execute
- expect(application_settings.terms).to eq('Be nice!')
+ expect(application_settings.terms).to eq("Be nice!")
expect { 2.times { application_settings.terms } }
.not_to exceed_query_limit(0)
end
end
end
- describe 'performance bar settings' do
+ describe "performance bar settings" do
using RSpec::Parameterized::TableSyntax
where(:params_performance_bar_enabled,
:params_performance_bar_allowed_group_path,
:previous_performance_bar_allowed_group_id,
:expected_performance_bar_allowed_group_id) do
- true | '' | nil | nil
- true | '' | 42_000_000 | nil
+ true | "" | nil | nil
+ true | "" | 42_000_000 | nil
true | nil | nil | nil
true | nil | 42_000_000 | nil
- true | 'foo' | nil | nil
- true | 'foo' | 42_000_000 | nil
- true | 'group_a' | nil | 42_000_000
- true | 'group_b' | 42_000_000 | 43_000_000
- true | 'group_a' | 42_000_000 | 42_000_000
- false | '' | nil | nil
- false | '' | 42_000_000 | nil
+ true | "foo" | nil | nil
+ true | "foo" | 42_000_000 | nil
+ true | "group_a" | nil | 42_000_000
+ true | "group_b" | 42_000_000 | 43_000_000
+ true | "group_a" | 42_000_000 | 42_000_000
+ false | "" | nil | nil
+ false | "" | 42_000_000 | nil
false | nil | nil | nil
false | nil | 42_000_000 | nil
- false | 'foo' | nil | nil
- false | 'foo' | 42_000_000 | nil
- false | 'group_a' | nil | nil
- false | 'group_b' | 42_000_000 | nil
- false | 'group_a' | 42_000_000 | nil
+ false | "foo" | nil | nil
+ false | "foo" | 42_000_000 | nil
+ false | "group_a" | nil | nil
+ false | "group_b" | 42_000_000 | nil
+ false | "group_a" | 42_000_000 | nil
end
with_them do
let(:params) do
{
performance_bar_enabled: params_performance_bar_enabled,
- performance_bar_allowed_group_path: params_performance_bar_allowed_group_path
+ performance_bar_allowed_group_path: params_performance_bar_allowed_group_path,
}
end
before do
- if previous_performance_bar_allowed_group_id == 42_000_000 || params_performance_bar_allowed_group_path == 'group_a'
- create(:group, id: 42_000_000, path: 'group_a')
+ if previous_performance_bar_allowed_group_id == 42_000_000 || params_performance_bar_allowed_group_path == "group_a"
+ create(:group, id: 42_000_000, path: "group_a")
end
- if expected_performance_bar_allowed_group_id == 43_000_000 || params_performance_bar_allowed_group_path == 'group_b'
- create(:group, id: 43_000_000, path: 'group_b')
+ if expected_performance_bar_allowed_group_id == 43_000_000 || params_performance_bar_allowed_group_path == "group_b"
+ create(:group, id: 43_000_000, path: "group_b")
end
application_settings.update!(performance_bar_allowed_group_id: previous_performance_bar_allowed_group_id)
end
- it 'sets performance_bar_allowed_group_id when present and performance_bar_enabled == true' do
+ it "sets performance_bar_allowed_group_id when present and performance_bar_enabled == true" do
expect(application_settings.performance_bar_allowed_group_id).to eq(previous_performance_bar_allowed_group_id)
if previous_performance_bar_allowed_group_id != expected_performance_bar_allowed_group_id
@@ -119,24 +119,24 @@ describe ApplicationSettings::UpdateService do
end
end
- context 'when :performance_bar_allowed_group_path is not present' do
+ context "when :performance_bar_allowed_group_path is not present" do
let(:group) { create(:group) }
before do
application_settings.update!(performance_bar_allowed_group_id: group.id)
end
- it 'does not change the performance bar settings' do
+ it "does not change the performance bar settings" do
expect { subject.execute }
.not_to change(application_settings, :performance_bar_allowed_group_id)
end
end
- context 'when :performance_bar_enabled is not present' do
+ context "when :performance_bar_enabled is not present" do
let(:group) { create(:group) }
- let(:params) { { performance_bar_allowed_group_path: group.full_path } }
+ let(:params) { {performance_bar_allowed_group_path: group.full_path} }
- it 'implicitely defaults to true' do
+ it "implicitely defaults to true" do
expect { subject.execute }
.to change(application_settings, :performance_bar_allowed_group_id)
.from(nil).to(group.id)
diff --git a/spec/services/audit_event_service_spec.rb b/spec/services/audit_event_service_spec.rb
index 32fd98e6ef9..69466a8b2ef 100644
--- a/spec/services/audit_event_service_spec.rb
+++ b/spec/services/audit_event_service_spec.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe AuditEventService do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:project_member) { create(:project_member, user: user) }
- let(:service) { described_class.new(user, project, { action: :destroy }) }
+ let(:service) { described_class.new(user, project, {action: :destroy}) }
let(:logger) { instance_double(Gitlab::AuditJsonLogger) }
- describe '#security_event' do
+ describe "#security_event" do
before do
expect(service).to receive(:file_logger).and_return(logger)
end
- it 'creates an event and logs to a file' do
+ it "creates an event and logs to a file" do
expect(logger).to receive(:info).with(author_id: user.id,
entity_id: project.id,
entity_type: "Project",
diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb
index 8021bd338e0..5b9e563dc89 100644
--- a/spec/services/auth/container_registry_authentication_service_spec.rb
+++ b/spec/services/auth/container_registry_authentication_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Auth::ContainerRegistryAuthenticationService do
let(:current_project) { nil }
let(:current_user) { nil }
let(:current_params) { {} }
let(:rsa_key) { OpenSSL::PKey::RSA.generate(512) }
- let(:payload) { JWT.decode(subject[:token], rsa_key, true, { algorithm: 'RS256' }).first }
+ let(:payload) { JWT.decode(subject[:token], rsa_key, true, {algorithm: "RS256"}).first }
let(:authentication_abilities) do
[:read_container_image, :create_container_image, :admin_container_image]
@@ -17,28 +17,28 @@ describe Auth::ContainerRegistryAuthenticationService do
end
before do
- allow(Gitlab.config.registry).to receive_messages(enabled: true, issuer: 'rspec', key: nil)
+ allow(Gitlab.config.registry).to receive_messages(enabled: true, issuer: "rspec", key: nil)
allow_any_instance_of(JSONWebToken::RSAToken).to receive(:key).and_return(rsa_key)
end
- shared_examples 'an authenticated' do
+ shared_examples "an authenticated" do
it { is_expected.to include(:token) }
- it { expect(payload).to include('access') }
+ it { expect(payload).to include("access") }
end
- shared_examples 'a valid token' do
+ shared_examples "a valid token" do
it { is_expected.to include(:token) }
- it { expect(payload).to include('access') }
+ it { expect(payload).to include("access") }
- context 'a expirable' do
- let(:expires_at) { Time.at(payload['exp']) }
+ context "a expirable" do
+ let(:expires_at) { Time.at(payload["exp"]) }
let(:expire_delay) { 10 }
- context 'for default configuration' do
+ context "for default configuration" do
it { expect(expires_at).not_to be_within(2.seconds).of(Time.now + expire_delay.minutes) }
end
- context 'for changed configuration' do
+ context "for changed configuration" do
before do
stub_application_setting(container_registry_token_expire_delay: expire_delay)
end
@@ -48,307 +48,307 @@ describe Auth::ContainerRegistryAuthenticationService do
end
end
- shared_examples 'a browsable' do
+ shared_examples "a browsable" do
let(:access) do
- [{ 'type' => 'registry',
- 'name' => 'catalog',
- 'actions' => ['*'] }]
+ [{"type" => "registry",
+ "name" => "catalog",
+ "actions" => ["*"],}]
end
- it_behaves_like 'a valid token'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a valid token"
+ it_behaves_like "not a container repository factory"
- it 'has the correct scope' do
- expect(payload).to include('access' => access)
+ it "has the correct scope" do
+ expect(payload).to include("access" => access)
end
end
- shared_examples 'an accessible' do
+ shared_examples "an accessible" do
let(:access) do
- [{ 'type' => 'repository',
- 'name' => project.full_path,
- 'actions' => actions }]
+ [{"type" => "repository",
+ "name" => project.full_path,
+ "actions" => actions,}]
end
- it_behaves_like 'a valid token'
+ it_behaves_like "a valid token"
- it 'has the correct scope' do
- expect(payload).to include('access' => access)
+ it "has the correct scope" do
+ expect(payload).to include("access" => access)
end
end
- shared_examples 'an inaccessible' do
- it_behaves_like 'a valid token'
- it { expect(payload).to include('access' => []) }
+ shared_examples "an inaccessible" do
+ it_behaves_like "a valid token"
+ it { expect(payload).to include("access" => []) }
end
- shared_examples 'a deletable' do
- it_behaves_like 'an accessible' do
- let(:actions) { ['*'] }
+ shared_examples "a deletable" do
+ it_behaves_like "an accessible" do
+ let(:actions) { ["*"] }
end
end
- shared_examples 'a pullable' do
- it_behaves_like 'an accessible' do
- let(:actions) { ['pull'] }
+ shared_examples "a pullable" do
+ it_behaves_like "an accessible" do
+ let(:actions) { ["pull"] }
end
end
- shared_examples 'a pushable' do
- it_behaves_like 'an accessible' do
- let(:actions) { ['push'] }
+ shared_examples "a pushable" do
+ it_behaves_like "an accessible" do
+ let(:actions) { ["push"] }
end
end
- shared_examples 'a pullable and pushable' do
- it_behaves_like 'an accessible' do
- let(:actions) { %w(pull push) }
+ shared_examples "a pullable and pushable" do
+ it_behaves_like "an accessible" do
+ let(:actions) { %w[pull push] }
end
end
- shared_examples 'a forbidden' do
+ shared_examples "a forbidden" do
it { is_expected.to include(http_status: 403) }
it { is_expected.not_to include(:token) }
end
- shared_examples 'container repository factory' do
- it 'creates a new container repository resource' do
+ shared_examples "container repository factory" do
+ it "creates a new container repository resource" do
expect { subject }
.to change { project.container_repositories.count }.by(1)
end
end
- shared_examples 'not a container repository factory' do
- it 'does not create a new container repository resource' do
+ shared_examples "not a container repository factory" do
+ it "does not create a new container repository resource" do
expect { subject }.not_to change { ContainerRepository.count }
end
end
- describe '#full_access_token' do
+ describe "#full_access_token" do
let(:project) { create(:project) }
let(:token) { described_class.full_access_token(project.full_path) }
- subject { { token: token } }
+ subject { {token: token} }
- it_behaves_like 'an accessible' do
- let(:actions) { ['*'] }
+ it_behaves_like "an accessible" do
+ let(:actions) { ["*"] }
end
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "not a container repository factory"
end
- context 'user authorization' do
+ context "user authorization" do
let(:current_user) { create(:user) }
- context 'for registry catalog' do
+ context "for registry catalog" do
let(:current_params) do
- { scopes: ["registry:catalog:*"] }
+ {scopes: ["registry:catalog:*"]}
end
- context 'disallow browsing for users without GitLab admin rights' do
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ context "disallow browsing for users without GitLab admin rights" do
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project) }
- context 'allow to use scope-less authentication' do
- it_behaves_like 'a valid token'
+ context "allow to use scope-less authentication" do
+ it_behaves_like "a valid token"
end
- context 'allow developer to push images' do
+ context "allow developer to push images" do
before do
project.add_developer(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'a pushable'
- it_behaves_like 'container repository factory'
+ it_behaves_like "a pushable"
+ it_behaves_like "container repository factory"
end
- context 'disallow developer to delete images' do
+ context "disallow developer to delete images" do
before do
project.add_developer(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'allow reporter to pull images' do
+ context "allow reporter to pull images" do
before do
project.add_reporter(current_user)
end
- context 'when pulling from root level repository' do
+ context "when pulling from root level repository" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
end
- context 'disallow reporter to delete images' do
+ context "disallow reporter to delete images" do
before do
project.add_reporter(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'return a least of privileges' do
+ context "return a least of privileges" do
before do
project.add_reporter(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push,pull"] }
+ {scopes: ["repository:#{project.full_path}:push,pull"]}
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow guest to pull or push images' do
+ context "disallow guest to pull or push images" do
before do
project.add_guest(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull,push"] }
+ {scopes: ["repository:#{project.full_path}:pull,push"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow guest to delete images' do
+ context "disallow guest to delete images" do
before do
project.add_guest(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- context 'allow anyone to pull images' do
+ context "allow anyone to pull images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow anyone to push images' do
+ context "disallow anyone to push images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow anyone to delete images' do
+ context "disallow anyone to delete images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'when repository name is invalid' do
+ context "when repository name is invalid" do
let(:current_params) do
- { scopes: ['repository:invalid:push'] }
+ {scopes: ["repository:invalid:push"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for internal project' do
+ context "for internal project" do
let(:project) { create(:project, :internal) }
- context 'for internal user' do
- context 'allow anyone to pull images' do
+ context "for internal user" do
+ context "allow anyone to pull images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow anyone to push images' do
+ context "disallow anyone to push images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow anyone to delete images' do
+ context "disallow anyone to delete images" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for external user' do
- context 'disallow anyone to pull or push images' do
+ context "for external user" do
+ context "disallow anyone to pull or push images" do
let(:current_user) { create(:user, external: true) }
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull,push"] }
+ {scopes: ["repository:#{project.full_path}:pull,push"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'disallow anyone to delete images' do
+ context "disallow anyone to delete images" do
let(:current_user) { create(:user, external: true) }
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:*"] }
+ {scopes: ["repository:#{project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
end
end
- context 'delete authorized as maintainer' do
+ context "delete authorized as maintainer" do
let(:current_project) { create(:project) }
let(:current_user) { create(:user) }
@@ -360,20 +360,20 @@ describe Auth::ContainerRegistryAuthenticationService do
current_project.add_maintainer(current_user)
end
- it_behaves_like 'a valid token'
+ it_behaves_like "a valid token"
- context 'allow to delete images' do
+ context "allow to delete images" do
let(:current_params) do
- { scopes: ["repository:#{current_project.full_path}:*"] }
+ {scopes: ["repository:#{current_project.full_path}:*"]}
end
- it_behaves_like 'a deletable' do
+ it_behaves_like "a deletable" do
let(:project) { current_project }
end
end
end
- context 'build authorized as user' do
+ context "build authorized as user" do
let(:current_project) { create(:project) }
let(:current_user) { create(:user) }
@@ -385,165 +385,165 @@ describe Auth::ContainerRegistryAuthenticationService do
current_project.add_developer(current_user)
end
- context 'allow to use offline_token' do
+ context "allow to use offline_token" do
let(:current_params) do
- { offline_token: true }
+ {offline_token: true}
end
- it_behaves_like 'an authenticated'
+ it_behaves_like "an authenticated"
end
- it_behaves_like 'a valid token'
+ it_behaves_like "a valid token"
- context 'allow to pull and push images' do
+ context "allow to pull and push images" do
let(:current_params) do
- { scopes: ["repository:#{current_project.full_path}:pull,push"] }
+ {scopes: ["repository:#{current_project.full_path}:pull,push"]}
end
- it_behaves_like 'a pullable and pushable' do
+ it_behaves_like "a pullable and pushable" do
let(:project) { current_project }
end
- it_behaves_like 'container repository factory' do
+ it_behaves_like "container repository factory" do
let(:project) { current_project }
end
end
- context 'disallow to delete images' do
+ context "disallow to delete images" do
let(:current_params) do
- { scopes: ["repository:#{current_project.full_path}:*"] }
+ {scopes: ["repository:#{current_project.full_path}:*"]}
end
- it_behaves_like 'an inaccessible' do
+ it_behaves_like "an inaccessible" do
let(:project) { current_project }
end
end
- context 'for other projects' do
- context 'when pulling' do
+ context "for other projects" do
+ context "when pulling" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- context 'allow for public' do
+ context "allow for public" do
let(:project) { create(:project, :public) }
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- shared_examples 'pullable for being team member' do
- context 'when you are not member' do
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ shared_examples "pullable for being team member" do
+ context "when you are not member" do
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'when you are member' do
+ context "when you are member" do
before do
project.add_developer(current_user)
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'when you are owner' do
+ context "when you are owner" do
let(:project) { create(:project, namespace: current_user.namespace) }
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for private' do
+ context "for private" do
let(:project) { create(:project, :private) }
- it_behaves_like 'pullable for being team member'
+ it_behaves_like "pullable for being team member"
- context 'when you are admin' do
+ context "when you are admin" do
let(:current_user) { create(:admin) }
- context 'when you are not member' do
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ context "when you are not member" do
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'when you are member' do
+ context "when you are member" do
before do
project.add_developer(current_user)
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'when you are owner' do
+ context "when you are owner" do
let(:project) { create(:project, namespace: current_user.namespace) }
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
end
end
end
- context 'when pushing' do
+ context "when pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- context 'disallow for all' do
- context 'when you are member' do
+ context "disallow for all" do
+ context "when you are member" do
let(:project) { create(:project, :public) }
before do
project.add_developer(current_user)
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
- context 'when you are owner' do
+ context "when you are owner" do
let(:project) { create(:project, :public, namespace: current_user.namespace) }
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
end
end
- context 'for project without container registry' do
+ context "for project without container registry" do
let(:project) { create(:project, :public, container_registry_enabled: false) }
before do
project.update(container_registry_enabled: false)
end
- context 'disallow when pulling' do
+ context "disallow when pulling" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- it_behaves_like 'an inaccessible'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "an inaccessible"
+ it_behaves_like "not a container repository factory"
end
end
end
- context 'registry catalog browsing authorized as admin' do
+ context "registry catalog browsing authorized as admin" do
let(:current_user) { create(:user, :admin) }
let(:project) { create(:project, :public) }
let(:current_params) do
- { scopes: ["registry:catalog:*"] }
+ {scopes: ["registry:catalog:*"]}
end
- it_behaves_like 'a browsable'
+ it_behaves_like "a browsable"
end
- context 'support for multiple scopes' do
+ context "support for multiple scopes" do
let(:internal_project) { create(:project, :internal) }
let(:private_project) { create(:project, :private) }
@@ -551,260 +551,260 @@ describe Auth::ContainerRegistryAuthenticationService do
{
scopes: [
"repository:#{internal_project.full_path}:pull",
- "repository:#{private_project.full_path}:pull"
- ]
+ "repository:#{private_project.full_path}:pull",
+ ],
}
end
- context 'user has access to all projects' do
+ context "user has access to all projects" do
let(:current_user) { create(:user, :admin) }
- it_behaves_like 'a browsable' do
+ it_behaves_like "a browsable" do
let(:access) do
[
- { 'type' => 'repository',
- 'name' => internal_project.full_path,
- 'actions' => ['pull'] },
- { 'type' => 'repository',
- 'name' => private_project.full_path,
- 'actions' => ['pull'] }
+ {"type" => "repository",
+ "name" => internal_project.full_path,
+ "actions" => ["pull"],},
+ {"type" => "repository",
+ "name" => private_project.full_path,
+ "actions" => ["pull"],},
]
end
end
end
- context 'user only has access to internal project' do
+ context "user only has access to internal project" do
let(:current_user) { create(:user) }
- it_behaves_like 'a browsable' do
+ it_behaves_like "a browsable" do
let(:access) do
[
- { 'type' => 'repository',
- 'name' => internal_project.full_path,
- 'actions' => ['pull'] }
+ {"type" => "repository",
+ "name" => internal_project.full_path,
+ "actions" => ["pull"],},
]
end
end
end
- context 'anonymous access is rejected' do
+ context "anonymous access is rejected" do
let(:current_user) { nil }
- it_behaves_like 'a forbidden'
+ it_behaves_like "a forbidden"
end
end
- context 'unauthorized' do
- context 'disallow to use scope-less authentication' do
- it_behaves_like 'a forbidden'
- it_behaves_like 'not a container repository factory'
+ context "unauthorized" do
+ context "disallow to use scope-less authentication" do
+ it_behaves_like "a forbidden"
+ it_behaves_like "not a container repository factory"
end
- context 'for invalid scope' do
+ context "for invalid scope" do
let(:current_params) do
- { scopes: ['invalid:aa:bb'] }
+ {scopes: ["invalid:aa:bb"]}
end
- it_behaves_like 'a forbidden'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a forbidden"
+ it_behaves_like "not a container repository factory"
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project, :private) }
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- it_behaves_like 'a forbidden'
+ it_behaves_like "a forbidden"
end
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- context 'when pulling and pushing' do
+ context "when pulling and pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull,push"] }
+ {scopes: ["repository:#{project.full_path}:pull,push"]}
end
- it_behaves_like 'a pullable'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a pullable"
+ it_behaves_like "not a container repository factory"
end
- context 'when pushing' do
+ context "when pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'a forbidden'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a forbidden"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for registry catalog' do
+ context "for registry catalog" do
let(:current_params) do
- { scopes: ["registry:catalog:*"] }
+ {scopes: ["registry:catalog:*"]}
end
- it_behaves_like 'a forbidden'
- it_behaves_like 'not a container repository factory'
+ it_behaves_like "a forbidden"
+ it_behaves_like "not a container repository factory"
end
end
- context 'for deploy tokens' do
+ context "for deploy tokens" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:pull"] }
+ {scopes: ["repository:#{project.full_path}:pull"]}
end
- context 'when deploy token has read_registry as a scope' do
+ context "when deploy token has read_registry as a scope" do
let(:current_user) { create(:deploy_token, projects: [project]) }
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- context 'when pulling' do
- it_behaves_like 'a pullable'
+ context "when pulling" do
+ it_behaves_like "a pullable"
end
- context 'when pushing' do
+ context "when pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'an inaccessible'
+ it_behaves_like "an inaccessible"
end
end
- context 'for internal project' do
+ context "for internal project" do
let(:project) { create(:project, :internal) }
- context 'when pulling' do
- it_behaves_like 'a pullable'
+ context "when pulling" do
+ it_behaves_like "a pullable"
end
- context 'when pushing' do
+ context "when pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'an inaccessible'
+ it_behaves_like "an inaccessible"
end
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project, :private) }
- context 'when pulling' do
- it_behaves_like 'a pullable'
+ context "when pulling" do
+ it_behaves_like "a pullable"
end
- context 'when pushing' do
+ context "when pushing" do
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'an inaccessible'
+ it_behaves_like "an inaccessible"
end
end
end
- context 'when deploy token does not have read_registry scope' do
+ context "when deploy token does not have read_registry scope" do
let(:current_user) { create(:deploy_token, projects: [project], read_registry: false) }
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- context 'when pulling' do
- it_behaves_like 'a pullable'
+ context "when pulling" do
+ it_behaves_like "a pullable"
end
end
- context 'for internal project' do
+ context "for internal project" do
let(:project) { create(:project, :internal) }
- context 'when pulling' do
- it_behaves_like 'an inaccessible'
+ context "when pulling" do
+ it_behaves_like "an inaccessible"
end
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project, :internal) }
- context 'when pulling' do
- it_behaves_like 'an inaccessible'
+ context "when pulling" do
+ it_behaves_like "an inaccessible"
end
end
end
- context 'when deploy token is not related to the project' do
+ context "when deploy token is not related to the project" do
let(:current_user) { create(:deploy_token, read_registry: false) }
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- context 'when pulling' do
- it_behaves_like 'a pullable'
+ context "when pulling" do
+ it_behaves_like "a pullable"
end
end
- context 'for internal project' do
+ context "for internal project" do
let(:project) { create(:project, :internal) }
- context 'when pulling' do
- it_behaves_like 'an inaccessible'
+ context "when pulling" do
+ it_behaves_like "an inaccessible"
end
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project, :internal) }
- context 'when pulling' do
- it_behaves_like 'an inaccessible'
+ context "when pulling" do
+ it_behaves_like "an inaccessible"
end
end
end
- context 'when deploy token has been revoked' do
+ context "when deploy token has been revoked" do
let(:current_user) { create(:deploy_token, :revoked, projects: [project]) }
- context 'for public project' do
+ context "for public project" do
let(:project) { create(:project, :public) }
- it_behaves_like 'a pullable'
+ it_behaves_like "a pullable"
end
- context 'for internal project' do
+ context "for internal project" do
let(:project) { create(:project, :internal) }
- it_behaves_like 'an inaccessible'
+ it_behaves_like "an inaccessible"
end
- context 'for private project' do
+ context "for private project" do
let(:project) { create(:project, :internal) }
- it_behaves_like 'an inaccessible'
+ it_behaves_like "an inaccessible"
end
end
end
- context 'user authorization' do
+ context "user authorization" do
let(:current_user) { create(:user) }
- context 'with multiple scopes' do
+ context "with multiple scopes" do
let(:project) { create(:project) }
let(:project2) { create }
- context 'allow developer to push images' do
+ context "allow developer to push images" do
before do
project.add_developer(current_user)
end
let(:current_params) do
- { scopes: ["repository:#{project.full_path}:push"] }
+ {scopes: ["repository:#{project.full_path}:push"]}
end
- it_behaves_like 'a pushable'
- it_behaves_like 'container repository factory'
+ it_behaves_like "a pushable"
+ it_behaves_like "container repository factory"
end
end
end
diff --git a/spec/services/base_count_service_spec.rb b/spec/services/base_count_service_spec.rb
index 090b2dcdd43..aa106f1fade 100644
--- a/spec/services/base_count_service_spec.rb
+++ b/spec/services/base_count_service_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe BaseCountService, :use_clean_rails_memory_store_caching do
let(:service) { described_class.new }
- describe '#relation_for_count' do
- it 'raises NotImplementedError' do
+ describe "#relation_for_count" do
+ it "raises NotImplementedError" do
expect { service.relation_for_count }.to raise_error(NotImplementedError)
end
end
- describe '#count' do
- it 'returns the number of values' do
+ describe "#count" do
+ it "returns the number of values" do
expect(service)
.to receive(:cache_key)
- .and_return('foo')
+ .and_return("foo")
expect(service)
.to receive(:uncached_count)
@@ -23,8 +23,8 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#uncached_count' do
- it 'returns the uncached number of values' do
+ describe "#uncached_count" do
+ it "returns the uncached number of values" do
expect(service)
.to receive(:relation_for_count)
.and_return(double(:relation, count: 5))
@@ -33,11 +33,11 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#refresh_cache' do
- it 'refreshes the cache' do
+ describe "#refresh_cache" do
+ it "refreshes the cache" do
allow(service)
.to receive(:cache_key)
- .and_return('foo')
+ .and_return("foo")
allow(service)
.to receive(:uncached_count)
@@ -49,11 +49,11 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#delete_cache' do
- it 'deletes the cache' do
+ describe "#delete_cache" do
+ it "deletes the cache" do
allow(service)
.to receive(:cache_key)
- .and_return('foo')
+ .and_return("foo")
allow(service)
.to receive(:uncached_count)
@@ -66,21 +66,21 @@ describe BaseCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#raw?' do
- it 'returns false' do
+ describe "#raw?" do
+ it "returns false" do
expect(service.raw?).to eq(false)
end
end
- describe '#cache_key' do
- it 'raises NotImplementedError' do
+ describe "#cache_key" do
+ it "raises NotImplementedError" do
expect { service.cache_key }.to raise_error(NotImplementedError)
end
end
- describe '#cache_options' do
- it 'returns the default in options' do
- expect(service.cache_options).to eq({ raw: false })
+ describe "#cache_options" do
+ it "returns the default in options" do
+ expect(service.cache_options).to eq({raw: false})
end
end
end
diff --git a/spec/services/boards/create_service_spec.rb b/spec/services/boards/create_service_spec.rb
index a715261cd6c..313bf00b7ed 100644
--- a/spec/services/boards/create_service_spec.rb
+++ b/spec/services/boards/create_service_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::CreateService do
- describe '#execute' do
- context 'when board parent is a project' do
+ describe "#execute" do
+ context "when board parent is a project" do
let(:parent) { create(:project) }
subject(:service) { described_class.new(parent, double) }
- it_behaves_like 'boards create service'
+ it_behaves_like "boards create service"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:parent) { create(:group) }
subject(:service) { described_class.new(parent, double) }
- it_behaves_like 'boards create service'
+ it_behaves_like "boards create service"
end
end
end
diff --git a/spec/services/boards/issues/create_service_spec.rb b/spec/services/boards/issues/create_service_spec.rb
index f0179e35652..67ddcb146ee 100644
--- a/spec/services/boards/issues/create_service_spec.rb
+++ b/spec/services/boards/issues/create_service_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Issues::CreateService do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
- let(:label) { create(:label, project: project, name: 'in-progress') }
+ let(:label) { create(:label, project: project, name: "in-progress") }
let!(:list) { create(:list, board: board, label: label, position: 0) }
- subject(:service) { described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: 'New issue') }
+ subject(:service) { described_class.new(board.parent, project, user, board_id: board.id, list_id: list.id, title: "New issue") }
before do
project.add_developer(user)
end
- it 'delegates the create proceedings to Issues::CreateService' do
+ it "delegates the create proceedings to Issues::CreateService" do
expect_any_instance_of(Issues::CreateService).to receive(:execute).once
service.execute
end
- it 'creates a new issue' do
+ it "creates a new issue" do
expect { service.execute }.to change(project.issues, :count).by(1)
end
- it 'adds the label of the list to the issue' do
+ it "adds the label of the list to the issue" do
issue = service.execute
expect(issue.labels).to eq [label]
diff --git a/spec/services/boards/issues/list_service_spec.rb b/spec/services/boards/issues/list_service_spec.rb
index aaad29536af..2e846134407 100644
--- a/spec/services/boards/issues/list_service_spec.rb
+++ b/spec/services/boards/issues/list_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Issues::ListService do
- describe '#execute' do
- context 'when parent is a project' do
+ describe "#execute" do
+ context "when parent is a project" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
@@ -10,21 +10,21 @@ describe Boards::Issues::ListService do
let(:m1) { create(:milestone, project: project) }
let(:m2) { create(:milestone, project: project) }
- let(:bug) { create(:label, project: project, name: 'Bug') }
- let(:development) { create(:label, project: project, name: 'Development') }
- let(:testing) { create(:label, project: project, name: 'Testing') }
- let(:p1) { create(:label, title: 'P1', project: project, priority: 1) }
- let(:p2) { create(:label, title: 'P2', project: project, priority: 2) }
- let(:p3) { create(:label, title: 'P3', project: project, priority: 3) }
+ let(:bug) { create(:label, project: project, name: "Bug") }
+ let(:development) { create(:label, project: project, name: "Development") }
+ let(:testing) { create(:label, project: project, name: "Testing") }
+ let(:p1) { create(:label, title: "P1", project: project, priority: 1) }
+ let(:p2) { create(:label, title: "P2", project: project, priority: 2) }
+ let(:p3) { create(:label, title: "P3", project: project, priority: 3) }
let!(:backlog) { create(:backlog_list, board: board) }
let!(:list1) { create(:list, board: board, label: development, position: 0) }
let!(:list2) { create(:list, board: board, label: testing, position: 1) }
let!(:closed) { create(:closed_list, board: board) }
- let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
- let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2]) }
- let!(:reopened_issue1) { create(:issue, :opened, project: project, title: 'Reopened Issue 1' ) }
+ let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: "Issue 1", labels: [bug]) }
+ let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: "Issue 2", labels: [p2]) }
+ let!(:reopened_issue1) { create(:issue, :opened, project: project, title: "Reopened Issue 1") }
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) }
let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
@@ -43,16 +43,16 @@ describe Boards::Issues::ListService do
project.add_developer(user)
end
- it_behaves_like 'issues list service'
+ it_behaves_like "issues list service"
- context 'when project is archived' do
+ context "when project is archived" do
let(:project) { create(:project, :archived) }
- it_behaves_like 'issues list service'
+ it_behaves_like "issues list service"
end
end
- context 'when parent is a group' do
+ context "when parent is a group" do
let(:user) { create(:user) }
let(:project) { create(:project, :empty_repo, namespace: group) }
let(:project1) { create(:project, :empty_repo, namespace: group) }
@@ -61,31 +61,31 @@ describe Boards::Issues::ListService do
let(:m1) { create(:milestone, group: group) }
let(:m2) { create(:milestone, group: group) }
- let(:bug) { create(:group_label, group: group, name: 'Bug') }
- let(:development) { create(:group_label, group: group, name: 'Development') }
- let(:testing) { create(:group_label, group: group, name: 'Testing') }
+ let(:bug) { create(:group_label, group: group, name: "Bug") }
+ let(:development) { create(:group_label, group: group, name: "Development") }
+ let(:testing) { create(:group_label, group: group, name: "Testing") }
- let(:p1) { create(:group_label, title: 'P1', group: group) }
- let(:p2) { create(:group_label, title: 'P2', group: group) }
- let(:p3) { create(:group_label, title: 'P3', group: group) }
+ let(:p1) { create(:group_label, title: "P1", group: group) }
+ let(:p2) { create(:group_label, title: "P2", group: group) }
+ let(:p3) { create(:group_label, title: "P3", group: group) }
- let(:p1_project) { create(:label, title: 'P1_project', project: project, priority: 1) }
- let(:p2_project) { create(:label, title: 'P2_project', project: project, priority: 2) }
- let(:p3_project) { create(:label, title: 'P3_project', project: project, priority: 3) }
+ let(:p1_project) { create(:label, title: "P1_project", project: project, priority: 1) }
+ let(:p2_project) { create(:label, title: "P2_project", project: project, priority: 2) }
+ let(:p3_project) { create(:label, title: "P3_project", project: project, priority: 3) }
- let(:p1_project1) { create(:label, title: 'P1_project1', project: project1, priority: 1) }
- let(:p2_project1) { create(:label, title: 'P2_project1', project: project1, priority: 2) }
- let(:p3_project1) { create(:label, title: 'P3_project1', project: project1, priority: 3) }
+ let(:p1_project1) { create(:label, title: "P1_project1", project: project1, priority: 1) }
+ let(:p2_project1) { create(:label, title: "P2_project1", project: project1, priority: 2) }
+ let(:p3_project1) { create(:label, title: "P3_project1", project: project1, priority: 3) }
let!(:backlog) { create(:backlog_list, board: board) }
let!(:list1) { create(:list, board: board, label: development, position: 0) }
let!(:list2) { create(:list, board: board, label: testing, position: 1) }
let!(:closed) { create(:closed_list, board: board) }
- let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
- let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2, p2_project]) }
- let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: 'Issue 3', labels: [bug]) }
- let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Reopened Issue 1', closed_at: Time.now ) }
+ let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: "Issue 1", labels: [bug]) }
+ let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: "Issue 2", labels: [p2, p2_project]) }
+ let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: "Issue 3", labels: [bug]) }
+ let!(:reopened_issue1) { create(:issue, state: "opened", project: project, title: "Reopened Issue 1", closed_at: Time.now) }
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, p2_project, development]) }
let!(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
@@ -102,15 +102,15 @@ describe Boards::Issues::ListService do
group.add_developer(user)
end
- context 'and group has no parent' do
+ context "and group has no parent" do
let(:parent) { group }
let(:group) { create(:group) }
let(:board) { create(:board, group: group) }
- it_behaves_like 'issues list service'
+ it_behaves_like "issues list service"
end
- context 'and group is an ancestor', :nested_groups do
+ context "and group is an ancestor", :nested_groups do
let(:parent) { create(:group) }
let(:group) { create(:group, parent: parent) }
let!(:backlog) { create(:backlog_list, board: board) }
@@ -120,7 +120,7 @@ describe Boards::Issues::ListService do
parent.add_developer(user)
end
- it_behaves_like 'issues list service'
+ it_behaves_like "issues list service"
end
end
end
diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb
index 6020f0771e5..9533e31fc08 100644
--- a/spec/services/boards/issues/move_service_spec.rb
+++ b/spec/services/boards/issues/move_service_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Issues::MoveService do
- describe '#execute' do
- context 'when parent is a project' do
+ describe "#execute" do
+ context "when parent is a project" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:board1) { create(:board, project: project) }
let(:board2) { create(:board, project: project) }
- let(:bug) { create(:label, project: project, name: 'Bug') }
- let(:development) { create(:label, project: project, name: 'Development') }
- let(:testing) { create(:label, project: project, name: 'Testing') }
- let(:regression) { create(:label, project: project, name: 'Regression') }
+ let(:bug) { create(:label, project: project, name: "Bug") }
+ let(:development) { create(:label, project: project, name: "Development") }
+ let(:testing) { create(:label, project: project, name: "Testing") }
+ let(:regression) { create(:label, project: project, name: "Regression") }
let!(:list1) { create(:list, board: board1, label: development, position: 0) }
let!(:list2) { create(:list, board: board1, label: testing, position: 1) }
@@ -23,20 +23,20 @@ describe Boards::Issues::MoveService do
parent.add_developer(user)
end
- it_behaves_like 'issues move service'
+ it_behaves_like "issues move service"
end
- context 'when parent is a group' do
+ context "when parent is a group" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:board1) { create(:board, group: group) }
let(:board2) { create(:board, group: group) }
- let(:bug) { create(:group_label, group: group, name: 'Bug') }
- let(:development) { create(:group_label, group: group, name: 'Development') }
- let(:testing) { create(:group_label, group: group, name: 'Testing') }
- let(:regression) { create(:group_label, group: group, name: 'Regression') }
+ let(:bug) { create(:group_label, group: group, name: "Bug") }
+ let(:development) { create(:group_label, group: group, name: "Development") }
+ let(:testing) { create(:group_label, group: group, name: "Testing") }
+ let(:regression) { create(:group_label, group: group, name: "Regression") }
let!(:list1) { create(:list, board: board1, label: development, position: 0) }
let!(:list2) { create(:list, board: board1, label: testing, position: 1) }
@@ -48,7 +48,7 @@ describe Boards::Issues::MoveService do
parent.add_developer(user)
end
- it_behaves_like 'issues move service', true
+ it_behaves_like "issues move service", true
end
end
end
diff --git a/spec/services/boards/list_service_spec.rb b/spec/services/boards/list_service_spec.rb
index 7518e9e9b75..219f075718b 100644
--- a/spec/services/boards/list_service_spec.rb
+++ b/spec/services/boards/list_service_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::ListService do
- describe '#execute' do
- context 'when board parent is a project' do
+ describe "#execute" do
+ context "when board parent is a project" do
let(:parent) { create(:project) }
subject(:service) { described_class.new(parent, double) }
- it_behaves_like 'boards list service'
+ it_behaves_like "boards list service"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:parent) { create(:group) }
subject(:service) { described_class.new(parent, double) }
- it_behaves_like 'boards list service'
+ it_behaves_like "boards list service"
end
end
end
diff --git a/spec/services/boards/lists/create_service_spec.rb b/spec/services/boards/lists/create_service_spec.rb
index 7d3f5f86deb..199932133c4 100644
--- a/spec/services/boards/lists/create_service_spec.rb
+++ b/spec/services/boards/lists/create_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Lists::CreateService do
- describe '#execute' do
- shared_examples 'creating board lists' do
+ describe "#execute" do
+ shared_examples "creating board lists" do
let(:user) { create(:user) }
subject(:service) { described_class.new(parent, user, label_id: label.id) }
@@ -11,24 +11,24 @@ describe Boards::Lists::CreateService do
parent.add_developer(user)
end
- context 'when board lists is empty' do
- it 'creates a new list at beginning of the list' do
+ context "when board lists is empty" do
+ it "creates a new list at beginning of the list" do
list = service.execute(board)
expect(list.position).to eq 0
end
end
- context 'when board lists has the done list' do
- it 'creates a new list at beginning of the list' do
+ context "when board lists has the done list" do
+ it "creates a new list at beginning of the list" do
list = service.execute(board)
expect(list.position).to eq 0
end
end
- context 'when board lists has labels lists' do
- it 'creates a new list at end of the lists' do
+ context "when board lists has labels lists" do
+ it "creates a new list at end of the lists" do
create(:list, board: board, position: 0)
create(:list, board: board, position: 1)
@@ -38,8 +38,8 @@ describe Boards::Lists::CreateService do
end
end
- context 'when board lists has label and done lists' do
- it 'creates a new list at end of the label lists' do
+ context "when board lists has label and done lists" do
+ it "creates a new list at end of the label lists" do
list1 = create(:list, board: board, position: 0)
list2 = service.execute(board)
@@ -49,9 +49,9 @@ describe Boards::Lists::CreateService do
end
end
- context 'when provided label does not belongs to the parent' do
- it 'raises an error' do
- label = create(:label, name: 'in-development')
+ context "when provided label does not belongs to the parent" do
+ it "raises an error" do
+ label = create(:label, name: "in-development")
service = described_class.new(parent, user, label_id: label.id)
expect { service.execute(board) }.to raise_error(ActiveRecord::RecordNotFound)
@@ -59,20 +59,20 @@ describe Boards::Lists::CreateService do
end
end
- context 'when board parent is a project' do
+ context "when board parent is a project" do
let(:parent) { create(:project) }
let(:board) { create(:board, project: parent) }
- let(:label) { create(:label, project: parent, name: 'in-progress') }
+ let(:label) { create(:label, project: parent, name: "in-progress") }
- it_behaves_like 'creating board lists'
+ it_behaves_like "creating board lists"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:parent) { create(:group) }
let(:board) { create(:board, group: parent) }
- let(:label) { create(:group_label, group: parent, name: 'in-progress') }
+ let(:label) { create(:group_label, group: parent, name: "in-progress") }
- it_behaves_like 'creating board lists'
+ it_behaves_like "creating board lists"
end
end
end
diff --git a/spec/services/boards/lists/destroy_service_spec.rb b/spec/services/boards/lists/destroy_service_spec.rb
index 3c4eb6b3fc5..4356d3d9831 100644
--- a/spec/services/boards/lists/destroy_service_spec.rb
+++ b/spec/services/boards/lists/destroy_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Lists::DestroyService do
- describe '#execute' do
- context 'when board parent is a project' do
+ describe "#execute" do
+ context "when board parent is a project" do
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
let(:parent) { project }
- it_behaves_like 'lists destroy service'
+ it_behaves_like "lists destroy service"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:group) { create(:group) }
let(:board) { create(:board, group: group) }
let(:user) { create(:user) }
let(:parent) { group }
- it_behaves_like 'lists destroy service'
+ it_behaves_like "lists destroy service"
end
end
end
diff --git a/spec/services/boards/lists/generate_service_spec.rb b/spec/services/boards/lists/generate_service_spec.rb
index 82dbd1ee744..699eb104e42 100644
--- a/spec/services/boards/lists/generate_service_spec.rb
+++ b/spec/services/boards/lists/generate_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Lists::GenerateService do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
@@ -12,29 +12,29 @@ describe Boards::Lists::GenerateService do
project.add_developer(user)
end
- context 'when board lists is empty' do
- it 'creates the default lists' do
+ context "when board lists is empty" do
+ it "creates the default lists" do
expect { service.execute(board) }.to change(board.lists, :count).by(2)
end
end
- context 'when board lists is not empty' do
- it 'does not creates the default lists' do
+ context "when board lists is not empty" do
+ it "does not creates the default lists" do
create(:list, board: board)
expect { service.execute(board) }.not_to change(board.lists, :count)
end
end
- context 'when project labels does not contains any list label' do
- it 'creates labels' do
+ context "when project labels does not contains any list label" do
+ it "creates labels" do
expect { service.execute(board) }.to change(project.labels, :count).by(2)
end
end
- context 'when project labels contains some of list label' do
- it 'creates the missing labels' do
- create(:label, project: project, name: 'Doing')
+ context "when project labels contains some of list label" do
+ it "creates the missing labels" do
+ create(:label, project: project, name: "Doing")
expect { service.execute(board) }.to change(project.labels, :count).by(1)
end
diff --git a/spec/services/boards/lists/list_service_spec.rb b/spec/services/boards/lists/list_service_spec.rb
index 24e04eed642..e23f4cc4560 100644
--- a/spec/services/boards/lists/list_service_spec.rb
+++ b/spec/services/boards/lists/list_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Lists::ListService do
- describe '#execute' do
- context 'when board parent is a project' do
+ describe "#execute" do
+ context "when board parent is a project" do
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:label) { create(:label, project: project) }
let!(:list) { create(:list, board: board, label: label) }
let(:service) { described_class.new(project, double) }
- it_behaves_like 'lists list service'
+ it_behaves_like "lists list service"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:group) { create(:group) }
let(:board) { create(:board, group: group) }
let(:label) { create(:group_label, group: group) }
let!(:list) { create(:list, board: board, label: label) }
let(:service) { described_class.new(group, double) }
- it_behaves_like 'lists list service'
+ it_behaves_like "lists list service"
end
end
end
diff --git a/spec/services/boards/lists/move_service_spec.rb b/spec/services/boards/lists/move_service_spec.rb
index 16dfb2ae6af..cb853e94b0f 100644
--- a/spec/services/boards/lists/move_service_spec.rb
+++ b/spec/services/boards/lists/move_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Boards::Lists::MoveService do
- describe '#execute' do
- context 'when board parent is a project' do
+ describe "#execute" do
+ context "when board parent is a project" do
let(:project) { create(:project) }
let(:board) { create(:board, project: project) }
let(:user) { create(:user) }
let(:parent) { project }
- it_behaves_like 'lists move service'
+ it_behaves_like "lists move service"
end
- context 'when board parent is a group' do
+ context "when board parent is a group" do
let(:group) { create(:group) }
let(:board) { create(:board, group: group) }
let(:user) { create(:user) }
let(:parent) { group }
- it_behaves_like 'lists move service'
+ it_behaves_like "lists move service"
end
end
end
diff --git a/spec/services/boards/visits/create_service_spec.rb b/spec/services/boards/visits/create_service_spec.rb
index 6baf7ac9deb..6be65ff5f67 100644
--- a/spec/services/boards/visits/create_service_spec.rb
+++ b/spec/services/boards/visits/create_service_spec.rb
@@ -1,49 +1,49 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Boards::Visits::CreateService do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
- context 'when a project board' do
+ context "when a project board" do
let(:project) { create(:project) }
let(:project_board) { create(:board, project: project) }
subject(:service) { described_class.new(project_board.parent, user) }
- it 'returns nil when there is no user' do
+ it "returns nil when there is no user" do
service.current_user = nil
expect(service.execute(project_board)).to eq nil
end
- it 'returns nil when database is read only' do
+ it "returns nil when database is read only" do
allow(Gitlab::Database).to receive(:read_only?) { true }
expect(service.execute(project_board)).to eq nil
end
- it 'records the visit' do
+ it "records the visit" do
expect(BoardProjectRecentVisit).to receive(:visited!).once
service.execute(project_board)
end
end
- context 'when a group board' do
+ context "when a group board" do
let(:group) { create(:group) }
let(:group_board) { create(:board, group: group) }
subject(:service) { described_class.new(group_board.parent, user) }
- it 'returns nil when there is no user' do
+ it "returns nil when there is no user" do
service.current_user = nil
expect(service.execute(group_board)).to eq nil
end
- it 'records the visit' do
+ it "records the visit" do
expect(BoardGroupRecentVisit).to receive(:visited!).once
service.execute(group_board)
diff --git a/spec/services/boards/visits/latest_service_spec.rb b/spec/services/boards/visits/latest_service_spec.rb
index e55d599e2cc..eb4afbede09 100644
--- a/spec/services/boards/visits/latest_service_spec.rb
+++ b/spec/services/boards/visits/latest_service_spec.rb
@@ -1,43 +1,43 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Boards::Visits::LatestService do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
- context 'when a project board' do
+ context "when a project board" do
let(:project) { create(:project) }
let(:project_board) { create(:board, project: project) }
subject(:service) { described_class.new(project_board.parent, user) }
- it 'returns nil when there is no user' do
+ it "returns nil when there is no user" do
service.current_user = nil
expect(service.execute).to eq nil
end
- it 'queries for most recent visit' do
+ it "queries for most recent visit" do
expect(BoardProjectRecentVisit).to receive(:latest).once
service.execute
end
end
- context 'when a group board' do
+ context "when a group board" do
let(:group) { create(:group) }
let(:group_board) { create(:board, group: group) }
subject(:service) { described_class.new(group_board.parent, user) }
- it 'returns nil when there is no user' do
+ it "returns nil when there is no user" do
service.current_user = nil
expect(service.execute).to eq nil
end
- it 'queries for most recent visit' do
+ it "queries for most recent visit" do
expect(BoardGroupRecentVisit).to receive(:latest).once
service.execute
diff --git a/spec/services/chat_names/authorize_user_service_spec.rb b/spec/services/chat_names/authorize_user_service_spec.rb
index d88b2504133..0042b12c13c 100644
--- a/spec/services/chat_names/authorize_user_service_spec.rb
+++ b/spec/services/chat_names/authorize_user_service_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatNames::AuthorizeUserService do
- describe '#execute' do
+ describe "#execute" do
let(:service) { create(:service) }
subject { described_class.new(service, params).execute }
- context 'when all parameters are valid' do
- let(:params) { { team_id: 'T0001', team_domain: 'myteam', user_id: 'U0001', user_name: 'user' } }
+ context "when all parameters are valid" do
+ let(:params) { {team_id: "T0001", team_domain: "myteam", user_id: "U0001", user_name: "user"} }
- it 'requests a new token' do
+ it "requests a new token" do
is_expected.to be_url
end
end
- context 'when there are missing parameters' do
+ context "when there are missing parameters" do
let(:params) { {} }
- it 'does not request a new token' do
+ it "does not request a new token" do
is_expected.to be_nil
end
end
diff --git a/spec/services/chat_names/find_user_service_spec.rb b/spec/services/chat_names/find_user_service_spec.rb
index 5734b10109a..5c1ffd33207 100644
--- a/spec/services/chat_names/find_user_service_spec.rb
+++ b/spec/services/chat_names/find_user_service_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
- describe '#execute' do
+ describe "#execute" do
let(:service) { create(:service) }
subject { described_class.new(service, params).execute }
- context 'find user mapping' do
+ context "find user mapping" do
let(:user) { create(:user) }
let!(:chat_name) { create(:chat_name, user: user, service: service) }
- context 'when existing user is requested' do
- let(:params) { { team_id: chat_name.team_id, user_id: chat_name.chat_id } }
+ context "when existing user is requested" do
+ let(:params) { {team_id: chat_name.team_id, user_id: chat_name.chat_id} }
- it 'returns the existing chat_name' do
+ it "returns the existing chat_name" do
is_expected.to eq(chat_name)
end
- it 'updates the last used timestamp if one is not already set' do
+ it "updates the last used timestamp if one is not already set" do
expect(chat_name.last_used_at).to be_nil
subject
@@ -25,7 +25,7 @@ describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
expect(chat_name.reload.last_used_at).to be_present
end
- it 'only updates an existing timestamp once within a certain time frame' do
+ it "only updates an existing timestamp once within a certain time frame" do
service = described_class.new(service, params)
expect(chat_name.last_used_at).to be_nil
@@ -40,10 +40,10 @@ describe ChatNames::FindUserService, :clean_gitlab_redis_shared_state do
end
end
- context 'when different user is requested' do
- let(:params) { { team_id: chat_name.team_id, user_id: 'non-existing-user' } }
+ context "when different user is requested" do
+ let(:params) { {team_id: chat_name.team_id, user_id: "non-existing-user"} }
- it 'returns existing user' do
+ it "returns existing user" do
is_expected.to be_nil
end
end
diff --git a/spec/services/ci/archive_trace_service_spec.rb b/spec/services/ci/archive_trace_service_spec.rb
index 8e9cb65f3bc..776079d64b0 100644
--- a/spec/services/ci/archive_trace_service_spec.rb
+++ b/spec/services/ci/archive_trace_service_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::ArchiveTraceService, '#execute' do
+describe Ci::ArchiveTraceService, "#execute" do
subject { described_class.new.execute(job) }
- context 'when job is finished' do
+ context "when job is finished" do
let(:job) { create(:ci_build, :success, :trace_live) }
- it 'creates an archived trace' do
+ it "creates an archived trace" do
expect { subject }.not_to raise_error
expect(job.reload.job_artifacts_trace).to be_exist
end
- context 'when trace is already archived' do
+ context "when trace is already archived" do
let!(:job) { create(:ci_build, :success, :trace_artifact) }
- it 'ignores an exception' do
+ it "ignores an exception" do
expect { subject }.not_to raise_error
end
- it 'does not create an archived trace' do
+ it "does not create an archived trace" do
expect { subject }.not_to change { Ci::JobArtifact.trace.count }
end
end
end
- context 'when job is running' do
+ context "when job is running" do
let(:job) { create(:ci_build, :running, :trace_live) }
- it 'increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive' do
+ it "increments Prometheus counter, sends crash report to Sentry and ignore an error for continuing to archive" do
expect(Gitlab::Sentry)
.to receive(:track_exception)
.with(::Gitlab::Ci::Trace::ArchiveError,
- issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/51502',
- extra: { job_id: job.id } ).once
+ issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/51502",
+ extra: {job_id: job.id}).once
expect(Rails.logger)
.to receive(:error)
diff --git a/spec/services/ci/compare_test_reports_service_spec.rb b/spec/services/ci/compare_test_reports_service_spec.rb
index a26c970a8f0..181ed36d40a 100644
--- a/spec/services/ci/compare_test_reports_service_spec.rb
+++ b/spec/services/ci/compare_test_reports_service_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::CompareTestReportsService do
let(:service) { described_class.new(project) }
let(:project) { create(:project, :repository) }
- describe '#execute' do
+ describe "#execute" do
subject { service.execute(base_pipeline, head_pipeline) }
- context 'when head pipeline has test reports' do
+ context "when head pipeline has test reports" do
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
- it 'returns status and data' do
+ it "returns status and data" do
expect(subject[:status]).to eq(:parsed)
- expect(subject[:data]).to match_schema('entities/test_reports_comparer')
+ expect(subject[:data]).to match_schema("entities/test_reports_comparer")
end
end
- context 'when base and head pipelines have test reports' do
+ context "when base and head pipelines have test reports" do
let!(:base_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
- it 'returns status and data' do
+ it "returns status and data" do
expect(subject[:status]).to eq(:parsed)
- expect(subject[:data]).to match_schema('entities/test_reports_comparer')
+ expect(subject[:data]).to match_schema("entities/test_reports_comparer")
end
end
- context 'when head pipeline has corrupted test reports' do
+ context "when head pipeline has corrupted test reports" do
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ci_pipeline, project: project) }
@@ -36,38 +36,38 @@ describe Ci::CompareTestReportsService do
create(:ci_job_artifact, :junit_with_corrupted_data, job: build, project: project)
end
- it 'returns status and error message' do
+ it "returns status and error message" do
expect(subject[:status]).to eq(:error)
- expect(subject[:status_reason]).to include('XML parsing failed')
+ expect(subject[:status_reason]).to include("XML parsing failed")
end
end
end
- describe '#latest?' do
+ describe "#latest?" do
subject { service.latest?(base_pipeline, head_pipeline, data) }
let!(:base_pipeline) { nil }
let!(:head_pipeline) { create(:ci_pipeline, :with_test_reports, project: project) }
let!(:key) { service.send(:key, base_pipeline, head_pipeline) }
- context 'when cache key is latest' do
- let(:data) { { key: key } }
+ context "when cache key is latest" do
+ let(:data) { {key: key} }
it { is_expected.to be_truthy }
end
- context 'when cache key is outdated' do
+ context "when cache key is outdated" do
before do
head_pipeline.update_column(:updated_at, 10.minutes.ago)
end
- let(:data) { { key: key } }
+ let(:data) { {key: key} }
it { is_expected.to be_falsy }
end
- context 'when cache key is empty' do
- let(:data) { { key: nil } }
+ context "when cache key is empty" do
+ let(:data) { {key: nil} }
it { is_expected.to be_falsy }
end
diff --git a/spec/services/ci/create_pipeline_service_spec.rb b/spec/services/ci/create_pipeline_service_spec.rb
index 93349ba7b5b..44dbdb2db83 100644
--- a/spec/services/ci/create_pipeline_service_spec.rb
+++ b/spec/services/ci/create_pipeline_service_spec.rb
@@ -1,65 +1,67 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::CreatePipelineService do
include ProjectForksHelper
set(:project) { create(:project, :repository) }
let(:user) { create(:admin) }
- let(:ref_name) { 'refs/heads/master' }
+ let(:ref_name) { "refs/heads/master" }
before do
stub_repository_ci_yaml_file(sha: anything)
end
- describe '#execute' do
+ describe "#execute" do
# rubocop:disable Metrics/ParameterLists
def execute_service(
source: :push,
after: project.commit.id,
- message: 'Message',
+ message: "Message",
ref: ref_name,
trigger_request: nil,
variables_attributes: nil,
merge_request: nil,
push_options: nil,
source_sha: nil,
- target_sha: nil)
- params = { ref: ref,
- before: '00000000',
- after: after,
- commits: [{ message: message }],
- variables_attributes: variables_attributes,
- push_options: push_options,
- source_sha: source_sha,
- target_sha: target_sha }
+ target_sha: nil
+ )
+ params = {ref: ref,
+ before: "00000000",
+ after: after,
+ commits: [{message: message}],
+ variables_attributes: variables_attributes,
+ push_options: push_options,
+ source_sha: source_sha,
+ target_sha: target_sha,}
described_class.new(project, user, params).execute(
- source, trigger_request: trigger_request, merge_request: merge_request)
+ source, trigger_request: trigger_request, merge_request: merge_request
+ )
end
# rubocop:enable Metrics/ParameterLists
- context 'valid params' do
+ context "valid params" do
let(:pipeline) { execute_service }
let(:pipeline_on_previous_commit) do
execute_service(
- after: previous_commit_sha_from_ref('master')
+ after: previous_commit_sha_from_ref("master")
)
end
- it 'creates a pipeline' do
+ it "creates a pipeline" do
expect(pipeline).to be_kind_of(Ci::Pipeline)
expect(pipeline).to be_valid
expect(pipeline).to be_persisted
expect(pipeline).to be_push
expect(pipeline).to eq(project.ci_pipelines.last)
expect(pipeline).to have_attributes(user: user)
- expect(pipeline).to have_attributes(status: 'pending')
+ expect(pipeline).to have_attributes(status: "pending")
expect(pipeline.repository_source?).to be true
expect(pipeline.builds.first).to be_kind_of(Ci::Build)
end
- it 'increments the prometheus counter' do
+ it "increments the prometheus counter" do
expect(Gitlab::Metrics).to receive(:counter)
.with(:pipelines_created_total, "Counter of pipelines created")
.and_call_original
@@ -67,46 +69,46 @@ describe Ci::CreatePipelineService do
pipeline
end
- context 'when merge requests already exist for this source branch' do
+ context "when merge requests already exist for this source branch" do
let(:merge_request_1) do
- create(:merge_request, source_branch: 'feature', target_branch: "master", source_project: project)
+ create(:merge_request, source_branch: "feature", target_branch: "master", source_project: project)
end
let(:merge_request_2) do
- create(:merge_request, source_branch: 'feature', target_branch: "v1.1.0", source_project: project)
+ create(:merge_request, source_branch: "feature", target_branch: "v1.1.0", source_project: project)
end
- context 'when related merge request is already merged' do
+ context "when related merge request is already merged" do
let!(:merged_merge_request) do
- create(:merge_request, source_branch: 'master', target_branch: "branch_2", source_project: project, state: 'merged')
+ create(:merge_request, source_branch: "master", target_branch: "branch_2", source_project: project, state: "merged")
end
- it 'does not schedule update head pipeline job' do
+ it "does not schedule update head pipeline job" do
expect(UpdateHeadPipelineForMergeRequestWorker).not_to receive(:perform_async).with(merged_merge_request.id)
execute_service
end
end
- context 'when the head pipeline sha equals merge request sha' do
- it 'updates head pipeline of each merge request' do
+ context "when the head pipeline sha equals merge request sha" do
+ it "updates head pipeline of each merge request" do
merge_request_1
merge_request_2
- head_pipeline = execute_service(ref: 'feature', after: nil)
+ head_pipeline = execute_service(ref: "feature", after: nil)
expect(merge_request_1.reload.head_pipeline).to eq(head_pipeline)
expect(merge_request_2.reload.head_pipeline).to eq(head_pipeline)
end
end
- context 'when the head pipeline sha does not equal merge request sha' do
- it 'does not update the head piepeline of MRs' do
+ context "when the head pipeline sha does not equal merge request sha" do
+ it "does not update the head piepeline of MRs" do
merge_request_1
merge_request_2
allow_any_instance_of(Ci::Pipeline).to receive(:latest?).and_return(true)
- expect { execute_service(after: 'ae73cb07c9eeaf35924a10f713b364d32b2dd34f') }.not_to raise_error
+ expect { execute_service(after: "ae73cb07c9eeaf35924a10f713b364d32b2dd34f") }.not_to raise_error
last_pipeline = Ci::Pipeline.last
@@ -115,9 +117,9 @@ describe Ci::CreatePipelineService do
end
end
- context 'when there is no pipeline for source branch' do
+ context "when there is no pipeline for source branch" do
it "does not update merge request head pipeline" do
- merge_request = create(:merge_request, source_branch: 'feature',
+ merge_request = create(:merge_request, source_branch: "feature",
target_branch: "branch_1",
source_project: project)
@@ -127,25 +129,25 @@ describe Ci::CreatePipelineService do
end
end
- context 'when merge request target project is different from source project' do
+ context "when merge request target project is different from source project" do
let!(:project) { fork_project(target_project, nil, repository: true) }
let!(:target_project) { create(:project, :repository) }
- it 'updates head pipeline for merge request' do
- merge_request = create(:merge_request, source_branch: 'feature',
+ it "updates head pipeline for merge request" do
+ merge_request = create(:merge_request, source_branch: "feature",
target_branch: "master",
source_project: project,
target_project: target_project)
- head_pipeline = execute_service(ref: 'feature', after: nil)
+ head_pipeline = execute_service(ref: "feature", after: nil)
expect(merge_request.reload.head_pipeline).to eq(head_pipeline)
end
end
- context 'when the pipeline is not the latest for the branch' do
- it 'does not update merge request head pipeline' do
- merge_request = create(:merge_request, source_branch: 'master',
+ context "when the pipeline is not the latest for the branch" do
+ it "does not update merge request head pipeline" do
+ merge_request = create(:merge_request, source_branch: "master",
target_branch: "branch_1",
source_project: project)
@@ -158,14 +160,14 @@ describe Ci::CreatePipelineService do
end
end
- context 'when pipeline has errors' do
+ context "when pipeline has errors" do
before do
- stub_ci_pipeline_yaml_file('some invalid syntax')
+ stub_ci_pipeline_yaml_file("some invalid syntax")
end
- it 'updates merge request head pipeline reference' do
- merge_request = create(:merge_request, source_branch: 'master',
- target_branch: 'feature',
+ it "updates merge request head pipeline reference" do
+ merge_request = create(:merge_request, source_branch: "master",
+ target_branch: "feature",
source_project: project)
head_pipeline = execute_service
@@ -176,16 +178,16 @@ describe Ci::CreatePipelineService do
end
end
- context 'when pipeline has been skipped' do
+ context "when pipeline has been skipped" do
before do
allow_any_instance_of(Ci::Pipeline)
.to receive(:git_commit_message)
- .and_return('some commit [ci skip]')
+ .and_return("some commit [ci skip]")
end
- it 'updates merge request head pipeline' do
- merge_request = create(:merge_request, source_branch: 'master',
- target_branch: 'feature',
+ it "updates merge request head pipeline" do
+ merge_request = create(:merge_request, source_branch: "master",
+ target_branch: "feature",
source_project: project)
head_pipeline = execute_service
@@ -197,61 +199,61 @@ describe Ci::CreatePipelineService do
end
end
- context 'auto-cancel enabled' do
+ context "auto-cancel enabled" do
before do
- project.update(auto_cancel_pending_pipelines: 'enabled')
+ project.update(auto_cancel_pending_pipelines: "enabled")
end
- it 'does not cancel HEAD pipeline' do
+ it "does not cancel HEAD pipeline" do
pipeline
pipeline_on_previous_commit
- expect(pipeline.reload).to have_attributes(status: 'pending', auto_canceled_by_id: nil)
+ expect(pipeline.reload).to have_attributes(status: "pending", auto_canceled_by_id: nil)
end
- it 'auto cancel pending non-HEAD pipelines' do
+ it "auto cancel pending non-HEAD pipelines" do
pipeline_on_previous_commit
pipeline
- expect(pipeline_on_previous_commit.reload).to have_attributes(status: 'canceled', auto_canceled_by_id: pipeline.id)
+ expect(pipeline_on_previous_commit.reload).to have_attributes(status: "canceled", auto_canceled_by_id: pipeline.id)
end
- it 'does not cancel running outdated pipelines' do
+ it "does not cancel running outdated pipelines" do
pipeline_on_previous_commit.run
execute_service
- expect(pipeline_on_previous_commit.reload).to have_attributes(status: 'running', auto_canceled_by_id: nil)
+ expect(pipeline_on_previous_commit.reload).to have_attributes(status: "running", auto_canceled_by_id: nil)
end
- it 'cancel created outdated pipelines' do
- pipeline_on_previous_commit.update(status: 'created')
+ it "cancel created outdated pipelines" do
+ pipeline_on_previous_commit.update(status: "created")
pipeline
- expect(pipeline_on_previous_commit.reload).to have_attributes(status: 'canceled', auto_canceled_by_id: pipeline.id)
+ expect(pipeline_on_previous_commit.reload).to have_attributes(status: "canceled", auto_canceled_by_id: pipeline.id)
end
- it 'does not cancel pipelines from the other branches' do
+ it "does not cancel pipelines from the other branches" do
pending_pipeline = execute_service(
- ref: 'refs/heads/feature',
- after: previous_commit_sha_from_ref('feature')
+ ref: "refs/heads/feature",
+ after: previous_commit_sha_from_ref("feature")
)
pipeline
- expect(pending_pipeline.reload).to have_attributes(status: 'pending', auto_canceled_by_id: nil)
+ expect(pending_pipeline.reload).to have_attributes(status: "pending", auto_canceled_by_id: nil)
end
end
- context 'auto-cancel disabled' do
+ context "auto-cancel disabled" do
before do
- project.update(auto_cancel_pending_pipelines: 'disabled')
+ project.update(auto_cancel_pending_pipelines: "disabled")
end
- it 'does not auto cancel pending non-HEAD pipelines' do
+ it "does not auto cancel pending non-HEAD pipelines" do
pipeline_on_previous_commit
pipeline
expect(pipeline_on_previous_commit.reload)
- .to have_attributes(status: 'pending', auto_canceled_by_id: nil)
+ .to have_attributes(status: "pending", auto_canceled_by_id: nil)
end
end
@@ -266,49 +268,49 @@ describe Ci::CreatePipelineService do
end
it "creates commit if there is no appropriate job but deploy job has right ref setting" do
- config = YAML.dump({ deploy: { script: "ls", only: ["master"] } })
+ config = YAML.dump({deploy: {script: "ls", only: ["master"]}})
stub_ci_pipeline_yaml_file(config)
expect(execute_service).to be_persisted
end
end
- it 'skips creating pipeline for refs without .gitlab-ci.yml' do
+ it "skips creating pipeline for refs without .gitlab-ci.yml" do
stub_ci_pipeline_yaml_file(nil)
expect(execute_service).not_to be_persisted
expect(Ci::Pipeline.count).to eq(0)
end
- shared_examples 'a failed pipeline' do
- it 'creates failed pipeline' do
+ shared_examples "a failed pipeline" do
+ it "creates failed pipeline" do
stub_ci_pipeline_yaml_file(ci_yaml)
pipeline = execute_service(message: message)
expect(pipeline).to be_persisted
expect(pipeline.builds.any?).to be false
- expect(pipeline.status).to eq('failed')
+ expect(pipeline.status).to eq("failed")
expect(pipeline.yaml_errors).not_to be_nil
end
end
- context 'when yaml is invalid' do
- let(:ci_yaml) { 'invalid: file: fiile' }
- let(:message) { 'Message' }
+ context "when yaml is invalid" do
+ let(:ci_yaml) { "invalid: file: fiile" }
+ let(:message) { "Message" }
- it_behaves_like 'a failed pipeline'
+ it_behaves_like "a failed pipeline"
- context 'when receive git commit' do
+ context "when receive git commit" do
before do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { message }
end
- it_behaves_like 'a failed pipeline'
+ it_behaves_like "a failed pipeline"
end
end
- context 'when commit contains a [ci skip] directive' do
+ context "when commit contains a [ci skip] directive" do
let(:message) { "some message[ci skip]" }
ci_messages = [
@@ -319,7 +321,7 @@ describe Ci::CreatePipelineService do
"some message[ci_skip]",
"some message[skip_ci]",
"some message[ci-skip]",
- "some message[skip-ci]"
+ "some message[skip-ci]",
]
before do
@@ -336,8 +338,8 @@ describe Ci::CreatePipelineService do
end
end
- shared_examples 'creating a pipeline' do
- it 'does not skip pipeline creation' do
+ shared_examples "creating a pipeline" do
+ it "does not skip pipeline creation" do
allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { commit_message }
pipeline = execute_service(message: commit_message)
@@ -347,32 +349,32 @@ describe Ci::CreatePipelineService do
end
end
- context 'when commit message does not contain [ci skip] nor [skip ci]' do
- let(:commit_message) { 'some message' }
+ context "when commit message does not contain [ci skip] nor [skip ci]" do
+ let(:commit_message) { "some message" }
- it_behaves_like 'creating a pipeline'
+ it_behaves_like "creating a pipeline"
end
- context 'when commit message is nil' do
+ context "when commit message is nil" do
let(:commit_message) { nil }
- it_behaves_like 'creating a pipeline'
+ it_behaves_like "creating a pipeline"
end
- context 'when there is [ci skip] tag in commit message and yaml is invalid' do
- let(:ci_yaml) { 'invalid: file: fiile' }
+ context "when there is [ci skip] tag in commit message and yaml is invalid" do
+ let(:ci_yaml) { "invalid: file: fiile" }
- it_behaves_like 'a failed pipeline'
+ it_behaves_like "a failed pipeline"
end
end
- context 'when push options contain ci.skip' do
+ context "when push options contain ci.skip" do
let(:push_options) do
- ['ci.skip',
- 'another push option']
+ ["ci.skip",
+ "another push option",]
end
- it 'creates a pipline in the skipped state' do
+ it "creates a pipline in the skipped state" do
pipeline = execute_service(push_options: push_options)
# TODO: DRY these up with "skips builds creation if the commit message"
@@ -382,13 +384,13 @@ describe Ci::CreatePipelineService do
end
end
- context 'when there are no jobs for this pipeline' do
+ context "when there are no jobs for this pipeline" do
before do
- config = YAML.dump({ test: { script: 'ls', only: ['feature'] } })
+ config = YAML.dump({test: {script: "ls", only: ["feature"]}})
stub_ci_pipeline_yaml_file(config)
end
- it 'does not create a new pipeline' do
+ it "does not create a new pipeline" do
result = execute_service
expect(result).not_to be_persisted
@@ -397,13 +399,13 @@ describe Ci::CreatePipelineService do
end
end
- context 'with manual actions' do
+ context "with manual actions" do
before do
- config = YAML.dump({ deploy: { script: 'ls', when: 'manual' } })
+ config = YAML.dump({deploy: {script: "ls", when: "manual"}})
stub_ci_pipeline_yaml_file(config)
end
- it 'does not create a new pipeline' do
+ it "does not create a new pipeline" do
result = execute_service
expect(result).to be_persisted
@@ -411,42 +413,43 @@ describe Ci::CreatePipelineService do
end
end
- context 'with environment' do
+ context "with environment" do
before do
config = YAML.dump(
deploy: {
- environment: { name: "review/$CI_COMMIT_REF_NAME" },
- script: 'ls',
- tags: ['hello']
- })
+ environment: {name: "review/$CI_COMMIT_REF_NAME"},
+ script: "ls",
+ tags: ["hello"],
+ }
+ )
stub_ci_pipeline_yaml_file(config)
end
- it 'creates the environment with tags' do
+ it "creates the environment with tags" do
result = execute_service
expect(result).to be_persisted
expect(Environment.find_by(name: "review/master")).to be_present
- expect(result.builds.first.tag_list).to contain_exactly('hello')
+ expect(result.builds.first.tag_list).to contain_exactly("hello")
expect(result.builds.first.deployment).to be_persisted
expect(result.builds.first.deployment.deployable).to be_a(Ci::Build)
end
end
- context 'with environment name including persisted variables' do
+ context "with environment name including persisted variables" do
before do
config = YAML.dump(
deploy: {
- environment: { name: "review/id1$CI_PIPELINE_ID/id2$CI_BUILD_ID" },
- script: 'ls'
+ environment: {name: "review/id1$CI_PIPELINE_ID/id2$CI_BUILD_ID"},
+ script: "ls",
}
)
stub_ci_pipeline_yaml_file(config)
end
- it 'skipps persisted variables in environment name' do
+ it "skipps persisted variables in environment name" do
result = execute_service
expect(result).to be_persisted
@@ -454,93 +457,93 @@ describe Ci::CreatePipelineService do
end
end
- context 'when environment with invalid name' do
+ context "when environment with invalid name" do
before do
- config = YAML.dump(deploy: { environment: { name: 'name,with,commas' }, script: 'ls' })
+ config = YAML.dump(deploy: {environment: {name: "name,with,commas"}, script: "ls"})
stub_ci_pipeline_yaml_file(config)
end
- it 'does not create an environment' do
- expect do
+ it "does not create an environment" do
+ expect {
result = execute_service
expect(result).to be_persisted
- end.not_to change { Environment.count }
+ }.not_to change { Environment.count }
end
end
- context 'when builds with auto-retries are configured' do
- context 'as an integer' do
+ context "when builds with auto-retries are configured" do
+ context "as an integer" do
before do
- config = YAML.dump(rspec: { script: 'rspec', retry: 2 })
+ config = YAML.dump(rspec: {script: "rspec", retry: 2})
stub_ci_pipeline_yaml_file(config)
end
- it 'correctly creates builds with auto-retry value configured' do
+ it "correctly creates builds with auto-retry value configured" do
pipeline = execute_service
expect(pipeline).to be_persisted
- expect(pipeline.builds.find_by(name: 'rspec').retries_max).to eq 2
- expect(pipeline.builds.find_by(name: 'rspec').retry_when).to eq ['always']
+ expect(pipeline.builds.find_by(name: "rspec").retries_max).to eq 2
+ expect(pipeline.builds.find_by(name: "rspec").retry_when).to eq ["always"]
end
end
- context 'as hash' do
+ context "as hash" do
before do
- config = YAML.dump(rspec: { script: 'rspec', retry: { max: 2, when: 'runner_system_failure' } })
+ config = YAML.dump(rspec: {script: "rspec", retry: {max: 2, when: "runner_system_failure"}})
stub_ci_pipeline_yaml_file(config)
end
- it 'correctly creates builds with auto-retry value configured' do
+ it "correctly creates builds with auto-retry value configured" do
pipeline = execute_service
expect(pipeline).to be_persisted
- expect(pipeline.builds.find_by(name: 'rspec').retries_max).to eq 2
- expect(pipeline.builds.find_by(name: 'rspec').retry_when).to eq ['runner_system_failure']
+ expect(pipeline.builds.find_by(name: "rspec").retries_max).to eq 2
+ expect(pipeline.builds.find_by(name: "rspec").retry_when).to eq ["runner_system_failure"]
end
end
end
- shared_examples 'when ref is protected' do
+ shared_examples "when ref is protected" do
let(:user) { create(:user) }
- context 'when user is developer' do
+ context "when user is developer" do
before do
project.add_developer(user)
end
- it 'does not create a pipeline' do
+ it "does not create a pipeline" do
expect(execute_service).not_to be_persisted
expect(Ci::Pipeline.count).to eq(0)
end
end
- context 'when user is maintainer' do
+ context "when user is maintainer" do
let(:pipeline) { execute_service }
before do
project.add_maintainer(user)
end
- it 'creates a protected pipeline' do
+ it "creates a protected pipeline" do
expect(pipeline).to be_persisted
expect(pipeline).to be_protected
expect(Ci::Pipeline.count).to eq(1)
end
end
- context 'when trigger belongs to no one' do
+ context "when trigger belongs to no one" do
let(:user) {}
let(:trigger_request) { create(:ci_trigger_request) }
- it 'does not create a pipeline' do
+ it "does not create a pipeline" do
expect(execute_service(trigger_request: trigger_request))
.not_to be_persisted
expect(Ci::Pipeline.count).to eq(0)
end
end
- context 'when trigger belongs to a developer' do
+ context "when trigger belongs to a developer" do
let(:user) { create(:user) }
let(:trigger) { create(:ci_trigger, owner: user) }
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
@@ -549,14 +552,14 @@ describe Ci::CreatePipelineService do
project.add_developer(user)
end
- it 'does not create a pipeline' do
+ it "does not create a pipeline" do
expect(execute_service(trigger_request: trigger_request))
.not_to be_persisted
expect(Ci::Pipeline.count).to eq(0)
end
end
- context 'when trigger belongs to a maintainer' do
+ context "when trigger belongs to a maintainer" do
let(:user) { create(:user) }
let(:trigger) { create(:ci_trigger, owner: user) }
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
@@ -565,7 +568,7 @@ describe Ci::CreatePipelineService do
project.add_maintainer(user)
end
- it 'creates a pipeline' do
+ it "creates a pipeline" do
expect(execute_service(trigger_request: trigger_request))
.to be_persisted
expect(Ci::Pipeline.count).to eq(1)
@@ -573,32 +576,32 @@ describe Ci::CreatePipelineService do
end
end
- context 'when ref is a protected branch' do
+ context "when ref is a protected branch" do
before do
- create(:protected_branch, project: project, name: 'master')
+ create(:protected_branch, project: project, name: "master")
end
- it_behaves_like 'when ref is protected'
+ it_behaves_like "when ref is protected"
end
- context 'when ref is a protected tag' do
- let(:ref_name) { 'refs/tags/v1.0.0' }
+ context "when ref is a protected tag" do
+ let(:ref_name) { "refs/tags/v1.0.0" }
before do
- create(:protected_tag, project: project, name: '*')
+ create(:protected_tag, project: project, name: "*")
end
- it_behaves_like 'when ref is protected'
+ it_behaves_like "when ref is protected"
end
- context 'when ref is not protected' do
- context 'when trigger belongs to no one' do
+ context "when ref is not protected" do
+ context "when trigger belongs to no one" do
let(:user) {}
let(:trigger) { create(:ci_trigger, owner: nil) }
let(:trigger_request) { create(:ci_trigger_request, trigger: trigger) }
let(:pipeline) { execute_service(trigger_request: trigger_request) }
- it 'creates an unprotected pipeline' do
+ it "creates an unprotected pipeline" do
expect(pipeline).to be_persisted
expect(pipeline).not_to be_protected
expect(Ci::Pipeline.count).to eq(1)
@@ -606,76 +609,76 @@ describe Ci::CreatePipelineService do
end
end
- context 'when pipeline is running for a tag' do
+ context "when pipeline is running for a tag" do
before do
- config = YAML.dump(test: { script: 'test', only: ['branches'] },
- deploy: { script: 'deploy', only: ['tags'] })
+ config = YAML.dump(test: {script: "test", only: ["branches"]},
+ deploy: {script: "deploy", only: ["tags"]})
stub_ci_pipeline_yaml_file(config)
end
- it 'creates a tagged pipeline' do
- pipeline = execute_service(ref: 'v1.0.0')
+ it "creates a tagged pipeline" do
+ pipeline = execute_service(ref: "v1.0.0")
expect(pipeline.tag?).to be true
end
end
- context 'when pipeline variables are specified' do
+ context "when pipeline variables are specified" do
let(:variables_attributes) do
- [{ key: 'first', secret_value: 'world' },
- { key: 'second', secret_value: 'second_world' }]
+ [{key: "first", secret_value: "world"},
+ {key: "second", secret_value: "second_world"},]
end
subject { execute_service(variables_attributes: variables_attributes) }
- it 'creates a pipeline with specified variables' do
+ it "creates a pipeline with specified variables" do
expect(subject.variables.map { |var| var.slice(:key, :secret_value) })
.to eq variables_attributes.map(&:with_indifferent_access)
end
end
- context 'when pipeline has a job with environment' do
+ context "when pipeline has a job with environment" do
let(:pipeline) { execute_service }
before do
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
- context 'when environment name is valid' do
+ context "when environment name is valid" do
let(:config) do
{
review_app: {
- script: 'deploy',
+ script: "deploy",
environment: {
- name: 'review/${CI_COMMIT_REF_NAME}',
- url: 'http://${CI_COMMIT_REF_SLUG}-staging.example.com'
- }
- }
+ name: "review/${CI_COMMIT_REF_NAME}",
+ url: "http://${CI_COMMIT_REF_SLUG}-staging.example.com",
+ },
+ },
}
end
- it 'has a job with environment' do
+ it "has a job with environment" do
expect(pipeline.builds.count).to eq(1)
- expect(pipeline.builds.first.persisted_environment.name).to eq('review/master')
+ expect(pipeline.builds.first.persisted_environment.name).to eq("review/master")
expect(pipeline.builds.first.deployment).to be_created
end
end
- context 'when environment name is invalid' do
+ context "when environment name is invalid" do
let(:config) do
{
'job:deploy-to-test-site': {
- script: 'deploy',
+ script: "deploy",
environment: {
- name: '${CI_JOB_NAME}',
- url: 'https://$APP_URL'
- }
- }
+ name: "${CI_JOB_NAME}",
+ url: "https://$APP_URL",
+ },
+ },
}
end
- it 'has a job without environment' do
+ it "has a job without environment" do
expect(pipeline.builds.count).to eq(1)
expect(pipeline.builds.first.persisted_environment).to be_nil
expect(pipeline.builds.first.deployment).to be_nil
@@ -683,7 +686,7 @@ describe Ci::CreatePipelineService do
end
end
- describe 'Merge request pipelines' do
+ describe "Merge request pipelines" do
let(:pipeline) do
execute_service(source: source,
merge_request: merge_request,
@@ -696,87 +699,87 @@ describe Ci::CreatePipelineService do
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
- let(:ref_name) { 'refs/heads/feature' }
+ let(:ref_name) { "refs/heads/feature" }
let(:source_sha) { project.commit(ref_name).id }
let(:target_sha) { nil }
- context 'when source is merge request' do
+ context "when source is merge request" do
let(:source) { :merge_request }
context "when config has merge_requests keywords" do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo'
+ stage: "build",
+ script: "echo",
},
test: {
- stage: 'test',
- script: 'echo',
- only: ['merge_requests']
+ stage: "test",
+ script: "echo",
+ only: ["merge_requests"],
},
pages: {
- stage: 'deploy',
- script: 'echo',
- except: ['merge_requests']
- }
+ stage: "deploy",
+ script: "echo",
+ except: ["merge_requests"],
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: Gitlab::Git.ref_name(ref_name),
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'creates a merge request pipeline' do
+ it "creates a merge request pipeline" do
expect(pipeline).to be_persisted
expect(pipeline).to be_merge_request
expect(pipeline.merge_request).to eq(merge_request)
expect(pipeline.builds.order(:stage_id).map(&:name)).to eq(%w[test])
end
- it 'persists the specified source sha' do
+ it "persists the specified source sha" do
expect(pipeline.source_sha).to eq(source_sha)
end
- it 'does not persist target sha for detached merge request pipeline' do
+ it "does not persist target sha for detached merge request pipeline" do
expect(pipeline.target_sha).to be_nil
end
- context 'when target sha is specified' do
+ context "when target sha is specified" do
let(:target_sha) { merge_request.target_branch_sha }
- it 'persists the target sha' do
+ it "persists the target sha" do
expect(pipeline.target_sha).to eq(target_sha)
end
end
- context 'when ref is tag' do
- let(:ref_name) { 'refs/tags/v1.1.0' }
+ context "when ref is tag" do
+ let(:ref_name) { "refs/tags/v1.1.0" }
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:tag]).to eq(["is not included in the list"])
end
end
- context 'when merge request is created from a forked project' do
+ context "when merge request is created from a forked project" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: Gitlab::Git.ref_name(ref_name),
target_project: target_project,
- target_branch: 'master')
+ target_branch: "master")
end
let!(:project) { fork_project(target_project, nil, repository: true) }
let!(:target_project) { create(:project, :repository) }
- it 'creates a merge request pipeline in the forked project' do
+ it "creates a merge request pipeline in the forked project" do
expect(pipeline).to be_persisted
expect(project.ci_pipelines).to eq([pipeline])
expect(target_project.ci_pipelines).to be_empty
@@ -787,24 +790,24 @@ describe Ci::CreatePipelineService do
let(:config) do
{
test: {
- stage: 'test',
- script: 'echo',
- except: ['merge_requests']
- }
+ stage: "test",
+ script: "echo",
+ except: ["merge_requests"],
+ },
}
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base]).to eq(["No stages / jobs for this pipeline."])
end
end
end
- context 'when merge request is not specified' do
+ context "when merge request is not specified" do
let(:merge_request) { nil }
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:merge_request]).to eq(["can't be blank"])
end
@@ -815,45 +818,45 @@ describe Ci::CreatePipelineService do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo'
+ stage: "build",
+ script: "echo",
},
test: {
- stage: 'test',
- script: 'echo'
+ stage: "test",
+ script: "echo",
},
pages: {
- stage: 'deploy',
- script: 'echo'
- }
+ stage: "deploy",
+ script: "echo",
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: Gitlab::Git.ref_name(ref_name),
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base])
- .to eq(['No stages / jobs for this pipeline.'])
+ .to eq(["No stages / jobs for this pipeline."])
end
end
- context 'when merge request is not specified' do
+ context "when merge request is not specified" do
let(:merge_request) { nil }
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base])
- .to eq(['No stages / jobs for this pipeline.'])
+ .to eq(["No stages / jobs for this pipeline."])
end
end
end
@@ -862,27 +865,27 @@ describe Ci::CreatePipelineService do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo',
- only: ["/^#{ref_name}$/"]
- }
+ stage: "build",
+ script: "echo",
+ only: ["/^#{ref_name}$/"],
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: ref_name,
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base])
- .to eq(['No stages / jobs for this pipeline.'])
+ .to eq(["No stages / jobs for this pipeline."])
end
end
end
@@ -891,29 +894,29 @@ describe Ci::CreatePipelineService do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo',
+ stage: "build",
+ script: "echo",
only: {
- variables: %w($CI)
- }
- }
+ variables: %w[$CI],
+ },
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: ref_name,
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base])
- .to eq(['No stages / jobs for this pipeline.'])
+ .to eq(["No stages / jobs for this pipeline."])
end
end
end
@@ -922,74 +925,74 @@ describe Ci::CreatePipelineService do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo',
- except: ['tags']
- }
+ stage: "build",
+ script: "echo",
+ except: ["tags"],
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: ref_name,
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:base])
- .to eq(['No stages / jobs for this pipeline.'])
+ .to eq(["No stages / jobs for this pipeline."])
end
end
end
end
- context 'when source is web' do
+ context "when source is web" do
let(:source) { :web }
context "when config has merge_requests keywords" do
let(:config) do
{
build: {
- stage: 'build',
- script: 'echo'
+ stage: "build",
+ script: "echo",
},
test: {
- stage: 'test',
- script: 'echo',
- only: ['merge_requests']
+ stage: "test",
+ script: "echo",
+ only: ["merge_requests"],
},
pages: {
- stage: 'deploy',
- script: 'echo',
- except: ['merge_requests']
- }
+ stage: "deploy",
+ script: "echo",
+ except: ["merge_requests"],
+ },
}
end
- context 'when merge request is specified' do
+ context "when merge request is specified" do
let(:merge_request) do
create(:merge_request,
source_project: project,
source_branch: Gitlab::Git.ref_name(ref_name),
target_project: project,
- target_branch: 'master')
+ target_branch: "master")
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(pipeline).not_to be_persisted
expect(pipeline.errors[:merge_request]).to eq(["must be blank"])
end
end
- context 'when merge request is not specified' do
+ context "when merge request is not specified" do
let(:merge_request) { nil }
- it 'creates a branch pipeline' do
+ it "creates a branch pipeline" do
expect(pipeline).to be_persisted
expect(pipeline).to be_web
expect(pipeline.merge_request).to be_nil
@@ -1001,35 +1004,35 @@ describe Ci::CreatePipelineService do
end
end
- describe '#execute!' do
+ describe "#execute!" do
subject { service.execute!(*args) }
let(:service) { described_class.new(project, user, ref: ref_name) }
let(:args) { [:push] }
- context 'when user has a permission to create a pipeline' do
+ context "when user has a permission to create a pipeline" do
let(:user) { create(:user) }
before do
project.add_developer(user)
end
- it 'does not raise an error' do
+ it "does not raise an error" do
expect { subject }.not_to raise_error
end
- it 'creates a pipeline' do
+ it "creates a pipeline" do
expect { subject }.to change { Ci::Pipeline.count }.by(1)
end
end
- context 'when user does not have a permission to create a pipeline' do
+ context "when user does not have a permission to create a pipeline" do
let(:user) { create(:user) }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }
.to raise_error(described_class::CreateError)
- .with_message('Insufficient permissions to create a new pipeline')
+ .with_message("Insufficient permissions to create a new pipeline")
end
end
end
diff --git a/spec/services/ci/destroy_expired_job_artifacts_service_spec.rb b/spec/services/ci/destroy_expired_job_artifacts_service_spec.rb
index 80d82ba3ac9..cfe06f86175 100644
--- a/spec/services/ci/destroy_expired_job_artifacts_service_spec.rb
+++ b/spec/services/ci/destroy_expired_job_artifacts_service_spec.rb
@@ -1,102 +1,102 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::DestroyExpiredJobArtifactsService, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
- describe '.execute' do
+ describe ".execute" do
subject { service.execute }
let(:service) { described_class.new }
let!(:artifact) { create(:ci_job_artifact, expire_at: 1.day.ago) }
- it 'destroys expired job artifacts' do
+ it "destroys expired job artifacts" do
expect { subject }.to change { Ci::JobArtifact.count }.by(-1)
end
- context 'when artifact is not expired' do
+ context "when artifact is not expired" do
let!(:artifact) { create(:ci_job_artifact, expire_at: 1.day.since) }
- it 'does not destroy expired job artifacts' do
+ it "does not destroy expired job artifacts" do
expect { subject }.not_to change { Ci::JobArtifact.count }
end
end
- context 'when artifact is permanent' do
+ context "when artifact is permanent" do
let!(:artifact) { create(:ci_job_artifact, expire_at: nil) }
- it 'does not destroy expired job artifacts' do
+ it "does not destroy expired job artifacts" do
expect { subject }.not_to change { Ci::JobArtifact.count }
end
end
- context 'when failed to destroy artifact' do
+ context "when failed to destroy artifact" do
before do
- stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 10)
+ stub_const("Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT", 10)
allow_any_instance_of(Ci::JobArtifact)
.to receive(:destroy!)
.and_raise(ActiveRecord::RecordNotDestroyed)
end
- it 'raises an exception and stop destroying' do
+ it "raises an exception and stop destroying" do
expect { subject }.to raise_error(ActiveRecord::RecordNotDestroyed)
end
end
- context 'when exclusive lease has already been taken by the other instance' do
+ context "when exclusive lease has already been taken by the other instance" do
before do
stub_exclusive_lease_taken(described_class::EXCLUSIVE_LOCK_KEY, timeout: described_class::LOCK_TIMEOUT)
end
- it 'raises an error and does not start destroying' do
+ it "raises an error and does not start destroying" do
expect { subject }.to raise_error(Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError)
end
end
- context 'when timeout happens' do
+ context "when timeout happens" do
before do
- stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_TIMEOUT', 1.second)
+ stub_const("Ci::DestroyExpiredJobArtifactsService::LOOP_TIMEOUT", 1.second)
allow_any_instance_of(described_class).to receive(:destroy_batch) { true }
end
- it 'returns false and does not continue destroying' do
+ it "returns false and does not continue destroying" do
is_expected.to be_falsy
end
end
- context 'when loop reached loop limit' do
+ context "when loop reached loop limit" do
before do
- stub_const('Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT', 1)
- stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
+ stub_const("Ci::DestroyExpiredJobArtifactsService::LOOP_LIMIT", 1)
+ stub_const("Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE", 1)
end
let!(:artifact) { create_list(:ci_job_artifact, 2, expire_at: 1.day.ago) }
- it 'raises an error and does not continue destroying' do
+ it "raises an error and does not continue destroying" do
is_expected.to be_falsy
end
- it 'destroys one artifact' do
+ it "destroys one artifact" do
expect { subject }.to change { Ci::JobArtifact.count }.by(-1)
end
end
- context 'when there are no artifacts' do
+ context "when there are no artifacts" do
let!(:artifact) { }
- it 'does not raise error' do
+ it "does not raise error" do
expect { subject }.not_to raise_error
end
end
- context 'when there are artifacts more than batch sizes' do
+ context "when there are artifacts more than batch sizes" do
before do
- stub_const('Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE', 1)
+ stub_const("Ci::DestroyExpiredJobArtifactsService::BATCH_SIZE", 1)
end
let!(:artifact) { create_list(:ci_job_artifact, 2, expire_at: 1.day.ago) }
- it 'destroys all expired artifacts' do
+ it "destroys all expired artifacts" do
expect { subject }.to change { Ci::JobArtifact.count }.by(-2)
end
end
diff --git a/spec/services/ci/destroy_pipeline_service_spec.rb b/spec/services/ci/destroy_pipeline_service_spec.rb
index d896f990470..f4f215b8b15 100644
--- a/spec/services/ci/destroy_pipeline_service_spec.rb
+++ b/spec/services/ci/destroy_pipeline_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ::Ci::DestroyPipelineService do
let(:project) { create(:project) }
@@ -8,29 +8,29 @@ describe ::Ci::DestroyPipelineService do
subject { described_class.new(project, user).execute(pipeline) }
- context 'user is owner' do
+ context "user is owner" do
let(:user) { project.owner }
- it 'destroys the pipeline' do
+ it "destroys the pipeline" do
subject
expect { pipeline.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'does not log an audit event' do
+ it "does not log an audit event" do
expect { subject }.not_to change { SecurityEvent.count }
end
- context 'when the pipeline has jobs' do
+ context "when the pipeline has jobs" do
let!(:build) { create(:ci_build, project: project, pipeline: pipeline) }
- it 'destroys associated jobs' do
+ it "destroys associated jobs" do
subject
expect { build.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'destroys associated stages' do
+ it "destroys associated stages" do
stages = pipeline.stages
subject
@@ -38,10 +38,10 @@ describe ::Ci::DestroyPipelineService do
expect(stages).to all(raise_error(ActiveRecord::RecordNotFound))
end
- context 'when job has artifacts' do
+ context "when job has artifacts" do
let!(:artifact) { create(:ci_job_artifact, :archive, job: build) }
- it 'destroys associated artifacts' do
+ it "destroys associated artifacts" do
subject
expect { artifact.reload }.to raise_error(ActiveRecord::RecordNotFound)
@@ -50,10 +50,10 @@ describe ::Ci::DestroyPipelineService do
end
end
- context 'user is not owner' do
+ context "user is not owner" do
let(:user) { create(:user) }
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
diff --git a/spec/services/ci/ensure_stage_service_spec.rb b/spec/services/ci/ensure_stage_service_spec.rb
index d17e30763d7..a535228cefb 100644
--- a/spec/services/ci/ensure_stage_service_spec.rb
+++ b/spec/services/ci/ensure_stage_service_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::EnsureStageService, '#execute' do
+describe Ci::EnsureStageService, "#execute" do
set(:project) { create(:project) }
set(:user) { create(:user) }
@@ -9,37 +9,37 @@ describe Ci::EnsureStageService, '#execute' do
let(:service) { described_class.new(project, user) }
- context 'when build has a stage assigned' do
- it 'does not create a new stage' do
+ context "when build has a stage assigned" do
+ it "does not create a new stage" do
job.assign_attributes(stage_id: stage.id)
expect { service.execute(job) }.not_to change { Ci::Stage.count }
end
end
- context 'when build does not have a stage assigned' do
- it 'creates a new stage' do
- job.assign_attributes(stage_id: nil, stage: 'test')
+ context "when build does not have a stage assigned" do
+ it "creates a new stage" do
+ job.assign_attributes(stage_id: nil, stage: "test")
expect { service.execute(job) }.to change { Ci::Stage.count }.by(1)
end
end
- context 'when build is invalid' do
- it 'does not create a new stage' do
+ context "when build is invalid" do
+ it "does not create a new stage" do
job.assign_attributes(stage_id: nil, ref: nil)
expect { service.execute(job) }.not_to change { Ci::Stage.count }
end
end
- context 'when new stage can not be created because of an exception' do
+ context "when new stage can not be created because of an exception" do
before do
allow(Ci::Stage).to receive(:create!)
- .and_raise(ActiveRecord::RecordNotUnique.new('Duplicates!'))
+ .and_raise(ActiveRecord::RecordNotUnique.new("Duplicates!"))
end
- it 'retries up to two times' do
+ it "retries up to two times" do
job.assign_attributes(stage_id: nil)
expect(service).to receive(:find_stage).exactly(2).times
diff --git a/spec/services/ci/extract_sections_from_build_trace_service_spec.rb b/spec/services/ci/extract_sections_from_build_trace_service_spec.rb
index 28f2fa7903a..b5874d87807 100644
--- a/spec/services/ci/extract_sections_from_build_trace_service_spec.rb
+++ b/spec/services/ci/extract_sections_from_build_trace_service_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::ExtractSectionsFromBuildTraceService, '#execute' do
+describe Ci::ExtractSectionsFromBuildTraceService, "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:build) { create(:ci_build, project: project) }
subject { described_class.new(project, user) }
- shared_examples 'build trace has sections markers' do
+ shared_examples "build trace has sections markers" do
before do
- build.trace.set(File.read(expand_fixture_path('trace/trace_with_sections')))
+ build.trace.set(File.read(expand_fixture_path("trace/trace_with_sections")))
end
- it 'saves the correct extracted sections' do
+ it "saves the correct extracted sections" do
expect(build.trace_sections).to be_empty
expect(subject.execute(build)).to be(true)
expect(build.trace_sections).not_to be_empty
@@ -27,29 +27,29 @@ describe Ci::ExtractSectionsFromBuildTraceService, '#execute' do
end
end
- shared_examples 'build trace has no sections markers' do
+ shared_examples "build trace has no sections markers" do
before do
- build.trace.set('no markerts')
+ build.trace.set("no markerts")
end
- it 'extracts no sections' do
+ it "extracts no sections" do
expect(build.trace_sections).to be_empty
expect(subject.execute(build)).to be(true)
expect(build.trace_sections).to be_empty
end
end
- context 'when the build has no user' do
- it_behaves_like 'build trace has sections markers'
- it_behaves_like 'build trace has no sections markers'
+ context "when the build has no user" do
+ it_behaves_like "build trace has sections markers"
+ it_behaves_like "build trace has no sections markers"
end
- context 'when the build has a valid user' do
+ context "when the build has a valid user" do
before do
build.user = user
end
- it_behaves_like 'build trace has sections markers'
- it_behaves_like 'build trace has no sections markers'
+ it_behaves_like "build trace has sections markers"
+ it_behaves_like "build trace has no sections markers"
end
end
diff --git a/spec/services/ci/pipeline_trigger_service_spec.rb b/spec/services/ci/pipeline_trigger_service_spec.rb
index f4ff818c479..ce54885373d 100644
--- a/spec/services/ci/pipeline_trigger_service_spec.rb
+++ b/spec/services/ci/pipeline_trigger_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::PipelineTriggerService do
let(:project) { create(:project, :repository) }
@@ -7,7 +7,7 @@ describe Ci::PipelineTriggerService do
stub_ci_pipeline_to_return_yaml_file
end
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:user) }
let(:trigger) { create(:ci_trigger, project: project, owner: user) }
let(:result) { described_class.new(project, user, params).execute }
@@ -16,22 +16,22 @@ describe Ci::PipelineTriggerService do
project.add_developer(user)
end
- context 'when trigger belongs to a different project' do
- let(:params) { { token: trigger.token, ref: 'master', variables: nil } }
+ context "when trigger belongs to a different project" do
+ let(:params) { {token: trigger.token, ref: "master", variables: nil} }
let(:trigger) { create(:ci_trigger, project: create(:project), owner: user) }
- it 'does nothing' do
+ it "does nothing" do
expect { result }.not_to change { Ci::Pipeline.count }
end
end
- context 'when params have an existsed trigger token' do
- context 'when params have an existsed ref' do
- let(:params) { { token: trigger.token, ref: 'master', variables: nil } }
+ context "when params have an existsed trigger token" do
+ context "when params have an existsed ref" do
+ let(:params) { {token: trigger.token, ref: "master", variables: nil} }
- it 'triggers a pipeline' do
+ it "triggers a pipeline" do
expect { result }.to change { Ci::Pipeline.count }.by(1)
- expect(result[:pipeline].ref).to eq('master')
+ expect(result[:pipeline].ref).to eq("master")
expect(result[:pipeline].project).to eq(project)
expect(result[:pipeline].user).to eq(trigger.owner)
expect(result[:pipeline].trigger_requests.to_a)
@@ -39,44 +39,44 @@ describe Ci::PipelineTriggerService do
expect(result[:status]).to eq(:success)
end
- context 'when commit message has [ci skip]' do
+ context "when commit message has [ci skip]" do
before do
- allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { '[ci skip]' }
+ allow_any_instance_of(Ci::Pipeline).to receive(:git_commit_message) { "[ci skip]" }
end
- it 'ignores [ci skip] and create as general' do
+ it "ignores [ci skip] and create as general" do
expect { result }.to change { Ci::Pipeline.count }.by(1)
expect(result[:status]).to eq(:success)
end
end
- context 'when params have a variable' do
- let(:params) { { token: trigger.token, ref: 'master', variables: variables } }
- let(:variables) { { 'AAA' => 'AAA123' } }
+ context "when params have a variable" do
+ let(:params) { {token: trigger.token, ref: "master", variables: variables} }
+ let(:variables) { {"AAA" => "AAA123"} }
- it 'has a variable' do
+ it "has a variable" do
expect { result }.to change { Ci::PipelineVariable.count }.by(1)
- .and change { Ci::TriggerRequest.count }.by(1)
- expect(result[:pipeline].variables.map { |v| { v.key => v.value } }.first).to eq(variables)
+ .and change { Ci::TriggerRequest.count }.by(1)
+ expect(result[:pipeline].variables.map { |v| {v.key => v.value} }.first).to eq(variables)
expect(result[:pipeline].trigger_requests.last.variables).to be_nil
end
end
end
- context 'when params have a non-existsed ref' do
- let(:params) { { token: trigger.token, ref: 'invalid-ref', variables: nil } }
+ context "when params have a non-existsed ref" do
+ let(:params) { {token: trigger.token, ref: "invalid-ref", variables: nil} }
- it 'does not trigger a pipeline' do
+ it "does not trigger a pipeline" do
expect { result }.not_to change { Ci::Pipeline.count }
expect(result[:http_status]).to eq(400)
end
end
end
- context 'when params have a non-existsed trigger token' do
- let(:params) { { token: 'invalid-token', ref: nil, variables: nil } }
+ context "when params have a non-existsed trigger token" do
+ let(:params) { {token: "invalid-token", ref: nil, variables: nil} }
- it 'does not trigger a pipeline' do
+ it "does not trigger a pipeline" do
expect { result }.not_to change { Ci::Pipeline.count }
expect(result).to be_nil
end
diff --git a/spec/services/ci/play_build_service_spec.rb b/spec/services/ci/play_build_service_spec.rb
index 330ec81e87d..e002ea70316 100644
--- a/spec/services/ci/play_build_service_spec.rb
+++ b/spec/services/ci/play_build_service_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::PlayBuildService, '#execute' do
+describe Ci::PlayBuildService, "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:pipeline) { create(:ci_pipeline, project: project) }
@@ -10,21 +10,21 @@ describe Ci::PlayBuildService, '#execute' do
described_class.new(project, user)
end
- context 'when project does not have repository yet' do
+ context "when project does not have repository yet" do
let(:project) { create(:project) }
- it 'allows user to play build if protected branch rules are met' do
+ it "allows user to play build if protected branch rules are met" do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
service.execute(build)
expect(build.reload).to be_pending
end
- it 'does not allow user with developer role to play build' do
+ it "does not allow user with developer role to play build" do
project.add_developer(user)
expect { service.execute(build) }
@@ -32,10 +32,10 @@ describe Ci::PlayBuildService, '#execute' do
end
end
- context 'when project has repository' do
+ context "when project has repository" do
let(:project) { create(:project, :repository) }
- it 'allows user with developer role to play a build' do
+ it "allows user with developer role to play a build" do
project.add_developer(user)
service.execute(build)
@@ -44,46 +44,46 @@ describe Ci::PlayBuildService, '#execute' do
end
end
- context 'when build is a playable manual action' do
+ context "when build is a playable manual action" do
let(:build) { create(:ci_build, :manual, pipeline: pipeline) }
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'enqueues the build' do
+ it "enqueues the build" do
expect(service.execute(build)).to eq build
expect(build.reload).to be_pending
end
- it 'reassignes build user correctly' do
+ it "reassignes build user correctly" do
service.execute(build)
expect(build.reload.user).to eq user
end
end
- context 'when build is not a playable manual action' do
+ context "when build is not a playable manual action" do
let(:build) { create(:ci_build, when: :manual, pipeline: pipeline) }
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'duplicates the build' do
+ it "duplicates the build" do
duplicate = service.execute(build)
expect(duplicate).not_to eq build
expect(duplicate).to be_pending
end
- it 'assigns users correctly' do
+ it "assigns users correctly" do
duplicate = service.execute(build)
expect(build.user).not_to eq user
@@ -91,22 +91,22 @@ describe Ci::PlayBuildService, '#execute' do
end
end
- context 'when build is not action' do
+ context "when build is not action" do
let(:build) { create(:ci_build, :success, pipeline: pipeline) }
- it 'raises an error' do
+ it "raises an error" do
expect { service.execute(build) }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'when user does not have ability to trigger action' do
+ context "when user does not have ability to trigger action" do
before do
create(:protected_branch, :no_one_can_push,
- name: build.ref, project: project)
+ name: build.ref, project: project)
end
- it 'raises an error' do
+ it "raises an error" do
expect { service.execute(build) }
.to raise_error Gitlab::Access::AccessDeniedError
end
diff --git a/spec/services/ci/process_build_service_spec.rb b/spec/services/ci/process_build_service_spec.rb
index 704685417bb..8872dd162e7 100644
--- a/spec/services/ci/process_build_service_spec.rb
+++ b/spec/services/ci/process_build_service_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe Ci::ProcessBuildService, '#execute' do
+require "spec_helper"
+
+describe Ci::ProcessBuildService, "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project) }
@@ -11,106 +12,106 @@ describe Ci::ProcessBuildService, '#execute' do
project.add_maintainer(user)
end
- context 'when build has on_success option' do
+ context "when build has on_success option" do
let(:build) { create(:ci_build, :created, when: :on_success, user: user, project: project) }
- context 'when current status is success' do
- let(:current_status) { 'success' }
+ context "when current status is success" do
+ let(:current_status) { "success" }
- it 'changes the build status' do
- expect { subject }.to change { build.status }.to('pending')
+ it "changes the build status" do
+ expect { subject }.to change { build.status }.to("pending")
end
end
- context 'when current status is failed' do
- let(:current_status) { 'failed' }
+ context "when current status is failed" do
+ let(:current_status) { "failed" }
- it 'does not change the build status' do
- expect { subject }.to change { build.status }.to('skipped')
+ it "does not change the build status" do
+ expect { subject }.to change { build.status }.to("skipped")
end
end
end
- context 'when build has on_failure option' do
+ context "when build has on_failure option" do
let(:build) { create(:ci_build, :created, when: :on_failure, user: user, project: project) }
- context 'when current status is success' do
- let(:current_status) { 'success' }
+ context "when current status is success" do
+ let(:current_status) { "success" }
- it 'changes the build status' do
- expect { subject }.to change { build.status }.to('skipped')
+ it "changes the build status" do
+ expect { subject }.to change { build.status }.to("skipped")
end
end
- context 'when current status is failed' do
- let(:current_status) { 'failed' }
+ context "when current status is failed" do
+ let(:current_status) { "failed" }
- it 'does not change the build status' do
- expect { subject }.to change { build.status }.to('pending')
+ it "does not change the build status" do
+ expect { subject }.to change { build.status }.to("pending")
end
end
end
- context 'when build has always option' do
+ context "when build has always option" do
let(:build) { create(:ci_build, :created, when: :always, user: user, project: project) }
- context 'when current status is success' do
- let(:current_status) { 'success' }
+ context "when current status is success" do
+ let(:current_status) { "success" }
- it 'changes the build status' do
- expect { subject }.to change { build.status }.to('pending')
+ it "changes the build status" do
+ expect { subject }.to change { build.status }.to("pending")
end
end
- context 'when current status is failed' do
- let(:current_status) { 'failed' }
+ context "when current status is failed" do
+ let(:current_status) { "failed" }
- it 'does not change the build status' do
- expect { subject }.to change { build.status }.to('pending')
+ it "does not change the build status" do
+ expect { subject }.to change { build.status }.to("pending")
end
end
end
- context 'when build has manual option' do
+ context "when build has manual option" do
let(:build) { create(:ci_build, :created, :actionable, user: user, project: project) }
- context 'when current status is success' do
- let(:current_status) { 'success' }
+ context "when current status is success" do
+ let(:current_status) { "success" }
- it 'changes the build status' do
- expect { subject }.to change { build.status }.to('manual')
+ it "changes the build status" do
+ expect { subject }.to change { build.status }.to("manual")
end
end
- context 'when current status is failed' do
- let(:current_status) { 'failed' }
+ context "when current status is failed" do
+ let(:current_status) { "failed" }
- it 'does not change the build status' do
- expect { subject }.to change { build.status }.to('skipped')
+ it "does not change the build status" do
+ expect { subject }.to change { build.status }.to("skipped")
end
end
end
- context 'when build has delayed option' do
+ context "when build has delayed option" do
before do
allow(Ci::BuildScheduleWorker).to receive(:perform_at) { }
end
let(:build) { create(:ci_build, :created, :schedulable, user: user, project: project) }
- context 'when current status is success' do
- let(:current_status) { 'success' }
+ context "when current status is success" do
+ let(:current_status) { "success" }
- it 'changes the build status' do
- expect { subject }.to change { build.status }.to('scheduled')
+ it "changes the build status" do
+ expect { subject }.to change { build.status }.to("scheduled")
end
end
- context 'when current status is failed' do
- let(:current_status) { 'failed' }
+ context "when current status is failed" do
+ let(:current_status) { "failed" }
- it 'does not change the build status' do
- expect { subject }.to change { build.status }.to('skipped')
+ it "does not change the build status" do
+ expect { subject }.to change { build.status }.to("skipped")
end
end
end
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb
index 6674d89518e..7acfe1282d3 100644
--- a/spec/services/ci/process_pipeline_service_spec.rb
+++ b/spec/services/ci/process_pipeline_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::ProcessPipelineService, '#execute' do
+describe Ci::ProcessPipelineService, "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:pipeline) do
- create(:ci_empty_pipeline, ref: 'master', project: project)
+ create(:ci_empty_pipeline, ref: "master", project: project)
end
before do
@@ -16,16 +16,16 @@ describe Ci::ProcessPipelineService, '#execute' do
project.add_developer(user)
end
- context 'when simple pipeline is defined' do
+ context "when simple pipeline is defined" do
before do
- create_build('linux', stage_idx: 0)
- create_build('mac', stage_idx: 0)
- create_build('rspec', stage_idx: 1)
- create_build('rubocop', stage_idx: 1)
- create_build('deploy', stage_idx: 2)
+ create_build("linux", stage_idx: 0)
+ create_build("mac", stage_idx: 0)
+ create_build("rspec", stage_idx: 1)
+ create_build("rubocop", stage_idx: 1)
+ create_build("deploy", stage_idx: 2)
end
- it 'processes a pipeline' do
+ it "processes a pipeline" do
expect(process_pipeline).to be_truthy
succeed_pending
@@ -41,7 +41,7 @@ describe Ci::ProcessPipelineService, '#execute' do
expect(builds.success.count).to eq(5)
end
- it 'does not process pipeline if existing stage is running' do
+ it "does not process pipeline if existing stage is running" do
expect(process_pipeline).to be_truthy
expect(builds.pending.count).to eq(2)
@@ -50,19 +50,19 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'custom stage with first job allowed to fail' do
+ context "custom stage with first job allowed to fail" do
before do
- create_build('clean_job', stage_idx: 0, allow_failure: true)
- create_build('test_job', stage_idx: 1, allow_failure: true)
+ create_build("clean_job", stage_idx: 0, allow_failure: true)
+ create_build("test_job", stage_idx: 1, allow_failure: true)
end
- it 'automatically triggers a next stage when build finishes' do
+ it "automatically triggers a next stage when build finishes" do
expect(process_pipeline).to be_truthy
- expect(builds_statuses).to eq ['pending']
+ expect(builds_statuses).to eq ["pending"]
fail_running_or_pending
- expect(builds_statuses).to eq %w(failed pending)
+ expect(builds_statuses).to eq %w[failed pending]
fail_running_or_pending
@@ -70,141 +70,141 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when optional manual actions are defined' do
+ context "when optional manual actions are defined" do
before do
- create_build('build', stage_idx: 0)
- create_build('test', stage_idx: 1)
- create_build('test_failure', stage_idx: 2, when: 'on_failure')
- create_build('deploy', stage_idx: 3)
- create_build('production', stage_idx: 3, when: 'manual', allow_failure: true)
- create_build('cleanup', stage_idx: 4, when: 'always')
- create_build('clear:cache', stage_idx: 4, when: 'manual', allow_failure: true)
+ create_build("build", stage_idx: 0)
+ create_build("test", stage_idx: 1)
+ create_build("test_failure", stage_idx: 2, when: "on_failure")
+ create_build("deploy", stage_idx: 3)
+ create_build("production", stage_idx: 3, when: "manual", allow_failure: true)
+ create_build("cleanup", stage_idx: 4, when: "always")
+ create_build("clear:cache", stage_idx: 4, when: "manual", allow_failure: true)
end
- context 'when builds are successful' do
- it 'properly processes the pipeline' do
+ context "when builds are successful" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build']
- expect(builds_statuses).to eq ['pending']
+ expect(builds_names).to eq ["build"]
+ expect(builds_statuses).to eq ["pending"]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test)
- expect(builds_statuses).to eq %w(success pending)
+ expect(builds_names).to eq %w[build test]
+ expect(builds_statuses).to eq %w[success pending]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test deploy production)
- expect(builds_statuses).to eq %w(success success pending manual)
+ expect(builds_names).to eq %w[build test deploy production]
+ expect(builds_statuses).to eq %w[success success pending manual]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test deploy production cleanup clear:cache)
- expect(builds_statuses).to eq %w(success success success manual pending manual)
+ expect(builds_names).to eq %w[build test deploy production cleanup clear:cache]
+ expect(builds_statuses).to eq %w[success success success manual pending manual]
succeed_running_or_pending
- expect(builds_statuses).to eq %w(success success success manual success manual)
- expect(pipeline.reload.status).to eq 'success'
+ expect(builds_statuses).to eq %w[success success success manual success manual]
+ expect(pipeline.reload.status).to eq "success"
end
end
- context 'when test job fails' do
- it 'properly processes the pipeline' do
+ context "when test job fails" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build']
- expect(builds_statuses).to eq ['pending']
+ expect(builds_names).to eq ["build"]
+ expect(builds_statuses).to eq ["pending"]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test)
- expect(builds_statuses).to eq %w(success pending)
+ expect(builds_names).to eq %w[build test]
+ expect(builds_statuses).to eq %w[success pending]
fail_running_or_pending
- expect(builds_names).to eq %w(build test test_failure)
- expect(builds_statuses).to eq %w(success failed pending)
+ expect(builds_names).to eq %w[build test test_failure]
+ expect(builds_statuses).to eq %w[success failed pending]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test test_failure cleanup)
- expect(builds_statuses).to eq %w(success failed success pending)
+ expect(builds_names).to eq %w[build test test_failure cleanup]
+ expect(builds_statuses).to eq %w[success failed success pending]
succeed_running_or_pending
- expect(builds_statuses).to eq %w(success failed success success)
- expect(pipeline.reload.status).to eq 'failed'
+ expect(builds_statuses).to eq %w[success failed success success]
+ expect(pipeline.reload.status).to eq "failed"
end
end
- context 'when test and test_failure jobs fail' do
- it 'properly processes the pipeline' do
+ context "when test and test_failure jobs fail" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build']
- expect(builds_statuses).to eq ['pending']
+ expect(builds_names).to eq ["build"]
+ expect(builds_statuses).to eq ["pending"]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test)
- expect(builds_statuses).to eq %w(success pending)
+ expect(builds_names).to eq %w[build test]
+ expect(builds_statuses).to eq %w[success pending]
fail_running_or_pending
- expect(builds_names).to eq %w(build test test_failure)
- expect(builds_statuses).to eq %w(success failed pending)
+ expect(builds_names).to eq %w[build test test_failure]
+ expect(builds_statuses).to eq %w[success failed pending]
fail_running_or_pending
- expect(builds_names).to eq %w(build test test_failure cleanup)
- expect(builds_statuses).to eq %w(success failed failed pending)
+ expect(builds_names).to eq %w[build test test_failure cleanup]
+ expect(builds_statuses).to eq %w[success failed failed pending]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test test_failure cleanup)
- expect(builds_statuses).to eq %w(success failed failed success)
- expect(pipeline.reload.status).to eq('failed')
+ expect(builds_names).to eq %w[build test test_failure cleanup]
+ expect(builds_statuses).to eq %w[success failed failed success]
+ expect(pipeline.reload.status).to eq("failed")
end
end
- context 'when deploy job fails' do
- it 'properly processes the pipeline' do
+ context "when deploy job fails" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build']
- expect(builds_statuses).to eq ['pending']
+ expect(builds_names).to eq ["build"]
+ expect(builds_statuses).to eq ["pending"]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test)
- expect(builds_statuses).to eq %w(success pending)
+ expect(builds_names).to eq %w[build test]
+ expect(builds_statuses).to eq %w[success pending]
succeed_running_or_pending
- expect(builds_names).to eq %w(build test deploy production)
- expect(builds_statuses).to eq %w(success success pending manual)
+ expect(builds_names).to eq %w[build test deploy production]
+ expect(builds_statuses).to eq %w[success success pending manual]
fail_running_or_pending
- expect(builds_names).to eq %w(build test deploy production cleanup)
- expect(builds_statuses).to eq %w(success success failed manual pending)
+ expect(builds_names).to eq %w[build test deploy production cleanup]
+ expect(builds_statuses).to eq %w[success success failed manual pending]
succeed_running_or_pending
- expect(builds_statuses).to eq %w(success success failed manual success)
+ expect(builds_statuses).to eq %w[success success failed manual success]
expect(pipeline.reload).to be_failed
end
end
- context 'when build is canceled in the second stage' do
- it 'does not schedule builds after build has been canceled' do
+ context "when build is canceled in the second stage" do
+ it "does not schedule builds after build has been canceled" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build']
- expect(builds_statuses).to eq ['pending']
+ expect(builds_names).to eq ["build"]
+ expect(builds_statuses).to eq ["pending"]
succeed_running_or_pending
expect(builds.running_or_pending).not_to be_empty
- expect(builds_names).to eq %w(build test)
- expect(builds_statuses).to eq %w(success pending)
+ expect(builds_names).to eq %w[build test]
+ expect(builds_statuses).to eq %w[success pending]
cancel_running_or_pending
@@ -215,8 +215,8 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when listing optional manual actions' do
- it 'returns only for skipped builds' do
+ context "when listing optional manual actions" do
+ it "returns only for skipped builds" do
# currently all builds are created
expect(process_pipeline).to be_truthy
expect(manual_actions).to be_empty
@@ -239,212 +239,212 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when delayed jobs are defined' do
- context 'when the scene is timed incremental rollout' do
+ context "when delayed jobs are defined" do
+ context "when the scene is timed incremental rollout" do
before do
- create_build('build', stage_idx: 0)
- create_build('rollout10%', **delayed_options, stage_idx: 1)
- create_build('rollout100%', **delayed_options, stage_idx: 2)
- create_build('cleanup', stage_idx: 3)
+ create_build("build", stage_idx: 0)
+ create_build("rollout10%", **delayed_options, stage_idx: 1)
+ create_build("rollout100%", **delayed_options, stage_idx: 2)
+ create_build("cleanup", stage_idx: 3)
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
end
- context 'when builds are successful' do
- it 'properly processes the pipeline' do
+ context "when builds are successful" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'build': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "pending"})
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "scheduled"})
- enqueue_scheduled('rollout10%')
+ enqueue_scheduled("rollout10%")
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'success', 'rollout100%': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "success", 'rollout100%': "scheduled"})
- enqueue_scheduled('rollout100%')
+ enqueue_scheduled("rollout100%")
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'success', 'rollout100%': 'success', 'cleanup': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "success", 'rollout100%': "success", 'cleanup': "pending"})
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'success', 'rollout100%': 'success', 'cleanup': 'success' })
- expect(pipeline.reload.status).to eq 'success'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "success", 'rollout100%': "success", 'cleanup': "success"})
+ expect(pipeline.reload.status).to eq "success"
end
end
- context 'when build job fails' do
- it 'properly processes the pipeline' do
+ context "when build job fails" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'build': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "pending"})
fail_running_or_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'failed' })
- expect(pipeline.reload.status).to eq 'failed'
+ expect(builds_names_and_statuses).to eq({'build': "failed"})
+ expect(pipeline.reload.status).to eq "failed"
end
end
- context 'when rollout 10% is unscheduled' do
- it 'properly processes the pipeline' do
+ context "when rollout 10% is unscheduled" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'build': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "pending"})
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "scheduled"})
unschedule
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'manual' })
- expect(pipeline.reload.status).to eq 'manual'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "manual"})
+ expect(pipeline.reload.status).to eq "manual"
end
- context 'when user plays rollout 10%' do
- it 'schedules rollout100%' do
+ context "when user plays rollout 10%" do
+ it "schedules rollout100%" do
process_pipeline
succeed_pending
unschedule
- play_manual_action('rollout10%')
+ play_manual_action("rollout10%")
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'success', 'rollout100%': 'scheduled' })
- expect(pipeline.reload.status).to eq 'scheduled'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "success", 'rollout100%': "scheduled"})
+ expect(pipeline.reload.status).to eq "scheduled"
end
end
end
- context 'when rollout 10% fails' do
- it 'properly processes the pipeline' do
+ context "when rollout 10% fails" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'build': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "pending"})
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "scheduled"})
- enqueue_scheduled('rollout10%')
+ enqueue_scheduled("rollout10%")
fail_running_or_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'failed' })
- expect(pipeline.reload.status).to eq 'failed'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "failed"})
+ expect(pipeline.reload.status).to eq "failed"
end
- context 'when user retries rollout 10%' do
- it 'does not schedule rollout10% again' do
+ context "when user retries rollout 10%" do
+ it "does not schedule rollout10% again" do
process_pipeline
succeed_pending
- enqueue_scheduled('rollout10%')
+ enqueue_scheduled("rollout10%")
fail_running_or_pending
- retry_build('rollout10%')
+ retry_build("rollout10%")
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'pending' })
- expect(pipeline.reload.status).to eq 'running'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "pending"})
+ expect(pipeline.reload.status).to eq "running"
end
end
end
- context 'when rollout 10% is played immidiately' do
- it 'properly processes the pipeline' do
+ context "when rollout 10% is played immidiately" do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'build': 'pending' })
+ expect(builds_names_and_statuses).to eq({'build': "pending"})
succeed_pending
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "scheduled"})
- play_manual_action('rollout10%')
+ play_manual_action("rollout10%")
- expect(builds_names_and_statuses).to eq({ 'build': 'success', 'rollout10%': 'pending' })
- expect(pipeline.reload.status).to eq 'running'
+ expect(builds_names_and_statuses).to eq({'build': "success", 'rollout10%': "pending"})
+ expect(pipeline.reload.status).to eq "running"
end
end
end
- context 'when only one scheduled job exists in a pipeline' do
+ context "when only one scheduled job exists in a pipeline" do
before do
- create_build('delayed', **delayed_options, stage_idx: 0)
+ create_build("delayed", **delayed_options, stage_idx: 0)
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
end
- it 'properly processes the pipeline' do
+ it "properly processes the pipeline" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'delayed': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'delayed': "scheduled"})
- expect(pipeline.reload.status).to eq 'scheduled'
+ expect(pipeline.reload.status).to eq "scheduled"
end
end
- context 'when there are two delayed jobs in a stage' do
+ context "when there are two delayed jobs in a stage" do
before do
- create_build('delayed1', **delayed_options, stage_idx: 0)
- create_build('delayed2', **delayed_options, stage_idx: 0)
- create_build('job', stage_idx: 1)
+ create_build("delayed1", **delayed_options, stage_idx: 0)
+ create_build("delayed2", **delayed_options, stage_idx: 0)
+ create_build("job", stage_idx: 1)
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
end
- it 'blocks the stage until all scheduled jobs finished' do
+ it "blocks the stage until all scheduled jobs finished" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'delayed1': 'scheduled', 'delayed2': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'delayed1': "scheduled", 'delayed2': "scheduled"})
- enqueue_scheduled('delayed1')
+ enqueue_scheduled("delayed1")
- expect(builds_names_and_statuses).to eq({ 'delayed1': 'pending', 'delayed2': 'scheduled' })
- expect(pipeline.reload.status).to eq 'running'
+ expect(builds_names_and_statuses).to eq({'delayed1': "pending", 'delayed2': "scheduled"})
+ expect(pipeline.reload.status).to eq "running"
end
end
- context 'when a delayed job is allowed to fail' do
+ context "when a delayed job is allowed to fail" do
before do
- create_build('delayed', **delayed_options, allow_failure: true, stage_idx: 0)
- create_build('job', stage_idx: 1)
+ create_build("delayed", **delayed_options, allow_failure: true, stage_idx: 0)
+ create_build("job", stage_idx: 1)
allow(Ci::BuildScheduleWorker).to receive(:perform_at)
end
- it 'blocks the stage and continues after it failed' do
+ it "blocks the stage and continues after it failed" do
expect(process_pipeline).to be_truthy
- expect(builds_names_and_statuses).to eq({ 'delayed': 'scheduled' })
+ expect(builds_names_and_statuses).to eq({'delayed': "scheduled"})
- enqueue_scheduled('delayed')
+ enqueue_scheduled("delayed")
fail_running_or_pending
- expect(builds_names_and_statuses).to eq({ 'delayed': 'failed', 'job': 'pending' })
- expect(pipeline.reload.status).to eq 'pending'
+ expect(builds_names_and_statuses).to eq({'delayed': "failed", 'job': "pending"})
+ expect(pipeline.reload.status).to eq "pending"
end
end
end
- context 'when there are manual action in earlier stages' do
- context 'when first stage has only optional manual actions' do
+ context "when there are manual action in earlier stages" do
+ context "when first stage has only optional manual actions" do
before do
- create_build('build', stage_idx: 0, when: 'manual', allow_failure: true)
- create_build('check', stage_idx: 1)
- create_build('test', stage_idx: 2)
+ create_build("build", stage_idx: 0, when: "manual", allow_failure: true)
+ create_build("check", stage_idx: 1)
+ create_build("test", stage_idx: 2)
process_pipeline
end
- it 'starts from the second stage' do
+ it "starts from the second stage" do
expect(all_builds_statuses).to eq %w[manual pending created]
end
end
- context 'when second stage has only optional manual actions' do
+ context "when second stage has only optional manual actions" do
before do
- create_build('check', stage_idx: 0)
- create_build('build', stage_idx: 1, when: 'manual', allow_failure: true)
- create_build('test', stage_idx: 2)
+ create_build("check", stage_idx: 0)
+ create_build("build", stage_idx: 1, when: "manual", allow_failure: true)
+ create_build("test", stage_idx: 2)
process_pipeline
end
- it 'skips second stage and continues on third stage' do
+ it "skips second stage and continues on third stage" do
expect(all_builds_statuses).to eq(%w[pending created created])
builds.first.success
@@ -454,17 +454,17 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when there are only manual actions in stages' do
+ context "when there are only manual actions in stages" do
before do
- create_build('image', stage_idx: 0, when: 'manual', allow_failure: true)
- create_build('build', stage_idx: 1, when: 'manual', allow_failure: true)
- create_build('deploy', stage_idx: 2, when: 'manual')
- create_build('check', stage_idx: 3)
+ create_build("image", stage_idx: 0, when: "manual", allow_failure: true)
+ create_build("build", stage_idx: 1, when: "manual", allow_failure: true)
+ create_build("deploy", stage_idx: 2, when: "manual")
+ create_build("check", stage_idx: 3)
process_pipeline
end
- it 'processes all jobs until blocking actions encountered' do
+ it "processes all jobs until blocking actions encountered" do
expect(all_builds_statuses).to eq(%w[manual manual manual created])
expect(all_builds_names).to eq(%w[image build deploy check])
@@ -472,23 +472,23 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when there is only one manual action' do
+ context "when there is only one manual action" do
before do
- create_build('deploy', stage_idx: 0, when: 'manual', allow_failure: true)
+ create_build("deploy", stage_idx: 0, when: "manual", allow_failure: true)
process_pipeline
end
- it 'skips the pipeline' do
+ it "skips the pipeline" do
expect(pipeline.reload).to be_skipped
end
- context 'when the action was played' do
+ context "when the action was played" do
before do
- play_manual_action('deploy')
+ play_manual_action("deploy")
end
- it 'queues the action and pipeline' do
+ it "queues the action and pipeline" do
expect(all_builds_statuses).to eq(%w[pending])
expect(pipeline.reload).to be_pending
@@ -496,22 +496,22 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when blocking manual actions are defined' do
+ context "when blocking manual actions are defined" do
before do
- create_build('code:test', stage_idx: 0)
- create_build('staging:deploy', stage_idx: 1, when: 'manual')
- create_build('staging:test', stage_idx: 2, when: 'on_success')
- create_build('production:deploy', stage_idx: 3, when: 'manual')
- create_build('production:test', stage_idx: 4, when: 'always')
+ create_build("code:test", stage_idx: 0)
+ create_build("staging:deploy", stage_idx: 1, when: "manual")
+ create_build("staging:test", stage_idx: 2, when: "on_success")
+ create_build("production:deploy", stage_idx: 3, when: "manual")
+ create_build("production:test", stage_idx: 4, when: "always")
end
- context 'when first stage succeeds' do
- it 'blocks pipeline on stage with first manual action' do
+ context "when first stage succeeds" do
+ it "blocks pipeline on stage with first manual action" do
process_pipeline
expect(builds_names).to eq %w[code:test]
expect(builds_statuses).to eq %w[pending]
- expect(pipeline.reload.status).to eq 'pending'
+ expect(pipeline.reload.status).to eq "pending"
succeed_running_or_pending
@@ -521,13 +521,13 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when first stage fails' do
- it 'does not take blocking action into account' do
+ context "when first stage fails" do
+ it "does not take blocking action into account" do
process_pipeline
expect(builds_names).to eq %w[code:test]
expect(builds_statuses).to eq %w[pending]
- expect(pipeline.reload.status).to eq 'pending'
+ expect(pipeline.reload.status).to eq "pending"
fail_running_or_pending
@@ -541,16 +541,16 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when pipeline is promoted sequentially up to the end' do
+ context "when pipeline is promoted sequentially up to the end" do
before do
# Users need ability to merge into a branch in order to trigger
# protected manual actions.
#
create(:protected_branch, :developers_can_merge,
- name: 'master', project: project)
+ name: "master", project: project)
end
- it 'properly processes entire pipeline' do
+ it "properly processes entire pipeline" do
process_pipeline
expect(builds_names).to eq %w[code:test]
@@ -562,7 +562,7 @@ describe Ci::ProcessPipelineService, '#execute' do
expect(builds_statuses).to eq %w[success manual]
expect(pipeline.reload).to be_manual
- play_manual_action('staging:deploy')
+ play_manual_action("staging:deploy")
expect(builds_statuses).to eq %w[success pending]
@@ -582,7 +582,7 @@ describe Ci::ProcessPipelineService, '#execute' do
expect(pipeline.reload).not_to be_active
expect(pipeline.reload).not_to be_complete
- play_manual_action('production:deploy')
+ play_manual_action("production:deploy")
expect(builds_statuses).to eq %w[success success success pending]
expect(pipeline.reload).to be_running
@@ -604,16 +604,16 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when second stage has only on_failure jobs' do
+ context "when second stage has only on_failure jobs" do
before do
- create_build('check', stage_idx: 0)
- create_build('build', stage_idx: 1, when: 'on_failure')
- create_build('test', stage_idx: 2)
+ create_build("check", stage_idx: 0)
+ create_build("build", stage_idx: 1, when: "on_failure")
+ create_build("test", stage_idx: 2)
process_pipeline
end
- it 'skips second stage and continues on third stage' do
+ it "skips second stage and continues on third stage" do
expect(all_builds_statuses).to eq(%w[pending created created])
builds.first.success
@@ -622,46 +622,46 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when failed build in the middle stage is retried' do
- context 'when failed build is the only unsuccessful build in the stage' do
+ context "when failed build in the middle stage is retried" do
+ context "when failed build is the only unsuccessful build in the stage" do
before do
- create_build('build:1', stage_idx: 0)
- create_build('build:2', stage_idx: 0)
- create_build('test:1', stage_idx: 1)
- create_build('test:2', stage_idx: 1)
- create_build('deploy:1', stage_idx: 2)
- create_build('deploy:2', stage_idx: 2)
+ create_build("build:1", stage_idx: 0)
+ create_build("build:2", stage_idx: 0)
+ create_build("test:1", stage_idx: 1)
+ create_build("test:2", stage_idx: 1)
+ create_build("deploy:1", stage_idx: 2)
+ create_build("deploy:2", stage_idx: 2)
end
- it 'does trigger builds in the next stage' do
+ it "does trigger builds in the next stage" do
expect(process_pipeline).to be_truthy
- expect(builds_names).to eq ['build:1', 'build:2']
+ expect(builds_names).to eq ["build:1", "build:2"]
succeed_running_or_pending
- expect(builds_names).to eq ['build:1', 'build:2', 'test:1', 'test:2']
+ expect(builds_names).to eq ["build:1", "build:2", "test:1", "test:2"]
- pipeline.builds.find_by(name: 'test:1').success
- pipeline.builds.find_by(name: 'test:2').drop
+ pipeline.builds.find_by(name: "test:1").success
+ pipeline.builds.find_by(name: "test:2").drop
- expect(builds_names).to eq ['build:1', 'build:2', 'test:1', 'test:2']
+ expect(builds_names).to eq ["build:1", "build:2", "test:1", "test:2"]
- Ci::Build.retry(pipeline.builds.find_by(name: 'test:2'), user).success
+ Ci::Build.retry(pipeline.builds.find_by(name: "test:2"), user).success
- expect(builds_names).to eq ['build:1', 'build:2', 'test:1', 'test:2',
- 'test:2', 'deploy:1', 'deploy:2']
+ expect(builds_names).to eq ["build:1", "build:2", "test:1", "test:2",
+ "test:2", "deploy:1", "deploy:2",]
end
end
end
- context 'updates a list of retried builds' do
+ context "updates a list of retried builds" do
subject { described_class.retried.order(:id) }
- let!(:build_retried) { create_build('build') }
- let!(:build) { create_build('build') }
- let!(:test) { create_build('test') }
+ let!(:build_retried) { create_build("build") }
+ let!(:build) { create_build("build") }
+ let!(:test) { create_build("test") }
- it 'returns unique statuses' do
+ it "returns unique statuses" do
process_pipeline
expect(all_builds.latest).to contain_exactly(build, test)
@@ -669,14 +669,14 @@ describe Ci::ProcessPipelineService, '#execute' do
end
end
- context 'when builds with auto-retries are configured' do
+ context "when builds with auto-retries are configured" do
before do
- create_build('build:1', stage_idx: 0, user: user, options: { script: 'aa', retry: 2 })
- create_build('test:1', stage_idx: 1, user: user, when: :on_failure)
- create_build('test:2', stage_idx: 1, user: user, options: { script: 'aa', retry: 1 })
+ create_build("build:1", stage_idx: 0, user: user, options: {script: "aa", retry: 2})
+ create_build("test:1", stage_idx: 1, user: user, when: :on_failure)
+ create_build("test:2", stage_idx: 1, user: user, options: {script: "aa", retry: 1})
end
- it 'automatically retries builds in a valid order' do
+ it "automatically retries builds in a valid order" do
expect(process_pipeline).to be_truthy
fail_running_or_pending
@@ -770,7 +770,7 @@ describe Ci::ProcessPipelineService, '#execute' do
end
def delayed_options
- { when: 'delayed', options: { script: %w(echo), start_in: '1 minute' } }
+ {when: "delayed", options: {script: %w[echo], start_in: "1 minute"}}
end
def unschedule
diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb
index 20181387612..538b2e5ec72 100644
--- a/spec/services/ci/register_job_service_spec.rb
+++ b/spec/services/ci/register_job_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
module Ci
describe RegisterJobService do
@@ -10,8 +10,8 @@ module Ci
let!(:group_runner) { create(:ci_runner, :group, groups: [group]) }
let!(:pending_job) { create(:ci_build, pipeline: pipeline) }
- describe '#execute' do
- context 'runner follow tag list' do
+ describe "#execute" do
+ context "runner follow tag list" do
it "picks build with the same tag" do
pending_job.update(tag_list: ["linux"])
specific_runner.update(tag_list: ["linux"])
@@ -39,34 +39,34 @@ module Ci
end
end
- context 'deleted projects' do
+ context "deleted projects" do
before do
project.update(pending_delete: true)
end
- context 'for shared runners' do
+ context "for shared runners" do
before do
project.update(shared_runners_enabled: true)
end
- it 'does not pick a build' do
+ it "does not pick a build" do
expect(execute(shared_runner)).to be_nil
end
end
- context 'for specific runner' do
- it 'does not pick a build' do
+ context "for specific runner" do
+ it "does not pick a build" do
expect(execute(specific_runner)).to be_nil
end
end
end
- context 'allow shared runners' do
+ context "allow shared runners" do
before do
project.update(shared_runners_enabled: true)
end
- context 'for multiple builds' do
+ context "for multiple builds" do
let!(:project2) { create :project, shared_runners_enabled: true }
let!(:pipeline2) { create :ci_pipeline, project: project2 }
let!(:project3) { create :project, shared_runners_enabled: true }
@@ -78,7 +78,7 @@ module Ci
let!(:build2_project2) { FactoryBot.create :ci_build, pipeline: pipeline2 }
let!(:build1_project3) { FactoryBot.create :ci_build, pipeline: pipeline3 }
- it 'prefers projects without builds first' do
+ it "prefers projects without builds first" do
# it gets for one build from each of the projects
expect(execute(shared_runner)).to eq(build1_project1)
expect(execute(shared_runner)).to eq(build1_project2)
@@ -92,7 +92,7 @@ module Ci
expect(execute(shared_runner)).to eq(build3_project1)
end
- it 'equalises number of running builds' do
+ it "equalises number of running builds" do
# after finishing the first build for project 1, get a second build from the same project
expect(execute(shared_runner)).to eq(build1_project1)
build1_project1.reload.success
@@ -106,7 +106,7 @@ module Ci
end
end
- context 'shared runner' do
+ context "shared runner" do
let(:build) { execute(shared_runner) }
it { expect(build).to be_kind_of(Build) }
@@ -115,7 +115,7 @@ module Ci
it { expect(build.runner).to eq(shared_runner) }
end
- context 'specific runner' do
+ context "specific runner" do
let(:build) { execute(specific_runner) }
it { expect(build).to be_kind_of(Build) }
@@ -125,18 +125,18 @@ module Ci
end
end
- context 'disallow shared runners' do
+ context "disallow shared runners" do
before do
project.update(shared_runners_enabled: false)
end
- context 'shared runner' do
+ context "shared runner" do
let(:build) { execute(shared_runner) }
it { expect(build).to be_nil }
end
- context 'specific runner' do
+ context "specific runner" do
let(:build) { execute(specific_runner) }
it { expect(build).to be_kind_of(Build) }
@@ -146,37 +146,37 @@ module Ci
end
end
- context 'disallow when builds are disabled' do
+ context "disallow when builds are disabled" do
before do
project.update(shared_runners_enabled: true, group_runners_enabled: true)
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end
- context 'and uses shared runner' do
+ context "and uses shared runner" do
let(:build) { execute(shared_runner) }
it { expect(build).to be_nil }
end
- context 'and uses group runner' do
+ context "and uses group runner" do
let(:build) { execute(group_runner) }
it { expect(build).to be_nil }
end
- context 'and uses project runner' do
+ context "and uses project runner" do
let(:build) { execute(specific_runner) }
it { expect(build).to be_nil }
end
end
- context 'allow group runners' do
+ context "allow group runners" do
before do
project.update!(group_runners_enabled: true)
end
- context 'for multiple builds' do
+ context "for multiple builds" do
let!(:project2) { create(:project, group_runners_enabled: true, group: group) }
let!(:pipeline2) { create(:ci_pipeline, project: project2) }
let!(:project3) { create(:project, group_runners_enabled: true, group: group) }
@@ -196,7 +196,7 @@ module Ci
let!(:build1_unrelated_project) { create(:ci_build, pipeline: unrelated_pipeline) }
let!(:unrelated_group_runner) { create(:ci_runner, :group, groups: [unrelated_group]) }
- it 'does not consider builds from other group runners' do
+ it "does not consider builds from other group runners" do
expect(described_class.new(group_runner).send(:builds_for_group_runner).count).to eq 6
execute(group_runner)
@@ -220,7 +220,7 @@ module Ci
end
end
- context 'group runner' do
+ context "group runner" do
let(:build) { execute(group_runner) }
it { expect(build).to be_kind_of(Build) }
@@ -230,19 +230,19 @@ module Ci
end
end
- context 'disallow group runners' do
+ context "disallow group runners" do
before do
project.update!(group_runners_enabled: false)
end
- context 'group runner' do
+ context "group runner" do
let(:build) { execute(group_runner) }
it { expect(build).to be_nil }
end
end
- context 'when first build is stalled' do
+ context "when first build is stalled" do
before do
allow_any_instance_of(Ci::RegisterJobService).to receive(:assign_runner!).and_call_original
allow_any_instance_of(Ci::RegisterJobService).to receive(:assign_runner!)
@@ -251,7 +251,7 @@ module Ci
subject { described_class.new(specific_runner).execute }
- context 'with multiple builds are in queue' do
+ context "with multiple builds are in queue" do
let!(:other_build) { create :ci_build, pipeline: pipeline }
before do
@@ -265,7 +265,7 @@ module Ci
end
end
- context 'when single build is in queue' do
+ context "when single build is in queue" do
before do
allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_project_runner)
.and_return(Ci::Build.where(id: pending_job))
@@ -276,7 +276,7 @@ module Ci
end
end
- context 'when there is no build in queue' do
+ context "when there is no build in queue" do
before do
allow_any_instance_of(Ci::RegisterJobService).to receive(:builds_for_project_runner)
.and_return(Ci::Build.none)
@@ -289,71 +289,71 @@ module Ci
end
end
- context 'when access_level of runner is not_protected' do
+ context "when access_level of runner is not_protected" do
let!(:specific_runner) { create(:ci_runner, :project, projects: [project]) }
- context 'when a job is protected' do
+ context "when a job is protected" do
let!(:pending_job) { create(:ci_build, :protected, pipeline: pipeline) }
- it 'picks the job' do
+ it "picks the job" do
expect(execute(specific_runner)).to eq(pending_job)
end
end
- context 'when a job is unprotected' do
+ context "when a job is unprotected" do
let!(:pending_job) { create(:ci_build, pipeline: pipeline) }
- it 'picks the job' do
+ it "picks the job" do
expect(execute(specific_runner)).to eq(pending_job)
end
end
- context 'when protected attribute of a job is nil' do
+ context "when protected attribute of a job is nil" do
let!(:pending_job) { create(:ci_build, pipeline: pipeline) }
before do
pending_job.update_attribute(:protected, nil)
end
- it 'picks the job' do
+ it "picks the job" do
expect(execute(specific_runner)).to eq(pending_job)
end
end
end
- context 'when access_level of runner is ref_protected' do
+ context "when access_level of runner is ref_protected" do
let!(:specific_runner) { create(:ci_runner, :project, :ref_protected, projects: [project]) }
- context 'when a job is protected' do
+ context "when a job is protected" do
let!(:pending_job) { create(:ci_build, :protected, pipeline: pipeline) }
- it 'picks the job' do
+ it "picks the job" do
expect(execute(specific_runner)).to eq(pending_job)
end
end
- context 'when a job is unprotected' do
+ context "when a job is unprotected" do
let!(:pending_job) { create(:ci_build, pipeline: pipeline) }
- it 'does not pick the job' do
+ it "does not pick the job" do
expect(execute(specific_runner)).to be_nil
end
end
- context 'when protected attribute of a job is nil' do
+ context "when protected attribute of a job is nil" do
let!(:pending_job) { create(:ci_build, pipeline: pipeline) }
before do
pending_job.update_attribute(:protected, nil)
end
- it 'does not pick the job' do
+ it "does not pick the job" do
expect(execute(specific_runner)).to be_nil
end
end
end
- context 'runner feature set is verified' do
+ context "runner feature set is verified" do
let!(:pending_job) { create(:ci_build, :pending, pipeline: pipeline) }
before do
@@ -364,88 +364,88 @@ module Ci
subject { execute(specific_runner, params) }
- context 'when feature is missing by runner' do
+ context "when feature is missing by runner" do
let(:params) { {} }
- it 'does not pick the build and drops the build' do
+ it "does not pick the build and drops the build" do
expect(subject).to be_nil
expect(pending_job.reload).to be_failed
expect(pending_job).to be_runner_unsupported
end
end
- context 'when feature is supported by runner' do
+ context "when feature is supported by runner" do
let(:params) do
- { info: { features: { runner_required_feature: true } } }
+ {info: {features: {runner_required_feature: true}}}
end
- it 'does pick job' do
+ it "does pick job" do
expect(subject).not_to be_nil
end
end
end
context 'when "dependencies" keyword is specified' do
- shared_examples 'not pick' do
- it 'does not pick the build and drops the build' do
+ shared_examples "not pick" do
+ it "does not pick the build and drops the build" do
expect(subject).to be_nil
expect(pending_job.reload).to be_failed
expect(pending_job).to be_missing_dependency_failure
end
end
- shared_examples 'validation is active' do
- context 'when depended job has not been completed yet' do
- let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ shared_examples "validation is active" do
+ context "when depended job has not been completed yet" do
+ let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(subject).to eq(pending_job) }
end
- context 'when artifacts of depended job has been expired' do
- let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ context "when artifacts of depended job has been expired" do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: "test", stage_idx: 0) }
- it_behaves_like 'not pick'
+ it_behaves_like "not pick"
end
- context 'when artifacts of depended job has been erased' do
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
+ context "when artifacts of depended job has been erased" do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0, erased_at: 1.minute.ago) }
before do
pre_stage_job.erase
end
- it_behaves_like 'not pick'
+ it_behaves_like "not pick"
end
- context 'when job object is staled' do
- let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ context "when job object is staled" do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: "test", stage_idx: 0) }
before do
allow_any_instance_of(Ci::Build).to receive(:drop!)
.and_raise(ActiveRecord::StaleObjectError.new(pending_job, :drop!))
end
- it 'does not drop nor pick' do
+ it "does not drop nor pick" do
expect(subject).to be_nil
end
end
end
- shared_examples 'validation is not active' do
- context 'when depended job has not been completed yet' do
- let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ shared_examples "validation is not active" do
+ context "when depended job has not been completed yet" do
+ let!(:pre_stage_job) { create(:ci_build, :manual, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(subject).to eq(pending_job) }
end
- context 'when artifacts of depended job has been expired' do
- let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ context "when artifacts of depended job has been expired" do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: "test", stage_idx: 0) }
it { expect(subject).to eq(pending_job) }
end
- context 'when artifacts of depended job has been erased' do
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
+ context "when artifacts of depended job has been erased" do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0, erased_at: 1.minute.ago) }
before do
pre_stage_job.erase
@@ -459,39 +459,39 @@ module Ci
stub_feature_flags(ci_disable_validates_dependencies: false)
end
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: "test", stage_idx: 0) }
let!(:pending_job) do
create(:ci_build, :pending,
pipeline: pipeline, stage_idx: 1,
- options: { script: ["bash"], dependencies: ['test'] })
+ options: {script: ["bash"], dependencies: ["test"]})
end
subject { execute(specific_runner) }
- context 'when validates for dependencies is enabled' do
+ context "when validates for dependencies is enabled" do
before do
stub_feature_flags(ci_disable_validates_dependencies: false)
end
- it_behaves_like 'validation is active'
+ it_behaves_like "validation is active"
end
- context 'when validates for dependencies is disabled' do
+ context "when validates for dependencies is disabled" do
before do
stub_feature_flags(ci_disable_validates_dependencies: true)
end
- it_behaves_like 'validation is not active'
+ it_behaves_like "validation is not active"
end
end
- context 'when build is degenerated' do
+ context "when build is degenerated" do
let!(:pending_job) { create(:ci_build, :pending, :degenerated, pipeline: pipeline) }
subject { execute(specific_runner, {}) }
- it 'does not pick the build and drops the build' do
+ it "does not pick the build and drops the build" do
expect(subject).to be_nil
pending_job.reload
@@ -501,36 +501,36 @@ module Ci
end
end
- describe '#register_success' do
+ describe "#register_success" do
let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) }
- let!(:attempt_counter) { double('Gitlab::Metrics::NullMetric') }
- let!(:job_queue_duration_seconds) { double('Gitlab::Metrics::NullMetric') }
+ let!(:attempt_counter) { double("Gitlab::Metrics::NullMetric") }
+ let!(:job_queue_duration_seconds) { double("Gitlab::Metrics::NullMetric") }
before do
allow(Time).to receive(:now).and_return(current_time)
# Stub defaults for any metrics other than the ones we're testing
allow(Gitlab::Metrics).to receive(:counter)
- .with(any_args)
- .and_return(Gitlab::Metrics::NullMetric.instance)
+ .with(any_args)
+ .and_return(Gitlab::Metrics::NullMetric.instance)
allow(Gitlab::Metrics).to receive(:histogram)
- .with(any_args)
- .and_return(Gitlab::Metrics::NullMetric.instance)
+ .with(any_args)
+ .and_return(Gitlab::Metrics::NullMetric.instance)
# Stub tested metrics
allow(Gitlab::Metrics).to receive(:counter)
- .with(:job_register_attempts_total, anything)
- .and_return(attempt_counter)
+ .with(:job_register_attempts_total, anything)
+ .and_return(attempt_counter)
allow(Gitlab::Metrics).to receive(:histogram)
- .with(:job_queue_duration_seconds, anything, anything, anything)
- .and_return(job_queue_duration_seconds)
+ .with(:job_queue_duration_seconds, anything, anything, anything)
+ .and_return(job_queue_duration_seconds)
project.update(shared_runners_enabled: true)
pending_job.update(created_at: current_time - 3600, queued_at: current_time - 1800)
end
- shared_examples 'attempt counter collector' do
- it 'increments attempt counter' do
+ shared_examples "attempt counter collector" do
+ it "increments attempt counter" do
allow(job_queue_duration_seconds).to receive(:observe)
expect(attempt_counter).to receive(:increment)
@@ -538,50 +538,50 @@ module Ci
end
end
- shared_examples 'jobs queueing time histogram collector' do
- it 'counts job queuing time histogram with expected labels' do
+ shared_examples "jobs queueing time histogram collector" do
+ it "counts job queuing time histogram with expected labels" do
allow(attempt_counter).to receive(:increment)
expect(job_queue_duration_seconds).to receive(:observe)
- .with({ shared_runner: expected_shared_runner,
- jobs_running_for_project: expected_jobs_running_for_project_first_job }, 1800)
+ .with({shared_runner: expected_shared_runner,
+ jobs_running_for_project: expected_jobs_running_for_project_first_job,}, 1800)
execute(runner)
end
- context 'when project already has running jobs' do
- let!(:build2) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) }
- let!(:build3) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) }
+ context "when project already has running jobs" do
+ let!(:build2) { create(:ci_build, :running, pipeline: pipeline, runner: shared_runner) }
+ let!(:build3) { create(:ci_build, :running, pipeline: pipeline, runner: shared_runner) }
- it 'counts job queuing time histogram with expected labels' do
+ it "counts job queuing time histogram with expected labels" do
allow(attempt_counter).to receive(:increment)
expect(job_queue_duration_seconds).to receive(:observe)
- .with({ shared_runner: expected_shared_runner,
- jobs_running_for_project: expected_jobs_running_for_project_third_job }, 1800)
+ .with({shared_runner: expected_shared_runner,
+ jobs_running_for_project: expected_jobs_running_for_project_third_job,}, 1800)
execute(runner)
end
end
end
- shared_examples 'metrics collector' do
- it_behaves_like 'attempt counter collector'
- it_behaves_like 'jobs queueing time histogram collector'
+ shared_examples "metrics collector" do
+ it_behaves_like "attempt counter collector"
+ it_behaves_like "jobs queueing time histogram collector"
end
- context 'when shared runner is used' do
+ context "when shared runner is used" do
let(:runner) { shared_runner }
let(:expected_shared_runner) { true }
let(:expected_jobs_running_for_project_first_job) { 0 }
let(:expected_jobs_running_for_project_third_job) { 2 }
- it_behaves_like 'metrics collector'
+ it_behaves_like "metrics collector"
- context 'when pending job with queued_at=nil is used' do
+ context "when pending job with queued_at=nil is used" do
before do
pending_job.update(queued_at: nil)
end
- it_behaves_like 'attempt counter collector'
+ it_behaves_like "attempt counter collector"
it "doesn't count job queuing time histogram" do
allow(attempt_counter).to receive(:increment)
@@ -592,25 +592,25 @@ module Ci
end
end
- context 'when specific runner is used' do
+ context "when specific runner is used" do
let(:runner) { specific_runner }
let(:expected_shared_runner) { false }
- let(:expected_jobs_running_for_project_first_job) { '+Inf' }
- let(:expected_jobs_running_for_project_third_job) { '+Inf' }
+ let(:expected_jobs_running_for_project_first_job) { "+Inf" }
+ let(:expected_jobs_running_for_project_third_job) { "+Inf" }
- it_behaves_like 'metrics collector'
+ it_behaves_like "metrics collector"
end
end
- context 'when runner_session params are' do
- it 'present sets runner session configuration in the build' do
- runner_session_params = { session: { 'url' => 'https://example.com' } }
+ context "when runner_session params are" do
+ it "present sets runner session configuration in the build" do
+ runner_session_params = {session: {"url" => "https://example.com"}}
expect(execute(specific_runner, runner_session_params).runner_session.attributes)
.to include(runner_session_params[:session])
end
- it 'not present it does not configure the runner session' do
+ it "not present it does not configure the runner session" do
expect(execute(specific_runner).runner_session).to be_nil
end
end
diff --git a/spec/services/ci/retry_build_service_spec.rb b/spec/services/ci/retry_build_service_spec.rb
index 87185891470..45bcb3ba24e 100644
--- a/spec/services/ci/retry_build_service_spec.rb
+++ b/spec/services/ci/retry_build_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::RetryBuildService do
set(:user) { create(:user) }
@@ -8,7 +8,7 @@ describe Ci::RetryBuildService do
let(:stage) do
create(:ci_stage_entity, project: project,
pipeline: pipeline,
- name: 'test')
+ name: "test")
end
let(:build) { create(:ci_build, pipeline: pipeline, stage_id: stage.id) }
@@ -38,34 +38,34 @@ describe Ci::RetryBuildService do
artifacts_file_store artifacts_metadata_store
metadata runner_session trace_chunks].freeze
- shared_examples 'build duplication' do
+ shared_examples "build duplication" do
let(:another_pipeline) { create(:ci_empty_pipeline, project: project) }
let(:build) do
create(:ci_build, :failed, :expired, :erased, :queued, :coverage, :tags,
- :allowed_to_fail, :on_tag, :triggered, :teardown_environment,
- description: 'my-job', stage: 'test', stage_id: stage.id,
- pipeline: pipeline, auto_canceled_by: another_pipeline,
- scheduled_at: 10.seconds.since)
+ :allowed_to_fail, :on_tag, :triggered, :teardown_environment,
+ description: "my-job", stage: "test", stage_id: stage.id,
+ pipeline: pipeline, auto_canceled_by: another_pipeline,
+ scheduled_at: 10.seconds.since)
end
before do
# Make sure that build has both `stage_id` and `stage` because FactoryBot
# can reset one of the fields when assigning another. We plan to deprecate
# and remove legacy `stage` column in the future.
- build.update(stage: 'test', stage_id: stage.id)
+ build.update(stage: "test", stage_id: stage.id)
# Make sure we have one instance for every possible job_artifact_X
# associations to check they are correctly rejected on build duplication.
Ci::JobArtifact::TYPE_AND_FORMAT_PAIRS.each do |file_type, file_format|
create(:ci_job_artifact, file_format,
- file_type: file_type, job: build, expire_at: build.artifacts_expire_at)
+ file_type: file_type, job: build, expire_at: build.artifacts_expire_at)
end
build.reload
end
- describe 'clone accessors' do
+ describe "clone accessors" do
CLONE_ACCESSORS.each do |attribute|
it "clones #{attribute} build attribute" do
expect(build.send(attribute)).not_to be_nil
@@ -74,7 +74,7 @@ describe Ci::RetryBuildService do
end
end
- context 'when job has nullified protected' do
+ context "when job has nullified protected" do
before do
build.update_attribute(:protected, nil)
end
@@ -86,7 +86,7 @@ describe Ci::RetryBuildService do
end
end
- describe 'reject acessors' do
+ describe "reject acessors" do
REJECT_ACCESSORS.each do |attribute|
it "does not clone #{attribute} build attribute" do
expect(new_build.send(attribute)).not_to eq build.send(attribute)
@@ -94,7 +94,7 @@ describe Ci::RetryBuildService do
end
end
- it 'has correct number of known attributes' do
+ it "has correct number of known attributes" do
known_accessors = CLONE_ACCESSORS + REJECT_ACCESSORS + IGNORE_ACCESSORS
# :tag_list is a special case, this accessor does not exist
@@ -112,45 +112,45 @@ describe Ci::RetryBuildService do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:new_build) do
Timecop.freeze(1.second.from_now) do
service.execute(build)
end
end
- context 'when user has ability to execute build' do
+ context "when user has ability to execute build" do
before do
stub_not_protect_default_branch
project.add_developer(user)
end
- it_behaves_like 'build duplication'
+ it_behaves_like "build duplication"
- it 'creates a new build that represents the old one' do
+ it "creates a new build that represents the old one" do
expect(new_build.name).to eq build.name
end
- it 'enqueues the new build' do
+ it "enqueues the new build" do
expect(new_build).to be_pending
end
- it 'resolves todos for old build that failed' do
+ it "resolves todos for old build that failed" do
expect(MergeRequests::AddTodoWhenBuildFailsService)
.to receive_message_chain(:new, :close)
service.execute(build)
end
- context 'when there are subsequent builds that are skipped' do
+ context "when there are subsequent builds that are skipped" do
let!(:subsequent_build) do
create(:ci_build, :skipped, stage_idx: 2,
pipeline: pipeline,
- stage: 'deploy')
+ stage: "deploy")
end
- it 'resumes pipeline processing in a subsequent stage' do
+ it "resumes pipeline processing in a subsequent stage" do
service.execute(build)
expect(subsequent_build.reload).to be_created
@@ -158,47 +158,47 @@ describe Ci::RetryBuildService do
end
end
- context 'when user does not have ability to execute build' do
- it 'raises an error' do
+ context "when user does not have ability to execute build" do
+ it "raises an error" do
expect { service.execute(build) }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
end
- describe '#reprocess' do
+ describe "#reprocess" do
let(:new_build) do
Timecop.freeze(1.second.from_now) do
service.reprocess!(build)
end
end
- context 'when user has ability to execute build' do
+ context "when user has ability to execute build" do
before do
stub_not_protect_default_branch
project.add_developer(user)
end
- it_behaves_like 'build duplication'
+ it_behaves_like "build duplication"
- it 'creates a new build that represents the old one' do
+ it "creates a new build that represents the old one" do
expect(new_build.name).to eq build.name
end
- it 'does not enqueue the new build' do
+ it "does not enqueue the new build" do
expect(new_build).to be_created
end
- it 'does mark old build as retried in the database and on the instance' do
+ it "does mark old build as retried in the database and on the instance" do
expect(new_build).to be_latest
expect(build).to be_retried
expect(build.reload).to be_retried
end
end
- context 'when user does not have ability to execute build' do
- it 'raises an error' do
+ context "when user does not have ability to execute build" do
+ it "raises an error" do
expect { service.reprocess!(build) }
.to raise_error Gitlab::Access::AccessDeniedError
end
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index 75042b29bea..ab149d0b985 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Ci::RetryPipelineService, '#execute' do
+describe Ci::RetryPipelineService, "#execute" do
include ProjectForksHelper
let(:user) { create(:user) }
@@ -8,289 +8,289 @@ describe Ci::RetryPipelineService, '#execute' do
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:service) { described_class.new(project, user) }
- context 'when user has full ability to modify pipeline' do
+ context "when user has full ability to modify pipeline" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- context 'when there are already retried jobs present' do
+ context "when there are already retried jobs present" do
before do
- create_build('rspec', :canceled, 0, retried: true)
- create_build('rspec', :failed, 0)
+ create_build("rspec", :canceled, 0, retried: true)
+ create_build("rspec", :failed, 0)
end
- it 'does not retry jobs that has already been retried' do
+ it "does not retry jobs that has already been retried" do
expect(statuses.first).to be_retried
expect { service.execute(pipeline) }
.to change { CommitStatus.count }.by(1)
end
end
- context 'when there are failed builds in the last stage' do
+ context "when there are failed builds in the last stage" do
before do
- create_build('rspec 1', :success, 0)
- create_build('rspec 2', :failed, 1)
- create_build('rspec 3', :canceled, 1)
+ create_build("rspec 1", :success, 0)
+ create_build("rspec 2", :failed, 1)
+ create_build("rspec 3", :canceled, 1)
end
- it 'enqueues all builds in the last stage' do
+ it "enqueues all builds in the last stage" do
service.execute(pipeline)
- expect(build('rspec 2')).to be_pending
- expect(build('rspec 3')).to be_pending
+ expect(build("rspec 2")).to be_pending
+ expect(build("rspec 3")).to be_pending
expect(pipeline.reload).to be_running
end
end
- context 'when there are failed or canceled builds in the first stage' do
+ context "when there are failed or canceled builds in the first stage" do
before do
- create_build('rspec 1', :failed, 0)
- create_build('rspec 2', :canceled, 0)
- create_build('rspec 3', :canceled, 1)
- create_build('spinach 1', :canceled, 2)
+ create_build("rspec 1", :failed, 0)
+ create_build("rspec 2", :canceled, 0)
+ create_build("rspec 3", :canceled, 1)
+ create_build("spinach 1", :canceled, 2)
end
- it 'retries builds failed builds and marks subsequent for processing' do
+ it "retries builds failed builds and marks subsequent for processing" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('rspec 2')).to be_pending
- expect(build('rspec 3')).to be_created
- expect(build('spinach 1')).to be_created
+ expect(build("rspec 1")).to be_pending
+ expect(build("rspec 2")).to be_pending
+ expect(build("rspec 3")).to be_created
+ expect(build("spinach 1")).to be_created
expect(pipeline.reload).to be_running
end
end
- context 'when there is failed build present which was run on failure' do
+ context "when there is failed build present which was run on failure" do
before do
- create_build('rspec 1', :failed, 0)
- create_build('rspec 2', :canceled, 0)
- create_build('rspec 3', :canceled, 1)
- create_build('report 1', :failed, 2)
+ create_build("rspec 1", :failed, 0)
+ create_build("rspec 2", :canceled, 0)
+ create_build("rspec 3", :canceled, 1)
+ create_build("report 1", :failed, 2)
end
- it 'retries builds only in the first stage' do
+ it "retries builds only in the first stage" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('rspec 2')).to be_pending
- expect(build('rspec 3')).to be_created
- expect(build('report 1')).to be_created
+ expect(build("rspec 1")).to be_pending
+ expect(build("rspec 2")).to be_pending
+ expect(build("rspec 3")).to be_created
+ expect(build("report 1")).to be_created
expect(pipeline.reload).to be_running
end
- it 'creates a new job for report job in this case' do
+ it "creates a new job for report job in this case" do
service.execute(pipeline)
- expect(statuses.where(name: 'report 1').first).to be_retried
+ expect(statuses.where(name: "report 1").first).to be_retried
end
end
- context 'when the last stage was skipepd' do
+ context "when the last stage was skipepd" do
before do
- create_build('build 1', :success, 0)
- create_build('test 2', :failed, 1)
- create_build('report 3', :skipped, 2)
- create_build('report 4', :skipped, 2)
+ create_build("build 1", :success, 0)
+ create_build("test 2", :failed, 1)
+ create_build("report 3", :skipped, 2)
+ create_build("report 4", :skipped, 2)
end
- it 'retries builds only in the first stage' do
+ it "retries builds only in the first stage" do
service.execute(pipeline)
- expect(build('build 1')).to be_success
- expect(build('test 2')).to be_pending
- expect(build('report 3')).to be_created
- expect(build('report 4')).to be_created
+ expect(build("build 1")).to be_success
+ expect(build("test 2")).to be_pending
+ expect(build("report 3")).to be_created
+ expect(build("report 4")).to be_created
expect(pipeline.reload).to be_running
end
end
- context 'when pipeline contains manual actions' do
- context 'when there are optional manual actions only' do
- context 'when there is a canceled manual action in first stage' do
+ context "when pipeline contains manual actions" do
+ context "when there are optional manual actions only" do
+ context "when there is a canceled manual action in first stage" do
before do
- create_build('rspec 1', :failed, 0)
- create_build('staging', :canceled, 0, when: :manual, allow_failure: true)
- create_build('rspec 2', :canceled, 1)
+ create_build("rspec 1", :failed, 0)
+ create_build("staging", :canceled, 0, when: :manual, allow_failure: true)
+ create_build("rspec 2", :canceled, 1)
end
- it 'retries failed builds and marks subsequent for processing' do
+ it "retries failed builds and marks subsequent for processing" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('staging')).to be_manual
- expect(build('rspec 2')).to be_created
+ expect(build("rspec 1")).to be_pending
+ expect(build("staging")).to be_manual
+ expect(build("rspec 2")).to be_created
expect(pipeline.reload).to be_running
end
end
end
- context 'when pipeline has blocking manual actions defined' do
- context 'when pipeline retry should enqueue builds' do
+ context "when pipeline has blocking manual actions defined" do
+ context "when pipeline retry should enqueue builds" do
before do
- create_build('test', :failed, 0)
- create_build('deploy', :canceled, 0, when: :manual, allow_failure: false)
- create_build('verify', :canceled, 1)
+ create_build("test", :failed, 0)
+ create_build("deploy", :canceled, 0, when: :manual, allow_failure: false)
+ create_build("verify", :canceled, 1)
end
- it 'retries failed builds' do
+ it "retries failed builds" do
service.execute(pipeline)
- expect(build('test')).to be_pending
- expect(build('deploy')).to be_manual
- expect(build('verify')).to be_created
+ expect(build("test")).to be_pending
+ expect(build("deploy")).to be_manual
+ expect(build("verify")).to be_created
expect(pipeline.reload).to be_running
end
end
- context 'when pipeline retry should block pipeline immediately' do
+ context "when pipeline retry should block pipeline immediately" do
before do
- create_build('test', :success, 0)
- create_build('deploy:1', :success, 1, when: :manual, allow_failure: false)
- create_build('deploy:2', :failed, 1, when: :manual, allow_failure: false)
- create_build('verify', :canceled, 2)
+ create_build("test", :success, 0)
+ create_build("deploy:1", :success, 1, when: :manual, allow_failure: false)
+ create_build("deploy:2", :failed, 1, when: :manual, allow_failure: false)
+ create_build("verify", :canceled, 2)
end
- it 'reprocesses blocking manual action and blocks pipeline' do
+ it "reprocesses blocking manual action and blocks pipeline" do
service.execute(pipeline)
- expect(build('deploy:1')).to be_success
- expect(build('deploy:2')).to be_manual
- expect(build('verify')).to be_created
+ expect(build("deploy:1")).to be_success
+ expect(build("deploy:2")).to be_manual
+ expect(build("verify")).to be_created
expect(pipeline.reload).to be_blocked
end
end
end
- context 'when there is a skipped manual action in last stage' do
+ context "when there is a skipped manual action in last stage" do
before do
- create_build('rspec 1', :canceled, 0)
- create_build('rspec 2', :skipped, 0, when: :manual, allow_failure: true)
- create_build('staging', :skipped, 1, when: :manual, allow_failure: true)
+ create_build("rspec 1", :canceled, 0)
+ create_build("rspec 2", :skipped, 0, when: :manual, allow_failure: true)
+ create_build("staging", :skipped, 1, when: :manual, allow_failure: true)
end
- it 'retries canceled job and reprocesses manual actions' do
+ it "retries canceled job and reprocesses manual actions" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('rspec 2')).to be_manual
- expect(build('staging')).to be_created
+ expect(build("rspec 1")).to be_pending
+ expect(build("rspec 2")).to be_manual
+ expect(build("staging")).to be_created
expect(pipeline.reload).to be_running
end
end
- context 'when there is a created manual action in the last stage' do
+ context "when there is a created manual action in the last stage" do
before do
- create_build('rspec 1', :canceled, 0)
- create_build('staging', :created, 1, when: :manual, allow_failure: true)
+ create_build("rspec 1", :canceled, 0)
+ create_build("staging", :created, 1, when: :manual, allow_failure: true)
end
- it 'retries canceled job and does not update the manual action' do
+ it "retries canceled job and does not update the manual action" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('staging')).to be_created
+ expect(build("rspec 1")).to be_pending
+ expect(build("staging")).to be_created
expect(pipeline.reload).to be_running
end
end
- context 'when there is a created manual action in the first stage' do
+ context "when there is a created manual action in the first stage" do
before do
- create_build('rspec 1', :canceled, 0)
- create_build('staging', :created, 0, when: :manual, allow_failure: true)
+ create_build("rspec 1", :canceled, 0)
+ create_build("staging", :created, 0, when: :manual, allow_failure: true)
end
- it 'retries canceled job and processes the manual action' do
+ it "retries canceled job and processes the manual action" do
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
- expect(build('staging')).to be_manual
+ expect(build("rspec 1")).to be_pending
+ expect(build("staging")).to be_manual
expect(pipeline.reload).to be_running
end
end
end
- it 'closes all todos about failed jobs for pipeline' do
+ it "closes all todos about failed jobs for pipeline" do
expect(MergeRequests::AddTodoWhenBuildFailsService)
.to receive_message_chain(:new, :close_all)
service.execute(pipeline)
end
- it 'reprocesses the pipeline' do
+ it "reprocesses the pipeline" do
expect(pipeline).to receive(:process!)
service.execute(pipeline)
end
end
- context 'when user is not allowed to retry pipeline' do
- it 'raises an error' do
+ context "when user is not allowed to retry pipeline" do
+ it "raises an error" do
expect { service.execute(pipeline) }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'when user is not allowed to trigger manual action' do
+ context "when user is not allowed to trigger manual action" do
before do
project.add_developer(user)
create(:protected_branch, :maintainers_can_push,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- context 'when there is a failed manual action present' do
+ context "when there is a failed manual action present" do
before do
- create_build('test', :failed, 0)
- create_build('deploy', :failed, 0, when: :manual)
- create_build('verify', :canceled, 1)
+ create_build("test", :failed, 0)
+ create_build("deploy", :failed, 0, when: :manual)
+ create_build("verify", :canceled, 1)
end
- it 'raises an error' do
+ it "raises an error" do
expect { service.execute(pipeline) }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'when there is a failed manual action in later stage' do
+ context "when there is a failed manual action in later stage" do
before do
- create_build('test', :failed, 0)
- create_build('deploy', :failed, 1, when: :manual)
- create_build('verify', :canceled, 2)
+ create_build("test", :failed, 0)
+ create_build("deploy", :failed, 1, when: :manual)
+ create_build("verify", :canceled, 2)
end
- it 'raises an error' do
+ it "raises an error" do
expect { service.execute(pipeline) }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
end
- context 'when maintainer is allowed to push to forked project' do
+ context "when maintainer is allowed to push to forked project" do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:forked_project) { fork_project(project) }
- let(:pipeline) { create(:ci_pipeline, project: forked_project, ref: 'fixes') }
+ let(:pipeline) { create(:ci_pipeline, project: forked_project, ref: "fixes") }
before do
project.add_maintainer(user)
create(:merge_request,
source_project: forked_project,
target_project: project,
- source_branch: 'fixes',
+ source_branch: "fixes",
allow_collaboration: true)
- create_build('rspec 1', :failed, 1)
+ create_build("rspec 1", :failed, 1)
end
- it 'allows to retry failed pipeline' do
+ it "allows to retry failed pipeline" do
allow_any_instance_of(Project).to receive(:branch_allows_collaboration?).and_return(true)
allow_any_instance_of(Project).to receive(:empty_repo?).and_return(false)
service.execute(pipeline)
- expect(build('rspec 1')).to be_pending
+ expect(build("rspec 1")).to be_pending
expect(pipeline.reload).to be_running
end
end
diff --git a/spec/services/ci/run_scheduled_build_service_spec.rb b/spec/services/ci/run_scheduled_build_service_spec.rb
index be2aad33ef4..c36f53804cf 100644
--- a/spec/services/ci/run_scheduled_build_service_spec.rb
+++ b/spec/services/ci/run_scheduled_build_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::RunScheduledBuildService do
let(:user) { create(:user) }
@@ -7,29 +7,29 @@ describe Ci::RunScheduledBuildService do
subject { described_class.new(project, user).execute(build) }
- context 'when user can update build' do
+ context "when user can update build" do
before do
project.add_developer(user)
create(:protected_branch, :developers_can_merge,
- name: pipeline.ref, project: project)
+ name: pipeline.ref, project: project)
end
- context 'when build is scheduled' do
- context 'when scheduled_at is expired' do
+ context "when build is scheduled" do
+ context "when scheduled_at is expired" do
let(:build) { create(:ci_build, :expired_scheduled, user: user, project: project, pipeline: pipeline) }
- it 'can run the build' do
+ it "can run the build" do
expect { subject }.not_to raise_error
expect(build).to be_pending
end
end
- context 'when scheduled_at is not expired' do
+ context "when scheduled_at is not expired" do
let(:build) { create(:ci_build, :scheduled, user: user, project: project, pipeline: pipeline) }
- it 'can not run the build' do
+ it "can not run the build" do
expect { subject }.to raise_error(StateMachines::InvalidTransition)
expect(build).to be_scheduled
@@ -37,10 +37,10 @@ describe Ci::RunScheduledBuildService do
end
end
- context 'when build is not scheduled' do
+ context "when build is not scheduled" do
let(:build) { create(:ci_build, :created, user: user, project: project, pipeline: pipeline) }
- it 'can not run the build' do
+ it "can not run the build" do
expect { subject }.to raise_error(StateMachines::InvalidTransition)
expect(build).to be_created
@@ -48,11 +48,11 @@ describe Ci::RunScheduledBuildService do
end
end
- context 'when user can not update build' do
- context 'when build is scheduled' do
+ context "when user can not update build" do
+ context "when build is scheduled" do
let(:build) { create(:ci_build, :scheduled, user: user, project: project, pipeline: pipeline) }
- it 'can not run the build' do
+ it "can not run the build" do
expect { subject }.to raise_error(Gitlab::Access::AccessDeniedError)
expect(build).to be_scheduled
diff --git a/spec/services/ci/stop_environments_service_spec.rb b/spec/services/ci/stop_environments_service_spec.rb
index cdd3d851f61..b0535c12b1e 100644
--- a/spec/services/ci/stop_environments_service_spec.rb
+++ b/spec/services/ci/stop_environments_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::StopEnvironmentsService do
let(:project) { create(:project, :private, :repository) }
@@ -6,98 +6,98 @@ describe Ci::StopEnvironmentsService do
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- context 'when environment with review app exists' do
+ describe "#execute" do
+ context "when environment with review app exists" do
before do
create(:environment, :with_review_app, project: project,
- ref: 'feature')
+ ref: "feature")
end
- context 'when user has permission to stop environment' do
+ context "when user has permission to stop environment" do
before do
project.add_developer(user)
end
- context 'when environment is associated with removed branch' do
- it 'stops environment' do
- expect_environment_stopped_on('feature')
+ context "when environment is associated with removed branch" do
+ it "stops environment" do
+ expect_environment_stopped_on("feature")
end
end
- context 'when environment is associated with different branch' do
- it 'does not stop environment' do
- expect_environment_not_stopped_on('master')
+ context "when environment is associated with different branch" do
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("master")
end
end
- context 'when specified branch does not exist' do
- it 'does not stop environment' do
- expect_environment_not_stopped_on('non/existent/branch')
+ context "when specified branch does not exist" do
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("non/existent/branch")
end
end
- context 'when no branch not specified' do
- it 'does not stop environment' do
+ context "when no branch not specified" do
+ it "does not stop environment" do
expect_environment_not_stopped_on(nil)
end
end
- context 'when environment is not stopped' do
+ context "when environment is not stopped" do
before do
allow_any_instance_of(Environment)
.to receive(:state).and_return(:stopped)
end
- it 'does not stop environment' do
- expect_environment_not_stopped_on('feature')
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("feature")
end
end
end
- context 'when user does not have permission to stop environment' do
- context 'when user has no access to manage deployments' do
+ context "when user does not have permission to stop environment" do
+ context "when user has no access to manage deployments" do
before do
project.add_guest(user)
end
- it 'does not stop environment' do
- expect_environment_not_stopped_on('master')
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("master")
end
end
end
- context 'when branch for stop action is protected' do
+ context "when branch for stop action is protected" do
before do
project.add_developer(user)
create(:protected_branch, :no_one_can_push,
- name: 'master', project: project)
+ name: "master", project: project)
end
- it 'does not stop environment' do
- expect_environment_not_stopped_on('master')
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("master")
end
end
end
- context 'when there is no environment associated with review app' do
+ context "when there is no environment associated with review app" do
before do
create(:environment, project: project)
end
- context 'when user has permission to stop environments' do
+ context "when user has permission to stop environments" do
before do
project.add_maintainer(user)
end
- it 'does not stop environment' do
- expect_environment_not_stopped_on('master')
+ it "does not stop environment" do
+ expect_environment_not_stopped_on("master")
end
end
end
- context 'when environment does not exist' do
- it 'does not raise error' do
- expect { service.execute('master') }
+ context "when environment does not exist" do
+ it "does not raise error" do
+ expect { service.execute("master") }
.not_to raise_error
end
end
diff --git a/spec/services/ci/update_build_queue_service_spec.rb b/spec/services/ci/update_build_queue_service_spec.rb
index ca0c6be5da6..509f9d37b60 100644
--- a/spec/services/ci/update_build_queue_service_spec.rb
+++ b/spec/services/ci/update_build_queue_service_spec.rb
@@ -1,86 +1,86 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::UpdateBuildQueueService do
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when updating specific runners' do
+ context "when updating specific runners" do
let(:runner) { create(:ci_runner, :project, projects: [project]) }
- context 'when there is a runner that can pick build' do
- it 'ticks runner queue value' do
+ context "when there is a runner that can pick build" do
+ it "ticks runner queue value" do
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
end
end
- context 'when there is no runner that can pick build' do
+ context "when there is no runner that can pick build" do
let(:another_project) { create(:project) }
let(:runner) { create(:ci_runner, :project, projects: [another_project]) }
- it 'does not tick runner queue value' do
+ it "does not tick runner queue value" do
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
end
end
end
- context 'when updating shared runners' do
+ context "when updating shared runners" do
let(:runner) { create(:ci_runner, :instance) }
- context 'when there is no runner that can pick build' do
- it 'ticks runner queue value' do
+ context "when there is no runner that can pick build" do
+ it "ticks runner queue value" do
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
end
end
- context 'when there is no runner that can pick build due to tag mismatch' do
+ context "when there is no runner that can pick build due to tag mismatch" do
before do
build.tag_list = [:docker]
end
- it 'does not tick runner queue value' do
+ it "does not tick runner queue value" do
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
end
end
- context 'when there is no runner that can pick build due to being disabled on project' do
+ context "when there is no runner that can pick build due to being disabled on project" do
before do
build.project.shared_runners_enabled = false
end
- it 'does not tick runner queue value' do
+ it "does not tick runner queue value" do
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
end
end
end
- context 'when updating group runners' do
+ context "when updating group runners" do
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:runner) { create(:ci_runner, :group, groups: [group]) }
- context 'when there is a runner that can pick build' do
- it 'ticks runner queue value' do
+ context "when there is a runner that can pick build" do
+ it "ticks runner queue value" do
expect { subject.execute(build) }.to change { runner.ensure_runner_queue_value }
end
end
- context 'when there is no runner that can pick build due to tag mismatch' do
+ context "when there is no runner that can pick build due to tag mismatch" do
before do
build.tag_list = [:docker]
end
- it 'does not tick runner queue value' do
+ it "does not tick runner queue value" do
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
end
end
- context 'when there is no runner that can pick build due to being disabled on project' do
+ context "when there is no runner that can pick build due to being disabled on project" do
before do
build.project.group_runners_enabled = false
end
- it 'does not tick runner queue value' do
+ it "does not tick runner queue value" do
expect { subject.execute(build) }.not_to change { runner.ensure_runner_queue_value }
end
end
diff --git a/spec/services/ci/update_runner_service_spec.rb b/spec/services/ci/update_runner_service_spec.rb
index 7cc04c92d27..54928bc92b6 100644
--- a/spec/services/ci/update_runner_service_spec.rb
+++ b/spec/services/ci/update_runner_service_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::UpdateRunnerService do
let(:runner) { create(:ci_runner) }
- describe '#update' do
+ describe "#update" do
before do
allow(runner).to receive(:tick_runner_queue)
end
- context 'with description params' do
- let(:params) { { description: 'new runner' } }
+ context "with description params" do
+ let(:params) { {description: "new runner"} }
- it 'updates the runner and ticking the queue' do
+ it "updates the runner and ticking the queue" do
expect(update).to be_truthy
runner.reload
expect(runner).to have_received(:tick_runner_queue)
- expect(runner.description).to eq('new runner')
+ expect(runner.description).to eq("new runner")
end
end
- context 'when params are not valid' do
- let(:params) { { run_untagged: false } }
+ context "when params are not valid" do
+ let(:params) { {run_untagged: false} }
- it 'does not update and give false because it is not valid' do
+ it "does not update and give false because it is not valid" do
expect(update).to be_falsey
runner.reload
diff --git a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
index f3036fbcb0e..483eeabbb8d 100644
--- a/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
+++ b/spec/services/clusters/applications/check_ingress_ip_address_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Applications::CheckIngressIpAddressService do
include ExclusiveLeaseHelpers
@@ -6,17 +6,17 @@ describe Clusters::Applications::CheckIngressIpAddressService do
let(:application) { create(:clusters_applications_ingress, :installed) }
let(:service) { described_class.new(application) }
let(:kubeclient) { double(::Kubeclient::Client, get_service: kube_service) }
- let(:ingress) { [{ ip: '111.222.111.222' }] }
+ let(:ingress) { [{ip: "111.222.111.222"}] }
let(:lease_key) { "check_ingress_ip_address_service:#{application.id}" }
let(:kube_service) do
::Kubeclient::Resource.new(
{
- status: {
- loadBalancer: {
- ingress: ingress
- }
- }
+ status: {
+ loadBalancer: {
+ ingress: ingress,
+ },
+ },
}
)
end
@@ -28,7 +28,7 @@ describe Clusters::Applications::CheckIngressIpAddressService do
allow(application.cluster).to receive(:kubeclient).and_return(kubeclient)
end
- include_examples 'check ingress ip executions', :clusters_applications_ingress
+ include_examples "check ingress ip executions", :clusters_applications_ingress
- include_examples 'check ingress ip executions', :clusters_applications_knative
+ include_examples "check ingress ip executions", :clusters_applications_knative
end
diff --git a/spec/services/clusters/applications/check_installation_progress_service_spec.rb b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
index 19446ce1cf8..c8b0aec7574 100644
--- a/spec/services/clusters/applications/check_installation_progress_service_spec.rb
+++ b/spec/services/clusters/applications/check_installation_progress_service_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
+describe Clusters::Applications::CheckInstallationProgressService, "#execute" do
RESCHEDULE_PHASES = Gitlab::Kubernetes::Pod::PHASES - [Gitlab::Kubernetes::Pod::SUCCEEDED, Gitlab::Kubernetes::Pod::FAILED].freeze
let(:application) { create(:clusters_applications_helm, :installing) }
@@ -8,7 +8,7 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
let(:phase) { Gitlab::Kubernetes::Pod::UNKNOWN }
let(:errors) { nil }
- shared_examples 'a not yet terminated installation' do |a_phase|
+ shared_examples "a not yet terminated installation" do |a_phase|
let(:phase) { a_phase }
before do
@@ -16,16 +16,16 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
end
context "when phase is #{a_phase}" do
- context 'when not timeouted' do
- it 'reschedule a new check' do
+ context "when not timeouted" do
+ it "reschedule a new check" do
expect(ClusterWaitForAppInstallationWorker).to receive(:perform_in).once
expect(service).not_to receive(:remove_installation_pod)
- expect do
+ expect {
service.execute
application.reload
- end.not_to change(application, :status)
+ }.not_to change(application, :status)
expect(application.status_reason).to be_nil
end
@@ -33,24 +33,24 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
end
end
- shared_examples 'error logging' do
- context 'when installation raises a Kubeclient::HttpError' do
+ shared_examples "error logging" do
+ context "when installation raises a Kubeclient::HttpError" do
let(:cluster) { create(:cluster, :provided_by_user, :project) }
before do
application.update!(cluster: cluster)
- expect(service).to receive(:installation_phase).and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
+ expect(service).to receive(:installation_phase).and_raise(Kubeclient::HttpError.new(401, "Unauthorized", nil))
end
- it 'shows the response code from the error' do
+ it "shows the response code from the error" do
service.execute
expect(application).to be_errored.or(be_update_errored)
- expect(application.status_reason).to eq('Kubernetes error: 401')
+ expect(application.status_reason).to eq("Kubernetes error: 401")
end
- it 'should log error' do
+ it "should log error" do
expect(service.send(:logger)).to receive(:error)
service.execute
@@ -63,26 +63,26 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
allow(service).to receive(:remove_installation_pod).and_return(nil)
end
- context 'when application is updating' do
+ context "when application is updating" do
let(:application) { create(:clusters_applications_helm, :updating) }
- include_examples 'error logging'
+ include_examples "error logging"
- RESCHEDULE_PHASES.each { |phase| it_behaves_like 'a not yet terminated installation', phase }
+ RESCHEDULE_PHASES.each { |phase| it_behaves_like "a not yet terminated installation", phase }
- context 'when installation POD succeeded' do
+ context "when installation POD succeeded" do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'removes the installation POD' do
+ it "removes the installation POD" do
expect(service).to receive(:remove_installation_pod).once
service.execute
end
- it 'make the application installed' do
+ it "make the application installed" do
expect(ClusterWaitForAppInstallationWorker).not_to receive(:perform_in)
service.execute
@@ -92,58 +92,58 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
end
end
- context 'when installation POD failed' do
+ context "when installation POD failed" do
let(:phase) { Gitlab::Kubernetes::Pod::FAILED }
- let(:errors) { 'test installation failed' }
+ let(:errors) { "test installation failed" }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'make the application errored' do
+ it "make the application errored" do
service.execute
expect(application).to be_update_errored
- expect(application.status_reason).to eq('Operation failed. Check pod logs for install-helm for more details.')
+ expect(application.status_reason).to eq("Operation failed. Check pod logs for install-helm for more details.")
end
end
- context 'when timed out' do
+ context "when timed out" do
let(:application) { create(:clusters_applications_helm, :timeouted, :updating) }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'make the application errored' do
+ it "make the application errored" do
expect(ClusterWaitForAppInstallationWorker).not_to receive(:perform_in)
service.execute
expect(application).to be_update_errored
- expect(application.status_reason).to eq('Operation timed out. Check pod logs for install-helm for more details.')
+ expect(application.status_reason).to eq("Operation timed out. Check pod logs for install-helm for more details.")
end
end
end
- context 'when application is installing' do
- include_examples 'error logging'
+ context "when application is installing" do
+ include_examples "error logging"
- RESCHEDULE_PHASES.each { |phase| it_behaves_like 'a not yet terminated installation', phase }
+ RESCHEDULE_PHASES.each { |phase| it_behaves_like "a not yet terminated installation", phase }
- context 'when installation POD succeeded' do
+ context "when installation POD succeeded" do
let(:phase) { Gitlab::Kubernetes::Pod::SUCCEEDED }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'removes the installation POD' do
+ it "removes the installation POD" do
expect(service).to receive(:remove_installation_pod).once
service.execute
end
- it 'make the application installed' do
+ it "make the application installed" do
expect(ClusterWaitForAppInstallationWorker).not_to receive(:perform_in)
service.execute
@@ -153,36 +153,36 @@ describe Clusters::Applications::CheckInstallationProgressService, '#execute' do
end
end
- context 'when installation POD failed' do
+ context "when installation POD failed" do
let(:phase) { Gitlab::Kubernetes::Pod::FAILED }
- let(:errors) { 'test installation failed' }
+ let(:errors) { "test installation failed" }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'make the application errored' do
+ it "make the application errored" do
service.execute
expect(application).to be_errored
- expect(application.status_reason).to eq('Operation failed. Check pod logs for install-helm for more details.')
+ expect(application.status_reason).to eq("Operation failed. Check pod logs for install-helm for more details.")
end
end
- context 'when timed out' do
+ context "when timed out" do
let(:application) { create(:clusters_applications_helm, :timeouted) }
before do
expect(service).to receive(:installation_phase).once.and_return(phase)
end
- it 'make the application errored' do
+ it "make the application errored" do
expect(ClusterWaitForAppInstallationWorker).not_to receive(:perform_in)
service.execute
expect(application).to be_errored
- expect(application.status_reason).to eq('Operation timed out. Check pod logs for install-helm for more details.')
+ expect(application.status_reason).to eq("Operation timed out. Check pod logs for install-helm for more details.")
end
end
end
diff --git a/spec/services/clusters/applications/create_service_spec.rb b/spec/services/clusters/applications/create_service_spec.rb
index cbdef008b07..7bcd0c80fcd 100644
--- a/spec/services/clusters/applications/create_service_spec.rb
+++ b/spec/services/clusters/applications/create_service_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Applications::CreateService do
include TestRequestHelpers
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:user) { create(:user) }
- let(:params) { { application: 'helm' } }
+ let(:params) { {application: "helm"} }
let(:service) { described_class.new(cluster, user, params) }
- describe '#execute' do
+ describe "#execute" do
before do
allow(ClusterInstallAppWorker).to receive(:perform_async)
allow(ClusterUpgradeAppWorker).to receive(:perform_async)
@@ -18,40 +18,40 @@ describe Clusters::Applications::CreateService do
subject { service.execute(test_request) }
- it 'creates an application' do
- expect do
+ it "creates an application" do
+ expect {
subject
cluster.reload
- end.to change(cluster, :application_helm)
+ }.to change(cluster, :application_helm)
end
- context 'application already installed' do
+ context "application already installed" do
let!(:application) { create(:clusters_applications_helm, :installed, cluster: cluster) }
- it 'does not create a new application' do
- expect do
+ it "does not create a new application" do
+ expect {
subject
- end.not_to change(Clusters::Applications::Helm, :count)
+ }.not_to change(Clusters::Applications::Helm, :count)
end
- it 'schedules an upgrade for the application' do
+ it "schedules an upgrade for the application" do
expect(ClusterUpgradeAppWorker).to receive(:perform_async)
subject
end
end
- context 'known applications' do
+ context "known applications" do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
- context 'cert manager application' do
+ context "cert manager application" do
let(:params) do
{
- application: 'cert_manager',
- email: 'test@example.com'
+ application: "cert_manager",
+ email: "test@example.com",
}
end
@@ -61,24 +61,24 @@ describe Clusters::Applications::CreateService do
.and_call_original
end
- it 'creates the application' do
- expect do
+ it "creates the application" do
+ expect {
subject
cluster.reload
- end.to change(cluster, :application_cert_manager)
+ }.to change(cluster, :application_cert_manager)
end
- it 'sets the email' do
- expect(subject.email).to eq('test@example.com')
+ it "sets the email" do
+ expect(subject.email).to eq("test@example.com")
end
end
- context 'jupyter application' do
+ context "jupyter application" do
let(:params) do
{
- application: 'jupyter',
- hostname: 'example.com'
+ application: "jupyter",
+ hostname: "example.com",
}
end
@@ -89,28 +89,28 @@ describe Clusters::Applications::CreateService do
.and_call_original
end
- it 'creates the application' do
- expect do
+ it "creates the application" do
+ expect {
subject
cluster.reload
- end.to change(cluster, :application_jupyter)
+ }.to change(cluster, :application_jupyter)
end
- it 'sets the hostname' do
- expect(subject.hostname).to eq('example.com')
+ it "sets the hostname" do
+ expect(subject.hostname).to eq("example.com")
end
- it 'sets the oauth_application' do
+ it "sets the oauth_application" do
expect(subject.oauth_application).to be_present
end
end
- context 'knative application' do
+ context "knative application" do
let(:params) do
{
- application: 'knative',
- hostname: 'example.com'
+ application: "knative",
+ hostname: "example.com",
}
end
@@ -120,39 +120,39 @@ describe Clusters::Applications::CreateService do
.and_call_original
end
- it 'creates the application' do
- expect do
+ it "creates the application" do
+ expect {
subject
cluster.reload
- end.to change(cluster, :application_knative)
+ }.to change(cluster, :application_knative)
end
- it 'sets the hostname' do
- expect(subject.hostname).to eq('example.com')
+ it "sets the hostname" do
+ expect(subject.hostname).to eq("example.com")
end
end
end
- context 'invalid application' do
- let(:params) { { application: 'non-existent' } }
+ context "invalid application" do
+ let(:params) { {application: "non-existent"} }
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError)
end
end
- context 'group cluster' do
+ context "group cluster" do
let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
using RSpec::Parameterized::TableSyntax
where(:application, :association, :allowed, :pre_create_helm) do
- 'helm' | :application_helm | true | false
- 'ingress' | :application_ingress | true | true
- 'runner' | :application_runner | false | true
- 'jupyter' | :application_jupyter | false | true
- 'prometheus' | :application_prometheus | false | true
+ "helm" | :application_helm | true | false
+ "ingress" | :application_ingress | true | true
+ "runner" | :application_runner | false | true
+ "jupyter" | :application_jupyter | false | true
+ "prometheus" | :application_prometheus | false | true
end
with_them do
@@ -162,15 +162,15 @@ describe Clusters::Applications::CreateService do
create(:clusters_applications_helm, :installed, cluster: cluster) if pre_create_helm
end
- let(:params) { { application: application } }
+ let(:params) { {application: application} }
- it 'executes for each application' do
+ it "executes for each application" do
if allowed
- expect do
+ expect {
subject
cluster.reload
- end.to change(cluster, association)
+ }.to change(cluster, association)
else
expect { subject }.to raise_error(Clusters::Applications::CreateService::InvalidApplicationError)
end
@@ -178,15 +178,15 @@ describe Clusters::Applications::CreateService do
end
end
- context 'when application is installable' do
- shared_examples 'installable applications' do
- it 'makes the application scheduled' do
- expect do
+ context "when application is installable" do
+ shared_examples "installable applications" do
+ it "makes the application scheduled" do
+ expect {
subject
- end.to change { Clusters::Applications::Helm.with_status(:scheduled).count }.by(1)
+ }.to change { Clusters::Applications::Helm.with_status(:scheduled).count }.by(1)
end
- it 'schedules an install via worker' do
+ it "schedules an install via worker" do
expect(ClusterInstallAppWorker)
.to receive(:perform_async)
.with(*worker_arguments)
@@ -196,39 +196,39 @@ describe Clusters::Applications::CreateService do
end
end
- context 'when application is associated with a cluster' do
+ context "when application is associated with a cluster" do
let(:application) { create(:clusters_applications_helm, :installable, cluster: cluster) }
let(:worker_arguments) { [application.name, application.id] }
- it_behaves_like 'installable applications'
+ it_behaves_like "installable applications"
end
- context 'when application is not associated with a cluster' do
+ context "when application is not associated with a cluster" do
let(:worker_arguments) { [params[:application], kind_of(Numeric)] }
- it_behaves_like 'installable applications'
+ it_behaves_like "installable applications"
end
end
- context 'when installation is already in progress' do
+ context "when installation is already in progress" do
let!(:application) { create(:clusters_applications_helm, :installing, cluster: cluster) }
- it 'raises an exception' do
+ it "raises an exception" do
expect { subject }
.to raise_exception(StateMachines::InvalidTransition)
.and not_change(application.class.with_status(:scheduled), :count)
end
- it 'does not schedule a cluster worker' do
+ it "does not schedule a cluster worker" do
expect(ClusterInstallAppWorker).not_to receive(:perform_async)
end
end
- context 'when application is installed' do
- %i(installed updated).each do |status|
+ context "when application is installed" do
+ %i[installed updated].each do |status|
let(:application) { create(:clusters_applications_helm, status, cluster: cluster) }
- it 'schedules an upgrade via worker' do
+ it "schedules an upgrade via worker" do
expect(ClusterUpgradeAppWorker)
.to receive(:perform_async)
.with(application.name, application.id)
diff --git a/spec/services/clusters/applications/install_service_spec.rb b/spec/services/clusters/applications/install_service_spec.rb
index 018d9822d3e..a5dd74065ed 100644
--- a/spec/services/clusters/applications/install_service_spec.rb
+++ b/spec/services/clusters/applications/install_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Applications::InstallService do
- describe '#execute' do
+ describe "#execute" do
let(:application) { create(:clusters_applications_helm, :scheduled) }
let!(:install_command) { application.install_command }
let(:service) { described_class.new(application) }
@@ -12,63 +12,63 @@ describe Clusters::Applications::InstallService do
allow(service).to receive(:helm_api).and_return(helm_client)
end
- context 'when there are no errors' do
+ context "when there are no errors" do
before do
expect(helm_client).to receive(:install).with(install_command)
allow(ClusterWaitForAppInstallationWorker).to receive(:perform_in).and_return(nil)
end
- it 'make the application installing' do
+ it "make the application installing" do
expect(application.cluster).not_to be_nil
service.execute
expect(application).to be_installing
end
- it 'schedule async installation status check' do
+ it "schedule async installation status check" do
expect(ClusterWaitForAppInstallationWorker).to receive(:perform_in).once
service.execute
end
end
- context 'when k8s cluster communication fails' do
- let(:error) { Kubeclient::HttpError.new(500, 'system failure', nil) }
+ context "when k8s cluster communication fails" do
+ let(:error) { Kubeclient::HttpError.new(500, "system failure", nil) }
before do
expect(helm_client).to receive(:install).with(install_command).and_raise(error)
end
- it 'make the application errored' do
+ it "make the application errored" do
service.execute
expect(application).to be_errored
- expect(application.status_reason).to match('Kubernetes error: 500')
+ expect(application.status_reason).to match("Kubernetes error: 500")
end
- it 'logs errors' do
+ it "logs errors" do
expect(service.send(:logger)).to receive(:error).with(
{
- exception: 'Kubeclient::HttpError',
- message: 'system failure',
- service: 'Clusters::Applications::InstallService',
+ exception: "Kubeclient::HttpError",
+ message: "system failure",
+ service: "Clusters::Applications::InstallService",
app_id: application.id,
project_ids: application.cluster.project_ids,
group_ids: [],
- error_code: 500
+ error_code: 500,
}
)
expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
error,
extra: {
- exception: 'Kubeclient::HttpError',
- message: 'system failure',
- service: 'Clusters::Applications::InstallService',
+ exception: "Kubeclient::HttpError",
+ message: "system failure",
+ service: "Clusters::Applications::InstallService",
app_id: application.id,
project_ids: application.cluster.project_ids,
group_ids: [],
- error_code: 500
+ error_code: 500,
}
)
@@ -76,7 +76,7 @@ describe Clusters::Applications::InstallService do
end
end
- context 'a non kubernetes error happens' do
+ context "a non kubernetes error happens" do
let(:application) { create(:clusters_applications_helm, :scheduled) }
let(:error) { StandardError.new("something bad happened") }
@@ -84,7 +84,7 @@ describe Clusters::Applications::InstallService do
expect(application).to receive(:make_installing!).once.and_raise(error)
end
- it 'make the application errored' do
+ it "make the application errored" do
expect(helm_client).not_to receive(:install)
service.execute
@@ -93,29 +93,29 @@ describe Clusters::Applications::InstallService do
expect(application.status_reason).to eq("Can't start installation process.")
end
- it 'logs errors' do
+ it "logs errors" do
expect(service.send(:logger)).to receive(:error).with(
{
- exception: 'StandardError',
+ exception: "StandardError",
error_code: nil,
- message: 'something bad happened',
- service: 'Clusters::Applications::InstallService',
+ message: "something bad happened",
+ service: "Clusters::Applications::InstallService",
app_id: application.id,
project_ids: application.cluster.projects.pluck(:id),
- group_ids: []
+ group_ids: [],
}
)
expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
error,
extra: {
- exception: 'StandardError',
+ exception: "StandardError",
error_code: nil,
- message: 'something bad happened',
- service: 'Clusters::Applications::InstallService',
+ message: "something bad happened",
+ service: "Clusters::Applications::InstallService",
app_id: application.id,
project_ids: application.cluster.projects.pluck(:id),
- group_ids: []
+ group_ids: [],
}
)
diff --git a/spec/services/clusters/applications/upgrade_service_spec.rb b/spec/services/clusters/applications/upgrade_service_spec.rb
index 1822fc38dbd..b078d7f4631 100644
--- a/spec/services/clusters/applications/upgrade_service_spec.rb
+++ b/spec/services/clusters/applications/upgrade_service_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Applications::UpgradeService do
- describe '#execute' do
+ describe "#execute" do
let(:application) { create(:clusters_applications_helm, :scheduled) }
let!(:install_command) { application.install_command }
let(:service) { described_class.new(application) }
@@ -14,63 +14,63 @@ describe Clusters::Applications::UpgradeService do
allow(service).to receive(:helm_api).and_return(helm_client)
end
- context 'when there are no errors' do
+ context "when there are no errors" do
before do
expect(helm_client).to receive(:update).with(install_command)
allow(ClusterWaitForAppInstallationWorker).to receive(:perform_in).and_return(nil)
end
- it 'make the application updating' do
+ it "make the application updating" do
expect(application.cluster).not_to be_nil
service.execute
expect(application).to be_updating
end
- it 'schedule async installation status check' do
+ it "schedule async installation status check" do
expect(ClusterWaitForAppInstallationWorker).to receive(:perform_in).once
service.execute
end
end
- context 'when kubernetes cluster communication fails' do
- let(:error) { Kubeclient::HttpError.new(500, 'system failure', nil) }
+ context "when kubernetes cluster communication fails" do
+ let(:error) { Kubeclient::HttpError.new(500, "system failure", nil) }
before do
expect(helm_client).to receive(:update).with(install_command).and_raise(error)
end
- it 'make the application errored' do
+ it "make the application errored" do
service.execute
expect(application).to be_update_errored
- expect(application.status_reason).to match('Kubernetes error: 500')
+ expect(application.status_reason).to match("Kubernetes error: 500")
end
- it 'logs errors' do
+ it "logs errors" do
expect(service.send(:logger)).to receive(:error).with(
{
- exception: 'Kubeclient::HttpError',
- message: 'system failure',
- service: 'Clusters::Applications::UpgradeService',
+ exception: "Kubeclient::HttpError",
+ message: "system failure",
+ service: "Clusters::Applications::UpgradeService",
app_id: application.id,
project_ids: application.cluster.project_ids,
group_ids: [],
- error_code: 500
+ error_code: 500,
}
)
expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
error,
extra: {
- exception: 'Kubeclient::HttpError',
- message: 'system failure',
- service: 'Clusters::Applications::UpgradeService',
+ exception: "Kubeclient::HttpError",
+ message: "system failure",
+ service: "Clusters::Applications::UpgradeService",
app_id: application.id,
project_ids: application.cluster.project_ids,
group_ids: [],
- error_code: 500
+ error_code: 500,
}
)
@@ -78,15 +78,15 @@ describe Clusters::Applications::UpgradeService do
end
end
- context 'a non kubernetes error happens' do
+ context "a non kubernetes error happens" do
let(:application) { create(:clusters_applications_helm, :scheduled) }
- let(:error) { StandardError.new('something bad happened') }
+ let(:error) { StandardError.new("something bad happened") }
before do
expect(application).to receive(:make_updating!).once.and_raise(error)
end
- it 'make the application errored' do
+ it "make the application errored" do
expect(helm_client).not_to receive(:update)
service.execute
@@ -95,29 +95,29 @@ describe Clusters::Applications::UpgradeService do
expect(application.status_reason).to eq("Can't start upgrade process.")
end
- it 'logs errors' do
+ it "logs errors" do
expect(service.send(:logger)).to receive(:error).with(
{
- exception: 'StandardError',
+ exception: "StandardError",
error_code: nil,
- message: 'something bad happened',
- service: 'Clusters::Applications::UpgradeService',
+ message: "something bad happened",
+ service: "Clusters::Applications::UpgradeService",
app_id: application.id,
project_ids: application.cluster.projects.pluck(:id),
- group_ids: []
+ group_ids: [],
}
)
expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
error,
extra: {
- exception: 'StandardError',
+ exception: "StandardError",
error_code: nil,
- message: 'something bad happened',
- service: 'Clusters::Applications::UpgradeService',
+ message: "something bad happened",
+ service: "Clusters::Applications::UpgradeService",
app_id: application.id,
project_ids: application.cluster.projects.pluck(:id),
- group_ids: []
+ group_ids: [],
}
)
diff --git a/spec/services/clusters/build_service_spec.rb b/spec/services/clusters/build_service_spec.rb
index da0cb42b3a1..21765a4cd7d 100644
--- a/spec/services/clusters/build_service_spec.rb
+++ b/spec/services/clusters/build_service_spec.rb
@@ -1,23 +1,23 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::BuildService do
- describe '#execute' do
+ describe "#execute" do
subject { described_class.new(cluster_subject).execute }
- describe 'when cluster subject is a project' do
+ describe "when cluster subject is a project" do
let(:cluster_subject) { build(:project) }
- it 'sets the cluster_type to project_type' do
+ it "sets the cluster_type to project_type" do
is_expected.to be_project_type
end
end
- describe 'when cluster subject is a group' do
+ describe "when cluster subject is a group" do
let(:cluster_subject) { build(:group) }
- it 'sets the cluster_type to group_type' do
+ it "sets the cluster_type to group_type" do
is_expected.to be_group_type
end
end
diff --git a/spec/services/clusters/create_service_spec.rb b/spec/services/clusters/create_service_spec.rb
index 274880f2c49..f9433341f3e 100644
--- a/spec/services/clusters/create_service_spec.rb
+++ b/spec/services/clusters/create_service_spec.rb
@@ -1,57 +1,57 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::CreateService do
- let(:access_token) { 'xxx' }
+ let(:access_token) { "xxx" }
let(:project) { create(:project) }
let(:user) { create(:user) }
subject { described_class.new(user, params).execute(access_token: access_token) }
- context 'when provider is gcp' do
- context 'when project has no clusters' do
- context 'when correct params' do
+ context "when provider is gcp" do
+ context "when project has no clusters" do
+ context "when correct params" do
let(:params) do
{
- name: 'test-cluster',
+ name: "test-cluster",
provider_type: :gcp,
provider_gcp_attributes: {
- gcp_project_id: 'gcp-project',
- zone: 'us-central1-a',
+ gcp_project_id: "gcp-project",
+ zone: "us-central1-a",
num_nodes: 1,
- machine_type: 'machine_type-a',
- legacy_abac: 'true'
+ machine_type: "machine_type-a",
+ legacy_abac: "true",
},
- clusterable: project
+ clusterable: project,
}
end
- include_examples 'create cluster service success'
+ include_examples "create cluster service success"
end
- context 'when invalid params' do
+ context "when invalid params" do
let(:params) do
{
- name: 'test-cluster',
+ name: "test-cluster",
provider_type: :gcp,
provider_gcp_attributes: {
- gcp_project_id: '!!!!!!!',
- zone: 'us-central1-a',
+ gcp_project_id: "!!!!!!!",
+ zone: "us-central1-a",
num_nodes: 1,
- machine_type: 'machine_type-a'
+ machine_type: "machine_type-a",
},
- clusterable: project
+ clusterable: project,
}
end
- include_examples 'create cluster service error'
+ include_examples "create cluster service error"
end
end
- context 'when project has a cluster' do
- include_context 'valid cluster create params'
+ context "when project has a cluster" do
+ include_context "valid cluster create params"
let!(:cluster) { create(:cluster, :provided_by_gcp, :production_environment, projects: [project]) }
- it 'does not create a cluster' do
+ it "does not create a cluster" do
expect(ClusterProvisionWorker).not_to receive(:perform_async)
expect { subject }.to raise_error(ArgumentError).and change { Clusters::Cluster.count }.by(0)
end
diff --git a/spec/services/clusters/gcp/fetch_operation_service_spec.rb b/spec/services/clusters/gcp/fetch_operation_service_spec.rb
index 55f123ee786..074d04f802e 100644
--- a/spec/services/clusters/gcp/fetch_operation_service_spec.rb
+++ b/spec/services/clusters/gcp/fetch_operation_service_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Gcp::FetchOperationService do
include GoogleApi::CloudPlatformHelpers
- describe '#execute' do
+ describe "#execute" do
let(:provider) { create(:cluster_provider_gcp, :creating) }
let(:gcp_project_id) { provider.gcp_project_id }
let(:zone) { provider.zone }
let(:operation_id) { provider.operation_id }
- shared_examples 'success' do
- it 'yields' do
+ shared_examples "success" do
+ it "yields" do
expect { |b| described_class.new.execute(provider, &b) }
.to yield_with_args
end
end
- shared_examples 'error' do
- it 'sets an error to provider object' do
+ shared_examples "error" do
+ it "sets an error to provider object" do
expect { |b| described_class.new.execute(provider, &b) }
.not_to yield_with_args
expect(provider.reload).to be_errored
end
end
- context 'when succeeded to fetch operation' do
+ context "when succeeded to fetch operation" do
before do
stub_cloud_platform_get_zone_operation(gcp_project_id, zone, operation_id)
end
- it_behaves_like 'success'
+ it_behaves_like "success"
end
- context 'when Internal Server Error happened' do
+ context "when Internal Server Error happened" do
before do
stub_cloud_platform_get_zone_operation_error(gcp_project_id, zone, operation_id)
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
end
end
diff --git a/spec/services/clusters/gcp/finalize_creation_service_spec.rb b/spec/services/clusters/gcp/finalize_creation_service_spec.rb
index 2664649df47..6268d45f149 100644
--- a/spec/services/clusters/gcp/finalize_creation_service_spec.rb
+++ b/spec/services/clusters/gcp/finalize_creation_service_spec.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe Clusters::Gcp::FinalizeCreationService, '#execute' do
+describe Clusters::Gcp::FinalizeCreationService, "#execute" do
include GoogleApi::CloudPlatformHelpers
include KubernetesHelpers
let(:cluster) { create(:cluster, :project, :providing_by_gcp) }
let(:provider) { cluster.provider }
let(:platform) { cluster.platform }
- let(:endpoint) { '111.111.111.111' }
- let(:api_url) { 'https://' + endpoint }
- let(:username) { 'sample-username' }
- let(:password) { 'sample-password' }
- let(:secret_name) { 'gitlab-token' }
- let(:token) { 'sample-token' }
+ let(:endpoint) { "111.111.111.111" }
+ let(:api_url) { "https://" + endpoint }
+ let(:username) { "sample-username" }
+ let(:password) { "sample-password" }
+ let(:secret_name) { "gitlab-token" }
+ let(:token) { "sample-token" }
let(:namespace) { "#{cluster.project.path}-#{cluster.project.id}" }
subject { described_class.new.execute(provider) }
@@ -23,14 +23,14 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
allow(ClusterConfigureWorker).to receive(:perform_async)
end
- shared_examples 'success' do
- it 'configures provider and kubernetes' do
+ shared_examples "success" do
+ it "configures provider and kubernetes" do
subject
expect(provider).to be_created
end
- it 'properly configures database models' do
+ it "properly configures database models" do
subject
cluster.reload
@@ -43,123 +43,123 @@ describe Clusters::Gcp::FinalizeCreationService, '#execute' do
expect(platform.token).to eq(token)
end
- it 'calls ClusterConfigureWorker in a ascync fashion' do
+ it "calls ClusterConfigureWorker in a ascync fashion" do
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
subject
end
end
- shared_examples 'error' do
- it 'sets an error to provider object' do
+ shared_examples "error" do
+ it "sets an error to provider object" do
subject
expect(provider.reload).to be_errored
end
end
- shared_examples 'kubernetes information not successfully fetched' do
- context 'when failed to fetch gke cluster info' do
+ shared_examples "kubernetes information not successfully fetched" do
+ context "when failed to fetch gke cluster info" do
before do
stub_cloud_platform_get_zone_cluster_error(provider.gcp_project_id, provider.zone, cluster.name)
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when token is empty' do
- let(:token) { '' }
+ context "when token is empty" do
+ let(:token) { "" }
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when failed to fetch kubernetes token' do
+ context "when failed to fetch kubernetes token" do
before do
- stub_kubeclient_get_secret_error(api_url, secret_name, namespace: 'default')
+ stub_kubeclient_get_secret_error(api_url, secret_name, namespace: "default")
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when service account fails to create' do
+ context "when service account fails to create" do
before do
- stub_kubeclient_create_service_account_error(api_url, namespace: 'default')
+ stub_kubeclient_create_service_account_error(api_url, namespace: "default")
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
end
- shared_context 'kubernetes information successfully fetched' do
+ shared_context "kubernetes information successfully fetched" do
before do
stub_cloud_platform_get_zone_cluster(
provider.gcp_project_id, provider.zone, cluster.name,
{
endpoint: endpoint,
username: username,
- password: password
+ password: password,
}
)
stub_kubeclient_discover(api_url)
stub_kubeclient_get_namespace(api_url)
stub_kubeclient_create_namespace(api_url)
- stub_kubeclient_get_service_account_error(api_url, 'gitlab')
+ stub_kubeclient_get_service_account_error(api_url, "gitlab")
stub_kubeclient_create_service_account(api_url)
stub_kubeclient_create_secret(api_url)
- stub_kubeclient_put_secret(api_url, 'gitlab-token')
+ stub_kubeclient_put_secret(api_url, "gitlab-token")
stub_kubeclient_get_secret(
api_url,
{
metadata_name: secret_name,
token: Base64.encode64(token),
- namespace: 'default'
+ namespace: "default",
}
)
end
end
- context 'With a legacy ABAC cluster' do
+ context "With a legacy ABAC cluster" do
before do
provider.legacy_abac = true
end
- include_context 'kubernetes information successfully fetched'
+ include_context "kubernetes information successfully fetched"
- it_behaves_like 'success'
+ it_behaves_like "success"
- it 'uses ABAC authorization type' do
+ it "uses ABAC authorization type" do
subject
cluster.reload
expect(platform).to be_abac
- expect(platform.authorization_type).to eq('abac')
+ expect(platform.authorization_type).to eq("abac")
end
- it_behaves_like 'kubernetes information not successfully fetched'
+ it_behaves_like "kubernetes information not successfully fetched"
end
- context 'With an RBAC cluster' do
+ context "With an RBAC cluster" do
before do
provider.legacy_abac = false
- stub_kubeclient_get_cluster_role_binding_error(api_url, 'gitlab-admin')
+ stub_kubeclient_get_cluster_role_binding_error(api_url, "gitlab-admin")
stub_kubeclient_create_cluster_role_binding(api_url)
end
- include_context 'kubernetes information successfully fetched'
+ include_context "kubernetes information successfully fetched"
- it_behaves_like 'success'
+ it_behaves_like "success"
- it 'uses RBAC authorization type' do
+ it "uses RBAC authorization type" do
subject
cluster.reload
expect(platform).to be_rbac
- expect(platform.authorization_type).to eq('rbac')
+ expect(platform.authorization_type).to eq("rbac")
end
- it_behaves_like 'kubernetes information not successfully fetched'
+ it_behaves_like "kubernetes information not successfully fetched"
end
end
diff --git a/spec/services/clusters/gcp/kubernetes/create_or_update_namespace_service_spec.rb b/spec/services/clusters/gcp/kubernetes/create_or_update_namespace_service_spec.rb
index 18f218fc236..45ce2c088ad 100644
--- a/spec/services/clusters/gcp/kubernetes/create_or_update_namespace_service_spec.rb
+++ b/spec/services/clusters/gcp/kubernetes/create_or_update_namespace_service_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService, '#execute' do
+describe Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService, "#execute" do
include KubernetesHelpers
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:platform) { cluster.platform }
- let(:api_url) { 'https://kubernetes.example.com' }
+ let(:api_url) { "https://kubernetes.example.com" }
let(:project) { cluster.project }
let(:cluster_project) { cluster.cluster_project }
let(:namespace) { "#{project.path}-#{project.id}" }
@@ -22,9 +22,9 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService, '#execute' d
before do
stub_kubeclient_discover(api_url)
stub_kubeclient_get_namespace(api_url)
- stub_kubeclient_get_service_account_error(api_url, 'gitlab')
+ stub_kubeclient_get_service_account_error(api_url, "gitlab")
stub_kubeclient_create_service_account(api_url)
- stub_kubeclient_get_secret_error(api_url, 'gitlab-token')
+ stub_kubeclient_get_secret_error(api_url, "gitlab-token")
stub_kubeclient_create_secret(api_url)
stub_kubeclient_get_role_binding(api_url, "gitlab-#{namespace}", namespace: namespace)
@@ -39,26 +39,26 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService, '#execute' d
api_url,
{
metadata_name: "#{namespace}-token",
- token: Base64.encode64('sample-token'),
- namespace: namespace
+ token: Base64.encode64("sample-token"),
+ namespace: namespace,
}
)
end
- shared_examples 'successful creation of kubernetes namespace' do
- it 'creates a Clusters::KubernetesNamespace' do
- expect do
+ shared_examples "successful creation of kubernetes namespace" do
+ it "creates a Clusters::KubernetesNamespace" do
+ expect {
subject
- end.to change(Clusters::KubernetesNamespace, :count).by(1)
+ }.to change(Clusters::KubernetesNamespace, :count).by(1)
end
- it 'creates project service account' do
+ it "creates project service account" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).to receive(:execute).once
subject
end
- it 'configures kubernetes token' do
+ it "configures kubernetes token" do
subject
kubernetes_namespace.reload
@@ -68,61 +68,61 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService, '#execute' d
end
end
- context 'group clusters' do
+ context "group clusters" do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:group) { cluster.group }
let(:project) { create(:project, group: group) }
- context 'when kubernetes namespace is not persisted' do
+ context "when kubernetes namespace is not persisted" do
let(:kubernetes_namespace) do
build(:cluster_kubernetes_namespace,
- cluster: cluster,
- project: project)
+ cluster: cluster,
+ project: project)
end
- it_behaves_like 'successful creation of kubernetes namespace'
+ it_behaves_like "successful creation of kubernetes namespace"
end
end
- context 'project clusters' do
- context 'when kubernetes namespace is not persisted' do
+ context "project clusters" do
+ context "when kubernetes namespace is not persisted" do
let(:kubernetes_namespace) do
build(:cluster_kubernetes_namespace,
- cluster: cluster,
- project: cluster_project.project,
- cluster_project: cluster_project)
+ cluster: cluster,
+ project: cluster_project.project,
+ cluster_project: cluster_project)
end
- it_behaves_like 'successful creation of kubernetes namespace'
+ it_behaves_like "successful creation of kubernetes namespace"
end
- context 'when there is a Kubernetes Namespace associated' do
- let(:namespace) { 'new-namespace' }
+ context "when there is a Kubernetes Namespace associated" do
+ let(:namespace) { "new-namespace" }
let(:kubernetes_namespace) do
create(:cluster_kubernetes_namespace,
- cluster: cluster,
- project: cluster_project.project,
- cluster_project: cluster_project)
+ cluster: cluster,
+ project: cluster_project.project,
+ cluster_project: cluster_project)
end
before do
- platform.update_column(:namespace, 'new-namespace')
+ platform.update_column(:namespace, "new-namespace")
end
- it 'does not create any Clusters::KubernetesNamespace' do
+ it "does not create any Clusters::KubernetesNamespace" do
subject
expect(cluster.kubernetes_namespace).to eq(kubernetes_namespace)
end
- it 'creates project service account' do
+ it "creates project service account" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).to receive(:execute).once
subject
end
- it 'updates Clusters::KubernetesNamespace' do
+ it "updates Clusters::KubernetesNamespace" do
subject
kubernetes_namespace.reload
diff --git a/spec/services/clusters/gcp/kubernetes/create_or_update_service_account_service_spec.rb b/spec/services/clusters/gcp/kubernetes/create_or_update_service_account_service_spec.rb
index 11a65d0c300..03e54b06138 100644
--- a/spec/services/clusters/gcp/kubernetes/create_or_update_service_account_service_spec.rb
+++ b/spec/services/clusters/gcp/kubernetes/create_or_update_service_account_service_spec.rb
@@ -1,52 +1,53 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
include KubernetesHelpers
- let(:api_url) { 'http://111.111.111.111' }
+ let(:api_url) { "http://111.111.111.111" }
let(:platform_kubernetes) { cluster.platform_kubernetes }
let(:cluster_project) { cluster.cluster_project }
let(:project) { cluster_project.project }
let(:cluster) do
create(:cluster,
- :project, :provided_by_gcp,
- platform_kubernetes: create(:cluster_platform_kubernetes, :configured))
+ :project, :provided_by_gcp,
+ platform_kubernetes: create(:cluster_platform_kubernetes, :configured))
end
let(:kubeclient) do
Gitlab::Kubernetes::KubeClient.new(
api_url,
- auth_options: { username: 'admin', password: 'xxx' }
+ auth_options: {username: "admin", password: "xxx"}
)
end
- shared_examples 'creates service account and token' do
- it 'creates a kubernetes service account' do
+ shared_examples "creates service account and token" do
+ it "creates a kubernetes service account" do
subject
expect(WebMock).to have_requested(:post, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts").with(
body: hash_including(
- kind: 'ServiceAccount',
- metadata: { name: service_account_name, namespace: namespace }
+ kind: "ServiceAccount",
+ metadata: {name: service_account_name, namespace: namespace}
)
)
end
- it 'creates a kubernetes secret' do
+ it "creates a kubernetes secret" do
subject
expect(WebMock).to have_requested(:post, api_url + "/api/v1/namespaces/#{namespace}/secrets").with(
body: hash_including(
- kind: 'Secret',
+ kind: "Secret",
metadata: {
name: token_name,
namespace: namespace,
annotations: {
- 'kubernetes.io/service-account.name': service_account_name
- }
+ 'kubernetes.io/service-account.name': service_account_name,
+ },
},
- type: 'kubernetes.io/service-account-token'
+ type: "kubernetes.io/service-account-token"
)
)
end
@@ -63,22 +64,22 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
stub_kubeclient_create_secret(api_url, namespace: namespace)
end
- describe '.gitlab_creator' do
- let(:namespace) { 'default' }
- let(:service_account_name) { 'gitlab' }
- let(:token_name) { 'gitlab-token' }
+ describe ".gitlab_creator" do
+ let(:namespace) { "default" }
+ let(:service_account_name) { "gitlab" }
+ let(:token_name) { "gitlab-token" }
subject { described_class.gitlab_creator(kubeclient, rbac: rbac).execute }
- context 'with ABAC cluster' do
+ context "with ABAC cluster" do
let(:rbac) { false }
- it_behaves_like 'creates service account and token'
+ it_behaves_like "creates service account and token"
end
- context 'with RBAC cluster' do
+ context "with RBAC cluster" do
let(:rbac) { true }
- let(:cluster_role_binding_name) { 'gitlab-admin' }
+ let(:cluster_role_binding_name) { "gitlab-admin" }
before do
cluster.platform_kubernetes.rbac!
@@ -87,26 +88,26 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
stub_kubeclient_create_cluster_role_binding(api_url)
end
- it_behaves_like 'creates service account and token'
+ it_behaves_like "creates service account and token"
- it 'should create a cluster role binding with cluster-admin access' do
+ it "should create a cluster role binding with cluster-admin access" do
subject
expect(WebMock).to have_requested(:post, api_url + "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings").with(
body: hash_including(
- kind: 'ClusterRoleBinding',
- metadata: { name: 'gitlab-admin' },
+ kind: "ClusterRoleBinding",
+ metadata: {name: "gitlab-admin"},
roleRef: {
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: 'cluster-admin'
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: "cluster-admin",
},
subjects: [
{
- kind: 'ServiceAccount',
+ kind: "ServiceAccount",
name: service_account_name,
- namespace: namespace
- }
+ namespace: namespace,
+ },
]
)
)
@@ -114,7 +115,7 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
end
end
- describe '.namespace_creator' do
+ describe ".namespace_creator" do
let(:namespace) { "#{project.path}-#{project.id}" }
let(:service_account_name) { "#{namespace}-service-account" }
let(:token_name) { "#{namespace}-token" }
@@ -128,13 +129,13 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
).execute
end
- context 'with ABAC cluster' do
+ context "with ABAC cluster" do
let(:rbac) { false }
- it_behaves_like 'creates service account and token'
+ it_behaves_like "creates service account and token"
end
- context 'With RBAC enabled cluster' do
+ context "With RBAC enabled cluster" do
let(:rbac) { true }
let(:role_binding_name) { "gitlab-#{namespace}"}
@@ -145,26 +146,26 @@ describe Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService do
stub_kubeclient_create_role_binding(api_url, namespace: namespace)
end
- it_behaves_like 'creates service account and token'
+ it_behaves_like "creates service account and token"
- it 'creates a namespaced role binding with edit access' do
+ it "creates a namespaced role binding with edit access" do
subject
expect(WebMock).to have_requested(:post, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings").with(
body: hash_including(
- kind: 'RoleBinding',
- metadata: { name: "gitlab-#{namespace}", namespace: "#{namespace}" },
+ kind: "RoleBinding",
+ metadata: {name: "gitlab-#{namespace}", namespace: namespace.to_s},
roleRef: {
- apiGroup: 'rbac.authorization.k8s.io',
- kind: 'ClusterRole',
- name: 'edit'
+ apiGroup: "rbac.authorization.k8s.io",
+ kind: "ClusterRole",
+ name: "edit",
},
subjects: [
{
- kind: 'ServiceAccount',
+ kind: "ServiceAccount",
name: service_account_name,
- namespace: namespace
- }
+ namespace: namespace,
+ },
]
)
)
diff --git a/spec/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service_spec.rb b/spec/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service_spec.rb
index a5806559b14..6a2a2f331f1 100644
--- a/spec/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service_spec.rb
+++ b/spec/services/clusters/gcp/kubernetes/fetch_kubernetes_token_service_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
include KubernetesHelpers
- describe '#execute' do
- let(:api_url) { 'http://111.111.111.111' }
- let(:namespace) { 'my-namespace' }
- let(:service_account_token_name) { 'gitlab-token' }
+ describe "#execute" do
+ let(:api_url) { "http://111.111.111.111" }
+ let(:namespace) { "my-namespace" }
+ let(:service_account_token_name) { "gitlab-token" }
let(:kubeclient) do
Gitlab::Kubernetes::KubeClient.new(
api_url,
- auth_options: { username: 'admin', password: 'xxx' }
+ auth_options: {username: "admin", password: "xxx"}
)
end
@@ -23,18 +23,18 @@ describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
stub_kubeclient_discover(api_url)
end
- context 'when params correct' do
- let(:decoded_token) { 'xxx.token.xxx' }
+ context "when params correct" do
+ let(:decoded_token) { "xxx.token.xxx" }
let(:token) { Base64.encode64(decoded_token) }
- context 'when gitlab-token exists' do
+ context "when gitlab-token exists" do
before do
stub_kubeclient_get_secret(
api_url,
{
metadata_name: service_account_token_name,
namespace: namespace,
- token: token
+ token: token,
}
)
end
@@ -42,7 +42,7 @@ describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
it { is_expected.to eq(decoded_token) }
end
- context 'when there is a 500 error' do
+ context "when there is a 500 error" do
before do
stub_kubeclient_get_secret_error(api_url, service_account_token_name, namespace: namespace, status: 500)
end
@@ -50,7 +50,7 @@ describe Clusters::Gcp::Kubernetes::FetchKubernetesTokenService do
it { expect { subject }.to raise_error(Kubeclient::HttpError) }
end
- context 'when gitlab-token does not exist' do
+ context "when gitlab-token does not exist" do
before do
stub_kubeclient_get_secret_error(api_url, service_account_token_name, namespace: namespace, status: 404)
end
diff --git a/spec/services/clusters/gcp/provision_service_spec.rb b/spec/services/clusters/gcp/provision_service_spec.rb
index c0bdac40938..329444d68a9 100644
--- a/spec/services/clusters/gcp/provision_service_spec.rb
+++ b/spec/services/clusters/gcp/provision_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Gcp::ProvisionService do
include GoogleApi::CloudPlatformHelpers
- describe '#execute' do
+ describe "#execute" do
let(:provider) { create(:cluster_provider_gcp, :scheduled) }
let(:gcp_project_id) { provider.gcp_project_id }
let(:zone) { provider.zone }
- shared_examples 'success' do
- it 'schedules a worker for status minitoring' do
+ shared_examples "success" do
+ it "schedules a worker for status minitoring" do
expect(WaitForClusterCreationWorker).to receive(:perform_in)
described_class.new.execute(provider)
@@ -18,52 +18,54 @@ describe Clusters::Gcp::ProvisionService do
end
end
- shared_examples 'error' do
- it 'sets an error to provider object' do
+ shared_examples "error" do
+ it "sets an error to provider object" do
described_class.new.execute(provider)
expect(provider.reload).to be_errored
end
end
- context 'when succeeded to request provision' do
+ context "when succeeded to request provision" do
before do
stub_cloud_platform_create_cluster(gcp_project_id, zone)
end
- it_behaves_like 'success'
+ it_behaves_like "success"
end
- context 'when operation status is unexpected' do
+ context "when operation status is unexpected" do
before do
stub_cloud_platform_create_cluster(
gcp_project_id, zone,
{
- "status": 'unexpected'
- } )
+ "status": "unexpected",
+ }
+ )
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when selfLink is unexpected' do
+ context "when selfLink is unexpected" do
before do
stub_cloud_platform_create_cluster(
gcp_project_id, zone,
{
- "selfLink": 'unexpected'
- })
+ "selfLink": "unexpected",
+ }
+ )
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when Internal Server Error happened' do
+ context "when Internal Server Error happened" do
before do
stub_cloud_platform_create_cluster_error(gcp_project_id, zone)
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
end
end
diff --git a/spec/services/clusters/gcp/verify_provision_status_service_spec.rb b/spec/services/clusters/gcp/verify_provision_status_service_spec.rb
index 2ee2fa51f63..574b39ab0ba 100644
--- a/spec/services/clusters/gcp/verify_provision_status_service_spec.rb
+++ b/spec/services/clusters/gcp/verify_provision_status_service_spec.rb
@@ -1,107 +1,112 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::Gcp::VerifyProvisionStatusService do
include GoogleApi::CloudPlatformHelpers
- describe '#execute' do
+ describe "#execute" do
let(:provider) { create(:cluster_provider_gcp, :creating) }
let(:gcp_project_id) { provider.gcp_project_id }
let(:zone) { provider.zone }
let(:operation_id) { provider.operation_id }
- shared_examples 'continue_creation' do
- it 'schedules a worker for status minitoring' do
+ shared_examples "continue_creation" do
+ it "schedules a worker for status minitoring" do
expect(WaitForClusterCreationWorker).to receive(:perform_in)
described_class.new.execute(provider)
end
end
- shared_examples 'finalize_creation' do
- it 'schedules a worker for status minitoring' do
+ shared_examples "finalize_creation" do
+ it "schedules a worker for status minitoring" do
expect_any_instance_of(Clusters::Gcp::FinalizeCreationService).to receive(:execute)
described_class.new.execute(provider)
end
end
- shared_examples 'error' do
- it 'sets an error to provider object' do
+ shared_examples "error" do
+ it "sets an error to provider object" do
described_class.new.execute(provider)
expect(provider.reload).to be_errored
end
end
- context 'when operation status is RUNNING' do
+ context "when operation status is RUNNING" do
before do
stub_cloud_platform_get_zone_operation(
gcp_project_id, zone, operation_id,
{
- "status": 'RUNNING',
- "startTime": 1.minute.ago.strftime("%FT%TZ")
- } )
+ "status": "RUNNING",
+ "startTime": 1.minute.ago.strftime("%FT%TZ"),
+ }
+ )
end
- it_behaves_like 'continue_creation'
+ it_behaves_like "continue_creation"
- context 'when cluster creation time exceeds timeout' do
+ context "when cluster creation time exceeds timeout" do
before do
stub_cloud_platform_get_zone_operation(
gcp_project_id, zone, operation_id,
{
- "status": 'RUNNING',
- "startTime": 30.minutes.ago.strftime("%FT%TZ")
- } )
+ "status": "RUNNING",
+ "startTime": 30.minutes.ago.strftime("%FT%TZ"),
+ }
+ )
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
end
- context 'when operation status is PENDING' do
+ context "when operation status is PENDING" do
before do
stub_cloud_platform_get_zone_operation(
gcp_project_id, zone, operation_id,
{
- "status": 'PENDING',
- "startTime": 1.minute.ago.strftime("%FT%TZ")
- } )
+ "status": "PENDING",
+ "startTime": 1.minute.ago.strftime("%FT%TZ"),
+ }
+ )
end
- it_behaves_like 'continue_creation'
+ it_behaves_like "continue_creation"
end
- context 'when operation status is DONE' do
+ context "when operation status is DONE" do
before do
stub_cloud_platform_get_zone_operation(
gcp_project_id, zone, operation_id,
{
- "status": 'DONE'
- } )
+ "status": "DONE",
+ }
+ )
end
- it_behaves_like 'finalize_creation'
+ it_behaves_like "finalize_creation"
end
- context 'when operation status is unexpected' do
+ context "when operation status is unexpected" do
before do
stub_cloud_platform_get_zone_operation(
gcp_project_id, zone, operation_id,
{
- "status": 'unexpected'
- } )
+ "status": "unexpected",
+ }
+ )
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
- context 'when failed to get operation status' do
+ context "when failed to get operation status" do
before do
stub_cloud_platform_get_zone_operation_error(gcp_project_id, zone, operation_id)
end
- it_behaves_like 'error'
+ it_behaves_like "error"
end
end
end
diff --git a/spec/services/clusters/refresh_service_spec.rb b/spec/services/clusters/refresh_service_spec.rb
index 58ab3c3cf73..e346a12917b 100644
--- a/spec/services/clusters/refresh_service_spec.rb
+++ b/spec/services/clusters/refresh_service_spec.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Clusters::RefreshService do
- shared_examples 'creates a kubernetes namespace' do
- let(:token) { 'aaaaaa' }
+ shared_examples "creates a kubernetes namespace" do
+ let(:token) { "aaaaaa" }
let(:service_account_creator) { double(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService, execute: true) }
let(:secrets_fetcher) { double(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService, execute: token) }
- it 'creates a kubernetes namespace' do
+ it "creates a kubernetes namespace" do
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).to receive(:namespace_creator).and_return(service_account_creator)
expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).to receive(:new).and_return(secrets_fetcher)
@@ -20,8 +20,8 @@ describe Clusters::RefreshService do
end
end
- shared_examples 'does not create a kubernetes namespace' do
- it 'does not create a new kubernetes namespace' do
+ shared_examples "does not create a kubernetes namespace" do
+ it "does not create a new kubernetes namespace" do
expect(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService).not_to receive(:namespace_creator)
expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).not_to receive(:new)
@@ -29,78 +29,78 @@ describe Clusters::RefreshService do
end
end
- describe '.create_or_update_namespaces_for_cluster' do
+ describe ".create_or_update_namespaces_for_cluster" do
let(:cluster) { create(:cluster, :provided_by_user, :project) }
let(:project) { cluster.project }
subject { described_class.create_or_update_namespaces_for_cluster(cluster) }
- context 'cluster is project level' do
- include_examples 'creates a kubernetes namespace'
+ context "cluster is project level" do
+ include_examples "creates a kubernetes namespace"
- context 'when project already has kubernetes namespace' do
+ context "when project already has kubernetes namespace" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
- include_examples 'does not create a kubernetes namespace'
+ include_examples "does not create a kubernetes namespace"
end
end
- context 'cluster is group level' do
+ context "cluster is group level" do
let(:cluster) { create(:cluster, :provided_by_user, :group) }
let(:group) { cluster.group }
let(:project) { create(:project, group: group) }
- include_examples 'creates a kubernetes namespace'
+ include_examples "creates a kubernetes namespace"
- context 'when project already has kubernetes namespace' do
+ context "when project already has kubernetes namespace" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
- include_examples 'does not create a kubernetes namespace'
+ include_examples "does not create a kubernetes namespace"
end
end
end
- describe '.create_or_update_namespaces_for_project' do
+ describe ".create_or_update_namespaces_for_project" do
let(:project) { create(:project) }
subject { described_class.create_or_update_namespaces_for_project(project) }
- it 'creates no kubernetes namespaces' do
+ it "creates no kubernetes namespaces" do
expect { subject }.not_to change(project.kubernetes_namespaces, :count)
end
- context 'project has a project cluster' do
+ context "project has a project cluster" do
let!(:cluster) { create(:cluster, :provided_by_gcp, cluster_type: :project_type, projects: [project]) }
- include_examples 'creates a kubernetes namespace'
+ include_examples "creates a kubernetes namespace"
- context 'when project already has kubernetes namespace' do
+ context "when project already has kubernetes namespace" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
- include_examples 'does not create a kubernetes namespace'
+ include_examples "does not create a kubernetes namespace"
end
end
- context 'project belongs to a group cluster' do
+ context "project belongs to a group cluster" do
let!(:cluster) { create(:cluster, :provided_by_gcp, :group) }
let(:group) { cluster.group }
let(:project) { create(:project, group: group) }
- include_examples 'creates a kubernetes namespace'
+ include_examples "creates a kubernetes namespace"
- context 'when project already has kubernetes namespace' do
+ context "when project already has kubernetes namespace" do
before do
create(:cluster_kubernetes_namespace, project: project, cluster: cluster)
end
- include_examples 'does not create a kubernetes namespace'
+ include_examples "does not create a kubernetes namespace"
end
end
end
diff --git a/spec/services/clusters/update_service_spec.rb b/spec/services/clusters/update_service_spec.rb
index b2e6ebecd4a..bd83ebba15f 100644
--- a/spec/services/clusters/update_service_spec.rb
+++ b/spec/services/clusters/update_service_spec.rb
@@ -1,91 +1,91 @@
-require 'spec_helper'
+require "spec_helper"
describe Clusters::UpdateService do
include KubernetesHelpers
- describe '#execute' do
+ describe "#execute" do
subject { described_class.new(cluster.user, params).execute(cluster) }
let(:cluster) { create(:cluster, :project, :provided_by_user) }
- context 'when correct params' do
- context 'when enabled is true' do
- let(:params) { { enabled: true } }
+ context "when correct params" do
+ context "when enabled is true" do
+ let(:params) { {enabled: true} }
- it 'enables cluster' do
+ it "enables cluster" do
is_expected.to eq(true)
expect(cluster.enabled).to be_truthy
end
end
- context 'when enabled is false' do
- let(:params) { { enabled: false } }
+ context "when enabled is false" do
+ let(:params) { {enabled: false} }
- it 'disables cluster' do
+ it "disables cluster" do
is_expected.to eq(true)
expect(cluster.enabled).to be_falsy
end
end
- context 'when namespace is specified' do
+ context "when namespace is specified" do
let(:params) do
{
platform_kubernetes_attributes: {
- namespace: 'custom-namespace'
- }
+ namespace: "custom-namespace",
+ },
}
end
before do
allow(ClusterConfigureWorker).to receive(:perform_async)
- stub_kubeclient_get_namespace('https://kubernetes.example.com', namespace: 'my-namespace')
+ stub_kubeclient_get_namespace("https://kubernetes.example.com", namespace: "my-namespace")
end
- it 'updates namespace' do
+ it "updates namespace" do
is_expected.to eq(true)
- expect(cluster.platform.namespace).to eq('custom-namespace')
+ expect(cluster.platform.namespace).to eq("custom-namespace")
end
end
end
- context 'when invalid params' do
+ context "when invalid params" do
let(:params) do
{
platform_kubernetes_attributes: {
- namespace: '!!!'
- }
+ namespace: "!!!",
+ },
}
end
- it 'returns false' do
+ it "returns false" do
is_expected.to eq(false)
expect(cluster.errors[:"platform_kubernetes.namespace"]).to be_present
end
end
- context 'when cluster is provided by GCP' do
+ context "when cluster is provided by GCP" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:params) do
{
- name: 'my-new-name'
+ name: "my-new-name",
}
end
- it 'does not change cluster name' do
+ it "does not change cluster name" do
is_expected.to eq(false)
cluster.reload
- expect(cluster.name).to eq('test-cluster')
+ expect(cluster.name).to eq("test-cluster")
end
- context 'when cluster is being created' do
+ context "when cluster is being created" do
let(:cluster) { create(:cluster, :providing_by_gcp) }
- it 'rejects changes' do
+ it "rejects changes" do
is_expected.to eq(false)
- expect(cluster.errors.full_messages).to include('cannot modify during creation')
+ expect(cluster.errors.full_messages).to include("cannot modify during creation")
end
end
end
diff --git a/spec/services/cohorts_service_spec.rb b/spec/services/cohorts_service_spec.rb
index 77595d7ba2d..54a19cbeeb1 100644
--- a/spec/services/cohorts_service_spec.rb
+++ b/spec/services/cohorts_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe CohortsService do
- describe '#execute' do
+ describe "#execute" do
def month_start(months_ago)
months_ago.months.ago.beginning_of_month.to_date
end
# In the interests of speed and clarity, this example has minimal data.
- it 'returns a list of user cohorts' do
+ it "returns a list of user cohorts" do
6.times do |months_ago|
months_ago_time = (months_ago * 2).months.ago
@@ -20,76 +20,76 @@ describe CohortsService do
expected_cohorts = [
{
registration_month: month_start(11),
- activity_months: Array.new(12) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(12) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(10),
- activity_months: [{ total: 2, percentage: 100 }] + Array.new(10) { { total: 1, percentage: 50 } },
+ activity_months: [{total: 2, percentage: 100}] + Array.new(10) { {total: 1, percentage: 50} },
total: 2,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(9),
- activity_months: Array.new(10) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(10) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(8),
- activity_months: [{ total: 2, percentage: 100 }] + Array.new(8) { { total: 1, percentage: 50 } },
+ activity_months: [{total: 2, percentage: 100}] + Array.new(8) { {total: 1, percentage: 50} },
total: 2,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(7),
- activity_months: Array.new(8) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(8) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(6),
- activity_months: [{ total: 2, percentage: 100 }] + Array.new(6) { { total: 1, percentage: 50 } },
+ activity_months: [{total: 2, percentage: 100}] + Array.new(6) { {total: 1, percentage: 50} },
total: 2,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(5),
- activity_months: Array.new(6) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(6) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(4),
- activity_months: [{ total: 2, percentage: 100 }] + Array.new(4) { { total: 1, percentage: 50 } },
+ activity_months: [{total: 2, percentage: 100}] + Array.new(4) { {total: 1, percentage: 50} },
total: 2,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(3),
- activity_months: Array.new(4) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(4) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(2),
- activity_months: [{ total: 2, percentage: 100 }] + Array.new(2) { { total: 1, percentage: 50 } },
+ activity_months: [{total: 2, percentage: 100}] + Array.new(2) { {total: 1, percentage: 50} },
total: 2,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(1),
- activity_months: Array.new(2) { { total: 0, percentage: 0 } },
+ activity_months: Array.new(2) { {total: 0, percentage: 0} },
total: 0,
- inactive: 0
+ inactive: 0,
},
{
registration_month: month_start(0),
- activity_months: [{ total: 2, percentage: 100 }],
+ activity_months: [{total: 2, percentage: 100}],
total: 2,
- inactive: 1
- }
+ inactive: 1,
+ },
]
expect(described_class.new.execute).to eq(months_included: 12,
diff --git a/spec/services/commits/commit_patch_service_spec.rb b/spec/services/commits/commit_patch_service_spec.rb
index f4fcec2fbc2..9ebe051bdfe 100644
--- a/spec/services/commits/commit_patch_service_spec.rb
+++ b/spec/services/commits/commit_patch_service_spec.rb
@@ -1,26 +1,27 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Commits::CommitPatchService do
- describe '#execute' do
+ describe "#execute" do
let(:patches) do
- patches_folder = Rails.root.join('spec/fixtures/patchfiles')
+ patches_folder = Rails.root.join("spec/fixtures/patchfiles")
content_1 = File.read(File.join(patches_folder, "0001-This-does-not-apply-to-the-feature-branch.patch"))
content_2 = File.read(File.join(patches_folder, "0001-A-commit-from-a-patch.patch"))
[content_1, content_2]
end
let(:user) { project.creator }
- let(:branch_name) { 'branch-with-patches' }
+ let(:branch_name) { "branch-with-patches" }
let(:project) { create(:project, :repository) }
let(:start_branch) { nil }
- let(:params) { { branch_name: branch_name, patches: patches, start_branch: start_branch } }
+ let(:params) { {branch_name: branch_name, patches: patches, start_branch: start_branch} }
subject(:service) do
described_class.new(project, user, params)
end
- it 'returns a successful result' do
+ it "returns a successful result" do
result = service.execute
branch = project.repository.find_branch(branch_name)
@@ -29,18 +30,18 @@ describe Commits::CommitPatchService do
expect(result[:result]).to eq(branch.target)
end
- it 'is based off HEAD when no start ref is passed' do
+ it "is based off HEAD when no start ref is passed" do
service.execute
merge_base = project.repository.merge_base(project.repository.root_ref, branch_name)
- expect(merge_base).to eq(project.repository.commit('HEAD').sha)
+ expect(merge_base).to eq(project.repository.commit("HEAD").sha)
end
- context 'when specifying a different start branch' do
- let(:start_branch) { 'with-codeowners' }
+ context "when specifying a different start branch" do
+ let(:start_branch) { "with-codeowners" }
- it 'is based of the correct branch' do
+ it "is based of the correct branch" do
service.execute
merge_base = project.repository.merge_base(start_branch, branch_name)
@@ -49,8 +50,8 @@ describe Commits::CommitPatchService do
end
end
- shared_examples 'an error response' do |expected_message|
- it 'returns the correct error' do
+ shared_examples "an error response" do |expected_message|
+ it "returns the correct error" do
result = service.execute
expect(result[:status]).to eq(:error)
@@ -58,35 +59,35 @@ describe Commits::CommitPatchService do
end
end
- context 'when the user does not have access' do
+ context "when the user does not have access" do
let(:user) { create(:user) }
- it_behaves_like 'an error response',
- 'You are not allowed to push into this branch'
+ it_behaves_like "an error response",
+ "You are not allowed to push into this branch"
end
- context 'when the patches are not valid' do
+ context "when the patches are not valid" do
let(:patches) { "a" * 2.1.megabytes }
- it_behaves_like 'an error response', 'Patches are too big'
+ it_behaves_like "an error response", "Patches are too big"
end
- context 'when the new branch name is invalid' do
- let(:branch_name) { 'HEAD' }
+ context "when the new branch name is invalid" do
+ let(:branch_name) { "HEAD" }
- it_behaves_like 'an error response', 'Branch name is invalid'
+ it_behaves_like "an error response", "Branch name is invalid"
end
- context 'when the patches do not apply' do
- let(:branch_name) { 'feature' }
+ context "when the patches do not apply" do
+ let(:branch_name) { "feature" }
- it_behaves_like 'an error response', 'Patch failed at'
+ it_behaves_like "an error response", "Patch failed at"
end
- context 'when specifying a non existent start branch' do
- let(:start_branch) { 'does-not-exist' }
+ context "when specifying a non existent start branch" do
+ let(:start_branch) { "does-not-exist" }
- it_behaves_like 'an error response', 'Invalid reference name'
+ it_behaves_like "an error response", "Invalid reference name"
end
end
end
diff --git a/spec/services/commits/tag_service_spec.rb b/spec/services/commits/tag_service_spec.rb
index 82377a8dace..b3e879033b6 100644
--- a/spec/services/commits/tag_service_spec.rb
+++ b/spec/services/commits/tag_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Commits::TagService do
let(:project) { create(:project, :repository) }
@@ -12,21 +12,21 @@ describe Commits::TagService do
project.add_maintainer(user)
end
- describe '#execute' do
+ describe "#execute" do
let(:service) { described_class.new(project, user, opts) }
- shared_examples 'tag failure' do
- it 'returns a hash with the :error status' do
+ shared_examples "tag failure" do
+ it "returns a hash with the :error status" do
result = service.execute(commit)
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq(error_message)
end
- it 'does not add a system note' do
+ it "does not add a system note" do
service.execute(commit)
- description_notes = find_notes('tag')
+ description_notes = find_notes("tag")
expect(description_notes).to be_empty
end
end
@@ -35,14 +35,14 @@ describe Commits::TagService do
commit
.notes
.joins(:system_note_metadata)
- .where(system_note_metadata: { action: action })
+ .where(system_note_metadata: {action: action})
end
- context 'valid params' do
+ context "valid params" do
let(:opts) do
{
- tag_name: 'v1.2.3',
- tag_message: 'Release'
+ tag_name: "v1.2.3",
+ tag_message: "Release",
}
end
@@ -50,11 +50,11 @@ describe Commits::TagService do
commit
.notes
.joins(:system_note_metadata)
- .where(system_note_metadata: { action: action })
+ .where(system_note_metadata: {action: action})
end
- context 'when tagging succeeds' do
- it 'returns a hash with the :success status and created tag' do
+ context "when tagging succeeds" do
+ it "returns a hash with the :success status and created tag" do
result = service.execute(commit)
expect(result[:status]).to eq(:success)
@@ -64,38 +64,38 @@ describe Commits::TagService do
expect(tag.message).to eq(opts[:tag_message])
end
- it 'adds a system note' do
+ it "adds a system note" do
service.execute(commit)
- description_notes = find_notes('tag')
+ description_notes = find_notes("tag")
expect(description_notes.length).to eq(1)
end
end
- context 'when tagging fails' do
- let(:tag_error) { 'GitLab: You are not allowed to push code to this project.' }
+ context "when tagging fails" do
+ let(:tag_error) { "GitLab: You are not allowed to push code to this project." }
before do
tag_stub = instance_double(Tags::CreateService)
allow(Tags::CreateService).to receive(:new).and_return(tag_stub)
allow(tag_stub).to receive(:execute).and_return({
- status: :error, message: tag_error
+ status: :error, message: tag_error,
})
end
- it_behaves_like 'tag failure' do
+ it_behaves_like "tag failure" do
let(:error_message) { tag_error }
end
end
end
- context 'invalid params' do
+ context "invalid params" do
let(:opts) do
{}
end
- it_behaves_like 'tag failure' do
- let(:error_message) { 'Missing parameter tag_name' }
+ it_behaves_like "tag failure" do
+ let(:error_message) { "Missing parameter tag_name" }
end
end
end
diff --git a/spec/services/compare_service_spec.rb b/spec/services/compare_service_spec.rb
index 9e15eae8c13..168b3fea8ad 100644
--- a/spec/services/compare_service_spec.rb
+++ b/spec/services/compare_service_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe CompareService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- let(:service) { described_class.new(project, 'feature') }
+ let(:service) { described_class.new(project, "feature") }
- describe '#execute' do
- context 'compare with base, like feature...fix' do
- subject { service.execute(project, 'fix', straight: false) }
+ describe "#execute" do
+ context "compare with base, like feature...fix" do
+ subject { service.execute(project, "fix", straight: false) }
it { expect(subject.diffs.size).to eq(1) }
end
- context 'straight compare, like feature..fix' do
- subject { service.execute(project, 'fix', straight: true) }
+ context "straight compare, like feature..fix" do
+ subject { service.execute(project, "fix", straight: true) }
it { expect(subject.diffs.size).to eq(3) }
end
diff --git a/spec/services/create_branch_service_spec.rb b/spec/services/create_branch_service_spec.rb
index 38096a080a7..bc688cb7ae0 100644
--- a/spec/services/create_branch_service_spec.rb
+++ b/spec/services/create_branch_service_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe CreateBranchService do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- context 'when repository is empty' do
+ describe "#execute" do
+ context "when repository is empty" do
let(:project) { create(:project_empty_repo) }
- it 'creates master branch' do
- service.execute('my-feature', 'master')
+ it "creates master branch" do
+ service.execute("my-feature", "master")
- expect(project.repository.branch_exists?('master')).to be_truthy
+ expect(project.repository.branch_exists?("master")).to be_truthy
end
- it 'creates my-feature branch' do
- service.execute('my-feature', 'master')
+ it "creates my-feature branch" do
+ service.execute("my-feature", "master")
- expect(project.repository.branch_exists?('my-feature')).to be_truthy
+ expect(project.repository.branch_exists?("my-feature")).to be_truthy
end
end
end
diff --git a/spec/services/create_snippet_service_spec.rb b/spec/services/create_snippet_service_spec.rb
index b6ab6b8271c..6246d3c4788 100644
--- a/spec/services/create_snippet_service_spec.rb
+++ b/spec/services/create_snippet_service_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe CreateSnippetService do
before do
@user = create :user
@admin = create :user, admin: true
@opts = {
- title: 'Test snippet',
- file_name: 'snippet.rb',
+ title: "Test snippet",
+ file_name: "snippet.rb",
content: 'puts "hello world"',
- visibility_level: Gitlab::VisibilityLevel::PRIVATE
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE,
}
end
- context 'When public visibility is restricted' do
+ context "When public visibility is restricted" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it 'non-admins are not 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(
- match('has been restricted')
+ match("has been restricted")
)
end
- it 'admins are 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/delete_branch_service_spec.rb b/spec/services/delete_branch_service_spec.rb
index 9c9fba030e7..fa75f7f2f60 100644
--- a/spec/services/delete_branch_service_spec.rb
+++ b/spec/services/delete_branch_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeleteBranchService do
let(:project) { create(:project, :repository) }
@@ -6,31 +6,31 @@ describe DeleteBranchService do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- context 'when user has access to push to repository' do
+ describe "#execute" do
+ context "when user has access to push to repository" do
before do
project.add_developer(user)
end
- it 'removes the branch' do
- expect(branch_exists?('feature')).to be true
+ it "removes the branch" do
+ expect(branch_exists?("feature")).to be true
- result = service.execute('feature')
+ result = service.execute("feature")
expect(result[:status]).to eq :success
- expect(branch_exists?('feature')).to be false
+ expect(branch_exists?("feature")).to be false
end
end
- context 'when user does not have access to push to repository' do
- it 'does not remove branch' do
- expect(branch_exists?('feature')).to be true
+ context "when user does not have access to push to repository" do
+ it "does not remove branch" do
+ expect(branch_exists?("feature")).to be true
- result = service.execute('feature')
+ result = service.execute("feature")
expect(result[:status]).to eq :error
- expect(result[:message]).to eq 'You dont have push access to repo'
- expect(branch_exists?('feature')).to be true
+ expect(result[:message]).to eq "You dont have push access to repo"
+ expect(branch_exists?("feature")).to be true
end
end
end
diff --git a/spec/services/delete_merged_branches_service_spec.rb b/spec/services/delete_merged_branches_service_spec.rb
index 0de02576203..ad4904e44b1 100644
--- a/spec/services/delete_merged_branches_service_spec.rb
+++ b/spec/services/delete_merged_branches_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeleteMergedBranchesService do
include ProjectForksHelper
@@ -7,73 +7,73 @@ describe DeleteMergedBranchesService do
let(:project) { create(:project, :repository) }
- context '#execute' do
- it 'deletes a branch that was merged' do
+ context "#execute" do
+ it "deletes a branch that was merged" do
service.execute
- expect(project.repository.branch_names).not_to include('improve/awesome')
+ expect(project.repository.branch_names).not_to include("improve/awesome")
end
- it 'keeps branch that is unmerged' do
+ it "keeps branch that is unmerged" do
service.execute
- expect(project.repository.branch_names).to include('feature')
+ expect(project.repository.branch_names).to include("feature")
end
it 'keeps "master"' do
service.execute
- expect(project.repository.branch_names).to include('master')
+ expect(project.repository.branch_names).to include("master")
end
- it 'keeps protected branches' do
- create(:protected_branch, project: project, name: 'improve/awesome')
+ it "keeps protected branches" do
+ create(:protected_branch, project: project, name: "improve/awesome")
service.execute
- expect(project.repository.branch_names).to include('improve/awesome')
+ expect(project.repository.branch_names).to include("improve/awesome")
end
- it 'keeps wildcard protected branches' do
- create(:protected_branch, project: project, name: 'improve/*')
+ it "keeps wildcard protected branches" do
+ create(:protected_branch, project: project, name: "improve/*")
service.execute
- expect(project.repository.branch_names).to include('improve/awesome')
+ expect(project.repository.branch_names).to include("improve/awesome")
end
- it 'ignores protected tags' do
- create(:protected_tag, project: project, name: 'improve/*')
+ it "ignores protected tags" do
+ create(:protected_tag, project: project, name: "improve/*")
service.execute
- expect(project.repository.branch_names).not_to include('improve/awesome')
+ expect(project.repository.branch_names).not_to include("improve/awesome")
end
- context 'user without rights' do
+ context "user without rights" do
let(:user) { create(:user) }
- it 'cannot execute' do
+ it "cannot execute" do
expect { described_class.new(project, user).execute }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- context 'open merge requests' do
- it 'does not delete branches from open merge requests' do
+ context "open merge requests" do
+ it "does not delete branches from open merge requests" do
forked_project = fork_project(project)
- create(:merge_request, :opened, source_project: project, target_project: project, source_branch: 'branch-merged', target_branch: 'master')
- create(:merge_request, :opened, source_project: forked_project, target_project: project, target_branch: 'improve/awesome', source_branch: 'master')
+ create(:merge_request, :opened, source_project: project, target_project: project, source_branch: "branch-merged", target_branch: "master")
+ create(:merge_request, :opened, source_project: forked_project, target_project: project, target_branch: "improve/awesome", source_branch: "master")
service.execute
- expect(project.repository.branch_names).to include('branch-merged')
- expect(project.repository.branch_names).to include('improve/awesome')
+ expect(project.repository.branch_names).to include("branch-merged")
+ expect(project.repository.branch_names).to include("improve/awesome")
end
end
end
- context '#async_execute' do
- it 'calls DeleteMergedBranchesWorker async' do
+ context "#async_execute" do
+ it "calls DeleteMergedBranchesWorker async" do
expect(DeleteMergedBranchesWorker).to receive(:perform_async)
service.async_execute
diff --git a/spec/services/deploy_keys/create_service_spec.rb b/spec/services/deploy_keys/create_service_spec.rb
index 7a604c0cadd..c7724a65983 100644
--- a/spec/services/deploy_keys/create_service_spec.rb
+++ b/spec/services/deploy_keys/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployKeys::CreateService do
let(:user) { create(:user) }
diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb
index 3a2bbf1ecd1..acd34c9c7e0 100644
--- a/spec/services/deploy_tokens/create_service_spec.rb
+++ b/spec/services/deploy_tokens/create_service_spec.rb
@@ -1,43 +1,43 @@
-require 'spec_helper'
+require "spec_helper"
describe DeployTokens::CreateService do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:deploy_token_params) { attributes_for(:deploy_token) }
- describe '#execute' do
+ describe "#execute" do
subject { described_class.new(project, user, deploy_token_params).execute }
- context 'when the deploy token is valid' do
- it 'should create a new DeployToken' do
+ context "when the deploy token is valid" do
+ it "should create a new DeployToken" do
expect { subject }.to change { DeployToken.count }.by(1)
end
- it 'should create a new ProjectDeployToken' do
+ it "should create a new ProjectDeployToken" do
expect { subject }.to change { ProjectDeployToken.count }.by(1)
end
- it 'returns a DeployToken' do
+ it "returns a DeployToken" do
expect(subject).to be_an_instance_of DeployToken
end
end
- context 'when expires at date is not passed' do
- let(:deploy_token_params) { attributes_for(:deploy_token, expires_at: '') }
+ context "when expires at date is not passed" do
+ let(:deploy_token_params) { attributes_for(:deploy_token, expires_at: "") }
- it 'should set Forever.date' do
+ it "should set Forever.date" do
expect(subject.read_attribute(:expires_at)).to eq(Forever.date)
end
end
- context 'when the deploy token is invalid' do
+ context "when the deploy token is invalid" do
let(:deploy_token_params) { attributes_for(:deploy_token, read_repository: false, read_registry: false) }
- it 'should not create a new DeployToken' do
+ it "should not create a new DeployToken" do
expect { subject }.not_to change { DeployToken.count }
end
- it 'should not create a new ProjectDeployToken' do
+ it "should not create a new ProjectDeployToken" do
expect { subject }.not_to change { ProjectDeployToken.count }
end
end
diff --git a/spec/services/discussions/resolve_service_spec.rb b/spec/services/discussions/resolve_service_spec.rb
index 4e0d4749239..32c00866182 100644
--- a/spec/services/discussions/resolve_service_spec.rb
+++ b/spec/services/discussions/resolve_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Discussions::ResolveService do
- describe '#execute' do
+ describe "#execute" do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:project) { merge_request.project }
let(:merge_request) { discussion.noteable }
@@ -20,19 +20,19 @@ describe Discussions::ResolveService do
expect(discussion.resolved?).to be(false)
end
- it 'resolves the discussion' do
+ it "resolves the discussion" do
service.execute(discussion)
expect(discussion.resolved?).to be(true)
end
- it 'executes the notification service' do
+ it "executes the notification service" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService).to receive(:execute).with(discussion.noteable)
service.execute(discussion)
end
- it 'adds a system note to the discussion' do
+ it "adds a system note to the discussion" do
issue = create(:issue, project: project)
expect(SystemNoteService).to receive(:discussion_continued_in_issue).with(discussion, project, user, issue)
@@ -40,7 +40,7 @@ describe Discussions::ResolveService do
service.execute(discussion)
end
- it 'can resolve multiple discussions at once' do
+ it "can resolve multiple discussions at once" do
other_discussion = create(:diff_note_on_merge_request, noteable: discussion.noteable, project: discussion.noteable.source_project).to_discussion
service.execute([discussion, other_discussion])
diff --git a/spec/services/discussions/update_diff_position_service_spec.rb b/spec/services/discussions/update_diff_position_service_spec.rb
index 2b84206318f..a81b67c0743 100644
--- a/spec/services/discussions/update_diff_position_service_spec.rb
+++ b/spec/services/discussions/update_diff_position_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Discussions::UpdateDiffPositionService do
let(:project) { create(:project, :repository) }
@@ -150,7 +150,7 @@ describe Discussions::UpdateDiffPositionService do
)
end
- shared_examples 'outdated diff note' do
+ shared_examples "outdated diff note" do
it "doesn't update the position" do
subject.execute(discussion)
@@ -158,7 +158,7 @@ describe Discussions::UpdateDiffPositionService do
expect(discussion.position).to eq(old_position)
end
- it 'sets the change position' do
+ it "sets the change position" do
subject.execute(discussion)
change_position = discussion.change_position
@@ -168,9 +168,10 @@ describe Discussions::UpdateDiffPositionService do
expect(change_position.formatter.new_line).to be_nil
end
- it 'creates a system discussion' do
+ it "creates a system discussion" do
expect(SystemNoteService).to receive(:diff_discussion_outdated).with(
- discussion, project, current_user, instance_of(Gitlab::Diff::Position))
+ discussion, project, current_user, instance_of(Gitlab::Diff::Position)
+ )
subject.execute(discussion)
end
@@ -187,12 +188,12 @@ describe Discussions::UpdateDiffPositionService do
expect(discussion.position.formatter.new_line).to eq(22)
end
- context 'when the resolve_outdated_diff_discussions setting is set' do
+ context "when the resolve_outdated_diff_discussions setting is set" do
before do
project.update!(resolve_outdated_diff_discussions: true)
end
- it 'does not resolve the discussion' do
+ it "does not resolve the discussion" do
subject.execute(discussion)
expect(discussion).not_to be_resolved
@@ -204,21 +205,21 @@ describe Discussions::UpdateDiffPositionService do
context "when the diff line has changed" do
let(:line) { 9 }
- include_examples 'outdated diff note'
+ include_examples "outdated diff note"
- context 'when the resolve_outdated_diff_discussions setting is set' do
+ context "when the resolve_outdated_diff_discussions setting is set" do
before do
project.update!(resolve_outdated_diff_discussions: true)
end
- it 'sets resolves the discussion and sets resolved_by_push' do
+ it "sets resolves the discussion and sets resolved_by_push" do
subject.execute(discussion)
expect(discussion).to be_resolved
expect(discussion).to be_resolved_by_push
end
- include_examples 'outdated diff note'
+ include_examples "outdated diff note"
end
end
end
diff --git a/spec/services/emails/confirm_service_spec.rb b/spec/services/emails/confirm_service_spec.rb
index 2b2c31e2521..9f1e730e76d 100644
--- a/spec/services/emails/confirm_service_spec.rb
+++ b/spec/services/emails/confirm_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Emails::ConfirmService do
let(:user) { create(:user) }
subject(:service) { described_class.new(user) }
- describe '#execute' do
- it 'sends a confirmation email again' do
- email = user.emails.create(email: 'new@email.com')
+ describe "#execute" do
+ it "sends a confirmation email again" do
+ email = user.emails.create(email: "new@email.com")
mail = service.execute(email)
- expect(mail.subject).to eq('Confirmation instructions')
+ expect(mail.subject).to eq("Confirmation instructions")
end
end
end
diff --git a/spec/services/emails/create_service_spec.rb b/spec/services/emails/create_service_spec.rb
index 54692c88623..c8d42bef4f3 100644
--- a/spec/services/emails/create_service_spec.rb
+++ b/spec/services/emails/create_service_spec.rb
@@ -1,23 +1,23 @@
-require 'spec_helper'
+require "spec_helper"
describe Emails::CreateService do
let(:user) { create(:user) }
- let(:opts) { { email: 'new@email.com', user: user } }
+ let(:opts) { {email: "new@email.com", user: user} }
subject(:service) { described_class.new(user, opts) }
- describe '#execute' do
- it 'creates an email with valid attributes' do
+ describe "#execute" do
+ it "creates an email with valid attributes" do
expect { service.execute }.to change { Email.count }.by(1)
expect(Email.where(opts)).not_to be_empty
end
- it 'creates an email with additional attributes' do
- expect { service.execute(confirmation_token: 'abc') }.to change { Email.count }.by(1)
- expect(Email.where(opts).first.confirmation_token).to eq 'abc'
+ it "creates an email with additional attributes" do
+ expect { service.execute(confirmation_token: "abc") }.to change { Email.count }.by(1)
+ expect(Email.where(opts).first.confirmation_token).to eq "abc"
end
- it 'has the right user association' do
+ it "has the right user association" do
service.execute
expect(user.emails).to eq(Email.where(opts))
diff --git a/spec/services/emails/destroy_service_spec.rb b/spec/services/emails/destroy_service_spec.rb
index c3204fac3df..a32578820a9 100644
--- a/spec/services/emails/destroy_service_spec.rb
+++ b/spec/services/emails/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Emails::DestroyService do
let!(:user) { create(:user) }
@@ -6,8 +6,8 @@ describe Emails::DestroyService do
subject(:service) { described_class.new(user, user: user) }
- describe '#execute' do
- it 'removes an email' do
+ describe "#execute" do
+ it "removes an email" do
expect { service.execute(email) }.to change { user.emails.count }.by(-1)
end
end
diff --git a/spec/services/error_tracking/list_issues_service_spec.rb b/spec/services/error_tracking/list_issues_service_spec.rb
index 9d4fc62f923..df94e2c2c84 100644
--- a/spec/services/error_tracking/list_issues_service_spec.rb
+++ b/spec/services/error_tracking/list_issues_service_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ErrorTracking::ListIssuesService do
set(:user) { create(:user) }
set(:project) { create(:project) }
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
- let(:token) { 'test-token' }
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project" }
+ let(:token) { "test-token" }
let(:result) { subject.execute }
let(:error_tracking_setting) do
@@ -22,9 +22,9 @@ describe ErrorTracking::ListIssuesService do
project.add_reporter(user)
end
- describe '#execute' do
- context 'with authorized user' do
- context 'when list_sentry_issues returns issues' do
+ describe "#execute" do
+ context "with authorized user" do
+ context "when list_sentry_issues returns issues" do
let(:issues) { [:list, :of, :issues] }
before do
@@ -32,73 +32,74 @@ describe ErrorTracking::ListIssuesService do
.to receive(:list_sentry_issues).and_return(issues: issues)
end
- it 'returns the issues' do
+ it "returns the issues" do
expect(result).to eq(status: :success, issues: issues)
end
end
- context 'when list_sentry_issues returns nil' do
+ context "when list_sentry_issues returns nil" do
before do
expect(error_tracking_setting)
.to receive(:list_sentry_issues).and_return(nil)
end
- it 'result is not ready' do
+ it "result is not ready" do
expect(result).to eq(
- status: :error, http_status: :no_content, message: 'Not ready. Try again later')
+ status: :error, http_status: :no_content, message: "Not ready. Try again later"
+ )
end
end
- context 'when list_sentry_issues returns error' do
+ context "when list_sentry_issues returns error" do
before do
allow(error_tracking_setting)
.to receive(:list_sentry_issues)
- .and_return(error: 'Sentry response status code: 401')
+ .and_return(error: "Sentry response status code: 401")
end
- it 'returns the error' do
+ it "returns the error" do
expect(result).to eq(
status: :error,
http_status: :bad_request,
- message: 'Sentry response status code: 401'
+ message: "Sentry response status code: 401"
)
end
end
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
let(:unauthorized_user) { create(:user) }
subject { described_class.new(project, unauthorized_user) }
- it 'returns error' do
+ it "returns error" do
result = subject.execute
expect(result).to include(
status: :error,
- message: 'Access denied',
+ message: "Access denied",
http_status: :unauthorized
)
end
end
- context 'with error tracking disabled' do
+ context "with error tracking disabled" do
before do
error_tracking_setting.enabled = false
end
- it 'raises error' do
+ it "raises error" do
result = subject.execute
- expect(result).to include(status: :error, message: 'Error Tracking is not enabled')
+ expect(result).to include(status: :error, message: "Error Tracking is not enabled")
end
end
end
- describe '#sentry_external_url' do
- let(:external_url) { 'https://sentrytest.gitlab.com/sentry-org/sentry-project' }
+ describe "#sentry_external_url" do
+ let(:external_url) { "https://sentrytest.gitlab.com/sentry-org/sentry-project" }
- it 'calls ErrorTracking::ProjectErrorTrackingSetting' do
+ it "calls ErrorTracking::ProjectErrorTrackingSetting" do
expect(error_tracking_setting).to receive(:sentry_external_url).and_call_original
subject.external_url
diff --git a/spec/services/error_tracking/list_projects_service_spec.rb b/spec/services/error_tracking/list_projects_service_spec.rb
index 9f25a633deb..e476e446e4c 100644
--- a/spec/services/error_tracking/list_projects_service_spec.rb
+++ b/spec/services/error_tracking/list_projects_service_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ErrorTracking::ListProjectsService do
set(:user) { create(:user) }
set(:project) { create(:project) }
- let(:sentry_url) { 'https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project' }
- let(:token) { 'test-token' }
- let(:new_api_host) { 'https://gitlab.com/' }
- let(:new_token) { 'new-token' }
+ let(:sentry_url) { "https://sentrytest.gitlab.com/api/0/projects/sentry-org/sentry-project" }
+ let(:token) { "test-token" }
+ let(:new_api_host) { "https://gitlab.com/" }
+ let(:new_token) { "new-token" }
let(:params) { ActionController::Parameters.new(api_host: new_api_host, token: new_token) }
let(:error_tracking_setting) do
@@ -22,24 +22,24 @@ describe ErrorTracking::ListProjectsService do
project.add_reporter(user)
end
- describe '#execute' do
+ describe "#execute" do
let(:result) { subject.execute }
- context 'with authorized user' do
+ context "with authorized user" do
before do
expect(project).to receive(:error_tracking_setting).at_least(:once)
.and_return(error_tracking_setting)
end
- context 'set model attributes to new values' do
- let(:new_api_url) { new_api_host + 'api/0/projects/' }
+ context "set model attributes to new values" do
+ let(:new_api_url) { new_api_host + "api/0/projects/" }
before do
expect(error_tracking_setting).to receive(:list_sentry_projects)
- .and_return({ projects: [] })
+ .and_return({projects: []})
end
- it 'uses new api_url and token' do
+ it "uses new api_url and token" do
subject.execute
expect(error_tracking_setting.api_url).to eq(new_api_url)
@@ -50,22 +50,22 @@ describe ErrorTracking::ListProjectsService do
end
end
- context 'sentry client raises exception' do
+ context "sentry client raises exception" do
before do
expect(error_tracking_setting).to receive(:list_sentry_projects)
- .and_raise(Sentry::Client::Error, 'Sentry response status code: 500')
+ .and_raise(Sentry::Client::Error, "Sentry response status code: 500")
end
- it 'returns error response' do
- expect(result[:message]).to eq('Sentry response status code: 500')
+ it "returns error response" do
+ expect(result[:message]).to eq("Sentry response status code: 500")
expect(result[:http_status]).to eq(:bad_request)
end
end
- context 'with invalid url' do
+ context "with invalid url" do
let(:params) do
ActionController::Parameters.new(
- api_host: 'https://localhost',
+ api_host: "https://localhost",
token: new_token
)
end
@@ -74,13 +74,13 @@ describe ErrorTracking::ListProjectsService do
error_tracking_setting.enabled = false
end
- it 'returns error' do
- expect(result[:message]).to start_with('Api url is blocked')
+ it "returns error" do
+ expect(result[:message]).to start_with("Api url is blocked")
expect(error_tracking_setting).not_to be_valid
end
end
- context 'when list_sentry_projects returns projects' do
+ context "when list_sentry_projects returns projects" do
let(:projects) { [:list, :of, :projects] }
before do
@@ -88,23 +88,23 @@ describe ErrorTracking::ListProjectsService do
.to receive(:list_sentry_projects).and_return(projects: projects)
end
- it 'returns the projects' do
+ it "returns the projects" do
expect(result).to eq(status: :success, projects: projects)
end
end
end
- context 'with unauthorized user' do
+ context "with unauthorized user" do
before do
project.add_guest(user)
end
- it 'returns error' do
- expect(result).to include(status: :error, message: 'access denied')
+ it "returns error" do
+ expect(result).to include(status: :error, message: "access denied")
end
end
- context 'with error tracking disabled' do
+ context "with error tracking disabled" do
before do
expect(project).to receive(:error_tracking_setting).at_least(:once)
.and_return(error_tracking_setting)
@@ -114,14 +114,14 @@ describe ErrorTracking::ListProjectsService do
error_tracking_setting.enabled = false
end
- it 'ignores enabled flag' do
+ it "ignores enabled flag" do
expect(result).to include(status: :success, projects: [])
end
end
- context 'error_tracking_setting is nil' do
+ context "error_tracking_setting is nil" do
let(:error_tracking_setting) { build(:project_error_tracking_setting) }
- let(:new_api_url) { new_api_host + 'api/0/projects/' }
+ let(:new_api_url) { new_api_host + "api/0/projects/" }
before do
expect(project).to receive(:build_error_tracking_setting).once
@@ -131,7 +131,7 @@ describe ErrorTracking::ListProjectsService do
.and_return(projects: [:project1, :project2])
end
- it 'builds a new error_tracking_setting' do
+ it "builds a new error_tracking_setting" do
expect(project.error_tracking_setting).to be_nil
expect(result[:projects]).to eq([:project1, :project2])
diff --git a/spec/services/event_create_service_spec.rb b/spec/services/event_create_service_spec.rb
index 443665c9959..d6361f3d70a 100644
--- a/spec/services/event_create_service_spec.rb
+++ b/spec/services/event_create_service_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe EventCreateService do
let(:service) { described_class.new }
- describe 'Issues' do
- describe '#open_issue' do
+ describe "Issues" do
+ describe "#open_issue" do
let(:issue) { create(:issue) }
it { expect(service.open_issue(issue, issue.author)).to be_truthy }
@@ -14,7 +14,7 @@ describe EventCreateService do
end
end
- describe '#close_issue' do
+ describe "#close_issue" do
let(:issue) { create(:issue) }
it { expect(service.close_issue(issue, issue.author)).to be_truthy }
@@ -24,7 +24,7 @@ describe EventCreateService do
end
end
- describe '#reopen_issue' do
+ describe "#reopen_issue" do
let(:issue) { create(:issue) }
it { expect(service.reopen_issue(issue, issue.author)).to be_truthy }
@@ -35,8 +35,8 @@ describe EventCreateService do
end
end
- describe 'Merge Requests' do
- describe '#open_mr' do
+ describe "Merge Requests" do
+ describe "#open_mr" do
let(:merge_request) { create(:merge_request) }
it { expect(service.open_mr(merge_request, merge_request.author)).to be_truthy }
@@ -46,7 +46,7 @@ describe EventCreateService do
end
end
- describe '#close_mr' do
+ describe "#close_mr" do
let(:merge_request) { create(:merge_request) }
it { expect(service.close_mr(merge_request, merge_request.author)).to be_truthy }
@@ -56,7 +56,7 @@ describe EventCreateService do
end
end
- describe '#merge_mr' do
+ describe "#merge_mr" do
let(:merge_request) { create(:merge_request) }
it { expect(service.merge_mr(merge_request, merge_request.author)).to be_truthy }
@@ -66,7 +66,7 @@ describe EventCreateService do
end
end
- describe '#reopen_mr' do
+ describe "#reopen_mr" do
let(:merge_request) { create(:merge_request) }
it { expect(service.reopen_mr(merge_request, merge_request.author)).to be_truthy }
@@ -77,10 +77,10 @@ describe EventCreateService do
end
end
- describe 'Milestone' do
+ describe "Milestone" do
let(:user) { create :user }
- describe '#open_milestone' do
+ describe "#open_milestone" do
let(:milestone) { create(:milestone) }
it { expect(service.open_milestone(milestone, user)).to be_truthy }
@@ -90,7 +90,7 @@ describe EventCreateService do
end
end
- describe '#close_mr' do
+ describe "#close_mr" do
let(:milestone) { create(:milestone) }
it { expect(service.close_milestone(milestone, user)).to be_truthy }
@@ -100,7 +100,7 @@ describe EventCreateService do
end
end
- describe '#destroy_mr' do
+ describe "#destroy_mr" do
let(:milestone) { create(:milestone) }
it { expect(service.destroy_milestone(milestone, user)).to be_truthy }
@@ -111,7 +111,7 @@ describe EventCreateService do
end
end
- describe '#push', :clean_gitlab_redis_shared_state do
+ describe "#push", :clean_gitlab_redis_shared_state do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -119,22 +119,22 @@ describe EventCreateService do
{
commits: [
{
- id: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
- message: 'This is a commit'
- }
+ id: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
+ message: "This is a commit",
+ },
],
- before: '0000000000000000000000000000000000000000',
- after: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
+ before: "0000000000000000000000000000000000000000",
+ after: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
total_commits_count: 1,
- ref: 'refs/heads/my-branch'
+ ref: "refs/heads/my-branch",
}
end
- it 'creates a new event' do
+ it "creates a new event" do
expect { service.push(project, user, push_data) }.to change { Event.count }
end
- it 'creates the push event payload' do
+ it "creates the push event payload" do
expect(PushEventPayloadService).to receive(:new)
.with(an_instance_of(PushEvent), push_data)
.and_call_original
@@ -142,12 +142,12 @@ describe EventCreateService do
service.push(project, user, push_data)
end
- it 'updates user last activity' do
+ it "updates user last activity" do
expect { service.push(project, user, push_data) }
.to change { user.last_activity_on }.to(Date.today)
end
- it 'caches the last push event for the user' do
+ it "caches the last push event for the user" do
expect_any_instance_of(Users::LastPushEventService)
.to receive(:cache_last_push_event)
.with(an_instance_of(PushEvent))
@@ -155,7 +155,7 @@ describe EventCreateService do
service.push(project, user, push_data)
end
- it 'does not create any event data when an error is raised' do
+ it "does not create any event data when an error is raised" do
payload_service = double(:service)
allow(payload_service).to receive(:execute)
@@ -172,18 +172,18 @@ describe EventCreateService do
end
end
- describe 'Project' do
+ describe "Project" do
let(:user) { create :user }
let(:project) { create(:project) }
- describe '#join_project' do
+ describe "#join_project" do
subject { service.join_project(project, user) }
it { is_expected.to be_truthy }
it { expect { subject }.to change { Event.count }.from(0).to(1) }
end
- describe '#expired_leave_project' do
+ describe "#expired_leave_project" do
subject { service.expired_leave_project(project, user) }
it { is_expected.to be_truthy }
diff --git a/spec/services/events/render_service_spec.rb b/spec/services/events/render_service_spec.rb
index 075cb45e46c..bd3c967682b 100644
--- a/spec/services/events/render_service_spec.rb
+++ b/spec/services/events/render_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Events::RenderService do
- describe '#execute' do
+ describe "#execute" do
let!(:note) { build(:note) }
let!(:event) { build(:event, target: note, project: note.project) }
let!(:user) { build(:user) }
- context 'when the request format is atom' do
- it 'renders the note inside events' do
+ context "when the request format is atom" do
+ it "renders the note inside events" do
expect(Banzai::ObjectRenderer).to receive(:new)
- .with(user: user, redaction_context: { only_path: false, xhtml: true })
+ .with(user: user, redaction_context: {only_path: false, xhtml: true})
.and_call_original
expect_any_instance_of(Banzai::ObjectRenderer)
@@ -19,8 +19,8 @@ describe Events::RenderService do
end
end
- context 'when the request format is not atom' do
- it 'renders the note inside events' do
+ context "when the request format is not atom" do
+ it "renders the note inside events" do
expect(Banzai::ObjectRenderer).to receive(:new)
.with(user: user, redaction_context: {})
.and_call_original
diff --git a/spec/services/files/create_service_spec.rb b/spec/services/files/create_service_spec.rb
index 751b7160276..0ae27295ab3 100644
--- a/spec/services/files/create_service_spec.rb
+++ b/spec/services/files/create_service_spec.rb
@@ -4,7 +4,7 @@ describe Files::CreateService do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user, :commit_email) }
- let(:file_content) { 'Test file content' }
+ let(:file_content) { "Test file content" }
let(:branch_name) { project.default_branch }
let(:start_branch) { branch_name }
@@ -16,7 +16,7 @@ describe Files::CreateService do
file_content_encoding: "text",
start_project: project,
start_branch: start_branch,
- branch_name: branch_name
+ branch_name: branch_name,
}
end
@@ -29,12 +29,12 @@ describe Files::CreateService do
end
describe "#execute" do
- context 'when file matches LFS filter' do
- let(:file_path) { 'test_file.lfs' }
- let(:branch_name) { 'lfs' }
+ context "when file matches LFS filter" do
+ let(:file_path) { "test_file.lfs" }
+ let(:branch_name) { "lfs" }
- context 'with LFS disabled' do
- it 'skips gitattributes check' do
+ context "with LFS disabled" do
+ it "skips gitattributes check" do
expect(repository).not_to receive(:attributes_at)
subject.execute
@@ -43,22 +43,22 @@ describe Files::CreateService do
it "doesn't create LFS pointers" do
subject.execute
- blob = repository.blob_at('lfs', file_path)
+ blob = repository.blob_at("lfs", file_path)
expect(blob.data).not_to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
expect(blob.data).to eq(file_content)
end
end
- context 'with LFS enabled' do
+ context "with LFS enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- it 'creates an LFS pointer' do
+ it "creates an LFS pointer" do
subject.execute
- blob = repository.blob_at('lfs', file_path)
+ blob = repository.blob_at("lfs", file_path)
expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end
@@ -69,19 +69,19 @@ describe Files::CreateService do
expect(LfsObject.last.file.read).to eq file_content
end
- it 'links the LfsObject to the project' do
- expect do
+ it "links the LfsObject to the project" do
+ expect {
subject.execute
- end.to change { project.lfs_objects.count }.by(1)
+ }.to change { project.lfs_objects.count }.by(1)
end
end
end
end
- context 'commit attribute' do
- let(:file_path) { 'test-commit-attributes.txt' }
+ context "commit attribute" do
+ let(:file_path) { "test-commit-attributes.txt" }
- it 'uses the commit email' do
+ it "uses the commit email" do
subject.execute
expect(user.commit_email).not_to eq(user.email)
diff --git a/spec/services/files/delete_service_spec.rb b/spec/services/files/delete_service_spec.rb
index 309802ce733..a28be0dd8e1 100644
--- a/spec/services/files/delete_service_spec.rb
+++ b/spec/services/files/delete_service_spec.rb
@@ -5,7 +5,7 @@ describe Files::DeleteService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user, :commit_email) }
- let(:file_path) { 'files/ruby/popen.rb' }
+ let(:file_path) { "files/ruby/popen.rb" }
let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil }
let(:commit) { project.repository.head_commit }
@@ -17,18 +17,18 @@ describe Files::DeleteService do
last_commit_sha: last_commit_sha,
start_project: project,
start_branch: project.default_branch,
- branch_name: branch_name
+ branch_name: branch_name,
}
end
- shared_examples 'successfully deletes the file' do
- it 'returns a hash with the :success status' do
+ shared_examples "successfully deletes the file" do
+ it "returns a hash with the :success status" do
results = subject.execute
expect(results[:status]).to match(:success)
end
- it 'deletes the file' do
+ it "deletes the file" do
subject.execute
blob = project.repository.blob_at_branch(project.default_branch, file_path)
@@ -36,7 +36,7 @@ describe Files::DeleteService do
expect(blob).to be_nil
end
- it 'uses the commit email' do
+ it "uses the commit email" do
subject.execute
expect(user.commit_email).not_to eq(user.email)
@@ -56,18 +56,18 @@ describe Files::DeleteService do
it "returns a hash with the correct error message and a :error status " do
expect { subject.execute }
.to raise_error(Files::UpdateService::FileChangedError,
- "You are attempting to delete a file that has been previously updated.")
+ "You are attempting to delete a file that has been previously updated.")
end
end
context "when the file's last commit sha does match the supplied last_commit_sha" do
let(:last_commit_sha) { Gitlab::Git::Commit.last_for_path(project.repository, project.default_branch, file_path).sha }
- it_behaves_like 'successfully deletes the file'
+ it_behaves_like "successfully deletes the file"
end
context "when the last_commit_sha is not supplied" do
- it_behaves_like 'successfully deletes the file'
+ it_behaves_like "successfully deletes the file"
end
end
end
diff --git a/spec/services/files/multi_service_spec.rb b/spec/services/files/multi_service_spec.rb
index 84c48d63c64..3e1a8a3d3b8 100644
--- a/spec/services/files/multi_service_spec.rb
+++ b/spec/services/files/multi_service_spec.rb
@@ -7,11 +7,11 @@ describe Files::MultiService do
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:branch_name) { project.default_branch }
- let(:original_file_path) { 'files/ruby/popen.rb' }
- let(:new_file_path) { 'files/ruby/popen.rb' }
- let(:file_content) { 'New content' }
- let(:action) { 'update' }
- let(:commit_message) { 'Update File' }
+ let(:original_file_path) { "files/ruby/popen.rb" }
+ let(:new_file_path) { "files/ruby/popen.rb" }
+ let(:file_content) { "New content" }
+ let(:action) { "update" }
+ let(:commit_message) { "Update File" }
let!(:original_commit_id) do
Gitlab::Git::Commit.last_for_path(project.repository, branch_name, original_file_path).sha
@@ -23,7 +23,7 @@ describe Files::MultiService do
file_path: new_file_path,
previous_path: original_file_path,
content: file_content,
- last_commit_id: original_commit_id
+ last_commit_id: original_commit_id,
}
end
@@ -34,7 +34,7 @@ describe Files::MultiService do
commit_message: commit_message,
branch_name: branch_name,
start_branch: branch_name,
- actions: actions
+ actions: actions,
}
end
@@ -42,19 +42,19 @@ describe Files::MultiService do
project.add_maintainer(user)
end
- describe '#execute' do
- context 'with a valid action' do
- it 'returns a hash with the :success status' do
+ describe "#execute" do
+ context "with a valid action" do
+ it "returns a hash with the :success status" do
results = subject.execute
expect(results[:status]).to eq(:success)
end
end
- context 'with an invalid action' do
- let(:action) { 'rename' }
+ context "with an invalid action" do
+ let(:action) { "rename" }
- it 'returns a hash with the :error status' do
+ it "returns a hash with the :error status" do
results = subject.execute
expect(results[:status]).to eq(:error)
@@ -62,13 +62,13 @@ describe Files::MultiService do
end
end
- describe 'Updating files' do
- context 'when the file has been previously updated' do
+ describe "Updating files" do
+ context "when the file has been previously updated" do
before do
update_file(original_file_path)
end
- it 'rejects the commit' do
+ it "rejects the commit" do
results = subject.execute
expect(results[:status]).to eq(:error)
@@ -76,8 +76,8 @@ describe Files::MultiService do
end
end
- context 'when the file have not been modified' do
- it 'accepts the commit' do
+ context "when the file have not been modified" do
+ it "accepts the commit" do
results = subject.execute
expect(results[:status]).to eq(:success)
@@ -85,31 +85,31 @@ describe Files::MultiService do
end
end
- describe 'changing execute_filemode of a file' do
- let(:commit_message) { 'Chmod +x file' }
+ describe "changing execute_filemode of a file" do
+ let(:commit_message) { "Chmod +x file" }
let(:file_path) { original_file_path }
let(:default_action) do
{
- action: 'chmod',
+ action: "chmod",
file_path: file_path,
- execute_filemode: true
+ execute_filemode: true,
}
end
- it 'accepts the commit' do
+ it "accepts the commit" do
results = subject.execute
expect(results[:status]).to eq(:success)
end
- it 'updates the execute_filemode of the file' do
- expect { subject.execute }.to change { repository.blob_at_branch(branch_name, file_path).mode }.from('100644').to('100755')
+ it "updates the execute_filemode of the file" do
+ expect { subject.execute }.to change { repository.blob_at_branch(branch_name, file_path).mode }.from("100644").to("100755")
end
context "when the file doesn't exists" do
- let(:file_path) { 'files/wrong_path.rb' }
+ let(:file_path) { "files/wrong_path.rb" }
- it 'rejects the commit' do
+ it "rejects the commit" do
results = subject.execute
expect(results[:status]).to eq(:error)
@@ -118,35 +118,35 @@ describe Files::MultiService do
end
end
- context 'when moving a file' do
- let(:action) { 'move' }
- let(:new_file_path) { 'files/ruby/new_popen.rb' }
+ context "when moving a file" do
+ let(:action) { "move" }
+ let(:new_file_path) { "files/ruby/new_popen.rb" }
let(:result) { subject.execute }
let(:blob) { repository.blob_at_branch(branch_name, new_file_path) }
- context 'when original file has been updated' do
+ context "when original file has been updated" do
before do
update_file(original_file_path)
end
- it 'rejects the commit' do
+ it "rejects the commit" do
expect(result[:status]).to eq(:error)
expect(result[:message]).to match(original_file_path)
end
end
- context 'when original file has not been updated' do
- it 'moves the file' do
+ context "when original file has not been updated" do
+ it "moves the file" do
expect(result[:status]).to eq(:success)
expect(blob).to be_present
expect(blob.data).to eq(file_content)
end
- context 'when content is nil' do
+ context "when content is nil" do
let(:file_content) { nil }
- it 'moves the existing content untouched' do
+ it "moves the existing content untouched" do
original_content = repository.blob_at_branch(branch_name, original_file_path).data
expect(result[:status]).to eq(:success)
@@ -155,31 +155,31 @@ describe Files::MultiService do
end
end
- context 'when content is an empty string' do
- let(:file_content) { '' }
+ context "when content is an empty string" do
+ let(:file_content) { "" }
- it 'moves the file and empties it' do
+ it "moves the file and empties it" do
expect(result[:status]).to eq(:success)
expect(blob).not_to be_nil
- expect(blob.data).to eq('')
+ expect(blob.data).to eq("")
end
end
end
end
- context 'when creating a file matching an LFS filter' do
- let(:action) { 'create' }
- let(:branch_name) { 'lfs' }
- let(:new_file_path) { 'test_file.lfs' }
+ context "when creating a file matching an LFS filter" do
+ let(:action) { "create" }
+ let(:branch_name) { "lfs" }
+ let(:new_file_path) { "test_file.lfs" }
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- it 'creates an LFS pointer' do
+ it "creates an LFS pointer" do
subject.execute
- blob = repository.blob_at('lfs', new_file_path)
+ blob = repository.blob_at("lfs", new_file_path)
expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end
@@ -190,15 +190,15 @@ describe Files::MultiService do
expect(LfsObject.last.file.read).to eq file_content
end
- context 'with base64 encoded content' do
- let(:raw_file_content) { 'Raw content' }
+ context "with base64 encoded content" do
+ let(:raw_file_content) { "Raw content" }
let(:file_content) { Base64.encode64(raw_file_content) }
- let(:actions) { [default_action.merge(encoding: 'base64')] }
+ let(:actions) { [default_action.merge(encoding: "base64")] }
- it 'creates an LFS pointer' do
+ it "creates an LFS pointer" do
subject.execute
- blob = repository.blob_at('lfs', new_file_path)
+ blob = repository.blob_at("lfs", new_file_path)
expect(blob.data).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end
@@ -210,24 +210,24 @@ describe Files::MultiService do
end
end
- it 'links the LfsObject to the project' do
- expect do
+ it "links the LfsObject to the project" do
+ expect {
subject.execute
- end.to change { project.lfs_objects.count }.by(1)
+ }.to change { project.lfs_objects.count }.by(1)
end
end
- context 'when file status validation is skipped' do
- let(:action) { 'create' }
- let(:new_file_path) { 'files/ruby/new_file.rb' }
+ context "when file status validation is skipped" do
+ let(:action) { "create" }
+ let(:new_file_path) { "files/ruby/new_file.rb" }
- it 'does not check the last commit' do
+ it "does not check the last commit" do
expect(Gitlab::Git::Commit).not_to receive(:last_for_path)
subject.execute
end
- it 'creates the file' do
+ it "creates the file" do
subject.execute
blob = project.repository.blob_at_branch(branch_name, new_file_path)
@@ -242,8 +242,8 @@ describe Files::MultiService do
file_path: path,
start_branch: branch_name,
branch_name: branch_name,
- commit_message: 'Update file',
- file_content: 'New content'
+ commit_message: "Update file",
+ file_content: "New content",
}
Files::UpdateService.new(project, user, params).execute
diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb
index 23db35c2418..f1a769b5a61 100644
--- a/spec/services/files/update_service_spec.rb
+++ b/spec/services/files/update_service_spec.rb
@@ -5,8 +5,8 @@ describe Files::UpdateService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user, :commit_email) }
- let(:file_path) { 'files/ruby/popen.rb' }
- let(:new_contents) { 'New Content' }
+ let(:file_path) { "files/ruby/popen.rb" }
+ let(:new_contents) { "New Content" }
let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil }
let(:commit) { project.repository.commit }
@@ -20,7 +20,7 @@ describe Files::UpdateService do
last_commit_sha: last_commit_sha,
start_project: project,
start_branch: project.default_branch,
- branch_name: branch_name
+ branch_name: branch_name,
}
end
@@ -35,7 +35,7 @@ describe Files::UpdateService do
it "returns a hash with the correct error message and a :error status " do
expect { subject.execute }
.to raise_error(Files::UpdateService::FileChangedError,
- "You are attempting to update a file that has changed since you started editing it.")
+ "You are attempting to update a file that has changed since you started editing it.")
end
end
@@ -56,7 +56,7 @@ describe Files::UpdateService do
expect(results.data).to eq(new_contents)
end
- it 'uses the commit email' do
+ it "uses the commit email" do
subject.execute
expect(user.commit_email).not_to eq(user.email)
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index e8fce951155..562bb08736d 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GitPushService, services: true do
include RepoHelpers
@@ -8,70 +8,70 @@ describe GitPushService, services: true do
let(:blankrev) { Gitlab::Git::BLANK_SHA }
let(:oldrev) { sample_commit.parent_id }
let(:newrev) { sample_commit.id }
- let(:ref) { 'refs/heads/master' }
+ let(:ref) { "refs/heads/master" }
before do
project.add_maintainer(user)
end
- describe 'with remote mirrors' do
+ describe "with remote mirrors" do
let(:project) { create(:project, :repository, :remote_mirror) }
subject do
described_class.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref)
end
- context 'when remote mirror feature is enabled' do
- it 'fails stuck remote mirrors' do
+ context "when remote mirror feature is enabled" do
+ it "fails stuck remote mirrors" do
allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors)
expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!)
subject.execute
end
- it 'updates remote mirrors' do
+ it "updates remote mirrors" do
expect(project).to receive(:update_remote_mirrors)
subject.execute
end
end
- context 'when remote mirror feature is disabled' do
+ context "when remote mirror feature is disabled" do
before do
stub_application_setting(mirror_available: false)
end
- context 'with remote mirrors global setting overridden' do
+ context "with remote mirrors global setting overridden" do
before do
project.remote_mirror_available_overridden = true
end
- it 'fails stuck remote mirrors' do
+ it "fails stuck remote mirrors" do
allow(project).to receive(:update_remote_mirrors).and_return(project.remote_mirrors)
expect(project).to receive(:mark_stuck_remote_mirrors_as_failed!)
subject.execute
end
- it 'updates remote mirrors' do
+ it "updates remote mirrors" do
expect(project).to receive(:update_remote_mirrors)
subject.execute
end
end
- context 'without remote mirrors global setting overridden' do
+ context "without remote mirrors global setting overridden" do
before do
project.remote_mirror_available_overridden = false
end
- it 'does not fails stuck remote mirrors' do
+ it "does not fails stuck remote mirrors" do
expect(project).not_to receive(:mark_stuck_remote_mirrors_as_failed!)
subject.execute
end
- it 'does not updates remote mirrors' do
+ it "does not updates remote mirrors" do
expect(project).not_to receive(:update_remote_mirrors)
subject.execute
@@ -80,51 +80,51 @@ describe GitPushService, services: true do
end
end
- describe 'Push branches' do
+ describe "Push branches" do
subject do
execute_service(project, user, oldrev, newrev, ref)
end
- context 'new branch' do
+ context "new branch" do
let(:oldrev) { blankrev }
it { is_expected.to be_truthy }
- it 'calls the after_push_commit hook' do
- expect(project.repository).to receive(:after_push_commit).with('master')
+ it "calls the after_push_commit hook" do
+ expect(project.repository).to receive(:after_push_commit).with("master")
subject
end
- it 'calls the after_create_branch hook' do
+ it "calls the after_create_branch hook" do
expect(project.repository).to receive(:after_create_branch)
subject
end
end
- context 'existing branch' do
+ context "existing branch" do
it { is_expected.to be_truthy }
- it 'calls the after_push_commit hook' do
- expect(project.repository).to receive(:after_push_commit).with('master')
+ it "calls the after_push_commit hook" do
+ expect(project.repository).to receive(:after_push_commit).with("master")
subject
end
end
- context 'rm branch' do
+ context "rm branch" do
let(:newrev) { blankrev }
it { is_expected.to be_truthy }
- it 'calls the after_push_commit hook' do
- expect(project.repository).to receive(:after_push_commit).with('master')
+ it "calls the after_push_commit hook" do
+ expect(project.repository).to receive(:after_push_commit).with("master")
subject
end
- it 'calls the after_remove_branch hook' do
+ it "calls the after_remove_branch hook" do
expect(project.repository).to receive(:after_remove_branch)
subject
@@ -137,7 +137,7 @@ describe GitPushService, services: true do
subject { push_data_from_service(project, user, oldrev, newrev, ref) }
- it { is_expected.to include(object_kind: 'push') }
+ it { is_expected.to include(object_kind: "push") }
it { is_expected.to include(before: oldrev) }
it { is_expected.to include(after: newrev) }
it { is_expected.to include(ref: ref) }
@@ -158,7 +158,7 @@ describe GitPushService, services: true do
subject { push_data_from_service(project, user, oldrev, newrev, ref)[:commits] }
it { is_expected.to be_an(Array) }
- it 'has 1 element' do
+ it "has 1 element" do
expect(subject.size).to eq(1)
end
@@ -174,9 +174,9 @@ describe GitPushService, services: true do
Gitlab.config.gitlab.url,
project.namespace.to_param,
project.to_param,
- 'commit',
- commit.id
- ].join('/')
+ "commit",
+ commit.id,
+ ].join("/")
)
end
@@ -208,14 +208,14 @@ describe GitPushService, services: true do
let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) }
let(:event) { Event.find_by_action(Event::PUSHED) }
- it 'generates a push event with one commit' do
+ it "generates a push event with one commit" do
expect(event).to be_an_instance_of(PushEvent)
expect(event.project).to eq(project)
expect(event.action).to eq(Event::PUSHED)
expect(event.push_event_payload).to be_an_instance_of(PushEventPayload)
expect(event.push_event_payload.commit_from).to eq(oldrev)
expect(event.push_event_payload.commit_to).to eq(newrev)
- expect(event.push_event_payload.ref).to eq('master')
+ expect(event.push_event_payload.ref).to eq("master")
expect(event.push_event_payload.commit_count).to eq(1)
end
end
@@ -224,14 +224,14 @@ describe GitPushService, services: true do
let!(:new_branch_data) { push_data_from_service(project, user, Gitlab::Git::BLANK_SHA, newrev, ref) }
let(:event) { Event.find_by_action(Event::PUSHED) }
- it 'generates a push event with more than one commit' do
+ it "generates a push event with more than one commit" do
expect(event).to be_an_instance_of(PushEvent)
expect(event.project).to eq(project)
expect(event.action).to eq(Event::PUSHED)
expect(event.push_event_payload).to be_an_instance_of(PushEventPayload)
expect(event.push_event_payload.commit_from).to be_nil
expect(event.push_event_payload.commit_to).to eq(newrev)
- expect(event.push_event_payload.ref).to eq('master')
+ expect(event.push_event_payload.ref).to eq("master")
expect(event.push_event_payload.commit_count).to be > 1
end
end
@@ -239,12 +239,12 @@ describe GitPushService, services: true do
context "Updates merge requests" do
it "when pushing a new branch for the first time" do
expect(UpdateMergeRequestsWorker).to receive(:perform_async)
- .with(project.id, user.id, blankrev, 'newrev', ref)
- execute_service(project, user, blankrev, 'newrev', ref )
+ .with(project.id, user.id, blankrev, "newrev", ref)
+ execute_service(project, user, blankrev, "newrev", ref)
end
end
- describe 'system hooks' do
+ describe "system hooks" do
let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) }
let!(:system_hooks_service) { SystemHooksService.new }
@@ -262,22 +262,22 @@ describe GitPushService, services: true do
describe "Updates git attributes" do
context "for default branch" do
it "calls the copy attributes method for the first push to the default branch" do
- expect(project.repository).to receive(:copy_gitattributes).with('master')
+ expect(project.repository).to receive(:copy_gitattributes).with("master")
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
end
it "calls the copy attributes method for changes to the default branch" do
expect(project.repository).to receive(:copy_gitattributes).with(ref)
- execute_service(project, user, 'oldrev', 'newrev', ref)
+ execute_service(project, user, "oldrev", "newrev", ref)
end
end
context "for non-default branch" do
before do
# Make sure the "default" branch is different
- allow(project).to receive(:default_branch).and_return('not-master')
+ allow(project).to receive(:default_branch).and_return("not-master")
end
it "does not call copy attributes method" do
@@ -293,7 +293,7 @@ describe GitPushService, services: true do
it "when pushing a branch for the first time" do
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
expect(project.protected_branches).not_to be_empty
expect(project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
expect(project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
@@ -304,7 +304,7 @@ describe GitPushService, services: true do
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
expect(project.protected_branches).to be_empty
end
@@ -314,7 +314,7 @@ describe GitPushService, services: true do
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
expect(project.protected_branches).not_to be_empty
expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::DEVELOPER])
@@ -324,12 +324,12 @@ describe GitPushService, services: true do
it "when pushing a branch for the first time with an existing branch permission configured" do
stub_application_setting(default_branch_protection: Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
- create(:protected_branch, :no_one_can_push, :developers_can_merge, project: project, name: 'master')
+ create(:protected_branch, :no_one_can_push, :developers_can_merge, project: project, name: "master")
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
expect_any_instance_of(ProtectedBranches::CreateService).not_to receive(:execute)
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
expect(project.protected_branches).not_to be_empty
expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::NO_ACCESS])
@@ -341,7 +341,7 @@ describe GitPushService, services: true do
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
- execute_service(project, user, blankrev, 'newrev', ref)
+ execute_service(project, user, blankrev, "newrev", ref)
expect(project.protected_branches).not_to be_empty
expect(project.protected_branches.first.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
expect(project.protected_branches.first.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::DEVELOPER])
@@ -349,7 +349,7 @@ describe GitPushService, services: true do
it "when pushing new commits to existing branch" do
expect(project).to receive(:execute_hooks)
- execute_service(project, user, 'oldrev', 'newrev', ref)
+ execute_service(project, user, "oldrev", "newrev", ref)
end
end
end
@@ -392,8 +392,8 @@ describe GitPushService, services: true do
it "defaults to the pushing user if the commit's author is not known" do
allow(commit).to receive_messages(
- author_name: 'unknown name',
- author_email: 'unknown@email.com'
+ author_name: "unknown name",
+ author_email: "unknown@email.com"
)
expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, user)
@@ -406,7 +406,7 @@ describe GitPushService, services: true do
expect(SystemNoteService).to receive(:cross_reference).with(issue, commit, commit_author)
- execute_service(project, user, blankrev, newrev, 'refs/heads/other')
+ execute_service(project, user, blankrev, newrev, "refs/heads/other")
end
end
@@ -435,13 +435,13 @@ describe GitPushService, services: true do
end
context "while saving the 'first_mentioned_in_commit_at' metric for an issue" do
- it 'sets the metric for referenced issues' do
+ it "sets the metric for referenced issues" do
execute_service(project, user, oldrev, newrev, ref)
expect(issue.reload.metrics.first_mentioned_in_commit_at).to be_like_time(commit_time)
end
- it 'does not set the metric for non-referenced issues' do
+ it "does not set the metric for non-referenced issues" do
non_referenced_issue = create(:issue, project: project)
execute_service(project, user, oldrev, newrev, ref)
@@ -493,7 +493,7 @@ describe GitPushService, services: true do
context "to non-default branches" do
before do
# Make sure the "default" branch is different
- allow(project).to receive(:default_branch).and_return('not-master')
+ allow(project).to receive(:default_branch).and_return("not-master")
end
it "creates cross-reference notes" do
@@ -522,7 +522,7 @@ describe GitPushService, services: true do
issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern),
safe_message: message,
author_name: commit_author.name,
- author_email: commit_author.email
+ author_email: commit_author.email,
})
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
@@ -540,7 +540,7 @@ describe GitPushService, services: true 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('JIRA-1')).with(
+ expect(WebMock).to have_requested(:post, jira_api_comment_url("JIRA-1")).with(
body: /mentioned this issue in/
).once
end
@@ -550,12 +550,12 @@ describe GitPushService, services: true do
let(:message) { "this is some work.\n\ncloses JIRA-1" }
let(:comment_body) do
{
- body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.full_path}/commit/#{closing_commit.id}]."
+ body: "Issue solved with [#{closing_commit.id}|http://#{Gitlab.config.gitlab.host}/#{project.full_path}/commit/#{closing_commit.id}].",
}.to_json
end
before do
- open_issue = JIRA::Resource::Issue.new(jira_tracker.client, attrs: { "id" => "JIRA-1" })
+ open_issue = JIRA::Resource::Issue.new(jira_tracker.client, attrs: {"id" => "JIRA-1"})
closed_issue = open_issue.dup
allow(open_issue).to receive(:resolution).and_return(false)
allow(closed_issue).to receive(:resolution).and_return(true)
@@ -568,20 +568,20 @@ describe GitPushService, services: true do
it "initiates one api call to jira server to close the issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).to have_requested(:post, jira_api_transition_url('JIRA-1')).once
+ expect(WebMock).to have_requested(:post, jira_api_transition_url("JIRA-1")).once
end
it "initiates one api call to jira server to comment on the issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with(
+ expect(WebMock).to have_requested(:post, jira_api_comment_url("JIRA-1")).with(
body: comment_body
).once
end
end
context "using internal issue reference" do
- context 'when internal issues are disabled' do
+ context "when internal issues are disabled" do
before do
project.issues_enabled = false
project.save!
@@ -591,32 +591,32 @@ describe GitPushService, services: true do
it "does not initiates one api call to jira server to close the issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).not_to have_requested(:post, jira_api_transition_url('JIRA-1'))
+ expect(WebMock).not_to have_requested(:post, jira_api_transition_url("JIRA-1"))
end
it "does not initiates one api call to jira server to comment on the issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).not_to have_requested(:post, jira_api_comment_url('JIRA-1')).with(
+ expect(WebMock).not_to have_requested(:post, jira_api_comment_url("JIRA-1")).with(
body: comment_body
).once
end
end
- context 'when internal issues are enabled' do
+ context "when internal issues are enabled" do
let(:issue) { create(:issue, project: project) }
let(:message) { "this is some work.\n\ncloses JIRA-1 \n\n closes #{issue.to_reference}" }
it "initiates one api call to jira server to close the jira issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).to have_requested(:post, jira_api_transition_url('JIRA-1')).once
+ expect(WebMock).to have_requested(:post, jira_api_transition_url("JIRA-1")).once
end
it "initiates one api call to jira server to comment on the jira issue" do
execute_service(project, commit_author, oldrev, newrev, ref)
- expect(WebMock).to have_requested(:post, jira_api_comment_url('JIRA-1')).with(
+ expect(WebMock).to have_requested(:post, jira_api_comment_url("JIRA-1")).with(
body: comment_body
).once
end
@@ -639,14 +639,14 @@ describe GitPushService, services: true do
describe "empty project" do
let(:project) { create(:project_empty_repo) }
- let(:new_ref) { 'refs/heads/feature' }
+ let(:new_ref) { "refs/heads/feature" }
before do
- allow(project).to receive(:default_branch).and_return('feature')
- expect(project).to receive(:change_head) { 'feature'}
+ allow(project).to receive(:default_branch).and_return("feature")
+ expect(project).to receive(:change_head) { "feature"}
end
- it 'push to first branch updates HEAD' do
+ it "push to first branch updates HEAD" do
execute_service(project, user, blankrev, newrev, new_ref)
end
end
@@ -669,54 +669,54 @@ describe GitPushService, services: true do
Gitlab::Redis::SharedState.with { |conn| conn.flushall }
end
- it 'does not perform housekeeping when not needed' do
+ it "does not perform housekeeping when not needed" do
expect(housekeeping).not_to receive(:execute)
execute_service(project, user, oldrev, newrev, ref)
end
- context 'when housekeeping is needed' do
+ context "when housekeeping is needed" do
before do
allow(housekeeping).to receive(:needed?).and_return(true)
end
- it 'performs housekeeping' do
+ it "performs housekeeping" do
expect(housekeeping).to receive(:execute)
execute_service(project, user, oldrev, newrev, ref)
end
- it 'does not raise an exception' do
+ it "does not raise an exception" do
allow(housekeeping).to receive(:try_obtain_lease).and_return(false)
execute_service(project, user, oldrev, newrev, ref)
end
end
- it 'increments the push counter' do
+ it "increments the push counter" do
expect(housekeeping).to receive(:increment!)
execute_service(project, user, oldrev, newrev, ref)
end
end
- describe '#update_caches' do
+ describe "#update_caches" do
let(:service) do
described_class.new(project,
- user,
- oldrev: oldrev,
- newrev: newrev,
- ref: ref)
+ user,
+ oldrev: oldrev,
+ newrev: newrev,
+ ref: ref)
end
- context 'on the default branch' do
+ context "on the default branch" do
before do
allow(service).to receive(:default_branch?).and_return(true)
end
- it 'flushes the caches of any special files that have been changed' do
+ it "flushes the caches of any special files that have been changed" do
commit = double(:commit)
- diff = double(:diff, new_path: 'README.md')
+ diff = double(:diff, new_path: "README.md")
expect(commit).to receive(:raw_deltas)
.and_return([diff])
@@ -724,20 +724,20 @@ describe GitPushService, services: true do
service.push_commits = [commit]
expect(ProjectCacheWorker).to receive(:perform_async)
- .with(project.id, %i(readme), %i(commit_count repository_size))
+ .with(project.id, %i[readme], %i[commit_count repository_size])
service.update_caches
end
end
- context 'on a non-default branch' do
+ context "on a non-default branch" do
before do
allow(service).to receive(:default_branch?).and_return(false)
end
- it 'does not flush any conditional caches' do
+ it "does not flush any conditional caches" do
expect(ProjectCacheWorker).to receive(:perform_async)
- .with(project.id, [], %i(commit_count repository_size))
+ .with(project.id, [], %i[commit_count repository_size])
.and_call_original
service.update_caches
@@ -745,16 +745,16 @@ describe GitPushService, services: true do
end
end
- describe '#process_commit_messages' do
+ describe "#process_commit_messages" do
let(:service) do
described_class.new(project,
- user,
- oldrev: oldrev,
- newrev: newrev,
- ref: ref)
+ user,
+ oldrev: oldrev,
+ newrev: newrev,
+ ref: ref)
end
- it 'only schedules a limited number of commits' do
+ it "only schedules a limited number of commits" do
service.push_commits = Array.new(1000, double(:commit, to_hash: {}, matches_cross_reference_regex?: true))
expect(ProcessCommitWorker).to receive(:perform_async).exactly(100).times
@@ -771,38 +771,38 @@ describe GitPushService, services: true do
end
end
- describe '#update_signatures' do
+ describe "#update_signatures" do
let(:service) do
described_class.new(
project,
user,
oldrev: oldrev,
newrev: newrev,
- ref: 'refs/heads/master'
+ ref: "refs/heads/master"
)
end
- context 'when the commit has a signature' do
- context 'when the signature is already cached' do
+ context "when the commit has a signature" do
+ context "when the signature is already cached" do
before do
create(:gpg_signature, commit_sha: sample_commit.id)
end
- it 'does not queue a CreateGpgSignatureWorker' do
+ it "does not queue a CreateGpgSignatureWorker" do
expect(CreateGpgSignatureWorker).not_to receive(:perform_async)
execute_service(project, user, oldrev, newrev, ref)
end
end
- context 'when the signature is not yet cached' do
- it 'queues a CreateGpgSignatureWorker' do
+ context "when the signature is not yet cached" do
+ it "queues a CreateGpgSignatureWorker" do
expect(CreateGpgSignatureWorker).to receive(:perform_async).with([sample_commit.id], project.id)
execute_service(project, user, oldrev, newrev, ref)
end
- it 'can queue several commits to create the gpg signature' do
+ it "can queue several commits to create the gpg signature" do
allow(Gitlab::Git::Commit).to receive(:shas_with_signatures).and_return([sample_commit.id, another_sample_commit.id])
expect(CreateGpgSignatureWorker).to receive(:perform_async).with([sample_commit.id, another_sample_commit.id], project.id)
@@ -812,12 +812,12 @@ describe GitPushService, services: true do
end
end
- context 'when the commit does not have a signature' do
+ context "when the commit does not have a signature" do
before do
allow(Gitlab::Git::Commit).to receive(:shas_with_signatures).with(project.repository, [sample_commit.id]).and_return([])
end
- it 'does not queue a CreateGpgSignatureWorker' do
+ it "does not queue a CreateGpgSignatureWorker" do
expect(CreateGpgSignatureWorker).not_to receive(:perform_async).with(sample_commit.id, project.id)
execute_service(project, user, oldrev, newrev, ref)
diff --git a/spec/services/git_tag_push_service_spec.rb b/spec/services/git_tag_push_service_spec.rb
index 2699f6e7bcd..d3c3e04837d 100644
--- a/spec/services/git_tag_push_service_spec.rb
+++ b/spec/services/git_tag_push_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GitTagPushService do
include RepoHelpers
@@ -10,7 +10,7 @@ describe GitTagPushService do
let(:oldrev) { Gitlab::Git::BLANK_SHA }
let(:newrev) { "8a2a6eb295bb170b34c24c76c49ed0e9b2eaf34b" } # gitlab-test: git rev-parse refs/tags/v1.1.0
- let(:ref) { 'refs/tags/v1.1.0' }
+ let(:ref) { "refs/tags/v1.1.0" }
describe "Push tags" do
subject do
@@ -18,13 +18,13 @@ describe GitTagPushService do
service
end
- it 'flushes general cached data' do
+ it "flushes general cached data" do
expect(project.repository).to receive(:before_push_tag)
subject
end
- it 'flushes the tags cache' do
+ it "flushes the tags cache" do
expect(project.repository).to receive(:expire_tags_cache)
subject
@@ -50,7 +50,7 @@ describe GitTagPushService do
let(:tag) { project.repository.find_tag(tag_name) }
let(:commit) { tag.dereferenced_target }
- context 'annotated tag' do
+ context "annotated tag" do
let(:tag_name) { Gitlab::Git.ref_name(ref) }
before do
@@ -58,7 +58,7 @@ describe GitTagPushService do
@push_data = service.push_data
end
- it { is_expected.to include(object_kind: 'tag_push') }
+ it { is_expected.to include(object_kind: "tag_push") }
it { is_expected.to include(ref: ref) }
it { is_expected.to include(before: oldrev) }
it { is_expected.to include(after: newrev) }
@@ -80,7 +80,7 @@ describe GitTagPushService do
subject { @push_data[:commits] }
it { is_expected.to be_an(Array) }
- it 'has 1 element' do
+ it "has 1 element" do
expect(subject.size).to eq(1)
end
@@ -93,12 +93,12 @@ describe GitTagPushService do
it do
is_expected.to include(
url: [
- Gitlab.config.gitlab.url,
- project.namespace.to_param,
- project.to_param,
- 'commit',
- commit.id
- ].join('/')
+ Gitlab.config.gitlab.url,
+ project.namespace.to_param,
+ project.to_param,
+ "commit",
+ commit.id,
+ ].join("/")
)
end
@@ -112,9 +112,9 @@ describe GitTagPushService do
end
end
- context 'lightweight tag' do
- let(:tag_name) { 'light-tag' }
- let(:newrev) { '5937ac0a7beb003549fc5fd26fc247adbce4a52e' }
+ context "lightweight tag" do
+ let(:tag_name) { "light-tag" }
+ let(:newrev) { "5937ac0a7beb003549fc5fd26fc247adbce4a52e" }
let(:ref) { "refs/tags/light-tag" }
before do
@@ -128,7 +128,7 @@ describe GitTagPushService do
@push_data = service.push_data
end
- it { is_expected.to include(object_kind: 'tag_push') }
+ it { is_expected.to include(object_kind: "tag_push") }
it { is_expected.to include(ref: ref) }
it { is_expected.to include(before: oldrev) }
it { is_expected.to include(after: newrev) }
@@ -150,7 +150,7 @@ describe GitTagPushService do
subject { @push_data[:commits] }
it { is_expected.to be_an(Array) }
- it 'has 1 element' do
+ it "has 1 element" do
expect(subject.size).to eq(1)
end
@@ -163,12 +163,12 @@ describe GitTagPushService do
it do
is_expected.to include(
url: [
- Gitlab.config.gitlab.url,
- project.namespace.to_param,
- project.to_param,
- 'commit',
- commit.id
- ].join('/')
+ Gitlab.config.gitlab.url,
+ project.namespace.to_param,
+ project.to_param,
+ "commit",
+ commit.id,
+ ].join("/")
)
end
@@ -185,7 +185,7 @@ describe GitTagPushService do
describe "Webhooks" do
context "execute webhooks" do
- let(:service) { described_class.new(project, user, oldrev: 'oldrev', newrev: 'newrev', ref: 'refs/tags/v1.0.0') }
+ let(:service) { described_class.new(project, user, oldrev: "oldrev", newrev: "newrev", ref: "refs/tags/v1.0.0") }
it "when pushing tags" do
expect(project).to receive(:execute_hooks)
diff --git a/spec/services/gpg_keys/create_service_spec.rb b/spec/services/gpg_keys/create_service_spec.rb
index 1cd2625531e..f0a6b775ce6 100644
--- a/spec/services/gpg_keys/create_service_spec.rb
+++ b/spec/services/gpg_keys/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GpgKeys::CreateService do
let(:user) { create(:user) }
@@ -6,8 +6,8 @@ describe GpgKeys::CreateService do
subject { described_class.new(user, params) }
- context 'notification', :mailer do
- it 'sends a notification' do
+ context "notification", :mailer do
+ it "sends a notification" do
perform_enqueued_jobs do
subject.execute
end
@@ -15,14 +15,14 @@ describe GpgKeys::CreateService do
end
end
- it 'creates a gpg key' do
+ it "creates a gpg key" do
expect { subject.execute }.to change { user.gpg_keys.where(params).count }.by(1)
end
- context 'when the public key contains subkeys' do
+ context "when the public key contains subkeys" do
let(:params) { attributes_for(:gpg_key_with_subkeys) }
- it 'generates the gpg subkeys' do
+ it "generates the gpg subkeys" do
gpg_key = subject.execute
expect(gpg_key.subkeys.count).to eq(2)
diff --git a/spec/services/gravatar_service_spec.rb b/spec/services/gravatar_service_spec.rb
index d2cc53fe0ee..b5e56f5d176 100644
--- a/spec/services/gravatar_service_spec.rb
+++ b/spec/services/gravatar_service_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe GravatarService do
- describe '#execute' do
- let(:url) { 'http://example.com/avatar?hash=%{hash}&size=%{size}&email=%{email}&username=%{username}' }
+ describe "#execute" do
+ let(:url) { "http://example.com/avatar?hash=%{hash}&size=%{size}&email=%{email}&username=%{username}" }
before do
allow(Gitlab.config.gravatar).to receive(:plain_url).and_return(url)
end
- it 'replaces the placeholders' do
- avatar_url = described_class.new.execute('user@example.com', 100, 2, username: 'user')
+ it "replaces the placeholders" do
+ avatar_url = described_class.new.execute("user@example.com", 100, 2, username: "user")
- expect(avatar_url).to include("hash=#{Digest::MD5.hexdigest('user@example.com')}")
+ expect(avatar_url).to include("hash=#{Digest::MD5.hexdigest("user@example.com")}")
expect(avatar_url).to include("size=200")
expect(avatar_url).to include("email=user%40example.com")
expect(avatar_url).to include("username=user")
diff --git a/spec/services/groups/create_service_spec.rb b/spec/services/groups/create_service_spec.rb
index fe6a8691ae0..f731e833ecd 100644
--- a/spec/services/groups/create_service_spec.rb
+++ b/spec/services/groups/create_service_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe Groups::CreateService, '#execute' do
+describe Groups::CreateService, "#execute" do
let!(:user) { create(:user) }
- let!(:group_params) { { path: "group_path", visibility_level: Gitlab::VisibilityLevel::PUBLIC } }
+ let!(:group_params) { {path: "group_path", visibility_level: Gitlab::VisibilityLevel::PUBLIC} }
subject { service.execute }
- describe 'visibility level restrictions' do
+ describe "visibility level restrictions" do
let!(:service) { described_class.new(user, group_params) }
context "create groups without restricted visibility level" do
@@ -22,10 +22,10 @@ describe Groups::CreateService, '#execute' do
end
end
- describe 'creating a top level group' do
+ describe "creating a top level group" do
let(:service) { described_class.new(user, group_params) }
- context 'when user can create a group' do
+ context "when user can create a group" do
before do
user.update_attribute(:can_create_group, true)
end
@@ -33,7 +33,7 @@ describe Groups::CreateService, '#execute' do
it { is_expected.to be_persisted }
end
- context 'when user can not create a group' do
+ context "when user can not create a group" do
before do
user.update_attribute(:can_create_group, false)
end
@@ -42,43 +42,43 @@ describe Groups::CreateService, '#execute' do
end
end
- describe 'creating subgroup', :nested_groups do
+ describe "creating subgroup", :nested_groups do
let!(:group) { create(:group) }
let!(:service) { described_class.new(user, group_params.merge(parent_id: group.id)) }
- context 'as group owner' do
+ context "as group owner" do
before do
group.add_owner(user)
end
it { is_expected.to be_persisted }
- context 'when nested groups feature is disabled' do
- it 'does not save group and returns an error' do
+ context "when nested groups feature is disabled" do
+ it "does not save group and returns an error" do
allow(Group).to receive(:supports_nested_objects?).and_return(false)
is_expected.not_to be_persisted
- expect(subject.errors[:parent_id]).to include('You don’t have permission to create a subgroup in this group.')
+ expect(subject.errors[:parent_id]).to include("You don’t have permission to create a subgroup in this group.")
expect(subject.parent_id).to be_nil
end
end
end
- context 'when nested groups feature is enabled' do
+ context "when nested groups feature is enabled" do
before do
allow(Group).to receive(:supports_nested_objects?).and_return(true)
end
- context 'as guest' do
- it 'does not save group and returns an error' do
+ context "as guest" do
+ it "does not save group and returns an error" do
is_expected.not_to be_persisted
- expect(subject.errors[:parent_id].first).to eq('You don’t have permission to create a subgroup in this group.')
+ expect(subject.errors[:parent_id].first).to eq("You don’t have permission to create a subgroup in this group.")
expect(subject.parent_id).to be_nil
end
end
- context 'as owner' do
+ context "as owner" do
before do
group.add_owner(user)
end
@@ -88,7 +88,7 @@ describe Groups::CreateService, '#execute' do
end
end
- describe 'creating a mattermost team' do
+ describe "creating a mattermost team" do
let!(:params) { group_params.merge(create_chat_team: "true") }
let!(:service) { described_class.new(user, params) }
@@ -96,9 +96,9 @@ describe Groups::CreateService, '#execute' do
stub_mattermost_setting(enabled: true)
end
- it 'create the chat team with the group' do
+ it "create the chat team with the group" do
allow_any_instance_of(Mattermost::Team).to receive(:create)
- .and_return({ 'name' => 'tanuki', 'id' => 'lskdjfwlekfjsdifjj' })
+ .and_return({"name" => "tanuki", "id" => "lskdjfwlekfjsdifjj"})
expect { subject }.to change { ChatTeam.count }.from(0).to(1)
end
diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb
index d80d0f5a8a8..5433a10a449 100644
--- a/spec/services/groups/destroy_service_spec.rb
+++ b/spec/services/groups/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::DestroyService do
include DatabaseConnectionHelpers
@@ -23,8 +23,8 @@ describe Groups::DestroyService do
end
end
- shared_examples 'group destruction' do |async|
- context 'database records' do
+ shared_examples "group destruction" do |async|
+ context "database records" do
before do
destroy_group(group, user, async)
end
@@ -35,24 +35,24 @@ describe Groups::DestroyService do
it { expect(NotificationSetting.unscoped.all).not_to include(notification_setting) }
end
- context 'mattermost team' do
+ context "mattermost team" do
let!(:chat_team) { create(:chat_team, namespace: group) }
- it 'destroys the team too' do
+ it "destroys the team too" do
expect_any_instance_of(Mattermost::Team).to receive(:destroy)
destroy_group(group, user, async)
end
end
- context 'file system' do
- context 'Sidekiq inline' do
+ context "file system" do
+ context "Sidekiq inline" do
before do
# Run sidekiq immediately to check that renamed dir will be removed
perform_enqueued_jobs { destroy_group(group, user, async) }
end
- it 'verifies that paths have been deleted' do
+ it "verifies that paths have been deleted" do
expect(gitlab_shell.exists?(project.repository_storage, group.path)).to be_falsey
expect(gitlab_shell.exists?(project.repository_storage, remove_path)).to be_falsey
end
@@ -60,10 +60,10 @@ describe Groups::DestroyService do
end
end
- describe 'asynchronous delete' do
- it_behaves_like 'group destruction', true
+ describe "asynchronous delete" do
+ it_behaves_like "group destruction", true
- context 'Sidekiq fake' do
+ context "Sidekiq fake" do
before do
# Don't run Sidekiq to verify that group and projects are not actually destroyed
Sidekiq::Testing.fake! { destroy_group(group, user, true) }
@@ -75,7 +75,7 @@ describe Groups::DestroyService do
gitlab_shell.rm_namespace(project.repository_storage, remove_path)
end
- it 'verifies original paths and projects still exist' do
+ it "verifies original paths and projects still exist" do
expect(gitlab_shell.exists?(project.repository_storage, group.path)).to be_truthy
expect(gitlab_shell.exists?(project.repository_storage, remove_path)).to be_falsey
expect(Project.unscoped.count).to eq(1)
@@ -83,7 +83,7 @@ describe Groups::DestroyService do
end
end
- context 'potential race conditions' do
+ context "potential race conditions" do
context "when the `GroupDestroyWorker` task runs immediately" do
it "deletes the group" do
# Commit the contents of this spec's transaction so far
@@ -95,9 +95,9 @@ describe Groups::DestroyService do
# cannot be seen by any other connections / threads in this spec.
Group.connection.commit_db_transaction
- group_record = run_with_new_database_connection do |conn|
+ group_record = run_with_new_database_connection { |conn|
conn.execute("SELECT * FROM namespaces WHERE id = #{group.id}").first
- end
+ }
expect(group_record).not_to be_nil
@@ -112,9 +112,9 @@ describe Groups::DestroyService do
# it doesn't share this spec's database transaction.
Thread.new { described_class.new(group, user).async_execute }.join(5)
- group_record = run_with_new_database_connection do |conn|
+ group_record = run_with_new_database_connection { |conn|
conn.execute("SELECT * FROM namespaces WHERE id = #{group.id}").first
- end
+ }
expect(group_record).to be_nil
end
@@ -122,47 +122,47 @@ describe Groups::DestroyService do
end
end
- describe 'synchronous delete' do
- it_behaves_like 'group destruction', false
+ describe "synchronous delete" do
+ it_behaves_like "group destruction", false
end
- context 'projects in pending_delete' do
+ context "projects in pending_delete" do
before do
project.pending_delete = true
project.save
end
- it_behaves_like 'group destruction', false
+ it_behaves_like "group destruction", false
end
- context 'repository removal status is taken into account' do
- it 'raises exception' do
+ context "repository removal status is taken into account" do
+ it "raises exception" do
expect_next_instance_of(::Projects::DestroyService) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(false)
end
expect { destroy_group(group, user, false) }
- .to raise_error(Groups::DestroyService::DestroyError, "Project #{project.id} can't be deleted" )
+ .to raise_error(Groups::DestroyService::DestroyError, "Project #{project.id} can't be deleted")
end
end
- describe 'repository removal' do
+ describe "repository removal" do
before do
destroy_group(group, user, false)
end
- context 'legacy storage' do
+ context "legacy storage" do
let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: group) }
- it 'removes repository' do
+ it "removes repository" do
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let!(:project) { create(:project, :empty_repo, namespace: group) }
- it 'removes repository' do
+ it "removes repository" do
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
end
end
diff --git a/spec/services/groups/nested_create_service_spec.rb b/spec/services/groups/nested_create_service_spec.rb
index 75d6ddb0a2c..1596cdce02b 100644
--- a/spec/services/groups/nested_create_service_spec.rb
+++ b/spec/services/groups/nested_create_service_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::NestedCreateService do
let(:user) { create(:user) }
subject(:service) { described_class.new(user, params) }
- shared_examples 'with a visibility level' do
- it 'creates the group with correct visibility level' do
+ shared_examples "with a visibility level" do
+ it "creates the group with correct visibility level" do
allow(Gitlab::CurrentSettings.current_application_settings)
.to receive(:default_group_visibility) { Gitlab::VisibilityLevel::INTERNAL }
@@ -15,8 +15,8 @@ describe Groups::NestedCreateService do
expect(group.visibility_level).to eq(Gitlab::VisibilityLevel::INTERNAL)
end
- context 'adding a visibility level ' do
- it 'overwrites the visibility level' do
+ context "adding a visibility level " do
+ it "overwrites the visibility level" do
service = described_class.new(user, params.merge(visibility_level: Gitlab::VisibilityLevel::PRIVATE))
group = service.execute
@@ -26,41 +26,41 @@ describe Groups::NestedCreateService do
end
end
- describe 'without subgroups' do
- let(:params) { { group_path: 'a-group' } }
+ describe "without subgroups" do
+ let(:params) { {group_path: "a-group"} }
before do
allow(Group).to receive(:supports_nested_objects?) { false }
end
- it 'creates the group' do
+ it "creates the group" do
group = service.execute
expect(group).to be_persisted
end
- it 'returns the group if it already existed' do
- existing_group = create(:group, path: 'a-group')
+ it "returns the group if it already existed" do
+ existing_group = create(:group, path: "a-group")
expect(service.execute).to eq(existing_group)
end
- it 'raises an error when tring to create a subgroup' do
- service = described_class.new(user, group_path: 'a-group/a-sub-group')
+ it "raises an error when tring to create a subgroup" do
+ service = described_class.new(user, group_path: "a-group/a-sub-group")
- expect { service.execute }.to raise_error('Nested groups are not supported on MySQL')
+ expect { service.execute }.to raise_error("Nested groups are not supported on MySQL")
end
- it_behaves_like 'with a visibility level'
+ it_behaves_like "with a visibility level"
end
- describe 'with subgroups', :nested_groups do
- let(:params) { { group_path: 'a-group/a-sub-group' } }
+ describe "with subgroups", :nested_groups do
+ let(:params) { {group_path: "a-group/a-sub-group"} }
describe "#execute" do
- it 'returns the group if it already existed' do
- parent = create(:group, path: 'a-group')
- child = create(:group, path: 'a-sub-group', parent: parent)
+ it "returns the group if it already existed" do
+ parent = create(:group, path: "a-group")
+ child = create(:group, path: "a-sub-group", parent: parent)
parent.add_owner(user)
child.add_owner(user)
@@ -68,24 +68,24 @@ describe Groups::NestedCreateService do
expect(service.execute).to eq(child)
end
- it 'reuses a parent if it already existed' do
- parent = create(:group, path: 'a-group')
+ it "reuses a parent if it already existed" do
+ parent = create(:group, path: "a-group")
parent.add_owner(user)
expect(service.execute.parent).to eq(parent)
end
- it 'creates group and subgroup in the database' do
+ it "creates group and subgroup in the database" do
service.execute
- parent = Group.find_by_full_path('a-group')
- child = parent.children.find_by(path: 'a-sub-group')
+ parent = Group.find_by_full_path("a-group")
+ child = parent.children.find_by(path: "a-sub-group")
expect(parent).not_to be_nil
expect(child).not_to be_nil
end
- it_behaves_like 'with a visibility level'
+ it_behaves_like "with a visibility level"
end
end
end
diff --git a/spec/services/groups/transfer_service_spec.rb b/spec/services/groups/transfer_service_spec.rb
index 6b48c993c57..1b17360520c 100644
--- a/spec/services/groups/transfer_service_spec.rb
+++ b/spec/services/groups/transfer_service_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe Groups::TransferService, :postgresql do
let(:user) { create(:user) }
@@ -6,19 +6,19 @@ describe Groups::TransferService, :postgresql do
let!(:group_member) { create(:group_member, :owner, group: group, user: user) }
let(:transfer_service) { described_class.new(group, user) }
- shared_examples 'ensuring allowed transfer for a group' do
- context 'with other database than PostgreSQL' do
+ shared_examples "ensuring allowed transfer for a group" do
+ context "with other database than PostgreSQL" do
before do
allow(Group).to receive(:supports_nested_objects?).and_return(false)
end
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(new_parent_group)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(new_parent_group)
- expect(transfer_service.error).to eq('Transfer failed: Database is not supported.')
+ expect(transfer_service.error).to eq("Transfer failed: Database is not supported.")
end
end
@@ -26,37 +26,37 @@ describe Groups::TransferService, :postgresql do
let(:new_parent_group) { create(:group, :public) }
before do
- allow_any_instance_of(described_class).to receive(:update_group_attributes).and_raise(Gitlab::UpdatePathError, 'namespace directory cannot be moved')
+ allow_any_instance_of(described_class).to receive(:update_group_attributes).and_raise(Gitlab::UpdatePathError, "namespace directory cannot be moved")
create(:group_member, :owner, group: new_parent_group, user: user)
end
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(new_parent_group)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(new_parent_group)
- expect(transfer_service.error).to eq('Transfer failed: namespace directory cannot be moved')
+ expect(transfer_service.error).to eq("Transfer failed: namespace directory cannot be moved")
end
end
end
- describe '#execute' do
- context 'when transforming a group into a root group' do
+ describe "#execute" do
+ context "when transforming a group into a root group" do
let!(:group) { create(:group, :public, :nested) }
- it_behaves_like 'ensuring allowed transfer for a group'
+ it_behaves_like "ensuring allowed transfer for a group"
- context 'when the group is already a root group' do
+ context "when the group is already a root group" do
let(:group) { create(:group, :public) }
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(nil)
- expect(transfer_service.error).to eq('Transfer failed: Group is already a root group.')
+ expect(transfer_service.error).to eq("Transfer failed: Group is already a root group.")
end
end
- context 'when the user does not have the right policies' do
+ context "when the user does not have the right policies" do
let!(:group_member) { create(:group_member, :guest, group: group, user: user) }
it "should return false" do
@@ -69,24 +69,24 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when there is a group with the same path' do
- let!(:group) { create(:group, :public, :nested, path: 'not-unique') }
+ context "when there is a group with the same path" do
+ let!(:group) { create(:group, :public, :nested, path: "not-unique") }
before do
- create(:group, path: 'not-unique')
+ create(:group, path: "not-unique")
end
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(nil)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(nil)
- expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
+ expect(transfer_service.error).to eq("Transfer failed: The parent group already has a subgroup with the same path.")
end
end
- context 'when the group is a subgroup and the transfer is valid' do
+ context "when the group is a subgroup and the transfer is valid" do
let!(:subgroup1) { create(:group, :private, parent: group) }
let!(:subgroup2) { create(:group, :internal, parent: group) }
let!(:project1) { create(:project, :repository, :private, namespace: group) }
@@ -96,17 +96,17 @@ describe Groups::TransferService, :postgresql do
group.reload
end
- it 'should update group attributes' do
+ it "should update group attributes" do
expect(group.parent).to be_nil
end
- it 'should update group children path' do
+ it "should update group children path" do
group.children.each do |subgroup|
expect(subgroup.full_path).to eq("#{group.path}/#{subgroup.path}")
end
end
- it 'should update group projects path' do
+ it "should update group projects path" do
group.projects.each do |project|
expect(project.full_path).to eq("#{group.path}/#{project.path}")
end
@@ -114,25 +114,25 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when transferring a subgroup into another group' do
+ context "when transferring a subgroup into another group" do
let(:group) { create(:group, :public, :nested) }
- it_behaves_like 'ensuring allowed transfer for a group'
+ it_behaves_like "ensuring allowed transfer for a group"
- context 'when the new parent group is the same as the previous parent group' do
+ context "when the new parent group is the same as the previous parent group" do
let(:group) { create(:group, :public, :nested, parent: new_parent_group) }
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(new_parent_group)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(new_parent_group)
- expect(transfer_service.error).to eq('Transfer failed: Group is already associated to the parent group.')
+ expect(transfer_service.error).to eq("Transfer failed: Group is already associated to the parent group.")
end
end
- context 'when the user does not have the right policies' do
+ context "when the user does not have the right policies" do
let!(:group_member) { create(:group_member, :guest, group: group, user: user) }
it "should return false" do
@@ -145,89 +145,89 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when the parent has a group with the same path' do
+ context "when the parent has a group with the same path" do
before do
create(:group_member, :owner, group: new_parent_group, user: user)
group.update_attribute(:path, "not-unique")
create(:group, path: "not-unique", parent: new_parent_group)
end
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(new_parent_group)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(new_parent_group)
- expect(transfer_service.error).to eq('Transfer failed: The parent group already has a subgroup with the same path.')
+ expect(transfer_service.error).to eq("Transfer failed: The parent group already has a subgroup with the same path.")
end
end
- context 'when the parent group has a project with the same path' do
- let!(:group) { create(:group, :public, :nested, path: 'foo') }
+ context "when the parent group has a project with the same path" do
+ let!(:group) { create(:group, :public, :nested, path: "foo") }
before do
create(:group_member, :owner, group: new_parent_group, user: user)
- create(:project, path: 'foo', namespace: new_parent_group)
- group.update_attribute(:path, 'foo')
+ create(:project, path: "foo", namespace: new_parent_group)
+ group.update_attribute(:path, "foo")
end
- it 'should return false' do
+ it "should return false" do
expect(transfer_service.execute(new_parent_group)).to be_falsy
end
- it 'should add an error on group' do
+ it "should add an error on group" do
transfer_service.execute(new_parent_group)
- expect(transfer_service.error).to eq('Transfer failed: Validation failed: Group URL has already been taken')
+ expect(transfer_service.error).to eq("Transfer failed: Validation failed: Group URL has already been taken")
end
end
- context 'when the group is allowed to be transferred' do
+ context "when the group is allowed to be transferred" do
before do
create(:group_member, :owner, group: new_parent_group, user: user)
transfer_service.execute(new_parent_group)
end
- context 'when the group has a lower visibility than the parent group' do
+ context "when the group has a lower visibility than the parent group" do
let(:new_parent_group) { create(:group, :public) }
let(:group) { create(:group, :private, :nested) }
- it 'should not update the visibility for the group' do
+ it "should not update the visibility for the group" do
group.reload
expect(group.private?).to be_truthy
expect(group.visibility_level).not_to eq(new_parent_group.visibility_level)
end
end
- context 'when the group has a higher visibility than the parent group' do
+ context "when the group has a higher visibility than the parent group" do
let(:new_parent_group) { create(:group, :private) }
let(:group) { create(:group, :public, :nested) }
- it 'should update visibility level based on the parent group' do
+ it "should update visibility level based on the parent group" do
group.reload
expect(group.private?).to be_truthy
expect(group.visibility_level).to eq(new_parent_group.visibility_level)
end
end
- it 'should update visibility for the group based on the parent group' do
+ it "should update visibility for the group based on the parent group" do
expect(group.visibility_level).to eq(new_parent_group.visibility_level)
end
- it 'should update parent group to the new parent ' do
+ it "should update parent group to the new parent " do
expect(group.parent).to eq(new_parent_group)
end
- it 'should return the group as children of the new parent' do
+ it "should return the group as children of the new parent" do
expect(new_parent_group.children.count).to eq(1)
expect(new_parent_group.children.first).to eq(group)
end
- it 'should create a redirect for the group' do
+ it "should create a redirect for the group" do
expect(group.redirect_routes.count).to eq(1)
end
end
- context 'when transferring a group with group descendants' do
+ context "when transferring a group with group descendants" do
let!(:subgroup1) { create(:group, :private, parent: group) }
let!(:subgroup2) { create(:group, :internal, parent: group) }
@@ -236,32 +236,32 @@ describe Groups::TransferService, :postgresql do
transfer_service.execute(new_parent_group)
end
- it 'should update subgroups path' do
+ it "should update subgroups path" do
new_parent_path = new_parent_group.path
group.children.each do |subgroup|
expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
end
end
- it 'should create redirects for the subgroups' do
+ it "should create redirects for the subgroups" do
expect(group.redirect_routes.count).to eq(1)
expect(subgroup1.redirect_routes.count).to eq(1)
expect(subgroup2.redirect_routes.count).to eq(1)
end
- context 'when the new parent has a higher visibility than the children' do
- it 'should not update the children visibility' do
+ context "when the new parent has a higher visibility than the children" do
+ it "should not update the children visibility" do
expect(subgroup1.private?).to be_truthy
expect(subgroup2.internal?).to be_truthy
end
end
- context 'when the new parent has a lower visibility than the children' do
+ context "when the new parent has a lower visibility than the children" do
let!(:subgroup1) { create(:group, :public, parent: group) }
let!(:subgroup2) { create(:group, :public, parent: group) }
let(:new_parent_group) { create(:group, :private) }
- it 'should update children visibility to match the new parent' do
+ it "should update children visibility to match the new parent" do
group.children.each do |subgroup|
expect(subgroup.private?).to be_truthy
end
@@ -269,7 +269,7 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when transferring a group with project descendants' do
+ context "when transferring a group with project descendants" do
let!(:project1) { create(:project, :repository, :private, namespace: group) }
let!(:project2) { create(:project, :repository, :internal, namespace: group) }
@@ -279,32 +279,32 @@ describe Groups::TransferService, :postgresql do
transfer_service.execute(new_parent_group)
end
- it 'should update projects path' do
+ it "should update projects path" do
new_parent_path = new_parent_group.path
group.projects.each do |project|
expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
end
end
- it 'should create permanent redirects for the projects' do
+ it "should create permanent redirects for the projects" do
expect(group.redirect_routes.count).to eq(1)
expect(project1.redirect_routes.count).to eq(1)
expect(project2.redirect_routes.count).to eq(1)
end
- context 'when the new parent has a higher visibility than the projects' do
- it 'should not update projects visibility' do
+ context "when the new parent has a higher visibility than the projects" do
+ it "should not update projects visibility" do
expect(project1.private?).to be_truthy
expect(project2.internal?).to be_truthy
end
end
- context 'when the new parent has a lower visibility than the projects' do
+ context "when the new parent has a lower visibility than the projects" do
let!(:project1) { create(:project, :repository, :public, namespace: group) }
let!(:project2) { create(:project, :repository, :public, namespace: group) }
let(:new_parent_group) { create(:group, :private) }
- it 'should update projects visibility to match the new parent' do
+ it "should update projects visibility to match the new parent" do
group.projects.each do |project|
expect(project.private?).to be_truthy
end
@@ -312,7 +312,7 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when transferring a group with subgroups & projects descendants' do
+ context "when transferring a group with subgroups & projects descendants" do
let!(:project1) { create(:project, :repository, :private, namespace: group) }
let!(:project2) { create(:project, :repository, :internal, namespace: group) }
let!(:subgroup1) { create(:group, :private, parent: group) }
@@ -324,21 +324,21 @@ describe Groups::TransferService, :postgresql do
transfer_service.execute(new_parent_group)
end
- it 'should update subgroups path' do
+ it "should update subgroups path" do
new_parent_path = new_parent_group.path
group.children.each do |subgroup|
expect(subgroup.full_path).to eq("#{new_parent_path}/#{group.path}/#{subgroup.path}")
end
end
- it 'should update projects path' do
+ it "should update projects path" do
new_parent_path = new_parent_group.path
group.projects.each do |project|
expect(project.full_path).to eq("#{new_parent_path}/#{group.path}/#{project.name}")
end
end
- it 'should create redirect for the subgroups and projects' do
+ it "should create redirect for the subgroups and projects" do
expect(group.redirect_routes.count).to eq(1)
expect(subgroup1.redirect_routes.count).to eq(1)
expect(subgroup2.redirect_routes.count).to eq(1)
@@ -347,7 +347,7 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when transferring a group with nested groups and projects' do
+ context "when transferring a group with nested groups and projects" do
let!(:group) { create(:group, :public) }
let!(:project1) { create(:project, :repository, :private, namespace: group) }
let!(:subgroup1) { create(:group, :private, parent: group) }
@@ -360,7 +360,7 @@ describe Groups::TransferService, :postgresql do
transfer_service.execute(new_parent_group)
end
- it 'should update subgroups path' do
+ it "should update subgroups path" do
new_base_path = "#{new_parent_group.path}/#{group.path}"
group.children.each do |children|
expect(children.full_path).to eq("#{new_base_path}/#{children.path}")
@@ -372,7 +372,7 @@ describe Groups::TransferService, :postgresql do
end
end
- it 'should update projects path' do
+ it "should update projects path" do
new_parent_path = "#{new_parent_group.path}/#{group.path}"
subgroup1.projects.each do |project|
project_full_path = "#{new_parent_path}/#{project.namespace.path}/#{project.name}"
@@ -380,7 +380,7 @@ describe Groups::TransferService, :postgresql do
end
end
- it 'should create redirect for the subgroups and projects' do
+ it "should create redirect for the subgroups and projects" do
expect(group.redirect_routes.count).to eq(1)
expect(project1.redirect_routes.count).to eq(1)
expect(subgroup1.redirect_routes.count).to eq(1)
@@ -389,7 +389,7 @@ describe Groups::TransferService, :postgresql do
end
end
- context 'when updating the group goes wrong' do
+ context "when updating the group goes wrong" do
let!(:subgroup1) { create(:group, :public, parent: group) }
let!(:subgroup2) { create(:group, :public, parent: group) }
let(:new_parent_group) { create(:group, :private) }
@@ -402,7 +402,7 @@ describe Groups::TransferService, :postgresql do
transfer_service.execute(new_parent_group)
end
- it 'should restore group and projects visibility' do
+ it "should restore group and projects visibility" do
subgroup1.reload
project1.reload
expect(subgroup1.public?).to be_truthy
diff --git a/spec/services/groups/update_service_spec.rb b/spec/services/groups/update_service_spec.rb
index d87a7dd234d..26fb8650b3a 100644
--- a/spec/services/groups/update_service_spec.rb
+++ b/spec/services/groups/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Groups::UpdateService do
let!(:user) { create(:user) }
@@ -74,7 +74,7 @@ describe Groups::UpdateService do
service.execute
end
- it 'does not update parent_id' do
+ it "does not update parent_id" do
updated_group = public_group.reload
expect(updated_group.parent_id).to be_nil
@@ -94,7 +94,7 @@ describe Groups::UpdateService do
end
end
- context 'rename group' do
+ context "rename group" do
let!(:service) { described_class.new(internal_group, user, path: SecureRandom.hex) }
before do
@@ -102,27 +102,27 @@ describe Groups::UpdateService do
create(:project, :internal, group: internal_group)
end
- it 'returns true' do
+ it "returns true" do
expect(service.execute).to eq(true)
end
- context 'error moving group' do
+ context "error moving group" do
before do
allow(internal_group).to receive(:move_dir).and_raise(Gitlab::UpdatePathError)
end
- it 'does not raise an error' do
+ it "does not raise an error" do
expect { service.execute }.not_to raise_error
end
- it 'returns false' do
+ it "returns false" do
expect(service.execute).to eq(false)
end
- it 'has the right error' do
+ it "has the right error" do
service.execute
- expect(internal_group.errors.full_messages.first).to eq('Gitlab::UpdatePathError')
+ expect(internal_group.errors.full_messages.first).to eq("Gitlab::UpdatePathError")
end
it "hasn't changed the path" do
@@ -131,16 +131,16 @@ describe Groups::UpdateService do
end
end
- context 'for a subgroup', :nested_groups do
+ context "for a subgroup", :nested_groups do
let(:subgroup) { create(:group, :private, parent: private_group) }
- context 'when the parent group share_with_group_lock is enabled' do
+ context "when the parent group share_with_group_lock is enabled" do
before do
private_group.update_column(:share_with_group_lock, true)
end
- context 'for the parent group owner' do
- it 'allows disabling share_with_group_lock' do
+ context "for the parent group owner" do
+ it "allows disabling share_with_group_lock" do
private_group.add_owner(user)
result = described_class.new(subgroup, user, share_with_group_lock: false).execute
@@ -150,8 +150,8 @@ describe Groups::UpdateService do
end
end
- context 'for a subgroup owner (who does not own the parent)' do
- it 'does not allow disabling share_with_group_lock' do
+ context "for a subgroup owner (who does not own the parent)" do
+ it "does not allow disabling share_with_group_lock" do
subgroup_owner = create(:user)
subgroup.add_owner(subgroup_owner)
diff --git a/spec/services/import_export_clean_up_service_spec.rb b/spec/services/import_export_clean_up_service_spec.rb
index d5fcef1246f..0fac2f4bda4 100644
--- a/spec/services/import_export_clean_up_service_spec.rb
+++ b/spec/services/import_export_clean_up_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe ImportExportCleanUpService do
- describe '#execute' do
+ describe "#execute" do
let(:service) { described_class.new }
- let(:tmp_import_export_folder) { 'tmp/project_exports' }
+ let(:tmp_import_export_folder) { "tmp/project_exports" }
- context 'when the import/export directory does not exist' do
- it 'does not remove any archives' do
- path = '/invalid/path/'
+ context "when the import/export directory does not exist" do
+ it "does not remove any archives" do
+ path = "/invalid/path/"
stub_repository_downloads_path(path)
expect(service).not_to receive(:clean_up_export_files)
@@ -17,8 +17,8 @@ describe ImportExportCleanUpService do
end
end
- context 'when the import/export directory exists' do
- it 'removes old files' do
+ context "when the import/export directory exists" do
+ it "removes old files" do
in_directory_with_files(mtime: 2.days.ago) do |dir, files|
service.execute
@@ -27,7 +27,7 @@ describe ImportExportCleanUpService do
end
end
- it 'does not remove new files' do
+ it "does not remove new files" do
in_directory_with_files(mtime: 2.hours.ago) do |dir, files|
service.execute
@@ -37,19 +37,19 @@ describe ImportExportCleanUpService do
end
end
- context 'with uploader exports' do
- it 'removes old files' do
+ context "with uploader exports" do
+ it "removes old files" do
upload = create(:import_export_upload,
- updated_at: 2.days.ago,
- export_file: fixture_file_upload('spec/fixtures/project_export.tar.gz'))
+ updated_at: 2.days.ago,
+ export_file: fixture_file_upload("spec/fixtures/project_export.tar.gz"))
expect { service.execute }.to change { upload.reload.export_file.file.nil? }.to(true)
end
- it 'does not remove new files' do
+ it "does not remove new files" do
upload = create(:import_export_upload,
- updated_at: 1.hour.ago,
- export_file: fixture_file_upload('spec/fixtures/project_export.tar.gz'))
+ updated_at: 1.hour.ago,
+ export_file: fixture_file_upload("spec/fixtures/project_export.tar.gz"))
expect { service.execute }.not_to change { upload.reload.export_file.file.nil? }
end
@@ -58,7 +58,7 @@ describe ImportExportCleanUpService do
def in_directory_with_files(mtime:)
Dir.mktmpdir do |tmpdir|
stub_repository_downloads_path(tmpdir)
- dir = File.join(tmpdir, tmp_import_export_folder, 'subfolder')
+ dir = File.join(tmpdir, tmp_import_export_folder, "subfolder")
FileUtils.mkdir_p(dir)
files = FileUtils.touch(file_list(dir) + [dir], mtime: mtime.to_time)
@@ -68,7 +68,7 @@ describe ImportExportCleanUpService do
end
def stub_repository_downloads_path(path)
- new_shared_settings = Settings.shared.merge('path' => path)
+ new_shared_settings = Settings.shared.merge("path" => path)
allow(Settings).to receive(:shared).and_return(new_shared_settings)
end
diff --git a/spec/services/issuable/bulk_update_service_spec.rb b/spec/services/issuable/bulk_update_service_spec.rb
index ca366cdf1df..4b86579a1ff 100644
--- a/spec/services/issuable/bulk_update_service_spec.rb
+++ b/spec/services/issuable/bulk_update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issuable::BulkUpdateService do
let(:user) { create(:user) }
@@ -6,38 +6,38 @@ describe Issuable::BulkUpdateService do
def bulk_update(issuables, extra_params = {})
bulk_update_params = extra_params
- .reverse_merge(issuable_ids: Array(issuables).map(&:id).join(','))
+ .reverse_merge(issuable_ids: Array(issuables).map(&:id).join(","))
type = Array(issuables).first.model_name.param_key
Issuable::BulkUpdateService.new(project, user, bulk_update_params).execute(type)
end
- describe 'close issues' do
+ describe "close issues" do
let(:issues) { create_list(:issue, 2, project: project) }
- it 'succeeds and returns the correct number of issues updated' do
- result = bulk_update(issues, state_event: 'close')
+ it "succeeds and returns the correct number of issues updated" do
+ result = bulk_update(issues, state_event: "close")
expect(result[:success]).to be_truthy
expect(result[:count]).to eq(issues.count)
end
- it 'closes all the issues passed' do
- bulk_update(issues, state_event: 'close')
+ it "closes all the issues passed" do
+ bulk_update(issues, state_event: "close")
expect(project.issues.opened).to be_empty
expect(project.issues.closed).not_to be_empty
end
- context 'when issue for a different project is created' do
+ context "when issue for a different project is created" do
let(:private_project) { create(:project, :private) }
let(:issue) { create(:issue, project: private_project, author: user) }
- context 'when user has access to the project' do
- it 'closes all issues passed' do
+ context "when user has access to the project" do
+ it "closes all issues passed" do
private_project.add_maintainer(user)
- bulk_update(issues + [issue], state_event: 'close')
+ bulk_update(issues + [issue], state_event: "close")
expect(project.issues.opened).to be_empty
expect(project.issues.closed).not_to be_empty
@@ -45,9 +45,9 @@ describe Issuable::BulkUpdateService do
end
end
- context 'when user does not have access to project' do
- it 'only closes all issues that the user has access to' do
- bulk_update(issues + [issue], state_event: 'close')
+ context "when user does not have access to project" do
+ it "only closes all issues that the user has access to" do
+ bulk_update(issues + [issue], state_event: "close")
expect(project.issues.opened).to be_empty
expect(project.issues.closed).not_to be_empty
@@ -57,29 +57,29 @@ describe Issuable::BulkUpdateService do
end
end
- describe 'reopen issues' do
+ describe "reopen issues" do
let(:issues) { create_list(:closed_issue, 2, project: project) }
- it 'succeeds and returns the correct number of issues updated' do
- result = bulk_update(issues, state_event: 'reopen')
+ it "succeeds and returns the correct number of issues updated" do
+ result = bulk_update(issues, state_event: "reopen")
expect(result[:success]).to be_truthy
expect(result[:count]).to eq(issues.count)
end
- it 'reopens all the issues passed' do
- bulk_update(issues, state_event: 'reopen')
+ it "reopens all the issues passed" do
+ bulk_update(issues, state_event: "reopen")
expect(project.issues.closed).to be_empty
expect(project.issues.opened).not_to be_empty
end
end
- describe 'updating merge request assignee' do
+ describe "updating merge request assignee" do
let(:merge_request) { create(:merge_request, target_project: project, source_project: project, assignee: user) }
- context 'when the new assignee ID is a valid user' do
- it 'succeeds' do
+ context "when the new assignee ID is a valid user" do
+ it "succeeds" do
new_assignee = create(:user)
project.add_developer(new_assignee)
@@ -89,7 +89,7 @@ describe Issuable::BulkUpdateService do
expect(result[:count]).to eq(1)
end
- it 'updates the assignee to the user ID passed' do
+ it "updates the assignee to the user ID passed" do
assignee = create(:user)
project.add_developer(assignee)
@@ -99,25 +99,25 @@ describe Issuable::BulkUpdateService do
end
context "when the new assignee ID is #{IssuableFinder::NONE}" do
- it 'unassigns the issues' do
+ it "unassigns the issues" do
expect { bulk_update(merge_request, assignee_id: IssuableFinder::NONE) }
.to change { merge_request.reload.assignee }.to(nil)
end
end
- context 'when the new assignee ID is not present' do
- it 'does not unassign' do
+ context "when the new assignee ID is not present" do
+ it "does not unassign" do
expect { bulk_update(merge_request, assignee_id: nil) }
.not_to change { merge_request.reload.assignee }
end
end
end
- describe 'updating issue assignee' do
+ describe "updating issue assignee" do
let(:issue) { create(:issue, project: project, assignees: [user]) }
- context 'when the new assignee ID is a valid user' do
- it 'succeeds' do
+ context "when the new assignee ID is a valid user" do
+ it "succeeds" do
new_assignee = create(:user)
project.add_developer(new_assignee)
@@ -127,7 +127,7 @@ describe Issuable::BulkUpdateService do
expect(result[:count]).to eq(1)
end
- it 'updates the assignee to the user ID passed' do
+ it "updates the assignee to the user ID passed" do
assignee = create(:user)
project.add_developer(assignee)
expect { bulk_update(issue, assignee_ids: [assignee.id]) }
@@ -142,32 +142,32 @@ describe Issuable::BulkUpdateService do
end
end
- context 'when the new assignee ID is not present' do
- it 'does not unassign' do
+ context "when the new assignee ID is not present" do
+ it "does not unassign" do
expect { bulk_update(issue, assignee_ids: []) }
.not_to change { issue.reload.assignees }
end
end
end
- describe 'updating milestones' do
+ describe "updating milestones" do
let(:issue) { create(:issue, project: project) }
let(:milestone) { create(:milestone, project: project) }
- it 'succeeds' do
+ it "succeeds" do
result = bulk_update(issue, milestone_id: milestone.id)
expect(result[:success]).to be_truthy
expect(result[:count]).to eq(1)
end
- it 'updates the issue milestone' do
+ it "updates the issue milestone" do
expect { bulk_update(issue, milestone_id: milestone.id) }
.to change { issue.reload.milestone }.from(nil).to(milestone)
end
end
- describe 'updating labels' do
+ describe "updating labels" do
def create_issue_with_labels(labels)
create(:labeled_issue, project: project, labels: labels)
end
@@ -188,9 +188,9 @@ describe Issuable::BulkUpdateService do
let(:bulk_update_params) do
{
- label_ids: labels.map(&:id),
- add_label_ids: add_labels.map(&:id),
- remove_label_ids: remove_labels.map(&:id)
+ label_ids: labels.map(&:id),
+ add_label_ids: add_labels.map(&:id),
+ remove_label_ids: remove_labels.map(&:id),
}
end
@@ -198,150 +198,150 @@ describe Issuable::BulkUpdateService do
bulk_update(issues, bulk_update_params)
end
- context 'when label_ids are passed' do
+ context "when label_ids are passed" do
let(:issues) { [issue_all_labels, issue_no_labels] }
let(:labels) { [bug, regression] }
- it 'updates the labels of all issues passed to the labels passed' do
+ it "updates the labels of all issues passed to the labels passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(match_array(labels.map(&:id)))
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
end
- context 'when those label IDs are empty' do
+ context "when those label IDs are empty" do
let(:labels) { [] }
- it 'updates the issues passed to have no labels' do
+ it "updates the issues passed to have no labels" do
expect(issues.map(&:reload).map(&:label_ids)).to all(be_empty)
end
end
end
- context 'when add_label_ids are passed' do
+ context "when add_label_ids are passed" do
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
let(:add_labels) { [bug, regression, merge_requests] }
- it 'adds those label IDs to all issues passed' do
+ it "adds those label IDs to all issues passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(include(*add_labels.map(&:id)))
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
end
end
- context 'when remove_label_ids are passed' do
+ context "when remove_label_ids are passed" do
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
let(:remove_labels) { [bug, regression, merge_requests] }
- it 'removes those label IDs from all issues passed' do
+ it "removes those label IDs from all issues passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(be_empty)
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
end
end
- context 'when add_label_ids and remove_label_ids are passed' do
+ context "when add_label_ids and remove_label_ids are passed" do
let(:issues) { [issue_all_labels, issue_bug_and_merge_requests, issue_no_labels] }
let(:add_labels) { [bug] }
let(:remove_labels) { [merge_requests] }
- it 'adds the label IDs to all issues passed' do
+ it "adds the label IDs to all issues passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
end
- it 'removes 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(merge_requests.id)
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
end
end
- context 'when add_label_ids and label_ids are passed' do
+ context "when add_label_ids and label_ids are passed" do
let(:issues) { [issue_all_labels, issue_bug_and_regression, issue_bug_and_merge_requests] }
let(:labels) { [merge_requests] }
let(:add_labels) { [regression] }
- it 'adds the label IDs to all issues passed' do
+ it "adds the label IDs to all issues passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(include(regression.id))
end
- it 'ignores the label IDs parameter' do
+ it "ignores the label IDs parameter" do
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_no_labels.label_ids).to be_empty
end
end
- context 'when remove_label_ids and label_ids are passed' do
+ context "when remove_label_ids and label_ids are passed" do
let(:issues) { [issue_no_labels, issue_bug_and_regression] }
let(:labels) { [merge_requests] }
let(:remove_labels) { [regression] }
- it 'removes 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
- it 'ignores the label IDs parameter' do
+ it "ignores the label IDs parameter" do
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(merge_requests.id)
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_all_labels.label_ids).to contain_exactly(bug.id, regression.id, merge_requests.id)
end
end
- context 'when add_label_ids, remove_label_ids, and label_ids are passed' do
+ context "when add_label_ids, remove_label_ids, and label_ids are passed" do
let(:issues) { [issue_bug_and_merge_requests, issue_no_labels] }
let(:labels) { [regression] }
let(:add_labels) { [bug] }
let(:remove_labels) { [merge_requests] }
- it 'adds the label IDs to all issues passed' do
+ it "adds the label IDs to all issues passed" do
expect(issues.map(&:reload).map(&:label_ids)).to all(include(bug.id))
end
- it 'removes 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(merge_requests.id)
end
- it 'ignores the label IDs parameter' do
+ it "ignores the label IDs parameter" do
expect(issues.map(&:reload).map(&:label_ids).flatten).not_to include(regression.id)
end
- it 'does not update issues not passed in' do
+ it "does not update issues not passed in" do
expect(issue_bug_and_regression.label_ids).to contain_exactly(bug.id, regression.id)
end
end
end
- describe 'subscribe to issues' do
+ describe "subscribe to issues" do
let(:issues) { create_list(:issue, 2, project: project) }
- it 'subscribes the given user' do
- bulk_update(issues, subscription_event: 'subscribe')
+ it "subscribes the given user" do
+ bulk_update(issues, subscription_event: "subscribe")
expect(issues).to all(be_subscribed(user, project))
end
end
- describe 'unsubscribe from issues' do
+ describe "unsubscribe from issues" do
let(:issues) do
create_list(:closed_issue, 2, project: project) do |issue|
issue.subscriptions.create(user: user, project: project, subscribed: true)
end
end
- it 'unsubscribes the given user' do
- bulk_update(issues, subscription_event: 'unsubscribe')
+ it "unsubscribes the given user" do
+ bulk_update(issues, subscription_event: "unsubscribe")
issues.each do |issue|
expect(issue).not_to be_subscribed(user, project)
diff --git a/spec/services/issuable/clone/attributes_rewriter_spec.rb b/spec/services/issuable/clone/attributes_rewriter_spec.rb
index 20bda6984bd..88ce4a103b3 100644
--- a/spec/services/issuable/clone/attributes_rewriter_spec.rb
+++ b/spec/services/issuable/clone/attributes_rewriter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Issuable::Clone::AttributesRewriter do
let(:user) { create(:user) }
@@ -12,13 +12,13 @@ describe Issuable::Clone::AttributesRewriter do
subject { described_class.new(user, original_issue, new_issue) }
- context 'setting labels' do
- it 'sets labels present in the new project and group labels' do
- project1_label_1 = create(:label, title: 'label1', project: project1)
- project1_label_2 = create(:label, title: 'label2', project: project1)
- project2_label_1 = create(:label, title: 'label1', project: project2)
- group_label = create(:group_label, title: 'group_label', group: group)
- create(:label, title: 'label3', project: project2)
+ context "setting labels" do
+ it "sets labels present in the new project and group labels" do
+ project1_label_1 = create(:label, title: "label1", project: project1)
+ project1_label_2 = create(:label, title: "label2", project: project1)
+ project2_label_1 = create(:label, title: "label1", project: project2)
+ group_label = create(:group_label, title: "group_label", group: group)
+ create(:label, title: "label3", project: project2)
original_issue.update(labels: [project1_label_1, project1_label_2, group_label])
@@ -27,13 +27,13 @@ describe Issuable::Clone::AttributesRewriter do
expect(new_issue.reload.labels).to match_array([project2_label_1, group_label])
end
- it 'does not set any labels when not used on the original issue' do
+ it "does not set any labels when not used on the original issue" do
subject.execute
expect(new_issue.reload.labels).to be_empty
end
- it 'copies the resource label events' do
+ it "copies the resource label events" do
resource_label_events = create_list(:resource_label_event, 2, issue: original_issue)
subject.execute
@@ -44,9 +44,9 @@ describe Issuable::Clone::AttributesRewriter do
end
end
- context 'setting milestones' do
- it 'sets milestone to nil when old issue milestone is not in the new project' do
- milestone = create(:milestone, title: 'milestone', project: project1)
+ context "setting milestones" do
+ it "sets milestone to nil when old issue milestone is not in the new project" do
+ milestone = create(:milestone, title: "milestone", project: project1)
original_issue.update(milestone: milestone)
@@ -55,9 +55,9 @@ describe Issuable::Clone::AttributesRewriter do
expect(new_issue.reload.milestone).to be_nil
end
- it 'copies the milestone when old issue milestone title is in the new project' do
- milestone_project1 = create(:milestone, title: 'milestone', project: project1)
- milestone_project2 = create(:milestone, title: 'milestone', project: project2)
+ it "copies the milestone when old issue milestone title is in the new project" do
+ milestone_project1 = create(:milestone, title: "milestone", project: project1)
+ milestone_project2 = create(:milestone, title: "milestone", project: project2)
original_issue.update(milestone: milestone_project1)
@@ -66,8 +66,8 @@ describe Issuable::Clone::AttributesRewriter do
expect(new_issue.reload.milestone).to eq(milestone_project2)
end
- it 'copies the milestone when old issue milestone is a group milestone' do
- milestone = create(:milestone, title: 'milestone', group: group)
+ it "copies the milestone when old issue milestone is a group milestone" do
+ milestone = create(:milestone, title: "milestone", group: group)
original_issue.update(milestone: milestone)
diff --git a/spec/services/issuable/clone/content_rewriter_spec.rb b/spec/services/issuable/clone/content_rewriter_spec.rb
index 4d3cb0bd254..c63a16e9e51 100644
--- a/spec/services/issuable/clone/content_rewriter_spec.rb
+++ b/spec/services/issuable/clone/content_rewriter_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Issuable::Clone::ContentRewriter do
let(:user) { create(:user) }
@@ -13,65 +13,65 @@ describe Issuable::Clone::ContentRewriter do
subject { described_class.new(user, original_issue, new_issue)}
- let(:description) { 'Simple text' }
+ let(:description) { "Simple text" }
let(:original_issue) { create(:issue, description: description, project: project1) }
let(:new_issue) { create(:issue, project: project2) }
- context 'rewriting award emojis' do
- it 'copies the award emojis' do
- create(:award_emoji, awardable: original_issue, name: 'thumbsup')
- create(:award_emoji, awardable: original_issue, name: 'thumbsdown')
+ context "rewriting award emojis" do
+ it "copies the award emojis" do
+ create(:award_emoji, awardable: original_issue, name: "thumbsup")
+ create(:award_emoji, awardable: original_issue, name: "thumbsdown")
expect { subject.execute }.to change { AwardEmoji.count }.by(2)
- expect(new_issue.award_emoji.map(&:name)).to match_array(%w(thumbsup thumbsdown))
+ expect(new_issue.award_emoji.map(&:name)).to match_array(%w[thumbsup thumbsdown])
end
end
- context 'rewriting description' do
+ context "rewriting description" do
before do
subject.execute
end
- context 'when description is a simple text' do
- it 'does not rewrite the description' do
+ context "when description is a simple text" do
+ it "does not rewrite the description" do
expect(new_issue.reload.description).to eq(original_issue.description)
end
end
- context 'when description contains a local reference' do
+ context "when description contains a local reference" do
let(:description) { "See ##{other_issue.iid}" }
- it 'rewrites the local reference correctly' do
+ it "rewrites the local reference correctly" do
expected_description = "See #{project1.path}##{other_issue.iid}"
expect(new_issue.reload.description).to eq(expected_description)
end
end
- context 'when description contains a cross reference' do
+ context "when description contains a cross reference" do
let(:description) { "See #{merge_request.project.full_path}!#{merge_request.iid}" }
- it 'rewrites the cross reference correctly' do
+ it "rewrites the cross reference correctly" do
expected_description = "See #{merge_request.project.full_path}!#{merge_request.iid}"
expect(new_issue.reload.description).to eq(expected_description)
end
end
- context 'when description contains a user reference' do
+ context "when description contains a user reference" do
let(:description) { "FYU #{user.to_reference}" }
- it 'works with a user reference' do
+ it "works with a user reference" do
expect(new_issue.reload.description).to eq("FYU #{user.to_reference}")
end
end
- context 'when description contains uploads' do
+ context "when description contains uploads" do
let(:uploader) { build(:file_uploader, project: project1) }
let(:description) { "Text and #{uploader.markdown_link}" }
- it 'rewrites uploads in the description' do
+ it "rewrites uploads in the description" do
upload = Upload.last
expect(new_issue.description).not_to eq(description)
@@ -83,32 +83,32 @@ describe Issuable::Clone::ContentRewriter do
end
end
- context 'rewriting notes' do
- context 'simple notes' do
+ context "rewriting notes" do
+ context "simple notes" do
let!(:notes) do
[
create(:note, noteable: original_issue, project: project1,
created_at: 2.weeks.ago, updated_at: 1.week.ago),
create(:note, noteable: original_issue, project: project1),
- create(:note, system: true, noteable: original_issue, project: project1)
+ create(:note, system: true, noteable: original_issue, project: project1),
]
end
let!(:system_note_metadata) { create(:system_note_metadata, note: notes.last) }
- let!(:award_emoji) { create(:award_emoji, awardable: notes.first, name: 'thumbsup')}
+ let!(:award_emoji) { create(:award_emoji, awardable: notes.first, name: "thumbsup")}
before do
subject.execute
end
- it 'rewrites existing notes in valid order' do
- expect(new_issue.notes.order('id ASC').pluck(:note).first(3)).to eq(notes.map(&:note))
+ it "rewrites existing notes in valid order" do
+ expect(new_issue.notes.order("id ASC").pluck(:note).first(3)).to eq(notes.map(&:note))
end
- it 'copies all the issue notes' do
+ it "copies all the issue notes" do
expect(new_issue.notes.count).to eq(3)
end
- it 'does not change the note attributes' do
+ it "does not change the note attributes" do
subject.execute
new_note = new_issue.notes.first
@@ -117,14 +117,14 @@ describe Issuable::Clone::ContentRewriter do
expect(new_note.author).to eq(notes.first.author)
end
- it 'copies the award emojis' do
+ it "copies the award emojis" do
subject.execute
new_note = new_issue.notes.first
- new_note.award_emoji.first.name = 'thumbsup'
+ new_note.award_emoji.first.name = "thumbsup"
end
- it 'copies system_note_metadata for system note' do
+ it "copies system_note_metadata for system note" do
new_note = new_issue.notes.last
expect(new_note.system_note_metadata.action).to eq(system_note_metadata.action)
@@ -132,13 +132,13 @@ describe Issuable::Clone::ContentRewriter do
end
end
- context 'notes with reference' do
+ context "notes with reference" do
let(:text) do
"See ##{other_issue.iid} and #{merge_request.project.full_path}!#{merge_request.iid}"
end
let!(:note) { create(:note, noteable: original_issue, note: text, project: project1) }
- it 'rewrites the references correctly' do
+ it "rewrites the references correctly" do
subject.execute
new_note = new_issue.notes.first
diff --git a/spec/services/issuable/common_system_notes_service_spec.rb b/spec/services/issuable/common_system_notes_service_spec.rb
index fa5d5ebac5c..874352867db 100644
--- a/spec/services/issuable/common_system_notes_service_spec.rb
+++ b/spec/services/issuable/common_system_notes_service_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Issuable::CommonSystemNotesService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:issuable) { create(:issue) }
- context 'on issuable update' do
- it_behaves_like 'system note creation', { title: 'New title' }, 'changed title'
- it_behaves_like 'system note creation', { description: 'New description' }, 'changed the description'
- it_behaves_like 'system note creation', { discussion_locked: true }, 'locked this issue'
- it_behaves_like 'system note creation', { time_estimate: 5 }, 'changed time estimate'
+ context "on issuable update" do
+ it_behaves_like "system note creation", {title: "New title"}, "changed title"
+ it_behaves_like "system note creation", {description: "New description"}, "changed the description"
+ it_behaves_like "system note creation", {discussion_locked: true}, "locked this issue"
+ it_behaves_like "system note creation", {time_estimate: 5}, "changed time estimate"
- context 'when new label is added' do
+ context "when new label is added" do
let(:label) { create(:label, project: project) }
before do
@@ -19,7 +19,7 @@ describe Issuable::CommonSystemNotesService do
issuable.save
end
- it 'creates a resource label event' do
+ it "creates a resource label event" do
described_class.new(project, user).execute(issuable, old_labels: [])
event = issuable.reload.resource_label_events.last
@@ -29,58 +29,58 @@ describe Issuable::CommonSystemNotesService do
end
end
- context 'when new milestone is assigned' do
+ context "when new milestone is assigned" do
before do
milestone = create(:milestone, project: project)
issuable.milestone_id = milestone.id
end
- it_behaves_like 'system note creation', {}, 'changed milestone'
+ it_behaves_like "system note creation", {}, "changed milestone"
end
- context 'with merge requests WIP note' do
- context 'adding WIP note' do
+ context "with merge requests WIP note" do
+ context "adding WIP note" do
let(:issuable) { create(:merge_request, title: "merge request") }
- it_behaves_like 'system note creation', { title: "WIP merge request" }, 'marked as a **Work In Progress**'
+ it_behaves_like "system note creation", {title: "WIP merge request"}, "marked as a **Work In Progress**"
- context 'and changing title' do
+ context "and changing title" do
before do
issuable.update_attribute(:title, "WIP changed title")
end
- it_behaves_like 'WIP notes creation', 'marked'
+ it_behaves_like "WIP notes creation", "marked"
end
end
- context 'removing WIP note' do
+ context "removing WIP note" do
let(:issuable) { create(:merge_request, title: "WIP merge request") }
- it_behaves_like 'system note creation', { title: "merge request" }, 'unmarked as a **Work In Progress**'
+ it_behaves_like "system note creation", {title: "merge request"}, "unmarked as a **Work In Progress**"
- context 'and changing title' do
+ context "and changing title" do
before do
issuable.update_attribute(:title, "changed title")
end
- it_behaves_like 'WIP notes creation', 'unmarked'
+ it_behaves_like "WIP notes creation", "unmarked"
end
end
end
end
- context 'on issuable create' do
+ context "on issuable create" do
let(:issuable) { build(:issue) }
subject { described_class.new(project, user).execute(issuable, old_labels: [], is_update: false) }
- it 'does not create system note for title and description' do
+ it "does not create system note for title and description" do
issuable.save
expect { subject }.not_to change { issuable.notes.count }
end
- it 'creates a resource label event for labels added' do
+ it "creates a resource label event for labels added" do
label = create(:label, project: project)
issuable.labels << label
@@ -95,20 +95,20 @@ describe Issuable::CommonSystemNotesService do
expect(event.user_id).to eq user.id
end
- it 'creates a system note for milestone set' do
+ it "creates a system note for milestone set" do
issuable.milestone = create(:milestone, project: project)
issuable.save
expect { subject }.to change { issuable.notes.count }.from(0).to(1)
- expect(issuable.notes.last.note).to match('changed milestone')
+ expect(issuable.notes.last.note).to match("changed milestone")
end
- it 'creates a system note for due_date set' do
+ it "creates a system note for due_date set" do
issuable.due_date = Date.today
issuable.save
expect { subject }.to change { issuable.notes.count }.from(0).to(1)
- expect(issuable.notes.last.note).to match('changed due date')
+ expect(issuable.notes.last.note).to match("changed due date")
end
end
end
diff --git a/spec/services/issuable/destroy_service_spec.rb b/spec/services/issuable/destroy_service_spec.rb
index 8ccbba7fa58..e9c0e25b0be 100644
--- a/spec/services/issuable/destroy_service_spec.rb
+++ b/spec/services/issuable/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issuable::DestroyService do
let(:user) { create(:user) }
@@ -6,52 +6,52 @@ describe Issuable::DestroyService do
subject(:service) { described_class.new(project, user) }
- describe '#execute' do
- context 'when issuable is an issue' do
+ describe "#execute" do
+ context "when issuable is an issue" do
let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) }
- it 'destroys the issue' do
+ it "destroys the issue" do
expect { service.execute(issue) }.to change { project.issues.count }.by(-1)
end
- it 'updates open issues count cache' do
+ it "updates open issues count cache" do
expect_any_instance_of(Projects::OpenIssuesCountService).to receive(:refresh_cache)
service.execute(issue)
end
- it 'updates the todo caches for users with todos on the issue' do
+ it "updates the todo caches for users with todos on the issue" do
create(:todo, target: issue, user: user, author: user, project: project)
expect { service.execute(issue) }
.to change { user.todos_pending_count }.from(1).to(0)
end
- it 'invalidates the issues count cache for the assignees' do
+ it "invalidates the issues count cache for the assignees" do
expect_any_instance_of(User).to receive(:invalidate_cache_counts).once
service.execute(issue)
end
end
- context 'when issuable is a merge request' do
+ context "when issuable is a merge request" do
let!(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: user, assignee: user) }
- it 'destroys the merge request' do
+ it "destroys the merge request" do
expect { service.execute(merge_request) }.to change { project.merge_requests.count }.by(-1)
end
- it 'updates open merge requests count cache' do
+ it "updates open merge requests count cache" do
expect_any_instance_of(Projects::OpenMergeRequestsCountService).to receive(:refresh_cache)
service.execute(merge_request)
end
- it 'invalidates the merge request caches for the MR assignee' do
+ it "invalidates the merge request caches for the MR assignee" do
expect_any_instance_of(User).to receive(:invalidate_cache_counts).once
service.execute(merge_request)
end
- it 'updates the todo caches for users with todos on the merge request' do
+ it "updates the todo caches for users with todos on the merge request" do
create(:todo, target: merge_request, user: user, author: user, project: project)
expect { service.execute(merge_request) }
diff --git a/spec/services/issues/build_service_spec.rb b/spec/services/issues/build_service_spec.rb
index 248e7d5a389..282dd616f90 100644
--- a/spec/services/issues/build_service_spec.rb
+++ b/spec/services/issues/build_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper.rb'
+require "spec_helper.rb"
describe Issues::BuildService do
let(:project) { create(:project, :repository) }
@@ -8,32 +8,32 @@ describe Issues::BuildService do
project.add_developer(user)
end
- context 'for a single discussion' do
- describe '#execute' do
+ context "for a single discussion" do
+ describe "#execute" do
let(:merge_request) { create(:merge_request, title: "Hello world", source_project: project) }
let(:discussion) { create(:diff_note_on_merge_request, project: project, noteable: merge_request, note: "Almost done").to_discussion }
let(:service) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid, discussion_to_resolve: discussion.id) }
- it 'references the noteable title in the issue title' do
+ it "references the noteable title in the issue title" do
issue = service.execute
- expect(issue.title).to include('Hello world')
+ expect(issue.title).to include("Hello world")
end
- it 'adds the note content to the description' do
+ it "adds the note content to the description" do
issue = service.execute
- expect(issue.description).to include('Almost done')
+ expect(issue.description).to include("Almost done")
end
end
end
- context 'for discussions in a merge request' do
+ context "for discussions in a merge request" do
let(:merge_request) { create(:merge_request_with_diff_notes, source_project: project) }
let(:issue) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid).execute }
- describe '#items_for_discussions' do
- it 'has an item for each discussion' do
+ describe "#items_for_discussions" do
+ it "has an item for each discussion" do
create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.source_project, line_number: 13)
service = described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid)
@@ -43,15 +43,15 @@ describe Issues::BuildService do
end
end
- describe '#item_for_discussion' do
+ describe "#item_for_discussion" do
let(:service) { described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid) }
- it 'mentions the author of the note' do
- discussion = create(:diff_note_on_merge_request, author: create(:user, username: 'author')).to_discussion
- expect(service.item_for_discussion(discussion)).to include('@author')
+ it "mentions the author of the note" do
+ discussion = create(:diff_note_on_merge_request, author: create(:user, username: "author")).to_discussion
+ expect(service.item_for_discussion(discussion)).to include("@author")
end
- it 'wraps the note in a blockquote' do
+ it "wraps the note in a blockquote" do
note_text = "This is a string\n"\
">>>\n"\
"with a blockquote\n"\
@@ -65,61 +65,61 @@ describe Issues::BuildService do
end
end
- describe '#execute' do
- it 'has the merge request reference in the title' do
+ describe "#execute" do
+ it "has the merge request reference in the title" do
expect(issue.title).to include(merge_request.title)
end
- it 'has the reference of the merge request in the description' do
+ it "has the reference of the merge request in the description" do
expect(issue.description).to include(merge_request.to_reference)
end
- it 'does not assign title when a title was given' do
+ it "does not assign title when a title was given" do
issue = described_class.new(project, user,
- merge_request_to_resolve_discussions_of: merge_request,
- title: 'What an issue').execute
+ merge_request_to_resolve_discussions_of: merge_request,
+ title: "What an issue").execute
- expect(issue.title).to eq('What an issue')
+ expect(issue.title).to eq("What an issue")
end
- it 'does not assign description when a description was given' do
+ it "does not assign description when a description was given" do
issue = described_class.new(project, user,
- merge_request_to_resolve_discussions_of: merge_request,
- description: 'Fix at your earliest conveignance').execute
+ merge_request_to_resolve_discussions_of: merge_request,
+ description: "Fix at your earliest conveignance").execute
- expect(issue.description).to eq('Fix at your earliest conveignance')
+ expect(issue.description).to eq("Fix at your earliest conveignance")
end
- describe 'with multiple discussions' do
+ describe "with multiple discussions" do
let!(:diff_note) { create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.target_project, line_number: 15) }
- it 'mentions all the authors in the description' do
+ it "mentions all the authors in the description" do
authors = merge_request.resolvable_discussions.map(&:author)
expect(issue.description).to include(*authors.map(&:to_reference))
end
- it 'has a link for each unresolved discussion in the description' do
+ it "has a link for each unresolved discussion in the description" do
notes = merge_request.resolvable_discussions.map(&:first_note)
links = notes.map { |note| Gitlab::UrlBuilder.build(note) }
expect(issue.description).to include(*links)
end
- it 'mentions additional notes' do
+ it "mentions additional notes" do
create_list(:diff_note_on_merge_request, 2, noteable: merge_request, project: merge_request.target_project, in_reply_to: diff_note)
- expect(issue.description).to include('(+2 comments)')
+ expect(issue.description).to include("(+2 comments)")
end
end
end
end
- context 'For a merge request without discussions' do
+ context "For a merge request without discussions" do
let(:merge_request) { create(:merge_request, source_project: project) }
- describe '#execute' do
- it 'mentions the merge request in the description' do
+ describe "#execute" do
+ it "mentions the merge request in the description" do
issue = described_class.new(project, user, merge_request_to_resolve_discussions_of: merge_request.iid).execute
expect(issue.description).to include("Review the conversation in #{merge_request.to_reference}")
@@ -127,20 +127,20 @@ describe Issues::BuildService do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:milestone) { create(:milestone, project: project) }
- it 'builds a new issues with given params' do
+ it "builds a new issues with given params" do
issue = described_class.new(
project,
user,
- title: 'Issue #1',
- description: 'Issue description',
+ title: "Issue #1",
+ description: "Issue description",
milestone_id: milestone.id
).execute
- expect(issue.title).to eq('Issue #1')
- expect(issue.description).to eq('Issue description')
+ expect(issue.title).to eq("Issue #1")
+ expect(issue.description).to eq("Issue description")
expect(issue.milestone).to eq(milestone)
end
end
diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb
index 5e38d0aeb6a..887f8e2f832 100644
--- a/spec/services/issues/close_service_spec.rb
+++ b/spec/services/issues/close_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::CloseService do
let(:user) { create(:user) }
@@ -14,17 +14,17 @@ describe Issues::CloseService do
project.add_guest(guest)
end
- describe '#execute' do
+ describe "#execute" do
let(:service) { described_class.new(project, user) }
- it 'checks if the user is authorized to update the issue' do
+ it "checks if the user is authorized to update the issue" do
expect(service).to receive(:can?).with(user, :update_issue, issue)
.and_call_original
service.execute(issue)
end
- it 'does not close the issue when the user is not authorized to do so' do
+ it "does not close the issue when the user is not authorized to do so" do
allow(service).to receive(:can?).with(user, :update_issue, issue)
.and_return(false)
@@ -32,7 +32,7 @@ describe Issues::CloseService do
expect(service.execute(issue)).to eq(issue)
end
- it 'closes the issue when the user is authorized to do so' do
+ it "closes the issue when the user is authorized to do so" do
allow(service).to receive(:can?).with(user, :update_issue, issue)
.and_return(true)
@@ -42,19 +42,19 @@ describe Issues::CloseService do
service.execute(issue)
end
- it 'refreshes the number of open issues', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open issues", :use_clean_rails_memory_store_caching do
expect { service.execute(issue) }
.to change { project.open_issues_count }.from(1).to(0)
end
- it 'invalidates counter cache for assignees' do
+ it "invalidates counter cache for assignees" do
expect_any_instance_of(User).to receive(:invalidate_issue_cache_counts)
service.execute(issue)
end
end
- describe '#close_issue' do
+ describe "#close_issue" do
context "valid params" do
before do
perform_enqueued_jobs do
@@ -62,33 +62,33 @@ describe Issues::CloseService do
end
end
- it 'closes the issue' do
+ it "closes the issue" do
expect(issue).to be_valid
expect(issue).to be_closed
end
- it 'records closed user' do
+ it "records closed user" do
expect(issue.closed_by_id).to be(user.id)
end
- it 'sends 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 'creates system note about issue reassign' do
+ it "creates system note about issue reassign" do
note = issue.notes.last
expect(note.note).to include "closed"
end
- it 'marks todos as done' do
+ it "marks todos as done" do
expect(todo.reload).to be_done
end
end
- context 'when issue is not confidential' do
- it 'executes issue hooks' do
+ context "when issue is not confidential" do
+ it "executes issue hooks" do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
@@ -96,8 +96,8 @@ describe Issues::CloseService do
end
end
- context 'when issue is confidential' do
- it 'executes confidential issue hooks' do
+ context "when issue is confidential" do
+ it "executes confidential issue hooks" do
issue = create(:issue, :confidential, project: project)
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
@@ -107,13 +107,13 @@ describe Issues::CloseService do
end
end
- context 'internal issues disabled' do
+ context "internal issues disabled" do
before do
project.issues_enabled = false
project.save!
end
- it 'does not close the issue' do
+ it "does not close the issue" do
expect(issue).to be_valid
expect(issue).to be_opened
expect(todo.reload).to be_pending
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb
index 715b1168bfb..3086b291f3e 100644
--- a/spec/services/issues/create_service_spec.rb
+++ b/spec/services/issues/create_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::CreateService do
let(:project) { create(:project) }
let(:user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
let(:issue) { described_class.new(project, user, opts).execute }
let(:assignee) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
- context 'when params are valid' do
+ context "when params are valid" do
let(:labels) { create_pair(:label, project: project) }
before do
@@ -18,40 +18,40 @@ describe Issues::CreateService do
end
let(:opts) do
- { title: 'Awesome issue',
- description: 'please fix',
- assignee_ids: [assignee.id],
- label_ids: labels.map(&:id),
- milestone_id: milestone.id,
- due_date: Date.tomorrow }
+ {title: "Awesome issue",
+ description: "please fix",
+ assignee_ids: [assignee.id],
+ label_ids: labels.map(&:id),
+ milestone_id: milestone.id,
+ due_date: Date.tomorrow,}
end
- it 'creates the issue with the given params' do
+ it "creates the issue with the given params" do
expect(issue).to be_persisted
- expect(issue.title).to eq('Awesome issue')
+ expect(issue.title).to eq("Awesome issue")
expect(issue.assignees).to eq [assignee]
expect(issue.labels).to match_array labels
expect(issue.milestone).to eq milestone
expect(issue.due_date).to eq Date.tomorrow
end
- it 'refreshes the number of open issues', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open issues", :use_clean_rails_memory_store_caching do
expect { issue }.to change { project.open_issues_count }.from(0).to(1)
end
- context 'when current user cannot admin issues in the project' do
+ context "when current user cannot admin issues in the project" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
- it 'filters out params that cannot be set without the :admin_issue permission' do
+ it "filters out params that cannot be set without the :admin_issue permission" do
issue = described_class.new(project, guest, opts).execute
expect(issue).to be_persisted
- expect(issue.title).to eq('Awesome issue')
- expect(issue.description).to eq('please fix')
+ expect(issue.title).to eq("Awesome issue")
+ expect(issue.description).to eq("please fix")
expect(issue.assignees).to be_empty
expect(issue.labels).to be_empty
expect(issue.milestone).to be_nil
@@ -59,7 +59,7 @@ describe Issues::CreateService do
end
end
- it 'creates a pending todo for new assignee' do
+ it "creates a pending todo for new assignee" do
attributes = {
project: project,
author: user,
@@ -67,21 +67,21 @@ describe Issues::CreateService do
target_id: issue.id,
target_type: issue.class.name,
action: Todo::ASSIGNED,
- state: :pending
+ state: :pending,
}
expect(Todo.where(attributes).count).to eq 1
end
- context 'when label belongs to project group' do
+ context "when label belongs to project group" do
let(:group) { create(:group) }
let(:group_labels) { create_pair(:group_label, group: group) }
let(:opts) do
{
- title: 'Title',
- description: 'Description',
- label_ids: group_labels.map(&:id)
+ title: "Title",
+ description: "Description",
+ label_ids: group_labels.map(&:id),
}
end
@@ -89,47 +89,47 @@ describe Issues::CreateService do
project.update(group: group)
end
- it 'assigns group labels' do
+ it "assigns group labels" do
expect(issue.labels).to match_array group_labels
end
end
- context 'when label belongs to different project' do
+ context "when label belongs to different project" do
let(:label) { create(:label) }
let(:opts) do
- { title: 'Title',
- description: 'Description',
- label_ids: [label.id] }
+ {title: "Title",
+ description: "Description",
+ label_ids: [label.id],}
end
- it 'does not assign label' do
+ it "does not assign label" do
expect(issue.labels).not_to include label
end
end
- context 'when milestone belongs to different project' do
+ context "when milestone belongs to different project" do
let(:milestone) { create(:milestone) }
let(:opts) do
- { title: 'Title',
- description: 'Description',
- milestone_id: milestone.id }
+ {title: "Title",
+ description: "Description",
+ milestone_id: milestone.id,}
end
- it 'does not assign milestone' do
+ it "does not assign milestone" do
expect(issue.milestone).not_to eq milestone
end
end
- context 'when assignee is set' do
+ context "when assignee is set" do
let(:opts) do
- { title: 'Title',
- description: 'Description',
- assignees: [assignee] }
+ {title: "Title",
+ description: "Description",
+ assignees: [assignee],}
end
- it 'invalidates open issues counter for assignees when issue is assigned' do
+ it "invalidates open issues counter for assignees when issue is assigned" do
project.add_maintainer(assignee)
described_class.new(project, user, opts).execute
@@ -138,8 +138,8 @@ describe Issues::CreateService do
end
end
- it 'executes issue hooks when issue is not confidential' do
- opts = { title: 'Title', description: 'Description', confidential: false }
+ it "executes issue hooks when issue is not confidential" do
+ opts = {title: "Title", description: "Description", confidential: false}
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
@@ -147,8 +147,8 @@ describe Issues::CreateService do
described_class.new(project, user, opts).execute
end
- it 'executes confidential issue hooks when issue is confidential' do
- opts = { title: 'Title', description: 'Description', confidential: true }
+ it "executes confidential issue hooks when issue is confidential" do
+ opts = {title: "Title", description: "Description", confidential: true}
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
@@ -157,31 +157,31 @@ describe Issues::CreateService do
end
end
- context 'issue create service' do
- context 'assignees' do
+ context "issue create service" do
+ context "assignees" do
before do
project.add_maintainer(user)
end
- it 'removes assignee when user id is invalid' do
- opts = { title: 'Title', description: 'Description', assignee_ids: [-1] }
+ it "removes assignee when user id is invalid" do
+ opts = {title: "Title", description: "Description", assignee_ids: [-1]}
issue = described_class.new(project, user, opts).execute
expect(issue.assignees).to be_empty
end
- it 'removes assignee when user id is 0' do
- opts = { title: 'Title', description: 'Description', assignee_ids: [0] }
+ it "removes assignee when user id is 0" do
+ opts = {title: "Title", description: "Description", assignee_ids: [0]}
issue = described_class.new(project, user, opts).execute
expect(issue.assignees).to be_empty
end
- it 'saves assignee when user id is valid' do
+ it "saves assignee when user id is valid" do
project.add_maintainer(assignee)
- opts = { title: 'Title', description: 'Description', assignee_ids: [assignee.id] }
+ opts = {title: "Title", description: "Description", assignee_ids: [assignee.id]}
issue = described_class.new(project, user, opts).execute
@@ -199,7 +199,7 @@ describe Issues::CreateService do
levels.each do |level|
it "removes not authorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do
project.update(visibility_level: level)
- opts = { title: 'Title', description: 'Description', assignee_ids: [assignee.id] }
+ opts = {title: "Title", description: "Description", assignee_ids: [assignee.id]}
issue = described_class.new(project, user, opts).execute
@@ -210,16 +210,16 @@ describe Issues::CreateService do
end
end
- it_behaves_like 'new issuable record that supports quick actions'
+ it_behaves_like "new issuable record that supports quick actions"
- context 'Quick actions' do
- context 'with assignee and milestone in params and command' do
+ context "Quick actions" do
+ context "with assignee and milestone in params and command" do
let(:opts) do
{
assignee_ids: [create(:user).id],
milestone_id: 1,
- title: 'Title',
- description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
+ title: "Title",
+ description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}"),
}
end
@@ -228,7 +228,7 @@ describe Issues::CreateService do
project.add_maintainer(assignee)
end
- it 'assigns and sets milestone to issuable from command' do
+ it "assigns and sets milestone to issuable from command" do
expect(issue).to be_persisted
expect(issue.assignees).to eq([assignee])
expect(issue.milestone).to eq(milestone)
@@ -236,7 +236,7 @@ describe Issues::CreateService do
end
end
- context 'resolving discussions' do
+ context "resolving discussions" do
let(:discussion) { create(:diff_note_on_merge_request).to_discussion }
let(:merge_request) { discussion.noteable }
let(:project) { merge_request.source_project }
@@ -245,17 +245,17 @@ describe Issues::CreateService do
project.add_maintainer(user)
end
- describe 'for a single discussion' do
- let(:opts) { { discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid } }
+ describe "for a single discussion" do
+ let(:opts) { {discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid} }
- it 'resolves the discussion' do
+ it "resolves the discussion" do
described_class.new(project, user, opts).execute
discussion.first_note.reload
expect(discussion.resolved?).to be(true)
end
- it 'added a system note to the discussion' do
+ it "added a system note to the discussion" do
described_class.new(project, user, opts).execute
reloaded_discussion = MergeRequest.find(merge_request.id).discussions.first
@@ -263,35 +263,35 @@ describe Issues::CreateService do
expect(reloaded_discussion.last_note.system).to eq(true)
end
- it 'assigns the title and description for the issue' do
+ it "assigns the title and description for the issue" do
issue = described_class.new(project, user, opts).execute
expect(issue.title).not_to be_nil
expect(issue.description).not_to be_nil
end
- it 'can set nil explicitly to the title and description' do
+ it "can set nil explicitly to the title and description" do
issue = described_class.new(project, user,
- merge_request_to_resolve_discussions_of: merge_request,
- description: nil,
- title: nil).execute
+ merge_request_to_resolve_discussions_of: merge_request,
+ description: nil,
+ title: nil).execute
expect(issue.description).to be_nil
expect(issue.title).to be_nil
end
end
- describe 'for a merge request' do
- let(:opts) { { merge_request_to_resolve_discussions_of: merge_request.iid } }
+ describe "for a merge request" do
+ let(:opts) { {merge_request_to_resolve_discussions_of: merge_request.iid} }
- it 'resolves the discussion' do
+ it "resolves the discussion" do
described_class.new(project, user, opts).execute
discussion.first_note.reload
expect(discussion.resolved?).to be(true)
end
- it 'added a system note to the discussion' do
+ it "added a system note to the discussion" do
described_class.new(project, user, opts).execute
reloaded_discussion = MergeRequest.find(merge_request.id).discussions.first
@@ -299,18 +299,18 @@ describe Issues::CreateService do
expect(reloaded_discussion.last_note.system).to eq(true)
end
- it 'assigns the title and description for the issue' do
+ it "assigns the title and description for the issue" do
issue = described_class.new(project, user, opts).execute
expect(issue.title).not_to be_nil
expect(issue.description).not_to be_nil
end
- it 'can set nil explicitly to the title and description' do
+ it "can set nil explicitly to the title and description" do
issue = described_class.new(project, user,
- merge_request_to_resolve_discussions_of: merge_request,
- description: nil,
- title: nil).execute
+ merge_request_to_resolve_discussions_of: merge_request,
+ description: nil,
+ title: nil).execute
expect(issue.description).to be_nil
expect(issue.title).to be_nil
@@ -318,12 +318,12 @@ describe Issues::CreateService do
end
end
- context 'checking spam' do
+ context "checking spam" do
let(:opts) do
{
- title: 'Awesome issue',
- description: 'please fix',
- request: double(:request, env: {})
+ title: "Awesome issue",
+ description: "please fix",
+ request: double(:request, env: {}),
}
end
@@ -331,9 +331,9 @@ describe Issues::CreateService do
allow_any_instance_of(SpamService).to receive(:check_for_spam?).and_return(true)
end
- context 'when recaptcha was verified' do
+ context "when recaptcha was verified" do
let(:log_user) { user }
- let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: 'Awesome issue') }
+ let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: "Awesome issue") }
before do
opts[:recaptcha_verified] = true
@@ -342,68 +342,68 @@ describe Issues::CreateService do
expect(AkismetService).not_to receive(:new)
end
- it 'does no mark an issue as a spam ' do
+ it "does no mark an issue as a spam " do
expect(issue).not_to be_spam
end
- it 'an issue is valid ' do
+ it "an issue is valid " do
expect(issue.valid?).to be_truthy
end
- it 'does not assign a spam_log to an issue' do
+ it "does not assign a spam_log to an issue" do
expect(issue.spam_log).to be_nil
end
- it 'marks related spam_log as recaptcha_verified' do
+ it "marks related spam_log as recaptcha_verified" do
expect { issue }.to change {SpamLog.last.recaptcha_verified}.from(false).to(true)
end
- context 'when spam log does not belong to a user' do
+ context "when spam log does not belong to a user" do
let(:log_user) { create(:user) }
- it 'does not mark spam_log as recaptcha_verified' do
+ it "does not mark spam_log as recaptcha_verified" do
expect { issue }.not_to change {SpamLog.last.recaptcha_verified}
end
end
end
- context 'when recaptcha was not verified' do
- context 'when akismet detects spam' do
+ context "when recaptcha was not verified" do
+ context "when akismet detects spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(true)
end
- it 'marks an issue as a spam ' do
+ it "marks an issue as a spam " do
expect(issue).to be_spam
end
- it 'an issue is not valid ' do
+ it "an issue is not valid " do
expect(issue.valid?).to be_falsey
end
- it 'creates a new spam_log' do
+ it "creates a new spam_log" do
expect {issue}.to change {SpamLog.count}.from(0).to(1)
end
- it 'assigns a spam_log to an issue' do
+ it "assigns a spam_log to an issue" do
expect(issue.spam_log).to eq(SpamLog.last)
end
end
- context 'when akismet does not detect spam' do
+ context "when akismet does not detect spam" do
before do
allow_any_instance_of(AkismetService).to receive(:spam?).and_return(false)
end
- it 'does not mark an issue as a spam ' do
+ it "does not mark an issue as a spam " do
expect(issue).not_to be_spam
end
- it 'an issue is valid ' do
+ it "an issue is valid " do
expect(issue.valid?).to be_truthy
end
- it 'does not assign a spam_log to an issue' do
+ it "does not assign a spam_log to an issue" do
expect(issue.spam_log).to be_nil
end
end
diff --git a/spec/services/issues/duplicate_service_spec.rb b/spec/services/issues/duplicate_service_spec.rb
index 089e77cc88b..332773ec130 100644
--- a/spec/services/issues/duplicate_service_spec.rb
+++ b/spec/services/issues/duplicate_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::DuplicateService do
let(:user) { create(:user) }
@@ -10,9 +10,9 @@ describe Issues::DuplicateService do
subject { described_class.new(duplicate_project, user, {}) }
- describe '#execute' do
- context 'when the issues passed are the same' do
- it 'does nothing' do
+ describe "#execute" do
+ context "when the issues passed are the same" do
+ it "does nothing" do
expect(subject).not_to receive(:close_service)
expect(SystemNoteService).not_to receive(:mark_duplicate_issue)
expect(SystemNoteService).not_to receive(:mark_canonical_issue_of_duplicate)
@@ -21,12 +21,12 @@ describe Issues::DuplicateService do
end
end
- context 'when the user cannot update the duplicate issue' do
+ context "when the user cannot update the duplicate issue" do
before do
canonical_project.add_reporter(user)
end
- it 'does nothing' do
+ it "does nothing" do
expect(subject).not_to receive(:close_service)
expect(SystemNoteService).not_to receive(:mark_duplicate_issue)
expect(SystemNoteService).not_to receive(:mark_canonical_issue_of_duplicate)
@@ -35,12 +35,12 @@ describe Issues::DuplicateService do
end
end
- context 'when the user cannot comment on the canonical issue' do
+ context "when the user cannot comment on the canonical issue" do
before do
duplicate_project.add_reporter(user)
end
- it 'does nothing' do
+ it "does nothing" do
expect(subject).not_to receive(:close_service)
expect(SystemNoteService).not_to receive(:mark_duplicate_issue)
expect(SystemNoteService).not_to receive(:mark_canonical_issue_of_duplicate)
@@ -49,27 +49,27 @@ describe Issues::DuplicateService do
end
end
- context 'when the user can mark the issue as a duplicate' do
+ context "when the user can mark the issue as a duplicate" do
before do
canonical_project.add_reporter(user)
duplicate_project.add_reporter(user)
end
- it 'closes the duplicate issue' do
+ it "closes the duplicate issue" do
subject.execute(duplicate_issue, canonical_issue)
expect(duplicate_issue.reload).to be_closed
expect(canonical_issue.reload).to be_open
end
- it 'adds a system note to the duplicate issue' do
+ it "adds a system note to the duplicate issue" do
expect(SystemNoteService)
.to receive(:mark_duplicate_issue).with(duplicate_issue, duplicate_project, user, canonical_issue)
subject.execute(duplicate_issue, canonical_issue)
end
- it 'adds a system note to the canonical issue' do
+ it "adds a system note to the canonical issue" do
expect(SystemNoteService)
.to receive(:mark_canonical_issue_of_duplicate).with(canonical_issue, canonical_project, user, duplicate_issue)
diff --git a/spec/services/issues/import_csv_service_spec.rb b/spec/services/issues/import_csv_service_spec.rb
index 516a1137319..4826978a051 100644
--- a/spec/services/issues/import_csv_service_spec.rb
+++ b/spec/services/issues/import_csv_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Issues::ImportCsvService do
let(:project) { create(:project) }
@@ -13,11 +13,11 @@ describe Issues::ImportCsvService do
described_class.new(user, project, uploader).execute
end
- describe '#execute' do
- context 'invalid file' do
- let(:file) { fixture_file_upload('spec/fixtures/banana_sample.gif') }
+ describe "#execute" do
+ context "invalid file" do
+ let(:file) { fixture_file_upload("spec/fixtures/banana_sample.gif") }
- it 'returns invalid file error' do
+ it "returns invalid file error" do
expect_any_instance_of(Notify).to receive(:import_issues_csv_email)
expect(subject[:success]).to eq(0)
@@ -25,10 +25,10 @@ describe Issues::ImportCsvService do
end
end
- context 'comma delimited file' do
- let(:file) { fixture_file_upload('spec/fixtures/csv_comma.csv') }
+ context "comma delimited file" do
+ let(:file) { fixture_file_upload("spec/fixtures/csv_comma.csv") }
- it 'imports CSV without errors' do
+ it "imports CSV without errors" do
expect_any_instance_of(Notify).to receive(:import_issues_csv_email)
expect(subject[:success]).to eq(3)
@@ -37,10 +37,10 @@ describe Issues::ImportCsvService do
end
end
- context 'tab delimited file with error row' do
- let(:file) { fixture_file_upload('spec/fixtures/csv_tab.csv') }
+ context "tab delimited file with error row" do
+ let(:file) { fixture_file_upload("spec/fixtures/csv_tab.csv") }
- it 'imports CSV with some error rows' do
+ it "imports CSV with some error rows" do
expect_any_instance_of(Notify).to receive(:import_issues_csv_email)
expect(subject[:success]).to eq(2)
@@ -49,10 +49,10 @@ describe Issues::ImportCsvService do
end
end
- context 'semicolon delimited file with CRLF' do
- let(:file) { fixture_file_upload('spec/fixtures/csv_semicolon.csv') }
+ context "semicolon delimited file with CRLF" do
+ let(:file) { fixture_file_upload("spec/fixtures/csv_semicolon.csv") }
- it 'imports CSV with a blank row' do
+ it "imports CSV with a blank row" do
expect_any_instance_of(Notify).to receive(:import_issues_csv_email)
expect(subject[:success]).to eq(3)
diff --git a/spec/services/issues/move_service_spec.rb b/spec/services/issues/move_service_spec.rb
index 1e088bc7d9b..5608fdcd1b1 100644
--- a/spec/services/issues/move_service_spec.rb
+++ b/spec/services/issues/move_service_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::MoveService do
let(:user) { create(:user) }
let(:author) { create(:user) }
- let(:title) { 'Some issue' }
- let(:description) { 'Some issue description' }
+ let(:title) { "Some issue" }
+ let(:description) { "Some issue description" }
let(:group) { create(:group, :private) }
let(:sub_group_1) { create(:group, :private, parent: group) }
let(:sub_group_2) { create(:group, :private, parent: group) }
@@ -19,89 +19,89 @@ describe Issues::MoveService do
described_class.new(old_project, user)
end
- shared_context 'user can move issue' do
+ shared_context "user can move issue" do
before do
old_project.add_reporter(user)
new_project.add_reporter(user)
end
end
- describe '#execute' do
- shared_context 'issue move executed' do
+ describe "#execute" do
+ shared_context "issue move executed" do
let!(:award_emoji) { create(:award_emoji, awardable: old_issue) }
let!(:new_issue) { move_service.execute(old_issue, new_project) }
end
- context 'issue movable' do
- include_context 'user can move issue'
+ context "issue movable" do
+ include_context "user can move issue"
- context 'generic issue' do
- include_context 'issue move executed'
+ context "generic issue" do
+ include_context "issue move executed"
- it 'creates a new issue in a new project' do
+ it "creates a new issue in a new project" do
expect(new_issue.project).to eq new_project
end
- it 'rewrites issue title' do
+ it "rewrites issue title" do
expect(new_issue.title).to eq title
end
- it 'rewrites issue description' do
+ it "rewrites issue description" do
expect(new_issue.description).to eq description
end
- it 'adds system note to old issue at the end' do
- expect(old_issue.notes.last.note).to start_with 'moved to'
+ it "adds system note to old issue at the end" do
+ expect(old_issue.notes.last.note).to start_with "moved to"
end
- it 'adds system note to new issue at the end' do
- expect(new_issue.notes.last.note).to start_with 'moved from'
+ it "adds system note to new issue at the end" do
+ expect(new_issue.notes.last.note).to start_with "moved from"
end
- it 'closes old issue' do
+ it "closes old issue" do
expect(old_issue.closed?).to be true
end
- it 'persists new issue' do
+ it "persists new issue" do
expect(new_issue.persisted?).to be true
end
- it 'persists all changes' do
+ it "persists all changes" do
expect(old_issue.changed?).to be false
expect(new_issue.changed?).to be false
end
- it 'preserves author' do
+ it "preserves author" do
expect(new_issue.author).to eq author
end
- it 'creates a new internal id for issue' do
+ it "creates a new internal id for issue" do
expect(new_issue.iid).to be 1
end
- it 'marks issue as moved' do
+ it "marks issue as moved" do
expect(old_issue.moved?).to eq true
expect(old_issue.moved_to).to eq new_issue
end
- it 'preserves create time' do
+ it "preserves create time" do
expect(old_issue.created_at).to eq new_issue.created_at
end
- it 'moves the award emoji' do
+ it "moves the award emoji" do
expect(old_issue.award_emoji.first.name).to eq new_issue.reload.award_emoji.first.name
end
end
- context 'issue with assignee' do
+ context "issue with assignee" do
let(:assignee) { create(:user) }
before do
old_issue.assignees = [assignee]
end
- it 'preserves assignee with access to the new issue' do
+ it "preserves assignee with access to the new issue" do
new_project.add_reporter(assignee)
new_issue = move_service.execute(old_issue, new_project)
@@ -109,26 +109,26 @@ describe Issues::MoveService do
expect(new_issue.assignees).to eq([assignee])
end
- it 'ignores assignee without access to the new issue' do
+ it "ignores assignee without access to the new issue" do
new_issue = move_service.execute(old_issue, new_project)
expect(new_issue.assignees).to be_empty
end
end
- context 'moving to same project' do
+ context "moving to same project" do
let(:new_project) { old_project }
- it 'raises error' do
+ it "raises error" do
expect { move_service.execute(old_issue, new_project) }
.to raise_error(StandardError, /Cannot move issue/)
end
end
- context 'project issue hooks' do
+ context "project issue hooks" do
let!(:hook) { create(:project_hook, project: old_project, issues_events: true) }
- it 'executes project issue hooks' do
+ it "executes project issue hooks" do
allow_any_instance_of(WebHookService).to receive(:execute)
# Ideally, we'd test that `WebHookWorker.jobs.size` increased by 1,
@@ -140,15 +140,15 @@ describe Issues::MoveService do
end
end
- describe 'move permissions' do
+ describe "move permissions" do
let(:move) { move_service.execute(old_issue, new_project) }
- context 'user is reporter in both projects' do
- include_context 'user can move issue'
+ context "user is reporter in both projects" do
+ include_context "user can move issue"
it { expect { move }.not_to raise_error }
end
- context 'user is reporter only in new project' do
+ context "user is reporter only in new project" do
before do
new_project.add_reporter(user)
end
@@ -156,7 +156,7 @@ describe Issues::MoveService do
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
- context 'user is reporter only in old project' do
+ context "user is reporter only in old project" do
before do
old_project.add_reporter(user)
end
@@ -164,7 +164,7 @@ describe Issues::MoveService do
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
- context 'user is reporter in one project and guest in another' do
+ context "user is reporter in one project and guest in another" do
before do
new_project.add_guest(user)
old_project.add_reporter(user)
@@ -173,8 +173,8 @@ describe Issues::MoveService do
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
- context 'issue has already been moved' do
- include_context 'user can move issue'
+ context "issue has already been moved" do
+ include_context "user can move issue"
let(:moved_to_issue) { create(:issue) }
@@ -186,8 +186,8 @@ describe Issues::MoveService do
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
- context 'issue is not persisted' do
- include_context 'user can move issue'
+ context "issue is not persisted" do
+ include_context "user can move issue"
let(:old_issue) { build(:issue, project: old_project, author: author) }
it { expect { move }.to raise_error(StandardError, /permissions/) }
end
diff --git a/spec/services/issues/referenced_merge_requests_service_spec.rb b/spec/services/issues/referenced_merge_requests_service_spec.rb
index 61d1612829f..81ca85108bd 100644
--- a/spec/services/issues/referenced_merge_requests_service_spec.rb
+++ b/spec/services/issues/referenced_merge_requests_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper.rb'
+require "spec_helper.rb"
describe Issues::ReferencedMergeRequestsService do
def create_referencing_mr(attributes = {})
@@ -23,21 +23,21 @@ describe Issues::ReferencedMergeRequestsService do
set(:closing_mr) { create_closing_mr(source_project: project) }
set(:closing_mr_other_project) { create_closing_mr(source_project: other_project) }
- set(:referencing_mr) { create_referencing_mr(source_project: project, source_branch: 'csv') }
- set(:referencing_mr_other_project) { create_referencing_mr(source_project: other_project, source_branch: 'csv') }
+ set(:referencing_mr) { create_referencing_mr(source_project: project, source_branch: "csv") }
+ set(:referencing_mr_other_project) { create_referencing_mr(source_project: other_project, source_branch: "csv") }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- it 'returns a list of sorted merge requests' do
+ describe "#execute" do
+ it "returns a list of sorted merge requests" do
mrs, closed_by_mrs = service.execute(issue)
expect(mrs).to eq([closing_mr, referencing_mr, closing_mr_other_project, referencing_mr_other_project])
expect(closed_by_mrs).to eq([closing_mr, closing_mr_other_project])
end
- context 'performance' do
- it 'does not run extra queries when extra namespaces are included', :use_clean_rails_memory_store_caching do
+ context "performance" do
+ it "does not run extra queries when extra namespaces are included", :use_clean_rails_memory_store_caching do
service.execute(issue) # warm cache
control_count = ActiveRecord::QueryRecorder.new { service.execute(issue) }.count
@@ -48,7 +48,7 @@ describe Issues::ReferencedMergeRequestsService do
expect { service.execute(issue) }.not_to exceed_query_limit(control_count)
end
- it 'preloads the head pipeline for each merge request, and its routes' do
+ it "preloads the head pipeline for each merge request, and its routes" do
# Hack to ensure no data is preserved on issue before starting the spec,
# to avoid false negatives
reloaded_issue = Issue.find(issue.id)
@@ -66,7 +66,7 @@ describe Issues::ReferencedMergeRequestsService do
.not_to exceed_query_limit(control_count)
end
- it 'only loads issue notes once' do
+ it "only loads issue notes once" do
expect(issue).to receive(:notes).once.and_call_original
service.execute(issue)
@@ -74,17 +74,17 @@ describe Issues::ReferencedMergeRequestsService do
end
end
- describe '#referenced_merge_requests' do
- it 'returns the referenced merge requests' do
+ describe "#referenced_merge_requests" do
+ it "returns the referenced merge requests" do
expect(service.referenced_merge_requests(issue)).to match_array([
- closing_mr,
- closing_mr_other_project,
- referencing_mr,
- referencing_mr_other_project
- ])
+ closing_mr,
+ closing_mr_other_project,
+ referencing_mr,
+ referencing_mr_other_project,
+ ])
end
- it 'excludes cross project references if the user cannot read cross project' do
+ it "excludes cross project references if the user cannot read cross project" do
allow(Ability).to receive(:allowed?).and_call_original
expect(Ability).to receive(:allowed?).with(user, :read_cross_project).at_least(:once).and_return(false)
@@ -92,8 +92,8 @@ describe Issues::ReferencedMergeRequestsService do
expect(service.referenced_merge_requests(issue)).not_to include(referencing_mr_other_project)
end
- context 'performance' do
- it 'does not run a query for each note author', :use_clean_rails_memory_store_caching do
+ context "performance" do
+ it "does not run a query for each note author", :use_clean_rails_memory_store_caching do
service.referenced_merge_requests(issue) # warm cache
control_count = ActiveRecord::QueryRecorder.new { service.referenced_merge_requests(issue) }.count
@@ -105,21 +105,21 @@ describe Issues::ReferencedMergeRequestsService do
end
end
- describe '#closed_by_merge_requests' do
+ describe "#closed_by_merge_requests" do
let(:closed_issue) { build(:issue, :closed, project: project)}
- it 'returns the open merge requests that close this issue' do
- create_closing_mr(source_project: project, state: 'closed')
+ it "returns the open merge requests that close this issue" do
+ create_closing_mr(source_project: project, state: "closed")
expect(service.closed_by_merge_requests(issue)).to match_array([closing_mr, closing_mr_other_project])
end
- it 'returns an empty array when the current issue is closed already' do
+ it "returns an empty array when the current issue is closed already" do
expect(service.closed_by_merge_requests(closed_issue)).to eq([])
end
- context 'performance' do
- it 'does not run a query for each note author', :use_clean_rails_memory_store_caching do
+ context "performance" do
+ it "does not run a query for each note author", :use_clean_rails_memory_store_caching do
service.closed_by_merge_requests(issue) # warm cache
control_count = ActiveRecord::QueryRecorder.new { service.closed_by_merge_requests(issue) }.count
diff --git a/spec/services/issues/related_branches_service_spec.rb b/spec/services/issues/related_branches_service_spec.rb
index c2e1eba6a63..f68c91af518 100644
--- a/spec/services/issues/related_branches_service_spec.rb
+++ b/spec/services/issues/related_branches_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::RelatedBranchesService do
let(:user) { create(:admin) }
@@ -6,7 +6,7 @@ describe Issues::RelatedBranchesService do
subject { described_class.new(issue.project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
allow(issue.project.repository).to receive(:branch_names).and_return(["mpempe", "#{issue.iid}mepmep", issue.to_branch_name, "#{issue.iid}-branch"])
end
@@ -16,20 +16,20 @@ describe Issues::RelatedBranchesService do
end
it "selects the right branches when there is a referenced merge request" do
- merge_request = create(:merge_request, { description: "Closes ##{issue.iid}",
- source_project: issue.project,
- source_branch: "#{issue.iid}-branch" })
+ merge_request = create(:merge_request, {description: "Closes ##{issue.iid}",
+ source_project: issue.project,
+ source_branch: "#{issue.iid}-branch",})
merge_request.create_cross_references!(user)
referenced_merge_requests = Issues::ReferencedMergeRequestsService
- .new(issue.project, user)
- .referenced_merge_requests(issue)
+ .new(issue.project, user)
+ .referenced_merge_requests(issue)
expect(referenced_merge_requests).not_to be_empty
expect(subject.execute(issue)).to eq([issue.to_branch_name])
end
- it 'excludes stable branches from the related branches' do
+ it "excludes stable branches from the related branches" do
allow(issue.project.repository).to receive(:branch_names)
.and_return(["#{issue.iid}-0-stable"])
diff --git a/spec/services/issues/reopen_service_spec.rb b/spec/services/issues/reopen_service_spec.rb
index 2a56075419b..d667f43d570 100644
--- a/spec/services/issues/reopen_service_spec.rb
+++ b/spec/services/issues/reopen_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Issues::ReopenService do
let(:project) { create(:project) }
let(:issue) { create(:issue, :closed, project: project) }
- describe '#execute' do
- context 'when user is not authorized to reopen issue' do
+ describe "#execute" do
+ context "when user is not authorized to reopen issue" do
before do
guest = create(:user)
project.add_guest(guest)
@@ -15,34 +15,34 @@ describe Issues::ReopenService do
end
end
- it 'does not reopen the issue' do
+ it "does not reopen the issue" do
expect(issue).to be_closed
end
end
- context 'when user is authorized to reopen issue' do
+ context "when user is authorized to reopen issue" do
let(:user) { create(:user) }
before do
project.add_maintainer(user)
end
- it 'invalidates counter cache for assignees' do
+ it "invalidates counter cache for assignees" do
issue.assignees << user
expect_any_instance_of(User).to receive(:invalidate_issue_cache_counts)
described_class.new(project, user).execute(issue)
end
- it 'refreshes the number of opened issues' do
+ it "refreshes the number of opened issues" do
service = described_class.new(project, user)
expect { service.execute(issue) }
.to change { project.open_issues_count }.from(0).to(1)
end
- context 'when issue is not confidential' do
- it 'executes issue hooks' do
+ context "when issue is not confidential" do
+ it "executes issue hooks" do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :issue_hooks)
@@ -50,8 +50,8 @@ describe Issues::ReopenService do
end
end
- context 'when issue is confidential' do
- it 'executes confidential issue hooks' do
+ context "when issue is confidential" do
+ it "executes confidential issue hooks" do
issue = create(:issue, :confidential, :closed, project: project)
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
diff --git a/spec/services/issues/resolve_discussions_spec.rb b/spec/services/issues/resolve_discussions_spec.rb
index b6cfc09da65..c60fb36151d 100644
--- a/spec/services/issues/resolve_discussions_spec.rb
+++ b/spec/services/issues/resolve_discussions_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper.rb'
+require "spec_helper.rb"
describe Issues::ResolveDiscussions do
class DummyService < Issues::BaseService
@@ -56,9 +56,9 @@ describe Issues::ResolveDiscussions do
it "contains all discussions when only a merge request is passed" do
second_discussion = Discussion.new([create(:diff_note_on_merge_request,
- noteable: merge_request,
- project: merge_request.target_project,
- line_number: 15)])
+ noteable: merge_request,
+ project: merge_request.target_project,
+ line_number: 15)])
service = DummyService.new(
project,
user,
@@ -73,10 +73,9 @@ describe Issues::ResolveDiscussions do
it "contains only unresolved discussions" do
_second_discussion = Discussion.new([create(:diff_note_on_merge_request, :resolved,
- noteable: merge_request,
- project: merge_request.target_project,
- line_number: 15
- )])
+ noteable: merge_request,
+ project: merge_request.target_project,
+ line_number: 15)])
service = DummyService.new(
project,
user,
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 931e47d3a77..062e2d004d1 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -1,5 +1,4 @@
-# coding: utf-8
-require 'spec_helper'
+require "spec_helper"
describe Issues::UpdateService, :mailer do
let(:user) { create(:user) }
@@ -10,7 +9,7 @@ describe Issues::UpdateService, :mailer do
let(:label2) { create(:label) }
let(:issue) do
- create(:issue, title: 'Old title',
+ create(:issue, title: "Old title",
description: "for #{user2.to_reference}",
assignee_ids: [user3.id],
project: project,
@@ -23,10 +22,10 @@ describe Issues::UpdateService, :mailer do
project.add_developer(user3)
end
- describe 'execute' do
+ describe "execute" do
def find_note(starting_with)
issue.notes.find do |note|
- note && note.note.start_with?(starting_with)
+ note&.note&.start_with?(starting_with)
end
end
@@ -34,34 +33,34 @@ describe Issues::UpdateService, :mailer do
issue
.notes
.joins(:system_note_metadata)
- .where(system_note_metadata: { action: action })
+ .where(system_note_metadata: {action: action})
end
def update_issue(opts)
described_class.new(project, user, opts).execute(issue)
end
- context 'valid params' do
+ context "valid params" do
let(:opts) do
{
- title: 'New title',
- description: 'Also please fix',
+ title: "New title",
+ description: "Also please fix",
assignee_ids: [user2.id],
- state_event: 'close',
+ state_event: "close",
label_ids: [label.id],
due_date: Date.tomorrow,
- discussion_locked: true
+ discussion_locked: true,
}
end
- it 'updates the issue with the given params' do
+ it "updates the issue with the given params" do
expect(TodosDestroyer::ConfidentialIssueWorker).not_to receive(:perform_in)
update_issue(opts)
expect(issue).to be_valid
- expect(issue.title).to eq 'New title'
- expect(issue.description).to eq 'Also please fix'
+ expect(issue.title).to eq "New title"
+ expect(issue.description).to eq "Also please fix"
expect(issue.assignees).to match_array([user2])
expect(issue).to be_closed
expect(issue.labels).to match_array [label]
@@ -69,20 +68,20 @@ describe Issues::UpdateService, :mailer do
expect(issue.discussion_locked).to be_truthy
end
- it 'refreshes the number of open issues when the issue is made confidential', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open issues when the issue is made confidential", :use_clean_rails_memory_store_caching do
issue # make sure the issue is created first so our counts are correct.
expect { update_issue(confidential: true) }
.to change { project.open_issues_count }.from(1).to(0)
end
- it 'enqueues ConfidentialIssueWorker when an issue is made confidential' do
+ it "enqueues ConfidentialIssueWorker when an issue is made confidential" do
expect(TodosDestroyer::ConfidentialIssueWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, issue.id)
update_issue(confidential: true)
end
- it 'does not enqueue ConfidentialIssueWorker when an issue is made non confidential' do
+ it "does not enqueue ConfidentialIssueWorker when an issue is made non confidential" do
# set confidentiality to true before the actual update
issue.update!(confidential: true)
@@ -91,14 +90,14 @@ describe Issues::UpdateService, :mailer do
update_issue(confidential: false)
end
- it 'updates open issue counter for assignees when issue is reassigned' do
+ it "updates open issue counter for assignees when issue is reassigned" do
update_issue(assignee_ids: [user2.id])
expect(user3.assigned_open_issues_count).to eq 0
expect(user2.assigned_open_issues_count).to eq 1
end
- it 'sorts issues as specified by parameters' do
+ it "sorts issues as specified by parameters" do
issue1 = create(:issue, project: project, assignees: [user3])
issue2 = create(:issue, project: project, assignees: [user3])
@@ -114,7 +113,7 @@ describe Issues::UpdateService, :mailer do
expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position)
end
- context 'when moving issue between issues from different projects', :nested_groups do
+ context "when moving issue between issues from different projects", :nested_groups do
let(:group) { create(:group) }
let(:subgroup) { create(:group, parent: group) }
@@ -130,7 +129,7 @@ describe Issues::UpdateService, :mailer do
group.add_developer(user)
end
- it 'sorts issues as specified by parameters' do
+ it "sorts issues as specified by parameters" do
# Moving all issues to end here like the last example won't work since
# all projects only have the same issue count
# so their relative_position will be the same.
@@ -147,18 +146,18 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'when current user cannot admin issues in the project' do
+ context "when current user cannot admin issues in the project" do
let(:guest) { create(:user) }
before do
project.add_guest(guest)
end
- it 'filters out params that cannot be set without the :admin_issue permission' do
+ it "filters out params that cannot be set without the :admin_issue permission" do
described_class.new(project, guest, opts).execute(issue)
expect(issue).to be_valid
- expect(issue.title).to eq 'New title'
- expect(issue.description).to eq 'Also please fix'
+ expect(issue.title).to eq "New title"
+ expect(issue.description).to eq "Also please fix"
expect(issue.assignees).to match_array [user3]
expect(issue.labels).to be_empty
expect(issue.milestone).to be_nil
@@ -167,14 +166,14 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'with background jobs processed' do
+ context "with background jobs processed" do
before do
perform_enqueued_jobs do
update_issue(opts)
end
end
- it 'sends 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
@@ -182,14 +181,14 @@ describe Issues::UpdateService, :mailer do
expect(email.subject).to include(issue.title)
end
- it 'creates system note about issue reassign' do
- note = find_note('assigned to')
+ it "creates system note about issue reassign" do
+ note = find_note("assigned to")
expect(note).not_to be_nil
expect(note.note).to include "assigned to #{user2.to_reference}"
end
- it 'creates a resource label event' do
+ it "creates a resource label event" do
event = issue.resource_label_events.last
expect(event).not_to be_nil
@@ -197,62 +196,62 @@ describe Issues::UpdateService, :mailer do
expect(event.user_id).to eq user.id
end
- it 'creates system note about title change' do
- note = find_note('changed title')
+ it "creates system note about title change" do
+ note = find_note("changed title")
expect(note).not_to be_nil
- expect(note.note).to eq 'changed title from **{-Old-} title** to **{+New+} title**'
+ expect(note.note).to eq "changed title from **{-Old-} title** to **{+New+} title**"
end
- it 'creates system note about discussion lock' do
- note = find_note('locked this issue')
+ it "creates system note about discussion lock" do
+ note = find_note("locked this issue")
expect(note).not_to be_nil
- expect(note.note).to eq 'locked this issue'
+ expect(note.note).to eq "locked this issue"
end
end
end
- context 'when description changed' do
- it 'creates system note about description change' do
- update_issue(description: 'Changed description')
+ context "when description changed" do
+ it "creates system note about description change" do
+ update_issue(description: "Changed description")
- note = find_note('changed the description')
+ note = find_note("changed the description")
expect(note).not_to be_nil
- expect(note.note).to eq('changed the description')
+ expect(note.note).to eq("changed the description")
end
end
- context 'when issue turns confidential' do
+ context "when issue turns confidential" do
let(:opts) do
{
- title: 'New title',
- description: 'Also please fix',
+ title: "New title",
+ description: "Also please fix",
assignee_ids: [user2],
- state_event: 'close',
+ state_event: "close",
label_ids: [label.id],
- confidential: true
+ confidential: true,
}
end
- it 'creates system note about confidentiality change' do
+ it "creates system note about confidentiality change" do
update_issue(confidential: true)
- note = find_note('made the issue confidential')
+ note = find_note("made the issue confidential")
expect(note).not_to be_nil
- expect(note.note).to eq 'made the issue confidential'
+ expect(note.note).to eq "made the issue confidential"
end
- it 'executes confidential issue hooks' do
+ it "executes confidential issue hooks" do
expect(project).to receive(:execute_hooks).with(an_instance_of(Hash), :confidential_issue_hooks)
expect(project).to receive(:execute_services).with(an_instance_of(Hash), :confidential_issue_hooks)
update_issue(confidential: true)
end
- it 'does not update assignee_id with unauthorized users' do
+ it "does not update assignee_id with unauthorized users" do
project.update(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
update_issue(confidential: true)
non_member = create(:user)
@@ -264,47 +263,47 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'todos' do
+ context "todos" do
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
- context 'when the title change' do
+ context "when the title change" do
before do
- update_issue(title: 'New title')
+ update_issue(title: "New title")
end
- it 'marks pending todos as done' do
+ it "marks pending todos as done" do
expect(todo.reload.done?).to eq true
end
- it 'does not create any new todos' do
+ it "does not create any new todos" do
expect(Todo.count).to eq(1)
end
end
- context 'when the description change' do
+ context "when the description change" do
before do
update_issue(description: "Also please fix #{user2.to_reference} #{user3.to_reference}")
end
- it 'marks todos as done' do
+ it "marks todos as done" do
expect(todo.reload.done?).to eq true
end
- it 'creates only 1 new todo' do
+ it "creates only 1 new todo" do
expect(Todo.count).to eq(2)
end
end
- context 'when is reassigned' do
+ context "when is reassigned" do
before do
update_issue(assignees: [user2])
end
- it 'marks previous assignee todos as done' do
+ it "marks previous assignee todos as done" do
expect(todo.reload.done?).to eq true
end
- it 'creates a todo for new assignee' do
+ it "creates a todo for new assignee" do
attributes = {
project: project,
author: user,
@@ -312,21 +311,21 @@ describe Issues::UpdateService, :mailer do
target_id: issue.id,
target_type: issue.class.name,
action: Todo::ASSIGNED,
- state: :pending
+ state: :pending,
}
expect(Todo.where(attributes).count).to eq 1
end
end
- context 'when a new assignee added' do
+ context "when a new assignee added" do
subject { update_issue(assignees: issue.assignees + [user2]) }
- it 'creates only 1 new todo' do
+ it "creates only 1 new todo" do
expect { subject }.to change { Todo.count }.by(1)
end
- it 'creates a todo for new assignee' do
+ it "creates a todo for new assignee" do
subject
attributes = {
@@ -336,14 +335,14 @@ describe Issues::UpdateService, :mailer do
target_id: issue.id,
target_type: issue.class.name,
action: Todo::ASSIGNED,
- state: :pending
+ state: :pending,
}
expect(Todo.where(attributes).count).to eq(1)
end
end
- context 'when the milestone is removed' do
+ context "when the milestone is removed" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
@@ -353,9 +352,9 @@ describe Issues::UpdateService, :mailer do
end
end
- it_behaves_like 'system notes for milestones'
+ it_behaves_like "system notes for milestones"
- it 'sends notifications for subscribers of changed milestone' do
+ it "sends notifications for subscribers of changed milestone" do
issue.milestone = create(:milestone)
issue.save
@@ -369,7 +368,7 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'when the milestone is changed' do
+ context "when the milestone is changed" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
@@ -379,15 +378,15 @@ describe Issues::UpdateService, :mailer do
end
end
- it 'marks todos as done' do
+ it "marks todos as done" do
update_issue(milestone: create(:milestone))
expect(todo.reload.done?).to eq true
end
- it_behaves_like 'system notes for milestones'
+ it_behaves_like "system notes for milestones"
- it 'sends notifications for subscribers of changed milestone' do
+ it "sends notifications for subscribers of changed milestone" do
perform_enqueued_jobs do
update_issue(milestone: create(:milestone))
end
@@ -397,24 +396,24 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'when the labels change' do
+ context "when the labels change" do
before do
Timecop.freeze(1.minute.from_now) do
update_issue(label_ids: [label.id])
end
end
- it 'marks todos as done' do
+ it "marks todos as done" do
expect(todo.reload.done?).to eq true
end
- it 'updates updated_at' do
+ it "updates updated_at" do
expect(issue.reload.updated_at).to be > Time.now
end
end
end
- context 'when the issue is relabeled' do
+ context "when the issue is relabeled" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
@@ -424,8 +423,8 @@ describe Issues::UpdateService, :mailer do
end
end
- it 'sends notifications for subscribers of newly added labels' do
- opts = { label_ids: [label.id] }
+ it "sends notifications for subscribers of newly added labels" do
+ opts = {label_ids: [label.id]}
perform_enqueued_jobs do
@issue = described_class.new(project, user, opts).execute(issue)
@@ -435,13 +434,13 @@ describe Issues::UpdateService, :mailer do
should_not_email(non_subscriber)
end
- context 'when issue has the `label` label' do
+ context "when issue has the `label` label" do
before do
issue.labels << label
end
- it 'does not send notifications for existing labels' do
- opts = { label_ids: [label.id, label2.id] }
+ it "does not send notifications for existing labels" do
+ opts = {label_ids: [label.id, label2.id]}
perform_enqueued_jobs do
@issue = described_class.new(project, user, opts).execute(issue)
@@ -451,8 +450,8 @@ describe Issues::UpdateService, :mailer do
should_not_email(non_subscriber)
end
- it 'does not send notifications for removed labels' do
- opts = { label_ids: [label2.id] }
+ it "does not send notifications for removed labels" do
+ opts = {label_ids: [label2.id]}
perform_enqueued_jobs do
@issue = described_class.new(project, user, opts).execute(issue)
@@ -464,150 +463,150 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'when issue has tasks' do
+ context "when issue has tasks" do
before do
update_issue(description: "- [ ] Task 1\n- [ ] Task 2")
end
it { expect(issue.tasks?).to eq(true) }
- it_behaves_like 'updating a single task'
+ it_behaves_like "updating a single task"
- context 'when tasks are marked as completed' do
+ context "when tasks are marked as completed" do
before do
update_issue(description: "- [x] Task 1\n- [X] Task 2")
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 1** as completed')
- note2 = find_note('marked the task **Task 2** as completed')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 1** as completed")
+ note2 = find_note("marked the task **Task 2** as completed")
expect(note1).not_to be_nil
expect(note2).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
- context 'when tasks are marked as incomplete' do
+ context "when tasks are marked as incomplete" do
before do
update_issue(description: "- [x] Task 1\n- [X] Task 2")
update_issue(description: "- [ ] Task 1\n- [ ] Task 2")
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 1** as incomplete')
- note2 = find_note('marked the task **Task 2** as incomplete')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 1** as incomplete")
+ note2 = find_note("marked the task **Task 2** as incomplete")
expect(note1).not_to be_nil
expect(note2).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
- context 'when tasks position has been modified' do
+ context "when tasks position has been modified" do
before do
update_issue(description: "- [x] Task 1\n- [X] Task 2")
update_issue(description: "- [x] Task 1\n- [ ] Task 3\n- [ ] Task 2")
end
- it 'does not create a system note for the task' do
- task_note = find_note('marked the task **Task 2** as incomplete')
- description_notes = find_notes('description')
+ it "does not create a system note for the task" do
+ task_note = find_note("marked the task **Task 2** as incomplete")
+ description_notes = find_notes("description")
expect(task_note).to be_nil
expect(description_notes.length).to eq(2)
end
end
- context 'when a Task list with a completed item is totally replaced' do
+ context "when a Task list with a completed item is totally replaced" do
before do
update_issue(description: "- [ ] Task 1\n- [X] Task 2")
update_issue(description: "- [ ] One\n- [ ] Two\n- [ ] Three")
end
- it 'does not create a system note referencing the position the old item' do
- task_note = find_note('marked the task **Two** as incomplete')
- description_notes = find_notes('description')
+ it "does not create a system note referencing the position the old item" do
+ task_note = find_note("marked the task **Two** as incomplete")
+ description_notes = find_notes("description")
expect(task_note).to be_nil
expect(description_notes.length).to eq(2)
end
- it 'does not generate a new note at all' do
- expect do
+ it "does not generate a new note at all" do
+ expect {
update_issue(description: "- [ ] One\n- [ ] Two\n- [ ] Three")
- end.not_to change { Note.count }
+ }.not_to change { Note.count }
end
end
end
- context 'updating labels' do
+ context "updating labels" do
let(:label3) { create(:label, project: project) }
let(:result) { described_class.new(project, user, params).execute(issue).reload }
- context 'when add_label_ids and label_ids are passed' do
- let(:params) { { label_ids: [label.id], add_label_ids: [label3.id] } }
+ context "when add_label_ids and label_ids are passed" do
+ let(:params) { {label_ids: [label.id], add_label_ids: [label3.id]} }
- it 'ignores the label_ids parameter' do
+ it "ignores the label_ids parameter" do
expect(result.label_ids).not_to include(label.id)
end
- it 'adds the passed labels' do
+ it "adds the passed labels" do
expect(result.label_ids).to include(label3.id)
end
end
- context 'when remove_label_ids and label_ids are passed' do
- let(:params) { { label_ids: [], remove_label_ids: [label.id] } }
+ context "when remove_label_ids and label_ids are passed" do
+ let(:params) { {label_ids: [], remove_label_ids: [label.id]} }
before do
issue.update(labels: [label, label3])
end
- it 'ignores the label_ids parameter' do
+ it "ignores the label_ids parameter" do
expect(result.label_ids).not_to be_empty
end
- it 'removes the passed labels' do
+ it "removes the passed labels" do
expect(result.label_ids).not_to include(label.id)
end
end
- context 'when add_label_ids and remove_label_ids are passed' do
- let(:params) { { add_label_ids: [label3.id], remove_label_ids: [label.id] } }
+ context "when add_label_ids and remove_label_ids are passed" do
+ let(:params) { {add_label_ids: [label3.id], remove_label_ids: [label.id]} }
before do
issue.update(labels: [label])
end
- it 'adds the passed labels' do
+ it "adds the passed labels" do
expect(result.label_ids).to include(label3.id)
end
- it 'removes the passed labels' do
+ it "removes the passed labels" do
expect(result.label_ids).not_to include(label.id)
end
end
end
- context 'updating asssignee_id' do
- it 'does not update assignee when assignee_id is invalid' do
+ context "updating asssignee_id" do
+ it "does not update assignee when assignee_id is invalid" do
update_issue(assignee_ids: [-1])
expect(issue.reload.assignees).to eq([user3])
end
- it 'unassigns assignee when user id is 0' do
+ it "unassigns assignee when user id is 0" do
update_issue(assignee_ids: [0])
expect(issue.reload.assignees).to be_empty
end
- it 'does not update assignee_id when user cannot read issue' do
+ it "does not update assignee_id when user cannot read issue" do
update_issue(assignee_ids: [create(:user).id])
expect(issue.reload.assignees).to eq([user3])
@@ -629,24 +628,24 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'updating mentions' do
+ context "updating mentions" do
let(:mentionable) { issue }
- include_examples 'updating mentions', described_class
+ include_examples "updating mentions", described_class
end
- context 'duplicate issue' do
+ context "duplicate issue" do
let(:canonical_issue) { create(:issue, project: project) }
- context 'invalid canonical_issue_id' do
- it 'does not call the duplicate service' do
+ context "invalid canonical_issue_id" do
+ it "does not call the duplicate service" do
expect(Issues::DuplicateService).not_to receive(:new)
update_issue(canonical_issue_id: 123456789)
end
end
- context 'valid canonical_issue_id' do
- it 'calls the duplicate service with both issues' do
+ context "valid canonical_issue_id" do
+ it "calls the duplicate service with both issues" do
expect_any_instance_of(Issues::DuplicateService)
.to receive(:execute).with(issue, canonical_issue)
@@ -655,15 +654,15 @@ describe Issues::UpdateService, :mailer do
end
end
- context 'move issue to another project' do
+ context "move issue to another project" do
let(:target_project) { create(:project) }
- context 'valid project' do
+ context "valid project" do
before do
target_project.add_maintainer(user)
end
- it 'calls the move service with the proper issue and project' do
+ it "calls the move service with the proper issue and project" do
move_stub = instance_double(Issues::MoveService)
allow(Issues::MoveService).to receive(:new).and_return(move_stub)
allow(move_stub).to receive(:execute).with(issue, target_project).and_return(issue)
@@ -675,7 +674,7 @@ describe Issues::UpdateService, :mailer do
end
end
- include_examples 'issuable update service' do
+ include_examples "issuable update service" do
let(:open_issuable) { issue }
let(:closed_issuable) { create(:closed_issue, project: project) }
end
diff --git a/spec/services/keys/create_service_spec.rb b/spec/services/keys/create_service_spec.rb
index bcb436c1e46..0d015cb2b9f 100644
--- a/spec/services/keys/create_service_spec.rb
+++ b/spec/services/keys/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Keys::CreateService do
let(:user) { create(:user) }
@@ -6,8 +6,8 @@ describe Keys::CreateService do
subject { described_class.new(user, params) }
- context 'notification', :mailer do
- it 'sends a notification' do
+ context "notification", :mailer do
+ it "sends a notification" do
perform_enqueued_jobs do
subject.execute
end
@@ -15,7 +15,7 @@ describe Keys::CreateService do
end
end
- it 'creates a key' do
+ it "creates a key" do
expect { subject.execute }.to change { user.keys.where(params).count }.by(1)
end
end
diff --git a/spec/services/keys/destroy_service_spec.rb b/spec/services/keys/destroy_service_spec.rb
index 28ac72ddd42..cdc7d2ab206 100644
--- a/spec/services/keys/destroy_service_spec.rb
+++ b/spec/services/keys/destroy_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Keys::DestroyService do
let(:user) { create(:user) }
subject { described_class.new(user) }
- it 'destroys a key' do
+ it "destroys a key" do
key = create(:key)
expect { subject.execute(key) }.to change(Key, :count).by(-1)
diff --git a/spec/services/keys/last_used_service_spec.rb b/spec/services/keys/last_used_service_spec.rb
index 8e553c2f1fa..95498eba408 100644
--- a/spec/services/keys/last_used_service_spec.rb
+++ b/spec/services/keys/last_used_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Keys::LastUsedService do
- describe '#execute', :clean_gitlab_redis_shared_state do
- it 'updates the key when it has not been used recently' do
+ describe "#execute", :clean_gitlab_redis_shared_state do
+ it "updates the key when it has not been used recently" do
key = create(:key, last_used_at: 1.year.ago)
time = Time.zone.now
@@ -11,7 +11,7 @@ describe Keys::LastUsedService do
expect(key.reload.last_used_at).to be_like_time(time)
end
- it 'does not update the key when it has been used recently' do
+ it "does not update the key when it has been used recently" do
time = 1.minute.ago
key = create(:key, last_used_at: time)
@@ -20,7 +20,7 @@ describe Keys::LastUsedService do
expect(key.last_used_at).to be_like_time(time)
end
- it 'does not update the updated_at field' do
+ it "does not update the updated_at field" do
# Since a lot of these updates could happen in parallel for different keys
# we want these updates to be as lightweight as possible, hence we want to
# make sure we _only_ update last_used_at and not always updated_at.
@@ -30,22 +30,22 @@ describe Keys::LastUsedService do
end
end
- describe '#update?', :clean_gitlab_redis_shared_state do
- it 'returns true when no last used timestamp is present' do
+ describe "#update?", :clean_gitlab_redis_shared_state do
+ it "returns true when no last used timestamp is present" do
key = build(:key, last_used_at: nil)
service = described_class.new(key)
expect(service.update?).to eq(true)
end
- it 'returns true when the key needs to be updated' do
+ it "returns true when the key needs to be updated" do
key = build(:key, last_used_at: 1.year.ago)
service = described_class.new(key)
expect(service.update?).to eq(true)
end
- it 'returns false when a lease has already been obtained' do
+ it "returns false when a lease has already been obtained" do
key = build(:key, last_used_at: 1.year.ago)
service = described_class.new(key)
@@ -53,7 +53,7 @@ describe Keys::LastUsedService do
expect(service.update?).to eq(false)
end
- it 'returns false when the key does not yet need to be updated' do
+ it "returns false when the key does not yet need to be updated" do
key = build(:key, last_used_at: 1.minute.ago)
service = described_class.new(key)
diff --git a/spec/services/labels/create_service_spec.rb b/spec/services/labels/create_service_spec.rb
index 438e6dbc628..5dd182f1e64 100644
--- a/spec/services/labels/create_service_spec.rb
+++ b/spec/services/labels/create_service_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Labels::CreateService do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
let(:group) { create(:group) }
- let(:hex_color) { '#FF0000' }
- let(:named_color) { 'red' }
- let(:upcase_color) { 'RED' }
- let(:spaced_color) { ' red ' }
- let(:unknown_color) { 'unknown' }
- let(:no_color) { '' }
+ let(:hex_color) { "#FF0000" }
+ let(:named_color) { "red" }
+ let(:upcase_color) { "RED" }
+ let(:spaced_color) { " red " }
+ let(:unknown_color) { "unknown" }
+ let(:no_color) { "" }
let(:expected_saved_color) { hex_color }
- context 'in a project' do
- context 'with color in hex-code' do
- it 'creates a label' do
+ context "in a project" do
+ context "with color in hex-code" do
+ it "creates a label" do
label = described_class.new(params_with(hex_color)).execute(project: project)
expect(label).to be_persisted
@@ -24,8 +24,8 @@ describe Labels::CreateService do
end
end
- context 'with color in allowed name' do
- it 'creates a label' do
+ context "with color in allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(named_color)).execute(project: project)
expect(label).to be_persisted
@@ -33,8 +33,8 @@ describe Labels::CreateService do
end
end
- context 'with color in up-case allowed name' do
- it 'creates a label' do
+ context "with color in up-case allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(upcase_color)).execute(project: project)
expect(label).to be_persisted
@@ -42,8 +42,8 @@ describe Labels::CreateService do
end
end
- context 'with color surrounded by spaces' do
- it 'creates a label' do
+ context "with color surrounded by spaces" do
+ it "creates a label" do
label = described_class.new(params_with(spaced_color)).execute(project: project)
expect(label).to be_persisted
@@ -51,16 +51,16 @@ describe Labels::CreateService do
end
end
- context 'with unknown color' do
- it 'doesn\'t create a label' do
+ context "with unknown color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(unknown_color)).execute(project: project)
expect(label).not_to be_persisted
end
end
- context 'with no color' do
- it 'doesn\'t create a label' do
+ context "with no color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(no_color)).execute(project: project)
expect(label).not_to be_persisted
@@ -68,9 +68,9 @@ describe Labels::CreateService do
end
end
- context 'in a group' do
- context 'with color in hex-code' do
- it 'creates a label' do
+ context "in a group" do
+ context "with color in hex-code" do
+ it "creates a label" do
label = described_class.new(params_with(hex_color)).execute(group: group)
expect(label).to be_persisted
@@ -78,8 +78,8 @@ describe Labels::CreateService do
end
end
- context 'with color in allowed name' do
- it 'creates a label' do
+ context "with color in allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(named_color)).execute(group: group)
expect(label).to be_persisted
@@ -87,8 +87,8 @@ describe Labels::CreateService do
end
end
- context 'with color in up-case allowed name' do
- it 'creates a label' do
+ context "with color in up-case allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(upcase_color)).execute(group: group)
expect(label).to be_persisted
@@ -96,8 +96,8 @@ describe Labels::CreateService do
end
end
- context 'with color surrounded by spaces' do
- it 'creates a label' do
+ context "with color surrounded by spaces" do
+ it "creates a label" do
label = described_class.new(params_with(spaced_color)).execute(group: group)
expect(label).to be_persisted
@@ -105,16 +105,16 @@ describe Labels::CreateService do
end
end
- context 'with unknown color' do
- it 'doesn\'t create a label' do
+ context "with unknown color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(unknown_color)).execute(group: group)
expect(label).not_to be_persisted
end
end
- context 'with no color' do
- it 'doesn\'t create a label' do
+ context "with no color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(no_color)).execute(group: group)
expect(label).not_to be_persisted
@@ -122,9 +122,9 @@ describe Labels::CreateService do
end
end
- context 'in admin area' do
- context 'with color in hex-code' do
- it 'creates a label' do
+ context "in admin area" do
+ context "with color in hex-code" do
+ it "creates a label" do
label = described_class.new(params_with(hex_color)).execute(template: true)
expect(label).to be_persisted
@@ -132,8 +132,8 @@ describe Labels::CreateService do
end
end
- context 'with color in allowed name' do
- it 'creates a label' do
+ context "with color in allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(named_color)).execute(template: true)
expect(label).to be_persisted
@@ -141,8 +141,8 @@ describe Labels::CreateService do
end
end
- context 'with color in up-case allowed name' do
- it 'creates a label' do
+ context "with color in up-case allowed name" do
+ it "creates a label" do
label = described_class.new(params_with(upcase_color)).execute(template: true)
expect(label).to be_persisted
@@ -150,8 +150,8 @@ describe Labels::CreateService do
end
end
- context 'with color surrounded by spaces' do
- it 'creates a label' do
+ context "with color surrounded by spaces" do
+ it "creates a label" do
label = described_class.new(params_with(spaced_color)).execute(template: true)
expect(label).to be_persisted
@@ -159,16 +159,16 @@ describe Labels::CreateService do
end
end
- context 'with unknown color' do
- it 'doesn\'t create a label' do
+ context "with unknown color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(unknown_color)).execute(template: true)
expect(label).not_to be_persisted
end
end
- context 'with no color' do
- it 'doesn\'t create a label' do
+ context "with no color" do
+ it "doesn't create a label" do
label = described_class.new(params_with(no_color)).execute(template: true)
expect(label).not_to be_persisted
@@ -179,8 +179,8 @@ describe Labels::CreateService do
def params_with(color)
{
- title: 'A Label',
- color: color
+ title: "A Label",
+ color: color,
}
end
end
diff --git a/spec/services/labels/find_or_create_service_spec.rb b/spec/services/labels/find_or_create_service_spec.rb
index 7af514a5bea..8225f19e814 100644
--- a/spec/services/labels/find_or_create_service_spec.rb
+++ b/spec/services/labels/find_or_create_service_spec.rb
@@ -1,87 +1,87 @@
-require 'spec_helper'
+require "spec_helper"
describe Labels::FindOrCreateService do
- describe '#execute' do
+ describe "#execute" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:params) do
{
- title: 'Security',
- description: 'Security related stuff.',
- color: '#FF0000'
+ title: "Security",
+ description: "Security related stuff.",
+ color: "#FF0000",
}
end
- context 'when acting on behalf of a specific user' do
+ context "when acting on behalf of a specific user" do
let(:user) { create(:user) }
- context 'when finding labels on project level' do
+ context "when finding labels on project level" do
subject(:service) { described_class.new(user, project, params) }
before do
project.add_developer(user)
end
- context 'when label does not exist at group level' do
- it 'creates a new label at project level' do
+ context "when label does not exist at group level" do
+ it "creates a new label at project level" do
expect { service.execute }.to change(project.labels, :count).by(1)
end
end
- context 'when label exists at group level' do
- it 'returns the group label' do
- group_label = create(:group_label, group: group, title: 'Security')
+ context "when label exists at group level" do
+ it "returns the group label" do
+ group_label = create(:group_label, group: group, title: "Security")
expect(service.execute).to eq group_label
end
end
- context 'when label exists at project level' do
- it 'returns the project label' do
- project_label = create(:label, project: project, title: 'Security')
+ context "when label exists at project level" do
+ it "returns the project label" do
+ project_label = create(:label, project: project, title: "Security")
expect(service.execute).to eq project_label
end
end
- context 'when include_ancestor_groups is true' do
+ context "when include_ancestor_groups is true" do
let(:group) { create(:group, :nested) }
let(:params) do
{
- title: 'Audit',
- include_ancestor_groups: true
+ title: "Audit",
+ include_ancestor_groups: true,
}
end
- it 'returns the ancestor group labels' do
- group_label = create(:group_label, group: group.parent, title: 'Audit')
+ it "returns the ancestor group labels" do
+ group_label = create(:group_label, group: group.parent, title: "Audit")
expect(service.execute).to eq group_label
end
- it 'creates new labels if labels are not found' do
+ it "creates new labels if labels are not found" do
expect { service.execute }.to change(project.labels, :count).by(1)
end
end
end
- context 'when finding labels on group level' do
+ context "when finding labels on group level" do
subject(:service) { described_class.new(user, group, params) }
before do
group.add_developer(user)
end
- context 'when label does not exist at group level' do
- it 'creates a new label at group level' do
+ context "when label does not exist at group level" do
+ it "creates a new label at group level" do
expect { service.execute }.to change(group.labels, :count).by(1)
end
end
- context 'when label exists at group level' do
- it 'returns the group label' do
- group_label = create(:group_label, group: group, title: 'Security')
+ context "when label exists at group level" do
+ it "returns the group label" do
+ group_label = create(:group_label, group: group, title: "Security")
expect(service.execute).to eq group_label
end
@@ -89,22 +89,22 @@ describe Labels::FindOrCreateService do
end
end
- context 'when authorization is not required' do
- context 'when finding labels on project level' do
+ context "when authorization is not required" do
+ context "when finding labels on project level" do
subject(:service) { described_class.new(nil, project, params) }
- it 'returns the project label' do
- project_label = create(:label, project: project, title: 'Security')
+ it "returns the project label" do
+ project_label = create(:label, project: project, title: "Security")
expect(service.execute(skip_authorization: true)).to eq project_label
end
end
- context 'when finding labels on group level' do
+ context "when finding labels on group level" do
subject(:service) { described_class.new(nil, group, params) }
- it 'returns the group label' do
- group_label = create(:group_label, group: group, title: 'Security')
+ it "returns the group label" do
+ group_label = create(:group_label, group: group, title: "Security")
expect(service.execute(skip_authorization: true)).to eq group_label
end
diff --git a/spec/services/labels/promote_service_spec.rb b/spec/services/labels/promote_service_spec.rb
index c4c7f33e36a..158c102fad6 100644
--- a/spec/services/labels/promote_service_spec.rb
+++ b/spec/services/labels/promote_service_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Labels::PromoteService do
- describe '#execute' do
+ describe "#execute" do
let!(:user) { create(:user) }
- context 'project without group' do
+ context "project without group" do
let!(:project_1) { create(:project) }
let!(:project_label_1_1) { create(:label, project: project_1) }
subject(:service) { described_class.new(project_1, user) }
- it 'fails on project without group' do
+ it "fails on project without group" do
expect(service.execute(project_label_1_1)).to be_falsey
end
end
- context 'project with group' do
+ context "project with group" do
let!(:promoted_label_name) { "Promoted Label" }
let!(:untouched_label_name) { "Untouched Label" }
let!(:promoted_description) { "Promoted Description" }
@@ -55,24 +55,24 @@ describe Labels::PromoteService do
subject(:service) { described_class.new(project_1, user) }
- it 'fails on group label' do
+ it "fails on group label" do
group_label = create(:group_label, group: group_1)
expect(service.execute(group_label)).to be_falsey
end
- it 'is truthy on success' do
+ it "is truthy on success" do
expect(service.execute(project_label_1_1)).to be_truthy
end
- it 'recreates the label as a group label' do
+ it "recreates the label as a group label" do
expect { service.execute(project_label_1_1) }
.to change(project_1.labels, :count).by(-1)
.and change(group_1.labels, :count).by(1)
expect(new_label).not_to be_nil
end
- it 'copies title, description and color' do
+ it "copies title, description and color" do
service.execute(project_label_1_1)
expect(new_label.title).to eq(promoted_label_name)
@@ -80,12 +80,12 @@ describe Labels::PromoteService do
expect(new_label.color).to eq(promoted_color)
end
- it 'merges labels with the same name in group' do
+ it "merges labels with the same name in group" do
expect { service.execute(project_label_1_1) }.to change(project_2.labels, :count).by(-1).and \
change(project_3.labels, :count).by(-1)
end
- it 'keeps users\' subscriptions' do
+ it "keeps users' subscriptions" do
user2 = create(:user)
project_label_1_1.subscriptions.create(user: user, subscribed: true)
project_label_2_1.subscriptions.create(user: user, subscribed: true)
@@ -98,7 +98,7 @@ describe Labels::PromoteService do
expect(new_label.subscribed?(user2)).to be_truthy
end
- it 'recreates priorities' do
+ it "recreates priorities" do
service.execute(project_label_1_1)
expect(new_label.priority(project_1)).to be_nil
@@ -106,7 +106,7 @@ describe Labels::PromoteService do
expect(new_label.priority(project_3)).to eq(label_3_1_priority)
end
- it 'does not touch project out of promoted group' do
+ it "does not touch project out of promoted group" do
service.execute(project_label_1_1)
project_4_new_label = project_4.labels.find_by(title: promoted_label_name)
@@ -114,13 +114,13 @@ describe Labels::PromoteService do
expect(project_4_new_label.id).to eq(project_label_4_1.id)
end
- it 'does not touch out of group priority' do
+ it "does not touch out of group priority" do
service.execute(project_label_1_1)
expect(new_label.priority(project_4)).to be_nil
end
- it 'relinks issue with the promoted label' do
+ it "relinks issue with the promoted label" do
service.execute(project_label_1_1)
issue_label = issue_1_1.labels.find_by(title: promoted_label_name)
@@ -128,11 +128,11 @@ describe Labels::PromoteService do
expect(issue_label.id).to eq(new_label.id)
end
- it 'does not remove untouched labels from issue' do
+ it "does not remove untouched labels from issue" do
expect { service.execute(project_label_1_1) }.not_to change(issue_1_1.labels, :count)
end
- it 'does not relink untouched label in issue' do
+ it "does not relink untouched label in issue" do
service.execute(project_label_1_1)
issue_label = issue_1_2.labels.find_by(title: untouched_label_name)
@@ -140,7 +140,7 @@ describe Labels::PromoteService do
expect(issue_label.id).to eq(project_label_1_2.id)
end
- it 'relinks issues with merged labels' do
+ it "relinks issues with merged labels" do
service.execute(project_label_1_1)
issue_label = issue_2_1.labels.find_by(title: promoted_label_name)
@@ -148,7 +148,7 @@ describe Labels::PromoteService do
expect(issue_label.id).to eq(new_label.id)
end
- it 'does not relink issues from other group' do
+ it "does not relink issues from other group" do
service.execute(project_label_1_1)
issue_label = issue_4_1.labels.find_by(title: promoted_label_name)
@@ -156,7 +156,7 @@ describe Labels::PromoteService do
expect(issue_label.id).to eq(project_label_4_1.id)
end
- it 'updates merge request' do
+ it "updates merge request" do
service.execute(project_label_1_1)
merge_label = merge_3_1.labels.find_by(title: promoted_label_name)
@@ -164,7 +164,7 @@ describe Labels::PromoteService do
expect(merge_label.id).to eq(new_label.id)
end
- it 'updates board lists' do
+ it "updates board lists" do
service.execute(project_label_1_1)
list = issue_board_2_1.lists.find_by(label: new_label)
@@ -173,7 +173,7 @@ describe Labels::PromoteService do
# In case someone adds a new relation to Label.rb and forgets to relink it
# and the database doesn't have foreign key constraints
- it 'relinks all relations' do
+ it "relinks all relations" do
service.execute(project_label_1_1)
Label.reflect_on_all_associations.each do |association|
@@ -181,7 +181,7 @@ describe Labels::PromoteService do
end
end
- context 'with invalid group label' do
+ context "with invalid group label" do
before do
allow(service).to receive(:clone_label_to_group_label).and_wrap_original do |m, *args|
label = m.call(*args)
@@ -191,7 +191,7 @@ describe Labels::PromoteService do
end
end
- it 'raises an exception' do
+ it "raises an exception" do
expect { service.execute(project_label_1_1) }.to raise_error(ActiveRecord::RecordInvalid)
end
end
diff --git a/spec/services/labels/transfer_service_spec.rb b/spec/services/labels/transfer_service_spec.rb
index 80bac590a11..12b9524ffa0 100644
--- a/spec/services/labels/transfer_service_spec.rb
+++ b/spec/services/labels/transfer_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Labels::TransferService do
- describe '#execute' do
+ describe "#execute" do
let(:user) { create(:admin) }
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
@@ -10,12 +10,12 @@ describe Labels::TransferService do
let(:project_2) { create(:project, namespace: group_3) }
let(:project_3) { create(:project, namespace: group_1) }
- let(:group_label_1) { create(:group_label, group: group_1, name: 'Group Label 1') }
- let(:group_label_2) { create(:group_label, group: group_1, name: 'Group Label 2') }
- let(:group_label_3) { create(:group_label, group: group_1, name: 'Group Label 3') }
- let(:group_label_4) { create(:group_label, group: group_2, name: 'Group Label 4') }
- let(:group_label_5) { create(:group_label, group: group_3, name: 'Group Label 5') }
- let(:project_label_1) { create(:label, project: project_1, name: 'Project Label 1') }
+ let(:group_label_1) { create(:group_label, group: group_1, name: "Group Label 1") }
+ let(:group_label_2) { create(:group_label, group: group_1, name: "Group Label 2") }
+ let(:group_label_3) { create(:group_label, group: group_1, name: "Group Label 3") }
+ let(:group_label_4) { create(:group_label, group: group_2, name: "Group Label 4") }
+ let(:group_label_5) { create(:group_label, group: group_3, name: "Group Label 5") }
+ let(:project_label_1) { create(:label, project: project_1, name: "Project Label 1") }
subject(:service) { described_class.new(user, group_1, project_1) }
@@ -29,11 +29,11 @@ describe Labels::TransferService do
create(:labeled_merge_request, source_project: project_2, labels: [group_label_5])
end
- it 'recreates the missing group labels at project level' do
+ it "recreates the missing group labels at project level" do
expect { service.execute }.to change(project_1.labels, :count).by(2)
end
- it 'recreates label priorities related to the missing group labels' do
+ it "recreates label priorities related to the missing group labels" do
create(:label_priority, project: project_1, label: group_label_1, priority: 1)
service.execute
@@ -43,19 +43,19 @@ describe Labels::TransferService do
expect(new_project_label.priorities).not_to be_empty
end
- it 'does not recreate missing group labels that are not applied to issues or merge requests' do
+ it "does not recreate missing group labels that are not applied to issues or merge requests" do
service.execute
expect(project_1.labels.where(title: group_label_3.title)).to be_empty
end
- it 'does not recreate missing group labels that already exist in the project group' do
+ it "does not recreate missing group labels that already exist in the project group" do
service.execute
expect(project_1.labels.where(title: group_label_4.title)).to be_empty
end
- it 'updates only label links in the given project' do
+ it "updates only label links in the given project" do
service.execute
targets = LabelLink.where(label_id: group_label_1.id).map(&:target)
diff --git a/spec/services/labels/update_service_spec.rb b/spec/services/labels/update_service_spec.rb
index c3fe33045fa..2ffd116a7f2 100644
--- a/spec/services/labels/update_service_spec.rb
+++ b/spec/services/labels/update_service_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Labels::UpdateService do
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project) }
- let(:hex_color) { '#FF0000' }
- let(:named_color) { 'red' }
- let(:upcase_color) { 'RED' }
- let(:spaced_color) { ' red ' }
- let(:unknown_color) { 'unknown' }
- let(:no_color) { '' }
+ let(:hex_color) { "#FF0000" }
+ let(:named_color) { "red" }
+ let(:upcase_color) { "RED" }
+ let(:spaced_color) { " red " }
+ let(:unknown_color) { "unknown" }
+ let(:no_color) { "" }
let(:expected_saved_color) { hex_color }
before do
- @label = Labels::CreateService.new(title: 'Initial', color: '#000000').execute(project: project)
+ @label = Labels::CreateService.new(title: "Initial", color: "#000000").execute(project: project)
expect(@label).to be_persisted
end
- context 'with color in hex-code' do
- it 'updates the label' do
+ context "with color in hex-code" do
+ it "updates the label" do
label = described_class.new(params_with(hex_color)).execute(@label)
expect(label).to be_valid
@@ -27,8 +27,8 @@ describe Labels::UpdateService do
end
end
- context 'with color in allowed name' do
- it 'updates the label' do
+ context "with color in allowed name" do
+ it "updates the label" do
label = described_class.new(params_with(named_color)).execute(@label)
expect(label).to be_valid
@@ -36,8 +36,8 @@ describe Labels::UpdateService do
end
end
- context 'with color in up-case allowed name' do
- it 'updates the label' do
+ context "with color in up-case allowed name" do
+ it "updates the label" do
label = described_class.new(params_with(upcase_color)).execute(@label)
expect(label).to be_valid
@@ -45,8 +45,8 @@ describe Labels::UpdateService do
end
end
- context 'with color surrounded by spaces' do
- it 'updates the label' do
+ context "with color surrounded by spaces" do
+ it "updates the label" do
label = described_class.new(params_with(spaced_color)).execute(@label)
expect(label).to be_valid
@@ -54,16 +54,16 @@ describe Labels::UpdateService do
end
end
- context 'with unknown color' do
- it 'doesn\'t update the label' do
+ context "with unknown color" do
+ it "doesn't update the label" do
label = described_class.new(params_with(unknown_color)).execute(@label)
expect(label).not_to be_valid
end
end
- context 'with no color' do
- it 'doesn\'t update the label' do
+ context "with no color" do
+ it "doesn't update the label" do
label = described_class.new(params_with(no_color)).execute(@label)
expect(label).not_to be_valid
@@ -73,8 +73,8 @@ describe Labels::UpdateService do
def params_with(color)
{
- title: 'A Label',
- color: color
+ title: "A Label",
+ color: color,
}
end
end
diff --git a/spec/services/lfs/file_transformer_spec.rb b/spec/services/lfs/file_transformer_spec.rb
index e8938338cb7..e9663adfe19 100644
--- a/spec/services/lfs/file_transformer_spec.rb
+++ b/spec/services/lfs/file_transformer_spec.rb
@@ -3,42 +3,42 @@ require "spec_helper"
describe Lfs::FileTransformer do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- let(:file_content) { 'Test file content' }
- let(:branch_name) { 'lfs' }
- let(:file_path) { 'test_file.lfs' }
+ let(:file_content) { "Test file content" }
+ let(:branch_name) { "lfs" }
+ let(:file_path) { "test_file.lfs" }
subject { described_class.new(project, branch_name) }
- describe '#new_file' do
- context 'with lfs disabled' do
- it 'skips gitattributes check' do
+ describe "#new_file" do
+ context "with lfs disabled" do
+ it "skips gitattributes check" do
expect(repository.raw).not_to receive(:blob_at)
subject.new_file(file_path, file_content)
end
- it 'returns untransformed content' do
+ it "returns untransformed content" do
result = subject.new_file(file_path, file_content)
expect(result.content).to eq(file_content)
end
- it 'returns untransformed encoding' do
- result = subject.new_file(file_path, file_content, encoding: 'base64')
+ it "returns untransformed encoding" do
+ result = subject.new_file(file_path, file_content, encoding: "base64")
- expect(result.encoding).to eq('base64')
+ expect(result.encoding).to eq("base64")
end
end
- context 'with lfs enabled' do
+ context "with lfs enabled" do
before do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- it 'reuses cached gitattributes' do
- second_file = 'another_file.lfs'
+ it "reuses cached gitattributes" do
+ second_file = "another_file.lfs"
- expect(repository.raw).to receive(:blob_at).with(branch_name, '.gitattributes').once
+ expect(repository.raw).to receive(:blob_at).with(branch_name, ".gitattributes").once
subject.new_file(file_path, file_content)
subject.new_file(second_file, file_content)
@@ -50,20 +50,20 @@ describe Lfs::FileTransformer do
expect(LfsObject.last.file.read).to eq file_content
end
- it 'returns an LFS pointer' do
+ it "returns an LFS pointer" do
result = subject.new_file(file_path, file_content)
expect(result.content).to start_with(Gitlab::Git::LfsPointerFile::VERSION_LINE)
end
- it 'returns LFS pointer encoding as text' do
- result = subject.new_file(file_path, file_content, encoding: 'base64')
+ it "returns LFS pointer encoding as text" do
+ result = subject.new_file(file_path, file_content, encoding: "base64")
- expect(result.encoding).to eq('text')
+ expect(result.encoding).to eq("text")
end
context "when doesn't use LFS" do
- let(:file_path) { 'other.filetype' }
+ let(:file_path) { "other.filetype" }
it "doesn't create LFS pointers" do
new_content = subject.new_file(file_path, file_content).content
@@ -73,23 +73,23 @@ describe Lfs::FileTransformer do
end
end
- it 'links LfsObjects to project' do
- expect do
+ it "links LfsObjects to project" do
+ expect {
subject.new_file(file_path, file_content)
- end.to change { project.lfs_objects.count }.by(1)
+ }.to change { project.lfs_objects.count }.by(1)
end
- context 'when LfsObject already exists' do
+ context "when LfsObject already exists" do
let(:lfs_pointer) { Gitlab::Git::LfsPointerFile.new(file_content) }
before do
create(:lfs_object, oid: lfs_pointer.sha256, size: lfs_pointer.size)
end
- it 'links LfsObjects to project' do
- expect do
+ it "links LfsObjects to project" do
+ expect {
subject.new_file(file_path, file_content)
- end.to change { project.lfs_objects.count }.by(1)
+ }.to change { project.lfs_objects.count }.by(1)
end
end
end
diff --git a/spec/services/lfs/lock_file_service_spec.rb b/spec/services/lfs/lock_file_service_spec.rb
index 3e58eea2501..3764e00a601 100644
--- a/spec/services/lfs/lock_file_service_spec.rb
+++ b/spec/services/lfs/lock_file_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Lfs::LockFileService do
let(:project) { create(:project) }
@@ -6,25 +6,25 @@ describe Lfs::LockFileService do
subject { described_class.new(project, current_user, params) }
- describe '#execute' do
- let(:params) { { path: 'README.md' } }
+ describe "#execute" do
+ let(:params) { {path: "README.md"} }
- context 'when not authorized' do
+ context "when not authorized" do
it "doesn't succeed" do
result = subject.execute
expect(result[:status]).to eq(:error)
expect(result[:http_status]).to eq(403)
- expect(result[:message]).to eq('You have no permissions')
+ expect(result[:message]).to eq("You have no permissions")
end
end
- context 'when authorized' do
+ context "when authorized" do
before do
project.add_developer(current_user)
end
- context 'with an existent lock' do
+ context "with an existent lock" do
let!(:lock) { create(:lfs_file_lock, project: project) }
it "doesn't succeed" do
@@ -32,25 +32,25 @@ describe Lfs::LockFileService do
end
it "doesn't create the Lock" do
- expect do
+ expect {
subject.execute
- end.not_to change { LfsFileLock.count }
+ }.not_to change { LfsFileLock.count }
end
end
- context 'without an existent lock' do
+ context "without an existent lock" do
it "succeeds" do
expect(subject.execute[:status]).to eq(:success)
end
it "creates the Lock" do
- expect do
+ expect {
subject.execute
- end.to change { LfsFileLock.count }.by(1)
+ }.to change { LfsFileLock.count }.by(1)
end
end
- context 'when an error is raised' do
+ context "when an error is raised" do
it "doesn't succeed" do
allow_any_instance_of(described_class).to receive(:create_lock!).and_raise(StandardError)
diff --git a/spec/services/lfs/locks_finder_service_spec.rb b/spec/services/lfs/locks_finder_service_spec.rb
index e409b77babf..8799165b56f 100644
--- a/spec/services/lfs/locks_finder_service_spec.rb
+++ b/spec/services/lfs/locks_finder_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Lfs::LocksFinderService do
let(:project) { create(:project) }
@@ -7,8 +7,8 @@ describe Lfs::LocksFinderService do
subject { described_class.new(project, user, params) }
- shared_examples 'no results' do
- it 'returns an empty list' do
+ shared_examples "no results" do
+ it "returns an empty list" do
result = subject.execute
expect(result[:status]).to eq(:success)
@@ -16,17 +16,17 @@ describe Lfs::LocksFinderService do
end
end
- describe '#execute' do
+ describe "#execute" do
let!(:lock_1) { create(:lfs_file_lock, project: project) }
- let!(:lock_2) { create(:lfs_file_lock, project: project, path: 'README') }
+ let!(:lock_2) { create(:lfs_file_lock, project: project, path: "README") }
- context 'find by id' do
- context 'with results' do
+ context "find by id" do
+ context "with results" do
let(:params) do
- { id: lock_1.id }
+ {id: lock_1.id}
end
- it 'returns the record' do
+ it "returns the record" do
result = subject.execute
expect(result[:status]).to eq(:success)
@@ -35,22 +35,22 @@ describe Lfs::LocksFinderService do
end
end
- context 'without results' do
+ context "without results" do
let(:params) do
- { id: 123 }
+ {id: 123}
end
- include_examples 'no results'
+ include_examples "no results"
end
end
- context 'find by path' do
- context 'with results' do
+ context "find by path" do
+ context "with results" do
let(:params) do
- { path: lock_1.path }
+ {path: lock_1.path}
end
- it 'returns the record' do
+ it "returns the record" do
result = subject.execute
expect(result[:status]).to eq(:success)
@@ -59,18 +59,18 @@ describe Lfs::LocksFinderService do
end
end
- context 'without results' do
+ context "without results" do
let(:params) do
- { path: 'not-found' }
+ {path: "not-found"}
end
- include_examples 'no results'
+ include_examples "no results"
end
end
- context 'find all' do
- context 'with results' do
- it 'returns all the records' do
+ context "find all" do
+ context "with results" do
+ it "returns all the records" do
result = subject.execute
expect(result[:status]).to eq(:success)
@@ -78,16 +78,16 @@ describe Lfs::LocksFinderService do
end
end
- context 'without results' do
+ context "without results" do
before do
LfsFileLock.delete_all
end
- include_examples 'no results'
+ include_examples "no results"
end
end
- context 'when an error is raised' do
+ context "when an error is raised" do
it "doesn't succeed" do
allow_any_instance_of(described_class).to receive(:find_locks).and_raise(StandardError)
diff --git a/spec/services/lfs/unlock_file_service_spec.rb b/spec/services/lfs/unlock_file_service_spec.rb
index fe42ca41633..b23fc39a5b9 100644
--- a/spec/services/lfs/unlock_file_service_spec.rb
+++ b/spec/services/lfs/unlock_file_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Lfs::UnlockFileService do
let(:project) { create(:project) }
@@ -9,24 +9,24 @@ describe Lfs::UnlockFileService do
subject { described_class.new(project, current_user, params) }
- describe '#execute' do
- context 'when not authorized' do
+ describe "#execute" do
+ context "when not authorized" do
it "doesn't succeed" do
result = subject.execute
expect(result[:status]).to eq(:error)
expect(result[:http_status]).to eq(403)
- expect(result[:message]).to eq('You have no permissions')
+ expect(result[:message]).to eq("You have no permissions")
end
end
- context 'when authorized' do
+ context "when authorized" do
before do
project.add_developer(current_user)
end
- context 'when lock does not exists' do
- let(:params) { { id: 123 } }
+ context "when lock does not exists" do
+ let(:params) { {id: 123} }
it "doesn't succeed" do
result = subject.execute
@@ -35,9 +35,9 @@ describe Lfs::UnlockFileService do
end
end
- context 'when unlocked by the author' do
+ context "when unlocked by the author" do
let(:current_user) { lock_author }
- let(:params) { { id: lock.id } }
+ let(:params) { {id: lock.id} }
it "succeeds" do
result = subject.execute
@@ -47,9 +47,9 @@ describe Lfs::UnlockFileService do
end
end
- context 'when unlocked by a different user' do
+ context "when unlocked by a different user" do
let(:current_user) { create(:user) }
- let(:params) { { id: lock.id } }
+ let(:params) { {id: lock.id} }
it "doesn't succeed" do
result = subject.execute
@@ -60,7 +60,7 @@ describe Lfs::UnlockFileService do
end
end
- context 'when forced' do
+ context "when forced" do
let(:developer) { create(:user) }
let(:maintainer) { create(:user) }
@@ -69,11 +69,11 @@ describe Lfs::UnlockFileService do
project.add_maintainer(maintainer)
end
- context 'by a regular user' do
+ context "by a regular user" do
let(:current_user) { developer }
let(:params) do
- { id: lock.id,
- force: true }
+ {id: lock.id,
+ force: true,}
end
it "doesn't succeed" do
@@ -85,11 +85,11 @@ describe Lfs::UnlockFileService do
end
end
- context 'by a maintainer user' do
+ context "by a maintainer user" do
let(:current_user) { maintainer }
let(:params) do
- { id: lock.id,
- force: true }
+ {id: lock.id,
+ force: true,}
end
it "succeeds" do
diff --git a/spec/services/members/approve_access_request_service_spec.rb b/spec/services/members/approve_access_request_service_spec.rb
index 5c30f5b6a61..8a3623f3b0f 100644
--- a/spec/services/members/approve_access_request_service_spec.rb
+++ b/spec/services/members/approve_access_request_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Members::ApproveAccessRequestService do
let(:project) { create(:project, :public, :access_requestable) }
@@ -8,32 +8,32 @@ describe Members::ApproveAccessRequestService do
let(:access_requester) { source.requesters.find_by!(user_id: access_requester_user.id) }
let(:opts) { {} }
- shared_examples 'a service raising ActiveRecord::RecordNotFound' do
- it 'raises ActiveRecord::RecordNotFound' do
+ shared_examples "a service raising ActiveRecord::RecordNotFound" do
+ it "raises ActiveRecord::RecordNotFound" do
expect { described_class.new(current_user).execute(access_requester, opts) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a service raising Gitlab::Access::AccessDeniedError" do
+ it "raises Gitlab::Access::AccessDeniedError" do
expect { described_class.new(current_user).execute(access_requester, opts) }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- shared_examples 'a service approving an access request' do
- it 'succeeds' do
+ shared_examples "a service approving an access request" do
+ it "succeeds" do
expect { described_class.new(current_user).execute(access_requester, opts) }.to change { source.requesters.count }.by(-1)
end
- it 'returns a <Source>Member' do
+ it "returns a <Source>Member" do
member = described_class.new(current_user).execute(access_requester, opts)
expect(member).to be_a "#{source.class}Member".constantize
expect(member.requested_at).to be_nil
end
- context 'with a custom access level' do
- it 'returns a ProjectMember with the custom access level' do
+ context "with a custom access level" do
+ it "returns a ProjectMember with the custom access level" do
member = described_class.new(current_user, access_level: Gitlab::Access::MAINTAINER).execute(access_requester, opts)
expect(member.access_level).to eq(Gitlab::Access::MAINTAINER)
@@ -41,71 +41,71 @@ describe Members::ApproveAccessRequestService do
end
end
- context 'when an access requester is found' do
+ context "when an access requester is found" do
before do
project.request_access(access_requester_user)
group.request_access(access_requester_user)
end
- context 'when current user is nil' do
+ context "when current user is nil" do
let(:user) { nil }
- context 'and :ldap option is not given' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "and :ldap option is not given" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { project }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { group }
end
end
- context 'and :skip_authorization option is false' do
- let(:opts) { { skip_authorization: false } }
+ context "and :skip_authorization option is false" do
+ let(:opts) { {skip_authorization: false} }
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { project }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { group }
end
end
- context 'and :skip_authorization option is true' do
- let(:opts) { { skip_authorization: true } }
+ context "and :skip_authorization option is true" do
+ let(:opts) { {skip_authorization: true} }
- it_behaves_like 'a service approving an access request' do
+ it_behaves_like "a service approving an access request" do
let(:source) { project }
end
- it_behaves_like 'a service approving an access request' do
+ it_behaves_like "a service approving an access request" do
let(:source) { group }
end
end
end
- context 'when current user cannot approve access request to the project' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "when current user cannot approve access request to the project" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { project }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { group }
end
end
- context 'when current user can approve access request to the project' do
+ context "when current user can approve access request to the project" do
before do
project.add_maintainer(current_user)
group.add_owner(current_user)
end
- it_behaves_like 'a service approving an access request' do
+ it_behaves_like "a service approving an access request" do
let(:source) { project }
end
- it_behaves_like 'a service approving an access request' do
+ it_behaves_like "a service approving an access request" do
let(:source) { group }
end
end
diff --git a/spec/services/members/create_service_spec.rb b/spec/services/members/create_service_spec.rb
index 3bc05182932..e861e7b3798 100644
--- a/spec/services/members/create_service_spec.rb
+++ b/spec/services/members/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Members::CreateService do
let(:project) { create(:project) }
@@ -9,16 +9,16 @@ describe Members::CreateService do
project.add_maintainer(user)
end
- it 'adds user to members' do
- params = { user_ids: project_user.id.to_s, access_level: Gitlab::Access::GUEST }
+ it "adds user to members" do
+ params = {user_ids: project_user.id.to_s, access_level: Gitlab::Access::GUEST}
result = described_class.new(user, params).execute(project)
expect(result[:status]).to eq(:success)
expect(project.users).to include project_user
end
- it 'adds no user to members' do
- params = { user_ids: '', access_level: Gitlab::Access::GUEST }
+ it "adds no user to members" do
+ params = {user_ids: "", access_level: Gitlab::Access::GUEST}
result = described_class.new(user, params).execute(project)
expect(result[:status]).to eq(:error)
@@ -26,9 +26,9 @@ describe Members::CreateService do
expect(project.users).not_to include project_user
end
- it 'limits the number of users to 100' do
- user_ids = 1.upto(101).to_a.join(',')
- params = { user_ids: user_ids, access_level: Gitlab::Access::GUEST }
+ it "limits the number of users to 100" do
+ user_ids = 1.upto(101).to_a.join(",")
+ params = {user_ids: user_ids, access_level: Gitlab::Access::GUEST}
result = described_class.new(user, params).execute(project)
@@ -37,8 +37,8 @@ describe Members::CreateService do
expect(project.users).not_to include project_user
end
- it 'does not add an invalid member' do
- params = { user_ids: project_user.id.to_s, access_level: -1 }
+ it "does not add an invalid member" do
+ params = {user_ids: project_user.id.to_s, access_level: -1}
result = described_class.new(user, params).execute(project)
expect(result[:status]).to eq(:error)
diff --git a/spec/services/members/destroy_service_spec.rb b/spec/services/members/destroy_service_spec.rb
index d37ca13ebd2..653d46e920e 100644
--- a/spec/services/members/destroy_service_spec.rb
+++ b/spec/services/members/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Members::DestroyService do
let(:current_user) { create(:user) }
@@ -7,29 +7,29 @@ describe Members::DestroyService do
let(:group_project) { create(:project, :public, group: group) }
let(:opts) { {} }
- shared_examples 'a service raising ActiveRecord::RecordNotFound' do
- it 'raises ActiveRecord::RecordNotFound' do
+ shared_examples "a service raising ActiveRecord::RecordNotFound" do
+ it "raises ActiveRecord::RecordNotFound" do
expect { described_class.new(current_user).execute(member) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a service raising Gitlab::Access::AccessDeniedError" do
+ it "raises Gitlab::Access::AccessDeniedError" do
expect { described_class.new(current_user).execute(member) }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- shared_examples 'a service destroying a member' do
+ shared_examples "a service destroying a member" do
before do
- type = member.is_a?(GroupMember) ? 'Group' : 'Project'
+ type = member.is_a?(GroupMember) ? "Group" : "Project"
expect(TodosDestroyer::EntityLeaveWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, member.user_id, member.source_id, type)
end
- it 'destroys the member' do
+ it "destroys the member" do
expect { described_class.new(current_user).execute(member, opts) }.to change { member.source.members_and_requesters.count }.by(-1)
end
- it 'destroys member notification_settings' do
+ it "destroys member notification_settings" do
if member_user.notification_settings.any?
expect { described_class.new(current_user).execute(member, opts) }
.to change { member_user.notification_settings.count }.by(-1)
@@ -40,10 +40,10 @@ describe Members::DestroyService do
end
end
- shared_examples 'a service destroying a member with access' do
- it_behaves_like 'a service destroying a member'
+ shared_examples "a service destroying a member with access" do
+ it_behaves_like "a service destroying a member"
- it 'invalidates cached counts for todos and assigned issues and merge requests', :aggregate_failures do
+ it "invalidates cached counts for todos and assigned issues and merge requests", :aggregate_failures do
create(:issue, project: group_project, assignees: [member_user])
create(:merge_request, source_project: group_project, assignee: member_user)
create(:todo, :pending, project: group_project, user: member_user)
@@ -63,17 +63,17 @@ describe Members::DestroyService do
end
end
- shared_examples 'a service destroying an access requester' do
- it_behaves_like 'a service destroying a member'
+ shared_examples "a service destroying an access requester" do
+ it_behaves_like "a service destroying a member"
- it 'calls Member#after_decline_request' do
+ it "calls Member#after_decline_request" do
expect_any_instance_of(NotificationService).to receive(:decline_access_request).with(member)
described_class.new(current_user).execute(member, opts)
end
- context 'when current user is the member' do
- it 'does not call Member#after_decline_request' do
+ context "when current user is the member" do
+ it "does not call Member#after_decline_request" do
expect_any_instance_of(NotificationService).not_to receive(:decline_access_request).with(member)
described_class.new(member_user).execute(member, opts)
@@ -81,71 +81,71 @@ describe Members::DestroyService do
end
end
- context 'with a member with access' do
+ context "with a member with access" do
before do
group_project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
group.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end
- context 'when current user cannot destroy the given member' do
- context 'with a project member' do
+ context "when current user cannot destroy the given member" do
+ context "with a project member" do
let(:member) { group_project.members.find_by(user_id: member_user.id) }
before do
group_project.add_developer(member_user)
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError'
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError"
- it_behaves_like 'a service destroying a member with access' do
- let(:opts) { { skip_authorization: true } }
+ it_behaves_like "a service destroying a member with access" do
+ let(:opts) { {skip_authorization: true} }
end
end
- context 'with a group member' do
+ context "with a group member" do
let(:member) { group.members.find_by(user_id: member_user.id) }
before do
group.add_developer(member_user)
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError'
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError"
- it_behaves_like 'a service destroying a member with access' do
- let(:opts) { { skip_authorization: true } }
+ it_behaves_like "a service destroying a member with access" do
+ let(:opts) { {skip_authorization: true} }
end
end
end
- context 'when current user can destroy the given member' do
+ context "when current user can destroy the given member" do
before do
group_project.add_maintainer(current_user)
group.add_owner(current_user)
end
- context 'with a project member' do
+ context "with a project member" do
let(:member) { group_project.members.find_by(user_id: member_user.id) }
before do
group_project.add_developer(member_user)
end
- it_behaves_like 'a service destroying a member with access'
+ it_behaves_like "a service destroying a member with access"
end
- context 'with a group member' do
+ context "with a group member" do
let(:member) { group.members.find_by(user_id: member_user.id) }
before do
group.add_developer(member_user)
end
- it_behaves_like 'a service destroying a member with access'
+ it_behaves_like "a service destroying a member with access"
end
end
end
- context 'with an access requester' do
+ context "with an access requester" do
before do
group_project.update(request_access_enabled: true)
group.update(request_access_enabled: true)
@@ -153,86 +153,86 @@ describe Members::DestroyService do
group.request_access(member_user)
end
- context 'when current user cannot destroy the given access requester' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "when current user cannot destroy the given access requester" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:member) { group_project.requesters.find_by(user_id: member_user.id) }
end
- it_behaves_like 'a service destroying a member' do
- let(:opts) { { skip_authorization: true, skip_subresources: true } }
+ it_behaves_like "a service destroying a member" do
+ let(:opts) { {skip_authorization: true, skip_subresources: true} }
let(:member) { group_project.requesters.find_by(user_id: member_user.id) }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:member) { group.requesters.find_by(user_id: member_user.id) }
end
- it_behaves_like 'a service destroying a member' do
- let(:opts) { { skip_authorization: true, skip_subresources: true } }
+ it_behaves_like "a service destroying a member" do
+ let(:opts) { {skip_authorization: true, skip_subresources: true} }
let(:member) { group.requesters.find_by(user_id: member_user.id) }
end
end
- context 'when current user can destroy the given access requester' do
- let(:opts) { { skip_subresources: true } }
+ context "when current user can destroy the given access requester" do
+ let(:opts) { {skip_subresources: true} }
before do
group_project.add_maintainer(current_user)
group.add_owner(current_user)
end
- it_behaves_like 'a service destroying an access requester' do
+ it_behaves_like "a service destroying an access requester" do
let(:member) { group_project.requesters.find_by(user_id: member_user.id) }
end
- it_behaves_like 'a service destroying an access requester' do
+ it_behaves_like "a service destroying an access requester" do
let(:member) { group.requesters.find_by(user_id: member_user.id) }
end
end
end
- context 'with an invited user' do
+ context "with an invited user" do
let(:project_invited_member) { create(:project_member, :invited, project: group_project) }
let(:group_invited_member) { create(:group_member, :invited, group: group) }
- context 'when current user cannot destroy the given invited user' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "when current user cannot destroy the given invited user" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:member) { project_invited_member }
end
- it_behaves_like 'a service destroying a member' do
- let(:opts) { { skip_authorization: true } }
+ it_behaves_like "a service destroying a member" do
+ let(:opts) { {skip_authorization: true} }
let(:member) { project_invited_member }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:member) { group_invited_member }
end
- it_behaves_like 'a service destroying a member' do
- let(:opts) { { skip_authorization: true } }
+ it_behaves_like "a service destroying a member" do
+ let(:opts) { {skip_authorization: true} }
let(:member) { group_invited_member }
end
end
- context 'when current user can destroy the given invited user' do
+ context "when current user can destroy the given invited user" do
before do
group_project.add_maintainer(current_user)
group.add_owner(current_user)
end
# Regression spec for issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/32504
- it_behaves_like 'a service destroying a member' do
+ it_behaves_like "a service destroying a member" do
let(:member) { project_invited_member }
end
- it_behaves_like 'a service destroying a member' do
+ it_behaves_like "a service destroying a member" do
let(:member) { group_invited_member }
end
end
end
- context 'subresources' do
+ context "subresources" do
let(:user) { create(:user) }
let(:member_user) { create(:user) }
let(:opts) { {} }
@@ -257,27 +257,27 @@ describe Members::DestroyService do
described_class.new(user).execute(group_member, opts)
end
- it 'removes the project membership' do
+ it "removes the project membership" do
expect(group_project.members.map(&:user)).not_to include(member_user)
end
- it 'removes the group membership' do
+ it "removes the group membership" do
expect(group.members.map(&:user)).not_to include(member_user)
end
- it 'removes the subgroup membership', :postgresql do
+ it "removes the subgroup membership", :postgresql do
expect(subgroup.members.map(&:user)).not_to include(member_user)
end
- it 'removes the subsubgroup membership', :postgresql do
+ it "removes the subsubgroup membership", :postgresql do
expect(subsubgroup.members.map(&:user)).not_to include(member_user)
end
- it 'removes the subsubproject membership', :postgresql do
+ it "removes the subsubproject membership", :postgresql do
expect(subsubproject.members.map(&:user)).not_to include(member_user)
end
- it 'does not remove the user from the control project' do
+ it "does not remove the user from the control project" do
expect(control_project.members.map(&:user)).to include(user)
end
end
diff --git a/spec/services/members/request_access_service_spec.rb b/spec/services/members/request_access_service_spec.rb
index e93ba5a85c0..8a735b54afe 100644
--- a/spec/services/members/request_access_service_spec.rb
+++ b/spec/services/members/request_access_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Members::RequestAccessService do
let(:user) { create(:user) }
- shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a service raising Gitlab::Access::AccessDeniedError" do
+ it "raises Gitlab::Access::AccessDeniedError" do
expect { described_class.new(user).execute(source) }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- shared_examples 'a service creating a access request' do
- it 'succeeds' do
+ shared_examples "a service creating a access request" do
+ it "succeeds" do
expect { described_class.new(user).execute(source) }.to change { source.requesters.count }.by(1)
end
- it 'returns a <Source>Member' do
+ it "returns a <Source>Member" do
member = described_class.new(user).execute(source)
expect(member).to be_a "#{source.class}Member".constantize
@@ -22,31 +22,31 @@ describe Members::RequestAccessService do
end
end
- context 'when source is nil' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "when source is nil" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { nil }
end
end
- context 'when current user cannot request access to the project' do
+ context "when current user cannot request access to the project" do
%i[project group].each do |source_type|
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { create(source_type, :private) }
end
end
end
- context 'when access requests are disabled' do
+ context "when access requests are disabled" do
%i[project group].each do |source_type|
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { create(source_type, :public) }
end
end
end
- context 'when current user can request access to the project' do
+ context "when current user can request access to the project" do
%i[project group].each do |source_type|
- it_behaves_like 'a service creating a access request' do
+ it_behaves_like "a service creating a access request" do
let(:source) { create(source_type, :public, :access_requestable) }
end
end
diff --git a/spec/services/members/update_service_spec.rb b/spec/services/members/update_service_spec.rb
index 599ed39ca37..2bfde1f3c97 100644
--- a/spec/services/members/update_service_spec.rb
+++ b/spec/services/members/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Members::UpdateService do
let(:project) { create(:project, :public) }
@@ -8,18 +8,18 @@ describe Members::UpdateService do
let(:permission) { :update }
let(:member) { source.members_and_requesters.find_by!(user_id: member_user.id) }
let(:params) do
- { access_level: Gitlab::Access::MAINTAINER }
+ {access_level: Gitlab::Access::MAINTAINER}
end
- shared_examples 'a service raising Gitlab::Access::AccessDeniedError' do
- it 'raises Gitlab::Access::AccessDeniedError' do
+ shared_examples "a service raising Gitlab::Access::AccessDeniedError" do
+ it "raises Gitlab::Access::AccessDeniedError" do
expect { described_class.new(current_user, params).execute(member, permission: permission) }
.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- shared_examples 'a service updating a member' do
- it 'updates the member' do
+ shared_examples "a service updating a member" do
+ it "updates the member" do
expect(TodosDestroyer::EntityLeaveWorker).not_to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, member.user_id, member.source_id, source.class.name)
updated_member = described_class.new(current_user, params).execute(member, permission: permission)
@@ -28,12 +28,12 @@ describe Members::UpdateService do
expect(updated_member.access_level).to eq(Gitlab::Access::MAINTAINER)
end
- context 'when member is downgraded to guest' do
+ context "when member is downgraded to guest" do
let(:params) do
- { access_level: Gitlab::Access::GUEST }
+ {access_level: Gitlab::Access::GUEST}
end
- it 'schedules to delete confidential todos' do
+ it "schedules to delete confidential todos" do
expect(TodosDestroyer::EntityLeaveWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, member.user_id, member.source_id, source.class.name).once
updated_member = described_class.new(current_user, params).execute(member, permission: permission)
@@ -49,27 +49,27 @@ describe Members::UpdateService do
group.add_developer(member_user)
end
- context 'when current user cannot update the given member' do
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ context "when current user cannot update the given member" do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { project }
end
- it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
+ it_behaves_like "a service raising Gitlab::Access::AccessDeniedError" do
let(:source) { group }
end
end
- context 'when current user can update the given member' do
+ context "when current user can update the given member" do
before do
project.add_maintainer(current_user)
group.add_owner(current_user)
end
- it_behaves_like 'a service updating a member' do
+ it_behaves_like "a service updating a member" do
let(:source) { project }
end
- it_behaves_like 'a service updating a member' do
+ it_behaves_like "a service updating a member" do
let(:source) { group }
end
end
diff --git a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
index af0a214c00f..7031f1ecb63 100644
--- a/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
+++ b/spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::AddTodoWhenBuildFailsService do
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:project) { create(:project, :repository) }
- let(:sha) { '1234567890abcdef1234567890abcdef12345678' }
+ let(:sha) { "1234567890abcdef1234567890abcdef12345678" }
let(:ref) { merge_request.source_branch }
let(:pipeline) do
@@ -14,18 +14,18 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
end
let(:service) do
- described_class.new(project, user, commit_message: 'Awesome message')
+ described_class.new(project, user, commit_message: "Awesome message")
end
- let(:todo_service) { spy('todo service') }
+ let(:todo_service) { spy("todo service") }
let(:merge_request) do
create(:merge_request, merge_user: user,
- source_branch: 'master',
- target_branch: 'feature',
+ source_branch: "master",
+ target_branch: "feature",
source_project: project,
target_project: project,
- state: 'opened')
+ state: "opened")
end
before do
@@ -36,42 +36,42 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
allow(service).to receive(:todo_service).and_return(todo_service)
end
- describe '#execute' do
- context 'commit status with ref' do
+ describe "#execute" do
+ context "commit status with ref" do
let(:commit_status) do
create(:generic_commit_status, ref: ref, pipeline: pipeline)
end
- it 'notifies the todo service' do
+ it "notifies the todo service" do
expect(todo_service).to receive(:merge_request_build_failed).with(merge_request)
service.execute(commit_status)
end
end
- context 'commit status with non-HEAD ref' do
+ context "commit status with non-HEAD ref" do
let(:commit_status) { create(:generic_commit_status, ref: ref) }
- it 'does not notify the todo service' do
+ it "does not notify the todo service" do
expect(todo_service).not_to receive(:merge_request_build_failed)
service.execute(commit_status)
end
end
- context 'commit status without ref' do
+ context "commit status without ref" do
let(:commit_status) { create(:generic_commit_status) }
- it 'does not notify the todo service' do
+ it "does not notify the todo service" do
expect(todo_service).not_to receive(:merge_request_build_failed)
service.execute(commit_status)
end
end
- context 'when commit status is a build allowed to fail' do
+ context "when commit status is a build allowed to fail" do
let(:commit_status) do
create(:ci_build, :allowed_to_fail, ref: ref, pipeline: pipeline)
end
- it 'does not create todo' do
+ it "does not create todo" do
expect(todo_service).not_to receive(:merge_request_build_failed)
service.execute(commit_status)
@@ -79,38 +79,38 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
end
end
- describe '#close' do
- context 'commit status with ref' do
+ describe "#close" do
+ context "commit status with ref" do
let(:commit_status) { create(:generic_commit_status, ref: merge_request.source_branch, pipeline: pipeline) }
- it 'notifies the todo service' do
+ it "notifies the todo service" do
expect(todo_service).to receive(:merge_request_build_retried).with(merge_request)
service.close(commit_status)
end
end
- context 'commit status with non-HEAD ref' do
+ context "commit status with non-HEAD ref" do
let(:commit_status) { create(:generic_commit_status, ref: merge_request.source_branch) }
- it 'does not notify the todo service' do
+ it "does not notify the todo service" do
expect(todo_service).not_to receive(:merge_request_build_retried)
service.close(commit_status)
end
end
- context 'commit status without ref' do
+ context "commit status without ref" do
let(:commit_status) { create(:generic_commit_status) }
- it 'does not notify the todo service' do
+ it "does not notify the todo service" do
expect(todo_service).not_to receive(:merge_request_build_retried)
service.close(commit_status)
end
end
end
- describe '#close_all' do
- context 'when using pipeline that belongs to merge request' do
- it 'resolves todos about failed builds for pipeline' do
+ describe "#close_all" do
+ context "when using pipeline that belongs to merge request" do
+ it "resolves todos about failed builds for pipeline" do
service.close_all(pipeline)
expect(todo_service)
@@ -119,10 +119,10 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
end
end
- context 'when pipeline is not related to merge request' do
+ context "when pipeline is not related to merge request" do
let(:pipeline) { create(:ci_empty_pipeline) }
- it 'does not resolve any todos about failed builds' do
+ it "does not resolve any todos about failed builds" do
service.close_all(pipeline)
expect(todo_service)
diff --git a/spec/services/merge_requests/assign_issues_service_spec.rb b/spec/services/merge_requests/assign_issues_service_spec.rb
index bda6383a346..6940cae9920 100644
--- a/spec/services/merge_requests/assign_issues_service_spec.rb
+++ b/spec/services/merge_requests/assign_issues_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::AssignIssuesService do
let(:user) { create(:user) }
@@ -11,44 +11,44 @@ describe MergeRequests::AssignIssuesService do
project.add_developer(user)
end
- it 'finds unassigned issues fixed in merge request' do
+ it "finds unassigned issues fixed in merge request" do
expect(service.assignable_issues.map(&:id)).to include(issue.id)
end
- it 'ignores issues the user cannot update assignee on' do
+ it "ignores issues the user cannot update assignee on" do
project.team.truncate
expect(service.assignable_issues).to be_empty
end
- it 'ignores issues already assigned to any user' do
+ it "ignores issues already assigned to any user" do
issue.assignees = [create(:user)]
expect(service.assignable_issues).to be_empty
end
- it 'ignores all issues unless current_user is merge_request.author' do
+ it "ignores all issues unless current_user is merge_request.author" do
merge_request.update!(author: create(:user))
expect(service.assignable_issues).to be_empty
end
- it 'accepts precomputed data for closes_issues' do
+ it "accepts precomputed data for closes_issues" do
issue2 = create(:issue, project: project)
service2 = described_class.new(project,
- user,
- merge_request: merge_request,
- closes_issues: [issue, issue2])
+ user,
+ merge_request: merge_request,
+ closes_issues: [issue, issue2])
expect(service2.assignable_issues.count).to eq 2
end
- it 'assigns these to the merge request owner' do
+ it "assigns these to the merge request owner" do
expect { service.execute }.to change { issue.assignees.first }.to(user)
end
- it 'ignores external issues' do
- external_issue = ExternalIssue.new('JIRA-123', project)
+ it "ignores external issues" do
+ external_issue = ExternalIssue.new("JIRA-123", project)
service = described_class.new(
project,
user,
diff --git a/spec/services/merge_requests/build_service_spec.rb b/spec/services/merge_requests/build_service_spec.rb
index 536d0d345a4..0112acd2360 100644
--- a/spec/services/merge_requests/build_service_spec.rb
+++ b/spec/services/merge_requests/build_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::BuildService do
using RSpec::Parameterized::TableSyntax
@@ -10,16 +10,16 @@ describe MergeRequests::BuildService do
let(:target_project) { nil }
let(:user) { create(:user) }
let(:issue_confidential) { false }
- let(:issue) { create(:issue, project: project, title: 'A bug', confidential: issue_confidential) }
+ let(:issue) { create(:issue, project: project, title: "A bug", confidential: issue_confidential) }
let(:description) { nil }
- let(:source_branch) { 'feature-branch' }
- let(:target_branch) { 'master' }
+ let(:source_branch) { "feature-branch" }
+ let(:target_branch) { "master" }
let(:milestone_id) { nil }
let(:label_ids) { [] }
let(:merge_request) { service.execute }
let(:compare) { double(:compare, commits: commits) }
- let(:commit_1) { double(:commit_1, sha: 'f00ba7', safe_message: "Initial commit\n\nCreate the app") }
- let(:commit_2) { double(:commit_2, sha: 'f00ba7', safe_message: 'This is a bad commit message!') }
+ let(:commit_1) { double(:commit_1, sha: "f00ba7", safe_message: "Initial commit\n\nCreate the app") }
+ let(:commit_2) { double(:commit_2, sha: "f00ba7", safe_message: "This is a bad commit message!") }
let(:commits) { nil }
let(:params) do
@@ -30,7 +30,7 @@ describe MergeRequests::BuildService do
source_project: source_project,
target_project: target_project,
milestone_id: milestone_id,
- label_ids: label_ids
+ label_ids: label_ids,
}
end
@@ -48,46 +48,46 @@ describe MergeRequests::BuildService do
allow(project).to receive(:commit).and_return(commit_2)
end
- describe '#execute' do
- it 'calls the compare service with the correct arguments' do
+ describe "#execute" do
+ it "calls the compare service with the correct arguments" do
allow_any_instance_of(described_class).to receive(:projects_and_branches_valid?).and_return(true)
expect(CompareService).to receive(:new)
- .with(project, Gitlab::Git::BRANCH_REF_PREFIX + source_branch)
- .and_call_original
+ .with(project, Gitlab::Git::BRANCH_REF_PREFIX + source_branch)
+ .and_call_original
expect_any_instance_of(CompareService).to receive(:execute)
- .with(project, Gitlab::Git::BRANCH_REF_PREFIX + target_branch)
- .and_call_original
+ .with(project, Gitlab::Git::BRANCH_REF_PREFIX + target_branch)
+ .and_call_original
merge_request
end
- it 'does not assign force_remove_source_branch' do
+ it "does not assign force_remove_source_branch" do
expect(merge_request.force_remove_source_branch?).to be_falsey
end
- context 'with force_remove_source_branch parameter' do
- let(:mr_params) { params.merge(force_remove_source_branch: '1') }
+ context "with force_remove_source_branch parameter" do
+ let(:mr_params) { params.merge(force_remove_source_branch: "1") }
let(:merge_request) { described_class.new(project, user, mr_params).execute }
- it 'assigns force_remove_source_branch' do
+ it "assigns force_remove_source_branch" do
expect(merge_request.force_remove_source_branch?).to be_truthy
end
end
- context 'missing source branch' do
- let(:source_branch) { '' }
+ context "missing source branch" do
+ let(:source_branch) { "" }
- it 'forbids the merge request from being created' do
+ it "forbids the merge request from being created" do
expect(merge_request.can_be_created).to eq(false)
end
- it 'adds an error message to the merge request' do
- expect(merge_request.errors).to contain_exactly('You must select source and target branch')
+ it "adds an error message to the merge request" do
+ expect(merge_request.errors).to contain_exactly("You must select source and target branch")
end
end
- context 'when target branch is missing' do
+ context "when target branch is missing" do
let(:target_branch) { nil }
let(:commits) { Commit.decorate([commit_1], project) }
@@ -95,45 +95,45 @@ describe MergeRequests::BuildService do
stub_compare
end
- it 'creates compare object with target branch as default branch' do
+ it "creates compare object with target branch as default branch" do
expect(merge_request.compare).to be_present
expect(merge_request.target_branch).to eq(project.default_branch)
end
- it 'allows the merge request to be created' do
+ it "allows the merge request to be created" do
expect(merge_request.can_be_created).to eq(true)
end
end
- context 'same source and target branch' do
- let(:source_branch) { 'master' }
+ context "same source and target branch" do
+ let(:source_branch) { "master" }
- it 'forbids the merge request from being created' do
+ it "forbids the merge request from being created" do
expect(merge_request.can_be_created).to eq(false)
end
- it 'adds an error message to the merge request' do
- expect(merge_request.errors).to contain_exactly('You must select different branches')
+ it "adds an error message to the merge request" do
+ expect(merge_request.errors).to contain_exactly("You must select different branches")
end
end
- context 'no commits in the diff' do
+ context "no commits in the diff" do
let(:commits) { [] }
before do
stub_compare
end
- it 'allows the merge request to be created' do
+ it "allows the merge request to be created" do
expect(merge_request.can_be_created).to eq(true)
end
- it 'adds a WIP prefix to the merge request title' do
- expect(merge_request.title).to eq('WIP: Feature branch')
+ it "adds a WIP prefix to the merge request title" do
+ expect(merge_request.title).to eq("WIP: Feature branch")
end
end
- context 'one commit in the diff' do
+ context "one commit in the diff" do
let(:commits) { Commit.decorate([commit_1], project) }
let(:commit_description) { commit_1.safe_message.split(/\n+/, 2).last }
@@ -141,46 +141,46 @@ describe MergeRequests::BuildService do
stub_compare
end
- it 'allows the merge request to be created' do
+ it "allows the merge request to be created" do
expect(merge_request.can_be_created).to eq(true)
end
- it 'uses the title of the commit as the title of the merge request' do
+ it "uses the title of the commit as the title of the merge request" do
expect(merge_request.title).to eq(commit_1.safe_message.split("\n").first)
end
- it 'uses the description of the commit as the description of the merge request' do
+ it "uses the description of the commit as the description of the merge request" do
expect(merge_request.description).to eq(commit_description)
end
- context 'merge request already has a description set' do
- let(:description) { 'Merge request description' }
+ context "merge request already has a description set" do
+ let(:description) { "Merge request description" }
- it 'keeps the description from the initial params' do
+ it "keeps the description from the initial params" do
expect(merge_request.description).to eq(description)
end
end
- context 'commit has no description' do
+ context "commit has no description" do
let(:commits) { Commit.decorate([commit_2], project) }
- it 'uses the title of the commit as the title of the merge request' do
+ it "uses the title of the commit as the title of the merge request" do
expect(merge_request.title).to eq(commit_2.safe_message)
end
- it 'sets the description to nil' do
+ it "sets the description to nil" do
expect(merge_request.description).to be_nil
end
end
- context 'when the source branch matches an issue' do
+ context "when the source branch matches an issue" do
where(:issue_tracker, :source_branch, :closing_message) do
- :jira | 'FOO-123-fix-issue' | 'Closes FOO-123'
- :jira | 'fix-issue' | nil
- :custom_issue_tracker | '123-fix-issue' | 'Closes #123'
- :custom_issue_tracker | 'fix-issue' | nil
- :internal | '123-fix-issue' | 'Closes #123'
- :internal | 'fix-issue' | nil
+ :jira | "FOO-123-fix-issue" | "Closes FOO-123"
+ :jira | "fix-issue" | nil
+ :custom_issue_tracker | "123-fix-issue" | "Closes #123"
+ :custom_issue_tracker | "fix-issue" | nil
+ :internal | "123-fix-issue" | "Closes #123"
+ :internal | "fix-issue" | nil
end
with_them do
@@ -192,38 +192,38 @@ describe MergeRequests::BuildService do
end
end
- it 'uses the title of the commit as the title of the merge request' do
- expect(merge_request.title).to eq('Initial commit')
+ it "uses the title of the commit as the title of the merge request" do
+ expect(merge_request.title).to eq("Initial commit")
end
- it 'appends the closing description' do
+ it "appends the closing description" do
expected_description = [commit_description, closing_message].compact.join("\n\n")
expect(merge_request.description).to eq(expected_description)
end
end
- context 'when the source branch matches an internal issue' do
+ context "when the source branch matches an internal issue" do
let(:label) { create(:label, project: project) }
let(:milestone) { create(:milestone, project: project) }
- let(:source_branch) { '123-fix-issue' }
+ let(:source_branch) { "123-fix-issue" }
before do
issue.update!(iid: 123, labels: [label], milestone: milestone)
end
- it 'assigns the issue label and milestone' do
+ it "assigns the issue label and milestone" do
expect(merge_request.milestone).to eq(milestone)
expect(merge_request.labels).to match_array([label])
end
- context 'when milestone_id and label_ids are shared in the params' do
+ context "when milestone_id and label_ids are shared in the params" do
let(:label2) { create(:label, project: project) }
let(:milestone2) { create(:milestone, project: project) }
let(:label_ids) { [label2.id] }
let(:milestone_id) { milestone2.id }
- it 'assigns milestone_id and label_ids instead of issue labels and milestone' do
+ it "assigns milestone_id and label_ids instead of issue labels and milestone" do
expect(merge_request.milestone).to eq(milestone2)
expect(merge_request.labels).to match_array([label2])
end
@@ -232,42 +232,42 @@ describe MergeRequests::BuildService do
end
end
- context 'more than one commit in the diff' do
+ context "more than one commit in the diff" do
let(:commits) { Commit.decorate([commit_1, commit_2], project) }
before do
stub_compare
end
- it 'allows the merge request to be created' do
+ it "allows the merge request to be created" do
expect(merge_request.can_be_created).to eq(true)
end
- it 'uses the title of the branch as the merge request title' do
- expect(merge_request.title).to eq('Feature branch')
+ it "uses the title of the branch as the merge request title" do
+ expect(merge_request.title).to eq("Feature branch")
end
- it 'does not add a description' do
+ it "does not add a description" do
expect(merge_request.description).to be_nil
end
- context 'merge request already has a description set' do
- let(:description) { 'Merge request description' }
+ context "merge request already has a description set" do
+ let(:description) { "Merge request description" }
- it 'keeps the description from the initial params' do
+ it "keeps the description from the initial params" do
expect(merge_request.description).to eq(description)
end
end
- context 'when the source branch matches an issue' do
+ context "when the source branch matches an issue" do
where(:issue_tracker, :source_branch, :title, :closing_message) do
- :jira | 'FOO-123-fix-issue' | 'Resolve FOO-123 "Fix issue"' | 'Closes FOO-123'
- :jira | 'fix-issue' | 'Fix issue' | nil
- :custom_issue_tracker | '123-fix-issue' | 'Resolve #123 "Fix issue"' | 'Closes #123'
- :custom_issue_tracker | 'fix-issue' | 'Fix issue' | nil
- :internal | '123-fix-issue' | 'Resolve "A bug"' | 'Closes #123'
- :internal | 'fix-issue' | 'Fix issue' | nil
- :internal | '124-fix-issue' | '124 fix issue' | nil
+ :jira | "FOO-123-fix-issue" | 'Resolve FOO-123 "Fix issue"' | "Closes FOO-123"
+ :jira | "fix-issue" | "Fix issue" | nil
+ :custom_issue_tracker | "123-fix-issue" | 'Resolve #123 "Fix issue"' | "Closes #123"
+ :custom_issue_tracker | "fix-issue" | "Fix issue" | nil
+ :internal | "123-fix-issue" | 'Resolve "A bug"' | "Closes #123"
+ :internal | "fix-issue" | "Fix issue" | nil
+ :internal | "124-fix-issue" | "124 fix issue" | nil
end
with_them do
@@ -279,86 +279,86 @@ describe MergeRequests::BuildService do
end
end
- it 'sets the correct title' do
+ it "sets the correct title" do
expect(merge_request.title).to eq(title)
end
- it 'sets the closing description' do
+ it "sets the closing description" do
expect(merge_request.description).to eq(closing_message)
end
end
end
- context 'when the issue is not accessible to user' do
+ context "when the issue is not accessible to user" do
let(:source_branch) { "#{issue.iid}-fix-issue" }
before do
project.team.truncate
end
- it 'uses branch title as the merge request title' do
+ it "uses branch title as the merge request title" do
expect(merge_request.title).to eq("#{issue.iid} fix issue")
end
- it 'does not set a description' do
+ it "does not set a description" do
expect(merge_request.description).to be_nil
end
end
- context 'when the issue is confidential' do
+ context "when the issue is confidential" do
let(:source_branch) { "#{issue.iid}-fix-issue" }
let(:issue_confidential) { true }
- it 'uses the title of the branch as the merge request title' do
+ it "uses the title of the branch as the merge request title" do
expect(merge_request.title).to eq("#{issue.iid} fix issue")
end
- it 'does not set a description' do
+ it "does not set a description" do
expect(merge_request.description).to be_nil
end
end
end
- context 'source branch does not exist' do
+ context "source branch does not exist" do
before do
allow(project).to receive(:commit).with(source_branch).and_return(nil)
allow(project).to receive(:commit).with(target_branch).and_return(commit_1)
end
- it 'forbids the merge request from being created' do
+ it "forbids the merge request from being created" do
expect(merge_request.can_be_created).to eq(false)
end
- it 'adds an error message to the merge request' do
+ it "adds an error message to the merge request" do
expect(merge_request.errors).to contain_exactly('Source branch "feature-branch" does not exist')
end
end
- context 'target branch does not exist' do
+ context "target branch does not exist" do
before do
allow(project).to receive(:commit).with(source_branch).and_return(commit_1)
allow(project).to receive(:commit).with(target_branch).and_return(nil)
end
- it 'forbids the merge request from being created' do
+ it "forbids the merge request from being created" do
expect(merge_request.can_be_created).to eq(false)
end
- it 'adds an error message to the merge request' do
+ it "adds an error message to the merge request" do
expect(merge_request.errors).to contain_exactly('Target branch "master" does not exist')
end
end
- context 'both source and target branches do not exist' do
+ context "both source and target branches do not exist" do
before do
allow(project).to receive(:commit).and_return(nil)
end
- it 'forbids the merge request from being created' do
+ it "forbids the merge request from being created" do
expect(merge_request.can_be_created).to eq(false)
end
- it 'adds both error messages to the merge request' do
+ it "adds both error messages to the merge request" do
expect(merge_request.errors).to contain_exactly(
'Source branch "feature-branch" does not exist',
'Target branch "master" does not exist'
@@ -366,45 +366,45 @@ describe MergeRequests::BuildService do
end
end
- context 'upstream project has disabled merge requests' do
+ context "upstream project has disabled merge requests" do
let(:upstream_project) { create(:project, :merge_requests_disabled) }
let(:project) { create(:project, forked_from_project: upstream_project) }
let(:commits) { Commit.decorate([commit_1], project) }
- it 'sets target project correctly' do
+ it "sets target project correctly" do
expect(merge_request.target_project).to eq(project)
end
end
- context 'target_project is set and accessible by current_user' do
+ context "target_project is set and accessible by current_user" do
let(:target_project) { create(:project, :public, :repository)}
let(:commits) { Commit.decorate([commit_1], project) }
- it 'sets target project correctly' do
+ it "sets target project correctly" do
expect(merge_request.target_project).to eq(target_project)
end
end
- context 'target_project is set but not accessible by current_user' do
+ context "target_project is set but not accessible by current_user" do
let(:target_project) { create(:project, :private, :repository)}
let(:commits) { Commit.decorate([commit_1], project) }
- it 'sets target project correctly' do
+ it "sets target project correctly" do
expect(merge_request.target_project).to eq(project)
end
end
- context 'target_project is set but repo is not accessible by current_user' do
+ context "target_project is set but repo is not accessible by current_user" do
let(:target_project) do
create(:project, :public, :repository, repository_access_level: ProjectFeature::PRIVATE)
end
- it 'sets target project correctly' do
+ it "sets target project correctly" do
expect(merge_request.target_project).to eq(project)
end
end
- context 'source_project is set and accessible by current_user' do
+ context "source_project is set and accessible by current_user" do
let(:source_project) { create(:project, :public, :repository)}
let(:commits) { Commit.decorate([commit_1], project) }
@@ -414,39 +414,39 @@ describe MergeRequests::BuildService do
source_project.add_developer(user)
end
- it 'sets source project correctly' do
+ it "sets source project correctly" do
expect(merge_request.source_project).to eq(source_project)
end
end
- context 'source_project is set but not accessible by current_user' do
+ context "source_project is set but not accessible by current_user" do
let(:source_project) { create(:project, :private, :repository)}
let(:commits) { Commit.decorate([commit_1], project) }
- it 'sets source project correctly' do
+ it "sets source project correctly" do
expect(merge_request.source_project).to eq(project)
end
end
- context 'source_project is set but the user cannot create merge requests from the project' do
+ context "source_project is set but the user cannot create merge requests from the project" do
let(:source_project) do
create(:project, :public, :repository, merge_requests_access_level: ProjectFeature::PRIVATE)
end
- it 'sets the source_project correctly' do
+ it "sets the source_project correctly" do
expect(merge_request.source_project).to eq(project)
end
end
- context 'target_project is not in the fork network of source_project' do
+ context "target_project is not in the fork network of source_project" do
let(:target_project) { create(:project, :public, :repository) }
- it 'adds an error to the merge request' do
- expect(merge_request.errors[:validate_fork]).to contain_exactly('Source project is not a fork of the target project')
+ it "adds an error to the merge request" do
+ expect(merge_request.errors[:validate_fork]).to contain_exactly("Source project is not a fork of the target project")
end
end
- context 'target_project is in the fork network of source project but no longer accessible' do
+ context "target_project is in the fork network of source project but no longer accessible" do
let!(:project) { fork_project(target_project, user, namespace: user.namespace, repository: true) }
let(:source_project) { project }
let(:target_project) { create(:project, :public, :repository) }
@@ -455,16 +455,16 @@ describe MergeRequests::BuildService do
target_project.update(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'sets the target_project correctly' do
+ it "sets the target_project correctly" do
expect(merge_request.target_project).to eq(project)
end
end
- context 'when specifying target branch in the description' do
+ context "when specifying target branch in the description" do
let(:description) { "A merge request targeting another branch\n\n/target_branch with-codeowners" }
- it 'sets the attribute from the quick actions' do
- expect(merge_request.target_branch).to eq('with-codeowners')
+ it "sets the attribute from the quick actions" do
+ expect(merge_request.target_branch).to eq("with-codeowners")
end
end
end
diff --git a/spec/services/merge_requests/close_service_spec.rb b/spec/services/merge_requests/close_service_spec.rb
index 433ffbd97f0..db7005084aa 100644
--- a/spec/services/merge_requests/close_service_spec.rb
+++ b/spec/services/merge_requests/close_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::CloseService do
let(:user) { create(:user) }
@@ -14,10 +14,10 @@ describe MergeRequests::CloseService do
project.add_guest(guest)
end
- describe '#execute' do
- it_behaves_like 'cache counters invalidator'
+ describe "#execute" do
+ it_behaves_like "cache counters invalidator"
- context 'valid params' do
+ context "valid params" do
let(:service) { described_class.new(project, user, {}) }
before do
@@ -31,28 +31,28 @@ describe MergeRequests::CloseService do
it { expect(@merge_request).to be_valid }
it { expect(@merge_request).to be_closed }
- it 'executes hooks with close action' do
+ it "executes hooks with close action" do
expect(service).to have_received(:execute_hooks)
- .with(@merge_request, 'close')
+ .with(@merge_request, "close")
end
- it 'sends 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 'creates 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 'closed'
+ expect(note.note).to include "closed"
end
- it 'marks todos as done' do
+ it "marks todos as done" do
expect(todo.reload).to be_done
end
end
- it 'updates metrics' do
+ it "updates metrics" do
metrics = merge_request.metrics
metrics_service = double(MergeRequestMetricsService)
allow(MergeRequestMetricsService)
@@ -65,21 +65,21 @@ describe MergeRequests::CloseService do
described_class.new(project, user, {}).execute(merge_request)
end
- it 'refreshes the number of open merge requests for a valid MR', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open merge requests for a valid MR", :use_clean_rails_memory_store_caching do
service = described_class.new(project, user, {})
expect { service.execute(merge_request) }
.to change { project.open_merge_requests_count }.from(1).to(0)
end
- context 'current user is not authorized to close merge request' do
+ context "current user is not authorized to close merge request" do
before do
perform_enqueued_jobs do
@merge_request = described_class.new(project, guest).execute(merge_request)
end
end
- it 'does not close the merge request' do
+ it "does not close the merge request" do
expect(@merge_request).to be_open
end
end
diff --git a/spec/services/merge_requests/conflicts/list_service_spec.rb b/spec/services/merge_requests/conflicts/list_service_spec.rb
index c81fa95e4b7..aebae3124e2 100644
--- a/spec/services/merge_requests/conflicts/list_service_spec.rb
+++ b/spec/services/merge_requests/conflicts/list_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::Conflicts::ListService do
- describe '#can_be_resolved_in_ui?' do
- def create_merge_request(source_branch, target_branch = 'conflict-start')
+ describe "#can_be_resolved_in_ui?" do
+ def create_merge_request(source_branch, target_branch = "conflict-start")
create(:merge_request, source_branch: source_branch, target_branch: target_branch, merge_status: :unchecked) do |mr|
mr.mark_as_unmergeable
end
@@ -12,81 +12,81 @@ describe MergeRequests::Conflicts::ListService do
described_class.new(merge_request)
end
- it 'returns a falsey value when the MR can be merged without conflicts' do
- merge_request = create_merge_request('master')
+ it "returns a falsey value when the MR can be merged without conflicts" do
+ merge_request = create_merge_request("master")
merge_request.mark_as_mergeable
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the MR is marked as having conflicts, but has none' do
- merge_request = create_merge_request('master')
+ it "returns a falsey value when the MR is marked as having conflicts, but has none" do
+ merge_request = create_merge_request("master")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when one of the MR branches is missing' do
- merge_request = create_merge_request('conflict-resolvable')
- merge_request.project.repository.rm_branch(merge_request.author, 'conflict-resolvable')
+ it "returns a falsey value when one of the MR branches is missing" do
+ merge_request = create_merge_request("conflict-resolvable")
+ merge_request.project.repository.rm_branch(merge_request.author, "conflict-resolvable")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the MR does not support new diff notes' do
- merge_request = create_merge_request('conflict-resolvable')
+ it "returns a falsey value when the MR does not support new diff notes" do
+ merge_request = create_merge_request("conflict-resolvable")
merge_request.merge_request_diff.update(start_commit_sha: nil)
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the conflicts contain a large file' do
- merge_request = create_merge_request('conflict-too-large')
+ it "returns a falsey value when the conflicts contain a large file" do
+ merge_request = create_merge_request("conflict-too-large")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the conflicts contain a binary file' do
- merge_request = create_merge_request('conflict-binary-file')
+ it "returns a falsey value when the conflicts contain a binary file" do
+ merge_request = create_merge_request("conflict-binary-file")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the conflicts contain a file edited in one branch and deleted in another' do
- merge_request = create_merge_request('conflict-missing-side')
+ it "returns a falsey value when the conflicts contain a file edited in one branch and deleted in another" do
+ merge_request = create_merge_request("conflict-missing-side")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a truthy value when the conflicts are resolvable in the UI' do
- merge_request = create_merge_request('conflict-resolvable')
+ it "returns a truthy value when the conflicts are resolvable in the UI" do
+ merge_request = create_merge_request("conflict-resolvable")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_truthy
end
- it 'returns a truthy value when the conflicts have to be resolved in an editor' do
- merge_request = create_merge_request('conflict-contains-conflict-markers')
+ it "returns a truthy value when the conflicts have to be resolved in an editor" do
+ merge_request = create_merge_request("conflict-contains-conflict-markers")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_truthy
end
- it 'returns a falsey value when the MR has a missing ref after a force push' do
- merge_request = create_merge_request('conflict-resolvable')
+ it "returns a falsey value when the MR has a missing ref after a force push" do
+ merge_request = create_merge_request("conflict-resolvable")
service = conflicts_service(merge_request)
allow_any_instance_of(Gitlab::GitalyClient::ConflictsService).to receive(:list_conflict_files).and_raise(GRPC::Unknown)
expect(service.can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the MR has a missing revision after a force push' do
- merge_request = create_merge_request('conflict-resolvable')
+ it "returns a falsey value when the MR has a missing revision after a force push" do
+ merge_request = create_merge_request("conflict-resolvable")
service = conflicts_service(merge_request)
allow(merge_request).to receive_message_chain(:target_branch_head, :raw, :id).and_return(Gitlab::Git::BLANK_SHA)
expect(service.can_be_resolved_in_ui?).to be_falsey
end
- it 'returns a falsey value when the conflict is in a submodule revision' do
- merge_request = create_merge_request('update-gitlab-shell-v-6-0-3', 'update-gitlab-shell-v-6-0-1')
+ it "returns a falsey value when the conflict is in a submodule revision" do
+ merge_request = create_merge_request("update-gitlab-shell-v-6-0-3", "update-gitlab-shell-v-6-0-1")
expect(conflicts_service(merge_request).can_be_resolved_in_ui?).to be_falsey
end
diff --git a/spec/services/merge_requests/conflicts/resolve_service_spec.rb b/spec/services/merge_requests/conflicts/resolve_service_spec.rb
index 7edf8a96c94..1063230d632 100644
--- a/spec/services/merge_requests/conflicts/resolve_service_spec.rb
+++ b/spec/services/merge_requests/conflicts/resolve_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::Conflicts::ResolveService do
include ProjectForksHelper
@@ -11,74 +11,74 @@ describe MergeRequests::Conflicts::ResolveService do
let(:merge_request) do
create(:merge_request,
- source_branch: 'conflict-resolvable', source_project: project,
- target_branch: 'conflict-start')
+ source_branch: "conflict-resolvable", source_project: project,
+ target_branch: "conflict-start")
end
let(:merge_request_from_fork) do
create(:merge_request,
- source_branch: 'conflict-resolvable-fork', source_project: forked_project,
- target_branch: 'conflict-start', target_project: project)
+ source_branch: "conflict-resolvable-fork", source_project: forked_project,
+ target_branch: "conflict-start", target_project: project)
end
- describe '#execute' do
+ describe "#execute" do
let(:service) { described_class.new(merge_request) }
def blob_content(project, ref, path)
project.repository.blob_at(ref, path).data
end
- context 'with section params' do
+ context "with section params" do
let(:params) do
{
files: [
{
- old_path: 'files/ruby/popen.rb',
- new_path: 'files/ruby/popen.rb',
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
sections: {
- '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14' => 'head'
- }
+ "2f6fcd96b88b36ce98c38da085c795a27d92a3dd_14_14" => "head",
+ },
}, {
- old_path: 'files/ruby/regex.rb',
- new_path: 'files/ruby/regex.rb',
+ old_path: "files/ruby/regex.rb",
+ new_path: "files/ruby/regex.rb",
sections: {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21' => 'origin',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49' => 'origin'
- }
- }
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21" => "origin",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49" => "origin",
+ },
+ },
],
- commit_message: 'This is a commit message!'
+ commit_message: "This is a commit message!",
}
end
- context 'when the source and target project are the same' do
+ context "when the source and target project are the same" do
before do
service.execute(user, params)
end
- it 'creates a commit with the message' do
+ it "creates a commit with the message" do
expect(merge_request.source_branch_head.message).to eq(params[:commit_message])
end
- it 'creates a commit with the correct parents' do
+ it "creates a commit with the correct parents" do
expect(merge_request.source_branch_head.parents.map(&:id))
- .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06
- 824be604a34828eb682305f0d963056cfac87b2d))
+ .to eq(%w[1450cd639e0bc6721eb02800169e464f212cde06
+ 824be604a34828eb682305f0d963056cfac87b2d])
end
end
- context 'when some files have trailing newlines' do
+ context "when some files have trailing newlines" do
let!(:source_head) do
- branch = 'conflict-resolvable'
- path = 'files/ruby/popen.rb'
+ branch = "conflict-resolvable"
+ path = "files/ruby/popen.rb"
popen_content = blob_content(project, branch, path)
project.repository.update_file(
user,
path,
popen_content.chomp("\n"),
- message: 'Remove trailing newline from popen.rb',
+ message: "Remove trailing newline from popen.rb",
branch_name: branch
)
end
@@ -87,66 +87,67 @@ describe MergeRequests::Conflicts::ResolveService do
service.execute(user, params)
end
- it 'preserves trailing newlines from our side of the conflicts' do
+ it "preserves trailing newlines from our side of the conflicts" do
head_sha = merge_request.source_branch_head.sha
- popen_content = blob_content(project, head_sha, 'files/ruby/popen.rb')
- regex_content = blob_content(project, head_sha, 'files/ruby/regex.rb')
+ popen_content = blob_content(project, head_sha, "files/ruby/popen.rb")
+ regex_content = blob_content(project, head_sha, "files/ruby/regex.rb")
expect(popen_content).not_to end_with("\n")
expect(regex_content).to end_with("\n")
end
end
- context 'when the source project is a fork and does not contain the HEAD of the target branch' do
+ context "when the source project is a fork and does not contain the HEAD of the target branch" do
let!(:target_head) do
project.repository.create_file(
user,
- 'new-file-in-target',
- '',
- message: 'Add new file in target',
- branch_name: 'conflict-start')
+ "new-file-in-target",
+ "",
+ message: "Add new file in target",
+ branch_name: "conflict-start"
+ )
end
subject do
described_class.new(merge_request_from_fork).execute(user, params)
end
- it 'creates a commit with the message' do
+ it "creates a commit with the message" do
subject
expect(merge_request_from_fork.source_branch_head.message).to eq(params[:commit_message])
end
- it 'creates a commit with the correct parents' do
+ it "creates a commit with the correct parents" do
subject
expect(merge_request_from_fork.source_branch_head.parents.map(&:id))
- .to eq(['404fa3fc7c2c9b5dacff102f353bdf55b1be2813', target_head])
+ .to eq(["404fa3fc7c2c9b5dacff102f353bdf55b1be2813", target_head])
end
end
end
- context 'with content and sections params' do
+ context "with content and sections params" do
let(:popen_content) { "class Popen\nend" }
let(:params) do
{
files: [
{
- old_path: 'files/ruby/popen.rb',
- new_path: 'files/ruby/popen.rb',
- content: popen_content
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ content: popen_content,
}, {
- old_path: 'files/ruby/regex.rb',
- new_path: 'files/ruby/regex.rb',
+ old_path: "files/ruby/regex.rb",
+ new_path: "files/ruby/regex.rb",
sections: {
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21' => 'origin',
- '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49' => 'origin'
- }
- }
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_21_21" => "origin",
+ "6eb14e00385d2fb284765eb1cd8d420d33d63fc9_49_49" => "origin",
+ },
+ },
],
- commit_message: 'This is a commit message!'
+ commit_message: "This is a commit message!",
}
end
@@ -154,97 +155,97 @@ describe MergeRequests::Conflicts::ResolveService do
service.execute(user, params)
end
- it 'creates a commit with the message' do
+ it "creates a commit with the message" do
expect(merge_request.source_branch_head.message).to eq(params[:commit_message])
end
- it 'creates a commit with the correct parents' do
+ it "creates a commit with the correct parents" do
expect(merge_request.source_branch_head.parents.map(&:id))
- .to eq(%w(1450cd639e0bc6721eb02800169e464f212cde06
- 824be604a34828eb682305f0d963056cfac87b2d))
+ .to eq(%w[1450cd639e0bc6721eb02800169e464f212cde06
+ 824be604a34828eb682305f0d963056cfac87b2d])
end
- it 'sets the content to the content given' do
+ it "sets the content to the content given" do
blob = blob_content(
merge_request.source_project,
merge_request.source_branch_head.sha,
- 'files/ruby/popen.rb'
+ "files/ruby/popen.rb"
)
expect(blob).to eq(popen_content)
end
end
- context 'when a resolution section is missing' do
+ context "when a resolution section is missing" do
let(:invalid_params) do
{
files: [
{
- old_path: 'files/ruby/popen.rb',
- new_path: 'files/ruby/popen.rb',
- content: ''
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ content: "",
}, {
- old_path: 'files/ruby/regex.rb',
- new_path: 'files/ruby/regex.rb',
- sections: { '6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9' => 'head' }
- }
+ old_path: "files/ruby/regex.rb",
+ new_path: "files/ruby/regex.rb",
+ sections: {"6eb14e00385d2fb284765eb1cd8d420d33d63fc9_9_9" => "head"},
+ },
],
- commit_message: 'This is a commit message!'
+ commit_message: "This is a commit message!",
}
end
- it 'raises a ResolutionError error' do
+ it "raises a ResolutionError error" do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
end
- context 'when the content of a file is unchanged' do
+ context "when the content of a file is unchanged" do
let(:resolver) do
MergeRequests::Conflicts::ListService.new(merge_request).conflicts.resolver
end
let(:regex_conflict) do
- resolver.conflict_for_path(resolver.conflicts, 'files/ruby/regex.rb', 'files/ruby/regex.rb')
+ resolver.conflict_for_path(resolver.conflicts, "files/ruby/regex.rb", "files/ruby/regex.rb")
end
let(:invalid_params) do
{
files: [
{
- old_path: 'files/ruby/popen.rb',
- new_path: 'files/ruby/popen.rb',
- content: ''
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ content: "",
}, {
- old_path: 'files/ruby/regex.rb',
- new_path: 'files/ruby/regex.rb',
- content: regex_conflict.content
- }
+ old_path: "files/ruby/regex.rb",
+ new_path: "files/ruby/regex.rb",
+ content: regex_conflict.content,
+ },
],
- commit_message: 'This is a commit message!'
+ commit_message: "This is a commit message!",
}
end
- it 'raises a ResolutionError error' do
+ it "raises a ResolutionError error" do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
end
- context 'when a file is missing' do
+ context "when a file is missing" do
let(:invalid_params) do
{
files: [
{
- old_path: 'files/ruby/popen.rb',
- new_path: 'files/ruby/popen.rb',
- content: ''
- }
+ old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ content: "",
+ },
],
- commit_message: 'This is a commit message!'
+ commit_message: "This is a commit message!",
}
end
- it 'raises a ResolutionError error' do
+ it "raises a ResolutionError error" do
expect { service.execute(user, invalid_params) }
.to raise_error(Gitlab::Git::Conflict::Resolver::ResolutionError)
end
diff --git a/spec/services/merge_requests/create_from_issue_service_spec.rb b/spec/services/merge_requests/create_from_issue_service_spec.rb
index 393299cce00..6a0c1035347 100644
--- a/spec/services/merge_requests/create_from_issue_service_spec.rb
+++ b/spec/services/merge_requests/create_from_issue_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::CreateFromIssueService do
let(:project) { create(:project, :repository) }
@@ -6,7 +6,7 @@ describe MergeRequests::CreateFromIssueService do
let(:label_ids) { create_pair(:label, project: project).map(&:id) }
let(:milestone_id) { create(:milestone, project: project).id }
let(:issue) { create(:issue, project: project, milestone_id: milestone_id) }
- let(:custom_source_branch) { 'custom-source-branch' }
+ let(:custom_source_branch) { "custom-source-branch" }
subject(:service) { described_class.new(project, user, issue_iid: issue.iid) }
subject(:service_with_custom_source_branch) { described_class.new(project, user, issue_iid: issue.iid, branch_name: custom_source_branch) }
@@ -15,15 +15,15 @@ describe MergeRequests::CreateFromIssueService do
project.add_developer(user)
end
- describe '#execute' do
- it 'returns an error with invalid issue iid' do
+ describe "#execute" do
+ it "returns an error with invalid issue iid" do
result = described_class.new(project, user, issue_iid: -1).execute
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('Invalid issue iid')
+ expect(result[:message]).to eq("Invalid issue iid")
end
- it 'delegates issue search to IssuesFinder' do
+ it "delegates issue search to IssuesFinder" do
expect_any_instance_of(IssuesFinder).to receive(:find_by).once.and_call_original
described_class.new(project, user, issue_iid: -1).execute
@@ -43,31 +43,31 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].milestone_id).to eq(milestone_id)
end
- it 'delegates the branch creation to CreateBranchService' do
+ it "delegates the branch creation to CreateBranchService" do
expect_any_instance_of(CreateBranchService).to receive(:execute).once.and_call_original
service.execute
end
- it 'creates a branch based on issue title' do
+ it "creates a branch based on issue title" do
service.execute
expect(project.repository.branch_exists?(issue.to_branch_name)).to be_truthy
end
- it 'creates a branch using passed name' do
+ it "creates a branch using passed name" do
service_with_custom_source_branch.execute
expect(project.repository.branch_exists?(custom_source_branch)).to be_truthy
end
- it 'creates the new_merge_request system note' do
+ it "creates the new_merge_request system note" do
expect(SystemNoteService).to receive(:new_merge_request).with(issue, project, user, instance_of(MergeRequest))
service.execute
end
- it 'creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created' do
+ it "creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created" do
project.project_feature.update!(merge_requests_access_level: ProjectFeature::DISABLED)
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name)
@@ -75,7 +75,7 @@ describe MergeRequests::CreateFromIssueService do
service.execute
end
- it 'creates a merge request' do
+ it "creates a merge request" do
expect { service.execute }.to change(project.merge_requests, :count).by(1)
end
@@ -85,31 +85,31 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].title).to eq("WIP: Resolve \"#{issue.title}\"")
end
- it 'sets the merge request author to current user' do
+ it "sets the merge request author to current user" do
result = service.execute
expect(result[:merge_request].author).to eq(user)
end
- it 'sets the merge request source branch to the new issue branch' do
+ it "sets the merge request source branch to the new issue branch" do
result = service.execute
expect(result[:merge_request].source_branch).to eq(issue.to_branch_name)
end
- it 'sets the merge request source branch to the passed branch name' do
+ it "sets the merge request source branch to the passed branch name" do
result = service_with_custom_source_branch.execute
expect(result[:merge_request].source_branch).to eq(custom_source_branch)
end
- it 'sets the merge request target branch to the project default branch' do
+ it "sets the merge request target branch to the project default branch" do
result = service.execute
expect(result[:merge_request].target_branch).to eq(project.default_branch)
end
- it 'executes quick actions if the build service sets them in the description' do
+ it "executes quick actions if the build service sets them in the description" do
allow(service).to receive(:merge_request).and_wrap_original do |m, *args|
m.call(*args).tap do |merge_request|
merge_request.description = "/assign #{user.to_reference}"
@@ -121,25 +121,25 @@ describe MergeRequests::CreateFromIssueService do
expect(result[:merge_request].assignee).to eq(user)
end
- context 'when ref branch is set' do
- subject { described_class.new(project, user, issue_iid: issue.iid, ref: 'feature').execute }
+ context "when ref branch is set" do
+ subject { described_class.new(project, user, issue_iid: issue.iid, ref: "feature").execute }
- it 'sets the merge request source branch to the new issue branch' do
+ it "sets the merge request source branch to the new issue branch" do
expect(subject[:merge_request].source_branch).to eq(issue.to_branch_name)
end
- it 'sets the merge request target branch to the ref branch' do
- expect(subject[:merge_request].target_branch).to eq('feature')
+ it "sets the merge request target branch to the ref branch" do
+ expect(subject[:merge_request].target_branch).to eq("feature")
end
- context 'when ref branch does not exist' do
- subject { described_class.new(project, user, issue_iid: issue.iid, ref: 'no-such-branch').execute }
+ context "when ref branch does not exist" do
+ subject { described_class.new(project, user, issue_iid: issue.iid, ref: "no-such-branch").execute }
- it 'creates a merge request' do
+ it "creates a merge request" do
expect { subject }.to change(project.merge_requests, :count).by(1)
end
- it 'sets the merge request target branch to the project default branch' do
+ it "sets the merge request target branch to the project default branch" do
expect(subject[:merge_request].target_branch).to eq(project.default_branch)
end
end
diff --git a/spec/services/merge_requests/create_service_spec.rb b/spec/services/merge_requests/create_service_spec.rb
index b46aa65818d..97f2fa943ae 100644
--- a/spec/services/merge_requests/create_service_spec.rb
+++ b/spec/services/merge_requests/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::CreateService do
include ProjectForksHelper
@@ -7,15 +7,15 @@ describe MergeRequests::CreateService do
let(:user) { create(:user) }
let(:assignee) { create(:user) }
- describe '#execute' do
- context 'valid params' do
+ describe "#execute" do
+ context "valid params" do
let(:opts) do
{
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'feature',
- target_branch: 'master',
- force_remove_source_branch: '1'
+ title: "Awesome merge_request",
+ description: "please fix",
+ source_branch: "feature",
+ target_branch: "master",
+ force_remove_source_branch: "1",
}
end
@@ -28,91 +28,91 @@ describe MergeRequests::CreateService do
allow(service).to receive(:execute_hooks)
end
- it 'creates an MR' do
+ it "creates an MR" do
expect(merge_request).to be_valid
expect(merge_request.work_in_progress?).to be(false)
- expect(merge_request.title).to eq('Awesome merge_request')
+ expect(merge_request.title).to eq("Awesome merge_request")
expect(merge_request.assignee).to be_nil
- expect(merge_request.merge_params['force_remove_source_branch']).to eq('1')
+ expect(merge_request.merge_params["force_remove_source_branch"]).to eq("1")
end
- it 'executes hooks with default action' do
+ it "executes hooks with default action" do
expect(service).to have_received(:execute_hooks).with(merge_request)
end
- it 'refreshes the number of open merge requests', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open merge requests", :use_clean_rails_memory_store_caching do
expect { service.execute }
.to change { project.open_merge_requests_count }.from(0).to(1)
end
- it 'does not creates todos' do
+ it "does not creates todos" do
attributes = {
project: project,
target_id: merge_request.id,
- target_type: merge_request.class.name
+ target_type: merge_request.class.name,
}
expect(Todo.where(attributes).count).to be_zero
end
- it 'creates exactly 1 create MR event' do
+ it "creates exactly 1 create MR event" do
attributes = {
action: Event::CREATED,
target_id: merge_request.id,
- target_type: merge_request.class.name
+ target_type: merge_request.class.name,
}
expect(Event.where(attributes).count).to eq(1)
end
- describe 'when marked with /wip' do
- context 'in title and in description' do
+ describe "when marked with /wip" do
+ context "in title and in description" do
let(:opts) do
{
- title: 'WIP: Awesome merge_request',
+ title: "WIP: Awesome merge_request",
description: "well this is not done yet\n/wip",
- source_branch: 'feature',
- target_branch: 'master',
- assignee: assignee
+ source_branch: "feature",
+ target_branch: "master",
+ assignee: assignee,
}
end
- it 'sets MR to WIP' do
+ it "sets MR to WIP" do
expect(merge_request.work_in_progress?).to be(true)
end
end
- context 'in description only' do
+ context "in description only" do
let(:opts) do
{
- title: 'Awesome merge_request',
+ title: "Awesome merge_request",
description: "well this is not done yet\n/wip",
- source_branch: 'feature',
- target_branch: 'master',
- assignee: assignee
+ source_branch: "feature",
+ target_branch: "master",
+ assignee: assignee,
}
end
- it 'sets MR to WIP' do
+ it "sets MR to WIP" do
expect(merge_request.work_in_progress?).to be(true)
end
end
end
- context 'when merge request is assigned to someone' do
+ context "when merge request is assigned to someone" do
let(:opts) do
{
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'feature',
- target_branch: 'master',
- assignee: assignee
+ title: "Awesome merge_request",
+ description: "please fix",
+ source_branch: "feature",
+ target_branch: "master",
+ assignee: assignee,
}
end
it { expect(merge_request.assignee).to eq assignee }
- it 'creates a todo for new assignee' do
+ it "creates a todo for new assignee" do
attributes = {
project: project,
author: user,
@@ -120,14 +120,14 @@ describe MergeRequests::CreateService do
target_id: merge_request.id,
target_type: merge_request.class.name,
action: Todo::ASSIGNED,
- state: :pending
+ state: :pending,
}
expect(Todo.where(attributes).count).to eq 1
end
end
- context 'when head pipelines already exist for merge request source branch' do
+ context "when head pipelines already exist for merge request source branch" do
let(:shas) { project.repository.commits(opts[:source_branch], limit: 2).map(&:id) }
let!(:pipeline_1) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[1]) }
let!(:pipeline_2) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[0]) }
@@ -141,18 +141,18 @@ describe MergeRequests::CreateService do
# rubocop: enable DestroyAll
end
- it 'sets head pipeline' do
+ it "sets head pipeline" do
merge_request = service.execute
expect(merge_request.reload.head_pipeline).to eq(pipeline_2)
expect(merge_request).to be_persisted
end
- context 'when the new pipeline is associated with an old sha' do
+ context "when the new pipeline is associated with an old sha" do
let!(:pipeline_1) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[0]) }
let!(:pipeline_2) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[1]) }
- it 'sets an old pipeline with associated with the latest sha as the head pipeline' do
+ it "sets an old pipeline with associated with the latest sha as the head pipeline" do
merge_request = service.execute
expect(merge_request.reload.head_pipeline).to eq(pipeline_1)
@@ -160,11 +160,11 @@ describe MergeRequests::CreateService do
end
end
- context 'when there are no pipelines with the diff head sha' do
+ context "when there are no pipelines with the diff head sha" do
let!(:pipeline_1) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[1]) }
let!(:pipeline_2) { create(:ci_pipeline, project: project, ref: opts[:source_branch], project_id: project.id, sha: shas[1]) }
- it 'does not set the head pipeline' do
+ it "does not set the head pipeline" do
merge_request = service.execute
expect(merge_request.reload.head_pipeline).to be_nil
@@ -173,7 +173,7 @@ describe MergeRequests::CreateService do
end
end
- describe 'Merge request pipelines' do
+ describe "Merge request pipelines" do
before do
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
@@ -182,14 +182,14 @@ describe MergeRequests::CreateService do
let(:config) do
{
test: {
- stage: 'test',
- script: 'echo',
- only: ['merge_requests']
- }
+ stage: "test",
+ script: "echo",
+ only: ["merge_requests"],
+ },
}
end
- it 'creates a merge request pipeline and sets it as a head pipeline' do
+ it "creates a merge request pipeline and sets it as a head pipeline" do
expect(merge_request).to be_persisted
merge_request.reload
@@ -197,17 +197,17 @@ describe MergeRequests::CreateService do
expect(merge_request.actual_head_pipeline).to be_merge_request
end
- context 'when there are no commits between source branch and target branch' do
+ context "when there are no commits between source branch and target branch" do
let(:opts) do
{
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'not-merged-branch',
- target_branch: 'master'
+ title: "Awesome merge_request",
+ description: "please fix",
+ source_branch: "not-merged-branch",
+ target_branch: "master",
}
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(merge_request).to be_persisted
merge_request.reload
@@ -225,7 +225,7 @@ describe MergeRequests::CreateService do
merge_request
end
- it 'sets the latest merge request pipeline as the head pipeline' do
+ it "sets the latest merge request pipeline as the head pipeline" do
expect(merge_request.actual_head_pipeline).to be_merge_request
end
end
@@ -235,7 +235,7 @@ describe MergeRequests::CreateService do
stub_feature_flags(ci_merge_request_pipeline: false)
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(merge_request).to be_persisted
merge_request.reload
@@ -248,13 +248,13 @@ describe MergeRequests::CreateService do
let(:config) do
{
test: {
- stage: 'test',
- script: 'echo'
- }
+ stage: "test",
+ script: "echo",
+ },
}
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect(merge_request).to be_persisted
merge_request.reload
@@ -264,17 +264,17 @@ describe MergeRequests::CreateService do
end
end
- it_behaves_like 'new issuable record that supports quick actions' do
+ it_behaves_like "new issuable record that supports quick actions" do
let(:default_params) do
{
- source_branch: 'feature',
- target_branch: 'master'
+ source_branch: "feature",
+ target_branch: "master",
}
end
end
- context 'Quick actions' do
- context 'with assignee and milestone in params and command' do
+ context "Quick actions" do
+ context "with assignee and milestone in params and command" do
let(:merge_request) { described_class.new(project, user, opts).execute }
let(:milestone) { create(:milestone, project: project) }
@@ -282,10 +282,10 @@ describe MergeRequests::CreateService do
{
assignee_id: create(:user).id,
milestone_id: 1,
- title: 'Title',
+ title: "Title",
description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}"),
- source_branch: 'feature',
- target_branch: 'master'
+ source_branch: "feature",
+ target_branch: "master",
}
end
@@ -294,7 +294,7 @@ describe MergeRequests::CreateService do
project.add_maintainer(assignee)
end
- it 'assigns and sets milestone to issuable from command' do
+ it "assigns and sets milestone to issuable from command" do
expect(merge_request).to be_persisted
expect(merge_request.assignee).to eq(assignee)
expect(merge_request.milestone).to eq(milestone)
@@ -302,51 +302,51 @@ describe MergeRequests::CreateService do
end
end
- context 'merge request create service' do
- context 'asssignee_id' do
+ context "merge request create service" do
+ context "asssignee_id" do
let(:assignee) { create(:user) }
before do
project.add_maintainer(user)
end
- it 'removes assignee_id when user id is invalid' do
- opts = { title: 'Title', description: 'Description', assignee_id: -1 }
+ it "removes assignee_id when user id is invalid" do
+ opts = {title: "Title", description: "Description", assignee_id: -1}
merge_request = described_class.new(project, user, opts).execute
expect(merge_request.assignee_id).to be_nil
end
- it 'removes assignee_id when user id is 0' do
- opts = { title: 'Title', description: 'Description', assignee_id: 0 }
+ it "removes assignee_id when user id is 0" do
+ opts = {title: "Title", description: "Description", assignee_id: 0}
merge_request = described_class.new(project, user, opts).execute
expect(merge_request.assignee_id).to be_nil
end
- it 'saves assignee when user id is valid' do
+ it "saves assignee when user id is valid" do
project.add_maintainer(assignee)
- opts = { title: 'Title', description: 'Description', assignee_id: assignee.id }
+ opts = {title: "Title", description: "Description", assignee_id: assignee.id}
merge_request = described_class.new(project, user, opts).execute
expect(merge_request.assignee).to eq(assignee)
end
- context 'when assignee is set' do
+ context "when assignee is set" do
let(:opts) do
{
- title: 'Title',
- description: 'Description',
+ title: "Title",
+ description: "Description",
assignee_id: assignee.id,
- source_branch: 'feature',
- target_branch: 'master'
+ source_branch: "feature",
+ target_branch: "master",
}
end
- it 'invalidates open merge request counter for assignees when merge request is assigned' do
+ it "invalidates open merge request counter for assignees when merge request is assigned" do
project.add_maintainer(assignee)
described_class.new(project, user, opts).execute
@@ -366,7 +366,7 @@ describe MergeRequests::CreateService do
levels.each do |level|
it "removes not authorized assignee when project is #{Gitlab::VisibilityLevel.level_name(level)}" do
project.update(visibility_level: level)
- opts = { title: 'Title', description: 'Description', assignee_id: assignee.id }
+ opts = {title: "Title", description: "Description", assignee_id: assignee.id}
merge_request = described_class.new(project, user, opts).execute
@@ -377,16 +377,16 @@ describe MergeRequests::CreateService do
end
end
- context 'while saving references to issues that the created merge request closes' do
+ context "while saving references to issues that the created merge request closes" do
let(:first_issue) { create(:issue, project: project) }
let(:second_issue) { create(:issue, project: project) }
let(:opts) do
{
- title: 'Awesome merge_request',
- source_branch: 'feature',
- target_branch: 'master',
- force_remove_source_branch: '1'
+ title: "Awesome merge_request",
+ source_branch: "feature",
+ target_branch: "master",
+ force_remove_source_branch: "1",
}
end
@@ -395,7 +395,7 @@ describe MergeRequests::CreateService do
project.add_developer(assignee)
end
- it 'creates a `MergeRequestsClosingIssues` record for each issue' do
+ it "creates a `MergeRequestsClosingIssues` record for each issue" do
issue_closing_opts = opts.merge(description: "Closes #{first_issue.to_reference} and #{second_issue.to_reference}")
service = described_class.new(project, user, issue_closing_opts)
allow(service).to receive(:execute_hooks)
@@ -406,55 +406,55 @@ describe MergeRequests::CreateService do
end
end
- context 'when source and target projects are different' do
+ context "when source and target projects are different" do
let(:target_project) { fork_project(project, nil, repository: true) }
let(:opts) do
{
- title: 'Awesome merge_request',
- source_branch: 'feature',
- target_branch: 'master',
- target_project_id: target_project.id
+ title: "Awesome merge_request",
+ source_branch: "feature",
+ target_branch: "master",
+ target_project_id: target_project.id,
}
end
- context 'when user can not access source project' do
+ context "when user can not access source project" do
before do
target_project.add_developer(assignee)
target_project.add_maintainer(user)
end
- it 'raises an error' do
+ it "raises an error" do
expect { described_class.new(project, user, opts).execute }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'when user can not access target project' do
+ context "when user can not access target project" do
before do
target_project.add_developer(assignee)
target_project.add_maintainer(user)
end
- it 'raises an error' do
+ it "raises an error" do
expect { described_class.new(project, user, opts).execute }
.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'when the user has access to both projects' do
+ context "when the user has access to both projects" do
before do
target_project.add_developer(user)
project.add_developer(user)
end
- it 'creates the merge request' do
+ it "creates the merge request" do
merge_request = described_class.new(project, user, opts).execute
expect(merge_request).to be_persisted
end
- it 'does not create the merge request when the target project is archived' do
+ it "does not create the merge request when the target project is archived" do
target_project.update!(archived: true)
expect { described_class.new(project, user, opts).execute }
@@ -463,15 +463,15 @@ describe MergeRequests::CreateService do
end
end
- context 'when user sets source project id' do
+ context "when user sets source project id" do
let(:another_project) { create(:project) }
let(:opts) do
{
- title: 'Awesome merge_request',
- source_branch: 'feature',
- target_branch: 'master',
- source_project_id: another_project.id
+ title: "Awesome merge_request",
+ source_branch: "feature",
+ target_branch: "master",
+ source_project_id: another_project.id,
}
end
@@ -480,7 +480,7 @@ describe MergeRequests::CreateService do
project.add_maintainer(user)
end
- it 'ignores source_project_id' do
+ it "ignores source_project_id" do
merge_request = described_class.new(project, user, opts).execute
expect(merge_request.source_project_id).to eq(project.id)
diff --git a/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb b/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb
index 6268c149fc6..24962f6cee1 100644
--- a/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb
+++ b/spec/services/merge_requests/delete_non_latest_diffs_service_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_state do
let(:merge_request) { create(:merge_request) }
let!(:subject) { described_class.new(merge_request) }
- describe '#execute' do
+ describe "#execute" do
before do
stub_const("#{described_class.name}::BATCH_SIZE", 2)
3.times { merge_request.create_merge_request_diff }
end
- it 'schedules non-latest merge request diffs removal' do
+ it "schedules non-latest merge request diffs removal" do
diffs = merge_request.merge_request_diffs
expect(diffs.count).to eq(4)
@@ -29,7 +29,7 @@ describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_
end
end
- it 'schedules no removal if it is already cleaned' do
+ it "schedules no removal if it is already cleaned" do
merge_request.merge_request_diffs.each(&:clean!)
expect(DeleteDiffFilesWorker).not_to receive(:bulk_perform_in)
@@ -37,7 +37,7 @@ describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_
subject.execute
end
- it 'schedules no removal if it is empty' do
+ it "schedules no removal if it is empty" do
merge_request.merge_request_diffs.each { |diff| diff.update!(state: :empty) }
expect(DeleteDiffFilesWorker).not_to receive(:bulk_perform_in)
@@ -45,7 +45,7 @@ describe MergeRequests::DeleteNonLatestDiffsService, :clean_gitlab_redis_shared_
subject.execute
end
- it 'schedules no removal if there is no non-latest diffs' do
+ it "schedules no removal if there is no non-latest diffs" do
# rubocop: disable DestroyAll
merge_request
.merge_request_diffs
diff --git a/spec/services/merge_requests/ff_merge_service_spec.rb b/spec/services/merge_requests/ff_merge_service_spec.rb
index fe673de46aa..1e3ccf956a1 100644
--- a/spec/services/merge_requests/ff_merge_service_spec.rb
+++ b/spec/services/merge_requests/ff_merge_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::FfMergeService do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:merge_request) do
create(:merge_request,
- source_branch: 'flatten-dir',
- target_branch: 'improve/awesome',
- assignee: user2,
- author: create(:user))
+ source_branch: "flatten-dir",
+ target_branch: "improve/awesome",
+ assignee: user2,
+ author: create(:user))
end
let(:project) { merge_request.project }
@@ -17,8 +17,8 @@ describe MergeRequests::FfMergeService do
project.add_developer(user2)
end
- describe '#execute' do
- context 'valid params' do
+ describe "#execute" do
+ context "valid params" do
let(:service) { described_class.new(project, user, {}) }
before do
@@ -38,27 +38,27 @@ describe MergeRequests::FfMergeService do
it { expect(merge_request).to be_valid }
it { expect(merge_request).to be_merged }
- it 'sends 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 'creates 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 'merged'
+ expect(note.note).to include "merged"
end
end
context "error handling" do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
before do
allow(Rails.logger).to receive(:error)
end
- it 'logs and saves error if there is an exception' do
- error_message = 'error message'
+ it "logs and saves error if there is an exception" do
+ error_message = "error message"
allow(service).to receive(:repository).and_raise("error message")
allow(service).to receive(:execute_hooks)
@@ -69,8 +69,8 @@ describe MergeRequests::FfMergeService do
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
end
- it 'logs and saves error if there is an PreReceiveError exception' do
- error_message = 'error message'
+ it "logs and saves error if there is an PreReceiveError exception" do
+ error_message = "error message"
allow(service).to receive(:repository).and_raise(Gitlab::Git::PreReceiveError, error_message)
allow(service).to receive(:execute_hooks)
diff --git a/spec/services/merge_requests/get_urls_service_spec.rb b/spec/services/merge_requests/get_urls_service_spec.rb
index 274624aa8bb..373ee2fb72f 100644
--- a/spec/services/merge_requests/get_urls_service_spec.rb
+++ b/spec/services/merge_requests/get_urls_service_spec.rb
@@ -14,78 +14,78 @@ describe MergeRequests::GetUrlsService do
let(:default_branch_changes) { "d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/master" }
describe "#execute" do
- shared_examples 'new_merge_request_link' do
- it 'returns url to create new merge request' do
+ shared_examples "new_merge_request_link" do
+ it "returns url to create new merge request" do
result = service.execute(changes)
expect(result).to match([{
branch_name: source_branch,
url: new_merge_request_url,
- new_merge_request: true
+ new_merge_request: true,
}])
end
end
- shared_examples 'show_merge_request_url' do
- it 'returns url to view merge request' do
+ shared_examples "show_merge_request_url" do
+ it "returns url to view merge request" do
result = service.execute(changes)
expect(result).to match([{
branch_name: source_branch,
url: show_merge_request_url,
- new_merge_request: false
+ new_merge_request: false,
}])
end
end
- shared_examples 'no_merge_request_url' do
- it 'returns no URL' do
+ shared_examples "no_merge_request_url" do
+ it "returns no URL" do
result = service.execute(changes)
expect(result).to be_empty
end
end
- context 'pushing to default branch' do
+ context "pushing to default branch" do
let(:changes) { default_branch_changes }
- it_behaves_like 'no_merge_request_url'
+ it_behaves_like "no_merge_request_url"
end
- context 'pushing to project with MRs disabled' do
+ context "pushing to project with MRs disabled" do
let(:changes) { new_branch_changes }
before do
project.project_feature.update_attribute(:merge_requests_access_level, ProjectFeature::DISABLED)
end
- it_behaves_like 'no_merge_request_url'
+ it_behaves_like "no_merge_request_url"
end
- context 'pushing one completely new branch' do
+ context "pushing one completely new branch" do
let(:changes) { new_branch_changes }
- it_behaves_like 'new_merge_request_link'
+ it_behaves_like "new_merge_request_link"
end
- context 'pushing to existing branch but no merge request' do
+ context "pushing to existing branch but no merge request" do
let(:changes) { existing_branch_changes }
- it_behaves_like 'new_merge_request_link'
+ it_behaves_like "new_merge_request_link"
end
- context 'pushing to deleted branch' do
+ context "pushing to deleted branch" do
let(:changes) { deleted_branch_changes }
- it_behaves_like 'no_merge_request_url'
+ it_behaves_like "no_merge_request_url"
end
- context 'pushing to existing branch and merge request opened' do
+ context "pushing to existing branch and merge request opened" do
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
- it_behaves_like 'show_merge_request_url'
+ it_behaves_like "show_merge_request_url"
end
- context 'pushing to existing branch and merge request is reopened' do
+ context "pushing to existing branch and merge request is reopened" do
let!(:merge_request) { create(:merge_request, :opened, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
- it_behaves_like 'show_merge_request_url'
+ it_behaves_like "show_merge_request_url"
end
- context 'pushing to existing branch from forked project' do
+ context "pushing to existing branch from forked project" do
let(:user) { create(:user) }
let!(:forked_project) { fork_project(project, user, repository: true) }
let!(:merge_request) { create(:merge_request, source_project: forked_project, target_project: project, source_branch: source_branch) }
@@ -97,44 +97,44 @@ describe MergeRequests::GetUrlsService do
allow(forked_project).to receive(:empty_repo?).and_return(false)
end
- it_behaves_like 'show_merge_request_url'
+ it_behaves_like "show_merge_request_url"
end
- context 'pushing to existing branch and merge request is closed' do
+ context "pushing to existing branch and merge request is closed" do
let!(:merge_request) { create(:merge_request, :closed, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
- it_behaves_like 'new_merge_request_link'
+ it_behaves_like "new_merge_request_link"
end
- context 'pushing to existing branch and merge request is merged' do
+ context "pushing to existing branch and merge request is merged" do
let!(:merge_request) { create(:merge_request, :merged, source_project: project, source_branch: source_branch) }
let(:changes) { existing_branch_changes }
- it_behaves_like 'new_merge_request_link'
+ it_behaves_like "new_merge_request_link"
end
- context 'pushing new branch and existing branch (with merge request created) at once' do
+ context "pushing new branch and existing branch (with merge request created) at once" do
let!(:merge_request) { create(:merge_request, source_project: project, source_branch: "markdown") }
let(:new_branch_changes) { "#{Gitlab::Git::BLANK_SHA} 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/new_branch" }
let(:existing_branch_changes) { "d14d6c0abdd253381df51a723d58691b2ee1ab08 570e7b2abdd848b95f2f578043fc23bd6f6fd24d refs/heads/markdown" }
let(:changes) { "#{new_branch_changes}\n#{existing_branch_changes}" }
let(:new_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=new_branch" }
- it 'returns 2 urls for both creating new and showing merge request' do
+ it "returns 2 urls for both creating new and showing merge request" do
result = service.execute(changes)
expect(result).to match([{
branch_name: "new_branch",
url: new_merge_request_url,
- new_merge_request: true
+ new_merge_request: true,
}, {
branch_name: "markdown",
url: show_merge_request_url,
- new_merge_request: false
- }])
+ new_merge_request: false,
+ },])
end
end
- context 'when printing_merge_request_link_enabled is false' do
- it 'returns empty array' do
+ context "when printing_merge_request_link_enabled is false" do
+ it "returns empty array" do
project.update!(printing_merge_request_link_enabled: false)
result = service.execute(existing_branch_changes)
diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb
index ede79b87bcc..9569cf86084 100644
--- a/spec/services/merge_requests/merge_service_spec.rb
+++ b/spec/services/merge_requests/merge_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::MergeService do
set(:user) { create(:user) }
@@ -11,9 +11,9 @@ describe MergeRequests::MergeService do
project.add_developer(user2)
end
- describe '#execute' do
- context 'valid params' do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ describe "#execute" do
+ context "valid params" do
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
before do
allow(service).to receive(:execute_hooks)
@@ -26,28 +26,28 @@ describe MergeRequests::MergeService do
it { expect(merge_request).to be_valid }
it { expect(merge_request).to be_merged }
- it 'sends 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 'creates 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 'merged'
+ expect(note.note).to include "merged"
end
end
- context 'closes related issues' do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ context "closes related issues" do
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
before do
allow(project).to receive(:default_branch).and_return(merge_request.target_branch)
end
- it 'closes GitLab issue tracker issues' do
+ it "closes GitLab issue tracker issues" do
issue = create :issue, project: project
- commit = double('commit', safe_message: "Fixes #{issue.to_reference}")
+ commit = double("commit", safe_message: "Fixes #{issue.to_reference}")
allow(merge_request).to receive(:commits).and_return([commit])
merge_request.cache_merge_request_closes_issues!
@@ -56,12 +56,12 @@ describe MergeRequests::MergeService do
expect(issue.reload.closed?).to be_truthy
end
- context 'with JIRA integration' do
+ context "with JIRA integration" do
include JiraServiceHelper
let(:jira_tracker) { project.create_jira_service }
- let(:jira_issue) { ExternalIssue.new('JIRA-123', project) }
- let(:commit) { double('commit', safe_message: "Fixes #{jira_issue.to_reference}") }
+ let(:jira_issue) { ExternalIssue.new("JIRA-123", project) }
+ let(:commit) { double("commit", safe_message: "Fixes #{jira_issue.to_reference}") }
before do
project.update!(has_external_issue_tracker: true)
@@ -70,10 +70,10 @@ describe MergeRequests::MergeService do
allow(merge_request).to receive(:commits).and_return([commit])
end
- it 'closes issues on JIRA issue tracker' do
- jira_issue = ExternalIssue.new('JIRA-123', project)
+ it "closes issues on JIRA issue tracker" do
+ jira_issue = ExternalIssue.new("JIRA-123", project)
stub_jira_urls(jira_issue)
- commit = double('commit', safe_message: "Fixes #{jira_issue.to_reference}")
+ commit = double("commit", safe_message: "Fixes #{jira_issue.to_reference}")
allow(merge_request).to receive(:commits).and_return([commit])
expect_any_instance_of(JiraService).to receive(:close_issue).with(merge_request, jira_issue).once
@@ -96,10 +96,10 @@ describe MergeRequests::MergeService do
end
context "wrong issue markdown" do
- it 'does not close issues on JIRA issue tracker' do
- jira_issue = ExternalIssue.new('#JIRA-123', project)
+ it "does not close issues on JIRA issue tracker" do
+ jira_issue = ExternalIssue.new("#JIRA-123", project)
stub_jira_urls(jira_issue)
- commit = double('commit', safe_message: "Fixes #{jira_issue.to_reference}")
+ commit = double("commit", safe_message: "Fixes #{jira_issue.to_reference}")
allow(merge_request).to receive(:commits).and_return([commit])
expect_any_instance_of(JiraService).not_to receive(:close_issue)
@@ -110,10 +110,10 @@ describe MergeRequests::MergeService do
end
end
- context 'closes related todos' do
+ context "closes related todos" do
let(:merge_request) { create(:merge_request, assignee: user, author: user) }
let(:project) { merge_request.project }
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
let!(:todo) do
create(:todo, :assigned,
project: project,
@@ -134,68 +134,68 @@ describe MergeRequests::MergeService do
it { expect(todo).to be_done }
end
- context 'source branch removal' do
- context 'when the source branch is protected' do
+ context "source branch removal" do
+ context "when the source branch is protected" do
let(:service) do
- described_class.new(project, user, 'should_remove_source_branch' => true)
+ described_class.new(project, user, "should_remove_source_branch" => true)
end
before do
create(:protected_branch, project: project, name: merge_request.source_branch)
end
- it 'does not delete the source branch' do
+ it "does not delete the source branch" do
expect(DeleteBranchService).not_to receive(:new)
service.execute(merge_request)
end
end
- context 'when the source branch is the default branch' do
+ context "when the source branch is the default branch" do
let(:service) do
- described_class.new(project, user, 'should_remove_source_branch' => true)
+ described_class.new(project, user, "should_remove_source_branch" => true)
end
before do
allow(project).to receive(:root_ref?).with(merge_request.source_branch).and_return(true)
end
- it 'does not delete the source branch' do
+ it "does not delete the source branch" do
expect(DeleteBranchService).not_to receive(:new)
service.execute(merge_request)
end
end
- context 'when the source branch can be removed' do
- context 'when MR author set the source branch to be removed' do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ context "when the source branch can be removed" do
+ context "when MR author set the source branch to be removed" do
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
before do
- merge_request.update_attribute(:merge_params, { 'force_remove_source_branch' => '1' })
+ merge_request.update_attribute(:merge_params, {"force_remove_source_branch" => "1"})
end
- it 'removes the source branch using the author user' do
+ it "removes the source branch using the author user" do
expect(DeleteBranchService).to receive(:new)
.with(merge_request.source_project, merge_request.author)
.and_call_original
service.execute(merge_request)
end
- context 'when the merger set the source branch not to be removed' do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message', 'should_remove_source_branch' => false) }
+ context "when the merger set the source branch not to be removed" do
+ let(:service) { described_class.new(project, user, :commit_message => "Awesome message", "should_remove_source_branch" => false) }
- it 'does not delete the source branch' do
+ it "does not delete the source branch" do
expect(DeleteBranchService).not_to receive(:new)
service.execute(merge_request)
end
end
end
- context 'when MR merger set the source branch to be removed' do
+ context "when MR merger set the source branch to be removed" do
let(:service) do
- described_class.new(project, user, commit_message: 'Awesome message', 'should_remove_source_branch' => true)
+ described_class.new(project, user, :commit_message => "Awesome message", "should_remove_source_branch" => true)
end
- it 'removes the source branch using the current user' do
+ it "removes the source branch using the current user" do
expect(DeleteBranchService).to receive(:new)
.with(merge_request.source_project, user)
.and_call_original
@@ -206,25 +206,25 @@ describe MergeRequests::MergeService do
end
context "error handling" do
- let(:service) { described_class.new(project, user, commit_message: 'Awesome message') }
+ let(:service) { described_class.new(project, user, commit_message: "Awesome message") }
before do
allow(Rails.logger).to receive(:error)
end
- it 'logs and saves error if there is an exception' do
- error_message = 'error message'
+ it "logs and saves error if there is an exception" do
+ error_message = "error message"
allow(service).to receive(:repository).and_raise("error message")
allow(service).to receive(:execute_hooks)
service.execute(merge_request)
- expect(merge_request.merge_error).to include('Something went wrong during merge')
+ expect(merge_request.merge_error).to include("Something went wrong during merge")
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
end
- it 'logs and saves error if user is not authorized' do
+ it "logs and saves error if user is not authorized" do
unauthorized_user = create(:user)
project.add_reporter(unauthorized_user)
@@ -233,23 +233,23 @@ describe MergeRequests::MergeService do
service.execute(merge_request)
expect(merge_request.merge_error)
- .to eq('You are not allowed to merge this merge request')
+ .to eq("You are not allowed to merge this merge request")
end
- it 'logs and saves error if there is an PreReceiveError exception' do
- error_message = 'error message'
+ it "logs and saves error if there is an PreReceiveError exception" do
+ error_message = "error message"
allow(service).to receive(:repository).and_raise(Gitlab::Git::PreReceiveError, error_message)
allow(service).to receive(:execute_hooks)
service.execute(merge_request)
- expect(merge_request.merge_error).to include('Something went wrong during merge pre-receive hook')
+ expect(merge_request.merge_error).to include("Something went wrong during merge pre-receive hook")
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
end
- it 'logs and saves error if there is a merge conflict' do
- error_message = 'Conflicts detected during merge'
+ it "logs and saves error if there is a merge conflict" do
+ error_message = "Conflicts detected during merge"
allow_any_instance_of(Repository).to receive(:merge).and_return(false)
allow(service).to receive(:execute_hooks)
@@ -262,13 +262,13 @@ describe MergeRequests::MergeService do
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
end
- context 'when squashing' do
+ context "when squashing" do
before do
- merge_request.update!(source_branch: 'master', target_branch: 'feature')
+ merge_request.update!(source_branch: "master", target_branch: "feature")
end
- it 'logs and saves error if there is an error when squashing' do
- error_message = 'Failed to squash. Should be done manually'
+ it "logs and saves error if there is an error when squashing" do
+ error_message = "Failed to squash. Should be done manually"
allow_any_instance_of(MergeRequests::SquashService).to receive(:squash!).and_return(nil)
merge_request.update(squash: true)
@@ -281,8 +281,8 @@ describe MergeRequests::MergeService do
expect(Rails.logger).to have_received(:error).with(a_string_matching(error_message))
end
- it 'logs and saves error if there is a squash in progress' do
- error_message = 'another squash is already in progress'
+ it "logs and saves error if there is a squash in progress" do
+ error_message = "another squash is already in progress"
allow_any_instance_of(MergeRequest).to receive(:squash_in_progress?).and_return(true)
merge_request.update(squash: true)
@@ -300,11 +300,11 @@ describe MergeRequests::MergeService do
allow_any_instance_of(Repository).to receive(:ancestor?).and_return(nil)
end
- %w(semi-linear ff).each do |merge_method|
+ %w[semi-linear ff].each do |merge_method|
it "logs and saves error if merge is #{merge_method} only" do
- merge_method = 'rebase_merge' if merge_method == 'semi-linear'
+ merge_method = "rebase_merge" if merge_method == "semi-linear"
merge_request.project.update(merge_method: merge_method)
- error_message = 'Only fast-forward merge is allowed for your project. Please update your source branch'
+ error_message = "Only fast-forward merge is allowed for your project. Please update your source branch"
allow(service).to receive(:execute_hooks)
service.execute(merge_request)
diff --git a/spec/services/merge_requests/merge_to_ref_service_spec.rb b/spec/services/merge_requests/merge_to_ref_service_spec.rb
index 96f2fde7117..174d5d7b70e 100644
--- a/spec/services/merge_requests/merge_to_ref_service_spec.rb
+++ b/spec/services/merge_requests/merge_to_ref_service_spec.rb
@@ -1,10 +1,10 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::MergeToRefService do
- shared_examples_for 'MergeService for target ref' do
- it 'target_ref has the same state of target branch' do
+ shared_examples_for "MergeService for target ref" do
+ it "target_ref has the same state of target branch" do
repo = merge_request.target_project.repository
process_merge_to_ref
@@ -27,11 +27,11 @@ describe MergeRequests::MergeToRefService do
project.add_maintainer(user)
end
- describe '#execute' do
+ describe "#execute" do
let(:service) do
described_class.new(project, user,
- commit_message: 'Awesome message',
- 'should_remove_source_branch' => true)
+ :commit_message => "Awesome message",
+ "should_remove_source_branch" => true)
end
def process_merge_to_ref
@@ -40,7 +40,7 @@ describe MergeRequests::MergeToRefService do
end
end
- it 'writes commit to merge ref' do
+ it "writes commit to merge ref" do
repository = project.repository
target_ref = merge_request.merge_ref_path
@@ -56,43 +56,43 @@ describe MergeRequests::MergeToRefService do
expect(ref_head.id).to eq(result[:commit_id])
end
- it 'does not send any mail' do
+ it "does not send any mail" do
expect { process_merge_to_ref }.not_to change { ActionMailer::Base.deliveries.count }
end
- it 'does not change the MR state' do
+ it "does not change the MR state" do
expect { process_merge_to_ref }.not_to change { merge_request.state }
end
- it 'does not create notes' do
+ it "does not create notes" do
expect { process_merge_to_ref }.not_to change { merge_request.notes.count }
end
- it 'does not delete the source branch' do
+ it "does not delete the source branch" do
expect(DeleteBranchService).not_to receive(:new)
process_merge_to_ref
end
- it 'returns error when feature is disabled' do
+ it "returns error when feature is disabled" do
stub_feature_flags(merge_to_tmp_merge_ref_path: false)
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('Feature is not enabled')
+ expect(result[:message]).to eq("Feature is not enabled")
end
- it 'returns an error when the failing to process the merge' do
+ it "returns an error when the failing to process the merge" do
allow(project.repository).to receive(:merge_to_ref).and_return(nil)
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('Conflicts detected during merge')
+ expect(result[:message]).to eq("Conflicts detected during merge")
end
- context 'commit history comparison with regular MergeService' do
+ context "commit history comparison with regular MergeService" do
let(:merge_ref_service) do
described_class.new(project, user, {})
end
@@ -101,31 +101,31 @@ describe MergeRequests::MergeToRefService do
MergeRequests::MergeService.new(project, user, {})
end
- context 'when merge commit' do
- it_behaves_like 'MergeService for target ref'
+ context "when merge commit" do
+ it_behaves_like "MergeService for target ref"
end
- context 'when merge commit with squash' do
+ context "when merge commit with squash" do
before do
- merge_request.update!(squash: true, source_branch: 'master', target_branch: 'feature')
+ merge_request.update!(squash: true, source_branch: "master", target_branch: "feature")
end
- it_behaves_like 'MergeService for target ref'
+ it_behaves_like "MergeService for target ref"
end
end
- context 'merge pre-condition checks' do
+ context "merge pre-condition checks" do
before do
merge_request.project.update!(merge_method: merge_method)
end
- context 'when semi-linear merge method' do
+ context "when semi-linear merge method" do
let(:merge_method) { :rebase_merge }
- it 'return error when MR should be able to fast-forward' do
+ it "return error when MR should be able to fast-forward" do
allow(merge_request).to receive(:should_be_rebased?) { true }
- error_message = 'Fast-forward merge is not possible. Please update your source branch.'
+ error_message = "Fast-forward merge is not possible. Please update your source branch."
result = service.execute(merge_request)
@@ -134,10 +134,10 @@ describe MergeRequests::MergeToRefService do
end
end
- context 'when fast-forward merge method' do
+ context "when fast-forward merge method" do
let(:merge_method) { :ff }
- it 'returns error' do
+ it "returns error" do
error_message = "Fast-forward to #{merge_request.merge_ref_path} is currently not supported."
result = service.execute(merge_request)
@@ -147,10 +147,10 @@ describe MergeRequests::MergeToRefService do
end
end
- context 'when MR is not mergeable to ref' do
+ context "when MR is not mergeable to ref" do
let(:merge_method) { :merge }
- it 'returns error' do
+ it "returns error" do
allow(merge_request).to receive(:mergeable_to_ref?) { false }
error_message = "Merge request is not mergeable to #{merge_request.merge_ref_path}"
@@ -163,15 +163,15 @@ describe MergeRequests::MergeToRefService do
end
end
- context 'does not close related todos' do
+ context "does not close related todos" do
let(:merge_request) { create(:merge_request, assignee: user, author: user) }
let(:project) { merge_request.project }
let!(:todo) do
create(:todo, :assigned,
- project: project,
- author: user,
- user: user,
- target: merge_request)
+ project: project,
+ author: user,
+ user: user,
+ target: merge_request)
end
before do
@@ -186,7 +186,7 @@ describe MergeRequests::MergeToRefService do
it { expect(todo).not_to be_done }
end
- it 'returns error when user has no authorization to admin the merge request' do
+ it "returns error when user has no authorization to admin the merge request" do
unauthorized_user = create(:user)
project.add_reporter(unauthorized_user)
@@ -195,7 +195,7 @@ describe MergeRequests::MergeToRefService do
result = service.execute(merge_request)
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('You are not allowed to merge to this ref')
+ expect(result[:message]).to eq("You are not allowed to merge to this ref")
end
end
end
diff --git a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
index 52bbd4e794d..3823503d3a4 100644
--- a/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
+++ b/spec/services/merge_requests/merge_when_pipeline_succeeds_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::MergeWhenPipelineSucceedsService do
let(:user) { create(:user) }
@@ -6,7 +6,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
let(:mr_merge_if_green_enabled) do
create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user,
- source_branch: "master", target_branch: 'feature',
+ source_branch: "master", target_branch: "feature",
source_project: project, target_project: project, state: "opened")
end
@@ -16,16 +16,16 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
end
let(:service) do
- described_class.new(project, user, commit_message: 'Awesome message')
+ described_class.new(project, user, commit_message: "Awesome message")
end
describe "#execute" do
let(:merge_request) do
create(:merge_request, target_project: project, source_project: project,
- source_branch: "feature", target_branch: 'master')
+ source_branch: "feature", target_branch: "master")
end
- context 'first time enabling' do
+ context "first time enabling" do
before do
allow(merge_request)
.to receive(:head_pipeline)
@@ -34,20 +34,20 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
service.execute(merge_request)
end
- it 'sets the params, merge_user, and flag' do
+ it "sets the params, merge_user, and flag" do
expect(merge_request).to be_valid
expect(merge_request.merge_when_pipeline_succeeds).to be_truthy
- expect(merge_request.merge_params).to eq commit_message: 'Awesome message'
+ expect(merge_request.merge_params).to eq commit_message: "Awesome message"
expect(merge_request.merge_user).to be user
end
- it 'creates a system note' do
+ it "creates a system note" do
note = merge_request.notes.last
expect(note.note).to match %r{enabled an automatic merge when the pipeline for (\w+/\w+@)?\h{8}}
end
end
- context 'already approved' do
+ context "already approved" do
let(:service) { described_class.new(project, user, new_key: true) }
let(:build) { create(:ci_build, ref: mr_merge_if_green_enabled.source_branch) }
@@ -61,7 +61,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
allow(pipeline).to receive(:success?).and_return(true)
end
- it 'updates the merge params' do
+ it "updates the merge params" do
expect(SystemNoteService).not_to receive(:merge_when_pipeline_succeeds)
service.execute(mr_merge_if_green_enabled)
@@ -76,10 +76,10 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
project.commit(mr_merge_if_green_enabled.source_branch).id
end
- context 'when triggered by pipeline with valid ref and sha' do
+ context "when triggered by pipeline with valid ref and sha" do
let(:triggering_pipeline) do
create(:ci_pipeline, project: project, ref: merge_request_ref,
- sha: merge_request_head, status: 'success',
+ sha: merge_request_head, status: "success",
head_pipeline_of: mr_merge_if_green_enabled)
end
@@ -89,25 +89,25 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
end
end
- context 'when triggered by an old pipeline' do
+ context "when triggered by an old pipeline" do
let(:old_pipeline) do
create(:ci_pipeline, project: project, ref: merge_request_ref,
- sha: '1234abcdef', status: 'success')
+ sha: "1234abcdef", status: "success")
end
- it 'it does not merge request' do
+ it "it does not merge request" do
expect(MergeWorker).not_to receive(:perform_async)
service.trigger(old_pipeline)
end
end
- context 'when triggered by pipeline from a different branch' do
+ context "when triggered by pipeline from a different branch" do
let(:unrelated_pipeline) do
- create(:ci_pipeline, project: project, ref: 'feature',
- sha: merge_request_head, status: 'success')
+ create(:ci_pipeline, project: project, ref: "feature",
+ sha: merge_request_head, status: "success")
end
- it 'does not merge request' do
+ it "does not merge request" do
expect(MergeWorker).not_to receive(:perform_async)
service.trigger(unrelated_pipeline)
end
@@ -125,14 +125,14 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
expect(mr_merge_if_green_enabled.merge_user).to be nil
end
- it 'Posts a system note' do
+ it "Posts a system note" do
note = mr_merge_if_green_enabled.notes.last
- expect(note.note).to include 'canceled the automatic merge'
+ expect(note.note).to include "canceled the automatic merge"
end
end
- describe 'pipeline integration' do
- context 'when there are multiple stages in the pipeline' do
+ describe "pipeline integration" do
+ context "when there are multiple stages in the pipeline" do
let(:ref) { mr_merge_if_green_enabled.source_branch }
let(:sha) { project.commit(ref).id }
@@ -142,12 +142,12 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
let!(:build) do
create(:ci_build, :created, pipeline: pipeline, ref: ref,
- name: 'build', stage: 'build')
+ name: "build", stage: "build")
end
let!(:test) do
create(:ci_build, :created, pipeline: pipeline, ref: ref,
- name: 'test', stage: 'test')
+ name: "test", stage: "test")
end
before do
@@ -168,7 +168,7 @@ describe MergeRequests::MergeWhenPipelineSucceedsService do
test.drop
end
- it 'merges when all stages succeeded' do
+ it "merges when all stages succeeded" do
expect(MergeWorker).to receive(:perform_async)
build.success
diff --git a/spec/services/merge_requests/post_merge_service_spec.rb b/spec/services/merge_requests/post_merge_service_spec.rb
index 5ad6f5528f9..9a31c739940 100644
--- a/spec/services/merge_requests/post_merge_service_spec.rb
+++ b/spec/services/merge_requests/post_merge_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::PostMergeService do
let(:user) { create(:user) }
@@ -9,13 +9,13 @@ describe MergeRequests::PostMergeService do
project.add_maintainer(user)
end
- describe '#execute' do
- it_behaves_like 'cache counters invalidator'
+ describe "#execute" do
+ it_behaves_like "cache counters invalidator"
- it 'refreshes the number of open merge requests for a valid MR', :use_clean_rails_memory_store_caching do
+ it "refreshes the number of open merge requests for a valid MR", :use_clean_rails_memory_store_caching do
# Cache the counter before the MR changed state.
project.open_merge_requests_count
- merge_request.update!(state: 'merged')
+ merge_request.update!(state: "merged")
service = described_class.new(project, user, {})
@@ -23,7 +23,7 @@ describe MergeRequests::PostMergeService do
.to change { project.open_merge_requests_count }.from(1).to(0)
end
- it 'updates metrics' do
+ it "updates metrics" do
metrics = merge_request.metrics
metrics_service = double(MergeRequestMetricsService)
allow(MergeRequestMetricsService)
@@ -36,7 +36,7 @@ describe MergeRequests::PostMergeService do
described_class.new(project, user, {}).execute(merge_request)
end
- it 'deletes non-latest diffs' do
+ it "deletes non-latest diffs" do
diff_removal_service = instance_double(MergeRequests::DeleteNonLatestDiffsService, execute: nil)
expect(MergeRequests::DeleteNonLatestDiffsService)
@@ -48,9 +48,9 @@ describe MergeRequests::PostMergeService do
expect(diff_removal_service).to have_received(:execute)
end
- it 'marks MR as merged regardless of errors when closing issues' do
- merge_request.update(target_branch: 'foo')
- allow(project).to receive(:default_branch).and_return('foo')
+ it "marks MR as merged regardless of errors when closing issues" do
+ merge_request.update(target_branch: "foo")
+ allow(project).to receive(:default_branch).and_return("foo")
issue = create(:issue, project: project)
allow(merge_request).to receive(:visible_closing_issues_for).and_return([issue])
diff --git a/spec/services/merge_requests/rebase_service_spec.rb b/spec/services/merge_requests/rebase_service_spec.rb
index 427a2d63a88..1671172ea9a 100644
--- a/spec/services/merge_requests/rebase_service_spec.rb
+++ b/spec/services/merge_requests/rebase_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::RebaseService do
include ProjectForksHelper
@@ -6,8 +6,8 @@ describe MergeRequests::RebaseService do
let(:user) { create(:user) }
let(:merge_request) do
create(:merge_request,
- source_branch: 'feature_conflict',
- target_branch: 'master')
+ source_branch: "feature_conflict",
+ target_branch: "master")
end
let(:project) { merge_request.project }
let(:repository) { project.repository.raw }
@@ -18,87 +18,87 @@ describe MergeRequests::RebaseService do
project.add_maintainer(user)
end
- describe '#execute' do
- context 'when another rebase is already in progress' do
+ describe "#execute" do
+ context "when another rebase is already in progress" do
before do
allow(merge_request).to receive(:rebase_in_progress?).and_return(true)
end
- it 'saves the error message' do
+ it "saves the error message" do
subject.execute(merge_request)
- expect(merge_request.reload.merge_error).to eq 'Rebase task canceled: Another rebase is already in progress'
+ expect(merge_request.reload.merge_error).to eq "Rebase task canceled: Another rebase is already in progress"
end
- it 'returns an error' do
+ it "returns an error" do
expect(service.execute(merge_request)).to match(status: :error,
message: described_class::REBASE_ERROR)
end
end
- context 'when unexpected error occurs' do
+ context "when unexpected error occurs" do
before do
- allow(repository).to receive(:gitaly_operation_client).and_raise('Something went wrong')
+ allow(repository).to receive(:gitaly_operation_client).and_raise("Something went wrong")
end
- it 'saves a generic error message' do
+ it "saves a generic error message" do
subject.execute(merge_request)
expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR
end
- it 'returns an error' do
+ it "returns an error" do
expect(service.execute(merge_request)).to match(status: :error,
message: described_class::REBASE_ERROR)
end
end
- context 'with git command failure' do
+ context "with git command failure" do
before do
- allow(repository).to receive(:gitaly_operation_client).and_raise(Gitlab::Git::Repository::GitError, 'Something went wrong')
+ allow(repository).to receive(:gitaly_operation_client).and_raise(Gitlab::Git::Repository::GitError, "Something went wrong")
end
- it 'saves a generic error message' do
+ it "saves a generic error message" do
subject.execute(merge_request)
expect(merge_request.reload.merge_error).to eq described_class::REBASE_ERROR
end
- it 'returns an error' do
+ it "returns an error" do
expect(service.execute(merge_request)).to match(status: :error,
message: described_class::REBASE_ERROR)
end
end
- context 'valid params' do
- describe 'successful rebase' do
+ context "valid params" do
+ describe "successful rebase" do
before do
service.execute(merge_request)
end
- it 'rebases source branch' do
+ it "rebases source branch" do
parent_sha = merge_request.source_project.repository.commit(merge_request.source_branch).parents.first.sha
target_branch_sha = merge_request.target_project.repository.commit(merge_request.target_branch).sha
expect(parent_sha).to eq(target_branch_sha)
end
- it 'records the new SHA on the merge request' do
+ it "records the new SHA on the merge request" do
head_sha = merge_request.source_project.repository.commit(merge_request.source_branch).sha
expect(merge_request.reload.rebase_commit_sha).to eq(head_sha)
end
- it 'logs correct author and committer' do
+ it "logs correct author and committer" do
head_commit = merge_request.source_project.repository.commit(merge_request.source_branch)
- expect(head_commit.author_email).to eq('dmitriy.zaporozhets@gmail.com')
- expect(head_commit.author_name).to eq('Dmitriy Zaporozhets')
+ expect(head_commit.author_email).to eq("dmitriy.zaporozhets@gmail.com")
+ expect(head_commit.author_name).to eq("Dmitriy Zaporozhets")
expect(head_commit.committer_email).to eq(user.email)
expect(head_commit.committer_name).to eq(user.name)
end
end
- context 'fork' do
- describe 'successful fork rebase' do
+ context "fork" do
+ describe "successful fork rebase" do
let(:forked_project) do
fork_project(project, user, repository: true)
end
@@ -106,17 +106,18 @@ describe MergeRequests::RebaseService do
let(:merge_request_from_fork) do
forked_project.repository.create_file(
user,
- 'new-file-to-target',
- '',
- message: 'Add new file to target',
- branch_name: 'master')
+ "new-file-to-target",
+ "",
+ message: "Add new file to target",
+ branch_name: "master"
+ )
create(:merge_request,
- source_branch: 'master', source_project: forked_project,
- target_branch: 'master', target_project: project)
+ source_branch: "master", source_project: forked_project,
+ target_branch: "master", target_project: project)
end
- it 'rebases source branch' do
+ it "rebases source branch" do
parent_sha = forked_project.repository.commit(merge_request_from_fork.source_branch).parents.first.sha
target_branch_sha = project.repository.commit(merge_request_from_fork.target_branch).sha
expect(parent_sha).to eq(target_branch_sha)
diff --git a/spec/services/merge_requests/refresh_service_spec.rb b/spec/services/merge_requests/refresh_service_spec.rb
index 9e9dc5a576c..5fd6430bb98 100644
--- a/spec/services/merge_requests/refresh_service_spec.rb
+++ b/spec/services/merge_requests/refresh_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::RefreshService do
include ProjectForksHelper
@@ -7,7 +7,7 @@ describe MergeRequests::RefreshService do
let(:user) { create(:user) }
let(:service) { described_class }
- describe '#execute' do
+ describe "#execute" do
before do
@user = create(:user)
group = create(:group)
@@ -17,40 +17,40 @@ describe MergeRequests::RefreshService do
@fork_project = fork_project(@project, @user, repository: true)
@merge_request = create(:merge_request,
- source_project: @project,
- source_branch: 'master',
- target_branch: 'feature',
- target_project: @project,
- merge_when_pipeline_succeeds: true,
- merge_user: @user)
+ source_project: @project,
+ source_branch: "master",
+ target_branch: "feature",
+ target_project: @project,
+ merge_when_pipeline_succeeds: true,
+ merge_user: @user)
@another_merge_request = create(:merge_request,
- source_project: @project,
- source_branch: 'master',
- target_branch: 'test',
- target_project: @project,
- merge_when_pipeline_succeeds: true,
- merge_user: @user)
+ source_project: @project,
+ source_branch: "master",
+ target_branch: "test",
+ target_project: @project,
+ merge_when_pipeline_succeeds: true,
+ merge_user: @user)
@fork_merge_request = create(:merge_request,
- source_project: @fork_project,
- source_branch: 'master',
- target_branch: 'feature',
- target_project: @project)
+ source_project: @fork_project,
+ source_branch: "master",
+ target_branch: "feature",
+ target_project: @project)
@build_failed_todo = create(:todo,
- :build_failed,
- user: @user,
- project: @project,
- target: @merge_request,
- author: @user)
+ :build_failed,
+ user: @user,
+ project: @project,
+ target: @merge_request,
+ author: @user)
@fork_build_failed_todo = create(:todo,
- :build_failed,
- user: @user,
- project: @project,
- target: @merge_request,
- author: @user)
+ :build_failed,
+ user: @user,
+ project: @project,
+ target: @merge_request,
+ author: @user)
@commits = @merge_request.commits
@@ -58,21 +58,21 @@ describe MergeRequests::RefreshService do
@newrev = @commits.first.id
end
- context 'push to origin repo source branch' do
+ context "push to origin repo source branch" do
let(:refresh_service) { service.new(@project, @user) }
- let(:notification_service) { spy('notification_service') }
+ let(:notification_service) { spy("notification_service") }
before do
allow(refresh_service).to receive(:execute_hooks)
allow(NotificationService).to receive(:new) { notification_service }
end
- it 'executes hooks with update action' do
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ it "executes hooks with update action" do
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
reload_mrs
expect(refresh_service).to have_received(:execute_hooks)
- .with(@merge_request, 'update', old_rev: @oldrev)
+ .with(@merge_request, "update", old_rev: @oldrev)
expect(notification_service).to have_received(:push_to_merge_request)
.with(@merge_request, @user, new_commits: anything, existing_commits: anything)
@@ -89,68 +89,68 @@ describe MergeRequests::RefreshService do
expect(@fork_build_failed_todo).to be_done
end
- it 'reloads source branch MRs memoization' do
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ it "reloads source branch MRs memoization" do
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
- expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') }.to change {
+ expect { refresh_service.execute(@oldrev, @newrev, "refs/heads/master") }.to change {
refresh_service.instance_variable_get("@source_merge_requests").first.merge_request_diff
}
end
- context 'when source branch ref does not exists' do
+ context "when source branch ref does not exists" do
before do
DeleteBranchService.new(@project, @user).execute(@merge_request.source_branch)
end
- it 'closes MRs without source branch ref' do
- expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') }
+ it "closes MRs without source branch ref" do
+ expect { refresh_service.execute(@oldrev, @newrev, "refs/heads/master") }
.to change { @merge_request.reload.state }
- .from('opened')
- .to('closed')
+ .from("opened")
+ .to("closed")
expect(@fork_merge_request.reload).to be_open
end
- it 'does not change the merge request diff' do
- expect { refresh_service.execute(@oldrev, @newrev, 'refs/heads/master') }
+ it "does not change the merge request diff" do
+ expect { refresh_service.execute(@oldrev, @newrev, "refs/heads/master") }
.not_to change { @merge_request.reload.merge_request_diff }
end
end
end
- context 'when pipeline exists for the source branch' do
+ context "when pipeline exists for the source branch" do
let!(:pipeline) { create(:ci_empty_pipeline, ref: @merge_request.source_branch, project: @project, sha: @commits.first.sha)}
- subject { service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/master') }
+ subject { service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/master") }
- it 'updates the head_pipeline_id for @merge_request' do
+ it "updates the head_pipeline_id for @merge_request" do
expect { subject }.to change { @merge_request.reload.head_pipeline_id }.from(nil).to(pipeline.id)
end
- it 'does not update the head_pipeline_id for @fork_merge_request' do
+ it "does not update the head_pipeline_id for @fork_merge_request" do
expect { subject }.not_to change { @fork_merge_request.reload.head_pipeline_id }
end
end
- describe 'Merge request pipelines' do
+ describe "Merge request pipelines" do
before do
stub_ci_pipeline_yaml_file(YAML.dump(config))
end
- subject { service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/master') }
+ subject { service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/master") }
context "when .gitlab-ci.yml has merge_requests keywords" do
let(:config) do
{
test: {
- stage: 'test',
- script: 'echo',
- only: ['merge_requests']
- }
+ stage: "test",
+ script: "echo",
+ only: ["merge_requests"],
+ },
}
end
- it 'create merge request pipeline with commits' do
+ it "create merge request pipeline with commits" do
expect { subject }
.to change { @merge_request.merge_request_pipelines.count }.by(1)
.and change { @fork_merge_request.merge_request_pipelines.count }.by(1)
@@ -171,12 +171,12 @@ describe MergeRequests::RefreshService do
subject
end
- it 'sets the latest merge request pipeline as a head pipeline' do
+ it "sets the latest merge request pipeline as a head pipeline" do
@merge_request.reload
expect(@merge_request.actual_head_pipeline).to be_merge_request
end
- it 'returns pipelines in correct order' do
+ it "returns pipelines in correct order" do
@merge_request.reload
expect(@merge_request.all_pipelines.first).to be_merge_request
expect(@merge_request.all_pipelines.second).to be_push
@@ -184,14 +184,14 @@ describe MergeRequests::RefreshService do
end
context "when MergeRequestUpdateWorker is retried by an exception" do
- it 'does not re-create a duplicate merge request pipeline' do
- expect do
- service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/master')
- end.to change { @merge_request.merge_request_pipelines.count }.by(1)
-
- expect do
- service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/master')
- end.not_to change { @merge_request.merge_request_pipelines.count }
+ it "does not re-create a duplicate merge request pipeline" do
+ expect {
+ service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/master")
+ }.to change { @merge_request.merge_request_pipelines.count }.by(1)
+
+ expect {
+ service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/master")
+ }.not_to change { @merge_request.merge_request_pipelines.count }
end
end
@@ -200,7 +200,7 @@ describe MergeRequests::RefreshService do
stub_feature_flags(ci_merge_request_pipeline: false)
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect { subject }
.not_to change { @merge_request.merge_request_pipelines.count }
end
@@ -211,35 +211,35 @@ describe MergeRequests::RefreshService do
let(:config) do
{
test: {
- stage: 'test',
- script: 'echo'
- }
+ stage: "test",
+ script: "echo",
+ },
}
end
- it 'does not create a merge request pipeline' do
+ it "does not create a merge request pipeline" do
expect { subject }
.not_to change { @merge_request.merge_request_pipelines.count }
end
end
end
- context 'push to origin repo source branch when an MR was reopened' do
+ context "push to origin repo source branch when an MR was reopened" do
let(:refresh_service) { service.new(@project, @user) }
- let(:notification_service) { spy('notification_service') }
+ let(:notification_service) { spy("notification_service") }
before do
@merge_request.update(state: :reopened)
allow(refresh_service).to receive(:execute_hooks)
allow(NotificationService).to receive(:new) { notification_service }
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
reload_mrs
end
- it 'executes hooks with update action' do
+ it "executes hooks with update action" do
expect(refresh_service).to have_received(:execute_hooks)
- .with(@merge_request, 'update', old_rev: @oldrev)
+ .with(@merge_request, "update", old_rev: @oldrev)
expect(notification_service).to have_received(:push_to_merge_request)
.with(@merge_request, @user, new_commits: anything, existing_commits: anything)
expect(notification_service).to have_received(:push_to_merge_request)
@@ -256,112 +256,112 @@ describe MergeRequests::RefreshService do
end
end
- context 'push to origin repo target branch' do
- context 'when all MRs to the target branch had diffs' do
+ context "push to origin repo target branch" do
+ context "when all MRs to the target branch had diffs" do
before do
- service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
+ service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/feature")
reload_mrs
end
- it 'updates the merge state' do
- expect(@merge_request.notes.last.note).to include('merged')
+ it "updates the merge state" do
+ expect(@merge_request.notes.last.note).to include("merged")
expect(@merge_request).to be_merged
expect(@fork_merge_request).to be_merged
- expect(@fork_merge_request.notes.last.note).to include('merged')
+ expect(@fork_merge_request.notes.last.note).to include("merged")
expect(@build_failed_todo).to be_done
expect(@fork_build_failed_todo).to be_done
end
end
- context 'when an MR to be closed was empty already' do
+ context "when an MR to be closed was empty already" do
let!(:empty_fork_merge_request) do
create(:merge_request,
- source_project: @fork_project,
- source_branch: 'master',
- target_branch: 'master',
- target_project: @project)
+ source_project: @fork_project,
+ source_branch: "master",
+ target_branch: "master",
+ target_project: @project)
end
before do
# This spec already has a fake push, so pretend that we were targeting
# feature all along.
- empty_fork_merge_request.update_columns(target_branch: 'feature')
+ empty_fork_merge_request.update_columns(target_branch: "feature")
- service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
+ service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/feature")
reload_mrs
empty_fork_merge_request.reload
end
- it 'only updates the non-empty MRs' do
+ it "only updates the non-empty MRs" do
expect(@merge_request).to be_merged
- expect(@merge_request.notes.last.note).to include('merged')
+ expect(@merge_request.notes.last.note).to include("merged")
expect(@fork_merge_request).to be_merged
- expect(@fork_merge_request.notes.last.note).to include('merged')
+ expect(@fork_merge_request.notes.last.note).to include("merged")
expect(empty_fork_merge_request).to be_open
- expect(empty_fork_merge_request.merge_request_diff.state).to eq('empty')
+ expect(empty_fork_merge_request.merge_request_diff.state).to eq("empty")
expect(empty_fork_merge_request.notes).to be_empty
end
end
end
- context 'manual merge of source branch' do
+ context "manual merge of source branch" do
before do
# Merge master -> feature branch
- @project.repository.merge(@user, @merge_request.diff_head_sha, @merge_request, 'Test message')
- commit = @project.repository.commit('feature')
- service.new(@project, @user).execute(@oldrev, commit.id, 'refs/heads/feature')
+ @project.repository.merge(@user, @merge_request.diff_head_sha, @merge_request, "Test message")
+ commit = @project.repository.commit("feature")
+ service.new(@project, @user).execute(@oldrev, commit.id, "refs/heads/feature")
reload_mrs
end
- it 'updates the merge state' do
- expect(@merge_request.notes.last.note).to include('merged')
+ it "updates the merge state" do
+ expect(@merge_request.notes.last.note).to include("merged")
expect(@merge_request).to be_merged
expect(@merge_request.diffs.size).to be > 0
expect(@fork_merge_request).to be_merged
- expect(@fork_merge_request.notes.last.note).to include('merged')
+ expect(@fork_merge_request.notes.last.note).to include("merged")
expect(@build_failed_todo).to be_done
expect(@fork_build_failed_todo).to be_done
end
end
- context 'push to fork repo source branch' do
+ context "push to fork repo source branch" do
let(:refresh_service) { service.new(@fork_project, @user) }
- context 'open fork merge request' do
+ context "open fork merge request" do
before do
allow(refresh_service).to receive(:execute_hooks)
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
reload_mrs
end
- it 'executes 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', old_rev: @oldrev)
+ .with(@fork_merge_request, "update", old_rev: @oldrev)
expect(@merge_request.notes).to be_empty
expect(@merge_request).to be_open
- expect(@fork_merge_request.notes.last.note).to include('added 28 commits')
+ expect(@fork_merge_request.notes.last.note).to include("added 28 commits")
expect(@fork_merge_request).to be_open
expect(@build_failed_todo).to be_pending
expect(@fork_build_failed_todo).to be_pending
end
end
- context 'closed fork merge request' do
+ context "closed fork merge request" do
before do
@fork_merge_request.close!
allow(refresh_service).to receive(:execute_hooks)
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
reload_mrs
end
- it 'do not execute hooks with update action' do
+ it "do not execute hooks with update action" do
expect(refresh_service).not_to have_received(:execute_hooks)
end
- it 'updates merge request to closed state' do
+ it "updates merge request to closed state" do
expect(@merge_request.notes).to be_empty
expect(@merge_request).to be_open
expect(@fork_merge_request.notes).to be_empty
@@ -372,14 +372,14 @@ describe MergeRequests::RefreshService do
end
end
- context 'push to fork repo target branch' do
- describe 'changes to merge requests' do
+ context "push to fork repo target branch" do
+ describe "changes to merge requests" do
before do
- service.new(@fork_project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
+ service.new(@fork_project, @user).execute(@oldrev, @newrev, "refs/heads/feature")
reload_mrs
end
- it 'updates the merge request state' do
+ it "updates the merge request state" do
expect(@merge_request.notes).to be_empty
expect(@merge_request).to be_open
expect(@fork_merge_request.notes).to be_empty
@@ -389,84 +389,84 @@ describe MergeRequests::RefreshService do
end
end
- describe 'merge request diff' do
- it 'does not reload the diff of the merge request made from fork' do
- expect do
- service.new(@fork_project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
- end.not_to change { @fork_merge_request.reload.merge_request_diff }
+ describe "merge request diff" do
+ it "does not reload the diff of the merge request made from fork" do
+ expect {
+ service.new(@fork_project, @user).execute(@oldrev, @newrev, "refs/heads/feature")
+ }.not_to change { @fork_merge_request.reload.merge_request_diff }
end
end
end
- context 'forked projects with the same source branch name as target branch' do
+ context "forked projects with the same source branch name as target branch" do
let!(:first_commit) do
- @fork_project.repository.create_file(@user, 'test1.txt', 'Test data',
- message: 'Test commit',
- branch_name: 'master')
+ @fork_project.repository.create_file(@user, "test1.txt", "Test data",
+ message: "Test commit",
+ branch_name: "master")
end
let!(:second_commit) do
- @fork_project.repository.create_file(@user, 'test2.txt', 'More test data',
- message: 'Second test commit',
- branch_name: 'master')
+ @fork_project.repository.create_file(@user, "test2.txt", "More test data",
+ message: "Second test commit",
+ branch_name: "master")
end
let!(:forked_master_mr) do
create(:merge_request,
- source_project: @fork_project,
- source_branch: 'master',
- target_branch: 'master',
- target_project: @project)
+ source_project: @fork_project,
+ source_branch: "master",
+ target_branch: "master",
+ target_project: @project)
end
- let(:force_push_commit) { @project.commit('feature').id }
+ let(:force_push_commit) { @project.commit("feature").id }
- it 'should reload a new diff for a push to the forked project' do
- expect do
- service.new(@fork_project, @user).execute(@oldrev, first_commit, 'refs/heads/master')
+ it "should reload a new diff for a push to the forked project" do
+ expect {
+ service.new(@fork_project, @user).execute(@oldrev, first_commit, "refs/heads/master")
reload_mrs
- end.to change { forked_master_mr.merge_request_diffs.count }.by(1)
+ }.to change { forked_master_mr.merge_request_diffs.count }.by(1)
end
- it 'should reload a new diff for a force push to the source branch' do
- expect do
- service.new(@fork_project, @user).execute(@oldrev, force_push_commit, 'refs/heads/master')
+ it "should reload a new diff for a force push to the source branch" do
+ expect {
+ service.new(@fork_project, @user).execute(@oldrev, force_push_commit, "refs/heads/master")
reload_mrs
- end.to change { forked_master_mr.merge_request_diffs.count }.by(1)
+ }.to change { forked_master_mr.merge_request_diffs.count }.by(1)
end
- it 'should reload a new diff for a force push to the target branch' do
- expect do
- service.new(@project, @user).execute(@oldrev, force_push_commit, 'refs/heads/master')
+ it "should reload a new diff for a force push to the target branch" do
+ expect {
+ service.new(@project, @user).execute(@oldrev, force_push_commit, "refs/heads/master")
reload_mrs
- end.to change { forked_master_mr.merge_request_diffs.count }.by(1)
+ }.to change { forked_master_mr.merge_request_diffs.count }.by(1)
end
- it 'should reload a new diff for a push to the target project that contains a commit in the MR' do
- expect do
- service.new(@project, @user).execute(@oldrev, first_commit, 'refs/heads/master')
+ it "should reload a new diff for a push to the target project that contains a commit in the MR" do
+ expect {
+ service.new(@project, @user).execute(@oldrev, first_commit, "refs/heads/master")
reload_mrs
- end.to change { forked_master_mr.merge_request_diffs.count }.by(1)
+ }.to change { forked_master_mr.merge_request_diffs.count }.by(1)
end
- it 'should not increase the diff count for a new push to target branch' do
- new_commit = @project.repository.create_file(@user, 'new-file.txt', 'A new file',
- message: 'This is a test',
- branch_name: 'master')
+ it "should not increase the diff count for a new push to target branch" do
+ new_commit = @project.repository.create_file(@user, "new-file.txt", "A new file",
+ message: "This is a test",
+ branch_name: "master")
- expect do
- service.new(@project, @user).execute(@newrev, new_commit, 'refs/heads/master')
+ expect {
+ service.new(@project, @user).execute(@newrev, new_commit, "refs/heads/master")
reload_mrs
- end.not_to change { forked_master_mr.merge_request_diffs.count }
+ }.not_to change { forked_master_mr.merge_request_diffs.count }
end
end
- context 'push to origin repo target branch after fork project was removed' do
+ context "push to origin repo target branch after fork project was removed" do
before do
@fork_project.destroy
- service.new(@project, @user).execute(@oldrev, @newrev, 'refs/heads/feature')
+ service.new(@project, @user).execute(@oldrev, @newrev, "refs/heads/feature")
reload_mrs
end
- it 'updates the merge request state' do
- expect(@merge_request.notes.last.note).to include('merged')
+ it "updates the merge request state" do
+ expect(@merge_request.notes.last.note).to include("merged")
expect(@merge_request).to be_merged
expect(@fork_merge_request).to be_open
expect(@fork_merge_request.notes).to be_empty
@@ -475,28 +475,28 @@ describe MergeRequests::RefreshService do
end
end
- context 'push new branch that exists in a merge request' do
+ context "push new branch that exists in a merge request" do
let(:refresh_service) { service.new(@fork_project, @user) }
- it 'refreshes the merge request' do
+ it "refreshes the merge request" do
expect(refresh_service).to receive(:execute_hooks)
- .with(@fork_merge_request, 'update', old_rev: Gitlab::Git::BLANK_SHA)
+ .with(@fork_merge_request, "update", old_rev: Gitlab::Git::BLANK_SHA)
allow_any_instance_of(Repository).to receive(:merge_base).and_return(@oldrev)
- refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, 'refs/heads/master')
+ refresh_service.execute(Gitlab::Git::BLANK_SHA, @newrev, "refs/heads/master")
reload_mrs
expect(@merge_request.notes).to be_empty
expect(@merge_request).to be_open
notes = @fork_merge_request.notes.reorder(:created_at).map(&:note)
- expect(notes[0]).to include('restored source branch `master`')
- expect(notes[1]).to include('added 28 commits')
+ expect(notes[0]).to include("restored source branch `master`")
+ expect(notes[1]).to include("added 28 commits")
expect(@fork_merge_request).to be_open
end
end
- context 'merge request metrics' do
+ context "merge request metrics" do
let(:issue) { create :issue, project: @project }
let(:commit_author) { create :user }
let(:commit) { project.commit }
@@ -513,33 +513,33 @@ describe MergeRequests::RefreshService do
committed_date: Time.now
)
- allow_any_instance_of(MergeRequest).to receive(:commits).and_return(CommitCollection.new(@project, [commit], 'feature'))
+ allow_any_instance_of(MergeRequest).to receive(:commits).and_return(CommitCollection.new(@project, [commit], "feature"))
end
- context 'when the merge request is sourced from the same project' do
- it 'creates a `MergeRequestsClosingIssues` record for each issue closed by a commit' do
- merge_request = create(:merge_request, target_branch: 'master', source_branch: 'feature', source_project: @project)
+ context "when the merge request is sourced from the same project" do
+ it "creates a `MergeRequestsClosingIssues` record for each issue closed by a commit" do
+ merge_request = create(:merge_request, target_branch: "master", source_branch: "feature", source_project: @project)
refresh_service = service.new(@project, @user)
allow(refresh_service).to receive(:execute_hooks)
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/feature')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/feature")
issue_ids = MergeRequestsClosingIssues.where(merge_request: merge_request).pluck(:issue_id)
expect(issue_ids).to eq([issue.id])
end
end
- context 'when the merge request is sourced from a different project' do
- it 'creates a `MergeRequestsClosingIssues` record for each issue closed by a commit' do
+ context "when the merge request is sourced from a different project" do
+ it "creates a `MergeRequestsClosingIssues` record for each issue closed by a commit" do
forked_project = fork_project(@project, @user, repository: true)
merge_request = create(:merge_request,
- target_branch: 'master',
- source_branch: 'feature',
- target_project: @project,
- source_project: forked_project)
+ target_branch: "master",
+ source_branch: "feature",
+ target_project: @project,
+ source_project: forked_project)
refresh_service = service.new(@project, @user)
allow(refresh_service).to receive(:execute_hooks)
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/feature')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/feature")
issue_ids = MergeRequestsClosingIssues.where(merge_request: merge_request).pluck(:issue_id)
expect(issue_ids).to eq([issue.id])
@@ -547,23 +547,23 @@ describe MergeRequests::RefreshService do
end
end
- context 'marking the merge request as work in progress' do
+ context "marking the merge request as work in progress" do
let(:refresh_service) { service.new(@project, @user) }
before do
allow(refresh_service).to receive(:execute_hooks)
end
- it 'marks the merge request as work in progress from fixup commits' do
+ it "marks the merge request as work in progress from fixup commits" do
fixup_merge_request = create(:merge_request,
- source_project: @project,
- source_branch: 'wip',
- target_branch: 'master',
- target_project: @project)
+ source_project: @project,
+ source_branch: "wip",
+ target_branch: "master",
+ target_project: @project)
commits = fixup_merge_request.commits
oldrev = commits.last.id
newrev = commits.first.id
- refresh_service.execute(oldrev, newrev, 'refs/heads/wip')
+ refresh_service.execute(oldrev, newrev, "refs/heads/wip")
fixup_merge_request.reload
expect(fixup_merge_request.work_in_progress?).to eq(true)
@@ -572,46 +572,46 @@ describe MergeRequests::RefreshService do
)
end
- it 'references the commit that caused the Work in Progress status' do
+ it "references the commit that caused the Work in Progress status" do
wip_merge_request = create(:merge_request,
- source_project: @project,
- source_branch: 'wip',
- target_branch: 'master',
- target_project: @project)
+ source_project: @project,
+ source_branch: "wip",
+ target_branch: "master",
+ target_project: @project)
commits = wip_merge_request.commits
oldrev = commits.last.id
newrev = commits.first.id
wip_commit = wip_merge_request.commits.find(&:work_in_progress?)
- refresh_service.execute(oldrev, newrev, 'refs/heads/wip')
+ refresh_service.execute(oldrev, newrev, "refs/heads/wip")
expect(wip_merge_request.reload.notes.last.note).to eq(
"marked as a **Work In Progress** from #{wip_commit.id}"
)
end
- it 'does not mark as WIP based on commits that do not belong to an MR' do
+ it "does not mark as WIP based on commits that do not belong to an MR" do
allow(refresh_service).to receive(:find_new_commits)
refresh_service.instance_variable_set("@commits", [
double(
- id: 'aaaaaaa',
- sha: 'aaaaaaa',
- short_id: 'aaaaaaa',
- title: 'Fix issue',
+ id: "aaaaaaa",
+ sha: "aaaaaaa",
+ short_id: "aaaaaaa",
+ title: "Fix issue",
work_in_progress?: false
),
double(
- id: 'bbbbbbb',
- sha: 'bbbbbbbb',
- short_id: 'bbbbbbb',
- title: 'fixup! Fix issue',
+ id: "bbbbbbb",
+ sha: "bbbbbbbb",
+ short_id: "bbbbbbb",
+ title: "fixup! Fix issue",
work_in_progress?: true,
- to_reference: 'bbbbbbb'
- )
+ to_reference: "bbbbbbb"
+ ),
])
- refresh_service.execute(@oldrev, @newrev, 'refs/heads/master')
+ refresh_service.execute(@oldrev, @newrev, "refs/heads/master")
reload_mrs
expect(@merge_request.work_in_progress?).to be_falsey
@@ -626,20 +626,20 @@ describe MergeRequests::RefreshService do
end
end
- describe 'updating merge_commit' do
+ describe "updating merge_commit" do
let(:service) { described_class.new(project, user) }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:oldrev) { TestEnv::BRANCH_SHA['merge-commit-analyze-before'] }
- let(:newrev) { TestEnv::BRANCH_SHA['merge-commit-analyze-after'] } # Pretend branch is now updated
+ let(:oldrev) { TestEnv::BRANCH_SHA["merge-commit-analyze-before"] }
+ let(:newrev) { TestEnv::BRANCH_SHA["merge-commit-analyze-after"] } # Pretend branch is now updated
let!(:merge_request) do
create(
:merge_request,
source_project: project,
- source_branch: 'merge-commit-analyze-after',
- target_branch: 'merge-commit-analyze-before',
+ source_branch: "merge-commit-analyze-after",
+ target_branch: "merge-commit-analyze-before",
target_project: project,
merge_user: user
)
@@ -649,23 +649,23 @@ describe MergeRequests::RefreshService do
create(
:merge_request,
source_project: project,
- source_branch: 'merge-commit-analyze-side-branch',
- target_branch: 'merge-commit-analyze-before',
+ source_branch: "merge-commit-analyze-side-branch",
+ target_branch: "merge-commit-analyze-before",
target_project: project,
merge_user: user
)
end
- subject { service.execute(oldrev, newrev, 'refs/heads/merge-commit-analyze-before') }
+ subject { service.execute(oldrev, newrev, "refs/heads/merge-commit-analyze-before") }
- context 'feature enabled' do
+ context "feature enabled" do
before do
stub_feature_flags(branch_push_merge_commit_analyze: true)
end
it "updates merge requests' merge_commits" do
expect(Gitlab::BranchPushMergeCommitAnalyzer).to receive(:new).and_wrap_original do |original_method, commits|
- expect(commits.map(&:id)).to eq(%w{646ece5cfed840eca0a4feb21bcd6a81bb19bda3 29284d9bcc350bcae005872d0be6edd016e2efb5 5f82584f0a907f3b30cfce5bb8df371454a90051 8a994512e8c8f0dfcf22bb16df6e876be7a61036 689600b91aabec706e657e38ea706ece1ee8268f db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9})
+ expect(commits.map(&:id)).to eq(%w[646ece5cfed840eca0a4feb21bcd6a81bb19bda3 29284d9bcc350bcae005872d0be6edd016e2efb5 5f82584f0a907f3b30cfce5bb8df371454a90051 8a994512e8c8f0dfcf22bb16df6e876be7a61036 689600b91aabec706e657e38ea706ece1ee8268f db46a1c5a5e474aa169b6cdb7a522d891bc4c5f9])
original_method.call(commits)
end
@@ -675,12 +675,12 @@ describe MergeRequests::RefreshService do
merge_request.reload
merge_request_side_branch.reload
- expect(merge_request.merge_commit.id).to eq('646ece5cfed840eca0a4feb21bcd6a81bb19bda3')
- expect(merge_request_side_branch.merge_commit.id).to eq('29284d9bcc350bcae005872d0be6edd016e2efb5')
+ expect(merge_request.merge_commit.id).to eq("646ece5cfed840eca0a4feb21bcd6a81bb19bda3")
+ expect(merge_request_side_branch.merge_commit.id).to eq("29284d9bcc350bcae005872d0be6edd016e2efb5")
end
end
- context 'when feature is disabled' do
+ context "when feature is disabled" do
before do
stub_feature_flags(branch_push_merge_commit_analyze: false)
end
diff --git a/spec/services/merge_requests/reload_diffs_service_spec.rb b/spec/services/merge_requests/reload_diffs_service_spec.rb
index 5acd01828cb..abd88959a67 100644
--- a/spec/services/merge_requests/reload_diffs_service_spec.rb
+++ b/spec/services/merge_requests/reload_diffs_service_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::ReloadDiffsService, :use_clean_rails_memory_store_caching do
let(:current_user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:subject) { described_class.new(merge_request, current_user) }
- describe '#execute' do
- it 'creates new merge request diff' do
+ describe "#execute" do
+ it "creates new merge request diff" do
expect { subject.execute }.to change { merge_request.merge_request_diffs.count }.by(1)
end
- it 'calls update_diff_discussion_positions with correct params' do
+ it "calls update_diff_discussion_positions with correct params" do
old_diff_refs = merge_request.diff_refs
new_diff = merge_request.create_merge_request_diff
new_diff_refs = merge_request.diff_refs
@@ -24,14 +24,14 @@ describe MergeRequests::ReloadDiffsService, :use_clean_rails_memory_store_cachin
subject.execute
end
- it 'does not change existing merge request diff' do
+ it "does not change existing merge request diff" do
expect(merge_request.merge_request_diff).not_to receive(:save_git_content)
subject.execute
end
- context 'cache clearing' do
- it 'clears the cache for older diffs on the merge request' do
+ context "cache clearing" do
+ it "clears the cache for older diffs on the merge request" do
old_diff = merge_request.merge_request_diff
old_cache_key = old_diff.diffs_collection.cache_key
@@ -40,13 +40,13 @@ describe MergeRequests::ReloadDiffsService, :use_clean_rails_memory_store_cachin
subject.execute
end
- it 'avoids N+1 queries', :request_store do
+ it "avoids N+1 queries", :request_store do
current_user
merge_request
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
subject.execute
- end.count
+ }.count
expect { subject.execute }.not_to exceed_query_limit(control_count)
end
diff --git a/spec/services/merge_requests/reopen_service_spec.rb b/spec/services/merge_requests/reopen_service_spec.rb
index 21e71509ed6..c1049a7cdb1 100644
--- a/spec/services/merge_requests/reopen_service_spec.rb
+++ b/spec/services/merge_requests/reopen_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::ReopenService do
let(:user) { create(:user) }
@@ -13,10 +13,10 @@ describe MergeRequests::ReopenService do
project.add_guest(guest)
end
- describe '#execute' do
- it_behaves_like 'cache counters invalidator'
+ describe "#execute" do
+ it_behaves_like "cache counters invalidator"
- context 'valid params' do
+ context "valid params" do
let(:service) { described_class.new(project, user, {}) }
before do
@@ -30,30 +30,30 @@ describe MergeRequests::ReopenService do
it { expect(merge_request).to be_valid }
it { expect(merge_request).to be_opened }
- it 'executes hooks with reopen action' do
+ it "executes hooks with reopen action" do
expect(service).to have_received(:execute_hooks)
- .with(merge_request, 'reopen')
+ .with(merge_request, "reopen")
end
- it 'sends 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 'creates 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 'reopened'
+ expect(note.note).to include "reopened"
end
end
- it 'caches merge request closing issues' do
+ it "caches merge request closing issues" do
expect(merge_request).to receive(:cache_merge_request_closes_issues!)
described_class.new(project, user, {}).execute(merge_request)
end
- it 'updates metrics' do
+ it "updates metrics" do
metrics = merge_request.metrics
service = double(MergeRequestMetricsService)
allow(MergeRequestMetricsService)
@@ -66,21 +66,21 @@ describe MergeRequests::ReopenService do
described_class.new(project, user, {}).execute(merge_request)
end
- it 'refreshes the number of open merge requests for a valid MR' do
+ it "refreshes the number of open merge requests for a valid MR" do
service = described_class.new(project, user, {})
expect { service.execute(merge_request) }
.to change { project.open_merge_requests_count }.from(0).to(1)
end
- context 'current user is not authorized to reopen merge request' do
+ context "current user is not authorized to reopen merge request" do
before do
perform_enqueued_jobs do
@merge_request = described_class.new(project, guest).execute(merge_request)
end
end
- it 'does not reopen the merge request' do
+ it "does not reopen the merge request" do
expect(@merge_request).to be_closed
end
end
diff --git a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb
index e3fd906fe7b..6b1bce94cd6 100644
--- a/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb
+++ b/spec/services/merge_requests/resolved_discussion_notification_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::ResolvedDiscussionNotificationService do
let(:merge_request) { create(:merge_request) }
diff --git a/spec/services/merge_requests/squash_service_spec.rb b/spec/services/merge_requests/squash_service_spec.rb
index 2713652873e..960297638ce 100644
--- a/spec/services/merge_requests/squash_service_spec.rb
+++ b/spec/services/merge_requests/squash_service_spec.rb
@@ -1,87 +1,87 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::SquashService do
include GitHelpers
- let(:service) { described_class.new(project, user, { merge_request: merge_request }) }
+ let(:service) { described_class.new(project, user, {merge_request: merge_request}) }
let(:user) { project.owner }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository.raw }
let(:log_error) { "Failed to squash merge request #{merge_request.to_reference(full: true)}:" }
let(:squash_dir_path) do
- File.join(Gitlab.config.shared.path, 'tmp/squash', repository.gl_repository, merge_request.id.to_s)
+ File.join(Gitlab.config.shared.path, "tmp/squash", repository.gl_repository, merge_request.id.to_s)
end
let(:merge_request_with_one_commit) do
create(:merge_request,
- source_branch: 'feature', source_project: project,
- target_branch: 'master', target_project: project)
+ source_branch: "feature", source_project: project,
+ target_branch: "master", target_project: project)
end
let(:merge_request_with_only_new_files) do
create(:merge_request,
- source_branch: 'video', source_project: project,
- target_branch: 'master', target_project: project)
+ source_branch: "video", source_project: project,
+ target_branch: "master", target_project: project)
end
let(:merge_request_with_large_files) do
create(:merge_request,
- source_branch: 'squash-large-files', source_project: project,
- target_branch: 'master', target_project: project)
+ source_branch: "squash-large-files", source_project: project,
+ target_branch: "master", target_project: project)
end
- shared_examples 'the squash succeeds' do
- it 'returns the squashed commit SHA' do
+ shared_examples "the squash succeeds" do
+ it "returns the squashed commit SHA" do
result = service.execute
expect(result).to match(status: :success, squash_sha: a_string_matching(/\h{40}/))
expect(result[:squash_sha]).not_to eq(merge_request.diff_head_sha)
end
- it 'cleans up the temporary directory' do
+ it "cleans up the temporary directory" do
service.execute
expect(File.exist?(squash_dir_path)).to be(false)
end
- it 'does not keep the branch push event' do
+ it "does not keep the branch push event" do
expect { service.execute }.not_to change { Event.count }
end
- context 'when there is a single commit in the merge request' do
+ context "when there is a single commit in the merge request" do
before do
expect(merge_request).to receive(:commits_count).at_least(:once).and_return(1)
end
- it 'will skip performing the squash, as the outcome would be the same' do
+ it "will skip performing the squash, as the outcome would be the same" do
expect(merge_request.target_project.repository).not_to receive(:squash)
service.execute
end
- it 'will still perform the squash when a custom squash commit message has been provided' do
- service = described_class.new(project, user, { merge_request: merge_request, squash_commit_message: 'A custom commit message' })
+ it "will still perform the squash when a custom squash commit message has been provided" do
+ service = described_class.new(project, user, {merge_request: merge_request, squash_commit_message: "A custom commit message"})
- expect(merge_request.target_project.repository).to receive(:squash).and_return('sha')
+ expect(merge_request.target_project.repository).to receive(:squash).and_return("sha")
service.execute
end
end
- context 'the squashed commit' do
+ context "the squashed commit" do
let(:squash_sha) { service.execute[:squash_sha] }
let(:squash_commit) { project.repository.commit(squash_sha) }
- it 'copies the author info from the merge request' do
+ it "copies the author info from the merge request" do
expect(squash_commit.author_name).to eq(merge_request.author.name)
expect(squash_commit.author_email).to eq(merge_request.author.email)
end
- it 'sets the current user as the committer' do
- expect(squash_commit.committer_name).to eq(user.name.chomp('.'))
+ it "sets the current user as the committer" do
+ expect(squash_commit.committer_name).to eq(user.name.chomp("."))
expect(squash_commit.committer_email).to eq(user.email)
end
- it 'has the same diff as the merge request, but a different SHA' do
+ it "has the same diff as the merge request, but a different SHA" do
rugged = rugged_repo(project.repository)
mr_diff = rugged.diff(merge_request.diff_base_sha, merge_request.diff_head_sha)
squash_diff = rugged.diff(merge_request.diff_start_sha, squash_sha)
@@ -90,94 +90,94 @@ describe MergeRequests::SquashService do
expect(squash_commit.sha).not_to eq(merge_request.diff_head_sha)
end
- it 'has a default squash commit message if no message was provided' do
+ it "has a default squash commit message if no message was provided" do
expect(squash_commit.message.chomp).to eq(merge_request.default_squash_commit_message.chomp)
end
- context 'if a message was provided' do
- let(:service) { described_class.new(project, user, { merge_request: merge_request, squash_commit_message: message }) }
- let(:message) { 'My custom message' }
+ context "if a message was provided" do
+ let(:service) { described_class.new(project, user, {merge_request: merge_request, squash_commit_message: message}) }
+ let(:message) { "My custom message" }
let(:squash_sha) { service.execute[:squash_sha] }
- it 'has the same message as the message provided' do
+ it "has the same message as the message provided" do
expect(squash_commit.message.chomp).to eq(message)
end
end
end
end
- describe '#execute' do
- context 'when there is only one commit in the merge request' do
+ describe "#execute" do
+ context "when there is only one commit in the merge request" do
let(:merge_request) { merge_request_with_one_commit }
- it 'returns that commit SHA' do
+ it "returns that commit SHA" do
result = service.execute
expect(result).to match(status: :success, squash_sha: merge_request.diff_head_sha)
end
- it 'does not perform any git actions' do
+ it "does not perform any git actions" do
expect(repository).not_to receive(:popen)
service.execute
end
end
- context 'when squashing only new files' do
+ context "when squashing only new files" do
let(:merge_request) { merge_request_with_only_new_files }
- include_examples 'the squash succeeds'
+ include_examples "the squash succeeds"
end
- context 'when squashing with files too large to display' do
+ context "when squashing with files too large to display" do
let(:merge_request) { merge_request_with_large_files }
- include_examples 'the squash succeeds'
+ include_examples "the squash succeeds"
end
- context 'git errors' do
+ context "git errors" do
let(:merge_request) { merge_request_with_only_new_files }
- let(:error) { 'A test error' }
+ let(:error) { "A test error" }
- context 'with gitaly enabled' do
+ context "with gitaly enabled" do
before do
allow(repository.gitaly_operation_client).to receive(:user_squash)
.and_raise(Gitlab::Git::Repository::GitError, error)
end
- it 'logs the stage and output' do
+ it "logs the stage and output" do
expect(service).to receive(:log_error).with(log_error)
expect(service).to receive(:log_error).with(error)
service.execute
end
- it 'returns an error' do
- expect(service.execute).to match(status: :error, message: a_string_including('squash'))
+ it "returns an error" do
+ expect(service.execute).to match(status: :error, message: a_string_including("squash"))
end
end
end
- context 'when any other exception is thrown' do
+ context "when any other exception is thrown" do
let(:merge_request) { merge_request_with_only_new_files }
- let(:error) { 'A test error' }
+ let(:error) { "A test error" }
before do
allow(merge_request.target_project.repository).to receive(:squash).and_raise(error)
end
- it 'logs the MR reference and exception' do
+ it "logs the MR reference and exception" do
expect(service).to receive(:log_error).with(a_string_including("#{project.full_path}#{merge_request.to_reference}"))
expect(service).to receive(:log_error).with(error)
service.execute
end
- it 'returns an error' do
- expect(service.execute).to match(status: :error, message: a_string_including('squash'))
+ it "returns an error" do
+ expect(service.execute).to match(status: :error, message: a_string_including("squash"))
end
- it 'cleans up the temporary directory' do
+ it "cleans up the temporary directory" do
service.execute
expect(File.exist?(squash_dir_path)).to be(false)
diff --git a/spec/services/merge_requests/update_service_spec.rb b/spec/services/merge_requests/update_service_spec.rb
index 20580bf14b9..1dc3295456c 100644
--- a/spec/services/merge_requests/update_service_spec.rb
+++ b/spec/services/merge_requests/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeRequests::UpdateService, :mailer do
include ProjectForksHelper
@@ -11,7 +11,7 @@ describe MergeRequests::UpdateService, :mailer do
let(:label2) { create(:label) }
let(:merge_request) do
- create(:merge_request, :simple, title: 'Old title',
+ create(:merge_request, :simple, title: "Old title",
description: "FYI #{user2.to_reference}",
assignee_id: user3.id,
source_project: project,
@@ -24,10 +24,10 @@ describe MergeRequests::UpdateService, :mailer do
project.add_developer(user3)
end
- describe 'execute' do
+ describe "execute" do
def find_note(starting_with)
@merge_request.notes.find do |note|
- note && note.note.start_with?(starting_with)
+ note&.note&.start_with?(starting_with)
end
end
@@ -35,7 +35,7 @@ describe MergeRequests::UpdateService, :mailer do
@merge_request
.notes
.joins(:system_note_metadata)
- .where(system_note_metadata: { action: action })
+ .where(system_note_metadata: {action: action})
end
def update_merge_request(opts)
@@ -43,17 +43,17 @@ describe MergeRequests::UpdateService, :mailer do
@merge_request.reload
end
- context 'valid params' do
+ context "valid params" do
let(:opts) do
{
- title: 'New title',
- description: 'Also please fix',
+ title: "New title",
+ description: "Also please fix",
assignee_id: user2.id,
- state_event: 'close',
+ state_event: "close",
label_ids: [label.id],
- target_branch: 'target',
- force_remove_source_branch: '1',
- discussion_locked: true
+ target_branch: "target",
+ force_remove_source_branch: "1",
+ discussion_locked: true,
}
end
@@ -68,33 +68,33 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it 'matches base expectations' do
+ it "matches base expectations" do
expect(@merge_request).to be_valid
- expect(@merge_request.title).to eq('New title')
+ expect(@merge_request.title).to eq("New title")
expect(@merge_request.assignee).to eq(user2)
expect(@merge_request).to be_closed
expect(@merge_request.labels.count).to eq(1)
expect(@merge_request.labels.first.title).to eq(label.name)
- expect(@merge_request.target_branch).to eq('target')
- expect(@merge_request.merge_params['force_remove_source_branch']).to eq('1')
+ expect(@merge_request.target_branch).to eq("target")
+ expect(@merge_request.merge_params["force_remove_source_branch"]).to eq("1")
expect(@merge_request.discussion_locked).to be_truthy
end
- it 'executes hooks with update action' do
+ it "executes hooks with update action" do
expect(service).to have_received(:execute_hooks)
.with(
@merge_request,
- 'update',
+ "update",
old_associations: {
labels: [],
mentioned_users: [user2],
assignees: [user3],
- total_time_spent: 0
+ total_time_spent: 0,
}
)
end
- it 'sends 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
@@ -102,14 +102,14 @@ describe MergeRequests::UpdateService, :mailer do
expect(email.subject).to include(merge_request.title)
end
- it 'creates system note about merge_request reassign' do
- note = find_note('assigned to')
+ it "creates system note about merge_request reassign" do
+ note = find_note("assigned to")
expect(note).not_to be_nil
expect(note.note).to include "assigned to #{user2.to_reference}"
end
- it 'creates a resource label event' do
+ it "creates a resource label event" do
event = merge_request.resource_label_events.last
expect(event).not_to be_nil
@@ -117,40 +117,40 @@ describe MergeRequests::UpdateService, :mailer do
expect(event.user_id).to eq user.id
end
- it 'creates system note about title change' do
- note = find_note('changed title')
+ it "creates system note about title change" do
+ note = find_note("changed title")
expect(note).not_to be_nil
- expect(note.note).to eq 'changed title from **{-Old-} title** to **{+New+} title**'
+ expect(note.note).to eq "changed title from **{-Old-} title** to **{+New+} title**"
end
- it 'creates system note about description change' do
- note = find_note('changed the description')
+ it "creates system note about description change" do
+ note = find_note("changed the description")
expect(note).not_to be_nil
- expect(note.note).to eq('changed the description')
+ expect(note.note).to eq("changed the description")
end
- it 'creates system note about branch change' do
- note = find_note('changed target')
+ it "creates system note about branch change" do
+ note = find_note("changed target")
expect(note).not_to be_nil
- expect(note.note).to eq 'changed target branch from `master` to `target`'
+ expect(note.note).to eq "changed target branch from `master` to `target`"
end
- it 'creates system note about discussion lock' do
- note = find_note('locked this merge request')
+ it "creates system note about discussion lock" do
+ note = find_note("locked this merge request")
expect(note).not_to be_nil
- expect(note.note).to eq 'locked this merge request'
+ expect(note.note).to eq "locked this merge request"
end
- context 'when not including source branch removal options' do
+ context "when not including source branch removal options" do
before do
opts.delete(:force_remove_source_branch)
end
- it 'maintains the original options' do
+ it "maintains the original options" do
update_merge_request(opts)
expect(@merge_request.merge_params["force_remove_source_branch"]).to eq("1")
@@ -158,18 +158,18 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'merge' do
+ context "merge" do
let(:opts) do
{
- merge: merge_request.diff_head_sha
+ merge: merge_request.diff_head_sha,
}
end
let(:service) { described_class.new(project, user, opts) }
- context 'without pipeline' do
+ context "without pipeline" do
before do
- merge_request.merge_error = 'Error'
+ merge_request.merge_error = "Error"
perform_enqueued_jobs do
service.execute(merge_request)
@@ -177,20 +177,20 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it 'merges the MR' do
+ it "merges the MR" do
expect(@merge_request).to be_valid
- expect(@merge_request.state).to eq('merged')
+ expect(@merge_request.state).to eq("merged")
expect(@merge_request.merge_error).to be_nil
end
end
- context 'with finished pipeline' do
+ context "with finished pipeline" do
before do
create(:ci_pipeline_with_one_job,
project: project,
- ref: merge_request.source_branch,
- sha: merge_request.diff_head_sha,
- status: :success)
+ ref: merge_request.source_branch,
+ sha: merge_request.diff_head_sha,
+ status: :success)
perform_enqueued_jobs do
@merge_request = service.execute(merge_request)
@@ -198,13 +198,13 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it 'merges the MR' do
+ it "merges the MR" do
expect(@merge_request).to be_valid
- expect(@merge_request.state).to eq('merged')
+ expect(@merge_request.state).to eq("merged")
end
end
- context 'with active pipeline' do
+ context "with active pipeline" do
before do
service_mock = double
create(
@@ -223,12 +223,12 @@ describe MergeRequests::UpdateService, :mailer do
it { service.execute(merge_request) }
end
- context 'with a non-authorised user' do
+ context "with a non-authorised user" do
let(:visitor) { create(:user) }
let(:service) { described_class.new(project, visitor, opts) }
before do
- merge_request.update_attribute(:merge_error, 'Error')
+ merge_request.update_attribute(:merge_error, "Error")
perform_enqueued_jobs do
@merge_request = service.execute(merge_request)
@@ -236,16 +236,16 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it 'does not merge the MR' do
- expect(@merge_request.state).to eq('opened')
+ it "does not merge the MR" do
+ expect(@merge_request.state).to eq("opened")
expect(@merge_request.merge_error).not_to be_nil
end
end
- context 'MR can not be merged when note sha != MR sha' do
+ context "MR can not be merged when note sha != MR sha" do
let(:opts) do
{
- merge: 'other_commit'
+ merge: "other_commit",
}
end
@@ -256,51 +256,51 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it { expect(@merge_request.state).to eq('opened') }
+ it { expect(@merge_request.state).to eq("opened") }
end
end
- context 'todos' do
+ context "todos" do
let!(:pending_todo) { create(:todo, :assigned, user: user, project: project, target: merge_request, author: user2) }
- context 'when the title change' do
+ context "when the title change" do
before do
- update_merge_request({ title: 'New title' })
+ update_merge_request({title: "New title"})
end
- it 'marks pending todos as done' do
+ it "marks pending todos as done" do
expect(pending_todo.reload).to be_done
end
- it 'does not create any new todos' do
+ it "does not create any new todos" do
expect(Todo.count).to eq(1)
end
end
- context 'when the description change' do
+ context "when the description change" do
before do
- update_merge_request({ description: "Also please fix #{user2.to_reference} #{user3.to_reference}" })
+ update_merge_request({description: "Also please fix #{user2.to_reference} #{user3.to_reference}"})
end
- it 'marks pending todos as done' do
+ it "marks pending todos as done" do
expect(pending_todo.reload).to be_done
end
- it 'creates only 1 new todo' do
+ it "creates only 1 new todo" do
expect(Todo.count).to eq(2)
end
end
- context 'when is reassigned' do
+ context "when is reassigned" do
before do
- update_merge_request({ assignee: user2 })
+ update_merge_request({assignee: user2})
end
- it 'marks previous assignee pending todos as done' do
+ it "marks previous assignee pending todos as done" do
expect(pending_todo.reload).to be_done
end
- it 'creates a pending todo for new assignee' do
+ it "creates a pending todo for new assignee" do
attributes = {
project: project,
author: user,
@@ -308,14 +308,14 @@ describe MergeRequests::UpdateService, :mailer do
target_id: merge_request.id,
target_type: merge_request.class.name,
action: Todo::ASSIGNED,
- state: :pending
+ state: :pending,
}
expect(Todo.where(attributes).count).to eq 1
end
end
- context 'when the milestone is removed' do
+ context "when the milestone is removed" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
@@ -325,9 +325,9 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it_behaves_like 'system notes for milestones'
+ it_behaves_like "system notes for milestones"
- it 'sends notifications for subscribers of changed milestone' do
+ it "sends notifications for subscribers of changed milestone" do
merge_request.milestone = create(:milestone)
merge_request.save
@@ -341,7 +341,7 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'when the milestone is changed' do
+ context "when the milestone is changed" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) do
@@ -351,15 +351,15 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- it 'marks pending todos as done' do
- update_merge_request({ milestone: create(:milestone) })
+ it "marks pending todos as done" do
+ update_merge_request({milestone: create(:milestone)})
expect(pending_todo.reload).to be_done
end
- it_behaves_like 'system notes for milestones'
+ it_behaves_like "system notes for milestones"
- it 'sends notifications for subscribers of changed milestone' do
+ it "sends notifications for subscribers of changed milestone" do
perform_enqueued_jobs do
update_merge_request(milestone: create(:milestone))
end
@@ -369,24 +369,24 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'when the labels change' do
+ context "when the labels change" do
before do
Timecop.freeze(1.minute.from_now) do
- update_merge_request({ label_ids: [label.id] })
+ update_merge_request({label_ids: [label.id]})
end
end
- it 'marks pending todos as done' do
+ it "marks pending todos as done" do
expect(pending_todo.reload).to be_done
end
- it 'updates updated_at' do
+ it "updates updated_at" do
expect(merge_request.reload.updated_at).to be > Time.now
end
end
- context 'when the assignee changes' do
- it 'updates open merge request counter for assignees when merge request is reassigned' do
+ context "when the assignee changes" do
+ it "updates open merge request counter for assignees when merge request is reassigned" do
update_merge_request(assignee_id: user2.id)
expect(user3.assigned_open_merge_requests_count).to eq 0
@@ -394,18 +394,18 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'when the target branch change' do
+ context "when the target branch change" do
before do
- update_merge_request({ target_branch: 'target' })
+ update_merge_request({target_branch: "target"})
end
- it 'marks pending todos as done' do
+ it "marks pending todos as done" do
expect(pending_todo.reload).to be_done
end
end
end
- context 'when the issue is relabeled' do
+ context "when the issue is relabeled" do
let!(:non_subscriber) { create(:user) }
let!(:subscriber) { create(:user) { |u| label.toggle_subscription(u, project) } }
@@ -414,8 +414,8 @@ describe MergeRequests::UpdateService, :mailer do
project.add_developer(subscriber)
end
- it 'sends notifications for subscribers of newly added labels' do
- opts = { label_ids: [label.id] }
+ it "sends notifications for subscribers of newly added labels" do
+ opts = {label_ids: [label.id]}
perform_enqueued_jobs do
@merge_request = described_class.new(project, user, opts).execute(merge_request)
@@ -425,13 +425,13 @@ describe MergeRequests::UpdateService, :mailer do
should_not_email(non_subscriber)
end
- context 'when issue has the `label` label' do
+ context "when issue has the `label` label" do
before do
merge_request.labels << label
end
- it 'does not send notifications for existing labels' do
- opts = { label_ids: [label.id, label2.id] }
+ it "does not send notifications for existing labels" do
+ opts = {label_ids: [label.id, label2.id]}
perform_enqueued_jobs do
@merge_request = described_class.new(project, user, opts).execute(merge_request)
@@ -441,8 +441,8 @@ describe MergeRequests::UpdateService, :mailer do
should_not_email(non_subscriber)
end
- it 'does not send notifications for removed labels' do
- opts = { label_ids: [label2.id] }
+ it "does not send notifications for removed labels" do
+ opts = {label_ids: [label2.id]}
perform_enqueued_jobs do
@merge_request = described_class.new(project, user, opts).execute(merge_request)
@@ -454,62 +454,62 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'updating mentions' do
+ context "updating mentions" do
let(:mentionable) { merge_request }
- include_examples 'updating mentions', described_class
+ include_examples "updating mentions", described_class
end
- context 'when MergeRequest has tasks' do
+ context "when MergeRequest has tasks" do
before do
- update_merge_request({ description: "- [ ] Task 1\n- [ ] Task 2" })
+ update_merge_request({description: "- [ ] Task 1\n- [ ] Task 2"})
end
it { expect(@merge_request.tasks?).to eq(true) }
- it_behaves_like 'updating a single task'
+ it_behaves_like "updating a single task"
- context 'when tasks are marked as completed' do
+ context "when tasks are marked as completed" do
before do
- update_merge_request({ description: "- [x] Task 1\n- [X] Task 2" })
+ update_merge_request({description: "- [x] Task 1\n- [X] Task 2"})
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 1** as completed')
- note2 = find_note('marked the task **Task 2** as completed')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 1** as completed")
+ note2 = find_note("marked the task **Task 2** as completed")
expect(note1).not_to be_nil
expect(note2).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
- context 'when tasks are marked as incomplete' do
+ context "when tasks are marked as incomplete" do
before do
- update_merge_request({ description: "- [x] Task 1\n- [X] Task 2" })
- update_merge_request({ description: "- [ ] Task 1\n- [ ] Task 2" })
+ update_merge_request({description: "- [x] Task 1\n- [X] Task 2"})
+ update_merge_request({description: "- [ ] Task 1\n- [ ] Task 2"})
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 1** as incomplete')
- note2 = find_note('marked the task **Task 2** as incomplete')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 1** as incomplete")
+ note2 = find_note("marked the task **Task 2** as incomplete")
expect(note1).not_to be_nil
expect(note2).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
end
- context 'while saving references to issues that the updated merge request closes' do
+ context "while saving references to issues that the updated merge request closes" do
let(:first_issue) { create(:issue, project: project) }
let(:second_issue) { create(:issue, project: project) }
- it 'creates a `MergeRequestsClosingIssues` record for each issue' do
- issue_closing_opts = { description: "Closes #{first_issue.to_reference} and #{second_issue.to_reference}" }
+ it "creates a `MergeRequestsClosingIssues` record for each issue" do
+ issue_closing_opts = {description: "Closes #{first_issue.to_reference} and #{second_issue.to_reference}"}
service = described_class.new(project, user, issue_closing_opts)
allow(service).to receive(:execute_hooks)
service.execute(merge_request)
@@ -518,13 +518,13 @@ describe MergeRequests::UpdateService, :mailer do
expect(issue_ids).to match_array([first_issue.id, second_issue.id])
end
- it 'removes `MergeRequestsClosingIssues` records when issues are not closed anymore' do
+ it "removes `MergeRequestsClosingIssues` records when issues are not closed anymore" do
opts = {
- title: 'Awesome merge_request',
+ title: "Awesome merge_request",
description: "Closes #{first_issue.to_reference} and #{second_issue.to_reference}",
- source_branch: 'feature',
- target_branch: 'master',
- force_remove_source_branch: '1'
+ source_branch: "feature",
+ target_branch: "master",
+ force_remove_source_branch: "1",
}
merge_request = MergeRequests::CreateService.new(project, user, opts).execute
@@ -541,8 +541,8 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- context 'updating asssignee_id' do
- it 'does not update assignee when assignee_id is invalid' do
+ context "updating asssignee_id" do
+ it "does not update assignee when assignee_id is invalid" do
merge_request.update(assignee_id: user.id)
update_merge_request(assignee_id: -1)
@@ -550,7 +550,7 @@ describe MergeRequests::UpdateService, :mailer do
expect(merge_request.reload.assignee).to eq(user)
end
- it 'unassigns assignee when user id is 0' do
+ it "unassigns assignee when user id is 0" do
merge_request.update(assignee_id: user.id)
update_merge_request(assignee_id: 0)
@@ -558,13 +558,13 @@ describe MergeRequests::UpdateService, :mailer do
expect(merge_request.assignee_id).to be_nil
end
- it 'saves assignee when user id is valid' do
+ it "saves assignee when user id is valid" do
update_merge_request(assignee_id: user.id)
expect(merge_request.assignee_id).to eq(user.id)
end
- it 'does not update assignee_id when user cannot read issue' do
+ it "does not update assignee_id when user cannot read issue" do
non_member = create(:user)
original_assignee = merge_request.assignee
@@ -589,42 +589,42 @@ describe MergeRequests::UpdateService, :mailer do
end
end
- include_examples 'issuable update service' do
+ include_examples "issuable update service" do
let(:open_issuable) { merge_request }
let(:closed_issuable) { create(:closed_merge_request, source_project: project) }
end
- context 'setting `allow_collaboration`' do
+ context "setting `allow_collaboration`" do
let(:target_project) { create(:project, :repository, :public) }
let(:source_project) { fork_project(target_project, nil, repository: true) }
let(:user) { create(:user) }
let(:merge_request) do
create(:merge_request,
- source_project: source_project,
- source_branch: 'fixes',
- target_project: target_project)
+ source_project: source_project,
+ source_branch: "fixes",
+ target_project: target_project)
end
before do
- allow(ProtectedBranch).to receive(:protected?).with(source_project, 'fixes') { false }
+ allow(ProtectedBranch).to receive(:protected?).with(source_project, "fixes") { false }
end
- it 'does not allow a maintainer of the target project to set `allow_collaboration`' do
+ it "does not allow a maintainer of the target project to set `allow_collaboration`" do
target_project.add_developer(user)
- update_merge_request(allow_collaboration: true, title: 'Updated title')
+ update_merge_request(allow_collaboration: true, title: "Updated title")
- expect(merge_request.title).to eq('Updated title')
+ expect(merge_request.title).to eq("Updated title")
expect(merge_request.allow_collaboration).to be_falsy
end
- it 'is allowed by a user that can push to the source and can update the merge request' do
+ it "is allowed by a user that can push to the source and can update the merge request" do
merge_request.update!(assignee: user)
source_project.add_developer(user)
- update_merge_request(allow_collaboration: true, title: 'Updated title')
+ update_merge_request(allow_collaboration: true, title: "Updated title")
- expect(merge_request.title).to eq('Updated title')
+ expect(merge_request.title).to eq("Updated title")
expect(merge_request.allow_collaboration).to be_truthy
end
end
diff --git a/spec/services/milestones/close_service_spec.rb b/spec/services/milestones/close_service_spec.rb
index 3f7a544ea0a..11d621dedad 100644
--- a/spec/services/milestones/close_service_spec.rb
+++ b/spec/services/milestones/close_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Milestones::CloseService do
let(:user) { create(:user) }
@@ -9,7 +9,7 @@ describe Milestones::CloseService do
project.add_maintainer(user)
end
- describe '#execute' do
+ describe "#execute" do
before do
described_class.new(project, user, {}).execute(milestone)
end
@@ -17,12 +17,12 @@ describe Milestones::CloseService do
it { expect(milestone).to be_valid }
it { expect(milestone).to be_closed }
- describe 'event' do
+ describe "event" do
let(:event) { Event.recent.first }
it { expect(event.milestone).to be_truthy }
it { expect(event.target).to eq(milestone) }
- it { expect(event.action_name).to eq('closed') }
+ it { expect(event.action_name).to eq("closed") }
end
end
end
diff --git a/spec/services/milestones/create_service_spec.rb b/spec/services/milestones/create_service_spec.rb
index 0c91112026f..9b8f9c909a9 100644
--- a/spec/services/milestones/create_service_spec.rb
+++ b/spec/services/milestones/create_service_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Milestones::CreateService do
let(:project) { create(:project) }
let(:user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
context "valid params" do
before do
project.add_maintainer(user)
opts = {
- title: 'v2.1.9',
- description: 'Patch release to fix security issue'
+ title: "v2.1.9",
+ description: "Patch release to fix security issue",
}
@milestone = described_class.new(project, user, opts).execute
end
it { expect(@milestone).to be_valid }
- it { expect(@milestone.title).to eq('v2.1.9') }
+ it { expect(@milestone.title).to eq("v2.1.9") }
end
end
end
diff --git a/spec/services/milestones/destroy_service_spec.rb b/spec/services/milestones/destroy_service_spec.rb
index 9d2be30c636..45a218b6c71 100644
--- a/spec/services/milestones/destroy_service_spec.rb
+++ b/spec/services/milestones/destroy_service_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Milestones::DestroyService do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:milestone) { create(:milestone, title: 'Milestone v1.0', project: project) }
+ let(:milestone) { create(:milestone, title: "Milestone v1.0", project: project) }
before do
project.add_maintainer(user)
@@ -13,14 +13,14 @@ describe Milestones::DestroyService do
described_class.new(project, user, {})
end
- describe '#execute' do
- it 'deletes milestone' do
+ describe "#execute" do
+ it "deletes milestone" do
service.execute(milestone)
expect { milestone.reload }.to raise_error ActiveRecord::RecordNotFound
end
- it 'deletes milestone id from issuables' do
+ it "deletes milestone id from issuables" do
issue = create(:issue, project: project, milestone: milestone)
merge_request = create(:merge_request, source_project: project, milestone: milestone)
@@ -30,15 +30,15 @@ describe Milestones::DestroyService do
expect(merge_request.reload.milestone).to be_nil
end
- it 'logs destroy event' do
+ it "logs destroy event" do
service.execute(milestone)
- event = Event.where(project_id: milestone.project_id, target_type: 'Milestone')
+ event = Event.where(project_id: milestone.project_id, target_type: "Milestone")
expect(event.count).to eq(1)
end
- context 'group milestones' do
+ context "group milestones" do
let(:group) { create(:group) }
let(:group_milestone) { create(:milestone, group: group) }
@@ -49,7 +49,7 @@ describe Milestones::DestroyService do
it { expect(service.execute(group_milestone)).to eq(group_milestone) }
- it 'deletes milestone id from issuables' do
+ it "deletes milestone id from issuables" do
issue = create(:issue, project: project, milestone: group_milestone)
merge_request = create(:merge_request, source_project: project, milestone: group_milestone)
@@ -59,7 +59,7 @@ describe Milestones::DestroyService do
expect(merge_request.reload.milestone).to be_nil
end
- it 'does not log destroy event' do
+ it "does not log destroy event" do
expect { service.execute(group_milestone) }.not_to change { Event.count }
end
end
diff --git a/spec/services/milestones/promote_service_spec.rb b/spec/services/milestones/promote_service_spec.rb
index df212d912e9..f51e5c9fde8 100644
--- a/spec/services/milestones/promote_service_spec.rb
+++ b/spec/services/milestones/promote_service_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Milestones::PromoteService do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:user) { create(:user) }
- let(:milestone_title) { 'project milestone' }
+ let(:milestone_title) { "project milestone" }
let(:milestone) { create(:milestone, project: project, title: milestone_title) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
group.add_maintainer(user)
end
- context 'validations' do
- it 'raises error if milestone does not belong to a project' do
+ context "validations" do
+ it "raises error if milestone does not belong to a project" do
allow(milestone).to receive(:project_milestone?).and_return(false)
expect { service.execute(milestone) }.to raise_error(described_class::PromoteMilestoneError)
end
- it 'raises error if project does not belong to a group' do
+ it "raises error if project does not belong to a group" do
project.update(namespace: user.namespace)
expect { service.execute(milestone) }.to raise_error(described_class::PromoteMilestoneError)
end
- it 'does not promote milestone and update issuables if promoted milestone is not valid' do
+ it "does not promote milestone and update issuables if promoted milestone is not valid" do
issue = create(:issue, milestone: milestone, project: project)
merge_request = create(:merge_request, milestone: milestone, source_project: project)
allow_any_instance_of(Milestone).to receive(:valid?).and_return(false)
@@ -39,14 +39,14 @@ describe Milestones::PromoteService do
end
end
- context 'without duplicated milestone titles across projects' do
- it 'promotes project milestone to group milestone' do
+ context "without duplicated milestone titles across projects" do
+ it "promotes project milestone to group milestone" do
promoted_milestone = service.execute(milestone)
expect(promoted_milestone).to be_group_milestone
end
- it 'does not update issuables without milestone with the new promoted milestone' do
+ it "does not update issuables without milestone with the new promoted milestone" do
issue_without_milestone = create(:issue, project: project, milestone: nil)
merge_request_without_milestone = create(:merge_request, milestone: nil, source_project: project)
@@ -56,7 +56,7 @@ describe Milestones::PromoteService do
expect(merge_request_without_milestone.reload.milestone).to be_nil
end
- it 'sets issuables with new promoted milestone' do
+ it "sets issuables with new promoted milestone" do
issue = create(:issue, milestone: milestone, project: project)
merge_request = create(:merge_request, milestone: milestone, source_project: project)
@@ -68,11 +68,11 @@ describe Milestones::PromoteService do
end
end
- context 'with duplicated milestone titles across projects' do
+ context "with duplicated milestone titles across projects" do
let(:project_2) { create(:project, namespace: group) }
let!(:milestone_2) { create(:milestone, project: project_2, title: milestone_title) }
- it 'deletes project milestones with the same title' do
+ it "deletes project milestones with the same title" do
promoted_milestone = service.execute(milestone)
expect(promoted_milestone).to be_group_milestone
@@ -81,7 +81,7 @@ describe Milestones::PromoteService do
expect(Milestone.exists?(milestone_2.id)).to be_falsy
end
- it 'does not update issuables without milestone with the new promoted milestone' do
+ it "does not update issuables without milestone with the new promoted milestone" do
issue_without_milestone_1 = create(:issue, project: project, milestone: nil)
issue_without_milestone_2 = create(:issue, project: project_2, milestone: nil)
merge_request_without_milestone_1 = create(:merge_request, milestone: nil, source_project: project)
@@ -95,7 +95,7 @@ describe Milestones::PromoteService do
expect(merge_request_without_milestone_2.reload.milestone).to be_nil
end
- it 'sets all issuables with new promoted milestone' do
+ it "sets all issuables with new promoted milestone" do
issue = create(:issue, milestone: milestone, project: project)
issue_2 = create(:issue, milestone: milestone_2, project: project_2)
merge_request = create(:merge_request, milestone: milestone, source_project: project)
diff --git a/spec/services/milestones/update_service_spec.rb b/spec/services/milestones/update_service_spec.rb
index 3b91442c0ba..209be0da2d5 100644
--- a/spec/services/milestones/update_service_spec.rb
+++ b/spec/services/milestones/update_service_spec.rb
@@ -1,12 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Milestones::UpdateService do
let(:project) { create(:project) }
let(:user) { build(:user) }
let(:milestone) { create(:milestone, project: project) }
- describe '#execute' do
+ describe "#execute" do
context "valid params" do
let(:inner_service) { double(:service) }
@@ -14,26 +15,26 @@ describe Milestones::UpdateService do
project.add_maintainer(user)
end
- subject { described_class.new(project, user, { title: 'new_title' }).execute(milestone) }
+ subject { described_class.new(project, user, {title: "new_title"}).execute(milestone) }
it { expect(subject).to be_valid }
- it { expect(subject.title).to eq('new_title') }
+ it { expect(subject.title).to eq("new_title") }
- context 'state_event is activate' do
- it 'calls ReopenService' do
+ context "state_event is activate" do
+ it "calls ReopenService" do
expect(Milestones::ReopenService).to receive(:new).with(project, user, {}).and_return(inner_service)
expect(inner_service).to receive(:execute).with(milestone)
- described_class.new(project, user, { state_event: 'activate' }).execute(milestone)
+ described_class.new(project, user, {state_event: "activate"}).execute(milestone)
end
end
- context 'state_event is close' do
- it 'calls ReopenService' do
+ context "state_event is close" do
+ it "calls ReopenService" do
expect(Milestones::CloseService).to receive(:new).with(project, user, {}).and_return(inner_service)
expect(inner_service).to receive(:execute).with(milestone)
- described_class.new(project, user, { state_event: 'close' }).execute(milestone)
+ described_class.new(project, user, {state_event: "close"}).execute(milestone)
end
end
end
diff --git a/spec/services/note_summary_spec.rb b/spec/services/note_summary_spec.rb
index a6cc2251e48..7d48759c3cc 100644
--- a/spec/services/note_summary_spec.rb
+++ b/spec/services/note_summary_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NoteSummary do
let(:project) { build(:project) }
@@ -6,39 +6,39 @@ describe NoteSummary do
let(:user) { build(:user) }
def create_note_summary
- described_class.new(noteable, project, user, 'note', action: 'icon', commit_count: 5)
+ described_class.new(noteable, project, user, "note", action: "icon", commit_count: 5)
end
- describe '#metadata?' do
- it 'returns true when metadata present' do
+ describe "#metadata?" do
+ it "returns true when metadata present" do
expect(create_note_summary.metadata?).to be_truthy
end
- it 'returns false when metadata not present' do
- expect(described_class.new(noteable, project, user, 'note').metadata?).to be_falsey
+ it "returns false when metadata not present" do
+ expect(described_class.new(noteable, project, user, "note").metadata?).to be_falsey
end
end
- describe '#note' do
- it 'returns note hash' do
- expect(create_note_summary.note).to eq(noteable: noteable, project: project, author: user, note: 'note')
+ describe "#note" do
+ it "returns note hash" do
+ expect(create_note_summary.note).to eq(noteable: noteable, project: project, author: user, note: "note")
end
- context 'when noteable is a commit' do
+ context "when noteable is a commit" do
let(:noteable) { build(:commit) }
- it 'returns note hash specific to commit' do
+ it "returns note hash specific to commit" do
expect(create_note_summary.note).to eq(
- noteable: nil, project: project, author: user, note: 'note',
- noteable_type: 'Commit', commit_id: noteable.id
+ noteable: nil, project: project, author: user, note: "note",
+ noteable_type: "Commit", commit_id: noteable.id
)
end
end
end
- describe '#metadata' do
- it 'returns metadata hash' do
- expect(create_note_summary.metadata).to eq(action: 'icon', commit_count: 5)
+ describe "#metadata" do
+ it "returns metadata hash" do
+ expect(create_note_summary.metadata).to eq(action: "icon", commit_count: 5)
end
end
end
diff --git a/spec/services/notes/build_service_spec.rb b/spec/services/notes/build_service_spec.rb
index af4daff336b..5bbafb90ebf 100644
--- a/spec/services/notes/build_service_spec.rb
+++ b/spec/services/notes/build_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::BuildService do
let(:note) { create(:discussion_note_on_issue) }
@@ -7,67 +7,67 @@ describe Notes::BuildService do
let(:merge_request) { create(:merge_request, source_project: project) }
let(:mr_note) { create(:discussion_note_on_merge_request, noteable: merge_request, project: project, author: author) }
- describe '#execute' do
- context 'when in_reply_to_discussion_id is specified' do
- context 'when a note with that original discussion ID exists' do
- it 'sets the note up to be in reply to that note' do
- new_note = described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: note.discussion_id).execute
+ describe "#execute" do
+ context "when in_reply_to_discussion_id is specified" do
+ context "when a note with that original discussion ID exists" do
+ it "sets the note up to be in reply to that note" do
+ new_note = described_class.new(project, author, note: "Test", in_reply_to_discussion_id: note.discussion_id).execute
expect(new_note).to be_valid
expect(new_note.in_reply_to?(note)).to be_truthy
expect(new_note.resolved?).to be_falsey
end
- context 'when discussion is resolved' do
+ context "when discussion is resolved" do
before do
mr_note.resolve!(author)
end
- it 'resolves the note' do
- new_note = described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: mr_note.discussion_id).execute
+ it "resolves the note" do
+ new_note = described_class.new(project, author, note: "Test", in_reply_to_discussion_id: mr_note.discussion_id).execute
expect(new_note).to be_valid
expect(new_note.resolved?).to be_truthy
end
end
end
- context 'when a note with that discussion ID exists' do
- it 'sets the note up to be in reply to that note' do
- new_note = described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: note.discussion_id).execute
+ context "when a note with that discussion ID exists" do
+ it "sets the note up to be in reply to that note" do
+ new_note = described_class.new(project, author, note: "Test", in_reply_to_discussion_id: note.discussion_id).execute
expect(new_note).to be_valid
expect(new_note.in_reply_to?(note)).to be_truthy
end
end
- context 'when no note with that discussion ID exists' do
- it 'sets an error' do
- new_note = described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: 'foo').execute
- expect(new_note.errors[:base]).to include('Discussion to reply to cannot be found')
+ context "when no note with that discussion ID exists" do
+ it "sets an error" do
+ new_note = described_class.new(project, author, note: "Test", in_reply_to_discussion_id: "foo").execute
+ expect(new_note.errors[:base]).to include("Discussion to reply to cannot be found")
end
end
- context 'when user has no access to discussion' do
- it 'sets an error' do
+ context "when user has no access to discussion" do
+ it "sets an error" do
another_user = create(:user)
- new_note = described_class.new(project, another_user, note: 'Test', in_reply_to_discussion_id: note.discussion_id).execute
+ new_note = described_class.new(project, another_user, note: "Test", in_reply_to_discussion_id: note.discussion_id).execute
- expect(new_note.errors[:base]).to include('Discussion to reply to cannot be found')
+ expect(new_note.errors[:base]).to include("Discussion to reply to cannot be found")
end
end
- context 'personal snippet note' do
+ context "personal snippet note" do
def reply(note, user = nil)
user ||= create(:user)
described_class.new(nil,
- user,
- note: 'Test',
- in_reply_to_discussion_id: note.discussion_id).execute
+ user,
+ note: "Test",
+ in_reply_to_discussion_id: note.discussion_id).execute
end
let(:snippet_author) { create(:user) }
- context 'when a snippet is public' do
- it 'creates a reply note' do
+ context "when a snippet is public" do
+ it "creates a reply note" do
snippet = create(:personal_snippet, :public)
note = create(:discussion_note_on_personal_snippet, noteable: snippet)
@@ -78,97 +78,97 @@ describe Notes::BuildService do
end
end
- context 'when a snippet is private' do
+ context "when a snippet is private" do
let(:snippet) { create(:personal_snippet, :private, author: snippet_author) }
let(:note) { create(:discussion_note_on_personal_snippet, noteable: snippet) }
- it 'creates a reply note when the author replies' do
+ it "creates a reply note when the author replies" do
new_note = reply(note, snippet_author)
expect(new_note).to be_valid
expect(new_note.in_reply_to?(note)).to be_truthy
end
- it 'sets an error when another user replies' do
+ it "sets an error when another user replies" do
new_note = reply(note)
- expect(new_note.errors[:base]).to include('Discussion to reply to cannot be found')
+ expect(new_note.errors[:base]).to include("Discussion to reply to cannot be found")
end
end
- context 'when a snippet is internal' do
+ context "when a snippet is internal" do
let(:snippet) { create(:personal_snippet, :internal, author: snippet_author) }
let(:note) { create(:discussion_note_on_personal_snippet, noteable: snippet) }
- it 'creates a reply note when the author replies' do
+ it "creates a reply note when the author replies" do
new_note = reply(note, snippet_author)
expect(new_note).to be_valid
expect(new_note.in_reply_to?(note)).to be_truthy
end
- it 'creates a reply note when a regular user replies' do
+ it "creates a reply note when a regular user replies" do
new_note = reply(note)
expect(new_note).to be_valid
expect(new_note.in_reply_to?(note)).to be_truthy
end
- it 'sets an error when an external user replies' do
+ it "sets an error when an external user replies" do
new_note = reply(note, create(:user, :external))
- expect(new_note.errors[:base]).to include('Discussion to reply to cannot be found')
+ expect(new_note.errors[:base]).to include("Discussion to reply to cannot be found")
end
end
end
end
- context 'when replying to individual note' do
+ context "when replying to individual note" do
let(:note) { create(:note_on_issue) }
- subject { described_class.new(project, author, note: 'Test', in_reply_to_discussion_id: note.discussion_id).execute }
+ subject { described_class.new(project, author, note: "Test", in_reply_to_discussion_id: note.discussion_id).execute }
- shared_examples 'an individual note reply' do
- it 'builds another individual note' do
+ shared_examples "an individual note reply" do
+ it "builds another individual note" do
expect(subject).to be_valid
expect(subject).to be_a(Note)
expect(subject.discussion_id).not_to eq(note.discussion_id)
end
end
- context 'when reply_to_individual_notes is disabled' do
+ context "when reply_to_individual_notes is disabled" do
before do
stub_feature_flags(reply_to_individual_notes: false)
end
- it_behaves_like 'an individual note reply'
+ it_behaves_like "an individual note reply"
end
- context 'when reply_to_individual_notes is enabled' do
+ context "when reply_to_individual_notes is enabled" do
before do
stub_feature_flags(reply_to_individual_notes: true)
end
- it 'sets the note up to be in reply to that note' do
+ it "sets the note up to be in reply to that note" do
expect(subject).to be_valid
expect(subject).to be_a(DiscussionNote)
expect(subject.discussion_id).to eq(note.discussion_id)
end
- context 'when noteable does not support replies' do
+ context "when noteable does not support replies" do
let(:note) { create(:note_on_commit) }
- it_behaves_like 'an individual note reply'
+ it_behaves_like "an individual note reply"
end
end
end
- it 'builds a note without saving it' do
+ it "builds a note without saving it" do
new_note = described_class.new(project,
- author,
- noteable_type: note.noteable_type,
- noteable_id: note.noteable_id,
- note: 'Test').execute
+ author,
+ noteable_type: note.noteable_type,
+ noteable_id: note.noteable_id,
+ note: "Test").execute
expect(new_note).to be_valid
expect(new_note).not_to be_persisted
end
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 1645b67c329..4aa5704b88d 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::CreateService do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
let(:opts) do
- { note: 'Awesome comment', noteable_type: 'Issue', noteable_id: issue.id }
+ {note: "Awesome comment", noteable_type: "Issue", noteable_id: issue.id}
end
- describe '#execute' do
+ describe "#execute" do
before do
project.add_maintainer(user)
end
context "valid params" do
- it 'returns a valid note' do
+ it "returns a valid note" do
note = described_class.new(project, user, opts).execute
expect(note).to be_valid
end
- it 'returns a persisted note' do
+ it "returns a persisted note" do
note = described_class.new(project, user, opts).execute
expect(note).to be_persisted
end
- it 'note has valid content' do
+ it "note has valid content" do
note = described_class.new(project, user, opts).execute
expect(note.note).to eq(opts[:note])
end
- it 'note belongs to the correct project' do
+ it "note belongs to the correct project" do
note = described_class.new(project, user, opts).execute
expect(note.project).to eq(project)
end
- it 'TodoService#new_note is called' do
+ it "TodoService#new_note is called" do
note = build(:note, project: project)
allow(Note).to receive(:new).with(opts) { note }
@@ -47,7 +47,7 @@ describe Notes::CreateService do
described_class.new(project, user, opts).execute
end
- it 'enqueues NewNoteWorker' do
+ it "enqueues NewNoteWorker" do
note = build(:note, id: 999, project: project)
allow(Note).to receive(:new).with(opts) { note }
@@ -57,7 +57,7 @@ describe Notes::CreateService do
end
end
- context 'noteable highlight cache clearing' do
+ context "noteable highlight cache clearing" do
let(:project_with_repo) { create(:project, :repository) }
let(:merge_request) do
create(:merge_request, source_project: project_with_repo,
@@ -74,8 +74,8 @@ describe Notes::CreateService do
let(:new_opts) do
opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
+ type: "DiffNote",
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
position: position.to_h)
end
@@ -85,20 +85,20 @@ describe Notes::CreateService do
.to receive(:unfolded_diff?) { true }
end
- it 'clears noteable diff cache when it was unfolded for the note position' do
+ it "clears noteable diff cache when it was unfolded for the note position" do
expect_any_instance_of(Gitlab::Diff::HighlightCache).to receive(:clear)
described_class.new(project_with_repo, user, new_opts).execute
end
- it 'does not clear cache when note is not the first of the discussion' do
+ it "does not clear cache when note is not the first of the discussion" do
prev_note =
create(:diff_note_on_merge_request, noteable: merge_request,
project: project_with_repo)
reply_opts =
opts.merge(in_reply_to_discussion_id: prev_note.discussion_id,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
+ type: "DiffNote",
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
position: position.to_h)
@@ -108,12 +108,12 @@ describe Notes::CreateService do
end
end
- context 'note diff file' do
+ context "note diff file" do
let(:project_with_repo) { create(:project, :repository) }
let(:merge_request) do
create(:merge_request,
- source_project: project_with_repo,
- target_project: project_with_repo)
+ source_project: project_with_repo,
+ target_project: project_with_repo)
end
let(:line_number) { 14 }
let(:position) do
@@ -131,16 +131,16 @@ describe Notes::CreateService do
project_with_repo.add_maintainer(user)
end
- context 'when eligible to have a note diff file' do
+ context "when eligible to have a note diff file" do
let(:new_opts) do
opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
+ type: "DiffNote",
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
position: position.to_h)
end
- it 'note is associated with a note diff file' do
+ it "note is associated with a note diff file" do
note = described_class.new(project_with_repo, user, new_opts).execute
expect(note).to be_persisted
@@ -148,23 +148,23 @@ describe Notes::CreateService do
end
end
- context 'when DiffNote is a reply' do
+ context "when DiffNote is a reply" do
let(:new_opts) do
opts.merge(in_reply_to_discussion_id: previous_note.discussion_id,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
+ type: "DiffNote",
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
position: position.to_h)
end
- it 'note is not associated with a note diff file' do
+ it "note is not associated with a note diff file" do
note = described_class.new(project_with_repo, user, new_opts).execute
expect(note).to be_persisted
expect(note.note_diff_file).to be_nil
end
- context 'when DiffNote from an image' do
+ context "when DiffNote from an image" do
let(:image_position) do
Gitlab::Diff::Position.new(old_path: "files/images/6049019_460s.jpg",
new_path: "files/images/6049019_460s.jpg",
@@ -173,18 +173,18 @@ describe Notes::CreateService do
x: 1,
y: 100,
diff_refs: merge_request.diff_refs,
- position_type: 'image')
+ position_type: "image")
end
let(:new_opts) do
opts.merge(in_reply_to_discussion_id: nil,
- type: 'DiffNote',
- noteable_type: 'MergeRequest',
+ type: "DiffNote",
+ noteable_type: "MergeRequest",
noteable_id: merge_request.id,
position: image_position.to_h)
end
- it 'note is not associated with a note diff file' do
+ it "note is not associated with a note diff file" do
note = described_class.new(project_with_repo, user, new_opts).execute
expect(note).to be_persisted
@@ -194,12 +194,12 @@ describe Notes::CreateService do
end
end
- context 'note with commands' do
- context 'as a user who can update the target' do
- context '/close, /label, /assign & /milestone' do
+ context "note with commands" do
+ context "as a user who can update the target" do
+ context "/close, /label, /assign & /milestone" do
let(:note_text) { %(HELLO\n/close\n/assign @#{user.username}\nWORLD) }
- it 'saves the note and does not alter the note text' do
+ it "saves the note and does not alter the note text" do
service = double(:service)
allow(Issues::UpdateService).to receive(:new).and_return(service)
expect(service).to receive(:execute)
@@ -210,11 +210,11 @@ describe Notes::CreateService do
end
end
- context '/merge with sha option' do
+ context "/merge with sha option" do
let(:note_text) { %(HELLO\n/merge\nWORLD) }
- let(:params) { opts.merge(note: note_text, merge_request_diff_head_sha: 'sha') }
+ let(:params) { opts.merge(note: note_text, merge_request_diff_head_sha: "sha") }
- it 'saves the note and exectues merge command' do
+ it "saves the note and exectues merge command" do
note = described_class.new(project, user, params).execute
expect(note.note).to eq "HELLO\nWORLD"
@@ -222,7 +222,7 @@ describe Notes::CreateService do
end
end
- context 'as a user who cannot update the target' do
+ context "as a user who cannot update the target" do
let(:note_text) { "HELLO\n/todo\n/assign #{user.to_reference}\nWORLD" }
let(:note) { described_class.new(project, user, opts.merge(note: note_text)).execute }
@@ -230,95 +230,95 @@ describe Notes::CreateService do
project.team.find_member(user.id).update!(access_level: Gitlab::Access::GUEST)
end
- it 'applies commands the user can execute' do
+ it "applies commands the user can execute" do
expect { note }.to change { user.todos_pending_count }.from(0).to(1)
end
- it 'does not apply commands the user cannot execute' do
+ it "does not apply commands the user cannot execute" do
expect { note }.not_to change { issue.assignees }
end
- it 'saves the note' do
+ it "saves the note" do
expect(note.note).to eq "HELLO\nWORLD"
end
end
end
- context 'personal snippet note' do
+ context "personal snippet note" do
subject { described_class.new(nil, user, params).execute }
let(:snippet) { create(:personal_snippet) }
let(:params) do
- { note: 'comment', noteable_type: 'Snippet', noteable_id: snippet.id }
+ {note: "comment", noteable_type: "Snippet", noteable_id: snippet.id}
end
- it 'returns a valid note' do
+ it "returns a valid note" do
expect(subject).to be_valid
end
- it 'returns a persisted note' do
+ it "returns a persisted note" do
expect(subject).to be_persisted
end
- it 'note has valid content' do
+ it "note has valid content" do
expect(subject.note).to eq(params[:note])
end
end
- context 'note with emoji only' do
- it 'creates regular note' do
+ context "note with emoji only" do
+ it "creates regular note" do
opts = {
- note: ':smile: ',
- noteable_type: 'Issue',
- noteable_id: issue.id
+ note: ":smile: ",
+ noteable_type: "Issue",
+ noteable_id: issue.id,
}
note = described_class.new(project, user, opts).execute
expect(note).to be_valid
- expect(note.note).to eq(':smile:')
+ expect(note.note).to eq(":smile:")
end
end
- context 'reply to individual note' do
+ context "reply to individual note" do
let(:existing_note) { create(:note_on_issue, noteable: issue, project: project) }
let(:reply_opts) { opts.merge(in_reply_to_discussion_id: existing_note.discussion_id) }
subject { described_class.new(project, user, reply_opts).execute }
- context 'when reply_to_individual_notes is disabled' do
+ context "when reply_to_individual_notes is disabled" do
before do
stub_feature_flags(reply_to_individual_notes: false)
end
- it 'creates an individual note' do
+ it "creates an individual note" do
expect(subject.type).to eq(nil)
expect(subject.discussion_id).not_to eq(existing_note.discussion_id)
end
- it 'does not convert existing note' do
+ it "does not convert existing note" do
expect { subject }.not_to change { existing_note.reload.type }
end
end
- context 'when reply_to_individual_notes is enabled' do
+ context "when reply_to_individual_notes is enabled" do
before do
stub_feature_flags(reply_to_individual_notes: true)
end
- it 'creates a DiscussionNote in reply to existing note' do
+ it "creates a DiscussionNote in reply to existing note" do
expect(subject).to be_a(DiscussionNote)
expect(subject.discussion_id).to eq(existing_note.discussion_id)
end
- it 'converts existing note to DiscussionNote' do
- expect do
+ it "converts existing note to DiscussionNote" do
+ expect {
existing_note
Timecop.freeze(Time.now + 1.minute) { subject }
existing_note.reload
- end.to change { existing_note.type }.from(nil).to('DiscussionNote')
- .and change { existing_note.updated_at }
+ }.to change { existing_note.type }.from(nil).to("DiscussionNote")
+ .and change { existing_note.updated_at }
end
end
end
diff --git a/spec/services/notes/destroy_service_spec.rb b/spec/services/notes/destroy_service_spec.rb
index b1f4e87e8ea..40a7d7129e2 100644
--- a/spec/services/notes/destroy_service_spec.rb
+++ b/spec/services/notes/destroy_service_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::DestroyService do
set(:project) { create(:project, :public) }
set(:issue) { create(:issue, project: project) }
let(:user) { issue.author }
- describe '#execute' do
- it 'deletes a note' do
+ describe "#execute" do
+ it "deletes a note" do
note = create(:note, project: project, noteable: issue)
described_class.new(project, user).execute(note)
@@ -14,7 +14,7 @@ describe Notes::DestroyService do
expect(project.issues.find(issue.id).notes).not_to include(note)
end
- it 'updates the todo counts for users with todos for the note' do
+ it "updates the todo counts for users with todos for the note" do
note = create(:note, project: project, noteable: issue)
create(:todo, note: note, target: issue, user: user, author: user, project: project)
@@ -22,7 +22,7 @@ describe Notes::DestroyService do
.to change { user.todos_pending_count }.from(1).to(0)
end
- context 'noteable highlight cache clearing' do
+ context "noteable highlight cache clearing" do
let(:repo_project) { create(:project, :repository) }
let(:merge_request) do
create(:merge_request, source_project: repo_project,
@@ -38,13 +38,13 @@ describe Notes::DestroyService do
allow(note.position).to receive(:unfolded_diff?) { true }
end
- it 'clears noteable diff cache when it was unfolded for the note position' do
+ it "clears noteable diff cache when it was unfolded for the note position" do
expect(merge_request).to receive_message_chain(:diffs, :clear_cache)
described_class.new(repo_project, user).execute(note)
end
- it 'does not clear cache when note is not the first of the discussion' do
+ it "does not clear cache when note is not the first of the discussion" do
reply_note = create(:diff_note_on_merge_request, in_reply_to: note,
project: repo_project,
noteable: merge_request)
diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb
index 5aae0d711c3..e7528850961 100644
--- a/spec/services/notes/post_process_service_spec.rb
+++ b/spec/services/notes/post_process_service_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::PostProcessService do
let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) }
let(:user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
before do
project.add_maintainer(user)
note_opts = {
- note: 'Awesome comment',
- noteable_type: 'Issue',
- noteable_id: issue.id
+ note: "Awesome comment",
+ noteable_type: "Issue",
+ noteable_id: issue.id,
}
@note = Notes::CreateService.new(project, user, note_opts).execute
@@ -24,7 +24,7 @@ describe Notes::PostProcessService do
described_class.new(@note).execute
end
- context 'with a confidential issue' do
+ context "with a confidential issue" do
let(:issue) { create(:issue, :confidential, project: project) }
it "doesn't call note hooks/services" do
diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb
index 14d62763a5b..3a49a94bbca 100644
--- a/spec/services/notes/quick_actions_service_spec.rb
+++ b/spec/services/notes/quick_actions_service_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::QuickActionsService do
- shared_context 'note on noteable' do
+ shared_context "note on noteable" do
let(:project) { create(:project, :repository) }
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:assignee) { create(:user) }
@@ -11,8 +11,8 @@ describe Notes::QuickActionsService do
end
end
- shared_examples 'note on noteable that supports quick actions' do
- include_context 'note on noteable'
+ shared_examples "note on noteable that supports quick actions" do
+ include_context "note on noteable"
before do
note.note = note_text
@@ -21,17 +21,17 @@ describe Notes::QuickActionsService do
let!(:milestone) { create(:milestone, project: project) }
let!(:labels) { create_pair(:label, project: project) }
- describe 'note with only command' do
- describe '/close, /label, /assign & /milestone' do
+ describe "note with only command" do
+ describe "/close, /label, /assign & /milestone" do
let(:note_text) do
%(/close\n/label ~#{labels.first.name} ~#{labels.last.name}\n/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
end
- it 'closes noteable, sets labels, assigns, and sets milestone to noteable, and leave no note' do
+ it "closes noteable, sets labels, assigns, and sets milestone to noteable, and leave no note" do
content, command_params = service.extract_commands(note)
service.execute(command_params, note)
- expect(content).to eq ''
+ expect(content).to eq ""
expect(note.noteable).to be_closed
expect(note.noteable.labels).to match_array(labels)
expect(note.noteable.assignees).to eq([assignee])
@@ -39,42 +39,42 @@ describe Notes::QuickActionsService do
end
end
- describe '/reopen' do
+ describe "/reopen" do
before do
note.noteable.close!
expect(note.noteable).to be_closed
end
- let(:note_text) { '/reopen' }
+ let(:note_text) { "/reopen" }
- it 'opens the noteable, and leave no note' do
+ it "opens the noteable, and leave no note" do
content, command_params = service.extract_commands(note)
service.execute(command_params, note)
- expect(content).to eq ''
+ expect(content).to eq ""
expect(note.noteable).to be_open
end
end
- describe '/spend' do
- let(:note_text) { '/spend 1h' }
+ describe "/spend" do
+ let(:note_text) { "/spend 1h" }
- it 'updates the spent time on the noteable' do
+ it "updates the spent time on the noteable" do
content, command_params = service.extract_commands(note)
service.execute(command_params, note)
- expect(content).to eq ''
+ expect(content).to eq ""
expect(note.noteable.time_spent).to eq(3600)
end
end
end
- describe 'note with command & text' do
- describe '/close, /label, /assign & /milestone' do
+ describe "note with command & text" do
+ describe "/close, /label, /assign & /milestone" do
let(:note_text) do
%(HELLO\n/close\n/label ~#{labels.first.name} ~#{labels.last.name}\n/assign @#{assignee.username}\n/milestone %"#{milestone.name}"\nWORLD)
end
- it 'closes noteable, sets labels, assigns, and sets milestone to noteable' do
+ it "closes noteable, sets labels, assigns, and sets milestone to noteable" do
content, command_params = service.extract_commands(note)
service.execute(command_params, note)
@@ -86,14 +86,14 @@ describe Notes::QuickActionsService do
end
end
- describe '/reopen' do
+ describe "/reopen" do
before do
note.noteable.close
expect(note.noteable).to be_closed
end
let(:note_text) { "HELLO\n/reopen\nWORLD" }
- it 'opens the noteable' do
+ it "opens the noteable" do
content, command_params = service.extract_commands(note)
service.execute(command_params, note)
@@ -104,52 +104,52 @@ describe Notes::QuickActionsService do
end
end
- describe '.noteable_update_service' do
- include_context 'note on noteable'
+ describe ".noteable_update_service" do
+ include_context "note on noteable"
- it 'returns Issues::UpdateService for a note on an issue' do
+ it "returns Issues::UpdateService for a note on an issue" do
note = create(:note_on_issue, project: project)
expect(described_class.noteable_update_service(note)).to eq(Issues::UpdateService)
end
- it 'returns MergeRequests::UpdateService for a note on a merge request' do
+ it "returns MergeRequests::UpdateService for a note on a merge request" do
note = create(:note_on_merge_request, project: project)
expect(described_class.noteable_update_service(note)).to eq(MergeRequests::UpdateService)
end
- it 'returns Commits::TagService for a note on a commit' do
+ it "returns Commits::TagService for a note on a commit" do
note = create(:note_on_commit, project: project)
expect(described_class.noteable_update_service(note)).to eq(Commits::TagService)
end
end
- describe '.supported?' do
- include_context 'note on noteable'
+ describe ".supported?" do
+ include_context "note on noteable"
let(:note) { create(:note_on_issue, project: project) }
- context 'with a note on an issue' do
- it 'returns true' do
+ context "with a note on an issue" do
+ it "returns true" do
expect(described_class.supported?(note)).to be_truthy
end
end
- context 'with a note on a commit' do
+ context "with a note on a commit" do
let(:note) { create(:note_on_commit, project: project) }
- it 'returns false' do
+ it "returns false" do
expect(described_class.supported?(note)).to be_truthy
end
end
end
- describe '#supported?' do
- include_context 'note on noteable'
+ describe "#supported?" do
+ include_context "note on noteable"
- it 'delegates to the class method' do
+ it "delegates to the class method" do
service = described_class.new(project, maintainer)
note = create(:note_on_issue, project: project)
@@ -159,20 +159,20 @@ describe Notes::QuickActionsService do
end
end
- describe '#execute' do
+ describe "#execute" do
let(:service) { described_class.new(project, maintainer) }
- it_behaves_like 'note on noteable that supports quick actions' do
+ it_behaves_like "note on noteable that supports quick actions" do
let(:note) { build(:note_on_issue, project: project) }
end
- it_behaves_like 'note on noteable that supports quick actions' do
+ it_behaves_like "note on noteable that supports quick actions" do
let(:note) { build(:note_on_merge_request, project: project) }
end
end
- context 'CE restriction for issue assignees' do
- describe '/assign' do
+ context "CE restriction for issue assignees" do
+ describe "/assign" do
let(:project) { create(:project) }
let(:maintainer) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:assignee) { create(:user) }
@@ -189,7 +189,7 @@ describe Notes::QuickActionsService do
project.add_maintainer(assignee)
end
- it 'adds only one assignee from the list' do
+ it "adds only one assignee from the list" do
_, command_params = service.extract_commands(note)
service.execute(command_params, note)
diff --git a/spec/services/notes/render_service_spec.rb b/spec/services/notes/render_service_spec.rb
index f771620bc0d..f1a00691131 100644
--- a/spec/services/notes/render_service_spec.rb
+++ b/spec/services/notes/render_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::RenderService do
- describe '#execute' do
- it 'renders a Note' do
+ describe "#execute" do
+ it "renders a Note" do
note = double(:note)
wiki = double(:wiki)
user = double(:user)
@@ -12,11 +12,11 @@ describe Notes::RenderService do
.with(
user: user,
redaction_context: {
- requested_path: 'foo',
- project_wiki: wiki,
- ref: 'bar',
- only_path: nil,
- xhtml: false
+ requested_path: "foo",
+ project_wiki: wiki,
+ ref: "bar",
+ only_path: nil,
+ xhtml: false,
}
)
.and_call_original
@@ -26,11 +26,11 @@ describe Notes::RenderService do
.with([note], :note)
described_class.new(user).execute([note],
- requested_path: 'foo',
- project_wiki: wiki,
- ref: 'bar',
- only_path: nil,
- xhtml: false)
+ requested_path: "foo",
+ project_wiki: wiki,
+ ref: "bar",
+ only_path: nil,
+ xhtml: false)
end
end
end
diff --git a/spec/services/notes/resolve_service_spec.rb b/spec/services/notes/resolve_service_spec.rb
index b54d40a7a5c..eb835271c87 100644
--- a/spec/services/notes/resolve_service_spec.rb
+++ b/spec/services/notes/resolve_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::ResolveService do
let(:merge_request) { create(:merge_request) }
let(:note) { create(:diff_note_on_merge_request, noteable: merge_request, project: merge_request.project) }
let(:user) { merge_request.author }
- describe '#execute' do
+ describe "#execute" do
it "resolves the note" do
described_class.new(merge_request.project, user).execute(note)
note.reload
diff --git a/spec/services/notes/update_service_spec.rb b/spec/services/notes/update_service_spec.rb
index fd9bff46a06..4aea33bf057 100644
--- a/spec/services/notes/update_service_spec.rb
+++ b/spec/services/notes/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Notes::UpdateService do
let(:project) { create(:project) }
@@ -14,14 +14,14 @@ describe Notes::UpdateService do
project.add_developer(user3)
end
- describe '#execute' do
+ describe "#execute" do
def update_note(opts)
@note = Notes::UpdateService.new(project, user, opts).execute(note)
@note.reload
end
- context 'suggestions' do
- it 'refreshes note suggestions' do
+ context "suggestions" do
+ it "refreshes note suggestions" do
markdown = <<-MARKDOWN.strip_heredoc
```suggestion
foo
@@ -43,33 +43,33 @@ describe Notes::UpdateService do
end
end
- context 'todos' do
+ context "todos" do
let!(:todo) { create(:todo, :assigned, user: user, project: project, target: issue, author: user2) }
- context 'when the note change' do
+ context "when the note change" do
before do
- update_note({ note: "New note #{user2.to_reference} #{user3.to_reference}" })
+ update_note({note: "New note #{user2.to_reference} #{user3.to_reference}"})
end
- it 'marks todos as done' do
+ it "marks todos as done" do
expect(todo.reload).to be_done
end
- it 'creates only 1 new todo' do
+ it "creates only 1 new todo" do
expect(Todo.count).to eq(2)
end
end
- context 'when the note does not change' do
+ context "when the note does not change" do
before do
- update_note({ note: "Old note #{user2.to_reference}" })
+ update_note({note: "Old note #{user2.to_reference}"})
end
- it 'keep todos' do
+ it "keep todos" do
expect(todo.reload).to be_pending
end
- it 'does not create any new todos' do
+ it "does not create any new todos" do
expect(Todo.count).to eq(1)
end
end
diff --git a/spec/services/notification_recipient_service_spec.rb b/spec/services/notification_recipient_service_spec.rb
index cea5ea125b9..39e2abcec3b 100644
--- a/spec/services/notification_recipient_service_spec.rb
+++ b/spec/services/notification_recipient_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NotificationRecipientService do
let(:service) { described_class }
@@ -6,19 +6,19 @@ describe NotificationRecipientService do
let(:project) { create(:project, :public) }
let(:other_projects) { create_list(:project, 5, :public) }
- describe '#build_new_note_recipients' do
+ describe "#build_new_note_recipients" do
let(:issue) { create(:issue, project: project, assignees: [assignee]) }
let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id) }
- shared_examples 'no N+1 queries' do
- it 'avoids N+1 queries', :request_store do
+ shared_examples "no N+1 queries" do
+ it "avoids N+1 queries", :request_store do
create_user
service.build_new_note_recipients(note)
- control_count = ActiveRecord::QueryRecorder.new do
+ control_count = ActiveRecord::QueryRecorder.new {
service.build_new_note_recipients(note)
- end
+ }
create_user
@@ -26,7 +26,7 @@ describe NotificationRecipientService do
end
end
- context 'when there are multiple watchers' do
+ context "when there are multiple watchers" do
def create_user
watcher = create(:user)
create(:notification_setting, source: project, user: watcher, level: :watch)
@@ -36,23 +36,23 @@ describe NotificationRecipientService do
end
end
- include_examples 'no N+1 queries'
+ include_examples "no N+1 queries"
end
- context 'when there are multiple subscribers' do
+ context "when there are multiple subscribers" do
def create_user
subscriber = create(:user)
issue.subscriptions.create(user: subscriber, project: project, subscribed: true)
end
- include_examples 'no N+1 queries'
+ include_examples "no N+1 queries"
- context 'when the project is private' do
+ context "when the project is private" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- include_examples 'no N+1 queries'
+ include_examples "no N+1 queries"
end
end
end
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb
index 9ba4a11104a..45f7dcb3d57 100644
--- a/spec/services/notification_service_spec.rb
+++ b/spec/services/notification_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NotificationService, :mailer do
include EmailSpec::Matchers
@@ -13,8 +13,8 @@ describe NotificationService, :mailer do
end
end
- shared_examples 'altered milestone notification on issue' do
- it 'sends the email to the correct people' do
+ shared_examples "altered milestone notification on issue" do
+ it "sends the email to the correct people" do
should_email(subscriber_to_new_milestone)
issue.assignees.each do |a|
should_email(a)
@@ -37,8 +37,8 @@ describe NotificationService, :mailer do
end
end
- shared_examples 'altered milestone notification on merge request' do
- it 'sends the email to the correct people' do
+ shared_examples "altered milestone notification on merge request" do
+ it "sends the email to the correct people" do
should_email(subscriber_to_new_milestone)
merge_request.assignees.each do |a|
should_email(a)
@@ -61,34 +61,34 @@ describe NotificationService, :mailer do
end
end
- shared_examples 'notifications for new mentions' do
- it 'sends no emails when no new mentions are present' do
+ shared_examples "notifications for new mentions" do
+ it "sends no emails when no new mentions are present" do
send_notifications
should_not_email_anyone
end
- it 'emails new mentions with a watch level higher than mention' do
+ it "emails new mentions with a watch level higher than mention" do
send_notifications(@u_watcher, @u_participant_mentioned, @u_custom_global, @u_mentioned)
should_only_email(@u_watcher, @u_participant_mentioned, @u_custom_global, @u_mentioned)
end
- it 'does not email new mentions with a watch level equal to or less than mention' do
+ it "does not email new mentions with a watch level equal to or less than mention" do
send_notifications(@u_disabled)
should_not_email_anyone
end
- it 'emails new mentions despite being unsubscribed' do
+ it "emails new mentions despite being unsubscribed" do
send_notifications(@unsubscribed_mentioned)
should_only_email(@unsubscribed_mentioned)
end
- it 'sends the proper notification reason header' do
+ it "sends the proper notification reason header" do
send_notifications(@u_watcher)
should_only_email(@u_watcher)
email = find_email_for(@u_watcher)
- expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::MENTIONED)
+ expect(email).to have_header("X-GitLab-NotificationReason", NotificationReason::MENTIONED)
end
end
@@ -99,22 +99,22 @@ describe NotificationService, :mailer do
# * notification trigger
# * participant
#
- shared_examples 'participating by note notification' do
- it 'emails the participant' do
- create(:note_on_issue, noteable: issuable, project_id: project.id, note: 'anything', author: participant)
+ shared_examples "participating by note notification" do
+ it "emails the participant" do
+ create(:note_on_issue, noteable: issuable, project_id: project.id, note: "anything", author: participant)
notification_trigger
should_email(participant)
end
- context 'for subgroups', :nested_groups do
+ context "for subgroups", :nested_groups do
before do
build_group(project)
end
- it 'emails the participant' do
- create(:note_on_issue, noteable: issuable, project_id: project.id, note: 'anything', author: @pg_participant)
+ it "emails the participant" do
+ create(:note_on_issue, noteable: issuable, project_id: project.id, note: "anything", author: @pg_participant)
notification_trigger
@@ -123,8 +123,8 @@ describe NotificationService, :mailer do
end
end
- shared_examples 'participating by assignee notification' do
- it 'emails the participant' do
+ shared_examples "participating by assignee notification" do
+ it "emails the participant" do
if issuable.is_a?(Issue)
issuable.assignees << participant
else
@@ -137,8 +137,8 @@ describe NotificationService, :mailer do
end
end
- shared_examples 'participating by author notification' do
- it 'emails the participant' do
+ shared_examples "participating by author notification" do
+ it "emails the participant" do
issuable.author = participant
notification_trigger
@@ -147,76 +147,76 @@ describe NotificationService, :mailer do
end
end
- shared_examples_for 'participating notifications' do
- it_should_behave_like 'participating by note notification'
- it_should_behave_like 'participating by author notification'
- it_should_behave_like 'participating by assignee notification'
+ shared_examples_for "participating notifications" do
+ it_should_behave_like "participating by note notification"
+ it_should_behave_like "participating by author notification"
+ it_should_behave_like "participating by assignee notification"
end
- describe '#async' do
+ describe "#async" do
let(:async) { notification.async }
set(:key) { create(:personal_key) }
- it 'returns an Async object with the correct parent' do
+ it "returns an Async object with the correct parent" do
expect(async).to be_a(described_class::Async)
expect(async.parent).to eq(notification)
end
- context 'when receiving a public method' do
- it 'schedules a MailScheduler::NotificationServiceWorker' do
+ context "when receiving a public method" do
+ it "schedules a MailScheduler::NotificationServiceWorker" do
expect(MailScheduler::NotificationServiceWorker)
- .to receive(:perform_async).with('new_key', key)
+ .to receive(:perform_async).with("new_key", key)
async.new_key(key)
end
end
- context 'when receiving a private method' do
- it 'raises NoMethodError' do
+ context "when receiving a private method" do
+ it "raises NoMethodError" do
expect { async.notifiable?(key) }.to raise_error(NoMethodError)
end
end
- context 'when receiving a non-existent method' do
- it 'raises NoMethodError' do
+ context "when receiving a non-existent method" do
+ it "raises NoMethodError" do
expect { async.foo(key) }.to raise_error(NoMethodError)
end
end
end
- describe 'Keys' do
- describe '#new_key' do
+ describe "Keys" do
+ describe "#new_key" do
let(:key_options) { {} }
let!(:key) { create(:personal_key, key_options) }
it { expect(notification.new_key(key)).to be_truthy }
- describe 'never emails the ghost user' do
- let(:key_options) { { user: User.ghost } }
+ describe "never emails the ghost user" do
+ let(:key_options) { {user: User.ghost} }
it { should_not_email_anyone }
end
end
end
- describe 'GpgKeys' do
- describe '#new_gpg_key' do
+ describe "GpgKeys" do
+ describe "#new_gpg_key" do
let!(:key) { create(:gpg_key) }
it { expect(notification.new_gpg_key(key)).to be_truthy }
- it 'sends email to key owner' do
+ it "sends email to key owner" do
expect { notification.new_gpg_key(key) }.to change { ActionMailer::Base.deliveries.size }.by(1)
end
end
end
- describe 'Notes' do
- context 'issue note' do
+ describe "Notes" do
+ context "issue note" do
let(:project) { create(:project, :private) }
let(:issue) { create(:issue, project: project, assignees: [assignee]) }
let(:mentioned_issue) { create(:issue, assignees: issue.assignees) }
- let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@mention referenced, @unsubscribed_mentioned and @outsider also') }
+ let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: "@mention referenced, @unsubscribed_mentioned and @outsider also") }
before do
build_team(note.project)
@@ -224,7 +224,7 @@ describe NotificationService, :mailer do
project.add_maintainer(assignee)
project.add_maintainer(note.author)
- @u_custom_off = create_user_with_notification(:custom, 'custom_off')
+ @u_custom_off = create_user_with_notification(:custom, "custom_off")
project.add_guest(@u_custom_off)
create(
@@ -232,14 +232,14 @@ describe NotificationService, :mailer do
author: @u_custom_off,
noteable: issue,
project_id: issue.project_id,
- note: 'i think @subscribed_participant should see this'
+ note: "i think @subscribed_participant should see this"
)
update_custom_notification(:new_note, @u_guest_custom, resource: project)
update_custom_notification(:new_note, @u_custom_global)
end
- describe '#new_note' do
+ describe "#new_note" do
it do
add_users_with_subscription(note.project, issue)
reset_delivered_emails!
@@ -286,8 +286,8 @@ describe NotificationService, :mailer do
notification.new_note(mentioned_note)
end
- context 'participating' do
- context 'by note' do
+ context "participating" do
+ context "by note" do
before do
reset_delivered_emails!
note.author = @u_lazy_participant
@@ -300,7 +300,7 @@ describe NotificationService, :mailer do
end
end
- describe 'new note on issue in project that belongs to a group' do
+ describe "new note on issue in project that belongs to a group" do
before do
note.project.namespace_id = group.id
group.add_user(@u_watcher, GroupMember::MAINTAINER)
@@ -313,7 +313,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- shared_examples 'new note notifications' do
+ shared_examples "new note notifications" do
it do
notification.new_note(note)
@@ -333,15 +333,15 @@ describe NotificationService, :mailer do
let(:group) { create(:group) }
- it_behaves_like 'new note notifications'
+ it_behaves_like "new note notifications"
- context 'which is a subgroup', :nested_groups do
+ context "which is a subgroup", :nested_groups do
let!(:parent) { create(:group) }
let!(:group) { create(:group, parent: parent) }
- it_behaves_like 'new note notifications'
+ it_behaves_like "new note notifications"
- it 'overrides child objects with global level' do
+ it "overrides child objects with global level" do
user = create(:user)
parent.add_developer(user)
user.notification_settings_for(parent).watch!
@@ -355,7 +355,7 @@ describe NotificationService, :mailer do
end
end
- context 'confidential issue note' do
+ context "confidential issue note" do
let(:project) { create(:project, :public) }
let(:author) { create(:user) }
let(:assignee) { create(:user) }
@@ -367,7 +367,7 @@ describe NotificationService, :mailer do
let(:note) { create(:note_on_issue, noteable: confidential_issue, project: project, note: "#{author.to_reference} #{assignee.to_reference} #{non_member.to_reference} #{member.to_reference} #{admin.to_reference}") }
let(:guest_watcher) { create_user_with_notification(:watch, "guest-watcher-confidential") }
- it 'filters out users that can not read the issue' do
+ it "filters out users that can not read the issue" do
project.add_developer(member)
project.add_guest(guest)
@@ -386,14 +386,14 @@ describe NotificationService, :mailer do
should_email(admin)
end
- context 'on project that belongs to subgroup', :nested_groups do
+ context "on project that belongs to subgroup", :nested_groups do
let(:group_reporter) { create(:user) }
let(:group_guest) { create(:user) }
let(:parent_group) { create(:group) }
let(:child_group) { create(:group, parent: parent_group) }
let(:project) { create(:project, namespace: child_group) }
- context 'when user is group guest member' do
+ context "when user is group guest member" do
before do
parent_group.add_reporter(group_reporter)
parent_group.add_guest(group_guest)
@@ -402,7 +402,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- it 'does not email guest user' do
+ it "does not email guest user" do
notification.new_note(note)
should_email(group_reporter)
@@ -412,11 +412,11 @@ describe NotificationService, :mailer do
end
end
- context 'issue note mention' do
+ context "issue note mention" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project, assignees: [assignee]) }
let(:mentioned_issue) { create(:issue, assignees: issue.assignees) }
- let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: '@all mentioned') }
+ let(:note) { create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: "@all mentioned") }
before do
build_team(note.project)
@@ -426,8 +426,8 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- describe '#new_note' do
- it 'notifies the team members' do
+ describe "#new_note" do
+ it "notifies the team members" do
notification.new_note(note)
# Make sure @unsubscribed_mentioned is part of the team
@@ -454,7 +454,7 @@ describe NotificationService, :mailer do
should_not_email_nested_group_user(@pg_disabled)
end
- it 'notifies parent group members with mention level', :nested_groups do
+ it "notifies parent group members with mention level", :nested_groups do
note = create(:note_on_issue, noteable: issue, project_id: issue.project_id, note: "@#{@pg_mention.username}")
notification.new_note(note)
@@ -471,10 +471,10 @@ describe NotificationService, :mailer do
end
end
- context 'project snippet note' do
+ context "project snippet note" do
let!(:project) { create(:project, :public) }
let(:snippet) { create(:project_snippet, project: project, author: create(:user)) }
- let(:note) { create(:note_on_project_snippet, noteable: snippet, project_id: project.id, note: '@all mentioned') }
+ let(:note) { create(:note_on_project_snippet, noteable: snippet, project_id: project.id, note: "@all mentioned") }
before do
build_team(project)
@@ -488,8 +488,8 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- describe '#new_note' do
- it 'notifies the team members' do
+ describe "#new_note" do
+ it "notifies the team members" do
notification.new_note(note)
# Notify all team members
note.project.team.members.each do |member|
@@ -514,35 +514,35 @@ describe NotificationService, :mailer do
end
end
- context 'personal snippet note' do
+ context "personal snippet note" do
let(:snippet) { create(:personal_snippet, :public, author: @u_snippet_author) }
- let(:note) { create(:note_on_personal_snippet, noteable: snippet, note: '@mentioned note', author: @u_note_author) }
+ let(:note) { create(:note_on_personal_snippet, noteable: snippet, note: "@mentioned note", author: @u_note_author) }
before do
@u_watcher = create_global_setting_for(create(:user), :watch)
@u_participant = create_global_setting_for(create(:user), :participating)
@u_disabled = create_global_setting_for(create(:user), :disabled)
- @u_mentioned = create_global_setting_for(create(:user, username: 'mentioned'), :mention)
- @u_mentioned_level = create_global_setting_for(create(:user, username: 'participator'), :mention)
- @u_note_author = create(:user, username: 'note_author')
- @u_snippet_author = create(:user, username: 'snippet_author')
- @u_not_mentioned = create_global_setting_for(create(:user, username: 'regular'), :participating)
+ @u_mentioned = create_global_setting_for(create(:user, username: "mentioned"), :mention)
+ @u_mentioned_level = create_global_setting_for(create(:user, username: "participator"), :mention)
+ @u_note_author = create(:user, username: "note_author")
+ @u_snippet_author = create(:user, username: "snippet_author")
+ @u_not_mentioned = create_global_setting_for(create(:user, username: "regular"), :participating)
reset_delivered_emails!
end
let!(:notes) do
[
- create(:note_on_personal_snippet, noteable: snippet, note: 'note', author: @u_watcher),
- create(:note_on_personal_snippet, noteable: snippet, note: 'note', author: @u_participant),
- create(:note_on_personal_snippet, noteable: snippet, note: 'note', author: @u_mentioned),
- create(:note_on_personal_snippet, noteable: snippet, note: 'note', author: @u_disabled),
- create(:note_on_personal_snippet, noteable: snippet, note: 'note', author: @u_note_author)
+ create(:note_on_personal_snippet, noteable: snippet, note: "note", author: @u_watcher),
+ create(:note_on_personal_snippet, noteable: snippet, note: "note", author: @u_participant),
+ create(:note_on_personal_snippet, noteable: snippet, note: "note", author: @u_mentioned),
+ create(:note_on_personal_snippet, noteable: snippet, note: "note", author: @u_disabled),
+ create(:note_on_personal_snippet, noteable: snippet, note: "note", author: @u_note_author),
]
end
- describe '#new_note' do
- it 'notifies the participants' do
+ describe "#new_note" do
+ it "notifies the participants" do
notification.new_note(note)
# it emails participants
@@ -563,7 +563,7 @@ describe NotificationService, :mailer do
end
end
- context 'commit note' do
+ context "commit note" do
let(:project) { create(:project, :public, :repository) }
let(:note) { create(:note_on_commit, project: project) }
@@ -576,7 +576,7 @@ describe NotificationService, :mailer do
update_custom_notification(:new_note, @u_custom_global)
end
- describe '#new_note, #perform_enqueued_jobs' do
+ describe "#new_note, #perform_enqueued_jobs" do
it do
notification.new_note(note)
should_email(@u_guest_watcher)
@@ -594,7 +594,7 @@ describe NotificationService, :mailer do
end
it do
- note.update_attribute(:note, '@mention referenced')
+ note.update_attribute(:note, "@mention referenced")
notification.new_note(note)
should_email(@u_guest_watcher)
@@ -629,7 +629,7 @@ describe NotificationService, :mailer do
project.add_maintainer(merge_request.assignee)
end
- describe '#new_note' do
+ describe "#new_note" do
it "records sent notifications" do
# 3 SentNotification are sent: the MR assignee and author, and the @u_watcher
expect(SentNotification).to receive(:record_note).with(note, any_args).exactly(3).times.and_call_original
@@ -644,11 +644,11 @@ describe NotificationService, :mailer do
end
end
- describe 'Issues' do
+ describe "Issues" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
let(:another_project) { create(:project, :public, namespace: group) }
- let(:issue) { create :issue, project: project, assignees: [assignee], description: 'cc @participant @unsubscribed_mentioned' }
+ let(:issue) { create :issue, project: project, assignees: [assignee], description: "cc @participant @unsubscribed_mentioned" }
before do
build_team(issue.project)
@@ -660,7 +660,7 @@ describe NotificationService, :mailer do
update_custom_notification(:new_issue, @u_custom_global)
end
- describe '#new_issue' do
+ describe "#new_issue" do
it do
notification.new_issue(issue, @u_disabled)
@@ -689,17 +689,17 @@ describe NotificationService, :mailer do
should_not_email(issue.assignees.first)
end
- it 'properly prioritizes notification reason' do
+ it "properly prioritizes notification reason" do
# have assignee be both assigned and mentioned
issue.update_attribute(:description, "/cc #{assignee.to_reference} #{@u_mentioned.to_reference}")
notification.new_issue(issue, @u_disabled)
email = find_email_for(assignee)
- expect(email).to have_header('X-GitLab-NotificationReason', 'assigned')
+ expect(email).to have_header("X-GitLab-NotificationReason", "assigned")
email = find_email_for(@u_mentioned)
- expect(email).to have_header('X-GitLab-NotificationReason', 'mentioned')
+ expect(email).to have_header("X-GitLab-NotificationReason", "mentioned")
end
it 'adds "assigned" reason for assignees if any' do
@@ -707,7 +707,7 @@ describe NotificationService, :mailer do
email = find_email_for(assignee)
- expect(email).to have_header('X-GitLab-NotificationReason', 'assigned')
+ expect(email).to have_header("X-GitLab-NotificationReason", "assigned")
end
it "emails any mentioned users with the mention level" do
@@ -717,7 +717,7 @@ describe NotificationService, :mailer do
email = find_email_for(@u_mentioned)
expect(email).not_to be_nil
- expect(email).to have_header('X-GitLab-NotificationReason', 'mentioned')
+ expect(email).to have_header("X-GitLab-NotificationReason", "mentioned")
end
it "emails the author if they've opted into notifications about their activity" do
@@ -755,14 +755,14 @@ describe NotificationService, :mailer do
should_email(user_4)
end
- context 'confidential issues' do
+ context "confidential issues" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
- let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
+ let(:confidential_issue) { create(:issue, :confidential, project: project, title: "Confidential issue", author: author, assignees: [assignee]) }
it "emails subscribers of the issue's labels that can read the issue" do
project.add_developer(member)
@@ -792,20 +792,20 @@ describe NotificationService, :mailer do
end
end
- describe '#new_mentions_in_issue' do
+ describe "#new_mentions_in_issue" do
let(:notification_method) { :new_mentions_in_issue }
let(:mentionable) { issue }
- include_examples 'notifications for new mentions'
+ include_examples "notifications for new mentions"
end
- describe '#reassigned_issue' do
+ describe "#reassigned_issue" do
before do
update_custom_notification(:reassign_issue, @u_guest_custom, resource: project)
update_custom_notification(:reassign_issue, @u_custom_global)
end
- it 'emails new assignee' do
+ it "emails new assignee" do
notification.reassigned_issue(issue, @u_disabled, [assignee])
should_email(issue.assignees.first)
@@ -826,7 +826,7 @@ describe NotificationService, :mailer do
email = find_email_for(assignee)
- expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ expect(email).to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
it 'emails previous assignee even if he has the "on mention" notif level' do
@@ -864,7 +864,7 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it 'emails new assignee' do
+ it "emails new assignee" do
issue.assignees = [@u_mentioned]
notification.reassigned_issue(issue, @u_disabled, [@u_mentioned])
@@ -882,7 +882,7 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it 'does not email new assignee if they are the current user' do
+ it "does not email new assignee if they are the current user" do
issue.assignees = [@u_mentioned]
notification.reassigned_issue(issue, @u_mentioned, [@u_mentioned])
@@ -900,18 +900,18 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { issue }
let(:notification_trigger) { notification.reassigned_issue(issue, @u_disabled, [assignee]) }
end
end
- describe '#relabeled_issue' do
- let(:group_label_1) { create(:group_label, group: group, title: 'Group Label 1', issues: [issue]) }
- let(:group_label_2) { create(:group_label, group: group, title: 'Group Label 2') }
- let(:label_1) { create(:label, project: project, title: 'Label 1', issues: [issue]) }
- let(:label_2) { create(:label, project: project, title: 'Label 2') }
+ describe "#relabeled_issue" do
+ let(:group_label_1) { create(:group_label, group: group, title: "Group Label 1", issues: [issue]) }
+ let(:group_label_2) { create(:group_label, group: group, title: "Group Label 2") }
+ let(:label_1) { create(:label, project: project, title: "Label 1", issues: [issue]) }
+ let(:label_2) { create(:label, project: project, title: "Label 2") }
let!(:subscriber_to_group_label_1) { create(:user) { |u| group_label_1.toggle_subscription(u, project) } }
let!(:subscriber_1_to_group_label_2) { create(:user) { |u| group_label_2.toggle_subscription(u, project) } }
let!(:subscriber_2_to_group_label_2) { create(:user) { |u| group_label_2.toggle_subscription(u) } }
@@ -953,9 +953,9 @@ describe NotificationService, :mailer do
end
it "doesn't send multiple email when a user is subscribed to multiple given labels" do
- subscriber_to_both = create(:user) do |user|
+ subscriber_to_both = create(:user) { |user|
[label_1, label_2].each { |label| label.toggle_subscription(user, project) }
- end
+ }
notification.relabeled_issue(issue, [label_1, label_2], @u_disabled)
@@ -964,14 +964,14 @@ describe NotificationService, :mailer do
should_email(subscriber_to_both)
end
- context 'confidential issues' do
+ context "confidential issues" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
- let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
+ let(:confidential_issue) { create(:issue, :confidential, project: project, title: "Confidential issue", author: author, assignees: [assignee]) }
let!(:label_1) { create(:label, project: project, issues: [confidential_issue]) }
let!(:label_2) { create(:label, project: project) }
@@ -1000,8 +1000,8 @@ describe NotificationService, :mailer do
end
end
- describe '#removed_milestone_issue' do
- it_behaves_like 'altered milestone notification on issue' do
+ describe "#removed_milestone_issue" do
+ it_behaves_like "altered milestone notification on issue" do
let(:milestone) { create(:milestone, project: project, issues: [issue]) }
let!(:subscriber_to_new_milestone) { create(:user) { |u| issue.toggle_subscription(u, project) } }
@@ -1010,14 +1010,14 @@ describe NotificationService, :mailer do
end
end
- context 'confidential issues' do
+ context "confidential issues" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
- let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
+ let(:confidential_issue) { create(:issue, :confidential, project: project, title: "Confidential issue", author: author, assignees: [assignee]) }
let(:milestone) { create(:milestone, project: project, issues: [confidential_issue]) }
it "emails subscribers of the issue's milestone that can read the issue" do
@@ -1045,8 +1045,8 @@ describe NotificationService, :mailer do
end
end
- describe '#changed_milestone_issue' do
- it_behaves_like 'altered milestone notification on issue' do
+ describe "#changed_milestone_issue" do
+ it_behaves_like "altered milestone notification on issue" do
let(:new_milestone) { create(:milestone, project: project, issues: [issue]) }
let!(:subscriber_to_new_milestone) { create(:user) { |u| issue.toggle_subscription(u, project) } }
@@ -1055,14 +1055,14 @@ describe NotificationService, :mailer do
end
end
- context 'confidential issues' do
+ context "confidential issues" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
- let(:confidential_issue) { create(:issue, :confidential, project: project, title: 'Confidential issue', author: author, assignees: [assignee]) }
+ let(:confidential_issue) { create(:issue, :confidential, project: project, title: "Confidential issue", author: author, assignees: [assignee]) }
let(:new_milestone) { create(:milestone, project: project, issues: [confidential_issue]) }
it "emails subscribers of the issue's milestone that can read the issue" do
@@ -1090,13 +1090,13 @@ describe NotificationService, :mailer do
end
end
- describe '#close_issue' do
+ describe "#close_issue" do
before do
update_custom_notification(:close_issue, @u_guest_custom, resource: project)
update_custom_notification(:close_issue, @u_custom_global)
end
- it 'sends 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.assignees.first)
@@ -1114,20 +1114,20 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { issue }
let(:notification_trigger) { notification.close_issue(issue, @u_disabled) }
end
end
- describe '#reopen_issue' do
+ describe "#reopen_issue" do
before do
update_custom_notification(:reopen_issue, @u_guest_custom, resource: project)
update_custom_notification(:reopen_issue, @u_custom_global)
end
- it 'sends email to issue notification recipients' do
+ it "sends email to issue notification recipients" do
notification.reopen_issue(issue, @u_disabled)
should_email(issue.assignees.first)
@@ -1145,17 +1145,17 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { issue }
let(:notification_trigger) { notification.reopen_issue(issue, @u_disabled) }
end
end
- describe '#issue_moved' do
+ describe "#issue_moved" do
let(:new_issue) { create(:issue) }
- it 'sends email to issue notification recipients' do
+ it "sends email to issue notification recipients" do
notification.issue_moved(issue, new_issue, @u_disabled)
should_email(issue.assignees.first)
@@ -1171,14 +1171,14 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { issue }
let(:notification_trigger) { notification.issue_moved(issue, new_issue, @u_disabled) }
end
end
- describe '#issue_due' do
+ describe "#issue_due" do
before do
issue.update!(due_date: Date.today)
@@ -1186,7 +1186,7 @@ describe NotificationService, :mailer do
update_custom_notification(:issue_due, @u_custom_global)
end
- it 'sends email to issue notification recipients, excluding watchers' do
+ it "sends email to issue notification recipients, excluding watchers" do
notification.issue_due(issue)
should_email(issue.assignees.first)
@@ -1204,26 +1204,26 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it 'sends the email from the author' do
+ it "sends the email from the author" do
notification.issue_due(issue)
email = find_email_for(@subscriber)
expect(email.header[:from].display_names).to eq([issue.author.name])
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { issue }
let(:notification_trigger) { notification.issue_due(issue) }
end
end
end
- describe 'Merge Requests' do
+ describe "Merge Requests" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, :repository, namespace: group) }
let(:another_project) { create(:project, :public, namespace: group) }
- let(:merge_request) { create :merge_request, source_project: project, assignee: create(:user), description: 'cc @participant' }
+ let(:merge_request) { create :merge_request, source_project: project, assignee: create(:user), description: "cc @participant" }
before do
project.add_maintainer(merge_request.author)
@@ -1235,7 +1235,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- describe '#new_merge_request' do
+ describe "#new_merge_request" do
it do
notification.new_merge_request(merge_request, @u_disabled)
@@ -1256,7 +1256,7 @@ describe NotificationService, :mailer do
email = find_email_for(merge_request.assignee)
- expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ expect(email).to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
it "emails any mentioned users with the mention level" do
@@ -1275,7 +1275,7 @@ describe NotificationService, :mailer do
should_email(merge_request.author)
email = find_email_for(merge_request.author)
- expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::OWN_ACTIVITY)
+ expect(email).to have_header("X-GitLab-NotificationReason", NotificationReason::OWN_ACTIVITY)
end
it "doesn't email the author if they haven't opted into notifications about their activity" do
@@ -1304,21 +1304,21 @@ describe NotificationService, :mailer do
should_email(user_4)
end
- context 'participating' do
- it_should_behave_like 'participating by assignee notification' do
- let(:participant) { create(:user, username: 'user-participant')}
+ context "participating" do
+ it_should_behave_like "participating by assignee notification" do
+ let(:participant) { create(:user, username: "user-participant")}
let(:issuable) { merge_request }
let(:notification_trigger) { notification.new_merge_request(merge_request, @u_disabled) }
end
- it_should_behave_like 'participating by note notification' do
- let(:participant) { create(:user, username: 'user-participant')}
+ it_should_behave_like "participating by note notification" do
+ let(:participant) { create(:user, username: "user-participant")}
let(:issuable) { merge_request }
let(:notification_trigger) { notification.new_merge_request(merge_request, @u_disabled) }
end
- context 'by author' do
- let(:participant) { create(:user, username: 'user-participant')}
+ context "by author" do
+ let(:participant) { create(:user, username: "user-participant")}
before do
merge_request.author = participant
@@ -1331,14 +1331,14 @@ describe NotificationService, :mailer do
end
end
- describe '#new_mentions_in_merge_request' do
+ describe "#new_mentions_in_merge_request" do
let(:notification_method) { :new_mentions_in_merge_request }
let(:mentionable) { merge_request }
- include_examples 'notifications for new mentions'
+ include_examples "notifications for new mentions"
end
- describe '#reassigned_merge_request' do
+ describe "#reassigned_merge_request" do
let(:current_user) { create(:user) }
before do
@@ -1369,17 +1369,17 @@ describe NotificationService, :mailer do
email = find_email_for(merge_request.assignee)
- expect(email).to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED)
+ expect(email).to have_header("X-GitLab-NotificationReason", NotificationReason::ASSIGNED)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.reassigned_merge_request(merge_request, current_user, merge_request.author) }
end
end
- describe '#push_to_merge_request' do
+ describe "#push_to_merge_request" do
before do
update_custom_notification(:push_to_merge_request, @u_guest_custom, resource: project)
update_custom_notification(:push_to_merge_request, @u_custom_global)
@@ -1402,18 +1402,18 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.push_to_merge_request(merge_request, @u_disabled) }
end
end
- describe '#relabel_merge_request' do
- let(:group_label_1) { create(:group_label, group: group, title: 'Group Label 1', merge_requests: [merge_request]) }
- let(:group_label_2) { create(:group_label, group: group, title: 'Group Label 2') }
- let(:label_1) { create(:label, project: project, title: 'Label 1', merge_requests: [merge_request]) }
- let(:label_2) { create(:label, project: project, title: 'Label 2') }
+ describe "#relabel_merge_request" do
+ let(:group_label_1) { create(:group_label, group: group, title: "Group Label 1", merge_requests: [merge_request]) }
+ let(:group_label_2) { create(:group_label, group: group, title: "Group Label 2") }
+ let(:label_1) { create(:label, project: project, title: "Label 1", merge_requests: [merge_request]) }
+ let(:label_2) { create(:label, project: project, title: "Label 2") }
let!(:subscriber_to_group_label_1) { create(:user) { |u| group_label_1.toggle_subscription(u, project) } }
let!(:subscriber_1_to_group_label_2) { create(:user) { |u| group_label_2.toggle_subscription(u, project) } }
let!(:subscriber_2_to_group_label_2) { create(:user) { |u| group_label_2.toggle_subscription(u) } }
@@ -1442,8 +1442,8 @@ describe NotificationService, :mailer do
end
end
- describe '#removed_milestone_merge_request' do
- it_behaves_like 'altered milestone notification on merge request' do
+ describe "#removed_milestone_merge_request" do
+ it_behaves_like "altered milestone notification on merge request" do
let(:milestone) { create(:milestone, project: project, merge_requests: [merge_request]) }
let!(:subscriber_to_new_milestone) { create(:user) { |u| merge_request.toggle_subscription(u, project) } }
@@ -1453,8 +1453,8 @@ describe NotificationService, :mailer do
end
end
- describe '#changed_milestone_merge_request' do
- it_behaves_like 'altered milestone notification on merge request' do
+ describe "#changed_milestone_merge_request" do
+ it_behaves_like "altered milestone notification on merge request" do
let(:new_milestone) { create(:milestone, project: project, merge_requests: [merge_request]) }
let!(:subscriber_to_new_milestone) { create(:user) { |u| merge_request.toggle_subscription(u, project) } }
@@ -1464,7 +1464,7 @@ describe NotificationService, :mailer do
end
end
- describe '#merge_request_unmergeable' do
+ describe "#merge_request_unmergeable" do
it "sends email to merge request author" do
notification.merge_request_unmergeable(merge_request)
@@ -1472,7 +1472,7 @@ describe NotificationService, :mailer do
expect(email_recipients.size).to eq(1)
end
- describe 'when merge_when_pipeline_succeeds is true' do
+ describe "when merge_when_pipeline_succeeds is true" do
before do
merge_request.update(
merge_when_pipeline_succeeds: true,
@@ -1490,7 +1490,7 @@ describe NotificationService, :mailer do
end
end
- describe '#closed_merge_request' do
+ describe "#closed_merge_request" do
before do
update_custom_notification(:close_merge_request, @u_guest_custom, resource: project)
update_custom_notification(:close_merge_request, @u_custom_global)
@@ -1513,14 +1513,14 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.close_mr(merge_request, @u_disabled) }
end
end
- describe '#merged_merge_request' do
+ describe "#merged_merge_request" do
before do
update_custom_notification(:merge_merge_request, @u_guest_custom, resource: project)
update_custom_notification(:merge_merge_request, @u_custom_global)
@@ -1565,14 +1565,14 @@ describe NotificationService, :mailer do
should_email(@u_watcher)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.merge_mr(merge_request, @u_disabled) }
end
end
- describe '#reopen_merge_request' do
+ describe "#reopen_merge_request" do
before do
update_custom_notification(:reopen_merge_request, @u_guest_custom, resource: project)
update_custom_notification(:reopen_merge_request, @u_custom_global)
@@ -1595,8 +1595,8 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.reopen_mr(merge_request, @u_disabled) }
end
@@ -1618,15 +1618,15 @@ describe NotificationService, :mailer do
should_not_email(@u_lazy_participant)
end
- it_behaves_like 'participating notifications' do
- let(:participant) { create(:user, username: 'user-participant') }
+ it_behaves_like "participating notifications" do
+ let(:participant) { create(:user, username: "user-participant") }
let(:issuable) { merge_request }
let(:notification_trigger) { notification.resolve_all_discussions(merge_request, @u_disabled) }
end
end
end
- describe 'Projects' do
+ describe "Projects" do
let(:project) { create(:project) }
before do
@@ -1634,7 +1634,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- describe '#project_was_moved' do
+ describe "#project_was_moved" do
it do
notification.project_was_moved(project, "gitlab/gitlab")
@@ -1647,8 +1647,8 @@ describe NotificationService, :mailer do
should_not_email(@u_disabled)
end
- context 'users not having access to the new location' do
- it 'does not send email' do
+ context "users not having access to the new location" do
+ it "does not send email" do
old_user = create(:user)
ProjectAuthorization.create!(project: project, user: old_user, access_level: Gitlab::Access::GUEST)
@@ -1665,8 +1665,8 @@ describe NotificationService, :mailer do
end
end
- context 'user with notifications disabled' do
- describe '#project_exported' do
+ context "user with notifications disabled" do
+ describe "#project_exported" do
it do
notification.project_exported(project, @u_disabled)
@@ -1674,17 +1674,17 @@ describe NotificationService, :mailer do
end
end
- describe '#project_not_exported' do
+ describe "#project_not_exported" do
it do
- notification.project_not_exported(project, @u_disabled, ['error'])
+ notification.project_not_exported(project, @u_disabled, ["error"])
should_not_email_anyone
end
end
end
- context 'user with notifications enabled' do
- describe '#project_exported' do
+ context "user with notifications enabled" do
+ describe "#project_exported" do
it do
notification.project_exported(project, @u_participating)
@@ -1692,9 +1692,9 @@ describe NotificationService, :mailer do
end
end
- describe '#project_not_exported' do
+ describe "#project_not_exported" do
it do
- notification.project_not_exported(project, @u_participating, ['error'])
+ notification.project_not_exported(project, @u_participating, ["error"])
should_only_email(@u_participating)
end
@@ -1702,10 +1702,10 @@ describe NotificationService, :mailer do
end
end
- describe 'GroupMember' do
+ describe "GroupMember" do
let(:added_user) { create(:user) }
- describe '#new_access_request' do
+ describe "#new_access_request" do
let(:maintainer) { create(:user) }
let(:owner) { create(:user) }
let(:developer) { create(:user) }
@@ -1721,7 +1721,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- it 'sends notification to group owners_and_maintainers' do
+ it "sends notification to group owners_and_maintainers" do
group.request_access(added_user)
should_email(owner)
@@ -1730,7 +1730,7 @@ describe NotificationService, :mailer do
end
end
- describe '#decline_group_invite' do
+ describe "#decline_group_invite" do
let(:creator) { create(:user) }
let(:group) { create(:group) }
let(:member) { create(:user) }
@@ -1743,26 +1743,26 @@ describe NotificationService, :mailer do
it do
group_member = group.members.last
- expect do
+ expect {
notification.decline_group_invite(group_member)
- end.to change { ActionMailer::Base.deliveries.size }.by(1)
+ }.to change { ActionMailer::Base.deliveries.size }.by(1)
end
end
- describe '#new_group_member' do
+ describe "#new_group_member" do
let(:group) { create(:group) }
- it 'sends a notification' do
+ it "sends a notification" do
group.add_guest(added_user)
should_only_email(added_user)
end
- describe 'when notifications are disabled' do
+ describe "when notifications are disabled" do
before do
create_global_setting_for(added_user, :disabled)
end
- it 'does not send a notification' do
+ it "does not send a notification" do
group.add_guest(added_user)
should_not_email_anyone
end
@@ -1770,26 +1770,26 @@ describe NotificationService, :mailer do
end
end
- describe 'ProjectMember' do
+ describe "ProjectMember" do
let(:project) { create(:project) }
set(:added_user) { create(:user) }
- describe '#new_access_request' do
- context 'for a project in a user namespace' do
+ describe "#new_access_request" do
+ context "for a project in a user namespace" do
let(:project) do
create(:project, :public, :access_requestable) do |project|
project.add_maintainer(project.owner)
end
end
- it 'sends notification to project owners_and_maintainers' do
+ it "sends notification to project owners_and_maintainers" do
project.request_access(added_user)
should_only_email(project.owner)
end
end
- context 'for a project in a group' do
+ context "for a project in a group" do
let(:group_owner) { create(:user) }
let(:group) { create(:group).tap { |g| g.add_owner(group_owner) } }
let!(:project) { create(:project, :public, :access_requestable, namespace: group) }
@@ -1798,7 +1798,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- it 'sends notification to group owners_and_maintainers' do
+ it "sends notification to group owners_and_maintainers" do
project.request_access(added_user)
should_only_email(group_owner)
@@ -1806,7 +1806,7 @@ describe NotificationService, :mailer do
end
end
- describe '#decline_group_invite' do
+ describe "#decline_group_invite" do
let(:member) { create(:user) }
before do
@@ -1816,19 +1816,19 @@ describe NotificationService, :mailer do
it do
project_member = project.members.last
- expect do
+ expect {
notification.decline_project_invite(project_member)
- end.to change { ActionMailer::Base.deliveries.size }.by(1)
+ }.to change { ActionMailer::Base.deliveries.size }.by(1)
end
end
- describe '#new_project_member' do
+ describe "#new_project_member" do
it do
create_member!
should_only_email(added_user)
end
- context 'when notifications are disabled' do
+ context "when notifications are disabled" do
before do
create_global_setting_for(added_user, :disabled)
end
@@ -1845,7 +1845,7 @@ describe NotificationService, :mailer do
end
end
- context 'guest user in private project' do
+ context "guest user in private project" do
let(:private_project) { create(:project, :private) }
let(:guest) { create(:user) }
let(:developer) { create(:user) }
@@ -1862,7 +1862,7 @@ describe NotificationService, :mailer do
ActionMailer::Base.deliveries.clear
end
- it 'filters out guests when new note is created' do
+ it "filters out guests when new note is created" do
expect(SentNotification).to receive(:record).with(merge_request, any_args).exactly(1).times
notification.new_note(note)
@@ -1871,28 +1871,28 @@ describe NotificationService, :mailer do
should_email(assignee)
end
- it 'filters out guests when new merge request is created' do
+ it "filters out guests when new merge request is created" do
notification.new_merge_request(merge_request1, @u_disabled)
should_not_email(guest)
should_email(assignee)
end
- it 'filters out guests when merge request is closed' do
+ it "filters out guests when merge request is closed" do
notification.close_mr(merge_request, developer)
should_not_email(guest)
should_email(assignee)
end
- it 'filters out guests when merge request is reopened' do
+ it "filters out guests when merge request is reopened" do
notification.reopen_mr(merge_request, developer)
should_not_email(guest)
should_email(assignee)
end
- it 'filters out guests when merge request is merged' do
+ it "filters out guests when merge request is merged" do
notification.merge_mr(merge_request, developer)
should_not_email(guest)
@@ -1900,25 +1900,25 @@ describe NotificationService, :mailer do
end
end
- describe 'Pipelines' do
- describe '#pipeline_finished' do
+ describe "Pipelines" do
+ describe "#pipeline_finished" do
let(:project) { create(:project, :public, :repository) }
let(:u_member) { create(:user) }
- let(:u_watcher) { create_user_with_notification(:watch, 'watcher') }
+ let(:u_watcher) { create_user_with_notification(:watch, "watcher") }
let(:u_custom_notification_unset) do
- create_user_with_notification(:custom, 'custom_unset')
+ create_user_with_notification(:custom, "custom_unset")
end
let(:u_custom_notification_enabled) do
- user = create_user_with_notification(:custom, 'custom_enabled')
+ user = create_user_with_notification(:custom, "custom_enabled")
update_custom_notification(:success_pipeline, user, resource: project)
update_custom_notification(:failed_pipeline, user, resource: project)
user
end
let(:u_custom_notification_disabled) do
- user = create_user_with_notification(:custom, 'custom_disabled')
+ user = create_user_with_notification(:custom, "custom_disabled")
update_custom_notification(:success_pipeline, user, resource: project, value: false)
update_custom_notification(:failed_pipeline, user, resource: project, value: false)
user
@@ -1928,11 +1928,11 @@ describe NotificationService, :mailer do
def create_pipeline(user, status)
create(:ci_pipeline, status,
- project: project,
- user: user,
- ref: 'refs/heads/master',
- sha: commit.id,
- before_sha: '00000000')
+ project: project,
+ user: user,
+ ref: "refs/heads/master",
+ sha: commit.id,
+ before_sha: "00000000")
end
before do
@@ -1945,120 +1945,120 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- context 'with a successful pipeline' do
- context 'when the creator has default settings' do
+ context "with a successful pipeline" do
+ context "when the creator has default settings" do
before do
pipeline = create_pipeline(u_member, :success)
notification.pipeline_finished(pipeline)
end
- it 'notifies nobody' do
+ it "notifies nobody" do
should_not_email_anyone
end
end
- context 'when the creator has watch set' do
+ context "when the creator has watch set" do
before do
pipeline = create_pipeline(u_watcher, :success)
notification.pipeline_finished(pipeline)
end
- it 'notifies nobody' do
+ it "notifies nobody" do
should_not_email_anyone
end
end
- context 'when the creator has custom notifications, but without any set' do
+ context "when the creator has custom notifications, but without any set" do
before do
pipeline = create_pipeline(u_custom_notification_unset, :success)
notification.pipeline_finished(pipeline)
end
- it 'notifies nobody' do
+ it "notifies nobody" do
should_not_email_anyone
end
end
- context 'when the creator has custom notifications disabled' do
+ context "when the creator has custom notifications disabled" do
before do
pipeline = create_pipeline(u_custom_notification_disabled, :success)
notification.pipeline_finished(pipeline)
end
- it 'notifies nobody' do
+ it "notifies nobody" do
should_not_email_anyone
end
end
- context 'when the creator has custom notifications enabled' do
+ context "when the creator has custom notifications enabled" do
before do
pipeline = create_pipeline(u_custom_notification_enabled, :success)
notification.pipeline_finished(pipeline)
end
- it 'emails only the creator' do
+ it "emails only the creator" do
should_only_email(u_custom_notification_enabled, kind: :bcc)
end
end
end
- context 'with a failed pipeline' do
- context 'when the creator has no custom notification set' do
+ context "with a failed pipeline" do
+ context "when the creator has no custom notification set" do
before do
pipeline = create_pipeline(u_member, :failed)
notification.pipeline_finished(pipeline)
end
- it 'emails only the creator' do
+ it "emails only the creator" do
should_only_email(u_member, kind: :bcc)
end
end
- context 'when the creator has watch set' do
+ context "when the creator has watch set" do
before do
pipeline = create_pipeline(u_watcher, :failed)
notification.pipeline_finished(pipeline)
end
- it 'emails only the creator' do
+ it "emails only the creator" do
should_only_email(u_watcher, kind: :bcc)
end
end
- context 'when the creator has custom notifications, but without any set' do
+ context "when the creator has custom notifications, but without any set" do
before do
pipeline = create_pipeline(u_custom_notification_unset, :failed)
notification.pipeline_finished(pipeline)
end
- it 'emails only the creator' do
+ it "emails only the creator" do
should_only_email(u_custom_notification_unset, kind: :bcc)
end
end
- context 'when the creator has custom notifications disabled' do
+ context "when the creator has custom notifications disabled" do
before do
pipeline = create_pipeline(u_custom_notification_disabled, :failed)
notification.pipeline_finished(pipeline)
end
- it 'notifies nobody' do
+ it "notifies nobody" do
should_not_email_anyone
end
end
- context 'when the creator has custom notifications set' do
+ context "when the creator has custom notifications set" do
before do
pipeline = create_pipeline(u_custom_notification_enabled, :failed)
notification.pipeline_finished(pipeline)
end
- it 'emails only the creator' do
+ it "emails only the creator" do
should_only_email(u_custom_notification_enabled, kind: :bcc)
end
end
- context 'when the creator has no read_build access' do
+ context "when the creator has no read_build access" do
before do
pipeline = create_pipeline(u_member, :failed)
project.update(public_builds: false)
@@ -2066,7 +2066,7 @@ describe NotificationService, :mailer do
notification.pipeline_finished(pipeline)
end
- it 'does not send emails' do
+ it "does not send emails" do
should_not_email_anyone
end
end
@@ -2074,11 +2074,11 @@ describe NotificationService, :mailer do
end
end
- describe 'Pages domains' do
+ describe "Pages domains" do
set(:project) { create(:project) }
set(:domain) { create(:pages_domain, project: project) }
set(:u_blocked) { create(:user, :blocked) }
- set(:u_silence) { create_user_with_notification(:disabled, 'silent', project) }
+ set(:u_silence) { create_user_with_notification(:disabled, "silent", project) }
set(:u_owner) { project.owner }
set(:u_maintainer1) { create(:user) }
set(:u_maintainer2) { create(:user) }
@@ -2103,7 +2103,7 @@ describe NotificationService, :mailer do
describe "##{sym}" do
subject(:notify!) { notification.send(sym, domain) }
- it 'emails current watching maintainers' do
+ it "emails current watching maintainers" do
expect(Notify).to receive(:"#{sym}_email").at_least(:once).and_call_original
notify!
@@ -2111,7 +2111,7 @@ describe NotificationService, :mailer do
should_only_email(u_maintainer1, u_maintainer2, u_owner)
end
- it 'emails nobody if the project is missing' do
+ it "emails nobody if the project is missing" do
domain.project = nil
notify!
@@ -2121,24 +2121,24 @@ describe NotificationService, :mailer do
end
end
- describe '#pages_domain_verification_failed' do
- it 'emails current watching maintainers' do
+ describe "#pages_domain_verification_failed" do
+ it "emails current watching maintainers" do
notification.pages_domain_verification_failed(domain)
should_only_email(u_maintainer1, u_maintainer2, u_owner)
end
end
- describe '#pages_domain_enabled' do
- it 'emails current watching maintainers' do
+ describe "#pages_domain_enabled" do
+ it "emails current watching maintainers" do
notification.pages_domain_enabled(domain)
should_only_email(u_maintainer1, u_maintainer2, u_owner)
end
end
- describe '#pages_domain_disabled' do
- it 'emails current watching maintainers' do
+ describe "#pages_domain_disabled" do
+ it "emails current watching maintainers" do
notification.pages_domain_disabled(domain)
should_only_email(u_maintainer1, u_maintainer2, u_owner)
@@ -2146,15 +2146,15 @@ describe NotificationService, :mailer do
end
end
- context 'Auto DevOps notifications' do
- describe '#autodevops_disabled' do
+ context "Auto DevOps notifications" do
+ describe "#autodevops_disabled" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, :repository, :auto_devops, namespace: namespace) }
let(:pipeline_user) { create(:user) }
let(:pipeline) { create(:ci_pipeline, :failed, project: project, user: pipeline_user) }
- it 'emails project owner and user that triggered the pipeline' do
+ it "emails project owner and user that triggered the pipeline" do
notification.autodevops_disabled(pipeline, [owner.email, pipeline_user.email])
should_email(owner)
@@ -2163,33 +2163,33 @@ describe NotificationService, :mailer do
end
end
- describe 'Repository cleanup' do
+ describe "Repository cleanup" do
let(:user) { create(:user) }
let(:project) { create(:project) }
- describe '#repository_cleanup_success' do
- it 'emails the specified user only' do
+ describe "#repository_cleanup_success" do
+ it "emails the specified user only" do
notification.repository_cleanup_success(project, user)
should_email(user)
end
end
- describe '#repository_cleanup_failure' do
- it 'emails the specified user only' do
- notification.repository_cleanup_failure(project, user, 'Some error')
+ describe "#repository_cleanup_failure" do
+ it "emails the specified user only" do
+ notification.repository_cleanup_failure(project, user, "Some error")
should_email(user)
end
end
end
- context 'Remote mirror notifications' do
- describe '#remote_mirror_update_failed' do
+ context "Remote mirror notifications" do
+ describe "#remote_mirror_update_failed" do
let(:project) { create(:project) }
let(:remote_mirror) { create(:remote_mirror, project: project) }
let(:u_blocked) { create(:user, :blocked) }
- let(:u_silence) { create_user_with_notification(:disabled, 'silent-maintainer', project) }
+ let(:u_silence) { create_user_with_notification(:disabled, "silent-maintainer", project) }
let(:u_owner) { project.owner }
let(:u_maintainer1) { create(:user) }
let(:u_maintainer2) { create(:user) }
@@ -2209,7 +2209,7 @@ describe NotificationService, :mailer do
reset_delivered_emails!
end
- it 'emails current watching maintainers' do
+ it "emails current watching maintainers" do
notification.remote_mirror_update_failed(remote_mirror)
should_only_email(u_maintainer1, u_maintainer2, u_owner)
@@ -2220,21 +2220,21 @@ describe NotificationService, :mailer do
def build_team(project)
@u_watcher = create_global_setting_for(create(:user), :watch)
@u_participating = create_global_setting_for(create(:user), :participating)
- @u_participant_mentioned = create_global_setting_for(create(:user, username: 'participant'), :participating)
+ @u_participant_mentioned = create_global_setting_for(create(:user, username: "participant"), :participating)
@u_disabled = create_global_setting_for(create(:user), :disabled)
- @u_mentioned = create_global_setting_for(create(:user, username: 'mention'), :mention)
- @u_committer = create(:user, username: 'committer')
- @u_not_mentioned = create_global_setting_for(create(:user, username: 'regular'), :participating)
- @u_outsider_mentioned = create(:user, username: 'outsider')
- @u_custom_global = create_global_setting_for(create(:user, username: 'custom_global'), :custom)
+ @u_mentioned = create_global_setting_for(create(:user, username: "mention"), :mention)
+ @u_committer = create(:user, username: "committer")
+ @u_not_mentioned = create_global_setting_for(create(:user, username: "regular"), :participating)
+ @u_outsider_mentioned = create(:user, username: "outsider")
+ @u_custom_global = create_global_setting_for(create(:user, username: "custom_global"), :custom)
# User to be participant by default
# This user does not contain any record in notification settings table
# It should be treated with a :participating notification_level
- @u_lazy_participant = create(:user, username: 'lazy-participant')
+ @u_lazy_participant = create(:user, username: "lazy-participant")
- @u_guest_watcher = create_user_with_notification(:watch, 'guest_watching')
- @u_guest_custom = create_user_with_notification(:custom, 'guest_custom')
+ @u_guest_watcher = create_user_with_notification(:watch, "guest_watching")
+ @u_guest_custom = create_user_with_notification(:custom, "guest_custom")
project.add_maintainer(@u_watcher)
project.add_maintainer(@u_participating)
@@ -2254,7 +2254,7 @@ describe NotificationService, :mailer do
project.update(namespace_id: group.id)
# Group member: global=disabled, group=watch
- @g_watcher ||= create_user_with_notification(:watch, 'group_watcher', project.group)
+ @g_watcher ||= create_user_with_notification(:watch, "group_watcher", project.group)
@g_watcher.notification_settings_for(nil).disabled!
# Group member: global=watch, group=global
@@ -2272,19 +2272,19 @@ describe NotificationService, :mailer do
child_group = create(:group, visibility, parent: parent_group)
# Parent group member: global=disabled, parent_group=watch, child_group=global
- @pg_watcher ||= create_user_with_notification(:watch, 'parent_group_watcher', parent_group)
+ @pg_watcher ||= create_user_with_notification(:watch, "parent_group_watcher", parent_group)
@pg_watcher.notification_settings_for(nil).disabled!
# Parent group member: global=global, parent_group=disabled, child_group=global
- @pg_disabled ||= create_user_with_notification(:disabled, 'parent_group_disabled', parent_group)
+ @pg_disabled ||= create_user_with_notification(:disabled, "parent_group_disabled", parent_group)
@pg_disabled.notification_settings_for(nil).global!
# Parent group member: global=global, parent_group=mention, child_group=global
- @pg_mention ||= create_user_with_notification(:mention, 'parent_group_mention', parent_group)
+ @pg_mention ||= create_user_with_notification(:mention, "parent_group_mention", parent_group)
@pg_mention.notification_settings_for(nil).global!
# Parent group member: global=global, parent_group=participating, child_group=global
- @pg_participant ||= create_user_with_notification(:participating, 'parent_group_participant', parent_group)
+ @pg_participant ||= create_user_with_notification(:participating, "parent_group_participant", parent_group)
@pg_mention.notification_settings_for(nil).global!
child_group
@@ -2316,8 +2316,8 @@ describe NotificationService, :mailer do
def add_users_with_subscription(project, issuable)
@subscriber = create :user
@unsubscriber = create :user
- @unsubscribed_mentioned = create :user, username: 'unsubscribed_mentioned'
- @subscribed_participant = create_global_setting_for(create(:user, username: 'subscribed_participant'), :participating)
+ @unsubscribed_mentioned = create :user, username: "unsubscribed_mentioned"
+ @subscribed_participant = create_global_setting_for(create(:user, username: "subscribed_participant"), :participating)
@watcher_and_subscriber = create_global_setting_for(create(:user), :watch)
project.add_maintainer(@subscribed_participant)
diff --git a/spec/services/preview_markdown_service_spec.rb b/spec/services/preview_markdown_service_spec.rb
index 85515d548a7..d2773aa2c7e 100644
--- a/spec/services/preview_markdown_service_spec.rb
+++ b/spec/services/preview_markdown_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PreviewMarkdownService do
let(:user) { create(:user) }
@@ -8,35 +8,35 @@ describe PreviewMarkdownService do
project.add_developer(user)
end
- describe 'user references' do
- let(:params) { { text: "Take a look #{user.to_reference}" } }
+ describe "user references" do
+ let(:params) { {text: "Take a look #{user.to_reference}"} }
let(:service) { described_class.new(project, user, params) }
- it 'returns users referenced in text' do
+ it "returns users referenced in text" do
result = service.execute
expect(result[:users]).to eq [user.username]
end
end
- describe 'suggestions' do
- let(:params) { { text: "```suggestion\nfoo\n```", preview_suggestions: preview_suggestions } }
+ describe "suggestions" do
+ let(:params) { {text: "```suggestion\nfoo\n```", preview_suggestions: preview_suggestions} }
let(:service) { described_class.new(project, user, params) }
- context 'when preview markdown param is present' do
+ context "when preview markdown param is present" do
let(:preview_suggestions) { true }
- it 'returns users referenced in text' do
+ it "returns users referenced in text" do
result = service.execute
- expect(result[:suggestions]).to eq(['foo'])
+ expect(result[:suggestions]).to eq(["foo"])
end
end
- context 'when preview markdown param is not present' do
+ context "when preview markdown param is not present" do
let(:preview_suggestions) { false }
- it 'returns users referenced in text' do
+ it "returns users referenced in text" do
result = service.execute
expect(result[:suggestions]).to eq([])
@@ -44,71 +44,71 @@ describe PreviewMarkdownService do
end
end
- context 'new note with quick actions' do
+ context "new note with quick actions" do
let(:issue) { create(:issue, project: project) }
let(:params) do
{
text: "Please do it\n/assign #{user.to_reference}",
- quick_actions_target_type: 'Issue',
- quick_actions_target_id: issue.id
+ quick_actions_target_type: "Issue",
+ quick_actions_target_id: issue.id,
}
end
let(:service) { described_class.new(project, user, params) }
- it 'removes quick actions from text' do
+ it "removes quick actions from text" do
result = service.execute
- expect(result[:text]).to eq 'Please do it'
+ expect(result[:text]).to eq "Please do it"
end
- it 'explains quick actions effect' do
+ it "explains quick actions effect" do
result = service.execute
expect(result[:commands]).to eq "Assigns #{user.to_reference}."
end
end
- context 'merge request description' do
+ context "merge request description" do
let(:params) do
{
text: "My work\n/estimate 2y",
- quick_actions_target_type: 'MergeRequest'
+ quick_actions_target_type: "MergeRequest",
}
end
let(:service) { described_class.new(project, user, params) }
- it 'removes quick actions from text' do
+ it "removes quick actions from text" do
result = service.execute
- expect(result[:text]).to eq 'My work'
+ expect(result[:text]).to eq "My work"
end
- it 'explains quick actions effect' do
+ it "explains quick actions effect" do
result = service.execute
- expect(result[:commands]).to eq 'Sets time estimate to 2y.'
+ expect(result[:commands]).to eq "Sets time estimate to 2y."
end
end
- context 'commit description' do
+ context "commit description" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
let(:params) do
{
text: "My work\n/tag v1.2.3 Stable release",
- quick_actions_target_type: 'Commit',
- quick_actions_target_id: commit.id
+ quick_actions_target_type: "Commit",
+ quick_actions_target_id: commit.id,
}
end
let(:service) { described_class.new(project, user, params) }
- it 'removes quick actions from text' do
+ it "removes quick actions from text" do
result = service.execute
- expect(result[:text]).to eq 'My work'
+ expect(result[:text]).to eq "My work"
end
- it 'explains quick actions effect' do
+ it "explains quick actions effect" do
result = service.execute
expect(result[:commands]).to eq 'Tags this commit to v1.2.3 with "Stable release".'
diff --git a/spec/services/projects/after_import_service_spec.rb b/spec/services/projects/after_import_service_spec.rb
index 4dd6c6dab86..5ba93adef2a 100644
--- a/spec/services/projects/after_import_service_spec.rb
+++ b/spec/services/projects/after_import_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::AfterImportService do
include GitHelpers
@@ -10,7 +10,7 @@ describe Projects::AfterImportService do
let(:sha) { project.commit.sha }
let(:housekeeping_service) { double(:housekeeping_service) }
- describe '#execute' do
+ describe "#execute" do
before do
allow(Projects::HousekeepingService)
.to receive(:new).with(project).and_return(housekeeping_service)
@@ -19,21 +19,21 @@ describe Projects::AfterImportService do
.to receive(:execute).and_yield
end
- it 'performs housekeeping' do
+ it "performs housekeeping" do
subject.execute
expect(housekeeping_service).to have_received(:execute)
end
- context 'with some refs in refs/pull/**/*' do
+ context "with some refs in refs/pull/**/*" do
before do
- repository.write_ref('refs/pull/1/head', sha)
- repository.write_ref('refs/pull/1/merge', sha)
+ repository.write_ref("refs/pull/1/head", sha)
+ repository.write_ref("refs/pull/1/merge", sha)
subject.execute
end
- it 'removes refs/pull/**/*' do
+ it "removes refs/pull/**/*" do
expect(rugged.references.map(&:name))
.not_to include(%r{\Arefs/pull/})
end
diff --git a/spec/services/projects/after_rename_service_spec.rb b/spec/services/projects/after_rename_service_spec.rb
index b8055a285f2..38cb79e444a 100644
--- a/spec/services/projects/after_rename_service_spec.rb
+++ b/spec/services/projects/after_rename_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::AfterRenameService do
let(:rugged_config) { rugged_repo(project.repository).config }
@@ -11,8 +11,8 @@ describe Projects::AfterRenameService do
let!(:path_after_rename) { "#{project.path}-renamed" }
let!(:full_path_after_rename) { "#{project.full_path}-renamed" }
- describe '#execute' do
- context 'using legacy storage' do
+ describe "#execute" do
+ context "using legacy storage" do
let(:project) { create(:project, :repository, :wiki_repo, :legacy_storage) }
let(:project_storage) { project.send(:storage) }
let(:gitlab_shell) { Gitlab::Shell.new }
@@ -25,7 +25,7 @@ describe Projects::AfterRenameService do
stub_feature_flags(skip_hashed_storage_upgrade: false)
end
- it 'renames a repository' do
+ it "renames a repository" do
stub_container_registry_config(enabled: false)
expect_any_instance_of(SystemHooksService)
@@ -45,51 +45,51 @@ describe Projects::AfterRenameService do
expect_repository_exist("#{full_path_after_rename}.wiki.git")
end
- context 'container registry with images' do
+ context "container registry with images" do
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ stub_container_registry_tags(repository: :any, tags: ["tag"])
project.container_repositories << container_repository
end
- it 'raises a RenameFailedError' do
+ it "raises a RenameFailedError" do
expect { service_execute }.to raise_error(described_class::RenameFailedError)
end
end
- context 'gitlab pages' do
+ context "gitlab pages" do
before do
expect(project_storage).to receive(:rename_repo) { true }
end
- it 'moves pages folder to new location' do
+ it "moves pages folder to new location" do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute
end
end
- context 'attachments' do
+ context "attachments" do
before do
expect(project_storage).to receive(:rename_repo) { true }
end
- it 'moves uploads folder to new location' do
+ it "moves uploads folder to new location" do
expect_any_instance_of(Gitlab::UploadsTransfer).to receive(:rename_project)
service_execute
end
end
- it 'updates project full path in .git/config' do
+ it "updates project full path in .git/config" do
service_execute
- expect(rugged_config['gitlab.fullpath']).to eq(project.full_path)
+ expect(rugged_config["gitlab.fullpath"]).to eq(project.full_path)
end
- it 'updates storage location' do
+ it "updates storage location" do
allow(project_storage).to receive(:rename_repo).and_return(true)
service_execute
@@ -100,8 +100,8 @@ describe Projects::AfterRenameService do
)
end
- context 'with hashed storage upgrade when renaming enabled' do
- it 'calls HashedStorage::MigrationService with correct options' do
+ context "with hashed storage upgrade when renaming enabled" do
+ it "calls HashedStorage::MigrationService with correct options" do
stub_application_setting(hashed_storage_enabled: true)
expect_next_instance_of(::Projects::HashedStorage::MigrationService) do |service|
@@ -113,11 +113,11 @@ describe Projects::AfterRenameService do
end
end
- context 'using hashed storage' do
+ context "using hashed storage" do
let(:project) { create(:project, :repository, skip_disk_validation: true) }
let(:gitlab_shell) { Gitlab::Shell.new }
let(:hash) { Digest::SHA2.hexdigest(project.id.to_s) }
- let(:hashed_prefix) { File.join('@hashed', hash[0..1], hash[2..3]) }
+ let(:hashed_prefix) { File.join("@hashed", hash[0..1], hash[2..3]) }
let(:hashed_path) { File.join(hashed_prefix, hash) }
before do
@@ -129,7 +129,7 @@ describe Projects::AfterRenameService do
stub_application_setting(hashed_storage_enabled: true)
end
- it 'renames a repository' do
+ it "renames a repository" do
stub_container_registry_config(enabled: false)
expect(gitlab_shell).not_to receive(:mv_repository)
@@ -143,45 +143,45 @@ describe Projects::AfterRenameService do
service_execute
end
- context 'container registry with images' do
+ context "container registry with images" do
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ stub_container_registry_tags(repository: :any, tags: ["tag"])
project.container_repositories << container_repository
end
- it 'raises a RenameFailedError' do
+ it "raises a RenameFailedError" do
expect { service_execute }
.to raise_error(described_class::RenameFailedError)
end
end
- context 'gitlab pages' do
- it 'moves pages folder to new location' do
+ context "gitlab pages" do
+ it "moves pages folder to new location" do
expect_any_instance_of(Gitlab::PagesTransfer).to receive(:rename_project)
service_execute
end
end
- context 'attachments' do
+ context "attachments" do
let(:uploader) { create(:upload, :issuable_upload, :with_file, model: project) }
let(:file_uploader) { build(:file_uploader, project: project) }
let(:legacy_storage_path) { File.join(file_uploader.root, legacy_storage.disk_path) }
let(:hashed_storage_path) { File.join(file_uploader.root, hashed_storage.disk_path) }
- it 'keeps uploads folder location unchanged' do
+ it "keeps uploads folder location unchanged" do
expect_any_instance_of(Gitlab::UploadsTransfer).not_to receive(:rename_project)
service_execute
end
- context 'when not rolled out' do
+ context "when not rolled out" do
let(:project) { create(:project, :repository, storage_version: 1, skip_disk_validation: true) }
- it 'moves attachments folder to hashed storage' do
+ it "moves attachments folder to hashed storage" do
expect(File.directory?(legacy_storage_path)).to be_truthy
expect(File.directory?(hashed_storage_path)).to be_falsey
@@ -194,13 +194,13 @@ describe Projects::AfterRenameService do
end
end
- it 'updates project full path in .git/config' do
+ it "updates project full path in .git/config" do
service_execute
- expect(rugged_config['gitlab.fullpath']).to eq(project.full_path)
+ expect(rugged_config["gitlab.fullpath"]).to eq(project.full_path)
end
- it 'updates storage location' do
+ it "updates storage location" do
service_execute
expect(project.project_repository).to have_attributes(
diff --git a/spec/services/projects/auto_devops/disable_service_spec.rb b/spec/services/projects/auto_devops/disable_service_spec.rb
index 76977d7a1a7..86fe5fd3dd0 100644
--- a/spec/services/projects/auto_devops/disable_service_spec.rb
+++ b/spec/services/projects/auto_devops/disable_service_spec.rb
@@ -1,13 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe Projects::AutoDevops::DisableService, '#execute' do
+require "spec_helper"
+
+describe Projects::AutoDevops::DisableService, "#execute" do
let(:project) { create(:project, :repository, :auto_devops) }
let(:auto_devops) { project.auto_devops }
subject { described_class.new(project).execute }
- context 'when Auto DevOps disabled at instance level' do
+ context "when Auto DevOps disabled at instance level" do
before do
stub_application_setting(auto_devops_enabled: false)
end
@@ -15,12 +16,12 @@ describe Projects::AutoDevops::DisableService, '#execute' do
it { is_expected.to be_falsy }
end
- context 'when Auto DevOps enabled at instance level' do
+ context "when Auto DevOps enabled at instance level" do
before do
stub_application_setting(auto_devops_enabled: true)
end
- context 'when Auto DevOps explicitly enabled on project' do
+ context "when Auto DevOps explicitly enabled on project" do
before do
auto_devops.update!(enabled: true)
end
@@ -28,7 +29,7 @@ describe Projects::AutoDevops::DisableService, '#execute' do
it { is_expected.to be_falsy }
end
- context 'when Auto DevOps explicitly disabled on project' do
+ context "when Auto DevOps explicitly disabled on project" do
before do
auto_devops.update!(enabled: false)
end
@@ -36,41 +37,41 @@ describe Projects::AutoDevops::DisableService, '#execute' do
it { is_expected.to be_falsy }
end
- context 'when Auto DevOps is implicitly enabled' do
+ context "when Auto DevOps is implicitly enabled" do
before do
auto_devops.update!(enabled: nil)
end
- context 'when is the first pipeline failure' do
+ context "when is the first pipeline failure" do
before do
create(:ci_pipeline, :failed, :auto_devops_source, project: project)
end
- it 'should disable Auto DevOps for project' do
+ it "should disable Auto DevOps for project" do
subject
expect(auto_devops.enabled).to eq(false)
end
end
- context 'when it is not the first pipeline failure' do
+ context "when it is not the first pipeline failure" do
before do
create_list(:ci_pipeline, 2, :failed, :auto_devops_source, project: project)
end
- it 'should explicitly disable Auto DevOps for project' do
+ it "should explicitly disable Auto DevOps for project" do
subject
expect(auto_devops.reload.enabled).to eq(false)
end
end
- context 'when an Auto DevOps pipeline has succeeded before' do
+ context "when an Auto DevOps pipeline has succeeded before" do
before do
create(:ci_pipeline, :success, :auto_devops_source, project: project)
end
- it 'should not disable Auto DevOps for project' do
+ it "should not disable Auto DevOps for project" do
subject
expect(auto_devops.reload.enabled).to be_nil
@@ -78,21 +79,21 @@ describe Projects::AutoDevops::DisableService, '#execute' do
end
end
- context 'when project does not have an Auto DevOps record related' do
+ context "when project does not have an Auto DevOps record related" do
let(:project) { create(:project, :repository) }
before do
create(:ci_pipeline, :failed, :auto_devops_source, project: project)
end
- it 'should disable Auto DevOps for project' do
+ it "should disable Auto DevOps for project" do
subject
auto_devops = project.reload.auto_devops
expect(auto_devops.enabled).to eq(false)
end
- it 'should create a ProjectAutoDevops record' do
+ it "should create a ProjectAutoDevops record" do
expect { subject }.to change { ProjectAutoDevops.count }.from(0).to(1)
end
end
diff --git a/spec/services/projects/autocomplete_service_spec.rb b/spec/services/projects/autocomplete_service_spec.rb
index 373fe7cb7dd..180b2038f33 100644
--- a/spec/services/projects/autocomplete_service_spec.rb
+++ b/spec/services/projects/autocomplete_service_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::AutocompleteService do
- describe '#issues' do
- describe 'confidential issues' do
+ describe "#issues" do
+ describe "confidential issues" do
let(:author) { create(:user) }
let(:assignee) { create(:user) }
let(:non_member) { create(:user) }
let(:member) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, :public) }
- let!(:issue) { create(:issue, project: project, title: 'Issue 1') }
- 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, assignees: [assignee]) }
+ let!(:issue) { create(:issue, project: project, title: "Issue 1") }
+ 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, assignees: [assignee]) }
- it 'does 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 do
expect(issues.count).to eq 1
end
- it 'does 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 do
expect(issues.count).to eq 1
end
- it 'does 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.add_guest(member)
autocomplete = described_class.new(project, non_member)
@@ -45,7 +45,7 @@ describe Projects::AutocompleteService do
expect(issues.count).to eq 1
end
- it 'lists 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 do
expect(issues.count).to eq 2
end
- it 'lists 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 do
expect(issues.count).to eq 2
end
- it 'lists project confidential issues for project members' do
+ it "lists project confidential issues for project members" do
project.add_developer(member)
autocomplete = described_class.new(project, member)
@@ -77,7 +77,7 @@ describe Projects::AutocompleteService do
expect(issues.count).to eq 3
end
- it 'lists 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)
@@ -89,34 +89,34 @@ describe Projects::AutocompleteService do
end
end
- describe '#milestones' do
+ describe "#milestones" do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, group: group) }
- let!(:group_milestone1) { create(:milestone, group: group, due_date: '2017-01-01', title: 'Second Title') }
- let!(:group_milestone2) { create(:milestone, group: group, due_date: '2017-01-01', title: 'First Title') }
- let!(:project_milestone) { create(:milestone, project: project, due_date: '2016-01-01') }
+ let!(:group_milestone1) { create(:milestone, group: group, due_date: "2017-01-01", title: "Second Title") }
+ let!(:group_milestone2) { create(:milestone, group: group, due_date: "2017-01-01", title: "First Title") }
+ let!(:project_milestone) { create(:milestone, project: project, due_date: "2016-01-01") }
let(:milestone_titles) { described_class.new(project, user).milestones.map(&:title) }
- it 'includes project and group milestones and sorts them correctly' do
+ it "includes project and group milestones and sorts them correctly" do
expect(milestone_titles).to eq([project_milestone.title, group_milestone2.title, group_milestone1.title])
end
- it 'does not include closed milestones' do
+ it "does not include closed milestones" do
group_milestone1.close
expect(milestone_titles).to eq([project_milestone.title, group_milestone2.title])
end
- it 'does not include milestones from other projects in the group' do
+ it "does not include milestones from other projects in the group" do
other_project = create(:project, group: group)
project_milestone.update!(project: other_project)
expect(milestone_titles).to eq([group_milestone2.title, group_milestone1.title])
end
- context 'with nested groups', :nested_groups do
+ context "with nested groups", :nested_groups do
let(:subgroup) { create(:group, :public, parent: group) }
let!(:subgroup_milestone) { create(:milestone, group: subgroup) }
@@ -124,7 +124,7 @@ describe Projects::AutocompleteService do
project.update(namespace: subgroup)
end
- it 'includes project milestones and all acestors milestones' do
+ it "includes project milestones and all acestors milestones" do
expect(milestone_titles).to match_array(
[project_milestone.title, group_milestone2.title, group_milestone1.title, subgroup_milestone.title]
)
@@ -132,10 +132,10 @@ describe Projects::AutocompleteService do
end
end
- describe '#labels_as_hash' do
+ describe "#labels_as_hash" do
def expect_labels_to_equal(labels, expected_labels)
expect(labels.size).to eq(expected_labels.size)
- extract_title = lambda { |label| label['title'] }
+ extract_title = lambda { |label| label["title"] }
expect(labels.map(&extract_title)).to eq(expected_labels.map(&extract_title))
end
@@ -154,7 +154,7 @@ describe Projects::AutocompleteService do
create(:group_member, group: group, user: user)
end
- it 'returns labels from project and ancestor groups' do
+ it "returns labels from project and ancestor groups" do
service = described_class.new(project, user)
results = service.labels_as_hash(nil)
expected_labels = [label1, label2, parent_group_label]
@@ -162,12 +162,12 @@ describe Projects::AutocompleteService do
expect_labels_to_equal(results, expected_labels)
end
- context 'some labels are already assigned' do
+ context "some labels are already assigned" do
before do
issue.labels << label1
end
- it 'marks already assigned as set' do
+ it "marks already assigned as set" do
service = described_class.new(project, user)
results = service.labels_as_hash(issue)
expected_labels = [label1, label2, parent_group_label]
@@ -176,7 +176,7 @@ describe Projects::AutocompleteService do
assigned_label_titles = issue.labels.map(&:title)
results.each do |hash|
- if assigned_label_titles.include?(hash['title'])
+ if assigned_label_titles.include?(hash["title"])
expect(hash[:set]).to eq(true)
else
expect(hash.key?(:set)).to eq(false)
diff --git a/spec/services/projects/batch_open_issues_count_service_spec.rb b/spec/services/projects/batch_open_issues_count_service_spec.rb
index 599aaf62080..20b91ccd64f 100644
--- a/spec/services/projects/batch_open_issues_count_service_spec.rb
+++ b/spec/services/projects/batch_open_issues_count_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::BatchOpenIssuesCountService do
let!(:project_1) { create(:project) }
@@ -6,7 +6,7 @@ describe Projects::BatchOpenIssuesCountService do
let(:subject) { described_class.new([project_1, project_2]) }
- context '#refresh_cache', :use_clean_rails_memory_store_caching do
+ context "#refresh_cache", :use_clean_rails_memory_store_caching do
before do
create(:issue, project: project_1)
create(:issue, project: project_1, confidential: true)
@@ -15,8 +15,8 @@ describe Projects::BatchOpenIssuesCountService do
create(:issue, project: project_2, confidential: true)
end
- context 'when cache is clean' do
- it 'refreshes cache keys correctly' do
+ context "when cache is clean" do
+ it "refreshes cache keys correctly" do
subject.refresh_cache
# It does not update total issues cache
@@ -28,13 +28,13 @@ describe Projects::BatchOpenIssuesCountService do
end
end
- context 'when issues count is already cached' do
+ context "when issues count is already cached" do
before do
create(:issue, project: project_2)
subject.refresh_cache
end
- it 'does update cache again' do
+ it "does update cache again" do
expect(Rails.cache).not_to receive(:write)
subject.refresh_cache
diff --git a/spec/services/projects/cleanup_service_spec.rb b/spec/services/projects/cleanup_service_spec.rb
index 3d4587ce2a1..aa6664f3326 100644
--- a/spec/services/projects/cleanup_service_spec.rb
+++ b/spec/services/projects/cleanup_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CleanupService do
- let(:project) { create(:project, :repository, bfg_object_map: fixture_file_upload('spec/fixtures/bfg_object_map.txt')) }
+ let(:project) { create(:project, :repository, bfg_object_map: fixture_file_upload("spec/fixtures/bfg_object_map.txt")) }
let(:object_map) { project.bfg_object_map }
subject(:service) { described_class.new(project) }
- describe '#execute' do
- it 'runs the apply_bfg_object_map gitaly RPC' do
+ describe "#execute" do
+ it "runs the apply_bfg_object_map gitaly RPC" do
expect_next_instance_of(Gitlab::Git::RepositoryCleaner) do |cleaner|
expect(cleaner).to receive(:apply_bfg_object_map).with(kind_of(IO))
end
@@ -15,7 +15,7 @@ describe Projects::CleanupService do
service.execute
end
- it 'runs garbage collection on the repository' do
+ it "runs garbage collection on the repository" do
expect_next_instance_of(GitGarbageCollectWorker) do |worker|
expect(worker).to receive(:perform)
end
@@ -23,19 +23,19 @@ describe Projects::CleanupService do
service.execute
end
- it 'clears the repository cache' do
+ it "clears the repository cache" do
expect(project.repository).to receive(:expire_all_method_caches)
service.execute
end
- it 'removes the object map file' do
+ it "removes the object map file" do
service.execute
expect(object_map.exists?).to be_falsy
end
- it 'raises an error if no object map can be found' do
+ it "raises an error if no object map can be found" do
object_map.remove!
expect { service.execute }.to raise_error(described_class::NoUploadError)
diff --git a/spec/services/projects/container_repository/cleanup_tags_service_spec.rb b/spec/services/projects/container_repository/cleanup_tags_service_spec.rb
index 0659130bed2..ab26d5df027 100644
--- a/spec/services/projects/container_repository/cleanup_tags_service_spec.rb
+++ b/spec/services/projects/container_repository/cleanup_tags_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ContainerRepository::CleanupTagsService do
set(:user) { create(:user) }
@@ -18,116 +18,117 @@ describe Projects::ContainerRepository::CleanupTagsService do
stub_container_registry_tags(
repository: repository.path,
- tags: %w(latest A Ba Bb C D E))
-
- stub_tag_digest('latest', 'sha256:configA')
- stub_tag_digest('A', 'sha256:configA')
- stub_tag_digest('Ba', 'sha256:configB')
- stub_tag_digest('Bb', 'sha256:configB')
- stub_tag_digest('C', 'sha256:configC')
- stub_tag_digest('D', 'sha256:configD')
- stub_tag_digest('E', nil)
-
- stub_digest_config('sha256:configA', 1.hour.ago)
- stub_digest_config('sha256:configB', 5.days.ago)
- stub_digest_config('sha256:configC', 1.month.ago)
- stub_digest_config('sha256:configD', nil)
+ tags: %w[latest A Ba Bb C D E]
+ )
+
+ stub_tag_digest("latest", "sha256:configA")
+ stub_tag_digest("A", "sha256:configA")
+ stub_tag_digest("Ba", "sha256:configB")
+ stub_tag_digest("Bb", "sha256:configB")
+ stub_tag_digest("C", "sha256:configC")
+ stub_tag_digest("D", "sha256:configD")
+ stub_tag_digest("E", nil)
+
+ stub_digest_config("sha256:configA", 1.hour.ago)
+ stub_digest_config("sha256:configB", 5.days.ago)
+ stub_digest_config("sha256:configC", 1.month.ago)
+ stub_digest_config("sha256:configD", nil)
end
- describe '#execute' do
+ describe "#execute" do
subject { service.execute(repository) }
- context 'when no params are specified' do
+ context "when no params are specified" do
let(:params) { {} }
- it 'does not remove anything' do
+ it "does not remove anything" do
expect_any_instance_of(ContainerRegistry::Client).not_to receive(:delete_repository_tag)
is_expected.to include(status: :success, deleted: [])
end
end
- context 'when regex matching everything is specified' do
+ context "when regex matching everything is specified" do
let(:params) do
- { 'name_regex' => '.*' }
+ {"name_regex" => ".*"}
end
- it 'does remove B* and C' do
+ it "does remove B* and C" do
# The :A cannot be removed as config is shared with :latest
# The :E cannot be removed as it does not have valid manifest
- expect_delete('sha256:configB').twice
- expect_delete('sha256:configC')
- expect_delete('sha256:configD')
+ expect_delete("sha256:configB").twice
+ expect_delete("sha256:configC")
+ expect_delete("sha256:configD")
- is_expected.to include(status: :success, deleted: %w(D Bb Ba C))
+ is_expected.to include(status: :success, deleted: %w[D Bb Ba C])
end
end
- context 'when regex matching specific tags is used' do
+ context "when regex matching specific tags is used" do
let(:params) do
- { 'name_regex' => 'C|D' }
+ {"name_regex" => "C|D"}
end
- it 'does remove C and D' do
- expect_delete('sha256:configC')
- expect_delete('sha256:configD')
+ it "does remove C and D" do
+ expect_delete("sha256:configC")
+ expect_delete("sha256:configD")
- is_expected.to include(status: :success, deleted: %w(D C))
+ is_expected.to include(status: :success, deleted: %w[D C])
end
end
- context 'when removing a tagged image that is used by another tag' do
+ context "when removing a tagged image that is used by another tag" do
let(:params) do
- { 'name_regex' => 'Ba' }
+ {"name_regex" => "Ba"}
end
- it 'does not remove the tag' do
+ it "does not remove the tag" do
# Issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/21405
is_expected.to include(status: :success, deleted: [])
end
end
- context 'when removing keeping only 3' do
+ context "when removing keeping only 3" do
let(:params) do
- { 'name_regex' => '.*',
- 'keep_n' => 3 }
+ {"name_regex" => ".*",
+ "keep_n" => 3,}
end
- it 'does remove C as it is oldest' do
- expect_delete('sha256:configC')
+ it "does remove C as it is oldest" do
+ expect_delete("sha256:configC")
- is_expected.to include(status: :success, deleted: %w(C))
+ is_expected.to include(status: :success, deleted: %w[C])
end
end
- context 'when removing older than 1 day' do
+ context "when removing older than 1 day" do
let(:params) do
- { 'name_regex' => '.*',
- 'older_than' => '1 day' }
+ {"name_regex" => ".*",
+ "older_than" => "1 day",}
end
- it 'does remove B* and C as they are older than 1 day' do
- expect_delete('sha256:configB').twice
- expect_delete('sha256:configC')
+ it "does remove B* and C as they are older than 1 day" do
+ expect_delete("sha256:configB").twice
+ expect_delete("sha256:configC")
- is_expected.to include(status: :success, deleted: %w(Bb Ba C))
+ is_expected.to include(status: :success, deleted: %w[Bb Ba C])
end
end
- context 'when combining all parameters' do
+ context "when combining all parameters" do
let(:params) do
- { 'name_regex' => '.*',
- 'keep_n' => 1,
- 'older_than' => '1 day' }
+ {"name_regex" => ".*",
+ "keep_n" => 1,
+ "older_than" => "1 day",}
end
- it 'does remove B* and C' do
- expect_delete('sha256:configB').twice
- expect_delete('sha256:configC')
+ it "does remove B* and C" do
+ expect_delete("sha256:configB").twice
+ expect_delete("sha256:configC")
- is_expected.to include(status: :success, deleted: %w(Bb Ba C))
+ is_expected.to include(status: :success, deleted: %w[Bb Ba C])
end
end
end
@@ -137,12 +138,12 @@ describe Projects::ContainerRepository::CleanupTagsService do
def stub_tag_digest(tag, digest)
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_tag_digest)
- .with(repository.path, tag) { digest }
+ .with(repository.path, tag) { digest }
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_manifest)
.with(repository.path, tag) do
- { 'config' => { 'digest' => digest } } if digest
+ {"config" => {"digest" => digest}} if digest
end
end
@@ -150,7 +151,7 @@ describe Projects::ContainerRepository::CleanupTagsService do
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:blob)
.with(repository.path, digest, nil) do
- { 'created' => created_at.to_datetime.rfc3339 }.to_json if created_at
+ {"created" => created_at.to_datetime.rfc3339}.to_json if created_at
end
end
diff --git a/spec/services/projects/container_repository/destroy_service_spec.rb b/spec/services/projects/container_repository/destroy_service_spec.rb
index affcc66d2bb..e6a8cc867c8 100644
--- a/spec/services/projects/container_repository/destroy_service_spec.rb
+++ b/spec/services/projects/container_repository/destroy_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ContainerRepository::DestroyService do
set(:user) { create(:user) }
@@ -12,27 +12,27 @@ describe Projects::ContainerRepository::DestroyService do
stub_container_registry_config(enabled: true)
end
- context 'when user does not have access to registry' do
+ context "when user does not have access to registry" do
let!(:repository) { create(:container_repository, :root, project: project) }
- it 'does not delete a repository' do
+ it "does not delete a repository" do
expect { subject.execute(repository) }.not_to change { ContainerRepository.all.count }
end
end
- context 'when user has access to registry' do
+ context "when user has access to registry" do
before do
project.add_developer(user)
end
- context 'when root container repository exists' do
+ context "when root container repository exists" do
let!(:repository) { create(:container_repository, :root, project: project) }
before do
stub_container_registry_tags(repository: :any, tags: [])
end
- it 'deletes the repository' do
+ it "deletes the repository" do
expect(repository).to receive(:delete_tags!).and_call_original
expect { described_class.new(project, user).execute(repository) }.to change { ContainerRepository.all.count }.by(-1)
end
diff --git a/spec/services/projects/count_service_spec.rb b/spec/services/projects/count_service_spec.rb
index 183f6128c7b..2107509d61d 100644
--- a/spec/services/projects/count_service_spec.rb
+++ b/spec/services/projects/count_service_spec.rb
@@ -1,35 +1,35 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CountService do
let(:project) { build(:project, id: 1) }
let(:service) { described_class.new(project) }
- describe '.query' do
- it 'raises NotImplementedError' do
+ describe ".query" do
+ it "raises NotImplementedError" do
expect { described_class.query(project.id) }.to raise_error(NotImplementedError)
end
end
- describe '#relation_for_count' do
- it 'calls the class method query with the project id' do
+ describe "#relation_for_count" do
+ it "calls the class method query with the project id" do
expect(described_class).to receive(:query).with(project.id)
service.relation_for_count
end
end
- describe '#count' do
+ describe "#count" do
before do
- allow(service).to receive(:cache_key_name).and_return('count_service')
+ allow(service).to receive(:cache_key_name).and_return("count_service")
end
- it 'returns the number of rows' do
+ it "returns the number of rows" do
allow(service).to receive(:uncached_count).and_return(1)
expect(service.count).to eq(1)
end
- it 'caches the number of rows', :use_clean_rails_memory_store_caching do
+ it "caches the number of rows", :use_clean_rails_memory_store_caching do
expect(service).to receive(:uncached_count).once.and_return(1)
2.times do
@@ -38,12 +38,12 @@ describe Projects::CountService do
end
end
- describe '#refresh_cache', :use_clean_rails_memory_store_caching do
+ describe "#refresh_cache", :use_clean_rails_memory_store_caching do
before do
- allow(service).to receive(:cache_key_name).and_return('count_service')
+ allow(service).to receive(:cache_key_name).and_return("count_service")
end
- it 'refreshes the cache' do
+ it "refreshes the cache" do
expect(service).to receive(:uncached_count).once.and_return(1)
service.refresh_cache
@@ -52,12 +52,12 @@ describe Projects::CountService do
end
end
- describe '#delete_cache', :use_clean_rails_memory_store_caching do
+ describe "#delete_cache", :use_clean_rails_memory_store_caching do
before do
- allow(service).to receive(:cache_key_name).and_return('count_service')
+ allow(service).to receive(:cache_key_name).and_return("count_service")
end
- it 'removes the cache' do
+ it "removes the cache" do
expect(service).to receive(:uncached_count).twice.and_return(1)
service.count
@@ -66,16 +66,16 @@ describe Projects::CountService do
end
end
- describe '#cache_key_name' do
- it 'raises NotImplementedError' do
+ describe "#cache_key_name" do
+ it "raises NotImplementedError" do
expect { service.cache_key_name }.to raise_error(NotImplementedError)
end
end
- describe '#cache_key' do
- it 'returns the cache key as an Array' do
- allow(service).to receive(:cache_key_name).and_return('foo')
- expect(service.cache_key).to eq(['projects', 'count_service', described_class::VERSION, 1, 'foo'])
+ describe "#cache_key" do
+ it "returns the cache key as an Array" do
+ allow(service).to receive(:cache_key_name).and_return("foo")
+ expect(service.cache_key).to eq(["projects", "count_service", described_class::VERSION, 1, "foo"])
end
end
end
diff --git a/spec/services/projects/create_from_template_service_spec.rb b/spec/services/projects/create_from_template_service_spec.rb
index da078dd36c6..c17df071596 100644
--- a/spec/services/projects/create_from_template_service_spec.rb
+++ b/spec/services/projects/create_from_template_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::CreateFromTemplateService do
let(:user) { create(:user) }
- let(:template_name) { 'rails' }
+ let(:template_name) { "rails" }
let(:project_params) do
{
- path: user.to_param,
- template_name: template_name,
- description: 'project description',
- visibility_level: Gitlab::VisibilityLevel::PUBLIC
+ path: user.to_param,
+ template_name: template_name,
+ description: "project description",
+ visibility_level: Gitlab::VisibilityLevel::PUBLIC,
}
end
subject { described_class.new(user, project_params) }
- it 'calls the importer service' do
+ it "calls the importer service" do
import_service_double = double
allow(Projects::GitlabProjectsImportService).to receive(:new).and_return(import_service_double)
@@ -23,39 +23,39 @@ describe Projects::CreateFromTemplateService do
subject.execute
end
- it 'returns the project thats created' do
+ it "returns the project thats created" do
project = subject.execute
expect(project).to be_saved
expect(project.import_scheduled?).to be(true)
end
- context 'when template is not present' do
- let(:template_name) { 'non_existent' }
+ context "when template is not present" do
+ let(:template_name) { "non_existent" }
let(:project) { subject.execute }
before do
expect(project).to be_saved
end
- it 'does not set import set import type' do
+ it "does not set import set import type" do
expect(project.import_type).to be nil
end
- it 'does not set import set import source' do
+ it "does not set import set import source" do
expect(project.import_source).to be nil
end
- it 'is not scheduled' do
+ it "is not scheduled" do
expect(project.import_scheduled?).to be_nil
end
- it 'repository is empty' do
+ it "repository is empty" do
expect(project.repository.empty?).to be(true)
end
end
- context 'the result project' do
+ context "the result project" do
before do
perform_enqueued_jobs do
@project = subject.execute
@@ -64,11 +64,11 @@ describe Projects::CreateFromTemplateService do
@project.reload
end
- it 'overrides template description' do
- expect(@project.description).to match('project description')
+ it "overrides template description" do
+ expect(@project.description).to match("project description")
end
- it 'overrides template visibility_level' do
+ it "overrides template visibility_level" do
expect(@project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
end
diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb
index d1b110b9806..9714572b8a3 100644
--- a/spec/services/projects/create_service_spec.rb
+++ b/spec/services/projects/create_service_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::CreateService, '#execute' do
+describe Projects::CreateService, "#execute" do
include GitHelpers
let(:gitlab_shell) { Gitlab::Shell.new }
let(:user) { create :user }
let(:opts) do
{
- name: 'GitLab',
- namespace_id: user.namespace.id
+ name: "GitLab",
+ namespace_id: user.namespace.id,
}
end
- it 'creates labels on Project creation if there are templates' do
+ it "creates labels on Project creation if there are templates" do
Label.create(title: "bug", template: true)
project = create_project(user, opts)
created_label = project.reload.labels.last
- expect(created_label.type).to eq('ProjectLabel')
+ expect(created_label.type).to eq("ProjectLabel")
expect(created_label.project_id).to eq(project.id)
- expect(created_label.title).to eq('bug')
+ expect(created_label.title).to eq("bug")
end
- context 'user namespace' do
+ context "user namespace" do
it do
project = create_project(user, opts)
@@ -34,8 +34,8 @@ describe Projects::CreateService, '#execute' do
end
end
- describe 'after create actions' do
- it 'invalidate personal_projects_count caches' do
+ describe "after create actions" do
+ it "invalidate personal_projects_count caches" do
expect(user).to receive(:invalidate_personal_projects_count)
create_project(user, opts)
@@ -43,11 +43,11 @@ describe Projects::CreateService, '#execute' do
end
context "admin creates project with other user's namespace_id" do
- it 'sets the correct permissions' do
+ it "sets the correct permissions" do
admin = create(:admin)
opts = {
- name: 'GitLab',
- namespace_id: user.namespace.id
+ name: "GitLab",
+ namespace_id: user.namespace.id,
}
project = create_project(admin, opts)
@@ -58,7 +58,7 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'group namespace' do
+ context "group namespace" do
let(:group) do
create(:group).tap do |group|
group.add_owner(user)
@@ -79,14 +79,14 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'error handling' do
- it 'handles invalid options' do
- opts[:default_branch] = 'master'
+ context "error handling" do
+ it "handles invalid options" do
+ opts[:default_branch] = "master"
expect(create_project(user, opts)).to eq(nil)
end
- it 'sets invalid service as inactive' do
- create(:service, type: 'JiraService', project: nil, template: true, active: true)
+ it "sets invalid service as inactive" do
+ create(:service, type: "JiraService", project: nil, template: true, active: true)
project = create_project(user, opts)
service = project.services.first
@@ -96,8 +96,8 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'wiki_enabled creates repository directory' do
- context 'wiki_enabled true creates wiki repository directory' do
+ context "wiki_enabled creates repository directory" do
+ context "wiki_enabled true creates wiki repository directory" do
it do
project = create_project(user, opts)
@@ -105,7 +105,7 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'wiki_enabled false does not create wiki repository directory' do
+ context "wiki_enabled false does not create wiki repository directory" do
it do
opts[:wiki_enabled] = false
project = create_project(user, opts)
@@ -115,28 +115,28 @@ describe Projects::CreateService, '#execute' do
end
def wiki_repo(project)
- relative_path = ProjectWiki.new(project).disk_path + '.git'
- Gitlab::Git::Repository.new(project.repository_storage, relative_path, 'foobar', project.full_path)
+ relative_path = ProjectWiki.new(project).disk_path + ".git"
+ Gitlab::Git::Repository.new(project.repository_storage, relative_path, "foobar", project.full_path)
end
end
- context 'import data' do
- it 'stores import data and URL' do
- import_data = { data: { 'test' => 'some data' } }
- project = create_project(user, { name: 'test', import_url: 'http://import-url', import_data: import_data })
+ context "import data" do
+ it "stores import data and URL" do
+ import_data = {data: {"test" => "some data"}}
+ project = create_project(user, {name: "test", import_url: "http://import-url", import_data: import_data})
expect(project.import_data).to be_persisted
expect(project.import_data.data).to eq(import_data[:data])
- expect(project.import_url).to eq('http://import-url')
+ expect(project.import_url).to eq("http://import-url")
end
end
- context 'builds_enabled global setting' do
+ context "builds_enabled global setting" do
let(:project) { create_project(user, opts) }
subject { project.builds_enabled? }
- context 'global builds_enabled false does not enable CI by default' do
+ context "global builds_enabled false does not enable CI by default" do
before do
project.project_feature.update_attribute(:builds_access_level, ProjectFeature::DISABLED)
end
@@ -144,12 +144,12 @@ describe Projects::CreateService, '#execute' do
it { is_expected.to be_falsey }
end
- context 'global builds_enabled true does enable CI by default' do
+ context "global builds_enabled true does enable CI by default" do
it { is_expected.to be_truthy }
end
end
- context 'restricted visibility level' do
+ context "restricted visibility level" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@@ -158,16 +158,16 @@ describe Projects::CreateService, '#execute' do
)
end
- it 'does 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)
expect(project.errors.messages[:visibility_level].first).to(
- match('restricted by your GitLab administrator')
+ match("restricted by your GitLab administrator")
)
end
- it 'allows a restricted visibility level for admins' do
+ it "allows a restricted visibility level for admins" do
admin = create(:admin)
project = create_project(admin, opts)
@@ -176,8 +176,8 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'repository creation' do
- it 'synchronously creates the repository' do
+ context "repository creation" do
+ it "synchronously creates the repository" do
expect_any_instance_of(Project).to receive(:create_repository)
project = create_project(user, opts)
@@ -186,47 +186,47 @@ describe Projects::CreateService, '#execute' do
expect(project.namespace).to eq(user.namespace)
end
- context 'when another repository already exists on disk' do
- let(:repository_storage) { 'default' }
+ context "when another repository already exists on disk" do
+ let(:repository_storage) { "default" }
let(:opts) do
{
- name: 'Existing',
- namespace_id: user.namespace.id
+ name: "Existing",
+ namespace_id: user.namespace.id,
}
end
- context 'with legacy storage' do
+ context "with legacy storage" do
before do
- gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing", 'group/project')
+ gitlab_shell.create_repository(repository_storage, "#{user.namespace.full_path}/existing", "group/project")
end
after do
gitlab_shell.remove_repository(repository_storage, "#{user.namespace.full_path}/existing")
end
- it 'does not allow to create a project when path matches existing repository on disk' do
+ it "does not allow to create a project when path matches existing repository on disk" do
project = create_project(user, opts)
expect(project).not_to be_persisted
expect(project).to respond_to(:errors)
expect(project.errors.messages).to have_key(:base)
- expect(project.errors.messages[:base].first).to match('There is already a repository with that name on disk')
+ expect(project.errors.messages[:base].first).to match("There is already a repository with that name on disk")
end
- it 'does not allow to import project when path matches existing repository on disk' do
- project = create_project(user, opts.merge({ import_url: 'https://gitlab.com/gitlab-org/gitlab-test.git' }))
+ it "does not allow to import project when path matches existing repository on disk" do
+ project = create_project(user, opts.merge({import_url: "https://gitlab.com/gitlab-org/gitlab-test.git"}))
expect(project).not_to be_persisted
expect(project).to respond_to(:errors)
expect(project.errors.messages).to have_key(:base)
- expect(project.errors.messages[:base].first).to match('There is already a repository with that name on disk')
+ expect(project.errors.messages[:base].first).to match("There is already a repository with that name on disk")
end
end
- context 'with hashed storage' do
- let(:hash) { '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' }
- let(:hashed_path) { '@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' }
+ context "with hashed storage" do
+ let(:hash) { "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" }
+ let(:hashed_path) { "@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b" }
before do
stub_application_setting(hashed_storage_enabled: true)
@@ -234,42 +234,42 @@ describe Projects::CreateService, '#execute' do
end
before do
- gitlab_shell.create_repository(repository_storage, hashed_path, 'group/project')
+ gitlab_shell.create_repository(repository_storage, hashed_path, "group/project")
end
after do
gitlab_shell.remove_repository(repository_storage, hashed_path)
end
- it 'does not allow to create a project when path matches existing repository on disk' do
+ it "does not allow to create a project when path matches existing repository on disk" do
project = create_project(user, opts)
expect(project).not_to be_persisted
expect(project).to respond_to(:errors)
expect(project.errors.messages).to have_key(:base)
- expect(project.errors.messages[:base].first).to match('There is already a repository with that name on disk')
+ expect(project.errors.messages[:base].first).to match("There is already a repository with that name on disk")
end
end
end
end
- context 'when readme initialization is requested' do
- it 'creates README.md' do
- opts[:initialize_with_readme] = '1'
+ context "when readme initialization is requested" do
+ it "creates README.md" do
+ opts[:initialize_with_readme] = "1"
project = create_project(user, opts)
expect(project.repository.commit_count).to be(1)
- expect(project.repository.readme.name).to eql('README.md')
- expect(project.repository.readme.data).to include('# GitLab')
+ expect(project.repository.readme.name).to eql("README.md")
+ expect(project.repository.readme.data).to include("# GitLab")
end
end
- context 'when group has kubernetes cluster' do
+ context "when group has kubernetes cluster" do
let(:group_cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:group) { group_cluster.group }
- let(:token) { 'aaaa' }
+ let(:token) { "aaaa" }
let(:service_account_creator) { double(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService, execute: true) }
let(:secrets_fetcher) { double(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService, execute: token) }
@@ -280,7 +280,7 @@ describe Projects::CreateService, '#execute' do
expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).to receive(:new).and_return(secrets_fetcher)
end
- it 'creates kubernetes namespace for the project' do
+ it "creates kubernetes namespace for the project" do
project = create_project(user, opts.merge!(namespace_id: group.id))
expect(project).to be_valid
@@ -291,22 +291,22 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'when there is an active service template' do
+ context "when there is an active service template" do
before do
create(:service, project: nil, template: true, active: true)
end
- it 'creates a service from this template' do
+ it "creates a service from this template" do
project = create_project(user, opts)
expect(project.services.count).to eq 1
end
end
- context 'when a bad service template is created' do
- it 'sets service to be inactive' do
- opts[:import_url] = 'http://www.gitlab.com/gitlab-org/gitlab-ce'
- create(:service, type: 'DroneCiService', project: nil, template: true, active: true)
+ context "when a bad service template is created" do
+ it "sets service to be inactive" do
+ opts[:import_url] = "http://www.gitlab.com/gitlab-org/gitlab-ce"
+ create(:service, type: "DroneCiService", project: nil, template: true, active: true)
project = create_project(user, opts)
service = project.services.first
@@ -316,8 +316,8 @@ describe Projects::CreateService, '#execute' do
end
end
- context 'when skip_disk_validation is used' do
- it 'sets the project attribute' do
+ context "when skip_disk_validation is used" do
+ it "sets the project attribute" do
opts[:skip_disk_validation] = true
project = create_project(user, opts)
@@ -325,8 +325,8 @@ describe Projects::CreateService, '#execute' do
end
end
- it 'calls the passed block' do
- fake_block = double('block')
+ it "calls the passed block" do
+ fake_block = double("block")
opts[:relations_block] = fake_block
expect_next_instance_of(Project) do |project|
@@ -336,11 +336,11 @@ describe Projects::CreateService, '#execute' do
create_project(user, opts)
end
- it 'writes project full path to .git/config' do
+ it "writes project full path to .git/config" do
project = create_project(user, opts)
rugged = rugged_repo(project.repository)
- expect(rugged.config['gitlab.fullpath']).to eq project.full_path
+ expect(rugged.config["gitlab.fullpath"]).to eq project.full_path
end
def create_project(user, opts)
diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb
index dfbdfa2ab69..388515799df 100644
--- a/spec/services/projects/destroy_service_spec.rb
+++ b/spec/services/projects/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DestroyService do
include ProjectForksHelper
@@ -18,17 +18,17 @@ describe Projects::DestroyService do
stub_container_registry_tags(repository: :any, tags: [])
end
- shared_examples 'deleting the project' do
- it 'deletes the project' do
+ shared_examples "deleting the project" do
+ it "deletes the project" do
expect(Project.unscoped.all).not_to include(project)
- expect(project.gitlab_shell.exists?(project.repository_storage, path + '.git')).to be_falsey
- expect(project.gitlab_shell.exists?(project.repository_storage, remove_path + '.git')).to be_falsey
+ expect(project.gitlab_shell.exists?(project.repository_storage, path + ".git")).to be_falsey
+ expect(project.gitlab_shell.exists?(project.repository_storage, remove_path + ".git")).to be_falsey
end
end
- shared_examples 'deleting the project with pipeline and build' do
- context 'with pipeline and build' do # which has optimistic locking
+ shared_examples "deleting the project with pipeline and build" do
+ context "with pipeline and build" do # which has optimistic locking
let!(:pipeline) { create(:ci_pipeline, project: project) }
let!(:build) { create(:ci_build, :artifacts, pipeline: pipeline) }
@@ -38,15 +38,15 @@ describe Projects::DestroyService do
end
end
- it_behaves_like 'deleting the project'
+ it_behaves_like "deleting the project"
end
end
- shared_examples 'handles errors thrown during async destroy' do |error_message|
- it 'does not allow the error to bubble up' do
- expect do
+ shared_examples "handles errors thrown during async destroy" do |error_message|
+ it "does not allow the error to bubble up" do
+ expect {
perform_enqueued_jobs { destroy_project(project, user, {}) }
- end.not_to raise_error
+ }.not_to raise_error
end
it 'unmarks the project as "pending deletion"' do
@@ -55,7 +55,7 @@ describe Projects::DestroyService do
expect(project.reload.pending_delete).to be(false)
end
- it 'stores an error message in `projects.delete_error`' do
+ it "stores an error message in `projects.delete_error`" do
perform_enqueued_jobs { destroy_project(project, user, {}) }
expect(project.reload.delete_error).to be_present
@@ -63,44 +63,44 @@ describe Projects::DestroyService do
end
end
- context 'Sidekiq inline' do
+ context "Sidekiq inline" do
before do
# Run sidekiq immediately to check that renamed repository will be removed
perform_enqueued_jobs { destroy_project(project, user, {}) }
end
- it_behaves_like 'deleting the project'
+ it_behaves_like "deleting the project"
- context 'when has remote mirrors' do
+ context "when has remote mirrors" do
let!(:project) do
create(:project, :repository, namespace: user.namespace).tap do |project|
- project.remote_mirrors.create(url: 'http://test.com')
+ project.remote_mirrors.create(url: "http://test.com")
end
end
let!(:async) { true }
- it 'destroys them' do
+ it "destroys them" do
expect(RemoteMirror.count).to eq(0)
end
end
- it 'invalidates personal_project_count cache' do
+ it "invalidates personal_project_count cache" do
expect(user).to receive(:invalidate_personal_projects_count)
destroy_project(project, user)
end
- context 'when project has exports' do
+ context "when project has exports" do
let!(:project_with_export) do
create(:project, :repository, namespace: user.namespace).tap do |project|
create(:import_export_upload,
- project: project,
- export_file: fixture_file_upload('spec/fixtures/project_export.tar.gz'))
+ project: project,
+ export_file: fixture_file_upload("spec/fixtures/project_export.tar.gz"))
end
end
let!(:async) { true }
- it 'destroys project and export' do
+ it "destroys project and export" do
expect { destroy_project(project_with_export, user) }.to change(ImportExportUpload, :count).by(-1)
expect(Project.all).not_to include(project_with_export)
@@ -108,7 +108,7 @@ describe Projects::DestroyService do
end
end
- context 'Sidekiq fake' do
+ context "Sidekiq fake" do
before do
# Dont run sidekiq to check if renamed repository exists
Sidekiq::Testing.fake! { destroy_project(project, user, {}) }
@@ -119,78 +119,76 @@ describe Projects::DestroyService do
it { expect(Dir.exist?(remove_path)).to be_truthy }
end
- context 'when flushing caches fail' do
+ context "when flushing caches fail" do
before do
new_user = create(:user)
project.team.add_user(new_user, Gitlab::Access::DEVELOPER)
allow_any_instance_of(described_class).to receive(:flush_caches).and_raise(::Redis::CannotConnectError)
end
- it 'keeps project team intact upon an error' do
+ it "keeps project team intact upon an error" do
perform_enqueued_jobs do
- begin
- destroy_project(project, user, {})
- rescue ::Redis::CannotConnectError
- end
+ destroy_project(project, user, {})
+ rescue ::Redis::CannotConnectError
end
expect(project.team.members.count).to eq 2
end
end
- context 'with async_execute' do
+ context "with async_execute" do
let(:async) { true }
- context 'async delete of project with private issue visibility' do
+ context "async delete of project with private issue visibility" do
before do
project.project_feature.update_attribute("issues_access_level", ProjectFeature::PRIVATE)
# Run sidekiq immediately to check that renamed repository will be removed
perform_enqueued_jobs { destroy_project(project, user, {}) }
end
- it_behaves_like 'deleting the project'
+ it_behaves_like "deleting the project"
end
- it_behaves_like 'deleting the project with pipeline and build'
+ it_behaves_like "deleting the project with pipeline and build"
- context 'errors' do
- context 'when `remove_legacy_registry_tags` fails' do
+ context "errors" do
+ context "when `remove_legacy_registry_tags` fails" do
before do
expect_any_instance_of(described_class)
.to receive(:remove_legacy_registry_tags).and_return(false)
end
- it_behaves_like 'handles errors thrown during async destroy', "Failed to remove some tags"
+ it_behaves_like "handles errors thrown during async destroy", "Failed to remove some tags"
end
- context 'when `remove_repository` fails' do
+ context "when `remove_repository` fails" do
before do
expect_any_instance_of(described_class)
.to receive(:remove_repository).and_return(false)
end
- it_behaves_like 'handles errors thrown during async destroy', "Failed to remove project repository"
+ it_behaves_like "handles errors thrown during async destroy", "Failed to remove project repository"
end
- context 'when `execute` raises expected error' do
+ context "when `execute` raises expected error" do
before do
expect_any_instance_of(Project)
.to receive(:destroy!).and_raise(StandardError.new("Other error message"))
end
- it_behaves_like 'handles errors thrown during async destroy', "Other error message"
+ it_behaves_like "handles errors thrown during async destroy", "Other error message"
end
- context 'when `execute` raises unexpected error' do
+ context "when `execute` raises unexpected error" do
before do
expect_any_instance_of(Project)
- .to receive(:destroy!).and_raise(Exception.new('Other error message'))
+ .to receive(:destroy!).and_raise(Exception.new("Other error message"))
end
- it 'allows error to bubble up and rolls back project deletion' do
- expect do
+ it "allows error to bubble up and rolls back project deletion" do
+ expect {
perform_enqueued_jobs { destroy_project(project, user, {}) }
- end.to raise_error(Exception, 'Other error message')
+ }.to raise_error(Exception, "Other error message")
expect(project.reload.pending_delete).to be(false)
expect(project.delete_error).to include("Other error message")
@@ -199,18 +197,18 @@ describe Projects::DestroyService do
end
end
- describe 'container registry' do
- context 'when there are regular container repositories' do
+ describe "container registry" do
+ context "when there are regular container repositories" do
let(:container_repository) { create(:container_repository) }
before do
- stub_container_registry_tags(repository: project.full_path + '/image',
- tags: ['tag'])
+ stub_container_registry_tags(repository: project.full_path + "/image",
+ tags: ["tag"])
project.container_repositories << container_repository
end
- context 'when image repository deletion succeeds' do
- it 'removes tags' do
+ context "when image repository deletion succeeds" do
+ it "removes tags" do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
@@ -218,8 +216,8 @@ describe Projects::DestroyService do
end
end
- context 'when image repository deletion fails' do
- it 'raises an exception' do
+ context "when image repository deletion fails" do
+ it "raises an exception" do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_raise(RuntimeError)
@@ -228,14 +226,14 @@ describe Projects::DestroyService do
end
end
- context 'when there are tags for legacy root repository' do
+ context "when there are tags for legacy root repository" do
before do
stub_container_registry_tags(repository: project.full_path,
- tags: ['tag'])
+ tags: ["tag"])
end
- context 'when image repository tags deletion succeeds' do
- it 'removes tags' do
+ context "when image repository tags deletion succeeds" do
+ it "removes tags" do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
@@ -243,8 +241,8 @@ describe Projects::DestroyService do
end
end
- context 'when image repository tags deletion fails' do
- it 'raises an exception' do
+ context "when image repository tags deletion fails" do
+ it "raises an exception" do
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(false)
@@ -254,7 +252,7 @@ describe Projects::DestroyService do
end
end
- context 'for a forked project with LFS objects' do
+ context "for a forked project with LFS objects" do
let(:forked_project) { fork_project(project, user) }
before do
@@ -262,16 +260,16 @@ describe Projects::DestroyService do
forked_project.reload
end
- it 'destroys the fork' do
+ it "destroys the fork" do
expect { destroy_project(forked_project, user) }
.not_to raise_error
end
end
- context 'as the root of a fork network' do
+ context "as the root of a fork network" do
let!(:fork_network) { create(:fork_network, root_project: project) }
- it 'updates the fork network with the project name' do
+ it "updates the fork network with the project name" do
destroy_project(project, user)
fork_network.reload
@@ -281,13 +279,13 @@ describe Projects::DestroyService do
end
end
- context 'repository +deleted path removal' do
+ context "repository +deleted path removal" do
def removal_path(path)
"#{path}+#{project.id}#{described_class::DELETED_FLAG}"
end
- context 'regular phase' do
- it 'schedules +deleted removal of existing repos' do
+ context "regular phase" do
+ it "schedules +deleted removal of existing repos" do
service = described_class.new(project, user, {})
allow(service).to receive(:schedule_stale_repos_removal)
@@ -298,10 +296,10 @@ describe Projects::DestroyService do
end
end
- context 'stale cleanup' do
+ context "stale cleanup" do
let!(:async) { true }
- it 'schedules +deleted wiki and repo removal' do
+ it "schedules +deleted wiki and repo removal" do
allow(ProjectDestroyWorker).to receive(:perform_async)
expect(GitlabShellWorker).to receive(:perform_in)
@@ -315,8 +313,8 @@ describe Projects::DestroyService do
end
end
- context '#attempt_restore_repositories' do
- let(:path) { project.disk_path + '.git' }
+ context "#attempt_restore_repositories" do
+ let(:path) { project.disk_path + ".git" }
before do
expect(project.gitlab_shell.exists?(project.repository_storage, path)).to be_truthy
@@ -329,7 +327,7 @@ describe Projects::DestroyService do
expect(project.gitlab_shell.exists?(project.repository_storage, remove_path)).to be_truthy
end
- it 'restores the repositories' do
+ it "restores the repositories" do
Sidekiq::Testing.fake! { described_class.new(project, user).attempt_repositories_rollback }
expect(project.gitlab_shell.exists?(project.repository_storage, path)).to be_truthy
diff --git a/spec/services/projects/detect_repository_languages_service_spec.rb b/spec/services/projects/detect_repository_languages_service_spec.rb
index deea1189cdf..6d58c22ee9b 100644
--- a/spec/services/projects/detect_repository_languages_service_spec.rb
+++ b/spec/services/projects/detect_repository_languages_service_spec.rb
@@ -1,47 +1,47 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DetectRepositoryLanguagesService, :clean_gitlab_redis_shared_state do
set(:project) { create(:project, :repository) }
subject { described_class.new(project, project.owner) }
- describe '#execute' do
- context 'without previous detection' do
- it 'inserts new programming languages in the database' do
+ describe "#execute" do
+ context "without previous detection" do
+ it "inserts new programming languages in the database" do
subject.execute
- expect(ProgrammingLanguage.exists?(name: 'Ruby')).to be(true)
+ expect(ProgrammingLanguage.exists?(name: "Ruby")).to be(true)
expect(ProgrammingLanguage.count).to be(4)
end
- it 'inserts the repository langauges' do
+ it "inserts the repository langauges" do
names = subject.execute.map(&:name)
expect(names).to eq(%w[Ruby JavaScript HTML CoffeeScript])
end
end
- context 'with a previous detection' do
+ context "with a previous detection" do
before do
subject.execute
allow(project.repository).to receive(:languages).and_return(
- [{ value: 99.63, label: "Ruby", color: "#701516", highlight: "#701516" },
- { value: 0.3, label: "D", color: "#701516", highlight: "#701516" }]
+ [{value: 99.63, label: "Ruby", color: "#701516", highlight: "#701516"},
+ {value: 0.3, label: "D", color: "#701516", highlight: "#701516"},]
)
end
- it 'updates the repository languages' do
+ it "updates the repository languages" do
repository_languages = subject.execute.map(&:name)
expect(repository_languages).to eq(%w[Ruby D])
end
end
- context 'when no repository exists' do
+ context "when no repository exists" do
set(:project) { create(:project) }
- it 'has no languages' do
+ it "has no languages" do
expect(subject.execute).to be_empty
expect(project.repository_languages).to be_empty
end
diff --git a/spec/services/projects/download_service_spec.rb b/spec/services/projects/download_service_spec.rb
index da236052ebf..d27788b65f8 100644
--- a/spec/services/projects/download_service_spec.rb
+++ b/spec/services/projects/download_service_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::DownloadService do
- describe 'File service' do
+ describe "File service" do
before do
@user = create(:user)
@project = create(:project, creator_id: @user.id, namespace: @user.namespace)
end
- context 'for a URL that is not on whitelist' do
+ context "for a URL that is not on whitelist" do
before do
- url = 'https://code.jquery.com/jquery-2.1.4.min.js'
+ url = "https://code.jquery.com/jquery-2.1.4.min.js"
@link_to_file = download_file(@project, url)
end
it { expect(@link_to_file).to eq(nil) }
end
- context 'for URLs that are on the whitelist' do
+ context "for URLs that are on the whitelist" do
before do
- sham_rack_app = ShamRack.at('mycompany.fogbugz.com').stub
- sham_rack_app.register_resource('/rails_sample.jpg', File.read(Rails.root + 'spec/fixtures/rails_sample.jpg'), 'image/jpg')
- sham_rack_app.register_resource('/doc_sample.txt', File.read(Rails.root + 'spec/fixtures/doc_sample.txt'), 'text/plain')
+ sham_rack_app = ShamRack.at("mycompany.fogbugz.com").stub
+ sham_rack_app.register_resource("/rails_sample.jpg", File.read(Rails.root + "spec/fixtures/rails_sample.jpg"), "image/jpg")
+ sham_rack_app.register_resource("/doc_sample.txt", File.read(Rails.root + "spec/fixtures/doc_sample.txt"), "text/plain")
end
after do
ShamRack.unmount_all
end
- context 'an image file' do
+ context "an image file" do
before do
- url = 'http://mycompany.fogbugz.com/rails_sample.jpg'
+ url = "http://mycompany.fogbugz.com/rails_sample.jpg"
@link_to_file = download_file(@project, url)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file[:url]).to match('rails_sample.jpg') }
- it { expect(@link_to_file[:alt]).to eq('rails_sample') }
+ it { expect(@link_to_file[:url]).to match("rails_sample.jpg") }
+ it { expect(@link_to_file[:alt]).to eq("rails_sample") }
end
- context 'a txt file' do
+ context "a txt file" do
before do
- url = 'http://mycompany.fogbugz.com/doc_sample.txt'
+ url = "http://mycompany.fogbugz.com/doc_sample.txt"
@link_to_file = download_file(@project, url)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file[:url]).to match('doc_sample.txt') }
- it { expect(@link_to_file[:alt]).to eq('doc_sample.txt') }
+ it { expect(@link_to_file[:url]).to match("doc_sample.txt") }
+ it { expect(@link_to_file[:alt]).to eq("doc_sample.txt") }
end
end
end
diff --git a/spec/services/projects/enable_deploy_key_service_spec.rb b/spec/services/projects/enable_deploy_key_service_spec.rb
index 835dae68fcd..b6ebb658b63 100644
--- a/spec/services/projects/enable_deploy_key_service_spec.rb
+++ b/spec/services/projects/enable_deploy_key_service_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::EnableDeployKeyService do
let(:deploy_key) { create(:deploy_key, public: true) }
let(:project) { create(:project) }
let(:user) { project.creator}
- let!(:params) { { key_id: deploy_key.id } }
+ let!(:params) { {key_id: deploy_key.id} }
- it 'enables the key' do
- expect do
+ it "enables the key" do
+ expect {
service.execute
- end.to change { project.deploy_keys.count }.from(0).to(1)
+ }.to change { project.deploy_keys.count }.from(0).to(1)
end
- context 'trying to add an unaccessable key' do
+ context "trying to add an unaccessable key" do
let(:another_key) { create(:another_key) }
- let!(:params) { { key_id: another_key.id } }
+ let!(:params) { {key_id: another_key.id} }
- it 'returns nil if the key cannot be added' do
+ it "returns nil if the key cannot be added" do
expect(service.execute).to be nil
end
end
- context 'add the same key twice' do
+ context "add the same key twice" do
before do
project.deploy_keys << deploy_key
end
- it 'returns existing key' do
+ it "returns existing key" do
expect(service.execute).to eq(deploy_key)
end
end
diff --git a/spec/services/projects/fetch_statistics_increment_service_spec.rb b/spec/services/projects/fetch_statistics_increment_service_spec.rb
index fcfb138aad6..da606397693 100644
--- a/spec/services/projects/fetch_statistics_increment_service_spec.rb
+++ b/spec/services/projects/fetch_statistics_increment_service_spec.rb
@@ -1,15 +1,15 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
module Projects
describe FetchStatisticsIncrementService do
let(:project) { create(:project) }
- describe '#execute' do
+ describe "#execute" do
subject { described_class.new(project).execute }
- it 'creates a new record for today with count == 1' do
+ it "creates a new record for today with count == 1" do
expect { subject }.to change { ProjectDailyStatistic.count }.by(1)
created_stat = ProjectDailyStatistic.last
@@ -24,10 +24,10 @@ module Projects
expect { subject }.not_to change { yesterday_stat.reload.fetch_count }
end
- context 'when the record already exists for today' do
+ context "when the record already exists for today" do
let!(:project_daily_stat) { create(:project_daily_statistic, fetch_count: 5, project: project, date: Date.today) }
- it 'increments the today record count by 1' do
+ it "increments the today record count by 1" do
expect { subject }.to change { project_daily_stat.reload.fetch_count }.to(6)
end
end
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 23ec29cce7b..23380c659b7 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ForkService do
include ProjectForksHelper
include Gitlab::ShellAdapter
- context 'when forking a new project' do
- describe 'fork by user' do
+ context "when forking a new project" do
+ describe "fork by user" do
before do
@from_user = create(:user)
@from_namespace = @from_user.namespace
avatar = fixture_file_upload("spec/fixtures/dk.png", "image/png")
@from_project = create(:project,
- :repository,
- creator_id: @from_user.id,
- namespace: @from_namespace,
- star_count: 107,
- avatar: avatar,
- description: 'wow such project')
+ :repository,
+ creator_id: @from_user.id,
+ namespace: @from_namespace,
+ star_count: 107,
+ avatar: avatar,
+ description: "wow such project")
@to_user = create(:user)
@to_namespace = @to_user.namespace
@from_project.add_user(@to_user, :developer)
end
- context 'fork project' do
- context 'when forker is a guest' do
+ context "fork project" do
+ context "when forker is a guest" do
before do
@guest = create(:user)
@from_project.add_user(@guest, :guest)
@@ -31,9 +31,9 @@ describe Projects::ForkService do
subject { fork_project(@from_project, @guest) }
it { is_expected.not_to be_persisted }
- it { expect(subject.errors[:forked_from_project_id]).to eq(['is forbidden']) }
+ it { expect(subject.errors[:forked_from_project_id]).to eq(["is forbidden"]) }
- it 'does not create a fork network' do
+ it "does not create a fork network" do
expect { subject }.not_to change { @from_project.reload.fork_network }
end
end
@@ -59,7 +59,7 @@ describe Projects::ForkService do
expect(@from_project.avatar.file).to be_exists
end
- it 'flushes the forks count cache of the source project' do
+ it "flushes the forks count cache of the source project" do
expect(@from_project.forks_count).to be_zero
fork_project(@from_project, @to_user)
@@ -67,7 +67,7 @@ describe Projects::ForkService do
expect(@from_project.forks_count).to eq(1)
end
- it 'creates a fork network with the new project and the root project set' do
+ it "creates a fork network with the new project and the root project set" do
to_project
fork_network = @from_project.reload.fork_network
@@ -76,14 +76,14 @@ describe Projects::ForkService do
expect(fork_network.projects).to contain_exactly(@from_project, to_project)
end
- it 'imports the repository of the forked project' do
+ it "imports the repository of the forked project" do
to_project = fork_project(@from_project, @to_user, repository: true)
expect(to_project.empty_repo?).to be_falsy
end
end
- context 'creating a fork of a fork' do
+ context "creating a fork of a fork" do
let(:from_forked_project) { fork_project(@from_project, @to_user) }
let(:other_namespace) do
group = create(:group)
@@ -92,30 +92,30 @@ describe Projects::ForkService do
end
let(:to_project) { fork_project(from_forked_project, @to_user, namespace: other_namespace) }
- it 'sets the root of the network to the root project' do
+ it "sets the root of the network to the root project" do
expect(to_project.fork_network.root_project).to eq(@from_project)
end
- it 'sets the forked_from_project on the membership' do
+ it "sets the forked_from_project on the membership" do
expect(to_project.fork_network_member.forked_from_project).to eq(from_forked_project)
end
end
end
- context 'project already exists' do
+ context "project already exists" do
it "fails due to validation, not transaction failure" do
@existing_project = create(:project, :repository, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user, namespace: @to_namespace)
expect(@existing_project).to be_persisted
expect(@to_project).not_to be_persisted
- expect(@to_project.errors[:name]).to eq(['has already been taken'])
- expect(@to_project.errors[:path]).to eq(['has already been taken'])
+ expect(@to_project.errors[:name]).to eq(["has already been taken"])
+ expect(@to_project.errors[:path]).to eq(["has already been taken"])
end
end
- context 'repository already exists' do
- let(:repository_storage) { 'default' }
+ context "repository already exists" do
+ let(:repository_storage) { "default" }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
before do
@@ -126,16 +126,16 @@ describe Projects::ForkService do
gitlab_shell.remove_repository(repository_storage, "#{@to_user.namespace.full_path}/#{@from_project.path}")
end
- it 'does not allow creation' do
+ it "does not allow creation" do
to_project = fork_project(@from_project, @to_user, namespace: @to_user.namespace)
expect(to_project).not_to be_persisted
expect(to_project.errors.messages).to have_key(:base)
- expect(to_project.errors.messages[:base].first).to match('There is already a repository with that name on disk')
+ expect(to_project.errors.messages[:base].first).to match("There is already a repository with that name on disk")
end
end
- context 'GitLab CI is enabled' do
+ context "GitLab CI is enabled" do
it "forks and enables CI for fork" do
@from_project.enable_ci
@to_project = fork_project(@from_project, @to_user)
@@ -171,24 +171,24 @@ describe Projects::ForkService do
end
end
- describe 'fork to namespace' do
+ describe "fork to namespace" do
before do
@group_owner = create(:user)
@developer = create(:user)
@project = create(:project, :repository,
- creator_id: @group_owner.id,
- star_count: 777,
- description: 'Wow, such a cool project!')
+ creator_id: @group_owner.id,
+ star_count: 777,
+ description: "Wow, such a cool project!")
@group = create(:group)
@group.add_user(@group_owner, GroupMember::OWNER)
@group.add_user(@developer, GroupMember::DEVELOPER)
@project.add_user(@developer, :developer)
@project.add_user(@group_owner, :developer)
- @opts = { namespace: @group }
+ @opts = {namespace: @group}
end
- context 'fork project for group' do
- it 'group owner successfully forks project into the group' do
+ context "fork project for group" do
+ it "group owner successfully forks project into the group" do
to_project = fork_project(@project, @group_owner, @opts)
expect(to_project).to be_persisted
@@ -202,27 +202,27 @@ describe Projects::ForkService do
end
end
- context 'fork project for group when user not owner' do
- it 'group developer fails to fork project into the group' do
+ context "fork project for group when user not owner" 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'])
+ expect(to_project.errors[:namespace]).to eq(["is not valid"])
end
end
- context 'project already exists in group' do
- it 'fails due to validation, not transaction failure' do
+ context "project already exists in group" do
+ it "fails due to validation, not transaction failure" do
existing_project = create(:project, :repository,
- name: @project.name,
- namespace: @group)
+ name: @project.name,
+ namespace: @group)
to_project = fork_project(@project, @group_owner, @opts)
expect(existing_project.persisted?).to be_truthy
- expect(to_project.errors[:name]).to eq(['has already been taken'])
- expect(to_project.errors[:path]).to eq(['has already been taken'])
+ expect(to_project.errors[:name]).to eq(["has already been taken"])
+ expect(to_project.errors[:path]).to eq(["has already been taken"])
end
end
- context 'when the namespace has a lower visibility level than the project' do
- it 'creates the project with the lower visibility level' do
+ context "when the namespace has a lower visibility level than the project" do
+ it "creates the project with the lower visibility level" do
public_project = create(:project, :public)
private_group = create(:group, :private)
group_owner = create(:user)
@@ -236,7 +236,7 @@ describe Projects::ForkService do
end
end
- context 'when forking with object pools' do
+ context "when forking with object pools" do
let(:fork_from_project) { create(:project, :public) }
let(:forker) { create(:user) }
@@ -244,18 +244,18 @@ describe Projects::ForkService do
stub_feature_flags(object_pools: true)
end
- context 'when no pool exists' do
- it 'creates a new object pool' do
+ context "when no pool exists" do
+ it "creates a new object pool" do
forked_project = fork_project(fork_from_project, forker)
expect(forked_project.pool_repository).to eq(fork_from_project.pool_repository)
end
end
- context 'when a pool already exists' do
+ context "when a pool already exists" do
let!(:pool_repository) { create(:pool_repository, source_project: fork_from_project) }
- it 'joins the object pool' do
+ it "joins the object pool" do
forked_project = fork_project(fork_from_project, forker)
expect(forked_project.pool_repository).to eq(fork_from_project.pool_repository)
@@ -263,7 +263,7 @@ describe Projects::ForkService do
end
end
- context 'when linking fork to an existing project' do
+ context "when linking fork to an existing project" do
let(:fork_from_project) { create(:project, :public) }
let(:fork_to_project) { create(:project, :public) }
let(:user) { create(:user) }
@@ -274,8 +274,8 @@ describe Projects::ForkService do
project.fork_network_member&.forked_from_project
end
- context 'if project is already forked' do
- it 'does not create fork relation' do
+ context "if project is already forked" do
+ it "does not create fork relation" do
allow(fork_to_project).to receive(:forked?).and_return(true)
expect(forked_from_project(fork_to_project)).to be_nil
expect(subject.execute(fork_to_project)).to be_nil
@@ -283,8 +283,8 @@ describe Projects::ForkService do
end
end
- context 'if project is not forked' do
- it 'creates fork relation' do
+ context "if project is not forked" do
+ it "creates fork relation" do
expect(fork_to_project.forked?).to be_falsy
expect(forked_from_project(fork_to_project)).to be_nil
@@ -297,7 +297,7 @@ describe Projects::ForkService do
expect(fork_to_project.forked_from_project).to eq fork_from_project
end
- it 'flushes the forks count cache of the source project' do
+ it "flushes the forks count cache of the source project" do
expect(fork_from_project.forks_count).to be_zero
subject.execute(fork_to_project)
@@ -305,7 +305,7 @@ describe Projects::ForkService do
expect(fork_from_project.forks_count).to eq(1)
end
- it 'leaves no LFS objects dangling' do
+ it "leaves no LFS objects dangling" do
create(:lfs_objects_project, project: fork_to_project)
expect { subject.execute(fork_to_project) }
@@ -313,10 +313,10 @@ describe Projects::ForkService do
.to(0)
end
- context 'if the fork is not allowed' do
+ context "if the fork is not allowed" do
let(:fork_from_project) { create(:project, :private) }
- it 'does not delete the LFS objects' do
+ it "does not delete the LFS objects" do
create(:lfs_objects_project, project: fork_to_project)
expect { subject.execute(fork_to_project) }
diff --git a/spec/services/projects/forks_count_service_spec.rb b/spec/services/projects/forks_count_service_spec.rb
index 9f8e7ee18a8..1619313d7a4 100644
--- a/spec/services/projects/forks_count_service_spec.rb
+++ b/spec/services/projects/forks_count_service_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ForksCountService do
- describe '#count' do
- it 'returns the number of forks' do
+ describe "#count" do
+ it "returns the number of forks" do
project = build(:project, id: 42)
service = described_class.new(project)
diff --git a/spec/services/projects/gitlab_projects_import_service_spec.rb b/spec/services/projects/gitlab_projects_import_service_spec.rb
index b5f2c826c97..b1bcc8338bf 100644
--- a/spec/services/projects/gitlab_projects_import_service_spec.rb
+++ b/spec/services/projects/gitlab_projects_import_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::GitlabProjectsImportService do
set(:namespace) { create(:namespace) }
- let(:path) { 'test-path' }
- let(:file) { fixture_file_upload('spec/fixtures/project_export.tar.gz') }
+ let(:path) { "test-path" }
+ let(:file) { fixture_file_upload("spec/fixtures/project_export.tar.gz") }
let(:overwrite) { false }
- let(:import_params) { { namespace_id: namespace.id, path: path, file: file, overwrite: overwrite } }
+ let(:import_params) { {namespace_id: namespace.id, path: path, file: file, overwrite: overwrite} }
subject { described_class.new(namespace.owner, import_params) }
- describe '#execute' do
- it_behaves_like 'gitlab projects import validations'
+ describe "#execute" do
+ it_behaves_like "gitlab projects import validations"
end
end
diff --git a/spec/services/projects/group_links/create_service_spec.rb b/spec/services/projects/group_links/create_service_spec.rb
index ffb270d277e..3de31e6f5f2 100644
--- a/spec/services/projects/group_links/create_service_spec.rb
+++ b/spec/services/projects/group_links/create_service_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::GroupLinks::CreateService, '#execute' do
+describe Projects::GroupLinks::CreateService, "#execute" do
let(:user) { create :user }
let(:group) { create :group }
let(:project) { create :project }
let(:opts) do
{
- link_group_access: '30',
- expires_at: nil
+ link_group_access: "30",
+ expires_at: nil,
}
end
let(:subject) { described_class.new(project, user, opts) }
- it 'adds group to project' do
+ it "adds group to project" do
expect { subject.execute(group) }.to change { project.project_group_links.count }.from(0).to(1)
end
- it 'returns false if group is blank' do
+ it "returns false if group is blank" do
expect { subject.execute(nil) }.not_to change { project.project_group_links.count }
end
end
diff --git a/spec/services/projects/group_links/destroy_service_spec.rb b/spec/services/projects/group_links/destroy_service_spec.rb
index 336ee01ae50..ce87101e2b7 100644
--- a/spec/services/projects/group_links/destroy_service_spec.rb
+++ b/spec/services/projects/group_links/destroy_service_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe Projects::GroupLinks::DestroyService, '#execute' do
+describe Projects::GroupLinks::DestroyService, "#execute" do
let(:group_link) { create :project_group_link }
let(:project) { group_link.project }
let(:user) { create :user }
let(:subject) { described_class.new(project, user) }
- it 'removes group from project' do
+ it "removes group from project" do
expect { subject.execute(group_link) }.to change { project.project_group_links.count }.from(1).to(0)
end
- it 'returns false if group_link is blank' do
+ it "returns false if group_link is blank" do
expect { subject.execute(nil) }.not_to change { project.project_group_links.count }
end
end
diff --git a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
index 61dbb57ec08..bf41c8b0c09 100644
--- a/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_attachments_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::HashedStorage::MigrateAttachmentsService do
subject(:service) { described_class.new(project, project.full_path, logger: nil) }
@@ -12,9 +12,9 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
let(:old_disk_path) { File.join(base_path(legacy_storage), upload.path) }
let(:new_disk_path) { File.join(base_path(hashed_storage), upload.path) }
- context '#execute' do
- context 'when succeeds' do
- it 'moves attachments to hashed storage layout' do
+ context "#execute" do
+ context "when succeeds" do
+ it "moves attachments to hashed storage layout" do
expect(File.file?(old_disk_path)).to be_truthy
expect(File.file?(new_disk_path)).to be_falsey
expect(File.exist?(base_path(legacy_storage))).to be_truthy
@@ -29,23 +29,23 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
expect(File.file?(new_disk_path)).to be_truthy
end
- it 'returns true' do
+ it "returns true" do
expect(service.execute).to be_truthy
end
- it 'sets skipped to false' do
+ it "sets skipped to false" do
service.execute
expect(service.skipped?).to be_falsey
end
end
- context 'when original folder does not exist anymore' do
+ context "when original folder does not exist anymore" do
before do
FileUtils.rm_rf(base_path(legacy_storage))
end
- it 'skips moving folders and go to next' do
+ it "skips moving folders and go to next" do
expect(FileUtils).not_to receive(:mv).with(base_path(legacy_storage), base_path(hashed_storage))
service.execute
@@ -54,23 +54,23 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
expect(File.file?(new_disk_path)).to be_falsey
end
- it 'returns true' do
+ it "returns true" do
expect(service.execute).to be_truthy
end
- it 'sets skipped to true' do
+ it "sets skipped to true" do
service.execute
expect(service.skipped?).to be_truthy
end
end
- context 'when target folder already exists' do
+ context "when target folder already exists" do
before do
FileUtils.mkdir_p(base_path(hashed_storage))
end
- it 'raises AttachmentMigrationError' do
+ it "raises AttachmentMigrationError" do
expect(FileUtils).not_to receive(:mv).with(base_path(legacy_storage), base_path(hashed_storage))
expect { service.execute }.to raise_error(Projects::HashedStorage::AttachmentMigrationError)
@@ -78,14 +78,14 @@ describe Projects::HashedStorage::MigrateAttachmentsService do
end
end
- context '#old_disk_path' do
- it 'returns old disk_path for project' do
+ context "#old_disk_path" do
+ it "returns old disk_path for project" do
expect(service.old_disk_path).to eq(project.full_path)
end
end
- context '#new_disk_path' do
- it 'returns new disk_path for project' do
+ context "#new_disk_path" do
+ it "returns new disk_path for project" do
expect(service.new_disk_path).to eq(project.disk_path)
end
end
diff --git a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
index 0772dc4b85b..edd2d82b93b 100644
--- a/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migrate_repository_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::HashedStorage::MigrateRepositoryService do
include GitHelpers
@@ -10,7 +10,7 @@ describe Projects::HashedStorage::MigrateRepositoryService do
subject(:service) { described_class.new(project, project.disk_path) }
- describe '#execute' do
+ describe "#execute" do
let(:old_disk_path) { legacy_storage.disk_path }
let(:new_disk_path) { hashed_storage.disk_path }
@@ -18,53 +18,53 @@ describe Projects::HashedStorage::MigrateRepositoryService do
allow(service).to receive(:gitlab_shell) { gitlab_shell }
end
- context 'repository lock' do
- it 'tries to lock the repository' do
+ context "repository lock" do
+ it "tries to lock the repository" do
expect(service).to receive(:try_to_set_repository_read_only!)
service.execute
end
- it 'fails when a git operation is in progress' do
+ it "fails when a git operation is in progress" do
allow(project).to receive(:repo_reference_count) { 1 }
expect { service.execute }.to raise_error(Projects::HashedStorage::RepositoryMigrationError)
end
end
- context 'when succeeds' do
- it 'renames project and wiki repositories' do
+ context "when succeeds" do
+ it "renames project and wiki repositories" do
service.execute
expect(gitlab_shell.exists?(project.repository_storage, "#{new_disk_path}.git")).to be_truthy
expect(gitlab_shell.exists?(project.repository_storage, "#{new_disk_path}.wiki.git")).to be_truthy
end
- it 'updates project to be hashed and not read-only' do
+ it "updates project to be hashed and not read-only" do
service.execute
expect(project.hashed_storage?(:repository)).to be_truthy
expect(project.repository_read_only).to be_falsey
end
- it 'move operation is called for both repositories' do
+ it "move operation is called for both repositories" do
expect_move_repository(old_disk_path, new_disk_path)
expect_move_repository("#{old_disk_path}.wiki", "#{new_disk_path}.wiki")
service.execute
end
- it 'writes project full path to .git/config' do
+ it "writes project full path to .git/config" do
service.execute
- rugged_config = rugged_repo(project.repository).config['gitlab.fullpath']
+ rugged_config = rugged_repo(project.repository).config["gitlab.fullpath"]
expect(rugged_config).to eq project.full_path
end
end
- context 'when one move fails' do
- it 'rollsback repositories to original name' do
+ context "when one move fails" do
+ it "rollsback repositories to original name" do
allow(service).to receive(:move_repository).and_call_original
allow(service).to receive(:move_repository).with(old_disk_path, new_disk_path).once { false } # will disable first move only
@@ -77,13 +77,13 @@ describe Projects::HashedStorage::MigrateRepositoryService do
expect(project.repository_read_only?).to be_falsey
end
- context 'when rollback fails' do
+ context "when rollback fails" do
before do
hashed_storage.ensure_storage_path_exists
gitlab_shell.mv_repository(project.repository_storage, old_disk_path, new_disk_path)
end
- it 'does not try to move nil repository over existing' do
+ it "does not try to move nil repository over existing" do
expect(gitlab_shell).not_to receive(:mv_repository).with(project.repository_storage, old_disk_path, new_disk_path)
expect_move_repository("#{old_disk_path}.wiki", "#{new_disk_path}.wiki")
diff --git a/spec/services/projects/hashed_storage/migration_service_spec.rb b/spec/services/projects/hashed_storage/migration_service_spec.rb
index b4647586363..838f1e136d8 100644
--- a/spec/services/projects/hashed_storage/migration_service_spec.rb
+++ b/spec/services/projects/hashed_storage/migration_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::HashedStorage::MigrationService do
let(:project) { create(:project, :empty_repo, :wiki_repo, :legacy_storage) }
@@ -6,21 +6,21 @@ describe Projects::HashedStorage::MigrationService do
subject(:service) { described_class.new(project, project.full_path, logger: logger) }
- describe '#execute' do
- context 'repository migration' do
+ describe "#execute" do
+ context "repository migration" do
let(:repository_service) { Projects::HashedStorage::MigrateRepositoryService.new(project, project.full_path, logger: logger) }
- it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
+ it "delegates migration to Projects::HashedStorage::MigrateRepositoryService" do
expect(Projects::HashedStorage::MigrateRepositoryService)
.to receive(:new)
- .with(project, project.full_path, logger: logger)
- .and_return(repository_service)
+ .with(project, project.full_path, logger: logger)
+ .and_return(repository_service)
expect(repository_service).to receive(:execute)
service.execute
end
- it 'does not delegate migration if repository is already migrated' do
+ it "does not delegate migration if repository is already migrated" do
project.storage_version = ::Project::LATEST_STORAGE_VERSION
expect(Projects::HashedStorage::MigrateRepositoryService).not_to receive(:new)
@@ -28,20 +28,20 @@ describe Projects::HashedStorage::MigrationService do
end
end
- context 'attachments migration' do
+ context "attachments migration" do
let(:attachments_service) { Projects::HashedStorage::MigrateAttachmentsService.new(project, project.full_path, logger: logger) }
- it 'delegates migration to Projects::HashedStorage::MigrateRepositoryService' do
+ it "delegates migration to Projects::HashedStorage::MigrateRepositoryService" do
expect(Projects::HashedStorage::MigrateAttachmentsService)
.to receive(:new)
- .with(project, project.full_path, logger: logger)
- .and_return(attachments_service)
+ .with(project, project.full_path, logger: logger)
+ .and_return(attachments_service)
expect(attachments_service).to receive(:execute)
service.execute
end
- it 'does not delegate migration if attachments are already migrated' do
+ it "does not delegate migration if attachments are already migrated" do
project.storage_version = ::Project::LATEST_STORAGE_VERSION
expect(Projects::HashedStorage::MigrateAttachmentsService).not_to receive(:new)
diff --git a/spec/services/projects/housekeeping_service_spec.rb b/spec/services/projects/housekeeping_service_spec.rb
index 18ecef1c0a1..64f75d2abaf 100644
--- a/spec/services/projects/housekeeping_service_spec.rb
+++ b/spec/services/projects/housekeeping_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::HousekeepingService do
subject { described_class.new(project) }
@@ -12,8 +12,8 @@ describe Projects::HousekeepingService do
project.reset_pushes_since_gc
end
- describe '#execute' do
- it 'enqueues a sidekiq job' do
+ describe "#execute" do
+ it "enqueues a sidekiq job" do
expect(subject).to receive(:try_obtain_lease).and_return(:the_uuid)
expect(subject).to receive(:lease_key).and_return(:the_lease_key)
expect(subject).to receive(:task).and_return(:incremental_repack)
@@ -24,13 +24,13 @@ describe Projects::HousekeepingService do
end
end
- it 'yields the block if given' do
- expect do |block|
+ it "yields the block if given" do
+ expect { |block|
subject.execute(&block)
- end.to yield_with_no_args
+ }.to yield_with_no_args
end
- it 'resets counter after execution' do
+ it "resets counter after execution" do
expect(subject).to receive(:try_obtain_lease).and_return(:the_uuid)
allow(subject).to receive(:gc_period).and_return(1)
project.increment_pushes_since_gc
@@ -40,33 +40,33 @@ describe Projects::HousekeepingService do
end
end
- context 'when no lease can be obtained' do
+ context "when no lease can be obtained" do
before do
expect(subject).to receive(:try_obtain_lease).and_return(false)
end
- it 'does not enqueue a job' do
+ it "does not enqueue a job" do
expect(GitGarbageCollectWorker).not_to receive(:perform_async)
expect { subject.execute }.to raise_error(Projects::HousekeepingService::LeaseTaken)
end
- it 'does not reset pushes_since_gc' do
- expect do
+ it "does not reset pushes_since_gc" do
+ expect {
expect { subject.execute }.to raise_error(Projects::HousekeepingService::LeaseTaken)
- end.not_to change { project.pushes_since_gc }
+ }.not_to change { project.pushes_since_gc }
end
- it 'does not yield' do
- expect do |block|
+ it "does not yield" do
+ expect { |block|
expect { subject.execute(&block) }
.to raise_error(Projects::HousekeepingService::LeaseTaken)
- end.not_to yield_with_no_args
+ }.not_to yield_with_no_args
end
end
- context 'task type' do
- it 'goes through all three housekeeping tasks, executing only the highest task when there is overlap' do
+ context "task type" do
+ it "goes through all three housekeeping tasks, executing only the highest task when there is overlap" do
allow(subject).to receive(:try_obtain_lease).and_return(:the_uuid)
allow(subject).to receive(:lease_key).and_return(:the_lease_key)
@@ -90,19 +90,19 @@ describe Projects::HousekeepingService do
end
end
- describe '#needed?' do
- it 'when the count is low enough' do
+ describe "#needed?" do
+ it "when the count is low enough" do
expect(subject.needed?).to eq(false)
end
- it 'when the count is high enough' do
+ it "when the count is high enough" do
allow(project).to receive(:pushes_since_gc).and_return(10)
expect(subject.needed?).to eq(true)
end
end
- describe '#increment!' do
- it 'increments the pushes_since_gc counter' do
+ describe "#increment!" do
+ it "increments the pushes_since_gc counter" do
expect { subject.increment! }.to change { project.pushes_since_gc }.by(1)
end
end
diff --git a/spec/services/projects/import_error_filter_spec.rb b/spec/services/projects/import_error_filter_spec.rb
index 312b658de89..9eb5b5e741f 100644
--- a/spec/services/projects/import_error_filter_spec.rb
+++ b/spec/services/projects/import_error_filter_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ImportErrorFilter do
- it 'filters any full paths' do
- message = 'Error importing into /my/folder Permission denied @ unlink_internal - /var/opt/gitlab/gitlab-rails/shared/a/b/c/uploads/file'
+ it "filters any full paths" do
+ message = "Error importing into /my/folder Permission denied @ unlink_internal - /var/opt/gitlab/gitlab-rails/shared/a/b/c/uploads/file"
- expect(described_class.filter_message(message)).to eq('Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED]')
+ expect(described_class.filter_message(message)).to eq("Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED]")
end
- it 'filters any relative paths ignoring single slash ones' do
- message = 'Error importing into my/project Permission denied @ unlink_internal - ../file/ and folder/../file'
+ it "filters any relative paths ignoring single slash ones" do
+ message = "Error importing into my/project Permission denied @ unlink_internal - ../file/ and folder/../file"
- expect(described_class.filter_message(message)).to eq('Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED] and [FILTERED]')
+ expect(described_class.filter_message(message)).to eq("Error importing into [FILTERED] Permission denied @ unlink_internal - [FILTERED] and [FILTERED]")
end
end
diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb
index f9e5530bc9d..18093a9b889 100644
--- a/spec/services/projects/import_export/export_service_spec.rb
+++ b/spec/services/projects/import_export/export_service_spec.rb
@@ -1,74 +1,74 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ImportExport::ExportService do
- describe '#execute' do
+ describe "#execute" do
let!(:user) { create(:user) }
let(:project) { create(:project) }
let(:shared) { project.import_export_shared }
let(:service) { described_class.new(project, user) }
let!(:after_export_strategy) { Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy.new }
- it 'saves the version' do
+ it "saves the version" do
expect(Gitlab::ImportExport::VersionSaver).to receive(:new).and_call_original
service.execute
end
- it 'saves the avatar' do
+ it "saves the avatar" do
expect(Gitlab::ImportExport::AvatarSaver).to receive(:new).and_call_original
service.execute
end
- it 'saves the models' do
+ it "saves the models" do
expect(Gitlab::ImportExport::ProjectTreeSaver).to receive(:new).and_call_original
service.execute
end
- it 'saves the uploads' do
+ it "saves the uploads" do
expect(Gitlab::ImportExport::UploadsSaver).to receive(:new).and_call_original
service.execute
end
- it 'saves the repo' do
+ it "saves the repo" do
# once for the normal repo, once for the wiki
expect(Gitlab::ImportExport::RepoSaver).to receive(:new).twice.and_call_original
service.execute
end
- it 'saves the lfs objects' do
+ it "saves the lfs objects" do
expect(Gitlab::ImportExport::LfsSaver).to receive(:new).and_call_original
service.execute
end
- it 'saves the wiki repo' do
+ it "saves the wiki repo" do
expect(Gitlab::ImportExport::WikiRepoSaver).to receive(:new).and_call_original
service.execute
end
- context 'when all saver services succeed' do
+ context "when all saver services succeed" do
before do
allow(service).to receive(:save_services).and_return(true)
end
- it 'saves the project in the file system' do
+ it "saves the project in the file system" do
expect(Gitlab::ImportExport::Saver).to receive(:save).with(project: project, shared: shared)
service.execute
end
- it 'calls the after export strategy' do
+ it "calls the after export strategy" do
expect(after_export_strategy).to receive(:execute)
service.execute(after_export_strategy)
end
- context 'when after export strategy fails' do
+ context "when after export strategy fails" do
before do
allow(after_export_strategy).to receive(:execute).and_return(false)
end
@@ -77,18 +77,18 @@ describe Projects::ImportExport::ExportService do
service.execute(after_export_strategy)
end
- it 'removes the remaining exported data' do
- allow(shared).to receive(:export_path).and_return('whatever')
+ it "removes the remaining exported data" do
+ allow(shared).to receive(:export_path).and_return("whatever")
allow(FileUtils).to receive(:rm_rf)
expect(FileUtils).to receive(:rm_rf).with(shared.export_path)
end
- it 'notifies the user' do
+ it "notifies the user" do
expect_any_instance_of(NotificationService).to receive(:project_not_exported)
end
- it 'notifies logger' do
+ it "notifies logger" do
allow(Rails.logger).to receive(:error)
expect(Rails.logger).to receive(:error)
@@ -96,7 +96,7 @@ describe Projects::ImportExport::ExportService do
end
end
- context 'when saver services fail' do
+ context "when saver services fail" do
before do
allow(service).to receive(:save_services).and_return(false)
end
@@ -105,22 +105,22 @@ describe Projects::ImportExport::ExportService do
expect { service.execute }.to raise_error(Gitlab::ImportExport::Error)
end
- it 'removes the remaining exported data' do
- allow(shared).to receive(:export_path).and_return('whatever')
+ it "removes the remaining exported data" do
+ allow(shared).to receive(:export_path).and_return("whatever")
allow(FileUtils).to receive(:rm_rf)
expect(FileUtils).to receive(:rm_rf).with(shared.export_path)
end
- it 'notifies the user' do
+ it "notifies the user" do
expect_any_instance_of(NotificationService).to receive(:project_not_exported)
end
- it 'notifies logger' do
+ it "notifies logger" do
expect(Rails.logger).to receive(:error)
end
- it 'the after export strategy is not called' do
+ it "the after export strategy is not called" do
expect(service).not_to receive(:execute_after_export_action)
end
end
diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb
index 7faf0fc2868..ab8ce8c59a2 100644
--- a/spec/services/projects/import_service_spec.rb
+++ b/spec/services/projects/import_service_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ImportService do
let!(:project) { create(:project) }
let(:user) { project.creator }
- let(:import_url) { 'http://www.gitlab.com/demo/repo.git' }
- let(:oid_download_links) { { 'oid1' => "#{import_url}/gitlab-lfs/objects/oid1", 'oid2' => "#{import_url}/gitlab-lfs/objects/oid2" } }
+ let(:import_url) { "http://www.gitlab.com/demo/repo.git" }
+ let(:oid_download_links) { {"oid1" => "#{import_url}/gitlab-lfs/objects/oid1", "oid2" => "#{import_url}/gitlab-lfs/objects/oid2"} }
subject { described_class.new(project, user) }
@@ -14,8 +14,8 @@ describe Projects::ImportService do
allow_any_instance_of(Projects::LfsPointers::LfsImportService).to receive(:execute).and_return(oid_download_links)
end
- describe '#async?' do
- it 'returns true for an asynchronous importer' do
+ describe "#async?" do
+ it "returns true for an asynchronous importer" do
importer_class = double(:importer, async?: true)
allow(subject).to receive(:has_importer?).and_return(true)
@@ -24,7 +24,7 @@ describe Projects::ImportService do
expect(subject).to be_async
end
- it 'returns false for a regular importer' do
+ it "returns false for a regular importer" do
importer_class = double(:importer, async?: false)
allow(subject).to receive(:has_importer?).and_return(true)
@@ -33,7 +33,7 @@ describe Projects::ImportService do
expect(subject).not_to be_async
end
- it 'returns false when the importer does not define #async?' do
+ it "returns false when the importer does not define #async?" do
importer_class = double(:importer)
allow(subject).to receive(:has_importer?).and_return(true)
@@ -42,20 +42,20 @@ describe Projects::ImportService do
expect(subject).not_to be_async
end
- it 'returns false when the importer does not exist' do
+ it "returns false when the importer does not exist" do
allow(subject).to receive(:has_importer?).and_return(false)
expect(subject).not_to be_async
end
end
- describe '#execute' do
- context 'with unknown url' do
+ describe "#execute" do
+ context "with unknown url" do
before do
project.import_url = Project::UNKNOWN_IMPORT_URL
end
- it 'succeeds if repository is created successfully' do
+ it "succeeds if repository is created successfully" do
expect(project).to receive(:create_repository).and_return(true)
result = subject.execute
@@ -63,7 +63,7 @@ describe Projects::ImportService do
expect(result[:status]).to eq :success
end
- it 'fails if repository creation fails' do
+ it "fails if repository creation fails" do
expect(project).to receive(:create_repository).and_return(false)
result = subject.execute
@@ -72,8 +72,8 @@ describe Projects::ImportService do
expect(result[:message]).to eq "Error importing repository #{project.safe_import_url} into #{project.full_path} - The repository could not be created."
end
- context 'when repository creation succeeds' do
- it 'does not download lfs files' do
+ context "when repository creation succeeds" do
+ it "does not download lfs files" do
expect_any_instance_of(Projects::LfsPointers::LfsImportService).not_to receive(:execute)
expect_any_instance_of(Projects::LfsPointers::LfsDownloadService).not_to receive(:execute)
@@ -82,14 +82,14 @@ describe Projects::ImportService do
end
end
- context 'with known url' do
+ context "with known url" do
before do
- project.import_url = 'https://github.com/vim/vim.git'
- project.import_type = 'github'
+ project.import_url = "https://github.com/vim/vim.git"
+ project.import_type = "github"
end
- context 'with a Github repository' do
- it 'succeeds if repository import was scheduled' do
+ context "with a Github repository" do
+ it "succeeds if repository import was scheduled" do
expect_any_instance_of(Gitlab::GithubImport::ParallelImporter)
.to receive(:execute)
.and_return(true)
@@ -99,7 +99,7 @@ describe Projects::ImportService do
expect(result[:status]).to eq :success
end
- it 'fails if repository import was not scheduled' do
+ it "fails if repository import was not scheduled" do
expect_any_instance_of(Gitlab::GithubImport::ParallelImporter)
.to receive(:execute)
.and_return(false)
@@ -109,8 +109,8 @@ describe Projects::ImportService do
expect(result[:status]).to eq :error
end
- context 'when repository import scheduled' do
- it 'does not download lfs objects' do
+ context "when repository import scheduled" do
+ it "does not download lfs objects" do
expect_any_instance_of(Projects::LfsPointers::LfsImportService).not_to receive(:execute)
expect_any_instance_of(Projects::LfsPointers::LfsDownloadService).not_to receive(:execute)
@@ -119,13 +119,13 @@ describe Projects::ImportService do
end
end
- context 'with a non Github repository' do
+ context "with a non Github repository" do
before do
- project.import_url = 'https://bitbucket.org/vim/vim.git'
- project.import_type = 'bitbucket'
+ project.import_url = "https://bitbucket.org/vim/vim.git"
+ project.import_type = "bitbucket"
end
- it 'succeeds if repository import is successful' do
+ it "succeeds if repository import is successful" do
expect_any_instance_of(Gitlab::Shell).to receive(:import_repository).and_return(true)
expect_any_instance_of(Gitlab::BitbucketImport::Importer).to receive(:execute).and_return(true)
expect_any_instance_of(Projects::LfsPointers::LfsImportService).to receive(:execute).and_return({})
@@ -135,8 +135,8 @@ describe Projects::ImportService do
expect(result[:status]).to eq :success
end
- it 'fails if repository import fails' do
- expect_any_instance_of(Gitlab::Shell).to receive(:import_repository).and_raise(Gitlab::Shell::Error.new('Failed to import the repository /a/b/c'))
+ it "fails if repository import fails" do
+ expect_any_instance_of(Gitlab::Shell).to receive(:import_repository).and_raise(Gitlab::Shell::Error.new("Failed to import the repository /a/b/c"))
result = subject.execute
@@ -144,13 +144,13 @@ describe Projects::ImportService do
expect(result[:message]).to eq "Error importing repository #{project.safe_import_url} into #{project.full_path} - Failed to import the repository [FILTERED]"
end
- context 'when repository import scheduled' do
+ context "when repository import scheduled" do
before do
allow_any_instance_of(Gitlab::Shell).to receive(:import_repository).and_return(true)
allow(subject).to receive(:import_data)
end
- it 'downloads lfs objects if lfs_enabled is enabled for project' do
+ it "downloads lfs objects if lfs_enabled is enabled for project" do
allow(project).to receive(:lfs_enabled?).and_return(true)
service = double
@@ -161,7 +161,7 @@ describe Projects::ImportService do
subject.execute
end
- it 'does not download lfs objects if lfs_enabled is not enabled for project' do
+ it "does not download lfs objects if lfs_enabled is not enabled for project" do
allow(project).to receive(:lfs_enabled?).and_return(false)
expect_any_instance_of(Projects::LfsPointers::LfsImportService).not_to receive(:execute)
expect_any_instance_of(Projects::LfsPointers::LfsDownloadService).not_to receive(:execute)
@@ -172,17 +172,17 @@ describe Projects::ImportService do
end
end
- context 'with valid importer' do
+ context "with valid importer" do
before do
stub_github_omniauth_provider
- project.import_url = 'https://github.com/vim/vim.git'
- project.import_type = 'github'
+ project.import_url = "https://github.com/vim/vim.git"
+ project.import_type = "github"
allow(project).to receive(:import_data).and_return(double.as_null_object)
end
- it 'succeeds if importer succeeds' do
+ it "succeeds if importer succeeds" do
allow_any_instance_of(Gitlab::GithubImport::ParallelImporter)
.to receive(:execute).and_return(true)
@@ -191,7 +191,7 @@ describe Projects::ImportService do
expect(result[:status]).to eq :success
end
- it 'fails if importer fails' do
+ it "fails if importer fails" do
allow_any_instance_of(Gitlab::GithubImport::ParallelImporter)
.to receive(:execute)
.and_return(false)
@@ -201,8 +201,8 @@ describe Projects::ImportService do
expect(result[:status]).to eq :error
end
- context 'when importer' do
- it 'has a custom repository importer it does not download lfs objects' do
+ context "when importer" do
+ it "has a custom repository importer it does not download lfs objects" do
allow(Gitlab::GithubImport::ParallelImporter).to receive(:imports_repository?).and_return(true)
expect_any_instance_of(Projects::LfsPointers::LfsImportService).not_to receive(:execute)
@@ -211,7 +211,7 @@ describe Projects::ImportService do
subject.execute
end
- it 'does not have a custom repository importer downloads lfs objects' do
+ it "does not have a custom repository importer downloads lfs objects" do
allow(Gitlab::GithubImport::ParallelImporter).to receive(:imports_repository?).and_return(false)
service = double
@@ -224,37 +224,37 @@ describe Projects::ImportService do
end
end
- context 'with blocked import_URL' do
- it 'fails with localhost' do
- project.import_url = 'https://localhost:9000/vim/vim.git'
+ context "with blocked import_URL" do
+ it "fails with localhost" do
+ project.import_url = "https://localhost:9000/vim/vim.git"
result = described_class.new(project, user).execute
expect(result[:status]).to eq :error
- expect(result[:message]).to include('Requests to localhost are not allowed')
+ expect(result[:message]).to include("Requests to localhost are not allowed")
end
- it 'fails with port 25' do
+ it "fails with port 25" do
project.import_url = "https://github.com:25/vim/vim.git"
result = described_class.new(project, user).execute
expect(result[:status]).to eq :error
- expect(result[:message]).to include('Only allowed ports are 80, 443')
+ expect(result[:message]).to include("Only allowed ports are 80, 443")
end
end
def stub_github_omniauth_provider
provider = OpenStruct.new(
- 'name' => 'github',
- 'app_id' => 'asd123',
- 'app_secret' => 'asd123',
- 'args' => {
- 'client_options' => {
- 'site' => 'https://github.com/api/v3',
- 'authorize_url' => 'https://github.com/login/oauth/authorize',
- 'token_url' => 'https://github.com/login/oauth/access_token'
- }
+ "name" => "github",
+ "app_id" => "asd123",
+ "app_secret" => "asd123",
+ "args" => {
+ "client_options" => {
+ "site" => "https://github.com/api/v3",
+ "authorize_url" => "https://github.com/login/oauth/authorize",
+ "token_url" => "https://github.com/login/oauth/access_token",
+ },
}
)
diff --git a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
index f222c52199f..e5236cfd037 100644
--- a/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_download_link_list_service_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::LfsPointers::LfsDownloadLinkListService do
- let(:import_url) { 'http://www.gitlab.com/demo/repo.git' }
+ let(:import_url) { "http://www.gitlab.com/demo/repo.git" }
let(:lfs_endpoint) { "#{import_url}/info/lfs/objects/batch" }
let!(:project) { create(:project, import_url: import_url) }
- let(:new_oids) { { 'oid1' => 123, 'oid2' => 125 } }
+ let(:new_oids) { {"oid1" => 123, "oid2" => 125} }
let(:remote_uri) { URI.parse(lfs_endpoint) }
let(:objects_response) do
- body = new_oids.map do |oid, size|
+ body = new_oids.map { |oid, size|
{
- 'oid' => oid,
- 'size' => size,
- 'actions' => {
- 'download' => { 'href' => "#{import_url}/gitlab-lfs/objects/#{oid}" }
- }
+ "oid" => oid,
+ "size" => size,
+ "actions" => {
+ "download" => {"href" => "#{import_url}/gitlab-lfs/objects/#{oid}"},
+ },
}
- end
+ }
Struct.new(:success?, :objects).new(true, body)
end
let(:invalid_object_response) do
[
- 'oid' => 'whatever',
- 'size' => 123
+ "oid" => "whatever",
+ "size" => 123,
]
end
@@ -35,63 +35,63 @@ describe Projects::LfsPointers::LfsDownloadLinkListService do
allow(Gitlab::HTTP).to receive(:post).and_return(objects_response)
end
- describe '#execute' do
- it 'retrieves each download link of every non existent lfs object' do
+ describe "#execute" do
+ it "retrieves each download link of every non existent lfs object" do
subject.execute(new_oids).each do |lfs_download_object|
expect(lfs_download_object.link).to eq "#{import_url}/gitlab-lfs/objects/#{lfs_download_object.oid}"
end
end
- context 'credentials' do
- context 'when the download link and the lfs_endpoint have the same host' do
- context 'when lfs_endpoint has credentials' do
- let(:import_url) { 'http://user:password@www.gitlab.com/demo/repo.git' }
+ context "credentials" do
+ context "when the download link and the lfs_endpoint have the same host" do
+ context "when lfs_endpoint has credentials" do
+ let(:import_url) { "http://user:password@www.gitlab.com/demo/repo.git" }
- it 'adds credentials to the download_link' do
+ it "adds credentials to the download_link" do
result = subject.execute(new_oids)
result.each do |lfs_download_object|
- expect(lfs_download_object.link.starts_with?('http://user:password@')).to be_truthy
+ expect(lfs_download_object.link.starts_with?("http://user:password@")).to be_truthy
end
end
end
- context 'when lfs_endpoint does not have any credentials' do
- it 'does not add any credentials' do
+ context "when lfs_endpoint does not have any credentials" do
+ it "does not add any credentials" do
result = subject.execute(new_oids)
result.each do |lfs_download_object|
- expect(lfs_download_object.link.starts_with?('http://user:password@')).to be_falsey
+ expect(lfs_download_object.link.starts_with?("http://user:password@")).to be_falsey
end
end
end
end
- context 'when the download link and the lfs_endpoint have different hosts' do
- let(:import_url_with_credentials) { 'http://user:password@www.otherdomain.com/demo/repo.git' }
+ context "when the download link and the lfs_endpoint have different hosts" do
+ let(:import_url_with_credentials) { "http://user:password@www.otherdomain.com/demo/repo.git" }
let(:lfs_endpoint) { "#{import_url_with_credentials}/info/lfs/objects/batch" }
- it 'downloads without any credentials' do
+ it "downloads without any credentials" do
result = subject.execute(new_oids)
result.each do |lfs_download_object|
- expect(lfs_download_object.link.starts_with?('http://user:password@')).to be_falsey
+ expect(lfs_download_object.link.starts_with?("http://user:password@")).to be_falsey
end
end
end
end
end
- describe '#get_download_links' do
- it 'raise errorif request fails' do
- allow(Gitlab::HTTP).to receive(:post).and_return(Struct.new(:success?, :message).new(false, 'Failed request'))
+ describe "#get_download_links" do
+ it "raise errorif request fails" do
+ allow(Gitlab::HTTP).to receive(:post).and_return(Struct.new(:success?, :message).new(false, "Failed request"))
expect { subject.send(:get_download_links, new_oids) }.to raise_error(described_class::DownloadLinksError)
end
end
- describe '#parse_response_links' do
- it 'does not add oid entry if href not found' do
+ describe "#parse_response_links" do
+ it "does not add oid entry if href not found" do
expect(subject).to receive(:log_error).with("Link for Lfs Object with oid whatever not found or invalid.")
result = subject.send(:parse_response_links, invalid_object_response)
diff --git a/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb
index 876beb39801..87a9a5bb273 100644
--- a/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_download_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::LfsPointers::LfsDownloadService do
let(:project) { create(:project) }
@@ -18,7 +18,7 @@ describe Projects::LfsPointers::LfsDownloadService do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- shared_examples 'lfs temporal file is removed' do
+ shared_examples "lfs temporal file is removed" do
it do
subject.execute
@@ -26,139 +26,139 @@ describe Projects::LfsPointers::LfsDownloadService do
end
end
- shared_examples 'no lfs object is created' do
+ shared_examples "no lfs object is created" do
it do
expect { subject.execute }.not_to change { LfsObject.count }
end
- it 'returns error result' do
+ it "returns error result" do
expect(subject.execute[:status]).to eq :error
end
- it 'an error is logged' do
+ it "an error is logged" do
expect(subject).to receive(:log_error)
subject.execute
end
- it_behaves_like 'lfs temporal file is removed'
+ it_behaves_like "lfs temporal file is removed"
end
- shared_examples 'lfs object is created' do
+ shared_examples "lfs object is created" do
it do
expect(subject).to receive(:download_and_save_file!).and_call_original
expect { subject.execute }.to change { LfsObject.count }.by(1)
end
- it 'returns success result' do
+ it "returns success result" do
expect(subject.execute[:status]).to eq :success
end
- it_behaves_like 'lfs temporal file is removed'
+ it_behaves_like "lfs temporal file is removed"
end
- describe '#execute' do
- context 'when file download succeeds' do
+ describe "#execute" do
+ context "when file download succeeds" do
before do
WebMock.stub_request(:get, download_link).to_return(body: lfs_content)
end
- it_behaves_like 'lfs object is created'
+ it_behaves_like "lfs object is created"
- it 'has the same oid' do
+ it "has the same oid" do
subject.execute
expect(LfsObject.first.oid).to eq oid
end
- it 'has the same size' do
+ it "has the same size" do
subject.execute
expect(LfsObject.first.size).to eq size
end
- it 'stores the content' do
+ it "stores the content" do
subject.execute
expect(File.binread(LfsObject.first.file.file.file)).to eq lfs_content
end
end
- context 'when file download fails' do
+ context "when file download fails" do
before do
- allow(Gitlab::HTTP).to receive(:get).and_return(code: 500, 'success?' => false)
+ allow(Gitlab::HTTP).to receive(:get).and_return(:code => 500, "success?" => false)
end
- it_behaves_like 'no lfs object is created'
+ it_behaves_like "no lfs object is created"
- it 'raise StandardError exception' do
+ it "raise StandardError exception" do
expect(subject).to receive(:download_and_save_file!).and_raise(StandardError)
subject.execute
end
end
- context 'when downloaded lfs file has a different size' do
+ context "when downloaded lfs file has a different size" do
let(:size) { 1 }
before do
WebMock.stub_request(:get, download_link).to_return(body: lfs_content)
end
- it_behaves_like 'no lfs object is created'
+ it_behaves_like "no lfs object is created"
- it 'raise SizeError exception' do
+ it "raise SizeError exception" do
expect(subject).to receive(:download_and_save_file!).and_raise(described_class::SizeError)
subject.execute
end
end
- context 'when downloaded lfs file has a different oid' do
+ context "when downloaded lfs file has a different oid" do
before do
WebMock.stub_request(:get, download_link).to_return(body: lfs_content)
- allow_any_instance_of(Digest::SHA256).to receive(:hexdigest).and_return('foobar')
+ allow_any_instance_of(Digest::SHA256).to receive(:hexdigest).and_return("foobar")
end
- it_behaves_like 'no lfs object is created'
+ it_behaves_like "no lfs object is created"
- it 'raise OidError exception' do
+ it "raise OidError exception" do
expect(subject).to receive(:download_and_save_file!).and_raise(described_class::OidError)
subject.execute
end
end
- context 'when credentials present' do
+ context "when credentials present" do
let(:download_link_with_credentials) { "http://user:password@gitlab.com/#{oid}" }
let(:lfs_object) { LfsDownloadObject.new(oid: oid, size: size, link: download_link_with_credentials) }
before do
- WebMock.stub_request(:get, download_link).with(headers: { 'Authorization' => 'Basic dXNlcjpwYXNzd29yZA==' }).to_return(body: lfs_content)
+ WebMock.stub_request(:get, download_link).with(headers: {"Authorization" => "Basic dXNlcjpwYXNzd29yZA=="}).to_return(body: lfs_content)
end
- it 'the request adds authorization headers' do
+ it "the request adds authorization headers" do
subject
end
end
- context 'when localhost requests are allowed' do
- let(:download_link) { 'http://192.168.2.120' }
+ context "when localhost requests are allowed" do
+ let(:download_link) { "http://192.168.2.120" }
let(:local_request_setting) { true }
before do
WebMock.stub_request(:get, download_link).to_return(body: lfs_content)
end
- it_behaves_like 'lfs object is created'
+ it_behaves_like "lfs object is created"
end
- context 'when a bad URL is used' do
- where(download_link: ['/etc/passwd', 'ftp://example.com', 'http://127.0.0.2', 'http://192.168.2.120'])
+ context "when a bad URL is used" do
+ where(download_link: ["/etc/passwd", "ftp://example.com", "http://127.0.0.2", "http://192.168.2.120"])
with_them do
- it 'does not download the file' do
+ it "does not download the file" do
expect(subject).not_to receive(:download_lfs_file!)
expect { subject.execute }.not_to change { LfsObject.count }
@@ -166,53 +166,53 @@ describe Projects::LfsPointers::LfsDownloadService do
end
end
- context 'when the URL points to a redirected URL' do
- context 'that is blocked' do
- where(redirect_link: ['ftp://example.com', 'http://127.0.0.2', 'http://192.168.2.120'])
+ context "when the URL points to a redirected URL" do
+ context "that is blocked" do
+ where(redirect_link: ["ftp://example.com", "http://127.0.0.2", "http://192.168.2.120"])
with_them do
before do
- WebMock.stub_request(:get, download_link).to_return(status: 301, headers: { 'Location' => redirect_link })
+ WebMock.stub_request(:get, download_link).to_return(status: 301, headers: {"Location" => redirect_link})
end
- it_behaves_like 'no lfs object is created'
+ it_behaves_like "no lfs object is created"
end
end
- context 'that is not blocked' do
+ context "that is not blocked" do
let(:redirect_link) { "http://example.com/"}
before do
- WebMock.stub_request(:get, download_link).to_return(status: 301, headers: { 'Location' => redirect_link })
+ WebMock.stub_request(:get, download_link).to_return(status: 301, headers: {"Location" => redirect_link})
WebMock.stub_request(:get, redirect_link).to_return(body: lfs_content)
end
- it_behaves_like 'lfs object is created'
+ it_behaves_like "lfs object is created"
end
end
- context 'when the lfs object attributes are invalid' do
- let(:oid) { 'foobar' }
+ context "when the lfs object attributes are invalid" do
+ let(:oid) { "foobar" }
before do
expect(lfs_object).to be_invalid
end
- it_behaves_like 'no lfs object is created'
+ it_behaves_like "no lfs object is created"
- it 'does not download the file' do
+ it "does not download the file" do
expect(subject).not_to receive(:download_lfs_file!)
subject.execute
end
end
- context 'when an lfs object with the same oid already exists' do
+ context "when an lfs object with the same oid already exists" do
before do
create(:lfs_object, oid: oid)
end
- it 'does not download the file' do
+ it "does not download the file" do
expect(subject).not_to receive(:download_lfs_file!)
subject.execute
diff --git a/spec/services/projects/lfs_pointers/lfs_import_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_import_service_spec.rb
index 5a75fb38dec..c1b50b66d27 100644
--- a/spec/services/projects/lfs_pointers/lfs_import_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_import_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::LfsPointers::LfsImportService do
- let(:import_url) { 'http://www.gitlab.com/demo/repo.git' }
+ let(:import_url) { "http://www.gitlab.com/demo/repo.git" }
let(:default_endpoint) { "#{import_url}/info/lfs/objects/batch"}
let(:group) { create(:group, lfs_enabled: true)}
let!(:project) { create(:project, namespace: group, import_url: import_url, lfs_enabled: true) }
let!(:lfs_objects_project) { create_list(:lfs_objects_project, 2, project: project) }
let!(:existing_lfs_objects) { LfsObject.pluck(:oid, :size).to_h }
- let(:oids) { { 'oid1' => 123, 'oid2' => 125 } }
- let(:oid_download_links) { { 'oid1' => "#{import_url}/gitlab-lfs/objects/oid1", 'oid2' => "#{import_url}/gitlab-lfs/objects/oid2" } }
+ let(:oids) { {"oid1" => 123, "oid2" => 125} }
+ let(:oid_download_links) { {"oid1" => "#{import_url}/gitlab-lfs/objects/oid1", "oid2" => "#{import_url}/gitlab-lfs/objects/oid2"} }
let(:all_oids) { existing_lfs_objects.merge(oids) }
let(:remote_uri) { URI.parse(lfs_endpoint) }
@@ -20,81 +20,81 @@ describe Projects::LfsPointers::LfsImportService do
allow_any_instance_of(Projects::LfsPointers::LfsListService).to receive(:execute).and_return(all_oids)
end
- describe '#execute' do
- context 'when no lfs pointer is linked' do
+ describe "#execute" do
+ context "when no lfs pointer is linked" do
before do
allow_any_instance_of(Projects::LfsPointers::LfsLinkService).to receive(:execute).and_return([])
allow_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute).and_return(oid_download_links)
expect(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:new).with(project, remote_uri: URI.parse(default_endpoint)).and_call_original
end
- it 'retrieves all lfs pointers in the project repository' do
+ it "retrieves all lfs pointers in the project repository" do
expect_any_instance_of(Projects::LfsPointers::LfsListService).to receive(:execute)
subject.execute
end
- it 'links existent lfs objects to the project' do
+ it "links existent lfs objects to the project" do
expect_any_instance_of(Projects::LfsPointers::LfsLinkService).to receive(:execute)
subject.execute
end
- it 'retrieves the download links of non existent objects' do
+ it "retrieves the download links of non existent objects" do
expect_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute).with(all_oids)
subject.execute
end
end
- context 'when some lfs objects are linked' do
+ context "when some lfs objects are linked" do
before do
allow_any_instance_of(Projects::LfsPointers::LfsLinkService).to receive(:execute).and_return(existing_lfs_objects.keys)
allow_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute).and_return(oid_download_links)
end
- it 'retrieves the download links of non existent objects' do
+ it "retrieves the download links of non existent objects" do
expect_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute).with(oids)
subject.execute
end
end
- context 'when all lfs objects are linked' do
+ context "when all lfs objects are linked" do
before do
allow_any_instance_of(Projects::LfsPointers::LfsLinkService).to receive(:execute).and_return(all_oids.keys)
allow_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute)
end
- it 'retrieves no download links' do
+ it "retrieves no download links" do
expect_any_instance_of(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:execute).with({}).and_call_original
expect(subject.execute).to be_empty
end
end
- context 'when lfsconfig file exists' do
+ context "when lfsconfig file exists" do
before do
allow(project.repository).to receive(:lfsconfig_for).and_return("[lfs]\n\turl = #{lfs_endpoint}\n")
end
- context 'when url points to the same import url host' do
+ context "when url points to the same import url host" do
let(:lfs_endpoint) { "#{import_url}/different_endpoint" }
let(:service) { double }
before do
allow(service).to receive(:execute)
end
- it 'downloads lfs object using the new endpoint' do
+ it "downloads lfs object using the new endpoint" do
expect(Projects::LfsPointers::LfsDownloadLinkListService).to receive(:new).with(project, remote_uri: remote_uri).and_return(service)
subject.execute
end
- context 'when import url has credentials' do
- let(:import_url) { 'http://user:password@www.gitlab.com/demo/repo.git'}
+ context "when import url has credentials" do
+ let(:import_url) { "http://user:password@www.gitlab.com/demo/repo.git"}
- it 'adds the credentials to the new endpoint' do
+ it "adds the credentials to the new endpoint" do
expect(Projects::LfsPointers::LfsDownloadLinkListService)
.to receive(:new).with(project, remote_uri: URI.parse("http://user:password@www.gitlab.com/demo/repo.git/different_endpoint"))
.and_return(service)
@@ -102,10 +102,10 @@ describe Projects::LfsPointers::LfsImportService do
subject.execute
end
- context 'when url has its own credentials' do
+ context "when url has its own credentials" do
let(:lfs_endpoint) { "http://user1:password1@www.gitlab.com/demo/repo.git/different_endpoint" }
- it 'does not add the import url credentials' do
+ it "does not add the import url credentials" do
expect(Projects::LfsPointers::LfsDownloadLinkListService)
.to receive(:new).with(project, remote_uri: remote_uri)
.and_return(service)
@@ -116,10 +116,10 @@ describe Projects::LfsPointers::LfsImportService do
end
end
- context 'when url points to a third party service' do
- let(:lfs_endpoint) { 'http://third_party_service.com/info/lfs/objects/' }
+ context "when url points to a third party service" do
+ let(:lfs_endpoint) { "http://third_party_service.com/info/lfs/objects/" }
- it 'disables lfs from the project' do
+ it "disables lfs from the project" do
expect(project.lfs_enabled?).to be_truthy
subject.execute
@@ -127,7 +127,7 @@ describe Projects::LfsPointers::LfsImportService do
expect(project.lfs_enabled?).to be_falsey
end
- it 'does not download anything' do
+ it "does not download anything" do
expect_any_instance_of(Projects::LfsPointers::LfsListService).not_to receive(:execute)
subject.execute
@@ -136,10 +136,10 @@ describe Projects::LfsPointers::LfsImportService do
end
end
- describe '#default_endpoint_uri' do
- let(:import_url) { 'http://www.gitlab.com/demo/repo' }
+ describe "#default_endpoint_uri" do
+ let(:import_url) { "http://www.gitlab.com/demo/repo" }
- it 'adds suffix .git if the url does not have it' do
+ it "adds suffix .git if the url does not have it" do
expect(subject.send(:default_endpoint_uri).path).to match(/repo.git/)
end
end
diff --git a/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb b/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
index b7b153655db..d8bc6e68d7c 100644
--- a/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
+++ b/spec/services/projects/lfs_pointers/lfs_link_service_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::LfsPointers::LfsLinkService do
let!(:project) { create(:project, lfs_enabled: true) }
let!(:lfs_objects_project) { create_list(:lfs_objects_project, 2, project: project) }
- let(:new_oids) { { 'oid1' => 123, 'oid2' => 125 } }
+ let(:new_oids) { {"oid1" => 123, "oid2" => 125} }
let(:all_oids) { LfsObject.pluck(:oid, :size).to_h.merge(new_oids) }
let(:new_lfs_object) { create(:lfs_object) }
let(:new_oid_list) { all_oids.merge(new_lfs_object.oid => new_lfs_object.size) }
@@ -14,8 +14,8 @@ describe Projects::LfsPointers::LfsLinkService do
allow(project).to receive(:lfs_enabled?).and_return(true)
end
- describe '#execute' do
- it 'links existing lfs objects to the project' do
+ describe "#execute" do
+ it "links existing lfs objects to the project" do
expect(project.all_lfs_objects.count).to eq 2
linked = subject.execute(new_oid_list.keys)
@@ -24,7 +24,7 @@ describe Projects::LfsPointers::LfsLinkService do
expect(linked.size).to eq 3
end
- it 'returns linked oids' do
+ it "returns linked oids" do
linked = lfs_objects_project.map(&:lfs_object).map(&:oid) << new_lfs_object.oid
expect(subject.execute(new_oid_list.keys)).to eq linked
diff --git a/spec/services/projects/move_access_service_spec.rb b/spec/services/projects/move_access_service_spec.rb
index 88d9d93c33b..ebf20799394 100644
--- a/spec/services/projects/move_access_service_spec.rb
+++ b/spec/services/projects/move_access_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveAccessService do
let(:user) { create(:user) }
@@ -22,8 +22,8 @@ describe Projects::MoveAccessService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
- shared_examples 'move the accesses' do
+ describe "#execute" do
+ shared_examples "move the accesses" do
it do
expect(project_with_access.project_members.count).to eq 4
expect(project_with_access.project_group_links.count).to eq 3
@@ -39,7 +39,7 @@ describe Projects::MoveAccessService do
expect(target_project.authorized_users.count).to eq 4
end
- it 'rollbacks if an exception is raised' do
+ it "rollbacks if an exception is raised" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_groups) }.to raise_error(StandardError)
@@ -50,10 +50,10 @@ describe Projects::MoveAccessService do
end
end
- context 'when both projects are in the same namespace' do
+ context "when both projects are in the same namespace" do
let(:target_project) { create(:project, namespace: user.namespace) }
- it 'does not refresh project owner authorized projects' do
+ it "does not refresh project owner authorized projects" do
allow(project_with_access).to receive(:namespace).and_return(user.namespace)
expect(project_with_access.namespace).not_to receive(:refresh_project_authorizations)
expect(target_project.namespace).not_to receive(:refresh_project_authorizations)
@@ -61,17 +61,17 @@ describe Projects::MoveAccessService do
subject.execute(project_with_access)
end
- it_behaves_like 'move the accesses'
+ it_behaves_like "move the accesses"
end
- context 'when projects are in different namespaces' do
+ context "when projects are in different namespaces" do
let(:target_project) { create(:project, namespace: group) }
before do
group.add_owner(user)
end
- it 'refreshes both project owner authorized projects' do
+ it "refreshes both project owner authorized projects" do
allow(project_with_access).to receive(:namespace).and_return(user.namespace)
expect(user.namespace).to receive(:refresh_project_authorizations).once
expect(group).to receive(:refresh_project_authorizations).once
@@ -79,14 +79,14 @@ describe Projects::MoveAccessService do
subject.execute(project_with_access)
end
- it_behaves_like 'move the accesses'
+ it_behaves_like "move the accesses"
end
- context 'when remove_remaining_elements is false' do
+ context "when remove_remaining_elements is false" do
let(:target_project) { create(:project, namespace: user.namespace) }
- let(:options) { { remove_remaining_elements: false } }
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining memberships' do
+ it "does not remove remaining memberships" do
target_project.add_maintainer(maintainer_user)
subject.execute(project_with_access, options)
@@ -94,7 +94,7 @@ describe Projects::MoveAccessService do
expect(project_with_access.project_members.count).not_to eq 0
end
- it 'does not remove remaining group links' do
+ it "does not remove remaining group links" do
target_project.project_group_links.create(group: maintainer_group, group_access: Gitlab::Access::MAINTAINER)
subject.execute(project_with_access, options)
@@ -102,7 +102,7 @@ describe Projects::MoveAccessService do
expect(project_with_access.project_group_links.count).not_to eq 0
end
- it 'does not remove remaining authorizations' do
+ it "does not remove remaining authorizations" do
target_project.add_developer(developer_user)
subject.execute(project_with_access, options)
diff --git a/spec/services/projects/move_deploy_keys_projects_service_spec.rb b/spec/services/projects/move_deploy_keys_projects_service_spec.rb
index c548edf39a8..964c41dd29d 100644
--- a/spec/services/projects/move_deploy_keys_projects_service_spec.rb
+++ b/spec/services/projects/move_deploy_keys_projects_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveDeployKeysProjectsService do
let!(:user) { create(:user) }
@@ -7,12 +7,12 @@ describe Projects::MoveDeployKeysProjectsService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
create_list(:deploy_keys_project, 2, project: project_with_deploy_keys)
end
- it 'moves the user\'s deploy keys from one project to another' do
+ it "moves the user's deploy keys from one project to another" do
expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 2
expect(target_project.deploy_keys_projects.count).to eq 0
@@ -22,7 +22,7 @@ describe Projects::MoveDeployKeysProjectsService do
expect(target_project.deploy_keys_projects.count).to eq 2
end
- it 'does not link existent deploy_keys in the current project' do
+ it "does not link existent deploy_keys in the current project" do
target_project.deploy_keys << project_with_deploy_keys.deploy_keys.first
expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 2
@@ -34,7 +34,7 @@ describe Projects::MoveDeployKeysProjectsService do
expect(target_project.deploy_keys_projects.count).to eq 2
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_deploy_keys) }.to raise_error(StandardError)
@@ -43,10 +43,10 @@ describe Projects::MoveDeployKeysProjectsService do
expect(target_project.deploy_keys_projects.count).to eq 0
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining deploy keys projects' do
+ it "does not remove remaining deploy keys projects" do
target_project.deploy_keys << project_with_deploy_keys.deploy_keys.first
subject.execute(project_with_deploy_keys, options)
diff --git a/spec/services/projects/move_forks_service_spec.rb b/spec/services/projects/move_forks_service_spec.rb
index f4a5a7f9fc2..a39ebc5b159 100644
--- a/spec/services/projects/move_forks_service_spec.rb
+++ b/spec/services/projects/move_forks_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveForksService do
include ProjectForksHelper
@@ -13,9 +13,9 @@ describe Projects::MoveForksService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
- context 'when moving a root forked project' do
- it 'moves the descendant forks' do
+ describe "#execute" do
+ context "when moving a root forked project" do
+ it "moves the descendant forks" do
expect(project_with_forks.forks.count).to eq 2
expect(target_project.forks.count).to eq 0
@@ -29,7 +29,7 @@ describe Projects::MoveForksService do
expect(lvl1_forked_project_2.fork_network_member.forked_from_project).to eq target_project
end
- it 'updates the fork network' do
+ it "updates the fork network" do
expect(project_with_forks.fork_network.root_project).to eq project_with_forks
expect(project_with_forks.fork_network.fork_network_members.map(&:project)).to include project_with_forks
@@ -40,8 +40,8 @@ describe Projects::MoveForksService do
end
end
- context 'when moving a intermediate forked project' do
- it 'moves the descendant forks' do
+ context "when moving a intermediate forked project" do
+ it "moves the descendant forks" do
expect(lvl1_forked_project_1.forks.count).to eq 2
expect(target_project.forks.count).to eq 0
@@ -55,36 +55,36 @@ describe Projects::MoveForksService do
expect(lvl2_forked_project_1_2.fork_network_member.forked_from_project).to eq target_project
end
- it 'moves the ascendant fork' do
+ it "moves the ascendant fork" do
subject.execute(lvl1_forked_project_1)
expect(target_project.forked_from_project).to eq project_with_forks
expect(target_project.fork_network_member.forked_from_project).to eq project_with_forks
end
- it 'does not update fork network' do
+ it "does not update fork network" do
subject.execute(lvl1_forked_project_1)
expect(target_project.reload.fork_network.root_project).to eq project_with_forks
end
end
- context 'when moving a leaf forked project' do
- it 'moves the ascendant fork' do
+ context "when moving a leaf forked project" do
+ it "moves the ascendant fork" do
subject.execute(lvl2_forked_project_1_1)
expect(target_project.forked_from_project).to eq lvl1_forked_project_1
expect(target_project.fork_network_member.forked_from_project).to eq lvl1_forked_project_1
end
- it 'does not update fork network' do
+ it "does not update fork network" do
subject.execute(lvl2_forked_project_1_1)
expect(target_project.reload.fork_network.root_project).to eq project_with_forks
end
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_forks) }.to raise_error(StandardError)
diff --git a/spec/services/projects/move_lfs_objects_projects_service_spec.rb b/spec/services/projects/move_lfs_objects_projects_service_spec.rb
index 517a24a982a..c197bc4f738 100644
--- a/spec/services/projects/move_lfs_objects_projects_service_spec.rb
+++ b/spec/services/projects/move_lfs_objects_projects_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveLfsObjectsProjectsService do
let!(:user) { create(:user) }
@@ -11,8 +11,8 @@ describe Projects::MoveLfsObjectsProjectsService do
create_list(:lfs_objects_project, 3, project: project_with_lfs_objects)
end
- describe '#execute' do
- it 'links the lfs objects from existent in source project' do
+ describe "#execute" do
+ it "links the lfs objects from existent in source project" do
expect(target_project.lfs_objects.count).to eq 0
subject.execute(project_with_lfs_objects)
@@ -21,7 +21,7 @@ describe Projects::MoveLfsObjectsProjectsService do
expect(target_project.reload.lfs_objects.count).to eq 3
end
- it 'does not link existent lfs_object in the current project' do
+ it "does not link existent lfs_object in the current project" do
target_project.lfs_objects << project_with_lfs_objects.lfs_objects.first(2)
expect(target_project.lfs_objects.count).to eq 2
@@ -31,7 +31,7 @@ describe Projects::MoveLfsObjectsProjectsService do
expect(target_project.lfs_objects.count).to eq 3
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_lfs_objects) }.to raise_error(StandardError)
@@ -40,10 +40,10 @@ describe Projects::MoveLfsObjectsProjectsService do
expect(target_project.lfs_objects.count).to eq 0
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining lfs objects' do
+ it "does not remove remaining lfs objects" do
target_project.lfs_objects << project_with_lfs_objects.lfs_objects.first(2)
subject.execute(project_with_lfs_objects, options)
diff --git a/spec/services/projects/move_notification_settings_service_spec.rb b/spec/services/projects/move_notification_settings_service_spec.rb
index 24d69eef86a..b623325331e 100644
--- a/spec/services/projects/move_notification_settings_service_spec.rb
+++ b/spec/services/projects/move_notification_settings_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveNotificationSettingsService do
let(:user) { create(:user) }
@@ -7,13 +7,13 @@ describe Projects::MoveNotificationSettingsService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
- context 'with notification settings' do
+ describe "#execute" do
+ context "with notification settings" do
before do
create_list(:notification_setting, 2, source: project_with_notifications)
end
- it 'moves the user\'s notification settings from one project to another' do
+ it "moves the user's notification settings from one project to another" do
expect(project_with_notifications.notification_settings.count).to eq 3
expect(target_project.notification_settings.count).to eq 1
@@ -23,7 +23,7 @@ describe Projects::MoveNotificationSettingsService do
expect(target_project.notification_settings.count).to eq 3
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_notifications) }.to raise_error(StandardError)
@@ -33,7 +33,7 @@ describe Projects::MoveNotificationSettingsService do
end
end
- it 'does not move existent notification settings in the current project' do
+ it "does not move existent notification settings in the current project" do
expect(project_with_notifications.notification_settings.count).to eq 1
expect(target_project.notification_settings.count).to eq 1
expect(user.notification_settings.count).to eq 2
@@ -43,10 +43,10 @@ describe Projects::MoveNotificationSettingsService do
expect(user.notification_settings.count).to eq 1
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining notification settings' do
+ it "does not remove remaining notification settings" do
subject.execute(project_with_notifications, options)
expect(project_with_notifications.notification_settings.count).not_to eq 0
diff --git a/spec/services/projects/move_project_authorizations_service_spec.rb b/spec/services/projects/move_project_authorizations_service_spec.rb
index b4408393624..6af4498a653 100644
--- a/spec/services/projects/move_project_authorizations_service_spec.rb
+++ b/spec/services/projects/move_project_authorizations_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveProjectAuthorizationsService do
let!(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe Projects::MoveProjectAuthorizationsService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
project_with_users.add_maintainer(maintainer_user)
project_with_users.add_developer(developer_user)
project_with_users.add_reporter(reporter_user)
end
- it 'moves the authorizations from one project to another' do
+ it "moves the authorizations from one project to another" do
expect(project_with_users.authorized_users.count).to eq 4
expect(target_project.authorized_users.count).to eq 1
@@ -27,7 +27,7 @@ describe Projects::MoveProjectAuthorizationsService do
expect(target_project.authorized_users.count).to eq 4
end
- it 'does not move existent authorizations to the current project' do
+ it "does not move existent authorizations to the current project" do
target_project.add_maintainer(developer_user)
target_project.add_developer(reporter_user)
@@ -40,10 +40,10 @@ describe Projects::MoveProjectAuthorizationsService do
expect(target_project.authorized_users.count).to eq 4
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining project authorizations' do
+ it "does not remove remaining project authorizations" do
target_project.add_maintainer(developer_user)
target_project.add_developer(reporter_user)
diff --git a/spec/services/projects/move_project_group_links_service_spec.rb b/spec/services/projects/move_project_group_links_service_spec.rb
index 7ca8cf304fe..9551f97b44b 100644
--- a/spec/services/projects/move_project_group_links_service_spec.rb
+++ b/spec/services/projects/move_project_group_links_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveProjectGroupLinksService do
let!(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe Projects::MoveProjectGroupLinksService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
project_with_groups.project_group_links.create(group: maintainer_group, group_access: Gitlab::Access::MAINTAINER)
project_with_groups.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER)
project_with_groups.project_group_links.create(group: reporter_group, group_access: Gitlab::Access::REPORTER)
end
- it 'moves the group links from one project to another' do
+ it "moves the group links from one project to another" do
expect(project_with_groups.project_group_links.count).to eq 3
expect(target_project.project_group_links.count).to eq 0
@@ -27,7 +27,7 @@ describe Projects::MoveProjectGroupLinksService do
expect(target_project.project_group_links.count).to eq 3
end
- it 'does not move existent group links in the current project' do
+ it "does not move existent group links in the current project" do
target_project.project_group_links.create(group: maintainer_group, group_access: Gitlab::Access::MAINTAINER)
target_project.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER)
@@ -40,7 +40,7 @@ describe Projects::MoveProjectGroupLinksService do
expect(target_project.project_group_links.count).to eq 3
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_groups) }.to raise_error(StandardError)
@@ -49,10 +49,10 @@ describe Projects::MoveProjectGroupLinksService do
expect(target_project.project_group_links.count).to eq 0
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining project group links' do
+ it "does not remove remaining project group links" do
target_project.project_group_links.create(group: maintainer_group, group_access: Gitlab::Access::MAINTAINER)
target_project.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER)
diff --git a/spec/services/projects/move_project_members_service_spec.rb b/spec/services/projects/move_project_members_service_spec.rb
index c8c0eac1f13..f99800d7a0c 100644
--- a/spec/services/projects/move_project_members_service_spec.rb
+++ b/spec/services/projects/move_project_members_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveProjectMembersService do
let!(:user) { create(:user) }
@@ -10,14 +10,14 @@ describe Projects::MoveProjectMembersService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
project_with_users.add_maintainer(maintainer_user)
project_with_users.add_developer(developer_user)
project_with_users.add_reporter(reporter_user)
end
- it 'moves the members from one project to another' do
+ it "moves the members from one project to another" do
expect(project_with_users.project_members.count).to eq 4
expect(target_project.project_members.count).to eq 1
@@ -27,7 +27,7 @@ describe Projects::MoveProjectMembersService do
expect(target_project.project_members.count).to eq 4
end
- it 'does not move existent members to the current project' do
+ it "does not move existent members to the current project" do
target_project.add_maintainer(developer_user)
target_project.add_developer(reporter_user)
@@ -40,7 +40,7 @@ describe Projects::MoveProjectMembersService do
expect(target_project.project_members.count).to eq 4
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_users) }.to raise_error(StandardError)
@@ -49,10 +49,10 @@ describe Projects::MoveProjectMembersService do
expect(target_project.project_members.count).to eq 1
end
- context 'when remove_remaining_elements is false' do
- let(:options) { { remove_remaining_elements: false } }
+ context "when remove_remaining_elements is false" do
+ let(:options) { {remove_remaining_elements: false} }
- it 'does not remove remaining project members' do
+ it "does not remove remaining project members" do
target_project.add_maintainer(developer_user)
target_project.add_developer(reporter_user)
diff --git a/spec/services/projects/move_users_star_projects_service_spec.rb b/spec/services/projects/move_users_star_projects_service_spec.rb
index e0545c5a21b..6acea46c501 100644
--- a/spec/services/projects/move_users_star_projects_service_spec.rb
+++ b/spec/services/projects/move_users_star_projects_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::MoveUsersStarProjectsService do
let!(:user) { create(:user) }
@@ -7,12 +7,12 @@ describe Projects::MoveUsersStarProjectsService do
subject { described_class.new(target_project, user) }
- describe '#execute' do
+ describe "#execute" do
before do
create_list(:users_star_project, 2, project: project_with_stars)
end
- it 'moves the user\'s stars from one project to another' do
+ it "moves the user's stars from one project to another" do
expect(project_with_stars.users_star_projects.count).to eq 2
expect(project_with_stars.star_count).to eq 2
expect(target_project.users_star_projects.count).to eq 0
@@ -28,7 +28,7 @@ describe Projects::MoveUsersStarProjectsService do
expect(target_project.star_count).to eq 2
end
- it 'rollbacks changes if transaction fails' do
+ it "rollbacks changes if transaction fails" do
allow(subject).to receive(:success).and_raise(StandardError)
expect { subject.execute(project_with_stars) }.to raise_error(StandardError)
diff --git a/spec/services/projects/open_issues_count_service_spec.rb b/spec/services/projects/open_issues_count_service_spec.rb
index 562c14a8df8..c368b1ec459 100644
--- a/spec/services/projects/open_issues_count_service_spec.rb
+++ b/spec/services/projects/open_issues_count_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::OpenIssuesCountService do
- describe '#count' do
+ describe "#count" do
let(:project) { create(:project) }
- context 'when user is nil' do
- it 'does not include confidential issues in the issue count' do
+ context "when user is nil" do
+ it "does not include confidential issues in the issue count" do
create(:issue, :opened, project: project)
create(:issue, :opened, confidential: true, project: project)
@@ -13,45 +13,45 @@ describe Projects::OpenIssuesCountService do
end
end
- context 'when user is provided' do
+ context "when user is provided" do
let(:user) { create(:user) }
- context 'when user can read confidential issues' do
+ context "when user can read confidential issues" do
before do
project.add_reporter(user)
end
- it 'returns the right count with confidential issues' do
+ it "returns the right count with confidential issues" do
create(:issue, :opened, project: project)
create(:issue, :opened, confidential: true, project: project)
expect(described_class.new(project, user).count).to eq(2)
end
- it 'uses total_open_issues_count cache key' do
- expect(described_class.new(project, user).cache_key_name).to eq('total_open_issues_count')
+ it "uses total_open_issues_count cache key" do
+ expect(described_class.new(project, user).cache_key_name).to eq("total_open_issues_count")
end
end
- context 'when user cannot read confidential issues' do
+ context "when user cannot read confidential issues" do
before do
project.add_guest(user)
end
- it 'does not include confidential issues' do
+ it "does not include confidential issues" do
create(:issue, :opened, project: project)
create(:issue, :opened, confidential: true, project: project)
expect(described_class.new(project, user).count).to eq(1)
end
- it 'uses public_open_issues_count cache key' do
- expect(described_class.new(project, user).cache_key_name).to eq('public_open_issues_count')
+ it "uses public_open_issues_count cache key" do
+ expect(described_class.new(project, user).cache_key_name).to eq("public_open_issues_count")
end
end
end
- context '#refresh_cache', :use_clean_rails_memory_store_caching do
+ context "#refresh_cache", :use_clean_rails_memory_store_caching do
let(:subject) { described_class.new(project) }
before do
@@ -60,8 +60,8 @@ describe Projects::OpenIssuesCountService do
create(:issue, :opened, confidential: true, project: project)
end
- context 'when cache is empty' do
- it 'refreshes cache keys correctly' do
+ context "when cache is empty" do
+ it "refreshes cache keys correctly" do
subject.refresh_cache
expect(Rails.cache.read(subject.cache_key(described_class::PUBLIC_COUNT_KEY))).to eq(2)
@@ -69,12 +69,12 @@ describe Projects::OpenIssuesCountService do
end
end
- context 'when cache is outdated' do
+ context "when cache is outdated" do
before do
subject.refresh_cache
end
- it 'refreshes cache keys correctly' do
+ it "refreshes cache keys correctly" do
create(:issue, :opened, project: project)
create(:issue, :opened, confidential: true, project: project)
diff --git a/spec/services/projects/open_merge_requests_count_service_spec.rb b/spec/services/projects/open_merge_requests_count_service_spec.rb
index 9f49b9ec6a2..995cda9a1d3 100644
--- a/spec/services/projects/open_merge_requests_count_service_spec.rb
+++ b/spec/services/projects/open_merge_requests_count_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::OpenMergeRequestsCountService do
- describe '#count' do
- it 'returns the number of open merge requests' do
+ describe "#count" do
+ it "returns the number of open merge requests" do
project = create(:project)
create(:merge_request,
- :opened,
- source_project: project,
- target_project: project)
+ :opened,
+ source_project: project,
+ target_project: project)
expect(described_class.new(project).count).to eq(1)
end
diff --git a/spec/services/projects/operations/update_service_spec.rb b/spec/services/projects/operations/update_service_spec.rb
index 6afae3da80c..f82613bc94b 100644
--- a/spec/services/projects/operations/update_service_spec.rb
+++ b/spec/services/projects/operations/update_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::Operations::UpdateService do
set(:user) { create(:user) }
@@ -10,16 +10,16 @@ describe Projects::Operations::UpdateService do
subject { described_class.new(project, user, params) }
- describe '#execute' do
- context 'error tracking' do
- context 'with existing error tracking setting' do
+ describe "#execute" do
+ context "error tracking" do
+ context "with existing error tracking setting" do
let(:params) do
{
error_tracking_setting_attributes: {
enabled: false,
- api_url: 'http://gitlab.com/api/0/projects/org/project',
- token: 'token'
- }
+ api_url: "http://gitlab.com/api/0/projects/org/project",
+ token: "token",
+ },
}
end
@@ -27,44 +27,44 @@ describe Projects::Operations::UpdateService do
create(:project_error_tracking_setting, project: project)
end
- it 'updates the settings' do
+ it "updates the settings" do
expect(result[:status]).to eq(:success)
project.reload
expect(project.error_tracking_setting).not_to be_enabled
- expect(project.error_tracking_setting.api_url).to eq('http://gitlab.com/api/0/projects/org/project')
- expect(project.error_tracking_setting.token).to eq('token')
+ expect(project.error_tracking_setting.api_url).to eq("http://gitlab.com/api/0/projects/org/project")
+ expect(project.error_tracking_setting.token).to eq("token")
end
end
- context 'without an existing error tracking setting' do
+ context "without an existing error tracking setting" do
let(:params) do
{
error_tracking_setting_attributes: {
enabled: true,
- api_url: 'http://gitlab.com/api/0/projects/org/project',
- token: 'token'
- }
+ api_url: "http://gitlab.com/api/0/projects/org/project",
+ token: "token",
+ },
}
end
- it 'creates a setting' do
+ it "creates a setting" do
expect(result[:status]).to eq(:success)
expect(project.error_tracking_setting).to be_enabled
- expect(project.error_tracking_setting.api_url).to eq('http://gitlab.com/api/0/projects/org/project')
- expect(project.error_tracking_setting.token).to eq('token')
+ expect(project.error_tracking_setting.api_url).to eq("http://gitlab.com/api/0/projects/org/project")
+ expect(project.error_tracking_setting.token).to eq("token")
end
end
- context 'with invalid parameters' do
+ context "with invalid parameters" do
let(:params) { {} }
let!(:error_tracking_setting) do
create(:project_error_tracking_setting, project: project)
end
- it 'does nothing' do
+ it "does nothing" do
expect(result[:status]).to eq(:success)
expect(project.reload.error_tracking_setting)
.to eq(error_tracking_setting)
@@ -72,12 +72,12 @@ describe Projects::Operations::UpdateService do
end
end
- context 'with inappropriate params' do
- let(:params) { { name: '' } }
+ context "with inappropriate params" do
+ let(:params) { {name: ""} }
let!(:original_name) { project.name }
- it 'ignores params' do
+ it "ignores params" do
expect(result[:status]).to eq(:success)
expect(project.reload.name).to eq(original_name)
end
diff --git a/spec/services/projects/overwrite_project_service_spec.rb b/spec/services/projects/overwrite_project_service_spec.rb
index c7900629f5f..4a1a0391be1 100644
--- a/spec/services/projects/overwrite_project_service_spec.rb
+++ b/spec/services/projects/overwrite_project_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::OverwriteProjectService do
include ProjectForksHelper
@@ -14,12 +14,12 @@ describe Projects::OverwriteProjectService do
subject { described_class.new(project_to, user) }
before do
- allow(project_to).to receive(:import_data).and_return(double(data: { 'original_path' => project_from.path }))
+ allow(project_to).to receive(:import_data).and_return(double(data: {"original_path" => project_from.path}))
end
- describe '#execute' do
- shared_examples 'overwrite actions' do
- it 'moves deploy keys' do
+ describe "#execute" do
+ shared_examples "overwrite actions" do
+ it "moves deploy keys" do
deploy_keys_count = project_from.deploy_keys_projects.count
subject.execute(project_from)
@@ -27,7 +27,7 @@ describe Projects::OverwriteProjectService do
expect(project_to.deploy_keys_projects.count).to eq deploy_keys_count
end
- it 'moves notification settings' do
+ it "moves notification settings" do
notification_count = project_from.notification_settings.count
subject.execute(project_from)
@@ -35,7 +35,7 @@ describe Projects::OverwriteProjectService do
expect(project_to.notification_settings.count).to eq notification_count
end
- it 'moves users stars' do
+ it "moves users stars" do
stars_count = project_from.users_star_projects.count
subject.execute(project_from)
@@ -45,7 +45,7 @@ describe Projects::OverwriteProjectService do
expect(project_to.star_count).to eq stars_count
end
- it 'moves project group links' do
+ it "moves project group links" do
group_links_count = project_from.project_group_links.count
subject.execute(project_from)
@@ -53,7 +53,7 @@ describe Projects::OverwriteProjectService do
expect(project_to.project_group_links.count).to eq group_links_count
end
- it 'moves memberships and authorizations' do
+ it "moves memberships and authorizations" do
members_count = project_from.project_members.count
project_authorizations = project_from.project_authorizations.count
@@ -63,7 +63,7 @@ describe Projects::OverwriteProjectService do
expect(project_to.project_authorizations.count).to eq project_authorizations
end
- context 'moves lfs objects relationships' do
+ context "moves lfs objects relationships" do
before do
create_list(:lfs_objects_project, 3, project: project_from)
end
@@ -77,25 +77,25 @@ describe Projects::OverwriteProjectService do
end
end
- it 'removes the original project' do
+ it "removes the original project" do
subject.execute(project_from)
expect { Project.find(project_from.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'renames the project' do
+ it "renames the project" do
subject.execute(project_from)
expect(project_to.full_path).to eq project_from.full_path
end
end
- context 'when project does not have any relation' do
- it_behaves_like 'overwrite actions'
+ context "when project does not have any relation" do
+ it_behaves_like "overwrite actions"
end
- context 'when project with elements' do
- it_behaves_like 'overwrite actions' do
+ context "when project with elements" do
+ it_behaves_like "overwrite actions" do
let(:maintainer_user) { create(:user) }
let(:reporter_user) { create(:user) }
let(:developer_user) { create(:user) }
@@ -117,9 +117,9 @@ describe Projects::OverwriteProjectService do
end
end
- context 'forks' do
- context 'when moving a root forked project' do
- it 'moves the descendant forks' do
+ context "forks" do
+ context "when moving a root forked project" do
+ it "moves the descendant forks" do
expect(project_from.forks.count).to eq 2
expect(project_to.forks.count).to eq 0
@@ -133,7 +133,7 @@ describe Projects::OverwriteProjectService do
expect(lvl1_forked_project_2.fork_network_member.forked_from_project).to eq project_to
end
- it 'updates the fork network' do
+ it "updates the fork network" do
expect(project_from.fork_network.root_project).to eq project_from
expect(project_from.fork_network.fork_network_members.map(&:project)).to include project_from
@@ -143,10 +143,10 @@ describe Projects::OverwriteProjectService do
expect(project_to.fork_network.fork_network_members.map(&:project)).not_to include project_from
end
end
- context 'when moving a intermediate forked project' do
+ context "when moving a intermediate forked project" do
let(:project_to) { create(:project, namespace: lvl1_forked_project_1.namespace) }
- it 'moves the descendant forks' do
+ it "moves the descendant forks" do
expect(lvl1_forked_project_1.forks.count).to eq 2
expect(project_to.forks.count).to eq 0
@@ -160,14 +160,14 @@ describe Projects::OverwriteProjectService do
expect(lvl2_forked_project_1_2.fork_network_member.forked_from_project).to eq project_to
end
- it 'moves the ascendant fork' do
+ it "moves the ascendant fork" do
subject.execute(lvl1_forked_project_1)
expect(project_to.reload.forked_from_project).to eq project_from
expect(project_to.fork_network_member.forked_from_project).to eq project_from
end
- it 'does not update fork network' do
+ it "does not update fork network" do
subject.execute(lvl1_forked_project_1)
expect(project_to.reload.fork_network.root_project).to eq project_from
@@ -175,8 +175,8 @@ describe Projects::OverwriteProjectService do
end
end
- context 'if an exception is raised' do
- it 'rollbacks changes' do
+ context "if an exception is raised" do
+ it "rollbacks changes" do
updated_at = project_from.updated_at
allow(subject).to receive(:rename_project).and_raise(StandardError)
@@ -186,7 +186,7 @@ describe Projects::OverwriteProjectService do
expect(project_from.reload.updated_at.change(usec: 0)).to eq updated_at.change(usec: 0)
end
- it 'tries to restore the original project repositories' do
+ it "tries to restore the original project repositories" do
allow(subject).to receive(:rename_project).and_raise(StandardError)
expect(subject).to receive(:attempt_restore_repositories).with(project_from)
diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb
index 6040f9100f8..10dc1414c9d 100644
--- a/spec/services/projects/participants_service_spec.rb
+++ b/spec/services/projects/participants_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::ParticipantsService do
- describe '#groups' do
- describe 'avatar_url' do
+ describe "#groups" do
+ describe "avatar_url" do
let(:project) { create(:project, :public) }
- let(:group) { create(:group, avatar: fixture_file_upload('spec/fixtures/dk.png')) }
+ let(:group) { create(:group, avatar: fixture_file_upload("spec/fixtures/dk.png")) }
let(:user) { create(:user) }
let!(:group_member) { create(:group_member, group: group, user: user) }
- it 'should return an url for the avatar' do
+ it "should return an url for the avatar" do
participants = described_class.new(project, user)
groups = participants.groups
@@ -16,8 +16,8 @@ describe Projects::ParticipantsService do
expect(groups.first[:avatar_url]).to eq("/uploads/-/system/group/avatar/#{group.id}/dk.png")
end
- it 'should return an url for the avatar with relative url' do
- stub_config_setting(relative_url_root: '/gitlab')
+ it "should return an url for the avatar with relative url" do
+ stub_config_setting(relative_url_root: "/gitlab")
stub_config_setting(url: Settings.send(:build_gitlab_url))
participants = described_class.new(project, user)
diff --git a/spec/services/projects/propagate_service_template_spec.rb b/spec/services/projects/propagate_service_template_spec.rb
index f4c59735c43..ddd6350f4c6 100644
--- a/spec/services/projects/propagate_service_template_spec.rb
+++ b/spec/services/projects/propagate_service_template_spec.rb
@@ -1,23 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::PropagateServiceTemplate do
- describe '.propagate' do
+ describe ".propagate" do
let!(:service_template) do
PushoverService.create(
template: true,
active: true,
properties: {
- device: 'MyDevice',
- sound: 'mic',
+ device: "MyDevice",
+ sound: "mic",
priority: 4,
- user_key: 'asdf',
- api_key: '123456789'
- })
+ user_key: "asdf",
+ api_key: "123456789",
+ }
+ )
end
let!(:project) { create(:project) }
- it 'creates services for projects' do
+ it "creates services for projects" do
expect(project.pushover_service).to be_nil
described_class.propagate(service_template)
@@ -25,16 +26,16 @@ describe Projects::PropagateServiceTemplate do
expect(project.reload.pushover_service).to be_present
end
- it 'creates services for a project that has another service' do
+ it "creates services for a project that has another service" do
BambooService.create(
template: true,
active: true,
project: project,
properties: {
- bamboo_url: 'http://gitlab.com',
- username: 'mic',
+ bamboo_url: "http://gitlab.com",
+ username: "mic",
password: "password",
- build_key: 'build'
+ build_key: "build",
}
)
@@ -45,15 +46,15 @@ describe Projects::PropagateServiceTemplate do
expect(project.reload.pushover_service).to be_present
end
- it 'does not create the service if it exists already' do
+ it "does not create the service if it exists already" do
other_service = BambooService.create(
template: true,
active: true,
properties: {
- bamboo_url: 'http://gitlab.com',
- username: 'mic',
+ bamboo_url: "http://gitlab.com",
+ username: "mic",
password: "password",
- build_key: 'build'
+ build_key: "build",
}
)
@@ -64,40 +65,40 @@ describe Projects::PropagateServiceTemplate do
.not_to change { Service.count }
end
- it 'creates the service containing the template attributes' do
+ it "creates the service containing the template attributes" do
described_class.propagate(service_template)
expect(project.pushover_service.properties).to eq(service_template.properties)
end
- describe 'bulk update' do
+ describe "bulk update" do
let(:project_total) { 5 }
before do
- stub_const 'Projects::PropagateServiceTemplate::BATCH_SIZE', 3
+ stub_const "Projects::PropagateServiceTemplate::BATCH_SIZE", 3
project_total.times { create(:project) }
described_class.propagate(service_template)
end
- it 'creates services for all projects' do
+ it "creates services for all projects" do
expect(Service.all.reload.count).to eq(project_total + 2)
end
end
- describe 'external tracker' do
- it 'updates the project external tracker' do
- service_template.update!(category: 'issue_tracker', default: false)
+ describe "external tracker" do
+ it "updates the project external tracker" do
+ service_template.update!(category: "issue_tracker", default: false)
expect { described_class.propagate(service_template) }
.to change { project.reload.has_external_issue_tracker }.to(true)
end
end
- describe 'external wiki' do
- it 'updates the project external tracker' do
- service_template.update!(type: 'ExternalWikiService')
+ describe "external wiki" do
+ it "updates the project external tracker" do
+ service_template.update!(type: "ExternalWikiService")
expect { described_class.propagate(service_template) }
.to change { project.reload.has_external_wiki }.to(true)
diff --git a/spec/services/projects/protect_default_branch_service_spec.rb b/spec/services/projects/protect_default_branch_service_spec.rb
index c145b2c06c6..cbe97ae921c 100644
--- a/spec/services/projects/protect_default_branch_service_spec.rb
+++ b/spec/services/projects/protect_default_branch_service_spec.rb
@@ -1,19 +1,19 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Projects::ProtectDefaultBranchService do
let(:service) { described_class.new(project) }
let(:project) { instance_spy(Project) }
- describe '#execute' do
+ describe "#execute" do
before do
allow(service)
.to receive(:protect_default_branch)
end
- context 'without a default branch' do
- it 'does nothing' do
+ context "without a default branch" do
+ it "does nothing" do
allow(service)
.to receive(:default_branch)
.and_return(nil)
@@ -25,11 +25,11 @@ describe Projects::ProtectDefaultBranchService do
end
end
- context 'with a default branch' do
- it 'protects the default branch' do
+ context "with a default branch" do
+ it "protects the default branch" do
allow(service)
.to receive(:default_branch)
- .and_return('master')
+ .and_return("master")
service.execute
@@ -39,21 +39,21 @@ describe Projects::ProtectDefaultBranchService do
end
end
- describe '#protect_default_branch' do
+ describe "#protect_default_branch" do
before do
allow(service)
.to receive(:default_branch)
- .and_return('master')
+ .and_return("master")
allow(project)
.to receive(:change_head)
- .with('master')
+ .with("master")
allow(service)
.to receive(:create_protected_branch)
end
- context 'when branch protection is needed' do
+ context "when branch protection is needed" do
before do
allow(service)
.to receive(:protect_branch?)
@@ -63,14 +63,14 @@ describe Projects::ProtectDefaultBranchService do
.to receive(:create_protected_branch)
end
- it 'changes the HEAD of the project' do
+ it "changes the HEAD of the project" do
service.protect_default_branch
expect(project)
.to have_received(:change_head)
end
- it 'protects the default branch' do
+ it "protects the default branch" do
service.protect_default_branch
expect(service)
@@ -78,21 +78,21 @@ describe Projects::ProtectDefaultBranchService do
end
end
- context 'when branch protection is not needed' do
+ context "when branch protection is not needed" do
before do
allow(service)
.to receive(:protect_branch?)
.and_return(false)
end
- it 'changes the HEAD of the project' do
+ it "changes the HEAD of the project" do
service.protect_default_branch
expect(project)
.to have_received(:change_head)
end
- it 'does not protect the default branch' do
+ it "does not protect the default branch" do
service.protect_default_branch
expect(service)
@@ -101,15 +101,15 @@ describe Projects::ProtectDefaultBranchService do
end
end
- describe '#create_protected_branch' do
- it 'creates the protected branch' do
+ describe "#create_protected_branch" do
+ it "creates the protected branch" do
creator = instance_spy(User)
create_service = instance_spy(ProtectedBranches::CreateService)
access_level = Gitlab::Access::DEVELOPER
params = {
- name: 'master',
- push_access_levels_attributes: [{ access_level: access_level }],
- merge_access_levels_attributes: [{ access_level: access_level }]
+ name: "master",
+ push_access_levels_attributes: [{access_level: access_level}],
+ merge_access_levels_attributes: [{access_level: access_level}],
}
allow(project)
@@ -131,7 +131,7 @@ describe Projects::ProtectDefaultBranchService do
allow(service)
.to receive(:default_branch)
- .and_return('master')
+ .and_return("master")
allow(create_service)
.to receive(:execute)
@@ -144,9 +144,9 @@ describe Projects::ProtectDefaultBranchService do
end
end
- describe '#protect_branch?' do
- context 'when default branch protection is disabled' do
- it 'returns false' do
+ describe "#protect_branch?" do
+ context "when default branch protection is disabled" do
+ it "returns false" do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
.and_return(Gitlab::Access::PROTECTION_NONE)
@@ -155,7 +155,7 @@ describe Projects::ProtectDefaultBranchService do
end
end
- context 'when default branch protection is enabled' do
+ context "when default branch protection is enabled" do
before do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
@@ -163,22 +163,22 @@ describe Projects::ProtectDefaultBranchService do
allow(service)
.to receive(:default_branch)
- .and_return('master')
+ .and_return("master")
end
- it 'returns false if the branch is already protected' do
+ it "returns false if the branch is already protected" do
allow(ProtectedBranch)
.to receive(:protected?)
- .with(project, 'master')
+ .with(project, "master")
.and_return(true)
expect(service.protect_branch?).to eq(false)
end
- it 'returns true if the branch is not yet protected' do
+ it "returns true if the branch is not yet protected" do
allow(ProtectedBranch)
.to receive(:protected?)
- .with(project, 'master')
+ .with(project, "master")
.and_return(false)
expect(service.protect_branch?).to eq(true)
@@ -186,19 +186,19 @@ describe Projects::ProtectDefaultBranchService do
end
end
- describe '#default_branch' do
- it 'returns the default branch of the project' do
+ describe "#default_branch" do
+ it "returns the default branch of the project" do
allow(project)
.to receive(:default_branch)
- .and_return('master')
+ .and_return("master")
- expect(service.default_branch).to eq('master')
+ expect(service.default_branch).to eq("master")
end
end
- describe '#push_access_level' do
- context 'when developers can push' do
- it 'returns the DEVELOPER access level' do
+ describe "#push_access_level" do
+ context "when developers can push" do
+ it "returns the DEVELOPER access level" do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
.and_return(Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
@@ -207,8 +207,8 @@ describe Projects::ProtectDefaultBranchService do
end
end
- context 'when developers can not push' do
- it 'returns the MAINTAINER access level' do
+ context "when developers can not push" do
+ it "returns the MAINTAINER access level" do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
.and_return(Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
@@ -218,9 +218,9 @@ describe Projects::ProtectDefaultBranchService do
end
end
- describe '#merge_access_level' do
- context 'when developers can merge' do
- it 'returns the DEVELOPER access level' do
+ describe "#merge_access_level" do
+ context "when developers can merge" do
+ it "returns the DEVELOPER access level" do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
.and_return(Gitlab::Access::PROTECTION_DEV_CAN_MERGE)
@@ -229,8 +229,8 @@ describe Projects::ProtectDefaultBranchService do
end
end
- context 'when developers can not merge' do
- it 'returns the MAINTAINER access level' do
+ context "when developers can not merge" do
+ it "returns the MAINTAINER access level" do
allow(Gitlab::CurrentSettings)
.to receive(:default_branch_protection)
.and_return(Gitlab::Access::PROTECTION_DEV_CAN_PUSH)
diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb
index aae50d5307f..304e7f50bc6 100644
--- a/spec/services/projects/transfer_service_spec.rb
+++ b/spec/services/projects/transfer_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::TransferService do
include GitHelpers
@@ -8,7 +8,7 @@ describe Projects::TransferService do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :legacy_storage, namespace: user.namespace) }
- context 'namespace -> namespace' do
+ context "namespace -> namespace" do
before do
allow_any_instance_of(Gitlab::UploadsTransfer)
.to receive(:move_project).and_return(true)
@@ -22,30 +22,30 @@ describe Projects::TransferService do
it { expect(project.namespace).to eq(group) }
end
- context 'when transfer succeeds' do
+ context "when transfer succeeds" do
before do
group.add_owner(user)
end
- it 'sends notifications' do
+ it "sends notifications" do
expect_any_instance_of(NotificationService).to receive(:project_was_moved)
transfer_project(project, user, group)
end
- it 'invalidates the user\'s personal_project_count cache' do
+ it "invalidates the user's personal_project_count cache" do
expect(user).to receive(:invalidate_personal_projects_count)
transfer_project(project, user, group)
end
- it 'executes system hooks' do
+ it "executes system hooks" do
transfer_project(project, user, group) do |service|
expect(service).to receive(:execute_system_hooks)
end
end
- it 'disk path has moved' do
+ it "disk path has moved" do
old_path = project.repository.disk_path
old_full_path = project.repository.full_path
@@ -57,13 +57,13 @@ describe Projects::TransferService do
expect(project.disk_path).to start_with(group.path)
end
- it 'updates project full path in .git/config' do
+ it "updates project full path in .git/config" do
transfer_project(project, user, group)
- expect(rugged_config['gitlab.fullpath']).to eq "#{group.full_path}/#{project.path}"
+ expect(rugged_config["gitlab.fullpath"]).to eq "#{group.full_path}/#{project.path}"
end
- it 'updates storage location' do
+ it "updates storage location" do
transfer_project(project, user, group)
expect(project.project_repository).to have_attributes(
@@ -72,11 +72,11 @@ describe Projects::TransferService do
)
end
- context 'new group has a kubernetes cluster' do
+ context "new group has a kubernetes cluster" do
let(:group_cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:group) { group_cluster.group }
- let(:token) { 'aaaa' }
+ let(:token) { "aaaa" }
let(:service_account_creator) { double(Clusters::Gcp::Kubernetes::CreateOrUpdateServiceAccountService, execute: true) }
let(:secrets_fetcher) { double(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService, execute: token) }
@@ -87,7 +87,7 @@ describe Projects::TransferService do
expect(Clusters::Gcp::Kubernetes::FetchKubernetesTokenService).to receive(:new).and_return(secrets_fetcher)
end
- it 'creates kubernetes namespace for the project' do
+ it "creates kubernetes namespace for the project" do
subject
expect(project.kubernetes_namespaces.count).to eq(1)
@@ -99,13 +99,13 @@ describe Projects::TransferService do
end
end
- context 'when transfer fails' do
+ context "when transfer fails" do
let!(:original_path) { project_path(project) }
def attempt_project_transfer(&block)
- expect do
+ expect {
transfer_project(project, user, group, &block)
- end.to raise_error(ActiveRecord::ActiveRecordError)
+ }.to raise_error(ActiveRecord::ActiveRecordError)
end
before do
@@ -124,17 +124,17 @@ describe Projects::TransferService do
project_path(project)
end
- it 'rolls back repo location' do
+ it "rolls back repo location" do
attempt_project_transfer
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be(true)
expect(original_path).to eq current_path
end
- it 'rolls back project full path in .git/config' do
+ it "rolls back project full path in .git/config" do
attempt_project_transfer
- expect(rugged_config['gitlab.fullpath']).to eq project.full_path
+ expect(rugged_config["gitlab.fullpath"]).to eq project.full_path
end
it "doesn't send move notifications" do
@@ -149,7 +149,7 @@ describe Projects::TransferService do
end
end
- it 'does not update storage location' do
+ it "does not update storage location" do
create(:project_repository, project: project)
attempt_project_transfer
@@ -161,22 +161,22 @@ describe Projects::TransferService do
end
end
- context 'namespace -> no namespace' do
+ context "namespace -> no namespace" do
before do
@result = transfer_project(project, user, nil)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
- it { expect(project.errors.messages[:new_namespace].first).to eq 'Please select a new namespace for your project.' }
+ it { expect(project.errors.messages[:new_namespace].first).to eq "Please select a new namespace for your project." }
end
- context 'disallow transferring of project with tags' do
+ context "disallow transferring of project with tags" do
let(:container_repository) { create(:container_repository) }
before do
stub_container_registry_config(enabled: true)
- stub_container_registry_tags(repository: :any, tags: ['tag'])
+ stub_container_registry_tags(repository: :any, tags: ["tag"])
project.container_repositories << container_repository
end
@@ -185,7 +185,7 @@ describe Projects::TransferService do
it { is_expected.to be_falsey }
end
- context 'namespace -> not allowed namespace' do
+ context "namespace -> not allowed namespace" do
before do
@result = transfer_project(project, user, group)
end
@@ -194,15 +194,15 @@ describe Projects::TransferService do
it { expect(project.namespace).to eq(user.namespace) }
end
- context 'namespace which contains orphan repository with same projects path name' do
- let(:repository_storage) { 'default' }
+ context "namespace which contains orphan repository with same projects path name" do
+ let(:repository_storage) { "default" }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
before do
group.add_owner(user)
unless gitlab_shell.create_repository(repository_storage, "#{group.full_path}/#{project.path}", project.full_path)
- raise 'failed to add repository'
+ raise "failed to add repository"
end
@result = transfer_project(project, user, group)
@@ -214,36 +214,36 @@ describe Projects::TransferService do
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
- it { expect(project.errors[:new_namespace]).to include('Cannot move project') }
+ it { expect(project.errors[:new_namespace]).to include("Cannot move project") }
end
- context 'target namespace containing the same project name' do
+ context "target namespace containing the same project name" do
before do
group.add_owner(user)
- project.update(name: 'new_name')
+ project.update(name: "new_name")
- create(:project, name: 'new_name', group: group, path: 'other')
+ create(:project, name: "new_name", group: group, path: "other")
@result = transfer_project(project, user, group)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
- it { expect(project.errors[:new_namespace]).to include('Project with same name or path in target namespace already exists') }
+ it { expect(project.errors[:new_namespace]).to include("Project with same name or path in target namespace already exists") }
end
- context 'target namespace containing the same project path' do
+ context "target namespace containing the same project path" do
before do
group.add_owner(user)
- create(:project, name: 'other-name', path: project.path, group: group)
+ create(:project, name: "other-name", path: project.path, group: group)
@result = transfer_project(project, user, group)
end
it { expect(@result).to eq false }
it { expect(project.namespace).to eq(user.namespace) }
- it { expect(project.errors[:new_namespace]).to include('Project with same name or path in target namespace already exists') }
+ it { expect(project.errors[:new_namespace]).to include("Project with same name or path in target namespace already exists") }
end
def transfer_project(project, user, new_namespace)
@@ -254,14 +254,14 @@ describe Projects::TransferService do
service.execute(new_namespace)
end
- context 'visibility level' do
+ context "visibility level" do
let(:internal_group) { create(:group, :internal) }
before do
internal_group.add_owner(user)
end
- context 'when namespace visibility level < project visibility level' do
+ context "when namespace visibility level < project visibility level" do
let(:public_project) { create(:project, :public, :repository, namespace: user.namespace) }
before do
@@ -271,7 +271,7 @@ describe Projects::TransferService do
it { expect(public_project.visibility_level).to eq(internal_group.visibility_level) }
end
- context 'when namespace visibility level > project visibility level' do
+ context "when namespace visibility level > project visibility level" do
let(:private_project) { create(:project, :private, :repository, namespace: user.namespace) }
before do
@@ -282,8 +282,8 @@ describe Projects::TransferService do
end
end
- context 'missing group labels applied to issues or merge requests' do
- it 'delegates tranfer to Labels::TransferService' do
+ context "missing group labels applied to issues or merge requests" do
+ it "delegates tranfer to Labels::TransferService" do
group.add_owner(user)
expect_any_instance_of(Labels::TransferService).to receive(:execute).once.and_call_original
@@ -292,14 +292,14 @@ describe Projects::TransferService do
end
end
- context 'when hashed storage in use' do
+ context "when hashed storage in use" do
let(:hashed_project) { create(:project, :repository, namespace: user.namespace) }
before do
group.add_owner(user)
end
- it 'does not move the directory' do
+ it "does not move the directory" do
old_path = hashed_project.repository.disk_path
old_full_path = hashed_project.repository.full_path
@@ -312,7 +312,7 @@ describe Projects::TransferService do
end
end
- describe 'refreshing project authorizations' do
+ describe "refreshing project authorizations" do
let(:group) { create(:group) }
let(:owner) { project.namespace.owner }
let(:group_member) { create(:user) }
@@ -322,14 +322,14 @@ describe Projects::TransferService do
group.add_user(group_member, GroupMember::DEVELOPER)
end
- it 'refreshes the permissions of the old and new namespace' do
+ it "refreshes the permissions of the old and new namespace" do
transfer_project(project, owner, group)
expect(group_member.authorized_projects).to include(project)
expect(owner.authorized_projects).to include(project)
end
- it 'only schedules a single job for every user' do
+ it "only schedules a single job for every user" do
expect(UserProjectAccessChangedService).to receive(:new)
.with([owner.id, group_member.id])
.and_call_original
diff --git a/spec/services/projects/unlink_fork_service_spec.rb b/spec/services/projects/unlink_fork_service_spec.rb
index 014aab44281..17775ce65bd 100644
--- a/spec/services/projects/unlink_fork_service_spec.rb
+++ b/spec/services/projects/unlink_fork_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::UnlinkForkService do
include ProjectForksHelper
@@ -9,7 +9,7 @@ describe Projects::UnlinkForkService do
let(:forked_project) { fork_project(project, user) }
let(:user) { create(:user) }
- context 'with opened merge request on the source project' do
+ context "with opened merge request on the source project" do
let(:merge_request) { create(:merge_request, source_project: forked_project, target_project: forked_project.forked_from_project) }
let(:merge_request2) { create(:merge_request, source_project: forked_project, target_project: fork_project(project)) }
let(:merge_request_in_fork) { create(:merge_request, source_project: forked_project, target_project: forked_project) }
@@ -22,19 +22,19 @@ describe Projects::UnlinkForkService do
.and_return(mr_close_service)
end
- it 'close all pending merge requests' do
+ it "close all pending merge requests" do
expect(mr_close_service).to receive(:execute).with(merge_request)
expect(mr_close_service).to receive(:execute).with(merge_request2)
subject.execute
end
- it 'does not close merge requests for the project being unlinked' do
+ it "does not close merge requests for the project being unlinked" do
expect(mr_close_service).not_to receive(:execute).with(merge_request_in_fork)
end
end
- it 'removes the link to the fork network' do
+ it "removes the link to the fork network" do
expect(forked_project.fork_network_member).to be_present
expect(forked_project.fork_network).to be_present
@@ -45,7 +45,7 @@ describe Projects::UnlinkForkService do
expect(forked_project.reload.fork_network).to be_nil
end
- it 'refreshes the forks count cache of the source project' do
+ it "refreshes the forks count cache of the source project" do
source = forked_project.forked_from_project
expect(source.forks_count).to eq(1)
@@ -55,28 +55,28 @@ describe Projects::UnlinkForkService do
expect(source.forks_count).to be_zero
end
- context 'when the source has LFS objects' do
+ context "when the source has LFS objects" do
let(:lfs_object) { create(:lfs_object) }
before do
lfs_object.projects << project
end
- it 'links the fork to the lfs object before unlinking' do
+ it "links the fork to the lfs object before unlinking" do
subject.execute
expect(lfs_object.projects).to include(forked_project)
end
- it 'does not fail if the lfs objects were already linked' do
+ it "does not fail if the lfs objects were already linked" do
lfs_object.projects << forked_project
expect { subject.execute }.not_to raise_error
end
end
- context 'when the original project was deleted' do
- it 'does not fail when the original project is deleted' do
+ context "when the original project was deleted" do
+ it "does not fail when the original project is deleted" do
source = forked_project.forked_from_project
source.destroy
forked_project.reload
diff --git a/spec/services/projects/update_pages_configuration_service_spec.rb b/spec/services/projects/update_pages_configuration_service_spec.rb
index 7f5ef3129d7..9ff82aa9f9c 100644
--- a/spec/services/projects/update_pages_configuration_service_spec.rb
+++ b/spec/services/projects/update_pages_configuration_service_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::UpdatePagesConfigurationService do
let(:project) { create(:project) }
let(:service) { described_class.new(project) }
describe "#update" do
- let(:file) { Tempfile.new('pages-test') }
+ let(:file) { Tempfile.new("pages-test") }
subject { service.execute }
@@ -18,21 +18,21 @@ describe Projects::UpdatePagesConfigurationService do
allow(service).to receive(:pages_config_file).and_return(file.path)
end
- context 'when configuration changes' do
- it 'updates the .update file' do
+ context "when configuration changes" do
+ it "updates the .update file" do
expect(service).to receive(:reload_daemon).and_call_original
expect(subject).to include(status: :success, reload: true)
end
end
- context 'when configuration does not change' do
+ context "when configuration does not change" do
before do
# we set the configuration
service.execute
end
- it 'does not update the .update file' do
+ it "does not update the .update file" do
expect(service).not_to receive(:reload_daemon)
expect(subject).to include(status: :success, reload: false)
diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb
index 8b70845befe..39ce4dc28b5 100644
--- a/spec/services/projects/update_pages_service_spec.rb
+++ b/spec/services/projects/update_pages_service_spec.rb
@@ -2,9 +2,9 @@ require "spec_helper"
describe Projects::UpdatePagesService do
set(:project) { create(:project, :repository) }
- set(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
- set(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
- let(:invalid_file) { fixture_file_upload('spec/fixtures/dk.png') }
+ set(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit("HEAD").sha) }
+ set(:build) { create(:ci_build, pipeline: pipeline, ref: "HEAD") }
+ let(:invalid_file) { fixture_file_upload("spec/fixtures/dk.png") }
let(:file) { fixture_file_upload("spec/fixtures/pages.zip") }
let(:empty_file) { fixture_file_upload("spec/fixtures/pages_empty.zip") }
@@ -19,19 +19,19 @@ describe Projects::UpdatePagesService do
project.remove_pages
end
- context '::TMP_EXTRACT_PATH' do
+ context "::TMP_EXTRACT_PATH" do
subject { described_class::TMP_EXTRACT_PATH }
it { is_expected.not_to match(Gitlab::PathRegex.namespace_format_regex) }
end
- context 'legacy artifacts' do
+ context "legacy artifacts" do
before do
build.update(legacy_artifacts_file: file)
build.update(legacy_artifacts_metadata: metadata)
end
- describe 'pages artifacts' do
+ describe "pages artifacts" do
it "doesn't delete artifacts after deploying" do
expect(execute).to eq(:success)
@@ -39,7 +39,7 @@ describe Projects::UpdatePagesService do
end
end
- it 'succeeds' do
+ it "succeeds" do
expect(project.pages_deployed?).to be_falsey
expect(execute).to eq(:success)
expect(project.pages_deployed?).to be_truthy
@@ -50,12 +50,12 @@ describe Projects::UpdatePagesService do
end
end
- it 'limits pages size' do
+ it "limits pages size" do
stub_application_setting(max_pages_size: 1)
expect(execute).not_to eq(:success)
end
- it 'removes pages after destroy' do
+ it "removes pages after destroy" do
expect(PagesWorker).to receive(:perform_in)
expect(project.pages_deployed?).to be_falsey
expect(execute).to eq(:success)
@@ -64,13 +64,13 @@ describe Projects::UpdatePagesService do
expect(project.pages_deployed?).to be_falsey
end
- it 'fails if sha on branch is not latest' do
- build.update(ref: 'feature')
+ it "fails if sha on branch is not latest" do
+ build.update(ref: "feature")
expect(execute).not_to eq(:success)
end
- it 'fails for empty file fails' do
+ it "fails for empty file fails" do
build.update(legacy_artifacts_file: empty_file)
expect { execute }
@@ -78,7 +78,7 @@ describe Projects::UpdatePagesService do
end
end
- context 'for new artifacts' do
+ context "for new artifacts" do
context "for a valid job" do
before do
create(:ci_job_artifact, file: file, job: build)
@@ -87,7 +87,7 @@ describe Projects::UpdatePagesService do
build.reload
end
- describe 'pages artifacts' do
+ describe "pages artifacts" do
it "doesn't delete artifacts after deploying" do
expect(execute).to eq(:success)
@@ -95,7 +95,7 @@ describe Projects::UpdatePagesService do
end
end
- it 'succeeds' do
+ it "succeeds" do
expect(project.pages_deployed?).to be_falsey
expect(execute).to eq(:success)
expect(project.pages_deployed?).to be_truthy
@@ -106,12 +106,12 @@ describe Projects::UpdatePagesService do
end
end
- it 'limits pages size' do
+ it "limits pages size" do
stub_application_setting(max_pages_size: 1)
expect(execute).not_to eq(:success)
end
- it 'removes pages after destroy' do
+ it "removes pages after destroy" do
expect(PagesWorker).to receive(:perform_in)
expect(project.pages_deployed?).to be_falsey
expect(execute).to eq(:success)
@@ -120,42 +120,42 @@ describe Projects::UpdatePagesService do
expect(project.pages_deployed?).to be_falsey
end
- it 'fails if sha on branch is not latest' do
- build.update(ref: 'feature')
+ it "fails if sha on branch is not latest" do
+ build.update(ref: "feature")
expect(execute).not_to eq(:success)
end
- context 'when using empty file' do
+ context "when using empty file" do
let(:file) { empty_file }
- it 'fails to extract' do
+ it "fails to extract" do
expect { execute }
.to raise_error(Projects::UpdatePagesService::FailedToExtractError)
end
end
- context 'when using pages with non-writeable public' do
+ context "when using pages with non-writeable public" do
let(:file) { fixture_file_upload("spec/fixtures/pages_non_writeable.zip") }
- context 'when using RubyZip' do
+ context "when using RubyZip" do
before do
stub_feature_flags(safezip_use_rubyzip: true)
end
- it 'succeeds to extract' do
+ it "succeeds to extract" do
expect(execute).to eq(:success)
end
end
end
- context 'when timeout happens by DNS error' do
+ context "when timeout happens by DNS error" do
before do
allow_any_instance_of(described_class)
.to receive(:extract_zip_archive!).and_raise(SocketError)
end
- it 'raises an error' do
+ it "raises an error" do
expect { execute }.to raise_error(SocketError)
build.reload
@@ -163,14 +163,14 @@ describe Projects::UpdatePagesService do
end
end
- context 'when failed to extract zip artifacts' do
+ context "when failed to extract zip artifacts" do
before do
expect_any_instance_of(described_class)
.to receive(:extract_zip_archive!)
.and_raise(Projects::UpdatePagesService::FailedToExtractError)
end
- it 'raises an error' do
+ it "raises an error" do
expect { execute }
.to raise_error(Projects::UpdatePagesService::FailedToExtractError)
@@ -179,12 +179,12 @@ describe Projects::UpdatePagesService do
end
end
- context 'when missing artifacts metadata' do
+ context "when missing artifacts metadata" do
before do
expect(build).to receive(:artifacts_metadata?).and_return(false)
end
- it 'does not raise an error as failed job' do
+ it "does not raise an error as failed job" do
execute
build.reload
@@ -194,27 +194,27 @@ describe Projects::UpdatePagesService do
end
end
- it 'fails to remove project pages when no pages is deployed' do
+ it "fails to remove project pages when no pages is deployed" do
expect(PagesWorker).not_to receive(:perform_in)
expect(project.pages_deployed?).to be_falsey
project.destroy
end
- it 'fails if no artifacts' do
+ it "fails if no artifacts" do
expect(execute).not_to eq(:success)
end
- it 'fails for invalid archive' do
+ it "fails for invalid archive" do
build.update(legacy_artifacts_file: invalid_file)
expect(execute).not_to eq(:success)
end
- describe 'maximum pages artifacts size' do
- let(:metadata) { spy('metadata') }
+ describe "maximum pages artifacts size" do
+ let(:metadata) { spy("metadata") }
before do
- file = fixture_file_upload('spec/fixtures/pages.zip')
- metafile = fixture_file_upload('spec/fixtures/pages.zip.meta')
+ file = fixture_file_upload("spec/fixtures/pages.zip")
+ metafile = fixture_file_upload("spec/fixtures/pages.zip.meta")
build.update(legacy_artifacts_file: file)
build.update(legacy_artifacts_metadata: metafile)
@@ -223,8 +223,8 @@ describe Projects::UpdatePagesService do
.and_return(metadata)
end
- shared_examples 'pages size limit exceeded' do
- it 'limits the maximum size of gitlab pages' do
+ shared_examples "pages size limit exceeded" do
+ it "limits the maximum size of gitlab pages" do
subject.execute
expect(deploy_status.description)
@@ -233,53 +233,53 @@ describe Projects::UpdatePagesService do
end
end
- context 'when maximum pages size is set to zero' do
+ context "when maximum pages size is set to zero" do
before do
stub_application_setting(max_pages_size: 0)
end
- context 'when page size does not exceed internal maximum' do
+ context "when page size does not exceed internal maximum" do
before do
allow(metadata).to receive(:total_size).and_return(200.megabytes)
end
- it 'updates pages correctly' do
+ it "updates pages correctly" do
subject.execute
expect(deploy_status.description).not_to be_present
end
end
- context 'when pages size does exceed internal maximum' do
+ context "when pages size does exceed internal maximum" do
before do
allow(metadata).to receive(:total_size).and_return(2.terabytes)
end
- it_behaves_like 'pages size limit exceeded'
+ it_behaves_like "pages size limit exceeded"
end
end
- context 'when pages size is greater than max size setting' do
+ context "when pages size is greater than max size setting" do
before do
stub_application_setting(max_pages_size: 200)
allow(metadata).to receive(:total_size).and_return(201.megabytes)
end
- it_behaves_like 'pages size limit exceeded'
+ it_behaves_like "pages size limit exceeded"
end
- context 'when max size setting is greater than internal max size' do
+ context "when max size setting is greater than internal max size" do
before do
stub_application_setting(max_pages_size: 3.terabytes / 1.megabyte)
allow(metadata).to receive(:total_size).and_return(2.terabytes)
end
- it_behaves_like 'pages size limit exceeded'
+ it_behaves_like "pages size limit exceeded"
end
end
def deploy_status
- GenericCommitStatus.find_by(name: 'pages:deploy')
+ GenericCommitStatus.find_by(name: "pages:deploy")
end
def execute
diff --git a/spec/services/projects/update_remote_mirror_service_spec.rb b/spec/services/projects/update_remote_mirror_service_spec.rb
index c1e5f788146..860d5f6c79b 100644
--- a/spec/services/projects/update_remote_mirror_service_spec.rb
+++ b/spec/services/projects/update_remote_mirror_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::UpdateRemoteMirrorService do
let(:project) { create(:project, :repository) }
@@ -10,7 +10,7 @@ describe Projects::UpdateRemoteMirrorService do
describe "#execute" do
before do
- project.repository.add_branch(project.owner, 'existing-branch', 'master')
+ project.repository.add_branch(project.owner, "existing-branch", "master")
allow(remote_mirror).to receive(:update_repository).and_return(true)
end
@@ -39,7 +39,7 @@ describe Projects::UpdateRemoteMirrorService do
expect(result[:status]).to eq(:success)
end
- context 'when syncing all branches' do
+ context "when syncing all branches" do
it "push all the branches the first time" do
stub_fetch_remote(project, remote_name: remote_name, ssh_auth: remote_mirror)
@@ -49,7 +49,7 @@ describe Projects::UpdateRemoteMirrorService do
end
end
- context 'when only syncing protected branches' do
+ context "when only syncing protected branches" do
it "sync updated protected branches" do
stub_fetch_remote(project, remote_name: remote_name, ssh_auth: remote_mirror)
protected_branch = create_protected_branch(project)
@@ -63,7 +63,7 @@ describe Projects::UpdateRemoteMirrorService do
end
def create_protected_branch(project)
- branch_name = project.repository.branch_names.find { |n| n != 'existing-branch' }
+ branch_name = project.repository.branch_names.find { |n| n != "existing-branch" }
create(:protected_branch, project: project, name: branch_name)
end
end
@@ -72,7 +72,7 @@ describe Projects::UpdateRemoteMirrorService do
def stub_fetch_remote(project, remote_name:, ssh_auth:)
allow(project.repository)
.to receive(:fetch_remote)
- .with(remote_name, no_tags: true, ssh_auth: ssh_auth) { fetch_remote(project.repository, remote_name) }
+ .with(remote_name, no_tags: true, ssh_auth: ssh_auth) { fetch_remote(project.repository, remote_name) }
end
def fetch_remote(repository, remote_name)
@@ -85,6 +85,6 @@ describe Projects::UpdateRemoteMirrorService do
def local_branch_names(repository)
branch_names = repository.branches.map(&:name)
# we want the protected branch to be pushed first
- branch_names.unshift(branch_names.delete('master'))
+ branch_names.unshift(branch_names.delete("master"))
end
end
diff --git a/spec/services/projects/update_service_spec.rb b/spec/services/projects/update_service_spec.rb
index 90eaea9c872..8b98208ac34 100644
--- a/spec/services/projects/update_service_spec.rb
+++ b/spec/services/projects/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Projects::UpdateService do
include ProjectForksHelper
@@ -8,215 +8,214 @@ describe Projects::UpdateService do
create(:project, creator: user, namespace: user.namespace)
end
- describe '#execute' do
+ describe "#execute" do
let(:gitlab_shell) { Gitlab::Shell.new }
let(:admin) { create(:admin) }
- context 'when changing visibility level' do
- context 'when visibility_level is INTERNAL' do
- it 'updates the project to internal' do
+ context "when changing visibility level" do
+ context "when visibility_level is INTERNAL" do
+ it "updates the project to internal" do
expect(TodosDestroyer::ProjectPrivateWorker).not_to receive(:perform_in)
result = update_project(project, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL)
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project).to be_internal
end
end
- context 'when visibility_level is PUBLIC' do
- it 'updates the project to public' do
+ context "when visibility_level is PUBLIC" do
+ it "updates the project to public" do
expect(TodosDestroyer::ProjectPrivateWorker).not_to receive(:perform_in)
result = update_project(project, user, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project).to be_public
end
end
- context 'when visibility_level is PRIVATE' do
+ context "when visibility_level is PRIVATE" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it 'updates the project to private' do
+ it "updates the project to private" do
expect(TodosDestroyer::ProjectPrivateWorker).to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, project.id)
result = update_project(project, user, visibility_level: Gitlab::VisibilityLevel::PRIVATE)
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project).to be_private
end
end
- context 'when visibility levels are restricted to PUBLIC only' do
+ context "when visibility levels are restricted to PUBLIC only" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
end
- context 'when visibility_level is INTERNAL' do
- it 'updates the project to internal' do
+ context "when visibility_level is INTERNAL" do
+ it "updates the project to internal" do
result = update_project(project, user, visibility_level: Gitlab::VisibilityLevel::INTERNAL)
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project).to be_internal
end
end
- context 'when visibility_level is PUBLIC' do
- it 'does not update the project to public' do
+ context "when visibility_level is PUBLIC" do
+ it "does not update the project to public" do
result = update_project(project, user, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
- expect(result).to eq({ status: :error, message: 'New visibility level not allowed!' })
+ expect(result).to eq({status: :error, message: "New visibility level not allowed!"})
expect(project).to be_private
end
- context 'when updated by an admin' do
- it 'updates the project to public' do
+ context "when updated by an admin" do
+ it "updates the project to public" do
result = update_project(project, admin, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project).to be_public
end
end
end
end
- context 'when project visibility is higher than parent group' do
+ context "when project visibility is higher than parent group" do
let(:group) { create(:group, visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
before do
project.update(namespace: group, visibility_level: group.visibility_level)
end
- it 'does not update project visibility level' do
+ it "does not update project visibility level" do
result = update_project(project, admin, visibility_level: Gitlab::VisibilityLevel::PUBLIC)
- expect(result).to eq({ status: :error, message: 'Visibility level public is not allowed in a internal group.' })
+ expect(result).to eq({status: :error, message: "Visibility level public is not allowed in a internal group."})
expect(project.reload).to be_internal
end
end
end
- describe 'when updating project that has forks' do
+ describe "when updating project that has forks" do
let(:project) { create(:project, :internal) }
let(:forked_project) { fork_project(project) }
- it 'updates forks visibility level when parent set to more restrictive' do
- opts = { visibility_level: Gitlab::VisibilityLevel::PRIVATE }
+ it "updates forks visibility level when parent set to more restrictive" do
+ opts = {visibility_level: Gitlab::VisibilityLevel::PRIVATE}
expect(project).to be_internal
expect(forked_project).to be_internal
- expect(update_project(project, admin, opts)).to eq({ status: :success })
+ expect(update_project(project, admin, opts)).to eq({status: :success})
expect(project).to be_private
expect(forked_project.reload).to be_private
end
- it 'does not update forks visibility level when parent set to less restrictive' do
- opts = { visibility_level: Gitlab::VisibilityLevel::PUBLIC }
+ it "does not update forks visibility level when parent set to less restrictive" do
+ opts = {visibility_level: Gitlab::VisibilityLevel::PUBLIC}
expect(project).to be_internal
expect(forked_project).to be_internal
- expect(update_project(project, admin, opts)).to eq({ status: :success })
+ expect(update_project(project, admin, opts)).to eq({status: :success})
expect(project).to be_public
expect(forked_project.reload).to be_internal
end
end
- context 'when updating a default branch' do
+ context "when updating a default branch" do
let(:project) { create(:project, :repository) }
- it 'changes a default branch' do
- update_project(project, admin, default_branch: 'feature')
+ it "changes a default branch" do
+ update_project(project, admin, default_branch: "feature")
- expect(Project.find(project.id).default_branch).to eq 'feature'
+ expect(Project.find(project.id).default_branch).to eq "feature"
end
- it 'does not change a default branch' do
+ it "does not change a default branch" do
# The branch 'unexisted-branch' does not exist.
- update_project(project, admin, default_branch: 'unexisted-branch')
+ update_project(project, admin, default_branch: "unexisted-branch")
- expect(Project.find(project.id).default_branch).to eq 'master'
+ expect(Project.find(project.id).default_branch).to eq "master"
end
end
- context 'when we update project but not enabling a wiki' do
- it 'does not try to create an empty wiki' do
+ context "when we update project but not enabling a wiki" do
+ it "does not try to create an empty wiki" do
Gitlab::Shell.new.rm_directory(project.repository_storage, project.wiki.path)
- result = update_project(project, user, { name: 'test1' })
+ result = update_project(project, user, {name: "test1"})
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project.wiki_repository_exists?).to be false
end
- it 'handles empty project feature attributes' do
+ it "handles empty project feature attributes" do
project.project_feature.update(wiki_access_level: ProjectFeature::DISABLED)
- result = update_project(project, user, { name: 'test1' })
+ result = update_project(project, user, {name: "test1"})
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project.wiki_repository_exists?).to be false
end
end
- context 'when enabling a wiki' do
- it 'creates a wiki' do
+ context "when enabling a wiki" do
+ it "creates a wiki" do
project.project_feature.update(wiki_access_level: ProjectFeature::DISABLED)
Gitlab::Shell.new.rm_directory(project.repository_storage, project.wiki.path)
- result = update_project(project, user, project_feature_attributes: { wiki_access_level: ProjectFeature::ENABLED })
+ result = update_project(project, user, project_feature_attributes: {wiki_access_level: ProjectFeature::ENABLED})
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project.wiki_repository_exists?).to be true
expect(project.wiki_enabled?).to be true
end
- it 'logs an error and creates a metric when wiki can not be created' do
+ it "logs an error and creates a metric when wiki can not be created" do
project.project_feature.update(wiki_access_level: ProjectFeature::DISABLED)
expect_any_instance_of(ProjectWiki).to receive(:wiki).and_raise(ProjectWiki::CouldNotCreateWikiError)
expect_any_instance_of(described_class).to receive(:log_error).with("Could not create wiki for #{project.full_name}")
expect(Gitlab::Metrics).to receive(:counter)
- update_project(project, user, project_feature_attributes: { wiki_access_level: ProjectFeature::ENABLED })
+ update_project(project, user, project_feature_attributes: {wiki_access_level: ProjectFeature::ENABLED})
end
end
- context 'when changing feature visibility to private' do
- it 'updates the visibility correctly' do
+ context "when changing feature visibility to private" do
+ it "updates the visibility correctly" do
expect(TodosDestroyer::PrivateFeaturesWorker)
.to receive(:perform_in).with(Todo::WAIT_FOR_DELETE, project.id)
result = update_project(project, user, project_feature_attributes:
- { issues_access_level: ProjectFeature::PRIVATE }
- )
+ {issues_access_level: ProjectFeature::PRIVATE})
- expect(result).to eq({ status: :success })
+ expect(result).to eq({status: :success})
expect(project.project_feature.issues_access_level).to be(ProjectFeature::PRIVATE)
end
end
- context 'when updating a project that contains container images' do
+ context "when updating a project that contains container images" do
before do
stub_container_registry_config(enabled: true)
stub_container_registry_tags(repository: /image/, tags: %w[rc1])
create(:container_repository, project: project, name: :image)
end
- it 'does not allow to rename the project' do
- result = update_project(project, admin, path: 'renamed')
+ it "does not allow to rename the project" do
+ result = update_project(project, admin, path: "renamed")
expect(result).to include(status: :error)
expect(result[:message]).to match(/contains container registry tags/)
end
- it 'allows to update other settings' do
+ it "allows to update other settings" do
result = update_project(project, admin, public_builds: true)
expect(result[:status]).to eq :success
@@ -224,11 +223,11 @@ describe Projects::UpdateService do
end
end
- context 'when renaming a project' do
- let(:repository_storage) { 'default' }
+ context "when renaming a project" do
+ let(:repository_storage) { "default" }
let(:repository_storage_path) { Gitlab.config.repositories.storages[repository_storage].legacy_disk_path }
- context 'with legacy storage' do
+ context "with legacy storage" do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
before do
@@ -239,34 +238,34 @@ describe Projects::UpdateService do
gitlab_shell.remove_repository(repository_storage, "#{user.namespace.full_path}/existing")
end
- it 'does not allow renaming when new path matches existing repository on disk' do
- result = update_project(project, admin, path: 'existing')
+ it "does not allow renaming when new path matches existing repository on disk" do
+ result = update_project(project, admin, path: "existing")
expect(result).to include(status: :error)
- expect(result[:message]).to match('There is already a repository with that name on disk')
+ expect(result[:message]).to match("There is already a repository with that name on disk")
expect(project).not_to be_valid
expect(project.errors.messages).to have_key(:base)
- expect(project.errors.messages[:base]).to include('There is already a repository with that name on disk')
+ expect(project.errors.messages[:base]).to include("There is already a repository with that name on disk")
end
- it 'renames the project without upgrading it' do
- result = update_project(project, admin, path: 'new-path')
+ it "renames the project without upgrading it" do
+ result = update_project(project, admin, path: "new-path")
expect(result).not_to include(status: :error)
expect(project).to be_valid
expect(project.errors).to be_empty
- expect(project.disk_path).to include('new-path')
+ expect(project.disk_path).to include("new-path")
expect(project.reload.hashed_storage?(:repository)).to be_falsey
end
- context 'when hashed storage is enabled' do
+ context "when hashed storage is enabled" do
before do
stub_application_setting(hashed_storage_enabled: true)
stub_feature_flags(skip_hashed_storage_upgrade: false)
end
- it 'migrates project to a hashed storage instead of renaming the repo to another legacy name' do
- result = update_project(project, admin, path: 'new-path')
+ it "migrates project to a hashed storage instead of renaming the repo to another legacy name" do
+ result = update_project(project, admin, path: "new-path")
expect(result).not_to include(status: :error)
expect(project).to be_valid
@@ -274,64 +273,64 @@ describe Projects::UpdateService do
expect(project.reload.hashed_storage?(:repository)).to be_truthy
end
- context 'when skip_hashed_storage_upgrade feature flag is enabled' do
+ context "when skip_hashed_storage_upgrade feature flag is enabled" do
before do
stub_feature_flags(skip_hashed_storage_upgrade: true)
end
- it 'renames the project without upgrading it' do
- result = update_project(project, admin, path: 'new-path')
+ it "renames the project without upgrading it" do
+ result = update_project(project, admin, path: "new-path")
expect(result).not_to include(status: :error)
expect(project).to be_valid
expect(project.errors).to be_empty
- expect(project.disk_path).to include('new-path')
+ expect(project.disk_path).to include("new-path")
expect(project.reload.hashed_storage?(:repository)).to be_falsey
end
end
end
end
- context 'with hashed storage' do
+ context "with hashed storage" do
let(:project) { create(:project, :repository, creator: user, namespace: user.namespace) }
before do
stub_application_setting(hashed_storage_enabled: true)
end
- it 'does not check if new path matches existing repository on disk' do
+ it "does not check if new path matches existing repository on disk" do
expect(project).not_to receive(:repository_with_same_path_already_exists?)
- result = update_project(project, admin, path: 'existing')
+ result = update_project(project, admin, path: "existing")
expect(result).to include(status: :success)
end
end
end
- context 'when passing invalid parameters' do
- it 'returns an error result when record cannot be updated' do
- result = update_project(project, admin, { name: 'foo&bar' })
+ context "when passing invalid parameters" do
+ it "returns an error result when record cannot be updated" do
+ result = update_project(project, admin, {name: "foo&bar"})
expect(result).to eq({
status: :error,
- message: "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'."
+ message: "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'.",
})
end
end
- context 'when updating #pages_https_only', :https_pages_enabled do
+ context "when updating #pages_https_only", :https_pages_enabled do
subject(:call_service) do
update_project(project, admin, pages_https_only: false)
end
- it 'updates the attribute' do
+ it "updates the attribute" do
expect { call_service }
.to change { project.pages_https_only? }
.to(false)
end
- it 'calls Projects::UpdatePagesConfigurationService' do
+ it "calls Projects::UpdatePagesConfigurationService" do
expect(Projects::UpdatePagesConfigurationService)
.to receive(:new)
.with(project)
@@ -341,18 +340,18 @@ describe Projects::UpdateService do
end
end
- context 'when updating #pages_access_level' do
+ context "when updating #pages_access_level" do
subject(:call_service) do
- update_project(project, admin, project_feature_attributes: { pages_access_level: ProjectFeature::PRIVATE })
+ update_project(project, admin, project_feature_attributes: {pages_access_level: ProjectFeature::PRIVATE})
end
- it 'updates the attribute' do
+ it "updates the attribute" do
expect { call_service }
.to change { project.project_feature.pages_access_level }
.to(ProjectFeature::PRIVATE)
end
- it 'calls Projects::UpdatePagesConfigurationService' do
+ it "calls Projects::UpdatePagesConfigurationService" do
expect(Projects::UpdatePagesConfigurationService)
.to receive(:new)
.with(project)
@@ -363,10 +362,10 @@ describe Projects::UpdateService do
end
end
- describe '#run_auto_devops_pipeline?' do
+ describe "#run_auto_devops_pipeline?" do
subject { described_class.new(project, user).run_auto_devops_pipeline? }
- context 'when master contains a .gitlab-ci.yml file' do
+ context "when master contains a .gitlab-ci.yml file" do
before do
allow(project.repository).to receive(:gitlab_ci_yml).and_return("script: ['test']")
end
@@ -374,11 +373,11 @@ describe Projects::UpdateService do
it { is_expected.to eq(false) }
end
- context 'when auto devops is nil' do
+ context "when auto devops is nil" do
it { is_expected.to eq(false) }
end
- context 'when auto devops is explicitly enabled' do
+ context "when auto devops is explicitly enabled" do
before do
project.create_auto_devops!(enabled: true)
end
@@ -386,7 +385,7 @@ describe Projects::UpdateService do
it { is_expected.to eq(true) }
end
- context 'when auto devops is explicitly disabled' do
+ context "when auto devops is explicitly disabled" do
before do
project.create_auto_devops!(enabled: false)
end
@@ -394,13 +393,13 @@ describe Projects::UpdateService do
it { is_expected.to eq(false) }
end
- context 'when auto devops is set to instance setting' do
+ context "when auto devops is set to instance setting" do
before do
project.create_auto_devops!(enabled: nil)
- allow(project.auto_devops).to receive(:previous_changes).and_return('enabled' => true)
+ allow(project.auto_devops).to receive(:previous_changes).and_return("enabled" => true)
end
- context 'when auto devops is enabled system-wide' do
+ context "when auto devops is enabled system-wide" do
before do
stub_application_setting(auto_devops_enabled: true)
end
@@ -408,7 +407,7 @@ describe Projects::UpdateService do
it { is_expected.to eq(true) }
end
- context 'when auto devops is disabled system-wide' do
+ context "when auto devops is disabled system-wide" do
before do
stub_application_setting(auto_devops_enabled: false)
end
diff --git a/spec/services/prometheus/adapter_service_spec.rb b/spec/services/prometheus/adapter_service_spec.rb
index 505e2935e93..81fa2ea81ef 100644
--- a/spec/services/prometheus/adapter_service_spec.rb
+++ b/spec/services/prometheus/adapter_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Prometheus::AdapterService do
let(:project) { create(:project) }
subject { described_class.new(project) }
- describe '#prometheus_adapter' do
- let(:cluster) { create(:cluster, :provided_by_user, environment_scope: '*', projects: [project]) }
+ describe "#prometheus_adapter" do
+ let(:cluster) { create(:cluster, :provided_by_user, environment_scope: "*", projects: [project]) }
- context 'prometheus service can execute queries' do
+ context "prometheus service can execute queries" do
let(:prometheus_service) { double(:prometheus_service, can_query?: true) }
before do
- allow(project).to receive(:find_or_initialize_service).with('prometheus').and_return prometheus_service
+ allow(project).to receive(:find_or_initialize_service).with("prometheus").and_return prometheus_service
end
- it 'return prometheus service as prometheus adapter' do
+ it "return prometheus service as prometheus adapter" do
expect(subject.prometheus_adapter).to eq(prometheus_service)
end
end
@@ -22,24 +22,24 @@ describe Prometheus::AdapterService do
context "prometheus service can't execute queries" do
let(:prometheus_service) { double(:prometheus_service, can_query?: false) }
- context 'with cluster with prometheus not available' do
+ context "with cluster with prometheus not available" do
let!(:prometheus) { create(:clusters_applications_prometheus, :installable, cluster: cluster) }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.prometheus_adapter).to be_nil
end
end
- context 'with cluster with prometheus available' do
+ context "with cluster with prometheus available" do
let!(:prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
- it 'returns application handling all environments' do
+ it "returns application handling all environments" do
expect(subject.prometheus_adapter).to eq(prometheus)
end
end
- context 'with cluster without prometheus installed' do
- it 'returns nil' do
+ context "with cluster without prometheus installed" do
+ it "returns nil" do
expect(subject.prometheus_adapter).to be_nil
end
end
diff --git a/spec/services/protected_branches/create_service_spec.rb b/spec/services/protected_branches/create_service_spec.rb
index 79b744142c6..65be4cddc85 100644
--- a/spec/services/protected_branches/create_service_spec.rb
+++ b/spec/services/protected_branches/create_service_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranches::CreateService do
let(:project) { create(:project) }
let(:user) { project.owner }
let(:params) do
{
- name: 'master',
- merge_access_levels_attributes: [{ access_level: Gitlab::Access::MAINTAINER }],
- push_access_levels_attributes: [{ access_level: Gitlab::Access::MAINTAINER }]
+ name: "master",
+ merge_access_levels_attributes: [{access_level: Gitlab::Access::MAINTAINER}],
+ push_access_levels_attributes: [{access_level: Gitlab::Access::MAINTAINER}],
}
end
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user, params) }
- it 'creates a new protected branch' do
+ it "creates a new protected branch" do
expect { service.execute }.to change(ProtectedBranch, :count).by(1)
expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
expect(project.protected_branches.last.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
end
- context 'when user does not have permission' do
+ context "when user does not have permission" do
let(:user) { create(:user) }
before do
project.add_developer(user)
end
- it 'creates a new protected branch if we skip authorization step' do
+ it "creates a new protected branch if we skip authorization step" do
expect { service.execute(skip_authorization: true) }.to change(ProtectedBranch, :count).by(1)
end
- it 'raises Gitlab::Access:AccessDeniedError' do
+ it "raises Gitlab::Access:AccessDeniedError" do
expect { service.execute }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
- context 'when a policy restricts rule creation' do
+ context "when a policy restricts rule creation" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
end
it "prevents creation of the protected branch rule" do
- expect do
+ expect {
service.execute
- end.to raise_error(Gitlab::Access::AccessDeniedError)
+ }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
end
diff --git a/spec/services/protected_branches/destroy_service_spec.rb b/spec/services/protected_branches/destroy_service_spec.rb
index 4a391b6c25c..b820c122e4a 100644
--- a/spec/services/protected_branches/destroy_service_spec.rb
+++ b/spec/services/protected_branches/destroy_service_spec.rb
@@ -1,29 +1,29 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranches::DestroyService do
let(:protected_branch) { create(:protected_branch) }
let(:project) { protected_branch.project }
let(:user) { project.owner }
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user) }
- it 'destroys a protected branch' do
+ it "destroys a protected branch" do
service.execute(protected_branch)
expect(protected_branch).to be_destroyed
end
- context 'when a policy restricts rule deletion' do
+ context "when a policy restricts rule deletion" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
end
it "prevents deletion of the protected branch rule" do
- expect do
+ expect {
service.execute(protected_branch)
- end.to raise_error(Gitlab::Access::AccessDeniedError)
+ }.to raise_error(Gitlab::Access::AccessDeniedError)
end
end
end
diff --git a/spec/services/protected_branches/update_service_spec.rb b/spec/services/protected_branches/update_service_spec.rb
index 3f6f8e09565..98e226643c6 100644
--- a/spec/services/protected_branches/update_service_spec.rb
+++ b/spec/services/protected_branches/update_service_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedBranches::UpdateService do
let(:protected_branch) { create(:protected_branch) }
let(:project) { protected_branch.project }
let(:user) { project.owner }
- let(:params) { { name: 'new protected branch name' } }
+ let(:params) { {name: "new protected branch name"} }
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user, params) }
- it 'updates a protected branch' do
+ it "updates a protected branch" do
result = service.execute(protected_branch)
expect(result.reload.name).to eq(params[:name])
end
- context 'without admin_project permissions' do
+ context "without admin_project permissions" do
let(:user) { create(:user) }
it "raises error" do
@@ -23,7 +23,7 @@ describe ProtectedBranches::UpdateService do
end
end
- context 'when a policy restricts rule creation' do
+ context "when a policy restricts rule creation" do
before do
policy = instance_double(ProtectedBranchPolicy, can?: false)
expect(ProtectedBranchPolicy).to receive(:new).and_return(policy)
diff --git a/spec/services/protected_tags/create_service_spec.rb b/spec/services/protected_tags/create_service_spec.rb
index b16acf1d36c..b19f16e02e9 100644
--- a/spec/services/protected_tags/create_service_spec.rb
+++ b/spec/services/protected_tags/create_service_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedTags::CreateService do
let(:project) { create(:project) }
let(:user) { project.owner }
let(:params) do
{
- name: 'master',
- create_access_levels_attributes: [{ access_level: Gitlab::Access::MAINTAINER }]
+ name: "master",
+ create_access_levels_attributes: [{access_level: Gitlab::Access::MAINTAINER}],
}
end
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user, params) }
- it 'creates a new protected tag' do
+ it "creates a new protected tag" do
expect { service.execute }.to change(ProtectedTag, :count).by(1)
expect(project.protected_tags.last.create_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
end
diff --git a/spec/services/protected_tags/destroy_service_spec.rb b/spec/services/protected_tags/destroy_service_spec.rb
index e12f53a2221..3dd99451340 100644
--- a/spec/services/protected_tags/destroy_service_spec.rb
+++ b/spec/services/protected_tags/destroy_service_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedTags::DestroyService do
let(:protected_tag) { create(:protected_tag) }
let(:project) { protected_tag.project }
let(:user) { project.owner }
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user) }
- it 'destroy a protected tag' do
+ it "destroy a protected tag" do
service.execute(protected_tag)
expect(protected_tag).to be_destroyed
diff --git a/spec/services/protected_tags/update_service_spec.rb b/spec/services/protected_tags/update_service_spec.rb
index 2ece4e3b07b..6185f628879 100644
--- a/spec/services/protected_tags/update_service_spec.rb
+++ b/spec/services/protected_tags/update_service_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe ProtectedTags::UpdateService do
let(:protected_tag) { create(:protected_tag) }
let(:project) { protected_tag.project }
let(:user) { project.owner }
- let(:params) { { name: 'new protected tag name' } }
+ let(:params) { {name: "new protected tag name"} }
- describe '#execute' do
+ describe "#execute" do
subject(:service) { described_class.new(project, user, params) }
- it 'updates a protected tag' do
+ it "updates a protected tag" do
result = service.execute(protected_tag)
expect(result.reload.name).to eq(params[:name])
end
- context 'without admin_project permissions' do
+ context "without admin_project permissions" do
let(:user) { create(:user) }
it "raises error" do
diff --git a/spec/services/push_event_payload_service_spec.rb b/spec/services/push_event_payload_service_spec.rb
index 81956200bff..c071b43070f 100644
--- a/spec/services/push_event_payload_service_spec.rb
+++ b/spec/services/push_event_payload_service_spec.rb
@@ -1,216 +1,216 @@
-require 'spec_helper'
+require "spec_helper"
describe PushEventPayloadService do
let(:event) { create(:push_event) }
- describe '#execute' do
+ describe "#execute" do
let(:push_data) do
{
commits: [
{
- id: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
- message: 'This is a commit'
- }
+ id: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
+ message: "This is a commit",
+ },
],
- before: '0000000000000000000000000000000000000000',
- after: '1cf19a015df3523caf0a1f9d40c98a267d6a2fc2',
+ before: "0000000000000000000000000000000000000000",
+ after: "1cf19a015df3523caf0a1f9d40c98a267d6a2fc2",
total_commits_count: 1,
- ref: 'refs/heads/my-branch'
+ ref: "refs/heads/my-branch",
}
end
- it 'creates a new PushEventPayload row' do
+ it "creates a new PushEventPayload row" do
payload = described_class.new(event, push_data).execute
expect(payload.commit_count).to eq(1)
- expect(payload.action).to eq('created')
- expect(payload.ref_type).to eq('branch')
+ expect(payload.action).to eq("created")
+ expect(payload.ref_type).to eq("branch")
expect(payload.commit_from).to be_nil
expect(payload.commit_to).to eq(push_data[:after])
- expect(payload.ref).to eq('my-branch')
- expect(payload.commit_title).to eq('This is a commit')
+ expect(payload.ref).to eq("my-branch")
+ expect(payload.commit_title).to eq("This is a commit")
expect(payload.event_id).to eq(event.id)
end
- it 'sets the push_event_payload association of the used event' do
+ it "sets the push_event_payload association of the used event" do
payload = described_class.new(event, push_data).execute
expect(event.push_event_payload).to eq(payload)
end
end
- describe '#commit_title' do
- it 'returns nil if no commits were pushed' do
+ describe "#commit_title" do
+ it "returns nil if no commits were pushed" do
service = described_class.new(event, commits: [])
expect(service.commit_title).to be_nil
end
- it 'returns a String limited to 70 characters' do
- service = described_class.new(event, commits: [{ message: 'a' * 100 }])
+ it "returns a String limited to 70 characters" do
+ service = described_class.new(event, commits: [{message: "a" * 100}])
- expect(service.commit_title).to eq(('a' * 67) + '...')
+ expect(service.commit_title).to eq(("a" * 67) + "...")
end
- it 'does not truncate the commit message if it is shorter than 70 characters' do
- service = described_class.new(event, commits: [{ message: 'Hello' }])
+ it "does not truncate the commit message if it is shorter than 70 characters" do
+ service = described_class.new(event, commits: [{message: "Hello"}])
- expect(service.commit_title).to eq('Hello')
+ expect(service.commit_title).to eq("Hello")
end
- it 'includes the first line of a commit message if the message spans multiple lines' do
+ it "includes the first line of a commit message if the message spans multiple lines" do
service = described_class
- .new(event, commits: [{ message: "Hello\n\nworld" }])
+ .new(event, commits: [{message: "Hello\n\nworld"}])
- expect(service.commit_title).to eq('Hello')
+ expect(service.commit_title).to eq("Hello")
end
end
- describe '#commit_from_id' do
- it 'returns nil when creating a new ref' do
+ describe "#commit_from_id" do
+ it "returns nil when creating a new ref" do
service = described_class.new(event, before: Gitlab::Git::BLANK_SHA)
expect(service.commit_from_id).to be_nil
end
- it 'returns the ID of the first commit when pushing to an existing ref' do
- service = described_class.new(event, before: '123')
+ it "returns the ID of the first commit when pushing to an existing ref" do
+ service = described_class.new(event, before: "123")
- expect(service.commit_from_id).to eq('123')
+ expect(service.commit_from_id).to eq("123")
end
end
- describe '#commit_to_id' do
- it 'returns nil when removing an existing ref' do
+ describe "#commit_to_id" do
+ it "returns nil when removing an existing ref" do
service = described_class.new(event, after: Gitlab::Git::BLANK_SHA)
expect(service.commit_to_id).to be_nil
end
end
- describe '#commit_count' do
- it 'returns the number of commits' do
+ describe "#commit_count" do
+ it "returns the number of commits" do
service = described_class.new(event, total_commits_count: 1)
expect(service.commit_count).to eq(1)
end
- it 'raises when the push data does not contain the commits count' do
+ it "raises when the push data does not contain the commits count" do
service = described_class.new(event, {})
expect { service.commit_count }.to raise_error(KeyError)
end
end
- describe '#ref' do
- it 'returns the name of the ref' do
- service = described_class.new(event, ref: 'refs/heads/foo')
+ describe "#ref" do
+ it "returns the name of the ref" do
+ service = described_class.new(event, ref: "refs/heads/foo")
- expect(service.ref).to eq('refs/heads/foo')
+ expect(service.ref).to eq("refs/heads/foo")
end
- it 'raises when the push data does not contain the ref name' do
+ it "raises when the push data does not contain the ref name" do
service = described_class.new(event, {})
expect { service.ref }.to raise_error(KeyError)
end
end
- describe '#revision_before' do
- it 'returns the revision from before the push' do
- service = described_class.new(event, before: 'foo')
+ describe "#revision_before" do
+ it "returns the revision from before the push" do
+ service = described_class.new(event, before: "foo")
- expect(service.revision_before).to eq('foo')
+ expect(service.revision_before).to eq("foo")
end
- it 'raises when the push data does not contain the before revision' do
+ it "raises when the push data does not contain the before revision" do
service = described_class.new(event, {})
expect { service.revision_before }.to raise_error(KeyError)
end
end
- describe '#revision_after' do
- it 'returns the revision from after the push' do
- service = described_class.new(event, after: 'foo')
+ describe "#revision_after" do
+ it "returns the revision from after the push" do
+ service = described_class.new(event, after: "foo")
- expect(service.revision_after).to eq('foo')
+ expect(service.revision_after).to eq("foo")
end
- it 'raises when the push data does not contain the after revision' do
+ it "raises when the push data does not contain the after revision" do
service = described_class.new(event, {})
expect { service.revision_after }.to raise_error(KeyError)
end
end
- describe '#trimmed_ref' do
- it 'returns the ref name without its prefix' do
- service = described_class.new(event, ref: 'refs/heads/foo')
+ describe "#trimmed_ref" do
+ it "returns the ref name without its prefix" do
+ service = described_class.new(event, ref: "refs/heads/foo")
- expect(service.trimmed_ref).to eq('foo')
+ expect(service.trimmed_ref).to eq("foo")
end
end
- describe '#create?' do
- it 'returns true when creating a new ref' do
+ describe "#create?" do
+ it "returns true when creating a new ref" do
service = described_class.new(event, before: Gitlab::Git::BLANK_SHA)
expect(service.create?).to eq(true)
end
- it 'returns false when pushing to an existing ref' do
- service = described_class.new(event, before: 'foo')
+ it "returns false when pushing to an existing ref" do
+ service = described_class.new(event, before: "foo")
expect(service.create?).to eq(false)
end
end
- describe '#remove?' do
- it 'returns true when removing an existing ref' do
+ describe "#remove?" do
+ it "returns true when removing an existing ref" do
service = described_class.new(event, after: Gitlab::Git::BLANK_SHA)
expect(service.remove?).to eq(true)
end
- it 'returns false pushing to an existing ref' do
- service = described_class.new(event, after: 'foo')
+ it "returns false pushing to an existing ref" do
+ service = described_class.new(event, after: "foo")
expect(service.remove?).to eq(false)
end
end
- describe '#action' do
- it 'returns :created when creating a ref' do
+ describe "#action" do
+ it "returns :created when creating a ref" do
service = described_class.new(event, before: Gitlab::Git::BLANK_SHA)
expect(service.action).to eq(:created)
end
- it 'returns :removed when removing an existing ref' do
+ it "returns :removed when removing an existing ref" do
service = described_class.new(event,
- before: '123',
- after: Gitlab::Git::BLANK_SHA)
+ before: "123",
+ after: Gitlab::Git::BLANK_SHA)
expect(service.action).to eq(:removed)
end
- it 'returns :pushed when pushing to an existing ref' do
- service = described_class.new(event, before: '123', after: '456')
+ it "returns :pushed when pushing to an existing ref" do
+ service = described_class.new(event, before: "123", after: "456")
expect(service.action).to eq(:pushed)
end
end
- describe '#ref_type' do
- it 'returns :tag for a tag' do
- service = described_class.new(event, ref: 'refs/tags/1.2')
+ describe "#ref_type" do
+ it "returns :tag for a tag" do
+ service = described_class.new(event, ref: "refs/tags/1.2")
expect(service.ref_type).to eq(:tag)
end
- it 'returns :branch for a branch' do
- service = described_class.new(event, ref: 'refs/heads/master')
+ it "returns :branch for a branch" do
+ service = described_class.new(event, ref: "refs/heads/master")
expect(service.ref_type).to eq(:branch)
end
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 938764f40b0..2cfa17d0e94 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe QuickActions::InterpretService do
let(:project) { create(:project, :public) }
let(:developer) { create(:user) }
let(:developer2) { create(:user) }
let(:issue) { create(:issue, project: project) }
- let(:milestone) { create(:milestone, project: project, title: '9.10') }
+ let(:milestone) { create(:milestone, project: project, title: "9.10") }
let(:commit) { create(:commit, project: project) }
- let(:inprogress) { create(:label, project: project, title: 'In Progress') }
- let(:bug) { create(:label, project: project, title: 'Bug') }
+ let(:inprogress) { create(:label, project: project, title: "In Progress") }
+ let(:bug) { create(:label, project: project, title: "Bug") }
let(:note) { build(:note, commit_id: merge_request.diff_head_sha) }
let(:service) { described_class.new(project, developer) }
@@ -18,36 +18,36 @@ describe QuickActions::InterpretService do
project.add_developer(developer)
end
- describe '#execute' do
+ describe "#execute" do
let(:merge_request) { create(:merge_request, source_project: project) }
- shared_examples 'reopen command' do
+ shared_examples "reopen command" do
it 'returns state_event: "reopen" if content contains /reopen' do
issuable.close!
_, updates = service.execute(content, issuable)
- expect(updates).to eq(state_event: 'reopen')
+ expect(updates).to eq(state_event: "reopen")
end
end
- shared_examples 'close command' do
+ shared_examples "close command" do
it 'returns state_event: "close" if content contains /close' do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(state_event: 'close')
+ expect(updates).to eq(state_event: "close")
end
end
- shared_examples 'title command' do
+ shared_examples "title command" do
it 'populates title: "A brand new title" if content contains /title A brand new title' do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(title: 'A brand new title')
+ expect(updates).to eq(title: "A brand new title")
end
end
- shared_examples 'milestone command' do
- it 'fetches milestone and populates milestone_id if content contains /milestone' do
+ shared_examples "milestone command" do
+ it "fetches milestone and populates milestone_id if content contains /milestone" do
milestone # populate the milestone
_, updates = service.execute(content, issuable)
@@ -55,8 +55,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'remove_milestone command' do
- it 'populates milestone_id: nil if content contains /remove_milestone' do
+ shared_examples "remove_milestone command" do
+ it "populates milestone_id: nil if content contains /remove_milestone" do
issuable.update!(milestone_id: milestone.id)
_, updates = service.execute(content, issuable)
@@ -64,8 +64,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'label command' do
- it 'fetches label ids and populates add_label_ids if content contains /label' do
+ shared_examples "label command" do
+ it "fetches label ids and populates add_label_ids if content contains /label" do
bug # populate the label
inprogress # populate the label
_, updates = service.execute(content, issuable)
@@ -74,8 +74,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'multiple label command' do
- it 'fetches label ids and populates add_label_ids if content contains multiple /label' do
+ shared_examples "multiple label command" do
+ it "fetches label ids and populates add_label_ids if content contains multiple /label" do
bug # populate the label
inprogress # populate the label
_, updates = service.execute(content, issuable)
@@ -84,8 +84,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'multiple label with same argument' do
- it 'prevents duplicate label ids and populates add_label_ids if content contains multiple /label' do
+ shared_examples "multiple label with same argument" do
+ it "prevents duplicate label ids and populates add_label_ids if content contains multiple /label" do
inprogress # populate the label
_, updates = service.execute(content, issuable)
@@ -93,8 +93,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'unlabel command' do
- it 'fetches label ids and populates remove_label_ids if content contains /unlabel' do
+ shared_examples "unlabel command" do
+ it "fetches label ids and populates remove_label_ids if content contains /unlabel" do
issuable.update!(label_ids: [inprogress.id]) # populate the label
_, updates = service.execute(content, issuable)
@@ -102,8 +102,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'multiple unlabel command' do
- it 'fetches label ids and populates remove_label_ids if content contains mutiple /unlabel' do
+ shared_examples "multiple unlabel command" do
+ it "fetches label ids and populates remove_label_ids if content contains mutiple /unlabel" do
issuable.update!(label_ids: [inprogress.id, bug.id]) # populate the label
_, updates = service.execute(content, issuable)
@@ -111,8 +111,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'unlabel command with no argument' do
- it 'populates label_ids: [] if content contains /unlabel with no arguments' do
+ shared_examples "unlabel command with no argument" do
+ it "populates label_ids: [] if content contains /unlabel with no arguments" do
issuable.update!(label_ids: [inprogress.id]) # populate the label
_, updates = service.execute(content, issuable)
@@ -120,8 +120,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'relabel command' do
- it 'populates label_ids: [] if content contains /relabel' do
+ shared_examples "relabel command" do
+ it "populates label_ids: [] if content contains /relabel" do
issuable.update!(label_ids: [bug.id]) # populate the label
inprogress # populate the label
_, updates = service.execute(content, issuable)
@@ -130,50 +130,50 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'todo command' do
+ shared_examples "todo command" do
it 'populates todo_event: "add" if content contains /todo' do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(todo_event: 'add')
+ expect(updates).to eq(todo_event: "add")
end
end
- shared_examples 'done command' do
+ shared_examples "done command" do
it 'populates todo_event: "done" if content contains /done' do
TodoService.new.mark_todo(issuable, developer)
_, updates = service.execute(content, issuable)
- expect(updates).to eq(todo_event: 'done')
+ expect(updates).to eq(todo_event: "done")
end
end
- shared_examples 'subscribe command' do
+ shared_examples "subscribe command" do
it 'populates subscription_event: "subscribe" if content contains /subscribe' do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(subscription_event: 'subscribe')
+ expect(updates).to eq(subscription_event: "subscribe")
end
end
- shared_examples 'unsubscribe command' do
+ shared_examples "unsubscribe command" do
it 'populates subscription_event: "unsubscribe" if content contains /unsubscribe' do
issuable.subscribe(developer, project)
_, updates = service.execute(content, issuable)
- expect(updates).to eq(subscription_event: 'unsubscribe')
+ expect(updates).to eq(subscription_event: "unsubscribe")
end
end
- shared_examples 'due command' do
- it 'populates due_date: Date.new(2016, 8, 28) if content contains /due 2016-08-28' do
+ shared_examples "due command" do
+ it "populates due_date: Date.new(2016, 8, 28) if content contains /due 2016-08-28" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(due_date: defined?(expected_date) ? expected_date : Date.new(2016, 8, 28))
end
end
- shared_examples 'remove_due_date command' do
- it 'populates due_date: nil if content contains /remove_due_date' do
+ shared_examples "remove_due_date command" do
+ it "populates due_date: nil if content contains /remove_due_date" do
issuable.update!(due_date: Date.today)
_, updates = service.execute(content, issuable)
@@ -181,149 +181,149 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'wip command' do
+ shared_examples "wip command" do
it 'returns wip_event: "wip" if content contains /wip' do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(wip_event: 'wip')
+ expect(updates).to eq(wip_event: "wip")
end
end
- shared_examples 'unwip command' do
+ shared_examples "unwip command" do
it 'returns wip_event: "unwip" if content contains /wip' do
issuable.update!(title: issuable.wip_title)
_, updates = service.execute(content, issuable)
- expect(updates).to eq(wip_event: 'unwip')
+ expect(updates).to eq(wip_event: "unwip")
end
end
- shared_examples 'estimate command' do
- it 'populates time_estimate: 3600 if content contains /estimate 1h' do
+ shared_examples "estimate command" do
+ it "populates time_estimate: 3600 if content contains /estimate 1h" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(time_estimate: 3600)
end
end
- shared_examples 'spend command' do
- it 'populates spend_time: 3600 if content contains /spend 1h' do
+ shared_examples "spend command" do
+ it "populates spend_time: 3600 if content contains /spend 1h" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(spend_time: {
- duration: 3600,
- user_id: developer.id,
- spent_at: DateTime.now.to_date
- })
+ duration: 3600,
+ user_id: developer.id,
+ spent_at: DateTime.now.to_date,
+ })
end
end
- shared_examples 'spend command with negative time' do
- it 'populates spend_time: -1800 if content contains /spend -30m' do
+ shared_examples "spend command with negative time" do
+ it "populates spend_time: -1800 if content contains /spend -30m" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(spend_time: {
- duration: -1800,
- user_id: developer.id,
- spent_at: DateTime.now.to_date
- })
+ duration: -1800,
+ user_id: developer.id,
+ spent_at: DateTime.now.to_date,
+ })
end
end
- shared_examples 'spend command with valid date' do
- it 'populates spend time: 1800 with date in date type format' do
+ shared_examples "spend command with valid date" do
+ it "populates spend time: 1800 with date in date type format" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(spend_time: {
- duration: 1800,
- user_id: developer.id,
- spent_at: Date.parse(date)
- })
+ duration: 1800,
+ user_id: developer.id,
+ spent_at: Date.parse(date),
+ })
end
end
- shared_examples 'spend command with invalid date' do
- it 'will not create any note and timelog' do
+ shared_examples "spend command with invalid date" do
+ it "will not create any note and timelog" do
_, updates = service.execute(content, issuable)
expect(updates).to eq({})
end
end
- shared_examples 'spend command with future date' do
- it 'will not create any note and timelog' do
+ shared_examples "spend command with future date" do
+ it "will not create any note and timelog" do
_, updates = service.execute(content, issuable)
expect(updates).to eq({})
end
end
- shared_examples 'remove_estimate command' do
- it 'populates time_estimate: 0 if content contains /remove_estimate' do
+ shared_examples "remove_estimate command" do
+ it "populates time_estimate: 0 if content contains /remove_estimate" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(time_estimate: 0)
end
end
- shared_examples 'remove_time_spent command' do
- it 'populates spend_time: :reset if content contains /remove_time_spent' do
+ shared_examples "remove_time_spent command" do
+ it "populates spend_time: :reset if content contains /remove_time_spent" do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(spend_time: { duration: :reset, user_id: developer.id })
+ expect(updates).to eq(spend_time: {duration: :reset, user_id: developer.id})
end
end
- shared_examples 'lock command' do
+ shared_examples "lock command" do
let(:issue) { create(:issue, project: project, discussion_locked: false) }
let(:merge_request) { create(:merge_request, source_project: project, discussion_locked: false) }
- it 'returns discussion_locked: true if content contains /lock' do
+ it "returns discussion_locked: true if content contains /lock" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(discussion_locked: true)
end
end
- shared_examples 'unlock command' do
+ shared_examples "unlock command" do
let(:issue) { create(:issue, project: project, discussion_locked: true) }
let(:merge_request) { create(:merge_request, source_project: project, discussion_locked: true) }
- it 'returns discussion_locked: true if content contains /unlock' do
+ it "returns discussion_locked: true if content contains /unlock" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(discussion_locked: false)
end
end
- shared_examples 'empty command' do
- it 'populates {} if content contains an unsupported command' do
+ shared_examples "empty command" do
+ it "populates {} if content contains an unsupported command" do
_, updates = service.execute(content, issuable)
expect(updates).to be_empty
end
end
- shared_examples 'merge command' do
+ shared_examples "merge command" do
let(:project) { create(:project, :repository) }
- it 'runs merge command if content contains /merge' do
+ it "runs merge command if content contains /merge" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(merge: merge_request.diff_head_sha)
end
end
- shared_examples 'award command' do
- it 'toggle award 100 emoji if content contains /award :100:' do
+ shared_examples "award command" do
+ it "toggle award 100 emoji if content contains /award :100:" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(emoji_award: "100")
end
end
- shared_examples 'duplicate command' do
- it 'fetches issue and populates canonical_issue_id if content contains /duplicate issue_reference' do
+ shared_examples "duplicate command" do
+ it "fetches issue and populates canonical_issue_id if content contains /duplicate issue_reference" do
issue_duplicate # populate the issue
_, updates = service.execute(content, issuable)
@@ -331,8 +331,8 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'copy_metadata command' do
- it 'fetches issue or merge request and copies labels and milestone if content contains /copy_metadata reference' do
+ shared_examples "copy_metadata command" do
+ it "fetches issue or merge request and copies labels and milestone if content contains /copy_metadata reference" do
source_issuable # populate the issue
todo_label # populate this label
inreview_label # populate this label
@@ -348,15 +348,15 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'confidential command' do
- it 'marks issue as confidential if content contains /confidential' do
+ shared_examples "confidential command" do
+ it "marks issue as confidential if content contains /confidential" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(confidential: true)
end
end
- shared_examples 'shrug command' do
+ shared_examples "shrug command" do
it 'appends ¯\_(ツ)_/¯ to the comment' do
new_content, _ = service.execute(content, issuable)
@@ -364,192 +364,192 @@ describe QuickActions::InterpretService do
end
end
- shared_examples 'tableflip command' do
- it 'appends (╯°□°)╯︵ ┻━┻ to the comment' do
+ shared_examples "tableflip command" do
+ it "appends (╯°□°)╯︵ ┻━┻ to the comment" do
new_content, _ = service.execute(content, issuable)
expect(new_content).to end_with(described_class::TABLEFLIP)
end
end
- shared_examples 'tag command' do
- it 'tags a commit' do
+ shared_examples "tag command" do
+ it "tags a commit" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(tag_name: tag_name, tag_message: tag_message)
end
end
- shared_examples 'assign command' do
- it 'assigns to a single user' do
+ shared_examples "assign command" do
+ it "assigns to a single user" do
_, updates = service.execute(content, issuable)
expect(updates).to eq(assignee_ids: [developer.id])
end
end
- it_behaves_like 'reopen command' do
- let(:content) { '/reopen' }
+ it_behaves_like "reopen command" do
+ let(:content) { "/reopen" }
let(:issuable) { issue }
end
- it_behaves_like 'reopen command' do
- let(:content) { '/reopen' }
+ it_behaves_like "reopen command" do
+ let(:content) { "/reopen" }
let(:issuable) { merge_request }
end
- it_behaves_like 'close command' do
- let(:content) { '/close' }
+ it_behaves_like "close command" do
+ let(:content) { "/close" }
let(:issuable) { issue }
end
- it_behaves_like 'close command' do
- let(:content) { '/close' }
+ it_behaves_like "close command" do
+ let(:content) { "/close" }
let(:issuable) { merge_request }
end
- context 'merge command' do
- let(:service) { described_class.new(project, developer, { merge_request_diff_head_sha: merge_request.diff_head_sha }) }
+ context "merge command" do
+ let(:service) { described_class.new(project, developer, {merge_request_diff_head_sha: merge_request.diff_head_sha}) }
- it_behaves_like 'merge command' do
- let(:content) { '/merge' }
+ it_behaves_like "merge command" do
+ let(:content) { "/merge" }
let(:issuable) { merge_request }
end
- context 'can not be merged when logged user does not have permissions' do
+ context "can not be merged when logged user does not have permissions" do
let(:service) { described_class.new(project, create(:user)) }
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/merge" }
let(:issuable) { merge_request }
end
end
- context 'can not be merged when sha does not match' do
- let(:service) { described_class.new(project, developer, { merge_request_diff_head_sha: 'othersha' }) }
+ context "can not be merged when sha does not match" do
+ let(:service) { described_class.new(project, developer, {merge_request_diff_head_sha: "othersha"}) }
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/merge" }
let(:issuable) { merge_request }
end
end
- context 'when sha is missing' do
+ context "when sha is missing" do
let(:project) { create(:project, :repository) }
let(:service) { described_class.new(project, developer, {}) }
- it 'precheck passes and returns merge command' do
- _, updates = service.execute('/merge', merge_request)
+ it "precheck passes and returns merge command" do
+ _, updates = service.execute("/merge", merge_request)
expect(updates).to eq(merge: nil)
end
end
- context 'issue can not be merged' do
- it_behaves_like 'empty command' do
+ context "issue can not be merged" do
+ it_behaves_like "empty command" do
let(:content) { "/merge" }
let(:issuable) { issue }
end
end
- context 'non persisted merge request cant be merged' do
- it_behaves_like 'empty command' do
+ context "non persisted merge request cant be merged" do
+ it_behaves_like "empty command" do
let(:content) { "/merge" }
let(:issuable) { build(:merge_request) }
end
end
- context 'not persisted merge request can not be merged' do
- it_behaves_like 'empty command' do
+ context "not persisted merge request can not be merged" do
+ it_behaves_like "empty command" do
let(:content) { "/merge" }
let(:issuable) { build(:merge_request, source_project: project) }
end
end
end
- it_behaves_like 'title command' do
- let(:content) { '/title A brand new title' }
+ it_behaves_like "title command" do
+ let(:content) { "/title A brand new title" }
let(:issuable) { issue }
end
- it_behaves_like 'title command' do
- let(:content) { '/title A brand new title' }
+ it_behaves_like "title command" do
+ let(:content) { "/title A brand new title" }
let(:issuable) { merge_request }
end
- it_behaves_like 'empty command' do
- let(:content) { '/title' }
+ it_behaves_like "empty command" do
+ let(:content) { "/title" }
let(:issuable) { issue }
end
- context 'assign command with one user' do
- it_behaves_like 'assign command' do
+ context "assign command with one user" do
+ it_behaves_like "assign command" do
let(:content) { "/assign @#{developer.username}" }
let(:issuable) { issue }
end
- it_behaves_like 'assign command' do
+ it_behaves_like "assign command" do
let(:content) { "/assign @#{developer.username}" }
let(:issuable) { merge_request }
end
end
# CE does not have multiple assignees
- context 'assign command with multiple assignees' do
+ context "assign command with multiple assignees" do
before do
project.add_developer(developer2)
end
- it_behaves_like 'assign command' do
+ it_behaves_like "assign command" do
let(:content) { "/assign @#{developer.username} @#{developer2.username}" }
let(:issuable) { issue }
end
- it_behaves_like 'assign command' do
+ it_behaves_like "assign command" do
let(:content) { "/assign @#{developer.username} @#{developer2.username}" }
let(:issuable) { merge_request }
end
end
- context 'assign command with me alias' do
- it_behaves_like 'assign command' do
- let(:content) { '/assign me' }
+ context "assign command with me alias" do
+ it_behaves_like "assign command" do
+ let(:content) { "/assign me" }
let(:issuable) { issue }
end
- it_behaves_like 'assign command' do
- let(:content) { '/assign me' }
+ it_behaves_like "assign command" do
+ let(:content) { "/assign me" }
let(:issuable) { merge_request }
end
end
- context 'assign command with me alias and whitespace' do
- it_behaves_like 'assign command' do
- let(:content) { '/assign me ' }
+ context "assign command with me alias and whitespace" do
+ it_behaves_like "assign command" do
+ let(:content) { "/assign me " }
let(:issuable) { issue }
end
- it_behaves_like 'assign command' do
- let(:content) { '/assign me ' }
+ it_behaves_like "assign command" do
+ let(:content) { "/assign me " }
let(:issuable) { merge_request }
end
end
- it_behaves_like 'empty command' do
- let(:content) { '/assign @abcd1234' }
+ it_behaves_like "empty command" do
+ let(:content) { "/assign @abcd1234" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/assign' }
+ it_behaves_like "empty command" do
+ let(:content) { "/assign" }
let(:issuable) { issue }
end
- context 'unassign command' do
- let(:content) { '/unassign' }
+ context "unassign command" do
+ let(:content) { "/unassign" }
- context 'Issue' do
- it 'populates assignee_ids: [] if content contains /unassign' do
+ context "Issue" do
+ it "populates assignee_ids: [] if content contains /unassign" do
issue.update(assignee_ids: [developer.id])
_, updates = service.execute(content, issue)
@@ -557,8 +557,8 @@ describe QuickActions::InterpretService do
end
end
- context 'Merge Request' do
- it 'populates assignee_ids: [] if content contains /unassign' do
+ context "Merge Request" do
+ it "populates assignee_ids: [] if content contains /unassign" do
merge_request.update(assignee_ids: [developer.id])
_, updates = service.execute(content, merge_request)
@@ -567,313 +567,313 @@ describe QuickActions::InterpretService do
end
end
- it_behaves_like 'milestone command' do
+ it_behaves_like "milestone command" do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { issue }
end
- it_behaves_like 'milestone command' do
+ it_behaves_like "milestone command" do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { merge_request }
end
- context 'only group milestones available' do
+ context "only group milestones available" do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
- let(:milestone) { create(:milestone, group: group, title: '10.0') }
+ let(:milestone) { create(:milestone, group: group, title: "10.0") }
- it_behaves_like 'milestone command' do
+ it_behaves_like "milestone command" do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { issue }
end
- it_behaves_like 'milestone command' do
+ it_behaves_like "milestone command" do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { merge_request }
end
end
- it_behaves_like 'remove_milestone command' do
- let(:content) { '/remove_milestone' }
+ it_behaves_like "remove_milestone command" do
+ let(:content) { "/remove_milestone" }
let(:issuable) { issue }
end
- it_behaves_like 'remove_milestone command' do
- let(:content) { '/remove_milestone' }
+ it_behaves_like "remove_milestone command" do
+ let(:content) { "/remove_milestone" }
let(:issuable) { merge_request }
end
- it_behaves_like 'label command' do
+ it_behaves_like "label command" do
let(:content) { %(/label ~"#{inprogress.title}" ~#{bug.title} ~unknown) }
let(:issuable) { issue }
end
- it_behaves_like 'label command' do
+ it_behaves_like "label command" do
let(:content) { %(/label ~"#{inprogress.title}" ~#{bug.title} ~unknown) }
let(:issuable) { merge_request }
end
- it_behaves_like 'multiple label command' do
+ it_behaves_like "multiple label command" do
let(:content) { %(/label ~"#{inprogress.title}" \n/label ~#{bug.title}) }
let(:issuable) { issue }
end
- it_behaves_like 'multiple label with same argument' do
+ it_behaves_like "multiple label with same argument" do
let(:content) { %(/label ~"#{inprogress.title}" \n/label ~#{inprogress.title}) }
let(:issuable) { issue }
end
- it_behaves_like 'unlabel command' do
+ it_behaves_like "unlabel command" do
let(:content) { %(/unlabel ~"#{inprogress.title}") }
let(:issuable) { issue }
end
- it_behaves_like 'unlabel command' do
+ it_behaves_like "unlabel command" do
let(:content) { %(/unlabel ~"#{inprogress.title}") }
let(:issuable) { merge_request }
end
- it_behaves_like 'multiple unlabel command' do
+ it_behaves_like "multiple unlabel command" do
let(:content) { %(/unlabel ~"#{inprogress.title}" \n/unlabel ~#{bug.title}) }
let(:issuable) { issue }
end
- it_behaves_like 'unlabel command with no argument' do
+ it_behaves_like "unlabel command with no argument" do
let(:content) { %(/unlabel) }
let(:issuable) { issue }
end
- it_behaves_like 'unlabel command with no argument' do
+ it_behaves_like "unlabel command with no argument" do
let(:content) { %(/unlabel) }
let(:issuable) { merge_request }
end
- it_behaves_like 'relabel command' do
+ it_behaves_like "relabel command" do
let(:content) { %(/relabel ~"#{inprogress.title}") }
let(:issuable) { issue }
end
- it_behaves_like 'relabel command' do
+ it_behaves_like "relabel command" do
let(:content) { %(/relabel ~"#{inprogress.title}") }
let(:issuable) { merge_request }
end
- it_behaves_like 'done command' do
- let(:content) { '/done' }
+ it_behaves_like "done command" do
+ let(:content) { "/done" }
let(:issuable) { issue }
end
- it_behaves_like 'done command' do
- let(:content) { '/done' }
+ it_behaves_like "done command" do
+ let(:content) { "/done" }
let(:issuable) { merge_request }
end
- it_behaves_like 'subscribe command' do
- let(:content) { '/subscribe' }
+ it_behaves_like "subscribe command" do
+ let(:content) { "/subscribe" }
let(:issuable) { issue }
end
- it_behaves_like 'subscribe command' do
- let(:content) { '/subscribe' }
+ it_behaves_like "subscribe command" do
+ let(:content) { "/subscribe" }
let(:issuable) { merge_request }
end
- it_behaves_like 'unsubscribe command' do
- let(:content) { '/unsubscribe' }
+ it_behaves_like "unsubscribe command" do
+ let(:content) { "/unsubscribe" }
let(:issuable) { issue }
end
- it_behaves_like 'unsubscribe command' do
- let(:content) { '/unsubscribe' }
+ it_behaves_like "unsubscribe command" do
+ let(:content) { "/unsubscribe" }
let(:issuable) { merge_request }
end
- it_behaves_like 'due command' do
- let(:content) { '/due 2016-08-28' }
+ it_behaves_like "due command" do
+ let(:content) { "/due 2016-08-28" }
let(:issuable) { issue }
end
- it_behaves_like 'due command' do
- let(:content) { '/due tomorrow' }
+ it_behaves_like "due command" do
+ let(:content) { "/due tomorrow" }
let(:issuable) { issue }
let(:expected_date) { Date.tomorrow }
end
- it_behaves_like 'due command' do
- let(:content) { '/due 5 days from now' }
+ it_behaves_like "due command" do
+ let(:content) { "/due 5 days from now" }
let(:issuable) { issue }
let(:expected_date) { 5.days.from_now.to_date }
end
- it_behaves_like 'due command' do
- let(:content) { '/due in 2 days' }
+ it_behaves_like "due command" do
+ let(:content) { "/due in 2 days" }
let(:issuable) { issue }
let(:expected_date) { 2.days.from_now.to_date }
end
- it_behaves_like 'empty command' do
- let(:content) { '/due foo bar' }
+ it_behaves_like "empty command" do
+ let(:content) { "/due foo bar" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/due 2016-08-28' }
+ it_behaves_like "empty command" do
+ let(:content) { "/due 2016-08-28" }
let(:issuable) { merge_request }
end
- it_behaves_like 'remove_due_date command' do
- let(:content) { '/remove_due_date' }
+ it_behaves_like "remove_due_date command" do
+ let(:content) { "/remove_due_date" }
let(:issuable) { issue }
end
- it_behaves_like 'wip command' do
- let(:content) { '/wip' }
+ it_behaves_like "wip command" do
+ let(:content) { "/wip" }
let(:issuable) { merge_request }
end
- it_behaves_like 'unwip command' do
- let(:content) { '/wip' }
+ it_behaves_like "unwip command" do
+ let(:content) { "/wip" }
let(:issuable) { merge_request }
end
- it_behaves_like 'empty command' do
- let(:content) { '/remove_due_date' }
+ it_behaves_like "empty command" do
+ let(:content) { "/remove_due_date" }
let(:issuable) { merge_request }
end
- it_behaves_like 'estimate command' do
- let(:content) { '/estimate 1h' }
+ it_behaves_like "estimate command" do
+ let(:content) { "/estimate 1h" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/estimate' }
+ it_behaves_like "empty command" do
+ let(:content) { "/estimate" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/estimate abc' }
+ it_behaves_like "empty command" do
+ let(:content) { "/estimate abc" }
let(:issuable) { issue }
end
- it_behaves_like 'spend command' do
- let(:content) { '/spend 1h' }
+ it_behaves_like "spend command" do
+ let(:content) { "/spend 1h" }
let(:issuable) { issue }
end
- it_behaves_like 'spend command with negative time' do
- let(:content) { '/spend -30m' }
+ it_behaves_like "spend command with negative time" do
+ let(:content) { "/spend -30m" }
let(:issuable) { issue }
end
- it_behaves_like 'spend command with valid date' do
- let(:date) { '2016-02-02' }
+ it_behaves_like "spend command with valid date" do
+ let(:date) { "2016-02-02" }
let(:content) { "/spend 30m #{date}" }
let(:issuable) { issue }
end
- it_behaves_like 'spend command with invalid date' do
- let(:content) { '/spend 30m 17-99-99' }
+ it_behaves_like "spend command with invalid date" do
+ let(:content) { "/spend 30m 17-99-99" }
let(:issuable) { issue }
end
- it_behaves_like 'spend command with future date' do
- let(:content) { '/spend 30m 6017-10-10' }
+ it_behaves_like "spend command with future date" do
+ let(:content) { "/spend 30m 6017-10-10" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/spend' }
+ it_behaves_like "empty command" do
+ let(:content) { "/spend" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/spend abc' }
+ it_behaves_like "empty command" do
+ let(:content) { "/spend abc" }
let(:issuable) { issue }
end
- it_behaves_like 'remove_estimate command' do
- let(:content) { '/remove_estimate' }
+ it_behaves_like "remove_estimate command" do
+ let(:content) { "/remove_estimate" }
let(:issuable) { issue }
end
- it_behaves_like 'remove_time_spent command' do
- let(:content) { '/remove_time_spent' }
+ it_behaves_like "remove_time_spent command" do
+ let(:content) { "/remove_time_spent" }
let(:issuable) { issue }
end
- it_behaves_like 'confidential command' do
- let(:content) { '/confidential' }
+ it_behaves_like "confidential command" do
+ let(:content) { "/confidential" }
let(:issuable) { issue }
end
- it_behaves_like 'lock command' do
- let(:content) { '/lock' }
+ it_behaves_like "lock command" do
+ let(:content) { "/lock" }
let(:issuable) { issue }
end
- it_behaves_like 'lock command' do
- let(:content) { '/lock' }
+ it_behaves_like "lock command" do
+ let(:content) { "/lock" }
let(:issuable) { merge_request }
end
- it_behaves_like 'unlock command' do
- let(:content) { '/unlock' }
+ it_behaves_like "unlock command" do
+ let(:content) { "/unlock" }
let(:issuable) { issue }
end
- it_behaves_like 'unlock command' do
- let(:content) { '/unlock' }
+ it_behaves_like "unlock command" do
+ let(:content) { "/unlock" }
let(:issuable) { merge_request }
end
- context '/todo' do
- let(:content) { '/todo' }
+ context "/todo" do
+ let(:content) { "/todo" }
- context 'if issuable is an Issue' do
- it_behaves_like 'todo command' do
+ context "if issuable is an Issue" do
+ it_behaves_like "todo command" do
let(:issuable) { issue }
end
end
- context 'if issuable is a MergeRequest' do
- it_behaves_like 'todo command' do
+ context "if issuable is a MergeRequest" do
+ it_behaves_like "todo command" do
let(:issuable) { merge_request }
end
end
- context 'if issuable is a Commit' do
- it_behaves_like 'empty command' do
+ context "if issuable is a Commit" do
+ it_behaves_like "empty command" do
let(:issuable) { commit }
end
end
end
- context '/copy_metadata command' do
- let(:todo_label) { create(:label, project: project, title: 'To Do') }
- let(:inreview_label) { create(:label, project: project, title: 'In Review') }
+ context "/copy_metadata command" do
+ let(:todo_label) { create(:label, project: project, title: "To Do") }
+ let(:inreview_label) { create(:label, project: project, title: "In Review") }
- it_behaves_like 'empty command' do
- let(:content) { '/copy_metadata' }
+ it_behaves_like "empty command" do
+ let(:content) { "/copy_metadata" }
let(:issuable) { issue }
end
- it_behaves_like 'copy_metadata command' do
+ it_behaves_like "copy_metadata command" do
let(:source_issuable) { create(:labeled_issue, project: project, labels: [inreview_label, todo_label]) }
let(:content) { "/copy_metadata #{source_issuable.to_reference}" }
let(:issuable) { build(:issue, project: project) }
end
- it_behaves_like 'copy_metadata command' do
+ it_behaves_like "copy_metadata command" do
let(:source_issuable) { create(:labeled_issue, project: project, labels: [inreview_label, todo_label]) }
let(:content) { "/copy_metadata #{source_issuable.to_reference}" }
let(:issuable) { issue }
end
- context 'when the parent issuable has a milestone' do
- it_behaves_like 'copy_metadata command' do
+ context "when the parent issuable has a milestone" do
+ it_behaves_like "copy_metadata command" do
let(:source_issuable) { create(:labeled_issue, project: project, labels: [todo_label, inreview_label], milestone: milestone) }
let(:content) { "/copy_metadata #{source_issuable.to_reference(project)}" }
@@ -881,10 +881,10 @@ describe QuickActions::InterpretService do
end
end
- context 'when more than one issuable is passed' do
- it_behaves_like 'copy_metadata command' do
+ context "when more than one issuable is passed" do
+ it_behaves_like "copy_metadata command" do
let(:source_issuable) { create(:labeled_issue, project: project, labels: [inreview_label, todo_label]) }
- let(:other_label) { create(:label, project: project, title: 'Other') }
+ let(:other_label) { create(:label, project: project, title: "Other") }
let(:other_source_issuable) { create(:labeled_issue, project: project, labels: [other_label]) }
let(:content) { "/copy_metadata #{source_issuable.to_reference} #{other_source_issuable.to_reference}" }
@@ -892,20 +892,20 @@ describe QuickActions::InterpretService do
end
end
- context 'cross project references' do
- it_behaves_like 'empty command' do
+ context "cross project references" do
+ it_behaves_like "empty command" do
let(:other_project) { create(:project, :public) }
let(:source_issuable) { create(:labeled_issue, project: other_project, labels: [todo_label, inreview_label]) }
let(:content) { "/copy_metadata #{source_issuable.to_reference(project)}" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/copy_metadata imaginary#1234" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:other_project) { create(:project, :private) }
let(:source_issuable) { create(:issue, project: other_project) }
@@ -915,32 +915,32 @@ describe QuickActions::InterpretService do
end
end
- context '/duplicate command' do
- it_behaves_like 'duplicate command' do
+ context "/duplicate command" do
+ it_behaves_like "duplicate command" do
let(:issue_duplicate) { create(:issue, project: project) }
let(:content) { "/duplicate #{issue_duplicate.to_reference}" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/duplicate' }
+ it_behaves_like "empty command" do
+ let(:content) { "/duplicate" }
let(:issuable) { issue }
end
- context 'cross project references' do
- it_behaves_like 'duplicate command' do
+ context "cross project references" do
+ it_behaves_like "duplicate command" do
let(:other_project) { create(:project, :public) }
let(:issue_duplicate) { create(:issue, project: other_project) }
let(:content) { "/duplicate #{issue_duplicate.to_reference(project)}" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/duplicate imaginary#1234" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:other_project) { create(:project, :private) }
let(:issue_duplicate) { create(:issue, project: other_project) }
@@ -950,181 +950,181 @@ describe QuickActions::InterpretService do
end
end
- context 'when current_user cannot :admin_issue' do
+ context "when current_user cannot :admin_issue" do
let(:visitor) { create(:user) }
let(:issue) { create(:issue, project: project, author: visitor) }
let(:service) { described_class.new(project, visitor) }
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/assign @#{developer.username}" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/unassign' }
+ it_behaves_like "empty command" do
+ let(:content) { "/unassign" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/remove_milestone' }
+ it_behaves_like "empty command" do
+ let(:content) { "/remove_milestone" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { %(/label ~"#{inprogress.title}" ~#{bug.title} ~unknown) }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { %(/unlabel ~"#{inprogress.title}") }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { %(/relabel ~"#{inprogress.title}") }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/due tomorrow' }
+ it_behaves_like "empty command" do
+ let(:content) { "/due tomorrow" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/remove_due_date' }
+ it_behaves_like "empty command" do
+ let(:content) { "/remove_due_date" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/confidential' }
+ it_behaves_like "empty command" do
+ let(:content) { "/confidential" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
+ it_behaves_like "empty command" do
let(:content) { '/duplicate #{issue.to_reference}' }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/lock' }
+ it_behaves_like "empty command" do
+ let(:content) { "/lock" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/unlock' }
+ it_behaves_like "empty command" do
+ let(:content) { "/unlock" }
let(:issuable) { issue }
end
end
- context '/award command' do
- it_behaves_like 'award command' do
- let(:content) { '/award :100:' }
+ context "/award command" do
+ it_behaves_like "award command" do
+ let(:content) { "/award :100:" }
let(:issuable) { issue }
end
- it_behaves_like 'award command' do
- let(:content) { '/award :100:' }
+ it_behaves_like "award command" do
+ let(:content) { "/award :100:" }
let(:issuable) { merge_request }
end
- context 'ignores command with no argument' do
- it_behaves_like 'empty command' do
- let(:content) { '/award' }
+ context "ignores command with no argument" do
+ it_behaves_like "empty command" do
+ let(:content) { "/award" }
let(:issuable) { issue }
end
end
- context 'ignores non-existing / invalid emojis' do
- it_behaves_like 'empty command' do
- let(:content) { '/award noop' }
+ context "ignores non-existing / invalid emojis" do
+ it_behaves_like "empty command" do
+ let(:content) { "/award noop" }
let(:issuable) { issue }
end
- it_behaves_like 'empty command' do
- let(:content) { '/award :lorem_ipsum:' }
+ it_behaves_like "empty command" do
+ let(:content) { "/award :lorem_ipsum:" }
let(:issuable) { issue }
end
end
- context 'if issuable is a Commit' do
- let(:content) { '/award :100:' }
+ context "if issuable is a Commit" do
+ let(:content) { "/award :100:" }
let(:issuable) { commit }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
end
- context '/shrug command' do
- it_behaves_like 'shrug command' do
- let(:content) { '/shrug people are people' }
+ context "/shrug command" do
+ it_behaves_like "shrug command" do
+ let(:content) { "/shrug people are people" }
let(:issuable) { issue }
end
- it_behaves_like 'shrug command' do
- let(:content) { '/shrug' }
+ it_behaves_like "shrug command" do
+ let(:content) { "/shrug" }
let(:issuable) { issue }
end
end
- context '/tableflip command' do
- it_behaves_like 'tableflip command' do
- let(:content) { '/tableflip curse your sudden but enviable betrayal' }
+ context "/tableflip command" do
+ it_behaves_like "tableflip command" do
+ let(:content) { "/tableflip curse your sudden but enviable betrayal" }
let(:issuable) { issue }
end
- it_behaves_like 'tableflip command' do
- let(:content) { '/tableflip' }
+ it_behaves_like "tableflip command" do
+ let(:content) { "/tableflip" }
let(:issuable) { issue }
end
end
- context '/target_branch command' do
+ context "/target_branch command" do
let(:non_empty_project) { create(:project, :repository) }
let(:another_merge_request) { create(:merge_request, author: developer, source_project: non_empty_project) }
let(:service) { described_class.new(non_empty_project, developer)}
- it 'updates target_branch if /target_branch command is executed' do
- _, updates = service.execute('/target_branch merge-test', merge_request)
+ it "updates target_branch if /target_branch command is executed" do
+ _, updates = service.execute("/target_branch merge-test", merge_request)
- expect(updates).to eq(target_branch: 'merge-test')
+ expect(updates).to eq(target_branch: "merge-test")
end
- it 'handles blanks around param' do
- _, updates = service.execute('/target_branch merge-test ', merge_request)
+ it "handles blanks around param" do
+ _, updates = service.execute("/target_branch merge-test ", merge_request)
- expect(updates).to eq(target_branch: 'merge-test')
+ expect(updates).to eq(target_branch: "merge-test")
end
- context 'ignores command with no argument' do
- it_behaves_like 'empty command' do
- let(:content) { '/target_branch' }
+ context "ignores command with no argument" do
+ it_behaves_like "empty command" do
+ let(:content) { "/target_branch" }
let(:issuable) { another_merge_request }
end
end
- context 'ignores non-existing target branch' do
- it_behaves_like 'empty command' do
- let(:content) { '/target_branch totally_non_existing_branch' }
+ context "ignores non-existing target branch" do
+ it_behaves_like "empty command" do
+ let(:content) { "/target_branch totally_non_existing_branch" }
let(:issuable) { another_merge_request }
end
end
end
- context '/board_move command' do
- let(:todo) { create(:label, project: project, title: 'To Do') }
- let(:inreview) { create(:label, project: project, title: 'In Review') }
- let(:content) { %{/board_move ~"#{inreview.title}"} }
+ context "/board_move command" do
+ let(:todo) { create(:label, project: project, title: "To Do") }
+ let(:inreview) { create(:label, project: project, title: "In Review") }
+ let(:content) { %(/board_move ~"#{inreview.title}") }
let!(:board) { create(:board, project: project) }
let!(:todo_list) { create(:list, board: board, label: todo) }
let!(:inreview_list) { create(:list, board: board, label: inreview) }
let!(:inprogress_list) { create(:list, board: board, label: inprogress) }
- it 'populates remove_label_ids for all current board columns' do
+ it "populates remove_label_ids for all current board columns" do
issue.update!(label_ids: [todo.id, inprogress.id])
_, updates = service.execute(content, issue)
@@ -1132,13 +1132,13 @@ describe QuickActions::InterpretService do
expect(updates[:remove_label_ids]).to match_array([todo.id, inprogress.id])
end
- it 'populates add_label_ids with the id of the given label' do
+ it "populates add_label_ids with the id of the given label" do
_, updates = service.execute(content, issue)
expect(updates[:add_label_ids]).to eq([inreview.id])
end
- it 'does not include the given label id in remove_label_ids' do
+ it "does not include the given label id in remove_label_ids" do
issue.update!(label_ids: [todo.id, inreview.id])
_, updates = service.execute(content, issue)
@@ -1146,7 +1146,7 @@ describe QuickActions::InterpretService do
expect(updates[:remove_label_ids]).to match_array([todo.id])
end
- it 'does not remove label ids that are not lists on the board' do
+ it "does not remove label ids that are not lists on the board" do
issue.update!(label_ids: [todo.id, bug.id])
_, updates = service.execute(content, issue)
@@ -1154,67 +1154,67 @@ describe QuickActions::InterpretService do
expect(updates[:remove_label_ids]).to match_array([todo.id])
end
- context 'if the project has multiple boards' do
+ context "if the project has multiple boards" do
let(:issuable) { issue }
before do
create(:board, project: project)
end
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
- context 'if the given label does not exist' do
+ context "if the given label does not exist" do
let(:issuable) { issue }
let(:content) { '/board_move ~"Fake Label"' }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
- context 'if multiple labels are given' do
+ context "if multiple labels are given" do
let(:issuable) { issue }
- let(:content) { %{/board_move ~"#{inreview.title}" ~"#{todo.title}"} }
- it_behaves_like 'empty command'
+ let(:content) { %(/board_move ~"#{inreview.title}" ~"#{todo.title}") }
+ it_behaves_like "empty command"
end
- context 'if the given label is not a list on the board' do
+ context "if the given label is not a list on the board" do
let(:issuable) { issue }
- let(:content) { %{/board_move ~"#{bug.title}"} }
- it_behaves_like 'empty command'
+ let(:content) { %(/board_move ~"#{bug.title}") }
+ it_behaves_like "empty command"
end
- context 'if issuable is not an Issue' do
+ context "if issuable is not an Issue" do
let(:issuable) { merge_request }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
end
- context '/tag command' do
+ context "/tag command" do
let(:issuable) { commit }
- context 'ignores command with no argument' do
- it_behaves_like 'empty command' do
- let(:content) { '/tag' }
+ context "ignores command with no argument" do
+ it_behaves_like "empty command" do
+ let(:content) { "/tag" }
end
end
- context 'tags a commit with a tag name' do
- it_behaves_like 'tag command' do
- let(:tag_name) { 'v1.2.3' }
+ context "tags a commit with a tag name" do
+ it_behaves_like "tag command" do
+ let(:tag_name) { "v1.2.3" }
let(:tag_message) { nil }
let(:content) { "/tag #{tag_name}" }
end
end
- context 'tags a commit with a tag name and message' do
- it_behaves_like 'tag command' do
- let(:tag_name) { 'v1.2.3' }
- let(:tag_message) { 'Stable release' }
+ context "tags a commit with a tag name and message" do
+ it_behaves_like "tag command" do
+ let(:tag_name) { "v1.2.3" }
+ let(:tag_message) { "Stable release" }
let(:content) { "/tag #{tag_name} #{tag_message}" }
end
end
end
- it 'limits to commands passed ' do
+ it "limits to commands passed " do
content = "/shrug\n/close"
text, commands = service.execute(content, issue, only: [:shrug])
@@ -1223,144 +1223,144 @@ describe QuickActions::InterpretService do
expect(text).to eq("#{described_class::SHRUG}\n/close")
end
- context '/create_merge_request command' do
- let(:branch_name) { '1-feature' }
+ context "/create_merge_request command" do
+ let(:branch_name) { "1-feature" }
let(:content) { "/create_merge_request #{branch_name}" }
let(:issuable) { issue }
- context 'if issuable is not an Issue' do
+ context "if issuable is not an Issue" do
let(:issuable) { merge_request }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
context "when logged user cannot create_merge_requests in the project" do
let(:project) { create(:project, :archived) }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
- context 'when logged user cannot push code to the project' do
+ context "when logged user cannot push code to the project" do
let(:project) { create(:project, :private) }
let(:service) { described_class.new(project, create(:user)) }
- it_behaves_like 'empty command'
+ it_behaves_like "empty command"
end
- it 'populates create_merge_request with branch_name and issue iid' do
+ it "populates create_merge_request with branch_name and issue iid" do
_, updates = service.execute(content, issuable)
- expect(updates).to eq(create_merge_request: { branch_name: branch_name, issue_iid: issuable.iid })
+ expect(updates).to eq(create_merge_request: {branch_name: branch_name, issue_iid: issuable.iid})
end
end
end
- describe '#explain' do
+ describe "#explain" do
let(:service) { described_class.new(project, developer) }
let(:merge_request) { create(:merge_request, source_project: project) }
- describe 'close command' do
- let(:content) { '/close' }
+ describe "close command" do
+ let(:content) { "/close" }
- it 'includes issuable name' do
+ it "includes issuable name" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Closes this issue.'])
+ expect(explanations).to eq(["Closes this issue."])
end
end
- describe 'reopen command' do
- let(:content) { '/reopen' }
+ describe "reopen command" do
+ let(:content) { "/reopen" }
let(:merge_request) { create(:merge_request, :closed, source_project: project) }
- it 'includes issuable name' do
+ it "includes issuable name" do
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Reopens this merge request.'])
+ expect(explanations).to eq(["Reopens this merge request."])
end
end
- describe 'title command' do
- let(:content) { '/title This is new title' }
+ describe "title command" do
+ let(:content) { "/title This is new title" }
- it 'includes new title' do
+ it "includes new title" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(['Changes the title to "This is new title".'])
end
end
- describe 'assign command' do
+ describe "assign command" do
let(:content) { "/assign @#{developer.username} do it!" }
- it 'includes only the user reference' do
+ it "includes only the user reference" do
_, explanations = service.explain(content, merge_request)
expect(explanations).to eq(["Assigns @#{developer.username}."])
end
end
- describe 'unassign command' do
- let(:content) { '/unassign' }
+ describe "unassign command" do
+ let(:content) { "/unassign" }
let(:issue) { create(:issue, project: project, assignees: [developer]) }
- it 'includes current assignee reference' do
+ it "includes current assignee reference" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Removes assignee @#{developer.username}."])
end
end
- describe 'milestone command' do
- let(:content) { '/milestone %wrong-milestone' }
- let!(:milestone) { create(:milestone, project: project, title: '9.10') }
+ describe "milestone command" do
+ let(:content) { "/milestone %wrong-milestone" }
+ let!(:milestone) { create(:milestone, project: project, title: "9.10") }
- it 'is empty when milestone reference is wrong' do
+ it "is empty when milestone reference is wrong" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq([])
end
end
- describe 'remove milestone command' do
- let(:content) { '/remove_milestone' }
+ describe "remove milestone command" do
+ let(:content) { "/remove_milestone" }
let(:merge_request) { create(:merge_request, source_project: project, milestone: milestone) }
- it 'includes current milestone name' do
+ it "includes current milestone name" do
_, explanations = service.explain(content, merge_request)
expect(explanations).to eq(['Removes %"9.10" milestone.'])
end
end
- describe 'label command' do
- let(:content) { '/label ~missing' }
+ describe "label command" do
+ let(:content) { "/label ~missing" }
let!(:label) { create(:label, project: project) }
- it 'is empty when there are no correct labels' do
+ it "is empty when there are no correct labels" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq([])
end
end
- describe 'unlabel command' do
- let(:content) { '/unlabel' }
+ describe "unlabel command" do
+ let(:content) { "/unlabel" }
- it 'says all labels if no parameter provided' do
+ it "says all labels if no parameter provided" do
merge_request.update!(label_ids: [bug.id])
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Removes all labels.'])
+ expect(explanations).to eq(["Removes all labels."])
end
end
- describe 'relabel command' do
- let(:content) { '/relabel Bug' }
- let!(:bug) { create(:label, project: project, title: 'Bug') }
- let(:feature) { create(:label, project: project, title: 'Feature') }
+ describe "relabel command" do
+ let(:content) { "/relabel Bug" }
+ let!(:bug) { create(:label, project: project, title: "Bug") }
+ let(:feature) { create(:label, project: project, title: "Feature") }
- it 'includes label name' do
+ it "includes label name" do
issue.update!(label_ids: [feature.id])
_, explanations = service.explain(content, issue)
@@ -1368,125 +1368,125 @@ describe QuickActions::InterpretService do
end
end
- describe 'subscribe command' do
- let(:content) { '/subscribe' }
+ describe "subscribe command" do
+ let(:content) { "/subscribe" }
- it 'includes issuable name' do
+ it "includes issuable name" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Subscribes to this issue.'])
+ expect(explanations).to eq(["Subscribes to this issue."])
end
end
- describe 'unsubscribe command' do
- let(:content) { '/unsubscribe' }
+ describe "unsubscribe command" do
+ let(:content) { "/unsubscribe" }
- it 'includes issuable name' do
+ it "includes issuable name" do
merge_request.subscribe(developer, project)
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Unsubscribes from this merge request.'])
+ expect(explanations).to eq(["Unsubscribes from this merge request."])
end
end
- describe 'due command' do
- let(:content) { '/due April 1st 2016' }
+ describe "due command" do
+ let(:content) { "/due April 1st 2016" }
- it 'includes the date' do
+ it "includes the date" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Sets the due date to Apr 1, 2016.'])
+ expect(explanations).to eq(["Sets the due date to Apr 1, 2016."])
end
end
- describe 'wip command' do
- let(:content) { '/wip' }
+ describe "wip command" do
+ let(:content) { "/wip" }
- it 'includes the new status' do
+ it "includes the new status" do
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Marks this merge request as Work In Progress.'])
+ expect(explanations).to eq(["Marks this merge request as Work In Progress."])
end
end
- describe 'award command' do
- let(:content) { '/award :confetti_ball: ' }
+ describe "award command" do
+ let(:content) { "/award :confetti_ball: " }
- it 'includes the emoji' do
+ it "includes the emoji" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Toggles :confetti_ball: emoji award.'])
+ expect(explanations).to eq(["Toggles :confetti_ball: emoji award."])
end
end
- describe 'estimate command' do
- let(:content) { '/estimate 79d' }
+ describe "estimate command" do
+ let(:content) { "/estimate 79d" }
- it 'includes the formatted duration' do
+ it "includes the formatted duration" do
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Sets time estimate to 3mo 3w 4d.'])
+ expect(explanations).to eq(["Sets time estimate to 3mo 3w 4d."])
end
end
- describe 'spend command' do
- let(:content) { '/spend -120m' }
+ describe "spend command" do
+ let(:content) { "/spend -120m" }
- it 'includes the formatted duration and proper verb' do
+ it "includes the formatted duration and proper verb" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Subtracts 2h spent time.'])
+ expect(explanations).to eq(["Subtracts 2h spent time."])
end
end
- describe 'target branch command' do
- let(:content) { '/target_branch my-feature ' }
+ describe "target branch command" do
+ let(:content) { "/target_branch my-feature " }
- it 'includes the branch name' do
+ it "includes the branch name" do
_, explanations = service.explain(content, merge_request)
- expect(explanations).to eq(['Sets target branch to my-feature.'])
+ expect(explanations).to eq(["Sets target branch to my-feature."])
end
end
- describe 'board move command' do
- let(:content) { '/board_move ~bug' }
- let!(:bug) { create(:label, project: project, title: 'bug') }
+ describe "board move command" do
+ let(:content) { "/board_move ~bug" }
+ let!(:bug) { create(:label, project: project, title: "bug") }
let!(:board) { create(:board, project: project) }
- it 'includes the label name' do
+ it "includes the label name" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Moves issue to ~#{bug.id} column in the board."])
end
end
- describe 'move issue to another project command' do
- let(:content) { '/move test/project' }
+ describe "move issue to another project command" do
+ let(:content) { "/move test/project" }
- it 'includes the project name' do
+ it "includes the project name" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Moves this issue to test/project."])
end
end
- describe 'tag a commit' do
- describe 'with a tag name' do
- context 'without a message' do
- let(:content) { '/tag v1.2.3' }
+ describe "tag a commit" do
+ describe "with a tag name" do
+ context "without a message" do
+ let(:content) { "/tag v1.2.3" }
- it 'includes the tag name only' do
+ it "includes the tag name only" do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to v1.2.3."])
end
end
- context 'with an empty message' do
- let(:content) { '/tag v1.2.3 ' }
+ context "with an empty message" do
+ let(:content) { "/tag v1.2.3 " }
- it 'includes the tag name only' do
+ it "includes the tag name only" do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to v1.2.3."])
@@ -1494,10 +1494,10 @@ describe QuickActions::InterpretService do
end
end
- describe 'with a tag name and message' do
- let(:content) { '/tag v1.2.3 Stable release' }
+ describe "with a tag name and message" do
+ let(:content) { "/tag v1.2.3 Stable release" }
- it 'includes the tag name and message' do
+ it "includes the tag name and message" do
_, explanations = service.explain(content, commit)
expect(explanations).to eq(["Tags this commit to v1.2.3 with \"Stable release\"."])
@@ -1505,21 +1505,21 @@ describe QuickActions::InterpretService do
end
end
- describe 'create a merge request' do
- context 'with no branch name' do
- let(:content) { '/create_merge_request' }
+ describe "create a merge request" do
+ context "with no branch name" do
+ let(:content) { "/create_merge_request" }
- it 'uses the default branch name' do
+ it "uses the default branch name" do
_, explanations = service.explain(content, issue)
- expect(explanations).to eq(['Creates a branch and a merge request to resolve this issue'])
+ expect(explanations).to eq(["Creates a branch and a merge request to resolve this issue"])
end
end
- context 'with a branch name' do
- let(:content) { '/create_merge_request foo' }
+ context "with a branch name" do
+ let(:content) { "/create_merge_request foo" }
- it 'uses the given branch name' do
+ it "uses the given branch name" do
_, explanations = service.explain(content, issue)
expect(explanations).to eq(["Creates branch 'foo' and a merge request to resolve this issue"])
diff --git a/spec/services/quick_actions/target_service_spec.rb b/spec/services/quick_actions/target_service_spec.rb
index 0aeb29cbeec..c221edee351 100644
--- a/spec/services/quick_actions/target_service_spec.rb
+++ b/spec/services/quick_actions/target_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe QuickActions::TargetService do
let(:project) { create(:project) }
@@ -11,25 +11,25 @@ describe QuickActions::TargetService do
project.add_maintainer(user)
end
- describe '#execute' do
- shared_examples 'no target' do |type_id:|
- it 'returns nil' do
+ describe "#execute" do
+ shared_examples "no target" do |type_id:|
+ it "returns nil" do
target = service.execute(type, type_id)
expect(target).to be_nil
end
end
- shared_examples 'find target' do
- it 'returns the target' do
+ shared_examples "find target" do
+ it "returns the target" do
found_target = service.execute(type, target_id)
expect(found_target).to eq(target)
end
end
- shared_examples 'build target' do |type_id:|
- it 'builds a new target' do
+ shared_examples "build target" do |type_id:|
+ it "builds a new target" do
target = service.execute(type, type_id)
expect(target.project).to eq(project)
@@ -37,47 +37,47 @@ describe QuickActions::TargetService do
end
end
- context 'for issue' do
+ context "for issue" do
let(:target) { create(:issue, project: project) }
let(:target_id) { target.iid }
- let(:type) { 'Issue' }
+ let(:type) { "Issue" }
- it_behaves_like 'find target'
- it_behaves_like 'build target', type_id: nil
- it_behaves_like 'build target', type_id: -1
+ it_behaves_like "find target"
+ it_behaves_like "build target", type_id: nil
+ it_behaves_like "build target", type_id: -1
end
- context 'for merge request' do
+ context "for merge request" do
let(:target) { create(:merge_request, source_project: project) }
let(:target_id) { target.iid }
- let(:type) { 'MergeRequest' }
+ let(:type) { "MergeRequest" }
- it_behaves_like 'find target'
- it_behaves_like 'build target', type_id: nil
- it_behaves_like 'build target', type_id: -1
+ it_behaves_like "find target"
+ it_behaves_like "build target", type_id: nil
+ it_behaves_like "build target", type_id: -1
end
- context 'for commit' do
+ context "for commit" do
let(:project) { create(:project, :repository) }
let(:target) { project.commit.parent }
let(:target_id) { target.sha }
- let(:type) { 'Commit' }
+ let(:type) { "Commit" }
- it_behaves_like 'find target'
- it_behaves_like 'no target', type_id: 'invalid_sha'
+ it_behaves_like "find target"
+ it_behaves_like "no target", type_id: "invalid_sha"
- context 'with nil target_id' do
+ context "with nil target_id" do
let(:target) { project.commit }
let(:target_id) { nil }
- it_behaves_like 'find target'
+ it_behaves_like "find target"
end
end
- context 'for unknown type' do
- let(:type) { 'unknown' }
+ context "for unknown type" do
+ let(:type) { "unknown" }
- it_behaves_like 'no target', type_id: :unused
+ it_behaves_like "no target", type_id: :unused
end
end
end
diff --git a/spec/services/releases/create_service_spec.rb b/spec/services/releases/create_service_spec.rb
index 612e9f152e7..0fe84b7db4f 100644
--- a/spec/services/releases/create_service_spec.rb
+++ b/spec/services/releases/create_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Releases::CreateService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:tag_sha) { project.repository.find_tag(tag_name).dereferenced_target.sha }
- let(:name) { 'Bionic Beaver' }
- let(:description) { 'Awesome release!' }
- let(:params) { { tag: tag_name, name: name, description: description, ref: ref } }
+ let(:name) { "Bionic Beaver" }
+ let(:description) { "Awesome release!" }
+ let(:params) { {tag: tag_name, name: name, description: description, ref: ref} }
let(:ref) { nil }
let(:service) { described_class.new(project, user, params) }
@@ -15,9 +15,9 @@ describe Releases::CreateService do
project.add_maintainer(user)
end
- describe '#execute' do
- shared_examples 'a successful release creation' do
- it 'creates a new release' do
+ describe "#execute" do
+ shared_examples "a successful release creation" do
+ it "creates a new release" do
result = service.execute
expect(result[:status]).to eq(:success)
expect(result[:tag]).not_to be_nil
@@ -29,25 +29,25 @@ describe Releases::CreateService do
end
end
- it_behaves_like 'a successful release creation'
+ it_behaves_like "a successful release creation"
- context 'when the tag does not exist' do
- let(:tag_name) { 'non-exist-tag' }
+ context "when the tag does not exist" do
+ let(:tag_name) { "non-exist-tag" }
- it 'raises an error' do
+ it "raises an error" do
result = service.execute
expect(result[:status]).to eq(:error)
end
end
- context 'when ref is provided' do
- let(:ref) { 'master' }
- let(:tag_name) { 'foobar' }
+ context "when ref is provided" do
+ let(:ref) { "master" }
+ let(:tag_name) { "foobar" }
- it_behaves_like 'a successful release creation'
+ it_behaves_like "a successful release creation"
- it 'creates a tag if the tag does not exist' do
+ it "creates a tag if the tag does not exist" do
expect(project.repository.ref_exists?("refs/tags/#{tag_name}")).to be_falsey
result = service.execute
@@ -57,12 +57,12 @@ describe Releases::CreateService do
end
end
- context 'there already exists a release on a tag' do
+ context "there already exists a release on a tag" do
let!(:release) do
create(:release, project: project, tag: tag_name, description: description)
end
- it 'raises an error and does not update the release' do
+ it "raises an error and does not update the release" do
result = service.execute
expect(result[:status]).to eq(:error)
expect(project.releases.find_by(tag: tag_name).description).to eq(description)
diff --git a/spec/services/releases/destroy_service_spec.rb b/spec/services/releases/destroy_service_spec.rb
index dd5b8708f36..db97ea8445b 100644
--- a/spec/services/releases/destroy_service_spec.rb
+++ b/spec/services/releases/destroy_service_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Releases::DestroyService do
let(:project) { create(:project, :repository) }
let(:mainatiner) { create(:user) }
let(:repoter) { create(:user) }
- let(:tag) { 'v1.1.0' }
+ let(:tag) { "v1.1.0" }
let!(:release) { create(:release, project: project, tag: tag) }
let(:service) { described_class.new(project, user, params) }
- let(:params) { { tag: tag } }
+ let(:params) { {tag: tag} }
let(:user) { mainatiner }
before do
@@ -15,45 +15,45 @@ describe Releases::DestroyService do
project.add_reporter(repoter)
end
- describe '#execute' do
+ describe "#execute" do
subject { service.execute }
- context 'when there is a release' do
- it 'removes the release' do
+ context "when there is a release" do
+ it "removes the release" do
expect { subject }.to change { project.releases.count }.by(-1)
end
- it 'returns the destroyed object' do
+ it "returns the destroyed object" do
is_expected.to include(status: :success, release: release)
end
end
- context 'when tag is not found' do
- let(:tag) { 'v1.1.1' }
+ context "when tag is not found" do
+ let(:tag) { "v1.1.1" }
- it 'returns an error' do
+ it "returns an error" do
is_expected.to include(status: :error,
- message: 'Tag does not exist',
+ message: "Tag does not exist",
http_status: 404)
end
end
- context 'when release is not found' do
+ context "when release is not found" do
let!(:release) { }
- it 'returns an error' do
+ it "returns an error" do
is_expected.to include(status: :error,
- message: 'Release does not exist',
+ message: "Release does not exist",
http_status: 404)
end
end
- context 'when user does not have permission' do
+ context "when user does not have permission" do
let(:user) { repoter }
- it 'returns an error' do
+ it "returns an error" do
is_expected.to include(status: :error,
- message: 'Access Denied',
+ message: "Access Denied",
http_status: 403)
end
end
diff --git a/spec/services/releases/update_service_spec.rb b/spec/services/releases/update_service_spec.rb
index 6c68f364739..5b2449ea69f 100644
--- a/spec/services/releases/update_service_spec.rb
+++ b/spec/services/releases/update_service_spec.rb
@@ -1,50 +1,50 @@
-require 'spec_helper'
+require "spec_helper"
describe Releases::UpdateService do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
- let(:new_name) { 'A new name' }
- let(:new_description) { 'The best release!' }
- let(:params) { { name: new_name, description: new_description, tag: tag_name } }
+ let(:new_name) { "A new name" }
+ let(:new_description) { "The best release!" }
+ let(:params) { {name: new_name, description: new_description, tag: tag_name} }
let(:service) { described_class.new(project, user, params) }
let!(:release) { create(:release, project: project, author: user, tag: tag_name) }
- let(:tag_name) { 'v1.1.0' }
+ let(:tag_name) { "v1.1.0" }
before do
project.add_developer(user)
end
- describe '#execute' do
- shared_examples 'a failed update' do
- it 'raises an error' do
+ describe "#execute" do
+ shared_examples "a failed update" do
+ it "raises an error" do
result = service.execute
expect(result[:status]).to eq(:error)
end
end
- it 'successfully updates an existing release' do
+ it "successfully updates an existing release" do
result = service.execute
expect(result[:status]).to eq(:success)
expect(result[:release].name).to eq(new_name)
expect(result[:release].description).to eq(new_description)
end
- context 'when the tag does not exists' do
- let(:tag_name) { 'foobar' }
+ context "when the tag does not exists" do
+ let(:tag_name) { "foobar" }
- it_behaves_like 'a failed update'
+ it_behaves_like "a failed update"
end
- context 'when the release does not exist' do
+ context "when the release does not exist" do
let!(:release) { }
- it_behaves_like 'a failed update'
+ it_behaves_like "a failed update"
end
- context 'with an invalid update' do
- let(:new_description) { '' }
+ context "with an invalid update" do
+ let(:new_description) { "" }
- it_behaves_like 'a failed update'
+ it_behaves_like "a failed update"
end
end
end
diff --git a/spec/services/repair_ldap_blocked_user_service_spec.rb b/spec/services/repair_ldap_blocked_user_service_spec.rb
index bf79cfe74b7..2d14b789312 100644
--- a/spec/services/repair_ldap_blocked_user_service_spec.rb
+++ b/spec/services/repair_ldap_blocked_user_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe RepairLdapBlockedUserService do
- let(:user) { create(:omniauth_user, provider: 'ldapmain', state: 'ldap_blocked') }
+ let(:user) { create(:omniauth_user, provider: "ldapmain", state: "ldap_blocked") }
let(:identity) { user.ldap_identity }
subject(:service) { described_class.new(user) }
- describe '#execute' do
- it 'changes to normal block after destroying last ldap identity' do
+ describe "#execute" 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 'changes to normal block after changing last ldap identity to another provider' do
- identity.update_attribute(:provider, 'twitter')
+ it "changes to normal block after changing last ldap identity to another provider" do
+ identity.update_attribute(:provider, "twitter")
service.execute
expect(user.reload).not_to be_ldap_blocked
diff --git a/spec/services/repository_archive_clean_up_service_spec.rb b/spec/services/repository_archive_clean_up_service_spec.rb
index ab1c638fc39..01fd8965c46 100644
--- a/spec/services/repository_archive_clean_up_service_spec.rb
+++ b/spec/services/repository_archive_clean_up_service_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryArchiveCleanUpService do
subject(:service) { described_class.new }
- describe '#execute (new archive locations)' do
+ describe "#execute (new archive locations)" do
let(:sha) { "0" * 40 }
- it 'removes outdated archives and directories in a new-style path' do
+ it "removes outdated archives and directories in a new-style path" do
in_directory_with_files("project-999/#{sha}", %w[tar tar.bz2 tar.gz zip], 3.hours) do |dirname, files|
service.execute
@@ -16,7 +16,7 @@ describe RepositoryArchiveCleanUpService do
end
end
- it 'does not remove directories when they contain outdated non-archives' do
+ it "does not remove directories when they contain outdated non-archives" do
in_directory_with_files("project-999/#{sha}", %w[tar conf rb], 2.hours) do |dirname, files|
service.execute
@@ -24,7 +24,7 @@ describe RepositoryArchiveCleanUpService do
end
end
- it 'does not remove in-date archives in a new-style path' do
+ it "does not remove in-date archives in a new-style path" do
in_directory_with_files("project-999/#{sha}", %w[tar tar.bz2 tar.gz zip], 1.hour) do |dirname, files|
service.execute
@@ -33,10 +33,10 @@ describe RepositoryArchiveCleanUpService do
end
end
- describe '#execute (legacy archive locations)' do
- context 'when the downloads directory does not exist' do
- it 'does not remove any archives' do
- path = '/invalid/path/'
+ describe "#execute (legacy archive locations)" do
+ context "when the downloads directory does not exist" do
+ it "does not remove any archives" do
+ path = "/invalid/path/"
stub_repository_downloads_path(path)
allow(File).to receive(:directory?).and_call_original
@@ -49,9 +49,9 @@ describe RepositoryArchiveCleanUpService do
end
end
- context 'when the downloads directory exists' do
- shared_examples 'invalid archive files' do |dirname, extensions, mtime|
- it 'does not remove files and directory' do
+ context "when the downloads directory exists" do
+ shared_examples "invalid archive files" do |dirname, extensions, mtime|
+ it "does not remove files and directory" do
in_directory_with_files(dirname, extensions, mtime) do |dir, files|
service.execute
@@ -61,8 +61,8 @@ describe RepositoryArchiveCleanUpService do
end
end
- it 'removes files older than 2 hours that matches valid archive extensions' do
- in_directory_with_files('sample.git', %w[tar tar.bz2 tar.gz zip], 2.hours) do |dir, files|
+ it "removes files older than 2 hours that matches valid archive extensions" do
+ in_directory_with_files("sample.git", %w[tar tar.bz2 tar.gz zip], 2.hours) do |dir, files|
service.execute
files.each { |file| expect(File.exist?(file)).to eq false }
@@ -70,24 +70,24 @@ describe RepositoryArchiveCleanUpService do
end
end
- context 'with files older than 2 hours that does not matches valid archive extensions' do
- it_behaves_like 'invalid archive files', 'sample.git', %w[conf rb], 2.hours
+ context "with files older than 2 hours that does not matches valid archive extensions" do
+ it_behaves_like "invalid archive files", "sample.git", %w[conf rb], 2.hours
end
- context 'with files older than 2 hours inside invalid directories' do
- it_behaves_like 'invalid archive files', 'john/doe/sample.git', %w[conf rb tar tar.gz], 2.hours
+ context "with files older than 2 hours inside invalid directories" do
+ it_behaves_like "invalid archive files", "john/doe/sample.git", %w[conf rb tar tar.gz], 2.hours
end
- context 'with files newer than 2 hours that matches valid archive extensions' do
- it_behaves_like 'invalid archive files', 'sample.git', %w[tar tar.bz2 tar.gz zip], 1.hour
+ context "with files newer than 2 hours that matches valid archive extensions" do
+ it_behaves_like "invalid archive files", "sample.git", %w[tar tar.bz2 tar.gz zip], 1.hour
end
- context 'with files newer than 2 hours that does not matches valid archive extensions' do
- it_behaves_like 'invalid archive files', 'sample.git', %w[conf rb], 1.hour
+ context "with files newer than 2 hours that does not matches valid archive extensions" do
+ it_behaves_like "invalid archive files", "sample.git", %w[conf rb], 1.hour
end
- context 'with files newer than 2 hours inside invalid directories' do
- it_behaves_like 'invalid archive files', 'sample.git', %w[conf rb tar tar.gz], 1.hour
+ context "with files newer than 2 hours inside invalid directories" do
+ it_behaves_like "invalid archive files", "sample.git", %w[conf rb tar tar.gz], 1.hour
end
end
end
diff --git a/spec/services/reset_project_cache_service_spec.rb b/spec/services/reset_project_cache_service_spec.rb
index 1490ad5fe3b..1449f69fea7 100644
--- a/spec/services/reset_project_cache_service_spec.rb
+++ b/spec/services/reset_project_cache_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ResetProjectCacheService do
let(:project) { create(:project) }
@@ -6,22 +6,22 @@ describe ResetProjectCacheService do
subject { described_class.new(project, user).execute }
- context 'when project cache_index is nil' do
+ context "when project cache_index is nil" do
before do
project.jobs_cache_index = nil
end
- it 'sets project cache_index to one' do
+ it "sets project cache_index to one" do
expect { subject }.to change { project.reload.jobs_cache_index }.from(nil).to(1)
end
end
- context 'when project cache_index is a numeric value' do
+ context "when project cache_index is a numeric value" do
before do
project.update(jobs_cache_index: 1)
end
- it 'increments project cache index' do
+ it "increments project cache index" do
expect { subject }.to change { project.reload.jobs_cache_index }.by(1)
end
end
diff --git a/spec/services/resource_events/change_labels_service_spec.rb b/spec/services/resource_events/change_labels_service_spec.rb
index 070964eb1ec..bdf5a4ca9ca 100644
--- a/spec/services/resource_events/change_labels_service_spec.rb
+++ b/spec/services/resource_events/change_labels_service_spec.rb
@@ -1,13 +1,13 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ResourceEvents::ChangeLabelsService do
set(:project) { create(:project) }
set(:author) { create(:user) }
let(:resource) { create(:issue, project: project) }
- describe '.change_labels' do
+ describe ".change_labels" do
subject { described_class.new(resource, author).execute(added_labels: added, removed_labels: removed) }
let(:labels) { create_list(:label, 2, project: project) }
@@ -18,7 +18,7 @@ describe ResourceEvents::ChangeLabelsService do
expect(event.action).to eq(action)
end
- it 'expires resource note etag cache' do
+ it "expires resource note etag cache" do
expect_any_instance_of(Gitlab::EtagCaching::Store)
.to receive(:touch)
.with("/#{resource.project.namespace.to_param}/#{resource.project.to_param}/noteable/issue/#{resource.id}/notes")
@@ -26,33 +26,33 @@ describe ResourceEvents::ChangeLabelsService do
described_class.new(resource, author).execute(added_labels: [labels[0]])
end
- context 'when adding a label' do
+ context "when adding a label" do
let(:added) { [labels[0]] }
let(:removed) { [] }
- it 'creates new label event' do
+ it "creates new label event" do
expect { subject }.to change { resource.resource_label_events.count }.from(0).to(1)
- expect_label_event(resource.resource_label_events.first, labels[0], 'add')
+ expect_label_event(resource.resource_label_events.first, labels[0], "add")
end
end
- context 'when removing a label' do
+ context "when removing a label" do
let(:added) { [] }
let(:removed) { [labels[1]] }
- it 'creates new label event' do
+ it "creates new label event" do
expect { subject }.to change { resource.resource_label_events.count }.from(0).to(1)
- expect_label_event(resource.resource_label_events.first, labels[1], 'remove')
+ expect_label_event(resource.resource_label_events.first, labels[1], "remove")
end
end
- context 'when both adding and removing labels' do
+ context "when both adding and removing labels" do
let(:added) { [labels[0]] }
let(:removed) { [labels[1]] }
- it 'creates all label events in a single query' do
+ it "creates all label events in a single query" do
expect(Gitlab::Database).to receive(:bulk_insert).once.and_call_original
expect { subject }.to change { resource.resource_label_events.count }.from(0).to(2)
end
diff --git a/spec/services/resource_events/merge_into_notes_service_spec.rb b/spec/services/resource_events/merge_into_notes_service_spec.rb
index 72467091791..a574303c81a 100644
--- a/spec/services/resource_events/merge_into_notes_service_spec.rb
+++ b/spec/services/resource_events/merge_into_notes_service_spec.rb
@@ -1,17 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ResourceEvents::MergeIntoNotesService do
def create_event(params)
- event_params = { action: :add, label: label, issue: resource,
- user: user }
+ event_params = {action: :add, label: label, issue: resource,
+ user: user,}
create(:resource_label_event, event_params.merge(params))
end
def create_note(params)
- opts = { noteable: resource, project: project }
+ opts = {noteable: resource, project: project}
create(:note_on_issue, opts.merge(params))
end
@@ -23,8 +23,8 @@ describe ResourceEvents::MergeIntoNotesService do
set(:label2) { create(:label, project: project) }
let(:time) { Time.now }
- describe '#execute' do
- it 'merges label events into notes in order of created_at' do
+ describe "#execute" do
+ it "merges label events into notes in order of created_at" do
note1 = create_note(created_at: 4.days.ago)
note2 = create_note(created_at: 2.days.ago)
event1 = create_event(created_at: 3.days.ago)
@@ -36,7 +36,7 @@ describe ResourceEvents::MergeIntoNotesService do
expect(notes.map(&:discussion_id)).to eq expected
end
- it 'squashes events with same time and author into single note' do
+ it "squashes events with same time and author into single note" do
user2 = create(:user)
create_event(created_at: time)
@@ -49,19 +49,19 @@ describe ResourceEvents::MergeIntoNotesService do
expected = [
"added #{label.to_reference} label and removed #{label2.to_reference} label",
"added #{label.to_reference} label",
- "added #{label2.to_reference} label"
+ "added #{label2.to_reference} label",
]
expect(notes.count).to eq 3
expect(notes.map(&:note)).to match_array expected
end
- it 'fetches only notes created after last_fetched_at' do
+ it "fetches only notes created after last_fetched_at" do
create_event(created_at: 4.days.ago)
event = create_event(created_at: 1.day.ago)
notes = described_class.new(resource, user,
- last_fetched_at: 2.days.ago.to_i).execute
+ last_fetched_at: 2.days.ago.to_i).execute
expect(notes.count).to eq 1
expect(notes.first.discussion_id).to eq event.discussion_id
diff --git a/spec/services/search/global_service_spec.rb b/spec/services/search/global_service_spec.rb
index 980545b8083..9025ceab402 100644
--- a/spec/services/search/global_service_spec.rb
+++ b/spec/services/search/global_service_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Search::GlobalService do
let(:user) { create(:user) }
let(:internal_user) { create(:user) }
- let!(:found_project) { create(:project, :private, name: 'searchable_project') }
- let!(:unfound_project) { create(:project, :private, name: 'unfound_project') }
- let!(:internal_project) { create(:project, :internal, name: 'searchable_internal_project') }
- let!(:public_project) { create(:project, :public, name: 'searchable_public_project') }
+ let!(:found_project) { create(:project, :private, name: "searchable_project") }
+ let!(:unfound_project) { create(:project, :private, name: "unfound_project") }
+ let!(:internal_project) { create(:project, :internal, name: "searchable_internal_project") }
+ let!(:public_project) { create(:project, :public, name: "searchable_public_project") }
before do
found_project.add_maintainer(user)
end
- describe '#execute' do
- context 'unauthenticated' do
- it 'returns public projects only' do
+ describe "#execute" do
+ context "unauthenticated" do
+ it "returns public projects only" do
results = described_class.new(nil, search: "searchable").execute
- expect(results.objects('projects')).to match_array [public_project]
+ expect(results.objects("projects")).to match_array [public_project]
end
end
- context 'authenticated' do
- it 'returns public, internal and private projects' do
+ context "authenticated" do
+ it "returns public, internal and private projects" do
results = described_class.new(user, search: "searchable").execute
- expect(results.objects('projects')).to match_array [public_project, found_project, internal_project]
+ expect(results.objects("projects")).to match_array [public_project, found_project, internal_project]
end
- it 'returns only public & internal projects' do
+ it "returns only public & internal projects" do
results = described_class.new(internal_user, search: "searchable").execute
- expect(results.objects('projects')).to match_array [internal_project, public_project]
+ expect(results.objects("projects")).to match_array [internal_project, public_project]
end
- it 'project name is searchable' do
+ it "project name is searchable" do
results = described_class.new(user, search: found_project.name).execute
- expect(results.objects('projects')).to match_array [found_project]
+ expect(results.objects("projects")).to match_array [found_project]
end
end
end
diff --git a/spec/services/search/group_service_spec.rb b/spec/services/search/group_service_spec.rb
index cbc553a60cf..93c2f42994b 100644
--- a/spec/services/search/group_service_spec.rb
+++ b/spec/services/search/group_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Search::GroupService do
- shared_examples_for 'group search' do
- context 'finding projects by name' do
+ shared_examples_for "group search" do
+ context "finding projects by name" do
let(:user) { create(:user) }
let(:term) { "Project Name" }
let(:nested_group) { create(:group, :nested) }
# These projects shouldn't be found
let!(:outside_project) { create(:project, :public, name: "Outside #{term}") }
- let!(:private_project) { create(:project, :private, namespace: nested_group, name: "Private #{term}" )}
+ let!(:private_project) { create(:project, :private, namespace: nested_group, name: "Private #{term}")}
let!(:other_project) { create(:project, :public, namespace: nested_group, name: term.reverse) }
# These projects should be found
@@ -18,15 +18,15 @@ describe Search::GroupService do
let!(:project3) { create(:project, :internal, namespace: nested_group.parent, name: "Outer #{term}") }
let(:results) { described_class.new(user, search_group, search: term).execute }
- subject { results.objects('projects') }
+ subject { results.objects("projects") }
- context 'in parent group' do
+ context "in parent group" do
let(:search_group) { nested_group.parent }
it { is_expected.to match_array([project1, project2, project3]) }
end
- context 'in subgroup' do
+ context "in subgroup" do
let(:search_group) { nested_group }
it { is_expected.to match_array([project1, project2]) }
@@ -34,7 +34,7 @@ describe Search::GroupService do
end
end
- describe 'basic search' do
- include_examples 'group search'
+ describe "basic search" do
+ include_examples "group search"
end
end
diff --git a/spec/services/search/snippet_service_spec.rb b/spec/services/search/snippet_service_spec.rb
index 8ad162ad66e..a561a50d711 100644
--- a/spec/services/search/snippet_service_spec.rb
+++ b/spec/services/search/snippet_service_spec.rb
@@ -1,58 +1,58 @@
-require 'spec_helper'
+require "spec_helper"
describe Search::SnippetService do
let(:author) { create(:author) }
let(:project) { create(:project, :public) }
- let!(:public_snippet) { create(:snippet, :public, content: 'password: XXX') }
- let!(:internal_snippet) { create(:snippet, :internal, content: 'password: XXX') }
- let!(:private_snippet) { create(:snippet, :private, content: 'password: XXX', author: author) }
+ let!(:public_snippet) { create(:snippet, :public, content: "password: XXX") }
+ let!(:internal_snippet) { create(:snippet, :internal, content: "password: XXX") }
+ let!(:private_snippet) { create(:snippet, :private, content: "password: XXX", author: author) }
- let!(:project_public_snippet) { create(:snippet, :public, project: project, content: 'password: XXX') }
- let!(:project_internal_snippet) { create(:snippet, :internal, project: project, content: 'password: XXX') }
- let!(:project_private_snippet) { create(:snippet, :private, project: project, content: 'password: XXX') }
+ let!(:project_public_snippet) { create(:snippet, :public, project: project, content: "password: XXX") }
+ let!(:project_internal_snippet) { create(:snippet, :internal, project: project, content: "password: XXX") }
+ let!(:project_private_snippet) { create(:snippet, :private, project: project, content: "password: XXX") }
- describe '#execute' do
- context 'unauthenticated' do
- it 'returns public snippets only' do
- search = described_class.new(nil, search: 'password')
+ describe "#execute" do
+ context "unauthenticated" do
+ it "returns public snippets only" do
+ search = described_class.new(nil, search: "password")
results = search.execute
- expect(results.objects('snippet_blobs')).to match_array [public_snippet, project_public_snippet]
+ expect(results.objects("snippet_blobs")).to match_array [public_snippet, project_public_snippet]
end
end
- context 'authenticated' do
- it 'returns only public & internal snippets for regular users' do
+ context "authenticated" do
+ it "returns only public & internal snippets for regular users" do
user = create(:user)
- search = described_class.new(user, search: 'password')
+ search = described_class.new(user, search: "password")
results = search.execute
- expect(results.objects('snippet_blobs')).to match_array [public_snippet, internal_snippet, project_public_snippet, project_internal_snippet]
+ expect(results.objects("snippet_blobs")).to match_array [public_snippet, internal_snippet, project_public_snippet, project_internal_snippet]
end
- it 'returns public, internal snippets and project private snippets for project members' do
+ it "returns public, internal snippets and project private snippets for project members" do
member = create(:user)
project.add_developer(member)
- search = described_class.new(member, search: 'password')
+ search = described_class.new(member, search: "password")
results = search.execute
- expect(results.objects('snippet_blobs')).to match_array [public_snippet, internal_snippet, project_public_snippet, project_internal_snippet, project_private_snippet]
+ expect(results.objects("snippet_blobs")).to match_array [public_snippet, internal_snippet, project_public_snippet, project_internal_snippet, project_private_snippet]
end
- it 'returns public, internal and private snippets where user is the author' do
- search = described_class.new(author, search: 'password')
+ it "returns public, internal and private snippets where user is the author" do
+ search = described_class.new(author, search: "password")
results = search.execute
- expect(results.objects('snippet_blobs')).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet]
+ expect(results.objects("snippet_blobs")).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet]
end
- it 'returns all snippets when user is admin' do
+ it "returns all snippets when user is admin" do
admin = create(:admin)
- search = described_class.new(admin, search: 'password')
+ search = described_class.new(admin, search: "password")
results = search.execute
- expect(results.objects('snippet_blobs')).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet, project_private_snippet]
+ expect(results.objects("snippet_blobs")).to match_array [public_snippet, internal_snippet, private_snippet, project_public_snippet, project_internal_snippet, project_private_snippet]
end
end
end
diff --git a/spec/services/search_service_spec.rb b/spec/services/search_service_spec.rb
index e5e036c7d44..f993f37276c 100644
--- a/spec/services/search_service_spec.rb
+++ b/spec/services/search_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SearchService do
let(:user) { create(:user) }
@@ -7,27 +7,27 @@ describe SearchService do
let(:inaccessible_group) { create(:group, :private) }
let!(:group_member) { create(:group_member, group: accessible_group, user: user) }
- let!(:accessible_project) { create(:project, :private, name: 'accessible_project') }
- let!(:inaccessible_project) { create(:project, :private, name: 'inaccessible_project') }
+ let!(:accessible_project) { create(:project, :private, name: "accessible_project") }
+ let!(:inaccessible_project) { create(:project, :private, name: "inaccessible_project") }
let(:note) { create(:note_on_issue, project: accessible_project) }
let(:snippet) { create(:snippet, author: user) }
- let(:group_project) { create(:project, group: accessible_group, name: 'group_project') }
- let(:public_project) { create(:project, :public, name: 'public_project') }
+ let(:group_project) { create(:project, group: accessible_group, name: "group_project") }
+ let(:public_project) { create(:project, :public, name: "public_project") }
before do
accessible_project.add_maintainer(user)
end
- describe '#project' do
- context 'when the project is accessible' do
- it 'returns the project' do
+ describe "#project" do
+ context "when the project is accessible" do
+ it "returns the project" do
project = described_class.new(user, project_id: accessible_project.id).project
expect(project).to eq accessible_project
end
- it 'returns the project for guests' do
+ it "returns the project for guests" do
search_project = create :project
search_project.add_guest(user)
@@ -37,16 +37,16 @@ describe SearchService do
end
end
- context 'when the project is not accessible' do
- it 'returns nil' do
+ context "when the project is not accessible" do
+ it "returns nil" do
project = described_class.new(user, project_id: inaccessible_project.id).project
expect(project).to be_nil
end
end
- context 'when there is no project_id' do
- it 'returns nil' do
+ context "when there is no project_id" do
+ it "returns nil" do
project = described_class.new(user).project
expect(project).to be_nil
@@ -54,25 +54,25 @@ describe SearchService do
end
end
- describe '#group' do
- context 'when the group is accessible' do
- it 'returns the group' do
+ describe "#group" do
+ context "when the group is accessible" do
+ it "returns the group" do
group = described_class.new(user, group_id: accessible_group.id).group
expect(group).to eq accessible_group
end
end
- context 'when the group is not accessible' do
- it 'returns nil' do
+ context "when the group is not accessible" do
+ it "returns nil" do
group = described_class.new(user, group_id: inaccessible_group.id).group
expect(group).to be_nil
end
end
- context 'when there is no group_id' do
- it 'returns nil' do
+ context "when there is no group_id" do
+ it "returns nil" do
group = described_class.new(user).group
expect(group).to be_nil
@@ -80,25 +80,25 @@ describe SearchService do
end
end
- describe '#show_snippets?' do
- context 'when :snippets is \'true\'' do
- it 'returns true' do
- show_snippets = described_class.new(user, snippets: 'true').show_snippets?
+ describe "#show_snippets?" do
+ context "when :snippets is 'true'" do
+ it "returns true" do
+ show_snippets = described_class.new(user, snippets: "true").show_snippets?
expect(show_snippets).to be_truthy
end
end
- context 'when :snippets is not \'true\'' do
- it 'returns false' do
- show_snippets = described_class.new(user, snippets: 'tru').show_snippets?
+ context "when :snippets is not 'true'" do
+ it "returns false" do
+ show_snippets = described_class.new(user, snippets: "tru").show_snippets?
expect(show_snippets).to be_falsey
end
end
- context 'when :snippets is missing' do
- it 'returns false' do
+ context "when :snippets is missing" do
+ it "returns false" do
show_snippets = described_class.new(user).show_snippets?
expect(show_snippets).to be_falsey
@@ -106,187 +106,196 @@ describe SearchService do
end
end
- describe '#scope' do
- context 'with accessible project_id' do
- context 'and allowed scope' do
- it 'returns the specified scope' do
- scope = described_class.new(user, project_id: accessible_project.id, scope: 'notes').scope
+ describe "#scope" do
+ context "with accessible project_id" do
+ context "and allowed scope" do
+ it "returns the specified scope" do
+ scope = described_class.new(user, project_id: accessible_project.id, scope: "notes").scope
- expect(scope).to eq 'notes'
+ expect(scope).to eq "notes"
end
end
- context 'and disallowed scope' do
- it 'returns the default scope' do
- scope = described_class.new(user, project_id: accessible_project.id, scope: 'projects').scope
+ context "and disallowed scope" do
+ it "returns the default scope" do
+ scope = described_class.new(user, project_id: accessible_project.id, scope: "projects").scope
- expect(scope).to eq 'blobs'
+ expect(scope).to eq "blobs"
end
end
- context 'and no scope' do
- it 'returns the default scope' do
+ context "and no scope" do
+ it "returns the default scope" do
scope = described_class.new(user, project_id: accessible_project.id).scope
- expect(scope).to eq 'blobs'
+ expect(scope).to eq "blobs"
end
end
end
- context 'with \'true\' snippets' do
- context 'and allowed scope' do
- it 'returns the specified scope' do
- scope = described_class.new(user, snippets: 'true', scope: 'snippet_titles').scope
+ context "with 'true' snippets" do
+ context "and allowed scope" do
+ it "returns the specified scope" do
+ scope = described_class.new(user, snippets: "true", scope: "snippet_titles").scope
- expect(scope).to eq 'snippet_titles'
+ expect(scope).to eq "snippet_titles"
end
end
- context 'and disallowed scope' do
- it 'returns the default scope' do
- scope = described_class.new(user, snippets: 'true', scope: 'projects').scope
+ context "and disallowed scope" do
+ it "returns the default scope" do
+ scope = described_class.new(user, snippets: "true", scope: "projects").scope
- expect(scope).to eq 'snippet_blobs'
+ expect(scope).to eq "snippet_blobs"
end
end
- context 'and no scope' do
- it 'returns the default scope' do
- scope = described_class.new(user, snippets: 'true').scope
+ context "and no scope" do
+ it "returns the default scope" do
+ scope = described_class.new(user, snippets: "true").scope
- expect(scope).to eq 'snippet_blobs'
+ expect(scope).to eq "snippet_blobs"
end
end
end
- context 'with no project_id, no snippets' do
- context 'and allowed scope' do
- it 'returns the specified scope' do
- scope = described_class.new(user, scope: 'issues').scope
+ context "with no project_id, no snippets" do
+ context "and allowed scope" do
+ it "returns the specified scope" do
+ scope = described_class.new(user, scope: "issues").scope
- expect(scope).to eq 'issues'
+ expect(scope).to eq "issues"
end
end
- context 'and disallowed scope' do
- it 'returns the default scope' do
- scope = described_class.new(user, scope: 'blobs').scope
+ context "and disallowed scope" do
+ it "returns the default scope" do
+ scope = described_class.new(user, scope: "blobs").scope
- expect(scope).to eq 'projects'
+ expect(scope).to eq "projects"
end
end
- context 'and no scope' do
- it 'returns the default scope' do
+ context "and no scope" do
+ it "returns the default scope" do
scope = described_class.new(user).scope
- expect(scope).to eq 'projects'
+ expect(scope).to eq "projects"
end
end
end
end
- describe '#search_results' do
- context 'with accessible project_id' do
- it 'returns an instance of Gitlab::ProjectSearchResults' do
+ describe "#search_results" do
+ context "with accessible project_id" do
+ it "returns an instance of Gitlab::ProjectSearchResults" do
search_results = described_class.new(
user,
project_id: accessible_project.id,
- scope: 'notes',
- search: note.note).search_results
+ scope: "notes",
+ search: note.note
+ ).search_results
expect(search_results).to be_a Gitlab::ProjectSearchResults
end
end
- context 'with accessible project_id and \'true\' snippets' do
- it 'returns an instance of Gitlab::ProjectSearchResults' do
+ context "with accessible project_id and 'true' snippets" do
+ it "returns an instance of Gitlab::ProjectSearchResults" do
search_results = described_class.new(
user,
project_id: accessible_project.id,
- snippets: 'true',
- scope: 'notes',
- search: note.note).search_results
+ snippets: "true",
+ scope: "notes",
+ search: note.note
+ ).search_results
expect(search_results).to be_a Gitlab::ProjectSearchResults
end
end
- context 'with \'true\' snippets' do
- it 'returns an instance of Gitlab::SnippetSearchResults' do
+ context "with 'true' snippets" do
+ it "returns an instance of Gitlab::SnippetSearchResults" do
search_results = described_class.new(
user,
- snippets: 'true',
- search: snippet.content).search_results
+ snippets: "true",
+ search: snippet.content
+ ).search_results
expect(search_results).to be_a Gitlab::SnippetSearchResults
end
end
- context 'with no project_id and no snippets' do
- it 'returns an instance of Gitlab::SearchResults' do
+ context "with no project_id and no snippets" do
+ it "returns an instance of Gitlab::SearchResults" do
search_results = described_class.new(
user,
- search: public_project.name).search_results
+ search: public_project.name
+ ).search_results
expect(search_results).to be_a Gitlab::SearchResults
end
end
end
- describe '#search_objects' do
- context 'with accessible project_id' do
- it 'returns objects in the project' do
+ describe "#search_objects" do
+ context "with accessible project_id" do
+ it "returns objects in the project" do
search_objects = described_class.new(
user,
project_id: accessible_project.id,
- scope: 'notes',
- search: note.note).search_objects
+ scope: "notes",
+ search: note.note
+ ).search_objects
expect(search_objects.first).to eq note
end
end
- context 'with accessible project_id and \'true\' snippets' do
- it 'returns objects in the project' do
+ context "with accessible project_id and 'true' snippets" do
+ it "returns objects in the project" do
search_objects = described_class.new(
user,
project_id: accessible_project.id,
- snippets: 'true',
- scope: 'notes',
- search: note.note).search_objects
+ snippets: "true",
+ scope: "notes",
+ search: note.note
+ ).search_objects
expect(search_objects.first).to eq note
end
end
- context 'with \'true\' snippets' do
- it 'returns objects in snippets' do
+ context "with 'true' snippets" do
+ it "returns objects in snippets" do
search_objects = described_class.new(
user,
- snippets: 'true',
- search: snippet.content).search_objects
+ snippets: "true",
+ search: snippet.content
+ ).search_objects
expect(search_objects.first).to eq snippet
end
end
- context 'with accessible group_id' do
- it 'returns objects in the group' do
+ context "with accessible group_id" do
+ it "returns objects in the group" do
search_objects = described_class.new(
user,
group_id: accessible_group.id,
- search: group_project.name).search_objects
+ search: group_project.name
+ ).search_objects
expect(search_objects.first).to eq group_project
end
end
- context 'with no project_id, group_id or snippets' do
- it 'returns objects in global' do
+ context "with no project_id, group_id or snippets" do
+ it "returns objects in global" do
search_objects = described_class.new(
user,
- search: public_project.name).search_objects
+ search: public_project.name
+ ).search_objects
expect(search_objects.first).to eq public_project
end
diff --git a/spec/services/spam_service_spec.rb b/spec/services/spam_service_spec.rb
index 61312d55b84..96306df9a2d 100644
--- a/spec/services/spam_service_spec.rb
+++ b/spec/services/spam_service_spec.rb
@@ -1,84 +1,84 @@
-require 'spec_helper'
+require "spec_helper"
describe SpamService do
- describe '#when_recaptcha_verified' do
+ describe "#when_recaptcha_verified" do
def check_spam(issue, request, recaptcha_verified)
described_class.new(issue, request).when_recaptcha_verified(recaptcha_verified) do
- 'yielded'
+ "yielded"
end
end
- it 'yields block when recaptcha was already verified' do
+ it "yields block when recaptcha was already verified" do
issue = build_stubbed(:issue)
- expect(check_spam(issue, nil, true)).to eql('yielded')
+ expect(check_spam(issue, nil, true)).to eql("yielded")
end
- context 'when recaptcha was not verified' do
+ context "when recaptcha was not verified" do
let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) }
let(:request) { double(:request, env: {}) }
- context 'when spammable attributes have not changed' do
+ context "when spammable attributes have not changed" do
before do
issue.closed_at = Time.zone.now
allow(AkismetService).to receive(:new).and_return(double(spam?: true))
end
- it 'returns false' do
+ it "returns false" do
expect(check_spam(issue, request, false)).to be_falsey
end
- it 'does not create a spam log' do
+ it "does not create a spam log" do
expect { check_spam(issue, request, false) }
.not_to change { SpamLog.count }
end
end
- context 'when spammable attributes have changed' do
+ context "when spammable attributes have changed" do
before do
- issue.description = 'SPAM!'
+ issue.description = "SPAM!"
end
- context 'when indicated as spam by akismet' do
+ context "when indicated as spam by akismet" do
before do
allow(AkismetService).to receive(:new).and_return(double(spam?: true))
end
- it 'doesnt check as spam when request is missing' do
+ it "doesnt check as spam when request is missing" do
check_spam(issue, nil, false)
expect(issue.spam).to be_falsey
end
- it 'checks as spam' do
+ it "checks as spam" do
check_spam(issue, request, false)
expect(issue.spam).to be_truthy
end
- it 'creates a spam log' do
+ it "creates a spam log" do
expect { check_spam(issue, request, false) }
.to change { SpamLog.count }.from(0).to(1)
end
- it 'doesnt yield block' do
+ it "doesnt yield block" do
expect(check_spam(issue, request, false))
.to eql(SpamLog.last)
end
end
- context 'when not indicated as spam by akismet' do
+ context "when not indicated as spam by akismet" do
before do
allow(AkismetService).to receive(:new).and_return(double(spam?: false))
end
- it 'returns false' do
+ it "returns false" do
expect(check_spam(issue, request, false)).to be_falsey
end
- it 'does not create a spam log' do
+ it "does not create a spam log" do
expect { check_spam(issue, request, false) }
.not_to change { SpamLog.count }
end
diff --git a/spec/services/submit_usage_ping_service_spec.rb b/spec/services/submit_usage_ping_service_spec.rb
index c8a6fc1a99b..2b3d3bea1c5 100644
--- a/spec/services/submit_usage_ping_service_spec.rb
+++ b/spec/services/submit_usage_ping_service_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe SubmitUsagePingService do
- context 'when usage ping is disabled' do
+ context "when usage ping is disabled" do
before do
stub_application_setting(usage_ping_enabled: false)
end
- it 'does not run' do
+ it "does not run" do
expect(HTTParty).not_to receive(:post)
result = subject.execute
@@ -15,12 +15,12 @@ describe SubmitUsagePingService do
end
end
- context 'when usage ping is enabled' do
+ context "when usage ping is enabled" do
before do
stub_application_setting(usage_ping_enabled: true)
end
- it 'sends a POST request' do
+ it "sends a POST request" do
response = stub_response(without_conv_index_params)
subject.execute
@@ -28,7 +28,7 @@ describe SubmitUsagePingService do
expect(response).to have_been_requested
end
- it 'refreshes usage data statistics before submitting' do
+ it "refreshes usage data statistics before submitting" do
stub_response(without_conv_index_params)
expect(Gitlab::UsageData).to receive(:to_json)
@@ -38,7 +38,7 @@ describe SubmitUsagePingService do
subject.execute
end
- it 'saves conversational development index data from the response' do
+ it "saves conversational development index data from the response" do
stub_response(with_conv_index_params)
expect { subject.execute }
@@ -53,7 +53,7 @@ describe SubmitUsagePingService do
def without_conv_index_params
{
- conv_index: {}
+ conv_index: {},
}
end
@@ -91,15 +91,15 @@ describe SubmitUsagePingService do
leader_service_desk_issues: 15.8,
instance_service_desk_issues: 15.1,
- non_existing_column: 'value'
- }
+ non_existing_column: "value",
+ },
}
end
def stub_response(body)
- stub_request(:post, 'https://version.gitlab.com/usage_data')
+ stub_request(:post, "https://version.gitlab.com/usage_data")
.to_return(
- headers: { 'Content-Type' => 'application/json' },
+ headers: {"Content-Type" => "application/json"},
body: body.to_json
)
end
diff --git a/spec/services/submodules/update_service_spec.rb b/spec/services/submodules/update_service_spec.rb
index cf92350c1b2..e54094d0aec 100644
--- a/spec/services/submodules/update_service_spec.rb
+++ b/spec/services/submodules/update_service_spec.rb
@@ -1,28 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Submodules::UpdateService do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user, :commit_email) }
let(:branch_name) { project.default_branch }
- let(:submodule) { 'six' }
- let(:commit_sha) { 'e25eda1fece24ac7a03624ed1320f82396f35bd8' }
- let(:commit_message) { 'whatever' }
- let(:current_sha) { repository.blob_at('HEAD', submodule).id }
+ let(:submodule) { "six" }
+ let(:commit_sha) { "e25eda1fece24ac7a03624ed1320f82396f35bd8" }
+ let(:commit_message) { "whatever" }
+ let(:current_sha) { repository.blob_at("HEAD", submodule).id }
let(:commit_params) do
{
submodule: submodule,
commit_message: commit_message,
commit_sha: commit_sha,
- branch_name: branch_name
+ branch_name: branch_name,
}
end
subject { described_class.new(project, user, commit_params) }
describe "#execute" do
- shared_examples 'returns error result' do
+ shared_examples "returns error result" do
it do
result = subject.execute
@@ -31,133 +32,133 @@ describe Submodules::UpdateService do
end
end
- context 'when the user is not authorized' do
- it_behaves_like 'returns error result' do
- let(:error_message) { 'You are not allowed to push into this branch' }
+ context "when the user is not authorized" do
+ it_behaves_like "returns error result" do
+ let(:error_message) { "You are not allowed to push into this branch" }
end
end
- context 'when the user is authorized' do
+ context "when the user is authorized" do
before do
project.add_maintainer(user)
end
- context 'when the branch is protected' do
+ context "when the branch is protected" do
before do
create(:protected_branch, :no_one_can_push, project: project, name: branch_name)
end
- it_behaves_like 'returns error result' do
- let(:error_message) { 'You are not allowed to push into this branch' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "You are not allowed to push into this branch" }
end
end
- context 'validations' do
- context 'when submodule' do
- context 'is empty' do
- let(:submodule) { '' }
+ context "validations" do
+ context "when submodule" do
+ context "is empty" do
+ let(:submodule) { "" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
- context 'is not present' do
+ context "is not present" do
let(:submodule) { nil }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
- context 'is invalid' do
- let(:submodule) { 'VERSION' }
+ context "is invalid" do
+ let(:submodule) { "VERSION" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid submodule path' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid submodule path" }
end
end
- context 'does not exist' do
- let(:submodule) { 'non-existent-submodule' }
+ context "does not exist" do
+ let(:submodule) { "non-existent-submodule" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid submodule path' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid submodule path" }
end
end
- context 'has traversal path' do
- let(:submodule) { '../six' }
+ context "has traversal path" do
+ let(:submodule) { "../six" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
end
- context 'commit_sha' do
- context 'is empty' do
- let(:commit_sha) { '' }
+ context "commit_sha" do
+ context "is empty" do
+ let(:commit_sha) { "" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
- context 'is not present' do
+ context "is not present" do
let(:commit_sha) { nil }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
- context 'is invalid' do
- let(:commit_sha) { '1' }
+ context "is invalid" do
+ let(:commit_sha) { "1" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'Invalid parameters' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "Invalid parameters" }
end
end
- context 'is the same as the current ref' do
+ context "is the same as the current ref" do
let(:commit_sha) { current_sha }
- it_behaves_like 'returns error result' do
+ it_behaves_like "returns error result" do
let(:error_message) { "The submodule #{submodule} is already at #{commit_sha}" }
end
end
end
- context 'branch_name' do
- context 'is empty' do
- let(:branch_name) { '' }
+ context "branch_name" do
+ context "is empty" do
+ let(:branch_name) { "" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'You can only create or edit files when you are on a branch' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "You can only create or edit files when you are on a branch" }
end
end
- context 'is not present' do
+ context "is not present" do
let(:branch_name) { nil }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'You can only create or edit files when you are on a branch' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "You can only create or edit files when you are on a branch" }
end
end
- context 'does not exist' do
- let(:branch_name) { 'non/existent-branch' }
+ context "does not exist" do
+ let(:branch_name) { "non/existent-branch" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'You can only create or edit files when you are on a branch' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "You can only create or edit files when you are on a branch" }
end
end
- context 'when commit message is empty' do
- let(:commit_message) { '' }
+ context "when commit message is empty" do
+ let(:commit_message) { "" }
- it 'a default commit message is set' do
+ it "a default commit message is set" do
message = "Update submodule #{submodule} with oid #{commit_sha}"
expect(repository).to receive(:update_submodule).with(any_args, hash_including(message: message))
@@ -168,29 +169,29 @@ describe Submodules::UpdateService do
end
end
- context 'when there is an unexpected error' do
+ context "when there is an unexpected error" do
before do
- allow(repository).to receive(:update_submodule).and_raise(StandardError, 'error message')
+ allow(repository).to receive(:update_submodule).and_raise(StandardError, "error message")
end
- it_behaves_like 'returns error result' do
- let(:error_message) { 'error message' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "error message" }
end
end
- it 'updates the submodule reference' do
+ it "updates the submodule reference" do
result = subject.execute
expect(result[:status]).to eq :success
expect(result[:result]).to eq repository.head_commit.id
- expect(repository.blob_at('HEAD', submodule).id).to eq commit_sha
+ expect(repository.blob_at("HEAD", submodule).id).to eq commit_sha
end
- context 'when submodule is inside a directory' do
- let(:submodule) { 'test_inside_folder/another_folder/six' }
- let(:branch_name) { 'submodule_inside_folder' }
+ context "when submodule is inside a directory" do
+ let(:submodule) { "test_inside_folder/another_folder/six" }
+ let(:branch_name) { "submodule_inside_folder" }
- it 'updates the submodule reference' do
+ it "updates the submodule reference" do
expect(repository.blob_at(branch_name, submodule).id).not_to eq commit_sha
subject.execute
@@ -199,12 +200,12 @@ describe Submodules::UpdateService do
end
end
- context 'when repository is empty' do
+ context "when repository is empty" do
let(:project) { create(:project, :empty_repo) }
- let(:branch_name) { 'master' }
+ let(:branch_name) { "master" }
- it_behaves_like 'returns error result' do
- let(:error_message) { 'The repository is empty' }
+ it_behaves_like "returns error result" do
+ let(:error_message) { "The repository is empty" }
end
end
end
diff --git a/spec/services/suggestions/apply_service_spec.rb b/spec/services/suggestions/apply_service_spec.rb
index fe85b5c9065..6ae03cd9303 100644
--- a/spec/services/suggestions/apply_service_spec.rb
+++ b/spec/services/suggestions/apply_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Suggestions::ApplyService do
include ProjectForksHelper
@@ -24,7 +24,7 @@ describe Suggestions::ApplyService do
subject { described_class.new(user) }
- context 'patch is appliable' do
+ context "patch is appliable" do
let(:expected_content) do
<<-CONTENT.strip_heredoc
require 'fileutils'
@@ -68,7 +68,7 @@ describe Suggestions::ApplyService do
CONTENT
end
- context 'non-fork project' do
+ context "non-fork project" do
let(:merge_request) do
create(:merge_request, source_project: project,
target_project: project)
@@ -84,22 +84,22 @@ describe Suggestions::ApplyService do
project.add_maintainer(user)
end
- it 'updates the file with the new contents' do
+ it "updates the file with the new contents" do
subject.execute(suggestion)
blob = project.repository.blob_at_branch(merge_request.source_branch,
- position.new_path)
+ position.new_path)
expect(blob.data).to eq(expected_content)
end
- it 'returns success status' do
+ it "returns success status" do
result = subject.execute(suggestion)
expect(result[:status]).to eq(:success)
end
- it 'updates suggestion applied and commit_id columns' do
+ it "updates suggestion applied and commit_id columns" do
expect { subject.execute(suggestion) }
.to change(suggestion, :applied)
.from(false).to(true)
@@ -107,7 +107,7 @@ describe Suggestions::ApplyService do
.from(nil)
end
- it 'created commit has users email and name' do
+ it "created commit has users email and name" do
subject.execute(suggestion)
commit = project.repository.commit
@@ -118,8 +118,8 @@ describe Suggestions::ApplyService do
expect(commit.author_name).to eq(user.name)
end
- context 'when it fails to apply because the file was changed' do
- it 'returns error message' do
+ context "when it fails to apply because the file was changed" do
+ it "returns error message" do
service = instance_double(Files::UpdateService)
expect(Files::UpdateService).to receive(:new)
@@ -130,23 +130,23 @@ describe Suggestions::ApplyService do
result = subject.execute(suggestion)
- expect(result).to eq(message: 'The file has been changed', status: :error)
+ expect(result).to eq(message: "The file has been changed", status: :error)
end
end
- context 'when HEAD from position is different from source branch HEAD on repo' do
- it 'returns error message' do
+ context "when HEAD from position is different from source branch HEAD on repo" do
+ it "returns error message" do
allow(suggestion).to receive(:appliable?) { true }
- allow(suggestion.position).to receive(:head_sha) { 'old-sha' }
- allow(suggestion.noteable).to receive(:source_branch_sha) { 'new-sha' }
+ allow(suggestion.position).to receive(:head_sha) { "old-sha" }
+ allow(suggestion.noteable).to receive(:source_branch_sha) { "new-sha" }
result = subject.execute(suggestion)
- expect(result).to eq(message: 'The file has been changed', status: :error)
+ expect(result).to eq(message: "The file has been changed", status: :error)
end
end
- context 'multiple suggestions applied' do
+ context "multiple suggestions applied" do
let(:expected_content) do
<<-CONTENT.strip_heredoc
require 'fileutils'
@@ -219,8 +219,8 @@ describe Suggestions::ApplyService do
result = subject.execute(suggestion)
refresh = MergeRequests::RefreshService.new(project, user)
refresh.execute(merge_request.diff_head_sha,
- suggestion.commit_id,
- merge_request.source_branch_ref)
+ suggestion.commit_id,
+ merge_request.source_branch_ref)
result
end
@@ -229,21 +229,21 @@ describe Suggestions::ApplyService do
project.reload.commit(suggestion.commit_id).diffs.diff_files.first.diff.diff
end
- it 'applies multiple suggestions in subsequent versions correctly' do
+ it "applies multiple suggestions in subsequent versions correctly" do
diff = merge_request.merge_request_diff
- path = 'files/ruby/popen.rb'
+ path = "files/ruby/popen.rb"
- suggestion_1_changes = { old_line: nil,
- new_line: 13,
- from_content: "\n",
- to_content: "# v1 change\n",
- path: path }
+ suggestion_1_changes = {old_line: nil,
+ new_line: 13,
+ from_content: "\n",
+ to_content: "# v1 change\n",
+ path: path,}
- suggestion_2_changes = { old_line: 24,
- new_line: 31,
- from_content: " @cmd_output << stderr.read\n",
- to_content: "# v2 change\n",
- path: path }
+ suggestion_2_changes = {old_line: 24,
+ new_line: 31,
+ from_content: " @cmd_output << stderr.read\n",
+ to_content: "# v2 change\n",
+ path: path,}
suggestion_1 = create_suggestion(diff, suggestion_1_changes)
suggestion_2 = create_suggestion(diff, suggestion_2_changes)
@@ -289,7 +289,7 @@ describe Suggestions::ApplyService do
end
end
- context 'fork-project' do
+ context "fork-project" do
let(:project) { create(:project, :public, :repository) }
let(:forked_project) do
@@ -298,8 +298,8 @@ describe Suggestions::ApplyService do
let(:merge_request) do
create(:merge_request,
- source_branch: 'conflict-resolvable-fork', source_project: forked_project,
- target_branch: 'conflict-start', target_project: project)
+ source_branch: "conflict-resolvable-fork", source_project: forked_project,
+ target_branch: "conflict-start", target_project: project)
end
let!(:diff_note) do
@@ -310,7 +310,7 @@ describe Suggestions::ApplyService do
project.add_maintainer(user)
end
- it 'updates file in the source project' do
+ it "updates file in the source project" do
expect(Files::UpdateService).to receive(:new)
.with(merge_request.source_project, user, anything)
.and_call_original
@@ -320,7 +320,7 @@ describe Suggestions::ApplyService do
end
end
- context 'no permission' do
+ context "no permission" do
let(:merge_request) do
create(:merge_request, source_project: project,
target_project: project)
@@ -332,12 +332,12 @@ describe Suggestions::ApplyService do
project: project)
end
- context 'user cannot write in project repo' do
+ context "user cannot write in project repo" do
before do
project.add_reporter(user)
end
- it 'returns error' do
+ it "returns error" do
result = subject.execute(suggestion)
expect(result).to eq(message: "You are not allowed to push into this branch",
@@ -346,7 +346,7 @@ describe Suggestions::ApplyService do
end
end
- context 'patch is not appliable' do
+ context "patch is not appliable" do
let(:merge_request) do
create(:merge_request, source_project: project,
target_project: project)
@@ -362,47 +362,47 @@ describe Suggestions::ApplyService do
project.add_maintainer(user)
end
- context 'diff file was not found' do
- it 'returns error message' do
+ context "diff file was not found" do
+ it "returns error message" do
expect(suggestion.note).to receive(:latest_diff_file) { nil }
result = subject.execute(suggestion)
- expect(result).to eq(message: 'The file was not found',
+ expect(result).to eq(message: "The file was not found",
status: :error)
end
end
- context 'suggestion was already applied' do
- it 'returns success status' do
+ context "suggestion was already applied" do
+ it "returns success status" do
result = subject.execute(suggestion)
expect(result[:status]).to eq(:success)
end
end
- context 'note is outdated' do
+ context "note is outdated" do
before do
allow(diff_note).to receive(:active?) { false }
end
- it 'returns error message' do
+ it "returns error message" do
result = subject.execute(suggestion)
- expect(result).to eq(message: 'Suggestion is not appliable',
+ expect(result).to eq(message: "Suggestion is not appliable",
status: :error)
end
end
- context 'suggestion was already applied' do
+ context "suggestion was already applied" do
before do
- suggestion.update!(applied: true, commit_id: 'sha')
+ suggestion.update!(applied: true, commit_id: "sha")
end
- it 'returns error message' do
+ it "returns error message" do
result = subject.execute(suggestion)
- expect(result).to eq(message: 'Suggestion is not appliable',
+ expect(result).to eq(message: "Suggestion is not appliable",
status: :error)
end
end
diff --git a/spec/services/suggestions/create_service_spec.rb b/spec/services/suggestions/create_service_spec.rb
index 1b4b15b8eaa..3265f34f69f 100644
--- a/spec/services/suggestions/create_service_spec.rb
+++ b/spec/services/suggestions/create_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Suggestions::CreateService do
let(:project_with_repo) { create(:project, :repository) }
@@ -10,11 +10,11 @@ describe Suggestions::CreateService do
end
def build_position(args = {})
- default_args = { old_path: "files/ruby/popen.rb",
- new_path: "files/ruby/popen.rb",
- old_line: nil,
- new_line: 14,
- diff_refs: merge_request.diff_refs }
+ default_args = {old_path: "files/ruby/popen.rb",
+ new_path: "files/ruby/popen.rb",
+ old_line: nil,
+ new_line: 14,
+ diff_refs: merge_request.diff_refs,}
Gitlab::Diff::Position.new(default_args.merge(args))
end
@@ -45,22 +45,22 @@ describe Suggestions::CreateService do
subject { described_class.new(note) }
- describe '#execute' do
- context 'should not try to parse suggestions' do
- context 'when not a diff note for merge requests' do
+ describe "#execute" do
+ context "should not try to parse suggestions" do
+ context "when not a diff note for merge requests" do
let(:note) do
create(:diff_note_on_commit, project: project_with_repo,
note: markdown)
end
- it 'does not try to parse suggestions' do
+ it "does not try to parse suggestions" do
expect(Banzai::SuggestionsParser).not_to receive(:parse)
subject.execute
end
end
- context 'when diff note is not for text' do
+ context "when diff note is not for text" do
let(:note) do
create(:diff_note_on_merge_request, project: project_with_repo,
noteable: merge_request,
@@ -68,7 +68,7 @@ describe Suggestions::CreateService do
note: markdown)
end
- it 'does not try to parse suggestions' do
+ it "does not try to parse suggestions" do
allow(note).to receive(:on_text?) { false }
expect(Banzai::SuggestionsParser).not_to receive(:parse)
@@ -78,7 +78,7 @@ describe Suggestions::CreateService do
end
end
- context 'should not create suggestions' do
+ context "should not create suggestions" do
let(:note) do
create(:diff_note_on_merge_request, project: project_with_repo,
noteable: merge_request,
@@ -86,14 +86,14 @@ describe Suggestions::CreateService do
note: markdown)
end
- it 'creates no suggestion when diff file is not found' do
+ it "creates no suggestion when diff file is not found" do
expect(note).to receive(:latest_diff_file) { nil }
expect { subject.execute }.not_to change(Suggestion, :count)
end
end
- context 'should create suggestions' do
+ context "should create suggestions" do
let(:note) do
create(:diff_note_on_merge_request, project: project_with_repo,
noteable: merge_request,
@@ -101,15 +101,15 @@ describe Suggestions::CreateService do
note: markdown)
end
- context 'single line suggestions' do
- it 'persists suggestion records' do
+ context "single line suggestions" do
+ it "persists suggestion records" do
expect { subject.execute }
.to change { note.suggestions.count }
.from(0)
.to(2)
end
- it 'persists original from_content lines and suggested lines' do
+ it "persists original from_content lines and suggested lines" do
subject.execute
suggestions = note.suggestions.order(:relative_order)
@@ -124,13 +124,13 @@ describe Suggestions::CreateService do
to_content: " xpto\n baz\n")
end
- context 'outdated position note' do
+ context "outdated position note" do
let!(:outdated_diff) { merge_request.merge_request_diff }
let!(:latest_diff) { merge_request.create_merge_request_diff }
let(:outdated_position) { build_position(diff_refs: outdated_diff.diff_refs) }
let(:position) { build_position(diff_refs: latest_diff.diff_refs) }
- it 'uses the correct position when creating the suggestion' do
+ it "uses the correct position when creating the suggestion" do
expect(note.position)
.to receive(:diff_file)
.with(project_with_repo.repository)
diff --git a/spec/services/system_hooks_service_spec.rb b/spec/services/system_hooks_service_spec.rb
index 81b2c17fdb5..f6c0af71f15 100644
--- a/spec/services/system_hooks_service_spec.rb
+++ b/spec/services/system_hooks_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemHooksService do
let(:user) { create(:user) }
@@ -9,7 +9,7 @@ describe SystemHooksService do
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
- context 'event data' do
+ context "event data" do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
it { expect(event_data(user, :destroy)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
it { expect(event_data(project, :create)).to include(:event_name, :name, :created_at, :updated_at, :path, :project_id, :owner_name, :owner_email, :project_visibility) }
@@ -23,7 +23,7 @@ describe SystemHooksService do
it { expect(event_data(deploy_key, :destroy)).to include(:key, :id) }
it do
- project.old_path_with_namespace = 'renamed_from_path'
+ project.old_path_with_namespace = "renamed_from_path"
expect(event_data(project, :rename)).to include(
:event_name, :name, :created_at, :updated_at, :path, :project_id,
:owner_name, :owner_email, :project_visibility,
@@ -32,7 +32,7 @@ describe SystemHooksService do
end
it do
- project.old_path_with_namespace = 'transferred_from_path'
+ project.old_path_with_namespace = "transferred_from_path"
expect(event_data(project, :transfer)).to include(
:event_name, :name, :created_at, :updated_at, :path, :project_id,
:owner_name, :owner_email, :project_visibility,
@@ -68,13 +68,13 @@ describe SystemHooksService do
)
end
- it 'includes the correct project visibility level' do
+ it "includes the correct project visibility level" do
data = event_data(project, :create)
- expect(data[:project_visibility]).to eq('private')
+ expect(data[:project_visibility]).to eq("private")
end
- it 'handles nil datetime columns' do
+ it "handles nil datetime columns" do
user.update(created_at: nil, updated_at: nil)
data = event_data(user, :destroy)
@@ -82,9 +82,9 @@ describe SystemHooksService do
expect(data[:updated_at]).to be(nil)
end
- context 'group_rename' do
- it 'contains old and new path' do
- allow(group).to receive(:path_was).and_return('old-path')
+ context "group_rename" do
+ it "contains old and new path" do
+ allow(group).to receive(:path_was).and_return("old-path")
data = event_data(group, :rename)
@@ -95,20 +95,20 @@ describe SystemHooksService do
expect(data[:old_full_path]).to eq(group.path_was)
end
- it 'contains old and new full_path for subgroup' do
+ it "contains old and new full_path for subgroup" do
subgroup = create(:group, parent: group)
- allow(subgroup).to receive(:path_was).and_return('old-path')
+ allow(subgroup).to receive(:path_was).and_return("old-path")
data = event_data(subgroup, :rename)
expect(data[:full_path]).to eq(subgroup.full_path)
- expect(data[:old_path]).to eq('old-path')
+ expect(data[:old_path]).to eq("old-path")
end
end
- context 'user_rename' do
- it 'contains old and new username' do
- allow(user).to receive(:username_was).and_return('old-username')
+ context "user_rename" do
+ it "contains old and new username" do
+ allow(user).to receive(:username_was).and_return("old-username")
data = event_data(user, :rename)
@@ -118,24 +118,24 @@ describe SystemHooksService do
end
end
- context 'user_failed_login' do
- it 'contains state of user' do
+ context "user_failed_login" do
+ it "contains state of user" do
user.ldap_block!
data = event_data(user, :failed_login)
expect(data).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username, :state)
expect(data[:username]).to eq(user.username)
- expect(data[:state]).to eq('ldap_blocked')
+ expect(data[:state]).to eq("ldap_blocked")
end
end
end
- context 'event names' do
+ context "event names" do
it { expect(event_name(user, :create)).to eq "user_create" }
it { expect(event_name(user, :destroy)).to eq "user_destroy" }
- it { expect(event_name(user, :rename)).to eq 'user_rename' }
- it { expect(event_name(user, :failed_login)).to eq 'user_failed_login' }
+ it { expect(event_name(user, :rename)).to eq "user_rename" }
+ it { expect(event_name(user, :failed_login)).to eq "user_failed_login" }
it { expect(event_name(project, :create)).to eq "project_create" }
it { expect(event_name(project, :destroy)).to eq "project_destroy" }
it { expect(event_name(project, :rename)).to eq "project_rename" }
@@ -143,13 +143,13 @@ describe SystemHooksService do
it { expect(event_name(project, :update)).to eq "project_update" }
it { expect(event_name(project_member, :create)).to eq "user_add_to_team" }
it { expect(event_name(project_member, :destroy)).to eq "user_remove_from_team" }
- it { expect(event_name(key, :create)).to eq 'key_create' }
- it { expect(event_name(key, :destroy)).to eq 'key_destroy' }
- it { expect(event_name(group, :create)).to eq 'group_create' }
- it { expect(event_name(group, :destroy)).to eq 'group_destroy' }
- it { expect(event_name(group, :rename)).to eq 'group_rename' }
- it { expect(event_name(group_member, :create)).to eq 'user_add_to_group' }
- it { expect(event_name(group_member, :destroy)).to eq 'user_remove_from_group' }
+ it { expect(event_name(key, :create)).to eq "key_create" }
+ it { expect(event_name(key, :destroy)).to eq "key_destroy" }
+ it { expect(event_name(group, :create)).to eq "group_create" }
+ it { expect(event_name(group, :destroy)).to eq "group_destroy" }
+ it { expect(event_name(group, :rename)).to eq "group_rename" }
+ it { expect(event_name(group_member, :create)).to eq "user_add_to_group" }
+ it { expect(event_name(group_member, :destroy)).to eq "user_remove_from_group" }
end
def event_data(*args)
diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb
index b917de14b2e..b8d2c37186e 100644
--- a/spec/services/system_note_service_spec.rb
+++ b/spec/services/system_note_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemNoteService do
include Gitlab::Routing
@@ -11,11 +11,11 @@ describe SystemNoteService do
let(:noteable) { create(:issue, project: project) }
let(:issue) { noteable }
- shared_examples_for 'a system note' do
+ shared_examples_for "a system note" do
let(:expected_noteable) { noteable }
let(:commit_count) { nil }
- it 'has the correct attributes', :aggregate_failures do
+ it "has the correct attributes", :aggregate_failures do
expect(subject).to be_valid
expect(subject).to be_system
@@ -28,7 +28,7 @@ describe SystemNoteService do
end
end
- describe '.add_commits' do
+ describe ".add_commits" do
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
@@ -36,26 +36,26 @@ describe SystemNoteService do
let(:old_commits) { [] }
let(:oldrev) { nil }
- it_behaves_like 'a system note' do
+ it_behaves_like "a system note" do
let(:commit_count) { new_commits.size }
- let(:action) { 'commit' }
+ let(:action) { "commit" }
end
- describe 'note body' do
+ describe "note body" do
let(:note_lines) { subject.note.split("\n").reject(&:blank?) }
- describe 'comparison diff link line' do
- it 'adds the comparison text' do
+ describe "comparison diff link line" do
+ it "adds the comparison text" do
expect(note_lines[2]).to match "[Compare with previous version]"
end
end
- context 'without existing commits' do
- it 'adds a message header' do
+ context "without existing commits" do
+ it "adds a message header" do
expect(note_lines[0]).to eq "added #{new_commits.size} commits"
end
- it 'adds a message for each commit' do
+ it "adds a message for each commit" do
decoded_note_content = HTMLEntities.new.decode(subject.note)
new_commits.each do |commit|
@@ -64,42 +64,42 @@ describe SystemNoteService do
end
end
- describe 'summary line for existing commits' do
+ describe "summary line for existing commits" do
let(:summary_line) { note_lines[1] }
- context 'with one existing commit' do
+ context "with one existing commit" do
let(:old_commits) { [noteable.commits.last] }
- it 'includes the existing commit' do
+ it "includes the existing commit" do
expect(summary_line).to start_with("<ul><li>#{old_commits.first.short_id} - 1 commit from branch <code>feature</code>")
end
end
- context 'with multiple existing commits' do
+ context "with multiple existing commits" do
let(:old_commits) { noteable.commits[3..-1] }
- context 'with oldrev' do
+ context "with oldrev" do
let(:oldrev) { noteable.commits[2].id }
- it 'includes a commit range and count' do
+ it "includes a commit range and count" do
expect(summary_line)
.to start_with("<ul><li>#{Commit.truncate_sha(oldrev)}...#{old_commits.last.short_id} - 26 commits from branch <code>feature</code>")
end
end
- context 'without oldrev' do
- it 'includes a commit range and count' do
+ context "without oldrev" do
+ it "includes a commit range and count" do
expect(summary_line)
.to start_with("<ul><li>#{old_commits[0].short_id}..#{old_commits[-1].short_id} - 26 commits from branch <code>feature</code>")
end
end
- context 'on a fork' do
+ context "on a fork" do
before do
expect(noteable).to receive(:for_fork?).and_return(true)
end
- it 'includes the project namespace' do
+ it "includes the project namespace" do
expect(summary_line).to include("<code>#{noteable.target_project_namespace}:feature</code>")
end
end
@@ -108,50 +108,50 @@ describe SystemNoteService do
end
end
- describe '.tag_commit' do
+ describe ".tag_commit" do
let(:noteable) do
project.commit
end
- let(:tag_name) { 'v1.2.3' }
+ let(:tag_name) { "v1.2.3" }
subject { described_class.tag_commit(noteable, project, author, tag_name) }
- it_behaves_like 'a system note' do
- let(:action) { 'tag' }
+ it_behaves_like "a system note" do
+ let(:action) { "tag" }
end
- it 'sets the note text' do
+ it "sets the note text" do
link = "http://localhost/#{project.full_path}/tags/#{tag_name}"
expect(subject.note).to eq "tagged commit #{noteable.sha} to [`#{tag_name}`](#{link})"
end
end
- describe '.change_assignee' do
+ describe ".change_assignee" do
subject { described_class.change_assignee(noteable, project, author, assignee) }
let(:assignee) { create(:user) }
- it_behaves_like 'a system note' do
- let(:action) { 'assignee' }
+ it_behaves_like "a system note" do
+ let(:action) { "assignee" }
end
- context 'when assignee added' do
- it 'sets the note text' do
+ context "when assignee added" do
+ it "sets the note text" do
expect(subject.note).to eq "assigned to @#{assignee.username}"
end
end
- context 'when assignee removed' do
+ context "when assignee removed" do
let(:assignee) { nil }
- it 'sets the note text' do
- expect(subject.note).to eq 'removed assignee'
+ it "sets the note text" do
+ expect(subject.note).to eq "removed assignee"
end
end
end
- describe '.change_issue_assignees' do
+ describe ".change_issue_assignees" do
subject { described_class.change_issue_assignees(noteable, project, author, [assignee]) }
let(:assignee) { create(:user) }
@@ -159,8 +159,8 @@ describe SystemNoteService do
let(:assignee2) { create(:user) }
let(:assignee3) { create(:user) }
- it_behaves_like 'a system note' do
- let(:action) { 'assignee' }
+ it_behaves_like "a system note" do
+ let(:action) { "assignee" }
end
def build_note(old_assignees, new_assignees)
@@ -168,143 +168,143 @@ describe SystemNoteService do
described_class.change_issue_assignees(issue, project, author, old_assignees).note
end
- it 'builds a correct phrase when an assignee is added to a non-assigned issue' do
+ it "builds a correct phrase when an assignee is added to a non-assigned issue" do
expect(build_note([], [assignee1])).to eq "assigned to @#{assignee1.username}"
end
- it 'builds a correct phrase when assignee removed' do
+ it "builds a correct phrase when assignee removed" do
expect(build_note([assignee1], [])).to eq "unassigned @#{assignee1.username}"
end
- it 'builds a correct phrase when assignees changed' do
+ it "builds a correct phrase when assignees changed" do
expect(build_note([assignee1], [assignee2])).to eq \
"assigned to @#{assignee2.username} and unassigned @#{assignee1.username}"
end
- it 'builds a correct phrase when three assignees removed and one added' do
+ it "builds a correct phrase when three assignees removed and one added" do
expect(build_note([assignee, assignee1, assignee2], [assignee3])).to eq \
"assigned to @#{assignee3.username} and unassigned @#{assignee.username}, @#{assignee1.username}, and @#{assignee2.username}"
end
- it 'builds a correct phrase when one assignee changed from a set' do
+ it "builds a correct phrase when one assignee changed from a set" do
expect(build_note([assignee, assignee1], [assignee, assignee2])).to eq \
"assigned to @#{assignee2.username} and unassigned @#{assignee1.username}"
end
- it 'builds a correct phrase when one assignee removed from a set' do
+ it "builds a correct phrase when one assignee removed from a set" do
expect(build_note([assignee, assignee1, assignee2], [assignee, assignee1])).to eq \
"unassigned @#{assignee2.username}"
end
end
- describe '.change_milestone' do
- context 'for a project milestone' do
+ describe ".change_milestone" do
+ context "for a project milestone" do
subject { described_class.change_milestone(noteable, project, author, milestone) }
let(:milestone) { create(:milestone, project: project) }
- it_behaves_like 'a system note' do
- let(:action) { 'milestone' }
+ it_behaves_like "a system note" do
+ let(:action) { "milestone" }
end
- context 'when milestone added' do
- it 'sets the note text' do
+ context "when milestone added" do
+ it "sets the note text" do
reference = milestone.to_reference(format: :iid)
expect(subject.note).to eq "changed milestone to #{reference}"
end
end
- context 'when milestone removed' do
+ context "when milestone removed" do
let(:milestone) { nil }
- it 'sets the note text' do
- expect(subject.note).to eq 'removed milestone'
+ it "sets the note text" do
+ expect(subject.note).to eq "removed milestone"
end
end
end
- context 'for a group milestone' do
+ context "for a group milestone" do
subject { described_class.change_milestone(noteable, project, author, milestone) }
let(:milestone) { create(:milestone, group: group) }
- it_behaves_like 'a system note' do
- let(:action) { 'milestone' }
+ it_behaves_like "a system note" do
+ let(:action) { "milestone" }
end
- context 'when milestone added' do
- it 'sets the note text to use the milestone name' do
+ context "when milestone added" do
+ it "sets the note text to use the milestone name" do
expect(subject.note).to eq "changed milestone to #{milestone.to_reference(format: :name)}"
end
end
- context 'when milestone removed' do
+ context "when milestone removed" do
let(:milestone) { nil }
- it 'sets the note text' do
- expect(subject.note).to eq 'removed milestone'
+ it "sets the note text" do
+ expect(subject.note).to eq "removed milestone"
end
end
end
end
- describe '.change_due_date' do
+ describe ".change_due_date" do
subject { described_class.change_due_date(noteable, project, author, due_date) }
let(:due_date) { Date.today }
- it_behaves_like 'a system note' do
- let(:action) { 'due_date' }
+ it_behaves_like "a system note" do
+ let(:action) { "due_date" }
end
- context 'when due date added' do
- it 'sets the note text' do
+ context "when due date added" do
+ it "sets the note text" do
expect(subject.note).to eq "changed due date to #{Date.today.to_s(:long)}"
end
end
- context 'when due date removed' do
+ context "when due date removed" do
let(:due_date) { nil }
- it 'sets the note text' do
- expect(subject.note).to eq 'removed due date'
+ it "sets the note text" do
+ expect(subject.note).to eq "removed due date"
end
end
end
- describe '.change_status' do
+ describe ".change_status" do
subject { described_class.change_status(noteable, project, author, status, source) }
- context 'with status reopened' do
- let(:status) { 'reopened' }
+ context "with status reopened" do
+ let(:status) { "reopened" }
let(:source) { nil }
- it_behaves_like 'a system note' do
- let(:action) { 'opened' }
+ it_behaves_like "a system note" do
+ let(:action) { "opened" }
end
end
- context 'with a source' do
- let(:status) { 'opened' }
- let(:source) { double('commit', gfm_reference: 'commit 123456') }
+ context "with a source" do
+ let(:status) { "opened" }
+ let(:source) { double("commit", gfm_reference: "commit 123456") }
- it 'sets the note text' do
+ it "sets the note text" do
expect(subject.note).to eq "#{status} via commit 123456"
end
end
end
- describe '.merge_when_pipeline_succeeds' do
- let(:pipeline) { build(:ci_pipeline_without_jobs )}
+ describe ".merge_when_pipeline_succeeds" do
+ let(:pipeline) { build(:ci_pipeline_without_jobs)}
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
subject { described_class.merge_when_pipeline_succeeds(noteable, project, author, noteable.diff_head_commit) }
- it_behaves_like 'a system note' do
- let(:action) { 'merge' }
+ it_behaves_like "a system note" do
+ let(:action) { "merge" }
end
it "posts the 'merge when pipeline succeeds' system note" do
@@ -312,15 +312,15 @@ describe SystemNoteService do
end
end
- describe '.cancel_merge_when_pipeline_succeeds' do
+ describe ".cancel_merge_when_pipeline_succeeds" do
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
subject { described_class.cancel_merge_when_pipeline_succeeds(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'merge' }
+ it_behaves_like "a system note" do
+ let(:action) { "merge" }
end
it "posts the 'merge when pipeline succeeds' system note" do
@@ -328,187 +328,187 @@ describe SystemNoteService do
end
end
- describe '.change_title' do
- let(:noteable) { create(:issue, project: project, title: 'Lorem ipsum') }
+ describe ".change_title" do
+ let(:noteable) { create(:issue, project: project, title: "Lorem ipsum") }
- subject { described_class.change_title(noteable, project, author, 'Old title') }
+ subject { described_class.change_title(noteable, project, author, "Old title") }
- context 'when noteable responds to `title`' do
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
+ context "when noteable responds to `title`" do
+ it_behaves_like "a system note" do
+ let(:action) { "title" }
end
- it 'sets the note text' do
+ it "sets the note text" do
expect(subject.note)
.to eq "changed title from **{-Old title-}** to **{+Lorem ipsum+}**"
end
end
end
- describe '.change_description' do
+ describe ".change_description" do
subject { described_class.change_description(noteable, project, author) }
- context 'when noteable responds to `description`' do
- it_behaves_like 'a system note' do
- let(:action) { 'description' }
+ context "when noteable responds to `description`" do
+ it_behaves_like "a system note" do
+ let(:action) { "description" }
end
- it 'sets the note text' do
- expect(subject.note).to eq('changed the description')
+ it "sets the note text" do
+ expect(subject.note).to eq("changed the description")
end
end
end
- describe '.change_issue_confidentiality' do
+ describe ".change_issue_confidentiality" do
subject { described_class.change_issue_confidentiality(noteable, project, author) }
- context 'issue has been made confidential' do
+ context "issue has been made confidential" do
before do
noteable.update_attribute(:confidential, true)
end
- it_behaves_like 'a system note' do
- let(:action) { 'confidential' }
+ it_behaves_like "a system note" do
+ let(:action) { "confidential" }
end
- it 'sets the note text' do
- expect(subject.note).to eq 'made the issue confidential'
+ it "sets the note text" do
+ expect(subject.note).to eq "made the issue confidential"
end
end
- context 'issue has been made visible' do
- it_behaves_like 'a system note' do
- let(:action) { 'visible' }
+ context "issue has been made visible" do
+ it_behaves_like "a system note" do
+ let(:action) { "visible" }
end
- it 'sets the note text' do
- expect(subject.note).to eq 'made the issue visible to everyone'
+ it "sets the note text" do
+ expect(subject.note).to eq "made the issue visible to everyone"
end
end
end
- describe '.change_branch' do
- subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
+ describe ".change_branch" do
+ subject { described_class.change_branch(noteable, project, author, "target", old_branch, new_branch) }
- let(:old_branch) { 'old_branch'}
- let(:new_branch) { 'new_branch'}
+ let(:old_branch) { "old_branch"}
+ let(:new_branch) { "new_branch"}
- it_behaves_like 'a system note' do
- let(:action) { 'branch' }
+ it_behaves_like "a system note" do
+ let(:action) { "branch" }
end
- context 'when target branch name changed' do
- it 'sets the note text' do
+ context "when target branch name changed" do
+ it "sets the note text" do
expect(subject.note).to eq "changed target branch from `#{old_branch}` to `#{new_branch}`"
end
end
end
- describe '.change_branch_presence' do
- subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
+ describe ".change_branch_presence" do
+ subject { described_class.change_branch_presence(noteable, project, author, :source, "feature", :delete) }
- it_behaves_like 'a system note' do
- let(:action) { 'branch' }
+ it_behaves_like "a system note" do
+ let(:action) { "branch" }
end
- context 'when source branch deleted' do
- it 'sets the note text' do
+ context "when source branch deleted" do
+ it "sets the note text" do
expect(subject.note).to eq "deleted source branch `feature`"
end
end
end
- describe '.new_issue_branch' do
+ describe ".new_issue_branch" do
subject { described_class.new_issue_branch(noteable, project, author, "1-mepmep") }
- it_behaves_like 'a system note' do
- let(:action) { 'branch' }
+ it_behaves_like "a system note" do
+ let(:action) { "branch" }
end
- context 'when a branch is created from the new branch button' do
- it 'sets the note text' do
+ context "when a branch is created from the new branch button" do
+ it "sets the note text" do
expect(subject.note).to start_with("created branch [`1-mepmep`]")
end
end
end
- describe '.new_merge_request' do
+ describe ".new_merge_request" do
subject { described_class.new_merge_request(noteable, project, author, merge_request) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
- it_behaves_like 'a system note' do
- let(:action) { 'merge' }
+ it_behaves_like "a system note" do
+ let(:action) { "merge" }
end
- it 'sets the new merge request note text' do
+ it "sets the new merge request note text" do
expect(subject.note).to eq("created merge request #{merge_request.to_reference} to address this issue")
end
end
- describe '.cross_reference' do
+ describe ".cross_reference" do
subject { described_class.cross_reference(noteable, mentioner, author) }
let(:mentioner) { create(:issue, project: project) }
- it_behaves_like 'a system note' do
- let(:action) { 'cross_reference' }
+ it_behaves_like "a system note" do
+ let(:action) { "cross_reference" }
end
- context 'when cross-reference disallowed' do
+ context "when cross-reference disallowed" do
before do
expect(described_class).to receive(:cross_reference_disallowed?).and_return(true)
end
- it 'returns nil' do
+ it "returns nil" do
expect(subject).to be_nil
end
- it 'does not create a system note metadata record' do
+ it "does not create a system note metadata record" do
expect { subject }.not_to change { SystemNoteMetadata.count }
end
end
- context 'when cross-reference allowed' do
+ context "when cross-reference allowed" do
before do
expect(described_class).to receive(:cross_reference_disallowed?).and_return(false)
end
- it_behaves_like 'a system note' do
- let(:action) { 'cross_reference' }
+ it_behaves_like "a system note" do
+ let(:action) { "cross_reference" }
end
- describe 'note_body' do
- context 'cross-project' do
+ describe "note_body" do
+ context "cross-project" do
let(:project2) { create(:project, :repository) }
let(:mentioner) { create(:issue, project: project2) }
- context 'from Commit' do
+ context "from Commit" do
let(:mentioner) { project2.repository.commit }
- it 'references the mentioning commit' do
+ it "references the mentioning commit" do
expect(subject.note).to eq "mentioned in commit #{mentioner.to_reference(project)}"
end
end
- context 'from non-Commit' do
- it 'references the mentioning object' do
+ context "from non-Commit" do
+ it "references the mentioning object" do
expect(subject.note).to eq "mentioned in issue #{mentioner.to_reference(project)}"
end
end
end
- context 'within the same project' do
- context 'from Commit' do
+ context "within the same project" do
+ context "from Commit" do
let(:mentioner) { project.repository.commit }
- it 'references the mentioning commit' do
+ it "references the mentioning commit" do
expect(subject.note).to eq "mentioned in commit #{mentioner.to_reference}"
end
end
- context 'from non-Commit' do
- it 'references the mentioning object' do
+ context "from non-Commit" do
+ it "references the mentioning object" do
expect(subject.note).to eq "mentioned in issue #{mentioner.to_reference}"
end
end
@@ -517,35 +517,35 @@ describe SystemNoteService do
end
end
- describe '.cross_reference_disallowed?' do
- context 'when mentioner is not a MergeRequest' do
- it 'is falsey' do
+ describe ".cross_reference_disallowed?" do
+ context "when mentioner is not a MergeRequest" do
+ it "is falsey" do
mentioner = noteable.dup
expect(described_class.cross_reference_disallowed?(noteable, mentioner))
.to be_falsey
end
end
- context 'when mentioner is a MergeRequest' do
+ context "when mentioner is a MergeRequest" do
let(:mentioner) { create(:merge_request, :simple, source_project: project) }
let(:noteable) { project.commit }
- it 'is truthy when noteable is in commits' do
+ it "is truthy when noteable is in commits" do
expect(mentioner).to receive(:commits).and_return([noteable])
expect(described_class.cross_reference_disallowed?(noteable, mentioner))
.to be_truthy
end
- it 'is falsey when noteable is not in commits' do
+ it "is falsey when noteable is not in commits" do
expect(mentioner).to receive(:commits).and_return([])
expect(described_class.cross_reference_disallowed?(noteable, mentioner))
.to be_falsey
end
end
- context 'when notable is an ExternalIssue' do
- let(:noteable) { ExternalIssue.new('EXT-1234', project) }
- it 'is truthy' do
+ context "when notable is an ExternalIssue" do
+ let(:noteable) { ExternalIssue.new("EXT-1234", project) }
+ it "is truthy" do
mentioner = noteable.dup
expect(described_class.cross_reference_disallowed?(noteable, mentioner))
.to be_truthy
@@ -553,71 +553,71 @@ describe SystemNoteService do
end
end
- describe '.cross_reference_exists?' do
+ describe ".cross_reference_exists?" do
let(:commit0) { project.commit }
- let(:commit1) { project.commit('HEAD~2') }
+ let(:commit1) { project.commit("HEAD~2") }
- context 'issue from commit' do
+ context "issue from commit" do
before do
# Mention issue (noteable) from commit0
described_class.cross_reference(noteable, commit0, author)
end
- it 'is truthy when already mentioned' do
+ it "is truthy when already mentioned" do
expect(described_class.cross_reference_exists?(noteable, commit0))
.to be_truthy
end
- it 'is falsey when not already mentioned' do
+ it "is falsey when not already mentioned" do
expect(described_class.cross_reference_exists?(noteable, commit1))
.to be_falsey
end
- context 'legacy capitalized cross reference' do
+ context "legacy capitalized cross reference" do
before do
# Mention issue (noteable) from commit0
system_note = described_class.cross_reference(noteable, commit0, author)
system_note.update(note: system_note.note.capitalize)
end
- it 'is truthy when already mentioned' do
+ it "is truthy when already mentioned" do
expect(described_class.cross_reference_exists?(noteable, commit0))
.to be_truthy
end
end
end
- context 'commit from commit' do
+ context "commit from commit" do
before do
# Mention commit1 from commit0
described_class.cross_reference(commit0, commit1, author)
end
- it 'is truthy when already mentioned' do
+ it "is truthy when already mentioned" do
expect(described_class.cross_reference_exists?(commit0, commit1))
.to be_truthy
end
- it 'is falsey when not already mentioned' do
+ it "is falsey when not already mentioned" do
expect(described_class.cross_reference_exists?(commit1, commit0))
.to be_falsey
end
- context 'legacy capitalized cross reference' do
+ context "legacy capitalized cross reference" do
before do
# Mention commit1 from commit0
system_note = described_class.cross_reference(commit0, commit1, author)
system_note.update(note: system_note.note.capitalize)
end
- it 'is truthy when already mentioned' do
+ it "is truthy when already mentioned" do
expect(described_class.cross_reference_exists?(commit0, commit1))
.to be_truthy
end
end
end
- context 'commit with cross-reference from fork' do
+ context "commit with cross-reference from fork" do
let(:author2) { create(:project_member, :reporter, user: create(:user), project: project).user }
let(:forked_project) { Projects::ForkService.new(project, author2).execute }
let(:commit2) { forked_project.commit }
@@ -626,26 +626,26 @@ describe SystemNoteService do
described_class.cross_reference(noteable, commit0, author2)
end
- it 'is true when a fork mentions an external issue' do
+ it "is true when a fork mentions an external issue" do
expect(described_class.cross_reference_exists?(noteable, commit2))
- .to be true
+ .to be true
end
- context 'legacy capitalized cross reference' do
+ context "legacy capitalized cross reference" do
before do
system_note = described_class.cross_reference(noteable, commit0, author2)
system_note.update(note: system_note.note.capitalize)
end
- it 'is true when a fork mentions an external issue' do
+ it "is true when a fork mentions an external issue" do
expect(described_class.cross_reference_exists?(noteable, commit2))
- .to be true
+ .to be true
end
end
end
end
- describe '.noteable_moved' do
+ describe ".noteable_moved" do
let(:new_project) { create(:project) }
let(:new_noteable) { create(:issue, project: new_project) }
@@ -653,67 +653,67 @@ describe SystemNoteService do
described_class.noteable_moved(noteable, project, new_noteable, author, direction: direction)
end
- shared_examples 'cross project mentionable' do
+ shared_examples "cross project mentionable" do
include MarkupHelper
- it 'contains 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 'mentions referenced noteable' do
+ it "mentions referenced noteable" do
expect(subject.note).to include new_noteable.to_reference
end
- it 'mentions referenced project' do
+ it "mentions referenced project" do
expect(subject.note).to include new_project.full_path
end
end
- context 'moved to' do
+ context "moved to" do
let(:direction) { :to }
- it_behaves_like 'cross project mentionable'
- it_behaves_like 'a system note' do
- let(:action) { 'moved' }
+ it_behaves_like "cross project mentionable"
+ it_behaves_like "a system note" do
+ let(:action) { "moved" }
end
- it 'notifies about noteable being moved to' do
- expect(subject.note).to match('moved to')
+ it "notifies about noteable being moved to" do
+ expect(subject.note).to match("moved to")
end
end
- context 'moved from' do
+ context "moved from" do
let(:direction) { :from }
- it_behaves_like 'cross project mentionable'
- it_behaves_like 'a system note' do
- let(:action) { 'moved' }
+ it_behaves_like "cross project mentionable"
+ it_behaves_like "a system note" do
+ let(:action) { "moved" }
end
- it 'notifies about noteable being moved from' do
- expect(subject.note).to match('moved from')
+ it "notifies about noteable being moved from" do
+ expect(subject.note).to match("moved from")
end
end
- context 'invalid direction' do
+ context "invalid direction" do
let(:direction) { :invalid }
- it 'raises error' do
+ it "raises error" do
expect { subject }.to raise_error StandardError, /Invalid direction/
end
end
end
- describe '.new_commit_summary' do
- it 'escapes HTML titles' do
- commit = double(title: '<pre>This is a test</pre>', short_id: '12345678')
- escaped = '&lt;pre&gt;This is a test&lt;/pre&gt;'
+ describe ".new_commit_summary" do
+ it "escapes HTML titles" do
+ commit = double(title: "<pre>This is a test</pre>", short_id: "12345678")
+ escaped = "&lt;pre&gt;This is a test&lt;/pre&gt;"
expect(described_class.new_commit_summary([commit])).to all(match(/- #{escaped}/))
end
end
- describe 'JIRA integration' do
+ describe "JIRA integration" do
include JiraServiceHelper
let(:project) { create(:jira_project, :repository) }
@@ -732,17 +732,17 @@ describe SystemNoteService do
end
def cross_reference(type, link_exists = false)
- noteable = type == 'commit' ? commit : merge_request
+ noteable = type == "commit" ? commit : merge_request
links = []
if link_exists
- url = if type == 'commit'
- "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/commit/#{commit.id}"
- else
- "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/merge_requests/#{merge_request.iid}"
- end
+ url = if type == "commit"
+ "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/commit/#{commit.id}"
+ else
+ "#{Settings.gitlab.base_url}/#{project.namespace.path}/#{project.path}/merge_requests/#{merge_request.iid}"
+ end
- link = double(object: { 'url' => url })
+ link = double(object: {"url" => url})
links << link
expect(link).to receive(:save!)
end
@@ -752,7 +752,7 @@ describe SystemNoteService do
described_class.cross_reference(jira_issue, noteable, author)
end
- noteable_types = %w(merge_requests commit)
+ noteable_types = %w[merge_requests commit]
noteable_types.each do |type|
context "when noteable is a #{type}" do
@@ -769,8 +769,8 @@ describe SystemNoteService do
end
end
- context 'when a new cross reference is created' do
- it 'creates a new comment and remote link' do
+ context "when a new cross reference is created" do
+ it "creates a new comment and remote link" do
cross_reference(type)
expect(WebMock).to have_requested(:post, jira_api_comment_url(jira_issue))
@@ -778,8 +778,8 @@ describe SystemNoteService do
end
end
- context 'when a link exists' do
- it 'updates a link but does not create a new comment' do
+ context "when a link exists" do
+ it "updates a link but does not create a new comment" do
expect(WebMock).not_to have_requested(:post, jira_api_comment_url(jira_issue))
cross_reference(type, true)
@@ -788,13 +788,13 @@ describe SystemNoteService do
end
describe "new reference" do
- let(:favicon_path) { "http://localhost/assets/#{find_asset('favicon.png').digest_path}" }
+ let(:favicon_path) { "http://localhost/assets/#{find_asset("favicon.png").digest_path}" }
before do
allow(JIRA::Resource::Remotelink).to receive(:all).and_return([])
end
- context 'for commits' do
+ context "for commits" do
it "creates comment" do
result = described_class.cross_reference(jira_issue, commit, author)
@@ -807,19 +807,19 @@ describe SystemNoteService do
expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
body: hash_including(
GlobalID: "GitLab",
- relationship: 'mentioned on',
+ relationship: "mentioned on",
object: {
url: project_commit_url(project, commit),
title: "Commit - #{commit.title}",
- icon: { title: "GitLab", url16x16: favicon_path },
- status: { resolved: false }
+ icon: {title: "GitLab", url16x16: favicon_path},
+ status: {resolved: false},
}
)
).once
end
end
- context 'for issues' do
+ context "for issues" do
let(:issue) { create(:issue, project: project) }
it "creates comment" do
@@ -834,19 +834,19 @@ describe SystemNoteService do
expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
body: hash_including(
GlobalID: "GitLab",
- relationship: 'mentioned on',
+ relationship: "mentioned on",
object: {
url: project_issue_url(project, issue),
title: "Issue - #{issue.title}",
- icon: { title: "GitLab", url16x16: favicon_path },
- status: { resolved: false }
+ icon: {title: "GitLab", url16x16: favicon_path},
+ status: {resolved: false},
}
)
).once
end
end
- context 'for snippets' do
+ context "for snippets" do
let(:snippet) { create(:snippet, project: project) }
it "creates comment" do
@@ -861,12 +861,12 @@ describe SystemNoteService do
expect(WebMock).to have_requested(:post, jira_api_remote_link_url(jira_issue)).with(
body: hash_including(
GlobalID: "GitLab",
- relationship: 'mentioned on',
+ relationship: "mentioned on",
object: {
url: project_snippet_url(project, snippet),
title: "Snippet - #{snippet.title}",
- icon: { title: "GitLab", url16x16: favicon_path },
- status: { resolved: false }
+ icon: {title: "GitLab", url16x16: favicon_path},
+ status: {resolved: false},
}
)
).once
@@ -887,7 +887,7 @@ describe SystemNoteService do
expect(result).not_to eq(success_message)
end
- it 'does not try to create comment and remote link' do
+ it "does not try to create comment and remote link" do
subject
expect(WebMock).not_to have_requested(:post, jira_api_comment_url(jira_issue))
@@ -896,7 +896,7 @@ describe SystemNoteService do
end
end
- describe '.discussion_continued_in_issue' do
+ describe ".discussion_continued_in_issue" do
let(:discussion) { create(:diff_note_on_merge_request, project: project).to_discussion }
let(:merge_request) { discussion.noteable }
let(:issue) { create(:issue, project: project) }
@@ -907,44 +907,44 @@ describe SystemNoteService do
subject { described_class.discussion_continued_in_issue(discussion, project, author, issue) }
- it_behaves_like 'a system note' do
+ it_behaves_like "a system note" do
let(:expected_noteable) { discussion.first_note.noteable }
- let(:action) { 'discussion' }
+ let(:action) { "discussion" }
end
- it 'creates a new note in the discussion' do
+ it "creates a new note in the discussion" do
# we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded.
expect { subject }.to change { reloaded_merge_request.discussions.first.notes.size }.by(1)
end
- it 'mentions the created issue in the system note' do
+ it "mentions the created issue in the system note" do
expect(subject.note).to include(issue.to_reference)
end
end
- describe '.change_time_estimate' do
+ describe ".change_time_estimate" do
subject { described_class.change_time_estimate(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'time_tracking' }
+ it_behaves_like "a system note" do
+ let(:action) { "time_tracking" }
end
- context 'with a time estimate' do
- it 'sets the note text' do
+ context "with a time estimate" do
+ it "sets the note text" do
noteable.update_attribute(:time_estimate, 277200)
expect(subject.note).to eq "changed time estimate to 1w 4d 5h"
end
end
- context 'without a time estimate' do
- it 'sets the note text' do
+ context "without a time estimate" do
+ it "sets the note text" do
expect(subject.note).to eq "removed time estimate"
end
end
end
- describe '.change_time_spent' do
+ describe ".change_time_spent" do
# We need a custom noteable in order to the shared examples to be green.
let(:noteable) do
mr = create(:merge_request, source_project: project)
@@ -957,28 +957,28 @@ describe SystemNoteService do
described_class.change_time_spent(noteable, project, author)
end
- it_behaves_like 'a system note' do
- let(:action) { 'time_tracking' }
+ it_behaves_like "a system note" do
+ let(:action) { "time_tracking" }
end
- context 'when time was added' do
- it 'sets the note text' do
+ context "when time was added" do
+ it "sets the note text" do
spend_time!(277200)
expect(subject.note).to eq "added 1w 4d 5h of time spent"
end
end
- context 'when time was subtracted' do
- it 'sets the note text' do
+ context "when time was subtracted" do
+ it "sets the note text" do
spend_time!(-277200)
expect(subject.note).to eq "subtracted 1w 4d 5h of time spent"
end
end
- context 'when time was removed' do
- it 'sets the note text' do
+ context "when time was removed" do
+ it "sets the note text" do
spend_time!(:reset)
expect(subject.note).to eq "removed time spent"
@@ -991,37 +991,37 @@ describe SystemNoteService do
end
end
- describe '.handle_merge_request_wip' do
- context 'adding wip note' do
- let(:noteable) { create(:merge_request, source_project: project, title: 'WIP Lorem ipsum') }
+ describe ".handle_merge_request_wip" do
+ context "adding wip note" do
+ let(:noteable) { create(:merge_request, source_project: project, title: "WIP Lorem ipsum") }
subject { described_class.handle_merge_request_wip(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
+ it_behaves_like "a system note" do
+ let(:action) { "title" }
end
- it 'sets the note text' do
- expect(subject.note).to eq 'marked as a **Work In Progress**'
+ it "sets the note text" do
+ expect(subject.note).to eq "marked as a **Work In Progress**"
end
end
- context 'removing wip note' do
- let(:noteable) { create(:merge_request, source_project: project, title: 'Lorem ipsum') }
+ context "removing wip note" do
+ let(:noteable) { create(:merge_request, source_project: project, title: "Lorem ipsum") }
subject { described_class.handle_merge_request_wip(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
+ it_behaves_like "a system note" do
+ let(:action) { "title" }
end
- it 'sets the note text' do
- expect(subject.note).to eq 'unmarked as a **Work In Progress**'
+ it "sets the note text" do
+ expect(subject.note).to eq "unmarked as a **Work In Progress**"
end
end
end
- describe '.add_merge_request_wip_from_commit' do
+ describe ".add_merge_request_wip_from_commit" do
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
@@ -1035,8 +1035,8 @@ describe SystemNoteService do
)
end
- it_behaves_like 'a system note' do
- let(:action) { 'title' }
+ it_behaves_like "a system note" do
+ let(:action) { "title" }
end
it "posts the 'marked as a Work In Progress from commit' system note" do
@@ -1046,14 +1046,14 @@ describe SystemNoteService do
end
end
- describe '.change_task_status' do
+ describe ".change_task_status" do
let(:noteable) { create(:issue, project: project) }
- let(:task) { double(:task, complete?: true, source: 'task') }
+ let(:task) { double(:task, complete?: true, source: "task") }
subject { described_class.change_task_status(noteable, project, author, task) }
- it_behaves_like 'a system note' do
- let(:action) { 'task' }
+ it_behaves_like "a system note" do
+ let(:action) { "task" }
end
it "posts the 'marked the task as complete' system note" do
@@ -1061,21 +1061,21 @@ describe SystemNoteService do
end
end
- describe '.resolve_all_discussions' do
+ describe ".resolve_all_discussions" do
let(:noteable) { create(:merge_request, source_project: project, target_project: project) }
subject { described_class.resolve_all_discussions(noteable, project, author) }
- it_behaves_like 'a system note' do
- let(:action) { 'discussion' }
+ it_behaves_like "a system note" do
+ let(:action) { "discussion" }
end
- it 'sets the note text' do
- expect(subject.note).to eq 'resolved all discussions'
+ it "sets the note text" do
+ expect(subject.note).to eq "resolved all discussions"
end
end
- describe '.diff_discussion_outdated' do
+ describe ".diff_discussion_outdated" do
let(:discussion) { create(:diff_note_on_merge_request, project: project).to_discussion }
let(:merge_request) { discussion.noteable }
let(:change_position) { discussion.position }
@@ -1086,19 +1086,19 @@ describe SystemNoteService do
subject { described_class.diff_discussion_outdated(discussion, project, author, change_position) }
- it_behaves_like 'a system note' do
+ it_behaves_like "a system note" do
let(:expected_noteable) { discussion.first_note.noteable }
- let(:action) { 'outdated' }
+ let(:action) { "outdated" }
end
- context 'when the change_position is valid for the discussion' do
- it 'creates a new note in the discussion' do
+ context "when the change_position is valid for the discussion" do
+ it "creates a new note in the discussion" do
# we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded.
expect { subject }.to change { reloaded_merge_request.discussions.first.notes.size }.by(1)
end
- it 'links to the diff in the system note' do
- expect(subject.note).to include('version 1')
+ it "links to the diff in the system note" do
+ expect(subject.note).to include("version 1")
diff_id = merge_request.merge_request_diff.id
line_code = change_position.line_code(project.repository)
@@ -1106,79 +1106,79 @@ describe SystemNoteService do
end
end
- context 'when the change_position is invalid for the discussion' do
+ context "when the change_position is invalid for the discussion" do
let(:change_position) { project.commit(sample_commit.id) }
- it 'creates a new note in the discussion' do
+ it "creates a new note in the discussion" do
# we need to completely rebuild the merge request object, or the `@discussions` on the merge request are not reloaded.
expect { subject }.to change { reloaded_merge_request.discussions.first.notes.size }.by(1)
end
- it 'does not create a link' do
- expect(subject.note).to eq('changed this line in version 1 of the diff')
+ it "does not create a link" do
+ expect(subject.note).to eq("changed this line in version 1 of the diff")
end
end
end
- describe '.mark_duplicate_issue' do
+ describe ".mark_duplicate_issue" do
subject { described_class.mark_duplicate_issue(noteable, project, author, canonical_issue) }
- context 'within the same project' do
+ context "within the same project" do
let(:canonical_issue) { create(:issue, project: project) }
- it_behaves_like 'a system note' do
- let(:action) { 'duplicate' }
+ it_behaves_like "a system note" do
+ let(:action) { "duplicate" }
end
it { expect(subject.note).to eq "marked this issue as a duplicate of #{canonical_issue.to_reference}" }
end
- context 'across different projects' do
+ context "across different projects" do
let(:other_project) { create(:project) }
let(:canonical_issue) { create(:issue, project: other_project) }
- it_behaves_like 'a system note' do
- let(:action) { 'duplicate' }
+ it_behaves_like "a system note" do
+ let(:action) { "duplicate" }
end
it { expect(subject.note).to eq "marked this issue as a duplicate of #{canonical_issue.to_reference(project)}" }
end
end
- describe '.mark_canonical_issue_of_duplicate' do
+ describe ".mark_canonical_issue_of_duplicate" do
subject { described_class.mark_canonical_issue_of_duplicate(noteable, project, author, duplicate_issue) }
- context 'within the same project' do
+ context "within the same project" do
let(:duplicate_issue) { create(:issue, project: project) }
- it_behaves_like 'a system note' do
- let(:action) { 'duplicate' }
+ it_behaves_like "a system note" do
+ let(:action) { "duplicate" }
end
it { expect(subject.note).to eq "marked #{duplicate_issue.to_reference} as a duplicate of this issue" }
end
- context 'across different projects' do
+ context "across different projects" do
let(:other_project) { create(:project) }
let(:duplicate_issue) { create(:issue, project: other_project) }
- it_behaves_like 'a system note' do
- let(:action) { 'duplicate' }
+ it_behaves_like "a system note" do
+ let(:action) { "duplicate" }
end
it { expect(subject.note).to eq "marked #{duplicate_issue.to_reference(project)} as a duplicate of this issue" }
end
end
- describe '.discussion_lock' do
+ describe ".discussion_lock" do
subject { described_class.discussion_lock(noteable, author) }
- context 'discussion unlocked' do
- it_behaves_like 'a system note' do
- let(:action) { 'unlocked' }
+ context "discussion unlocked" do
+ it_behaves_like "a system note" do
+ let(:action) { "unlocked" }
end
- it 'creates the note text correctly' do
+ it "creates the note text correctly" do
[:issue, :merge_request].each do |type|
issuable = create(type)
@@ -1188,16 +1188,16 @@ describe SystemNoteService do
end
end
- context 'discussion locked' do
+ context "discussion locked" do
before do
noteable.update_attribute(:discussion_locked, true)
end
- it_behaves_like 'a system note' do
- let(:action) { 'locked' }
+ it_behaves_like "a system note" do
+ let(:action) { "locked" }
end
- it 'creates the note text correctly' do
+ it "creates the note text correctly" do
[:issue, :merge_request].each do |type|
issuable = create(type, discussion_locked: true)
diff --git a/spec/services/tags/create_service_spec.rb b/spec/services/tags/create_service_spec.rb
index 0cbe57352be..37889e4ecd4 100644
--- a/spec/services/tags/create_service_spec.rb
+++ b/spec/services/tags/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Tags::CreateService do
let(:project) { create(:project, :repository) }
@@ -6,47 +6,47 @@ describe Tags::CreateService do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- it 'creates the tag and returns success' do
- response = service.execute('v42.42.42', 'master', 'Foo')
+ describe "#execute" do
+ it "creates the tag and returns success" do
+ response = service.execute("v42.42.42", "master", "Foo")
expect(response[:status]).to eq(:success)
expect(response[:tag]).to be_a Gitlab::Git::Tag
- expect(response[:tag].name).to eq('v42.42.42')
+ expect(response[:tag].name).to eq("v42.42.42")
end
- context 'when target is invalid' do
- it 'returns an error' do
- response = service.execute('v1.1.0', 'foo', 'Foo')
+ context "when target is invalid" do
+ it "returns an error" do
+ response = service.execute("v1.1.0", "foo", "Foo")
expect(response).to eq(status: :error,
- message: 'Target foo is invalid')
+ message: "Target foo is invalid")
end
end
- context 'when tag already exists' do
- it 'returns an error' do
+ context "when tag already exists" do
+ it "returns an error" do
expect(repository).to receive(:add_tag)
- .with(user, 'v1.1.0', 'master', 'Foo')
+ .with(user, "v1.1.0", "master", "Foo")
.and_raise(Gitlab::Git::Repository::TagExistsError)
- response = service.execute('v1.1.0', 'master', 'Foo')
+ response = service.execute("v1.1.0", "master", "Foo")
expect(response).to eq(status: :error,
- message: 'Tag v1.1.0 already exists')
+ message: "Tag v1.1.0 already exists")
end
end
- context 'when pre-receive hook fails' do
- it 'returns an error' do
+ context "when pre-receive hook fails" do
+ it "returns an error" do
expect(repository).to receive(:add_tag)
- .with(user, 'v1.1.0', 'master', 'Foo')
- .and_raise(Gitlab::Git::PreReceiveError, 'something went wrong')
+ .with(user, "v1.1.0", "master", "Foo")
+ .and_raise(Gitlab::Git::PreReceiveError, "something went wrong")
- response = service.execute('v1.1.0', 'master', 'Foo')
+ response = service.execute("v1.1.0", "master", "Foo")
expect(response).to eq(status: :error,
- message: 'something went wrong')
+ message: "something went wrong")
end
end
end
diff --git a/spec/services/tags/destroy_service_spec.rb b/spec/services/tags/destroy_service_spec.rb
index 7c8c1dd0d3a..64394d70a32 100644
--- a/spec/services/tags/destroy_service_spec.rb
+++ b/spec/services/tags/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Tags::DestroyService do
let(:project) { create(:project, :repository) }
@@ -6,12 +6,12 @@ describe Tags::DestroyService do
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
- describe '#execute' do
- it 'removes the tag' do
+ describe "#execute" do
+ it "removes the tag" do
expect(repository).to receive(:before_remove_tag)
expect(service).to receive(:success)
- service.execute('v1.1.0')
+ service.execute("v1.1.0")
end
end
end
diff --git a/spec/services/task_list_toggle_service_spec.rb b/spec/services/task_list_toggle_service_spec.rb
index b1260cf740a..8eda4902110 100644
--- a/spec/services/task_list_toggle_service_spec.rb
+++ b/spec/services/task_list_toggle_service_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe TaskListToggleService do
let(:markdown) do
@@ -49,40 +49,40 @@ describe TaskListToggleService do
EOT
end
- it 'checks Task 1' do
+ it "checks Task 1" do
toggler = described_class.new(markdown, markdown_html,
- toggle_as_checked: true,
- line_source: '* [ ] Task 1', line_number: 1)
+ toggle_as_checked: true,
+ line_source: "* [ ] Task 1", line_number: 1)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[0]).to eq "* [x] Task 1\n"
- expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
+ expect(toggler.updated_markdown_html).to include("disabled checked> Task 1")
end
- it 'unchecks Item 1' do
+ it "unchecks Item 1" do
toggler = described_class.new(markdown, markdown_html,
- toggle_as_checked: false,
- line_source: '1. [X] Item 1', line_number: 6)
+ toggle_as_checked: false,
+ line_source: "1. [X] Item 1", line_number: 6)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[5]).to eq "1. [ ] Item 1\n"
- expect(toggler.updated_markdown_html).to include('disabled> Item 1')
+ expect(toggler.updated_markdown_html).to include("disabled> Item 1")
end
- it 'checks task in loose list' do
+ it "checks task in loose list" do
toggler = described_class.new(markdown, markdown_html,
- toggle_as_checked: true,
- line_source: '- [ ] loose list', line_number: 9)
+ toggle_as_checked: true,
+ line_source: "- [ ] loose list", line_number: 9)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[8]).to eq "- [x] loose list\n"
- expect(toggler.updated_markdown_html).to include('disabled checked> loose list')
+ expect(toggler.updated_markdown_html).to include("disabled checked> loose list")
end
- it 'returns false if line_source does not match the text' do
+ it "returns false if line_source does not match the text" do
toggler = described_class.new(markdown, markdown_html,
- toggle_as_checked: false,
- line_source: '* [x] Task Added', line_number: 2)
+ toggle_as_checked: false,
+ line_source: "* [x] Task Added", line_number: 2)
expect(toggler.execute).to be_falsey
end
@@ -90,26 +90,26 @@ describe TaskListToggleService do
it 'tolerates \r\n line endings' do
rn_markdown = markdown.gsub("\n", "\r\n")
toggler = described_class.new(rn_markdown, markdown_html,
- toggle_as_checked: true,
- line_source: '* [ ] Task 1', line_number: 1)
+ toggle_as_checked: true,
+ line_source: "* [ ] Task 1", line_number: 1)
expect(toggler.execute).to be_truthy
expect(toggler.updated_markdown.lines[0]).to eq "* [x] Task 1\r\n"
- expect(toggler.updated_markdown_html).to include('disabled checked> Task 1')
+ expect(toggler.updated_markdown_html).to include("disabled checked> Task 1")
end
- it 'returns false if markdown is nil' do
+ it "returns false if markdown is nil" do
toggler = described_class.new(nil, markdown_html,
- toggle_as_checked: false,
- line_source: '* [x] Task Added', line_number: 2)
+ toggle_as_checked: false,
+ line_source: "* [x] Task Added", line_number: 2)
expect(toggler.execute).to be_falsey
end
- it 'returns false if markdown_html is nil' do
+ it "returns false if markdown_html is nil" do
toggler = described_class.new(markdown, nil,
- toggle_as_checked: false,
- line_source: '* [x] Task Added', line_number: 2)
+ toggle_as_checked: false,
+ line_source: "* [x] Task Added", line_number: 2)
expect(toggler.execute).to be_falsey
end
diff --git a/spec/services/test_hooks/project_service_spec.rb b/spec/services/test_hooks/project_service_spec.rb
index 19e1c5ff3b2..d8c4ddba151 100644
--- a/spec/services/test_hooks/project_service_spec.rb
+++ b/spec/services/test_hooks/project_service_spec.rb
@@ -1,42 +1,42 @@
-require 'spec_helper'
+require "spec_helper"
describe TestHooks::ProjectService do
let(:current_user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project, :repository) }
let(:hook) { create(:project_hook, project: project) }
- let(:trigger) { 'not_implemented_events' }
+ let(:trigger) { "not_implemented_events" }
let(:service) { described_class.new(hook, current_user, trigger) }
- let(:sample_data) { { data: 'sample' } }
- let(:success_result) { { status: :success, http_status: 200, message: 'ok' } }
+ let(:sample_data) { {data: "sample"} }
+ let(:success_result) { {status: :success, http_status: 200, message: "ok"} }
- it 'allows to set a custom project' do
+ it "allows to set a custom project" do
project = double
service.project = project
expect(service.project).to eq(project)
end
- context 'hook with not implemented test' do
- it 'returns error message' do
+ context "hook with not implemented test" do
+ it "returns error message" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Testing not available for this hook' })
+ expect(service.execute).to include({status: :error, message: "Testing not available for this hook"})
end
end
- context 'push_events' do
- let(:trigger) { 'push_events' }
+ context "push_events" do
+ let(:trigger) { "push_events" }
let(:trigger_key) { :push_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
allow(project).to receive(:empty_repo?).and_return(true)
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has at least one commit.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has at least one commit."})
end
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:empty_repo?).and_return(false)
allow(Gitlab::DataBuilder::Push).to receive(:build_sample).and_return(sample_data)
@@ -45,18 +45,18 @@ describe TestHooks::ProjectService do
end
end
- context 'tag_push_events' do
- let(:trigger) { 'tag_push_events' }
+ context "tag_push_events" do
+ let(:trigger) { "tag_push_events" }
let(:trigger_key) { :tag_push_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
allow(project).to receive(:empty_repo?).and_return(true)
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has at least one commit.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has at least one commit."})
end
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:empty_repo?).and_return(false)
allow(Gitlab::DataBuilder::Push).to receive(:build_sample).and_return(sample_data)
@@ -65,16 +65,16 @@ describe TestHooks::ProjectService do
end
end
- context 'note_events' do
- let(:trigger) { 'note_events' }
+ context "note_events" do
+ let(:trigger) { "note_events" }
let(:trigger_key) { :note_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has notes.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has notes."})
end
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:notes).and_return([Note.new])
allow(Gitlab::DataBuilder::Note).to receive(:build).and_return(sample_data)
@@ -83,17 +83,17 @@ describe TestHooks::ProjectService do
end
end
- context 'issues_events' do
- let(:trigger) { 'issues_events' }
+ context "issues_events" do
+ let(:trigger) { "issues_events" }
let(:trigger_key) { :issue_hooks }
let(:issue) { build(:issue) }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has issues.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has issues."})
end
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:issues).and_return([issue])
allow(issue).to receive(:to_hook_data).and_return(sample_data)
@@ -102,17 +102,17 @@ describe TestHooks::ProjectService do
end
end
- context 'confidential_issues_events' do
- let(:trigger) { 'confidential_issues_events' }
+ context "confidential_issues_events" do
+ let(:trigger) { "confidential_issues_events" }
let(:trigger_key) { :confidential_issue_hooks }
let(:issue) { build(:issue) }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has issues.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has issues."})
end
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:issues).and_return([issue])
allow(issue).to receive(:to_hook_data).and_return(sample_data)
@@ -121,16 +121,16 @@ describe TestHooks::ProjectService do
end
end
- context 'merge_requests_events' do
- let(:trigger) { 'merge_requests_events' }
+ context "merge_requests_events" do
+ let(:trigger) { "merge_requests_events" }
let(:trigger_key) { :merge_request_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has merge requests.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has merge requests."})
end
- it 'executes hook' do
+ it "executes hook" do
create(:merge_request, source_project: project)
allow_any_instance_of(MergeRequest).to receive(:to_hook_data).and_return(sample_data)
@@ -139,16 +139,16 @@ describe TestHooks::ProjectService do
end
end
- context 'job_events' do
- let(:trigger) { 'job_events' }
+ context "job_events" do
+ let(:trigger) { "job_events" }
let(:trigger_key) { :job_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has CI jobs.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has CI jobs."})
end
- it 'executes hook' do
+ it "executes hook" do
create(:ci_build, project: project)
allow(Gitlab::DataBuilder::Build).to receive(:build).and_return(sample_data)
@@ -157,16 +157,16 @@ describe TestHooks::ProjectService do
end
end
- context 'pipeline_events' do
- let(:trigger) { 'pipeline_events' }
+ context "pipeline_events" do
+ let(:trigger) { "pipeline_events" }
let(:trigger_key) { :pipeline_hooks }
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the project has CI pipelines.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the project has CI pipelines."})
end
- it 'executes hook' do
+ it "executes hook" do
create(:ci_empty_pipeline, project: project)
allow(Gitlab::DataBuilder::Pipeline).to receive(:build).and_return(sample_data)
@@ -175,24 +175,24 @@ describe TestHooks::ProjectService do
end
end
- context 'wiki_page_events' do
+ context "wiki_page_events" do
let(:project) { create(:project, :wiki_repo) }
- let(:trigger) { 'wiki_page_events' }
+ let(:trigger) { "wiki_page_events" }
let(:trigger_key) { :wiki_page_hooks }
- it 'returns error message if wiki disabled' do
+ it "returns error message if wiki disabled" do
allow(project).to receive(:wiki_enabled?).and_return(false)
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the wiki is enabled and has pages.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the wiki is enabled and has pages."})
end
- it 'returns error message if not enough data' do
+ it "returns error message if not enough data" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure the wiki is enabled and has pages.' })
+ expect(service.execute).to include({status: :error, message: "Ensure the wiki is enabled and has pages."})
end
- it 'executes hook' do
+ it "executes hook" do
create(:wiki_page, wiki: project.wiki)
allow(Gitlab::DataBuilder::WikiPage).to receive(:build).and_return(sample_data)
diff --git a/spec/services/test_hooks/system_service_spec.rb b/spec/services/test_hooks/system_service_spec.rb
index 74d7715e50f..cc0409fa33a 100644
--- a/spec/services/test_hooks/system_service_spec.rb
+++ b/spec/services/test_hooks/system_service_spec.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
describe TestHooks::SystemService do
let(:current_user) { create(:user) }
- describe '#execute' do
+ describe "#execute" do
let(:project) { create(:project, :repository) }
let(:hook) { create(:system_hook) }
let(:service) { described_class.new(hook, current_user, trigger) }
- let(:success_result) { { status: :success, http_status: 200, message: 'ok' } }
+ let(:success_result) { {status: :success, http_status: 200, message: "ok"} }
before do
allow(Project).to receive(:first).and_return(project)
end
- context 'hook with not implemented test' do
- let(:trigger) { 'not_implemented_events' }
+ context "hook with not implemented test" do
+ let(:trigger) { "not_implemented_events" }
- it 'returns error message' do
+ it "returns error message" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Testing not available for this hook' })
+ expect(service.execute).to include({status: :error, message: "Testing not available for this hook"})
end
end
- context 'push_events' do
- let(:trigger) { 'push_events' }
+ context "push_events" do
+ let(:trigger) { "push_events" }
let(:trigger_key) { :push_hooks }
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:empty_repo?).and_return(false)
expect(Gitlab::DataBuilder::Push).to receive(:sample_data).and_call_original
@@ -35,12 +35,12 @@ describe TestHooks::SystemService do
end
end
- context 'tag_push_events' do
- let(:trigger) { 'tag_push_events' }
+ context "tag_push_events" do
+ let(:trigger) { "tag_push_events" }
let(:trigger_key) { :tag_push_hooks }
- it 'executes hook' do
- allow(project.repository).to receive(:tags).and_return(['tag'])
+ it "executes hook" do
+ allow(project.repository).to receive(:tags).and_return(["tag"])
expect(Gitlab::DataBuilder::Push).to receive(:sample_data).and_call_original
expect(hook).to receive(:execute).with(Gitlab::DataBuilder::Push::SAMPLE_DATA, trigger_key).and_return(success_result)
@@ -48,11 +48,11 @@ describe TestHooks::SystemService do
end
end
- context 'repository_update_events' do
- let(:trigger) { 'repository_update_events' }
+ context "repository_update_events" do
+ let(:trigger) { "repository_update_events" }
let(:trigger_key) { :repository_update_hooks }
- it 'executes hook' do
+ it "executes hook" do
allow(project).to receive(:empty_repo?).and_return(false)
expect(Gitlab::DataBuilder::Repository).to receive(:sample_data).and_call_original
@@ -61,17 +61,17 @@ describe TestHooks::SystemService do
end
end
- context 'merge_requests_events' do
- let(:trigger) { 'merge_requests_events' }
+ context "merge_requests_events" do
+ let(:trigger) { "merge_requests_events" }
- it 'returns error message if the user does not have any repository with a merge request' do
+ it "returns error message if the user does not have any repository with a merge request" do
expect(hook).not_to receive(:execute)
- expect(service.execute).to include({ status: :error, message: 'Ensure one of your projects has merge requests.' })
+ expect(service.execute).to include({status: :error, message: "Ensure one of your projects has merge requests."})
end
- it 'executes hook' do
+ it "executes hook" do
trigger_key = :merge_request_hooks
- sample_data = { data: 'sample' }
+ sample_data = {data: "sample"}
create(:project_member, user: current_user, project: project)
create(:merge_request, source_project: project)
allow_any_instance_of(MergeRequest).to receive(:to_hook_data).and_return(sample_data)
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 8631f3f9a33..7cc6d632902 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TodoService do
let(:author) { create(:user) }
@@ -11,9 +11,9 @@ describe TodoService do
let(:skipped) { create(:user) }
let(:skip_users) { [skipped] }
let(:project) { create(:project, :repository) }
- let(:mentions) { 'FYI: ' + [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(' ') }
- let(:directly_addressed) { [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(' ') }
- let(:directly_addressed_and_mentioned) { member.to_reference + ", what do you think? cc: " + [guest, admin, skipped].map(&:to_reference).join(' ') }
+ let(:mentions) { "FYI: " + [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(" ") }
+ let(:directly_addressed) { [author, assignee, john_doe, member, guest, non_member, admin, skipped].map(&:to_reference).join(" ") }
+ let(:directly_addressed_and_mentioned) { member.to_reference + ", what do you think? cc: " + [guest, admin, skipped].map(&:to_reference).join(" ") }
let(:service) { described_class.new }
before do
@@ -25,32 +25,32 @@ describe TodoService do
project.add_developer(skipped)
end
- describe 'Issues' do
+ describe "Issues" do
let(:issue) { create(:issue, project: project, assignees: [john_doe], author: author, description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
let(:addressed_issue) { create(:issue, project: project, assignees: [john_doe], author: author, description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
let(:unassigned_issue) { create(:issue, project: project, assignees: []) }
let(:confidential_issue) { create(:issue, :confidential, project: project, author: author, assignees: [assignee], description: mentions) }
let(:addressed_confident_issue) { create(:issue, :confidential, project: project, author: author, assignees: [assignee], description: directly_addressed) }
- describe '#new_issue' do
- it 'creates a todo if assigned' do
+ describe "#new_issue" do
+ it "creates a todo if assigned" do
service.new_issue(issue, author)
should_create_todo(user: john_doe, target: issue, action: Todo::ASSIGNED)
end
- it 'does not create a todo if unassigned' do
+ it "does not create a todo if unassigned" do
should_not_create_any_todo { service.new_issue(unassigned_issue, author) }
end
- it 'creates a todo if assignee is the current user' do
+ it "creates a todo if assignee is the current user" do
unassigned_issue.assignees = [john_doe]
service.new_issue(unassigned_issue, john_doe)
should_create_todo(user: john_doe, target: unassigned_issue, author: john_doe, action: Todo::ASSIGNED)
end
- it 'creates a todo for each valid mentioned user' do
+ it "creates a todo for each valid mentioned user" do
service.new_issue(issue, author)
should_create_todo(user: member, target: issue, action: Todo::MENTIONED)
@@ -60,7 +60,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: issue, action: Todo::MENTIONED)
end
- it 'creates a directly addressed todo for each valid addressed user' do
+ it "creates a directly addressed todo for each valid addressed user" do
service.new_issue(addressed_issue, author)
should_create_todo(user: member, target: addressed_issue, action: Todo::DIRECTLY_ADDRESSED)
@@ -70,7 +70,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: addressed_issue, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'creates correct todos for each valid user based on the type of mention' do
+ it "creates correct todos for each valid user based on the type of mention" do
issue.update(description: directly_addressed_and_mentioned)
service.new_issue(issue, author)
@@ -80,7 +80,7 @@ describe TodoService do
should_create_todo(user: guest, target: issue, action: Todo::MENTIONED)
end
- it 'does not create todo if user can not see the issue when issue is confidential' do
+ it "does not create todo if user can not see the issue when issue is confidential" do
service.new_issue(confidential_issue, john_doe)
should_create_todo(user: assignee, target: confidential_issue, author: john_doe, action: Todo::ASSIGNED)
@@ -91,7 +91,7 @@ describe TodoService do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
end
- it 'does not create directly addressed todo if user cannot see the issue when issue is confidential' do
+ it "does not create directly addressed todo if user cannot see the issue when issue is confidential" do
service.new_issue(addressed_confident_issue, john_doe)
should_create_todo(user: assignee, target: addressed_confident_issue, author: john_doe, action: Todo::ASSIGNED)
@@ -102,7 +102,7 @@ describe TodoService do
should_create_todo(user: john_doe, target: addressed_confident_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED)
end
- context 'when a private group is mentioned' do
+ context "when a private group is mentioned" do
let(:group) { create(:group, :private) }
let(:project) { create(:project, :private, group: group) }
let(:issue) { create(:issue, author: author, project: project, description: group.to_reference) }
@@ -115,15 +115,15 @@ describe TodoService do
service.new_issue(issue, author)
end
- it 'creates a todo for group members' do
+ it "creates a todo for group members" do
should_create_todo(user: member, target: issue)
should_create_todo(user: john_doe, target: issue)
end
end
end
- describe '#update_issue' do
- it 'creates a todo for each valid mentioned user not included in skip_users' do
+ describe "#update_issue" do
+ it "creates a todo for each valid mentioned user not included in skip_users" do
service.update_issue(issue, author, skip_users)
should_create_todo(user: member, target: issue, action: Todo::MENTIONED)
@@ -134,7 +134,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: issue, action: Todo::MENTIONED)
end
- it 'creates a todo for each valid user not included in skip_users based on the type of mention' do
+ it "creates a todo for each valid user not included in skip_users based on the type of mention" do
issue.update(description: directly_addressed_and_mentioned)
service.update_issue(issue, author, skip_users)
@@ -145,7 +145,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: issue)
end
- it 'creates a directly addressed todo for each valid addressed user not included in skip_users' do
+ it "creates a directly addressed todo for each valid addressed user not included in skip_users" do
service.update_issue(addressed_issue, author, skip_users)
should_create_todo(user: member, target: addressed_issue, action: Todo::DIRECTLY_ADDRESSED)
@@ -156,31 +156,31 @@ describe TodoService do
should_not_create_todo(user: skipped, target: addressed_issue, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'does not create a todo if user was already mentioned and todo is pending' do
+ it "does not create a todo if user was already mentioned and todo is pending" do
create(:todo, :mentioned, user: member, project: project, target: issue, author: author)
expect { service.update_issue(issue, author, skip_users) }.not_to change(member.todos, :count)
end
- it 'does not create a todo if user was already mentioned and todo is done' do
+ it "does not create a todo if user was already mentioned and todo is done" do
create(:todo, :mentioned, :done, user: skipped, project: project, target: issue, author: author)
expect { service.update_issue(issue, author, skip_users) }.not_to change(skipped.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is pending' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is pending" do
create(:todo, :directly_addressed, user: member, project: project, target: addressed_issue, author: author)
expect { service.update_issue(addressed_issue, author, skip_users) }.not_to change(member.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is done' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is done" do
create(:todo, :directly_addressed, :done, user: skipped, project: project, target: addressed_issue, author: author)
expect { service.update_issue(addressed_issue, author, skip_users) }.not_to change(skipped.todos, :count)
end
- it 'does not create todo if user can not see the issue when issue is confidential' do
+ it "does not create todo if user can not see the issue when issue is confidential" do
service.update_issue(confidential_issue, john_doe)
should_create_todo(user: author, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
@@ -191,7 +191,7 @@ describe TodoService do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::MENTIONED)
end
- it 'does not create a directly addressed todo if user can not see the issue when issue is confidential' do
+ it "does not create a directly addressed todo if user can not see the issue when issue is confidential" do
service.update_issue(addressed_confident_issue, john_doe)
should_create_todo(user: author, target: addressed_confident_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED)
@@ -202,8 +202,8 @@ describe TodoService do
should_create_todo(user: john_doe, target: addressed_confident_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED)
end
- context 'issues with a task list' do
- it 'does not create todo when tasks are marked as completed' do
+ context "issues with a task list" do
+ it "does not create todo when tasks are marked as completed" do
issue.update(description: "- [x] Task 1\n- [X] Task 2 #{mentions}")
service.update_issue(issue, author)
@@ -216,7 +216,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: issue, action: Todo::MENTIONED)
end
- it 'does not create directly addressed todo when tasks are marked as completed' do
+ it "does not create directly addressed todo when tasks are marked as completed" do
addressed_issue.update(description: "#{directly_addressed}\n- [x] Task 1\n- [x] Task 2\n")
service.update_issue(addressed_issue, author)
@@ -229,16 +229,16 @@ describe TodoService do
should_not_create_todo(user: non_member, target: addressed_issue, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'does not raise an error when description not change' do
- issue.update(title: 'Sample')
+ it "does not raise an error when description not change" do
+ issue.update(title: "Sample")
expect { service.update_issue(issue, author) }.not_to raise_error
end
end
end
- describe '#close_issue' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#close_issue" do
+ it "marks related pending todos to the target for the user as done" do
first_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
second_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
@@ -249,8 +249,8 @@ describe TodoService do
end
end
- describe '#destroy_target' do
- it 'refreshes the todos count cache for users with todos on the target' do
+ describe "#destroy_target" do
+ it "refreshes the todos count cache for users with todos on the target" do
create(:todo, target: issue, user: john_doe, author: john_doe, project: issue.project)
expect_any_instance_of(User).to receive(:update_todos_count_cache).and_call_original
@@ -258,7 +258,7 @@ describe TodoService do
service.destroy_target(issue) { }
end
- it 'does not refresh the todos count cache for users with only done todos on the target' do
+ it "does not refresh the todos count cache for users with only done todos on the target" do
create(:todo, :done, target: issue, user: john_doe, author: john_doe, project: issue.project)
expect_any_instance_of(User).not_to receive(:update_todos_count_cache)
@@ -266,27 +266,27 @@ describe TodoService do
service.destroy_target(issue) { }
end
- it 'yields the target to the caller' do
+ it "yields the target to the caller" do
expect { |b| service.destroy_target(issue, &b) }
.to yield_with_args(issue)
end
end
- describe '#reassigned_issue' do
- it 'creates a pending todo for new assignee' do
+ describe "#reassigned_issue" do
+ it "creates a pending todo for new assignee" do
unassigned_issue.assignees << john_doe
service.reassigned_issue(unassigned_issue, author)
should_create_todo(user: john_doe, target: unassigned_issue, action: Todo::ASSIGNED)
end
- it 'does not create a todo if unassigned' do
+ it "does not create a todo if unassigned" do
issue.assignees.destroy_all # rubocop: disable DestroyAll
should_not_create_any_todo { service.reassigned_issue(issue, author) }
end
- it 'creates a todo if new assignee is the current user' do
+ it "creates a todo if new assignee is the current user" do
unassigned_issue.assignees << john_doe
service.reassigned_issue(unassigned_issue, john_doe)
@@ -294,8 +294,8 @@ describe TodoService do
end
end
- describe '#mark_pending_todos_as_done' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#mark_pending_todos_as_done" do
+ it "marks related pending todos to the target for the user as done" do
first_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
second_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
@@ -305,8 +305,8 @@ describe TodoService do
expect(second_todo.reload).to be_done
end
- describe 'cached counts' do
- it 'updates when todos change' do
+ describe "cached counts" do
+ it "updates when todos change" do
create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
expect(john_doe.todos_done_count).to eq(0)
@@ -321,23 +321,23 @@ describe TodoService do
end
end
- shared_examples 'updating todos state' do |meth, state, new_state|
+ shared_examples "updating todos state" do |meth, state, new_state|
let!(:first_todo) { create(:todo, state, user: john_doe, project: project, target: issue, author: author) }
let!(:second_todo) { create(:todo, state, user: john_doe, project: project, target: issue, author: author) }
- it 'updates related todos for the user with the new_state' do
+ it "updates related todos for the user with the new_state" do
service.send(meth, collection, john_doe)
expect(first_todo.reload.state?(new_state)).to be true
expect(second_todo.reload.state?(new_state)).to be true
end
- it 'returns the updated ids' do
+ it "returns the updated ids" do
expect(service.send(meth, collection, john_doe)).to match_array([first_todo.id, second_todo.id])
end
- describe 'cached counts' do
- it 'updates when todos change' do
+ describe "cached counts" do
+ it "updates when todos change" do
expect(john_doe.todos.where(state: new_state).count).to eq(0)
expect(john_doe.todos.where(state: state).count).to eq(2)
expect(john_doe).to receive(:update_todos_count_cache).and_call_original
@@ -350,31 +350,31 @@ describe TodoService do
end
end
- describe '#mark_todos_as_done' do
- it_behaves_like 'updating todos state', :mark_todos_as_done, :pending, :done do
+ describe "#mark_todos_as_done" do
+ it_behaves_like "updating todos state", :mark_todos_as_done, :pending, :done do
let(:collection) { Todo.all }
end
end
- describe '#mark_todos_as_done_by_ids' do
- it_behaves_like 'updating todos state', :mark_todos_as_done_by_ids, :pending, :done do
+ describe "#mark_todos_as_done_by_ids" do
+ it_behaves_like "updating todos state", :mark_todos_as_done_by_ids, :pending, :done do
let(:collection) { [first_todo, second_todo].map(&:id) }
end
end
- describe '#mark_todos_as_pending' do
- it_behaves_like 'updating todos state', :mark_todos_as_pending, :done, :pending do
+ describe "#mark_todos_as_pending" do
+ it_behaves_like "updating todos state", :mark_todos_as_pending, :done, :pending do
let(:collection) { Todo.all }
end
end
- describe '#mark_todos_as_pending_by_ids' do
- it_behaves_like 'updating todos state', :mark_todos_as_pending_by_ids, :done, :pending do
+ describe "#mark_todos_as_pending_by_ids" do
+ it_behaves_like "updating todos state", :mark_todos_as_pending_by_ids, :done, :pending do
let(:collection) { [first_todo, second_todo].map(&:id) }
end
end
- describe '#new_note' do
+ describe "#new_note" do
let!(:first_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) }
let!(:second_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) }
let(:confidential_issue) { create(:issue, :confidential, project: project, author: author, assignees: [assignee]) }
@@ -387,7 +387,7 @@ describe TodoService do
let(:note_on_project_snippet) { create(:note_on_project_snippet, project: project, author: john_doe, note: mentions) }
let(:system_note) { create(:system_note, project: project, noteable: issue) }
- it 'mark related pending todos to the noteable for the note author as done' do
+ it "mark related pending todos to the noteable for the note author as done" do
first_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
second_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author)
@@ -397,14 +397,14 @@ describe TodoService do
expect(second_todo.reload).to be_done
end
- it 'does not mark related pending todos it is a system note' do
+ it "does not mark related pending todos it is a system note" do
service.new_note(system_note, john_doe)
expect(first_todo.reload).to be_pending
expect(second_todo.reload).to be_pending
end
- it 'creates a todo for each valid mentioned user' do
+ it "creates a todo for each valid mentioned user" do
service.new_note(note, john_doe)
should_create_todo(user: member, target: issue, author: john_doe, action: Todo::MENTIONED, note: note)
@@ -414,7 +414,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: issue, author: john_doe, action: Todo::MENTIONED, note: note)
end
- it 'creates a todo for each valid user based on the type of mention' do
+ it "creates a todo for each valid user based on the type of mention" do
note.update(note: directly_addressed_and_mentioned)
service.new_note(note, john_doe)
@@ -424,7 +424,7 @@ describe TodoService do
should_create_todo(user: guest, target: issue, author: john_doe, action: Todo::MENTIONED, note: note)
end
- it 'creates a directly addressed todo for each valid addressed user' do
+ it "creates a directly addressed todo for each valid addressed user" do
service.new_note(addressed_note, john_doe)
should_create_todo(user: member, target: issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note)
@@ -434,7 +434,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note)
end
- it 'does not create todo if user can not see the issue when leaving a note on a confidential issue' do
+ it "does not create todo if user can not see the issue when leaving a note on a confidential issue" do
service.new_note(note_on_confidential_issue, john_doe)
should_create_todo(user: author, target: confidential_issue, author: john_doe, action: Todo::MENTIONED, note: note_on_confidential_issue)
@@ -445,7 +445,7 @@ describe TodoService do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::MENTIONED, note: note_on_confidential_issue)
end
- it 'does not create a directly addressed todo if user can not see the issue when leaving a note on a confidential issue' do
+ it "does not create a directly addressed todo if user can not see the issue when leaving a note on a confidential issue" do
service.new_note(addressed_note_on_confidential_issue, john_doe)
should_create_todo(user: author, target: confidential_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_confidential_issue)
@@ -456,47 +456,47 @@ describe TodoService do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_confidential_issue)
end
- context 'on commit' do
+ context "on commit" do
let(:project) { create(:project, :repository) }
- it 'creates a todo for each valid mentioned user when leaving a note on commit' do
+ it "creates a todo for each valid mentioned user when leaving a note on commit" do
service.new_note(note_on_commit, john_doe)
- should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
- should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
- should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
- should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
+ should_create_todo(user: member, target_id: nil, target_type: "Commit", commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
+ should_create_todo(user: author, target_id: nil, target_type: "Commit", commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
+ should_create_todo(user: john_doe, target_id: nil, target_type: "Commit", commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
+ should_not_create_todo(user: non_member, target_id: nil, target_type: "Commit", commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
end
- it 'creates a directly addressed todo for each valid mentioned user when leaving a note on commit' do
+ it "creates a directly addressed todo for each valid mentioned user when leaving a note on commit" do
service.new_note(addressed_note_on_commit, john_doe)
- should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
- should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
- should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
- should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
+ should_create_todo(user: member, target_id: nil, target_type: "Commit", commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
+ should_create_todo(user: author, target_id: nil, target_type: "Commit", commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
+ should_create_todo(user: john_doe, target_id: nil, target_type: "Commit", commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
+ should_not_create_todo(user: non_member, target_id: nil, target_type: "Commit", commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
end
end
- it 'does not create todo when leaving a note on snippet' do
+ it "does not create todo when leaving a note on snippet" do
should_not_create_any_todo { service.new_note(note_on_project_snippet, john_doe) }
end
end
- describe '#mark_todo' do
- it 'creates a todo from a issue' do
+ describe "#mark_todo" do
+ it "creates a todo from a issue" do
service.mark_todo(unassigned_issue, author)
should_create_todo(user: author, target: unassigned_issue, action: Todo::MARKED)
end
end
- describe '#todo_exists?' do
- it 'returns false when no todo exist for the given issuable' do
+ describe "#todo_exists?" do
+ it "returns false when no todo exist for the given issuable" do
expect(service.todo_exist?(unassigned_issue, author)).to be_falsy
end
- it 'returns true when a todo exist for the given issuable' do
+ it "returns true when a todo exist for the given issuable" do
service.mark_todo(unassigned_issue, author)
expect(service.todo_exist?(unassigned_issue, author)).to be_truthy
@@ -504,27 +504,27 @@ describe TodoService do
end
end
- describe 'Merge Requests' do
+ describe "Merge Requests" do
let(:mr_assigned) { create(:merge_request, source_project: project, author: author, assignee: john_doe, description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
let(:addressed_mr_assigned) { create(:merge_request, source_project: project, author: author, assignee: john_doe, description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
let(:mr_unassigned) { create(:merge_request, source_project: project, author: author, assignee: nil) }
- describe '#new_merge_request' do
- it 'creates a pending todo if assigned' do
+ describe "#new_merge_request" do
+ it "creates a pending todo if assigned" do
service.new_merge_request(mr_assigned, author)
should_create_todo(user: john_doe, target: mr_assigned, action: Todo::ASSIGNED)
end
- it 'does not create a todo if unassigned' do
+ it "does not create a todo if unassigned" do
should_not_create_any_todo { service.new_merge_request(mr_unassigned, author) }
end
- it 'does not create a todo if assignee is the current user' do
+ it "does not create a todo if assignee is the current user" do
should_not_create_any_todo { service.new_merge_request(mr_unassigned, john_doe) }
end
- it 'creates a todo for each valid mentioned user' do
+ it "creates a todo for each valid mentioned user" do
service.new_merge_request(mr_assigned, author)
should_create_todo(user: member, target: mr_assigned, action: Todo::MENTIONED)
@@ -534,7 +534,7 @@ describe TodoService do
should_not_create_todo(user: non_member, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'creates a todo for each valid user based on the type of mention' do
+ it "creates a todo for each valid user based on the type of mention" do
mr_assigned.update(description: directly_addressed_and_mentioned)
service.new_merge_request(mr_assigned, author)
@@ -543,7 +543,7 @@ describe TodoService do
should_create_todo(user: admin, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'creates a directly addressed todo for each valid addressed user' do
+ it "creates a directly addressed todo for each valid addressed user" do
service.new_merge_request(addressed_mr_assigned, author)
should_create_todo(user: member, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
@@ -554,8 +554,8 @@ describe TodoService do
end
end
- describe '#update_merge_request' do
- it 'creates a todo for each valid mentioned user not included in skip_users' do
+ describe "#update_merge_request" do
+ it "creates a todo for each valid mentioned user not included in skip_users" do
service.update_merge_request(mr_assigned, author, skip_users)
should_create_todo(user: member, target: mr_assigned, action: Todo::MENTIONED)
@@ -566,7 +566,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'creates a todo for each valid user not included in skip_users based on the type of mention' do
+ it "creates a todo for each valid user not included in skip_users based on the type of mention" do
mr_assigned.update(description: directly_addressed_and_mentioned)
service.update_merge_request(mr_assigned, author, skip_users)
@@ -576,7 +576,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: mr_assigned)
end
- it 'creates a directly addressed todo for each valid addressed user not included in skip_users' do
+ it "creates a directly addressed todo for each valid addressed user not included in skip_users" do
service.update_merge_request(addressed_mr_assigned, author, skip_users)
should_create_todo(user: member, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
@@ -587,32 +587,32 @@ describe TodoService do
should_not_create_todo(user: skipped, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'does not create a todo if user was already mentioned and todo is pending' do
+ it "does not create a todo if user was already mentioned and todo is pending" do
create(:todo, :mentioned, user: member, project: project, target: mr_assigned, author: author)
expect { service.update_merge_request(mr_assigned, author) }.not_to change(member.todos, :count)
end
- it 'does not create a todo if user was already mentioned and todo is done' do
+ it "does not create a todo if user was already mentioned and todo is done" do
create(:todo, :mentioned, :done, user: skipped, project: project, target: mr_assigned, author: author)
expect { service.update_merge_request(mr_assigned, author, skip_users) }.not_to change(skipped.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is pending' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is pending" do
create(:todo, :directly_addressed, user: member, project: project, target: addressed_mr_assigned, author: author)
expect { service.update_merge_request(addressed_mr_assigned, author) }.not_to change(member.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is done' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is done" do
create(:todo, :directly_addressed, user: skipped, project: project, target: addressed_mr_assigned, author: author)
expect { service.update_merge_request(addressed_mr_assigned, author, skip_users) }.not_to change(skipped.todos, :count)
end
- context 'with a task list' do
- it 'does not create todo when tasks are marked as completed' do
+ context "with a task list" do
+ it "does not create todo when tasks are marked as completed" do
mr_assigned.update(description: "- [x] Task 1\n- [X] Task 2 #{mentions}")
service.update_merge_request(mr_assigned, author)
@@ -626,7 +626,7 @@ describe TodoService do
should_not_create_todo(user: guest, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'does not create directly addressed todo when tasks are marked as completed' do
+ it "does not create directly addressed todo when tasks are marked as completed" do
addressed_mr_assigned.update(description: "#{directly_addressed}\n- [x] Task 1\n- [X] Task 2")
service.update_merge_request(addressed_mr_assigned, author)
@@ -640,16 +640,16 @@ describe TodoService do
should_not_create_todo(user: guest, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'does not raise an error when description not change' do
- mr_assigned.update(title: 'Sample')
+ it "does not raise an error when description not change" do
+ mr_assigned.update(title: "Sample")
expect { service.update_merge_request(mr_assigned, author) }.not_to raise_error
end
end
end
- describe '#close_merge_request' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#close_merge_request" do
+ it "marks related pending todos to the target for the user as done" do
first_todo = create(:todo, :assigned, user: john_doe, project: project, target: mr_assigned, author: author)
second_todo = create(:todo, :assigned, user: john_doe, project: project, target: mr_assigned, author: author)
service.close_merge_request(mr_assigned, john_doe)
@@ -659,40 +659,40 @@ describe TodoService do
end
end
- describe '#reassigned_merge_request' do
- it 'creates a pending todo for new assignee' do
+ describe "#reassigned_merge_request" do
+ it "creates a pending todo for new assignee" do
mr_unassigned.update_attribute(:assignee, john_doe)
service.reassigned_merge_request(mr_unassigned, author)
should_create_todo(user: john_doe, target: mr_unassigned, action: Todo::ASSIGNED)
end
- it 'does not create a todo if unassigned' do
+ it "does not create a todo if unassigned" do
mr_assigned.update_attribute(:assignee, nil)
should_not_create_any_todo { service.reassigned_merge_request(mr_assigned, author) }
end
- it 'creates a todo if new assignee is the current user' do
+ it "creates a todo if new assignee is the current user" do
mr_assigned.update_attribute(:assignee, john_doe)
service.reassigned_merge_request(mr_assigned, john_doe)
should_create_todo(user: john_doe, target: mr_assigned, author: john_doe, action: Todo::ASSIGNED)
end
- it 'does not create a todo for guests' do
+ it "does not create a todo for guests" do
service.reassigned_merge_request(mr_assigned, author)
should_not_create_todo(user: guest, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'does not create a directly addressed todo for guests' do
+ it "does not create a directly addressed todo for guests" do
service.reassigned_merge_request(addressed_mr_assigned, author)
should_not_create_todo(user: guest, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
end
end
- describe '#merge_merge_request' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#merge_merge_request" do
+ it "marks related pending todos to the target for the user as done" do
first_todo = create(:todo, :assigned, user: john_doe, project: project, target: mr_assigned, author: author)
second_todo = create(:todo, :assigned, user: john_doe, project: project, target: mr_assigned, author: author)
service.merge_merge_request(mr_assigned, john_doe)
@@ -701,19 +701,19 @@ describe TodoService do
expect(second_todo.reload).to be_done
end
- it 'does not create todo for guests' do
+ it "does not create todo for guests" do
service.merge_merge_request(mr_assigned, john_doe)
should_not_create_todo(user: guest, target: mr_assigned, action: Todo::MENTIONED)
end
- it 'does not create directly addressed todo for guests' do
+ it "does not create directly addressed todo for guests" do
service.merge_merge_request(addressed_mr_assigned, john_doe)
should_not_create_todo(user: guest, target: addressed_mr_assigned, action: Todo::DIRECTLY_ADDRESSED)
end
end
- describe '#new_award_emoji' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#new_award_emoji" do
+ it "marks related pending todos to the target for the user as done" do
todo = create(:todo, user: john_doe, project: project, target: mr_assigned, author: author)
service.new_award_emoji(mr_assigned, john_doe)
@@ -721,14 +721,14 @@ describe TodoService do
end
end
- describe '#merge_request_build_failed' do
+ describe "#merge_request_build_failed" do
let(:merge_participants) { [mr_unassigned.author, admin] }
before do
allow(mr_unassigned).to receive(:merge_participants).and_return(merge_participants)
end
- it 'creates a pending todo for each merge_participant' do
+ it "creates a pending todo for each merge_participant" do
service.merge_request_build_failed(mr_unassigned)
merge_participants.each do |participant|
@@ -737,8 +737,8 @@ describe TodoService do
end
end
- describe '#merge_request_push' do
- it 'marks related pending todos to the target for the user as done' do
+ describe "#merge_request_push" do
+ it "marks related pending todos to the target for the user as done" do
first_todo = create(:todo, :build_failed, user: author, project: project, target: mr_assigned, author: john_doe)
second_todo = create(:todo, :build_failed, user: john_doe, project: project, target: mr_assigned, author: john_doe)
service.merge_request_push(mr_assigned, author)
@@ -748,14 +748,14 @@ describe TodoService do
end
end
- describe '#merge_request_became_unmergeable' do
+ describe "#merge_request_became_unmergeable" do
let(:merge_participants) { [admin, create(:user)] }
before do
allow(mr_unassigned).to receive(:merge_participants).and_return(merge_participants)
end
- it 'creates a pending todo for each merge_participant' do
+ it "creates a pending todo for each merge_participant" do
mr_unassigned.update(merge_when_pipeline_succeeds: true, merge_user: admin)
service.merge_request_became_unmergeable(mr_unassigned)
@@ -765,40 +765,40 @@ describe TodoService do
end
end
- describe '#mark_todo' do
- it 'creates a todo from a merge request' do
+ describe "#mark_todo" do
+ it "creates a todo from a merge request" do
service.mark_todo(mr_unassigned, author)
should_create_todo(user: author, target: mr_unassigned, action: Todo::MARKED)
end
end
- describe '#new_note' do
+ describe "#new_note" do
let(:project) { create(:project, :repository) }
let(:mention) { john_doe.to_reference }
let(:diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "Hey #{mention}") }
let(:addressed_diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "#{mention}, hey!") }
let(:legacy_diff_note_on_merge_request) { create(:legacy_diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "Hey #{mention}") }
- it 'creates a todo for mentioned user on new diff note' do
+ it "creates a todo for mentioned user on new diff note" do
service.new_note(diff_note_on_merge_request, author)
should_create_todo(user: john_doe, target: mr_unassigned, author: author, action: Todo::MENTIONED, note: diff_note_on_merge_request)
end
- it 'creates a directly addressed todo for addressed user on new diff note' do
+ it "creates a directly addressed todo for addressed user on new diff note" do
service.new_note(addressed_diff_note_on_merge_request, author)
should_create_todo(user: john_doe, target: mr_unassigned, author: author, action: Todo::DIRECTLY_ADDRESSED, note: addressed_diff_note_on_merge_request)
end
- it 'creates a todo for mentioned user on legacy diff note' do
+ it "creates a todo for mentioned user on legacy diff note" do
service.new_note(legacy_diff_note_on_merge_request, author)
should_create_todo(user: john_doe, target: mr_unassigned, author: author, action: Todo::MENTIONED, note: legacy_diff_note_on_merge_request)
end
- it 'does not create todo for guests' do
+ it "does not create todo for guests" do
note_on_merge_request = create :note_on_merge_request, project: project, noteable: mr_assigned, note: mentions
service.new_note(note_on_merge_request, author)
@@ -807,12 +807,12 @@ describe TodoService do
end
end
- describe '#update_note' do
+ describe "#update_note" do
let(:noteable) { create(:issue, project: project) }
let(:note) { create(:note, project: project, note: mentions, noteable: noteable) }
- let(:addressed_note) { create(:note, project: project, note: "#{directly_addressed}", noteable: noteable) }
+ let(:addressed_note) { create(:note, project: project, note: directly_addressed.to_s, noteable: noteable) }
- it 'creates a todo for each valid mentioned user not included in skip_users' do
+ it "creates a todo for each valid mentioned user not included in skip_users" do
service.update_note(note, author, skip_users)
should_create_todo(user: member, target: noteable, action: Todo::MENTIONED)
@@ -823,7 +823,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: noteable, action: Todo::MENTIONED)
end
- it 'creates a todo for each valid user not included in skip_users based on the type of mention' do
+ it "creates a todo for each valid user not included in skip_users based on the type of mention" do
note.update(note: directly_addressed_and_mentioned)
service.update_note(note, author, skip_users)
@@ -834,7 +834,7 @@ describe TodoService do
should_not_create_todo(user: skipped, target: noteable)
end
- it 'creates a directly addressed todo for each valid addressed user not included in skip_users' do
+ it "creates a directly addressed todo for each valid addressed user not included in skip_users" do
service.update_note(addressed_note, author, skip_users)
should_create_todo(user: member, target: noteable, action: Todo::DIRECTLY_ADDRESSED)
@@ -845,32 +845,32 @@ describe TodoService do
should_not_create_todo(user: skipped, target: noteable, action: Todo::DIRECTLY_ADDRESSED)
end
- it 'does not create a todo if user was already mentioned and todo is pending' do
+ it "does not create a todo if user was already mentioned and todo is pending" do
create(:todo, :mentioned, user: member, project: project, target: noteable, author: author)
expect { service.update_note(note, author, skip_users) }.not_to change(member.todos, :count)
end
- it 'does not create a todo if user was already mentioned and todo is done' do
+ it "does not create a todo if user was already mentioned and todo is done" do
create(:todo, :mentioned, :done, user: skipped, project: project, target: noteable, author: author)
expect { service.update_note(note, author, skip_users) }.not_to change(skipped.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is pending' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is pending" do
create(:todo, :directly_addressed, user: member, project: project, target: noteable, author: author)
expect { service.update_note(addressed_note, author, skip_users) }.not_to change(member.todos, :count)
end
- it 'does not create a directly addressed todo if user was already mentioned or addressed and todo is done' do
+ it "does not create a directly addressed todo if user was already mentioned or addressed and todo is done" do
create(:todo, :directly_addressed, :done, user: skipped, project: project, target: noteable, author: author)
expect { service.update_note(addressed_note, author, skip_users) }.not_to change(skipped.todos, :count)
end
end
- it 'updates cached counts when a todo is created' do
+ it "updates cached counts when a todo is created" do
issue = create(:issue, project: project, assignees: [john_doe], author: author, description: mentions)
expect(john_doe.todos_pending_count).to eq(0)
@@ -882,44 +882,44 @@ describe TodoService do
expect(john_doe.todos_pending_count).to eq(1)
end
- describe '#mark_todos_as_done' do
+ describe "#mark_todos_as_done" do
let(:issue) { create(:issue, project: project, author: author, assignees: [john_doe]) }
let(:another_issue) { create(:issue, project: project, author: author, assignees: [john_doe]) }
- it 'marks a relation of todos as done' do
+ it "marks a relation of todos as done" do
create(:todo, :mentioned, user: john_doe, target: issue, project: project)
todos = TodosFinder.new(john_doe, {}).execute
expect { described_class.new.mark_todos_as_done(todos, john_doe) }
- .to change { john_doe.todos.done.count }.from(0).to(1)
+ .to change { john_doe.todos.done.count }.from(0).to(1)
end
- it 'marks an array of todos as done' do
+ it "marks an array of todos as done" do
todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project)
todos = TodosFinder.new(john_doe, {}).execute
expect { described_class.new.mark_todos_as_done(todos, john_doe) }
- .to change { todo.reload.state }.from('pending').to('done')
+ .to change { todo.reload.state }.from("pending").to("done")
end
- it 'returns the ids of updated todos' do # Needed on API
+ it "returns the ids of updated todos" do # Needed on API
todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project)
todos = TodosFinder.new(john_doe, {}).execute
expect(described_class.new.mark_todos_as_done(todos, john_doe)).to eq([todo.id])
end
- context 'when some of the todos are done already' do
+ context "when some of the todos are done already" do
let!(:first_todo) { create(:todo, :mentioned, user: john_doe, target: issue, project: project) }
let!(:second_todo) { create(:todo, :mentioned, user: john_doe, target: another_issue, project: project) }
- it 'returns the ids of those still pending' do
+ it "returns the ids of those still pending" do
described_class.new.mark_pending_todos_as_done(issue, john_doe)
expect(described_class.new.mark_todos_as_done(Todo.all, john_doe)).to eq([second_todo.id])
end
- it 'returns an empty array if all are done' do
+ it "returns an empty array if all are done" do
described_class.new.mark_pending_todos_as_done(issue, john_doe)
described_class.new.mark_pending_todos_as_done(another_issue, john_doe)
@@ -928,11 +928,11 @@ describe TodoService do
end
end
- describe '#mark_todos_as_done_by_ids' do
+ describe "#mark_todos_as_done_by_ids" do
let(:issue) { create(:issue, project: project, author: author, assignees: [john_doe]) }
let(:another_issue) { create(:issue, project: project, author: author, assignees: [john_doe]) }
- it 'marks an array of todo ids as done' do
+ it "marks an array of todo ids as done" do
todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project)
another_todo = create(:todo, :mentioned, user: john_doe, target: another_issue, project: project)
@@ -940,14 +940,14 @@ describe TodoService do
.to change { john_doe.todos.done.count }.from(0).to(2)
end
- it 'marks a single todo id as done' do
+ it "marks a single todo id as done" do
todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project)
expect { described_class.new.mark_todos_as_done_by_ids(todo.id, john_doe) }
- .to change { todo.reload.state }.from('pending').to('done')
+ .to change { todo.reload.state }.from("pending").to("done")
end
- it 'caches the number of todos of a user', :use_clean_rails_memory_store_caching do
+ it "caches the number of todos of a user", :use_clean_rails_memory_store_caching do
create(:todo, :mentioned, user: john_doe, target: issue, project: project)
todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project)
diff --git a/spec/services/todos/destroy/confidential_issue_service_spec.rb b/spec/services/todos/destroy/confidential_issue_service_spec.rb
index 3294f7509aa..a03e363a233 100644
--- a/spec/services/todos/destroy/confidential_issue_service_spec.rb
+++ b/spec/services/todos/destroy/confidential_issue_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Todos::Destroy::ConfidentialIssueService do
let(:project) { create(:project, :public) }
@@ -16,7 +16,7 @@ describe Todos::Destroy::ConfidentialIssueService do
let!(:todo_issue_guest) { create(:todo, user: guest, target: issue, project: project) }
let!(:todo_another_non_member) { create(:todo, user: user, project: project) }
- describe '#execute' do
+ describe "#execute" do
before do
project.add_developer(project_member)
project.add_guest(guest)
@@ -24,18 +24,18 @@ describe Todos::Destroy::ConfidentialIssueService do
subject { described_class.new(issue.id).execute }
- context 'when provided issue is confidential' do
+ context "when provided issue is confidential" do
before do
issue.update!(confidential: true)
end
- it 'removes issue todos for users who can not access the confidential issue' do
+ it "removes issue todos for users who can not access the confidential issue" do
expect { subject }.to change { Todo.count }.from(6).to(4)
end
end
- context 'when provided issue is not confidential' do
- it 'does not remove any todos' do
+ context "when provided issue is not confidential" do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
diff --git a/spec/services/todos/destroy/entity_leave_service_spec.rb b/spec/services/todos/destroy/entity_leave_service_spec.rb
index 4b238280848..af068148267 100644
--- a/spec/services/todos/destroy/entity_leave_service_spec.rb
+++ b/spec/services/todos/destroy/entity_leave_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Todos::Destroy::EntityLeaveService do
let(:group) { create(:group, :private) }
@@ -14,121 +14,121 @@ describe Todos::Destroy::EntityLeaveService do
let!(:todo_issue_user2) { create(:todo, user: user2, target: issue, project: project) }
let!(:todo_group_user2) { create(:todo, user: user2, group: group) }
- describe '#execute' do
- context 'when a user leaves a project' do
- subject { described_class.new(user.id, project.id, 'Project').execute }
+ describe "#execute" do
+ context "when a user leaves a project" do
+ subject { described_class.new(user.id, project.id, "Project").execute }
- context 'when project is private' do
- it 'removes project todos for the provided user' do
+ context "when project is private" do
+ it "removes project todos for the provided user" do
expect { subject }.to change { Todo.count }.from(5).to(3)
expect(user.todos).to match_array([todo_group_user])
expect(user2.todos).to match_array([todo_issue_user2, todo_group_user2])
end
- context 'when the user is member of the project' do
+ context "when the user is member of the project" do
before do
project.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when the user is a project guest' do
+ context "when the user is a project guest" do
before do
project.add_guest(user)
end
- it 'removes only confidential issues todos' do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
- context 'when the user is member of a parent group' do
+ context "when the user is member of a parent group" do
before do
group.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when the user is guest of a parent group' do
+ context "when the user is guest of a parent group" do
before do
project.add_guest(user)
end
- it 'removes only confidential issues todos' do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
end
- context 'when project is not private' do
+ context "when project is not private" do
before do
group.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- context 'confidential issues' do
- context 'when a user is not an author of confidential issue' do
- it 'removes only confidential issues todos' do
+ context "confidential issues" do
+ context "when a user is not an author of confidential issue" do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
- context 'when a user is an author of confidential issue' do
+ context "when a user is an author of confidential issue" do
before do
issue.update!(author: user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when a user is an assignee of confidential issue' do
+ context "when a user is an assignee of confidential issue" do
before do
issue.assignees << user
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when a user is a project guest' do
+ context "when a user is a project guest" do
before do
project.add_guest(user)
end
- it 'removes only confidential issues todos' do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
- context 'when a user is a project guest but group developer' do
+ context "when a user is a project guest but group developer" do
before do
project.add_guest(user)
group.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
end
- context 'feature visibility check' do
- context 'when issues are visible only to project members' do
+ context "feature visibility check" do
+ context "when issues are visible only to project members" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only users issue todos' do
+ it "removes only users issue todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
@@ -136,38 +136,38 @@ describe Todos::Destroy::EntityLeaveService do
end
end
- context 'when a user leaves a group' do
- subject { described_class.new(user.id, group.id, 'Group').execute }
+ context "when a user leaves a group" do
+ subject { described_class.new(user.id, group.id, "Group").execute }
- context 'when group is private' do
- it 'removes group and subproject todos for the user' do
+ context "when group is private" do
+ it "removes group and subproject todos for the user" do
expect { subject }.to change { Todo.count }.from(5).to(2)
expect(user.todos).to be_empty
expect(user2.todos).to match_array([todo_issue_user2, todo_group_user2])
end
- context 'when the user is member of the group' do
+ context "when the user is member of the group" do
before do
group.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when the user is member of the group project but not the group' do
+ context "when the user is member of the group project but not the group" do
before do
project.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'with nested groups', :nested_groups do
+ context "with nested groups", :nested_groups do
let(:subgroup) { create(:group, :private, parent: group) }
let(:subgroup2) { create(:group, :private, parent: group) }
let(:subproject) { create(:project, group: subgroup) }
@@ -180,8 +180,8 @@ describe Todos::Destroy::EntityLeaveService do
let!(:todo_subproject_user2) { create(:todo, user: user2, project: subproject) }
let!(:todo_subpgroup_user2) { create(:todo, user: user2, group: subgroup) }
- context 'when the user is not a member of any groups/projects' do
- it 'removes todos for the user including subprojects todos' do
+ context "when the user is not a member of any groups/projects" do
+ it "removes todos for the user including subprojects todos" do
expect { subject }.to change { Todo.count }.from(11).to(4)
expect(user.todos).to be_empty
@@ -192,24 +192,24 @@ describe Todos::Destroy::EntityLeaveService do
end
end
- context 'when the user is member of a parent group' do
+ context "when the user is member of a parent group" do
before do
parent_group = create(:group)
group.update!(parent: parent_group)
parent_group.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when the user is member of a subgroup' do
+ context "when the user is member of a subgroup" do
before do
subgroup.add_developer(user)
end
- it 'does not remove group and subproject todos' do
+ it "does not remove group and subproject todos" do
expect { subject }.to change { Todo.count }.from(11).to(7)
expect(user.todos).to match_array([todo_group_user, todo_subgroup_user, todo_subproject_user])
@@ -220,12 +220,12 @@ describe Todos::Destroy::EntityLeaveService do
end
end
- context 'when the user is member of a child project' do
+ context "when the user is member of a child project" do
before do
subproject.add_developer(user)
end
- it 'does not remove subproject and group todos' do
+ it "does not remove subproject and group todos" do
expect { subject }.to change { Todo.count }.from(11).to(7)
expect(user.todos).to match_array([todo_subgroup_user, todo_group_user, todo_subproject_user])
@@ -238,51 +238,51 @@ describe Todos::Destroy::EntityLeaveService do
end
end
- context 'when group is not private' do
+ context "when group is not private" do
before do
group.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
project.update!(visibility_level: Gitlab::VisibilityLevel::INTERNAL)
end
- context 'when user is not member' do
- it 'removes only confidential issues todos' do
+ context "when user is not member" do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
- context 'when user is a project guest' do
+ context "when user is a project guest" do
before do
project.add_guest(user)
end
- it 'removes only confidential issues todos' do
+ it "removes only confidential issues todos" do
expect { subject }.to change { Todo.count }.from(5).to(4)
end
end
- context 'when user is a project guest & group developer' do
+ context "when user is a project guest & group developer" do
before do
project.add_guest(user)
group.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
end
end
- context 'when entity type is not valid' do
- it 'raises an exception' do
- expect { described_class.new(user.id, group.id, 'GroupWrongly').execute }
+ context "when entity type is not valid" do
+ it "raises an exception" do
+ expect { described_class.new(user.id, group.id, "GroupWrongly").execute }
.to raise_error(ArgumentError)
end
end
- context 'when entity was not found' do
- it 'does not remove any todos' do
- expect { described_class.new(user.id, 999999, 'Group').execute }
+ context "when entity was not found" do
+ it "does not remove any todos" do
+ expect { described_class.new(user.id, 999999, "Group").execute }
.not_to change { Todo.count }
end
end
diff --git a/spec/services/todos/destroy/group_private_service_spec.rb b/spec/services/todos/destroy/group_private_service_spec.rb
index 5cefbdd35ab..548cd21a3bd 100644
--- a/spec/services/todos/destroy/group_private_service_spec.rb
+++ b/spec/services/todos/destroy/group_private_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Todos::Destroy::GroupPrivateService do
let(:group) { create(:group, :public) }
@@ -12,7 +12,7 @@ describe Todos::Destroy::GroupPrivateService do
let!(:todo_group_member) { create(:todo, user: group_member, group: group) }
let!(:todo_project_member) { create(:todo, user: project_member, group: group) }
- describe '#execute' do
+ describe "#execute" do
before do
group.add_developer(group_member)
project.add_developer(project_member)
@@ -20,12 +20,12 @@ describe Todos::Destroy::GroupPrivateService do
subject { described_class.new(group.id).execute }
- context 'when a group set to private' do
+ context "when a group set to private" do
before do
group.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'removes todos only for users who are not group users' do
+ it "removes todos only for users who are not group users" do
expect { subject }.to change { Todo.count }.from(4).to(2)
expect(user.todos).to be_empty
@@ -33,7 +33,7 @@ describe Todos::Destroy::GroupPrivateService do
expect(project_member.todos).to match_array([todo_project_member])
end
- context 'with nested groups', :nested_groups do
+ context "with nested groups", :nested_groups do
let(:parent_group) { create(:group) }
let(:subgroup) { create(:group, :private, parent: group) }
let(:subproject) { create(:project, group: subgroup) }
@@ -54,14 +54,14 @@ describe Todos::Destroy::GroupPrivateService do
subproject.add_developer(subgproject_member)
end
- it 'removes todos only for users who are not group users' do
+ it "removes todos only for users who are not group users" do
expect { subject }.to change { Todo.count }.from(7).to(5)
end
end
end
- context 'when group is not private' do
- it 'does not remove any todos' do
+ context "when group is not private" do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
diff --git a/spec/services/todos/destroy/private_features_service_spec.rb b/spec/services/todos/destroy/private_features_service_spec.rb
index be8b5bb3979..513dc930570 100644
--- a/spec/services/todos/destroy/private_features_service_spec.rb
+++ b/spec/services/todos/destroy/private_features_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Todos::Destroy::PrivateFeaturesService do
let(:project) { create(:project, :public) }
@@ -22,37 +22,37 @@ describe Todos::Destroy::PrivateFeaturesService do
project.add_developer(project_member)
end
- context 'when user_id is provided' do
+ context "when user_id is provided" do
subject { described_class.new(project.id, user.id).execute }
- context 'when all feaures have same visibility as the project' do
- it 'removes only user issue todos' do
+ context "when all feaures have same visibility as the project" do
+ it "removes only user issue todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when issues are visible only to project members but the user is a member' do
+ context "when issues are visible only to project members but the user is a member" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
project.add_developer(user)
end
- it 'does not remove any todos' do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when issues are visible only to project members' do
+ context "when issues are visible only to project members" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only user issue todos' do
+ it "removes only user issue todos" do
expect { subject }.to change { Todo.count }.from(9).to(8)
end
end
- context 'when mrs, builds and repository are visible only to project members' do
+ context "when mrs, builds and repository are visible only to project members" do
before do
# builds and merge requests cannot have higher visibility than repository
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
@@ -60,53 +60,53 @@ describe Todos::Destroy::PrivateFeaturesService do
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only user mr and commit todos' do
+ it "removes only user mr and commit todos" do
expect { subject }.to change { Todo.count }.from(9).to(7)
end
end
- context 'when mrs are visible only to project members' do
+ context "when mrs are visible only to project members" do
before do
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only user merge request todo' do
+ it "removes only user merge request todo" do
expect { subject }.to change { Todo.count }.from(9).to(8)
end
end
- context 'when mrs and issues are visible only to project members' do
+ context "when mrs and issues are visible only to project members" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only user merge request and issue todos' do
+ it "removes only user merge request and issue todos" do
expect { subject }.to change { Todo.count }.from(9).to(7)
end
end
end
- context 'when user_id is not provided' do
+ context "when user_id is not provided" do
subject { described_class.new(project.id).execute }
- context 'when all feaures have same visibility as the project' do
- it 'does not remove any todos' do
+ context "when all feaures have same visibility as the project" do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
- context 'when issues are visible only to project members' do
+ context "when issues are visible only to project members" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only non members issue todos' do
+ it "removes only non members issue todos" do
expect { subject }.to change { Todo.count }.from(9).to(7)
end
end
- context 'when mrs, builds and repository are visible only to project members' do
+ context "when mrs, builds and repository are visible only to project members" do
before do
# builds and merge requests cannot have higher visibility than repository
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
@@ -114,28 +114,28 @@ describe Todos::Destroy::PrivateFeaturesService do
project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only non members mr and commit todos' do
+ it "removes only non members mr and commit todos" do
expect { subject }.to change { Todo.count }.from(9).to(5)
end
end
- context 'when mrs are visible only to project members' do
+ context "when mrs are visible only to project members" do
before do
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only non members merge request todos' do
+ it "removes only non members merge request todos" do
expect { subject }.to change { Todo.count }.from(9).to(7)
end
end
- context 'when mrs and issues are visible only to project members' do
+ context "when mrs and issues are visible only to project members" do
before do
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
end
- it 'removes only non members merge request and issue todos' do
+ it "removes only non members merge request and issue todos" do
expect { subject }.to change { Todo.count }.from(9).to(5)
end
end
diff --git a/spec/services/todos/destroy/project_private_service_spec.rb b/spec/services/todos/destroy/project_private_service_spec.rb
index 128d3487514..7bd59b409ac 100644
--- a/spec/services/todos/destroy/project_private_service_spec.rb
+++ b/spec/services/todos/destroy/project_private_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Todos::Destroy::ProjectPrivateService do
let(:group) { create(:group, :public) }
@@ -12,7 +12,7 @@ describe Todos::Destroy::ProjectPrivateService do
let!(:todo_member) { create(:todo, user: project_member, project: project) }
let!(:todo_group_member) { create(:todo, user: group_member, project: project) }
- describe '#execute' do
+ describe "#execute" do
before do
project.add_developer(project_member)
group.add_developer(group_member)
@@ -20,12 +20,12 @@ describe Todos::Destroy::ProjectPrivateService do
subject { described_class.new(project.id).execute }
- context 'when a project set to private' do
+ context "when a project set to private" do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'removes issue todos for a user who is not a member' do
+ it "removes issue todos for a user who is not a member" do
expect { subject }.to change { Todo.count }.from(4).to(2)
expect(user.todos).to be_empty
@@ -34,8 +34,8 @@ describe Todos::Destroy::ProjectPrivateService do
end
end
- context 'when project is not private' do
- it 'does not remove any todos' do
+ context "when project is not private" do
+ it "does not remove any todos" do
expect { subject }.not_to change { Todo.count }
end
end
diff --git a/spec/services/update_deployment_service_spec.rb b/spec/services/update_deployment_service_spec.rb
index 3c55dd9659a..91a3d30e2a9 100644
--- a/spec/services/update_deployment_service_spec.rb
+++ b/spec/services/update_deployment_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe UpdateDeploymentService do
let(:user) { create(:user) }
- let(:options) { { name: 'production' } }
+ let(:options) { {name: "production"} }
let(:job) do
create(:ci_build,
- ref: 'master',
+ ref: "master",
tag: false,
- environment: 'production',
- options: { environment: options },
+ environment: "production",
+ options: {environment: options},
project: project)
end
@@ -22,12 +22,12 @@ describe UpdateDeploymentService do
job.success! # Create/Succeed deployment
end
- describe '#execute' do
+ describe "#execute" do
subject { service.execute }
let(:store) { Gitlab::EtagCaching::Store.new }
- it 'invalidates the environment etag cache' do
+ it "invalidates the environment etag cache" do
old_value = store.get(environment.etag_cache_key)
subject
@@ -35,7 +35,7 @@ describe UpdateDeploymentService do
expect(store.get(environment.etag_cache_key)).not_to eq(old_value)
end
- it 'creates ref' do
+ it "creates ref" do
expect_any_instance_of(Repository)
.to receive(:create_ref)
.with(deployment.ref, deployment.send(:ref_path))
@@ -43,22 +43,22 @@ describe UpdateDeploymentService do
subject
end
- it 'updates merge request metrics' do
+ it "updates merge request metrics" do
expect_any_instance_of(Deployment)
.to receive(:update_merge_request_metrics!)
subject
end
- context 'when start action is defined' do
- let(:options) { { name: 'production', action: 'start' } }
+ context "when start action is defined" do
+ let(:options) { {name: "production", action: "start"} }
- context 'and environment is stopped' do
+ context "and environment is stopped" do
before do
environment.stop
end
- it 'makes environment available' do
+ it "makes environment available" do
subject
expect(environment.reload).to be_available
@@ -66,80 +66,80 @@ describe UpdateDeploymentService do
end
end
- context 'when variables are used' do
+ context "when variables are used" do
let(:options) do
- { name: 'review-apps/$CI_COMMIT_REF_NAME',
- url: 'http://$CI_COMMIT_REF_NAME.review-apps.gitlab.com' }
+ {name: "review-apps/$CI_COMMIT_REF_NAME",
+ url: "http://$CI_COMMIT_REF_NAME.review-apps.gitlab.com",}
end
before do
- environment.update(name: 'review-apps/master')
- job.update(environment: 'review-apps/$CI_COMMIT_REF_NAME')
+ environment.update(name: "review-apps/master")
+ job.update(environment: "review-apps/$CI_COMMIT_REF_NAME")
end
- it 'does not create a new environment' do
+ it "does not create a new environment" do
expect { subject }.not_to change { Environment.count }
end
- it 'updates external url' do
+ it "updates external url" do
subject
- expect(subject.environment.name).to eq('review-apps/master')
- expect(subject.environment.external_url).to eq('http://master.review-apps.gitlab.com')
+ expect(subject.environment.name).to eq("review-apps/master")
+ expect(subject.environment.external_url).to eq("http://master.review-apps.gitlab.com")
end
end
end
- describe '#expanded_environment_url' do
+ describe "#expanded_environment_url" do
subject { service.send(:expanded_environment_url) }
- context 'when yaml environment uses $CI_COMMIT_REF_NAME' do
+ context "when yaml environment uses $CI_COMMIT_REF_NAME" do
let(:job) do
create(:ci_build,
- ref: 'master',
- environment: 'production',
- project: project,
- options: { environment: { name: 'production', url: 'http://review/$CI_COMMIT_REF_NAME' } })
+ ref: "master",
+ environment: "production",
+ project: project,
+ options: {environment: {name: "production", url: "http://review/$CI_COMMIT_REF_NAME"}})
end
- it { is_expected.to eq('http://review/master') }
+ it { is_expected.to eq("http://review/master") }
end
- context 'when yaml environment uses $CI_ENVIRONMENT_SLUG' do
+ context "when yaml environment uses $CI_ENVIRONMENT_SLUG" do
let(:job) do
create(:ci_build,
- ref: 'master',
- environment: 'prod-slug',
- project: project,
- options: { environment: { name: 'prod-slug', url: 'http://review/$CI_ENVIRONMENT_SLUG' } })
+ ref: "master",
+ environment: "prod-slug",
+ project: project,
+ options: {environment: {name: "prod-slug", url: "http://review/$CI_ENVIRONMENT_SLUG"}})
end
- it { is_expected.to eq('http://review/prod-slug') }
+ it { is_expected.to eq("http://review/prod-slug") }
end
- context 'when yaml environment uses yaml_variables containing symbol keys' do
+ context "when yaml environment uses yaml_variables containing symbol keys" do
let(:job) do
create(:ci_build,
- yaml_variables: [{ key: :APP_HOST, value: 'host' }],
- environment: 'production',
- project: project,
- options: { environment: { name: 'production', url: 'http://review/$APP_HOST' } })
+ yaml_variables: [{key: :APP_HOST, value: "host"}],
+ environment: "production",
+ project: project,
+ options: {environment: {name: "production", url: "http://review/$APP_HOST"}})
end
- it { is_expected.to eq('http://review/host') }
+ it { is_expected.to eq("http://review/host") }
end
- context 'when yaml environment does not have url' do
- let(:job) { create(:ci_build, environment: 'staging', project: project) }
+ context "when yaml environment does not have url" do
+ let(:job) { create(:ci_build, environment: "staging", project: project) }
- it 'returns the external_url from persisted environment' do
+ it "returns the external_url from persisted environment" do
is_expected.to be_nil
end
end
end
describe "merge request metrics" do
- let(:merge_request) { create(:merge_request, target_branch: 'master', source_branch: 'feature', source_project: project) }
+ let(:merge_request) { create(:merge_request, target_branch: "master", source_branch: "feature", source_project: project) }
context "while updating the 'first_deployed_to_production_at' time" do
before do
@@ -153,13 +153,13 @@ describe UpdateDeploymentService do
expect(merge_request.reload.metrics.first_deployed_to_production_at).to be_like_time(deployment.finished_at)
end
- context 'when job deploys to staging' do
+ context "when job deploys to staging" do
let(:job) do
create(:ci_build,
- ref: 'master',
+ ref: "master",
tag: false,
- environment: 'staging',
- options: { environment: { name: 'staging' } },
+ environment: "staging",
+ options: {environment: {name: "staging"}},
project: project)
end
@@ -170,7 +170,7 @@ describe UpdateDeploymentService do
end
end
- it 'does not raise errors if the merge request does not have a metrics record' do
+ it "does not raise errors if the merge request does not have a metrics record" do
merge_request.metrics.destroy
expect(merge_request.reload.metrics).to be_nil
diff --git a/spec/services/update_merge_request_metrics_service_spec.rb b/spec/services/update_merge_request_metrics_service_spec.rb
index 812dd42934d..97ae49f40bb 100644
--- a/spec/services/update_merge_request_metrics_service_spec.rb
+++ b/spec/services/update_merge_request_metrics_service_spec.rb
@@ -1,10 +1,10 @@
-require 'rails_helper'
+require "rails_helper"
describe MergeRequestMetricsService do
let(:metrics) { create(:merge_request).metrics }
- describe '#merge' do
- it 'updates metrics' do
+ describe "#merge" do
+ it "updates metrics" do
user = create(:user)
service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now)
@@ -16,8 +16,8 @@ describe MergeRequestMetricsService do
end
end
- describe '#close' do
- it 'updates metrics' do
+ describe "#close" do
+ it "updates metrics" do
user = create(:user)
service = described_class.new(metrics)
event = double(Event, author_id: user.id, created_at: Time.now)
@@ -29,8 +29,8 @@ describe MergeRequestMetricsService do
end
end
- describe '#reopen' do
- it 'updates metrics' do
+ describe "#reopen" do
+ it "updates metrics" do
service = described_class.new(metrics)
service.reopen
diff --git a/spec/services/update_snippet_service_spec.rb b/spec/services/update_snippet_service_spec.rb
index ef535c5cf1f..67522c6d01c 100644
--- a/spec/services/update_snippet_service_spec.rb
+++ b/spec/services/update_snippet_service_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe UpdateSnippetService do
before do
@user = create :user
@admin = create :user, admin: true
@opts = {
- title: 'Test snippet',
- file_name: 'snippet.rb',
+ title: "Test snippet",
+ file_name: "snippet.rb",
content: 'puts "hello world"',
- visibility_level: Gitlab::VisibilityLevel::PRIVATE
+ visibility_level: Gitlab::VisibilityLevel::PRIVATE,
}
end
- context 'When public visibility is restricted' do
+ context "When public visibility is restricted" do
before do
stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC])
@@ -20,17 +20,17 @@ describe UpdateSnippetService do
@opts.merge!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
end
- it 'non-admins should not be able to update to public visibility' do
+ it "non-admins should not be able to update to public visibility" do
old_visibility = @snippet.visibility_level
update_snippet(@project, @user, @snippet, @opts)
expect(@snippet.errors.messages).to have_key(:visibility_level)
expect(@snippet.errors.messages[:visibility_level].first).to(
- match('has been restricted')
+ match("has been restricted")
)
expect(@snippet.visibility_level).to eq(old_visibility)
end
- it 'admins should be able to update to pubic visibility' do
+ it "admins should be able to update to pubic visibility" do
old_visibility = @snippet.visibility_level
update_snippet(@project, @admin, @snippet, @opts)
expect(@snippet.visibility_level).not_to eq(old_visibility)
diff --git a/spec/services/upload_service_spec.rb b/spec/services/upload_service_spec.rb
index 4a809d5bf18..21d0cf68cfa 100644
--- a/spec/services/upload_service_spec.rb
+++ b/spec/services/upload_service_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe UploadService do
- describe 'File service' do
+ describe "File service" do
before do
@user = create(:user)
@project = create(:project, creator_id: @user.id, namespace: @user.namespace)
end
- context 'for valid gif file' do
+ context "for valid gif file" do
before do
- gif = fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif')
+ gif = fixture_file_upload("spec/fixtures/banana_sample.gif", "image/gif")
@link_to_file = upload_file(@project, gif)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file).to have_value('banana_sample') }
- it { expect(@link_to_file[:url]).to match('banana_sample.gif') }
+ it { expect(@link_to_file).to have_value("banana_sample") }
+ it { expect(@link_to_file[:url]).to match("banana_sample.gif") }
end
- context 'for valid png file' do
+ context "for valid png file" do
before do
- png = fixture_file_upload('spec/fixtures/dk.png',
- 'image/png')
+ png = fixture_file_upload("spec/fixtures/dk.png",
+ "image/png")
@link_to_file = upload_file(@project, png)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file).to have_value('dk') }
- it { expect(@link_to_file[:url]).to match('dk.png') }
+ it { expect(@link_to_file).to have_value("dk") }
+ it { expect(@link_to_file[:url]).to match("dk.png") }
end
- context 'for valid jpg file' do
+ context "for valid jpg file" do
before do
- jpg = fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
+ jpg = fixture_file_upload("spec/fixtures/rails_sample.jpg", "image/jpg")
@link_to_file = upload_file(@project, jpg)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file).to have_value('rails_sample') }
- it { expect(@link_to_file[:url]).to match('rails_sample.jpg') }
+ it { expect(@link_to_file).to have_value("rails_sample") }
+ it { expect(@link_to_file[:url]).to match("rails_sample.jpg") }
end
- context 'for txt file' do
+ context "for txt file" do
before do
- txt = fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain')
+ txt = fixture_file_upload("spec/fixtures/doc_sample.txt", "text/plain")
@link_to_file = upload_file(@project, txt)
end
it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) }
- it { expect(@link_to_file).to have_value('doc_sample.txt') }
- it { expect(@link_to_file[:url]).to match('doc_sample.txt') }
+ it { expect(@link_to_file).to have_value("doc_sample.txt") }
+ it { expect(@link_to_file[:url]).to match("doc_sample.txt") }
end
- context 'for too large a file' do
+ context "for too large a file" do
before do
- txt = fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain')
+ txt = fixture_file_upload("spec/fixtures/doc_sample.txt", "text/plain")
allow(txt).to receive(:size) { 1000.megabytes.to_i }
@link_to_file = upload_file(@project, txt)
end
diff --git a/spec/services/user_project_access_changed_service_spec.rb b/spec/services/user_project_access_changed_service_spec.rb
index 87a90378e2b..688d2e91da4 100644
--- a/spec/services/user_project_access_changed_service_spec.rb
+++ b/spec/services/user_project_access_changed_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe UserProjectAccessChangedService do
- describe '#execute' do
- it 'schedules the user IDs' do
+ describe "#execute" do
+ it "schedules the user IDs" do
expect(AuthorizedProjectsWorker).to receive(:bulk_perform_and_wait)
.with([[1], [2]])
described_class.new([1, 2]).execute
end
- it 'permits non-blocking operation' do
+ it "permits non-blocking operation" do
expect(AuthorizedProjectsWorker).to receive(:bulk_perform_async)
.with([[1], [2]])
diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb
index 3c0a4ac8e18..d9b55fc6af5 100644
--- a/spec/services/users/activity_service_spec.rb
+++ b/spec/services/users/activity_service_spec.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::ActivityService do
include ExclusiveLeaseHelpers
let(:user) { create(:user, last_activity_on: last_activity_on) }
- subject { described_class.new(user, 'type') }
+ subject { described_class.new(user, "type") }
- describe '#execute', :clean_gitlab_redis_shared_state do
- context 'when last activity is nil' do
+ describe "#execute", :clean_gitlab_redis_shared_state do
+ context "when last activity is nil" do
let(:last_activity_on) { nil }
- it 'updates last_activity_on for the user' do
+ it "updates last_activity_on for the user" do
expect { subject.execute }
.to change(user, :last_activity_on).from(last_activity_on).to(Date.today)
end
end
- context 'when last activity is in the past' do
+ context "when last activity is in the past" do
let(:last_activity_on) { Date.today - 1.week }
- it 'updates last_activity_on for the user' do
+ it "updates last_activity_on for the user" do
expect { subject.execute }
.to change(user, :last_activity_on)
- .from(last_activity_on)
- .to(Date.today)
+ .from(last_activity_on)
+ .to(Date.today)
end
- it 'tries to obtain ExclusiveLease' do
+ it "tries to obtain ExclusiveLease" do
expect(Gitlab::ExclusiveLease).to receive(:new).and_call_original
subject.execute
end
end
- context 'when a bad object is passed' do
- let(:fake_object) { double(username: 'hello') }
+ context "when a bad object is passed" do
+ let(:fake_object) { double(username: "hello") }
- it 'does not record activity' do
- service = described_class.new(fake_object, 'pull')
+ it "does not record activity" do
+ service = described_class.new(fake_object, "pull")
expect(service).not_to receive(:record_activity)
@@ -46,36 +46,36 @@ describe Users::ActivityService do
end
end
- context 'when last activity is today' do
+ context "when last activity is today" do
let(:last_activity_on) { Date.today }
- it 'does not update last_activity_on' do
+ it "does not update last_activity_on" do
expect { subject.execute }.not_to change(user, :last_activity_on)
end
- it 'does not try to obtain ExclusiveLease' do
+ it "does not try to obtain ExclusiveLease" do
expect(Gitlab::ExclusiveLease).not_to receive(:new)
subject.execute
end
end
- context 'when in GitLab read-only instance' do
+ context "when in GitLab read-only instance" do
let(:last_activity_on) { nil }
before do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
end
- it 'does not update last_activity_on' do
+ it "does not update last_activity_on" do
expect { subject.execute }.not_to change(user, :last_activity_on)
end
end
- context 'when a lease could not be obtained' do
+ context "when a lease could not be obtained" do
let(:last_activity_on) { nil }
- it 'does not update last_activity_on' do
+ it "does not update last_activity_on" do
stub_exclusive_lease_taken("acitvity_service:#{user.id}", timeout: 1.minute.to_i)
expect { subject.execute }.not_to change(user, :last_activity_on)
diff --git a/spec/services/users/build_service_spec.rb b/spec/services/users/build_service_spec.rb
index b7b9817efdb..14c00b769ff 100644
--- a/spec/services/users/build_service_spec.rb
+++ b/spec/services/users/build_service_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::BuildService do
- describe '#execute' do
+ describe "#execute" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass' }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass"}
end
- context 'with an admin user' do
+ context "with an admin user" do
let(:admin_user) { create(:admin) }
let(:service) { described_class.new(admin_user, ActionController::Parameters.new(params).permit!) }
- it 'returns a valid user' do
+ it "returns a valid user" do
expect(service.execute).to be_valid
end
- context 'allowed params' do
+ context "allowed params" do
let(:params) do
{
access_level: 1,
@@ -44,11 +44,11 @@ describe Users::BuildService do
private_profile: 1,
organization: 1,
location: 1,
- public_email: 1
+ public_email: 1,
}
end
- it 'sets all allowed attributes' do
+ it "sets all allowed attributes" do
admin_user # call first so the admin gets created before setting `expect`
expect(User).to receive(:new).with(hash_including(params)).and_call_original
@@ -61,37 +61,37 @@ describe Users::BuildService do
using RSpec::Parameterized::TableSyntax
where(:user_default_external, :external, :email, :user_default_internal_regex, :result) do
- true | nil | 'fl@example.com' | nil | true
- true | true | 'fl@example.com' | nil | true
- true | false | 'fl@example.com' | nil | false
+ true | nil | "fl@example.com" | nil | true
+ true | true | "fl@example.com" | nil | true
+ true | false | "fl@example.com" | nil | false
- true | nil | 'fl@example.com' | '' | true
- true | true | 'fl@example.com' | '' | true
- true | false | 'fl@example.com' | '' | false
+ true | nil | "fl@example.com" | "" | true
+ true | true | "fl@example.com" | "" | true
+ true | false | "fl@example.com" | "" | false
- true | nil | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- true | true | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | true
- true | false | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ true | nil | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ true | true | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ true | false | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
- true | nil | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
- true | true | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
- true | false | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ true | nil | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ true | true | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ true | false | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
- false | nil | 'fl@example.com' | nil | false
- false | true | 'fl@example.com' | nil | true
- false | false | 'fl@example.com' | nil | false
+ false | nil | "fl@example.com" | nil | false
+ false | true | "fl@example.com" | nil | true
+ false | false | "fl@example.com" | nil | false
- false | nil | 'fl@example.com' | '' | false
- false | true | 'fl@example.com' | '' | true
- false | false | 'fl@example.com' | '' | false
+ false | nil | "fl@example.com" | "" | false
+ false | true | "fl@example.com" | "" | true
+ false | false | "fl@example.com" | "" | false
- false | nil | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | true | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | true
- false | false | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ false | nil | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | true | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ false | false | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
- false | nil | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | true | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
- false | false | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ false | nil | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | true | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ false | false | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
end
with_them do
@@ -99,31 +99,31 @@ describe Users::BuildService do
stub_application_setting(user_default_external: user_default_external)
stub_application_setting(user_default_internal_regex: user_default_internal_regex)
- params.merge!({ external: external, email: email }.compact)
+ params.merge!({external: external, email: email}.compact)
end
subject(:user) { service.execute }
- it 'correctly sets user.external' do
+ it "correctly sets user.external" do
expect(user.external).to eq(result)
end
end
end
end
- context 'with non admin user' do
+ context "with non admin user" do
let(:user) { create(:user) }
let(:service) { described_class.new(user, params) }
- it 'raises AccessDeniedError exception' do
+ it "raises AccessDeniedError exception" do
expect { service.execute }.to raise_error Gitlab::Access::AccessDeniedError
end
end
- context 'with nil user' do
+ context "with nil user" do
let(:service) { described_class.new(nil, params) }
- it 'returns a valid user' do
+ it "returns a valid user" do
expect(service.execute).to be_valid
end
@@ -132,7 +132,7 @@ describe Users::BuildService do
stub_application_setting(send_user_confirmation_email: true, signup_enabled?: true)
end
- it 'does not confirm the user' do
+ it "does not confirm the user" do
expect(service.execute).not_to be_confirmed
end
end
@@ -142,7 +142,7 @@ describe Users::BuildService do
stub_application_setting(send_user_confirmation_email: false, signup_enabled?: true)
end
- it 'confirms the user' do
+ it "confirms the user" do
expect(service.execute).to be_confirmed
end
end
@@ -151,37 +151,37 @@ describe Users::BuildService do
using RSpec::Parameterized::TableSyntax
where(:user_default_external, :external, :email, :user_default_internal_regex, :result) do
- true | nil | 'fl@example.com' | nil | true
- true | true | 'fl@example.com' | nil | true
- true | false | 'fl@example.com' | nil | true
+ true | nil | "fl@example.com" | nil | true
+ true | true | "fl@example.com" | nil | true
+ true | false | "fl@example.com" | nil | true
- true | nil | 'fl@example.com' | '' | true
- true | true | 'fl@example.com' | '' | true
- true | false | 'fl@example.com' | '' | true
+ true | nil | "fl@example.com" | "" | true
+ true | true | "fl@example.com" | "" | true
+ true | false | "fl@example.com" | "" | true
- true | nil | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- true | true | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- true | false | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ true | nil | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ true | true | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ true | false | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
- true | nil | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
- true | true | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
- true | false | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | true
+ true | nil | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ true | true | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
+ true | false | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | true
- false | nil | 'fl@example.com' | nil | false
- false | true | 'fl@example.com' | nil | false
- false | false | 'fl@example.com' | nil | false
+ false | nil | "fl@example.com" | nil | false
+ false | true | "fl@example.com" | nil | false
+ false | false | "fl@example.com" | nil | false
- false | nil | 'fl@example.com' | '' | false
- false | true | 'fl@example.com' | '' | false
- false | false | 'fl@example.com' | '' | false
+ false | nil | "fl@example.com" | "" | false
+ false | true | "fl@example.com" | "" | false
+ false | false | "fl@example.com" | "" | false
- false | nil | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | true | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | false | 'fl@example.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ false | nil | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | true | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | false | "fl@example.com" | '^(?:(?!\.ext@).)*$\r?' | false
- false | nil | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | true | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
- false | false | 'tester.ext@domain.com' | '^(?:(?!\.ext@).)*$\r?' | false
+ false | nil | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | true | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
+ false | false | "tester.ext@domain.com" | '^(?:(?!\.ext@).)*$\r?' | false
end
with_them do
@@ -189,12 +189,12 @@ describe Users::BuildService do
stub_application_setting(user_default_external: user_default_external)
stub_application_setting(user_default_internal_regex: user_default_internal_regex)
- params.merge!({ external: external, email: email }.compact)
+ params.merge!({external: external, email: email}.compact)
end
subject(:user) { service.execute }
- it 'sets the value of Gitlab::CurrentSettings.user_default_external' do
+ it "sets the value of Gitlab::CurrentSettings.user_default_external" do
expect(user.external).to eq(result)
end
end
diff --git a/spec/services/users/create_service_spec.rb b/spec/services/users/create_service_spec.rb
index 24dac569678..8a1808efc39 100644
--- a/spec/services/users/create_service_spec.rb
+++ b/spec/services/users/create_service_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::CreateService do
- describe '#execute' do
+ describe "#execute" do
let(:admin_user) { create(:admin) }
- context 'with an admin user' do
+ context "with an admin user" do
let(:service) { described_class.new(admin_user, params) }
- context 'when required parameters are provided' do
+ context "when required parameters are provided" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass' }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass"}
end
- it 'returns a persisted user' do
+ it "returns a persisted user" do
expect(service.execute).to be_persisted
end
- it 'persists the given attributes' do
+ it "persists the given attributes" do
user = service.execute
user.reload
@@ -29,10 +29,10 @@ describe Users::CreateService do
)
end
- context 'when the current_user is not persisted' do
+ context "when the current_user is not persisted" do
let(:admin_user) { build(:admin) }
- it 'persists the given attributes and sets created_by_id to nil' do
+ it "persists the given attributes and sets created_by_id to nil" do
user = service.execute
user.reload
@@ -46,17 +46,17 @@ describe Users::CreateService do
end
end
- it 'user is not confirmed if skip_confirmation param is not present' do
+ it "user is not confirmed if skip_confirmation param is not present" do
expect(service.execute).not_to be_confirmed
end
- it 'logs the user creation' do
+ it "logs the user creation" do
expect(service).to receive(:log_info).with("User \"John Doe\" (jd@example.com) was created")
service.execute
end
- it 'executes system hooks ' do
+ it "executes system hooks " do
system_hook_service = spy(:system_hook_service)
expect(service).to receive(:system_hook_service).and_return(system_hook_service)
@@ -66,7 +66,7 @@ describe Users::CreateService do
expect(system_hook_service).to have_received(:execute_hooks_for).with(user, :create)
end
- it 'does not send a notification email' do
+ it "does not send a notification email" do
notification_service = spy(:notification_service)
expect(service).not_to receive(:notification_service)
@@ -77,31 +77,31 @@ describe Users::CreateService do
end
end
- context 'when force_random_password parameter is true' do
+ context "when force_random_password parameter is true" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', force_random_password: true }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass", force_random_password: true}
end
- it 'generates random password' do
+ it "generates random password" do
user = service.execute
- expect(user.password).not_to eq 'mydummypass'
+ expect(user.password).not_to eq "mydummypass"
expect(user.password).to be_present
end
end
- context 'when password_automatically_set parameter is true' do
+ context "when password_automatically_set parameter is true" do
let(:params) do
{
- name: 'John Doe',
- username: 'jduser',
- email: 'jd@example.com',
- password: 'mydummypass',
- password_automatically_set: true
+ name: "John Doe",
+ username: "jduser",
+ email: "jd@example.com",
+ password: "mydummypass",
+ password_automatically_set: true,
}
end
- it 'persists the given attributes' do
+ it "persists the given attributes" do
user = service.execute
user.reload
@@ -116,26 +116,26 @@ describe Users::CreateService do
end
end
- context 'when skip_confirmation parameter is true' do
+ context "when skip_confirmation parameter is true" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', skip_confirmation: true }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass", skip_confirmation: true}
end
- it 'confirms the user' do
+ it "confirms the user" do
expect(service.execute).to be_confirmed
end
end
- context 'when reset_password parameter is true' do
+ context "when reset_password parameter is true" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', reset_password: true }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass", reset_password: true}
end
- it 'resets password even if a password parameter is given' do
+ it "resets password even if a password parameter is given" do
expect(service.execute).to be_recently_sent_password_reset
end
- it 'sends a notification email' do
+ it "sends a notification email" do
notification_service = spy(:notification_service)
expect(service).to receive(:notification_service).and_return(notification_service)
@@ -147,13 +147,13 @@ describe Users::CreateService do
end
end
- context 'with nil user' do
+ context "with nil user" do
let(:params) do
- { name: 'John Doe', username: 'jduser', email: 'jd@example.com', password: 'mydummypass', skip_confirmation: true }
+ {name: "John Doe", username: "jduser", email: "jd@example.com", password: "mydummypass", skip_confirmation: true}
end
let(:service) { described_class.new(nil, params) }
- it 'persists the given attributes' do
+ it "persists the given attributes" do
user = service.execute
user.reload
diff --git a/spec/services/users/destroy_service_spec.rb b/spec/services/users/destroy_service_spec.rb
index 83f1495a1c6..33a32286015 100644
--- a/spec/services/users/destroy_service_spec.rb
+++ b/spec/services/users/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::DestroyService do
describe "Deletes a user and all their personal projects" do
@@ -9,16 +9,16 @@ describe Users::DestroyService do
let(:service) { described_class.new(admin) }
let(:gitlab_shell) { Gitlab::Shell.new }
- context 'no options are given' do
- it 'deletes the user' do
+ context "no options are given" do
+ it "deletes the user" do
user_data = service.execute(user)
- expect { user_data['email'].to eq(user.email) }
+ expect { user_data["email"].to eq(user.email) }
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
expect { Namespace.find(namespace.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'will delete the project' do
+ it "will delete the project" do
expect_next_instance_of(Projects::DestroyService) do |destroy_service|
expect(destroy_service).to receive(:execute).once.and_return(true)
end
@@ -27,13 +27,13 @@ describe Users::DestroyService do
end
end
- context 'projects in pending_delete' do
+ context "projects in pending_delete" do
before do
project.pending_delete = true
project.save
end
- it 'destroys a project in pending_delete' do
+ it "destroys a project in pending_delete" do
expect_next_instance_of(Projects::DestroyService) do |destroy_service|
expect(destroy_service).to receive(:execute).once.and_return(true)
end
@@ -58,7 +58,7 @@ describe Users::DestroyService do
service.execute(user)
end
- it 'does not delete issues the user is assigned to' do
+ it "does not delete issues the user is assigned to" do
expect(Issue.find_by_id(issue.id)).to be_present
end
@@ -84,7 +84,7 @@ describe Users::DestroyService do
service.execute(user)
end
- it 'does not delete merge requests the user is assigned to' do
+ it "does not delete merge requests the user is assigned to" do
expect(MergeRequest.find_by_id(merge_request.id)).to be_present
end
@@ -106,7 +106,7 @@ describe Users::DestroyService do
service.execute(user)
end
- it 'does not delete the user' do
+ it "does not delete the user" do
expect(User.find(user.id)).to eq user
end
end
@@ -121,30 +121,30 @@ describe Users::DestroyService do
service.execute(user, delete_solo_owned_groups: true)
end
- it 'deletes solo owned groups' do
+ it "deletes solo owned groups" do
expect { Project.find(solo_owned.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'deletes the user' do
+ it "deletes the user" do
expect { User.find(user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
context "deletion permission checks" do
- it 'does not delete the user when user is not an admin' do
+ it "does not delete the user when user is not an admin" do
other_user = create(:user)
expect { described_class.new(other_user).execute(user) }.to raise_error(Gitlab::Access::AccessDeniedError)
expect(User.exists?(user.id)).to be(true)
end
- it 'allows admins to delete anyone' do
+ it "allows admins to delete anyone" do
described_class.new(admin).execute(user)
expect(User.exists?(user.id)).to be(false)
end
- it 'allows users to delete their own account' do
+ it "allows users to delete their own account" do
described_class.new(user).execute(user)
expect(User.exists?(user.id)).to be(false)
@@ -154,7 +154,7 @@ describe Users::DestroyService do
context "migrating associated records" do
let!(:issue) { create(:issue, author: user) }
- it 'delegates to the `MigrateToGhostUser` service to move associated records to the ghost user' do
+ it "delegates to the `MigrateToGhostUser` service to move associated records to the ghost user" do
expect_any_instance_of(Users::MigrateToGhostUserService).to receive(:execute).once.and_call_original
service.execute(user)
@@ -162,7 +162,7 @@ describe Users::DestroyService do
expect(issue.reload.author).to be_ghost
end
- it 'does not run `MigrateToGhostUser` if hard_delete option is given' do
+ it "does not run `MigrateToGhostUser` if hard_delete option is given" do
expect_any_instance_of(Users::MigrateToGhostUserService).not_to receive(:execute)
service.execute(user, hard_delete: true)
@@ -172,48 +172,48 @@ describe Users::DestroyService do
end
describe "user personal's repository removal" do
- context 'storages' do
+ context "storages" do
before do
perform_enqueued_jobs { service.execute(user) }
end
- context 'legacy storage' do
+ context "legacy storage" do
let!(:project) { create(:project, :empty_repo, :legacy_storage, namespace: user.namespace) }
- it 'removes repository' do
+ it "removes repository" do
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
end
end
- context 'hashed storage' do
+ context "hashed storage" do
let!(:project) { create(:project, :empty_repo, namespace: user.namespace) }
- it 'removes repository' do
+ it "removes repository" do
expect(gitlab_shell.exists?(project.repository_storage, "#{project.disk_path}.git")).to be_falsey
end
end
end
- context 'repository removal status is taken into account' do
- it 'raises exception' do
+ context "repository removal status is taken into account" do
+ it "raises exception" do
expect_next_instance_of(::Projects::DestroyService) do |destroy_service|
expect(destroy_service).to receive(:execute).and_return(false)
end
expect { service.execute(user) }
- .to raise_error(Users::DestroyService::DestroyError, "Project #{project.id} can't be deleted" )
+ .to raise_error(Users::DestroyService::DestroyError, "Project #{project.id} can't be deleted")
end
end
end
describe "calls the before/after callbacks" do
- it 'of project_members' do
+ it "of project_members" do
expect_any_instance_of(ProjectMember).to receive(:run_callbacks).with(:destroy).once
service.execute(user)
end
- it 'of group_members' do
+ it "of group_members" do
group_member = create(:group_member)
group_member.group.group_members.create(user: user, access_level: 40)
diff --git a/spec/services/users/keys_count_service_spec.rb b/spec/services/users/keys_count_service_spec.rb
index bee8380e8b7..44670407395 100644
--- a/spec/services/users/keys_count_service_spec.rb
+++ b/spec/services/users/keys_count_service_spec.rb
@@ -1,21 +1,21 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
let(:user) { create(:user) }
let(:service) { described_class.new(user) }
- describe '#count' do
+ describe "#count" do
before do
create(:personal_key, user: user)
end
- it 'returns the number of SSH keys as an Integer' do
+ it "returns the number of SSH keys as an Integer" do
expect(service.count).to eq(1)
end
- it 'caches the number of keys in Redis', :request_store do
+ it "caches the number of keys in Redis", :request_store do
service.delete_cache
control_count = ActiveRecord::QueryRecorder.new { service.count }.count
service.delete_cache
@@ -24,8 +24,8 @@ describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#refresh_cache' do
- it 'refreshes the Redis cache' do
+ describe "#refresh_cache" do
+ it "refreshes the Redis cache" do
Rails.cache.write(service.cache_key, 10)
service.refresh_cache
@@ -33,8 +33,8 @@ describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#delete_cache' do
- it 'removes the cache' do
+ describe "#delete_cache" do
+ it "removes the cache" do
service.count
service.delete_cache
@@ -42,22 +42,22 @@ describe Users::KeysCountService, :use_clean_rails_memory_store_caching do
end
end
- describe '#uncached_count' do
- it 'returns the number of SSH keys' do
+ describe "#uncached_count" do
+ it "returns the number of SSH keys" do
expect(service.uncached_count).to be_zero
end
- it 'does not cache the number of keys' do
- recorder = ActiveRecord::QueryRecorder.new do
+ it "does not cache the number of keys" do
+ recorder = ActiveRecord::QueryRecorder.new {
2.times { service.uncached_count }
- end
+ }
expect(recorder.count).to be > 0
end
end
- describe '#cache_key' do
- it 'returns the cache key' do
+ describe "#cache_key" do
+ it "returns the cache key" do
expect(service.cache_key).to eq("users/key-count-service/#{user.id}")
end
end
diff --git a/spec/services/users/last_push_event_service_spec.rb b/spec/services/users/last_push_event_service_spec.rb
index 2b6c0267a0f..44e1086f50e 100644
--- a/spec/services/users/last_push_event_service_spec.rb
+++ b/spec/services/users/last_push_event_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::LastPushEventService do
let(:user) { build(:user, id: 1) }
@@ -6,105 +6,105 @@ describe Users::LastPushEventService do
let(:event) { build(:push_event, id: 3, author: user, project: project) }
let(:service) { described_class.new(user) }
- describe '#cache_last_push_event' do
+ describe "#cache_last_push_event" do
it "caches the event for the event's project and current user" do
expect(service).to receive(:set_key)
.ordered
- .with('last-push-event/1/2', 3)
+ .with("last-push-event/1/2", 3)
expect(service).to receive(:set_key)
.ordered
- .with('last-push-event/1', 3)
+ .with("last-push-event/1", 3)
service.cache_last_push_event(event)
end
- it 'caches the event for the origin project when pushing to a fork' do
+ it "caches the event for the origin project when pushing to a fork" do
source = build(:project, id: 5)
allow(project).to receive(:forked_from_project).and_return(source)
expect(service).to receive(:set_key)
.ordered
- .with('last-push-event/1/2', 3)
+ .with("last-push-event/1/2", 3)
expect(service).to receive(:set_key)
.ordered
- .with('last-push-event/1', 3)
+ .with("last-push-event/1", 3)
expect(service).to receive(:set_key)
.ordered
- .with('last-push-event/1/5', 3)
+ .with("last-push-event/1/5", 3)
service.cache_last_push_event(event)
end
end
- describe '#last_event_for_user' do
- it 'returns the last push event for the current user' do
+ describe "#last_event_for_user" do
+ it "returns the last push event for the current user" do
expect(service).to receive(:find_cached_event)
- .with('last-push-event/1')
+ .with("last-push-event/1")
.and_return(event)
expect(service.last_event_for_user).to eq(event)
end
- it 'returns nil when no push event could be found' do
+ it "returns nil when no push event could be found" do
expect(service).to receive(:find_cached_event)
- .with('last-push-event/1')
+ .with("last-push-event/1")
.and_return(nil)
expect(service.last_event_for_user).to be_nil
end
end
- describe '#last_event_for_project' do
- it 'returns the last push event for the given project' do
+ describe "#last_event_for_project" do
+ it "returns the last push event for the given project" do
expect(service).to receive(:find_cached_event)
- .with('last-push-event/1/2')
+ .with("last-push-event/1/2")
.and_return(event)
expect(service.last_event_for_project(project)).to eq(event)
end
- it 'returns nil when no push event could be found' do
+ it "returns nil when no push event could be found" do
expect(service).to receive(:find_cached_event)
- .with('last-push-event/1/2')
+ .with("last-push-event/1/2")
.and_return(nil)
expect(service.last_event_for_project(project)).to be_nil
end
end
- describe '#find_cached_event', :use_clean_rails_memory_store_caching do
- context 'with a non-existing cache key' do
- it 'returns nil' do
- expect(service.find_cached_event('bla')).to be_nil
+ describe "#find_cached_event", :use_clean_rails_memory_store_caching do
+ context "with a non-existing cache key" do
+ it "returns nil" do
+ expect(service.find_cached_event("bla")).to be_nil
end
end
- context 'with an existing cache key' do
+ context "with an existing cache key" do
before do
service.cache_last_push_event(event)
end
- it 'returns a PushEvent when no merge requests exist for the event' do
+ it "returns a PushEvent when no merge requests exist for the event" do
allow(service).to receive(:find_event_in_database)
.with(event.id)
.and_return(event)
- expect(service.find_cached_event('last-push-event/1')).to eq(event)
+ expect(service.find_cached_event("last-push-event/1")).to eq(event)
end
- it 'removes the cache key when no event could be found and returns nil' do
+ it "removes the cache key when no event could be found and returns nil" do
allow(PushEvent).to receive(:without_existing_merge_requests)
.and_return(PushEvent.none)
expect(Rails.cache).to receive(:delete)
- .with('last-push-event/1')
+ .with("last-push-event/1")
.and_call_original
- expect(service.find_cached_event('last-push-event/1')).to be_nil
+ expect(service.find_cached_event("last-push-event/1")).to be_nil
end
end
end
diff --git a/spec/services/users/migrate_to_ghost_user_service_spec.rb b/spec/services/users/migrate_to_ghost_user_service_spec.rb
index 68b0f79c6d1..c5e7a91c137 100644
--- a/spec/services/users/migrate_to_ghost_user_service_spec.rb
+++ b/spec/services/users/migrate_to_ghost_user_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::MigrateToGhostUserService do
let!(:user) { create(:user) }
@@ -6,8 +6,8 @@ describe Users::MigrateToGhostUserService do
let(:service) { described_class.new(user) }
context "migrating a user's associated records to the ghost user" do
- context 'issues' do
- context 'deleted user is present as both author and edited_user' do
+ context "issues" do
+ context "deleted user is present as both author and edited_user" do
include_examples "migrating a deleted user's associated records to the ghost user", Issue, [:author, :last_edited_by] do
let(:created_record) do
create(:issue, project: project, author: user, last_edited_by: user)
@@ -15,40 +15,40 @@ describe Users::MigrateToGhostUserService do
end
end
- context 'deleted user is present only as edited_user' do
+ context "deleted user is present only as edited_user" do
include_examples "migrating a deleted user's associated records to the ghost user", Issue, [:last_edited_by] do
let(:created_record) { create(:issue, project: project, author: create(:user), last_edited_by: user) }
end
end
end
- context 'merge requests' do
- context 'deleted user is present as both author and merge_user' do
+ context "merge requests" do
+ context "deleted user is present as both author and merge_user" do
include_examples "migrating a deleted user's associated records to the ghost user", MergeRequest, [:author, :merge_user] do
let(:created_record) { create(:merge_request, source_project: project, author: user, merge_user: user, target_branch: "first") }
end
end
- context 'deleted user is present only as both merge_user' do
+ context "deleted user is present only as both merge_user" do
include_examples "migrating a deleted user's associated records to the ghost user", MergeRequest, [:merge_user] do
let(:created_record) { create(:merge_request, source_project: project, merge_user: user, target_branch: "first") }
end
end
end
- context 'notes' do
+ context "notes" do
include_examples "migrating a deleted user's associated records to the ghost user", Note do
let(:created_record) { create(:note, project: project, author: user) }
end
end
- context 'abuse reports' do
+ context "abuse reports" do
include_examples "migrating a deleted user's associated records to the ghost user", AbuseReport do
let(:created_record) { create(:abuse_report, reporter: user, user: create(:user)) }
end
end
- context 'award emoji' do
+ context "award emoji" do
include_examples "migrating a deleted user's associated records to the ghost user", AwardEmoji, [:user] do
let(:created_record) { create(:award_emoji, user: user) }
diff --git a/spec/services/users/refresh_authorized_projects_service_spec.rb b/spec/services/users/refresh_authorized_projects_service_spec.rb
index 122b96ef216..c6672543f97 100644
--- a/spec/services/users/refresh_authorized_projects_service_spec.rb
+++ b/spec/services/users/refresh_authorized_projects_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::RefreshAuthorizedProjectsService do
include ExclusiveLeaseHelpers
@@ -10,24 +10,24 @@ describe Users::RefreshAuthorizedProjectsService do
let(:user) { project.namespace.owner }
let(:service) { described_class.new(user) }
- describe '#execute', :clean_gitlab_redis_shared_state do
- it 'refreshes the authorizations using a lease' do
+ describe "#execute", :clean_gitlab_redis_shared_state do
+ it "refreshes the authorizations using a lease" do
lease_key = "refresh_authorized_projects:#{user.id}"
- expect_to_obtain_exclusive_lease(lease_key, 'uuid')
- expect_to_cancel_exclusive_lease(lease_key, 'uuid')
+ expect_to_obtain_exclusive_lease(lease_key, "uuid")
+ expect_to_cancel_exclusive_lease(lease_key, "uuid")
expect(service).to receive(:execute_without_lease)
service.execute
end
end
- describe '#execute_without_lease' do
+ describe "#execute_without_lease" do
before do
user.project_authorizations.delete_all
end
- it 'updates the authorized projects of the user' do
+ it "updates the authorized projects of the user" do
project2 = create(:project)
to_remove = user.project_authorizations
.create!(project: project2, access_level: Gitlab::Access::MAINTAINER)
@@ -38,7 +38,7 @@ describe Users::RefreshAuthorizedProjectsService do
service.execute_without_lease
end
- it 'sets the access level of a project to the highest available level' do
+ it "sets the access level of a project to the highest available level" do
user.project_authorizations.delete_all
to_remove = user.project_authorizations
@@ -50,14 +50,14 @@ describe Users::RefreshAuthorizedProjectsService do
service.execute_without_lease
end
- it 'returns a User' do
+ it "returns a User" do
expect(service.execute_without_lease).to be_an_instance_of(User)
end
end
- describe '#update_authorizations' do
- context 'when there are no rows to add and remove' do
- it 'does not change authorizations' do
+ describe "#update_authorizations" do
+ context "when there are no rows to add and remove" do
+ it "does not change authorizations" do
expect(user).not_to receive(:remove_project_authorizations)
expect(ProjectAuthorization).not_to receive(:insert_authorizations)
@@ -65,7 +65,7 @@ describe Users::RefreshAuthorizedProjectsService do
end
end
- it 'removes authorizations that should be removed' do
+ it "removes authorizations that should be removed" do
authorization = user.project_authorizations.find_by(project_id: project.id)
service.update_authorizations([authorization.project_id])
@@ -73,7 +73,7 @@ describe Users::RefreshAuthorizedProjectsService do
expect(user.project_authorizations).to be_empty
end
- it 'inserts authorizations that should be added' do
+ it "inserts authorizations that should be added" do
user.project_authorizations.delete_all
service.update_authorizations([], [[user.id, project.id, Gitlab::Access::MAINTAINER]])
@@ -87,40 +87,40 @@ describe Users::RefreshAuthorizedProjectsService do
end
end
- describe '#fresh_access_levels_per_project' do
+ describe "#fresh_access_levels_per_project" do
let(:hash) { service.fresh_access_levels_per_project }
- it 'returns a Hash' do
+ it "returns a Hash" do
expect(hash).to be_an_instance_of(Hash)
end
- it 'sets the keys to the project IDs' do
+ it "sets the keys to the project IDs" do
expect(hash.keys).to eq([project.id])
end
- it 'sets the values to the access levels' do
+ it "sets the values to the access levels" do
expect(hash.values).to eq([Gitlab::Access::MAINTAINER])
end
- context 'personal projects' do
- it 'includes the project with the right access level' do
+ context "personal projects" do
+ it "includes the project with the right access level" do
expect(hash[project.id]).to eq(Gitlab::Access::MAINTAINER)
end
end
- context 'projects the user is a member of' do
+ context "projects the user is a member of" do
let!(:other_project) { create(:project) }
before do
other_project.team.add_reporter(user)
end
- it 'includes the project with the right access level' do
+ it "includes the project with the right access level" do
expect(hash[other_project.id]).to eq(Gitlab::Access::REPORTER)
end
end
- context 'projects of groups the user is a member of' do
+ context "projects of groups the user is a member of" do
let(:group) { create(:group) }
let!(:other_project) { create(:project, group: group) }
@@ -128,12 +128,12 @@ describe Users::RefreshAuthorizedProjectsService do
group.add_owner(user)
end
- it 'includes the project with the right access level' do
+ it "includes the project with the right access level" do
expect(hash[other_project.id]).to eq(Gitlab::Access::OWNER)
end
end
- context 'projects of subgroups of groups the user is a member of', :nested_groups do
+ context "projects of subgroups of groups the user is a member of", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let!(:other_project) { create(:project, group: nested_group) }
@@ -142,12 +142,12 @@ describe Users::RefreshAuthorizedProjectsService do
group.add_maintainer(user)
end
- it 'includes the project with the right access level' do
+ it "includes the project with the right access level" do
expect(hash[other_project.id]).to eq(Gitlab::Access::MAINTAINER)
end
end
- context 'projects shared with groups the user is a member of' do
+ context "projects shared with groups the user is a member of" do
let(:group) { create(:group) }
let(:other_project) { create(:project) }
let!(:project_group_link) { create(:project_group_link, project: other_project, group: group, group_access: Gitlab::Access::GUEST) }
@@ -156,12 +156,12 @@ describe Users::RefreshAuthorizedProjectsService do
group.add_maintainer(user)
end
- it 'includes the project with the right access level' do
+ it "includes the project with the right access level" do
expect(hash[other_project.id]).to eq(Gitlab::Access::GUEST)
end
end
- context 'projects shared with subgroups of groups the user is a member of', :nested_groups do
+ context "projects shared with subgroups of groups the user is a member of", :nested_groups do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let(:other_project) { create(:project) }
@@ -171,24 +171,24 @@ describe Users::RefreshAuthorizedProjectsService do
group.add_maintainer(user)
end
- it 'includes the project with the right access level' do
+ it "includes the project with the right access level" do
expect(hash[other_project.id]).to eq(Gitlab::Access::DEVELOPER)
end
end
end
- describe '#current_authorizations_per_project' do
+ describe "#current_authorizations_per_project" do
let(:hash) { service.current_authorizations_per_project }
- it 'returns a Hash' do
+ it "returns a Hash" do
expect(hash).to be_an_instance_of(Hash)
end
- it 'sets the keys to the project IDs' do
+ it "sets the keys to the project IDs" do
expect(hash.keys).to eq([project.id])
end
- it 'sets the values to the project authorization rows' do
+ it "sets the values to the project authorization rows" do
expect(hash.values.length).to eq(1)
value = hash.values[0]
@@ -198,38 +198,38 @@ describe Users::RefreshAuthorizedProjectsService do
end
end
- describe '#current_authorizations' do
- context 'without authorizations' do
- it 'returns an empty list' do
+ describe "#current_authorizations" do
+ context "without authorizations" do
+ it "returns an empty list" do
user.project_authorizations.delete_all
expect(service.current_authorizations.empty?).to eq(true)
end
end
- context 'with an authorization' do
+ context "with an authorization" do
let(:row) { service.current_authorizations.take }
- it 'returns the currently authorized projects' do
+ it "returns the currently authorized projects" do
expect(service.current_authorizations.length).to eq(1)
end
- it 'includes the project ID for every row' do
+ it "includes the project ID for every row" do
expect(row.project_id).to eq(project.id)
end
- it 'includes the access level for every row' do
+ it "includes the access level for every row" do
expect(row.access_level).to eq(Gitlab::Access::MAINTAINER)
end
end
end
- describe '#fresh_authorizations' do
- it 'returns the new authorized projects' do
+ describe "#fresh_authorizations" do
+ it "returns the new authorized projects" do
expect(service.fresh_authorizations.length).to eq(1)
end
- it 'returns the highest access level' do
+ it "returns the highest access level" do
project.team.add_guest(user)
rows = service.fresh_authorizations.to_a
@@ -238,14 +238,14 @@ describe Users::RefreshAuthorizedProjectsService do
expect(rows.first.access_level).to eq(Gitlab::Access::MAINTAINER)
end
- context 'every returned row' do
+ context "every returned row" do
let(:row) { service.fresh_authorizations.take }
- it 'includes the project ID' do
+ it "includes the project ID" do
expect(row.project_id).to eq(project.id)
end
- it 'includes the access level' do
+ it "includes the access level" do
expect(row.access_level).to eq(Gitlab::Access::MAINTAINER)
end
end
diff --git a/spec/services/users/respond_to_terms_service_spec.rb b/spec/services/users/respond_to_terms_service_spec.rb
index fb08dd10b87..91e1d2e1819 100644
--- a/spec/services/users/respond_to_terms_service_spec.rb
+++ b/spec/services/users/respond_to_terms_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::RespondToTermsService do
let(:user) { create(:user) }
@@ -6,13 +6,13 @@ describe Users::RespondToTermsService do
subject(:service) { described_class.new(user, term) }
- describe '#execute' do
- it 'creates a new agreement if it did not exist' do
+ describe "#execute" do
+ it "creates a new agreement if it did not exist" do
expect { service.execute(accepted: true) }
.to change { user.term_agreements.size }.by(1)
end
- it 'updates an agreement if it existed' do
+ it "updates an agreement if it existed" do
agreement = create(:term_agreement, user: user, term: term, accepted: true)
service.execute(accepted: true)
@@ -20,13 +20,13 @@ describe Users::RespondToTermsService do
expect(agreement.reload.accepted).to be_truthy
end
- it 'adds the accepted terms to the user' do
+ it "adds the accepted terms to the user" do
service.execute(accepted: true)
expect(user.reload.accepted_term).to eq(term)
end
- it 'removes accepted terms when declining' do
+ it "removes accepted terms when declining" do
user.update!(accepted_term: term)
service.execute(accepted: false)
diff --git a/spec/services/users/set_status_service_spec.rb b/spec/services/users/set_status_service_spec.rb
index 7c26be48345..91bdfeceee7 100644
--- a/spec/services/users/set_status_service_spec.rb
+++ b/spec/services/users/set_status_service_spec.rb
@@ -1,53 +1,53 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe Users::SetStatusService do
let(:current_user) { create(:user) }
subject(:service) { described_class.new(current_user, params) }
- describe '#execute' do
- context 'when params are set' do
- let(:params) { { emoji: 'taurus', message: 'a random status' } }
+ describe "#execute" do
+ context "when params are set" do
+ let(:params) { {emoji: "taurus", message: "a random status"} }
- it 'creates a status' do
+ it "creates a status" do
service.execute
- expect(current_user.status.emoji).to eq('taurus')
- expect(current_user.status.message).to eq('a random status')
+ expect(current_user.status.emoji).to eq("taurus")
+ expect(current_user.status.message).to eq("a random status")
end
- it 'updates a status if it already existed' do
+ it "updates a status if it already existed" do
create(:user_status, user: current_user)
expect { service.execute }.not_to change { UserStatus.count }
- expect(current_user.status.message).to eq('a random status')
+ expect(current_user.status.message).to eq("a random status")
end
- context 'for another user' do
+ context "for another user" do
let(:target_user) { create(:user) }
let(:params) do
- { emoji: 'taurus', message: 'a random status', user: target_user }
+ {emoji: "taurus", message: "a random status", user: target_user}
end
- context 'the current user is admin' do
+ context "the current user is admin" do
let(:current_user) { create(:admin) }
- it 'changes the status when the current user is allowed to do that' do
+ it "changes the status when the current user is allowed to do that" do
expect { service.execute }.to change { target_user.status }
end
end
- it 'does not update the status if the current user is not allowed' do
+ it "does not update the status if the current user is not allowed" do
expect { service.execute }.not_to change { target_user.status }
end
end
end
- context 'without params' do
+ context "without params" do
let(:params) { {} }
- it 'deletes the status' do
+ it "deletes the status" do
status = create(:user_status, user: current_user)
expect { service.execute }
diff --git a/spec/services/users/update_service_spec.rb b/spec/services/users/update_service_spec.rb
index 529c8485202..6cb89476805 100644
--- a/spec/services/users/update_service_spec.rb
+++ b/spec/services/users/update_service_spec.rb
@@ -1,51 +1,51 @@
-require 'spec_helper'
+require "spec_helper"
describe Users::UpdateService do
let(:user) { create(:user) }
- describe '#execute' do
- it 'updates the name' do
- result = update_user(user, name: 'New Name')
+ describe "#execute" do
+ it "updates the name" do
+ result = update_user(user, name: "New Name")
expect(result).to eq(status: :success)
- expect(user.name).to eq('New Name')
+ expect(user.name).to eq("New Name")
end
- it 'returns an error result when record cannot be updated' do
+ it "returns an error result when record cannot be updated" do
result = {}
- expect do
- result = update_user(user, { email: 'invalid' })
- end.not_to change { user.reload.email }
+ expect {
+ result = update_user(user, {email: "invalid"})
+ }.not_to change { user.reload.email }
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('Email is invalid')
+ expect(result[:message]).to eq("Email is invalid")
end
- it 'includes namespace error messages' do
- create(:group, path: 'taken')
+ it "includes namespace error messages" do
+ create(:group, path: "taken")
result = {}
- expect do
- result = update_user(user, { username: 'taken' })
- end.not_to change { user.reload.username }
+ expect {
+ result = update_user(user, {username: "taken"})
+ }.not_to change { user.reload.username }
expect(result[:status]).to eq(:error)
- expect(result[:message]).to eq('Username has already been taken')
+ expect(result[:message]).to eq("Username has already been taken")
end
- it 'updates the status if status params were given' do
- update_user(user, status: { message: "On a call" })
+ it "updates the status if status params were given" do
+ update_user(user, status: {message: "On a call"})
expect(user.status.message).to eq("On a call")
end
- it 'does not delete the status if no status param was passed' do
- create(:user_status, user: user, message: 'Busy!')
+ it "does not delete the status if no status param was passed" do
+ create(:user_status, user: user, message: "Busy!")
- update_user(user, name: 'New name')
+ update_user(user, name: "New name")
- expect(user.status.message).to eq('Busy!')
+ expect(user.status.message).to eq("Busy!")
end
- it 'includes status error messages' do
- result = update_user(user, status: { emoji: "Moo!" })
+ it "includes status error messages" do
+ result = update_user(user, status: {emoji: "Moo!"})
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq("Emoji is not included in the list")
@@ -56,27 +56,27 @@ describe Users::UpdateService do
end
end
- describe '#execute!' do
- it 'updates the name' do
- service = described_class.new(user, user: user, name: 'New Name')
+ describe "#execute!" do
+ it "updates the name" do
+ service = described_class.new(user, user: user, name: "New Name")
expect(service).not_to receive(:notify_new_user)
result = service.execute!
expect(result).to be true
- expect(user.name).to eq('New Name')
+ expect(user.name).to eq("New Name")
end
- it 'raises an error when record cannot be updated' do
- expect do
- update_user(user, email: 'invalid')
- end.to raise_error(ActiveRecord::RecordInvalid)
+ it "raises an error when record cannot be updated" do
+ expect {
+ update_user(user, email: "invalid")
+ }.to raise_error(ActiveRecord::RecordInvalid)
end
- it 'fires system hooks when a new user is saved' do
+ it "fires system hooks when a new user is saved" do
system_hook_service = spy(:system_hook_service)
user = build(:user)
- service = described_class.new(user, user: user, name: 'John Doe')
+ service = described_class.new(user, user: user, name: "John Doe")
expect(service).to receive(:notify_new_user).and_call_original
expect(service).to receive(:system_hook_service).and_return(system_hook_service)
diff --git a/spec/services/verify_pages_domain_service_spec.rb b/spec/services/verify_pages_domain_service_spec.rb
index d974cc0226f..aedec60c5ea 100644
--- a/spec/services/verify_pages_domain_service_spec.rb
+++ b/spec/services/verify_pages_domain_service_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe VerifyPagesDomainService do
using RSpec::Parameterized::TableSyntax
include EmailHelpers
- let(:error_status) { { status: :error, message: "Couldn't verify #{domain.domain}" } }
+ let(:error_status) { {status: :error, message: "Couldn't verify #{domain.domain}"} }
subject(:service) { described_class.new(domain) }
- describe '#execute' do
- context 'verification code recognition (verified domain)' do
+ describe "#execute" do
+ context "verification code recognition (verified domain)" do
where(:domain_sym, :code_sym) do
:domain | :verification_code
:domain | :keyed_verification_code
@@ -24,15 +24,15 @@ describe VerifyPagesDomainService do
let(:domain_name) { domain.send(domain_sym) }
let(:verification_code) { domain.send(code_sym) }
- it 'verifies and enables the domain' do
- stub_resolver(domain_name => ['something else', verification_code])
+ it "verifies and enables the domain" do
+ stub_resolver(domain_name => ["something else", verification_code])
expect(service.execute).to eq(status: :success)
expect(domain).to be_verified
expect(domain).to be_enabled
end
- it 'verifies and enables when the code is contained partway through a TXT record' do
+ it "verifies and enables when the code is contained partway through a TXT record" do
stub_resolver(domain_name => "something #{verification_code} else")
expect(service.execute).to eq(status: :success)
@@ -40,8 +40,8 @@ describe VerifyPagesDomainService do
expect(domain).to be_enabled
end
- it 'does not verify when the code is not present' do
- stub_resolver(domain_name => 'something else')
+ it "does not verify when the code is not present" do
+ stub_resolver(domain_name => "something else")
expect(service.execute).to eq(error_status)
@@ -50,18 +50,18 @@ describe VerifyPagesDomainService do
end
end
- context 'verified domain' do
+ context "verified domain" do
set(:domain) { create(:pages_domain) }
- it 'unverifies (but does not disable) when the right code is not present' do
- stub_resolver(domain.domain => 'something else')
+ it "unverifies (but does not disable) when the right code is not present" do
+ stub_resolver(domain.domain => "something else")
expect(service.execute).to eq(error_status)
expect(domain).not_to be_verified
expect(domain).to be_enabled
end
- it 'unverifies (but does not disable) when no records are present' do
+ it "unverifies (but does not disable) when no records are present" do
stub_resolver
expect(service.execute).to eq(error_status)
@@ -70,10 +70,10 @@ describe VerifyPagesDomainService do
end
end
- context 'expired domain' do
+ context "expired domain" do
set(:domain) { create(:pages_domain, :expired) }
- it 'verifies and enables when the right code is present' do
+ it "verifies and enables when the right code is present" do
stub_resolver(domain.domain => domain.keyed_verification_code)
expect(service.execute).to eq(status: :success)
@@ -82,8 +82,8 @@ describe VerifyPagesDomainService do
expect(domain).to be_enabled
end
- it 'disables when the right code is not present' do
- error_status[:message] += '. It is now disabled.'
+ it "disables when the right code is not present" do
+ error_status[:message] += ". It is now disabled."
stub_resolver
@@ -94,15 +94,15 @@ describe VerifyPagesDomainService do
end
end
- context 'invalid domain' do
+ context "invalid domain" do
let(:domain) { build(:pages_domain, :expired, :with_missing_chain) }
before do
domain.save(validate: false)
end
- it 'can be disabled' do
- error_status[:message] += '. It is now disabled.'
+ it "can be disabled" do
+ error_status[:message] += ". It is now disabled."
stub_resolver
@@ -114,18 +114,18 @@ describe VerifyPagesDomainService do
end
end
- context 'timeout behaviour' do
+ context "timeout behaviour" do
let(:domain) { create(:pages_domain) }
- it 'sets a timeout on the DNS query' do
+ it "sets a timeout on the DNS query" do
expect(stub_resolver).to receive(:timeouts=).with(described_class::RESOLVER_TIMEOUT_SECONDS)
service.execute
end
end
- context 'email notifications' do
- let(:notification_service) { instance_double('NotificationService') }
+ context "email notifications" do
+ let(:notification_service) { instance_double("NotificationService") }
where(:factory, :verification_succeeds, :expected_notification) do
nil | true | nil
@@ -153,7 +153,7 @@ describe VerifyPagesDomainService do
end
end
- it 'sends a notification if appropriate' do
+ it "sends a notification if appropriate" do
if expected_notification
expect(notification_service).to receive(:"pages_domain_#{expected_notification}").with(domain)
end
@@ -162,7 +162,7 @@ describe VerifyPagesDomainService do
end
end
- context 'pages verification disabled' do
+ context "pages verification disabled" do
let(:domain) { create(:pages_domain, :disabled) }
before do
@@ -170,7 +170,7 @@ describe VerifyPagesDomainService do
allow(service).to receive(:notification_service) { notification_service }
end
- it 'skips email notifications' do
+ it "skips email notifications" do
expect(notification_service).not_to receive(:pages_domain_enabled)
service.execute
@@ -178,11 +178,11 @@ describe VerifyPagesDomainService do
end
end
- context 'pages configuration updates' do
- context 'enabling a disabled domain' do
+ context "pages configuration updates" do
+ context "enabling a disabled domain" do
let(:domain) { create(:pages_domain, :disabled) }
- it 'schedules an update' do
+ it "schedules an update" do
stub_resolver(domain.domain => domain.verification_code)
expect(domain).to receive(:update_daemon)
@@ -191,10 +191,10 @@ describe VerifyPagesDomainService do
end
end
- context 'verifying an enabled domain' do
+ context "verifying an enabled domain" do
let(:domain) { create(:pages_domain) }
- it 'schedules an update' do
+ it "schedules an update" do
stub_resolver(domain.domain => domain.verification_code)
expect(domain).not_to receive(:update_daemon)
@@ -203,10 +203,10 @@ describe VerifyPagesDomainService do
end
end
- context 'disabling an expired domain' do
+ context "disabling an expired domain" do
let(:domain) { create(:pages_domain, :expired) }
- it 'schedules an update' do
+ it "schedules an update" do
stub_resolver
expect(domain).to receive(:update_daemon)
@@ -215,10 +215,10 @@ describe VerifyPagesDomainService do
end
end
- context 'failing to verify a disabled domain' do
+ context "failing to verify a disabled domain" do
let(:domain) { create(:pages_domain, :disabled) }
- it 'does not schedule an update' do
+ it "does not schedule an update" do
stub_resolver
expect(domain).not_to receive(:update_daemon)
@@ -228,11 +228,11 @@ describe VerifyPagesDomainService do
end
end
- context 'no verification code' do
+ context "no verification code" do
let(:domain) { create(:pages_domain) }
- it 'returns an error' do
- domain.verification_code = ''
+ it "returns an error" do
+ domain.verification_code = ""
disallow_resolver!
@@ -240,14 +240,14 @@ describe VerifyPagesDomainService do
end
end
- context 'pages domain verification is disabled' do
+ context "pages domain verification is disabled" do
let(:domain) { create(:pages_domain, :disabled) }
before do
stub_application_setting(pages_domain_verification_enabled: false)
end
- it 'extends domain validity by unconditionally reverifying' do
+ it "extends domain validity by unconditionally reverifying" do
disallow_resolver!
service.execute
@@ -256,7 +256,7 @@ describe VerifyPagesDomainService do
expect(domain).to be_enabled
end
- it 'does not shorten any grace period' do
+ it "does not shorten any grace period" do
grace = Time.now + 1.year
domain.update!(enabled_until: grace)
disallow_resolver!
@@ -273,7 +273,7 @@ describe VerifyPagesDomainService do
end
def stub_resolver(stubbed_lookups = {})
- resolver = instance_double('Resolv::DNS')
+ resolver = instance_double("Resolv::DNS")
allow(resolver).to receive(:timeouts=)
expect(Resolv::DNS).to receive(:open).and_yield(resolver)
diff --git a/spec/services/web_hook_service_spec.rb b/spec/services/web_hook_service_spec.rb
index 747e04fb18c..b52a1ae0602 100644
--- a/spec/services/web_hook_service_spec.rb
+++ b/spec/services/web_hook_service_spec.rb
@@ -1,184 +1,184 @@
-require 'spec_helper'
+require "spec_helper"
describe WebHookService do
let(:project) { create(:project) }
let(:project_hook) { create(:project_hook) }
let(:headers) do
{
- 'Content-Type' => 'application/json',
- 'X-Gitlab-Event' => 'Push Hook'
+ "Content-Type" => "application/json",
+ "X-Gitlab-Event" => "Push Hook",
}
end
let(:data) do
- { before: 'oldrev', after: 'newrev', ref: 'ref' }
+ {before: "oldrev", after: "newrev", ref: "ref"}
end
let(:service_instance) { described_class.new(project_hook, data, :push_hooks) }
- describe '#initialize' do
- it 'allow_local_requests is true if hook is a SystemHook' do
+ describe "#initialize" do
+ it "allow_local_requests is true if hook is a SystemHook" do
instance = described_class.new(build(:system_hook), data, :system_hook)
expect(instance.request_options[:allow_local_requests]).to be_truthy
end
- it 'allow_local_requests is false if hook is not a SystemHook' do
- %i(project_hook service_hook web_hook_log).each do |hook|
+ it "allow_local_requests is false if hook is not a SystemHook" do
+ %i[project_hook service_hook web_hook_log].each do |hook|
instance = described_class.new(build(hook), data, hook)
expect(instance.request_options[:allow_local_requests]).to be_falsey
end
end
end
- describe '#execute' do
+ describe "#execute" do
before do
project.hooks << [project_hook]
WebMock.stub_request(:post, project_hook.url)
end
- context 'when token is defined' do
+ context "when token is defined" do
let(:project_hook) { create(:project_hook, :token) }
- it 'POSTs to the webhook URL' do
+ it "POSTs to the webhook URL" do
service_instance.execute
expect(WebMock).to have_requested(:post, project_hook.url).with(
- headers: headers.merge({ 'X-Gitlab-Token' => project_hook.token })
+ headers: headers.merge({"X-Gitlab-Token" => project_hook.token})
).once
end
end
- it 'POSTs to the webhook URL' do
+ it "POSTs to the webhook URL" do
service_instance.execute
expect(WebMock).to have_requested(:post, project_hook.url).with(
headers: headers
).once
end
- it 'POSTs the data as JSON' do
+ it "POSTs the data as JSON" do
service_instance.execute
expect(WebMock).to have_requested(:post, project_hook.url).with(
headers: headers
).once
end
- context 'when auth credentials are present' do
- let(:url) {'https://example.org'}
- let(:project_hook) { create(:project_hook, url: 'https://demo:demo@example.org/') }
+ context "when auth credentials are present" do
+ let(:url) {"https://example.org"}
+ let(:project_hook) { create(:project_hook, url: "https://demo:demo@example.org/") }
- it 'uses the credentials' do
+ it "uses the credentials" do
WebMock.stub_request(:post, url)
service_instance.execute
expect(WebMock).to have_requested(:post, url).with(
- headers: headers.merge('Authorization' => 'Basic ZGVtbzpkZW1v')
+ headers: headers.merge("Authorization" => "Basic ZGVtbzpkZW1v")
).once
end
end
- context 'when auth credentials are partial present' do
- let(:url) {'https://example.org'}
- let(:project_hook) { create(:project_hook, url: 'https://demo@example.org/') }
+ context "when auth credentials are partial present" do
+ let(:url) {"https://example.org"}
+ let(:project_hook) { create(:project_hook, url: "https://demo@example.org/") }
- it 'uses the credentials anyways' do
+ it "uses the credentials anyways" do
WebMock.stub_request(:post, url)
service_instance.execute
expect(WebMock).to have_requested(:post, url).with(
- headers: headers.merge('Authorization' => 'Basic ZGVtbzo=')
+ headers: headers.merge("Authorization" => "Basic ZGVtbzo=")
).once
end
end
- it 'catches exceptions' do
- WebMock.stub_request(:post, project_hook.url).to_raise(StandardError.new('Some error'))
+ it "catches exceptions" do
+ WebMock.stub_request(:post, project_hook.url).to_raise(StandardError.new("Some error"))
expect { service_instance.execute }.to raise_error(StandardError)
end
- it 'handles exceptions' do
+ it "handles exceptions" do
exceptions = [SocketError, OpenSSL::SSL::SSLError, Errno::ECONNRESET, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, Net::OpenTimeout, Net::ReadTimeout, Gitlab::HTTP::BlockedUrlError, Gitlab::HTTP::RedirectionTooDeep]
exceptions.each do |exception_class|
- exception = exception_class.new('Exception message')
+ exception = exception_class.new("Exception message")
WebMock.stub_request(:post, project_hook.url).to_raise(exception)
- expect(service_instance.execute).to eq({ status: :error, message: exception.to_s })
+ expect(service_instance.execute).to eq({status: :error, message: exception.to_s})
expect { service_instance.execute }.not_to raise_error
end
end
- it 'handles 200 status code' do
- WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: 'Success')
+ it "handles 200 status code" do
+ WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: "Success")
- expect(service_instance.execute).to include({ status: :success, http_status: 200, message: 'Success' })
+ expect(service_instance.execute).to include({status: :success, http_status: 200, message: "Success"})
end
- it 'handles 2xx status codes' do
- WebMock.stub_request(:post, project_hook.url).to_return(status: 201, body: 'Success')
+ it "handles 2xx status codes" do
+ WebMock.stub_request(:post, project_hook.url).to_return(status: 201, body: "Success")
- expect(service_instance.execute).to include({ status: :success, http_status: 201, message: 'Success' })
+ expect(service_instance.execute).to include({status: :success, http_status: 201, message: "Success"})
end
- context 'execution logging' do
+ context "execution logging" do
let(:hook_log) { project_hook.web_hook_logs.last }
- context 'with success' do
+ context "with success" do
before do
- WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: 'Success')
+ WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: "Success")
service_instance.execute
end
- it 'log successful execution' do
- expect(hook_log.trigger).to eq('push_hooks')
+ it "log successful execution" do
+ expect(hook_log.trigger).to eq("push_hooks")
expect(hook_log.url).to eq(project_hook.url)
expect(hook_log.request_headers).to eq(headers)
- expect(hook_log.response_body).to eq('Success')
- expect(hook_log.response_status).to eq('200')
+ expect(hook_log.response_body).to eq("Success")
+ expect(hook_log.response_status).to eq("200")
expect(hook_log.execution_duration).to be > 0
expect(hook_log.internal_error_message).to be_nil
end
end
- context 'with exception' do
+ context "with exception" do
before do
- WebMock.stub_request(:post, project_hook.url).to_raise(SocketError.new('Some HTTP Post error'))
+ WebMock.stub_request(:post, project_hook.url).to_raise(SocketError.new("Some HTTP Post error"))
service_instance.execute
end
- it 'log failed execution' do
- expect(hook_log.trigger).to eq('push_hooks')
+ it "log failed execution" do
+ expect(hook_log.trigger).to eq("push_hooks")
expect(hook_log.url).to eq(project_hook.url)
expect(hook_log.request_headers).to eq(headers)
- expect(hook_log.response_body).to eq('')
- expect(hook_log.response_status).to eq('internal error')
+ expect(hook_log.response_body).to eq("")
+ expect(hook_log.response_status).to eq("internal error")
expect(hook_log.execution_duration).to be > 0
- expect(hook_log.internal_error_message).to eq('Some HTTP Post error')
+ expect(hook_log.internal_error_message).to eq("Some HTTP Post error")
end
end
- context 'with unsafe response body' do
+ context "with unsafe response body" do
before do
WebMock.stub_request(:post, project_hook.url).to_return(status: 200, body: "\xBB")
service_instance.execute
end
- it 'log successful execution' do
- expect(hook_log.trigger).to eq('push_hooks')
+ it "log successful execution" do
+ expect(hook_log.trigger).to eq("push_hooks")
expect(hook_log.url).to eq(project_hook.url)
expect(hook_log.request_headers).to eq(headers)
- expect(hook_log.response_body).to eq('')
- expect(hook_log.response_status).to eq('200')
+ expect(hook_log.response_body).to eq("")
+ expect(hook_log.response_status).to eq("200")
expect(hook_log.execution_duration).to be > 0
expect(hook_log.internal_error_message).to be_nil
end
end
- context 'should not log ServiceHooks' do
+ context "should not log ServiceHooks" do
let(:service_hook) { create(:service_hook) }
- let(:service_instance) { described_class.new(service_hook, data, 'service_hook') }
+ let(:service_instance) { described_class.new(service_hook, data, "service_hook") }
before do
- WebMock.stub_request(:post, service_hook.url).to_return(status: 200, body: 'Success')
+ WebMock.stub_request(:post, service_hook.url).to_return(status: 200, body: "Success")
end
it { expect { service_instance.execute }.not_to change(WebHookLog, :count) }
@@ -186,13 +186,13 @@ describe WebHookService do
end
end
- describe '#async_execute' do
+ describe "#async_execute" do
let(:system_hook) { create(:system_hook) }
- it 'enqueue WebHookWorker' do
- expect(WebHookWorker).to receive(:perform_async).with(project_hook.id, data, 'push_hooks')
+ it "enqueue WebHookWorker" do
+ expect(WebHookWorker).to receive(:perform_async).with(project_hook.id, data, "push_hooks")
- described_class.new(project_hook, data, 'push_hooks').async_execute
+ described_class.new(project_hook, data, "push_hooks").async_execute
end
end
end
diff --git a/spec/services/wiki_pages/create_service_spec.rb b/spec/services/wiki_pages/create_service_spec.rb
index 259f445247e..3e933b37ab8 100644
--- a/spec/services/wiki_pages/create_service_spec.rb
+++ b/spec/services/wiki_pages/create_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe WikiPages::CreateService do
let(:project) { create(:project, :wiki_repo) }
@@ -6,9 +6,9 @@ describe WikiPages::CreateService do
let(:opts) do
{
- title: 'Title',
- content: 'Content for wiki page',
- format: 'markdown'
+ title: "Title",
+ content: "Content for wiki page",
+ format: "markdown",
}
end
@@ -18,8 +18,8 @@ describe WikiPages::CreateService do
project.add_developer(user)
end
- describe '#execute' do
- it 'creates wiki page with valid attributes' do
+ describe "#execute" do
+ it "creates wiki page with valid attributes" do
page = service.execute
expect(page).to be_valid
@@ -28,9 +28,9 @@ describe WikiPages::CreateService do
expect(page.format).to eq(opts[:format].to_sym)
end
- it 'executes webhooks' do
+ it "executes webhooks" do
expect(service).to receive(:execute_hooks).once
- .with(instance_of(WikiPage), 'create')
+ .with(instance_of(WikiPage), "create")
service.execute
end
diff --git a/spec/services/wiki_pages/destroy_service_spec.rb b/spec/services/wiki_pages/destroy_service_spec.rb
index 2938126914b..a05c51d71c3 100644
--- a/spec/services/wiki_pages/destroy_service_spec.rb
+++ b/spec/services/wiki_pages/destroy_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe WikiPages::DestroyService do
let(:project) { create(:project) }
@@ -11,10 +11,10 @@ describe WikiPages::DestroyService do
project.add_developer(user)
end
- describe '#execute' do
- it 'executes webhooks' do
+ describe "#execute" do
+ it "executes webhooks" do
expect(service).to receive(:execute_hooks).once
- .with(instance_of(WikiPage), 'delete')
+ .with(instance_of(WikiPage), "delete")
service.execute(page)
end
diff --git a/spec/services/wiki_pages/update_service_spec.rb b/spec/services/wiki_pages/update_service_spec.rb
index 2399db7d3d4..ddefeef1341 100644
--- a/spec/services/wiki_pages/update_service_spec.rb
+++ b/spec/services/wiki_pages/update_service_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe WikiPages::UpdateService do
let(:project) { create(:project) }
@@ -7,10 +7,10 @@ describe WikiPages::UpdateService do
let(:opts) do
{
- content: 'New content for wiki page',
- format: 'markdown',
- message: 'New wiki message',
- title: 'New Title'
+ content: "New content for wiki page",
+ format: "markdown",
+ message: "New wiki message",
+ title: "New Title",
}
end
@@ -20,8 +20,8 @@ describe WikiPages::UpdateService do
project.add_developer(user)
end
- describe '#execute' do
- it 'updates the wiki page' do
+ describe "#execute" do
+ it "updates the wiki page" do
updated_page = service.execute(page)
expect(updated_page).to be_valid
@@ -31,9 +31,9 @@ describe WikiPages::UpdateService do
expect(updated_page.title).to eq(opts[:title])
end
- it 'executes webhooks' do
+ it "executes webhooks" do
expect(service).to receive(:execute_hooks).once
- .with(instance_of(WikiPage), 'update')
+ .with(instance_of(WikiPage), "update")
service.execute(page)
end
diff --git a/spec/services/wikis/create_attachment_service_spec.rb b/spec/services/wikis/create_attachment_service_spec.rb
index f5899f292c8..bab0b149400 100644
--- a/spec/services/wikis/create_attachment_service_spec.rb
+++ b/spec/services/wikis/create_attachment_service_spec.rb
@@ -1,16 +1,17 @@
# frozen_string_literal: true
-require 'spec_helper'
+
+require "spec_helper"
describe Wikis::CreateAttachmentService do
let(:project) { create(:project, :wiki_repo) }
let(:user) { create(:user) }
- let(:file_name) { 'filename.txt' }
+ let(:file_name) { "filename.txt" }
let(:file_path_regex) { %r{#{described_class::ATTACHMENT_PATH}/\h{32}/#{file_name}} }
let(:file_opts) do
{
file_name: file_name,
- file_content: 'Content of attachment'
+ file_content: "Content of attachment",
}
end
let(:opts) { file_opts }
@@ -21,113 +22,113 @@ describe Wikis::CreateAttachmentService do
project.add_developer(user)
end
- describe 'initialization' do
- context 'author commit info' do
- it 'does not raise error if user is nil' do
+ describe "initialization" do
+ context "author commit info" do
+ it "does not raise error if user is nil" do
service = described_class.new(project, nil, opts)
expect(service.instance_variable_get(:@author_email)).to be_nil
expect(service.instance_variable_get(:@author_name)).to be_nil
end
- it 'fills file_path from the repository uploads folder' do
+ it "fills file_path from the repository uploads folder" do
expect(service.instance_variable_get(:@file_path)).to match(file_path_regex)
end
- context 'when no author info provided' do
- it 'fills author_email and author_name from current_user info' do
+ context "when no author info provided" do
+ it "fills author_email and author_name from current_user info" do
expect(service.instance_variable_get(:@author_email)).to eq user.email
expect(service.instance_variable_get(:@author_name)).to eq user.name
end
end
- context 'when author info provided' do
- let(:author_email) { 'author_email' }
- let(:author_name) { 'author_name' }
+ context "when author info provided" do
+ let(:author_email) { "author_email" }
+ let(:author_name) { "author_name" }
let(:opts) { file_opts.merge(author_email: author_email, author_name: author_name) }
- it 'fills author_email and author_name from params' do
+ it "fills author_email and author_name from params" do
expect(service.instance_variable_get(:@author_email)).to eq author_email
expect(service.instance_variable_get(:@author_name)).to eq author_name
end
end
end
- context 'commit message' do
- context 'when no commit message provided' do
- it 'sets a default commit message' do
+ context "commit message" do
+ context "when no commit message provided" do
+ it "sets a default commit message" do
expect(service.instance_variable_get(:@commit_message)).to eq "Upload attachment #{opts[:file_name]}"
end
end
- context 'when commit message provided' do
- let(:commit_message) { 'whatever' }
+ context "when commit message provided" do
+ let(:commit_message) { "whatever" }
let(:opts) { file_opts.merge(commit_message: commit_message) }
- it 'use the commit message from params' do
+ it "use the commit message from params" do
expect(service.instance_variable_get(:@commit_message)).to eq commit_message
end
end
end
- context 'branch name' do
- context 'when no branch provided' do
- it 'sets the branch from the wiki default_branch' do
+ context "branch name" do
+ context "when no branch provided" do
+ it "sets the branch from the wiki default_branch" do
expect(service.instance_variable_get(:@branch_name)).to eq project.wiki.default_branch
end
end
- context 'when branch provided' do
- let(:branch_name) { 'whatever' }
+ context "when branch provided" do
+ let(:branch_name) { "whatever" }
let(:opts) { file_opts.merge(branch_name: branch_name) }
- it 'use the commit message from params' do
+ it "use the commit message from params" do
expect(service.instance_variable_get(:@branch_name)).to eq branch_name
end
end
end
end
- describe '#parse_file_name' do
- context 'when file_name' do
- context 'has white spaces' do
- let(:file_name) { 'file with spaces' }
+ describe "#parse_file_name" do
+ context "when file_name" do
+ context "has white spaces" do
+ let(:file_name) { "file with spaces" }
it "replaces all of them with '_'" do
result = service.execute
expect(result[:status]).to eq :success
- expect(result[:result][:file_name]).to eq 'file_with_spaces'
+ expect(result[:result][:file_name]).to eq "file_with_spaces"
end
end
- context 'has other invalid characters' do
+ context "has other invalid characters" do
let(:file_name) { "file\twith\tinvalid chars" }
it "replaces all of them with '_'" do
result = service.execute
expect(result[:status]).to eq :success
- expect(result[:result][:file_name]).to eq 'file_with_invalid_chars'
+ expect(result[:result][:file_name]).to eq "file_with_invalid_chars"
end
end
- context 'is not present' do
+ context "is not present" do
let(:file_name) { nil }
- it 'returns error' do
+ it "returns error" do
result = service.execute
expect(result[:status]).to eq :error
- expect(result[:message]).to eq 'The file name cannot be empty'
+ expect(result[:message]).to eq "The file name cannot be empty"
end
end
- context 'length' do
- context 'is bigger than 255' do
- let(:file_name) { "#{'0' * 256}.jpg" }
+ context "length" do
+ context "is bigger than 255" do
+ let(:file_name) { "#{"0" * 256}.jpg" }
- it 'truncates file name' do
+ it "truncates file name" do
result = service.execute
expect(result[:status]).to eq :success
@@ -136,10 +137,10 @@ describe Wikis::CreateAttachmentService do
end
end
- context 'is less or equal to 255 does not return error' do
- let(:file_name) { '0' * 255 }
+ context "is less or equal to 255 does not return error" do
+ let(:file_name) { "0" * 255 }
- it 'does not return error' do
+ it "does not return error" do
result = service.execute
expect(result[:status]).to eq :success
@@ -148,36 +149,36 @@ describe Wikis::CreateAttachmentService do
end
end
- context 'when user' do
- shared_examples 'wiki attachment user validations' do
- it 'returns error' do
+ context "when user" do
+ shared_examples "wiki attachment user validations" do
+ it "returns error" do
result = described_class.new(project, user2, opts).execute
expect(result[:status]).to eq :error
- expect(result[:message]).to eq 'You are not allowed to push to the wiki'
+ expect(result[:message]).to eq "You are not allowed to push to the wiki"
end
end
- context 'does not have permission' do
+ context "does not have permission" do
let(:user2) { create(:user) }
- it_behaves_like 'wiki attachment user validations'
+ it_behaves_like "wiki attachment user validations"
end
- context 'is nil' do
+ context "is nil" do
let(:user2) { nil }
- it_behaves_like 'wiki attachment user validations'
+ it_behaves_like "wiki attachment user validations"
end
end
end
- describe '#execute' do
+ describe "#execute" do
let(:wiki) { project.wiki }
subject(:service_execute) { service.execute[:result] }
- context 'creates branch if it does not exists' do
- let(:branch_name) { 'new_branch' }
+ context "creates branch if it does not exists" do
+ let(:branch_name) { "new_branch" }
let(:opts) { file_opts.merge(branch_name: branch_name) }
it do
@@ -187,36 +188,36 @@ describe Wikis::CreateAttachmentService do
end
end
- it 'adds file to the repository' do
- expect(wiki.repository.ls_files('HEAD')).to be_empty
+ it "adds file to the repository" do
+ expect(wiki.repository.ls_files("HEAD")).to be_empty
service.execute
- files = wiki.repository.ls_files('HEAD')
+ files = wiki.repository.ls_files("HEAD")
expect(files.count).to eq 1
expect(files.first).to match(file_path_regex)
end
- context 'returns' do
+ context "returns" do
before do
- allow(SecureRandom).to receive(:hex).and_return('fixed_hex')
+ allow(SecureRandom).to receive(:hex).and_return("fixed_hex")
service_execute
end
- it 'returns the file name' do
+ it "returns the file name" do
expect(service_execute[:file_name]).to eq file_name
end
- it 'returns the path where file was stored' do
- expect(service_execute[:file_path]).to eq 'uploads/fixed_hex/filename.txt'
+ it "returns the path where file was stored" do
+ expect(service_execute[:file_path]).to eq "uploads/fixed_hex/filename.txt"
end
- it 'returns the branch where the file was pushed' do
+ it "returns the branch where the file was pushed" do
expect(service_execute[:branch]).to eq wiki.default_branch
end
- it 'returns the commit id' do
+ it "returns the commit id" do
expect(service_execute[:commit]).not_to be_empty
end
end
diff --git a/spec/sidekiq/cron/job_gem_dependency_spec.rb b/spec/sidekiq/cron/job_gem_dependency_spec.rb
index 2e7de75fd08..2bb4e9cdaec 100644
--- a/spec/sidekiq/cron/job_gem_dependency_spec.rb
+++ b/spec/sidekiq/cron/job_gem_dependency_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Sidekiq::Cron::Job do
- describe 'cron jobs' do
- context 'when Fugit depends on ZoTime or EoTime' do
+ describe "cron jobs" do
+ context "when Fugit depends on ZoTime or EoTime" do
before do
described_class
- .create(name: 'TestCronWorker',
- cron: Settings.cron_jobs[:pipeline_schedule_worker]['cron'],
- class: Settings.cron_jobs[:pipeline_schedule_worker]['job_class'])
+ .create(name: "TestCronWorker",
+ cron: Settings.cron_jobs[:pipeline_schedule_worker]["cron"],
+ class: Settings.cron_jobs[:pipeline_schedule_worker]["job_class"])
end
- it 'does not get any errors' do
+ it "does not get any errors" do
expect { described_class.all.first.should_enque?(Time.now) }.not_to raise_error
end
end
diff --git a/spec/simplecov_env.rb b/spec/simplecov_env.rb
index 82236bb4201..fb9e2abb7f8 100644
--- a/spec/simplecov_env.rb
+++ b/spec/simplecov_env.rb
@@ -1,12 +1,12 @@
-require 'simplecov'
-require 'active_support/core_ext/numeric/time'
-require_relative '../lib/gitlab/utils'
+require "simplecov"
+require "active_support/core_ext/numeric/time"
+require_relative "../lib/gitlab/utils"
module SimpleCovEnv
extend self
def start!
- return unless ENV['SIMPLECOV']
+ return unless ENV["SIMPLECOV"]
configure_profile
configure_job
@@ -16,13 +16,13 @@ module SimpleCovEnv
def configure_job
SimpleCov.configure do
- if ENV['CI_JOB_NAME']
- job_name = Gitlab::Utils.slugify(ENV['CI_JOB_NAME'])
+ if ENV["CI_JOB_NAME"]
+ job_name = Gitlab::Utils.slugify(ENV["CI_JOB_NAME"])
coverage_dir "coverage/#{job_name}"
command_name job_name
end
- if ENV['CI']
+ if ENV["CI"]
SimpleCov.at_exit do
# In CI environment don't generate formatted reports
# Only generate .resultset.json
@@ -34,29 +34,29 @@ module SimpleCovEnv
def configure_profile
SimpleCov.configure do
- load_profile 'test_frameworks'
- track_files '{app,lib}/**/*.rb'
+ load_profile "test_frameworks"
+ track_files "{app,lib}/**/*.rb"
- add_filter '/vendor/ruby/'
- add_filter 'app/controllers/sherlock/'
- add_filter 'config/initializers/'
- add_filter 'db/fixtures/'
- add_filter 'lib/gitlab/sidekiq_middleware/'
- add_filter 'lib/system_check/'
+ add_filter "/vendor/ruby/"
+ add_filter "app/controllers/sherlock/"
+ add_filter "config/initializers/"
+ add_filter "db/fixtures/"
+ add_filter "lib/gitlab/sidekiq_middleware/"
+ add_filter "lib/system_check/"
- add_group 'Controllers', 'app/controllers'
- add_group 'Finders', 'app/finders'
- add_group 'Helpers', 'app/helpers'
- add_group 'Libraries', 'lib'
- add_group 'Mailers', 'app/mailers'
- add_group 'Models', 'app/models'
- add_group 'Policies', 'app/policies'
- add_group 'Presenters', 'app/presenters'
- add_group 'Serializers', 'app/serializers'
- add_group 'Services', 'app/services'
- add_group 'Uploaders', 'app/uploaders'
- add_group 'Validators', 'app/validators'
- add_group 'Workers', %w(app/jobs app/workers)
+ add_group "Controllers", "app/controllers"
+ add_group "Finders", "app/finders"
+ add_group "Helpers", "app/helpers"
+ add_group "Libraries", "lib"
+ add_group "Mailers", "app/mailers"
+ add_group "Models", "app/models"
+ add_group "Policies", "app/policies"
+ add_group "Presenters", "app/presenters"
+ add_group "Serializers", "app/serializers"
+ add_group "Services", "app/services"
+ add_group "Uploaders", "app/uploaders"
+ add_group "Validators", "app/validators"
+ add_group "Workers", %w[app/jobs app/workers]
merge_timeout 365.days
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 97e7a019222..3f723ebab67 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -1,34 +1,34 @@
-require './spec/simplecov_env'
+require "./spec/simplecov_env"
SimpleCovEnv.start!
-ENV["RAILS_ENV"] = 'test'
-ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true'
+ENV["RAILS_ENV"] = "test"
+ENV["IN_MEMORY_APPLICATION_SETTINGS"] = "true"
-require File.expand_path('../config/environment', __dir__)
-require 'rspec/rails'
-require 'shoulda/matchers'
-require 'rspec/retry'
-require 'rspec-parameterized'
+require File.expand_path("../config/environment", __dir__)
+require "rspec/rails"
+require "shoulda/matchers"
+require "rspec/retry"
+require "rspec-parameterized"
rspec_profiling_is_configured =
- ENV['RSPEC_PROFILING_POSTGRES_URL'].present? ||
- ENV['RSPEC_PROFILING']
+ ENV["RSPEC_PROFILING_POSTGRES_URL"].present? ||
+ ENV["RSPEC_PROFILING"]
branch_can_be_profiled =
- ENV['GITLAB_DATABASE'] == 'postgresql' &&
- (ENV['CI_COMMIT_REF_NAME'] == 'master' ||
- ENV['CI_COMMIT_REF_NAME'] =~ /rspec-profile/)
+ ENV["GITLAB_DATABASE"] == "postgresql" &&
+ (ENV["CI_COMMIT_REF_NAME"] == "master" ||
+ ENV["CI_COMMIT_REF_NAME"] =~ /rspec-profile/)
-if rspec_profiling_is_configured && (!ENV.key?('CI') || branch_can_be_profiled)
- require 'rspec_profiling/rspec'
+if rspec_profiling_is_configured && (!ENV.key?("CI") || branch_can_be_profiled)
+ require "rspec_profiling/rspec"
end
-if ENV['CI'] && ENV['KNAPSACK_GENERATE_REPORT'] && !ENV['NO_KNAPSACK']
- require 'knapsack'
+if ENV["CI"] && ENV["KNAPSACK_GENERATE_REPORT"] && !ENV["NO_KNAPSACK"]
+ require "knapsack"
Knapsack::Adapters::RSpecAdapter.bind
end
# require rainbow gem String monkeypatch, so we can test SystemChecks
-require 'rainbow/ext/string'
+require "rainbow/ext/string"
Rainbow.enabled = false
# Requires supporting ruby files with custom matchers and macros, etc,
@@ -97,13 +97,14 @@ RSpec.configure do |config|
config.include RedisHelpers
config.include Rails.application.routes.url_helpers, type: :routing
- if ENV['CI']
+ if ENV["CI"]
# This includes the first try, i.e. tests will be run 4 times before failing.
config.default_retry_count = 4
config.reporter.register_listener(
RspecFlaky::Listener.new,
:example_passed,
- :dump_summary)
+ :dump_summary
+ )
end
config.before(:suite) do
@@ -129,7 +130,7 @@ RSpec.configure do |config|
config.before(:example, :quarantine) do
# Skip tests in quarantine unless we explicitly focus on them.
- skip('In quarantine') unless config.inclusion_filter[:quarantine]
+ skip("In quarantine") unless config.inclusion_filter[:quarantine]
end
config.before(:example, :request_store) do
@@ -253,11 +254,11 @@ RSpec.configure do |config|
end
config.before(:each, :http_pages_enabled) do |_|
- allow(Gitlab.config.pages).to receive(:external_http).and_return(['1.1.1.1:80'])
+ allow(Gitlab.config.pages).to receive(:external_http).and_return(["1.1.1.1:80"])
end
config.before(:each, :https_pages_enabled) do |_|
- allow(Gitlab.config.pages).to receive(:external_https).and_return(['1.1.1.1:443'])
+ allow(Gitlab.config.pages).to receive(:external_https).and_return(["1.1.1.1:443"])
end
config.before(:each, :http_pages_disabled) do |_|
@@ -274,7 +275,7 @@ RSpec::Matchers.define :match_asset_path do |expected|
match do |actual|
path = Regexp.escape(expected)
extname = Regexp.escape(File.extname(expected))
- digest_regex = Regexp.new(path.sub(extname, "(?:-\\h+)?#{extname}") << '$')
+ digest_regex = Regexp.new(path.sub(extname, "(?:-\\h+)?#{extname}") << "$")
digest_regex =~ actual
end
@@ -301,4 +302,4 @@ Shoulda::Matchers.configure do |config|
end
# Prevent Rugged from picking up local developer gitconfig.
-Rugged::Settings['search_path_global'] = Rails.root.join('tmp/tests').to_s
+Rugged::Settings["search_path_global"] = Rails.root.join("tmp/tests").to_s
diff --git a/spec/support/active_record_enum.rb b/spec/support/active_record_enum.rb
index fb1189c7f17..1aa095b962c 100644
--- a/spec/support/active_record_enum.rb
+++ b/spec/support/active_record_enum.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-shared_examples 'having unique enum values' do
+shared_examples "having unique enum values" do
described_class.defined_enums.each do |name, enum|
it "has unique values in #{name.inspect}" do
duplicated = enum.group_by(&:last).select { |key, value| value.size > 1 }
diff --git a/spec/support/api/boards_shared_examples.rb b/spec/support/api/boards_shared_examples.rb
index 592962ebf7c..bae84b4c72c 100644
--- a/spec/support/api/boards_shared_examples.rb
+++ b/spec/support/api/boards_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_examples_for 'group and project boards' do |route_definition, ee = false|
+shared_examples_for "group and project boards" do |route_definition, ee = false|
let(:root_url) { route_definition.gsub(":id", board_parent.id.to_s) }
before do
@@ -30,16 +30,16 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect_schema_match_for(response, 'public_api/v4/boards', ee)
+ expect_schema_match_for(response, "public_api/v4/boards", ee)
end
describe "GET #{route_definition}/:board_id" do
let(:url) { "#{root_url}/#{board.id}" }
- it 'get a single board by id' do
+ it "get a single board by id" do
get api(url, user)
- expect_schema_match_for(response, 'public_api/v4/board', ee)
+ expect_schema_match_for(response, "public_api/v4/board", ee)
end
end
end
@@ -48,17 +48,17 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
describe "GET #{route_definition}/:board_id/lists" do
let(:url) { "#{root_url}/#{board.id}/lists" }
- it 'returns issue board lists' do
+ it "returns issue board lists" do
get api(url, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- expect(json_response.first['label']['name']).to eq(dev_label.title)
+ expect(json_response.first["label"]["name"]).to eq(dev_label.title)
end
- it 'returns 404 if board not found' do
+ it "returns 404 if board not found" do
get api("#{root_url}/22343/lists", user)
expect(response).to have_gitlab_http_status(404)
@@ -68,16 +68,16 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
describe "GET #{route_definition}/:board_id/lists/:list_id" do
let(:url) { "#{root_url}/#{board.id}/lists" }
- it 'returns a list' do
+ it "returns a list" do
get api("#{url}/#{dev_list.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(dev_list.id)
- expect(json_response['label']['name']).to eq(dev_label.title)
- expect(json_response['position']).to eq(1)
+ expect(json_response["id"]).to eq(dev_list.id)
+ expect(json_response["label"]["name"]).to eq(dev_label.title)
+ expect(json_response["position"]).to eq(1)
end
- it 'returns 404 if list not found' do
+ it "returns 404 if list not found" do
get api("#{url}/5324", user)
expect(response).to have_gitlab_http_status(404)
@@ -87,22 +87,22 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
describe "POST #{route_definition}/lists" do
let(:url) { "#{root_url}/#{board.id}/lists" }
- it 'creates a new issue board list for labels' do
- post api(url, user), params: { label_id: ux_label.id }
+ it "creates a new issue board list for labels" do
+ post api(url, user), params: {label_id: ux_label.id}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['label']['name']).to eq(ux_label.title)
- expect(json_response['position']).to eq(3)
+ expect(json_response["label"]["name"]).to eq(ux_label.title)
+ expect(json_response["position"]).to eq(3)
end
- it 'returns 400 when creating a new list if label_id is invalid' do
- post api(url, user), params: { label_id: 23423 }
+ it "returns 400 when creating a new list if label_id is invalid" do
+ post api(url, user), params: {label_id: 23423}
expect(response).to have_gitlab_http_status(400)
end
- it 'returns 403 for members with guest role' do
- put api("#{url}/#{test_list.id}", guest), params: { position: 1 }
+ it "returns 403 for members with guest role" do
+ put api("#{url}/#{test_list.id}", guest), params: {position: 1}
expect(response).to have_gitlab_http_status(403)
end
@@ -112,20 +112,20 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
let(:url) { "#{root_url}/#{board.id}/lists" }
it "updates a list" do
- put api("#{url}/#{test_list.id}", user), params: { position: 1 }
+ put api("#{url}/#{test_list.id}", user), params: {position: 1}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['position']).to eq(1)
+ expect(json_response["position"]).to eq(1)
end
it "returns 404 error if list id not found" do
- put api("#{url}/44444", user), params: { position: 1 }
+ put api("#{url}/44444", user), params: {position: 1}
expect(response).to have_gitlab_http_status(404)
end
it "returns 403 for members with guest role" do
- put api("#{url}/#{test_list.id}", guest), params: { position: 1 }
+ put api("#{url}/#{test_list.id}", guest), params: {position: 1}
expect(response).to have_gitlab_http_status(403)
end
@@ -169,7 +169,7 @@ shared_examples_for 'group and project boards' do |route_definition, ee = false|
expect(response).to have_gitlab_http_status(204)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("#{url}/#{dev_list.id}", owner) }
end
end
diff --git a/spec/support/api/issues_resolving_discussions_shared_examples.rb b/spec/support/api/issues_resolving_discussions_shared_examples.rb
index d2d6260dfa8..1323a807e5c 100644
--- a/spec/support/api/issues_resolving_discussions_shared_examples.rb
+++ b/spec/support/api/issues_resolving_discussions_shared_examples.rb
@@ -1,15 +1,15 @@
-shared_examples 'creating an issue resolving discussions through the API' do
- it 'creates a new project issue' do
+shared_examples "creating an issue resolving discussions through the API" do
+ it "creates a new project issue" do
expect(response).to have_gitlab_http_status(:created)
end
- it 'resolves the discussions in a merge request' do
+ it "resolves the discussions in a merge request" do
discussion.first_note.reload
expect(discussion.resolved?).to be(true)
end
- it 'assigns a description to the issue mentioning the merge request' do
- expect(json_response['description']).to include(merge_request.to_reference)
+ it "assigns a description to the issue mentioning the merge request" do
+ expect(json_response["description"]).to include(merge_request.to_reference)
end
end
diff --git a/spec/support/api/members_shared_examples.rb b/spec/support/api/members_shared_examples.rb
index 8d910e52eda..4f662af6efc 100644
--- a/spec/support/api/members_shared_examples.rb
+++ b/spec/support/api/members_shared_examples.rb
@@ -1,9 +1,9 @@
-shared_examples 'a 404 response when source is private' do
+shared_examples "a 404 response when source is private" do
before do
source.update_column(:visibility_level, Gitlab::VisibilityLevel::PRIVATE)
end
- it 'returns 404' do
+ it "returns 404" do
route
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/support/api/milestones_shared_examples.rb b/spec/support/api/milestones_shared_examples.rb
index 5f709831ce1..8c7db674bf3 100644
--- a/spec/support/api/milestones_shared_examples.rb
+++ b/spec/support/api/milestones_shared_examples.rb
@@ -1,114 +1,114 @@
-shared_examples_for 'group and project milestones' do |route_definition|
+shared_examples_for "group and project milestones" do |route_definition|
let(:resource_route) { "#{route}/#{milestone.id}" }
- let(:label_1) { create(:label, title: 'label_1', project: project, priority: 1) }
- let(:label_2) { create(:label, title: 'label_2', project: project, priority: 2) }
- let(:label_3) { create(:label, title: 'label_3', project: project) }
+ let(:label_1) { create(:label, title: "label_1", project: project, priority: 1) }
+ let(:label_2) { create(:label, title: "label_2", project: project, priority: 2) }
+ let(:label_3) { create(:label, title: "label_3", project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
let(:another_merge_request) { create(:merge_request, :simple, source_project: project) }
describe "GET #{route_definition}" do
- it 'returns milestones list' do
+ it "returns milestones list" do
get api(route, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['title']).to eq(milestone.title)
+ expect(json_response.first["title"]).to eq(milestone.title)
end
- it 'returns a 401 error if user not authenticated' do
+ it "returns a 401 error if user not authenticated" do
get api(route)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns an array of active milestones' do
+ it "returns an array of active milestones" do
get api("#{route}/?state=active", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(milestone.id)
+ expect(json_response.first["id"]).to eq(milestone.id)
end
- it 'returns an array of closed milestones' do
+ it "returns an array of closed milestones" do
get api("#{route}/?state=closed", user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(closed_milestone.id)
+ expect(json_response.first["id"]).to eq(closed_milestone.id)
end
- it 'returns an array of milestones specified by iids' do
+ it "returns an array of milestones specified by iids" do
other_milestone = create(:milestone, project: try(:project), group: try(:group))
- get api(route, user), params: { iids: [closed_milestone.iid, other_milestone.iid] }
+ get api(route, user), params: {iids: [closed_milestone.iid, other_milestone.iid]}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(2)
- expect(json_response.map { |m| m['id'] }).to match_array([closed_milestone.id, other_milestone.id])
+ expect(json_response.map { |m| m["id"] }).to match_array([closed_milestone.id, other_milestone.id])
end
- it 'does not return any milestone if none found' do
- get api(route, user), params: { iids: [Milestone.maximum(:iid).succ] }
+ it "does not return any milestone if none found" do
+ get api(route, user), params: {iids: [Milestone.maximum(:iid).succ]}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'returns a milestone by iids array' do
+ it "returns a milestone by iids array" do
get api("#{route}?iids=#{closed_milestone.iid}", user)
expect(response.status).to eq 200
expect(response).to include_pagination_headers
expect(json_response.size).to eq(1)
expect(json_response.size).to eq(1)
- expect(json_response.first['title']).to eq closed_milestone.title
- expect(json_response.first['id']).to eq closed_milestone.id
+ expect(json_response.first["title"]).to eq closed_milestone.title
+ expect(json_response.first["id"]).to eq closed_milestone.id
end
- it 'returns a milestone by searching for title' do
- get api(route, user), params: { search: 'version2' }
+ it "returns a milestone by searching for title" do
+ get api(route, user), params: {search: "version2"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to eq(1)
- expect(json_response.first['title']).to eq milestone.title
- expect(json_response.first['id']).to eq milestone.id
+ expect(json_response.first["title"]).to eq milestone.title
+ expect(json_response.first["id"]).to eq milestone.id
end
- it 'returns a milestones by searching for description' do
- get api(route, user), params: { search: 'open' }
+ it "returns a milestones by searching for description" do
+ get api(route, user), params: {search: "open"}
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response.size).to eq(1)
- expect(json_response.first['title']).to eq milestone.title
- expect(json_response.first['id']).to eq milestone.id
+ expect(json_response.first["title"]).to eq milestone.title
+ expect(json_response.first["id"]).to eq milestone.id
end
end
describe "GET #{route_definition}/:milestone_id" do
- it 'returns a milestone by id' do
+ it "returns a milestone by id" do
get api(resource_route, user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq(milestone.title)
- expect(json_response['iid']).to eq(milestone.iid)
+ expect(json_response["title"]).to eq(milestone.title)
+ expect(json_response["iid"]).to eq(milestone.iid)
end
- it 'returns 401 error if user not authenticated' do
+ it "returns 401 error if user not authenticated" do
get api(resource_route)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns a 404 error if milestone id not found' do
+ it "returns a 404 error if milestone id not found" do
get api("#{route}/1234", user)
expect(response).to have_gitlab_http_status(404)
@@ -116,76 +116,76 @@ shared_examples_for 'group and project milestones' do |route_definition|
end
describe "POST #{route_definition}" do
- it 'creates a new milestone' do
- post api(route, user), params: { title: 'new milestone' }
+ it "creates a new milestone" do
+ post api(route, user), params: {title: "new milestone"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('new milestone')
- expect(json_response['description']).to be_nil
+ expect(json_response["title"]).to eq("new milestone")
+ expect(json_response["description"]).to be_nil
end
- it 'creates a new milestone with description and dates' do
- post api(route, user), params: { title: 'new milestone', description: 'release', due_date: '2013-03-02', start_date: '2013-02-02' }
+ it "creates a new milestone with description and dates" do
+ post api(route, user), params: {title: "new milestone", description: "release", due_date: "2013-03-02", start_date: "2013-02-02"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['description']).to eq('release')
- expect(json_response['due_date']).to eq('2013-03-02')
- expect(json_response['start_date']).to eq('2013-02-02')
+ expect(json_response["description"]).to eq("release")
+ expect(json_response["due_date"]).to eq("2013-03-02")
+ expect(json_response["start_date"]).to eq("2013-02-02")
end
- it 'returns a 400 error if title is missing' do
+ it "returns a 400 error if title is missing" do
post api(route, user)
expect(response).to have_gitlab_http_status(400)
end
- it 'returns a 400 error if params are invalid (duplicate title)' do
- post api(route, user), params: { title: milestone.title, description: 'release', due_date: '2013-03-02' }
+ it "returns a 400 error if params are invalid (duplicate title)" do
+ post api(route, user), params: {title: milestone.title, description: "release", due_date: "2013-03-02"}
expect(response).to have_gitlab_http_status(400)
end
- it 'creates a new milestone with reserved html characters' do
- post api(route, user), params: { title: 'foo & bar 1.1 -> 2.2' }
+ it "creates a new milestone with reserved html characters" do
+ post api(route, user), params: {title: "foo & bar 1.1 -> 2.2"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['title']).to eq('foo & bar 1.1 -> 2.2')
- expect(json_response['description']).to be_nil
+ expect(json_response["title"]).to eq("foo & bar 1.1 -> 2.2")
+ expect(json_response["description"]).to be_nil
end
end
describe "PUT #{route_definition}/:milestone_id" do
- it 'updates a milestone' do
- put api(resource_route, user), params: { title: 'updated title' }
+ it "updates a milestone" do
+ put api(resource_route, user), params: {title: "updated title"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['title']).to eq('updated title')
+ expect(json_response["title"]).to eq("updated title")
end
- it 'removes a due date if nil is passed' do
+ it "removes a due date if nil is passed" do
milestone.update!(due_date: "2016-08-05")
- put api(resource_route, user), params: { due_date: nil }
+ put api(resource_route, user), params: {due_date: nil}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['due_date']).to be_nil
+ expect(json_response["due_date"]).to be_nil
end
- it 'returns a 404 error if milestone id not found' do
- put api("#{route}/1234", user), params: { title: 'updated title' }
+ it "returns a 404 error if milestone id not found" do
+ put api("#{route}/1234", user), params: {title: "updated title"}
expect(response).to have_gitlab_http_status(404)
end
- it 'closes milestone' do
- put api(resource_route, user), params: { state_event: 'close' }
+ it "closes milestone" do
+ put api(resource_route, user), params: {state_event: "close"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['state']).to eq('closed')
+ expect(json_response["state"]).to eq("closed")
end
- it 'updates milestone with only start date' do
- put api(resource_route, user), params: { start_date: Date.tomorrow }
+ it "updates milestone with only start date" do
+ put api(resource_route, user), params: {start_date: Date.tomorrow}
expect(response).to have_gitlab_http_status(200)
end
@@ -201,7 +201,7 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to have_gitlab_http_status(403)
end
- it 'deletes the milestone when the user has developer access to the project' do
+ it "deletes the milestone when the user has developer access to the project" do
delete api(resource_route, user)
expect(project.milestones.find_by_id(milestone.id)).to be_nil
@@ -215,41 +215,41 @@ shared_examples_for 'group and project milestones' do |route_definition|
before do
milestone.issues << create(:issue, project: project)
end
- it 'returns issues for a particular milestone' do
+ it "returns issues for a particular milestone" do
get api(issues_route, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['milestone']['title']).to eq(milestone.title)
+ expect(json_response.first["milestone"]["title"]).to eq(milestone.title)
end
- it 'returns issues sorted by label priority' do
+ it "returns issues sorted by label priority" do
issue_1 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_3])
issue_2 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_1])
issue_3 = create(:labeled_issue, project: project, milestone: milestone, labels: [label_2])
get api(issues_route, user)
- expect(json_response.first['id']).to eq(issue_2.id)
- expect(json_response.second['id']).to eq(issue_3.id)
- expect(json_response.third['id']).to eq(issue_1.id)
+ expect(json_response.first["id"]).to eq(issue_2.id)
+ expect(json_response.second["id"]).to eq(issue_3.id)
+ expect(json_response.third["id"]).to eq(issue_1.id)
end
- it 'matches V4 response schema for a list of issues' do
+ it "matches V4 response schema for a list of issues" do
get api(issues_route, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/issues')
+ expect(response).to match_response_schema("public_api/v4/issues")
end
- it 'returns a 401 error if user not authenticated' do
+ it "returns a 401 error if user not authenticated" do
get api(issues_route)
expect(response).to have_gitlab_http_status(401)
end
- describe 'confidential issues' do
+ describe "confidential issues" do
let!(:public_project) { create(:project, :public) }
let!(:context_group) { try(:group) }
let!(:milestone) do
@@ -273,7 +273,7 @@ shared_examples_for 'group and project milestones' do |route_definition|
milestone.issues << issue << confidential_issue
end
- it 'returns confidential issues to team members' do
+ it "returns confidential issues to team members" do
get api(issues_route, user)
expect(response).to have_gitlab_http_status(200)
@@ -281,10 +281,10 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(json_response).to be_an Array
# 2 for projects, 3 for group(which has another project with an issue)
expect(json_response.size).to be_between(2, 3)
- expect(json_response.map { |issue| issue['id'] }).to include(issue.id, confidential_issue.id)
+ expect(json_response.map { |issue| issue["id"] }).to include(issue.id, confidential_issue.id)
end
- it 'does not return confidential issues to team members with guest role' do
+ it "does not return confidential issues to team members with guest role" do
member = create(:user)
public_project.add_guest(member)
@@ -294,20 +294,20 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
+ expect(json_response.map { |issue| issue["id"] }).to include(issue.id)
end
- it 'does not return confidential issues to regular users' do
+ it "does not return confidential issues to regular users" do
get api(issues_route, create(:user))
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response.map { |issue| issue['id'] }).to include(issue.id)
+ expect(json_response.map { |issue| issue["id"] }).to include(issue.id)
end
- it 'returns issues ordered by label priority' do
+ it "returns issues ordered by label priority" do
issue.labels << label_2
confidential_issue.labels << label_1
@@ -318,8 +318,8 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(json_response).to be_an Array
# 2 for projects, 3 for group(which has another project with an issue)
expect(json_response.size).to be_between(2, 3)
- expect(json_response.first['id']).to eq(confidential_issue.id)
- expect(json_response.second['id']).to eq(issue.id)
+ expect(json_response.first["id"]).to eq(confidential_issue.id)
+ expect(json_response.second["id"]).to eq(issue.id)
end
end
end
@@ -331,7 +331,7 @@ shared_examples_for 'group and project milestones' do |route_definition|
milestone.merge_requests << merge_request
end
- it 'returns merge_requests for a particular milestone' do
+ it "returns merge_requests for a particular milestone" do
# eager-load another_merge_request
another_merge_request
get api(merge_requests_route, user)
@@ -339,23 +339,23 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.size).to eq(1)
- expect(json_response.first['title']).to eq(merge_request.title)
- expect(json_response.first['milestone']['title']).to eq(milestone.title)
+ expect(json_response.first["title"]).to eq(merge_request.title)
+ expect(json_response.first["milestone"]["title"]).to eq(milestone.title)
end
- it 'returns merge_requests sorted by label priority' do
- merge_request_1 = create(:labeled_merge_request, source_branch: 'branch_1', source_project: project, milestone: milestone, labels: [label_2])
- merge_request_2 = create(:labeled_merge_request, source_branch: 'branch_2', source_project: project, milestone: milestone, labels: [label_1])
- merge_request_3 = create(:labeled_merge_request, source_branch: 'branch_3', source_project: project, milestone: milestone, labels: [label_3])
+ it "returns merge_requests sorted by label priority" do
+ merge_request_1 = create(:labeled_merge_request, source_branch: "branch_1", source_project: project, milestone: milestone, labels: [label_2])
+ merge_request_2 = create(:labeled_merge_request, source_branch: "branch_2", source_project: project, milestone: milestone, labels: [label_1])
+ merge_request_3 = create(:labeled_merge_request, source_branch: "branch_3", source_project: project, milestone: milestone, labels: [label_3])
get api(merge_requests_route, user)
- expect(json_response.first['id']).to eq(merge_request_2.id)
- expect(json_response.second['id']).to eq(merge_request_1.id)
- expect(json_response.third['id']).to eq(merge_request_3.id)
+ expect(json_response.first["id"]).to eq(merge_request_2.id)
+ expect(json_response.second["id"]).to eq(merge_request_1.id)
+ expect(json_response.third["id"]).to eq(merge_request_3.id)
end
- it 'returns a 404 error if milestone id not found' do
+ it "returns a 404 error if milestone id not found" do
not_found_route = "#{route}/1234/merge_requests"
get api(not_found_route, user)
@@ -363,20 +363,20 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 if the user has no access to the milestone' do
+ it "returns a 404 if the user has no access to the milestone" do
new_user = create :user
get api(merge_requests_route, new_user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 401 error if user not authenticated' do
+ it "returns a 401 error if user not authenticated" do
get api(merge_requests_route)
expect(response).to have_gitlab_http_status(401)
end
- it 'returns merge_requests ordered by position asc' do
+ it "returns merge_requests ordered by position asc" do
milestone.merge_requests << another_merge_request
another_merge_request.labels << label_1
merge_request.labels << label_2
@@ -387,8 +387,8 @@ shared_examples_for 'group and project milestones' do |route_definition|
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq(2)
- expect(json_response.first['id']).to eq(another_merge_request.id)
- expect(json_response.second['id']).to eq(merge_request.id)
+ expect(json_response.first["id"]).to eq(another_merge_request.id)
+ expect(json_response.second["id"]).to eq(merge_request.id)
end
end
end
diff --git a/spec/support/api/repositories_shared_context.rb b/spec/support/api/repositories_shared_context.rb
index f1341804e56..a410e71ccb5 100644
--- a/spec/support/api/repositories_shared_context.rb
+++ b/spec/support/api/repositories_shared_context.rb
@@ -1,4 +1,4 @@
-shared_context 'disabled repository' do
+shared_context "disabled repository" do
before do
project.project_feature.update!(
repository_access_level: ProjectFeature::DISABLED,
diff --git a/spec/support/api/schema_matcher.rb b/spec/support/api/schema_matcher.rb
index 6591d56e473..51fd655cd4d 100644
--- a/spec/support/api/schema_matcher.rb
+++ b/spec/support/api/schema_matcher.rb
@@ -1,13 +1,14 @@
module SchemaPath
- def self.expand(schema, dir = '')
- Rails.root.join('spec', dir, "fixtures/api/schemas/#{schema}.json").to_s
+ def self.expand(schema, dir = "")
+ Rails.root.join("spec", dir, "fixtures/api/schemas/#{schema}.json").to_s
end
end
-RSpec::Matchers.define :match_response_schema do |schema, dir: '', **options|
+RSpec::Matchers.define :match_response_schema do |schema, dir: "", **options|
match do |response|
@errors = JSON::Validator.fully_validate(
- SchemaPath.expand(schema, dir), response.body, options)
+ SchemaPath.expand(schema, dir), response.body, options
+ )
@errors.empty?
end
@@ -18,7 +19,7 @@ RSpec::Matchers.define :match_response_schema do |schema, dir: '', **options|
end
end
-RSpec::Matchers.define :match_schema do |schema, dir: '', **options|
+RSpec::Matchers.define :match_schema do |schema, dir: "", **options|
match do |data|
JSON::Validator.validate!(SchemaPath.expand(schema, dir), data, options)
end
diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb
index 683234264a8..355fe76a3b0 100644
--- a/spec/support/api/scopes/read_user_shared_examples.rb
+++ b/spec/support/api/scopes/read_user_shared_examples.rb
@@ -1,9 +1,9 @@
shared_examples_for 'allows the "read_user" scope' do |api_version|
- let(:version) { api_version || 'v4' }
+ let(:version) { api_version || "v4" }
- context 'for personal access tokens' do
+ context "for personal access tokens" do
context 'when the requesting token has the "api" scope' do
- let(:token) { create(:personal_access_token, scopes: ['api'], user: user) }
+ let(:token) { create(:personal_access_token, scopes: ["api"], user: user) }
it 'returns a "200" response' do
get api_call.call(path, user, personal_access_token: token, version: version)
@@ -13,7 +13,7 @@ shared_examples_for 'allows the "read_user" scope' do |api_version|
end
context 'when the requesting token has the "read_user" scope' do
- let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) }
+ let(:token) { create(:personal_access_token, scopes: ["read_user"], user: user) }
it 'returns a "200" response' do
get api_call.call(path, user, personal_access_token: token, version: version)
@@ -22,8 +22,8 @@ shared_examples_for 'allows the "read_user" scope' do |api_version|
end
end
- context 'when the requesting token does not have any required scope' do
- let(:token) { create(:personal_access_token, scopes: ['read_registry'], user: user) }
+ context "when the requesting token does not have any required scope" do
+ let(:token) { create(:personal_access_token, scopes: ["read_registry"], user: user) }
before do
stub_container_registry_config(enabled: true)
@@ -37,7 +37,7 @@ shared_examples_for 'allows the "read_user" scope' do |api_version|
end
end
- context 'for doorkeeper (OAuth) tokens' do
+ context "for doorkeeper (OAuth) tokens" do
let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) }
context 'when the requesting token has the "api" scope' do
@@ -60,7 +60,7 @@ shared_examples_for 'allows the "read_user" scope' do |api_version|
end
end
- context 'when the requesting token does not have any required scope' do
+ context "when the requesting token does not have any required scope" do
let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "invalid" }
it 'returns a "403" response' do
@@ -74,7 +74,7 @@ end
shared_examples_for 'does not allow the "read_user" scope' do
context 'when the requesting token has the "read_user" scope' do
- let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) }
+ let(:token) { create(:personal_access_token, scopes: ["read_user"], user: user) }
it 'returns a "403" response' do
post api_call.call(path, user, personal_access_token: token), params: attributes_for(:user, projects_limit: 3)
diff --git a/spec/support/api/time_tracking_shared_examples.rb b/spec/support/api/time_tracking_shared_examples.rb
index e883d33f671..74868dfe845 100644
--- a/spec/support/api/time_tracking_shared_examples.rb
+++ b/spec/support/api/time_tracking_shared_examples.rb
@@ -1,144 +1,144 @@
-shared_examples 'an unauthorized API user' do
+shared_examples "an unauthorized API user" do
it { is_expected.to eq(403) }
end
-shared_examples 'time tracking endpoints' do |issuable_name|
+shared_examples "time tracking endpoints" do |issuable_name|
issuable_collection_name = issuable_name.pluralize
describe "POST /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/time_estimate" do
- context 'with an unauthorized user' do
- subject { post(api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", non_member), params: { duration: '1w' }) }
+ context "with an unauthorized user" do
+ subject { post(api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", non_member), params: {duration: "1w"}) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
it "sets the time estimate for #{issuable_name}" do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: { duration: '1w' }
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: {duration: "1w"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['human_time_estimate']).to eq('1w')
+ expect(json_response["human_time_estimate"]).to eq("1w")
end
- describe 'updating the current estimate' do
+ describe "updating the current estimate" do
before do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: { duration: '1w' }
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: {duration: "1w"}
end
- context 'when duration has a bad format' do
- it 'does not modify the original estimate' do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: { duration: 'foo' }
+ context "when duration has a bad format" do
+ it "does not modify the original estimate" do
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: {duration: "foo"}
expect(response).to have_gitlab_http_status(400)
- expect(issuable.reload.human_time_estimate).to eq('1w')
+ expect(issuable.reload.human_time_estimate).to eq("1w")
end
end
- context 'with a valid duration' do
- it 'updates the estimate' do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: { duration: '3w1h' }
+ context "with a valid duration" do
+ it "updates the estimate" do
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_estimate", user), params: {duration: "3w1h"}
expect(response).to have_gitlab_http_status(200)
- expect(issuable.reload.human_time_estimate).to eq('3w 1h')
+ expect(issuable.reload.human_time_estimate).to eq("3w 1h")
end
end
end
end
describe "POST /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/reset_time_estimate" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject { post(api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_time_estimate", non_member)) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
it "resets the time estimate for #{issuable_name}" do
post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_time_estimate", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['time_estimate']).to eq(0)
+ expect(json_response["time_estimate"]).to eq(0)
end
end
describe "POST /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/add_spent_time" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", non_member), params: { duration: '2h' }
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", non_member), params: {duration: "2h"}
end
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
it "add spent time for #{issuable_name}" do
Timecop.travel(1.minute.from_now) do
- expect do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: { duration: '2h' }
- end.to change { issuable.reload.updated_at }
+ expect {
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: {duration: "2h"}
+ }.to change { issuable.reload.updated_at }
end
expect(response).to have_gitlab_http_status(201)
- expect(json_response['human_total_time_spent']).to eq('2h')
+ expect(json_response["human_total_time_spent"]).to eq("2h")
end
- context 'when subtracting time' do
- it 'subtracts time of the total spent time' do
+ context "when subtracting time" do
+ it "subtracts time of the total spent time" do
Timecop.travel(1.minute.from_now) do
- expect do
- issuable.update!(spend_time: { duration: 7200, user_id: user.id })
- end.to change { issuable.reload.updated_at }
+ expect {
+ issuable.update!(spend_time: {duration: 7200, user_id: user.id})
+ }.to change { issuable.reload.updated_at }
end
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: { duration: '-1h' }
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: {duration: "-1h"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['total_time_spent']).to eq(3600)
+ expect(json_response["total_time_spent"]).to eq(3600)
end
end
- context 'when time to subtract is greater than the total spent time' do
- it 'does not modify the total time spent' do
- issuable.update!(spend_time: { duration: 7200, user_id: user.id })
+ context "when time to subtract is greater than the total spent time" do
+ it "does not modify the total time spent" do
+ issuable.update!(spend_time: {duration: 7200, user_id: user.id})
Timecop.travel(1.minute.from_now) do
- expect do
- post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: { duration: '-1w' }
- end.not_to change { issuable.reload.updated_at }
+ expect {
+ post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/add_spent_time", user), params: {duration: "-1w"}
+ }.not_to change { issuable.reload.updated_at }
end
expect(response).to have_gitlab_http_status(400)
- expect(json_response['message']['time_spent'].first).to match(/exceeds the total time spent/)
+ expect(json_response["message"]["time_spent"].first).to match(/exceeds the total time spent/)
end
end
end
describe "POST /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/reset_spent_time" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject { post(api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", non_member)) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
it "resets spent time for #{issuable_name}" do
Timecop.travel(1.minute.from_now) do
- expect do
+ expect {
post api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/reset_spent_time", user)
- end.to change { issuable.reload.updated_at }
+ }.to change { issuable.reload.updated_at }
end
expect(response).to have_gitlab_http_status(200)
- expect(json_response['total_time_spent']).to eq(0)
+ expect(json_response["total_time_spent"]).to eq(0)
end
end
describe "GET /projects/:id/#{issuable_collection_name}/:#{issuable_name}_id/time_stats" do
it "returns the time stats for #{issuable_name}" do
- issuable.update!(spend_time: { duration: 1800, user_id: user.id },
+ issuable.update!(spend_time: {duration: 1800, user_id: user.id},
time_estimate: 3600)
get api("/projects/#{project.id}/#{issuable_collection_name}/#{issuable.iid}/time_stats", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['total_time_spent']).to eq(1800)
- expect(json_response['time_estimate']).to eq(3600)
+ expect(json_response["total_time_spent"]).to eq(1800)
+ expect(json_response["time_estimate"]).to eq(3600)
end
end
end
diff --git a/spec/support/banzai/reference_filter_shared_examples.rb b/spec/support/banzai/reference_filter_shared_examples.rb
index 476d80f3a93..38d14bac8c6 100644
--- a/spec/support/banzai/reference_filter_shared_examples.rb
+++ b/spec/support/banzai/reference_filter_shared_examples.rb
@@ -2,11 +2,11 @@
#
# Requires a reference:
# let(:reference) { '#42' }
-shared_examples 'a reference containing an element node' do
- let(:inner_html) { 'element <code>node</code> inside' }
- let(:reference_with_element) { %{<a href="#{reference}">#{inner_html}</a>} }
+shared_examples "a reference containing an element node" do
+ let(:inner_html) { "element <code>node</code> inside" }
+ let(:reference_with_element) { %(<a href="#{reference}">#{inner_html}</a>) }
- it 'does not escape inner html' do
+ it "does not escape inner html" do
doc = reference_filter(reference_with_element)
expect(doc.children.first.inner_html).to eq(inner_html)
end
@@ -16,69 +16,69 @@ end
# subject { create(:user) }
# let(:reference) { subject.to_reference }
# let(:subject_name) { 'user' }
-shared_examples 'user reference or project reference' do
- shared_examples 'it contains a data- attribute' do
- it 'includes a data- attribute' do
+shared_examples "user reference or project reference" do
+ shared_examples "it contains a data- attribute" do
+ it "includes a data- attribute" do
doc = reference_filter("Hey #{reference}")
- link = doc.css('a').first
+ link = doc.css("a").first
expect(link).to have_attribute("data-#{subject_name}")
expect(link.attr("data-#{subject_name}")).to eq subject.id.to_s
end
end
- context 'mentioning a resource' do
- it_behaves_like 'a reference containing an element node'
- it_behaves_like 'it contains a data- attribute'
+ context "mentioning a resource" do
+ it_behaves_like "a reference containing an element node"
+ it_behaves_like "it contains a data- attribute"
it "links to a resource" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.send("#{subject_name}_url", subject)
+ expect(doc.css("a").first.attr("href")).to eq urls.send("#{subject_name}_url", subject)
end
- it 'links to a resource with a period' do
- subject = create(subject_name.to_sym, name: 'alphA.Beta')
+ it "links to a resource with a period" do
+ subject = create(subject_name.to_sym, name: "alphA.Beta")
doc = reference_filter("Hey #{get_reference(subject)}")
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'links to a resource with an underscore' do
- subject = create(subject_name.to_sym, name: 'ping_pong_king')
+ it "links to a resource with an underscore" do
+ subject = create(subject_name.to_sym, name: "ping_pong_king")
doc = reference_filter("Hey #{get_reference(subject)}")
- expect(doc.css('a').length).to eq 1
+ expect(doc.css("a").length).to eq 1
end
- it 'links to a resource with different case-sensitivity' do
- subject = create(subject_name.to_sym, name: 'RescueRanger')
+ it "links to a resource with different case-sensitivity" do
+ subject = create(subject_name.to_sym, name: "RescueRanger")
reference = get_reference(subject)
doc = reference_filter("Hey #{reference.upcase}")
- expect(doc.css('a').length).to eq 1
- expect(doc.css('a').text).to eq(reference)
+ expect(doc.css("a").length).to eq 1
+ expect(doc.css("a").text).to eq(reference)
end
end
- it 'supports an :only_path context' do
+ it "supports an :only_path context" do
doc = reference_filter("Hey #{reference}", only_path: true)
- link = doc.css('a').first.attr('href')
+ link = doc.css("a").first.attr("href")
- expect(link).not_to match %r(https?://)
+ expect(link).not_to match %r{https?://}
expect(link).to eq urls.send "#{subject_name}_path", subject
end
- context 'referencing a resource in a link href' do
- let(:reference) { %Q{<a href="#{get_reference(subject)}">Some text</a>} }
+ context "referencing a resource in a link href" do
+ let(:reference) { %(<a href="#{get_reference(subject)}">Some text</a>) }
- it_behaves_like 'it contains a data- attribute'
+ it_behaves_like "it contains a data- attribute"
- it 'links to the resource' do
+ it "links to the resource" do
doc = reference_filter("Hey #{reference}")
- expect(doc.css('a').first.attr('href')).to eq urls.send "#{subject_name}_url", subject
+ expect(doc.css("a").first.attr("href")).to eq urls.send "#{subject_name}_url", subject
end
- it 'links with adjacent text' do
+ it "links with adjacent text" do
doc = reference_filter("Mention me (#{reference}.)")
expect(doc.to_html).to match(%r{\(<a.+>Some text</a>\.\)})
end
diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb
index 18a7a392c12..07ad9ffb25e 100644
--- a/spec/support/capybara.rb
+++ b/spec/support/capybara.rb
@@ -1,11 +1,11 @@
# rubocop:disable Style/GlobalVars
-require 'capybara/rails'
-require 'capybara/rspec'
-require 'capybara-screenshot/rspec'
-require 'selenium-webdriver'
+require "capybara/rails"
+require "capybara/rspec"
+require "capybara-screenshot/rspec"
+require "selenium-webdriver"
# Give CI some extra time
-timeout = (ENV['CI'] || ENV['CI_SERVER']) ? 60 : 30
+timeout = ENV["CI"] || ENV["CI_SERVER"] ? 60 : 30
# Define an error class for JS console messages
JSConsoleError = Class.new(StandardError)
@@ -14,7 +14,7 @@ JSConsoleError = Class.new(StandardError)
JS_CONSOLE_FILTER = Regexp.union([
'"[HMR] Waiting for update signal from WDS..."',
'"[WDS] Hot Module Replacement enabled."',
- "Download the Vue Devtools extension"
+ "Download the Vue Devtools extension",
])
Capybara.register_driver :chrome do |app|
@@ -24,7 +24,7 @@ Capybara.register_driver :chrome do |app|
browser: "ALL",
client: "ALL",
driver: "ALL",
- server: "ALL"
+ server: "ALL",
}
)
@@ -35,10 +35,10 @@ Capybara.register_driver :chrome do |app|
options.add_argument("no-sandbox")
# Run headless by default unless CHROME_HEADLESS specified
- options.add_argument("headless") unless ENV['CHROME_HEADLESS'] =~ /^(false|no|0)$/i
+ options.add_argument("headless") unless ENV["CHROME_HEADLESS"] =~ /^(false|no|0)$/i
# Disable /dev/shm use in CI. See https://gitlab.com/gitlab-org/gitlab-ee/issues/4252
- options.add_argument("disable-dev-shm-usage") if ENV['CI'] || ENV['CI_SERVER']
+ options.add_argument("disable-dev-shm-usage") if ENV["CI"] || ENV["CI_SERVER"]
Capybara::Selenium::Driver.new(
app,
@@ -75,11 +75,16 @@ RSpec.configure do |config|
allow(Gitlab::Application.routes).to receive(:default_url_options).and_return(
host: session.server.host,
port: session.server.port,
- protocol: 'http')
+ protocol: "http"
+ )
# reset window size between tests
unless session.current_window.size == [1240, 1400]
- session.current_window.resize_to(1240, 1400) rescue nil
+ begin
+ session.current_window.resize_to(1240, 1400)
+ rescue
+ nil
+ end
end
end
@@ -94,7 +99,7 @@ RSpec.configure do |config|
end
# prevent localStorage from introducing side effects based on test order
- unless ['', 'about:blank', 'data:,'].include? Capybara.current_session.driver.browser.current_url
+ unless ["", "about:blank", "data:,"].include? Capybara.current_session.driver.browser.current_url
execute_script("localStorage.clear();")
end
diff --git a/spec/support/carrierwave.rb b/spec/support/carrierwave.rb
index b376822d530..673fe328ac8 100644
--- a/spec/support/carrierwave.rb
+++ b/spec/support/carrierwave.rb
@@ -1,4 +1,4 @@
-CarrierWave.root = File.expand_path('tmp/tests/public', Rails.root)
+CarrierWave.root = File.expand_path("tmp/tests/public", Rails.root)
RSpec.configure do |config|
config.after do
diff --git a/spec/support/chunked_io/chunked_io_helpers.rb b/spec/support/chunked_io/chunked_io_helpers.rb
index fec1f951563..ebadb29eaf3 100644
--- a/spec/support/chunked_io/chunked_io_helpers.rb
+++ b/spec/support/chunked_io/chunked_io_helpers.rb
@@ -1,11 +1,11 @@
module ChunkedIOHelpers
def sample_trace_raw
- @sample_trace_raw ||= File.read(expand_fixture_path('trace/sample_trace'))
+ @sample_trace_raw ||= File.read(expand_fixture_path("trace/sample_trace"))
.force_encoding(Encoding::BINARY)
end
def stub_buffer_size(size)
- stub_const('Ci::BuildTraceChunk::CHUNK_SIZE', size)
- stub_const('Gitlab::Ci::Trace::ChunkedIO::CHUNK_SIZE', size)
+ stub_const("Ci::BuildTraceChunk::CHUNK_SIZE", size)
+ stub_const("Gitlab::Ci::Trace::ChunkedIO::CHUNK_SIZE", size)
end
end
diff --git a/spec/support/commit_trailers_spec_helper.rb b/spec/support/commit_trailers_spec_helper.rb
index efa317fd2f9..b53230e5545 100644
--- a/spec/support/commit_trailers_spec_helper.rb
+++ b/spec/support/commit_trailers_spec_helper.rb
@@ -5,7 +5,7 @@ module CommitTrailersSpecHelper
wrapper = find_user_wrapper(doc, trailer)
expect_to_have_links_with_url_and_avatar(wrapper, urls.user_url(user), email || user.email)
- expect(wrapper.attribute('data-user').value).to eq user.id.to_s
+ expect(wrapper.attribute("data-user").value).to eq user.id.to_s
end
def expect_to_have_mailto_link_with_avatar(doc, email:, trailer:)
@@ -18,7 +18,7 @@ module CommitTrailersSpecHelper
expect(doc).not_to be_nil
expect(doc.xpath("a[position()<3 and @href='#{url}']").size).to eq 2
expect(doc.xpath("a[position()=3 and @href='mailto:#{CGI.escape_html(email)}']").size).to eq 1
- expect(doc.css('img').size).to eq 1
+ expect(doc.css("img").size).to eq 1
end
def find_user_wrapper(doc, trailer)
diff --git a/spec/support/controllers/githubish_import_controller_shared_context.rb b/spec/support/controllers/githubish_import_controller_shared_context.rb
index e71994edec6..67d0abededa 100644
--- a/spec/support/controllers/githubish_import_controller_shared_context.rb
+++ b/spec/support/controllers/githubish_import_controller_shared_context.rb
@@ -1,7 +1,7 @@
-shared_context 'a GitHub-ish import controller' do
+shared_context "a GitHub-ish import controller" do
let(:user) { create(:user) }
let(:token) { "asdasd12345" }
- let(:access_params) { { github_access_token: token } }
+ let(:access_params) { {github_access_token: token} }
before do
sign_in(user)
diff --git a/spec/support/controllers/githubish_import_controller_shared_examples.rb b/spec/support/controllers/githubish_import_controller_shared_examples.rb
index 5bb1269a19d..b3599975c71 100644
--- a/spec/support/controllers/githubish_import_controller_shared_examples.rb
+++ b/spec/support/controllers/githubish_import_controller_shared_examples.rb
@@ -5,38 +5,38 @@
# being currently tested).
def assign_session_token(provider)
- session[:"#{provider}_access_token"] = 'asdasd12345'
+ session[:"#{provider}_access_token"] = "asdasd12345"
end
-shared_examples 'a GitHub-ish import controller: POST personal_access_token' do
+shared_examples "a GitHub-ish import controller: POST personal_access_token" do
let(:status_import_url) { public_send("status_import_#{provider}_url") }
it "updates access token" do
- token = 'asdfasdf9876'
+ token = "asdfasdf9876"
allow_any_instance_of(Gitlab::LegacyGithubImport::Client)
.to receive(:user).and_return(true)
- post :personal_access_token, params: { personal_access_token: token }
+ post :personal_access_token, params: {personal_access_token: token}
expect(session[:"#{provider}_access_token"]).to eq(token)
expect(controller).to redirect_to(status_import_url)
end
it "strips access token with spaces" do
- token = 'asdfasdf9876'
+ token = "asdfasdf9876"
allow_any_instance_of(Gitlab::LegacyGithubImport::Client)
.to receive(:user).and_return(true)
- post :personal_access_token, params: { personal_access_token: " #{token} " }
+ post :personal_access_token, params: {personal_access_token: " #{token} "}
expect(session[:"#{provider}_access_token"]).to eq(token)
expect(controller).to redirect_to(status_import_url)
end
end
-shared_examples 'a GitHub-ish import controller: GET new' do
+shared_examples "a GitHub-ish import controller: GET new" do
let(:status_import_url) { public_send("status_import_#{provider}_url") }
it "redirects to status if we already have a token" do
@@ -55,19 +55,19 @@ shared_examples 'a GitHub-ish import controller: GET new' do
end
end
-shared_examples 'a GitHub-ish import controller: GET status' do
+shared_examples "a GitHub-ish import controller: GET status" do
let(:new_import_url) { public_send("new_import_#{provider}_url") }
let(:user) { create(:user) }
- let(:repo) { OpenStruct.new(login: 'vim', full_name: 'asd/vim', name: 'vim', owner: { login: 'owner' }) }
- let(:org) { OpenStruct.new(login: 'company') }
- let(:org_repo) { OpenStruct.new(login: 'company', full_name: 'company/repo', name: 'repo', owner: { login: 'owner' }) }
+ let(:repo) { OpenStruct.new(login: "vim", full_name: "asd/vim", name: "vim", owner: {login: "owner"}) }
+ let(:org) { OpenStruct.new(login: "company") }
+ let(:org_repo) { OpenStruct.new(login: "company", full_name: "company/repo", name: "repo", owner: {login: "owner"}) }
before do
assign_session_token(provider)
end
it "returns variables for json request" do
- project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: 'example/repo')
+ project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: "example/repo")
group = create(:group)
group.add_owner(user)
stub_client(repos: [repo, org_repo], orgs: [org], org_repos: [org_repo])
@@ -82,7 +82,7 @@ shared_examples 'a GitHub-ish import controller: GET status' do
end
it "does not show already added project" do
- project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: 'asd/vim')
+ project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: "asd/vim")
stub_client(repos: [repo], orgs: [])
get :status, format: :json
@@ -125,9 +125,9 @@ shared_examples 'a GitHub-ish import controller: GET status' do
group_a.add_owner(user)
create(:project, :import_started, import_type: provider, namespace: user.namespace)
- control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) do
+ control_count = ActiveRecord::QueryRecorder.new(skip_cached: false) {
get :status, format: :json
- end.count
+ }.count
stub_client(repos: [repo, org_repo], orgs: [])
group_b = create(:group)
@@ -139,14 +139,14 @@ shared_examples 'a GitHub-ish import controller: GET status' do
end
end
-shared_examples 'a GitHub-ish import controller: POST create' do
+shared_examples "a GitHub-ish import controller: POST create" do
let(:user) { create(:user) }
let(:provider_username) { user.username }
let(:provider_user) { OpenStruct.new(login: provider_username) }
let(:project) { create(:project, import_type: provider, import_status: :finished, import_source: "#{provider_username}/vim") }
let(:provider_repo) do
OpenStruct.new(
- name: 'vim',
+ name: "vim",
full_name: "#{provider_username}/vim",
owner: OpenStruct.new(login: provider_username)
)
@@ -157,35 +157,35 @@ shared_examples 'a GitHub-ish import controller: POST create' do
assign_session_token(provider)
end
- it 'returns 200 response when the project is imported successfully' do
+ it "returns 200 response when the project is imported successfully" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
expect(response).to have_gitlab_http_status(200)
end
- it 'returns 422 response with the base error when the project could not be imported' do
+ it "returns 422 response with the base error when the project could not be imported" do
project = build(:project)
- project.errors.add(:name, 'is invalid')
- project.errors.add(:path, 'is old')
+ project.errors.add(:name, "is invalid")
+ project.errors.add(:path, "is old")
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
expect(response).to have_gitlab_http_status(422)
- expect(json_response['errors']).to eq('Name is invalid, Path is old')
+ expect(json_response["errors"]).to eq("Name is invalid, Path is old")
end
it "touches the etag cache store" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
expect_next_instance_of(Gitlab::EtagCaching::Store) do |store|
expect(store).to receive(:touch) { "realtime_changes_import_#{provider}_path" }
end
@@ -198,7 +198,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do
it "takes the current user's namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
end
@@ -210,7 +210,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do
it "takes the current user's namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
end
@@ -237,7 +237,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do
it "takes the existing namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, existing_namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
end
@@ -249,7 +249,7 @@ shared_examples 'a GitHub-ish import controller: POST create' do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
end
@@ -262,15 +262,15 @@ shared_examples 'a GitHub-ish import controller: POST create' do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).and_return(double(execute: project))
- expect { post :create, params: { target_namespace: provider_repo.name }, format: :json }.to change(Namespace, :count).by(1)
+ expect { post :create, params: {target_namespace: provider_repo.name}, format: :json }.to change(Namespace, :count).by(1)
end
it "takes the new namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, an_instance_of(Group), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: provider_repo.name }, format: :json
+ post :create, params: {target_namespace: provider_repo.name}, format: :json
end
end
@@ -289,166 +289,166 @@ shared_examples 'a GitHub-ish import controller: POST create' do
it "takes the current user's namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, provider_repo.name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
post :create, format: :json
end
end
end
- context 'user has chosen a namespace and name for the project' do
- let(:test_namespace) { create(:group, name: 'test_namespace') }
- let(:test_name) { 'test_name' }
+ context "user has chosen a namespace and name for the project" do
+ let(:test_namespace) { create(:group, name: "test_namespace") }
+ let(:test_name) { "test_name" }
before do
test_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, test_namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: test_namespace.name, new_name: test_name }, format: :json
+ post :create, params: {target_namespace: test_namespace.name, new_name: test_name}, format: :json
end
- it 'takes the selected name and default namespace' do
+ it "takes the selected name and default namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { new_name: test_name }, format: :json
+ post :create, params: {new_name: test_name}, format: :json
end
end
- context 'user has chosen an existing nested namespace and name for the project', :postgresql do
- let(:parent_namespace) { create(:group, name: 'foo') }
- let(:nested_namespace) { create(:group, name: 'bar', parent: parent_namespace) }
- let(:test_name) { 'test_name' }
+ context "user has chosen an existing nested namespace and name for the project", :postgresql do
+ let(:parent_namespace) { create(:group, name: "foo") }
+ let(:nested_namespace) { create(:group, name: "bar", parent: parent_namespace) }
+ let(:test_name) { "test_name" }
before do
parent_namespace.add_owner(user)
nested_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, nested_namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: nested_namespace.full_path, new_name: test_name }, format: :json
+ post :create, params: {target_namespace: nested_namespace.full_path, new_name: test_name}, format: :json
end
end
- context 'user has chosen a non-existent nested namespaces and name for the project', :postgresql do
- let(:test_name) { 'test_name' }
+ context "user has chosen a non-existent nested namespaces and name for the project", :postgresql do
+ let(:test_name) { "test_name" }
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json }
.to change { Namespace.count }.by(2)
end
- it 'new namespace has the right parent' do
+ it "new namespace has the right parent" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/bar", new_name: test_name}, format: :json
- expect(Namespace.find_by_path_or_name('bar').parent.path).to eq('foo')
+ expect(Namespace.find_by_path_or_name("bar").parent.path).to eq("foo")
end
end
- context 'user has chosen existent and non-existent nested namespaces and name for the project', :postgresql do
- let(:test_name) { 'test_name' }
- let!(:parent_namespace) { create(:group, name: 'foo') }
+ context "user has chosen existent and non-existent nested namespaces and name for the project", :postgresql do
+ let(:test_name) { "test_name" }
+ let!(:parent_namespace) { create(:group, name: "foo") }
before do
parent_namespace.add_owner(user)
end
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :json
+ post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :json
end
- it 'creates the namespaces' do
+ it "creates the namespaces" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
.to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :json }
+ expect { post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :json }
.to change { Namespace.count }.by(2)
end
- it 'does not create a new namespace under the user namespace' do
+ it "does not create a new namespace under the user namespace" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
- .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider)
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: "#{user.namespace_path}/test_group", new_name: test_name }, format: :js }
- .not_to change { Namespace.count }
+ expect { post :create, params: {target_namespace: "#{user.namespace_path}/test_group", new_name: test_name}, format: :js }
+ .not_to change { Namespace.count }
end
end
- context 'user cannot create a subgroup inside a group is not a member of' do
- let(:test_name) { 'test_name' }
- let!(:parent_namespace) { create(:group, name: 'foo') }
+ context "user cannot create a subgroup inside a group is not a member of" do
+ let(:test_name) { "test_name" }
+ let!(:parent_namespace) { create(:group, name: "foo") }
- it 'does not take the selected namespace and name' do
+ it "does not take the selected namespace and name" do
expect(Gitlab::LegacyGithubImport::ProjectCreator)
- .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .to receive(:new).with(provider_repo, test_name, user.namespace, user, access_params, type: provider)
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :js
+ post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :js
end
- it 'does not create the namespaces' do
+ it "does not create the namespaces" do
allow(Gitlab::LegacyGithubImport::ProjectCreator)
- .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
- .and_return(double(execute: project))
+ .to receive(:new).with(provider_repo, test_name, kind_of(Namespace), user, access_params, type: provider)
+ .and_return(double(execute: project))
- expect { post :create, params: { target_namespace: 'foo/foobar/bar', new_name: test_name }, format: :js }
- .not_to change { Namespace.count }
+ expect { post :create, params: {target_namespace: "foo/foobar/bar", new_name: test_name}, format: :js }
+ .not_to change { Namespace.count }
end
end
- context 'user can use a group without having permissions to create a group' do
- let(:test_name) { 'test_name' }
- let!(:group) { create(:group, name: 'foo') }
+ context "user can use a group without having permissions to create a group" do
+ let(:test_name) { "test_name" }
+ let!(:group) { create(:group, name: "foo") }
- it 'takes the selected namespace and name' do
+ it "takes the selected namespace and name" do
group.add_owner(user)
user.update!(can_create_group: false)
expect(Gitlab::LegacyGithubImport::ProjectCreator)
- .to receive(:new).with(provider_repo, test_name, group, user, access_params, type: provider)
- .and_return(double(execute: project))
+ .to receive(:new).with(provider_repo, test_name, group, user, access_params, type: provider)
+ .and_return(double(execute: project))
- post :create, params: { target_namespace: 'foo', new_name: test_name }, format: :js
+ post :create, params: {target_namespace: "foo", new_name: test_name}, format: :js
end
end
- context 'when user can not create projects in the chosen namespace' do
- it 'returns 422 response' do
- other_namespace = create(:group, name: 'other_namespace')
+ context "when user can not create projects in the chosen namespace" do
+ it "returns 422 response" do
+ other_namespace = create(:group, name: "other_namespace")
- post :create, params: { target_namespace: other_namespace.name }, format: :json
+ post :create, params: {target_namespace: other_namespace.name}, format: :json
expect(response).to have_gitlab_http_status(422)
end
@@ -456,19 +456,19 @@ shared_examples 'a GitHub-ish import controller: POST create' do
end
end
-shared_examples 'a GitHub-ish import controller: GET realtime_changes' do
+shared_examples "a GitHub-ish import controller: GET realtime_changes" do
let(:user) { create(:user) }
before do
assign_session_token(provider)
end
- it 'sets a Poll-Interval header' do
- project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: 'example/repo')
+ it "sets a Poll-Interval header" do
+ project = create(:project, import_type: provider, namespace: user.namespace, import_status: :finished, import_source: "example/repo")
get :realtime_changes
- expect(json_response).to eq([{ "id" => project.id, "import_status" => project.import_status }])
- expect(Integer(response.headers['Poll-Interval'])).to be > -1
+ expect(json_response).to eq([{"id" => project.id, "import_status" => project.import_status}])
+ expect(Integer(response.headers["Poll-Interval"])).to be > -1
end
end
diff --git a/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb b/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb
index 72912ffb89d..6f6ff80c563 100644
--- a/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb
+++ b/spec/support/controllers/ldap_omniauth_callbacks_controller_shared_context.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
-shared_context 'Ldap::OmniauthCallbacksController' do
+shared_context "Ldap::OmniauthCallbacksController" do
include LoginHelpers
include LdapHelpers
- let(:uid) { 'my-uid' }
- let(:provider) { 'ldapmain' }
+ let(:uid) { "my-uid" }
+ let(:provider) { "ldapmain" }
let(:valid_login?) { true }
let(:user) { create(:omniauth_user, extern_uid: uid, provider: provider) }
let(:ldap_server_config) do
- { main: ldap_config_defaults(:main) }
+ {main: ldap_config_defaults(:main)}
end
def ldap_config_defaults(key, hash = {})
{
provider_name: "ldap#{key}",
attributes: {},
- encryption: 'plain'
+ encryption: "plain",
}.merge(hash)
end
diff --git a/spec/support/controllers/sessionless_auth_controller_shared_examples.rb b/spec/support/controllers/sessionless_auth_controller_shared_examples.rb
index 355555d9d19..93333a128d6 100644
--- a/spec/support/controllers/sessionless_auth_controller_shared_examples.rb
+++ b/spec/support/controllers/sessionless_auth_controller_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_examples 'authenticates sessionless user' do |path, format, params|
+shared_examples "authenticates sessionless user" do |path, format, params|
params ||= {}
before do
@@ -7,14 +7,14 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
let(:user) { create(:user) }
let(:personal_access_token) { create(:personal_access_token, user: user) }
- let(:default_params) { { format: format }.merge(params.except(:public) || {}) }
+ let(:default_params) { {format: format}.merge(params.except(:public) || {}) }
context "when the 'personal_access_token' param is populated with the personal access token" do
- it 'logs the user in' do
+ it "logs the user in" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
- .and increment(:user_session_override_counter)
- .and increment(:user_sessionless_authentication_counter)
+ .and increment(:user_session_override_counter)
+ .and increment(:user_sessionless_authentication_counter)
get path, params: default_params.merge(private_token: personal_access_token.token)
@@ -22,7 +22,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
expect(controller.current_user).to eq(user)
end
- it 'does not log the user in if page is public', if: params[:public] do
+ it "does not log the user in if page is public", if: params[:public] do
get path, params: default_params
expect(response).to have_gitlab_http_status(200)
@@ -30,8 +30,8 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
end
end
- context 'when the personal access token has no api scope', unless: params[:public] do
- it 'does not log the user in' do
+ context "when the personal access token has no api scope", unless: params[:public] do
+ it "does not log the user in" do
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
@@ -44,13 +44,13 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
end
context "when the 'PERSONAL_ACCESS_TOKEN' header is populated with the personal access token" do
- it 'logs the user in' do
+ it "logs the user in" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
- .and increment(:user_session_override_counter)
- .and increment(:user_sessionless_authentication_counter)
+ .and increment(:user_session_override_counter)
+ .and increment(:user_sessionless_authentication_counter)
- @request.headers['PRIVATE-TOKEN'] = personal_access_token.token
+ @request.headers["PRIVATE-TOKEN"] = personal_access_token.token
get path, params: default_params
expect(response).to have_gitlab_http_status(200)
@@ -61,8 +61,8 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
it "logs the user in" do
expect(authentication_metrics)
.to increment(:user_authenticated_counter)
- .and increment(:user_session_override_counter)
- .and increment(:user_sessionless_authentication_counter)
+ .and increment(:user_session_override_counter)
+ .and increment(:user_sessionless_authentication_counter)
get path, params: default_params.merge(feed_token: user.feed_token)
@@ -75,7 +75,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
- get path, params: default_params.merge(feed_token: 'token')
+ get path, params: default_params.merge(feed_token: "token")
expect(response.status).not_to eq 200
end
@@ -85,7 +85,7 @@ shared_examples 'authenticates sessionless user' do |path, format, params|
expect(authentication_metrics)
.to increment(:user_unauthenticated_counter)
- get path, params: default_params.merge(private_token: 'token')
+ get path, params: default_params.merge(private_token: "token")
expect(response.status).not_to eq(200)
end
diff --git a/spec/support/cycle_analytics_helpers/test_generation.rb b/spec/support/cycle_analytics_helpers/test_generation.rb
index 19b32c84d81..a80f95520be 100644
--- a/spec/support/cycle_analytics_helpers/test_generation.rb
+++ b/spec/support/cycle_analytics_helpers/test_generation.rb
@@ -28,7 +28,7 @@ module CycleAnalyticsHelpers
context "start condition: #{start_time_conditions.map(&:first).to_sentence}" do
context "end condition: #{end_time_conditions.map(&:first).to_sentence}" do
it "finds the median of available durations between the two conditions" do
- time_differences = Array.new(5) do |index|
+ time_differences = Array.new(5) { |index|
data = data_fn[self]
start_time = (index * 10).days.from_now
end_time = start_time + rand(1..5).days
@@ -47,7 +47,7 @@ module CycleAnalyticsHelpers
Timecop.freeze(end_time + 1.day) { post_fn[self, data] } if post_fn
end_time - start_time
- end
+ }
median_time_difference = time_differences.sort[2]
expect(subject[phase].median).to be_within(5).of(median_time_difference)
@@ -85,7 +85,7 @@ module CycleAnalyticsHelpers
end
context "when the end condition happens before the start condition" do
- it 'returns nil' do
+ it "returns nil" do
data = data_fn[self]
start_time = Time.now
end_time = start_time + rand(1..5).days
diff --git a/spec/support/db_cleaner.rb b/spec/support/db_cleaner.rb
index 34b9efaaecd..aba8d892b09 100644
--- a/spec/support/db_cleaner.rb
+++ b/spec/support/db_cleaner.rb
@@ -1,4 +1,4 @@
-require 'database_cleaner/active_record/deletion'
+require "database_cleaner/active_record/deletion"
module FakeInformationSchema
# Work around a bug in DatabaseCleaner when using the deletion strategy:
@@ -28,15 +28,15 @@ RSpec.configure do |config|
end
config.before(:each, :js) do
- DatabaseCleaner.strategy = :deletion, { cache_tables: false }
+ DatabaseCleaner.strategy = :deletion, {cache_tables: false}
end
config.before(:each, :delete) do
- DatabaseCleaner.strategy = :deletion, { cache_tables: false }
+ DatabaseCleaner.strategy = :deletion, {cache_tables: false}
end
config.before(:each, :migration) do
- DatabaseCleaner.strategy = :deletion, { cache_tables: false }
+ DatabaseCleaner.strategy = :deletion, {cache_tables: false}
end
config.before do
diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb
index 42a086d58d2..7e8e3e9d4ad 100644
--- a/spec/support/features/discussion_comments_shared_example.rb
+++ b/spec/support/features/discussion_comments_shared_example.rb
@@ -1,16 +1,16 @@
-shared_examples 'discussion comments' do |resource_name|
- let(:form_selector) { '.js-main-target-form' }
+shared_examples "discussion comments" do |resource_name|
+ let(:form_selector) { ".js-main-target-form" }
let(:dropdown_selector) { "#{form_selector} .comment-type-dropdown" }
let(:toggle_selector) { "#{dropdown_selector} .dropdown-toggle" }
let(:menu_selector) { "#{dropdown_selector} .dropdown-menu" }
let(:submit_selector) { "#{form_selector} .js-comment-submit-button" }
let(:close_selector) { "#{form_selector} .btn-comment-and-close" }
- let(:comments_selector) { '.timeline > .note.timeline-entry' }
+ let(:comments_selector) { ".timeline > .note.timeline-entry" }
it 'clicking "Comment" will post a comment' do
expect(page).to have_selector toggle_selector
- find("#{form_selector} .note-textarea").send_keys('a')
+ find("#{form_selector} .note-textarea").send_keys("a")
find(submit_selector).click
@@ -19,13 +19,13 @@ shared_examples 'discussion comments' do |resource_name|
find(comments_selector, match: :first)
new_comment = all(comments_selector).last
- expect(new_comment).to have_content 'a'
- expect(new_comment).not_to have_selector '.discussion'
+ expect(new_comment).to have_content "a"
+ expect(new_comment).not_to have_selector ".discussion"
end
- if resource_name == 'issue'
+ if resource_name == "issue"
it "clicking 'Comment & close #{resource_name}' will post a comment and close the #{resource_name}" do
- find("#{form_selector} .note-textarea").send_keys('a')
+ find("#{form_selector} .note-textarea").send_keys("a")
find(close_selector).click
wait_for_requests
@@ -36,14 +36,14 @@ shared_examples 'discussion comments' do |resource_name|
close_note = entries.last
new_comment = entries[-2]
- expect(close_note).to have_content 'closed'
- expect(new_comment).not_to have_selector '.discussion'
+ expect(close_note).to have_content "closed"
+ expect(new_comment).not_to have_selector ".discussion"
end
end
- describe 'when the toggle is clicked' do
+ describe "when the toggle is clicked" do
before do
- find("#{form_selector} .note-textarea").send_keys('a')
+ find("#{form_selector} .note-textarea").send_keys("a")
find(toggle_selector).click
end
@@ -54,18 +54,18 @@ shared_examples 'discussion comments' do |resource_name|
find("#{menu_selector} li", match: :first)
items = all("#{menu_selector} li")
- expect(items.first).to have_content 'Comment'
+ expect(items.first).to have_content "Comment"
expect(items.first).to have_content "Add a general comment to this #{resource_name}."
- expect(items.first).to have_selector '.fa-check'
- expect(items.first['class']).to match 'droplab-item-selected'
+ expect(items.first).to have_selector ".fa-check"
+ expect(items.first["class"]).to match "droplab-item-selected"
- expect(items.last).to have_content 'Start discussion'
- expect(items.last).to have_content "Discuss a specific suggestion or question#{' that needs to be resolved' if resource_name == 'merge request'}."
- expect(items.last).not_to have_selector '.fa-check'
- expect(items.last['class']).not_to match 'droplab-item-selected'
+ expect(items.last).to have_content "Start discussion"
+ expect(items.last).to have_content "Discuss a specific suggestion or question#{" that needs to be resolved" if resource_name == "merge request"}."
+ expect(items.last).not_to have_selector ".fa-check"
+ expect(items.last["class"]).not_to match "droplab-item-selected"
end
- it 'closes the menu when clicking the toggle or body' do
+ it "closes the menu when clicking the toggle or body" do
find(toggle_selector).click
expect(page).not_to have_selector menu_selector
@@ -76,7 +76,7 @@ shared_examples 'discussion comments' do |resource_name|
expect(page).not_to have_selector menu_selector
end
- it 'clicking the ul padding or divider should not change the text' do
+ it "clicking the ul padding or divider should not change the text" do
execute_script("document.querySelector('#{menu_selector}').click()")
# on issues page, the menu closes when clicking anywhere, on other pages it will
@@ -85,7 +85,7 @@ shared_examples 'discussion comments' do |resource_name|
# if dropdown menu is not toggled (and also not present),
# it's "issue-type" dropdown
if first(menu_selector).nil?
- expect(find(dropdown_selector)).to have_content 'Comment'
+ expect(find(dropdown_selector)).to have_content "Comment"
find(toggle_selector).click
execute_script("document.querySelector('#{menu_selector} .divider').click()")
@@ -93,14 +93,14 @@ shared_examples 'discussion comments' do |resource_name|
execute_script("document.querySelector('#{menu_selector}').click()")
expect(page).to have_selector menu_selector
- expect(find(dropdown_selector)).to have_content 'Comment'
+ expect(find(dropdown_selector)).to have_content "Comment"
execute_script("document.querySelector('#{menu_selector} .divider').click()")
expect(page).to have_selector menu_selector
end
- expect(find(dropdown_selector)).to have_content 'Comment'
+ expect(find(dropdown_selector)).to have_content "Comment"
end
describe 'when selecting "Start discussion"' do
@@ -109,32 +109,32 @@ shared_examples 'discussion comments' do |resource_name|
all("#{menu_selector} li").last.click
end
- it 'updates the submit button text and closes the dropdown' do
+ it "updates the submit button text and closes the dropdown" do
button = find(submit_selector)
# on issues page, the submit input is a <button>, on other pages it is <input>
- if button.tag_name == 'button'
- expect(find(submit_selector)).to have_content 'Start discussion'
+ if button.tag_name == "button"
+ expect(find(submit_selector)).to have_content "Start discussion"
else
- expect(find(submit_selector).value).to eq 'Start discussion'
+ expect(find(submit_selector).value).to eq "Start discussion"
end
expect(page).not_to have_selector menu_selector
end
- if resource_name =~ /(issue|merge request)/
- it 'updates the close button text' do
+ if /(issue|merge request)/.match?(resource_name)
+ it "updates the close button text" do
expect(find(close_selector)).to have_content "Start discussion & close #{resource_name}"
end
- it 'typing does not change the close button text' do
- find("#{form_selector} .note-textarea").send_keys('b')
+ it "typing does not change the close button text" do
+ find("#{form_selector} .note-textarea").send_keys("b")
expect(find(close_selector)).to have_content "Start discussion & close #{resource_name}"
end
end
- describe 'creating a discussion' do
+ describe "creating a discussion" do
before do
find(submit_selector).click
wait_for_requests
@@ -153,43 +153,43 @@ shared_examples 'discussion comments' do |resource_name|
it 'clicking "Start discussion" will post a discussion' do
new_comment = all(comments_selector).last
- expect(new_comment).to have_content 'a'
- expect(new_comment).to have_selector '.discussion'
+ expect(new_comment).to have_content "a"
+ expect(new_comment).to have_selector ".discussion"
end
- if resource_name =~ /(issue|merge request)/
- it 'can be replied to' do
- submit_reply('some text')
+ if /(issue|merge request)/.match?(resource_name)
+ it "can be replied to" do
+ submit_reply("some text")
- expect(page).to have_css('.discussion-notes .note', count: 2)
- expect(page).to have_content 'Collapse replies'
+ expect(page).to have_css(".discussion-notes .note", count: 2)
+ expect(page).to have_content "Collapse replies"
end
- it 'can be collapsed' do
- submit_reply('another text')
+ it "can be collapsed" do
+ submit_reply("another text")
- find('.js-collapse-replies').click
- expect(page).to have_css('.discussion-notes .note', count: 1)
- expect(page).to have_content '1 reply'
+ find(".js-collapse-replies").click
+ expect(page).to have_css(".discussion-notes .note", count: 1)
+ expect(page).to have_content "1 reply"
end
end
- if resource_name == 'merge request'
- let(:note_id) { find("#{comments_selector} .note:first-child", match: :first)['data-note-id'] }
- let(:reply_id) { find("#{comments_selector} .note:last-child", match: :first)['data-note-id'] }
+ if resource_name == "merge request"
+ let(:note_id) { find("#{comments_selector} .note:first-child", match: :first)["data-note-id"] }
+ let(:reply_id) { find("#{comments_selector} .note:last-child", match: :first)["data-note-id"] }
- it 'can be replied to after resolving' do
+ it "can be replied to after resolving" do
click_button "Resolve discussion"
wait_for_requests
refresh
wait_for_requests
- submit_reply('to reply or not reply')
+ submit_reply("to reply or not reply")
end
- it 'shows resolved discussion when toggled' do
- submit_reply('a')
+ it "shows resolved discussion when toggled" do
+ submit_reply("a")
click_button "Resolve discussion"
wait_for_requests
@@ -204,7 +204,7 @@ shared_examples 'discussion comments' do |resource_name|
end
end
- if resource_name == 'issue'
+ if resource_name == "issue"
it "clicking 'Start discussion & close #{resource_name}' will post a discussion and close the #{resource_name}" do
find(close_selector).click
@@ -214,12 +214,12 @@ shared_examples 'discussion comments' do |resource_name|
close_note = entries.last
new_discussion = entries[-2]
- expect(close_note).to have_content 'closed'
- expect(new_discussion).to have_selector '.discussion'
+ expect(close_note).to have_content "closed"
+ expect(new_discussion).to have_selector ".discussion"
end
end
- describe 'when opening the menu' do
+ describe "when opening the menu" do
before do
find(toggle_selector).click
end
@@ -228,13 +228,13 @@ shared_examples 'discussion comments' do |resource_name|
find("#{menu_selector} li", match: :first)
items = all("#{menu_selector} li")
- expect(items.first).to have_content 'Comment'
- expect(items.first).not_to have_selector '.fa-check'
- expect(items.first['class']).not_to match 'droplab-item-selected'
+ expect(items.first).to have_content "Comment"
+ expect(items.first).not_to have_selector ".fa-check"
+ expect(items.first["class"]).not_to match "droplab-item-selected"
- expect(items.last).to have_content 'Start discussion'
- expect(items.last).to have_selector '.fa-check'
- expect(items.last['class']).to match 'droplab-item-selected'
+ expect(items.last).to have_content "Start discussion"
+ expect(items.last).to have_selector ".fa-check"
+ expect(items.last["class"]).to match "droplab-item-selected"
end
describe 'when selecting "Comment"' do
@@ -242,26 +242,26 @@ shared_examples 'discussion comments' do |resource_name|
find("#{menu_selector} li", match: :first).click
end
- it 'updates the submit button text and closes the dropdown' do
+ it "updates the submit button text and closes the dropdown" do
button = find(submit_selector)
# on issues page, the submit input is a <button>, on other pages it is <input>
- if button.tag_name == 'button'
- expect(button).to have_content 'Comment'
+ if button.tag_name == "button"
+ expect(button).to have_content "Comment"
else
- expect(button.value).to eq 'Comment'
+ expect(button.value).to eq "Comment"
end
expect(page).not_to have_selector menu_selector
end
- if resource_name =~ /(issue|merge request)/
- it 'updates the close button text' do
+ if /(issue|merge request)/.match?(resource_name)
+ it "updates the close button text" do
expect(find(close_selector)).to have_content "Comment & close #{resource_name}"
end
- it 'typing does not change the close button text' do
- find("#{form_selector} .note-textarea").send_keys('b')
+ it "typing does not change the close button text" do
+ find("#{form_selector} .note-textarea").send_keys("b")
expect(find(close_selector)).to have_content "Comment & close #{resource_name}"
end
@@ -273,26 +273,26 @@ shared_examples 'discussion comments' do |resource_name|
find("#{menu_selector} li", match: :first)
items = all("#{menu_selector} li")
- expect(items.first).to have_content 'Comment'
- expect(items.first).to have_selector '.fa-check'
- expect(items.first['class']).to match 'droplab-item-selected'
+ expect(items.first).to have_content "Comment"
+ expect(items.first).to have_selector ".fa-check"
+ expect(items.first["class"]).to match "droplab-item-selected"
- expect(items.last).to have_content 'Start discussion'
- expect(items.last).not_to have_selector '.fa-check'
- expect(items.last['class']).not_to match 'droplab-item-selected'
+ expect(items.last).to have_content "Start discussion"
+ expect(items.last).not_to have_selector ".fa-check"
+ expect(items.last["class"]).not_to match "droplab-item-selected"
end
end
end
end
end
- if resource_name =~ /(issue|merge request)/
+ if /(issue|merge request)/.match?(resource_name)
describe "on a closed #{resource_name}" do
before do
find("#{form_selector} .js-note-target-close").click
wait_for_requests
- find("#{form_selector} .note-textarea").send_keys('a')
+ find("#{form_selector} .note-textarea").send_keys("a")
end
it "should show a 'Comment & reopen #{resource_name}' button" do
diff --git a/spec/support/features/issuable_quick_actions_shared_examples.rb b/spec/support/features/issuable_quick_actions_shared_examples.rb
index 2a883ce1074..b43a91d403f 100644
--- a/spec/support/features/issuable_quick_actions_shared_examples.rb
+++ b/spec/support/features/issuable_quick_actions_shared_examples.rb
@@ -1,7 +1,7 @@
# Specifications for behavior common to all objects with executable attributes.
# It takes a `issuable_type`, and expect an `issuable`.
-shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type|
+shared_examples "issuable record that supports quick actions in its description and notes" do |issuable_type|
include Spec::Support::Helpers::Features::NotesHelpers
let(:maintainer) { create(:user) }
@@ -13,9 +13,9 @@ shared_examples 'issuable record that supports quick actions in its description
create(:project, :public)
end
end
- let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
- let!(:label_bug) { create(:label, project: project, title: 'bug') }
- let!(:label_feature) { create(:label, project: project, title: 'feature') }
+ let!(:milestone) { create(:milestone, project: project, title: "ASAP") }
+ let!(:label_bug) { create(:label, project: project, title: "bug") }
+ let!(:label_feature) { create(:label, project: project, title: "feature") }
let(:new_url_opts) { {} }
before do
@@ -30,7 +30,7 @@ shared_examples 'issuable record that supports quick actions in its description
end
describe "new #{issuable_type}", :js do
- context 'with commands in the description' do
+ context "with commands in the description" do
it "creates the #{issuable_type} and interpret commands accordingly" do
case issuable_type
when :merge_request
@@ -38,7 +38,7 @@ shared_examples 'issuable record that supports quick actions in its description
when :issue
visit public_send("new_namespace_project_issue_path", project.namespace, project, new_url_opts)
end
- fill_in "#{issuable_type}_title", with: 'bug 345'
+ fill_in "#{issuable_type}_title", with: "bug 345"
fill_in "#{issuable_type}_description", with: "bug description\n/label ~bug\n/milestone %\"ASAP\""
click_button "Submit #{issuable_type}".humanize
@@ -47,8 +47,8 @@ shared_examples 'issuable record that supports quick actions in its description
expect(issuable.description).to eq "bug description"
expect(issuable.labels).to eq [label_bug]
expect(issuable.milestone).to eq milestone
- expect(page).to have_content 'bug 345'
- expect(page).to have_content 'bug description'
+ expect(page).to have_content "bug 345"
+ expect(page).to have_content "bug description"
end
end
end
@@ -58,14 +58,14 @@ shared_examples 'issuable record that supports quick actions in its description
visit public_send("project_#{issuable_type}_path", project, issuable)
end
- context 'with a note containing commands' do
- it 'creates a note without the commands and interpret the commands accordingly' do
- assignee = create(:user, username: 'bob')
+ context "with a note containing commands" do
+ it "creates a note without the commands and interpret the commands accordingly" do
+ assignee = create(:user, username: "bob")
add_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
- expect(page).to have_content 'Awesome!'
- expect(page).not_to have_content '/assign @bob'
- expect(page).not_to have_content '/label ~bug'
+ expect(page).to have_content "Awesome!"
+ expect(page).not_to have_content "/assign @bob"
+ expect(page).not_to have_content "/label ~bug"
expect(page).not_to have_content '/milestone %"ASAP"'
wait_for_requests
@@ -78,25 +78,25 @@ shared_examples 'issuable record that supports quick actions in its description
expect(issuable.milestone).to eq milestone
end
- it 'removes the quick action from note and explains it in the preview' do
+ it "removes the quick action from note and explains it in the preview" do
preview_note("Awesome!\n\n/close")
- expect(page).to have_content 'Awesome!'
- expect(page).not_to have_content '/close'
- issuable_name = issuable.is_a?(Issue) ? 'issue' : 'merge request'
+ expect(page).to have_content "Awesome!"
+ expect(page).not_to have_content "/close"
+ issuable_name = issuable.is_a?(Issue) ? "issue" : "merge request"
expect(page).to have_content "Closes this #{issuable_name}."
end
end
- context 'with a note containing only commands' do
- it 'does not create a note but interpret the commands accordingly' do
- assignee = create(:user, username: 'bob')
+ context "with a note containing only commands" do
+ it "does not create a note but interpret the commands accordingly" do
+ assignee = create(:user, username: "bob")
add_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"")
- expect(page).not_to have_content '/assign @bob'
- expect(page).not_to have_content '/label ~bug'
+ expect(page).not_to have_content "/assign @bob"
+ expect(page).not_to have_content "/label ~bug"
expect(page).not_to have_content '/milestone %"ASAP"'
- expect(page).to have_content 'Commands applied'
+ expect(page).to have_content "Commands applied"
issuable.reload
@@ -116,8 +116,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "closes the #{issuable_type}" do
add_note("/close")
- expect(page).not_to have_content '/close'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/close"
+ expect(page).to have_content "Commands applied"
expect(issuable.reload).to be_closed
end
@@ -136,7 +136,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "does not close the #{issuable_type}" do
add_note("/close")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(issuable).to be_open
end
@@ -153,8 +153,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "reopens the #{issuable_type}" do
add_note("/reopen")
- expect(page).not_to have_content '/reopen'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/reopen"
+ expect(page).to have_content "Commands applied"
expect(issuable.reload).to be_open
end
@@ -173,7 +173,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "does not reopen the #{issuable_type}" do
add_note("/reopen")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(issuable).to be_closed
end
@@ -185,10 +185,10 @@ shared_examples 'issuable record that supports quick actions in its description
it "reopens the #{issuable_type}" do
add_note("/title Awesome new title")
- expect(page).not_to have_content '/title'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/title"
+ expect(page).to have_content "Commands applied"
- expect(issuable.reload.title).to eq 'Awesome new title'
+ expect(issuable.reload.title).to eq "Awesome new title"
end
end
@@ -205,9 +205,9 @@ shared_examples 'issuable record that supports quick actions in its description
it "does not change the #{issuable_type} title" do
add_note("/title Awesome new title")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
- expect(issuable.reload.title).not_to eq 'Awesome new title'
+ expect(issuable.reload.title).not_to eq "Awesome new title"
end
end
end
@@ -216,8 +216,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "creates a new todo for the #{issuable_type}" do
add_note("/todo")
- expect(page).not_to have_content '/todo'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/todo"
+ expect(page).to have_content "Commands applied"
todos = TodosFinder.new(maintainer).execute
todo = todos.first
@@ -247,8 +247,8 @@ shared_examples 'issuable record that supports quick actions in its description
add_note("/done")
- expect(page).not_to have_content '/done'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/done"
+ expect(page).to have_content "Commands applied"
expect(todo.reload).to be_done
end
@@ -260,8 +260,8 @@ shared_examples 'issuable record that supports quick actions in its description
add_note("/subscribe")
- expect(page).not_to have_content '/subscribe'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/subscribe"
+ expect(page).to have_content "Commands applied"
expect(issuable.subscribed?(maintainer, project)).to be_truthy
end
@@ -277,8 +277,8 @@ shared_examples 'issuable record that supports quick actions in its description
add_note("/unsubscribe")
- expect(page).not_to have_content '/unsubscribe'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/unsubscribe"
+ expect(page).to have_content "Commands applied"
expect(issuable.subscribed?(maintainer, project)).to be_falsy
end
@@ -288,8 +288,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "assigns the #{issuable_type} to the current user" do
add_note("/assign me")
- expect(page).not_to have_content '/assign me'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/assign me"
+ expect(page).to have_content "Commands applied"
expect(issuable.reload.assignees).to eq [maintainer]
end
@@ -305,8 +305,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "locks the #{issuable_type} discussion" do
add_note("/lock")
- expect(page).not_to have_content '/lock'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/lock"
+ expect(page).to have_content "Commands applied"
expect(issuable.reload).to be_discussion_locked
end
@@ -325,7 +325,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "does not lock the #{issuable_type} discussion" do
add_note("/lock")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(issuable).not_to be_discussion_locked
end
@@ -342,8 +342,8 @@ shared_examples 'issuable record that supports quick actions in its description
it "unlocks the #{issuable_type} discussion" do
add_note("/unlock")
- expect(page).not_to have_content '/unlock'
- expect(page).to have_content 'Commands applied'
+ expect(page).not_to have_content "/unlock"
+ expect(page).to have_content "Commands applied"
expect(issuable.reload).not_to be_discussion_locked
end
@@ -362,7 +362,7 @@ shared_examples 'issuable record that supports quick actions in its description
it "does not unlock the #{issuable_type} discussion" do
add_note("/unlock")
- expect(page).not_to have_content 'Commands applied'
+ expect(page).not_to have_content "Commands applied"
expect(issuable).to be_discussion_locked
end
@@ -371,18 +371,18 @@ shared_examples 'issuable record that supports quick actions in its description
end
describe "preview of note on #{issuable_type}", :js do
- it 'removes quick actions from note and explains them' do
- create(:user, username: 'bob')
+ it "removes quick actions from note and explains them" do
+ create(:user, username: "bob")
visit public_send("project_#{issuable_type}_path", project, issuable)
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "Awesome!\n/assign @bob "
- click_on 'Preview'
+ page.within(".js-main-target-form") do
+ fill_in "note[note]", with: "Awesome!\n/assign @bob "
+ click_on "Preview"
- expect(page).to have_content 'Awesome!'
- expect(page).not_to have_content '/assign @bob'
- expect(page).to have_content 'Assigns @bob.'
+ expect(page).to have_content "Awesome!"
+ expect(page).not_to have_content "/assign @bob"
+ expect(page).to have_content "Assigns @bob."
end
end
end
diff --git a/spec/support/features/reportable_note_shared_examples.rb b/spec/support/features/reportable_note_shared_examples.rb
index 8cfce49da8a..329eb696353 100644
--- a/spec/support/features/reportable_note_shared_examples.rb
+++ b/spec/support/features/reportable_note_shared_examples.rb
@@ -1,49 +1,49 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'reportable note' do |type|
+shared_examples "reportable note" do |type|
include MobileHelpers
include NotesHelper
let(:comment) { find("##{ActionView::RecordIdentifier.dom_id(note)}") }
- let(:more_actions_selector) { '.more-actions.dropdown' }
+ let(:more_actions_selector) { ".more-actions.dropdown" }
let(:abuse_report_path) { new_abuse_report_path(user_id: note.author.id, ref_url: noteable_note_url(note)) }
- it 'has an edit button' do
- expect(comment).to have_selector('.js-note-edit')
+ it "has an edit button" do
+ expect(comment).to have_selector(".js-note-edit")
end
- it 'has a `More actions` dropdown' do
+ it "has a `More actions` dropdown" do
expect(comment).to have_selector(more_actions_selector)
end
- it 'dropdown has Report and Delete links' do
+ it "dropdown has Report and Delete links" do
dropdown = comment.find(more_actions_selector)
open_dropdown(dropdown)
- expect(dropdown).to have_link('Report abuse to GitLab', href: abuse_report_path)
+ expect(dropdown).to have_link("Report abuse to GitLab", href: abuse_report_path)
- if type == 'issue' || type == 'merge_request'
- expect(dropdown).to have_button('Delete comment')
+ if type == "issue" || type == "merge_request"
+ expect(dropdown).to have_button("Delete comment")
else
- expect(dropdown).to have_link('Delete comment', href: note_url(note, project))
+ expect(dropdown).to have_link("Delete comment", href: note_url(note, project))
end
end
- it 'Report button links to a report page' do
+ it "Report button links to a report page" do
dropdown = comment.find(more_actions_selector)
open_dropdown(dropdown)
- dropdown.click_link('Report abuse to GitLab')
+ dropdown.click_link("Report abuse to GitLab")
- expect(find('#user_name')['value']).to match(note.author.username)
- expect(find('#abuse_report_message')['value']).to match(noteable_note_url(note))
+ expect(find("#user_name")["value"]).to match(note.author.username)
+ expect(find("#abuse_report_message")["value"]).to match(noteable_note_url(note))
end
def open_dropdown(dropdown)
# make window wide enough that tooltip doesn't trigger horizontal scrollbar
resize_window(1200, 800)
- dropdown.find('.more-actions-toggle').click
- dropdown.find('.dropdown-menu li', match: :first)
+ dropdown.find(".more-actions-toggle").click
+ dropdown.find(".dropdown-menu li", match: :first)
end
end
diff --git a/spec/support/features/resolving_discussions_in_issues_shared_examples.rb b/spec/support/features/resolving_discussions_in_issues_shared_examples.rb
index 38e5fb155a4..53e671594fe 100644
--- a/spec/support/features/resolving_discussions_in_issues_shared_examples.rb
+++ b/spec/support/features/resolving_discussions_in_issues_shared_examples.rb
@@ -1,40 +1,40 @@
-shared_examples 'creating an issue for a discussion' do
- it 'shows an issue with the title filled in' do
- title_field = page.find_field('issue[title]')
+shared_examples "creating an issue for a discussion" do
+ it "shows an issue with the title filled in" do
+ title_field = page.find_field("issue[title]")
expect(title_field.value).to include(merge_request.title)
end
- it 'has a mention of the discussion in the description' do
- description_field = page.find_field('issue[description]')
+ it "has a mention of the discussion in the description" do
+ description_field = page.find_field("issue[description]")
expect(description_field.value).to include(discussion.first_note.note)
end
- it 'can create a new issue for the project' do
- expect { click_button 'Submit issue' }.to change { project.issues.reload.size }.by(1)
+ it "can create a new issue for the project" do
+ expect { click_button "Submit issue" }.to change { project.issues.reload.size }.by(1)
end
- it 'resolves the discussion in the merge request' do
- click_button 'Submit issue'
+ it "resolves the discussion in the merge request" do
+ click_button "Submit issue"
discussion.first_note.reload
expect(discussion.resolved?).to eq(true)
end
- it 'shows a flash messaage after resolving a discussion' do
- click_button 'Submit issue'
+ it "shows a flash messaage after resolving a discussion" do
+ click_button "Submit issue"
- page.within '.flash-notice' do
+ page.within ".flash-notice" do
# Only check for the word 'Resolved' since the spec might have resolved
# multiple discussions
- expect(page).to have_content('Resolved')
+ expect(page).to have_content("Resolved")
end
end
- it 'has a hidden field for the merge request' do
- merge_request_field = find('#merge_request_to_resolve_discussions_of', visible: false)
+ it "has a hidden field for the merge request" do
+ merge_request_field = find("#merge_request_to_resolve_discussions_of", visible: false)
expect(merge_request_field.value).to eq(merge_request.iid.to_s)
end
diff --git a/spec/support/features/variable_list_shared_examples.rb b/spec/support/features/variable_list_shared_examples.rb
index 73156d18c1b..c6b28b3161e 100644
--- a/spec/support/features/variable_list_shared_examples.rb
+++ b/spec/support/features/variable_list_shared_examples.rb
@@ -1,317 +1,317 @@
-shared_examples 'variable list' do
- it 'shows list of variables' do
- page.within('.js-ci-variable-list-section') do
- expect(first('.js-ci-variable-input-key').value).to eq(variable.key)
+shared_examples "variable list" do
+ it "shows list of variables" do
+ page.within(".js-ci-variable-list-section") do
+ expect(first(".js-ci-variable-input-key").value).to eq(variable.key)
end
end
- it 'adds new CI variable' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('key')
- find('.js-ci-variable-input-value').set('key_value')
+ it "adds new CI variable" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("key")
+ find(".js-ci-variable-input-value").set("key_value")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('key_value')
+ page.within(".js-ci-variable-list-section .js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("key_value")
end
end
- it 'adds empty variable' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('key')
- find('.js-ci-variable-input-value').set('')
+ it "adds empty variable" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("key")
+ find(".js-ci-variable-input-value").set("")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('')
+ page.within(".js-ci-variable-list-section .js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("")
end
end
- it 'adds new protected variable' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('key')
- find('.js-ci-variable-input-value').set('key_value')
- find('.ci-variable-protected-item .js-project-feature-toggle').click
+ it "adds new protected variable" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("key")
+ find(".js-ci-variable-input-value").set("key_value")
+ find(".ci-variable-protected-item .js-project-feature-toggle").click
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("true")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('key_value')
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ page.within(".js-ci-variable-list-section .js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("key_value")
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("true")
end
end
- context 'defaults to the application setting' do
- context 'application setting is true' do
+ context "defaults to the application setting" do
+ context "application setting is true" do
before do
stub_application_setting(protected_ci_variables: true)
visit page_path
end
- it 'defaults to protected' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('key')
+ it "defaults to protected" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("key")
end
- values = all('.js-ci-variable-input-protected', visible: false).map(&:value)
+ values = all(".js-ci-variable-input-protected", visible: false).map(&:value)
- expect(values).to eq %w(false true true)
+ expect(values).to eq %w[false true true]
end
- it 'shows a message regarding the changed default' do
- expect(page).to have_content 'Environment variables are configured by your administrator to be protected by default'
+ it "shows a message regarding the changed default" do
+ expect(page).to have_content "Environment variables are configured by your administrator to be protected by default"
end
end
- context 'application setting is false' do
+ context "application setting is false" do
before do
stub_application_setting(protected_ci_variables: false)
visit page_path
end
- it 'defaults to unprotected' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('key')
+ it "defaults to unprotected" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("key")
end
- values = all('.js-ci-variable-input-protected', visible: false).map(&:value)
+ values = all(".js-ci-variable-input-protected", visible: false).map(&:value)
- expect(values).to eq %w(false false false)
+ expect(values).to eq %w[false false false]
end
- it 'does not show a message regarding the default' do
- expect(page).not_to have_content 'Environment variables are configured by your administrator to be protected by default'
+ it "does not show a message regarding the default" do
+ expect(page).not_to have_content "Environment variables are configured by your administrator to be protected by default"
end
end
end
- it 'reveals and hides variables' do
- page.within('.js-ci-variable-list-section') do
- expect(first('.js-ci-variable-input-key').value).to eq(variable.key)
- expect(first('.js-ci-variable-input-value', visible: false).value).to eq(variable.value)
- expect(page).to have_content('*' * 20)
+ it "reveals and hides variables" do
+ page.within(".js-ci-variable-list-section") do
+ expect(first(".js-ci-variable-input-key").value).to eq(variable.key)
+ expect(first(".js-ci-variable-input-value", visible: false).value).to eq(variable.value)
+ expect(page).to have_content("*" * 20)
- click_button('Reveal value')
+ click_button("Reveal value")
- expect(first('.js-ci-variable-input-key').value).to eq(variable.key)
- expect(first('.js-ci-variable-input-value').value).to eq(variable.value)
- expect(page).not_to have_content('*' * 20)
+ expect(first(".js-ci-variable-input-key").value).to eq(variable.key)
+ expect(first(".js-ci-variable-input-value").value).to eq(variable.value)
+ expect(page).not_to have_content("*" * 20)
- click_button('Hide value')
+ click_button("Hide value")
- expect(first('.js-ci-variable-input-key').value).to eq(variable.key)
- expect(first('.js-ci-variable-input-value', visible: false).value).to eq(variable.value)
- expect(page).to have_content('*' * 20)
+ expect(first(".js-ci-variable-input-key").value).to eq(variable.key)
+ expect(first(".js-ci-variable-input-value", visible: false).value).to eq(variable.value)
+ expect(page).to have_content("*" * 20)
end
end
- it 'deletes variable' do
- page.within('.js-ci-variable-list-section') do
- expect(page).to have_selector('.js-row', count: 2)
+ it "deletes variable" do
+ page.within(".js-ci-variable-list-section") do
+ expect(page).to have_selector(".js-row", count: 2)
- first('.js-row-remove-button').click
+ first(".js-row-remove-button").click
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
- expect(page).to have_selector('.js-row', count: 1)
+ expect(page).to have_selector(".js-row", count: 1)
end
end
- it 'edits variable' do
- page.within('.js-ci-variable-list-section') do
- click_button('Reveal value')
+ it "edits variable" do
+ page.within(".js-ci-variable-list-section") do
+ click_button("Reveal value")
- page.within('.js-row:nth-child(1)') do
- find('.js-ci-variable-input-key').set('new_key')
- find('.js-ci-variable-input-value').set('new_value')
+ page.within(".js-row:nth-child(1)") do
+ find(".js-ci-variable-input-key").set("new_key")
+ find(".js-ci-variable-input-value").set("new_value")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
- page.within('.js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('new_key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('new_value')
+ page.within(".js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("new_key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("new_value")
end
end
end
- it 'edits variable with empty value' do
- page.within('.js-ci-variable-list-section') do
- click_button('Reveal value')
+ it "edits variable with empty value" do
+ page.within(".js-ci-variable-list-section") do
+ click_button("Reveal value")
- page.within('.js-row:nth-child(1)') do
- find('.js-ci-variable-input-key').set('new_key')
- find('.js-ci-variable-input-value').set('')
+ page.within(".js-row:nth-child(1)") do
+ find(".js-ci-variable-input-key").set("new_key")
+ find(".js-ci-variable-input-value").set("")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
- page.within('.js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('new_key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('')
+ page.within(".js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("new_key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("")
end
end
end
- it 'edits variable to be protected' do
+ it "edits variable to be protected" do
# Create the unprotected variable
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('unprotected_key')
- find('.js-ci-variable-input-value').set('unprotected_value')
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("unprotected_key")
+ find(".js-ci-variable-input-value").set("unprotected_value")
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('false')
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("false")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section .js-row:nth-child(2)') do
- find('.ci-variable-protected-item .js-project-feature-toggle').click
+ page.within(".js-ci-variable-list-section .js-row:nth-child(2)") do
+ find(".ci-variable-protected-item .js-project-feature-toggle").click
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("true")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section .js-row:nth-child(2)') do
- expect(find('.js-ci-variable-input-key').value).to eq('unprotected_key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('unprotected_value')
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ page.within(".js-ci-variable-list-section .js-row:nth-child(2)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("unprotected_key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("unprotected_value")
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("true")
end
end
- it 'edits variable to be unprotected' do
+ it "edits variable to be unprotected" do
# Create the protected variable
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('protected_key')
- find('.js-ci-variable-input-value').set('protected_value')
- find('.ci-variable-protected-item .js-project-feature-toggle').click
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("protected_key")
+ find(".js-ci-variable-input-value").set("protected_value")
+ find(".ci-variable-protected-item .js-project-feature-toggle").click
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('true')
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("true")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- find('.ci-variable-protected-item .js-project-feature-toggle').click
+ page.within(".js-ci-variable-list-section .js-row:nth-child(1)") do
+ find(".ci-variable-protected-item .js-project-feature-toggle").click
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('false')
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("false")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
- page.within('.js-ci-variable-list-section .js-row:nth-child(1)') do
- expect(find('.js-ci-variable-input-key').value).to eq('protected_key')
- expect(find('.js-ci-variable-input-value', visible: false).value).to eq('protected_value')
- expect(find('.js-ci-variable-input-protected', visible: false).value).to eq('false')
+ page.within(".js-ci-variable-list-section .js-row:nth-child(1)") do
+ expect(find(".js-ci-variable-input-key").value).to eq("protected_key")
+ expect(find(".js-ci-variable-input-value", visible: false).value).to eq("protected_value")
+ expect(find(".js-ci-variable-input-protected", visible: false).value).to eq("false")
end
end
- it 'handles multiple edits and deletion in the middle' do
- page.within('.js-ci-variable-list-section') do
+ it "handles multiple edits and deletion in the middle" do
+ page.within(".js-ci-variable-list-section") do
# Create 2 variables
- page.within('.js-row:last-child') do
- find('.js-ci-variable-input-key').set('akey')
- find('.js-ci-variable-input-value').set('akeyvalue')
+ page.within(".js-row:last-child") do
+ find(".js-ci-variable-input-key").set("akey")
+ find(".js-ci-variable-input-value").set("akeyvalue")
end
- page.within('.js-row:last-child') do
- find('.js-ci-variable-input-key').set('zkey')
- find('.js-ci-variable-input-value').set('zkeyvalue')
+ page.within(".js-row:last-child") do
+ find(".js-ci-variable-input-key").set("zkey")
+ find(".js-ci-variable-input-value").set("zkeyvalue")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
- expect(page).to have_selector('.js-row', count: 4)
+ expect(page).to have_selector(".js-row", count: 4)
# Remove the `akey` variable
- page.within('.js-row:nth-child(2)') do
- first('.js-row-remove-button').click
+ page.within(".js-row:nth-child(2)") do
+ first(".js-row-remove-button").click
end
# Add another variable
- page.within('.js-row:last-child') do
- find('.js-ci-variable-input-key').set('ckey')
- find('.js-ci-variable-input-value').set('ckeyvalue')
+ page.within(".js-row:last-child") do
+ find(".js-ci-variable-input-key").set("ckey")
+ find(".js-ci-variable-input-value").set("ckeyvalue")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
visit page_path
# Expect to find 3 variables(4 rows) in alphbetical order
- expect(page).to have_selector('.js-row', count: 4)
- row_keys = all('.js-ci-variable-input-key')
- expect(row_keys[0].value).to eq('ckey')
- expect(row_keys[1].value).to eq('test_key')
- expect(row_keys[2].value).to eq('zkey')
- expect(row_keys[3].value).to eq('')
+ expect(page).to have_selector(".js-row", count: 4)
+ row_keys = all(".js-ci-variable-input-key")
+ expect(row_keys[0].value).to eq("ckey")
+ expect(row_keys[1].value).to eq("test_key")
+ expect(row_keys[2].value).to eq("zkey")
+ expect(row_keys[3].value).to eq("")
end
end
- it 'shows validation error box about duplicate keys' do
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('samekey')
- find('.js-ci-variable-input-value').set('value1')
+ it "shows validation error box about duplicate keys" do
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("samekey")
+ find(".js-ci-variable-input-value").set("value1")
end
- page.within('.js-ci-variable-list-section .js-row:last-child') do
- find('.js-ci-variable-input-key').set('samekey')
- find('.js-ci-variable-input-value').set('value2')
+ page.within(".js-ci-variable-list-section .js-row:last-child") do
+ find(".js-ci-variable-input-key").set("samekey")
+ find(".js-ci-variable-input-value").set("value2")
end
- click_button('Save variables')
+ click_button("Save variables")
wait_for_requests
- expect(all('.js-ci-variable-list-section .js-ci-variable-error-box ul li').count).to eq(1)
+ expect(all(".js-ci-variable-list-section .js-ci-variable-error-box ul li").count).to eq(1)
# We check the first row because it re-sorts to alphabetical order on refresh
- page.within('.js-ci-variable-list-section') do
- expect(find('.js-ci-variable-error-box')).to have_content(/Validation failed Variables have duplicate values \(.+\)/)
+ page.within(".js-ci-variable-list-section") do
+ expect(find(".js-ci-variable-error-box")).to have_content(/Validation failed Variables have duplicate values \(.+\)/)
end
end
end
diff --git a/spec/support/generate-seed-repo-rb b/spec/support/generate-seed-repo-rb
index bee9d419376..a0d496445e6 100755
--- a/spec/support/generate-seed-repo-rb
+++ b/spec/support/generate-seed-repo-rb
@@ -12,16 +12,16 @@
#
#
-require 'erb'
-require 'tempfile'
+require "erb"
+require "tempfile"
-SOURCE = File.expand_path('gitlab-git-test.git', __dir__).freeze
-SCRIPT_NAME = 'generate-seed-repo-rb'.freeze
-REPO_NAME = 'gitlab-git-test.git'.freeze
+SOURCE = File.expand_path("gitlab-git-test.git", __dir__).freeze
+SCRIPT_NAME = "generate-seed-repo-rb".freeze
+REPO_NAME = "gitlab-git-test.git".freeze
def main
Dir.mktmpdir do |dir|
- unless system(*%W[git clone --bare #{SOURCE} #{REPO_NAME}], chdir: dir)
+ unless system("git", "clone", "--bare", SOURCE.to_s, REPO_NAME.to_s, chdir: dir)
abort "git clone failed"
end
@@ -32,8 +32,8 @@ def main
end
def capture!(cmd, dir)
- output = IO.popen(cmd, 'r', chdir: dir) { |io| io.read }
- raise "command failed with #{$?}: #{cmd.join(' ')}" unless $?.success?
+ output = IO.popen(cmd, "r", chdir: dir) { |io| io.read }
+ raise "command failed with #{$?}: #{cmd.join(" ")}" unless $?.success?
output.chomp
end
diff --git a/spec/support/google_api/cloud_platform_helpers.rb b/spec/support/google_api/cloud_platform_helpers.rb
index 2fdbddd40c2..0084e7b30d8 100644
--- a/spec/support/google_api/cloud_platform_helpers.rb
+++ b/spec/support/google_api/cloud_platform_helpers.rb
@@ -1,12 +1,12 @@
module GoogleApi
module CloudPlatformHelpers
def stub_google_api_validate_token
- request.session[GoogleApi::CloudPlatform::Client.session_key_for_token] = 'token'
+ request.session[GoogleApi::CloudPlatform::Client.session_key_for_token] = "token"
request.session[GoogleApi::CloudPlatform::Client.session_key_for_expires_at] = 1.hour.since.to_i.to_s
end
def stub_google_api_expired_token
- request.session[GoogleApi::CloudPlatform::Client.session_key_for_token] = 'token'
+ request.session[GoogleApi::CloudPlatform::Client.session_key_for_token] = "token"
request.session[GoogleApi::CloudPlatform::Client.session_key_for_expires_at] = 1.hour.ago.to_i.to_s
end
@@ -71,11 +71,11 @@ module GoogleApi
end
def cloud_platform_response(body)
- { status: 200, headers: { 'Content-Type' => 'application/json' }, body: body.to_json }
+ {status: 200, headers: {"Content-Type" => "application/json"}, body: body.to_json}
end
def load_sample_cert
- pem_file = File.expand_path(Rails.root.join('spec/fixtures/clusters/sample_cert.pem'))
+ pem_file = File.expand_path(Rails.root.join("spec/fixtures/clusters/sample_cert.pem"))
Base64.encode64(File.read(pem_file))
end
@@ -86,51 +86,51 @@ module GoogleApi
# rubocop:disable Metrics/PerceivedComplexity
def cloud_platform_cluster_body(**options)
{
- "name": options[:name] || 'string',
- "description": options[:description] || 'string',
- "initialNodeCount": options[:initialNodeCount] || 'number',
+ "name": options[:name] || "string",
+ "description": options[:description] || "string",
+ "initialNodeCount": options[:initialNodeCount] || "number",
"masterAuth": {
- "username": options[:username] || 'string',
- "password": options[:password] || 'string',
+ "username": options[:username] || "string",
+ "password": options[:password] || "string",
"clusterCaCertificate": options[:clusterCaCertificate] || load_sample_cert,
- "clientCertificate": options[:clientCertificate] || 'string',
- "clientKey": options[:clientKey] || 'string'
+ "clientCertificate": options[:clientCertificate] || "string",
+ "clientKey": options[:clientKey] || "string",
},
- "loggingService": options[:loggingService] || 'string',
- "monitoringService": options[:monitoringService] || 'string',
- "network": options[:network] || 'string',
- "clusterIpv4Cidr": options[:clusterIpv4Cidr] || 'string',
- "subnetwork": options[:subnetwork] || 'string',
- "enableKubernetesAlpha": options[:enableKubernetesAlpha] || 'boolean',
- "labelFingerprint": options[:labelFingerprint] || 'string',
- "selfLink": options[:selfLink] || 'string',
- "zone": options[:zone] || 'string',
- "endpoint": options[:endpoint] || 'string',
- "initialClusterVersion": options[:initialClusterVersion] || 'string',
- "currentMasterVersion": options[:currentMasterVersion] || 'string',
- "currentNodeVersion": options[:currentNodeVersion] || 'string',
- "createTime": options[:createTime] || 'string',
- "status": options[:status] || 'RUNNING',
- "statusMessage": options[:statusMessage] || 'string',
- "nodeIpv4CidrSize": options[:nodeIpv4CidrSize] || 'number',
- "servicesIpv4Cidr": options[:servicesIpv4Cidr] || 'string',
- "currentNodeCount": options[:currentNodeCount] || 'number',
- "expireTime": options[:expireTime] || 'string'
+ "loggingService": options[:loggingService] || "string",
+ "monitoringService": options[:monitoringService] || "string",
+ "network": options[:network] || "string",
+ "clusterIpv4Cidr": options[:clusterIpv4Cidr] || "string",
+ "subnetwork": options[:subnetwork] || "string",
+ "enableKubernetesAlpha": options[:enableKubernetesAlpha] || "boolean",
+ "labelFingerprint": options[:labelFingerprint] || "string",
+ "selfLink": options[:selfLink] || "string",
+ "zone": options[:zone] || "string",
+ "endpoint": options[:endpoint] || "string",
+ "initialClusterVersion": options[:initialClusterVersion] || "string",
+ "currentMasterVersion": options[:currentMasterVersion] || "string",
+ "currentNodeVersion": options[:currentNodeVersion] || "string",
+ "createTime": options[:createTime] || "string",
+ "status": options[:status] || "RUNNING",
+ "statusMessage": options[:statusMessage] || "string",
+ "nodeIpv4CidrSize": options[:nodeIpv4CidrSize] || "number",
+ "servicesIpv4Cidr": options[:servicesIpv4Cidr] || "string",
+ "currentNodeCount": options[:currentNodeCount] || "number",
+ "expireTime": options[:expireTime] || "string",
}
end
def cloud_platform_operation_body(**options)
{
- "name": options[:name] || 'operation-1234567891234-1234567',
- "zone": options[:zone] || 'us-central1-a',
- "operationType": options[:operationType] || 'CREATE_CLUSTER',
- "status": options[:status] || 'PENDING',
- "detail": options[:detail] || 'detail',
- "statusMessage": options[:statusMessage] || '',
- "selfLink": options[:selfLink] || 'https://container.googleapis.com/v1/projects/123456789101/zones/us-central1-a/operations/operation-1234567891234-1234567',
- "targetLink": options[:targetLink] || 'https://container.googleapis.com/v1/projects/123456789101/zones/us-central1-a/clusters/test-cluster',
- "startTime": options[:startTime] || '2017-09-13T16:49:13.055601589Z',
- "endTime": options[:endTime] || ''
+ "name": options[:name] || "operation-1234567891234-1234567",
+ "zone": options[:zone] || "us-central1-a",
+ "operationType": options[:operationType] || "CREATE_CLUSTER",
+ "status": options[:status] || "PENDING",
+ "detail": options[:detail] || "detail",
+ "statusMessage": options[:statusMessage] || "",
+ "selfLink": options[:selfLink] || "https://container.googleapis.com/v1/projects/123456789101/zones/us-central1-a/operations/operation-1234567891234-1234567",
+ "targetLink": options[:targetLink] || "https://container.googleapis.com/v1/projects/123456789101/zones/us-central1-a/clusters/test-cluster",
+ "startTime": options[:startTime] || "2017-09-13T16:49:13.055601589Z",
+ "endTime": options[:endTime] || "",
}
end
@@ -145,19 +145,19 @@ module GoogleApi
"createTime": "2017-12-16T01:48:29.129Z",
"parent": {
"type": "organization",
- "id": "12345"
- }
- }
- ]
+ "id": "12345",
+ },
+ },
+ ],
}
end
def cloud_platform_projects_billing_info_body(project_id, billing_enabled)
{
"name": "projects/#{project_id}/billingInfo",
- "projectId": "#{project_id}",
+ "projectId": project_id.to_s,
"billingAccountName": "account-name",
- "billingEnabled": billing_enabled
+ "billingEnabled": billing_enabled,
}
end
end
diff --git a/spec/support/helpers/api_helpers.rb b/spec/support/helpers/api_helpers.rb
index 4a9ce9beb78..b7cc583f79e 100644
--- a/spec/support/helpers/api_helpers.rb
+++ b/spec/support/helpers/api_helpers.rb
@@ -30,7 +30,7 @@ module ApiHelpers
end
if query_string
- full_path << (path.index('?') ? '&' : '?')
+ full_path << (path.index("?") ? "&" : "?")
full_path << query_string
end
@@ -41,6 +41,6 @@ module ApiHelpers
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.map { |item| item['id'] }).to eq(Array(items))
+ expect(json_response.map { |item| item["id"] }).to eq(Array(items))
end
end
diff --git a/spec/support/helpers/assets_helpers.rb b/spec/support/helpers/assets_helpers.rb
index 09bbf451671..67519c30c0d 100644
--- a/spec/support/helpers/assets_helpers.rb
+++ b/spec/support/helpers/assets_helpers.rb
@@ -6,7 +6,7 @@ module AssetsHelpers
#
# Sprockets doesn't provide one method to access an asset for both cases.
def find_asset(asset_name)
- if ENV['CI']
+ if ENV["CI"]
Sprockets::Railtie.build_environment(Rails.application, true)[asset_name]
else
Rails.application.assets.find_asset(asset_name)
diff --git a/spec/support/helpers/bare_repo_operations.rb b/spec/support/helpers/bare_repo_operations.rb
index 3f4a4243cb6..c2273fc941f 100644
--- a/spec/support/helpers/bare_repo_operations.rb
+++ b/spec/support/helpers/bare_repo_operations.rb
@@ -1,4 +1,4 @@
-require 'zlib'
+require "zlib"
class BareRepoOperations
include Gitlab::Popen
@@ -8,45 +8,45 @@ class BareRepoOperations
end
def commit_tree(tree_id, msg, parent: Gitlab::Git::EMPTY_TREE_ID)
- commit_tree_args = ['commit-tree', tree_id, '-m', msg]
- commit_tree_args += ['-p', parent] unless parent == Gitlab::Git::EMPTY_TREE_ID
+ commit_tree_args = ["commit-tree", tree_id, "-m", msg]
+ commit_tree_args += ["-p", parent] unless parent == Gitlab::Git::EMPTY_TREE_ID
commit_id = execute(commit_tree_args)
commit_id[0]
end
# Based on https://stackoverflow.com/a/25556917/1856239
- def commit_file(file, dst_path, branch = 'master')
- head_id = execute(['show', '--format=format:%H', '--no-patch', branch], allow_failure: true)[0] || Gitlab::Git::EMPTY_TREE_ID
+ def commit_file(file, dst_path, branch = "master")
+ head_id = execute(["show", "--format=format:%H", "--no-patch", branch], allow_failure: true)[0] || Gitlab::Git::EMPTY_TREE_ID
- execute(['read-tree', '--empty'])
- execute(['read-tree', head_id])
+ execute(["read-tree", "--empty"])
+ execute(["read-tree", head_id])
- blob_id = execute(['hash-object', '--stdin', '-w']) do |stdin|
+ blob_id = execute(["hash-object", "--stdin", "-w"]) { |stdin|
stdin.write(file.read)
- end
+ }
- execute(['update-index', '--add', '--cacheinfo', '100644', blob_id[0], dst_path])
+ execute(["update-index", "--add", "--cacheinfo", "100644", blob_id[0], dst_path])
- tree_id = execute(['write-tree'])
+ tree_id = execute(["write-tree"])
commit_id = commit_tree(tree_id[0], "Add #{dst_path}", parent: head_id)
- execute(['update-ref', "refs/heads/#{branch}", commit_id])
+ execute(["update-ref", "refs/heads/#{branch}", commit_id])
end
private
def execute(args, allow_failure: false)
- output, status = popen(base_args + args, nil) do |stdin|
+ output, status = popen(base_args + args, nil) { |stdin|
yield stdin if block_given?
- end
+ }
unless status.zero?
if allow_failure
return []
else
- raise "Got a non-zero exit code while calling out `#{args.join(' ')}`: #{output}"
+ raise "Got a non-zero exit code while calling out `#{args.join(" ")}`: #{output}"
end
end
@@ -56,7 +56,7 @@ class BareRepoOperations
def base_args
[
Gitlab.config.git.bin_path,
- "--git-dir=#{@path_to_repo}"
+ "--git-dir=#{@path_to_repo}",
]
end
end
diff --git a/spec/support/helpers/board_helpers.rb b/spec/support/helpers/board_helpers.rb
index b85fde222ea..d67302584ec 100644
--- a/spec/support/helpers/board_helpers.rb
+++ b/spec/support/helpers/board_helpers.rb
@@ -1,7 +1,7 @@
module BoardHelpers
def click_card(card)
within card do
- first('.board-card-number').click
+ first(".board-card-number").click
end
wait_for_sidebar
diff --git a/spec/support/helpers/capybara_helpers.rb b/spec/support/helpers/capybara_helpers.rb
index bcc2df44708..88971ed7968 100644
--- a/spec/support/helpers/capybara_helpers.rb
+++ b/spec/support/helpers/capybara_helpers.rb
@@ -32,12 +32,12 @@ module CapybaraHelpers
#
def refresh
url = current_url
- visit 'about:blank'
+ visit "about:blank"
visit url
end
# Simulate a browser restart by clearing the session cookie.
def clear_browser_session
- page.driver.browser.manage.delete_cookie('_gitlab_session')
+ page.driver.browser.manage.delete_cookie("_gitlab_session")
end
end
diff --git a/spec/support/helpers/ci_artifact_metadata_generator.rb b/spec/support/helpers/ci_artifact_metadata_generator.rb
index ef638d59d2d..c8bcad34415 100644
--- a/spec/support/helpers/ci_artifact_metadata_generator.rb
+++ b/spec/support/helpers/ci_artifact_metadata_generator.rb
@@ -13,7 +13,7 @@ class CiArtifactMetadataGenerator
end
def add_entry(filename)
- @entries[filename] = { CRC: rand(0xfffffff), Comment: FFaker::Lorem.sentence(10) }
+ @entries[filename] = {CRC: rand(0xfffffff), Comment: FFaker::Lorem.sentence(10)}
end
def write
@@ -30,7 +30,7 @@ class CiArtifactMetadataGenerator
end
def write_errors
- write_string('{}')
+ write_string("{}")
end
def write_entries
@@ -41,7 +41,7 @@ class CiArtifactMetadataGenerator
end
def write_string(data)
- bytes = [data.length].pack('L>')
+ bytes = [data.length].pack("L>")
output.write(bytes)
output.write(data)
end
diff --git a/spec/support/helpers/cookie_helper.rb b/spec/support/helpers/cookie_helper.rb
index 5ff7b0b68c9..d35d907ae60 100644
--- a/spec/support/helpers/cookie_helper.rb
+++ b/spec/support/helpers/cookie_helper.rb
@@ -13,7 +13,7 @@ module CookieHelper
def selenium_set_cookie(name, value, options = {})
# Selenium driver will not set cookies for a given domain when the browser is at `about:blank`.
# It also doesn't appear to allow overriding the cookie path. loading `/` is the most inclusive.
- visit options.fetch(:path, '/') unless on_a_page?
+ visit options.fetch(:path, "/") unless on_a_page?
page.driver.browser.manage.add_cookie(name: name, value: value, **options)
end
@@ -29,6 +29,6 @@ module CookieHelper
def on_a_page?
current_url = Capybara.current_session.driver.browser.current_url
- current_url && current_url != '' && current_url != 'about:blank' && current_url != 'data:,'
+ current_url && current_url != "" && current_url != "about:blank" && current_url != "data:,"
end
end
diff --git a/spec/support/helpers/cycle_analytics_helpers.rb b/spec/support/helpers/cycle_analytics_helpers.rb
index ecefdc23811..6ab7beca91c 100644
--- a/spec/support/helpers/cycle_analytics_helpers.rb
+++ b/spec/support/helpers/cycle_analytics_helpers.rb
@@ -2,7 +2,7 @@ module CycleAnalyticsHelpers
include GitHelpers
def create_commit_referencing_issue(issue, branch_name: generate(:branch))
- project.repository.add_branch(user, branch_name, 'master')
+ project.repository.add_branch(user, branch_name, "master")
create_commit("Commit for ##{issue.iid}", issue.project, user, branch_name)
end
@@ -14,20 +14,20 @@ module CycleAnalyticsHelpers
mock_gitaly_multi_action_dates(repository, commit_time)
end
- commit_shas = Array.new(count) do |index|
+ commit_shas = Array.new(count) { |index|
commit_sha = repository.create_file(user, generate(:branch), "content", message: message, branch_name: branch_name)
repository.commit(commit_sha)
commit_sha
- end
+ }
return if skip_push_handler
GitPushService.new(project,
- user,
- oldrev: oldrev,
- newrev: commit_shas.last,
- ref: 'refs/heads/master').execute
+ user,
+ oldrev: oldrev,
+ newrev: commit_shas.last,
+ ref: "refs/heads/master").execute
end
def create_cycle(user, project, issue, mr, milestone, pipeline)
@@ -42,10 +42,10 @@ module CycleAnalyticsHelpers
ci_build
end
- def create_merge_request_closing_issue(user, project, issue, message: nil, source_branch: nil, commit_message: 'commit message')
+ def create_merge_request_closing_issue(user, project, issue, message: nil, source_branch: nil, commit_message: "commit message")
if !source_branch || project.repository.commit(source_branch).blank?
source_branch = generate(:branch)
- project.repository.add_branch(user, source_branch, 'master')
+ project.repository.add_branch(user, source_branch, "master")
end
# Cycle analytic specs often test with frozen times, which causes metrics to be
@@ -55,10 +55,10 @@ module CycleAnalyticsHelpers
create_commit(commit_message, project, user, source_branch, commit_time: Time.now + 1.second, skip_push_handler: true)
opts = {
- title: 'Awesome merge_request',
+ title: "Awesome merge_request",
description: message || "Fixes #{issue.to_reference}",
source_branch: source_branch,
- target_branch: 'master'
+ target_branch: "master",
}
mr = MergeRequests::CreateService.new(project, user, opts).execute
@@ -68,18 +68,18 @@ module CycleAnalyticsHelpers
def merge_merge_requests_closing_issue(user, project, issue)
merge_requests = Issues::ReferencedMergeRequestsService
- .new(project, user)
- .closed_by_merge_requests(issue)
+ .new(project, user)
+ .closed_by_merge_requests(issue)
merge_requests.each { |merge_request| MergeRequests::MergeService.new(project, user).execute(merge_request) }
end
- def deploy_master(user, project, environment: 'production')
+ def deploy_master(user, project, environment: "production")
dummy_job =
case environment
- when 'production'
+ when "production"
dummy_production_job(user, project)
- when 'staging'
+ when "staging"
dummy_staging_job(user, project)
else
raise ArgumentError
@@ -89,17 +89,17 @@ module CycleAnalyticsHelpers
end
def dummy_production_job(user, project)
- new_dummy_job(user, project, 'production')
+ new_dummy_job(user, project, "production")
end
def dummy_staging_job(user, project)
- new_dummy_job(user, project, 'staging')
+ new_dummy_job(user, project, "staging")
end
def dummy_pipeline(project)
create(:ci_pipeline,
- sha: project.repository.commit('master').sha,
- ref: 'master',
+ sha: project.repository.commit("master").sha,
+ ref: "master",
source: :push,
project: project,
protected: false)
@@ -110,10 +110,10 @@ module CycleAnalyticsHelpers
project: project,
user: user,
environment: environment,
- ref: 'master',
+ ref: "master",
tag: false,
- name: 'dummy',
- stage: 'dummy',
+ name: "dummy",
+ stage: "dummy",
pipeline: dummy_pipeline(project),
protected: false)
end
diff --git a/spec/support/helpers/devise_helpers.rb b/spec/support/helpers/devise_helpers.rb
index d32bc2424c0..029934bb466 100644
--- a/spec/support/helpers/devise_helpers.rb
+++ b/spec/support/helpers/devise_helpers.rb
@@ -4,7 +4,7 @@ module DeviseHelpers
def set_devise_mapping(context:)
env = env_from_context(context)
- env['devise.mapping'] = Devise.mappings[:user] if env
+ env["devise.mapping"] = Devise.mappings[:user] if env
end
def env_from_context(context)
diff --git a/spec/support/helpers/drag_to_helper.rb b/spec/support/helpers/drag_to_helper.rb
index 6d53ad0b602..c477fe39eac 100644
--- a/spec/support/helpers/drag_to_helper.rb
+++ b/spec/support/helpers/drag_to_helper.rb
@@ -1,5 +1,5 @@
module DragTo
- def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: '', scrollable: 'body', duration: 1000)
+ def drag_to(list_from_index: 0, from_index: 0, to_index: 0, list_to_index: 0, selector: "", scrollable: "body", duration: 1000)
evaluate_script("simulateDrag({scrollable: $('#{scrollable}').get(0), duration: #{duration}, from: {el: $('#{selector}').eq(#{list_from_index}).get(0), index: #{from_index}}, to: {el: $('#{selector}').eq(#{list_to_index}).get(0), index: #{to_index}}});")
Timeout.timeout(Capybara.default_max_wait_time) do
@@ -8,6 +8,6 @@ module DragTo
end
def drag_active?
- page.evaluate_script('window.SIMULATE_DRAG_ACTIVE').nonzero?
+ page.evaluate_script("window.SIMULATE_DRAG_ACTIVE").nonzero?
end
end
diff --git a/spec/support/helpers/dropzone_helper.rb b/spec/support/helpers/dropzone_helper.rb
index fe72d320fcf..bb6570c9e73 100644
--- a/spec/support/helpers/dropzone_helper.rb
+++ b/spec/support/helpers/dropzone_helper.rb
@@ -23,7 +23,7 @@ module DropzoneHelper
JS
# Attach files to the fake input selector with Capybara
- attach_file('fakeFileInput', files)
+ attach_file("fakeFileInput", files)
# Manually trigger a Dropzone "drop" event with the fake input's file list
page.execute_script <<-JS.strip_heredoc
@@ -51,7 +51,7 @@ module DropzoneHelper
if wait_for_queuecomplete
# Wait until Dropzone's fired `queuecomplete`
- loop until page.evaluate_script('window._dropzoneComplete === true')
+ loop until page.evaluate_script("window._dropzoneComplete === true")
end
end
@@ -64,7 +64,7 @@ module DropzoneHelper
JS
# Attach the file to the fake input selector with Capybara
- attach_file('fakeFileInput', file_path)
+ attach_file("fakeFileInput", file_path)
# Add the file to a fileList array and trigger the fake drop event
page.execute_script <<-JS
diff --git a/spec/support/helpers/email_helpers.rb b/spec/support/helpers/email_helpers.rb
index ad6e1064499..2bf9d244e81 100644
--- a/spec/support/helpers/email_helpers.rb
+++ b/spec/support/helpers/email_helpers.rb
@@ -36,7 +36,7 @@ module EmailHelpers
end
def have_referable_subject(referable, include_project: true, reply: false)
- prefix = (include_project && referable.project ? "#{referable.project.name} | " : '').freeze
+ prefix = (include_project && referable.project ? "#{referable.project.name} | " : "").freeze
prefix = "Re: #{prefix}" if reply
suffix = "#{referable.title} (#{referable.to_reference})"
diff --git a/spec/support/helpers/exclusive_lease_helpers.rb b/spec/support/helpers/exclusive_lease_helpers.rb
index 383cc7dee81..ed0d25889e0 100644
--- a/spec/support/helpers/exclusive_lease_helpers.rb
+++ b/spec/support/helpers/exclusive_lease_helpers.rb
@@ -1,5 +1,5 @@
module ExclusiveLeaseHelpers
- def stub_exclusive_lease(key = nil, uuid = 'uuid', renew: false, timeout: nil)
+ def stub_exclusive_lease(key = nil, uuid = "uuid", renew: false, timeout: nil)
key ||= instance_of(String)
timeout ||= instance_of(Integer)
@@ -22,7 +22,7 @@ module ExclusiveLeaseHelpers
stub_exclusive_lease(key, nil, timeout: timeout)
end
- def expect_to_obtain_exclusive_lease(key, uuid = 'uuid', timeout: nil)
+ def expect_to_obtain_exclusive_lease(key, uuid = "uuid", timeout: nil)
lease = stub_exclusive_lease(key, uuid, timeout: timeout)
expect(lease).to receive(:try_obtain)
diff --git a/spec/support/helpers/expect_offense.rb b/spec/support/helpers/expect_offense.rb
index 35718ba90c5..8aed8112518 100644
--- a/spec/support/helpers/expect_offense.rb
+++ b/spec/support/helpers/expect_offense.rb
@@ -1,4 +1,4 @@
-require 'rubocop/rspec/support'
+require "rubocop/rspec/support"
# https://github.com/backus/rubocop-rspec/blob/master/spec/support/expect_offense.rb
# rubocop-rspec gem extension of RuboCop's ExpectOffense module.
@@ -8,7 +8,7 @@ require 'rubocop/rspec/support'
module ExpectOffense
include RuboCop::RSpec::ExpectOffense
- DEFAULT_FILENAME = 'example_spec.rb'.freeze
+ DEFAULT_FILENAME = "example_spec.rb".freeze
def expect_offense(source, filename = DEFAULT_FILENAME)
super
diff --git a/spec/support/helpers/fake_blob_helpers.rb b/spec/support/helpers/fake_blob_helpers.rb
index 801ca8b7412..c864df2fde0 100644
--- a/spec/support/helpers/fake_blob_helpers.rb
+++ b/spec/support/helpers/fake_blob_helpers.rb
@@ -4,7 +4,7 @@ module FakeBlobHelpers
attr_reader :path, :size, :data, :lfs_oid, :lfs_size
- def initialize(path: 'file.txt', size: 1.kilobyte, data: 'foo', binary: false, lfs: nil)
+ def initialize(path: "file.txt", size: 1.kilobyte, data: "foo", binary: false, lfs: nil)
@path = path
@size = size
@data = data
@@ -17,7 +17,7 @@ module FakeBlobHelpers
end
end
- alias_method :name, :path
+ alias name path
def id
0
@@ -31,7 +31,7 @@ module FakeBlobHelpers
:lfs if @lfs_pointer
end
- alias_method :external_size, :lfs_size
+ alias external_size lfs_size
end
def fake_blob(**kwargs)
diff --git a/spec/support/helpers/fake_migration_classes.rb b/spec/support/helpers/fake_migration_classes.rb
index c7766df7a52..66054ba753c 100644
--- a/spec/support/helpers/fake_migration_classes.rb
+++ b/spec/support/helpers/fake_migration_classes.rb
@@ -2,7 +2,7 @@ class FakeRenameReservedPathMigrationV1 < ActiveRecord::Migration[4.2]
include Gitlab::Database::RenameReservedPathsMigration::V1
def version
- '20170316163845'
+ "20170316163845"
end
def name
diff --git a/spec/support/helpers/fake_u2f_device.rb b/spec/support/helpers/fake_u2f_device.rb
index a7605cd483a..368da8cdaf9 100644
--- a/spec/support/helpers/fake_u2f_device.rb
+++ b/spec/support/helpers/fake_u2f_device.rb
@@ -7,8 +7,8 @@ class FakeU2fDevice
end
def respond_to_u2f_registration
- app_id = @page.evaluate_script('gon.u2f.app_id')
- challenges = @page.evaluate_script('gon.u2f.challenges')
+ app_id = @page.evaluate_script("gon.u2f.app_id")
+ challenges = @page.evaluate_script("gon.u2f.challenges")
json_response = u2f_device(app_id).register_response(challenges[0])
@@ -20,8 +20,8 @@ class FakeU2fDevice
end
def respond_to_u2f_authentication
- app_id = @page.evaluate_script('gon.u2f.app_id')
- challenge = @page.evaluate_script('gon.u2f.challenge')
+ app_id = @page.evaluate_script("gon.u2f.app_id")
+ challenge = @page.evaluate_script("gon.u2f.challenge")
json_response = u2f_device(app_id).sign_response(challenge)
@page.execute_script("
diff --git a/spec/support/helpers/features/list_rows_helpers.rb b/spec/support/helpers/features/list_rows_helpers.rb
index 0626415361c..ce1711d13b4 100644
--- a/spec/support/helpers/features/list_rows_helpers.rb
+++ b/spec/support/helpers/features/list_rows_helpers.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# These helpers allow you to access rows in the list
#
# Usage:
@@ -15,11 +16,11 @@ module Spec
module Features
module ListRowsHelpers
def first_row
- page.all('ul.content-list > li')[0]
+ page.all("ul.content-list > li")[0]
end
def second_row
- page.all('ul.content-list > li')[1]
+ page.all("ul.content-list > li")[1]
end
end
end
diff --git a/spec/support/helpers/features/notes_helpers.rb b/spec/support/helpers/features/notes_helpers.rb
index 89517fde6e2..ebb5da4736d 100644
--- a/spec/support/helpers/features/notes_helpers.rb
+++ b/spec/support/helpers/features/notes_helpers.rb
@@ -22,9 +22,9 @@ module Spec
end
def preview_note(text)
- page.within('.js-main-target-form') do
- fill_in('note[note]', with: text)
- click_on('Preview')
+ page.within(".js-main-target-form") do
+ fill_in("note[note]", with: text)
+ click_on("Preview")
end
end
end
diff --git a/spec/support/helpers/features/responsive_table_helpers.rb b/spec/support/helpers/features/responsive_table_helpers.rb
index 7a175219fe9..3ba7c5c1f13 100644
--- a/spec/support/helpers/features/responsive_table_helpers.rb
+++ b/spec/support/helpers/features/responsive_table_helpers.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
# These helpers allow you to access rows in a responsive table
#
# Usage:
@@ -19,11 +20,11 @@ module Spec
module Features
module ResponsiveTableHelpers
def first_row
- page.all('.gl-responsive-table-row')[1]
+ page.all(".gl-responsive-table-row")[1]
end
def second_row
- page.all('.gl-responsive-table-row')[2]
+ page.all(".gl-responsive-table-row")[2]
end
end
end
diff --git a/spec/support/helpers/features/sorting_helpers.rb b/spec/support/helpers/features/sorting_helpers.rb
index 003ecb251fe..b90c5c573e4 100644
--- a/spec/support/helpers/features/sorting_helpers.rb
+++ b/spec/support/helpers/features/sorting_helpers.rb
@@ -13,9 +13,9 @@ module Spec
module Features
module SortingHelpers
def sort_by(value)
- find('.filter-dropdown-container .dropdown').click
+ find(".filter-dropdown-container .dropdown").click
- page.within('ul.dropdown-menu.dropdown-menu-right li') do
+ page.within("ul.dropdown-menu.dropdown-menu-right li") do
click_link(value)
end
end
diff --git a/spec/support/helpers/filter_spec_helper.rb b/spec/support/helpers/filter_spec_helper.rb
index 721d359c2ee..25fbfecf0f2 100644
--- a/spec/support/helpers/filter_spec_helper.rb
+++ b/spec/support/helpers/filter_spec_helper.rb
@@ -45,7 +45,7 @@ module FilterSpecHelper
filters = [
Banzai::Filter::AutolinkFilter,
- described_class
+ described_class,
]
HTML::Pipeline.new(filters, context)
@@ -68,10 +68,10 @@ module FilterSpecHelper
#
# Returns a String
def invalidate_reference(reference)
- if reference =~ /\A(.+)?[^\d]\d+\z/
+ if /\A(.+)?[^\d]\d+\z/.match?(reference)
# Integer-based reference with optional project prefix
reference.gsub(/\d+\z/) { |i| i.to_i + 10_000 }
- elsif reference =~ /\A(.+@)?(\h{7,40}\z)/
+ elsif /\A(.+@)?(\h{7,40}\z)/.match?(reference)
# SHA-based reference with optional prefix
reference.gsub(/\h{7,40}\z/) { |v| v.reverse }
else
diff --git a/spec/support/helpers/filtered_search_helpers.rb b/spec/support/helpers/filtered_search_helpers.rb
index 6569feec39b..af3e638d584 100644
--- a/spec/support/helpers/filtered_search_helpers.rb
+++ b/spec/support/helpers/filtered_search_helpers.rb
@@ -1,6 +1,6 @@
module FilteredSearchHelpers
def filtered_search
- page.find('.filtered-search')
+ page.find(".filtered-search")
end
# Enables input to be set (similar to copy and paste)
@@ -26,10 +26,10 @@ module FilteredSearchHelpers
def select_label_on_dropdown(label_title)
input_filtered_search("label:", submit: false)
- within('#js-dropdown-label') do
+ within("#js-dropdown-label") do
wait_for_requests
- find('li', text: label_title).click
+ find("li", text: label_title).click
end
filtered_search.send_keys(:enter)
@@ -39,8 +39,8 @@ module FilteredSearchHelpers
all_count = open_count + closed_count
expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count)
- page.within '.issues-list' do
- expect(page).to have_selector('.issue', count: open_count)
+ page.within ".issues-list" do
+ expect(page).to have_selector(".issue", count: open_count)
end
end
@@ -52,11 +52,11 @@ module FilteredSearchHelpers
end
def expect_filtered_search_input(input)
- expect(find('.filtered-search').value).to eq(input)
+ expect(find(".filtered-search").value).to eq(input)
end
def clear_search_field
- find('.filtered-search-box .clear-search').click
+ find(".filtered-search-box .clear-search").click
end
def reset_filters
@@ -65,79 +65,79 @@ module FilteredSearchHelpers
end
def init_label_search
- filtered_search.set('label:')
+ filtered_search.set("label:")
# This ensures the dropdown is shown
- expect(find('#js-dropdown-label')).not_to have_css('.filter-dropdown-loading')
+ expect(find("#js-dropdown-label")).not_to have_css(".filter-dropdown-loading")
end
def expect_filtered_search_input_empty
- expect(find('.filtered-search').value).to eq('')
+ expect(find(".filtered-search").value).to eq("")
end
# Iterates through each visual token inside
# .tokens-container to make sure the correct names and values are rendered
def expect_tokens(tokens)
- page.within '.filtered-search-box .tokens-container' do
- page.all(:css, '.tokens-container li .selectable').each_with_index do |el, index|
+ page.within ".filtered-search-box .tokens-container" do
+ page.all(:css, ".tokens-container li .selectable").each_with_index do |el, index|
token_name = tokens[index][:name]
token_value = tokens[index][:value]
token_emoji = tokens[index][:emoji_name]
- expect(el.find('.name')).to have_content(token_name)
+ expect(el.find(".name")).to have_content(token_name)
if token_value
- expect(el.find('.value')).to have_content(token_value)
+ expect(el.find(".value")).to have_content(token_value)
end
# gl-emoji content is blank when the emoji unicode is not supported
if token_emoji
selector = %(gl-emoji[data-name="#{token_emoji}"])
- expect(el.find('.value')).to have_css(selector)
+ expect(el.find(".value")).to have_css(selector)
end
end
end
end
def create_token(token_name, token_value = nil, symbol = nil)
- { name: token_name, value: "#{symbol}#{token_value}" }
+ {name: token_name, value: "#{symbol}#{token_value}"}
end
def author_token(author_name = nil)
- create_token('Author', author_name)
+ create_token("Author", author_name)
end
def assignee_token(assignee_name = nil)
- create_token('Assignee', assignee_name)
+ create_token("Assignee", assignee_name)
end
def milestone_token(milestone_name = nil, has_symbol = true)
- symbol = has_symbol ? '%' : nil
- create_token('Milestone', milestone_name, symbol)
+ symbol = has_symbol ? "%" : nil
+ create_token("Milestone", milestone_name, symbol)
end
def label_token(label_name = nil, has_symbol = true)
- symbol = has_symbol ? '~' : nil
- create_token('Label', label_name, symbol)
+ symbol = has_symbol ? "~" : nil
+ create_token("Label", label_name, symbol)
end
def reaction_token(reaction_name = nil, is_emoji = true)
if is_emoji
- { name: 'My-Reaction', emoji_name: reaction_name }
+ {name: "My-Reaction", emoji_name: reaction_name}
else
- create_token('My-Reaction', reaction_name)
+ create_token("My-Reaction", reaction_name)
end
end
def default_placeholder
- 'Search or filter results...'
+ "Search or filter results..."
end
def get_filtered_search_placeholder
- find('.filtered-search')['placeholder']
+ find(".filtered-search")["placeholder"]
end
def remove_recent_searches
- execute_script('window.localStorage.clear();')
+ execute_script("window.localStorage.clear();")
end
def set_recent_searches(key, input)
@@ -146,7 +146,7 @@ module FilteredSearchHelpers
def wait_for_filtered_search(text)
Timeout.timeout(Capybara.default_max_wait_time) do
- loop until find('.filtered-search').value.strip == text
+ loop until find(".filtered-search").value.strip == text
end
end
end
diff --git a/spec/support/helpers/fixture_helpers.rb b/spec/support/helpers/fixture_helpers.rb
index 611d19f36a0..e0748a1a000 100644
--- a/spec/support/helpers/fixture_helpers.rb
+++ b/spec/support/helpers/fixture_helpers.rb
@@ -1,11 +1,11 @@
module FixtureHelpers
- def fixture_file(filename, dir: '')
- return '' if filename.blank?
+ def fixture_file(filename, dir: "")
+ return "" if filename.blank?
File.read(expand_fixture_path(filename, dir: dir))
end
- def expand_fixture_path(filename, dir: '')
- File.expand_path(Rails.root.join(dir, 'spec', 'fixtures', filename))
+ def expand_fixture_path(filename, dir: "")
+ File.expand_path(Rails.root.join(dir, "spec", "fixtures", filename))
end
end
diff --git a/spec/support/helpers/git_helpers.rb b/spec/support/helpers/git_helpers.rb
index 99a7c39852e..bc8a4fd852d 100644
--- a/spec/support/helpers/git_helpers.rb
+++ b/spec/support/helpers/git_helpers.rb
@@ -2,7 +2,7 @@
module GitHelpers
def rugged_repo(repository)
- path = File.join(TestEnv.repos_path, repository.disk_path + '.git')
+ path = File.join(TestEnv.repos_path, repository.disk_path + ".git")
Rugged::Repository.new(path)
end
@@ -11,7 +11,7 @@ module GitHelpers
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
project_path = project.repository.raw_repository.path
- File.exist?(File.join(project_path, 'hooks', 'post-receive'))
+ File.exist?(File.join(project_path, "hooks", "post-receive"))
end
end
end
diff --git a/spec/support/helpers/git_http_helpers.rb b/spec/support/helpers/git_http_helpers.rb
index cd49bb148f2..d5a36c0a3cf 100644
--- a/spec/support/helpers/git_http_helpers.rb
+++ b/spec/support/helpers/git_http_helpers.rb
@@ -1,6 +1,6 @@
module GitHttpHelpers
def clone_get(project, options = {})
- get "/#{project}/info/refs", params: { service: 'git-upload-pack' }, headers: auth_env(*options.values_at(:user, :password, :spnego_request_token))
+ get "/#{project}/info/refs", params: {service: "git-upload-pack"}, headers: auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
def clone_post(project, options = {})
@@ -8,7 +8,7 @@ module GitHttpHelpers
end
def push_get(project, options = {})
- get "/#{project}/info/refs", params: { service: 'git-receive-pack' }, headers: auth_env(*options.values_at(:user, :password, :spnego_request_token))
+ get "/#{project}/info/refs", params: {service: "git-receive-pack"}, headers: auth_env(*options.values_at(:user, :password, :spnego_request_token))
end
def push_post(project, options = {})
@@ -16,7 +16,7 @@ module GitHttpHelpers
end
def download(project, user: nil, password: nil, spnego_request_token: nil)
- args = [project, { user: user, password: password, spnego_request_token: spnego_request_token }]
+ args = [project, {user: user, password: password, spnego_request_token: spnego_request_token}]
clone_get(*args)
yield response
@@ -26,7 +26,7 @@ module GitHttpHelpers
end
def upload(project, user: nil, password: nil, spnego_request_token: nil)
- args = [project, { user: user, password: password, spnego_request_token: spnego_request_token }]
+ args = [project, {user: user, password: password, spnego_request_token: spnego_request_token}]
push_get(*args)
yield response
@@ -43,9 +43,9 @@ module GitHttpHelpers
def auth_env(user, password, spnego_request_token)
env = workhorse_internal_api_request_header
if user
- env['HTTP_AUTHORIZATION'] = ActionController::HttpAuthentication::Basic.encode_credentials(user, password)
+ env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials(user, password)
elsif spnego_request_token
- env['HTTP_AUTHORIZATION'] = "Negotiate #{::Base64.strict_encode64('opaque_request_token')}"
+ env["HTTP_AUTHORIZATION"] = "Negotiate #{::Base64.strict_encode64("opaque_request_token")}"
end
env
diff --git a/spec/support/helpers/gpg_helpers.rb b/spec/support/helpers/gpg_helpers.rb
index 8d1637228d0..eaa580f9370 100644
--- a/spec/support/helpers/gpg_helpers.rb
+++ b/spec/support/helpers/gpg_helpers.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
module GpgHelpers
- SIGNED_COMMIT_SHA = '8a852d50dda17cc8fd1408d2fd0c5b0f24c76ca4'
- SIGNED_AND_AUTHORED_SHA = '3c1d9a0266cb0c62d926f4a6c649beed561846f5'
- DIFFERING_EMAIL_SHA = 'a17a9f66543673edf0a3d1c6b93bdda3fe600f32'
+ SIGNED_COMMIT_SHA = "8a852d50dda17cc8fd1408d2fd0c5b0f24c76ca4"
+ SIGNED_AND_AUTHORED_SHA = "3c1d9a0266cb0c62d926f4a6c649beed561846f5"
+ DIFFERING_EMAIL_SHA = "a17a9f66543673edf0a3d1c6b93bdda3fe600f32"
module User1
extend self
@@ -141,15 +141,15 @@ module GpgHelpers
end
def fingerprint
- '5F7EA3981A5845B141ABD522CCFBE19F00AC8B1D'
+ "5F7EA3981A5845B141ABD522CCFBE19F00AC8B1D"
end
def names
- ['Nannie Bernhard']
+ ["Nannie Bernhard"]
end
def emails
- ['nannie.bernhard@example.com']
+ ["nannie.bernhard@example.com"]
end
end
@@ -234,15 +234,15 @@ module GpgHelpers
end
def fingerprint
- '6D494CA6FC90C0CAE0910E42BF9D925F911EFD65'
+ "6D494CA6FC90C0CAE0910E42BF9D925F911EFD65"
end
def names
- ['Bette Cartwright', 'Bette Cartwright']
+ ["Bette Cartwright", "Bette Cartwright"]
end
def emails
- ['bette.cartwright@example.com', 'bette.cartwright@example.net']
+ ["bette.cartwright@example.com", "bette.cartwright@example.net"]
end
end
@@ -430,19 +430,19 @@ module GpgHelpers
end
def fingerprint
- 'EA3F8B88972A8FD474872F2F115B3AF1AAD3EDBA'
+ "EA3F8B88972A8FD474872F2F115B3AF1AAD3EDBA"
end
def subkey_fingerprints
- %w(159AD5DDF199591D67D2B87AA3CEC5C0A7C270EC 0522DD29B98F167CD8421752E38FFCAF75ABD92A)
+ %w[159AD5DDF199591D67D2B87AA3CEC5C0A7C270EC 0522DD29B98F167CD8421752E38FFCAF75ABD92A]
end
def names
- ['John Doe']
+ ["John Doe"]
end
def emails
- ['john.doe@example.com']
+ ["john.doe@example.com"]
end
end
@@ -515,7 +515,7 @@ module GpgHelpers
end
def fingerprint
- '08748B360CD25C2ECC99D59407016CF9E13A3F9B'
+ "08748B360CD25C2ECC99D59407016CF9E13A3F9B"
end
end
end
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index e468ee4676d..739ca8be46a 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -18,12 +18,10 @@ module GraphqlHelpers
# Runs a block inside a BatchLoader::Executor wrapper
def batch(max_queries: nil, &blk)
wrapper = proc do
- begin
- BatchLoader::Executor.ensure_current
- yield
- ensure
- BatchLoader::Executor.clear_current
- end
+ BatchLoader::Executor.ensure_current
+ yield
+ ensure
+ BatchLoader::Executor.clear_current
end
if max_queries
@@ -37,9 +35,9 @@ module GraphqlHelpers
def graphql_query_for(name, attributes = {}, fields = nil)
<<~QUERY
- {
- #{query_graphql_field(name, attributes, fields)}
- }
+ {
+ #{query_graphql_field(name, attributes, fields)}
+ }
QUERY
end
@@ -50,7 +48,7 @@ module GraphqlHelpers
fields ||= all_graphql_fields_for(mutation_field.type)
query = <<~MUTATION
- mutation(#{input_variable_name}: #{mutation_field.arguments['input'].type}) {
+ mutation(#{input_variable_name}: #{mutation_field.arguments["input"].type}) {
#{mutation_name}(input: #{input_variable_name}) {
#{fields}
}
@@ -63,13 +61,13 @@ module GraphqlHelpers
def variables_for_mutation(name, input)
graphql_input = input.map { |name, value| [GraphqlHelpers.fieldnamerize(name), value] }.to_h
- { input_variable_name_for_mutation(name) => graphql_input }.to_json
+ {input_variable_name_for_mutation(name) => graphql_input}.to_json
end
def input_variable_name_for_mutation(mutation_name)
mutation_name = GraphqlHelpers.fieldnamerize(mutation_name)
mutation_field = GitlabSchema.mutation.fields[mutation_name]
- input_type = field_type(mutation_field.arguments['input'])
+ input_type = field_type(mutation_field.arguments["input"])
GraphqlHelpers.fieldnamerize(input_type)
end
@@ -88,7 +86,7 @@ module GraphqlHelpers
type = GitlabSchema.types[class_name.to_s]
return "" unless type
- type.fields.map do |name, field|
+ type.fields.map { |name, field|
# We can't guess arguments, so skip fields that require them
next if required_arguments?(field)
@@ -106,17 +104,17 @@ module GraphqlHelpers
else
name
end
- end.compact.join("\n")
+ }.compact.join("\n")
end
def attributes_to_graphql(attributes)
- attributes.map do |name, value|
+ attributes.map { |name, value|
"#{GraphqlHelpers.fieldnamerize(name.to_s)}: \"#{value}\""
- end.join(", ")
+ }.join(", ")
end
def post_graphql(query, current_user: nil, variables: nil)
- post api('/', current_user, version: 'graphql'), params: { query: query, variables: variables }
+ post api("/", current_user, version: "graphql"), params: {query: query, variables: variables}
end
def post_graphql_mutation(mutation, current_user: nil)
@@ -124,11 +122,11 @@ module GraphqlHelpers
end
def graphql_data
- json_response['data']
+ json_response["data"]
end
def graphql_errors
- json_response['errors']
+ json_response["errors"]
end
def graphql_mutation_response(mutation_name)
diff --git a/spec/support/helpers/import_spec_helper.rb b/spec/support/helpers/import_spec_helper.rb
index d4eced724fa..b919ddc3700 100644
--- a/spec/support/helpers/import_spec_helper.rb
+++ b/spec/support/helpers/import_spec_helper.rb
@@ -1,4 +1,4 @@
-require 'ostruct'
+require "ostruct"
# Helper methods for controller specs in the Import namespace
#
@@ -16,7 +16,7 @@ module ImportSpecHelper
#
# Returns the client double
def stub_client(messages = {})
- client = double('client', messages).as_null_object
+ client = double("client", messages).as_null_object
allow(controller).to receive(:client).and_return(client)
client
@@ -25,8 +25,8 @@ module ImportSpecHelper
def stub_omniauth_provider(name)
provider = OpenStruct.new(
name: name,
- app_id: 'asd123',
- app_secret: 'asd123'
+ app_id: "asd123",
+ app_secret: "asd123"
)
stub_omniauth_setting(providers: [provider])
end
diff --git a/spec/support/helpers/input_helper.rb b/spec/support/helpers/input_helper.rb
index acbb42274ec..a2a57a46c53 100644
--- a/spec/support/helpers/input_helper.rb
+++ b/spec/support/helpers/input_helper.rb
@@ -1,7 +1,7 @@
# see app/assets/javascripts/test_utils/simulate_input.js
module InputHelper
- def simulate_input(selector, input = '')
+ def simulate_input(selector, input = "")
evaluate_script("window.simulateInput(#{selector.to_json}, #{input.to_json});")
end
end
diff --git a/spec/support/helpers/inspect_requests.rb b/spec/support/helpers/inspect_requests.rb
index 88ddc5c7f6c..b3784fb302b 100644
--- a/spec/support/helpers/inspect_requests.rb
+++ b/spec/support/helpers/inspect_requests.rb
@@ -1,4 +1,4 @@
-require_relative './wait_for_requests'
+require_relative "./wait_for_requests"
module InspectRequests
extend self
diff --git a/spec/support/helpers/issue_helpers.rb b/spec/support/helpers/issue_helpers.rb
index ffd72515f37..6f21f32112f 100644
--- a/spec/support/helpers/issue_helpers.rb
+++ b/spec/support/helpers/issue_helpers.rb
@@ -4,10 +4,10 @@ module IssueHelpers
end
def first_issue
- page.all('ul.issues-list > li').first.text
+ page.all("ul.issues-list > li").first.text
end
def last_issue
- page.all('ul.issues-list > li').last.text
+ page.all("ul.issues-list > li").last.text
end
end
diff --git a/spec/support/helpers/javascript_fixtures_helpers.rb b/spec/support/helpers/javascript_fixtures_helpers.rb
index 89c5ec7a718..70d2e3f36da 100644
--- a/spec/support/helpers/javascript_fixtures_helpers.rb
+++ b/spec/support/helpers/javascript_fixtures_helpers.rb
@@ -1,10 +1,10 @@
-require 'action_dispatch/testing/test_request'
-require 'fileutils'
+require "action_dispatch/testing/test_request"
+require "fileutils"
module JavaScriptFixturesHelpers
include Gitlab::Popen
- FIXTURE_PATH = 'spec/javascripts/fixtures'.freeze
+ FIXTURE_PATH = "spec/javascripts/fixtures".freeze
def self.included(base)
base.around do |example|
@@ -19,7 +19,7 @@ module JavaScriptFixturesHelpers
#
def clean_frontend_fixtures(directory_name)
directory_name = File.expand_path(directory_name, FIXTURE_PATH)
- Dir[File.expand_path('*.html.raw', directory_name)].each do |file_name|
+ Dir[File.expand_path("*.html.raw", directory_name)].each do |file_name|
FileUtils.rm(file_name)
end
end
@@ -55,7 +55,7 @@ module JavaScriptFixturesHelpers
if response_mime_type.html?
doc = Nokogiri::HTML::DocumentFragment.parse(fixture)
- link_tags = doc.css('link')
+ link_tags = doc.css("link")
link_tags.remove
scripts = doc.css("script:not([type='text/template']):not([type='text/x-template'])")
@@ -64,7 +64,7 @@ module JavaScriptFixturesHelpers
fixture = doc.to_html
# replace relative links
- test_host = ActionDispatch::TestRequest::DEFAULT_ENV['HTTP_HOST']
+ test_host = ActionDispatch::TestRequest::DEFAULT_ENV["HTTP_HOST"]
fixture.gsub!(%r{="/}, "=\"http://#{test_host}/")
end
diff --git a/spec/support/helpers/jira_service_helper.rb b/spec/support/helpers/jira_service_helper.rb
index f4d5343c4ed..b025bc91360 100644
--- a/spec/support/helpers/jira_service_helper.rb
+++ b/spec/support/helpers/jira_service_helper.rb
@@ -6,10 +6,10 @@ module JiraServiceHelper
properties = {
title: "JIRA tracker",
url: JIRA_URL,
- username: 'jira-user',
- password: 'my-secret-password',
+ username: "jira-user",
+ password: "my-secret-password",
project_key: "JIRA",
- jira_issue_transition_id: '1'
+ jira_issue_transition_id: "1",
}
jira_tracker.update(properties: properties, active: true)
diff --git a/spec/support/helpers/key_generator_helper.rb b/spec/support/helpers/key_generator_helper.rb
index d55d8312c65..d675484a087 100644
--- a/spec/support/helpers/key_generator_helper.rb
+++ b/spec/support/helpers/key_generator_helper.rb
@@ -3,7 +3,7 @@ module Spec
module Helpers
class KeyGeneratorHelper
# The components in a openssh .pub / known_host RSA public key.
- RSA_COMPONENTS = ['ssh-rsa', :e, :n].freeze
+ RSA_COMPONENTS = ["ssh-rsa", :e, :n].freeze
attr_reader :size
@@ -13,12 +13,12 @@ module Spec
def generate
key = OpenSSL::PKey::RSA.generate(size)
- components = RSA_COMPONENTS.map do |component|
+ components = RSA_COMPONENTS.map { |component|
key.respond_to?(component) ? encode_mpi(key.public_send(component)) : component
- end
+ }
# Ruby tries to be helpful and adds new lines every 60 bytes :(
- 'ssh-rsa ' + [pack_pubkey_components(components)].pack('m').delete("\n")
+ "ssh-rsa " + [pack_pubkey_components(components)].pack("m").delete("\n")
end
private
@@ -28,12 +28,12 @@ module Spec
chars, n = [], n.to_i
chars << (n & 0xff) && n >>= 8 while n != 0
chars << 0 if chars.empty? || chars.last >= 0x80
- chars.reverse.pack('C*')
+ chars.reverse.pack("C*")
end
# Packs string components into an openssh-encoded pubkey.
def pack_pubkey_components(strings)
- (strings.map { |s| [s.length].pack('N') }).zip(strings).flatten.join
+ (strings.map { |s| [s.length].pack("N") }).zip(strings).flatten.join
end
end
end
diff --git a/spec/support/helpers/kubernetes_helpers.rb b/spec/support/helpers/kubernetes_helpers.rb
index 9dc89b483b2..05d7cae18e4 100644
--- a/spec/support/helpers/kubernetes_helpers.rb
+++ b/spec/support/helpers/kubernetes_helpers.rb
@@ -2,7 +2,7 @@ module KubernetesHelpers
include Gitlab::Kubernetes
def kube_response(body)
- { body: body.to_json }
+ {body: body.to_json}
end
def kube_pods_response
@@ -14,10 +14,10 @@ module KubernetesHelpers
end
def stub_kubeclient_discover(api_url)
- WebMock.stub_request(:get, api_url + '/api/v1').to_return(kube_response(kube_v1_discovery_body))
- WebMock.stub_request(:get, api_url + '/apis/extensions/v1beta1').to_return(kube_response(kube_v1beta1_discovery_body))
- WebMock.stub_request(:get, api_url + '/apis/rbac.authorization.k8s.io/v1').to_return(kube_response(kube_v1_rbac_authorization_discovery_body))
- WebMock.stub_request(:get, api_url + '/apis/serving.knative.dev/v1alpha1').to_return(kube_response(kube_v1alpha1_serving_knative_discovery_body))
+ WebMock.stub_request(:get, api_url + "/api/v1").to_return(kube_response(kube_v1_discovery_body))
+ WebMock.stub_request(:get, api_url + "/apis/extensions/v1beta1").to_return(kube_response(kube_v1beta1_discovery_body))
+ WebMock.stub_request(:get, api_url + "/apis/rbac.authorization.k8s.io/v1").to_return(kube_response(kube_v1_rbac_authorization_discovery_body))
+ WebMock.stub_request(:get, api_url + "/apis/serving.knative.dev/v1alpha1").to_return(kube_response(kube_v1alpha1_serving_knative_discovery_body))
end
def stub_kubeclient_service_pods(response = nil)
@@ -60,42 +60,42 @@ module KubernetesHelpers
.to_return(kube_response(kube_v1_secret_body(options)))
end
- def stub_kubeclient_get_secret_error(api_url, name, namespace: 'default', status: 404)
+ def stub_kubeclient_get_secret_error(api_url, name, namespace: "default", status: 404)
WebMock.stub_request(:get, api_url + "/api/v1/namespaces/#{namespace}/secrets/#{name}")
.to_return(status: [status, "Internal Server Error"])
end
- def stub_kubeclient_get_service_account(api_url, name, namespace: 'default')
+ def stub_kubeclient_get_service_account(api_url, name, namespace: "default")
WebMock.stub_request(:get, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts/#{name}")
.to_return(kube_response({}))
end
- def stub_kubeclient_get_service_account_error(api_url, name, namespace: 'default', status: 404)
+ def stub_kubeclient_get_service_account_error(api_url, name, namespace: "default", status: 404)
WebMock.stub_request(:get, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts/#{name}")
.to_return(status: [status, "Internal Server Error"])
end
- def stub_kubeclient_create_service_account(api_url, namespace: 'default')
+ def stub_kubeclient_create_service_account(api_url, namespace: "default")
WebMock.stub_request(:post, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts")
.to_return(kube_response({}))
end
- def stub_kubeclient_create_service_account_error(api_url, namespace: 'default')
+ def stub_kubeclient_create_service_account_error(api_url, namespace: "default")
WebMock.stub_request(:post, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts")
.to_return(status: [500, "Internal Server Error"])
end
- def stub_kubeclient_put_service_account(api_url, name, namespace: 'default')
+ def stub_kubeclient_put_service_account(api_url, name, namespace: "default")
WebMock.stub_request(:put, api_url + "/api/v1/namespaces/#{namespace}/serviceaccounts/#{name}")
.to_return(kube_response({}))
end
- def stub_kubeclient_create_secret(api_url, namespace: 'default')
+ def stub_kubeclient_create_secret(api_url, namespace: "default")
WebMock.stub_request(:post, api_url + "/api/v1/namespaces/#{namespace}/secrets")
.to_return(kube_response({}))
end
- def stub_kubeclient_put_secret(api_url, name, namespace: 'default')
+ def stub_kubeclient_put_secret(api_url, name, namespace: "default")
WebMock.stub_request(:put, api_url + "/api/v1/namespaces/#{namespace}/secrets/#{name}")
.to_return(kube_response({}))
end
@@ -106,26 +106,26 @@ module KubernetesHelpers
end
def stub_kubeclient_create_cluster_role_binding(api_url)
- WebMock.stub_request(:post, api_url + '/apis/rbac.authorization.k8s.io/v1/clusterrolebindings')
+ WebMock.stub_request(:post, api_url + "/apis/rbac.authorization.k8s.io/v1/clusterrolebindings")
.to_return(kube_response({}))
end
- def stub_kubeclient_get_role_binding(api_url, name, namespace: 'default')
+ def stub_kubeclient_get_role_binding(api_url, name, namespace: "default")
WebMock.stub_request(:get, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings/#{name}")
.to_return(kube_response({}))
end
- def stub_kubeclient_get_role_binding_error(api_url, name, namespace: 'default', status: 404)
+ def stub_kubeclient_get_role_binding_error(api_url, name, namespace: "default", status: 404)
WebMock.stub_request(:get, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings/#{name}")
.to_return(status: [status, "Internal Server Error"])
end
- def stub_kubeclient_create_role_binding(api_url, namespace: 'default')
+ def stub_kubeclient_create_role_binding(api_url, namespace: "default")
WebMock.stub_request(:post, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings")
.to_return(kube_response({}))
end
- def stub_kubeclient_put_role_binding(api_url, name, namespace: 'default')
+ def stub_kubeclient_put_role_binding(api_url, name, namespace: "default")
WebMock.stub_request(:put, api_url + "/apis/rbac.authorization.k8s.io/v1/namespaces/#{namespace}/rolebindings/#{name}")
.to_return(kube_response({}))
end
@@ -135,7 +135,7 @@ module KubernetesHelpers
.to_return(kube_response({}))
end
- def stub_kubeclient_get_namespace(api_url, namespace: 'default')
+ def stub_kubeclient_get_namespace(api_url, namespace: "default")
WebMock.stub_request(:get, api_url + "/api/v1/namespaces/#{namespace}")
.to_return(kube_response({}))
end
@@ -143,14 +143,14 @@ module KubernetesHelpers
def kube_v1_secret_body(**options)
{
"kind" => "SecretList",
- "apiVersion": "v1",
- "metadata": {
+ :apiVersion => "v1",
+ :metadata => {
"name": options[:metadata_name] || "default-token-1",
- "namespace": "kube-system"
+ "namespace": "kube-system",
+ },
+ :data => {
+ "token": options[:token] || Base64.encode64("token-sample-123"),
},
- "data": {
- "token": options[:token] || Base64.encode64('token-sample-123')
- }
}
end
@@ -158,13 +158,13 @@ module KubernetesHelpers
{
"kind" => "APIResourceList",
"resources" => [
- { "name" => "pods", "namespaced" => true, "kind" => "Pod" },
- { "name" => "deployments", "namespaced" => true, "kind" => "Deployment" },
- { "name" => "secrets", "namespaced" => true, "kind" => "Secret" },
- { "name" => "serviceaccounts", "namespaced" => true, "kind" => "ServiceAccount" },
- { "name" => "services", "namespaced" => true, "kind" => "Service" },
- { "name" => "namespaces", "namespaced" => true, "kind" => "Namespace" }
- ]
+ {"name" => "pods", "namespaced" => true, "kind" => "Pod"},
+ {"name" => "deployments", "namespaced" => true, "kind" => "Deployment"},
+ {"name" => "secrets", "namespaced" => true, "kind" => "Secret"},
+ {"name" => "serviceaccounts", "namespaced" => true, "kind" => "ServiceAccount"},
+ {"name" => "services", "namespaced" => true, "kind" => "Service"},
+ {"name" => "namespaces", "namespaced" => true, "kind" => "Namespace"},
+ ],
}
end
@@ -172,12 +172,12 @@ module KubernetesHelpers
{
"kind" => "APIResourceList",
"resources" => [
- { "name" => "pods", "namespaced" => true, "kind" => "Pod" },
- { "name" => "deployments", "namespaced" => true, "kind" => "Deployment" },
- { "name" => "secrets", "namespaced" => true, "kind" => "Secret" },
- { "name" => "serviceaccounts", "namespaced" => true, "kind" => "ServiceAccount" },
- { "name" => "services", "namespaced" => true, "kind" => "Service" }
- ]
+ {"name" => "pods", "namespaced" => true, "kind" => "Pod"},
+ {"name" => "deployments", "namespaced" => true, "kind" => "Deployment"},
+ {"name" => "secrets", "namespaced" => true, "kind" => "Secret"},
+ {"name" => "serviceaccounts", "namespaced" => true, "kind" => "ServiceAccount"},
+ {"name" => "services", "namespaced" => true, "kind" => "Service"},
+ ],
}
end
@@ -185,11 +185,11 @@ module KubernetesHelpers
{
"kind" => "APIResourceList",
"resources" => [
- { "name" => "clusterrolebindings", "namespaced" => false, "kind" => "ClusterRoleBinding" },
- { "name" => "clusterroles", "namespaced" => false, "kind" => "ClusterRole" },
- { "name" => "rolebindings", "namespaced" => true, "kind" => "RoleBinding" },
- { "name" => "roles", "namespaced" => true, "kind" => "Role" }
- ]
+ {"name" => "clusterrolebindings", "namespaced" => false, "kind" => "ClusterRoleBinding"},
+ {"name" => "clusterroles", "namespaced" => false, "kind" => "ClusterRole"},
+ {"name" => "rolebindings", "namespaced" => true, "kind" => "RoleBinding"},
+ {"name" => "roles", "namespaced" => true, "kind" => "Role"},
+ ],
}
end
@@ -197,39 +197,39 @@ module KubernetesHelpers
{
"kind" => "APIResourceList",
"resources" => [
- { "name" => "revisions", "namespaced" => true, "kind" => "Revision" },
- { "name" => "services", "namespaced" => true, "kind" => "Service" },
- { "name" => "configurations", "namespaced" => true, "kind" => "Configuration" },
- { "name" => "routes", "namespaced" => true, "kind" => "Route" }
- ]
+ {"name" => "revisions", "namespaced" => true, "kind" => "Revision"},
+ {"name" => "services", "namespaced" => true, "kind" => "Service"},
+ {"name" => "configurations", "namespaced" => true, "kind" => "Configuration"},
+ {"name" => "routes", "namespaced" => true, "kind" => "Route"},
+ ],
}
end
def kube_pods_body
{
"kind" => "PodList",
- "items" => [kube_pod]
+ "items" => [kube_pod],
}
end
def kube_deployments_body
{
"kind" => "DeploymentList",
- "items" => [kube_deployment]
+ "items" => [kube_deployment],
}
end
def kube_knative_pods_body(name, namespace)
{
"kind" => "PodList",
- "items" => [kube_knative_pod(name: name, namespace: namespace)]
+ "items" => [kube_knative_pod(name: name, namespace: namespace)],
}
end
def kube_knative_services_body(**options)
{
"kind" => "List",
- "items" => [kube_service(options)]
+ "items" => [kube_service(options)],
}
end
@@ -243,16 +243,16 @@ module KubernetesHelpers
"creationTimestamp" => "2016-11-25T19:55:19Z",
"labels" => {
"app" => app,
- "track" => track
- }
+ "track" => track,
+ },
},
"spec" => {
"containers" => [
- { "name" => "container-0" },
- { "name" => "container-1" }
- ]
+ {"name" => "container-0"},
+ {"name" => "container-1"},
+ ],
},
- "status" => { "phase" => status }
+ "status" => {"phase" => status},
}
end
@@ -265,16 +265,16 @@ module KubernetesHelpers
"generate_name" => "generated-name-with-suffix",
"creationTimestamp" => "2016-11-25T19:55:19Z",
"labels" => {
- "serving.knative.dev/service" => name
- }
+ "serving.knative.dev/service" => name,
+ },
},
"spec" => {
"containers" => [
- { "name" => "container-0" },
- { "name" => "container-1" }
- ]
+ {"name" => "container-0"},
+ {"name" => "container-1"},
+ ],
},
- "status" => { "phase" => status }
+ "status" => {"phase" => status},
}
end
@@ -285,16 +285,16 @@ module KubernetesHelpers
"generation" => 4,
"labels" => {
"app" => app,
- "track" => track
- }.compact
+ "track" => track,
+ }.compact,
},
- "spec" => { "replicas" => 3 },
+ "spec" => {"replicas" => 3},
"status" => {
"observedGeneration" => 4,
"replicas" => 3,
"updatedReplicas" => 3,
- "availableReplicas" => 3
- }
+ "availableReplicas" => 3,
+ },
}
end
@@ -304,18 +304,18 @@ module KubernetesHelpers
"creationTimestamp" => "2018-11-21T06:16:33Z",
"name" => name,
"namespace" => namespace,
- "selfLink" => "/apis/serving.knative.dev/v1alpha1/namespaces/#{namespace}/services/#{name}"
+ "selfLink" => "/apis/serving.knative.dev/v1alpha1/namespaces/#{namespace}/services/#{name}",
},
"spec" => {
- "generation" => 2
+ "generation" => 2,
},
"status" => {
"domain" => "#{name}.#{namespace}.#{domain}",
"domainInternal" => "#{name}.#{namespace}.svc.cluster.local",
"latestCreatedRevisionName" => "#{name}-00002",
"latestReadyRevisionName" => "#{name}-00002",
- "observedGeneration" => 2
- }
+ "observedGeneration" => 2,
+ },
}
end
@@ -327,37 +327,37 @@ module KubernetesHelpers
"namespace" => namespace,
"selfLink" => "/apis/serving.knative.dev/v1alpha1/namespaces/#{namespace}/services/#{name}",
"annotation" => {
- "description" => "This is a test description"
- }
+ "description" => "This is a test description",
+ },
},
"spec" => {
"generation" => 2,
"build" => {
- "template" => "go-1.10.3"
- }
+ "template" => "go-1.10.3",
+ },
},
"status" => {
"domain" => "#{name}.#{namespace}.#{domain}",
"domainInternal" => "#{name}.#{namespace}.svc.cluster.local",
"latestCreatedRevisionName" => "#{name}-00002",
"latestReadyRevisionName" => "#{name}-00002",
- "observedGeneration" => 2
- }
+ "observedGeneration" => 2,
+ },
}
end
def kube_terminals(service, pod)
- pod_name = pod['metadata']['name']
- containers = pod['spec']['containers']
+ pod_name = pod["metadata"]["name"]
+ containers = pod["spec"]["containers"]
containers.map do |container|
terminal = {
- selectors: { pod: pod_name, container: container['name'] },
- url: container_exec_url(service.api_url, service.actual_namespace, pod_name, container['name']),
- subprotocols: ['channel.k8s.io'],
- headers: { 'Authorization' => ["Bearer #{service.token}"] },
- created_at: DateTime.parse(pod['metadata']['creationTimestamp']),
- max_session_time: 0
+ selectors: {pod: pod_name, container: container["name"]},
+ url: container_exec_url(service.api_url, service.actual_namespace, pod_name, container["name"]),
+ subprotocols: ["channel.k8s.io"],
+ headers: {"Authorization" => ["Bearer #{service.token}"]},
+ created_at: DateTime.parse(pod["metadata"]["creationTimestamp"]),
+ max_session_time: 0,
}
terminal[:ca_pem] = service.ca_pem if service.ca_pem.present?
terminal
diff --git a/spec/support/helpers/ldap_helpers.rb b/spec/support/helpers/ldap_helpers.rb
index 66ca5d7f0a3..443329d4aaf 100644
--- a/spec/support/helpers/ldap_helpers.rb
+++ b/spec/support/helpers/ldap_helpers.rb
@@ -1,5 +1,5 @@
module LdapHelpers
- def ldap_adapter(provider = 'ldapmain', ldap = double(:ldap))
+ def ldap_adapter(provider = "ldapmain", ldap = double(:ldap))
::Gitlab::Auth::LDAP::Adapter.new(provider, ldap)
end
@@ -30,14 +30,14 @@ module LdapHelpers
# ldap_user_entry = ldap_user_entry('john_doe')
#
# stub_ldap_person_find_by_uid('john_doe', ldap_user_entry, adapter)
- def stub_ldap_person_find_by_uid(uid, entry, provider = 'ldapmain')
+ def stub_ldap_person_find_by_uid(uid, entry, provider = "ldapmain")
return_value = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
allow(::Gitlab::Auth::LDAP::Person)
.to receive(:find_by_uid).with(uid, any_args).and_return(return_value)
end
- def stub_ldap_person_find_by_dn(entry, provider = 'ldapmain')
+ def stub_ldap_person_find_by_dn(entry, provider = "ldapmain")
person = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
allow(::Gitlab::Auth::LDAP::Person)
@@ -45,7 +45,7 @@ module LdapHelpers
.and_return(person)
end
- def stub_ldap_person_find_by_email(email, entry, provider = 'ldapmain')
+ def stub_ldap_person_find_by_email(email, entry, provider = "ldapmain")
person = ::Gitlab::Auth::LDAP::Person.new(entry, provider) if entry.present?
allow(::Gitlab::Auth::LDAP::Person)
@@ -57,8 +57,8 @@ module LdapHelpers
# Create a simple LDAP user entry.
def ldap_user_entry(uid)
entry = Net::LDAP::Entry.new
- entry['dn'] = user_dn(uid)
- entry['uid'] = uid
+ entry["dn"] = user_dn(uid)
+ entry["uid"] = uid
entry
end
diff --git a/spec/support/helpers/live_debugger.rb b/spec/support/helpers/live_debugger.rb
index 911eb48a8ca..659d65f0576 100644
--- a/spec/support/helpers/live_debugger.rb
+++ b/spec/support/helpers/live_debugger.rb
@@ -1,4 +1,4 @@
-require 'io/console'
+require "io/console"
module LiveDebugger
def live_debug
diff --git a/spec/support/helpers/login_helpers.rb b/spec/support/helpers/login_helpers.rb
index 3fee6872498..99af5ff4d8e 100644
--- a/spec/support/helpers/login_helpers.rb
+++ b/spec/support/helpers/login_helpers.rb
@@ -1,4 +1,4 @@
-require_relative 'devise_helpers'
+require_relative "devise_helpers"
module LoginHelpers
include DeviseHelpers
@@ -58,7 +58,7 @@ module LoginHelpers
click_link "Sign out"
@current_user = nil
- expect(page).to have_button('Sign in')
+ expect(page).to have_button("Sign in")
end
private
@@ -72,7 +72,7 @@ module LoginHelpers
fill_in "user_login", with: user.email
fill_in "user_password", with: "12345678"
- check 'user_remember_me' if remember
+ check "user_remember_me" if remember
click_button "Sign in"
end
@@ -80,9 +80,9 @@ module LoginHelpers
def login_via(provider, user, uid, remember_me: false)
mock_auth_hash(provider, uid, user.email)
visit new_user_session_path
- expect(page).to have_content('Sign in with')
+ expect(page).to have_content("Sign in with")
- check 'remember_me' if remember_me
+ check "remember_me" if remember_me
click_link "oauth-login-#{provider}"
end
@@ -94,51 +94,51 @@ module LoginHelpers
provider: provider,
uid: uid,
info: {
- name: 'mockuser',
+ name: "mockuser",
email: email,
- image: 'mock_user_thumbnail_url'
+ image: "mock_user_thumbnail_url",
},
credentials: {
- token: 'mock_token',
- secret: 'mock_secret'
+ token: "mock_token",
+ secret: "mock_secret",
},
extra: {
raw_info: {
info: {
- name: 'mockuser',
+ name: "mockuser",
email: email,
- image: 'mock_user_thumbnail_url'
- }
+ image: "mock_user_thumbnail_url",
+ },
},
response_object: {
- document: saml_xml(saml_response)
- }
- }
+ document: saml_xml(saml_response),
+ },
+ },
})
- Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider.to_sym]
+ Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider.to_sym]
end
def saml_xml(raw_saml_response)
- return '' if raw_saml_response.blank?
+ return "" if raw_saml_response.blank?
XMLSecurity::SignedDocument.new(raw_saml_response, [])
end
def mock_saml_config
- OpenStruct.new(name: 'saml', label: 'saml', args: {
- assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback',
- idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52',
- idp_sso_target_url: 'https://idp.example.com/sso/saml',
- issuer: 'https://localhost:3443/',
- name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient'
+ OpenStruct.new(name: "saml", label: "saml", args: {
+ assertion_consumer_service_url: "https://localhost:3443/users/auth/saml/callback",
+ idp_cert_fingerprint: "26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52",
+ idp_sso_target_url: "https://idp.example.com/sso/saml",
+ issuer: "https://localhost:3443/",
+ name_identifier_format: "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
})
end
def mock_saml_config_with_upstream_two_factor_authn_contexts
config = mock_saml_config
- config.args[:upstream_two_factor_authn_contexts] = %w(urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport
+ config.args[:upstream_two_factor_authn_contexts] = %w[urn:oasis:names:tc:SAML:2.0:ac:classes:CertificateProtectedTransport
urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorOTPSMS
- urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN)
+ urn:oasis:names:tc:SAML:2.0:ac:classes:SecondFactorIGTOKEN]
config
end
@@ -146,15 +146,15 @@ module LoginHelpers
env = env_from_context(context)
set_devise_mapping(context: context)
- env['omniauth.auth'] = OmniAuth.config.mock_auth[provider.to_sym]
+ env["omniauth.auth"] = OmniAuth.config.mock_auth[provider.to_sym]
end
def stub_omniauth_failure(strategy, message_key, exception = nil)
env = @request.env
- env['omniauth.error'] = exception
- env['omniauth.error.type'] = message_key.to_sym
- env['omniauth.error.strategy'] = strategy
+ env["omniauth.error"] = exception
+ env["omniauth.error.type"] = message_key.to_sym
+ env["omniauth.error.strategy"] = strategy
end
def stub_omniauth_saml_config(messages, context: Rails.application)
@@ -163,7 +163,7 @@ module LoginHelpers
routes.disable_clear_and_finalize = true
routes.formatter.clear
routes.draw do
- post '/users/auth/saml' => 'omniauth_callbacks#saml'
+ post "/users/auth/saml" => "omniauth_callbacks#saml"
end
saml_config = messages.key?(:providers) ? messages[:providers].first : mock_saml_config
allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config)
@@ -174,11 +174,11 @@ module LoginHelpers
def stub_saml_authorize_path_helpers
allow_any_instance_of(ActionDispatch::Routing::RoutesProxy)
.to receive(:user_saml_omniauth_authorize_path)
- .and_return('/users/auth/saml')
+ .and_return("/users/auth/saml")
allow(Devise::OmniAuth::UrlHelpers)
.to receive(:omniauth_authorize_path)
.with(:user, "saml")
- .and_return('/users/auth/saml')
+ .and_return("/users/auth/saml")
end
def stub_omniauth_config(messages)
@@ -186,10 +186,10 @@ module LoginHelpers
end
def stub_basic_saml_config
- allow(Gitlab::Auth::Saml::Config).to receive_messages({ options: { name: 'saml', args: {} } })
+ allow(Gitlab::Auth::Saml::Config).to receive_messages({options: {name: "saml", args: {}}})
end
def stub_saml_group_config(groups)
- allow(Gitlab::Auth::Saml::Config).to receive_messages({ options: { name: 'saml', groups_attribute: 'groups', external_groups: groups, args: {} } })
+ allow(Gitlab::Auth::Saml::Config).to receive_messages({options: {name: "saml", groups_attribute: "groups", external_groups: groups, args: {}}})
end
end
diff --git a/spec/support/helpers/markdown_feature.rb b/spec/support/helpers/markdown_feature.rb
index 96401379cf0..35e92ca41cb 100644
--- a/spec/support/helpers/markdown_feature.rb
+++ b/spec/support/helpers/markdown_feature.rb
@@ -12,7 +12,7 @@ class MarkdownFeature
attr_reader :fixture_path
- def initialize(fixture_path = Rails.root.join('spec/fixtures/markdown.md.erb'))
+ def initialize(fixture_path = Rails.root.join("spec/fixtures/markdown.md.erb"))
@fixture_path = fixture_path
end
@@ -60,29 +60,29 @@ class MarkdownFeature
def commit_range
@commit_range ||= begin
- commit2 = project.commit('HEAD~3')
+ commit2 = project.commit("HEAD~3")
CommitRange.new("#{commit.id}...#{commit2.id}", project)
end
end
def simple_label
- @simple_label ||= create(:label, name: 'gfm', project: project)
+ @simple_label ||= create(:label, name: "gfm", project: project)
end
def label
- @label ||= create(:label, name: 'awaiting feedback', project: project)
+ @label ||= create(:label, name: "awaiting feedback", project: project)
end
def simple_milestone
- @simple_milestone ||= create(:milestone, name: 'gfm-milestone', project: project)
+ @simple_milestone ||= create(:milestone, name: "gfm-milestone", project: project)
end
def milestone
- @milestone ||= create(:milestone, name: 'next goal', project: project)
+ @milestone ||= create(:milestone, name: "next goal", project: project)
end
def group_milestone
- @group_milestone ||= create(:milestone, name: 'group-milestone', group: group)
+ @group_milestone ||= create(:milestone, name: "group-milestone", group: group)
end
# Cross-references -----------------------------------------------------------
@@ -114,7 +114,7 @@ class MarkdownFeature
def xcommit_range
@xcommit_range ||= begin
- xcommit2 = xproject.commit('HEAD~2')
+ xcommit2 = xproject.commit("HEAD~2")
CommitRange.new("#{xcommit.id}...#{xcommit2.id}", xproject)
end
end
diff --git a/spec/support/helpers/merge_request_diff_helpers.rb b/spec/support/helpers/merge_request_diff_helpers.rb
index 3b49d0b3319..2c810067aae 100644
--- a/spec/support/helpers/merge_request_diff_helpers.rb
+++ b/spec/support/helpers/merge_request_diff_helpers.rb
@@ -2,7 +2,7 @@ module MergeRequestDiffHelpers
def click_diff_line(line_holder, diff_side = nil)
line = get_line_components(line_holder, diff_side)
line[:content].hover
- line[:num].find('.js-add-diff-note-button', visible: false).send_keys(:return)
+ line[:num].find(".js-add-diff-note-button", visible: false).send_keys(:return)
end
def get_line_components(line_holder, diff_side = nil)
@@ -14,15 +14,15 @@ module MergeRequestDiffHelpers
end
def get_inline_line_components(line_holder)
- { content: line_holder.find('.line_content', match: :first), num: line_holder.find('.diff-line-num', match: :first) }
+ {content: line_holder.find(".line_content", match: :first), num: line_holder.find(".diff-line-num", match: :first)}
end
def get_parallel_line_components(line_holder, diff_side = nil)
- side_index = diff_side == 'left' ? 0 : 1
+ side_index = diff_side == "left" ? 0 : 1
# Wait for `.line_content`
- line_holder.find('.line_content', match: :first)
+ line_holder.find(".line_content", match: :first)
# Wait for `.diff-line-num`
- line_holder.find('.diff-line-num', match: :first)
- { content: line_holder.all('.line_content')[side_index], num: line_holder.all('.diff-line-num')[side_index] }
+ line_holder.find(".diff-line-num", match: :first)
+ {content: line_holder.all(".line_content")[side_index], num: line_holder.all(".diff-line-num")[side_index]}
end
end
diff --git a/spec/support/helpers/merge_request_helpers.rb b/spec/support/helpers/merge_request_helpers.rb
index 772adff4626..be3c202b75d 100644
--- a/spec/support/helpers/merge_request_helpers.rb
+++ b/spec/support/helpers/merge_request_helpers.rb
@@ -4,19 +4,19 @@ module MergeRequestHelpers
end
def first_merge_request
- page.all('ul.mr-list > li').first.text
+ page.all("ul.mr-list > li").first.text
end
def last_merge_request
- page.all('ul.mr-list > li').last.text
+ page.all("ul.mr-list > li").last.text
end
def expect_mr_list_count(open_count, closed_count = 0)
all_count = open_count + closed_count
expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count)
- page.within '.mr-list' do
- expect(page).to have_selector('.merge-request', count: open_count)
+ page.within ".mr-list" do
+ expect(page).to have_selector(".merge-request", count: open_count)
end
end
end
diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb
index cc1a28cb264..9a30a0ab635 100644
--- a/spec/support/helpers/migrations_helpers.rb
+++ b/spec/support/helpers/migrations_helpers.rb
@@ -75,7 +75,7 @@ module MigrationsHelpers
.to receive(:active?)
.and_return(false)
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
end
def previous_migration
@@ -97,7 +97,7 @@ module MigrationsHelpers
def schema_migrate_down!
disable_migrations_output do
ActiveRecord::Migrator.migrate(migrations_paths,
- migration_schema_version)
+ migration_schema_version)
end
reset_column_in_all_models
diff --git a/spec/support/helpers/note_interaction_helpers.rb b/spec/support/helpers/note_interaction_helpers.rb
index 79a0aa174b1..b1f4f8d943f 100644
--- a/spec/support/helpers/note_interaction_helpers.rb
+++ b/spec/support/helpers/note_interaction_helpers.rb
@@ -2,7 +2,7 @@ module NoteInteractionHelpers
def open_more_actions_dropdown(note)
note_element = find("#note_#{note.id}")
- note_element.find('.more-actions-toggle').click
- note_element.find('.more-actions .dropdown-menu li', match: :first)
+ note_element.find(".more-actions-toggle").click
+ note_element.find(".more-actions .dropdown-menu li", match: :first)
end
end
diff --git a/spec/support/helpers/notification_helpers.rb b/spec/support/helpers/notification_helpers.rb
index 8d84510fb73..200a1759521 100644
--- a/spec/support/helpers/notification_helpers.rb
+++ b/spec/support/helpers/notification_helpers.rb
@@ -2,7 +2,7 @@ module NotificationHelpers
extend self
def send_notifications(*new_mentions)
- mentionable.description = new_mentions.map(&:to_reference).join(' ')
+ mentionable.description = new_mentions.map(&:to_reference).join(" ")
notification.send(notification_method, mentionable, new_mentions, @u_disabled)
end
diff --git a/spec/support/helpers/project_forks_helper.rb b/spec/support/helpers/project_forks_helper.rb
index 9a86560da2a..c27898c3eb5 100644
--- a/spec/support/helpers/project_forks_helper.rb
+++ b/spec/support/helpers/project_forks_helper.rb
@@ -20,7 +20,7 @@ module ProjectForksHelper
# Avoid creating a repository
unless create_repository
allow(RepositoryForkWorker).to receive(:perform_async).and_return(true)
- shell = double('gitlab_shell', fork_repository: true)
+ shell = double("gitlab_shell", fork_repository: true)
allow(service).to receive(:gitlab_shell).and_return(shell)
end
@@ -46,8 +46,8 @@ module ProjectForksHelper
def fork_project_with_submodules(project, user = nil, params = {})
forked_project = fork_project(project, user, params)
TestEnv.copy_repo(forked_project,
- bare_repo: TestEnv.forked_repo_path_bare,
- refs: TestEnv::FORKED_BRANCH_SHA)
+ bare_repo: TestEnv.forked_repo_path_bare,
+ refs: TestEnv::FORKED_BRANCH_SHA)
forked_project.repository.after_import
forked_project
end
diff --git a/spec/support/helpers/prometheus_helpers.rb b/spec/support/helpers/prometheus_helpers.rb
index ce1f9fce10d..0b68c3f4887 100644
--- a/spec/support/helpers/prometheus_helpers.rb
+++ b/spec/support/helpers/prometheus_helpers.rb
@@ -8,19 +8,19 @@ module PrometheusHelpers
end
def prometheus_ping_url(prometheus_query)
- query = { query: prometheus_query }.to_query
+ query = {query: prometheus_query}.to_query
"https://prometheus.example.com/api/v1/query?#{query}"
end
def prometheus_query_url(prometheus_query)
- query = { query: prometheus_query }.to_query
+ query = {query: prometheus_query}.to_query
"https://prometheus.example.com/api/v1/query?#{query}"
end
def prometheus_query_with_time_url(prometheus_query, time)
- query = { query: prometheus_query, time: time.to_f }.to_query
+ query = {query: prometheus_query, time: time.to_f}.to_query
"https://prometheus.example.com/api/v1/query?#{query}"
end
@@ -30,7 +30,7 @@ module PrometheusHelpers
query: prometheus_query,
start: start.to_f,
end: stop,
- step: 1.minute.to_i
+ step: 1.minute.to_i,
}.to_query
"https://prometheus.example.com/api/v1/query_range?#{query}"
@@ -44,7 +44,7 @@ module PrometheusHelpers
query = {
match: matches,
start: start.to_f,
- end: stop.to_f
+ end: stop.to_f,
}.to_query
"https://prometheus.example.com/api/v1/series?#{query}"
end
@@ -53,8 +53,8 @@ module PrometheusHelpers
WebMock.stub_request(:get, url)
.to_return({
status: status,
- headers: { 'Content-Type' => 'application/json' }.merge(headers),
- body: body.to_json
+ headers: {"Content-Type" => "application/json"}.merge(headers),
+ body: body.to_json,
})
end
@@ -99,12 +99,12 @@ module PrometheusHelpers
{
success: true,
data: {
- memory_values: prometheus_values_body('matrix').dig(:data, :result),
- memory_current: prometheus_value_body('vector').dig(:data, :result),
- cpu_values: prometheus_values_body('matrix').dig(:data, :result),
- cpu_current: prometheus_value_body('vector').dig(:data, :result)
+ memory_values: prometheus_values_body("matrix").dig(:data, :result),
+ memory_current: prometheus_value_body("vector").dig(:data, :result),
+ cpu_values: prometheus_values_body("matrix").dig(:data, :result),
+ cpu_current: prometheus_value_body("vector").dig(:data, :result),
},
- last_update: last_update
+ last_update: last_update,
}
end
@@ -112,12 +112,12 @@ module PrometheusHelpers
{
success: true,
metrics: {
- memory_values: prometheus_values_body('matrix').dig(:data, :result),
- memory_current: prometheus_value_body('vector').dig(:data, :result),
- cpu_values: prometheus_values_body('matrix').dig(:data, :result),
- cpu_current: prometheus_value_body('vector').dig(:data, :result)
+ memory_values: prometheus_values_body("matrix").dig(:data, :result),
+ memory_current: prometheus_value_body("vector").dig(:data, :result),
+ cpu_values: prometheus_values_body("matrix").dig(:data, :result),
+ cpu_current: prometheus_value_body("vector").dig(:data, :result),
},
- last_update: last_update
+ last_update: last_update,
}
end
@@ -126,12 +126,12 @@ module PrometheusHelpers
"status": "success",
"data": {
"resultType": type,
- "result": []
- }
+ "result": [],
+ },
}
end
- def prometheus_value_body(type = 'vector')
+ def prometheus_value_body(type = "vector")
{
"status": "success",
"data": {
@@ -141,15 +141,15 @@ module PrometheusHelpers
"metric": {},
"value": [
1488772511.004,
- "0.000041021495238095323"
- ]
- }
- ]
- }
+ "0.000041021495238095323",
+ ],
+ },
+ ],
+ },
}
end
- def prometheus_values_body(type = 'matrix')
+ def prometheus_values_body(type = "matrix")
{
"status": "success",
"data": {
@@ -159,44 +159,44 @@ module PrometheusHelpers
"metric": {},
"values": [
[1488758662.506, "0.00002996364761904785"],
- [1488758722.506, "0.00003090239047619091"]
- ]
- }
- ]
- }
+ [1488758722.506, "0.00003090239047619091"],
+ ],
+ },
+ ],
+ },
}
end
def prometheus_label_values
{
- 'status': 'success',
- 'data': %w(job_adds job_controller_rate_limiter_use job_depth job_queue_latency job_work_duration_sum up)
+ 'status': "success",
+ 'data': %w[job_adds job_controller_rate_limiter_use job_depth job_queue_latency job_work_duration_sum up],
}
end
def prometheus_series(name)
{
- 'status': 'success',
+ 'status': "success",
'data': [
{
'__name__': name,
- 'container_name': 'gitlab',
- 'environment': 'mattermost',
- 'id': '/docker/9953982f95cf5010dfc59d7864564d5f188aaecddeda343699783009f89db667',
- 'image': 'gitlab/gitlab-ce:8.15.4-ce.1',
- 'instance': 'minikube',
- 'job': 'kubernetes-nodes',
- 'name': 'k8s_gitlab.e6611886_mattermost-4210310111-77z8r_gitlab_2298ae6b-da24-11e6-baee-8e7f67d0eb3a_43536cb6',
- 'namespace': 'gitlab',
- 'pod_name': 'mattermost-4210310111-77z8r'
+ 'container_name': "gitlab",
+ 'environment': "mattermost",
+ 'id': "/docker/9953982f95cf5010dfc59d7864564d5f188aaecddeda343699783009f89db667",
+ 'image': "gitlab/gitlab-ce:8.15.4-ce.1",
+ 'instance': "minikube",
+ 'job': "kubernetes-nodes",
+ 'name': "k8s_gitlab.e6611886_mattermost-4210310111-77z8r_gitlab_2298ae6b-da24-11e6-baee-8e7f67d0eb3a_43536cb6",
+ 'namespace': "gitlab",
+ 'pod_name': "mattermost-4210310111-77z8r",
},
{
'__name__': name,
- 'id': '/docker',
- 'instance': 'minikube',
- 'job': 'kubernetes-nodes'
- }
- ]
+ 'id': "/docker",
+ 'instance': "minikube",
+ 'job': "kubernetes-nodes",
+ },
+ ],
}
end
end
diff --git a/spec/support/helpers/query_recorder.rb b/spec/support/helpers/query_recorder.rb
index 7ce63375d34..5772c081866 100644
--- a/spec/support/helpers/query_recorder.rb
+++ b/spec/support/helpers/query_recorder.rb
@@ -6,7 +6,7 @@ module ActiveRecord
@log = []
@cached = []
@skip_cached = skip_cached
- ActiveSupport::Notifications.subscribed(method(:callback), 'sql.active_record', &block)
+ ActiveSupport::Notifications.subscribed(method(:callback), "sql.active_record", &block)
end
def show_backtrace(values)
@@ -15,7 +15,7 @@ module ActiveRecord
end
def callback(name, start, finish, message_id, values)
- show_backtrace(values) if ENV['QUERY_RECORDER_DEBUG']
+ show_backtrace(values) if ENV["QUERY_RECORDER_DEBUG"]
if values[:name]&.include?("CACHE") && skip_cached
@cached << values[:sql]
diff --git a/spec/support/helpers/quick_actions_helpers.rb b/spec/support/helpers/quick_actions_helpers.rb
index 361190aa352..6c3a6343d9a 100644
--- a/spec/support/helpers/quick_actions_helpers.rb
+++ b/spec/support/helpers/quick_actions_helpers.rb
@@ -1,9 +1,9 @@
module QuickActionsHelpers
def write_note(text)
Sidekiq::Testing.fake! do
- page.within('.js-main-target-form') do
- fill_in 'note[note]', with: text
- find('.js-comment-submit-button').click
+ page.within(".js-main-target-form") do
+ fill_in "note[note]", with: text
+ find(".js-comment-submit-button").click
end
end
end
diff --git a/spec/support/helpers/rake_helpers.rb b/spec/support/helpers/rake_helpers.rb
index 7d8d7750bf3..ddcd1143960 100644
--- a/spec/support/helpers/rake_helpers.rb
+++ b/spec/support/helpers/rake_helpers.rb
@@ -1,7 +1,7 @@
module RakeHelpers
def run_rake_task(task_name, *args)
Rake::Task[task_name].reenable
- Rake.application.invoke_task("#{task_name}[#{args.join(',')}]")
+ Rake.application.invoke_task("#{task_name}[#{args.join(",")}]")
end
def stub_warn_user_is_not_gitlab
@@ -18,6 +18,6 @@ module RakeHelpers
end
def main_object
- @main_object ||= TOPLEVEL_BINDING.eval('self')
+ @main_object ||= TOPLEVEL_BINDING.eval("self")
end
end
diff --git a/spec/support/helpers/reactive_caching_helpers.rb b/spec/support/helpers/reactive_caching_helpers.rb
index b76b53db0b9..59e30731473 100644
--- a/spec/support/helpers/reactive_caching_helpers.rb
+++ b/spec/support/helpers/reactive_caching_helpers.rb
@@ -1,10 +1,10 @@
module ReactiveCachingHelpers
def reactive_cache_key(subject, *qualifiers)
- ([subject.class.reactive_cache_key.call(subject)].flatten + qualifiers).join(':')
+ ([subject.class.reactive_cache_key.call(subject)].flatten + qualifiers).join(":")
end
def alive_reactive_cache_key(subject, *qualifiers)
- reactive_cache_key(subject, *(qualifiers + ['alive']))
+ reactive_cache_key(subject, *(qualifiers + ["alive"]))
end
def stub_reactive_cache(subject = nil, data = nil, *qualifiers)
diff --git a/spec/support/helpers/reference_parser_helpers.rb b/spec/support/helpers/reference_parser_helpers.rb
index 9f27502aa52..5598e4f1d2c 100644
--- a/spec/support/helpers/reference_parser_helpers.rb
+++ b/spec/support/helpers/reference_parser_helpers.rb
@@ -1,10 +1,10 @@
module ReferenceParserHelpers
def empty_html_link
- Nokogiri::HTML.fragment('<a></a>').children[0]
+ Nokogiri::HTML.fragment("<a></a>").children[0]
end
- shared_examples 'no project N+1 queries' do
- it 'avoids N+1 queries in #nodes_visible_to_user', :request_store do
+ shared_examples "no project N+1 queries" do
+ it "avoids N+1 queries in #nodes_visible_to_user", :request_store do
context = Banzai::RenderContext.new(project, user)
record_queries = lambda do |links|
@@ -21,10 +21,10 @@ module ReferenceParserHelpers
end
end
- shared_examples 'no N+1 queries' do
- it_behaves_like 'no project N+1 queries'
+ shared_examples "no N+1 queries" do
+ it_behaves_like "no project N+1 queries"
- it 'avoids N+1 queries in #records_for_nodes', :request_store do
+ it "avoids N+1 queries in #records_for_nodes", :request_store do
context = Banzai::RenderContext.new(project, user)
record_queries = lambda do |links|
diff --git a/spec/support/helpers/repo_helpers.rb b/spec/support/helpers/repo_helpers.rb
index 3c6956cf5e0..e586982bf2f 100644
--- a/spec/support/helpers/repo_helpers.rb
+++ b/spec/support/helpers/repo_helpers.rb
@@ -13,52 +13,52 @@ module RepoHelpers
#
def sample_blob
OpenStruct.new(
- oid: '5f53439ca4b009096571d3c8bc3d09d30e7431b3',
+ oid: "5f53439ca4b009096571d3c8bc3d09d30e7431b3",
path: "files/js/commit.js.coffee",
- data: <<eos
-class Commit
- constructor: ->
- $('.files .diff-file').each ->
- new CommitFile(this)
+ data: <<~eos
+ class Commit
+ constructor: ->
+ $('.files .diff-file').each ->
+ new CommitFile(this)
-@Commit = Commit
-eos
+ @Commit = Commit
+ eos
)
end
def sample_commit
OpenStruct.new(
id: "570e7b2abdd848b95f2f578043fc23bd6f6fd24d",
- parent_id: '6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9',
+ parent_id: "6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9",
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
files_changed_count: 2,
- line_code: '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_14',
- line_code_path: 'files/ruby/popen.rb',
- del_line_code: '2f6fcd96b88b36ce98c38da085c795a27d92a3dd_13_13',
- message: <<eos
-Change some files
-Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-eos
+ line_code: "2f6fcd96b88b36ce98c38da085c795a27d92a3dd_15_14",
+ line_code_path: "files/ruby/popen.rb",
+ del_line_code: "2f6fcd96b88b36ce98c38da085c795a27d92a3dd_13_13",
+ message: <<~eos
+ Change some files
+ Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
+ eos
)
end
def another_sample_commit
OpenStruct.new(
id: "e56497bb5f03a90a51293fc6d516788730953899",
- parent_id: '4cd80ccab63c82b4bad16faa5193fbd2aa06df40',
+ parent_id: "4cd80ccab63c82b4bad16faa5193fbd2aa06df40",
author_full_name: "Sytse Sijbrandij",
author_email: "sytse@gitlab.com",
files_changed_count: 1,
- message: <<eos
-Add directory structure for tree_helper spec
+ message: <<~eos
+ Add directory structure for tree_helper spec
-This directory structure is needed for a testing the method flatten_tree(tree) in the TreeHelper module
+ This directory structure is needed for a testing the method flatten_tree(tree) in the TreeHelper module
-See [merge request #275](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/275#note_732774)
+ See [merge request #275](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/275#note_732774)
-See merge request !2
-eos
+ See merge request !2
+ eos
)
end
@@ -67,10 +67,10 @@ eos
id: "913c66a37b4a45b9769037c55c2d238bd0942d2e",
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
- message: <<eos
-Files, encoding and much more
-Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-eos
+ message: <<~eos
+ Files, encoding and much more
+ Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
+ eos
)
end
@@ -79,38 +79,38 @@ eos
id: "2f63565e7aac07bcdadb654e253078b727143ec4",
author_full_name: "Dmitriy Zaporozhets",
author_email: "dmitriy.zaporozhets@gmail.com",
- old_blob_id: '33f3729a45c02fc67d00adb1b8bca394b0e761d9',
- new_blob_id: '2f63565e7aac07bcdadb654e253078b727143ec4',
- message: <<eos
-Modified image
-Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-eos
+ old_blob_id: "33f3729a45c02fc67d00adb1b8bca394b0e761d9",
+ new_blob_id: "2f63565e7aac07bcdadb654e253078b727143ec4",
+ message: <<~eos
+ Modified image
+ Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
+ eos
)
end
def sample_compare
changes = [
{
- line_code: 'a5cc2925ca8258af241be7e5b0381edf30266302_20_20',
- file_path: '.gitignore'
+ line_code: "a5cc2925ca8258af241be7e5b0381edf30266302_20_20",
+ file_path: ".gitignore",
},
{
- line_code: '7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44_4_6',
- file_path: '.gitmodules'
- }
+ line_code: "7445606fbf8f3683cd42bdc54b05d7a0bc2dfc44_4_6",
+ file_path: ".gitmodules",
+ },
]
- commits = %w(
+ commits = %w[
5937ac0a7beb003549fc5fd26fc247adbce4a52e
570e7b2abdd848b95f2f578043fc23bd6f6fd24d
6f6d7e7ed97bb5f0054f2b1df789b39ca89b6ff9
d14d6c0abdd253381df51a723d58691b2ee1ab08
c1acaa58bbcbc3eafe538cb8274ba387047b69f8
- ).reverse # last commit is recent one
+ ].reverse # last commit is recent one
OpenStruct.new(
- source_branch: 'master',
- target_branch: 'feature',
+ source_branch: "master",
+ target_branch: "feature",
changes: changes,
commits: commits
)
diff --git a/spec/support/helpers/seed_helper.rb b/spec/support/helpers/seed_helper.rb
index 90d7f60fdeb..a06795fe07c 100644
--- a/spec/support/helpers/seed_helper.rb
+++ b/spec/support/helpers/seed_helper.rb
@@ -1,18 +1,18 @@
# frozen_string_literal: true
-require_relative 'test_env'
+require_relative "test_env"
# This file is specific to specs in spec/lib/gitlab/git/
SEED_STORAGE_PATH = TestEnv.repos_path
-TEST_REPO_PATH = 'gitlab-git-test.git'
-TEST_NORMAL_REPO_PATH = 'not-bare-repo.git'
-TEST_MUTABLE_REPO_PATH = 'mutable-repo.git'
-TEST_BROKEN_REPO_PATH = 'broken-repo.git'
-TEST_GITATTRIBUTES_REPO_PATH = 'with-git-attributes.git'
+TEST_REPO_PATH = "gitlab-git-test.git"
+TEST_NORMAL_REPO_PATH = "not-bare-repo.git"
+TEST_MUTABLE_REPO_PATH = "mutable-repo.git"
+TEST_BROKEN_REPO_PATH = "broken-repo.git"
+TEST_GITATTRIBUTES_REPO_PATH = "with-git-attributes.git"
module SeedHelper
- GITLAB_GIT_TEST_REPO_URL = File.expand_path('../gitlab-git-test.git', __dir__)
+ GITLAB_GIT_TEST_REPO_URL = File.expand_path("../gitlab-git-test.git", __dir__)
def ensure_seeds
if File.exist?(SEED_STORAGE_PATH)
@@ -30,85 +30,85 @@ module SeedHelper
end
def create_bare_seeds
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{GITLAB_GIT_TEST_REPO_URL}),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "--bare", GITLAB_GIT_TEST_REPO_URL.to_s,
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
end
def create_normal_seeds
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone #{TEST_REPO_PATH} #{TEST_NORMAL_REPO_PATH}),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", TEST_REPO_PATH.to_s, TEST_NORMAL_REPO_PATH.to_s,
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
end
def create_mutable_seeds
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} #{TEST_MUTABLE_REPO_PATH}),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "--bare", TEST_REPO_PATH.to_s, TEST_MUTABLE_REPO_PATH.to_s,
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
mutable_repo_full_path = File.join(SEED_STORAGE_PATH, TEST_MUTABLE_REPO_PATH)
- system(git_env, *%W(#{Gitlab.config.git.bin_path} branch -t feature origin/feature),
- chdir: mutable_repo_full_path, out: '/dev/null', err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "branch", "-t", "feature", "origin/feature",
+ chdir: mutable_repo_full_path, out: "/dev/null", err: "/dev/null")
- system(git_env, *%W(#{Gitlab.config.git.bin_path} remote add expendable #{GITLAB_GIT_TEST_REPO_URL}),
- chdir: mutable_repo_full_path, out: '/dev/null', err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "remote", "add", "expendable", GITLAB_GIT_TEST_REPO_URL.to_s,
+ chdir: mutable_repo_full_path, out: "/dev/null", err: "/dev/null")
end
def create_broken_seeds
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} #{TEST_BROKEN_REPO_PATH}),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "--bare", TEST_REPO_PATH.to_s, TEST_BROKEN_REPO_PATH.to_s,
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
- refs_path = File.join(SEED_STORAGE_PATH, TEST_BROKEN_REPO_PATH, 'refs')
+ refs_path = File.join(SEED_STORAGE_PATH, TEST_BROKEN_REPO_PATH, "refs")
FileUtils.rm_r(refs_path)
end
def create_git_attributes
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone --bare #{TEST_REPO_PATH} #{TEST_GITATTRIBUTES_REPO_PATH}),
- chdir: SEED_STORAGE_PATH,
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "--bare", TEST_REPO_PATH.to_s, TEST_GITATTRIBUTES_REPO_PATH.to_s,
+ chdir: SEED_STORAGE_PATH,
+ out: "/dev/null",
+ err: "/dev/null")
- dir = File.join(SEED_STORAGE_PATH, 'with-git-attributes.git', 'info')
+ dir = File.join(SEED_STORAGE_PATH, "with-git-attributes.git", "info")
FileUtils.mkdir_p(dir)
- File.open(File.join(dir, 'attributes'), 'w') do |handle|
- handle.write <<-EOF.strip
-# This is a comment, it should be ignored.
-
-*.txt text
-*.jpg -text
-*.sh eol=lf gitlab-language=shell
-*.haml.* gitlab-language=haml
-foo/bar.* foo
-*.cgi key=value?p1=v1&p2=v2
-/*.png gitlab-language=png
-*.binary binary
-/custom-highlighting/*.gitlab-custom gitlab-language=ruby
-/custom-highlighting/*.gitlab-cgi gitlab-language=erb?parent=json
-
-# This uses a tab instead of spaces to ensure the parser also supports this.
-*.md\tgitlab-language=markdown
-bla/bla.txt
+ File.open(File.join(dir, "attributes"), "w") do |handle|
+ handle.write <<~EOF.strip
+ # This is a comment, it should be ignored.
+
+ *.txt text
+ *.jpg -text
+ *.sh eol=lf gitlab-language=shell
+ *.haml.* gitlab-language=haml
+ foo/bar.* foo
+ *.cgi key=value?p1=v1&p2=v2
+ /*.png gitlab-language=png
+ *.binary binary
+ /custom-highlighting/*.gitlab-custom gitlab-language=ruby
+ /custom-highlighting/*.gitlab-cgi gitlab-language=erb?parent=json
+
+ # This uses a tab instead of spaces to ensure the parser also supports this.
+ *.md\tgitlab-language=markdown
+ bla/bla.txt
EOF
end
end
def create_invalid_git_attributes
- dir = File.join(SEED_STORAGE_PATH, 'with-invalid-git-attributes.git', 'info')
+ dir = File.join(SEED_STORAGE_PATH, "with-invalid-git-attributes.git", "info")
FileUtils.mkdir_p(dir)
enc = Encoding::UTF_16
- File.open(File.join(dir, 'attributes'), 'w', encoding: enc) do |handle|
- handle.write('# hello'.encode(enc))
+ File.open(File.join(dir, "attributes"), "w", encoding: enc) do |handle|
+ handle.write("# hello".encode(enc))
end
end
end
diff --git a/spec/support/helpers/seed_repo.rb b/spec/support/helpers/seed_repo.rb
index 71f1a86b0c1..add58658f52 100644
--- a/spec/support/helpers/seed_repo.rb
+++ b/spec/support/helpers/seed_repo.rb
@@ -45,7 +45,7 @@ module SeedRepo
FILES_COUNT = 2
C_FILE_PATH = "files/ruby".freeze
C_FILES = ["popen.rb", "regex.rb", "version_info.rb"].freeze
- BLOB_FILE = %{%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n}.freeze
+ BLOB_FILE = %(%h3= @key.title\n%hr\n%pre= @key.key\n.actions\n = link_to 'Remove', @key, :confirm => 'Are you sure?', :method => :delete, :class => \"btn danger delete-key\"\n\n\n).freeze
BLOB_FILE_PATH = "app/views/keys/show.html.haml".freeze
end
@@ -111,44 +111,44 @@ module SeedRepo
module RubyBlob
ID = "7e3e39ebb9b2bf433b4ad17313770fbe4051649c".freeze
NAME = "popen.rb".freeze
- CONTENT = <<-eos.freeze
-require 'fileutils'
-require 'open3'
+ CONTENT = <<~eos.freeze
+ require 'fileutils'
+ require 'open3'
-module Popen
- extend self
+ module Popen
+ extend self
- def popen(cmd, path=nil)
- unless cmd.is_a?(Array)
- raise RuntimeError, "System commands must be given as an array of strings"
- end
+ def popen(cmd, path=nil)
+ unless cmd.is_a?(Array)
+ raise RuntimeError, "System commands must be given as an array of strings"
+ end
- path ||= Dir.pwd
+ path ||= Dir.pwd
- vars = {
- "PWD" => path
- }
+ vars = {
+ "PWD" => path
+ }
- options = {
- chdir: path
- }
+ options = {
+ chdir: path
+ }
- unless File.directory?(path)
- FileUtils.mkdir_p(path)
- end
+ unless File.directory?(path)
+ FileUtils.mkdir_p(path)
+ end
- @cmd_output = ""
- @cmd_status = 0
+ @cmd_output = ""
+ @cmd_status = 0
- Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
- @cmd_output << stdout.read
- @cmd_output << stderr.read
- @cmd_status = wait_thr.value.exitstatus
- end
+ Open3.popen3(vars, *cmd, options) do |stdin, stdout, stderr, wait_thr|
+ @cmd_output << stdout.read
+ @cmd_output << stderr.read
+ @cmd_status = wait_thr.value.exitstatus
+ end
- return @cmd_output, @cmd_status
- end
-end
+ return @cmd_output, @cmd_status
+ end
+ end
eos
end
end
diff --git a/spec/support/helpers/select2_helper.rb b/spec/support/helpers/select2_helper.rb
index f4f0415985c..49aee851b8d 100644
--- a/spec/support/helpers/select2_helper.rb
+++ b/spec/support/helpers/select2_helper.rb
@@ -1,4 +1,4 @@
-require_relative 'wait_for_requests'
+require_relative "wait_for_requests"
# Select2 ajax programmatic helper
# It allows you to select value from select2
@@ -16,7 +16,7 @@ module Select2Helper
include WaitForRequests
def select2(value, options = {})
- raise ArgumentError, 'options must be a Hash' unless options.is_a?(Hash)
+ raise ArgumentError, "options must be a Hash" unless options.is_a?(Hash)
wait_for_requests unless options[:async]
diff --git a/spec/support/helpers/sorting_helper.rb b/spec/support/helpers/sorting_helper.rb
index e505a6b7258..1a98328bcb6 100644
--- a/spec/support/helpers/sorting_helper.rb
+++ b/spec/support/helpers/sorting_helper.rb
@@ -10,8 +10,8 @@
#
module SortingHelper
def sorting_by(value)
- find('.filter-dropdown-container button.dropdown-menu-toggle').click
- page.within('.content ul.dropdown-menu.dropdown-menu-right li') do
+ find(".filter-dropdown-container button.dropdown-menu-toggle").click
+ page.within(".content ul.dropdown-menu.dropdown-menu-right li") do
click_link value
end
end
diff --git a/spec/support/helpers/stub_configuration.rb b/spec/support/helpers/stub_configuration.rb
index ff21bbe28ca..40e3bcfcbd6 100644
--- a/spec/support/helpers/stub_configuration.rb
+++ b/spec/support/helpers/stub_configuration.rb
@@ -1,8 +1,8 @@
-require 'active_support/core_ext/hash/transform_values'
-require 'active_support/hash_with_indifferent_access'
-require 'active_support/dependencies'
+require "active_support/core_ext/hash/transform_values"
+require "active_support/hash_with_indifferent_access"
+require "active_support/dependencies"
-require_dependency 'gitlab'
+require_dependency "gitlab"
module StubConfiguration
def stub_application_setting(messages)
@@ -20,7 +20,8 @@ module StubConfiguration
def stub_not_protect_default_branch
stub_application_setting(
- default_branch_protection: Gitlab::Access::PROTECTION_NONE)
+ default_branch_protection: Gitlab::Access::PROTECTION_NONE
+ )
end
def stub_config_setting(messages)
@@ -28,7 +29,7 @@ module StubConfiguration
end
def stub_default_url_options(host: "localhost", protocol: "http")
- url_options = { host: host, protocol: protocol }
+ url_options = {host: host, protocol: protocol}
allow(Rails.application.routes).to receive(:default_url_options).and_return(url_options)
end
@@ -68,10 +69,10 @@ module StubConfiguration
messages.deep_stringify_keys!
# Default storage is always required
- messages['default'] ||= Gitlab.config.repositories.storages.default
+ messages["default"] ||= Gitlab.config.repositories.storages.default
messages.each do |storage_name, storage_hash|
- if !storage_hash.key?('path') || storage_hash['path'] == Gitlab::GitalyClient::StorageSettings::Deprecated
- storage_hash['path'] = TestEnv.repos_path
+ if !storage_hash.key?("path") || storage_hash["path"] == Gitlab::GitalyClient::StorageSettings::Deprecated
+ storage_hash["path"] = TestEnv.repos_path
end
messages[storage_name] = Gitlab::GitalyClient::StorageSettings.new(storage_hash.to_h)
@@ -97,10 +98,10 @@ module StubConfiguration
# # => {signup_enabled? false}
def add_predicates(messages)
# Only modify keys that aren't already predicates
- keys = messages.keys.map(&:to_s).reject { |k| k.end_with?('?') }
+ keys = messages.keys.map(&:to_s).reject { |k| k.end_with?("?") }
keys.each do |key|
- predicate = key + '?'
+ predicate = key + "?"
messages[predicate.to_sym] = messages[key.to_sym]
end
end
diff --git a/spec/support/helpers/stub_env.rb b/spec/support/helpers/stub_env.rb
index 1c2f474a015..2f58eb35a1e 100644
--- a/spec/support/helpers/stub_env.rb
+++ b/spec/support/helpers/stub_env.rb
@@ -12,7 +12,7 @@ module StubENV
private
- STUBBED_KEY = '__STUBBED__'.freeze
+ STUBBED_KEY = "__STUBBED__".freeze
def add_stubbed_value(key, value)
allow(ENV).to receive(:[]).with(key).and_return(value)
diff --git a/spec/support/helpers/stub_gitlab_calls.rb b/spec/support/helpers/stub_gitlab_calls.rb
index 4cb3b18df85..b01e4c178fc 100644
--- a/spec/support/helpers/stub_gitlab_calls.rb
+++ b/spec/support/helpers/stub_gitlab_calls.rb
@@ -20,7 +20,7 @@ module StubGitlabCalls
allow_any_instance_of(Ci::Pipeline).to receive(:ci_yaml_file) { ci_yaml }
end
- def stub_repository_ci_yaml_file(sha:, path: '.gitlab-ci.yml')
+ def stub_repository_ci_yaml_file(sha:, path: ".gitlab-ci.yml")
allow_any_instance_of(Repository)
.to receive(:gitlab_ci_yml_for).with(sha, path)
.and_return(gitlab_ci_yaml)
@@ -33,7 +33,7 @@ module StubGitlabCalls
def stub_container_registry_config(registry_settings)
allow(Gitlab.config.registry).to receive_messages(registry_settings)
allow(Auth::ContainerRegistryAuthenticationService)
- .to receive(:full_access_token).and_return('token')
+ .to receive(:full_access_token).and_return("token")
end
def stub_container_registry_tags(repository: :any, tags: [], with_manifest: false)
@@ -41,15 +41,15 @@ module StubGitlabCalls
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_tags).with(repository)
- .and_return({ 'tags' => tags })
+ .and_return({"tags" => tags})
if with_manifest
tags.each do |tag|
allow_any_instance_of(ContainerRegistry::Client)
.to receive(:repository_tag_digest)
.with(repository, tag)
- .and_return('sha256:4c8e63ca4cb663ce6c688cb06f1c3' \
- '72b088dac5b6d7ad7d49cd620d85cf72a15')
+ .and_return("sha256:4c8e63ca4cb663ce6c688cb06f1c3" \
+ "72b088dac5b6d7ad7d49cd620d85cf72a15")
end
allow_any_instance_of(ContainerRegistry::Client)
@@ -57,7 +57,7 @@ module StubGitlabCalls
.and_return(stub_container_registry_tag_manifest_content)
allow_any_instance_of(ContainerRegistry::Client)
- .to receive(:blob).with(repository, anything, 'application/octet-stream')
+ .to receive(:blob).with(repository, anything, "application/octet-stream")
.and_return(stub_container_registry_blob_content)
end
end
@@ -71,13 +71,13 @@ module StubGitlabCalls
private
def stub_container_registry_tag_manifest_content
- fixture_path = 'spec/fixtures/container_registry/tag_manifest.json'
+ fixture_path = "spec/fixtures/container_registry/tag_manifest.json"
JSON.parse(File.read(Rails.root + fixture_path))
end
def stub_container_registry_blob_content
- fixture_path = 'spec/fixtures/container_registry/config_blob.json'
+ fixture_path = "spec/fixtures/container_registry/config_blob.json"
File.read(Rails.root + fixture_path)
end
@@ -87,49 +87,49 @@ module StubGitlabCalls
end
def stub_user
- f = File.read(Rails.root.join('spec/support/gitlab_stubs/user.json'))
+ f = File.read(Rails.root.join("spec/support/gitlab_stubs/user.json"))
stub_request(:get, "#{gitlab_url}api/v4/user?private_token=Wvjy2Krpb7y8xi93owUz")
- .with(headers: { 'Content-Type' => 'application/json' })
- .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' })
+ .with(headers: {"Content-Type" => "application/json"})
+ .to_return(status: 200, body: f, headers: {"Content-Type" => "application/json"})
stub_request(:get, "#{gitlab_url}api/v4/user?access_token=some_token")
- .with(headers: { 'Content-Type' => 'application/json' })
- .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' })
+ .with(headers: {"Content-Type" => "application/json"})
+ .to_return(status: 200, body: f, headers: {"Content-Type" => "application/json"})
end
def stub_project_8
- data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8.json'))
+ data = File.read(Rails.root.join("spec/support/gitlab_stubs/project_8.json"))
allow_any_instance_of(Network).to receive(:project).and_return(JSON.parse(data))
end
def stub_project_8_hooks
- data = File.read(Rails.root.join('spec/support/gitlab_stubs/project_8_hooks.json'))
+ data = File.read(Rails.root.join("spec/support/gitlab_stubs/project_8_hooks.json"))
allow_any_instance_of(Network).to receive(:project_hooks).and_return(JSON.parse(data))
end
def stub_projects
- f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json'))
+ f = File.read(Rails.root.join("spec/support/gitlab_stubs/projects.json"))
stub_request(:get, "#{gitlab_url}api/v4/projects.json?archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz")
- .with(headers: { 'Content-Type' => 'application/json' })
- .to_return(status: 200, body: f, headers: { 'Content-Type' => 'application/json' })
+ .with(headers: {"Content-Type" => "application/json"})
+ .to_return(status: 200, body: f, headers: {"Content-Type" => "application/json"})
end
def stub_projects_owned
stub_request(:get, "#{gitlab_url}api/v4/projects?owned=true&archived=false&ci_enabled_first=true&private_token=Wvjy2Krpb7y8xi93owUz")
- .with(headers: { 'Content-Type' => 'application/json' })
+ .with(headers: {"Content-Type" => "application/json"})
.to_return(status: 200, body: "", headers: {})
end
def stub_ci_enable
stub_request(:put, "#{gitlab_url}api/v4/projects/2/services/gitlab-ci.json?private_token=Wvjy2Krpb7y8xi93owUz")
- .with(headers: { 'Content-Type' => 'application/json' })
+ .with(headers: {"Content-Type" => "application/json"})
.to_return(status: 200, body: "", headers: {})
end
def project_hash_array
- f = File.read(Rails.root.join('spec/support/gitlab_stubs/projects.json'))
+ f = File.read(Rails.root.join("spec/support/gitlab_stubs/projects.json"))
JSON.parse f
end
end
diff --git a/spec/support/helpers/stub_gitlab_data.rb b/spec/support/helpers/stub_gitlab_data.rb
index fa402f35b95..ca1beecdbe9 100644
--- a/spec/support/helpers/stub_gitlab_data.rb
+++ b/spec/support/helpers/stub_gitlab_data.rb
@@ -1,5 +1,5 @@
module StubGitlabData
def gitlab_ci_yaml
- File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml'))
+ File.read(Rails.root.join("spec/support/gitlab_stubs/gitlab_ci.yml"))
end
end
diff --git a/spec/support/helpers/stub_object_storage.rb b/spec/support/helpers/stub_object_storage.rb
index e0c50e533a6..9928ed0f77b 100644
--- a/spec/support/helpers/stub_object_storage.rb
+++ b/spec/support/helpers/stub_object_storage.rb
@@ -1,12 +1,12 @@
module StubObjectStorage
def stub_object_storage_uploader(
- config:,
- uploader:,
- remote_directory:,
- enabled: true,
- proxy_download: false,
- background_upload: false,
- direct_upload: false
+ config:,
+ uploader:,
+ remote_directory:,
+ enabled: true,
+ proxy_download: false,
+ background_upload: false,
+ direct_upload: false
)
allow(config).to receive(:enabled) { enabled }
allow(config).to receive(:proxy_download) { proxy_download }
@@ -23,43 +23,41 @@ module StubObjectStorage
Fog.mock!
::Fog::Storage.new(connection_params).tap do |connection|
- begin
- connection.directories.create(key: remote_directory)
+ connection.directories.create(key: remote_directory)
- # Cleanup remaining files
- connection.directories.each do |directory|
- directory.files.map(&:destroy)
- end
- rescue Excon::Error::Conflict
+ # Cleanup remaining files
+ connection.directories.each do |directory|
+ directory.files.map(&:destroy)
end
+ rescue Excon::Error::Conflict
end
end
def stub_artifacts_object_storage(**params)
stub_object_storage_uploader(config: Gitlab.config.artifacts.object_store,
uploader: JobArtifactUploader,
- remote_directory: 'artifacts',
+ remote_directory: "artifacts",
**params)
end
def stub_external_diffs_object_storage(uploader = described_class, **params)
stub_object_storage_uploader(config: Gitlab.config.external_diffs.object_store,
uploader: uploader,
- remote_directory: 'external_diffs',
+ remote_directory: "external_diffs",
**params)
end
def stub_lfs_object_storage(**params)
stub_object_storage_uploader(config: Gitlab.config.lfs.object_store,
uploader: LfsObjectUploader,
- remote_directory: 'lfs-objects',
+ remote_directory: "lfs-objects",
**params)
end
def stub_uploads_object_storage(uploader = described_class, **params)
stub_object_storage_uploader(config: Gitlab.config.uploads.object_store,
uploader: uploader,
- remote_directory: 'uploads',
+ remote_directory: "uploads",
**params)
end
diff --git a/spec/support/helpers/terms_helper.rb b/spec/support/helpers/terms_helper.rb
index a00ec14138b..d5eb3238a82 100644
--- a/spec/support/helpers/terms_helper.rb
+++ b/spec/support/helpers/terms_helper.rb
@@ -1,9 +1,9 @@
module TermsHelper
def enforce_terms
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
settings = Gitlab::CurrentSettings.current_application_settings
ApplicationSettings::UpdateService.new(
- settings, nil, terms: 'These are the terms', enforce_terms: true
+ settings, nil, terms: "These are the terms", enforce_terms: true
).execute
end
@@ -14,6 +14,6 @@ module TermsHelper
def expect_to_be_on_terms_page
expect(current_path).to eq terms_path
- expect(page).to have_content('Please accept the Terms of Service before continuing.')
+ expect(page).to have_content("Please accept the Terms of Service before continuing.")
end
end
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index 80a22134021..39cc2141ca6 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -1,5 +1,5 @@
-require 'rspec/mocks'
-require 'toml-rb'
+require "rspec/mocks"
+require "toml-rb"
module TestEnv
extend self
@@ -8,77 +8,77 @@ module TestEnv
# When developing the seed repository, comment out the branch you will modify.
BRANCH_SHA = {
- 'signed-commits' => '6101e87',
- 'not-merged-branch' => 'b83d6e3',
- 'branch-merged' => '498214d',
- 'empty-branch' => '7efb185',
- 'ends-with.json' => '98b0d8b',
- 'flatten-dir' => 'e56497b',
- 'feature' => '0b4bc9a',
- 'feature_conflict' => 'bb5206f',
- 'fix' => '48f0be4',
- 'improve/awesome' => '5937ac0',
- 'merged-target' => '21751bf',
- 'markdown' => '0ed8c6c',
- 'lfs' => '55bc176',
- 'master' => 'b83d6e3',
- 'merge-test' => '5937ac0',
- "'test'" => 'e56497b',
- 'orphaned-branch' => '45127a9',
- 'binary-encoding' => '7b1cf43',
- 'gitattributes' => '5a62481',
- 'expand-collapse-diffs' => '4842455',
- 'symlink-expand-diff' => '81e6355',
- 'expand-collapse-files' => '025db92',
- 'expand-collapse-lines' => '238e82d',
- 'pages-deploy' => '7897d5b',
- 'pages-deploy-target' => '7975be0',
- 'video' => '8879059',
- 'add-balsamiq-file' => 'b89b56d',
- 'crlf-diff' => '5938907',
- 'conflict-start' => '824be60',
- 'conflict-resolvable' => '1450cd6',
- 'conflict-binary-file' => '259a6fb',
- 'conflict-contains-conflict-markers' => '78a3086',
- 'conflict-missing-side' => 'eb227b3',
- 'conflict-non-utf8' => 'd0a293c',
- 'conflict-too-large' => '39fa04f',
- 'deleted-image-test' => '6c17798',
- 'wip' => 'b9238ee',
- 'csv' => '3dd0896',
- 'v1.1.0' => 'b83d6e3',
- 'add-ipython-files' => '93ee732',
- 'add-pdf-file' => 'e774ebd',
- 'squash-large-files' => '54cec52',
- 'add-pdf-text-binary' => '79faa7b',
- 'add_images_and_changes' => '010d106',
- 'update-gitlab-shell-v-6-0-1' => '2f61d70',
- 'update-gitlab-shell-v-6-0-3' => 'de78448',
- 'merge-commit-analyze-before' => '1adbdef',
- 'merge-commit-analyze-side-branch' => '8a99451',
- 'merge-commit-analyze-after' => '646ece5',
- '2-mb-file' => 'bf12d25',
- 'before-create-delete-modify-move' => '845009f',
- 'between-create-delete-modify-move' => '3f5f443',
- 'after-create-delete-modify-move' => 'ba3faa7',
- 'with-codeowners' => '219560e',
- 'submodule_inside_folder' => 'b491b92',
- 'png-lfs' => 'fe42f41',
- 'sha-starting-with-large-number' => '8426165'
+ "signed-commits" => "6101e87",
+ "not-merged-branch" => "b83d6e3",
+ "branch-merged" => "498214d",
+ "empty-branch" => "7efb185",
+ "ends-with.json" => "98b0d8b",
+ "flatten-dir" => "e56497b",
+ "feature" => "0b4bc9a",
+ "feature_conflict" => "bb5206f",
+ "fix" => "48f0be4",
+ "improve/awesome" => "5937ac0",
+ "merged-target" => "21751bf",
+ "markdown" => "0ed8c6c",
+ "lfs" => "55bc176",
+ "master" => "b83d6e3",
+ "merge-test" => "5937ac0",
+ "'test'" => "e56497b",
+ "orphaned-branch" => "45127a9",
+ "binary-encoding" => "7b1cf43",
+ "gitattributes" => "5a62481",
+ "expand-collapse-diffs" => "4842455",
+ "symlink-expand-diff" => "81e6355",
+ "expand-collapse-files" => "025db92",
+ "expand-collapse-lines" => "238e82d",
+ "pages-deploy" => "7897d5b",
+ "pages-deploy-target" => "7975be0",
+ "video" => "8879059",
+ "add-balsamiq-file" => "b89b56d",
+ "crlf-diff" => "5938907",
+ "conflict-start" => "824be60",
+ "conflict-resolvable" => "1450cd6",
+ "conflict-binary-file" => "259a6fb",
+ "conflict-contains-conflict-markers" => "78a3086",
+ "conflict-missing-side" => "eb227b3",
+ "conflict-non-utf8" => "d0a293c",
+ "conflict-too-large" => "39fa04f",
+ "deleted-image-test" => "6c17798",
+ "wip" => "b9238ee",
+ "csv" => "3dd0896",
+ "v1.1.0" => "b83d6e3",
+ "add-ipython-files" => "93ee732",
+ "add-pdf-file" => "e774ebd",
+ "squash-large-files" => "54cec52",
+ "add-pdf-text-binary" => "79faa7b",
+ "add_images_and_changes" => "010d106",
+ "update-gitlab-shell-v-6-0-1" => "2f61d70",
+ "update-gitlab-shell-v-6-0-3" => "de78448",
+ "merge-commit-analyze-before" => "1adbdef",
+ "merge-commit-analyze-side-branch" => "8a99451",
+ "merge-commit-analyze-after" => "646ece5",
+ "2-mb-file" => "bf12d25",
+ "before-create-delete-modify-move" => "845009f",
+ "between-create-delete-modify-move" => "3f5f443",
+ "after-create-delete-modify-move" => "ba3faa7",
+ "with-codeowners" => "219560e",
+ "submodule_inside_folder" => "b491b92",
+ "png-lfs" => "fe42f41",
+ "sha-starting-with-large-number" => "8426165",
}.freeze
# gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily
# need to keep all the branches in sync.
# We currently only need a subset of the branches
FORKED_BRANCH_SHA = {
- 'add-submodule-version-bump' => '3f547c0',
- 'master' => '5937ac0',
- 'remove-submodule' => '2a33e0c',
- 'conflict-resolvable-fork' => '404fa3f'
+ "add-submodule-version-bump" => "3f547c0",
+ "master" => "5937ac0",
+ "remove-submodule" => "2a33e0c",
+ "conflict-resolvable-fork" => "404fa3f",
}.freeze
- TMP_TEST_PATH = Rails.root.join('tmp', 'tests', '**')
- REPOS_STORAGE = 'default'.freeze
+ TMP_TEST_PATH = Rails.root.join("tmp", "tests", "**")
+ REPOS_STORAGE = "default".freeze
# Test environment
#
@@ -122,7 +122,7 @@ module TestEnv
# Keeps gitlab-shell and gitlab-test
def clean_test_path
Dir[TMP_TEST_PATH].each do |entry|
- unless File.basename(entry) =~ /\A(gitaly|gitlab-(shell|test|test_bare|test-fork|test-fork_bare))\z/
+ unless /\A(gitaly|gitlab-(shell|test|test_bare|test-fork|test-fork_bare))\z/.match?(File.basename(entry))
FileUtils.rm_rf(entry)
end
end
@@ -135,17 +135,17 @@ module TestEnv
def clean_gitlab_test_path
Dir[TMP_TEST_PATH].each do |entry|
- if File.basename(entry) =~ /\A(gitlab-(test|test_bare|test-fork|test-fork_bare))\z/
+ if /\A(gitlab-(test|test_bare|test-fork|test-fork_bare))\z/.match?(File.basename(entry))
FileUtils.rm_rf(entry)
end
end
end
def setup_gitlab_shell
- component_timed_setup('GitLab Shell',
+ component_timed_setup("GitLab Shell",
install_dir: Gitlab.config.gitlab_shell.path,
version: Gitlab::Shell.version_required,
- task: 'gitlab:shell:install')
+ task: "gitlab:shell:install")
# gitlab-shell hooks don't work in our test environment because they try to make internal API calls
sabotage_gitlab_shell_hooks
@@ -157,39 +157,39 @@ module TestEnv
def create_fake_git_hooks(hooks_dir)
%w[pre-receive post-receive update].each do |hook|
- File.open(File.join(hooks_dir, hook), 'w', 0755) { |f| f.puts '#!/bin/sh' }
+ File.open(File.join(hooks_dir, hook), "w", 0o755) { |f| f.puts "#!/bin/sh" }
end
end
def setup_gitaly
- socket_path = Gitlab::GitalyClient.address('default').sub(/\Aunix:/, '')
+ socket_path = Gitlab::GitalyClient.address("default").sub(/\Aunix:/, "")
gitaly_dir = File.dirname(socket_path)
- install_gitaly_args = [gitaly_dir, repos_path, gitaly_url].compact.join(',')
+ install_gitaly_args = [gitaly_dir, repos_path, gitaly_url].compact.join(",")
- component_timed_setup('Gitaly',
+ component_timed_setup("Gitaly",
install_dir: gitaly_dir,
version: Gitlab::GitalyClient.expected_server_version,
task: "gitlab:gitaly:install[#{install_gitaly_args}]") do
- Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, { 'default' => repos_path }, force: true)
- create_fake_git_hooks(File.join(gitaly_dir, 'ruby/git-hooks'))
+ Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, {"default" => repos_path}, force: true)
+ create_fake_git_hooks(File.join(gitaly_dir, "ruby/git-hooks"))
start_gitaly(gitaly_dir)
end
end
def start_gitaly(gitaly_dir)
- if ENV['CI'].present?
+ if ENV["CI"].present?
# Gitaly has been spawned outside this process already
return
end
FileUtils.mkdir_p("tmp/tests/second_storage") unless File.exist?("tmp/tests/second_storage")
- spawn_script = Rails.root.join('scripts/gitaly-test-spawn').to_s
+ spawn_script = Rails.root.join("scripts/gitaly-test-spawn").to_s
Bundler.with_original_env do
raise "gitaly spawn failed" unless system(spawn_script)
end
- @gitaly_pid = Integer(File.read('tmp/tests/gitaly.pid'))
+ @gitaly_pid = Integer(File.read("tmp/tests/gitaly.pid"))
Kernel.at_exit { stop_gitaly }
@@ -199,15 +199,13 @@ module TestEnv
def wait_gitaly
sleep_time = 10
sleep_interval = 0.1
- socket = Gitlab::GitalyClient.address('default').sub('unix:', '')
+ socket = Gitlab::GitalyClient.address("default").sub("unix:", "")
Integer(sleep_time / sleep_interval).times do
- begin
- Socket.unix(socket)
- return
- rescue
- sleep sleep_interval
- end
+ Socket.unix(socket)
+ return
+ rescue
+ sleep sleep_interval
end
raise "could not connect to gitaly at #{socket.inspect} after #{sleep_time} seconds"
@@ -216,39 +214,39 @@ module TestEnv
def stop_gitaly
return unless @gitaly_pid
- Process.kill('KILL', @gitaly_pid)
+ Process.kill("KILL", @gitaly_pid)
rescue Errno::ESRCH
# The process can already be gone if the test run was INTerrupted.
end
def gitaly_url
- ENV.fetch('GITALY_REPO_URL', nil)
+ ENV.fetch("GITALY_REPO_URL", nil)
end
def setup_factory_repo
setup_repo(factory_repo_path, factory_repo_path_bare, factory_repo_name,
- BRANCH_SHA)
+ BRANCH_SHA)
end
# This repo has a submodule commit that is not present in the main test
# repository.
def setup_forked_repo
setup_repo(forked_repo_path, forked_repo_path_bare, forked_repo_name,
- FORKED_BRANCH_SHA)
+ FORKED_BRANCH_SHA)
end
def setup_repo(repo_path, repo_path_bare, repo_name, refs)
clone_url = "https://gitlab.com/gitlab-org/#{repo_name}.git"
unless File.directory?(repo_path)
- system(*%W(#{Gitlab.config.git.bin_path} clone -q #{clone_url} #{repo_path}))
+ system(Gitlab.config.git.bin_path.to_s, "clone", "-q", clone_url.to_s, repo_path.to_s)
end
set_repo_refs(repo_path, refs)
unless File.directory?(repo_path_bare)
# We must copy bare repositories because we will push to them.
- system(git_env, *%W(#{Gitlab.config.git.bin_path} clone -q --bare #{repo_path} #{repo_path_bare}))
+ system(git_env, Gitlab.config.git.bin_path.to_s, "clone", "-q", "--bare", repo_path.to_s, repo_path_bare.to_s)
end
end
@@ -257,16 +255,16 @@ module TestEnv
FileUtils.mkdir_p(target_repo_path)
FileUtils.cp_r("#{File.expand_path(bare_repo)}/.", target_repo_path)
- FileUtils.chmod_R 0755, target_repo_path
+ FileUtils.chmod_R 0o755, target_repo_path
set_repo_refs(target_repo_path, refs)
end
def create_bare_repository(path)
FileUtils.mkdir_p(path)
- system(git_env, *%W(#{Gitlab.config.git.bin_path} -C #{path} init --bare),
- out: '/dev/null',
- err: '/dev/null')
+ system(git_env, Gitlab.config.git.bin_path.to_s, "-C", path.to_s, "init", "--bare",
+ out: "/dev/null",
+ err: "/dev/null")
end
def repos_path
@@ -293,7 +291,7 @@ module TestEnv
return unless defined?(Capybara)
puts "Starting the Capybara driver server..."
- Capybara.current_session.visit '/'
+ Capybara.current_session.visit "/"
end
def factory_repo_path_bare
@@ -305,7 +303,7 @@ module TestEnv
end
def with_empty_bare_repository(name = nil)
- path = Rails.root.join('tmp/tests', name || 'empty-bare-repository').to_s
+ path = Rails.root.join("tmp/tests", name || "empty-bare-repository").to_s
yield(Rugged::Repository.init_at(path, :bare))
ensure
@@ -315,30 +313,30 @@ module TestEnv
private
def factory_repo_path
- @factory_repo_path ||= Rails.root.join('tmp', 'tests', factory_repo_name)
+ @factory_repo_path ||= Rails.root.join("tmp", "tests", factory_repo_name)
end
def factory_repo_name
- 'gitlab-test'
+ "gitlab-test"
end
def forked_repo_path
- @forked_repo_path ||= Rails.root.join('tmp', 'tests', forked_repo_name)
+ @forked_repo_path ||= Rails.root.join("tmp", "tests", forked_repo_name)
end
def forked_repo_name
- 'gitlab-test-fork'
+ "gitlab-test-fork"
end
# Prevent developer git configurations from being persisted to test
# repositories
def git_env
- { 'GIT_TEMPLATE_DIR' => '' }
+ {"GIT_TEMPLATE_DIR" => ""}
end
def set_repo_refs(repo_path, branch_sha)
instructions = branch_sha.map { |branch, sha| "update refs/heads/#{branch}\x00#{sha}\x00" }.join("\x00") << "\x00"
- update_refs = %W(#{Gitlab.config.git.bin_path} update-ref --stdin -z)
+ update_refs = %W[#{Gitlab.config.git.bin_path} update-ref --stdin -z]
reset = proc do
Dir.chdir(repo_path) do
IO.popen(update_refs, "w") { |io| io.write(instructions) }
@@ -348,7 +346,7 @@ module TestEnv
# Try to reset without fetching to avoid using the network.
unless reset.call
- raise 'Could not fetch test seed repository.' unless system(*%W(#{Gitlab.config.git.bin_path} -C #{repo_path} fetch origin))
+ raise "Could not fetch test seed repository." unless system(Gitlab.config.git.bin_path.to_s, "-C", repo_path.to_s, "fetch", "origin")
# Before we used Git clone's --mirror option, bare repos could end up
# with missing refs, clearing them and retrying should fix the issue.
@@ -363,19 +361,18 @@ module TestEnv
ensure_component_dir_name_is_correct!(component, install_dir)
# On CI, once installed, components never need update
- return if File.exist?(install_dir) && ENV['CI']
+ return if File.exist?(install_dir) && ENV["CI"]
if component_needs_update?(install_dir, version)
# Cleanup the component entirely to ensure we start fresh
FileUtils.rm_rf(install_dir)
- unless system('rake', task)
+ unless system("rake", task)
raise ComponentFailedToInstallError
end
end
yield if block_given?
-
rescue ComponentFailedToInstallError
puts "\n#{component} failed to install, cleaning up #{install_dir}!\n"
FileUtils.rm_rf(install_dir)
@@ -398,7 +395,7 @@ module TestEnv
# Allow local overrides of the component for tests during development
return false if Rails.env.test? && File.symlink?(component_folder)
- version = File.read(File.join(component_folder, 'VERSION')).strip
+ version = File.read(File.join(component_folder, "VERSION")).strip
# Notice that this will always yield true when using branch versions
# (`=branch_name`), but that actually makes sure the server is always based
diff --git a/spec/support/helpers/test_request_helpers.rb b/spec/support/helpers/test_request_helpers.rb
index 5a84d67bdfc..0424ca5906f 100644
--- a/spec/support/helpers/test_request_helpers.rb
+++ b/spec/support/helpers/test_request_helpers.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
module TestRequestHelpers
- def test_request(remote_ip: '127.0.0.1')
- ActionController::TestRequest.new({ remote_ip: remote_ip }, ActionController::TestSession.new)
+ def test_request(remote_ip: "127.0.0.1")
+ ActionController::TestRequest.new({remote_ip: remote_ip}, ActionController::TestSession.new)
end
end
diff --git a/spec/support/helpers/upload_helpers.rb b/spec/support/helpers/upload_helpers.rb
index 5eead80c935..cc75945e0c6 100644
--- a/spec/support/helpers/upload_helpers.rb
+++ b/spec/support/helpers/upload_helpers.rb
@@ -1,12 +1,12 @@
-require 'fileutils'
+require "fileutils"
module UploadHelpers
extend self
def uploaded_image_temp_path
- basename = 'banana_sample.gif'
- orig_path = File.join(Rails.root, 'spec', 'fixtures', basename)
- tmp_path = File.join(Rails.root, 'tmp', 'tests', basename)
+ basename = "banana_sample.gif"
+ orig_path = File.join(Rails.root, "spec", "fixtures", basename)
+ tmp_path = File.join(Rails.root, "tmp", "tests", basename)
# Because we use 'move_to_store' on all uploaders, we create a new
# tempfile on each call: the file we return here will be renamed in most
# cases.
diff --git a/spec/support/helpers/user_login_helper.rb b/spec/support/helpers/user_login_helper.rb
index 36c002f53af..47c13820db5 100644
--- a/spec/support/helpers/user_login_helper.rb
+++ b/spec/support/helpers/user_login_helper.rb
@@ -17,10 +17,10 @@ module UserLoginHelper
end
def ensure_one_active_tab
- expect(page).to have_selector('ul.new-session-tabs > li > a.active', count: 1)
+ expect(page).to have_selector("ul.new-session-tabs > li > a.active", count: 1)
end
def ensure_one_active_pane
- expect(page).to have_selector('.tab-pane.active', count: 1)
+ expect(page).to have_selector(".tab-pane.active", count: 1)
end
end
diff --git a/spec/support/helpers/wait_for_requests.rb b/spec/support/helpers/wait_for_requests.rb
index c7f878b7371..f39f55f19f7 100644
--- a/spec/support/helpers/wait_for_requests.rb
+++ b/spec/support/helpers/wait_for_requests.rb
@@ -24,14 +24,14 @@ module WaitForRequests
# Wait for client-side AJAX requests
def wait_for_requests
- wait_for('JS requests complete', max_wait_time: 2 * Capybara.default_max_wait_time) do
+ wait_for("JS requests complete", max_wait_time: 2 * Capybara.default_max_wait_time) do
finished_all_js_requests?
end
end
# Wait for active Rack requests and client-side AJAX requests
def wait_for_all_requests
- wait_for('pending requests complete') do
+ wait_for("pending requests complete") do
finished_all_rack_reqiests? &&
finished_all_js_requests?
end
@@ -65,13 +65,13 @@ module WaitForRequests
end
def finished_all_vue_resource_requests?
- Capybara.page.evaluate_script('window.activeVueResources || 0').zero?
+ Capybara.page.evaluate_script("window.activeVueResources || 0").zero?
end
def finished_all_ajax_requests?
return true if Capybara.page.evaluate_script('typeof jQuery === "undefined"')
- Capybara.page.evaluate_script('jQuery.active').zero?
+ Capybara.page.evaluate_script("jQuery.active").zero?
end
def javascript_test?
diff --git a/spec/support/helpers/wiki_helpers.rb b/spec/support/helpers/wiki_helpers.rb
index 8165403cb60..0e19a960abf 100644
--- a/spec/support/helpers/wiki_helpers.rb
+++ b/spec/support/helpers/wiki_helpers.rb
@@ -4,10 +4,10 @@ module WikiHelpers
def upload_file_to_wiki(project, user, file_name)
opts = {
file_name: file_name,
- file_content: File.read(expand_fixture_path(file_name))
- }
+ file_content: File.read(expand_fixture_path(file_name)),
+ }
::Wikis::CreateAttachmentService.new(project, user, opts)
- .execute[:result][:file_path]
+ .execute[:result][:file_path]
end
end
diff --git a/spec/support/helpers/workhorse_helpers.rb b/spec/support/helpers/workhorse_helpers.rb
index ef1f9f68671..d585d0e6337 100644
--- a/spec/support/helpers/workhorse_helpers.rb
+++ b/spec/support/helpers/workhorse_helpers.rb
@@ -4,18 +4,18 @@ module WorkhorseHelpers
def workhorse_send_data
@_workhorse_send_data ||= begin
header = response.headers[Gitlab::Workhorse::SEND_DATA_HEADER]
- split_header = header.split(':')
+ split_header = header.split(":")
type = split_header.shift
- header = split_header.join(':')
+ header = split_header.join(":")
[
type,
- JSON.parse(Base64.urlsafe_decode64(header))
+ JSON.parse(Base64.urlsafe_decode64(header)),
]
end
end
def workhorse_internal_api_request_header
- jwt_token = JWT.encode({ 'iss' => 'gitlab-workhorse' }, Gitlab::Workhorse.secret, 'HS256')
- { 'HTTP_' + Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER.upcase.tr('-', '_') => jwt_token }
+ jwt_token = JWT.encode({"iss" => "gitlab-workhorse"}, Gitlab::Workhorse.secret, "HS256")
+ {"HTTP_" + Gitlab::Workhorse::INTERNAL_API_REQUEST_HEADER.upcase.tr("-", "_") => jwt_token}
end
end
diff --git a/spec/support/http_io/http_io_helpers.rb b/spec/support/http_io/http_io_helpers.rb
index 42144870eb5..7f2b0bf1928 100644
--- a/spec/support/http_io/http_io_helpers.rb
+++ b/spec/support/http_io/http_io_helpers.rb
@@ -15,7 +15,7 @@ module HttpIOHelpers
end
def remote_url_response(file_path, request, response_status)
- range = request.headers['Range'].match(/bytes=(\d+)-(\d+)/)
+ range = request.headers["Range"].match(/bytes=(\d+)-(\d+)/)
body = File.read(file_path).force_encoding(Encoding::BINARY)
size = body.bytesize
@@ -23,14 +23,14 @@ module HttpIOHelpers
{
status: response_status,
headers: remote_url_response_headers(response_status, range[1].to_i, range[2].to_i, size),
- body: body[range[1].to_i..range[2].to_i]
+ body: body[range[1].to_i..range[2].to_i],
}
end
def remote_url_response_headers(response_status, from, to, size)
- { 'Content-Type' => 'text/plain' }.tap do |headers|
+ {"Content-Type" => "text/plain"}.tap do |headers|
if response_status == 206
- headers.merge('Content-Range' => "bytes #{from}-#{to}/#{size}")
+ headers.merge("Content-Range" => "bytes #{from}-#{to}/#{size}")
end
end
end
diff --git a/spec/support/import_export/common_util.rb b/spec/support/import_export/common_util.rb
index 2542a59bb00..ce3b5cbdb97 100644
--- a/spec/support/import_export/common_util.rb
+++ b/spec/support/import_export/common_util.rb
@@ -3,7 +3,7 @@ module ImportExport
def setup_symlink(tmpdir, symlink_name)
allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(tmpdir)
- File.open("#{tmpdir}/test", 'w') { |file| file.write("test") }
+ File.open("#{tmpdir}/test", "w") { |file| file.write("test") }
FileUtils.ln_s("#{tmpdir}/test", "#{tmpdir}/#{symlink_name}")
end
end
diff --git a/spec/support/import_export/configuration_helper.rb b/spec/support/import_export/configuration_helper.rb
index b4164cff922..9b41bf5fe68 100644
--- a/spec/support/import_export/configuration_helper.rb
+++ b/spec/support/import_export/configuration_helper.rb
@@ -14,11 +14,11 @@ module ConfigurationHelper
end
def parsed_attributes(relation_name, attributes)
- excluded_attributes = config_hash['excluded_attributes'][relation_name]
- included_attributes = config_hash['included_attributes'][relation_name]
+ excluded_attributes = config_hash["excluded_attributes"][relation_name]
+ included_attributes = config_hash["included_attributes"][relation_name]
- attributes = attributes - JSON[excluded_attributes.to_json] if excluded_attributes
- attributes = attributes & JSON[included_attributes.to_json] if included_attributes
+ attributes -= JSON[excluded_attributes.to_json] if excluded_attributes
+ attributes &= JSON[included_attributes.to_json] if included_attributes
attributes
end
diff --git a/spec/support/import_export/export_file_helper.rb b/spec/support/import_export/export_file_helper.rb
index ac320934f5a..bc6b219a8f2 100644
--- a/spec/support/import_export/export_file_helper.rb
+++ b/spec/support/import_export/export_file_helper.rb
@@ -1,4 +1,4 @@
-require './spec/support/import_export/configuration_helper'
+require "./spec/support/import_export/configuration_helper"
module ExportFileHelper
include ConfigurationHelper
@@ -20,10 +20,10 @@ module ExportFileHelper
create(:label_link, label: label, target: issue)
ci_pipeline = create(:ci_pipeline,
- project: project,
- sha: merge_request.diff_head_sha,
- ref: merge_request.source_branch,
- statuses: [commit_status])
+ project: project,
+ sha: merge_request.diff_head_sha,
+ ref: merge_request.source_branch,
+ statuses: [commit_status])
create(:ci_build, pipeline: ci_pipeline, project: project)
create(:milestone, project: project)
@@ -31,9 +31,9 @@ module ExportFileHelper
create(:note, noteable: merge_request, project: project)
create(:note, noteable: snippet, project: project)
create(:note_on_commit,
- author: user,
- project: project,
- commit_id: ci_pipeline.sha)
+ author: user,
+ project: project,
+ commit_id: ci_pipeline.sha)
event = create(:event, :created, target: milestone, project: project, author: user, action: 5)
create(:push_event_payload, event: event)
@@ -43,7 +43,7 @@ module ExportFileHelper
key = create(:deploy_key)
key.projects << project
create(:service, project: project)
- create(:project_hook, project: project, token: 'token')
+ create(:project_hook, project: project, token: "token")
create(:protected_branch, project: project)
project
@@ -53,7 +53,7 @@ module ExportFileHelper
def in_directory_with_expanded_export(project)
Dir.mktmpdir do |tmpdir|
export_file = project.export_file.path
- _output, exit_status = Gitlab::Popen.popen(%W{tar -zxf #{export_file} -C #{tmpdir}})
+ _output, exit_status = Gitlab::Popen.popen(%W[tar -zxf #{export_file} -C #{tmpdir}])
yield(exit_status, tmpdir)
end
@@ -91,7 +91,7 @@ module ExportFileHelper
loop do
object_with_parent = deep_find_with_parent(sensitive_word, project_hash)
- return nil unless object_with_parent && object_with_parent.object
+ return nil unless object_with_parent&.object
if is_safe_hash?(object_with_parent.parent, sensitive_word)
# It's in the safe list, remove hash and keep looking
@@ -109,7 +109,7 @@ module ExportFileHelper
return false unless parent && safe_list[sensitive_word.to_sym]
# Extra attributes that appear in a model but not in the exported hash.
- excluded_attributes = ['type']
+ excluded_attributes = ["type"]
safe_list[sensitive_word.to_sym].each do |model|
# Check whether this is a hash attribute inside a model
@@ -133,6 +133,6 @@ module ExportFileHelper
end
def file_permissions(file)
- File.lstat(file).mode & 0777
+ File.lstat(file).mode & 0o777
end
end
diff --git a/spec/support/issuables_requiring_filter_shared_examples.rb b/spec/support/issuables_requiring_filter_shared_examples.rb
index 71bcc82ee58..caf6b61452a 100644
--- a/spec/support/issuables_requiring_filter_shared_examples.rb
+++ b/spec/support/issuables_requiring_filter_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_examples 'issuables requiring filter' do |action|
+shared_examples "issuables requiring filter" do |action|
it "doesn't load any issuables if no filter is set" do
expect_any_instance_of(described_class).not_to receive(:issuables_collection)
@@ -10,6 +10,6 @@ shared_examples 'issuables requiring filter' do |action|
it "loads issuables if at least one filter is set" do
expect_any_instance_of(described_class).to receive(:issuables_collection).and_call_original
- get action, params: { author_id: user.id }
+ get action, params: {author_id: user.id}
end
end
diff --git a/spec/support/json_response.rb b/spec/support/json_response.rb
index 210b0e6d867..d7645191654 100644
--- a/spec/support/json_response.rb
+++ b/spec/support/json_response.rb
@@ -1,5 +1,5 @@
RSpec.configure do |config|
- config.include_context 'JSON response'
- config.include_context 'JSON response', type: :request
- config.include_context 'JSON response', :api
+ config.include_context "JSON response"
+ config.include_context "JSON response", type: :request
+ config.include_context "JSON response", :api
end
diff --git a/spec/support/matchers/access_matchers.rb b/spec/support/matchers/access_matchers.rb
index 3e4ca8b7ab0..13522c42848 100644
--- a/spec/support/matchers/access_matchers.rb
+++ b/spec/support/matchers/access_matchers.rb
@@ -58,7 +58,7 @@ module AccessMatchers
@membership = membership
end
- description { description_for(user, 'allowed') }
+ description { description_for(user, "allowed") }
end
matcher :be_denied_for do |user|
@@ -73,6 +73,6 @@ module AccessMatchers
@membership = membership
end
- description { description_for(user, 'denied') }
+ description { description_for(user, "denied") }
end
end
diff --git a/spec/support/matchers/access_matchers_for_controller.rb b/spec/support/matchers/access_matchers_for_controller.rb
index 429401a5da8..508af948490 100644
--- a/spec/support/matchers/access_matchers_for_controller.rb
+++ b/spec/support/matchers/access_matchers_for_controller.rb
@@ -48,7 +48,7 @@ module AccessMatchersForController
end
def description_for(role, type, expected, result)
- "be #{type} for #{role}. Expected: #{expected.join(',')} Got: #{result}"
+ "be #{type} for #{role}. Expected: #{expected.join(",")} Got: #{result}"
end
def update_owner(objects, user)
@@ -82,7 +82,7 @@ module AccessMatchersForController
@objects = objects
end
- description { description_for(role, 'allowed', EXPECTED_STATUS_CODE_ALLOWED, response.status) }
+ description { description_for(role, "allowed", EXPECTED_STATUS_CODE_ALLOWED, response.status) }
supports_block_expectations
end
@@ -103,7 +103,7 @@ module AccessMatchersForController
@objects = objects
end
- description { description_for(role, 'denied', EXPECTED_STATUS_CODE_DENIED, response.status) }
+ description { description_for(role, "denied", EXPECTED_STATUS_CODE_DENIED, response.status) }
supports_block_expectations
end
end
diff --git a/spec/support/matchers/background_migrations_matchers.rb b/spec/support/matchers/background_migrations_matchers.rb
index f4127efc6ae..82cfa92f16f 100644
--- a/spec/support/matchers/background_migrations_matchers.rb
+++ b/spec/support/matchers/background_migrations_matchers.rb
@@ -1,21 +1,21 @@
RSpec::Matchers.define :be_scheduled_delayed_migration do |delay, *expected|
match do |migration|
BackgroundMigrationWorker.jobs.any? do |job|
- job['args'] == [migration, expected] &&
- job['at'].to_i == (delay.to_i + Time.now.to_i)
+ job["args"] == [migration, expected] &&
+ job["at"].to_i == (delay.to_i + Time.now.to_i)
end
end
failure_message do |migration|
"Migration `#{migration}` with args `#{expected.inspect}` " \
- 'not scheduled in expected time!'
+ "not scheduled in expected time!"
end
end
RSpec::Matchers.define :be_scheduled_migration do |*expected|
match do |migration|
BackgroundMigrationWorker.jobs.any? do |job|
- args = job['args'].size == 1 ? [BackgroundMigrationWorker.jobs[0]['args'][0], []] : job['args']
+ args = job["args"].size == 1 ? [BackgroundMigrationWorker.jobs[0]["args"][0], []] : job["args"]
args == [migration, expected]
end
end
diff --git a/spec/support/matchers/be_a_binary_string.rb b/spec/support/matchers/be_a_binary_string.rb
index f041ae76167..5463136fa92 100644
--- a/spec/support/matchers/be_a_binary_string.rb
+++ b/spec/support/matchers/be_a_binary_string.rb
@@ -1,6 +1,6 @@
RSpec::Matchers.define :be_a_binary_string do |_|
match do |actual|
- actual.is_a?(String) && actual.encoding == Encoding.find('ASCII-8BIT')
+ actual.is_a?(String) && actual.encoding == Encoding.find("ASCII-8BIT")
end
description do
diff --git a/spec/support/matchers/be_url.rb b/spec/support/matchers/be_url.rb
index f8096af1b22..7393f39df58 100644
--- a/spec/support/matchers/be_url.rb
+++ b/spec/support/matchers/be_url.rb
@@ -1,5 +1,7 @@
RSpec::Matchers.define :be_url do |_|
match do |actual|
- URI.parse(actual) rescue false
+ URI.parse(actual)
+ rescue
+ false
end
end
diff --git a/spec/support/matchers/be_utf8.rb b/spec/support/matchers/be_utf8.rb
index ea806352422..582d3b5de36 100644
--- a/spec/support/matchers/be_utf8.rb
+++ b/spec/support/matchers/be_utf8.rb
@@ -1,6 +1,6 @@
RSpec::Matchers.define :be_utf8 do |_|
match do |actual|
- actual.is_a?(String) && actual.encoding == Encoding.find('UTF-8')
+ actual.is_a?(String) && actual.encoding == Encoding.find("UTF-8")
end
description do
diff --git a/spec/support/matchers/disallow_request_matchers.rb b/spec/support/matchers/disallow_request_matchers.rb
index db4d90e4fd0..7ee6f30603f 100644
--- a/spec/support/matchers/disallow_request_matchers.rb
+++ b/spec/support/matchers/disallow_request_matchers.rb
@@ -1,15 +1,15 @@
RSpec::Matchers.define :disallow_request do
match do |middleware|
- alert = middleware.env['rack.session'].to_hash
- .dig('flash', 'flashes', 'alert')
+ alert = middleware.env["rack.session"].to_hash
+ .dig("flash", "flashes", "alert")
- alert&.include?('You cannot perform write operations')
+ alert&.include?("You cannot perform write operations")
end
end
RSpec::Matchers.define :disallow_request_in_json do
match do |response|
json_response = JSON.parse(response.body)
- response.body.include?('You cannot perform write operations') && json_response.key?('message')
+ response.body.include?("You cannot perform write operations") && json_response.key?("message")
end
end
diff --git a/spec/support/matchers/exceed_query_limit.rb b/spec/support/matchers/exceed_query_limit.rb
index cd042401f3a..cb2e71ab020 100644
--- a/spec/support/matchers/exceed_query_limit.rb
+++ b/spec/support/matchers/exceed_query_limit.rb
@@ -23,10 +23,10 @@ module ExceedQueryLimitHelpers
def actual_count
@actual_count ||= if @query
- recorder.log.select { |recorded| recorded =~ @query }.size
- else
- recorder.count
- end
+ recorder.log.select { |recorded| recorded =~ @query }.size
+ else
+ recorder.count
+ end
end
def recorder
@@ -43,7 +43,7 @@ module ExceedQueryLimitHelpers
extra_queries = @recorder.log.reject { |query| counts[query] -= 1 unless counts[query].zero? }
extra_queries_display = count_queries(extra_queries).map { |query, count| "[#{count}] #{query}" }
- (['Extra queries:'] + extra_queries_display).join("\n\n")
+ (["Extra queries:"] + extra_queries_display).join("\n\n")
else
@recorder.log_message
end
@@ -59,7 +59,7 @@ module ExceedQueryLimitHelpers
end
def failure_message
- threshold_message = threshold > 0 ? " (+#{@threshold})" : ''
+ threshold_message = threshold > 0 ? " (+#{@threshold})" : ""
counts = "#{expected_count}#{threshold_message}"
"Expected a maximum of #{counts} queries, got #{actual_count}:\n\n#{log_message}"
end
diff --git a/spec/support/matchers/execute_check.rb b/spec/support/matchers/execute_check.rb
index 7232fad52fb..72982acbdcd 100644
--- a/spec/support/matchers/execute_check.rb
+++ b/spec/support/matchers/execute_check.rb
@@ -14,10 +14,10 @@ RSpec::Matchers.define :execute_check do |expected|
end
failure_message do |actual|
- 'This matcher must be used with SystemCheck' unless actual == SystemCheck
+ "This matcher must be used with SystemCheck" unless actual == SystemCheck
end
failure_message_when_negated do |actual|
- 'This matcher must be used with SystemCheck' unless actual == SystemCheck
+ "This matcher must be used with SystemCheck" unless actual == SystemCheck
end
end
diff --git a/spec/support/matchers/graphql_matchers.rb b/spec/support/matchers/graphql_matchers.rb
index 7894484f590..11d6d83dd87 100644
--- a/spec/support/matchers/graphql_matchers.rb
+++ b/spec/support/matchers/graphql_matchers.rb
@@ -69,7 +69,7 @@ end
RSpec::Matchers.define :expose_permissions_using do |expected|
match do |type|
- permission_field = type.fields['userPermissions']
+ permission_field = type.fields["userPermissions"]
expect(permission_field).not_to be_nil
expect(permission_field.type).to be_non_null
diff --git a/spec/support/matchers/have_issuable_counts.rb b/spec/support/matchers/have_issuable_counts.rb
index 92cf3de5448..b532fb5887a 100644
--- a/spec/support/matchers/have_issuable_counts.rb
+++ b/spec/support/matchers/have_issuable_counts.rb
@@ -1,10 +1,10 @@
RSpec::Matchers.define :have_issuable_counts do |opts|
- expected_counts = opts.map do |state, count|
+ expected_counts = opts.map { |state, count|
"#{state.to_s.humanize} #{count}"
- end
+ }
match do |actual|
- actual.within '.issues-state-filters' do
+ actual.within ".issues-state-filters" do
expected_counts.each do |expected_count|
expect(actual).to have_content(expected_count)
end
diff --git a/spec/support/matchers/markdown_matchers.rb b/spec/support/matchers/markdown_matchers.rb
index ec4ec6f4038..606ef843aae 100644
--- a/spec/support/matchers/markdown_matchers.rb
+++ b/spec/support/matchers/markdown_matchers.rb
@@ -16,8 +16,8 @@ module MarkdownMatchers
link = actual.at_css('a:contains("Relative Link")')
image = actual.at_css('img[alt="Relative Image"]')
- expect(link['href']).to end_with('master/doc/README.md')
- expect(image['data-src']).to end_with('master/app/assets/images/touch-icon-ipad.png')
+ expect(link["href"]).to end_with("master/doc/README.md")
+ expect(image["data-src"]).to end_with("master/app/assets/images/touch-icon-ipad.png")
end
end
@@ -26,11 +26,11 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('gl-emoji', count: 10)
+ expect(actual).to have_selector("gl-emoji", count: 10)
- emoji_element = actual.at_css('gl-emoji')
- expect(emoji_element['data-name'].to_s).not_to be_empty
- expect(emoji_element['data-unicode-version'].to_s).not_to be_empty
+ emoji_element = actual.at_css("gl-emoji")
+ expect(emoji_element["data-name"].to_s).not_to be_empty
+ expect(emoji_element["data-unicode-version"].to_s).not_to be_empty
end
end
@@ -39,9 +39,9 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('h1 a#user-content-gitlab-markdown')
- expect(actual).to have_selector('h2 a#user-content-markdown')
- expect(actual).to have_selector('h3 a#user-content-autolinkfilter')
+ expect(actual).to have_selector("h1 a#user-content-gitlab-markdown")
+ expect(actual).to have_selector("h2 a#user-content-markdown")
+ expect(actual).to have_selector("h3 a#user-content-autolinkfilter")
end
end
@@ -54,14 +54,14 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_autolink('http://about.gitlab.com/')
- expect(actual).to have_autolink('https://google.com/')
- expect(actual).to have_autolink('ftp://ftp.us.debian.org/debian/')
- expect(actual).to have_autolink('smb://foo/bar/baz')
- expect(actual).to have_autolink('irc://irc.freenode.net/git')
- expect(actual).to have_autolink('http://localhost:3000')
+ expect(actual).to have_autolink("http://about.gitlab.com/")
+ expect(actual).to have_autolink("https://google.com/")
+ expect(actual).to have_autolink("ftp://ftp.us.debian.org/debian/")
+ expect(actual).to have_autolink("smb://foo/bar/baz")
+ expect(actual).to have_autolink("irc://irc.freenode.net/git")
+ expect(actual).to have_autolink("http://localhost:3000")
- %w(code a kbd).each do |elem|
+ %w[code a kbd].each do |elem|
expect(body).not_to have_selector("#{elem} a")
end
end
@@ -73,16 +73,16 @@ module MarkdownMatchers
have_css("img[data-src$='#{src}']")
end
- prefix = '/namespace1/gitlabhq/wikis'
+ prefix = "/namespace1/gitlabhq/wikis"
set_default_markdown_messages
match do |actual|
- expect(actual).to have_link('linked-resource', href: "#{prefix}/linked-resource")
- expect(actual).to have_link('link-text', href: "#{prefix}/linked-resource")
- expect(actual).to have_link('http://example.com', href: 'http://example.com')
- expect(actual).to have_link('link-text', href: 'http://example.com/pdfs/gollum.pdf')
+ expect(actual).to have_link("linked-resource", href: "#{prefix}/linked-resource")
+ expect(actual).to have_link("link-text", href: "#{prefix}/linked-resource")
+ expect(actual).to have_link("http://example.com", href: "http://example.com")
+ expect(actual).to have_link("link-text", href: "http://example.com/pdfs/gollum.pdf")
expect(actual).to have_image("#{prefix}/images/example.jpg")
- expect(actual).to have_image('http://example.com/images/example.jpg')
+ expect(actual).to have_image("http://example.com/images/example.jpg")
end
end
@@ -91,7 +91,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-project_member', count: 4)
+ expect(actual).to have_selector("a.gfm.gfm-project_member", count: 4)
end
end
@@ -100,7 +100,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-issue', count: 6)
+ expect(actual).to have_selector("a.gfm.gfm-issue", count: 6)
end
end
@@ -109,8 +109,8 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-merge_request', count: 6)
- expect(actual).to have_selector('em a.gfm-merge_request')
+ expect(actual).to have_selector("a.gfm.gfm-merge_request", count: 6)
+ expect(actual).to have_selector("em a.gfm-merge_request")
end
end
@@ -119,7 +119,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-snippet', count: 5)
+ expect(actual).to have_selector("a.gfm.gfm-snippet", count: 5)
end
end
@@ -128,7 +128,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-commit_range', count: 5)
+ expect(actual).to have_selector("a.gfm.gfm-commit_range", count: 5)
end
end
@@ -137,7 +137,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-commit', count: 5)
+ expect(actual).to have_selector("a.gfm.gfm-commit", count: 5)
end
end
@@ -146,7 +146,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-label', count: 4)
+ expect(actual).to have_selector("a.gfm.gfm-label", count: 4)
end
end
@@ -155,7 +155,7 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('a.gfm.gfm-milestone', count: 8)
+ expect(actual).to have_selector("a.gfm.gfm-milestone", count: 8)
end
end
@@ -164,9 +164,9 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('ul.task-list', count: 2)
- expect(actual).to have_selector('li.task-list-item', count: 7)
- expect(actual).to have_selector('input[checked]', count: 3)
+ expect(actual).to have_selector("ul.task-list", count: 2)
+ expect(actual).to have_selector("li.task-list-item", count: 7)
+ expect(actual).to have_selector("input[checked]", count: 3)
end
end
@@ -175,8 +175,8 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- expect(actual).to have_selector('span.idiff.addition', count: 2)
- expect(actual).to have_selector('span.idiff.deletion', count: 2)
+ expect(actual).to have_selector("span.idiff.addition", count: 2)
+ expect(actual).to have_selector("span.idiff.deletion", count: 2)
end
end
@@ -185,9 +185,9 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- video = actual.at_css('video')
+ video = actual.at_css("video")
- expect(video['src']).to end_with('/assets/videos/gitlab-demo.mp4')
+ expect(video["src"]).to end_with("/assets/videos/gitlab-demo.mp4")
end
end
@@ -196,17 +196,17 @@ module MarkdownMatchers
set_default_markdown_messages
match do |actual|
- color_chips = actual.css('code > span.gfm-color_chip > span')
+ color_chips = actual.css("code > span.gfm-color_chip > span")
expect(color_chips.count).to eq(9)
[
- '#F00', '#F00A', '#FF0000', '#FF0000AA', 'RGB(0,255,0)',
- 'RGB(0%,100%,0%)', 'RGBA(0,255,0,0.7)', 'HSL(540,70%,50%)',
- 'HSLA(540,70%,50%,0.7)'
+ "#F00", "#F00A", "#FF0000", "#FF0000AA", "RGB(0,255,0)",
+ "RGB(0%,100%,0%)", "RGBA(0,255,0,0.7)", "HSL(540,70%,50%)",
+ "HSLA(540,70%,50%,0.7)",
].each_with_index do |color, i|
parsed_color = Banzai::ColorParser.parse(color)
- expect(color_chips[i]['style']).to match("background-color: #{parsed_color};")
+ expect(color_chips[i]["style"]).to match("background-color: #{parsed_color};")
expect(color_chips[i].parent.parent.content).to match(color)
end
end
diff --git a/spec/support/matchers/match_ids.rb b/spec/support/matchers/match_ids.rb
index 1cb6b74acac..b7faad433b1 100644
--- a/spec/support/matchers/match_ids.rb
+++ b/spec/support/matchers/match_ids.rb
@@ -7,7 +7,7 @@ RSpec::Matchers.define :match_ids do |*expected|
end
description do
- 'matches elements by ids'
+ "matches elements by ids"
end
failure_message do
diff --git a/spec/support/matchers/navigation_matcher.rb b/spec/support/matchers/navigation_matcher.rb
index 63f59b9654c..4c4b54630a3 100644
--- a/spec/support/matchers/navigation_matcher.rb
+++ b/spec/support/matchers/navigation_matcher.rb
@@ -1,12 +1,12 @@
RSpec::Matchers.define :have_active_navigation do |expected|
match do |page|
- expect(page).to have_selector('.sidebar-top-level-items > li.active', count: 1)
- expect(page.find('.sidebar-top-level-items > li.active')).to have_content(expected)
+ expect(page).to have_selector(".sidebar-top-level-items > li.active", count: 1)
+ expect(page.find(".sidebar-top-level-items > li.active")).to have_content(expected)
end
end
RSpec::Matchers.define :have_active_sub_navigation do |expected|
match do |page|
- expect(page.find('.sidebar-sub-level-items > li.active:not(.fly-out-top-item)')).to have_content(expected)
+ expect(page.find(".sidebar-sub-level-items > li.active:not(.fly-out-top-item)")).to have_content(expected)
end
end
diff --git a/spec/support/matchers/pagination_matcher.rb b/spec/support/matchers/pagination_matcher.rb
index 9a7697e2bfc..7034d2be8e1 100644
--- a/spec/support/matchers/pagination_matcher.rb
+++ b/spec/support/matchers/pagination_matcher.rb
@@ -1,11 +1,11 @@
RSpec::Matchers.define :include_pagination_headers do |expected|
match do |actual|
- expect(actual.headers).to include('X-Total', 'X-Total-Pages', 'X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page', 'Link')
+ expect(actual.headers).to include("X-Total", "X-Total-Pages", "X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "Link")
end
end
RSpec::Matchers.define :include_limited_pagination_headers do |expected|
match do |actual|
- expect(actual.headers).to include('X-Per-Page', 'X-Page', 'X-Next-Page', 'X-Prev-Page', 'Link')
+ expect(actual.headers).to include("X-Per-Page", "X-Page", "X-Next-Page", "X-Prev-Page", "Link")
end
end
diff --git a/spec/support/matchers/security_header_matcher.rb b/spec/support/matchers/security_header_matcher.rb
index f8518d13ebb..816da3de129 100644
--- a/spec/support/matchers/security_header_matcher.rb
+++ b/spec/support/matchers/security_header_matcher.rb
@@ -1,5 +1,5 @@
RSpec::Matchers.define :include_security_headers do |expected|
match do |actual|
- expect(actual.headers).to include('X-Content-Type-Options')
+ expect(actual.headers).to include("X-Content-Type-Options")
end
end
diff --git a/spec/support/migrations_helpers/cluster_helpers.rb b/spec/support/migrations_helpers/cluster_helpers.rb
index b54af15c29e..3e3aedd505e 100644
--- a/spec/support/migrations_helpers/cluster_helpers.rb
+++ b/spec/support/migrations_helpers/cluster_helpers.rb
@@ -4,7 +4,7 @@ module MigrationHelpers
module ClusterHelpers
# Creates a list of cluster projects.
def create_cluster_project_list(quantity)
- group = namespaces_table.create(name: 'gitlab-org', path: 'gitlab-org')
+ group = namespaces_table.create(name: "gitlab-org", path: "gitlab-org")
quantity.times do |id|
create_cluster_project(group, id)
@@ -26,7 +26,7 @@ module MigrationHelpers
)
cluster = clusters_table.create(
- name: 'test-cluster',
+ name: "test-cluster",
cluster_type: 3,
provider_type: :gcp,
platform_type: :kubernetes
@@ -36,18 +36,18 @@ module MigrationHelpers
provider_gcp_table.create!(
gcp_project_id: "test-gcp-project-#{id}",
- endpoint: '111.111.111.111',
+ endpoint: "111.111.111.111",
cluster_id: cluster.id,
status: 3,
num_nodes: 1,
- zone: 'us-central1-a'
+ zone: "us-central1-a"
)
platform_kubernetes_table.create(
cluster_id: cluster.id,
- api_url: 'https://kubernetes.example.com',
- encrypted_token: 'a' * 40,
- encrypted_token_iv: 'a' * 40
+ api_url: "https://kubernetes.example.com",
+ encrypted_token: "a" * 40,
+ encrypted_token_iv: "a" * 40
)
end
diff --git a/spec/support/migrations_helpers/track_untracked_uploads_helpers.rb b/spec/support/migrations_helpers/track_untracked_uploads_helpers.rb
index 016bcfa9b1b..7c0e3d35b89 100644
--- a/spec/support/migrations_helpers/track_untracked_uploads_helpers.rb
+++ b/spec/support/migrations_helpers/track_untracked_uploads_helpers.rb
@@ -1,17 +1,17 @@
module MigrationsHelpers
module TrackUntrackedUploadsHelpers
- PUBLIC_DIR = File.join(Rails.root, 'tmp', 'tests', 'public')
- UPLOADS_DIR = File.join(PUBLIC_DIR, 'uploads')
- SYSTEM_DIR = File.join(UPLOADS_DIR, '-', 'system')
- UPLOAD_FILENAME = 'image.png'.freeze
- FIXTURE_FILE_PATH = File.join(Rails.root, 'spec', 'fixtures', 'dk.png')
- FIXTURE_CHECKSUM = 'b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75'.freeze
+ PUBLIC_DIR = File.join(Rails.root, "tmp", "tests", "public")
+ UPLOADS_DIR = File.join(PUBLIC_DIR, "uploads")
+ SYSTEM_DIR = File.join(UPLOADS_DIR, "-", "system")
+ UPLOAD_FILENAME = "image.png".freeze
+ FIXTURE_FILE_PATH = File.join(Rails.root, "spec", "fixtures", "dk.png")
+ FIXTURE_CHECKSUM = "b804383982bb89b00e828e3f44c038cc991d3d1768009fc39ba8e2c081b9fb75".freeze
def create_or_update_appearance(logo: false, header_logo: false)
- appearance = appearances.first_or_create(title: 'foo', description: 'bar', logo: (UPLOAD_FILENAME if logo), header_logo: (UPLOAD_FILENAME if header_logo))
+ appearance = appearances.first_or_create(title: "foo", description: "bar", logo: (UPLOAD_FILENAME if logo), header_logo: (UPLOAD_FILENAME if header_logo))
- add_upload(appearance, 'Appearance', 'logo', 'AttachmentUploader') if logo
- add_upload(appearance, 'Appearance', 'header_logo', 'AttachmentUploader') if header_logo
+ add_upload(appearance, "Appearance", "logo", "AttachmentUploader") if logo
+ add_upload(appearance, "Appearance", "header_logo", "AttachmentUploader") if header_logo
appearance
end
@@ -20,7 +20,7 @@ module MigrationsHelpers
index = unique_index(:group)
group = namespaces.create(name: "group#{index}", path: "group#{index}", avatar: (UPLOAD_FILENAME if avatar))
- add_upload(group, 'Group', 'avatar', 'AvatarUploader') if avatar
+ add_upload(group, "Group", "avatar", "AvatarUploader") if avatar
group
end
@@ -28,7 +28,7 @@ module MigrationsHelpers
def create_note(attachment: false)
note = notes.create(attachment: (UPLOAD_FILENAME if attachment))
- add_upload(note, 'Note', 'attachment', 'AttachmentUploader') if attachment
+ add_upload(note, "Note", "attachment", "AttachmentUploader") if attachment
note
end
@@ -36,9 +36,9 @@ module MigrationsHelpers
def create_project(avatar: false)
group = create_group
project = projects.create(namespace_id: group.id, path: "project#{unique_index(:project)}", avatar: (UPLOAD_FILENAME if avatar))
- routes.create(path: "#{group.path}/#{project.path}", source_id: project.id, source_type: 'Project') # so Project.find_by_full_path works
+ routes.create(path: "#{group.path}/#{project.path}", source_id: project.id, source_type: "Project") # so Project.find_by_full_path works
- add_upload(project, 'Project', 'avatar', 'AvatarUploader') if avatar
+ add_upload(project, "Project", "avatar", "AvatarUploader") if avatar
project
end
@@ -46,7 +46,7 @@ module MigrationsHelpers
def create_user(avatar: false)
user = users.create(email: "foo#{unique_index(:user)}@bar.com", avatar: (UPLOAD_FILENAME if avatar), projects_limit: 100)
- add_upload(user, 'User', 'avatar', 'AvatarUploader') if avatar
+ add_upload(user, "User", "avatar", "AvatarUploader") if avatar
user
end
@@ -59,14 +59,14 @@ module MigrationsHelpers
def add_upload(model, model_type, attachment_type, uploader)
file_path = upload_file_path(model, model_type, attachment_type)
- path_relative_to_public = file_path.sub("#{PUBLIC_DIR}/", '')
+ path_relative_to_public = file_path.sub("#{PUBLIC_DIR}/", "")
create_file(file_path)
uploads.create!(
size: 1062,
path: path_relative_to_public,
model_id: model.id,
- model_type: model_type == 'Group' ? 'Namespace' : model_type,
+ model_type: model_type == "Group" ? "Namespace" : model_type,
uploader: uploader,
checksum: FIXTURE_CHECKSUM
)
@@ -76,15 +76,15 @@ module MigrationsHelpers
project_dir = hashed_storage ? hashed_project_uploads_dir(project) : legacy_project_uploads_dir(project)
attachment_dir = File.join(project_dir, SecureRandom.hex)
attachment_file_path = File.join(attachment_dir, UPLOAD_FILENAME)
- project_attachment_path_relative_to_project = attachment_file_path.sub("#{project_dir}/", '')
+ project_attachment_path_relative_to_project = attachment_file_path.sub("#{project_dir}/", "")
create_file(attachment_file_path)
uploads.create!(
size: 1062,
path: project_attachment_path_relative_to_project,
model_id: project.id,
- model_type: 'Project',
- uploader: 'FileUploader',
+ model_type: "Project",
+ uploader: "FileUploader",
checksum: FIXTURE_CHECKSUM
)
end
@@ -95,7 +95,7 @@ module MigrationsHelpers
end
def hashed_project_uploads_dir(project)
- File.join(UPLOADS_DIR, '@hashed', 'aa', 'aaaaaaaaaaaa')
+ File.join(UPLOADS_DIR, "@hashed", "aa", "aaaaaaaaaaaa")
end
def upload_file_path(model, model_type, attachment_type)
@@ -118,7 +118,7 @@ module MigrationsHelpers
end
def get_full_path(project)
- routes.find_by(source_id: project.id, source_type: 'Project').path
+ routes.find_by(source_id: project.id, source_type: "Project").path
end
def ensure_temporary_tracking_table_exists
diff --git a/spec/support/prepare-gitlab-git-test-for-commit b/spec/support/prepare-gitlab-git-test-for-commit
index d08e3ba5481..72a11449877 100755
--- a/spec/support/prepare-gitlab-git-test-for-commit
+++ b/spec/support/prepare-gitlab-git-test-for-commit
@@ -1,11 +1,11 @@
#!/usr/bin/env ruby
abort unless [
- system('spec/support/generate-seed-repo-rb', out: 'spec/support/helpers/seed_repo.rb'),
- system('spec/support/unpack-gitlab-git-test')
+ system("spec/support/generate-seed-repo-rb", out: "spec/support/helpers/seed_repo.rb"),
+ system("spec/support/unpack-gitlab-git-test"),
].all?
-exit if ARGV.first != '--check-for-changes'
+exit if ARGV.first != "--check-for-changes"
git_status = IO.popen(%w[git status --porcelain], &:read)
abort unless $?.success?
diff --git a/spec/support/prometheus/additional_metrics_shared_examples.rb b/spec/support/prometheus/additional_metrics_shared_examples.rb
index 0fd67531c3b..668ec60d1a3 100644
--- a/spec/support/prometheus/additional_metrics_shared_examples.rb
+++ b/spec/support/prometheus/additional_metrics_shared_examples.rb
@@ -1,36 +1,36 @@
-RSpec.shared_examples 'additional metrics query' do
+RSpec.shared_examples "additional metrics query" do
include Prometheus::MetricBuilders
let(:metric_group_class) { Gitlab::Prometheus::MetricGroup }
let(:metric_class) { Gitlab::Prometheus::Metric }
- let(:metric_names) { %w{metric_a metric_b} }
+ let(:metric_names) { %w[metric_a metric_b] }
let(:query_range_result) do
- [{ 'metric': {}, 'values': [[1488758662.506, '0.00002996364761904785'], [1488758722.506, '0.00003090239047619091']] }]
+ [{'metric': {}, 'values': [[1488758662.506, "0.00002996364761904785"], [1488758722.506, "0.00003090239047619091"]]}]
end
- let(:client) { double('prometheus_client') }
+ let(:client) { double("prometheus_client") }
let(:query_result) { described_class.new(client).query(*query_params) }
let(:project) { create(:project) }
- let(:environment) { create(:environment, slug: 'environment-slug', project: project) }
+ let(:environment) { create(:environment, slug: "environment-slug", project: project) }
before do
allow(client).to receive(:label_values).and_return(metric_names)
allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group(metrics: [simple_metric])])
end
- context 'metrics query context' do
+ context "metrics query context" do
subject! { described_class.new(client) }
- shared_examples 'query context containing environment slug and filter' do
- it 'contains ci_environment_slug' do
+ shared_examples "query context containing environment slug and filter" do
+ it "contains ci_environment_slug" do
expect(subject).to receive(:query_metrics).with(project, environment, hash_including(ci_environment_slug: environment.slug))
subject.query(*query_params)
end
- it 'contains environment filter' do
+ it "contains environment filter" do
expect(subject).to receive(:query_metrics).with(
project,
environment,
@@ -43,102 +43,103 @@ RSpec.shared_examples 'additional metrics query' do
end
end
- describe 'project has Kubernetes service' do
- shared_examples 'same behavior between KubernetesService and Platform::Kubernetes' do
- let(:environment) { create(:environment, slug: 'environment-slug', project: project) }
+ describe "project has Kubernetes service" do
+ shared_examples "same behavior between KubernetesService and Platform::Kubernetes" do
+ let(:environment) { create(:environment, slug: "environment-slug", project: project) }
let(:kube_namespace) { project.deployment_platform.actual_namespace }
- it_behaves_like 'query context containing environment slug and filter'
+ it_behaves_like "query context containing environment slug and filter"
- it 'query context contains kube_namespace' do
+ it "query context contains kube_namespace" do
expect(subject).to receive(:query_metrics).with(project, environment, hash_including(kube_namespace: kube_namespace))
subject.query(*query_params)
end
end
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it_behaves_like 'same behavior between KubernetesService and Platform::Kubernetes'
+ it_behaves_like "same behavior between KubernetesService and Platform::Kubernetes"
end
end
- describe 'project without Kubernetes service' do
- it_behaves_like 'query context containing environment slug and filter'
+ describe "project without Kubernetes service" do
+ it_behaves_like "query context containing environment slug and filter"
- it 'query context contains empty kube_namespace' do
- expect(subject).to receive(:query_metrics).with(project, environment, hash_including(kube_namespace: ''))
+ it "query context contains empty kube_namespace" do
+ expect(subject).to receive(:query_metrics).with(project, environment, hash_including(kube_namespace: ""))
subject.query(*query_params)
end
end
end
- context 'with one group where two metrics is found' do
+ context "with one group where two metrics is found" do
before do
allow(metric_group_class).to receive(:common_metrics).and_return([simple_metric_group])
end
- context 'some queries return results' do
+ context "some queries return results" do
before do
- allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result)
- allow(client).to receive(:query_range).with('query_range_b', any_args).and_return(query_range_result)
- allow(client).to receive(:query_range).with('query_range_empty', any_args).and_return([])
+ allow(client).to receive(:query_range).with("query_range_a", any_args).and_return(query_range_result)
+ allow(client).to receive(:query_range).with("query_range_b", any_args).and_return(query_range_result)
+ allow(client).to receive(:query_range).with("query_range_empty", any_args).and_return([])
end
- it 'return group data only for queries with results' do
+ it "return group data only for queries with results" do
expected = [
{
- group: 'name',
+ group: "name",
priority: 1,
metrics: [
{
- title: 'title', weight: 1, y_label: 'Values', queries: [
- { query_range: 'query_range_a', result: query_range_result },
- { query_range: 'query_range_b', label: 'label', unit: 'unit', result: query_range_result }
- ]
- }
- ]
- }
+ title: "title", weight: 1, y_label: "Values", queries: [
+ {query_range: "query_range_a", result: query_range_result},
+ {query_range: "query_range_b", label: "label", unit: "unit", result: query_range_result},
+ ],
+ },
+ ],
+ },
]
- expect(query_result).to match_schema('prometheus/additional_metrics_query_result')
+ expect(query_result).to match_schema("prometheus/additional_metrics_query_result")
expect(query_result).to eq(expected)
end
end
end
- context 'with two groups with one metric each' do
+ context "with two groups with one metric each" do
let(:metrics) { [simple_metric(queries: [simple_query])] }
before do
allow(metric_group_class).to receive(:common_metrics).and_return(
[
- simple_metric_group(name: 'group_a', metrics: [simple_metric(queries: [simple_query])]),
- simple_metric_group(name: 'group_b', metrics: [simple_metric(title: 'title_b', queries: [simple_query('b')])])
- ])
+ simple_metric_group(name: "group_a", metrics: [simple_metric(queries: [simple_query])]),
+ simple_metric_group(name: "group_b", metrics: [simple_metric(title: "title_b", queries: [simple_query("b")])]),
+ ]
+ )
allow(client).to receive(:label_values).and_return(metric_names)
end
- context 'both queries return results' do
+ context "both queries return results" do
before do
- allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result)
- allow(client).to receive(:query_range).with('query_range_b', any_args).and_return(query_range_result)
+ allow(client).to receive(:query_range).with("query_range_a", any_args).and_return(query_range_result)
+ allow(client).to receive(:query_range).with("query_range_b", any_args).and_return(query_range_result)
end
- it 'return group data both queries' do
- queries_with_result_a = { queries: [{ query_range: 'query_range_a', result: query_range_result }] }
- queries_with_result_b = { queries: [{ query_range: 'query_range_b', result: query_range_result }] }
+ it "return group data both queries" do
+ queries_with_result_a = {queries: [{query_range: "query_range_a", result: query_range_result}]}
+ queries_with_result_b = {queries: [{query_range: "query_range_b", result: query_range_result}]}
- expect(query_result).to match_schema('prometheus/additional_metrics_query_result')
+ expect(query_result).to match_schema("prometheus/additional_metrics_query_result")
expect(query_result.count).to eq(2)
expect(query_result).to all(satisfy { |r| r[:metrics].count == 1 })
@@ -148,16 +149,16 @@ RSpec.shared_examples 'additional metrics query' do
end
end
- context 'one query returns result' do
+ context "one query returns result" do
before do
- allow(client).to receive(:query_range).with('query_range_a', any_args).and_return(query_range_result)
- allow(client).to receive(:query_range).with('query_range_b', any_args).and_return([])
+ allow(client).to receive(:query_range).with("query_range_a", any_args).and_return(query_range_result)
+ allow(client).to receive(:query_range).with("query_range_b", any_args).and_return([])
end
- it 'return group data only for query with results' do
- queries_with_result = { queries: [{ query_range: 'query_range_a', result: query_range_result }] }
+ it "return group data only for query with results" do
+ queries_with_result = {queries: [{query_range: "query_range_a", result: query_range_result}]}
- expect(query_result).to match_schema('prometheus/additional_metrics_query_result')
+ expect(query_result).to match_schema("prometheus/additional_metrics_query_result")
expect(query_result.count).to eq(1)
expect(query_result).to all(satisfy { |r| r[:metrics].count == 1 })
diff --git a/spec/support/prometheus/metric_builders.rb b/spec/support/prometheus/metric_builders.rb
index c8d056d3fc8..8c64e6af4ff 100644
--- a/spec/support/prometheus/metric_builders.rb
+++ b/spec/support/prometheus/metric_builders.rb
@@ -1,26 +1,26 @@
module Prometheus
module MetricBuilders
- def simple_query(suffix = 'a', **opts)
- { query_range: "query_range_#{suffix}" }.merge(opts)
+ def simple_query(suffix = "a", **opts)
+ {query_range: "query_range_#{suffix}"}.merge(opts)
end
def simple_queries
- [simple_query, simple_query('b', label: 'label', unit: 'unit')]
+ [simple_query, simple_query("b", label: "label", unit: "unit")]
end
- def simple_metric(title: 'title', required_metrics: [], queries: [simple_query])
+ def simple_metric(title: "title", required_metrics: [], queries: [simple_query])
Gitlab::Prometheus::Metric.new(title: title, required_metrics: required_metrics, weight: 1, queries: queries)
end
- def simple_metrics(added_metric_name: 'metric_a')
+ def simple_metrics(added_metric_name: "metric_a")
[
- simple_metric(required_metrics: %W(#{added_metric_name} metric_b), queries: simple_queries),
- simple_metric(required_metrics: [added_metric_name], queries: [simple_query('empty')]),
- simple_metric(required_metrics: %w{metric_c})
+ simple_metric(required_metrics: %W[#{added_metric_name} metric_b], queries: simple_queries),
+ simple_metric(required_metrics: [added_metric_name], queries: [simple_query("empty")]),
+ simple_metric(required_metrics: %w[metric_c]),
]
end
- def simple_metric_group(name: 'name', metrics: simple_metrics)
+ def simple_metric_group(name: "name", metrics: simple_metrics)
Gitlab::Prometheus::MetricGroup.new(name: name, priority: 1, metrics: metrics)
end
end
diff --git a/spec/support/protected_tags/access_control_ce_shared_examples.rb b/spec/support/protected_tags/access_control_ce_shared_examples.rb
index 71eec9f3217..ba587a9edc1 100644
--- a/spec/support/protected_tags/access_control_ce_shared_examples.rb
+++ b/spec/support/protected_tags/access_control_ce_shared_examples.rb
@@ -3,15 +3,15 @@ RSpec.shared_examples "protected tags > access control > CE" do
it "allows creating protected tags that #{access_type_name} can create" do
visit project_protected_tags_path(project)
- set_protected_tag_name('master')
+ set_protected_tag_name("master")
- within('.js-new-protected-tag') do
+ within(".js-new-protected-tag") do
allowed_to_create_button = find(".js-allowed-to-create")
unless allowed_to_create_button.text == access_type_name
allowed_to_create_button.click
- find('.create_access_levels-container .dropdown-menu li', match: :first)
- within('.create_access_levels-container .dropdown-menu') { click_on access_type_name }
+ find(".create_access_levels-container .dropdown-menu li", match: :first)
+ within(".create_access_levels-container .dropdown-menu") { click_on access_type_name }
end
end
@@ -24,7 +24,7 @@ RSpec.shared_examples "protected tags > access control > CE" do
it "allows updating protected tags so that #{access_type_name} can create them" do
visit project_protected_tags_path(project)
- set_protected_tag_name('master')
+ set_protected_tag_name("master")
click_on "Protect"
@@ -33,7 +33,7 @@ RSpec.shared_examples "protected tags > access control > CE" do
within(".protected-tags-list") do
find(".js-allowed-to-create").click
- within('.js-allowed-to-create-container') do
+ within(".js-allowed-to-create-container") do
expect(first("li")).to have_content("Roles")
click_on access_type_name
end
diff --git a/spec/support/redis/redis_shared_examples.rb b/spec/support/redis/redis_shared_examples.rb
index a8b00004fe7..073c8e1b7de 100644
--- a/spec/support/redis/redis_shared_examples.rb
+++ b/spec/support/redis/redis_shared_examples.rb
@@ -12,10 +12,10 @@ RSpec.shared_examples "redis_shared_examples" do
clear_raw_config
end
- describe '.params' do
+ describe ".params" do
subject { described_class.params }
- it 'withstands mutation' do
+ it "withstands mutation" do
params1 = described_class.params
params2 = described_class.params
params1[:foo] = :bar
@@ -23,78 +23,78 @@ RSpec.shared_examples "redis_shared_examples" do
expect(params2).not_to have_key(:foo)
end
- context 'when url contains unix socket reference' do
- context 'with old format' do
+ context "when url contains unix socket reference" do
+ context "with old format" do
let(:config_file_name) { config_old_format_socket }
- it 'returns path key instead' do
+ it "returns path key instead" do
is_expected.to include(path: old_socket_path)
is_expected.not_to have_key(:url)
end
end
- context 'with new format' do
+ context "with new format" do
let(:config_file_name) { config_new_format_socket }
- it 'returns path key instead' do
+ it "returns path key instead" do
is_expected.to include(path: new_socket_path)
is_expected.not_to have_key(:url)
end
end
end
- context 'when url is host based' do
- context 'with old format' do
+ context "when url is host based" do
+ context "with old format" do
let(:config_file_name) { config_old_format_host }
- it 'returns hash with host, port, db, and password' do
- is_expected.to include(host: 'localhost', password: 'mypassword', port: redis_port, db: redis_database)
+ it "returns hash with host, port, db, and password" do
+ is_expected.to include(host: "localhost", password: "mypassword", port: redis_port, db: redis_database)
is_expected.not_to have_key(:url)
end
end
- context 'with new format' do
+ context "with new format" do
let(:config_file_name) { config_new_format_host }
- it 'returns hash with host, port, db, and password' do
- is_expected.to include(host: 'localhost', password: 'mynewpassword', port: redis_port, db: redis_database)
+ it "returns hash with host, port, db, and password" do
+ is_expected.to include(host: "localhost", password: "mynewpassword", port: redis_port, db: redis_database)
is_expected.not_to have_key(:url)
end
end
end
end
- describe '.url' do
- it 'withstands mutation' do
+ describe ".url" do
+ it "withstands mutation" do
url1 = described_class.url
url2 = described_class.url
- url1 << 'foobar' unless url1.frozen?
+ url1 << "foobar" unless url1.frozen?
- expect(url2).not_to end_with('foobar')
+ expect(url2).not_to end_with("foobar")
end
- context 'when yml file with env variable' do
+ context "when yml file with env variable" do
let(:config_file_name) { config_with_environment_variable_inside }
before do
stub_env(config_env_variable_url, test_redis_url)
end
- it 'reads redis url from env variable' do
+ it "reads redis url from env variable" do
expect(described_class.url).to eq test_redis_url
end
end
end
- describe '._raw_config' do
+ describe "._raw_config" do
subject { described_class._raw_config }
- let(:config_file_name) { '/var/empty/doesnotexist' }
+ let(:config_file_name) { "/var/empty/doesnotexist" }
- it 'should be frozen' do
+ it "should be frozen" do
expect(subject).to be_frozen
end
- it 'returns false when the file does not exist' do
+ it "returns false when the file does not exist" do
expect(subject).to eq(false)
end
@@ -105,7 +105,7 @@ RSpec.shared_examples "redis_shared_examples" do
end
end
- describe '.with' do
+ describe ".with" do
before do
clear_pool
end
@@ -113,25 +113,25 @@ RSpec.shared_examples "redis_shared_examples" do
clear_pool
end
- context 'when running not on sidekiq workers' do
+ context "when running not on sidekiq workers" do
before do
allow(Sidekiq).to receive(:server?).and_return(false)
end
- it 'instantiates a connection pool with size 5' do
+ it "instantiates a connection pool with size 5" do
expect(ConnectionPool).to receive(:new).with(size: 5).and_call_original
described_class.with { |_redis_shared_example| true }
end
end
- context 'when running on sidekiq workers' do
+ context "when running on sidekiq workers" do
before do
allow(Sidekiq).to receive(:server?).and_return(true)
- allow(Sidekiq).to receive(:options).and_return({ concurrency: 18 })
+ allow(Sidekiq).to receive(:options).and_return({concurrency: 18})
end
- it 'instantiates a connection pool with a size based on the concurrency of the worker' do
+ it "instantiates a connection pool with a size based on the concurrency of the worker" do
expect(ConnectionPool).to receive(:new).with(size: 18 + 5).and_call_original
described_class.with { |_redis_shared_example| true }
@@ -139,68 +139,68 @@ RSpec.shared_examples "redis_shared_examples" do
end
end
- describe '#sentinels' do
+ describe "#sentinels" do
subject { described_class.new(Rails.env).sentinels }
- context 'when sentinels are defined' do
+ context "when sentinels are defined" do
let(:config_file_name) { config_new_format_host }
- it 'returns an array of hashes with host and port keys' do
- is_expected.to include(host: 'localhost', port: sentinel_port)
- is_expected.to include(host: 'slave2', port: sentinel_port)
+ it "returns an array of hashes with host and port keys" do
+ is_expected.to include(host: "localhost", port: sentinel_port)
+ is_expected.to include(host: "slave2", port: sentinel_port)
end
end
- context 'when sentinels are not defined' do
+ context "when sentinels are not defined" do
let(:config_file_name) { config_old_format_host }
- it 'returns nil' do
+ it "returns nil" do
is_expected.to be_nil
end
end
end
- describe '#sentinels?' do
+ describe "#sentinels?" do
subject { described_class.new(Rails.env).sentinels? }
- context 'when sentinels are defined' do
+ context "when sentinels are defined" do
let(:config_file_name) { config_new_format_host }
- it 'returns true' do
+ it "returns true" do
is_expected.to be_truthy
end
end
- context 'when sentinels are not defined' do
+ context "when sentinels are not defined" do
let(:config_file_name) { config_old_format_host }
- it 'returns false' do
+ it "returns false" do
is_expected.to be_falsey
end
end
end
- describe '#raw_config_hash' do
- it 'returns default redis url when no config file is present' do
+ describe "#raw_config_hash" do
+ it "returns default redis url when no config file is present" do
expect(subject).to receive(:fetch_config) { false }
- expect(subject.send(:raw_config_hash)).to eq(url: class_redis_url )
+ expect(subject.send(:raw_config_hash)).to eq(url: class_redis_url)
end
- it 'returns old-style single url config in a hash' do
+ it "returns old-style single url config in a hash" do
expect(subject).to receive(:fetch_config) { test_redis_url }
expect(subject.send(:raw_config_hash)).to eq(url: test_redis_url)
end
end
- describe '#fetch_config' do
- it 'returns false when no config file is present' do
+ describe "#fetch_config" do
+ it "returns false when no config file is present" do
allow(described_class).to receive(:_raw_config) { false }
expect(subject.send(:fetch_config)).to eq false
end
- it 'returns false when config file is present but has invalid YAML' do
+ it "returns false when config file is present but has invalid YAML" do
allow(described_class).to receive(:_raw_config) { "# development: true" }
expect(subject.send(:fetch_config)).to eq false
diff --git a/spec/support/services/clusters/create_service_shared.rb b/spec/support/services/clusters/create_service_shared.rb
index b0bf942aa09..6e16943932e 100644
--- a/spec/support/services/clusters/create_service_shared.rb
+++ b/spec/support/services/clusters/create_service_shared.rb
@@ -1,57 +1,57 @@
-shared_context 'valid cluster create params' do
+shared_context "valid cluster create params" do
let(:params) do
{
- name: 'test-cluster',
+ name: "test-cluster",
provider_type: :gcp,
provider_gcp_attributes: {
- gcp_project_id: 'gcp-project',
- zone: 'us-central1-a',
+ gcp_project_id: "gcp-project",
+ zone: "us-central1-a",
num_nodes: 1,
- machine_type: 'machine_type-a',
- legacy_abac: 'true'
- }
+ machine_type: "machine_type-a",
+ legacy_abac: "true",
+ },
}
end
end
-shared_context 'invalid cluster create params' do
+shared_context "invalid cluster create params" do
let(:params) do
{
- name: 'test-cluster',
+ name: "test-cluster",
provider_type: :gcp,
provider_gcp_attributes: {
- gcp_project_id: '!!!!!!!',
- zone: 'us-central1-a',
+ gcp_project_id: "!!!!!!!",
+ zone: "us-central1-a",
num_nodes: 1,
- machine_type: 'machine_type-a'
- }
+ machine_type: "machine_type-a",
+ },
}
end
end
-shared_examples 'create cluster service success' do
- it 'creates a cluster object and performs a worker' do
+shared_examples "create cluster service success" do
+ it "creates a cluster object and performs a worker" do
expect(ClusterProvisionWorker).to receive(:perform_async)
expect { subject }
.to change { Clusters::Cluster.count }.by(1)
.and change { Clusters::Providers::Gcp.count }.by(1)
- expect(subject.name).to eq('test-cluster')
+ expect(subject.name).to eq("test-cluster")
expect(subject.user).to eq(user)
expect(subject.project).to eq(project)
- expect(subject.provider.gcp_project_id).to eq('gcp-project')
- expect(subject.provider.zone).to eq('us-central1-a')
+ expect(subject.provider.gcp_project_id).to eq("gcp-project")
+ expect(subject.provider.zone).to eq("us-central1-a")
expect(subject.provider.num_nodes).to eq(1)
- expect(subject.provider.machine_type).to eq('machine_type-a')
+ expect(subject.provider.machine_type).to eq("machine_type-a")
expect(subject.provider.access_token).to eq(access_token)
expect(subject.provider).to be_legacy_abac
expect(subject.platform).to be_nil
end
end
-shared_examples 'create cluster service error' do
- it 'returns an error' do
+shared_examples "create cluster service error" do
+ it "returns an error" do
expect(ClusterProvisionWorker).not_to receive(:perform_async)
expect { subject }.to change { Clusters::Cluster.count }.by(0)
expect(subject.errors[:"provider_gcp.gcp_project_id"]).to be_present
diff --git a/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb b/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
index 8b4cffaac19..ef92fa63e41 100644
--- a/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
+++ b/spec/support/services/issuable_create_service_slash_commands_shared_examples.rb
@@ -1,13 +1,13 @@
# Specifications for behavior common to all objects with executable attributes.
# It can take a `default_params`.
-shared_examples 'new issuable record that supports quick actions' do
+shared_examples "new issuable record that supports quick actions" do
let!(:project) { create(:project, :repository) }
let(:user) { create(:user).tap { |u| project.add_maintainer(u) } }
let(:assignee) { create(:user) }
let!(:milestone) { create(:milestone, project: project) }
let!(:labels) { create_list(:label, 3, project: project) }
- let(:base_params) { { title: 'My issuable title' } }
+ let(:base_params) { {title: "My issuable title"} }
let(:params) { base_params.merge(defined?(default_params) ? default_params : {}).merge(example_params) }
let(:issuable) { described_class.new(project, user, params).execute }
@@ -15,55 +15,55 @@ shared_examples 'new issuable record that supports quick actions' do
project.add_maintainer(assignee)
end
- context 'with labels in command only' do
+ context "with labels in command only" do
let(:example_params) do
{
- description: "/label ~#{labels.first.name} ~#{labels.second.name}\n/unlabel ~#{labels.third.name}"
+ description: "/label ~#{labels.first.name} ~#{labels.second.name}\n/unlabel ~#{labels.third.name}",
}
end
- it 'attaches labels to issuable' do
+ it "attaches labels to issuable" do
expect(issuable).to be_persisted
expect(issuable.label_ids).to match_array([labels.first.id, labels.second.id])
end
end
- context 'with labels in params and command' do
+ context "with labels in params and command" do
let(:example_params) do
{
label_ids: [labels.second.id],
- description: "/label ~#{labels.first.name}\n/unlabel ~#{labels.third.name}"
+ description: "/label ~#{labels.first.name}\n/unlabel ~#{labels.third.name}",
}
end
- it 'attaches all labels to issuable' do
+ it "attaches all labels to issuable" do
expect(issuable).to be_persisted
expect(issuable.label_ids).to match_array([labels.first.id, labels.second.id])
end
end
- context 'with assignee and milestone in command only' do
+ context "with assignee and milestone in command only" do
let(:example_params) do
{
- description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}")
+ description: %(/assign @#{assignee.username}\n/milestone %"#{milestone.name}"),
}
end
- it 'assigns and sets milestone to issuable' do
+ it "assigns and sets milestone to issuable" do
expect(issuable).to be_persisted
expect(issuable.assignees).to eq([assignee])
expect(issuable.milestone).to eq(milestone)
end
end
- describe '/close' do
+ describe "/close" do
let(:example_params) do
{
- description: '/close'
+ description: "/close",
}
end
- it 'returns an open issue' do
+ it "returns an open issue" do
expect(issuable).to be_persisted
expect(issuable).to be_open
end
diff --git a/spec/support/services/issuable_update_service_shared_examples.rb b/spec/support/services/issuable_update_service_shared_examples.rb
index ffbce6c42bf..f17a3aadaf5 100644
--- a/spec/support/services/issuable_update_service_shared_examples.rb
+++ b/spec/support/services/issuable_update_service_shared_examples.rb
@@ -1,22 +1,22 @@
-shared_examples 'issuable update service' do
+shared_examples "issuable update service" do
def update_issuable(opts)
described_class.new(project, user, opts).execute(open_issuable)
end
- context 'changing state' do
+ context "changing state" do
before do
expect(project).to receive(:execute_hooks).once
end
- context 'to reopened' do
- it 'executes hooks only once' do
- described_class.new(project, user, state_event: 'reopen').execute(closed_issuable)
+ context "to reopened" do
+ it "executes hooks only once" do
+ described_class.new(project, user, state_event: "reopen").execute(closed_issuable)
end
end
- context 'to closed' do
- it 'executes hooks only once' do
- described_class.new(project, user, state_event: 'close').execute(open_issuable)
+ context "to closed" do
+ it "executes hooks only once" do
+ described_class.new(project, user, state_event: "close").execute(open_issuable)
end
end
end
diff --git a/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb b/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb
index 62ae95df8c0..12beff681ca 100644
--- a/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb
+++ b/spec/support/services/migrate_to_ghost_user_service_shared_examples.rb
@@ -49,7 +49,7 @@ shared_examples "migrating a deleted user's associated records to the ghost user
.to receive(:update_all).and_raise(ActiveRecord::Rollback)
end
- it 'rolls back the user block' do
+ it "rolls back the user block" do
service.execute
expect(user.reload).not_to be_blocked
@@ -70,8 +70,12 @@ shared_examples "migrating a deleted user's associated records to the ghost user
.to receive(:update_all).and_raise(ArgumentError)
end
- it 'rolls back the user block' do
- service.execute rescue nil
+ it "rolls back the user block" do
+ begin
+ service.execute
+ rescue
+ nil
+ end
expect(user.reload).not_to be_blocked
end
@@ -79,14 +83,18 @@ shared_examples "migrating a deleted user's associated records to the ghost user
it "doesn't unblock an previously-blocked user" do
user.block
- service.execute rescue nil
+ begin
+ service.execute
+ rescue
+ nil
+ end
expect(user.reload).to be_blocked
end
end
it "blocks the user before #{record_class_name} migration begins" do
- expect(service).to receive("migrate_#{record_class_name.parameterize(separator: '_').pluralize}".to_sym) do
+ expect(service).to receive("migrate_#{record_class_name.parameterize(separator: "_").pluralize}".to_sym) do
expect(user.reload).to be_blocked
end
diff --git a/spec/support/setup_builds_storage.rb b/spec/support/setup_builds_storage.rb
index 1d2a4856724..b2386e6bef1 100644
--- a/spec/support/setup_builds_storage.rb
+++ b/spec/support/setup_builds_storage.rb
@@ -1,10 +1,10 @@
RSpec.configure do |config|
def builds_path
- Rails.root.join('tmp/tests/builds')
+ Rails.root.join("tmp/tests/builds")
end
config.before(:suite) do
- Settings.gitlab_ci['builds_path'] = builds_path
+ Settings.gitlab_ci["builds_path"] = builds_path
end
config.before(:all) do
diff --git a/spec/support/shared_contexts/change_access_checks_shared_context.rb b/spec/support/shared_contexts/change_access_checks_shared_context.rb
index aca18b0c73b..df5594e0379 100644
--- a/spec/support/shared_contexts/change_access_checks_shared_context.rb
+++ b/spec/support/shared_contexts/change_access_checks_shared_context.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-shared_context 'change access checks context' do
+shared_context "change access checks context" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:user_access) { Gitlab::UserAccess.new(user, project: project) }
- let(:oldrev) { 'be93687618e4b132087f430a4d8fc3a609c9b77c' }
- let(:newrev) { '54fcc214b94e78d7a41a9a8fe6d87a5e59500e51' }
- let(:ref) { 'refs/heads/master' }
- let(:changes) { { oldrev: oldrev, newrev: newrev, ref: ref } }
- let(:protocol) { 'ssh' }
+ let(:oldrev) { "be93687618e4b132087f430a4d8fc3a609c9b77c" }
+ let(:newrev) { "54fcc214b94e78d7a41a9a8fe6d87a5e59500e51" }
+ let(:ref) { "refs/heads/master" }
+ let(:changes) { {oldrev: oldrev, newrev: newrev, ref: ref} }
+ let(:protocol) { "ssh" }
let(:timeout) { Gitlab::GitAccess::INTERNAL_TIMEOUT }
let(:logger) { Gitlab::Checks::TimedLogger.new(timeout: timeout) }
let(:change_access) do
diff --git a/spec/support/shared_contexts/email_shared_context.rb b/spec/support/shared_contexts/email_shared_context.rb
index 9d806fc524d..99121d7bc2b 100644
--- a/spec/support/shared_contexts/email_shared_context.rb
+++ b/spec/support/shared_contexts/email_shared_context.rb
@@ -1,4 +1,4 @@
-require 'gitlab/email/receiver'
+require "gitlab/email/receiver"
shared_context :email_shared_context do
let(:mail_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" }
@@ -11,8 +11,8 @@ shared_context :email_shared_context do
{
url: "uploads/image.png",
alt: "image",
- markdown: markdown
- }
+ markdown: markdown,
+ },
]
)
end
diff --git a/spec/support/shared_contexts/json_response_shared_context.rb b/spec/support/shared_contexts/json_response_shared_context.rb
index df5fc288089..3ff5b9bfd5f 100644
--- a/spec/support/shared_contexts/json_response_shared_context.rb
+++ b/spec/support/shared_contexts/json_response_shared_context.rb
@@ -1,3 +1,3 @@
-shared_context 'JSON response' do
+shared_context "JSON response" do
let(:json_response) { JSON.parse(response.body) }
end
diff --git a/spec/support/shared_contexts/merge_requests_allowing_collaboration.rb b/spec/support/shared_contexts/merge_requests_allowing_collaboration.rb
index 05424d08b9d..11e6b1eeea5 100644
--- a/spec/support/shared_contexts/merge_requests_allowing_collaboration.rb
+++ b/spec/support/shared_contexts/merge_requests_allowing_collaboration.rb
@@ -1,4 +1,4 @@
-shared_context 'merge request allowing collaboration' do
+shared_context "merge request allowing collaboration" do
include ProjectForksHelper
let(:canonical) { create(:project, :public, :repository) }
@@ -7,9 +7,9 @@ shared_context 'merge request allowing collaboration' do
before do
canonical.add_maintainer(user)
create(:merge_request,
- target_project: canonical,
- source_project: forked_project,
- source_branch: 'feature',
- allow_collaboration: true)
+ target_project: canonical,
+ source_project: forked_project,
+ source_branch: "feature",
+ allow_collaboration: true)
end
end
diff --git a/spec/support/shared_contexts/services_shared_context.rb b/spec/support/shared_contexts/services_shared_context.rb
index d92e8318fa0..c272d9af975 100644
--- a/spec/support/shared_contexts/services_shared_context.rb
+++ b/spec/support/shared_contexts/services_shared_context.rb
@@ -8,18 +8,18 @@ Service.available_services_names.each do |service|
let(:service_attrs_list) { service_fields.inject([]) {|arr, hash| arr << hash[:name].to_sym } }
let(:service_attrs) do
service_attrs_list.inject({}) do |hash, k|
- if k =~ /^(token*|.*_token|.*_key)/
- hash.merge!(k => 'secrettoken')
- elsif k =~ /^(.*_url|url|webhook)/
+ if /^(token*|.*_token|.*_key)/.match?(k)
+ hash.merge!(k => "secrettoken")
+ elsif /^(.*_url|url|webhook)/.match?(k)
hash.merge!(k => "http://example.com")
elsif service_klass.method_defined?("#{k}?")
hash.merge!(k => true)
- elsif service == 'irker' && k == :recipients
- hash.merge!(k => 'irc://irc.network.net:666/#channel')
- elsif service == 'irker' && k == :server_port
+ elsif service == "irker" && k == :recipients
+ hash.merge!(k => "irc://irc.network.net:666/#channel")
+ elsif service == "irker" && k == :server_port
hash.merge!(k => 1234)
- elsif service == 'jira' && k == :jira_issue_transition_id
- hash.merge!(k => '1,2,3')
+ elsif service == "jira" && k == :jira_issue_transition_id
+ hash.merge!(k => "1,2,3")
else
hash.merge!(k => "someword")
end
diff --git a/spec/support/shared_contexts/url_shared_context.rb b/spec/support/shared_contexts/url_shared_context.rb
index 1b1f67daac3..db971c5f612 100644
--- a/spec/support/shared_contexts/url_shared_context.rb
+++ b/spec/support/shared_contexts/url_shared_context.rb
@@ -1,4 +1,4 @@
-shared_context 'invalid urls' do
+shared_context "invalid urls" do
let(:urls_with_CRLF) do
["http://127.0.0.1:333/pa\rth",
"http://127.0.0.1:333/pa\nth",
@@ -12,6 +12,6 @@ shared_context 'invalid urls' do
"http://127.0.0.1:333/pa%0D%0Ath",
"http://127.0.0.1:333/path?param=foo%0Abar",
"http://127.0.0.1:333/path?param=foo%0Dbar",
- "http://127.0.0.1:333/path?param=foo%0D%0Abar"]
+ "http://127.0.0.1:333/path?param=foo%0D%0Abar",]
end
end
diff --git a/spec/support/shared_examples/chat_slash_commands_shared_examples.rb b/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
index dc97a39f051..6e42de4db6e 100644
--- a/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
+++ b/spec/support/shared_examples/chat_slash_commands_shared_examples.rb
@@ -1,51 +1,51 @@
-RSpec.shared_examples 'chat slash commands service' do
+RSpec.shared_examples "chat slash commands service" do
describe "Associations" do
it { is_expected.to respond_to :token }
it { is_expected.to have_many :chat_names }
end
- describe '#valid_token?' do
+ describe "#valid_token?" do
subject { described_class.new }
- context 'when the token is empty' do
- it 'is false' do
- expect(subject.valid_token?('wer')).to be_falsey
+ context "when the token is empty" do
+ it "is false" do
+ expect(subject.valid_token?("wer")).to be_falsey
end
end
- context 'when there is a token' do
+ context "when there is a token" do
before do
- subject.token = '123'
+ subject.token = "123"
end
- it 'accepts equal tokens' do
- expect(subject.valid_token?('123')).to be_truthy
+ it "accepts equal tokens" do
+ expect(subject.valid_token?("123")).to be_truthy
end
end
end
- describe '#trigger' do
+ describe "#trigger" do
subject { described_class.new }
- context 'no token is passed' do
- let(:params) { Hash.new }
+ context "no token is passed" do
+ let(:params) { {} }
- it 'returns nil' do
+ it "returns nil" do
expect(subject.trigger(params)).to be_nil
end
end
- context 'with a token passed' do
+ context "with a token passed" do
let(:project) { create(:project) }
- let(:params) { { token: 'token' } }
+ let(:params) { {token: "token"} }
before do
- allow(subject).to receive(:token).and_return('token')
+ allow(subject).to receive(:token).and_return("token")
end
- context 'no user can be found' do
- context 'when no url can be generated' do
- it 'responds with the authorize url' do
+ context "no user can be found" do
+ context "when no url can be generated" do
+ it "responds with the authorize url" do
response = subject.trigger(params)
expect(response[:response_type]).to eq :ephemeral
@@ -53,40 +53,40 @@ RSpec.shared_examples 'chat slash commands service' do
end
end
- context 'when an auth url can be generated' do
+ context "when an auth url can be generated" do
let(:params) do
{
- team_domain: 'http://domain.tld',
- team_id: 'T3423423',
- user_id: 'U234234',
- user_name: 'mepmep',
- token: 'token'
+ team_domain: "http://domain.tld",
+ team_id: "T3423423",
+ user_id: "U234234",
+ user_name: "mepmep",
+ token: "token",
}
end
let(:service) do
project.create_mattermost_slash_commands_service(
- properties: { token: 'token' }
+ properties: {token: "token"}
)
end
- it 'generates the url' do
+ it "generates the url" do
response = service.trigger(params)
- expect(response[:text]).to start_with(':wave: Hi there!')
+ expect(response[:text]).to start_with(":wave: Hi there!")
end
end
end
- context 'when the user is authenticated' do
+ context "when the user is authenticated" do
let!(:chat_name) { create(:chat_name, service: subject) }
- let(:params) { { token: 'token', team_id: chat_name.team_id, user_id: chat_name.chat_id } }
+ let(:params) { {token: "token", team_id: chat_name.team_id, user_id: chat_name.chat_id} }
subject do
- described_class.create(project: project, properties: { token: 'token' })
+ described_class.create(project: project, properties: {token: "token"})
end
- it 'triggers the command' do
+ it "triggers the command" do
expect_any_instance_of(Gitlab::SlashCommands::Command).to receive(:execute)
subject.trigger(params)
diff --git a/spec/support/shared_examples/ci_trace_shared_examples.rb b/spec/support/shared_examples/ci_trace_shared_examples.rb
index c603421d748..82170c03b78 100644
--- a/spec/support/shared_examples/ci_trace_shared_examples.rb
+++ b/spec/support/shared_examples/ci_trace_shared_examples.rb
@@ -1,5 +1,5 @@
-shared_examples_for 'common trace features' do
- describe '#html' do
+shared_examples_for "common trace features" do
+ describe "#html" do
before do
trace.set("12\n34")
end
@@ -13,7 +13,7 @@ shared_examples_for 'common trace features' do
end
end
- describe '#raw' do
+ describe "#raw" do
before do
trace.set("12\n34")
end
@@ -27,12 +27,12 @@ shared_examples_for 'common trace features' do
end
end
- describe '#extract_coverage' do
+ describe "#extract_coverage" do
let(:regex) { '\(\d+.\d+\%\) covered' }
- context 'matching coverage' do
+ context "matching coverage" do
before do
- trace.set('Coverage 1033 / 1051 LOC (98.29%) covered')
+ trace.set("Coverage 1033 / 1051 LOC (98.29%) covered")
end
it "returns valid coverage" do
@@ -40,50 +40,50 @@ shared_examples_for 'common trace features' do
end
end
- context 'no coverage' do
+ context "no coverage" do
before do
- trace.set('No coverage')
+ trace.set("No coverage")
end
- it 'returs nil' do
+ it "returs nil" do
expect(trace.extract_coverage(regex)).to be_nil
end
end
end
- describe '#extract_sections' do
- let(:log) { 'No sections' }
+ describe "#extract_sections" do
+ let(:log) { "No sections" }
let(:sections) { trace.extract_sections }
before do
trace.set(log)
end
- context 'no sections' do
- it 'returs []' do
+ context "no sections" do
+ it "returs []" do
expect(trace.extract_sections).to eq([])
end
end
- context 'multiple sections available' do
- let(:log) { File.read(expand_fixture_path('trace/trace_with_sections')) }
+ context "multiple sections available" do
+ let(:log) { File.read(expand_fixture_path("trace/trace_with_sections")) }
let(:sections_data) do
[
- { name: 'prepare_script', lines: 2, duration: 3.seconds },
- { name: 'get_sources', lines: 4, duration: 1.second },
- { name: 'restore_cache', lines: 0, duration: 0.seconds },
- { name: 'download_artifacts', lines: 0, duration: 0.seconds },
- { name: 'build_script', lines: 2, duration: 1.second },
- { name: 'after_script', lines: 0, duration: 0.seconds },
- { name: 'archive_cache', lines: 0, duration: 0.seconds },
- { name: 'upload_artifacts', lines: 0, duration: 0.seconds }
+ {name: "prepare_script", lines: 2, duration: 3.seconds},
+ {name: "get_sources", lines: 4, duration: 1.second},
+ {name: "restore_cache", lines: 0, duration: 0.seconds},
+ {name: "download_artifacts", lines: 0, duration: 0.seconds},
+ {name: "build_script", lines: 2, duration: 1.second},
+ {name: "after_script", lines: 0, duration: 0.seconds},
+ {name: "archive_cache", lines: 0, duration: 0.seconds},
+ {name: "upload_artifacts", lines: 0, duration: 0.seconds},
]
end
it "returns valid sections" do
expect(sections).not_to be_empty
expect(sections.size).to eq(sections_data.size),
- "expected #{sections_data.size} sections, got #{sections.size}"
+ "expected #{sections_data.size} sections, got #{sections.size}"
buff = StringIO.new(log)
sections.each_with_index do |s, i|
@@ -108,12 +108,12 @@ shared_examples_for 'common trace features' do
expect(sections.size).to eq(1)
section = sections[0]
- expect(section[:name]).to eq('a_section')
+ expect(section[:name]).to eq("a_section")
expect(section[:byte_start]).not_to eq(section[:byte_end]), "got an empty section"
end
end
- context 'missing section_end' do
+ context "missing section_end" do
let(:log) { "section_start:1506417476:a_section\r\033[0KSome logs\nNo section_end\n"}
it "returns no sections" do
@@ -121,7 +121,7 @@ shared_examples_for 'common trace features' do
end
end
- context 'missing section_start' do
+ context "missing section_start" do
let(:log) { "Some logs\nNo section_start\nsection_end:1506417476:a_section\r\033[0K"}
it "returns no sections" do
@@ -129,7 +129,7 @@ shared_examples_for 'common trace features' do
end
end
- context 'inverted section_start section_end' do
+ context "inverted section_start section_end" do
let(:log) { "section_end:1506417476:a_section\r\033[0Klooks like a section_start:invalid\nsection_start:1506417477:a_section\r\033[0K"}
it "returns no sections" do
@@ -138,29 +138,29 @@ shared_examples_for 'common trace features' do
end
end
- describe '#write' do
+ describe "#write" do
subject { trace.send(:write, mode) { } }
- let(:mode) { 'wb' }
+ let(:mode) { "wb" }
- context 'when arhicved trace does not exist yet' do
- it 'does not raise an error' do
+ context "when arhicved trace does not exist yet" do
+ it "does not raise an error" do
expect { subject }.not_to raise_error
end
end
- context 'when arhicved trace already exists' do
+ context "when arhicved trace already exists" do
before do
create(:ci_job_artifact, :trace, job: build)
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(Gitlab::Ci::Trace::AlreadyArchivedError)
end
end
end
- describe '#set' do
+ describe "#set" do
before do
trace.set("12")
end
@@ -169,7 +169,7 @@ shared_examples_for 'common trace features' do
expect(trace.raw).to eq("12")
end
- context 'overwrite trace' do
+ context "overwrite trace" do
before do
trace.set("34")
end
@@ -179,7 +179,7 @@ shared_examples_for 'common trace features' do
end
end
- context 'runners token' do
+ context "runners token" do
let(:token) { build.project.runners_token }
before do
@@ -191,7 +191,7 @@ shared_examples_for 'common trace features' do
end
end
- context 'hides build token' do
+ context "hides build token" do
let(:token) { build.token }
before do
@@ -204,7 +204,7 @@ shared_examples_for 'common trace features' do
end
end
- describe '#append' do
+ describe "#append" do
before do
trace.set("1234")
end
@@ -214,15 +214,15 @@ shared_examples_for 'common trace features' do
expect(trace.raw).to eq("123456")
end
- context 'tries to append trace at different offset' do
+ context "tries to append trace at different offset" do
it "fails with append" do
expect(trace.append("56", 2)).to eq(4)
expect(trace.raw).to eq("1234")
end
end
- context 'runners token' do
- let(:token) { 'my_secret_token' }
+ context "runners token" do
+ let(:token) { "my_secret_token" }
before do
build.project.update(runners_token: token)
@@ -234,8 +234,8 @@ shared_examples_for 'common trace features' do
end
end
- context 'build token' do
- let(:token) { 'my_secret_token' }
+ context "build token" do
+ let(:token) { "my_secret_token" }
before do
build.update(token: token)
@@ -248,32 +248,32 @@ shared_examples_for 'common trace features' do
end
end
- describe '#archive!' do
+ describe "#archive!" do
subject { trace.archive! }
- context 'when build status is success' do
+ context "when build status is success" do
let!(:build) { create(:ci_build, :success, :trace_live) }
- it 'does not have an archived trace yet' do
+ it "does not have an archived trace yet" do
expect(build.job_artifacts_trace).to be_nil
end
- context 'when archives' do
- it 'has an archived trace' do
+ context "when archives" do
+ it "has an archived trace" do
subject
build.reload
expect(build.job_artifacts_trace).to be_exist
end
- context 'when another process has already been archiving', :clean_gitlab_redis_shared_state do
+ context "when another process has already been archiving", :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
before do
stub_exclusive_lease_taken("trace:write:lock:#{trace.job.id}", timeout: 1.minute)
end
- it 'blocks concurrent archiving' do
+ it "blocks concurrent archiving" do
expect { subject }.to raise_error(::Gitlab::ExclusiveLeaseHelpers::FailedToObtainLockError)
end
end
@@ -282,12 +282,12 @@ shared_examples_for 'common trace features' do
end
end
-shared_examples_for 'trace with disabled live trace feature' do
- it_behaves_like 'common trace features'
+shared_examples_for "trace with disabled live trace feature" do
+ it_behaves_like "common trace features"
- describe '#read' do
- shared_examples 'read successfully with IO' do
- it 'yields with source' do
+ describe "#read" do
+ shared_examples "read successfully with IO" do
+ it "yields with source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_a(IO)
@@ -295,8 +295,8 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- shared_examples 'read successfully with StringIO' do
- it 'yields with source' do
+ shared_examples "read successfully with StringIO" do
+ it "yields with source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_a(StringIO)
@@ -304,8 +304,8 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- shared_examples 'failed to read' do
- it 'yields without source' do
+ shared_examples "failed to read" do
+ it "yields without source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_nil
@@ -313,71 +313,71 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'when trace artifact exists' do
+ context "when trace artifact exists" do
before do
create(:ci_job_artifact, :trace, job: build)
end
- it_behaves_like 'read successfully with IO'
+ it_behaves_like "read successfully with IO"
end
- context 'when current_path (with project_id) exists' do
+ context "when current_path (with project_id) exists" do
before do
- expect(trace).to receive(:default_path) { expand_fixture_path('trace/sample_trace') }
+ expect(trace).to receive(:default_path) { expand_fixture_path("trace/sample_trace") }
end
- it_behaves_like 'read successfully with IO'
+ it_behaves_like "read successfully with IO"
end
- context 'when current_path (with project_ci_id) exists' do
+ context "when current_path (with project_ci_id) exists" do
before do
- expect(trace).to receive(:deprecated_path) { expand_fixture_path('trace/sample_trace') }
+ expect(trace).to receive(:deprecated_path) { expand_fixture_path("trace/sample_trace") }
end
- it_behaves_like 'read successfully with IO'
+ it_behaves_like "read successfully with IO"
end
- context 'when db trace exists' do
+ context "when db trace exists" do
before do
build.send(:write_attribute, :trace, "data")
end
- it_behaves_like 'read successfully with StringIO'
+ it_behaves_like "read successfully with StringIO"
end
- context 'when no sources exist' do
- it_behaves_like 'failed to read'
+ context "when no sources exist" do
+ it_behaves_like "failed to read"
end
end
- describe 'trace handling' do
+ describe "trace handling" do
subject { trace.exist? }
- context 'trace does not exist' do
+ context "trace does not exist" do
it { expect(trace.exist?).to be(false) }
end
- context 'when trace artifact exists' do
+ context "when trace artifact exists" do
before do
create(:ci_job_artifact, :trace, job: build)
end
it { is_expected.to be_truthy }
- context 'when the trace artifact has been erased' do
+ context "when the trace artifact has been erased" do
before do
trace.erase!
end
it { is_expected.to be_falsy }
- it 'removes associations' do
+ it "removes associations" do
expect(Ci::JobArtifact.exists?(job_id: build.id, file_type: :trace)).to be_falsy
end
end
end
- context 'new trace path is used' do
+ context "new trace path is used" do
before do
trace.send(:ensure_directory)
@@ -396,10 +396,10 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'deprecated path' do
+ context "deprecated path" do
let(:path) { trace.send(:deprecated_path) }
- context 'with valid ci_id' do
+ context "with valid ci_id" do
before do
build.project.update(ci_id: 1000)
@@ -420,14 +420,14 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'without valid ci_id' do
+ context "without valid ci_id" do
it "does not return deprecated path" do
expect(path).to be_nil
end
end
end
- context 'stored in database' do
+ context "stored in database" do
before do
build.send(:write_attribute, :trace, "data")
end
@@ -447,17 +447,17 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- describe '#archive!' do
+ describe "#archive!" do
subject { trace.archive! }
- shared_examples 'archive trace file' do
+ shared_examples "archive trace file" do
it do
expect { subject }.to change { Ci::JobArtifact.count }.by(1)
build.reload
expect(build.trace.exist?).to be_truthy
expect(build.job_artifacts_trace.file.exists?).to be_truthy
- expect(build.job_artifacts_trace.file.filename).to eq('job.log')
+ expect(build.job_artifacts_trace.file.filename).to eq("job.log")
expect(File.exist?(src_path)).to be_falsy
expect(src_checksum)
.to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).hexdigest)
@@ -465,7 +465,7 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- shared_examples 'source trace file stays intact' do |error:|
+ shared_examples "source trace file stays intact" do |error:|
it do
expect { subject }.to raise_error(error)
@@ -476,14 +476,14 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- shared_examples 'archive trace in database' do
+ shared_examples "archive trace in database" do
it do
expect { subject }.to change { Ci::JobArtifact.count }.by(1)
build.reload
expect(build.trace.exist?).to be_truthy
expect(build.job_artifacts_trace.file.exists?).to be_truthy
- expect(build.job_artifacts_trace.file.filename).to eq('job.log')
+ expect(build.job_artifacts_trace.file.filename).to eq("job.log")
expect(build.old_trace).to be_nil
expect(src_checksum)
.to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).hexdigest)
@@ -491,7 +491,7 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- shared_examples 'source trace in database stays intact' do |error:|
+ shared_examples "source trace in database stays intact" do |error:|
it do
expect { subject }.to raise_error(error)
@@ -502,63 +502,63 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'when job does not have trace artifact' do
- context 'when trace file stored in default path' do
+ context "when job does not have trace artifact" do
+ context "when trace file stored in default path" do
let!(:build) { create(:ci_build, :success, :trace_live) }
let!(:src_path) { trace.read { |s| s.path } }
let!(:src_checksum) { Digest::SHA256.file(src_path).hexdigest }
- it_behaves_like 'archive trace file'
+ it_behaves_like "archive trace file"
- context 'when failed to create clone file' do
+ context "when failed to create clone file" do
before do
allow(IO).to receive(:copy_stream).and_return(0)
end
- it_behaves_like 'source trace file stays intact', error: Gitlab::Ci::Trace::ArchiveError
+ it_behaves_like "source trace file stays intact", error: Gitlab::Ci::Trace::ArchiveError
end
- context 'when failed to create job artifact record' do
+ context "when failed to create job artifact record" do
before do
allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false)
allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages)
.and_return(%w[Error Error])
end
- it_behaves_like 'source trace file stays intact', error: ActiveRecord::RecordInvalid
+ it_behaves_like "source trace file stays intact", error: ActiveRecord::RecordInvalid
end
end
- context 'when trace is stored in database' do
+ context "when trace is stored in database" do
let(:build) { create(:ci_build, :success) }
- let(:trace_content) { 'Sample trace' }
+ let(:trace_content) { "Sample trace" }
let(:src_checksum) { Digest::SHA256.hexdigest(trace_content) }
before do
build.update_column(:trace, trace_content)
end
- it_behaves_like 'archive trace in database'
+ it_behaves_like "archive trace in database"
- context 'when failed to create clone file' do
+ context "when failed to create clone file" do
before do
allow(IO).to receive(:copy_stream).and_return(0)
end
- it_behaves_like 'source trace in database stays intact', error: Gitlab::Ci::Trace::ArchiveError
+ it_behaves_like "source trace in database stays intact", error: Gitlab::Ci::Trace::ArchiveError
end
- context 'when failed to create job artifact record' do
+ context "when failed to create job artifact record" do
before do
allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false)
allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages)
.and_return(%w[Error Error])
end
- it_behaves_like 'source trace in database stays intact', error: ActiveRecord::RecordInvalid
+ it_behaves_like "source trace in database stays intact", error: ActiveRecord::RecordInvalid
end
- context 'when there is a validation error on Ci::Build' do
+ context "when there is a validation error on Ci::Build" do
before do
allow_any_instance_of(Ci::Build).to receive(:save).and_return(false)
allow_any_instance_of(Ci::Build).to receive_message_chain(:errors, :full_messages)
@@ -571,49 +571,49 @@ shared_examples_for 'trace with disabled live trace feature' do
build.save
end
- it 'old trace is not deleted' do
+ it "old trace is not deleted" do
build.reload
expect(build.trace.raw).to eq(trace_content)
end
end
- it_behaves_like 'archive trace in database'
+ it_behaves_like "archive trace in database"
end
end
end
- context 'when job has trace artifact' do
+ context "when job has trace artifact" do
before do
create(:ci_job_artifact, :trace, job: build)
end
- it 'does not archive' do
+ it "does not archive" do
expect_any_instance_of(described_class).not_to receive(:archive_stream!)
expect { subject }.to raise_error(Gitlab::Ci::Trace::AlreadyArchivedError)
expect(build.job_artifacts_trace.file.exists?).to be_truthy
end
end
- context 'when job is not finished yet' do
+ context "when job is not finished yet" do
let!(:build) { create(:ci_build, :running, :trace_live) }
- it 'does not archive' do
+ it "does not archive" do
expect_any_instance_of(described_class).not_to receive(:archive_stream!)
- expect { subject }.to raise_error('Job is not finished yet')
+ expect { subject }.to raise_error("Job is not finished yet")
expect(build.trace.exist?).to be_truthy
end
end
end
- describe '#erase!' do
+ describe "#erase!" do
subject { trace.erase! }
- context 'when it is a live trace' do
- context 'when trace is stored in database' do
+ context "when it is a live trace" do
+ context "when trace is stored in database" do
let(:build) { create(:ci_build) }
before do
- build.update_column(:trace, 'sample trace')
+ build.update_column(:trace, "sample trace")
end
it { expect(trace.raw).not_to be_nil }
@@ -625,7 +625,7 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'when trace is stored in file storage' do
+ context "when trace is stored in file storage" do
let(:build) { create(:ci_build, :trace_live) }
it { expect(trace.raw).not_to be_nil }
@@ -638,7 +638,7 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
- context 'when it is an archived trace' do
+ context "when it is an archived trace" do
let(:build) { create(:ci_build, :trace_artifact) }
it "has trace at first" do
@@ -655,12 +655,12 @@ shared_examples_for 'trace with disabled live trace feature' do
end
end
-shared_examples_for 'trace with enabled live trace feature' do
- it_behaves_like 'common trace features'
+shared_examples_for "trace with enabled live trace feature" do
+ it_behaves_like "common trace features"
- describe '#read' do
- shared_examples 'read successfully with IO' do
- it 'yields with source' do
+ describe "#read" do
+ shared_examples "read successfully with IO" do
+ it "yields with source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_a(IO)
@@ -668,8 +668,8 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- shared_examples 'read successfully with ChunkedIO' do
- it 'yields with source' do
+ shared_examples "read successfully with ChunkedIO" do
+ it "yields with source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_a(Gitlab::Ci::Trace::ChunkedIO)
@@ -677,8 +677,8 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- shared_examples 'failed to read' do
- it 'yields without source' do
+ shared_examples "failed to read" do
+ it "yields without source" do
trace.read do |stream|
expect(stream).to be_a(Gitlab::Ci::Trace::Stream)
expect(stream.stream).to be_nil
@@ -686,60 +686,60 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- context 'when trace artifact exists' do
+ context "when trace artifact exists" do
before do
create(:ci_job_artifact, :trace, job: build)
end
- it_behaves_like 'read successfully with IO'
+ it_behaves_like "read successfully with IO"
end
- context 'when live trace exists' do
+ context "when live trace exists" do
before do
Gitlab::Ci::Trace::ChunkedIO.new(build) do |stream|
- stream.write('abc')
+ stream.write("abc")
end
end
- it_behaves_like 'read successfully with ChunkedIO'
+ it_behaves_like "read successfully with ChunkedIO"
end
- context 'when no sources exist' do
- it_behaves_like 'failed to read'
+ context "when no sources exist" do
+ it_behaves_like "failed to read"
end
end
- describe 'trace handling' do
+ describe "trace handling" do
subject { trace.exist? }
- context 'trace does not exist' do
+ context "trace does not exist" do
it { expect(trace.exist?).to be(false) }
end
- context 'when trace artifact exists' do
+ context "when trace artifact exists" do
before do
create(:ci_job_artifact, :trace, job: build)
end
it { is_expected.to be_truthy }
- context 'when the trace artifact has been erased' do
+ context "when the trace artifact has been erased" do
before do
trace.erase!
end
it { is_expected.to be_falsy }
- it 'removes associations' do
+ it "removes associations" do
expect(Ci::JobArtifact.exists?(job_id: build.id, file_type: :trace)).to be_falsy
end
end
end
- context 'stored in live trace' do
+ context "stored in live trace" do
before do
Gitlab::Ci::Trace::ChunkedIO.new(build) do |stream|
- stream.write('abc')
+ stream.write("abc")
end
end
@@ -759,17 +759,17 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- describe '#archive!' do
+ describe "#archive!" do
subject { trace.archive! }
- shared_examples 'archive trace file in ChunkedIO' do
+ shared_examples "archive trace file in ChunkedIO" do
it do
expect { subject }.to change { Ci::JobArtifact.count }.by(1)
build.reload
expect(build.trace.exist?).to be_truthy
expect(build.job_artifacts_trace.file.exists?).to be_truthy
- expect(build.job_artifacts_trace.file.filename).to eq('job.log')
+ expect(build.job_artifacts_trace.file.filename).to eq("job.log")
expect(Ci::BuildTraceChunk.where(build: build)).not_to be_exist
expect(src_checksum)
.to eq(Digest::SHA256.file(build.job_artifacts_trace.file.path).hexdigest)
@@ -777,7 +777,7 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- shared_examples 'source trace in ChunkedIO stays intact' do |error:|
+ shared_examples "source trace in ChunkedIO stays intact" do |error:|
it do
expect { subject }.to raise_error(error)
@@ -790,61 +790,61 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- context 'when job does not have trace artifact' do
- context 'when trace is stored in ChunkedIO' do
+ context "when job does not have trace artifact" do
+ context "when trace is stored in ChunkedIO" do
let!(:build) { create(:ci_build, :success, :trace_live) }
let!(:trace_raw) { build.trace.raw }
let!(:src_checksum) { Digest::SHA256.hexdigest(trace_raw) }
- it_behaves_like 'archive trace file in ChunkedIO'
+ it_behaves_like "archive trace file in ChunkedIO"
- context 'when failed to create clone file' do
+ context "when failed to create clone file" do
before do
allow(IO).to receive(:copy_stream).and_return(0)
end
- it_behaves_like 'source trace in ChunkedIO stays intact', error: Gitlab::Ci::Trace::ArchiveError
+ it_behaves_like "source trace in ChunkedIO stays intact", error: Gitlab::Ci::Trace::ArchiveError
end
- context 'when failed to create job artifact record' do
+ context "when failed to create job artifact record" do
before do
allow_any_instance_of(Ci::JobArtifact).to receive(:save).and_return(false)
allow_any_instance_of(Ci::JobArtifact).to receive_message_chain(:errors, :full_messages)
.and_return(%w[Error Error])
end
- it_behaves_like 'source trace in ChunkedIO stays intact', error: ActiveRecord::RecordInvalid
+ it_behaves_like "source trace in ChunkedIO stays intact", error: ActiveRecord::RecordInvalid
end
end
end
- context 'when job has trace artifact' do
+ context "when job has trace artifact" do
before do
create(:ci_job_artifact, :trace, job: build)
end
- it 'does not archive' do
+ it "does not archive" do
expect_any_instance_of(described_class).not_to receive(:archive_stream!)
expect { subject }.to raise_error(Gitlab::Ci::Trace::AlreadyArchivedError)
expect(build.job_artifacts_trace.file.exists?).to be_truthy
end
end
- context 'when job is not finished yet' do
+ context "when job is not finished yet" do
let!(:build) { create(:ci_build, :running, :trace_live) }
- it 'does not archive' do
+ it "does not archive" do
expect_any_instance_of(described_class).not_to receive(:archive_stream!)
- expect { subject }.to raise_error('Job is not finished yet')
+ expect { subject }.to raise_error("Job is not finished yet")
expect(build.trace.exist?).to be_truthy
end
end
end
- describe '#erase!' do
+ describe "#erase!" do
subject { trace.erase! }
- context 'when it is a live trace' do
+ context "when it is a live trace" do
let(:build) { create(:ci_build, :trace_live) }
it { expect(trace.raw).not_to be_nil }
@@ -856,7 +856,7 @@ shared_examples_for 'trace with enabled live trace feature' do
end
end
- context 'when it is an archived trace' do
+ context "when it is an archived trace" do
let(:build) { create(:ci_build, :trace_artifact) }
it "has trace at first" do
diff --git a/spec/support/shared_examples/common_system_notes_examples.rb b/spec/support/shared_examples/common_system_notes_examples.rb
index da5a4f3e319..50c459bd2cd 100644
--- a/spec/support/shared_examples/common_system_notes_examples.rb
+++ b/spec/support/shared_examples/common_system_notes_examples.rb
@@ -1,4 +1,4 @@
-shared_examples 'system note creation' do |update_params, note_text|
+shared_examples "system note creation" do |update_params, note_text|
subject { described_class.new(project, user).execute(issuable, old_labels: []) }
before do
@@ -6,7 +6,7 @@ shared_examples 'system note creation' do |update_params, note_text|
issuable.save
end
- it 'creates 1 system note with the correct content' do
+ it "creates 1 system note with the correct content" do
expect { subject }.to change { Note.count }.from(0).to(1)
note = Note.last
@@ -15,13 +15,13 @@ shared_examples 'system note creation' do |update_params, note_text|
end
end
-shared_examples 'WIP notes creation' do |wip_action|
+shared_examples "WIP notes creation" do |wip_action|
subject { described_class.new(project, user).execute(issuable, old_labels: []) }
- it 'creates WIP toggle and title change notes' do
+ it "creates WIP toggle and title change notes" do
expect { subject }.to change { Note.count }.from(0).to(2)
expect(Note.first.note).to match("#{wip_action} as a **Work In Progress**")
- expect(Note.second.note).to match('changed title')
+ expect(Note.second.note).to match("changed title")
end
end
diff --git a/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb b/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb
index 0acc9e2a836..9a2d90c5342 100644
--- a/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb
@@ -1,13 +1,13 @@
-shared_examples 'issuable notes filter' do
+shared_examples "issuable notes filter" do
let(:params) do
if issuable_parent.is_a?(Project)
- { namespace_id: issuable_parent.namespace, project_id: issuable_parent, id: issuable.iid }
+ {namespace_id: issuable_parent.namespace, project_id: issuable_parent, id: issuable.iid}
else
- { group_id: issuable_parent, id: issuable.to_param }
+ {group_id: issuable_parent, id: issuable.to_param}
end
end
- it 'sets discussion filter' do
+ it "sets discussion filter" do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
get :discussions, params: params.merge(notes_filter: notes_filter)
@@ -16,7 +16,7 @@ shared_examples 'issuable notes filter' do
expect(UserPreference.count).to eq(1)
end
- it 'expires notes e-tag cache for issuable if filter changed' do
+ it "expires notes e-tag cache for issuable if filter changed" do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
expect_any_instance_of(issuable.class).to receive(:expire_note_etag_cache)
@@ -24,7 +24,7 @@ shared_examples 'issuable notes filter' do
get :discussions, params: params.merge(notes_filter: notes_filter)
end
- it 'does not expires notes e-tag cache for issuable if filter did not change' do
+ it "does not expires notes e-tag cache for issuable if filter did not change" do
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
user.set_notes_filter(notes_filter, issuable)
@@ -33,7 +33,7 @@ shared_examples 'issuable notes filter' do
get :discussions, params: params.merge(notes_filter: notes_filter)
end
- it 'does not set notes filter when database is in read only mode' do
+ it "does not set notes filter when database is in read only mode" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
notes_filter = UserPreference::NOTES_FILTERS[:only_comments]
@@ -42,7 +42,7 @@ shared_examples 'issuable notes filter' do
expect(user.reload.notes_filter_for(issuable)).to eq(0)
end
- it 'returns only user comments' do
+ it "returns only user comments" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issuable)
get :discussions, params: params
@@ -52,7 +52,7 @@ shared_examples 'issuable notes filter' do
expect(discussions.first["notes"].first["system"]).to be(false)
end
- it 'returns only activity notes' do
+ it "returns only activity notes" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_activity], issuable)
get :discussions, params: params
@@ -63,7 +63,7 @@ shared_examples 'issuable notes filter' do
end
context 'when filter is set to "only_comments"' do
- it 'does not merge label event notes' do
+ it "does not merge label event notes" do
user.set_notes_filter(UserPreference::NOTES_FILTERS[:only_comments], issuable)
expect(ResourceEvents::MergeIntoNotesService).not_to receive(:new)
diff --git a/spec/support/shared_examples/controllers/repository_lfs_file_load_examples.rb b/spec/support/shared_examples/controllers/repository_lfs_file_load_examples.rb
index 982e0317f7f..6d26dec88c8 100644
--- a/spec/support/shared_examples/controllers/repository_lfs_file_load_examples.rb
+++ b/spec/support/shared_examples/controllers/repository_lfs_file_load_examples.rb
@@ -9,39 +9,40 @@
# - `filepath`: path of the file (contains filename)
# - `subject`: the request to be made to the controller. Example:
# subject { get :show, namespace_id: project.namespace, project_id: project }
-shared_examples 'repository lfs file load' do
- context 'when file is stored in lfs' do
- let(:lfs_oid) { '91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' }
- let(:lfs_size) { '1575078' }
+shared_examples "repository lfs file load" do
+ context "when file is stored in lfs" do
+ let(:lfs_oid) { "91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897" }
+ let(:lfs_size) { "1575078" }
let!(:lfs_object) { create(:lfs_object, oid: lfs_oid, size: lfs_size) }
- context 'when lfs is enabled' do
+ context "when lfs is enabled" do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true)
end
- context 'when project has access' do
+ context "when project has access" do
before do
project.lfs_objects << lfs_object
allow_any_instance_of(LfsObjectUploader).to receive(:exists?).and_return(true)
allow(controller).to receive(:send_file) { controller.head :ok }
end
- it 'serves the file' do
+ it "serves the file" do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expect(controller).to receive(:send_file)
- .with(
- "#{LfsObjectUploader.root}/91/ef/f75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
- filename: filename,
- disposition: %Q(attachment; filename*=UTF-8''#{filename}))
+ .with(
+ "#{LfsObjectUploader.root}/91/ef/f75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897",
+ filename: filename,
+ disposition: %(attachment; filename*=UTF-8''#{filename})
+ )
subject
expect(response).to have_gitlab_http_status(200)
end
- context 'and lfs uses object storage' do
+ context "and lfs uses object storage" do
let(:lfs_object) { create(:lfs_object, :with_file, oid: lfs_oid, size: lfs_size) }
before do
@@ -49,14 +50,14 @@ shared_examples 'repository lfs file load' do
lfs_object.file.migrate!(LfsObjectUploader::Store::REMOTE)
end
- it 'responds with redirect to file' do
+ it "responds with redirect to file" do
subject
expect(response).to have_gitlab_http_status(302)
expect(response.location).to include(lfs_object.reload.file.path)
end
- it 'sets content disposition' do
+ it "sets content disposition" do
subject
file_uri = URI.parse(response.location)
@@ -67,8 +68,8 @@ shared_examples 'repository lfs file load' do
end
end
- context 'when project does not have access' do
- it 'does not serve the file' do
+ context "when project does not have access" do
+ it "does not serve the file" do
subject
expect(response).to have_gitlab_http_status(404)
@@ -76,19 +77,19 @@ shared_examples 'repository lfs file load' do
end
end
- context 'when lfs is not enabled' do
+ context "when lfs is not enabled" do
before do
allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false)
end
- it 'delivers ASCII file' do
+ it "delivers ASCII file" do
subject
expect(response).to have_gitlab_http_status(200)
- expect(response.header['Content-Type']).to eq('text/plain; charset=utf-8')
- expect(response.header['Content-Disposition'])
- .to eq('inline')
- expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with('git-blob:')
+ expect(response.header["Content-Type"]).to eq("text/plain; charset=utf-8")
+ expect(response.header["Content-Disposition"])
+ .to eq("inline")
+ expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-blob:")
end
end
end
diff --git a/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb b/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb
index 98ab04c5636..bdf6438f0c9 100644
--- a/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/set_sort_order_from_user_preference_shared_examples.rb
@@ -1,25 +1,25 @@
-shared_examples 'set sort order from user preference' do
- describe '#set_sort_order_from_user_preference' do
+shared_examples "set sort order from user preference" do
+ describe "#set_sort_order_from_user_preference" do
# There is no issuable_sorting_field defined in any CE controllers yet,
# however any other field present in user_preferences table can be used for testing.
- context 'when database is in read-only mode' do
- it 'it does not update user preference' do
+ context "when database is in read-only mode" do
+ it "it does not update user preference" do
allow(Gitlab::Database).to receive(:read_only?).and_return(true)
- expect_any_instance_of(UserPreference).not_to receive(:update).with({ controller.send(:issuable_sorting_field) => sorting_param })
+ expect_any_instance_of(UserPreference).not_to receive(:update).with({controller.send(:issuable_sorting_field) => sorting_param})
- get :index, params: { namespace_id: project.namespace, project_id: project, sort: sorting_param }
+ get :index, params: {namespace_id: project.namespace, project_id: project, sort: sorting_param}
end
end
- context 'when database is not in read-only mode' do
- it 'updates user preference' do
+ context "when database is not in read-only mode" do
+ it "updates user preference" do
allow(Gitlab::Database).to receive(:read_only?).and_return(false)
- expect_any_instance_of(UserPreference).to receive(:update).with({ controller.send(:issuable_sorting_field) => sorting_param })
+ expect_any_instance_of(UserPreference).to receive(:update).with({controller.send(:issuable_sorting_field) => sorting_param})
- get :index, params: { namespace_id: project.namespace, project_id: project, sort: sorting_param }
+ get :index, params: {namespace_id: project.namespace, project_id: project, sort: sorting_param}
end
end
end
diff --git a/spec/support/shared_examples/controllers/todos_shared_examples.rb b/spec/support/shared_examples/controllers/todos_shared_examples.rb
index bafd9bac8d0..8c2e1e5128a 100644
--- a/spec/support/shared_examples/controllers/todos_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/todos_shared_examples.rb
@@ -1,41 +1,41 @@
-shared_examples 'todos actions' do
- context 'when authorized' do
+shared_examples "todos actions" do
+ context "when authorized" do
before do
sign_in(user)
parent.add_developer(user)
end
- it 'creates todo' do
- expect do
+ it "creates todo" do
+ expect {
post_create
- end.to change { user.todos.count }.by(1)
+ }.to change { user.todos.count }.by(1)
expect(response).to have_gitlab_http_status(200)
end
- it 'returns todo path and pending count' do
+ it "returns todo path and pending count" do
post_create
expect(response).to have_gitlab_http_status(200)
- expect(json_response['count']).to eq 1
- expect(json_response['delete_path']).to match(%r{/dashboard/todos/\d{1}})
+ expect(json_response["count"]).to eq 1
+ expect(json_response["delete_path"]).to match(%r{/dashboard/todos/\d{1}})
end
end
- context 'when not authorized for project/group' do
- it 'does not create todo for resource that user has no access to' do
+ context "when not authorized for project/group" do
+ it "does not create todo for resource that user has no access to" do
sign_in(user)
- expect do
+ expect {
post_create
- end.to change { user.todos.count }.by(0)
+ }.to change { user.todos.count }.by(0)
expect(response).to have_gitlab_http_status(404)
end
- it 'does not create todo when user is not logged in' do
- expect do
+ it "does not create todo when user is not logged in" do
+ expect {
post_create
- end.to change { user.todos.count }.by(0)
+ }.to change { user.todos.count }.by(0)
expect(response).to have_gitlab_http_status(parent.is_a?(Group) ? 401 : 302)
end
diff --git a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
index 59708173716..cc0bf9f9bae 100644
--- a/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/uploads_actions_shared_examples.rb
@@ -1,19 +1,19 @@
-shared_examples 'handle uploads' do
+shared_examples "handle uploads" do
let(:user) { create(:user) }
- let(:jpg) { fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg') }
- let(:txt) { fixture_file_upload('spec/fixtures/doc_sample.txt', 'text/plain') }
+ let(:jpg) { fixture_file_upload("spec/fixtures/rails_sample.jpg", "image/jpg") }
+ let(:txt) { fixture_file_upload("spec/fixtures/doc_sample.txt", "text/plain") }
let(:secret) { FileUploader.generate_secret }
let(:uploader_class) { FileUploader }
describe "POST #create" do
- context 'when a user is not authorized to upload a file' do
- it 'returns 404 status' do
+ context "when a user is not authorized to upload a file" do
+ it "returns 404 status" do
post :create, params: params.merge(file: jpg), format: :json
expect(response.status).to eq(404)
end
end
- context 'when a user can upload a file' do
+ context "when a user can upload a file" do
before do
sign_in(user)
model.add_developer(user)
@@ -27,12 +27,12 @@ shared_examples 'handle uploads' do
end
end
- context 'with valid image' do
+ context "with valid image" do
before do
post :create, params: params.merge(file: jpg), format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
expect(response.body).to match '\"alt\":\"rails_sample\"'
expect(response.body).to match "\"url\":\"/uploads"
end
@@ -41,7 +41,7 @@ shared_examples 'handle uploads' do
# behavior. We're avoiding a proper Feature test because those should be
# testing things entirely user-facing, which the Upload model is very much
# not.
- it 'creates a corresponding Upload record' do
+ it "creates a corresponding Upload record" do
upload = Upload.last
aggregate_failures do
@@ -51,12 +51,12 @@ shared_examples 'handle uploads' do
end
end
- context 'with valid non-image file' do
+ context "with valid non-image file" do
before do
post :create, params: params.merge(file: txt), format: :json
end
- it 'returns a content with original filename, new link, and correct type.' do
+ it "returns a content with original filename, new link, and correct type." do
expect(response.body).to match '\"alt\":\"doc_sample.txt\"'
expect(response.body).to match "\"url\":\"/uploads"
end
@@ -261,78 +261,78 @@ shared_examples 'handle uploads' do
end
describe "POST #authorize" do
- context 'when a user is not authorized to upload a file' do
- it 'returns 404 status' do
+ context "when a user is not authorized to upload a file" do
+ it "returns 404 status" do
post_authorize
expect(response.status).to eq(404)
end
end
- context 'when a user can upload a file' do
+ context "when a user can upload a file" do
before do
sign_in(user)
model.add_developer(user)
end
- context 'and the request bypassed workhorse' do
- it 'raises an exception' do
+ context "and the request bypassed workhorse" do
+ it "raises an exception" do
expect { post_authorize(verified: false) }.to raise_error JWT::DecodeError
end
end
- context 'and request is sent by gitlab-workhorse to authorize the request' do
- shared_examples 'a valid response' do
+ context "and request is sent by gitlab-workhorse to authorize the request" do
+ shared_examples "a valid response" do
before do
post_authorize
end
- it 'responds with status 200' do
+ it "responds with status 200" do
expect(response).to have_gitlab_http_status(200)
end
- it 'uses the gitlab-workhorse content type' do
+ it "uses the gitlab-workhorse content type" do
expect(response.headers["Content-Type"]).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE)
end
end
- shared_examples 'a local file' do
- it_behaves_like 'a valid response' do
- it 'responds with status 200, location of uploads store and object details' do
- expect(json_response['TempPath']).to eq(uploader_class.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to be_nil
+ shared_examples "a local file" do
+ it_behaves_like "a valid response" do
+ it "responds with status 200, location of uploads store and object details" do
+ expect(json_response["TempPath"]).to eq(uploader_class.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to be_nil
end
end
end
- context 'when using local storage' do
- it_behaves_like 'a local file'
+ context "when using local storage" do
+ it_behaves_like "a local file"
end
- context 'when using remote storage' do
- context 'when direct upload is enabled' do
+ context "when using remote storage" do
+ context "when direct upload is enabled" do
before do
stub_uploads_object_storage(uploader_class, direct_upload: true)
end
- it_behaves_like 'a valid response' do
- it 'responds with status 200, location of uploads remote store and object details' do
- expect(json_response['TempPath']).to eq(uploader_class.workhorse_local_upload_path)
- expect(json_response['RemoteObject']).to have_key('ID')
- expect(json_response['RemoteObject']).to have_key('GetURL')
- expect(json_response['RemoteObject']).to have_key('StoreURL')
- expect(json_response['RemoteObject']).to have_key('DeleteURL')
- expect(json_response['RemoteObject']).to have_key('MultipartUpload')
+ it_behaves_like "a valid response" do
+ it "responds with status 200, location of uploads remote store and object details" do
+ expect(json_response["TempPath"]).to eq(uploader_class.workhorse_local_upload_path)
+ expect(json_response["RemoteObject"]).to have_key("ID")
+ expect(json_response["RemoteObject"]).to have_key("GetURL")
+ expect(json_response["RemoteObject"]).to have_key("StoreURL")
+ expect(json_response["RemoteObject"]).to have_key("DeleteURL")
+ expect(json_response["RemoteObject"]).to have_key("MultipartUpload")
end
end
end
- context 'when direct upload is disabled' do
+ context "when direct upload is disabled" do
before do
stub_uploads_object_storage(uploader_class, direct_upload: false)
end
- it_behaves_like 'a local file'
+ it_behaves_like "a local file"
end
end
end
diff --git a/spec/support/shared_examples/controllers/variables_shared_examples.rb b/spec/support/shared_examples/controllers/variables_shared_examples.rb
index b615a8f54cf..4b1326879c4 100644
--- a/spec/support/shared_examples/controllers/variables_shared_examples.rb
+++ b/spec/support/shared_examples/controllers/variables_shared_examples.rb
@@ -1,123 +1,123 @@
-shared_examples 'GET #show lists all variables' do
- it 'renders the variables as json' do
+shared_examples "GET #show lists all variables" do
+ it "renders the variables as json" do
subject
- expect(response).to match_response_schema('variables')
+ expect(response).to match_response_schema("variables")
end
- it 'has only one variable' do
+ it "has only one variable" do
subject
- expect(json_response['variables'].count).to eq(1)
+ expect(json_response["variables"].count).to eq(1)
end
end
-shared_examples 'PATCH #update updates variables' do
+shared_examples "PATCH #update updates variables" do
let(:variable_attributes) do
- { id: variable.id,
- key: variable.key,
- secret_value: variable.value,
- protected: variable.protected?.to_s }
+ {id: variable.id,
+ key: variable.key,
+ secret_value: variable.value,
+ protected: variable.protected?.to_s,}
end
let(:new_variable_attributes) do
- { key: 'new_key',
- secret_value: 'dummy_value',
- protected: 'false' }
+ {key: "new_key",
+ secret_value: "dummy_value",
+ protected: "false",}
end
- context 'with invalid new variable parameters' do
+ context "with invalid new variable parameters" do
let(:variables_attributes) do
[
- variable_attributes.merge(secret_value: 'other_value'),
- new_variable_attributes.merge(key: '...?')
+ variable_attributes.merge(secret_value: "other_value"),
+ new_variable_attributes.merge(key: "...?"),
]
end
- it 'does not update the existing variable' do
+ it "does not update the existing variable" do
expect { subject }.not_to change { variable.reload.value }
end
- it 'does not create the new variable' do
+ it "does not create the new variable" do
expect { subject }.not_to change { owner.variables.count }
end
- it 'returns a bad request response' do
+ it "returns a bad request response" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'with duplicate new variable parameters' do
+ context "with duplicate new variable parameters" do
let(:variables_attributes) do
[
new_variable_attributes,
- new_variable_attributes.merge(secret_value: 'other_value')
+ new_variable_attributes.merge(secret_value: "other_value"),
]
end
- it 'does not update the existing variable' do
+ it "does not update the existing variable" do
expect { subject }.not_to change { variable.reload.value }
end
- it 'does not create the new variable' do
+ it "does not create the new variable" do
expect { subject }.not_to change { owner.variables.count }
end
- it 'returns a bad request response' do
+ it "returns a bad request response" do
subject
expect(response).to have_gitlab_http_status(:bad_request)
end
end
- context 'with valid new variable parameters' do
+ context "with valid new variable parameters" do
let(:variables_attributes) do
[
- variable_attributes.merge(secret_value: 'other_value'),
- new_variable_attributes
+ variable_attributes.merge(secret_value: "other_value"),
+ new_variable_attributes,
]
end
- it 'updates the existing variable' do
- expect { subject }.to change { variable.reload.value }.to('other_value')
+ it "updates the existing variable" do
+ expect { subject }.to change { variable.reload.value }.to("other_value")
end
- it 'creates the new variable' do
+ it "creates the new variable" do
expect { subject }.to change { owner.variables.count }.by(1)
end
- it 'returns a successful response' do
+ it "returns a successful response" do
subject
expect(response).to have_gitlab_http_status(:ok)
end
- it 'has all variables in response' do
+ it "has all variables in response" do
subject
- expect(response).to match_response_schema('variables')
+ expect(response).to match_response_schema("variables")
end
end
- context 'with a deleted variable' do
- let(:variables_attributes) { [variable_attributes.merge(_destroy: 'true')] }
+ context "with a deleted variable" do
+ let(:variables_attributes) { [variable_attributes.merge(_destroy: "true")] }
- it 'destroys the variable' do
+ it "destroys the variable" do
expect { subject }.to change { owner.variables.count }.by(-1)
expect { variable.reload }.to raise_error ActiveRecord::RecordNotFound
end
- it 'returns a successful response' do
+ it "returns a successful response" do
subject
expect(response).to have_gitlab_http_status(:ok)
end
- it 'has all variables in response' do
+ it "has all variables in response" do
subject
- expect(response).to match_response_schema('variables')
+ expect(response).to match_response_schema("variables")
end
end
end
diff --git a/spec/support/shared_examples/diff_file_collections.rb b/spec/support/shared_examples/diff_file_collections.rb
index 367ddf06c28..f8c4beae5a0 100644
--- a/spec/support/shared_examples/diff_file_collections.rb
+++ b/spec/support/shared_examples/diff_file_collections.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-shared_examples 'diff statistics' do |test_include_stats_flag: true|
+shared_examples "diff statistics" do |test_include_stats_flag: true|
def stub_stats_find_by_path(path, stats_mock)
expect_next_instance_of(Gitlab::Git::DiffStatsCollection) do |collection|
allow(collection).to receive(:find_by_path).and_call_original
@@ -8,8 +8,8 @@ shared_examples 'diff statistics' do |test_include_stats_flag: true|
end
end
- context 'when should request diff stats' do
- it 'Repository#diff_stats is called' do
+ context "when should request diff stats" do
+ it "Repository#diff_stats is called" do
subject = described_class.new(diffable, collection_default_args)
expect(diffable.project.repository)
@@ -20,10 +20,10 @@ shared_examples 'diff statistics' do |test_include_stats_flag: true|
subject.diff_files
end
- it 'Gitlab::Diff::File is initialized with diff stats' do
+ it "Gitlab::Diff::File is initialized with diff stats" do
subject = described_class.new(diffable, collection_default_args)
- stats_mock = double(Gitaly::DiffStats, path: '.gitignore', additions: 758, deletions: 120)
+ stats_mock = double(Gitaly::DiffStats, path: ".gitignore", additions: 758, deletions: 120)
stub_stats_find_by_path(stub_path, stats_mock)
diff_file = subject.diff_files.find { |file| file.new_path == stub_path }
@@ -33,8 +33,8 @@ shared_examples 'diff statistics' do |test_include_stats_flag: true|
end
end
- context 'when should not request diff stats' do
- it 'Repository#diff_stats is not called' do
+ context "when should not request diff stats" do
+ it "Repository#diff_stats is not called" do
collection_default_args[:diff_options][:include_stats] = false
subject = described_class.new(diffable, collection_default_args)
@@ -46,13 +46,13 @@ shared_examples 'diff statistics' do |test_include_stats_flag: true|
end
end
-shared_examples 'unfoldable diff' do
+shared_examples "unfoldable diff" do
let(:subject) { described_class.new(diffable, diff_options: nil) }
- it 'calls Gitlab::Diff::File#unfold_diff_lines with correct position' do
- position = instance_double(Gitlab::Diff::Position, file_path: 'README')
- readme_file = instance_double(Gitlab::Diff::File, file_path: 'README')
- other_file = instance_double(Gitlab::Diff::File, file_path: 'foo.rb')
+ it "calls Gitlab::Diff::File#unfold_diff_lines with correct position" do
+ position = instance_double(Gitlab::Diff::Position, file_path: "README")
+ readme_file = instance_double(Gitlab::Diff::File, file_path: "README")
+ other_file = instance_double(Gitlab::Diff::File, file_path: "foo.rb")
nil_path_file = instance_double(Gitlab::Diff::File, file_path: nil)
allow(subject).to receive(:diff_files) { [readme_file, other_file, nil_path_file] }
diff --git a/spec/support/shared_examples/dirty_submit_form_shared_examples.rb b/spec/support/shared_examples/dirty_submit_form_shared_examples.rb
index 52a2ee49495..031a8224ed4 100644
--- a/spec/support/shared_examples/dirty_submit_form_shared_examples.rb
+++ b/spec/support/shared_examples/dirty_submit_form_shared_examples.rb
@@ -1,8 +1,8 @@
-shared_examples 'dirty submit form' do |selector_args|
+shared_examples "dirty submit form" do |selector_args|
selectors = selector_args.is_a?(Array) ? selector_args : [selector_args]
def expect_disabled_state(form, submit, is_disabled = true)
- disabled_selector = is_disabled == true ? '[disabled]' : ':not([disabled])'
+ disabled_selector = is_disabled == true ? "[disabled]" : ":not([disabled])"
form.find(".js-dirty-submit#{disabled_selector}", match: :first)
@@ -12,10 +12,10 @@ shared_examples 'dirty submit form' do |selector_args|
selectors.each do |selector|
it "disables #{selector[:form]} submit until there are changes on #{selector[:input]}", :js do
form = find(selector[:form])
- submit = form.first('.js-dirty-submit')
+ submit = form.first(".js-dirty-submit")
input = form.first(selector[:input])
- is_radio = input[:type] == 'radio'
- is_checkbox = input[:type] == 'checkbox'
+ is_radio = input[:type] == "radio"
+ is_checkbox = input[:type] == "checkbox"
is_checkable = is_radio || is_checkbox
original_value = input.value
original_checkable = form.find("input[name='#{input[:name]}'][checked]") if is_radio
diff --git a/spec/support/shared_examples/email_format_shared_examples.rb b/spec/support/shared_examples/email_format_shared_examples.rb
index b924a208e71..01f05fa6fd0 100644
--- a/spec/support/shared_examples/email_format_shared_examples.rb
+++ b/spec/support/shared_examples/email_format_shared_examples.rb
@@ -4,7 +4,7 @@
# Note: You have access to `email_value` which is the email address value
# being currently tested).
-shared_examples 'an object with email-formated attributes' do |*attributes|
+shared_examples "an object with email-formated attributes" do |*attributes|
attributes.each do |attribute|
describe "specifically its :#{attribute} attribute" do
%w[
@@ -17,7 +17,7 @@ shared_examples 'an object with email-formated attributes' do |*attributes|
context "with a value of '#{valid_email}'" do
let(:email_value) { valid_email }
- it 'is valid' do
+ it "is valid" do
subject.send("#{attribute}=", valid_email)
expect(subject).to be_valid
@@ -32,7 +32,7 @@ shared_examples 'an object with email-formated attributes' do |*attributes|
context "with a value of '#{invalid_email}'" do
let(:email_value) { invalid_email }
- it 'is invalid' do
+ it "is invalid" do
subject.send("#{attribute}=", invalid_email)
expect(subject).to be_invalid
diff --git a/spec/support/shared_examples/fast_destroy_all.rb b/spec/support/shared_examples/fast_destroy_all.rb
index a8079b6d864..1c6ce901f2a 100644
--- a/spec/support/shared_examples/fast_destroy_all.rb
+++ b/spec/support/shared_examples/fast_destroy_all.rb
@@ -1,19 +1,19 @@
-shared_examples_for 'fast destroyable' do
- describe 'Forbid #destroy and #destroy_all' do
- it 'does not delete database rows and associted external data' do
+shared_examples_for "fast destroyable" do
+ describe "Forbid #destroy and #destroy_all" do
+ it "does not delete database rows and associted external data" do
expect(external_data_counter).to be > 0
expect(subjects.count).to be > 0
- expect { subjects.first.destroy }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`')
- expect { subjects.destroy_all }.to raise_error('`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`') # rubocop: disable DestroyAll
+ expect { subjects.first.destroy }.to raise_error("`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`")
+ expect { subjects.destroy_all }.to raise_error("`destroy` and `destroy_all` are forbidden. Please use `fast_destroy_all`") # rubocop: disable DestroyAll
expect(subjects.count).to be > 0
expect(external_data_counter).to be > 0
end
end
- describe '.fast_destroy_all' do
- it 'deletes database rows and associted external data' do
+ describe ".fast_destroy_all" do
+ it "deletes database rows and associted external data" do
expect(external_data_counter).to be > 0
expect(subjects.count).to be > 0
@@ -24,8 +24,8 @@ shared_examples_for 'fast destroyable' do
end
end
- describe '.use_fast_destroy' do
- it 'performs cascading delete with fast_destroy_all' do
+ describe ".use_fast_destroy" do
+ it "performs cascading delete with fast_destroy_all" do
expect(external_data_counter).to be > 0
expect(subjects.count).to be > 0
diff --git a/spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb b/spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb
index 221926aaf7e..b5a7428b63a 100644
--- a/spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb
+++ b/spec/support/shared_examples/features/comments_on_merge_request_files_shared_examples.rb
@@ -1,28 +1,28 @@
-shared_examples 'comment on merge request file' do
- it 'adds a comment' do
+shared_examples "comment on merge request file" do
+ it "adds a comment" do
click_diff_line(find("[id='#{sample_commit.line_code}']"))
- page.within('.js-discussion-note-form') do
- fill_in(:note_note, with: 'Line is wrong')
- click_button('Comment')
+ page.within(".js-discussion-note-form") do
+ fill_in(:note_note, with: "Line is wrong")
+ click_button("Comment")
end
wait_for_requests
- page.within('.notes_holder') do
- expect(page).to have_content('Line is wrong')
+ page.within(".notes_holder") do
+ expect(page).to have_content("Line is wrong")
end
visit(merge_request_path(merge_request))
- page.within('.notes .discussion') do
+ page.within(".notes .discussion") do
expect(page).to have_content("#{user.name} #{user.to_reference} started a discussion")
expect(page).to have_content(sample_commit.line_code_path)
- expect(page).to have_content('Line is wrong')
+ expect(page).to have_content("Line is wrong")
end
- page.within('.notes-tab .badge') do
- expect(page).to have_content('1')
+ page.within(".notes-tab .badge") do
+ expect(page).to have_content("1")
end
end
end
diff --git a/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb
index 7038a366144..cf779a923fd 100644
--- a/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb
+++ b/spec/support/shared_examples/features/creatable_merge_request_shared_examples.rb
@@ -1,4 +1,4 @@
-RSpec.shared_examples 'a creatable merge request' do
+RSpec.shared_examples "a creatable merge request" do
include WaitForRequests
let(:user) { create(:user) }
@@ -20,80 +20,81 @@ RSpec.shared_examples 'a creatable merge request' do
merge_request: {
source_project_id: source_project.id,
target_project_id: target_project.id,
- source_branch: 'fix',
- target_branch: 'master'
- })
+ source_branch: "fix",
+ target_branch: "master",
+ }
+ )
end
- it 'creates new merge request', :js do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
+ it "creates new merge request", :js do
+ click_button "Assignee"
+ page.within ".dropdown-menu-user" do
click_link user2.name
end
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
- page.within '.js-assignee-search' do
+ page.within ".js-assignee-search" do
expect(page).to have_content user2.name
end
- click_link 'Assign to me'
+ click_link "Assign to me"
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
+ page.within ".js-assignee-search" do
expect(page).to have_content user.name
end
- click_button 'Milestone'
- page.within '.issue-milestone' do
+ click_button "Milestone"
+ page.within ".issue-milestone" do
click_link milestone.title
end
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
+ page.within ".js-milestone-select" do
expect(page).to have_content milestone.title
end
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
+ click_button "Labels"
+ page.within ".dropdown-menu-labels" do
click_link label.title
click_link label2.title
end
- page.within '.js-label-select' do
+ page.within ".js-label-select" do
expect(page).to have_content label.title
end
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- click_button 'Submit merge request'
+ click_button "Submit merge request"
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
+ page.within ".issuable-sidebar" do
+ page.within ".assignee" do
expect(page).to have_content user.name
end
- page.within '.milestone' do
+ page.within ".milestone" do
expect(page).to have_content milestone.title
end
- page.within '.labels' do
+ page.within ".labels" do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
end
end
- it 'updates the branches when selecting a new target project', :js do
+ it "updates the branches when selecting a new target project", :js do
target_project_member = target_project.owner
CreateBranchService.new(target_project, target_project_member)
- .execute('a-brand-new-branch-to-test', 'master')
+ .execute("a-brand-new-branch-to-test", "master")
visit project_new_merge_request_path(source_project)
- first('.js-target-project').click
- find('.dropdown-target-project .dropdown-content a', text: target_project.full_path).click
+ first(".js-target-project").click
+ find(".dropdown-target-project .dropdown-content a", text: target_project.full_path).click
wait_for_requests
- first('.js-target-branch').click
+ first(".js-target-branch").click
- within('.js-target-branch-dropdown .dropdown-content') do
- expect(page).to have_content('a-brand-new-branch-to-test')
+ within(".js-target-branch-dropdown .dropdown-content") do
+ expect(page).to have_content("a-brand-new-branch-to-test")
end
end
end
diff --git a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb
index eef0327c9a6..080c9aea908 100644
--- a/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb
+++ b/spec/support/shared_examples/features/editable_merge_request_shared_examples.rb
@@ -1,4 +1,4 @@
-RSpec.shared_examples 'an editable merge request' do
+RSpec.shared_examples "an editable merge request" do
let(:user) { create(:user) }
let(:user2) { create(:user) }
let!(:milestone) { create(:milestone, project: target_project) }
@@ -10,8 +10,8 @@ RSpec.shared_examples 'an editable merge request' do
create(:merge_request,
source_project: source_project,
target_project: target_project,
- source_branch: 'fix',
- target_branch: 'master')
+ source_branch: "fix",
+ target_branch: "master")
end
before do
@@ -23,82 +23,82 @@ RSpec.shared_examples 'an editable merge request' do
visit edit_project_merge_request_path(target_project, merge_request)
end
- it 'updates merge request', :js do
- click_button 'Assignee'
- page.within '.dropdown-menu-user' do
+ it "updates merge request", :js do
+ click_button "Assignee"
+ page.within ".dropdown-menu-user" do
click_link user.name
end
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
- page.within '.js-assignee-search' do
+ page.within ".js-assignee-search" do
expect(page).to have_content user.name
end
- click_button 'Milestone'
- page.within '.issue-milestone' do
+ click_button "Milestone"
+ page.within ".issue-milestone" do
click_link milestone.title
end
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
- page.within '.js-milestone-select' do
+ page.within ".js-milestone-select" do
expect(page).to have_content milestone.title
end
- click_button 'Labels'
- page.within '.dropdown-menu-labels' do
+ click_button "Labels"
+ page.within ".dropdown-menu-labels" do
click_link label.title
click_link label2.title
end
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
- page.within '.js-label-select' do
+ page.within ".js-label-select" do
expect(page).to have_content label.title
end
- click_button 'Save changes'
+ click_button "Save changes"
- page.within '.issuable-sidebar' do
- page.within '.assignee' do
+ page.within ".issuable-sidebar" do
+ page.within ".assignee" do
expect(page).to have_content user.name
end
- page.within '.milestone' do
+ page.within ".milestone" do
expect(page).to have_content milestone.title
end
- page.within '.labels' do
+ page.within ".labels" do
expect(page).to have_content label.title
expect(page).to have_content label2.title
end
end
end
- it 'description has autocomplete', :js do
- find('#merge_request_description').native.send_keys('')
- fill_in 'merge_request_description', with: user.to_reference[0..4]
+ it "description has autocomplete", :js do
+ find("#merge_request_description").native.send_keys("")
+ fill_in "merge_request_description", with: user.to_reference[0..4]
wait_for_requests
- page.within('.atwho-view') do
+ page.within(".atwho-view") do
expect(page).to have_content(user2.name)
end
end
- it 'has class js-quick-submit in form' do
- expect(page).to have_selector('.js-quick-submit')
+ it "has class js-quick-submit in form" do
+ expect(page).to have_selector(".js-quick-submit")
end
- it 'warns about version conflict' do
+ it "warns about version conflict" do
merge_request.update(title: "New title")
- fill_in 'merge_request_title', with: 'bug 345'
- fill_in 'merge_request_description', with: 'bug description'
+ fill_in "merge_request_title", with: "bug 345"
+ fill_in "merge_request_description", with: "bug description"
- click_button 'Save changes'
+ click_button "Save changes"
- expect(page).to have_content 'Someone edited the merge request the same time you did'
+ expect(page).to have_content "Someone edited the merge request the same time you did"
end
- it 'preserves description textarea height', :js do
- long_description = %q(
+ it "preserves description textarea height", :js do
+ long_description = '
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ac ornare ligula, ut tempus arcu. Etiam ultricies accumsan dolor vitae faucibus. Donec at elit lacus. Mauris orci ante, aliquam quis lorem eget, convallis faucibus arcu. Aenean at pulvinar lacus. Ut viverra quam massa, molestie ornare tortor dignissim a. Suspendisse tristique pellentesque tellus, id lacinia metus elementum id. Nam tristique, arcu rhoncus faucibus viverra, lacus ipsum sagittis ligula, vitae convallis odio lacus a nibh. Ut tincidunt est purus, ac vestibulum augue maximus in. Suspendisse vel erat et mi ultricies semper. Pellentesque volutpat pellentesque consequat.
Cras congue nec ligula tristique viverra. Curabitur fringilla fringilla fringilla. Donec rhoncus dignissim orci ut accumsan. Ut rutrum urna a rhoncus varius. Maecenas blandit, mauris nec accumsan gravida, augue nibh finibus magna, sed maximus turpis libero nec neque. Suspendisse at semper est. Nunc imperdiet dapibus dui, varius sollicitudin erat luctus non. Sed pellentesque ligula eget posuere facilisis. Donec dictum commodo volutpat. Donec egestas dui ac magna sollicitudin bibendum. Vivamus purus neque, ullamcorper ac feugiat et, tempus sit amet metus. Praesent quis viverra neque. Sed bibendum viverra est, eu aliquam mi ornare vitae. Proin et dapibus ipsum. Nunc tortor diam, malesuada nec interdum vel, placerat quis justo. Ut viverra at erat eu laoreet.
@@ -108,13 +108,13 @@ RSpec.shared_examples 'an editable merge request' do
Nam tempor et magna sed convallis. Fusce sit amet sollicitudin risus, a ullamcorper lacus. Morbi gravida quis sem eget porttitor. Donec eu egestas mauris, in elementum tortor. Sed eget ex mi. Mauris iaculis tortor ut est auctor, nec dignissim quam sagittis. Suspendisse vel metus non quam suscipit tincidunt. Cras molestie lacus non justo finibus sodales quis vitae erat. In a porttitor nisi, id sollicitudin urna. Ut at felis tellus. Suspendisse potenti.
Maecenas leo ligula, varius at neque vitae, ornare maximus justo. Nullam convallis luctus risus et vulputate. Duis suscipit faucibus iaculis. Etiam quis tortor faucibus, tristique tellus sit amet, sodales neque. Nulla dapibus nisi vel aliquet consequat. Etiam faucibus, metus eget condimentum iaculis, enim urna lobortis sem, id efficitur eros sapien nec nisi. Aenean ut finibus ex.
- )
+ '
- fill_in 'merge_request_description', with: long_description
+ fill_in "merge_request_description", with: long_description
height = get_textarea_height
- find('.js-md-preview-button').click
- find('.js-md-write-button').click
+ find(".js-md-preview-button").click
+ find(".js-md-write-button").click
new_height = get_textarea_height
expect(height).to eq(new_height)
@@ -122,19 +122,19 @@ RSpec.shared_examples 'an editable merge request' do
context 'when "Remove source branch" is set' do
before do
- merge_request.update!(merge_params: { 'force_remove_source_branch' => '1' })
+ merge_request.update!(merge_params: {"force_remove_source_branch" => "1"})
end
it 'allows to unselect "Remove source branch"', :js do
- expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy
+ expect(merge_request.merge_params["force_remove_source_branch"]).to be_truthy
visit edit_project_merge_request_path(target_project, merge_request)
- uncheck 'Delete source branch when merge request is accepted'
+ uncheck "Delete source branch when merge request is accepted"
- click_button 'Save changes'
+ click_button "Save changes"
- expect(page).to have_unchecked_field 'remove-source-branch-input'
- expect(page).to have_content 'Delete source branch'
+ expect(page).to have_unchecked_field "remove-source-branch-input"
+ expect(page).to have_content "Delete source branch"
end
end
end
diff --git a/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb b/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb
index 96c821b26f7..80eaacdfbc5 100644
--- a/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb
+++ b/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb
@@ -1,9 +1,9 @@
-shared_examples 'issue sidebar stays collapsed on mobile' do
+shared_examples "issue sidebar stays collapsed on mobile" do
before do
resize_screen_xs
end
- it 'keeps the sidebar collapsed' do
- expect(page).not_to have_css('.right-sidebar.right-sidebar-collapsed')
+ it "keeps the sidebar collapsed" do
+ expect(page).not_to have_css(".right-sidebar.right-sidebar-collapsed")
end
end
diff --git a/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb b/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb
index c92c7f603d6..8ee09c4940a 100644
--- a/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb
+++ b/spec/support/shared_examples/features/issuables_user_dropdown_behaviors_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_examples 'issuable user dropdown behaviors' do
+shared_examples "issuable user dropdown behaviors" do
include FilteredSearchHelpers
before do
@@ -8,7 +8,7 @@ shared_examples 'issuable user dropdown behaviors' do
%w[author assignee].each do |dropdown|
describe "#{dropdown} dropdown", :js do
- it 'only includes members of the project/group' do
+ it "only includes members of the project/group" do
visit issuables_path
filtered_search.set("#{dropdown}:")
diff --git a/spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb b/spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb
index 75ad948e42c..792ef7ad341 100644
--- a/spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb
+++ b/spec/support/shared_examples/features/master_manages_access_requests_shared_example.rb
@@ -1,4 +1,4 @@
-RSpec.shared_examples 'Maintainer manages access requests' do
+RSpec.shared_examples "Maintainer manages access requests" do
let(:user) { create(:user) }
let(:maintainer) { create(:user) }
@@ -8,32 +8,32 @@ RSpec.shared_examples 'Maintainer manages access requests' do
sign_in(maintainer)
end
- it 'maintainer can see access requests' do
+ it "maintainer can see access requests" do
visit members_page_path
expect_visible_access_request(entity, user)
end
- it 'maintainer can grant access', :js do
+ it "maintainer can grant access", :js do
visit members_page_path
expect_visible_access_request(entity, user)
- accept_confirm { click_on 'Grant access' }
+ accept_confirm { click_on "Grant access" }
expect_no_visible_access_request(entity, user)
- page.within('.members-list') do
+ page.within(".members-list") do
expect(page).to have_content user.name
end
end
- it 'maintainer can deny access', :js do
+ it "maintainer can deny access", :js do
visit members_page_path
expect_visible_access_request(entity, user)
- accept_confirm { click_on 'Deny access' }
+ accept_confirm { click_on "Deny access" }
expect_no_visible_access_request(entity, user)
expect(page).not_to have_content user.name
diff --git a/spec/support/shared_examples/features/project_features_apply_to_issuables_shared_examples.rb b/spec/support/shared_examples/features/project_features_apply_to_issuables_shared_examples.rb
index 64c3b80136d..1c040b87afa 100644
--- a/spec/support/shared_examples/features/project_features_apply_to_issuables_shared_examples.rb
+++ b/spec/support/shared_examples/features/project_features_apply_to_issuables_shared_examples.rb
@@ -1,8 +1,8 @@
-shared_examples 'project features apply to issuables' do |klass|
+shared_examples "project features apply to issuables" do |klass|
let(:described_class) { klass }
let(:group) { create(:group) }
- let(:user_in_group) { create(:group_member, :developer, user: create(:user), group: group ).user }
+ let(:user_in_group) { create(:group_member, :developer, user: create(:user), group: group).user }
let(:user_outside_group) { create(:user) }
let(:project) { create(:project, :public, project_args) }
@@ -10,7 +10,7 @@ shared_examples 'project features apply to issuables' do |klass|
def project_args
feature = "#{described_class.model_name.plural}_access_level".to_sym
- args = { group: group }
+ args = {group: group}
args[feature] = access_level
args
@@ -22,32 +22,32 @@ shared_examples 'project features apply to issuables' do |klass|
visit path
end
- context 'public access level' do
+ context "public access level" do
let(:access_level) { ProjectFeature::ENABLED }
- context 'group member' do
+ context "group member" do
let(:user) { user_in_group }
it { expect(page).to have_content(issuable.title) }
end
- context 'non-member' do
+ context "non-member" do
let(:user) { user_outside_group }
it { expect(page).to have_content(issuable.title) }
end
end
- context 'private access level' do
+ context "private access level" do
let(:access_level) { ProjectFeature::PRIVATE }
- context 'group member' do
+ context "group member" do
let(:user) { user_in_group }
it { expect(page).to have_content(issuable.title) }
end
- context 'non-member' do
+ context "non-member" do
let(:user) { user_outside_group }
it { expect(page).not_to have_content(issuable.title) }
diff --git a/spec/support/shared_examples/features/protected_branches_access_control_ce.rb b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb
index a8f2c2e7a5a..e9e95035c2c 100644
--- a/spec/support/shared_examples/features/protected_branches_access_control_ce.rb
+++ b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb
@@ -3,15 +3,15 @@ shared_examples "protected branches > access control > CE" do
it "allows creating protected branches that #{access_type_name} can push to" do
visit project_protected_branches_path(project)
- set_protected_branch_name('master')
+ set_protected_branch_name("master")
find(".js-allowed-to-merge").click
- within('.qa-allowed-to-merge-dropdown') do
+ within(".qa-allowed-to-merge-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
- within('.js-new-protected-branch') do
+ within(".js-new-protected-branch") do
allowed_to_push_button = find(".js-allowed-to-push")
unless allowed_to_push_button.text == access_type_name
@@ -29,18 +29,18 @@ shared_examples "protected branches > access control > CE" do
it "allows updating protected branches so that #{access_type_name} can push to them" do
visit project_protected_branches_path(project)
- set_protected_branch_name('master')
+ set_protected_branch_name("master")
find(".js-allowed-to-merge").click
- within('.qa-allowed-to-merge-dropdown') do
+ within(".qa-allowed-to-merge-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
find(".js-allowed-to-push").click
- within('.qa-allowed-to-push-dropdown') do
+ within(".qa-allowed-to-push-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
click_on "Protect"
@@ -50,7 +50,7 @@ shared_examples "protected branches > access control > CE" do
within(".protected-branches-list") do
find(".js-allowed-to-push").click
- within('.js-allowed-to-push-container') do
+ within(".js-allowed-to-push-container") do
expect(first("li")).to have_content("Roles")
find(:link, access_type_name).click
end
@@ -66,9 +66,9 @@ shared_examples "protected branches > access control > CE" do
it "allows creating protected branches that #{access_type_name} can merge to" do
visit project_protected_branches_path(project)
- set_protected_branch_name('master')
+ set_protected_branch_name("master")
- within('.js-new-protected-branch') do
+ within(".js-new-protected-branch") do
allowed_to_merge_button = find(".js-allowed-to-merge")
unless allowed_to_merge_button.text == access_type_name
@@ -78,9 +78,9 @@ shared_examples "protected branches > access control > CE" do
end
find(".js-allowed-to-push").click
- within('.qa-allowed-to-push-dropdown') do
+ within(".qa-allowed-to-push-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
click_on "Protect"
@@ -92,18 +92,18 @@ shared_examples "protected branches > access control > CE" do
it "allows updating protected branches so that #{access_type_name} can merge to them" do
visit project_protected_branches_path(project)
- set_protected_branch_name('master')
+ set_protected_branch_name("master")
find(".js-allowed-to-merge").click
- within('.qa-allowed-to-merge-dropdown') do
+ within(".qa-allowed-to-merge-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
find(".js-allowed-to-push").click
- within('.qa-allowed-to-push-dropdown') do
+ within(".qa-allowed-to-push-dropdown") do
expect(first("li")).to have_content("Roles")
- find(:link, 'No one').click
+ find(:link, "No one").click
end
click_on "Protect"
@@ -113,7 +113,7 @@ shared_examples "protected branches > access control > CE" do
within(".protected-branches-list") do
find(".js-allowed-to-merge").click
- within('.js-allowed-to-merge-container') do
+ within(".js-allowed-to-merge-container") do
expect(first("li")).to have_content("Roles")
find(:link, access_type_name).click
end
diff --git a/spec/support/shared_examples/features/search_shared_examples.rb b/spec/support/shared_examples/features/search_shared_examples.rb
index 25ebbf011d5..a18553ada97 100644
--- a/spec/support/shared_examples/features/search_shared_examples.rb
+++ b/spec/support/shared_examples/features/search_shared_examples.rb
@@ -1,5 +1,5 @@
-shared_examples 'top right search form' do
- it 'does not show top right search form' do
- expect(page).not_to have_selector('.search')
+shared_examples "top right search form" do
+ it "does not show top right search form" do
+ expect(page).not_to have_selector(".search")
end
end
diff --git a/spec/support/shared_examples/file_finder.rb b/spec/support/shared_examples/file_finder.rb
index 0dc351b5149..b1c56ccea90 100644
--- a/spec/support/shared_examples/file_finder.rb
+++ b/spec/support/shared_examples/file_finder.rb
@@ -1,8 +1,8 @@
-shared_examples 'file finder' do
- let(:query) { 'files' }
+shared_examples "file finder" do
+ let(:query) { "files" }
let(:search_results) { subject.find(query) }
- it 'finds by name' do
+ it "finds by name" do
blob = search_results.find { |blob| blob.filename == expected_file_by_name }
expect(blob.filename).to eq(expected_file_by_name)
@@ -11,7 +11,7 @@ shared_examples 'file finder' do
expect(blob.data).not_to be_empty
end
- it 'finds by content' do
+ it "finds by content" do
blob = search_results.find { |blob| blob.filename == expected_file_by_content }
expect(blob.filename).to eq(expected_file_by_content)
diff --git a/spec/support/shared_examples/gitlab_verify.rb b/spec/support/shared_examples/gitlab_verify.rb
index 560913ca92f..d9278bcfc8d 100644
--- a/spec/support/shared_examples/gitlab_verify.rb
+++ b/spec/support/shared_examples/gitlab_verify.rb
@@ -1,18 +1,18 @@
-RSpec.shared_examples 'Gitlab::Verify::BatchVerifier subclass' do
- describe 'batching' do
+RSpec.shared_examples "Gitlab::Verify::BatchVerifier subclass" do
+ describe "batching" do
let(:first_batch) { objects[0].id..objects[0].id }
let(:second_batch) { objects[1].id..objects[1].id }
let(:third_batch) { objects[2].id..objects[2].id }
- it 'iterates through objects in batches' do
+ it "iterates through objects in batches" do
expect(collect_ranges).to eq([first_batch, second_batch, third_batch])
end
- it 'allows the starting ID to be specified' do
+ it "allows the starting ID to be specified" do
expect(collect_ranges(start: second_batch.first)).to eq([second_batch, third_batch])
end
- it 'allows the finishing ID to be specified' do
+ it "allows the finishing ID to be specified" do
expect(collect_ranges(finish: second_batch.last)).to eq([first_batch, second_batch])
end
end
diff --git a/spec/support/shared_examples/graphql/issuable_state_shared_examples.rb b/spec/support/shared_examples/graphql/issuable_state_shared_examples.rb
index 713f0a879c1..4ec71f9f664 100644
--- a/spec/support/shared_examples/graphql/issuable_state_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/issuable_state_shared_examples.rb
@@ -1,5 +1,5 @@
-RSpec.shared_examples 'issuable state' do
- it 'exposes all the existing issuable states' do
- expect(described_class.values.keys).to include(*%w[opened closed locked])
+RSpec.shared_examples "issuable state" do
+ it "exposes all the existing issuable states" do
+ expect(described_class.values.keys).to include("opened", "closed", "locked")
end
end
diff --git a/spec/support/shared_examples/group_members_shared_example.rb b/spec/support/shared_examples/group_members_shared_example.rb
index 547c83c7955..812993313f3 100644
--- a/spec/support/shared_examples/group_members_shared_example.rb
+++ b/spec/support/shared_examples/group_members_shared_example.rb
@@ -1,14 +1,14 @@
-RSpec.shared_examples 'members and requesters associations' do
- describe '#members_and_requesters' do
- it 'includes members and requesters' do
+RSpec.shared_examples "members and requesters associations" do
+ describe "#members_and_requesters" do
+ it "includes members and requesters" do
member_and_requester_user_ids = namespace.members_and_requesters.pluck(:user_id)
expect(member_and_requester_user_ids).to include(requester.id, developer.id)
end
end
- describe '#members' do
- it 'includes members and exclude requesters' do
+ describe "#members" do
+ it "includes members and exclude requesters" do
member_user_ids = namespace.members.pluck(:user_id)
expect(member_user_ids).to include(developer.id)
@@ -16,8 +16,8 @@ RSpec.shared_examples 'members and requesters associations' do
end
end
- describe '#requesters' do
- it 'does not include requesters' do
+ describe "#requesters" do
+ it "does not include requesters" do
requester_user_ids = namespace.requesters.pluck(:user_id)
expect(requester_user_ids).to include(requester.id)
diff --git a/spec/support/shared_examples/helm_generated_script.rb b/spec/support/shared_examples/helm_generated_script.rb
index ba9b7d3bdcf..14dfc220acf 100644
--- a/spec/support/shared_examples/helm_generated_script.rb
+++ b/spec/support/shared_examples/helm_generated_script.rb
@@ -1,12 +1,12 @@
-shared_examples 'helm commands' do
- describe '#generate_script' do
+shared_examples "helm commands" do
+ describe "#generate_script" do
let(:helm_setup) do
<<~EOS
- set -xeo pipefail
+ set -xeo pipefail
EOS
end
- it 'should return appropriate command' do
+ it "should return appropriate command" do
expect(subject.generate_script.strip).to eq((helm_setup + commands).strip)
end
end
diff --git a/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb b/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb
index 8ea307c7c61..9dd4054a1ec 100644
--- a/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb
+++ b/spec/support/shared_examples/instance_statistics_controllers_shared_examples.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-shared_examples 'instance statistics availability' do
+shared_examples "instance statistics availability" do
let(:user) { create(:user) }
before do
@@ -9,14 +9,14 @@ shared_examples 'instance statistics availability' do
stub_application_setting(usage_ping_enabled: true)
end
- describe 'GET #index' do
- it 'is available when the feature is available publicly' do
+ describe "GET #index" do
+ it "is available when the feature is available publicly" do
get :index
expect(response).to have_gitlab_http_status(:success)
end
- it 'renders a 404 when the feature is not available publicly' do
+ it "renders a 404 when the feature is not available publicly" do
stub_application_setting(instance_statistics_visibility_private: true)
get :index
@@ -24,10 +24,10 @@ shared_examples 'instance statistics availability' do
expect(response).to have_gitlab_http_status(:not_found)
end
- context 'for admins' do
+ context "for admins" do
let(:user) { create(:admin) }
- it 'allows access when the feature is not available publicly' do
+ it "allows access when the feature is not available publicly" do
stub_application_setting(instance_statistics_visibility_private: true)
get :index
diff --git a/spec/support/shared_examples/issuable_shared_examples.rb b/spec/support/shared_examples/issuable_shared_examples.rb
index c3d40c5b231..e28346c8345 100644
--- a/spec/support/shared_examples/issuable_shared_examples.rb
+++ b/spec/support/shared_examples/issuable_shared_examples.rb
@@ -1,18 +1,18 @@
-shared_examples 'cache counters invalidator' do
- it 'invalidates counter cache for assignees' do
+shared_examples "cache counters invalidator" do
+ it "invalidates counter cache for assignees" do
expect_any_instance_of(User).to receive(:invalidate_merge_request_cache_counts)
described_class.new(project, user, {}).execute(merge_request)
end
end
-shared_examples 'system notes for milestones' do
+shared_examples "system notes for milestones" do
def update_issuable(opts)
issuable = try(:issue) || try(:merge_request)
described_class.new(project, user, opts).execute(issuable)
end
- context 'group milestones' do
+ context "group milestones" do
let(:group) { create(:group) }
let(:group_milestone) { create(:milestone, group: group) }
@@ -21,23 +21,23 @@ shared_examples 'system notes for milestones' do
create(:group_member, group: group, user: user)
end
- it 'creates a system note' do
- expect do
+ it "creates a system note" do
+ expect {
update_issuable(milestone: group_milestone)
- end.to change { Note.system.count }.by(1)
+ }.to change { Note.system.count }.by(1)
end
end
- context 'project milestones' do
- it 'creates a system note' do
- expect do
+ context "project milestones" do
+ it "creates a system note" do
+ expect {
update_issuable(milestone: create(:milestone))
- end.to change { Note.system.count }.by(1)
+ }.to change { Note.system.count }.by(1)
end
end
end
-shared_examples 'updating a single task' do
+shared_examples "updating a single task" do
def update_issuable(opts)
issuable = try(:issue) || try(:merge_request)
described_class.new(project, user, opts).execute(issuable)
@@ -47,64 +47,64 @@ shared_examples 'updating a single task' do
update_issuable(description: "- [ ] Task 1\n- [ ] Task 2")
end
- context 'when a task is marked as completed' do
+ context "when a task is marked as completed" do
before do
- update_issuable(update_task: { index: 1, checked: true, line_source: '- [ ] Task 1', line_number: 1 })
+ update_issuable(update_task: {index: 1, checked: true, line_source: "- [ ] Task 1", line_number: 1})
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 1** as completed')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 1** as completed")
expect(note1).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
- context 'when a task is marked as incomplete' do
+ context "when a task is marked as incomplete" do
before do
update_issuable(description: "- [x] Task 1\n- [X] Task 2")
- update_issuable(update_task: { index: 2, checked: false, line_source: '- [X] Task 2', line_number: 2 })
+ update_issuable(update_task: {index: 2, checked: false, line_source: "- [X] Task 2", line_number: 2})
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 2** as incomplete')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 2** as incomplete")
expect(note1).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(1)
end
end
- context 'when the task position has been modified' do
+ context "when the task position has been modified" do
before do
update_issuable(description: "- [ ] Task 1\n- [ ] Task 3\n- [ ] Task 2")
end
- it 'raises an exception' do
+ it "raises an exception" do
expect(Note.count).to eq(2)
- expect do
- update_issuable(update_task: { index: 2, checked: true, line_source: '- [ ] Task 2', line_number: 2 })
- end.to raise_error(ActiveRecord::StaleObjectError)
+ expect {
+ update_issuable(update_task: {index: 2, checked: true, line_source: "- [ ] Task 2", line_number: 2})
+ }.to raise_error(ActiveRecord::StaleObjectError)
expect(Note.count).to eq(2)
end
end
- context 'when the content changes but not task line number' do
+ context "when the content changes but not task line number" do
before do
update_issuable(description: "Paragraph\n\n- [ ] Task 1\n- [x] Task 2")
update_issuable(description: "Paragraph with more words\n\n- [ ] Task 1\n- [x] Task 2")
- update_issuable(update_task: { index: 2, checked: false, line_source: '- [x] Task 2', line_number: 4 })
+ update_issuable(update_task: {index: 2, checked: false, line_source: "- [x] Task 2", line_number: 4})
end
- it 'creates system note about task status change' do
- note1 = find_note('marked the task **Task 2** as incomplete')
+ it "creates system note about task status change" do
+ note1 = find_note("marked the task **Task 2** as incomplete")
expect(note1).not_to be_nil
- description_notes = find_notes('description')
+ description_notes = find_notes("description")
expect(description_notes.length).to eq(2)
end
end
diff --git a/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb b/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb
index 90d67fd00fc..a52fb093c30 100644
--- a/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb
+++ b/spec/support/shared_examples/issuables_list_metadata_shared_examples.rb
@@ -1,11 +1,11 @@
-shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
+shared_examples "issuables list meta-data" do |issuable_type, action = nil|
include ProjectForksHelper
def get_action(action, project)
if action
- get action, params: { author_id: project.creator.id }
+ get action, params: {author_id: project.creator.id}
else
- get :index, params: { namespace_id: project.namespace, project_id: project }
+ get :index, params: {namespace_id: project.namespace, project_id: project}
end
end
@@ -18,9 +18,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
end
before do
- @issuable_ids = %w[fix improve/awesome].map do |source_branch|
+ @issuable_ids = %w[fix improve/awesome].map { |source_branch|
create_issuable(issuable_type, project, source_branch: source_branch).id
- end
+ }
end
it "creates indexed meta-data object for issuable notes and votes count" do
@@ -36,7 +36,7 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
it "avoids N+1 queries" do
control = ActiveRecord::QueryRecorder.new { get_action(action, project) }
- issuable = create_issuable(issuable_type, project, source_branch: 'csv')
+ issuable = create_issuable(issuable_type, project, source_branch: "csv")
if issuable_type == :merge_request
issuable.update!(source_project: fork_project(project))
@@ -51,9 +51,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil|
it "doesn't execute any queries with false conditions" do
get_empty =
if action
- proc { get action, params: { author_id: project.creator.id } }
+ proc { get action, params: {author_id: project.creator.id} }
else
- proc { get :index, params: { namespace_id: project2.namespace, project_id: project2 } }
+ proc { get :index, params: {namespace_id: project2.namespace, project_id: project2} }
end
expect(&get_empty).not_to make_queries_matching(/WHERE (?:1=0|0=1)/)
diff --git a/spec/support/shared_examples/issue_tracker_service_shared_example.rb b/spec/support/shared_examples/issue_tracker_service_shared_example.rb
index a6ab03cb808..59d5e09ae61 100644
--- a/spec/support/shared_examples/issue_tracker_service_shared_example.rb
+++ b/spec/support/shared_examples/issue_tracker_service_shared_example.rb
@@ -1,22 +1,22 @@
-RSpec.shared_examples 'issue tracker service URL attribute' do |url_attr|
- it { is_expected.to allow_value('https://example.com').for(url_attr) }
+RSpec.shared_examples "issue tracker service URL attribute" do |url_attr|
+ it { is_expected.to allow_value("https://example.com").for(url_attr) }
- it { is_expected.not_to allow_value('example.com').for(url_attr) }
- it { is_expected.not_to allow_value('ftp://example.com').for(url_attr) }
- it { is_expected.not_to allow_value('herp-and-derp').for(url_attr) }
+ it { is_expected.not_to allow_value("example.com").for(url_attr) }
+ it { is_expected.not_to allow_value("ftp://example.com").for(url_attr) }
+ it { is_expected.not_to allow_value("herp-and-derp").for(url_attr) }
end
-RSpec.shared_examples 'allows project key on reference pattern' do |url_attr|
- it 'allows underscores in the project name' do
- expect(described_class.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234'
+RSpec.shared_examples "allows project key on reference pattern" do |url_attr|
+ it "allows underscores in the project name" do
+ expect(described_class.reference_pattern.match("EXT_EXT-1234")[0]).to eq "EXT_EXT-1234"
end
- it 'allows numbers in the project name' do
- expect(described_class.reference_pattern.match('EXT3_EXT-1234')[0]).to eq 'EXT3_EXT-1234'
+ it "allows numbers in the project name" do
+ expect(described_class.reference_pattern.match("EXT3_EXT-1234")[0]).to eq "EXT3_EXT-1234"
end
- it 'requires the project name to begin with A-Z' do
- expect(described_class.reference_pattern.match('3EXT_EXT-1234')).to eq nil
- expect(described_class.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234'
+ it "requires the project name to begin with A-Z" do
+ expect(described_class.reference_pattern.match("3EXT_EXT-1234")).to eq nil
+ expect(described_class.reference_pattern.match("EXT_EXT-1234")[0]).to eq "EXT_EXT-1234"
end
end
diff --git a/spec/support/shared_examples/ldap_shared_examples.rb b/spec/support/shared_examples/ldap_shared_examples.rb
index 52c34e78965..46ba6769dae 100644
--- a/spec/support/shared_examples/ldap_shared_examples.rb
+++ b/spec/support/shared_examples/ldap_shared_examples.rb
@@ -1,68 +1,68 @@
-shared_examples_for 'normalizes a DN' do
+shared_examples_for "normalizes a DN" do
using RSpec::Parameterized::TableSyntax
where(:test_description, :given, :expected) do
- 'strips extraneous whitespace' | 'uid =John Smith , ou = People, dc= example,dc =com' | 'uid=john smith,ou=people,dc=example,dc=com'
- 'strips extraneous whitespace for a DN with a single RDN' | 'uid = John Smith' | 'uid=john smith'
- 'unescapes non-reserved, non-special Unicode characters' | 'uid = Sebasti\\c3\\a1n\\ C.\\20Smith, ou=People (aka. \\22humans\\") ,dc=example, dc=com' | 'uid=sebastián c. smith,ou=people (aka. \\"humans\\"),dc=example,dc=com'
- 'downcases the whole string' | 'UID=John Smith,ou=People,dc=example,dc=com' | 'uid=john smith,ou=people,dc=example,dc=com'
- 'for a null DN (empty string), returns empty string and does not error' | '' | ''
- 'does not strip an escaped leading space in an attribute value' | 'uid=\\ John Smith,ou=People,dc=example,dc=com' | 'uid=\\ john smith,ou=people,dc=example,dc=com'
- 'does not strip an escaped leading space in the last attribute value' | 'uid=\\ John Smith' | 'uid=\\ john smith'
- 'does not strip an escaped trailing space in an attribute value' | 'uid=John Smith\\ ,ou=People,dc=example,dc=com' | 'uid=john smith\\ ,ou=people,dc=example,dc=com'
- 'strips extraneous spaces after an escaped trailing space' | 'uid=John Smith\\ ,ou=People,dc=example,dc=com' | 'uid=john smith\\ ,ou=people,dc=example,dc=com'
- 'strips extraneous spaces after an escaped trailing space at the end of the DN' | 'uid=John Smith,ou=People,dc=example,dc=com\\ ' | 'uid=john smith,ou=people,dc=example,dc=com\\ '
- 'properly preserves escaped trailing space after unescaped trailing spaces' | 'uid=John Smith \\ ,ou=People,dc=example,dc=com' | 'uid=john smith \\ ,ou=people,dc=example,dc=com'
- 'preserves multiple inner spaces in an attribute value' | 'uid=John Smith,ou=People,dc=example,dc=com' | 'uid=john smith,ou=people,dc=example,dc=com'
- 'preserves inner spaces after an escaped space' | 'uid=John\\ Smith,ou=People,dc=example,dc=com' | 'uid=john smith,ou=people,dc=example,dc=com'
- 'hex-escapes an escaped leading newline in an attribute value' | "uid=\\\nJohn Smith,ou=People,dc=example,dc=com" | "uid=\\0ajohn smith,ou=people,dc=example,dc=com"
- 'hex-escapes and does not strip an escaped trailing newline in an attribute value' | "uid=John Smith\\\n,ou=People,dc=example,dc=com" | "uid=john smith\\0a,ou=people,dc=example,dc=com"
- 'hex-escapes an unescaped leading newline (actually an invalid DN?)' | "uid=\nJohn Smith,ou=People,dc=example,dc=com" | "uid=\\0ajohn smith,ou=people,dc=example,dc=com"
- 'strips an unescaped trailing newline (actually an invalid DN?)' | "uid=John Smith\n,ou=People,dc=example,dc=com" | "uid=john smith,ou=people,dc=example,dc=com"
- 'does not strip if no extraneous whitespace' | 'uid=John Smith,ou=People,dc=example,dc=com' | 'uid=john smith,ou=people,dc=example,dc=com'
- 'does not modify an escaped equal sign in an attribute value' | 'uid= foo \\= bar' | 'uid=foo \\= bar'
- 'converts an escaped hex equal sign to an escaped equal sign in an attribute value' | 'uid= foo \\3D bar' | 'uid=foo \\= bar'
- 'does not modify an escaped comma in an attribute value' | 'uid= John C. Smith, ou=San Francisco\\, CA' | 'uid=john c. smith,ou=san francisco\\, ca'
- 'converts an escaped hex comma to an escaped comma in an attribute value' | 'uid= John C. Smith, ou=San Francisco\\2C CA' | 'uid=john c. smith,ou=san francisco\\, ca'
- 'does not modify an escaped hex carriage return character in an attribute value' | 'uid= John C. Smith, ou=San Francisco\\,\\0DCA' | 'uid=john c. smith,ou=san francisco\\,\\0dca'
- 'does not modify an escaped hex line feed character in an attribute value' | 'uid= John C. Smith, ou=San Francisco\\,\\0ACA' | 'uid=john c. smith,ou=san francisco\\,\\0aca'
- 'does not modify an escaped hex CRLF in an attribute value' | 'uid= John C. Smith, ou=San Francisco\\,\\0D\\0ACA' | 'uid=john c. smith,ou=san francisco\\,\\0d\\0aca'
- 'allows attribute type name OIDs' | '0.9.2342.19200300.100.1.25=Example,0.9.2342.19200300.100.1.25=Com' | '0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com'
- 'strips extraneous whitespace from attribute type name OIDs' | '0.9.2342.19200300.100.1.25 = Example, 0.9.2342.19200300.100.1.25 = Com' | '0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com'
+ "strips extraneous whitespace" | "uid =John Smith , ou = People, dc= example,dc =com" | "uid=john smith,ou=people,dc=example,dc=com"
+ "strips extraneous whitespace for a DN with a single RDN" | "uid = John Smith" | "uid=john smith"
+ "unescapes non-reserved, non-special Unicode characters" | 'uid = Sebasti\\c3\\a1n\\ C.\\20Smith, ou=People (aka. \\22humans\\") ,dc=example, dc=com' | 'uid=sebastián c. smith,ou=people (aka. \\"humans\\"),dc=example,dc=com'
+ "downcases the whole string" | "UID=John Smith,ou=People,dc=example,dc=com" | "uid=john smith,ou=people,dc=example,dc=com"
+ "for a null DN (empty string), returns empty string and does not error" | "" | ""
+ "does not strip an escaped leading space in an attribute value" | 'uid=\\ John Smith,ou=People,dc=example,dc=com' | 'uid=\\ john smith,ou=people,dc=example,dc=com'
+ "does not strip an escaped leading space in the last attribute value" | 'uid=\\ John Smith' | 'uid=\\ john smith'
+ "does not strip an escaped trailing space in an attribute value" | 'uid=John Smith\\ ,ou=People,dc=example,dc=com' | 'uid=john smith\\ ,ou=people,dc=example,dc=com'
+ "strips extraneous spaces after an escaped trailing space" | 'uid=John Smith\\ ,ou=People,dc=example,dc=com' | 'uid=john smith\\ ,ou=people,dc=example,dc=com'
+ "strips extraneous spaces after an escaped trailing space at the end of the DN" | 'uid=John Smith,ou=People,dc=example,dc=com\\ ' | 'uid=john smith,ou=people,dc=example,dc=com\\ '
+ "properly preserves escaped trailing space after unescaped trailing spaces" | 'uid=John Smith \\ ,ou=People,dc=example,dc=com' | 'uid=john smith \\ ,ou=people,dc=example,dc=com'
+ "preserves multiple inner spaces in an attribute value" | "uid=John Smith,ou=People,dc=example,dc=com" | "uid=john smith,ou=people,dc=example,dc=com"
+ "preserves inner spaces after an escaped space" | 'uid=John\\ Smith,ou=People,dc=example,dc=com' | "uid=john smith,ou=people,dc=example,dc=com"
+ "hex-escapes an escaped leading newline in an attribute value" | "uid=\\\nJohn Smith,ou=People,dc=example,dc=com" | "uid=\\0ajohn smith,ou=people,dc=example,dc=com"
+ "hex-escapes and does not strip an escaped trailing newline in an attribute value" | "uid=John Smith\\\n,ou=People,dc=example,dc=com" | "uid=john smith\\0a,ou=people,dc=example,dc=com"
+ "hex-escapes an unescaped leading newline (actually an invalid DN?)" | "uid=\nJohn Smith,ou=People,dc=example,dc=com" | "uid=\\0ajohn smith,ou=people,dc=example,dc=com"
+ "strips an unescaped trailing newline (actually an invalid DN?)" | "uid=John Smith\n,ou=People,dc=example,dc=com" | "uid=john smith,ou=people,dc=example,dc=com"
+ "does not strip if no extraneous whitespace" | "uid=John Smith,ou=People,dc=example,dc=com" | "uid=john smith,ou=people,dc=example,dc=com"
+ "does not modify an escaped equal sign in an attribute value" | 'uid= foo \\= bar' | 'uid=foo \\= bar'
+ "converts an escaped hex equal sign to an escaped equal sign in an attribute value" | 'uid= foo \\3D bar' | 'uid=foo \\= bar'
+ "does not modify an escaped comma in an attribute value" | 'uid= John C. Smith, ou=San Francisco\\, CA' | 'uid=john c. smith,ou=san francisco\\, ca'
+ "converts an escaped hex comma to an escaped comma in an attribute value" | 'uid= John C. Smith, ou=San Francisco\\2C CA' | 'uid=john c. smith,ou=san francisco\\, ca'
+ "does not modify an escaped hex carriage return character in an attribute value" | 'uid= John C. Smith, ou=San Francisco\\,\\0DCA' | 'uid=john c. smith,ou=san francisco\\,\\0dca'
+ "does not modify an escaped hex line feed character in an attribute value" | 'uid= John C. Smith, ou=San Francisco\\,\\0ACA' | 'uid=john c. smith,ou=san francisco\\,\\0aca'
+ "does not modify an escaped hex CRLF in an attribute value" | 'uid= John C. Smith, ou=San Francisco\\,\\0D\\0ACA' | 'uid=john c. smith,ou=san francisco\\,\\0d\\0aca'
+ "allows attribute type name OIDs" | "0.9.2342.19200300.100.1.25=Example,0.9.2342.19200300.100.1.25=Com" | "0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
+ "strips extraneous whitespace from attribute type name OIDs" | "0.9.2342.19200300.100.1.25 = Example, 0.9.2342.19200300.100.1.25 = Com" | "0.9.2342.19200300.100.1.25=example,0.9.2342.19200300.100.1.25=com"
end
with_them do
- it 'normalizes the DN' do
+ it "normalizes the DN" do
assert_generic_test(test_description, subject, expected)
end
end
end
-shared_examples_for 'normalizes a DN attribute value' do
+shared_examples_for "normalizes a DN attribute value" do
using RSpec::Parameterized::TableSyntax
where(:test_description, :given, :expected) do
- 'strips extraneous whitespace' | ' John Smith ' | 'john smith'
- 'unescapes non-reserved, non-special Unicode characters' | 'Sebasti\\c3\\a1n\\ C.\\20Smith' | 'sebastián c. smith'
- 'downcases the whole string' | 'JoHn C. Smith' | 'john c. smith'
- 'does not strip an escaped leading space in an attribute value' | '\\ John Smith' | '\\ john smith'
- 'does not strip an escaped trailing space in an attribute value' | 'John Smith\\ ' | 'john smith\\ '
- 'hex-escapes an escaped leading newline in an attribute value' | "\\\nJohn Smith" | "\\0ajohn smith"
- 'hex-escapes and does not strip an escaped trailing newline in an attribute value' | "John Smith\\\n" | "john smith\\0a"
- 'hex-escapes an unescaped leading newline (actually an invalid DN value?)' | "\nJohn Smith" | "\\0ajohn smith"
- 'strips an unescaped trailing newline (actually an invalid DN value?)' | "John Smith\n" | "john smith"
- 'does not strip if no extraneous whitespace' | 'John Smith' | 'john smith'
- 'does not modify an escaped equal sign in an attribute value' | ' foo \\= bar' | 'foo \\= bar'
- 'converts an escaped hex equal sign to an escaped equal sign in an attribute value' | ' foo \\3D bar' | 'foo \\= bar'
- 'does not modify an escaped comma in an attribute value' | 'San Francisco\\, CA' | 'san francisco\\, ca'
- 'converts an escaped hex comma to an escaped comma in an attribute value' | 'San Francisco\\2C CA' | 'san francisco\\, ca'
- 'does not modify an escaped hex carriage return character in an attribute value' | 'San Francisco\\,\\0DCA' | 'san francisco\\,\\0dca'
- 'does not modify an escaped hex line feed character in an attribute value' | 'San Francisco\\,\\0ACA' | 'san francisco\\,\\0aca'
- 'does not modify an escaped hex CRLF in an attribute value' | 'San Francisco\\,\\0D\\0ACA' | 'san francisco\\,\\0d\\0aca'
+ "strips extraneous whitespace" | " John Smith " | "john smith"
+ "unescapes non-reserved, non-special Unicode characters" | 'Sebasti\\c3\\a1n\\ C.\\20Smith' | "sebastián c. smith"
+ "downcases the whole string" | "JoHn C. Smith" | "john c. smith"
+ "does not strip an escaped leading space in an attribute value" | '\\ John Smith' | '\\ john smith'
+ "does not strip an escaped trailing space in an attribute value" | 'John Smith\\ ' | 'john smith\\ '
+ "hex-escapes an escaped leading newline in an attribute value" | "\\\nJohn Smith" | "\\0ajohn smith"
+ "hex-escapes and does not strip an escaped trailing newline in an attribute value" | "John Smith\\\n" | "john smith\\0a"
+ "hex-escapes an unescaped leading newline (actually an invalid DN value?)" | "\nJohn Smith" | "\\0ajohn smith"
+ "strips an unescaped trailing newline (actually an invalid DN value?)" | "John Smith\n" | "john smith"
+ "does not strip if no extraneous whitespace" | "John Smith" | "john smith"
+ "does not modify an escaped equal sign in an attribute value" | ' foo \\= bar' | 'foo \\= bar'
+ "converts an escaped hex equal sign to an escaped equal sign in an attribute value" | ' foo \\3D bar' | 'foo \\= bar'
+ "does not modify an escaped comma in an attribute value" | 'San Francisco\\, CA' | 'san francisco\\, ca'
+ "converts an escaped hex comma to an escaped comma in an attribute value" | 'San Francisco\\2C CA' | 'san francisco\\, ca'
+ "does not modify an escaped hex carriage return character in an attribute value" | 'San Francisco\\,\\0DCA' | 'san francisco\\,\\0dca'
+ "does not modify an escaped hex line feed character in an attribute value" | 'San Francisco\\,\\0ACA' | 'san francisco\\,\\0aca'
+ "does not modify an escaped hex CRLF in an attribute value" | 'San Francisco\\,\\0D\\0ACA' | 'san francisco\\,\\0d\\0aca'
end
with_them do
- it 'normalizes the DN attribute value' do
+ it "normalizes the DN attribute value" do
assert_generic_test(test_description, subject, expected)
end
end
diff --git a/spec/support/shared_examples/legacy_path_redirect_shared_examples.rb b/spec/support/shared_examples/legacy_path_redirect_shared_examples.rb
index f300bdd48b1..185561b4203 100644
--- a/spec/support/shared_examples/legacy_path_redirect_shared_examples.rb
+++ b/spec/support/shared_examples/legacy_path_redirect_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_examples 'redirecting a legacy path' do |source, target|
+shared_examples "redirecting a legacy path" do |source, target|
include RSpec::Rails::RequestExampleGroup
it "redirects #{source} to #{target} when the resource does not exist" do
diff --git a/spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb b/spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb
index dcf7c1a90c2..0ca3d63e702 100644
--- a/spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb
+++ b/spec/support/shared_examples/lib/gitlab/background_migration/backfill_project_repositories_examples.rb
@@ -1,13 +1,13 @@
-shared_examples 'backfill migration for project repositories' do |storage|
- describe '#perform' do
+shared_examples "backfill migration for project repositories" do |storage|
+ describe "#perform" do
let(:storage_versions) { storage == :legacy ? [nil, 0] : [1, 2] }
let(:storage_version) { storage_versions.first }
let(:namespaces) { table(:namespaces) }
let(:project_repositories) { table(:project_repositories) }
let(:projects) { table(:projects) }
let(:shards) { table(:shards) }
- let(:group) { namespaces.create!(name: 'foo', path: 'foo') }
- let(:shard) { shards.create!(name: 'default') }
+ let(:group) { namespaces.create!(name: "foo", path: "foo") }
+ let(:shard) { shards.create!(name: "default") }
it "creates a project_repository row for projects on #{storage} storage that needs one" do
storage_versions.each_with_index do |storage_version, index|
@@ -18,27 +18,27 @@ shared_examples 'backfill migration for project repositories' do |storage|
end
it "does nothing for projects on #{storage} storage that have already a project_repository row" do
- projects.create!(id: 1, name: 'foo', path: 'foo', namespace_id: group.id, storage_version: storage_version)
- project_repositories.create!(project_id: 1, disk_path: 'phony/foo/bar', shard_id: shard.id)
+ projects.create!(id: 1, name: "foo", path: "foo", namespace_id: group.id, storage_version: storage_version)
+ project_repositories.create!(project_id: 1, disk_path: "phony/foo/bar", shard_id: shard.id)
expect { described_class.new.perform(1, projects.last.id) }.not_to change(project_repositories, :count)
end
- it "does nothing for projects on #{storage == :legacy ? 'hashed' : 'legacy'} storage" do
- projects.create!(name: 'foo', path: 'foo', namespace_id: group.id, storage_version: storage == :legacy ? 1 : nil)
+ it "does nothing for projects on #{storage == :legacy ? "hashed" : "legacy"} storage" do
+ projects.create!(name: "foo", path: "foo", namespace_id: group.id, storage_version: storage == :legacy ? 1 : nil)
expect { described_class.new.perform(1, projects.last.id) }.not_to change(project_repositories, :count)
end
- it 'inserts rows in a single query' do
- projects.create!(name: 'foo', path: 'foo', namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
- group2 = namespaces.create!(name: 'gro', path: 'gro')
+ it "inserts rows in a single query" do
+ projects.create!(name: "foo", path: "foo", namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
+ group2 = namespaces.create!(name: "gro", path: "gro")
control_count = ActiveRecord::QueryRecorder.new { described_class.new.perform(1, projects.last.id) }
- projects.create!(name: 'bar', path: 'bar', namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
- projects.create!(name: 'top', path: 'top', namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
- projects.create!(name: 'zoo', path: 'zoo', namespace_id: group2.id, storage_version: storage_version, repository_storage: shard.name)
+ projects.create!(name: "bar", path: "bar", namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
+ projects.create!(name: "top", path: "top", namespace_id: group.id, storage_version: storage_version, repository_storage: shard.name)
+ projects.create!(name: "zoo", path: "zoo", namespace_id: group2.id, storage_version: storage_version, repository_storage: shard.name)
expect { described_class.new.perform(1, projects.last.id) }.not_to exceed_query_limit(control_count)
end
diff --git a/spec/support/shared_examples/malicious_regexp_shared_examples.rb b/spec/support/shared_examples/malicious_regexp_shared_examples.rb
index db69b75c0c8..076ca7cf46c 100644
--- a/spec/support/shared_examples/malicious_regexp_shared_examples.rb
+++ b/spec/support/shared_examples/malicious_regexp_shared_examples.rb
@@ -1,10 +1,10 @@
-require 'timeout'
+require "timeout"
-shared_examples 'malicious regexp' do
- let(:malicious_text) { 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!' }
- let(:malicious_regexp) { '(?i)^(([a-z])+.)+[A-Z]([a-z])+$' }
+shared_examples "malicious regexp" do
+ let(:malicious_text) { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa!" }
+ let(:malicious_regexp) { "(?i)^(([a-z])+.)+[A-Z]([a-z])+$" }
- it 'takes under a second' do
+ it "takes under a second" do
expect { Timeout.timeout(1) { subject } }.not_to raise_error
end
end
diff --git a/spec/support/shared_examples/mentionable_shared_examples.rb b/spec/support/shared_examples/mentionable_shared_examples.rb
index 1226841f24c..f59f87d2822 100644
--- a/spec/support/shared_examples/mentionable_shared_examples.rb
+++ b/spec/support/shared_examples/mentionable_shared_examples.rb
@@ -4,7 +4,7 @@
# - let(:backref_text) { "the way that +subject+ should refer to itself in backreferences " }
# - let(:set_mentionable_text) { lambda { |txt| "block that assigns txt to the subject's mentionable_text" } }
-shared_context 'mentionable context' do
+shared_context "mentionable context" do
let(:project) { subject.project }
let(:author) { subject.author }
@@ -57,10 +57,10 @@ shared_context 'mentionable context' do
end
end
-shared_examples 'a mentionable' do
- include_context 'mentionable context'
+shared_examples "a mentionable" do
+ include_context "mentionable context"
- it 'generates a descriptive back-reference' do
+ it "generates a descriptive back-reference" do
expect(subject.gfm_reference).to eq(backref_text)
end
@@ -76,9 +76,9 @@ shared_examples 'a mentionable' do
expect(refs).to include(ext_commit)
end
- it 'creates cross-reference notes' do
+ it "creates cross-reference notes" do
mentioned_objects = [mentioned_issue, mentioned_mr, mentioned_commit,
- ext_issue, ext_mr, ext_commit]
+ ext_issue, ext_mr, ext_commit,]
mentioned_objects.each do |referenced|
expect(SystemNoteService).to receive(:cross_reference)
@@ -89,16 +89,16 @@ shared_examples 'a mentionable' do
end
end
-shared_examples 'an editable mentionable' do
- include_context 'mentionable context'
+shared_examples "an editable mentionable" do
+ include_context "mentionable context"
- it_behaves_like 'a mentionable'
+ it_behaves_like "a mentionable"
let(:new_issues) do
[create(:issue, project: project), create(:issue, project: ext_proj)]
end
- it 'creates new cross-reference notes when the mentionable text is edited' do
+ it "creates new cross-reference notes when the mentionable text is edited" do
subject.save
subject.create_cross_references!
diff --git a/spec/support/shared_examples/milestone_tabs_examples.rb b/spec/support/shared_examples/milestone_tabs_examples.rb
index 8b757586941..94808a31ed3 100644
--- a/spec/support/shared_examples/milestone_tabs_examples.rb
+++ b/spec/support/shared_examples/milestone_tabs_examples.rb
@@ -1,83 +1,83 @@
-shared_examples 'milestone tabs' do
+shared_examples "milestone tabs" do
def go(path, extra_params = {})
params =
case milestone
when DashboardMilestone
- { id: milestone.safe_title, title: milestone.title }
+ {id: milestone.safe_title, title: milestone.title}
when GroupMilestone
- { group_id: group.to_param, id: milestone.safe_title, title: milestone.title }
+ {group_id: group.to_param, id: milestone.safe_title, title: milestone.title}
else
- { namespace_id: project.namespace.to_param, project_id: project, id: milestone.iid }
+ {namespace_id: project.namespace.to_param, project_id: project, id: milestone.iid}
end
get path, params: params.merge(extra_params)
end
- describe '#merge_requests' do
- context 'as html' do
+ describe "#merge_requests" do
+ context "as html" do
before do
- go(:merge_requests, format: 'html')
+ go(:merge_requests, format: "html")
end
- it 'redirects to milestone#show' do
+ it "redirects to milestone#show" do
expect(response).to redirect_to(milestone_path)
end
end
- context 'as json' do
+ context "as json" do
before do
- go(:merge_requests, format: 'json')
+ go(:merge_requests, format: "json")
end
- it 'renders the merge requests tab template to a string' do
- expect(response).to render_template('shared/milestones/_merge_requests_tab')
- expect(json_response).to have_key('html')
+ it "renders the merge requests tab template to a string" do
+ expect(response).to render_template("shared/milestones/_merge_requests_tab")
+ expect(json_response).to have_key("html")
end
end
end
- describe '#participants' do
- context 'as html' do
+ describe "#participants" do
+ context "as html" do
before do
- go(:participants, format: 'html')
+ go(:participants, format: "html")
end
- it 'redirects to milestone#show' do
+ it "redirects to milestone#show" do
expect(response).to redirect_to(milestone_path)
end
end
- context 'as json' do
+ context "as json" do
before do
- go(:participants, format: 'json')
+ go(:participants, format: "json")
end
- it 'renders the participants tab template to a string' do
- expect(response).to render_template('shared/milestones/_participants_tab')
- expect(json_response).to have_key('html')
+ it "renders the participants tab template to a string" do
+ expect(response).to render_template("shared/milestones/_participants_tab")
+ expect(json_response).to have_key("html")
end
end
end
- describe '#labels' do
- context 'as html' do
+ describe "#labels" do
+ context "as html" do
before do
- go(:labels, format: 'html')
+ go(:labels, format: "html")
end
- it 'redirects to milestone#show' do
+ it "redirects to milestone#show" do
expect(response).to redirect_to(milestone_path)
end
end
- context 'as json' do
+ context "as json" do
before do
- go(:labels, format: 'json')
+ go(:labels, format: "json")
end
- it 'renders the labels tab template to a string' do
- expect(response).to render_template('shared/milestones/_labels_tab')
- expect(json_response).to have_key('html')
+ it "renders the labels tab template to a string" do
+ expect(response).to render_template("shared/milestones/_labels_tab")
+ expect(json_response).to have_key("html")
end
end
end
diff --git a/spec/support/shared_examples/models/atomic_internal_id_spec.rb b/spec/support/shared_examples/models/atomic_internal_id_spec.rb
index c659be8f13a..1e6ec25ece1 100644
--- a/spec/support/shared_examples/models/atomic_internal_id_spec.rb
+++ b/spec/support/shared_examples/models/atomic_internal_id_spec.rb
@@ -1,53 +1,53 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples_for 'AtomicInternalId' do |validate_presence: true|
- describe '.has_internal_id' do
- describe 'Module inclusion' do
+shared_examples_for "AtomicInternalId" do |validate_presence: true|
+ describe ".has_internal_id" do
+ describe "Module inclusion" do
subject { described_class }
it { is_expected.to include_module(AtomicInternalId) }
end
- describe 'Validation' do
+ describe "Validation" do
before do
allow_any_instance_of(described_class).to receive(:"ensure_#{scope}_#{internal_id_attribute}!")
instance.valid?
end
- context 'when presence validation is required' do
+ context "when presence validation is required" do
before do
skip unless validate_presence
end
- it 'validates presence' do
+ it "validates presence" do
expect(instance.errors[internal_id_attribute]).to include("can't be blank")
end
end
- context 'when presence validation is not required' do
+ context "when presence validation is not required" do
before do
skip if validate_presence
end
- it 'does not validate presence' do
+ it "does not validate presence" do
expect(instance.errors[internal_id_attribute]).to be_empty
end
end
end
- describe 'Creating an instance' do
+ describe "Creating an instance" do
subject { instance.save! }
- it 'saves a new instance properly' do
+ it "saves a new instance properly" do
expect { subject }.not_to raise_error
end
end
- describe 'internal id generation' do
+ describe "internal id generation" do
subject { instance.save! }
- it 'calls InternalId.generate_next and sets internal id attribute' do
+ it "calls InternalId.generate_next and sets internal id attribute" do
iid = rand(1..1000)
expect(InternalId).to receive(:generate_next).with(instance, scope_attrs, usage, any_args).and_return(iid)
@@ -55,16 +55,16 @@ shared_examples_for 'AtomicInternalId' do |validate_presence: true|
expect(instance.public_send(internal_id_attribute)).to eq(iid)
end
- it 'does not overwrite an existing internal id' do
+ it "does not overwrite an existing internal id" do
instance.public_send("#{internal_id_attribute}=", 4711)
expect { subject }.not_to change { instance.public_send(internal_id_attribute) }
end
- context 'when the instance has an internal ID set' do
+ context "when the instance has an internal ID set" do
let(:internal_id) { 9001 }
- it 'calls InternalId.update_last_value and sets the `last_value` to that of the instance' do
+ it "calls InternalId.update_last_value and sets the `last_value` to that of the instance" do
instance.send("#{internal_id_attribute}=", internal_id)
expect(InternalId)
diff --git a/spec/support/shared_examples/models/chat_service_spec.rb b/spec/support/shared_examples/models/chat_service_spec.rb
index cf1d52a9616..fae1c4fc363 100644
--- a/spec/support/shared_examples/models/chat_service_spec.rb
+++ b/spec/support/shared_examples/models/chat_service_spec.rb
@@ -90,7 +90,7 @@ shared_examples_for "chat service" do |service_name|
end
context "with issue events" do
- let(:opts) { { title: "Awesome issue", description: "please fix" } }
+ let(:opts) { {title: "Awesome issue", description: "please fix"} }
let(:sample_data) do
service = Issues::CreateService.new(project, user, opts)
issue = service.execute
@@ -106,7 +106,7 @@ shared_examples_for "chat service" do |service_name|
title: "Awesome merge_request",
description: "please fix",
source_branch: "feature",
- target_branch: "master"
+ target_branch: "master",
}
end
@@ -129,7 +129,7 @@ shared_examples_for "chat service" do |service_name|
title: "Awesome wiki_page",
content: "Some text describing some thing or another",
format: "md",
- message: "user created page: Awesome wiki_page"
+ message: "user created page: Awesome wiki_page",
}
end
let(:wiki_page) { create(:wiki_page, wiki: project.wiki, attrs: opts) }
@@ -144,10 +144,10 @@ shared_examples_for "chat service" do |service_name|
context "with commit comment" do
let(:note) do
create(:note_on_commit,
- author: user,
- project: project,
- commit_id: project.repository.commit.id,
- note: "a comment on a commit")
+ author: user,
+ project: project,
+ commit_id: project.repository.commit.id,
+ note: "a comment on a commit")
end
it_behaves_like "#{service_name} service"
@@ -181,8 +181,8 @@ shared_examples_for "chat service" do |service_name|
context "with pipeline events" do
let(:pipeline) do
create(:ci_pipeline,
- project: project, status: status,
- sha: project.commit.sha, ref: project.default_branch)
+ project: project, status: status,
+ sha: project.commit.sha, ref: project.default_branch)
end
let(:sample_data) { Gitlab::DataBuilder::Pipeline.build(pipeline) }
diff --git a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
index 1f76b981292..6a0c524b4f8 100644
--- a/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_core_shared_examples.rb
@@ -1,13 +1,13 @@
-shared_examples 'cluster application core specs' do |application_name|
+shared_examples "cluster application core specs" do |application_name|
it { is_expected.to belong_to(:cluster) }
it { is_expected.to validate_presence_of(:cluster) }
- describe '#name' do
- it 'is .application_name' do
+ describe "#name" do
+ it "is .application_name" do
expect(subject.name).to eq(described_class.application_name)
end
- it 'is recorded in Clusters::Cluster::APPLICATIONS' do
+ it "is recorded in Clusters::Cluster::APPLICATIONS" do
expect(Clusters::Cluster::APPLICATIONS[subject.name]).to eq(described_class)
end
end
diff --git a/spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb b/spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
index d87b3181e80..061e91820b6 100644
--- a/spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_helm_cert_examples.rb
@@ -1,20 +1,20 @@
-shared_examples 'cluster application helm specs' do |application_name|
+shared_examples "cluster application helm specs" do |application_name|
let(:application) { create(application_name) }
- describe '#files' do
+ describe "#files" do
subject { application.files }
- context 'when the helm application does not have a ca_cert' do
+ context "when the helm application does not have a ca_cert" do
before do
application.cluster.application_helm.ca_cert = nil
end
- it 'should not include cert files when there is no ca_cert entry' do
+ it "should not include cert files when there is no ca_cert entry" do
expect(subject).not_to include(:'ca.pem', :'cert.pem', :'key.pem')
end
end
- it 'should include cert files when there is a ca_cert entry' do
+ it "should include cert files when there is a ca_cert entry" do
expect(subject).to include(:'ca.pem', :'cert.pem', :'key.pem')
expect(subject[:'ca.pem']).to eq(application.cluster.application_helm.ca_cert)
diff --git a/spec/support/shared_examples/models/cluster_application_initial_status.rb b/spec/support/shared_examples/models/cluster_application_initial_status.rb
index 9775d87953c..79e1e664215 100644
--- a/spec/support/shared_examples/models/cluster_application_initial_status.rb
+++ b/spec/support/shared_examples/models/cluster_application_initial_status.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
-shared_examples 'cluster application initial status specs' do
- describe '#status' do
+shared_examples "cluster application initial status specs" do
+ describe "#status" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { described_class.new(cluster: cluster) }
- context 'when application helm is scheduled' do
+ context "when application helm is scheduled" do
before do
create(:clusters_applications_helm, :scheduled, cluster: cluster)
end
- it 'defaults to :not_installable' do
+ it "defaults to :not_installable" do
expect(subject.status_name).to be(:not_installable)
end
end
- context 'when application is scheduled' do
+ context "when application is scheduled" do
before do
create(:clusters_applications_helm, :installed, cluster: cluster)
end
- it 'sets a default status' do
+ it "sets a default status" do
expect(subject.status_name).to be(:installable)
end
end
diff --git a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
index b8c19cab0c4..1d62caffc07 100644
--- a/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_status_shared_examples.rb
@@ -1,15 +1,15 @@
-shared_examples 'cluster application status specs' do |application_name|
- describe '#status' do
+shared_examples "cluster application status specs" do |application_name|
+ describe "#status" do
let(:cluster) { create(:cluster, :provided_by_gcp) }
subject { described_class.new(cluster: cluster) }
- it 'sets a default status' do
+ it "sets a default status" do
expect(subject.status_name).to be(:not_installable)
end
end
- describe '.available' do
+ describe ".available" do
subject { described_class.available }
let!(:installed_cluster) { create(application_name, :installed) }
@@ -22,28 +22,28 @@ shared_examples 'cluster application status specs' do |application_name|
it { is_expected.to contain_exactly(installed_cluster, updated_cluster) }
end
- describe 'status state machine' do
- describe '#make_installing' do
+ describe "status state machine" do
+ describe "#make_installing" do
subject { create(application_name, :scheduled) }
- it 'is installing' do
+ it "is installing" do
subject.make_installing!
expect(subject).to be_installing
end
end
- describe '#make_installed' do
+ describe "#make_installed" do
subject { create(application_name, :installing) }
- it 'is installed' do
+ it "is installed" do
subject.make_installed!
expect(subject).to be_installed
end
- it 'updates helm version' do
- subject.cluster.application_helm.update!(version: '1.2.3')
+ it "updates helm version" do
+ subject.cluster.application_helm.update!(version: "1.2.3")
subject.make_installed!
@@ -52,8 +52,8 @@ shared_examples 'cluster application status specs' do |application_name|
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
- it 'sets the correct version of the application' do
- subject.update!(version: '0.0.0')
+ it "sets the correct version of the application" do
+ subject.update!(version: "0.0.0")
subject.make_installed!
@@ -62,17 +62,17 @@ shared_examples 'cluster application status specs' do |application_name|
expect(subject.version).to eq(subject.class.const_get(:VERSION))
end
- context 'application is updating' do
+ context "application is updating" do
subject { create(application_name, :updating) }
- it 'is updated' do
+ it "is updated" do
subject.make_installed!
expect(subject).to be_updated
end
- it 'updates helm version' do
- subject.cluster.application_helm.update!(version: '1.2.3')
+ it "updates helm version" do
+ subject.cluster.application_helm.update!(version: "1.2.3")
subject.make_installed!
@@ -81,8 +81,8 @@ shared_examples 'cluster application status specs' do |application_name|
expect(subject.cluster.application_helm.version).to eq(Gitlab::Kubernetes::Helm::HELM_VERSION)
end
- it 'updates the version of the application' do
- subject.update!(version: '0.0.0')
+ it "updates the version of the application" do
+ subject.update!(version: "0.0.0")
subject.make_installed!
@@ -93,21 +93,21 @@ shared_examples 'cluster application status specs' do |application_name|
end
end
- describe '#make_errored' do
+ describe "#make_errored" do
subject { create(application_name, :installing) }
- let(:reason) { 'some errors' }
+ let(:reason) { "some errors" }
- it 'is errored' do
+ it "is errored" do
subject.make_errored(reason)
expect(subject).to be_errored
expect(subject.status_reason).to eq(reason)
end
- context 'application is updating' do
+ context "application is updating" do
subject { create(application_name, :updating) }
- it 'is update_errored' do
+ it "is update_errored" do
subject.make_errored(reason)
expect(subject).to be_update_errored
@@ -116,19 +116,19 @@ shared_examples 'cluster application status specs' do |application_name|
end
end
- describe '#make_scheduled' do
+ describe "#make_scheduled" do
subject { create(application_name, :installable) }
- it 'is scheduled' do
+ it "is scheduled" do
subject.make_scheduled
expect(subject).to be_scheduled
end
- describe 'when was errored' do
+ describe "when was errored" do
subject { create(application_name, :errored) }
- it 'clears #status_reason' do
+ it "clears #status_reason" do
expect(subject.status_reason).not_to be_nil
subject.make_scheduled!
@@ -137,10 +137,10 @@ shared_examples 'cluster application status specs' do |application_name|
end
end
- describe 'when was updated_errored' do
+ describe "when was updated_errored" do
subject { create(application_name, :update_errored) }
- it 'clears #status_reason' do
+ it "clears #status_reason" do
expect(subject.status_reason).not_to be_nil
subject.make_scheduled!
@@ -151,7 +151,7 @@ shared_examples 'cluster application status specs' do |application_name|
end
end
- describe '#available?' do
+ describe "#available?" do
using RSpec::Parameterized::TableSyntax
where(:trait, :available) do
diff --git a/spec/support/shared_examples/models/cluster_application_version_shared_examples.rb b/spec/support/shared_examples/models/cluster_application_version_shared_examples.rb
index 181b102e685..fdd905eb955 100644
--- a/spec/support/shared_examples/models/cluster_application_version_shared_examples.rb
+++ b/spec/support/shared_examples/models/cluster_application_version_shared_examples.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-shared_examples 'cluster application version specs' do |application_name|
- describe 'update_available?' do
- let(:version) { '0.0.0' }
+shared_examples "cluster application version specs" do |application_name|
+ describe "update_available?" do
+ let(:version) { "0.0.0" }
subject { create(application_name, :installed, version: version).update_available? }
- context 'version is not the same as VERSION' do
+ context "version is not the same as VERSION" do
it { is_expected.to be_truthy }
end
- context 'version is the same as VERSION' do
+ context "version is the same as VERSION" do
let(:application) { build(application_name) }
let(:version) { application.class.const_get(:VERSION) }
diff --git a/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb b/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb
index a4762b68858..2e690db7ab0 100644
--- a/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb
+++ b/spec/support/shared_examples/models/issuable_hook_data_shared_examples.rb
@@ -1,14 +1,14 @@
# This shared example requires a `builder` and `user` variable
-shared_examples 'issuable hook data' do |kind|
+shared_examples "issuable hook data" do |kind|
let(:data) { builder.build(user: user) }
- include_examples 'project hook data' do
+ include_examples "project hook data" do
let(:project) { builder.issuable.project }
end
- include_examples 'deprecated repository hook data'
+ include_examples "deprecated repository hook data"
context "with a #{kind}" do
- it 'contains issuable data' do
+ it "contains issuable data" do
expect(data[:object_kind]).to eq(kind)
expect(data[:user]).to eq(user.hook_attrs)
expect(data[:project]).to eq(builder.issuable.project.hook_attrs)
@@ -17,40 +17,40 @@ shared_examples 'issuable hook data' do |kind|
expect(data[:repository]).to eq(builder.issuable.project.hook_attrs.slice(:name, :url, :description, :homepage))
end
- it 'does not contain certain keys' do
+ it "does not contain certain keys" do
expect(data).not_to have_key(:assignees)
expect(data).not_to have_key(:assignee)
end
- describe 'changes are given' do
+ describe "changes are given" do
let(:changes) do
{
cached_markdown_version: %w[foo bar],
- description: ['A description', 'A cool description'],
+ description: ["A description", "A cool description"],
description_html: %w[foo bar],
in_progress_merge_commit_sha: %w[foo bar],
lock_version: %w[foo bar],
merge_jid: %w[foo bar],
- title: ['A title', 'Hello World'],
- title_html: %w[foo bar]
+ title: ["A title", "Hello World"],
+ title_html: %w[foo bar],
}
end
let(:data) { builder.build(user: user, changes: changes) }
- it 'populates the :changes hash' do
+ it "populates the :changes hash" do
expect(data[:changes]).to match(hash_including({
- title: { previous: 'A title', current: 'Hello World' },
- description: { previous: 'A description', current: 'A cool description' }
+ title: {previous: "A title", current: "Hello World"},
+ description: {previous: "A description", current: "A cool description"},
}))
end
- it 'does not contain certain keys' do
- expect(data[:changes]).not_to have_key('cached_markdown_version')
- expect(data[:changes]).not_to have_key('description_html')
- expect(data[:changes]).not_to have_key('lock_version')
- expect(data[:changes]).not_to have_key('title_html')
- expect(data[:changes]).not_to have_key('in_progress_merge_commit_sha')
- expect(data[:changes]).not_to have_key('merge_jid')
+ it "does not contain certain keys" do
+ expect(data[:changes]).not_to have_key("cached_markdown_version")
+ expect(data[:changes]).not_to have_key("description_html")
+ expect(data[:changes]).not_to have_key("lock_version")
+ expect(data[:changes]).not_to have_key("title_html")
+ expect(data[:changes]).not_to have_key("in_progress_merge_commit_sha")
+ expect(data[:changes]).not_to have_key("merge_jid")
end
end
end
diff --git a/spec/support/shared_examples/models/label_note_shared_examples.rb b/spec/support/shared_examples/models/label_note_shared_examples.rb
index 406385c13bd..7b45b466a2c 100644
--- a/spec/support/shared_examples/models/label_note_shared_examples.rb
+++ b/spec/support/shared_examples/models/label_note_shared_examples.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-shared_examples 'label note created from events' do
+shared_examples "label note created from events" do
def create_event(params = {})
- event_params = { action: :add, label: label, user: user }
+ event_params = {action: :add, label: label, user: user}
resource_key = resource.class.name.underscore.to_s
event_params[resource_key] = resource
@@ -12,14 +12,14 @@ shared_examples 'label note created from events' do
def label_refs(events)
labels = events.map(&:label).compact
- labels.map { |l| l.to_reference}.sort.join(' ')
+ labels.map { |l| l.to_reference}.sort.join(" ")
end
let(:time) { Time.now }
let(:local_label_ids) { [label.id, label2.id] }
- describe '.from_events' do
- it 'returns system note with expected attributes' do
+ describe ".from_events" do
+ it "returns system note with expected attributes" do
event = create_event
note = described_class.from_events([event, create_event])
@@ -32,7 +32,7 @@ shared_examples 'label note created from events' do
expect(note.note_html).to be_present
end
- it 'updates markdown cache if reference is not set yet' do
+ it "updates markdown cache if reference is not set yet" do
event = create_event(reference: nil)
described_class.from_events([event])
@@ -40,15 +40,15 @@ shared_examples 'label note created from events' do
expect(event.reference).not_to be_nil
end
- it 'updates markdown cache if label was deleted' do
- event = create_event(reference: 'some_ref', label: nil)
+ it "updates markdown cache if label was deleted" do
+ event = create_event(reference: "some_ref", label: nil)
described_class.from_events([event])
- expect(event.reference).to eq ''
+ expect(event.reference).to eq ""
end
- it 'returns html note' do
+ it "returns html note" do
events = [create_event(created_at: time)]
note = described_class.from_events(events)
@@ -56,39 +56,39 @@ shared_examples 'label note created from events' do
expect(note.note_html).to include label.title
end
- it 'returns text note for added labels' do
+ it "returns text note for added labels" do
events = [create_event(created_at: time),
create_event(created_at: time, label: label2),
- create_event(created_at: time, label: nil)]
+ create_event(created_at: time, label: nil),]
note = described_class.from_events(events)
expect(note.note).to eq "added #{label_refs(events)} + 1 deleted label"
end
- it 'returns text note for removed labels' do
+ it "returns text note for removed labels" do
events = [create_event(action: :remove, created_at: time),
create_event(action: :remove, created_at: time, label: label2),
- create_event(action: :remove, created_at: time, label: nil)]
+ create_event(action: :remove, created_at: time, label: nil),]
note = described_class.from_events(events)
expect(note.note).to eq "removed #{label_refs(events)} + 1 deleted label"
end
- it 'returns text note for added and removed labels' do
+ it "returns text note for added and removed labels" do
add_events = [create_event(created_at: time),
- create_event(created_at: time, label: nil)]
+ create_event(created_at: time, label: nil),]
remove_events = [create_event(action: :remove, created_at: time),
- create_event(action: :remove, created_at: time, label: nil)]
+ create_event(action: :remove, created_at: time, label: nil),]
note = described_class.from_events(add_events + remove_events)
expect(note.note).to eq "added #{label_refs(add_events)} + 1 deleted label and removed #{label_refs(remove_events)} + 1 deleted label"
end
- it 'returns text note for cross-project label' do
+ it "returns text note for cross-project label" do
other_label = create(:label)
event = create_event(label: other_label)
@@ -97,7 +97,7 @@ shared_examples 'label note created from events' do
expect(note.note).to eq "added #{other_label.to_reference(resource_parent)} label"
end
- it 'returns text note for cross-group label' do
+ it "returns text note for cross-group label" do
other_label = create(:group_label)
event = create_event(label: other_label)
diff --git a/spec/support/shared_examples/models/member_shared_examples.rb b/spec/support/shared_examples/models/member_shared_examples.rb
index 77376496854..510dbf4a593 100644
--- a/spec/support/shared_examples/models/member_shared_examples.rb
+++ b/spec/support/shared_examples/models/member_shared_examples.rb
@@ -1,35 +1,35 @@
# frozen_string_literal: true
-shared_examples_for 'inherited access level as a member of entity' do
+shared_examples_for "inherited access level as a member of entity" do
let(:parent_entity) { create(:group) }
let(:user) { create(:user) }
let(:member) { entity.is_a?(Group) ? entity.group_member(user) : entity.project_member(user) }
- context 'with root parent_entity developer member' do
+ context "with root parent_entity developer member" do
before do
parent_entity.add_developer(user)
end
- it 'is allowed to be a maintainer of the entity' do
+ it "is allowed to be a maintainer of the entity" do
entity.add_maintainer(user)
expect(member.access_level).to eq(Gitlab::Access::MAINTAINER)
end
- it 'is not allowed to be a reporter of the entity' do
+ it "is not allowed to be a reporter of the entity" do
entity.add_reporter(user)
expect(member).to be_nil
end
- it 'is allowed to change to be a developer of the entity' do
+ it "is allowed to change to be a developer of the entity" do
entity.add_maintainer(user)
expect { member.update(access_level: Gitlab::Access::DEVELOPER) }
.to change { member.access_level }.to(Gitlab::Access::DEVELOPER)
end
- it 'is not allowed to change to be a guest of the entity' do
+ it "is not allowed to change to be a guest of the entity" do
entity.add_maintainer(user)
expect { member.update(access_level: Gitlab::Access::GUEST) }
@@ -44,7 +44,7 @@ shared_examples_for 'inherited access level as a member of entity' do
expect(member.errors.full_messages).to eq(["Access level should be higher than Developer inherited membership from group #{parent_entity.name}"])
end
- it 'allows changing the level from a non existing member' do
+ it "allows changing the level from a non existing member" do
non_member_user = create(:user)
entity.add_maintainer(non_member_user)
@@ -57,19 +57,19 @@ shared_examples_for 'inherited access level as a member of entity' do
end
end
-shared_examples_for '#valid_level_roles' do |entity_name|
+shared_examples_for "#valid_level_roles" do |entity_name|
let(:member_user) { create(:user) }
let(:group) { create(:group) }
let(:entity) { create(entity_name) }
let(:entity_member) { create("#{entity_name}_member", :developer, source: entity, user: member_user) }
let(:presenter) { described_class.new(entity_member, current_user: member_user) }
- let(:expected_roles) { { 'Developer' => 30, 'Maintainer' => 40, 'Reporter' => 20 } }
+ let(:expected_roles) { {"Developer" => 30, "Maintainer" => 40, "Reporter" => 20} }
- it 'returns all roles when no parent member is present' do
+ it "returns all roles when no parent member is present" do
expect(presenter.valid_level_roles).to eq(entity_member.class.access_level_roles)
end
- it 'returns higher roles when a parent member is present' do
+ it "returns higher roles when a parent member is present" do
group.add_reporter(member_user)
expect(presenter.valid_level_roles).to eq(expected_roles)
diff --git a/spec/support/shared_examples/models/members_notifications_shared_example.rb b/spec/support/shared_examples/models/members_notifications_shared_example.rb
index ef5cea3f2a5..e09e1bb772e 100644
--- a/spec/support/shared_examples/models/members_notifications_shared_example.rb
+++ b/spec/support/shared_examples/models/members_notifications_shared_example.rb
@@ -1,5 +1,5 @@
-RSpec.shared_examples 'members notifications' do |entity_type|
- let(:notification_service) { double('NotificationService').as_null_object }
+RSpec.shared_examples "members notifications" do |entity_type|
+ let(:notification_service) { double("NotificationService").as_null_object }
before do
allow(member).to receive(:notification_service).and_return(notification_service)
@@ -31,7 +31,7 @@ RSpec.shared_examples 'members notifications' do |entity_type|
end
end
- describe '#accept_request' do
+ describe "#accept_request" do
let(:member) { create(:"#{entity_type}_member", :access_request) }
it "calls NotificationService.new_#{entity_type}_member" do
diff --git a/spec/support/shared_examples/models/project_hook_data_shared_examples.rb b/spec/support/shared_examples/models/project_hook_data_shared_examples.rb
index f0264878811..0e0cd71ecad 100644
--- a/spec/support/shared_examples/models/project_hook_data_shared_examples.rb
+++ b/spec/support/shared_examples/models/project_hook_data_shared_examples.rb
@@ -1,5 +1,5 @@
-shared_examples 'project hook data with deprecateds' do |project_key: :project|
- it 'contains project data' do
+shared_examples "project hook data with deprecateds" do |project_key: :project|
+ it "contains project data" do
expect(data[project_key][:name]).to eq(project.name)
expect(data[project_key][:description]).to eq(project.description)
expect(data[project_key][:web_url]).to eq(project.web_url)
@@ -17,8 +17,8 @@ shared_examples 'project hook data with deprecateds' do |project_key: :project|
end
end
-shared_examples 'project hook data' do |project_key: :project|
- it 'contains project data' do
+shared_examples "project hook data" do |project_key: :project|
+ it "contains project data" do
expect(data[project_key][:name]).to eq(project.name)
expect(data[project_key][:description]).to eq(project.description)
expect(data[project_key][:web_url]).to eq(project.web_url)
@@ -32,8 +32,8 @@ shared_examples 'project hook data' do |project_key: :project|
end
end
-shared_examples 'deprecated repository hook data' do
- it 'contains deprecated repository data' do
+shared_examples "deprecated repository hook data" do
+ it "contains deprecated repository data" do
expect(data[:repository][:name]).to eq(project.name)
expect(data[:repository][:description]).to eq(project.description)
expect(data[:repository][:url]).to eq(project.url_to_repo)
diff --git a/spec/support/shared_examples/models/with_uploads_shared_examples.rb b/spec/support/shared_examples/models/with_uploads_shared_examples.rb
index 43033a2d256..c8c965ff2d2 100644
--- a/spec/support/shared_examples/models/with_uploads_shared_examples.rb
+++ b/spec/support/shared_examples/models/with_uploads_shared_examples.rb
@@ -1,44 +1,44 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples_for 'model with uploads' do |supports_fileuploads|
- describe '.destroy' do
+shared_examples_for "model with uploads" do |supports_fileuploads|
+ describe ".destroy" do
before do
stub_uploads_object_storage(uploader_class)
model_object.public_send(upload_attribute).migrate!(ObjectStorage::Store::REMOTE)
end
- context 'with mounted uploader' do
- it 'deletes remote uploads' do
+ context "with mounted uploader" do
+ it "deletes remote uploads" do
expect_any_instance_of(CarrierWave::Storage::Fog::File).to receive(:delete).and_call_original
expect { model_object.destroy }.to change { Upload.count }.by(-1)
end
end
- context 'with not mounted uploads', :sidekiq, skip: !supports_fileuploads do
- context 'with local files' do
+ context "with not mounted uploads", :sidekiq, skip: !supports_fileuploads do
+ context "with local files" do
let!(:uploads) { create_list(:upload, 2, uploader: FileUploader, model: model_object) }
- it 'deletes any FileUploader uploads which are not mounted' do
+ it "deletes any FileUploader uploads which are not mounted" do
expect { model_object.destroy }.to change { Upload.count }.by(-3)
end
- it 'deletes local files' do
+ it "deletes local files" do
expect_any_instance_of(Uploads::Local).to receive(:delete_keys).with(uploads.map(&:absolute_path))
model_object.destroy
end
end
- context 'with remote files' do
+ context "with remote files" do
let!(:uploads) { create_list(:upload, 2, :object_storage, uploader: FileUploader, model: model_object) }
- it 'deletes any FileUploader uploads which are not mounted' do
+ it "deletes any FileUploader uploads which are not mounted" do
expect { model_object.destroy }.to change { Upload.count }.by(-3)
end
- it 'deletes remote files' do
+ it "deletes remote files" do
expect_any_instance_of(Uploads::Fog).to receive(:delete_keys).with(uploads.map(&:path))
model_object.destroy
diff --git a/spec/support/shared_examples/notify_shared_examples.rb b/spec/support/shared_examples/notify_shared_examples.rb
index 4fff1c4e228..86062c40003 100644
--- a/spec/support/shared_examples/notify_shared_examples.rb
+++ b/spec/support/shared_examples/notify_shared_examples.rb
@@ -1,11 +1,11 @@
-shared_context 'gitlab email notification' do
- set(:project) { create(:project, :repository, name: 'a-known-name') }
- set(:recipient) { create(:user, email: 'recipient@example.com') }
+shared_context "gitlab email notification" do
+ set(:project) { create(:project, :repository, name: "a-known-name") }
+ set(:recipient) { create(:user, email: "recipient@example.com") }
let(:gitlab_sender_display_name) { Gitlab.config.gitlab.email_display_name }
let(:gitlab_sender) { Gitlab.config.gitlab.email_from }
let(:gitlab_sender_reply_to) { Gitlab.config.gitlab.email_reply_to }
- let(:new_user_address) { 'newguy@example.com' }
+ let(:new_user_address) { "newguy@example.com" }
before do
email = recipient.emails.create(email: "notifications@example.com")
@@ -14,20 +14,20 @@ shared_context 'gitlab email notification' do
end
end
-shared_context 'reply-by-email is enabled with incoming address without %{key}' do
+shared_context "reply-by-email is enabled with incoming address without %{key}" do
before do
stub_incoming_email_setting(enabled: true, address: "reply@#{Gitlab.config.gitlab.host}")
end
end
-shared_examples 'a multiple recipients email' do
- it 'is sent to the given recipient' do
+shared_examples "a multiple recipients email" do
+ it "is sent to the given recipient" do
is_expected.to deliver_to recipient.notification_email
end
end
-shared_examples 'an email sent from GitLab' do
- it 'has the characteristics of an email sent from GitLab' do
+shared_examples "an email sent from GitLab" do
+ it "has the characteristics of an email sent from GitLab" do
sender = subject.header[:from].addrs[0]
reply_to = subject.header[:reply_to].addresses
@@ -39,192 +39,192 @@ shared_examples 'an email sent from GitLab' do
end
end
-shared_examples 'an email that contains a header with author username' do
- it 'has X-GitLab-Author header containing author\'s username' do
- is_expected.to have_header 'X-GitLab-Author', user.username
+shared_examples "an email that contains a header with author username" do
+ it "has X-GitLab-Author header containing author's username" do
+ is_expected.to have_header "X-GitLab-Author", user.username
end
end
-shared_examples 'an email with X-GitLab headers containing IDs' do
- it 'has X-GitLab-*-ID header' do
- is_expected.to have_header "X-GitLab-#{model.class.name}-ID", "#{model.id}"
+shared_examples "an email with X-GitLab headers containing IDs" do
+ it "has X-GitLab-*-ID header" do
+ is_expected.to have_header "X-GitLab-#{model.class.name}-ID", model.id.to_s
end
- it 'has X-GitLab-*-IID header if model has iid defined' do
+ it "has X-GitLab-*-IID header if model has iid defined" do
if model.respond_to?(:iid)
- is_expected.to have_header "X-GitLab-#{model.class.name}-IID", "#{model.iid}"
+ is_expected.to have_header "X-GitLab-#{model.class.name}-IID", model.iid.to_s
else
expect(subject.header["X-GitLab-#{model.class.name}-IID"]).to eq nil
end
end
end
-shared_examples 'an email with X-GitLab headers containing project details' do
- it 'has X-GitLab-Project headers' do
+shared_examples "an email with X-GitLab headers containing project details" do
+ it "has X-GitLab-Project headers" do
aggregate_failures do
full_path_as_domain = "#{project.name}.#{project.namespace.path}"
- is_expected.to have_header('X-GitLab-Project', /#{project.name}/)
- is_expected.to have_header('X-GitLab-Project-Id', /#{project.id}/)
- is_expected.to have_header('X-GitLab-Project-Path', /#{project.full_path}/)
- is_expected.to have_header('List-Id', "#{project.full_path} <#{project.id}.#{full_path_as_domain}.#{Gitlab.config.gitlab.host}>")
+ is_expected.to have_header("X-GitLab-Project", /#{project.name}/)
+ is_expected.to have_header("X-GitLab-Project-Id", /#{project.id}/)
+ is_expected.to have_header("X-GitLab-Project-Path", /#{project.full_path}/)
+ is_expected.to have_header("List-Id", "#{project.full_path} <#{project.id}.#{full_path_as_domain}.#{Gitlab.config.gitlab.host}>")
end
end
end
-shared_examples 'a new thread email with reply-by-email enabled' do
- it 'has the characteristics of a threaded email' do
+shared_examples "a new thread email with reply-by-email enabled" do
+ it "has the characteristics of a threaded email" do
host = Gitlab.config.gitlab.host
route_key = "#{model.class.model_name.singular_route_key}_#{model.id}"
aggregate_failures do
- is_expected.to have_header('Message-ID', "<#{route_key}@#{host}>")
- is_expected.to have_header('References', /\A<reply\-.*@#{host}>\Z/ )
+ is_expected.to have_header("Message-ID", "<#{route_key}@#{host}>")
+ is_expected.to have_header("References", /\A<reply\-.*@#{host}>\Z/)
end
end
end
-shared_examples 'a thread answer email with reply-by-email enabled' do
- include_examples 'an email with X-GitLab headers containing project details'
- include_examples 'an email with X-GitLab headers containing IDs'
+shared_examples "a thread answer email with reply-by-email enabled" do
+ include_examples "an email with X-GitLab headers containing project details"
+ include_examples "an email with X-GitLab headers containing IDs"
- it 'has the characteristics of a threaded reply' do
+ it "has the characteristics of a threaded reply" do
host = Gitlab.config.gitlab.host
route_key = "#{model.class.model_name.singular_route_key}_#{model.id}"
aggregate_failures do
- is_expected.to have_header('Message-ID', /\A<.*@#{host}>\Z/)
- is_expected.to have_header('In-Reply-To', "<#{route_key}@#{host}>")
- is_expected.to have_header('References', /\A<reply\-.*@#{host}> <#{route_key}@#{host}>\Z/ )
+ is_expected.to have_header("Message-ID", /\A<.*@#{host}>\Z/)
+ is_expected.to have_header("In-Reply-To", "<#{route_key}@#{host}>")
+ is_expected.to have_header("References", /\A<reply\-.*@#{host}> <#{route_key}@#{host}>\Z/)
is_expected.to have_subject(/^Re: /)
end
end
end
-shared_examples 'an email starting a new thread with reply-by-email enabled' do
- include_examples 'an email with X-GitLab headers containing project details'
- include_examples 'an email with X-GitLab headers containing IDs'
- include_examples 'a new thread email with reply-by-email enabled'
+shared_examples "an email starting a new thread with reply-by-email enabled" do
+ include_examples "an email with X-GitLab headers containing project details"
+ include_examples "an email with X-GitLab headers containing IDs"
+ include_examples "a new thread email with reply-by-email enabled"
it 'includes "Reply to this email directly or <View it on GitLab>"' do
expect(subject.default_part.body).to include(%(Reply to this email directly or <a href="#{Gitlab::UrlBuilder.build(model)}">view it on GitLab</a>.))
end
- context 'when reply-by-email is enabled with incoming address with %{key}' do
- it 'has a Reply-To header' do
- is_expected.to have_header 'Reply-To', /<reply+(.*)@#{Gitlab.config.gitlab.host}>\Z/
+ context "when reply-by-email is enabled with incoming address with %{key}" do
+ it "has a Reply-To header" do
+ is_expected.to have_header "Reply-To", /<reply+(.*)@#{Gitlab.config.gitlab.host}>\Z/
end
end
- context 'when reply-by-email is enabled with incoming address without %{key}' do
- include_context 'reply-by-email is enabled with incoming address without %{key}'
- include_examples 'a new thread email with reply-by-email enabled'
+ context "when reply-by-email is enabled with incoming address without %{key}" do
+ include_context "reply-by-email is enabled with incoming address without %{key}"
+ include_examples "a new thread email with reply-by-email enabled"
- it 'has a Reply-To header' do
- is_expected.to have_header 'Reply-To', /<reply@#{Gitlab.config.gitlab.host}>\Z/
+ it "has a Reply-To header" do
+ is_expected.to have_header "Reply-To", /<reply@#{Gitlab.config.gitlab.host}>\Z/
end
end
end
-shared_examples 'an answer to an existing thread with reply-by-email enabled' do
- include_examples 'an email with X-GitLab headers containing project details'
- include_examples 'an email with X-GitLab headers containing IDs'
- include_examples 'a thread answer email with reply-by-email enabled'
+shared_examples "an answer to an existing thread with reply-by-email enabled" do
+ include_examples "an email with X-GitLab headers containing project details"
+ include_examples "an email with X-GitLab headers containing IDs"
+ include_examples "a thread answer email with reply-by-email enabled"
- context 'when reply-by-email is enabled with incoming address with %{key}' do
- it 'has a Reply-To header' do
- is_expected.to have_header 'Reply-To', /<reply+(.*)@#{Gitlab.config.gitlab.host}>\Z/
+ context "when reply-by-email is enabled with incoming address with %{key}" do
+ it "has a Reply-To header" do
+ is_expected.to have_header "Reply-To", /<reply+(.*)@#{Gitlab.config.gitlab.host}>\Z/
end
end
- context 'when reply-by-email is enabled with incoming address without %{key}' do
- include_context 'reply-by-email is enabled with incoming address without %{key}'
- include_examples 'a thread answer email with reply-by-email enabled'
+ context "when reply-by-email is enabled with incoming address without %{key}" do
+ include_context "reply-by-email is enabled with incoming address without %{key}"
+ include_examples "a thread answer email with reply-by-email enabled"
- it 'has a Reply-To header' do
- is_expected.to have_header 'Reply-To', /<reply@#{Gitlab.config.gitlab.host}>\Z/
+ it "has a Reply-To header" do
+ is_expected.to have_header "Reply-To", /<reply@#{Gitlab.config.gitlab.host}>\Z/
end
end
end
-shared_examples 'it should have Gmail Actions links' do
+shared_examples "it should have Gmail Actions links" do
it do
aggregate_failures do
is_expected.to have_body_text('<script type="application/ld+json">')
- is_expected.to have_body_text('ViewAction')
+ is_expected.to have_body_text("ViewAction")
end
end
end
-shared_examples 'it should not have Gmail Actions links' do
+shared_examples "it should not have Gmail Actions links" do
it do
aggregate_failures do
is_expected.not_to have_body_text('<script type="application/ld+json">')
- is_expected.not_to have_body_text('ViewAction')
+ is_expected.not_to have_body_text("ViewAction")
end
end
end
-shared_examples 'it should show Gmail Actions View Issue link' do
- it_behaves_like 'it should have Gmail Actions links'
+shared_examples "it should show Gmail Actions View Issue link" do
+ it_behaves_like "it should have Gmail Actions links"
- it { is_expected.to have_body_text('View Issue') }
+ it { is_expected.to have_body_text("View Issue") }
end
-shared_examples 'it should show Gmail Actions View Merge request link' do
- it_behaves_like 'it should have Gmail Actions links'
+shared_examples "it should show Gmail Actions View Merge request link" do
+ it_behaves_like "it should have Gmail Actions links"
- it { is_expected.to have_body_text('View Merge request') }
+ it { is_expected.to have_body_text("View Merge request") }
end
-shared_examples 'it should show Gmail Actions View Commit link' do
- it_behaves_like 'it should have Gmail Actions links'
+shared_examples "it should show Gmail Actions View Commit link" do
+ it_behaves_like "it should have Gmail Actions links"
- it { is_expected.to have_body_text('View Commit') }
+ it { is_expected.to have_body_text("View Commit") }
end
-shared_examples 'an unsubscribeable thread' do
- it_behaves_like 'an unsubscribeable thread with incoming address without %{key}'
+shared_examples "an unsubscribeable thread" do
+ it_behaves_like "an unsubscribeable thread with incoming address without %{key}"
- it 'has a List-Unsubscribe header in the correct format, and a body link' do
+ it "has a List-Unsubscribe header in the correct format, and a body link" do
aggregate_failures do
- is_expected.to have_header('List-Unsubscribe', /unsubscribe/)
- is_expected.to have_header('List-Unsubscribe', /mailto/)
- is_expected.to have_header('List-Unsubscribe', /^<.+,.+>$/)
- is_expected.to have_body_text('unsubscribe')
+ is_expected.to have_header("List-Unsubscribe", /unsubscribe/)
+ is_expected.to have_header("List-Unsubscribe", /mailto/)
+ is_expected.to have_header("List-Unsubscribe", /^<.+,.+>$/)
+ is_expected.to have_body_text("unsubscribe")
end
end
end
-shared_examples 'an unsubscribeable thread with incoming address without %{key}' do
- include_context 'reply-by-email is enabled with incoming address without %{key}'
+shared_examples "an unsubscribeable thread with incoming address without %{key}" do
+ include_context "reply-by-email is enabled with incoming address without %{key}"
- it 'has a List-Unsubscribe header in the correct format, and a body link' do
+ it "has a List-Unsubscribe header in the correct format, and a body link" do
aggregate_failures do
- is_expected.to have_header('List-Unsubscribe', /unsubscribe/)
- is_expected.not_to have_header('List-Unsubscribe', /mailto/)
- is_expected.to have_header('List-Unsubscribe', /^<[^,]+>$/)
- is_expected.to have_body_text('unsubscribe')
+ is_expected.to have_header("List-Unsubscribe", /unsubscribe/)
+ is_expected.not_to have_header("List-Unsubscribe", /mailto/)
+ is_expected.to have_header("List-Unsubscribe", /^<[^,]+>$/)
+ is_expected.to have_body_text("unsubscribe")
end
end
end
-shared_examples 'a user cannot unsubscribe through footer link' do
- it 'does not have a List-Unsubscribe header or a body link' do
+shared_examples "a user cannot unsubscribe through footer link" do
+ it "does not have a List-Unsubscribe header or a body link" do
aggregate_failures do
- is_expected.not_to have_header('List-Unsubscribe', /unsubscribe/)
- is_expected.not_to have_body_text('unsubscribe')
+ is_expected.not_to have_header("List-Unsubscribe", /unsubscribe/)
+ is_expected.not_to have_body_text("unsubscribe")
end
end
end
-shared_examples 'an email with a labels subscriptions link in its footer' do
- it { is_expected.to have_body_text('label subscriptions') }
+shared_examples "an email with a labels subscriptions link in its footer" do
+ it { is_expected.to have_body_text("label subscriptions") }
end
-shared_examples 'a note email' do
- it_behaves_like 'it should have Gmail Actions links'
+shared_examples "a note email" do
+ it_behaves_like "it should have Gmail Actions links"
- it 'is sent to the given recipient as the author' do
+ it "is sent to the given recipient as the author" do
sender = subject.header[:from].addrs[0]
aggregate_failures do
@@ -234,26 +234,26 @@ shared_examples 'a note email' do
end
end
- it 'contains the message from the note' do
+ it "contains the message from the note" do
is_expected.to have_body_text note.note
end
- it 'does not contain note author' do
+ it "does not contain note author" do
is_expected.not_to have_body_text note.author_name
end
- context 'when enabled email_author_in_body' do
+ context "when enabled email_author_in_body" do
before do
stub_application_setting(email_author_in_body: true)
end
- it 'contains a link to note author' do
+ it "contains a link to note author" do
is_expected.to have_body_text note.author_name
end
end
end
-shared_examples 'appearance header and footer enabled' do
+shared_examples "appearance header and footer enabled" do
it "contains header and footer" do
create :appearance, header_message: "Foo", footer_message: "Bar", email_header_and_footer_enabled: true
@@ -267,7 +267,7 @@ shared_examples 'appearance header and footer enabled' do
end
end
-shared_examples 'appearance header and footer not enabled' do
+shared_examples "appearance header and footer not enabled" do
it "does not contain header and footer" do
create :appearance, header_message: "Foo", footer_message: "Bar", email_header_and_footer_enabled: false
diff --git a/spec/support/shared_examples/policies/clusterable_shared_examples.rb b/spec/support/shared_examples/policies/clusterable_shared_examples.rb
index d99f94c76c3..fe82e8d46b9 100644
--- a/spec/support/shared_examples/policies/clusterable_shared_examples.rb
+++ b/spec/support/shared_examples/policies/clusterable_shared_examples.rb
@@ -1,14 +1,14 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'clusterable policies' do
- describe '#add_cluster?' do
+shared_examples "clusterable policies" do
+ describe "#add_cluster?" do
let(:current_user) { create(:user) }
subject { described_class.new(current_user, clusterable) }
- context 'with a developer' do
+ context "with a developer" do
before do
clusterable.add_developer(current_user)
end
@@ -16,16 +16,16 @@ shared_examples 'clusterable policies' do
it { expect_disallowed(:add_cluster) }
end
- context 'with a maintainer' do
+ context "with a maintainer" do
before do
clusterable.add_maintainer(current_user)
end
- context 'with no clusters' do
+ context "with no clusters" do
it { expect_allowed(:add_cluster) }
end
- context 'with an existing cluster' do
+ context "with an existing cluster" do
before do
cluster
end
diff --git a/spec/support/shared_examples/position_formatters.rb b/spec/support/shared_examples/position_formatters.rb
index ffc9456dbc7..2e794f94290 100644
--- a/spec/support/shared_examples/position_formatters.rb
+++ b/spec/support/shared_examples/position_formatters.rb
@@ -1,7 +1,7 @@
shared_examples_for "position formatter" do
let(:formatter) { described_class.new(attrs) }
- describe '#key' do
+ describe "#key" do
let(:key) { [123, 456, 789, Digest::SHA1.hexdigest(formatter.old_path), Digest::SHA1.hexdigest(formatter.new_path), 1, 2] }
subject { formatter.key }
@@ -9,23 +9,23 @@ shared_examples_for "position formatter" do
it { is_expected.to eq(key) }
end
- describe '#complete?' do
+ describe "#complete?" do
subject { formatter.complete? }
- context 'when there are missing key attributes' do
+ context "when there are missing key attributes" do
it { is_expected.to be_truthy }
end
- context 'when old_line and new_line are nil' do
+ context "when old_line and new_line are nil" do
let(:attrs) { base_attrs }
it { is_expected.to be_falsy }
end
end
- describe '#to_h' do
+ describe "#to_h" do
let(:formatter_hash) do
- attrs.merge(position_type: base_attrs[:position_type] || 'text' )
+ attrs.merge(position_type: base_attrs[:position_type] || "text")
end
subject { formatter.to_h }
@@ -33,7 +33,7 @@ shared_examples_for "position formatter" do
it { is_expected.to eq(formatter_hash) }
end
- describe '#==' do
+ describe "#==" do
subject { formatter }
let(:other_formatter) { described_class.new(attrs) }
diff --git a/spec/support/shared_examples/project_list_shared_examples.rb b/spec/support/shared_examples/project_list_shared_examples.rb
index 675d489fcab..74c0b3c91f5 100644
--- a/spec/support/shared_examples/project_list_shared_examples.rb
+++ b/spec/support/shared_examples/project_list_shared_examples.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
-shared_examples 'shows public projects' do
- it 'shows projects' do
+shared_examples "shows public projects" do
+ it "shows projects" do
expect(page).to have_content(public_project.title)
expect(page).not_to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
@@ -9,8 +9,8 @@ shared_examples 'shows public projects' do
end
end
-shared_examples 'shows public and internal projects' do
- it 'shows projects' do
+shared_examples "shows public and internal projects" do
+ it "shows projects" do
expect(page).to have_content(public_project.title)
expect(page).to have_content(internal_project.title)
expect(page).not_to have_content(private_project.title)
diff --git a/spec/support/shared_examples/reference_parser_shared_examples.rb b/spec/support/shared_examples/reference_parser_shared_examples.rb
index baf8bcc04b8..36d03cca7af 100644
--- a/spec/support/shared_examples/reference_parser_shared_examples.rb
+++ b/spec/support/shared_examples/reference_parser_shared_examples.rb
@@ -4,7 +4,7 @@ RSpec.shared_examples "referenced feature visibility" do |*related_features|
end
before do
- link['data-project'] = project.id.to_s
+ link["data-project"] = project.id.to_s
end
context "when feature is disabled" do
diff --git a/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb b/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb
index 8a7fcf856a1..8e678b5a192 100644
--- a/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/custom_attributes_shared_examples.rb
@@ -1,29 +1,29 @@
-shared_examples 'custom attributes endpoints' do |attributable_name|
- let!(:custom_attribute1) { attributable.custom_attributes.create key: 'foo', value: 'foo' }
- let!(:custom_attribute2) { attributable.custom_attributes.create key: 'bar', value: 'bar' }
+shared_examples "custom attributes endpoints" do |attributable_name|
+ let!(:custom_attribute1) { attributable.custom_attributes.create key: "foo", value: "foo" }
+ let!(:custom_attribute2) { attributable.custom_attributes.create key: "bar", value: "bar" }
describe "GET /#{attributable_name} with custom attributes filter" do
before do
other_attributable
end
- context 'with an unauthorized user' do
- it 'does not filter by custom attributes' do
- get api("/#{attributable_name}", user), params: { custom_attributes: { foo: 'foo', bar: 'bar' } }
+ context "with an unauthorized user" do
+ it "does not filter by custom attributes" do
+ get api("/#{attributable_name}", user), params: {custom_attributes: {foo: "foo", bar: "bar"}}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to be 2
- expect(json_response.map { |r| r['id'] }).to contain_exactly attributable.id, other_attributable.id
+ expect(json_response.map { |r| r["id"] }).to contain_exactly attributable.id, other_attributable.id
end
end
- context 'with an authorized user' do
- it 'filters by custom attributes' do
- get api("/#{attributable_name}", admin), params: { custom_attributes: { foo: 'foo', bar: 'bar' } }
+ context "with an authorized user" do
+ it "filters by custom attributes" do
+ get api("/#{attributable_name}", admin), params: {custom_attributes: {foo: "foo", bar: "bar"}}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to be 1
- expect(json_response.first['id']).to eq attributable.id
+ expect(json_response.first["id"]).to eq attributable.id
end
end
end
@@ -33,157 +33,157 @@ shared_examples 'custom attributes endpoints' do |attributable_name|
other_attributable
end
- context 'with an unauthorized user' do
- it 'does not include custom attributes' do
- get api("/#{attributable_name}", user), params: { with_custom_attributes: true }
+ context "with an unauthorized user" do
+ it "does not include custom attributes" do
+ get api("/#{attributable_name}", user), params: {with_custom_attributes: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to be 2
- expect(json_response.first).not_to include 'custom_attributes'
+ expect(json_response.first).not_to include "custom_attributes"
end
end
- context 'with an authorized user' do
- it 'does not include custom attributes by default' do
+ context "with an authorized user" do
+ it "does not include custom attributes by default" do
get api("/#{attributable_name}", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to be 2
- expect(json_response.first).not_to include 'custom_attributes'
- expect(json_response.second).not_to include 'custom_attributes'
+ expect(json_response.first).not_to include "custom_attributes"
+ expect(json_response.second).not_to include "custom_attributes"
end
- it 'includes custom attributes if requested' do
- get api("/#{attributable_name}", admin), params: { with_custom_attributes: true }
+ it "includes custom attributes if requested" do
+ get api("/#{attributable_name}", admin), params: {with_custom_attributes: true}
expect(response).to have_gitlab_http_status(200)
expect(json_response.size).to be 2
- attributable_response = json_response.find { |r| r['id'] == attributable.id }
- other_attributable_response = json_response.find { |r| r['id'] == other_attributable.id }
+ attributable_response = json_response.find { |r| r["id"] == attributable.id }
+ other_attributable_response = json_response.find { |r| r["id"] == other_attributable.id }
- expect(attributable_response['custom_attributes']).to contain_exactly(
- { 'key' => 'foo', 'value' => 'foo' },
- { 'key' => 'bar', 'value' => 'bar' }
+ expect(attributable_response["custom_attributes"]).to contain_exactly(
+ {"key" => "foo", "value" => "foo"},
+ {"key" => "bar", "value" => "bar"}
)
- expect(other_attributable_response['custom_attributes']).to eq []
+ expect(other_attributable_response["custom_attributes"]).to eq []
end
end
end
describe "GET /#{attributable_name}/:id with custom attributes" do
- context 'with an unauthorized user' do
- it 'does not include custom attributes' do
- get api("/#{attributable_name}/#{attributable.id}", user), params: { with_custom_attributes: true }
+ context "with an unauthorized user" do
+ it "does not include custom attributes" do
+ get api("/#{attributable_name}/#{attributable.id}", user), params: {with_custom_attributes: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response).not_to include 'custom_attributes'
+ expect(json_response).not_to include "custom_attributes"
end
end
- context 'with an authorized user' do
- it 'does not include custom attributes by default' do
+ context "with an authorized user" do
+ it "does not include custom attributes by default" do
get api("/#{attributable_name}/#{attributable.id}", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).not_to include 'custom_attributes'
+ expect(json_response).not_to include "custom_attributes"
end
- it 'includes custom attributes if requested' do
- get api("/#{attributable_name}/#{attributable.id}", admin), params: { with_custom_attributes: true }
+ it "includes custom attributes if requested" do
+ get api("/#{attributable_name}/#{attributable.id}", admin), params: {with_custom_attributes: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['custom_attributes']).to contain_exactly(
- { 'key' => 'foo', 'value' => 'foo' },
- { 'key' => 'bar', 'value' => 'bar' }
+ expect(json_response["custom_attributes"]).to contain_exactly(
+ {"key" => "foo", "value" => "foo"},
+ {"key" => "bar", "value" => "bar"}
)
end
end
end
describe "GET /#{attributable_name}/:id/custom_attributes" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject { get api("/#{attributable_name}/#{attributable.id}/custom_attributes", user) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
- context 'with an authorized user' do
- it 'returns all custom attributes' do
+ context "with an authorized user" do
+ it "returns all custom attributes" do
get api("/#{attributable_name}/#{attributable.id}/custom_attributes", admin)
expect(response).to have_gitlab_http_status(200)
expect(json_response).to contain_exactly(
- { 'key' => 'foo', 'value' => 'foo' },
- { 'key' => 'bar', 'value' => 'bar' }
+ {"key" => "foo", "value" => "foo"},
+ {"key" => "bar", "value" => "bar"}
)
end
end
end
describe "GET /#{attributable_name}/:id/custom_attributes/:key" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject { get api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
- context 'with an authorized user' do
- it'returns a single custom attribute' do
+ context "with an authorized user" do
+ it"returns a single custom attribute" do
get api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq({ 'key' => 'foo', 'value' => 'foo' })
+ expect(json_response).to eq({"key" => "foo", "value" => "foo"})
end
end
end
describe "PUT /#{attributable_name}/:id/custom_attributes/:key" do
- context 'with an unauthorized user' do
- subject { put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user), params: { value: 'new' } }
+ context "with an unauthorized user" do
+ subject { put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user), params: {value: "new"} }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
- context 'with an authorized user' do
- it 'creates a new custom attribute' do
- expect do
- put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: { value: 'new' }
- end.to change { attributable.custom_attributes.count }.by(1)
+ context "with an authorized user" do
+ it "creates a new custom attribute" do
+ expect {
+ put api("/#{attributable_name}/#{attributable.id}/custom_attributes/new", admin), params: {value: "new"}
+ }.to change { attributable.custom_attributes.count }.by(1)
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq({ 'key' => 'new', 'value' => 'new' })
- expect(attributable.custom_attributes.find_by(key: 'new').value).to eq 'new'
+ expect(json_response).to eq({"key" => "new", "value" => "new"})
+ expect(attributable.custom_attributes.find_by(key: "new").value).to eq "new"
end
- it 'updates an existing custom attribute' do
- expect do
- put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: { value: 'new' }
- end.not_to change { attributable.custom_attributes.count }
+ it "updates an existing custom attribute" do
+ expect {
+ put api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin), params: {value: "new"}
+ }.not_to change { attributable.custom_attributes.count }
expect(response).to have_gitlab_http_status(200)
- expect(json_response).to eq({ 'key' => 'foo', 'value' => 'new' })
- expect(custom_attribute1.reload.value).to eq 'new'
+ expect(json_response).to eq({"key" => "foo", "value" => "new"})
+ expect(custom_attribute1.reload.value).to eq "new"
end
end
end
describe "DELETE /#{attributable_name}/:id/custom_attributes/:key" do
- context 'with an unauthorized user' do
+ context "with an unauthorized user" do
subject { delete api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", user) }
- it_behaves_like 'an unauthorized API user'
+ it_behaves_like "an unauthorized API user"
end
- context 'with an authorized user' do
- it 'deletes an existing custom attribute' do
- expect do
+ context "with an authorized user" do
+ it "deletes an existing custom attribute" do
+ expect {
delete api("/#{attributable_name}/#{attributable.id}/custom_attributes/foo", admin)
- end.to change { attributable.custom_attributes.count }.by(-1)
+ }.to change { attributable.custom_attributes.count }.by(-1)
expect(response).to have_gitlab_http_status(204)
- expect(attributable.custom_attributes.find_by(key: 'foo')).to be_nil
+ expect(attributable.custom_attributes.find_by(key: "foo")).to be_nil
end
end
end
diff --git a/spec/support/shared_examples/requests/api/diff_discussions.rb b/spec/support/shared_examples/requests/api/diff_discussions.rb
index 366c2955359..4657ffbc555 100644
--- a/spec/support/shared_examples/requests/api/diff_discussions.rb
+++ b/spec/support/shared_examples/requests/api/diff_discussions.rb
@@ -1,14 +1,14 @@
-shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
+shared_examples "diff discussions API" do |parent_type, noteable_type, id_name|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "includes diff discussions" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user)
- discussion = json_response.find { |record| record['id'] == diff_note.discussion_id }
+ discussion = json_response.find { |record| record["id"] == diff_note.discussion_id }
expect(response).to have_gitlab_http_status(200)
expect(discussion).not_to be_nil
- expect(discussion['individual_note']).to eq(false)
- expect(discussion['notes'].first['body']).to eq(diff_note.note)
+ expect(discussion["individual_note"]).to eq(false)
+ expect(discussion["notes"].first["body"]).to eq(diff_note.note)
end
end
@@ -17,9 +17,9 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{diff_note.discussion_id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(diff_note.discussion_id)
- expect(json_response['notes'].first['body']).to eq(diff_note.note)
- expect(json_response['notes'].first['position']).to eq(diff_note.position.to_h.stringify_keys)
+ expect(json_response["id"]).to eq(diff_note.discussion_id)
+ expect(json_response["notes"].first["body"]).to eq(diff_note.note)
+ expect(json_response["notes"].first["position"]).to eq(diff_note.position.to_h.stringify_keys)
end
end
@@ -28,32 +28,32 @@ shared_examples 'diff discussions API' do |parent_type, noteable_type, id_name|
position = diff_note.position.to_h
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
- params: { body: 'hi!', position: position }
+ params: {body: "hi!", position: position}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['notes'].first['body']).to eq('hi!')
- expect(json_response['notes'].first['type']).to eq('DiffNote')
- expect(json_response['notes'].first['position']).to eq(position.stringify_keys)
+ expect(json_response["notes"].first["body"]).to eq("hi!")
+ expect(json_response["notes"].first["type"]).to eq("DiffNote")
+ expect(json_response["notes"].first["position"]).to eq(position.stringify_keys)
end
it "returns a 400 bad request error when position is invalid" do
- position = diff_note.position.to_h.merge(new_line: '100000')
+ position = diff_note.position.to_h.merge(new_line: "100000")
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
- params: { body: 'hi!', position: position }
+ params: {body: "hi!", position: position}
expect(response).to have_gitlab_http_status(400)
end
end
describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes" do
- it 'adds a new note to the diff discussion' do
+ it "adds a new note to the diff discussion" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{diff_note.discussion_id}/notes", user), params: { body: 'hi!' }
+ "discussions/#{diff_note.discussion_id}/notes", user), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['type']).to eq('DiffNote')
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["type"]).to eq("DiffNote")
end
end
end
diff --git a/spec/support/shared_examples/requests/api/discussions.rb b/spec/support/shared_examples/requests/api/discussions.rb
index e44da4faa5a..316f6ae448f 100644
--- a/spec/support/shared_examples/requests/api/discussions.rb
+++ b/spec/support/shared_examples/requests/api/discussions.rb
@@ -1,4 +1,4 @@
-shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
+shared_examples "discussions API" do |parent_type, noteable_type, id_name|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "returns an array of discussions" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user)
@@ -6,7 +6,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['id']).to eq(note.discussion_id)
+ expect(json_response.first["id"]).to eq(note.discussion_id)
end
it "returns a 404 error when noteable id not found" do
@@ -29,8 +29,8 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions/#{note.discussion_id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['id']).to eq(note.discussion_id)
- expect(json_response['notes'].first['body']).to eq(note.note)
+ expect(json_response["id"]).to eq(note.discussion_id)
+ expect(json_response["notes"].first["body"]).to eq(note.note)
end
it "returns a 404 error if discussion not found" do
@@ -42,11 +42,11 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions" do
it "creates a new note" do
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: { body: 'hi!' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['notes'].first['body']).to eq('hi!')
- expect(json_response['notes'].first['author']['username']).to eq(user.username)
+ expect(json_response["notes"].first["body"]).to eq("hi!")
+ expect(json_response["notes"].first["author"]["username"]).to eq(user.username)
end
it "returns a 400 bad request error if body not given" do
@@ -56,32 +56,32 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
end
it "returns a 401 unauthorized error if user not authenticated" do
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: { body: 'hi!' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions"), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(401)
end
- context 'when an admin or owner makes the request' do
- it 'accepts the creation date to be set' do
+ context "when an admin or owner makes the request" do
+ it "accepts the creation date to be set" do
creation_time = 2.weeks.ago
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", user),
- params: { body: 'hi!', created_at: creation_time }
+ params: {body: "hi!", created_at: creation_time}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['notes'].first['body']).to eq('hi!')
- expect(json_response['notes'].first['author']['username']).to eq(user.username)
- expect(Time.parse(json_response['notes'].first['created_at'])).to be_like_time(creation_time)
+ expect(json_response["notes"].first["body"]).to eq("hi!")
+ expect(json_response["notes"].first["author"]["username"]).to eq(user.username)
+ expect(Time.parse(json_response["notes"].first["created_at"])).to be_like_time(creation_time)
end
end
- context 'when user does not have access to read the discussion' do
+ context "when user does not have access to read the discussion" do
before do
parent.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'responds with 404' do
+ it "responds with 404" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/discussions", private_user),
- params: { body: 'Foo' }
+ params: {body: "Foo"}
expect(response).to have_gitlab_http_status(404)
end
@@ -89,16 +89,16 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
end
describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes" do
- it 'adds a new note to the discussion' do
+ it "adds a new note to the discussion" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes", user), params: { body: 'Hello!' }
+ "discussions/#{note.discussion_id}/notes", user), params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('Hello!')
- expect(json_response['type']).to eq('DiscussionNote')
+ expect(json_response["body"]).to eq("Hello!")
+ expect(json_response["type"]).to eq("DiscussionNote")
end
- it 'returns a 400 bad request error if body not given' do
+ it "returns a 400 bad request error if body not given" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes", user)
@@ -109,30 +109,30 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
note.update_attribute(:type, nil)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes", user), params: { body: 'hi!' }
+ "discussions/#{note.discussion_id}/notes", user), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(400)
end
end
describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
- it 'returns modified note' do
+ it "returns modified note" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { body: 'Hello!' }
+ "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['body']).to eq('Hello!')
+ expect(json_response["body"]).to eq("Hello!")
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/12345", user),
- params: { body: 'Hello!' }
+ params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 400 bad request error if body not given' do
+ it "returns a 400 bad request error if body not given" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user)
@@ -141,7 +141,7 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
end
describe "DELETE /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
- it 'deletes a note' do
+ it "deletes a note" do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user)
@@ -152,14 +152,14 @@ shared_examples 'discussions API' do |parent_type, noteable_type, id_name|
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/12345", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) do
api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user)
diff --git a/spec/support/shared_examples/requests/api/issuable_participants_examples.rb b/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
index 96d59e0c472..e6cd45175f6 100644
--- a/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
+++ b/spec/support/shared_examples/requests/api/issuable_participants_examples.rb
@@ -1,7 +1,7 @@
-shared_examples 'issuable participants endpoint' do
+shared_examples "issuable participants endpoint" do
let(:area) { entity.class.name.underscore.pluralize }
- it 'returns participants' do
+ it "returns participants" do
get api("/projects/#{project.id}/#{area}/#{entity.iid}/participants", user)
expect(response).to have_gitlab_http_status(200)
@@ -10,18 +10,18 @@ shared_examples 'issuable participants endpoint' do
expect(json_response.size).to eq(entity.participants.size)
last_participant = entity.participants.last
- expect(json_response.last['id']).to eq(last_participant.id)
- expect(json_response.last['name']).to eq(last_participant.name)
- expect(json_response.last['username']).to eq(last_participant.username)
+ expect(json_response.last["id"]).to eq(last_participant.id)
+ expect(json_response.last["name"]).to eq(last_participant.name)
+ expect(json_response.last["username"]).to eq(last_participant.username)
end
- it 'returns a 404 when iid does not exist' do
+ it "returns a 404 when iid does not exist" do
get api("/projects/#{project.id}/#{area}/999/participants", user)
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 when id is used instead of iid' do
+ it "returns a 404 when id is used instead of iid" do
get api("/projects/#{project.id}/#{area}/#{entity.id}/participants", user)
expect(response).to have_gitlab_http_status(404)
diff --git a/spec/support/shared_examples/requests/api/merge_requests_list.rb b/spec/support/shared_examples/requests/api/merge_requests_list.rb
index 6713ec47ace..022bc352fd1 100644
--- a/spec/support/shared_examples/requests/api/merge_requests_list.rb
+++ b/spec/support/shared_examples/requests/api/merge_requests_list.rb
@@ -1,6 +1,6 @@
-shared_examples 'merge requests list' do
- context 'when unauthenticated' do
- it 'returns merge requests for public projects' do
+shared_examples "merge requests list" do
+ context "when unauthenticated" do
+ it "returns merge requests for public projects" do
get api(endpoint_path)
expect(response).to have_gitlab_http_status(200)
@@ -8,67 +8,67 @@ shared_examples 'merge requests list' do
end
end
- context 'when authenticated' do
- it 'avoids N+1 queries' do
- control = ActiveRecord::QueryRecorder.new do
+ context "when authenticated" do
+ it "avoids N+1 queries" do
+ control = ActiveRecord::QueryRecorder.new {
get api(endpoint_path, user)
- end
+ }
- create(:merge_request, state: 'closed', milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: 'Test', created_at: base_time)
+ create(:merge_request, state: "closed", milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Test", created_at: base_time)
- merge_request = create(:merge_request, milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: 'Test', created_at: base_time)
+ merge_request = create(:merge_request, milestone: milestone1, author: user, assignee: user, source_project: project, target_project: project, title: "Test", created_at: base_time)
merge_request.metrics.update!(merged_by: user,
latest_closed_by: user,
latest_closed_at: 1.hour.ago,
merged_at: 2.hours.ago)
- expect do
+ expect {
get api(endpoint_path, user)
- end.not_to exceed_query_limit(control)
+ }.not_to exceed_query_limit(control)
end
- it 'returns an array of all merge_requests' do
+ it "returns an array of all merge_requests" do
get api(endpoint_path, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- expect(json_response.last['title']).to eq(merge_request.title)
- expect(json_response.last).to have_key('web_url')
- expect(json_response.last['sha']).to eq(merge_request.diff_head_sha)
- expect(json_response.last['merge_commit_sha']).to be_nil
- expect(json_response.last['merge_commit_sha']).to eq(merge_request.merge_commit_sha)
- expect(json_response.last['downvotes']).to eq(1)
- expect(json_response.last['upvotes']).to eq(1)
- expect(json_response.last['labels']).to eq([label2.title, label.title])
- expect(json_response.first['title']).to eq(merge_request_merged.title)
- expect(json_response.first['sha']).to eq(merge_request_merged.diff_head_sha)
- expect(json_response.first['merge_commit_sha']).not_to be_nil
- expect(json_response.first['merge_commit_sha']).to eq(merge_request_merged.merge_commit_sha)
+ expect(json_response.last["title"]).to eq(merge_request.title)
+ expect(json_response.last).to have_key("web_url")
+ expect(json_response.last["sha"]).to eq(merge_request.diff_head_sha)
+ expect(json_response.last["merge_commit_sha"]).to be_nil
+ expect(json_response.last["merge_commit_sha"]).to eq(merge_request.merge_commit_sha)
+ expect(json_response.last["downvotes"]).to eq(1)
+ expect(json_response.last["upvotes"]).to eq(1)
+ expect(json_response.last["labels"]).to eq([label2.title, label.title])
+ expect(json_response.first["title"]).to eq(merge_request_merged.title)
+ expect(json_response.first["sha"]).to eq(merge_request_merged.diff_head_sha)
+ expect(json_response.first["merge_commit_sha"]).not_to be_nil
+ expect(json_response.first["merge_commit_sha"]).to eq(merge_request_merged.merge_commit_sha)
end
- it 'returns an array of all merge_requests using simple mode' do
- path = endpoint_path + '?view=simple'
+ it "returns an array of all merge_requests using simple mode" do
+ path = endpoint_path + "?view=simple"
get api(path, user)
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
- expect(json_response.last.keys).to match_array(%w(id iid title web_url created_at description project_id state updated_at))
+ expect(json_response.last.keys).to match_array(%w[id iid title web_url created_at description project_id state updated_at])
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- expect(json_response.last['iid']).to eq(merge_request.iid)
- expect(json_response.last['title']).to eq(merge_request.title)
- expect(json_response.last).to have_key('web_url')
- expect(json_response.first['iid']).to eq(merge_request_merged.iid)
- expect(json_response.first['title']).to eq(merge_request_merged.title)
- expect(json_response.first).to have_key('web_url')
+ expect(json_response.last["iid"]).to eq(merge_request.iid)
+ expect(json_response.last["title"]).to eq(merge_request.title)
+ expect(json_response.last).to have_key("web_url")
+ expect(json_response.first["iid"]).to eq(merge_request_merged.iid)
+ expect(json_response.first["title"]).to eq(merge_request_merged.title)
+ expect(json_response.first).to have_key("web_url")
end
- it 'returns an array of all merge_requests' do
- path = endpoint_path + '?state'
+ it "returns an array of all merge_requests" do
+ path = endpoint_path + "?state"
get api(path, user)
@@ -76,11 +76,11 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- expect(json_response.last['title']).to eq(merge_request.title)
+ expect(json_response.last["title"]).to eq(merge_request.title)
end
- it 'returns an array of open merge_requests' do
- path = endpoint_path + '?state=opened'
+ it "returns an array of open merge_requests" do
+ path = endpoint_path + "?state=opened"
get api(path, user)
@@ -88,11 +88,11 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.last['title']).to eq(merge_request.title)
+ expect(json_response.last["title"]).to eq(merge_request.title)
end
- it 'returns an array of closed merge_requests' do
- path = endpoint_path + '?state=closed'
+ it "returns an array of closed merge_requests" do
+ path = endpoint_path + "?state=closed"
get api(path, user)
@@ -100,11 +100,11 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['title']).to eq(merge_request_closed.title)
+ expect(json_response.first["title"]).to eq(merge_request_closed.title)
end
- it 'returns an array of merged merge_requests' do
- path = endpoint_path + '?state=merged'
+ it "returns an array of merged merge_requests" do
+ path = endpoint_path + "?state=merged"
get api(path, user)
@@ -112,50 +112,50 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['title']).to eq(merge_request_merged.title)
+ expect(json_response.first["title"]).to eq(merge_request_merged.title)
end
- it 'matches V4 response schema' do
+ it "matches V4 response schema" do
get api(endpoint_path, user)
expect(response).to have_gitlab_http_status(200)
- expect(response).to match_response_schema('public_api/v4/merge_requests')
+ expect(response).to match_response_schema("public_api/v4/merge_requests")
end
- it 'returns an empty array if no issue matches milestone' do
- get api(endpoint_path, user), params: { milestone: '1.0.0' }
+ it "returns an empty array if no issue matches milestone" do
+ get api(endpoint_path, user), params: {milestone: "1.0.0"}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'returns an empty array if milestone does not exist' do
- get api(endpoint_path, user), params: { milestone: 'foo' }
+ it "returns an empty array if milestone does not exist" do
+ get api(endpoint_path, user), params: {milestone: "foo"}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(0)
end
- it 'returns an array of merge requests in given milestone' do
- get api(endpoint_path, user), params: { milestone: '0.9' }
+ it "returns an array of merge requests in given milestone" do
+ get api(endpoint_path, user), params: {milestone: "0.9"}
- closed_issues = json_response.select { |mr| mr['id'] == merge_request_closed.id }
+ closed_issues = json_response.select { |mr| mr["id"] == merge_request_closed.id }
expect(closed_issues.length).to eq(1)
- expect(closed_issues.first['title']).to eq merge_request_closed.title
+ expect(closed_issues.first["title"]).to eq merge_request_closed.title
end
- it 'returns an array of merge requests matching state in milestone' do
- get api(endpoint_path, user), params: { milestone: '0.9', state: 'closed' }
+ it "returns an array of merge requests matching state in milestone" do
+ get api(endpoint_path, user), params: {milestone: "0.9", state: "closed"}
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(merge_request_closed.id)
+ expect(json_response.first["id"]).to eq(merge_request_closed.id)
end
- it 'returns an array of labeled merge requests' do
+ it "returns an array of labeled merge requests" do
path = endpoint_path + "?labels=#{label.title}"
get api(path, user)
@@ -163,10 +163,10 @@ shared_examples 'merge requests list' do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['labels']).to eq([label2.title, label.title])
+ expect(json_response.first["labels"]).to eq([label2.title, label.title])
end
- it 'returns an array of labeled merge requests where all labels match' do
+ it "returns an array of labeled merge requests where all labels match" do
path = endpoint_path + "?labels=#{label.title},foo,bar"
get api(path, user)
@@ -176,8 +176,8 @@ shared_examples 'merge requests list' do
expect(json_response.length).to eq(0)
end
- it 'returns an empty array if no merge request matches labels' do
- path = endpoint_path + '?labels=foo,bar'
+ it "returns an empty array if no merge request matches labels" do
+ path = endpoint_path + "?labels=foo,bar"
get api(path, user)
@@ -186,30 +186,30 @@ shared_examples 'merge requests list' do
expect(json_response.length).to eq(0)
end
- it 'returns an array of merge requests with any label when filtering by any label' do
- get api(endpoint_path, user), params: { labels: IssuesFinder::FILTER_ANY }
+ it "returns an array of merge requests with any label when filtering by any label" do
+ get api(endpoint_path, user), params: {labels: IssuesFinder::FILTER_ANY}
expect_paginated_array_response
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(merge_request.id)
+ expect(json_response.first["id"]).to eq(merge_request.id)
end
- it 'returns an array of merge requests without a label when filtering by no label' do
- get api(endpoint_path, user), params: { labels: IssuesFinder::FILTER_NONE }
+ it "returns an array of merge requests without a label when filtering by no label" do
+ get api(endpoint_path, user), params: {labels: IssuesFinder::FILTER_NONE}
- response_ids = json_response.map { |merge_request| merge_request['id'] }
+ response_ids = json_response.map { |merge_request| merge_request["id"] }
expect_paginated_array_response
expect(response_ids).to contain_exactly(merge_request_closed.id, merge_request_merged.id, merge_request_locked.id)
end
- it 'returns an array of labeled merge requests that are merged for a milestone' do
- bug_label = create(:label, title: 'bug', color: '#FFAABB', project: project)
+ it "returns an array of labeled merge requests that are merged for a milestone" do
+ bug_label = create(:label, title: "bug", color: "#FFAABB", project: project)
- mr1 = create(:merge_request, state: 'merged', source_project: project, target_project: project, milestone: milestone)
- mr2 = create(:merge_request, state: 'merged', source_project: project, target_project: project, milestone: milestone1)
- mr3 = create(:merge_request, state: 'closed', source_project: project, target_project: project, milestone: milestone1)
- _mr = create(:merge_request, state: 'merged', source_project: project, target_project: project, milestone: milestone1)
+ mr1 = create(:merge_request, state: "merged", source_project: project, target_project: project, milestone: milestone)
+ mr2 = create(:merge_request, state: "merged", source_project: project, target_project: project, milestone: milestone1)
+ mr3 = create(:merge_request, state: "closed", source_project: project, target_project: project, milestone: milestone1)
+ _mr = create(:merge_request, state: "merged", source_project: project, target_project: project, milestone: milestone1)
create(:label_link, label: bug_label, target: mr1)
create(:label_link, label: bug_label, target: mr2)
@@ -222,17 +222,17 @@ shared_examples 'merge requests list' do
expect(response).to have_gitlab_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
- expect(json_response.first['id']).to eq(mr2.id)
+ expect(json_response.first["id"]).to eq(mr2.id)
end
- context 'with ordering' do
+ context "with ordering" do
before do
@mr_later = mr_with_later_created_and_updated_at_time
@mr_earlier = mr_with_earlier_created_and_updated_at_time
end
- it 'returns an array of merge_requests in ascending order' do
- path = endpoint_path + '?sort=asc'
+ it "returns an array of merge_requests in ascending order" do
+ path = endpoint_path + "?sort=asc"
get api(path, user)
@@ -240,12 +240,12 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- response_dates = json_response.map { |merge_request| merge_request['created_at'] }
+ response_dates = json_response.map { |merge_request| merge_request["created_at"] }
expect(response_dates).to eq(response_dates.sort)
end
- it 'returns an array of merge_requests in descending order' do
- path = endpoint_path + '?sort=desc'
+ it "returns an array of merge_requests in descending order" do
+ path = endpoint_path + "?sort=desc"
get api(path, user)
@@ -253,44 +253,44 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- response_dates = json_response.map { |merge_request| merge_request['created_at'] }
+ response_dates = json_response.map { |merge_request| merge_request["created_at"] }
expect(response_dates).to eq(response_dates.sort.reverse)
end
- context '2 merge requests with equal created_at' do
+ context "2 merge requests with equal created_at" do
let!(:closed_mr2) do
create :merge_request,
- state: 'closed',
- milestone: milestone1,
- author: user,
- assignee: user,
- source_project: project,
- target_project: project,
- title: "Test",
- created_at: @mr_earlier.created_at
+ state: "closed",
+ milestone: milestone1,
+ author: user,
+ assignee: user,
+ source_project: project,
+ target_project: project,
+ title: "Test",
+ created_at: @mr_earlier.created_at
end
- it 'page breaks first page correctly' do
+ it "page breaks first page correctly" do
get api("#{endpoint_path}?sort=desc&per_page=4", user)
- response_ids = json_response.map { |merge_request| merge_request['id'] }
+ response_ids = json_response.map { |merge_request| merge_request["id"] }
expect(response_ids).to include(closed_mr2.id)
expect(response_ids).not_to include(@mr_earlier.id)
end
- it 'page breaks second page correctly' do
+ it "page breaks second page correctly" do
get api("#{endpoint_path}?sort=desc&per_page=4&page=2", user)
- response_ids = json_response.map { |merge_request| merge_request['id'] }
+ response_ids = json_response.map { |merge_request| merge_request["id"] }
expect(response_ids).not_to include(closed_mr2.id)
expect(response_ids).to include(@mr_earlier.id)
end
end
- it 'returns an array of merge_requests ordered by updated_at' do
- path = endpoint_path + '?order_by=updated_at'
+ it "returns an array of merge_requests ordered by updated_at" do
+ path = endpoint_path + "?order_by=updated_at"
get api(path, user)
@@ -298,12 +298,12 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- response_dates = json_response.map { |merge_request| merge_request['updated_at'] }
+ response_dates = json_response.map { |merge_request| merge_request["updated_at"] }
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it 'returns an array of merge_requests ordered by created_at' do
- path = endpoint_path + '?order_by=created_at&sort=asc'
+ it "returns an array of merge_requests ordered by created_at" do
+ path = endpoint_path + "?order_by=created_at&sort=asc"
get api(path, user)
@@ -311,22 +311,22 @@ shared_examples 'merge requests list' do
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.length).to eq(4)
- response_dates = json_response.map { |merge_request| merge_request['created_at'] }
+ response_dates = json_response.map { |merge_request| merge_request["created_at"] }
expect(response_dates).to eq(response_dates.sort)
end
end
- context 'source_branch param' do
- it 'returns merge requests with the given source branch' do
- get api(endpoint_path, user), params: { source_branch: merge_request_closed.source_branch, state: 'all' }
+ context "source_branch param" do
+ it "returns merge requests with the given source branch" do
+ get api(endpoint_path, user), params: {source_branch: merge_request_closed.source_branch, state: "all"}
expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked)
end
end
- context 'target_branch param' do
- it 'returns merge requests with the given target branch' do
- get api(endpoint_path, user), params: { target_branch: merge_request_closed.target_branch, state: 'all' }
+ context "target_branch param" do
+ it "returns merge requests with the given target branch" do
+ get api(endpoint_path, user), params: {target_branch: merge_request_closed.target_branch, state: "all"}
expect_response_contain_exactly(merge_request_closed, merge_request_merged, merge_request_locked)
end
diff --git a/spec/support/shared_examples/requests/api/notes.rb b/spec/support/shared_examples/requests/api/notes.rb
index 57eefd5ef01..f2a45299862 100644
--- a/spec/support/shared_examples/requests/api/notes.rb
+++ b/spec/support/shared_examples/requests/api/notes.rb
@@ -1,47 +1,47 @@
-shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
+shared_examples "noteable API" do |parent_type, noteable_type, id_name|
describe "GET /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes" do
- context 'sorting' do
+ context "sorting" do
before do
- params = { noteable: noteable, author: user }
+ params = {noteable: noteable, author: user}
params[:project] = parent if parent.is_a?(Project)
create_list(:note, 3, params)
end
- context 'without sort params' do
- it 'sorts by created_at in descending order by default' do
+ context "without sort params" do
+ it "sorts by created_at in descending order by default" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user)
- response_dates = json_response.map { |note| note['created_at'] }
+ response_dates = json_response.map { |note| note["created_at"] }
expect(json_response.length).to eq(4)
expect(response_dates).to eq(response_dates.sort.reverse)
end
- context '2 notes with equal created_at' do
+ context "2 notes with equal created_at" do
before do
@first_note = Note.first
- params = { noteable: noteable, author: user }
+ params = {noteable: noteable, author: user}
params[:project] = parent if parent.is_a?(Project)
params[:created_at] = @first_note.created_at
@note2 = create(:note, params)
end
- it 'page breaks first page correctly' do
+ it "page breaks first page correctly" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes?per_page=4", user)
- response_ids = json_response.map { |note| note['id'] }
+ response_ids = json_response.map { |note| note["id"] }
expect(response_ids).to include(@note2.id)
expect(response_ids).not_to include(@first_note.id)
end
- it 'page breaks second page correctly' do
+ it "page breaks second page correctly" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes?per_page=4&page=2", user)
- response_ids = json_response.map { |note| note['id'] }
+ response_ids = json_response.map { |note| note["id"] }
expect(response_ids).not_to include(@note2.id)
expect(response_ids).to include(@first_note.id)
@@ -49,28 +49,28 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
end
- it 'sorts by ascending order when requested' do
+ it "sorts by ascending order when requested" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes?sort=asc", user)
- response_dates = json_response.map { |note| note['created_at'] }
+ response_dates = json_response.map { |note| note["created_at"] }
expect(json_response.length).to eq(4)
expect(response_dates).to eq(response_dates.sort)
end
- it 'sorts by updated_at in descending order when requested' do
+ it "sorts by updated_at in descending order when requested" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes?order_by=updated_at", user)
- response_dates = json_response.map { |note| note['updated_at'] }
+ response_dates = json_response.map { |note| note["updated_at"] }
expect(json_response.length).to eq(4)
expect(response_dates).to eq(response_dates.sort.reverse)
end
- it 'sorts by updated_at in ascending order when requested' do
+ it "sorts by updated_at in ascending order when requested" do
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes?order_by=updated_at&sort=asc", user)
- response_dates = json_response.map { |note| note['updated_at'] }
+ response_dates = json_response.map { |note| note["updated_at"] }
expect(json_response.length).to eq(4)
expect(response_dates).to eq(response_dates.sort)
@@ -83,7 +83,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
expect(response).to have_gitlab_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
- expect(json_response.first['body']).to eq(note.note)
+ expect(json_response.first["body"]).to eq(note.note)
end
it "returns a 404 error when noteable id not found" do
@@ -106,7 +106,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
get api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{note.id}", user)
expect(response).to have_gitlab_http_status(200)
- expect(json_response['body']).to eq(note.note)
+ expect(json_response["body"]).to eq(note.note)
end
it "returns a 404 error if note not found" do
@@ -118,11 +118,11 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
describe "POST /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes" do
it "creates a new note" do
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: 'hi!' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(user.username)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(user.username)
end
it "returns a 400 bad request error if body not given" do
@@ -132,7 +132,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
it "returns a 401 unauthorized error if user not authenticated" do
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes"), params: { body: 'hi!' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes"), params: {body: "hi!"}
expect(response).to have_gitlab_http_status(401)
end
@@ -140,41 +140,41 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
it "creates an activity event when a note is created" do
expect(Event).to receive(:create!)
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: 'hi!' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: {body: "hi!"}
end
- context 'setting created_at' do
+ context "setting created_at" do
let(:creation_time) { 2.weeks.ago }
- let(:params) { { body: 'hi!', created_at: creation_time } }
+ let(:params) { {body: "hi!", created_at: creation_time} }
- context 'by an admin' do
- it 'sets the creation time on the new note' do
+ context "by an admin" do
+ it "sets the creation time on the new note" do
admin = create(:admin)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", admin), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(admin.username)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
- expect(Time.parse(json_response['updated_at'])).to be_like_time(creation_time)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(admin.username)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["updated_at"])).to be_like_time(creation_time)
end
end
- if parent_type == 'projects'
- context 'by a project owner' do
- it 'sets the creation time on the new note' do
+ if parent_type == "projects"
+ context "by a project owner" do
+ it "sets the creation time on the new note" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(user.username)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
- expect(Time.parse(json_response['updated_at'])).to be_like_time(creation_time)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(user.username)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["updated_at"])).to be_like_time(creation_time)
end
end
- context 'by a group owner' do
- it 'sets the creation time on the new note' do
+ context "by a group owner" do
+ it "sets the creation time on the new note" do
user2 = create(:user)
group = create(:group)
group.add_owner(user2)
@@ -184,68 +184,68 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(user2.username)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
- expect(Time.parse(json_response['updated_at'])).to be_like_time(creation_time)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(user2.username)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["updated_at"])).to be_like_time(creation_time)
end
end
- elsif parent_type == 'groups'
- context 'by a group owner' do
- it 'sets the creation time on the new note' do
+ elsif parent_type == "groups"
+ context "by a group owner" do
+ it "sets the creation time on the new note" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(user.username)
- expect(Time.parse(json_response['created_at'])).to be_like_time(creation_time)
- expect(Time.parse(json_response['updated_at'])).to be_like_time(creation_time)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(user.username)
+ expect(Time.parse(json_response["created_at"])).to be_like_time(creation_time)
+ expect(Time.parse(json_response["updated_at"])).to be_like_time(creation_time)
end
end
end
- context 'by another user' do
- it 'ignores the given creation time' do
+ context "by another user" do
+ it "ignores the given creation time" do
user2 = create(:user)
parent.add_developer(user2)
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user2), params: params
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq('hi!')
- expect(json_response['author']['username']).to eq(user2.username)
- expect(Time.parse(json_response['created_at'])).not_to be_like_time(creation_time)
- expect(Time.parse(json_response['updated_at'])).not_to be_like_time(creation_time)
+ expect(json_response["body"]).to eq("hi!")
+ expect(json_response["author"]["username"]).to eq(user2.username)
+ expect(Time.parse(json_response["created_at"])).not_to be_like_time(creation_time)
+ expect(Time.parse(json_response["updated_at"])).not_to be_like_time(creation_time)
end
end
end
- context 'when the user is posting an award emoji on a noteable created by someone else' do
- it 'creates a new note' do
+ context "when the user is posting an award emoji on a noteable created by someone else" do
+ it "creates a new note" do
parent.add_developer(private_user)
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), params: { body: ':+1:' }
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user), params: {body: ":+1:"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq(':+1:')
+ expect(json_response["body"]).to eq(":+1:")
end
end
- context 'when the user is posting an award emoji on his/her own noteable' do
- it 'creates a new note' do
- post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: ':+1:' }
+ context "when the user is posting an award emoji on his/her own noteable" do
+ it "creates a new note" do
+ post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: {body: ":+1:"}
expect(response).to have_gitlab_http_status(201)
- expect(json_response['body']).to eq(':+1:')
+ expect(json_response["body"]).to eq(":+1:")
end
end
- context 'when user does not have access to read the noteable' do
+ context "when user does not have access to read the noteable" do
before do
parent.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'responds with 404' do
+ it "responds with 404" do
post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", private_user),
- params: { body: 'Foo' }
+ params: {body: "Foo"}
expect(response).to have_gitlab_http_status(404)
end
@@ -253,22 +253,22 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes/:note_id" do
- it 'returns modified note' do
+ it "returns modified note" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "notes/#{note.id}", user), params: { body: 'Hello!' }
+ "notes/#{note.id}", user), params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['body']).to eq('Hello!')
+ expect(json_response["body"]).to eq("Hello!")
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user),
- params: { body: 'Hello!' }
+ params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 400 bad request error if body not given' do
+ it "returns a 400 bad request error if body not given" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user)
@@ -277,7 +277,7 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
end
describe "DELETE /#{parent_type}/:id/#{noteable_type}/:noteable_id/notes/:note_id" do
- it 'deletes a note' do
+ it "deletes a note" do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"notes/#{note.id}", user)
@@ -288,13 +288,13 @@ shared_examples 'noteable API' do |parent_type, noteable_type, id_name|
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
delete api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/12345", user)
expect(response).to have_gitlab_http_status(404)
end
- it_behaves_like '412 response' do
+ it_behaves_like "412 response" do
let(:request) { api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes/#{note.id}", user) }
end
end
diff --git a/spec/support/shared_examples/requests/api/resolvable_discussions.rb b/spec/support/shared_examples/requests/api/resolvable_discussions.rb
index 7e2416b23f3..02e2bf6b7cf 100644
--- a/spec/support/shared_examples/requests/api/resolvable_discussions.rb
+++ b/spec/support/shared_examples/requests/api/resolvable_discussions.rb
@@ -1,21 +1,21 @@
-shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_name|
+shared_examples "resolvable discussions API" do |parent_type, noteable_type, id_name|
describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id" do
it "resolves discussion if resolved is true" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}", user), params: { resolved: true }
+ "discussions/#{note.discussion_id}", user), params: {resolved: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['notes'].size).to eq(1)
- expect(json_response['notes'][0]['resolved']).to eq(true)
+ expect(json_response["notes"].size).to eq(1)
+ expect(json_response["notes"][0]["resolved"]).to eq(true)
end
it "unresolves discussion if resolved is false" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}", user), params: { resolved: false }
+ "discussions/#{note.discussion_id}", user), params: {resolved: false}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['notes'].size).to eq(1)
- expect(json_response['notes'][0]['resolved']).to eq(false)
+ expect(json_response["notes"].size).to eq(1)
+ expect(json_response["notes"][0]["resolved"]).to eq(false)
end
it "returns a 400 bad request error if resolved parameter is not passed" do
@@ -27,26 +27,26 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
it "returns a 401 unauthorized error if user is not authenticated" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}"), params: { resolved: true }
+ "discussions/#{note.discussion_id}"), params: {resolved: true}
expect(response).to have_gitlab_http_status(401)
end
it "returns a 403 error if user resolves discussion of someone else" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}", private_user), params: { resolved: true }
+ "discussions/#{note.discussion_id}", private_user), params: {resolved: true}
expect(response).to have_gitlab_http_status(403)
end
- context 'when user does not have access to read the discussion' do
+ context "when user does not have access to read the discussion" do
before do
parent.update!(visibility_level: Gitlab::VisibilityLevel::PRIVATE)
end
- it 'responds with 404' do
+ it "responds with 404" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}", private_user), params: { resolved: true }
+ "discussions/#{note.discussion_id}", private_user), params: {resolved: true}
expect(response).to have_gitlab_http_status(404)
end
@@ -54,23 +54,23 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
end
describe "PUT /#{parent_type}/:id/#{noteable_type}/:noteable_id/discussions/:discussion_id/notes/:note_id" do
- it 'returns resolved note when resolved parameter is true' do
+ it "returns resolved note when resolved parameter is true" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: { resolved: true }
+ "discussions/#{note.discussion_id}/notes/#{note.id}", user), params: {resolved: true}
expect(response).to have_gitlab_http_status(200)
- expect(json_response['resolved']).to eq(true)
+ expect(json_response["resolved"]).to eq(true)
end
- it 'returns a 404 error when note id not found' do
+ it "returns a 404 error when note id not found" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/12345", user),
- params: { body: 'Hello!' }
+ params: {body: "Hello!"}
expect(response).to have_gitlab_http_status(404)
end
- it 'returns a 400 bad request error if neither body nor resolved parameter is given' do
+ it "returns a 400 bad request error if neither body nor resolved parameter is given" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
"discussions/#{note.discussion_id}/notes/#{note.id}", user)
@@ -79,7 +79,7 @@ shared_examples 'resolvable discussions API' do |parent_type, noteable_type, id_
it "returns a 403 error if user resolves note of someone else" do
put api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/"\
- "discussions/#{note.discussion_id}/notes/#{note.id}", private_user), params: { resolved: true }
+ "discussions/#{note.discussion_id}/notes/#{note.id}", private_user), params: {resolved: true}
expect(response).to have_gitlab_http_status(403)
end
diff --git a/spec/support/shared_examples/requests/api/status_shared_examples.rb b/spec/support/shared_examples/requests/api/status_shared_examples.rb
index ebfc5fed3bb..5d9f6ae2e61 100644
--- a/spec/support/shared_examples/requests/api/status_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/status_shared_examples.rb
@@ -2,7 +2,7 @@
#
# Requires an API request:
# let(:request) { get api("/projects/#{project.id}/repository/branches", user) }
-shared_examples_for '400 response' do
+shared_examples_for "400 response" do
let(:message) { nil }
before do
@@ -10,27 +10,27 @@ shared_examples_for '400 response' do
request
end
- it 'returns 400' do
+ it "returns 400" do
expect(response).to have_gitlab_http_status(400)
if message.present?
- expect(json_response['message']).to eq(message)
+ expect(json_response["message"]).to eq(message)
end
end
end
-shared_examples_for '403 response' do
+shared_examples_for "403 response" do
before do
# Fires the request
request
end
- it 'returns 403' do
+ it "returns 403" do
expect(response).to have_gitlab_http_status(403)
end
end
-shared_examples_for '404 response' do
+shared_examples_for "404 response" do
let(:message) { nil }
before do
@@ -38,36 +38,36 @@ shared_examples_for '404 response' do
request
end
- it 'returns 404' do
+ it "returns 404" do
expect(response).to have_gitlab_http_status(404)
expect(json_response).to be_an Object
if message.present?
- expect(json_response['message']).to eq(message)
+ expect(json_response["message"]).to eq(message)
end
end
end
-shared_examples_for '412 response' do
+shared_examples_for "412 response" do
let(:params) { nil }
let(:success_status) { 204 }
- context 'for a modified ressource' do
+ context "for a modified ressource" do
before do
- delete request, params: params, headers: { 'HTTP_IF_UNMODIFIED_SINCE' => '1990-01-12T00:00:48-0600' }
+ delete request, params: params, headers: {"HTTP_IF_UNMODIFIED_SINCE" => "1990-01-12T00:00:48-0600"}
end
- it 'returns 412' do
+ it "returns 412" do
expect(response).to have_gitlab_http_status(412)
end
end
- context 'for an unmodified ressource' do
+ context "for an unmodified ressource" do
before do
- delete request, params: params, headers: { 'HTTP_IF_UNMODIFIED_SINCE' => Time.now }
+ delete request, params: params, headers: {"HTTP_IF_UNMODIFIED_SINCE" => Time.now}
end
- it 'returns accepted' do
+ it "returns accepted" do
expect(response).to have_gitlab_http_status(success_status)
end
end
diff --git a/spec/support/shared_examples/requests/graphql_shared_examples.rb b/spec/support/shared_examples/requests/graphql_shared_examples.rb
index 04140cad3f0..d039fe91c7e 100644
--- a/spec/support/shared_examples/requests/graphql_shared_examples.rb
+++ b/spec/support/shared_examples/requests/graphql_shared_examples.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-shared_examples 'a working graphql query' do
+shared_examples "a working graphql query" do
include GraphqlHelpers
- it 'returns a successful response', :aggregate_failures do
+ it "returns a successful response", :aggregate_failures do
expect(response).to have_gitlab_http_status(:success)
expect(graphql_errors).to be_nil
- expect(json_response.keys).to include('data')
+ expect(json_response.keys).to include("data")
end
end
diff --git a/spec/support/shared_examples/serializers/diff_file_entity_examples.rb b/spec/support/shared_examples/serializers/diff_file_entity_examples.rb
index 96cb71be737..037ace7c5b4 100644
--- a/spec/support/shared_examples/serializers/diff_file_entity_examples.rb
+++ b/spec/support/shared_examples/serializers/diff_file_entity_examples.rb
@@ -1,20 +1,20 @@
# frozen_string_literal: true
-shared_examples 'diff file base entity' do
- it 'exposes essential attributes' do
+shared_examples "diff file base entity" do
+ it "exposes essential attributes" do
expect(subject).to include(:content_sha, :submodule, :submodule_link,
- :submodule_tree_url, :old_path_html,
- :new_path_html, :blob, :can_modify_blob,
- :file_hash, :file_path, :old_path, :new_path,
- :viewer, :diff_refs, :stored_externally,
- :external_storage, :renamed_file, :deleted_file,
- :a_mode, :b_mode, :new_file)
+ :submodule_tree_url, :old_path_html,
+ :new_path_html, :blob, :can_modify_blob,
+ :file_hash, :file_path, :old_path, :new_path,
+ :viewer, :diff_refs, :stored_externally,
+ :external_storage, :renamed_file, :deleted_file,
+ :a_mode, :b_mode, :new_file)
end
# Converted diff files from GitHub import does not contain blob file
# and content sha.
- context 'when diff file does not have a blob and content sha' do
- it 'exposes some attributes as nil' do
+ context "when diff file does not have a blob and content sha" do
+ it "exposes some attributes as nil" do
allow(diff_file).to receive(:content_sha).and_return(nil)
allow(diff_file).to receive(:blob).and_return(nil)
@@ -26,21 +26,21 @@ shared_examples 'diff file base entity' do
end
end
-shared_examples 'diff file entity' do
- it_behaves_like 'diff file base entity'
+shared_examples "diff file entity" do
+ it_behaves_like "diff file base entity"
- it 'exposes correct attributes' do
+ it "exposes correct attributes" do
expect(subject).to include(:added_lines, :removed_lines,
- :context_lines_path, :highlighted_diff_lines,
- :parallel_diff_lines)
+ :context_lines_path, :highlighted_diff_lines,
+ :parallel_diff_lines)
end
- it 'includes viewer' do
+ it "includes viewer" do
expect(subject[:viewer].with_indifferent_access)
- .to match_schema('entities/diff_viewer')
+ .to match_schema("entities/diff_viewer")
end
end
-shared_examples 'diff file discussion entity' do
- it_behaves_like 'diff file base entity'
+shared_examples "diff file discussion entity" do
+ it_behaves_like "diff file base entity"
end
diff --git a/spec/support/shared_examples/serializers/note_entity_examples.rb b/spec/support/shared_examples/serializers/note_entity_examples.rb
index ec208aba2a9..5f7fc5f6281 100644
--- a/spec/support/shared_examples/serializers/note_entity_examples.rb
+++ b/spec/support/shared_examples/serializers/note_entity_examples.rb
@@ -1,41 +1,41 @@
-shared_examples 'note entity' do
+shared_examples "note entity" do
subject { entity.as_json }
- context 'basic note' do
- it 'exposes correct elements' do
+ context "basic note" do
+ it "exposes correct elements" do
expect(subject).to include(:type, :author, :note, :note_html, :current_user, :discussion_id,
:emoji_awardable, :award_emoji, :report_abuse_path, :attachment, :noteable_note_url, :resolvable)
end
- it 'does not expose elements for specific notes cases' do
+ it "does not expose elements for specific notes cases" do
expect(subject).not_to include(:last_edited_by, :last_edited_at, :system_note_icon_name)
end
- it 'exposes author correctly' do
+ it "exposes author correctly" do
expect(subject[:author]).to include(:id, :name, :username, :state, :avatar_url, :path)
end
- it 'does not expose web_url for author' do
+ it "does not expose web_url for author" do
expect(subject[:author]).not_to include(:web_url)
end
end
- context 'when note was edited' do
+ context "when note was edited" do
before do
note.update(updated_at: 1.minute.from_now, updated_by: user)
end
- it 'exposes last_edited_at and last_edited_by elements' do
+ it "exposes last_edited_at and last_edited_by elements" do
expect(subject).to include(:last_edited_at, :last_edited_by)
end
end
- context 'when note is a system note' do
+ context "when note is a system note" do
before do
note.update(system: true)
end
- it 'exposes system_note_icon_name element' do
+ it "exposes system_note_icon_name element" do
expect(subject).to include(:system_note_icon_name)
end
end
diff --git a/spec/support/shared_examples/services/boards/boards_create_service.rb b/spec/support/shared_examples/services/boards/boards_create_service.rb
index 5bdc04f660f..343a8c86656 100644
--- a/spec/support/shared_examples/services/boards/boards_create_service.rb
+++ b/spec/support/shared_examples/services/boards/boards_create_service.rb
@@ -1,10 +1,10 @@
-shared_examples 'boards create service' do
- context 'when parent does not have a board' do
- it 'creates a new board' do
+shared_examples "boards create service" do
+ context "when parent does not have a board" do
+ it "creates a new board" do
expect { service.execute }.to change(Board, :count).by(1)
end
- it 'creates the default lists' do
+ it "creates the default lists" do
board = service.execute
expect(board.lists.size).to eq 2
@@ -13,12 +13,12 @@ shared_examples 'boards create service' do
end
end
- context 'when parent has a board' do
+ context "when parent has a board" do
before do
create(:board, parent: parent)
end
- it 'does not create a new board' do
+ it "does not create a new board" do
expect(service).to receive(:can_create_board?) { false }
expect { service.execute }.not_to change(parent.boards, :count)
diff --git a/spec/support/shared_examples/services/boards/boards_list_service.rb b/spec/support/shared_examples/services/boards/boards_list_service.rb
index e0d5a7c61f2..d2641361d66 100644
--- a/spec/support/shared_examples/services/boards/boards_list_service.rb
+++ b/spec/support/shared_examples/services/boards/boards_list_service.rb
@@ -1,27 +1,27 @@
-shared_examples 'boards list service' do
- context 'when parent does not have a board' do
- it 'creates a new parent board' do
+shared_examples "boards list service" do
+ context "when parent does not have a board" do
+ it "creates a new parent board" do
expect { service.execute }.to change(parent.boards, :count).by(1)
end
- it 'delegates the parent board creation to Boards::CreateService' do
+ it "delegates the parent board creation to Boards::CreateService" do
expect_any_instance_of(Boards::CreateService).to receive(:execute).once
service.execute
end
end
- context 'when parent has a board' do
+ context "when parent has a board" do
before do
create(:board, parent: parent)
end
- it 'does not create a new board' do
+ it "does not create a new board" do
expect { service.execute }.not_to change(parent.boards, :count)
end
end
- it 'returns parent boards' do
+ it "returns parent boards" do
board = create(:board, parent: parent)
expect(service.execute).to eq [board]
diff --git a/spec/support/shared_examples/services/boards/issues_list_service.rb b/spec/support/shared_examples/services/boards/issues_list_service.rb
index 8b879cef084..58b63aa4765 100644
--- a/spec/support/shared_examples/services/boards/issues_list_service.rb
+++ b/spec/support/shared_examples/services/boards/issues_list_service.rb
@@ -1,15 +1,15 @@
-shared_examples 'issues list service' do
- it 'delegates search to IssuesFinder' do
- params = { board_id: board.id, id: list1.id }
+shared_examples "issues list service" do
+ it "delegates search to IssuesFinder" do
+ params = {board_id: board.id, id: list1.id}
expect_any_instance_of(IssuesFinder).to receive(:execute).once.and_call_original
described_class.new(parent, user, params).execute
end
- context '#metadata' do
- it 'returns issues count for list' do
- params = { board_id: board.id, id: list1.id }
+ context "#metadata" do
+ it "returns issues count for list" do
+ params = {board_id: board.id, id: list1.id}
metadata = described_class.new(parent, user, params).metadata
@@ -17,33 +17,33 @@ shared_examples 'issues list service' do
end
end
- context 'issues are ordered by priority' do
- it 'returns opened issues when list_id is missing' do
- params = { board_id: board.id }
+ context "issues are ordered by priority" do
+ it "returns opened issues when list_id is missing" do
+ params = {board_id: board.id}
issues = described_class.new(parent, user, params).execute
expect(issues).to eq [opened_issue2, reopened_issue1, opened_issue1]
end
- it 'returns opened issues when listing issues from Backlog' do
- params = { board_id: board.id, id: backlog.id }
+ it "returns opened issues when listing issues from Backlog" do
+ params = {board_id: board.id, id: backlog.id}
issues = described_class.new(parent, user, params).execute
expect(issues).to eq [opened_issue2, reopened_issue1, opened_issue1]
end
- it 'returns closed issues when listing issues from Closed' do
- params = { board_id: board.id, id: closed.id }
+ it "returns closed issues when listing issues from Closed" do
+ params = {board_id: board.id, id: closed.id}
issues = described_class.new(parent, user, params).execute
expect(issues).to eq [closed_issue4, closed_issue2, closed_issue5, closed_issue3, closed_issue1]
end
- it 'returns opened issues that have label list applied when listing issues from a label list' do
- params = { board_id: board.id, id: list1.id }
+ it "returns opened issues that have label list applied when listing issues from a label list" do
+ params = {board_id: board.id, id: list1.id}
issues = described_class.new(parent, user, params).execute
@@ -51,8 +51,8 @@ shared_examples 'issues list service' do
end
end
- context 'with list that does not belong to the board' do
- it 'raises an error' do
+ context "with list that does not belong to the board" do
+ it "raises an error" do
list = create(:list)
service = described_class.new(parent, user, board_id: board.id, id: list.id)
@@ -60,8 +60,8 @@ shared_examples 'issues list service' do
end
end
- context 'with invalid list id' do
- it 'raises an error' do
+ context "with invalid list id" do
+ it "raises an error" do
service = described_class.new(parent, user, board_id: board.id, id: nil)
expect { service.execute }.to raise_error(ActiveRecord::RecordNotFound)
diff --git a/spec/support/shared_examples/services/boards/issues_move_service.rb b/spec/support/shared_examples/services/boards/issues_move_service.rb
index 9dbd1d8e867..07fc2dd01af 100644
--- a/spec/support/shared_examples/services/boards/issues_move_service.rb
+++ b/spec/support/shared_examples/services/boards/issues_move_service.rb
@@ -1,9 +1,9 @@
-shared_examples 'issues move service' do |group|
- context 'when moving an issue between lists' do
+shared_examples "issues move service" do |group|
+ context "when moving an issue between lists" do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) }
- let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id } }
+ let(:params) { {board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id} }
- it 'delegates the label changes to Issues::UpdateService' do
+ it "delegates the label changes to Issues::UpdateService" do
service = double(:service)
expect(Issues::UpdateService).to receive(:new).and_return(service)
expect(service).to receive(:execute).with(issue).once
@@ -11,26 +11,26 @@ shared_examples 'issues move service' do |group|
described_class.new(parent, user, params).execute(issue)
end
- it 'removes the label from the list it came from and adds the label of the list it goes to' do
+ it "removes the label from the list it came from and adds the label of the list it goes to" do
described_class.new(parent, user, params).execute(issue)
expect(issue.reload.labels).to contain_exactly(bug, testing)
end
end
- context 'when moving to closed' do
+ context "when moving to closed" do
let!(:list3) { create(:list, board: board2, label: regression, position: 1) }
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing, regression]) }
- let(:params) { { board_id: board1.id, from_list_id: list2.id, to_list_id: closed.id } }
+ let(:params) { {board_id: board1.id, from_list_id: list2.id, to_list_id: closed.id} }
- it 'delegates the close proceedings to Issues::CloseService' do
+ it "delegates the close proceedings to Issues::CloseService" do
expect_any_instance_of(Issues::CloseService).to receive(:execute).with(issue).once
described_class.new(parent, user, params).execute(issue)
end
- it 'removes all list-labels from boards and close the issue' do
+ it "removes all list-labels from boards and close the issue" do
described_class.new(parent, user, params).execute(issue)
issue.reload
@@ -39,14 +39,14 @@ shared_examples 'issues move service' do |group|
end
end
- context 'when moving to backlog' do
+ context "when moving to backlog" do
let(:milestone) { create(:milestone, project: project) }
let!(:backlog) { create(:backlog_list, board: board1) }
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing, regression], milestone: milestone) }
- let(:params) { { board_id: board1.id, from_list_id: list2.id, to_list_id: backlog.id } }
+ let(:params) { {board_id: board1.id, from_list_id: list2.id, to_list_id: backlog.id} }
- it 'keeps labels and milestone' do
+ it "keeps labels and milestone" do
described_class.new(parent, user, params).execute(issue)
issue.reload
@@ -55,17 +55,17 @@ shared_examples 'issues move service' do |group|
end
end
- context 'when moving from closed' do
+ context "when moving from closed" do
let(:issue) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
- let(:params) { { board_id: board1.id, from_list_id: closed.id, to_list_id: list2.id } }
+ let(:params) { {board_id: board1.id, from_list_id: closed.id, to_list_id: list2.id} }
- it 'delegates the re-open proceedings to Issues::ReopenService' do
+ it "delegates the re-open proceedings to Issues::ReopenService" do
expect_any_instance_of(Issues::ReopenService).to receive(:execute).with(issue).once
described_class.new(parent, user, params).execute(issue)
end
- it 'adds the label of the list it goes to and reopen the issue' do
+ it "adds the label of the list it goes to and reopen the issue" do
described_class.new(parent, user, params).execute(issue)
issue.reload
@@ -74,23 +74,23 @@ shared_examples 'issues move service' do |group|
end
end
- context 'when moving to same list' do
+ context "when moving to same list" do
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) }
let(:issue1) { create(:labeled_issue, project: project, labels: [bug, development]) }
let(:issue2) { create(:labeled_issue, project: project, labels: [bug, development]) }
- let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list1.id } }
+ let(:params) { {board_id: board1.id, from_list_id: list1.id, to_list_id: list1.id} }
- it 'returns false' do
+ it "returns false" do
expect(described_class.new(parent, user, params).execute(issue)).to eq false
end
- it 'keeps issues labels' do
+ it "keeps issues labels" do
described_class.new(parent, user, params).execute(issue)
expect(issue.reload.labels).to contain_exactly(bug, development)
end
- it 'sorts issues' do
+ it "sorts issues" do
[issue, issue1, issue2].each do |issue|
issue.move_to_end && issue.save!
end
@@ -103,11 +103,11 @@ shared_examples 'issues move service' do |group|
end
if group
- context 'when on a group board' do
- it 'sends the board_group_id parameter' do
+ context "when on a group board" do
+ it "sends the board_group_id parameter" do
params.merge!(move_after_id: issue1.id, move_before_id: issue2.id)
- match_params = { move_between_ids: [issue1.id, issue2.id], board_group_id: parent.id }
+ match_params = {move_between_ids: [issue1.id, issue2.id], board_group_id: parent.id}
expect(Issues::UpdateService).to receive(:new).with(issue.project, user, match_params).and_return(double(execute: build(:issue)))
described_class.new(parent, user, params).execute(issue)
diff --git a/spec/support/shared_examples/services/boards/lists_destroy_service.rb b/spec/support/shared_examples/services/boards/lists_destroy_service.rb
index 62b6ffe1836..e9734c46e6e 100644
--- a/spec/support/shared_examples/services/boards/lists_destroy_service.rb
+++ b/spec/support/shared_examples/services/boards/lists_destroy_service.rb
@@ -1,13 +1,13 @@
-shared_examples 'lists destroy service' do
- context 'when list type is label' do
- it 'removes list from board' do
+shared_examples "lists destroy service" do
+ context "when list type is label" do
+ it "removes list from board" do
list = create(:list, board: board)
service = described_class.new(parent, user)
expect { service.execute(list) }.to change(board.lists, :count).by(-1)
end
- it 'decrements position of higher lists' do
+ it "decrements position of higher lists" do
development = create(:list, board: board, position: 0)
review = create(:list, board: board, position: 1)
staging = create(:list, board: board, position: 2)
@@ -21,7 +21,7 @@ shared_examples 'lists destroy service' do
end
end
- it 'does not remove list from board when list type is closed' do
+ it "does not remove list from board when list type is closed" do
list = board.closed_list
service = described_class.new(parent, user)
diff --git a/spec/support/shared_examples/services/boards/lists_list_service.rb b/spec/support/shared_examples/services/boards/lists_list_service.rb
index 0a8220111ab..b7b89b3aeea 100644
--- a/spec/support/shared_examples/services/boards/lists_list_service.rb
+++ b/spec/support/shared_examples/services/boards/lists_list_service.rb
@@ -1,8 +1,8 @@
-shared_examples 'lists list service' do
- context 'when the board has a backlog list' do
+shared_examples "lists list service" do
+ context "when the board has a backlog list" do
let!(:backlog_list) { create(:backlog_list, board: board) }
- it 'does not create a backlog list' do
+ it "does not create a backlog list" do
expect { service.execute(board) }.not_to change(board.lists, :count)
end
@@ -11,8 +11,8 @@ shared_examples 'lists list service' do
end
end
- context 'when the board does not have a backlog list' do
- it 'creates a backlog list' do
+ context "when the board does not have a backlog list" do
+ it "creates a backlog list" do
expect { service.execute(board) }.to change(board.lists, :count).by(1)
end
diff --git a/spec/support/shared_examples/services/boards/lists_move_service.rb b/spec/support/shared_examples/services/boards/lists_move_service.rb
index 2cdb968a45d..ea1cfec98cb 100644
--- a/spec/support/shared_examples/services/boards/lists_move_service.rb
+++ b/spec/support/shared_examples/services/boards/lists_move_service.rb
@@ -1,12 +1,12 @@
-shared_examples 'lists move service' do
+shared_examples "lists move service" do
let!(:planning) { create(:list, board: board, position: 0) }
let!(:development) { create(:list, board: board, position: 1) }
let!(:review) { create(:list, board: board, position: 2) }
let!(:staging) { create(:list, board: board, position: 3) }
let!(:closed) { create(:closed_list, board: board) }
- context 'when list type is set to label' do
- it 'keeps position of lists when new position is nil' do
+ context "when list type is set to label" do
+ it "keeps position of lists when new position is nil" do
service = described_class.new(parent, user, position: nil)
service.execute(planning)
@@ -14,7 +14,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [0, 1, 2, 3]
end
- it 'keeps position of lists when new position is equal to old position' do
+ it "keeps position of lists when new position is equal to old position" do
service = described_class.new(parent, user, position: planning.position)
service.execute(planning)
@@ -22,7 +22,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [0, 1, 2, 3]
end
- it 'keeps position of lists when new position is negative' do
+ it "keeps position of lists when new position is negative" do
service = described_class.new(parent, user, position: -1)
service.execute(planning)
@@ -30,7 +30,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [0, 1, 2, 3]
end
- it 'keeps position of lists when new position is equal to number of labels lists' do
+ it "keeps position of lists when new position is equal to number of labels lists" do
service = described_class.new(parent, user, position: board.lists.label.size)
service.execute(planning)
@@ -38,7 +38,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [0, 1, 2, 3]
end
- it 'keeps position of lists when new position is greater than number of labels lists' do
+ it "keeps position of lists when new position is greater than number of labels lists" do
service = described_class.new(parent, user, position: board.lists.label.size + 1)
service.execute(planning)
@@ -46,7 +46,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [0, 1, 2, 3]
end
- it 'increments position of intermediate lists when new position is equal to first position' do
+ it "increments position of intermediate lists when new position is equal to first position" do
service = described_class.new(parent, user, position: 0)
service.execute(staging)
@@ -54,7 +54,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [1, 2, 3, 0]
end
- it 'decrements position of intermediate lists when new position is equal to last position' do
+ it "decrements position of intermediate lists when new position is equal to last position" do
service = described_class.new(parent, user, position: board.lists.label.last.position)
service.execute(planning)
@@ -62,7 +62,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [3, 0, 1, 2]
end
- it 'decrements position of intermediate lists when new position is greater than old position' do
+ it "decrements position of intermediate lists when new position is greater than old position" do
service = described_class.new(parent, user, position: 2)
service.execute(planning)
@@ -70,7 +70,7 @@ shared_examples 'lists move service' do
expect(current_list_positions).to eq [2, 0, 1, 3]
end
- it 'increments position of intermediate lists when new position is lower than old position' do
+ it "increments position of intermediate lists when new position is lower than old position" do
service = described_class.new(parent, user, position: 1)
service.execute(staging)
@@ -79,7 +79,7 @@ shared_examples 'lists move service' do
end
end
- it 'keeps position of lists when list type is closed' do
+ it "keeps position of lists when list type is closed" do
service = described_class.new(parent, user, position: 2)
service.execute(closed)
diff --git a/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb b/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
index 14638a574a5..4447bc92f01 100644
--- a/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/check_ingress_ip_address_service_shared_examples.rb
@@ -1,27 +1,27 @@
-shared_examples 'check ingress ip executions' do |app_name|
- describe '#execute' do
+shared_examples "check ingress ip executions" do |app_name|
+ describe "#execute" do
let(:application) { create(app_name, :installed) }
let(:service) { described_class.new(application) }
let(:kubeclient) { double(::Kubeclient::Client, get_service: kube_service) }
- context 'when the ingress ip address is available' do
- it 'updates the external_ip for the app' do
+ context "when the ingress ip address is available" do
+ it "updates the external_ip for the app" do
subject
- expect(application.external_ip).to eq('111.222.111.222')
+ expect(application.external_ip).to eq("111.222.111.222")
end
end
- context 'when the ingress ip address is not available' do
+ context "when the ingress ip address is not available" do
let(:ingress) { nil }
- it 'does not error' do
+ it "does not error" do
subject
end
end
- context 'when the exclusive lease cannot be obtained' do
- it 'does not call kubeclient' do
+ context "when the exclusive lease cannot be obtained" do
+ it "does not call kubeclient" do
stub_exclusive_lease_taken(lease_key, timeout: 15.seconds.to_i)
subject
diff --git a/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb b/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb
index b8db35a6ef9..c154fc2d3de 100644
--- a/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb
+++ b/spec/support/shared_examples/services/gitlab_projects_import_service_shared_examples.rb
@@ -1,8 +1,8 @@
-shared_examples 'gitlab projects import validations' do
- context 'with an invalid path' do
- let(:path) { '/invalid-path/' }
+shared_examples "gitlab projects import validations" do
+ context "with an invalid path" do
+ let(:path) { "/invalid-path/" }
- it 'returns an invalid project' do
+ it "returns an invalid project" do
project = subject.execute
expect(project).not_to be_persisted
@@ -10,8 +10,8 @@ shared_examples 'gitlab projects import validations' do
end
end
- context 'with a valid path' do
- it 'creates a project' do
+ context "with a valid path" do
+ it "creates a project" do
project = subject.execute
expect(project).to be_persisted
@@ -19,31 +19,31 @@ shared_examples 'gitlab projects import validations' do
end
end
- context 'override params' do
- it 'stores them as import data when passed' do
+ context "override params" do
+ it "stores them as import data when passed" do
project = described_class
- .new(namespace.owner, import_params, description: 'Hello')
- .execute
+ .new(namespace.owner, import_params, description: "Hello")
+ .execute
- expect(project.import_data.data['override_params']['description']).to eq('Hello')
+ expect(project.import_data.data["override_params"]["description"]).to eq("Hello")
end
end
- context 'when there is a project with the same path' do
+ context "when there is a project with the same path" do
let(:existing_project) { create(:project, namespace: namespace) }
let(:path) { existing_project.path}
- it 'does not create the project' do
+ it "does not create the project" do
project = subject.execute
expect(project).to be_invalid
expect(project).not_to be_persisted
end
- context 'when overwrite param is set' do
+ context "when overwrite param is set" do
let(:overwrite) { true }
- it 'creates a project in a temporary full_path' do
+ it "creates a project in a temporary full_path" do
project = subject.execute
expect(project).to be_valid
diff --git a/spec/support/shared_examples/showing_user_status_shared_examples.rb b/spec/support/shared_examples/showing_user_status_shared_examples.rb
index eef769de2fc..40411f091c4 100644
--- a/spec/support/shared_examples/showing_user_status_shared_examples.rb
+++ b/spec/support/shared_examples/showing_user_status_shared_examples.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-shared_examples 'showing user status' do
- let!(:status) { create(:user_status, user: user_with_status, emoji: 'smirk', message: 'Authoring this object') }
+shared_examples "showing user status" do
+ let!(:status) { create(:user_status, user: user_with_status, emoji: "smirk", message: "Authoring this object") }
- it 'shows the status' do
+ it "shows the status" do
subject
expect(page).to show_user_status(status)
diff --git a/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb b/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb
index 940c24c8d67..1b8a87a1ff2 100644
--- a/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb
+++ b/spec/support/shared_examples/slack_mattermost_notifications_shared_examples.rb
@@ -1,12 +1,12 @@
Dir[Rails.root.join("app/models/project_services/chat_message/*.rb")].each { |f| require f }
-RSpec.shared_examples 'slack or mattermost notifications' do
+RSpec.shared_examples "slack or mattermost notifications" do
let(:chat_service) { described_class.new }
- let(:webhook_url) { 'https://example.gitlab.com/' }
+ let(:webhook_url) { "https://example.gitlab.com/" }
def execute_with_options(options)
receive(:new).with(webhook_url, options)
- .and_return(double(:slack_service).as_null_object)
+ .and_return(double(:slack_service).as_null_object)
end
describe "Associations" do
@@ -14,17 +14,17 @@ RSpec.shared_examples 'slack or mattermost notifications' do
it { is_expected.to have_one :service_hook }
end
- describe 'Validations' do
- context 'when service is active' do
+ describe "Validations" do
+ context "when service is active" do
before do
subject.active = true
end
it { is_expected.to validate_presence_of(:webhook) }
- it_behaves_like 'issue tracker service URL attribute', :webhook
+ it_behaves_like "issue tracker service URL attribute", :webhook
end
- context 'when service is inactive' do
+ context "when service is inactive" do
before do
subject.active = false
end
@@ -36,9 +36,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do
describe "#execute" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, :wiki_repo) }
- let(:username) { 'slack_username' }
- let(:channel) { 'slack_channel' }
- let(:issue_service_options) { { title: 'Awesome issue', description: 'please fix' } }
+ let(:username) { "slack_username" }
+ let(:channel) { "slack_channel" }
+ let(:issue_service_options) { {title: "Awesome issue", description: "please fix"} }
let(:push_sample_data) do
Gitlab::DataBuilder::Push.build_sample(project, user)
@@ -56,30 +56,30 @@ RSpec.shared_examples 'slack or mattermost notifications' do
issue_service = Issues::CreateService.new(project, user, issue_service_options)
@issue = issue_service.execute
- @issues_sample_data = issue_service.hook_data(@issue, 'open')
+ @issues_sample_data = issue_service.hook_data(@issue, "open")
project.add_developer(user)
opts = {
- title: 'Awesome merge_request',
- description: 'please fix',
- source_branch: 'feature',
- target_branch: 'master'
+ title: "Awesome merge_request",
+ description: "please fix",
+ source_branch: "feature",
+ target_branch: "master",
}
merge_service = MergeRequests::CreateService.new(project,
- user, opts)
+ user, opts)
@merge_request = merge_service.execute
@merge_sample_data = merge_service.hook_data(@merge_request,
- 'open')
+ "open")
opts = {
title: "Awesome wiki_page",
content: "Some text describing some thing or another",
format: "md",
- message: "user created page: Awesome wiki_page"
+ message: "user created page: Awesome wiki_page",
}
@wiki_page = create(:wiki_page, wiki: project.wiki, attrs: opts)
- @wiki_page_sample_data = Gitlab::DataBuilder::WikiPage.build(@wiki_page, user, 'create')
+ @wiki_page_sample_data = Gitlab::DataBuilder::WikiPage.build(@wiki_page, user, "create")
end
it "calls Slack/Mattermost API for push events" do
@@ -106,19 +106,19 @@ RSpec.shared_examples 'slack or mattermost notifications' do
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it 'uses the username as an option for slack when configured' do
+ it "uses the username as an option for slack when configured" do
allow(chat_service).to receive(:username).and_return(username)
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, username: username)
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, username: username)
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(push_sample_data)
end
- it 'uses the channel as an option when it is configured' do
+ it "uses the channel as an option when it is configured" do
allow(chat_service).to receive(:channel).and_return(channel)
expect(Slack::Notifier).to receive(:new)
.with(webhook_url, channel: channel)
@@ -133,10 +133,10 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.update(push_channel: "random")
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random")
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, channel: "random")
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(push_sample_data)
end
@@ -145,10 +145,10 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.update(merge_request_channel: "random")
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random")
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, channel: "random")
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(@merge_sample_data)
end
@@ -157,29 +157,29 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.update(issue_channel: "random")
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random")
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, channel: "random")
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(@issues_sample_data)
end
- context 'for confidential issues' do
- let(:issue_service_options) { { title: 'Secret', confidential: true } }
+ context "for confidential issues" do
+ let(:issue_service_options) { {title: "Secret", confidential: true} }
it "uses confidential issue channel" do
- chat_service.update(confidential_issue_channel: 'confidential')
+ chat_service.update(confidential_issue_channel: "confidential")
- expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+ expect(Slack::Notifier).to execute_with_options(channel: "confidential")
chat_service.execute(@issues_sample_data)
end
- it 'falls back to issue channel' do
- chat_service.update(issue_channel: 'fallback_channel')
+ it "falls back to issue channel" do
+ chat_service.update(issue_channel: "fallback_channel")
- expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+ expect(Slack::Notifier).to execute_with_options(channel: "fallback_channel")
chat_service.execute(@issues_sample_data)
end
@@ -189,10 +189,10 @@ RSpec.shared_examples 'slack or mattermost notifications' do
chat_service.update(wiki_page_channel: "random")
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random")
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, channel: "random")
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(@wiki_page_sample_data)
end
@@ -208,15 +208,15 @@ RSpec.shared_examples 'slack or mattermost notifications' do
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
expect(Slack::Notifier).to receive(:new)
- .with(webhook_url, channel: "random")
- .and_return(
- double(:slack_service).as_null_object
- )
+ .with(webhook_url, channel: "random")
+ .and_return(
+ double(:slack_service).as_null_object
+ )
chat_service.execute(note_data)
end
- context 'for confidential notes' do
+ context "for confidential notes" do
before do
issue_note.noteable.update!(confidential: true)
end
@@ -226,17 +226,17 @@ RSpec.shared_examples 'slack or mattermost notifications' do
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
- expect(Slack::Notifier).to execute_with_options(channel: 'confidential')
+ expect(Slack::Notifier).to execute_with_options(channel: "confidential")
chat_service.execute(note_data)
end
- it 'falls back to note channel' do
+ it "falls back to note channel" do
chat_service.update(note_channel: "fallback_channel")
note_data = Gitlab::DataBuilder::Note.build(issue_note, user)
- expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel')
+ expect(Slack::Notifier).to execute_with_options(channel: "fallback_channel")
chat_service.execute(note_data)
end
@@ -245,7 +245,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- describe 'Push events' do
+ describe "Push events" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, creator: user) }
@@ -259,13 +259,13 @@ RSpec.shared_examples 'slack or mattermost notifications' do
WebMock.stub_request(:post, webhook_url)
end
- context 'only notify for the default branch' do
- context 'when enabled' do
+ context "only notify for the default branch" do
+ context "when enabled" do
before do
chat_service.notify_only_default_branch = true
end
- it 'does not notify push events if they are not for the default branch' do
+ it "does not notify push events if they are not for the default branch" do
ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}test"
push_sample_data = Gitlab::DataBuilder::Push.build(project, user, nil, nil, ref, [])
@@ -274,7 +274,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
expect(WebMock).not_to have_requested(:post, webhook_url)
end
- it 'notifies about push events for the default branch' do
+ it "notifies about push events for the default branch" do
push_sample_data = Gitlab::DataBuilder::Push.build_sample(project, user)
chat_service.execute(push_sample_data)
@@ -282,7 +282,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
expect(WebMock).to have_requested(:post, webhook_url).once
end
- it 'still notifies about pushed tags' do
+ it "still notifies about pushed tags" do
ref = "#{Gitlab::Git::TAG_REF_PREFIX}test"
push_sample_data = Gitlab::DataBuilder::Push.build(project, user, nil, nil, ref, [])
@@ -292,12 +292,12 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'when disabled' do
+ context "when disabled" do
before do
chat_service.notify_only_default_branch = false
end
- it 'notifies about all push events' do
+ it "notifies about all push events" do
ref = "#{Gitlab::Git::BRANCH_REF_PREFIX}test"
push_sample_data = Gitlab::DataBuilder::Push.build(project, user, nil, nil, ref, [])
@@ -324,12 +324,12 @@ RSpec.shared_examples 'slack or mattermost notifications' do
WebMock.stub_request(:post, webhook_url)
end
- context 'when commit comment event executed' do
+ context "when commit comment event executed" do
let(:commit_note) do
create(:note_on_commit, author: user,
project: project,
commit_id: project.repository.commit.id,
- note: 'a comment on a commit')
+ note: "a comment on a commit")
end
it "calls Slack/Mattermost API for commit comment events" do
@@ -340,7 +340,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'when merge request comment event executed' do
+ context "when merge request comment event executed" do
let(:merge_request_note) do
create(:note_on_merge_request, project: project,
note: "merge request note")
@@ -354,7 +354,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'when issue comment event executed' do
+ context "when issue comment event executed" do
let(:issue_note) do
create(:note_on_issue, project: project, note: "issue note")
end
@@ -368,7 +368,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'when snippet comment event executed' do
+ context "when snippet comment event executed" do
let(:snippet_note) do
create(:note_on_project_snippet, project: project,
note: "snippet note")
@@ -383,14 +383,14 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- describe 'Pipeline events' do
+ describe "Pipeline events" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:pipeline) do
create(:ci_pipeline,
- project: project, status: status,
- sha: project.commit.sha, ref: project.default_branch)
+ project: project, status: status,
+ sha: project.commit.sha, ref: project.default_branch)
end
before do
@@ -401,12 +401,12 @@ RSpec.shared_examples 'slack or mattermost notifications' do
)
end
- shared_examples 'call Slack/Mattermost API' do
+ shared_examples "call Slack/Mattermost API" do
before do
WebMock.stub_request(:post, webhook_url)
end
- it 'calls Slack/Mattermost API for pipeline events' do
+ it "calls Slack/Mattermost API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
chat_service.execute(data)
@@ -414,17 +414,17 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'with failed pipeline' do
- let(:status) { 'failed' }
+ context "with failed pipeline" do
+ let(:status) { "failed" }
- it_behaves_like 'call Slack/Mattermost API'
+ it_behaves_like "call Slack/Mattermost API"
end
- context 'with succeeded pipeline' do
- let(:status) { 'success' }
+ context "with succeeded pipeline" do
+ let(:status) { "success" }
- context 'with default to notify_only_broken_pipelines' do
- it 'does not call Slack/Mattermost API for pipeline events' do
+ context "with default to notify_only_broken_pipelines" do
+ it "does not call Slack/Mattermost API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
@@ -432,19 +432,19 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'with setting notify_only_broken_pipelines to false' do
+ context "with setting notify_only_broken_pipelines to false" do
before do
chat_service.notify_only_broken_pipelines = false
end
- it_behaves_like 'call Slack/Mattermost API'
+ it_behaves_like "call Slack/Mattermost API"
end
end
- context 'only notify for the default branch' do
- context 'when enabled' do
+ context "only notify for the default branch" do
+ context "when enabled" do
let(:pipeline) do
- create(:ci_pipeline, :failed, project: project, ref: 'not-the-default-branch')
+ create(:ci_pipeline, :failed, project: project, ref: "not-the-default-branch")
end
before do
@@ -452,7 +452,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do
WebMock.stub_request(:post, webhook_url)
end
- it 'does not call the Slack/Mattermost API for pipeline events' do
+ it "does not call the Slack/Mattermost API for pipeline events" do
data = Gitlab::DataBuilder::Pipeline.build(pipeline)
result = chat_service.execute(data)
@@ -460,16 +460,16 @@ RSpec.shared_examples 'slack or mattermost notifications' do
end
end
- context 'when disabled' do
+ context "when disabled" do
let(:pipeline) do
- create(:ci_pipeline, :failed, project: project, ref: 'not-the-default-branch')
+ create(:ci_pipeline, :failed, project: project, ref: "not-the-default-branch")
end
before do
chat_service.notify_only_default_branch = false
end
- it_behaves_like 'call Slack/Mattermost API'
+ it_behaves_like "call Slack/Mattermost API"
end
end
end
diff --git a/spec/support/shared_examples/snippet_visibility.rb b/spec/support/shared_examples/snippet_visibility.rb
index 3a7c69b7877..e7d5be3fe6e 100644
--- a/spec/support/shared_examples/snippet_visibility.rb
+++ b/spec/support/shared_examples/snippet_visibility.rb
@@ -1,4 +1,4 @@
-RSpec.shared_examples 'snippet visibility' do
+RSpec.shared_examples "snippet visibility" do
let!(:author) { create(:user) }
let!(:member) { create(:user) }
let!(:external) { create(:user, :external) }
@@ -7,7 +7,7 @@ RSpec.shared_examples 'snippet visibility' do
{
public: Snippet::PUBLIC,
internal: Snippet::INTERNAL,
- private: Snippet::PRIVATE
+ private: Snippet::PRIVATE,
}
end
@@ -18,7 +18,7 @@ RSpec.shared_examples 'snippet visibility' do
external: external,
non_member: create(:user),
member: member,
- author: author
+ author: author,
}
end
@@ -26,7 +26,7 @@ RSpec.shared_examples 'snippet visibility' do
{
public: Gitlab::VisibilityLevel::PUBLIC,
internal: Gitlab::VisibilityLevel::INTERNAL,
- private: Gitlab::VisibilityLevel::PRIVATE
+ private: Gitlab::VisibilityLevel::PRIVATE,
}
end
@@ -34,7 +34,7 @@ RSpec.shared_examples 'snippet visibility' do
{
enabled: ProjectFeature::ENABLED,
private: ProjectFeature::PRIVATE,
- disabled: ProjectFeature::DISABLED
+ disabled: ProjectFeature::DISABLED,
}
end
@@ -221,7 +221,7 @@ RSpec.shared_examples 'snippet visibility' do
[:private, :disabled, :author, :public, false],
[:private, :disabled, :author, :internal, false],
- [:private, :disabled, :author, :private, false]
+ [:private, :disabled, :author, :private, false],
]
end
@@ -237,23 +237,23 @@ RSpec.shared_examples 'snippet visibility' do
end
context "For #{params[:project_type]} project and #{params[:user_type]} users" do
- it 'should agree with the read_project_snippet policy' do
+ it "should agree with the read_project_snippet policy" do
expect(can?(user, :read_project_snippet, snippet)).to eq(outcome)
end
- it 'should return proper outcome' do
+ it "should return proper outcome" do
results = described_class.new(user, project: project).execute
expect(results.include?(snippet)).to eq(outcome)
end
end
context "Without a given project and #{params[:user_type]} users" do
- it 'should return proper outcome' do
+ it "should return proper outcome" do
results = described_class.new(user).execute
expect(results.include?(snippet)).to eq(outcome)
end
- it 'returns no snippets when the user cannot read cross project' do
+ it "returns no snippets when the user cannot read cross project" do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
@@ -265,13 +265,13 @@ RSpec.shared_examples 'snippet visibility' do
end
end
- context 'For personal snippets' do
+ context "For personal snippets" do
let!(:users) do
{
unauthenticated: nil,
external: external,
non_member: create(:user),
- author: author
+ author: author,
}
end
@@ -290,7 +290,7 @@ RSpec.shared_examples 'snippet visibility' do
[:private, :unauthenticated, false],
[:private, :external, false],
[:private, :non_member, false],
- [:private, :author, true]
+ [:private, :author, true],
]
end
@@ -299,16 +299,16 @@ RSpec.shared_examples 'snippet visibility' do
let!(:snippet) { create(:personal_snippet, visibility_level: snippet_type_visibilities[snippet_visibility], author: author) }
context "For personal and #{params[:snippet_visibility]} snippets with #{params[:user_type]} user" do
- it 'should agree with read_personal_snippet policy' do
+ it "should agree with read_personal_snippet policy" do
expect(can?(user, :read_personal_snippet, snippet)).to eq(outcome)
end
- it 'should return proper outcome' do
+ it "should return proper outcome" do
results = described_class.new(user).execute
expect(results.include?(snippet)).to eq(outcome)
end
- it 'should return personal snippets when the user cannot read cross project' do
+ it "should return personal snippets when the user cannot read cross project" do
allow(Ability).to receive(:allowed?).and_call_original
allow(Ability).to receive(:allowed?).with(user, :read_cross_project) { false }
diff --git a/spec/support/shared_examples/snippets_shared_examples.rb b/spec/support/shared_examples/snippets_shared_examples.rb
index 85f0facd5c3..0dcd7020790 100644
--- a/spec/support/shared_examples/snippets_shared_examples.rb
+++ b/spec/support/shared_examples/snippets_shared_examples.rb
@@ -1,18 +1,18 @@
# These shared examples expect a `snippets` array of snippets
-RSpec.shared_examples 'paginated snippets' do |remote: false|
+RSpec.shared_examples "paginated snippets" do |remote: false|
it "is limited to #{Snippet.default_per_page} items per page" do
- expect(page.all('.snippets-list-holder .snippet-row').count).to eq(Snippet.default_per_page)
+ expect(page.all(".snippets-list-holder .snippet-row").count).to eq(Snippet.default_per_page)
end
- context 'clicking on the link to the second page' do
+ context "clicking on the link to the second page" do
before do
- click_link('2')
+ click_link("2")
wait_for_requests if remote
end
- it 'shows the remaining snippets' do
+ it "shows the remaining snippets" do
remaining_snippets_count = [snippets.size - Snippet.default_per_page, Snippet.default_per_page].min
- expect(page).to have_selector('.snippets-list-holder .snippet-row', count: remaining_snippets_count)
+ expect(page).to have_selector(".snippets-list-holder .snippet-row", count: remaining_snippets_count)
end
end
end
diff --git a/spec/support/shared_examples/taskable_shared_examples.rb b/spec/support/shared_examples/taskable_shared_examples.rb
index 4056ff06b84..8d1d2502eb5 100644
--- a/spec/support/shared_examples/taskable_shared_examples.rb
+++ b/spec/support/shared_examples/taskable_shared_examples.rb
@@ -2,8 +2,8 @@
#
# Requires a context containing:
# subject { Issue or MergeRequest }
-shared_examples 'a Taskable' do
- describe 'with multiple tasks' do
+shared_examples "a Taskable" do
+ describe "with multiple tasks" do
before do
subject.description = <<-EOT.strip_heredoc
* [ ] Task 1
@@ -14,26 +14,26 @@ shared_examples 'a Taskable' do
EOT
end
- it 'returns the correct task status' do
- expect(subject.task_status).to match('2 of')
- expect(subject.task_status).to match('5 tasks completed')
- expect(subject.task_status_short).to match('2/')
- expect(subject.task_status_short).to match('5 tasks')
+ it "returns the correct task status" do
+ expect(subject.task_status).to match("2 of")
+ expect(subject.task_status).to match("5 tasks completed")
+ expect(subject.task_status_short).to match("2/")
+ expect(subject.task_status_short).to match("5 tasks")
end
- describe '#tasks?' do
- it 'returns true when object has tasks' do
+ describe "#tasks?" do
+ it "returns true when object has tasks" do
expect(subject.tasks?).to eq true
end
- it 'returns false when object has no tasks' do
- subject.description = 'Now I have no tasks'
+ it "returns false when object has no tasks" do
+ subject.description = "Now I have no tasks"
expect(subject.tasks?).to eq false
end
end
end
- describe 'with nested tasks' do
+ describe "with nested tasks" do
before do
subject.description = <<-EOT.strip_heredoc
- [ ] Task a
@@ -49,30 +49,30 @@ shared_examples 'a Taskable' do
EOT
end
- it 'returns the correct task status' do
- expect(subject.task_status).to match('3 of')
- expect(subject.task_status).to match('9 tasks completed')
- expect(subject.task_status_short).to match('3/')
- expect(subject.task_status_short).to match('9 tasks')
+ it "returns the correct task status" do
+ expect(subject.task_status).to match("3 of")
+ expect(subject.task_status).to match("9 tasks completed")
+ expect(subject.task_status_short).to match("3/")
+ expect(subject.task_status_short).to match("9 tasks")
end
end
- describe 'with an incomplete task' do
+ describe "with an incomplete task" do
before do
subject.description = <<-EOT.strip_heredoc
* [ ] Task 1
EOT
end
- it 'returns the correct task status' do
- expect(subject.task_status).to match('0 of')
- expect(subject.task_status).to match('1 task completed')
- expect(subject.task_status_short).to match('0/')
- expect(subject.task_status_short).to match('1 task')
+ it "returns the correct task status" do
+ expect(subject.task_status).to match("0 of")
+ expect(subject.task_status).to match("1 task completed")
+ expect(subject.task_status_short).to match("0/")
+ expect(subject.task_status_short).to match("1 task")
end
end
- describe 'with tasks that are not formatted correctly' do
+ describe "with tasks that are not formatted correctly" do
before do
subject.description = <<-EOT.strip_heredoc
[ ] task 1
@@ -83,26 +83,26 @@ shared_examples 'a Taskable' do
EOT
end
- it 'returns the correct task status' do
- expect(subject.task_status).to match('0 of')
- expect(subject.task_status).to match('0 tasks completed')
- expect(subject.task_status_short).to match('0/')
- expect(subject.task_status_short).to match('0 task')
+ it "returns the correct task status" do
+ expect(subject.task_status).to match("0 of")
+ expect(subject.task_status).to match("0 tasks completed")
+ expect(subject.task_status_short).to match("0/")
+ expect(subject.task_status_short).to match("0 task")
end
end
- describe 'with a complete task' do
+ describe "with a complete task" do
before do
subject.description = <<-EOT.strip_heredoc
* [x] Task 1
EOT
end
- it 'returns the correct task status' do
- expect(subject.task_status).to match('1 of')
- expect(subject.task_status).to match('1 task completed')
- expect(subject.task_status_short).to match('1/')
- expect(subject.task_status_short).to match('1 task')
+ it "returns the correct task status" do
+ expect(subject.task_status).to match("1 of")
+ expect(subject.task_status).to match("1 task completed")
+ expect(subject.task_status_short).to match("1/")
+ expect(subject.task_status_short).to match("1 task")
end
end
end
diff --git a/spec/support/shared_examples/throttled_touch.rb b/spec/support/shared_examples/throttled_touch.rb
index eba990d4037..2f13ad1c31a 100644
--- a/spec/support/shared_examples/throttled_touch.rb
+++ b/spec/support/shared_examples/throttled_touch.rb
@@ -1,13 +1,13 @@
-shared_examples_for 'throttled touch' do
- describe '#touch' do
- it 'updates the updated_at timestamp' do
+shared_examples_for "throttled touch" do
+ describe "#touch" do
+ it "updates the updated_at timestamp" do
Timecop.freeze do
subject.touch
expect(subject.updated_at).to be_like_time(Time.zone.now)
end
end
- it 'updates the object at most once per minute' do
+ it "updates the object at most once per minute" do
first_updated_at = Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 2)
second_updated_at = Time.zone.now - (ThrottledTouch::TOUCH_INTERVAL * 1.5)
diff --git a/spec/support/shared_examples/time_tracking_shared_examples.rb b/spec/support/shared_examples/time_tracking_shared_examples.rb
index 909d4e2ee8d..ca04817092b 100644
--- a/spec/support/shared_examples/time_tracking_shared_examples.rb
+++ b/spec/support/shared_examples/time_tracking_shared_examples.rb
@@ -1,85 +1,85 @@
-shared_examples 'issuable time tracker' do
- it 'renders the sidebar component empty state' do
- page.within '.time-tracking-no-tracking-pane' do
- expect(page).to have_content 'No estimate or time spent'
+shared_examples "issuable time tracker" do
+ it "renders the sidebar component empty state" do
+ page.within ".time-tracking-no-tracking-pane" do
+ expect(page).to have_content "No estimate or time spent"
end
end
- it 'updates the sidebar component when estimate is added' do
- submit_time('/estimate 3w 1d 1h')
+ it "updates the sidebar component when estimate is added" do
+ submit_time("/estimate 3w 1d 1h")
wait_for_requests
- page.within '.time-tracking-estimate-only-pane' do
- expect(page).to have_content '3w 1d 1h'
+ page.within ".time-tracking-estimate-only-pane" do
+ expect(page).to have_content "3w 1d 1h"
end
end
- it 'updates the sidebar component when spent is added' do
- submit_time('/spend 3w 1d 1h')
+ it "updates the sidebar component when spent is added" do
+ submit_time("/spend 3w 1d 1h")
wait_for_requests
- page.within '.time-tracking-spend-only-pane' do
- expect(page).to have_content '3w 1d 1h'
+ page.within ".time-tracking-spend-only-pane" do
+ expect(page).to have_content "3w 1d 1h"
end
end
- it 'shows the comparison when estimate and spent are added' do
- submit_time('/estimate 3w 1d 1h')
- submit_time('/spend 3w 1d 1h')
+ it "shows the comparison when estimate and spent are added" do
+ submit_time("/estimate 3w 1d 1h")
+ submit_time("/spend 3w 1d 1h")
wait_for_requests
- page.within '.time-tracking-comparison-pane' do
- expect(page).to have_content '3w 1d 1h'
+ page.within ".time-tracking-comparison-pane" do
+ expect(page).to have_content "3w 1d 1h"
end
end
- it 'updates the sidebar component when estimate is removed' do
- submit_time('/estimate 3w 1d 1h')
- submit_time('/remove_estimate')
+ it "updates the sidebar component when estimate is removed" do
+ submit_time("/estimate 3w 1d 1h")
+ submit_time("/remove_estimate")
- page.within '.time-tracking-component-wrap' do
- expect(page).to have_content 'No estimate or time spent'
+ page.within ".time-tracking-component-wrap" do
+ expect(page).to have_content "No estimate or time spent"
end
end
- it 'updates the sidebar component when spent is removed' do
- submit_time('/spend 3w 1d 1h')
- submit_time('/remove_time_spent')
+ it "updates the sidebar component when spent is removed" do
+ submit_time("/spend 3w 1d 1h")
+ submit_time("/remove_time_spent")
- page.within '.time-tracking-component-wrap' do
- expect(page).to have_content 'No estimate or time spent'
+ page.within ".time-tracking-component-wrap" do
+ expect(page).to have_content "No estimate or time spent"
end
end
- it 'shows the help state when icon is clicked' do
- page.within '.time-tracking-component-wrap' do
- find('.help-button').click
- expect(page).to have_content 'Track time with quick actions'
- expect(page).to have_content 'Learn more'
+ it "shows the help state when icon is clicked" do
+ page.within ".time-tracking-component-wrap" do
+ find(".help-button").click
+ expect(page).to have_content "Track time with quick actions"
+ expect(page).to have_content "Learn more"
end
end
- it 'hides the help state when close icon is clicked' do
- page.within '.time-tracking-component-wrap' do
- find('.help-button').click
- find('.close-help-button').click
+ it "hides the help state when close icon is clicked" do
+ page.within ".time-tracking-component-wrap" do
+ find(".help-button").click
+ find(".close-help-button").click
- expect(page).not_to have_content 'Track time with quick actions'
- expect(page).not_to have_content 'Learn more'
+ expect(page).not_to have_content "Track time with quick actions"
+ expect(page).not_to have_content "Learn more"
end
end
- it 'displays the correct help url' do
- page.within '.time-tracking-component-wrap' do
- find('.help-button').click
+ it "displays the correct help url" do
+ page.within ".time-tracking-component-wrap" do
+ find(".help-button").click
- expect(find_link('Learn more')[:href]).to have_content('/help/workflow/time_tracking.md')
+ expect(find_link("Learn more")[:href]).to have_content("/help/workflow/time_tracking.md")
end
end
end
def submit_time(quick_action)
- fill_in 'note[note]', with: quick_action
- find('.js-comment-submit-button').click
+ fill_in "note[note]", with: quick_action
+ find(".js-comment-submit-button").click
wait_for_requests
end
diff --git a/spec/support/shared_examples/unique_ip_check_shared_examples.rb b/spec/support/shared_examples/unique_ip_check_shared_examples.rb
index e5c8ac6a004..6bab5404cb1 100644
--- a/spec/support/shared_examples/unique_ip_check_shared_examples.rb
+++ b/spec/support/shared_examples/unique_ip_check_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_context 'unique ips sign in limit' do
+shared_context "unique ips sign in limit" do
include StubENV
before do
Gitlab::Redis::Cache.with(&:flushall)
@@ -7,7 +7,7 @@ shared_context 'unique ips sign in limit' do
end
before do
- stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false')
+ stub_env("IN_MEMORY_APPLICATION_SETTINGS", "false")
Gitlab::CurrentSettings.update!(
unique_ips_limit_enabled: true,
@@ -31,38 +31,38 @@ shared_context 'unique ips sign in limit' do
end
end
-shared_examples 'user login operation with unique ip limit' do
- include_context 'unique ips sign in limit' do
+shared_examples "user login operation with unique ip limit" do
+ include_context "unique ips sign in limit" do
before do
Gitlab::CurrentSettings.update!(unique_ips_limit_per_user: 1)
end
- it 'allows user authenticating from the same ip' do
- expect { operation_from_ip('ip') }.not_to raise_error
- expect { operation_from_ip('ip') }.not_to raise_error
+ it "allows user authenticating from the same ip" do
+ expect { operation_from_ip("ip") }.not_to raise_error
+ expect { operation_from_ip("ip") }.not_to raise_error
end
- it 'blocks user authenticating from two distinct ips' do
- expect { operation_from_ip('ip') }.not_to raise_error
- expect { operation_from_ip('ip2') }.to raise_error(Gitlab::Auth::TooManyIps)
+ it "blocks user authenticating from two distinct ips" do
+ expect { operation_from_ip("ip") }.not_to raise_error
+ expect { operation_from_ip("ip2") }.to raise_error(Gitlab::Auth::TooManyIps)
end
end
end
-shared_examples 'user login request with unique ip limit' do |success_status = 200|
- include_context 'unique ips sign in limit' do
+shared_examples "user login request with unique ip limit" do |success_status = 200|
+ include_context "unique ips sign in limit" do
before do
Gitlab::CurrentSettings.update!(unique_ips_limit_per_user: 1)
end
- it 'allows user authenticating from the same ip' do
- expect(request_from_ip('ip')).to have_gitlab_http_status(success_status)
- expect(request_from_ip('ip')).to have_gitlab_http_status(success_status)
+ it "allows user authenticating from the same ip" do
+ expect(request_from_ip("ip")).to have_gitlab_http_status(success_status)
+ expect(request_from_ip("ip")).to have_gitlab_http_status(success_status)
end
- it 'blocks user authenticating from two distinct ips' do
- expect(request_from_ip('ip')).to have_gitlab_http_status(success_status)
- expect(request_from_ip('ip2')).to have_gitlab_http_status(403)
+ it "blocks user authenticating from two distinct ips" do
+ expect(request_from_ip("ip")).to have_gitlab_http_status(success_status)
+ expect(request_from_ip("ip2")).to have_gitlab_http_status(403)
end
end
end
diff --git a/spec/support/shared_examples/update_invalid_issuable.rb b/spec/support/shared_examples/update_invalid_issuable.rb
index 64568de424e..4edef0294c1 100644
--- a/spec/support/shared_examples/update_invalid_issuable.rb
+++ b/spec/support/shared_examples/update_invalid_issuable.rb
@@ -1,9 +1,9 @@
-shared_examples 'update invalid issuable' do |klass|
+shared_examples "update invalid issuable" do |klass|
let(:params) do
{
namespace_id: project.namespace.path,
project_id: project.path,
- id: issuable.iid
+ id: issuable.iid,
}
end
@@ -13,42 +13,42 @@ shared_examples 'update invalid issuable' do |klass|
before do
if klass == Issue
- params.merge!(issue: { title: "any" })
+ params.merge!(issue: {title: "any"})
else
- params.merge!(merge_request: { title: "any" })
+ params.merge!(merge_request: {title: "any"})
end
end
- context 'when updating causes conflicts' do
+ context "when updating causes conflicts" do
before do
allow_any_instance_of(issuable.class).to receive(:save)
.and_raise(ActiveRecord::StaleObjectError.new(issuable, :save))
end
- it 'renders edit when format is html' do
+ it "renders edit when format is html" do
put :update, params: params
expect(response).to render_template(:edit)
expect(assigns[:conflict]).to be_truthy
end
- it 'renders json error message when format is json' do
+ it "renders json error message when format is json" do
params[:format] = "json"
put :update, params: params
expect(response.status).to eq(409)
- expect(JSON.parse(response.body)).to have_key('errors')
+ expect(JSON.parse(response.body)).to have_key("errors")
end
end
- context 'when updating an invalid issuable' do
+ context "when updating an invalid issuable" do
before do
key = klass == Issue ? :issue : :merge_request
params[key][:title] = ""
end
- it 'renders edit when merge request is invalid' do
+ it "renders edit when merge request is invalid" do
put :update, params: params
expect(response).to render_template(:edit)
diff --git a/spec/support/shared_examples/updating_mentions_shared_examples.rb b/spec/support/shared_examples/updating_mentions_shared_examples.rb
index 5e3f19ba19e..2a9c45e593f 100644
--- a/spec/support/shared_examples/updating_mentions_shared_examples.rb
+++ b/spec/support/shared_examples/updating_mentions_shared_examples.rb
@@ -1,4 +1,4 @@
-RSpec.shared_examples 'updating mentions' do |service_class|
+RSpec.shared_examples "updating mentions" do |service_class|
let(:mentioned_user) { create(:user) }
let(:service_class) { service_class }
@@ -14,22 +14,22 @@ RSpec.shared_examples 'updating mentions' do |service_class|
mentionable.reload
end
- context 'in title' do
+ context "in title" do
before do
update_mentionable(title: mentioned_user.to_reference)
end
- it 'emails only the newly-mentioned user' do
+ it "emails only the newly-mentioned user" do
should_only_email(mentioned_user)
end
end
- context 'in description' do
+ context "in description" do
before do
update_mentionable(description: mentioned_user.to_reference)
end
- it 'emails only the newly-mentioned user' do
+ it "emails only the newly-mentioned user" do
should_only_email(mentioned_user)
end
end
diff --git a/spec/support/shared_examples/uploaders/gitlab_uploader_shared_examples.rb b/spec/support/shared_examples/uploaders/gitlab_uploader_shared_examples.rb
index 1190863d88e..d49303664f0 100644
--- a/spec/support/shared_examples/uploaders/gitlab_uploader_shared_examples.rb
+++ b/spec/support/shared_examples/uploaders/gitlab_uploader_shared_examples.rb
@@ -14,7 +14,7 @@ shared_examples "builds correct paths" do |**patterns|
let(:patterns) { patterns }
before do
- allow(subject).to receive(:filename).and_return('<filename>')
+ allow(subject).to receive(:filename).and_return("<filename>")
end
describe "#store_dir" do
@@ -34,8 +34,8 @@ shared_examples "builds correct paths" do |**patterns|
end
describe "#relative_path" do
- it 'is relative' do
- skip 'Path not set, skipping.' unless subject.path
+ it "is relative" do
+ skip "Path not set, skipping." unless subject.path
expect(Pathname.new(subject.relative_path)).to be_relative
end
diff --git a/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb b/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb
index 1bd176280c5..0ad0e815656 100644
--- a/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb
+++ b/spec/support/shared_examples/uploaders/object_storage_shared_examples.rb
@@ -1,4 +1,4 @@
-shared_context 'with storage' do |store, **stub_params|
+shared_context "with storage" do |store, **stub_params|
before do
subject.object_store = store
end
@@ -20,7 +20,7 @@ shared_examples "migrates" do |to_store:, from_store: nil|
migrate(from)
end
- it 'returns corresponding file type' do
+ it "returns corresponding file type" do
expect(subject).to be_an(CarrierWave::Uploader::Base)
expect(subject).to be_a(ObjectStorage::Concern)
@@ -29,29 +29,29 @@ shared_examples "migrates" do |to_store:, from_store: nil|
elsif from == described_class::Store::LOCAL
expect(subject.file).to be_a(CarrierWave::SanitizedFile)
else
- raise 'Unexpected file type'
+ raise "Unexpected file type"
end
end
- it 'does nothing when migrating to the current store' do
+ it "does nothing when migrating to the current store" do
expect { migrate(from) }.not_to change { subject.object_store }.from(from)
end
- it 'migrate to the specified store' do
+ it "migrate to the specified store" do
from_checksum = checksum
expect { migrate(to) }.to change { subject.object_store }.from(from).to(to)
expect(checksum).to eq(from_checksum)
end
- it 'removes the original file after the migration' do
+ it "removes the original file after the migration" do
original_file = subject.file.path
migrate(to)
expect(File.exist?(original_file)).to be_falsey
end
- it 'can access to the original file during migration' do
+ it "can access to the original file during migration" do
file = subject.file
allow(subject).to receive(:delete_migrated_file) { } # Remove as a callback of :migrate
@@ -61,60 +61,60 @@ shared_examples "migrates" do |to_store:, from_store: nil|
expect { migrate(to) }.not_to change { file.exists? }
end
- context 'when migrate! is not occupied by another process' do
- it 'executes migrate!' do
+ context "when migrate! is not occupied by another process" do
+ it "executes migrate!" do
expect(subject).to receive(:object_store=).at_least(1)
migrate(to)
end
- it 'executes use_file' do
+ it "executes use_file" do
expect(subject).to receive(:unsafe_use_file).once
subject.use_file
end
end
- context 'when migrate! is occupied by another process' do
+ context "when migrate! is occupied by another process" do
include ExclusiveLeaseHelpers
before do
stub_exclusive_lease_taken(subject.exclusive_lease_key, timeout: 1.hour.to_i)
end
- it 'does not execute migrate!' do
+ it "does not execute migrate!" do
expect(subject).not_to receive(:unsafe_migrate!)
expect { migrate(to) }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
end
- it 'does not execute use_file' do
+ it "does not execute use_file" do
expect(subject).not_to receive(:unsafe_use_file)
expect { subject.use_file }.to raise_error(ObjectStorage::ExclusiveLeaseTaken)
end
end
- context 'migration is unsuccessful' do
+ context "migration is unsuccessful" do
shared_examples "handles gracefully" do |error:|
- it 'does not update the object_store' do
+ it "does not update the object_store" do
expect { migrate(to) }.to raise_error(error)
expect(subject.object_store).to eq(from)
end
- it 'does not delete the original file' do
+ it "does not delete the original file" do
expect { migrate(to) }.to raise_error(error)
expect(subject.exists?).to be_truthy
end
end
- context 'when the store is not supported' do
+ context "when the store is not supported" do
let(:to) { -1 } # not a valid store
include_examples "handles gracefully", error: ObjectStorage::UnknownStoreError
end
- context 'upon a fog failure' do
+ context "upon a fog failure" do
before do
storage_class = subject.send(:storage_for, to).class
expect_any_instance_of(storage_class).to receive(:store!).and_raise("Store failure.")
@@ -123,7 +123,7 @@ shared_examples "migrates" do |to_store:, from_store: nil|
include_examples "handles gracefully", error: "Store failure."
end
- context 'upon a database failure' do
+ context "upon a database failure" do
before do
expect(uploader).to receive(:persist_object_store!).and_raise("ActiveRecord failure.")
end
diff --git a/spec/support/shared_examples/url_validator_examples.rb b/spec/support/shared_examples/url_validator_examples.rb
index 1f7e2f7ff79..e7c779faf82 100644
--- a/spec/support/shared_examples/url_validator_examples.rb
+++ b/spec/support/shared_examples/url_validator_examples.rb
@@ -1,18 +1,18 @@
-RSpec.shared_examples 'url validator examples' do |protocols|
+RSpec.shared_examples "url validator examples" do |protocols|
let(:validator) { described_class.new(attributes: [:link_url], **options) }
- let!(:badge) { build(:badge, link_url: 'http://www.example.com') }
+ let!(:badge) { build(:badge, link_url: "http://www.example.com") }
subject { validator.validate_each(badge, :link_url, badge.link_url) }
- describe '#validates_each' do
- context 'with no options' do
+ describe "#validates_each" do
+ context "with no options" do
let(:options) { {} }
- it "allows #{protocols.join(',')} protocols by default" do
+ it "allows #{protocols.join(",")} protocols by default" do
expect(validator.send(:default_options)[:protocols]).to eq protocols
end
- it 'checks that the url structure is valid' do
+ it "checks that the url structure is valid" do
badge.link_url = "#{badge.link_url}:invalid_port"
subject
@@ -21,17 +21,17 @@ RSpec.shared_examples 'url validator examples' do |protocols|
end
end
- context 'with protocols' do
- let(:options) { { protocols: %w[http] } }
+ context "with protocols" do
+ let(:options) { {protocols: %w[http]} }
- it 'allows urls with the defined protocols' do
+ it "allows urls with the defined protocols" do
subject
expect(badge.errors.empty?).to be true
end
- it 'add error if the url protocol does not match the selected ones' do
- badge.link_url = 'https://www.example.com'
+ it "add error if the url protocol does not match the selected ones" do
+ badge.link_url = "https://www.example.com"
subject
diff --git a/spec/support/shared_examples/wiki_file_attachments_examples.rb b/spec/support/shared_examples/wiki_file_attachments_examples.rb
index b6fb2a66b0e..162193bd729 100644
--- a/spec/support/shared_examples/wiki_file_attachments_examples.rb
+++ b/spec/support/shared_examples/wiki_file_attachments_examples.rb
@@ -3,85 +3,85 @@
# Requires a context containing:
# project
-shared_examples 'wiki file attachments' do
+shared_examples "wiki file attachments" do
include DropzoneHelper
- context 'uploading attachments', :js do
+ context "uploading attachments", :js do
let(:wiki) { project.wiki }
def attach_with_dropzone(wait = false)
- dropzone_file([Rails.root.join('spec', 'fixtures', 'dk.png')], 0, wait)
+ dropzone_file([Rails.root.join("spec", "fixtures", "dk.png")], 0, wait)
end
- context 'before uploading' do
+ context "before uploading" do
it 'shows "Attach a file" button' do
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
end
- context 'uploading is in progress' do
+ context "uploading is in progress" do
it 'cancels uploading on clicking to "Cancel" button' do
slow_requests do
attach_with_dropzone
- click_button 'Cancel'
+ click_button "Cancel"
end
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_button('Cancel')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_button("Cancel")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
it 'shows "Attaching a file" message on uploading 1 file' do
slow_requests do
attach_with_dropzone
- expect(page).to have_selector('.attaching-file-message', visible: true, text: 'Attaching a file -')
+ expect(page).to have_selector(".attaching-file-message", visible: true, text: "Attaching a file -")
end
end
end
- context 'uploading is complete' do
+ context "uploading is complete" do
it 'shows "Attach a file" button on uploading complete' do
attach_with_dropzone
wait_for_requests
- expect(page).to have_button('Attach a file')
- expect(page).not_to have_selector('.uploading-progress-container', visible: true)
+ expect(page).to have_button("Attach a file")
+ expect(page).not_to have_selector(".uploading-progress-container", visible: true)
end
- it 'the markdown link is added to the page' do
- fill_in(:wiki_content, with: '')
+ it "the markdown link is added to the page" do
+ fill_in(:wiki_content, with: "")
attach_with_dropzone(true)
wait_for_requests
- expect(page.find('#wiki_content').value)
+ expect(page.find("#wiki_content").value)
.to match(%r{\!\[dk\]\(uploads/\h{32}/dk\.png\)$})
end
- it 'the links point to the wiki root url' do
+ it "the links point to the wiki root url" do
attach_with_dropzone(true)
wait_for_requests
- find('.js-md-preview-button').click
+ find(".js-md-preview-button").click
file_path = page.find('input[name="files[]"]', visible: :hidden).value
- link = page.find('a.no-attachment-icon')['href']
- img_link = page.find('a.no-attachment-icon img')['src']
+ link = page.find("a.no-attachment-icon")["href"]
+ img_link = page.find("a.no-attachment-icon img")["src"]
expect(link).to eq img_link
expect(URI.parse(link).path).to eq File.join(wiki.wiki_base_path, file_path)
end
- it 'the file has been added to the wiki repository' do
- expect do
+ it "the file has been added to the wiki repository" do
+ expect {
attach_with_dropzone(true)
wait_for_requests
- end.to change { wiki.repository.ls_files('HEAD').count }.by(1)
+ }.to change { wiki.repository.ls_files("HEAD").count }.by(1)
file_path = page.find('input[name="files[]"]', visible: :hidden).value
- expect(wiki.find_file(file_path, 'HEAD').path).not_to be_nil
+ expect(wiki.find_file(file_path, "HEAD").path).not_to be_nil
end
end
end
diff --git a/spec/support/shoulda/matchers/rails_shim.rb b/spec/support/shoulda/matchers/rails_shim.rb
index 8d70598beb5..7a595111565 100644
--- a/spec/support/shoulda/matchers/rails_shim.rb
+++ b/spec/support/shoulda/matchers/rails_shim.rb
@@ -8,11 +8,11 @@ module Shoulda
def self.serialized_attributes_for(model)
if defined?(::ActiveRecord::Type::Serialized)
# Rails 5+
- serialized_columns = model.columns.select do |column|
+ serialized_columns = model.columns.select { |column|
model.type_for_attribute(column.name).is_a?(
::ActiveRecord::Type::Serialized
)
- end
+ }
serialized_columns.inject({}) do |hash, column| # rubocop:disable Style/EachWithObject
hash[column.name.to_s] = model.type_for_attribute(column.name).coder
diff --git a/spec/support/sidekiq.rb b/spec/support/sidekiq.rb
index 6c4e11910d3..9f2b01ac6a7 100644
--- a/spec/support/sidekiq.rb
+++ b/spec/support/sidekiq.rb
@@ -1,4 +1,4 @@
-require 'sidekiq/testing/inline'
+require "sidekiq/testing/inline"
# If Sidekiq::Testing.inline! is used, SQL transactions done inside
# Sidekiq worker are included in the SQL query limit (in a real
diff --git a/spec/support/stored_repositories.rb b/spec/support/stored_repositories.rb
index 55212355daa..492ae8947ef 100644
--- a/spec/support/stored_repositories.rb
+++ b/spec/support/stored_repositories.rb
@@ -1,7 +1,7 @@
RSpec.configure do |config|
config.before(:each, :broken_storage) do
allow(Gitlab::GitalyClient).to receive(:call) do
- raise GRPC::Unavailable.new('Gitaly broken in this spec')
+ raise GRPC::Unavailable.new("Gitaly broken in this spec")
end
end
end
diff --git a/spec/support/stub_version.rb b/spec/support/stub_version.rb
index 594ab64e7c6..1a106b7a3fb 100644
--- a/spec/support/stub_version.rb
+++ b/spec/support/stub_version.rb
@@ -2,7 +2,7 @@
module StubVersion
def stub_version(version, revision)
- stub_const('Gitlab::VERSION', version)
+ stub_const("Gitlab::VERSION", version)
allow(Gitlab).to receive(:revision).and_return(revision)
end
end
diff --git a/spec/support/test_reports/test_reports_helper.rb b/spec/support/test_reports/test_reports_helper.rb
index 45c6e04dbf3..7478be2904e 100644
--- a/spec/support/test_reports/test_reports_helper.rb
+++ b/spec/support/test_reports/test_reports_helper.rb
@@ -1,39 +1,43 @@
module TestReportsHelper
def create_test_case_rspec_success
Gitlab::Ci::Reports::TestCase.new(
- name: 'Test#sum when a is 1 and b is 3 returns summary',
- classname: 'spec.test_spec',
- file: './spec/test_spec.rb',
+ name: "Test#sum when a is 1 and b is 3 returns summary",
+ classname: "spec.test_spec",
+ file: "./spec/test_spec.rb",
execution_time: 1.11,
- status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS
+ )
end
def create_test_case_rspec_failed
Gitlab::Ci::Reports::TestCase.new(
- name: 'Test#sum when a is 2 and b is 2 returns summary',
- classname: 'spec.test_spec',
- file: './spec/test_spec.rb',
+ name: "Test#sum when a is 2 and b is 2 returns summary",
+ classname: "spec.test_spec",
+ file: "./spec/test_spec.rb",
execution_time: 2.22,
system_output: sample_rspec_failed_message,
- status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED
+ )
end
def create_test_case_rspec_skipped
Gitlab::Ci::Reports::TestCase.new(
- name: 'Test#sum when a is 3 and b is 3 returns summary',
- classname: 'spec.test_spec',
- file: './spec/test_spec.rb',
+ name: "Test#sum when a is 3 and b is 3 returns summary",
+ classname: "spec.test_spec",
+ file: "./spec/test_spec.rb",
execution_time: 3.33,
- status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED
+ )
end
def create_test_case_rspec_error
Gitlab::Ci::Reports::TestCase.new(
- name: 'Test#sum when a is 4 and b is 4 returns summary',
- classname: 'spec.test_spec',
- file: './spec/test_spec.rb',
+ name: "Test#sum when a is 4 and b is 4 returns summary",
+ classname: "spec.test_spec",
+ file: "./spec/test_spec.rb",
execution_time: 4.44,
- status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR
+ )
end
def sample_rspec_failed_message
@@ -50,35 +54,39 @@ module TestReportsHelper
def create_test_case_java_success
Gitlab::Ci::Reports::TestCase.new(
- name: 'addTest',
- classname: 'CalculatorTest',
+ name: "addTest",
+ classname: "CalculatorTest",
execution_time: 5.55,
- status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_SUCCESS
+ )
end
def create_test_case_java_failed
Gitlab::Ci::Reports::TestCase.new(
- name: 'subtractTest',
- classname: 'CalculatorTest',
+ name: "subtractTest",
+ classname: "CalculatorTest",
execution_time: 6.66,
system_output: sample_java_failed_message,
- status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_FAILED
+ )
end
def create_test_case_java_skipped
Gitlab::Ci::Reports::TestCase.new(
- name: 'multiplyTest',
- classname: 'CalculatorTest',
+ name: "multiplyTest",
+ classname: "CalculatorTest",
execution_time: 7.77,
- status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_SKIPPED
+ )
end
def create_test_case_java_error
Gitlab::Ci::Reports::TestCase.new(
- name: 'divideTest',
- classname: 'CalculatorTest',
+ name: "divideTest",
+ classname: "CalculatorTest",
execution_time: 8.88,
- status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR)
+ status: Gitlab::Ci::Reports::TestCase::STATUS_ERROR
+ )
end
def sample_java_failed_message
diff --git a/spec/support/trace/trace_helpers.rb b/spec/support/trace/trace_helpers.rb
index c7802bbcb94..2b0bea8a092 100644
--- a/spec/support/trace/trace_helpers.rb
+++ b/spec/support/trace/trace_helpers.rb
@@ -1,6 +1,6 @@
module TraceHelpers
def create_legacy_trace(build, content)
- File.open(legacy_trace_path(build), 'wb') { |stream| stream.write(content) }
+ File.open(legacy_trace_path(build), "wb") { |stream| stream.write(content) }
end
def create_legacy_trace_in_db(build, content)
@@ -19,9 +19,9 @@ module TraceHelpers
def archived_trace_path(job_artifact)
disk_hash = Digest::SHA2.hexdigest(job_artifact.project_id.to_s)
- creation_date = job_artifact.created_at.utc.strftime('%Y_%m_%d')
+ creation_date = job_artifact.created_at.utc.strftime("%Y_%m_%d")
File.join(Gitlab.config.artifacts.path, disk_hash[0..1], disk_hash[2..3], disk_hash,
- creation_date, job_artifact.job_id.to_s, job_artifact.id.to_s, 'job.log')
+ creation_date, job_artifact.job_id.to_s, job_artifact.id.to_s, "job.log")
end
end
diff --git a/spec/support/unpack-gitlab-git-test b/spec/support/unpack-gitlab-git-test
index d5b4912457d..38243f9ae21 100755
--- a/spec/support/unpack-gitlab-git-test
+++ b/spec/support/unpack-gitlab-git-test
@@ -1,36 +1,36 @@
#!/usr/bin/env ruby
-require 'fileutils'
+require "fileutils"
-REPO = 'spec/support/gitlab-git-test.git'.freeze
-PACK_DIR = REPO + '/objects/pack'
+REPO = "spec/support/gitlab-git-test.git".freeze
+PACK_DIR = REPO + "/objects/pack"
GIT = %W[git --git-dir=#{REPO}].freeze
-BASE_PACK = 'pack-691247af2a6acb0b63b73ac0cb90540e93614043'.freeze
+BASE_PACK = "pack-691247af2a6acb0b63b73ac0cb90540e93614043".freeze
def main
unpack
# We want to store the refs in a packed-refs file because if we don't
# they can get mangled by filesystems.
- abort unless system(*GIT, *%w[pack-refs --all])
- abort unless system(*GIT, 'fsck')
+ abort unless system(*GIT, "pack-refs", "--all")
+ abort unless system(*GIT, "fsck")
end
# We don't want contributors to commit new pack files because those
# create unnecessary churn.
def unpack
- pack_files = Dir[File.join(PACK_DIR, '*')].reject do |pack|
+ pack_files = Dir[File.join(PACK_DIR, "*")].reject { |pack|
pack.start_with?(File.join(PACK_DIR, BASE_PACK))
- end
+ }
return if pack_files.empty?
pack_files.each do |pack|
- unless pack.end_with?('.pack')
+ unless pack.end_with?(".pack")
FileUtils.rm(pack)
next
end
- File.open(pack, 'rb') do |open_pack|
+ File.open(pack, "rb") do |open_pack|
File.unlink(pack)
- abort unless system(*GIT, 'unpack-objects', in: open_pack)
+ abort unless system(*GIT, "unpack-objects", in: open_pack)
end
end
end
diff --git a/spec/support/webmock.rb b/spec/support/webmock.rb
index af2906b7568..2c144b646d1 100644
--- a/spec/support/webmock.rb
+++ b/spec/support/webmock.rb
@@ -1,4 +1,4 @@
-require 'webmock'
-require 'webmock/rspec'
+require "webmock"
+require "webmock/rspec"
WebMock.disable_net_connect!(allow_localhost: true)
diff --git a/spec/tasks/cache/clear/redis_spec.rb b/spec/tasks/cache/clear/redis_spec.rb
index 97c8c943f3a..92aee829578 100644
--- a/spec/tasks/cache/clear/redis_spec.rb
+++ b/spec/tasks/cache/clear/redis_spec.rb
@@ -1,11 +1,11 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'clearing redis cache' do
+describe "clearing redis cache" do
before do
- Rake.application.rake_require 'tasks/cache'
+ Rake.application.rake_require "tasks/cache"
end
- describe 'clearing pipeline status cache' do
+ describe "clearing pipeline status cache" do
let(:pipeline_status) do
project = create(:project, :repository)
create(:ci_pipeline, project: project).project.pipeline_status
@@ -15,8 +15,8 @@ describe 'clearing redis cache' do
allow(pipeline_status).to receive(:loaded).and_return(nil)
end
- it 'clears pipeline status cache' do
- expect { run_rake_task('cache:clear:redis') }.to change { pipeline_status.has_cache? }
+ it "clears pipeline status cache" do
+ expect { run_rake_task("cache:clear:redis") }.to change { pipeline_status.has_cache? }
end
end
end
diff --git a/spec/tasks/config_lint_spec.rb b/spec/tasks/config_lint_spec.rb
index 83d54259dfa..d188fd63dc2 100644
--- a/spec/tasks/config_lint_spec.rb
+++ b/spec/tasks/config_lint_spec.rb
@@ -1,27 +1,27 @@
-require 'rake_helper'
-Rake.application.rake_require 'tasks/config_lint'
+require "rake_helper"
+Rake.application.rake_require "tasks/config_lint"
describe ConfigLint do
- let(:files) { ['lib/support/fake.sh'] }
+ let(:files) { ["lib/support/fake.sh"] }
- it 'errors out if any bash scripts have errors' do
- expect { described_class.run(files) { system('exit 1') } }.to raise_error(SystemExit)
+ it "errors out if any bash scripts have errors" do
+ expect { described_class.run(files) { system("exit 1") } }.to raise_error(SystemExit)
end
- it 'passes if all scripts are fine' do
- expect { described_class.run(files) { system('exit 0') } }.not_to raise_error
+ it "passes if all scripts are fine" do
+ expect { described_class.run(files) { system("exit 0") } }.not_to raise_error
end
end
-describe 'config_lint rake task' do
+describe "config_lint rake task" do
before do
# Prevent `system` from actually being called
allow(Kernel).to receive(:system).and_return(true)
end
- it 'runs lint on shell scripts' do
- expect(Kernel).to receive(:system).with('bash', '-n', 'lib/support/init.d/gitlab')
+ it "runs lint on shell scripts" do
+ expect(Kernel).to receive(:system).with("bash", "-n", "lib/support/init.d/gitlab")
- run_rake_task('config_lint')
+ run_rake_task("config_lint")
end
end
diff --git a/spec/tasks/gitlab/artifacts/check_rake_spec.rb b/spec/tasks/gitlab/artifacts/check_rake_spec.rb
index d495b08aca0..4b7e5366266 100644
--- a/spec/tasks/gitlab/artifacts/check_rake_spec.rb
+++ b/spec/tasks/gitlab/artifacts/check_rake_spec.rb
@@ -1,34 +1,34 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:artifacts rake tasks' do
- describe 'check' do
+describe "gitlab:artifacts rake tasks" do
+ describe "check" do
let!(:artifact) { create(:ci_job_artifact, :archive, :correct_checksum) }
before do
- Rake.application.rake_require('tasks/gitlab/artifacts/check')
- stub_env('VERBOSE' => 'true')
+ Rake.application.rake_require("tasks/gitlab/artifacts/check")
+ stub_env("VERBOSE" => "true")
end
- it 'outputs the integrity check for each batch' do
- expect { run_rake_task('gitlab:artifacts:check') }.to output(/Failures: 0/).to_stdout
+ it "outputs the integrity check for each batch" do
+ expect { run_rake_task("gitlab:artifacts:check") }.to output(/Failures: 0/).to_stdout
end
- it 'errors out about missing files on the file system' do
+ it "errors out about missing files on the file system" do
FileUtils.rm_f(artifact.file.path)
- expect { run_rake_task('gitlab:artifacts:check') }.to output(/No such file.*#{Regexp.quote(artifact.file.path)}/).to_stdout
+ expect { run_rake_task("gitlab:artifacts:check") }.to output(/No such file.*#{Regexp.quote(artifact.file.path)}/).to_stdout
end
- it 'errors out about invalid checksum' do
- artifact.update_column(:file_sha256, 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855')
+ it "errors out about invalid checksum" do
+ artifact.update_column(:file_sha256, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
- expect { run_rake_task('gitlab:artifacts:check') }.to output(/Checksum mismatch/).to_stdout
+ expect { run_rake_task("gitlab:artifacts:check") }.to output(/Checksum mismatch/).to_stdout
end
- it 'errors out about missing checksum' do
+ it "errors out about missing checksum" do
artifact.update_column(:file_sha256, nil)
- expect { run_rake_task('gitlab:artifacts:check') }.to output(/Checksum missing/).to_stdout
+ expect { run_rake_task("gitlab:artifacts:check") }.to output(/Checksum missing/).to_stdout
end
end
end
diff --git a/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb b/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb
index 8544fb62b5a..1733d5a3861 100644
--- a/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb
+++ b/spec/tasks/gitlab/artifacts/migrate_rake_spec.rb
@@ -1,8 +1,8 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:artifacts namespace rake task' do
+describe "gitlab:artifacts namespace rake task" do
before(:context) do
- Rake.application.rake_require 'tasks/gitlab/artifacts/migrate'
+ Rake.application.rake_require "tasks/gitlab/artifacts/migrate"
end
let(:object_storage_enabled) { false }
@@ -11,16 +11,16 @@ describe 'gitlab:artifacts namespace rake task' do
stub_artifacts_object_storage(enabled: object_storage_enabled)
end
- subject { run_rake_task('gitlab:artifacts:migrate') }
+ subject { run_rake_task("gitlab:artifacts:migrate") }
- context 'legacy artifacts' do
- describe 'migrate' do
+ context "legacy artifacts" do
+ describe "migrate" do
let!(:build) { create(:ci_build, :legacy_artifacts, artifacts_file_store: store, artifacts_metadata_store: store) }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { ObjectStorage::Store::LOCAL }
- context 'and job does not have file store defined' do
+ context "and job does not have file store defined" do
let(:object_storage_enabled) { true }
let(:store) { nil }
@@ -32,7 +32,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
let(:object_storage_enabled) { true }
it "migrates file to remote storage" do
@@ -43,7 +43,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'and remote storage is not defined' do
+ context "and remote storage is not defined" do
it "fails to migrate to remote storage" do
subject
@@ -53,7 +53,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'when remote storage is used' do
+ context "when remote storage is used" do
let(:object_storage_enabled) { true }
let(:store) { ObjectStorage::Store::REMOTE }
@@ -68,13 +68,13 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'job artifacts' do
+ context "job artifacts" do
let!(:artifact) { create(:ci_job_artifact, :archive, file_store: store) }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { ObjectStorage::Store::LOCAL }
- context 'and job does not have file store defined' do
+ context "and job does not have file store defined" do
let(:object_storage_enabled) { true }
let(:store) { nil }
@@ -85,7 +85,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
let(:object_storage_enabled) { true }
it "migrates file to remote storage" do
@@ -95,7 +95,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'and remote storage is not defined' do
+ context "and remote storage is not defined" do
it "fails to migrate to remote storage" do
subject
@@ -104,7 +104,7 @@ describe 'gitlab:artifacts namespace rake task' do
end
end
- context 'when remote storage is used' do
+ context "when remote storage is used" do
let(:object_storage_enabled) { true }
let(:store) { ObjectStorage::Store::REMOTE }
diff --git a/spec/tasks/gitlab/backup_rake_spec.rb b/spec/tasks/gitlab/backup_rake_spec.rb
index a8fae4a88a3..b3d2deb7b06 100644
--- a/spec/tasks/gitlab/backup_rake_spec.rb
+++ b/spec/tasks/gitlab/backup_rake_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'rake'
+require "spec_helper"
+require "rake"
-describe 'gitlab:app namespace rake task' do
+describe "gitlab:app namespace rake task" do
let(:enable_registry) { true }
def tars_glob
- Dir.glob(File.join(Gitlab.config.backup.path, '*_gitlab_backup.tar'))
+ Dir.glob(File.join(Gitlab.config.backup.path, "*_gitlab_backup.tar"))
end
def backup_tar
@@ -13,21 +13,21 @@ describe 'gitlab:app namespace rake task' do
end
before(:all) do
- Rake.application.rake_require 'tasks/gitlab/helpers'
- Rake.application.rake_require 'tasks/gitlab/backup'
- Rake.application.rake_require 'tasks/gitlab/shell'
- Rake.application.rake_require 'tasks/gitlab/db'
- Rake.application.rake_require 'tasks/cache'
+ Rake.application.rake_require "tasks/gitlab/helpers"
+ Rake.application.rake_require "tasks/gitlab/backup"
+ Rake.application.rake_require "tasks/gitlab/shell"
+ Rake.application.rake_require "tasks/gitlab/db"
+ Rake.application.rake_require "tasks/cache"
# empty task as env is already loaded
Rake::Task.define_task :environment
# We need this directory to run `gitlab:backup:create` task
- FileUtils.mkdir_p('public/uploads')
+ FileUtils.mkdir_p("public/uploads")
end
before do
- stub_env('force', 'yes')
+ stub_env("force", "yes")
FileUtils.rm(tars_glob, force: true)
reenable_backup_sub_tasks
stub_container_registry_config(enabled: enable_registry)
@@ -43,15 +43,15 @@ describe 'gitlab:app namespace rake task' do
end
def reenable_backup_sub_tasks
- %w{db repo uploads builds artifacts pages lfs registry}.each do |subtask|
+ %w[db repo uploads builds artifacts pages lfs registry].each do |subtask|
Rake::Task["gitlab:backup:#{subtask}:create"].reenable
end
end
- describe 'backup_restore' do
- context 'gitlab version' do
+ describe "backup_restore" do
+ context "gitlab version" do
before do
- allow(Dir).to receive(:glob).and_return(['1_gitlab_backup.tar'])
+ allow(Dir).to receive(:glob).and_return(["1_gitlab_backup.tar"])
allow(File).to receive(:exist?).and_return(true)
allow(Kernel).to receive(:system).and_return(true)
allow(FileUtils).to receive(:cp_r).and_return(true)
@@ -62,53 +62,53 @@ describe 'gitlab:app namespace rake task' do
let(:gitlab_version) { Gitlab::VERSION }
- it 'fails on mismatch' do
+ it "fails on mismatch" do
allow(YAML).to receive(:load_file)
- .and_return({ gitlab_version: "not #{gitlab_version}" })
+ .and_return({gitlab_version: "not #{gitlab_version}"})
- expect do
- expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
- end.to raise_error(SystemExit)
+ expect {
+ expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
+ }.to raise_error(SystemExit)
end
- context 'restore with matching gitlab version' do
+ context "restore with matching gitlab version" do
before do
allow(YAML).to receive(:load_file)
- .and_return({ gitlab_version: gitlab_version })
- expect(Rake::Task['gitlab:db:drop_tables']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:db:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:repo:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:builds:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:uploads:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:pages:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:lfs:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:backup:registry:restore']).to receive(:invoke)
- expect(Rake::Task['gitlab:shell:setup']).to receive(:invoke)
+ .and_return({gitlab_version: gitlab_version})
+ expect(Rake::Task["gitlab:db:drop_tables"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:db:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:repo:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:builds:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:uploads:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:artifacts:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:pages:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:lfs:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:backup:registry:restore"]).to receive(:invoke)
+ expect(Rake::Task["gitlab:shell:setup"]).to receive(:invoke)
end
- it 'invokes restoration on match' do
- expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
+ it "invokes restoration on match" do
+ expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
end
- it 'prints timestamps on messages' do
- expect { run_rake_task('gitlab:backup:restore') }.to output(/.*\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s[-+]\d{4}\s--\s.*/).to_stdout
+ it "prints timestamps on messages" do
+ expect { run_rake_task("gitlab:backup:restore") }.to output(/.*\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2}\s[-+]\d{4}\s--\s.*/).to_stdout
end
end
end
- context 'when the restore directory is not empty' do
+ context "when the restore directory is not empty" do
before do
# We only need a backup of the repositories for this test
- stub_env('SKIP', 'db,uploads,builds,artifacts,lfs,registry')
+ stub_env("SKIP", "db,uploads,builds,artifacts,lfs,registry")
end
- it 'removes stale data' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "removes stale data" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
- excluded_project = create(:project, :repository, name: 'mepmep')
+ excluded_project = create(:project, :repository, name: "mepmep")
- expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
+ expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
raw_repo = excluded_project.repository.raw
@@ -119,30 +119,30 @@ describe 'gitlab:app namespace rake task' do
end
end # backup_restore task
- describe 'backup' do
+ describe "backup" do
before do
# This reconnect makes our project fixture disappear, breaking the restore. Stub it out.
allow(ActiveRecord::Base.connection).to receive(:reconnect!)
end
- describe 'backup creation and deletion using custom_hooks' do
+ describe "backup creation and deletion using custom_hooks" do
let(:project) { create(:project, :repository) }
let(:user_backup_path) { "repositories/#{project.disk_path}" }
before do
- stub_env('SKIP', 'db')
- path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
- File.join(project.repository.path_to_repo, 'custom_hooks')
- end
+ stub_env("SKIP", "db")
+ path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
+ File.join(project.repository.path_to_repo, "custom_hooks")
+ }
FileUtils.mkdir_p(path)
FileUtils.touch(File.join(path, "dummy.txt"))
end
- context 'project uses custom_hooks and successfully creates backup' do
- it 'creates custom_hooks.tar and project bundle' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ context "project uses custom_hooks and successfully creates backup" do
+ it "creates custom_hooks.tar and project bundle" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
- tar_contents, exit_status = Gitlab::Popen.popen(%W{tar -tvf #{backup_tar}})
+ tar_contents, exit_status = Gitlab::Popen.popen(%W[tar -tvf #{backup_tar}])
expect(exit_status).to eq(0)
expect(tar_contents).to match(user_backup_path)
@@ -150,21 +150,21 @@ describe 'gitlab:app namespace rake task' do
expect(tar_contents).to match("#{user_backup_path}.bundle")
end
- it 'restores files correctly' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
- expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
+ it "restores files correctly" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
+ expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
- repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
project.repository.path
- end
- expect(Dir.entries(File.join(repo_path, 'custom_hooks'))).to include("dummy.txt")
+ }
+ expect(Dir.entries(File.join(repo_path, "custom_hooks"))).to include("dummy.txt")
end
end
- context 'specific backup tasks' do
- let(:task_list) { %w(db repo uploads builds artifacts pages lfs registry) }
+ context "specific backup tasks" do
+ let(:task_list) { %w[db repo uploads builds artifacts pages lfs registry] }
- it 'prints a progress message to stdout' do
+ it "prints a progress message to stdout" do
task_list.each do |task|
expect { run_rake_task("gitlab:backup:#{task}:create") }.to output(/Dumping /).to_stdout
end
@@ -172,81 +172,81 @@ describe 'gitlab:app namespace rake task' do
end
end
- context 'tar creation' do
- context 'archive file permissions' do
- it 'sets correct permissions on the tar file' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ context "tar creation" do
+ context "archive file permissions" do
+ it "sets correct permissions on the tar file" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
expect(File.exist?(backup_tar)).to be_truthy
- expect(File::Stat.new(backup_tar).mode.to_s(8)).to eq('100600')
+ expect(File::Stat.new(backup_tar).mode.to_s(8)).to eq("100600")
end
- context 'with custom archive_permissions' do
+ context "with custom archive_permissions" do
before do
- allow(Gitlab.config.backup).to receive(:archive_permissions).and_return(0651)
+ allow(Gitlab.config.backup).to receive(:archive_permissions).and_return(0o651)
end
- it 'uses the custom permissions' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "uses the custom permissions" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
- expect(File::Stat.new(backup_tar).mode.to_s(8)).to eq('100651')
+ expect(File::Stat.new(backup_tar).mode.to_s(8)).to eq("100651")
end
end
end
- it 'sets correct permissions on the tar contents' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "sets correct permissions on the tar contents" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
tar_contents, exit_status = Gitlab::Popen.popen(
- %W{tar -tvf #{backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz pages.tar.gz lfs.tar.gz registry.tar.gz}
+ %W[tar -tvf #{backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz pages.tar.gz lfs.tar.gz registry.tar.gz]
)
expect(exit_status).to eq(0)
- expect(tar_contents).to match('db/')
- expect(tar_contents).to match('uploads.tar.gz')
- expect(tar_contents).to match('repositories/')
- expect(tar_contents).to match('builds.tar.gz')
- expect(tar_contents).to match('artifacts.tar.gz')
- expect(tar_contents).to match('pages.tar.gz')
- expect(tar_contents).to match('lfs.tar.gz')
- expect(tar_contents).to match('registry.tar.gz')
+ expect(tar_contents).to match("db/")
+ expect(tar_contents).to match("uploads.tar.gz")
+ expect(tar_contents).to match("repositories/")
+ expect(tar_contents).to match("builds.tar.gz")
+ expect(tar_contents).to match("artifacts.tar.gz")
+ expect(tar_contents).to match("pages.tar.gz")
+ expect(tar_contents).to match("lfs.tar.gz")
+ expect(tar_contents).to match("registry.tar.gz")
expect(tar_contents).not_to match(%r{^.{4,9}[rwx].* (database.sql.gz|uploads.tar.gz|repositories|builds.tar.gz|pages.tar.gz|artifacts.tar.gz|registry.tar.gz)/$})
end
- it 'deletes temp directories' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "deletes temp directories" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
temp_dirs = Dir.glob(
- File.join(Gitlab.config.backup.path, '{db,repositories,uploads,builds,artifacts,pages,lfs,registry}')
+ File.join(Gitlab.config.backup.path, "{db,repositories,uploads,builds,artifacts,pages,lfs,registry}")
)
expect(temp_dirs).to be_empty
end
- context 'registry disabled' do
+ context "registry disabled" do
let(:enable_registry) { false }
- it 'does not create registry.tar.gz' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "does not create registry.tar.gz" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
tar_contents, exit_status = Gitlab::Popen.popen(
- %W{tar -tvf #{backup_tar}}
+ %W[tar -tvf #{backup_tar}]
)
expect(exit_status).to eq(0)
- expect(tar_contents).not_to match('registry.tar.gz')
+ expect(tar_contents).not_to match("registry.tar.gz")
end
end
end
- context 'multiple repository storages' do
+ context "multiple repository storages" do
let(:test_second_storage) do
- Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => 'tmp/tests/custom_storage'))
+ Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge("path" => "tmp/tests/custom_storage"))
end
let(:storages) do
{
- 'default' => Gitlab.config.repositories.storages.default,
- 'test_second_storage' => test_second_storage
+ "default" => Gitlab.config.repositories.storages.default,
+ "test_second_storage" => test_second_storage,
}
end
@@ -256,7 +256,7 @@ describe 'gitlab:app namespace rake task' do
before do
# We only need a backup of the repositories for this test
- stub_env('SKIP', 'db,uploads,builds,artifacts,lfs,registry')
+ stub_env("SKIP", "db,uploads,builds,artifacts,lfs,registry")
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
@@ -266,29 +266,29 @@ describe 'gitlab:app namespace rake task' do
end
after do
- FileUtils.rm_rf(Settings.absolute('tmp/tests/custom_storage'))
+ FileUtils.rm_rf(Settings.absolute("tmp/tests/custom_storage"))
end
- it 'includes repositories in all repository storages' do
+ it "includes repositories in all repository storages" do
project_a = create(:project, :repository)
- project_b = create(:project, :repository, repository_storage: 'test_second_storage')
+ project_b = create(:project, :repository, repository_storage: "test_second_storage")
- b_storage_dir = File.join(Settings.absolute('tmp/tests/custom_storage'), File.dirname(project_b.disk_path))
+ b_storage_dir = File.join(Settings.absolute("tmp/tests/custom_storage"), File.dirname(project_b.disk_path))
FileUtils.mkdir_p(b_storage_dir)
# Even when overriding the storage, we have to move it there, so it exists
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
FileUtils.mv(
- File.join(Settings.absolute(storages['default'].legacy_disk_path), project_b.repository.disk_path + '.git'),
- Rails.root.join(storages['test_second_storage'].legacy_disk_path, project_b.repository.disk_path + '.git')
+ File.join(Settings.absolute(storages["default"].legacy_disk_path), project_b.repository.disk_path + ".git"),
+ Rails.root.join(storages["test_second_storage"].legacy_disk_path, project_b.repository.disk_path + ".git")
)
end
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
tar_contents, exit_status = Gitlab::Popen.popen(
- %W{tar -tvf #{backup_tar} repositories}
+ %W[tar -tvf #{backup_tar} repositories]
)
expect(exit_status).to eq(0)
@@ -300,49 +300,49 @@ describe 'gitlab:app namespace rake task' do
describe "Skipping items" do
before do
- stub_env('SKIP', 'repositories,uploads')
+ stub_env("SKIP", "repositories,uploads")
end
it "does not contain skipped item" do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
tar_contents, _exit_status = Gitlab::Popen.popen(
- %W{tar -tvf #{backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz pages.tar.gz lfs.tar.gz registry.tar.gz}
+ %W[tar -tvf #{backup_tar} db uploads.tar.gz repositories builds.tar.gz artifacts.tar.gz pages.tar.gz lfs.tar.gz registry.tar.gz]
)
- expect(tar_contents).to match('db/')
- expect(tar_contents).to match('uploads.tar.gz')
- expect(tar_contents).to match('builds.tar.gz')
- expect(tar_contents).to match('artifacts.tar.gz')
- expect(tar_contents).to match('lfs.tar.gz')
- expect(tar_contents).to match('pages.tar.gz')
- expect(tar_contents).to match('registry.tar.gz')
- expect(tar_contents).not_to match('repositories/')
+ expect(tar_contents).to match("db/")
+ expect(tar_contents).to match("uploads.tar.gz")
+ expect(tar_contents).to match("builds.tar.gz")
+ expect(tar_contents).to match("artifacts.tar.gz")
+ expect(tar_contents).to match("lfs.tar.gz")
+ expect(tar_contents).to match("pages.tar.gz")
+ expect(tar_contents).to match("registry.tar.gz")
+ expect(tar_contents).not_to match("repositories/")
end
- it 'does not invoke repositories restore' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "does not invoke repositories restore" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
- allow(Rake::Task['gitlab:shell:setup'])
+ allow(Rake::Task["gitlab:shell:setup"])
.to receive(:invoke).and_return(true)
- expect(Rake::Task['gitlab:db:drop_tables']).to receive :invoke
- expect(Rake::Task['gitlab:backup:db:restore']).to receive :invoke
- expect(Rake::Task['gitlab:backup:repo:restore']).not_to receive :invoke
- expect(Rake::Task['gitlab:backup:uploads:restore']).not_to receive :invoke
- expect(Rake::Task['gitlab:backup:builds:restore']).to receive :invoke
- expect(Rake::Task['gitlab:backup:artifacts:restore']).to receive :invoke
- expect(Rake::Task['gitlab:backup:pages:restore']).to receive :invoke
- expect(Rake::Task['gitlab:backup:lfs:restore']).to receive :invoke
- expect(Rake::Task['gitlab:backup:registry:restore']).to receive :invoke
- expect(Rake::Task['gitlab:shell:setup']).to receive :invoke
- expect { run_rake_task('gitlab:backup:restore') }.to output.to_stdout
+ expect(Rake::Task["gitlab:db:drop_tables"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:db:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:repo:restore"]).not_to receive :invoke
+ expect(Rake::Task["gitlab:backup:uploads:restore"]).not_to receive :invoke
+ expect(Rake::Task["gitlab:backup:builds:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:artifacts:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:pages:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:lfs:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:backup:registry:restore"]).to receive :invoke
+ expect(Rake::Task["gitlab:shell:setup"]).to receive :invoke
+ expect { run_rake_task("gitlab:backup:restore") }.to output.to_stdout
end
end
describe "Human Readable Backup Name" do
- it 'name has human readable time' do
- expect { run_rake_task('gitlab:backup:create') }.to output.to_stdout
+ it "name has human readable time" do
+ expect { run_rake_task("gitlab:backup:create") }.to output.to_stdout
expect(backup_tar).to match(/\d+_\d{4}_\d{2}_\d{2}_\d+\.\d+\.\d+.*_gitlab_backup.tar$/)
end
diff --git a/spec/tasks/gitlab/check_rake_spec.rb b/spec/tasks/gitlab/check_rake_spec.rb
index 06525e3c771..cac581ad138 100644
--- a/spec/tasks/gitlab/check_rake_spec.rb
+++ b/spec/tasks/gitlab/check_rake_spec.rb
@@ -1,65 +1,65 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'check.rake' do
+describe "check.rake" do
before do
- Rake.application.rake_require 'tasks/gitlab/check'
+ Rake.application.rake_require "tasks/gitlab/check"
stub_warn_user_is_not_gitlab
end
- shared_examples_for 'system check rake task' do
- it 'runs the check' do
- expect do
+ shared_examples_for "system check rake task" do
+ it "runs the check" do
+ expect {
subject
- end.to output(/Checking #{name} ... Finished/).to_stdout
+ }.to output(/Checking #{name} ... Finished/).to_stdout
end
end
- describe 'gitlab:check rake task' do
- subject { run_rake_task('gitlab:check') }
- let(:name) { 'GitLab subtasks' }
+ describe "gitlab:check rake task" do
+ subject { run_rake_task("gitlab:check") }
+ let(:name) { "GitLab subtasks" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
end
- describe 'gitlab:gitlab_shell:check rake task' do
- subject { run_rake_task('gitlab:gitlab_shell:check') }
- let(:name) { 'GitLab Shell' }
+ describe "gitlab:gitlab_shell:check rake task" do
+ subject { run_rake_task("gitlab:gitlab_shell:check") }
+ let(:name) { "GitLab Shell" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
end
- describe 'gitlab:gitaly:check rake task' do
- subject { run_rake_task('gitlab:gitaly:check') }
- let(:name) { 'Gitaly' }
+ describe "gitlab:gitaly:check rake task" do
+ subject { run_rake_task("gitlab:gitaly:check") }
+ let(:name) { "Gitaly" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
end
- describe 'gitlab:sidekiq:check rake task' do
- subject { run_rake_task('gitlab:sidekiq:check') }
- let(:name) { 'Sidekiq' }
+ describe "gitlab:sidekiq:check rake task" do
+ subject { run_rake_task("gitlab:sidekiq:check") }
+ let(:name) { "Sidekiq" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
end
- describe 'gitlab:incoming_email:check rake task' do
- subject { run_rake_task('gitlab:incoming_email:check') }
- let(:name) { 'Incoming Email' }
+ describe "gitlab:incoming_email:check rake task" do
+ subject { run_rake_task("gitlab:incoming_email:check") }
+ let(:name) { "Incoming Email" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
end
- describe 'gitlab:ldap:check rake task' do
+ describe "gitlab:ldap:check rake task" do
include LdapHelpers
- subject { run_rake_task('gitlab:ldap:check') }
- let(:name) { 'LDAP' }
+ subject { run_rake_task("gitlab:ldap:check") }
+ let(:name) { "LDAP" }
- it_behaves_like 'system check rake task'
+ it_behaves_like "system check rake task"
- context 'when LDAP is not enabled' do
- it 'does not attempt to bind or search for users' do
+ context "when LDAP is not enabled" do
+ it "does not attempt to bind or search for users" do
expect(Gitlab::Auth::LDAP::Config).not_to receive(:providers)
expect(Gitlab::Auth::LDAP::Adapter).not_to receive(:open)
@@ -67,21 +67,21 @@ describe 'check.rake' do
end
end
- context 'when LDAP is enabled' do
+ context "when LDAP is enabled" do
let(:ldap) { double(:ldap) }
- let(:adapter) { ldap_adapter('ldapmain', ldap) }
+ let(:adapter) { ldap_adapter("ldapmain", ldap) }
before do
allow(Gitlab::Auth::LDAP::Config)
.to receive_messages(
enabled?: true,
- providers: ['ldapmain']
+ providers: ["ldapmain"]
)
allow(Gitlab::Auth::LDAP::Adapter).to receive(:open).and_yield(adapter)
allow(adapter).to receive(:users).and_return([])
end
- it 'attempts to bind using credentials' do
+ it "attempts to bind using credentials" do
stub_ldap_config(has_auth?: true)
expect(ldap).to receive(:bind)
@@ -89,10 +89,10 @@ describe 'check.rake' do
subject
end
- it 'searches for 100 LDAP users' do
- stub_ldap_config(uid: 'uid')
+ it "searches for 100 LDAP users" do
+ stub_ldap_config(uid: "uid")
- expect(adapter).to receive(:users).with('uid', '*', 100)
+ expect(adapter).to receive(:users).with("uid", "*", 100)
subject
end
diff --git a/spec/tasks/gitlab/cleanup_rake_spec.rb b/spec/tasks/gitlab/cleanup_rake_spec.rb
index 19794227d9f..ebb0e4f8b08 100644
--- a/spec/tasks/gitlab/cleanup_rake_spec.rb
+++ b/spec/tasks/gitlab/cleanup_rake_spec.rb
@@ -1,16 +1,16 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:cleanup rake tasks' do
+describe "gitlab:cleanup rake tasks" do
before do
- Rake.application.rake_require 'tasks/gitlab/cleanup'
+ Rake.application.rake_require "tasks/gitlab/cleanup"
end
- describe 'cleanup namespaces and repos' do
+ describe "cleanup namespaces and repos" do
let(:gitlab_shell) { Gitlab::Shell.new }
let(:storage) { storages.keys.first }
let(:storages) do
{
- 'default' => Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge('path' => 'tmp/tests/default_storage'))
+ "default" => Gitlab::GitalyClient::StorageSettings.new(@default_storage_hash.merge("path" => "tmp/tests/default_storage")),
}
end
@@ -26,49 +26,49 @@ describe 'gitlab:cleanup rake tasks' do
Gitlab::GitalyClient::StorageService.new(storage).delete_all_repositories
end
- describe 'cleanup:repos' do
+ describe "cleanup:repos" do
before do
- gitlab_shell.add_namespace(storage, 'broken/project.git')
- gitlab_shell.add_namespace(storage, '@hashed/12/34/5678.git')
+ gitlab_shell.add_namespace(storage, "broken/project.git")
+ gitlab_shell.add_namespace(storage, "@hashed/12/34/5678.git")
end
- it 'moves it to an orphaned path' do
+ it "moves it to an orphaned path" do
now = Time.now
Timecop.freeze(now) do
- run_rake_task('gitlab:cleanup:repos')
+ run_rake_task("gitlab:cleanup:repos")
repo_list = Gitlab::GitalyClient::StorageService.new(storage).list_directories(depth: 0)
expect(repo_list.last).to include("broken+orphaned+#{now.to_i}")
end
end
- it 'ignores @hashed repos' do
- run_rake_task('gitlab:cleanup:repos')
+ it "ignores @hashed repos" do
+ run_rake_task("gitlab:cleanup:repos")
- expect(gitlab_shell.exists?(storage, '@hashed/12/34/5678.git')).to be(true)
+ expect(gitlab_shell.exists?(storage, "@hashed/12/34/5678.git")).to be(true)
end
end
- describe 'cleanup:dirs' do
- it 'removes missing namespaces' do
+ describe "cleanup:dirs" do
+ it "removes missing namespaces" do
gitlab_shell.add_namespace(storage, "namespace_1/project.git")
gitlab_shell.add_namespace(storage, "namespace_2/project.git")
- allow(Namespace).to receive(:pluck).and_return(['namespace_1'])
+ allow(Namespace).to receive(:pluck).and_return(["namespace_1"])
- stub_env('REMOVE', 'true')
- run_rake_task('gitlab:cleanup:dirs')
+ stub_env("REMOVE", "true")
+ run_rake_task("gitlab:cleanup:dirs")
- expect(gitlab_shell.exists?(storage, 'namespace_1')).to be(true)
- expect(gitlab_shell.exists?(storage, 'namespace_2')).to be(false)
+ expect(gitlab_shell.exists?(storage, "namespace_1")).to be(true)
+ expect(gitlab_shell.exists?(storage, "namespace_2")).to be(false)
end
- it 'ignores @hashed directory' do
- gitlab_shell.add_namespace(storage, '@hashed/12/34/5678.git')
+ it "ignores @hashed directory" do
+ gitlab_shell.add_namespace(storage, "@hashed/12/34/5678.git")
- run_rake_task('gitlab:cleanup:dirs')
+ run_rake_task("gitlab:cleanup:dirs")
- expect(gitlab_shell.exists?(storage, '@hashed/12/34/5678.git')).to be(true)
+ expect(gitlab_shell.exists?(storage, "@hashed/12/34/5678.git")).to be(true)
end
end
end
@@ -78,7 +78,7 @@ describe 'gitlab:cleanup rake tasks' do
#
# Additionally, this tests DRY_RUN env var values, and the extra line of
# output that says you can disable DRY_RUN if it's enabled.
- describe 'cleanup:project_uploads' do
+ describe "cleanup:project_uploads" do
let!(:logger) { double(:logger) }
before do
@@ -88,71 +88,71 @@ describe 'gitlab:cleanup rake tasks' do
allow(logger).to receive(:debug).at_least(1).times
end
- context 'with a fixable orphaned project upload file' do
+ context "with a fixable orphaned project upload file" do
let(:orphaned) { create(:upload, :issuable_upload, :with_file, model: build(:project, :legacy_storage)) }
let(:new_path) { orphaned.absolute_path }
- let(:path) { File.join(FileUploader.root, 'some', 'wrong', 'location', orphaned.path) }
+ let(:path) { File.join(FileUploader.root, "some", "wrong", "location", orphaned.path) }
before do
FileUtils.mkdir_p(File.dirname(path))
FileUtils.mv(new_path, path)
end
- context 'with DRY_RUN disabled' do
+ context "with DRY_RUN disabled" do
before do
- stub_env('DRY_RUN', 'false')
+ stub_env("DRY_RUN", "false")
end
- it 'moves the file to its proper location' do
- run_rake_task('gitlab:cleanup:project_uploads')
+ it "moves the file to its proper location" do
+ run_rake_task("gitlab:cleanup:project_uploads")
expect(File.exist?(path)).to be_falsey
expect(File.exist?(new_path)).to be_truthy
end
- it 'logs action as done' do
+ it "logs action as done" do
expect(logger).to receive(:info).with("Looking for orphaned project uploads to clean up...")
expect(logger).to receive(:info).with("Did fix #{path} -> #{new_path}")
- run_rake_task('gitlab:cleanup:project_uploads')
+ run_rake_task("gitlab:cleanup:project_uploads")
end
end
- shared_examples_for 'does not move the file' do
- it 'does not move the file' do
- run_rake_task('gitlab:cleanup:project_uploads')
+ shared_examples_for "does not move the file" do
+ it "does not move the file" do
+ run_rake_task("gitlab:cleanup:project_uploads")
expect(File.exist?(path)).to be_truthy
expect(File.exist?(new_path)).to be_falsey
end
- it 'logs action as able to be done' do
+ it "logs action as able to be done" do
expect(logger).to receive(:info).with("Looking for orphaned project uploads to clean up. Dry run...")
expect(logger).to receive(:info).with("Can fix #{path} -> #{new_path}")
expect(logger).to receive(:info).with(/To clean up these files run this command with DRY_RUN=false/)
- run_rake_task('gitlab:cleanup:project_uploads')
+ run_rake_task("gitlab:cleanup:project_uploads")
end
end
- context 'with DRY_RUN explicitly enabled' do
+ context "with DRY_RUN explicitly enabled" do
before do
- stub_env('DRY_RUN', 'true')
+ stub_env("DRY_RUN", "true")
end
- it_behaves_like 'does not move the file'
+ it_behaves_like "does not move the file"
end
- context 'with DRY_RUN set to an unknown value' do
+ context "with DRY_RUN set to an unknown value" do
before do
- stub_env('DRY_RUN', 'foo')
+ stub_env("DRY_RUN", "foo")
end
- it_behaves_like 'does not move the file'
+ it_behaves_like "does not move the file"
end
- context 'with DRY_RUN unset' do
- it_behaves_like 'does not move the file'
+ context "with DRY_RUN unset" do
+ it_behaves_like "does not move the file"
end
end
end
diff --git a/spec/tasks/gitlab/db_rake_spec.rb b/spec/tasks/gitlab/db_rake_spec.rb
index 5818892d56a..5dc8312266d 100644
--- a/spec/tasks/gitlab/db_rake_spec.rb
+++ b/spec/tasks/gitlab/db_rake_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
-require 'rake'
+require "spec_helper"
+require "rake"
-describe 'gitlab:db namespace rake task' do
+describe "gitlab:db namespace rake task" do
before :all do
- Rake.application.rake_require 'active_record/railties/databases'
- Rake.application.rake_require 'tasks/seed_fu'
- Rake.application.rake_require 'tasks/gitlab/db'
+ Rake.application.rake_require "active_record/railties/databases"
+ Rake.application.rake_require "tasks/seed_fu"
+ Rake.application.rake_require "tasks/gitlab/db"
# empty task as env is already loaded
Rake::Task.define_task :environment
@@ -13,85 +13,85 @@ describe 'gitlab:db namespace rake task' do
before do
# Stub out db tasks
- allow(Rake::Task['db:migrate']).to receive(:invoke).and_return(true)
- allow(Rake::Task['db:schema:load']).to receive(:invoke).and_return(true)
- allow(Rake::Task['db:seed_fu']).to receive(:invoke).and_return(true)
+ allow(Rake::Task["db:migrate"]).to receive(:invoke).and_return(true)
+ allow(Rake::Task["db:schema:load"]).to receive(:invoke).and_return(true)
+ allow(Rake::Task["db:seed_fu"]).to receive(:invoke).and_return(true)
end
- describe 'configure' do
- it 'invokes db:migrate when schema has already been loaded' do
+ describe "configure" do
+ it "invokes db:migrate when schema has already been loaded" do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return(%w[table1 table2])
- expect(Rake::Task['db:migrate']).to receive(:invoke)
- expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
- expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
+ expect(Rake::Task["db:migrate"]).to receive(:invoke)
+ expect(Rake::Task["db:schema:load"]).not_to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.not_to raise_error
end
- it 'invokes 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)
- expect(Rake::Task['db:migrate']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
+ expect(Rake::Task["db:schema:load"]).to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).to receive(:invoke)
+ expect(Rake::Task["db:migrate"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.not_to raise_error
end
- it 'invokes db:shema:load and db:seed_fu when there is only a single table present' do
- allow(ActiveRecord::Base.connection).to receive(:tables).and_return(['default'])
- expect(Rake::Task['db:schema:load']).to receive(:invoke)
- expect(Rake::Task['db:seed_fu']).to receive(:invoke)
- expect(Rake::Task['db:migrate']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
+ it "invokes db:shema:load and db:seed_fu when there is only a single table present" do
+ allow(ActiveRecord::Base.connection).to receive(:tables).and_return(["default"])
+ expect(Rake::Task["db:schema:load"]).to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).to receive(:invoke)
+ expect(Rake::Task["db:migrate"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.not_to raise_error
end
- 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)
- expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.to raise_error(RuntimeError, 'error')
+ 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)
+ expect(Rake::Task["db:seed_fu"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.to raise_error(RuntimeError, "error")
# unstub connection so that the database cleaner still works
allow(ActiveRecord::Base).to receive(:connection).and_call_original
end
- it 'does 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)
- expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
- expect(Rake::Task['db:migrate']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.to raise_error(RuntimeError, 'error')
+ allow(Rake::Task["db:schema:load"]).to receive(:invoke).and_raise(RuntimeError, "error")
+ expect(Rake::Task["db:schema:load"]).to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).not_to receive(:invoke)
+ expect(Rake::Task["db:migrate"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.to raise_error(RuntimeError, "error")
end
- context 'SKIP_POST_DEPLOYMENT_MIGRATIONS environment variable set' do
- let(:rails_paths) { { 'db' => ['db'], 'db/migrate' => ['db/migrate'] } }
+ context "SKIP_POST_DEPLOYMENT_MIGRATIONS environment variable set" do
+ let(:rails_paths) { {"db" => ["db"], "db/migrate" => ["db/migrate"]} }
before do
allow(ENV).to receive(:[]).and_call_original
- allow(ENV).to receive(:[]).with('SKIP_POST_DEPLOYMENT_MIGRATIONS').and_return true
+ allow(ENV).to receive(:[]).with("SKIP_POST_DEPLOYMENT_MIGRATIONS").and_return true
# Our environment has already been loaded, so we need to pretend like post_migrations were not
allow(Rails.application.config).to receive(:paths).and_return(rails_paths)
- allow(ActiveRecord::Migrator).to receive(:migrations_paths).and_return(rails_paths['db/migrate'].dup)
+ allow(ActiveRecord::Migrator).to receive(:migrations_paths).and_return(rails_paths["db/migrate"].dup)
end
- it 'adds post deployment migrations before schema load if the schema is not already loaded' do
+ it "adds post deployment migrations before schema load if the schema is not already loaded" do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return([])
expect(Gitlab::Database).to receive(:add_post_migrate_path_to_rails).and_call_original
- expect(Rake::Task['db:schema:load']).to receive(:invoke)
- expect(Rake::Task['db:seed_fu']).to receive(:invoke)
- expect(Rake::Task['db:migrate']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
- expect(rails_paths['db/migrate'].include?(File.join(Rails.root, 'db', 'post_migrate'))).to be(true)
+ expect(Rake::Task["db:schema:load"]).to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).to receive(:invoke)
+ expect(Rake::Task["db:migrate"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.not_to raise_error
+ expect(rails_paths["db/migrate"].include?(File.join(Rails.root, "db", "post_migrate"))).to be(true)
end
- it 'ignores post deployment migrations when schema has already been loaded' do
+ it "ignores post deployment migrations when schema has already been loaded" do
allow(ActiveRecord::Base.connection).to receive(:tables).and_return(%w[table1 table2])
- expect(Rake::Task['db:migrate']).to receive(:invoke)
+ expect(Rake::Task["db:migrate"]).to receive(:invoke)
expect(Gitlab::Database).not_to receive(:add_post_migrate_path_to_rails)
- expect(Rake::Task['db:schema:load']).not_to receive(:invoke)
- expect(Rake::Task['db:seed_fu']).not_to receive(:invoke)
- expect { run_rake_task('gitlab:db:configure') }.not_to raise_error
- expect(rails_paths['db/migrate'].include?(File.join(Rails.root, 'db', 'post_migrate'))).to be(false)
+ expect(Rake::Task["db:schema:load"]).not_to receive(:invoke)
+ expect(Rake::Task["db:seed_fu"]).not_to receive(:invoke)
+ expect { run_rake_task("gitlab:db:configure") }.not_to raise_error
+ expect(rails_paths["db/migrate"].include?(File.join(Rails.root, "db", "post_migrate"))).to be(false)
end
end
end
diff --git a/spec/tasks/gitlab/git_rake_spec.rb b/spec/tasks/gitlab/git_rake_spec.rb
index 57b006e1a39..8dae93e7b56 100644
--- a/spec/tasks/gitlab/git_rake_spec.rb
+++ b/spec/tasks/gitlab/git_rake_spec.rb
@@ -1,20 +1,20 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:git rake tasks' do
- let(:base_path) { 'tmp/tests/default_storage' }
+describe "gitlab:git rake tasks" do
+ let(:base_path) { "tmp/tests/default_storage" }
let!(:project) { create(:project, :repository) }
before do
- Rake.application.rake_require 'tasks/gitlab/git'
+ Rake.application.rake_require "tasks/gitlab/git"
allow_any_instance_of(String).to receive(:color) { |string, _color| string }
stub_warn_user_is_not_gitlab
end
- describe 'fsck' do
- it 'outputs the integrity check for a repo' do
- expect { run_rake_task('gitlab:git:fsck') }.to output(/Performed integrity check for/).to_stdout
+ describe "fsck" do
+ it "outputs the integrity check for a repo" do
+ expect { run_rake_task("gitlab:git:fsck") }.to output(/Performed integrity check for/).to_stdout
end
end
end
diff --git a/spec/tasks/gitlab/gitaly_rake_spec.rb b/spec/tasks/gitlab/gitaly_rake_spec.rb
index e6e4d9504d9..84d41d1cb9d 100644
--- a/spec/tasks/gitlab/gitaly_rake_spec.rb
+++ b/spec/tasks/gitlab/gitaly_rake_spec.rb
@@ -1,48 +1,48 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:gitaly namespace rake task' do
+describe "gitlab:gitaly namespace rake task" do
before :all do
- Rake.application.rake_require 'tasks/gitlab/gitaly'
+ Rake.application.rake_require "tasks/gitlab/gitaly"
end
- describe 'install' do
- let(:repo) { 'https://gitlab.com/gitlab-org/gitaly.git' }
- let(:clone_path) { Rails.root.join('tmp/tests/gitaly').to_s }
- let(:storage_path) { Rails.root.join('tmp/tests/repositories').to_s }
+ describe "install" do
+ let(:repo) { "https://gitlab.com/gitlab-org/gitaly.git" }
+ let(:clone_path) { Rails.root.join("tmp/tests/gitaly").to_s }
+ let(:storage_path) { Rails.root.join("tmp/tests/repositories").to_s }
let(:version) { File.read(Rails.root.join(Gitlab::GitalyClient::SERVER_VERSION_FILE)).chomp }
- subject { run_rake_task('gitlab:gitaly:install', clone_path, storage_path) }
+ subject { run_rake_task("gitlab:gitaly:install", clone_path, storage_path) }
- context 'no dir given' do
- it 'aborts and display a help message' do
+ context "no dir given" do
+ it "aborts and display a help message" do
# avoid writing task output to spec progress
allow($stderr).to receive :write
- expect { run_rake_task('gitlab:gitaly:install') }.to raise_error /Please specify the directory where you want to install gitaly and the path for the default storage/
+ expect { run_rake_task("gitlab:gitaly:install") }.to raise_error /Please specify the directory where you want to install gitaly and the path for the default storage/
end
end
- context 'no storage path given' do
- it 'aborts and display a help message' do
+ context "no storage path given" do
+ it "aborts and display a help message" do
allow($stderr).to receive :write
- expect { run_rake_task('gitlab:gitaly:install', clone_path) }.to raise_error /Please specify the directory where you want to install gitaly and the path for the default storage/
+ expect { run_rake_task("gitlab:gitaly:install", clone_path) }.to raise_error /Please specify the directory where you want to install gitaly and the path for the default storage/
end
end
- context 'when an underlying Git command fail' do
- it 'aborts and display a help message' do
+ context "when an underlying Git command fail" do
+ it "aborts and display a help message" do
expect(main_object)
- .to receive(:checkout_or_clone_version).and_raise 'Git error'
+ .to receive(:checkout_or_clone_version).and_raise "Git error"
- expect { subject }.to raise_error 'Git error'
+ expect { subject }.to raise_error "Git error"
end
end
- describe 'checkout or clone' do
+ describe "checkout or clone" do
before do
expect(Dir).to receive(:chdir).with(clone_path)
end
- it 'calls checkout_or_clone_version with the right arguments' do
+ it "calls checkout_or_clone_version with the right arguments" do
expect(main_object)
.to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path)
@@ -50,42 +50,42 @@ describe 'gitlab:gitaly namespace rake task' do
end
end
- describe 'gmake/make' do
+ describe "gmake/make" do
let(:command_preamble) { %w[/usr/bin/env -u RUBYOPT -u BUNDLE_GEMFILE] }
before do
- stub_env('CI', false)
+ stub_env("CI", false)
FileUtils.mkdir_p(clone_path)
expect(Dir).to receive(:chdir).with(clone_path).and_call_original
allow(Rails.env).to receive(:test?).and_return(false)
end
- context 'gmake is available' do
+ context "gmake is available" do
before do
expect(main_object).to receive(:checkout_or_clone_version)
end
- it 'calls gmake in the gitaly directory' do
- expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0])
+ it "calls gmake in the gitaly directory" do
+ expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(["/usr/bin/gmake", 0])
expect(main_object).to receive(:run_command!).with(command_preamble + %w[gmake]).and_return(true)
subject
end
end
- context 'gmake is not available' do
+ context "gmake is not available" do
before do
expect(main_object).to receive(:checkout_or_clone_version)
- expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['', 42])
+ expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(["", 42])
end
- it 'calls make in the gitaly directory' do
+ it "calls make in the gitaly directory" do
expect(main_object).to receive(:run_command!).with(command_preamble + %w[make]).and_return(true)
subject
end
- context 'when Rails.env is test' do
+ context "when Rails.env is test" do
let(:command) do
%W[make
BUNDLE_FLAGS=--no-deployment
@@ -96,7 +96,7 @@ describe 'gitlab:gitaly namespace rake task' do
allow(Rails.env).to receive(:test?).and_return(true)
end
- it 'calls make in the gitaly directory with --no-deployment flag for bundle' do
+ it "calls make in the gitaly directory with --no-deployment flag for bundle" do
expect(main_object).to receive(:run_command!).with(command_preamble + command).and_return(true)
subject
diff --git a/spec/tasks/gitlab/info_rake_spec.rb b/spec/tasks/gitlab/info_rake_spec.rb
index ca74378a12a..cd7ddfa2b76 100644
--- a/spec/tasks/gitlab/info_rake_spec.rb
+++ b/spec/tasks/gitlab/info_rake_spec.rb
@@ -1,34 +1,34 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:env:info' do
+describe "gitlab:env:info" do
before do
- Rake.application.rake_require 'tasks/gitlab/info'
+ Rake.application.rake_require "tasks/gitlab/info"
stub_warn_user_is_not_gitlab
allow(Gitlab::Popen).to receive(:popen)
end
- describe 'git version' do
+ describe "git version" do
before do
- allow(Gitlab::Popen).to receive(:popen).with([Gitlab.config.git.bin_path, '--version'])
+ allow(Gitlab::Popen).to receive(:popen).with([Gitlab.config.git.bin_path, "--version"])
.and_return(git_version)
end
- context 'when git installed' do
- let(:git_version) { 'git version 2.10.0' }
+ context "when git installed" do
+ let(:git_version) { "git version 2.10.0" }
- it 'prints git version' do
- run_rake_task('gitlab:env:info')
+ it "prints git version" do
+ run_rake_task("gitlab:env:info")
expect($stdout.string).to match(/Git Version:(.*)2.10.0/)
end
end
- context 'when git not installed' do
- let(:git_version) { '' }
+ context "when git not installed" do
+ let(:git_version) { "" }
- it 'prints unknown' do
- run_rake_task('gitlab:env:info')
+ it "prints unknown" do
+ run_rake_task("gitlab:env:info")
expect($stdout.string).to match(/Git Version:(.*)unknown/)
end
diff --git a/spec/tasks/gitlab/ldap_rake_spec.rb b/spec/tasks/gitlab/ldap_rake_spec.rb
index 279234f2887..0da4f391bb6 100644
--- a/spec/tasks/gitlab/ldap_rake_spec.rb
+++ b/spec/tasks/gitlab/ldap_rake_spec.rb
@@ -1,13 +1,13 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:ldap:rename_provider rake task' do
- it 'completes without error' do
- Rake.application.rake_require 'tasks/gitlab/ldap'
+describe "gitlab:ldap:rename_provider rake task" do
+ it "completes without error" do
+ Rake.application.rake_require "tasks/gitlab/ldap"
stub_warn_user_is_not_gitlab
- stub_env('force', 'yes')
+ stub_env("force", "yes")
create(:identity) # Necessary to prevent `exit 1` from the task.
- run_rake_task('gitlab:ldap:rename_provider', 'ldapmain', 'ldapfoo')
+ run_rake_task("gitlab:ldap:rename_provider", "ldapmain", "ldapfoo")
end
end
diff --git a/spec/tasks/gitlab/lfs/check_rake_spec.rb b/spec/tasks/gitlab/lfs/check_rake_spec.rb
index 2610edf8bac..4b8a181ca80 100644
--- a/spec/tasks/gitlab/lfs/check_rake_spec.rb
+++ b/spec/tasks/gitlab/lfs/check_rake_spec.rb
@@ -1,28 +1,28 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:lfs rake tasks' do
- describe 'check' do
+describe "gitlab:lfs rake tasks" do
+ describe "check" do
let!(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) }
before do
- Rake.application.rake_require('tasks/gitlab/lfs/check')
- stub_env('VERBOSE' => 'true')
+ Rake.application.rake_require("tasks/gitlab/lfs/check")
+ stub_env("VERBOSE" => "true")
end
- it 'outputs the integrity check for each batch' do
- expect { run_rake_task('gitlab:lfs:check') }.to output(/Failures: 0/).to_stdout
+ it "outputs the integrity check for each batch" do
+ expect { run_rake_task("gitlab:lfs:check") }.to output(/Failures: 0/).to_stdout
end
- it 'errors out about missing files on the file system' do
+ it "errors out about missing files on the file system" do
FileUtils.rm_f(lfs_object.file.path)
- expect { run_rake_task('gitlab:lfs:check') }.to output(/No such file.*#{Regexp.quote(lfs_object.file.path)}/).to_stdout
+ expect { run_rake_task("gitlab:lfs:check") }.to output(/No such file.*#{Regexp.quote(lfs_object.file.path)}/).to_stdout
end
- it 'errors out about invalid checksum' do
+ it "errors out about invalid checksum" do
File.truncate(lfs_object.file.path, 0)
- expect { run_rake_task('gitlab:lfs:check') }.to output(/Checksum mismatch/).to_stdout
+ expect { run_rake_task("gitlab:lfs:check") }.to output(/Checksum mismatch/).to_stdout
end
end
end
diff --git a/spec/tasks/gitlab/lfs/migrate_rake_spec.rb b/spec/tasks/gitlab/lfs/migrate_rake_spec.rb
index 66d1a192a96..12f424184b6 100644
--- a/spec/tasks/gitlab/lfs/migrate_rake_spec.rb
+++ b/spec/tasks/gitlab/lfs/migrate_rake_spec.rb
@@ -1,20 +1,20 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:lfs namespace rake task' do
+describe "gitlab:lfs namespace rake task" do
before :all do
- Rake.application.rake_require 'tasks/gitlab/lfs/migrate'
+ Rake.application.rake_require "tasks/gitlab/lfs/migrate"
end
- describe 'migrate' do
+ describe "migrate" do
let(:local) { ObjectStorage::Store::LOCAL }
let(:remote) { ObjectStorage::Store::REMOTE }
let!(:lfs_object) { create(:lfs_object, :with_file, file_store: local) }
def lfs_migrate
- run_rake_task('gitlab:lfs:migrate')
+ run_rake_task("gitlab:lfs:migrate")
end
- context 'object storage disabled' do
+ context "object storage disabled" do
before do
stub_lfs_object_storage(enabled: false)
end
@@ -24,12 +24,12 @@ describe 'gitlab:lfs namespace rake task' do
end
end
- context 'object storage enabled' do
+ context "object storage enabled" do
before do
stub_lfs_object_storage
end
- it 'migrates local file to object storage' do
+ it "migrates local file to object storage" do
expect { lfs_migrate }.to change { lfs_object.reload.file_store }.from(local).to(remote)
end
end
diff --git a/spec/tasks/gitlab/mail_google_schema_whitelisting.rb b/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
index 8d1cff7a261..47ddda5197c 100644
--- a/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
+++ b/spec/tasks/gitlab/mail_google_schema_whitelisting.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
-require 'rake'
+require "spec_helper"
+require "rake"
-describe 'gitlab:mail_google_schema_whitelisting rake task' do
+describe "gitlab:mail_google_schema_whitelisting rake task" do
before :all do
Rake.application.rake_require "tasks/gitlab/helpers"
Rake.application.rake_require "tasks/gitlab/mail_google_schema_whitelisting"
@@ -9,7 +9,7 @@ describe 'gitlab:mail_google_schema_whitelisting rake task' do
Rake::Task.define_task :environment
end
- describe 'call' do
+ describe "call" do
before do
# avoid writing task output to spec progress
allow($stdout).to receive :write
@@ -20,7 +20,7 @@ describe 'gitlab:mail_google_schema_whitelisting rake task' do
Rake.application.invoke_task "gitlab:mail_google_schema_whitelisting"
end
- it 'runs the task without errors' do
+ it "runs the task without errors" do
expect { run_rake_task }.not_to raise_error
end
end
diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb
index a9d14070177..a011f9408b8 100644
--- a/spec/tasks/gitlab/shell_rake_spec.rb
+++ b/spec/tasks/gitlab/shell_rake_spec.rb
@@ -1,8 +1,8 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:shell rake tasks' do
+describe "gitlab:shell rake tasks" do
before do
- Rake.application.rake_require 'tasks/gitlab/shell'
+ Rake.application.rake_require "tasks/gitlab/shell"
stub_warn_user_is_not_gitlab
end
@@ -11,27 +11,27 @@ describe 'gitlab:shell rake tasks' do
TestEnv.sabotage_gitlab_shell_hooks
end
- describe 'install task' do
- it 'invokes create_hooks task' do
- expect(Rake::Task['gitlab:shell:create_hooks']).to receive(:invoke)
+ describe "install task" do
+ it "invokes create_hooks task" do
+ expect(Rake::Task["gitlab:shell:create_hooks"]).to receive(:invoke)
- storages = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
+ storages = Gitlab::GitalyClient::StorageSettings.allow_disk_access {
Gitlab.config.repositories.storages.values.map(&:legacy_disk_path)
- end
- expect(Kernel).to receive(:system).with('bin/install', *storages).and_call_original
- expect(Kernel).to receive(:system).with('bin/compile').and_call_original
+ }
+ expect(Kernel).to receive(:system).with("bin/install", *storages).and_call_original
+ expect(Kernel).to receive(:system).with("bin/compile").and_call_original
- run_rake_task('gitlab:shell:install')
+ run_rake_task("gitlab:shell:install")
end
end
- describe 'create_hooks task' do
- it 'calls gitlab-shell bin/create_hooks' do
+ describe "create_hooks task" do
+ it "calls gitlab-shell bin/create_hooks" do
expect_any_instance_of(Object).to receive(:system)
.with("#{Gitlab.config.gitlab_shell.path}/bin/create-hooks",
- *Gitlab::TaskHelpers.repository_storage_paths_args)
+ *Gitlab::TaskHelpers.repository_storage_paths_args)
- run_rake_task('gitlab:shell:create_hooks')
+ run_rake_task("gitlab:shell:create_hooks")
end
end
end
diff --git a/spec/tasks/gitlab/storage_rake_spec.rb b/spec/tasks/gitlab/storage_rake_spec.rb
index 6b50670c3c0..e6a8bb2cf0b 100644
--- a/spec/tasks/gitlab/storage_rake_spec.rb
+++ b/spec/tasks/gitlab/storage_rake_spec.rb
@@ -1,16 +1,16 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'rake gitlab:storage:*' do
+describe "rake gitlab:storage:*" do
before do
- Rake.application.rake_require 'tasks/gitlab/storage'
+ Rake.application.rake_require "tasks/gitlab/storage"
stub_warn_user_is_not_gitlab
end
shared_examples "rake listing entities" do |entity_name, storage_type|
- context 'limiting to 2' do
+ context "limiting to 2" do
before do
- stub_env('LIMIT' => 2)
+ stub_env("LIMIT" => 2)
end
it "lists 2 out of 3 #{storage_type.downcase} #{entity_name}" do
@@ -21,7 +21,7 @@ describe 'rake gitlab:storage:*' do
end
context "without any #{storage_type.downcase} #{entity_name.singularize}" do
- it 'displays message for empty results' do
+ it "displays message for empty results" do
expect { run_rake_task(task) }.to output(/Found 0 #{entity_name} using #{storage_type} Storage/).to_stdout
end
end
@@ -37,17 +37,17 @@ describe 'rake gitlab:storage:*' do
end
context "without any #{storage_type.downcase} #{entity_name.singularize}" do
- it 'displays message for empty results' do
+ it "displays message for empty results" do
expect { run_rake_task(task) }.to output(/Found 0 #{entity_name} using #{storage_type} Storage/).to_stdout
end
end
end
- describe 'gitlab:storage:migrate_to_hashed' do
- let(:task) { 'gitlab:storage:migrate_to_hashed' }
+ describe "gitlab:storage:migrate_to_hashed" do
+ let(:task) { "gitlab:storage:migrate_to_hashed" }
- context 'read-only database' do
- it 'does nothing' do
+ context "read-only database" do
+ it "does nothing" do
expect(Gitlab::Database).to receive(:read_only?).and_return(true)
expect(Project).not_to receive(:with_unmigrated_storage)
@@ -56,23 +56,23 @@ describe 'rake gitlab:storage:*' do
end
end
- context '0 legacy projects' do
- it 'does nothing' do
+ context "0 legacy projects" do
+ it "does nothing" do
expect(::HashedStorage::MigratorWorker).not_to receive(:perform_async)
run_rake_task(task)
end
end
- context '3 legacy projects' do
+ context "3 legacy projects" do
let(:projects) { create_list(:project, 3, :legacy_storage) }
- context 'in batches of 1' do
+ context "in batches of 1" do
before do
- stub_env('BATCH' => 1)
+ stub_env("BATCH" => 1)
end
- it 'enqueues one HashedStorage::MigratorWorker per project' do
+ it "enqueues one HashedStorage::MigratorWorker per project" do
projects.each do |project|
expect(::HashedStorage::MigratorWorker).to receive(:perform_async).with(project.id, project.id)
end
@@ -81,12 +81,12 @@ describe 'rake gitlab:storage:*' do
end
end
- context 'in batches of 2' do
+ context "in batches of 2" do
before do
- stub_env('BATCH' => 2)
+ stub_env("BATCH" => 2)
end
- it 'enqueues one HashedStorage::MigratorWorker per 2 projects' do
+ it "enqueues one HashedStorage::MigratorWorker per 2 projects" do
projects.map(&:id).sort.each_slice(2) do |first, last|
last ||= first
expect(::HashedStorage::MigratorWorker).to receive(:perform_async).with(first, last)
@@ -97,87 +97,87 @@ describe 'rake gitlab:storage:*' do
end
end
- context 'with same id in range' do
- it 'displays message when project cant be found' do
- stub_env('ID_FROM', 99999)
- stub_env('ID_TO', 99999)
+ context "with same id in range" do
+ it "displays message when project cant be found" do
+ stub_env("ID_FROM", 99999)
+ stub_env("ID_TO", 99999)
expect { run_rake_task(task) }.to output(/There are no projects requiring storage migration with ID=99999/).to_stderr
end
- it 'displays a message when project exists but its already migrated' do
+ it "displays a message when project exists but its already migrated" do
project = create(:project)
- stub_env('ID_FROM', project.id)
- stub_env('ID_TO', project.id)
+ stub_env("ID_FROM", project.id)
+ stub_env("ID_TO", project.id)
expect { run_rake_task(task) }.to output(/There are no projects requiring storage migration with ID=#{project.id}/).to_stderr
end
- it 'enqueues migration when project can be found' do
+ it "enqueues migration when project can be found" do
project = create(:project, :legacy_storage)
- stub_env('ID_FROM', project.id)
- stub_env('ID_TO', project.id)
+ stub_env("ID_FROM", project.id)
+ stub_env("ID_TO", project.id)
expect { run_rake_task(task) }.to output(/Enqueueing storage migration .* \(ID=#{project.id}\)/).to_stdout
end
end
end
- describe 'gitlab:storage:legacy_projects' do
- it_behaves_like 'rake entities summary', 'projects', 'Legacy' do
- let(:task) { 'gitlab:storage:legacy_projects' }
+ describe "gitlab:storage:legacy_projects" do
+ it_behaves_like "rake entities summary", "projects", "Legacy" do
+ let(:task) { "gitlab:storage:legacy_projects" }
let(:create_collection) { create_list(:project, 3, :legacy_storage) }
end
end
- describe 'gitlab:storage:list_legacy_projects' do
- it_behaves_like 'rake listing entities', 'projects', 'Legacy' do
- let(:task) { 'gitlab:storage:list_legacy_projects' }
+ describe "gitlab:storage:list_legacy_projects" do
+ it_behaves_like "rake listing entities", "projects", "Legacy" do
+ let(:task) { "gitlab:storage:list_legacy_projects" }
let(:create_collection) { create_list(:project, 3, :legacy_storage) }
end
end
- describe 'gitlab:storage:hashed_projects' do
- it_behaves_like 'rake entities summary', 'projects', 'Hashed' do
- let(:task) { 'gitlab:storage:hashed_projects' }
+ describe "gitlab:storage:hashed_projects" do
+ it_behaves_like "rake entities summary", "projects", "Hashed" do
+ let(:task) { "gitlab:storage:hashed_projects" }
let(:create_collection) { create_list(:project, 3, storage_version: 1) }
end
end
- describe 'gitlab:storage:list_hashed_projects' do
- it_behaves_like 'rake listing entities', 'projects', 'Hashed' do
- let(:task) { 'gitlab:storage:list_hashed_projects' }
+ describe "gitlab:storage:list_hashed_projects" do
+ it_behaves_like "rake listing entities", "projects", "Hashed" do
+ let(:task) { "gitlab:storage:list_hashed_projects" }
let(:create_collection) { create_list(:project, 3, storage_version: 1) }
end
end
- describe 'gitlab:storage:legacy_attachments' do
- it_behaves_like 'rake entities summary', 'attachments', 'Legacy' do
- let(:task) { 'gitlab:storage:legacy_attachments' }
+ describe "gitlab:storage:legacy_attachments" do
+ it_behaves_like "rake entities summary", "attachments", "Legacy" do
+ let(:task) { "gitlab:storage:legacy_attachments" }
let(:project) { create(:project, storage_version: 1) }
let(:create_collection) { create_list(:upload, 3, model: project) }
end
end
- describe 'gitlab:storage:list_legacy_attachments' do
- it_behaves_like 'rake listing entities', 'attachments', 'Legacy' do
- let(:task) { 'gitlab:storage:list_legacy_attachments' }
+ describe "gitlab:storage:list_legacy_attachments" do
+ it_behaves_like "rake listing entities", "attachments", "Legacy" do
+ let(:task) { "gitlab:storage:list_legacy_attachments" }
let(:project) { create(:project, storage_version: 1) }
let(:create_collection) { create_list(:upload, 3, model: project) }
end
end
- describe 'gitlab:storage:hashed_attachments' do
- it_behaves_like 'rake entities summary', 'attachments', 'Hashed' do
- let(:task) { 'gitlab:storage:hashed_attachments' }
+ describe "gitlab:storage:hashed_attachments" do
+ it_behaves_like "rake entities summary", "attachments", "Hashed" do
+ let(:task) { "gitlab:storage:hashed_attachments" }
let(:project) { create(:project) }
let(:create_collection) { create_list(:upload, 3, model: project) }
end
end
- describe 'gitlab:storage:list_hashed_attachments' do
- it_behaves_like 'rake listing entities', 'attachments', 'Hashed' do
- let(:task) { 'gitlab:storage:list_hashed_attachments' }
+ describe "gitlab:storage:list_hashed_attachments" do
+ it_behaves_like "rake listing entities", "attachments", "Hashed" do
+ let(:task) { "gitlab:storage:list_hashed_attachments" }
let(:project) { create(:project) }
let(:create_collection) { create_list(:upload, 3, model: project) }
end
diff --git a/spec/tasks/gitlab/task_helpers_spec.rb b/spec/tasks/gitlab/task_helpers_spec.rb
index e9322ec4931..4a283cfea8b 100644
--- a/spec/tasks/gitlab/task_helpers_spec.rb
+++ b/spec/tasks/gitlab/task_helpers_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
class TestHelpersTest
include Gitlab::TaskHelpers
@@ -7,27 +7,27 @@ end
describe Gitlab::TaskHelpers do
subject { TestHelpersTest.new }
- let(:repo) { 'https://gitlab.com/gitlab-org/gitlab-test.git' }
- let(:clone_path) { Rails.root.join('tmp/tests/task_helpers_tests').to_s }
- let(:version) { '1.1.0' }
- let(:tag) { 'v1.1.0' }
+ let(:repo) { "https://gitlab.com/gitlab-org/gitlab-test.git" }
+ let(:clone_path) { Rails.root.join("tmp/tests/task_helpers_tests").to_s }
+ let(:version) { "1.1.0" }
+ let(:tag) { "v1.1.0" }
- describe '#checkout_or_clone_version' do
+ describe "#checkout_or_clone_version" do
before do
allow(subject).to receive(:run_command!)
end
- it 'checkout the version and reset to it' do
+ it "checkout the version and reset to it" do
expect(subject).to receive(:checkout_version).with(tag, clone_path)
subject.checkout_or_clone_version(version: version, repo: repo, target_dir: clone_path)
end
- context 'with a branch version' do
- let(:version) { '=branch_name' }
- let(:branch) { 'branch_name' }
+ context "with a branch version" do
+ let(:version) { "=branch_name" }
+ let(:branch) { "branch_name" }
- it 'checkout the version and reset to it with a branch name' do
+ it "checkout the version and reset to it with a branch name" do
expect(subject).to receive(:checkout_version).with(branch, clone_path)
subject.checkout_or_clone_version(version: version, repo: repo, target_dir: clone_path)
@@ -35,14 +35,14 @@ describe Gitlab::TaskHelpers do
end
context "target_dir doesn't exist" do
- it 'clones the repo' do
+ it "clones the repo" do
expect(subject).to receive(:clone_repo).with(repo, clone_path)
subject.checkout_or_clone_version(version: version, repo: repo, target_dir: clone_path)
end
end
- context 'target_dir exists' do
+ context "target_dir exists" do
before do
expect(Dir).to receive(:exist?).and_return(true)
end
@@ -55,8 +55,8 @@ describe Gitlab::TaskHelpers do
end
end
- describe '#clone_repo' do
- it 'clones the repo in the target dir' do
+ describe "#clone_repo" do
+ it "clones the repo in the target dir" do
expect(subject)
.to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} clone -- #{repo} #{clone_path}])
@@ -64,8 +64,8 @@ describe Gitlab::TaskHelpers do
end
end
- describe '#checkout_version' do
- it 'clones the repo in the target dir' do
+ describe "#checkout_version" do
+ it "clones the repo in the target dir" do
expect(subject)
.to receive(:run_command!).with(%W[#{Gitlab.config.git.bin_path} -C #{clone_path} fetch --quiet origin #{tag}])
expect(subject)
@@ -75,23 +75,23 @@ describe Gitlab::TaskHelpers do
end
end
- describe '#run_command' do
- it 'runs command and return the output' do
- expect(subject.run_command(%w(echo it works!))).to eq("it works!\n")
+ describe "#run_command" do
+ it "runs command and return the output" do
+ expect(subject.run_command(%w[echo it works!])).to eq("it works!\n")
end
- it 'returns empty string when command doesnt exist' do
- expect(subject.run_command(%w(nonexistentcommand with arguments))).to eq('')
+ it "returns empty string when command doesnt exist" do
+ expect(subject.run_command(%w[nonexistentcommand with arguments])).to eq("")
end
end
- describe '#run_command!' do
- it 'runs command and return the output' do
- expect(subject.run_command!(%w(echo it works!))).to eq("it works!\n")
+ describe "#run_command!" do
+ it "runs command and return the output" do
+ expect(subject.run_command!(%w[echo it works!])).to eq("it works!\n")
end
- it 'returns and exception when command exit with non zero code' do
- expect { subject.run_command!(['bash', '-c', 'exit 1']) }.to raise_error Gitlab::TaskFailedError
+ it "returns and exception when command exit with non zero code" do
+ expect { subject.run_command!(["bash", "-c", "exit 1"]) }.to raise_error Gitlab::TaskFailedError
end
end
end
diff --git a/spec/tasks/gitlab/traces_rake_spec.rb b/spec/tasks/gitlab/traces_rake_spec.rb
index aaf0d7242dd..e996a0fd9fa 100644
--- a/spec/tasks/gitlab/traces_rake_spec.rb
+++ b/spec/tasks/gitlab/traces_rake_spec.rb
@@ -1,75 +1,75 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:traces rake tasks' do
+describe "gitlab:traces rake tasks" do
before do
- Rake.application.rake_require 'tasks/gitlab/traces'
+ Rake.application.rake_require "tasks/gitlab/traces"
end
- describe 'gitlab:traces:archive' do
- shared_examples 'passes the job id to worker' do
+ describe "gitlab:traces:archive" do
+ shared_examples "passes the job id to worker" do
it do
expect(ArchiveTraceWorker).to receive(:bulk_perform_async).with([[job.id]])
- run_rake_task('gitlab:traces:archive')
+ run_rake_task("gitlab:traces:archive")
end
end
- shared_examples 'does not pass the job id to worker' do
+ shared_examples "does not pass the job id to worker" do
it do
expect(ArchiveTraceWorker).not_to receive(:bulk_perform_async)
- run_rake_task('gitlab:traces:archive')
+ run_rake_task("gitlab:traces:archive")
end
end
- context 'when trace file stored in default path' do
+ context "when trace file stored in default path" do
let!(:job) { create(:ci_build, :success, :trace_live) }
- it_behaves_like 'passes the job id to worker'
+ it_behaves_like "passes the job id to worker"
end
- context 'when trace is stored in database' do
+ context "when trace is stored in database" do
let!(:job) { create(:ci_build, :success) }
before do
- job.update_column(:trace, 'trace in db')
+ job.update_column(:trace, "trace in db")
end
- it_behaves_like 'passes the job id to worker'
+ it_behaves_like "passes the job id to worker"
end
- context 'when job has trace artifact' do
+ context "when job has trace artifact" do
let!(:job) { create(:ci_build, :success) }
before do
create(:ci_job_artifact, :trace, job: job)
end
- it_behaves_like 'does not pass the job id to worker'
+ it_behaves_like "does not pass the job id to worker"
end
- context 'when job is not finished yet' do
+ context "when job is not finished yet" do
let!(:build) { create(:ci_build, :running, :trace_live) }
- it_behaves_like 'does not pass the job id to worker'
+ it_behaves_like "does not pass the job id to worker"
end
end
- describe 'gitlab:traces:migrate' do
+ describe "gitlab:traces:migrate" do
let(:object_storage_enabled) { false }
before do
stub_artifacts_object_storage(enabled: object_storage_enabled)
end
- subject { run_rake_task('gitlab:traces:migrate') }
+ subject { run_rake_task("gitlab:traces:migrate") }
let!(:job_trace) { create(:ci_job_artifact, :trace, file_store: store) }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { ObjectStorage::Store::LOCAL }
- context 'and job does not have file store defined' do
+ context "and job does not have file store defined" do
let(:object_storage_enabled) { true }
let(:store) { nil }
@@ -80,7 +80,7 @@ describe 'gitlab:traces rake tasks' do
end
end
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
let(:object_storage_enabled) { true }
it "migrates file to remote storage" do
@@ -90,7 +90,7 @@ describe 'gitlab:traces rake tasks' do
end
end
- context 'and remote storage is not defined' do
+ context "and remote storage is not defined" do
it "fails to migrate to remote storage" do
subject
@@ -99,7 +99,7 @@ describe 'gitlab:traces rake tasks' do
end
end
- context 'when remote storage is used' do
+ context "when remote storage is used" do
let(:object_storage_enabled) { true }
let(:store) { ObjectStorage::Store::REMOTE }
diff --git a/spec/tasks/gitlab/uploads/check_rake_spec.rb b/spec/tasks/gitlab/uploads/check_rake_spec.rb
index 5d597c66133..beb1aadb2c0 100644
--- a/spec/tasks/gitlab/uploads/check_rake_spec.rb
+++ b/spec/tasks/gitlab/uploads/check_rake_spec.rb
@@ -1,28 +1,28 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:uploads rake tasks' do
- describe 'check' do
- let!(:upload) { create(:upload, path: Rails.root.join('spec/fixtures/banana_sample.gif')) }
+describe "gitlab:uploads rake tasks" do
+ describe "check" do
+ let!(:upload) { create(:upload, path: Rails.root.join("spec/fixtures/banana_sample.gif")) }
before do
- Rake.application.rake_require('tasks/gitlab/uploads/check')
- stub_env('VERBOSE' => 'true')
+ Rake.application.rake_require("tasks/gitlab/uploads/check")
+ stub_env("VERBOSE" => "true")
end
- it 'outputs the integrity check for each batch' do
- expect { run_rake_task('gitlab:uploads:check') }.to output(/Failures: 0/).to_stdout
+ it "outputs the integrity check for each batch" do
+ expect { run_rake_task("gitlab:uploads:check") }.to output(/Failures: 0/).to_stdout
end
- it 'errors out about missing files on the file system' do
+ it "errors out about missing files on the file system" do
missing_upload = create(:upload)
- expect { run_rake_task('gitlab:uploads:check') }.to output(/No such file.*#{Regexp.quote(missing_upload.absolute_path)}/).to_stdout
+ expect { run_rake_task("gitlab:uploads:check") }.to output(/No such file.*#{Regexp.quote(missing_upload.absolute_path)}/).to_stdout
end
- it 'errors out about invalid checksum' do
- upload.update_column(:checksum, '01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e')
+ it "errors out about invalid checksum" do
+ upload.update_column(:checksum, "01a3156db2cf4f67ec823680b40b7302f89ab39179124ad219f94919b8a1769e")
- expect { run_rake_task('gitlab:uploads:check') }.to output(/Checksum mismatch/).to_stdout
+ expect { run_rake_task("gitlab:uploads:check") }.to output(/Checksum mismatch/).to_stdout
end
end
end
diff --git a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb
index 9588e8be5dc..de83c71edc3 100644
--- a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb
+++ b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb
@@ -1,15 +1,15 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:uploads:migrate rake tasks' do
+describe "gitlab:uploads:migrate rake tasks" do
let(:model_class) { nil }
let(:uploader_class) { nil }
let(:mounted_as) { nil }
let(:batch_size) { 3 }
before do
- stub_env('BATCH', batch_size.to_s)
+ stub_env("BATCH", batch_size.to_s)
stub_uploads_object_storage(uploader_class)
- Rake.application.rake_require 'tasks/gitlab/uploads/migrate'
+ Rake.application.rake_require "tasks/gitlab/uploads/migrate"
allow(ObjectStorage::MigrateUploadsWorker).to receive(:perform_async)
end
@@ -19,11 +19,11 @@ describe 'gitlab:uploads:migrate rake tasks' do
run_rake_task("gitlab:uploads:migrate", *args)
end
- shared_examples 'enqueue jobs in batch' do |batch:|
+ shared_examples "enqueue jobs in batch" do |batch:|
it do
expect(ObjectStorage::MigrateUploadsWorker)
.to receive(:perform_async).exactly(batch).times
- .and_return("A fake job.")
+ .and_return("A fake job.")
run
end
@@ -37,7 +37,7 @@ describe 'gitlab:uploads:migrate rake tasks' do
let(:model_class) { Project }
let!(:projects) { create_list(:project, 10, :with_avatar) }
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
context "for Group" do
@@ -47,7 +47,7 @@ describe 'gitlab:uploads:migrate rake tasks' do
create_list(:group, 10, :with_avatar)
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
context "for User" do
@@ -57,7 +57,7 @@ describe 'gitlab:uploads:migrate rake tasks' do
create_list(:user, 10, :with_avatar)
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
end
@@ -72,7 +72,7 @@ describe 'gitlab:uploads:migrate rake tasks' do
create_list(:note, 10, :with_attachment)
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
context "for Appearance" do
@@ -83,8 +83,8 @@ describe 'gitlab:uploads:migrate rake tasks' do
create(:appearance, :with_logos)
end
- %i(logo header_logo).each do |mount|
- it_behaves_like 'enqueue jobs in batch', batch: 1 do
+ %i[logo header_logo].each do |mount|
+ it_behaves_like "enqueue jobs in batch", batch: 1 do
let(:mounted_as) { mount }
end
end
@@ -98,11 +98,11 @@ describe 'gitlab:uploads:migrate rake tasks' do
before do
create_list(:project, 10) do |model|
uploader_class.new(model)
- .store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ .store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
end
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
context "for PersonalFileUploader" do
@@ -112,11 +112,11 @@ describe 'gitlab:uploads:migrate rake tasks' do
before do
create_list(:personal_snippet, 10) do |model|
uploader_class.new(model)
- .store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ .store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
end
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
context "for NamespaceFileUploader" do
@@ -126,10 +126,10 @@ describe 'gitlab:uploads:migrate rake tasks' do
before do
create_list(:snippet, 10) do |model|
uploader_class.new(model)
- .store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ .store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
end
end
- it_behaves_like 'enqueue jobs in batch', batch: 4
+ it_behaves_like "enqueue jobs in batch", batch: 4
end
end
diff --git a/spec/tasks/gitlab/web_hook_rake_spec.rb b/spec/tasks/gitlab/web_hook_rake_spec.rb
index 7bdf33ff6b0..7cef0c23a82 100644
--- a/spec/tasks/gitlab/web_hook_rake_spec.rb
+++ b/spec/tasks/gitlab/web_hook_rake_spec.rb
@@ -1,92 +1,92 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:web_hook namespace rake tasks' do
+describe "gitlab:web_hook namespace rake tasks" do
set(:group) { create(:group) }
set(:project1) { create(:project, namespace: group) }
set(:project2) { create(:project, namespace: group) }
set(:other_group_project) { create(:project) }
- let(:url) { 'http://example.com' }
+ let(:url) { "http://example.com" }
let(:hook_urls) { (project1.hooks + project2.hooks).map(&:url) }
let(:other_group_hook_urls) { other_group_project.hooks.map(&:url) }
before do
- Rake.application.rake_require 'tasks/gitlab/web_hook'
+ Rake.application.rake_require "tasks/gitlab/web_hook"
end
- describe 'gitlab:web_hook:add' do
- it 'adds a web hook to all projects' do
- stub_env('URL' => url)
- run_rake_task('gitlab:web_hook:add')
+ describe "gitlab:web_hook:add" do
+ it "adds a web hook to all projects" do
+ stub_env("URL" => url)
+ run_rake_task("gitlab:web_hook:add")
expect(hook_urls).to contain_exactly(url, url)
expect(other_group_hook_urls).to contain_exactly(url)
end
- it 'adds a web hook to projects in the specified namespace' do
- stub_env('URL' => url, 'NAMESPACE' => group.full_path)
- run_rake_task('gitlab:web_hook:add')
+ it "adds a web hook to projects in the specified namespace" do
+ stub_env("URL" => url, "NAMESPACE" => group.full_path)
+ run_rake_task("gitlab:web_hook:add")
expect(hook_urls).to contain_exactly(url, url)
expect(other_group_hook_urls).to be_empty
end
- it 'raises an error if an unknown namespace is specified' do
- stub_env('URL' => url, 'NAMESPACE' => group.full_path)
+ it "raises an error if an unknown namespace is specified" do
+ stub_env("URL" => url, "NAMESPACE" => group.full_path)
group.destroy
- expect { run_rake_task('gitlab:web_hook:add') }.to raise_error(SystemExit)
+ expect { run_rake_task("gitlab:web_hook:add") }.to raise_error(SystemExit)
end
end
- describe 'gitlab:web_hook:rm' do
+ describe "gitlab:web_hook:rm" do
let!(:hook1) { create(:project_hook, project: project1, url: url) }
let!(:hook2) { create(:project_hook, project: project2, url: url) }
let!(:other_group_hook) { create(:project_hook, project: other_group_project, url: url) }
let!(:other_url_hook) { create(:project_hook, url: other_url, project: project1) }
- let(:other_url) { 'http://other.example.com' }
+ let(:other_url) { "http://other.example.com" }
- it 'removes a web hook from all projects by URL' do
- stub_env('URL' => url)
- run_rake_task('gitlab:web_hook:rm')
+ it "removes a web hook from all projects by URL" do
+ stub_env("URL" => url)
+ run_rake_task("gitlab:web_hook:rm")
expect(hook_urls).to contain_exactly(other_url)
expect(other_group_hook_urls).to be_empty
end
- it 'removes a web hook from projects in the specified namespace by URL' do
- stub_env('NAMESPACE' => group.full_path, 'URL' => url)
- run_rake_task('gitlab:web_hook:rm')
+ it "removes a web hook from projects in the specified namespace by URL" do
+ stub_env("NAMESPACE" => group.full_path, "URL" => url)
+ run_rake_task("gitlab:web_hook:rm")
expect(hook_urls).to contain_exactly(other_url)
expect(other_group_hook_urls).to contain_exactly(url)
end
- it 'raises an error if an unknown namespace is specified' do
- stub_env('URL' => url, 'NAMESPACE' => group.full_path)
+ it "raises an error if an unknown namespace is specified" do
+ stub_env("URL" => url, "NAMESPACE" => group.full_path)
group.destroy
- expect { run_rake_task('gitlab:web_hook:rm') }.to raise_error(SystemExit)
+ expect { run_rake_task("gitlab:web_hook:rm") }.to raise_error(SystemExit)
end
end
- describe 'gitlab:web_hook:list' do
+ describe "gitlab:web_hook:list" do
let!(:hook1) { create(:project_hook, project: project1) }
let!(:hook2) { create(:project_hook, project: project2) }
let!(:other_group_hook) { create(:project_hook, project: other_group_project) }
- it 'lists all web hooks' do
- expect { run_rake_task('gitlab:web_hook:list') }.to output(/3 webhooks found/).to_stdout
+ it "lists all web hooks" do
+ expect { run_rake_task("gitlab:web_hook:list") }.to output(/3 webhooks found/).to_stdout
end
- it 'lists web hooks in a particular namespace' do
- stub_env('NAMESPACE', group.full_path)
+ it "lists web hooks in a particular namespace" do
+ stub_env("NAMESPACE", group.full_path)
- expect { run_rake_task('gitlab:web_hook:list') }.to output(/2 webhooks found/).to_stdout
+ expect { run_rake_task("gitlab:web_hook:list") }.to output(/2 webhooks found/).to_stdout
end
end
end
diff --git a/spec/tasks/gitlab/workhorse_rake_spec.rb b/spec/tasks/gitlab/workhorse_rake_spec.rb
index 42516d36c67..fbf22b1ab12 100644
--- a/spec/tasks/gitlab/workhorse_rake_spec.rb
+++ b/spec/tasks/gitlab/workhorse_rake_spec.rb
@@ -1,76 +1,76 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'gitlab:workhorse namespace rake task' do
+describe "gitlab:workhorse namespace rake task" do
before :all do
- Rake.application.rake_require 'tasks/gitlab/workhorse'
+ Rake.application.rake_require "tasks/gitlab/workhorse"
end
- describe 'install' do
- let(:repo) { 'https://gitlab.com/gitlab-org/gitlab-workhorse.git' }
- let(:clone_path) { Rails.root.join('tmp/tests/gitlab-workhorse').to_s }
+ describe "install" do
+ let(:repo) { "https://gitlab.com/gitlab-org/gitlab-workhorse.git" }
+ let(:clone_path) { Rails.root.join("tmp/tests/gitlab-workhorse").to_s }
let(:version) { File.read(Rails.root.join(Gitlab::Workhorse::VERSION_FILE)).chomp }
- context 'no dir given' do
- it 'aborts and display a help message' do
+ context "no dir given" do
+ it "aborts and display a help message" do
# avoid writing task output to spec progress
allow($stderr).to receive :write
- expect { run_rake_task('gitlab:workhorse:install') }.to raise_error /Please specify the directory where you want to install gitlab-workhorse/
+ expect { run_rake_task("gitlab:workhorse:install") }.to raise_error /Please specify the directory where you want to install gitlab-workhorse/
end
end
- context 'when an underlying Git command fail' do
- it 'aborts and display a help message' do
+ context "when an underlying Git command fail" do
+ it "aborts and display a help message" do
expect(main_object)
- .to receive(:checkout_or_clone_version).and_raise 'Git error'
+ .to receive(:checkout_or_clone_version).and_raise "Git error"
- expect { run_rake_task('gitlab:workhorse:install', clone_path) }.to raise_error 'Git error'
+ expect { run_rake_task("gitlab:workhorse:install", clone_path) }.to raise_error "Git error"
end
end
- describe 'checkout or clone' do
+ describe "checkout or clone" do
before do
expect(Dir).to receive(:chdir).with(clone_path)
end
- it 'calls checkout_or_clone_version with the right arguments' do
+ it "calls checkout_or_clone_version with the right arguments" do
expect(main_object)
.to receive(:checkout_or_clone_version).with(version: version, repo: repo, target_dir: clone_path)
- run_rake_task('gitlab:workhorse:install', clone_path)
+ run_rake_task("gitlab:workhorse:install", clone_path)
end
end
- describe 'gmake/make' do
+ describe "gmake/make" do
before do
FileUtils.mkdir_p(clone_path)
expect(Dir).to receive(:chdir).with(clone_path).and_call_original
end
- context 'gmake is available' do
+ context "gmake is available" do
before do
expect(main_object).to receive(:checkout_or_clone_version)
- allow(Object).to receive(:run_command!).with(['gmake']).and_return(true)
+ allow(Object).to receive(:run_command!).with(["gmake"]).and_return(true)
end
- it 'calls gmake in the gitlab-workhorse directory' do
- expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['/usr/bin/gmake', 0])
- expect(main_object).to receive(:run_command!).with(['gmake']).and_return(true)
+ it "calls gmake in the gitlab-workhorse directory" do
+ expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(["/usr/bin/gmake", 0])
+ expect(main_object).to receive(:run_command!).with(["gmake"]).and_return(true)
- run_rake_task('gitlab:workhorse:install', clone_path)
+ run_rake_task("gitlab:workhorse:install", clone_path)
end
end
- context 'gmake is not available' do
+ context "gmake is not available" do
before do
expect(main_object).to receive(:checkout_or_clone_version)
- allow(main_object).to receive(:run_command!).with(['make']).and_return(true)
+ allow(main_object).to receive(:run_command!).with(["make"]).and_return(true)
end
- it 'calls make in the gitlab-workhorse directory' do
- expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(['', 42])
- expect(main_object).to receive(:run_command!).with(['make']).and_return(true)
+ it "calls make in the gitlab-workhorse directory" do
+ expect(Gitlab::Popen).to receive(:popen).with(%w[which gmake]).and_return(["", 42])
+ expect(main_object).to receive(:run_command!).with(["make"]).and_return(true)
- run_rake_task('gitlab:workhorse:install', clone_path)
+ run_rake_task("gitlab:workhorse:install", clone_path)
end
end
end
diff --git a/spec/tasks/tokens_spec.rb b/spec/tasks/tokens_spec.rb
index 555a58e9aa1..52c78b6e04e 100644
--- a/spec/tasks/tokens_spec.rb
+++ b/spec/tasks/tokens_spec.rb
@@ -1,21 +1,21 @@
-require 'rake_helper'
+require "rake_helper"
-describe 'tokens rake tasks' do
+describe "tokens rake tasks" do
let!(:user) { create(:user) }
before do
- Rake.application.rake_require 'tasks/tokens'
+ Rake.application.rake_require "tasks/tokens"
end
- describe 'reset_all_email task' do
- it 'invokes create_hooks task' do
- expect { run_rake_task('tokens:reset_all_email') }.to change { user.reload.incoming_email_token }
+ describe "reset_all_email task" do
+ it "invokes create_hooks task" do
+ expect { run_rake_task("tokens:reset_all_email") }.to change { user.reload.incoming_email_token }
end
end
- describe 'reset_all_feed task' do
- it 'invokes create_hooks task' do
- expect { run_rake_task('tokens:reset_all_feed') }.to change { user.reload.feed_token }
+ describe "reset_all_feed task" do
+ it "invokes create_hooks task" do
+ expect { run_rake_task("tokens:reset_all_feed") }.to change { user.reload.feed_token }
end
end
end
diff --git a/spec/uploaders/attachment_uploader_spec.rb b/spec/uploaders/attachment_uploader_spec.rb
index a9415854d25..5b5c76c7cee 100644
--- a/spec/uploaders/attachment_uploader_spec.rb
+++ b/spec/uploaders/attachment_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AttachmentUploader do
let(:note) { create(:note, :with_attachment) }
@@ -7,26 +7,26 @@ describe AttachmentUploader do
subject { uploader }
- it_behaves_like 'builds correct paths',
- store_dir: %r[uploads/-/system/note/attachment/],
- upload_path: %r[uploads/-/system/note/attachment/],
- absolute_path: %r[#{CarrierWave.root}/uploads/-/system/note/attachment/]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{uploads/-/system/note/attachment/},
+ upload_path: %r{uploads/-/system/note/attachment/},
+ absolute_path: %r{#{CarrierWave.root}/uploads/-/system/note/attachment/}
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
- it_behaves_like 'builds correct paths',
- store_dir: %r[note/attachment/],
- upload_path: %r[note/attachment/]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{note/attachment/},
+ upload_path: %r{note/attachment/}
end
describe "#migrate!" do
before do
- uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
+ uploader.store!(fixture_file_upload(File.join("spec/fixtures/doc_sample.txt")))
stub_uploads_object_storage
end
diff --git a/spec/uploaders/avatar_uploader_spec.rb b/spec/uploaders/avatar_uploader_spec.rb
index 6aaec7a4fef..80b7d601a4a 100644
--- a/spec/uploaders/avatar_uploader_spec.rb
+++ b/spec/uploaders/avatar_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe AvatarUploader do
let(:model) { build_stubbed(:user) }
@@ -7,21 +7,21 @@ describe AvatarUploader do
subject { uploader }
- it_behaves_like 'builds correct paths',
- store_dir: %r[uploads/-/system/user/avatar/],
- upload_path: %r[uploads/-/system/user/avatar/],
- absolute_path: %r[#{CarrierWave.root}/uploads/-/system/user/avatar/]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{uploads/-/system/user/avatar/},
+ upload_path: %r{uploads/-/system/user/avatar/},
+ absolute_path: %r{#{CarrierWave.root}/uploads/-/system/user/avatar/}
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
- it_behaves_like 'builds correct paths',
- store_dir: %r[user/avatar/],
- upload_path: %r[user/avatar/]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{user/avatar/},
+ upload_path: %r{user/avatar/}
end
context "with a file" do
@@ -36,7 +36,7 @@ describe AvatarUploader do
it_behaves_like "migrates", to_store: described_class::Store::REMOTE
it_behaves_like "migrates", from_store: described_class::Store::REMOTE, to_store: described_class::Store::LOCAL
- it 'sets the right absolute path' do
+ it "sets the right absolute path" do
storage_path = Gitlab.config.uploads.storage_path
absolute_path = File.join(storage_path, upload.path)
diff --git a/spec/uploaders/external_diff_uploader_spec.rb b/spec/uploaders/external_diff_uploader_spec.rb
index 1c959770dc4..f51985fc255 100644
--- a/spec/uploaders/external_diff_uploader_spec.rb
+++ b/spec/uploaders/external_diff_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ExternalDiffUploader do
let(:diff) { create(:merge_request).merge_request_diff }
@@ -7,23 +7,23 @@ describe ExternalDiffUploader do
subject(:uploader) { described_class.new(diff, :external_diff) }
it_behaves_like "builds correct paths",
- store_dir: %r[merge_request_diffs/mr-\d+],
- cache_dir: %r[/external-diffs/tmp/cache],
- work_dir: %r[/external-diffs/tmp/work]
+ store_dir: %r{merge_request_diffs/mr-\d+},
+ cache_dir: %r{/external-diffs/tmp/cache},
+ work_dir: %r{/external-diffs/tmp/work}
context "object store is REMOTE" do
before do
stub_external_diffs_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
it_behaves_like "builds correct paths",
- store_dir: %r[merge_request_diffs/mr-\d+]
+ store_dir: %r{merge_request_diffs/mr-\d+}
end
- describe 'migration to object storage' do
- context 'with object storage disabled' do
+ describe "migration to object storage" do
+ context "with object storage disabled" do
it "is skipped" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
@@ -31,22 +31,22 @@ describe ExternalDiffUploader do
end
end
- context 'with object storage enabled' do
+ context "with object storage enabled" do
before do
stub_external_diffs_setting(enabled: true)
stub_external_diffs_object_storage(background_upload: true)
end
- it 'is scheduled to run after creation' do
- expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, 'MergeRequestDiff', :external_diff, kind_of(Numeric))
+ it "is scheduled to run after creation" do
+ expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, "MergeRequestDiff", :external_diff, kind_of(Numeric))
diff
end
end
end
- describe 'remote file' do
- context 'with object storage enabled' do
+ describe "remote file" do
+ context "with object storage enabled" do
before do
stub_external_diffs_setting(enabled: true)
stub_external_diffs_object_storage
@@ -54,7 +54,7 @@ describe ExternalDiffUploader do
diff.update!(external_diff_store: described_class::Store::REMOTE)
end
- it 'can store file remotely' do
+ it "can store file remotely" do
allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)
diff
diff --git a/spec/uploaders/file_mover_spec.rb b/spec/uploaders/file_mover_spec.rb
index de29d0c943f..8be159b3f3d 100644
--- a/spec/uploaders/file_mover_spec.rb
+++ b/spec/uploaders/file_mover_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe FileMover do
- let(:filename) { 'banana_sample.gif' }
- let(:file) { fixture_file_upload(File.join('spec', 'fixtures', filename)) }
- let(:temp_file_path) { File.join('uploads/-/system/temp', 'secret55', filename) }
+ let(:filename) { "banana_sample.gif" }
+ let(:file) { fixture_file_upload(File.join("spec", "fixtures", filename)) }
+ let(:temp_file_path) { File.join("uploads/-/system/temp", "secret55", filename) }
let(:temp_description) do
"test ![banana_sample](/#{temp_file_path}) "\
"same ![banana_sample](/#{temp_file_path}) "
end
- let(:file_path) { File.join('uploads/-/system/personal_snippet', snippet.id.to_s, 'secret55', filename) }
+ let(:file_path) { File.join("uploads/-/system/personal_snippet", snippet.id.to_s, "secret55", filename) }
let(:snippet) { create(:personal_snippet, description: temp_description) }
subject { described_class.new(file_path, snippet).execute }
- describe '#execute' do
+ describe "#execute" do
before do
expect(FileUtils).to receive(:mkdir_p).with(a_string_including(File.dirname(file_path)))
expect(FileUtils).to receive(:move).with(a_string_including(temp_file_path), a_string_including(file_path))
@@ -22,8 +22,8 @@ describe FileMover do
allow_any_instance_of(CarrierWave::SanitizedFile).to receive(:size).and_return(10)
end
- context 'when move and field update successful' do
- it 'updates the description correctly' do
+ context "when move and field update successful" do
+ it "updates the description correctly" do
subject
expect(snippet.reload.description)
@@ -33,25 +33,25 @@ describe FileMover do
)
end
- it 'creates a new update record' do
+ it "creates a new update record" do
expect { subject }.to change { Upload.count }.by(1)
end
- it 'schedules a background migration' do
+ it "schedules a background migration" do
expect_any_instance_of(PersonalFileUploader).to receive(:schedule_background_upload).once
subject
end
end
- context 'when update_markdown fails' do
+ context "when update_markdown fails" do
before do
expect(FileUtils).to receive(:move).with(a_string_including(file_path), a_string_including(temp_file_path))
end
subject { described_class.new(file_path, snippet, :non_existing_field).execute }
- it 'does not update the description' do
+ it "does not update the description" do
subject
expect(snippet.reload.description)
@@ -61,7 +61,7 @@ describe FileMover do
)
end
- it 'does not create a new update record' do
+ it "does not create a new update record" do
expect { subject }.not_to change { Upload.count }
end
end
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index 185c62491ce..d98f2bc96cb 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -1,107 +1,107 @@
-require 'spec_helper'
+require "spec_helper"
describe FileUploader do
- let(:group) { create(:group, name: 'awesome') }
- let(:project) { create(:project, :legacy_storage, namespace: group, name: 'project') }
+ let(:group) { create(:group, name: "awesome") }
+ let(:project) { create(:project, :legacy_storage, namespace: group, name: "project") }
let(:uploader) { described_class.new(project) }
- let(:upload) { double(model: project, path: 'secret/foo.jpg') }
+ let(:upload) { double(model: project, path: "secret/foo.jpg") }
subject { uploader }
- shared_examples 'builds correct legacy storage paths' do
- include_examples 'builds correct paths',
- store_dir: %r{awesome/project/\h+},
- upload_path: %r{\h+/<filename>},
- absolute_path: %r{#{described_class.root}/awesome/project/secret/foo.jpg}
+ shared_examples "builds correct legacy storage paths" do
+ include_examples "builds correct paths",
+ store_dir: %r{awesome/project/\h+},
+ upload_path: %r{\h+/<filename>},
+ absolute_path: %r{#{described_class.root}/awesome/project/secret/foo.jpg}
end
- context 'legacy storage' do
- it_behaves_like 'builds correct legacy storage paths'
+ context "legacy storage" do
+ it_behaves_like "builds correct legacy storage paths"
- context 'uses hashed storage' do
- context 'when rolled out attachments' do
- let(:project) { build_stubbed(:project, namespace: group, name: 'project') }
+ context "uses hashed storage" do
+ context "when rolled out attachments" do
+ let(:project) { build_stubbed(:project, namespace: group, name: "project") }
- include_examples 'builds correct paths',
- store_dir: %r{@hashed/\h{2}/\h{2}/\h+},
- upload_path: %r{\h+/<filename>}
+ include_examples "builds correct paths",
+ store_dir: %r{@hashed/\h{2}/\h{2}/\h+},
+ upload_path: %r{\h+/<filename>}
end
- context 'when only repositories are rolled out' do
- let(:project) { build_stubbed(:project, namespace: group, name: 'project', storage_version: Project::HASHED_STORAGE_FEATURES[:repository]) }
+ context "when only repositories are rolled out" do
+ let(:project) { build_stubbed(:project, namespace: group, name: "project", storage_version: Project::HASHED_STORAGE_FEATURES[:repository]) }
- it_behaves_like 'builds correct legacy storage paths'
+ it_behaves_like "builds correct legacy storage paths"
end
end
end
- context 'object store is remote' do
+ context "object store is remote" do
before do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
# always use hashed storage path for remote uploads
- it_behaves_like 'builds correct paths',
- store_dir: %r{@hashed/\h{2}/\h{2}/\h+},
- upload_path: %r{@hashed/\h{2}/\h{2}/\h+/\h+/<filename>}
+ it_behaves_like "builds correct paths",
+ store_dir: %r{@hashed/\h{2}/\h{2}/\h+},
+ upload_path: %r{@hashed/\h{2}/\h{2}/\h+/\h+/<filename>}
end
- describe 'initialize' do
- let(:uploader) { described_class.new(double, secret: 'secret') }
+ describe "initialize" do
+ let(:uploader) { described_class.new(double, secret: "secret") }
- it 'accepts a secret parameter' do
+ it "accepts a secret parameter" do
expect(described_class).not_to receive(:generate_secret)
- expect(uploader.secret).to eq('secret')
+ expect(uploader.secret).to eq("secret")
end
end
- describe 'callbacks' do
- describe '#prune_store_dir after :remove' do
+ describe "callbacks" do
+ describe "#prune_store_dir after :remove" do
before do
- uploader.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ uploader.store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
end
def store_dir
File.expand_path(uploader.store_dir, uploader.root)
end
- it 'is called' do
+ it "is called" do
expect(uploader).to receive(:prune_store_dir).once
uploader.remove!
end
- it 'prune the store directory' do
+ it "prune the store directory" do
expect { uploader.remove! }
.to change { File.exist?(store_dir) }.from(true).to(false)
end
end
end
- describe 'copy_to' do
+ describe "copy_to" do
let(:new_project) { create(:project) }
let(:moved) { described_class.copy_to(subject, new_project) }
- shared_examples 'returns a valid uploader' do
- describe 'returned uploader' do
- it 'generates a new secret' do
+ shared_examples "returns a valid uploader" do
+ describe "returned uploader" do
+ it "generates a new secret" do
expect(subject).to be
expect(described_class).to receive(:generate_secret).once.and_call_original
expect(moved).to be
end
- it 'creates new upload correctly' do
+ it "creates new upload correctly" do
upload = moved.upload
expect(upload).not_to eq(subject.upload)
expect(upload.model).to eq(new_project)
- expect(upload.uploader).to eq('FileUploader')
+ expect(upload.uploader).to eq("FileUploader")
expect(upload.secret).not_to eq(subject.upload.secret)
end
- it 'copies the file' do
+ it "copies the file" do
expect(subject.file).to exist
expect(moved.file).to exist
expect(subject.file).not_to eq(moved.file)
@@ -110,56 +110,56 @@ describe FileUploader do
end
end
- context 'files are stored locally' do
+ context "files are stored locally" do
before do
- subject.store!(fixture_file_upload('spec/fixtures/dk.png'))
+ subject.store!(fixture_file_upload("spec/fixtures/dk.png"))
end
- include_examples 'returns a valid uploader'
+ include_examples "returns a valid uploader"
- it 'copies the file to the correct location' do
+ it "copies the file to the correct location" do
expect(moved.upload.path).to eq("#{moved.upload.secret}/dk.png")
expect(moved.file.path).to end_with("public/uploads/#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
- expect(moved.filename).to eq('dk.png')
+ expect(moved.filename).to eq("dk.png")
end
end
- context 'files are stored remotely' do
+ context "files are stored remotely" do
before do
stub_uploads_object_storage
- subject.store!(fixture_file_upload('spec/fixtures/dk.png'))
+ subject.store!(fixture_file_upload("spec/fixtures/dk.png"))
subject.migrate!(ObjectStorage::Store::REMOTE)
end
- include_examples 'returns a valid uploader'
+ include_examples "returns a valid uploader"
- it 'copies the file to the correct location' do
+ it "copies the file to the correct location" do
expect(moved.upload.path).to eq("#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
expect(moved.file.path).to eq("#{new_project.disk_path}/#{moved.upload.secret}/dk.png")
- expect(moved.filename).to eq('dk.png')
+ expect(moved.filename).to eq("dk.png")
end
end
end
- describe '.extract_dynamic_path' do
- it 'works with hashed storage' do
- path = 'export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/72a497a02fe3ee09edae2ed06d390038/dummy.txt'
+ describe ".extract_dynamic_path" do
+ it "works with hashed storage" do
+ path = "export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/72a497a02fe3ee09edae2ed06d390038/dummy.txt"
- expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
- expect(described_class.extract_dynamic_path(path)[:secret]).to eq('72a497a02fe3ee09edae2ed06d390038')
+ expect(described_class.extract_dynamic_path(path)[:identifier]).to eq("dummy.txt")
+ expect(described_class.extract_dynamic_path(path)[:secret]).to eq("72a497a02fe3ee09edae2ed06d390038")
end
end
- describe '#secret' do
- it 'generates a secret if none is provided' do
- expect(described_class).to receive(:generate_secret).and_return('secret')
- expect(uploader.secret).to eq('secret')
+ describe "#secret" do
+ it "generates a secret if none is provided" do
+ expect(described_class).to receive(:generate_secret).and_return("secret")
+ expect(uploader.secret).to eq("secret")
end
end
describe "#migrate!" do
before do
- uploader.store!(fixture_file_upload('spec/fixtures/dk.png'))
+ uploader.store!(fixture_file_upload("spec/fixtures/dk.png"))
stub_uploads_object_storage
end
@@ -167,29 +167,29 @@ describe FileUploader do
it_behaves_like "migrates", from_store: described_class::Store::REMOTE, to_store: described_class::Store::LOCAL
end
- describe '#upload=' do
+ describe "#upload=" do
let(:secret) { SecureRandom.hex }
- let(:upload) { create(:upload, :issuable_upload, secret: secret, filename: 'file.txt') }
+ let(:upload) { create(:upload, :issuable_upload, secret: secret, filename: "file.txt") }
- it 'handles nil' do
+ it "handles nil" do
expect(uploader).not_to receive(:apply_context!)
uploader.upload = nil
end
- it 'extract the uploader context from it' do
- expect(uploader).to receive(:apply_context!).with(a_hash_including(secret: secret, identifier: 'file.txt'))
+ it "extract the uploader context from it" do
+ expect(uploader).to receive(:apply_context!).with(a_hash_including(secret: secret, identifier: "file.txt"))
uploader.upload = upload
end
end
- describe '#cache!' do
+ describe "#cache!" do
subject do
uploader.store!(uploaded_file)
end
- context 'when remote file is used' do
+ context "when remote file is used" do
let(:temp_file) { Tempfile.new("test") }
let!(:fog_connection) do
@@ -201,9 +201,9 @@ describe FileUploader do
end
let!(:fog_file) do
- fog_connection.directories.new(key: 'uploads').files.create(
- key: 'tmp/uploads/test/123123',
- body: 'content'
+ fog_connection.directories.new(key: "uploads").files.create(
+ key: "tmp/uploads/test/123123",
+ body: "content"
)
end
@@ -215,16 +215,16 @@ describe FileUploader do
FileUtils.rm_f(temp_file)
end
- it 'file is stored remotely in permament location with sanitized name' do
+ it "file is stored remotely in permament location with sanitized name" do
subject
expect(uploader).to be_exists
expect(uploader).not_to be_cached
expect(uploader).not_to be_file_storage
expect(uploader.path).not_to be_nil
- expect(uploader.path).not_to include('tmp/upload')
- expect(uploader.path).not_to include('tmp/cache')
- expect(uploader.url).to include('/my_file.txt')
+ expect(uploader.path).not_to include("tmp/upload")
+ expect(uploader.path).not_to include("tmp/cache")
+ expect(uploader.url).to include("/my_file.txt")
expect(uploader.object_store).to eq(described_class::Store::REMOTE)
end
end
diff --git a/spec/uploaders/gitlab_uploader_spec.rb b/spec/uploaders/gitlab_uploader_spec.rb
index 44718ed1212..863689446d7 100644
--- a/spec/uploaders/gitlab_uploader_spec.rb
+++ b/spec/uploaders/gitlab_uploader_spec.rb
@@ -1,13 +1,13 @@
-require 'rails_helper'
-require 'carrierwave/storage/fog'
+require "rails_helper"
+require "carrierwave/storage/fog"
describe GitlabUploader do
let(:uploader_class) { Class.new(described_class) }
subject { uploader_class.new(double) }
- describe '#file_storage?' do
- context 'when file storage is used' do
+ describe "#file_storage?" do
+ context "when file storage is used" do
before do
uploader_class.storage(:file)
end
@@ -15,7 +15,7 @@ describe GitlabUploader do
it { is_expected.to be_file_storage }
end
- context 'when is remote storage' do
+ context "when is remote storage" do
before do
uploader_class.storage(:fog)
end
@@ -24,8 +24,8 @@ describe GitlabUploader do
end
end
- describe '#file_cache_storage?' do
- context 'when file storage is used' do
+ describe "#file_cache_storage?" do
+ context "when file storage is used" do
before do
expect(uploader_class).to receive(:cache_storage) { CarrierWave::Storage::File }
end
@@ -33,7 +33,7 @@ describe GitlabUploader do
it { is_expected.to be_file_cache_storage }
end
- context 'when is remote storage' do
+ context "when is remote storage" do
before do
expect(uploader_class).to receive(:cache_storage) { CarrierWave::Storage::Fog }
end
@@ -42,89 +42,89 @@ describe GitlabUploader do
end
end
- describe '#move_to_cache' do
- it 'is true' do
+ describe "#move_to_cache" do
+ it "is true" do
expect(subject.move_to_cache).to eq(true)
end
end
- describe '#move_to_store' do
- it 'is true' do
+ describe "#move_to_store" do
+ it "is true" do
expect(subject.move_to_store).to eq(true)
end
end
- describe '#cache!' do
- it 'moves the file from the working directory to the cache directory' do
+ describe "#cache!" do
+ it "moves the file from the working directory to the cache directory" do
# One to get the work dir, the other to remove it
expect(subject).to receive(:workfile_path).exactly(2).times.and_call_original
# Test https://github.com/carrierwavesubject/carrierwave/blob/v1.0.0/lib/carrierwave/sanitized_file.rb#L200
expect(FileUtils).to receive(:mv).with(anything, /^#{subject.work_dir}/).and_call_original
expect(FileUtils).to receive(:mv).with(/^#{subject.work_dir}/, /#{subject.cache_dir}/).and_call_original
- fixture = File.join('spec', 'fixtures', 'rails_sample.jpg')
+ fixture = File.join("spec", "fixtures", "rails_sample.jpg")
subject.cache!(fixture_file_upload(fixture))
expect(subject.file.path).to match(/#{subject.cache_dir}/)
end
end
- describe '#open' do
- context 'when trace is stored in File storage' do
- context 'when file exists' do
+ describe "#open" do
+ context "when trace is stored in File storage" do
+ context "when file exists" do
let(:file) do
- fixture_file_upload('spec/fixtures/trace/sample_trace', 'text/plain')
+ fixture_file_upload("spec/fixtures/trace/sample_trace", "text/plain")
end
before do
subject.store!(file)
end
- it 'returns io stream' do
+ it "returns io stream" do
expect(subject.open).to be_a(IO)
end
- it 'when passing block it yields' do
+ it "when passing block it yields" do
expect { |b| subject.open(&b) }.to yield_control
end
end
- context 'when file does not exist' do
- it 'returns nil' do
+ context "when file does not exist" do
+ it "returns nil" do
expect(subject.open).to be_nil
end
- it 'when passing block it does not yield' do
+ it "when passing block it does not yield" do
expect { |b| subject.open(&b) }.not_to yield_control
end
end
end
- context 'when trace is stored in Object storage' do
+ context "when trace is stored in Object storage" do
before do
allow(subject).to receive(:file_storage?) { false }
end
- context 'when file exists' do
+ context "when file exists" do
before do
- allow(subject).to receive(:url) { 'http://object_storage.com/trace' }
+ allow(subject).to receive(:url) { "http://object_storage.com/trace" }
end
- it 'returns http io stream' do
+ it "returns http io stream" do
expect(subject.open).to be_a(Gitlab::HttpIO)
end
- it 'when passing block it yields' do
+ it "when passing block it yields" do
expect { |b| subject.open(&b) }.to yield_control.once
end
end
- context 'when file does not exist' do
- it 'returns nil' do
+ context "when file does not exist" do
+ it "returns nil" do
expect(subject.open).to be_nil
end
- it 'when passing block it does not yield' do
+ it "when passing block it does not yield" do
expect { |b| subject.open(&b) }.not_to yield_control
end
end
diff --git a/spec/uploaders/import_export_uploader_spec.rb b/spec/uploaders/import_export_uploader_spec.rb
index 825c1cabc14..28235a36999 100644
--- a/spec/uploaders/import_export_uploader_spec.rb
+++ b/spec/uploaders/import_export_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ImportExportUploader do
let(:model) { build_stubbed(:import_export_upload) }
@@ -11,10 +11,10 @@ describe ImportExportUploader do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
- it_behaves_like 'builds correct paths',
- store_dir: %r[import_export_upload/import_file/],
- upload_path: %r[import_export_upload/import_file/]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{import_export_upload/import_file/},
+ upload_path: %r{import_export_upload/import_file/}
end
end
diff --git a/spec/uploaders/job_artifact_uploader_spec.rb b/spec/uploaders/job_artifact_uploader_spec.rb
index 061432f082a..ae2f3dbe687 100644
--- a/spec/uploaders/job_artifact_uploader_spec.rb
+++ b/spec/uploaders/job_artifact_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe JobArtifactUploader do
let(:store) { described_class::Store::LOCAL }
@@ -8,24 +8,24 @@ describe JobArtifactUploader do
subject { uploader }
it_behaves_like "builds correct paths",
- store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z],
- cache_dir: %r[artifacts/tmp/cache],
- work_dir: %r[artifacts/tmp/work]
+ store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z],
+ cache_dir: %r{artifacts/tmp/cache},
+ work_dir: %r{artifacts/tmp/work}
context "object store is REMOTE" do
before do
stub_artifacts_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
it_behaves_like "builds correct paths",
- store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z]
+ store_dir: %r[\h{2}/\h{2}/\h{64}/\d{4}_\d{1,2}_\d{1,2}/\d+/\d+\z]
end
- context 'file is stored in valid local_path' do
+ context "file is stored in valid local_path" do
let(:file) do
- fixture_file_upload('spec/fixtures/ci_build_artifacts.zip', 'application/zip')
+ fixture_file_upload("spec/fixtures/ci_build_artifacts.zip", "application/zip")
end
before do
@@ -35,61 +35,61 @@ describe JobArtifactUploader do
subject { uploader.file.path }
it { is_expected.to start_with("#{uploader.root}/#{uploader.class.base_dir}") }
- it { is_expected.to include("/#{job_artifact.created_at.utc.strftime('%Y_%m_%d')}/") }
+ it { is_expected.to include("/#{job_artifact.created_at.utc.strftime("%Y_%m_%d")}/") }
it { is_expected.to include("/#{job_artifact.job_id}/#{job_artifact.id}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") }
end
- describe '#dynamic_segment' do
- let(:uploaded_content) { File.binread(Rails.root + 'spec/fixtures/ci_build_artifacts.zip') }
+ describe "#dynamic_segment" do
+ let(:uploaded_content) { File.binread(Rails.root + "spec/fixtures/ci_build_artifacts.zip") }
let(:model) { uploader.model }
- shared_examples_for 'Read file from legacy path' do
- it 'store_path returns the legacy path' do
- expect(model.file.store_path).to eq(File.join(model.created_at.utc.strftime('%Y_%m'), model.project_id.to_s, model.job_id.to_s, 'ci_build_artifacts.zip'))
+ shared_examples_for "Read file from legacy path" do
+ it "store_path returns the legacy path" do
+ expect(model.file.store_path).to eq(File.join(model.created_at.utc.strftime("%Y_%m"), model.project_id.to_s, model.job_id.to_s, "ci_build_artifacts.zip"))
end
- it 'has exactly the same content' do
+ it "has exactly the same content" do
expect(::File.binread(model.file.path)).to eq(uploaded_content)
end
end
- shared_examples_for 'Read file from hashed path' do
- it 'store_path returns hashed path' do
- expect(model.file.store_path).to eq(File.join(disk_hash[0..1], disk_hash[2..3], disk_hash, creation_date, model.job_id.to_s, model.id.to_s, 'ci_build_artifacts.zip'))
+ shared_examples_for "Read file from hashed path" do
+ it "store_path returns hashed path" do
+ expect(model.file.store_path).to eq(File.join(disk_hash[0..1], disk_hash[2..3], disk_hash, creation_date, model.job_id.to_s, model.id.to_s, "ci_build_artifacts.zip"))
end
- it 'has exactly the same content' do
+ it "has exactly the same content" do
expect(::File.binread(model.file.path)).to eq(uploaded_content)
end
end
- context 'when a job artifact is stored in legacy_path' do
+ context "when a job artifact is stored in legacy_path" do
let(:job_artifact) { create(:ci_job_artifact, :legacy_archive) }
- it_behaves_like 'Read file from legacy path'
+ it_behaves_like "Read file from legacy path"
end
- context 'when the artifact file is stored in hashed_path' do
+ context "when the artifact file is stored in hashed_path" do
let(:job_artifact) { create(:ci_job_artifact, :archive) }
let(:disk_hash) { Digest::SHA2.hexdigest(model.project_id.to_s) }
- let(:creation_date) { model.created_at.utc.strftime('%Y_%m_%d') }
+ let(:creation_date) { model.created_at.utc.strftime("%Y_%m_%d") }
- it_behaves_like 'Read file from hashed path'
+ it_behaves_like "Read file from hashed path"
- context 'when file_location column is empty' do
+ context "when file_location column is empty" do
before do
job_artifact.update_column(:file_location, nil)
end
- it_behaves_like 'Read file from hashed path'
+ it_behaves_like "Read file from hashed path"
end
end
end
describe "#migrate!" do
before do
- uploader.store!(fixture_file_upload('spec/fixtures/trace/sample_trace'))
+ uploader.store!(fixture_file_upload("spec/fixtures/trace/sample_trace"))
stub_artifacts_object_storage
end
diff --git a/spec/uploaders/legacy_artifact_uploader_spec.rb b/spec/uploaders/legacy_artifact_uploader_spec.rb
index 0589563b502..c04866f5e03 100644
--- a/spec/uploaders/legacy_artifact_uploader_spec.rb
+++ b/spec/uploaders/legacy_artifact_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe LegacyArtifactUploader do
let(:store) { described_class::Store::LOCAL }
@@ -9,30 +9,30 @@ describe LegacyArtifactUploader do
subject { uploader }
# TODO: move to Workhorse::UploadPath
- describe '.workhorse_upload_path' do
+ describe ".workhorse_upload_path" do
subject { described_class.workhorse_upload_path }
it { is_expected.to start_with(local_path) }
- it { is_expected.to end_with('tmp/uploads') }
+ it { is_expected.to end_with("tmp/uploads") }
end
it_behaves_like "builds correct paths",
- store_dir: %r[\d{4}_\d{1,2}/\d+/\d+\z],
- cache_dir: %r[artifacts/tmp/cache],
- work_dir: %r[artifacts/tmp/work]
+ store_dir: %r[\d{4}_\d{1,2}/\d+/\d+\z],
+ cache_dir: %r{artifacts/tmp/cache},
+ work_dir: %r{artifacts/tmp/work}
- context 'object store is remote' do
+ context "object store is remote" do
before do
stub_artifacts_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
it_behaves_like "builds correct paths",
- store_dir: %r[\d{4}_\d{1,2}/\d+/\d+\z]
+ store_dir: %r[\d{4}_\d{1,2}/\d+/\d+\z]
end
- describe '#filename' do
+ describe "#filename" do
# we need to use uploader, as this makes to use mounter
# which initialises uploader.file object
let(:uploader) { job.artifacts_file }
@@ -42,9 +42,9 @@ describe LegacyArtifactUploader do
it { is_expected.to be_nil }
end
- context 'file is stored in valid path' do
+ context "file is stored in valid path" do
let(:file) do
- fixture_file_upload('spec/fixtures/ci_build_artifacts.zip', 'application/zip')
+ fixture_file_upload("spec/fixtures/ci_build_artifacts.zip", "application/zip")
end
before do
@@ -53,8 +53,8 @@ describe LegacyArtifactUploader do
subject { uploader.file.path }
- it { is_expected.to start_with("#{uploader.root}") }
- it { is_expected.to include("/#{job.created_at.utc.strftime('%Y_%m')}/") }
+ it { is_expected.to start_with(uploader.root.to_s) }
+ it { is_expected.to include("/#{job.created_at.utc.strftime("%Y_%m")}/") }
it { is_expected.to include("/#{job.project_id}/") }
it { is_expected.to end_with("ci_build_artifacts.zip") }
end
diff --git a/spec/uploaders/lfs_object_uploader_spec.rb b/spec/uploaders/lfs_object_uploader_spec.rb
index 9f28510c3e4..44f05127658 100644
--- a/spec/uploaders/lfs_object_uploader_spec.rb
+++ b/spec/uploaders/lfs_object_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe LfsObjectUploader do
let(:lfs_object) { create(:lfs_object, :with_file) }
@@ -8,23 +8,23 @@ describe LfsObjectUploader do
subject { uploader }
it_behaves_like "builds correct paths",
- store_dir: %r[\h{2}/\h{2}],
- cache_dir: %r[/lfs-objects/tmp/cache],
- work_dir: %r[/lfs-objects/tmp/work]
+ store_dir: %r[\h{2}/\h{2}],
+ cache_dir: %r{/lfs-objects/tmp/cache},
+ work_dir: %r{/lfs-objects/tmp/work}
context "object store is REMOTE" do
before do
stub_lfs_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
it_behaves_like "builds correct paths",
- store_dir: %r[\h{2}/\h{2}]
+ store_dir: %r[\h{2}/\h{2}]
end
- describe 'migration to object storage' do
- context 'with object storage disabled' do
+ describe "migration to object storage" do
+ context "with object storage disabled" do
it "is skipped" do
expect(ObjectStorage::BackgroundMoveWorker).not_to receive(:perform_async)
@@ -32,28 +32,28 @@ describe LfsObjectUploader do
end
end
- context 'with object storage enabled' do
+ context "with object storage enabled" do
before do
stub_lfs_object_storage(background_upload: true)
end
- it 'is scheduled to run after creation' do
- expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, 'LfsObject', :file, kind_of(Numeric))
+ it "is scheduled to run after creation" do
+ expect(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async).with(described_class.name, "LfsObject", :file, kind_of(Numeric))
lfs_object
end
end
end
- describe 'remote file' do
+ describe "remote file" do
let(:lfs_object) { create(:lfs_object, :object_storage, :with_file) }
- context 'with object storage enabled' do
+ context "with object storage enabled" do
before do
stub_lfs_object_storage
end
- it 'can store file remotely' do
+ it "can store file remotely" do
allow(ObjectStorage::BackgroundMoveWorker).to receive(:perform_async)
lfs_object
diff --git a/spec/uploaders/namespace_file_uploader_spec.rb b/spec/uploaders/namespace_file_uploader_spec.rb
index 77401814194..b8a06372730 100644
--- a/spec/uploaders/namespace_file_uploader_spec.rb
+++ b/spec/uploaders/namespace_file_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NamespaceFileUploader do
let(:group) { build_stubbed(:group) }
@@ -8,12 +8,12 @@ describe NamespaceFileUploader do
subject { uploader }
- it_behaves_like 'builds correct paths' do
+ it_behaves_like "builds correct paths" do
let(:patterns) do
{
- store_dir: %r[uploads/-/system/namespace/\d+],
+ store_dir: %r{uploads/-/system/namespace/\d+},
upload_path: identifier,
- absolute_path: %r[#{CarrierWave.root}/uploads/-/system/namespace/\d+/#{identifier}]
+ absolute_path: %r{#{CarrierWave.root}/uploads/-/system/namespace/\d+/#{identifier}},
}
end
end
@@ -23,41 +23,41 @@ describe NamespaceFileUploader do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
- it_behaves_like 'builds correct paths' do
+ it_behaves_like "builds correct paths" do
let(:patterns) do
{
- store_dir: %r[namespace/\d+/\h+],
- upload_path: identifier
+ store_dir: %r{namespace/\d+/\h+},
+ upload_path: identifier,
}
end
end
end
- context '.base_dir' do
- it 'returns local storage base_dir without store param' do
+ context ".base_dir" do
+ it "returns local storage base_dir without store param" do
expect(described_class.base_dir(group)).to eq("uploads/-/system/namespace/#{group.id}")
end
- it 'returns local storage base_dir when store param is Store::LOCAL' do
+ it "returns local storage base_dir when store param is Store::LOCAL" do
expect(described_class.base_dir(group, ObjectStorage::Store::LOCAL)).to eq("uploads/-/system/namespace/#{group.id}")
end
- it 'returns remote base_dir when store param is Store::REMOTE' do
+ it "returns remote base_dir when store param is Store::REMOTE" do
expect(described_class.base_dir(group, ObjectStorage::Store::REMOTE)).to eq("namespace/#{group.id}")
end
end
- describe '#workhorse_local_upload_path' do
- it 'returns the correct path in uploads directory' do
- expect(described_class.workhorse_local_upload_path).to end_with('/uploads/tmp/uploads')
+ describe "#workhorse_local_upload_path" do
+ it "returns the correct path in uploads directory" do
+ expect(described_class.workhorse_local_upload_path).to end_with("/uploads/tmp/uploads")
end
end
describe "#migrate!" do
before do
- uploader.store!(fixture_file_upload(File.join('spec/fixtures/doc_sample.txt')))
+ uploader.store!(fixture_file_upload(File.join("spec/fixtures/doc_sample.txt")))
stub_uploads_object_storage
end
@@ -65,27 +65,27 @@ describe NamespaceFileUploader do
it_behaves_like "migrates", from_store: described_class::Store::REMOTE, to_store: described_class::Store::LOCAL
end
- describe 'copy_to' do
+ describe "copy_to" do
let(:group) { create(:group) }
let(:moved) { described_class.copy_to(subject, group) }
- shared_examples 'returns a valid uploader' do
- it 'generates a new secret' do
+ shared_examples "returns a valid uploader" do
+ it "generates a new secret" do
expect(subject).to be
expect(described_class).to receive(:generate_secret).once.and_call_original
expect(moved).to be
end
- it 'creates new upload correctly' do
+ it "creates new upload correctly" do
upload = moved.upload
expect(upload).not_to eq(subject.upload)
expect(upload.model).to eq(group)
- expect(upload.uploader).to eq('NamespaceFileUploader')
+ expect(upload.uploader).to eq("NamespaceFileUploader")
expect(upload.secret).not_to eq(subject.upload.secret)
end
- it 'copies the file' do
+ it "copies the file" do
expect(subject.file).to exist
expect(moved.file).to exist
expect(subject.file).not_to eq(moved.file)
@@ -93,32 +93,32 @@ describe NamespaceFileUploader do
end
end
- context 'files are stored locally' do
+ context "files are stored locally" do
before do
- subject.store!(fixture_file_upload('spec/fixtures/dk.png'))
+ subject.store!(fixture_file_upload("spec/fixtures/dk.png"))
end
- include_examples 'returns a valid uploader'
+ include_examples "returns a valid uploader"
- it 'copies the file to the correct location' do
+ it "copies the file to the correct location" do
expect(moved.upload.path).to eq("#{moved.upload.secret}/dk.png")
expect(moved.file.path).to end_with("system/namespace/#{group.id}/#{moved.upload.secret}/dk.png")
- expect(moved.filename).to eq('dk.png')
+ expect(moved.filename).to eq("dk.png")
end
end
- context 'files are stored remotely' do
+ context "files are stored remotely" do
before do
stub_uploads_object_storage
- subject.store!(fixture_file_upload('spec/fixtures/dk.png'))
+ subject.store!(fixture_file_upload("spec/fixtures/dk.png"))
subject.migrate!(ObjectStorage::Store::REMOTE)
end
- include_examples 'returns a valid uploader'
+ include_examples "returns a valid uploader"
- it 'copies the file to the correct location' do
+ it "copies the file to the correct location" do
expect(moved.file.path).to eq("namespace/#{group.id}/#{moved.upload.secret}/dk.png")
- expect(moved.filename).to eq('dk.png')
+ expect(moved.filename).to eq("dk.png")
end
end
end
diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb
index 533e9d87ea6..e1cb8c2e558 100644
--- a/spec/uploaders/object_storage_spec.rb
+++ b/spec/uploaders/object_storage_spec.rb
@@ -1,5 +1,5 @@
-require 'rails_helper'
-require 'carrierwave/storage/fog'
+require "rails_helper"
+require "carrierwave/storage/fog"
class Implementation < GitlabUploader
include ObjectStorage::Concern
@@ -21,7 +21,7 @@ describe ObjectStorage do
let(:object) { build_stubbed(:user) }
let(:uploader) { uploader_class.new(object, :file) }
- describe '#object_store=' do
+ describe "#object_store=" do
before do
allow(uploader_class).to receive(:object_store_enabled?).and_return(true)
end
@@ -36,32 +36,32 @@ describe ObjectStorage do
expect(uploader.file_storage?).to be_falsey
end
- context 'object_store is Store::LOCAL' do
+ context "object_store is Store::LOCAL" do
before do
uploader.object_store = described_class::Store::LOCAL
end
- describe '#store_dir' do
- it 'is the composition of (base_dir, dynamic_segment)' do
+ describe "#store_dir" do
+ it "is the composition of (base_dir, dynamic_segment)" do
expect(uploader.store_dir).to start_with("uploads/-/system/user/")
end
end
end
- context 'object_store is Store::REMOTE' do
+ context "object_store is Store::REMOTE" do
before do
uploader.object_store = described_class::Store::REMOTE
end
- describe '#store_dir' do
- it 'is the composition of (dynamic_segment)' do
+ describe "#store_dir" do
+ it "is the composition of (dynamic_segment)" do
expect(uploader.store_dir).to start_with("user/")
end
end
end
end
- describe '#object_store' do
+ describe "#object_store" do
subject { uploader.object_store }
it "delegates to <mount>_store on model" do
@@ -70,7 +70,7 @@ describe ObjectStorage do
subject
end
- context 'when store is null' do
+ context "when store is null" do
before do
expect(object).to receive(:file_store).and_return(nil)
end
@@ -80,7 +80,7 @@ describe ObjectStorage do
end
end
- context 'when value is set' do
+ context "when value is set" do
before do
expect(object).to receive(:file_store).and_return(described_class::Store::REMOTE)
end
@@ -91,8 +91,8 @@ describe ObjectStorage do
end
end
- describe '#file_cache_storage?' do
- context 'when file storage is used' do
+ describe "#file_cache_storage?" do
+ context "when file storage is used" do
before do
expect(uploader_class).to receive(:cache_storage) { CarrierWave::Storage::File }
end
@@ -100,7 +100,7 @@ describe ObjectStorage do
it { expect(uploader).to be_file_cache_storage }
end
- context 'when is remote storage' do
+ context "when is remote storage" do
before do
expect(uploader_class).to receive(:cache_storage) { CarrierWave::Storage::Fog }
end
@@ -114,24 +114,24 @@ describe ObjectStorage do
# prepend ObjectStorage::Extension::RecordsUploads
# the object_store persistence is delegated to the `Upload` model.
#
- context 'when persist_object_store? is false' do
+ context "when persist_object_store? is false" do
let(:object) { create(:project, :with_avatar) }
let(:uploader) { object.avatar }
it { expect(object).to be_a(Avatarable) }
it { expect(uploader.persist_object_store?).to be_falsey }
- describe 'delegates the object_store logic to the `Upload` model' do
- it 'sets @upload to the found `upload`' do
+ describe "delegates the object_store logic to the `Upload` model" do
+ it "sets @upload to the found `upload`" do
expect(uploader.upload).to eq(uploader.upload)
end
- it 'sets @object_store to the `Upload` value' do
+ it "sets @object_store to the `Upload` value" do
expect(uploader.object_store).to eq(uploader.upload.store)
end
end
- describe '#migrate!' do
+ describe "#migrate!" do
let(:new_store) { ObjectStorage::Store::REMOTE }
before do
@@ -140,14 +140,14 @@ describe ObjectStorage do
subject { uploader.migrate!(new_store) }
- it 'persist @object_store to the recorded upload' do
+ it "persist @object_store to the recorded upload" do
subject
expect(uploader.upload.store).to eq(new_store)
end
- describe 'fails' do
- it 'is handled gracefully' do
+ describe "fails" do
+ it "is handled gracefully" do
store = uploader.object_store
expect_any_instance_of(Upload).to receive(:save!).and_raise("An error")
@@ -162,26 +162,26 @@ describe ObjectStorage do
# this means the model holds an <mounted_as>_store attribute directly
# and do not delegate the object_store persistence to the `Upload` model.
#
- context 'persist_object_store? is true' do
- context 'when using JobArtifactsUploader' do
+ context "persist_object_store? is true" do
+ context "when using JobArtifactsUploader" do
let(:store) { described_class::Store::LOCAL }
let(:object) { create(:ci_job_artifact, :archive, file_store: store) }
let(:uploader) { object.file }
- context 'checking described_class' do
+ context "checking described_class" do
it "uploader include described_class::Concern" do
expect(uploader).to be_a(described_class::Concern)
end
end
- describe '#use_file' do
- context 'when file is stored locally' do
+ describe "#use_file" do
+ context "when file is stored locally" do
it "calls a regular path" do
- expect { |b| uploader.use_file(&b) }.not_to yield_with_args(%r[tmp/cache])
+ expect { |b| uploader.use_file(&b) }.not_to yield_with_args(%r{tmp/cache})
end
end
- context 'when file is stored remotely' do
+ context "when file is stored remotely" do
let(:store) { described_class::Store::REMOTE }
before do
@@ -189,11 +189,11 @@ describe ObjectStorage do
end
it "calls a cache path" do
- expect { |b| uploader.use_file(&b) }.to yield_with_args(%r[tmp/cache])
+ expect { |b| uploader.use_file(&b) }.to yield_with_args(%r{tmp/cache})
end
it "cleans up the cached file" do
- cached_path = ''
+ cached_path = ""
uploader.use_file do |path|
cached_path = path
@@ -206,7 +206,7 @@ describe ObjectStorage do
end
end
- describe '#migrate!' do
+ describe "#migrate!" do
subject { uploader.migrate!(new_store) }
shared_examples "updates the underlying <mounted>_store" do
@@ -217,7 +217,7 @@ describe ObjectStorage do
end
end
- context 'when using the same storage' do
+ context "when using the same storage" do
let(:new_store) { store }
it "to not migrate the storage" do
@@ -228,7 +228,7 @@ describe ObjectStorage do
end
end
- context 'when migrating to local storage' do
+ context "when migrating to local storage" do
let(:store) { described_class::Store::REMOTE }
let(:new_store) { described_class::Store::LOCAL }
@@ -254,7 +254,7 @@ describe ObjectStorage do
end
end
- context 'when migrating to remote storage' do
+ context "when migrating to remote storage" do
let(:new_store) { described_class::Store::REMOTE }
let!(:current_path) { uploader.path }
@@ -262,7 +262,7 @@ describe ObjectStorage do
expect(File.exist?(current_path)).to eq(true)
end
- context 'when storage is disabled' do
+ context "when storage is disabled" do
before do
stub_artifacts_object_storage(enabled: false)
end
@@ -272,7 +272,7 @@ describe ObjectStorage do
end
end
- context 'when credentials are set' do
+ context "when credentials are set" do
before do
stub_artifacts_object_storage
end
@@ -291,7 +291,7 @@ describe ObjectStorage do
expect(File.exist?(current_path)).to eq(false)
end
- context 'when subject save fails' do
+ context "when subject save fails" do
before do
expect(uploader).to receive(:persist_object_store!).and_raise(RuntimeError, "exception")
end
@@ -308,8 +308,8 @@ describe ObjectStorage do
end
end
- describe '#fog_directory' do
- let(:remote_directory) { 'directory' }
+ describe "#fog_directory" do
+ let(:remote_directory) { "directory" }
before do
allow(uploader_class).to receive(:options) do
@@ -322,14 +322,14 @@ describe ObjectStorage do
it { is_expected.to eq(remote_directory) }
end
- context 'when file is in use' do
+ context "when file is in use" do
def when_file_is_in_use
uploader.use_file do
yield
end
end
- it 'cannot migrate' do
+ it "cannot migrate" do
when_file_is_in_use do
expect(uploader).not_to receive(:unsafe_migrate!)
@@ -337,7 +337,7 @@ describe ObjectStorage do
end
end
- it 'cannot use_file' do
+ it "cannot use_file" do
when_file_is_in_use do
expect(uploader).not_to receive(:unsafe_use_file)
@@ -345,7 +345,7 @@ describe ObjectStorage do
end
end
- it 'can still migrate other files of the same model' do
+ it "can still migrate other files of the same model" do
uploader2 = uploader_class.new(object, :file)
uploader2.upload = create(:upload)
uploader.upload = create(:upload)
@@ -358,7 +358,7 @@ describe ObjectStorage do
end
end
- describe '#fog_credentials' do
+ describe "#fog_credentials" do
let(:connection) { Settingslogic.new("provider" => "AWS") }
before do
@@ -369,22 +369,22 @@ describe ObjectStorage do
subject { uploader.fog_credentials }
- it { is_expected.to eq(provider: 'AWS') }
+ it { is_expected.to eq(provider: "AWS") }
end
- describe '#fog_public' do
+ describe "#fog_public" do
subject { uploader.fog_public }
it { is_expected.to eq(false) }
end
- describe '.workhorse_authorize' do
+ describe ".workhorse_authorize" do
let(:has_length) { true }
let(:maximum_size) { nil }
subject { uploader_class.workhorse_authorize(has_length: has_length, maximum_size: maximum_size) }
- shared_examples 'uses local storage' do
+ shared_examples "uses local storage" do
it "returns temporary path" do
is_expected.to have_key(:TempPath)
@@ -393,7 +393,7 @@ describe ObjectStorage do
end
end
- shared_examples 'uses remote storage' do
+ shared_examples "uses remote storage" do
it "returns remote store" do
is_expected.to have_key(:RemoteObject)
@@ -409,8 +409,8 @@ describe ObjectStorage do
end
end
- shared_examples 'uses remote storage with multipart uploads' do
- it_behaves_like 'uses remote storage' do
+ shared_examples "uses remote storage with multipart uploads" do
+ it_behaves_like "uses remote storage" do
it "returns multipart upload" do
is_expected.to have_key(:RemoteObject)
@@ -426,8 +426,8 @@ describe ObjectStorage do
end
end
- shared_examples 'uses remote storage without multipart uploads' do
- it_behaves_like 'uses remote storage' do
+ shared_examples "uses remote storage without multipart uploads" do
+ it_behaves_like "uses remote storage" do
it "does not return multipart upload" do
is_expected.to have_key(:RemoteObject)
expect(subject[:RemoteObject]).not_to have_key(:MultipartUpload)
@@ -435,39 +435,39 @@ describe ObjectStorage do
end
end
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:enabled) { false }
end
- it_behaves_like 'uses local storage'
+ it_behaves_like "uses local storage"
end
- context 'when object storage is enabled' do
+ context "when object storage is enabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:enabled) { true }
end
- context 'when direct upload is enabled' do
+ context "when direct upload is enabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:direct_upload) { true }
end
- context 'uses AWS' do
+ context "uses AWS" do
let(:storage_url) { "https://uploads.s3-eu-central-1.amazonaws.com/" }
before do
expect(uploader_class).to receive(:object_store_credentials) do
- { provider: "AWS",
- aws_access_key_id: "AWS_ACCESS_KEY_ID",
- aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
- region: "eu-central-1" }
+ {provider: "AWS",
+ aws_access_key_id: "AWS_ACCESS_KEY_ID",
+ aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
+ region: "eu-central-1",}
end
end
- context 'for known length' do
- it_behaves_like 'uses remote storage without multipart uploads' do
- it 'returns links for S3' do
+ context "for known length" do
+ it_behaves_like "uses remote storage without multipart uploads" do
+ it "returns links for S3" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -475,7 +475,7 @@ describe ObjectStorage do
end
end
- context 'for unknown length' do
+ context "for unknown length" do
let(:has_length) { false }
let(:maximum_size) { 1.gigabyte }
@@ -483,8 +483,8 @@ describe ObjectStorage do
stub_object_storage_multipart_init(storage_url)
end
- it_behaves_like 'uses remote storage with multipart uploads' do
- it 'returns links for S3' do
+ it_behaves_like "uses remote storage with multipart uploads" do
+ it "returns links for S3" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -496,20 +496,20 @@ describe ObjectStorage do
end
end
- context 'uses Google' do
+ context "uses Google" do
let(:storage_url) { "https://storage.googleapis.com/uploads/" }
before do
expect(uploader_class).to receive(:object_store_credentials) do
- { provider: "Google",
- google_storage_access_key_id: 'ACCESS_KEY_ID',
- google_storage_secret_access_key: 'SECRET_ACCESS_KEY' }
+ {provider: "Google",
+ google_storage_access_key_id: "ACCESS_KEY_ID",
+ google_storage_secret_access_key: "SECRET_ACCESS_KEY",}
end
end
- context 'for known length' do
- it_behaves_like 'uses remote storage without multipart uploads' do
- it 'returns links for Google Cloud' do
+ context "for known length" do
+ it_behaves_like "uses remote storage without multipart uploads" do
+ it "returns links for Google Cloud" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -517,12 +517,12 @@ describe ObjectStorage do
end
end
- context 'for unknown length' do
+ context "for unknown length" do
let(:has_length) { false }
let(:maximum_size) { 1.gigabyte }
- it_behaves_like 'uses remote storage without multipart uploads' do
- it 'returns links for Google Cloud' do
+ it_behaves_like "uses remote storage without multipart uploads" do
+ it "returns links for Google Cloud" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -531,23 +531,23 @@ describe ObjectStorage do
end
end
- context 'uses GDK/minio' do
+ context "uses GDK/minio" do
let(:storage_url) { "http://minio:9000/uploads/" }
before do
expect(uploader_class).to receive(:object_store_credentials) do
- { provider: "AWS",
- aws_access_key_id: "AWS_ACCESS_KEY_ID",
- aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
- endpoint: 'http://minio:9000',
- path_style: true,
- region: "gdk" }
+ {provider: "AWS",
+ aws_access_key_id: "AWS_ACCESS_KEY_ID",
+ aws_secret_access_key: "AWS_SECRET_ACCESS_KEY",
+ endpoint: "http://minio:9000",
+ path_style: true,
+ region: "gdk",}
end
end
- context 'for known length' do
- it_behaves_like 'uses remote storage without multipart uploads' do
- it 'returns links for S3' do
+ context "for known length" do
+ it_behaves_like "uses remote storage without multipart uploads" do
+ it "returns links for S3" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -555,7 +555,7 @@ describe ObjectStorage do
end
end
- context 'for unknown length' do
+ context "for unknown length" do
let(:has_length) { false }
let(:maximum_size) { 1.gigabyte }
@@ -563,8 +563,8 @@ describe ObjectStorage do
stub_object_storage_multipart_init(storage_url)
end
- it_behaves_like 'uses remote storage with multipart uploads' do
- it 'returns links for S3' do
+ it_behaves_like "uses remote storage with multipart uploads" do
+ it "returns links for S3" do
expect(subject[:RemoteObject][:GetURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:DeleteURL]).to start_with(storage_url)
expect(subject[:RemoteObject][:StoreURL]).to start_with(storage_url)
@@ -577,25 +577,25 @@ describe ObjectStorage do
end
end
- context 'when direct upload is disabled' do
+ context "when direct upload is disabled" do
before do
allow(Gitlab.config.uploads.object_store).to receive(:direct_upload) { false }
end
- it_behaves_like 'uses local storage'
+ it_behaves_like "uses local storage"
end
end
end
- describe '#cache!' do
+ describe "#cache!" do
subject do
uploader.cache!(uploaded_file)
end
- context 'when local file is used' do
- context 'when valid file is used' do
+ context "when local file is used" do
+ context "when valid file is used" do
let(:uploaded_file) do
- fixture_file_upload('spec/fixtures/rails_sample.jpg', 'image/jpg')
+ fixture_file_upload("spec/fixtures/rails_sample.jpg", "image/jpg")
end
it "properly caches the file" do
@@ -603,12 +603,12 @@ describe ObjectStorage do
expect(uploader).to be_exists
expect(uploader.path).to start_with(uploader_class.root)
- expect(uploader.filename).to eq('rails_sample.jpg')
+ expect(uploader.filename).to eq("rails_sample.jpg")
end
end
end
- context 'when local file is used' do
+ context "when local file is used" do
let(:temp_file) { Tempfile.new("test") }
before do
@@ -619,53 +619,53 @@ describe ObjectStorage do
FileUtils.rm_f(temp_file)
end
- context 'when valid file is used' do
- context 'when valid file is specified' do
+ context "when valid file is used" do
+ context "when valid file is specified" do
let(:uploaded_file) { temp_file }
- context 'when object storage and direct upload is specified' do
+ context "when object storage and direct upload is specified" do
before do
stub_uploads_object_storage(uploader_class, enabled: true, direct_upload: true)
end
- context 'when file is stored' do
+ context "when file is stored" do
subject do
uploader.store!(uploaded_file)
end
- it 'file to be remotely stored in permament location' do
+ it "file to be remotely stored in permament location" do
subject
expect(uploader).to be_exists
expect(uploader).not_to be_cached
expect(uploader).not_to be_file_storage
expect(uploader.path).not_to be_nil
- expect(uploader.path).not_to include('tmp/upload')
- expect(uploader.path).not_to include('tmp/cache')
+ expect(uploader.path).not_to include("tmp/upload")
+ expect(uploader.path).not_to include("tmp/cache")
expect(uploader.object_store).to eq(described_class::Store::REMOTE)
end
end
end
- context 'when object storage and direct upload is not used' do
+ context "when object storage and direct upload is not used" do
before do
stub_uploads_object_storage(uploader_class, enabled: true, direct_upload: false)
end
- context 'when file is stored' do
+ context "when file is stored" do
subject do
uploader.store!(uploaded_file)
end
- it 'file to be remotely stored in permament location' do
+ it "file to be remotely stored in permament location" do
subject
expect(uploader).to be_exists
expect(uploader).not_to be_cached
expect(uploader).to be_file_storage
expect(uploader.path).not_to be_nil
- expect(uploader.path).not_to include('tmp/upload')
- expect(uploader.path).not_to include('tmp/cache')
+ expect(uploader.path).not_to include("tmp/upload")
+ expect(uploader.path).not_to include("tmp/cache")
expect(uploader.object_store).to eq(described_class::Store::LOCAL)
end
end
@@ -674,7 +674,7 @@ describe ObjectStorage do
end
end
- context 'when remote file is used' do
+ context "when remote file is used" do
let(:temp_file) { Tempfile.new("test") }
let!(:fog_connection) do
@@ -689,66 +689,66 @@ describe ObjectStorage do
FileUtils.rm_f(temp_file)
end
- context 'when valid file is used' do
- context 'when invalid file is specified' do
+ context "when valid file is used" do
+ context "when invalid file is specified" do
let(:uploaded_file) do
UploadedFile.new(temp_file.path, remote_id: "../test/123123")
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Bad file path/)
end
end
- context 'when non existing file is specified' do
+ context "when non existing file is specified" do
let(:uploaded_file) do
UploadedFile.new(temp_file.path, remote_id: "test/123123")
end
- it 'raises an error' do
+ it "raises an error" do
expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Missing file/)
end
end
- context 'when valid file is specified' do
+ context "when valid file is specified" do
let(:uploaded_file) do
UploadedFile.new(temp_file.path, filename: "my_file.txt", remote_id: "test/123123")
end
let!(:fog_file) do
- fog_connection.directories.new(key: 'uploads').files.create(
- key: 'tmp/uploads/test/123123',
- body: 'content'
+ fog_connection.directories.new(key: "uploads").files.create(
+ key: "tmp/uploads/test/123123",
+ body: "content"
)
end
- it 'file to be cached and remote stored' do
+ it "file to be cached and remote stored" do
expect { subject }.not_to raise_error
expect(uploader).to be_exists
expect(uploader).to be_cached
expect(uploader).not_to be_file_storage
expect(uploader.path).not_to be_nil
- expect(uploader.path).not_to include('tmp/cache')
- expect(uploader.path).not_to include('tmp/cache')
+ expect(uploader.path).not_to include("tmp/cache")
+ expect(uploader.path).not_to include("tmp/cache")
expect(uploader.object_store).to eq(described_class::Store::REMOTE)
end
- context 'when file is stored' do
+ context "when file is stored" do
subject do
uploader.store!(uploaded_file)
end
- it 'file to be remotely stored in permament location' do
+ it "file to be remotely stored in permament location" do
subject
expect(uploader).to be_exists
expect(uploader).not_to be_cached
expect(uploader).not_to be_file_storage
expect(uploader.path).not_to be_nil
- expect(uploader.path).not_to include('tmp/upload')
- expect(uploader.path).not_to include('tmp/cache')
- expect(uploader.url).to include('/my_file.txt')
+ expect(uploader.path).not_to include("tmp/upload")
+ expect(uploader.path).not_to include("tmp/cache")
+ expect(uploader.url).to include("/my_file.txt")
expect(uploader.object_store).to eq(described_class::Store::REMOTE)
end
end
@@ -757,13 +757,13 @@ describe ObjectStorage do
end
end
- describe '#retrieve_from_store!' do
+ describe "#retrieve_from_store!" do
[:group, :project, :user].each do |model|
context "for #{model}s" do
let(:models) { create_list(model, 3, :with_avatar).map(&:reload) }
let(:avatars) { models.map(&:avatar) }
- it 'batches fetching uploads from the database' do
+ it "batches fetching uploads from the database" do
# Ensure that these are all created and fully loaded before we start
# running queries for avatars
models
@@ -771,7 +771,7 @@ describe ObjectStorage do
expect { avatars }.not_to exceed_query_limit(1)
end
- it 'fetches a unique upload for each model' do
+ it "fetches a unique upload for each model" do
expect(avatars.map(&:url).uniq).to eq(avatars.map(&:url))
expect(avatars.map(&:upload).uniq).to eq(avatars.map(&:upload))
end
diff --git a/spec/uploaders/personal_file_uploader_spec.rb b/spec/uploaders/personal_file_uploader_spec.rb
index 97758f0243e..5062a142762 100644
--- a/spec/uploaders/personal_file_uploader_spec.rb
+++ b/spec/uploaders/personal_file_uploader_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PersonalFileUploader do
let(:model) { create(:personal_snippet) }
@@ -7,43 +7,43 @@ describe PersonalFileUploader do
subject { uploader }
- it_behaves_like 'builds correct paths',
- store_dir: %r[uploads/-/system/personal_snippet/\d+],
- upload_path: %r[\h+/\S+],
- absolute_path: %r[#{CarrierWave.root}/uploads/-/system/personal_snippet\/\d+\/\h+\/\S+$]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{uploads/-/system/personal_snippet/\d+},
+ upload_path: %r{\h+/\S+},
+ absolute_path: %r{#{CarrierWave.root}/uploads/-/system/personal_snippet\/\d+\/\h+\/\S+$}
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
end
- include_context 'with storage', described_class::Store::REMOTE
+ include_context "with storage", described_class::Store::REMOTE
- it_behaves_like 'builds correct paths',
- store_dir: %r[\d+/\h+],
- upload_path: %r[^personal_snippet\/\d+\/\h+\/<filename>]
+ it_behaves_like "builds correct paths",
+ store_dir: %r{\d+/\h+},
+ upload_path: %r{^personal_snippet\/\d+\/\h+\/<filename>}
end
- describe '#upload_paths' do
- it 'builds correct paths for both local and remote storage' do
- paths = uploader.upload_paths('test.jpg')
+ describe "#upload_paths" do
+ it "builds correct paths for both local and remote storage" do
+ paths = uploader.upload_paths("test.jpg")
- expect(paths.first).to match(%r[\h+\/test.jpg])
- expect(paths.second).to match(%r[^personal_snippet\/\d+\/\h+\/test.jpg])
+ expect(paths.first).to match(%r{\h+\/test.jpg})
+ expect(paths.second).to match(%r{^personal_snippet\/\d+\/\h+\/test.jpg})
end
end
- describe '#to_h' do
+ describe "#to_h" do
before do
- subject.instance_variable_set(:@secret, 'secret')
+ subject.instance_variable_set(:@secret, "secret")
end
- it 'is correct' do
- allow(uploader).to receive(:file).and_return(double(extension: 'txt', filename: 'file_name'))
+ it "is correct" do
+ allow(uploader).to receive(:file).and_return(double(extension: "txt", filename: "file_name"))
expected_url = "/uploads/-/system/personal_snippet/#{model.id}/secret/file_name"
expect(uploader.to_h).to eq(
- alt: 'file_name',
+ alt: "file_name",
url: expected_url,
markdown: "[file_name](#{expected_url})"
)
@@ -52,7 +52,7 @@ describe PersonalFileUploader do
describe "#migrate!" do
before do
- uploader.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ uploader.store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
stub_uploads_object_storage
end
diff --git a/spec/uploaders/records_uploads_spec.rb b/spec/uploaders/records_uploads_spec.rb
index 3592a11360d..c1b5546460a 100644
--- a/spec/uploaders/records_uploads_spec.rb
+++ b/spec/uploaders/records_uploads_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe RecordsUploads do
let!(:uploader) do
@@ -8,7 +8,7 @@ describe RecordsUploads do
storage :file
def dynamic_segment
- 'co/fe/ee'
+ "co/fe/ee"
end
end
@@ -16,37 +16,37 @@ describe RecordsUploads do
end
def upload_fixture(filename)
- fixture_file_upload(File.join('spec', 'fixtures', filename))
+ fixture_file_upload(File.join("spec", "fixtures", filename))
end
- describe 'callbacks' do
+ describe "callbacks" do
let(:upload) { create(:upload) }
before do
uploader.upload = upload
end
- it '#record_upload after `store`' do
+ it "#record_upload after `store`" do
expect(uploader).to receive(:record_upload).once
- uploader.store!(upload_fixture('doc_sample.txt'))
+ uploader.store!(upload_fixture("doc_sample.txt"))
end
- it '#destroy_upload after `remove`' do
- uploader.store!(upload_fixture('doc_sample.txt'))
+ it "#destroy_upload after `remove`" do
+ uploader.store!(upload_fixture("doc_sample.txt"))
expect(uploader).to receive(:destroy_upload).once
uploader.remove!
end
end
- describe '#record_upload callback' do
- it 'creates an Upload record after store' do
- expect { uploader.store!(upload_fixture('rails_sample.jpg')) }.to change { Upload.count }.by(1)
+ describe "#record_upload callback" do
+ it "creates an Upload record after store" do
+ expect { uploader.store!(upload_fixture("rails_sample.jpg")) }.to change { Upload.count }.by(1)
end
- it 'creates a new record and assigns size, path, model, and uploader' do
- uploader.store!(upload_fixture('rails_sample.jpg'))
+ it "creates a new record and assigns size, path, model, and uploader" do
+ uploader.store!(upload_fixture("rails_sample.jpg"))
upload = uploader.upload
aggregate_failures do
@@ -62,34 +62,34 @@ describe RecordsUploads do
it "does not create an Upload record when the file doesn't exist" do
allow(uploader).to receive(:file).and_return(double(exists?: false))
- expect { uploader.store!(upload_fixture('rails_sample.jpg')) }.not_to change { Upload.count }
+ expect { uploader.store!(upload_fixture("rails_sample.jpg")) }.not_to change { Upload.count }
end
- it 'does not create an Upload record if model is missing' do
+ it "does not create an Upload record if model is missing" do
allow_any_instance_of(RecordsUploadsExampleUploader).to receive(:model).and_return(nil)
- expect { uploader.store!(upload_fixture('rails_sample.jpg')) }.not_to change { Upload.count }
+ expect { uploader.store!(upload_fixture("rails_sample.jpg")) }.not_to change { Upload.count }
end
- it 'it destroys Upload records at the same path before recording' do
+ it "it destroys Upload records at the same path before recording" do
existing = Upload.create!(
- path: File.join('uploads', 'rails_sample.jpg'),
+ path: File.join("uploads", "rails_sample.jpg"),
size: 512.kilobytes,
model: build_stubbed(:user),
uploader: uploader.class.to_s
)
uploader.upload = existing
- uploader.store!(upload_fixture('rails_sample.jpg'))
+ uploader.store!(upload_fixture("rails_sample.jpg"))
expect { existing.reload }.to raise_error(ActiveRecord::RecordNotFound)
expect(Upload.count).to eq(1)
end
end
- describe '#destroy_upload callback' do
- it 'it destroys Upload records at the same path after removal' do
- uploader.store!(upload_fixture('rails_sample.jpg'))
+ describe "#destroy_upload callback" do
+ it "it destroys Upload records at the same path after removal" do
+ uploader.store!(upload_fixture("rails_sample.jpg"))
expect { uploader.remove! }.to change { Upload.count }.from(1).to(0)
end
diff --git a/spec/uploaders/uploader_helper_spec.rb b/spec/uploaders/uploader_helper_spec.rb
index fd6712d4645..58bfe2e33f7 100644
--- a/spec/uploaders/uploader_helper_spec.rb
+++ b/spec/uploaders/uploader_helper_spec.rb
@@ -1,20 +1,20 @@
-require 'rails_helper'
+require "rails_helper"
describe UploaderHelper do
let(:uploader) do
- example_uploader = Class.new(CarrierWave::Uploader::Base) do
+ example_uploader = Class.new(CarrierWave::Uploader::Base) {
include UploaderHelper
storage :file
- end
+ }
example_uploader.new
end
- describe '#extension_match?' do
- it 'returns false if file does not exists' do
+ describe "#extension_match?" do
+ it "returns false if file does not exists" do
expect(uploader.file).to be_nil
- expect(uploader.send(:extension_match?, 'jpg')).to eq false
+ expect(uploader.send(:extension_match?, "jpg")).to eq false
end
end
end
diff --git a/spec/uploaders/workers/object_storage/background_move_worker_spec.rb b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb
index 95813d15e52..5bc5aee5dfa 100644
--- a/spec/uploaders/workers/object_storage/background_move_worker_spec.rb
+++ b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ObjectStorage::BackgroundMoveWorker do
let(:local) { ObjectStorage::Store::LOCAL }
@@ -8,34 +8,34 @@ describe ObjectStorage::BackgroundMoveWorker do
described_class.perform_async(uploader_class.name, subject_class, file_field, subject_id)
end
- context 'for LFS' do
+ context "for LFS" do
let!(:lfs_object) { create(:lfs_object, :with_file, file_store: local) }
let(:uploader_class) { LfsObjectUploader }
let(:subject_class) { LfsObject }
let(:file_field) { :file }
let(:subject_id) { lfs_object.id }
- context 'when object storage is enabled' do
+ context "when object storage is enabled" do
before do
stub_lfs_object_storage(background_upload: true)
end
- it 'uploads object to storage' do
+ it "uploads object to storage" do
expect { perform }.to change { lfs_object.reload.file_store }.from(local).to(remote)
end
- context 'when background upload is disabled' do
+ context "when background upload is disabled" do
before do
allow(Gitlab.config.lfs.object_store).to receive(:background_upload) { false }
end
- it 'is skipped' do
+ it "is skipped" do
expect { perform }.not_to change { lfs_object.reload.file_store }
end
end
end
- context 'when object storage is disabled' do
+ context "when object storage is disabled" do
before do
stub_lfs_object_storage(enabled: false)
end
@@ -48,17 +48,17 @@ describe ObjectStorage::BackgroundMoveWorker do
end
end
- context 'for legacy artifacts' do
+ context "for legacy artifacts" do
let(:build) { create(:ci_build, :legacy_artifacts) }
let(:uploader_class) { LegacyArtifactUploader }
let(:subject_class) { Ci::Build }
let(:file_field) { :artifacts_file }
let(:subject_id) { build.id }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { local }
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
before do
stub_artifacts_object_storage(background_upload: true)
end
@@ -69,10 +69,10 @@ describe ObjectStorage::BackgroundMoveWorker do
expect(build.reload.artifacts_file_store).to eq(remote)
end
- context 'for artifacts_metadata' do
+ context "for artifacts_metadata" do
let(:file_field) { :artifacts_metadata }
- it 'migrates metadata to remote storage' do
+ it "migrates metadata to remote storage" do
perform
expect(build.reload.artifacts_metadata_store).to eq(remote)
@@ -82,17 +82,17 @@ describe ObjectStorage::BackgroundMoveWorker do
end
end
- context 'for job artifacts' do
+ context "for job artifacts" do
let(:artifact) { create(:ci_job_artifact, :archive) }
let(:uploader_class) { JobArtifactUploader }
let(:subject_class) { Ci::JobArtifact }
let(:file_field) { :file }
let(:subject_id) { artifact.id }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { local }
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
before do
stub_artifacts_object_storage(background_upload: true)
end
@@ -106,20 +106,20 @@ describe ObjectStorage::BackgroundMoveWorker do
end
end
- context 'for uploads' do
+ context "for uploads" do
let!(:project) { create(:project, :with_avatar) }
let(:uploader_class) { AvatarUploader }
let(:file_field) { :avatar }
- context 'when local storage is used' do
+ context "when local storage is used" do
let(:store) { local }
- context 'and remote storage is defined' do
+ context "and remote storage is defined" do
before do
stub_uploads_object_storage(uploader_class, background_upload: true)
end
- describe 'supports using the model' do
+ describe "supports using the model" do
let(:subject_class) { project.class }
let(:subject_id) { project.id }
@@ -132,7 +132,7 @@ describe ObjectStorage::BackgroundMoveWorker do
end
end
- describe 'supports using the Upload' do
+ describe "supports using the Upload" do
let(:subject_class) { Upload }
let(:subject_id) { project.avatar.upload.id }
diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
index da490cb02af..0650adc2fcc 100644
--- a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
+++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
- shared_context 'sanity_check! fails' do
+ shared_context "sanity_check! fails" do
before do
expect(described_class).to receive(:sanity_check!).and_raise(described_class::SanityCheckError)
end
@@ -18,22 +18,22 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
end
shared_examples "uploads migration worker" do
- describe '.enqueue!' do
+ describe ".enqueue!" do
def enqueue!
described_class.enqueue!(uploads, Project, mounted_as, to_store)
end
- it 'is guarded by .sanity_check!' do
+ it "is guarded by .sanity_check!" do
expect(described_class).to receive(:perform_async)
expect(described_class).to receive(:sanity_check!)
enqueue!
end
- context 'sanity_check! fails' do
- include_context 'sanity_check! fails'
+ context "sanity_check! fails" do
+ include_context "sanity_check! fails"
- it 'does not enqueue a job' do
+ it "does not enqueue a job" do
expect(described_class).not_to receive(:perform_async)
expect { enqueue! }.to raise_error(described_class::SanityCheckError)
@@ -41,8 +41,8 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
end
end
- describe '.sanity_check!' do
- shared_examples 'raises a SanityCheckError' do
+ describe ".sanity_check!" do
+ shared_examples "raises a SanityCheckError" do
let(:mount_point) { nil }
it do
@@ -55,31 +55,31 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
stub_const("WrongModel", Class.new)
end
- context 'uploader types mismatch' do
- let!(:outlier) { create(:upload, uploader: 'GitlabUploader') }
+ context "uploader types mismatch" do
+ let!(:outlier) { create(:upload, uploader: "GitlabUploader") }
- include_examples 'raises a SanityCheckError'
+ include_examples "raises a SanityCheckError"
end
- context 'model types mismatch' do
- let!(:outlier) { create(:upload, model_type: 'WrongModel') }
+ context "model types mismatch" do
+ let!(:outlier) { create(:upload, model_type: "WrongModel") }
- include_examples 'raises a SanityCheckError'
+ include_examples "raises a SanityCheckError"
end
- context 'mount point not found' do
- include_examples 'raises a SanityCheckError' do
+ context "mount point not found" do
+ include_examples "raises a SanityCheckError" do
let(:mount_point) { :potato }
end
end
end
- describe '#perform' do
- shared_examples 'outputs correctly' do |success: 0, failures: 0|
+ describe "#perform" do
+ shared_examples "outputs correctly" do |success: 0, failures: 0|
total = success + failures
if success > 0
- it 'outputs the reports' do
+ it "outputs the reports" do
expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files})
perform(uploads)
@@ -87,7 +87,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
end
if failures > 0
- it 'outputs upload failures' do
+ it "outputs upload failures" do
expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/)
perform(uploads)
@@ -95,21 +95,21 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
end
end
- it_behaves_like 'outputs correctly', success: 10
+ it_behaves_like "outputs correctly", success: 10
- it 'migrates files' do
+ it "migrates files" do
perform(uploads)
expect(Upload.where(store: ObjectStorage::Store::LOCAL).count).to eq(0)
end
- context 'migration is unsuccessful' do
+ context "migration is unsuccessful" do
before do
allow_any_instance_of(ObjectStorage::Concern)
.to receive(:migrate!).and_raise(CarrierWave::UploadError, "I am a teapot.")
end
- it_behaves_like 'outputs correctly', failures: 10
+ it_behaves_like "outputs correctly", failures: 10
end
end
end
@@ -143,7 +143,7 @@ describe ObjectStorage::MigrateUploadsWorker, :sidekiq do
def upload_file(project)
uploader = FileUploader.new(project)
- uploader.store!(fixture_file_upload('spec/fixtures/doc_sample.txt'))
+ uploader.store!(fixture_file_upload("spec/fixtures/doc_sample.txt"))
end
before do
diff --git a/spec/validators/branch_filter_validator_spec.rb b/spec/validators/branch_filter_validator_spec.rb
index 3be54827431..d858e99aebe 100644
--- a/spec/validators/branch_filter_validator_spec.rb
+++ b/spec/validators/branch_filter_validator_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
describe BranchFilterValidator do
let(:validator) { described_class.new(attributes: [:push_events_branch_filter]) }
let(:hook) { build(:project_hook) }
- describe '#validates_each' do
- it 'allows valid branch names' do
+ describe "#validates_each" do
+ it "allows valid branch names" do
validator.validate_each(hook, :push_events_branch_filter, "good_branch_name")
validator.validate_each(hook, :push_events_branch_filter, "another/good_branch_name")
expect(hook.errors.empty?).to be true
end
- it 'disallows bad branch names' do
+ it "disallows bad branch names" do
validator.validate_each(hook, :push_events_branch_filter, "bad branch~name")
expect(hook.errors[:push_events_branch_filter].empty?).to be false
end
- it 'allows wildcards' do
+ it "allows wildcards" do
validator.validate_each(hook, :push_events_branch_filter, "features/*")
validator.validate_each(hook, :push_events_branch_filter, "features/*/bla")
validator.validate_each(hook, :push_events_branch_filter, "*-stable")
expect(hook.errors.empty?).to be true
end
- it 'gets rid of whitespace' do
- filter = ' master '
+ it "gets rid of whitespace" do
+ filter = " master "
validator.validate_each(hook, :push_events_branch_filter, filter)
- expect(filter).to eq 'master'
+ expect(filter).to eq "master"
end
# Branch names can be quite long but in practice aren't over 255 so 4000 should
# be enough space for a list of branch names but we can increase if needed.
- it 'limits length to 4000 chars' do
- filter = 'a' * 4001
+ it "limits length to 4000 chars" do
+ filter = "a" * 4001
validator.validate_each(hook, :push_events_branch_filter, filter)
expect(hook.errors[:push_events_branch_filter].empty?).to be false
diff --git a/spec/validators/js_regex_validator_spec.rb b/spec/validators/js_regex_validator_spec.rb
index 4d3bafaf267..37ce921960b 100644
--- a/spec/validators/js_regex_validator_spec.rb
+++ b/spec/validators/js_regex_validator_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe JsRegexValidator do
- describe '#validates_each' do
+ describe "#validates_each" do
using RSpec::Parameterized::TableSyntax
let(:validator) { described_class.new(attributes: [:user_default_internal_regex]) }
@@ -9,13 +9,13 @@ describe JsRegexValidator do
where(:user_default_internal_regex, :result) do
nil | []
- '' | []
- '(?#comment)' | ['Regex Pattern (?#comment) can not be expressed in Javascript']
- '(?(a)b|c)' | ['invalid conditional pattern: /(?(a)b|c)/i']
+ "" | []
+ "(?#comment)" | ["Regex Pattern (?#comment) can not be expressed in Javascript"]
+ "(?(a)b|c)" | ["invalid conditional pattern: /(?(a)b|c)/i"]
end
with_them do
- it 'generates correct errors' do
+ it "generates correct errors" do
validator.validate_each(application_setting, :user_default_internal_regex, user_default_internal_regex)
expect(application_setting.errors[:user_default_internal_regex]).to eq result
diff --git a/spec/validators/namespace_path_validator_spec.rb b/spec/validators/namespace_path_validator_spec.rb
index 61e2845f35f..46b272b6a3c 100644
--- a/spec/validators/namespace_path_validator_spec.rb
+++ b/spec/validators/namespace_path_validator_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe NamespacePathValidator do
let(:validator) { described_class.new(attributes: [:path]) }
- describe '.valid_path?' do
- it 'handles invalid utf8' do
+ describe ".valid_path?" do
+ it "handles invalid utf8" do
expect(described_class.valid_path?("a\0weird\255path")).to be_falsey
end
end
- describe '#validates_each' do
- it 'adds a message when the path is not in the correct format' do
+ describe "#validates_each" do
+ it "adds a message when the path is not in the correct format" do
group = build(:group)
validator.validate_each(group, :path, "Path with spaces, and comma's!")
@@ -18,21 +18,21 @@ describe NamespacePathValidator do
expect(group.errors[:path]).to include(Gitlab::PathRegex.namespace_format_message)
end
- it 'adds a message when the path is reserved when creating' do
- group = build(:group, path: 'help')
+ it "adds a message when the path is reserved when creating" do
+ group = build(:group, path: "help")
- validator.validate_each(group, :path, 'help')
+ validator.validate_each(group, :path, "help")
- expect(group.errors[:path]).to include('help is a reserved name')
+ expect(group.errors[:path]).to include("help is a reserved name")
end
- it 'adds a message when the path is reserved when updating' do
+ it "adds a message when the path is reserved when updating" do
group = create(:group)
- group.path = 'help'
+ group.path = "help"
- validator.validate_each(group, :path, 'help')
+ validator.validate_each(group, :path, "help")
- expect(group.errors[:path]).to include('help is a reserved name')
+ expect(group.errors[:path]).to include("help is a reserved name")
end
end
end
diff --git a/spec/validators/project_path_validator_spec.rb b/spec/validators/project_path_validator_spec.rb
index 8bb5e72dc22..d1ac3869f97 100644
--- a/spec/validators/project_path_validator_spec.rb
+++ b/spec/validators/project_path_validator_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectPathValidator do
let(:validator) { described_class.new(attributes: [:path]) }
- describe '.valid_path?' do
- it 'handles invalid utf8' do
+ describe ".valid_path?" do
+ it "handles invalid utf8" do
expect(described_class.valid_path?("a\0weird\255path")).to be_falsey
end
end
- describe '#validates_each' do
- it 'adds a message when the path is not in the correct format' do
+ describe "#validates_each" do
+ it "adds a message when the path is not in the correct format" do
project = build(:project)
validator.validate_each(project, :path, "Path with spaces, and comma's!")
@@ -18,21 +18,21 @@ describe ProjectPathValidator do
expect(project.errors[:path]).to include(Gitlab::PathRegex.project_path_format_message)
end
- it 'adds a message when the path is reserved when creating' do
- project = build(:project, path: 'blob')
+ it "adds a message when the path is reserved when creating" do
+ project = build(:project, path: "blob")
- validator.validate_each(project, :path, 'blob')
+ validator.validate_each(project, :path, "blob")
- expect(project.errors[:path]).to include('blob is a reserved name')
+ expect(project.errors[:path]).to include("blob is a reserved name")
end
- it 'adds a message when the path is reserved when updating' do
+ it "adds a message when the path is reserved when updating" do
project = create(:project)
- project.path = 'blob'
+ project.path = "blob"
- validator.validate_each(project, :path, 'blob')
+ validator.validate_each(project, :path, "blob")
- expect(project.errors[:path]).to include('blob is a reserved name')
+ expect(project.errors[:path]).to include("blob is a reserved name")
end
end
end
diff --git a/spec/validators/public_url_validator_spec.rb b/spec/validators/public_url_validator_spec.rb
index 710dd3dc38e..816d87589a1 100644
--- a/spec/validators/public_url_validator_spec.rb
+++ b/spec/validators/public_url_validator_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe PublicUrlValidator do
- include_examples 'url validator examples', described_class::DEFAULT_PROTOCOLS
+ include_examples "url validator examples", described_class::DEFAULT_PROTOCOLS
- context 'by default' do
+ context "by default" do
let(:validator) { described_class.new(attributes: [:link_url]) }
- let!(:badge) { build(:badge, link_url: 'http://www.example.com') }
+ let!(:badge) { build(:badge, link_url: "http://www.example.com") }
subject { validator.validate_each(badge, :link_url, badge.link_url) }
- it 'blocks urls pointing to localhost' do
- badge.link_url = 'https://127.0.0.1'
+ it "blocks urls pointing to localhost" do
+ badge.link_url = "https://127.0.0.1"
subject
expect(badge.errors.empty?).to be false
end
- it 'blocks urls pointing to the local network' do
- badge.link_url = 'https://192.168.1.1'
+ it "blocks urls pointing to the local network" do
+ badge.link_url = "https://192.168.1.1"
subject
diff --git a/spec/validators/url_validator_spec.rb b/spec/validators/url_validator_spec.rb
index 1bb42382e8a..483a30b0581 100644
--- a/spec/validators/url_validator_spec.rb
+++ b/spec/validators/url_validator_spec.rb
@@ -1,57 +1,57 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe UrlValidator do
- let!(:badge) { build(:badge, link_url: 'http://www.example.com') }
+ let!(:badge) { build(:badge, link_url: "http://www.example.com") }
subject { validator.validate_each(badge, :link_url, badge.link_url) }
- include_examples 'url validator examples', described_class::DEFAULT_PROTOCOLS
+ include_examples "url validator examples", described_class::DEFAULT_PROTOCOLS
- describe 'validations' do
- include_context 'invalid urls'
+ describe "validations" do
+ include_context "invalid urls"
let(:validator) { described_class.new(attributes: [:link_url]) }
- it 'returns error when url is nil' do
+ it "returns error when url is nil" do
expect(validator.validate_each(badge, :link_url, nil)).to be_nil
- expect(badge.errors.first[1]).to eq 'must be a valid URL'
+ expect(badge.errors.first[1]).to eq "must be a valid URL"
end
- it 'returns error when url is empty' do
- expect(validator.validate_each(badge, :link_url, '')).to be_nil
- expect(badge.errors.first[1]).to eq 'must be a valid URL'
+ it "returns error when url is empty" do
+ expect(validator.validate_each(badge, :link_url, "")).to be_nil
+ expect(badge.errors.first[1]).to eq "must be a valid URL"
end
- it 'does not allow urls with CR or LF characters' do
+ it "does not allow urls with CR or LF characters" do
aggregate_failures do
urls_with_CRLF.each do |url|
- expect(validator.validate_each(badge, :link_url, url)[0]).to eq 'is blocked: URI is invalid'
+ expect(validator.validate_each(badge, :link_url, url)[0]).to eq "is blocked: URI is invalid"
end
end
end
end
- context 'by default' do
+ context "by default" do
let(:validator) { described_class.new(attributes: [:link_url]) }
- it 'does not block urls pointing to localhost' do
- badge.link_url = 'https://127.0.0.1'
+ it "does not block urls pointing to localhost" do
+ badge.link_url = "https://127.0.0.1"
subject
expect(badge.errors.empty?).to be true
end
- it 'does not block urls pointing to the local network' do
- badge.link_url = 'https://192.168.1.1'
+ it "does not block urls pointing to the local network" do
+ badge.link_url = "https://192.168.1.1"
subject
expect(badge.errors.empty?).to be true
end
- it 'strips urls' do
+ it "strips urls" do
badge.link_url = "\n\r\n\nhttps://127.0.0.1\r\n\r\n\n\n\n"
# It's unusual for a validator to modify its arguments. Some extensions,
@@ -63,15 +63,15 @@ describe UrlValidator do
subject
expect(badge.errors).to be_empty
- expect(badge.link_url).to eq('https://127.0.0.1')
+ expect(badge.link_url).to eq("https://127.0.0.1")
end
end
- context 'when allow_localhost is set to false' do
+ context "when allow_localhost is set to false" do
let(:validator) { described_class.new(attributes: [:link_url], allow_localhost: false) }
- it 'blocks urls pointing to localhost' do
- badge.link_url = 'https://127.0.0.1'
+ it "blocks urls pointing to localhost" do
+ badge.link_url = "https://127.0.0.1"
subject
@@ -79,11 +79,11 @@ describe UrlValidator do
end
end
- context 'when allow_local_network is set to false' do
+ context "when allow_local_network is set to false" do
let(:validator) { described_class.new(attributes: [:link_url], allow_local_network: false) }
- it 'blocks urls pointing to the local network' do
- badge.link_url = 'https://192.168.1.1'
+ it "blocks urls pointing to the local network" do
+ badge.link_url = "https://192.168.1.1"
subject
@@ -91,23 +91,23 @@ describe UrlValidator do
end
end
- context 'when ports is' do
+ context "when ports is" do
let(:validator) { described_class.new(attributes: [:link_url], ports: ports) }
- context 'empty' do
+ context "empty" do
let(:ports) { [] }
- it 'does not block any port' do
+ it "does not block any port" do
subject
expect(badge.errors.empty?).to be true
end
end
- context 'set' do
+ context "set" do
let(:ports) { [443] }
- it 'blocks urls with a different port' do
+ it "blocks urls with a different port" do
subject
expect(badge.errors.empty?).to be false
@@ -115,14 +115,14 @@ describe UrlValidator do
end
end
- context 'when enforce_user is' do
- let(:url) { 'http://$user@example.com'}
+ context "when enforce_user is" do
+ let(:url) { "http://$user@example.com"}
let(:validator) { described_class.new(attributes: [:link_url], enforce_user: enforce_user) }
- context 'true' do
+ context "true" do
let(:enforce_user) { true }
- it 'checks user format' do
+ it "checks user format" do
badge.link_url = url
subject
@@ -131,10 +131,10 @@ describe UrlValidator do
end
end
- context 'false (default)' do
+ context "false (default)" do
let(:enforce_user) { false }
- it 'does not check user format' do
+ it "does not check user format" do
badge.link_url = url
subject
@@ -144,14 +144,14 @@ describe UrlValidator do
end
end
- context 'when ascii_only is' do
- let(:url) { 'https://𝕘itⅼαƄ.com/foo/foo.bar'}
+ context "when ascii_only is" do
+ let(:url) { "https://𝕘itⅼαƄ.com/foo/foo.bar"}
let(:validator) { described_class.new(attributes: [:link_url], ascii_only: ascii_only) }
- context 'true' do
+ context "true" do
let(:ascii_only) { true }
- it 'prevents unicode characters' do
+ it "prevents unicode characters" do
badge.link_url = url
subject
@@ -160,10 +160,10 @@ describe UrlValidator do
end
end
- context 'false (default)' do
+ context "false (default)" do
let(:ascii_only) { false }
- it 'does not prevent unicode characters' do
+ it "does not prevent unicode characters" do
badge.link_url = url
subject
@@ -173,20 +173,20 @@ describe UrlValidator do
end
end
- context 'when enforce_sanitization is' do
+ context "when enforce_sanitization is" do
let(:validator) { described_class.new(attributes: [:link_url], enforce_sanitization: enforce_sanitization) }
let(:unsafe_url) { "https://replaceme.com/'><script>alert(document.cookie)</script>" }
- let(:safe_url) { 'https://replaceme.com/path/to/somewhere' }
+ let(:safe_url) { "https://replaceme.com/path/to/somewhere" }
let(:unsafe_internal_url) do
- Gitlab.config.gitlab.protocol + '://' + Gitlab.config.gitlab.host +
+ Gitlab.config.gitlab.protocol + "://" + Gitlab.config.gitlab.host +
"/'><script>alert(document.cookie)</script>"
end
- context 'true' do
+ context "true" do
let(:enforce_sanitization) { true }
- it 'prevents unsafe urls' do
+ it "prevents unsafe urls" do
badge.link_url = unsafe_url
subject
@@ -194,7 +194,7 @@ describe UrlValidator do
expect(badge.errors.empty?).to be false
end
- it 'prevents unsafe internal urls' do
+ it "prevents unsafe internal urls" do
badge.link_url = unsafe_internal_url
subject
@@ -202,7 +202,7 @@ describe UrlValidator do
expect(badge.errors.empty?).to be false
end
- it 'allows safe urls' do
+ it "allows safe urls" do
badge.link_url = safe_url
subject
@@ -211,10 +211,10 @@ describe UrlValidator do
end
end
- context 'false' do
+ context "false" do
let(:enforce_sanitization) { false }
- it 'allows unsafe urls' do
+ it "allows unsafe urls" do
badge.link_url = unsafe_url
subject
diff --git a/spec/validators/variable_duplicates_validator_spec.rb b/spec/validators/variable_duplicates_validator_spec.rb
index 0b71a67f94d..3e64683765e 100644
--- a/spec/validators/variable_duplicates_validator_spec.rb
+++ b/spec/validators/variable_duplicates_validator_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe VariableDuplicatesValidator do
let(:validator) { described_class.new(attributes: [:variables], **options) }
- describe '#validate_each' do
+ describe "#validate_each" do
let(:project) { build(:project) }
subject { validator.validate_each(project, :variables, project.variables) }
- context 'with no scope' do
+ context "with no scope" do
let(:options) { {} }
let(:variables) { build_list(:ci_variable, 2, project: project) }
@@ -16,18 +16,18 @@ describe VariableDuplicatesValidator do
project.variables << variables
end
- it 'does not have any errors' do
+ it "does not have any errors" do
subject
expect(project.errors.empty?).to be true
end
- context 'with duplicates' do
+ context "with duplicates" do
before do
- project.variables.build(key: variables.first.key, value: 'dummy_value')
+ project.variables.build(key: variables.first.key, value: "dummy_value")
end
- it 'has a duplicate key error' do
+ it "has a duplicate key error" do
subject
expect(project.errors).to have_key(:variables)
@@ -35,28 +35,28 @@ describe VariableDuplicatesValidator do
end
end
- context 'with a scope attribute' do
- let(:options) { { scope: :environment_scope } }
- let(:first_variable) { build(:ci_variable, key: 'test_key', environment_scope: '*', project: project) }
- let(:second_variable) { build(:ci_variable, key: 'test_key', environment_scope: 'prod', project: project) }
+ context "with a scope attribute" do
+ let(:options) { {scope: :environment_scope} }
+ let(:first_variable) { build(:ci_variable, key: "test_key", environment_scope: "*", project: project) }
+ let(:second_variable) { build(:ci_variable, key: "test_key", environment_scope: "prod", project: project) }
before do
project.variables << first_variable
project.variables << second_variable
end
- it 'does not have any errors' do
+ it "does not have any errors" do
subject
expect(project.errors.empty?).to be true
end
- context 'with duplicates' do
+ context "with duplicates" do
before do
- project.variables.build(key: second_variable.key, value: 'dummy_value', environment_scope: second_variable.environment_scope)
+ project.variables.build(key: second_variable.key, value: "dummy_value", environment_scope: second_variable.environment_scope)
end
- it 'has a duplicate key error' do
+ it "has a duplicate key error" do
subject
expect(project.errors).to have_key(:variables)
diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb
index 0e8b7c82d3a..a59392aad8a 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'admin/dashboard/index.html.haml' do
+describe "admin/dashboard/index.html.haml" do
include Devise::Test::ControllerHelpers
before do
- counts = Admin::DashboardController::COUNTED_ITEMS.each_with_object({}) do |item, hash|
+ counts = Admin::DashboardController::COUNTED_ITEMS.each_with_object({}) { |item, hash|
hash[item] = 100
- end
+ }
assign(:counts, counts)
assign(:projects, create_list(:project, 1))
@@ -20,7 +20,7 @@ describe 'admin/dashboard/index.html.haml' do
it "shows version of GitLab Workhorse" do
render
- expect(rendered).to have_content 'GitLab Workhorse'
+ expect(rendered).to have_content "GitLab Workhorse"
expect(rendered).to have_content Gitlab::Workhorse.version
end
diff --git a/spec/views/ci/status/_badge.html.haml_spec.rb b/spec/views/ci/status/_badge.html.haml_spec.rb
index 49f57969239..63b0515c8cf 100644
--- a/spec/views/ci/status/_badge.html.haml_spec.rb
+++ b/spec/views/ci/status/_badge.html.haml_spec.rb
@@ -1,88 +1,88 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'ci/status/_badge' do
+describe "ci/status/_badge" do
let(:user) { create(:user) }
let(:project) { create(:project, :private) }
let(:pipeline) { create(:ci_pipeline, project: project) }
- context 'when rendering status for build' do
+ context "when rendering status for build" do
let(:build) do
create(:ci_build, :success, pipeline: pipeline)
end
- context 'when user has ability to see details' do
+ context "when user has ability to see details" do
before do
project.add_developer(user)
end
- it 'has link to build details page' do
+ it "has link to build details page" do
details_path = project_job_path(project, build)
render_status(build)
- expect(rendered).to have_link 'passed', href: details_path
+ expect(rendered).to have_link "passed", href: details_path
end
end
- context 'when user do not have ability to see build details' do
+ context "when user do not have ability to see build details" do
before do
render_status(build)
end
- it 'contains build status text' do
- expect(rendered).to have_content 'passed'
+ it "contains build status text" do
+ expect(rendered).to have_content "passed"
end
- it 'does not contain links' do
- expect(rendered).not_to have_link 'passed'
+ it "does not contain links" do
+ expect(rendered).not_to have_link "passed"
end
end
end
- context 'when rendering status for external job' do
- context 'when user has ability to see commit status details' do
+ context "when rendering status for external job" do
+ context "when user has ability to see commit status details" do
before do
project.add_developer(user)
end
- context 'status has external target url' do
+ context "status has external target url" do
before do
external_job = create(:generic_commit_status,
- status: :running,
- pipeline: pipeline,
- target_url: 'http://gitlab.com')
+ status: :running,
+ pipeline: pipeline,
+ target_url: "http://gitlab.com")
render_status(external_job)
end
- it 'contains valid commit status text' do
- expect(rendered).to have_content 'running'
+ it "contains valid commit status text" do
+ expect(rendered).to have_content "running"
end
- it 'has link to external status page' do
- expect(rendered).to have_link 'running', href: 'http://gitlab.com'
+ it "has link to external status page" do
+ expect(rendered).to have_link "running", href: "http://gitlab.com"
end
end
- context 'status do not have external target url' do
+ context "status do not have external target url" do
before do
external_job = create(:generic_commit_status, status: :canceled)
render_status(external_job)
end
- it 'contains valid commit status text' do
- expect(rendered).to have_content 'canceled'
+ it "contains valid commit status text" do
+ expect(rendered).to have_content "canceled"
end
- it 'has link to external status page' do
- expect(rendered).not_to have_link 'canceled'
+ it "has link to external status page" do
+ expect(rendered).not_to have_link "canceled"
end
end
end
end
def render_status(resource)
- render 'ci/status/badge', status: resource.detailed_status(user)
+ render "ci/status/badge", status: resource.detailed_status(user)
end
end
diff --git a/spec/views/dashboard/projects/_blank_state_admin_welcome.haml.rb b/spec/views/dashboard/projects/_blank_state_admin_welcome.haml.rb
index 2f58eec86dc..4a8d9e07b64 100644
--- a/spec/views/dashboard/projects/_blank_state_admin_welcome.haml.rb
+++ b/spec/views/dashboard/projects/_blank_state_admin_welcome.haml.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'dashboard/projects/_blank_state_admin_welcome.html.haml' do
+describe "dashboard/projects/_blank_state_admin_welcome.html.haml" do
let(:user) { create(:admin) }
before do
allow(view).to receive(:current_user).and_return(user)
end
- it 'links to new group path' do
+ it "links to new group path" do
render
- expect(rendered).to have_link('Create a group', href: new_group_path)
+ expect(rendered).to have_link("Create a group", href: new_group_path)
end
end
diff --git a/spec/views/dashboard/projects/_nav.html.haml.rb b/spec/views/dashboard/projects/_nav.html.haml.rb
index f6a8ca13040..67680e56317 100644
--- a/spec/views/dashboard/projects/_nav.html.haml.rb
+++ b/spec/views/dashboard/projects/_nav.html.haml.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'dashboard/projects/_nav.html.haml' do
- it 'highlights All tab by default' do
+describe "dashboard/projects/_nav.html.haml" do
+ it "highlights All tab by default" do
render
- expect(rendered).to have_css('li.active a', text: 'All')
+ expect(rendered).to have_css("li.active a", text: "All")
end
- it 'highlights Personal tab personal param is present' do
+ it "highlights Personal tab personal param is present" do
controller.params[:personal] = true
render
- expect(rendered).to have_css('li.active a', text: 'Personal')
+ expect(rendered).to have_css("li.active a", text: "Personal")
end
end
diff --git a/spec/views/devise/shared/_signin_box.html.haml_spec.rb b/spec/views/devise/shared/_signin_box.html.haml_spec.rb
index 66c064e3fba..7560036fd5b 100644
--- a/spec/views/devise/shared/_signin_box.html.haml_spec.rb
+++ b/spec/views/devise/shared/_signin_box.html.haml_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'devise/shared/_signin_box' do
- describe 'Crowd form' do
+describe "devise/shared/_signin_box" do
+ describe "Crowd form" do
before do
stub_devise
assign(:ldap_servers, [])
@@ -9,18 +9,18 @@ describe 'devise/shared/_signin_box' do
allow(view).to receive(:captcha_enabled?).and_return(false)
end
- it 'is shown when Crowd is enabled' do
+ it "is shown when Crowd is enabled" do
enable_crowd
render
- expect(rendered).to have_selector('#crowd form')
+ expect(rendered).to have_selector("#crowd form")
end
- it 'is not shown when Crowd is disabled' do
+ it "is not shown when Crowd is disabled" do
render
- expect(rendered).not_to have_selector('#crowd')
+ expect(rendered).not_to have_selector("#crowd")
end
end
@@ -34,6 +34,6 @@ describe 'devise/shared/_signin_box' do
allow(view).to receive(:form_based_providers).and_return([:crowd])
allow(view).to receive(:crowd_enabled?).and_return(true)
allow(view).to receive(:omniauth_authorize_path).with(:user, :crowd)
- .and_return('/crowd')
+ .and_return("/crowd")
end
end
diff --git a/spec/views/errors/access_denied.html.haml_spec.rb b/spec/views/errors/access_denied.html.haml_spec.rb
index bde2f6f0169..a907b9fb8ee 100644
--- a/spec/views/errors/access_denied.html.haml_spec.rb
+++ b/spec/views/errors/access_denied.html.haml_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'errors/access_denied' do
- it 'does not fail to render when there is no message provided' do
+describe "errors/access_denied" do
+ it "does not fail to render when there is no message provided" do
expect { render }.not_to raise_error
end
end
diff --git a/spec/views/events/event/_push.html.haml_spec.rb b/spec/views/events/event/_push.html.haml_spec.rb
index f5634de4916..8420b59ead3 100644
--- a/spec/views/events/event/_push.html.haml_spec.rb
+++ b/spec/views/events/event/_push.html.haml_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'events/event/_push.html.haml' do
+describe "events/event/_push.html.haml" do
let(:event) { build_stubbed(:push_event) }
- context 'with a branch' do
+ context "with a branch" do
let(:payload) { build_stubbed(:push_event_payload, event: event) }
before do
allow(event).to receive(:push_event_payload).and_return(payload)
end
- it 'links to the branch' do
+ it "links to the branch" do
allow(event.project.repository).to receive(:branch_exists?).with(event.ref_name).and_return(true)
link = project_commits_path(event.project, event.ref_name)
- render partial: 'events/event/push', locals: { event: event }
+ render partial: "events/event/push", locals: {event: event}
expect(rendered).to have_link(event.ref_name, href: link)
end
- context 'that has been deleted' do
- it 'does not link to the branch' do
- render partial: 'events/event/push', locals: { event: event }
+ context "that has been deleted" do
+ it "does not link to the branch" do
+ render partial: "events/event/push", locals: {event: event}
expect(rendered).not_to have_link(event.ref_name)
end
end
end
- context 'with a tag' do
- let(:payload) { build_stubbed(:push_event_payload, event: event, ref_type: :tag, ref: 'v0.1.0') }
+ context "with a tag" do
+ let(:payload) { build_stubbed(:push_event_payload, event: event, ref_type: :tag, ref: "v0.1.0") }
before do
allow(event).to receive(:push_event_payload).and_return(payload)
end
- it 'links to the tag' do
+ it "links to the tag" do
allow(event.project.repository).to receive(:tag_exists?).with(event.ref_name).and_return(true)
link = project_commits_path(event.project, event.ref_name)
- render partial: 'events/event/push', locals: { event: event }
+ render partial: "events/event/push", locals: {event: event}
expect(rendered).to have_link(event.ref_name, href: link)
end
- context 'that has been deleted' do
- it 'does not link to the tag' do
- render partial: 'events/event/push', locals: { event: event }
+ context "that has been deleted" do
+ it "does not link to the tag" do
+ render partial: "events/event/push", locals: {event: event}
expect(rendered).not_to have_link(event.ref_name)
end
diff --git a/spec/views/groups/edit.html.haml_spec.rb b/spec/views/groups/edit.html.haml_spec.rb
index 38cfb84f0d5..8427c9d8d1c 100644
--- a/spec/views/groups/edit.html.haml_spec.rb
+++ b/spec/views/groups/edit.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'groups/edit.html.haml' do
+describe "groups/edit.html.haml" do
include Devise::Test::ControllerHelpers
describe '"Share with group lock" setting' do
@@ -12,46 +12,46 @@ describe 'groups/edit.html.haml' do
end
shared_examples_for '"Share with group lock" setting' do |checkbox_options|
- it 'should have the correct label, help text, and checkbox options' do
+ it "should have the correct label, help text, and checkbox options" do
assign(:group, test_group)
allow(view).to receive(:can?).with(test_user, :admin_group, test_group).and_return(true)
allow(view).to receive(:can_change_group_visibility_level?).and_return(false)
allow(view).to receive(:current_user).and_return(test_user)
expect(view).to receive(:can_change_share_with_group_lock?).and_return(!checkbox_options[:disabled])
- expect(view).to receive(:share_with_group_lock_help_text).and_return('help text here')
+ expect(view).to receive(:share_with_group_lock_help_text).and_return("help text here")
render
expect(rendered).to have_content("Prevent sharing a project within #{test_group.name} with other groups")
- expect(rendered).to have_css('.descr', text: 'help text here')
- expect(rendered).to have_field('group_share_with_group_lock', checkbox_options)
+ expect(rendered).to have_css(".descr", text: "help text here")
+ expect(rendered).to have_field("group_share_with_group_lock", checkbox_options)
end
end
- context 'for a root group' do
+ context "for a root group" do
let(:test_group) { root_group }
let(:test_user) { root_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: false}
end
- context 'for a subgroup', :nested_groups do
+ context "for a subgroup", :nested_groups do
let!(:subgroup) { create(:group, parent: root_group) }
let(:sub_owner) { create(:user) }
let(:test_group) { subgroup }
context 'when the root_group has "Share with group lock" disabled' do
context 'when the subgroup has "Share with group lock" disabled' do
- context 'as the root_owner' do
+ context "as the root_owner" do
let(:test_user) { root_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: false}
end
- context 'as the sub_owner' do
+ context "as the sub_owner" do
let(:test_user) { sub_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: false}
end
end
@@ -60,16 +60,16 @@ describe 'groups/edit.html.haml' do
subgroup.update_column(:share_with_group_lock, true)
end
- context 'as the root_owner' do
+ context "as the root_owner" do
let(:test_user) { root_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: true}
end
- context 'as the sub_owner' do
+ context "as the sub_owner" do
let(:test_user) { sub_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: true}
end
end
end
@@ -80,16 +80,16 @@ describe 'groups/edit.html.haml' do
end
context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do
- context 'as the root_owner' do
+ context "as the root_owner" do
let(:test_user) { root_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: false}
end
- context 'as the sub_owner' do
+ context "as the sub_owner" do
let(:test_user) { sub_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: false}
end
end
@@ -98,16 +98,16 @@ describe 'groups/edit.html.haml' do
subgroup.update_column(:share_with_group_lock, true)
end
- context 'as the root_owner' do
+ context "as the root_owner" do
let(:test_user) { root_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true }
+ it_behaves_like '"Share with group lock" setting', {disabled: false, checked: true}
end
- context 'as the sub_owner' do
+ context "as the sub_owner" do
let(:test_user) { sub_owner }
- it_behaves_like '"Share with group lock" setting', { disabled: true, checked: true }
+ it_behaves_like '"Share with group lock" setting', {disabled: true, checked: true}
end
end
end
diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb
index 34e93d929a7..06ef459a4fb 100644
--- a/spec/views/help/index.html.haml_spec.rb
+++ b/spec/views/help/index.html.haml_spec.rb
@@ -1,52 +1,52 @@
# frozen_string_literal: true
-require 'rails_helper'
+require "rails_helper"
-describe 'help/index' do
+describe "help/index" do
include StubVersion
- describe 'version information' do
+ describe "version information" do
before do
stub_helpers
end
- it 'is hidden from guests' do
+ it "is hidden from guests" do
stub_user(nil)
- stub_version('8.0.2', 'abcdefg')
+ stub_version("8.0.2", "abcdefg")
render
- expect(rendered).not_to match '8.0.2'
- expect(rendered).not_to match 'abcdefg'
+ expect(rendered).not_to match "8.0.2"
+ expect(rendered).not_to match "abcdefg"
end
- context 'when logged in' do
+ context "when logged in" do
before do
stub_user
end
- it 'shows a link to the tag to users' do
- stub_version('8.0.2', 'abcdefg')
+ it "shows a link to the tag to users" do
+ stub_version("8.0.2", "abcdefg")
render
- expect(rendered).to match '8.0.2'
- expect(rendered).to have_link('8.0.2', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/tags/v8.0.2})
+ expect(rendered).to match "8.0.2"
+ expect(rendered).to have_link("8.0.2", href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/tags/v8.0.2})
end
- it 'shows a link to the commit for pre-releases' do
- stub_version('8.0.2-pre', 'abcdefg')
+ it "shows a link to the commit for pre-releases" do
+ stub_version("8.0.2-pre", "abcdefg")
render
- expect(rendered).to match '8.0.2'
- expect(rendered).to have_link('abcdefg', href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/commits/abcdefg})
+ expect(rendered).to match "8.0.2"
+ expect(rendered).to have_link("abcdefg", href: %r{https://gitlab.com/gitlab-org/gitlab-(ce|ee)/commits/abcdefg})
end
end
end
- describe 'instance configuration link' do
- it 'is visible to guests' do
+ describe "instance configuration link" do
+ it "is visible to guests" do
render
expect(rendered).to have_link(nil, href: help_instance_configuration_url)
@@ -58,8 +58,8 @@ describe 'help/index' do
end
def stub_helpers
- allow(view).to receive(:markdown).and_return('')
- allow(view).to receive(:version_status_badge).and_return('')
+ allow(view).to receive(:markdown).and_return("")
+ allow(view).to receive(:version_status_badge).and_return("")
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
end
diff --git a/spec/views/help/instance_configuration.html.haml_spec.rb b/spec/views/help/instance_configuration.html.haml_spec.rb
index ceb7e34a540..a34f0aaefd5 100644
--- a/spec/views/help/instance_configuration.html.haml_spec.rb
+++ b/spec/views/help/instance_configuration.html.haml_spec.rb
@@ -1,7 +1,7 @@
-require 'rails_helper'
+require "rails_helper"
-describe 'help/instance_configuration' do
- describe 'General Sections:' do
+describe "help/instance_configuration" do
+ describe "General Sections:" do
let(:instance_configuration) { build(:instance_configuration)}
let(:settings) { instance_configuration.settings }
let(:ssh_settings) { settings[:ssh_algorithms_hashes] }
@@ -10,20 +10,20 @@ describe 'help/instance_configuration' do
assign(:instance_configuration, instance_configuration)
end
- it 'has links to several sections' do
+ it "has links to several sections" do
render
- expect(rendered).to have_link(nil, href: '#ssh-host-keys-fingerprints') if ssh_settings.any?
- expect(rendered).to have_link(nil, href: '#gitlab-pages')
- expect(rendered).to have_link(nil, href: '#gitlab-ci')
+ expect(rendered).to have_link(nil, href: "#ssh-host-keys-fingerprints") if ssh_settings.any?
+ expect(rendered).to have_link(nil, href: "#gitlab-pages")
+ expect(rendered).to have_link(nil, href: "#gitlab-ci")
end
- it 'has several sections' do
+ it "has several sections" do
render
- expect(rendered).to have_css('h2#ssh-host-keys-fingerprints') if ssh_settings.any?
- expect(rendered).to have_css('h2#gitlab-pages')
- expect(rendered).to have_css('h2#gitlab-ci')
+ expect(rendered).to have_css("h2#ssh-host-keys-fingerprints") if ssh_settings.any?
+ expect(rendered).to have_css("h2#gitlab-pages")
+ expect(rendered).to have_css("h2#gitlab-ci")
end
end
end
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb
index cbb4199954a..2987c1e1124 100644
--- a/spec/views/layouts/_head.html.haml_spec.rb
+++ b/spec/views/layouts/_head.html.haml_spec.rb
@@ -1,68 +1,68 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'layouts/_head' do
+describe "layouts/_head" do
before do
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
- it 'escapes HTML-safe strings in page_title' do
+ it "escapes HTML-safe strings in page_title" do
stub_helper_with_safe_string(:page_title)
render
- expect(rendered).to match(%{content="foo&quot; http-equiv=&quot;refresh"})
+ expect(rendered).to match(%(content="foo&quot; http-equiv=&quot;refresh"))
end
- it 'escapes HTML-safe strings in page_description' do
+ it "escapes HTML-safe strings in page_description" do
stub_helper_with_safe_string(:page_description)
render
- expect(rendered).to match(%{content="foo&quot; http-equiv=&quot;refresh"})
+ expect(rendered).to match(%(content="foo&quot; http-equiv=&quot;refresh"))
end
- it 'escapes HTML-safe strings in page_image' do
+ it "escapes HTML-safe strings in page_image" do
stub_helper_with_safe_string(:page_image)
render
- expect(rendered).to match(%{content="foo&quot; http-equiv=&quot;refresh"})
+ expect(rendered).to match(%(content="foo&quot; http-equiv=&quot;refresh"))
end
- context 'when an asset_host is set and feature is activated in the config it will' do
- let(:asset_host) { 'http://assets' }
+ context "when an asset_host is set and feature is activated in the config it will" do
+ let(:asset_host) { "http://assets" }
before do
stub_feature_flags(asset_host_prefetch: true)
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
end
- it 'add a link dns-prefetch tag' do
+ it "add a link dns-prefetch tag" do
render
expect(rendered).to match('<link href="http://assets" rel="dns-prefetch">')
end
- it 'add a link preconnect tag' do
+ it "add a link preconnect tag" do
render
expect(rendered).to match('<link crossorigin="" href="http://assets" rel="preconnnect">')
end
end
- context 'when an asset_host is set and feature is not activated in the config it will' do
- let(:asset_host) { 'http://assets' }
+ context "when an asset_host is set and feature is not activated in the config it will" do
+ let(:asset_host) { "http://assets" }
before do
stub_feature_flags(asset_host_prefetch: false)
allow(ActionController::Base).to receive(:asset_host).and_return(asset_host)
end
- it 'not add a link dns-prefetch tag' do
+ it "not add a link dns-prefetch tag" do
render
expect(rendered).not_to match('<link href="http://assets" rel="dns-prefetch">')
end
end
- it 'adds selected syntax highlight stylesheet' do
+ it "adds selected syntax highlight stylesheet" do
allow_any_instance_of(PreferencesHelper).to receive(:user_color_scheme).and_return("solarised-light")
render
@@ -72,6 +72,6 @@ describe 'layouts/_head' do
def stub_helper_with_safe_string(method)
allow_any_instance_of(PageLayoutHelper).to receive(method)
- .and_return(%q{foo" http-equiv="refresh}.html_safe)
+ .and_return('foo" http-equiv="refresh'.html_safe)
end
end
diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
index 2e19d0cec26..27767a0ac3e 100644
--- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb
+++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
@@ -1,11 +1,11 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'layouts/header/_new_dropdown' do
+describe "layouts/header/_new_dropdown" do
let(:user) { create(:user) }
- context 'group-specific links' do
+ context "group-specific links" do
let(:group) { create(:group) }
before do
@@ -14,7 +14,7 @@ describe 'layouts/header/_new_dropdown' do
assign(:group, group)
end
- context 'as a Group owner' do
+ context "as a Group owner" do
before do
group.add_owner(user)
end
@@ -23,7 +23,7 @@ describe 'layouts/header/_new_dropdown' do
render
expect(rendered).to have_link(
- 'New project',
+ "New project",
href: new_project_path(namespace_id: group.id)
)
end
@@ -32,21 +32,21 @@ describe 'layouts/header/_new_dropdown' do
render
expect(rendered).to have_link(
- 'New subgroup',
+ "New subgroup",
href: new_group_path(parent_id: group.id)
)
end
end
end
- context 'project-specific links' do
+ context "project-specific links" do
let(:project) { create(:project, creator: user, namespace: user.namespace) }
before do
assign(:project, project)
end
- context 'as a Project owner' do
+ context "as a Project owner" do
before do
stub_current_user(user)
end
@@ -55,7 +55,7 @@ describe 'layouts/header/_new_dropdown' do
render
expect(rendered).to have_link(
- 'New issue',
+ "New issue",
href: new_project_issue_path(project)
)
end
@@ -64,7 +64,7 @@ describe 'layouts/header/_new_dropdown' do
render
expect(rendered).to have_link(
- 'New merge request',
+ "New merge request",
href: project_new_merge_request_path(project)
)
end
@@ -73,13 +73,13 @@ describe 'layouts/header/_new_dropdown' do
render
expect(rendered).to have_link(
- 'New snippet',
+ "New snippet",
href: new_project_snippet_path(project)
)
end
end
- context 'as a Project guest' do
+ context "as a Project guest" do
let(:guest) { create(:user) }
before do
@@ -90,21 +90,21 @@ describe 'layouts/header/_new_dropdown' do
it 'has no "New merge request" link' do
render
- expect(rendered).not_to have_link('New merge request')
+ expect(rendered).not_to have_link("New merge request")
end
it 'has no "New snippet" link' do
render
expect(rendered).not_to have_link(
- 'New snippet',
+ "New snippet",
href: new_project_snippet_path(project)
)
end
end
end
- context 'global links' do
+ context "global links" do
before do
stub_current_user(user)
end
@@ -112,19 +112,19 @@ describe 'layouts/header/_new_dropdown' do
it 'has a "New project" link' do
render
- expect(rendered).to have_link('New project', href: new_project_path)
+ expect(rendered).to have_link("New project", href: new_project_path)
end
it 'has a "New group" link' do
render
- expect(rendered).to have_link('New group', href: new_group_path)
+ expect(rendered).to have_link("New group", href: new_group_path)
end
it 'has a "New snippet" link' do
render
- expect(rendered).to have_link('New snippet', href: new_snippet_path)
+ expect(rendered).to have_link("New snippet", href: new_snippet_path)
end
end
diff --git a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
index 05c2f61a606..0fe5131ee1c 100644
--- a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
@@ -1,90 +1,90 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'layouts/nav/sidebar/_admin' do
- shared_examples 'page has active tab' do |title|
+describe "layouts/nav/sidebar/_admin" do
+ shared_examples "page has active tab" do |title|
it "activates #{title} tab" do
render
- expect(rendered).to have_selector('.nav-sidebar .sidebar-top-level-items > li.active', count: 1)
- expect(rendered).to have_css('.nav-sidebar .sidebar-top-level-items > li.active', text: title)
+ expect(rendered).to have_selector(".nav-sidebar .sidebar-top-level-items > li.active", count: 1)
+ expect(rendered).to have_css(".nav-sidebar .sidebar-top-level-items > li.active", text: title)
end
end
- shared_examples 'page has active sub tab' do |title|
+ shared_examples "page has active sub tab" do |title|
it "activates #{title} sub tab" do
render
- expect(rendered).to have_css('.sidebar-sub-level-items > li.active', text: title)
+ expect(rendered).to have_css(".sidebar-sub-level-items > li.active", text: title)
end
end
- context 'on home page' do
+ context "on home page" do
before do
- allow(controller).to receive(:controller_name).and_return('dashboard')
+ allow(controller).to receive(:controller_name).and_return("dashboard")
end
- it_behaves_like 'page has active tab', 'Overview'
+ it_behaves_like "page has active tab", "Overview"
end
- context 'on projects' do
+ context "on projects" do
before do
- allow(controller).to receive(:controller_name).and_return('projects')
- allow(controller).to receive(:controller_path).and_return('admin/projects')
+ allow(controller).to receive(:controller_name).and_return("projects")
+ allow(controller).to receive(:controller_path).and_return("admin/projects")
end
- it_behaves_like 'page has active tab', 'Overview'
- it_behaves_like 'page has active sub tab', 'Projects'
+ it_behaves_like "page has active tab", "Overview"
+ it_behaves_like "page has active sub tab", "Projects"
end
- context 'on groups' do
+ context "on groups" do
before do
- allow(controller).to receive(:controller_name).and_return('groups')
+ allow(controller).to receive(:controller_name).and_return("groups")
end
- it_behaves_like 'page has active tab', 'Overview'
- it_behaves_like 'page has active sub tab', 'Groups'
+ it_behaves_like "page has active tab", "Overview"
+ it_behaves_like "page has active sub tab", "Groups"
end
- context 'on users' do
+ context "on users" do
before do
- allow(controller).to receive(:controller_name).and_return('users')
+ allow(controller).to receive(:controller_name).and_return("users")
end
- it_behaves_like 'page has active tab', 'Overview'
- it_behaves_like 'page has active sub tab', 'Users'
+ it_behaves_like "page has active tab", "Overview"
+ it_behaves_like "page has active sub tab", "Users"
end
- context 'on logs' do
+ context "on logs" do
before do
- allow(controller).to receive(:controller_name).and_return('logs')
+ allow(controller).to receive(:controller_name).and_return("logs")
end
- it_behaves_like 'page has active tab', 'Monitoring'
- it_behaves_like 'page has active sub tab', 'Logs'
+ it_behaves_like "page has active tab", "Monitoring"
+ it_behaves_like "page has active sub tab", "Logs"
end
- context 'on messages' do
+ context "on messages" do
before do
- allow(controller).to receive(:controller_name).and_return('broadcast_messages')
+ allow(controller).to receive(:controller_name).and_return("broadcast_messages")
end
- it_behaves_like 'page has active tab', 'Messages'
+ it_behaves_like "page has active tab", "Messages"
end
- context 'on hooks' do
+ context "on hooks" do
before do
- allow(controller).to receive(:controller_name).and_return('hooks')
+ allow(controller).to receive(:controller_name).and_return("hooks")
end
- it_behaves_like 'page has active tab', 'Hooks'
+ it_behaves_like "page has active tab", "Hooks"
end
- context 'on background jobs' do
+ context "on background jobs" do
before do
- allow(controller).to receive(:controller_name).and_return('background_jobs')
+ allow(controller).to receive(:controller_name).and_return("background_jobs")
end
- it_behaves_like 'page has active tab', 'Monitoring'
- it_behaves_like 'page has active sub tab', 'Background Jobs'
+ it_behaves_like "page has active tab", "Monitoring"
+ it_behaves_like "page has active sub tab", "Background Jobs"
end
end
diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
index d9f05e5f94f..9105437d602 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -1,91 +1,91 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'layouts/nav/sidebar/_project' do
+describe "layouts/nav/sidebar/_project" do
let(:project) { create(:project, :repository) }
before do
assign(:project, project)
assign(:repository, project.repository)
- allow(view).to receive(:current_ref).and_return('master')
+ allow(view).to receive(:current_ref).and_return("master")
allow(view).to receive(:can?).and_return(true)
end
- describe 'issue boards' do
- it 'has board tab' do
+ describe "issue boards" do
+ it "has board tab" do
render
expect(rendered).to have_css('a[title="Board"]')
end
end
- describe 'container registry tab' do
+ describe "container registry tab" do
before do
stub_container_registry_config(enabled: true)
allow(controller).to receive(:controller_name)
- .and_return('repositories')
+ .and_return("repositories")
allow(controller).to receive(:controller_path)
- .and_return('projects/registry/repositories')
+ .and_return("projects/registry/repositories")
end
- it 'has both Registry and Repository tabs' do
+ it "has both Registry and Repository tabs" do
render
- expect(rendered).to have_text 'Repository'
- expect(rendered).to have_text 'Registry'
+ expect(rendered).to have_text "Repository"
+ expect(rendered).to have_text "Registry"
end
- it 'highlights sidebar item and flyout' do
+ it "highlights sidebar item and flyout" do
render
- expect(rendered).to have_css('.sidebar-top-level-items > li.active', count: 1)
- expect(rendered).to have_css('.is-fly-out-only > li.active', count: 1)
+ expect(rendered).to have_css(".sidebar-top-level-items > li.active", count: 1)
+ expect(rendered).to have_css(".is-fly-out-only > li.active", count: 1)
end
- it 'highlights container registry tab' do
+ it "highlights container registry tab" do
render
- expect(rendered).to have_css('.sidebar-top-level-items > li.active', text: 'Registry')
+ expect(rendered).to have_css(".sidebar-top-level-items > li.active", text: "Registry")
end
end
- describe 'releases entry' do
- it 'renders releases link' do
+ describe "releases entry" do
+ it "renders releases link" do
render
- expect(rendered).to have_link('Releases', href: project_releases_path(project))
+ expect(rendered).to have_link("Releases", href: project_releases_path(project))
end
end
- describe 'wiki entry tab' do
+ describe "wiki entry tab" do
let(:can_read_wiki) { true }
before do
allow(view).to receive(:can?).with(nil, :read_wiki, project).and_return(can_read_wiki)
end
- describe 'when wiki is enabled' do
- it 'shows the wiki tab with the wiki internal link' do
+ describe "when wiki is enabled" do
+ it "shows the wiki tab with the wiki internal link" do
render
- expect(rendered).to have_link('Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).to have_link("Wiki", href: project_wiki_path(project, :home))
end
end
- describe 'when wiki is disabled' do
+ describe "when wiki is disabled" do
let(:can_read_wiki) { false }
- it 'does not show the wiki tab' do
+ it "does not show the wiki tab" do
render
- expect(rendered).not_to have_link('Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).not_to have_link("Wiki", href: project_wiki_path(project, :home))
end
end
end
- describe 'external wiki entry tab' do
- let(:properties) { { 'external_wiki_url' => 'https://gitlab.com' } }
+ describe "external wiki entry tab" do
+ let(:properties) { {"external_wiki_url" => "https://gitlab.com"} }
let(:service_status) { true }
before do
@@ -93,21 +93,21 @@ describe 'layouts/nav/sidebar/_project' do
project.reload
end
- context 'when it is active' do
- it 'shows the external wiki tab with the external wiki service link' do
+ context "when it is active" do
+ it "shows the external wiki tab with the external wiki service link" do
render
- expect(rendered).to have_link('External Wiki', href: properties['external_wiki_url'])
+ expect(rendered).to have_link("External Wiki", href: properties["external_wiki_url"])
end
end
- context 'when it is disabled' do
+ context "when it is disabled" do
let(:service_status) { false }
- it 'does not show the external wiki tab' do
+ it "does not show the external wiki tab" do
render
- expect(rendered).not_to have_link('External Wiki', href: project_wiki_path(project, :home))
+ expect(rendered).not_to have_link("External Wiki", href: project_wiki_path(project, :home))
end
end
end
diff --git a/spec/views/notify/changed_milestone_email.html.haml_spec.rb b/spec/views/notify/changed_milestone_email.html.haml_spec.rb
index 194b58840a3..1867e0f7b5a 100644
--- a/spec/views/notify/changed_milestone_email.html.haml_spec.rb
+++ b/spec/views/notify/changed_milestone_email.html.haml_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'notify/changed_milestone_email.html.haml' do
- let(:milestone) { create(:milestone, title: 'some-milestone') }
+describe "notify/changed_milestone_email.html.haml" do
+ let(:milestone) { create(:milestone, title: "some-milestone") }
let(:milestone_link) { milestone_url(milestone) }
before do
@@ -11,25 +11,25 @@ describe 'notify/changed_milestone_email.html.haml' do
assign(:milestone_url, milestone_link)
end
- context 'milestone without start and due dates' do
- it 'renders without date range' do
+ context "milestone without start and due dates" do
+ it "renders without date range" do
render
- expect(rendered).to have_content('Milestone changed to some-milestone', exact: true)
- expect(rendered).to have_link('some-milestone', href: milestone_link)
+ expect(rendered).to have_content("Milestone changed to some-milestone", exact: true)
+ expect(rendered).to have_link("some-milestone", href: milestone_link)
end
end
- context 'milestone with start and due dates' do
+ context "milestone with start and due dates" do
before do
- milestone.update(start_date: '2018-01-01', due_date: '2018-12-31')
+ milestone.update(start_date: "2018-01-01", due_date: "2018-12-31")
end
- it 'renders with date range' do
+ it "renders with date range" do
render
- expect(rendered).to have_content('Milestone changed to some-milestone (Jan 1, 2018–Dec 31, 2018)', exact: true)
- expect(rendered).to have_link('some-milestone', href: milestone_link)
+ expect(rendered).to have_content("Milestone changed to some-milestone (Jan 1, 2018–Dec 31, 2018)", exact: true)
+ expect(rendered).to have_link("some-milestone", href: milestone_link)
end
end
end
diff --git a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
index d9d73f789c5..3d0e8873125 100644
--- a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'notify/pipeline_failed_email.html.haml' do
+describe "notify/pipeline_failed_email.html.haml" do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
@@ -9,11 +9,11 @@ describe 'notify/pipeline_failed_email.html.haml' do
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- user: user,
- ref: project.default_branch,
- sha: project.commit.sha,
- status: :success)
+ project: project,
+ user: user,
+ ref: project.default_branch,
+ sha: project.commit.sha,
+ status: :success)
end
before do
@@ -22,8 +22,8 @@ describe 'notify/pipeline_failed_email.html.haml' do
assign(:merge_request, merge_request)
end
- context 'pipeline with user' do
- it 'renders the email correctly' do
+ context "pipeline with user" do
+ it "renders the email correctly" do
render
expect(rendered).to have_content "Your pipeline has failed"
@@ -35,12 +35,12 @@ describe 'notify/pipeline_failed_email.html.haml' do
end
end
- context 'pipeline without user' do
+ context "pipeline without user" do
before do
pipeline.update_attribute(:user, nil)
end
- it 'renders the email correctly' do
+ it "renders the email correctly" do
render
expect(rendered).to have_content "Your pipeline has failed"
diff --git a/spec/views/notify/pipeline_success_email.html.haml_spec.rb b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
index a793b37e412..be5b8950d97 100644
--- a/spec/views/notify/pipeline_success_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'notify/pipeline_success_email.html.haml' do
+describe "notify/pipeline_success_email.html.haml" do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
@@ -9,11 +9,11 @@ describe 'notify/pipeline_success_email.html.haml' do
let(:pipeline) do
create(:ci_pipeline,
- project: project,
- user: user,
- ref: project.default_branch,
- sha: project.commit.sha,
- status: :success)
+ project: project,
+ user: user,
+ ref: project.default_branch,
+ sha: project.commit.sha,
+ status: :success)
end
before do
@@ -22,8 +22,8 @@ describe 'notify/pipeline_success_email.html.haml' do
assign(:merge_request, merge_request)
end
- context 'pipeline with user' do
- it 'renders the email correctly' do
+ context "pipeline with user" do
+ it "renders the email correctly" do
render
expect(rendered).to have_content "Your pipeline has passed"
@@ -35,12 +35,12 @@ describe 'notify/pipeline_success_email.html.haml' do
end
end
- context 'pipeline without user' do
+ context "pipeline without user" do
before do
pipeline.update_attribute(:user, nil)
end
- it 'renders the email correctly' do
+ it "renders the email correctly" do
render
expect(rendered).to have_content "Your pipeline has passed"
diff --git a/spec/views/profiles/show.html.haml_spec.rb b/spec/views/profiles/show.html.haml_spec.rb
index e89a8cb9626..f649c42faf8 100644
--- a/spec/views/profiles/show.html.haml_spec.rb
+++ b/spec/views/profiles/show.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'profiles/show' do
+describe "profiles/show" do
let(:user) { create(:user) }
before do
@@ -8,12 +8,12 @@ describe 'profiles/show' do
allow(controller).to receive(:current_user).and_return(user)
end
- context 'when the profile page is opened' do
- it 'displays the correct elements' do
+ context "when the profile page is opened" do
+ it "displays the correct elements" do
render
- expect(rendered).to have_field('user_name', user.name)
- expect(rendered).to have_field('user_id', user.id)
+ expect(rendered).to have_field("user_name", user.name)
+ expect(rendered).to have_field("user_id", user.id)
end
end
end
diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb
index 908ecb898e4..51125ae2243 100644
--- a/spec/views/projects/_home_panel.html.haml_spec.rb
+++ b/spec/views/projects/_home_panel.html.haml_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/_home_panel' do
- context 'notifications' do
+describe "projects/_home_panel" do
+ context "notifications" do
let(:project) { create(:project) }
before do
@@ -12,7 +12,7 @@ describe 'projects/_home_panel' do
allow(project).to receive(:license_anchor_data).and_return(false)
end
- context 'when user is signed in' do
+ context "when user is signed in" do
let(:user) { create(:user) }
before do
@@ -20,35 +20,35 @@ describe 'projects/_home_panel' do
assign(:notification_setting, notification_settings)
end
- it 'makes it possible to set notification level' do
+ it "makes it possible to set notification level" do
render
- expect(view).to render_template('shared/notifications/_new_button')
- expect(rendered).to have_selector('.notification-dropdown')
+ expect(view).to render_template("shared/notifications/_new_button")
+ expect(rendered).to have_selector(".notification-dropdown")
end
end
- context 'when user is signed out' do
+ context "when user is signed out" do
let(:user) { nil }
before do
assign(:notification_setting, nil)
end
- it 'is not possible to set notification level' do
+ it "is not possible to set notification level" do
render
- expect(rendered).not_to have_selector('.notification_dropdown')
+ expect(rendered).not_to have_selector(".notification_dropdown")
end
end
end
- context 'badges' do
- shared_examples 'show badges' do
- it 'should render the all badges' do
+ context "badges" do
+ shared_examples "show badges" do
+ it "should render the all badges" do
render
- expect(rendered).to have_selector('.project-badges a')
+ expect(rendered).to have_selector(".project-badges a")
badges.each do |badge|
expect(rendered).to have_link(href: badge.rendered_link_url)
@@ -67,17 +67,17 @@ describe 'projects/_home_panel' do
allow(project).to receive(:license_anchor_data).and_return(false)
end
- context 'has no badges' do
+ context "has no badges" do
let(:project) { create(:project) }
- it 'should not render any badge' do
+ it "should not render any badge" do
render
- expect(rendered).not_to have_selector('.project-badges')
+ expect(rendered).not_to have_selector(".project-badges")
end
end
- context 'only has group badges' do
+ context "only has group badges" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
@@ -85,20 +85,20 @@ describe 'projects/_home_panel' do
create(:group_badge, group: project.group)
end
- it_behaves_like 'show badges'
+ it_behaves_like "show badges"
end
- context 'only has project badges' do
+ context "only has project badges" do
let(:project) { create(:project) }
before do
create(:project_badge, project: project)
end
- it_behaves_like 'show badges'
+ it_behaves_like "show badges"
end
- context 'has both group and project badges' do
+ context "has both group and project badges" do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
@@ -107,11 +107,11 @@ describe 'projects/_home_panel' do
create(:group_badge, group: project.group)
end
- it_behaves_like 'show badges'
+ it_behaves_like "show badges"
end
end
- context 'project id' do
+ context "project id" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -122,8 +122,8 @@ describe 'projects/_home_panel' do
allow(project).to receive(:license_anchor_data).and_return(false)
end
- context 'user can read project' do
- it 'is shown' do
+ context "user can read project" do
+ it "is shown" do
allow(view).to receive(:can?).with(user, :read_project, project).and_return(true)
render
@@ -132,8 +132,8 @@ describe 'projects/_home_panel' do
end
end
- context 'user cannot read project' do
- it 'is not shown' do
+ context "user cannot read project" do
+ it "is not shown" do
allow(view).to receive(:can?).with(user, :read_project, project).and_return(false)
render
diff --git a/spec/views/projects/blob/_viewer.html.haml_spec.rb b/spec/views/projects/blob/_viewer.html.haml_spec.rb
index 95f7f87d37b..a07c14460b4 100644
--- a/spec/views/projects/blob/_viewer.html.haml_spec.rb
+++ b/spec/views/projects/blob/_viewer.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/blob/_viewer.html.haml' do
+describe "projects/blob/_viewer.html.haml" do
include FakeBlobHelpers
let(:project) { build(:project) }
@@ -9,7 +9,7 @@ describe 'projects/blob/_viewer.html.haml' do
Class.new(BlobViewer::Base) do
include BlobViewer::Rich
- self.partial_name = 'text'
+ self.partial_name = "text"
self.collapse_limit = 1.megabyte
self.size_limit = 5.megabytes
self.load_async = true
@@ -22,77 +22,77 @@ describe 'projects/blob/_viewer.html.haml' do
before do
assign(:project, project)
assign(:blob, blob)
- assign(:id, File.join('master', blob.path))
+ assign(:id, File.join("master", blob.path))
- controller.params[:controller] = 'projects/blob'
- controller.params[:action] = 'show'
+ controller.params[:controller] = "projects/blob"
+ controller.params[:action] = "show"
controller.params[:namespace_id] = project.namespace.to_param
controller.params[:project_id] = project.to_param
- controller.params[:id] = File.join('master', blob.path)
+ controller.params[:id] = File.join("master", blob.path)
allow(project.repository).to receive(:gitattribute).and_return(nil)
end
def render_view
- render partial: 'projects/blob/viewer', locals: { viewer: viewer }
+ render partial: "projects/blob/viewer", locals: {viewer: viewer}
end
- context 'when the viewer is loaded asynchronously' do
+ context "when the viewer is loaded asynchronously" do
before do
viewer_class.load_async = true
end
- context 'when there is no render error' do
- it 'adds a URL to the blob viewer element' do
+ context "when there is no render error" do
+ it "adds a URL to the blob viewer element" do
render_view
- expect(rendered).to have_css('.blob-viewer[data-url]')
+ expect(rendered).to have_css(".blob-viewer[data-url]")
end
- it 'renders the loading indicator' do
+ it "renders the loading indicator" do
render_view
- expect(view).to render_template('projects/blob/viewers/_loading')
+ expect(view).to render_template("projects/blob/viewers/_loading")
end
end
- context 'when there is a render error' do
+ context "when there is a render error" do
let(:blob) { fake_blob(size: 10.megabytes) }
- it 'renders the error' do
+ it "renders the error" do
render_view
- expect(view).to render_template('projects/blob/_render_error')
+ expect(view).to render_template("projects/blob/_render_error")
end
end
end
- context 'when the viewer is loaded synchronously' do
+ context "when the viewer is loaded synchronously" do
before do
viewer_class.load_async = false
end
- context 'when there is no render error' do
- it 'prepares the viewer' do
+ context "when there is no render error" do
+ it "prepares the viewer" do
expect(viewer).to receive(:prepare!)
render_view
end
- it 'renders the viewer' do
+ it "renders the viewer" do
render_view
- expect(view).to render_template('projects/blob/viewers/_text')
+ expect(view).to render_template("projects/blob/viewers/_text")
end
end
- context 'when there is a render error' do
+ context "when there is a render error" do
let(:blob) { fake_blob(size: 10.megabytes) }
- it 'renders the error' do
+ it "renders the error" do
render_view
- expect(view).to render_template('projects/blob/_render_error')
+ expect(view).to render_template("projects/blob/_render_error")
end
end
end
diff --git a/spec/views/projects/buttons/_dropdown.html.haml_spec.rb b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
index 8b9aab30286..23d6e5d95c8 100644
--- a/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
+++ b/spec/views/projects/buttons/_dropdown.html.haml_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/buttons/_dropdown' do
+describe "projects/buttons/_dropdown" do
let(:user) { create(:user) }
- context 'user with all abilities' do
+ context "user with all abilities" do
before do
assign(:project, project)
@@ -12,28 +12,28 @@ describe 'projects/buttons/_dropdown' do
allow(view).to receive(:can_collaborate_with_project?).and_return(true)
end
- context 'empty repository' do
+ context "empty repository" do
let(:project) { create(:project, :empty_repo) }
- it 'has a link to create a new file' do
+ it "has a link to create a new file" do
render
- expect(view).to render_template('projects/buttons/_dropdown')
- expect(rendered).to have_link('New file')
+ expect(view).to render_template("projects/buttons/_dropdown")
+ expect(rendered).to have_link("New file")
end
- it 'does not have a link to create a new branch' do
+ it "does not have a link to create a new branch" do
render
- expect(view).to render_template('projects/buttons/_dropdown')
- expect(rendered).not_to have_link('New branch')
+ expect(view).to render_template("projects/buttons/_dropdown")
+ expect(rendered).not_to have_link("New branch")
end
- it 'does not have a link to create a new tag' do
+ it "does not have a link to create a new tag" do
render
- expect(view).to render_template('projects/buttons/_dropdown')
- expect(rendered).not_to have_link('New tag')
+ expect(view).to render_template("projects/buttons/_dropdown")
+ expect(rendered).not_to have_link("New tag")
end
end
end
diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb
index 2f0cd38c14a..9efc704a4d5 100644
--- a/spec/views/projects/ci/lints/show.html.haml_spec.rb
+++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/ci/lints/show' do
+describe "projects/ci/lints/show" do
include Devise::Test::ControllerHelpers
let(:project) { create(:project, :repository) }
let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) }
- describe 'XSS protection' do
+ describe "XSS protection" do
before do
assign(:project, project)
assign(:status, true)
@@ -14,51 +14,51 @@ describe 'projects/ci/lints/show' do
assign(:jobs, config_processor.jobs)
end
- context 'when builds attrbiutes contain HTML nodes' do
+ context "when builds attrbiutes contain HTML nodes" do
let(:content) do
{
rspec: {
- script: '<h1>rspec</h1>',
- stage: 'test'
- }
+ script: "<h1>rspec</h1>",
+ stage: "test",
+ },
}
end
- it 'does not render HTML elements' do
+ it "does not render HTML elements" do
render
- expect(rendered).not_to have_css('h1', text: 'rspec')
+ expect(rendered).not_to have_css("h1", text: "rspec")
end
end
- context 'when builds attributes do not contain HTML nodes' do
+ context "when builds attributes do not contain HTML nodes" do
let(:content) do
{
rspec: {
- script: 'rspec',
- stage: 'test'
- }
+ script: "rspec",
+ stage: "test",
+ },
}
end
- it 'shows configuration in the table' do
+ it "shows configuration in the table" do
render
- expect(rendered).to have_css('td pre', text: 'rspec')
+ expect(rendered).to have_css("td pre", text: "rspec")
end
end
end
- context 'when the content is valid' do
+ context "when the content is valid" do
let(:content) do
{
build_template: {
- script: './build.sh',
- tags: ['dotnet'],
- only: ['test@dude/repo'],
- except: ['deploy'],
- environment: 'testing'
- }
+ script: "./build.sh",
+ tags: ["dotnet"],
+ only: ["test@dude/repo"],
+ except: ["deploy"],
+ environment: "testing",
+ },
}
end
@@ -70,30 +70,30 @@ describe 'projects/ci/lints/show' do
assign(:jobs, config_processor.jobs)
end
- it 'shows the correct values' do
+ it "shows the correct values" do
render
- expect(rendered).to have_content('Tag list: dotnet')
- expect(rendered).to have_content('Only policy: refs, test@dude/repo')
- expect(rendered).to have_content('Except policy: refs, deploy')
- expect(rendered).to have_content('Environment: testing')
- expect(rendered).to have_content('When: on_success')
+ expect(rendered).to have_content("Tag list: dotnet")
+ expect(rendered).to have_content("Only policy: refs, test@dude/repo")
+ expect(rendered).to have_content("Except policy: refs, deploy")
+ expect(rendered).to have_content("Environment: testing")
+ expect(rendered).to have_content("When: on_success")
end
end
- context 'when the content is invalid' do
+ context "when the content is invalid" do
before do
assign(:project, project)
assign(:status, false)
- assign(:error, 'Undefined error')
+ assign(:error, "Undefined error")
end
- it 'shows error message' do
+ it "shows error message" do
render
- expect(rendered).to have_content('Status: syntax is incorrect')
- expect(rendered).to have_content('Error: Undefined error')
- expect(rendered).not_to have_content('Tag list:')
+ expect(rendered).to have_content("Status: syntax is incorrect")
+ expect(rendered).to have_content("Error: Undefined error")
+ expect(rendered).not_to have_content("Tag list:")
end
end
end
diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
index 1086546c10d..628bb7c50f2 100644
--- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb
+++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/commit/_commit_box.html.haml' do
+describe "projects/commit/_commit_box.html.haml" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
@@ -12,18 +12,18 @@ describe 'projects/commit/_commit_box.html.haml' do
project.add_developer(user)
end
- it 'shows the commit SHA' do
+ it "shows the commit SHA" do
render
- expect(rendered).to have_text("#{Commit.truncate_sha(project.commit.sha)}")
+ expect(rendered).to have_text(Commit.truncate_sha(project.commit.sha).to_s)
end
- context 'when there is a pipeline present' do
- context 'when there are multiple pipelines for a commit' do
- it 'shows the last pipeline' do
- create(:ci_pipeline, project: project, sha: project.commit.id, status: 'success')
- create(:ci_pipeline, project: project, sha: project.commit.id, status: 'canceled')
- third_pipeline = create(:ci_pipeline, project: project, sha: project.commit.id, status: 'failed')
+ context "when there is a pipeline present" do
+ context "when there are multiple pipelines for a commit" do
+ it "shows the last pipeline" do
+ create(:ci_pipeline, project: project, sha: project.commit.id, status: "success")
+ create(:ci_pipeline, project: project, sha: project.commit.id, status: "canceled")
+ third_pipeline = create(:ci_pipeline, project: project, sha: project.commit.id, status: "failed")
render
@@ -31,43 +31,43 @@ describe 'projects/commit/_commit_box.html.haml' do
end
end
- context 'when pipeline for the commit is blocked' do
+ context "when pipeline for the commit is blocked" do
let!(:pipeline) do
create(:ci_pipeline, :blocked, project: project,
sha: project.commit.id)
end
- it 'shows correct pipeline description' do
+ it "shows correct pipeline description" do
render
expect(rendered).to have_text "Pipeline ##{pipeline.id} " \
- 'waiting for manual action'
+ "waiting for manual action"
end
end
end
- context 'viewing a commit' do
- context 'as a developer' do
+ context "viewing a commit" do
+ context "as a developer" do
before do
allow(view).to receive(:can_collaborate_with_project?).and_return(true)
end
- it 'has a link to create a new tag' do
+ it "has a link to create a new tag" do
render
- expect(rendered).to have_link('Tag')
+ expect(rendered).to have_link("Tag")
end
end
- context 'as a non-developer' do
+ context "as a non-developer" do
before do
project.add_guest(user)
end
- it 'does not have a link to create a new tag' do
+ it "does not have a link to create a new tag" do
render
- expect(rendered).not_to have_link('Tag')
+ expect(rendered).not_to have_link("Tag")
end
end
end
diff --git a/spec/views/projects/commit/branches.html.haml_spec.rb b/spec/views/projects/commit/branches.html.haml_spec.rb
index b9d4dc80fe0..59ff753ac19 100644
--- a/spec/views/projects/commit/branches.html.haml_spec.rb
+++ b/spec/views/projects/commit/branches.html.haml_spec.rb
@@ -1,39 +1,39 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/commit/branches.html.haml' do
+describe "projects/commit/branches.html.haml" do
let(:project) { create(:project, :repository) }
before do
assign(:project, project)
end
- context 'when branches and tags are available' do
+ context "when branches and tags are available" do
before do
- assign(:branches, ['master', 'test-branch'])
+ assign(:branches, ["master", "test-branch"])
assign(:branches_limit_exceeded, false)
- assign(:tags, ['tag1'])
+ assign(:tags, ["tag1"])
assign(:tags_limit_exceeded, false)
render
end
- it 'shows default branch' do
- expect(rendered).to have_link('master')
+ it "shows default branch" do
+ expect(rendered).to have_link("master")
end
- it 'shows js expand link' do
- expect(rendered).to have_selector('.js-details-expand')
+ it "shows js expand link" do
+ expect(rendered).to have_selector(".js-details-expand")
end
- it 'shows branch and tag links' do
- expect(rendered).to have_link('test-branch')
- expect(rendered).to have_link('tag1')
+ it "shows branch and tag links" do
+ expect(rendered).to have_link("test-branch")
+ expect(rendered).to have_link("tag1")
end
end
- context 'when branches are available but no tags' do
+ context "when branches are available but no tags" do
before do
- assign(:branches, ['master', 'test-branch'])
+ assign(:branches, ["master", "test-branch"])
assign(:branches_limit_exceeded, false)
assign(:tags, [])
assign(:tags_limit_exceeded, true)
@@ -41,51 +41,51 @@ describe 'projects/commit/branches.html.haml' do
render
end
- it 'shows branches' do
- expect(rendered).to have_link('master')
- expect(rendered).to have_link('test-branch')
+ it "shows branches" do
+ expect(rendered).to have_link("master")
+ expect(rendered).to have_link("test-branch")
end
- it 'shows js expand link' do
- expect(rendered).to have_selector('.js-details-expand')
+ it "shows js expand link" do
+ expect(rendered).to have_selector(".js-details-expand")
end
- it 'shows limit exceeded message for tags' do
- expect(rendered).to have_text('Tags unavailable')
+ it "shows limit exceeded message for tags" do
+ expect(rendered).to have_text("Tags unavailable")
end
end
- context 'when tags are available but no branches (just default)' do
+ context "when tags are available but no branches (just default)" do
before do
- assign(:branches, ['master'])
+ assign(:branches, ["master"])
assign(:branches_limit_exceeded, true)
- assign(:tags, %w(tag1 tag2))
+ assign(:tags, %w[tag1 tag2])
assign(:tags_limit_exceeded, false)
render
end
- it 'shows default branch' do
- expect(rendered).to have_text('master')
+ it "shows default branch" do
+ expect(rendered).to have_text("master")
end
- it 'shows js expand link' do
- expect(rendered).to have_selector('.js-details-expand')
+ it "shows js expand link" do
+ expect(rendered).to have_selector(".js-details-expand")
end
- it 'shows tags' do
- expect(rendered).to have_link('tag1')
- expect(rendered).to have_link('tag2')
+ it "shows tags" do
+ expect(rendered).to have_link("tag1")
+ expect(rendered).to have_link("tag2")
end
- it 'shows limit exceeded for branches' do
- expect(rendered).to have_text('Branches unavailable')
+ it "shows limit exceeded for branches" do
+ expect(rendered).to have_text("Branches unavailable")
end
end
- context 'when branches and tags are not available' do
+ context "when branches and tags are not available" do
before do
- assign(:branches, ['master'])
+ assign(:branches, ["master"])
assign(:branches_limit_exceeded, true)
assign(:tags, [])
assign(:tags_limit_exceeded, true)
@@ -93,17 +93,17 @@ describe 'projects/commit/branches.html.haml' do
render
end
- it 'shows default branch' do
- expect(rendered).to have_text('master')
+ it "shows default branch" do
+ expect(rendered).to have_text("master")
end
- it 'shows js expand link' do
- expect(rendered).to have_selector('.js-details-expand')
+ it "shows js expand link" do
+ expect(rendered).to have_selector(".js-details-expand")
end
- it 'shows too many to search' do
- expect(rendered).to have_text('Branches unavailable')
- expect(rendered).to have_text('Tags unavailable')
+ it "shows too many to search" do
+ expect(rendered).to have_text("Branches unavailable")
+ expect(rendered).to have_text("Tags unavailable")
end
end
end
diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb
index d07099489e5..df172947e5c 100644
--- a/spec/views/projects/commit/show.html.haml_spec.rb
+++ b/spec/views/projects/commit/show.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/commit/show.html.haml' do
+describe "projects/commit/show.html.haml" do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
@@ -16,10 +16,10 @@ describe 'projects/commit/show.html.haml' do
allow(view).to receive(:can?).and_return(false)
allow(view).to receive(:can_collaborate_with_project?).and_return(false)
allow(view).to receive(:current_ref).and_return(project.repository.root_ref)
- allow(view).to receive(:diff_btn).and_return('')
+ allow(view).to receive(:diff_btn).and_return("")
end
- context 'inline diff view' do
+ context "inline diff view" do
before do
allow(view).to receive(:diff_view).and_return(:inline)
allow(view).to receive(:diff_view).and_return(:inline)
@@ -27,12 +27,12 @@ describe 'projects/commit/show.html.haml' do
render
end
- it 'has limited width' do
- expect(rendered).to have_selector('.limit-container-width')
+ it "has limited width" do
+ expect(rendered).to have_selector(".limit-container-width")
end
end
- context 'parallel diff view' do
+ context "parallel diff view" do
before do
allow(view).to receive(:diff_view).and_return(:parallel)
allow(view).to receive(:fluid_layout).and_return(true)
@@ -40,12 +40,12 @@ describe 'projects/commit/show.html.haml' do
render
end
- it 'spans full width' do
- expect(rendered).not_to have_selector('.limit-container-width')
+ it "spans full width" do
+ expect(rendered).not_to have_selector(".limit-container-width")
end
end
- context 'in the context of a merge request' do
+ context "in the context of a merge request" do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
before do
@@ -53,7 +53,7 @@ describe 'projects/commit/show.html.haml' do
render
end
- it 'shows that it is in the context of a merge request' do
+ it "shows that it is in the context of a merge request" do
merge_request_url = diffs_project_merge_request_path(project, merge_request, commit_id: commit.id)
expect(rendered).to have_content("This commit is part of merge request")
expect(rendered).to have_link(merge_request.to_reference, href: merge_request_url)
diff --git a/spec/views/projects/commits/_commit.html.haml_spec.rb b/spec/views/projects/commits/_commit.html.haml_spec.rb
index 6bf1b5fd2d0..64a5a8877ad 100644
--- a/spec/views/projects/commits/_commit.html.haml_spec.rb
+++ b/spec/views/projects/commits/_commit.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/commits/_commit.html.haml' do
+describe "projects/commits/_commit.html.haml" do
let(:project) { create(:project, :repository) }
let(:commit) { project.repository.commit(ref) }
@@ -8,24 +8,24 @@ describe 'projects/commits/_commit.html.haml' do
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
- context 'with a signed commit' do
+ context "with a signed commit" do
let(:ref) { GpgHelpers::SIGNED_COMMIT_SHA }
- it 'does not display a loading spinner for GPG status' do
- render partial: 'projects/commits/commit', locals: {
+ it "does not display a loading spinner for GPG status" do
+ render partial: "projects/commits/commit", locals: {
project: project,
ref: ref,
- commit: commit
+ commit: commit,
}
- within '.gpg-status-box' do
- expect(page).not_to have_css('i.fa.fa-spinner.fa-spin')
+ within ".gpg-status-box" do
+ expect(page).not_to have_css("i.fa.fa-spinner.fa-spin")
end
end
end
- context 'with ci status' do
- let(:ref) { 'master' }
+ context "with ci status" do
+ let(:ref) { "master" }
let(:user) { create(:user) }
before do
@@ -35,42 +35,42 @@ describe 'projects/commits/_commit.html.haml' do
create(
:ci_empty_pipeline,
- ref: 'master',
+ ref: "master",
sha: commit.id,
- status: 'success',
+ status: "success",
project: project
)
end
- context 'when pipelines are disabled' do
+ context "when pipelines are disabled" do
before do
allow(project).to receive(:builds_enabled?).and_return(false)
end
- it 'does not display a ci status icon' do
- render partial: 'projects/commits/commit', locals: {
+ it "does not display a ci status icon" do
+ render partial: "projects/commits/commit", locals: {
project: project,
ref: ref,
- commit: commit
+ commit: commit,
}
- expect(rendered).not_to have_css('.ci-status-link')
+ expect(rendered).not_to have_css(".ci-status-link")
end
end
- context 'when pipelines are enabled' do
+ context "when pipelines are enabled" do
before do
allow(project).to receive(:builds_enabled?).and_return(true)
end
- it 'does display a ci status icon when pipelines are enabled' do
- render partial: 'projects/commits/commit', locals: {
+ it "does display a ci status icon when pipelines are enabled" do
+ render partial: "projects/commits/commit", locals: {
project: project,
ref: ref,
- commit: commit
+ commit: commit,
}
- expect(rendered).to have_css('.ci-status-link')
+ expect(rendered).to have_css(".ci-status-link")
end
end
end
diff --git a/spec/views/projects/diffs/_stats.html.haml_spec.rb b/spec/views/projects/diffs/_stats.html.haml_spec.rb
index c7d2f85747c..4db3459d508 100644
--- a/spec/views/projects/diffs/_stats.html.haml_spec.rb
+++ b/spec/views/projects/diffs/_stats.html.haml_spec.rb
@@ -1,56 +1,56 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/diffs/_stats.html.haml' do
+describe "projects/diffs/_stats.html.haml" do
let(:project) { create(:project, :repository) }
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
def render_view
- render partial: "projects/diffs/stats", locals: { diff_files: commit.diffs.diff_files }
+ render partial: "projects/diffs/stats", locals: {diff_files: commit.diffs.diff_files}
end
- context 'when the commit contains several changes' do
- it 'uses plural for additions' do
+ context "when the commit contains several changes" do
+ it "uses plural for additions" do
render_view
- expect(rendered).to have_text('additions')
+ expect(rendered).to have_text("additions")
end
- it 'uses plural for deletions' do
+ it "uses plural for deletions" do
render_view
end
end
- context 'when the commit contains no addition and no deletions' do
- let(:commit) { project.commit('4cd80ccab63c82b4bad16faa5193fbd2aa06df40') }
+ context "when the commit contains no addition and no deletions" do
+ let(:commit) { project.commit("4cd80ccab63c82b4bad16faa5193fbd2aa06df40") }
- it 'uses plural for additions' do
+ it "uses plural for additions" do
render_view
- expect(rendered).to have_text('additions')
+ expect(rendered).to have_text("additions")
end
- it 'uses plural for deletions' do
+ it "uses plural for deletions" do
render_view
- expect(rendered).to have_text('deletions')
+ expect(rendered).to have_text("deletions")
end
end
- context 'when the commit contains exactly one addition and one deletion' do
- let(:commit) { project.commit('08f22f255f082689c0d7d39d19205085311542bc') }
+ context "when the commit contains exactly one addition and one deletion" do
+ let(:commit) { project.commit("08f22f255f082689c0d7d39d19205085311542bc") }
- it 'uses singular for additions' do
+ it "uses singular for additions" do
render_view
- expect(rendered).to have_text('addition')
- expect(rendered).not_to have_text('additions')
+ expect(rendered).to have_text("addition")
+ expect(rendered).not_to have_text("additions")
end
- it 'uses singular for deletions' do
+ it "uses singular for deletions" do
render_view
- expect(rendered).to have_text('deletion')
- expect(rendered).not_to have_text('deletions')
+ expect(rendered).to have_text("deletion")
+ expect(rendered).not_to have_text("deletions")
end
end
end
diff --git a/spec/views/projects/diffs/_viewer.html.haml_spec.rb b/spec/views/projects/diffs/_viewer.html.haml_spec.rb
index 8ac32db5585..486d2a6d8ab 100644
--- a/spec/views/projects/diffs/_viewer.html.haml_spec.rb
+++ b/spec/views/projects/diffs/_viewer.html.haml_spec.rb
@@ -1,17 +1,17 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/diffs/_viewer.html.haml' do
+describe "projects/diffs/_viewer.html.haml" do
include FakeBlobHelpers
let(:project) { create(:project, :repository) }
- let(:commit) { project.commit('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') }
- let(:diff_file) { commit.diffs.diff_file_with_new_path('files/ruby/popen.rb') }
+ let(:commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
+ let(:diff_file) { commit.diffs.diff_file_with_new_path("files/ruby/popen.rb") }
let(:viewer_class) do
Class.new(DiffViewer::Base) do
include DiffViewer::Rich
- self.partial_name = 'text'
+ self.partial_name = "text"
end
end
@@ -20,52 +20,52 @@ describe 'projects/diffs/_viewer.html.haml' do
before do
assign(:project, project)
- controller.params[:controller] = 'projects/commit'
- controller.params[:action] = 'show'
+ controller.params[:controller] = "projects/commit"
+ controller.params[:action] = "show"
controller.params[:namespace_id] = project.namespace.to_param
controller.params[:project_id] = project.to_param
controller.params[:id] = commit.id
end
def render_view
- render partial: 'projects/diffs/viewer', locals: { viewer: viewer }
+ render partial: "projects/diffs/viewer", locals: {viewer: viewer}
end
- context 'when there is a render error' do
+ context "when there is a render error" do
before do
allow(viewer).to receive(:render_error).and_return(:too_large)
end
- it 'renders the error' do
+ it "renders the error" do
render_view
- expect(view).to render_template('projects/diffs/_render_error')
+ expect(view).to render_template("projects/diffs/_render_error")
end
end
- context 'when the viewer is collapsed' do
+ context "when the viewer is collapsed" do
before do
allow(diff_file).to receive(:collapsed?).and_return(true)
end
- it 'renders the collapsed view' do
+ it "renders the collapsed view" do
render_view
- expect(view).to render_template('projects/diffs/_collapsed')
+ expect(view).to render_template("projects/diffs/_collapsed")
end
end
- context 'when there is no render error' do
- it 'prepares the viewer' do
+ context "when there is no render error" do
+ it "prepares the viewer" do
expect(viewer).to receive(:prepare!)
render_view
end
- it 'renders the viewer' do
+ it "renders the viewer" do
render_view
- expect(view).to render_template('projects/diffs/viewers/_text')
+ expect(view).to render_template("projects/diffs/viewers/_text")
end
end
end
diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb
index 5c6b2e4b042..d688fc9a83c 100644
--- a/spec/views/projects/edit.html.haml_spec.rb
+++ b/spec/views/projects/edit.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/edit' do
+describe "projects/edit" do
include Devise::Test::ControllerHelpers
let(:project) { create(:project) }
@@ -15,13 +15,13 @@ describe 'projects/edit' do
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
end
- context 'project export disabled' do
- it 'does not display the project export option' do
+ context "project export disabled" do
+ it "does not display the project export option" do
stub_application_setting(project_export_enabled?: false)
render
- expect(rendered).not_to have_content('Export project')
+ expect(rendered).not_to have_content("Export project")
end
end
end
diff --git a/spec/views/projects/environments/terminal.html.haml_spec.rb b/spec/views/projects/environments/terminal.html.haml_spec.rb
index d2e47225226..126909b8125 100644
--- a/spec/views/projects/environments/terminal.html.haml_spec.rb
+++ b/spec/views/projects/environments/terminal.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/environments/terminal' do
+describe "projects/environments/terminal" do
let!(:environment) { create(:environment, :with_review_app) }
before do
@@ -10,23 +10,23 @@ describe 'projects/environments/terminal' do
allow(view).to receive(:can?).and_return(true)
end
- context 'when environment has external URL' do
- it 'shows external URL button' do
- environment.update_attribute(:external_url, 'https://gitlab.com')
+ context "when environment has external URL" do
+ it "shows external URL button" do
+ environment.update_attribute(:external_url, "https://gitlab.com")
render
- expect(rendered).to have_link(nil, href: 'https://gitlab.com')
+ expect(rendered).to have_link(nil, href: "https://gitlab.com")
end
end
- context 'when environment does not have external URL' do
- it 'shows external URL button' do
+ context "when environment does not have external URL" do
+ it "shows external URL button" do
environment.update_attribute(:external_url, nil)
render
- expect(rendered).not_to have_link(nil, href: 'https://gitlab.com')
+ expect(rendered).not_to have_link(nil, href: "https://gitlab.com")
end
end
end
diff --git a/spec/views/projects/imports/new.html.haml_spec.rb b/spec/views/projects/imports/new.html.haml_spec.rb
index 11fe144d1d2..433e7e402d2 100644
--- a/spec/views/projects/imports/new.html.haml_spec.rb
+++ b/spec/views/projects/imports/new.html.haml_spec.rb
@@ -3,8 +3,8 @@ require "spec_helper"
describe "projects/imports/new.html.haml" do
let(:user) { create(:user) }
- context 'when import fails' do
- let(:project) { create(:project_empty_repo, :import_failed, import_type: :gitlab_project, import_source: '/var/opt/gitlab/gitlab-rails/shared/tmp/project_exports/uploads/t.tar.gz', import_url: nil) }
+ context "when import fails" do
+ let(:project) { create(:project_empty_repo, :import_failed, import_type: :gitlab_project, import_source: "/var/opt/gitlab/gitlab-rails/shared/tmp/project_exports/uploads/t.tar.gz", import_url: nil) }
before do
project.import_state.update(last_error: '<a href="http://googl.com">Foo</a>')
@@ -17,7 +17,7 @@ describe "projects/imports/new.html.haml" do
render
- expect(rendered).not_to have_link('Foo', href: "http://googl.com")
+ expect(rendered).not_to have_link("Foo", href: "http://googl.com")
end
end
end
diff --git a/spec/views/projects/issues/_merge_requests_status.html.haml_spec.rb b/spec/views/projects/issues/_merge_requests_status.html.haml_spec.rb
index 02c225292ce..c2f2ff4bf3d 100644
--- a/spec/views/projects/issues/_merge_requests_status.html.haml_spec.rb
+++ b/spec/views/projects/issues/_merge_requests_status.html.haml_spec.rb
@@ -1,21 +1,22 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe 'projects/issues/_merge_requests_status.html.haml' do
- it 'shows date of status change in tooltip' do
+require "spec_helper"
+
+describe "projects/issues/_merge_requests_status.html.haml" do
+ it "shows date of status change in tooltip" do
merge_request = create(:merge_request, created_at: 1.month.ago)
- render partial: 'projects/issues/merge_requests_status',
- locals: { merge_request: merge_request, css_class: '' }
+ render partial: "projects/issues/merge_requests_status",
+ locals: {merge_request: merge_request, css_class: ""}
expect(rendered).to match("Opened.*about 1 month ago")
end
- it 'shows only status in tooltip if date is not set' do
+ it "shows only status in tooltip if date is not set" do
merge_request = create(:merge_request, state: :closed)
- render partial: 'projects/issues/merge_requests_status',
- locals: { merge_request: merge_request, css_class: '' }
+ render partial: "projects/issues/merge_requests_status",
+ locals: {merge_request: merge_request, css_class: ""}
expect(rendered).to match("Closed")
end
diff --git a/spec/views/projects/issues/_related_branches.html.haml_spec.rb b/spec/views/projects/issues/_related_branches.html.haml_spec.rb
index 5cff7694029..83b2510e0c3 100644
--- a/spec/views/projects/issues/_related_branches.html.haml_spec.rb
+++ b/spec/views/projects/issues/_related_branches.html.haml_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/issues/_related_branches' do
+describe "projects/issues/_related_branches" do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
- let(:branch) { project.repository.find_branch('feature') }
- let!(:pipeline) { create(:ci_pipeline, project: project, sha: branch.dereferenced_target.id, ref: 'feature') }
+ let(:branch) { project.repository.find_branch("feature") }
+ let!(:pipeline) { create(:ci_pipeline, project: project, sha: branch.dereferenced_target.id, ref: "feature") }
before do
assign(:project, project)
- assign(:related_branches, ['feature'])
+ assign(:related_branches, ["feature"])
project.add_developer(user)
allow(view).to receive(:current_user).and_return(user)
@@ -18,8 +18,8 @@ describe 'projects/issues/_related_branches' do
render
end
- it 'shows the related branches with their build status' do
- expect(rendered).to match('feature')
- expect(rendered).to have_css('.related-branch-ci-status')
+ it "shows the related branches with their build status" do
+ expect(rendered).to match("feature")
+ expect(rendered).to have_css(".related-branch-ci-status")
end
end
diff --git a/spec/views/projects/issues/show.html.haml_spec.rb b/spec/views/projects/issues/show.html.haml_spec.rb
index 1d9c6d36ad7..15f913f4a99 100644
--- a/spec/views/projects/issues/show.html.haml_spec.rb
+++ b/spec/views/projects/issues/show.html.haml_spec.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/issues/show' do
+describe "projects/issues/show" do
let(:project) { create(:project, :repository) }
let(:issue) { create(:issue, project: project, author: user) }
let(:user) { create(:user) }
@@ -11,17 +11,17 @@ describe 'projects/issues/show' do
assign(:project, project)
assign(:issue, issue)
assign(:noteable, issue)
- stub_template 'shared/issuable/_sidebar' => ''
- stub_template 'projects/issues/_discussion' => ''
- allow(view).to receive(:issuable_meta).and_return('')
+ stub_template "shared/issuable/_sidebar" => ""
+ stub_template "projects/issues/_discussion" => ""
+ allow(view).to receive(:issuable_meta).and_return("")
end
- context 'when the issue is closed' do
+ context "when the issue is closed" do
before do
allow(issue).to receive(:closed?).and_return(true)
end
- context 'when the issue was moved' do
+ context "when the issue was moved" do
let(:new_issue) { create(:issue, project: project, author: user) }
before do
@@ -31,24 +31,24 @@ describe 'projects/issues/show' do
it 'shows "Closed (moved)" if an issue has been moved' do
render
- expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed (moved)')
+ expect(rendered).to have_selector(".status-box-issue-closed:not(.hidden)", text: "Closed (moved)")
end
it 'links "moved" to the new issue the original issue was moved to' do
render
- expect(rendered).to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: 'moved')
+ expect(rendered).to have_selector("a[href=\"#{issue_path(new_issue)}\"]", text: "moved")
end
end
it 'shows "Closed" if an issue has not been moved' do
render
- expect(rendered).to have_selector('.status-box-issue-closed:not(.hidden)', text: 'Closed')
+ expect(rendered).to have_selector(".status-box-issue-closed:not(.hidden)", text: "Closed")
end
end
- context 'when the issue is open' do
+ context "when the issue is open" do
before do
allow(issue).to receive(:closed?).and_return(false)
allow(issue).to receive(:disscussion_locked).and_return(false)
@@ -57,7 +57,7 @@ describe 'projects/issues/show' do
it 'shows "Open" if an issue has been moved' do
render
- expect(rendered).to have_selector('.status-box-open:not(.hidden)', text: 'Open')
+ expect(rendered).to have_selector(".status-box-open:not(.hidden)", text: "Open")
end
end
end
diff --git a/spec/views/projects/jobs/_build.html.haml_spec.rb b/spec/views/projects/jobs/_build.html.haml_spec.rb
index 1d58891036e..4a5e4509916 100644
--- a/spec/views/projects/jobs/_build.html.haml_spec.rb
+++ b/spec/views/projects/jobs/_build.html.haml_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/ci/jobs/_build' do
+describe "projects/ci/jobs/_build" do
include Devise::Test::ControllerHelpers
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
- let(:build) { create(:ci_build, pipeline: pipeline, stage: 'test', stage_idx: 1, name: 'rspec 0:2', status: :pending) }
+ let(:build) { create(:ci_build, pipeline: pipeline, stage: "test", stage_idx: 1, name: "rspec 0:2", status: :pending) }
before do
- controller.prepend_view_path('app/views/projects')
+ controller.prepend_view_path("app/views/projects")
allow(view).to receive(:can?).and_return(true)
end
- it 'won\'t include a column with a link to its pipeline by default' do
- render partial: 'projects/ci/builds/build', locals: { build: build }
+ it "won't include a column with a link to its pipeline by default" do
+ render partial: "projects/ci/builds/build", locals: {build: build}
- expect(rendered).not_to have_link('#1337')
- expect(rendered).not_to have_text('#1337 by API')
+ expect(rendered).not_to have_link("#1337")
+ expect(rendered).not_to have_text("#1337 by API")
end
- it 'can include a column with a link to its pipeline' do
- render partial: 'projects/ci/builds/build', locals: { build: build, pipeline_link: true }
+ it "can include a column with a link to its pipeline" do
+ render partial: "projects/ci/builds/build", locals: {build: build, pipeline_link: true}
- expect(rendered).to have_link('#1337')
- expect(rendered).to have_text('#1337 by API')
+ expect(rendered).to have_link("#1337")
+ expect(rendered).to have_text("#1337 by API")
end
end
diff --git a/spec/views/projects/jobs/_generic_commit_status.html.haml_spec.rb b/spec/views/projects/jobs/_generic_commit_status.html.haml_spec.rb
index dc2ffc9dc47..6dd0c771c6b 100644
--- a/spec/views/projects/jobs/_generic_commit_status.html.haml_spec.rb
+++ b/spec/views/projects/jobs/_generic_commit_status.html.haml_spec.rb
@@ -1,28 +1,28 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/generic_commit_statuses/_generic_commit_status.html.haml' do
+describe "projects/generic_commit_statuses/_generic_commit_status.html.haml" do
include Devise::Test::ControllerHelpers
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_empty_pipeline, id: 1337, project: project, sha: project.commit.id) }
- let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) }
+ let(:generic_commit_status) { create(:generic_commit_status, pipeline: pipeline, stage: "external", name: "jenkins", stage_idx: 3) }
before do
- controller.prepend_view_path('app/views/projects')
+ controller.prepend_view_path("app/views/projects")
allow(view).to receive(:can?).and_return(true)
end
- it 'won\'t include a column with a link to its pipeline by default' do
- render partial: 'projects/generic_commit_statuses/generic_commit_status', locals: { generic_commit_status: generic_commit_status }
+ it "won't include a column with a link to its pipeline by default" do
+ render partial: "projects/generic_commit_statuses/generic_commit_status", locals: {generic_commit_status: generic_commit_status}
- expect(rendered).not_to have_link('#1337')
- expect(rendered).not_to have_text('#1337 by API')
+ expect(rendered).not_to have_link("#1337")
+ expect(rendered).not_to have_text("#1337 by API")
end
- it 'can include a column with a link to its pipeline' do
- render partial: 'projects/generic_commit_statuses/generic_commit_status', locals: { generic_commit_status: generic_commit_status, pipeline_link: true }
+ it "can include a column with a link to its pipeline" do
+ render partial: "projects/generic_commit_statuses/generic_commit_status", locals: {generic_commit_status: generic_commit_status, pipeline_link: true}
- expect(rendered).to have_link('#1337')
- expect(rendered).to have_text('#1337 by API')
+ expect(rendered).to have_link("#1337")
+ expect(rendered).to have_text("#1337 by API")
end
end
diff --git a/spec/views/projects/jobs/show.html.haml_spec.rb b/spec/views/projects/jobs/show.html.haml_spec.rb
index e06a9ecb98b..b0b5c70e082 100644
--- a/spec/views/projects/jobs/show.html.haml_spec.rb
+++ b/spec/views/projects/jobs/show.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/jobs/show' do
+describe "projects/jobs/show" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
@@ -18,19 +18,19 @@ describe 'projects/jobs/show' do
allow(view).to receive(:can?).and_return(true)
end
- context 'when job is running' do
+ context "when job is running" do
let(:build) { create(:ci_build, :trace_live, :running, pipeline: pipeline) }
before do
render
end
- it 'does not show retry button' do
- expect(rendered).not_to have_link('Retry')
+ it "does not show retry button" do
+ expect(rendered).not_to have_link("Retry")
end
- it 'does not show New issue button' do
- expect(rendered).not_to have_link('New issue')
+ it "does not show New issue button" do
+ expect(rendered).not_to have_link("New issue")
end
end
end
diff --git a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb
index a7628548de6..aa1630ee52a 100644
--- a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/merge_requests/_commits.html.haml' do
+describe "projects/merge_requests/_commits.html.haml" do
include Devise::Test::ControllerHelpers
include ProjectForksHelper
@@ -16,14 +16,14 @@ describe 'projects/merge_requests/_commits.html.haml' do
end
before do
- controller.prepend_view_path('app/views/projects')
+ controller.prepend_view_path("app/views/projects")
assign(:merge_request, merge_request)
assign(:commits, merge_request.commits)
assign(:hidden_commit_count, 0)
end
- it 'shows commits from source project' do
+ it "shows commits from source project" do
render
commit = merge_request.commits.first # HEAD
@@ -32,12 +32,12 @@ describe 'projects/merge_requests/_commits.html.haml' do
expect(rendered).to have_link(href: href)
end
- context 'when there are hidden commits' do
+ context "when there are hidden commits" do
before do
assign(:hidden_commit_count, 1)
end
- it 'shows notice about omitted commits' do
+ it "shows notice about omitted commits" do
render
expect(rendered).to match(/1 additional commit has been omitted to prevent performance issues/)
diff --git a/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb b/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb
index 0206928a211..5e1c28f1b10 100644
--- a/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/creations/_new_submit.html.haml_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/merge_requests/creations/_new_submit.html.haml' do
+describe "projects/merge_requests/creations/_new_submit.html.haml" do
let(:merge_request) { create(:merge_request) }
let!(:pipeline) { create(:ci_empty_pipeline) }
before do
- controller.prepend_view_path('app/views/projects')
+ controller.prepend_view_path("app/views/projects")
assign(:merge_request, merge_request)
assign(:commits, merge_request.commits)
@@ -15,31 +15,31 @@ describe 'projects/merge_requests/creations/_new_submit.html.haml' do
assign(:mr_presenter, merge_request.present(current_user: merge_request.author))
allow(view).to receive(:can?).and_return(true)
- allow(view).to receive(:url_for).and_return('#')
+ allow(view).to receive(:url_for).and_return("#")
allow(view).to receive(:current_user).and_return(merge_request.author)
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
- context 'when there are pipelines for merge request but no pipeline for last commit' do
+ context "when there are pipelines for merge request but no pipeline for last commit" do
before do
assign(:pipelines, Ci::Pipeline.all)
assign(:pipeline, nil)
end
- it 'shows <<Pipelines>> tab and hides <<Builds>> tab' do
+ it "shows <<Pipelines>> tab and hides <<Builds>> tab" do
render
- expect(rendered).to have_text('Pipelines 1')
- expect(rendered).not_to have_text('Builds')
+ expect(rendered).to have_text("Pipelines 1")
+ expect(rendered).not_to have_text("Builds")
end
end
- context 'when there are hidden commits' do
+ context "when there are hidden commits" do
before do
assign(:pipelines, Ci::Pipeline.none)
assign(:hidden_commit_count, 2)
end
- it 'shows notice about omitted commits' do
+ it "shows notice about omitted commits" do
render
expect(rendered).to match(/2 additional commits have been omitted to prevent performance issues/)
diff --git a/spec/views/projects/merge_requests/diffs/_diffs.html.haml_spec.rb b/spec/views/projects/merge_requests/diffs/_diffs.html.haml_spec.rb
index e7c40421f1f..ce8a7ae0cbe 100644
--- a/spec/views/projects/merge_requests/diffs/_diffs.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/diffs/_diffs.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/merge_requests/diffs/_diffs.html.haml' do
+describe "projects/merge_requests/diffs/_diffs.html.haml" do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
@@ -20,7 +20,7 @@ describe 'projects/merge_requests/diffs/_diffs.html.haml' do
assign(:notes, [])
end
- context 'for a commit' do
+ context "for a commit" do
let(:commit) { merge_request.commits.last }
before do
diff --git a/spec/views/projects/merge_requests/edit.html.haml_spec.rb b/spec/views/projects/merge_requests/edit.html.haml_spec.rb
index c13eab30054..d7828aca740 100644
--- a/spec/views/projects/merge_requests/edit.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/edit.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/merge_requests/edit.html.haml' do
+describe "projects/merge_requests/edit.html.haml" do
include Devise::Test::ControllerHelpers
include ProjectForksHelper
@@ -31,30 +31,30 @@ describe 'projects/merge_requests/edit.html.haml' do
.and_return(User.find(closed_merge_request.author_id))
end
- context 'when a merge request without fork' do
+ context "when a merge request without fork" do
it "shows editable fields" do
unlink_project.execute
closed_merge_request.reload
render
- expect(rendered).to have_field('merge_request[title]')
- expect(rendered).to have_field('merge_request[description]')
- expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
- expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
- expect(rendered).not_to have_selector('#merge_request_target_branch', visible: false)
+ expect(rendered).to have_field("merge_request[title]")
+ expect(rendered).to have_field("merge_request[description]")
+ expect(rendered).to have_selector("#merge_request_assignee_id", visible: false)
+ expect(rendered).to have_selector("#merge_request_milestone_id", visible: false)
+ expect(rendered).not_to have_selector("#merge_request_target_branch", visible: false)
end
end
- context 'when a merge request with an existing source project is closed' do
+ context "when a merge request with an existing source project is closed" do
it "shows editable fields" do
render
- expect(rendered).to have_field('merge_request[title]')
- expect(rendered).to have_field('merge_request[description]')
- expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
- expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
- expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
+ expect(rendered).to have_field("merge_request[title]")
+ expect(rendered).to have_field("merge_request[description]")
+ expect(rendered).to have_selector("#merge_request_assignee_id", visible: false)
+ expect(rendered).to have_selector("#merge_request_milestone_id", visible: false)
+ expect(rendered).to have_selector("#merge_request_target_branch", visible: false)
end
end
end
diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb
index d9bda1a3414..f72f9e93298 100644
--- a/spec/views/projects/merge_requests/show.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/merge_requests/show.html.haml' do
+describe "projects/merge_requests/show.html.haml" do
include Devise::Test::ControllerHelpers
include ProjectForksHelper
@@ -41,21 +41,21 @@ describe 'projects/merge_requests/show.html.haml' do
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
end
- describe 'merge request assignee sidebar' do
- context 'when assignee is allowed to merge' do
- it 'does not show a warning icon' do
+ describe "merge request assignee sidebar" do
+ context "when assignee is allowed to merge" do
+ it "does not show a warning icon" do
closed_merge_request.update(assignee_id: user.id)
project.add_maintainer(user)
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
render
- expect(rendered).not_to have_css('.cannot-be-merged')
+ expect(rendered).not_to have_css(".cannot-be-merged")
end
end
- context 'when assignee is not allowed to merge' do
- it 'shows a warning icon' do
+ context "when assignee is not allowed to merge" do
+ it "shows a warning icon" do
reporter = create(:user)
project.add_reporter(reporter)
closed_merge_request.update(assignee_id: reporter.id)
@@ -63,17 +63,17 @@ describe 'projects/merge_requests/show.html.haml' do
render
- expect(rendered).to have_css('.cannot-be-merged')
+ expect(rendered).to have_css(".cannot-be-merged")
end
end
end
- context 'when the merge request is closed' do
+ context "when the merge request is closed" do
it 'shows the "Reopen" button' do
render
- expect(rendered).to have_css('a', visible: true, text: 'Reopen')
- expect(rendered).to have_css('a', visible: false, text: 'Close')
+ expect(rendered).to have_css("a", visible: true, text: "Reopen")
+ expect(rendered).to have_css("a", visible: false, text: "Close")
end
it 'does not show the "Reopen" button when the source project does not exist' do
@@ -83,14 +83,14 @@ describe 'projects/merge_requests/show.html.haml' do
render
- expect(rendered).to have_css('a', visible: false, text: 'Reopen')
- expect(rendered).to have_css('a', visible: false, text: 'Close')
+ expect(rendered).to have_css("a", visible: false, text: "Reopen")
+ expect(rendered).to have_css("a", visible: false, text: "Close")
end
end
- context 'when the merge request is open' do
- it 'closes the merge request if the source project does not exist' do
- closed_merge_request.update(state: 'open')
+ context "when the merge request is open" do
+ it "closes the merge request if the source project does not exist" do
+ closed_merge_request.update(state: "open")
forked_project.destroy
# Reload merge request so MergeRequest#source_project turns to `nil`
closed_merge_request.reload
@@ -98,15 +98,15 @@ describe 'projects/merge_requests/show.html.haml' do
render
- expect(closed_merge_request.reload.state).to eq('closed')
- expect(rendered).to have_css('a', visible: false, text: 'Reopen')
- expect(rendered).to have_css('a', visible: false, text: 'Close')
+ expect(closed_merge_request.reload.state).to eq("closed")
+ expect(rendered).to have_css("a", visible: false, text: "Reopen")
+ expect(rendered).to have_css("a", visible: false, text: "Close")
end
end
def serialize_issuable_sidebar(user, project, merge_request)
MergeRequestSerializer
.new(current_user: user, project: project)
- .represent(closed_merge_request, serializer: 'sidebar')
+ .represent(closed_merge_request, serializer: "sidebar")
end
end
diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
index 8a9ab02eaca..6353bde2ba7 100644
--- a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
+++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/notes/_more_actions_dropdown' do
+describe "projects/notes/_more_actions_dropdown" do
let(:author_user) { create(:user) }
let(:not_author_user) { create(:user) }
@@ -12,28 +12,28 @@ describe 'projects/notes/_more_actions_dropdown' do
assign(:project, project)
end
- it 'shows Report abuse to GitLab button if not editable and not current users comment' do
- render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note
+ it "shows Report abuse to GitLab button if not editable and not current users comment" do
+ render "projects/notes/more_actions_dropdown", current_user: not_author_user, note_editable: false, note: note
- expect(rendered).to have_link('Report abuse to GitLab')
+ expect(rendered).to have_link("Report abuse to GitLab")
end
- it 'does not show the More actions button if not editable and current users comment' do
- render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: false, note: note
+ it "does not show the More actions button if not editable and current users comment" do
+ render "projects/notes/more_actions_dropdown", current_user: author_user, note_editable: false, note: note
- expect(rendered).not_to have_selector('.dropdown.more-actions')
+ expect(rendered).not_to have_selector(".dropdown.more-actions")
end
- it 'shows Report abuse to GitLab and Delete buttons if editable and not current users comment' do
- render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note
+ it "shows Report abuse to GitLab and Delete buttons if editable and not current users comment" do
+ render "projects/notes/more_actions_dropdown", current_user: not_author_user, note_editable: true, note: note
- expect(rendered).to have_link('Report abuse to GitLab')
- expect(rendered).to have_link('Delete comment')
+ expect(rendered).to have_link("Report abuse to GitLab")
+ expect(rendered).to have_link("Delete comment")
end
- it 'shows Delete button if editable and current users comment' do
- render 'projects/notes/more_actions_dropdown', current_user: author_user, note_editable: true, note: note
+ it "shows Delete button if editable and current users comment" do
+ render "projects/notes/more_actions_dropdown", current_user: author_user, note_editable: true, note: note
- expect(rendered).to have_link('Delete comment')
+ expect(rendered).to have_link("Delete comment")
end
end
diff --git a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb
index 5d60d6bc5e7..60a0d8a006f 100644
--- a/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb
+++ b/spec/views/projects/pipeline_schedules/_pipeline_schedule.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/pipeline_schedules/_pipeline_schedule' do
+describe "projects/pipeline_schedules/_pipeline_schedule" do
let(:owner) { create(:user) }
let(:maintainer) { create(:user) }
let(:project) { create(:project) }
@@ -15,32 +15,32 @@ describe 'projects/pipeline_schedules/_pipeline_schedule' do
allow(view).to receive(:can?).and_return(true)
end
- context 'taking ownership of schedule' do
- context 'when non-owner is signed in' do
+ context "taking ownership of schedule" do
+ context "when non-owner is signed in" do
let(:user) { maintainer }
before do
allow(view).to receive(:can?).with(maintainer, :take_ownership_pipeline_schedule, pipeline_schedule).and_return(true)
end
- it 'non-owner can take ownership of pipeline' do
+ it "non-owner can take ownership of pipeline" do
render
- expect(rendered).to have_link('Take ownership')
+ expect(rendered).to have_link("Take ownership")
end
end
- context 'when owner is signed in' do
+ context "when owner is signed in" do
let(:user) { owner }
before do
allow(view).to receive(:can?).with(owner, :take_ownership_pipeline_schedule, pipeline_schedule).and_return(false)
end
- it 'owner cannot take ownership of pipeline' do
+ it "owner cannot take ownership of pipeline" do
render
- expect(rendered).not_to have_link('Take ownership')
+ expect(rendered).not_to have_link("Take ownership")
end
end
end
diff --git a/spec/views/projects/pipelines/_stage.html.haml_spec.rb b/spec/views/projects/pipelines/_stage.html.haml_spec.rb
index e40e16e742b..120ee79ab12 100644
--- a/spec/views/projects/pipelines/_stage.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/_stage.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/pipelines/_stage' do
+describe "projects/pipelines/_stage" do
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:stage) { build(:ci_stage, pipeline: pipeline) }
@@ -9,55 +9,55 @@ describe 'projects/pipelines/_stage' do
assign :stage, stage
end
- context 'when there are only latest builds present' do
+ context "when there are only latest builds present" do
before do
- create(:ci_build, name: 'test:build',
+ create(:ci_build, name: "test:build",
stage: stage.name,
pipeline: pipeline)
end
- it 'shows the builds in the stage' do
+ it "shows the builds in the stage" do
render
- expect(rendered).to have_text 'test:build'
+ expect(rendered).to have_text "test:build"
end
end
- context 'when build belongs to different stage' do
+ context "when build belongs to different stage" do
before do
- create(:ci_build, name: 'test:build',
- stage: 'other:stage',
+ create(:ci_build, name: "test:build",
+ stage: "other:stage",
pipeline: pipeline)
end
- it 'does not render build' do
+ it "does not render build" do
render
- expect(rendered).not_to have_text 'test:build'
+ expect(rendered).not_to have_text "test:build"
end
end
- context 'when there are retried builds present' do
+ context "when there are retried builds present" do
before do
- create(:ci_build, name: 'test:build', stage: stage.name, pipeline: pipeline, retried: true)
- create(:ci_build, name: 'test:build', stage: stage.name, pipeline: pipeline)
+ create(:ci_build, name: "test:build", stage: stage.name, pipeline: pipeline, retried: true)
+ create(:ci_build, name: "test:build", stage: stage.name, pipeline: pipeline)
end
- it 'shows only latest builds' do
+ it "shows only latest builds" do
render
- expect(rendered).to have_text 'test:build', count: 1
+ expect(rendered).to have_text "test:build", count: 1
end
end
- context 'when there are multiple builds' do
+ context "when there are multiple builds" do
before do
HasStatus::AVAILABLE_STATUSES.each do |status|
create_build(status)
end
end
- it 'shows them in order' do
+ it "shows them in order" do
render
expect(rendered).to have_text(HasStatus::ORDERED_STATUSES.join(" "))
diff --git a/spec/views/projects/services/_form.haml_spec.rb b/spec/views/projects/services/_form.haml_spec.rb
index 85167bca115..712142bd093 100644
--- a/spec/views/projects/services/_form.haml_spec.rb
+++ b/spec/views/projects/services/_form.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/services/_form' do
+describe "projects/services/_form" do
let(:project) { create(:redmine_project) }
let(:user) { create(:admin) }
@@ -14,32 +14,32 @@ describe 'projects/services/_form' do
current_application_settings: Gitlab::CurrentSettings.current_application_settings)
end
- context 'commit_events and merge_request_events' do
+ context "commit_events and merge_request_events" do
before do
assign(:service, project.redmine_service)
end
- it 'display merge_request_events and commit_events descriptions' do
- allow(RedmineService).to receive(:supported_events).and_return(%w(commit merge_request))
+ it "display merge_request_events and commit_events descriptions" do
+ allow(RedmineService).to receive(:supported_events).and_return(%w[commit merge_request])
render
- expect(rendered).to have_content('Event will be triggered when a commit is created/updated')
- expect(rendered).to have_content('Event will be triggered when a merge request is created/updated/merged')
+ expect(rendered).to have_content("Event will be triggered when a commit is created/updated")
+ expect(rendered).to have_content("Event will be triggered when a merge request is created/updated/merged")
end
- context 'when service is JIRA' do
+ context "when service is JIRA" do
let(:project) { create(:jira_project) }
before do
assign(:service, project.jira_service)
end
- it 'display merge_request_events and commit_events descriptions' do
+ it "display merge_request_events and commit_events descriptions" do
render
- expect(rendered).to have_content('JIRA comments will be created when an issue gets referenced in a commit.')
- expect(rendered).to have_content('JIRA comments will be created when an issue gets referenced in a merge request.')
+ expect(rendered).to have_content("JIRA comments will be created when an issue gets referenced in a commit.")
+ expect(rendered).to have_content("JIRA comments will be created when an issue gets referenced in a merge request.")
end
end
end
diff --git a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
index 2a2539c80b5..2b69c7e866a 100644
--- a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
+++ b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/settings/ci_cd/_autodevops_form' do
+describe "projects/settings/ci_cd/_autodevops_form" do
let(:project) { create(:project, :repository) }
before do
assign :project, project
end
- it 'shows a warning message about Kubernetes cluster' do
+ it "shows a warning message about Kubernetes cluster" do
render
- expect(rendered).to have_text('You must add a Kubernetes cluster integration to this project with a domain in order for your deployment strategy to work correctly.')
+ expect(rendered).to have_text("You must add a Kubernetes cluster integration to this project with a domain in order for your deployment strategy to work correctly.")
end
end
diff --git a/spec/views/projects/settings/operations/show.html.haml_spec.rb b/spec/views/projects/settings/operations/show.html.haml_spec.rb
index 8e34521c7c8..b4e129d8846 100644
--- a/spec/views/projects/settings/operations/show.html.haml_spec.rb
+++ b/spec/views/projects/settings/operations/show.html.haml_spec.rb
@@ -1,9 +1,9 @@
# frozen_string_literal: true
-require 'spec_helper'
-require 'rails_helper'
+require "spec_helper"
+require "rails_helper"
-describe 'projects/settings/operations/show' do
+describe "projects/settings/operations/show" do
let(:project) { create(:project) }
let(:user) { create(:user) }
@@ -11,7 +11,7 @@ describe 'projects/settings/operations/show' do
assign :project, project
end
- describe 'Operations > Error Tracking' do
+ describe "Operations > Error Tracking" do
before do
project.add_reporter(user)
@@ -24,13 +24,13 @@ describe 'projects/settings/operations/show' do
create(:project_error_tracking_setting, project: project)
end
- context 'Settings page ' do
- it 'renders the Operations Settings page' do
+ context "Settings page " do
+ it "renders the Operations Settings page" do
render
- expect(rendered).to have_content _('Error Tracking')
- expect(rendered).to have_content _('To link Sentry to GitLab, enter your Sentry URL and Auth Token')
- expect(rendered).to have_content _('Active')
+ expect(rendered).to have_content _("Error Tracking")
+ expect(rendered).to have_content _("To link Sentry to GitLab, enter your Sentry URL and Auth Token")
+ expect(rendered).to have_content _("Active")
end
end
end
diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb
index cb97d17988c..9c0bd264bea 100644
--- a/spec/views/projects/tags/index.html.haml_spec.rb
+++ b/spec/views/projects/tags/index.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/tags/index' do
+describe "projects/tags/index" do
let(:project) { create(:project, :repository) }
before do
@@ -8,13 +8,13 @@ describe 'projects/tags/index' do
assign(:repository, project.repository)
assign(:tags, [])
- allow(view).to receive(:current_ref).and_return('master')
+ allow(view).to receive(:current_ref).and_return("master")
allow(view).to receive(:can?).and_return(false)
end
- it 'defaults sort dropdown toggle to last updated' do
+ it "defaults sort dropdown toggle to last updated" do
render
- expect(rendered).to have_button('Last updated')
+ expect(rendered).to have_button("Last updated")
end
end
diff --git a/spec/views/projects/tree/_tree_row.html.haml_spec.rb b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
index 3353b7665e2..374babc0686 100644
--- a/spec/views/projects/tree/_tree_row.html.haml_spec.rb
+++ b/spec/views/projects/tree/_tree_row.html.haml_spec.rb
@@ -1,37 +1,37 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/tree/_tree_row' do
+describe "projects/tree/_tree_row" do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
- let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, 'files/ruby').first }
+ let(:blob_item) { Gitlab::Git::Tree.where(repository, SeedRepo::Commit::ID, "files/ruby").first }
before do
assign(:project, project)
assign(:repository, repository)
- assign(:id, File.join('master', ''))
+ assign(:id, File.join("master", ""))
assign(:lfs_blob_ids, [])
end
- it 'renders blob item' do
+ it "renders blob item" do
render_partial(blob_item)
expect(rendered).to have_content(blob_item.name)
- expect(rendered).not_to have_selector('.label-lfs', text: 'LFS')
+ expect(rendered).not_to have_selector(".label-lfs", text: "LFS")
end
- describe 'LFS blob' do
+ describe "LFS blob" do
before do
assign(:lfs_blob_ids, [blob_item].map(&:id))
render_partial(blob_item)
end
- it 'renders LFS badge' do
- expect(rendered).to have_selector('.label-lfs', text: 'LFS')
+ it "renders LFS badge" do
+ expect(rendered).to have_selector(".label-lfs", text: "LFS")
end
end
def render_partial(items)
- render partial: 'projects/tree/tree_row', collection: [items].flatten
+ render partial: "projects/tree/tree_row", collection: [items].flatten
end
end
diff --git a/spec/views/projects/tree/show.html.haml_spec.rb b/spec/views/projects/tree/show.html.haml_spec.rb
index 3b098320ad7..d4f9b7d4ddc 100644
--- a/spec/views/projects/tree/show.html.haml_spec.rb
+++ b/spec/views/projects/tree/show.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'projects/tree/show' do
+describe "projects/tree/show" do
include Devise::Test::ControllerHelpers
let(:project) { create(:project, :repository) }
@@ -13,14 +13,14 @@ describe 'projects/tree/show' do
allow(view).to receive(:can?).and_return(true)
allow(view).to receive(:can_collaborate_with_project?).and_return(true)
- allow(view).to receive_message_chain('user_access.can_push_to_branch?').and_return(true)
+ allow(view).to receive_message_chain("user_access.can_push_to_branch?").and_return(true)
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
- context 'for branch names ending on .json' do
- let(:ref) { 'ends-with.json' }
+ context "for branch names ending on .json" do
+ let(:ref) { "ends-with.json" }
let(:commit) { repository.commit(ref) }
- let(:path) { '' }
+ let(:path) { "" }
let(:tree) { repository.tree(commit.id, path) }
before do
@@ -31,10 +31,10 @@ describe 'projects/tree/show' do
assign(:tree, tree)
end
- it 'displays correctly' do
+ it "displays correctly" do
render
- expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref)
- expect(rendered).to have_css('.readme-holder')
+ expect(rendered).to have_css(".js-project-refs-dropdown .dropdown-toggle-text", text: ref)
+ expect(rendered).to have_css(".readme-holder")
end
end
end
diff --git a/spec/views/shared/milestones/_issuable.html.haml.rb b/spec/views/shared/milestones/_issuable.html.haml.rb
index 0a3f877cae0..29bf915110f 100644
--- a/spec/views/shared/milestones/_issuable.html.haml.rb
+++ b/spec/views/shared/milestones/_issuable.html.haml.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/milestones/_issuable.html.haml' do
+describe "shared/milestones/_issuable.html.haml" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:milestone) { create(:milestone, project: project) }
@@ -11,9 +11,9 @@ describe 'shared/milestones/_issuable.html.haml' do
assign(:milestone, milestone)
end
- it 'avatar links to issues page' do
- render 'shared/milestones/issuable', issuable: issuable, show_project_name: true
+ it "avatar links to issues page" do
+ render "shared/milestones/issuable", issuable: issuable, show_project_name: true
- expect(rendered).to have_css("a[href='#{project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id, state: 'all')}']")
+ expect(rendered).to have_css("a[href='#{project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id, state: "all")}']")
end
end
diff --git a/spec/views/shared/milestones/_issuables.html.haml.rb b/spec/views/shared/milestones/_issuables.html.haml.rb
index 4769d569548..3f41beebdae 100644
--- a/spec/views/shared/milestones/_issuables.html.haml.rb
+++ b/spec/views/shared/milestones/_issuables.html.haml.rb
@@ -1,32 +1,32 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/milestones/_issuables.html.haml' do
+describe "shared/milestones/_issuables.html.haml" do
let(:issuables_size) { 100 }
before do
allow(view).to receive_messages(title: nil, id: nil, show_project_name: nil,
- show_full_project_name: nil, dom_class: '',
+ show_full_project_name: nil, dom_class: "",
issuables: double(size: issuables_size).as_null_object)
- stub_template 'shared/milestones/_issuable.html.haml' => ''
+ stub_template "shared/milestones/_issuable.html.haml" => ""
end
- it 'should show the issuables count if show_counter is true' do
- render 'shared/milestones/issuables', show_counter: true
- expect(rendered).to have_content('100')
+ it "should show the issuables count if show_counter is true" do
+ render "shared/milestones/issuables", show_counter: true
+ expect(rendered).to have_content("100")
end
- it 'should not show the issuables count if show_counter is false' do
- render 'shared/milestones/issuables', show_counter: false
- expect(rendered).not_to have_content('100')
+ it "should not show the issuables count if show_counter is false" do
+ render "shared/milestones/issuables", show_counter: false
+ expect(rendered).not_to have_content("100")
end
- describe 'a high issuables count' do
+ describe "a high issuables count" do
let(:issuables_size) { 1000 }
- it 'should show a delimited number if show_counter is true' do
- render 'shared/milestones/issuables', show_counter: true
- expect(rendered).to have_content('1,000')
+ it "should show a delimited number if show_counter is true" do
+ render "shared/milestones/issuables", show_counter: true
+ expect(rendered).to have_content("1,000")
end
end
end
diff --git a/spec/views/shared/milestones/_top.html.haml.rb b/spec/views/shared/milestones/_top.html.haml.rb
index 516d81c87ac..f89d06f7baf 100644
--- a/spec/views/shared/milestones/_top.html.haml.rb
+++ b/spec/views/shared/milestones/_top.html.haml.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/milestones/_top.html.haml' do
+describe "shared/milestones/_top.html.haml" do
set(:group) { create(:group) }
let(:project) { create(:project, group: group) }
let(:milestone) { create(:milestone, project: project) }
@@ -9,27 +9,27 @@ describe 'shared/milestones/_top.html.haml' do
allow(milestone).to receive(:milestones) { [] }
end
- it 'renders a deprecation message for a legacy milestone' do
+ it "renders a deprecation message for a legacy milestone" do
allow(milestone).to receive(:legacy_group_milestone?) { true }
- render 'shared/milestones/top', milestone: milestone
+ render "shared/milestones/top", milestone: milestone
- expect(rendered).to have_css('.milestone-deprecation-message')
+ expect(rendered).to have_css(".milestone-deprecation-message")
end
- it 'renders a deprecation message for a dashboard milestone' do
+ it "renders a deprecation message for a dashboard milestone" do
allow(milestone).to receive(:dashboard_milestone?) { true }
- render 'shared/milestones/top', milestone: milestone
+ render "shared/milestones/top", milestone: milestone
- expect(rendered).to have_css('.milestone-deprecation-message')
+ expect(rendered).to have_css(".milestone-deprecation-message")
end
- it 'does not render a deprecation message for a non-legacy and non-dashboard milestone' do
+ it "does not render a deprecation message for a non-legacy and non-dashboard milestone" do
assign :group, group
- render 'shared/milestones/top', milestone: milestone
+ render "shared/milestones/top", milestone: milestone
- expect(rendered).not_to have_css('.milestone-deprecation-message')
+ expect(rendered).not_to have_css(".milestone-deprecation-message")
end
end
diff --git a/spec/views/shared/notes/_form.html.haml_spec.rb b/spec/views/shared/notes/_form.html.haml_spec.rb
index 0189f926a5f..4a155f9f03d 100644
--- a/spec/views/shared/notes/_form.html.haml_spec.rb
+++ b/spec/views/shared/notes/_form.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/notes/_form' do
+describe "shared/notes/_form" do
include Devise::Test::ControllerHelpers
let(:user) { create(:user) }
@@ -20,8 +20,8 @@ describe 'shared/notes/_form' do
context "with a note on #{noteable}" do
let(:note) { build(:"note_on_#{noteable}", project: project) }
- it 'says that markdown and quick actions are supported' do
- expect(rendered).to have_content('Markdown and quick actions are supported')
+ it "says that markdown and quick actions are supported" do
+ expect(rendered).to have_content("Markdown and quick actions are supported")
end
end
end
diff --git a/spec/views/shared/projects/_project.html.haml_spec.rb b/spec/views/shared/projects/_project.html.haml_spec.rb
index 3b14045e61f..c9f23b38261 100644
--- a/spec/views/shared/projects/_project.html.haml_spec.rb
+++ b/spec/views/shared/projects/_project.html.haml_spec.rb
@@ -1,6 +1,6 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/projects/_project.html.haml' do
+describe "shared/projects/_project.html.haml" do
let(:project) { create(:project) }
before do
@@ -8,17 +8,17 @@ describe 'shared/projects/_project.html.haml' do
allow(view).to receive(:can?) { true }
end
- it 'should render creator avatar if project has a creator' do
- render 'shared/projects/project', use_creator_avatar: true, project: project
+ it "should render creator avatar if project has a creator" do
+ render "shared/projects/project", use_creator_avatar: true, project: project
- expect(rendered).to have_selector('img.avatar')
+ expect(rendered).to have_selector("img.avatar")
end
- it 'should render a generic avatar if project does not have a creator' do
+ it "should render a generic avatar if project does not have a creator" do
project.creator = nil
- render 'shared/projects/project', use_creator_avatar: true, project: project
+ render "shared/projects/project", use_creator_avatar: true, project: project
- expect(rendered).to have_selector('.project-avatar')
+ expect(rendered).to have_selector(".project-avatar")
end
end
diff --git a/spec/views/shared/runners/show.html.haml_spec.rb b/spec/views/shared/runners/show.html.haml_spec.rb
index 5e92928b143..efbc2e5f098 100644
--- a/spec/views/shared/runners/show.html.haml_spec.rb
+++ b/spec/views/shared/runners/show.html.haml_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe 'shared/runners/show.html.haml' do
+describe "shared/runners/show.html.haml" do
include PageLayoutHelper
let(:runner) do
- create(:ci_runner, name: 'test runner',
- version: '11.4.0',
- ip_address: '127.1.2.3',
- revision: 'abcd1234',
- architecture: 'amd64' )
+ create(:ci_runner, name: "test runner",
+ version: "11.4.0",
+ ip_address: "127.1.2.3",
+ revision: "abcd1234",
+ architecture: "amd64")
end
before do
@@ -22,109 +22,109 @@ describe 'shared/runners/show.html.haml' do
rendered
end
- describe 'Page title' do
+ describe "Page title" do
before do
- expect_any_instance_of(PageLayoutHelper).to receive(:page_title).with("#{runner.description} ##{runner.id}", 'Runners')
+ expect_any_instance_of(PageLayoutHelper).to receive(:page_title).with("#{runner.description} ##{runner.id}", "Runners")
end
- it 'sets proper page title' do
+ it "sets proper page title" do
render
end
end
- describe 'Runner id and type' do
- context 'when runner is of type instance' do
+ describe "Runner id and type" do
+ context "when runner is of type instance" do
it { is_expected.to have_content("Runner ##{runner.id} Shared") }
end
- context 'when runner is of type group' do
+ context "when runner is of type group" do
let(:runner) { create(:ci_runner, :group) }
it { is_expected.to have_content("Runner ##{runner.id} Group") }
end
- context 'when runner is of type project' do
+ context "when runner is of type project" do
let(:runner) { create(:ci_runner, :project) }
it { is_expected.to have_content("Runner ##{runner.id} Specific") }
end
end
- describe 'Active value' do
- context 'when runner is active' do
- it { is_expected.to have_content('Active Yes') }
+ describe "Active value" do
+ context "when runner is active" do
+ it { is_expected.to have_content("Active Yes") }
end
- context 'when runner is inactive' do
+ context "when runner is inactive" do
let(:runner) { create(:ci_runner, :inactive) }
- it { is_expected.to have_content('Active No') }
+ it { is_expected.to have_content("Active No") }
end
end
- describe 'Protected value' do
- context 'when runner is not protected' do
- it { is_expected.to have_content('Protected No') }
+ describe "Protected value" do
+ context "when runner is not protected" do
+ it { is_expected.to have_content("Protected No") }
end
- context 'when runner is protected' do
+ context "when runner is protected" do
let(:runner) { create(:ci_runner, :ref_protected) }
- it { is_expected.to have_content('Protected Yes') }
+ it { is_expected.to have_content("Protected Yes") }
end
end
- describe 'Can run untagged jobs value' do
- context 'when runner run untagged job is set' do
- it { is_expected.to have_content('Can run untagged jobs Yes') }
+ describe "Can run untagged jobs value" do
+ context "when runner run untagged job is set" do
+ it { is_expected.to have_content("Can run untagged jobs Yes") }
end
- context 'when runner run untagged job is unset' do
+ context "when runner run untagged job is unset" do
let(:runner) { create(:ci_runner, :tagged_only) }
- it { is_expected.to have_content('Can run untagged jobs No') }
+ it { is_expected.to have_content("Can run untagged jobs No") }
end
end
- describe 'Locked to this project value' do
- context 'when runner locked is not set' do
- it { is_expected.to have_content('Locked to this project No') }
+ describe "Locked to this project value" do
+ context "when runner locked is not set" do
+ it { is_expected.to have_content("Locked to this project No") }
- context 'when runner is of type group' do
+ context "when runner is of type group" do
let(:runner) { create(:ci_runner, :group) }
- it { is_expected.not_to have_content('Locked to this project') }
+ it { is_expected.not_to have_content("Locked to this project") }
end
end
- context 'when runner locked is set' do
+ context "when runner locked is set" do
let(:runner) { create(:ci_runner, :locked) }
- it { is_expected.to have_content('Locked to this project Yes') }
+ it { is_expected.to have_content("Locked to this project Yes") }
- context 'when runner is of type group' do
+ context "when runner is of type group" do
let(:runner) { create(:ci_runner, :group, :locked) }
- it { is_expected.not_to have_content('Locked to this project') }
+ it { is_expected.not_to have_content("Locked to this project") }
end
end
end
- describe 'Tags value' do
- context 'when runner does not have tags' do
- it { is_expected.to have_content('Tags') }
- it { is_expected.not_to have_selector('span.badge.badge-primary')}
+ describe "Tags value" do
+ context "when runner does not have tags" do
+ it { is_expected.to have_content("Tags") }
+ it { is_expected.not_to have_selector("span.badge.badge-primary")}
end
- context 'when runner have tags' do
- let(:runner) { create(:ci_runner, tag_list: %w(tag2 tag3 tag1)) }
+ context "when runner have tags" do
+ let(:runner) { create(:ci_runner, tag_list: %w[tag2 tag3 tag1]) }
- it { is_expected.to have_content('Tags tag1 tag2 tag3') }
- it { is_expected.to have_selector('span.badge.badge-primary')}
+ it { is_expected.to have_content("Tags tag1 tag2 tag3") }
+ it { is_expected.to have_selector("span.badge.badge-primary")}
end
end
- describe 'Metadata values' do
+ describe "Metadata values" do
it { is_expected.to have_content("Name #{runner.name}") }
it { is_expected.to have_content("Version #{runner.version}") }
it { is_expected.to have_content("IP Address #{runner.ip_address}") }
@@ -134,18 +134,18 @@ describe 'shared/runners/show.html.haml' do
it { is_expected.to have_content("Description #{runner.description}") }
end
- describe 'Maximum job timeout value' do
+ describe "Maximum job timeout value" do
let(:runner) { create(:ci_runner, maximum_timeout: 5400) }
- it { is_expected.to have_content('Maximum job timeout 1h 30m') }
+ it { is_expected.to have_content("Maximum job timeout 1h 30m") }
end
- describe 'Last contact value' do
- context 'when runner have not contacted yet' do
- it { is_expected.to have_content('Last contact Never') }
+ describe "Last contact value" do
+ context "when runner have not contacted yet" do
+ it { is_expected.to have_content("Last contact Never") }
end
- context 'when runner have already contacted' do
+ context "when runner have already contacted" do
let(:runner) { create(:ci_runner, contacted_at: DateTime.now - 6.days) }
let(:expected_contacted_at) { I18n.localize(runner.contacted_at, format: "%b %d, %Y") }
diff --git a/spec/workers/admin_email_worker_spec.rb b/spec/workers/admin_email_worker_spec.rb
index 27687f069ea..b048a48cfb5 100644
--- a/spec/workers/admin_email_worker_spec.rb
+++ b/spec/workers/admin_email_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe AdminEmailWorker do
subject(:worker) { described_class.new }
- describe '.perform' do
- it 'does not attempt to send repository check mail when they are disabled' do
+ describe ".perform" do
+ it "does not attempt to send repository check mail when they are disabled" do
stub_application_setting(repository_checks_enabled: false)
expect(worker).not_to receive(:send_repository_check_mail)
@@ -12,24 +12,24 @@ describe AdminEmailWorker do
worker.perform
end
- context 'repository_checks enabled' do
+ context "repository_checks enabled" do
before do
stub_application_setting(repository_checks_enabled: true)
end
- it 'checks if repository check mail should be sent' do
+ it "checks if repository check mail should be sent" do
expect(worker).to receive(:send_repository_check_mail)
worker.perform
end
- it 'does not send mail when there are no failed repos' do
+ it "does not send mail when there are no failed repos" do
expect(RepositoryCheckMailer).not_to receive(:notify)
worker.perform
end
- it 'send mail when there is a failed repo' do
+ it "send mail when there is a failed repo" do
create(:project, last_repository_check_failed: true, last_repository_check_at: Date.yesterday)
expect(RepositoryCheckMailer).to receive(:notify).and_return(spy)
diff --git a/spec/workers/archive_trace_worker_spec.rb b/spec/workers/archive_trace_worker_spec.rb
index 7244ad4f199..4441ac168e2 100644
--- a/spec/workers/archive_trace_worker_spec.rb
+++ b/spec/workers/archive_trace_worker_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe ArchiveTraceWorker do
- describe '#perform' do
+ describe "#perform" do
subject { described_class.new.perform(job&.id) }
- context 'when job is found' do
+ context "when job is found" do
let(:job) { create(:ci_build, :trace_live) }
- it 'executes service' do
+ it "executes service" do
expect_any_instance_of(Ci::ArchiveTraceService)
.to receive(:execute).with(job)
@@ -15,10 +15,10 @@ describe ArchiveTraceWorker do
end
end
- context 'when job is not found' do
+ context "when job is not found" do
let(:job) { nil }
- it 'does not execute service' do
+ it "does not execute service" do
expect_any_instance_of(Ci::ArchiveTraceService)
.not_to receive(:execute)
diff --git a/spec/workers/authorized_projects_worker_spec.rb b/spec/workers/authorized_projects_worker_spec.rb
index d095138f6b7..3d1d75affa2 100644
--- a/spec/workers/authorized_projects_worker_spec.rb
+++ b/spec/workers/authorized_projects_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe AuthorizedProjectsWorker do
- describe '#perform' do
+ describe "#perform" do
let(:user) { create(:user) }
subject(:job) { described_class.new }
diff --git a/spec/workers/auto_devops/disable_worker_spec.rb b/spec/workers/auto_devops/disable_worker_spec.rb
index 800a07e41a5..d8adbe210f1 100644
--- a/spec/workers/auto_devops/disable_worker_spec.rb
+++ b/spec/workers/auto_devops/disable_worker_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe AutoDevops::DisableWorker, '#perform' do
+require "spec_helper"
+
+describe AutoDevops::DisableWorker, "#perform" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository, :auto_devops) }
let(:auto_devops) { project.auto_devops }
@@ -14,41 +15,41 @@ describe AutoDevops::DisableWorker, '#perform' do
auto_devops.update_attribute(:enabled, nil)
end
- it 'disables auto devops for project' do
+ it "disables auto devops for project" do
subject.perform(pipeline.id)
expect(auto_devops.reload.enabled).to eq(false)
end
- context 'when project owner is a user' do
+ context "when project owner is a user" do
let(:owner) { create(:user) }
let(:namespace) { create(:namespace, owner: owner) }
let(:project) { create(:project, :repository, :auto_devops, namespace: namespace) }
- it 'sends an email to pipeline user and project owner' do
+ it "sends an email to pipeline user and project owner" do
expect(NotificationService).to receive_message_chain(:new, :autodevops_disabled).with(pipeline, [user.email, owner.email])
subject.perform(pipeline.id)
end
end
- context 'when project does not have owner' do
+ context "when project does not have owner" do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :auto_devops, namespace: group) }
- it 'sends an email to pipeline user' do
+ it "sends an email to pipeline user" do
expect(NotificationService).to receive_message_chain(:new, :autodevops_disabled).with(pipeline, [user.email])
subject.perform(pipeline.id)
end
end
- context 'when pipeline is not related to a user and project does not have owner' do
+ context "when pipeline is not related to a user and project does not have owner" do
let(:group) { create(:group) }
let(:project) { create(:project, :repository, :auto_devops, namespace: group) }
let(:pipeline) { create(:ci_pipeline, :failed, project: project) }
- it 'does not send an email' do
+ it "does not send an email" do
expect(NotificationService).not_to receive(:new)
subject.perform(pipeline.id)
diff --git a/spec/workers/background_migration_worker_spec.rb b/spec/workers/background_migration_worker_spec.rb
index 3bd072e7125..4db83b13f0e 100644
--- a/spec/workers/background_migration_worker_spec.rb
+++ b/spec/workers/background_migration_worker_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state do
let(:worker) { described_class.new }
- describe '.minimum_interval' do
- it 'returns 2 minutes' do
+ describe ".minimum_interval" do
+ it "returns 2 minutes" do
expect(described_class.minimum_interval).to eq(2.minutes.to_i)
end
end
- describe '.perform' do
- it 'performs a background migration' do
+ describe ".perform" do
+ it "performs a background migration" do
expect(Gitlab::BackgroundMigration)
.to receive(:perform)
- .with('Foo', [10, 20])
+ .with("Foo", [10, 20])
- worker.perform('Foo', [10, 20])
+ worker.perform("Foo", [10, 20])
end
- it 'reschedules a migration if it was performed recently' do
+ it "reschedules a migration if it was performed recently" do
expect(worker)
.to receive(:always_perform?)
.and_return(false)
- worker.lease_for('Foo').try_obtain
+ worker.lease_for("Foo").try_obtain
expect(Gitlab::BackgroundMigration)
.not_to receive(:perform)
expect(described_class)
.to receive(:perform_in)
- .with(a_kind_of(Numeric), 'Foo', [10, 20])
+ .with(a_kind_of(Numeric), "Foo", [10, 20])
- worker.perform('Foo', [10, 20])
+ worker.perform("Foo", [10, 20])
end
- it 'reschedules a migration if the database is not healthy' do
+ it "reschedules a migration if the database is not healthy" do
allow(worker)
.to receive(:always_perform?)
.and_return(false)
@@ -46,22 +46,22 @@ describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state d
expect(described_class)
.to receive(:perform_in)
- .with(a_kind_of(Numeric), 'Foo', [10, 20])
+ .with(a_kind_of(Numeric), "Foo", [10, 20])
- worker.perform('Foo', [10, 20])
+ worker.perform("Foo", [10, 20])
end
end
- describe '#healthy_database?' do
- context 'using MySQL', :mysql do
- it 'returns true' do
+ describe "#healthy_database?" do
+ context "using MySQL", :mysql do
+ it "returns true" do
expect(worker.healthy_database?).to eq(true)
end
end
- context 'using PostgreSQL', :postgresql do
- context 'when replication lag is too great' do
- it 'returns false' do
+ context "using PostgreSQL", :postgresql do
+ context "when replication lag is too great" do
+ it "returns false" do
allow(Postgresql::ReplicationSlot)
.to receive(:lag_too_great?)
.and_return(true)
@@ -70,8 +70,8 @@ describe BackgroundMigrationWorker, :sidekiq, :clean_gitlab_redis_shared_state d
end
end
- context 'when replication lag is small enough' do
- it 'returns true' do
+ context "when replication lag is small enough" do
+ it "returns true" do
allow(Postgresql::ReplicationSlot)
.to receive(:lag_too_great?)
.and_return(false)
diff --git a/spec/workers/build_coverage_worker_spec.rb b/spec/workers/build_coverage_worker_spec.rb
index ba20488f663..a673acee18c 100644
--- a/spec/workers/build_coverage_worker_spec.rb
+++ b/spec/workers/build_coverage_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildCoverageWorker do
- describe '#perform' do
- context 'when build exists' do
+ describe "#perform" do
+ context "when build exists" do
let!(:build) { create(:ci_build) }
- it 'updates code coverage' do
+ it "updates code coverage" do
expect_any_instance_of(Ci::Build)
.to receive(:update_coverage)
@@ -13,8 +13,8 @@ describe BuildCoverageWorker do
end
end
- context 'when build does not exist' do
- it 'does not raise exception' do
+ context "when build does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/build_finished_worker_spec.rb b/spec/workers/build_finished_worker_spec.rb
index ccb26849e67..336d497efb1 100644
--- a/spec/workers/build_finished_worker_spec.rb
+++ b/spec/workers/build_finished_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildFinishedWorker do
- describe '#perform' do
- context 'when build exists' do
+ describe "#perform" do
+ context "when build exists" do
let!(:build) { create(:ci_build) }
- it 'calculates coverage and calls hooks' do
+ it "calculates coverage and calls hooks" do
expect(BuildTraceSectionsWorker)
.to receive(:new).ordered.and_call_original
expect(BuildCoverageWorker)
@@ -20,14 +20,14 @@ describe BuildFinishedWorker do
end
end
- context 'when build does not exist' do
- it 'does not raise exception' do
+ context "when build does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
end
- it 'schedules a ChatNotification job for a chat build' do
+ it "schedules a ChatNotification job for a chat build" do
build = create(:ci_build, :success, pipeline: create(:ci_pipeline, source: :chat))
expect(ChatNotificationWorker)
@@ -37,7 +37,7 @@ describe BuildFinishedWorker do
described_class.new.perform(build.id)
end
- it 'does not schedule a ChatNotification job for a regular build' do
+ it "does not schedule a ChatNotification job for a regular build" do
build = create(:ci_build, :success, pipeline: create(:ci_pipeline))
expect(ChatNotificationWorker)
diff --git a/spec/workers/build_hooks_worker_spec.rb b/spec/workers/build_hooks_worker_spec.rb
index 97654a93f5c..4f031c2321f 100644
--- a/spec/workers/build_hooks_worker_spec.rb
+++ b/spec/workers/build_hooks_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildHooksWorker do
- describe '#perform' do
- context 'when build exists' do
+ describe "#perform" do
+ context "when build exists" do
let!(:build) { create(:ci_build) }
- it 'calls build hooks' do
+ it "calls build hooks" do
expect_any_instance_of(Ci::Build)
.to receive(:execute_hooks)
@@ -13,8 +13,8 @@ describe BuildHooksWorker do
end
end
- context 'when build does not exist' do
- it 'does not raise exception' do
+ context "when build does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/build_success_worker_spec.rb b/spec/workers/build_success_worker_spec.rb
index 5eb9709ded9..32d3e830434 100644
--- a/spec/workers/build_success_worker_spec.rb
+++ b/spec/workers/build_success_worker_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildSuccessWorker do
- describe '#perform' do
+ describe "#perform" do
subject { described_class.new.perform(build.id) }
before do
allow_any_instance_of(Deployment).to receive(:create_ref)
end
- context 'when build exists' do
- context 'when deployment was not created with the build creation' do # An edge case during the transition period
+ context "when build exists" do
+ context "when deployment was not created with the build creation" do # An edge case during the transition period
let!(:build) { create(:ci_build, :deploy_to_production) }
before do
@@ -17,7 +17,7 @@ describe BuildSuccessWorker do
build.reload
end
- it 'creates a successful deployment' do
+ it "creates a successful deployment" do
expect(build).not_to be_has_deployment
subject
@@ -28,31 +28,31 @@ describe BuildSuccessWorker do
end
end
- context 'when deployment was created with the build creation' do # Counter part of the above edge case
+ context "when deployment was created with the build creation" do # Counter part of the above edge case
let!(:build) { create(:ci_build, :deploy_to_production) }
- it 'does not create a new deployment' do
+ it "does not create a new deployment" do
expect(build).to be_has_deployment
expect { subject }.not_to change { Deployment.count }
end
end
- context 'when build is not associated with project' do
+ context "when build is not associated with project" do
let!(:build) { create(:ci_build, project: nil) }
- it 'does not create deployment' do
+ it "does not create deployment" do
subject
expect(build.reload).not_to be_has_deployment
end
end
- context 'when the build will stop an environment' do
+ context "when the build will stop an environment" do
let!(:build) { create(:ci_build, :stop_review_app, environment: environment.name, project: environment.project) }
let(:environment) { create(:environment, state: :available) }
- it 'stops the environment' do
+ it "stops the environment" do
expect(environment).to be_available
subject
@@ -62,8 +62,8 @@ describe BuildSuccessWorker do
end
end
- context 'when build does not exist' do
- it 'does not raise exception' do
+ context "when build does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/build_trace_sections_worker_spec.rb b/spec/workers/build_trace_sections_worker_spec.rb
index 45243f45547..c1c0dd30884 100644
--- a/spec/workers/build_trace_sections_worker_spec.rb
+++ b/spec/workers/build_trace_sections_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe BuildTraceSectionsWorker do
- describe '#perform' do
- context 'when build exists' do
+ describe "#perform" do
+ context "when build exists" do
let!(:build) { create(:ci_build) }
- it 'updates trace sections' do
+ it "updates trace sections" do
expect_any_instance_of(Ci::Build)
.to receive(:parse_trace_sections!)
@@ -13,8 +13,8 @@ describe BuildTraceSectionsWorker do
end
end
- context 'when build does not exist' do
- it 'does not raise exception' do
+ context "when build does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/chat_notification_worker_spec.rb b/spec/workers/chat_notification_worker_spec.rb
index 91695674f5d..1f1b4d3839c 100644
--- a/spec/workers/chat_notification_worker_spec.rb
+++ b/spec/workers/chat_notification_worker_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ChatNotificationWorker do
let(:worker) { described_class.new }
@@ -8,14 +8,14 @@ describe ChatNotificationWorker do
create(:ci_build, pipeline: create(:ci_pipeline, source: :chat))
end
- describe '#perform' do
- it 'does nothing when the build no longer exists' do
+ describe "#perform" do
+ it "does nothing when the build no longer exists" do
expect(worker).not_to receive(:send_response)
worker.perform(-1)
end
- it 'sends a response for an existing build' do
+ it "sends a response for an existing build" do
expect(worker)
.to receive(:send_response)
.with(an_instance_of(Ci::Build))
@@ -23,7 +23,7 @@ describe ChatNotificationWorker do
worker.perform(chat_build.id)
end
- it 'reschedules the job if the trace sections could not be found' do
+ it "reschedules the job if the trace sections could not be found" do
expect(worker)
.to receive(:send_response)
.and_raise(Gitlab::Chat::Output::MissingBuildSectionError)
@@ -36,9 +36,9 @@ describe ChatNotificationWorker do
end
end
- describe '#send_response' do
- context 'when a responder could not be found' do
- it 'does nothing' do
+ describe "#send_response" do
+ context "when a responder could not be found" do
+ it "does nothing" do
expect(Gitlab::Chat::Responder)
.to receive(:responder_for)
.with(chat_build)
@@ -48,7 +48,7 @@ describe ChatNotificationWorker do
end
end
- context 'when a responder could be found' do
+ context "when a responder could be found" do
let(:responder) { double(:responder) }
before do
@@ -58,8 +58,8 @@ describe ChatNotificationWorker do
.and_return(responder)
end
- it 'sends the response for a succeeded build' do
- output = double(:output, to_s: 'this is the build output')
+ it "sends the response for a succeeded build" do
+ output = double(:output, to_s: "this is the build output")
expect(chat_build)
.to receive(:success?)
@@ -77,7 +77,7 @@ describe ChatNotificationWorker do
worker.send_response(chat_build)
end
- it 'sends the response for a failed build' do
+ it "sends the response for a failed build" do
expect(chat_build)
.to receive(:success?)
.and_return(false)
diff --git a/spec/workers/ci/archive_traces_cron_worker_spec.rb b/spec/workers/ci/archive_traces_cron_worker_spec.rb
index 478fb7d2c0f..a854a4a66b3 100644
--- a/spec/workers/ci/archive_traces_cron_worker_spec.rb
+++ b/spec/workers/ci/archive_traces_cron_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::ArchiveTracesCronWorker do
subject { described_class.new.perform }
@@ -7,7 +7,7 @@ describe Ci::ArchiveTracesCronWorker do
stub_feature_flags(ci_enable_live_trace: true)
end
- shared_examples_for 'archives trace' do
+ shared_examples_for "archives trace" do
it do
subject
@@ -16,7 +16,7 @@ describe Ci::ArchiveTracesCronWorker do
end
end
- shared_examples_for 'does not archive trace' do
+ shared_examples_for "does not archive trace" do
it do
subject
@@ -25,23 +25,23 @@ describe Ci::ArchiveTracesCronWorker do
end
end
- context 'when a job succeeded' do
+ context "when a job succeeded" do
let!(:build) { create(:ci_build, :success, :trace_live) }
- it_behaves_like 'archives trace'
+ it_behaves_like "archives trace"
- it 'executes service' do
+ it "executes service" do
expect_any_instance_of(Ci::ArchiveTraceService)
.to receive(:execute).with(build)
subject
end
- context 'when a trace had already been archived' do
+ context "when a trace had already been archived" do
let!(:build) { create(:ci_build, :success, :trace_live, :trace_artifact) }
let!(:build2) { create(:ci_build, :success, :trace_live) }
- it 'continues to archive live traces' do
+ it "continues to archive live traces" do
subject
build2.reload
@@ -49,15 +49,15 @@ describe Ci::ArchiveTracesCronWorker do
end
end
- context 'when an unexpected exception happened during archiving' do
+ context "when an unexpected exception happened during archiving" do
let!(:build) { create(:ci_build, :success, :trace_live) }
before do
allow(Gitlab::Sentry).to receive(:track_exception)
- allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!).and_raise('Unexpected error')
+ allow_any_instance_of(Gitlab::Ci::Trace).to receive(:archive!).and_raise("Unexpected error")
end
- it 'puts a log' do
+ it "puts a log" do
expect(Rails.logger).to receive(:error).with("Failed to archive trace. id: #{build.id} message: Unexpected error")
subject
@@ -65,15 +65,15 @@ describe Ci::ArchiveTracesCronWorker do
end
end
- context 'when a job was cancelled' do
+ context "when a job was cancelled" do
let!(:build) { create(:ci_build, :canceled, :trace_live) }
- it_behaves_like 'archives trace'
+ it_behaves_like "archives trace"
end
- context 'when a job is running' do
+ context "when a job is running" do
let!(:build) { create(:ci_build, :running, :trace_live) }
- it_behaves_like 'does not archive trace'
+ it_behaves_like "does not archive trace"
end
end
diff --git a/spec/workers/ci/build_schedule_worker_spec.rb b/spec/workers/ci/build_schedule_worker_spec.rb
index 4a3fe84d7f7..9ccadf7f683 100644
--- a/spec/workers/ci/build_schedule_worker_spec.rb
+++ b/spec/workers/ci/build_schedule_worker_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Ci::BuildScheduleWorker do
subject { described_class.new.perform(build.id) }
- context 'when build is found' do
- context 'when build is scheduled' do
+ context "when build is found" do
+ context "when build is scheduled" do
let(:build) { create(:ci_build, :scheduled) }
- it 'executes RunScheduledBuildService' do
+ it "executes RunScheduledBuildService" do
expect_any_instance_of(Ci::RunScheduledBuildService)
.to receive(:execute).once
@@ -15,10 +15,10 @@ describe Ci::BuildScheduleWorker do
end
end
- context 'when build is not scheduled' do
+ context "when build is not scheduled" do
let(:build) { create(:ci_build, :created) }
- it 'executes RunScheduledBuildService' do
+ it "executes RunScheduledBuildService" do
expect_any_instance_of(Ci::RunScheduledBuildService)
.not_to receive(:execute)
@@ -27,10 +27,10 @@ describe Ci::BuildScheduleWorker do
end
end
- context 'when build is not found' do
+ context "when build is not found" do
let(:build) { build_stubbed(:ci_build, :scheduled) }
- it 'does nothing' do
+ it "does nothing" do
expect_any_instance_of(Ci::RunScheduledBuildService)
.not_to receive(:execute)
diff --git a/spec/workers/cleanup_container_repository_worker_spec.rb b/spec/workers/cleanup_container_repository_worker_spec.rb
index 5bee7294010..1d64c2f4e2d 100644
--- a/spec/workers/cleanup_container_repository_worker_spec.rb
+++ b/spec/workers/cleanup_container_repository_worker_spec.rb
@@ -1,16 +1,16 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do
let(:repository) { create(:container_repository) }
let(:project) { repository.project }
let(:user) { project.owner }
- let(:params) { { key: 'value' } }
+ let(:params) { {key: "value"} }
subject { described_class.new }
- describe '#perform' do
+ describe "#perform" do
let(:service) { instance_double(Projects::ContainerRepository::CleanupTagsService) }
before do
@@ -18,26 +18,26 @@ describe CleanupContainerRepositoryWorker, :clean_gitlab_redis_shared_state do
.with(project, user, params).and_return(service)
end
- it 'executes the destroy service' do
+ it "executes the destroy service" do
expect(service).to receive(:execute)
subject.perform(user.id, repository.id, params)
end
- it 'does not raise error when user could not be found' do
- expect do
+ it "does not raise error when user could not be found" do
+ expect {
subject.perform(-1, repository.id, params)
- end.not_to raise_error
+ }.not_to raise_error
end
- it 'does not raise error when repository could not be found' do
- expect do
+ it "does not raise error when repository could not be found" do
+ expect {
subject.perform(user.id, -1, params)
- end.not_to raise_error
+ }.not_to raise_error
end
- context 'when executed twice in short period' do
- it 'executes service only for the first time' do
+ context "when executed twice in short period" do
+ it "executes service only for the first time" do
expect(service).to receive(:execute).once
2.times { subject.perform(user.id, repository.id, params) }
diff --git a/spec/workers/cluster_configure_worker_spec.rb b/spec/workers/cluster_configure_worker_spec.rb
index 6918ee3d7d8..661d234f82d 100644
--- a/spec/workers/cluster_configure_worker_spec.rb
+++ b/spec/workers/cluster_configure_worker_spec.rb
@@ -1,37 +1,37 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
-describe ClusterConfigureWorker, '#perform' do
+describe ClusterConfigureWorker, "#perform" do
let(:worker) { described_class.new }
- context 'when group cluster' do
+ context "when group cluster" do
let(:cluster) { create(:cluster, :group, :provided_by_gcp) }
let(:group) { cluster.group }
- context 'when group has no projects' do
- it 'does not create a namespace' do
+ context "when group has no projects" do
+ it "does not create a namespace" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:execute)
worker.perform(cluster.id)
end
end
- context 'when group has a project' do
+ context "when group has a project" do
let!(:project) { create(:project, group: group) }
- it 'creates a namespace for the project' do
+ it "creates a namespace for the project" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute).once
worker.perform(cluster.id)
end
end
- context 'when group has project in a sub-group' do
+ context "when group has project in a sub-group" do
let!(:subgroup) { create(:group, parent: group) }
let!(:project) { create(:project, group: subgroup) }
- it 'creates a namespace for the project' do
+ it "creates a namespace for the project" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute).once
worker.perform(cluster.id)
@@ -39,28 +39,28 @@ describe ClusterConfigureWorker, '#perform' do
end
end
- context 'when provider type is gcp' do
+ context "when provider type is gcp" do
let(:cluster) { create(:cluster, :project, :provided_by_gcp) }
- it 'configures kubernetes platform' do
+ it "configures kubernetes platform" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute)
described_class.new.perform(cluster.id)
end
end
- context 'when provider type is user' do
+ context "when provider type is user" do
let(:cluster) { create(:cluster, :project, :provided_by_user) }
- it 'configures kubernetes platform' do
+ it "configures kubernetes platform" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).to receive(:execute)
described_class.new.perform(cluster.id)
end
end
- context 'when cluster does not exist' do
- it 'does not provision a cluster' do
+ context "when cluster does not exist" do
+ it "does not provision a cluster" do
expect_any_instance_of(Clusters::Gcp::Kubernetes::CreateOrUpdateNamespaceService).not_to receive(:execute)
described_class.new.perform(123)
diff --git a/spec/workers/cluster_provision_worker_spec.rb b/spec/workers/cluster_provision_worker_spec.rb
index da32f29fec0..4d4efc53fa2 100644
--- a/spec/workers/cluster_provision_worker_spec.rb
+++ b/spec/workers/cluster_provision_worker_spec.rb
@@ -1,36 +1,36 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterProvisionWorker do
- describe '#perform' do
- context 'when provider type is gcp' do
+ describe "#perform" do
+ context "when provider type is gcp" do
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
let(:provider) { create(:cluster_provider_gcp, :scheduled) }
- it 'provision a cluster' do
+ it "provision a cluster" do
expect_any_instance_of(Clusters::Gcp::ProvisionService).to receive(:execute)
described_class.new.perform(cluster.id)
end
end
- context 'when provider type is user' do
+ context "when provider type is user" do
let(:cluster) { create(:cluster, :provided_by_user) }
- it 'does not provision a cluster' do
+ it "does not provision a cluster" do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
described_class.new.perform(cluster.id)
end
- it 'configures kubernetes platform' do
+ it "configures kubernetes platform" do
expect(ClusterConfigureWorker).to receive(:perform_async).with(cluster.id)
described_class.new.perform(cluster.id)
end
end
- context 'when cluster does not exist' do
- it 'does not provision a cluster' do
+ context "when cluster does not exist" do
+ it "does not provision a cluster" do
expect_any_instance_of(Clusters::Gcp::ProvisionService).not_to receive(:execute)
expect(ClusterConfigureWorker).not_to receive(:perform_async)
diff --git a/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb b/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb
index 2e2e9afd25a..193023b2907 100644
--- a/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb
+++ b/spec/workers/cluster_wait_for_ingress_ip_address_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterWaitForIngressIpAddressWorker do
- describe '#perform' do
+ describe "#perform" do
let(:service) { instance_double(Clusters::Applications::CheckIngressIpAddressService, execute: true) }
let(:application) { instance_double(Clusters::Applications::Ingress) }
let(:worker) { described_class.new }
@@ -9,7 +9,7 @@ describe ClusterWaitForIngressIpAddressWorker do
before do
allow(worker)
.to receive(:find_application)
- .with('ingress', 117)
+ .with("ingress", 117)
.and_yield(application)
allow(Clusters::Applications::CheckIngressIpAddressService)
@@ -21,8 +21,8 @@ describe ClusterWaitForIngressIpAddressWorker do
.to receive(:perform_in)
end
- it 'finds the application and calls CheckIngressIpAddressService#execute' do
- worker.perform('ingress', 117)
+ it "finds the application and calls CheckIngressIpAddressService#execute" do
+ worker.perform("ingress", 117)
expect(service).to have_received(:execute)
end
diff --git a/spec/workers/concerns/application_worker_spec.rb b/spec/workers/concerns/application_worker_spec.rb
index 901d77178bc..2202e7c222d 100644
--- a/spec/workers/concerns/application_worker_spec.rb
+++ b/spec/workers/concerns/application_worker_spec.rb
@@ -1,64 +1,64 @@
-require 'spec_helper'
+require "spec_helper"
describe ApplicationWorker do
let(:worker) do
Class.new do
def self.name
- 'Gitlab::Foo::Bar::DummyWorker'
+ "Gitlab::Foo::Bar::DummyWorker"
end
include ApplicationWorker
end
end
- describe 'Sidekiq options' do
- it 'sets the queue name based on the class name' do
- expect(worker.sidekiq_options['queue']).to eq('foo_bar_dummy')
+ describe "Sidekiq options" do
+ it "sets the queue name based on the class name" do
+ expect(worker.sidekiq_options["queue"]).to eq("foo_bar_dummy")
end
end
- describe '.queue_namespace' do
- it 'sets the queue name based on the class name' do
+ describe ".queue_namespace" do
+ it "sets the queue name based on the class name" do
worker.queue_namespace :some_namespace
- expect(worker.queue).to eq('some_namespace:foo_bar_dummy')
+ expect(worker.queue).to eq("some_namespace:foo_bar_dummy")
end
end
- describe '.queue' do
- it 'returns the queue name' do
+ describe ".queue" do
+ it "returns the queue name" do
worker.sidekiq_options queue: :some_queue
- expect(worker.queue).to eq('some_queue')
+ expect(worker.queue).to eq("some_queue")
end
end
- describe '.bulk_perform_async' do
- it 'enqueues jobs in bulk' do
+ describe ".bulk_perform_async" do
+ it "enqueues jobs in bulk" do
Sidekiq::Testing.fake! do
- worker.bulk_perform_async([['Foo', [1]], ['Foo', [2]]])
+ worker.bulk_perform_async([["Foo", [1]], ["Foo", [2]]])
expect(worker.jobs.count).to eq 2
- expect(worker.jobs).to all(include('enqueued_at'))
+ expect(worker.jobs).to all(include("enqueued_at"))
end
end
end
- describe '.bulk_perform_in' do
- context 'when delay is valid' do
- it 'correctly schedules jobs' do
+ describe ".bulk_perform_in" do
+ context "when delay is valid" do
+ it "correctly schedules jobs" do
Sidekiq::Testing.fake! do
- worker.bulk_perform_in(1.minute, [['Foo', [1]], ['Foo', [2]]])
+ worker.bulk_perform_in(1.minute, [["Foo", [1]], ["Foo", [2]]])
expect(worker.jobs.count).to eq 2
- expect(worker.jobs).to all(include('at'))
+ expect(worker.jobs).to all(include("at"))
end
end
end
- context 'when delay is invalid' do
- it 'raises an ArgumentError exception' do
- expect { worker.bulk_perform_in(-60, [['Foo']]) }
+ context "when delay is invalid" do
+ it "raises an ArgumentError exception" do
+ expect { worker.bulk_perform_in(-60, [["Foo"]]) }
.to raise_error(ArgumentError)
end
end
diff --git a/spec/workers/concerns/cluster_queue_spec.rb b/spec/workers/concerns/cluster_queue_spec.rb
index 4118b9aa194..bd4ba827b85 100644
--- a/spec/workers/concerns/cluster_queue_spec.rb
+++ b/spec/workers/concerns/cluster_queue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe ClusterQueue do
let(:worker) do
Class.new do
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
@@ -12,8 +12,8 @@ describe ClusterQueue do
end
end
- it 'sets a default pipelines queue automatically' do
- expect(worker.sidekiq_options['queue'])
- .to eq 'gcp_cluster:dummy'
+ it "sets a default pipelines queue automatically" do
+ expect(worker.sidekiq_options["queue"])
+ .to eq "gcp_cluster:dummy"
end
end
diff --git a/spec/workers/concerns/cronjob_queue_spec.rb b/spec/workers/concerns/cronjob_queue_spec.rb
index c042a52f41f..fd101a27617 100644
--- a/spec/workers/concerns/cronjob_queue_spec.rb
+++ b/spec/workers/concerns/cronjob_queue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe CronjobQueue do
let(:worker) do
Class.new do
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
@@ -12,11 +12,11 @@ describe CronjobQueue do
end
end
- it 'sets the queue name of a worker' do
- expect(worker.sidekiq_options['queue'].to_s).to eq('cronjob:dummy')
+ it "sets the queue name of a worker" do
+ expect(worker.sidekiq_options["queue"].to_s).to eq("cronjob:dummy")
end
- it 'disables retrying of failed jobs' do
- expect(worker.sidekiq_options['retry']).to eq(false)
+ it "disables retrying of failed jobs" do
+ expect(worker.sidekiq_options["retry"]).to eq(false)
end
end
diff --git a/spec/workers/concerns/gitlab/github_import/notify_upon_death_spec.rb b/spec/workers/concerns/gitlab/github_import/notify_upon_death_spec.rb
index 4b9aa9a7ef8..75107322184 100644
--- a/spec/workers/concerns/gitlab/github_import/notify_upon_death_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/notify_upon_death_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::NotifyUponDeath do
let(:worker_class) do
@@ -8,19 +8,19 @@ describe Gitlab::GithubImport::NotifyUponDeath do
end
end
- describe '.sidekiq_retries_exhausted' do
- it 'notifies the JobWaiter when 3 arguments are given and the last is a String' do
- job = { 'args' => [12, {}, '123abc'], 'jid' => '123' }
+ describe ".sidekiq_retries_exhausted" do
+ it "notifies the JobWaiter when 3 arguments are given and the last is a String" do
+ job = {"args" => [12, {}, "123abc"], "jid" => "123"}
expect(Gitlab::JobWaiter)
.to receive(:notify)
- .with('123abc', '123')
+ .with("123abc", "123")
worker_class.sidekiq_retries_exhausted_block.call(job)
end
- it 'does not notify the JobWaiter when only 2 arguments are given' do
- job = { 'args' => [12, {}], 'jid' => '123' }
+ it "does not notify the JobWaiter when only 2 arguments are given" do
+ job = {"args" => [12, {}], "jid" => "123"}
expect(Gitlab::JobWaiter)
.not_to receive(:notify)
@@ -28,8 +28,8 @@ describe Gitlab::GithubImport::NotifyUponDeath do
worker_class.sidekiq_retries_exhausted_block.call(job)
end
- it 'does not notify the JobWaiter when only 1 argument is given' do
- job = { 'args' => [12], 'jid' => '123' }
+ it "does not notify the JobWaiter when only 1 argument is given" do
+ job = {"args" => [12], "jid" => "123"}
expect(Gitlab::JobWaiter)
.not_to receive(:notify)
@@ -37,8 +37,8 @@ describe Gitlab::GithubImport::NotifyUponDeath do
worker_class.sidekiq_retries_exhausted_block.call(job)
end
- it 'does not notify the JobWaiter when the last argument is not a String' do
- job = { 'args' => [12, {}, 40], 'jid' => '123' }
+ it "does not notify the JobWaiter when the last argument is not a String" do
+ job = {"args" => [12, {}, 40], "jid" => "123"}
expect(Gitlab::JobWaiter)
.not_to receive(:notify)
diff --git a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
index 9c187bead0a..726f5af3a74 100644
--- a/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/object_importer_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ObjectImporter do
let(:worker) do
- Class.new do
+ Class.new {
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include(Gitlab::GithubImport::ObjectImporter)
@@ -14,18 +14,18 @@ describe Gitlab::GithubImport::ObjectImporter do
end
def counter_description
- 'This is a counter'
+ "This is a counter"
end
- end.new
+ }.new
end
- describe '#import' do
- it 'imports the object' do
+ describe "#import" do
+ it "imports the object" do
representation_class = double(:representation_class)
importer_class = double(:importer_class)
importer_instance = double(:importer_instance)
representation = double(:representation)
- project = double(:project, full_path: 'foo/bar')
+ project = double(:project, full_path: "foo/bar")
client = double(:client)
expect(worker)
@@ -53,12 +53,12 @@ describe Gitlab::GithubImport::ObjectImporter do
.to receive(:increment)
.and_call_original
- worker.import(project, client, { 'number' => 10 })
+ worker.import(project, client, {"number" => 10})
end
end
- describe '#counter' do
- it 'returns a Prometheus counter' do
+ describe "#counter" do
+ it "returns a Prometheus counter" do
expect(worker)
.to receive(:counter_name)
.and_call_original
diff --git a/spec/workers/concerns/gitlab/github_import/queue_spec.rb b/spec/workers/concerns/gitlab/github_import/queue_spec.rb
index a96f583aff7..1b9b5de87ee 100644
--- a/spec/workers/concerns/gitlab/github_import/queue_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/queue_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Queue do
- it 'sets the Sidekiq options for the worker' do
- worker = Class.new do
+ it "sets the Sidekiq options for the worker" do
+ worker = Class.new {
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
include Gitlab::GithubImport::Queue
- end
+ }
- expect(worker.sidekiq_options['queue']).to eq('github_importer:dummy')
+ expect(worker.sidekiq_options["queue"]).to eq("github_importer:dummy")
end
end
diff --git a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb
index 8de4059c4ae..a8f2018786c 100644
--- a/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/rescheduling_methods_spec.rb
@@ -1,54 +1,54 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ReschedulingMethods do
let(:worker) do
Class.new { include(Gitlab::GithubImport::ReschedulingMethods) }.new
end
- describe '#perform' do
- context 'with a non-existing project' do
- it 'does not perform any work' do
+ describe "#perform" do
+ context "with a non-existing project" do
+ it "does not perform any work" do
expect(worker)
.not_to receive(:try_import)
worker.perform(-1, {})
end
- it 'notifies any waiters so they do not wait forever' do
+ it "notifies any waiters so they do not wait forever" do
expect(worker)
.to receive(:notify_waiter)
- .with('123')
+ .with("123")
- worker.perform(-1, {}, '123')
+ worker.perform(-1, {}, "123")
end
end
- context 'with an existing project' do
+ context "with an existing project" do
let(:project) { create(:project) }
- it 'notifies any waiters upon successfully importing the data' do
+ it "notifies any waiters upon successfully importing the data" do
expect(worker)
.to receive(:try_import)
.with(
an_instance_of(Project),
an_instance_of(Gitlab::GithubImport::Client),
- { 'number' => 2 }
+ {"number" => 2}
)
.and_return(true)
expect(worker)
- .to receive(:notify_waiter).with('123')
+ .to receive(:notify_waiter).with("123")
- worker.perform(project.id, { 'number' => 2 }, '123')
+ worker.perform(project.id, {"number" => 2}, "123")
end
- it 'reschedules itself if the data could not be imported' do
+ it "reschedules itself if the data could not be imported" do
expect(worker)
.to receive(:try_import)
.with(
an_instance_of(Project),
an_instance_of(Gitlab::GithubImport::Client),
- { 'number' => 2 }
+ {"number" => 2}
)
.and_return(false)
@@ -61,15 +61,15 @@ describe Gitlab::GithubImport::ReschedulingMethods do
expect(worker.class)
.to receive(:perform_in)
- .with(14, project.id, { 'number' => 2 }, '123')
+ .with(14, project.id, {"number" => 2}, "123")
- worker.perform(project.id, { 'number' => 2 }, '123')
+ worker.perform(project.id, {"number" => 2}, "123")
end
end
end
- describe '#try_import' do
- it 'returns true when the import succeeds' do
+ describe "#try_import" do
+ it "returns true when the import succeeds" do
expect(worker)
.to receive(:import)
.with(10, 20)
@@ -77,7 +77,7 @@ describe Gitlab::GithubImport::ReschedulingMethods do
expect(worker.try_import(10, 20)).to eq(true)
end
- it 'returns false when the import fails due to hitting the GitHub API rate limit' do
+ it "returns false when the import fails due to hitting the GitHub API rate limit" do
expect(worker)
.to receive(:import)
.with(10, 20)
@@ -87,20 +87,20 @@ describe Gitlab::GithubImport::ReschedulingMethods do
end
end
- describe '#notify_waiter' do
- it 'notifies the waiter if a waiter key is specified' do
+ describe "#notify_waiter" do
+ it "notifies the waiter if a waiter key is specified" do
expect(worker)
.to receive(:jid)
- .and_return('abc123')
+ .and_return("abc123")
expect(Gitlab::JobWaiter)
.to receive(:notify)
- .with('123', 'abc123')
+ .with("123", "abc123")
- worker.notify_waiter('123')
+ worker.notify_waiter("123")
end
- it 'does not notify any waiters if no waiter key is specified' do
+ it "does not notify any waiters if no waiter key is specified" do
expect(Gitlab::JobWaiter)
.not_to receive(:notify)
diff --git a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
index d85a87f2cb0..6829710ce34 100644
--- a/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
+++ b/spec/workers/concerns/gitlab/github_import/stage_methods_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::StageMethods do
let(:project) { create(:project) }
@@ -6,14 +6,14 @@ describe Gitlab::GithubImport::StageMethods do
Class.new { include(Gitlab::GithubImport::StageMethods) }.new
end
- describe '#perform' do
- it 'returns if no project could be found' do
+ describe "#perform" do
+ it "returns if no project could be found" do
expect(worker).not_to receive(:try_import)
worker.perform(-1)
end
- it 'imports the data when the project exists' do
+ it "imports the data when the project exists" do
allow(worker)
.to receive(:find_project)
.with(project.id)
@@ -30,8 +30,8 @@ describe Gitlab::GithubImport::StageMethods do
end
end
- describe '#try_import' do
- it 'imports the project' do
+ describe "#try_import" do
+ it "imports the project" do
client = double(:client)
expect(worker)
@@ -41,7 +41,7 @@ describe Gitlab::GithubImport::StageMethods do
worker.try_import(client, project)
end
- it 'reschedules the worker if RateLimitError was raised' do
+ it "reschedules the worker if RateLimitError was raised" do
client = double(:client, rate_limit_resets_in: 10)
expect(worker)
@@ -57,22 +57,22 @@ describe Gitlab::GithubImport::StageMethods do
end
end
- describe '#find_project' do
+ describe "#find_project" do
let(:import_state) { create(:import_state, project: project) }
- it 'returns a Project for an existing ID' do
- import_state.update_column(:status, 'started')
+ it "returns a Project for an existing ID" do
+ import_state.update_column(:status, "started")
expect(worker.find_project(project.id)).to eq(project)
end
- it 'returns nil for a project that failed importing' do
- import_state.update_column(:status, 'failed')
+ it "returns nil for a project that failed importing" do
+ import_state.update_column(:status, "failed")
expect(worker.find_project(project.id)).to be_nil
end
- it 'returns nil for a non-existing project ID' do
+ it "returns nil for a non-existing project ID" do
expect(worker.find_project(-1)).to be_nil
end
end
diff --git a/spec/workers/concerns/pipeline_background_queue_spec.rb b/spec/workers/concerns/pipeline_background_queue_spec.rb
index 24c0a3c6a20..c238da16322 100644
--- a/spec/workers/concerns/pipeline_background_queue_spec.rb
+++ b/spec/workers/concerns/pipeline_background_queue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineBackgroundQueue do
let(:worker) do
Class.new do
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
@@ -12,8 +12,8 @@ describe PipelineBackgroundQueue do
end
end
- it 'sets a default object storage queue automatically' do
- expect(worker.sidekiq_options['queue'])
- .to eq 'pipeline_background:dummy'
+ it "sets a default object storage queue automatically" do
+ expect(worker.sidekiq_options["queue"])
+ .to eq "pipeline_background:dummy"
end
end
diff --git a/spec/workers/concerns/pipeline_queue_spec.rb b/spec/workers/concerns/pipeline_queue_spec.rb
index a312b307fce..98ed125fc43 100644
--- a/spec/workers/concerns/pipeline_queue_spec.rb
+++ b/spec/workers/concerns/pipeline_queue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineQueue do
let(:worker) do
Class.new do
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
@@ -12,8 +12,8 @@ describe PipelineQueue do
end
end
- it 'sets a default pipelines queue automatically' do
- expect(worker.sidekiq_options['queue'])
- .to eq 'pipeline_default:dummy'
+ it "sets a default pipelines queue automatically" do
+ expect(worker.sidekiq_options["queue"])
+ .to eq "pipeline_default:dummy"
end
end
diff --git a/spec/workers/concerns/project_import_options_spec.rb b/spec/workers/concerns/project_import_options_spec.rb
index 3699fd83a9a..e7bb8c50acd 100644
--- a/spec/workers/concerns/project_import_options_spec.rb
+++ b/spec/workers/concerns/project_import_options_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectImportOptions do
let(:project) { create(:project, :import_started) }
- let(:job) { { 'args' => [project.id, nil, nil], 'jid' => '123' } }
+ let(:job) { {"args" => [project.id, nil, nil], "jid" => "123"} }
let(:worker_class) do
Class.new do
include Sidekiq::Worker
@@ -10,20 +10,20 @@ describe ProjectImportOptions do
end
end
- it 'sets default retry limit' do
- expect(worker_class.sidekiq_options['retry']).to eq(ProjectImportOptions::IMPORT_RETRY_COUNT)
+ it "sets default retry limit" do
+ expect(worker_class.sidekiq_options["retry"]).to eq(ProjectImportOptions::IMPORT_RETRY_COUNT)
end
- it 'sets default status expiration' do
- expect(worker_class.sidekiq_options['status_expiration']).to eq(StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)
+ it "sets default status expiration" do
+ expect(worker_class.sidekiq_options["status_expiration"]).to eq(StuckImportJobsWorker::IMPORT_JOBS_EXPIRATION)
end
- describe '.sidekiq_retries_exhausted' do
- it 'marks fork as failed' do
+ describe ".sidekiq_retries_exhausted" do
+ it "marks fork as failed" do
expect { worker_class.sidekiq_retries_exhausted_block.call(job) }.to change { project.reload.import_status }.from("started").to("failed")
end
- it 'logs the appropriate error message for forked projects' do
+ it "logs the appropriate error message for forked projects" do
allow_any_instance_of(Project).to receive(:forked?).and_return(true)
worker_class.sidekiq_retries_exhausted_block.call(job)
@@ -31,19 +31,19 @@ describe ProjectImportOptions do
expect(project.import_state.reload.last_error).to include("fork")
end
- it 'logs the appropriate error message for forked projects' do
+ it "logs the appropriate error message for forked projects" do
worker_class.sidekiq_retries_exhausted_block.call(job)
expect(project.import_state.reload.last_error).to include("import")
end
- context 'when project does not have import_state' do
+ context "when project does not have import_state" do
let(:project) { create(:project) }
- it 'raises an error' do
- expect do
+ it "raises an error" do
+ expect {
worker_class.sidekiq_retries_exhausted_block.call(job)
- end.to raise_error(NoMethodError)
+ }.to raise_error(NoMethodError)
end
end
end
diff --git a/spec/workers/concerns/repository_check_queue_spec.rb b/spec/workers/concerns/repository_check_queue_spec.rb
index d2eeecfc9a8..292472beb68 100644
--- a/spec/workers/concerns/repository_check_queue_spec.rb
+++ b/spec/workers/concerns/repository_check_queue_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryCheckQueue do
let(:worker) do
Class.new do
def self.name
- 'DummyWorker'
+ "DummyWorker"
end
include ApplicationWorker
@@ -12,11 +12,11 @@ describe RepositoryCheckQueue do
end
end
- it 'sets the queue name of a worker' do
- expect(worker.sidekiq_options['queue'].to_s).to eq('repository_check:dummy')
+ it "sets the queue name of a worker" do
+ expect(worker.sidekiq_options["queue"].to_s).to eq("repository_check:dummy")
end
- it 'disables retrying of failed jobs' do
- expect(worker.sidekiq_options['retry']).to eq(false)
+ it "disables retrying of failed jobs" do
+ expect(worker.sidekiq_options["retry"]).to eq(false)
end
end
diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb
index ce38cde9208..17edb74c9ca 100644
--- a/spec/workers/concerns/waitable_worker_spec.rb
+++ b/spec/workers/concerns/waitable_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe WaitableWorker do
let(:worker) do
Class.new do
def self.name
- 'Gitlab::Foo::Bar::DummyWorker'
+ "Gitlab::Foo::Bar::DummyWorker"
end
cattr_accessor(:counter) { 0 }
@@ -26,14 +26,14 @@ describe WaitableWorker do
subject(:job) { worker.new }
- describe '.bulk_perform_and_wait' do
- it 'schedules the jobs and waits for them to complete' do
+ describe ".bulk_perform_and_wait" do
+ it "schedules the jobs and waits for them to complete" do
worker.bulk_perform_and_wait([[1], [2]])
expect(worker.counter).to eq(3)
end
- it 'inlines workloads <= 3 jobs' do
+ it "inlines workloads <= 3 jobs" do
args_list = [[1], [2], [3]]
expect(worker).to receive(:bulk_perform_inline).with(args_list).and_call_original
@@ -42,15 +42,15 @@ describe WaitableWorker do
expect(worker.counter).to eq(6)
end
- it 'runs > 3 jobs using sidekiq' do
+ it "runs > 3 jobs using sidekiq" do
expect(worker).to receive(:bulk_perform_async)
worker.bulk_perform_and_wait([[1], [2], [3], [4]])
end
end
- describe '.bulk_perform_inline' do
- it 'runs the jobs inline' do
+ describe ".bulk_perform_inline" do
+ it "runs the jobs inline" do
expect(worker).not_to receive(:bulk_perform_async)
worker.bulk_perform_inline([[1], [2]])
@@ -58,39 +58,39 @@ describe WaitableWorker do
expect(worker.counter).to eq(3)
end
- it 'enqueues jobs if an error is raised' do
- expect(worker).to receive(:bulk_perform_async).with([['foo']])
+ it "enqueues jobs if an error is raised" do
+ expect(worker).to receive(:bulk_perform_async).with([["foo"]])
- worker.bulk_perform_inline([[1], ['foo']])
+ worker.bulk_perform_inline([[1], ["foo"]])
end
end
- describe '#perform' do
- shared_examples 'perform' do
- it 'notifies the JobWaiter when done if the key is provided' do
+ describe "#perform" do
+ shared_examples "perform" do
+ it "notifies the JobWaiter when done if the key is provided" do
key = Gitlab::JobWaiter.new.key
expect(Gitlab::JobWaiter).to receive(:notify).with(key, job.jid)
job.perform(*args, key)
end
- it 'does not notify the JobWaiter when done if no key is provided' do
+ it "does not notify the JobWaiter when done if no key is provided" do
expect(Gitlab::JobWaiter).not_to receive(:notify)
job.perform(*args)
end
end
- context 'when the worker takes arguments' do
+ context "when the worker takes arguments" do
let(:args) { [1] }
- it_behaves_like 'perform'
+ it_behaves_like "perform"
end
- context 'when the worker takes no arguments' do
+ context "when the worker takes no arguments" do
let(:args) { [] }
- it_behaves_like 'perform'
+ it_behaves_like "perform"
end
end
end
diff --git a/spec/workers/create_gpg_signature_worker_spec.rb b/spec/workers/create_gpg_signature_worker_spec.rb
index f5479e57260..4194485450d 100644
--- a/spec/workers/create_gpg_signature_worker_spec.rb
+++ b/spec/workers/create_gpg_signature_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe CreateGpgSignatureWorker do
let(:project) { create(:project, :repository) }
- let(:commits) { project.repository.commits('HEAD', limit: 3).commits }
+ let(:commits) { project.repository.commits("HEAD", limit: 3).commits }
let(:commit_shas) { commits.map(&:id) }
let(:gpg_commit) { instance_double(Gitlab::Gpg::Commit) }
- context 'when GpgKey is found' do
+ context "when GpgKey is found" do
before do
allow(Project).to receive(:find_by).with(id: project.id).and_return(project)
allow(project).to receive(:commits_by).with(oids: commit_shas).and_return(commits)
@@ -14,7 +14,7 @@ describe CreateGpgSignatureWorker do
subject { described_class.new.perform(commit_shas, project.id) }
- it 'calls Gitlab::Gpg::Commit#signature' do
+ it "calls Gitlab::Gpg::Commit#signature" do
commits.each do |commit|
expect(Gitlab::Gpg::Commit).to receive(:new).with(commit).and_return(gpg_commit).once
end
@@ -24,7 +24,7 @@ describe CreateGpgSignatureWorker do
subject
end
- it 'can recover from exception and continue the signature process' do
+ it "can recover from exception and continue the signature process" do
allow(gpg_commit).to receive(:signature)
allow(Gitlab::Gpg::Commit).to receive(:new).and_return(gpg_commit)
allow(Gitlab::Gpg::Commit).to receive(:new).with(commits.first).and_raise(StandardError)
@@ -35,8 +35,8 @@ describe CreateGpgSignatureWorker do
end
end
- context 'handles when a string is passed in for the commit SHA' do
- it 'creates a signature once' do
+ context "handles when a string is passed in for the commit SHA" do
+ it "creates a signature once" do
allow(Gitlab::Gpg::Commit).to receive(:new).with(commits.first).and_return(gpg_commit)
expect(gpg_commit).to receive(:signature).once
@@ -45,22 +45,22 @@ describe CreateGpgSignatureWorker do
end
end
- context 'when Commit is not found' do
- let(:nonexisting_commit_sha) { '0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a34' }
+ context "when Commit is not found" do
+ let(:nonexisting_commit_sha) { "0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a34" }
- it 'does not raise errors' do
+ it "does not raise errors" do
expect { described_class.new.perform([nonexisting_commit_sha], project.id) }.not_to raise_error
end
end
- context 'when Project is not found' do
+ context "when Project is not found" do
let(:nonexisting_project_id) { -1 }
- it 'does not raise errors' do
+ it "does not raise errors" do
expect { described_class.new.perform(commit_shas, nonexisting_project_id) }.not_to raise_error
end
- it 'does not call Gitlab::Gpg::Commit#signature' do
+ it "does not call Gitlab::Gpg::Commit#signature" do
expect_any_instance_of(Gitlab::Gpg::Commit).not_to receive(:signature)
described_class.new.perform(commit_shas, nonexisting_project_id)
diff --git a/spec/workers/create_note_diff_file_worker_spec.rb b/spec/workers/create_note_diff_file_worker_spec.rb
index 0ac946a1232..6fa05a51d9a 100644
--- a/spec/workers/create_note_diff_file_worker_spec.rb
+++ b/spec/workers/create_note_diff_file_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe CreateNoteDiffFileWorker do
- describe '#perform' do
+ describe "#perform" do
let(:diff_note) { create(:diff_note_on_merge_request) }
- it 'creates diff file' do
+ it "creates diff file" do
diff_note.note_diff_file.destroy!
expect_any_instance_of(DiffNote).to receive(:create_diff_file)
diff --git a/spec/workers/create_pipeline_worker_spec.rb b/spec/workers/create_pipeline_worker_spec.rb
index 02cb0f46cb4..920d5479d0a 100644
--- a/spec/workers/create_pipeline_worker_spec.rb
+++ b/spec/workers/create_pipeline_worker_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe CreatePipelineWorker do
- describe '#perform' do
+ describe "#perform" do
let(:worker) { described_class.new }
- context 'when a project not found' do
- it 'does not call the Service' do
+ context "when a project not found" do
+ it "does not call the Service" do
expect(Ci::CreatePipelineService).not_to receive(:new)
- expect { worker.perform(99, create(:user).id, 'master', :web) }.to raise_error(ActiveRecord::RecordNotFound)
+ expect { worker.perform(99, create(:user).id, "master", :web) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- context 'when a user not found' do
+ context "when a user not found" do
let(:project) { create(:project) }
- it 'does not call the Service' do
+ it "does not call the Service" do
expect(Ci::CreatePipelineService).not_to receive(:new)
expect { worker.perform(project.id, 99, project.default_branch, :web) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- context 'when everything is ok' do
+ context "when everything is ok" do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:create_pipeline_service) { instance_double(Ci::CreatePipelineService) }
- it 'calls the Service' do
+ it "calls the Service" do
expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: project.default_branch).and_return(create_pipeline_service)
expect(create_pipeline_service).to receive(:execute).with(:web, any_args)
diff --git a/spec/workers/delete_container_repository_worker_spec.rb b/spec/workers/delete_container_repository_worker_spec.rb
index 8c40611a959..0d0f1c124a5 100644
--- a/spec/workers/delete_container_repository_worker_spec.rb
+++ b/spec/workers/delete_container_repository_worker_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe DeleteContainerRepositoryWorker do
let(:registry) { create(:container_repository) }
@@ -9,8 +9,8 @@ describe DeleteContainerRepositoryWorker do
subject { described_class.new }
- describe '#perform' do
- it 'executes the destroy service' do
+ describe "#perform" do
+ it "executes the destroy service" do
service = instance_double(Projects::ContainerRepository::DestroyService)
expect(service).to receive(:execute)
expect(Projects::ContainerRepository::DestroyService).to receive(:new).with(project, user).and_return(service)
@@ -18,16 +18,16 @@ describe DeleteContainerRepositoryWorker do
subject.perform(user.id, registry.id)
end
- it 'does not raise error when user could not be found' do
- expect do
+ it "does not raise error when user could not be found" do
+ expect {
subject.perform(-1, registry.id)
- end.not_to raise_error
+ }.not_to raise_error
end
- it 'does not raise error when registry could not be found' do
- expect do
+ it "does not raise error when registry could not be found" do
+ expect {
subject.perform(user.id, -1)
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/workers/delete_diff_files_worker_spec.rb b/spec/workers/delete_diff_files_worker_spec.rb
index e0edd313922..1a57e3df630 100644
--- a/spec/workers/delete_diff_files_worker_spec.rb
+++ b/spec/workers/delete_diff_files_worker_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe DeleteDiffFilesWorker do
- describe '#perform' do
+ describe "#perform" do
let(:merge_request) { create(:merge_request) }
let(:merge_request_diff) { merge_request.merge_request_diff }
- it 'deletes all merge request diff files' do
+ it "deletes all merge request diff files" do
expect { described_class.new.perform(merge_request_diff.id) }
.to change { merge_request_diff.merge_request_diff_files.count }
.from(20).to(0)
end
- it 'updates state to without_files' do
+ it "updates state to without_files" do
expect { described_class.new.perform(merge_request_diff.id) }
.to change { merge_request_diff.reload.state }
- .from('collected').to('without_files')
+ .from("collected").to("without_files")
end
it 'does nothing if diff was already marked as "without_files"' do
@@ -25,7 +25,7 @@ describe DeleteDiffFilesWorker do
described_class.new.perform(merge_request_diff.id)
end
- it 'rollsback if something goes wrong' do
+ it "rollsback if something goes wrong" do
expect(MergeRequestDiffFile).to receive_message_chain(:where, :delete_all)
.and_raise
@@ -34,7 +34,7 @@ describe DeleteDiffFilesWorker do
merge_request_diff.reload
- expect(merge_request_diff.state).to eq('collected')
+ expect(merge_request_diff.state).to eq("collected")
expect(merge_request_diff.merge_request_diff_files.count).to eq(20)
end
end
diff --git a/spec/workers/delete_merged_branches_worker_spec.rb b/spec/workers/delete_merged_branches_worker_spec.rb
index 39009d9e4b2..9a822b55de5 100644
--- a/spec/workers/delete_merged_branches_worker_spec.rb
+++ b/spec/workers/delete_merged_branches_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeleteMergedBranchesWorker do
subject(:worker) { described_class.new }
@@ -13,7 +13,7 @@ describe DeleteMergedBranchesWorker do
end
it "returns false when project was not found" do
- expect(worker.perform('unknown', project.owner.id)).to be_falsy
+ expect(worker.perform("unknown", project.owner.id)).to be_falsy
end
end
end
diff --git a/spec/workers/delete_user_worker_spec.rb b/spec/workers/delete_user_worker_spec.rb
index 06d9e125105..2e1acb07938 100644
--- a/spec/workers/delete_user_worker_spec.rb
+++ b/spec/workers/delete_user_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DeleteUserWorker do
let!(:user) { create(:user) }
diff --git a/spec/workers/deployments/success_worker_spec.rb b/spec/workers/deployments/success_worker_spec.rb
index ba7d45eca01..687a98a6ae7 100644
--- a/spec/workers/deployments/success_worker_spec.rb
+++ b/spec/workers/deployments/success_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Deployments::SuccessWorker do
subject { described_class.new.perform(deployment&.id) }
- context 'when successful deployment' do
+ context "when successful deployment" do
let(:deployment) { create(:deployment, :success) }
- it 'executes UpdateDeploymentService' do
+ it "executes UpdateDeploymentService" do
expect(UpdateDeploymentService)
.to receive(:new).with(deployment).and_call_original
@@ -14,20 +14,20 @@ describe Deployments::SuccessWorker do
end
end
- context 'when canceled deployment' do
+ context "when canceled deployment" do
let(:deployment) { create(:deployment, :canceled) }
- it 'does not execute UpdateDeploymentService' do
+ it "does not execute UpdateDeploymentService" do
expect(UpdateDeploymentService).not_to receive(:new)
subject
end
end
- context 'when deploy record does not exist' do
+ context "when deploy record does not exist" do
let(:deployment) { nil }
- it 'does not execute UpdateDeploymentService' do
+ it "does not execute UpdateDeploymentService" do
expect(UpdateDeploymentService).not_to receive(:new)
subject
diff --git a/spec/workers/detect_repository_languages_worker_spec.rb b/spec/workers/detect_repository_languages_worker_spec.rb
index ff3878fbc8e..dfd743f243d 100644
--- a/spec/workers/detect_repository_languages_worker_spec.rb
+++ b/spec/workers/detect_repository_languages_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe DetectRepositoryLanguagesWorker do
set(:project) { create(:project) }
@@ -6,8 +6,8 @@ describe DetectRepositoryLanguagesWorker do
subject { described_class.new }
- describe '#perform' do
- it 'calls de DetectRepositoryLanguages service' do
+ describe "#perform" do
+ it "calls de DetectRepositoryLanguages service" do
service = double
allow(::Projects::DetectRepositoryLanguagesService).to receive(:new).and_return(service)
expect(service).to receive(:execute)
@@ -15,17 +15,17 @@ describe DetectRepositoryLanguagesWorker do
subject.perform(project.id, user.id)
end
- context 'when invalid ids are used' do
- it 'does not raise when the project could not be found' do
- expect do
+ context "when invalid ids are used" do
+ it "does not raise when the project could not be found" do
+ expect {
subject.perform(-1, user.id)
- end.not_to raise_error
+ }.not_to raise_error
end
- it 'does not raise when the user could not be found' do
- expect do
+ it "does not raise when the user could not be found" do
+ expect {
subject.perform(project.id, -1)
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb
index 045135255d6..a0673c3925d 100644
--- a/spec/workers/email_receiver_worker_spec.rb
+++ b/spec/workers/email_receiver_worker_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe EmailReceiverWorker, :mailer do
- let(:raw_message) { fixture_file('emails/valid_reply.eml') }
+ let(:raw_message) { fixture_file("emails/valid_reply.eml") }
context "when reply by email is enabled" do
before do
@@ -20,10 +20,10 @@ describe EmailReceiverWorker, :mailer do
allow_any_instance_of(Gitlab::Email::Receiver).to receive(:execute).and_raise(error)
end
- context 'when the error is Gitlab::Email::EmptyEmailError' do
+ context "when the error is Gitlab::Email::EmptyEmailError" do
let(:error) { Gitlab::Email::EmptyEmailError }
- it 'sends out a rejection email' do
+ it "sends out a rejection email" do
perform_enqueued_jobs do
described_class.new.perform(raw_message)
end
@@ -35,10 +35,10 @@ describe EmailReceiverWorker, :mailer do
end
end
- context 'when the error is Gitlab::Email::AutoGeneratedEmailError' do
+ context "when the error is Gitlab::Email::AutoGeneratedEmailError" do
let(:error) { Gitlab::Email::AutoGeneratedEmailError }
- it 'does not send out any rejection email' do
+ it "does not send out any rejection email" do
perform_enqueued_jobs do
described_class.new.perform(raw_message)
end
@@ -47,10 +47,10 @@ describe EmailReceiverWorker, :mailer do
end
end
- context 'when the error is Gitlab::Email::InvalidAttachment' do
+ context "when the error is Gitlab::Email::InvalidAttachment" do
let(:error) { Gitlab::Email::InvalidAttachment.new("Could not deal with that") }
- it 'reports the error to the sender' do
+ it "reports the error to the sender" do
perform_enqueued_jobs do
described_class.new.perform(raw_message)
end
diff --git a/spec/workers/emails_on_push_worker_spec.rb b/spec/workers/emails_on_push_worker_spec.rb
index 05b4fb49ea3..89a5b991be4 100644
--- a/spec/workers/emails_on_push_worker_spec.rb
+++ b/spec/workers/emails_on_push_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe EmailsOnPushWorker, :mailer do
include RepoHelpers
@@ -49,7 +49,7 @@ describe EmailsOnPushWorker, :mailer do
context "when push is a force push to delete commits" do
before do
data_force_push = data.stringify_keys.merge(
- "after" => data[:before],
+ "after" => data[:before],
"before" => data[:after]
)
@@ -57,7 +57,7 @@ describe EmailsOnPushWorker, :mailer do
end
it "sends a mail with the correct subject" do
- expect(email.subject).to include('adds bar folder and branch-test text file')
+ expect(email.subject).to include("adds bar folder and branch-test text file")
end
it "mentions force pushing in the body" do
@@ -75,7 +75,7 @@ describe EmailsOnPushWorker, :mailer do
end
it "sends a mail with the correct subject" do
- expect(email.subject).to include('adds bar folder and branch-test text file')
+ expect(email.subject).to include("adds bar folder and branch-test text file")
end
it "does not mention force pushing in the body" do
@@ -112,7 +112,7 @@ describe EmailsOnPushWorker, :mailer do
context "when the recipient addresses are a list of email addresses" do
let(:recipients) do
- 1.upto(5).map { |i| user.email.sub('@', "+#{i}@") }.join("\n")
+ 1.upto(5).map { |i| user.email.sub("@", "+#{i}@") }.join("\n")
end
it "sends the mail to each of the recipients" do
diff --git a/spec/workers/every_sidekiq_worker_spec.rb b/spec/workers/every_sidekiq_worker_spec.rb
index ebe02373275..fb4dd533d0e 100644
--- a/spec/workers/every_sidekiq_worker_spec.rb
+++ b/spec/workers/every_sidekiq_worker_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
-describe 'Every Sidekiq worker' do
- it 'does not use the default queue' do
- expect(Gitlab::SidekiqConfig.workers.map(&:queue)).not_to include('default')
+describe "Every Sidekiq worker" do
+ it "does not use the default queue" do
+ expect(Gitlab::SidekiqConfig.workers.map(&:queue)).not_to include("default")
end
- it 'uses the cronjob queue when the worker runs as a cronjob' do
- expect(Gitlab::SidekiqConfig.cron_workers.map(&:queue)).to all(start_with('cronjob:'))
+ it "uses the cronjob queue when the worker runs as a cronjob" do
+ expect(Gitlab::SidekiqConfig.cron_workers.map(&:queue)).to all(start_with("cronjob:"))
end
- it 'has its queue in Gitlab::SidekiqConfig::QUEUE_CONFIG_PATHS', :aggregate_failures do
+ it "has its queue in Gitlab::SidekiqConfig::QUEUE_CONFIG_PATHS", :aggregate_failures do
file_worker_queues = Gitlab::SidekiqConfig.worker_queues.to_set
worker_queues = Gitlab::SidekiqConfig.workers.map(&:queue).to_set
worker_queues << ActionMailer::DeliveryJob.new.queue_name
- worker_queues << 'default'
+ worker_queues << "default"
missing_from_file = worker_queues - file_worker_queues
expect(missing_from_file).to be_empty, "expected #{missing_from_file.to_a.inspect} to be in Gitlab::SidekiqConfig::QUEUE_CONFIG_PATHS"
@@ -23,12 +23,12 @@ describe 'Every Sidekiq worker' do
expect(unncessarily_in_file).to be_empty, "expected #{unncessarily_in_file.to_a.inspect} not to be in Gitlab::SidekiqConfig::QUEUE_CONFIG_PATHS"
end
- it 'has its queue or namespace in config/sidekiq_queues.yml', :aggregate_failures do
+ it "has its queue or namespace in config/sidekiq_queues.yml", :aggregate_failures do
config_queues = Gitlab::SidekiqConfig.config_queues.to_set
Gitlab::SidekiqConfig.workers.each do |worker|
queue = worker.queue
- queue_namespace = queue.split(':').first
+ queue_namespace = queue.split(":").first
expect(config_queues).to include(queue).or(include(queue_namespace))
end
diff --git a/spec/workers/expire_build_artifacts_worker_spec.rb b/spec/workers/expire_build_artifacts_worker_spec.rb
index 27995cf1611..a791e908140 100644
--- a/spec/workers/expire_build_artifacts_worker_spec.rb
+++ b/spec/workers/expire_build_artifacts_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ExpireBuildArtifactsWorker do
include RepoHelpers
@@ -9,7 +9,7 @@ describe ExpireBuildArtifactsWorker do
Sidekiq::Worker.clear_all
end
- describe '#perform' do
+ describe "#perform" do
before do
stub_feature_flags(ci_new_expire_job_artifacts_service: false)
build
@@ -19,42 +19,42 @@ describe ExpireBuildArtifactsWorker do
Sidekiq::Testing.fake! { worker.perform }
end
- context 'with expired artifacts' do
+ context "with expired artifacts" do
let(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now - 7.days) }
- it 'enqueues that build' do
+ it "enqueues that build" do
expect(jobs_enqueued.size).to eq(1)
expect(jobs_enqueued[0]["args"]).to eq([build.id])
end
end
- context 'with not yet expired artifacts' do
+ context "with not yet expired artifacts" do
let(:build) { create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days) }
- it 'does not enqueue that build' do
+ it "does not enqueue that build" do
expect(jobs_enqueued.size).to eq(0)
end
end
- context 'without expire date' do
+ context "without expire date" do
let(:build) { create(:ci_build, :artifacts) }
- it 'does not enqueue that build' do
+ it "does not enqueue that build" do
expect(jobs_enqueued.size).to eq(0)
end
end
def jobs_enqueued
- Sidekiq::Queues.jobs_by_worker['ExpireBuildInstanceArtifactsWorker']
+ Sidekiq::Queues.jobs_by_worker["ExpireBuildInstanceArtifactsWorker"]
end
end
- describe '#perform with ci_new_expire_job_artifacts_service feature flag' do
+ describe "#perform with ci_new_expire_job_artifacts_service feature flag" do
before do
stub_feature_flags(ci_new_expire_job_artifacts_service: true)
end
- it 'executes a service' do
+ it "executes a service" do
expect_any_instance_of(Ci::DestroyExpiredJobArtifactsService).to receive(:execute)
expect(ExpireBuildInstanceArtifactsWorker).not_to receive(:bulk_perform_async)
diff --git a/spec/workers/expire_build_instance_artifacts_worker_spec.rb b/spec/workers/expire_build_instance_artifacts_worker_spec.rb
index e1a56c72162..34f974469ec 100644
--- a/spec/workers/expire_build_instance_artifacts_worker_spec.rb
+++ b/spec/workers/expire_build_instance_artifacts_worker_spec.rb
@@ -1,71 +1,71 @@
-require 'spec_helper'
+require "spec_helper"
describe ExpireBuildInstanceArtifactsWorker do
include RepoHelpers
let(:worker) { described_class.new }
- describe '#perform' do
+ describe "#perform" do
before do
worker.perform(build.id)
end
- context 'with expired artifacts' do
- context 'when associated project is valid' do
+ context "with expired artifacts" do
+ context "when associated project is valid" do
let(:build) { create(:ci_build, :artifacts, :expired) }
- it 'does expire' do
+ it "does expire" do
expect(build.reload.artifacts_expired?).to be_truthy
end
- it 'does remove files' do
+ it "does remove files" do
expect(build.reload.artifacts_file.exists?).to be_falsey
end
- it 'does remove the job artifact record' do
+ it "does remove the job artifact record" do
expect(build.reload.job_artifacts_archive).to be_nil
end
end
end
- context 'with not yet expired artifacts' do
+ context "with not yet expired artifacts" do
set(:build) do
create(:ci_build, :artifacts, artifacts_expire_at: Time.now + 7.days)
end
- it 'does not expire' do
+ it "does not expire" do
expect(build.reload.artifacts_expired?).to be_falsey
end
- it 'does not remove files' do
+ it "does not remove files" do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
- it 'does not remove the job artifact record' do
+ it "does not remove the job artifact record" do
expect(build.reload.job_artifacts_archive).not_to be_nil
end
end
- context 'without expire date' do
+ context "without expire date" do
let(:build) { create(:ci_build, :artifacts) }
- it 'does not expire' do
+ it "does not expire" do
expect(build.reload.artifacts_expired?).to be_falsey
end
- it 'does not remove files' do
+ it "does not remove files" do
expect(build.reload.artifacts_file.exists?).to be_truthy
end
- it 'does not remove the job artifact record' do
+ it "does not remove the job artifact record" do
expect(build.reload.job_artifacts_archive).not_to be_nil
end
end
- context 'for expired artifacts' do
+ context "for expired artifacts" do
let(:build) { create(:ci_build, :expired) }
- it 'is still expired' do
+ it "is still expired" do
expect(build.reload.artifacts_expired?).to be_truthy
end
end
diff --git a/spec/workers/expire_job_cache_worker_spec.rb b/spec/workers/expire_job_cache_worker_spec.rb
index 1b614342a18..0472993a661 100644
--- a/spec/workers/expire_job_cache_worker_spec.rb
+++ b/spec/workers/expire_job_cache_worker_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe ExpireJobCacheWorker do
set(:pipeline) { create(:ci_empty_pipeline) }
let(:project) { pipeline.project }
subject { described_class.new }
- describe '#perform' do
- context 'with a job in the pipeline' do
+ describe "#perform" do
+ context "with a job in the pipeline" do
let(:job) { create(:ci_build, pipeline: pipeline) }
- it 'invalidates Etag caching for the job path' do
+ it "invalidates Etag caching for the job path" do
pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
job_path = "/#{project.full_path}/builds/#{job.id}.json"
@@ -20,8 +20,8 @@ describe ExpireJobCacheWorker do
end
end
- context 'when there is no job in the pipeline' do
- it 'does not change the etag store' do
+ context "when there is no job in the pipeline" do
+ it "does not change the etag store" do
expect(Gitlab::EtagCaching::Store).not_to receive(:new)
subject.perform(9999)
diff --git a/spec/workers/expire_pipeline_cache_worker_spec.rb b/spec/workers/expire_pipeline_cache_worker_spec.rb
index 54c9a69d329..49ece96e93c 100644
--- a/spec/workers/expire_pipeline_cache_worker_spec.rb
+++ b/spec/workers/expire_pipeline_cache_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ExpirePipelineCacheWorker do
let(:user) { create(:user) }
@@ -6,8 +6,8 @@ describe ExpirePipelineCacheWorker do
let(:pipeline) { create(:ci_pipeline, project: project) }
subject { described_class.new }
- describe '#perform' do
- it 'invalidates Etag caching for project pipelines path' do
+ describe "#perform" do
+ it "invalidates Etag caching for project pipelines path" do
pipelines_path = "/#{project.full_path}/pipelines.json"
new_mr_pipelines_path = "/#{project.full_path}/merge_requests/new.json"
pipeline_path = "/#{project.full_path}/pipelines/#{pipeline.id}.json"
@@ -19,8 +19,8 @@ describe ExpirePipelineCacheWorker do
subject.perform(pipeline.id)
end
- it 'invalidates Etag caching for merge request pipelines if pipeline runs on any commit of that source branch' do
- pipeline = create(:ci_empty_pipeline, status: 'created', project: project, ref: 'master')
+ it "invalidates Etag caching for merge request pipelines if pipeline runs on any commit of that source branch" do
+ pipeline = create(:ci_empty_pipeline, status: "created", project: project, ref: "master")
merge_request = create(:merge_request, source_project: project, source_branch: pipeline.ref)
merge_request_pipelines_path = "/#{project.full_path}/merge_requests/#{merge_request.iid}/pipelines.json"
@@ -36,9 +36,9 @@ describe ExpirePipelineCacheWorker do
subject.perform(617748)
end
- it 'updates the cached status for a project' do
+ it "updates the cached status for a project" do
expect(Gitlab::Cache::Ci::ProjectPipelineStatus).to receive(:update_for_pipeline)
- .with(pipeline)
+ .with(pipeline)
subject.perform(pipeline.id)
end
diff --git a/spec/workers/git_garbage_collect_worker_spec.rb b/spec/workers/git_garbage_collect_worker_spec.rb
index 4895a968d6e..e8f0eaa53a0 100644
--- a/spec/workers/git_garbage_collect_worker_spec.rb
+++ b/spec/workers/git_garbage_collect_worker_spec.rb
@@ -1,6 +1,6 @@
-require 'fileutils'
+require "fileutils"
-require 'spec_helper'
+require "spec_helper"
describe GitGarbageCollectWorker do
include GitHelpers
@@ -13,7 +13,7 @@ describe GitGarbageCollectWorker do
subject { described_class.new }
describe "#perform" do
- context 'with active lease_uuid' do
+ context "with active lease_uuid" do
before do
allow(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
end
@@ -30,19 +30,19 @@ describe GitGarbageCollectWorker do
subject.perform(project.id, :gc, lease_key, lease_uuid)
end
- it 'handles gRPC errors' do
+ it "handles gRPC errors" do
expect_any_instance_of(Gitlab::GitalyClient::RepositoryService).to receive(:garbage_collect).and_raise(GRPC::NotFound)
expect { subject.perform(project.id, :gc, lease_key, lease_uuid) }.to raise_exception(Gitlab::Git::Repository::NoRepository)
end
end
- context 'with different lease than the active one' do
+ context "with different lease than the active one" do
before do
allow(subject).to receive(:get_lease_uuid).and_return(SecureRandom.uuid)
end
- it 'returns silently' do
+ it "returns silently" do
expect_any_instance_of(Repository).not_to receive(:after_create_branch).and_call_original
expect_any_instance_of(Repository).not_to receive(:branch_names).and_call_original
expect_any_instance_of(Repository).not_to receive(:has_visible_content?).and_call_original
@@ -51,12 +51,12 @@ describe GitGarbageCollectWorker do
end
end
- context 'with no active lease' do
+ context "with no active lease" do
before do
allow(subject).to receive(:get_lease_uuid).and_return(false)
end
- context 'when is able to get the lease' do
+ context "when is able to get the lease" do
before do
allow(subject).to receive(:try_obtain_lease).and_return(SecureRandom.uuid)
end
@@ -72,11 +72,11 @@ describe GitGarbageCollectWorker do
subject.perform(project.id)
end
- context 'when the repository has joined a pool' do
+ context "when the repository has joined a pool" do
let!(:pool) { create(:pool_repository, :ready) }
let(:project) { pool.source_project }
- it 'ensures the repositories are linked' do
+ it "ensures the repositories are linked" do
expect_any_instance_of(PoolRepository).to receive(:link_repository).once
subject.perform(project.id)
@@ -84,12 +84,12 @@ describe GitGarbageCollectWorker do
end
end
- context 'when no lease can be obtained' do
+ context "when no lease can be obtained" do
before do
expect(subject).to receive(:try_obtain_lease).and_return(false)
end
- it 'returns silently' do
+ it "returns silently" do
expect(subject).not_to receive(:command)
expect_any_instance_of(Repository).not_to receive(:after_create_branch).and_call_original
expect_any_instance_of(Repository).not_to receive(:branch_names).and_call_original
@@ -126,19 +126,19 @@ describe GitGarbageCollectWorker do
end
end
- shared_examples 'gc tasks' do
+ shared_examples "gc tasks" do
before do
allow(subject).to receive(:get_lease_uuid).and_return(lease_uuid)
allow(subject).to receive(:bitmaps_enabled?).and_return(bitmaps_enabled)
end
- it 'incremental repack adds a new packfile' do
+ it "incremental repack adds a new packfile" do
create_objects(project)
before_packs = packs(project)
expect(before_packs.count).to be >= 1
- subject.perform(project.id, 'incremental_repack', lease_key, lease_uuid)
+ subject.perform(project.id, "incremental_repack", lease_key, lease_uuid)
after_packs = packs(project)
# Exactly one new pack should have been created
@@ -148,14 +148,14 @@ describe GitGarbageCollectWorker do
expect(before_packs & after_packs).to eq(before_packs)
end
- it 'full repack consolidates into 1 packfile' do
+ it "full repack consolidates into 1 packfile" do
create_objects(project)
- subject.perform(project.id, 'incremental_repack', lease_key, lease_uuid)
+ subject.perform(project.id, "incremental_repack", lease_key, lease_uuid)
before_packs = packs(project)
expect(before_packs.count).to be >= 2
- subject.perform(project.id, 'full_repack', lease_key, lease_uuid)
+ subject.perform(project.id, "full_repack", lease_key, lease_uuid)
after_packs = packs(project)
expect(after_packs.count).to eq(1)
@@ -166,14 +166,14 @@ describe GitGarbageCollectWorker do
expect(File.exist?(bitmap_path(after_packs.first))).to eq(bitmaps_enabled)
end
- it 'gc consolidates into 1 packfile and updates packed-refs' do
+ it "gc consolidates into 1 packfile and updates packed-refs" do
create_objects(project)
before_packs = packs(project)
before_packed_refs = packed_refs(project)
expect(before_packs.count).to be >= 1
- subject.perform(project.id, 'gc', lease_key, lease_uuid)
+ subject.perform(project.id, "gc", lease_key, lease_uuid)
after_packed_refs = packed_refs(project)
after_packs = packs(project)
@@ -188,23 +188,23 @@ describe GitGarbageCollectWorker do
expect(File.exist?(bitmap_path(after_packs.first))).to eq(bitmaps_enabled)
end
- it 'cleans up repository after finishing' do
+ it "cleans up repository after finishing" do
expect_any_instance_of(Project).to receive(:cleanup).and_call_original
- subject.perform(project.id, 'gc', lease_key, lease_uuid)
+ subject.perform(project.id, "gc", lease_key, lease_uuid)
end
end
- context 'with bitmaps enabled' do
+ context "with bitmaps enabled" do
let(:bitmaps_enabled) { true }
- include_examples 'gc tasks'
+ include_examples "gc tasks"
end
- context 'with bitmaps disabled' do
+ context "with bitmaps disabled" do
let(:bitmaps_enabled) { false }
- include_examples 'gc tasks'
+ include_examples "gc tasks"
end
end
@@ -215,8 +215,8 @@ describe GitGarbageCollectWorker do
new_commit_sha = Rugged::Commit.create(
rugged,
message: "hello world #{SecureRandom.hex(6)}",
- author: Gitlab::Git.committer_hash(email: 'foo@bar', name: 'baz'),
- committer: Gitlab::Git.committer_hash(email: 'foo@bar', name: 'baz'),
+ author: Gitlab::Git.committer_hash(email: "foo@bar", name: "baz"),
+ committer: Gitlab::Git.committer_hash(email: "foo@bar", name: "baz"),
tree: old_commit.tree,
parents: [old_commit]
)
@@ -236,6 +236,6 @@ describe GitGarbageCollectWorker do
end
def bitmap_path(pack)
- pack.sub(/\.pack\z/, '.bitmap')
+ pack.sub(/\.pack\z/, ".bitmap")
end
end
diff --git a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb
index fc7aafbc0c9..620363e82c5 100644
--- a/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/advance_stage_worker_spec.rb
@@ -1,41 +1,41 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_state do
let(:project) { create(:project) }
- let(:import_state) { create(:import_state, project: project, jid: '123') }
+ let(:import_state) { create(:import_state, project: project, jid: "123") }
let(:worker) { described_class.new }
- describe '#perform' do
- context 'when the project no longer exists' do
- it 'does not perform any work' do
+ describe "#perform" do
+ context "when the project no longer exists" do
+ it "does not perform any work" do
expect(worker).not_to receive(:wait_for_jobs)
- worker.perform(-1, { '123' => 2 }, :finish)
+ worker.perform(-1, {"123" => 2}, :finish)
end
end
- context 'when there are remaining jobs' do
+ context "when there are remaining jobs" do
before do
allow(worker)
.to receive(:find_import_state)
.and_return(import_state)
end
- it 'reschedules itself' do
+ it "reschedules itself" do
expect(worker)
.to receive(:wait_for_jobs)
- .with({ '123' => 2 })
- .and_return({ '123' => 1 })
+ .with({"123" => 2})
+ .and_return({"123" => 1})
expect(described_class)
.to receive(:perform_in)
- .with(described_class::INTERVAL, project.id, { '123' => 1 }, :finish)
+ .with(described_class::INTERVAL, project.id, {"123" => 1}, :finish)
- worker.perform(project.id, { '123' => 2 }, :finish)
+ worker.perform(project.id, {"123" => 2}, :finish)
end
end
- context 'when there are no remaining jobs' do
+ context "when there are no remaining jobs" do
before do
allow(worker)
.to receive(:find_import_state)
@@ -43,11 +43,11 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st
allow(worker)
.to receive(:wait_for_jobs)
- .with({ '123' => 2 })
+ .with({"123" => 2})
.and_return({})
end
- it 'schedules the next stage' do
+ it "schedules the next stage" do
expect(import_state)
.to receive(:refresh_jid_expiration)
@@ -55,31 +55,31 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st
.to receive(:perform_async)
.with(project.id)
- worker.perform(project.id, { '123' => 2 }, :finish)
+ worker.perform(project.id, {"123" => 2}, :finish)
end
- it 'raises KeyError when the stage name is invalid' do
- expect { worker.perform(project.id, { '123' => 2 }, :kittens) }
+ it "raises KeyError when the stage name is invalid" do
+ expect { worker.perform(project.id, {"123" => 2}, :kittens) }
.to raise_error(KeyError)
end
end
end
- describe '#wait_for_jobs' do
- it 'waits for jobs to complete and returns a new pair of keys to wait for' do
- waiter1 = double(:waiter1, jobs_remaining: 1, key: '123')
- waiter2 = double(:waiter2, jobs_remaining: 0, key: '456')
+ describe "#wait_for_jobs" do
+ it "waits for jobs to complete and returns a new pair of keys to wait for" do
+ waiter1 = double(:waiter1, jobs_remaining: 1, key: "123")
+ waiter2 = double(:waiter2, jobs_remaining: 0, key: "456")
expect(Gitlab::JobWaiter)
.to receive(:new)
.ordered
- .with(2, '123')
+ .with(2, "123")
.and_return(waiter1)
expect(Gitlab::JobWaiter)
.to receive(:new)
.ordered
- .with(1, '456')
+ .with(1, "456")
.and_return(waiter2)
expect(waiter1)
@@ -90,23 +90,23 @@ describe Gitlab::GithubImport::AdvanceStageWorker, :clean_gitlab_redis_shared_st
.to receive(:wait)
.with(described_class::BLOCKING_WAIT_TIME)
- new_waiters = worker.wait_for_jobs({ '123' => 2, '456' => 1 })
+ new_waiters = worker.wait_for_jobs({"123" => 2, "456" => 1})
- expect(new_waiters).to eq({ '123' => 1 })
+ expect(new_waiters).to eq({"123" => 1})
end
end
- describe '#find_import_state' do
- it 'returns a ProjectImportState' do
- import_state.update_column(:status, 'started')
+ describe "#find_import_state" do
+ it "returns a ProjectImportState" do
+ import_state.update_column(:status, "started")
found = worker.find_import_state(project.id)
expect(found).to be_an_instance_of(ProjectImportState)
- expect(found.attributes.keys).to match_array(%w(id jid))
+ expect(found.attributes.keys).to match_array(%w[id jid])
end
- it 'returns nil if the project import is not running' do
+ it "returns nil if the project import is not running" do
expect(worker.find_import_state(project.id)).to be_nil
end
end
diff --git a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb
index 5b1c6b6010a..6d00fd642ad 100644
--- a/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_diff_note_worker_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ImportDiffNoteWorker do
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports a diff note' do
- project = double(:project, full_path: 'foo/bar')
+ describe "#import" do
+ it "imports a diff note" do
+ project = double(:project, full_path: "foo/bar")
client = double(:client)
importer = double(:importer)
hash = {
- 'noteable_id' => 42,
- 'path' => 'README.md',
- 'commit_id' => '123abc',
- 'diff_hunk' => "@@ -1 +1 @@\n-Hello\n+Hello world",
- 'user' => { 'id' => 4, 'login' => 'alice' },
- 'note' => 'Hello world',
- 'created_at' => Time.zone.now.to_s,
- 'updated_at' => Time.zone.now.to_s
+ "noteable_id" => 42,
+ "path" => "README.md",
+ "commit_id" => "123abc",
+ "diff_hunk" => "@@ -1 +1 @@\n-Hello\n+Hello world",
+ "user" => {"id" => 4, "login" => "alice"},
+ "note" => "Hello world",
+ "created_at" => Time.zone.now.to_s,
+ "updated_at" => Time.zone.now.to_s,
}
expect(Gitlab::GithubImport::Importer::DiffNoteImporter)
diff --git a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
index ab070d6d081..11cbd557f25 100644
--- a/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_issue_worker_spec.rb
@@ -1,25 +1,25 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ImportIssueWorker do
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports an issue' do
- project = double(:project, full_path: 'foo/bar')
+ describe "#import" do
+ it "imports an issue" do
+ project = double(:project, full_path: "foo/bar")
client = double(:client)
importer = double(:importer)
hash = {
- 'iid' => 42,
- 'title' => 'My Issue',
- 'description' => 'This is my issue',
- 'milestone_number' => 4,
- 'state' => 'opened',
- 'assignees' => [{ 'id' => 4, 'login' => 'alice' }],
- 'label_names' => %w[bug],
- 'user' => { 'id' => 4, 'login' => 'alice' },
- 'created_at' => Time.zone.now.to_s,
- 'updated_at' => Time.zone.now.to_s,
- 'pull_request' => false
+ "iid" => 42,
+ "title" => "My Issue",
+ "description" => "This is my issue",
+ "milestone_number" => 4,
+ "state" => "opened",
+ "assignees" => [{"id" => 4, "login" => "alice"}],
+ "label_names" => %w[bug],
+ "user" => {"id" => 4, "login" => "alice"},
+ "created_at" => Time.zone.now.to_s,
+ "updated_at" => Time.zone.now.to_s,
+ "pull_request" => false,
}
expect(Gitlab::GithubImport::Importer::IssueAndLabelLinksImporter)
diff --git a/spec/workers/gitlab/github_import/import_note_worker_spec.rb b/spec/workers/gitlab/github_import/import_note_worker_spec.rb
index 3a30f06bb2d..c1713405750 100644
--- a/spec/workers/gitlab/github_import/import_note_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_note_worker_spec.rb
@@ -1,20 +1,20 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ImportNoteWorker do
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports a note' do
- project = double(:project, full_path: 'foo/bar')
+ describe "#import" do
+ it "imports a note" do
+ project = double(:project, full_path: "foo/bar")
client = double(:client)
importer = double(:importer)
hash = {
- 'noteable_id' => 42,
- 'noteable_type' => 'issues',
- 'user' => { 'id' => 4, 'login' => 'alice' },
- 'note' => 'Hello world',
- 'created_at' => Time.zone.now.to_s,
- 'updated_at' => Time.zone.now.to_s
+ "noteable_id" => 42,
+ "noteable_type" => "issues",
+ "user" => {"id" => 4, "login" => "alice"},
+ "note" => "Hello world",
+ "created_at" => Time.zone.now.to_s,
+ "updated_at" => Time.zone.now.to_s,
}
expect(Gitlab::GithubImport::Importer::NoteImporter)
diff --git a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb
index 3cccd7cab21..b73598d653e 100644
--- a/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/import_pull_request_worker_spec.rb
@@ -1,31 +1,31 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::ImportPullRequestWorker do
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports a pull request' do
- project = double(:project, full_path: 'foo/bar')
+ describe "#import" do
+ it "imports a pull request" do
+ project = double(:project, full_path: "foo/bar")
client = double(:client)
importer = double(:importer)
hash = {
- 'iid' => 42,
- 'title' => 'My Pull Request',
- 'description' => 'This is my pull request',
- 'source_branch' => 'my-feature',
- 'source_branch_sha' => '123abc',
- 'target_branch' => 'master',
- 'target_branch_sha' => '456def',
- 'source_repository_id' => 400,
- 'target_repository_id' => 200,
- 'source_repository_owner' => 'alice',
- 'state' => 'closed',
- 'milestone_number' => 4,
- 'user' => { 'id' => 4, 'login' => 'alice' },
- 'assignee' => { 'id' => 4, 'login' => 'alice' },
- 'created_at' => Time.zone.now.to_s,
- 'updated_at' => Time.zone.now.to_s,
- 'merged_at' => Time.zone.now.to_s
+ "iid" => 42,
+ "title" => "My Pull Request",
+ "description" => "This is my pull request",
+ "source_branch" => "my-feature",
+ "source_branch_sha" => "123abc",
+ "target_branch" => "master",
+ "target_branch_sha" => "456def",
+ "source_repository_id" => 400,
+ "target_repository_id" => 200,
+ "source_repository_owner" => "alice",
+ "state" => "closed",
+ "milestone_number" => 4,
+ "user" => {"id" => 4, "login" => "alice"},
+ "assignee" => {"id" => 4, "login" => "alice"},
+ "created_at" => Time.zone.now.to_s,
+ "updated_at" => Time.zone.now.to_s,
+ "merged_at" => Time.zone.now.to_s,
}
expect(Gitlab::GithubImport::Importer::PullRequestImporter)
diff --git a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb
index 7ff133f1049..f5cc2919c52 100644
--- a/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/refresh_import_jid_worker_spec.rb
@@ -1,33 +1,33 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::RefreshImportJidWorker do
let(:worker) { described_class.new }
- describe '.perform_in_the_future' do
- it 'schedules a job in the future' do
+ describe ".perform_in_the_future" do
+ it "schedules a job in the future" do
expect(described_class)
.to receive(:perform_in)
- .with(1.minute.to_i, 10, '123')
+ .with(1.minute.to_i, 10, "123")
- described_class.perform_in_the_future(10, '123')
+ described_class.perform_in_the_future(10, "123")
end
end
- describe '#perform' do
+ describe "#perform" do
let(:project) { create(:project) }
- let(:import_state) { create(:import_state, project: project, jid: '123abc') }
+ let(:import_state) { create(:import_state, project: project, jid: "123abc") }
- context 'when the project does not exist' do
- it 'does nothing' do
+ context "when the project does not exist" do
+ it "does nothing" do
expect(Gitlab::SidekiqStatus)
.not_to receive(:running?)
- worker.perform(-1, '123')
+ worker.perform(-1, "123")
end
end
- context 'when the job is running' do
- it 'refreshes the import JID and reschedules itself' do
+ context "when the job is running" do
+ it "refreshes the import JID and reschedules itself" do
allow(worker)
.to receive(:find_import_state)
.with(project.id)
@@ -35,7 +35,7 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do
expect(Gitlab::SidekiqStatus)
.to receive(:running?)
- .with('123')
+ .with("123")
.and_return(true)
expect(project)
@@ -43,14 +43,14 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do
expect(worker.class)
.to receive(:perform_in_the_future)
- .with(project.id, '123')
+ .with(project.id, "123")
- worker.perform(project.id, '123')
+ worker.perform(project.id, "123")
end
end
- context 'when the job is no longer running' do
- it 'returns' do
+ context "when the job is no longer running" do
+ it "returns" do
allow(worker)
.to receive(:find_import_state)
.with(project.id)
@@ -58,19 +58,19 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do
expect(Gitlab::SidekiqStatus)
.to receive(:running?)
- .with('123')
+ .with("123")
.and_return(false)
expect(project)
.not_to receive(:refresh_jid_expiration)
- worker.perform(project.id, '123')
+ worker.perform(project.id, "123")
end
end
end
- describe '#find_import_state' do
- it 'returns a ProjectImportState' do
+ describe "#find_import_state" do
+ it "returns a ProjectImportState" do
project = create(:project, :import_started)
expect(worker.find_import_state(project.id)).to be_an_instance_of(ProjectImportState)
@@ -84,13 +84,13 @@ describe Gitlab::GithubImport::RefreshImportJidWorker do
# .to eq({ 'id' => nil, 'import_jid' => '123abc' })
# end
- it 'returns nil for a import state for which the import process failed' do
+ it "returns nil for a import state for which the import process failed" do
project = create(:project, :import_failed)
expect(worker.find_import_state(project.id)).to be_nil
end
- it 'returns nil for a non-existing find_import_state' do
+ it "returns nil for a non-existing find_import_state" do
expect(worker.find_import_state(-1)).to be_nil
end
end
diff --git a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
index 91e0cddb5d8..c4083453ed0 100644
--- a/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/finish_import_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::FinishImportWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
- describe '#perform' do
- it 'marks the import as finished' do
+ describe "#perform" do
+ it "marks the import as finished" do
expect(project).to receive(:after_import)
expect(worker).to receive(:report_import_time).with(project)
@@ -13,11 +13,11 @@ describe Gitlab::GithubImport::Stage::FinishImportWorker do
end
end
- describe '#report_import_time' do
- it 'reports the total import time' do
+ describe "#report_import_time" do
+ it "reports the total import time" do
expect(worker.histogram)
.to receive(:observe)
- .with({ project: project.path_with_namespace }, a_kind_of(Numeric))
+ .with({project: project.path_with_namespace}, a_kind_of(Numeric))
.and_call_original
expect(worker.counter)
diff --git a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
index ad6154cc4a4..ed79d1988a4 100644
--- a/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_base_data_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportBaseDataWorker do
let(:project) { create(:project) }
let(:import_state) { create(:import_state, project: project) }
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports the base data of a project' do
+ describe "#import" do
+ it "imports the base data of a project" do
importer = double(:importer)
client = double(:client)
diff --git a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
index ab347f5b75b..cfa18a3c440 100644
--- a/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_issues_and_diff_notes_worker_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports the issues and diff notes' do
+ describe "#import" do
+ it "imports the issues and diff notes" do
client = double(:client)
described_class::IMPORTERS.each do |klass|
importer = double(:importer)
- waiter = Gitlab::JobWaiter.new(2, '123')
+ waiter = Gitlab::JobWaiter.new(2, "123")
expect(klass)
.to receive(:new)
@@ -24,7 +24,7 @@ describe Gitlab::GithubImport::Stage::ImportIssuesAndDiffNotesWorker do
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :notes)
+ .with(project.id, {"123" => 2}, :notes)
worker.import(client, project)
end
diff --git a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
index b19884d7991..fc5e11a44a3 100644
--- a/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_lfs_objects_worker_spec.rb
@@ -1,13 +1,13 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportLfsObjectsWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports all the lfs objects' do
+ describe "#import" do
+ it "imports all the lfs objects" do
importer = double(:importer)
- waiter = Gitlab::JobWaiter.new(2, '123')
+ waiter = Gitlab::JobWaiter.new(2, "123")
expect(Gitlab::GithubImport::Importer::LfsObjectsImporter)
.to receive(:new)
@@ -20,7 +20,7 @@ describe Gitlab::GithubImport::Stage::ImportLfsObjectsWorker do
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :finish)
+ .with(project.id, {"123" => 2}, :finish)
worker.import(project)
end
diff --git a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
index 94cff9e4e80..f454d26f208 100644
--- a/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_notes_worker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportNotesWorker do
let(:project) { create(:project) }
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports all the notes' do
+ describe "#import" do
+ it "imports all the notes" do
importer = double(:importer)
client = double(:client)
- waiter = Gitlab::JobWaiter.new(2, '123')
+ waiter = Gitlab::JobWaiter.new(2, "123")
expect(Gitlab::GithubImport::Importer::NotesImporter)
.to receive(:new)
@@ -21,7 +21,7 @@ describe Gitlab::GithubImport::Stage::ImportNotesWorker do
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :lfs_objects)
+ .with(project.id, {"123" => 2}, :lfs_objects)
worker.import(client, project)
end
diff --git a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
index 1fbb073a34a..21cfe932baf 100644
--- a/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_pull_requests_worker_spec.rb
@@ -1,15 +1,15 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do
let(:project) { create(:project) }
let(:import_state) { create(:import_state, project: project) }
let(:worker) { described_class.new }
- describe '#import' do
- it 'imports all the pull requests' do
+ describe "#import" do
+ it "imports all the pull requests" do
importer = double(:importer)
client = double(:client)
- waiter = Gitlab::JobWaiter.new(2, '123')
+ waiter = Gitlab::JobWaiter.new(2, "123")
expect(Gitlab::GithubImport::Importer::PullRequestsImporter)
.to receive(:new)
@@ -25,7 +25,7 @@ describe Gitlab::GithubImport::Stage::ImportPullRequestsWorker do
expect(Gitlab::GithubImport::AdvanceStageWorker)
.to receive(:perform_async)
- .with(project.id, { '123' => 2 }, :issues_and_diff_notes)
+ .with(project.id, {"123" => 2}, :issues_and_diff_notes)
worker.import(client, project)
end
diff --git a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
index adab535ac05..c3f336f14d1 100644
--- a/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
+++ b/spec/workers/gitlab/github_import/stage/import_repository_worker_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
let(:project) { double(:project, id: 4) }
let(:worker) { described_class.new }
- describe '#import' do
+ describe "#import" do
before do
expect(Gitlab::GithubImport::RefreshImportJidWorker)
.to receive(:perform_in_the_future)
- .with(project.id, '123')
+ .with(project.id, "123")
expect(worker)
.to receive(:jid)
- .and_return('123')
+ .and_return("123")
end
- context 'when the import succeeds' do
- it 'schedules the importing of the base data' do
+ context "when the import succeeds" do
+ it "schedules the importing of the base data" do
client = double(:client)
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
@@ -31,8 +31,8 @@ describe Gitlab::GithubImport::Stage::ImportRepositoryWorker do
end
end
- context 'when the import fails' do
- it 'does not schedule the importing of the base data' do
+ context "when the import fails" do
+ it "does not schedule the importing of the base data" do
client = double(:client)
expect_any_instance_of(Gitlab::GithubImport::Importer::RepositoryImporter)
diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb
index 6b222af454d..2284aef0e6d 100644
--- a/spec/workers/gitlab_shell_worker_spec.rb
+++ b/spec/workers/gitlab_shell_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe GitlabShellWorker do
let(:worker) { described_class.new }
- describe '#perform with add_key' do
- it 'calls add_key on Gitlab::Shell' do
- expect_any_instance_of(Gitlab::Shell).to receive(:add_key).with('foo', 'bar')
- worker.perform(:add_key, 'foo', 'bar')
+ describe "#perform with add_key" do
+ it "calls add_key on Gitlab::Shell" do
+ expect_any_instance_of(Gitlab::Shell).to receive(:add_key).with("foo", "bar")
+ worker.perform(:add_key, "foo", "bar")
end
end
end
diff --git a/spec/workers/gitlab_usage_ping_worker_spec.rb b/spec/workers/gitlab_usage_ping_worker_spec.rb
index 49b4e04dc7c..da525d0c464 100644
--- a/spec/workers/gitlab_usage_ping_worker_spec.rb
+++ b/spec/workers/gitlab_usage_ping_worker_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe GitlabUsagePingWorker do
subject { described_class.new }
- it 'delegates to SubmitUsagePingService' do
+ it "delegates to SubmitUsagePingService" do
allow(subject).to receive(:try_obtain_lease).and_return(true)
expect_any_instance_of(SubmitUsagePingService).to receive(:execute)
diff --git a/spec/workers/group_destroy_worker_spec.rb b/spec/workers/group_destroy_worker_spec.rb
index a170c84ab12..8d9d8220e27 100644
--- a/spec/workers/group_destroy_worker_spec.rb
+++ b/spec/workers/group_destroy_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe GroupDestroyWorker do
let(:group) { create(:group) }
diff --git a/spec/workers/hashed_storage/migrator_worker_spec.rb b/spec/workers/hashed_storage/migrator_worker_spec.rb
index a85f820a3eb..659e5f90efd 100644
--- a/spec/workers/hashed_storage/migrator_worker_spec.rb
+++ b/spec/workers/hashed_storage/migrator_worker_spec.rb
@@ -1,18 +1,18 @@
-require 'spec_helper'
+require "spec_helper"
describe HashedStorage::MigratorWorker do
subject(:worker) { described_class.new }
let(:projects) { create_list(:project, 2, :legacy_storage, :empty_repo) }
let(:ids) { projects.map(&:id) }
- describe '#perform' do
- it 'delegates to MigratorService' do
+ describe "#perform" do
+ it "delegates to MigratorService" do
expect_any_instance_of(Gitlab::HashedStorage::Migrator).to receive(:bulk_migrate).with(start: 5, finish: 10)
worker.perform(5, 10)
end
- it 'migrates projects in the specified range' do
+ it "migrates projects in the specified range" do
perform_enqueued_jobs do
worker.perform(ids.min, ids.max)
end
diff --git a/spec/workers/import_issues_csv_worker_spec.rb b/spec/workers/import_issues_csv_worker_spec.rb
index 89370c4890d..311518eb497 100644
--- a/spec/workers/import_issues_csv_worker_spec.rb
+++ b/spec/workers/import_issues_csv_worker_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ImportIssuesCsvWorker do
let(:project) { create(:project) }
@@ -9,9 +9,9 @@ describe ImportIssuesCsvWorker do
let(:worker) { described_class.new }
- describe '#perform' do
- it 'calls #execute on Issues::ImportCsvService and destroys upload' do
- expect_any_instance_of(Issues::ImportCsvService).to receive(:execute).and_return({ success: 5, errors: [], valid_file: true })
+ describe "#perform" do
+ it "calls #execute on Issues::ImportCsvService and destroys upload" do
+ expect_any_instance_of(Issues::ImportCsvService).to receive(:execute).and_return({success: 5, errors: [], valid_file: true})
worker.perform(user.id, project.id, upload.id)
diff --git a/spec/workers/invalid_gpg_signature_update_worker_spec.rb b/spec/workers/invalid_gpg_signature_update_worker_spec.rb
index 5972696515b..8fa97b7ebcf 100644
--- a/spec/workers/invalid_gpg_signature_update_worker_spec.rb
+++ b/spec/workers/invalid_gpg_signature_update_worker_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe InvalidGpgSignatureUpdateWorker do
- context 'when GpgKey is found' do
- it 'calls NotificationService.new.run' do
+ context "when GpgKey is found" do
+ it "calls NotificationService.new.run" do
gpg_key = create(:gpg_key)
invalid_signature_updater = double(:invalid_signature_updater)
@@ -13,14 +13,14 @@ describe InvalidGpgSignatureUpdateWorker do
end
end
- context 'when GpgKey is not found' do
+ context "when GpgKey is not found" do
let(:nonexisting_gpg_key_id) { -1 }
- it 'does not raise errors' do
+ it "does not raise errors" do
expect { described_class.new.perform(nonexisting_gpg_key_id) }.not_to raise_error
end
- it 'does not call NotificationService.new.run' do
+ it "does not call NotificationService.new.run" do
expect(Gitlab::Gpg::InvalidGpgSignatureUpdater).not_to receive(:new)
described_class.new.perform(nonexisting_gpg_key_id)
diff --git a/spec/workers/issue_due_scheduler_worker_spec.rb b/spec/workers/issue_due_scheduler_worker_spec.rb
index 2710267d384..fbebef0d02a 100644
--- a/spec/workers/issue_due_scheduler_worker_spec.rb
+++ b/spec/workers/issue_due_scheduler_worker_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe IssueDueSchedulerWorker do
- describe '#perform' do
- it 'schedules one MailScheduler::IssueDueWorker per project with open issues due tomorrow' do
+ describe "#perform" do
+ it "schedules one MailScheduler::IssueDueWorker per project with open issues due tomorrow" do
project1 = create(:project)
project2 = create(:project)
project_closed_issue = create(:project)
diff --git a/spec/workers/mail_scheduler/issue_due_worker_spec.rb b/spec/workers/mail_scheduler/issue_due_worker_spec.rb
index 1026ae5b4bf..ab05f579b4c 100644
--- a/spec/workers/mail_scheduler/issue_due_worker_spec.rb
+++ b/spec/workers/mail_scheduler/issue_due_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe MailScheduler::IssueDueWorker do
- describe '#perform' do
+ describe "#perform" do
let(:worker) { described_class.new }
let(:project) { create(:project) }
- it 'sends emails for open issues due tomorrow in the project specified' do
+ it "sends emails for open issues due tomorrow in the project specified" do
issue1 = create(:issue, :opened, project: project, due_date: Date.tomorrow)
issue2 = create(:issue, :opened, project: project, due_date: Date.tomorrow)
create(:issue, :closed, project: project, due_date: Date.tomorrow) # closed
diff --git a/spec/workers/mail_scheduler/notification_service_worker_spec.rb b/spec/workers/mail_scheduler/notification_service_worker_spec.rb
index 5cfba01850c..c6f1721e281 100644
--- a/spec/workers/mail_scheduler/notification_service_worker_spec.rb
+++ b/spec/workers/mail_scheduler/notification_service_worker_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe MailScheduler::NotificationServiceWorker do
let(:worker) { described_class.new }
- let(:method) { 'new_key' }
+ let(:method) { "new_key" }
set(:key) { create(:personal_key) }
def serialize(*args)
@@ -13,23 +13,23 @@ describe MailScheduler::NotificationServiceWorker do
ActiveJob::Arguments.deserialize(args)
end
- describe '#perform' do
- it 'deserializes arguments from global IDs' do
+ describe "#perform" do
+ it "deserializes arguments from global IDs" do
expect(worker.notification_service).to receive(method).with(key)
worker.perform(method, *serialize(key))
end
- context 'when the arguments cannot be deserialized' do
- context 'when the arguments are not deserializeable' do
- it 'raises exception' do
+ context "when the arguments cannot be deserialized" do
+ context "when the arguments are not deserializeable" do
+ it "raises exception" do
expect(worker.notification_service).not_to receive(method)
expect { worker.perform(method, key.to_global_id.to_s.succ) }.to raise_exception(ArgumentError)
end
end
- context 'when the arguments are deserializeable' do
- it 'does nothing' do
+ context "when the arguments are deserializeable" do
+ it "does nothing" do
serialized_arguments = *serialize(key)
key.destroy!
@@ -39,52 +39,52 @@ describe MailScheduler::NotificationServiceWorker do
end
end
- context 'when the method is not a public method' do
- it 'raises NoMethodError' do
- expect { worker.perform('notifiable?', *serialize(key)) }.to raise_error(NoMethodError)
+ context "when the method is not a public method" do
+ it "raises NoMethodError" do
+ expect { worker.perform("notifiable?", *serialize(key)) }.to raise_error(NoMethodError)
end
end
end
- describe '.perform_async', :sidekiq do
+ describe ".perform_async", :sidekiq do
around do |example|
Sidekiq::Testing.fake! { example.run }
end
- it 'serializes arguments as global IDs when scheduling' do
+ it "serializes arguments as global IDs when scheduling" do
described_class.perform_async(method, key)
expect(described_class.jobs.count).to eq(1)
- expect(described_class.jobs.first).to include('args' => [method, *serialize(key)])
+ expect(described_class.jobs.first).to include("args" => [method, *serialize(key)])
end
- context 'with ActiveController::Parameters' do
+ context "with ActiveController::Parameters" do
let(:parameters) { ActionController::Parameters.new(hash) }
let(:hash) do
{
"nested" => {
- "hash" => true
- }
+ "hash" => true,
+ },
}
end
- context 'when permitted' do
+ context "when permitted" do
before do
parameters.permit!
end
- it 'serializes as a serializable Hash' do
+ it "serializes as a serializable Hash" do
described_class.perform_async(method, parameters)
expect(described_class.jobs.count).to eq(1)
- expect(deserialize(described_class.jobs.first['args']))
+ expect(deserialize(described_class.jobs.first["args"]))
.to eq([method, hash])
end
end
- context 'when not permitted' do
- it 'fails to serialize' do
+ context "when not permitted" do
+ it "fails to serialize" do
expect { described_class.perform_async(method, parameters) }
.to raise_error(ActionController::UnfilteredParameters)
end
diff --git a/spec/workers/merge_worker_spec.rb b/spec/workers/merge_worker_spec.rb
index b57c275c770..03615825d64 100644
--- a/spec/workers/merge_worker_spec.rb
+++ b/spec/workers/merge_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe MergeWorker do
describe "remove source branch" do
@@ -12,19 +12,20 @@ describe MergeWorker do
source_project.repository.expire_branches_cache
end
- it 'clears cache of source repo after removing source branch' do
- expect(source_project.repository.branch_names).to include('markdown')
+ it "clears cache of source repo after removing source branch" do
+ expect(source_project.repository.branch_names).to include("markdown")
described_class.new.perform(
merge_request.id, merge_request.author_id,
- commit_message: 'wow such merge',
- should_remove_source_branch: true)
+ commit_message: "wow such merge",
+ should_remove_source_branch: true
+ )
merge_request.reload
expect(merge_request).to be_merged
source_project.repository.expire_branches_cache
- expect(source_project.repository.branch_names).not_to include('markdown')
+ expect(source_project.repository.branch_names).not_to include("markdown")
end
end
end
diff --git a/spec/workers/namespaceless_project_destroy_worker_spec.rb b/spec/workers/namespaceless_project_destroy_worker_spec.rb
index 2f21a1321e1..87fc32962dc 100644
--- a/spec/workers/namespaceless_project_destroy_worker_spec.rb
+++ b/spec/workers/namespaceless_project_destroy_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe NamespacelessProjectDestroyWorker do
include ProjectForksHelper
@@ -11,9 +11,9 @@ describe NamespacelessProjectDestroyWorker do
allow_any_instance_of(Project).to receive(:update_project_statistics).and_return(nil)
end
- describe '#perform' do
- context 'project has namespace' do
- it 'does not do anything' do
+ describe "#perform" do
+ context "project has namespace" do
+ it "does not do anything" do
project = create(:project)
subject.perform(project.id)
@@ -22,40 +22,40 @@ describe NamespacelessProjectDestroyWorker do
end
end
- context 'project has no namespace' do
+ context "project has no namespace" do
let!(:project) { create(:project) }
before do
allow_any_instance_of(Project).to receive(:namespace).and_return(nil)
end
- context 'project not a fork of another project' do
+ context "project not a fork of another project" do
it "truncates the project's team" do
expect_any_instance_of(ProjectTeam).to receive(:truncate)
subject.perform(project.id)
end
- it 'deletes the project' do
+ it "deletes the project" do
subject.perform(project.id)
expect(Project.unscoped.all).not_to include(project)
end
- it 'does not call unlink_fork' do
+ it "does not call unlink_fork" do
is_expected.not_to receive(:unlink_fork)
subject.perform(project.id)
end
- it 'does not do anything in Project#remove_pages method' do
+ it "does not do anything in Project#remove_pages method" do
expect(Gitlab::PagesTransfer).not_to receive(:new)
subject.perform(project.id)
end
end
- context 'project forked from another' do
+ context "project forked from another" do
let!(:parent_project) { create(:project) }
let(:project) do
namespaceless_project = fork_project(parent_project)
@@ -63,7 +63,7 @@ describe NamespacelessProjectDestroyWorker do
namespaceless_project
end
- it 'closes open merge requests' do
+ it "closes open merge requests" do
merge_request = create(:merge_request, source_project: project, target_project: parent_project)
subject.perform(project.id)
@@ -71,7 +71,7 @@ describe NamespacelessProjectDestroyWorker do
expect(merge_request.reload).to be_closed
end
- it 'destroys fork network members' do
+ it "destroys fork network members" do
subject.perform(project.id)
expect(parent_project.forked_to_members).to be_empty
@@ -79,14 +79,14 @@ describe NamespacelessProjectDestroyWorker do
end
end
- context 'project has non-existing namespace' do
+ context "project has non-existing namespace" do
let!(:project) do
project = build(:project, namespace_id: Namespace.maximum(:id).to_i.succ)
project.save(validate: false)
project
end
- it 'deletes the project' do
+ it "deletes the project" do
subject.perform(project.id)
expect(Project.unscoped.all).not_to include(project)
diff --git a/spec/workers/new_issue_worker_spec.rb b/spec/workers/new_issue_worker_spec.rb
index baa8ddb59e5..a93afa8c422 100644
--- a/spec/workers/new_issue_worker_spec.rb
+++ b/spec/workers/new_issue_worker_spec.rb
@@ -1,52 +1,52 @@
-require 'spec_helper'
+require "spec_helper"
describe NewIssueWorker do
- describe '#perform' do
+ describe "#perform" do
let(:worker) { described_class.new }
- context 'when an issue not found' do
- it 'does not call Services' do
+ context "when an issue not found" do
+ it "does not call Services" do
expect(EventCreateService).not_to receive(:new)
expect(NotificationService).not_to receive(:new)
worker.perform(99, create(:user).id)
end
- it 'logs an error' do
- expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find Issue with ID=99, skipping job')
+ it "logs an error" do
+ expect(Rails.logger).to receive(:error).with("NewIssueWorker: couldn't find Issue with ID=99, skipping job")
worker.perform(99, create(:user).id)
end
end
- context 'when a user not found' do
- it 'does not call Services' do
+ context "when a user not found" do
+ it "does not call Services" do
expect(EventCreateService).not_to receive(:new)
expect(NotificationService).not_to receive(:new)
worker.perform(create(:issue).id, 99)
end
- it 'logs an error' do
- expect(Rails.logger).to receive(:error).with('NewIssueWorker: couldn\'t find User with ID=99, skipping job')
+ it "logs an error" do
+ expect(Rails.logger).to receive(:error).with("NewIssueWorker: couldn't find User with ID=99, skipping job")
worker.perform(create(:issue).id, 99)
end
end
- context 'when everything is ok' do
+ context "when everything is ok" do
let(:project) { create(:project, :public) }
let(:mentioned) { create(:user) }
let(:user) { create(:user) }
let(:issue) { create(:issue, project: project, description: "issue for #{mentioned.to_reference}") }
- it 'creates a new event record' do
+ it "creates a new event record" do
expect { worker.perform(issue.id, user.id) }.to change { Event.count }.from(0).to(1)
end
- it 'creates a notification for the mentioned user' do
+ it "creates a notification for the mentioned user" do
expect(Notify).to receive(:new_issue_email).with(mentioned.id, issue.id, NotificationReason::MENTIONED)
- .and_return(double(deliver_later: true))
+ .and_return(double(deliver_later: true))
worker.perform(issue.id, user.id)
end
diff --git a/spec/workers/new_merge_request_worker_spec.rb b/spec/workers/new_merge_request_worker_spec.rb
index c3f29a40d58..bd589fff350 100644
--- a/spec/workers/new_merge_request_worker_spec.rb
+++ b/spec/workers/new_merge_request_worker_spec.rb
@@ -1,40 +1,40 @@
-require 'spec_helper'
+require "spec_helper"
describe NewMergeRequestWorker do
- describe '#perform' do
+ describe "#perform" do
let(:worker) { described_class.new }
- context 'when a merge request not found' do
- it 'does not call Services' do
+ context "when a merge request not found" do
+ it "does not call Services" do
expect(EventCreateService).not_to receive(:new)
expect(NotificationService).not_to receive(:new)
worker.perform(99, create(:user).id)
end
- it 'logs an error' do
- expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find MergeRequest with ID=99, skipping job')
+ it "logs an error" do
+ expect(Rails.logger).to receive(:error).with("NewMergeRequestWorker: couldn't find MergeRequest with ID=99, skipping job")
worker.perform(99, create(:user).id)
end
end
- context 'when a user not found' do
- it 'does not call Services' do
+ context "when a user not found" do
+ it "does not call Services" do
expect(EventCreateService).not_to receive(:new)
expect(NotificationService).not_to receive(:new)
worker.perform(create(:merge_request).id, 99)
end
- it 'logs an error' do
- expect(Rails.logger).to receive(:error).with('NewMergeRequestWorker: couldn\'t find User with ID=99, skipping job')
+ it "logs an error" do
+ expect(Rails.logger).to receive(:error).with("NewMergeRequestWorker: couldn't find User with ID=99, skipping job")
worker.perform(create(:merge_request).id, 99)
end
end
- context 'when everything is ok' do
+ context "when everything is ok" do
let(:project) { create(:project, :public) }
let(:mentioned) { create(:user) }
let(:user) { create(:user) }
@@ -42,14 +42,14 @@ describe NewMergeRequestWorker do
create(:merge_request, source_project: project, description: "mr for #{mentioned.to_reference}")
end
- it 'creates a new event record' do
+ it "creates a new event record" do
expect { worker.perform(merge_request.id, user.id) }.to change { Event.count }.from(0).to(1)
end
- it 'creates a notification for the mentioned user' do
+ it "creates a notification for the mentioned user" do
expect(Notify).to receive(:new_merge_request_email)
- .with(mentioned.id, merge_request.id, NotificationReason::MENTIONED)
- .and_return(double(deliver_later: true))
+ .with(mentioned.id, merge_request.id, NotificationReason::MENTIONED)
+ .and_return(double(deliver_later: true))
worker.perform(merge_request.id, user.id)
end
diff --git a/spec/workers/new_note_worker_spec.rb b/spec/workers/new_note_worker_spec.rb
index 575361c93d4..e6a003f6882 100644
--- a/spec/workers/new_note_worker_spec.rb
+++ b/spec/workers/new_note_worker_spec.rb
@@ -1,7 +1,7 @@
require "spec_helper"
describe NewNoteWorker do
- context 'when Note found' do
+ context "when Note found" do
let(:note) { create(:note) }
it "calls NotificationService#new_note" do
@@ -20,17 +20,17 @@ describe NewNoteWorker do
end
end
- context 'when Note not found' do
+ context "when Note not found" do
let(:unexistent_note_id) { 999 }
- it 'logs NewNoteWorker process skipping' do
+ it "logs NewNoteWorker process skipping" do
expect(Rails.logger).to receive(:error)
.with("NewNoteWorker: couldn't find note with ID=999, skipping job")
described_class.new.perform(unexistent_note_id)
end
- it 'does not raise errors' do
+ it "does not raise errors" do
expect { described_class.new.perform(unexistent_note_id) }.not_to raise_error
end
diff --git a/spec/workers/object_pool/create_worker_spec.rb b/spec/workers/object_pool/create_worker_spec.rb
index 06416489472..845ed62beef 100644
--- a/spec/workers/object_pool/create_worker_spec.rb
+++ b/spec/workers/object_pool/create_worker_spec.rb
@@ -1,53 +1,53 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ObjectPool::CreateWorker do
let(:pool) { create(:pool_repository, :scheduled) }
subject { described_class.new }
- describe '#perform' do
- context 'when the pool creation is successful' do
- it 'marks the pool as ready' do
+ describe "#perform" do
+ context "when the pool creation is successful" do
+ it "marks the pool as ready" do
subject.perform(pool.id)
expect(pool.reload).to be_ready
end
end
- context 'when a the pool already exists' do
+ context "when a the pool already exists" do
before do
pool.create_object_pool
end
- it 'cleans up the pool' do
- expect do
+ it "cleans up the pool" do
+ expect {
subject.perform(pool.id)
- end.to raise_error(GRPC::FailedPrecondition)
+ }.to raise_error(GRPC::FailedPrecondition)
expect(pool.reload.failed?).to be(true)
end
end
- context 'when the server raises an unknown error' do
+ context "when the server raises an unknown error" do
before do
allow_any_instance_of(PoolRepository).to receive(:create_object_pool).and_raise(GRPC::Internal)
end
- it 'marks the pool as failed' do
- expect do
+ it "marks the pool as failed" do
+ expect {
subject.perform(pool.id)
- end.to raise_error(GRPC::Internal)
+ }.to raise_error(GRPC::Internal)
expect(pool.reload.failed?).to be(true)
end
end
- context 'when the pool creation failed before' do
+ context "when the pool creation failed before" do
let(:pool) { create(:pool_repository, :failed) }
- it 'deletes the pool first' do
+ it "deletes the pool first" do
expect_any_instance_of(PoolRepository).to receive(:delete_object_pool)
subject.perform(pool.id)
diff --git a/spec/workers/object_pool/destroy_worker_spec.rb b/spec/workers/object_pool/destroy_worker_spec.rb
index ef74f0ba87c..325f86cb063 100644
--- a/spec/workers/object_pool/destroy_worker_spec.rb
+++ b/spec/workers/object_pool/destroy_worker_spec.rb
@@ -1,27 +1,27 @@
# frozen_string_literal: true
describe ObjectPool::DestroyWorker do
- describe '#perform' do
- context 'when no pool is in the database' do
+ describe "#perform" do
+ context "when no pool is in the database" do
it "doesn't raise an error" do
- expect do
+ expect {
described_class.new.perform(987654321)
- end.not_to raise_error
+ }.not_to raise_error
end
end
- context 'when a pool is present' do
+ context "when a pool is present" do
let(:pool) { create(:pool_repository, :obsolete) }
subject { described_class.new }
- it 'requests Gitaly to remove the object pool' do
+ it "requests Gitaly to remove the object pool" do
expect(Gitlab::GitalyClient).to receive(:call).with(pool.shard_name, :object_pool_service, :delete_object_pool, Object)
subject.perform(pool.id)
end
- it 'destroys the pool' do
+ it "destroys the pool" do
subject.perform(pool.id)
expect(PoolRepository.find_by_id(pool.id)).to be_nil
diff --git a/spec/workers/object_pool/join_worker_spec.rb b/spec/workers/object_pool/join_worker_spec.rb
index 906bc22c8d2..742b581456e 100644
--- a/spec/workers/object_pool/join_worker_spec.rb
+++ b/spec/workers/object_pool/join_worker_spec.rb
@@ -1,6 +1,6 @@
# frozen_string_literal: true
-require 'spec_helper'
+require "spec_helper"
describe ObjectPool::JoinWorker do
let(:pool) { create(:pool_repository, :ready) }
@@ -9,26 +9,26 @@ describe ObjectPool::JoinWorker do
subject { described_class.new }
- describe '#perform' do
+ describe "#perform" do
context "when the pool is not joinable" do
let(:pool) { create(:pool_repository, :scheduled) }
it "doesn't raise an error" do
- expect do
+ expect {
subject.perform(pool.id, project.id)
- end.not_to raise_error
+ }.not_to raise_error
end
end
- context 'when the pool has been joined before' do
+ context "when the pool has been joined before" do
before do
pool.link_repository(repository)
end
- it 'succeeds in joining' do
- expect do
+ it "succeeds in joining" do
+ expect {
subject.perform(pool.id, project.id)
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/workers/pages_domain_verification_cron_worker_spec.rb b/spec/workers/pages_domain_verification_cron_worker_spec.rb
index 8f780428c82..eaac802a527 100644
--- a/spec/workers/pages_domain_verification_cron_worker_spec.rb
+++ b/spec/workers/pages_domain_verification_cron_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe PagesDomainVerificationCronWorker do
subject(:worker) { described_class.new }
- describe '#perform' do
- it 'enqueues a PagesDomainVerificationWorker for domains needing verification' do
+ describe "#perform" do
+ it "enqueues a PagesDomainVerificationWorker for domains needing verification" do
verified = create(:pages_domain)
reverify = create(:pages_domain, :reverify)
disabled = create(:pages_domain, :disabled)
diff --git a/spec/workers/pages_domain_verification_worker_spec.rb b/spec/workers/pages_domain_verification_worker_spec.rb
index 372fc95ab4a..67b0ca716c1 100644
--- a/spec/workers/pages_domain_verification_worker_spec.rb
+++ b/spec/workers/pages_domain_verification_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe PagesDomainVerificationWorker do
subject(:worker) { described_class.new }
let(:domain) { create(:pages_domain) }
- describe '#perform' do
- it 'does nothing for a non-existent domain' do
+ describe "#perform" do
+ it "does nothing for a non-existent domain" do
domain.destroy
expect(VerifyPagesDomainService).not_to receive(:new)
@@ -14,7 +14,7 @@ describe PagesDomainVerificationWorker do
expect { worker.perform(domain.id) }.not_to raise_error
end
- it 'delegates to VerifyPagesDomainService' do
+ it "delegates to VerifyPagesDomainService" do
service = double(:service)
expected_domain = satisfy { |obj| obj == domain }
diff --git a/spec/workers/pipeline_hooks_worker_spec.rb b/spec/workers/pipeline_hooks_worker_spec.rb
index 035e329839f..b8d79b29161 100644
--- a/spec/workers/pipeline_hooks_worker_spec.rb
+++ b/spec/workers/pipeline_hooks_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineHooksWorker do
- describe '#perform' do
- context 'when pipeline exists' do
+ describe "#perform" do
+ context "when pipeline exists" do
let(:pipeline) { create(:ci_pipeline) }
- it 'executes hooks for the pipeline' do
+ it "executes hooks for the pipeline" do
expect_any_instance_of(Ci::Pipeline)
.to receive(:execute_hooks)
@@ -13,8 +13,8 @@ describe PipelineHooksWorker do
end
end
- context 'when pipeline does not exist' do
- it 'does not raise exception' do
+ context "when pipeline does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb
index 896f9e6e7f2..911f4ef7013 100644
--- a/spec/workers/pipeline_metrics_worker_spec.rb
+++ b/spec/workers/pipeline_metrics_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineMetricsWorker do
let(:project) { create(:project, :repository) }
@@ -11,45 +11,45 @@ describe PipelineMetricsWorker do
let(:pipeline) do
create(:ci_empty_pipeline,
- status: status,
- project: project,
- ref: 'master',
- sha: project.repository.commit('master').id,
- started_at: 1.hour.ago,
- finished_at: Time.now)
+ status: status,
+ project: project,
+ ref: "master",
+ sha: project.repository.commit("master").id,
+ started_at: 1.hour.ago,
+ finished_at: Time.now)
end
- let(:status) { 'pending' }
+ let(:status) { "pending" }
- describe '#perform' do
+ describe "#perform" do
before do
described_class.new.perform(pipeline.id)
end
- context 'when pipeline is running' do
- let(:status) { 'running' }
+ context "when pipeline is running" do
+ let(:status) { "running" }
- it 'records the build start time' do
+ it "records the build start time" do
expect(merge_request.reload.metrics.latest_build_started_at).to be_like_time(pipeline.started_at)
end
- it 'clears the build end time' do
+ it "clears the build end time" do
expect(merge_request.reload.metrics.latest_build_finished_at).to be_nil
end
- it 'records the pipeline' do
+ it "records the pipeline" do
expect(merge_request.reload.metrics.pipeline).to eq(pipeline)
end
end
- context 'when pipeline succeeded' do
- let(:status) { 'success' }
+ context "when pipeline succeeded" do
+ let(:status) { "success" }
- it 'records the build end time' do
+ it "records the build end time" do
expect(merge_request.reload.metrics.latest_build_finished_at).to be_like_time(pipeline.finished_at)
end
- it 'records the pipeline' do
+ it "records the pipeline" do
expect(merge_request.reload.metrics.pipeline).to eq(pipeline)
end
end
diff --git a/spec/workers/pipeline_notification_worker_spec.rb b/spec/workers/pipeline_notification_worker_spec.rb
index eb539ffd893..e1e38b852b2 100644
--- a/spec/workers/pipeline_notification_worker_spec.rb
+++ b/spec/workers/pipeline_notification_worker_spec.rb
@@ -1,16 +1,16 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineNotificationWorker, :mailer do
let(:pipeline) { create(:ci_pipeline) }
- describe '#execute' do
- it 'calls NotificationService#pipeline_finished when the pipeline exists' do
+ describe "#execute" do
+ it "calls NotificationService#pipeline_finished when the pipeline exists" do
expect(NotificationService).to receive_message_chain(:new, :pipeline_finished)
subject.perform(pipeline.id)
end
- it 'does nothing when the pipeline does not exist' do
+ it "does nothing when the pipeline does not exist" do
expect(NotificationService).not_to receive(:new)
subject.perform(Ci::Pipeline.maximum(:id).to_i.succ)
diff --git a/spec/workers/pipeline_process_worker_spec.rb b/spec/workers/pipeline_process_worker_spec.rb
index 86e9d7f6684..d5c310b2ffb 100644
--- a/spec/workers/pipeline_process_worker_spec.rb
+++ b/spec/workers/pipeline_process_worker_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineProcessWorker do
- describe '#perform' do
- context 'when pipeline exists' do
+ describe "#perform" do
+ context "when pipeline exists" do
let(:pipeline) { create(:ci_pipeline) }
- it 'processes pipeline' do
+ it "processes pipeline" do
expect_any_instance_of(Ci::Pipeline).to receive(:process!)
described_class.new.perform(pipeline.id)
end
end
- context 'when pipeline does not exist' do
- it 'does not raise exception' do
+ context "when pipeline does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/pipeline_schedule_worker_spec.rb b/spec/workers/pipeline_schedule_worker_spec.rb
index ff408427926..71aae3d1d58 100644
--- a/spec/workers/pipeline_schedule_worker_spec.rb
+++ b/spec/workers/pipeline_schedule_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineScheduleWorker do
subject { described_class.new.perform }
@@ -17,14 +17,14 @@ describe PipelineScheduleWorker do
pipeline_schedule.update_column(:next_run_at, 1.day.ago)
end
- context 'when the schedule is runnable by the user' do
+ context "when the schedule is runnable by the user" do
before do
project.add_maintainer(user)
end
- context 'when there is a scheduled pipeline within next_run_at' do
- shared_examples 'successful scheduling' do
- it 'creates a new pipeline' do
+ context "when there is a scheduled pipeline within next_run_at" do
+ shared_examples "successful scheduling" do
+ it "creates a new pipeline" do
expect { subject }.to change { project.ci_pipelines.count }.by(1)
expect(Ci::Pipeline.last).to be_schedule
@@ -35,35 +35,35 @@ describe PipelineScheduleWorker do
end
end
- it_behaves_like 'successful scheduling'
+ it_behaves_like "successful scheduling"
- context 'when the latest commit contains [ci skip]' do
+ context "when the latest commit contains [ci skip]" do
before do
allow_any_instance_of(Ci::Pipeline)
.to receive(:git_commit_message)
- .and_return('some commit [ci skip]')
+ .and_return("some commit [ci skip]")
end
- it_behaves_like 'successful scheduling'
+ it_behaves_like "successful scheduling"
end
end
- context 'when the schedule is deactivated' do
+ context "when the schedule is deactivated" do
before do
pipeline_schedule.deactivate!
end
- it 'does not creates a new pipeline' do
+ it "does not creates a new pipeline" do
expect { subject }.not_to change { project.ci_pipelines.count }
end
end
- context 'when gitlab-ci.yml is corrupted' do
+ context "when gitlab-ci.yml is corrupted" do
before do
- stub_ci_pipeline_yaml_file(YAML.dump(rspec: { variables: 'rspec' } ))
+ stub_ci_pipeline_yaml_file(YAML.dump(rspec: {variables: "rspec"}))
end
- it 'creates a failed pipeline with the reason' do
+ it "creates a failed pipeline with the reason" do
expect { subject }.to change { project.ci_pipelines.count }.by(1)
expect(Ci::Pipeline.last).to be_config_error
expect(Ci::Pipeline.last.yaml_errors).not_to be_nil
@@ -71,22 +71,22 @@ describe PipelineScheduleWorker do
end
end
- context 'when the schedule is not runnable by the user' do
+ context "when the schedule is not runnable by the user" do
before do
expect(Gitlab::Sentry)
.to receive(:track_exception)
.with(Ci::CreatePipelineService::CreateError,
- issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/41231',
- extra: { schedule_id: pipeline_schedule.id } ).once
+ issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/41231",
+ extra: {schedule_id: pipeline_schedule.id}).once
end
- it 'does not deactivate the schedule' do
+ it "does not deactivate the schedule" do
subject
expect(pipeline_schedule.reload.active).to be_truthy
end
- it 'increments Prometheus counter' do
+ it "increments Prometheus counter" do
expect(Gitlab::Metrics)
.to receive(:counter)
.with(:pipeline_schedule_creation_failed_total, "Counter of failed attempts of pipeline schedule creation")
@@ -95,7 +95,7 @@ describe PipelineScheduleWorker do
subject
end
- it 'logging a pipeline error' do
+ it "logging a pipeline error" do
expect(Rails.logger)
.to receive(:error)
.with(a_string_matching("Insufficient permissions to create a new pipeline"))
@@ -104,16 +104,16 @@ describe PipelineScheduleWorker do
subject
end
- it 'does not create a pipeline' do
+ it "does not create a pipeline" do
expect { subject }.not_to change { project.ci_pipelines.count }
end
- it 'does not raise an exception' do
+ it "does not raise an exception" do
expect { subject }.not_to raise_error
end
end
- context 'when .gitlab-ci.yml is missing in the project' do
+ context "when .gitlab-ci.yml is missing in the project" do
before do
stub_ci_pipeline_yaml_file(nil)
project.add_maintainer(user)
@@ -121,11 +121,11 @@ describe PipelineScheduleWorker do
expect(Gitlab::Sentry)
.to receive(:track_exception)
.with(Ci::CreatePipelineService::CreateError,
- issue_url: 'https://gitlab.com/gitlab-org/gitlab-ce/issues/41231',
- extra: { schedule_id: pipeline_schedule.id } ).once
+ issue_url: "https://gitlab.com/gitlab-org/gitlab-ce/issues/41231",
+ extra: {schedule_id: pipeline_schedule.id}).once
end
- it 'logging a pipeline error' do
+ it "logging a pipeline error" do
expect(Rails.logger)
.to receive(:error)
.with(a_string_matching("Missing .gitlab-ci.yml file"))
@@ -134,11 +134,11 @@ describe PipelineScheduleWorker do
subject
end
- it 'does not create a pipeline' do
+ it "does not create a pipeline" do
expect { subject }.not_to change { project.ci_pipelines.count }
end
- it 'does not raise an exception' do
+ it "does not raise an exception" do
expect { subject }.not_to raise_error
end
end
diff --git a/spec/workers/pipeline_success_worker_spec.rb b/spec/workers/pipeline_success_worker_spec.rb
index d1c84adda6f..eaba55d2a84 100644
--- a/spec/workers/pipeline_success_worker_spec.rb
+++ b/spec/workers/pipeline_success_worker_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineSuccessWorker do
- describe '#perform' do
- context 'when pipeline exists' do
- let(:pipeline) { create(:ci_pipeline, status: 'success') }
+ describe "#perform" do
+ context "when pipeline exists" do
+ let(:pipeline) { create(:ci_pipeline, status: "success") }
it 'performs "merge when pipeline succeeds"' do
expect_any_instance_of(
@@ -14,8 +14,8 @@ describe PipelineSuccessWorker do
end
end
- context 'when pipeline does not exist' do
- it 'does not raise exception' do
+ context "when pipeline does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/pipeline_update_worker_spec.rb b/spec/workers/pipeline_update_worker_spec.rb
index 0b456cfd0da..ddf128de9d7 100644
--- a/spec/workers/pipeline_update_worker_spec.rb
+++ b/spec/workers/pipeline_update_worker_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe PipelineUpdateWorker do
- describe '#perform' do
- context 'when pipeline exists' do
+ describe "#perform" do
+ context "when pipeline exists" do
let(:pipeline) { create(:ci_pipeline) }
- it 'updates pipeline status' do
+ it "updates pipeline status" do
expect_any_instance_of(Ci::Pipeline).to receive(:update_status)
described_class.new.perform(pipeline.id)
end
end
- context 'when pipeline does not exist' do
- it 'does not raise exception' do
+ context "when pipeline does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/plugin_worker_spec.rb b/spec/workers/plugin_worker_spec.rb
index 9238a8199bc..967024f8fbb 100644
--- a/spec/workers/plugin_worker_spec.rb
+++ b/spec/workers/plugin_worker_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe PluginWorker do
include RepoHelpers
- let(:filename) { 'my_plugin.rb' }
- let(:data) { { 'event_name' => 'project_create' } }
+ let(:filename) { "my_plugin.rb" }
+ let(:data) { {"event_name" => "project_create"} }
subject { described_class.new }
- describe '#perform' do
- it 'executes Gitlab::Plugin with expected values' do
- allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_return([true, ''])
+ describe "#perform" do
+ it "executes Gitlab::Plugin with expected values" do
+ allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_return([true, ""])
expect(subject.perform(filename, data)).to be_truthy
end
- it 'logs message in case of plugin execution failure' do
- allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_return([false, 'permission denied'])
+ it "logs message in case of plugin execution failure" do
+ allow(Gitlab::Plugin).to receive(:execute).with(filename, data).and_return([false, "permission denied"])
expect(Gitlab::PluginLogger).to receive(:error)
expect(subject.perform(filename, data)).to be_truthy
diff --git a/spec/workers/post_receive_spec.rb b/spec/workers/post_receive_spec.rb
index caae46a3175..4c0e311ec8d 100644
--- a/spec/workers/post_receive_spec.rb
+++ b/spec/workers/post_receive_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe PostReceive do
let(:changes) { "123456 789012 refs/heads/tést\n654321 210987 refs/tags/tag" }
@@ -9,7 +9,7 @@ describe PostReceive do
let!(:key_id) { key.shell_id }
let(:project) do
- create(:project, :repository, auto_cancel_pending_pipelines: 'disabled')
+ create(:project, :repository, auto_cancel_pending_pipelines: "disabled")
end
context "as a sidekiq worker" do
@@ -18,7 +18,7 @@ describe PostReceive do
end
end
- context 'with a non-existing project' do
+ context "with a non-existing project" do
let(:gl_repository) { "project-123456789" }
let(:error_message) do
"Triggered hook for non-existing project with gl_repository \"#{gl_repository}\""
@@ -31,7 +31,7 @@ describe PostReceive do
end
describe "#process_project_changes" do
- context 'empty changes' do
+ context "empty changes" do
it "does not call any PushService but runs after project hooks" do
expect(GitPushService).not_to receive(:new)
expect(GitTagPushService).not_to receive(:new)
@@ -41,10 +41,10 @@ describe PostReceive do
end
end
- context 'unidentified user' do
+ context "unidentified user" do
let!(:key_id) { "" }
- it 'returns false' do
+ it "returns false" do
expect(GitPushService).not_to receive(:new)
expect(GitTagPushService).not_to receive(:new)
@@ -52,7 +52,7 @@ describe PostReceive do
end
end
- context 'with changes' do
+ context "with changes" do
before do
allow_any_instance_of(Gitlab::GitPostReceive).to receive(:identify).and_return(project.owner)
end
@@ -117,9 +117,9 @@ describe PostReceive do
end
end
- context 'after project changes hooks' do
- let(:changes) { '123456 789012 refs/heads/tést' }
- let(:fake_hook_data) { Hash.new(event_name: 'repository_update') }
+ context "after project changes hooks" do
+ let(:changes) { "123456 789012 refs/heads/tést" }
+ let(:fake_hook_data) { Hash.new(event_name: "repository_update") }
before do
allow_any_instance_of(Gitlab::DataBuilder::Repository).to receive(:update).and_return(fake_hook_data)
@@ -128,7 +128,7 @@ describe PostReceive do
allow_any_instance_of(GitPushService).to receive(:execute).and_return(true)
end
- it 'calls SystemHooksService' do
+ it "calls SystemHooksService" do
expect_any_instance_of(SystemHooksService).to receive(:execute_hooks).with(fake_hook_data, :repository_update_hooks).and_return(true)
described_class.new.perform(gl_repository, key_id, base64_changes)
@@ -137,21 +137,21 @@ describe PostReceive do
end
end
- describe '#process_wiki_changes' do
+ describe "#process_wiki_changes" do
let(:gl_repository) { "wiki-#{project.id}" }
- it 'updates project activity' do
+ it "updates project activity" do
# Force Project#set_timestamps_for_create to initialize timestamps
project
# MySQL drops milliseconds in the timestamps, so advance at least
# a second to ensure we see changes.
Timecop.freeze(1.second.from_now) do
- expect do
+ expect {
described_class.new.perform(gl_repository, key_id, base64_changes)
project.reload
- end.to change(project, :last_activity_at)
- .and change(project, :last_repository_updated_at)
+ }.to change(project, :last_activity_at)
+ .and change(project, :last_repository_updated_at)
end
end
end
diff --git a/spec/workers/process_commit_worker_spec.rb b/spec/workers/process_commit_worker_spec.rb
index 2d071c181c2..eddd1ea3f0b 100644
--- a/spec/workers/process_commit_worker_spec.rb
+++ b/spec/workers/process_commit_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProcessCommitWorker do
include ProjectForksHelper
@@ -9,34 +9,34 @@ describe ProcessCommitWorker do
let(:issue) { create(:issue, project: project, author: user) }
let(:commit) { project.commit }
- describe '#perform' do
- it 'does not process the commit when the project does not exist' do
+ describe "#perform" do
+ it "does not process the commit when the project does not exist" do
expect(worker).not_to receive(:close_issues)
worker.perform(-1, user.id, commit.to_hash)
end
- it 'does not process the commit when the user does not exist' do
+ it "does not process the commit when the user does not exist" do
expect(worker).not_to receive(:close_issues)
worker.perform(project.id, -1, commit.to_hash)
end
- it 'processes the commit message' do
+ it "processes the commit message" do
expect(worker).to receive(:process_commit_message).and_call_original
worker.perform(project.id, user.id, commit.to_hash)
end
- it 'updates the issue metrics' do
+ it "updates the issue metrics" do
expect(worker).to receive(:update_issue_metrics).and_call_original
worker.perform(project.id, user.id, commit.to_hash)
end
- context 'when the project is forked' do
- context 'when commit already exists in the upstream project' do
- it 'does not process the commit message' do
+ context "when the project is forked" do
+ context "when commit already exists in the upstream project" do
+ it "does not process the commit message" do
forked = fork_project(project, user, repository: true)
expect(worker).not_to receive(:process_commit_message)
@@ -45,14 +45,14 @@ describe ProcessCommitWorker do
end
end
- context 'when the commit does not exist in the upstream project' do
- it 'processes the commit message' do
+ context "when the commit does not exist in the upstream project" do
+ it "processes the commit message" do
empty_project = create(:project, :public)
forked = fork_project(empty_project, user, repository: true)
TestEnv.copy_repo(forked,
- bare_repo: TestEnv.factory_repo_path_bare,
- refs: TestEnv::BRANCH_SHA)
+ bare_repo: TestEnv.factory_repo_path_bare,
+ refs: TestEnv::BRANCH_SHA)
expect(worker).to receive(:process_commit_message)
@@ -60,8 +60,8 @@ describe ProcessCommitWorker do
end
end
- context 'when the upstream project no longer exists' do
- it 'processes the commit message' do
+ context "when the upstream project no longer exists" do
+ it "processes the commit message" do
forked = fork_project(project, user, repository: true)
project.destroy!
@@ -73,27 +73,27 @@ describe ProcessCommitWorker do
end
end
- describe '#process_commit_message' do
- context 'when pushing to the default branch' do
+ describe "#process_commit_message" do
+ context "when pushing to the default branch" do
before do
allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
end
- it 'closes issues that should be closed per the commit message' do
+ it "closes issues that should be closed per the commit message" do
expect(worker).to receive(:close_issues).with(project, user, user, commit, [issue])
worker.process_commit_message(project, commit, user, user, true)
end
- it 'creates cross references' do
+ it "creates cross references" do
expect(commit).to receive(:create_cross_references!).with(user, [issue])
worker.process_commit_message(project, commit, user, user, true)
end
end
- context 'when pushing to a non-default branch' do
- it 'does not close any issues' do
+ context "when pushing to a non-default branch" do
+ it "does not close any issues" do
allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
expect(worker).not_to receive(:close_issues)
@@ -101,24 +101,24 @@ describe ProcessCommitWorker do
worker.process_commit_message(project, commit, user, user, false)
end
- it 'does not create cross references' do
+ it "does not create cross references" do
expect(commit).to receive(:create_cross_references!).with(user, [])
worker.process_commit_message(project, commit, user, user, false)
end
end
- context 'when commit is a merge request merge commit to the default branch' do
+ context "when commit is a merge request merge commit to the default branch" do
let(:merge_request) do
create(:merge_request,
- description: "Closes #{issue.to_reference}",
- source_branch: 'feature-merged',
- target_branch: 'master',
- source_project: project)
+ description: "Closes #{issue.to_reference}",
+ source_branch: "feature-merged",
+ target_branch: "master",
+ source_project: project)
end
let(:commit) do
- project.repository.create_branch('feature-merged', 'feature')
+ project.repository.create_branch("feature-merged", "feature")
MergeRequests::MergeService
.new(project, merge_request.author)
@@ -127,13 +127,13 @@ describe ProcessCommitWorker do
merge_request.reload.merge_commit
end
- it 'does not close any issues from the commit message' do
+ it "does not close any issues from the commit message" do
expect(worker).not_to receive(:close_issues)
worker.process_commit_message(project, commit, user, user, true)
end
- it 'still creates cross references' do
+ it "still creates cross references" do
expect(commit).to receive(:create_cross_references!).with(user, [])
worker.process_commit_message(project, commit, user, user, true)
@@ -141,9 +141,9 @@ describe ProcessCommitWorker do
end
end
- describe '#close_issues' do
- context 'when the user can update the issues' do
- it 'closes the issues' do
+ describe "#close_issues" do
+ context "when the user can update the issues" do
+ it "closes the issues" do
worker.close_issues(project, user, user, commit, [issue])
issue.reload
@@ -152,8 +152,8 @@ describe ProcessCommitWorker do
end
end
- context 'when the user can not update the issues' do
- it 'does not close the issues' do
+ context "when the user can not update the issues" do
+ it "does not close the issues" do
other_user = create(:user)
worker.close_issues(project, other_user, other_user, commit, [issue])
@@ -165,8 +165,8 @@ describe ProcessCommitWorker do
end
end
- describe '#update_issue_metrics' do
- it 'updates any existing issue metrics' do
+ describe "#update_issue_metrics" do
+ it "updates any existing issue metrics" do
allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
worker.update_issue_metrics(commit, user)
@@ -184,17 +184,17 @@ describe ProcessCommitWorker do
end
end
- describe '#build_commit' do
- it 'returns a Commit' do
- commit = worker.build_commit(project, id: '123')
+ describe "#build_commit" do
+ it "returns a Commit" do
+ commit = worker.build_commit(project, id: "123")
expect(commit).to be_an_instance_of(Commit)
end
- it 'parses date strings into Time instances' do
+ it "parses date strings into Time instances" do
commit = worker.build_commit(project,
- id: '123',
- authored_date: Time.now.to_s)
+ id: "123",
+ authored_date: Time.now.to_s)
expect(commit.authored_date).to be_an_instance_of(Time)
end
diff --git a/spec/workers/project_cache_worker_spec.rb b/spec/workers/project_cache_worker_spec.rb
index b9b5445562f..754dccab16a 100644
--- a/spec/workers/project_cache_worker_spec.rb
+++ b/spec/workers/project_cache_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectCacheWorker do
include ExclusiveLeaseHelpers
@@ -9,21 +9,21 @@ describe ProjectCacheWorker do
let(:lease_key) { "project_cache_worker:#{project.id}:update_statistics" }
let(:lease_timeout) { ProjectCacheWorker::LEASE_TIMEOUT }
- describe '#perform' do
+ describe "#perform" do
before do
stub_exclusive_lease(lease_key, timeout: lease_timeout)
end
- context 'with a non-existing project' do
- it 'does nothing' do
+ context "with a non-existing project" do
+ it "does nothing" do
expect(worker).not_to receive(:update_statistics)
worker.perform(-1)
end
end
- context 'with an existing project without a repository' do
- it 'does nothing' do
+ context "with an existing project without a repository" do
+ it "does nothing" do
allow_any_instance_of(Repository).to receive(:exists?).and_return(false)
expect(worker).not_to receive(:update_statistics)
@@ -32,40 +32,40 @@ describe ProjectCacheWorker do
end
end
- context 'with an existing project' do
- it 'updates the project statistics' do
+ context "with an existing project" do
+ it "updates the project statistics" do
expect(worker).to receive(:update_statistics)
- .with(kind_of(Project), %i(repository_size))
+ .with(kind_of(Project), %i[repository_size])
.and_call_original
- worker.perform(project.id, [], %w(repository_size))
+ worker.perform(project.id, [], %w[repository_size])
end
- it 'refreshes the method caches' do
+ it "refreshes the method caches" do
expect_any_instance_of(Repository).to receive(:refresh_method_caches)
- .with(%i(readme))
+ .with(%i[readme])
.and_call_original
- worker.perform(project.id, %w(readme))
+ worker.perform(project.id, %w[readme])
end
- context 'with plain readme' do
- it 'refreshes the method caches' do
+ context "with plain readme" do
+ it "refreshes the method caches" do
allow(MarkupHelper).to receive(:gitlab_markdown?).and_return(false)
allow(MarkupHelper).to receive(:plain?).and_return(true)
expect_any_instance_of(Repository).to receive(:refresh_method_caches)
- .with(%i(readme))
- .and_call_original
- worker.perform(project.id, %w(readme))
+ .with(%i[readme])
+ .and_call_original
+ worker.perform(project.id, %w[readme])
end
end
end
end
- describe '#update_statistics' do
- context 'when a lease could not be obtained' do
- it 'does not update the repository size' do
+ describe "#update_statistics" do
+ context "when a lease could not be obtained" do
+ it "does not update the repository size" do
stub_exclusive_lease_taken(lease_key, timeout: lease_timeout)
expect(statistics).not_to receive(:refresh!)
@@ -74,15 +74,15 @@ describe ProjectCacheWorker do
end
end
- context 'when a lease could be obtained' do
- it 'updates the project statistics' do
+ context "when a lease could be obtained" do
+ it "updates the project statistics" do
stub_exclusive_lease(lease_key, timeout: lease_timeout)
expect(statistics).to receive(:refresh!)
- .with(only: %i(repository_size))
+ .with(only: %i[repository_size])
.and_call_original
- worker.update_statistics(project, %i(repository_size))
+ worker.update_statistics(project, %i[repository_size])
end
end
end
diff --git a/spec/workers/project_daily_statistics_worker_spec.rb b/spec/workers/project_daily_statistics_worker_spec.rb
index 8640add99e5..fe19778a685 100644
--- a/spec/workers/project_daily_statistics_worker_spec.rb
+++ b/spec/workers/project_daily_statistics_worker_spec.rb
@@ -1,28 +1,29 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe ProjectDailyStatisticsWorker, '#perform' do
+require "spec_helper"
+
+describe ProjectDailyStatisticsWorker, "#perform" do
let(:worker) { described_class.new }
let(:project) { create(:project) }
- describe '#perform' do
- context 'with a non-existing project' do
- it 'does nothing' do
+ describe "#perform" do
+ context "with a non-existing project" do
+ it "does nothing" do
expect(Projects::FetchStatisticsIncrementService).not_to receive(:new)
worker.perform(-1)
end
end
- context 'with an existing project without a repository' do
- it 'does nothing' do
+ context "with an existing project without a repository" do
+ it "does nothing" do
expect(Projects::FetchStatisticsIncrementService).not_to receive(:new)
worker.perform(project.id)
end
end
- it 'calls daily_statistics_service with the given project' do
+ it "calls daily_statistics_service with the given project" do
project = create(:project, :repository)
expect_next_instance_of(Projects::FetchStatisticsIncrementService, project) do |service|
diff --git a/spec/workers/project_destroy_worker_spec.rb b/spec/workers/project_destroy_worker_spec.rb
index 6132f145f8d..e27653e0ddb 100644
--- a/spec/workers/project_destroy_worker_spec.rb
+++ b/spec/workers/project_destroy_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectDestroyWorker do
let(:project) { create(:project, :repository, pending_delete: true) }
@@ -10,24 +10,24 @@ describe ProjectDestroyWorker do
subject { described_class.new }
- describe '#perform' do
- it 'deletes the project' do
+ describe "#perform" do
+ it "deletes the project" do
subject.perform(project.id, project.owner.id, {})
expect(Project.all).not_to include(project)
expect(Dir.exist?(path)).to be_falsey
end
- it 'does not raise error when project could not be found' do
- expect do
+ it "does not raise error when project could not be found" do
+ expect {
subject.perform(-1, project.owner.id, {})
- end.not_to raise_error
+ }.not_to raise_error
end
- it 'does not raise error when user could not be found' do
- expect do
+ it "does not raise error when user could not be found" do
+ expect {
subject.perform(project.id, -1, {})
- end.not_to raise_error
+ }.not_to raise_error
end
end
end
diff --git a/spec/workers/project_export_worker_spec.rb b/spec/workers/project_export_worker_spec.rb
index 8899969c178..7cf1d172624 100644
--- a/spec/workers/project_export_worker_spec.rb
+++ b/spec/workers/project_export_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectExportWorker do
let!(:user) { create(:user) }
@@ -6,22 +6,22 @@ describe ProjectExportWorker do
subject { described_class.new }
- describe '#perform' do
- context 'when it succeeds' do
- it 'calls the ExportService' do
+ describe "#perform" do
+ context "when it succeeds" do
+ it "calls the ExportService" do
expect_any_instance_of(::Projects::ImportExport::ExportService).to receive(:execute)
- subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' })
+ subject.perform(user.id, project.id, {"klass" => "Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy"})
end
end
- context 'when it fails' do
- it 'raises an exception when params are invalid' do
+ context "when it fails" do
+ it "raises an exception when params are invalid" do
expect_any_instance_of(::Projects::ImportExport::ExportService).not_to receive(:execute)
expect { subject.perform(1234, project.id, {}) }.to raise_exception(ActiveRecord::RecordNotFound)
expect { subject.perform(user.id, 1234, {}) }.to raise_exception(ActiveRecord::RecordNotFound)
- expect { subject.perform(user.id, project.id, { 'klass' => 'Whatever' }) }.to raise_exception(Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError)
+ expect { subject.perform(user.id, project.id, {"klass" => "Whatever"}) }.to raise_exception(Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError)
end
end
end
diff --git a/spec/workers/project_migrate_hashed_storage_worker_spec.rb b/spec/workers/project_migrate_hashed_storage_worker_spec.rb
index 333eb6a0569..e34e829e7a1 100644
--- a/spec/workers/project_migrate_hashed_storage_worker_spec.rb
+++ b/spec/workers/project_migrate_hashed_storage_worker_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe ProjectMigrateHashedStorageWorker, :clean_gitlab_redis_shared_state do
include ExclusiveLeaseHelpers
- describe '#perform' do
+ describe "#perform" do
let(:project) { create(:project, :empty_repo, :legacy_storage) }
let(:lease_key) { "project_migrate_hashed_storage_worker:#{project.id}" }
let(:lease_timeout) { described_class::LEASE_TIMEOUT }
let(:migration_service) { ::Projects::HashedStorage::MigrationService }
- it 'skips when project no longer exists' do
+ it "skips when project no longer exists" do
expect(migration_service).not_to receive(:new)
subject.perform(-1)
end
- it 'skips when project is pending delete' do
+ it "skips when project is pending delete" do
pending_delete_project = create(:project, :empty_repo, pending_delete: true)
expect(migration_service).not_to receive(:new)
@@ -23,8 +23,8 @@ describe ProjectMigrateHashedStorageWorker, :clean_gitlab_redis_shared_state do
subject.perform(pending_delete_project.id)
end
- it 'delegates migration to service class when we have exclusive lease' do
- stub_exclusive_lease(lease_key, 'uuid', timeout: lease_timeout)
+ it "delegates migration to service class when we have exclusive lease" do
+ stub_exclusive_lease(lease_key, "uuid", timeout: lease_timeout)
service_spy = spy
@@ -37,7 +37,7 @@ describe ProjectMigrateHashedStorageWorker, :clean_gitlab_redis_shared_state do
expect(service_spy).to have_received(:execute)
end
- it 'skips when it cant acquire the exclusive lease' do
+ it "skips when it cant acquire the exclusive lease" do
stub_exclusive_lease_taken(lease_key, timeout: lease_timeout)
expect(migration_service).not_to receive(:new)
diff --git a/spec/workers/project_service_worker_spec.rb b/spec/workers/project_service_worker_spec.rb
index 56934f122e4..b82f580c1fb 100644
--- a/spec/workers/project_service_worker_spec.rb
+++ b/spec/workers/project_service_worker_spec.rb
@@ -1,7 +1,8 @@
# frozen_string_literal: true
-require 'spec_helper'
-describe ProjectServiceWorker, '#perform' do
+require "spec_helper"
+
+describe ProjectServiceWorker, "#perform" do
let(:worker) { described_class.new }
let(:service) { JiraService.new }
@@ -9,16 +10,16 @@ describe ProjectServiceWorker, '#perform' do
allow(Service).to receive(:find).and_return(service)
end
- it 'executes service with given data' do
- data = { test: 'test' }
+ it "executes service with given data" do
+ data = {test: "test"}
expect(service).to receive(:execute).with(data)
worker.perform(1, data)
end
- it 'logs error messages' do
- allow(service).to receive(:execute).and_raise(StandardError, 'invalid URL')
- expect(Sidekiq.logger).to receive(:error).with({ class: described_class.name, service_class: service.class.name, message: "invalid URL" })
+ it "logs error messages" do
+ allow(service).to receive(:execute).and_raise(StandardError, "invalid URL")
+ expect(Sidekiq.logger).to receive(:error).with({class: described_class.name, service_class: service.class.name, message: "invalid URL"})
worker.perform(1, {})
end
diff --git a/spec/workers/propagate_service_template_worker_spec.rb b/spec/workers/propagate_service_template_worker_spec.rb
index af1fb80a51d..0d0797b066b 100644
--- a/spec/workers/propagate_service_template_worker_spec.rb
+++ b/spec/workers/propagate_service_template_worker_spec.rb
@@ -1,20 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
describe PropagateServiceTemplateWorker do
include ExclusiveLeaseHelpers
- describe '#perform' do
- it 'calls the propagate service with the template' do
+ describe "#perform" do
+ it "calls the propagate service with the template" do
template = PushoverService.create(
template: true,
active: true,
properties: {
- device: 'MyDevice',
- sound: 'mic',
+ device: "MyDevice",
+ sound: "mic",
priority: 4,
- user_key: 'asdf',
- api_key: '123456789'
- })
+ user_key: "asdf",
+ api_key: "123456789",
+ }
+ )
stub_exclusive_lease("propagate_service_template_worker:#{template.id}",
timeout: PropagateServiceTemplateWorker::LEASE_TIMEOUT)
diff --git a/spec/workers/prune_old_events_worker_spec.rb b/spec/workers/prune_old_events_worker_spec.rb
index ea2b6ae229e..d395b0d4620 100644
--- a/spec/workers/prune_old_events_worker_spec.rb
+++ b/spec/workers/prune_old_events_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe PruneOldEventsWorker do
- describe '#perform' do
+ describe "#perform" do
let(:user) { create(:user) }
let!(:expired_event) { create(:event, :closed, author: user, created_at: 25.months.ago) }
@@ -9,22 +9,22 @@ describe PruneOldEventsWorker do
let!(:not_expired_13_month_event) { create(:event, :closed, author: user, created_at: 13.months.ago) }
let!(:not_expired_2_years_event) { create(:event, :closed, author: user, created_at: 2.years.ago) }
- it 'prunes events older than 2 years' do
+ it "prunes events older than 2 years" do
expect { subject.perform }.to change { Event.count }.by(-1)
expect(Event.find_by(id: expired_event.id)).to be_nil
end
- it 'leaves fresh events' do
+ it "leaves fresh events" do
subject.perform
expect(not_expired_1_day_event.reload).to be_present
end
- it 'leaves events from 13 months ago' do
+ it "leaves events from 13 months ago" do
subject.perform
expect(not_expired_13_month_event.reload).to be_present
end
- it 'leaves events from 2 years ago' do
+ it "leaves events from 2 years ago" do
subject.perform
expect(not_expired_2_years_event).to be_present
end
diff --git a/spec/workers/prune_web_hook_logs_worker_spec.rb b/spec/workers/prune_web_hook_logs_worker_spec.rb
index b3ec71d4a00..a608235a1b5 100644
--- a/spec/workers/prune_web_hook_logs_worker_spec.rb
+++ b/spec/workers/prune_web_hook_logs_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe PruneWebHookLogsWorker do
- describe '#perform' do
+ describe "#perform" do
before do
hook = create(:project_hook)
@@ -11,14 +11,14 @@ describe PruneWebHookLogsWorker do
create(:web_hook_log, web_hook: hook, created_at: 89.days.ago)
create(:web_hook_log, web_hook: hook, created_at: 2.months.ago)
create(:web_hook_log, web_hook: hook, created_at: 1.month.ago)
- create(:web_hook_log, web_hook: hook, response_status: '404')
+ create(:web_hook_log, web_hook: hook, response_status: "404")
end
- it 'removes all web hook logs older than 90 days' do
+ it "removes all web hook logs older than 90 days" do
described_class.new.perform
expect(WebHookLog.count).to eq(4)
- expect(WebHookLog.last.response_status).to eq('404')
+ expect(WebHookLog.last.response_status).to eq("404")
end
end
end
diff --git a/spec/workers/reactive_caching_worker_spec.rb b/spec/workers/reactive_caching_worker_spec.rb
index 3da851de067..56368e1a477 100644
--- a/spec/workers/reactive_caching_worker_spec.rb
+++ b/spec/workers/reactive_caching_worker_spec.rb
@@ -1,24 +1,24 @@
-require 'spec_helper'
+require "spec_helper"
describe ReactiveCachingWorker do
let(:service) { project.deployment_platform }
- describe '#perform' do
- context 'when user configured kubernetes from Integration > Kubernetes' do
+ describe "#perform" do
+ context "when user configured kubernetes from Integration > Kubernetes" do
let(:project) { create(:kubernetes_project) }
- it 'calls #exclusively_update_reactive_cache!' do
+ it "calls #exclusively_update_reactive_cache!" do
expect_any_instance_of(KubernetesService).to receive(:exclusively_update_reactive_cache!)
described_class.new.perform("KubernetesService", service.id)
end
end
- context 'when user configured kubernetes from CI/CD > Clusters' do
+ context "when user configured kubernetes from CI/CD > Clusters" do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) }
let(:project) { cluster.project }
- it 'calls #exclusively_update_reactive_cache!' do
+ it "calls #exclusively_update_reactive_cache!" do
expect_any_instance_of(Clusters::Platforms::Kubernetes).to receive(:exclusively_update_reactive_cache!)
described_class.new.perform("Clusters::Platforms::Kubernetes", service.id)
diff --git a/spec/workers/rebase_worker_spec.rb b/spec/workers/rebase_worker_spec.rb
index 900332ed6b3..ab7b7c91f34 100644
--- a/spec/workers/rebase_worker_spec.rb
+++ b/spec/workers/rebase_worker_spec.rb
@@ -1,21 +1,21 @@
-require 'spec_helper'
+require "spec_helper"
-describe RebaseWorker, '#perform' do
+describe RebaseWorker, "#perform" do
include ProjectForksHelper
- context 'when rebasing an MR from a fork where upstream has protected branches' do
+ context "when rebasing an MR from a fork where upstream has protected branches" do
let(:upstream_project) { create(:project, :repository) }
let(:forked_project) { fork_project(upstream_project, nil, repository: true) }
let(:merge_request) do
create(:merge_request,
- source_project: forked_project,
- source_branch: 'feature_conflict',
- target_project: upstream_project,
- target_branch: 'master')
+ source_project: forked_project,
+ source_branch: "feature_conflict",
+ target_project: upstream_project,
+ target_branch: "master")
end
- it 'sets the correct project for running hooks' do
+ it "sets the correct project for running hooks" do
expect(MergeRequests::RebaseService)
.to receive(:new).with(forked_project, merge_request.author).and_call_original
diff --git a/spec/workers/remote_mirror_notification_worker_spec.rb b/spec/workers/remote_mirror_notification_worker_spec.rb
index e3db10ed645..649a79697d5 100644
--- a/spec/workers/remote_mirror_notification_worker_spec.rb
+++ b/spec/workers/remote_mirror_notification_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe RemoteMirrorNotificationWorker, :mailer do
set(:project) { create(:project, :repository, :remote_mirror) }
set(:mirror) { project.remote_mirrors.first }
- describe '#execute' do
- it 'calls NotificationService#remote_mirror_update_failed when the mirror exists' do
+ describe "#execute" do
+ it "calls NotificationService#remote_mirror_update_failed when the mirror exists" do
mirror.update_column(:last_error, "There was a problem fetching")
expect(NotificationService).to receive_message_chain(:new, :remote_mirror_update_failed)
@@ -15,19 +15,19 @@ describe RemoteMirrorNotificationWorker, :mailer do
expect(mirror.reload.error_notification_sent?).to be_truthy
end
- it 'does nothing when the mirror has no errors' do
+ it "does nothing when the mirror has no errors" do
expect(NotificationService).not_to receive(:new)
subject.perform(mirror.id)
end
- it 'does nothing when the mirror does not exist' do
+ it "does nothing when the mirror does not exist" do
expect(NotificationService).not_to receive(:new)
subject.perform(RemoteMirror.maximum(:id).to_i.succ)
end
- it 'does nothing when a notification has already been sent' do
+ it "does nothing when a notification has already been sent" do
mirror.update_columns(last_error: "There was a problem fetching",
error_notification_sent: true)
diff --git a/spec/workers/remove_expired_group_links_worker_spec.rb b/spec/workers/remove_expired_group_links_worker_spec.rb
index 689bc3d27b4..d573918e9b4 100644
--- a/spec/workers/remove_expired_group_links_worker_spec.rb
+++ b/spec/workers/remove_expired_group_links_worker_spec.rb
@@ -1,22 +1,22 @@
-require 'spec_helper'
+require "spec_helper"
describe RemoveExpiredGroupLinksWorker do
- describe '#perform' do
+ describe "#perform" do
let!(:expired_project_group_link) { create(:project_group_link, expires_at: 1.hour.ago) }
let!(:project_group_link_expiring_in_future) { create(:project_group_link, expires_at: 10.days.from_now) }
let!(:non_expiring_project_group_link) { create(:project_group_link, expires_at: nil) }
- it 'removes expired group links' do
+ it "removes expired group links" do
expect { subject.perform }.to change { ProjectGroupLink.count }.by(-1)
expect(ProjectGroupLink.find_by(id: expired_project_group_link.id)).to be_nil
end
- it 'leaves group links that expire in the future' do
+ it "leaves group links that expire in the future" do
subject.perform
expect(project_group_link_expiring_in_future.reload).to be_present
end
- it 'leaves group links that do not expire at all' do
+ it "leaves group links that do not expire at all" do
subject.perform
expect(non_expiring_project_group_link.reload).to be_present
end
diff --git a/spec/workers/remove_expired_members_worker_spec.rb b/spec/workers/remove_expired_members_worker_spec.rb
index 058fdf4c009..2dfb0e6b8ae 100644
--- a/spec/workers/remove_expired_members_worker_spec.rb
+++ b/spec/workers/remove_expired_members_worker_spec.rb
@@ -1,55 +1,55 @@
-require 'spec_helper'
+require "spec_helper"
describe RemoveExpiredMembersWorker do
let(:worker) { described_class.new }
- describe '#perform' do
- context 'project members' do
+ describe "#perform" do
+ context "project members" do
let!(:expired_project_member) { create(:project_member, expires_at: 1.hour.ago, access_level: GroupMember::DEVELOPER) }
let!(:project_member_expiring_in_future) { create(:project_member, expires_at: 10.days.from_now, access_level: GroupMember::DEVELOPER) }
let!(:non_expiring_project_member) { create(:project_member, expires_at: nil, access_level: GroupMember::DEVELOPER) }
- it 'removes expired members' do
+ it "removes expired members" do
expect { worker.perform }.to change { Member.count }.by(-1)
expect(Member.find_by(id: expired_project_member.id)).to be_nil
end
- it 'leaves members that expire in the future' do
+ it "leaves members that expire in the future" do
worker.perform
expect(project_member_expiring_in_future.reload).to be_present
end
- it 'leaves members that do not expire at all' do
+ it "leaves members that do not expire at all" do
worker.perform
expect(non_expiring_project_member.reload).to be_present
end
end
- context 'group members' do
+ context "group members" do
let!(:expired_group_member) { create(:group_member, expires_at: 1.hour.ago, access_level: GroupMember::DEVELOPER) }
let!(:group_member_expiring_in_future) { create(:group_member, expires_at: 10.days.from_now, access_level: GroupMember::DEVELOPER) }
let!(:non_expiring_group_member) { create(:group_member, expires_at: nil, access_level: GroupMember::DEVELOPER) }
- it 'removes expired members' do
+ it "removes expired members" do
expect { worker.perform }.to change { Member.count }.by(-1)
expect(Member.find_by(id: expired_group_member.id)).to be_nil
end
- it 'leaves members that expire in the future' do
+ it "leaves members that expire in the future" do
worker.perform
expect(group_member_expiring_in_future.reload).to be_present
end
- it 'leaves members that do not expire at all' do
+ it "leaves members that do not expire at all" do
worker.perform
expect(non_expiring_group_member.reload).to be_present
end
end
- context 'when the last group owner expires' do
+ context "when the last group owner expires" do
let!(:expired_group_owner) { create(:group_member, expires_at: 1.hour.ago, access_level: GroupMember::OWNER) }
- it 'does not delete the owner' do
+ it "does not delete the owner" do
worker.perform
expect(expired_group_owner.reload).to be_present
end
diff --git a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
index 57f83c1dbe9..6ce487c27ef 100644
--- a/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
+++ b/spec/workers/remove_unreferenced_lfs_objects_worker_spec.rb
@@ -1,49 +1,46 @@
-require 'spec_helper'
+require "spec_helper"
describe RemoveUnreferencedLfsObjectsWorker do
let(:worker) { described_class.new }
- describe '#perform' do
- let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: '1') }
- let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: '2') }
+ describe "#perform" do
+ let!(:unreferenced_lfs_object1) { create(:lfs_object, oid: "1") }
+ let!(:unreferenced_lfs_object2) { create(:lfs_object, oid: "2") }
let!(:project1) { create(:project, lfs_enabled: true) }
let!(:project2) { create(:project, lfs_enabled: true) }
- let!(:referenced_lfs_object1) { create(:lfs_object, oid: '3') }
- let!(:referenced_lfs_object2) { create(:lfs_object, oid: '4') }
+ let!(:referenced_lfs_object1) { create(:lfs_object, oid: "3") }
+ let!(:referenced_lfs_object2) { create(:lfs_object, oid: "4") }
let!(:lfs_objects_project1_1) do
create(:lfs_objects_project,
- project: project1,
- lfs_object: referenced_lfs_object1
- )
+ project: project1,
+ lfs_object: referenced_lfs_object1)
end
let!(:lfs_objects_project2_1) do
create(:lfs_objects_project,
- project: project2,
- lfs_object: referenced_lfs_object1
- )
+ project: project2,
+ lfs_object: referenced_lfs_object1)
end
let!(:lfs_objects_project1_2) do
create(:lfs_objects_project,
- project: project1,
- lfs_object: referenced_lfs_object2
- )
+ project: project1,
+ lfs_object: referenced_lfs_object2)
end
- it 'removes unreferenced lfs objects' do
+ it "removes unreferenced lfs objects" do
worker.perform
expect(LfsObject.where(id: unreferenced_lfs_object1.id)).to be_empty
expect(LfsObject.where(id: unreferenced_lfs_object2.id)).to be_empty
end
- it 'leaves referenced lfs objects' do
+ it "leaves referenced lfs objects" do
worker.perform
expect(referenced_lfs_object1.reload).to be_present
expect(referenced_lfs_object2.reload).to be_present
end
- it 'removes unreferenced lfs objects after project removal' do
+ it "removes unreferenced lfs objects after project removal" do
project1.destroy
worker.perform
diff --git a/spec/workers/repository_check/batch_worker_spec.rb b/spec/workers/repository_check/batch_worker_spec.rb
index 50b93fce2dc..84b18004428 100644
--- a/spec/workers/repository_check/batch_worker_spec.rb
+++ b/spec/workers/repository_check/batch_worker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryCheck::BatchWorker do
- let(:shard_name) { 'default' }
+ let(:shard_name) { "default" }
subject { described_class.new }
before do
Gitlab::ShardHealthCache.update([shard_name])
end
- it 'prefers projects that have never been checked' do
+ it "prefers projects that have never been checked" do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 4.months.ago)
projects[2].update_column(:last_repository_check_at, 3.months.ago)
@@ -16,7 +16,7 @@ describe RepositoryCheck::BatchWorker do
expect(subject.perform(shard_name)).to eq(projects.values_at(1, 0, 2).map(&:id))
end
- it 'sorts projects by last_repository_check_at' do
+ it "sorts projects by last_repository_check_at" do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.months.ago)
projects[1].update_column(:last_repository_check_at, 4.months.ago)
@@ -25,7 +25,7 @@ describe RepositoryCheck::BatchWorker do
expect(subject.perform(shard_name)).to eq(projects.values_at(1, 2, 0).map(&:id))
end
- it 'excludes projects that were checked recently' do
+ it "excludes projects that were checked recently" do
projects = create_list(:project, 3, created_at: 1.week.ago)
projects[0].update_column(:last_repository_check_at, 2.days.ago)
projects[1].update_column(:last_repository_check_at, 2.months.ago)
@@ -34,14 +34,14 @@ describe RepositoryCheck::BatchWorker do
expect(subject.perform(shard_name)).to eq([projects[1].id])
end
- it 'excludes projects on another shard' do
+ it "excludes projects on another shard" do
projects = create_list(:project, 2, created_at: 1.week.ago)
- projects[0].update_column(:repository_storage, 'other')
+ projects[0].update_column(:repository_storage, "other")
expect(subject.perform(shard_name)).to eq([projects[1].id])
end
- it 'does nothing when repository checks are disabled' do
+ it "does nothing when repository checks are disabled" do
create(:project, created_at: 1.week.ago)
stub_application_setting(repository_checks_enabled: false)
@@ -49,21 +49,21 @@ describe RepositoryCheck::BatchWorker do
expect(subject.perform(shard_name)).to eq(nil)
end
- it 'does nothing when shard is unhealthy' do
- shard_name = 'broken'
+ it "does nothing when shard is unhealthy" do
+ shard_name = "broken"
create(:project, :broken_storage, created_at: 1.week.ago)
expect(subject.perform(shard_name)).to eq(nil)
end
- it 'skips projects created less than 24 hours ago' do
+ it "skips projects created less than 24 hours ago" do
project = create(:project)
project.update_column(:created_at, 23.hours.ago)
expect(subject.perform(shard_name)).to eq([])
end
- it 'does not run if the exclusive lease is taken' do
+ it "does not run if the exclusive lease is taken" do
allow(subject).to receive(:try_obtain_lease).and_return(false)
expect(subject).not_to receive(:perform_repository_checks)
diff --git a/spec/workers/repository_check/clear_worker_spec.rb b/spec/workers/repository_check/clear_worker_spec.rb
index 1c49415d46c..ebcdd540ec3 100644
--- a/spec/workers/repository_check/clear_worker_spec.rb
+++ b/spec/workers/repository_check/clear_worker_spec.rb
@@ -1,7 +1,7 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryCheck::ClearWorker do
- it 'clears repository check columns' do
+ it "clears repository check columns" do
project = create(:project)
project.update_columns(
last_repository_check_failed: true,
diff --git a/spec/workers/repository_check/dispatch_worker_spec.rb b/spec/workers/repository_check/dispatch_worker_spec.rb
index 7877429aa8f..efd0e08506a 100644
--- a/spec/workers/repository_check/dispatch_worker_spec.rb
+++ b/spec/workers/repository_check/dispatch_worker_spec.rb
@@ -1,9 +1,9 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryCheck::DispatchWorker do
subject { described_class.new }
- it 'does nothing when repository checks are disabled' do
+ it "does nothing when repository checks are disabled" do
stub_application_setting(repository_checks_enabled: false)
expect(RepositoryCheck::BatchWorker).not_to receive(:perform_async)
@@ -11,7 +11,7 @@ describe RepositoryCheck::DispatchWorker do
subject.perform
end
- it 'does nothing if the exclusive lease is taken' do
+ it "does nothing if the exclusive lease is taken" do
allow(subject).to receive(:try_obtain_lease).and_return(false)
expect(RepositoryCheck::BatchWorker).not_to receive(:perform_async)
@@ -19,24 +19,24 @@ describe RepositoryCheck::DispatchWorker do
subject.perform
end
- it 'dispatches work to RepositoryCheck::BatchWorker' do
+ it "dispatches work to RepositoryCheck::BatchWorker" do
expect(RepositoryCheck::BatchWorker).to receive(:perform_async).at_least(:once)
subject.perform
end
- context 'with unhealthy shard' do
- let(:default_shard_name) { 'default' }
- let(:unhealthy_shard_name) { 'unhealthy' }
+ context "with unhealthy shard" do
+ let(:default_shard_name) { "default" }
+ let(:unhealthy_shard_name) { "unhealthy" }
let(:default_shard) { Gitlab::HealthChecks::Result.new(true, nil, shard: default_shard_name) }
- let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new(false, '14:Connect Failed', shard: unhealthy_shard_name) }
+ let(:unhealthy_shard) { Gitlab::HealthChecks::Result.new(false, "14:Connect Failed", shard: unhealthy_shard_name) }
before do
allow(Gitlab::HealthChecks::GitalyCheck).to receive(:readiness).and_return([default_shard, unhealthy_shard])
end
- it 'only triggers RepositoryCheck::BatchWorker for healthy shards' do
- expect(RepositoryCheck::BatchWorker).to receive(:perform_async).with('default')
+ it "only triggers RepositoryCheck::BatchWorker for healthy shards" do
+ expect(RepositoryCheck::BatchWorker).to receive(:perform_async).with("default")
subject.perform
end
diff --git a/spec/workers/repository_check/single_repository_worker_spec.rb b/spec/workers/repository_check/single_repository_worker_spec.rb
index f11875cffd1..6a3f84d40ce 100644
--- a/spec/workers/repository_check/single_repository_worker_spec.rb
+++ b/spec/workers/repository_check/single_repository_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
-require 'fileutils'
+require "spec_helper"
+require "fileutils"
describe RepositoryCheck::SingleRepositoryWorker do
subject(:worker) { described_class.new }
- it 'skips when the project has no push events' do
+ it "skips when the project has no push events" do
project = create(:project, :repository, :wiki_disabled)
project.events.destroy_all # rubocop: disable DestroyAll
break_project(project)
@@ -16,7 +16,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(false)
end
- it 'fails when the project has push events and a broken repository' do
+ it "fails when the project has push events and a broken repository" do
project = create(:project, :repository)
create_push_event(project)
break_project(project)
@@ -26,20 +26,20 @@ describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(true)
end
- it 'succeeds when the project repo is valid' do
+ it "succeeds when the project repo is valid" do
project = create(:project, :repository, :wiki_disabled)
create_push_event(project)
expect(worker).to receive(:git_fsck).and_call_original
- expect do
+ expect {
worker.perform(project.id)
- end.to change { project.reload.last_repository_check_at }
+ }.to change { project.reload.last_repository_check_at }
expect(project.reload.last_repository_check_failed).to eq(false)
end
- it 'fails if the wiki repository is broken' do
+ it "fails if the wiki repository is broken" do
project = create(:project, :repository, :wiki_enabled)
project.create_wiki
create_push_event(project)
@@ -54,7 +54,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(true)
end
- it 'skips wikis when disabled' do
+ it "skips wikis when disabled" do
project = create(:project, :wiki_disabled)
# Make sure the test would fail if the wiki repo was checked
break_wiki(project)
@@ -64,7 +64,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(false)
end
- it 'creates missing wikis' do
+ it "creates missing wikis" do
project = create(:project, :wiki_enabled)
Gitlab::Shell.new.rm_directory(project.repository_storage, project.wiki.path)
@@ -73,7 +73,7 @@ describe RepositoryCheck::SingleRepositoryWorker do
expect(project.reload.last_repository_check_failed).to eq(false)
end
- it 'does not create a wiki if the main repo does not exist at all' do
+ it "does not create a wiki if the main repo does not exist at all" do
project = create(:project, :repository)
Gitlab::Shell.new.rm_directory(project.repository_storage, project.path)
Gitlab::Shell.new.rm_directory(project.repository_storage, project.wiki.path)
@@ -106,8 +106,8 @@ describe RepositoryCheck::SingleRepositoryWorker do
def break_repo(repo)
# Create or replace blob ffffffffffffffffffffffffffffffffffffffff with an empty file
# This will make the repo invalid, _and_ 'git init' cannot fix it.
- path = File.join(repo, 'objects', 'ff')
- file = File.join(path, 'ffffffffffffffffffffffffffffffffffffff')
+ path = File.join(repo, "objects", "ff")
+ file = File.join(path, "ffffffffffffffffffffffffffffffffffffff")
FileUtils.mkdir_p(path)
FileUtils.rm_f(file)
diff --git a/spec/workers/repository_cleanup_worker_spec.rb b/spec/workers/repository_cleanup_worker_spec.rb
index 3adae0b6cfa..1d30e8db474 100644
--- a/spec/workers/repository_cleanup_worker_spec.rb
+++ b/spec/workers/repository_cleanup_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryCleanupWorker do
let(:project) { create(:project) }
@@ -6,8 +6,8 @@ describe RepositoryCleanupWorker do
subject(:worker) { described_class.new }
- describe '#perform' do
- it 'executes the cleanup service and sends a success notification' do
+ describe "#perform" do
+ it "executes the cleanup service and sends a success notification" do
expect_next_instance_of(Projects::CleanupService) do |service|
expect(service.project).to eq(project)
expect(service.current_user).to eq(user)
@@ -22,31 +22,31 @@ describe RepositoryCleanupWorker do
worker.perform(project.id, user.id)
end
- it 'raises an error if the project cannot be found' do
+ it "raises an error if the project cannot be found" do
project.destroy
expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
- it 'raises an error if the user cannot be found' do
+ it "raises an error if the user cannot be found" do
user.destroy
expect { worker.perform(project.id, user.id) }.to raise_error(ActiveRecord::RecordNotFound)
end
end
- describe '#sidekiq_retries_exhausted' do
- let(:job) { { 'args' => [project.id, user.id], 'error_message' => 'Error' } }
+ describe "#sidekiq_retries_exhausted" do
+ let(:job) { {"args" => [project.id, user.id], "error_message" => "Error"} }
- it 'does not send a failure notification for a RecordNotFound error' do
+ it "does not send a failure notification for a RecordNotFound error" do
expect(NotificationService).not_to receive(:new)
described_class.sidekiq_retries_exhausted_block.call(job, ActiveRecord::RecordNotFound.new)
end
- it 'sends a failure notification' do
+ it "sends a failure notification" do
expect_next_instance_of(NotificationService) do |service|
- expect(service).to receive(:repository_cleanup_failure).with(project, user, 'Error')
+ expect(service).to receive(:repository_cleanup_failure).with(project, user, "Error")
end
described_class.sidekiq_retries_exhausted_block.call(job, StandardError.new)
diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb
index 31bfe88d0bd..be4a2fca764 100644
--- a/spec/workers/repository_fork_worker_spec.rb
+++ b/spec/workers/repository_fork_worker_spec.rb
@@ -1,10 +1,10 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryForkWorker do
include ProjectForksHelper
- describe 'modules' do
- it 'includes ProjectImportOptions' do
+ describe "modules" do
+ it "includes ProjectImportOptions" do
expect(described_class).to include_module(ProjectImportOptions)
end
end
@@ -18,7 +18,7 @@ describe RepositoryForkWorker do
fork_project(project, forked_project.creator, target_project: forked_project, repository: true)
end
- shared_examples 'RepositoryForkWorker performing' do
+ shared_examples "RepositoryForkWorker performing" do
before do
allow(subject).to receive(:gitlab_shell).and_return(shell)
end
@@ -27,10 +27,10 @@ describe RepositoryForkWorker do
expect(shell).to receive(:fork_repository).with(project, forked_project)
end
- describe 'when a worker was reset without cleanup' do
- let(:jid) { '12345678' }
+ describe "when a worker was reset without cleanup" do
+ let(:jid) { "12345678" }
- it 'creates a new repository from a fork' do
+ it "creates a new repository from a fork" do
allow(subject).to receive(:jid).and_return(jid)
expect_fork_repository.and_return(true)
@@ -45,7 +45,7 @@ describe RepositoryForkWorker do
perform!
end
- it 'protects the default branch' do
+ it "protects the default branch" do
expect_fork_repository.and_return(true)
perform!
@@ -53,7 +53,7 @@ describe RepositoryForkWorker do
expect(forked_project.protected_branches.first.name).to eq(forked_project.default_branch)
end
- it 'flushes various caches' do
+ it "flushes various caches" do
expect_fork_repository.and_return(true)
# Works around https://github.com/rspec/rspec-mocks/issues/910
@@ -79,20 +79,20 @@ describe RepositoryForkWorker do
end
end
- context 'only project ID passed' do
+ context "only project ID passed" do
def perform!
subject.perform(forked_project.id)
end
- it_behaves_like 'RepositoryForkWorker performing'
+ it_behaves_like "RepositoryForkWorker performing"
end
- context 'project ID, storage and repo paths passed' do
+ context "project ID, storage and repo paths passed" do
def perform!
subject.perform(forked_project.id, TestEnv.repos_path, project.disk_path)
end
- it_behaves_like 'RepositoryForkWorker performing'
+ it_behaves_like "RepositoryForkWorker performing"
end
end
end
diff --git a/spec/workers/repository_import_worker_spec.rb b/spec/workers/repository_import_worker_spec.rb
index 87ac4bc05c1..d3cae4a116b 100644
--- a/spec/workers/repository_import_worker_spec.rb
+++ b/spec/workers/repository_import_worker_spec.rb
@@ -1,26 +1,26 @@
-require 'spec_helper'
+require "spec_helper"
describe RepositoryImportWorker do
- describe 'modules' do
- it 'includes ProjectImportOptions' do
+ describe "modules" do
+ it "includes ProjectImportOptions" do
expect(described_class).to include_module(ProjectImportOptions)
end
end
- describe '#perform' do
+ describe "#perform" do
let(:project) { create(:project, :import_scheduled) }
let(:import_state) { project.import_state }
- context 'when worker was reset without cleanup' do
- it 'imports the project successfully' do
- jid = '12345678'
+ context "when worker was reset without cleanup" do
+ it "imports the project successfully" do
+ jid = "12345678"
started_project = create(:project)
started_import_state = create(:import_state, :started, project: started_project, jid: jid)
allow(subject).to receive(:jid).and_return(jid)
expect_any_instance_of(Projects::ImportService).to receive(:execute)
- .and_return({ status: :ok })
+ .and_return({status: :ok})
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(started_project.id).and_return(started_project)
@@ -32,10 +32,10 @@ describe RepositoryImportWorker do
end
end
- context 'when the import was successful' do
- it 'imports a project' do
+ context "when the import was successful" do
+ it "imports a project" do
expect_any_instance_of(Projects::ImportService).to receive(:execute)
- .and_return({ status: :ok })
+ .and_return({status: :ok})
# Works around https://github.com/rspec/rspec-mocks/issues/910
expect(Project).to receive(:find).with(project.id).and_return(project)
@@ -47,36 +47,36 @@ describe RepositoryImportWorker do
end
end
- context 'when the import has failed' do
- it 'hide the credentials that were used in the import URL' do
- error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
+ context "when the import has failed" do
+ it "hide the credentials that were used in the import URL" do
+ error = "remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found "
- import_state.update(jid: '123')
- expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error })
+ import_state.update(jid: "123")
+ expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({status: :error, message: error})
- expect do
+ expect {
subject.perform(project.id)
- end.to raise_error(RuntimeError, error)
+ }.to raise_error(RuntimeError, error)
expect(import_state.reload.jid).not_to be_nil
end
- it 'updates the error on Import/Export' do
- error = %q{remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found }
+ it "updates the error on Import/Export" do
+ error = "remote: Not Found fatal: repository 'https://user:pass@test.com/root/repoC.git/' not found "
- project.update(import_type: 'gitlab_project')
- import_state.update(jid: '123')
- expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({ status: :error, message: error })
+ project.update(import_type: "gitlab_project")
+ import_state.update(jid: "123")
+ expect_any_instance_of(Projects::ImportService).to receive(:execute).and_return({status: :error, message: error})
- expect do
+ expect {
subject.perform(project.id)
- end.to raise_error(RuntimeError, error)
+ }.to raise_error(RuntimeError, error)
expect(import_state.reload.last_error).not_to be_nil
end
end
- context 'when using an asynchronous importer' do
- it 'does not mark the import process as finished' do
+ context "when using an asynchronous importer" do
+ it "does not mark the import process as finished" do
service = double(:service)
allow(Projects::ImportService)
diff --git a/spec/workers/repository_remove_remote_worker_spec.rb b/spec/workers/repository_remove_remote_worker_spec.rb
index 6ddb653d142..b0509533bf6 100644
--- a/spec/workers/repository_remove_remote_worker_spec.rb
+++ b/spec/workers/repository_remove_remote_worker_spec.rb
@@ -1,20 +1,20 @@
-require 'rails_helper'
+require "rails_helper"
describe RepositoryRemoveRemoteWorker do
include ExclusiveLeaseHelpers
include GitHelpers
- describe '#perform' do
+ describe "#perform" do
let!(:project) { create(:project, :repository) }
- let(:remote_name) { 'joe'}
+ let(:remote_name) { "joe"}
let(:lease_key) { "remove_remote_#{project.id}_#{remote_name}" }
let(:lease_timeout) { RepositoryRemoveRemoteWorker::LEASE_TIMEOUT }
- it 'returns nil when project does not exist' do
- expect(subject.perform(-1, 'remote_name')).to be_nil
+ it "returns nil when project does not exist" do
+ expect(subject.perform(-1, "remote_name")).to be_nil
end
- context 'when project exists' do
+ context "when project exists" do
before do
allow(Project)
.to receive(:find_by)
@@ -22,7 +22,7 @@ describe RepositoryRemoveRemoteWorker do
.and_return(project)
end
- it 'does not remove remote when cannot obtain lease' do
+ it "does not remove remote when cannot obtain lease" do
stub_exclusive_lease_taken(lease_key, timeout: lease_timeout)
expect(project.repository)
@@ -30,15 +30,15 @@ describe RepositoryRemoveRemoteWorker do
expect(subject)
.to receive(:log_error)
- .with('Cannot obtain an exclusive lease. There must be another instance already in execution.')
+ .with("Cannot obtain an exclusive lease. There must be another instance already in execution.")
subject.perform(project.id, remote_name)
end
- it 'removes remote from repository when obtain a lease' do
+ it "removes remote from repository when obtain a lease" do
stub_exclusive_lease(lease_key, timeout: lease_timeout)
- masterrev = project.repository.find_branch('master').dereferenced_target
- create_remote_branch(remote_name, 'remote_branch', masterrev)
+ masterrev = project.repository.find_branch("master").dereferenced_target
+ create_remote_branch(remote_name, "remote_branch", masterrev)
expect(project.repository)
.to receive(:remove_remote)
diff --git a/spec/workers/repository_update_remote_mirror_worker_spec.rb b/spec/workers/repository_update_remote_mirror_worker_spec.rb
index b582a3650b6..f9eaefedb77 100644
--- a/spec/workers/repository_update_remote_mirror_worker_spec.rb
+++ b/spec/workers/repository_update_remote_mirror_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'rails_helper'
+require "rails_helper"
describe RepositoryUpdateRemoteMirrorWorker do
subject { described_class.new }
@@ -10,27 +10,27 @@ describe RepositoryUpdateRemoteMirrorWorker do
Timecop.freeze(Time.now) { example.run }
end
- describe '#perform' do
- context 'with status none' do
+ describe "#perform" do
+ context "with status none" do
before do
- remote_mirror.update(update_status: 'none')
+ remote_mirror.update(update_status: "none")
end
- it 'sets status as finished when update remote mirror service executes successfully' do
+ it "sets status as finished when update remote mirror service executes successfully" do
expect_any_instance_of(Projects::UpdateRemoteMirrorService).to receive(:execute).with(remote_mirror).and_return(status: :success)
- expect { subject.perform(remote_mirror.id, Time.now) }.to change { remote_mirror.reload.update_status }.to('finished')
+ expect { subject.perform(remote_mirror.id, Time.now) }.to change { remote_mirror.reload.update_status }.to("finished")
end
- it 'resets the notification flag upon success' do
+ it "resets the notification flag upon success" do
expect_any_instance_of(Projects::UpdateRemoteMirrorService).to receive(:execute).with(remote_mirror).and_return(status: :success)
remote_mirror.update_column(:error_notification_sent, true)
expect { subject.perform(remote_mirror.id, Time.now) }.to change { remote_mirror.reload.error_notification_sent }.to(false)
end
- it 'sets status as failed when update remote mirror service executes with errors' do
- error_message = 'fail!'
+ it "sets status as failed when update remote mirror service executes with errors" do
+ error_message = "fail!"
expect_next_instance_of(Projects::UpdateRemoteMirrorService) do |service|
expect(service).to receive(:execute).with(remote_mirror).and_return(status: :error, message: error_message)
@@ -42,12 +42,12 @@ describe RepositoryUpdateRemoteMirrorWorker do
end
expect(remote_mirror).to receive(:mark_as_failed).with(error_message)
- expect do
+ expect {
subject.perform(remote_mirror.id, Time.now)
- end.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateError, error_message)
+ }.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateError, error_message)
end
- it 'does nothing if last_update_started_at is higher than the time the job was scheduled in' do
+ it "does nothing if last_update_started_at is higher than the time the job was scheduled in" do
remote_mirror.update(last_update_started_at: Time.now)
expect_any_instance_of(RemoteMirror).to receive(:updated_since?).with(scheduled_time).and_return(true)
@@ -57,41 +57,41 @@ describe RepositoryUpdateRemoteMirrorWorker do
end
end
- context 'with unexpected error' do
- it 'marks mirror as failed' do
+ context "with unexpected error" do
+ it "marks mirror as failed" do
allow_any_instance_of(Projects::UpdateRemoteMirrorService).to receive(:execute).with(remote_mirror).and_raise(RuntimeError)
- expect do
+ expect {
subject.perform(remote_mirror.id, Time.now)
- end.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateError)
- expect(remote_mirror.reload.update_status).to eq('failed')
+ }.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateError)
+ expect(remote_mirror.reload.update_status).to eq("failed")
end
end
- context 'with another worker already running' do
+ context "with another worker already running" do
before do
- remote_mirror.update(update_status: 'started')
+ remote_mirror.update(update_status: "started")
end
- it 'raises RemoteMirrorUpdateAlreadyInProgressError' do
- expect do
+ it "raises RemoteMirrorUpdateAlreadyInProgressError" do
+ expect {
subject.perform(remote_mirror.id, Time.now)
- end.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateAlreadyInProgressError)
+ }.to raise_error(RepositoryUpdateRemoteMirrorWorker::UpdateAlreadyInProgressError)
end
end
- context 'with status failed' do
+ context "with status failed" do
before do
- remote_mirror.update(update_status: 'failed')
+ remote_mirror.update(update_status: "failed")
end
- it 'sets status as finished if last_update_started_at is higher than the time the job was scheduled in' do
+ it "sets status as finished if last_update_started_at is higher than the time the job was scheduled in" do
remote_mirror.update(last_update_started_at: Time.now)
expect_any_instance_of(RemoteMirror).to receive(:updated_since?).with(scheduled_time).and_return(false)
expect_any_instance_of(Projects::UpdateRemoteMirrorService).to receive(:execute).with(remote_mirror).and_return(status: :success)
- expect { subject.perform(remote_mirror.id, scheduled_time) }.to change { remote_mirror.reload.update_status }.to('finished')
+ expect { subject.perform(remote_mirror.id, scheduled_time) }.to change { remote_mirror.reload.update_status }.to("finished")
end
end
end
diff --git a/spec/workers/run_pipeline_schedule_worker_spec.rb b/spec/workers/run_pipeline_schedule_worker_spec.rb
index 481a84837f9..50a34ce7f45 100644
--- a/spec/workers/run_pipeline_schedule_worker_spec.rb
+++ b/spec/workers/run_pipeline_schedule_worker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe RunPipelineScheduleWorker do
- describe '#perform' do
+ describe "#perform" do
set(:project) { create(:project) }
set(:user) { create(:user) }
- set(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project ) }
+ set(:pipeline_schedule) { create(:ci_pipeline_schedule, :nightly, project: project) }
let(:worker) { described_class.new }
- context 'when a project not found' do
- it 'does not call the Service' do
+ context "when a project not found" do
+ it "does not call the Service" do
expect(Ci::CreatePipelineService).not_to receive(:new)
expect(worker).not_to receive(:run_pipeline_schedule)
@@ -16,8 +16,8 @@ describe RunPipelineScheduleWorker do
end
end
- context 'when a user not found' do
- it 'does not call the Service' do
+ context "when a user not found" do
+ it "does not call the Service" do
expect(Ci::CreatePipelineService).not_to receive(:new)
expect(worker).not_to receive(:run_pipeline_schedule)
@@ -25,10 +25,10 @@ describe RunPipelineScheduleWorker do
end
end
- context 'when everything is ok' do
+ context "when everything is ok" do
let(:create_pipeline_service) { instance_double(Ci::CreatePipelineService) }
- it 'calls the Service' do
+ it "calls the Service" do
expect(Ci::CreatePipelineService).to receive(:new).with(project, user, ref: pipeline_schedule.ref).and_return(create_pipeline_service)
expect(create_pipeline_service).to receive(:execute).with(:schedule, ignore_skip_ci: true, save_on_errors: false, schedule: pipeline_schedule)
diff --git a/spec/workers/stage_update_worker_spec.rb b/spec/workers/stage_update_worker_spec.rb
index 7bc76c79464..1679796d3e6 100644
--- a/spec/workers/stage_update_worker_spec.rb
+++ b/spec/workers/stage_update_worker_spec.rb
@@ -1,19 +1,19 @@
-require 'spec_helper'
+require "spec_helper"
describe StageUpdateWorker do
- describe '#perform' do
- context 'when stage exists' do
+ describe "#perform" do
+ context "when stage exists" do
let(:stage) { create(:ci_stage_entity) }
- it 'updates stage status' do
+ it "updates stage status" do
expect_any_instance_of(Ci::Stage).to receive(:update_status)
described_class.new.perform(stage.id)
end
end
- context 'when stage does not exist' do
- it 'does not raise exception' do
+ context "when stage does not exist" do
+ it "does not raise exception" do
expect { described_class.new.perform(123) }
.not_to raise_error
end
diff --git a/spec/workers/stuck_ci_jobs_worker_spec.rb b/spec/workers/stuck_ci_jobs_worker_spec.rb
index e09b8e5b964..87972e9c128 100644
--- a/spec/workers/stuck_ci_jobs_worker_spec.rb
+++ b/spec/workers/stuck_ci_jobs_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe StuckCiJobsWorker do
include ExclusiveLeaseHelpers
@@ -18,7 +18,7 @@ describe StuckCiJobsWorker do
job.update!(status: status, updated_at: updated_at)
end
- shared_examples 'job is dropped' do
+ shared_examples "job is dropped" do
before do
worker.perform
job.reload
@@ -30,7 +30,7 @@ describe StuckCiJobsWorker do
end
end
- shared_examples 'job is unchanged' do
+ shared_examples "job is unchanged" do
before do
worker.perform
job.reload
@@ -41,100 +41,100 @@ describe StuckCiJobsWorker do
end
end
- context 'when job is pending' do
- let(:status) { 'pending' }
+ context "when job is pending" do
+ let(:status) { "pending" }
- context 'when job is not stuck' do
+ context "when job is not stuck" do
before do
allow_any_instance_of(Ci::Build).to receive(:stuck?).and_return(false)
end
- context 'when job was not updated for more than 1 day ago' do
+ context "when job was not updated for more than 1 day ago" do
let(:updated_at) { 2.days.ago }
- it_behaves_like 'job is dropped'
+ it_behaves_like "job is dropped"
end
- context 'when job was updated in less than 1 day ago' do
+ context "when job was updated in less than 1 day ago" do
let(:updated_at) { 6.hours.ago }
- it_behaves_like 'job is unchanged'
+ it_behaves_like "job is unchanged"
end
- context 'when job was not updated for more than 1 hour ago' do
+ context "when job was not updated for more than 1 hour ago" do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'job is unchanged'
+ it_behaves_like "job is unchanged"
end
end
- context 'when job is stuck' do
+ context "when job is stuck" do
before do
allow_any_instance_of(Ci::Build).to receive(:stuck?).and_return(true)
end
- context 'when job was not updated for more than 1 hour ago' do
+ context "when job was not updated for more than 1 hour ago" do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'job is dropped'
+ it_behaves_like "job is dropped"
end
context 'when job was updated in less than 1
hour ago' do
let(:updated_at) { 30.minutes.ago }
- it_behaves_like 'job is unchanged'
+ it_behaves_like "job is unchanged"
end
end
end
- context 'when job is running' do
- let(:status) { 'running' }
+ context "when job is running" do
+ let(:status) { "running" }
- context 'when job was not updated for more than 1 hour ago' do
+ context "when job was not updated for more than 1 hour ago" do
let(:updated_at) { 2.hours.ago }
- it_behaves_like 'job is dropped'
+ it_behaves_like "job is dropped"
end
- context 'when job was updated in less than 1 hour ago' do
+ context "when job was updated in less than 1 hour ago" do
let(:updated_at) { 30.minutes.ago }
- it_behaves_like 'job is unchanged'
+ it_behaves_like "job is unchanged"
end
end
- %w(success skipped failed canceled).each do |status|
+ %w[success skipped failed canceled].each do |status|
context "when job is #{status}" do
let(:status) { status }
let(:updated_at) { 2.days.ago }
- it_behaves_like 'job is unchanged'
+ it_behaves_like "job is unchanged"
end
end
- context 'for deleted project' do
- let(:status) { 'running' }
+ context "for deleted project" do
+ let(:status) { "running" }
let(:updated_at) { 2.days.ago }
before do
job.project.update(pending_delete: true)
end
- it 'does drop job' do
+ it "does drop job" do
expect_any_instance_of(Ci::Build).to receive(:drop).and_call_original
worker.perform
end
end
- describe 'drop stale scheduled builds' do
- let(:status) { 'scheduled' }
+ describe "drop stale scheduled builds" do
+ let(:status) { "scheduled" }
let(:updated_at) { }
- context 'when scheduled at 2 hours ago but it is not executed yet' do
+ context "when scheduled at 2 hours ago but it is not executed yet" do
let!(:job) { create(:ci_build, :scheduled, scheduled_at: 2.hours.ago) }
- it 'drops the stale scheduled build' do
+ it "drops the stale scheduled build" do
expect(Ci::Build.scheduled.count).to eq(1)
expect(job).to be_scheduled
@@ -147,10 +147,10 @@ describe StuckCiJobsWorker do
end
end
- context 'when scheduled at 30 minutes ago but it is not executed yet' do
+ context "when scheduled at 30 minutes ago but it is not executed yet" do
let!(:job) { create(:ci_build, :scheduled, scheduled_at: 30.minutes.ago) }
- it 'does not drop the stale scheduled build yet' do
+ it "does not drop the stale scheduled build yet" do
expect(Ci::Build.scheduled.count).to eq(1)
expect(job).to be_scheduled
@@ -161,19 +161,19 @@ describe StuckCiJobsWorker do
end
end
- context 'when there are no stale scheduled builds' do
- it 'does not drop the stale scheduled build yet' do
+ context "when there are no stale scheduled builds" do
+ it "does not drop the stale scheduled build yet" do
expect { worker.perform }.not_to raise_error
end
end
end
- describe 'exclusive lease' do
- let(:status) { 'running' }
+ describe "exclusive lease" do
+ let(:status) { "running" }
let(:updated_at) { 2.days.ago }
let(:worker2) { described_class.new }
- it 'is guard by exclusive lease when executed concurrently' do
+ it "is guard by exclusive lease when executed concurrently" do
expect(worker).to receive(:drop).at_least(:once).and_call_original
expect(worker2).not_to receive(:drop)
@@ -184,7 +184,7 @@ describe StuckCiJobsWorker do
worker2.perform
end
- it 'can be executed in sequence' do
+ it "can be executed in sequence" do
expect(worker).to receive(:drop).at_least(:once).and_call_original
expect(worker2).to receive(:drop).at_least(:once).and_call_original
@@ -192,7 +192,7 @@ describe StuckCiJobsWorker do
worker2.perform
end
- it 'cancels exclusive leases after worker perform' do
+ it "cancels exclusive leases after worker perform" do
expect_to_cancel_exclusive_lease(trace_lease_key, trace_lease_uuid)
expect_to_cancel_exclusive_lease(worker_lease_key, worker_lease_uuid)
diff --git a/spec/workers/stuck_import_jobs_worker_spec.rb b/spec/workers/stuck_import_jobs_worker_spec.rb
index e94d2be9850..2ee6a24671a 100644
--- a/spec/workers/stuck_import_jobs_worker_spec.rb
+++ b/spec/workers/stuck_import_jobs_worker_spec.rb
@@ -1,11 +1,11 @@
-require 'spec_helper'
+require "spec_helper"
describe StuckImportJobsWorker do
let(:worker) { described_class.new }
- shared_examples 'project import job detection' do
- context 'when the job has completed' do
- context 'when the import status was already updated' do
+ shared_examples "project import job detection" do
+ context "when the job has completed" do
+ context "when the import status was already updated" do
before do
allow(Gitlab::SidekiqStatus).to receive(:completed_jids) do
import_state.start
@@ -15,53 +15,53 @@ describe StuckImportJobsWorker do
end
end
- it 'does not mark the project as failed' do
+ it "does not mark the project as failed" do
worker.perform
- expect(import_state.reload.status).to eq('finished')
+ expect(import_state.reload.status).to eq("finished")
end
end
- context 'when the import status was not updated' do
+ context "when the import status was not updated" do
before do
allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([import_state.jid])
end
- it 'marks the project as failed' do
+ it "marks the project as failed" do
worker.perform
- expect(import_state.reload.status).to eq('failed')
+ expect(import_state.reload.status).to eq("failed")
end
end
end
- context 'when the job is still in Sidekiq' do
+ context "when the job is still in Sidekiq" do
before do
allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([])
end
- it 'does not mark the project as failed' do
+ it "does not mark the project as failed" do
expect { worker.perform }.not_to change { import_state.reload.status }
end
end
end
- describe 'with scheduled import_status' do
- it_behaves_like 'project import job detection' do
+ describe "with scheduled import_status" do
+ it_behaves_like "project import job detection" do
let(:import_state) { create(:project, :import_scheduled).import_state }
before do
- import_state.update(jid: '123')
+ import_state.update(jid: "123")
end
end
end
- describe 'with started import_status' do
- it_behaves_like 'project import job detection' do
+ describe "with started import_status" do
+ it_behaves_like "project import job detection" do
let(:import_state) { create(:project, :import_started).import_state }
before do
- import_state.update(jid: '123')
+ import_state.update(jid: "123")
end
end
end
diff --git a/spec/workers/stuck_merge_jobs_worker_spec.rb b/spec/workers/stuck_merge_jobs_worker_spec.rb
index 5aaff27a6b2..1be1d9c2523 100644
--- a/spec/workers/stuck_merge_jobs_worker_spec.rb
+++ b/spec/workers/stuck_merge_jobs_worker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe StuckMergeJobsWorker do
- describe 'perform' do
+ describe "perform" do
let(:worker) { described_class.new }
- context 'merge job identified as completed' do
- it 'updates merge request to merged when locked but has merge_commit_sha' do
- allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123 456))
- mr_with_sha = create(:merge_request, :locked, merge_jid: '123', state: :locked, merge_commit_sha: 'foo-bar-baz')
- mr_without_sha = create(:merge_request, :locked, merge_jid: '123', state: :locked, merge_commit_sha: nil)
+ context "merge job identified as completed" do
+ it "updates merge request to merged when locked but has merge_commit_sha" do
+ allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w[123 456])
+ mr_with_sha = create(:merge_request, :locked, merge_jid: "123", state: :locked, merge_commit_sha: "foo-bar-baz")
+ mr_without_sha = create(:merge_request, :locked, merge_jid: "123", state: :locked, merge_commit_sha: nil)
worker.perform
@@ -20,9 +20,9 @@ describe StuckMergeJobsWorker do
expect(mr_without_sha.merge_jid).to be_nil
end
- it 'updates merge request to opened when locked but has not been merged' do
- allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123))
- merge_request = create(:merge_request, :locked, merge_jid: '123', state: :locked)
+ it "updates merge request to opened when locked but has not been merged" do
+ allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w[123])
+ merge_request = create(:merge_request, :locked, merge_jid: "123", state: :locked)
pipeline = create(:ci_empty_pipeline, project: merge_request.project, ref: merge_request.source_branch, sha: merge_request.source_branch_sha)
worker.perform
@@ -32,26 +32,26 @@ describe StuckMergeJobsWorker do
expect(merge_request.head_pipeline).to eq(pipeline)
end
- it 'logs updated stuck merge job ids' do
- allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w(123 456))
+ it "logs updated stuck merge job ids" do
+ allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return(%w[123 456])
- create(:merge_request, :locked, merge_jid: '123')
- create(:merge_request, :locked, merge_jid: '456')
+ create(:merge_request, :locked, merge_jid: "123")
+ create(:merge_request, :locked, merge_jid: "456")
expect(described_class).to receive_message_chain(:logger, :info)
- .with('Updated state of locked merge jobs. JIDs: 123, 456')
+ .with("Updated state of locked merge jobs. JIDs: 123, 456")
worker.perform
end
end
- context 'merge job not identified as completed' do
- it 'does not change merge request state when job is not completed yet' do
+ context "merge job not identified as completed" do
+ it "does not change merge request state when job is not completed yet" do
allow(Gitlab::SidekiqStatus).to receive(:completed_jids).and_return([])
- merge_request = create(:merge_request, :locked, merge_jid: '123')
+ merge_request = create(:merge_request, :locked, merge_jid: "123")
- expect { worker.perform }.not_to change { merge_request.reload.state }.from('locked')
+ expect { worker.perform }.not_to change { merge_request.reload.state }.from("locked")
end
end
end
diff --git a/spec/workers/system_hook_push_worker_spec.rb b/spec/workers/system_hook_push_worker_spec.rb
index b1d446ed25f..a4e4a0ac8f5 100644
--- a/spec/workers/system_hook_push_worker_spec.rb
+++ b/spec/workers/system_hook_push_worker_spec.rb
@@ -1,14 +1,14 @@
-require 'spec_helper'
+require "spec_helper"
describe SystemHookPushWorker do
include RepoHelpers
subject { described_class.new }
- describe '#perform' do
- it 'executes SystemHooksService with expected values' do
- push_data = double('push_data')
- system_hook_service = double('system_hook_service')
+ describe "#perform" do
+ it "executes SystemHooksService with expected values" do
+ push_data = double("push_data")
+ system_hook_service = double("system_hook_service")
expect(SystemHooksService).to receive(:new).and_return(system_hook_service)
expect(system_hook_service).to receive(:execute_hooks).with(push_data, :push_hooks)
diff --git a/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb b/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb
index 9d7c0b8f560..28d84cee891 100644
--- a/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb
+++ b/spec/workers/todos_destroyer/confidential_issue_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosDestroyer::ConfidentialIssueWorker do
it "calls the Todos::Destroy::ConfidentialIssueService with the params it was given" do
diff --git a/spec/workers/todos_destroyer/entity_leave_worker_spec.rb b/spec/workers/todos_destroyer/entity_leave_worker_spec.rb
index 955447906aa..e917e71ffd2 100644
--- a/spec/workers/todos_destroyer/entity_leave_worker_spec.rb
+++ b/spec/workers/todos_destroyer/entity_leave_worker_spec.rb
@@ -1,12 +1,12 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosDestroyer::EntityLeaveWorker do
it "calls the Todos::Destroy::EntityLeaveService with the params it was given" do
service = double
- expect(::Todos::Destroy::EntityLeaveService).to receive(:new).with(100, 5, 'Group').and_return(service)
+ expect(::Todos::Destroy::EntityLeaveService).to receive(:new).with(100, 5, "Group").and_return(service)
expect(service).to receive(:execute)
- described_class.new.perform(100, 5, 'Group')
+ described_class.new.perform(100, 5, "Group")
end
end
diff --git a/spec/workers/todos_destroyer/group_private_worker_spec.rb b/spec/workers/todos_destroyer/group_private_worker_spec.rb
index fcc38989ced..fd7623d411e 100644
--- a/spec/workers/todos_destroyer/group_private_worker_spec.rb
+++ b/spec/workers/todos_destroyer/group_private_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosDestroyer::GroupPrivateWorker do
it "calls the Todos::Destroy::GroupPrivateService with the params it was given" do
diff --git a/spec/workers/todos_destroyer/private_features_worker_spec.rb b/spec/workers/todos_destroyer/private_features_worker_spec.rb
index 9599f5ee071..4e057cb6725 100644
--- a/spec/workers/todos_destroyer/private_features_worker_spec.rb
+++ b/spec/workers/todos_destroyer/private_features_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosDestroyer::PrivateFeaturesWorker do
it "calls the Todos::Destroy::PrivateFeaturesService with the params it was given" do
diff --git a/spec/workers/todos_destroyer/project_private_worker_spec.rb b/spec/workers/todos_destroyer/project_private_worker_spec.rb
index 15d926fa9d5..d00a41e05a6 100644
--- a/spec/workers/todos_destroyer/project_private_worker_spec.rb
+++ b/spec/workers/todos_destroyer/project_private_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe TodosDestroyer::ProjectPrivateWorker do
it "calls the Todos::Destroy::ProjectPrivateService with the params it was given" do
diff --git a/spec/workers/trending_projects_worker_spec.rb b/spec/workers/trending_projects_worker_spec.rb
index c3c6fdcf2d5..0224d6649e5 100644
--- a/spec/workers/trending_projects_worker_spec.rb
+++ b/spec/workers/trending_projects_worker_spec.rb
@@ -1,8 +1,8 @@
-require 'spec_helper'
+require "spec_helper"
describe TrendingProjectsWorker do
- describe '#perform' do
- it 'refreshes the trending projects' do
+ describe "#perform" do
+ it "refreshes the trending projects" do
expect(TrendingProject).to receive(:refresh!)
described_class.new.perform
diff --git a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb
index 963237ceadf..523c57c8943 100644
--- a/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb
+++ b/spec/workers/update_head_pipeline_for_merge_request_worker_spec.rb
@@ -1,61 +1,61 @@
-require 'spec_helper'
+require "spec_helper"
describe UpdateHeadPipelineForMergeRequestWorker do
- describe '#perform' do
+ describe "#perform" do
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:merge_request) { create(:merge_request, source_project: project) }
- let(:latest_sha) { 'b83d6e391c22777fca1ed3012fce84f633d7fed0' }
+ let(:latest_sha) { "b83d6e391c22777fca1ed3012fce84f633d7fed0" }
- context 'when pipeline exists for the source project and branch' do
+ context "when pipeline exists for the source project and branch" do
before do
create(:ci_empty_pipeline, project: project, ref: merge_request.source_branch, sha: latest_sha)
end
- it 'updates the head_pipeline_id of the merge_request' do
+ it "updates the head_pipeline_id of the merge_request" do
expect { subject.perform(merge_request.id) }.to change { merge_request.reload.head_pipeline_id }
end
- context 'when merge request sha does not equal pipeline sha' do
+ context "when merge request sha does not equal pipeline sha" do
before do
- merge_request.merge_request_diff.update(head_commit_sha: 'different_sha')
+ merge_request.merge_request_diff.update(head_commit_sha: "different_sha")
end
- it 'does not update head pipeline' do
+ it "does not update head pipeline" do
expect { subject.perform(merge_request.id) }
.not_to change { merge_request.reload.head_pipeline_id }
end
end
end
- context 'when pipeline does not exist for the source project and branch' do
- it 'does not update the head_pipeline_id of the merge_request' do
+ context "when pipeline does not exist for the source project and branch" do
+ it "does not update the head_pipeline_id of the merge_request" do
expect { subject.perform(merge_request.id) }
.not_to change { merge_request.reload.head_pipeline_id }
end
end
- context 'when a merge request pipeline exists' do
+ context "when a merge request pipeline exists" do
let!(:merge_request_pipeline) do
create(:ci_pipeline,
- project: project,
- source: :merge_request,
- sha: latest_sha,
- merge_request: merge_request)
+ project: project,
+ source: :merge_request,
+ sha: latest_sha,
+ merge_request: merge_request)
end
- it 'sets the merge request pipeline as the head pipeline' do
+ it "sets the merge request pipeline as the head pipeline" do
expect { subject.perform(merge_request.id) }
.to change { merge_request.reload.head_pipeline_id }
.from(nil).to(merge_request_pipeline.id)
end
- context 'when branch pipeline exists' do
+ context "when branch pipeline exists" do
let!(:branch_pipeline) do
create(:ci_pipeline, project: project, source: :push, sha: latest_sha)
end
- it 'prioritizes the merge request pipeline as the head pipeline' do
+ it "prioritizes the merge request pipeline as the head pipeline" do
expect { subject.perform(merge_request.id) }
.to change { merge_request.reload.head_pipeline_id }
.from(nil).to(merge_request_pipeline.id)
diff --git a/spec/workers/update_merge_requests_worker_spec.rb b/spec/workers/update_merge_requests_worker_spec.rb
index 0b553db0ca4..00bb4b8e3af 100644
--- a/spec/workers/update_merge_requests_worker_spec.rb
+++ b/spec/workers/update_merge_requests_worker_spec.rb
@@ -1,4 +1,4 @@
-require 'spec_helper'
+require "spec_helper"
describe UpdateMergeRequestsWorker do
include RepoHelpers
@@ -8,7 +8,7 @@ describe UpdateMergeRequestsWorker do
subject { described_class.new }
- describe '#perform' do
+ describe "#perform" do
let(:oldrev) { "123456" }
let(:newrev) { "789012" }
let(:ref) { "refs/heads/test" }
@@ -17,7 +17,7 @@ describe UpdateMergeRequestsWorker do
subject.perform(project.id, user.id, oldrev, newrev, ref)
end
- it 'executes MergeRequests::RefreshService with expected values' do
+ it "executes MergeRequests::RefreshService with expected values" do
expect_next_instance_of(MergeRequests::RefreshService, project, user) do |refresh_service|
expect(refresh_service).to receive(:execute).with(oldrev, newrev, ref)
end
@@ -25,12 +25,12 @@ describe UpdateMergeRequestsWorker do
perform
end
- context 'when slow' do
+ context "when slow" do
before do
stub_const("UpdateMergeRequestsWorker::LOG_TIME_THRESHOLD", -1)
end
- it 'logs debug info' do
+ it "logs debug info" do
expect(Rails.logger).to receive(:info).with(a_string_matching(/\AUpdateMergeRequestsWorker#perform.*project_id=#{project.id},user_id=#{user.id},oldrev=#{oldrev},newrev=#{newrev},ref=#{ref}/))
perform
diff --git a/spec/workers/upload_checksum_worker_spec.rb b/spec/workers/upload_checksum_worker_spec.rb
index 9e50ce15871..0c6ef5fa580 100644
--- a/spec/workers/upload_checksum_worker_spec.rb
+++ b/spec/workers/upload_checksum_worker_spec.rb
@@ -1,16 +1,16 @@
-require 'rails_helper'
+require "rails_helper"
describe UploadChecksumWorker do
- describe '#perform' do
+ describe "#perform" do
subject { described_class.new }
- context 'without a valid record' do
- it 'rescues ActiveRecord::RecordNotFound' do
+ context "without a valid record" do
+ it "rescues ActiveRecord::RecordNotFound" do
expect { subject.perform(999_999) }.not_to raise_error
end
end
- context 'with a valid record' do
+ context "with a valid record" do
let(:upload) { create(:user, :with_avatar).avatar.upload }
before do
@@ -18,12 +18,12 @@ describe UploadChecksumWorker do
allow(upload).to receive(:foreground_checksumable?).and_return(false)
end
- it 'calls calculate_checksum!' do
+ it "calls calculate_checksum!" do
expect(upload).to receive(:calculate_checksum!)
subject.perform(upload.id)
end
- it 'calls save!' do
+ it "calls save!" do
expect(upload).to receive(:save!)
subject.perform(upload.id)
end
diff --git a/spec/workers/wait_for_cluster_creation_worker_spec.rb b/spec/workers/wait_for_cluster_creation_worker_spec.rb
index 0e92b298178..26619cb7457 100644
--- a/spec/workers/wait_for_cluster_creation_worker_spec.rb
+++ b/spec/workers/wait_for_cluster_creation_worker_spec.rb
@@ -1,30 +1,30 @@
-require 'spec_helper'
+require "spec_helper"
describe WaitForClusterCreationWorker do
- describe '#perform' do
- context 'when provider type is gcp' do
+ describe "#perform" do
+ context "when provider type is gcp" do
let(:cluster) { create(:cluster, provider_type: :gcp, provider_gcp: provider) }
let(:provider) { create(:cluster_provider_gcp, :creating) }
- it 'provision a cluster' do
+ it "provision a cluster" do
expect_any_instance_of(Clusters::Gcp::VerifyProvisionStatusService).to receive(:execute)
described_class.new.perform(cluster.id)
end
end
- context 'when provider type is user' do
+ context "when provider type is user" do
let(:cluster) { create(:cluster, provider_type: :user) }
- it 'does not provision a cluster' do
+ it "does not provision a cluster" do
expect_any_instance_of(Clusters::Gcp::VerifyProvisionStatusService).not_to receive(:execute)
described_class.new.perform(cluster.id)
end
end
- context 'when cluster does not exist' do
- it 'does not provision a cluster' do
+ context "when cluster does not exist" do
+ it "does not provision a cluster" do
expect_any_instance_of(Clusters::Gcp::VerifyProvisionStatusService).not_to receive(:execute)
described_class.new.perform(123)